From b4109be58431bcd915d032d97c24a9119947da9c Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Fri, 28 Sep 2018 09:01:38 -0700 Subject: [PATCH 0001/1555] Confirm that generic API method name is not needed after call creation --- test/cpp/end2end/generic_end2end_test.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index 88a1227ca2e..0bdaf83618a 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -123,8 +123,16 @@ class GenericEnd2endTest : public ::testing::Test { cli_ctx.set_deadline(deadline); } + // Rather than using the original kMethodName, make a short-lived + // copy to also confirm that we don't refer to this object beyond + // the initial call preparation + const grpc::string* method_name = new grpc::string(kMethodName); + std::unique_ptr call = - generic_stub_->PrepareCall(&cli_ctx, kMethodName, &cli_cq_); + generic_stub_->PrepareCall(&cli_ctx, *method_name, &cli_cq_); + + delete method_name; // Make sure that this is not needed after invocation + call->StartCall(tag(1)); client_ok(1); std::unique_ptr send_buffer = From 1c766d5c6d2ddec146f3140eeefff7557ecd8228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zden=C4=9Bk=20Sojma?= Date: Tue, 6 Nov 2018 15:03:15 +0100 Subject: [PATCH 0002/1555] ability to set "no_proxy" with use of "no_grpc_proxy" environment variable --- src/core/ext/filters/client_channel/http_proxy.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/ext/filters/client_channel/http_proxy.cc b/src/core/ext/filters/client_channel/http_proxy.cc index 8951a2920c4..3f05b23ffaf 100644 --- a/src/core/ext/filters/client_channel/http_proxy.cc +++ b/src/core/ext/filters/client_channel/http_proxy.cc @@ -122,7 +122,10 @@ static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper, server_uri); goto no_use_proxy; } - no_proxy_str = gpr_getenv("no_proxy"); + no_proxy_str = gpr_getenv("no_grpc_proxy"); + if (no_proxy_str == nullptr) { + no_proxy_str = gpr_getenv("no_proxy"); + } if (no_proxy_str != nullptr) { static const char* NO_PROXY_SEPARATOR = ","; bool use_proxy = true; From c2ddef218fb066fd217432ac3703720d4671cdf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zden=C4=9Bk=20Sojma?= Date: Tue, 6 Nov 2018 15:16:56 +0100 Subject: [PATCH 0003/1555] ability to set proxy with use of "grpc_proxy" environment variable --- src/core/ext/filters/client_channel/http_proxy.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/ext/filters/client_channel/http_proxy.cc b/src/core/ext/filters/client_channel/http_proxy.cc index 3f05b23ffaf..94ef2c55ec8 100644 --- a/src/core/ext/filters/client_channel/http_proxy.cc +++ b/src/core/ext/filters/client_channel/http_proxy.cc @@ -47,10 +47,12 @@ static char* get_http_proxy_server(char** user_cred) { char* proxy_name = nullptr; char** authority_strs = nullptr; size_t authority_nstrs; - /* Prefer using 'https_proxy'. Fallback on 'http_proxy' if it is not set. The + /* Prefer using 'grpc_proxy'. Fallback on 'http_proxy' if it is not set. + * Also prefer using 'https_proxy' with fallback on 'http_proxy'. The * fallback behavior can be removed if there's a demand for it. */ - char* uri_str = gpr_getenv("https_proxy"); + char* uri_str = gpr_getenv("grpc_proxy"); + if (uri_str == nullptr) uri_str = gpr_getenv("https_proxy"); if (uri_str == nullptr) uri_str = gpr_getenv("http_proxy"); if (uri_str == nullptr) return nullptr; grpc_uri* uri = grpc_uri_parse(uri_str, false /* suppress_errors */); @@ -122,6 +124,7 @@ static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper, server_uri); goto no_use_proxy; } + /* Prefer using 'no_grpc_proxy'. Fallback on 'no_proxy' if it is not set. */ no_proxy_str = gpr_getenv("no_grpc_proxy"); if (no_proxy_str == nullptr) { no_proxy_str = gpr_getenv("no_proxy"); From 43279fc50ba83296fb43234aeab67910e68e7fbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zden=C4=9Bk=20Sojma?= Date: Tue, 6 Nov 2018 15:24:40 +0100 Subject: [PATCH 0004/1555] coding style update --- src/core/ext/filters/client_channel/http_proxy.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/core/ext/filters/client_channel/http_proxy.cc b/src/core/ext/filters/client_channel/http_proxy.cc index 94ef2c55ec8..26c8b439e75 100644 --- a/src/core/ext/filters/client_channel/http_proxy.cc +++ b/src/core/ext/filters/client_channel/http_proxy.cc @@ -126,9 +126,7 @@ static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper, } /* Prefer using 'no_grpc_proxy'. Fallback on 'no_proxy' if it is not set. */ no_proxy_str = gpr_getenv("no_grpc_proxy"); - if (no_proxy_str == nullptr) { - no_proxy_str = gpr_getenv("no_proxy"); - } + if (no_proxy_str == nullptr) no_proxy_str = gpr_getenv("no_proxy"); if (no_proxy_str != nullptr) { static const char* NO_PROXY_SEPARATOR = ","; bool use_proxy = true; From 3c77a3887a06a8eb79ead685450e3b4127d345a0 Mon Sep 17 00:00:00 2001 From: zhoulin xie Date: Sun, 24 Feb 2019 15:16:49 +0800 Subject: [PATCH 0005/1555] Fix some misspells in doc Signed-off-by: zhoulin xie --- doc/interop-test-descriptions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/interop-test-descriptions.md b/doc/interop-test-descriptions.md index 208af424298..141b5ccc293 100755 --- a/doc/interop-test-descriptions.md +++ b/doc/interop-test-descriptions.md @@ -1135,7 +1135,7 @@ responses, it closes with OK. ### Echo Status [Echo Status]: #echo-status When the client sends a response_status in the request payload, the server closes -the stream with the status code and messsage contained within said response_status. +the stream with the status code and message contained within said response_status. The server will not process any further messages on the stream sent by the client. This can be used by clients to verify correct handling of different status codes and associated status messages end-to-end. @@ -1152,7 +1152,7 @@ key and the corresponding value back to the client as trailing metadata. [Observe ResponseParameters.interval_us]: #observe-responseparametersinterval_us In StreamingOutputCall and FullDuplexCall, server delays sending a -StreamingOutputCallResponse by the ResponseParameters's `interval_us` for that +StreamingOutputCallResponse by the ResponseParameters' `interval_us` for that particular response, relative to the last response sent. That is, `interval_us` acts like a sleep *before* sending the response and accumulates from one response to the next. From 4778d42cb5f59f9a5a9dc8cf725146165dad65f9 Mon Sep 17 00:00:00 2001 From: Kim Bao Long Date: Mon, 25 Feb 2019 13:51:18 +0700 Subject: [PATCH 0006/1555] Replacing 'HTTP' by 'HTTPS' for securing links Currently, when we access **github.com** with **HTTP**, it is redirected to **HTTPS** automatically. So this commit aims to replace **http://github.com** by **https://github.com** for security. Co-Authored-By: Nguyen Phuong An Signed-off-by: Kim Bao Long --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b3a4c1f17d1..b9d564ade8a 100644 --- a/README.md +++ b/README.md @@ -77,8 +77,8 @@ Libraries in different languages may be in various states of development. We are | Language | Source repo | |-------------------------|------------------------------------------------------| -| Java | [grpc-java](http://github.com/grpc/grpc-java) | -| Go | [grpc-go](http://github.com/grpc/grpc-go) | +| Java | [grpc-java](https://github.com/grpc/grpc-java) | +| Go | [grpc-go](https://github.com/grpc/grpc-go) | | NodeJS | [grpc-node](https://github.com/grpc/grpc-node) | | WebJS | [grpc-web](https://github.com/grpc/grpc-web) | | Dart | [grpc-dart](https://github.com/grpc/grpc-dart) | From 3fe631d1b6ffa7ab9f46d120ef27298e4ede3d9c Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Tue, 5 Mar 2019 13:57:41 -0800 Subject: [PATCH 0007/1555] Update doc about using clang-5.0 --- BUILDING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILDING.md b/BUILDING.md index 615b371db6e..2d757f58dca 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -12,7 +12,7 @@ gRPC C++ - Building from source If you plan to build from source and run tests, install the following as well: ```sh $ [sudo] apt-get install libgflags-dev libgtest-dev - $ [sudo] apt-get install clang libc++-dev + $ [sudo] apt-get install clang-5.0 libc++-dev ``` ## MacOS From 9580c45c65e0fb2032a5ac1375a210fd05b01639 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 5 Apr 2019 17:31:27 -0700 Subject: [PATCH 0008/1555] Add VS integration for design time build --- .../build/_protobuf/Google.Protobuf.Tools.targets | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets b/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets index 1a862337c58..de2f66e5be1 100644 --- a/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets +++ b/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets @@ -38,6 +38,21 @@ + + + + + + + + + + + + MSBuild:Compile + + + - - - - MSBuild:Compile - From d116f58e8e0aa376ce1e8fc1147aa1a1780c09d0 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 8 Apr 2019 11:19:57 -0700 Subject: [PATCH 0010/1555] Remove fix for bug in project system --- .../build/_protobuf/Google.Protobuf.Tools.targets | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets b/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets index d1597872dab..80c7109e016 100644 --- a/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets +++ b/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets @@ -39,16 +39,6 @@ - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample/Base.lproj/Main.storyboard b/src/objective-c/examples/InterceptorSample/InterceptorSample/Base.lproj/Main.storyboard new file mode 100644 index 00000000000..9310a8e812f --- /dev/null +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample/Base.lproj/Main.storyboard @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.h b/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.h new file mode 100644 index 00000000000..a2c9d668c14 --- /dev/null +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.h @@ -0,0 +1,90 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface RequestCacheEntry : NSObject + +@property(readonly, copy, nullable) NSString *path; +@property(readonly, copy, nullable) id message; + +@end + +@interface MutableRequestCacheEntry : RequestCacheEntry + +@property(copy, nullable) NSString *path; +@property(copy, nullable) id message; + +@end + +@interface ResponseCacheEntry : NSObject + +@property(readonly, copy, nullable) NSDate *deadline; + +@property(readonly, copy, nullable) NSDictionary *headers; +@property(readonly, copy, nullable) id message; +@property(readonly, copy, nullable) NSDictionary *trailers; + +@end + +@interface MutableResponseCacheEntry : ResponseCacheEntry + +@property(copy, nullable) NSDate *deadline; + +@property(copy, nullable) NSDictionary *headers; +@property(copy, nullable) id message; +@property(copy, nullable) NSDictionary *trailers; + +@end + +@interface CacheContext : NSObject + +- (nullable instancetype)init; + +- (nullable ResponseCacheEntry *)getCachedResponseForRequest:(RequestCacheEntry *)request; + +- (void)setCachedResponse:(ResponseCacheEntry *)response forRequest:(RequestCacheEntry *)request; + +@end + +@interface CacheInterceptor : GRPCInterceptor + +- (instancetype)init NS_UNAVAILABLE; + ++ (instancetype)new NS_UNAVAILABLE; + +- (nullable instancetype)initWithInterceptorManager:(GRPCInterceptorManager * _Nonnull)intercepterManager + cacheContext:(CacheContext * _Nonnull)cacheContext NS_DESIGNATED_INITIALIZER; + +// implementation of GRPCInterceptorInterface +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions + callOptions:(GRPCCallOptions *)callOptions; +- (void)writeData:(id)data; +- (void)finish; + +// implementation of GRPCResponseHandler +- (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata; +- (void)didReceiveData:(id)data; +- (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata + error:(nullable NSError *)error; + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.m b/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.m new file mode 100644 index 00000000000..fea770af486 --- /dev/null +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.m @@ -0,0 +1,303 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "CacheInterceptor.h" + +@implementation RequestCacheEntry { + @protected + NSString *_path; + id _message; +} + +@synthesize path = _path; +@synthesize message = _message; + +- (instancetype)initWithPath:(NSString *)path message:(id)message { + if ((self = [super init])) { + _path = [path copy]; + _message = [message copy]; + } + return self; +} + +- (id)copyWithZone:(NSZone *)zone { + return [[RequestCacheEntry allocWithZone:zone] initWithPath:_path message:_message]; +} + +- (BOOL)isEqual:(id)object { + if ([self class] != [object class]) return NO; + RequestCacheEntry *rhs = (RequestCacheEntry *)object; + return ([_path isEqualToString:rhs.path] && [_message isEqual:rhs.message]); +} + +- (NSUInteger)hash { + return _path.hash ^ _message.hash; +} + +@end + +@implementation MutableRequestCacheEntry + +@dynamic path; +@dynamic message; + +- (void)setPath:(NSString *)path { + _path = [path copy]; +} + +- (void)setMessage:(id)message { + _message = [message copy]; +} + +@end + +@implementation ResponseCacheEntry { + @protected + NSDate *_deadline; + NSDictionary *_headers; + id _message; + NSDictionary *_trailers; +} + +@synthesize deadline = _deadline; +@synthesize headers = _headers; +@synthesize message = _message; +@synthesize trailers = _trailers; + +- (instancetype)initWithDeadline:(NSDate *)deadline + headers:(NSDictionary *)headers + message:(id)message + trailers:(NSDictionary *)trailers { + if (([super init])) { + _deadline = [deadline copy]; + _headers = [[NSDictionary alloc] initWithDictionary:headers copyItems:YES]; + _message = [message copy]; + _trailers = [[NSDictionary alloc] initWithDictionary:trailers copyItems:YES]; + } + return self; +} + +- (id)copyWithZone:(NSZone *)zone { + return [[ResponseCacheEntry allocWithZone:zone] initWithDeadline:_deadline + headers:_headers + message:_message + trailers:_trailers]; +} + +@end + +@implementation MutableResponseCacheEntry + +@dynamic deadline; +@dynamic headers; +@dynamic message; +@dynamic trailers; + +- (void)setDeadline:(NSDate *)deadline { + _deadline = [deadline copy]; +} + +- (void)setHeaders:(NSDictionary *)headers { + _headers = [[NSDictionary alloc] initWithDictionary:headers copyItems:YES]; +} + +- (void)setMessage:(id)message { + _message = [message copy]; +} + +- (void)setTrailers:(NSDictionary *)trailers { + _trailers = [[NSDictionary alloc] initWithDictionary:trailers copyItems:YES]; +} + +@end + +@implementation CacheContext { + NSCache *_cache; +} + +- (instancetype)init { + if ((self = [super init])) { + _cache = [[NSCache alloc] init]; + } + return self; +} + +- (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { + return [[CacheInterceptor alloc] initWithInterceptorManager:interceptorManager + cacheContext:self]; +} + +- (ResponseCacheEntry *)getCachedResponseForRequest:(RequestCacheEntry *)request { + ResponseCacheEntry *response = nil; + @synchronized (self) { + response = [_cache objectForKey:request]; + } + return response; +} + +- (void)setCachedResponse:(ResponseCacheEntry *)response + forRequest:(RequestCacheEntry *)request { + @synchronized (self) { + [_cache setObject:response forKey:request]; + } +} + +@end + +@implementation CacheInterceptor { + GRPCInterceptorManager *_manager; + CacheContext *_context; + dispatch_queue_t _dispatchQueue; + + BOOL _cacheable; + BOOL _messageSeen; + GRPCCallOptions *_callOptions; + GRPCRequestOptions *_requestOptions; + id _requestMessage; + MutableRequestCacheEntry *_request; + MutableResponseCacheEntry *_response; +} + +- (dispatch_queue_t)requestDispatchQueue { + return _dispatchQueue; +} + +- (dispatch_queue_t)dispatchQueue { + return _dispatchQueue; +} + +- (instancetype)initWithInterceptorManager:(GRPCInterceptorManager * _Nonnull)intercepterManager + cacheContext:(CacheContext * _Nonnull)cacheContext { + if ((self = [super initWithInterceptorManager:intercepterManager + requestDispatchQueue:dispatch_get_main_queue() + responseDispatchQueue:dispatch_get_main_queue()])) { + _manager = intercepterManager; + _context = cacheContext; + _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); + + _cacheable = YES; + _messageSeen = NO; + _request = nil; + _response = nil; + } + return self; +} + +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { + NSLog(@"start"); + if (requestOptions.safety != GRPCCallSafetyCacheableRequest) { + NSLog(@"no cache"); + _cacheable = NO; + [_manager startNextInterceptorWithRequest:requestOptions callOptions:callOptions]; + } else { + _requestOptions = [requestOptions copy]; + _callOptions = [callOptions copy]; + } +} + +- (void)writeData:(id)data { + NSLog(@"writeData"); + if (!_cacheable) { + [_manager writeNextInterceptorWithData:data]; + } else { + NSAssert(!_messageSeen, @"CacheInterceptor does not support streaming call"); + if (_messageSeen) { + NSLog(@"CacheInterceptor does not support streaming call"); + } + _messageSeen = YES; + _requestMessage = [data copy]; + } +} + +- (void)finish { + NSLog(@"finish"); + if (!_cacheable) { + [_manager finishNextInterceptor]; + } else { + _request = [[MutableRequestCacheEntry alloc] init]; + _request.path = _requestOptions.path; + _request.message = [_requestMessage copy]; + _response = [[_context getCachedResponseForRequest:_request] copy]; + NSLog(@"Read cache for %@", _request); + if (!_response) { + [_manager startNextInterceptorWithRequest:_requestOptions + callOptions:_callOptions]; + [_manager writeNextInterceptorWithData:_requestMessage]; + [_manager finishNextInterceptor]; + } else { + [_manager forwardPreviousInterceptorWithInitialMetadata:_response.headers]; + [_manager forwardPreviousIntercetporWithData:_response.message]; + [_manager forwardPreviousInterceptorCloseWithTrailingMetadata:_response.trailers error:nil]; + [_manager shutDown]; + } + } +} + +- (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata { + NSLog(@"initialMetadata"); + if (_cacheable) { + NSDate *deadline = nil; + for (NSString *key in initialMetadata) { + if ([key.lowercaseString isEqualToString:@"cache-control"]) { + NSArray *cacheControls = [initialMetadata[key] componentsSeparatedByString:@","]; + for (NSString *option in cacheControls) { + NSString *trimmedOption = [option stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" "]]; + if ([trimmedOption.lowercaseString isEqualToString:@"no-cache"] || + [trimmedOption.lowercaseString isEqualToString:@"no-store"] || + [trimmedOption.lowercaseString isEqualToString:@"no-transform"]) { + _cacheable = NO; + break; + } else if ([trimmedOption.lowercaseString hasPrefix:@"max-age="]) { + NSArray *components = [trimmedOption componentsSeparatedByString:@"="]; + if (components.count == 2) { + NSUInteger maxAge = components[1].intValue; + deadline = [NSDate dateWithTimeIntervalSinceNow:maxAge]; + } + } + } + } + } + if (_cacheable) { + _response = [[MutableResponseCacheEntry alloc] init]; + _response.headers = [initialMetadata copy]; + _response.deadline = deadline; + } + } + [_manager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; +} + +- (void)didReceiveData:(id)data { + NSLog(@"receiveData"); + if (_cacheable) { + _response.message = [data copy]; + } + [_manager forwardPreviousIntercetporWithData:data]; +} + +- (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { + NSLog(@"close"); + if (error == nil && _cacheable) { + _response.trailers = [trailingMetadata copy]; + [_context setCachedResponse:_response forRequest:_request]; + NSLog(@"Write cache for %@", _request); + } + [_manager forwardPreviousInterceptorCloseWithTrailingMetadata:trailingMetadata error:error]; + [_manager shutDown]; +} + +@end diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample/Info.plist b/src/objective-c/examples/InterceptorSample/InterceptorSample/Info.plist new file mode 100644 index 00000000000..16be3b68112 --- /dev/null +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.h b/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.h new file mode 100644 index 00000000000..79de577af81 --- /dev/null +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.h @@ -0,0 +1,25 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import + +@interface ViewController : UIViewController + + +@end + diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.m b/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.m new file mode 100644 index 00000000000..79e53313e55 --- /dev/null +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.m @@ -0,0 +1,86 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "ViewController.h" + +#import +#import +#import + +#import "CacheInterceptor.h" + +static NSString *const kPackage = @"grpc.testing"; +static NSString *const kService = @"TestService"; + +@interface ViewController () + +@end + +@implementation ViewController { + GRPCCallOptions *_options; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + + id factory = [[CacheContext alloc] init]; + options.interceptorFactories = @[ factory ]; + _options = options; +} + +- (IBAction)tapCall:(id)sender { + GRPCProtoMethod *kUnaryCallMethod = + [[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"UnaryCall"]; + + GRPCRequestOptions *requestOptions = + [[GRPCRequestOptions alloc] initWithHost:@"grpc-test.sandbox.googleapis.com" + path:kUnaryCallMethod.HTTPPath + safety:GRPCCallSafetyCacheableRequest]; + + GRPCCall2 *call = [[GRPCCall2 alloc] initWithRequestOptions:requestOptions + responseHandler:self + callOptions:_options]; + + RMTSimpleRequest *request = [RMTSimpleRequest message]; + request.responseSize = 100; + + [call start]; + [call writeData:[request data]]; + [call finish]; + +} + +- (dispatch_queue_t)dispatchQueue { + return dispatch_get_main_queue(); +} + +- (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata { + NSLog(@"Header: %@", initialMetadata); +} + +- (void)didReceiveData:(id)data { + NSLog(@"Message: %@", data); +} + +- (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { + NSLog(@"Trailer: %@\nError: %@", trailingMetadata, error); +} + +@end diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample/main.m b/src/objective-c/examples/InterceptorSample/InterceptorSample/main.m new file mode 100644 index 00000000000..62a9f8e6efb --- /dev/null +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample/main.m @@ -0,0 +1,26 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/src/objective-c/examples/InterceptorSample/Podfile b/src/objective-c/examples/InterceptorSample/Podfile new file mode 100644 index 00000000000..b20813d32aa --- /dev/null +++ b/src/objective-c/examples/InterceptorSample/Podfile @@ -0,0 +1,31 @@ +platform :ios, '8.0' + +install! 'cocoapods', :deterministic_uuids => false + +ROOT_DIR = '../../../..' + +target 'InterceptorSample' do + pod 'gRPC-ProtoRPC', :path => ROOT_DIR + pod 'gRPC', :path => ROOT_DIR + pod 'gRPC-Core', :path => ROOT_DIR + pod 'gRPC-RxLibrary', :path => ROOT_DIR + pod 'RemoteTest', :path => "../RemoteTestClient" + pod '!ProtoCompiler-gRPCPlugin', :path => "#{ROOT_DIR}/src/objective-c" +end + +pre_install do |installer| + grpc_core_spec = installer.pod_targets.find{|t| t.name.start_with?('gRPC-Core')}.root_spec + + src_root = "$(PODS_TARGET_SRCROOT)" + grpc_core_spec.pod_target_xcconfig = { + 'GRPC_SRC_ROOT' => src_root, + 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"', + 'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"', + # If we don't set these two settings, `include/grpc/support/time.h` and + # `src/core/lib/gpr/string.h` shadow the system `` and ``, breaking the + # build. + 'USE_HEADERMAP' => 'NO', + 'ALWAYS_SEARCH_USER_PATHS' => 'NO', + } +end + From 3433749d1b3f6e25fa5a0e9ad6387004cab07e2f Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Wed, 24 Apr 2019 16:37:19 -0700 Subject: [PATCH 0040/1555] Add clarification to callback API documentation --- include/grpcpp/impl/codegen/client_callback.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/grpcpp/impl/codegen/client_callback.h b/include/grpcpp/impl/codegen/client_callback.h index e973e23f891..c897f6676d9 100644 --- a/include/grpcpp/impl/codegen/client_callback.h +++ b/include/grpcpp/impl/codegen/client_callback.h @@ -174,6 +174,8 @@ class ClientCallbackUnary { // StartWrite, or AddHold operations on the streaming object. Note that none of // the classes are pure; all reactions have a default empty reaction so that the // user class only needs to override those classes that it cares about. +// The reactor must be passed to the stub invocation before any of the below +// operations can be called. /// \a ClientBidiReactor is the interface for a bidirectional streaming RPC. template From cb82833038911e34d7d25dc71d01e7d0a12bae6a Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 24 Apr 2019 17:30:19 -0700 Subject: [PATCH 0041/1555] Add documentation and comments --- src/objective-c/GRPCClient/GRPCInterceptor.h | 117 ++++++++++++++++++- 1 file changed, 116 insertions(+), 1 deletion(-) diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.h b/src/objective-c/GRPCClient/GRPCInterceptor.h index 4ec71f9c271..8e23ffc5361 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.h +++ b/src/objective-c/GRPCClient/GRPCInterceptor.h @@ -19,6 +19,90 @@ /** * API for interceptors implementation. This feature is currently EXPERIMENTAL and is subject to * breaking changes without prior notice. + * + * The interceptors in the gRPC system forms a chain. When a call is made by the user, each + * interceptor on the chain has chances to react to events of the call and make necessary + * modifications to the call's parameters, data, metadata, or flow. + * + * + * ----------- + * | GRPCCall2 | + * ----------- + * | + * | + * -------------------------- + * | GRPCInterceptorManager 1 | + * -------------------------- + * | GRPCInterceptor 1 | + * -------------------------- + * | + * ... + * | + * -------------------------- + * | GRPCInterceptorManager N | + * -------------------------- + * | GRPCInterceptor N | + * -------------------------- + * | + * | + * ------------------ + * | GRPCCallInternal | + * ------------------ + * + * The chain of interceptors is initialized when the corresponding GRPCCall2 object or proto call + * object (GRPCUnaryProtoCall and GRPCStreamingProtoCall) is initialized. The initialization of the + * chain is controlled by the property interceptorFactories in the callOptions parameter of the + * corresponding call object. Property interceptorFactories is an array of + * id objects provided by the user. When a call object is initialized, each + * interceptor factory generates an interceptor object for the call. gRPC internally links the + * interceptors with each other and with the actual call object. The order of the interceptors in + * the chain is exactly the same as the order of factory objects in interceptorFactories property. + * All requests (start, write, finish, cancel, receive next) initiated by the user will be processed + * in the order of interceptors, and all responses (initial metadata, data, trailing metadata, write + * data done) are processed in the reverse order. + * + * Each interceptor in the interceptor chain should behave as a user of the next interceptor, and at + * the same time behave as a call to the previous interceptor. Therefore interceptor implementations + * must follow the state transition of gRPC calls and must also forward events that are consistent + * with the current state of the next/previous interceptor. They should also make sure that the + * events they forwarded to the next and previous interceptors will, in the end, make the neighbour + * interceptor terminate correctly and reaches "finished" state. The diagram below shows the state + * transitions. Any event not appearing on the diagram means the event is not permitted for that + * particular state. + * + * writeData + * receiveNextMessages + * didReceiveInitialMetadata + * didReceiveData + * didWriteData + * writeData ----- ----- ---- didReceiveInitialMetadata + * receiveNextMessages | | | | | | didReceiveData + * | V | V | V didWriteData + * ------------- start --------- finish ------------ + * | initialized | -----> | started | --------> | half-close | + * ------------- --------- ------------ + * | | | + * | | didClose | didClose + * |cancel | cancel | cancel + * | V | + * | ---------- | + * --------------> | finished | <-------------- + * ---------- + * | ^ writeData + * | | finish + * ------ cancel + * receiveNextMessages + * + * Events of requests and responses are dispatched to interceptor objects using the interceptor's + * dispatch queue. The dispatch queue should be serial queue to make sure the events are processed + * in order. Interceptor implementations must derive from GRPCInterceptor class. The class makes + * some basic implementation of all methods responding to an event of a call. If an interceptor does + * not care about a particular event, it can use the basic implementation of the GRPCInterceptor + * class, which simply forward the event to the next or previous interceptor in the chain. + * + * The interceptor object should be unique for each call since the call context is not passed to the + * interceptor object in a call event. However, the interceptors can be implemented to share states + * by receiving state sharing object from the factory upon construction. */ #import "GRPCCall.h" @@ -28,24 +112,49 @@ NS_ASSUME_NONNULL_BEGIN @class GRPCInterceptorManager; @class GRPCInterceptor; +/** + * The GRPCInterceptorInterface defines the request events that can occur to an interceptr. + */ @protocol GRPCInterceptorInterface -/** The queue on which all methods of this interceptor should be dispatched on */ +/** + * The queue on which all methods of this interceptor should be dispatched on. The queue must be a + * serial queue. + */ @property(readonly) dispatch_queue_t requestDispatchQueue; +/** + * To start the call. This method will only be called once for each instance. + */ - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions; +/** + * To write data to the call. + */ - (void)writeData:(id)data; +/** + * To finish the stream of requests. + */ - (void)finish; +/** + * To cancel the call. + */ - (void)cancel; +/** + * To indicate the call that the previous interceptor is ready to receive more messages. + */ - (void)receiveNextMessages:(NSUInteger)numberOfMessages; @end +/** + * An interceptor factory object should be used to create interceptor object for the call at the + * call start time. + */ @protocol GRPCInterceptorFactory /** @@ -56,6 +165,12 @@ NS_ASSUME_NONNULL_BEGIN @end +/** + * The interceptor manager object retains reference to the next and previous interceptor object in + * the interceptor chain, and forward corresponding events to them. When a call terminates, it must + * invoke shutDown method of its corresponding manager so that references to other interceptors can + * be released. + */ @interface GRPCInterceptorManager : NSObject - (instancetype)init NS_UNAVAILABLE; From 6a3ea4934b44db30fde0b518d1be5372612b113f Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 24 Apr 2019 17:30:41 -0700 Subject: [PATCH 0042/1555] clang-format --- src/objective-c/GRPCClient/GRPCCall.m | 21 +- src/objective-c/GRPCClient/GRPCCallOptions.h | 2 - src/objective-c/GRPCClient/GRPCCallOptions.m | 14 +- src/objective-c/GRPCClient/GRPCInterceptor.h | 12 +- src/objective-c/GRPCClient/GRPCInterceptor.m | 37 +- .../GRPCClient/private/GRPCCallInternal.m | 18 +- .../InterceptorSample/AppDelegate.h | 4 +- .../InterceptorSample/CacheInterceptor.h | 8 +- .../InterceptorSample/CacheInterceptor.m | 28 +- .../InterceptorSample/ViewController.h | 2 - .../InterceptorSample/ViewController.m | 3 +- .../InterceptorSample/main.m | 4 +- src/objective-c/tests/InteropTests.m | 494 ++++++++++-------- 13 files changed, 341 insertions(+), 306 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index fb4dbdb5d71..40aaea16e56 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -18,8 +18,8 @@ #import "GRPCCall.h" #import "GRPCCall+OAuth2.h" -#import "GRPCInterceptor.h" #import "GRPCCallOptions.h" +#import "GRPCInterceptor.h" #import #import @@ -28,6 +28,8 @@ #include #include +#import "private/GRPCCall+V2API.h" +#import "private/GRPCCallInternal.h" #import "private/GRPCChannelPool.h" #import "private/GRPCCompletionQueue.h" #import "private/GRPCConnectivityMonitor.h" @@ -37,8 +39,6 @@ #import "private/NSData+GRPC.h" #import "private/NSDictionary+GRPC.h" #import "private/NSError+GRPC.h" -#import "private/GRPCCall+V2API.h" -#import "private/GRPCCallInternal.h" // At most 6 ops can be in an op batch for a client: SEND_INITIAL_METADATA, // SEND_MESSAGE, SEND_CLOSE_FROM_CLIENT, RECV_INITIAL_METADATA, RECV_MESSAGE, @@ -142,8 +142,10 @@ const char *kCFStreamVarName = "grpc_cfstream"; [internalCall setResponseHandler:_responseHandler]; } else { for (int i = (int)interceptorFactories.count - 1; i >= 0; i--) { - GRPCInterceptorManager *manager = [[GRPCInterceptorManager alloc] initWithNextInerceptor:nextInterceptor]; - GRPCInterceptor *interceptor = [interceptorFactories[i] createInterceptorWithManager:manager]; + GRPCInterceptorManager *manager = + [[GRPCInterceptorManager alloc] initWithNextInerceptor:nextInterceptor]; + GRPCInterceptor *interceptor = + [interceptorFactories[i] createInterceptorWithManager:manager]; NSAssert(interceptor != nil, @"Failed to create interceptor"); if (interceptor == nil) { return nil; @@ -180,8 +182,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; GRPCCallOptions *callOptions = [_actualCallOptions copy]; if ([copiedFirstInterceptor respondsToSelector:@selector(startWithRequestOptions:callOptions:)]) { dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ - [copiedFirstInterceptor startWithRequestOptions:requestOptions - callOptions:callOptions]; + [copiedFirstInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; }); } } @@ -200,7 +201,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; - (void)writeData:(id)data { id copiedFirstInterceptor; - @synchronized (self) { + @synchronized(self) { copiedFirstInterceptor = _firstInterceptor; } if ([copiedFirstInterceptor respondsToSelector:@selector(writeData:)]) { @@ -212,7 +213,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; - (void)finish { id copiedFirstInterceptor; - @synchronized (self) { + @synchronized(self) { copiedFirstInterceptor = _firstInterceptor; } if ([copiedFirstInterceptor respondsToSelector:@selector(finish)]) { @@ -224,7 +225,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; - (void)receiveNextMessages:(NSUInteger)numberOfMessages { id copiedFirstInterceptor; - @synchronized (self) { + @synchronized(self) { copiedFirstInterceptor = _firstInterceptor; } if ([copiedFirstInterceptor respondsToSelector:@selector(receiveNextMessages:)]) { diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.h b/src/objective-c/GRPCClient/GRPCCallOptions.h index 6f985c8d952..98511e3f5cb 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.h +++ b/src/objective-c/GRPCClient/GRPCCallOptions.h @@ -106,7 +106,6 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { */ @property(copy, readonly) NSArray *interceptorFactories; - // OAuth2 parameters. Users of gRPC may specify one of the following two parameters. /** @@ -270,7 +269,6 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { */ @property(copy, readwrite) NSArray *interceptorFactories; - // OAuth2 parameters. Users of gRPC may specify one of the following two parameters. /** diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.m b/src/objective-c/GRPCClient/GRPCCallOptions.m index 5a270407620..392e42a9d47 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.m +++ b/src/objective-c/GRPCClient/GRPCCallOptions.m @@ -115,7 +115,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { - (instancetype)init { return [self initWithServerAuthority:kDefaultServerAuthority timeout:kDefaultTimeout - flowControlEnabled:kDefaultFlowControlEnabled + flowControlEnabled:kDefaultFlowControlEnabled interceptorFactories:kDefaultInterceptorFactories oauth2AccessToken:kDefaultOauth2AccessToken authTokenProvider:kDefaultAuthTokenProvider @@ -142,7 +142,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { - (instancetype)initWithServerAuthority:(NSString *)serverAuthority timeout:(NSTimeInterval)timeout - flowControlEnabled:(BOOL)flowControlEnabled + flowControlEnabled:(BOOL)flowControlEnabled interceptorFactories:(NSArray *)interceptorFactories oauth2AccessToken:(NSString *)oauth2AccessToken authTokenProvider:(id)authTokenProvider @@ -205,7 +205,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { GRPCCallOptions *newOptions = [[GRPCCallOptions allocWithZone:zone] initWithServerAuthority:_serverAuthority timeout:_timeout - flowControlEnabled:_flowControlEnabled + flowControlEnabled:_flowControlEnabled interceptorFactories:_interceptorFactories oauth2AccessToken:_oauth2AccessToken authTokenProvider:_authTokenProvider @@ -235,7 +235,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { GRPCMutableCallOptions *newOptions = [[GRPCMutableCallOptions allocWithZone:zone] initWithServerAuthority:[_serverAuthority copy] timeout:_timeout - flowControlEnabled:_flowControlEnabled + flowControlEnabled:_flowControlEnabled interceptorFactories:_interceptorFactories oauth2AccessToken:[_oauth2AccessToken copy] authTokenProvider:_authTokenProvider @@ -344,7 +344,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { - (instancetype)init { return [self initWithServerAuthority:kDefaultServerAuthority timeout:kDefaultTimeout - flowControlEnabled:kDefaultFlowControlEnabled + flowControlEnabled:kDefaultFlowControlEnabled interceptorFactories:kDefaultInterceptorFactories oauth2AccessToken:kDefaultOauth2AccessToken authTokenProvider:kDefaultAuthTokenProvider @@ -373,7 +373,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { GRPCCallOptions *newOptions = [[GRPCCallOptions allocWithZone:zone] initWithServerAuthority:_serverAuthority timeout:_timeout - flowControlEnabled:_flowControlEnabled + flowControlEnabled:_flowControlEnabled interceptorFactories:_interceptorFactories oauth2AccessToken:_oauth2AccessToken authTokenProvider:_authTokenProvider @@ -403,7 +403,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { GRPCMutableCallOptions *newOptions = [[GRPCMutableCallOptions allocWithZone:zone] initWithServerAuthority:_serverAuthority timeout:_timeout - flowControlEnabled:_flowControlEnabled + flowControlEnabled:_flowControlEnabled interceptorFactories:_interceptorFactories oauth2AccessToken:_oauth2AccessToken authTokenProvider:_authTokenProvider diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.h b/src/objective-c/GRPCClient/GRPCInterceptor.h index 8e23ffc5361..931f6e4aa5a 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.h +++ b/src/objective-c/GRPCClient/GRPCInterceptor.h @@ -175,9 +175,10 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)init NS_UNAVAILABLE; -+ (instancetype)new NS_UNAVAILABLE; ++ (instancetype) new NS_UNAVAILABLE; -- (nullable instancetype)initWithNextInerceptor:(id)nextInterceptor NS_DESIGNATED_INITIALIZER; +- (nullable instancetype)initWithNextInerceptor:(id)nextInterceptor + NS_DESIGNATED_INITIALIZER; /** Set the previous interceptor in the chain. Can only be set once. */ - (void)setPreviousInterceptor:(id)previousInterceptor; @@ -213,7 +214,7 @@ NS_ASSUME_NONNULL_BEGIN /** Forward call close and trailing metadata to the previous interceptor in the chain */ - (void)forwardPreviousInterceptorCloseWithTrailingMetadata: -(nullable NSDictionary *)trailingMetadata + (nullable NSDictionary *)trailingMetadata error:(nullable NSError *)error; /** Forward write completion to the previous interceptor in the chain */ @@ -235,7 +236,7 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)init NS_UNAVAILABLE; -+ (instancetype)new NS_UNAVAILABLE; ++ (instancetype) new NS_UNAVAILABLE; /** * Initialize the interceptor with the next interceptor in the chain, and provide the dispatch queue @@ -243,7 +244,8 @@ NS_ASSUME_NONNULL_BEGIN */ - (nullable instancetype)initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager requestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue NS_DESIGNATED_INITIALIZER; + responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue + NS_DESIGNATED_INITIALIZER; // Default implementation of GRPCInterceptorInterface diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.m b/src/objective-c/GRPCClient/GRPCInterceptor.m index ac0b69f14eb..1c1f0b53114 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.m +++ b/src/objective-c/GRPCClient/GRPCInterceptor.m @@ -47,8 +47,7 @@ if ([_nextInterceptor respondsToSelector:@selector(startWithRequestOptions:callOptions:)]) { id copiedNextInterceptor = _nextInterceptor; dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor startWithRequestOptions:requestOptions - callOptions:callOptions]; + [copiedNextInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; }); } } @@ -114,13 +113,12 @@ /** Forward call close and trailing metadata to the previous interceptor in the chain */ - (void)forwardPreviousInterceptorCloseWithTrailingMetadata: -(nullable NSDictionary *)trailingMetadata + (nullable NSDictionary *)trailingMetadata error:(nullable NSError *)error { if ([_previousInterceptor respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { id copiedPreviousInterceptor = _previousInterceptor; dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didCloseWithTrailingMetadata:trailingMetadata - error:error]; + [copiedPreviousInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; }); } } @@ -165,8 +163,7 @@ - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { - [_manager startNextInterceptorWithRequest:requestOptions - callOptions:callOptions]; + [_manager startNextInterceptorWithRequest:requestOptions callOptions:callOptions]; } - (void)writeData:(id)data { @@ -179,13 +176,15 @@ - (void)cancel { [_manager cancelNextInterceptor]; - [_manager forwardPreviousInterceptorCloseWithTrailingMetadata:nil - error:[NSError errorWithDomain:kGRPCErrorDomain - code:GRPCErrorCodeCancelled - userInfo:@{ - NSLocalizedDescriptionKey : - @"Canceled" - }]]; + [_manager + forwardPreviousInterceptorCloseWithTrailingMetadata:nil + error:[NSError + errorWithDomain:kGRPCErrorDomain + code:GRPCErrorCodeCancelled + userInfo:@{ + NSLocalizedDescriptionKey : + @"Canceled" + }]]; [_manager shutDown]; } @@ -193,13 +192,13 @@ [_manager receiveNextInterceptorMessages:numberOfMessages]; } - - (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata { [_manager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; } - (void)didReceiveRawMessage:(id)message { - NSAssert(NO, @"The method didReceiveRawMessage is deprecated and cannot be used with interceptor"); + NSAssert(NO, + @"The method didReceiveRawMessage is deprecated and cannot be used with interceptor"); NSLog(@"The method didReceiveRawMessage is deprecated and cannot be used with interceptor"); abort(); } @@ -208,10 +207,8 @@ [_manager forwardPreviousIntercetporWithData:data]; } -- (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata - error:(NSError *)error { - [_manager forwardPreviousInterceptorCloseWithTrailingMetadata:trailingMetadata - error:error]; +- (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { + [_manager forwardPreviousInterceptorCloseWithTrailingMetadata:trailingMetadata error:error]; [_manager shutDown]; } diff --git a/src/objective-c/GRPCClient/private/GRPCCallInternal.m b/src/objective-c/GRPCClient/private/GRPCCallInternal.m index 06912cc7fa9..e4edcedf36c 100644 --- a/src/objective-c/GRPCClient/private/GRPCCallInternal.m +++ b/src/objective-c/GRPCClient/private/GRPCCallInternal.m @@ -35,12 +35,12 @@ - (instancetype)init { if ((self = [super init])) { - // Set queue QoS only when iOS version is 8.0 or above and Xcode version is 9.0 or above + // Set queue QoS only when iOS version is 8.0 or above and Xcode version is 9.0 or above #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 if (@available(iOS 8.0, macOS 10.10, *)) { _dispatchQueue = dispatch_queue_create( - NULL, - dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); + NULL, + dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); } else { #else { @@ -53,7 +53,7 @@ } - (void)setResponseHandler:(id)responseHandler { - @synchronized (self) { + @synchronized(self) { NSAssert(!_started, @"Call already started."); if (_started) { return; @@ -84,7 +84,7 @@ return; } - @synchronized (self) { + @synchronized(self) { NSAssert(_handler != nil, @"Response handler required."); if (_handler == nil) { NSLog(@"Invalid response handler."); @@ -172,7 +172,7 @@ } }; id responseWriteable = - [[GRXWriteable alloc] initWithValueHandler:valueHandler completionHandler:completionHandler]; + [[GRXWriteable alloc] initWithValueHandler:valueHandler completionHandler:completionHandler]; [copiedCall startWithWriteable:responseWriteable]; } @@ -197,9 +197,9 @@ error:[NSError errorWithDomain:kGRPCErrorDomain code:GRPCErrorCodeCancelled userInfo:@{ - NSLocalizedDescriptionKey : - @"Canceled by app" - }]]; + NSLocalizedDescriptionKey : + @"Canceled by app" + }]]; }); } else { _handler = nil; diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample/AppDelegate.h b/src/objective-c/examples/InterceptorSample/InterceptorSample/AppDelegate.h index c4e433787e6..183abcf4ec8 100644 --- a/src/objective-c/examples/InterceptorSample/InterceptorSample/AppDelegate.h +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample/AppDelegate.h @@ -18,8 +18,8 @@ #import -@interface AppDelegate : UIResponder +@interface AppDelegate : UIResponder -@property (strong, nonatomic) UIWindow *window; +@property(strong, nonatomic) UIWindow* window; @end diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.h b/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.h index a2c9d668c14..a1de74cdb1f 100644 --- a/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.h +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.h @@ -68,10 +68,12 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)init NS_UNAVAILABLE; -+ (instancetype)new NS_UNAVAILABLE; ++ (instancetype) new NS_UNAVAILABLE; -- (nullable instancetype)initWithInterceptorManager:(GRPCInterceptorManager * _Nonnull)intercepterManager - cacheContext:(CacheContext * _Nonnull)cacheContext NS_DESIGNATED_INITIALIZER; +- (nullable instancetype)initWithInterceptorManager: + (GRPCInterceptorManager *_Nonnull)intercepterManager + cacheContext:(CacheContext *_Nonnull)cacheContext + NS_DESIGNATED_INITIALIZER; // implementation of GRPCInterceptorInterface - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.m b/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.m index fea770af486..082bd303dec 100644 --- a/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.m +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.m @@ -19,7 +19,7 @@ #import "CacheInterceptor.h" @implementation RequestCacheEntry { - @protected + @protected NSString *_path; id _message; } @@ -67,7 +67,7 @@ @end @implementation ResponseCacheEntry { - @protected + @protected NSDate *_deadline; NSDictionary *_headers; id _message; @@ -138,21 +138,19 @@ } - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { - return [[CacheInterceptor alloc] initWithInterceptorManager:interceptorManager - cacheContext:self]; + return [[CacheInterceptor alloc] initWithInterceptorManager:interceptorManager cacheContext:self]; } - (ResponseCacheEntry *)getCachedResponseForRequest:(RequestCacheEntry *)request { ResponseCacheEntry *response = nil; - @synchronized (self) { + @synchronized(self) { response = [_cache objectForKey:request]; } return response; } -- (void)setCachedResponse:(ResponseCacheEntry *)response - forRequest:(RequestCacheEntry *)request { - @synchronized (self) { +- (void)setCachedResponse:(ResponseCacheEntry *)response forRequest:(RequestCacheEntry *)request { + @synchronized(self) { [_cache setObject:response forKey:request]; } } @@ -181,8 +179,8 @@ return _dispatchQueue; } -- (instancetype)initWithInterceptorManager:(GRPCInterceptorManager * _Nonnull)intercepterManager - cacheContext:(CacheContext * _Nonnull)cacheContext { +- (instancetype)initWithInterceptorManager:(GRPCInterceptorManager *_Nonnull)intercepterManager + cacheContext:(CacheContext *_Nonnull)cacheContext { if ((self = [super initWithInterceptorManager:intercepterManager requestDispatchQueue:dispatch_get_main_queue() responseDispatchQueue:dispatch_get_main_queue()])) { @@ -198,7 +196,8 @@ return self; } -- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions + callOptions:(GRPCCallOptions *)callOptions { NSLog(@"start"); if (requestOptions.safety != GRPCCallSafetyCacheableRequest) { NSLog(@"no cache"); @@ -235,8 +234,7 @@ _response = [[_context getCachedResponseForRequest:_request] copy]; NSLog(@"Read cache for %@", _request); if (!_response) { - [_manager startNextInterceptorWithRequest:_requestOptions - callOptions:_callOptions]; + [_manager startNextInterceptorWithRequest:_requestOptions callOptions:_callOptions]; [_manager writeNextInterceptorWithData:_requestMessage]; [_manager finishNextInterceptor]; } else { @@ -256,7 +254,9 @@ if ([key.lowercaseString isEqualToString:@"cache-control"]) { NSArray *cacheControls = [initialMetadata[key] componentsSeparatedByString:@","]; for (NSString *option in cacheControls) { - NSString *trimmedOption = [option stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" "]]; + NSString *trimmedOption = + [option stringByTrimmingCharactersInSet:[NSCharacterSet + characterSetWithCharactersInString:@" "]]; if ([trimmedOption.lowercaseString isEqualToString:@"no-cache"] || [trimmedOption.lowercaseString isEqualToString:@"no-store"] || [trimmedOption.lowercaseString isEqualToString:@"no-transform"]) { diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.h b/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.h index 79de577af81..0aa0b2a73a7 100644 --- a/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.h +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.h @@ -20,6 +20,4 @@ @interface ViewController : UIViewController - @end - diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.m b/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.m index 79e53313e55..9da6dedbf9e 100644 --- a/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.m +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.m @@ -19,8 +19,8 @@ #import "ViewController.h" #import -#import #import +#import #import "CacheInterceptor.h" @@ -64,7 +64,6 @@ static NSString *const kService = @"TestService"; [call start]; [call writeData:[request data]]; [call finish]; - } - (dispatch_queue_t)dispatchQueue { diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample/main.m b/src/objective-c/examples/InterceptorSample/InterceptorSample/main.m index 62a9f8e6efb..2797c6f17f2 100644 --- a/src/objective-c/examples/InterceptorSample/InterceptorSample/main.m +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample/main.m @@ -19,8 +19,8 @@ #import #import "AppDelegate.h" -int main(int argc, char * argv[]) { +int main(int argc, char* argv[]) { @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } diff --git a/src/objective-c/tests/InteropTests.m b/src/objective-c/tests/InteropTests.m index 42365d2be2c..93316c0ff5a 100644 --- a/src/objective-c/tests/InteropTests.m +++ b/src/objective-c/tests/InteropTests.m @@ -171,15 +171,20 @@ BOOL isRemoteInteropTest(NSString *host) { @interface HookInterceptorFactory : NSObject -- (instancetype)initWithDispatchQueue:(dispatch_queue_t)dispatchQueue - startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))writeDataHook - finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook - receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, GRPCInterceptorManager *manager))receiveNextMessagesHook - responseHeaderHook:(void (^)(NSDictionary *initialMetadata, GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))responseDataHook - responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager))responseCloseHook - didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook; +- (instancetype) + initWithDispatchQueue:(dispatch_queue_t)dispatchQueue + startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager))startHook + writeDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))writeDataHook + finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook +receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, + GRPCInterceptorManager *manager))receiveNextMessagesHook + responseHeaderHook:(void (^)(NSDictionary *initialMetadata, + GRPCInterceptorManager *manager))responseHeaderHook + responseDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))responseDataHook + responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager))responseCloseHook + didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook; - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager; @@ -187,40 +192,53 @@ BOOL isRemoteInteropTest(NSString *host) { @interface HookIntercetpor : GRPCInterceptor -- (instancetype)initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - dispatchQueue:(dispatch_queue_t)dispatchQueue - startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))writeDataHook - finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook - receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, GRPCInterceptorManager *manager))receiveNextMessagesHook - responseHeaderHook:(void (^)(NSDictionary *initialMetadata, GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))responseDataHook - responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager))responseCloseHook - didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook; +- (instancetype) +initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager + dispatchQueue:(dispatch_queue_t)dispatchQueue + startHook:(void (^)(GRPCRequestOptions *requestOptions, + GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager))startHook + writeDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))writeDataHook + finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook + receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, + GRPCInterceptorManager *manager))receiveNextMessagesHook + responseHeaderHook:(void (^)(NSDictionary *initialMetadata, + GRPCInterceptorManager *manager))responseHeaderHook + responseDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))responseDataHook + responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager))responseCloseHook + didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook; @end @implementation HookInterceptorFactory { - void (^_startHook)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager); + void (^_startHook)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager); void (^_writeDataHook)(NSData *data, GRPCInterceptorManager *manager); void (^_finishHook)(GRPCInterceptorManager *manager); void (^_receiveNextMessagesHook)(NSUInteger numberOfMessages, GRPCInterceptorManager *manager); void (^_responseHeaderHook)(NSDictionary *initialMetadata, GRPCInterceptorManager *manager); void (^_responseDataHook)(NSData *data, GRPCInterceptorManager *manager); - void (^_responseCloseHook)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager); + void (^_responseCloseHook)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager); void (^_didWriteDataHook)(GRPCInterceptorManager *manager); dispatch_queue_t _dispatchQueue; } -- (instancetype)initWithDispatchQueue:(dispatch_queue_t)dispatchQueue - startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))writeDataHook - finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook - receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, GRPCInterceptorManager *manager))receiveNextMessagesHook - responseHeaderHook:(void (^)(NSDictionary *initialMetadata, GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))responseDataHook - responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager))responseCloseHook - didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { +- (instancetype) + initWithDispatchQueue:(dispatch_queue_t)dispatchQueue + startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager))startHook + writeDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))writeDataHook + finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook +receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, + GRPCInterceptorManager *manager))receiveNextMessagesHook + responseHeaderHook:(void (^)(NSDictionary *initialMetadata, + GRPCInterceptorManager *manager))responseHeaderHook + responseDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))responseDataHook + responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager))responseCloseHook + didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { if ((self = [super init])) { _dispatchQueue = dispatchQueue; _startHook = startHook; @@ -252,13 +270,15 @@ BOOL isRemoteInteropTest(NSString *host) { @end @implementation HookIntercetpor { - void (^_startHook)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager); + void (^_startHook)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager); void (^_writeDataHook)(NSData *data, GRPCInterceptorManager *manager); void (^_finishHook)(GRPCInterceptorManager *manager); void (^_receiveNextMessagesHook)(NSUInteger numberOfMessages, GRPCInterceptorManager *manager); void (^_responseHeaderHook)(NSDictionary *initialMetadata, GRPCInterceptorManager *manager); void (^_responseDataHook)(NSData *data, GRPCInterceptorManager *manager); - void (^_responseCloseHook)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager); + void (^_responseCloseHook)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager); void (^_didWriteDataHook)(GRPCInterceptorManager *manager); GRPCInterceptorManager *_manager; dispatch_queue_t _dispatchQueue; @@ -272,17 +292,25 @@ BOOL isRemoteInteropTest(NSString *host) { return _dispatchQueue; } -- (instancetype)initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - dispatchQueue:(dispatch_queue_t)dispatchQueue - startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))writeDataHook - finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook - receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, GRPCInterceptorManager *manager))receiveNextMessagesHook - responseHeaderHook:(void (^)(NSDictionary *initialMetadata, GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))responseDataHook - responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager))responseCloseHook - didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { - if ((self = [super initWithInterceptorManager:interceptorManager requestDispatchQueue:dispatchQueue responseDispatchQueue:dispatchQueue])) { +- (instancetype) +initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager + dispatchQueue:(dispatch_queue_t)dispatchQueue + startHook:(void (^)(GRPCRequestOptions *requestOptions, + GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager))startHook + writeDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))writeDataHook + finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook + receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, + GRPCInterceptorManager *manager))receiveNextMessagesHook + responseHeaderHook:(void (^)(NSDictionary *initialMetadata, + GRPCInterceptorManager *manager))responseHeaderHook + responseDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))responseDataHook + responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager))responseCloseHook + didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { + if ((self = [super initWithInterceptorManager:interceptorManager + requestDispatchQueue:dispatchQueue + responseDispatchQueue:dispatchQueue])) { _startHook = startHook; _writeDataHook = writeDataHook; _finishHook = finishHook; @@ -1271,39 +1299,39 @@ BOOL isRemoteInteropTest(NSString *host) { options.interceptorFactories = @[ [[DefaultInterceptorFactory alloc] init] ]; __block GRPCStreamingProtoCall *call = [_service - fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:nil - messageCallback:^(id message) { - XCTAssertLessThan(index, 4, - @"More than 4 responses received."); - id expected = [RMTStreamingOutputCallResponse - messageWithPayloadSize:responses[index]]; - XCTAssertEqualObjects(message, expected); - index += 1; - if (index < 4) { - id request = [RMTStreamingOutputCallRequest - messageWithPayloadSize:requests[index] - requestedResponseSize:responses[index]]; - [call writeMessage:request]; - } else { - [call finish]; - } - // DEBUG - NSLog(@"Received message"); - } - closeCallback:^(NSDictionary *trailingMetadata, - NSError *error) { - XCTAssertNil(error, - @"Finished with unexpected error: %@", - error); - XCTAssertEqual(index, 4, - @"Received %i responses instead of 4.", - index); - [expectation fulfill]; - // DEBUG - NSLog(@"Received close"); - }] - callOptions:options]; + fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:^(id message) { + XCTAssertLessThan(index, 4, + @"More than 4 responses received."); + id expected = [RMTStreamingOutputCallResponse + messageWithPayloadSize:responses[index]]; + XCTAssertEqualObjects(message, expected); + index += 1; + if (index < 4) { + id request = [RMTStreamingOutputCallRequest + messageWithPayloadSize:requests[index] + requestedResponseSize:responses[index]]; + [call writeMessage:request]; + } else { + [call finish]; + } + // DEBUG + NSLog(@"Received message"); + } + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + XCTAssertNil(error, + @"Finished with unexpected error: %@", + error); + XCTAssertEqual(index, 4, + @"Received %i responses instead of 4.", + index); + [expectation fulfill]; + // DEBUG + NSLog(@"Received close"); + }] + callOptions:options]; [call start]; [call writeMessage:request]; @@ -1322,54 +1350,56 @@ BOOL isRemoteInteropTest(NSString *host) { __block NSUInteger responseDataCount = 0; __block NSUInteger responseCloseCount = 0; __block NSUInteger didWriteDataCount = 0; - id factory = - [[HookInterceptorFactory alloc] initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager) { - startCount++; - NSLog(@"Interceptor - started call, %@, %@", requestOptions, callOptions); - XCTAssertEqualObjects(requestOptions.host, [[self class] host]); - XCTAssertEqualObjects(requestOptions.path, @"/grpc.testing.TestService/FullDuplexCall"); - XCTAssertEqual(requestOptions.safety, GRPCCallSafetyDefault); - [manager startNextInterceptorWithRequest:[requestOptions copy] callOptions:[callOptions copy]]; - } - writeDataHook:^(NSData *data, GRPCInterceptorManager *manager) { - writeDataCount++; - NSLog(@"Interceptor - send data, %@", data); - XCTAssertNotEqual(data.length, 0); - [manager writeNextInterceptorWithData:data]; - } - finishHook:^(GRPCInterceptorManager *manager) { - finishCount++; - NSLog(@"Interceptor - finish call"); - [manager finishNextInterceptor]; - } - receiveNextMessagesHook:^(NSUInteger numberOfMessages, GRPCInterceptorManager *manager) { - receiveNextMessageCount++; - NSLog(@"Interceptor - receive next messages, %lu", (unsigned long)numberOfMessages); - [manager receiveNextInterceptorMessages:numberOfMessages]; - } - responseHeaderHook:^(NSDictionary *initialMetadata, GRPCInterceptorManager *manager) { - responseHeaderCount++; - NSLog(@"Interceptor - received initial metadata, %@", initialMetadata); - [manager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; - } - responseDataHook:^(NSData *data, GRPCInterceptorManager *manager) { - responseDataCount++; - NSLog(@"Interceptor - received data, %@", data); - XCTAssertNotEqual(data.length, 0); - [manager forwardPreviousIntercetporWithData:data]; - } - responseCloseHook:^(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager) { - responseCloseCount++; - NSLog(@"Interceptor - received close, %@, %@", trailingMetadata, error); - [manager forwardPreviousInterceptorCloseWithTrailingMetadata:trailingMetadata - error:error]; - } - didWriteDataHook:^(GRPCInterceptorManager *manager) { - didWriteDataCount++; - NSLog(@"Interceptor - received did-write-data"); - [manager forwardPreviousInterceptorDidWriteData]; - }]; + id factory = [[HookInterceptorFactory alloc] + initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager) { + startCount++; + NSLog(@"Interceptor - started call, %@, %@", requestOptions, callOptions); + XCTAssertEqualObjects(requestOptions.host, [[self class] host]); + XCTAssertEqualObjects(requestOptions.path, @"/grpc.testing.TestService/FullDuplexCall"); + XCTAssertEqual(requestOptions.safety, GRPCCallSafetyDefault); + [manager startNextInterceptorWithRequest:[requestOptions copy] + callOptions:[callOptions copy]]; + } + writeDataHook:^(NSData *data, GRPCInterceptorManager *manager) { + writeDataCount++; + NSLog(@"Interceptor - send data, %@", data); + XCTAssertNotEqual(data.length, 0); + [manager writeNextInterceptorWithData:data]; + } + finishHook:^(GRPCInterceptorManager *manager) { + finishCount++; + NSLog(@"Interceptor - finish call"); + [manager finishNextInterceptor]; + } + receiveNextMessagesHook:^(NSUInteger numberOfMessages, GRPCInterceptorManager *manager) { + receiveNextMessageCount++; + NSLog(@"Interceptor - receive next messages, %lu", (unsigned long)numberOfMessages); + [manager receiveNextInterceptorMessages:numberOfMessages]; + } + responseHeaderHook:^(NSDictionary *initialMetadata, GRPCInterceptorManager *manager) { + responseHeaderCount++; + NSLog(@"Interceptor - received initial metadata, %@", initialMetadata); + [manager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; + } + responseDataHook:^(NSData *data, GRPCInterceptorManager *manager) { + responseDataCount++; + NSLog(@"Interceptor - received data, %@", data); + XCTAssertNotEqual(data.length, 0); + [manager forwardPreviousIntercetporWithData:data]; + } + responseCloseHook:^(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager) { + responseCloseCount++; + NSLog(@"Interceptor - received close, %@, %@", trailingMetadata, error); + [manager forwardPreviousInterceptorCloseWithTrailingMetadata:trailingMetadata error:error]; + } + didWriteDataHook:^(GRPCInterceptorManager *manager) { + didWriteDataCount++; + NSLog(@"Interceptor - received did-write-data"); + [manager forwardPreviousInterceptorDidWriteData]; + }]; NSArray *requests = @[ @1, @2, @3, @4 ]; NSArray *responses = @[ @1, @2, @3, @4 ]; @@ -1387,41 +1417,41 @@ BOOL isRemoteInteropTest(NSString *host) { __block BOOL canWriteData = NO; __block GRPCStreamingProtoCall *call = [_service - fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:nil - messageCallback:^(id message) { - XCTAssertLessThan(index, 4, - @"More than 4 responses received."); - id expected = [RMTStreamingOutputCallResponse - messageWithPayloadSize:responses[index]]; - XCTAssertEqualObjects(message, expected); - index += 1; - if (index < 4) { - id request = [RMTStreamingOutputCallRequest - messageWithPayloadSize:requests[index] - requestedResponseSize:responses[index]]; - XCTAssertTrue(canWriteData); - canWriteData = NO; - [call writeMessage:request]; - [call receiveNextMessage]; - } else { - [call finish]; - } - } - closeCallback:^(NSDictionary *trailingMetadata, - NSError *error) { - XCTAssertNil(error, - @"Finished with unexpected error: %@", - error); - XCTAssertEqual(index, 4, - @"Received %i responses instead of 4.", - index); - [expectation fulfill]; - } - writeMessageCallback:^{ - canWriteData = YES; - }] - callOptions:options]; + fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:^(id message) { + XCTAssertLessThan(index, 4, + @"More than 4 responses received."); + id expected = [RMTStreamingOutputCallResponse + messageWithPayloadSize:responses[index]]; + XCTAssertEqualObjects(message, expected); + index += 1; + if (index < 4) { + id request = [RMTStreamingOutputCallRequest + messageWithPayloadSize:requests[index] + requestedResponseSize:responses[index]]; + XCTAssertTrue(canWriteData); + canWriteData = NO; + [call writeMessage:request]; + [call receiveNextMessage]; + } else { + [call finish]; + } + } + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + XCTAssertNil(error, + @"Finished with unexpected error: %@", + error); + XCTAssertEqual(index, 4, + @"Received %i responses instead of 4.", + index); + [expectation fulfill]; + } + writeMessageCallback:^{ + canWriteData = YES; + }] + callOptions:options]; [call start]; [call receiveNextMessage]; [call writeMessage:request]; @@ -1453,45 +1483,53 @@ BOOL isRemoteInteropTest(NSString *host) { __block NSUInteger responseHeaderCount = 0; __block NSUInteger responseDataCount = 0; __block NSUInteger responseCloseCount = 0; - id factory = - [[HookInterceptorFactory alloc] initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager) { - startCount++; - [manager startNextInterceptorWithRequest:[requestOptions copy] callOptions:[callOptions copy]]; - } - writeDataHook:^(NSData *data, GRPCInterceptorManager *manager) { - writeDataCount++; - if (index < kCancelAfterWrites) { - [manager writeNextInterceptorWithData:data]; - } else if (index == kCancelAfterWrites) { - [manager cancelNextInterceptor]; - [manager forwardPreviousIntercetporWithData:[[RMTStreamingOutputCallResponse messageWithPayloadSize:responses[index]] data]]; - } else { // (index > kCancelAfterWrites) - [manager forwardPreviousIntercetporWithData:[[RMTStreamingOutputCallResponse messageWithPayloadSize:responses[index]] data]]; - } - } - finishHook:^(GRPCInterceptorManager *manager) { - finishCount++; - // finish must happen after the hijacking, so directly reply with a close - [manager forwardPreviousInterceptorCloseWithTrailingMetadata:@{ @"grpc-status" : @"0" } error:nil]; - } - receiveNextMessagesHook:nil - responseHeaderHook:^(NSDictionary *initialMetadata, GRPCInterceptorManager *manager) { - responseHeaderCount++; - [manager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; - } - responseDataHook:^(NSData *data, GRPCInterceptorManager *manager) { - responseDataCount++; - [manager forwardPreviousIntercetporWithData:data]; - } - responseCloseHook:^(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager) { - responseCloseCount++; - // since we canceled the call, it should return cancel error - XCTAssertNil(trailingMetadata); - XCTAssertNotNil(error); - XCTAssertEqual(error.code, GRPC_STATUS_CANCELLED); - } - didWriteDataHook:nil]; + id factory = [[HookInterceptorFactory alloc] + initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager) { + startCount++; + [manager startNextInterceptorWithRequest:[requestOptions copy] + callOptions:[callOptions copy]]; + } + writeDataHook:^(NSData *data, GRPCInterceptorManager *manager) { + writeDataCount++; + if (index < kCancelAfterWrites) { + [manager writeNextInterceptorWithData:data]; + } else if (index == kCancelAfterWrites) { + [manager cancelNextInterceptor]; + [manager forwardPreviousIntercetporWithData:[[RMTStreamingOutputCallResponse + messageWithPayloadSize:responses[index]] + data]]; + } else { // (index > kCancelAfterWrites) + [manager forwardPreviousIntercetporWithData:[[RMTStreamingOutputCallResponse + messageWithPayloadSize:responses[index]] + data]]; + } + } + finishHook:^(GRPCInterceptorManager *manager) { + finishCount++; + // finish must happen after the hijacking, so directly reply with a close + [manager forwardPreviousInterceptorCloseWithTrailingMetadata:@{@"grpc-status" : @"0"} + error:nil]; + } + receiveNextMessagesHook:nil + responseHeaderHook:^(NSDictionary *initialMetadata, GRPCInterceptorManager *manager) { + responseHeaderCount++; + [manager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; + } + responseDataHook:^(NSData *data, GRPCInterceptorManager *manager) { + responseDataCount++; + [manager forwardPreviousIntercetporWithData:data]; + } + responseCloseHook:^(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager) { + responseCloseCount++; + // since we canceled the call, it should return cancel error + XCTAssertNil(trailingMetadata); + XCTAssertNotNil(error); + XCTAssertEqual(error.code, GRPC_STATUS_CANCELLED); + } + didWriteDataHook:nil]; NSArray *requests = @[ @1, @2, @3, @4 ]; @@ -1504,36 +1542,36 @@ BOOL isRemoteInteropTest(NSString *host) { options.interceptorFactories = @[ [[DefaultInterceptorFactory alloc] init], factory ]; __block GRPCStreamingProtoCall *call = [_service - fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:nil - messageCallback:^(id message) { - XCTAssertLessThan(index, 4, - @"More than 4 responses received."); - id expected = [RMTStreamingOutputCallResponse - messageWithPayloadSize:responses[index]]; - XCTAssertEqualObjects(message, expected); - index += 1; - if (index < 4) { - id request = [RMTStreamingOutputCallRequest - messageWithPayloadSize:requests[index] - requestedResponseSize:responses[index]]; - [call writeMessage:request]; - [call receiveNextMessage]; - } else { - [call finish]; - } - } - closeCallback:^(NSDictionary *trailingMetadata, - NSError *error) { - XCTAssertNil(error, - @"Finished with unexpected error: %@", - error); - XCTAssertEqual(index, 4, - @"Received %i responses instead of 4.", - index); - [expectation fulfill]; - }] - callOptions:options]; + fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:^(id message) { + XCTAssertLessThan(index, 4, + @"More than 4 responses received."); + id expected = [RMTStreamingOutputCallResponse + messageWithPayloadSize:responses[index]]; + XCTAssertEqualObjects(message, expected); + index += 1; + if (index < 4) { + id request = [RMTStreamingOutputCallRequest + messageWithPayloadSize:requests[index] + requestedResponseSize:responses[index]]; + [call writeMessage:request]; + [call receiveNextMessage]; + } else { + [call finish]; + } + } + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + XCTAssertNil(error, + @"Finished with unexpected error: %@", + error); + XCTAssertEqual(index, 4, + @"Received %i responses instead of 4.", + index); + [expectation fulfill]; + }] + callOptions:options]; [call start]; [call receiveNextMessage]; [call writeMessage:request]; From a2421cdeb169f9cb1947cb95924f21424b91e91c Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 24 Apr 2019 19:06:32 -0700 Subject: [PATCH 0043/1555] Remove internal link --- .../Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets | 1 - 1 file changed, 1 deletion(-) diff --git a/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets b/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets index befff4d41c0..784f789528e 100644 --- a/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets +++ b/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets @@ -42,7 +42,6 @@ - From 76e3489216204951f0115f4f007a782272876286 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 12 Jul 2018 16:36:35 +0200 Subject: [PATCH 0044/1555] csharp: support slice-by-slice deserialization --- .../Grpc.Core.Api/DeserializationContext.cs | 19 +- src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj | 8 + .../Grpc.Core.Tests/Grpc.Core.Tests.csproj | 4 + .../Internal/AsyncCallServerTest.cs | 12 +- .../Grpc.Core.Tests/Internal/AsyncCallTest.cs | 49 ++-- .../DefaultDeserializationContextTest.cs | 240 ++++++++++++++++++ .../Internal/FakeBufferReaderManager.cs | 118 +++++++++ .../Internal/FakeBufferReaderManagerTest.cs | 121 +++++++++ .../Internal/ReusableSliceBufferTest.cs | 151 +++++++++++ .../Grpc.Core.Tests/Internal/SliceTest.cs | 83 ++++++ src/csharp/Grpc.Core/Grpc.Core.csproj | 9 + src/csharp/Grpc.Core/Internal/AsyncCall.cs | 10 +- .../Grpc.Core/Internal/AsyncCallBase.cs | 15 +- .../Internal/BatchContextSafeHandle.cs | 42 ++- .../Grpc.Core/Internal/CallSafeHandle.cs | 4 +- .../Internal/DefaultDeserializationContext.cs | 64 ++++- src/csharp/Grpc.Core/Internal/INativeCall.cs | 4 +- .../Internal/NativeMethods.Generated.cs | 11 + .../Grpc.Core/Internal/ReusableSliceBuffer.cs | 148 +++++++++++ src/csharp/Grpc.Core/Internal/Slice.cs | 68 +++++ src/csharp/ext/grpc_csharp_ext.c | 46 ++++ src/csharp/tests.json | 4 + .../runtimes/grpc_csharp_ext_dummy_stubs.c | 4 + .../Grpc.Core/Internal/native_methods.include | 1 + 24 files changed, 1181 insertions(+), 54 deletions(-) create mode 100644 src/csharp/Grpc.Core.Tests/Internal/DefaultDeserializationContextTest.cs create mode 100644 src/csharp/Grpc.Core.Tests/Internal/FakeBufferReaderManager.cs create mode 100644 src/csharp/Grpc.Core.Tests/Internal/FakeBufferReaderManagerTest.cs create mode 100644 src/csharp/Grpc.Core.Tests/Internal/ReusableSliceBufferTest.cs create mode 100644 src/csharp/Grpc.Core.Tests/Internal/SliceTest.cs create mode 100644 src/csharp/Grpc.Core/Internal/ReusableSliceBuffer.cs create mode 100644 src/csharp/Grpc.Core/Internal/Slice.cs diff --git a/src/csharp/Grpc.Core.Api/DeserializationContext.cs b/src/csharp/Grpc.Core.Api/DeserializationContext.cs index d69e0db5bdf..966bcfa8c8e 100644 --- a/src/csharp/Grpc.Core.Api/DeserializationContext.cs +++ b/src/csharp/Grpc.Core.Api/DeserializationContext.cs @@ -39,7 +39,7 @@ namespace Grpc.Core /// Also, allocating a new buffer each time can put excessive pressure on GC, especially if /// the payload is more than 86700 bytes large (which means the newly allocated buffer will be placed in LOH, /// and LOH object can only be garbage collected via a full ("stop the world") GC run). - /// NOTE: Deserializers are expected not to call this method more than once per received message + /// NOTE: Deserializers are expected not to call this method (or other payload accessor methods) more than once per received message /// (as there is no practical reason for doing so) and DeserializationContext implementations are free to assume so. /// /// byte array containing the entire payload. @@ -47,5 +47,22 @@ namespace Grpc.Core { throw new NotImplementedException(); } + +#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY + /// + /// Gets the entire payload as a ReadOnlySequence. + /// The ReadOnlySequence is only valid for the duration of the deserializer routine and the caller must not access it after the deserializer returns. + /// Using the read only sequence is the most efficient way to access the message payload. Where possible it allows directly + /// accessing the received payload without needing to perform any buffer copying or buffer allocations. + /// NOTE: This method is only available in the netstandard2.0 build of the library. + /// NOTE: Deserializers are expected not to call this method (or other payload accessor methods) more than once per received message + /// (as there is no practical reason for doing so) and DeserializationContext implementations are free to assume so. + /// + /// read only sequence containing the entire payload. + public virtual System.Buffers.ReadOnlySequence PayloadAsReadOnlySequence() + { + throw new NotImplementedException(); + } +#endif } } diff --git a/src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj b/src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj index 6c29530402c..8a32bc757df 100755 --- a/src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj +++ b/src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj @@ -19,12 +19,20 @@ true + + $(DefineConstants);GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY + + + + + + diff --git a/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj b/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj index 23e5d7f65ef..7fef2c77091 100755 --- a/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj +++ b/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj @@ -8,6 +8,10 @@ true + + $(DefineConstants);GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY + + diff --git a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallServerTest.cs b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallServerTest.cs index 5c7d48f786c..fd221613c04 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallServerTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallServerTest.cs @@ -35,6 +35,7 @@ namespace Grpc.Core.Internal.Tests Server server; FakeNativeCall fakeCall; AsyncCallServer asyncCallServer; + FakeBufferReaderManager fakeBufferReaderManager; [SetUp] public void Init() @@ -52,11 +53,13 @@ namespace Grpc.Core.Internal.Tests Marshallers.StringMarshaller.ContextualSerializer, Marshallers.StringMarshaller.ContextualDeserializer, server); asyncCallServer.InitializeForTesting(fakeCall); + fakeBufferReaderManager = new FakeBufferReaderManager(); } [TearDown] public void Cleanup() { + fakeBufferReaderManager.Dispose(); server.ShutdownAsync().Wait(); } @@ -77,7 +80,7 @@ namespace Grpc.Core.Internal.Tests var moveNextTask = requestStream.MoveNext(); fakeCall.ReceivedCloseOnServerCallback.OnReceivedCloseOnServer(true, cancelled: true); - fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null); + fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, CreateNullResponse()); Assert.IsFalse(moveNextTask.Result); AssertFinished(asyncCallServer, fakeCall, finishedTask); @@ -107,7 +110,7 @@ namespace Grpc.Core.Internal.Tests // if a read completion's success==false, the request stream will silently finish // and we rely on C core cancelling the call. var moveNextTask = requestStream.MoveNext(); - fakeCall.ReceivedMessageCallback.OnReceivedMessage(false, null); + fakeCall.ReceivedMessageCallback.OnReceivedMessage(false, CreateNullResponse()); Assert.IsFalse(moveNextTask.Result); fakeCall.ReceivedCloseOnServerCallback.OnReceivedCloseOnServer(true, cancelled: true); @@ -182,5 +185,10 @@ namespace Grpc.Core.Internal.Tests Assert.IsTrue(finishedTask.IsCompleted); Assert.DoesNotThrow(() => finishedTask.Wait()); } + + IBufferReader CreateNullResponse() + { + return fakeBufferReaderManager.CreateNullPayloadBufferReader(); + } } } diff --git a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs index 775849d89b6..78c7f3ad5bb 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs @@ -21,6 +21,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Grpc.Core.Internal; +using Grpc.Core.Utils; using NUnit.Framework; namespace Grpc.Core.Internal.Tests @@ -33,6 +34,7 @@ namespace Grpc.Core.Internal.Tests Channel channel; FakeNativeCall fakeCall; AsyncCall asyncCall; + FakeBufferReaderManager fakeBufferReaderManager; [SetUp] public void Init() @@ -43,12 +45,14 @@ namespace Grpc.Core.Internal.Tests var callDetails = new CallInvocationDetails(channel, "someMethod", null, Marshallers.StringMarshaller, Marshallers.StringMarshaller, new CallOptions()); asyncCall = new AsyncCall(callDetails, fakeCall); + fakeBufferReaderManager = new FakeBufferReaderManager(); } [TearDown] public void Cleanup() { channel.ShutdownAsync().Wait(); + fakeBufferReaderManager.Dispose(); } [Test] @@ -87,7 +91,7 @@ namespace Grpc.Core.Internal.Tests var resultTask = asyncCall.UnaryCallAsync("request1"); fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true, CreateClientSideStatus(StatusCode.InvalidArgument), - null, + CreateNullResponse(), new Metadata()); AssertUnaryResponseError(asyncCall, fakeCall, resultTask, StatusCode.InvalidArgument); @@ -168,7 +172,7 @@ namespace Grpc.Core.Internal.Tests var resultTask = asyncCall.ClientStreamingCallAsync(); fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true, CreateClientSideStatus(StatusCode.InvalidArgument), - null, + CreateNullResponse(), new Metadata()); AssertUnaryResponseError(asyncCall, fakeCall, resultTask, StatusCode.InvalidArgument); @@ -214,7 +218,7 @@ namespace Grpc.Core.Internal.Tests fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true, CreateClientSideStatus(StatusCode.Internal), - null, + CreateNullResponse(), new Metadata()); var ex = Assert.ThrowsAsync(async () => await writeTask); @@ -233,7 +237,7 @@ namespace Grpc.Core.Internal.Tests fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true, CreateClientSideStatus(StatusCode.Internal), - null, + CreateNullResponse(), new Metadata()); fakeCall.SendCompletionCallback.OnSendCompletion(false); @@ -259,7 +263,7 @@ namespace Grpc.Core.Internal.Tests fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true, CreateClientSideStatus(StatusCode.Internal), - null, + CreateNullResponse(), new Metadata()); var ex = Assert.ThrowsAsync(async () => await writeTask); @@ -357,7 +361,7 @@ namespace Grpc.Core.Internal.Tests fakeCall.UnaryResponseClientCallback.OnUnaryResponseClient(true, CreateClientSideStatus(StatusCode.Cancelled), - null, + CreateNullResponse(), new Metadata()); AssertUnaryResponseError(asyncCall, fakeCall, resultTask, StatusCode.Cancelled); @@ -390,7 +394,7 @@ namespace Grpc.Core.Internal.Tests fakeCall.ReceivedResponseHeadersCallback.OnReceivedResponseHeaders(true, new Metadata()); Assert.AreEqual(0, asyncCall.ResponseHeadersAsync.Result.Count); - fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null); + fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, CreateNullResponse()); fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, new ClientSideStatus(Status.DefaultSuccess, new Metadata())); AssertStreamingResponseSuccess(asyncCall, fakeCall, readTask); @@ -405,7 +409,7 @@ namespace Grpc.Core.Internal.Tests // try alternative order of completions fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, new ClientSideStatus(Status.DefaultSuccess, new Metadata())); - fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null); + fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, CreateNullResponse()); AssertStreamingResponseSuccess(asyncCall, fakeCall, readTask); } @@ -417,7 +421,7 @@ namespace Grpc.Core.Internal.Tests var responseStream = new ClientResponseStream(asyncCall); var readTask = responseStream.MoveNext(); - fakeCall.ReceivedMessageCallback.OnReceivedMessage(false, null); // after a failed read, we rely on C core to deliver appropriate status code. + fakeCall.ReceivedMessageCallback.OnReceivedMessage(false, CreateNullResponse()); // after a failed read, we rely on C core to deliver appropriate status code. fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, CreateClientSideStatus(StatusCode.Internal)); AssertStreamingResponseError(asyncCall, fakeCall, readTask, StatusCode.Internal); @@ -441,7 +445,7 @@ namespace Grpc.Core.Internal.Tests var readTask3 = responseStream.MoveNext(); fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, new ClientSideStatus(Status.DefaultSuccess, new Metadata())); - fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null); + fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, CreateNullResponse()); AssertStreamingResponseSuccess(asyncCall, fakeCall, readTask3); } @@ -479,7 +483,7 @@ namespace Grpc.Core.Internal.Tests Assert.DoesNotThrowAsync(async () => await writeTask1); var readTask = responseStream.MoveNext(); - fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null); + fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, CreateNullResponse()); fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, new ClientSideStatus(Status.DefaultSuccess, new Metadata())); AssertStreamingResponseSuccess(asyncCall, fakeCall, readTask); @@ -493,7 +497,7 @@ namespace Grpc.Core.Internal.Tests var responseStream = new ClientResponseStream(asyncCall); var readTask = responseStream.MoveNext(); - fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null); + fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, CreateNullResponse()); fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, new ClientSideStatus(Status.DefaultSuccess, new Metadata())); AssertStreamingResponseSuccess(asyncCall, fakeCall, readTask); @@ -511,7 +515,7 @@ namespace Grpc.Core.Internal.Tests var responseStream = new ClientResponseStream(asyncCall); var readTask = responseStream.MoveNext(); - fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null); + fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, CreateNullResponse()); fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, new ClientSideStatus(Status.DefaultSuccess, new Metadata())); AssertStreamingResponseSuccess(asyncCall, fakeCall, readTask); @@ -533,7 +537,7 @@ namespace Grpc.Core.Internal.Tests Assert.IsFalse(writeTask.IsCompleted); var readTask = responseStream.MoveNext(); - fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null); + fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, CreateNullResponse()); fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, CreateClientSideStatus(StatusCode.PermissionDenied)); var ex = Assert.ThrowsAsync(async () => await writeTask); @@ -552,7 +556,7 @@ namespace Grpc.Core.Internal.Tests var writeTask = requestStream.WriteAsync("request1"); var readTask = responseStream.MoveNext(); - fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null); + fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, CreateNullResponse()); fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, CreateClientSideStatus(StatusCode.PermissionDenied)); fakeCall.SendCompletionCallback.OnSendCompletion(false); @@ -576,7 +580,7 @@ namespace Grpc.Core.Internal.Tests Assert.ThrowsAsync(typeof(TaskCanceledException), async () => await writeTask); var readTask = responseStream.MoveNext(); - fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null); + fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, CreateNullResponse()); fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, CreateClientSideStatus(StatusCode.Cancelled)); AssertStreamingResponseError(asyncCall, fakeCall, readTask, StatusCode.Cancelled); @@ -597,7 +601,7 @@ namespace Grpc.Core.Internal.Tests Assert.AreEqual("response1", responseStream.Current); var readTask2 = responseStream.MoveNext(); - fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null); + fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, CreateNullResponse()); fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, CreateClientSideStatus(StatusCode.Cancelled)); AssertStreamingResponseError(asyncCall, fakeCall, readTask2, StatusCode.Cancelled); @@ -618,7 +622,7 @@ namespace Grpc.Core.Internal.Tests Assert.AreEqual("response1", responseStream.Current); var readTask2 = responseStream.MoveNext(); - fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, null); + fakeCall.ReceivedMessageCallback.OnReceivedMessage(true, CreateNullResponse()); fakeCall.ReceivedStatusOnClientCallback.OnReceivedStatusOnClient(true, CreateClientSideStatus(StatusCode.Cancelled)); AssertStreamingResponseError(asyncCall, fakeCall, readTask2, StatusCode.Cancelled); @@ -638,9 +642,14 @@ namespace Grpc.Core.Internal.Tests return new ClientSideStatus(new Status(statusCode, ""), new Metadata()); } - byte[] CreateResponsePayload() + IBufferReader CreateResponsePayload() { - return Marshallers.StringMarshaller.Serializer("response1"); + return fakeBufferReaderManager.CreateSingleSegmentBufferReader(Marshallers.StringMarshaller.Serializer("response1")); + } + + IBufferReader CreateNullResponse() + { + return fakeBufferReaderManager.CreateNullPayloadBufferReader(); } static void AssertUnaryResponseSuccess(AsyncCall asyncCall, FakeNativeCall fakeCall, Task resultTask) diff --git a/src/csharp/Grpc.Core.Tests/Internal/DefaultDeserializationContextTest.cs b/src/csharp/Grpc.Core.Tests/Internal/DefaultDeserializationContextTest.cs new file mode 100644 index 00000000000..63baab31624 --- /dev/null +++ b/src/csharp/Grpc.Core.Tests/Internal/DefaultDeserializationContextTest.cs @@ -0,0 +1,240 @@ +#region Copyright notice and license + +// Copyright 2019 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using System.Collections.Generic; +using Grpc.Core; +using Grpc.Core.Internal; +using Grpc.Core.Utils; +using NUnit.Framework; + +using System.Runtime.InteropServices; + +#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY +using System.Buffers; +#endif + +namespace Grpc.Core.Internal.Tests +{ + public class DefaultDeserializationContextTest + { + FakeBufferReaderManager fakeBufferReaderManager; + + [SetUp] + public void Init() + { + fakeBufferReaderManager = new FakeBufferReaderManager(); + } + + [TearDown] + public void Cleanup() + { + fakeBufferReaderManager.Dispose(); + } + +#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY + [TestCase] + public void PayloadAsReadOnlySequence_ZeroSegmentPayload() + { + var context = new DefaultDeserializationContext(); + context.Initialize(fakeBufferReaderManager.CreateMultiSegmentBufferReader(new List {})); + + Assert.AreEqual(0, context.PayloadLength); + + var sequence = context.PayloadAsReadOnlySequence(); + + Assert.AreEqual(ReadOnlySequence.Empty, sequence); + Assert.IsTrue(sequence.IsEmpty); + Assert.IsTrue(sequence.IsSingleSegment); + } + + [TestCase(0)] + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + [TestCase(1000)] + public void PayloadAsReadOnlySequence_SingleSegmentPayload(int segmentLength) + { + var origBuffer = GetTestBuffer(segmentLength); + var context = new DefaultDeserializationContext(); + context.Initialize(fakeBufferReaderManager.CreateSingleSegmentBufferReader(origBuffer)); + + Assert.AreEqual(origBuffer.Length, context.PayloadLength); + + var sequence = context.PayloadAsReadOnlySequence(); + + Assert.AreEqual(origBuffer.Length, sequence.Length); + Assert.AreEqual(origBuffer.Length, sequence.First.Length); + Assert.IsTrue(sequence.IsSingleSegment); + CollectionAssert.AreEqual(origBuffer, sequence.First.ToArray()); + } + + [TestCase(0, 5, 10)] + [TestCase(1, 1, 1)] + [TestCase(10, 100, 1000)] + [TestCase(100, 100, 10)] + [TestCase(1000, 1000, 1000)] + public void PayloadAsReadOnlySequence_MultiSegmentPayload(int segmentLen1, int segmentLen2, int segmentLen3) + { + var origBuffer1 = GetTestBuffer(segmentLen1); + var origBuffer2 = GetTestBuffer(segmentLen2); + var origBuffer3 = GetTestBuffer(segmentLen3); + int totalLen = origBuffer1.Length + origBuffer2.Length + origBuffer3.Length; + + var context = new DefaultDeserializationContext(); + context.Initialize(fakeBufferReaderManager.CreateMultiSegmentBufferReader(new List { origBuffer1, origBuffer2, origBuffer3 })); + + Assert.AreEqual(totalLen, context.PayloadLength); + + var sequence = context.PayloadAsReadOnlySequence(); + + Assert.AreEqual(totalLen, sequence.Length); + + var segmentEnumerator = sequence.GetEnumerator(); + + Assert.IsTrue(segmentEnumerator.MoveNext()); + CollectionAssert.AreEqual(origBuffer1, segmentEnumerator.Current.ToArray()); + + Assert.IsTrue(segmentEnumerator.MoveNext()); + CollectionAssert.AreEqual(origBuffer2, segmentEnumerator.Current.ToArray()); + + Assert.IsTrue(segmentEnumerator.MoveNext()); + CollectionAssert.AreEqual(origBuffer3, segmentEnumerator.Current.ToArray()); + + Assert.IsFalse(segmentEnumerator.MoveNext()); + } +#endif + + [TestCase] + public void NullPayloadNotAllowed() + { + var context = new DefaultDeserializationContext(); + Assert.Throws(typeof(InvalidOperationException), () => context.Initialize(fakeBufferReaderManager.CreateNullPayloadBufferReader())); + } + + [TestCase] + public void PayloadAsNewByteBuffer_ZeroSegmentPayload() + { + var context = new DefaultDeserializationContext(); + context.Initialize(fakeBufferReaderManager.CreateMultiSegmentBufferReader(new List {})); + + Assert.AreEqual(0, context.PayloadLength); + + var payload = context.PayloadAsNewBuffer(); + Assert.AreEqual(0, payload.Length); + } + + [TestCase(0)] + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + [TestCase(1000)] + public void PayloadAsNewByteBuffer_SingleSegmentPayload(int segmentLength) + { + var origBuffer = GetTestBuffer(segmentLength); + var context = new DefaultDeserializationContext(); + context.Initialize(fakeBufferReaderManager.CreateSingleSegmentBufferReader(origBuffer)); + + Assert.AreEqual(origBuffer.Length, context.PayloadLength); + + var payload = context.PayloadAsNewBuffer(); + CollectionAssert.AreEqual(origBuffer, payload); + } + + [TestCase(0, 5, 10)] + [TestCase(1, 1, 1)] + [TestCase(10, 100, 1000)] + [TestCase(100, 100, 10)] + [TestCase(1000, 1000, 1000)] + public void PayloadAsNewByteBuffer_MultiSegmentPayload(int segmentLen1, int segmentLen2, int segmentLen3) + { + var origBuffer1 = GetTestBuffer(segmentLen1); + var origBuffer2 = GetTestBuffer(segmentLen2); + var origBuffer3 = GetTestBuffer(segmentLen3); + + var context = new DefaultDeserializationContext(); + context.Initialize(fakeBufferReaderManager.CreateMultiSegmentBufferReader(new List { origBuffer1, origBuffer2, origBuffer3 })); + + var payload = context.PayloadAsNewBuffer(); + + var concatenatedOrigBuffers = new List(); + concatenatedOrigBuffers.AddRange(origBuffer1); + concatenatedOrigBuffers.AddRange(origBuffer2); + concatenatedOrigBuffers.AddRange(origBuffer3); + + Assert.AreEqual(concatenatedOrigBuffers.Count, context.PayloadLength); + Assert.AreEqual(concatenatedOrigBuffers.Count, payload.Length); + CollectionAssert.AreEqual(concatenatedOrigBuffers, payload); + } + + [TestCase] + public void GetPayloadMultipleTimesIsIllegal() + { + var origBuffer = GetTestBuffer(100); + var context = new DefaultDeserializationContext(); + context.Initialize(fakeBufferReaderManager.CreateSingleSegmentBufferReader(origBuffer)); + + Assert.AreEqual(origBuffer.Length, context.PayloadLength); + + var payload = context.PayloadAsNewBuffer(); + CollectionAssert.AreEqual(origBuffer, payload); + + // Getting payload multiple times is illegal + Assert.Throws(typeof(InvalidOperationException), () => context.PayloadAsNewBuffer()); +#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY + Assert.Throws(typeof(InvalidOperationException), () => context.PayloadAsReadOnlySequence()); +#endif + } + + [TestCase] + public void ResetContextAndReinitialize() + { + var origBuffer = GetTestBuffer(100); + var context = new DefaultDeserializationContext(); + context.Initialize(fakeBufferReaderManager.CreateSingleSegmentBufferReader(origBuffer)); + + Assert.AreEqual(origBuffer.Length, context.PayloadLength); + + // Reset invalidates context + context.Reset(); + + Assert.AreEqual(0, context.PayloadLength); + Assert.Throws(typeof(NullReferenceException), () => context.PayloadAsNewBuffer()); +#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY + Assert.Throws(typeof(NullReferenceException), () => context.PayloadAsReadOnlySequence()); +#endif + + // Previously reset context can be initialized again + var origBuffer2 = GetTestBuffer(50); + context.Initialize(fakeBufferReaderManager.CreateSingleSegmentBufferReader(origBuffer2)); + + Assert.AreEqual(origBuffer2.Length, context.PayloadLength); + CollectionAssert.AreEqual(origBuffer2, context.PayloadAsNewBuffer()); + } + + private byte[] GetTestBuffer(int length) + { + var testBuffer = new byte[length]; + for (int i = 0; i < testBuffer.Length; i++) + { + testBuffer[i] = (byte) i; + } + return testBuffer; + } + } +} diff --git a/src/csharp/Grpc.Core.Tests/Internal/FakeBufferReaderManager.cs b/src/csharp/Grpc.Core.Tests/Internal/FakeBufferReaderManager.cs new file mode 100644 index 00000000000..d8d0c0a6354 --- /dev/null +++ b/src/csharp/Grpc.Core.Tests/Internal/FakeBufferReaderManager.cs @@ -0,0 +1,118 @@ +#region Copyright notice and license + +// Copyright 2018 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Threading.Tasks; + +using Grpc.Core.Internal; +using Grpc.Core.Utils; + +namespace Grpc.Core.Internal.Tests +{ + // Creates instances of fake IBufferReader. All created instances will become invalid once Dispose is called. + internal class FakeBufferReaderManager : IDisposable + { + List pinnedHandles = new List(); + bool disposed = false; + public IBufferReader CreateSingleSegmentBufferReader(byte[] data) + { + return CreateMultiSegmentBufferReader(new List { data }); + } + + public IBufferReader CreateMultiSegmentBufferReader(IEnumerable dataSegments) + { + GrpcPreconditions.CheckState(!disposed); + GrpcPreconditions.CheckNotNull(dataSegments); + var segments = new List(); + foreach (var data in dataSegments) + { + GrpcPreconditions.CheckNotNull(data); + segments.Add(GCHandle.Alloc(data, GCHandleType.Pinned)); + } + pinnedHandles.AddRange(segments); // all the allocated GCHandles will be freed on Dispose() + return new FakeBufferReader(segments); + } + + public IBufferReader CreateNullPayloadBufferReader() + { + GrpcPreconditions.CheckState(!disposed); + return new FakeBufferReader(null); + } + + public void Dispose() + { + if (!disposed) + { + disposed = true; + for (int i = 0; i < pinnedHandles.Count; i++) + { + pinnedHandles[i].Free(); + } + } + } + + private class FakeBufferReader : IBufferReader + { + readonly List bufferSegments; + readonly int? totalLength; + readonly IEnumerator segmentEnumerator; + + public FakeBufferReader(List bufferSegments) + { + this.bufferSegments = bufferSegments; + this.totalLength = ComputeTotalLength(bufferSegments); + this.segmentEnumerator = bufferSegments?.GetEnumerator(); + } + + public int? TotalLength => totalLength; + + public bool TryGetNextSlice(out Slice slice) + { + GrpcPreconditions.CheckNotNull(bufferSegments); + if (!segmentEnumerator.MoveNext()) + { + slice = default(Slice); + return false; + } + + var segment = segmentEnumerator.Current; + int sliceLen = ((byte[]) segment.Target).Length; + slice = new Slice(segment.AddrOfPinnedObject(), sliceLen); + return true; + } + + static int? ComputeTotalLength(List bufferSegments) + { + if (bufferSegments == null) + { + return null; + } + + int sum = 0; + foreach (var segment in bufferSegments) + { + var data = (byte[]) segment.Target; + sum += data.Length; + } + return sum; + } + } + } +} diff --git a/src/csharp/Grpc.Core.Tests/Internal/FakeBufferReaderManagerTest.cs b/src/csharp/Grpc.Core.Tests/Internal/FakeBufferReaderManagerTest.cs new file mode 100644 index 00000000000..7c4ff652bd3 --- /dev/null +++ b/src/csharp/Grpc.Core.Tests/Internal/FakeBufferReaderManagerTest.cs @@ -0,0 +1,121 @@ +#region Copyright notice and license + +// Copyright 2018 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using System.Collections.Generic; +using Grpc.Core; +using Grpc.Core.Internal; +using Grpc.Core.Utils; +using NUnit.Framework; + +namespace Grpc.Core.Internal.Tests +{ + public class FakeBufferReaderManagerTest + { + FakeBufferReaderManager fakeBufferReaderManager; + + [SetUp] + public void Init() + { + fakeBufferReaderManager = new FakeBufferReaderManager(); + } + + [TearDown] + public void Cleanup() + { + fakeBufferReaderManager.Dispose(); + } + + [TestCase] + public void NullPayload() + { + var fakeBufferReader = fakeBufferReaderManager.CreateNullPayloadBufferReader(); + Assert.IsFalse(fakeBufferReader.TotalLength.HasValue); + Assert.Throws(typeof(ArgumentNullException), () => fakeBufferReader.TryGetNextSlice(out Slice slice)); + } + [TestCase] + public void ZeroSegmentPayload() + { + var fakeBufferReader = fakeBufferReaderManager.CreateMultiSegmentBufferReader(new List {}); + Assert.AreEqual(0, fakeBufferReader.TotalLength.Value); + Assert.IsFalse(fakeBufferReader.TryGetNextSlice(out Slice slice)); + } + + [TestCase(0)] + [TestCase(1)] + [TestCase(10)] + [TestCase(30)] + [TestCase(100)] + [TestCase(1000)] + public void SingleSegmentPayload(int bufferLen) + { + var origBuffer = GetTestBuffer(bufferLen); + var fakeBufferReader = fakeBufferReaderManager.CreateSingleSegmentBufferReader(origBuffer); + Assert.AreEqual(origBuffer.Length, fakeBufferReader.TotalLength.Value); + + Assert.IsTrue(fakeBufferReader.TryGetNextSlice(out Slice slice)); + AssertSliceDataEqual(origBuffer, slice); + + Assert.IsFalse(fakeBufferReader.TryGetNextSlice(out Slice slice2)); + } + + [TestCase(0, 5, 10)] + [TestCase(1, 1, 1)] + [TestCase(10, 100, 1000)] + [TestCase(100, 100, 10)] + [TestCase(1000, 1000, 1000)] + public void MultiSegmentPayload(int segmentLen1, int segmentLen2, int segmentLen3) + { + var origBuffer1 = GetTestBuffer(segmentLen1); + var origBuffer2 = GetTestBuffer(segmentLen2); + var origBuffer3 = GetTestBuffer(segmentLen3); + var fakeBufferReader = fakeBufferReaderManager.CreateMultiSegmentBufferReader(new List { origBuffer1, origBuffer2, origBuffer3 }); + + Assert.AreEqual(origBuffer1.Length + origBuffer2.Length + origBuffer3.Length, fakeBufferReader.TotalLength.Value); + + Assert.IsTrue(fakeBufferReader.TryGetNextSlice(out Slice slice1)); + AssertSliceDataEqual(origBuffer1, slice1); + + Assert.IsTrue(fakeBufferReader.TryGetNextSlice(out Slice slice2)); + AssertSliceDataEqual(origBuffer2, slice2); + + Assert.IsTrue(fakeBufferReader.TryGetNextSlice(out Slice slice3)); + AssertSliceDataEqual(origBuffer3, slice3); + + Assert.IsFalse(fakeBufferReader.TryGetNextSlice(out Slice slice4)); + } + + private void AssertSliceDataEqual(byte[] expected, Slice actual) + { + var actualSliceData = new byte[actual.Length]; + actual.CopyTo(new ArraySegment(actualSliceData)); + CollectionAssert.AreEqual(expected, actualSliceData); + } + + // create a buffer of given size and fill it with some data + private byte[] GetTestBuffer(int length) + { + var testBuffer = new byte[length]; + for (int i = 0; i < testBuffer.Length; i++) + { + testBuffer[i] = (byte) i; + } + return testBuffer; + } + } +} diff --git a/src/csharp/Grpc.Core.Tests/Internal/ReusableSliceBufferTest.cs b/src/csharp/Grpc.Core.Tests/Internal/ReusableSliceBufferTest.cs new file mode 100644 index 00000000000..7630785aef4 --- /dev/null +++ b/src/csharp/Grpc.Core.Tests/Internal/ReusableSliceBufferTest.cs @@ -0,0 +1,151 @@ +#region Copyright notice and license + +// Copyright 2018 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using System.Collections.Generic; +using System.Linq; +using Grpc.Core; +using Grpc.Core.Internal; +using Grpc.Core.Utils; +using NUnit.Framework; + +using System.Runtime.InteropServices; + +#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY +using System.Buffers; +#endif + +namespace Grpc.Core.Internal.Tests +{ + // Converts IBufferReader into instances of ReadOnlySequence + // Objects representing the sequence segments are cached to decrease GC load. + public class ReusableSliceBufferTest + { + FakeBufferReaderManager fakeBufferReaderManager; + + [SetUp] + public void Init() + { + fakeBufferReaderManager = new FakeBufferReaderManager(); + } + + [TearDown] + public void Cleanup() + { + fakeBufferReaderManager.Dispose(); + } + +#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY + [TestCase] + public void NullPayload() + { + var sliceBuffer = new ReusableSliceBuffer(); + Assert.Throws(typeof(ArgumentNullException), () => sliceBuffer.PopulateFrom(fakeBufferReaderManager.CreateNullPayloadBufferReader())); + } + + [TestCase] + public void ZeroSegmentPayload() + { + var sliceBuffer = new ReusableSliceBuffer(); + var sequence = sliceBuffer.PopulateFrom(fakeBufferReaderManager.CreateMultiSegmentBufferReader(new List {})); + + Assert.AreEqual(ReadOnlySequence.Empty, sequence); + Assert.IsTrue(sequence.IsEmpty); + Assert.IsTrue(sequence.IsSingleSegment); + } + + [TestCase] + public void SegmentsAreCached() + { + var bufferSegments1 = Enumerable.Range(0, 100).Select((_) => GetTestBuffer(50)).ToList(); + var bufferSegments2 = Enumerable.Range(0, 100).Select((_) => GetTestBuffer(50)).ToList(); + + var sliceBuffer = new ReusableSliceBuffer(); + + var sequence1 = sliceBuffer.PopulateFrom(fakeBufferReaderManager.CreateMultiSegmentBufferReader(bufferSegments1)); + var memoryManagers1 = GetMemoryManagersForSequenceSegments(sequence1); + + sliceBuffer.Invalidate(); + + var sequence2 = sliceBuffer.PopulateFrom(fakeBufferReaderManager.CreateMultiSegmentBufferReader(bufferSegments2)); + var memoryManagers2 = GetMemoryManagersForSequenceSegments(sequence2); + + // check memory managers are identical objects (i.e. they've been reused) + CollectionAssert.AreEquivalent(memoryManagers1, memoryManagers2); + } + + [TestCase] + public void MultiSegmentPayload_LotsOfSegments() + { + var bufferSegments = Enumerable.Range(0, ReusableSliceBuffer.MaxCachedSegments + 100).Select((_) => GetTestBuffer(10)).ToList(); + + var sliceBuffer = new ReusableSliceBuffer(); + var sequence = sliceBuffer.PopulateFrom(fakeBufferReaderManager.CreateMultiSegmentBufferReader(bufferSegments)); + + int index = 0; + foreach (var memory in sequence) + { + CollectionAssert.AreEqual(bufferSegments[index], memory.ToArray()); + index ++; + } + } + + [TestCase] + public void InvalidateMakesSequenceUnusable() + { + var origBuffer = GetTestBuffer(100); + + var sliceBuffer = new ReusableSliceBuffer(); + var sequence = sliceBuffer.PopulateFrom(fakeBufferReaderManager.CreateMultiSegmentBufferReader(new List { origBuffer })); + + Assert.AreEqual(origBuffer.Length, sequence.Length); + + sliceBuffer.Invalidate(); + + // Invalidate with make the returned sequence completely unusable and broken, users must not use it beyond the deserializer functions. + Assert.Throws(typeof(ArgumentOutOfRangeException), () => { var first = sequence.First; }); + } + + private List> GetMemoryManagersForSequenceSegments(ReadOnlySequence sequence) + { + var result = new List>(); + foreach (var memory in sequence) + { + Assert.IsTrue(MemoryMarshal.TryGetMemoryManager(memory, out MemoryManager memoryManager)); + result.Add(memoryManager); + } + return result; + } +#else + [TestCase] + public void OnlySupportedOnNetCore() + { + // Test case needs to exist to make C# sanity test happy. + } +#endif + private byte[] GetTestBuffer(int length) + { + var testBuffer = new byte[length]; + for (int i = 0; i < testBuffer.Length; i++) + { + testBuffer[i] = (byte) i; + } + return testBuffer; + } + } +} diff --git a/src/csharp/Grpc.Core.Tests/Internal/SliceTest.cs b/src/csharp/Grpc.Core.Tests/Internal/SliceTest.cs new file mode 100644 index 00000000000..eb090bbfa50 --- /dev/null +++ b/src/csharp/Grpc.Core.Tests/Internal/SliceTest.cs @@ -0,0 +1,83 @@ +#region Copyright notice and license + +// Copyright 2018 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using Grpc.Core; +using Grpc.Core.Internal; +using Grpc.Core.Utils; +using NUnit.Framework; + +using System.Runtime.InteropServices; + +namespace Grpc.Core.Internal.Tests +{ + public class SliceTest + { + [TestCase(0)] + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + [TestCase(1000)] + public void SliceFromNativePtr_CopyToArraySegment(int bufferLength) + { + var origBuffer = GetTestBuffer(bufferLength); + var gcHandle = GCHandle.Alloc(origBuffer, GCHandleType.Pinned); + try + { + var slice = new Slice(gcHandle.AddrOfPinnedObject(), origBuffer.Length); + Assert.AreEqual(bufferLength, slice.Length); + + var newBuffer = new byte[bufferLength]; + slice.CopyTo(new ArraySegment(newBuffer)); + CollectionAssert.AreEqual(origBuffer, newBuffer); + } + finally + { + gcHandle.Free(); + } + } + + [TestCase] + public void SliceFromNativePtr_CopyToArraySegmentTooSmall() + { + var origBuffer = GetTestBuffer(100); + var gcHandle = GCHandle.Alloc(origBuffer, GCHandleType.Pinned); + try + { + var slice = new Slice(gcHandle.AddrOfPinnedObject(), origBuffer.Length); + var tooSmall = new byte[origBuffer.Length - 1]; + Assert.Catch(typeof(ArgumentException), () => slice.CopyTo(new ArraySegment(tooSmall))); + } + finally + { + gcHandle.Free(); + } + } + + // create a buffer of given size and fill it with some data + private byte[] GetTestBuffer(int length) + { + var testBuffer = new byte[length]; + for (int i = 0; i < testBuffer.Length; i++) + { + testBuffer[i] = (byte) i; + } + return testBuffer; + } + } +} diff --git a/src/csharp/Grpc.Core/Grpc.Core.csproj b/src/csharp/Grpc.Core/Grpc.Core.csproj index b7c191ea6a9..afd60e73a21 100755 --- a/src/csharp/Grpc.Core/Grpc.Core.csproj +++ b/src/csharp/Grpc.Core/Grpc.Core.csproj @@ -19,6 +19,15 @@ true + + true + + + + 7.2 + $(DefineConstants);GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY + + diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs index 785081c341a..a1c688140d1 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs @@ -111,7 +111,7 @@ namespace Grpc.Core.Internal { using (profiler.NewScope("AsyncCall.UnaryCall.HandleBatch")) { - HandleUnaryResponse(success, ctx.GetReceivedStatusOnClient(), ctx.GetReceivedMessage(), ctx.GetReceivedInitialMetadata()); + HandleUnaryResponse(success, ctx.GetReceivedStatusOnClient(), ctx.GetReceivedMessageReader(), ctx.GetReceivedInitialMetadata()); } } catch (Exception e) @@ -537,14 +537,14 @@ namespace Grpc.Core.Internal /// /// Handler for unary response completion. /// - private void HandleUnaryResponse(bool success, ClientSideStatus receivedStatus, byte[] receivedMessage, Metadata responseHeaders) + private void HandleUnaryResponse(bool success, ClientSideStatus receivedStatus, IBufferReader receivedMessageReader, Metadata responseHeaders) { // NOTE: because this event is a result of batch containing GRPC_OP_RECV_STATUS_ON_CLIENT, // success will be always set to true. TaskCompletionSource delayedStreamingWriteTcs = null; TResponse msg = default(TResponse); - var deserializeException = TryDeserialize(receivedMessage, out msg); + var deserializeException = TryDeserialize(receivedMessageReader, out msg); bool releasedResources; lock (myLock) @@ -634,9 +634,9 @@ namespace Grpc.Core.Internal IUnaryResponseClientCallback UnaryResponseClientCallback => this; - void IUnaryResponseClientCallback.OnUnaryResponseClient(bool success, ClientSideStatus receivedStatus, byte[] receivedMessage, Metadata responseHeaders) + void IUnaryResponseClientCallback.OnUnaryResponseClient(bool success, ClientSideStatus receivedStatus, IBufferReader receivedMessageReader, Metadata responseHeaders) { - HandleUnaryResponse(success, receivedStatus, receivedMessage, responseHeaders); + HandleUnaryResponse(success, receivedStatus, receivedMessageReader, responseHeaders); } IReceivedStatusOnClientCallback ReceivedStatusOnClientCallback => this; diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs index 39c9f7c6160..9497371cc1b 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs @@ -228,12 +228,12 @@ namespace Grpc.Core.Internal } } - protected Exception TryDeserialize(byte[] payload, out TRead msg) + protected Exception TryDeserialize(IBufferReader reader, out TRead msg) { DefaultDeserializationContext context = null; try { - context = DefaultDeserializationContext.GetInitializedThreadLocal(payload); + context = DefaultDeserializationContext.GetInitializedThreadLocal(reader); msg = deserializer(context); return null; } @@ -245,7 +245,6 @@ namespace Grpc.Core.Internal finally { context?.Reset(); - } } @@ -333,21 +332,21 @@ namespace Grpc.Core.Internal /// /// Handles streaming read completion. /// - protected void HandleReadFinished(bool success, byte[] receivedMessage) + protected void HandleReadFinished(bool success, IBufferReader receivedMessageReader) { // if success == false, received message will be null. It that case we will // treat this completion as the last read an rely on C core to handle the failed // read (e.g. deliver approriate statusCode on the clientside). TRead msg = default(TRead); - var deserializeException = (success && receivedMessage != null) ? TryDeserialize(receivedMessage, out msg) : null; + var deserializeException = (success && receivedMessageReader.TotalLength.HasValue) ? TryDeserialize(receivedMessageReader, out msg) : null; TaskCompletionSource origTcs = null; bool releasedResources; lock (myLock) { origTcs = streamingReadTcs; - if (receivedMessage == null) + if (!receivedMessageReader.TotalLength.HasValue) { // This was the last read. readingDone = true; @@ -391,9 +390,9 @@ namespace Grpc.Core.Internal IReceivedMessageCallback ReceivedMessageCallback => this; - void IReceivedMessageCallback.OnReceivedMessage(bool success, byte[] receivedMessage) + void IReceivedMessageCallback.OnReceivedMessage(bool success, IBufferReader receivedMessageReader) { - HandleReadFinished(success, receivedMessage); + HandleReadFinished(success, receivedMessageReader); } } } diff --git a/src/csharp/Grpc.Core/Internal/BatchContextSafeHandle.cs b/src/csharp/Grpc.Core/Internal/BatchContextSafeHandle.cs index 085e7faf595..61af26e9f90 100644 --- a/src/csharp/Grpc.Core/Internal/BatchContextSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/BatchContextSafeHandle.cs @@ -30,10 +30,17 @@ namespace Grpc.Core.Internal void OnComplete(bool success); } + internal interface IBufferReader + { + int? TotalLength { get; } + + bool TryGetNextSlice(out Slice slice); + } + /// /// grpcsharp_batch_context /// - internal class BatchContextSafeHandle : SafeHandleZeroIsInvalid, IOpCompletionCallback, IPooledObject + internal class BatchContextSafeHandle : SafeHandleZeroIsInvalid, IOpCompletionCallback, IPooledObject, IBufferReader { static readonly NativeMethods Native = NativeMethods.Get(); static readonly ILogger Logger = GrpcEnvironment.Logger.ForType(); @@ -106,6 +113,25 @@ namespace Grpc.Core.Internal return data; } + public bool GetReceivedMessageNextSlicePeek(out Slice slice) + { + UIntPtr sliceLen; + IntPtr sliceDataPtr; + + if (0 == Native.grpcsharp_batch_context_recv_message_next_slice_peek(this, out sliceLen, out sliceDataPtr)) + { + slice = default(Slice); + return false; + } + slice = new Slice(sliceDataPtr, (int) sliceLen); + return true; + } + + public IBufferReader GetReceivedMessageReader() + { + return this; + } + // Gets data of receive_close_on_server completion. public bool GetReceivedCloseOnServerCancelled() { @@ -153,6 +179,20 @@ namespace Grpc.Core.Internal } } + int? IBufferReader.TotalLength + { + get + { + var len = Native.grpcsharp_batch_context_recv_message_length(this); + return len != new IntPtr(-1) ? (int?) len : null; + } + } + + bool IBufferReader.TryGetNextSlice(out Slice slice) + { + return GetReceivedMessageNextSlicePeek(out slice); + } + struct CompletionCallbackData { public CompletionCallbackData(BatchCompletionDelegate callback, object state) diff --git a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs index a3ef3e61ee1..858d2a69605 100644 --- a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs @@ -35,11 +35,11 @@ namespace Grpc.Core.Internal // Completion handlers are pre-allocated to avoid unneccessary delegate allocations. // The "state" field is used to store the actual callback to invoke. static readonly BatchCompletionDelegate CompletionHandler_IUnaryResponseClientCallback = - (success, context, state) => ((IUnaryResponseClientCallback)state).OnUnaryResponseClient(success, context.GetReceivedStatusOnClient(), context.GetReceivedMessage(), context.GetReceivedInitialMetadata()); + (success, context, state) => ((IUnaryResponseClientCallback)state).OnUnaryResponseClient(success, context.GetReceivedStatusOnClient(), context.GetReceivedMessageReader(), context.GetReceivedInitialMetadata()); static readonly BatchCompletionDelegate CompletionHandler_IReceivedStatusOnClientCallback = (success, context, state) => ((IReceivedStatusOnClientCallback)state).OnReceivedStatusOnClient(success, context.GetReceivedStatusOnClient()); static readonly BatchCompletionDelegate CompletionHandler_IReceivedMessageCallback = - (success, context, state) => ((IReceivedMessageCallback)state).OnReceivedMessage(success, context.GetReceivedMessage()); + (success, context, state) => ((IReceivedMessageCallback)state).OnReceivedMessage(success, context.GetReceivedMessageReader()); static readonly BatchCompletionDelegate CompletionHandler_IReceivedResponseHeadersCallback = (success, context, state) => ((IReceivedResponseHeadersCallback)state).OnReceivedResponseHeaders(success, context.GetReceivedInitialMetadata()); static readonly BatchCompletionDelegate CompletionHandler_ISendCompletionCallback = diff --git a/src/csharp/Grpc.Core/Internal/DefaultDeserializationContext.cs b/src/csharp/Grpc.Core/Internal/DefaultDeserializationContext.cs index 7ace80e8d53..bac7bbe4c59 100644 --- a/src/csharp/Grpc.Core/Internal/DefaultDeserializationContext.cs +++ b/src/csharp/Grpc.Core/Internal/DefaultDeserializationContext.cs @@ -20,6 +20,10 @@ using Grpc.Core.Utils; using System; using System.Threading; +#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY +using System.Buffers; +#endif + namespace Grpc.Core.Internal { internal class DefaultDeserializationContext : DeserializationContext @@ -27,40 +31,74 @@ namespace Grpc.Core.Internal static readonly ThreadLocal threadLocalInstance = new ThreadLocal(() => new DefaultDeserializationContext(), false); - byte[] payload; - bool alreadyCalledPayloadAsNewBuffer; + IBufferReader bufferReader; + int payloadLength; +#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY + ReusableSliceBuffer cachedSliceBuffer = new ReusableSliceBuffer(); +#endif public DefaultDeserializationContext() { Reset(); } - public override int PayloadLength => payload.Length; + public override int PayloadLength => payloadLength; public override byte[] PayloadAsNewBuffer() { - GrpcPreconditions.CheckState(!alreadyCalledPayloadAsNewBuffer); - alreadyCalledPayloadAsNewBuffer = true; - return payload; + var buffer = new byte[payloadLength]; + FillContinguousBuffer(bufferReader, buffer); + return buffer; } - public void Initialize(byte[] payload) +#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY + public override ReadOnlySequence PayloadAsReadOnlySequence() { - this.payload = GrpcPreconditions.CheckNotNull(payload); - this.alreadyCalledPayloadAsNewBuffer = false; + var sequence = cachedSliceBuffer.PopulateFrom(bufferReader); + GrpcPreconditions.CheckState(sequence.Length == payloadLength); + return sequence; + } +#endif + + public void Initialize(IBufferReader bufferReader) + { + this.bufferReader = GrpcPreconditions.CheckNotNull(bufferReader); + this.payloadLength = bufferReader.TotalLength.Value; // payload must not be null } public void Reset() { - this.payload = null; - this.alreadyCalledPayloadAsNewBuffer = true; // mark payload as read + this.bufferReader = null; + this.payloadLength = 0; +#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY + this.cachedSliceBuffer.Invalidate(); +#endif } - public static DefaultDeserializationContext GetInitializedThreadLocal(byte[] payload) + public static DefaultDeserializationContext GetInitializedThreadLocal(IBufferReader bufferReader) { var instance = threadLocalInstance.Value; - instance.Initialize(payload); + instance.Initialize(bufferReader); return instance; } + +#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY + private void FillContinguousBuffer(IBufferReader reader, byte[] destination) + { + PayloadAsReadOnlySequence().CopyTo(new Span(destination)); + } +#else + private void FillContinguousBuffer(IBufferReader reader, byte[] destination) + { + int offset = 0; + while (reader.TryGetNextSlice(out Slice slice)) + { + slice.CopyTo(new ArraySegment(destination, offset, (int)slice.Length)); + offset += (int)slice.Length; + } + // check that we filled the entire destination + GrpcPreconditions.CheckState(offset == payloadLength); + } +#endif } } diff --git a/src/csharp/Grpc.Core/Internal/INativeCall.cs b/src/csharp/Grpc.Core/Internal/INativeCall.cs index 5c35b2ba461..98117c6988a 100644 --- a/src/csharp/Grpc.Core/Internal/INativeCall.cs +++ b/src/csharp/Grpc.Core/Internal/INativeCall.cs @@ -22,7 +22,7 @@ namespace Grpc.Core.Internal { internal interface IUnaryResponseClientCallback { - void OnUnaryResponseClient(bool success, ClientSideStatus receivedStatus, byte[] receivedMessage, Metadata responseHeaders); + void OnUnaryResponseClient(bool success, ClientSideStatus receivedStatus, IBufferReader receivedMessageReader, Metadata responseHeaders); } // Received status for streaming response calls. @@ -33,7 +33,7 @@ namespace Grpc.Core.Internal internal interface IReceivedMessageCallback { - void OnReceivedMessage(bool success, byte[] receivedMessage); + void OnReceivedMessage(bool success, IBufferReader receivedMessageReader); } internal interface IReceivedResponseHeadersCallback diff --git a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs index a1387aff562..9752a8e5a05 100644 --- a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs +++ b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs @@ -41,6 +41,7 @@ namespace Grpc.Core.Internal public readonly Delegates.grpcsharp_batch_context_recv_initial_metadata_delegate grpcsharp_batch_context_recv_initial_metadata; public readonly Delegates.grpcsharp_batch_context_recv_message_length_delegate grpcsharp_batch_context_recv_message_length; public readonly Delegates.grpcsharp_batch_context_recv_message_to_buffer_delegate grpcsharp_batch_context_recv_message_to_buffer; + public readonly Delegates.grpcsharp_batch_context_recv_message_next_slice_peek_delegate grpcsharp_batch_context_recv_message_next_slice_peek; public readonly Delegates.grpcsharp_batch_context_recv_status_on_client_status_delegate grpcsharp_batch_context_recv_status_on_client_status; public readonly Delegates.grpcsharp_batch_context_recv_status_on_client_details_delegate grpcsharp_batch_context_recv_status_on_client_details; public readonly Delegates.grpcsharp_batch_context_recv_status_on_client_trailing_metadata_delegate grpcsharp_batch_context_recv_status_on_client_trailing_metadata; @@ -142,6 +143,7 @@ namespace Grpc.Core.Internal this.grpcsharp_batch_context_recv_initial_metadata = GetMethodDelegate(library); this.grpcsharp_batch_context_recv_message_length = GetMethodDelegate(library); this.grpcsharp_batch_context_recv_message_to_buffer = GetMethodDelegate(library); + this.grpcsharp_batch_context_recv_message_next_slice_peek = GetMethodDelegate(library); this.grpcsharp_batch_context_recv_status_on_client_status = GetMethodDelegate(library); this.grpcsharp_batch_context_recv_status_on_client_details = GetMethodDelegate(library); this.grpcsharp_batch_context_recv_status_on_client_trailing_metadata = GetMethodDelegate(library); @@ -242,6 +244,7 @@ namespace Grpc.Core.Internal this.grpcsharp_batch_context_recv_initial_metadata = DllImportsFromStaticLib.grpcsharp_batch_context_recv_initial_metadata; this.grpcsharp_batch_context_recv_message_length = DllImportsFromStaticLib.grpcsharp_batch_context_recv_message_length; this.grpcsharp_batch_context_recv_message_to_buffer = DllImportsFromStaticLib.grpcsharp_batch_context_recv_message_to_buffer; + this.grpcsharp_batch_context_recv_message_next_slice_peek = DllImportsFromStaticLib.grpcsharp_batch_context_recv_message_next_slice_peek; this.grpcsharp_batch_context_recv_status_on_client_status = DllImportsFromStaticLib.grpcsharp_batch_context_recv_status_on_client_status; this.grpcsharp_batch_context_recv_status_on_client_details = DllImportsFromStaticLib.grpcsharp_batch_context_recv_status_on_client_details; this.grpcsharp_batch_context_recv_status_on_client_trailing_metadata = DllImportsFromStaticLib.grpcsharp_batch_context_recv_status_on_client_trailing_metadata; @@ -342,6 +345,7 @@ namespace Grpc.Core.Internal this.grpcsharp_batch_context_recv_initial_metadata = DllImportsFromSharedLib.grpcsharp_batch_context_recv_initial_metadata; this.grpcsharp_batch_context_recv_message_length = DllImportsFromSharedLib.grpcsharp_batch_context_recv_message_length; this.grpcsharp_batch_context_recv_message_to_buffer = DllImportsFromSharedLib.grpcsharp_batch_context_recv_message_to_buffer; + this.grpcsharp_batch_context_recv_message_next_slice_peek = DllImportsFromSharedLib.grpcsharp_batch_context_recv_message_next_slice_peek; this.grpcsharp_batch_context_recv_status_on_client_status = DllImportsFromSharedLib.grpcsharp_batch_context_recv_status_on_client_status; this.grpcsharp_batch_context_recv_status_on_client_details = DllImportsFromSharedLib.grpcsharp_batch_context_recv_status_on_client_details; this.grpcsharp_batch_context_recv_status_on_client_trailing_metadata = DllImportsFromSharedLib.grpcsharp_batch_context_recv_status_on_client_trailing_metadata; @@ -445,6 +449,7 @@ namespace Grpc.Core.Internal public delegate IntPtr grpcsharp_batch_context_recv_initial_metadata_delegate(BatchContextSafeHandle ctx); public delegate IntPtr grpcsharp_batch_context_recv_message_length_delegate(BatchContextSafeHandle ctx); public delegate void grpcsharp_batch_context_recv_message_to_buffer_delegate(BatchContextSafeHandle ctx, byte[] buffer, UIntPtr bufferLen); + public delegate int grpcsharp_batch_context_recv_message_next_slice_peek_delegate(BatchContextSafeHandle ctx, out UIntPtr sliceLen, out IntPtr sliceDataPtr); public delegate StatusCode grpcsharp_batch_context_recv_status_on_client_status_delegate(BatchContextSafeHandle ctx); public delegate IntPtr grpcsharp_batch_context_recv_status_on_client_details_delegate(BatchContextSafeHandle ctx, out UIntPtr detailsLength); public delegate IntPtr grpcsharp_batch_context_recv_status_on_client_trailing_metadata_delegate(BatchContextSafeHandle ctx); @@ -564,6 +569,9 @@ namespace Grpc.Core.Internal [DllImport(ImportName)] public static extern void grpcsharp_batch_context_recv_message_to_buffer(BatchContextSafeHandle ctx, byte[] buffer, UIntPtr bufferLen); + [DllImport(ImportName)] + public static extern int grpcsharp_batch_context_recv_message_next_slice_peek(BatchContextSafeHandle ctx, out UIntPtr sliceLen, out IntPtr sliceDataPtr); + [DllImport(ImportName)] public static extern StatusCode grpcsharp_batch_context_recv_status_on_client_status(BatchContextSafeHandle ctx); @@ -860,6 +868,9 @@ namespace Grpc.Core.Internal [DllImport(ImportName)] public static extern void grpcsharp_batch_context_recv_message_to_buffer(BatchContextSafeHandle ctx, byte[] buffer, UIntPtr bufferLen); + [DllImport(ImportName)] + public static extern int grpcsharp_batch_context_recv_message_next_slice_peek(BatchContextSafeHandle ctx, out UIntPtr sliceLen, out IntPtr sliceDataPtr); + [DllImport(ImportName)] public static extern StatusCode grpcsharp_batch_context_recv_status_on_client_status(BatchContextSafeHandle ctx); diff --git a/src/csharp/Grpc.Core/Internal/ReusableSliceBuffer.cs b/src/csharp/Grpc.Core/Internal/ReusableSliceBuffer.cs new file mode 100644 index 00000000000..fb8d2e720de --- /dev/null +++ b/src/csharp/Grpc.Core/Internal/ReusableSliceBuffer.cs @@ -0,0 +1,148 @@ +#region Copyright notice and license + +// Copyright 2019 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY + +using Grpc.Core.Utils; +using System; +using System.Threading; + +using System.Buffers; + +namespace Grpc.Core.Internal +{ + internal class ReusableSliceBuffer + { + public const int MaxCachedSegments = 1024; // ~4MB payload for 4K slices + + readonly SliceSegment[] cachedSegments = new SliceSegment[MaxCachedSegments]; + int populatedSegmentCount = 0; + + public ReadOnlySequence PopulateFrom(IBufferReader bufferReader) + { + long offset = 0; + int index = 0; + SliceSegment prevSegment = null; + while (bufferReader.TryGetNextSlice(out Slice slice)) + { + // Initialize cached segment if still null or just allocate a new segment if we already reached MaxCachedSegments + var current = index < cachedSegments.Length ? cachedSegments[index] : new SliceSegment(); + if (current == null) + { + current = cachedSegments[index] = new SliceSegment(); + } + + current.Reset(slice, offset); + prevSegment?.SetNext(current); + + index ++; + offset += slice.Length; + prevSegment = current; + } + populatedSegmentCount = index; + + // Not necessary for ending the ReadOnlySequence, but for making sure we + // don't keep more than MaxCachedSegments alive. + prevSegment?.SetNext(null); + + if (index == 0) + { + return ReadOnlySequence.Empty; + } + + var firstSegment = cachedSegments[0]; + var lastSegment = prevSegment; + return new ReadOnlySequence(firstSegment, 0, lastSegment, lastSegment.Memory.Length); + } + + public void Invalidate() + { + if (populatedSegmentCount == 0) + { + return; + } + var segment = cachedSegments[0]; + while (segment != null) + { + segment.Reset(new Slice(IntPtr.Zero, 0), 0); + segment.SetNext(null); + segment = (SliceSegment) segment.Next; + } + populatedSegmentCount = 0; + } + + // Represents a segment in ReadOnlySequence + // Segment is backed by Slice and the instances are reusable. + private class SliceSegment : ReadOnlySequenceSegment + { + readonly SliceMemoryManager pointerMemoryManager = new SliceMemoryManager(); + + public void Reset(Slice slice, long runningIndex) + { + pointerMemoryManager.Reset(slice); + Memory = pointerMemoryManager.Memory; // maybe not always necessary + RunningIndex = runningIndex; + } + + public void SetNext(ReadOnlySequenceSegment next) + { + Next = next; + } + } + + // Allow creating instances of Memory from Slice. + // Represents a chunk of native memory, but doesn't manage its lifetime. + // Instances of this class are reuseable - they can be reset to point to a different memory chunk. + // That is important to make the instances cacheable (rather then creating new instances + // the old ones will be reused to reduce GC pressure). + private class SliceMemoryManager : MemoryManager + { + private Slice slice; + + public void Reset(Slice slice) + { + this.slice = slice; + } + + public void Reset() + { + Reset(new Slice(IntPtr.Zero, 0)); + } + + public override Span GetSpan() + { + return slice.ToSpanUnsafe(); + } + + public override MemoryHandle Pin(int elementIndex = 0) + { + throw new NotSupportedException(); + } + + public override void Unpin() + { + } + + protected override void Dispose(bool disposing) + { + // NOP + } + } + } +} +#endif diff --git a/src/csharp/Grpc.Core/Internal/Slice.cs b/src/csharp/Grpc.Core/Internal/Slice.cs new file mode 100644 index 00000000000..22eb9537951 --- /dev/null +++ b/src/csharp/Grpc.Core/Internal/Slice.cs @@ -0,0 +1,68 @@ +#region Copyright notice and license + +// Copyright 2019 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using System.Runtime.InteropServices; +using System.Threading; +using Grpc.Core.Utils; + +namespace Grpc.Core.Internal +{ + /// + /// Slice of native memory. + /// Rough equivalent of grpc_slice (but doesn't support inlined slices, just a pointer to data and length) + /// + internal struct Slice + { + private readonly IntPtr dataPtr; + private readonly int length; + + public Slice(IntPtr dataPtr, int length) + { + this.dataPtr = dataPtr; + this.length = length; + } + + public int Length => length; + + // copies data of the slice to given span. + // there needs to be enough space in the destination buffer + public void CopyTo(ArraySegment destination) + { + Marshal.Copy(dataPtr, destination.Array, destination.Offset, length); + } + +#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY + public Span ToSpanUnsafe() + { + unsafe + { + return new Span((byte*) dataPtr, length); + } + } +#endif + + /// + /// Returns a that represents the current . + /// + public override string ToString() + { + return string.Format("[Slice: dataPtr={0}, length={1}]", dataPtr, length); + } + } +} diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 91d3957dbf0..b42e1e875d2 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -59,12 +59,16 @@ typedef struct grpcsharp_batch_context { } send_status_from_server; grpc_metadata_array recv_initial_metadata; grpc_byte_buffer* recv_message; + grpc_byte_buffer_reader* recv_message_reader; struct { grpc_metadata_array trailing_metadata; grpc_status_code status; grpc_slice status_details; } recv_status_on_client; int recv_close_on_server_cancelled; + + /* reserve space for byte_buffer_reader */ + grpc_byte_buffer_reader reserved_recv_message_reader; } grpcsharp_batch_context; GPR_EXPORT grpcsharp_batch_context* GPR_CALLTYPE @@ -206,6 +210,9 @@ grpcsharp_batch_context_reset(grpcsharp_batch_context* ctx) { grpcsharp_metadata_array_destroy_metadata_only(&(ctx->recv_initial_metadata)); + if (ctx->recv_message_reader) { + grpc_byte_buffer_reader_destroy(ctx->recv_message_reader); + } grpc_byte_buffer_destroy(ctx->recv_message); grpcsharp_metadata_array_destroy_metadata_only( @@ -287,6 +294,45 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_batch_context_recv_message_to_buffer( grpc_byte_buffer_reader_destroy(&reader); } +/* + * Gets the next slice from recv_message byte buffer. + * Returns 1 if a slice was get successfully, 0 if there are no more slices to + * read. Set slice_len to the length of the slice and the slice_data_ptr to + * point to slice's data. Caller must ensure that the byte buffer being read + * from stays alive as long as the data of the slice are being accessed + * (grpc_byte_buffer_reader_peek method is used internally) + * + * Remarks: + * Slices can only be iterated once. + * Initializes recv_message_buffer_reader if it was not initialized yet. + */ +GPR_EXPORT int GPR_CALLTYPE +grpcsharp_batch_context_recv_message_next_slice_peek( + grpcsharp_batch_context* ctx, size_t* slice_len, uint8_t** slice_data_ptr) { + *slice_len = 0; + *slice_data_ptr = NULL; + + if (!ctx->recv_message) { + return 0; + } + + if (!ctx->recv_message_reader) { + ctx->recv_message_reader = &ctx->reserved_recv_message_reader; + GPR_ASSERT(grpc_byte_buffer_reader_init(ctx->recv_message_reader, + ctx->recv_message)); + } + + grpc_slice* slice_ptr; + if (!grpc_byte_buffer_reader_peek(ctx->recv_message_reader, &slice_ptr)) { + return 0; + } + + /* recv_message buffer must not be deleted before all the data is read */ + *slice_len = GRPC_SLICE_LENGTH(*slice_ptr); + *slice_data_ptr = GRPC_SLICE_START_PTR(*slice_ptr); + return 1; +} + GPR_EXPORT grpc_status_code GPR_CALLTYPE grpcsharp_batch_context_recv_status_on_client_status( const grpcsharp_batch_context* ctx) { diff --git a/src/csharp/tests.json b/src/csharp/tests.json index c1e7fc1a6bf..cacdb305d2e 100644 --- a/src/csharp/tests.json +++ b/src/csharp/tests.json @@ -7,8 +7,12 @@ "Grpc.Core.Internal.Tests.ChannelArgsSafeHandleTest", "Grpc.Core.Internal.Tests.CompletionQueueEventTest", "Grpc.Core.Internal.Tests.CompletionQueueSafeHandleTest", + "Grpc.Core.Internal.Tests.DefaultDeserializationContextTest", "Grpc.Core.Internal.Tests.DefaultObjectPoolTest", + "Grpc.Core.Internal.Tests.FakeBufferReaderManagerTest", "Grpc.Core.Internal.Tests.MetadataArraySafeHandleTest", + "Grpc.Core.Internal.Tests.ReusableSliceBufferTest", + "Grpc.Core.Internal.Tests.SliceTest", "Grpc.Core.Internal.Tests.TimespecTest", "Grpc.Core.Tests.AppDomainUnloadTest", "Grpc.Core.Tests.AuthContextTest", diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c index 0e9d56f5bdf..1da79e2bcad 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c @@ -50,6 +50,10 @@ void grpcsharp_batch_context_recv_message_to_buffer() { fprintf(stderr, "Should never reach here"); abort(); } +void grpcsharp_batch_context_recv_message_next_slice_peek() { + fprintf(stderr, "Should never reach here"); + abort(); +} void grpcsharp_batch_context_recv_status_on_client_status() { fprintf(stderr, "Should never reach here"); abort(); diff --git a/templates/src/csharp/Grpc.Core/Internal/native_methods.include b/templates/src/csharp/Grpc.Core/Internal/native_methods.include index e8ec4c87b06..dab95991bca 100644 --- a/templates/src/csharp/Grpc.Core/Internal/native_methods.include +++ b/templates/src/csharp/Grpc.Core/Internal/native_methods.include @@ -7,6 +7,7 @@ native_method_signatures = [ 'IntPtr grpcsharp_batch_context_recv_initial_metadata(BatchContextSafeHandle ctx)', 'IntPtr grpcsharp_batch_context_recv_message_length(BatchContextSafeHandle ctx)', 'void grpcsharp_batch_context_recv_message_to_buffer(BatchContextSafeHandle ctx, byte[] buffer, UIntPtr bufferLen)', + 'int grpcsharp_batch_context_recv_message_next_slice_peek(BatchContextSafeHandle ctx, out UIntPtr sliceLen, out IntPtr sliceDataPtr)', 'StatusCode grpcsharp_batch_context_recv_status_on_client_status(BatchContextSafeHandle ctx)', 'IntPtr grpcsharp_batch_context_recv_status_on_client_details(BatchContextSafeHandle ctx, out UIntPtr detailsLength)', 'IntPtr grpcsharp_batch_context_recv_status_on_client_trailing_metadata(BatchContextSafeHandle ctx)', From ffe2057487262e36c57a3540413851572e36094b Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Tue, 16 Apr 2019 14:13:04 -0700 Subject: [PATCH 0045/1555] Revert "Revert "Merge pull request #18547 from lidizheng/fix-gevent"" This reverts commit a922bd7a03a35af0aaceb8f79e71f234e3fb418c. --- .../resolver/dns/c_ares/dns_resolver_ares.cc | 8 ++- src/core/lib/iomgr/iomgr_custom.cc | 3 + src/core/lib/iomgr/iomgr_custom.h | 2 + src/python/grpcio_tests/commands.py | 8 ++- src/python/grpcio_tests/tests/tests.json | 1 + .../grpcio_tests/tests/unit/BUILD.bazel | 1 + .../tests/unit/_dns_resolver_test.py | 63 +++++++++++++++++++ 7 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 src/python/grpcio_tests/tests/unit/_dns_resolver_test.py diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index 7de1c221a13..13fde4aeccd 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -43,6 +43,7 @@ #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/gethostname.h" +#include "src/core/lib/iomgr/iomgr_custom.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/json/json.h" @@ -426,8 +427,11 @@ static grpc_address_resolver_vtable ares_resolver = { grpc_resolve_address_ares, blocking_resolve_address_ares}; static bool should_use_ares(const char* resolver_env) { - return resolver_env == nullptr || strlen(resolver_env) == 0 || - gpr_stricmp(resolver_env, "ares") == 0; + // TODO(lidiz): Remove the "g_custom_iomgr_enabled" flag once c-ares support + // custom IO managers (e.g. gevent). + return !g_custom_iomgr_enabled && + (resolver_env == nullptr || strlen(resolver_env) == 0 || + gpr_stricmp(resolver_env, "ares") == 0); } void grpc_resolver_dns_ares_init() { diff --git a/src/core/lib/iomgr/iomgr_custom.cc b/src/core/lib/iomgr/iomgr_custom.cc index 56363c35fd6..f5ac8a0670a 100644 --- a/src/core/lib/iomgr/iomgr_custom.cc +++ b/src/core/lib/iomgr/iomgr_custom.cc @@ -49,6 +49,8 @@ static bool iomgr_platform_add_closure_to_background_poller( return false; } +bool g_custom_iomgr_enabled = false; + static grpc_iomgr_platform_vtable vtable = { iomgr_platform_init, iomgr_platform_flush, @@ -61,6 +63,7 @@ void grpc_custom_iomgr_init(grpc_socket_vtable* socket, grpc_custom_resolver_vtable* resolver, grpc_custom_timer_vtable* timer, grpc_custom_poller_vtable* poller) { + g_custom_iomgr_enabled = true; grpc_custom_endpoint_init(socket); grpc_custom_timer_init(timer); grpc_custom_pollset_init(poller); diff --git a/src/core/lib/iomgr/iomgr_custom.h b/src/core/lib/iomgr/iomgr_custom.h index 57cc2f9b923..e6a88843e5c 100644 --- a/src/core/lib/iomgr/iomgr_custom.h +++ b/src/core/lib/iomgr/iomgr_custom.h @@ -39,6 +39,8 @@ extern gpr_thd_id g_init_thread; #define GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD() #endif /* GRPC_CUSTOM_IOMGR_THREAD_CHECK */ +extern bool g_custom_iomgr_enabled; + void grpc_custom_iomgr_init(grpc_socket_vtable* socket, grpc_custom_resolver_vtable* resolver, grpc_custom_timer_vtable* timer, diff --git a/src/python/grpcio_tests/commands.py b/src/python/grpcio_tests/commands.py index 7a441feb84e..8f27ab5ac51 100644 --- a/src/python/grpcio_tests/commands.py +++ b/src/python/grpcio_tests/commands.py @@ -153,6 +153,9 @@ class TestGevent(setuptools.Command): # TODO(https://github.com/grpc/grpc/issues/15411) enable this test 'unit._cython._channel_test.ChannelTest.test_negative_deadline_connectivity' ) + BANNED_WINDOWS_TESTS = ( + # TODO(https://github.com/grpc/grpc/pull/15411) enable this test + 'unit._dns_resolver_test.DNSResolverTest.test_connect_loopback',) description = 'run tests with gevent. Assumes grpc/gevent are installed' user_options = [] @@ -178,7 +181,10 @@ class TestGevent(setuptools.Command): loader = tests.Loader() loader.loadTestsFromNames(['tests']) runner = tests.Runner() - runner.skip_tests(self.BANNED_TESTS) + if sys.platform == 'win32': + runner.skip_tests(self.BANNED_TESTS + self.BANNED_WINDOWS_TESTS) + else: + runner.skip_tests(self.BANNED_TESTS) result = gevent.spawn(runner.run, loader.suite) result.join() if not result.value.wasSuccessful(): diff --git a/src/python/grpcio_tests/tests/tests.json b/src/python/grpcio_tests/tests/tests.json index 7729ca01d53..cc08d56248a 100644 --- a/src/python/grpcio_tests/tests/tests.json +++ b/src/python/grpcio_tests/tests/tests.json @@ -46,6 +46,7 @@ "unit._cython.cygrpc_test.InsecureServerInsecureClient", "unit._cython.cygrpc_test.SecureServerSecureClient", "unit._cython.cygrpc_test.TypeSmokeTest", + "unit._dns_resolver_test.DNSResolverTest", "unit._empty_message_test.EmptyMessageTest", "unit._error_message_encoding_test.ErrorMessageEncodingTest", "unit._exit_test.ExitTest", diff --git a/src/python/grpcio_tests/tests/unit/BUILD.bazel b/src/python/grpcio_tests/tests/unit/BUILD.bazel index 54b3c9b6f6a..9c9887b3b73 100644 --- a/src/python/grpcio_tests/tests/unit/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/BUILD.bazel @@ -14,6 +14,7 @@ GRPCIO_TESTS_UNIT = [ "_channel_ready_future_test.py", "_compression_test.py", "_credentials_test.py", + "_dns_resolver_test.py", "_empty_message_test.py", "_exit_test.py", "_interceptor_test.py", diff --git a/src/python/grpcio_tests/tests/unit/_dns_resolver_test.py b/src/python/grpcio_tests/tests/unit/_dns_resolver_test.py new file mode 100644 index 00000000000..d119707b19d --- /dev/null +++ b/src/python/grpcio_tests/tests/unit/_dns_resolver_test.py @@ -0,0 +1,63 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Tests for an actual dns resolution.""" + +import unittest +import logging +import six + +import grpc +from tests.unit import test_common +from tests.unit.framework.common import test_constants + +_METHOD = '/ANY/METHOD' +_REQUEST = b'\x00\x00\x00' +_RESPONSE = _REQUEST + + +class GenericHandler(grpc.GenericRpcHandler): + + def service(self, unused_handler_details): + return grpc.unary_unary_rpc_method_handler( + lambda request, unused_context: request, + ) + + +class DNSResolverTest(unittest.TestCase): + + def setUp(self): + self._server = test_common.test_server() + self._server.add_generic_rpc_handlers((GenericHandler(),)) + self._port = self._server.add_insecure_port('[::]:0') + self._server.start() + + def tearDown(self): + self._server.stop(None) + + def test_connect_loopback(self): + # NOTE(https://github.com/grpc/grpc/issues/18422) + # In short, Gevent + C-Ares = Segfault. The C-Ares driver is not + # supported by custom io manager like "gevent" or "libuv". + with grpc.insecure_channel( + 'loopback4.unittest.grpc.io:%d' % self._port) as channel: + self.assertEqual( + channel.unary_unary(_METHOD)( + _REQUEST, + timeout=test_constants.SHORT_TIMEOUT, + ), _RESPONSE) + + +if __name__ == '__main__': + logging.basicConfig() + unittest.main(verbosity=2) From 365c118967c81ada37770d47fce550d454e6c432 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 25 Apr 2019 07:25:26 -0700 Subject: [PATCH 0046/1555] Bump version to v1.20.1 --- BUILD | 2 +- build.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index fcd1bcd8fbe..9157f5af0f4 100644 --- a/BUILD +++ b/BUILD @@ -78,7 +78,7 @@ g_stands_for = "godric" core_version = "7.0.0" -version = "1.20.0" +version = "1.20.1" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index 7520f9de6f7..f647e423749 100644 --- a/build.yaml +++ b/build.yaml @@ -14,7 +14,7 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 7.0.0 g_stands_for: godric - version: 1.20.0 + version: 1.20.1 filegroups: - name: alts_proto headers: From ee47d5ee75eea5ac046485312f8106a561a3d3ed Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 25 Apr 2019 07:28:33 -0700 Subject: [PATCH 0047/1555] Regenerate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 4 ++-- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 4 ++-- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 4 ++-- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/composer.json | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 30 files changed, 34 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23eeae53a65..e8207372018 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.20.0") +set(PACKAGE_VERSION "1.20.1") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 34d8b6d9047..53e70c95ba2 100644 --- a/Makefile +++ b/Makefile @@ -460,8 +460,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.20.0 -CSHARP_VERSION = 1.20.0 +CPP_VERSION = 1.20.1 +CSHARP_VERSION = 1.20.1 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 6556b8f40a4..f031cbf5851 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,7 +23,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.20.0' + # version = '1.20.1' version = '0.0.8' s.version = version s.summary = 'gRPC C++ library' @@ -31,7 +31,7 @@ Pod::Spec.new do |s| s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.20.0' + grpc_version = '1.20.1' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 9cad88f98b8..50fb324e9fb 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.20.0' + version = '1.20.1' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 6f9359b5329..89c367cc425 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.20.0' + version = '1.20.1' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 34dd3b67877..2dc3fe68227 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.20.0' + version = '1.20.1' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index e2e6e7f0b03..ec9cd77f457 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.20.0' + version = '1.20.1' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index 908a9d71cc6..91671644549 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2018-01-19 - 1.20.0 - 1.20.0 + 1.20.1 + 1.20.1 stable diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index d9e9f1b7168..2c17f47c471 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.20.0"; } +grpc::string Version() { return "1.20.1"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index bcf41de4320..402b6c3adbb 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -33,11 +33,11 @@ namespace Grpc.Core /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "1.20.0.0"; + public const string CurrentAssemblyFileVersion = "1.20.1.0"; /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.20.0"; + public const string CurrentVersion = "1.20.1"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index 72bd8bcdb72..17fb31eb7b8 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 1.20.0 + 1.20.1 3.7.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index d0230757628..cd77d55713a 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=1.20.0 +set VERSION=1.20.1 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index f1529fbd3fb..558a16390b0 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.20.0' + v = '1.20.1' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index d7c7e65bd46..2f624405a19 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.20.0" +#define GRPC_OBJC_VERSION_STRING @"1.20.1" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 6c547e15bee..39d38a9c094 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.20.0" +#define GRPC_OBJC_VERSION_STRING @"1.20.1" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/composer.json b/src/php/composer.json index e8106db7288..3ae0ce5749f 100644 --- a/src/php/composer.json +++ b/src/php/composer.json @@ -2,7 +2,7 @@ "name": "grpc/grpc-dev", "description": "gRPC library for PHP - for Developement use only", "license": "Apache-2.0", - "version": "1.20.0", + "version": "1.20.1", "require": { "php": ">=5.5.0", "google/protobuf": "^v3.3.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 0333c8d17a6..3aaf1d835cd 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.20.0" +#define PHP_GRPC_VERSION "1.20.1" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index d2b7655ed4a..79e68cfb480 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.20.0""" +__version__ = """1.20.1""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index b28450deab7..443a2dcf5a8 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.20.0' +VERSION = '1.20.1' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index 85c468277c3..a10aa7846ea 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.20.0' +VERSION = '1.20.1' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index eecc1fe5eb0..75014274bbb 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.20.0' +VERSION = '1.20.1' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 892b4010e90..64ec5494b3b 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.20.0' +VERSION = '1.20.1' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index 6c042c2aace..456fcde3ce3 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.20.0' +VERSION = '1.20.1' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 8af49a7c801..ed767b6eeb0 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.20.0' +VERSION = '1.20.1' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index df1ab623e79..8c8ee0c6938 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.20.0' +VERSION = '1.20.1' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 9ea2b99566c..620f67fdb29 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.20.0' + VERSION = '1.20.1' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index b13415996e9..5860fbcc85a 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.20.0' + VERSION = '1.20.1' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index d864b7bede5..7d2fc484239 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.20.0' +VERSION = '1.20.1' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 26840372f34..fac989c9ec3 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.20.0 +PROJECT_NUMBER = 1.20.1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 5d359830eab..5c481526207 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.20.0 +PROJECT_NUMBER = 1.20.1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From e457584c05fbbdecc6f4fe9356cea2450c4fd5d3 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Thu, 25 Apr 2019 11:07:36 -0700 Subject: [PATCH 0048/1555] Address comments --- .../dns/c_ares/grpc_ares_ev_driver_libuv.cc | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc index e69b824304d..c29fa44a353 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc @@ -47,9 +47,13 @@ class GrpcPolledFdLibuv : public GrpcPolledFd { handle_ = New(); uv_poll_init_socket(uv_default_loop(), handle_, as); handle_->data = this; + GRPC_COMBINER_REF(combiner_, "libuv ares event driver"); } - ~GrpcPolledFdLibuv() { gpr_free(name_); } + ~GrpcPolledFdLibuv() { + gpr_free(name_); + GRPC_COMBINER_UNREF(combiner_, "libuv ares event driver"); + } void RegisterForOnReadableLocked(grpc_closure* read_closure) override { GPR_ASSERT(read_closure_ == nullptr); @@ -73,18 +77,26 @@ class GrpcPolledFdLibuv : public GrpcPolledFd { return false; } - void ShutdownLocked(grpc_error* error) override { - grpc_core::ExecCtx exec_ctx; + void ShutdownInternal(grpc_error* error) { uv_poll_stop(handle_); uv_close(reinterpret_cast(handle_), ares_uv_poll_close_cb); - if (read_closure_) { + if (read_closure_ != nullptr) { GRPC_CLOSURE_SCHED(read_closure_, GRPC_ERROR_CANCELLED); } - if (write_closure_) { + if (write_closure_ != nullptr) { GRPC_CLOSURE_SCHED(write_closure_, GRPC_ERROR_CANCELLED); } } + void ShutdownLocked(grpc_error* error) override { + if (grpc_core::ExecCtx::Get() == nullptr) { + grpc_core::ExecCtx exec_ctx; + ShutdownInternal(error); + } else { + ShutdownInternal(error); + } + } + ares_socket_t GetWrappedAresSocketLocked() override { return as_; } const char* GetName() override { return name_; } @@ -107,8 +119,9 @@ struct AresUvPollCbArg { int events; }; -static void inner_callback(void* arg, grpc_error* error) { - AresUvPollCbArg* arg_struct = reinterpret_cast(arg); +static void ares_uv_poll_cb_locked(void* arg, grpc_error* error) { + grpc_core::UniquePtr arg_struct( + reinterpret_cast(arg)); uv_poll_t* handle = arg_struct->handle; int status = arg_struct->status; int events = arg_struct->events; @@ -120,18 +133,19 @@ static void inner_callback(void* arg, grpc_error* error) { grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, grpc_slice_from_static_string(uv_strerror(status))); } - if ((events & UV_READABLE) && polled_fd->read_closure_) { + if (events & UV_READABLE) { + GPR_ASSERT(polled_fd->read_closure_ != nullptr); GRPC_CLOSURE_SCHED(polled_fd->read_closure_, error); polled_fd->read_closure_ = nullptr; polled_fd->poll_events_ &= ~UV_READABLE; } - if ((events & UV_WRITABLE) && polled_fd->write_closure_) { + if (events & UV_WRITABLE) { + GPR_ASSERT(polled_fd->write_closure_ != nullptr); GRPC_CLOSURE_SCHED(polled_fd->write_closure_, error); polled_fd->write_closure_ = nullptr; polled_fd->poll_events_ &= ~UV_WRITABLE; } uv_poll_start(handle, polled_fd->poll_events_, ares_uv_poll_cb); - Delete(arg_struct); } void ares_uv_poll_cb(uv_poll_t* handle, int status, int events) { @@ -140,7 +154,7 @@ void ares_uv_poll_cb(uv_poll_t* handle, int status, int events) { reinterpret_cast(handle->data); AresUvPollCbArg* arg = New(handle, status, events); GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_CREATE(inner_callback, arg, + GRPC_CLOSURE_CREATE(ares_uv_poll_cb_locked, arg, grpc_combiner_scheduler(polled_fd->combiner_)), GRPC_ERROR_NONE); } From bbd4eb5028438ab84a50c2371874707615b94578 Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Fri, 26 Apr 2019 09:52:12 -0700 Subject: [PATCH 0049/1555] Add microbenchmark for callback unary ping pong and bidistreaming ping pong --- CMakeLists.txt | 147 +++++++++++++++++ Makefile | 148 +++++++++++++++++ build.yaml | 66 ++++++++ grpc.gyp | 15 ++ test/cpp/microbenchmarks/BUILD | 91 ++++++++-- .../bm_callback_streaming_ping_pong.cc | 155 ++++++++++++++++++ .../bm_callback_unary_ping_pong.cc | 148 +++++++++++++++++ .../callback_streaming_ping_pong.h | 53 ++++++ .../microbenchmarks/callback_test_service.cc | 111 +++++++++++++ .../microbenchmarks/callback_test_service.h | 95 +++++++++++ .../callback_unary_ping_pong.h | 84 ++++++++++ .../generated/sources_and_headers.json | 72 ++++++++ tools/run_tests/generated/tests.json | 52 ++++++ 13 files changed, 1219 insertions(+), 18 deletions(-) create mode 100644 test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc create mode 100644 test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc create mode 100644 test/cpp/microbenchmarks/callback_streaming_ping_pong.h create mode 100644 test/cpp/microbenchmarks/callback_test_service.cc create mode 100644 test/cpp/microbenchmarks/callback_test_service.h create mode 100644 test/cpp/microbenchmarks/callback_unary_ping_pong.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b93ab08af4..41427278646 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -556,6 +556,12 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx bm_call_create) endif() if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) +add_dependencies(buildtests_cxx bm_callback_streaming_ping_pong) +endif() +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) +add_dependencies(buildtests_cxx bm_callback_unary_ping_pong) +endif() +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx bm_channel) endif() if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) @@ -2896,6 +2902,55 @@ target_link_libraries(test_tcp_server ) +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + +add_library(callback_test_service + test/cpp/microbenchmarks/callback_test_service.cc +) + +if(WIN32 AND MSVC) + set_target_properties(callback_test_service PROPERTIES COMPILE_PDB_NAME "callback_test_service" + COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" + ) + if (gRPC_INSTALL) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/callback_test_service.pdb + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL + ) + endif() +endif() + + +target_include_directories(callback_test_service + PUBLIC $ $ + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) +target_link_libraries(callback_test_service + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + ${_gRPC_BENCHMARK_LIBRARIES} + grpc++_test_util + grpc_test_util + grpc++ + grpc + gpr + ${_gRPC_GFLAGS_LIBRARIES} +) + + endif (gRPC_BUILD_TESTS) add_library(grpc++ @@ -11479,6 +11534,98 @@ target_link_libraries(bm_call_create ) +endif() +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) + +add_executable(bm_callback_streaming_ping_pong + test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(bm_callback_streaming_ping_pong + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(bm_callback_streaming_ping_pong + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_benchmark + ${_gRPC_BENCHMARK_LIBRARIES} + grpc++_test_util_unsecure + grpc_test_util_unsecure + grpc++_unsecure + grpc_unsecure + gpr + grpc++_test_config + callback_test_service + ${_gRPC_GFLAGS_LIBRARIES} +) + + +endif() +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) + +add_executable(bm_callback_unary_ping_pong + test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(bm_callback_unary_ping_pong + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(bm_callback_unary_ping_pong + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_benchmark + ${_gRPC_BENCHMARK_LIBRARIES} + grpc++_test_util_unsecure + grpc_test_util_unsecure + grpc++_unsecure + grpc_unsecure + gpr + grpc++_test_config + callback_test_service + ${_gRPC_GFLAGS_LIBRARIES} +) + + endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index 700e789265e..6e83616e243 100644 --- a/Makefile +++ b/Makefile @@ -1162,6 +1162,8 @@ bm_alarm: $(BINDIR)/$(CONFIG)/bm_alarm bm_arena: $(BINDIR)/$(CONFIG)/bm_arena bm_byte_buffer: $(BINDIR)/$(CONFIG)/bm_byte_buffer bm_call_create: $(BINDIR)/$(CONFIG)/bm_call_create +bm_callback_streaming_ping_pong: $(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong +bm_callback_unary_ping_pong: $(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong bm_channel: $(BINDIR)/$(CONFIG)/bm_channel bm_chttp2_hpack: $(BINDIR)/$(CONFIG)/bm_chttp2_hpack bm_chttp2_transport: $(BINDIR)/$(CONFIG)/bm_chttp2_transport @@ -1638,6 +1640,8 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_arena \ $(BINDIR)/$(CONFIG)/bm_byte_buffer \ $(BINDIR)/$(CONFIG)/bm_call_create \ + $(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong \ + $(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong \ $(BINDIR)/$(CONFIG)/bm_channel \ $(BINDIR)/$(CONFIG)/bm_chttp2_hpack \ $(BINDIR)/$(CONFIG)/bm_chttp2_transport \ @@ -1782,6 +1786,8 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_arena \ $(BINDIR)/$(CONFIG)/bm_byte_buffer \ $(BINDIR)/$(CONFIG)/bm_call_create \ + $(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong \ + $(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong \ $(BINDIR)/$(CONFIG)/bm_channel \ $(BINDIR)/$(CONFIG)/bm_chttp2_hpack \ $(BINDIR)/$(CONFIG)/bm_chttp2_transport \ @@ -2232,6 +2238,10 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/bm_byte_buffer || ( echo test bm_byte_buffer failed ; exit 1 ) $(E) "[RUN] Testing bm_call_create" $(Q) $(BINDIR)/$(CONFIG)/bm_call_create || ( echo test bm_call_create failed ; exit 1 ) + $(E) "[RUN] Testing bm_callback_streaming_ping_pong" + $(Q) $(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong || ( echo test bm_callback_streaming_ping_pong failed ; exit 1 ) + $(E) "[RUN] Testing bm_callback_unary_ping_pong" + $(Q) $(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong || ( echo test bm_callback_unary_ping_pong failed ; exit 1 ) $(E) "[RUN] Testing bm_channel" $(Q) $(BINDIR)/$(CONFIG)/bm_channel || ( echo test bm_channel failed ; exit 1 ) $(E) "[RUN] Testing bm_chttp2_hpack" @@ -5273,6 +5283,55 @@ endif endif +LIBCALLBACK_TEST_SERVICE_SRC = \ + test/cpp/microbenchmarks/callback_test_service.cc \ + +PUBLIC_HEADERS_CXX += \ + +LIBCALLBACK_TEST_SERVICE_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBCALLBACK_TEST_SERVICE_SRC)))) + + +ifeq ($(NO_SECURE),true) + +# You can't build secure libraries if you don't have OpenSSL. + +$(LIBDIR)/$(CONFIG)/libcallback_test_service.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)/libcallback_test_service.a: protobuf_dep_error + + +else + +$(LIBDIR)/$(CONFIG)/libcallback_test_service.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(PROTOBUF_DEP) $(LIBCALLBACK_TEST_SERVICE_OBJS) + $(E) "[AR] Creating $@" + $(Q) mkdir -p `dirname $@` + $(Q) rm -f $(LIBDIR)/$(CONFIG)/libcallback_test_service.a + $(Q) $(AR) $(AROPTS) $(LIBDIR)/$(CONFIG)/libcallback_test_service.a $(LIBCALLBACK_TEST_SERVICE_OBJS) +ifeq ($(SYSTEM),Darwin) + $(Q) ranlib -no_warning_for_no_symbols $(LIBDIR)/$(CONFIG)/libcallback_test_service.a +endif + + + + +endif + +endif + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(LIBCALLBACK_TEST_SERVICE_OBJS:.o=.dep) +endif +endif + + LIBGRPC++_SRC = \ src/cpp/client/insecure_credentials.cc \ src/cpp/client/secure_credentials.cc \ @@ -14407,6 +14466,94 @@ endif endif +BM_CALLBACK_STREAMING_PING_PONG_SRC = \ + test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc \ + +BM_CALLBACK_STREAMING_PING_PONG_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BM_CALLBACK_STREAMING_PING_PONG_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong: $(PROTOBUF_DEP) $(BM_CALLBACK_STREAMING_PING_PONG_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libcallback_test_service.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(BM_CALLBACK_STREAMING_PING_PONG_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libcallback_test_service.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong + +endif + +endif + +$(BM_CALLBACK_STREAMING_PING_PONG_OBJS): CPPFLAGS += -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX +$(OBJDIR)/$(CONFIG)/test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.o: $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libcallback_test_service.a + +deps_bm_callback_streaming_ping_pong: $(BM_CALLBACK_STREAMING_PING_PONG_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(BM_CALLBACK_STREAMING_PING_PONG_OBJS:.o=.dep) +endif +endif + + +BM_CALLBACK_UNARY_PING_PONG_SRC = \ + test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc \ + +BM_CALLBACK_UNARY_PING_PONG_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BM_CALLBACK_UNARY_PING_PONG_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong: $(PROTOBUF_DEP) $(BM_CALLBACK_UNARY_PING_PONG_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libcallback_test_service.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(BM_CALLBACK_UNARY_PING_PONG_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libcallback_test_service.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong + +endif + +endif + +$(BM_CALLBACK_UNARY_PING_PONG_OBJS): CPPFLAGS += -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX +$(OBJDIR)/$(CONFIG)/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.o: $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libcallback_test_service.a + +deps_bm_callback_unary_ping_pong: $(BM_CALLBACK_UNARY_PING_PONG_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(BM_CALLBACK_UNARY_PING_PONG_OBJS:.o=.dep) +endif +endif + + BM_CHANNEL_SRC = \ test/cpp/microbenchmarks/bm_channel.cc \ @@ -22067,6 +22214,7 @@ test/cpp/interop/interop_client.cc: $(OPENSSL_DEP) test/cpp/interop/interop_server.cc: $(OPENSSL_DEP) test/cpp/interop/interop_server_bootstrap.cc: $(OPENSSL_DEP) test/cpp/interop/server_helper.cc: $(OPENSSL_DEP) +test/cpp/microbenchmarks/callback_test_service.cc: $(OPENSSL_DEP) test/cpp/microbenchmarks/helpers.cc: $(OPENSSL_DEP) test/cpp/qps/benchmark_config.cc: $(OPENSSL_DEP) test/cpp/qps/client_async.cc: $(OPENSSL_DEP) diff --git a/build.yaml b/build.yaml index 848bf4ba072..25a476d44fe 100644 --- a/build.yaml +++ b/build.yaml @@ -1665,6 +1665,20 @@ libs: - grpc_test_util - grpc - gpr +- name: callback_test_service + build: test + language: c++ + headers: + - test/cpp/microbenchmarks/callback_test_service.h + src: + - test/cpp/microbenchmarks/callback_test_service.cc + deps: + - benchmark + - grpc++_test_util + - grpc_test_util + - grpc++ + - grpc + - gpr - name: grpc++ build: all language: c++ @@ -4024,6 +4038,58 @@ targets: - linux - posix uses_polling: false +- name: bm_callback_streaming_ping_pong + build: test + language: c++ + headers: + - test/cpp/microbenchmarks/callback_streaming_ping_pong.h + src: + - test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc + deps: + - grpc_benchmark + - benchmark + - grpc++_test_util_unsecure + - grpc_test_util_unsecure + - grpc++_unsecure + - grpc_unsecure + - gpr + - grpc++_test_config + - callback_test_service + benchmark: true + defaults: benchmark + excluded_poll_engines: + - poll + platforms: + - mac + - linux + - posix + timeout_seconds: 1200 +- name: bm_callback_unary_ping_pong + build: test + language: c++ + headers: + - test/cpp/microbenchmarks/callback_unary_ping_pong.h + src: + - test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc + deps: + - grpc_benchmark + - benchmark + - grpc++_test_util_unsecure + - grpc_test_util_unsecure + - grpc++_unsecure + - grpc_unsecure + - gpr + - grpc++_test_config + - callback_test_service + benchmark: true + defaults: benchmark + excluded_poll_engines: + - poll + platforms: + - mac + - linux + - posix + timeout_seconds: 1200 - name: bm_channel build: test language: c++ diff --git a/grpc.gyp b/grpc.gyp index 5321658508a..fab5b010a4f 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -1398,6 +1398,21 @@ 'test/core/util/test_tcp_server.cc', ], }, + { + 'target_name': 'callback_test_service', + 'type': 'static_library', + 'dependencies': [ + 'benchmark', + 'grpc++_test_util', + 'grpc_test_util', + 'grpc++', + 'grpc', + 'gpr', + ], + 'sources': [ + 'test/cpp/microbenchmarks/callback_test_service.cc', + ], + }, { 'target_name': 'grpc++', 'type': 'static_library', diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD index 6e844a6dc62..e28846fcf94 100644 --- a/test/cpp/microbenchmarks/BUILD +++ b/test/cpp/microbenchmarks/BUILD @@ -39,85 +39,85 @@ grpc_cc_library( external_deps = [ "benchmark", ], + tags = ["no_windows"], deps = [ "//:grpc++_unsecure", "//src/proto/grpc/testing:echo_proto", "//test/core/util:grpc_test_util_unsecure", "//test/cpp/util:test_config", ], - tags = ["no_windows"], ) grpc_cc_binary( name = "bm_closure", testonly = 1, srcs = ["bm_closure.cc"], - deps = [":helpers"], tags = ["no_windows"], + deps = [":helpers"], ) grpc_cc_binary( name = "bm_alarm", testonly = 1, srcs = ["bm_alarm.cc"], - deps = [":helpers"], tags = ["no_windows"], + deps = [":helpers"], ) grpc_cc_binary( name = "bm_arena", testonly = 1, srcs = ["bm_arena.cc"], - deps = [":helpers"], tags = ["no_windows"], + deps = [":helpers"], ) grpc_cc_binary( name = "bm_byte_buffer", testonly = 1, srcs = ["bm_byte_buffer.cc"], - deps = [":helpers"], tags = ["no_windows"], + deps = [":helpers"], ) grpc_cc_binary( name = "bm_channel", testonly = 1, srcs = ["bm_channel.cc"], - deps = [":helpers"], tags = ["no_windows"], + deps = [":helpers"], ) grpc_cc_binary( name = "bm_call_create", testonly = 1, srcs = ["bm_call_create.cc"], - deps = [":helpers"], tags = ["no_windows"], + deps = [":helpers"], ) grpc_cc_binary( name = "bm_cq", testonly = 1, srcs = ["bm_cq.cc"], - deps = [":helpers"], tags = ["no_windows"], + deps = [":helpers"], ) grpc_cc_binary( name = "bm_cq_multiple_threads", testonly = 1, srcs = ["bm_cq_multiple_threads.cc"], - deps = [":helpers"], tags = ["no_windows"], + deps = [":helpers"], ) grpc_cc_binary( name = "bm_error", testonly = 1, srcs = ["bm_error.cc"], - deps = [":helpers"], tags = ["no_windows"], + deps = [":helpers"], ) grpc_cc_library( @@ -126,8 +126,8 @@ grpc_cc_library( hdrs = [ "fullstack_streaming_ping_pong.h", ], - deps = [":helpers"], tags = ["no_windows"], + deps = [":helpers"], ) grpc_cc_binary( @@ -136,8 +136,8 @@ grpc_cc_binary( srcs = [ "bm_fullstack_streaming_ping_pong.cc", ], - deps = [":fullstack_streaming_ping_pong_h"], tags = ["no_windows"], + deps = [":fullstack_streaming_ping_pong_h"], ) grpc_cc_library( @@ -155,16 +155,16 @@ grpc_cc_binary( srcs = [ "bm_fullstack_streaming_pump.cc", ], - deps = [":fullstack_streaming_pump_h"], tags = ["no_windows"], + deps = [":fullstack_streaming_pump_h"], ) grpc_cc_binary( name = "bm_fullstack_trickle", testonly = 1, srcs = ["bm_fullstack_trickle.cc"], - deps = [":helpers"], tags = ["no_windows"], + deps = [":helpers"], ) grpc_cc_library( @@ -182,24 +182,24 @@ grpc_cc_binary( srcs = [ "bm_fullstack_unary_ping_pong.cc", ], - deps = [":fullstack_unary_ping_pong_h"], tags = ["no_windows"], + deps = [":fullstack_unary_ping_pong_h"], ) grpc_cc_binary( name = "bm_metadata", testonly = 1, srcs = ["bm_metadata.cc"], - deps = [":helpers"], tags = ["no_windows"], + deps = [":helpers"], ) grpc_cc_binary( name = "bm_chttp2_hpack", testonly = 1, srcs = ["bm_chttp2_hpack.cc"], - deps = [":helpers"], tags = ["no_windows"], + deps = [":helpers"], ) grpc_cc_binary( @@ -218,6 +218,61 @@ grpc_cc_binary( name = "bm_timer", testonly = 1, srcs = ["bm_timer.cc"], - deps = [":helpers"], tags = ["no_windows"], + deps = [":helpers"], +) + +grpc_cc_library( + name = "callback_test_service", + testonly = 1, + srcs = ["callback_test_service.cc"], + hdrs = ["callback_test_service.h"], + deps = [ + "//third_party/grpc/src/proto/grpc/testing:echo_proto", + "//third_party/grpc/test/cpp/util:test_util", + ], +) + +grpc_cc_library( + name = "callback_unary_ping_pong_h", + testonly = 1, + hdrs = [ + "callback_unary_ping_pong.h", + ], + deps = [ + ":callback_test_service", + ":helpers", + ], +) + +grpc_cc_binary( + name = "bm_callback_unary_ping_pong", + testonly = 1, + srcs = [ + "bm_callback_unary_ping_pong.cc", + ], + tags = ["no_windows"], + deps = [":callback_unary_ping_pong_h"], +) + +grpc_cc_library( + name = "callback_streaming_ping_pong_h", + testonly = 1, + hdrs = [ + "callback_streaming_ping_pong.h", + ], + deps = [ + ":callback_test_service", + ":helpers", + ], +) + +grpc_cc_binary( + name = "bm_callback_streaming_ping_pong", + testonly = 1, + srcs = [ + "bm_callback_streaming_ping_pong.cc", + ], + tags = ["no_windows"], + deps = [":callback_streaming_ping_pong_h"], ) diff --git a/test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc b/test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc new file mode 100644 index 00000000000..ad7c2f0ee3e --- /dev/null +++ b/test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc @@ -0,0 +1,155 @@ +#include "test/cpp/microbenchmarks/callback_streaming_ping_pong.h" +#include "test/cpp/util/test_config.h" + +namespace grpc { +namespace testing { + +// force library initialization +auto& force_library_initialization = Library::get(); + +/******************************************************************************* + * CONFIGURATIONS + */ + +// Replace "benchmark::internal::Benchmark" with "::testing::Benchmark" to use +// internal microbenchmarking tooling +static void StreamingPingPongArgs(benchmark::internal::Benchmark* b) { + int msg_size = 0; + + b->Args({0, 0}); // spl case: 0 ping-pong msgs (msg_size doesn't matter here) + + for (msg_size = 0; msg_size <= 128 * 1024 * 1024; + msg_size == 0 ? msg_size++ : msg_size *= 8) { + b->Args({msg_size, 1}); + b->Args({msg_size, 2}); + } +} +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, + NoOpMutator) + ->Apply(StreamingPingPongArgs); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, MinInProcess, NoOpMutator, + NoOpMutator) + ->Apply(StreamingPingPongArgs); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, + NoOpMutator) + ->Apply(StreamingPingPongArgs); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, MinInProcessCHTTP2, NoOpMutator, + NoOpMutator) + ->Apply(StreamingPingPongArgs); + +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, + Client_AddMetadata, 1>, + NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, + Client_AddMetadata, 2>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, + Client_AddMetadata, 2>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, + Client_AddMetadata, 2>, + NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 100>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, + Client_AddMetadata, 1>, + NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, + Client_AddMetadata, 2>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, + Client_AddMetadata, 2>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, + Client_AddMetadata, 2>, + NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, + Server_AddInitialMetadata, 100>) + ->Args({0, 0}); + +} // namespace testing +} // namespace grpc + +// Some distros have RunSpecifiedBenchmarks under the benchmark namespace, +// and others do not. This allows us to support both modes. +namespace benchmark { +void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } +} // namespace benchmark + +int main(int argc, char** argv) { + ::benchmark::Initialize(&argc, argv); + ::grpc::testing::InitTest(&argc, &argv, false); + benchmark::RunTheBenchmarksNamespaced(); + return 0; +} diff --git a/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc b/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc new file mode 100644 index 00000000000..fee41ea8d1a --- /dev/null +++ b/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc @@ -0,0 +1,148 @@ +#include "test/cpp/microbenchmarks/callback_unary_ping_pong.h" +#include "test/cpp/util/test_config.h" + +namespace grpc { +namespace testing { + +// force library initialization +auto& force_library_initialization = Library::get(); + +/******************************************************************************* + * CONFIGURATIONS + */ + +// Replace "benchmark::internal::Benchmark" with "::testing::Benchmark" to use +// internal microbenchmarking tooling +static void SweepSizesArgs(benchmark::internal::Benchmark* b) { + b->Args({0, 0}); + for (int i = 1; i <= 128 * 1024 * 1024; i *= 8) { + b->Args({i, 0}); + b->Args({0, i}); + b->Args({i, i}); + } +} + +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, NoOpMutator) + ->Apply(SweepSizesArgs); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, MinInProcess, NoOpMutator, NoOpMutator) + ->Apply(SweepSizesArgs); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, NoOpMutator) + ->Apply(SweepSizesArgs); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, MinInProcessCHTTP2, NoOpMutator, + NoOpMutator) + ->Apply(SweepSizesArgs); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, + Client_AddMetadata, 1>, + NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, + Client_AddMetadata, 2>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, + Client_AddMetadata, 2>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, + Client_AddMetadata, 2>, + NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, + Server_AddInitialMetadata, 100>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, + Client_AddMetadata, 1>, + NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, + Client_AddMetadata, 2>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, + Client_AddMetadata, 2>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, + Client_AddMetadata, 2>, + NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 100>) + ->Args({0, 0}); +} // namespace testing +} // namespace grpc + +// Some distros have RunSpecifiedBenchmarks under the benchmark namespace, +// and others do not. This allows us to support both modes. +namespace benchmark { +void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } +} // namespace benchmark + +int main(int argc, char** argv) { + ::benchmark::Initialize(&argc, argv); + ::grpc::testing::InitTest(&argc, &argv, false); + benchmark::RunTheBenchmarksNamespaced(); + return 0; +} diff --git a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h new file mode 100644 index 00000000000..13b4c155459 --- /dev/null +++ b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h @@ -0,0 +1,53 @@ +#ifndef TEST_CPP_MICROBENCHMARKS_CALLBACK_STREAMING_PING_PONG_H +#define TEST_CPP_MICROBENCHMARKS_CALLBACK_STREAMING_PING_PONG_H + + +#include +#include +#include "src/core/lib/profiling/timers.h" +#include "src/proto/grpc/testing/echo.grpc.pb.h" +#include "test/cpp/microbenchmarks/fullstack_context_mutators.h" +#include "test/cpp/microbenchmarks/fullstack_fixtures.h" +#include "test/cpp/microbenchmarks/callback_test_service.h" + +namespace grpc { +namespace testing { + +/******************************************************************************* + * BENCHMARKING KERNELS + */ + +template +static void BM_CallbackBidiStreaming(benchmark::State& state) { + const int message_size = state.range(0); + const int max_ping_pongs = state.range(1) > 0 ? 1 : state.range(1); + CallbackStreamingTestService service; + std::unique_ptr fixture(new Fixture(&service)); + std::unique_ptr stub_( + EchoTestService::NewStub(fixture->channel())); + EchoRequest* request = new EchoRequest; + EchoResponse* response = new EchoResponse; + if (state.range(0) > 0) { + request->set_message(std::string(state.range(0), 'a')); + } else { + request->set_message(""); + } + while (state.KeepRunning()) { + GPR_TIMER_SCOPE("BenchmarkCycle", 0); + ClientContext* cli_ctx = new ClientContext; + cli_ctx->AddMetadata(kServerFinishAfterNReads, + grpc::to_string(max_ping_pongs)); + cli_ctx->AddMetadata(kServerResponseStreamsToSend, + grpc::to_string(message_size)); + BidiClient test{stub_.get(), request, response, cli_ctx, max_ping_pongs}; + test.Await(); + } + fixture->Finish(state); + fixture.reset(); + state.SetBytesProcessed(2 * state.range(0) * state.iterations() + * state.range(1)); +} + +} // namespace testing +} // namespace grpc +#endif // TEST_CPP_MICROBENCHMARKS_CALLBACK_STREAMING_PING_PONG_H diff --git a/test/cpp/microbenchmarks/callback_test_service.cc b/test/cpp/microbenchmarks/callback_test_service.cc new file mode 100644 index 00000000000..057517acf05 --- /dev/null +++ b/test/cpp/microbenchmarks/callback_test_service.cc @@ -0,0 +1,111 @@ +#include "test/cpp/microbenchmarks/callback_test_service.h" + +namespace grpc { +namespace testing { +namespace { + +grpc::string ToString(const grpc::string_ref& r) { + return grpc::string(r.data(), r.size()); +} + +int GetIntValueFromMetadataHelper( + const char* key, + const std::multimap& metadata, + int default_value) { + if (metadata.find(key) != metadata.end()) { + std::istringstream iss(ToString(metadata.find(key)->second)); + iss >> default_value; + } + + return default_value; +} + +int GetIntValueFromMetadata( + const char* key, + const std::multimap& metadata, + int default_value) { + return GetIntValueFromMetadataHelper(key, metadata, default_value); +} +} // namespace + +void CallbackStreamingTestService::Echo( + ServerContext* context, const EchoRequest* request, EchoResponse* response, + experimental::ServerCallbackRpcController* controller) { + controller->Finish(Status::OK); +} + +experimental::ServerBidiReactor* +CallbackStreamingTestService::BidiStream() { + class Reactor : public experimental::ServerBidiReactor { + public: + Reactor() {} + void OnStarted(ServerContext* context) override { + ctx_ = context; + server_write_last_ = GetIntValueFromMetadata( + kServerFinishAfterNReads, context->client_metadata(), 0); + message_size_ = GetIntValueFromMetadata( + kServerResponseStreamsToSend, context->client_metadata(), 0); +// EchoRequest* request = new EchoRequest; +// if (message_size_ > 0) { +// request->set_message(std::string(message_size_, 'a')); +// } else { +// request->set_message(""); +// } +// +// request_ = request; + StartRead(&request_); + on_started_done_ = true; + } + void OnDone() override { delete this; } + void OnCancel() override {} + void OnReadDone(bool ok) override { + if (ok) { + num_msgs_read_++; +// gpr_log(GPR_INFO, "recv msg %s", request_.message().c_str()); + if (message_size_ > 0) { + response_.set_message(std::string(message_size_, 'a')); + } else { + response_.set_message(""); + } + if (num_msgs_read_ == server_write_last_) { + StartWriteLast(&response_, WriteOptions()); + } else { + StartWrite(&response_); + return; + } + } + FinishOnce(Status::OK); + } + void OnWriteDone(bool ok) override { + std::lock_guard l(finish_mu_); + if (!finished_) { + StartRead(&request_); + } + } + + private: + void FinishOnce(const Status& s) { + std::lock_guard l(finish_mu_); + if (!finished_) { + Finish(s); + finished_ = true; + } + } + + ServerContext* ctx_; + EchoRequest request_; + EchoResponse response_; + int num_msgs_read_{0}; + int server_write_last_; + int message_size_; + std::mutex finish_mu_; + bool finished_{false}; + bool on_started_done_{false}; + }; + + return new Reactor; +} +} // namespace testing +} // namespace grpc + diff --git a/test/cpp/microbenchmarks/callback_test_service.h b/test/cpp/microbenchmarks/callback_test_service.h new file mode 100644 index 00000000000..3c43ecb2215 --- /dev/null +++ b/test/cpp/microbenchmarks/callback_test_service.h @@ -0,0 +1,95 @@ +#ifndef TEST_CPP_MICROBENCHMARKS_CALLBACK_TEST_SERVICE_H +#define TEST_CPP_MICROBENCHMARKS_CALLBACK_TEST_SERVICE_H + +#include "src/proto/grpc/testing/echo.grpc.pb.h" +#include "test/cpp/util/string_ref_helper.h" +#include +#include +#include +#include + +namespace grpc { +namespace testing { + +const char* const kServerFinishAfterNReads = "server_finish_after_n_reads"; +const char* const kServerResponseStreamsToSend = "server_responses_to_send"; + +class CallbackStreamingTestService + : public EchoTestService::ExperimentalCallbackService { + public: + CallbackStreamingTestService() {} + void Echo(ServerContext* context, const EchoRequest* request, + EchoResponse* response, + experimental::ServerCallbackRpcController* controller) override; + + experimental::ServerBidiReactor* BidiStream() override; +}; + +class BidiClient + : public grpc::experimental::ClientBidiReactor { + public: + BidiClient(EchoTestService::Stub* stub, EchoRequest* request, + EchoResponse* response, ClientContext* context, int num_msgs_to_send) + : request_{request}, + response_{response}, + context_{context}, + msgs_to_send_{num_msgs_to_send}{ + stub->experimental_async()->BidiStream(context_, this); + MaybeWrite(); + StartRead(response_); + StartCall(); + } + + void OnReadDone(bool ok) override { + if (ok && reads_complete_ < msgs_to_send_) { + reads_complete_++; + StartRead(response_); + } + } + + void OnWriteDone(bool ok) override { + if (!ok) { + return; + } + writes_complete_++; + MaybeWrite(); + } + + void OnDone(const Status& s) override { + GPR_ASSERT(s.ok()); + std::unique_lock l(mu_); + done_ = true; + cv_.notify_one(); + } + + void Await() { + std::unique_lock l(mu_); + while (!done_) { + cv_.wait(l); + } + } + + private: + void MaybeWrite() { + if (writes_complete_ == msgs_to_send_) { + StartWritesDone(); + } else { + StartWrite(request_); + } + } + + EchoRequest* request_; + EchoResponse* response_; + ClientContext* context_; + int reads_complete_{0}; + int writes_complete_{0}; + const int msgs_to_send_; + std::mutex mu_; + std::condition_variable cv_; + bool done_ = false; +}; + + +} // namespace testing +} // namespace grpc +#endif // TEST_CPP_MICROBENCHMARKS_CALLBACK_TEST_SERVICE_H diff --git a/test/cpp/microbenchmarks/callback_unary_ping_pong.h b/test/cpp/microbenchmarks/callback_unary_ping_pong.h new file mode 100644 index 00000000000..7babb56287d --- /dev/null +++ b/test/cpp/microbenchmarks/callback_unary_ping_pong.h @@ -0,0 +1,84 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/* Benchmark gRPC end2end in various configurations */ + +#ifndef TEST_CPP_MICROBENCHMARKS_CALLBACK_UNARY_PING_PONG_H +#define TEST_CPP_MICROBENCHMARKS_CALLBACK_UNARY_PING_PONG_H + +#include +#include +#include "src/core/lib/profiling/timers.h" +#include "src/proto/grpc/testing/echo.grpc.pb.h" +#include "test/cpp/microbenchmarks/fullstack_context_mutators.h" +#include "test/cpp/microbenchmarks/fullstack_fixtures.h" +#include "test/cpp/microbenchmarks/callback_test_service.h" + +namespace grpc { +namespace testing { + +/******************************************************************************* + * BENCHMARKING KERNELS + */ + +template +static void BM_CallbackUnaryPingPong(benchmark::State& state) { + CallbackStreamingTestService service; + std::unique_ptr fixture(new Fixture(&service)); + std::unique_ptr stub_( + EchoTestService::NewStub(fixture->channel())); + EchoRequest request; + EchoResponse response; + + if (state.range(0) > 0) { + request.set_message(std::string(state.range(0), 'a')); + } else { + request.set_message(""); + } + if (state.range(1) > 0) { + response.set_message(std::string(state.range(1), 'a')); + } else { + response.set_message(""); + } + + while (state.KeepRunning()) { + GPR_TIMER_SCOPE("BenchmarkCycle", 0); + ClientContext cli_ctx; + std::mutex mu; + std::condition_variable cv; + bool done = false; + stub_->experimental_async()->Echo(&cli_ctx, &request, &response, + [&done, &mu, &cv](Status s) { + GPR_ASSERT(s.ok()); + std::lock_guard l(mu); + done = true; + cv.notify_one(); + }); + std::unique_lock l(mu); + while (!done) { + cv.wait(l); + } + } + fixture->Finish(state); + fixture.reset(); + state.SetBytesProcessed(state.range(0) * state.iterations() + state.range(1) * state.iterations()); +} +} // namespace testing +} // namespace grpc + +#endif // TEST_CPP_MICROBENCHMARKS_FULLSTACK_UNARY_PING_PONG_H diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 9778343cd94..486ff054794 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -2776,6 +2776,56 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "benchmark", + "callback_test_service", + "gpr", + "grpc++_test_config", + "grpc++_test_util_unsecure", + "grpc++_unsecure", + "grpc_benchmark", + "grpc_test_util_unsecure", + "grpc_unsecure" + ], + "headers": [ + "test/cpp/microbenchmarks/callback_streaming_ping_pong.h" + ], + "is_filegroup": false, + "language": "c++", + "name": "bm_callback_streaming_ping_pong", + "src": [ + "test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc", + "test/cpp/microbenchmarks/callback_streaming_ping_pong.h" + ], + "third_party": false, + "type": "target" + }, + { + "deps": [ + "benchmark", + "callback_test_service", + "gpr", + "grpc++_test_config", + "grpc++_test_util_unsecure", + "grpc++_unsecure", + "grpc_benchmark", + "grpc_test_util_unsecure", + "grpc_unsecure" + ], + "headers": [ + "test/cpp/microbenchmarks/callback_unary_ping_pong.h" + ], + "is_filegroup": false, + "language": "c++", + "name": "bm_callback_unary_ping_pong", + "src": [ + "test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc", + "test/cpp/microbenchmarks/callback_unary_ping_pong.h" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "benchmark", @@ -6573,6 +6623,28 @@ "third_party": false, "type": "lib" }, + { + "deps": [ + "benchmark", + "gpr", + "grpc", + "grpc++", + "grpc++_test_util", + "grpc_test_util" + ], + "headers": [ + "test/cpp/microbenchmarks/callback_test_service.h" + ], + "is_filegroup": false, + "language": "c++", + "name": "callback_test_service", + "src": [ + "test/cpp/microbenchmarks/callback_test_service.cc", + "test/cpp/microbenchmarks/callback_test_service.h" + ], + "third_party": false, + "type": "lib" + }, { "deps": [ "gpr", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index ec2e570bea7..d442c3b9744 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -3479,6 +3479,58 @@ ], "uses_polling": false }, + { + "args": [], + "benchmark": true, + "ci_platforms": [ + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "excluded_poll_engines": [ + "poll" + ], + "flaky": false, + "gtest": false, + "language": "c++", + "name": "bm_callback_streaming_ping_pong", + "platforms": [ + "linux", + "mac", + "posix" + ], + "timeout_seconds": 1200, + "uses_polling": true + }, + { + "args": [], + "benchmark": true, + "ci_platforms": [ + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "excluded_poll_engines": [ + "poll" + ], + "flaky": false, + "gtest": false, + "language": "c++", + "name": "bm_callback_unary_ping_pong", + "platforms": [ + "linux", + "mac", + "posix" + ], + "timeout_seconds": 1200, + "uses_polling": true + }, { "args": [], "benchmark": true, From c864bea0c675d7abe67978c8f263c76d6a411875 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Tue, 23 Apr 2019 17:58:44 -0700 Subject: [PATCH 0050/1555] Move TestService to a separate file to simplify its dependency --- .../tests/fork/_fork_interop_test.py | 4 +- .../grpcio_tests/tests/interop/BUILD.bazel | 91 +++++++++-------- .../tests/interop/_insecure_intraop_test.py | 4 +- .../tests/interop/_secure_intraop_test.py | 4 +- .../grpcio_tests/tests/interop/methods.py | 73 -------------- .../grpcio_tests/tests/interop/server.py | 4 +- .../grpcio_tests/tests/interop/service.py | 97 +++++++++++++++++++ 7 files changed, 156 insertions(+), 121 deletions(-) create mode 100644 src/python/grpcio_tests/tests/interop/service.py diff --git a/src/python/grpcio_tests/tests/fork/_fork_interop_test.py b/src/python/grpcio_tests/tests/fork/_fork_interop_test.py index 608148dfe46..602786c5e0d 100644 --- a/src/python/grpcio_tests/tests/fork/_fork_interop_test.py +++ b/src/python/grpcio_tests/tests/fork/_fork_interop_test.py @@ -56,12 +56,12 @@ class ForkInteropTest(unittest.TestCase): import grpc from src.proto.grpc.testing import test_pb2_grpc - from tests.interop import methods as interop_methods + from tests.interop import service as interop_service from tests.unit import test_common server = test_common.test_server() test_pb2_grpc.add_TestServiceServicer_to_server( - interop_methods.TestService(), server) + interop_service.TestService(), server) port = server.add_insecure_port('[::]:0') server.start() print(port) diff --git a/src/python/grpcio_tests/tests/interop/BUILD.bazel b/src/python/grpcio_tests/tests/interop/BUILD.bazel index 770b1f78a70..fd636556074 100644 --- a/src/python/grpcio_tests/tests/interop/BUILD.bazel +++ b/src/python/grpcio_tests/tests/interop/BUILD.bazel @@ -5,45 +5,45 @@ package(default_visibility = ["//visibility:public"]) py_library( name = "_intraop_test_case", srcs = ["_intraop_test_case.py"], + imports = ["../../"], deps = [ ":methods", ], - imports=["../../",], ) py_library( name = "client", srcs = ["client.py"], + imports = ["../../"], deps = [ - "//src/python/grpcio/grpc:grpcio", ":methods", ":resources", "//src/proto/grpc/testing:py_test_proto", - requirement('google-auth'), + "//src/python/grpcio/grpc:grpcio", + requirement("google-auth"), ], - imports=["../../",], ) py_library( name = "methods", srcs = ["methods.py"], + imports = ["../../"], deps = [ "//src/python/grpcio/grpc:grpcio", "//src/python/grpcio_tests/tests:bazel_namespace_package_hack", "//src/proto/grpc/testing:py_empty_proto", "//src/proto/grpc/testing:py_messages_proto", "//src/proto/grpc/testing:py_test_proto", - requirement('google-auth'), - requirement('requests'), - requirement('urllib3'), - requirement('chardet'), - requirement('certifi'), - requirement('idna'), + requirement("google-auth"), + requirement("requests"), + requirement("urllib3"), + requirement("chardet"), + requirement("certifi"), + requirement("idna"), ] + select({ - "//conditions:default": [requirement('enum34'),], + "//conditions:default": [requirement("enum34")], "//:python3": [], }), - imports=["../../",], ) py_library( @@ -54,51 +54,62 @@ py_library( ], ) +py_library( + name = "service", + srcs = ["service.py"], + imports = ["../../"], + deps = [ + "//src/proto/grpc/testing:py_empty_proto", + "//src/proto/grpc/testing:py_messages_proto", + "//src/proto/grpc/testing:py_test_proto", + "//src/python/grpcio/grpc:grpcio", + ], +) + py_library( name = "server", srcs = ["server.py"], + imports = ["../../"], deps = [ - "//src/python/grpcio/grpc:grpcio", - ":methods", ":resources", - "//src/python/grpcio_tests/tests/unit:test_common", + ":service", "//src/proto/grpc/testing:py_test_proto", + "//src/python/grpcio/grpc:grpcio", + "//src/python/grpcio_tests/tests/unit:test_common", ], - imports=["../../",], ) py_test( - name="_insecure_intraop_test", - size="small", - srcs=["_insecure_intraop_test.py",], - main="_insecure_intraop_test.py", - deps=[ - "//src/python/grpcio/grpc:grpcio", - ":_intraop_test_case", - ":methods", - ":server", - "//src/python/grpcio_tests/tests/unit:test_common", - "//src/proto/grpc/testing:py_test_proto", - ], - imports=["../../",], - data=[ + name = "_insecure_intraop_test", + size = "small", + srcs = ["_insecure_intraop_test.py"], + data = [ "//src/python/grpcio_tests/tests/unit/credentials", ], + imports = ["../../"], + main = "_insecure_intraop_test.py", + deps = [ + ":_intraop_test_case", + ":server", + ":service", + "//src/proto/grpc/testing:py_test_proto", + "//src/python/grpcio/grpc:grpcio", + "//src/python/grpcio_tests/tests/unit:test_common", + ], ) py_test( - name="_secure_intraop_test", - size="small", - srcs=["_secure_intraop_test.py",], - main="_secure_intraop_test.py", - deps=[ - "//src/python/grpcio/grpc:grpcio", + name = "_secure_intraop_test", + size = "small", + srcs = ["_secure_intraop_test.py"], + imports = ["../../"], + main = "_secure_intraop_test.py", + deps = [ ":_intraop_test_case", - ":methods", ":server", - "//src/python/grpcio_tests/tests/unit:test_common", + ":service", "//src/proto/grpc/testing:py_test_proto", + "//src/python/grpcio/grpc:grpcio", + "//src/python/grpcio_tests/tests/unit:test_common", ], - imports=["../../",], ) - diff --git a/src/python/grpcio_tests/tests/interop/_insecure_intraop_test.py b/src/python/grpcio_tests/tests/interop/_insecure_intraop_test.py index ace15bea585..fecf31767a7 100644 --- a/src/python/grpcio_tests/tests/interop/_insecure_intraop_test.py +++ b/src/python/grpcio_tests/tests/interop/_insecure_intraop_test.py @@ -19,7 +19,7 @@ import grpc from src.proto.grpc.testing import test_pb2_grpc from tests.interop import _intraop_test_case -from tests.interop import methods +from tests.interop import service from tests.interop import server from tests.unit import test_common @@ -29,7 +29,7 @@ class InsecureIntraopTest(_intraop_test_case.IntraopTestCase, def setUp(self): self.server = test_common.test_server() - test_pb2_grpc.add_TestServiceServicer_to_server(methods.TestService(), + test_pb2_grpc.add_TestServiceServicer_to_server(service.TestService(), self.server) port = self.server.add_insecure_port('[::]:0') self.server.start() diff --git a/src/python/grpcio_tests/tests/interop/_secure_intraop_test.py b/src/python/grpcio_tests/tests/interop/_secure_intraop_test.py index e27e551ecb0..1b5e5cfd2dd 100644 --- a/src/python/grpcio_tests/tests/interop/_secure_intraop_test.py +++ b/src/python/grpcio_tests/tests/interop/_secure_intraop_test.py @@ -19,7 +19,7 @@ import grpc from src.proto.grpc.testing import test_pb2_grpc from tests.interop import _intraop_test_case -from tests.interop import methods +from tests.interop import service from tests.interop import resources from tests.unit import test_common @@ -30,7 +30,7 @@ class SecureIntraopTest(_intraop_test_case.IntraopTestCase, unittest.TestCase): def setUp(self): self.server = test_common.test_server() - test_pb2_grpc.add_TestServiceServicer_to_server(methods.TestService(), + test_pb2_grpc.add_TestServiceServicer_to_server(service.TestService(), self.server) port = self.server.add_secure_port( '[::]:0', diff --git a/src/python/grpcio_tests/tests/interop/methods.py b/src/python/grpcio_tests/tests/interop/methods.py index 08d8901a6b4..250db8bb385 100644 --- a/src/python/grpcio_tests/tests/interop/methods.py +++ b/src/python/grpcio_tests/tests/interop/methods.py @@ -35,82 +35,9 @@ import grpc from src.proto.grpc.testing import empty_pb2 from src.proto.grpc.testing import messages_pb2 -from src.proto.grpc.testing import test_pb2_grpc _INITIAL_METADATA_KEY = "x-grpc-test-echo-initial" _TRAILING_METADATA_KEY = "x-grpc-test-echo-trailing-bin" -_US_IN_A_SECOND = 1000 * 1000 - - -def _maybe_echo_metadata(servicer_context): - """Copies metadata from request to response if it is present.""" - invocation_metadata = dict(servicer_context.invocation_metadata()) - if _INITIAL_METADATA_KEY in invocation_metadata: - initial_metadatum = (_INITIAL_METADATA_KEY, - invocation_metadata[_INITIAL_METADATA_KEY]) - servicer_context.send_initial_metadata((initial_metadatum,)) - if _TRAILING_METADATA_KEY in invocation_metadata: - trailing_metadatum = (_TRAILING_METADATA_KEY, - invocation_metadata[_TRAILING_METADATA_KEY]) - servicer_context.set_trailing_metadata((trailing_metadatum,)) - - -def _maybe_echo_status_and_message(request, servicer_context): - """Sets the response context code and details if the request asks for them""" - if request.HasField('response_status'): - servicer_context.set_code(request.response_status.code) - servicer_context.set_details(request.response_status.message) - - -class TestService(test_pb2_grpc.TestServiceServicer): - - def EmptyCall(self, request, context): - _maybe_echo_metadata(context) - return empty_pb2.Empty() - - def UnaryCall(self, request, context): - _maybe_echo_metadata(context) - _maybe_echo_status_and_message(request, context) - return messages_pb2.SimpleResponse( - payload=messages_pb2.Payload( - type=messages_pb2.COMPRESSABLE, - body=b'\x00' * request.response_size)) - - def StreamingOutputCall(self, request, context): - _maybe_echo_status_and_message(request, context) - for response_parameters in request.response_parameters: - if response_parameters.interval_us != 0: - time.sleep(response_parameters.interval_us / _US_IN_A_SECOND) - yield messages_pb2.StreamingOutputCallResponse( - payload=messages_pb2.Payload( - type=request.response_type, - body=b'\x00' * response_parameters.size)) - - def StreamingInputCall(self, request_iterator, context): - aggregate_size = 0 - for request in request_iterator: - if request.payload is not None and request.payload.body: - aggregate_size += len(request.payload.body) - return messages_pb2.StreamingInputCallResponse( - aggregated_payload_size=aggregate_size) - - def FullDuplexCall(self, request_iterator, context): - _maybe_echo_metadata(context) - for request in request_iterator: - _maybe_echo_status_and_message(request, context) - for response_parameters in request.response_parameters: - if response_parameters.interval_us != 0: - time.sleep( - response_parameters.interval_us / _US_IN_A_SECOND) - yield messages_pb2.StreamingOutputCallResponse( - payload=messages_pb2.Payload( - type=request.payload.type, - body=b'\x00' * response_parameters.size)) - - # NOTE(nathaniel): Apparently this is the same as the full-duplex call? - # NOTE(atash): It isn't even called in the interop spec (Oct 22 2015)... - def HalfDuplexCall(self, request_iterator, context): - return self.FullDuplexCall(request_iterator, context) def _expect_status_code(call, expected_code): diff --git a/src/python/grpcio_tests/tests/interop/server.py b/src/python/grpcio_tests/tests/interop/server.py index 72f88a1c989..3611ffdbb2f 100644 --- a/src/python/grpcio_tests/tests/interop/server.py +++ b/src/python/grpcio_tests/tests/interop/server.py @@ -21,7 +21,7 @@ import time import grpc from src.proto.grpc.testing import test_pb2_grpc -from tests.interop import methods +from tests.interop import service from tests.interop import resources from tests.unit import test_common @@ -42,7 +42,7 @@ def serve(): args = parser.parse_args() server = test_common.test_server() - test_pb2_grpc.add_TestServiceServicer_to_server(methods.TestService(), + test_pb2_grpc.add_TestServiceServicer_to_server(service.TestService(), server) if args.use_tls: private_key = resources.private_key() diff --git a/src/python/grpcio_tests/tests/interop/service.py b/src/python/grpcio_tests/tests/interop/service.py new file mode 100644 index 00000000000..20f76fceebf --- /dev/null +++ b/src/python/grpcio_tests/tests/interop/service.py @@ -0,0 +1,97 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""The Python implementation of the TestServicer.""" + +import time + +import grpc + +from src.proto.grpc.testing import empty_pb2 +from src.proto.grpc.testing import messages_pb2 +from src.proto.grpc.testing import test_pb2_grpc + +_INITIAL_METADATA_KEY = "x-grpc-test-echo-initial" +_TRAILING_METADATA_KEY = "x-grpc-test-echo-trailing-bin" +_US_IN_A_SECOND = 1000 * 1000 + + +def _maybe_echo_metadata(servicer_context): + """Copies metadata from request to response if it is present.""" + invocation_metadata = dict(servicer_context.invocation_metadata()) + if _INITIAL_METADATA_KEY in invocation_metadata: + initial_metadatum = (_INITIAL_METADATA_KEY, + invocation_metadata[_INITIAL_METADATA_KEY]) + servicer_context.send_initial_metadata((initial_metadatum,)) + if _TRAILING_METADATA_KEY in invocation_metadata: + trailing_metadatum = (_TRAILING_METADATA_KEY, + invocation_metadata[_TRAILING_METADATA_KEY]) + servicer_context.set_trailing_metadata((trailing_metadatum,)) + + +def _maybe_echo_status_and_message(request, servicer_context): + """Sets the response context code and details if the request asks for them""" + if request.HasField('response_status'): + servicer_context.set_code(request.response_status.code) + servicer_context.set_details(request.response_status.message) + + +class TestService(test_pb2_grpc.TestServiceServicer): + + def EmptyCall(self, request, context): + _maybe_echo_metadata(context) + return empty_pb2.Empty() + + def UnaryCall(self, request, context): + _maybe_echo_metadata(context) + _maybe_echo_status_and_message(request, context) + return messages_pb2.SimpleResponse( + payload=messages_pb2.Payload( + type=messages_pb2.COMPRESSABLE, + body=b'\x00' * request.response_size)) + + def StreamingOutputCall(self, request, context): + _maybe_echo_status_and_message(request, context) + for response_parameters in request.response_parameters: + if response_parameters.interval_us != 0: + time.sleep(response_parameters.interval_us / _US_IN_A_SECOND) + yield messages_pb2.StreamingOutputCallResponse( + payload=messages_pb2.Payload( + type=request.response_type, + body=b'\x00' * response_parameters.size)) + + def StreamingInputCall(self, request_iterator, context): + aggregate_size = 0 + for request in request_iterator: + if request.payload is not None and request.payload.body: + aggregate_size += len(request.payload.body) + return messages_pb2.StreamingInputCallResponse( + aggregated_payload_size=aggregate_size) + + def FullDuplexCall(self, request_iterator, context): + _maybe_echo_metadata(context) + for request in request_iterator: + _maybe_echo_status_and_message(request, context) + for response_parameters in request.response_parameters: + if response_parameters.interval_us != 0: + time.sleep( + response_parameters.interval_us / _US_IN_A_SECOND) + yield messages_pb2.StreamingOutputCallResponse( + payload=messages_pb2.Payload( + type=request.payload.type, + body=b'\x00' * response_parameters.size)) + + # NOTE(nathaniel): Apparently this is the same as the full-duplex call? + # NOTE(atash): It isn't even called in the interop spec (Oct 22 2015)... + def HalfDuplexCall(self, request_iterator, context): + return self.FullDuplexCall(request_iterator, context) \ No newline at end of file From 875d2df3994f48037d707f0e151e1ff1bad38f6f Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Fri, 26 Apr 2019 10:52:21 -0700 Subject: [PATCH 0051/1555] Modify build file --- test/cpp/microbenchmarks/BUILD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD index e28846fcf94..116180d1688 100644 --- a/test/cpp/microbenchmarks/BUILD +++ b/test/cpp/microbenchmarks/BUILD @@ -228,8 +228,8 @@ grpc_cc_library( srcs = ["callback_test_service.cc"], hdrs = ["callback_test_service.h"], deps = [ - "//third_party/grpc/src/proto/grpc/testing:echo_proto", - "//third_party/grpc/test/cpp/util:test_util", + "//src/proto/grpc/testing:echo_proto", + "//test/cpp/util:test_util", ], ) From 13d6d7c2ece43dbed7664787ca64408e42a10ace Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Fri, 26 Apr 2019 12:58:56 -0700 Subject: [PATCH 0052/1555] Add filegroups in callback_test_service --- CMakeLists.txt | 119 +++++++++++++++++- Makefile | 106 +++++++++++++++- build.yaml | 16 +-- grpc.gyp | 10 +- .../generated/sources_and_headers.json | 13 +- 5 files changed, 237 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 41427278646..6eaa01c56d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2907,6 +2907,7 @@ if (gRPC_BUILD_TESTS) add_library(callback_test_service test/cpp/microbenchmarks/callback_test_service.cc + src/cpp/codegen/codegen_init.cc ) if(WIN32 AND MSVC) @@ -2941,15 +2942,121 @@ target_include_directories(callback_test_service target_link_libraries(callback_test_service ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - ${_gRPC_BENCHMARK_LIBRARIES} - grpc++_test_util - grpc_test_util - grpc++ - grpc - gpr + grpc++_unsecure + grpc_test_util_unsecure + grpc_unsecure ${_gRPC_GFLAGS_LIBRARIES} ) +foreach(_hdr + include/grpc++/impl/codegen/async_stream.h + include/grpc++/impl/codegen/async_unary_call.h + include/grpc++/impl/codegen/byte_buffer.h + include/grpc++/impl/codegen/call.h + include/grpc++/impl/codegen/call_hook.h + include/grpc++/impl/codegen/channel_interface.h + include/grpc++/impl/codegen/client_context.h + include/grpc++/impl/codegen/client_unary_call.h + include/grpc++/impl/codegen/completion_queue.h + include/grpc++/impl/codegen/completion_queue_tag.h + include/grpc++/impl/codegen/config.h + include/grpc++/impl/codegen/core_codegen_interface.h + include/grpc++/impl/codegen/create_auth_context.h + include/grpc++/impl/codegen/grpc_library.h + include/grpc++/impl/codegen/metadata_map.h + include/grpc++/impl/codegen/method_handler_impl.h + include/grpc++/impl/codegen/rpc_method.h + include/grpc++/impl/codegen/rpc_service_method.h + include/grpc++/impl/codegen/security/auth_context.h + include/grpc++/impl/codegen/serialization_traits.h + include/grpc++/impl/codegen/server_context.h + include/grpc++/impl/codegen/server_interface.h + include/grpc++/impl/codegen/service_type.h + include/grpc++/impl/codegen/slice.h + include/grpc++/impl/codegen/status.h + include/grpc++/impl/codegen/status_code_enum.h + include/grpc++/impl/codegen/string_ref.h + include/grpc++/impl/codegen/stub_options.h + include/grpc++/impl/codegen/sync_stream.h + include/grpc++/impl/codegen/time.h + include/grpcpp/impl/codegen/async_generic_service.h + include/grpcpp/impl/codegen/async_stream.h + include/grpcpp/impl/codegen/async_unary_call.h + include/grpcpp/impl/codegen/byte_buffer.h + include/grpcpp/impl/codegen/call.h + include/grpcpp/impl/codegen/call_hook.h + include/grpcpp/impl/codegen/call_op_set.h + include/grpcpp/impl/codegen/call_op_set_interface.h + include/grpcpp/impl/codegen/callback_common.h + include/grpcpp/impl/codegen/channel_interface.h + include/grpcpp/impl/codegen/client_callback.h + include/grpcpp/impl/codegen/client_context.h + include/grpcpp/impl/codegen/client_interceptor.h + include/grpcpp/impl/codegen/client_unary_call.h + include/grpcpp/impl/codegen/completion_queue.h + include/grpcpp/impl/codegen/completion_queue_tag.h + include/grpcpp/impl/codegen/config.h + include/grpcpp/impl/codegen/core_codegen_interface.h + include/grpcpp/impl/codegen/create_auth_context.h + include/grpcpp/impl/codegen/grpc_library.h + include/grpcpp/impl/codegen/intercepted_channel.h + include/grpcpp/impl/codegen/interceptor.h + include/grpcpp/impl/codegen/interceptor_common.h + include/grpcpp/impl/codegen/message_allocator.h + include/grpcpp/impl/codegen/metadata_map.h + include/grpcpp/impl/codegen/method_handler_impl.h + include/grpcpp/impl/codegen/rpc_method.h + include/grpcpp/impl/codegen/rpc_service_method.h + include/grpcpp/impl/codegen/security/auth_context.h + include/grpcpp/impl/codegen/serialization_traits.h + include/grpcpp/impl/codegen/server_callback.h + include/grpcpp/impl/codegen/server_context.h + include/grpcpp/impl/codegen/server_interceptor.h + include/grpcpp/impl/codegen/server_interface.h + include/grpcpp/impl/codegen/service_type.h + include/grpcpp/impl/codegen/slice.h + include/grpcpp/impl/codegen/status.h + include/grpcpp/impl/codegen/status_code_enum.h + include/grpcpp/impl/codegen/string_ref.h + include/grpcpp/impl/codegen/stub_options.h + include/grpcpp/impl/codegen/sync_stream.h + include/grpcpp/impl/codegen/time.h + include/grpc/impl/codegen/byte_buffer.h + include/grpc/impl/codegen/byte_buffer_reader.h + include/grpc/impl/codegen/compression_types.h + include/grpc/impl/codegen/connectivity_state.h + include/grpc/impl/codegen/grpc_types.h + include/grpc/impl/codegen/propagation_bits.h + include/grpc/impl/codegen/slice.h + include/grpc/impl/codegen/status.h + include/grpc/impl/codegen/atm.h + include/grpc/impl/codegen/atm_gcc_atomic.h + include/grpc/impl/codegen/atm_gcc_sync.h + include/grpc/impl/codegen/atm_windows.h + include/grpc/impl/codegen/fork.h + include/grpc/impl/codegen/gpr_slice.h + include/grpc/impl/codegen/gpr_types.h + include/grpc/impl/codegen/log.h + include/grpc/impl/codegen/port_platform.h + include/grpc/impl/codegen/sync.h + include/grpc/impl/codegen/sync_custom.h + include/grpc/impl/codegen/sync_generic.h + include/grpc/impl/codegen/sync_posix.h + include/grpc/impl/codegen/sync_windows.h + include/grpcpp/impl/codegen/sync.h + include/grpc++/impl/codegen/proto_utils.h + include/grpcpp/impl/codegen/proto_buffer_reader.h + include/grpcpp/impl/codegen/proto_buffer_writer.h + include/grpcpp/impl/codegen/proto_utils.h + include/grpc++/impl/codegen/config_protobuf.h + include/grpcpp/impl/codegen/config_protobuf.h +) + string(REPLACE "include/" "" _path ${_hdr}) + get_filename_component(_path ${_path} PATH) + install(FILES ${_hdr} + DESTINATION "${gRPC_INSTALL_INCLUDEDIR}/${_path}" + ) +endforeach() endif (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index 6e83616e243..698184ecafd 100644 --- a/Makefile +++ b/Makefile @@ -1411,9 +1411,9 @@ pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc ifeq ($(EMBED_OPENSSL),true) -privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_core_stats.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libhttp2_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libbenchmark.a +privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libcallback_test_service.a $(LIBDIR)/$(CONFIG)/libgrpc++_core_stats.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libhttp2_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libbenchmark.a else -privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_core_stats.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libhttp2_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libbenchmark.a +privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libcallback_test_service.a $(LIBDIR)/$(CONFIG)/libgrpc++_core_stats.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libhttp2_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libbenchmark.a endif @@ -5285,8 +5285,110 @@ endif LIBCALLBACK_TEST_SERVICE_SRC = \ test/cpp/microbenchmarks/callback_test_service.cc \ + src/cpp/codegen/codegen_init.cc \ PUBLIC_HEADERS_CXX += \ + include/grpc++/impl/codegen/async_stream.h \ + include/grpc++/impl/codegen/async_unary_call.h \ + include/grpc++/impl/codegen/byte_buffer.h \ + include/grpc++/impl/codegen/call.h \ + include/grpc++/impl/codegen/call_hook.h \ + include/grpc++/impl/codegen/channel_interface.h \ + include/grpc++/impl/codegen/client_context.h \ + include/grpc++/impl/codegen/client_unary_call.h \ + include/grpc++/impl/codegen/completion_queue.h \ + include/grpc++/impl/codegen/completion_queue_tag.h \ + include/grpc++/impl/codegen/config.h \ + include/grpc++/impl/codegen/core_codegen_interface.h \ + include/grpc++/impl/codegen/create_auth_context.h \ + include/grpc++/impl/codegen/grpc_library.h \ + include/grpc++/impl/codegen/metadata_map.h \ + include/grpc++/impl/codegen/method_handler_impl.h \ + include/grpc++/impl/codegen/rpc_method.h \ + include/grpc++/impl/codegen/rpc_service_method.h \ + include/grpc++/impl/codegen/security/auth_context.h \ + include/grpc++/impl/codegen/serialization_traits.h \ + include/grpc++/impl/codegen/server_context.h \ + include/grpc++/impl/codegen/server_interface.h \ + include/grpc++/impl/codegen/service_type.h \ + include/grpc++/impl/codegen/slice.h \ + include/grpc++/impl/codegen/status.h \ + include/grpc++/impl/codegen/status_code_enum.h \ + include/grpc++/impl/codegen/string_ref.h \ + include/grpc++/impl/codegen/stub_options.h \ + include/grpc++/impl/codegen/sync_stream.h \ + include/grpc++/impl/codegen/time.h \ + include/grpcpp/impl/codegen/async_generic_service.h \ + include/grpcpp/impl/codegen/async_stream.h \ + include/grpcpp/impl/codegen/async_unary_call.h \ + include/grpcpp/impl/codegen/byte_buffer.h \ + include/grpcpp/impl/codegen/call.h \ + include/grpcpp/impl/codegen/call_hook.h \ + include/grpcpp/impl/codegen/call_op_set.h \ + include/grpcpp/impl/codegen/call_op_set_interface.h \ + include/grpcpp/impl/codegen/callback_common.h \ + include/grpcpp/impl/codegen/channel_interface.h \ + include/grpcpp/impl/codegen/client_callback.h \ + include/grpcpp/impl/codegen/client_context.h \ + include/grpcpp/impl/codegen/client_interceptor.h \ + include/grpcpp/impl/codegen/client_unary_call.h \ + include/grpcpp/impl/codegen/completion_queue.h \ + include/grpcpp/impl/codegen/completion_queue_tag.h \ + include/grpcpp/impl/codegen/config.h \ + include/grpcpp/impl/codegen/core_codegen_interface.h \ + include/grpcpp/impl/codegen/create_auth_context.h \ + include/grpcpp/impl/codegen/grpc_library.h \ + include/grpcpp/impl/codegen/intercepted_channel.h \ + include/grpcpp/impl/codegen/interceptor.h \ + include/grpcpp/impl/codegen/interceptor_common.h \ + include/grpcpp/impl/codegen/message_allocator.h \ + include/grpcpp/impl/codegen/metadata_map.h \ + include/grpcpp/impl/codegen/method_handler_impl.h \ + include/grpcpp/impl/codegen/rpc_method.h \ + include/grpcpp/impl/codegen/rpc_service_method.h \ + include/grpcpp/impl/codegen/security/auth_context.h \ + include/grpcpp/impl/codegen/serialization_traits.h \ + include/grpcpp/impl/codegen/server_callback.h \ + include/grpcpp/impl/codegen/server_context.h \ + include/grpcpp/impl/codegen/server_interceptor.h \ + include/grpcpp/impl/codegen/server_interface.h \ + include/grpcpp/impl/codegen/service_type.h \ + include/grpcpp/impl/codegen/slice.h \ + include/grpcpp/impl/codegen/status.h \ + include/grpcpp/impl/codegen/status_code_enum.h \ + include/grpcpp/impl/codegen/string_ref.h \ + include/grpcpp/impl/codegen/stub_options.h \ + include/grpcpp/impl/codegen/sync_stream.h \ + include/grpcpp/impl/codegen/time.h \ + include/grpc/impl/codegen/byte_buffer.h \ + include/grpc/impl/codegen/byte_buffer_reader.h \ + include/grpc/impl/codegen/compression_types.h \ + include/grpc/impl/codegen/connectivity_state.h \ + include/grpc/impl/codegen/grpc_types.h \ + include/grpc/impl/codegen/propagation_bits.h \ + include/grpc/impl/codegen/slice.h \ + include/grpc/impl/codegen/status.h \ + include/grpc/impl/codegen/atm.h \ + include/grpc/impl/codegen/atm_gcc_atomic.h \ + include/grpc/impl/codegen/atm_gcc_sync.h \ + include/grpc/impl/codegen/atm_windows.h \ + include/grpc/impl/codegen/fork.h \ + include/grpc/impl/codegen/gpr_slice.h \ + include/grpc/impl/codegen/gpr_types.h \ + include/grpc/impl/codegen/log.h \ + include/grpc/impl/codegen/port_platform.h \ + include/grpc/impl/codegen/sync.h \ + include/grpc/impl/codegen/sync_custom.h \ + include/grpc/impl/codegen/sync_generic.h \ + include/grpc/impl/codegen/sync_posix.h \ + include/grpc/impl/codegen/sync_windows.h \ + include/grpcpp/impl/codegen/sync.h \ + include/grpc++/impl/codegen/proto_utils.h \ + include/grpcpp/impl/codegen/proto_buffer_reader.h \ + include/grpcpp/impl/codegen/proto_buffer_writer.h \ + include/grpcpp/impl/codegen/proto_utils.h \ + include/grpc++/impl/codegen/config_protobuf.h \ + include/grpcpp/impl/codegen/config_protobuf.h \ LIBCALLBACK_TEST_SERVICE_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBCALLBACK_TEST_SERVICE_SRC)))) diff --git a/build.yaml b/build.yaml index 25a476d44fe..562b3216356 100644 --- a/build.yaml +++ b/build.yaml @@ -1666,19 +1666,21 @@ libs: - grpc - gpr - name: callback_test_service - build: test + build: private language: c++ headers: - test/cpp/microbenchmarks/callback_test_service.h src: - test/cpp/microbenchmarks/callback_test_service.cc deps: - - benchmark - - grpc++_test_util - - grpc_test_util - - grpc++ - - grpc - - gpr + - grpc++_unsecure + - grpc_test_util_unsecure + - grpc_unsecure + filegroups: + - grpc++_codegen_base + - grpc++_codegen_base_src + - grpc++_codegen_proto + - grpc++_config_proto - name: grpc++ build: all language: c++ diff --git a/grpc.gyp b/grpc.gyp index fab5b010a4f..30e155f421f 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -1402,15 +1402,13 @@ 'target_name': 'callback_test_service', 'type': 'static_library', 'dependencies': [ - 'benchmark', - 'grpc++_test_util', - 'grpc_test_util', - 'grpc++', - 'grpc', - 'gpr', + 'grpc++_unsecure', + 'grpc_test_util_unsecure', + 'grpc_unsecure', ], 'sources': [ 'test/cpp/microbenchmarks/callback_test_service.cc', + 'src/cpp/codegen/codegen_init.cc', ], }, { diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 486ff054794..c87b79e624b 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -6625,12 +6625,13 @@ }, { "deps": [ - "benchmark", - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" + "grpc++_codegen_base", + "grpc++_codegen_base_src", + "grpc++_codegen_proto", + "grpc++_config_proto", + "grpc++_unsecure", + "grpc_test_util_unsecure", + "grpc_unsecure" ], "headers": [ "test/cpp/microbenchmarks/callback_test_service.h" From 8bf138d7998b56471c96299e421875b030f83809 Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Fri, 26 Apr 2019 14:29:57 -0700 Subject: [PATCH 0053/1555] Add copyright --- .../bm_callback_streaming_ping_pong.cc | 18 +++++++ .../bm_callback_unary_ping_pong.cc | 27 +++++++++-- .../callback_streaming_ping_pong.h | 27 +++++++++-- .../microbenchmarks/callback_test_service.cc | 47 +++++++++++++------ .../microbenchmarks/callback_test_service.h | 43 ++++++++++++----- .../callback_unary_ping_pong.h | 19 ++++---- 6 files changed, 137 insertions(+), 44 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc b/test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc index ad7c2f0ee3e..ed1c3189086 100644 --- a/test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc +++ b/test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc @@ -1,3 +1,21 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + #include "test/cpp/microbenchmarks/callback_streaming_ping_pong.h" #include "test/cpp/util/test_config.h" diff --git a/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc b/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc index fee41ea8d1a..c0a7054bf51 100644 --- a/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc +++ b/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc @@ -1,3 +1,21 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + #include "test/cpp/microbenchmarks/callback_unary_ping_pong.h" #include "test/cpp/util/test_config.h" @@ -22,11 +40,14 @@ static void SweepSizesArgs(benchmark::internal::Benchmark* b) { } } -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, NoOpMutator) +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, + NoOpMutator) ->Apply(SweepSizesArgs); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, MinInProcess, NoOpMutator, NoOpMutator) +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, MinInProcess, NoOpMutator, + NoOpMutator) ->Apply(SweepSizesArgs); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, NoOpMutator) +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, + NoOpMutator) ->Apply(SweepSizesArgs); BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, MinInProcessCHTTP2, NoOpMutator, NoOpMutator) diff --git a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h index 13b4c155459..13743412153 100644 --- a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h @@ -1,14 +1,31 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + #ifndef TEST_CPP_MICROBENCHMARKS_CALLBACK_STREAMING_PING_PONG_H #define TEST_CPP_MICROBENCHMARKS_CALLBACK_STREAMING_PING_PONG_H - #include #include #include "src/core/lib/profiling/timers.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" +#include "test/cpp/microbenchmarks/callback_test_service.h" #include "test/cpp/microbenchmarks/fullstack_context_mutators.h" #include "test/cpp/microbenchmarks/fullstack_fixtures.h" -#include "test/cpp/microbenchmarks/callback_test_service.h" namespace grpc { namespace testing { @@ -38,14 +55,14 @@ static void BM_CallbackBidiStreaming(benchmark::State& state) { cli_ctx->AddMetadata(kServerFinishAfterNReads, grpc::to_string(max_ping_pongs)); cli_ctx->AddMetadata(kServerResponseStreamsToSend, - grpc::to_string(message_size)); + grpc::to_string(message_size)); BidiClient test{stub_.get(), request, response, cli_ctx, max_ping_pongs}; test.Await(); } fixture->Finish(state); fixture.reset(); - state.SetBytesProcessed(2 * state.range(0) * state.iterations() - * state.range(1)); + state.SetBytesProcessed(2 * state.range(0) * state.iterations() * + state.range(1)); } } // namespace testing diff --git a/test/cpp/microbenchmarks/callback_test_service.cc b/test/cpp/microbenchmarks/callback_test_service.cc index 057517acf05..caa734d90e8 100644 --- a/test/cpp/microbenchmarks/callback_test_service.cc +++ b/test/cpp/microbenchmarks/callback_test_service.cc @@ -1,3 +1,21 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + #include "test/cpp/microbenchmarks/callback_test_service.h" namespace grpc { @@ -26,7 +44,7 @@ int GetIntValueFromMetadata( int default_value) { return GetIntValueFromMetadataHelper(key, metadata, default_value); } -} // namespace +} // namespace void CallbackStreamingTestService::Echo( ServerContext* context, const EchoRequest* request, EchoResponse* response, @@ -36,24 +54,24 @@ void CallbackStreamingTestService::Echo( experimental::ServerBidiReactor* CallbackStreamingTestService::BidiStream() { - class Reactor : public experimental::ServerBidiReactor { + class Reactor + : public experimental::ServerBidiReactor { public: Reactor() {} void OnStarted(ServerContext* context) override { ctx_ = context; server_write_last_ = GetIntValueFromMetadata( kServerFinishAfterNReads, context->client_metadata(), 0); - message_size_ = GetIntValueFromMetadata( - kServerResponseStreamsToSend, context->client_metadata(), 0); -// EchoRequest* request = new EchoRequest; -// if (message_size_ > 0) { -// request->set_message(std::string(message_size_, 'a')); -// } else { -// request->set_message(""); -// } -// -// request_ = request; + message_size_ = GetIntValueFromMetadata(kServerResponseStreamsToSend, + context->client_metadata(), 0); + // EchoRequest* request = new EchoRequest; + // if (message_size_ > 0) { + // request->set_message(std::string(message_size_, 'a')); + // } else { + // request->set_message(""); + // } + // + // request_ = request; StartRead(&request_); on_started_done_ = true; } @@ -62,7 +80,7 @@ CallbackStreamingTestService::BidiStream() { void OnReadDone(bool ok) override { if (ok) { num_msgs_read_++; -// gpr_log(GPR_INFO, "recv msg %s", request_.message().c_str()); + // gpr_log(GPR_INFO, "recv msg %s", request_.message().c_str()); if (message_size_ > 0) { response_.set_message(std::string(message_size_, 'a')); } else { @@ -108,4 +126,3 @@ CallbackStreamingTestService::BidiStream() { } } // namespace testing } // namespace grpc - diff --git a/test/cpp/microbenchmarks/callback_test_service.h b/test/cpp/microbenchmarks/callback_test_service.h index 3c43ecb2215..aba5c0cfa67 100644 --- a/test/cpp/microbenchmarks/callback_test_service.h +++ b/test/cpp/microbenchmarks/callback_test_service.h @@ -1,12 +1,30 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + #ifndef TEST_CPP_MICROBENCHMARKS_CALLBACK_TEST_SERVICE_H #define TEST_CPP_MICROBENCHMARKS_CALLBACK_TEST_SERVICE_H -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/cpp/util/string_ref_helper.h" -#include +#include #include #include -#include +#include +#include "src/proto/grpc/testing/echo.grpc.pb.h" +#include "test/cpp/util/string_ref_helper.h" namespace grpc { namespace testing { @@ -22,18 +40,20 @@ class CallbackStreamingTestService EchoResponse* response, experimental::ServerCallbackRpcController* controller) override; - experimental::ServerBidiReactor* BidiStream() override; + experimental::ServerBidiReactor* BidiStream() + override; }; class BidiClient : public grpc::experimental::ClientBidiReactor { public: BidiClient(EchoTestService::Stub* stub, EchoRequest* request, - EchoResponse* response, ClientContext* context, int num_msgs_to_send) + EchoResponse* response, ClientContext* context, + int num_msgs_to_send) : request_{request}, response_{response}, context_{context}, - msgs_to_send_{num_msgs_to_send}{ + msgs_to_send_{num_msgs_to_send} { stub->experimental_async()->BidiStream(context_, this); MaybeWrite(); StartRead(response_); @@ -63,11 +83,11 @@ class BidiClient } void Await() { - std::unique_lock l(mu_); - while (!done_) { - cv_.wait(l); - } + std::unique_lock l(mu_); + while (!done_) { + cv_.wait(l); } + } private: void MaybeWrite() { @@ -89,7 +109,6 @@ class BidiClient bool done_ = false; }; - } // namespace testing } // namespace grpc #endif // TEST_CPP_MICROBENCHMARKS_CALLBACK_TEST_SERVICE_H diff --git a/test/cpp/microbenchmarks/callback_unary_ping_pong.h b/test/cpp/microbenchmarks/callback_unary_ping_pong.h index 7babb56287d..01477e6402d 100644 --- a/test/cpp/microbenchmarks/callback_unary_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_unary_ping_pong.h @@ -1,6 +1,6 @@ /* * - * Copyright 2016 gRPC authors. + * Copyright 2019 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,9 +25,9 @@ #include #include "src/core/lib/profiling/timers.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" +#include "test/cpp/microbenchmarks/callback_test_service.h" #include "test/cpp/microbenchmarks/fullstack_context_mutators.h" #include "test/cpp/microbenchmarks/fullstack_fixtures.h" -#include "test/cpp/microbenchmarks/callback_test_service.h" namespace grpc { namespace testing { @@ -63,12 +63,12 @@ static void BM_CallbackUnaryPingPong(benchmark::State& state) { std::condition_variable cv; bool done = false; stub_->experimental_async()->Echo(&cli_ctx, &request, &response, - [&done, &mu, &cv](Status s) { - GPR_ASSERT(s.ok()); - std::lock_guard l(mu); - done = true; - cv.notify_one(); - }); + [&done, &mu, &cv](Status s) { + GPR_ASSERT(s.ok()); + std::lock_guard l(mu); + done = true; + cv.notify_one(); + }); std::unique_lock l(mu); while (!done) { cv.wait(l); @@ -76,7 +76,8 @@ static void BM_CallbackUnaryPingPong(benchmark::State& state) { } fixture->Finish(state); fixture.reset(); - state.SetBytesProcessed(state.range(0) * state.iterations() + state.range(1) * state.iterations()); + state.SetBytesProcessed(state.range(0) * state.iterations() + + state.range(1) * state.iterations()); } } // namespace testing } // namespace grpc From 8f74abcd2d9eaf6ed35ef783346463fc4f1de73f Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 26 Apr 2019 14:54:44 -0700 Subject: [PATCH 0054/1555] Add script to run build tests of examples --- src/objective-c/tests/examples_build_test.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 src/objective-c/tests/examples_build_test.sh diff --git a/src/objective-c/tests/examples_build_test.sh b/src/objective-c/tests/examples_build_test.sh new file mode 100755 index 00000000000..7bf4d67d019 --- /dev/null +++ b/src/objective-c/tests/examples_build_test.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -ex + +SCHEME=HelloWorld EXAMPLE_PATH=examples/objective-c/helloworld ./build_one_example.sh +SCHEME=RouteGuideClient EXAMPLE_PATH=examples/objective-c/route_guide ./build_one_example.sh +SCHEME=AuthSample EXAMPLE_PATH=examples/objective-c/auth_sample ./build_one_example.sh From 9f3c78177f4e19d28027d06867493e09098ddaab Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 26 Apr 2019 15:40:53 -0700 Subject: [PATCH 0055/1555] Resolve final comments --- .../resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc | 6 +++--- .../resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc index c29fa44a353..e272e5a8800 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc @@ -77,7 +77,7 @@ class GrpcPolledFdLibuv : public GrpcPolledFd { return false; } - void ShutdownInternal(grpc_error* error) { + void ShutdownInternalLocked(grpc_error* error) { uv_poll_stop(handle_); uv_close(reinterpret_cast(handle_), ares_uv_poll_close_cb); if (read_closure_ != nullptr) { @@ -91,9 +91,9 @@ class GrpcPolledFdLibuv : public GrpcPolledFd { void ShutdownLocked(grpc_error* error) override { if (grpc_core::ExecCtx::Get() == nullptr) { grpc_core::ExecCtx exec_ctx; - ShutdownInternal(error); + ShutdownInternalLocked(error); } else { - ShutdownInternal(error); + ShutdownInternalLocked(error); } } diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc index 706bc659582..07906f282aa 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc @@ -37,7 +37,7 @@ bool inner_maybe_resolve_localhost_manually_locked( gpr_split_host_port(name, host, port); if (*host == nullptr) { gpr_log(GPR_ERROR, - "Failed to parse %s into host:port during Windows localhost " + "Failed to parse %s into host:port during manual localhost " "resolution check.", name); return false; @@ -45,7 +45,7 @@ bool inner_maybe_resolve_localhost_manually_locked( if (*port == nullptr) { if (default_port == nullptr) { gpr_log(GPR_ERROR, - "No port or default port for %s during Windows localhost " + "No port or default port for %s during manual localhost " "resolution check.", name); return false; From a7a380c69b61faa4d4f55d4f3fde668308c6bce3 Mon Sep 17 00:00:00 2001 From: Guantao Liu Date: Mon, 29 Apr 2019 15:09:07 -0700 Subject: [PATCH 0056/1555] Delay the creation of Alarm in the callback-based qps client. The alarm is only used in the fixed-load scenarios, but its construction is a major point of contention in both the closed-loop and fixed-load scenarios. Delay its creation to when it is going to be used, which will get rid of the contention in the closed-loop scenarios. --- test/cpp/qps/client_callback.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/cpp/qps/client_callback.cc b/test/cpp/qps/client_callback.cc index dcfa2dbf875..ac70894712e 100644 --- a/test/cpp/qps/client_callback.cc +++ b/test/cpp/qps/client_callback.cc @@ -43,13 +43,14 @@ namespace testing { * Maintains context info per RPC */ struct CallbackClientRpcContext { - CallbackClientRpcContext(BenchmarkService::Stub* stub) : stub_(stub) {} + CallbackClientRpcContext(BenchmarkService::Stub* stub) + : alarm_(nullptr), stub_(stub) {} ~CallbackClientRpcContext() {} SimpleResponse response_; ClientContext context_; - Alarm alarm_; + std::unique_ptr alarm_; BenchmarkService::Stub* stub_; }; @@ -169,7 +170,10 @@ class CallbackUnaryClient final : public CallbackClient { gpr_timespec next_issue_time = NextRPCIssueTime(); // Start an alarm callback to run the internal callback after // next_issue_time - ctx_[vector_idx]->alarm_.experimental().Set( + if (ctx_[vector_idx]->alarm_ == nullptr) { + ctx_[vector_idx]->alarm_.reset(new Alarm); + } + ctx_[vector_idx]->alarm_->experimental().Set( next_issue_time, [this, t, vector_idx](bool ok) { IssueUnaryCallbackRpc(t, vector_idx); }); @@ -313,7 +317,10 @@ class CallbackStreamingPingPongReactor final gpr_timespec next_issue_time = client_->NextRPCIssueTime(); // Start an alarm callback to run the internal callback after // next_issue_time - ctx_->alarm_.experimental().Set(next_issue_time, + if (ctx_->alarm_ == nullptr) { + ctx_->alarm_.reset(new Alarm); + } + ctx_->alarm_->experimental().Set(next_issue_time, [this](bool ok) { StartNewRpc(); }); } else { StartNewRpc(); From 3b5c470bf16ff61a551ef820df70a753d0545517 Mon Sep 17 00:00:00 2001 From: Guantao Liu Date: Mon, 29 Apr 2019 15:19:55 -0700 Subject: [PATCH 0057/1555] Clang format. --- test/cpp/qps/client_callback.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/qps/client_callback.cc b/test/cpp/qps/client_callback.cc index ac70894712e..e61e36c9ee1 100644 --- a/test/cpp/qps/client_callback.cc +++ b/test/cpp/qps/client_callback.cc @@ -321,7 +321,7 @@ class CallbackStreamingPingPongReactor final ctx_->alarm_.reset(new Alarm); } ctx_->alarm_->experimental().Set(next_issue_time, - [this](bool ok) { StartNewRpc(); }); + [this](bool ok) { StartNewRpc(); }); } else { StartNewRpc(); } From 333ba8feaea465e35678c356542915140605b444 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Thu, 25 Apr 2019 17:31:20 -0700 Subject: [PATCH 0058/1555] Use aligned_alloc directly for grpc_core::Arena --- include/grpc/impl/codegen/port_platform.h | 3 + include/grpc/support/alloc.h | 2 + src/core/lib/gpr/alloc.cc | 78 ++++++++++++++++++++--- src/core/lib/gpr/alloc.h | 8 +++ src/core/lib/gprpp/arena.h | 2 +- test/core/gpr/alloc_test.cc | 18 +++++- test/core/util/memory_counters.cc | 8 ++- 7 files changed, 105 insertions(+), 14 deletions(-) diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index d7294d59d41..ff759d2baed 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -77,6 +77,7 @@ #define GPR_WINDOWS 1 #define GPR_WINDOWS_SUBPROCESS 1 #define GPR_WINDOWS_ENV +#define GPR_HAS_ALIGNED_MALLOC 1 #ifdef __MSYS__ #define GPR_GETPID_IN_UNISTD_H 1 #define GPR_MSYS_TMPFILE @@ -173,6 +174,7 @@ #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 #define GPR_HAS_PTHREAD_H 1 +#define GPR_HAS_ALIGNED_ALLOC 1 #define GPR_GETPID_IN_UNISTD_H 1 #ifdef _LP64 #define GPR_ARCH_64 1 @@ -238,6 +240,7 @@ #define GPR_POSIX_SUBPROCESS 1 #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 +#define GPR_HAS_POSIX_MEMALIGN 1 #define GPR_HAS_PTHREAD_H 1 #define GPR_GETPID_IN_UNISTD_H 1 #ifndef GRPC_CFSTREAM diff --git a/include/grpc/support/alloc.h b/include/grpc/support/alloc.h index 8bd940bec47..4d8e007a577 100644 --- a/include/grpc/support/alloc.h +++ b/include/grpc/support/alloc.h @@ -32,6 +32,8 @@ typedef struct gpr_allocation_functions { void* (*zalloc_fn)(size_t size); /** if NULL, uses malloc_fn then memset */ void* (*realloc_fn)(void* ptr, size_t size); void (*free_fn)(void* ptr); + void* (*aligned_alloc_fn)(size_t size, size_t alignment); + void (*aligned_free_fn)(void* ptr); } gpr_allocation_functions; /** malloc. diff --git a/src/core/lib/gpr/alloc.cc b/src/core/lib/gpr/alloc.cc index 611e4cceee4..b601ad79f79 100644 --- a/src/core/lib/gpr/alloc.cc +++ b/src/core/lib/gpr/alloc.cc @@ -23,6 +23,7 @@ #include #include #include +#include "src/core/lib/gpr/alloc.h" #include "src/core/lib/profiling/timers.h" static void* zalloc_with_calloc(size_t sz) { return calloc(sz, 1); } @@ -33,8 +34,61 @@ static void* zalloc_with_gpr_malloc(size_t sz) { return p; } -static gpr_allocation_functions g_alloc_functions = {malloc, zalloc_with_calloc, - realloc, free}; +static constexpr bool is_power_of_two(size_t value) { + // 2^N = 100000...000 + // 2^N - 1 = 011111...111 + // (2^N) && ((2^N)-1)) = 0 + return (value & (value - 1)) == 0; +} + +static void* aligned_alloc_with_gpr_malloc(size_t size, size_t alignment) { + GPR_DEBUG_ASSERT(is_power_of_two(alignment)); + size_t extra = alignment - 1 + sizeof(void*); + void* p = gpr_malloc(size + extra); + void** ret = (void**)(((uintptr_t)p + extra) & ~(alignment - 1)); + ret[-1] = p; + return (void*)ret; +} + +static void aligned_free_with_gpr_malloc(void* ptr) { + gpr_free((static_cast(ptr))[-1]); +} + +static void* platform_malloc_aligned(size_t size, size_t alignment) { +#if defined(GPR_HAS_ALIGNED_ALLOC) + size = GPR_ROUND_UP_TO_SPECIFIED_SIZE(size, alignment); + void* ret = aligned_alloc(alignment, size); + GPR_ASSERT(ret != nullptr); + return ret; +#elif defined(GPR_HAS_ALIGNED_MALLOC) + GPR_DEBUG_ASSERT(is_power_of_two(alignment)); + void* ret = _aligned_malloc(size, alignment); + GPR_ASSERT(ret != nullptr); + return ret; +#elif defined(GPR_HAS_POSIX_MEMALIGN) + GPR_DEBUG_ASSERT(is_power_of_two(alignment)); + GPR_DEBUG_ASSERT(alignment % sizeof(void*) == 0); + void* ret = nullptr; + GPR_ASSERT(posix_memalign(&ret, alignment, size) == 0); + return ret; +#else + return aligned_alloc_with_gpr_malloc(size, alignment); +#endif +} + +static void platform_free_aligned(void* ptr) { +#if defined(GPR_HAS_ALIGNED_ALLOC) || defined(GPR_HAS_POSIX_MEMALIGN) + free(ptr); +#elif defined(GPR_HAS_ALIGNED_MALLOC) + _aligned_free(ptr); +#else + aligned_free_with_gpr_malloc(ptr); +#endif +} + +static gpr_allocation_functions g_alloc_functions = { + malloc, zalloc_with_calloc, realloc, + free, platform_malloc_aligned, platform_free_aligned}; gpr_allocation_functions gpr_get_allocation_functions() { return g_alloc_functions; @@ -47,6 +101,12 @@ void gpr_set_allocation_functions(gpr_allocation_functions functions) { if (functions.zalloc_fn == nullptr) { functions.zalloc_fn = zalloc_with_gpr_malloc; } + GPR_ASSERT((functions.aligned_alloc_fn == nullptr) == + (functions.aligned_free_fn == nullptr)); + if (functions.aligned_alloc_fn == nullptr) { + functions.aligned_alloc_fn = aligned_alloc_with_gpr_malloc; + functions.aligned_free_fn = aligned_free_with_gpr_malloc; + } g_alloc_functions = functions; } @@ -88,12 +148,12 @@ void* gpr_realloc(void* p, size_t size) { } void* gpr_malloc_aligned(size_t size, size_t alignment) { - GPR_ASSERT(((alignment - 1) & alignment) == 0); // Must be power of 2. - size_t extra = alignment - 1 + sizeof(void*); - void* p = gpr_malloc(size + extra); - void** ret = (void**)(((uintptr_t)p + extra) & ~(alignment - 1)); - ret[-1] = p; - return (void*)ret; + GPR_TIMER_SCOPE("gpr_malloc_aligned", 0); + if (size == 0) return nullptr; + return g_alloc_functions.aligned_alloc_fn(size, alignment); } -void gpr_free_aligned(void* ptr) { gpr_free((static_cast(ptr))[-1]); } +void gpr_free_aligned(void* ptr) { + GPR_TIMER_SCOPE("gpr_free_aligned", 0); + g_alloc_functions.aligned_free_fn(ptr); +} diff --git a/src/core/lib/gpr/alloc.h b/src/core/lib/gpr/alloc.h index 762b51bf663..2493c87514d 100644 --- a/src/core/lib/gpr/alloc.h +++ b/src/core/lib/gpr/alloc.h @@ -25,4 +25,12 @@ #define GPR_ROUND_UP_TO_ALIGNMENT_SIZE(x) \ (((x) + GPR_MAX_ALIGNMENT - 1u) & ~(GPR_MAX_ALIGNMENT - 1u)) +#define GPR_ROUND_UP_TO_CACHELINE_SIZE(x) \ + (((x) + GPR_CACHELINE_SIZE - 1u) & ~(GPR_CACHELINE_SIZE - 1u)) + +#define GPR_ROUND_UP_TO_SPECIFIED_SIZE(x, align) \ + (((x) + align - 1u) & ~(align - 1u)) + +void* gpr_malloc_cacheline(size_t size); + #endif /* GRPC_CORE_LIB_GPR_ALLOC_H */ diff --git a/src/core/lib/gprpp/arena.h b/src/core/lib/gprpp/arena.h index b1b0c4a85cb..915cd5c528e 100644 --- a/src/core/lib/gprpp/arena.h +++ b/src/core/lib/gprpp/arena.h @@ -61,7 +61,7 @@ class Arena { GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(Arena)); size = GPR_ROUND_UP_TO_ALIGNMENT_SIZE(size); size_t begin = total_used_.FetchAdd(size, MemoryOrder::RELAXED); - if (begin + size <= initial_zone_size_) { + if (GPR_LIKELY(begin + size <= initial_zone_size_)) { return reinterpret_cast(this) + base_size + begin; } else { return AllocZone(size); diff --git a/test/core/gpr/alloc_test.cc b/test/core/gpr/alloc_test.cc index 0b110e2b77d..fb6bc9a0bdd 100644 --- a/test/core/gpr/alloc_test.cc +++ b/test/core/gpr/alloc_test.cc @@ -31,12 +31,21 @@ static void fake_free(void* addr) { *(static_cast(addr)) = static_cast(0xdeadd00d); } +static void* fake_aligned_malloc(size_t size, size_t alignment) { + return (void*)(size + alignment); +} + +static void fake_aligned_free(void* addr) { + *(static_cast(addr)) = static_cast(0xcafef00d); +} + static void test_custom_allocs() { const gpr_allocation_functions default_fns = gpr_get_allocation_functions(); intptr_t addr_to_free = 0; char* i; - gpr_allocation_functions fns = {fake_malloc, nullptr, fake_realloc, - fake_free}; + gpr_allocation_functions fns = {fake_malloc, nullptr, + fake_realloc, fake_free, + fake_aligned_malloc, fake_aligned_free}; gpr_set_allocation_functions(fns); GPR_ASSERT((void*)(size_t)0xdeadbeef == gpr_malloc(0xdeadbeef)); @@ -45,6 +54,11 @@ static void test_custom_allocs() { gpr_free(&addr_to_free); GPR_ASSERT(addr_to_free == (intptr_t)0xdeadd00d); + GPR_ASSERT((void*)(size_t)(0xdeadbeef + 64) == + gpr_malloc_aligned(0xdeadbeef, 64)); + gpr_free_aligned(&addr_to_free); + GPR_ASSERT(addr_to_free == (intptr_t)0xcafef00d); + /* Restore and check we don't get funky values and that we don't leak */ gpr_set_allocation_functions(default_fns); GPR_ASSERT((void*)sizeof(*i) != diff --git a/test/core/util/memory_counters.cc b/test/core/util/memory_counters.cc index 787fb76e48b..11107f670fb 100644 --- a/test/core/util/memory_counters.cc +++ b/test/core/util/memory_counters.cc @@ -90,8 +90,12 @@ static void guard_free(void* vptr) { g_old_allocs.free_fn(ptr); } -struct gpr_allocation_functions g_guard_allocs = {guard_malloc, nullptr, - guard_realloc, guard_free}; +// NB: We do not specify guard_malloc_aligned/guard_free_aligned methods. Since +// they are null, calls to gpr_malloc_aligned/gpr_free_aligned are executed as a +// wrapper over gpr_malloc/gpr_free, which do use guard_malloc/guard_free, and +// thus there allocations are tracked as well. +struct gpr_allocation_functions g_guard_allocs = { + guard_malloc, nullptr, guard_realloc, guard_free, nullptr, nullptr}; void grpc_memory_counters_init() { memset(&g_memory_counters, 0, sizeof(g_memory_counters)); From a3fe7c0c908451deb04c3bb99a6b364b313467f6 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Mon, 29 Apr 2019 14:49:03 -0700 Subject: [PATCH 0059/1555] Renamed macros for memory alignment --- .../ext/filters/client_channel/subchannel.cc | 22 +++++----- src/core/lib/channel/channel_stack.cc | 43 ++++++++++--------- src/core/lib/gpr/alloc.cc | 2 +- src/core/lib/gpr/alloc.h | 14 +++--- src/core/lib/gprpp/arena.cc | 4 +- src/core/lib/gprpp/arena.h | 4 +- src/core/lib/surface/call.cc | 6 +-- src/core/lib/transport/transport.cc | 2 +- test/core/util/memory_counters.cc | 20 +++++---- 9 files changed, 61 insertions(+), 56 deletions(-) diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index a284e692b09..873db8ef57c 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -66,12 +66,13 @@ #define GRPC_SUBCHANNEL_RECONNECT_JITTER 0.2 // Conversion between subchannel call and call stack. -#define SUBCHANNEL_CALL_TO_CALL_STACK(call) \ - (grpc_call_stack*)((char*)(call) + \ - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(SubchannelCall))) -#define CALL_STACK_TO_SUBCHANNEL_CALL(callstack) \ - (SubchannelCall*)(((char*)(call_stack)) - \ - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(SubchannelCall))) +#define SUBCHANNEL_CALL_TO_CALL_STACK(call) \ + (grpc_call_stack*)((char*)(call) + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE( \ + sizeof(SubchannelCall))) +#define CALL_STACK_TO_SUBCHANNEL_CALL(callstack) \ + (SubchannelCall*)(((char*)(call_stack)) - \ + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE( \ + sizeof(SubchannelCall))) namespace grpc_core { @@ -151,10 +152,10 @@ RefCountedPtr ConnectedSubchannel::CreateCall( size_t ConnectedSubchannel::GetInitialCallSizeEstimate( size_t parent_data_size) const { size_t allocation_size = - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(SubchannelCall)); + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(sizeof(SubchannelCall)); if (parent_data_size > 0) { allocation_size += - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(channel_stack_->call_stack_size) + + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(channel_stack_->call_stack_size) + parent_data_size; } else { allocation_size += channel_stack_->call_stack_size; @@ -178,8 +179,9 @@ void SubchannelCall::StartTransportStreamOpBatch( void* SubchannelCall::GetParentData() { grpc_channel_stack* chanstk = connected_subchannel_->channel_stack(); - return (char*)this + GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(SubchannelCall)) + - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(chanstk->call_stack_size); + return (char*)this + + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(sizeof(SubchannelCall)) + + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(chanstk->call_stack_size); } grpc_call_stack* SubchannelCall::GetCallStack() { diff --git a/src/core/lib/channel/channel_stack.cc b/src/core/lib/channel/channel_stack.cc index df956c7176c..7dfabbb0a1c 100644 --- a/src/core/lib/channel/channel_stack.cc +++ b/src/core/lib/channel/channel_stack.cc @@ -47,9 +47,9 @@ grpc_core::TraceFlag grpc_trace_channel(false, "channel"); size_t grpc_channel_stack_size(const grpc_channel_filter** filters, size_t filter_count) { /* always need the header, and size for the channel elements */ - size_t size = GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_channel_stack)) + - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filter_count * - sizeof(grpc_channel_element)); + size_t size = GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(sizeof(grpc_channel_stack)) + + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE( + filter_count * sizeof(grpc_channel_element)); size_t i; GPR_ASSERT((GPR_MAX_ALIGNMENT & (GPR_MAX_ALIGNMENT - 1)) == 0 && @@ -57,18 +57,18 @@ size_t grpc_channel_stack_size(const grpc_channel_filter** filters, /* add the size for each filter */ for (i = 0; i < filter_count; i++) { - size += GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filters[i]->sizeof_channel_data); + size += GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(filters[i]->sizeof_channel_data); } return size; } -#define CHANNEL_ELEMS_FROM_STACK(stk) \ - ((grpc_channel_element*)((char*)(stk) + GPR_ROUND_UP_TO_ALIGNMENT_SIZE( \ +#define CHANNEL_ELEMS_FROM_STACK(stk) \ + ((grpc_channel_element*)((char*)(stk) + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE( \ sizeof(grpc_channel_stack)))) -#define CALL_ELEMS_FROM_STACK(stk) \ - ((grpc_call_element*)((char*)(stk) + GPR_ROUND_UP_TO_ALIGNMENT_SIZE( \ +#define CALL_ELEMS_FROM_STACK(stk) \ + ((grpc_call_element*)((char*)(stk) + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE( \ sizeof(grpc_call_stack)))) grpc_channel_element* grpc_channel_stack_element( @@ -92,8 +92,9 @@ grpc_error* grpc_channel_stack_init( const grpc_channel_args* channel_args, grpc_transport* optional_transport, const char* name, grpc_channel_stack* stack) { size_t call_size = - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call_stack)) + - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filter_count * sizeof(grpc_call_element)); + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(sizeof(grpc_call_stack)) + + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(filter_count * + sizeof(grpc_call_element)); grpc_channel_element* elems; grpc_channel_element_args args; char* user_data; @@ -104,8 +105,8 @@ grpc_error* grpc_channel_stack_init( name); elems = CHANNEL_ELEMS_FROM_STACK(stack); user_data = (reinterpret_cast(elems)) + - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filter_count * - sizeof(grpc_channel_element)); + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(filter_count * + sizeof(grpc_channel_element)); /* init per-filter data */ grpc_error* first_error = GRPC_ERROR_NONE; @@ -126,8 +127,9 @@ grpc_error* grpc_channel_stack_init( } } user_data += - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filters[i]->sizeof_channel_data); - call_size += GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filters[i]->sizeof_call_data); + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(filters[i]->sizeof_channel_data); + call_size += + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(filters[i]->sizeof_call_data); } GPR_ASSERT(user_data > (char*)stack); @@ -162,8 +164,9 @@ grpc_error* grpc_call_stack_init(grpc_channel_stack* channel_stack, GRPC_STREAM_REF_INIT(&elem_args->call_stack->refcount, initial_refs, destroy, destroy_arg, "CALL_STACK"); call_elems = CALL_ELEMS_FROM_STACK(elem_args->call_stack); - user_data = (reinterpret_cast(call_elems)) + - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(count * sizeof(grpc_call_element)); + user_data = + (reinterpret_cast(call_elems)) + + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(count * sizeof(grpc_call_element)); /* init per-filter data */ grpc_error* first_error = GRPC_ERROR_NONE; @@ -171,8 +174,8 @@ grpc_error* grpc_call_stack_init(grpc_channel_stack* channel_stack, call_elems[i].filter = channel_elems[i].filter; call_elems[i].channel_data = channel_elems[i].channel_data; call_elems[i].call_data = user_data; - user_data += - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(call_elems[i].filter->sizeof_call_data); + user_data += GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE( + call_elems[i].filter->sizeof_call_data); } for (size_t i = 0; i < count; i++) { grpc_error* error = @@ -242,11 +245,11 @@ grpc_channel_stack* grpc_channel_stack_from_top_element( grpc_channel_element* elem) { return reinterpret_cast( reinterpret_cast(elem) - - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_channel_stack))); + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(sizeof(grpc_channel_stack))); } grpc_call_stack* grpc_call_stack_from_top_element(grpc_call_element* elem) { return reinterpret_cast( reinterpret_cast(elem) - - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call_stack))); + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(sizeof(grpc_call_stack))); } diff --git a/src/core/lib/gpr/alloc.cc b/src/core/lib/gpr/alloc.cc index b601ad79f79..0d9f6f7120e 100644 --- a/src/core/lib/gpr/alloc.cc +++ b/src/core/lib/gpr/alloc.cc @@ -56,7 +56,7 @@ static void aligned_free_with_gpr_malloc(void* ptr) { static void* platform_malloc_aligned(size_t size, size_t alignment) { #if defined(GPR_HAS_ALIGNED_ALLOC) - size = GPR_ROUND_UP_TO_SPECIFIED_SIZE(size, alignment); + size = GPR_ROUND_UP_TO_ALIGNMENT_SIZE(size, alignment); void* ret = aligned_alloc(alignment, size); GPR_ASSERT(ret != nullptr); return ret; diff --git a/src/core/lib/gpr/alloc.h b/src/core/lib/gpr/alloc.h index 2493c87514d..c77fbeaca49 100644 --- a/src/core/lib/gpr/alloc.h +++ b/src/core/lib/gpr/alloc.h @@ -22,15 +22,13 @@ #include /// Given a size, round up to the next multiple of sizeof(void*). -#define GPR_ROUND_UP_TO_ALIGNMENT_SIZE(x) \ - (((x) + GPR_MAX_ALIGNMENT - 1u) & ~(GPR_MAX_ALIGNMENT - 1u)) +#define GPR_ROUND_UP_TO_ALIGNMENT_SIZE(x, align) \ + (((x) + (align)-1u) & ~((align)-1u)) + +#define GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(x) \ + GPR_ROUND_UP_TO_ALIGNMENT_SIZE((x), GPR_MAX_ALIGNMENT) #define GPR_ROUND_UP_TO_CACHELINE_SIZE(x) \ - (((x) + GPR_CACHELINE_SIZE - 1u) & ~(GPR_CACHELINE_SIZE - 1u)) - -#define GPR_ROUND_UP_TO_SPECIFIED_SIZE(x, align) \ - (((x) + align - 1u) & ~(align - 1u)) - -void* gpr_malloc_cacheline(size_t size); + GPR_ROUND_UP_TO_ALIGNMENT_SIZE((x), GPR_CACHELINE_SIZE) #endif /* GRPC_CORE_LIB_GPR_ALLOC_H */ diff --git a/src/core/lib/gprpp/arena.cc b/src/core/lib/gprpp/arena.cc index 5c344db4e35..e1c7b292f8c 100644 --- a/src/core/lib/gprpp/arena.cc +++ b/src/core/lib/gprpp/arena.cc @@ -67,7 +67,7 @@ Arena* Arena::Create(size_t initial_size) { Pair Arena::CreateWithAlloc(size_t initial_size, size_t alloc_size) { static constexpr size_t base_size = - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(Arena)); + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(sizeof(Arena)); auto* new_arena = new (ArenaStorage(initial_size)) Arena(initial_size, alloc_size); void* first_alloc = reinterpret_cast(new_arena) + base_size; @@ -88,7 +88,7 @@ void* Arena::AllocZone(size_t size) { // sizing hysteresis (that is, most calls should have a large enough initial // zone and will not need to grow the arena). static constexpr size_t zone_base_size = - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(Zone)); + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(sizeof(Zone)); size_t alloc_size = zone_base_size + size; Zone* z = new (gpr_malloc_aligned(alloc_size, GPR_MAX_ALIGNMENT)) Zone(); { diff --git a/src/core/lib/gprpp/arena.h b/src/core/lib/gprpp/arena.h index 915cd5c528e..6c646c5871d 100644 --- a/src/core/lib/gprpp/arena.h +++ b/src/core/lib/gprpp/arena.h @@ -58,8 +58,8 @@ class Arena { // Allocate \a size bytes from the arena. void* Alloc(size_t size) { static constexpr size_t base_size = - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(Arena)); - size = GPR_ROUND_UP_TO_ALIGNMENT_SIZE(size); + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(sizeof(Arena)); + size = GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(size); size_t begin = total_used_.FetchAdd(size, MemoryOrder::RELAXED); if (GPR_LIKELY(begin + size <= initial_zone_size_)) { return reinterpret_cast(this) + base_size + begin; diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index bd140021c96..0a26872a9ea 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -260,10 +260,10 @@ grpc_core::TraceFlag grpc_compression_trace(false, "compression"); #define CALL_STACK_FROM_CALL(call) \ (grpc_call_stack*)((char*)(call) + \ - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call))) + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(sizeof(grpc_call))) #define CALL_FROM_CALL_STACK(call_stack) \ (grpc_call*)(((char*)(call_stack)) - \ - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call))) + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(sizeof(grpc_call))) #define CALL_ELEM_FROM_CALL(call, idx) \ grpc_call_stack_element(CALL_STACK_FROM_CALL(call), idx) @@ -329,7 +329,7 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args, size_t initial_size = grpc_channel_get_call_size_estimate(args->channel); GRPC_STATS_INC_CALL_INITIAL_SIZE(initial_size); size_t call_and_stack_size = - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call)) + + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(sizeof(grpc_call)) + channel_stack->call_stack_size; size_t call_alloc_size = call_and_stack_size + (args->parent ? sizeof(child_call) : 0); diff --git a/src/core/lib/transport/transport.cc b/src/core/lib/transport/transport.cc index 29c1e561891..40870657b84 100644 --- a/src/core/lib/transport/transport.cc +++ b/src/core/lib/transport/transport.cc @@ -115,7 +115,7 @@ void grpc_transport_move_stats(grpc_transport_stream_stats* from, } size_t grpc_transport_stream_size(grpc_transport* transport) { - return GPR_ROUND_UP_TO_ALIGNMENT_SIZE(transport->vtable->sizeof_stream); + return GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(transport->vtable->sizeof_stream); } void grpc_transport_destroy(grpc_transport* transport) { diff --git a/test/core/util/memory_counters.cc b/test/core/util/memory_counters.cc index 11107f670fb..60d22b18309 100644 --- a/test/core/util/memory_counters.cc +++ b/test/core/util/memory_counters.cc @@ -54,9 +54,10 @@ static void* guard_malloc(size_t size) { NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_absolute, (gpr_atm)1); NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_relative, (gpr_atm)1); void* ptr = g_old_allocs.malloc_fn( - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(size)) + size); + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(sizeof(size)) + size); *static_cast(ptr) = size; - return static_cast(ptr) + GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(size)); + return static_cast(ptr) + + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(sizeof(size)); } static void* guard_realloc(void* vptr, size_t size) { @@ -67,23 +68,24 @@ static void* guard_realloc(void* vptr, size_t size) { guard_free(vptr); return nullptr; } - void* ptr = - static_cast(vptr) - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(size)); + void* ptr = static_cast(vptr) - + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(sizeof(size)); NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_absolute, (gpr_atm)size); NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, -*static_cast(ptr)); NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, (gpr_atm)size); NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_absolute, (gpr_atm)1); ptr = g_old_allocs.realloc_fn( - ptr, GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(size)) + size); + ptr, GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(sizeof(size)) + size); *static_cast(ptr) = size; - return static_cast(ptr) + GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(size)); + return static_cast(ptr) + + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(sizeof(size)); } static void guard_free(void* vptr) { if (vptr == nullptr) return; - void* ptr = - static_cast(vptr) - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(size_t)); + void* ptr = static_cast(vptr) - + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(sizeof(size_t)); NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, -*static_cast(ptr)); NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_relative, -(gpr_atm)1); @@ -93,7 +95,7 @@ static void guard_free(void* vptr) { // NB: We do not specify guard_malloc_aligned/guard_free_aligned methods. Since // they are null, calls to gpr_malloc_aligned/gpr_free_aligned are executed as a // wrapper over gpr_malloc/gpr_free, which do use guard_malloc/guard_free, and -// thus there allocations are tracked as well. +// thus their allocations are tracked as well. struct gpr_allocation_functions g_guard_allocs = { guard_malloc, nullptr, guard_realloc, guard_free, nullptr, nullptr}; From e1a96b83471e229909890ebd9f9b7cf3d8d1edec Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Mon, 29 Apr 2019 15:20:31 -0700 Subject: [PATCH 0060/1555] Fixed non-debug build warning --- src/core/lib/gpr/alloc.cc | 2 ++ src/core/lib/gprpp/arena.cc | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/lib/gpr/alloc.cc b/src/core/lib/gpr/alloc.cc index 0d9f6f7120e..b12b7d8534d 100644 --- a/src/core/lib/gpr/alloc.cc +++ b/src/core/lib/gpr/alloc.cc @@ -34,12 +34,14 @@ static void* zalloc_with_gpr_malloc(size_t sz) { return p; } +#ifndef NDEBUG static constexpr bool is_power_of_two(size_t value) { // 2^N = 100000...000 // 2^N - 1 = 011111...111 // (2^N) && ((2^N)-1)) = 0 return (value & (value - 1)) == 0; } +#endif static void* aligned_alloc_with_gpr_malloc(size_t size, size_t alignment) { GPR_DEBUG_ASSERT(is_power_of_two(alignment)); diff --git a/src/core/lib/gprpp/arena.cc b/src/core/lib/gprpp/arena.cc index e1c7b292f8c..2623ae870a1 100644 --- a/src/core/lib/gprpp/arena.cc +++ b/src/core/lib/gprpp/arena.cc @@ -35,8 +35,8 @@ namespace { void* ArenaStorage(size_t initial_size) { static constexpr size_t base_size = - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_core::Arena)); - initial_size = GPR_ROUND_UP_TO_ALIGNMENT_SIZE(initial_size); + GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(sizeof(grpc_core::Arena)); + initial_size = GPR_ROUND_UP_TO_MAX_ALIGNMENT_SIZE(initial_size); size_t alloc_size = base_size + initial_size; static constexpr size_t alignment = (GPR_CACHELINE_SIZE > GPR_MAX_ALIGNMENT && From aafa4c48e5a07d87c5df9b6c0e1a92df6fd8dbd2 Mon Sep 17 00:00:00 2001 From: Guantao Liu Date: Mon, 29 Apr 2019 16:10:53 -0700 Subject: [PATCH 0061/1555] Fix another call of Alarm::experimental()::Set. --- test/cpp/qps/client_callback.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/cpp/qps/client_callback.cc b/test/cpp/qps/client_callback.cc index e61e36c9ee1..ade23e13a72 100644 --- a/test/cpp/qps/client_callback.cc +++ b/test/cpp/qps/client_callback.cc @@ -293,7 +293,10 @@ class CallbackStreamingPingPongReactor final gpr_timespec next_issue_time = client_->NextRPCIssueTime(); // Start an alarm callback to run the internal callback after // next_issue_time - ctx_->alarm_.experimental().Set(next_issue_time, [this](bool ok) { + if (ctx_->alarm_ == nullptr) { + ctx_->alarm_.reset(new Alarm); + } + ctx_->alarm_->experimental().Set(next_issue_time, [this](bool ok) { write_time_ = UsageTimer::Now(); StartWrite(client_->request()); }); From 7d55a8a904010cdb2b03fb1edddf8522ad5e9f69 Mon Sep 17 00:00:00 2001 From: Yusuke Sato Date: Tue, 30 Apr 2019 15:24:50 +0900 Subject: [PATCH 0062/1555] Fix a typo in the GRPC::RpcServer constructor description --- src/ruby/lib/grpc/generic/rpc_server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ruby/lib/grpc/generic/rpc_server.rb b/src/ruby/lib/grpc/generic/rpc_server.rb index 3d34419643e..a566afa0bc2 100644 --- a/src/ruby/lib/grpc/generic/rpc_server.rb +++ b/src/ruby/lib/grpc/generic/rpc_server.rb @@ -210,7 +210,7 @@ module GRPC # A server arguments hash to be passed down to the underlying core server # # * interceptors: - # Am array of GRPC::ServerInterceptor objects that will be used for + # An array of GRPC::ServerInterceptor objects that will be used for # intercepting server handlers to provide extra functionality. # Interceptors are an EXPERIMENTAL API. # From 9073d6d5b56ccd1f4bbb836dbd0c9ae77386cfa7 Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 30 Apr 2019 00:26:57 -0700 Subject: [PATCH 0063/1555] Migrate interceptor types for server-side interceptors --- .../Interceptors/ClientInterceptorContext.cs | 0 .../Interceptors/Interceptor.cs | 0 src/csharp/Grpc.Core/ForwardedTypes.cs | 10 ++++++---- 3 files changed, 6 insertions(+), 4 deletions(-) rename src/csharp/{Grpc.Core => Grpc.Core.Api}/Interceptors/ClientInterceptorContext.cs (100%) rename src/csharp/{Grpc.Core => Grpc.Core.Api}/Interceptors/Interceptor.cs (100%) diff --git a/src/csharp/Grpc.Core/Interceptors/ClientInterceptorContext.cs b/src/csharp/Grpc.Core.Api/Interceptors/ClientInterceptorContext.cs similarity index 100% rename from src/csharp/Grpc.Core/Interceptors/ClientInterceptorContext.cs rename to src/csharp/Grpc.Core.Api/Interceptors/ClientInterceptorContext.cs diff --git a/src/csharp/Grpc.Core/Interceptors/Interceptor.cs b/src/csharp/Grpc.Core.Api/Interceptors/Interceptor.cs similarity index 100% rename from src/csharp/Grpc.Core/Interceptors/Interceptor.cs rename to src/csharp/Grpc.Core.Api/Interceptors/Interceptor.cs diff --git a/src/csharp/Grpc.Core/ForwardedTypes.cs b/src/csharp/Grpc.Core/ForwardedTypes.cs index 3df44d167be..8b42cae3890 100644 --- a/src/csharp/Grpc.Core/ForwardedTypes.cs +++ b/src/csharp/Grpc.Core/ForwardedTypes.cs @@ -32,16 +32,18 @@ using Grpc.Core.Utils; [assembly:TypeForwardedToAttribute(typeof(AuthContext))] [assembly:TypeForwardedToAttribute(typeof(AsyncAuthInterceptor))] [assembly:TypeForwardedToAttribute(typeof(AuthInterceptorContext))] -[assembly: TypeForwardedToAttribute(typeof(CallCredentials))] -[assembly: TypeForwardedToAttribute(typeof(CallFlags))] -[assembly: TypeForwardedToAttribute(typeof(CallInvoker))] -[assembly: TypeForwardedToAttribute(typeof(CallOptions))] +[assembly:TypeForwardedToAttribute(typeof(CallCredentials))] +[assembly:TypeForwardedToAttribute(typeof(CallFlags))] +[assembly:TypeForwardedToAttribute(typeof(CallInvoker))] +[assembly:TypeForwardedToAttribute(typeof(CallOptions))] +[assembly:TypeForwardedToAttribute(typeof(ClientInterceptorContext<,>))] [assembly:TypeForwardedToAttribute(typeof(ContextPropagationOptions))] [assembly:TypeForwardedToAttribute(typeof(ContextPropagationToken))] [assembly:TypeForwardedToAttribute(typeof(DeserializationContext))] [assembly:TypeForwardedToAttribute(typeof(IAsyncStreamReader<>))] [assembly:TypeForwardedToAttribute(typeof(IAsyncStreamWriter<>))] [assembly:TypeForwardedToAttribute(typeof(IClientStreamWriter<>))] +[assembly:TypeForwardedToAttribute(typeof(Interceptor))] [assembly:TypeForwardedToAttribute(typeof(IServerStreamWriter<>))] [assembly:TypeForwardedToAttribute(typeof(Marshaller<>))] [assembly:TypeForwardedToAttribute(typeof(Marshallers))] From f52a743e34f68de26d681eb7b6d3436d72b96645 Mon Sep 17 00:00:00 2001 From: = Date: Tue, 30 Apr 2019 01:43:23 -0700 Subject: [PATCH 0064/1555] Missed using --- src/csharp/Grpc.Core/ForwardedTypes.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/csharp/Grpc.Core/ForwardedTypes.cs b/src/csharp/Grpc.Core/ForwardedTypes.cs index 8b42cae3890..ab5f5a87c67 100644 --- a/src/csharp/Grpc.Core/ForwardedTypes.cs +++ b/src/csharp/Grpc.Core/ForwardedTypes.cs @@ -18,6 +18,7 @@ using System.Runtime.CompilerServices; using Grpc.Core; +using Grpc.Core.Interceptors; using Grpc.Core.Internal; using Grpc.Core.Utils; From 99533ab52b30e4055eb6ee034a8de81f7cb863a8 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 25 Apr 2019 16:40:49 -0700 Subject: [PATCH 0065/1555] Reorganize ObjC tests --- src/objective-c/tests/APIv2Tests/Info.plist | 22 - src/objective-c/tests/ChannelTests/Info.plist | 22 - .../tests/CoreCronetEnd2EndTests/Info.plist | 24 - .../CoreCronetEnd2EndTests.mm | 0 .../CronetUnitTests.mm} | 4 +- .../InteropTestsRemoteWithCronet.m | 0 .../tests/CronetUnitTests/Info.plist | 24 - .../tests/{ => InteropTests}/InteropTests.h | 0 .../tests/{ => InteropTests}/InteropTests.m | 77 +- .../InteropTests/InteropTestsBlockCallbacks.h | 33 + .../InteropTests/InteropTestsBlockCallbacks.m | 80 + .../InteropTestsLocalCleartext.m | 0 .../{ => InteropTests}/InteropTestsLocalSSL.m | 0 .../InteropTestsMultipleChannels.m | 268 ++ .../{ => InteropTests}/InteropTestsRemote.m | 0 .../tests/InteropTestsCallOptions/Info.plist | 22 - .../InteropTestsCallOptions.m | 116 - .../InteropTestsMultipleChannels/Info.plist | 22 - .../InteropTestsMultipleChannels.m | 259 -- .../InteropTestsRemoteWithCronet/Info.plist | 24 - src/objective-c/tests/Podfile | 91 +- src/objective-c/tests/Tests.m | 25 - .../tests/Tests.xcodeproj/project.pbxproj | 3510 ++--------------- .../xcshareddata/xcschemes/AllTests.xcscheme | 110 - .../xcschemes/ChannelTests.xcscheme | 90 - .../xcschemes/CoreCronetEnd2EndTests.xcscheme | 101 - .../CoreCronetEnd2EndTests_Asan.xcscheme | 60 - .../CoreCronetEnd2EndTests_Tsan.xcscheme | 59 - ...Iv2Tests.xcscheme => CronetTests.xcscheme} | 30 +- .../xcschemes/CronetUnitTests.xcscheme | 56 - ...sRemote.xcscheme => InteropTests.xcscheme} | 46 +- .../InteropTestsCallOptions.xcscheme | 56 - .../InteropTestsLocalCleartext.xcscheme | 95 - ...nteropTestsLocalCleartextCFStream.xcscheme | 63 - .../xcschemes/InteropTestsLocalSSL.xcscheme | 95 - .../InteropTestsLocalSSLCFStream.xcscheme | 63 - .../InteropTestsMultipleChannels.xcscheme | 56 - .../InteropTestsRemoteCFStream.xcscheme | 61 - .../InteropTestsRemoteWithCronet.xcscheme | 104 - .../xcshareddata/xcschemes/MacTests.xcscheme | 2 +- .../xcschemes/RxLibraryUnitTests.xcscheme | 90 - .../xcshareddata/xcschemes/Tests.xcscheme | 80 - .../xcshareddata/xcschemes/UnitTests.xcscheme | 6 +- .../{APIv2Tests => UnitTests}/APIv2Tests.m | 0 .../ChannelPoolTest.m | 0 .../ChannelTests.m | 0 .../tests/{ => UnitTests}/GRPCClientTests.m | 2 +- src/objective-c/tests/UnitTests/Info.plist | 22 - .../{UnitTests.m => NSErrorUnitTests.m} | 4 +- .../{ => UnitTests}/RxLibraryUnitTests.m | 0 src/objective-c/tests/run_tests.sh | 130 +- 51 files changed, 860 insertions(+), 5244 deletions(-) delete mode 100644 src/objective-c/tests/APIv2Tests/Info.plist delete mode 100644 src/objective-c/tests/ChannelTests/Info.plist delete mode 100644 src/objective-c/tests/CoreCronetEnd2EndTests/Info.plist rename src/objective-c/tests/{CoreCronetEnd2EndTests => CronetTests}/CoreCronetEnd2EndTests.mm (100%) rename src/objective-c/tests/{CronetUnitTests/CronetUnitTests.m => CronetTests/CronetUnitTests.mm} (99%) rename src/objective-c/tests/{InteropTestsRemoteWithCronet => CronetTests}/InteropTestsRemoteWithCronet.m (100%) delete mode 100644 src/objective-c/tests/CronetUnitTests/Info.plist rename src/objective-c/tests/{ => InteropTests}/InteropTests.h (100%) rename src/objective-c/tests/{ => InteropTests}/InteropTests.m (94%) create mode 100644 src/objective-c/tests/InteropTests/InteropTestsBlockCallbacks.h create mode 100644 src/objective-c/tests/InteropTests/InteropTestsBlockCallbacks.m rename src/objective-c/tests/{ => InteropTests}/InteropTestsLocalCleartext.m (100%) rename src/objective-c/tests/{ => InteropTests}/InteropTestsLocalSSL.m (100%) create mode 100644 src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m rename src/objective-c/tests/{ => InteropTests}/InteropTestsRemote.m (100%) delete mode 100644 src/objective-c/tests/InteropTestsCallOptions/Info.plist delete mode 100644 src/objective-c/tests/InteropTestsCallOptions/InteropTestsCallOptions.m delete mode 100644 src/objective-c/tests/InteropTestsMultipleChannels/Info.plist delete mode 100644 src/objective-c/tests/InteropTestsMultipleChannels/InteropTestsMultipleChannels.m delete mode 100644 src/objective-c/tests/InteropTestsRemoteWithCronet/Info.plist delete mode 100644 src/objective-c/tests/Tests.m delete mode 100644 src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/AllTests.xcscheme delete mode 100644 src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/ChannelTests.xcscheme delete mode 100644 src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CoreCronetEnd2EndTests.xcscheme delete mode 100644 src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CoreCronetEnd2EndTests_Asan.xcscheme delete mode 100644 src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CoreCronetEnd2EndTests_Tsan.xcscheme rename src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/{APIv2Tests.xcscheme => CronetTests.xcscheme} (77%) delete mode 100644 src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CronetUnitTests.xcscheme rename src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/{InteropTestsRemote.xcscheme => InteropTests.xcscheme} (75%) delete mode 100644 src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsCallOptions.xcscheme delete mode 100644 src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartext.xcscheme delete mode 100644 src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartextCFStream.xcscheme delete mode 100644 src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalSSL.xcscheme delete mode 100644 src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalSSLCFStream.xcscheme delete mode 100644 src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsMultipleChannels.xcscheme delete mode 100644 src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemoteCFStream.xcscheme delete mode 100644 src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemoteWithCronet.xcscheme delete mode 100644 src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/RxLibraryUnitTests.xcscheme delete mode 100644 src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/Tests.xcscheme rename src/objective-c/tests/{APIv2Tests => UnitTests}/APIv2Tests.m (100%) rename src/objective-c/tests/{ChannelTests => UnitTests}/ChannelPoolTest.m (100%) rename src/objective-c/tests/{ChannelTests => UnitTests}/ChannelTests.m (100%) rename src/objective-c/tests/{ => UnitTests}/GRPCClientTests.m (99%) delete mode 100644 src/objective-c/tests/UnitTests/Info.plist rename src/objective-c/tests/UnitTests/{UnitTests.m => NSErrorUnitTests.m} (96%) rename src/objective-c/tests/{ => UnitTests}/RxLibraryUnitTests.m (100%) diff --git a/src/objective-c/tests/APIv2Tests/Info.plist b/src/objective-c/tests/APIv2Tests/Info.plist deleted file mode 100644 index 6c40a6cd0c4..00000000000 --- a/src/objective-c/tests/APIv2Tests/Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - - diff --git a/src/objective-c/tests/ChannelTests/Info.plist b/src/objective-c/tests/ChannelTests/Info.plist deleted file mode 100644 index 6c40a6cd0c4..00000000000 --- a/src/objective-c/tests/ChannelTests/Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - - diff --git a/src/objective-c/tests/CoreCronetEnd2EndTests/Info.plist b/src/objective-c/tests/CoreCronetEnd2EndTests/Info.plist deleted file mode 100644 index fbeeb96ba6c..00000000000 --- a/src/objective-c/tests/CoreCronetEnd2EndTests/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - gRPC.$(PRODUCT_NAME:rfc1034identifier) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - - diff --git a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm similarity index 100% rename from src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm rename to src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm diff --git a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m b/src/objective-c/tests/CronetTests/CronetUnitTests.mm similarity index 99% rename from src/objective-c/tests/CronetUnitTests/CronetUnitTests.m rename to src/objective-c/tests/CronetTests/CronetUnitTests.mm index d732bc6ba99..2a861032caf 100644 --- a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m +++ b/src/objective-c/tests/CronetTests/CronetUnitTests.mm @@ -37,9 +37,9 @@ #import "test/core/end2end/data/ssl_test_data.h" #import "test/core/util/test_config.h" +#define GRPC_SHADOW_BORINGSSL_SYMBOLS #import "src/core/tsi/grpc_shadow_boringssl.h" - -#import +#import " static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; diff --git a/src/objective-c/tests/InteropTestsRemoteWithCronet/InteropTestsRemoteWithCronet.m b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m similarity index 100% rename from src/objective-c/tests/InteropTestsRemoteWithCronet/InteropTestsRemoteWithCronet.m rename to src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m diff --git a/src/objective-c/tests/CronetUnitTests/Info.plist b/src/objective-c/tests/CronetUnitTests/Info.plist deleted file mode 100644 index ba72822e872..00000000000 --- a/src/objective-c/tests/CronetUnitTests/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - - diff --git a/src/objective-c/tests/InteropTests.h b/src/objective-c/tests/InteropTests/InteropTests.h similarity index 100% rename from src/objective-c/tests/InteropTests.h rename to src/objective-c/tests/InteropTests/InteropTests.h diff --git a/src/objective-c/tests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m similarity index 94% rename from src/objective-c/tests/InteropTests.m rename to src/objective-c/tests/InteropTests/InteropTests.m index aab38e3a594..164d571d125 100644 --- a/src/objective-c/tests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -36,6 +36,8 @@ #import #import +#import "InteropTestsBlockCallbacks.h" + #define TEST_TIMEOUT 32 extern const char *kCFStreamVarName; @@ -76,81 +78,6 @@ BOOL isRemoteInteropTest(NSString *host) { return [host isEqualToString:@"grpc-test.sandbox.googleapis.com"]; } -// Convenience class to use blocks as callbacks -@interface InteropTestsBlockCallbacks : NSObject - -- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback - messageCallback:(void (^)(id))messageCallback - closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback - writeMessageCallback:(void (^)(void))writeMessageCallback; - -- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback - messageCallback:(void (^)(id))messageCallback - closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback; - -@end - -@implementation InteropTestsBlockCallbacks { - void (^_initialMetadataCallback)(NSDictionary *); - void (^_messageCallback)(id); - void (^_closeCallback)(NSDictionary *, NSError *); - void (^_writeMessageCallback)(void); - dispatch_queue_t _dispatchQueue; -} - -- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback - messageCallback:(void (^)(id))messageCallback - closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback - writeMessageCallback:(void (^)(void))writeMessageCallback { - if ((self = [super init])) { - _initialMetadataCallback = initialMetadataCallback; - _messageCallback = messageCallback; - _closeCallback = closeCallback; - _writeMessageCallback = writeMessageCallback; - _dispatchQueue = dispatch_queue_create(nil, DISPATCH_QUEUE_SERIAL); - } - return self; -} - -- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback - messageCallback:(void (^)(id))messageCallback - closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback { - return [self initWithInitialMetadataCallback:initialMetadataCallback - messageCallback:messageCallback - closeCallback:closeCallback - writeMessageCallback:nil]; -} - -- (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata { - if (_initialMetadataCallback) { - _initialMetadataCallback(initialMetadata); - } -} - -- (void)didReceiveProtoMessage:(GPBMessage *)message { - if (_messageCallback) { - _messageCallback(message); - } -} - -- (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { - if (_closeCallback) { - _closeCallback(trailingMetadata, error); - } -} - -- (void)didWriteMessage { - if (_writeMessageCallback) { - _writeMessageCallback(); - } -} - -- (dispatch_queue_t)dispatchQueue { - return _dispatchQueue; -} - -@end - #pragma mark Tests @implementation InteropTests { diff --git a/src/objective-c/tests/InteropTests/InteropTestsBlockCallbacks.h b/src/objective-c/tests/InteropTests/InteropTestsBlockCallbacks.h new file mode 100644 index 00000000000..fa0b8361b65 --- /dev/null +++ b/src/objective-c/tests/InteropTests/InteropTestsBlockCallbacks.h @@ -0,0 +1,33 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import + +// Convenience class to use blocks as callbacks +@interface InteropTestsBlockCallbacks : NSObject + +- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback + messageCallback:(void (^)(id))messageCallback + closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback + writeMessageCallback:(void (^)(void))writeMessageCallback; + +- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback + messageCallback:(void (^)(id))messageCallback + closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback; + +@end diff --git a/src/objective-c/tests/InteropTests/InteropTestsBlockCallbacks.m b/src/objective-c/tests/InteropTests/InteropTestsBlockCallbacks.m new file mode 100644 index 00000000000..1ab1fa995a6 --- /dev/null +++ b/src/objective-c/tests/InteropTests/InteropTestsBlockCallbacks.m @@ -0,0 +1,80 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "InteropTestsBlockCallbacks.h" + +@implementation InteropTestsBlockCallbacks { + void (^_initialMetadataCallback)(NSDictionary *); + void (^_messageCallback)(id); + void (^_closeCallback)(NSDictionary *, NSError *); + void (^_writeMessageCallback)(void); + dispatch_queue_t _dispatchQueue; +} + +- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback + messageCallback:(void (^)(id))messageCallback + closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback + writeMessageCallback:(void (^)(void))writeMessageCallback { + if ((self = [super init])) { + _initialMetadataCallback = initialMetadataCallback; + _messageCallback = messageCallback; + _closeCallback = closeCallback; + _writeMessageCallback = writeMessageCallback; + _dispatchQueue = dispatch_queue_create(nil, DISPATCH_QUEUE_SERIAL); + } + return self; +} + +- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback + messageCallback:(void (^)(id))messageCallback + closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback { + return [self initWithInitialMetadataCallback:initialMetadataCallback + messageCallback:messageCallback + closeCallback:closeCallback + writeMessageCallback:nil]; +} + +- (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata { + if (_initialMetadataCallback) { + _initialMetadataCallback(initialMetadata); + } +} + +- (void)didReceiveProtoMessage:(GPBMessage *)message { + if (_messageCallback) { + _messageCallback(message); + } +} + +- (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { + if (_closeCallback) { + _closeCallback(trailingMetadata, error); + } +} + +- (void)didWriteMessage { + if (_writeMessageCallback) { + _writeMessageCallback(); + } +} + +- (dispatch_queue_t)dispatchQueue { + return _dispatchQueue; +} + +@end diff --git a/src/objective-c/tests/InteropTestsLocalCleartext.m b/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m similarity index 100% rename from src/objective-c/tests/InteropTestsLocalCleartext.m rename to src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m diff --git a/src/objective-c/tests/InteropTestsLocalSSL.m b/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m similarity index 100% rename from src/objective-c/tests/InteropTestsLocalSSL.m rename to src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m diff --git a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m new file mode 100644 index 00000000000..c0beb107fad --- /dev/null +++ b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m @@ -0,0 +1,268 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import + +#ifdef GRPC_COMPILE_WITH_CRONET +#import +#endif +#import +#import +#import +#import + +#import "InteropTestsBlockCallbacks.h" + +#define NSStringize_helper(x) #x +#define NSStringize(x) @NSStringize_helper(x) +static NSString *const kRemoteSSLHost = NSStringize(HOST_PORT_REMOTE); +static NSString *const kLocalSSLHost = NSStringize(HOST_PORT_LOCALSSL); +static NSString *const kLocalCleartextHost = NSStringize(HOST_PORT_LOCAL); + +static const NSTimeInterval TEST_TIMEOUT = 8000; + +@interface RMTStreamingOutputCallRequest (Constructors) ++ (instancetype)messageWithPayloadSize:(NSNumber *)payloadSize + requestedResponseSize:(NSNumber *)responseSize; +@end + +@implementation RMTStreamingOutputCallRequest (Constructors) ++ (instancetype)messageWithPayloadSize:(NSNumber *)payloadSize + requestedResponseSize:(NSNumber *)responseSize { + RMTStreamingOutputCallRequest *request = [self message]; + RMTResponseParameters *parameters = [RMTResponseParameters message]; + parameters.size = responseSize.intValue; + [request.responseParametersArray addObject:parameters]; + request.payload.body = [NSMutableData dataWithLength:payloadSize.unsignedIntegerValue]; + return request; +} +@end + +@interface RMTStreamingOutputCallResponse (Constructors) ++ (instancetype)messageWithPayloadSize:(NSNumber *)payloadSize; +@end + +@implementation RMTStreamingOutputCallResponse (Constructors) ++ (instancetype)messageWithPayloadSize:(NSNumber *)payloadSize { + RMTStreamingOutputCallResponse *response = [self message]; + response.payload.type = RMTPayloadType_Compressable; + response.payload.body = [NSMutableData dataWithLength:payloadSize.unsignedIntegerValue]; + return response; +} +@end + + + +@interface InteropTestsMultipleChannels : XCTestCase + +@end + +dispatch_once_t initCronet; + +@implementation InteropTestsMultipleChannels { + RMTTestService *_remoteService; + RMTTestService *_remoteCronetService; + RMTTestService *_localCleartextService; + RMTTestService *_localSSLService; +} + +- (void)setUp { + [super setUp]; + + self.continueAfterFailure = NO; + + _remoteService = [RMTTestService serviceWithHost:kRemoteSSLHost callOptions:nil]; + + dispatch_once(&initCronet, ^{ + [Cronet setHttp2Enabled:YES]; + [Cronet start]; + }); + + // Default stack with remote host + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + options.transportType = GRPCTransportTypeCronet; + // Cronet stack with remote host + _remoteCronetService = [RMTTestService serviceWithHost:kRemoteSSLHost callOptions:options]; + + + // Local stack with no SSL + options = [[GRPCMutableCallOptions alloc] init]; + options.transportType = GRPCTransportTypeInsecure; + _localCleartextService = [RMTTestService serviceWithHost:kLocalCleartextHost callOptions:options]; + + // Local stack with SSL + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + NSString *certsPath = + [bundle pathForResource:@"TestCertificates.bundle/test-certificates" ofType:@"pem"]; + NSError *error = nil; + NSString *certs = + [NSString stringWithContentsOfFile:certsPath encoding:NSUTF8StringEncoding error:&error]; + XCTAssertNil(error); + + options = [[GRPCMutableCallOptions alloc] init]; + options.transportType = GRPCTransportTypeChttp2BoringSSL; + options.PEMRootCertificates = certs; + options.hostNameOverride = @"foo.test.google.fr"; + _localSSLService = [RMTTestService serviceWithHost:kLocalSSLHost callOptions:options]; +} + +- (void)testEmptyUnaryRPC { + __weak XCTestExpectation *expectRemote = [self expectationWithDescription:@"Remote RPC finish"]; + __weak XCTestExpectation *expectCronetRemote = + [self expectationWithDescription:@"Remote RPC finish"]; + __weak XCTestExpectation *expectCleartext = + [self expectationWithDescription:@"Remote RPC finish"]; + __weak XCTestExpectation *expectSSL = [self expectationWithDescription:@"Remote RPC finish"]; + + GPBEmpty *request = [GPBEmpty message]; + + void (^messageHandler)(id message) = ^(id message) { + id expectedResponse = [GPBEmpty message]; + XCTAssertEqualObjects(message, expectedResponse); + }; + + GRPCUnaryProtoCall *callRemote = [_remoteService emptyCallWithMessage:request + responseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil + messageCallback:messageHandler + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + XCTAssertNil(error); + [expectRemote fulfill]; + } + writeMessageCallback:nil] + callOptions:nil]; + GRPCUnaryProtoCall *callCronet = [_remoteCronetService emptyCallWithMessage:request + responseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil + messageCallback:messageHandler + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + XCTAssertNil(error); + [expectCronetRemote fulfill]; + } + writeMessageCallback:nil] + callOptions:nil]; + GRPCUnaryProtoCall *callCleartext = [_localCleartextService emptyCallWithMessage:request + responseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil + messageCallback:messageHandler + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + XCTAssertNil(error); + [expectCleartext fulfill]; + } + writeMessageCallback:nil] + callOptions:nil]; + GRPCUnaryProtoCall *callSSL = [_localSSLService emptyCallWithMessage:request + responseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil + messageCallback:messageHandler + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + XCTAssertNil(error); + [expectSSL fulfill]; + } + writeMessageCallback:nil] + callOptions:nil]; + [callRemote start]; + [callCronet start]; + [callCleartext start]; + [callSSL start]; + + [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; +} + +- (void)testFullDuplexRPC { + __weak XCTestExpectation *expectRemote = [self expectationWithDescription:@"Remote RPC finish"]; + __weak XCTestExpectation *expectCronetRemote = + [self expectationWithDescription:@"Remote RPC finish"]; + __weak XCTestExpectation *expectCleartext = + [self expectationWithDescription:@"Remote RPC finish"]; + __weak XCTestExpectation *expectSSL = [self expectationWithDescription:@"Remote RPC finish"]; + + NSArray *requestSizes = @[ @100, @101, @102, @103 ]; + NSArray *responseSizes = @[ @104, @105, @106, @107 ]; + XCTAssertEqual([requestSizes count], [responseSizes count]); + NSUInteger kRounds = [requestSizes count]; + NSMutableArray *calls = [NSMutableArray arrayWithCapacity:4]; + + NSMutableArray *requests = [NSMutableArray arrayWithCapacity:kRounds]; + NSMutableArray *responses = [NSMutableArray arrayWithCapacity:kRounds]; + for (int i = 0; i < kRounds; i++) { + requests[i] = [RMTStreamingOutputCallRequest messageWithPayloadSize:requestSizes[i] + requestedResponseSize:responseSizes[i]]; + responses[i] = [RMTStreamingOutputCallResponse messageWithPayloadSize:responseSizes[i]]; + } + + __block NSMutableArray *steps = [NSMutableArray arrayWithCapacity:4]; + __block NSMutableArray *requestsBuffers = [NSMutableArray arrayWithCapacity:4]; + for (int i = 0; i < 4; i++) { + steps[i] = [NSNumber numberWithUnsignedInteger:0]; + requestsBuffers[i] = [[GRXBufferedPipe alloc] init]; + [requestsBuffers[i] writeValue:requests[0]]; + } + + void (^handler)(NSUInteger index, id message) = ^(NSUInteger index, id message) { + NSUInteger step = [steps[index] unsignedIntegerValue]; + step++; + steps[index] = [NSNumber numberWithUnsignedInteger:step]; + if (step < kRounds) { + [calls[index] writeMessage:requests[step]]; + } else { + [calls[index] finish]; + } + }; + + calls[0] = [_remoteService fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil + messageCallback:^(id message) { + handler(0, message); + } + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + XCTAssertNil(error); + [expectRemote fulfill]; + } writeMessageCallback:nil] + callOptions:nil]; + calls[1] = [_remoteCronetService fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil + messageCallback:^(id message) { + handler(1, message); + } + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + XCTAssertNil(error); + [expectCronetRemote fulfill]; + } writeMessageCallback:nil] + callOptions:nil]; + calls[2] = [_localCleartextService fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil + messageCallback:^(id message) { + handler(2, message); + } + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + XCTAssertNil(error); + [expectCleartext fulfill]; + } writeMessageCallback:nil] + callOptions:nil]; + calls[3] = [_localSSLService fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil + messageCallback:^(id message) { + handler(3, message); + } + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + XCTAssertNil(error); + [expectSSL fulfill]; + } writeMessageCallback:nil] + callOptions:nil]; + for (int i = 0; i < 4; i++) { + [calls[i] start]; + [calls[i] writeMessage:requests[0]]; + } + + [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; +} + +@end diff --git a/src/objective-c/tests/InteropTestsRemote.m b/src/objective-c/tests/InteropTests/InteropTestsRemote.m similarity index 100% rename from src/objective-c/tests/InteropTestsRemote.m rename to src/objective-c/tests/InteropTests/InteropTestsRemote.m diff --git a/src/objective-c/tests/InteropTestsCallOptions/Info.plist b/src/objective-c/tests/InteropTestsCallOptions/Info.plist deleted file mode 100644 index 6c40a6cd0c4..00000000000 --- a/src/objective-c/tests/InteropTestsCallOptions/Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - - diff --git a/src/objective-c/tests/InteropTestsCallOptions/InteropTestsCallOptions.m b/src/objective-c/tests/InteropTestsCallOptions/InteropTestsCallOptions.m deleted file mode 100644 index db51cb1cfbb..00000000000 --- a/src/objective-c/tests/InteropTestsCallOptions/InteropTestsCallOptions.m +++ /dev/null @@ -1,116 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import - -#import -#import -#import -#import -#import -#import - -#define NSStringize_helper(x) #x -#define NSStringize(x) @NSStringize_helper(x) -static NSString *kRemoteHost = NSStringize(HOST_PORT_REMOTE); -const int32_t kRemoteInteropServerOverhead = 12; - -static const NSTimeInterval TEST_TIMEOUT = 16000; - -@interface InteropTestsCallOptions : XCTestCase - -@end - -@implementation InteropTestsCallOptions { - RMTTestService *_service; -} - -- (void)setUp { - self.continueAfterFailure = NO; - _service = [RMTTestService serviceWithHost:kRemoteHost]; - _service.options = [[GRPCCallOptions alloc] init]; -} - -- (void)test4MBResponsesAreAccepted { - __weak XCTestExpectation *expectation = [self expectationWithDescription:@"MaxResponseSize"]; - - RMTSimpleRequest *request = [RMTSimpleRequest message]; - const int32_t kPayloadSize = - 4 * 1024 * 1024 - kRemoteInteropServerOverhead; // 4MB - encoding overhead - request.responseSize = kPayloadSize; - - [_service unaryCallWithRequest:request - handler:^(RMTSimpleResponse *response, NSError *error) { - XCTAssertNil(error, @"Finished with unexpected error: %@", error); - XCTAssertEqual(response.payload.body.length, kPayloadSize); - [expectation fulfill]; - }]; - - [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; -} - -- (void)testResponsesOverMaxSizeFailWithActionableMessage { - __weak XCTestExpectation *expectation = [self expectationWithDescription:@"ResponseOverMaxSize"]; - - RMTSimpleRequest *request = [RMTSimpleRequest message]; - const int32_t kPayloadSize = - 4 * 1024 * 1024 - kRemoteInteropServerOverhead + 1; // 1B over max size - request.responseSize = kPayloadSize; - - [_service unaryCallWithRequest:request - handler:^(RMTSimpleResponse *response, NSError *error) { - XCTAssertEqualObjects( - error.localizedDescription, - @"Received message larger than max (4194305 vs. 4194304)"); - [expectation fulfill]; - }]; - - [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; -} - -- (void)testResponsesOver4MBAreAcceptedIfOptedIn { - __weak XCTestExpectation *expectation = - [self expectationWithDescription:@"HigherResponseSizeLimit"]; - - RMTSimpleRequest *request = [RMTSimpleRequest message]; - const size_t kPayloadSize = 5 * 1024 * 1024; // 5MB - request.responseSize = kPayloadSize; - - GRPCProtoCall *rpc = [_service - RPCToUnaryCallWithRequest:request - handler:^(RMTSimpleResponse *response, NSError *error) { - XCTAssertNil(error, @"Finished with unexpected error: %@", error); - XCTAssertEqual(response.payload.body.length, kPayloadSize); - [expectation fulfill]; - }]; - GRPCCallOptions *options = rpc.options; - options.responseSizeLimit = 6 * 1024 * 1024; - - [rpc start]; - - [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; -} - -- (void)testPerformanceExample { - // This is an example of a performance test case. - [self measureBlock:^{ - // Put the code you want to measure the time of here. - }]; -} - -@end diff --git a/src/objective-c/tests/InteropTestsMultipleChannels/Info.plist b/src/objective-c/tests/InteropTestsMultipleChannels/Info.plist deleted file mode 100644 index 6c40a6cd0c4..00000000000 --- a/src/objective-c/tests/InteropTestsMultipleChannels/Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - - diff --git a/src/objective-c/tests/InteropTestsMultipleChannels/InteropTestsMultipleChannels.m b/src/objective-c/tests/InteropTestsMultipleChannels/InteropTestsMultipleChannels.m deleted file mode 100644 index b0d4e4883a3..00000000000 --- a/src/objective-c/tests/InteropTestsMultipleChannels/InteropTestsMultipleChannels.m +++ /dev/null @@ -1,259 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import - -#import -#import -#import -#import -#import - -#define NSStringize_helper(x) #x -#define NSStringize(x) @NSStringize_helper(x) -static NSString *const kRemoteSSLHost = NSStringize(HOST_PORT_REMOTE); -static NSString *const kLocalSSLHost = NSStringize(HOST_PORT_LOCALSSL); -static NSString *const kLocalCleartextHost = NSStringize(HOST_PORT_LOCAL); - -static const NSTimeInterval TEST_TIMEOUT = 8000; - -@interface RMTStreamingOutputCallRequest (Constructors) -+ (instancetype)messageWithPayloadSize:(NSNumber *)payloadSize - requestedResponseSize:(NSNumber *)responseSize; -@end - -@implementation RMTStreamingOutputCallRequest (Constructors) -+ (instancetype)messageWithPayloadSize:(NSNumber *)payloadSize - requestedResponseSize:(NSNumber *)responseSize { - RMTStreamingOutputCallRequest *request = [self message]; - RMTResponseParameters *parameters = [RMTResponseParameters message]; - parameters.size = responseSize.intValue; - [request.responseParametersArray addObject:parameters]; - request.payload.body = [NSMutableData dataWithLength:payloadSize.unsignedIntegerValue]; - return request; -} -@end - -@interface RMTStreamingOutputCallResponse (Constructors) -+ (instancetype)messageWithPayloadSize:(NSNumber *)payloadSize; -@end - -@implementation RMTStreamingOutputCallResponse (Constructors) -+ (instancetype)messageWithPayloadSize:(NSNumber *)payloadSize { - RMTStreamingOutputCallResponse *response = [self message]; - response.payload.type = RMTPayloadType_Compressable; - response.payload.body = [NSMutableData dataWithLength:payloadSize.unsignedIntegerValue]; - return response; -} -@end - -@interface InteropTestsMultipleChannels : XCTestCase - -@end - -dispatch_once_t initCronet; - -@implementation InteropTestsMultipleChannels { - RMTTestService *_remoteService; - RMTTestService *_remoteCronetService; - RMTTestService *_localCleartextService; - RMTTestService *_localSSLService; -} - -- (void)setUp { - [super setUp]; - - self.continueAfterFailure = NO; - - // Default stack with remote host - _remoteService = [RMTTestService serviceWithHost:kRemoteSSLHost]; - - // Cronet stack with remote host - _remoteCronetService = [RMTTestService serviceWithHost:kRemoteSSLHost]; - - dispatch_once(&initCronet, ^{ - [Cronet setHttp2Enabled:YES]; - [Cronet start]; - }); - - GRPCCallOptions *options = [[GRPCCallOptions alloc] init]; - options.transportType = GRPCTransportTypeCronet; - options.cronetEngine = [Cronet getGlobalEngine]; - _remoteCronetService.options = options; - - // Local stack with no SSL - _localCleartextService = [RMTTestService serviceWithHost:kLocalCleartextHost]; - options = [[GRPCCallOptions alloc] init]; - options.transportType = GRPCTransportTypeInsecure; - _localCleartextService.options = options; - - // Local stack with SSL - _localSSLService = [RMTTestService serviceWithHost:kLocalSSLHost]; - - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - NSString *certsPath = - [bundle pathForResource:@"TestCertificates.bundle/test-certificates" ofType:@"pem"]; - NSError *error = nil; - NSString *certs = - [NSString stringWithContentsOfFile:certsPath encoding:NSUTF8StringEncoding error:&error]; - XCTAssertNil(error); - - options = [[GRPCCallOptions alloc] init]; - options.transportType = GRPCTransportTypeChttp2BoringSSL; - options.PEMRootCertificates = certs; - options.hostNameOverride = @"foo.test.google.fr"; - _localSSLService.options = options; -} - -- (void)testEmptyUnaryRPC { - __weak XCTestExpectation *expectRemote = [self expectationWithDescription:@"Remote RPC finish"]; - __weak XCTestExpectation *expectCronetRemote = - [self expectationWithDescription:@"Remote RPC finish"]; - __weak XCTestExpectation *expectCleartext = - [self expectationWithDescription:@"Remote RPC finish"]; - __weak XCTestExpectation *expectSSL = [self expectationWithDescription:@"Remote RPC finish"]; - - GPBEmpty *request = [GPBEmpty message]; - - void (^handler)(GPBEmpty *response, NSError *error) = ^(GPBEmpty *response, NSError *error) { - XCTAssertNil(error, @"Finished with unexpected error: %@", error); - - id expectedResponse = [GPBEmpty message]; - XCTAssertEqualObjects(response, expectedResponse); - }; - - [_remoteService emptyCallWithRequest:request - handler:^(GPBEmpty *response, NSError *error) { - handler(response, error); - [expectRemote fulfill]; - }]; - [_remoteCronetService emptyCallWithRequest:request - handler:^(GPBEmpty *response, NSError *error) { - handler(response, error); - [expectCronetRemote fulfill]; - }]; - [_localCleartextService emptyCallWithRequest:request - handler:^(GPBEmpty *response, NSError *error) { - handler(response, error); - [expectCleartext fulfill]; - }]; - [_localSSLService emptyCallWithRequest:request - handler:^(GPBEmpty *response, NSError *error) { - handler(response, error); - [expectSSL fulfill]; - }]; - - [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; -} - -- (void)testFullDuplexRPC { - __weak XCTestExpectation *expectRemote = [self expectationWithDescription:@"Remote RPC finish"]; - __weak XCTestExpectation *expectCronetRemote = - [self expectationWithDescription:@"Remote RPC finish"]; - __weak XCTestExpectation *expectCleartext = - [self expectationWithDescription:@"Remote RPC finish"]; - __weak XCTestExpectation *expectSSL = [self expectationWithDescription:@"Remote RPC finish"]; - - NSArray *requestSizes = @[ @100, @101, @102, @103 ]; - NSArray *responseSizes = @[ @104, @105, @106, @107 ]; - XCTAssertEqual([requestSizes count], [responseSizes count]); - NSUInteger kRounds = [requestSizes count]; - - NSMutableArray *requests = [NSMutableArray arrayWithCapacity:kRounds]; - NSMutableArray *responses = [NSMutableArray arrayWithCapacity:kRounds]; - for (int i = 0; i < kRounds; i++) { - requests[i] = [RMTStreamingOutputCallRequest messageWithPayloadSize:requestSizes[i] - requestedResponseSize:responseSizes[i]]; - responses[i] = [RMTStreamingOutputCallResponse messageWithPayloadSize:responseSizes[i]]; - } - - __block NSMutableArray *steps = [NSMutableArray arrayWithCapacity:4]; - __block NSMutableArray *requestsBuffers = [NSMutableArray arrayWithCapacity:4]; - for (int i = 0; i < 4; i++) { - steps[i] = [NSNumber numberWithUnsignedInteger:0]; - requestsBuffers[i] = [[GRXBufferedPipe alloc] init]; - [requestsBuffers[i] writeValue:requests[0]]; - } - - BOOL (^handler)(int, BOOL, RMTStreamingOutputCallResponse *, NSError *) = - ^(int index, BOOL done, RMTStreamingOutputCallResponse *response, NSError *error) { - XCTAssertNil(error, @"Finished with unexpected error: %@", error); - XCTAssertTrue(done || response, @"Event handler called without an event."); - if (response) { - NSUInteger step = [steps[index] unsignedIntegerValue]; - XCTAssertLessThan(step, kRounds, @"More than %lu responses received.", - (unsigned long)kRounds); - XCTAssertEqualObjects(response, responses[step]); - step++; - steps[index] = [NSNumber numberWithUnsignedInteger:step]; - GRXBufferedPipe *pipe = requestsBuffers[index]; - if (step < kRounds) { - [pipe writeValue:requests[step]]; - } else { - [pipe writesFinishedWithError:nil]; - } - } - if (done) { - NSUInteger step = [steps[index] unsignedIntegerValue]; - XCTAssertEqual(step, kRounds, @"Received %lu responses instead of %lu.", step, kRounds); - return YES; - } - return NO; - }; - - [_remoteService - fullDuplexCallWithRequestsWriter:requestsBuffers[0] - eventHandler:^(BOOL done, - RMTStreamingOutputCallResponse *_Nullable response, - NSError *_Nullable error) { - if (handler(0, done, response, error)) { - [expectRemote fulfill]; - } - }]; - [_remoteCronetService - fullDuplexCallWithRequestsWriter:requestsBuffers[1] - eventHandler:^(BOOL done, - RMTStreamingOutputCallResponse *_Nullable response, - NSError *_Nullable error) { - if (handler(1, done, response, error)) { - [expectCronetRemote fulfill]; - } - }]; - [_localCleartextService - fullDuplexCallWithRequestsWriter:requestsBuffers[2] - eventHandler:^(BOOL done, - RMTStreamingOutputCallResponse *_Nullable response, - NSError *_Nullable error) { - if (handler(2, done, response, error)) { - [expectCleartext fulfill]; - } - }]; - [_localSSLService - fullDuplexCallWithRequestsWriter:requestsBuffers[3] - eventHandler:^(BOOL done, - RMTStreamingOutputCallResponse *_Nullable response, - NSError *_Nullable error) { - if (handler(3, done, response, error)) { - [expectSSL fulfill]; - } - }]; - - [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; -} - -@end diff --git a/src/objective-c/tests/InteropTestsRemoteWithCronet/Info.plist b/src/objective-c/tests/InteropTestsRemoteWithCronet/Info.plist deleted file mode 100644 index ba72822e872..00000000000 --- a/src/objective-c/tests/InteropTestsRemoteWithCronet/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - - diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile index 34ed6680195..146abf5b0e0 100644 --- a/src/objective-c/tests/Podfile +++ b/src/objective-c/tests/Podfile @@ -5,44 +5,6 @@ install! 'cocoapods', :deterministic_uuids => false # Location of gRPC's repo root relative to this file. GRPC_LOCAL_SRC = '../../..' -# Install the dependencies in the main target plus all test targets. -%w( - AllTests - RxLibraryUnitTests - InteropTestsRemote - InteropTestsLocalSSL - InteropTestsLocalCleartext - InteropTestsRemoteWithCronet - InteropTestsMultipleChannels - InteropTestsCallOptions - UnitTests - InteropTestsRemoteCFStream - InteropTestsLocalSSLCFStream - InteropTestsLocalCleartextCFStream - APIv2Tests -).each do |target_name| - target target_name do - platform :ios, '8.0' - pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf", :inhibit_warnings => true - - pod '!ProtoCompiler', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" - pod '!ProtoCompiler-gRPCPlugin', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" - - pod 'BoringSSL-GRPC', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true - - pod 'gRPC', :path => GRPC_LOCAL_SRC - pod 'gRPC-Core', :path => GRPC_LOCAL_SRC - pod 'gRPC-RxLibrary', :path => GRPC_LOCAL_SRC - pod 'gRPC-ProtoRPC', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true - pod 'RemoteTest', :path => "RemoteTestClient", :inhibit_warnings => true - - if target_name == 'InteropTestsRemoteWithCronet' or target_name == 'InteropTestsMultipleChannels' - pod 'gRPC-Core/Cronet-Implementation', :path => GRPC_LOCAL_SRC - pod 'CronetFramework', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" - end - end -end - target 'MacTests' do platform :osx, '10.13' pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf", :inhibit_warnings => true @@ -60,25 +22,48 @@ target 'MacTests' do end %w( - CoreCronetEnd2EndTests - CronetUnitTests + UnitTests ).each do |target_name| - target target_name do + target target_name do platform :ios, '8.0' - pod 'BoringSSL-GRPC', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true - pod 'CronetFramework', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" - pod 'gRPC-Core', :path => GRPC_LOCAL_SRC - pod 'gRPC-Core/Cronet-Interface', :path => GRPC_LOCAL_SRC - pod 'gRPC-Core/Cronet-Implementation', :path => GRPC_LOCAL_SRC - pod 'gRPC-Core/Tests', :path => GRPC_LOCAL_SRC + pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf", :inhibit_warnings => true + + pod '!ProtoCompiler', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" + pod '!ProtoCompiler-gRPCPlugin', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" + + pod 'BoringSSL-GRPC', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true + + pod 'gRPC', :path => GRPC_LOCAL_SRC + pod 'gRPC-Core', :path => GRPC_LOCAL_SRC + pod 'gRPC-RxLibrary', :path => GRPC_LOCAL_SRC + pod 'gRPC-ProtoRPC', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true + pod 'RemoteTest', :path => "RemoteTestClient", :inhibit_warnings => true end end -target 'ChannelTests' do - platform :ios, '8.0' - pod 'gRPC', :path => GRPC_LOCAL_SRC - pod 'gRPC-Core', :path => GRPC_LOCAL_SRC - pod 'BoringSSL-GRPC', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true +%w( + InteropTests + CronetTests +).each do |target_name| + target target_name do + platform :ios, '8.0' + pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf", :inhibit_warnings => true + + pod '!ProtoCompiler', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" + pod '!ProtoCompiler-gRPCPlugin', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" + + pod 'BoringSSL-GRPC', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true + + pod 'gRPC', :path => GRPC_LOCAL_SRC + pod 'gRPC-Core', :path => GRPC_LOCAL_SRC + pod 'gRPC-RxLibrary', :path => GRPC_LOCAL_SRC + pod 'gRPC-ProtoRPC', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true + pod 'RemoteTest', :path => "RemoteTestClient", :inhibit_warnings => true + + pod 'gRPC-Core/Cronet-Implementation', :path => GRPC_LOCAL_SRC + pod 'CronetFramework', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" + pod 'gRPC-Core/Tests', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true + end end # gRPC-Core.podspec needs to be modified to be successfully used for local development. A Podfile's @@ -127,7 +112,7 @@ post_install do |installer| # GPR_UNREACHABLE_CODE causes "Control may reach end of non-void # function" warning config.build_settings['GCC_WARN_ABOUT_RETURN_TYPE'] = 'NO' - config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_CRONET_WITH_PACKET_COALESCING=1 GRPC_CFSTREAM=1' + config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_CRONET_WITH_PACKET_COALESCING=1' end end diff --git a/src/objective-c/tests/Tests.m b/src/objective-c/tests/Tests.m deleted file mode 100644 index 1d303497134..00000000000 --- a/src/objective-c/tests/Tests.m +++ /dev/null @@ -1,25 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import - -@interface Tests : NSObject -@end - -@implementation Tests -@end diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index 27a617c83b4..1295731641b 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -7,186 +7,45 @@ objects = { /* Begin PBXBuildFile section */ - 06467F3A8D01EC493D12ADA2 /* libPods-CronetUnitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C6134277D2EB8B380862A03F /* libPods-CronetUnitTests.a */; }; - 09B76D9585ACE7403804D9DC /* libPods-InteropTestsRemoteWithCronet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9E9444C764F0FFF64A7EB58E /* libPods-InteropTestsRemoteWithCronet.a */; }; - 0F9232F984C08643FD40C34F /* libPods-InteropTestsRemote.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DBE059B4AC7A51919467EEC0 /* libPods-InteropTestsRemote.a */; }; - 16A9E77B6E336B3C0B9BA6E0 /* libPods-InteropTestsLocalSSL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DBEDE45BDA60DF1E1C8950C0 /* libPods-InteropTestsLocalSSL.a */; }; - 1A0FB7F8C95A2F82538BC950 /* libPods-ChannelTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 48F1841C9A920626995DC28C /* libPods-ChannelTests.a */; }; - 20DFDF829DD993A4A00D5662 /* libPods-RxLibraryUnitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A58BE6DF1C62D1739EBB2C78 /* libPods-RxLibraryUnitTests.a */; }; - 333E8FC01C8285B7C547D799 /* libPods-InteropTestsLocalCleartext.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FD346DB2C23F676C4842F3FF /* libPods-InteropTestsLocalCleartext.a */; }; - 5E0282E9215AA697007AC99D /* UnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E0282E8215AA697007AC99D /* UnitTests.m */; }; - 5E0282EB215AA697007AC99D /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; - 5E3B95A521CAC6C500C0A151 /* APIv2Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3B95A421CAC6C500C0A151 /* APIv2Tests.m */; }; - 5E7D71AD210954A8001EA6BA /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; - 5E7D71B5210B9EC9001EA6BA /* InteropTestsCallOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7D71B4210B9EC9001EA6BA /* InteropTestsCallOptions.m */; }; - 5E7D71B7210B9EC9001EA6BA /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; - 5E8A5DA71D3840B4000F8BC4 /* CoreCronetEnd2EndTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E8A5DA61D3840B4000F8BC4 /* CoreCronetEnd2EndTests.mm */; }; - 5E8A5DA91D3840B4000F8BC4 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; - 5EAD6D271E27047400002378 /* CronetUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EAD6D261E27047400002378 /* CronetUnitTests.m */; }; - 5EAD6D291E27047400002378 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; - 5EB2A2E72107DED300EB4B69 /* ChannelTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EB2A2E62107DED300EB4B69 /* ChannelTests.m */; }; - 5EB2A2E92107DED300EB4B69 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; - 5EB2A2F82109284500EB4B69 /* InteropTestsMultipleChannels.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EB2A2F72109284500EB4B69 /* InteropTestsMultipleChannels.m */; }; - 5EB2A2FA2109284500EB4B69 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; - 5EB5C3AA21656CEA00ADC300 /* ChannelPoolTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EB5C3A921656CEA00ADC300 /* ChannelPoolTest.m */; }; - 5EC5E42B2081782C000EF4AD /* InteropTestsRemote.m in Sources */ = {isa = PBXBuildFile; fileRef = 6379CC4F1BE16703001BC0A1 /* InteropTestsRemote.m */; }; - 5EC5E42C20817832000EF4AD /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; }; - 5EC5E43B208185A7000EF4AD /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; - 5EC5E43C208185AD000EF4AD /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; }; - 5EC5E43D208185B0000EF4AD /* GRPCClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6312AE4D1B1BF49B00341DEE /* GRPCClientTests.m */; }; - 5EC5E44C208185EC000EF4AD /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; }; - 5EC5E44D208185F0000EF4AD /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; - 5EC5E44E20818948000EF4AD /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; - 5EE84BF41D4717E40050C6CC /* InteropTestsRemoteWithCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE84BF31D4717E40050C6CC /* InteropTestsRemoteWithCronet.m */; }; - 5EE84BF61D4717E40050C6CC /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; - 5EE84BFE1D471D400050C6CC /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; }; - 60D2A57ED559F34428C2EEC5 /* libPods-CoreCronetEnd2EndTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FBD98AC417B9882D32B19F28 /* libPods-CoreCronetEnd2EndTests.a */; }; - 6312AE4E1B1BF49B00341DEE /* GRPCClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6312AE4D1B1BF49B00341DEE /* GRPCClientTests.m */; }; - 63423F4A1B150A5F006CF63C /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; - 635697CD1B14FC11007A7283 /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635697CC1B14FC11007A7283 /* Tests.m */; }; - 635ED2EC1B1A3BC400FDE5C3 /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; }; - 63715F561B780C020029CB0B /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; - 6379CC4D1BE1662A001BC0A1 /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; }; - 6379CC4E1BE1662B001BC0A1 /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; }; - 6379CC501BE16703001BC0A1 /* InteropTestsRemote.m in Sources */ = {isa = PBXBuildFile; fileRef = 6379CC4F1BE16703001BC0A1 /* InteropTestsRemote.m */; }; - 6379CC511BE1683B001BC0A1 /* InteropTestsRemote.m in Sources */ = {isa = PBXBuildFile; fileRef = 6379CC4F1BE16703001BC0A1 /* InteropTestsRemote.m */; }; - 6379CC531BE17709001BC0A1 /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; - 63DC84181BE15179000708E8 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; - 63DC841E1BE15180000708E8 /* RxLibraryUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 63423F501B151B77006CF63C /* RxLibraryUnitTests.m */; }; - 63DC84281BE15267000708E8 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; - 63DC842E1BE15278000708E8 /* RxLibraryUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 63423F501B151B77006CF63C /* RxLibraryUnitTests.m */; }; - 63DC842F1BE1527D000708E8 /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; }; - 63DC84391BE15294000708E8 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; - 63DC84481BE152B5000708E8 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; }; - 63DC844E1BE15350000708E8 /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; - 63DC844F1BE15353000708E8 /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; - 63DC84501BE153AA000708E8 /* GRPCClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6312AE4D1B1BF49B00341DEE /* GRPCClientTests.m */; }; - 63E240CE1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; - 63E240D01B6C63DC005F3B0E /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; - 6C1A3F81CCF7C998B4813EFD /* libPods-InteropTestsCallOptions.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AF3FC2CFFE7B0961823BC740 /* libPods-InteropTestsCallOptions.a */; }; - 886717A79EFF774F356798E6 /* libPods-InteropTestsMultipleChannels.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 355D0E30AD224763BC9519F4 /* libPods-InteropTestsMultipleChannels.a */; }; - 91D4B3C85B6D8562F409CB48 /* libPods-InteropTestsLocalSSLCFStream.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F3AB031E0E26AC8EF30A2A2A /* libPods-InteropTestsLocalSSLCFStream.a */; }; + 5E0282E9215AA697007AC99D /* NSErrorUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E0282E8215AA697007AC99D /* NSErrorUnitTests.m */; }; + 5E3F14842278B461007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; + 5E3F14852278BF5D007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; + 5E3F14862278BFFF007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; + 5E7F486422775B37006656AD /* InteropTestsRemoteWithCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE84BF31D4717E40050C6CC /* InteropTestsRemoteWithCronet.m */; }; + 5E7F486522775B41006656AD /* CronetUnitTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5EAD6D261E27047400002378 /* CronetUnitTests.mm */; }; + 5E7F486E22778086006656AD /* CoreCronetEnd2EndTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F486D22778086006656AD /* CoreCronetEnd2EndTests.mm */; }; + 5E7F487922778226006656AD /* InteropTestsMultipleChannels.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487722778226006656AD /* InteropTestsMultipleChannels.m */; }; + 5E7F487D22778256006656AD /* ChannelPoolTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487B22778256006656AD /* ChannelPoolTest.m */; }; + 5E7F487E22778256006656AD /* ChannelTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487C22778256006656AD /* ChannelTests.m */; }; + 5E7F4880227782C1006656AD /* APIv2Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487F227782C1006656AD /* APIv2Tests.m */; }; + 5E7F488322778A88006656AD /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F488222778A88006656AD /* InteropTests.m */; }; + 5E7F488422778A88006656AD /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F488222778A88006656AD /* InteropTests.m */; }; + 5E7F488522778A88006656AD /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F488222778A88006656AD /* InteropTests.m */; }; + 5E7F488722778AEA006656AD /* GRPCClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F488622778AEA006656AD /* GRPCClientTests.m */; }; + 5E7F488922778B04006656AD /* InteropTestsRemote.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F488822778B04006656AD /* InteropTestsRemote.m */; }; + 5E7F488B22778B5D006656AD /* RxLibraryUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F488A22778B5D006656AD /* RxLibraryUnitTests.m */; }; + 5E7F488C22778C60006656AD /* APIv2Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487F227782C1006656AD /* APIv2Tests.m */; }; + 5E7F488D22778C85006656AD /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; + 5E7F488E22778C87006656AD /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; + 5E7F488F22778C8C006656AD /* InteropTestsRemote.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F488822778B04006656AD /* InteropTestsRemote.m */; }; + 5E7F489022778C95006656AD /* RxLibraryUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F488A22778B5D006656AD /* RxLibraryUnitTests.m */; }; + 5EA4770322736178000F72FC /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; + 5EA477042273617B000F72FC /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; + 5EA4770522736AC4000F72FC /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; + 65EB19E418B39A8374D407BB /* libPods-CronetTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B1511C20E16A8422B58D61A /* libPods-CronetTests.a */; }; + 903163C7FE885838580AEC7A /* libPods-InteropTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D457AD9797664CFA191C3280 /* libPods-InteropTests.a */; }; 953CD2942A3A6D6CE695BE87 /* libPods-MacTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 276873A05AC5479B60DF6079 /* libPods-MacTests.a */; }; - 98478C9F42329DF769A45B6C /* libPods-APIv2Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B6AD69CACF67505B0F028E92 /* libPods-APIv2Tests.a */; }; B071230B22669EED004B64A1 /* StressTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B071230A22669EED004B64A1 /* StressTests.m */; }; - B0BB3F02225E7A3C008DA580 /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; - B0BB3F03225E7A44008DA580 /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; - B0BB3F04225E7A8D008DA580 /* RxLibraryUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 63423F501B151B77006CF63C /* RxLibraryUnitTests.m */; }; - B0BB3F05225E7A9F008DA580 /* InteropTestsRemote.m in Sources */ = {isa = PBXBuildFile; fileRef = 6379CC4F1BE16703001BC0A1 /* InteropTestsRemote.m */; }; - B0BB3F06225E7AAD008DA580 /* GRPCClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6312AE4D1B1BF49B00341DEE /* GRPCClientTests.m */; }; - B0BB3F07225E7AB5008DA580 /* APIv2Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3B95A421CAC6C500C0A151 /* APIv2Tests.m */; }; - B0BB3F08225E7ABA008DA580 /* UnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E0282E8215AA697007AC99D /* UnitTests.m */; }; + B0BB3F08225E7ABA008DA580 /* NSErrorUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E0282E8215AA697007AC99D /* NSErrorUnitTests.m */; }; B0BB3F0A225EA511008DA580 /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; - B0BB3F0B225EB110008DA580 /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; }; B0D39B9A2266F3CB00A4078D /* StressTestsSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D39B992266F3CB00A4078D /* StressTestsSSL.m */; }; B0D39B9C2266FF9800A4078D /* StressTestsCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D39B9B2266FF9800A4078D /* StressTestsCleartext.m */; }; - BC111C80CBF7068B62869352 /* libPods-InteropTestsRemoteCFStream.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F44AC3F44E3491A8C0D890FE /* libPods-InteropTestsRemoteCFStream.a */; }; - C3D6F4270A2FFF634D8849ED /* libPods-InteropTestsLocalCleartextCFStream.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0BDA4BA011779D5D25B5618C /* libPods-InteropTestsLocalCleartextCFStream.a */; }; CCF5C0719EF608276AE16374 /* libPods-UnitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 22A3EBB488699C8CEA19707B /* libPods-UnitTests.a */; }; - F15EF7852DC70770EFDB1D2C /* libPods-AllTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CAE086D5B470DA367D415AB0 /* libPods-AllTests.a */; }; /* End PBXBuildFile section */ -/* Begin PBXContainerItemProxy section */ - 5E0282EC215AA697007AC99D /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 635697BF1B14FC11007A7283 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 635697C61B14FC11007A7283; - remoteInfo = Tests; - }; - 5E7D71B8210B9EC9001EA6BA /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 635697BF1B14FC11007A7283 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 635697C61B14FC11007A7283; - remoteInfo = Tests; - }; - 5E8A5DAA1D3840B4000F8BC4 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 635697BF1B14FC11007A7283 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 635697C61B14FC11007A7283; - remoteInfo = Tests; - }; - 5EAD6D2A1E27047400002378 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 635697BF1B14FC11007A7283 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 635697C61B14FC11007A7283; - remoteInfo = Tests; - }; - 5EB2A2EA2107DED300EB4B69 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 635697BF1B14FC11007A7283 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 635697C61B14FC11007A7283; - remoteInfo = Tests; - }; - 5EB2A2FB2109284500EB4B69 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 635697BF1B14FC11007A7283 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 635697C61B14FC11007A7283; - remoteInfo = Tests; - }; - 5EE84BF71D4717E40050C6CC /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 635697BF1B14FC11007A7283 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 635697C61B14FC11007A7283; - remoteInfo = Tests; - }; - 63423F4B1B150A5F006CF63C /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 635697BF1B14FC11007A7283 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 635697C61B14FC11007A7283; - remoteInfo = Tests; - }; - 63DC84191BE15179000708E8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 635697BF1B14FC11007A7283 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 635697C61B14FC11007A7283; - remoteInfo = Tests; - }; - 63DC84291BE15267000708E8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 635697BF1B14FC11007A7283 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 635697C61B14FC11007A7283; - remoteInfo = Tests; - }; - 63DC843A1BE15294000708E8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 635697BF1B14FC11007A7283 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 635697C61B14FC11007A7283; - remoteInfo = Tests; - }; - 63DC84491BE152B5000708E8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 635697BF1B14FC11007A7283 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 635697C61B14FC11007A7283; - remoteInfo = Tests; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 635697C51B14FC11007A7283 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - /* Begin PBXFileReference section */ 02192CF1FF9534E3D18C65FC /* Pods-CronetUnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetUnitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests.release.xcconfig"; sourceTree = ""; }; + 070266E2626EB997B54880A3 /* Pods-InteropTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTests/Pods-InteropTests.test.xcconfig"; sourceTree = ""; }; 07D10A965323BEA7FE59A74B /* Pods-RxLibraryUnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.debug.xcconfig"; sourceTree = ""; }; 0A4F89D9C90E9C30990218F0 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; 0BDA4BA011779D5D25B5618C /* libPods-InteropTestsLocalCleartextCFStream.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalCleartextCFStream.a"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -198,9 +57,11 @@ 1588C85DEAF7FC0ACDEA4C02 /* Pods-InteropTestsLocalCleartext.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartext.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext.test.xcconfig"; sourceTree = ""; }; 16A2E4C5839C83FBDA63881F /* Pods-MacTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MacTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-MacTests/Pods-MacTests.cronet.xcconfig"; sourceTree = ""; }; 17F60BF2871F6AF85FB3FA12 /* Pods-InteropTestsRemoteWithCronet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.debug.xcconfig"; sourceTree = ""; }; + 1B1511C20E16A8422B58D61A /* libPods-CronetTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CronetTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 1E43EAE443CBB4482B1EB071 /* Pods-MacTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MacTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-MacTests/Pods-MacTests.release.xcconfig"; sourceTree = ""; }; 1F5E788FBF9A4A06EB9E1ACD /* Pods-MacTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MacTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-MacTests/Pods-MacTests.test.xcconfig"; sourceTree = ""; }; 20DFF2F3C97EF098FE5A3171 /* libPods-Tests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Tests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 20F6A3D59D0EE091E2D43953 /* Pods-CronetTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests.cronet.xcconfig"; sourceTree = ""; }; 22A3EBB488699C8CEA19707B /* libPods-UnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-UnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 2650FEF00956E7924772F9D9 /* Pods-InteropTestsMultipleChannels.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsMultipleChannels.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels.release.xcconfig"; sourceTree = ""; }; 276873A05AC5479B60DF6079 /* libPods-MacTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-MacTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -226,58 +87,41 @@ 55B630C1FF8C36D1EFC4E0A4 /* Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig"; sourceTree = ""; }; 573450F334B331D0BED8B961 /* Pods-CoreCronetEnd2EndTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CoreCronetEnd2EndTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests.cronet.xcconfig"; sourceTree = ""; }; 5761E98978DDDF136A58CB7E /* Pods-AllTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.release.xcconfig"; sourceTree = ""; }; + 5AB9A82F289D548D6B8816F9 /* Pods-CronetTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests.test.xcconfig"; sourceTree = ""; }; 5E0282E6215AA697007AC99D /* UnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 5E0282E8215AA697007AC99D /* UnitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UnitTests.m; sourceTree = ""; }; - 5E0282EA215AA697007AC99D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 5E3B95A221CAC6C500C0A151 /* APIv2Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = APIv2Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 5E3B95A421CAC6C500C0A151 /* APIv2Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = APIv2Tests.m; sourceTree = ""; }; - 5E3B95A621CAC6C500C0A151 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 5E7D71B2210B9EC8001EA6BA /* InteropTestsCallOptions.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTestsCallOptions.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 5E7D71B4210B9EC9001EA6BA /* InteropTestsCallOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InteropTestsCallOptions.m; sourceTree = ""; }; - 5E7D71B6210B9EC9001EA6BA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 5E8A5DA41D3840B4000F8BC4 /* CoreCronetEnd2EndTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CoreCronetEnd2EndTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 5E8A5DA61D3840B4000F8BC4 /* CoreCronetEnd2EndTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CoreCronetEnd2EndTests.mm; sourceTree = ""; }; + 5E0282E8215AA697007AC99D /* NSErrorUnitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NSErrorUnitTests.m; sourceTree = ""; }; + 5E3F14822278B42D007C6D90 /* InteropTestsBlockCallbacks.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InteropTestsBlockCallbacks.h; sourceTree = ""; }; + 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InteropTestsBlockCallbacks.m; sourceTree = ""; }; + 5E7F485922775B15006656AD /* CronetTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CronetTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 5E7F486622776AD8006656AD /* Cronet.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cronet.framework; path = Pods/CronetFramework/Cronet.framework; sourceTree = ""; }; + 5E7F486D22778086006656AD /* CoreCronetEnd2EndTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CoreCronetEnd2EndTests.mm; sourceTree = ""; }; + 5E7F487722778226006656AD /* InteropTestsMultipleChannels.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InteropTestsMultipleChannels.m; sourceTree = ""; }; + 5E7F487B22778256006656AD /* ChannelPoolTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChannelPoolTest.m; sourceTree = ""; }; + 5E7F487C22778256006656AD /* ChannelTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChannelTests.m; sourceTree = ""; }; + 5E7F487F227782C1006656AD /* APIv2Tests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APIv2Tests.m; sourceTree = ""; }; + 5E7F488122778A88006656AD /* InteropTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InteropTests.h; sourceTree = ""; }; + 5E7F488222778A88006656AD /* InteropTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InteropTests.m; sourceTree = ""; }; + 5E7F488622778AEA006656AD /* GRPCClientTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GRPCClientTests.m; sourceTree = ""; }; + 5E7F488822778B04006656AD /* InteropTestsRemote.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InteropTestsRemote.m; sourceTree = ""; }; + 5E7F488A22778B5D006656AD /* RxLibraryUnitTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RxLibraryUnitTests.m; sourceTree = ""; }; + 5EA476F42272816A000F72FC /* InteropTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 5EA908CF4CDA4CE218352A06 /* Pods-InteropTestsLocalSSLCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.release.xcconfig"; sourceTree = ""; }; - 5EAD6D241E27047400002378 /* CronetUnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CronetUnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 5EAD6D261E27047400002378 /* CronetUnitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CronetUnitTests.m; sourceTree = ""; }; - 5EAD6D281E27047400002378 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 5EAD6D261E27047400002378 /* CronetUnitTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = CronetUnitTests.mm; path = CronetTests/CronetUnitTests.mm; sourceTree = SOURCE_ROOT; }; 5EAFE8271F8EFB87007F2189 /* version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = version.h; sourceTree = ""; }; - 5EB2A2E42107DED300EB4B69 /* ChannelTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ChannelTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 5EB2A2E62107DED300EB4B69 /* ChannelTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ChannelTests.m; sourceTree = ""; }; - 5EB2A2E82107DED300EB4B69 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 5EB2A2F52109284500EB4B69 /* InteropTestsMultipleChannels.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTestsMultipleChannels.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 5EB2A2F72109284500EB4B69 /* InteropTestsMultipleChannels.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InteropTestsMultipleChannels.m; sourceTree = ""; }; - 5EB2A2F92109284500EB4B69 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 5EB5C3A921656CEA00ADC300 /* ChannelPoolTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ChannelPoolTest.m; sourceTree = ""; }; - 5EC5E421208177CC000EF4AD /* InteropTestsRemoteCFStream.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTestsRemoteCFStream.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 5EC5E4312081856B000EF4AD /* InteropTestsLocalCleartextCFStream.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTestsLocalCleartextCFStream.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 5EC5E442208185CE000EF4AD /* InteropTestsLocalSSLCFStream.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTestsLocalSSLCFStream.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 5EE84BF11D4717E40050C6CC /* InteropTestsRemoteWithCronet.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTestsRemoteWithCronet.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 5EE84BF31D4717E40050C6CC /* InteropTestsRemoteWithCronet.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InteropTestsRemoteWithCronet.m; sourceTree = ""; }; - 5EE84BF51D4717E40050C6CC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 6312AE4D1B1BF49B00341DEE /* GRPCClientTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GRPCClientTests.m; sourceTree = ""; }; - 63423F441B150A5F006CF63C /* AllTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AllTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 63423F501B151B77006CF63C /* RxLibraryUnitTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RxLibraryUnitTests.m; sourceTree = ""; }; - 635697C71B14FC11007A7283 /* libTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libTests.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 635697CC1B14FC11007A7283 /* Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = ""; }; + 5EE84BF31D4717E40050C6CC /* InteropTestsRemoteWithCronet.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = InteropTestsRemoteWithCronet.m; path = CronetTests/InteropTestsRemoteWithCronet.m; sourceTree = SOURCE_ROOT; }; 635697D81B14FC11007A7283 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InteropTests.m; sourceTree = ""; }; - 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InteropTestsLocalCleartext.m; sourceTree = ""; }; - 6379CC4F1BE16703001BC0A1 /* InteropTestsRemote.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InteropTestsRemote.m; sourceTree = ""; }; - 63DC84131BE15179000708E8 /* RxLibraryUnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RxLibraryUnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 63DC84231BE15267000708E8 /* InteropTestsRemote.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTestsRemote.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 63DC84341BE15294000708E8 /* InteropTestsLocalSSL.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTestsLocalSSL.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 63DC84431BE152B5000708E8 /* InteropTestsLocalCleartext.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTestsLocalCleartext.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 63E240CC1B6C4D3A005F3B0E /* InteropTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InteropTests.h; sourceTree = ""; }; - 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InteropTestsLocalSSL.m; sourceTree = ""; }; + 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = InteropTestsLocalCleartext.m; path = InteropTests/InteropTestsLocalCleartext.m; sourceTree = SOURCE_ROOT; }; + 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = InteropTestsLocalSSL.m; path = InteropTests/InteropTestsLocalSSL.m; sourceTree = SOURCE_ROOT; }; 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = TestCertificates.bundle; sourceTree = ""; }; 64F68A9A6A63CC930DD30A6E /* Pods-CronetUnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetUnitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests.debug.xcconfig"; sourceTree = ""; }; 6793C9D019CB268C5BB491A2 /* Pods-CoreCronetEnd2EndTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CoreCronetEnd2EndTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests.test.xcconfig"; sourceTree = ""; }; + 680439AC2BC8761EDD54A1EA /* Pods-InteropTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTests/Pods-InteropTests.debug.xcconfig"; sourceTree = ""; }; 73D2DF07027835BA0FB0B1C0 /* Pods-InteropTestsCallOptions.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsCallOptions.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions.cronet.xcconfig"; sourceTree = ""; }; 781089FAE980F51F88A3BE0B /* Pods-RxLibraryUnitTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.test.xcconfig"; sourceTree = ""; }; 79C68EFFCB5533475D810B79 /* Pods-RxLibraryUnitTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.cronet.xcconfig"; sourceTree = ""; }; 7A2E97E3F469CC2A758D77DE /* Pods-InteropTestsLocalSSL.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.release.xcconfig"; sourceTree = ""; }; 7BA53C6D224288D5870FE6F3 /* Pods-InteropTestsLocalCleartextCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.release.xcconfig"; sourceTree = ""; }; + 7F4F42EBAF311E9F84FCA32E /* Pods-CronetTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests.release.xcconfig"; sourceTree = ""; }; 8B498B05C6DA0818B2FA91D4 /* Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig"; sourceTree = ""; }; 8C233E85C3EB45B3CAE52EDF /* Pods-APIv2Tests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIv2Tests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests.cronet.xcconfig"; sourceTree = ""; }; 90E63AD3C4A1E3E6BC745096 /* Pods-ChannelTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChannelTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests.cronet.xcconfig"; sourceTree = ""; }; @@ -305,7 +149,9 @@ C6134277D2EB8B380862A03F /* libPods-CronetUnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CronetUnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; C9172F9020E8C97A470D7250 /* Pods-InteropTestsCallOptions.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsCallOptions.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions.release.xcconfig"; sourceTree = ""; }; CAE086D5B470DA367D415AB0 /* libPods-AllTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AllTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + CDF6CC70B8BF9D10EFE7D199 /* Pods-InteropTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTests/Pods-InteropTests.cronet.xcconfig"; sourceTree = ""; }; D13BEC8181B8E678A1B52F54 /* Pods-InteropTestsLocalSSL.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.test.xcconfig"; sourceTree = ""; }; + D457AD9797664CFA191C3280 /* libPods-InteropTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; D52B92A7108602F170DA8091 /* Pods-ChannelTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChannelTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests.release.xcconfig"; sourceTree = ""; }; DB1F4391AF69D20D38D74B67 /* Pods-AllTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.test.xcconfig"; sourceTree = ""; }; DBE059B4AC7A51919467EEC0 /* libPods-InteropTestsRemote.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsRemote.a"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -319,8 +165,10 @@ E7E4D3FD76E3B745D992AF5F /* Pods-AllTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.cronet.xcconfig"; sourceTree = ""; }; EA8B122ACDE73E3AAA0E4A19 /* Pods-InteropTestsMultipleChannels.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsMultipleChannels.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels.test.xcconfig"; sourceTree = ""; }; EBFFEC04B514CB0D4922DC40 /* Pods-UnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests.release.xcconfig"; sourceTree = ""; }; + EC66920112123D2DB1CB7F6C /* Pods-CronetTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests.debug.xcconfig"; sourceTree = ""; }; F3AB031E0E26AC8EF30A2A2A /* libPods-InteropTestsLocalSSLCFStream.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalSSLCFStream.a"; sourceTree = BUILT_PRODUCTS_DIR; }; F44AC3F44E3491A8C0D890FE /* libPods-InteropTestsRemoteCFStream.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsRemoteCFStream.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + F6A7EECACBB4849DDD3F450A /* Pods-InteropTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTests/Pods-InteropTests.release.xcconfig"; sourceTree = ""; }; F9E48EF5ACB1F38825171C5F /* Pods-ChannelTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChannelTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests.debug.xcconfig"; sourceTree = ""; }; FBD98AC417B9882D32B19F28 /* libPods-CoreCronetEnd2EndTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CoreCronetEnd2EndTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; FD346DB2C23F676C4842F3FF /* libPods-InteropTestsLocalCleartext.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalCleartext.a"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -332,146 +180,23 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 5E0282EB215AA697007AC99D /* libTests.a in Frameworks */, CCF5C0719EF608276AE16374 /* libPods-UnitTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; - 5E3B959F21CAC6C500C0A151 /* Frameworks */ = { + 5E7F485622775B15006656AD /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 98478C9F42329DF769A45B6C /* libPods-APIv2Tests.a in Frameworks */, + 65EB19E418B39A8374D407BB /* libPods-CronetTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; - 5E7D71AF210B9EC8001EA6BA /* Frameworks */ = { + 5EA476F12272816A000F72FC /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 5E7D71B7210B9EC9001EA6BA /* libTests.a in Frameworks */, - 6C1A3F81CCF7C998B4813EFD /* libPods-InteropTestsCallOptions.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5E8A5DA11D3840B4000F8BC4 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 5E8A5DA91D3840B4000F8BC4 /* libTests.a in Frameworks */, - 60D2A57ED559F34428C2EEC5 /* libPods-CoreCronetEnd2EndTests.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EAD6D211E27047400002378 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 5EAD6D291E27047400002378 /* libTests.a in Frameworks */, - 06467F3A8D01EC493D12ADA2 /* libPods-CronetUnitTests.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EB2A2E12107DED300EB4B69 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 5EB2A2E92107DED300EB4B69 /* libTests.a in Frameworks */, - 1A0FB7F8C95A2F82538BC950 /* libPods-ChannelTests.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EB2A2F22109284500EB4B69 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 5EB2A2FA2109284500EB4B69 /* libTests.a in Frameworks */, - 886717A79EFF774F356798E6 /* libPods-InteropTestsMultipleChannels.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EC5E41E208177CC000EF4AD /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - BC111C80CBF7068B62869352 /* libPods-InteropTestsRemoteCFStream.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EC5E42E2081856B000EF4AD /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - C3D6F4270A2FFF634D8849ED /* libPods-InteropTestsLocalCleartextCFStream.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EC5E43F208185CE000EF4AD /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 91D4B3C85B6D8562F409CB48 /* libPods-InteropTestsLocalSSLCFStream.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EE84BEE1D4717E40050C6CC /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 5EE84BF61D4717E40050C6CC /* libTests.a in Frameworks */, - 09B76D9585ACE7403804D9DC /* libPods-InteropTestsRemoteWithCronet.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 63423F411B150A5F006CF63C /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 63423F4A1B150A5F006CF63C /* libTests.a in Frameworks */, - F15EF7852DC70770EFDB1D2C /* libPods-AllTests.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 635697C41B14FC11007A7283 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 63DC84101BE15179000708E8 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 63DC84181BE15179000708E8 /* libTests.a in Frameworks */, - 20DFDF829DD993A4A00D5662 /* libPods-RxLibraryUnitTests.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 63DC84201BE15267000708E8 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 63DC84281BE15267000708E8 /* libTests.a in Frameworks */, - 0F9232F984C08643FD40C34F /* libPods-InteropTestsRemote.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 63DC84311BE15294000708E8 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 63DC84391BE15294000708E8 /* libTests.a in Frameworks */, - 16A9E77B6E336B3C0B9BA6E0 /* libPods-InteropTestsLocalSSL.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 63DC84401BE152B5000708E8 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 63DC84481BE152B5000708E8 /* libTests.a in Frameworks */, - 333E8FC01C8285B7C547D799 /* libPods-InteropTestsLocalCleartext.a in Frameworks */, + 903163C7FE885838580AEC7A /* libPods-InteropTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -489,6 +214,7 @@ 136D535E19727099B941D7B1 /* Frameworks */ = { isa = PBXGroup; children = ( + 5E7F486622776AD8006656AD /* Cronet.framework */, 35F2B6BF3BAE8F0DC4AFD76E /* libPods.a */, CAE086D5B470DA367D415AB0 /* libPods-AllTests.a */, FD346DB2C23F676C4842F3FF /* libPods-InteropTestsLocalCleartext.a */, @@ -508,6 +234,8 @@ 22A3EBB488699C8CEA19707B /* libPods-UnitTests.a */, B6AD69CACF67505B0F028E92 /* libPods-APIv2Tests.a */, 276873A05AC5479B60DF6079 /* libPods-MacTests.a */, + D457AD9797664CFA191C3280 /* libPods-InteropTests.a */, + 1B1511C20E16A8422B58D61A /* libPods-CronetTests.a */, ); name = Frameworks; sourceTree = ""; @@ -585,6 +313,14 @@ 1F5E788FBF9A4A06EB9E1ACD /* Pods-MacTests.test.xcconfig */, 16A2E4C5839C83FBDA63881F /* Pods-MacTests.cronet.xcconfig */, 1E43EAE443CBB4482B1EB071 /* Pods-MacTests.release.xcconfig */, + 680439AC2BC8761EDD54A1EA /* Pods-InteropTests.debug.xcconfig */, + 070266E2626EB997B54880A3 /* Pods-InteropTests.test.xcconfig */, + CDF6CC70B8BF9D10EFE7D199 /* Pods-InteropTests.cronet.xcconfig */, + F6A7EECACBB4849DDD3F450A /* Pods-InteropTests.release.xcconfig */, + EC66920112123D2DB1CB7F6C /* Pods-CronetTests.debug.xcconfig */, + 5AB9A82F289D548D6B8816F9 /* Pods-CronetTests.test.xcconfig */, + 20F6A3D59D0EE091E2D43953 /* Pods-CronetTests.cronet.xcconfig */, + 7F4F42EBAF311E9F84FCA32E /* Pods-CronetTests.release.xcconfig */, ); name = Pods; sourceTree = ""; @@ -592,89 +328,50 @@ 5E0282E7215AA697007AC99D /* UnitTests */ = { isa = PBXGroup; children = ( - 5E0282E8215AA697007AC99D /* UnitTests.m */, - 5E0282EA215AA697007AC99D /* Info.plist */, + 5E7F488A22778B5D006656AD /* RxLibraryUnitTests.m */, + 5E7F488622778AEA006656AD /* GRPCClientTests.m */, + 5E7F487F227782C1006656AD /* APIv2Tests.m */, + 5E7F487B22778256006656AD /* ChannelPoolTest.m */, + 5E7F487C22778256006656AD /* ChannelTests.m */, + 5E0282E8215AA697007AC99D /* NSErrorUnitTests.m */, ); path = UnitTests; sourceTree = ""; }; - 5E3B95A321CAC6C500C0A151 /* APIv2Tests */ = { - isa = PBXGroup; - children = ( - 5E3B95A421CAC6C500C0A151 /* APIv2Tests.m */, - 5E3B95A621CAC6C500C0A151 /* Info.plist */, - ); - path = APIv2Tests; - sourceTree = ""; - }; - 5E7D71B3210B9EC9001EA6BA /* InteropTestsCallOptions */ = { - isa = PBXGroup; - children = ( - 5E7D71B4210B9EC9001EA6BA /* InteropTestsCallOptions.m */, - 5E7D71B6210B9EC9001EA6BA /* Info.plist */, - ); - path = InteropTestsCallOptions; - sourceTree = ""; - }; - 5E8A5DA51D3840B4000F8BC4 /* CoreCronetEnd2EndTests */ = { - isa = PBXGroup; - children = ( - 5E8A5DA61D3840B4000F8BC4 /* CoreCronetEnd2EndTests.mm */, - ); - path = CoreCronetEnd2EndTests; - sourceTree = ""; - }; - 5EAD6D251E27047400002378 /* CronetUnitTests */ = { - isa = PBXGroup; - children = ( - 5EAD6D261E27047400002378 /* CronetUnitTests.m */, - 5EAD6D281E27047400002378 /* Info.plist */, - ); - path = CronetUnitTests; - sourceTree = ""; - }; - 5EB2A2E52107DED300EB4B69 /* ChannelTests */ = { - isa = PBXGroup; - children = ( - 5EB5C3A921656CEA00ADC300 /* ChannelPoolTest.m */, - 5EB2A2E62107DED300EB4B69 /* ChannelTests.m */, - 5EB2A2E82107DED300EB4B69 /* Info.plist */, - ); - path = ChannelTests; - sourceTree = ""; - }; - 5EB2A2F62109284500EB4B69 /* InteropTestsMultipleChannels */ = { - isa = PBXGroup; - children = ( - 5EB2A2F72109284500EB4B69 /* InteropTestsMultipleChannels.m */, - 5EB2A2F92109284500EB4B69 /* Info.plist */, - ); - path = InteropTestsMultipleChannels; - sourceTree = ""; - }; - 5EE84BF21D4717E40050C6CC /* InteropTestsRemoteWithCronet */ = { + 5E7F485A22775B15006656AD /* CronetTests */ = { isa = PBXGroup; children = ( 5EE84BF31D4717E40050C6CC /* InteropTestsRemoteWithCronet.m */, - 5EE84BF51D4717E40050C6CC /* Info.plist */, + 5E7F486D22778086006656AD /* CoreCronetEnd2EndTests.mm */, + 5EAD6D261E27047400002378 /* CronetUnitTests.mm */, ); - path = InteropTestsRemoteWithCronet; + path = CronetTests; + sourceTree = ""; + }; + 5E7F48762277820F006656AD /* InteropTests */ = { + isa = PBXGroup; + children = ( + 5E7F488822778B04006656AD /* InteropTestsRemote.m */, + 5E7F488122778A88006656AD /* InteropTests.h */, + 5E7F488222778A88006656AD /* InteropTests.m */, + 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */, + 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */, + 5E7F487722778226006656AD /* InteropTestsMultipleChannels.m */, + 5E3F14822278B42D007C6D90 /* InteropTestsBlockCallbacks.h */, + 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */, + ); + path = InteropTests; sourceTree = ""; }; 635697BE1B14FC11007A7283 = { isa = PBXGroup; children = ( + 5E7F48762277820F006656AD /* InteropTests */, 635697C91B14FC11007A7283 /* Tests */, 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */, - 5E8A5DA51D3840B4000F8BC4 /* CoreCronetEnd2EndTests */, - 5EE84BF21D4717E40050C6CC /* InteropTestsRemoteWithCronet */, - 5EAD6D251E27047400002378 /* CronetUnitTests */, - 5EB2A2E52107DED300EB4B69 /* ChannelTests */, - 5EB2A2F62109284500EB4B69 /* InteropTestsMultipleChannels */, - 5E7D71B3210B9EC9001EA6BA /* InteropTestsCallOptions */, 5E0282E7215AA697007AC99D /* UnitTests */, - 5E3B95A321CAC6C500C0A151 /* APIv2Tests */, B0BB3EF8225E795F008DA580 /* MacTests */, + 5E7F485A22775B15006656AD /* CronetTests */, 635697C81B14FC11007A7283 /* Products */, 51E4650F34F854F41FF053B3 /* Pods */, 136D535E19727099B941D7B1 /* Frameworks */, @@ -684,24 +381,10 @@ 635697C81B14FC11007A7283 /* Products */ = { isa = PBXGroup; children = ( - 635697C71B14FC11007A7283 /* libTests.a */, - 63423F441B150A5F006CF63C /* AllTests.xctest */, - 63DC84131BE15179000708E8 /* RxLibraryUnitTests.xctest */, - 63DC84231BE15267000708E8 /* InteropTestsRemote.xctest */, - 63DC84341BE15294000708E8 /* InteropTestsLocalSSL.xctest */, - 63DC84431BE152B5000708E8 /* InteropTestsLocalCleartext.xctest */, - 5E8A5DA41D3840B4000F8BC4 /* CoreCronetEnd2EndTests.xctest */, - 5EE84BF11D4717E40050C6CC /* InteropTestsRemoteWithCronet.xctest */, - 5EAD6D241E27047400002378 /* CronetUnitTests.xctest */, - 5EC5E421208177CC000EF4AD /* InteropTestsRemoteCFStream.xctest */, - 5EC5E4312081856B000EF4AD /* InteropTestsLocalCleartextCFStream.xctest */, - 5EC5E442208185CE000EF4AD /* InteropTestsLocalSSLCFStream.xctest */, - 5EB2A2E42107DED300EB4B69 /* ChannelTests.xctest */, - 5EB2A2F52109284500EB4B69 /* InteropTestsMultipleChannels.xctest */, - 5E7D71B2210B9EC8001EA6BA /* InteropTestsCallOptions.xctest */, 5E0282E6215AA697007AC99D /* UnitTests.xctest */, - 5E3B95A221CAC6C500C0A151 /* APIv2Tests.xctest */, B0BB3EF7225E795F008DA580 /* MacTests.xctest */, + 5EA476F42272816A000F72FC /* InteropTests.xctest */, + 5E7F485922775B15006656AD /* CronetTests.xctest */, ); name = Products; sourceTree = ""; @@ -710,14 +393,6 @@ isa = PBXGroup; children = ( 5EAFE8271F8EFB87007F2189 /* version.h */, - 6312AE4D1B1BF49B00341DEE /* GRPCClientTests.m */, - 63E240CC1B6C4D3A005F3B0E /* InteropTests.h */, - 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */, - 6379CC4F1BE16703001BC0A1 /* InteropTestsRemote.m */, - 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */, - 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */, - 63423F501B151B77006CF63C /* RxLibraryUnitTests.m */, - 635697CC1B14FC11007A7283 /* Tests.m */, 635697D71B14FC11007A7283 /* Supporting Files */, ); name = Tests; @@ -759,326 +434,50 @@ buildRules = ( ); dependencies = ( - 5E0282ED215AA697007AC99D /* PBXTargetDependency */, ); name = UnitTests; productName = UnitTests; productReference = 5E0282E6215AA697007AC99D /* UnitTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; - 5E3B95A121CAC6C500C0A151 /* APIv2Tests */ = { + 5E7F485822775B15006656AD /* CronetTests */ = { isa = PBXNativeTarget; - buildConfigurationList = 5E3B95A721CAC6C500C0A151 /* Build configuration list for PBXNativeTarget "APIv2Tests" */; + buildConfigurationList = 5E7F485E22775B15006656AD /* Build configuration list for PBXNativeTarget "CronetTests" */; buildPhases = ( - EDDD3FA856BCA3443ED36D1E /* [CP] Check Pods Manifest.lock */, - 5E3B959E21CAC6C500C0A151 /* Sources */, - 5E3B959F21CAC6C500C0A151 /* Frameworks */, - 5E3B95A021CAC6C500C0A151 /* Resources */, - C17B826BBD02FDD4A5F355AF /* [CP] Copy Pods Resources */, + CCAEC0F23E05489651A07D53 /* [CP] Check Pods Manifest.lock */, + 5E7F485522775B15006656AD /* Sources */, + 5E7F485622775B15006656AD /* Frameworks */, + 5E7F485722775B15006656AD /* Resources */, + 292EA42A76AC7933A37235FD /* [CP] Embed Pods Frameworks */, + 30AFD6F6FC40B9923632A866 /* [CP] Copy Pods Resources */, ); buildRules = ( ); dependencies = ( ); - name = APIv2Tests; - productName = APIv2Tests; - productReference = 5E3B95A221CAC6C500C0A151 /* APIv2Tests.xctest */; + name = CronetTests; + productName = CronetTests; + productReference = 5E7F485922775B15006656AD /* CronetTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; - 5E7D71B1210B9EC8001EA6BA /* InteropTestsCallOptions */ = { + 5EA476F32272816A000F72FC /* InteropTests */ = { isa = PBXNativeTarget; - buildConfigurationList = 5E7D71BA210B9EC9001EA6BA /* Build configuration list for PBXNativeTarget "InteropTestsCallOptions" */; + buildConfigurationList = 5EA477002272816B000F72FC /* Build configuration list for PBXNativeTarget "InteropTests" */; buildPhases = ( - 2865C6386D677998F861E183 /* [CP] Check Pods Manifest.lock */, - 5E7D71AE210B9EC8001EA6BA /* Sources */, - 5E7D71AF210B9EC8001EA6BA /* Frameworks */, - 5E7D71B0210B9EC8001EA6BA /* Resources */, - 6BA6D00B1816306453BF82D4 /* [CP] Copy Pods Resources */, - ); - buildRules = ( - ); - dependencies = ( - 5E7D71B9210B9EC9001EA6BA /* PBXTargetDependency */, - ); - name = InteropTestsCallOptions; - productName = InteropTestsCallOptions; - productReference = 5E7D71B2210B9EC8001EA6BA /* InteropTestsCallOptions.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 5E8A5DA31D3840B4000F8BC4 /* CoreCronetEnd2EndTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 5E8A5DAE1D3840B4000F8BC4 /* Build configuration list for PBXNativeTarget "CoreCronetEnd2EndTests" */; - buildPhases = ( - F58F17E425446B15028B9F74 /* [CP] Check Pods Manifest.lock */, - 5E8A5DA01D3840B4000F8BC4 /* Sources */, - 5E8A5DA11D3840B4000F8BC4 /* Frameworks */, - 5E8A5DA21D3840B4000F8BC4 /* Resources */, - E63468C760D0724F18861822 /* [CP] Embed Pods Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 5E8A5DAB1D3840B4000F8BC4 /* PBXTargetDependency */, - ); - name = CoreCronetEnd2EndTests; - productName = CoreCronetEnd2EndTests; - productReference = 5E8A5DA41D3840B4000F8BC4 /* CoreCronetEnd2EndTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 5EAD6D231E27047400002378 /* CronetUnitTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 5EAD6D2F1E27047400002378 /* Build configuration list for PBXNativeTarget "CronetUnitTests" */; - buildPhases = ( - 80E2DDD2EC04A4009F45E933 /* [CP] Check Pods Manifest.lock */, - 5EAD6D201E27047400002378 /* Sources */, - 5EAD6D211E27047400002378 /* Frameworks */, - 5EAD6D221E27047400002378 /* Resources */, - A686B9967BB4CB81B1CBF8F8 /* [CP] Embed Pods Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 5EAD6D2B1E27047400002378 /* PBXTargetDependency */, - ); - name = CronetUnitTests; - productName = CronetUnitTests; - productReference = 5EAD6D241E27047400002378 /* CronetUnitTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 5EB2A2E32107DED300EB4B69 /* ChannelTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 5EB2A2F02107DED300EB4B69 /* Build configuration list for PBXNativeTarget "ChannelTests" */; - buildPhases = ( - 021B3B1F545989843EBC9A4B /* [CP] Check Pods Manifest.lock */, - 5EB2A2E02107DED300EB4B69 /* Sources */, - 5EB2A2E12107DED300EB4B69 /* Frameworks */, - 5EB2A2E22107DED300EB4B69 /* Resources */, - 1EAF0CBDBFAB18D4DA64535D /* [CP] Copy Pods Resources */, - ); - buildRules = ( - ); - dependencies = ( - 5EB2A2EB2107DED300EB4B69 /* PBXTargetDependency */, - ); - name = ChannelTests; - productName = ChannelTests; - productReference = 5EB2A2E42107DED300EB4B69 /* ChannelTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 5EB2A2F42109284500EB4B69 /* InteropTestsMultipleChannels */ = { - isa = PBXNativeTarget; - buildConfigurationList = 5EB2A3012109284500EB4B69 /* Build configuration list for PBXNativeTarget "InteropTestsMultipleChannels" */; - buildPhases = ( - 8C1ED025E07C4D457C355336 /* [CP] Check Pods Manifest.lock */, - 5EB2A2F12109284500EB4B69 /* Sources */, - 5EB2A2F22109284500EB4B69 /* Frameworks */, - 5EB2A2F32109284500EB4B69 /* Resources */, - 8D685CB612835DB3F7A6F14A /* [CP] Embed Pods Frameworks */, - 0617B5294978A95BEBBFF733 /* [CP] Copy Pods Resources */, - ); - buildRules = ( - ); - dependencies = ( - 5EB2A2FC2109284500EB4B69 /* PBXTargetDependency */, - ); - name = InteropTestsMultipleChannels; - productName = InteropTestsMultipleChannels; - productReference = 5EB2A2F52109284500EB4B69 /* InteropTestsMultipleChannels.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 5EC5E420208177CC000EF4AD /* InteropTestsRemoteCFStream */ = { - isa = PBXNativeTarget; - buildConfigurationList = 5EC5E42A208177CD000EF4AD /* Build configuration list for PBXNativeTarget "InteropTestsRemoteCFStream" */; - buildPhases = ( - 483CDBBAEAEFCB530ADDDDD5 /* [CP] Check Pods Manifest.lock */, - 5EC5E41D208177CC000EF4AD /* Sources */, - 5EC5E41E208177CC000EF4AD /* Frameworks */, - 5EC5E41F208177CC000EF4AD /* Resources */, - 95FBC48B743503845678584F /* [CP] Copy Pods Resources */, + 40BCDB09674DF988C708D22B /* [CP] Check Pods Manifest.lock */, + 5EA476F02272816A000F72FC /* Sources */, + 5EA476F12272816A000F72FC /* Frameworks */, + 5EA476F22272816A000F72FC /* Resources */, + D11CB94CF56A1E53760D29D8 /* [CP] Copy Pods Resources */, + 0FEFD5FC6B323AC95549AE4A /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); dependencies = ( ); - name = InteropTestsRemoteCFStream; - productName = InteropTestsRemoteCFStream; - productReference = 5EC5E421208177CC000EF4AD /* InteropTestsRemoteCFStream.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 5EC5E4302081856B000EF4AD /* InteropTestsLocalCleartextCFStream */ = { - isa = PBXNativeTarget; - buildConfigurationList = 5EC5E4362081856C000EF4AD /* Build configuration list for PBXNativeTarget "InteropTestsLocalCleartextCFStream" */; - buildPhases = ( - 252A376345E38FD452A89C3D /* [CP] Check Pods Manifest.lock */, - 5EC5E42D2081856B000EF4AD /* Sources */, - 5EC5E42E2081856B000EF4AD /* Frameworks */, - 5EC5E42F2081856B000EF4AD /* Resources */, - A023FB55205A7EA37D413549 /* [CP] Copy Pods Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = InteropTestsLocalCleartextCFStream; - productName = InteropTestsLocalCleartextCFStream; - productReference = 5EC5E4312081856B000EF4AD /* InteropTestsLocalCleartextCFStream.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 5EC5E441208185CE000EF4AD /* InteropTestsLocalSSLCFStream */ = { - isa = PBXNativeTarget; - buildConfigurationList = 5EC5E447208185CE000EF4AD /* Build configuration list for PBXNativeTarget "InteropTestsLocalSSLCFStream" */; - buildPhases = ( - F3D5B2CDA172580341682830 /* [CP] Check Pods Manifest.lock */, - 5EC5E43E208185CE000EF4AD /* Sources */, - 5EC5E43F208185CE000EF4AD /* Frameworks */, - 5EC5E440208185CE000EF4AD /* Resources */, - 4EB2FFF40BB00AD0C545D7EF /* [CP] Copy Pods Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = InteropTestsLocalSSLCFStream; - productName = InteropTestsLocalSSLCFStream; - productReference = 5EC5E442208185CE000EF4AD /* InteropTestsLocalSSLCFStream.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 5EE84BF01D4717E40050C6CC /* InteropTestsRemoteWithCronet */ = { - isa = PBXNativeTarget; - buildConfigurationList = 5EE84BFB1D4717E40050C6CC /* Build configuration list for PBXNativeTarget "InteropTestsRemoteWithCronet" */; - buildPhases = ( - C0F7B1FF6F88CC5FBF362F4C /* [CP] Check Pods Manifest.lock */, - 5EE84BED1D4717E40050C6CC /* Sources */, - 5EE84BEE1D4717E40050C6CC /* Frameworks */, - 5EE84BEF1D4717E40050C6CC /* Resources */, - 31F8D1C407195CBF0C02929B /* [CP] Embed Pods Frameworks */, - DB4D0E73C229F2FF3B364AB3 /* [CP] Copy Pods Resources */, - ); - buildRules = ( - ); - dependencies = ( - 5EE84BF81D4717E40050C6CC /* PBXTargetDependency */, - ); - name = InteropTestsRemoteWithCronet; - productName = InteropTestsRemoteWithCronet; - productReference = 5EE84BF11D4717E40050C6CC /* InteropTestsRemoteWithCronet.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 63423F431B150A5F006CF63C /* AllTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 63423F4D1B150A5F006CF63C /* Build configuration list for PBXNativeTarget "AllTests" */; - buildPhases = ( - 914ADDD7106BA9BB8A7E569F /* [CP] Check Pods Manifest.lock */, - 63423F401B150A5F006CF63C /* Sources */, - 63423F411B150A5F006CF63C /* Frameworks */, - 63423F421B150A5F006CF63C /* Resources */, - A441F71824DCB9D0CA297748 /* [CP] Copy Pods Resources */, - ); - buildRules = ( - ); - dependencies = ( - 63423F4C1B150A5F006CF63C /* PBXTargetDependency */, - ); - name = AllTests; - productName = AllTests; - productReference = 63423F441B150A5F006CF63C /* AllTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 635697C61B14FC11007A7283 /* Tests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 635697DB1B14FC11007A7283 /* Build configuration list for PBXNativeTarget "Tests" */; - buildPhases = ( - 635697C31B14FC11007A7283 /* Sources */, - 635697C41B14FC11007A7283 /* Frameworks */, - 635697C51B14FC11007A7283 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = Tests; - productName = Tests; - productReference = 635697C71B14FC11007A7283 /* libTests.a */; - productType = "com.apple.product-type.library.static"; - }; - 63DC84121BE15179000708E8 /* RxLibraryUnitTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 63DC841B1BE15179000708E8 /* Build configuration list for PBXNativeTarget "RxLibraryUnitTests" */; - buildPhases = ( - B2986CEEE8CDD4901C97598B /* [CP] Check Pods Manifest.lock */, - 63DC840F1BE15179000708E8 /* Sources */, - 63DC84101BE15179000708E8 /* Frameworks */, - 63DC84111BE15179000708E8 /* Resources */, - C977426A8727267BBAC7D48E /* [CP] Copy Pods Resources */, - ); - buildRules = ( - ); - dependencies = ( - 63DC841A1BE15179000708E8 /* PBXTargetDependency */, - ); - name = RxLibraryUnitTests; - productName = RxLibraryUnitTests; - productReference = 63DC84131BE15179000708E8 /* RxLibraryUnitTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 63DC84221BE15267000708E8 /* InteropTestsRemote */ = { - isa = PBXNativeTarget; - buildConfigurationList = 63DC842B1BE15267000708E8 /* Build configuration list for PBXNativeTarget "InteropTestsRemote" */; - buildPhases = ( - 4C406327D3907A5E5FBA8AC9 /* [CP] Check Pods Manifest.lock */, - 63DC841F1BE15267000708E8 /* Sources */, - 63DC84201BE15267000708E8 /* Frameworks */, - 63DC84211BE15267000708E8 /* Resources */, - C2E09DC4BD239F71160F0CC1 /* [CP] Copy Pods Resources */, - ); - buildRules = ( - ); - dependencies = ( - 63DC842A1BE15267000708E8 /* PBXTargetDependency */, - ); - name = InteropTestsRemote; + name = InteropTests; productName = InteropTests; - productReference = 63DC84231BE15267000708E8 /* InteropTestsRemote.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 63DC84331BE15294000708E8 /* InteropTestsLocalSSL */ = { - isa = PBXNativeTarget; - buildConfigurationList = 63DC843C1BE15294000708E8 /* Build configuration list for PBXNativeTarget "InteropTestsLocalSSL" */; - buildPhases = ( - 5C20DCCB71C3991E6FE78C22 /* [CP] Check Pods Manifest.lock */, - 63DC84301BE15294000708E8 /* Sources */, - 63DC84311BE15294000708E8 /* Frameworks */, - 63DC84321BE15294000708E8 /* Resources */, - 693DD0B453431D64EA24FD66 /* [CP] Copy Pods Resources */, - ); - buildRules = ( - ); - dependencies = ( - 63DC843B1BE15294000708E8 /* PBXTargetDependency */, - ); - name = InteropTestsLocalSSL; - productName = InteropTestsLocalSSL; - productReference = 63DC84341BE15294000708E8 /* InteropTestsLocalSSL.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 63DC84421BE152B5000708E8 /* InteropTestsLocalCleartext */ = { - isa = PBXNativeTarget; - buildConfigurationList = 63DC844B1BE152B5000708E8 /* Build configuration list for PBXNativeTarget "InteropTestsLocalCleartext" */; - buildPhases = ( - 7418AC7B3844B29E48D24FC7 /* [CP] Check Pods Manifest.lock */, - 63DC843F1BE152B5000708E8 /* Sources */, - 63DC84401BE152B5000708E8 /* Frameworks */, - 63DC84411BE152B5000708E8 /* Resources */, - 8AD3130D3C58A0FB32FF2A36 /* [CP] Copy Pods Resources */, - ); - buildRules = ( - ); - dependencies = ( - 63DC844A1BE152B5000708E8 /* PBXTargetDependency */, - ); - name = InteropTestsLocalCleartext; - productName = InteropTestsLocalCleartext; - productReference = 63DC84431BE152B5000708E8 /* InteropTestsLocalCleartext.xctest */; + productReference = 5EA476F42272816A000F72FC /* InteropTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; B0BB3EF6225E795F008DA580 /* MacTests */ = { @@ -1113,61 +512,14 @@ CreatedOnToolsVersion = 9.2; ProvisioningStyle = Automatic; }; - 5E3B95A121CAC6C500C0A151 = { - CreatedOnToolsVersion = 10.0; + 5E7F485822775B15006656AD = { + CreatedOnToolsVersion = 10.1; ProvisioningStyle = Automatic; }; - 5E7D71B1210B9EC8001EA6BA = { - CreatedOnToolsVersion = 9.3; + 5EA476F32272816A000F72FC = { + CreatedOnToolsVersion = 10.1; ProvisioningStyle = Automatic; }; - 5E8A5DA31D3840B4000F8BC4 = { - CreatedOnToolsVersion = 7.3.1; - }; - 5EAD6D231E27047400002378 = { - CreatedOnToolsVersion = 7.3.1; - }; - 5EB2A2E32107DED300EB4B69 = { - CreatedOnToolsVersion = 9.3; - ProvisioningStyle = Automatic; - }; - 5EB2A2F42109284500EB4B69 = { - CreatedOnToolsVersion = 9.3; - ProvisioningStyle = Automatic; - }; - 5EC5E420208177CC000EF4AD = { - CreatedOnToolsVersion = 9.2; - ProvisioningStyle = Automatic; - }; - 5EC5E4302081856B000EF4AD = { - CreatedOnToolsVersion = 9.2; - ProvisioningStyle = Automatic; - }; - 5EC5E441208185CE000EF4AD = { - CreatedOnToolsVersion = 9.2; - ProvisioningStyle = Automatic; - }; - 5EE84BF01D4717E40050C6CC = { - CreatedOnToolsVersion = 7.3.1; - }; - 63423F431B150A5F006CF63C = { - CreatedOnToolsVersion = 6.3.1; - }; - 635697C61B14FC11007A7283 = { - CreatedOnToolsVersion = 6.3.1; - }; - 63DC84121BE15179000708E8 = { - CreatedOnToolsVersion = 7.0.1; - }; - 63DC84221BE15267000708E8 = { - CreatedOnToolsVersion = 7.0.1; - }; - 63DC84331BE15294000708E8 = { - CreatedOnToolsVersion = 7.0.1; - }; - 63DC84421BE152B5000708E8 = { - CreatedOnToolsVersion = 7.0.1; - }; B0BB3EF6225E795F008DA580 = { CreatedOnToolsVersion = 10.1; ProvisioningStyle = Automatic; @@ -1186,24 +538,10 @@ projectDirPath = ""; projectRoot = ""; targets = ( - 635697C61B14FC11007A7283 /* Tests */, - 63423F431B150A5F006CF63C /* AllTests */, - 63DC84121BE15179000708E8 /* RxLibraryUnitTests */, - 63DC84221BE15267000708E8 /* InteropTestsRemote */, - 63DC84331BE15294000708E8 /* InteropTestsLocalSSL */, - 63DC84421BE152B5000708E8 /* InteropTestsLocalCleartext */, - 5E8A5DA31D3840B4000F8BC4 /* CoreCronetEnd2EndTests */, - 5EE84BF01D4717E40050C6CC /* InteropTestsRemoteWithCronet */, - 5EAD6D231E27047400002378 /* CronetUnitTests */, - 5EC5E420208177CC000EF4AD /* InteropTestsRemoteCFStream */, - 5EC5E4302081856B000EF4AD /* InteropTestsLocalCleartextCFStream */, - 5EC5E441208185CE000EF4AD /* InteropTestsLocalSSLCFStream */, - 5EB2A2E32107DED300EB4B69 /* ChannelTests */, - 5EB2A2F42109284500EB4B69 /* InteropTestsMultipleChannels */, - 5E7D71B1210B9EC8001EA6BA /* InteropTestsCallOptions */, 5E0282E5215AA697007AC99D /* UnitTests */, - 5E3B95A121CAC6C500C0A151 /* APIv2Tests */, B0BB3EF6225E795F008DA580 /* MacTests */, + 5EA476F32272816A000F72FC /* InteropTests */, + 5E7F485822775B15006656AD /* CronetTests */, ); }; /* End PBXProject section */ @@ -1216,112 +554,18 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 5E3B95A021CAC6C500C0A151 /* Resources */ = { + 5E7F485722775B15006656AD /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; - 5E7D71B0210B9EC8001EA6BA /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5E8A5DA21D3840B4000F8BC4 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EAD6D221E27047400002378 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EB2A2E22107DED300EB4B69 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EB2A2F32109284500EB4B69 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 5E7D71AD210954A8001EA6BA /* TestCertificates.bundle in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EC5E41F208177CC000EF4AD /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EC5E42F2081856B000EF4AD /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EC5E440208185CE000EF4AD /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 5EC5E44E20818948000EF4AD /* TestCertificates.bundle in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EE84BEF1D4717E40050C6CC /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 63423F421B150A5F006CF63C /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 63E240D01B6C63DC005F3B0E /* TestCertificates.bundle in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 63DC84111BE15179000708E8 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 63DC84211BE15267000708E8 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 63DC84321BE15294000708E8 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 6379CC531BE17709001BC0A1 /* TestCertificates.bundle in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 63DC84411BE152B5000708E8 /* Resources */ = { + 5EA476F22272816A000F72FC /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 5EA4770522736AC4000F72FC /* TestCertificates.bundle in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1336,112 +580,92 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 021B3B1F545989843EBC9A4B /* [CP] Check Pods Manifest.lock */ = { + 0FEFD5FC6B323AC95549AE4A /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-ChannelTests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 0617B5294978A95BEBBFF733 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( + inputFileListPaths = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 1EAF0CBDBFAB18D4DA64535D /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 252A376345E38FD452A89C3D /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-InteropTestsLocalCleartextCFStream-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 2865C6386D677998F861E183 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-InteropTestsCallOptions-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 31F8D1C407195CBF0C02929B /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet-frameworks.sh", + "${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-frameworks.sh", "${PODS_ROOT}/CronetFramework/Cronet.framework", ); name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + ); outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 292EA42A76AC7933A37235FD /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-frameworks.sh", + "${PODS_ROOT}/CronetFramework/Cronet.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + ); + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 30AFD6F6FC40B9923632A866 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-resources.sh", + "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + ); + outputPaths = ( + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 40BCDB09674DF988C708D22B /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-InteropTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; 452FDC3918FEC23ECAFD31EC /* [CP] Copy Pods Resources */ = { @@ -1452,7 +676,7 @@ inputFileListPaths = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-MacTests/Pods-MacTests-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-MacTests/Pods-MacTests-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-macOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; @@ -1463,241 +687,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-MacTests/Pods-MacTests-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 483CDBBAEAEFCB530ADDDDD5 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-InteropTestsRemoteCFStream-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 4C406327D3907A5E5FBA8AC9 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-InteropTestsRemote-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 4EB2FFF40BB00AD0C545D7EF /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 5C20DCCB71C3991E6FE78C22 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-InteropTestsLocalSSL-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 693DD0B453431D64EA24FD66 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 6BA6D00B1816306453BF82D4 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 7418AC7B3844B29E48D24FC7 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-InteropTestsLocalCleartext-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 80E2DDD2EC04A4009F45E933 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-CronetUnitTests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 8AD3130D3C58A0FB32FF2A36 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 8C1ED025E07C4D457C355336 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-InteropTestsMultipleChannels-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 8D685CB612835DB3F7A6F14A /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels-frameworks.sh", - "${PODS_ROOT}/CronetFramework/Cronet.framework", - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - 914ADDD7106BA9BB8A7E569F /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-AllTests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 95FBC48B743503845678584F /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MacTests/Pods-MacTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; 9AD0B5E94F2AA5962EA6AA36 /* [CP] Copy Pods Resources */ = { @@ -1706,7 +696,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-UnitTests/Pods-UnitTests-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; @@ -1715,100 +705,10 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-UnitTests/Pods-UnitTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; - A023FB55205A7EA37D413549 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - A441F71824DCB9D0CA297748 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-AllTests/Pods-AllTests-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AllTests/Pods-AllTests-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - A686B9967BB4CB81B1CBF8F8 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests-frameworks.sh", - "${PODS_ROOT}/CronetFramework/Cronet.framework", - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - B2986CEEE8CDD4901C97598B /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-RxLibraryUnitTests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - C0F7B1FF6F88CC5FBF362F4C /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-InteropTestsRemoteWithCronet-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - C17B826BBD02FDD4A5F355AF /* [CP] Copy Pods Resources */ = { + CCAEC0F23E05489651A07D53 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -1816,7 +716,29 @@ inputFileListPaths = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests-resources.sh", + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-CronetTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + D11CB94CF56A1E53760D29D8 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; @@ -1827,61 +749,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - C2E09DC4BD239F71160F0CC1 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - C977426A8727267BBAC7D48E /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - DB4D0E73C229F2FF3B364AB3 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; E5B20F69559C6AE299DFEA7C /* [CP] Check Pods Manifest.lock */ = { @@ -1906,46 +774,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - E63468C760D0724F18861822 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests-frameworks.sh", - "${PODS_ROOT}/CronetFramework/Cronet.framework", - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - EDDD3FA856BCA3443ED36D1E /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-APIv2Tests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; F07941C0BAF6A7C67AA60C48 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -1964,42 +792,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - F3D5B2CDA172580341682830 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-InteropTestsLocalSSLCFStream-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - F58F17E425446B15028B9F74 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-CoreCronetEnd2EndTests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -2007,150 +799,37 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 5E0282E9215AA697007AC99D /* UnitTests.m in Sources */, + 5E0282E9215AA697007AC99D /* NSErrorUnitTests.m in Sources */, + 5E7F4880227782C1006656AD /* APIv2Tests.m in Sources */, + 5E7F487D22778256006656AD /* ChannelPoolTest.m in Sources */, + 5E7F488722778AEA006656AD /* GRPCClientTests.m in Sources */, + 5E7F487E22778256006656AD /* ChannelTests.m in Sources */, + 5E7F488B22778B5D006656AD /* RxLibraryUnitTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; - 5E3B959E21CAC6C500C0A151 /* Sources */ = { + 5E7F485522775B15006656AD /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 5E3B95A521CAC6C500C0A151 /* APIv2Tests.m in Sources */, + 5E3F14852278BF5D007C6D90 /* InteropTestsBlockCallbacks.m in Sources */, + 5E7F486E22778086006656AD /* CoreCronetEnd2EndTests.mm in Sources */, + 5E7F488522778A88006656AD /* InteropTests.m in Sources */, + 5E7F486422775B37006656AD /* InteropTestsRemoteWithCronet.m in Sources */, + 5E7F486522775B41006656AD /* CronetUnitTests.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; - 5E7D71AE210B9EC8001EA6BA /* Sources */ = { + 5EA476F02272816A000F72FC /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 5E7D71B5210B9EC9001EA6BA /* InteropTestsCallOptions.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5E8A5DA01D3840B4000F8BC4 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 5E8A5DA71D3840B4000F8BC4 /* CoreCronetEnd2EndTests.mm in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EAD6D201E27047400002378 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 5EAD6D271E27047400002378 /* CronetUnitTests.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EB2A2E02107DED300EB4B69 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 5EB2A2E72107DED300EB4B69 /* ChannelTests.m in Sources */, - 5EB5C3AA21656CEA00ADC300 /* ChannelPoolTest.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EB2A2F12109284500EB4B69 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 5EB2A2F82109284500EB4B69 /* InteropTestsMultipleChannels.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EC5E41D208177CC000EF4AD /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 5EC5E42B2081782C000EF4AD /* InteropTestsRemote.m in Sources */, - 5EC5E42C20817832000EF4AD /* InteropTests.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EC5E42D2081856B000EF4AD /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 5EC5E43B208185A7000EF4AD /* InteropTestsLocalCleartext.m in Sources */, - 5EC5E43D208185B0000EF4AD /* GRPCClientTests.m in Sources */, - 5EC5E43C208185AD000EF4AD /* InteropTests.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EC5E43E208185CE000EF4AD /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 5EC5E44D208185F0000EF4AD /* InteropTestsLocalSSL.m in Sources */, - 5EC5E44C208185EC000EF4AD /* InteropTests.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 5EE84BED1D4717E40050C6CC /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 5EE84BFE1D471D400050C6CC /* InteropTests.m in Sources */, - 5EE84BF41D4717E40050C6CC /* InteropTestsRemoteWithCronet.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 63423F401B150A5F006CF63C /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 63715F561B780C020029CB0B /* InteropTestsLocalCleartext.m in Sources */, - 6379CC511BE1683B001BC0A1 /* InteropTestsRemote.m in Sources */, - 63E240CE1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m in Sources */, - 6312AE4E1B1BF49B00341DEE /* GRPCClientTests.m in Sources */, - 635ED2EC1B1A3BC400FDE5C3 /* InteropTests.m in Sources */, - 63DC842E1BE15278000708E8 /* RxLibraryUnitTests.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 635697C31B14FC11007A7283 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 635697CD1B14FC11007A7283 /* Tests.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 63DC840F1BE15179000708E8 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 63DC841E1BE15180000708E8 /* RxLibraryUnitTests.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 63DC841F1BE15267000708E8 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 63DC842F1BE1527D000708E8 /* InteropTests.m in Sources */, - 6379CC501BE16703001BC0A1 /* InteropTestsRemote.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 63DC84301BE15294000708E8 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 63DC844F1BE15353000708E8 /* InteropTestsLocalSSL.m in Sources */, - 6379CC4D1BE1662A001BC0A1 /* InteropTests.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 63DC843F1BE152B5000708E8 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 63DC84501BE153AA000708E8 /* GRPCClientTests.m in Sources */, - 63DC844E1BE15350000708E8 /* InteropTestsLocalCleartext.m in Sources */, - 6379CC4E1BE1662B001BC0A1 /* InteropTests.m in Sources */, + 5E3F14842278B461007C6D90 /* InteropTestsBlockCallbacks.m in Sources */, + 5E7F488922778B04006656AD /* InteropTestsRemote.m in Sources */, + 5E7F487922778226006656AD /* InteropTestsMultipleChannels.m in Sources */, + 5EA477042273617B000F72FC /* InteropTestsLocalCleartext.m in Sources */, + 5EA4770322736178000F72FC /* InteropTestsLocalSSL.m in Sources */, + 5E7F488422778A88006656AD /* InteropTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2158,85 +837,22 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - B0BB3F07225E7AB5008DA580 /* APIv2Tests.m in Sources */, - B0BB3F08225E7ABA008DA580 /* UnitTests.m in Sources */, + B0BB3F08225E7ABA008DA580 /* NSErrorUnitTests.m in Sources */, + 5E7F488D22778C85006656AD /* InteropTestsLocalSSL.m in Sources */, + 5E7F488E22778C87006656AD /* InteropTestsLocalCleartext.m in Sources */, + 5E7F489022778C95006656AD /* RxLibraryUnitTests.m in Sources */, B071230B22669EED004B64A1 /* StressTests.m in Sources */, - B0BB3F05225E7A9F008DA580 /* InteropTestsRemote.m in Sources */, B0D39B9A2266F3CB00A4078D /* StressTestsSSL.m in Sources */, - B0BB3F03225E7A44008DA580 /* InteropTestsLocalCleartext.m in Sources */, - B0BB3F04225E7A8D008DA580 /* RxLibraryUnitTests.m in Sources */, + 5E7F488322778A88006656AD /* InteropTests.m in Sources */, + 5E3F14862278BFFF007C6D90 /* InteropTestsBlockCallbacks.m in Sources */, + 5E7F488C22778C60006656AD /* APIv2Tests.m in Sources */, + 5E7F488F22778C8C006656AD /* InteropTestsRemote.m in Sources */, B0D39B9C2266FF9800A4078D /* StressTestsCleartext.m in Sources */, - B0BB3F0B225EB110008DA580 /* InteropTests.m in Sources */, - B0BB3F02225E7A3C008DA580 /* InteropTestsLocalSSL.m in Sources */, - B0BB3F06225E7AAD008DA580 /* GRPCClientTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ -/* Begin PBXTargetDependency section */ - 5E0282ED215AA697007AC99D /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 635697C61B14FC11007A7283 /* Tests */; - targetProxy = 5E0282EC215AA697007AC99D /* PBXContainerItemProxy */; - }; - 5E7D71B9210B9EC9001EA6BA /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 635697C61B14FC11007A7283 /* Tests */; - targetProxy = 5E7D71B8210B9EC9001EA6BA /* PBXContainerItemProxy */; - }; - 5E8A5DAB1D3840B4000F8BC4 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 635697C61B14FC11007A7283 /* Tests */; - targetProxy = 5E8A5DAA1D3840B4000F8BC4 /* PBXContainerItemProxy */; - }; - 5EAD6D2B1E27047400002378 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 635697C61B14FC11007A7283 /* Tests */; - targetProxy = 5EAD6D2A1E27047400002378 /* PBXContainerItemProxy */; - }; - 5EB2A2EB2107DED300EB4B69 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 635697C61B14FC11007A7283 /* Tests */; - targetProxy = 5EB2A2EA2107DED300EB4B69 /* PBXContainerItemProxy */; - }; - 5EB2A2FC2109284500EB4B69 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 635697C61B14FC11007A7283 /* Tests */; - targetProxy = 5EB2A2FB2109284500EB4B69 /* PBXContainerItemProxy */; - }; - 5EE84BF81D4717E40050C6CC /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 635697C61B14FC11007A7283 /* Tests */; - targetProxy = 5EE84BF71D4717E40050C6CC /* PBXContainerItemProxy */; - }; - 63423F4C1B150A5F006CF63C /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 635697C61B14FC11007A7283 /* Tests */; - targetProxy = 63423F4B1B150A5F006CF63C /* PBXContainerItemProxy */; - }; - 63DC841A1BE15179000708E8 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 635697C61B14FC11007A7283 /* Tests */; - targetProxy = 63DC84191BE15179000708E8 /* PBXContainerItemProxy */; - }; - 63DC842A1BE15267000708E8 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 635697C61B14FC11007A7283 /* Tests */; - targetProxy = 63DC84291BE15267000708E8 /* PBXContainerItemProxy */; - }; - 63DC843B1BE15294000708E8 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 635697C61B14FC11007A7283 /* Tests */; - targetProxy = 63DC843A1BE15294000708E8 /* PBXContainerItemProxy */; - }; - 63DC844A1BE152B5000708E8 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 635697C61B14FC11007A7283 /* Tests */; - targetProxy = 63DC84491BE152B5000708E8 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - /* Begin XCBuildConfiguration section */ 5E0282EE215AA697007AC99D /* Debug */ = { isa = XCBuildConfiguration; @@ -2260,7 +876,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = UnitTests/Info.plist; + INFOPLIST_FILE = Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.grpc.UnitTests; @@ -2290,7 +906,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = UnitTests/Info.plist; + INFOPLIST_FILE = Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.grpc.UnitTests; @@ -2320,7 +936,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = UnitTests/Info.plist; + INFOPLIST_FILE = Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.grpc.UnitTests; @@ -2350,7 +966,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = UnitTests/Info.plist; + INFOPLIST_FILE = Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.grpc.UnitTests; @@ -2407,170 +1023,9 @@ }; name = Test; }; - 5E1228991E4D400F00E8504F /* Test */ = { + 5E7F485F22775B15006656AD /* Debug */ = { isa = XCBuildConfiguration; - buildSettings = { - GCC_TREAT_WARNINGS_AS_ERRORS = YES; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Test; - }; - 5E12289A1E4D400F00E8504F /* Test */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = DB1F4391AF69D20D38D74B67 /* Pods-AllTests.test.xcconfig */; - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - "GRPC_TEST_OBJC=1", - ); - INFOPLIST_FILE = Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Test; - }; - 5E12289B1E4D400F00E8504F /* Test */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 781089FAE980F51F88A3BE0B /* Pods-RxLibraryUnitTests.test.xcconfig */; - buildSettings = { - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.RxLibraryUnitTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Test; - }; - 5E12289C1E4D400F00E8504F /* Test */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = A6F832FCEFA6F6881E620F12 /* Pods-InteropTestsRemote.test.xcconfig */; - buildSettings = { - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COCOAPODS=1", - "$(inherited)", - "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1", - "GRPC_TEST_OBJC=1", - ); - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Test; - }; - 5E12289D1E4D400F00E8504F /* Test */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = D13BEC8181B8E678A1B52F54 /* Pods-InteropTestsLocalSSL.test.xcconfig */; - buildSettings = { - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COCOAPODS=1", - "$(inherited)", - "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1", - "GRPC_TEST_OBJC=1", - ); - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalSSL; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Test; - }; - 5E12289E1E4D400F00E8504F /* Test */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 1588C85DEAF7FC0ACDEA4C02 /* Pods-InteropTestsLocalCleartext.test.xcconfig */; - buildSettings = { - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COCOAPODS=1", - "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1", - "GRPC_TEST_OBJC=1", - ); - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalCleartext; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Test; - }; - 5E12289F1E4D400F00E8504F /* Test */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 6793C9D019CB268C5BB491A2 /* Pods-CoreCronetEnd2EndTests.test.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - INFOPLIST_FILE = CoreCronetEnd2EndTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CoreCronetEnd2EndTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - USER_HEADER_SEARCH_PATHS = "$(inherited) \"${PODS_ROOT}/../../../..\""; - }; - name = Test; - }; - 5E1228A01E4D400F00E8504F /* Test */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 2B89F3037963E6EDDD48D8C3 /* Pods-InteropTestsRemoteWithCronet.test.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COCOAPODS=1", - "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1", - "GRPC_TEST_OBJC=1", - ); - INFOPLIST_FILE = InteropTestsRemoteWithCronet/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsRemoteWithCronet; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Test; - }; - 5E1228A11E4D400F00E8504F /* Test */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = B226619DC4E709E0FFFF94B8 /* Pods-CronetUnitTests.test.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - GCC_INPUT_FILETYPE = sourcecode.cpp.objcpp; - INFOPLIST_FILE = CronetUnitTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CronetUnitTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - USER_HEADER_SEARCH_PATHS = "\"${PODS_ROOT}/../../../..\" $(inherited)"; - }; - name = Test; - }; - 5E3B95A821CAC6C500C0A151 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 1286B30AD74CB64CD91FB17D /* Pods-APIv2Tests.debug.xcconfig */; + baseConfigurationReference = EC66920112123D2DB1CB7F6C /* Pods-CronetTests.debug.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -2592,21 +1047,27 @@ CODE_SIGN_STYLE = Automatic; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_TESTABILITY = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Pods/CronetFramework", + ); GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = APIv2Tests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; + GCC_WARN_INHIBIT_ALL_WARNINGS = YES; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.APIv2Tests; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CronetTests; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = ../../..; }; name = Debug; }; - 5E3B95A921CAC6C500C0A151 /* Test */ = { + 5E7F486022775B15006656AD /* Test */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 51F2A64B7AADBA1B225B132E /* Pods-APIv2Tests.test.xcconfig */; + baseConfigurationReference = 5AB9A82F289D548D6B8816F9 /* Pods-CronetTests.test.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -2626,318 +1087,104 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = APIv2Tests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.APIv2Tests; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Test; - }; - 5E3B95AA21CAC6C500C0A151 /* Cronet */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 8C233E85C3EB45B3CAE52EDF /* Pods-APIv2Tests.cronet.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = APIv2Tests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.APIv2Tests; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Cronet; - }; - 5E3B95AB21CAC6C500C0A151 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 12B238CD1702393C2BA5DE80 /* Pods-APIv2Tests.release.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = APIv2Tests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.APIv2Tests; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; - 5E7D71BB210B9EC9001EA6BA /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 3A98DF08852F60AF1D96481D /* Pods-InteropTestsCallOptions.debug.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = InteropTestsCallOptions/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsCallOptions; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 5E7D71BC210B9EC9001EA6BA /* Test */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = A25967A0D40ED14B3287AD81 /* Pods-InteropTestsCallOptions.test.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = InteropTestsCallOptions/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsCallOptions; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Test; - }; - 5E7D71BD210B9EC9001EA6BA /* Cronet */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 73D2DF07027835BA0FB0B1C0 /* Pods-InteropTestsCallOptions.cronet.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = InteropTestsCallOptions/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsCallOptions; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Cronet; - }; - 5E7D71BE210B9EC9001EA6BA /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = C9172F9020E8C97A470D7250 /* Pods-InteropTestsCallOptions.release.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = InteropTestsCallOptions/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsCallOptions; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; - 5E8A5DAC1D3840B4000F8BC4 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 0D2284C3DF7E57F0ED504E39 /* Pods-CoreCronetEnd2EndTests.debug.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - INFOPLIST_FILE = CoreCronetEnd2EndTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - LIBRARY_SEARCH_PATHS = ( + FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", - "\"${PODS_CONFIGURATION_BUILD_DIR}/BoringSSL\"", - "\"${PODS_CONFIGURATION_BUILD_DIR}/Protobuf\"", - "\"${PODS_CONFIGURATION_BUILD_DIR}/RemoteTest\"", - "\"${PODS_CONFIGURATION_BUILD_DIR}/gRPC\"", - "\"${PODS_CONFIGURATION_BUILD_DIR}/gRPC-Core-072e2d32\"", - "\"${PODS_CONFIGURATION_BUILD_DIR}/gRPC-ProtoRPC\"", - "\"${PODS_CONFIGURATION_BUILD_DIR}/gRPC-RxLibrary\"", - "\"${PODS_CONFIGURATION_BUILD_DIR}/nanopb\"", - "\"${PODS_CONFIGURATION_BUILD_DIR}/gRPC-Core\"", + "$(PROJECT_DIR)/Pods/CronetFramework", ); - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CoreCronetEnd2EndTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - USER_HEADER_SEARCH_PATHS = "$(inherited) \"${PODS_ROOT}/../../../..\""; - }; - name = Debug; - }; - 5E8A5DAD1D3840B4000F8BC4 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 4AD97096D13D7416DC91A72A /* Pods-CoreCronetEnd2EndTests.release.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - INFOPLIST_FILE = CoreCronetEnd2EndTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_INHIBIT_ALL_WARNINGS = YES; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CoreCronetEnd2EndTests; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CronetTests; PRODUCT_NAME = "$(TARGET_NAME)"; - USER_HEADER_SEARCH_PATHS = "$(inherited) \"${PODS_ROOT}/../../../..\""; + TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = ../../..; }; - name = Release; + name = Test; }; - 5EAD6D2C1E27047400002378 /* Debug */ = { + 5E7F486122775B15006656AD /* Cronet */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 64F68A9A6A63CC930DD30A6E /* Pods-CronetUnitTests.debug.xcconfig */; + baseConfigurationReference = 20F6A3D59D0EE091E2D43953 /* Pods-CronetTests.cronet.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - GCC_INPUT_FILETYPE = sourcecode.cpp.objcpp; - GCC_PREPROCESSOR_DEFINITIONS = ( + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", - "COCOAPODS=1", - "$(inherited)", - "PB_FIELD_32BIT=1", - "PB_NO_PACKED_STRUCTS=1", - "GRPC_SHADOW_BORINGSSL_SYMBOLS=1", + "$(PROJECT_DIR)/Pods/CronetFramework", ); - INFOPLIST_FILE = CronetUnitTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_INHIBIT_ALL_WARNINGS = YES; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CronetUnitTests; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CronetTests; PRODUCT_NAME = "$(TARGET_NAME)"; - USER_HEADER_SEARCH_PATHS = "\"${PODS_ROOT}/../../../..\" $(inherited)"; - }; - name = Debug; - }; - 5EAD6D2D1E27047400002378 /* Cronet */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 386712AEACF7C2190C4B8B3F /* Pods-CronetUnitTests.cronet.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - GCC_INPUT_FILETYPE = sourcecode.cpp.objcpp; - INFOPLIST_FILE = CronetUnitTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CronetUnitTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - USER_HEADER_SEARCH_PATHS = "\"${PODS_ROOT}/../../../..\" $(inherited)"; + TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = ../../..; }; name = Cronet; }; - 5EAD6D2E1E27047400002378 /* Release */ = { + 5E7F486222775B15006656AD /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 02192CF1FF9534E3D18C65FC /* Pods-CronetUnitTests.release.xcconfig */; + baseConfigurationReference = 7F4F42EBAF311E9F84FCA32E /* Pods-CronetTests.release.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - GCC_INPUT_FILETYPE = sourcecode.cpp.objcpp; - INFOPLIST_FILE = CronetUnitTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Pods/CronetFramework", + ); + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_INHIBIT_ALL_WARNINGS = YES; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CronetUnitTests; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CronetTests; PRODUCT_NAME = "$(TARGET_NAME)"; - USER_HEADER_SEARCH_PATHS = "\"${PODS_ROOT}/../../../..\" $(inherited)"; + TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = ../../..; }; name = Release; }; - 5EB2A2EC2107DED300EB4B69 /* Debug */ = { + 5EA476FC2272816B000F72FC /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = F9E48EF5ACB1F38825171C5F /* Pods-ChannelTests.debug.xcconfig */; + baseConfigurationReference = 680439AC2BC8761EDD54A1EA /* Pods-InteropTests.debug.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -2960,18 +1207,20 @@ DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = ChannelTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.3; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.ChannelTests; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTests; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; - 5EB2A2ED2107DED300EB4B69 /* Test */ = { + 5EA476FD2272816B000F72FC /* Test */ = { isa = XCBuildConfiguration; - baseConfigurationReference = BED74BC8ABF9917C66175879 /* Pods-ChannelTests.test.xcconfig */; + baseConfigurationReference = 070266E2626EB997B54880A3 /* Pods-InteropTests.test.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -2992,18 +1241,19 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = ChannelTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.3; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.ChannelTests; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTests; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Test; }; - 5EB2A2EE2107DED300EB4B69 /* Cronet */ = { + 5EA476FE2272816B000F72FC /* Cronet */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 90E63AD3C4A1E3E6BC745096 /* Pods-ChannelTests.cronet.xcconfig */; + baseConfigurationReference = CDF6CC70B8BF9D10EFE7D199 /* Pods-InteropTests.cronet.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -3024,18 +1274,19 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = ChannelTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.3; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.ChannelTests; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTests; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Cronet; }; - 5EB2A2EF2107DED300EB4B69 /* Release */ = { + 5EA476FF2272816B000F72FC /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = D52B92A7108602F170DA8091 /* Pods-ChannelTests.release.xcconfig */; + baseConfigurationReference = F6A7EECACBB4849DDD3F450A /* Pods-InteropTests.release.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -3056,140 +1307,11 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = ChannelTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.3; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.ChannelTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; - 5EB2A2FD2109284500EB4B69 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 3CADF86203B9D03EA96C359D /* Pods-InteropTestsMultipleChannels.debug.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = InteropTestsMultipleChannels/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsMultipleChannels; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 5EB2A2FE2109284500EB4B69 /* Test */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = EA8B122ACDE73E3AAA0E4A19 /* Pods-InteropTestsMultipleChannels.test.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = InteropTestsMultipleChannels/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsMultipleChannels; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Test; - }; - 5EB2A2FF2109284500EB4B69 /* Cronet */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 1295CCBD1082B4A7CFCED95F /* Pods-InteropTestsMultipleChannels.cronet.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = InteropTestsMultipleChannels/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsMultipleChannels; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Cronet; - }; - 5EB2A3002109284500EB4B69 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 2650FEF00956E7924772F9D9 /* Pods-InteropTestsMultipleChannels.release.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = InteropTestsMultipleChannels/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsMultipleChannels; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTests; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -3225,6 +1347,8 @@ "HOST_PORT_REMOTE=$(HOST_PORT_REMOTE)", "HOST_PORT_LOCALSSL=$(HOST_PORT_LOCALSSL)", "HOST_PORT_LOCAL=$(HOST_PORT_LOCAL)", + "GRPC_TEST_OBJC=1", + "GRPC_COMPILE_WITH_CRONET=1", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_TREAT_WARNINGS_AS_ERRORS = YES; @@ -3241,594 +1365,6 @@ }; name = Cronet; }; - 5EC3C7A11D4FC18C000330E2 /* Cronet */ = { - isa = XCBuildConfiguration; - buildSettings = { - GCC_TREAT_WARNINGS_AS_ERRORS = YES; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Cronet; - }; - 5EC3C7A21D4FC18C000330E2 /* Cronet */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = E7E4D3FD76E3B745D992AF5F /* Pods-AllTests.cronet.xcconfig */; - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - INFOPLIST_FILE = Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Cronet; - }; - 5EC3C7A31D4FC18C000330E2 /* Cronet */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 79C68EFFCB5533475D810B79 /* Pods-RxLibraryUnitTests.cronet.xcconfig */; - buildSettings = { - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.RxLibraryUnitTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Cronet; - }; - 5EC3C7A41D4FC18C000330E2 /* Cronet */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 4ADEA1C8BBE10D90940AC68E /* Pods-InteropTestsRemote.cronet.xcconfig */; - buildSettings = { - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COCOAPODS=1", - "$(inherited)", - "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1", - ); - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Cronet; - }; - 5EC3C7A51D4FC18C000330E2 /* Cronet */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 14B09A58FEE53A7A6B838920 /* Pods-InteropTestsLocalSSL.cronet.xcconfig */; - buildSettings = { - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalSSL; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Cronet; - }; - 5EC3C7A61D4FC18C000330E2 /* Cronet */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = AA7CB64B4DD9915AE7C03163 /* Pods-InteropTestsLocalCleartext.cronet.xcconfig */; - buildSettings = { - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalCleartext; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Cronet; - }; - 5EC3C7A71D4FC18C000330E2 /* Cronet */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 573450F334B331D0BED8B961 /* Pods-CoreCronetEnd2EndTests.cronet.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - INFOPLIST_FILE = CoreCronetEnd2EndTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CoreCronetEnd2EndTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - USER_HEADER_SEARCH_PATHS = "$(inherited) \"${PODS_ROOT}/../../../..\""; - }; - name = Cronet; - }; - 5EC3C7A81D4FC18C000330E2 /* Cronet */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 3F27B2E744482771EB93C394 /* Pods-InteropTestsRemoteWithCronet.cronet.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COCOAPODS=1", - "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1", - "GRPC_COMPILE_WITH_CRONET=1", - "GRPC_CRONET_WITH_PACKET_COALESCING=1", - "GRPC_TEST_OBJC=1", - ); - INFOPLIST_FILE = InteropTestsRemoteWithCronet/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsRemoteWithCronet; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Cronet; - }; - 5EC5E426208177CC000EF4AD /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 32748C4078AEB05F8F954361 /* Pods-InteropTestsRemoteCFStream.debug.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsRemoteCFStream; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 5EC5E427208177CC000EF4AD /* Test */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = C17F57E5BCB989AB1C2F1F25 /* Pods-InteropTestsRemoteCFStream.test.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COCOAPODS=1", - "$(inherited)", - "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1", - "$(inherited)", - "PB_FIELD_32BIT=1", - "PB_NO_PACKED_STRUCTS=1", - "GRPC_CFSTREAM=1", - ); - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsRemoteCFStream; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Test; - }; - 5EC5E428208177CC000EF4AD /* Cronet */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 4A1A42B2E941CCD453489E5B /* Pods-InteropTestsRemoteCFStream.cronet.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsRemoteCFStream; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Cronet; - }; - 5EC5E429208177CC000EF4AD /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 303F4A17EB1650FC44603D17 /* Pods-InteropTestsRemoteCFStream.release.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsRemoteCFStream; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; - 5EC5E4372081856C000EF4AD /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 943138072A9605B5B8DC1FC0 /* Pods-InteropTestsLocalCleartextCFStream.debug.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalCleartextCFStream; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 5EC5E4382081856C000EF4AD /* Test */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = E4FD4606D4AB8D5A314D72F0 /* Pods-InteropTestsLocalCleartextCFStream.test.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COCOAPODS=1", - "$(inherited)", - "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1", - "$(inherited)", - "PB_FIELD_32BIT=1", - "PB_NO_PACKED_STRUCTS=1", - "GRPC_CFSTREAM=1", - ); - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalCleartextCFStream; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Test; - }; - 5EC5E4392081856C000EF4AD /* Cronet */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 8B498B05C6DA0818B2FA91D4 /* Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalCleartextCFStream; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Cronet; - }; - 5EC5E43A2081856C000EF4AD /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7BA53C6D224288D5870FE6F3 /* Pods-InteropTestsLocalCleartextCFStream.release.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalCleartextCFStream; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; - 5EC5E448208185CE000EF4AD /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 3EB55EF291706E3DDE23C3B7 /* Pods-InteropTestsLocalSSLCFStream.debug.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalSSLCFStream; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 5EC5E449208185CE000EF4AD /* Test */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 41AA59529240A6BBBD3DB904 /* Pods-InteropTestsLocalSSLCFStream.test.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COCOAPODS=1", - "$(inherited)", - "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1", - "$(inherited)", - "PB_FIELD_32BIT=1", - "PB_NO_PACKED_STRUCTS=1", - "GRPC_CFSTREAM=1", - ); - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalSSLCFStream; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Test; - }; - 5EC5E44A208185CE000EF4AD /* Cronet */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 55B630C1FF8C36D1EFC4E0A4 /* Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalSSLCFStream; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Cronet; - }; - 5EC5E44B208185CE000EF4AD /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 5EA908CF4CDA4CE218352A06 /* Pods-InteropTestsLocalSSLCFStream.release.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalSSLCFStream; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; - 5EE84BF91D4717E40050C6CC /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 17F60BF2871F6AF85FB3FA12 /* Pods-InteropTestsRemoteWithCronet.debug.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COCOAPODS=1", - "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1", - ); - INFOPLIST_FILE = InteropTestsRemoteWithCronet/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsRemoteWithCronet; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 5EE84BFA1D4717E40050C6CC /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = AC414EF7A6BF76ED02B6E480 /* Pods-InteropTestsRemoteWithCronet.release.xcconfig */; - buildSettings = { - CLANG_ANALYZER_NONNULL = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COCOAPODS=1", - "$(inherited)", - "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1", - "GRPC_COMPILE_WITH_CRONET=1", - ); - INFOPLIST_FILE = InteropTestsRemoteWithCronet/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsRemoteWithCronet; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; - 63423F4E1B150A5F006CF63C /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = B94C27C06733CF98CE1B2757 /* Pods-AllTests.debug.xcconfig */; - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - INFOPLIST_FILE = Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 63423F4F1B150A5F006CF63C /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 5761E98978DDDF136A58CB7E /* Pods-AllTests.release.xcconfig */; - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); - INFOPLIST_FILE = Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; 635697D91B14FC11007A7283 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -3909,128 +1445,6 @@ }; name = Release; }; - 635697DC1B14FC11007A7283 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - GCC_TREAT_WARNINGS_AS_ERRORS = YES; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - 635697DD1B14FC11007A7283 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - GCC_TREAT_WARNINGS_AS_ERRORS = YES; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Release; - }; - 63DC841C1BE15179000708E8 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 07D10A965323BEA7FE59A74B /* Pods-RxLibraryUnitTests.debug.xcconfig */; - buildSettings = { - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.RxLibraryUnitTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 63DC841D1BE15179000708E8 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 3B0861FC805389C52DB260D4 /* Pods-RxLibraryUnitTests.release.xcconfig */; - buildSettings = { - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.RxLibraryUnitTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; - 63DC842C1BE15267000708E8 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = DC3CA1D948F068E76957A861 /* Pods-InteropTestsRemote.debug.xcconfig */; - buildSettings = { - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 63DC842D1BE15267000708E8 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = E4275A759BDBDF143B9B438F /* Pods-InteropTestsRemote.release.xcconfig */; - buildSettings = { - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; - 63DC843D1BE15294000708E8 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 553BBBED24E4162D1F769D65 /* Pods-InteropTestsLocalSSL.debug.xcconfig */; - buildSettings = { - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalSSL; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 63DC843E1BE15294000708E8 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7A2E97E3F469CC2A758D77DE /* Pods-InteropTestsLocalSSL.release.xcconfig */; - buildSettings = { - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalSSL; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; - 63DC844C1BE152B5000708E8 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = E1486220285AF123EB124008 /* Pods-InteropTestsLocalCleartext.debug.xcconfig */; - buildSettings = { - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalCleartext; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 63DC844D1BE152B5000708E8 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 51A275E86C141416ED63FF76 /* Pods-InteropTestsLocalCleartext.release.xcconfig */; - buildSettings = { - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsLocalCleartext; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; B0BB3EFD225E795F008DA580 /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = E3ACD4D5902745976D9C2229 /* Pods-MacTests.debug.xcconfig */; @@ -4193,123 +1607,24 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 5E3B95A721CAC6C500C0A151 /* Build configuration list for PBXNativeTarget "APIv2Tests" */ = { + 5E7F485E22775B15006656AD /* Build configuration list for PBXNativeTarget "CronetTests" */ = { isa = XCConfigurationList; buildConfigurations = ( - 5E3B95A821CAC6C500C0A151 /* Debug */, - 5E3B95A921CAC6C500C0A151 /* Test */, - 5E3B95AA21CAC6C500C0A151 /* Cronet */, - 5E3B95AB21CAC6C500C0A151 /* Release */, + 5E7F485F22775B15006656AD /* Debug */, + 5E7F486022775B15006656AD /* Test */, + 5E7F486122775B15006656AD /* Cronet */, + 5E7F486222775B15006656AD /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 5E7D71BA210B9EC9001EA6BA /* Build configuration list for PBXNativeTarget "InteropTestsCallOptions" */ = { + 5EA477002272816B000F72FC /* Build configuration list for PBXNativeTarget "InteropTests" */ = { isa = XCConfigurationList; buildConfigurations = ( - 5E7D71BB210B9EC9001EA6BA /* Debug */, - 5E7D71BC210B9EC9001EA6BA /* Test */, - 5E7D71BD210B9EC9001EA6BA /* Cronet */, - 5E7D71BE210B9EC9001EA6BA /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 5E8A5DAE1D3840B4000F8BC4 /* Build configuration list for PBXNativeTarget "CoreCronetEnd2EndTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 5E8A5DAC1D3840B4000F8BC4 /* Debug */, - 5E12289F1E4D400F00E8504F /* Test */, - 5EC3C7A71D4FC18C000330E2 /* Cronet */, - 5E8A5DAD1D3840B4000F8BC4 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 5EAD6D2F1E27047400002378 /* Build configuration list for PBXNativeTarget "CronetUnitTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 5EAD6D2C1E27047400002378 /* Debug */, - 5E1228A11E4D400F00E8504F /* Test */, - 5EAD6D2D1E27047400002378 /* Cronet */, - 5EAD6D2E1E27047400002378 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 5EB2A2F02107DED300EB4B69 /* Build configuration list for PBXNativeTarget "ChannelTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 5EB2A2EC2107DED300EB4B69 /* Debug */, - 5EB2A2ED2107DED300EB4B69 /* Test */, - 5EB2A2EE2107DED300EB4B69 /* Cronet */, - 5EB2A2EF2107DED300EB4B69 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 5EB2A3012109284500EB4B69 /* Build configuration list for PBXNativeTarget "InteropTestsMultipleChannels" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 5EB2A2FD2109284500EB4B69 /* Debug */, - 5EB2A2FE2109284500EB4B69 /* Test */, - 5EB2A2FF2109284500EB4B69 /* Cronet */, - 5EB2A3002109284500EB4B69 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 5EC5E42A208177CD000EF4AD /* Build configuration list for PBXNativeTarget "InteropTestsRemoteCFStream" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 5EC5E426208177CC000EF4AD /* Debug */, - 5EC5E427208177CC000EF4AD /* Test */, - 5EC5E428208177CC000EF4AD /* Cronet */, - 5EC5E429208177CC000EF4AD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 5EC5E4362081856C000EF4AD /* Build configuration list for PBXNativeTarget "InteropTestsLocalCleartextCFStream" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 5EC5E4372081856C000EF4AD /* Debug */, - 5EC5E4382081856C000EF4AD /* Test */, - 5EC5E4392081856C000EF4AD /* Cronet */, - 5EC5E43A2081856C000EF4AD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 5EC5E447208185CE000EF4AD /* Build configuration list for PBXNativeTarget "InteropTestsLocalSSLCFStream" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 5EC5E448208185CE000EF4AD /* Debug */, - 5EC5E449208185CE000EF4AD /* Test */, - 5EC5E44A208185CE000EF4AD /* Cronet */, - 5EC5E44B208185CE000EF4AD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 5EE84BFB1D4717E40050C6CC /* Build configuration list for PBXNativeTarget "InteropTestsRemoteWithCronet" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 5EE84BF91D4717E40050C6CC /* Debug */, - 5E1228A01E4D400F00E8504F /* Test */, - 5EC3C7A81D4FC18C000330E2 /* Cronet */, - 5EE84BFA1D4717E40050C6CC /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 63423F4D1B150A5F006CF63C /* Build configuration list for PBXNativeTarget "AllTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 63423F4E1B150A5F006CF63C /* Debug */, - 5E12289A1E4D400F00E8504F /* Test */, - 5EC3C7A21D4FC18C000330E2 /* Cronet */, - 63423F4F1B150A5F006CF63C /* Release */, + 5EA476FC2272816B000F72FC /* Debug */, + 5EA476FD2272816B000F72FC /* Test */, + 5EA476FE2272816B000F72FC /* Cronet */, + 5EA476FF2272816B000F72FC /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; @@ -4325,61 +1640,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 635697DB1B14FC11007A7283 /* Build configuration list for PBXNativeTarget "Tests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 635697DC1B14FC11007A7283 /* Debug */, - 5E1228991E4D400F00E8504F /* Test */, - 5EC3C7A11D4FC18C000330E2 /* Cronet */, - 635697DD1B14FC11007A7283 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 63DC841B1BE15179000708E8 /* Build configuration list for PBXNativeTarget "RxLibraryUnitTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 63DC841C1BE15179000708E8 /* Debug */, - 5E12289B1E4D400F00E8504F /* Test */, - 5EC3C7A31D4FC18C000330E2 /* Cronet */, - 63DC841D1BE15179000708E8 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 63DC842B1BE15267000708E8 /* Build configuration list for PBXNativeTarget "InteropTestsRemote" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 63DC842C1BE15267000708E8 /* Debug */, - 5E12289C1E4D400F00E8504F /* Test */, - 5EC3C7A41D4FC18C000330E2 /* Cronet */, - 63DC842D1BE15267000708E8 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 63DC843C1BE15294000708E8 /* Build configuration list for PBXNativeTarget "InteropTestsLocalSSL" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 63DC843D1BE15294000708E8 /* Debug */, - 5E12289D1E4D400F00E8504F /* Test */, - 5EC3C7A51D4FC18C000330E2 /* Cronet */, - 63DC843E1BE15294000708E8 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 63DC844B1BE152B5000708E8 /* Build configuration list for PBXNativeTarget "InteropTestsLocalCleartext" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 63DC844C1BE152B5000708E8 /* Debug */, - 5E12289E1E4D400F00E8504F /* Test */, - 5EC3C7A61D4FC18C000330E2 /* Cronet */, - 63DC844D1BE152B5000708E8 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; B0BB3EFC225E795F008DA580 /* Build configuration list for PBXNativeTarget "MacTests" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/AllTests.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/AllTests.xcscheme deleted file mode 100644 index a2560fee029..00000000000 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/AllTests.xcscheme +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/ChannelTests.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/ChannelTests.xcscheme deleted file mode 100644 index acae965bed0..00000000000 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/ChannelTests.xcscheme +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CoreCronetEnd2EndTests.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CoreCronetEnd2EndTests.xcscheme deleted file mode 100644 index e62edd397a5..00000000000 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CoreCronetEnd2EndTests.xcscheme +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CoreCronetEnd2EndTests_Asan.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CoreCronetEnd2EndTests_Asan.xcscheme deleted file mode 100644 index 0a597e756ec..00000000000 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CoreCronetEnd2EndTests_Asan.xcscheme +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CoreCronetEnd2EndTests_Tsan.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CoreCronetEnd2EndTests_Tsan.xcscheme deleted file mode 100644 index 5fe60b96920..00000000000 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CoreCronetEnd2EndTests_Tsan.xcscheme +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/APIv2Tests.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CronetTests.xcscheme similarity index 77% rename from src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/APIv2Tests.xcscheme rename to src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CronetTests.xcscheme index e0d1d1fdcac..aea349a06cc 100644 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/APIv2Tests.xcscheme +++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CronetTests.xcscheme @@ -1,6 +1,6 @@ @@ -32,9 +32,9 @@ skipped = "NO"> @@ -43,7 +43,7 @@ @@ -73,9 +73,9 @@ diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CronetUnitTests.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CronetUnitTests.xcscheme deleted file mode 100644 index ea711e09e97..00000000000 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CronetUnitTests.xcscheme +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemote.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme similarity index 75% rename from src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemote.xcscheme rename to src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme index 412bf6a0143..a2b1614b991 100644 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemote.xcscheme +++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme @@ -1,6 +1,6 @@ + buildForAnalyzing = "NO"> @@ -32,9 +32,9 @@ skipped = "NO"> @@ -44,20 +44,11 @@ - - - - @@ -84,9 +75,18 @@ savedToolIdentifier = "" useCustomWorkingDirectory = "NO" debugDocumentVersioning = "YES"> + + + + + buildConfiguration = "Debug"> - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartext.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartext.xcscheme deleted file mode 100644 index 11b41c92140..00000000000 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartext.xcscheme +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartextCFStream.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartextCFStream.xcscheme deleted file mode 100644 index fe766de928e..00000000000 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartextCFStream.xcscheme +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalSSL.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalSSL.xcscheme deleted file mode 100644 index 37135b3ad36..00000000000 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalSSL.xcscheme +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalSSLCFStream.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalSSLCFStream.xcscheme deleted file mode 100644 index bd663276493..00000000000 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalSSLCFStream.xcscheme +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsMultipleChannels.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsMultipleChannels.xcscheme deleted file mode 100644 index 1b4c1f5e51c..00000000000 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsMultipleChannels.xcscheme +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemoteCFStream.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemoteCFStream.xcscheme deleted file mode 100644 index 33a5ded038b..00000000000 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemoteCFStream.xcscheme +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemoteWithCronet.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemoteWithCronet.xcscheme deleted file mode 100644 index 1d211115f75..00000000000 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemoteWithCronet.xcscheme +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/MacTests.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/MacTests.xcscheme index f84ac7fc741..fbd2d08f219 100644 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/MacTests.xcscheme +++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/MacTests.xcscheme @@ -51,7 +51,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/Tests.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/Tests.xcscheme deleted file mode 100644 index 77f567db3d4..00000000000 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/Tests.xcscheme +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/UnitTests.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/UnitTests.xcscheme index 3af3555f48e..d20a9e5ae7b 100644 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/UnitTests.xcscheme +++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/UnitTests.xcscheme @@ -23,10 +23,9 @@ -#import "version.h" +#import "../version.h" #define TEST_TIMEOUT 16 diff --git a/src/objective-c/tests/UnitTests/Info.plist b/src/objective-c/tests/UnitTests/Info.plist deleted file mode 100644 index 6c40a6cd0c4..00000000000 --- a/src/objective-c/tests/UnitTests/Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - - diff --git a/src/objective-c/tests/UnitTests/UnitTests.m b/src/objective-c/tests/UnitTests/NSErrorUnitTests.m similarity index 96% rename from src/objective-c/tests/UnitTests/UnitTests.m rename to src/objective-c/tests/UnitTests/NSErrorUnitTests.m index 4dcb8c08d28..8a4f03a4460 100644 --- a/src/objective-c/tests/UnitTests/UnitTests.m +++ b/src/objective-c/tests/UnitTests/NSErrorUnitTests.m @@ -22,11 +22,11 @@ #import "../../GRPCClient/private/NSError+GRPC.h" -@interface UnitTests : XCTestCase +@interface NSErrorUnitTests : XCTestCase @end -@implementation UnitTests +@implementation NSErrorUnitTests - (void)testNSError { const char *kDetails = "test details"; diff --git a/src/objective-c/tests/RxLibraryUnitTests.m b/src/objective-c/tests/UnitTests/RxLibraryUnitTests.m similarity index 100% rename from src/objective-c/tests/RxLibraryUnitTests.m rename to src/objective-c/tests/UnitTests/RxLibraryUnitTests.m diff --git a/src/objective-c/tests/run_tests.sh b/src/objective-c/tests/run_tests.sh index 8c768cb85be..24185c561ec 100755 --- a/src/objective-c/tests/run_tests.sh +++ b/src/objective-c/tests/run_tests.sh @@ -43,121 +43,13 @@ XCODEBUILD_FILTER='(^CompileC |^Ld |^ *[^ ]*clang |^ *cd |^ *export |^Libtool |^ echo "TIME: $(date)" -# Retry the test for up to 3 times when return code is 65, due to Xcode issue: -# http://www.openradar.me/29785686 -# The issue seems to be a connectivity issue to Xcode simulator so only retry -# the first xcodebuild command -retries=0 -while [ $retries -lt 3 ]; do - return_code=0 - out=$(xcodebuild \ - -workspace Tests.xcworkspace \ - -scheme AllTests \ - -destination name="iPhone 8" \ - HOST_PORT_LOCALSSL=localhost:5051 \ - HOST_PORT_LOCAL=localhost:5050 \ - HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ - test 2>&1 \ - | egrep -v "$XCODEBUILD_FILTER" \ - | egrep -v '^$' \ - | egrep -v "(GPBDictionary|GPBArray)" - ) || return_code=$? - if [ $return_code == 65 ] && [[ $out == *"DTXProxyChannel error 1"* ]]; then - echo "$out" - echo "Failed with code 65 (DTXProxyChannel error 1); retry." - retries=$(($retries+1)) - elif [ $return_code == 0 ]; then - echo "$out" - break - else - echo "$out" - echo "Failed with code $return_code." - exit 1 - fi -done -if [ $retries == 3 ]; then - echo "Failed with code 65 for 3 times; abort." - exit 1 -fi - -echo "TIME: $(date)" xcodebuild \ -workspace Tests.xcworkspace \ - -scheme CoreCronetEnd2EndTests \ - -destination name="iPhone 8" \ - test \ - | egrep -v "$XCODEBUILD_FILTER" \ - | egrep -v '^$' \ - | egrep -v "(GPBDictionary|GPBArray)" - - -echo "TIME: $(date)" -xcodebuild \ - -workspace Tests.xcworkspace \ - -scheme CoreCronetEnd2EndTests_Asan \ - -destination name="iPhone 6" \ - test \ - | egrep -v "$XCODEBUILD_FILTER" \ - | egrep -v '^$' \ - | egrep -v "(GPBDictionary|GPBArray)" - - -echo "TIME: $(date)" -xcodebuild \ - -workspace Tests.xcworkspace \ - -scheme CoreCronetEnd2EndTests_Tsan \ - -destination name="iPhone 6" \ - test \ - | egrep -v "$XCODEBUILD_FILTER" \ - | egrep -v '^$' \ - | egrep -v "(GPBDictionary|GPBArray)" - - -echo "TIME: $(date)" -xcodebuild \ - -workspace Tests.xcworkspace \ - -scheme CronetUnitTests \ - -destination name="iPhone 8" \ - test \ - | egrep -v "$XCODEBUILD_FILTER" \ - | egrep -v '^$' \ - | egrep -v "(GPBDictionary|GPBArray)" - - -echo "TIME: $(date)" -xcodebuild \ - -workspace Tests.xcworkspace \ - -scheme InteropTestsRemoteWithCronet \ - -destination name="iPhone 8" \ - HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ - test \ - | egrep -v "$XCODEBUILD_FILTER" \ - | egrep -v '^$' \ - | egrep -v "(GPBDictionary|GPBArray)" - - -echo "TIME: $(date)" -xcodebuild \ - -workspace Tests.xcworkspace \ - -scheme InteropTestsRemoteCFStream \ - -destination name="iPhone 8" \ - HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ - test \ - | egrep -v "$XCODEBUILD_FILTER" \ - | egrep -v '^$' \ - | egrep -v "(GPBDictionary|GPBArray)" - - -echo "TIME: $(date)" -xcodebuild \ - -workspace Tests.xcworkspace \ - -scheme InteropTestsLocalCleartextCFStream \ - -destination name="iPhone 8" \ - HOST_PORT_LOCAL=localhost:5050 \ - test \ - | egrep -v "$XCODEBUILD_FILTER" \ - | egrep -v '^$' \ - | egrep -v "(GPBDictionary|GPBArray)" - - -echo "TIME: $(date)" -xcodebuild \ - -workspace Tests.xcworkspace \ - -scheme InteropTestsLocalSSLCFStream \ + -scheme InteropTests \ -destination name="iPhone 8" \ HOST_PORT_LOCALSSL=localhost:5051 \ + HOST_PORT_LOCAL=localhost:5050 \ + HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ test \ | egrep -v "$XCODEBUILD_FILTER" \ | egrep -v '^$' \ @@ -168,6 +60,9 @@ xcodebuild \ -workspace Tests.xcworkspace \ -scheme UnitTests \ -destination name="iPhone 8" \ + HOST_PORT_LOCALSSL=localhost:5051 \ + HOST_PORT_LOCAL=localhost:5050 \ + HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ test \ | egrep -v "$XCODEBUILD_FILTER" \ | egrep -v '^$' \ @@ -176,18 +71,9 @@ xcodebuild \ echo "TIME: $(date)" xcodebuild \ -workspace Tests.xcworkspace \ - -scheme ChannelTests \ - -destination name="iPhone 8" \ - test \ - | egrep -v "$XCODEBUILD_FILTER" \ - | egrep -v '^$' \ - | egrep -v "(GPBDictionary|GPBArray)" - - -echo "TIME: $(date)" -xcodebuild \ - -workspace Tests.xcworkspace \ - -scheme APIv2Tests \ + -scheme CronetTests \ -destination name="iPhone 8" \ + HOST_PORT_LOCALSSL=localhost:5051 \ HOST_PORT_LOCAL=localhost:5050 \ HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ test \ From 930cec4e27347a2cc852954917e0263b27d7480b Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 30 Apr 2019 11:17:11 -0700 Subject: [PATCH 0066/1555] Revert "Merge pull request #18912 from grpc/revert-bazel-changes" This reverts commit c9a259aa3a5a8081fc8de88108759db07d3a4379, reversing changes made to 9c882bc7253a91262d662409453c5fc70b019d20. --- .gitignore | 1 + WORKSPACE | 7 - bazel/generate_cc.bzl | 204 +++++++++++------- bazel/grpc_python_deps.bzl | 14 +- bazel/protobuf.bzl | 84 ++++++++ bazel/python_rules.bzl | 203 +++++++++++++++++ examples/BUILD | 12 +- examples/python/errors/client.py | 4 +- examples/python/errors/server.py | 4 +- .../test/_error_handling_example_test.py | 2 +- examples/python/multiprocessing/BUILD | 17 +- .../wait_for_ready/wait_for_ready_example.py | 11 +- src/proto/grpc/channelz/BUILD | 5 + src/proto/grpc/health/v1/BUILD | 5 + src/proto/grpc/reflection/v1alpha/BUILD | 5 + src/proto/grpc/testing/BUILD | 41 ++-- src/proto/grpc/testing/proto2/BUILD.bazel | 30 +-- .../grpc_channelz/v1/BUILD.bazel | 26 +-- .../grpc_health/v1/BUILD.bazel | 19 +- .../grpc_reflection/v1alpha/BUILD.bazel | 17 +- .../grpcio_tests/tests/reflection/BUILD.bazel | 1 + tools/distrib/bazel_style.cfg | 4 + tools/distrib/format_bazel.sh | 39 ++++ .../linux/grpc_bazel_build_in_docker.sh | 3 +- .../linux/grpc_python_bazel_test_in_docker.sh | 13 +- 25 files changed, 561 insertions(+), 210 deletions(-) create mode 100644 bazel/protobuf.bzl create mode 100644 bazel/python_rules.bzl create mode 100644 tools/distrib/bazel_style.cfg create mode 100755 tools/distrib/format_bazel.sh diff --git a/.gitignore b/.gitignore index 0d2647e61b6..7b4c5d36cb4 100644 --- a/.gitignore +++ b/.gitignore @@ -115,6 +115,7 @@ bazel-genfiles bazel-grpc bazel-out bazel-testlogs +bazel_format_virtual_environment/ # Debug output gdb.txt diff --git a/WORKSPACE b/WORKSPACE index fcf5b5d6d10..2db3c5db2ff 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -18,13 +18,6 @@ register_toolchains( "//third_party/toolchains/bazel_0.23.2_rbe_windows:cc-toolchain-x64_windows", ) -# TODO(https://github.com/grpc/grpc/issues/18331): Move off of this dependency. -git_repository( - name = "org_pubref_rules_protobuf", - remote = "https://github.com/ghostwriternr/rules_protobuf", - tag = "v0.8.2.1-alpha", -) - git_repository( name = "io_bazel_rules_python", commit = "8b5d0683a7d878b28fffe464779c8a53659fc645", diff --git a/bazel/generate_cc.bzl b/bazel/generate_cc.bzl index 8f30c84f6b9..82f5cbad310 100644 --- a/bazel/generate_cc.bzl +++ b/bazel/generate_cc.bzl @@ -4,81 +4,132 @@ This is an internal rule used by cc_grpc_library, and shouldn't be used directly. """ +load( + "//bazel:protobuf.bzl", + "get_include_protoc_args", + "get_plugin_args", + "get_proto_root", + "proto_path_to_generated_filename", +) + +_GRPC_PROTO_HEADER_FMT = "{}.grpc.pb.h" +_GRPC_PROTO_SRC_FMT = "{}.grpc.pb.cc" +_GRPC_PROTO_MOCK_HEADER_FMT = "{}_mock.grpc.pb.h" +_PROTO_HEADER_FMT = "{}.pb.h" +_PROTO_SRC_FMT = "{}.pb.cc" + +def _strip_package_from_path(label_package, path): + if len(label_package) == 0: + return path + if not path.startswith(label_package + "/"): + fail("'{}' does not lie within '{}'.".format(path, label_package)) + return path[len(label_package + "/"):] + +def _join_directories(directories): + massaged_directories = [directory for directory in directories if len(directory) != 0] + return "/".join(massaged_directories) + def generate_cc_impl(ctx): - """Implementation of the generate_cc rule.""" - protos = [f for src in ctx.attr.srcs for f in src.proto.direct_sources] - includes = [f for src in ctx.attr.srcs for f in src.proto.transitive_imports] - outs = [] - # label_len is length of the path from WORKSPACE root to the location of this build file - label_len = 0 - # proto_root is the directory relative to which generated include paths should be - proto_root = "" - if ctx.label.package: - # The +1 is for the trailing slash. - label_len += len(ctx.label.package) + 1 - if ctx.label.workspace_root: - label_len += len(ctx.label.workspace_root) + 1 - proto_root = "/" + ctx.label.workspace_root + """Implementation of the generate_cc rule.""" + protos = [f for src in ctx.attr.srcs for f in src.proto.direct_sources] + includes = [ + f + for src in ctx.attr.srcs + for f in src.proto.transitive_imports + ] + outs = [] + proto_root = get_proto_root( + ctx.label.workspace_root, + ) - if ctx.executable.plugin: - outs += [proto.path[label_len:-len(".proto")] + ".grpc.pb.h" for proto in protos] - outs += [proto.path[label_len:-len(".proto")] + ".grpc.pb.cc" for proto in protos] - if ctx.attr.generate_mocks: - outs += [proto.path[label_len:-len(".proto")] + "_mock.grpc.pb.h" for proto in protos] - else: - outs += [proto.path[label_len:-len(".proto")] + ".pb.h" for proto in protos] - outs += [proto.path[label_len:-len(".proto")] + ".pb.cc" for proto in protos] - out_files = [ctx.actions.declare_file(out) for out in outs] - dir_out = str(ctx.genfiles_dir.path + proto_root) - - arguments = [] - if ctx.executable.plugin: - arguments += ["--plugin=protoc-gen-PLUGIN=" + ctx.executable.plugin.path] - flags = list(ctx.attr.flags) - if ctx.attr.generate_mocks: - flags.append("generate_mock_code=true") - arguments += ["--PLUGIN_out=" + ",".join(flags) + ":" + dir_out] - tools = [ctx.executable.plugin] - else: - arguments += ["--cpp_out=" + ",".join(ctx.attr.flags) + ":" + dir_out] - tools = [] - - # Import protos relative to their workspace root so that protoc prints the - # right include paths. - for include in includes: - directory = include.path - if directory.startswith("external"): - external_sep = directory.find("/") - repository_sep = directory.find("/", external_sep + 1) - arguments += ["--proto_path=" + directory[:repository_sep]] + label_package = _join_directories([ctx.label.workspace_root, ctx.label.package]) + if ctx.executable.plugin: + outs += [ + proto_path_to_generated_filename( + _strip_package_from_path(label_package, proto.path), + _GRPC_PROTO_HEADER_FMT, + ) + for proto in protos + ] + outs += [ + proto_path_to_generated_filename( + _strip_package_from_path(label_package, proto.path), + _GRPC_PROTO_SRC_FMT, + ) + for proto in protos + ] + if ctx.attr.generate_mocks: + outs += [ + proto_path_to_generated_filename( + _strip_package_from_path(label_package, proto.path), + _GRPC_PROTO_MOCK_HEADER_FMT, + ) + for proto in protos + ] else: - arguments += ["--proto_path=."] - # Include the output directory so that protoc puts the generated code in the - # right directory. - arguments += ["--proto_path={0}{1}".format(dir_out, proto_root)] - arguments += [proto.path for proto in protos] + outs += [ + proto_path_to_generated_filename( + _strip_package_from_path(label_package, proto.path), + _PROTO_HEADER_FMT, + ) + for proto in protos + ] + outs += [ + proto_path_to_generated_filename( + _strip_package_from_path(label_package, proto.path), + _PROTO_SRC_FMT, + ) + for proto in protos + ] + out_files = [ctx.actions.declare_file(out) for out in outs] + dir_out = str(ctx.genfiles_dir.path + proto_root) - # create a list of well known proto files if the argument is non-None - well_known_proto_files = [] - if ctx.attr.well_known_protos: - f = ctx.attr.well_known_protos.files.to_list()[0].dirname - if f != "external/com_google_protobuf/src/google/protobuf": - print("Error: Only @com_google_protobuf//:well_known_protos is supported") + arguments = [] + if ctx.executable.plugin: + arguments += get_plugin_args( + ctx.executable.plugin, + ctx.attr.flags, + dir_out, + ctx.attr.generate_mocks, + ) + tools = [ctx.executable.plugin] else: - # f points to "external/com_google_protobuf/src/google/protobuf" - # add -I argument to protoc so it knows where to look for the proto files. - arguments += ["-I{0}".format(f + "/../..")] - well_known_proto_files = [f for f in ctx.attr.well_known_protos.files] + arguments += ["--cpp_out=" + ",".join(ctx.attr.flags) + ":" + dir_out] + tools = [] - ctx.actions.run( - inputs = protos + includes + well_known_proto_files, - tools = tools, - outputs = out_files, - executable = ctx.executable._protoc, - arguments = arguments, - ) + arguments += get_include_protoc_args(includes) - return struct(files=depset(out_files)) + # Include the output directory so that protoc puts the generated code in the + # right directory. + arguments += ["--proto_path={0}{1}".format(dir_out, proto_root)] + arguments += [proto.path for proto in protos] + + # create a list of well known proto files if the argument is non-None + well_known_proto_files = [] + if ctx.attr.well_known_protos: + f = ctx.attr.well_known_protos.files.to_list()[0].dirname + if f != "external/com_google_protobuf/src/google/protobuf": + print( + "Error: Only @com_google_protobuf//:well_known_protos is supported", + ) + else: + # f points to "external/com_google_protobuf/src/google/protobuf" + # add -I argument to protoc so it knows where to look for the proto files. + arguments += ["-I{0}".format(f + "/../..")] + well_known_proto_files = [ + f + for f in ctx.attr.well_known_protos.files + ] + + ctx.actions.run( + inputs = protos + includes + well_known_proto_files, + tools = tools, + outputs = out_files, + executable = ctx.executable._protoc, + arguments = arguments, + ) + + return struct(files = depset(out_files)) _generate_cc = rule( attrs = { @@ -96,10 +147,8 @@ _generate_cc = rule( mandatory = False, allow_empty = True, ), - "well_known_protos" : attr.label( - mandatory = False, - ), - "generate_mocks" : attr.bool( + "well_known_protos": attr.label(mandatory = False), + "generate_mocks": attr.bool( default = False, mandatory = False, ), @@ -115,7 +164,10 @@ _generate_cc = rule( ) def generate_cc(well_known_protos, **kwargs): - if well_known_protos: - _generate_cc(well_known_protos="@com_google_protobuf//:well_known_protos", **kwargs) - else: - _generate_cc(**kwargs) + if well_known_protos: + _generate_cc( + well_known_protos = "@com_google_protobuf//:well_known_protos", + **kwargs + ) + else: + _generate_cc(**kwargs) diff --git a/bazel/grpc_python_deps.bzl b/bazel/grpc_python_deps.bzl index ec3df19e03a..91438f3927b 100644 --- a/bazel/grpc_python_deps.bzl +++ b/bazel/grpc_python_deps.bzl @@ -1,16 +1,8 @@ load("//third_party/py:python_configure.bzl", "python_configure") load("@io_bazel_rules_python//python:pip.bzl", "pip_repositories") load("@grpc_python_dependencies//:requirements.bzl", "pip_install") -load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_repositories") def grpc_python_deps(): - # TODO(https://github.com/grpc/grpc/issues/18256): Remove conditional. - if hasattr(native, "http_archive"): - python_configure(name = "local_config_python") - pip_repositories() - pip_install() - py_proto_repositories() - else: - print("Building Python gRPC with bazel 23.0+ is disabled pending " + - "resolution of https://github.com/grpc/grpc/issues/18256.") - + python_configure(name = "local_config_python") + pip_repositories() + pip_install() diff --git a/bazel/protobuf.bzl b/bazel/protobuf.bzl new file mode 100644 index 00000000000..bddd0d70c7f --- /dev/null +++ b/bazel/protobuf.bzl @@ -0,0 +1,84 @@ +"""Utility functions for generating protobuf code.""" + +_PROTO_EXTENSION = ".proto" + +def get_proto_root(workspace_root): + """Gets the root protobuf directory. + + Args: + workspace_root: context.label.workspace_root + + Returns: + The directory relative to which generated include paths should be. + """ + if workspace_root: + return "/{}".format(workspace_root) + else: + return "" + +def _strip_proto_extension(proto_filename): + if not proto_filename.endswith(_PROTO_EXTENSION): + fail('"{}" does not end with "{}"'.format( + proto_filename, + _PROTO_EXTENSION, + )) + return proto_filename[:-len(_PROTO_EXTENSION)] + +def proto_path_to_generated_filename(proto_path, fmt_str): + """Calculates the name of a generated file for a protobuf path. + + For example, "examples/protos/helloworld.proto" might map to + "helloworld.pb.h". + + Args: + proto_path: The path to the .proto file. + fmt_str: A format string used to calculate the generated filename. For + example, "{}.pb.h" might be used to calculate a C++ header filename. + + Returns: + The generated filename. + """ + return fmt_str.format(_strip_proto_extension(proto_path)) + +def _get_include_directory(include): + directory = include.path + if directory.startswith("external"): + external_separator = directory.find("/") + repository_separator = directory.find("/", external_separator + 1) + return directory[:repository_separator] + else: + return "." + +def get_include_protoc_args(includes): + """Returns protoc args that imports protos relative to their import root. + + Args: + includes: A list of included proto files. + + Returns: + A list of arguments to be passed to protoc. For example, ["--proto_path=."]. + """ + return [ + "--proto_path={}".format(_get_include_directory(include)) + for include in includes + ] + +def get_plugin_args(plugin, flags, dir_out, generate_mocks): + """Returns arguments configuring protoc to use a plugin for a language. + + Args: + plugin: An executable file to run as the protoc plugin. + flags: The plugin flags to be passed to protoc. + dir_out: The output directory for the plugin. + generate_mocks: A bool indicating whether to generate mocks. + + Returns: + A list of protoc arguments configuring the plugin. + """ + augmented_flags = list(flags) + if generate_mocks: + augmented_flags.append("generate_mock_code=true") + return [ + "--plugin=protoc-gen-PLUGIN=" + plugin.path, + "--PLUGIN_out=" + ",".join(augmented_flags) + ":" + dir_out, + ] diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl new file mode 100644 index 00000000000..bf6b4bec8d2 --- /dev/null +++ b/bazel/python_rules.bzl @@ -0,0 +1,203 @@ +"""Generates and compiles Python gRPC stubs from proto_library rules.""" + +load("@grpc_python_dependencies//:requirements.bzl", "requirement") +load( + "//bazel:protobuf.bzl", + "get_include_protoc_args", + "get_plugin_args", + "get_proto_root", + "proto_path_to_generated_filename", +) + +_GENERATED_PROTO_FORMAT = "{}_pb2.py" +_GENERATED_GRPC_PROTO_FORMAT = "{}_pb2_grpc.py" + +def _get_staged_proto_file(context, source_file): + if source_file.dirname == context.label.package: + return source_file + else: + copied_proto = context.actions.declare_file(source_file.basename) + context.actions.run_shell( + inputs = [source_file], + outputs = [copied_proto], + command = "cp {} {}".format(source_file.path, copied_proto.path), + mnemonic = "CopySourceProto", + ) + return copied_proto + +def _generate_py_impl(context): + protos = [] + for src in context.attr.deps: + for file in src.proto.direct_sources: + protos.append(_get_staged_proto_file(context, file)) + includes = [ + file + for src in context.attr.deps + for file in src.proto.transitive_imports + ] + proto_root = get_proto_root(context.label.workspace_root) + format_str = (_GENERATED_GRPC_PROTO_FORMAT if context.executable.plugin else _GENERATED_PROTO_FORMAT) + out_files = [ + context.actions.declare_file( + proto_path_to_generated_filename( + proto.basename, + format_str, + ), + ) + for proto in protos + ] + + arguments = [] + tools = [context.executable._protoc] + if context.executable.plugin: + arguments += get_plugin_args( + context.executable.plugin, + context.attr.flags, + context.genfiles_dir.path, + False, + ) + tools += [context.executable.plugin] + else: + arguments += [ + "--python_out={}:{}".format( + ",".join(context.attr.flags), + context.genfiles_dir.path, + ), + ] + + arguments += get_include_protoc_args(includes) + arguments += [ + "--proto_path={}".format(context.genfiles_dir.path) + for proto in protos + ] + for proto in protos: + massaged_path = proto.path + if massaged_path.startswith(context.genfiles_dir.path): + massaged_path = proto.path[len(context.genfiles_dir.path) + 1:] + arguments.append(massaged_path) + + well_known_proto_files = [] + if context.attr.well_known_protos: + well_known_proto_directory = context.attr.well_known_protos.files.to_list( + )[0].dirname + + arguments += ["-I{}".format(well_known_proto_directory + "/../..")] + well_known_proto_files = context.attr.well_known_protos.files.to_list() + + context.actions.run( + inputs = protos + includes + well_known_proto_files, + tools = tools, + outputs = out_files, + executable = context.executable._protoc, + arguments = arguments, + mnemonic = "ProtocInvocation", + ) + return struct(files = depset(out_files)) + +__generate_py = rule( + attrs = { + "deps": attr.label_list( + mandatory = True, + allow_empty = False, + providers = ["proto"], + ), + "plugin": attr.label( + executable = True, + providers = ["files_to_run"], + cfg = "host", + ), + "flags": attr.string_list( + mandatory = False, + allow_empty = True, + ), + "well_known_protos": attr.label(mandatory = False), + "_protoc": attr.label( + default = Label("//external:protocol_compiler"), + executable = True, + cfg = "host", + ), + }, + output_to_genfiles = True, + implementation = _generate_py_impl, +) + +def _generate_py(well_known_protos, **kwargs): + if well_known_protos: + __generate_py( + well_known_protos = "@com_google_protobuf//:well_known_protos", + **kwargs + ) + else: + __generate_py(**kwargs) + +_WELL_KNOWN_PROTO_LIBS = [ + "@com_google_protobuf//:any_proto", + "@com_google_protobuf//:api_proto", + "@com_google_protobuf//:compiler_plugin_proto", + "@com_google_protobuf//:descriptor_proto", + "@com_google_protobuf//:duration_proto", + "@com_google_protobuf//:empty_proto", + "@com_google_protobuf//:field_mask_proto", + "@com_google_protobuf//:source_context_proto", + "@com_google_protobuf//:struct_proto", + "@com_google_protobuf//:timestamp_proto", + "@com_google_protobuf//:type_proto", + "@com_google_protobuf//:wrappers_proto", +] + +def py_proto_library( + name, + deps, + well_known_protos = True, + proto_only = False, + **kwargs): + """Generate python code for a protobuf. + + Args: + name: The name of the target. + deps: A list of dependencies. Must contain a single element. + well_known_protos: A bool indicating whether or not to include well-known + protos. + proto_only: A bool indicating whether to generate vanilla protobuf code + or to also generate gRPC code. + """ + if len(deps) > 1: + fail("The supported length of 'deps' is 1.") + + codegen_target = "_{}_codegen".format(name) + codegen_grpc_target = "_{}_grpc_codegen".format(name) + + well_known_proto_rules = _WELL_KNOWN_PROTO_LIBS if well_known_protos else [] + + _generate_py( + name = codegen_target, + deps = deps, + well_known_protos = well_known_protos, + **kwargs + ) + + if not proto_only: + _generate_py( + name = codegen_grpc_target, + deps = deps, + plugin = "//:grpc_python_plugin", + well_known_protos = well_known_protos, + **kwargs + ) + + native.py_library( + name = name, + srcs = [ + ":{}".format(codegen_grpc_target), + ":{}".format(codegen_target), + ], + deps = [requirement("protobuf")], + **kwargs + ) + else: + native.py_library( + name = name, + srcs = [":{}".format(codegen_target), ":{}".format(codegen_target)], + deps = [requirement("protobuf")], + **kwargs + ) diff --git a/examples/BUILD b/examples/BUILD index d2b39b87f4d..d5fb6903d7c 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -16,9 +16,8 @@ licenses(["notice"]) # 3-clause BSD package(default_visibility = ["//visibility:public"]) -load("@grpc_python_dependencies//:requirements.bzl", "requirement") load("//bazel:grpc_build_system.bzl", "grpc_proto_library") -load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_library") +load("//bazel:python_rules.bzl", "py_proto_library") grpc_proto_library( name = "auth_sample", @@ -45,11 +44,14 @@ grpc_proto_library( srcs = ["protos/keyvaluestore.proto"], ) +proto_library( + name = "helloworld_proto_descriptor", + srcs = ["protos/helloworld.proto"], +) + py_proto_library( name = "py_helloworld", - protos = ["protos/helloworld.proto"], - with_grpc = True, - deps = [requirement('protobuf'),], + deps = [":helloworld_proto_descriptor"], ) cc_binary( diff --git a/examples/python/errors/client.py b/examples/python/errors/client.py index a79b8fce1bd..c762d798dc2 100644 --- a/examples/python/errors/client.py +++ b/examples/python/errors/client.py @@ -20,8 +20,8 @@ import grpc from grpc_status import rpc_status from google.rpc import error_details_pb2 -from examples.protos import helloworld_pb2 -from examples.protos import helloworld_pb2_grpc +from examples import helloworld_pb2 +from examples import helloworld_pb2_grpc _LOGGER = logging.getLogger(__name__) diff --git a/examples/python/errors/server.py b/examples/python/errors/server.py index f49586b848a..50d4a2ac671 100644 --- a/examples/python/errors/server.py +++ b/examples/python/errors/server.py @@ -24,8 +24,8 @@ from grpc_status import rpc_status from google.protobuf import any_pb2 from google.rpc import code_pb2, status_pb2, error_details_pb2 -from examples.protos import helloworld_pb2 -from examples.protos import helloworld_pb2_grpc +from examples import helloworld_pb2 +from examples import helloworld_pb2_grpc _ONE_DAY_IN_SECONDS = 60 * 60 * 24 diff --git a/examples/python/errors/test/_error_handling_example_test.py b/examples/python/errors/test/_error_handling_example_test.py index a79ca45e2a1..9eb81ba3742 100644 --- a/examples/python/errors/test/_error_handling_example_test.py +++ b/examples/python/errors/test/_error_handling_example_test.py @@ -26,7 +26,7 @@ import logging import grpc -from examples.protos import helloworld_pb2_grpc +from examples import helloworld_pb2_grpc from examples.python.errors import client as error_handling_client from examples.python.errors import server as error_handling_server diff --git a/examples/python/multiprocessing/BUILD b/examples/python/multiprocessing/BUILD index 6de1e947d85..0e135f471f2 100644 --- a/examples/python/multiprocessing/BUILD +++ b/examples/python/multiprocessing/BUILD @@ -15,12 +15,17 @@ # limitations under the License. load("@grpc_python_dependencies//:requirements.bzl", "requirement") -load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_library") +load("//bazel:python_rules.bzl", "py_proto_library") + +proto_library( + name = "prime_proto", + srcs = ["prime.proto"] +) py_proto_library( - name = "prime_proto", - protos = ["prime.proto",], - deps = [requirement("protobuf")], + name = "prime_proto_pb2", + deps = [":prime_proto"], + well_known_protos = False, ) py_binary( @@ -29,7 +34,7 @@ py_binary( srcs = ["client.py"], deps = [ "//src/python/grpcio/grpc:grpcio", - ":prime_proto", + ":prime_proto_pb2", ], default_python_version = "PY3", ) @@ -40,7 +45,7 @@ py_binary( srcs = ["server.py"], deps = [ "//src/python/grpcio/grpc:grpcio", - ":prime_proto" + ":prime_proto_pb2" ] + select({ "//conditions:default": [requirement("futures")], "//:python3": [], diff --git a/examples/python/wait_for_ready/wait_for_ready_example.py b/examples/python/wait_for_ready/wait_for_ready_example.py index 7c16b9bd4a1..a0f076e894a 100644 --- a/examples/python/wait_for_ready/wait_for_ready_example.py +++ b/examples/python/wait_for_ready/wait_for_ready_example.py @@ -22,8 +22,8 @@ import threading import grpc -from examples.protos import helloworld_pb2 -from examples.protos import helloworld_pb2_grpc +from examples import helloworld_pb2 +from examples import helloworld_pb2_grpc _LOGGER = logging.getLogger(__name__) _LOGGER.setLevel(logging.INFO) @@ -33,10 +33,13 @@ _ONE_DAY_IN_SECONDS = 60 * 60 * 24 @contextmanager def get_free_loopback_tcp_port(): - tcp_socket = socket.socket(socket.AF_INET6) + if socket.has_ipv6: + tcp_socket = socket.socket(socket.AF_INET6) + else: + tcp_socket = socket.socket(socket.AF_INET) tcp_socket.bind(('', 0)) address_tuple = tcp_socket.getsockname() - yield "[::1]:%s" % (address_tuple[1]) + yield "localhost:%s" % (address_tuple[1]) tcp_socket.close() diff --git a/src/proto/grpc/channelz/BUILD b/src/proto/grpc/channelz/BUILD index b6b485e3e8d..1d80ec23af1 100644 --- a/src/proto/grpc/channelz/BUILD +++ b/src/proto/grpc/channelz/BUILD @@ -25,6 +25,11 @@ grpc_proto_library( well_known_protos = True, ) +proto_library( + name = "channelz_proto_descriptors", + srcs = ["channelz.proto"], +) + filegroup( name = "channelz_proto_file", srcs = [ diff --git a/src/proto/grpc/health/v1/BUILD b/src/proto/grpc/health/v1/BUILD index 38a7d992e06..fc58e8a1770 100644 --- a/src/proto/grpc/health/v1/BUILD +++ b/src/proto/grpc/health/v1/BUILD @@ -23,6 +23,11 @@ grpc_proto_library( srcs = ["health.proto"], ) +proto_library( + name = "health_proto_descriptor", + srcs = ["health.proto"], +) + filegroup( name = "health_proto_file", srcs = [ diff --git a/src/proto/grpc/reflection/v1alpha/BUILD b/src/proto/grpc/reflection/v1alpha/BUILD index 4d919d029ee..5424c0d867e 100644 --- a/src/proto/grpc/reflection/v1alpha/BUILD +++ b/src/proto/grpc/reflection/v1alpha/BUILD @@ -23,6 +23,11 @@ grpc_proto_library( srcs = ["reflection.proto"], ) +proto_library( + name = "reflection_proto_descriptor", + srcs = ["reflection.proto"], +) + filegroup( name = "reflection_proto_file", srcs = [ diff --git a/src/proto/grpc/testing/BUILD b/src/proto/grpc/testing/BUILD index 9876d5160a1..16e47d81061 100644 --- a/src/proto/grpc/testing/BUILD +++ b/src/proto/grpc/testing/BUILD @@ -16,7 +16,7 @@ licenses(["notice"]) # Apache v2 load("//bazel:grpc_build_system.bzl", "grpc_proto_library", "grpc_package") load("@grpc_python_dependencies//:requirements.bzl", "requirement") -load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_library") +load("//bazel:python_rules.bzl", "py_proto_library") grpc_package(name = "testing", visibility = "public") @@ -61,13 +61,14 @@ grpc_proto_library( has_services = False, ) +proto_library( + name = "empty_proto_descriptor", + srcs = ["empty.proto"], +) + py_proto_library( name = "py_empty_proto", - protos = ["empty.proto",], - with_grpc = True, - deps = [ - requirement('protobuf'), - ], + deps = [":empty_proto_descriptor"], ) grpc_proto_library( @@ -76,13 +77,14 @@ grpc_proto_library( has_services = False, ) +proto_library( + name = "messages_proto_descriptor", + srcs = ["messages.proto"], +) + py_proto_library( name = "py_messages_proto", - protos = ["messages.proto",], - with_grpc = True, - deps = [ - requirement('protobuf'), - ], + deps = [":messages_proto_descriptor"], ) grpc_proto_library( @@ -144,16 +146,19 @@ grpc_proto_library( ], ) +proto_library( + name = "test_proto_descriptor", + srcs = ["test.proto"], + deps = [ + ":empty_proto_descriptor", + ":messages_proto_descriptor", + ], +) + py_proto_library( name = "py_test_proto", - protos = ["test.proto",], - with_grpc = True, deps = [ - requirement('protobuf'), - ], - proto_deps = [ - ":py_empty_proto", - ":py_messages_proto", + ":test_proto_descriptor", ] ) diff --git a/src/proto/grpc/testing/proto2/BUILD.bazel b/src/proto/grpc/testing/proto2/BUILD.bazel index c4c4f004efb..e939c523a64 100644 --- a/src/proto/grpc/testing/proto2/BUILD.bazel +++ b/src/proto/grpc/testing/proto2/BUILD.bazel @@ -1,30 +1,32 @@ load("@grpc_python_dependencies//:requirements.bzl", "requirement") -load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_library") package(default_visibility = ["//visibility:public"]) +load("//bazel:python_rules.bzl", "py_proto_library") + +proto_library( + name = "empty2_proto_descriptor", + srcs = ["empty2.proto"], +) py_proto_library( name = "empty2_proto", - protos = [ - "empty2.proto", - ], - with_grpc = True, deps = [ - requirement('protobuf'), + ":empty2_proto_descriptor", ], ) +proto_library( + name = "empty2_extensions_proto_descriptor", + srcs = ["empty2_extensions.proto"], + deps = [ + ":empty2_proto_descriptor", + ] +) + py_proto_library( name = "empty2_extensions_proto", - protos = [ - "empty2_extensions.proto", - ], - proto_deps = [ - ":empty2_proto", - ], - with_grpc = True, deps = [ - requirement('protobuf'), + ":empty2_extensions_proto_descriptor", ], ) diff --git a/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel b/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel index aae8cedb760..eccc166577d 100644 --- a/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel +++ b/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel @@ -1,30 +1,10 @@ -load("@grpc_python_dependencies//:requirements.bzl", "requirement") -load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_library") - +load("//bazel:python_rules.bzl", "py_proto_library") package(default_visibility = ["//visibility:public"]) -genrule( - name = "mv_channelz_proto", - srcs = [ - "//src/proto/grpc/channelz:channelz_proto_file", - ], - outs = ["channelz.proto",], - cmd = "cp $< $@", -) - py_proto_library( name = "py_channelz_proto", - protos = ["mv_channelz_proto",], - imports = [ - "external/com_google_protobuf/src/", - ], - inputs = [ - "@com_google_protobuf//:well_known_protos", - ], - with_grpc = True, - deps = [ - requirement('protobuf'), - ], + well_known_protos = True, + deps = ["//src/proto/grpc/channelz:channelz_proto_descriptors"], ) py_library( diff --git a/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel b/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel index ce3121fa90e..9e4fff34581 100644 --- a/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel +++ b/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel @@ -1,24 +1,9 @@ -load("@grpc_python_dependencies//:requirements.bzl", "requirement") -load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_library") - +load("//bazel:python_rules.bzl", "py_proto_library") package(default_visibility = ["//visibility:public"]) -genrule( - name = "mv_health_proto", - srcs = [ - "//src/proto/grpc/health/v1:health_proto_file", - ], - outs = ["health.proto",], - cmd = "cp $< $@", -) - py_proto_library( name = "py_health_proto", - protos = [":mv_health_proto",], - with_grpc = True, - deps = [ - requirement('protobuf'), - ], + deps = ["//src/proto/grpc/health/v1:health_proto_descriptor",], ) py_library( diff --git a/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel b/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel index 3a2ba263715..6aaa4dd3bdd 100644 --- a/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel +++ b/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel @@ -1,24 +1,11 @@ +load("//bazel:python_rules.bzl", "py_proto_library") load("@grpc_python_dependencies//:requirements.bzl", "requirement") -load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_library") package(default_visibility = ["//visibility:public"]) -genrule( - name = "mv_reflection_proto", - srcs = [ - "//src/proto/grpc/reflection/v1alpha:reflection_proto_file", - ], - outs = ["reflection.proto",], - cmd = "cp $< $@", -) - py_proto_library( name = "py_reflection_proto", - protos = [":mv_reflection_proto",], - with_grpc = True, - deps = [ - requirement('protobuf'), - ], + deps = ["//src/proto/grpc/reflection/v1alpha:reflection_proto_descriptor",], ) py_library( diff --git a/src/python/grpcio_tests/tests/reflection/BUILD.bazel b/src/python/grpcio_tests/tests/reflection/BUILD.bazel index c0efb0b7cef..b635b721631 100644 --- a/src/python/grpcio_tests/tests/reflection/BUILD.bazel +++ b/src/python/grpcio_tests/tests/reflection/BUILD.bazel @@ -14,6 +14,7 @@ py_test( "//src/python/grpcio_tests/tests/unit:test_common", "//src/proto/grpc/testing:py_empty_proto", "//src/proto/grpc/testing/proto2:empty2_extensions_proto", + "//src/proto/grpc/testing/proto2:empty2_proto", requirement('protobuf'), ], imports=["../../",], diff --git a/tools/distrib/bazel_style.cfg b/tools/distrib/bazel_style.cfg new file mode 100644 index 00000000000..a5a1fea4aba --- /dev/null +++ b/tools/distrib/bazel_style.cfg @@ -0,0 +1,4 @@ +[style] +based_on_style = google +allow_split_before_dict_value = False +spaces_around_default_or_named_assign = True diff --git a/tools/distrib/format_bazel.sh b/tools/distrib/format_bazel.sh new file mode 100755 index 00000000000..ee230118efb --- /dev/null +++ b/tools/distrib/format_bazel.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Copyright 2019 The gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set=-ex + +VIRTUAL_ENV=bazel_format_virtual_environment + +CONFIG_PATH="$(dirname ${0})/bazel_style.cfg" + +python -m virtualenv ${VIRTUAL_ENV} +PYTHON=${VIRTUAL_ENV}/bin/python +"$PYTHON" -m pip install --upgrade pip==10.0.1 +"$PYTHON" -m pip install --upgrade futures +"$PYTHON" -m pip install yapf==0.20.0 + +pushd "$(dirname "${0}")/../.." +FILES=$(find . -path ./third_party -prune -o -name '*.bzl' -print) +echo "${FILES}" | xargs "$PYTHON" -m yapf -i --style="${CONFIG_PATH}" + +if ! which buildifier &>/dev/null; then + echo 'buildifer must be installed.' >/dev/stderr + exit 1 +fi + +echo "${FILES}" | xargs buildifier --type=bzl + +popd diff --git a/tools/internal_ci/linux/grpc_bazel_build_in_docker.sh b/tools/internal_ci/linux/grpc_bazel_build_in_docker.sh index 3dd0167b7c0..24598f43f02 100755 --- a/tools/internal_ci/linux/grpc_bazel_build_in_docker.sh +++ b/tools/internal_ci/linux/grpc_bazel_build_in_docker.sh @@ -24,5 +24,4 @@ git clone /var/local/jenkins/grpc /var/local/git/grpc && git submodule update --init --reference /var/local/jenkins/grpc/${name} \ ${name}') cd /var/local/git/grpc -#TODO(yfen): add back examples/... to build targets once python rules issues are resolved -bazel build --spawn_strategy=standalone --genrule_strategy=standalone :all test/... +bazel build --spawn_strategy=standalone --genrule_strategy=standalone :all test/... examples/... diff --git a/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh b/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh index 3ca4673ca08..d844cff7f9a 100755 --- a/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh +++ b/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh @@ -23,10 +23,9 @@ git clone /var/local/jenkins/grpc /var/local/git/grpc (cd /var/local/jenkins/grpc/ && git submodule foreach 'cd /var/local/git/grpc \ && git submodule update --init --reference /var/local/jenkins/grpc/${name} \ ${name}') -#TODO(yfen): temporarily disabled all python bazel tests due to incompatibility with bazel 0.23.2 -#cd /var/local/git/grpc/test -#bazel test --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //src/python/... -#bazel test --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //examples/python/... -#bazel clean --expunge -#bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //src/python/... -#bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //examples/python/... +cd /var/local/git/grpc/test +bazel test --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //src/python/... +bazel test --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //examples/python/... +bazel clean --expunge +bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //src/python/... +bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //examples/python/... From 714a13c193c588967201132af4bb56f8cf47ded6 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Tue, 30 Apr 2019 14:15:50 -0400 Subject: [PATCH 0067/1555] Initialize TCP write and error closures only once. We are initializing the closures in the hot path on every event. --- src/core/lib/iomgr/tcp_posix.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index 30305a94f37..b140ae0ccae 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -271,16 +271,8 @@ static void notify_on_write(grpc_tcp* tcp) { if (grpc_tcp_trace.enabled()) { gpr_log(GPR_INFO, "TCP:%p notify_on_write", tcp); } - if (grpc_event_engine_run_in_background()) { - // If there is a polling engine always running in the background, there is - // no need to run the backup poller. - GRPC_CLOSURE_INIT(&tcp->write_done_closure, tcp_handle_write, tcp, - grpc_schedule_on_exec_ctx); - } else { + if (!grpc_event_engine_run_in_background()) { cover_self(tcp); - GRPC_CLOSURE_INIT(&tcp->write_done_closure, - tcp_drop_uncovered_then_handle_write, tcp, - grpc_schedule_on_exec_ctx); } grpc_fd_notify_on_write(tcp->em_fd, &tcp->write_done_closure); } @@ -884,8 +876,6 @@ static void tcp_handle_error(void* arg /* grpc_tcp */, grpc_error* error) { * ready. */ grpc_fd_set_readable(tcp->em_fd); grpc_fd_set_writable(tcp->em_fd); - GRPC_CLOSURE_INIT(&tcp->error_closure, tcp_handle_error, tcp, - grpc_schedule_on_exec_ctx); grpc_fd_notify_on_error(tcp->em_fd, &tcp->error_closure); } @@ -1248,6 +1238,16 @@ grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd, tcp->tb_head = nullptr; GRPC_CLOSURE_INIT(&tcp->read_done_closure, tcp_handle_read, tcp, grpc_schedule_on_exec_ctx); + if (grpc_event_engine_run_in_background()) { + // If there is a polling engine always running in the background, there is + // no need to run the backup poller. + GRPC_CLOSURE_INIT(&tcp->write_done_closure, tcp_handle_write, tcp, + grpc_schedule_on_exec_ctx); + } else { + GRPC_CLOSURE_INIT(&tcp->write_done_closure, + tcp_drop_uncovered_then_handle_write, tcp, + grpc_schedule_on_exec_ctx); + } /* Always assume there is something on the queue to read. */ tcp->inq = 1; #ifdef GRPC_HAVE_TCP_INQ From 6b0806eae327afd05f58f9fc68783850ba98749a Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 30 Apr 2019 11:22:04 -0700 Subject: [PATCH 0068/1555] more formatting changes --- include/grpcpp/server_impl.h | 6 +++--- src/cpp/server/server_cc.cc | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/grpcpp/server_impl.h b/include/grpcpp/server_impl.h index 14b16a06f4e..46bacf81d26 100644 --- a/include/grpcpp/server_impl.h +++ b/include/grpcpp/server_impl.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -49,7 +50,6 @@ class ServerContext; namespace grpc_impl { -class HealthCheckServiceInterface; class ServerInitializer; /// Represents a gRPC server. @@ -99,7 +99,7 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { grpc_server* c_server(); /// Returns the health check service. - grpc_impl::HealthCheckServiceInterface* GetHealthCheckService() const { + grpc::HealthCheckServiceInterface* GetHealthCheckService() const { return health_check_service_.get(); } @@ -333,7 +333,7 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { std::unique_ptr server_initializer_; - std::unique_ptr health_check_service_; + std::unique_ptr health_check_service_; bool health_check_service_disabled_; // When appropriate, use a default callback generic service to handle diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc index 31bdc553f8b..9c2b1ee13fc 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -753,9 +753,9 @@ class Server::CallbackRequest final : public Server::CallbackRequestBase { &server_->callback_unmatched_reqs_count_[method_index_], 1); grpc_metadata_array_init(&request_metadata_); ctx_.Setup(gpr_inf_future(GPR_CLOCK_REALTIME)); - handler_data_ = nullptr; request_payload_ = nullptr; request_ = nullptr; + handler_data_ = nullptr; request_status_ = grpc::Status(); } From 2cb63d859d69512a92685a19887ea7428c47bb9f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 30 Apr 2019 20:29:42 +0200 Subject: [PATCH 0069/1555] split multilang jobs by language --- .../linux/grpc_basictests_csharp.cfg | 30 ++++++++++++++++++ .../linux/grpc_basictests_node.cfg | 30 ++++++++++++++++++ .../internal_ci/linux/grpc_basictests_php.cfg | 30 ++++++++++++++++++ .../linux/grpc_basictests_python.cfg | 30 ++++++++++++++++++ .../linux/grpc_basictests_ruby.cfg | 30 ++++++++++++++++++ .../macos/grpc_basictests_c_cpp.cfg | 31 +++++++++++++++++++ .../macos/grpc_basictests_csharp.cfg | 31 +++++++++++++++++++ .../macos/grpc_basictests_node.cfg | 31 +++++++++++++++++++ .../internal_ci/macos/grpc_basictests_php.cfg | 31 +++++++++++++++++++ .../macos/grpc_basictests_python.cfg | 31 +++++++++++++++++++ .../macos/grpc_basictests_ruby.cfg | 31 +++++++++++++++++++ .../internal_ci/windows/grpc_basictests_c.cfg | 30 ++++++++++++++++++ .../windows/grpc_basictests_csharp.cfg | 30 ++++++++++++++++++ .../windows/grpc_basictests_python.cfg | 30 ++++++++++++++++++ 14 files changed, 426 insertions(+) create mode 100644 tools/internal_ci/linux/grpc_basictests_csharp.cfg create mode 100644 tools/internal_ci/linux/grpc_basictests_node.cfg create mode 100644 tools/internal_ci/linux/grpc_basictests_php.cfg create mode 100644 tools/internal_ci/linux/grpc_basictests_python.cfg create mode 100644 tools/internal_ci/linux/grpc_basictests_ruby.cfg create mode 100644 tools/internal_ci/macos/grpc_basictests_c_cpp.cfg create mode 100644 tools/internal_ci/macos/grpc_basictests_csharp.cfg create mode 100644 tools/internal_ci/macos/grpc_basictests_node.cfg create mode 100644 tools/internal_ci/macos/grpc_basictests_php.cfg create mode 100644 tools/internal_ci/macos/grpc_basictests_python.cfg create mode 100644 tools/internal_ci/macos/grpc_basictests_ruby.cfg create mode 100644 tools/internal_ci/windows/grpc_basictests_c.cfg create mode 100644 tools/internal_ci/windows/grpc_basictests_csharp.cfg create mode 100644 tools/internal_ci/windows/grpc_basictests_python.cfg diff --git a/tools/internal_ci/linux/grpc_basictests_csharp.cfg b/tools/internal_ci/linux/grpc_basictests_csharp.cfg new file mode 100644 index 00000000000..017e929beff --- /dev/null +++ b/tools/internal_ci/linux/grpc_basictests_csharp.cfg @@ -0,0 +1,30 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/linux/grpc_run_tests_matrix.sh" +timeout_mins: 60 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests linux csharp --inner_jobs 16 -j 2 --internal_ci --bq_result_table aggregate_results" +} diff --git a/tools/internal_ci/linux/grpc_basictests_node.cfg b/tools/internal_ci/linux/grpc_basictests_node.cfg new file mode 100644 index 00000000000..d7b35a04719 --- /dev/null +++ b/tools/internal_ci/linux/grpc_basictests_node.cfg @@ -0,0 +1,30 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/linux/grpc_run_tests_matrix.sh" +timeout_mins: 60 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests linux grpc-node --inner_jobs 16 -j 2 --internal_ci --bq_result_table aggregate_results" +} diff --git a/tools/internal_ci/linux/grpc_basictests_php.cfg b/tools/internal_ci/linux/grpc_basictests_php.cfg new file mode 100644 index 00000000000..80aa0dc87bb --- /dev/null +++ b/tools/internal_ci/linux/grpc_basictests_php.cfg @@ -0,0 +1,30 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/linux/grpc_run_tests_matrix.sh" +timeout_mins: 60 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests linux php --inner_jobs 16 -j 2 --internal_ci --bq_result_table aggregate_results" +} diff --git a/tools/internal_ci/linux/grpc_basictests_python.cfg b/tools/internal_ci/linux/grpc_basictests_python.cfg new file mode 100644 index 00000000000..444dba9f4df --- /dev/null +++ b/tools/internal_ci/linux/grpc_basictests_python.cfg @@ -0,0 +1,30 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/linux/grpc_run_tests_matrix.sh" +timeout_mins: 60 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests linux python --inner_jobs 16 -j 2 --internal_ci --bq_result_table aggregate_results" +} diff --git a/tools/internal_ci/linux/grpc_basictests_ruby.cfg b/tools/internal_ci/linux/grpc_basictests_ruby.cfg new file mode 100644 index 00000000000..336aa469958 --- /dev/null +++ b/tools/internal_ci/linux/grpc_basictests_ruby.cfg @@ -0,0 +1,30 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/linux/grpc_run_tests_matrix.sh" +timeout_mins: 60 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests linux ruby --inner_jobs 16 -j 2 --internal_ci --bq_result_table aggregate_results" +} diff --git a/tools/internal_ci/macos/grpc_basictests_c_cpp.cfg b/tools/internal_ci/macos/grpc_basictests_c_cpp.cfg new file mode 100644 index 00000000000..9783dd64673 --- /dev/null +++ b/tools/internal_ci/macos/grpc_basictests_c_cpp.cfg @@ -0,0 +1,31 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" +timeout_mins: 60 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests macos corelang --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results" +} diff --git a/tools/internal_ci/macos/grpc_basictests_csharp.cfg b/tools/internal_ci/macos/grpc_basictests_csharp.cfg new file mode 100644 index 00000000000..d3e04e71f71 --- /dev/null +++ b/tools/internal_ci/macos/grpc_basictests_csharp.cfg @@ -0,0 +1,31 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" +timeout_mins: 60 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests macos csharp --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results" +} diff --git a/tools/internal_ci/macos/grpc_basictests_node.cfg b/tools/internal_ci/macos/grpc_basictests_node.cfg new file mode 100644 index 00000000000..9dfd6a7b9e8 --- /dev/null +++ b/tools/internal_ci/macos/grpc_basictests_node.cfg @@ -0,0 +1,31 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" +timeout_mins: 60 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests macos grpc-node --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results" +} diff --git a/tools/internal_ci/macos/grpc_basictests_php.cfg b/tools/internal_ci/macos/grpc_basictests_php.cfg new file mode 100644 index 00000000000..091f68efaba --- /dev/null +++ b/tools/internal_ci/macos/grpc_basictests_php.cfg @@ -0,0 +1,31 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" +timeout_mins: 60 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests macos php --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results" +} diff --git a/tools/internal_ci/macos/grpc_basictests_python.cfg b/tools/internal_ci/macos/grpc_basictests_python.cfg new file mode 100644 index 00000000000..ae80ac317ff --- /dev/null +++ b/tools/internal_ci/macos/grpc_basictests_python.cfg @@ -0,0 +1,31 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" +timeout_mins: 60 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests macos python --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results" +} diff --git a/tools/internal_ci/macos/grpc_basictests_ruby.cfg b/tools/internal_ci/macos/grpc_basictests_ruby.cfg new file mode 100644 index 00000000000..3a28f97a54b --- /dev/null +++ b/tools/internal_ci/macos/grpc_basictests_ruby.cfg @@ -0,0 +1,31 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" +timeout_mins: 60 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests macos ruby --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results" +} diff --git a/tools/internal_ci/windows/grpc_basictests_c.cfg b/tools/internal_ci/windows/grpc_basictests_c.cfg new file mode 100644 index 00000000000..150a28e3f89 --- /dev/null +++ b/tools/internal_ci/windows/grpc_basictests_c.cfg @@ -0,0 +1,30 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/windows/grpc_run_tests_matrix.bat" +timeout_mins: 60 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests windows c -j 1 --inner_jobs 8 --internal_ci --bq_result_table aggregate_results" +} diff --git a/tools/internal_ci/windows/grpc_basictests_csharp.cfg b/tools/internal_ci/windows/grpc_basictests_csharp.cfg new file mode 100644 index 00000000000..17a362fb32a --- /dev/null +++ b/tools/internal_ci/windows/grpc_basictests_csharp.cfg @@ -0,0 +1,30 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/windows/grpc_run_tests_matrix.bat" +timeout_mins: 60 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests windows csharp -j 1 --inner_jobs 8 --internal_ci --bq_result_table aggregate_results" +} diff --git a/tools/internal_ci/windows/grpc_basictests_python.cfg b/tools/internal_ci/windows/grpc_basictests_python.cfg new file mode 100644 index 00000000000..b0f6f6772d3 --- /dev/null +++ b/tools/internal_ci/windows/grpc_basictests_python.cfg @@ -0,0 +1,30 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/windows/grpc_run_tests_matrix.bat" +timeout_mins: 60 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests windows python -j 1 --inner_jobs 8 --internal_ci --bq_result_table aggregate_results" +} From 058e90ef161e31d1f892b49c0ee6cb0ba3957e9e Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Tue, 30 Apr 2019 11:12:19 -0700 Subject: [PATCH 0070/1555] Tiny fix for combiner comment --- src/core/lib/iomgr/combiner.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/combiner.h b/src/core/lib/iomgr/combiner.h index 3c947bf9d64..b9274216993 100644 --- a/src/core/lib/iomgr/combiner.h +++ b/src/core/lib/iomgr/combiner.h @@ -31,7 +31,7 @@ // Provides serialized access to some resource. // Each action queued on a combiner is executed serially in a borrowed thread. // The actual thread executing actions may change over time (but there will only -// every be one at a time). +// ever be one at a time). // Initialize the lock, with an optional workqueue to shift load to when // necessary From dc148b6a303262124ac96a41a78e6bbd3770a83b Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Tue, 30 Apr 2019 10:29:11 -0700 Subject: [PATCH 0071/1555] Fix regression where we do not properly account for freed interned metadata. --- src/core/lib/transport/metadata.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc index e3b8d112795..7e0b2163246 100644 --- a/src/core/lib/transport/metadata.cc +++ b/src/core/lib/transport/metadata.cc @@ -211,7 +211,6 @@ void grpc_mdctx_global_shutdown() { mdtab_shard* shard = &g_shards[i]; gpr_mu_destroy(&shard->mu); gc_mdtab(shard); - /* TODO(ctiller): GPR_ASSERT(shard->count == 0); */ if (shard->count != 0) { gpr_log(GPR_DEBUG, "WARNING: %" PRIuPTR " metadata elements were leaked", shard->count); @@ -219,6 +218,7 @@ void grpc_mdctx_global_shutdown() { abort(); } } + GPR_DEBUG_ASSERT(shard->count == 0); gpr_free(shard->elems); } } @@ -251,7 +251,9 @@ static void gc_mdtab(mdtab_shard* shard) { GPR_TIMER_SCOPE("gc_mdtab", 0); size_t num_freed = 0; for (size_t i = 0; i < shard->capacity; ++i) { - num_freed += InternedMetadata::CleanupLinkedMetadata(&shard->elems[i]); + intptr_t freed = InternedMetadata::CleanupLinkedMetadata(&shard->elems[i]); + num_freed += freed; + shard->count -= freed; } gpr_atm_no_barrier_fetch_add(&shard->free_estimate, -static_cast(num_freed)); From 22c6e166c439481d5d5fa0990b8c59db92ec5152 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Tue, 30 Apr 2019 11:49:34 -0700 Subject: [PATCH 0072/1555] Use platform align_malloc function when setting custom allocators and no override provided --- src/core/lib/gpr/alloc.cc | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/core/lib/gpr/alloc.cc b/src/core/lib/gpr/alloc.cc index b12b7d8534d..f79e645971a 100644 --- a/src/core/lib/gpr/alloc.cc +++ b/src/core/lib/gpr/alloc.cc @@ -43,21 +43,9 @@ static constexpr bool is_power_of_two(size_t value) { } #endif -static void* aligned_alloc_with_gpr_malloc(size_t size, size_t alignment) { - GPR_DEBUG_ASSERT(is_power_of_two(alignment)); - size_t extra = alignment - 1 + sizeof(void*); - void* p = gpr_malloc(size + extra); - void** ret = (void**)(((uintptr_t)p + extra) & ~(alignment - 1)); - ret[-1] = p; - return (void*)ret; -} - -static void aligned_free_with_gpr_malloc(void* ptr) { - gpr_free((static_cast(ptr))[-1]); -} - static void* platform_malloc_aligned(size_t size, size_t alignment) { #if defined(GPR_HAS_ALIGNED_ALLOC) + GPR_DEBUG_ASSERT(is_power_of_two(alignment)); size = GPR_ROUND_UP_TO_ALIGNMENT_SIZE(size, alignment); void* ret = aligned_alloc(alignment, size); GPR_ASSERT(ret != nullptr); @@ -74,7 +62,12 @@ static void* platform_malloc_aligned(size_t size, size_t alignment) { GPR_ASSERT(posix_memalign(&ret, alignment, size) == 0); return ret; #else - return aligned_alloc_with_gpr_malloc(size, alignment); + GPR_DEBUG_ASSERT(is_power_of_two(alignment)); + size_t extra = alignment - 1 + sizeof(void*); + void* p = gpr_malloc(size + extra); + void** ret = (void**)(((uintptr_t)p + extra) & ~(alignment - 1)); + ret[-1] = p; + return (void*)ret; #endif } @@ -84,7 +77,7 @@ static void platform_free_aligned(void* ptr) { #elif defined(GPR_HAS_ALIGNED_MALLOC) _aligned_free(ptr); #else - aligned_free_with_gpr_malloc(ptr); + gpr_free((static_cast(ptr))[-1]); #endif } @@ -106,8 +99,8 @@ void gpr_set_allocation_functions(gpr_allocation_functions functions) { GPR_ASSERT((functions.aligned_alloc_fn == nullptr) == (functions.aligned_free_fn == nullptr)); if (functions.aligned_alloc_fn == nullptr) { - functions.aligned_alloc_fn = aligned_alloc_with_gpr_malloc; - functions.aligned_free_fn = aligned_free_with_gpr_malloc; + functions.aligned_alloc_fn = platform_malloc_aligned; + functions.aligned_free_fn = platform_free_aligned; } g_alloc_functions = functions; } From ac3a91edf8d15a405fffba7e1acb55d5a0c47796 Mon Sep 17 00:00:00 2001 From: yang-g Date: Mon, 29 Apr 2019 15:47:58 -0700 Subject: [PATCH 0073/1555] Support accepting external connections. --- BUILD | 2 + BUILD.gn | 2 + CMakeLists.txt | 45 +++ Makefile | 51 +++ build.yaml | 15 + gRPC-C++.podspec | 3 + grpc.gyp | 2 + include/grpcpp/impl/codegen/byte_buffer.h | 5 + include/grpcpp/server.h | 28 +- include/grpcpp/server_builder_impl.h | 29 +- include/grpcpp/server_impl.h | 7 +- .../transport/chttp2/server/chttp2_server.cc | 57 ++- src/core/lib/channel/handshaker.cc | 6 + src/core/lib/iomgr/tcp_server.cc | 5 + src/core/lib/iomgr/tcp_server.h | 22 ++ src/core/lib/iomgr/tcp_server_custom.cc | 20 +- src/core/lib/iomgr/tcp_server_posix.cc | 90 ++++- src/core/lib/iomgr/tcp_server_utils_posix.h | 3 + src/core/lib/iomgr/tcp_server_windows.cc | 20 +- .../external_connection_acceptor_impl.cc | 88 +++++ .../external_connection_acceptor_impl.h | 71 ++++ src/cpp/server/server_builder.cc | 17 +- src/cpp/server/server_cc.cc | 23 +- test/cpp/end2end/BUILD | 18 + test/cpp/end2end/port_sharing_end2end_test.cc | 362 ++++++++++++++++++ tools/doxygen/Doxyfile.c++.internal | 2 + .../generated/sources_and_headers.json | 22 ++ tools/run_tests/generated/tests.json | 24 ++ 28 files changed, 991 insertions(+), 48 deletions(-) create mode 100644 src/cpp/server/external_connection_acceptor_impl.cc create mode 100644 src/cpp/server/external_connection_acceptor_impl.h create mode 100644 test/cpp/end2end/port_sharing_end2end_test.cc diff --git a/BUILD b/BUILD index 58043459000..bfeec484a97 100644 --- a/BUILD +++ b/BUILD @@ -141,6 +141,7 @@ GRPCXX_SRCS = [ "src/cpp/server/channel_argument_option.cc", "src/cpp/server/create_default_thread_pool.cc", "src/cpp/server/dynamic_thread_pool.cc", + "src/cpp/server/external_connection_acceptor_impl.cc", "src/cpp/server/health/default_health_check_service.cc", "src/cpp/server/health/health_check_service.cc", "src/cpp/server/health/health_check_service_server_builder_option.cc", @@ -160,6 +161,7 @@ GRPCXX_HDRS = [ "src/cpp/client/create_channel_internal.h", "src/cpp/common/channel_filter.h", "src/cpp/server/dynamic_thread_pool.h", + "src/cpp/server/external_connection_acceptor_impl.h", "src/cpp/server/health/default_health_check_service.h", "src/cpp/server/thread_pool_interface.h", "src/cpp/thread_manager/thread_manager.h", diff --git a/BUILD.gn b/BUILD.gn index 38b2f0e6502..e1ac5d7500a 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1324,6 +1324,8 @@ config("grpc_config") { "src/cpp/server/create_default_thread_pool.cc", "src/cpp/server/dynamic_thread_pool.cc", "src/cpp/server/dynamic_thread_pool.h", + "src/cpp/server/external_connection_acceptor_impl.cc", + "src/cpp/server/external_connection_acceptor_impl.h", "src/cpp/server/health/default_health_check_service.cc", "src/cpp/server/health/default_health_check_service.h", "src/cpp/server/health/health_check_service.cc", diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b93ab08af4..d6eca20bc33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -668,6 +668,7 @@ add_dependencies(buildtests_cxx nonblocking_test) add_dependencies(buildtests_cxx noop-benchmark) add_dependencies(buildtests_cxx optional_test) add_dependencies(buildtests_cxx orphanable_test) +add_dependencies(buildtests_cxx port_sharing_end2end_test) add_dependencies(buildtests_cxx proto_server_reflection_test) add_dependencies(buildtests_cxx proto_utils_test) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) @@ -2927,6 +2928,7 @@ add_library(grpc++ src/cpp/server/channel_argument_option.cc src/cpp/server/create_default_thread_pool.cc src/cpp/server/dynamic_thread_pool.cc + src/cpp/server/external_connection_acceptor_impl.cc src/cpp/server/health/default_health_check_service.cc src/cpp/server/health/health_check_service.cc src/cpp/server/health/health_check_service_server_builder_option.cc @@ -3318,6 +3320,7 @@ add_library(grpc++_cronet src/cpp/server/channel_argument_option.cc src/cpp/server/create_default_thread_pool.cc src/cpp/server/dynamic_thread_pool.cc + src/cpp/server/external_connection_acceptor_impl.cc src/cpp/server/health/default_health_check_service.cc src/cpp/server/health/health_check_service.cc src/cpp/server/health/health_check_service_server_builder_option.cc @@ -4522,6 +4525,7 @@ add_library(grpc++_unsecure src/cpp/server/channel_argument_option.cc src/cpp/server/create_default_thread_pool.cc src/cpp/server/dynamic_thread_pool.cc + src/cpp/server/external_connection_acceptor_impl.cc src/cpp/server/health/default_health_check_service.cc src/cpp/server/health/health_check_service.cc src/cpp/server/health/health_check_service_server_builder_option.cc @@ -14822,6 +14826,47 @@ target_link_libraries(orphanable_test ) +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + +add_executable(port_sharing_end2end_test + test/cpp/end2end/port_sharing_end2end_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(port_sharing_end2end_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(port_sharing_end2end_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + test_tcp_server + grpc++_test_util + grpc_test_util + grpc++ + grpc + gpr + ${_gRPC_GFLAGS_LIBRARIES} +) + + endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index 700e789265e..5f20e183a75 100644 --- a/Makefile +++ b/Makefile @@ -1240,6 +1240,7 @@ nonblocking_test: $(BINDIR)/$(CONFIG)/nonblocking_test noop-benchmark: $(BINDIR)/$(CONFIG)/noop-benchmark optional_test: $(BINDIR)/$(CONFIG)/optional_test orphanable_test: $(BINDIR)/$(CONFIG)/orphanable_test +port_sharing_end2end_test: $(BINDIR)/$(CONFIG)/port_sharing_end2end_test proto_server_reflection_test: $(BINDIR)/$(CONFIG)/proto_server_reflection_test proto_utils_test: $(BINDIR)/$(CONFIG)/proto_utils_test qps_interarrival_test: $(BINDIR)/$(CONFIG)/qps_interarrival_test @@ -1709,6 +1710,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/noop-benchmark \ $(BINDIR)/$(CONFIG)/optional_test \ $(BINDIR)/$(CONFIG)/orphanable_test \ + $(BINDIR)/$(CONFIG)/port_sharing_end2end_test \ $(BINDIR)/$(CONFIG)/proto_server_reflection_test \ $(BINDIR)/$(CONFIG)/proto_utils_test \ $(BINDIR)/$(CONFIG)/qps_interarrival_test \ @@ -1853,6 +1855,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/noop-benchmark \ $(BINDIR)/$(CONFIG)/optional_test \ $(BINDIR)/$(CONFIG)/orphanable_test \ + $(BINDIR)/$(CONFIG)/port_sharing_end2end_test \ $(BINDIR)/$(CONFIG)/proto_server_reflection_test \ $(BINDIR)/$(CONFIG)/proto_utils_test \ $(BINDIR)/$(CONFIG)/qps_interarrival_test \ @@ -2358,6 +2361,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/optional_test || ( echo test optional_test failed ; exit 1 ) $(E) "[RUN] Testing orphanable_test" $(Q) $(BINDIR)/$(CONFIG)/orphanable_test || ( echo test orphanable_test failed ; exit 1 ) + $(E) "[RUN] Testing port_sharing_end2end_test" + $(Q) $(BINDIR)/$(CONFIG)/port_sharing_end2end_test || ( echo test port_sharing_end2end_test failed ; exit 1 ) $(E) "[RUN] Testing proto_server_reflection_test" $(Q) $(BINDIR)/$(CONFIG)/proto_server_reflection_test || ( echo test proto_server_reflection_test failed ; exit 1 ) $(E) "[RUN] Testing proto_utils_test" @@ -5302,6 +5307,7 @@ LIBGRPC++_SRC = \ src/cpp/server/channel_argument_option.cc \ src/cpp/server/create_default_thread_pool.cc \ src/cpp/server/dynamic_thread_pool.cc \ + src/cpp/server/external_connection_acceptor_impl.cc \ src/cpp/server/health/default_health_check_service.cc \ src/cpp/server/health/health_check_service.cc \ src/cpp/server/health/health_check_service_server_builder_option.cc \ @@ -5702,6 +5708,7 @@ LIBGRPC++_CRONET_SRC = \ src/cpp/server/channel_argument_option.cc \ src/cpp/server/create_default_thread_pool.cc \ src/cpp/server/dynamic_thread_pool.cc \ + src/cpp/server/external_connection_acceptor_impl.cc \ src/cpp/server/health/default_health_check_service.cc \ src/cpp/server/health/health_check_service.cc \ src/cpp/server/health/health_check_service_server_builder_option.cc \ @@ -6853,6 +6860,7 @@ LIBGRPC++_UNSECURE_SRC = \ src/cpp/server/channel_argument_option.cc \ src/cpp/server/create_default_thread_pool.cc \ src/cpp/server/dynamic_thread_pool.cc \ + src/cpp/server/external_connection_acceptor_impl.cc \ src/cpp/server/health/default_health_check_service.cc \ src/cpp/server/health/health_check_service.cc \ src/cpp/server/health/health_check_service_server_builder_option.cc \ @@ -17756,6 +17764,49 @@ endif endif +PORT_SHARING_END2END_TEST_SRC = \ + test/cpp/end2end/port_sharing_end2end_test.cc \ + +PORT_SHARING_END2END_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(PORT_SHARING_END2END_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/port_sharing_end2end_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/port_sharing_end2end_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/port_sharing_end2end_test: $(PROTOBUF_DEP) $(PORT_SHARING_END2END_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libtest_tcp_server.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(PORT_SHARING_END2END_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libtest_tcp_server.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/port_sharing_end2end_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/cpp/end2end/port_sharing_end2end_test.o: $(LIBDIR)/$(CONFIG)/libtest_tcp_server.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_port_sharing_end2end_test: $(PORT_SHARING_END2END_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(PORT_SHARING_END2END_TEST_OBJS:.o=.dep) +endif +endif + + PROTO_SERVER_REFLECTION_TEST_SRC = \ test/cpp/end2end/proto_server_reflection_test.cc \ diff --git a/build.yaml b/build.yaml index 848bf4ba072..0ca5114cb06 100644 --- a/build.yaml +++ b/build.yaml @@ -1408,6 +1408,7 @@ filegroups: - src/cpp/client/create_channel_internal.h - src/cpp/common/channel_filter.h - src/cpp/server/dynamic_thread_pool.h + - src/cpp/server/external_connection_acceptor_impl.h - src/cpp/server/health/default_health_check_service.h - src/cpp/server/thread_pool_interface.h - src/cpp/thread_manager/thread_manager.h @@ -1432,6 +1433,7 @@ filegroups: - src/cpp/server/channel_argument_option.cc - src/cpp/server/create_default_thread_pool.cc - src/cpp/server/dynamic_thread_pool.cc + - src/cpp/server/external_connection_acceptor_impl.cc - src/cpp/server/health/default_health_check_service.cc - src/cpp/server/health/health_check_service.cc - src/cpp/server/health/health_check_service_server_builder_option.cc @@ -5156,6 +5158,19 @@ targets: - gpr uses: - grpc++_test +- name: port_sharing_end2end_test + gtest: true + build: test + language: c++ + src: + - test/cpp/end2end/port_sharing_end2end_test.cc + deps: + - test_tcp_server + - grpc++_test_util + - grpc_test_util + - grpc++ + - grpc + - gpr - name: proto_server_reflection_test gtest: true build: test diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 3ecdcfe82a4..a015ecc4de9 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -202,6 +202,7 @@ Pod::Spec.new do |s| 'src/cpp/client/create_channel_internal.h', 'src/cpp/common/channel_filter.h', 'src/cpp/server/dynamic_thread_pool.h', + 'src/cpp/server/external_connection_acceptor_impl.h', 'src/cpp/server/health/default_health_check_service.h', 'src/cpp/server/thread_pool_interface.h', 'src/cpp/thread_manager/thread_manager.h', @@ -233,6 +234,7 @@ Pod::Spec.new do |s| 'src/cpp/server/channel_argument_option.cc', 'src/cpp/server/create_default_thread_pool.cc', 'src/cpp/server/dynamic_thread_pool.cc', + 'src/cpp/server/external_connection_acceptor_impl.cc', 'src/cpp/server/health/default_health_check_service.cc', 'src/cpp/server/health/health_check_service.cc', 'src/cpp/server/health/health_check_service_server_builder_option.cc', @@ -566,6 +568,7 @@ Pod::Spec.new do |s| 'src/cpp/client/create_channel_internal.h', 'src/cpp/common/channel_filter.h', 'src/cpp/server/dynamic_thread_pool.h', + 'src/cpp/server/external_connection_acceptor_impl.h', 'src/cpp/server/health/default_health_check_service.h', 'src/cpp/server/thread_pool_interface.h', 'src/cpp/thread_manager/thread_manager.h', diff --git a/grpc.gyp b/grpc.gyp index 5321658508a..1792aaf2b78 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -1434,6 +1434,7 @@ 'src/cpp/server/channel_argument_option.cc', 'src/cpp/server/create_default_thread_pool.cc', 'src/cpp/server/dynamic_thread_pool.cc', + 'src/cpp/server/external_connection_acceptor_impl.cc', 'src/cpp/server/health/default_health_check_service.cc', 'src/cpp/server/health/health_check_service.cc', 'src/cpp/server/health/health_check_service_server_builder_option.cc', @@ -1589,6 +1590,7 @@ 'src/cpp/server/channel_argument_option.cc', 'src/cpp/server/create_default_thread_pool.cc', 'src/cpp/server/dynamic_thread_pool.cc', + 'src/cpp/server/external_connection_acceptor_impl.cc', 'src/cpp/server/health/default_health_check_service.cc', 'src/cpp/server/health/health_check_service.cc', 'src/cpp/server/health/health_check_service_server_builder_option.cc', diff --git a/include/grpcpp/impl/codegen/byte_buffer.h b/include/grpcpp/impl/codegen/byte_buffer.h index 7b82f49a84e..aabaefc4319 100644 --- a/include/grpcpp/impl/codegen/byte_buffer.h +++ b/include/grpcpp/impl/codegen/byte_buffer.h @@ -29,6 +29,10 @@ #include +namespace grpc_impl { +class ExternalConnectionAcceptorImpl; +} // namespace grpc_impl + namespace grpc { class ServerInterface; @@ -185,6 +189,7 @@ class ByteBuffer final { friend class ProtoBufferReader; friend class ProtoBufferWriter; friend class internal::GrpcByteBufferPeer; + friend class ::grpc_impl::ExternalConnectionAcceptorImpl; grpc_byte_buffer* buffer_; diff --git a/include/grpcpp/server.h b/include/grpcpp/server.h index 8aff0663fe2..58b8c0d5042 100644 --- a/include/grpcpp/server.h +++ b/include/grpcpp/server.h @@ -42,9 +42,9 @@ struct grpc_server; namespace grpc_impl { - +class ExternalConnectionAcceptorImpl; class ServerInitializer; -} +} // namespace grpc_impl namespace grpc { class AsyncGenericService; @@ -174,15 +174,18 @@ class Server : public ServerInterface, private GrpcLibraryCodegen { /// /// \param sync_cq_timeout_msec The timeout to use when calling AsyncNext() on /// server completion queues passed via sync_server_cqs param. - Server(int max_message_size, ChannelArguments* args, - std::shared_ptr>> - sync_server_cqs, - int min_pollers, int max_pollers, int sync_cq_timeout_msec, - grpc_resource_quota* server_rq = nullptr, - std::vector< - std::unique_ptr> - interceptor_creators = std::vector>()); + Server( + int max_message_size, ChannelArguments* args, + std::shared_ptr>> + sync_server_cqs, + int min_pollers, int max_pollers, int sync_cq_timeout_msec, + std::vector> + acceptors, + grpc_resource_quota* server_rq = nullptr, + std::vector< + std::unique_ptr> + interceptor_creators = std::vector>()); /// Start the server. /// @@ -262,6 +265,9 @@ class Server : public ServerInterface, private GrpcLibraryCodegen { grpc_impl::ServerInitializer* initializer(); + std::vector> + acceptors_; + // A vector of interceptor factory objects. // This should be destroyed after health_check_service_ and this requirement // is satisfied by declaring interceptor_creators_ before diff --git a/include/grpcpp/server_builder_impl.h b/include/grpcpp/server_builder_impl.h index 25b8091a7df..c532d1093d2 100644 --- a/include/grpcpp/server_builder_impl.h +++ b/include/grpcpp/server_builder_impl.h @@ -36,10 +36,11 @@ struct grpc_resource_quota; namespace grpc_impl { - +class ExternalConnectionAcceptorImpl; class ResourceQuota; class ServerCredentials; } // namespace grpc_impl + namespace grpc { class AsyncGenericService; @@ -47,7 +48,6 @@ class CompletionQueue; class Server; class ServerCompletionQueue; class Service; - namespace testing { class ServerBuilderPluginTest; } // namespace testing @@ -55,7 +55,21 @@ class ServerBuilderPluginTest; namespace experimental { class CallbackGenericService; } + +class ExternalConnectionAcceptor { + public: + struct NewConnectionParameters { + int fd = -1; + ByteBuffer read_buffer; // data intended for the grpc server + }; + virtual ~ExternalConnectionAcceptor() {} + // If called before grpc::Server is started, the new connection will be + // closed. + virtual void HandleNewConnection(NewConnectionParameters* p) = 0; +}; + } // namespace grpc + namespace grpc_impl { /// A builder class for the creation and startup of \a grpc::Server instances. @@ -257,6 +271,16 @@ class ServerBuilder { /// at any time. experimental_type experimental() { return experimental_type(this); } + enum ExternalConnectionType { + CONNECTION_FROM_FD = 0 // in the form of a file descriptor + }; + // EXPERIMENTAL API: + // Create an acceptor to take in external connections and pass them to the + // gRPC server. + std::unique_ptr + AddExternalConnectionAcceptor(ExternalConnectionType type, + std::shared_ptr creds); + protected: /// Experimental, to be deprecated struct Port { @@ -347,6 +371,7 @@ class ServerBuilder { std::vector< std::unique_ptr> interceptor_creators_; + std::vector> acceptors_; }; } // namespace grpc_impl diff --git a/include/grpcpp/server_impl.h b/include/grpcpp/server_impl.h index 14b16a06f4e..458cf4e1c9f 100644 --- a/include/grpcpp/server_impl.h +++ b/include/grpcpp/server_impl.h @@ -48,7 +48,7 @@ class ServerContext; } // namespace grpc namespace grpc_impl { - +class ExternalConnectionAcceptorImpl; class HealthCheckServiceInterface; class ServerInitializer; @@ -183,6 +183,8 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { std::shared_ptr>> sync_server_cqs, int min_pollers, int max_pollers, int sync_cq_timeout_msec, + std::vector> + acceptors, grpc_resource_quota* server_rq = nullptr, std::vector> @@ -268,6 +270,9 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { grpc_impl::ServerInitializer* initializer(); + std::vector> + acceptors_; + // A vector of interceptor factory objects. // This should be destroyed after health_check_service_ and this requirement // is satisfied by declaring interceptor_creators_ before diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc index 040ea2044b1..5abedc23473 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -20,12 +20,12 @@ #include "src/core/ext/transport/chttp2/server/chttp2_server.h" -#include - #include #include #include +#include +#include #include #include #include @@ -289,6 +289,55 @@ static void server_destroy_listener(grpc_server* server, void* arg, grpc_tcp_server_unref(tcp_server); } +static grpc_error* chttp2_server_add_acceptor(grpc_server* server, + const char* name, + grpc_channel_args* args) { + grpc_tcp_server* tcp_server = nullptr; + grpc_error* err = GRPC_ERROR_NONE; + server_state* state = nullptr; + const grpc_arg* arg = nullptr; + grpc_core::TcpServerFdHandler** arg_val = nullptr; + + state = static_cast(gpr_zalloc(sizeof(*state))); + GRPC_CLOSURE_INIT(&state->tcp_server_shutdown_complete, + tcp_server_shutdown_complete, state, + grpc_schedule_on_exec_ctx); + err = grpc_tcp_server_create(&state->tcp_server_shutdown_complete, args, + &tcp_server); + if (err != GRPC_ERROR_NONE) { + goto error; + } + + state->server = server; + state->tcp_server = tcp_server; + state->args = args; + state->shutdown = true; + gpr_mu_init(&state->mu); + + // TODO(yangg) channelz + + arg = grpc_channel_args_find(args, name); + GPR_ASSERT(arg->type == GRPC_ARG_POINTER); + arg_val = static_cast(arg->value.pointer.p); + *arg_val = grpc_tcp_server_create_fd_handler(tcp_server); + + grpc_server_add_listener(server, state, server_start_listener, + server_destroy_listener, /* socket_uuid */ 0); + + return err; + +/* Error path: cleanup and return */ +error: + GPR_ASSERT(err != GRPC_ERROR_NONE); + if (tcp_server) { + grpc_tcp_server_unref(tcp_server); + } else { + grpc_channel_args_destroy(args); + gpr_free(state); + } + return err; +} + grpc_error* grpc_chttp2_server_add_port(grpc_server* server, const char* addr, grpc_channel_args* args, int* port_num) { @@ -306,6 +355,10 @@ grpc_error* grpc_chttp2_server_add_port(grpc_server* server, const char* addr, *port_num = -1; + if (strncmp(addr, "external:", 9) == 0) { + return chttp2_server_add_acceptor(server, addr, args); + } + /* resolve address */ err = grpc_blocking_resolve_address(addr, "https", &resolved); if (err != GRPC_ERROR_NONE) { diff --git a/src/core/lib/channel/handshaker.cc b/src/core/lib/channel/handshaker.cc index 6bb05cee24e..4466dd69678 100644 --- a/src/core/lib/channel/handshaker.cc +++ b/src/core/lib/channel/handshaker.cc @@ -20,6 +20,7 @@ #include +#include #include #include #include @@ -226,6 +227,11 @@ void HandshakeManager::DoHandshake(grpc_endpoint* endpoint, args_.read_buffer = static_cast(gpr_malloc(sizeof(*args_.read_buffer))); grpc_slice_buffer_init(args_.read_buffer); + if (acceptor != nullptr && acceptor->external_connection && + acceptor->pending_data != nullptr) { + grpc_slice_buffer_swap(args_.read_buffer, + &(acceptor->pending_data->data.raw.slice_buffer)); + } // Initialize state needed for calling handshakers. acceptor_ = acceptor; GRPC_CLOSURE_INIT(&call_next_handshaker_, diff --git a/src/core/lib/iomgr/tcp_server.cc b/src/core/lib/iomgr/tcp_server.cc index ea745f266b9..f2e4b1b51ea 100644 --- a/src/core/lib/iomgr/tcp_server.cc +++ b/src/core/lib/iomgr/tcp_server.cc @@ -41,6 +41,11 @@ grpc_error* grpc_tcp_server_add_port(grpc_tcp_server* s, return grpc_tcp_server_impl->add_port(s, addr, out_port); } +grpc_core::TcpServerFdHandler* grpc_tcp_server_create_fd_handler( + grpc_tcp_server* s) { + return grpc_tcp_server_impl->create_fd_handler(s); +} + unsigned grpc_tcp_server_port_fd_count(grpc_tcp_server* s, unsigned port_index) { return grpc_tcp_server_impl->port_fd_count(s, port_index); diff --git a/src/core/lib/iomgr/tcp_server.h b/src/core/lib/iomgr/tcp_server.h index 8fcbb2f6807..774f06ee17a 100644 --- a/src/core/lib/iomgr/tcp_server.h +++ b/src/core/lib/iomgr/tcp_server.h @@ -22,7 +22,9 @@ #include #include +#include +#include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/resolve_address.h" @@ -37,6 +39,9 @@ typedef struct grpc_tcp_server_acceptor { /* Indices that may be passed to grpc_tcp_server_port_fd(). */ unsigned port_index; unsigned fd_index; + /* Data when the connection is passed to tcp_server from external. */ + bool external_connection; + grpc_byte_buffer* pending_data; } grpc_tcp_server_acceptor; /* Called for newly connected TCP connections. @@ -44,6 +49,17 @@ typedef struct grpc_tcp_server_acceptor { typedef void (*grpc_tcp_server_cb)(void* arg, grpc_endpoint* ep, grpc_pollset* accepting_pollset, grpc_tcp_server_acceptor* acceptor); +namespace grpc_core { +// An interface for a handler to take a externally connected fd as a internal +// connection. +class TcpServerFdHandler { + public: + virtual ~TcpServerFdHandler() = default; + virtual void Handle(int fd, grpc_byte_buffer* pending_read) GRPC_ABSTRACT; + + GRPC_ABSTRACT_BASE_CLASS; +}; +} // namespace grpc_core typedef struct grpc_tcp_server_vtable { grpc_error* (*create)(grpc_closure* shutdown_complete, @@ -54,6 +70,7 @@ typedef struct grpc_tcp_server_vtable { void* cb_arg); grpc_error* (*add_port)(grpc_tcp_server* s, const grpc_resolved_address* addr, int* out_port); + grpc_core::TcpServerFdHandler* (*create_fd_handler)(grpc_tcp_server* s); unsigned (*port_fd_count)(grpc_tcp_server* s, unsigned port_index); int (*port_fd)(grpc_tcp_server* s, unsigned port_index, unsigned fd_index); grpc_tcp_server* (*ref)(grpc_tcp_server* s); @@ -88,6 +105,11 @@ grpc_error* grpc_tcp_server_add_port(grpc_tcp_server* s, const grpc_resolved_address* addr, int* out_port); +/* Create and return a TcpServerFdHandler so that it can be used by upper layer + to hand over an externally connected fd to the grpc server. */ +grpc_core::TcpServerFdHandler* grpc_tcp_server_create_fd_handler( + grpc_tcp_server* s); + /* Number of fds at the given port_index, or 0 if port_index is out of bounds. */ unsigned grpc_tcp_server_port_fd_count(grpc_tcp_server* s, unsigned port_index); diff --git a/src/core/lib/iomgr/tcp_server_custom.cc b/src/core/lib/iomgr/tcp_server_custom.cc index 019b354473b..1a1a1f28cfa 100644 --- a/src/core/lib/iomgr/tcp_server_custom.cc +++ b/src/core/lib/iomgr/tcp_server_custom.cc @@ -233,6 +233,7 @@ static void finish_accept(grpc_tcp_listener* sp, grpc_custom_socket* socket) { acceptor->from_server = sp->server; acceptor->port_index = sp->port_index; acceptor->fd_index = 0; + acceptor->external_connection = false; sp->server->on_accept_cb(sp->server->on_accept_cb_arg, ep, nullptr, acceptor); gpr_free(peer_name_string); } @@ -456,16 +457,17 @@ static void tcp_server_shutdown_listeners(grpc_tcp_server* s) { } } +static grpc_core::TcpServerFdHandler* tcp_server_create_fd_handler( + grpc_tcp_server* s) { + return nullptr; +} + grpc_tcp_server_vtable custom_tcp_server_vtable = { - tcp_server_create, - tcp_server_start, - tcp_server_add_port, - tcp_server_port_fd_count, - tcp_server_port_fd, - tcp_server_ref, - tcp_server_shutdown_starting_add, - tcp_server_unref, - tcp_server_shutdown_listeners}; + tcp_server_create, tcp_server_start, + tcp_server_add_port, tcp_server_create_fd_handler, + tcp_server_port_fd_count, tcp_server_port_fd, + tcp_server_ref, tcp_server_shutdown_starting_add, + tcp_server_unref, tcp_server_shutdown_listeners}; #ifdef GRPC_UV_TEST grpc_tcp_server_vtable* default_tcp_server_vtable = &custom_tcp_server_vtable; diff --git a/src/core/lib/iomgr/tcp_server_posix.cc b/src/core/lib/iomgr/tcp_server_posix.cc index baef3886530..ca492d724f9 100644 --- a/src/core/lib/iomgr/tcp_server_posix.cc +++ b/src/core/lib/iomgr/tcp_server_posix.cc @@ -27,8 +27,6 @@ #ifdef GRPC_POSIX_SOCKET_TCP_SERVER -#include "src/core/lib/iomgr/tcp_server.h" - #include #include #include @@ -47,11 +45,14 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/iomgr/socket_utils_posix.h" #include "src/core/lib/iomgr/tcp_posix.h" +#include "src/core/lib/iomgr/tcp_server.h" #include "src/core/lib/iomgr/tcp_server_utils_posix.h" #include "src/core/lib/iomgr/unix_sockets_posix.h" @@ -96,6 +97,7 @@ static grpc_error* tcp_server_create(grpc_closure* shutdown_complete, s->tail = nullptr; s->nports = 0; s->channel_args = grpc_channel_args_copy(args); + s->fd_handler = nullptr; gpr_atm_no_barrier_store(&s->next_pollset_to_assign, 0); *server = s; return GRPC_ERROR_NONE; @@ -117,6 +119,7 @@ static void finish_shutdown(grpc_tcp_server* s) { gpr_free(sp); } grpc_channel_args_destroy(s->channel_args); + grpc_core::Delete(s->fd_handler); gpr_free(s); } @@ -254,6 +257,7 @@ static void on_read(void* arg, grpc_error* err) { acceptor->from_server = sp->server; acceptor->port_index = sp->port_index; acceptor->fd_index = sp->fd_index; + acceptor->external_connection = false; sp->server->on_accept_cb( sp->server->on_accept_cb_arg, @@ -562,14 +566,78 @@ static void tcp_server_shutdown_listeners(grpc_tcp_server* s) { gpr_mu_unlock(&s->mu); } +namespace { +class ExternalConnectionHandler : public grpc_core::TcpServerFdHandler { + public: + explicit ExternalConnectionHandler(grpc_tcp_server* s) : s_(s) {} + + // TODO(yangg) resolve duplicate code with on_read + void Handle(int fd, grpc_byte_buffer* buf) override { + grpc_pollset* read_notifier_pollset; + grpc_resolved_address addr; + char* addr_str; + char* name; + memset(&addr, 0, sizeof(addr)); + addr.len = static_cast(sizeof(struct sockaddr_storage)); + grpc_core::ExecCtx exec_ctx; + + if (getpeername(fd, reinterpret_cast(addr.addr), + &(addr.len)) < 0) { + gpr_log(GPR_ERROR, "Failed getpeername: %s", strerror(errno)); + close(fd); + return; + } + + grpc_set_socket_no_sigpipe_if_possible(fd); + + addr_str = grpc_sockaddr_to_uri(&addr); + gpr_asprintf(&name, "tcp-server-connection:%s", addr_str); + + if (grpc_tcp_trace.enabled()) { + gpr_log(GPR_INFO, "SERVER_CONNECT: incoming external connection: %s", + addr_str); + } + + grpc_fd* fdobj = grpc_fd_create(fd, name, true); + + read_notifier_pollset = + s_->pollsets[static_cast(gpr_atm_no_barrier_fetch_add( + &s_->next_pollset_to_assign, 1)) % + s_->pollset_count]; + + grpc_pollset_add_fd(read_notifier_pollset, fdobj); + + grpc_tcp_server_acceptor* acceptor = + static_cast(gpr_malloc(sizeof(*acceptor))); + acceptor->from_server = s_; + acceptor->port_index = -1; + acceptor->fd_index = -1; + acceptor->external_connection = true; + acceptor->pending_data = buf; + + s_->on_accept_cb(s_->on_accept_cb_arg, + grpc_tcp_create(fdobj, s_->channel_args, addr_str), + read_notifier_pollset, acceptor); + gpr_free(name); + gpr_free(addr_str); + } + + private: + grpc_tcp_server* s_; +}; +} // namespace + +static grpc_core::TcpServerFdHandler* tcp_server_create_fd_handler( + grpc_tcp_server* s) { + s->fd_handler = grpc_core::New(s); + return s->fd_handler; +} + grpc_tcp_server_vtable grpc_posix_tcp_server_vtable = { - tcp_server_create, - tcp_server_start, - tcp_server_add_port, - tcp_server_port_fd_count, - tcp_server_port_fd, - tcp_server_ref, - tcp_server_shutdown_starting_add, - tcp_server_unref, - tcp_server_shutdown_listeners}; + tcp_server_create, tcp_server_start, + tcp_server_add_port, tcp_server_create_fd_handler, + tcp_server_port_fd_count, tcp_server_port_fd, + tcp_server_ref, tcp_server_shutdown_starting_add, + tcp_server_unref, tcp_server_shutdown_listeners}; + #endif /* GRPC_POSIX_SOCKET_TCP_SERVER */ diff --git a/src/core/lib/iomgr/tcp_server_utils_posix.h b/src/core/lib/iomgr/tcp_server_utils_posix.h index dd199097b2c..390d6d266a2 100644 --- a/src/core/lib/iomgr/tcp_server_utils_posix.h +++ b/src/core/lib/iomgr/tcp_server_utils_posix.h @@ -92,6 +92,9 @@ struct grpc_tcp_server { /* channel args for this server */ grpc_channel_args* channel_args; + + /* a handler for external connections, owned */ + grpc_core::TcpServerFdHandler* fd_handler; }; /* If successful, add a listener to \a s for \a addr, set \a dsmode for the diff --git a/src/core/lib/iomgr/tcp_server_windows.cc b/src/core/lib/iomgr/tcp_server_windows.cc index 7ac423440e2..abfa3be5708 100644 --- a/src/core/lib/iomgr/tcp_server_windows.cc +++ b/src/core/lib/iomgr/tcp_server_windows.cc @@ -372,6 +372,7 @@ static void on_accept(void* arg, grpc_error* error) { acceptor->from_server = sp->server; acceptor->port_index = sp->port_index; acceptor->fd_index = 0; + acceptor->external_connection = false; sp->server->on_accept_cb(sp->server->on_accept_cb_arg, ep, NULL, acceptor); } /* As we were notified from the IOCP of one and exactly one accept, @@ -545,16 +546,17 @@ static int tcp_server_port_fd(grpc_tcp_server* s, unsigned port_index, return -1; } +static grpc_core::TcpServerFdHandler* tcp_server_create_fd_handler( + grpc_tcp_server* s) { + return nullptr; +} + static void tcp_server_shutdown_listeners(grpc_tcp_server* s) {} grpc_tcp_server_vtable grpc_windows_tcp_server_vtable = { - tcp_server_create, - tcp_server_start, - tcp_server_add_port, - tcp_server_port_fd_count, - tcp_server_port_fd, - tcp_server_ref, - tcp_server_shutdown_starting_add, - tcp_server_unref, - tcp_server_shutdown_listeners}; + tcp_server_create, tcp_server_start, + tcp_server_add_port, tcp_server_create_fd_handler, + tcp_server_port_fd_count, tcp_server_port_fd, + tcp_server_ref, tcp_server_shutdown_starting_add, + tcp_server_unref, tcp_server_shutdown_listeners}; #endif /* GRPC_WINSOCK_SOCKET */ diff --git a/src/cpp/server/external_connection_acceptor_impl.cc b/src/cpp/server/external_connection_acceptor_impl.cc new file mode 100644 index 00000000000..24f58673a10 --- /dev/null +++ b/src/cpp/server/external_connection_acceptor_impl.cc @@ -0,0 +1,88 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "src/cpp/server/external_connection_acceptor_impl.h" + +#include + +#include +#include + +namespace grpc_impl { +namespace { +class InternalAcceptor : public grpc::ExternalConnectionAcceptor { + public: + explicit InternalAcceptor( + std::shared_ptr impl) + : impl_(std::move(impl)) {} + void HandleNewConnection(NewConnectionParameters* p) override { + impl_->HandleNewConnection(p); + } + + private: + std::shared_ptr impl_; +}; +} // namespace + +ExternalConnectionAcceptorImpl::ExternalConnectionAcceptorImpl( + const grpc::string& name, ServerBuilder::ExternalConnectionType type, + std::shared_ptr creds) + : name_(name), creds_(std::move(creds)) { + GPR_ASSERT(type == ServerBuilder::ExternalConnectionType::CONNECTION_FROM_FD); +} + +std::unique_ptr +ExternalConnectionAcceptorImpl::GetAcceptor() { + std::lock_guard lock(mu_); + GPR_ASSERT(!has_acceptor_); + has_acceptor_ = true; + return std::unique_ptr( + new InternalAcceptor(shared_from_this())); +} + +void ExternalConnectionAcceptorImpl::HandleNewConnection( + grpc::ExternalConnectionAcceptor::NewConnectionParameters* p) { + std::lock_guard lock(mu_); + if (shutdown_ || !started_) { + // TODO(yangg) clean up. + return; + } + if (handler_) { + handler_->Handle(p->fd, p->read_buffer.c_buffer()); + } +} + +void ExternalConnectionAcceptorImpl::Shutdown() { + std::lock_guard lock(mu_); + shutdown_ = true; +} + +void ExternalConnectionAcceptorImpl::Start() { + std::lock_guard lock(mu_); + GPR_ASSERT(!started_); + GPR_ASSERT(has_acceptor_); + GPR_ASSERT(!shutdown_); + started_ = true; +} + +void ExternalConnectionAcceptorImpl::SetToChannelArgs( + ::grpc::ChannelArguments* args) { + args->SetPointer(name_.c_str(), &handler_); +} + +} // namespace grpc_impl diff --git a/src/cpp/server/external_connection_acceptor_impl.h b/src/cpp/server/external_connection_acceptor_impl.h new file mode 100644 index 00000000000..3e146bebb37 --- /dev/null +++ b/src/cpp/server/external_connection_acceptor_impl.h @@ -0,0 +1,71 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef SRC_CPP_SERVER_EXTERNAL_CONNECTION_ACCEPTOR_IMPL_H_ +#define SRC_CPP_SERVER_EXTERNAL_CONNECTION_ACCEPTOR_IMPL_H_ + +#include +#include + +#include +#include +#include +#include +#include + +#include "src/core/lib/iomgr/tcp_server.h" + +namespace grpc_impl { + +typedef void (*RawConnectionHandler)(int fd, grpc_byte_buffer* buffer); + +class ExternalConnectionAcceptorImpl + : public std::enable_shared_from_this { + public: + ExternalConnectionAcceptorImpl(const grpc::string& name, + ServerBuilder::ExternalConnectionType type, + std::shared_ptr creds); + // Should only be called once. + std::unique_ptr GetAcceptor(); + + void HandleNewConnection( + grpc::ExternalConnectionAcceptor::NewConnectionParameters* p); + + void Shutdown(); + + void Start(); + + const char* name() { return name_.c_str(); } + + ServerCredentials* GetCredentials() { return creds_.get(); } + + void SetToChannelArgs(::grpc::ChannelArguments* args); + + private: + const grpc::string name_; + std::shared_ptr creds_; + grpc_core::TcpServerFdHandler* handler_ = nullptr; // not owned + std::mutex mu_; + bool has_acceptor_ = false; + bool started_ = false; + bool shutdown_ = false; +}; + +} // namespace grpc_impl + +#endif // SRC_CPP_SERVER_EXTERNAL_CONNECTION_ACCEPTOR_IMPL_H_ diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index af76ffbe9b5..fd93535f8b8 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -26,7 +26,9 @@ #include +#include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" +#include "src/cpp/server/external_connection_acceptor_impl.h" #include "src/cpp/server/thread_pool_interface.h" namespace grpc_impl { @@ -307,8 +309,8 @@ std::unique_ptr ServerBuilder::BuildAndStart() { std::unique_ptr server(new grpc::Server( max_receive_message_size_, &args, sync_server_cqs, sync_server_settings_.min_pollers, sync_server_settings_.max_pollers, - sync_server_settings_.cq_timeout_msec, resource_quota_, - std::move(interceptor_creators_))); + sync_server_settings_.cq_timeout_msec, std::move(acceptors_), + resource_quota_, std::move(interceptor_creators_))); grpc_impl::ServerInitializer* initializer = server->initializer(); @@ -409,4 +411,15 @@ ServerBuilder& ServerBuilder::EnableWorkaround(grpc_workaround_list id) { } } +std::unique_ptr +ServerBuilder::AddExternalConnectionAcceptor( + ExternalConnectionType type, std::shared_ptr creds) { + grpc::string name_prefix("external:"); + char count_str[GPR_LTOA_MIN_BUFSIZE]; + gpr_ltoa(static_cast(acceptors_.size()), count_str); + acceptors_.emplace_back(std::make_shared( + name_prefix.append(count_str), type, creds)); + return acceptors_.back()->GetAcceptor(); +} + } // namespace grpc_impl diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc index 63608cbcde6..5d9abd8e89b 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,7 @@ #include "src/core/lib/surface/call.h" #include "src/core/lib/surface/completion_queue.h" #include "src/cpp/client/create_channel_internal.h" +#include "src/cpp/server/external_connection_acceptor_impl.h" #include "src/cpp/server/health/default_health_check_service.h" #include "src/cpp/thread_manager/thread_manager.h" @@ -759,11 +761,14 @@ Server::Server( std::shared_ptr>> sync_server_cqs, int min_pollers, int max_pollers, int sync_cq_timeout_msec, + std::vector> + acceptors, grpc_resource_quota* server_rq, std::vector< std::unique_ptr> interceptor_creators) - : interceptor_creators_(std::move(interceptor_creators)), + : acceptors_(std::move(acceptors)), + interceptor_creators_(std::move(interceptor_creators)), max_receive_message_size_(max_receive_message_size), sync_server_cqs_(std::move(sync_server_cqs)), started_(false), @@ -797,6 +802,10 @@ Server::Server( } } + for (auto& acceptor : acceptors_) { + acceptor->SetToChannelArgs(args); + } + grpc_channel_args channel_args; args->SetChannelArgs(&channel_args); @@ -1008,6 +1017,10 @@ void Server::Start(ServerCompletionQueue** cqs, size_t num_cqs) { RegisterService(nullptr, default_health_check_service_impl); } + for (auto& acceptor : acceptors_) { + acceptor->GetCredentials()->AddPortToServer(acceptor->name(), server_); + } + // If this server uses callback methods, then create a callback generic // service to handle any unimplemented methods using the default reactor // creator @@ -1052,6 +1065,10 @@ void Server::Start(ServerCompletionQueue** cqs, size_t num_cqs) { if (default_health_check_service_impl != nullptr) { default_health_check_service_impl->StartServingThread(); } + + for (auto& acceptor : acceptors_) { + acceptor->Start(); + } } void Server::ShutdownInternal(gpr_timespec deadline) { @@ -1062,6 +1079,10 @@ void Server::ShutdownInternal(gpr_timespec deadline) { shutdown_ = true; + for (auto& acceptor : acceptors_) { + acceptor->Shutdown(); + } + /// The completion queue to use for server shutdown completion notification CompletionQueue shutdown_cq; ShutdownTag shutdown_tag; // Dummy shutdown tag diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD index 56fc5e06008..b6a8b69e3db 100644 --- a/test/cpp/end2end/BUILD +++ b/test/cpp/end2end/BUILD @@ -697,3 +697,21 @@ grpc_cc_test( ], ) +grpc_cc_test( + name = "port_sharing_end2end_test", + srcs = ["port_sharing_end2end_test.cc"], + external_deps = [ + "gtest", + ], + deps = [ + ":test_service_impl", + "//:gpr", + "//:grpc", + "//:grpc++", + "//src/proto/grpc/testing:echo_messages_proto", + "//src/proto/grpc/testing:echo_proto", + "//test/core/util:grpc_test_util", + "//test/cpp/util:test_util", + ], +) + diff --git a/test/cpp/end2end/port_sharing_end2end_test.cc b/test/cpp/end2end/port_sharing_end2end_test.cc new file mode 100644 index 00000000000..438d4169bea --- /dev/null +++ b/test/cpp/end2end/port_sharing_end2end_test.cc @@ -0,0 +1,362 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/pollset.h" +#include "src/core/lib/iomgr/port.h" +#include "src/core/lib/iomgr/tcp_server.h" +#include "src/core/lib/security/credentials/credentials.h" +#include "src/proto/grpc/testing/echo.grpc.pb.h" +#include "test/core/util/port.h" +#include "test/core/util/test_config.h" +#include "test/core/util/test_tcp_server.h" +#include "test/cpp/end2end/test_service_impl.h" +#include "test/cpp/util/test_credentials_provider.h" + +#ifdef GRPC_POSIX_SOCKET_TCP_SERVER + +#include "src/core/lib/iomgr/tcp_posix.h" + +namespace grpc { +namespace testing { +namespace { + +class TestScenario { + public: + TestScenario(bool server_port, bool pending_data, + const grpc::string& creds_type) + : server_has_port(server_port), + queue_pending_data(pending_data), + credentials_type(creds_type) {} + void Log() const; + // server has its own port or not + bool server_has_port; + // whether tcp server should read some data before handoff + bool queue_pending_data; + const grpc::string credentials_type; +}; + +static std::ostream& operator<<(std::ostream& out, + const TestScenario& scenario) { + return out << "TestScenario{server_has_port=" + << (scenario.server_has_port ? "true" : "false") + << ", queue_pending_data=" + << (scenario.queue_pending_data ? "true" : "false") + << ", credentials='" << scenario.credentials_type << "'}"; +} + +void TestScenario::Log() const { + std::ostringstream out; + out << *this; + gpr_log(GPR_ERROR, "%s", out.str().c_str()); +} + +// Set up a test tcp server which is in charge of accepting connections and +// handing off the connections as fds. +class TestTcpServer { + public: + TestTcpServer() + : shutdown_(false), + queue_data_(false), + port_(grpc_pick_unused_port_or_die()) { + std::ostringstream server_address; + server_address << "localhost:" << port_; + address_ = server_address.str(); + test_tcp_server_init(&tcp_server_, &TestTcpServer::OnConnect, this); + GRPC_CLOSURE_INIT(&on_fd_released_, &TestTcpServer::OnFdReleased, this, + grpc_schedule_on_exec_ctx); + } + + ~TestTcpServer() { + running_thread_.join(); + test_tcp_server_destroy(&tcp_server_); + grpc_recycle_unused_port(port_); + } + + // Read some data before handing off the connection. + void SetQueueData() { queue_data_ = true; } + + void Start() { + test_tcp_server_start(&tcp_server_, port_); + gpr_log(GPR_INFO, "Test TCP server started at %s", address_.c_str()); + } + + const grpc::string& address() { return address_; } + + void SetAcceptor(std::unique_ptr acceptor) { + connection_acceptor_ = std::move(acceptor); + } + + void Run() { + running_thread_ = std::thread([this]() { + while (true) { + { + std::lock_guard lock(mu_); + if (shutdown_) { + return; + } + } + test_tcp_server_poll(&tcp_server_, 1); + } + }); + } + + void Shutdown() { + std::lock_guard lock(mu_); + shutdown_ = true; + } + + static void OnConnect(void* arg, grpc_endpoint* tcp, + grpc_pollset* accepting_pollset, + grpc_tcp_server_acceptor* acceptor) { + auto* self = static_cast(arg); + self->OnConnect(tcp, accepting_pollset, acceptor); + } + + static void OnFdReleased(void* arg, grpc_error* err) { + auto* self = static_cast(arg); + self->OnFdReleased(err); + } + + private: + void OnConnect(grpc_endpoint* tcp, grpc_pollset* accepting_pollset, + grpc_tcp_server_acceptor* acceptor) { + char* peer = grpc_endpoint_get_peer(tcp); + gpr_log(GPR_INFO, "Got incoming connection! from %s", peer); + gpr_free(peer); + EXPECT_FALSE(acceptor->external_connection); + gpr_free(acceptor); + grpc_tcp_destroy_and_release_fd(tcp, &fd_, &on_fd_released_); + } + + void OnFdReleased(grpc_error* err) { + EXPECT_EQ(GRPC_ERROR_NONE, err); + ExternalConnectionAcceptor::NewConnectionParameters p; + p.fd = fd_; + if (queue_data_) { + char buf[1024]; + ssize_t read_bytes = 0; + while (read_bytes <= 0) { + read_bytes = read(fd_, buf, 1024); + } + Slice data(buf, read_bytes); + p.read_buffer = ByteBuffer(&data, 1); + } + gpr_log(GPR_INFO, "Handing off fd %d with data size %d", fd_, + static_cast(p.read_buffer.Length())); + connection_acceptor_->HandleNewConnection(&p); + } + + std::mutex mu_; + bool shutdown_; + + int fd_; + bool queue_data_; + + grpc_closure on_fd_released_; + std::thread running_thread_; + int port_; + grpc::string address_; + std::unique_ptr connection_acceptor_; + test_tcp_server tcp_server_; +}; + +class PortSharingEnd2endTest : public ::testing::TestWithParam { + protected: + PortSharingEnd2endTest() : is_server_started_(false), first_picked_port_(0) { + GetParam().Log(); + } + + void SetUp() override { + if (GetParam().queue_pending_data) { + tcp_server1_.SetQueueData(); + tcp_server2_.SetQueueData(); + } + tcp_server1_.Start(); + tcp_server2_.Start(); + ServerBuilder builder; + if (GetParam().server_has_port) { + int port = grpc_pick_unused_port_or_die(); + first_picked_port_ = port; + server_address_ << "localhost:" << port; + auto creds = GetCredentialsProvider()->GetServerCredentials( + GetParam().credentials_type); + builder.AddListeningPort(server_address_.str(), creds); + gpr_log(GPR_INFO, "gRPC server listening on %s", + server_address_.str().c_str()); + } + auto server_creds = GetCredentialsProvider()->GetServerCredentials( + GetParam().credentials_type); + auto acceptor1 = builder.AddExternalConnectionAcceptor( + ServerBuilder::ExternalConnectionType::CONNECTION_FROM_FD, + server_creds); + tcp_server1_.SetAcceptor(std::move(acceptor1)); + auto acceptor2 = builder.AddExternalConnectionAcceptor( + ServerBuilder::ExternalConnectionType::CONNECTION_FROM_FD, + server_creds); + tcp_server2_.SetAcceptor(std::move(acceptor2)); + builder.RegisterService(&service_); + server_ = builder.BuildAndStart(); + is_server_started_ = true; + + tcp_server1_.Run(); + tcp_server2_.Run(); + } + + void TearDown() override { + tcp_server1_.Shutdown(); + tcp_server2_.Shutdown(); + if (is_server_started_) { + server_->Shutdown(); + } + if (first_picked_port_ > 0) { + grpc_recycle_unused_port(first_picked_port_); + } + } + + void ResetStubs() { + EXPECT_TRUE(is_server_started_); + ChannelArguments args; + args.SetInt(GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL, 1); + auto channel_creds = GetCredentialsProvider()->GetChannelCredentials( + GetParam().credentials_type, &args); + channel_handoff1_ = + CreateCustomChannel(tcp_server1_.address(), channel_creds, args); + stub_handoff1_ = EchoTestService::NewStub(channel_handoff1_); + channel_handoff2_ = + CreateCustomChannel(tcp_server2_.address(), channel_creds, args); + stub_handoff2_ = EchoTestService::NewStub(channel_handoff2_); + if (GetParam().server_has_port) { + ChannelArguments direct_args; + direct_args.SetInt(GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL, 1); + auto direct_creds = GetCredentialsProvider()->GetChannelCredentials( + GetParam().credentials_type, &direct_args); + channel_direct_ = + CreateCustomChannel(server_address_.str(), direct_creds, direct_args); + stub_direct_ = EchoTestService::NewStub(channel_direct_); + } + } + + bool is_server_started_; + // channel/stub to the test tcp server, the connection will be handed to the + // grpc server. + std::shared_ptr channel_handoff1_; + std::unique_ptr stub_handoff1_; + std::shared_ptr channel_handoff2_; + std::unique_ptr stub_handoff2_; + // channel/stub to talk to the grpc server directly, if applicable. + std::shared_ptr channel_direct_; + std::unique_ptr stub_direct_; + std::unique_ptr server_; + std::ostringstream server_address_; + TestServiceImpl service_; + TestTcpServer tcp_server1_; + TestTcpServer tcp_server2_; + int first_picked_port_; +}; + +static void SendRpc(EchoTestService::Stub* stub, int num_rpcs) { + EchoRequest request; + EchoResponse response; + request.set_message("Hello hello hello hello"); + + for (int i = 0; i < num_rpcs; ++i) { + ClientContext context; + Status s = stub->Echo(&context, request, &response); + EXPECT_EQ(response.message(), request.message()); + EXPECT_TRUE(s.ok()); + } +} + +std::vector CreateTestScenarios() { + std::vector scenarios; + std::vector credentials_types; + credentials_types = GetCredentialsProvider()->GetSecureCredentialsTypeList(); + // Only allow insecure credentials type when it is registered with the + // provider. User may create providers that do not have insecure. + if (GetCredentialsProvider()->GetChannelCredentials(kInsecureCredentialsType, + nullptr) != nullptr) { + credentials_types.push_back(kInsecureCredentialsType); + } + + GPR_ASSERT(!credentials_types.empty()); + for (const auto& cred : credentials_types) { + for (auto server_has_port : {true, false}) { + for (auto queue_pending_data : {true, false}) { + scenarios.emplace_back(server_has_port, queue_pending_data, cred); + } + } + } + return scenarios; +} + +TEST_P(PortSharingEnd2endTest, HandoffAndDirectCalls) { + ResetStubs(); + SendRpc(stub_handoff1_.get(), 5); + if (GetParam().server_has_port) { + SendRpc(stub_direct_.get(), 5); + } +} + +TEST_P(PortSharingEnd2endTest, MultipleHandoff) { + for (int i = 0; i < 3; i++) { + ResetStubs(); + SendRpc(stub_handoff2_.get(), 1); + } +} + +TEST_P(PortSharingEnd2endTest, TwoHandoffPorts) { + for (int i = 0; i < 3; i++) { + ResetStubs(); + SendRpc(stub_handoff1_.get(), 5); + SendRpc(stub_handoff2_.get(), 5); + } +} + +INSTANTIATE_TEST_CASE_P(PortSharingEnd2end, PortSharingEnd2endTest, + ::testing::ValuesIn(CreateTestScenarios())); + +} // namespace +} // namespace testing +} // namespace grpc + +#endif // GRPC_POSIX_SOCKET_TCP_SERVER + +int main(int argc, char** argv) { + grpc::testing::TestEnvironment env(argc, argv); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 357efa0d684..d6bcdf75b36 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1241,6 +1241,8 @@ src/cpp/server/channel_argument_option.cc \ src/cpp/server/create_default_thread_pool.cc \ src/cpp/server/dynamic_thread_pool.cc \ src/cpp/server/dynamic_thread_pool.h \ +src/cpp/server/external_connection_acceptor_impl.cc \ +src/cpp/server/external_connection_acceptor_impl.h \ src/cpp/server/health/default_health_check_service.cc \ src/cpp/server/health/default_health_check_service.h \ src/cpp/server/health/health_check_service.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 9778343cd94..547b0828f11 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -4283,6 +4283,25 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "grpc", + "grpc++", + "grpc++_test_util", + "grpc_test_util", + "test_tcp_server" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "port_sharing_end2end_test", + "src": [ + "test/cpp/end2end/port_sharing_end2end_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", @@ -10206,6 +10225,7 @@ "src/cpp/client/create_channel_internal.h", "src/cpp/common/channel_filter.h", "src/cpp/server/dynamic_thread_pool.h", + "src/cpp/server/external_connection_acceptor_impl.h", "src/cpp/server/health/default_health_check_service.h", "src/cpp/server/thread_pool_interface.h", "src/cpp/thread_manager/thread_manager.h" @@ -10347,6 +10367,8 @@ "src/cpp/server/create_default_thread_pool.cc", "src/cpp/server/dynamic_thread_pool.cc", "src/cpp/server/dynamic_thread_pool.h", + "src/cpp/server/external_connection_acceptor_impl.cc", + "src/cpp/server/external_connection_acceptor_impl.h", "src/cpp/server/health/default_health_check_service.cc", "src/cpp/server/health/default_health_check_service.h", "src/cpp/server/health/health_check_service.cc", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index ec2e570bea7..41add98075e 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -5001,6 +5001,30 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "port_sharing_end2end_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": true + }, { "args": [], "benchmark": false, From 7e8dec516ba4fe886dcdbc57fa3a4ab772004cf7 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 30 Apr 2019 13:52:37 -0700 Subject: [PATCH 0074/1555] Unify deployment target --- .../tests/Tests.xcodeproj/project.pbxproj | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index 1295731641b..1f05899bd60 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -877,7 +877,6 @@ ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.grpc.UnitTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -907,7 +906,6 @@ CODE_SIGN_STYLE = Automatic; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.grpc.UnitTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -937,7 +935,6 @@ CODE_SIGN_STYLE = Automatic; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.grpc.UnitTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -967,7 +964,6 @@ CODE_SIGN_STYLE = Automatic; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.grpc.UnitTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1054,7 +1050,6 @@ GCC_C_LANGUAGE_STANDARD = gnu11; GCC_WARN_INHIBIT_ALL_WARNINGS = YES; INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -1094,7 +1089,6 @@ GCC_C_LANGUAGE_STANDARD = gnu11; GCC_WARN_INHIBIT_ALL_WARNINGS = YES; INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CronetTests; @@ -1133,7 +1127,6 @@ GCC_C_LANGUAGE_STANDARD = gnu11; GCC_WARN_INHIBIT_ALL_WARNINGS = YES; INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CronetTests; @@ -1172,7 +1165,6 @@ GCC_C_LANGUAGE_STANDARD = gnu11; GCC_WARN_INHIBIT_ALL_WARNINGS = YES; INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CronetTests; @@ -1208,7 +1200,6 @@ ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -1242,7 +1233,6 @@ CODE_SIGN_STYLE = Automatic; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTests; @@ -1275,7 +1265,6 @@ CODE_SIGN_STYLE = Automatic; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTests; @@ -1308,7 +1297,6 @@ CODE_SIGN_STYLE = Automatic; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTests; From b028141f01646688b1c4652e92e79160035c0bab Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Tue, 30 Apr 2019 14:24:40 -0700 Subject: [PATCH 0075/1555] Change streaming ping pong args and add comment --- .../bm_callback_streaming_ping_pong.cc | 153 +++++++++++------- .../callback_streaming_ping_pong.h | 18 +-- 2 files changed, 102 insertions(+), 69 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc b/test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc index ed1c3189086..f7e3469f2e4 100644 --- a/test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc +++ b/test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2016 gRPC authors. + * Copyright 2019 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,10 +31,11 @@ auto& force_library_initialization = Library::get(); // Replace "benchmark::internal::Benchmark" with "::testing::Benchmark" to use // internal microbenchmarking tooling -static void StreamingPingPongArgs(benchmark::internal::Benchmark* b) { +static void StreamingPingPongMsgSizeArgs(benchmark::internal::Benchmark* b) { int msg_size = 0; - - b->Args({0, 0}); // spl case: 0 ping-pong msgs (msg_size doesn't matter here) + // base case: 0 byte ping-pong msgs + b->Args({0, 1}); + b->Args({0, 2}); for (msg_size = 0; msg_size <= 128 * 1024 * 1024; msg_size == 0 ? msg_size++ : msg_size *= 8) { @@ -42,119 +43,151 @@ static void StreamingPingPongArgs(benchmark::internal::Benchmark* b) { b->Args({msg_size, 2}); } } + +// Replace "benchmark::internal::Benchmark" with "::testing::Benchmark" to use +// internal microbenchmarking tooling +static void StreamingPingPongMsgsNumberArgs(benchmark::internal::Benchmark* b) { + int msg_number = 0; + + for (msg_number = 0; msg_number <= 128 * 1024; + msg_number == 0 ? msg_number++ : msg_number *= 8) { + b->Args({0, msg_number}); + // 64 KiB same as the synthetic test configuration + b->Args({64 * 1024, msg_number}); + } +} + +// Streaming with different message size BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, NoOpMutator) - ->Apply(StreamingPingPongArgs); + ->Apply(StreamingPingPongMsgSizeArgs); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, MinInProcess, NoOpMutator, NoOpMutator) - ->Apply(StreamingPingPongArgs); + ->Apply(StreamingPingPongMsgSizeArgs); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, NoOpMutator) - ->Apply(StreamingPingPongArgs); + ->Apply(StreamingPingPongMsgSizeArgs); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, MinInProcessCHTTP2, NoOpMutator, NoOpMutator) - ->Apply(StreamingPingPongArgs); + ->Apply(StreamingPingPongMsgSizeArgs); +// Streaming with different message number +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, + NoOpMutator) + ->Apply(StreamingPingPongMsgsNumberArgs); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, MinInProcess, NoOpMutator, + NoOpMutator) + ->Apply(StreamingPingPongMsgsNumberArgs); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, + NoOpMutator) + ->Apply(StreamingPingPongMsgsNumberArgs); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, MinInProcessCHTTP2, NoOpMutator, + NoOpMutator) + ->Apply(StreamingPingPongMsgsNumberArgs); + +// Client context with different metadata BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, Client_AddMetadata, 2>, NoOpMutator) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, Client_AddMetadata, 2>, NoOpMutator) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, Client_AddMetadata, 2>, NoOpMutator) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 100>) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, Client_AddMetadata, 2>, NoOpMutator) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, Client_AddMetadata, 2>, NoOpMutator) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, Client_AddMetadata, 2>, NoOpMutator) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); + ->Args({0, 1}); + +// Server context with different metadata +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 1}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 1}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 1}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 1}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 1}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 1}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, + Server_AddInitialMetadata, 100>) + ->Args({0, 1}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 1}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 1}); +BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, Server_AddInitialMetadata, 1>) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, Server_AddInitialMetadata, 1>) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, Server_AddInitialMetadata, 1>) - ->Args({0, 0}); + ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, Server_AddInitialMetadata, 100>) - ->Args({0, 0}); + ->Args({0, 1}); } // namespace testing } // namespace grpc diff --git a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h index 13743412153..1710a754803 100644 --- a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h @@ -37,26 +37,26 @@ namespace testing { template static void BM_CallbackBidiStreaming(benchmark::State& state) { const int message_size = state.range(0); - const int max_ping_pongs = state.range(1) > 0 ? 1 : state.range(1); + const int max_ping_pongs = state.range(1); CallbackStreamingTestService service; std::unique_ptr fixture(new Fixture(&service)); std::unique_ptr stub_( EchoTestService::NewStub(fixture->channel())); - EchoRequest* request = new EchoRequest; - EchoResponse* response = new EchoResponse; + EchoRequest request; + EchoResponse response; if (state.range(0) > 0) { - request->set_message(std::string(state.range(0), 'a')); + request.set_message(std::string(state.range(0), 'a')); } else { - request->set_message(""); + request.set_message(""); } while (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); - ClientContext* cli_ctx = new ClientContext; - cli_ctx->AddMetadata(kServerFinishAfterNReads, + ClientContext cli_ctx; + cli_ctx.AddMetadata(kServerFinishAfterNReads, grpc::to_string(max_ping_pongs)); - cli_ctx->AddMetadata(kServerResponseStreamsToSend, + cli_ctx.AddMetadata(kServerResponseStreamsToSend, grpc::to_string(message_size)); - BidiClient test{stub_.get(), request, response, cli_ctx, max_ping_pongs}; + BidiClient test{stub_.get(), &request, &response, &cli_ctx, max_ping_pongs}; test.Await(); } fixture->Finish(state); From d74f04680f94b22982103cdddd9f6e7e76783d47 Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 30 Apr 2019 15:04:11 -0700 Subject: [PATCH 0076/1555] Restrict workaround to MSBuild 15.0 and above --- .../build/_protobuf/Google.Protobuf.Tools.targets | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets b/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets index 784f789528e..b3fd02d4faa 100644 --- a/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets +++ b/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets @@ -40,10 +40,11 @@ - - - - + + + + + From fd5f787080838028320e3553d79c5c3f603380a2 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Tue, 30 Apr 2019 18:23:58 -0400 Subject: [PATCH 0077/1555] Introduce slice_buffer helper methods to avoid copies. take_first(), grpc_undo_first(), ... are very clostly methods that unnecessarily copy grpc_slice with extra ref counting requirements. Introduce alternatives to avoid copies and refs wherever possible. This results in 1% improvements in the benchmarks. --- .../transport/chttp2/transport/frame_data.cc | 59 +++++++++---------- .../compression/stream_compression_gzip.cc | 18 +++--- src/core/lib/iomgr/tcp_posix.cc | 3 +- .../security/transport/security_handshaker.cc | 11 ++-- src/core/lib/slice/slice_buffer.cc | 18 ++++++ src/core/lib/slice/slice_internal.h | 15 +++++ test/core/slice/slice_buffer_test.cc | 43 ++++++++++++++ 7 files changed, 119 insertions(+), 48 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/frame_data.cc b/src/core/ext/transport/chttp2/transport/frame_data.cc index 6080a4bd1c4..2b7d3fce008 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.cc +++ b/src/core/ext/transport/chttp2/transport/frame_data.cc @@ -104,23 +104,22 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( uint8_t* end = nullptr; uint8_t* cur = nullptr; - grpc_slice slice = grpc_slice_buffer_take_first(slices); - - beg = GRPC_SLICE_START_PTR(slice); - end = GRPC_SLICE_END_PTR(slice); + grpc_slice* slice = grpc_slice_buffer_mutable_first(slices); + beg = GRPC_SLICE_START_PTR(*slice); + end = GRPC_SLICE_END_PTR(*slice); cur = beg; uint32_t message_flags; char* msg; if (cur == end) { - grpc_slice_unref_internal(slice); + grpc_slice_buffer_consume_first(slices); continue; } switch (p->state) { case GRPC_CHTTP2_DATA_ERROR: p->state = GRPC_CHTTP2_DATA_ERROR; - grpc_slice_unref_internal(slice); + grpc_slice_buffer_consume_first(slices); return GRPC_ERROR_REF(p->error); case GRPC_CHTTP2_DATA_FH_0: s->stats.incoming.framing_bytes++; @@ -138,19 +137,19 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( p->error = grpc_error_set_int(p->error, GRPC_ERROR_INT_STREAM_ID, static_cast(s->id)); gpr_free(msg); - msg = grpc_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); + msg = grpc_dump_slice(*slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); p->error = grpc_error_set_str(p->error, GRPC_ERROR_STR_RAW_BYTES, grpc_slice_from_copied_string(msg)); gpr_free(msg); p->error = grpc_error_set_int(p->error, GRPC_ERROR_INT_OFFSET, cur - beg); p->state = GRPC_CHTTP2_DATA_ERROR; - grpc_slice_unref_internal(slice); + grpc_slice_buffer_consume_first(slices); return GRPC_ERROR_REF(p->error); } if (++cur == end) { p->state = GRPC_CHTTP2_DATA_FH_1; - grpc_slice_unref_internal(slice); + grpc_slice_buffer_consume_first(slices); continue; } /* fallthrough */ @@ -159,7 +158,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( p->frame_size = (static_cast(*cur)) << 24; if (++cur == end) { p->state = GRPC_CHTTP2_DATA_FH_2; - grpc_slice_unref_internal(slice); + grpc_slice_buffer_consume_first(slices); continue; } /* fallthrough */ @@ -168,7 +167,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( p->frame_size |= (static_cast(*cur)) << 16; if (++cur == end) { p->state = GRPC_CHTTP2_DATA_FH_3; - grpc_slice_unref_internal(slice); + grpc_slice_buffer_consume_first(slices); continue; } /* fallthrough */ @@ -177,7 +176,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( p->frame_size |= (static_cast(*cur)) << 8; if (++cur == end) { p->state = GRPC_CHTTP2_DATA_FH_4; - grpc_slice_unref_internal(slice); + grpc_slice_buffer_consume_first(slices); continue; } /* fallthrough */ @@ -204,19 +203,18 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( p->state = GRPC_CHTTP2_DATA_FH_0; } s->pending_byte_stream = true; - if (cur != end) { - grpc_slice_buffer_undo_take_first( - slices, grpc_slice_sub(slice, static_cast(cur - beg), - static_cast(end - beg))); + grpc_slice_buffer_sub_first(slices, static_cast(cur - beg), + static_cast(end - beg)); + } else { + grpc_slice_buffer_consume_first(slices); } - grpc_slice_unref_internal(slice); return GRPC_ERROR_NONE; case GRPC_CHTTP2_DATA_FRAME: { GPR_ASSERT(p->parsing_frame != nullptr); GPR_ASSERT(slice_out != nullptr); if (cur == end) { - grpc_slice_unref_internal(slice); + grpc_slice_buffer_consume_first(slices); continue; } uint32_t remaining = static_cast(end - cur); @@ -224,32 +222,32 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( s->stats.incoming.data_bytes += remaining; if (GRPC_ERROR_NONE != (error = p->parsing_frame->Push( - grpc_slice_sub(slice, static_cast(cur - beg), + grpc_slice_sub(*slice, static_cast(cur - beg), static_cast(end - beg)), slice_out))) { - grpc_slice_unref_internal(slice); + grpc_slice_buffer_consume_first(slices); return error; } if (GRPC_ERROR_NONE != (error = p->parsing_frame->Finished(GRPC_ERROR_NONE, true))) { - grpc_slice_unref_internal(slice); + grpc_slice_buffer_consume_first(slices); return error; } p->parsing_frame = nullptr; p->state = GRPC_CHTTP2_DATA_FH_0; - grpc_slice_unref_internal(slice); + grpc_slice_buffer_consume_first(slices); return GRPC_ERROR_NONE; } else if (remaining < p->frame_size) { s->stats.incoming.data_bytes += remaining; if (GRPC_ERROR_NONE != (error = p->parsing_frame->Push( - grpc_slice_sub(slice, static_cast(cur - beg), + grpc_slice_sub(*slice, static_cast(cur - beg), static_cast(end - beg)), slice_out))) { return error; } p->frame_size -= remaining; - grpc_slice_unref_internal(slice); + grpc_slice_buffer_consume_first(slices); return GRPC_ERROR_NONE; } else { GPR_ASSERT(remaining > p->frame_size); @@ -257,30 +255,27 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( if (GRPC_ERROR_NONE != p->parsing_frame->Push( grpc_slice_sub( - slice, static_cast(cur - beg), + *slice, static_cast(cur - beg), static_cast(cur + p->frame_size - beg)), slice_out)) { - grpc_slice_unref_internal(slice); + grpc_slice_buffer_consume_first(slices); return error; } if (GRPC_ERROR_NONE != (error = p->parsing_frame->Finished(GRPC_ERROR_NONE, true))) { - grpc_slice_unref_internal(slice); + grpc_slice_buffer_consume_first(slices); return error; } p->parsing_frame = nullptr; p->state = GRPC_CHTTP2_DATA_FH_0; cur += p->frame_size; - grpc_slice_buffer_undo_take_first( - slices, grpc_slice_sub(slice, static_cast(cur - beg), - static_cast(end - beg))); - grpc_slice_unref_internal(slice); + grpc_slice_buffer_sub_first(slices, static_cast(cur - beg), + static_cast(end - beg)); return GRPC_ERROR_NONE; } } } } - return GRPC_ERROR_NONE; } diff --git a/src/core/lib/compression/stream_compression_gzip.cc b/src/core/lib/compression/stream_compression_gzip.cc index bffdb1fd17d..ca687066136 100644 --- a/src/core/lib/compression/stream_compression_gzip.cc +++ b/src/core/lib/compression/stream_compression_gzip.cc @@ -53,25 +53,25 @@ static bool gzip_flate(grpc_stream_compression_context_gzip* ctx, ctx->zs.avail_out = static_cast(slice_size); ctx->zs.next_out = GRPC_SLICE_START_PTR(slice_out); while (ctx->zs.avail_out > 0 && in->length > 0 && !eoc) { - grpc_slice slice = grpc_slice_buffer_take_first(in); - ctx->zs.avail_in = static_cast GRPC_SLICE_LENGTH(slice); - ctx->zs.next_in = GRPC_SLICE_START_PTR(slice); + grpc_slice* slice = grpc_slice_buffer_mutable_first(in); + ctx->zs.avail_in = static_cast GRPC_SLICE_LENGTH(*slice); + ctx->zs.next_in = GRPC_SLICE_START_PTR(*slice); r = ctx->flate(&ctx->zs, Z_NO_FLUSH); if (r < 0 && r != Z_BUF_ERROR) { gpr_log(GPR_ERROR, "zlib error (%d)", r); grpc_slice_unref_internal(slice_out); - grpc_slice_unref_internal(slice); + grpc_slice_buffer_consume_first(in); return false; } else if (r == Z_STREAM_END && ctx->flate == inflate) { eoc = true; } if (ctx->zs.avail_in > 0) { - grpc_slice_buffer_undo_take_first( - in, - grpc_slice_sub(slice, GRPC_SLICE_LENGTH(slice) - ctx->zs.avail_in, - GRPC_SLICE_LENGTH(slice))); + grpc_slice_buffer_sub_first( + in, GRPC_SLICE_LENGTH(*slice) - ctx->zs.avail_in, + GRPC_SLICE_LENGTH(*slice)); + } else { + grpc_slice_buffer_consume_first(in); } - grpc_slice_unref_internal(slice); } if (flush != 0 && ctx->zs.avail_out > 0 && !eoc) { GPR_ASSERT(in->length == 0); diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index b140ae0ccae..45af4931cf5 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -980,8 +980,7 @@ static bool tcp_flush(grpc_tcp* tcp, grpc_error** error) { // unref all and forget about all slices that have been written to this // point for (size_t idx = 0; idx < unwind_slice_idx; ++idx) { - grpc_slice_unref_internal( - grpc_slice_buffer_take_first(tcp->outgoing_buffer)); + grpc_slice_buffer_consume_first(tcp->outgoing_buffer); } return false; } else if (errno == EPIPE) { diff --git a/src/core/lib/security/transport/security_handshaker.cc b/src/core/lib/security/transport/security_handshaker.cc index 3605bbe5974..7c0792f2846 100644 --- a/src/core/lib/security/transport/security_handshaker.cc +++ b/src/core/lib/security/transport/security_handshaker.cc @@ -144,11 +144,12 @@ size_t SecurityHandshaker::MoveReadBufferIntoHandshakeBuffer() { } size_t offset = 0; while (args_->read_buffer->count > 0) { - grpc_slice next_slice = grpc_slice_buffer_take_first(args_->read_buffer); - memcpy(handshake_buffer_ + offset, GRPC_SLICE_START_PTR(next_slice), - GRPC_SLICE_LENGTH(next_slice)); - offset += GRPC_SLICE_LENGTH(next_slice); - grpc_slice_unref_internal(next_slice); + grpc_slice* next_slice = + grpc_slice_buffer_mutable_first(args_->read_buffer); + memcpy(handshake_buffer_ + offset, GRPC_SLICE_START_PTR(*next_slice), + GRPC_SLICE_LENGTH(*next_slice)); + offset += GRPC_SLICE_LENGTH(*next_slice); + grpc_slice_buffer_consume_first(args_->read_buffer); } return bytes_in_read_buffer; } diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc index 1f1c08b1594..76da64b858f 100644 --- a/src/core/lib/slice/slice_buffer.cc +++ b/src/core/lib/slice/slice_buffer.cc @@ -370,6 +370,24 @@ grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer* sb) { return slice; } +void grpc_slice_buffer_consume_first(grpc_slice_buffer* sb) { + GPR_ASSERT(sb->count > 0); + sb->length -= GRPC_SLICE_LENGTH(sb->slices[0]); + grpc_slice_unref_internal(sb->slices[0]); + sb->slices++; + if (--sb->count == 0) { + sb->slices = sb->base_slices; + } +} + +void grpc_slice_buffer_sub_first(grpc_slice_buffer* sb, size_t begin, + size_t end) { + // TODO(soheil): Introduce a ptr version for sub. + sb->length -= GRPC_SLICE_LENGTH(sb->slices[0]); + sb->slices[0] = grpc_slice_sub_no_ref(sb->slices[0], begin, end); + sb->length += GRPC_SLICE_LENGTH(sb->slices[0]); +} + void grpc_slice_buffer_undo_take_first(grpc_slice_buffer* sb, grpc_slice slice) { sb->slices--; diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index db8c8e5c7cc..4c4ace443dc 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -21,6 +21,8 @@ #include +#include + #include #include #include @@ -240,6 +242,19 @@ void grpc_slice_buffer_partial_unref_internal(grpc_slice_buffer* sb, size_t idx); void grpc_slice_buffer_destroy_internal(grpc_slice_buffer* sb); +// Returns the first slice in the slice buffer. +inline grpc_slice* grpc_slice_buffer_mutable_first(grpc_slice_buffer* sb) { + GPR_DEBUG_ASSERT(sb->count > 0); + return &sb->slices[0]; +} + +// Consumes the first slice in the slice buffer. +void grpc_slice_buffer_consume_first(grpc_slice_buffer* sb); + +// Calls grpc_slice_sub with the given parameters on the first slice. +void grpc_slice_buffer_sub_first(grpc_slice_buffer* sb, size_t begin, + size_t end); + /* Check if a slice is interned */ bool grpc_slice_is_interned(const grpc_slice& slice); diff --git a/test/core/slice/slice_buffer_test.cc b/test/core/slice/slice_buffer_test.cc index b53e3312df1..8aa58a3ac0d 100644 --- a/test/core/slice/slice_buffer_test.cc +++ b/test/core/slice/slice_buffer_test.cc @@ -19,6 +19,7 @@ #include #include #include +#include "src/core/lib/slice/slice_internal.h" #include "test/core/util/test_config.h" void test_slice_buffer_add() { @@ -105,12 +106,54 @@ void test_slice_buffer_move_first() { GPR_ASSERT(dst.length == dst_len); } +void test_slice_buffer_first() { + grpc_slice slices[3]; + slices[0] = grpc_slice_from_copied_string("aaa"); + slices[1] = grpc_slice_from_copied_string("bbbb"); + slices[2] = grpc_slice_from_copied_string("ccccc"); + + grpc_slice_buffer buf; + grpc_slice_buffer_init(&buf); + for (int idx = 0; idx < 3; ++idx) { + grpc_slice_ref(slices[idx]); + grpc_slice_buffer_add_indexed(&buf, slices[idx]); + } + + grpc_slice* first = grpc_slice_buffer_mutable_first(&buf); + GPR_ASSERT(GPR_SLICE_LENGTH(*first) == GPR_SLICE_LENGTH(slices[0])); + GPR_ASSERT(buf.count == 3); + GPR_ASSERT(buf.length == 12); + + grpc_slice_buffer_sub_first(&buf, 1, 2); + first = grpc_slice_buffer_mutable_first(&buf); + GPR_ASSERT(GPR_SLICE_LENGTH(*first) == 1); + GPR_ASSERT(buf.count == 3); + GPR_ASSERT(buf.length == 10); + + grpc_slice_buffer_consume_first(&buf); + first = grpc_slice_buffer_mutable_first(&buf); + GPR_ASSERT(GPR_SLICE_LENGTH(*first) == GPR_SLICE_LENGTH(slices[1])); + GPR_ASSERT(buf.count == 2); + GPR_ASSERT(buf.length == 9); + + grpc_slice_buffer_consume_first(&buf); + first = grpc_slice_buffer_mutable_first(&buf); + GPR_ASSERT(GPR_SLICE_LENGTH(*first) == GPR_SLICE_LENGTH(slices[2])); + GPR_ASSERT(buf.count == 1); + GPR_ASSERT(buf.length == 5); + + grpc_slice_buffer_consume_first(&buf); + GPR_ASSERT(buf.count == 0); + GPR_ASSERT(buf.length == 0); +} + int main(int argc, char** argv) { grpc::testing::TestEnvironment env(argc, argv); grpc_init(); test_slice_buffer_add(); test_slice_buffer_move_first(); + test_slice_buffer_first(); grpc_shutdown(); return 0; From 5538bb81434ccb01216c82d09ade04fdf9ec65b7 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Tue, 30 Apr 2019 17:56:43 -0400 Subject: [PATCH 0078/1555] Use compress and decompress slice_buffers only when they are needed. Compression is not used for performance senstiive RPCs, yet chttp2 always moves buffers in/out of the compressed/decmpressed buffers. Even initilizing them is costly. Use the (de)compression buffer and state only when we are using non-identity compression. This is part of a larger performance change, and this one buys us 1%-2% depending on the benchmark. --- .../chttp2/transport/chttp2_transport.cc | 79 +++++++++++++------ .../chttp2/transport/hpack_parser.cc | 6 ++ .../ext/transport/chttp2/transport/internal.h | 35 ++++---- .../ext/transport/chttp2/transport/writing.cc | 63 ++++++++++++--- 4 files changed, 131 insertions(+), 52 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index d4188775722..6eec4359563 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -679,8 +679,6 @@ grpc_chttp2_stream::grpc_chttp2_stream(grpc_chttp2_transport* t, grpc_slice_buffer_init(&frame_storage); grpc_slice_buffer_init(&unprocessed_incoming_frames_buffer); grpc_slice_buffer_init(&flow_controlled_buffer); - grpc_slice_buffer_init(&compressed_data_buffer); - grpc_slice_buffer_init(&decompressed_data_buffer); GRPC_CLOSURE_INIT(&complete_fetch_locked, ::complete_fetch_locked, this, grpc_combiner_scheduler(t->combiner)); @@ -704,8 +702,13 @@ grpc_chttp2_stream::~grpc_chttp2_stream() { grpc_slice_buffer_destroy_internal(&unprocessed_incoming_frames_buffer); grpc_slice_buffer_destroy_internal(&frame_storage); - grpc_slice_buffer_destroy_internal(&compressed_data_buffer); - grpc_slice_buffer_destroy_internal(&decompressed_data_buffer); + if (stream_compression_method != GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS) { + grpc_slice_buffer_destroy_internal(&compressed_data_buffer); + } + if (stream_decompression_method != + GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS) { + grpc_slice_buffer_destroy_internal(&decompressed_data_buffer); + } grpc_chttp2_list_remove_stalled_by_transport(t, this); grpc_chttp2_list_remove_stalled_by_stream(t, this); @@ -759,12 +762,15 @@ static void destroy_stream(grpc_transport* gt, grpc_stream* gs, GPR_TIMER_SCOPE("destroy_stream", 0); grpc_chttp2_transport* t = reinterpret_cast(gt); grpc_chttp2_stream* s = reinterpret_cast(gs); - - if (s->stream_compression_ctx != nullptr) { + if (s->stream_compression_method != + GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS && + s->stream_compression_ctx != nullptr) { grpc_stream_compression_context_destroy(s->stream_compression_ctx); s->stream_compression_ctx = nullptr; } - if (s->stream_decompression_ctx != nullptr) { + if (s->stream_decompression_method != + GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS && + s->stream_decompression_ctx != nullptr) { grpc_stream_compression_context_destroy(s->stream_decompression_ctx); s->stream_decompression_ctx = nullptr; } @@ -1443,6 +1449,13 @@ static void perform_stream_op_locked(void* stream_op, s->stream_compression_method = GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS; } + if (s->stream_compression_method != + GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS) { + s->uncompressed_data_size = 0; + s->stream_compression_ctx = nullptr; + grpc_slice_buffer_init(&s->compressed_data_buffer); + } + s->send_initial_metadata_finished = add_closure_barrier(on_complete); s->send_initial_metadata = op_payload->send_initial_metadata.send_initial_metadata; @@ -1998,27 +2011,39 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_chttp2_transport* t, !s->seen_error && s->recv_trailing_metadata_finished != nullptr) { /* Maybe some SYNC_FLUSH data is left in frame_storage. Consume them and * maybe decompress the next 5 bytes in the stream. */ - bool end_of_context; - if (!s->stream_decompression_ctx) { - s->stream_decompression_ctx = grpc_stream_compression_context_create( - s->stream_decompression_method); - } - if (!grpc_stream_decompress( - s->stream_decompression_ctx, &s->frame_storage, - &s->unprocessed_incoming_frames_buffer, nullptr, - GRPC_HEADER_SIZE_IN_BYTES, &end_of_context)) { - grpc_slice_buffer_reset_and_unref_internal(&s->frame_storage); - grpc_slice_buffer_reset_and_unref_internal( - &s->unprocessed_incoming_frames_buffer); - s->seen_error = true; - } else { + if (s->stream_decompression_method == + GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS) { + grpc_slice_buffer_move_first(&s->frame_storage, + GRPC_HEADER_SIZE_IN_BYTES, + &s->unprocessed_incoming_frames_buffer); if (s->unprocessed_incoming_frames_buffer.length > 0) { s->unprocessed_incoming_frames_decompressed = true; pending_data = true; } - if (end_of_context) { - grpc_stream_compression_context_destroy(s->stream_decompression_ctx); - s->stream_decompression_ctx = nullptr; + } else { + bool end_of_context; + if (!s->stream_decompression_ctx) { + s->stream_decompression_ctx = grpc_stream_compression_context_create( + s->stream_decompression_method); + } + if (!grpc_stream_decompress( + s->stream_decompression_ctx, &s->frame_storage, + &s->unprocessed_incoming_frames_buffer, nullptr, + GRPC_HEADER_SIZE_IN_BYTES, &end_of_context)) { + grpc_slice_buffer_reset_and_unref_internal(&s->frame_storage); + grpc_slice_buffer_reset_and_unref_internal( + &s->unprocessed_incoming_frames_buffer); + s->seen_error = true; + } else { + if (s->unprocessed_incoming_frames_buffer.length > 0) { + s->unprocessed_incoming_frames_decompressed = true; + pending_data = true; + } + if (end_of_context) { + grpc_stream_compression_context_destroy( + s->stream_decompression_ctx); + s->stream_decompression_ctx = nullptr; + } } } } @@ -2941,6 +2966,8 @@ bool Chttp2IncomingByteStream::Next(size_t max_size_hint, } void Chttp2IncomingByteStream::MaybeCreateStreamDecompressionCtx() { + GPR_DEBUG_ASSERT(stream_->stream_decompression_method != + GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS); if (!stream_->stream_decompression_ctx) { stream_->stream_decompression_ctx = grpc_stream_compression_context_create( stream_->stream_decompression_method); @@ -2951,7 +2978,9 @@ grpc_error* Chttp2IncomingByteStream::Pull(grpc_slice* slice) { GPR_TIMER_SCOPE("incoming_byte_stream_pull", 0); grpc_error* error; if (stream_->unprocessed_incoming_frames_buffer.length > 0) { - if (!stream_->unprocessed_incoming_frames_decompressed) { + if (!stream_->unprocessed_incoming_frames_decompressed && + stream_->stream_decompression_method != + GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS) { bool end_of_context; MaybeCreateStreamDecompressionCtx(); if (!grpc_stream_decompress(stream_->stream_decompression_ctx, diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index 5bcdb4e2326..7a37d37fd10 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -1616,6 +1616,12 @@ static void parse_stream_compression_md(grpc_chttp2_transport* t, s->stream_decompression_method = GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS; } + + if (s->stream_decompression_method != + GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS) { + s->stream_decompression_ctx = nullptr; + grpc_slice_buffer_init(&s->decompressed_data_buffer); + } } grpc_error* grpc_chttp2_header_parser_parse(void* hpack_parser, diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 00b1fe18b28..0a55ee111ee 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -583,10 +583,6 @@ struct grpc_chttp2_stream { grpc_slice_buffer frame_storage; /* protected by t combiner */ - /* Accessed only by transport thread when stream->pending_byte_stream == false - * Accessed only by application thread when stream->pending_byte_stream == - * true */ - grpc_slice_buffer unprocessed_incoming_frames_buffer; grpc_closure* on_next = nullptr; /* protected by t combiner */ bool pending_byte_stream = false; /* protected by t combiner */ // cached length of buffer to be used by the transport thread in cases where @@ -594,6 +590,10 @@ struct grpc_chttp2_stream { // application threads are allowed to modify // unprocessed_incoming_frames_buffer size_t unprocessed_incoming_frames_buffer_cached_length = 0; + /* Accessed only by transport thread when stream->pending_byte_stream == false + * Accessed only by application thread when stream->pending_byte_stream == + * true */ + grpc_slice_buffer unprocessed_incoming_frames_buffer; grpc_closure reset_byte_stream; grpc_error* byte_stream_error = GRPC_ERROR_NONE; /* protected by t combiner */ bool received_last_frame = false; /* protected by t combiner */ @@ -634,18 +634,7 @@ struct grpc_chttp2_stream { /* Stream decompression method to be used. */ grpc_stream_compression_method stream_decompression_method = GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS; - /** Stream compression decompress context */ - grpc_stream_compression_context* stream_decompression_ctx = nullptr; - /** Stream compression compress context */ - grpc_stream_compression_context* stream_compression_ctx = nullptr; - /** Buffer storing data that is compressed but not sent */ - grpc_slice_buffer compressed_data_buffer; - /** Amount of uncompressed bytes sent out when compressed_data_buffer is - * emptied */ - size_t uncompressed_data_size = 0; - /** Temporary buffer storing decompressed data */ - grpc_slice_buffer decompressed_data_buffer; /** Whether bytes stored in unprocessed_incoming_byte_stream is decompressed */ bool unprocessed_incoming_frames_decompressed = false; @@ -655,6 +644,22 @@ struct grpc_chttp2_stream { size_t decompressed_header_bytes = 0; /** Byte counter for number of bytes written */ size_t byte_counter = 0; + + /** Amount of uncompressed bytes sent out when compressed_data_buffer is + * emptied */ + size_t uncompressed_data_size; + /** Stream compression compress context */ + grpc_stream_compression_context* stream_compression_ctx; + /** Buffer storing data that is compressed but not sent */ + grpc_slice_buffer compressed_data_buffer; + + /** Stream compression decompress context */ + grpc_stream_compression_context* stream_decompression_ctx; + /** Temporary buffer storing decompressed data. + * Initialized, used, and destroyed only when stream uses (non-identity) + * compression. + */ + grpc_slice_buffer decompressed_data_buffer; }; /** Transport writing call flow: diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc index 3d1db0aa144..90015bd97ec 100644 --- a/src/core/ext/transport/chttp2/transport/writing.cc +++ b/src/core/ext/transport/chttp2/transport/writing.cc @@ -25,6 +25,7 @@ #include +#include "src/core/lib/compression/stream_compression.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/profiling/timers.h" #include "src/core/lib/slice/slice_internal.h" @@ -150,7 +151,11 @@ static void report_stall(grpc_chttp2_transport* t, grpc_chttp2_stream* s, ":flowed=%" PRId64 ":peer_initwin=%d:t_win=%" PRId64 ":s_win=%d:s_delta=%" PRId64 "]", t->peer_string, t, s->id, staller, s->flow_controlled_buffer.length, - s->compressed_data_buffer.length, s->flow_controlled_bytes_flowed, + s->stream_compression_method == + GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS + ? 0 + : s->compressed_data_buffer.length, + s->flow_controlled_bytes_flowed, t->settings[GRPC_ACKED_SETTINGS] [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE], t->flow_control->remote_window(), @@ -325,7 +330,23 @@ class DataSendContext { bool AnyOutgoing() const { return max_outgoing() > 0; } + void FlushUncompressedBytes() { + uint32_t send_bytes = static_cast GPR_MIN( + max_outgoing(), s_->flow_controlled_buffer.length); + is_last_frame_ = send_bytes == s_->flow_controlled_buffer.length && + s_->fetching_send_message == nullptr && + s_->send_trailing_metadata != nullptr && + grpc_metadata_batch_is_empty(s_->send_trailing_metadata); + grpc_chttp2_encode_data(s_->id, &s_->flow_controlled_buffer, send_bytes, + is_last_frame_, &s_->stats.outgoing, &t_->outbuf); + s_->flow_control->SentData(send_bytes); + s_->sending_bytes += send_bytes; + } + void FlushCompressedBytes() { + GPR_DEBUG_ASSERT(s_->stream_compression_method != + GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS); + uint32_t send_bytes = static_cast GPR_MIN( max_outgoing(), s_->compressed_data_buffer.length); bool is_last_data_frame = @@ -360,6 +381,9 @@ class DataSendContext { } void CompressMoreBytes() { + GPR_DEBUG_ASSERT(s_->stream_compression_method != + GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS); + if (s_->stream_compression_ctx == nullptr) { s_->stream_compression_ctx = grpc_stream_compression_context_create(s_->stream_compression_method); @@ -417,7 +441,7 @@ class StreamWriteContext { // https://github.com/grpc/proposal/blob/master/A6-client-retries.md#when-retries-are-valid if (!t_->is_client && s_->fetching_send_message == nullptr && s_->flow_controlled_buffer.length == 0 && - s_->compressed_data_buffer.length == 0 && + compressed_data_buffer_len() == 0 && s_->send_trailing_metadata != nullptr && is_default_initial_metadata(s_->send_initial_metadata)) { ConvertInitialMetadataToTrailingMetadata(); @@ -446,6 +470,13 @@ class StreamWriteContext { "send_initial_metadata_finished"); } + bool compressed_data_buffer_len() { + return s_->stream_compression_method == + GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS + ? 0 + : s_->compressed_data_buffer.length; + } + void FlushWindowUpdates() { /* send any window updates */ const uint32_t stream_announce = s_->flow_control->MaybeSendUpdate(); @@ -462,7 +493,7 @@ class StreamWriteContext { if (!s_->sent_initial_metadata) return; if (s_->flow_controlled_buffer.length == 0 && - s_->compressed_data_buffer.length == 0) { + compressed_data_buffer_len() == 0) { return; // early out: nothing to do } @@ -479,13 +510,21 @@ class StreamWriteContext { return; // early out: nothing to do } - while ((s_->flow_controlled_buffer.length > 0 || - s_->compressed_data_buffer.length > 0) && - data_send_context.max_outgoing() > 0) { - if (s_->compressed_data_buffer.length > 0) { - data_send_context.FlushCompressedBytes(); - } else { - data_send_context.CompressMoreBytes(); + if (s_->stream_compression_method == + GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS) { + while (s_->flow_controlled_buffer.length > 0 && + data_send_context.max_outgoing() > 0) { + data_send_context.FlushUncompressedBytes(); + } + } else { + while ((s_->flow_controlled_buffer.length > 0 || + s_->compressed_data_buffer.length > 0) && + data_send_context.max_outgoing() > 0) { + if (s_->compressed_data_buffer.length > 0) { + data_send_context.FlushCompressedBytes(); + } else { + data_send_context.CompressMoreBytes(); + } } } write_context_->ResetPingClock(); @@ -495,7 +534,7 @@ class StreamWriteContext { data_send_context.CallCallbacks(); stream_became_writable_ = true; if (s_->flow_controlled_buffer.length > 0 || - s_->compressed_data_buffer.length > 0) { + compressed_data_buffer_len() > 0) { GRPC_CHTTP2_STREAM_REF(s_, "chttp2_writing:fork"); grpc_chttp2_list_add_writable_stream(t_, s_); } @@ -508,7 +547,7 @@ class StreamWriteContext { if (s_->send_trailing_metadata == nullptr) return; if (s_->fetching_send_message != nullptr) return; if (s_->flow_controlled_buffer.length != 0) return; - if (s_->compressed_data_buffer.length != 0) return; + if (compressed_data_buffer_len() != 0) return; GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_INFO, "sending trailing_metadata")); if (grpc_metadata_batch_is_empty(s_->send_trailing_metadata)) { From 1518ecbd76040fa1b9157a53e735c7e2e7c95c64 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Mon, 15 Apr 2019 10:48:30 -0700 Subject: [PATCH 0079/1555] Added new configuration system to core/grp. More generic configuration system is introduced in order to i) unify the way how modules access the configurations instead of using low-level get/setenv functions and ii) enable the customization for where configuration is stored. This could be extended to support flag, file, etc. Default configuration system uses environment variables as before so basically this is expected to work just as it did. This behavior can change by redefining GPR_GLOBAL_CONFIG_DEFINE_*type* macros. * Migrated configuration GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS GRPC_EXPERIMENTAL_DISABLE_FLOW_CONTROL GRPC_ABORT_ON_LEAKS GRPC_NOT_USE_SYSTEM_SSL_ROOTS --- BUILD | 5 + BUILD.gn | 9 ++ CMakeLists.txt | 77 ++++++++++ Makefile | 97 +++++++++++++ build.yaml | 23 +++ config.m4 | 1 + config.w32 | 1 + gRPC-C++.podspec | 8 ++ gRPC-Core.podspec | 9 ++ grpc.gemspec | 5 + grpc.gyp | 1 + package.xml | 5 + .../filters/client_channel/backup_poller.cc | 27 ++-- .../filters/client_channel/backup_poller.h | 3 + .../chttp2/transport/chttp2_plugin.cc | 13 +- src/core/lib/gpr/env.h | 3 + src/core/lib/gpr/env_linux.cc | 5 + src/core/lib/gpr/env_posix.cc | 5 + src/core/lib/gpr/env_windows.cc | 7 + src/core/lib/gpr/string.cc | 18 ++- src/core/lib/gpr/string.h | 6 +- src/core/lib/gprpp/global_config.h | 87 +++++++++++ src/core/lib/gprpp/global_config_custom.h | 29 ++++ src/core/lib/gprpp/global_config_env.cc | 135 ++++++++++++++++++ src/core/lib/gprpp/global_config_env.h | 131 +++++++++++++++++ src/core/lib/gprpp/global_config_generic.h | 44 ++++++ src/core/lib/iomgr/iomgr.cc | 10 +- .../security/security_connector/ssl_utils.cc | 12 +- src/python/grpcio/grpc_core_dependencies.py | 1 + test/core/gpr/env_test.cc | 14 ++ test/core/gpr/string_test.cc | 27 ++-- test/core/gprpp/BUILD | 26 ++++ test/core/gprpp/global_config_env_test.cc | 130 +++++++++++++++++ test/core/gprpp/global_config_test.cc | 65 +++++++++ test/cpp/end2end/async_end2end_test.cc | 3 +- test/cpp/end2end/client_lb_end2end_test.cc | 4 +- test/cpp/end2end/end2end_test.cc | 3 +- test/cpp/end2end/grpclb_end2end_test.cc | 4 +- test/cpp/end2end/xds_end2end_test.cc | 3 +- test/cpp/naming/resolver_component_test.cc | 5 +- tools/doxygen/Doxyfile.c++.internal | 4 + tools/doxygen/Doxyfile.core.internal | 5 + .../generated/sources_and_headers.json | 39 +++++ tools/run_tests/generated/tests.json | 48 +++++++ 44 files changed, 1095 insertions(+), 62 deletions(-) create mode 100644 src/core/lib/gprpp/global_config.h create mode 100644 src/core/lib/gprpp/global_config_custom.h create mode 100644 src/core/lib/gprpp/global_config_env.cc create mode 100644 src/core/lib/gprpp/global_config_env.h create mode 100644 src/core/lib/gprpp/global_config_generic.h create mode 100644 test/core/gprpp/global_config_env_test.cc create mode 100644 test/core/gprpp/global_config_test.cc diff --git a/BUILD b/BUILD index 58043459000..94f2e2a1b75 100644 --- a/BUILD +++ b/BUILD @@ -575,6 +575,7 @@ grpc_cc_library( "src/core/lib/gpr/wrap_memcpy.cc", "src/core/lib/gprpp/arena.cc", "src/core/lib/gprpp/fork.cc", + "src/core/lib/gprpp/global_config_env.cc", "src/core/lib/gprpp/thd_posix.cc", "src/core/lib/gprpp/thd_windows.cc", "src/core/lib/profiling/basic_timers.cc", @@ -601,6 +602,10 @@ grpc_cc_library( "src/core/lib/gprpp/arena.h", "src/core/lib/gprpp/atomic.h", "src/core/lib/gprpp/fork.h", + "src/core/lib/gprpp/global_config_custom.h", + "src/core/lib/gprpp/global_config_env.h", + "src/core/lib/gprpp/global_config_generic.h", + "src/core/lib/gprpp/global_config.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", diff --git a/BUILD.gn b/BUILD.gn index 38b2f0e6502..f642f6af1c2 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -184,6 +184,11 @@ config("grpc_config") { "src/core/lib/gprpp/atomic.h", "src/core/lib/gprpp/fork.cc", "src/core/lib/gprpp/fork.h", + "src/core/lib/gprpp/global_config.h", + "src/core/lib/gprpp/global_config_custom.h", + "src/core/lib/gprpp/global_config_env.cc", + "src/core/lib/gprpp/global_config_env.h", + "src/core/lib/gprpp/global_config_generic.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", @@ -1170,6 +1175,10 @@ config("grpc_config") { "src/core/lib/gprpp/atomic.h", "src/core/lib/gprpp/debug_location.h", "src/core/lib/gprpp/fork.h", + "src/core/lib/gprpp/global_config.h", + "src/core/lib/gprpp/global_config_custom.h", + "src/core/lib/gprpp/global_config_env.h", + "src/core/lib/gprpp/global_config_generic.h", "src/core/lib/gprpp/inlined_vector.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b93ab08af4..da2326525da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -629,6 +629,8 @@ add_dependencies(buildtests_cxx error_details_test) add_dependencies(buildtests_cxx exception_test) add_dependencies(buildtests_cxx filter_end2end_test) add_dependencies(buildtests_cxx generic_end2end_test) +add_dependencies(buildtests_cxx global_config_env_test) +add_dependencies(buildtests_cxx global_config_test) add_dependencies(buildtests_cxx golden_file_test) add_dependencies(buildtests_cxx grpc_alts_credentials_options_test) add_dependencies(buildtests_cxx grpc_cli) @@ -873,6 +875,7 @@ add_library(gpr src/core/lib/gpr/wrap_memcpy.cc src/core/lib/gprpp/arena.cc src/core/lib/gprpp/fork.cc + src/core/lib/gprpp/global_config_env.cc src/core/lib/gprpp/thd_posix.cc src/core/lib/gprpp/thd_windows.cc src/core/lib/profiling/basic_timers.cc @@ -13422,6 +13425,80 @@ target_link_libraries(generic_end2end_test ) +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + +add_executable(global_config_env_test + test/core/gprpp/global_config_env_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(global_config_env_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(global_config_env_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + gpr + grpc_test_util_unsecure + ${_gRPC_GFLAGS_LIBRARIES} +) + + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + +add_executable(global_config_test + test/core/gprpp/global_config_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(global_config_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(global_config_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + gpr + grpc_test_util_unsecure + ${_gRPC_GFLAGS_LIBRARIES} +) + + endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index 700e789265e..2cf316590ec 100644 --- a/Makefile +++ b/Makefile @@ -1206,6 +1206,8 @@ error_details_test: $(BINDIR)/$(CONFIG)/error_details_test exception_test: $(BINDIR)/$(CONFIG)/exception_test filter_end2end_test: $(BINDIR)/$(CONFIG)/filter_end2end_test generic_end2end_test: $(BINDIR)/$(CONFIG)/generic_end2end_test +global_config_env_test: $(BINDIR)/$(CONFIG)/global_config_env_test +global_config_test: $(BINDIR)/$(CONFIG)/global_config_test golden_file_test: $(BINDIR)/$(CONFIG)/golden_file_test grpc_alts_credentials_options_test: $(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test grpc_cli: $(BINDIR)/$(CONFIG)/grpc_cli @@ -1682,6 +1684,8 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/exception_test \ $(BINDIR)/$(CONFIG)/filter_end2end_test \ $(BINDIR)/$(CONFIG)/generic_end2end_test \ + $(BINDIR)/$(CONFIG)/global_config_env_test \ + $(BINDIR)/$(CONFIG)/global_config_test \ $(BINDIR)/$(CONFIG)/golden_file_test \ $(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test \ $(BINDIR)/$(CONFIG)/grpc_cli \ @@ -1826,6 +1830,8 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/exception_test \ $(BINDIR)/$(CONFIG)/filter_end2end_test \ $(BINDIR)/$(CONFIG)/generic_end2end_test \ + $(BINDIR)/$(CONFIG)/global_config_env_test \ + $(BINDIR)/$(CONFIG)/global_config_test \ $(BINDIR)/$(CONFIG)/golden_file_test \ $(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test \ $(BINDIR)/$(CONFIG)/grpc_cli \ @@ -2318,6 +2324,10 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/filter_end2end_test || ( echo test filter_end2end_test failed ; exit 1 ) $(E) "[RUN] Testing generic_end2end_test" $(Q) $(BINDIR)/$(CONFIG)/generic_end2end_test || ( echo test generic_end2end_test failed ; exit 1 ) + $(E) "[RUN] Testing global_config_env_test" + $(Q) $(BINDIR)/$(CONFIG)/global_config_env_test || ( echo test global_config_env_test failed ; exit 1 ) + $(E) "[RUN] Testing global_config_test" + $(Q) $(BINDIR)/$(CONFIG)/global_config_test || ( echo test global_config_test failed ; exit 1 ) $(E) "[RUN] Testing golden_file_test" $(Q) $(BINDIR)/$(CONFIG)/golden_file_test || ( echo test golden_file_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_alts_credentials_options_test" @@ -3354,6 +3364,7 @@ LIBGPR_SRC = \ src/core/lib/gpr/wrap_memcpy.cc \ src/core/lib/gprpp/arena.cc \ src/core/lib/gprpp/fork.cc \ + src/core/lib/gprpp/global_config_env.cc \ src/core/lib/gprpp/thd_posix.cc \ src/core/lib/gprpp/thd_windows.cc \ src/core/lib/profiling/basic_timers.cc \ @@ -16390,6 +16401,92 @@ endif endif +GLOBAL_CONFIG_ENV_TEST_SRC = \ + test/core/gprpp/global_config_env_test.cc \ + +GLOBAL_CONFIG_ENV_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GLOBAL_CONFIG_ENV_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/global_config_env_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/global_config_env_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/global_config_env_test: $(PROTOBUF_DEP) $(GLOBAL_CONFIG_ENV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(GLOBAL_CONFIG_ENV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/global_config_env_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/core/gprpp/global_config_env_test.o: $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a + +deps_global_config_env_test: $(GLOBAL_CONFIG_ENV_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(GLOBAL_CONFIG_ENV_TEST_OBJS:.o=.dep) +endif +endif + + +GLOBAL_CONFIG_TEST_SRC = \ + test/core/gprpp/global_config_test.cc \ + +GLOBAL_CONFIG_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GLOBAL_CONFIG_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/global_config_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/global_config_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/global_config_test: $(PROTOBUF_DEP) $(GLOBAL_CONFIG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(GLOBAL_CONFIG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/global_config_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/core/gprpp/global_config_test.o: $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a + +deps_global_config_test: $(GLOBAL_CONFIG_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(GLOBAL_CONFIG_TEST_OBJS:.o=.dep) +endif +endif + + GOLDEN_FILE_TEST_SRC = \ $(GENDIR)/src/proto/grpc/testing/compiler_test.pb.cc $(GENDIR)/src/proto/grpc/testing/compiler_test.grpc.pb.cc \ test/cpp/codegen/golden_file_test.cc \ diff --git a/build.yaml b/build.yaml index 848bf4ba072..f333d982961 100644 --- a/build.yaml +++ b/build.yaml @@ -148,6 +148,7 @@ filegroups: - src/core/lib/gpr/wrap_memcpy.cc - src/core/lib/gprpp/arena.cc - src/core/lib/gprpp/fork.cc + - src/core/lib/gprpp/global_config_env.cc - src/core/lib/gprpp/thd_posix.cc - src/core/lib/gprpp/thd_windows.cc - src/core/lib/profiling/basic_timers.cc @@ -194,6 +195,10 @@ filegroups: - src/core/lib/gprpp/arena.h - src/core/lib/gprpp/atomic.h - src/core/lib/gprpp/fork.h + - src/core/lib/gprpp/global_config.h + - src/core/lib/gprpp/global_config_custom.h + - src/core/lib/gprpp/global_config_env.h + - src/core/lib/gprpp/global_config_generic.h - src/core/lib/gprpp/manual_constructor.h - src/core/lib/gprpp/map.h - src/core/lib/gprpp/memory.h @@ -4722,6 +4727,24 @@ targets: - grpc++ - grpc - gpr +- name: global_config_env_test + build: test + language: c++ + src: + - test/core/gprpp/global_config_env_test.cc + deps: + - gpr + - grpc_test_util_unsecure + uses_polling: false +- name: global_config_test + build: test + language: c++ + src: + - test/core/gprpp/global_config_test.cc + deps: + - gpr + - grpc_test_util_unsecure + uses_polling: false - name: golden_file_test gtest: true build: test diff --git a/config.m4 b/config.m4 index 205d425868e..4616922a38b 100644 --- a/config.m4 +++ b/config.m4 @@ -79,6 +79,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/gpr/wrap_memcpy.cc \ src/core/lib/gprpp/arena.cc \ src/core/lib/gprpp/fork.cc \ + src/core/lib/gprpp/global_config_env.cc \ src/core/lib/gprpp/thd_posix.cc \ src/core/lib/gprpp/thd_windows.cc \ src/core/lib/profiling/basic_timers.cc \ diff --git a/config.w32 b/config.w32 index 3b0fcdd202e..63048c73492 100644 --- a/config.w32 +++ b/config.w32 @@ -54,6 +54,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\gpr\\wrap_memcpy.cc " + "src\\core\\lib\\gprpp\\arena.cc " + "src\\core\\lib\\gprpp\\fork.cc " + + "src\\core\\lib\\gprpp\\global_config_env.cc " + "src\\core\\lib\\gprpp\\thd_posix.cc " + "src\\core\\lib\\gprpp\\thd_windows.cc " + "src\\core\\lib\\profiling\\basic_timers.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 3ecdcfe82a4..1809171006f 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -267,6 +267,10 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/arena.h', 'src/core/lib/gprpp/atomic.h', 'src/core/lib/gprpp/fork.h', + 'src/core/lib/gprpp/global_config.h', + 'src/core/lib/gprpp/global_config_custom.h', + 'src/core/lib/gprpp/global_config_env.h', + 'src/core/lib/gprpp/global_config_generic.h', 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', @@ -589,6 +593,10 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/arena.h', 'src/core/lib/gprpp/atomic.h', 'src/core/lib/gprpp/fork.h', + 'src/core/lib/gprpp/global_config.h', + 'src/core/lib/gprpp/global_config_custom.h', + 'src/core/lib/gprpp/global_config_env.h', + 'src/core/lib/gprpp/global_config_generic.h', 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index b5ff2c622d0..ec8661b4d19 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -208,6 +208,10 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/arena.h', 'src/core/lib/gprpp/atomic.h', 'src/core/lib/gprpp/fork.h', + 'src/core/lib/gprpp/global_config.h', + 'src/core/lib/gprpp/global_config_custom.h', + 'src/core/lib/gprpp/global_config_env.h', + 'src/core/lib/gprpp/global_config_generic.h', 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', @@ -250,6 +254,7 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/wrap_memcpy.cc', 'src/core/lib/gprpp/arena.cc', 'src/core/lib/gprpp/fork.cc', + 'src/core/lib/gprpp/global_config_env.cc', 'src/core/lib/gprpp/thd_posix.cc', 'src/core/lib/gprpp/thd_windows.cc', 'src/core/lib/profiling/basic_timers.cc', @@ -890,6 +895,10 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/arena.h', 'src/core/lib/gprpp/atomic.h', 'src/core/lib/gprpp/fork.h', + 'src/core/lib/gprpp/global_config.h', + 'src/core/lib/gprpp/global_config_custom.h', + 'src/core/lib/gprpp/global_config_env.h', + 'src/core/lib/gprpp/global_config_generic.h', 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', diff --git a/grpc.gemspec b/grpc.gemspec index 943e0aaa1a7..59296e8e251 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -102,6 +102,10 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gprpp/arena.h ) s.files += %w( src/core/lib/gprpp/atomic.h ) s.files += %w( src/core/lib/gprpp/fork.h ) + s.files += %w( src/core/lib/gprpp/global_config.h ) + s.files += %w( src/core/lib/gprpp/global_config_custom.h ) + s.files += %w( src/core/lib/gprpp/global_config_env.h ) + s.files += %w( src/core/lib/gprpp/global_config_generic.h ) s.files += %w( src/core/lib/gprpp/manual_constructor.h ) s.files += %w( src/core/lib/gprpp/map.h ) s.files += %w( src/core/lib/gprpp/memory.h ) @@ -144,6 +148,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/wrap_memcpy.cc ) s.files += %w( src/core/lib/gprpp/arena.cc ) s.files += %w( src/core/lib/gprpp/fork.cc ) + s.files += %w( src/core/lib/gprpp/global_config_env.cc ) s.files += %w( src/core/lib/gprpp/thd_posix.cc ) s.files += %w( src/core/lib/gprpp/thd_windows.cc ) s.files += %w( src/core/lib/profiling/basic_timers.cc ) diff --git a/grpc.gyp b/grpc.gyp index 5321658508a..14d98d003a6 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -252,6 +252,7 @@ 'src/core/lib/gpr/wrap_memcpy.cc', 'src/core/lib/gprpp/arena.cc', 'src/core/lib/gprpp/fork.cc', + 'src/core/lib/gprpp/global_config_env.cc', 'src/core/lib/gprpp/thd_posix.cc', 'src/core/lib/gprpp/thd_windows.cc', 'src/core/lib/profiling/basic_timers.cc', diff --git a/package.xml b/package.xml index c3e25173349..52b954e20c6 100644 --- a/package.xml +++ b/package.xml @@ -107,6 +107,10 @@ + + + + @@ -149,6 +153,7 @@ + diff --git a/src/core/ext/filters/client_channel/backup_poller.cc b/src/core/ext/filters/client_channel/backup_poller.cc index 3e2faa57bcf..a2d45c04026 100644 --- a/src/core/ext/filters/client_channel/backup_poller.cc +++ b/src/core/ext/filters/client_channel/backup_poller.cc @@ -25,8 +25,8 @@ #include #include #include "src/core/ext/filters/client_channel/client_channel.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/iomgr/timer.h" @@ -56,21 +56,22 @@ static backup_poller* g_poller = nullptr; // guarded by g_poller_mu // treated as const. static int g_poll_interval_ms = DEFAULT_POLL_INTERVAL_MS; +GPR_GLOBAL_CONFIG_DEFINE_INT32(grpc_client_channel_backup_poll_interval_ms, + DEFAULT_POLL_INTERVAL_MS, + "Client channel backup poll interval (ms)"); + static void init_globals() { gpr_mu_init(&g_poller_mu); - char* env = gpr_getenv("GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS"); - if (env != nullptr) { - int poll_interval_ms = gpr_parse_nonnegative_int(env); - if (poll_interval_ms == -1) { - gpr_log(GPR_ERROR, - "Invalid GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS: %s, " - "default value %d will be used.", - env, g_poll_interval_ms); - } else { - g_poll_interval_ms = poll_interval_ms; - } + int32_t poll_interval_ms = + GPR_GLOBAL_CONFIG_GET(grpc_client_channel_backup_poll_interval_ms); + if (poll_interval_ms < 0) { + gpr_log(GPR_ERROR, + "Invalid GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS: %d, " + "default value %d will be used.", + poll_interval_ms, g_poll_interval_ms); + } else { + g_poll_interval_ms = poll_interval_ms; } - gpr_free(env); } static void backup_poller_shutdown_unref(backup_poller* p) { diff --git a/src/core/ext/filters/client_channel/backup_poller.h b/src/core/ext/filters/client_channel/backup_poller.h index 8f132f968ce..e1bf4f88b2a 100644 --- a/src/core/ext/filters/client_channel/backup_poller.h +++ b/src/core/ext/filters/client_channel/backup_poller.h @@ -23,6 +23,9 @@ #include #include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/gprpp/global_config.h" + +GPR_GLOBAL_CONFIG_DECLARE_INT32(grpc_client_channel_backup_poll_interval_ms); /* Start polling \a interested_parties periodically in the timer thread */ void grpc_client_channel_start_backup_polling( diff --git a/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc b/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc index 531ea73e9e6..4c929d00ec9 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc @@ -20,16 +20,15 @@ #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/debug/trace.h" -#include "src/core/lib/gpr/env.h" +#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/transport/metadata.h" +GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_experimental_disable_flow_control, false, + "Disable flow control"); + void grpc_chttp2_plugin_init(void) { - g_flow_control_enabled = true; - char* env_variable = gpr_getenv("GRPC_EXPERIMENTAL_DISABLE_FLOW_CONTROL"); - if (env_variable != nullptr) { - g_flow_control_enabled = false; - gpr_free(env_variable); - } + g_flow_control_enabled = + !GPR_GLOBAL_CONFIG_GET(grpc_experimental_disable_flow_control); } void grpc_chttp2_plugin_shutdown(void) {} diff --git a/src/core/lib/gpr/env.h b/src/core/lib/gpr/env.h index aec8a3166b1..5956d17fcfe 100644 --- a/src/core/lib/gpr/env.h +++ b/src/core/lib/gpr/env.h @@ -40,4 +40,7 @@ void gpr_setenv(const char* name, const char* value); level of logging. So DO NOT USE THIS. */ const char* gpr_getenv_silent(const char* name, char** dst); +/* Deletes the variable name from the environment. */ +void gpr_unsetenv(const char* name); + #endif /* GRPC_CORE_LIB_GPR_ENV_H */ diff --git a/src/core/lib/gpr/env_linux.cc b/src/core/lib/gpr/env_linux.cc index fadc42f22f1..e84a9f6064c 100644 --- a/src/core/lib/gpr/env_linux.cc +++ b/src/core/lib/gpr/env_linux.cc @@ -79,4 +79,9 @@ void gpr_setenv(const char* name, const char* value) { GPR_ASSERT(res == 0); } +void gpr_unsetenv(const char* name) { + int res = unsetenv(name); + GPR_ASSERT(res == 0); +} + #endif /* GPR_LINUX_ENV */ diff --git a/src/core/lib/gpr/env_posix.cc b/src/core/lib/gpr/env_posix.cc index 599f85aa72b..30ddc50f682 100644 --- a/src/core/lib/gpr/env_posix.cc +++ b/src/core/lib/gpr/env_posix.cc @@ -44,4 +44,9 @@ void gpr_setenv(const char* name, const char* value) { GPR_ASSERT(res == 0); } +void gpr_unsetenv(const char* name) { + int res = unsetenv(name); + GPR_ASSERT(res == 0); +} + #endif /* GPR_POSIX_ENV */ diff --git a/src/core/lib/gpr/env_windows.cc b/src/core/lib/gpr/env_windows.cc index cf8ed60d8f6..72850a9587d 100644 --- a/src/core/lib/gpr/env_windows.cc +++ b/src/core/lib/gpr/env_windows.cc @@ -69,4 +69,11 @@ void gpr_setenv(const char* name, const char* value) { GPR_ASSERT(res); } +void gpr_unsetenv(const char* name) { + LPTSTR tname = gpr_char_to_tchar(name); + BOOL res = SetEnvironmentVariable(tname, NULL); + gpr_free(tname); + GPR_ASSERT(res); +} + #endif /* GPR_WINDOWS_ENV */ diff --git a/src/core/lib/gpr/string.cc b/src/core/lib/gpr/string.cc index 0a76fc1f54a..31d5fdee5be 100644 --- a/src/core/lib/gpr/string.cc +++ b/src/core/lib/gpr/string.cc @@ -332,16 +332,22 @@ void* gpr_memrchr(const void* s, int c, size_t n) { return nullptr; } -bool gpr_is_true(const char* s) { - size_t i; +bool gpr_parse_bool_value(const char* s, bool* dst) { + const char* kTrue[] = {"1", "t", "true", "y", "yes"}; + const char* kFalse[] = {"0", "f", "false", "n", "no"}; + static_assert(sizeof(kTrue) == sizeof(kFalse), "true_false_equal"); + if (s == nullptr) { return false; } - static const char* truthy[] = {"yes", "true", "1"}; - for (i = 0; i < GPR_ARRAY_SIZE(truthy); i++) { - if (0 == gpr_stricmp(s, truthy[i])) { + for (size_t i = 0; i < GPR_ARRAY_SIZE(kTrue); ++i) { + if (gpr_stricmp(s, kTrue[i]) == 0) { + *dst = true; + return true; + } else if (gpr_stricmp(s, kFalse[i]) == 0) { + *dst = false; return true; } } - return false; + return false; // didn't match a legal input } diff --git a/src/core/lib/gpr/string.h b/src/core/lib/gpr/string.h index ce51fe46321..c5efcec3bb1 100644 --- a/src/core/lib/gpr/string.h +++ b/src/core/lib/gpr/string.h @@ -113,7 +113,9 @@ int gpr_stricmp(const char* a, const char* b); void* gpr_memrchr(const void* s, int c, size_t n); -/** Return true if lower(s) equals "true", "yes" or "1", otherwise false. */ -bool gpr_is_true(const char* s); +/* Try to parse given string into a boolean value. + When parsed successfully, dst will have the value and returns true. + Otherwise, it returns false. */ +bool gpr_parse_bool_value(const char* value, bool* dst); #endif /* GRPC_CORE_LIB_GPR_STRING_H */ diff --git a/src/core/lib/gprpp/global_config.h b/src/core/lib/gprpp/global_config.h new file mode 100644 index 00000000000..a1bbf07564c --- /dev/null +++ b/src/core/lib/gprpp/global_config.h @@ -0,0 +1,87 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_GPRPP_GLOBAL_CONFIG_H +#define GRPC_CORE_LIB_GPRPP_GLOBAL_CONFIG_H + +#include + +#include + +// -------------------------------------------------------------------- +// How to use global configuration variables: +// +// Defining config variables of a specified type: +// GPR_GLOBAL_CONFIG_DEFINE_*TYPE*(name, default_value, help); +// +// Supported TYPEs: BOOL, INT32, STRING +// +// It's recommended to use lowercase letters for 'name' like +// regular variables. The builtin configuration system uses +// environment variable and the name is converted to uppercase +// when looking up the value. For example, +// GPR_GLOBAL_CONFIG_DEFINE(grpc_latency) looks up the value with the +// name, "GRPC_LATENCY". +// +// The variable initially has the specified 'default_value' +// which must be an expression convertible to 'Type'. +// 'default_value' may be evaluated 0 or more times, +// and at an unspecified time; keep it +// simple and usually free of side-effects. +// +// GPR_GLOBAL_CONFIG_DEFINE_*TYPE* should not be called in a C++ header. +// It should be called at the top-level (outside any namespaces) +// in a .cc file. +// +// Getting the variables: +// GPR_GLOBAL_CONFIG_GET(name) +// +// If error happens during getting variables, error messages will +// be logged and default value will be returned. +// +// Setting the variables with new value: +// GPR_GLOBAL_CONFIG_SET(name, new_value) +// +// Declaring config variables for other modules to access: +// GPR_GLOBAL_CONFIG_DECLARE_*TYPE*(name) + +// -------------------------------------------------------------------- +// How to customize the global configuration system: +// +// How to read and write configuration value can be customized. +// Builtin system uses environment variables but it can be extended to +// support command-line flag, file, etc. +// +// To customize it, following macros should be redefined. +// +// GPR_GLOBAL_CONFIG_DEFINE_BOOL +// GPR_GLOBAL_CONFIG_DEFINE_INT32 +// GPR_GLOBAL_CONFIG_DEFINE_STRING +// +// These macros should define functions for getting and setting variable. +// For example, GPR_GLOBAL_CONFIG_DEFINE_BOOL(test, ...) would define two +// functions. +// +// bool gpr_global_config_get_test(); +// void gpr_global_config_set_test(bool value); + +#include "src/core/lib/gprpp/global_config_env.h" + +#include "src/core/lib/gprpp/global_config_custom.h" + +#endif /* GRPC_CORE_LIB_GPRPP_GLOBAL_CONFIG_H */ diff --git a/src/core/lib/gprpp/global_config_custom.h b/src/core/lib/gprpp/global_config_custom.h new file mode 100644 index 00000000000..dd011fb34bf --- /dev/null +++ b/src/core/lib/gprpp/global_config_custom.h @@ -0,0 +1,29 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_GPRPP_GLOBAL_CONFIG_CUSTOM_H +#define GRPC_CORE_LIB_GPRPP_GLOBAL_CONFIG_CUSTOM_H + +// This is a placeholder for custom global configuration implementaion. +// To use the custom one, please define following macros here. +// +// GPR_GLOBAL_CONFIG_DEFINE_BOOL +// GPR_GLOBAL_CONFIG_DEFINE_INT32 +// GPR_GLOBAL_CONFIG_DEFINE_STRING + +#endif /* GRPC_CORE_LIB_GPRPP_GLOBAL_CONFIG_CUSTOM_H */ diff --git a/src/core/lib/gprpp/global_config_env.cc b/src/core/lib/gprpp/global_config_env.cc new file mode 100644 index 00000000000..fb14805d01b --- /dev/null +++ b/src/core/lib/gprpp/global_config_env.cc @@ -0,0 +1,135 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/gprpp/global_config_env.h" + +#include +#include +#include + +#include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/string.h" + +#include +#include + +namespace grpc_core { + +namespace { + +void DefaultGlobalConfigEnvErrorFunction(const char* error_message) { + gpr_log(GPR_ERROR, "%s", error_message); +} + +GlobalConfigEnvErrorFunctionType g_global_config_env_error_func = + DefaultGlobalConfigEnvErrorFunction; + +void LogParsingError(const char* name, const char* value) { + char* error_message; + gpr_asprintf(&error_message, + "Illegal value '%s' specified for environment variable '%s'", + value, name); + (*g_global_config_env_error_func)(error_message); + gpr_free(error_message); +} + +} // namespace + +void SetGlobalConfigEnvErrorFunction(GlobalConfigEnvErrorFunctionType func) { + g_global_config_env_error_func = func; +} + +UniquePtr GlobalConfigEnv::GetValue() { + return UniquePtr(gpr_getenv(GetName())); +} + +void GlobalConfigEnv::SetValue(const char* value) { + gpr_setenv(GetName(), value); +} + +void GlobalConfigEnv::Unset() { gpr_unsetenv(GetName()); } + +char* GlobalConfigEnv::GetName() { + // This makes sure that name_ is in a canonical form having uppercase + // letters. This is okay to be called serveral times. + for (char* c = name_; *c != 0; ++c) { + *c = toupper(*c); + } + return name_; +} +static_assert(std::is_trivially_destructible::value, + "GlobalConfigEnvBool needs to be trivially destructible."); + +bool GlobalConfigEnvBool::Get() { + UniquePtr str = GetValue(); + if (str == nullptr) { + return default_value_; + } + // parsing given value string. + bool result = false; + if (!gpr_parse_bool_value(str.get(), &result)) { + LogParsingError(GetName(), str.get()); + result = default_value_; + } + return result; +} + +void GlobalConfigEnvBool::Set(bool value) { + SetValue(value ? "true" : "false"); +} + +static_assert(std::is_trivially_destructible::value, + "GlobalConfigEnvInt32 needs to be trivially destructible."); + +int32_t GlobalConfigEnvInt32::Get() { + UniquePtr str = GetValue(); + if (str == nullptr) { + return default_value_; + } + // parsing given value string. + char* end = str.get(); + long result = strtol(str.get(), &end, 10); + if (*end != 0) { + LogParsingError(GetName(), str.get()); + result = default_value_; + } + return static_cast(result); +} + +void GlobalConfigEnvInt32::Set(int32_t value) { + char buffer[GPR_LTOA_MIN_BUFSIZE]; + gpr_ltoa(value, buffer); + SetValue(buffer); +} + +static_assert(std::is_trivially_destructible::value, + "GlobalConfigEnvString needs to be trivially destructible."); + +UniquePtr GlobalConfigEnvString::Get() { + UniquePtr str = GetValue(); + if (str == nullptr) { + return UniquePtr(gpr_strdup(default_value_)); + } + return str; +} + +void GlobalConfigEnvString::Set(const char* value) { SetValue(value); } + +} // namespace grpc_core diff --git a/src/core/lib/gprpp/global_config_env.h b/src/core/lib/gprpp/global_config_env.h new file mode 100644 index 00000000000..3d3038895d3 --- /dev/null +++ b/src/core/lib/gprpp/global_config_env.h @@ -0,0 +1,131 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_GPRPP_GLOBAL_CONFIG_ENV_H +#define GRPC_CORE_LIB_GPRPP_GLOBAL_CONFIG_ENV_H + +#include + +#include "src/core/lib/gprpp/global_config_generic.h" +#include "src/core/lib/gprpp/memory.h" + +namespace grpc_core { + +typedef void (*GlobalConfigEnvErrorFunctionType)(const char* error_message); + +/* + * Set global_config_env_error_function which is called when config system + * encounters errors such as parsing error. What the default function does + * is logging error message. + */ +void SetGlobalConfigEnvErrorFunction(GlobalConfigEnvErrorFunctionType func); + +// Base class for all classes to access environment variables. +class GlobalConfigEnv { + protected: + // `name` should be writable and alive after constructor is called. + constexpr explicit GlobalConfigEnv(char* name) : name_(name) {} + + public: + // Returns the value of `name` variable. + UniquePtr GetValue(); + + // Sets the value of `name` variable. + void SetValue(const char* value); + + // Unsets `name` variable. + void Unset(); + + protected: + char* GetName(); + + private: + char* name_; +}; + +class GlobalConfigEnvBool : public GlobalConfigEnv { + public: + constexpr GlobalConfigEnvBool(char* name, bool default_value) + : GlobalConfigEnv(name), default_value_(default_value) {} + + bool Get(); + void Set(bool value); + + private: + bool default_value_; +}; + +class GlobalConfigEnvInt32 : public GlobalConfigEnv { + public: + constexpr GlobalConfigEnvInt32(char* name, int32_t default_value) + : GlobalConfigEnv(name), default_value_(default_value) {} + + int32_t Get(); + void Set(int32_t value); + + private: + int32_t default_value_; +}; + +class GlobalConfigEnvString : public GlobalConfigEnv { + public: + constexpr GlobalConfigEnvString(char* name, const char* default_value) + : GlobalConfigEnv(name), default_value_(default_value) {} + + UniquePtr Get(); + void Set(const char* value); + + private: + const char* default_value_; +}; + +} // namespace grpc_core + +// Macros for defining global config instances using environment variables. +// This defines a GlobalConfig*Type* instance with arguments for +// mutable variable name and default value. +// Mutable name (g_env_str_##name) is here for having an array +// for the canonical name without dynamic allocation. +// `help` argument is ignored for this implementation. + +#define GPR_GLOBAL_CONFIG_DEFINE_BOOL(name, default_value, help) \ + static char g_env_str_##name[] = #name; \ + static ::grpc_core::GlobalConfigEnvBool g_env_##name(g_env_str_##name, \ + default_value); \ + bool gpr_global_config_get_##name() { return g_env_##name.Get(); } \ + void gpr_global_config_set_##name(bool value) { g_env_##name.Set(value); } + +#define GPR_GLOBAL_CONFIG_DEFINE_INT32(name, default_value, help) \ + static char g_env_str_##name[] = #name; \ + static ::grpc_core::GlobalConfigEnvInt32 g_env_##name(g_env_str_##name, \ + default_value); \ + int32_t gpr_global_config_get_##name() { return g_env_##name.Get(); } \ + void gpr_global_config_set_##name(int32_t value) { g_env_##name.Set(value); } + +#define GPR_GLOBAL_CONFIG_DEFINE_STRING(name, default_value, help) \ + static char g_env_str_##name[] = #name; \ + static ::grpc_core::GlobalConfigEnvString g_env_##name(g_env_str_##name, \ + default_value); \ + ::grpc_core::UniquePtr gpr_global_config_get_##name() { \ + return g_env_##name.Get(); \ + } \ + void gpr_global_config_set_##name(const char* value) { \ + g_env_##name.Set(value); \ + } + +#endif /* GRPC_CORE_LIB_GPRPP_GLOBAL_CONFIG_ENV_H */ diff --git a/src/core/lib/gprpp/global_config_generic.h b/src/core/lib/gprpp/global_config_generic.h new file mode 100644 index 00000000000..d3e3e2a2dbe --- /dev/null +++ b/src/core/lib/gprpp/global_config_generic.h @@ -0,0 +1,44 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_GPRPP_GLOBAL_CONFIG_GENERIC_H +#define GRPC_CORE_LIB_GPRPP_GLOBAL_CONFIG_GENERIC_H + +#include + +#include "src/core/lib/gprpp/memory.h" + +#include + +#define GPR_GLOBAL_CONFIG_GET(name) gpr_global_config_get_##name() + +#define GPR_GLOBAL_CONFIG_SET(name, value) gpr_global_config_set_##name(value) + +#define GPR_GLOBAL_CONFIG_DECLARE_BOOL(name) \ + extern bool gpr_global_config_get_##name(); \ + extern void gpr_global_config_set_##name(bool value) + +#define GPR_GLOBAL_CONFIG_DECLARE_INT32(name) \ + extern int32_t gpr_global_config_get_##name(); \ + extern void gpr_global_config_set_##name(int32_t value) + +#define GPR_GLOBAL_CONFIG_DECLARE_STRING(name) \ + extern grpc_core::UniquePtr gpr_global_config_get_##name(); \ + extern void gpr_global_config_set_##name(const char* value) + +#endif /* GRPC_CORE_LIB_GPRPP_GLOBAL_CONFIG_GENERIC_H */ diff --git a/src/core/lib/iomgr/iomgr.cc b/src/core/lib/iomgr/iomgr.cc index 0fbfcfce04f..fd011788a06 100644 --- a/src/core/lib/iomgr/iomgr.cc +++ b/src/core/lib/iomgr/iomgr.cc @@ -29,9 +29,9 @@ #include #include -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/buffer_list.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -41,6 +41,9 @@ #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/iomgr/timer_manager.h" +GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_abort_on_leaks, false, + "Abort when leak is found"); + static gpr_mu g_mu; static gpr_cv g_rcv; static int g_shutdown; @@ -186,8 +189,5 @@ void grpc_iomgr_unregister_object(grpc_iomgr_object* obj) { } bool grpc_iomgr_abort_on_leaks(void) { - char* env = gpr_getenv("GRPC_ABORT_ON_LEAKS"); - bool should_we = gpr_is_true(env); - gpr_free(env); - return should_we; + return GPR_GLOBAL_CONFIG_GET(grpc_abort_on_leaks); } diff --git a/src/core/lib/security/security_connector/ssl_utils.cc b/src/core/lib/security/security_connector/ssl_utils.cc index c9af5ca6ad0..1eefff6fe24 100644 --- a/src/core/lib/security/security_connector/ssl_utils.cc +++ b/src/core/lib/security/security_connector/ssl_utils.cc @@ -30,6 +30,7 @@ #include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/context/security_context.h" @@ -47,9 +48,8 @@ static const char* installed_roots_path = /** Environment variable used as a flag to enable/disable loading system root certificates from the OS trust store. */ -#ifndef GRPC_NOT_USE_SYSTEM_SSL_ROOTS_ENV_VAR -#define GRPC_NOT_USE_SYSTEM_SSL_ROOTS_ENV_VAR "GRPC_NOT_USE_SYSTEM_SSL_ROOTS" -#endif +GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_not_use_system_ssl_roots, false, + "Disable loading system root certificates."); #ifndef TSI_OPENSSL_ALPN_SUPPORT #define TSI_OPENSSL_ALPN_SUPPORT 1 @@ -428,10 +428,8 @@ const char* DefaultSslRootStore::GetPemRootCerts() { grpc_slice DefaultSslRootStore::ComputePemRootCerts() { grpc_slice result = grpc_empty_slice(); - char* not_use_system_roots_env_value = - gpr_getenv(GRPC_NOT_USE_SYSTEM_SSL_ROOTS_ENV_VAR); - const bool not_use_system_roots = gpr_is_true(not_use_system_roots_env_value); - gpr_free(not_use_system_roots_env_value); + const bool not_use_system_roots = + GPR_GLOBAL_CONFIG_GET(grpc_not_use_system_ssl_roots); // First try to load the roots from the environment. char* default_root_certs_path = gpr_getenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR); diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 2e358f9c1ef..615bf4ee0dc 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -53,6 +53,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/gpr/wrap_memcpy.cc', 'src/core/lib/gprpp/arena.cc', 'src/core/lib/gprpp/fork.cc', + 'src/core/lib/gprpp/global_config_env.cc', 'src/core/lib/gprpp/thd_posix.cc', 'src/core/lib/gprpp/thd_windows.cc', 'src/core/lib/profiling/basic_timers.cc', diff --git a/test/core/gpr/env_test.cc b/test/core/gpr/env_test.cc index a8206bd3cfd..3883a5df997 100644 --- a/test/core/gpr/env_test.cc +++ b/test/core/gpr/env_test.cc @@ -42,8 +42,22 @@ static void test_setenv_getenv(void) { gpr_free(retrieved_value); } +static void test_unsetenv(void) { + const char* name = "FOO"; + const char* value = "BAR"; + char* retrieved_value; + + LOG_TEST_NAME("test_unsetenv"); + + gpr_setenv(name, value); + gpr_unsetenv(name); + retrieved_value = gpr_getenv(name); + GPR_ASSERT(retrieved_value == nullptr); +} + int main(int argc, char** argv) { grpc::testing::TestEnvironment env(argc, argv); test_setenv_getenv(); + test_unsetenv(); return 0; } diff --git a/test/core/gpr/string_test.cc b/test/core/gpr/string_test.cc index 7da7b18778b..5e3ed9d5dfd 100644 --- a/test/core/gpr/string_test.cc +++ b/test/core/gpr/string_test.cc @@ -279,19 +279,20 @@ static void test_memrchr(void) { GPR_ASSERT(0 == strcmp((const char*)gpr_memrchr("hello", 'l', 5), "lo")); } -static void test_is_true(void) { - LOG_TEST_NAME("test_is_true"); +static void test_parse_bool_value(void) { + LOG_TEST_NAME("test_parse_bool_value"); - GPR_ASSERT(true == gpr_is_true("True")); - GPR_ASSERT(true == gpr_is_true("true")); - GPR_ASSERT(true == gpr_is_true("TRUE")); - GPR_ASSERT(true == gpr_is_true("Yes")); - GPR_ASSERT(true == gpr_is_true("yes")); - GPR_ASSERT(true == gpr_is_true("YES")); - GPR_ASSERT(true == gpr_is_true("1")); - GPR_ASSERT(false == gpr_is_true(nullptr)); - GPR_ASSERT(false == gpr_is_true("")); - GPR_ASSERT(false == gpr_is_true("0")); + bool ret; + GPR_ASSERT(true == gpr_parse_bool_value("truE", &ret) && true == ret); + GPR_ASSERT(true == gpr_parse_bool_value("falsE", &ret) && false == ret); + GPR_ASSERT(true == gpr_parse_bool_value("1", &ret) && true == ret); + GPR_ASSERT(true == gpr_parse_bool_value("0", &ret) && false == ret); + GPR_ASSERT(true == gpr_parse_bool_value("Yes", &ret) && true == ret); + GPR_ASSERT(true == gpr_parse_bool_value("No", &ret) && false == ret); + GPR_ASSERT(true == gpr_parse_bool_value("Y", &ret) && true == ret); + GPR_ASSERT(true == gpr_parse_bool_value("N", &ret) && false == ret); + GPR_ASSERT(false == gpr_parse_bool_value(nullptr, &ret)); + GPR_ASSERT(false == gpr_parse_bool_value("", &ret)); } int main(int argc, char** argv) { @@ -307,6 +308,6 @@ int main(int argc, char** argv) { test_leftpad(); test_stricmp(); test_memrchr(); - test_is_true(); + test_parse_bool_value(); return 0; } diff --git a/test/core/gprpp/BUILD b/test/core/gprpp/BUILD index 4665827e10f..cd3232addfd 100644 --- a/test/core/gprpp/BUILD +++ b/test/core/gprpp/BUILD @@ -28,6 +28,32 @@ grpc_cc_test( ], ) +grpc_cc_test( + name = "global_config_test", + srcs = ["global_config_test.cc"], + external_deps = [ + "gtest", + ], + language = "C++", + deps = [ + "//:gpr", + "//test/core/util:grpc_test_util", + ], +) + +grpc_cc_test( + name = "global_config_env_test", + srcs = ["global_config_env_test.cc"], + external_deps = [ + "gtest", + ], + language = "C++", + deps = [ + "//:gpr", + "//test/core/util:grpc_test_util", + ], +) + grpc_cc_test( name = "manual_constructor_test", srcs = ["manual_constructor_test.cc"], diff --git a/test/core/gprpp/global_config_env_test.cc b/test/core/gprpp/global_config_env_test.cc new file mode 100644 index 00000000000..74905d3b07c --- /dev/null +++ b/test/core/gprpp/global_config_env_test.cc @@ -0,0 +1,130 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +#include + +#include +#include + +#include "src/core/lib/gpr/env.h" +#include "src/core/lib/gprpp/global_config_env.h" +#include "src/core/lib/gprpp/memory.h" + +namespace { + +bool g_config_error_function_called; + +void ClearConfigErrorCalled() { g_config_error_function_called = false; } + +bool IsConfigErrorCalled() { return g_config_error_function_called; } + +// This function is for preventing the program from invoking +// an error handler due to configuration error and +// make test routines know whether there is error. +void FakeConfigErrorFunction(const char* error_message) { + g_config_error_function_called = true; +} + +class GlobalConfigEnvTest : public ::testing::Test { + protected: + void SetUp() override { ClearConfigErrorCalled(); } + void TearDown() override { EXPECT_FALSE(IsConfigErrorCalled()); } +}; + +} // namespace + +GPR_GLOBAL_CONFIG_DEFINE_BOOL(bool_var, true, ""); +GPR_GLOBAL_CONFIG_DEFINE_INT32(int32_var, 1234, ""); +GPR_GLOBAL_CONFIG_DEFINE_STRING(string_var, "Apple", ""); + +TEST_F(GlobalConfigEnvTest, BoolWithEnvTest) { + const char* bool_var_name = "BOOL_VAR"; + + gpr_unsetenv(bool_var_name); + EXPECT_TRUE(GPR_GLOBAL_CONFIG_GET(bool_var)); + + gpr_setenv(bool_var_name, "true"); + EXPECT_TRUE(GPR_GLOBAL_CONFIG_GET(bool_var)); + + gpr_setenv(bool_var_name, "false"); + EXPECT_FALSE(GPR_GLOBAL_CONFIG_GET(bool_var)); + + EXPECT_FALSE(IsConfigErrorCalled()); + + gpr_setenv(bool_var_name, ""); + GPR_GLOBAL_CONFIG_GET(bool_var); + EXPECT_TRUE(IsConfigErrorCalled()); + ClearConfigErrorCalled(); + + gpr_setenv(bool_var_name, "!"); + GPR_GLOBAL_CONFIG_GET(bool_var); + EXPECT_TRUE(IsConfigErrorCalled()); + ClearConfigErrorCalled(); +} + +TEST_F(GlobalConfigEnvTest, Int32WithEnvTest) { + const char* int32_var_name = "INT32_VAR"; + + gpr_unsetenv(int32_var_name); + EXPECT_EQ(1234, GPR_GLOBAL_CONFIG_GET(int32_var)); + + gpr_setenv(int32_var_name, "0"); + EXPECT_EQ(0, GPR_GLOBAL_CONFIG_GET(int32_var)); + + gpr_setenv(int32_var_name, "-123456789"); + EXPECT_EQ(-123456789, GPR_GLOBAL_CONFIG_GET(int32_var)); + + gpr_setenv(int32_var_name, "123456789"); + EXPECT_EQ(123456789, GPR_GLOBAL_CONFIG_GET(int32_var)); + + EXPECT_FALSE(IsConfigErrorCalled()); + + gpr_setenv(int32_var_name, "-1AB"); + GPR_GLOBAL_CONFIG_GET(int32_var); + EXPECT_TRUE(IsConfigErrorCalled()); + ClearConfigErrorCalled(); +} + +TEST_F(GlobalConfigEnvTest, StringWithEnvTest) { + const char* string_var_name = "STRING_VAR"; + grpc_core::UniquePtr value; + + gpr_unsetenv(string_var_name); + value = GPR_GLOBAL_CONFIG_GET(string_var); + EXPECT_EQ(0, strcmp(value.get(), "Apple")); + + gpr_setenv(string_var_name, "Banana"); + value = GPR_GLOBAL_CONFIG_GET(string_var); + EXPECT_EQ(0, strcmp(value.get(), "Banana")); + + gpr_setenv(string_var_name, ""); + value = GPR_GLOBAL_CONFIG_GET(string_var); + EXPECT_EQ(0, strcmp(value.get(), "")); +} + +int main(int argc, char** argv) { + // Not to abort the test when parsing error happens. + grpc_core::SetGlobalConfigEnvErrorFunction(&FakeConfigErrorFunction); + + ::testing::InitGoogleTest(&argc, argv); + int ret = RUN_ALL_TESTS(); + return ret; +} diff --git a/test/core/gprpp/global_config_test.cc b/test/core/gprpp/global_config_test.cc new file mode 100644 index 00000000000..7da78b690b1 --- /dev/null +++ b/test/core/gprpp/global_config_test.cc @@ -0,0 +1,65 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +#include + +#include +#include + +#include "src/core/lib/gpr/env.h" +#include "src/core/lib/gprpp/global_config.h" +#include "src/core/lib/gprpp/memory.h" + +GPR_GLOBAL_CONFIG_DECLARE_BOOL(bool_var); + +GPR_GLOBAL_CONFIG_DEFINE_BOOL(bool_var, false, ""); +GPR_GLOBAL_CONFIG_DEFINE_INT32(int32_var, 0, ""); +GPR_GLOBAL_CONFIG_DEFINE_STRING(string_var, "", ""); + +TEST(GlobalConfigTest, BoolTest) { + EXPECT_FALSE(GPR_GLOBAL_CONFIG_GET(bool_var)); + GPR_GLOBAL_CONFIG_SET(bool_var, true); + EXPECT_TRUE(GPR_GLOBAL_CONFIG_GET(bool_var)); +} + +TEST(GlobalConfigTest, Int32Test) { + EXPECT_EQ(0, GPR_GLOBAL_CONFIG_GET(int32_var)); + GPR_GLOBAL_CONFIG_SET(int32_var, 1024); + EXPECT_EQ(1024, GPR_GLOBAL_CONFIG_GET(int32_var)); +} + +TEST(GlobalConfigTest, StringTest) { + grpc_core::UniquePtr value; + + value = GPR_GLOBAL_CONFIG_GET(string_var); + EXPECT_EQ(0, strcmp(value.get(), "")); + + GPR_GLOBAL_CONFIG_SET(string_var, "Test"); + + value = GPR_GLOBAL_CONFIG_GET(string_var); + EXPECT_EQ(0, strcmp(value.get(), "Test")); +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + int ret = RUN_ALL_TESTS(); + return ret; +} diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index e09f54dcc3f..840d668e0d8 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -32,6 +32,7 @@ #include #include +#include "src/core/ext/filters/client_channel/backup_poller.h" #include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/tls.h" #include "src/core/lib/iomgr/port.h" @@ -1883,7 +1884,7 @@ INSTANTIATE_TEST_CASE_P(AsyncEnd2endServerTryCancel, int main(int argc, char** argv) { // Change the backup poll interval from 5s to 100ms to speed up the // ReconnectChannel test - gpr_setenv("GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS", "100"); + GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 100); grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); int ret = RUN_ALL_TESTS(); diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index 6623a2ff55f..ca20ebbaeee 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -37,13 +37,13 @@ #include #include +#include "src/core/ext/filters/client_channel/backup_poller.h" #include "src/core/ext/filters/client_channel/global_subchannel_pool.h" #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/tcp_client.h" @@ -142,7 +142,7 @@ class ClientLbEnd2endTest : public ::testing::Test { grpc_fake_transport_security_credentials_create())) { // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. - gpr_setenv("GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS", "1"); + GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); } void SetUp() override { diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index fb951fd44e6..a2b9ebe7197 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -34,6 +34,7 @@ #include #include +#include "src/core/ext/filters/client_channel/backup_poller.h" #include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/security/credentials/credentials.h" @@ -2104,7 +2105,7 @@ INSTANTIATE_TEST_CASE_P( } // namespace grpc int main(int argc, char** argv) { - gpr_setenv("GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS", "200"); + GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 200); grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc index bd915b04eee..f93e2548c8e 100644 --- a/test/cpp/end2end/grpclb_end2end_test.cc +++ b/test/cpp/end2end/grpclb_end2end_test.cc @@ -34,11 +34,11 @@ #include #include +#include "src/core/ext/filters/client_channel/backup_poller.h" #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/ext/filters/client_channel/service_config.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" @@ -375,7 +375,7 @@ class GrpclbEnd2endTest : public ::testing::Test { client_load_reporting_interval_seconds) { // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. - gpr_setenv("GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS", "1"); + GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); } void SetUp() override { diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index 2952c194d48..d6f2685642c 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -33,6 +33,7 @@ #include #include +#include "src/core/ext/filters/client_channel/backup_poller.h" #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" #include "src/core/ext/filters/client_channel/server_address.h" @@ -370,7 +371,7 @@ class XdsEnd2endTest : public ::testing::Test { client_load_reporting_interval_seconds) { // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. - gpr_setenv("GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS", "1"); + GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); } void SetUp() override { diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index 2e54993a31c..4d1beb7ec37 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -146,8 +146,9 @@ vector ParseExpectedAddrs(std::string expected_addrs) { expected_addrs = expected_addrs.substr(next_comma + 1, std::string::npos); // get the next is_balancer 'bool' associated with this address size_t next_semicolon = expected_addrs.find(';'); - bool is_balancer = - gpr_is_true(expected_addrs.substr(0, next_semicolon).c_str()); + bool is_balancer = false; + gpr_parse_bool_value(expected_addrs.substr(0, next_semicolon).c_str(), + &is_balancer); out.emplace_back(GrpcLBAddress(next_addr, is_balancer)); if (next_semicolon == std::string::npos) { break; diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 357efa0d684..bc2a32d3cfd 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1086,6 +1086,10 @@ src/core/lib/gprpp/arena.h \ src/core/lib/gprpp/atomic.h \ src/core/lib/gprpp/debug_location.h \ src/core/lib/gprpp/fork.h \ +src/core/lib/gprpp/global_config.h \ +src/core/lib/gprpp/global_config_custom.h \ +src/core/lib/gprpp/global_config_env.h \ +src/core/lib/gprpp/global_config_generic.h \ src/core/lib/gprpp/inlined_vector.h \ src/core/lib/gprpp/manual_constructor.h \ src/core/lib/gprpp/map.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 3a9951b0364..870d6348df0 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1165,6 +1165,11 @@ src/core/lib/gprpp/atomic.h \ src/core/lib/gprpp/debug_location.h \ src/core/lib/gprpp/fork.cc \ src/core/lib/gprpp/fork.h \ +src/core/lib/gprpp/global_config.h \ +src/core/lib/gprpp/global_config_custom.h \ +src/core/lib/gprpp/global_config_env.cc \ +src/core/lib/gprpp/global_config_env.h \ +src/core/lib/gprpp/global_config_generic.h \ src/core/lib/gprpp/inlined_vector.h \ src/core/lib/gprpp/manual_constructor.h \ src/core/lib/gprpp/map.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 9778343cd94..e07bb48675a 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -3662,6 +3662,36 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "grpc_test_util_unsecure" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "global_config_env_test", + "src": [ + "test/core/gprpp/global_config_env_test.cc" + ], + "third_party": false, + "type": "target" + }, + { + "deps": [ + "gpr", + "grpc_test_util_unsecure" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "global_config_test", + "src": [ + "test/core/gprpp/global_config_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", @@ -8019,6 +8049,7 @@ "src/core/lib/gpr/wrap_memcpy.cc", "src/core/lib/gprpp/arena.cc", "src/core/lib/gprpp/fork.cc", + "src/core/lib/gprpp/global_config_env.cc", "src/core/lib/gprpp/thd_posix.cc", "src/core/lib/gprpp/thd_windows.cc", "src/core/lib/profiling/basic_timers.cc", @@ -8069,6 +8100,10 @@ "src/core/lib/gprpp/arena.h", "src/core/lib/gprpp/atomic.h", "src/core/lib/gprpp/fork.h", + "src/core/lib/gprpp/global_config.h", + "src/core/lib/gprpp/global_config_custom.h", + "src/core/lib/gprpp/global_config_env.h", + "src/core/lib/gprpp/global_config_generic.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", @@ -8118,6 +8153,10 @@ "src/core/lib/gprpp/arena.h", "src/core/lib/gprpp/atomic.h", "src/core/lib/gprpp/fork.h", + "src/core/lib/gprpp/global_config.h", + "src/core/lib/gprpp/global_config_custom.h", + "src/core/lib/gprpp/global_config_env.h", + "src/core/lib/gprpp/global_config_generic.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index ec2e570bea7..8c14282acbb 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -4499,6 +4499,54 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": false, + "language": "c++", + "name": "global_config_env_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": false + }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": false, + "language": "c++", + "name": "global_config_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": false + }, { "args": [ "--generated_file_path=gens/src/proto/grpc/testing/" From 3184fff6b27bd97cf675a1b2c1669c2f81922c0a Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 30 Apr 2019 15:54:35 -0700 Subject: [PATCH 0080/1555] Fix BUILD.gn file --- BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/BUILD.gn b/BUILD.gn index 00a412c84bc..2ab56ba346b 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1014,6 +1014,7 @@ config("grpc_config") { "include/grpcpp/alarm.h", "include/grpcpp/alarm_impl.h", "include/grpcpp/channel.h", + "include/grpcpp/channel_impl.h", "include/grpcpp/client_context.h", "include/grpcpp/completion_queue.h", "include/grpcpp/create_channel.h", From e70d507abe159fec815d8fb95e780fc0859f8e8d Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Tue, 30 Apr 2019 16:32:31 -0700 Subject: [PATCH 0081/1555] Changes based on comment --- .../bm_callback_unary_ping_pong.cc | 83 ++++++++++--------- .../callback_streaming_ping_pong.h | 4 +- .../microbenchmarks/callback_test_service.cc | 9 -- .../callback_unary_ping_pong.h | 6 +- 4 files changed, 51 insertions(+), 51 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc b/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc index c0a7054bf51..bcbde5db035 100644 --- a/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc +++ b/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc @@ -34,12 +34,15 @@ auto& force_library_initialization = Library::get(); static void SweepSizesArgs(benchmark::internal::Benchmark* b) { b->Args({0, 0}); for (int i = 1; i <= 128 * 1024 * 1024; i *= 8) { + // First argument is the message size of request + // Second argument is the message size of response b->Args({i, 0}); b->Args({0, i}); b->Args({i, i}); } } +// Unary ping pong with different message size of request and response BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, NoOpMutator) ->Apply(SweepSizesArgs); @@ -52,6 +55,8 @@ BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, MinInProcessCHTTP2, NoOpMutator, NoOpMutator) ->Apply(SweepSizesArgs); + +// Client context with different metadata BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, Client_AddMetadata, 1>, NoOpMutator) ->Args({0, 0}); @@ -72,15 +77,6 @@ BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, Client_AddMetadata, 2>, NoOpMutator) ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, Client_AddMetadata, 1>, NoOpMutator) ->Args({0, 0}); @@ -90,6 +86,46 @@ BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, Client_AddMetadata, 1>, NoOpMutator) ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, + Client_AddMetadata, 1>, + NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, + Client_AddMetadata, 2>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, + Client_AddMetadata, 2>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, + Client_AddMetadata, 2>, + NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, + Client_AddMetadata, 1>, NoOpMutator) + ->Args({0, 0}); + +// Server context with different metadata +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, + Server_AddInitialMetadata, 1>) + ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, Server_AddInitialMetadata, 1>) ->Args({0, 0}); @@ -102,26 +138,6 @@ BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, Server_AddInitialMetadata, 100>) ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, - Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, - Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, - Client_AddMetadata, 1>, - NoOpMutator) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, - Client_AddMetadata, 2>, NoOpMutator) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, - Client_AddMetadata, 2>, NoOpMutator) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, - Client_AddMetadata, 2>, - NoOpMutator) - ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, Server_AddInitialMetadata, 1>) ->Args({0, 0}); @@ -131,15 +147,6 @@ BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, Server_AddInitialMetadata, 1>) ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, - Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, - Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, - Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, Server_AddInitialMetadata, 1>) ->Args({0, 0}); diff --git a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h index 1710a754803..fc74e2757ba 100644 --- a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h @@ -61,8 +61,8 @@ static void BM_CallbackBidiStreaming(benchmark::State& state) { } fixture->Finish(state); fixture.reset(); - state.SetBytesProcessed(2 * state.range(0) * state.iterations() * - state.range(1)); + state.SetBytesProcessed(2 * message_size * max_ping_pongs + * state.iterations()); } } // namespace testing diff --git a/test/cpp/microbenchmarks/callback_test_service.cc b/test/cpp/microbenchmarks/callback_test_service.cc index caa734d90e8..eebf6e31241 100644 --- a/test/cpp/microbenchmarks/callback_test_service.cc +++ b/test/cpp/microbenchmarks/callback_test_service.cc @@ -64,14 +64,6 @@ CallbackStreamingTestService::BidiStream() { kServerFinishAfterNReads, context->client_metadata(), 0); message_size_ = GetIntValueFromMetadata(kServerResponseStreamsToSend, context->client_metadata(), 0); - // EchoRequest* request = new EchoRequest; - // if (message_size_ > 0) { - // request->set_message(std::string(message_size_, 'a')); - // } else { - // request->set_message(""); - // } - // - // request_ = request; StartRead(&request_); on_started_done_ = true; } @@ -80,7 +72,6 @@ CallbackStreamingTestService::BidiStream() { void OnReadDone(bool ok) override { if (ok) { num_msgs_read_++; - // gpr_log(GPR_INFO, "recv msg %s", request_.message().c_str()); if (message_size_ > 0) { response_.set_message(std::string(message_size_, 'a')); } else { diff --git a/test/cpp/microbenchmarks/callback_unary_ping_pong.h b/test/cpp/microbenchmarks/callback_unary_ping_pong.h index 01477e6402d..19449341747 100644 --- a/test/cpp/microbenchmarks/callback_unary_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_unary_ping_pong.h @@ -38,6 +38,8 @@ namespace testing { template static void BM_CallbackUnaryPingPong(benchmark::State& state) { + int request_msgs_size = state.range(0); + int response_msgs_size = state.range(1); CallbackStreamingTestService service; std::unique_ptr fixture(new Fixture(&service)); std::unique_ptr stub_( @@ -76,8 +78,8 @@ static void BM_CallbackUnaryPingPong(benchmark::State& state) { } fixture->Finish(state); fixture.reset(); - state.SetBytesProcessed(state.range(0) * state.iterations() + - state.range(1) * state.iterations()); + state.SetBytesProcessed(request_msgs_size * state.iterations() + + response_msgs_size * state.iterations()); } } // namespace testing } // namespace grpc From e060cd7519f065db308ed04e765269221b609950 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 30 Apr 2019 16:36:05 -0700 Subject: [PATCH 0082/1555] Fix formatting errors --- BUILD.gn | 1 + include/grpcpp/channel_impl.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/BUILD.gn b/BUILD.gn index 195fe0e71fb..4e52a0dc339 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1014,6 +1014,7 @@ config("grpc_config") { "include/grpcpp/alarm.h", "include/grpcpp/alarm_impl.h", "include/grpcpp/channel.h", + "include/grpcpp/channel_impl.h", "include/grpcpp/client_context.h", "include/grpcpp/completion_queue.h", "include/grpcpp/create_channel.h", diff --git a/include/grpcpp/channel_impl.h b/include/grpcpp/channel_impl.h index b0240d30ec6..39917d2eb74 100644 --- a/include/grpcpp/channel_impl.h +++ b/include/grpcpp/channel_impl.h @@ -25,8 +25,8 @@ #include #include #include -#include #include +#include #include #include #include From 3a31b96ef9ba100f09032bc7ee0335b7070d9b6e Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 30 Apr 2019 16:39:54 -0700 Subject: [PATCH 0083/1555] Fix error from make --- src/cpp/client/cronet_credentials.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpp/client/cronet_credentials.cc b/src/cpp/client/cronet_credentials.cc index 4f3a053b494..f4ead14cde8 100644 --- a/src/cpp/client/cronet_credentials.cc +++ b/src/cpp/client/cronet_credentials.cc @@ -47,7 +47,7 @@ class CronetChannelCredentialsImpl final : public ChannelCredentials { interceptor_creators) override { grpc_channel_args channel_args; args.SetChannelArgs(&channel_args); - return ::grpc_impl::CreateChannelInternal( + return CreateChannelInternal( "", grpc_cronet_secure_channel_create(engine_, target.c_str(), &channel_args, nullptr), From 8e4b4b94038bc42d6cc2b9d124fe294137c78700 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 30 Apr 2019 16:49:48 -0700 Subject: [PATCH 0084/1555] Fix golden file for test --- test/cpp/codegen/compiler_test_golden | 1 + 1 file changed, 1 insertion(+) diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index e3b06a90f62..e571a95bb3e 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -52,6 +52,7 @@ template class MessageAllocator; } // namespace experimental } // namespace grpc_impl + namespace grpc { class ServerContext; } // namespace grpc From 2e8e7e4838ecf179cbb2ee8e943c27cec6dc7668 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 30 Apr 2019 16:56:43 -0700 Subject: [PATCH 0085/1555] Initialize Cronet only once --- src/objective-c/tests/InteropTests/InteropTests.m | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 164d571d125..260afb83e6f 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -110,10 +110,13 @@ BOOL isRemoteInteropTest(NSString *host) { + (void)setUp { NSLog(@"InteropTest Started, class: %@", [[self class] description]); #ifdef GRPC_COMPILE_WITH_CRONET - // Cronet setup - [Cronet setHttp2Enabled:YES]; - [Cronet start]; - [GRPCCall useCronetWithEngine:[Cronet getGlobalEngine]]; + static dispatch_once_t *enableCronet; + dispatch_once(enableCronet, ^{ + // Cronet setup + [Cronet setHttp2Enabled:YES]; + [Cronet start]; + [GRPCCall useCronetWithEngine:[Cronet getGlobalEngine]]; + }); #endif #ifdef GRPC_CFSTREAM setenv(kCFStreamVarName, "1", 1); From e17ce91d16e91baf0a23ea27bbcb8e8ab873fd7a Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 30 Apr 2019 17:08:07 -0700 Subject: [PATCH 0086/1555] Fix make errors --- src/cpp/client/cronet_credentials.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpp/client/cronet_credentials.cc b/src/cpp/client/cronet_credentials.cc index 4f3a053b494..4ad424dad26 100644 --- a/src/cpp/client/cronet_credentials.cc +++ b/src/cpp/client/cronet_credentials.cc @@ -47,7 +47,7 @@ class CronetChannelCredentialsImpl final : public ChannelCredentials { interceptor_creators) override { grpc_channel_args channel_args; args.SetChannelArgs(&channel_args); - return ::grpc_impl::CreateChannelInternal( + return ::grpc::CreateChannelInternal( "", grpc_cronet_secure_channel_create(engine_, target.c_str(), &channel_args, nullptr), From d6c98bf82e46daed0841382d59d112a36979fb17 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 30 Apr 2019 18:25:06 -0700 Subject: [PATCH 0087/1555] Fix Cronet multiple initialization problem --- .../CronetTests/CoreCronetEnd2EndTests.mm | 10 ++--- .../tests/CronetTests/CronetUnitTests.mm | 13 ++----- .../InteropTestsRemoteWithCronet.m | 4 ++ src/objective-c/tests/EnableCronet.h | 34 +++++++++++++++++ src/objective-c/tests/EnableCronet.m | 38 +++++++++++++++++++ .../tests/InteropTests/InteropTests.h | 5 +++ .../tests/InteropTests/InteropTests.m | 14 ++++--- .../tests/Tests.xcodeproj/project.pbxproj | 8 ++++ .../xcschemes/CronetTests.xcscheme | 5 +++ 9 files changed, 108 insertions(+), 23 deletions(-) create mode 100644 src/objective-c/tests/EnableCronet.h create mode 100644 src/objective-c/tests/EnableCronet.m diff --git a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm index 2fac1be3d0e..3a753d4a4a4 100644 --- a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm +++ b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm @@ -49,6 +49,8 @@ #import #include +#import "../EnableCronet.h" + typedef struct fullstack_secure_fixture_data { char *localaddr; } fullstack_secure_fixture_data; @@ -176,13 +178,7 @@ static char *roots_filename; grpc_init(); - [Cronet setHttp2Enabled:YES]; - [Cronet enableTestCertVerifierForTesting]; - NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory - inDomains:NSUserDomainMask] lastObject]; - NSLog(@"Documents directory: %@", url); - [Cronet start]; - [Cronet startNetLogToFile:@"cronet_netlog.json" logBytes:YES]; + enableCronet(); } // The tearDown() function is run after all test cases finish running diff --git a/src/objective-c/tests/CronetTests/CronetUnitTests.mm b/src/objective-c/tests/CronetTests/CronetUnitTests.mm index 2a861032caf..b17bc334479 100644 --- a/src/objective-c/tests/CronetTests/CronetUnitTests.mm +++ b/src/objective-c/tests/CronetTests/CronetUnitTests.mm @@ -20,6 +20,8 @@ #import #import +#import "../EnableCronet.h" + #import #import #import @@ -61,16 +63,7 @@ static void drain_cq(grpc_completion_queue *cq) { grpc_test_init(1, argv); grpc_init(); - - [Cronet setHttp2Enabled:YES]; - [Cronet setSslKeyLogFileName:@"Documents/key"]; - [Cronet enableTestCertVerifierForTesting]; - NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory - inDomains:NSUserDomainMask] lastObject]; - NSLog(@"Documents directory: %@", url); - [Cronet start]; - [Cronet startNetLogToFile:@"Documents/cronet_netlog.json" logBytes:YES]; - + enableCronet(); init_ssl(); } diff --git a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m index 25041ae5eb1..a2a79c46316 100644 --- a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m +++ b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m @@ -44,6 +44,10 @@ static int32_t kRemoteInteropServerOverhead = 12; return kRemoteSSLHost; } ++ (BOOL)useCronet { + return YES; +} + - (int32_t)encodingOverhead { return kRemoteInteropServerOverhead; // bytes } diff --git a/src/objective-c/tests/EnableCronet.h b/src/objective-c/tests/EnableCronet.h new file mode 100644 index 00000000000..e544e76345d --- /dev/null +++ b/src/objective-c/tests/EnableCronet.h @@ -0,0 +1,34 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifdef GRPC_COMPILE_WITH_CRONET + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Enable Cronet for once. + */ +void enableCronet(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/objective-c/tests/EnableCronet.m b/src/objective-c/tests/EnableCronet.m new file mode 100644 index 00000000000..ff6e4612d88 --- /dev/null +++ b/src/objective-c/tests/EnableCronet.m @@ -0,0 +1,38 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifdef GRPC_COMPILE_WITH_CRONET + +#import +#import "EnableCronet.h" + +void enableCronet(void) { + static dispatch_once_t enableCronet; + dispatch_once(&enableCronet, ^{ + [Cronet setHttp2Enabled:YES]; + [Cronet setSslKeyLogFileName:@"Documents/key"]; + [Cronet enableTestCertVerifierForTesting]; + NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory + inDomains:NSUserDomainMask] lastObject]; + NSLog(@"Documents directory: %@", url); + [Cronet start]; + [Cronet startNetLogToFile:@"cronet_netlog.json" logBytes:YES]; + }); +} + +#endif diff --git a/src/objective-c/tests/InteropTests/InteropTests.h b/src/objective-c/tests/InteropTests/InteropTests.h index 038f24b62e5..cffa90ac497 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.h +++ b/src/objective-c/tests/InteropTests/InteropTests.h @@ -59,4 +59,9 @@ */ + (NSString *)hostNameOverride; +/** + * Whether to use Cronet for all the v1 API tests in the test suite. + */ ++ (BOOL)useCronet; + @end diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 260afb83e6f..3204f689c48 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -37,6 +37,7 @@ #import #import "InteropTestsBlockCallbacks.h" +#import "../enableCronet.h" #define TEST_TIMEOUT 32 @@ -107,16 +108,17 @@ BOOL isRemoteInteropTest(NSString *host) { return nil; } ++ (BOOL)useCronet { + return NO; +} + + (void)setUp { NSLog(@"InteropTest Started, class: %@", [[self class] description]); #ifdef GRPC_COMPILE_WITH_CRONET - static dispatch_once_t *enableCronet; - dispatch_once(enableCronet, ^{ - // Cronet setup - [Cronet setHttp2Enabled:YES]; - [Cronet start]; + enableCronet(); + if ([self useCronet]) { [GRPCCall useCronetWithEngine:[Cronet getGlobalEngine]]; - }); + } #endif #ifdef GRPC_CFSTREAM setenv(kCFStreamVarName, "1", 1); diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index 1f05899bd60..c226e29d83b 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -11,6 +11,8 @@ 5E3F14842278B461007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; 5E3F14852278BF5D007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; 5E3F14862278BFFF007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; + 5E3F148D22792856007C6D90 /* EnableCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F1487227918AA007C6D90 /* EnableCronet.m */; }; + 5E3F148E22792AF5007C6D90 /* EnableCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F1487227918AA007C6D90 /* EnableCronet.m */; }; 5E7F486422775B37006656AD /* InteropTestsRemoteWithCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE84BF31D4717E40050C6CC /* InteropTestsRemoteWithCronet.m */; }; 5E7F486522775B41006656AD /* CronetUnitTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5EAD6D261E27047400002378 /* CronetUnitTests.mm */; }; 5E7F486E22778086006656AD /* CoreCronetEnd2EndTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F486D22778086006656AD /* CoreCronetEnd2EndTests.mm */; }; @@ -92,6 +94,8 @@ 5E0282E8215AA697007AC99D /* NSErrorUnitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NSErrorUnitTests.m; sourceTree = ""; }; 5E3F14822278B42D007C6D90 /* InteropTestsBlockCallbacks.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InteropTestsBlockCallbacks.h; sourceTree = ""; }; 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InteropTestsBlockCallbacks.m; sourceTree = ""; }; + 5E3F1487227918AA007C6D90 /* EnableCronet.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EnableCronet.m; sourceTree = ""; }; + 5E3F148A227918C4007C6D90 /* EnableCronet.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EnableCronet.h; sourceTree = ""; }; 5E7F485922775B15006656AD /* CronetTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CronetTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 5E7F486622776AD8006656AD /* Cronet.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cronet.framework; path = Pods/CronetFramework/Cronet.framework; sourceTree = ""; }; 5E7F486D22778086006656AD /* CoreCronetEnd2EndTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CoreCronetEnd2EndTests.mm; sourceTree = ""; }; @@ -392,6 +396,8 @@ 635697C91B14FC11007A7283 /* Tests */ = { isa = PBXGroup; children = ( + 5E3F148A227918C4007C6D90 /* EnableCronet.h */, + 5E3F1487227918AA007C6D90 /* EnableCronet.m */, 5EAFE8271F8EFB87007F2189 /* version.h */, 635697D71B14FC11007A7283 /* Supporting Files */, ); @@ -813,6 +819,7 @@ buildActionMask = 2147483647; files = ( 5E3F14852278BF5D007C6D90 /* InteropTestsBlockCallbacks.m in Sources */, + 5E3F148D22792856007C6D90 /* EnableCronet.m in Sources */, 5E7F486E22778086006656AD /* CoreCronetEnd2EndTests.mm in Sources */, 5E7F488522778A88006656AD /* InteropTests.m in Sources */, 5E7F486422775B37006656AD /* InteropTestsRemoteWithCronet.m in Sources */, @@ -825,6 +832,7 @@ buildActionMask = 2147483647; files = ( 5E3F14842278B461007C6D90 /* InteropTestsBlockCallbacks.m in Sources */, + 5E3F148E22792AF5007C6D90 /* EnableCronet.m in Sources */, 5E7F488922778B04006656AD /* InteropTestsRemote.m in Sources */, 5E7F487922778226006656AD /* InteropTestsMultipleChannels.m in Sources */, 5EA477042273617B000F72FC /* InteropTestsLocalCleartext.m in Sources */, diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CronetTests.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CronetTests.xcscheme index aea349a06cc..ac8cfc971c8 100644 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CronetTests.xcscheme +++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CronetTests.xcscheme @@ -37,6 +37,11 @@ BlueprintName = "CronetTests" ReferencedContainer = "container:Tests.xcodeproj"> + + + + From 4c0c2965fe430930060f686a1a0b678b64b24344 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Tue, 30 Apr 2019 22:20:06 -0400 Subject: [PATCH 0088/1555] Use peek_first instead of mutable_first. Use DEBUG_ASSERT instead of ASSERT. --- src/core/ext/transport/chttp2/transport/frame_data.cc | 2 +- src/core/lib/compression/stream_compression_gzip.cc | 2 +- src/core/lib/security/transport/security_handshaker.cc | 3 +-- src/core/lib/slice/slice_buffer.cc | 2 +- src/core/lib/slice/slice_internal.h | 2 +- test/core/slice/slice_buffer_test.cc | 8 ++++---- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/frame_data.cc b/src/core/ext/transport/chttp2/transport/frame_data.cc index 2b7d3fce008..5a0492f72ab 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.cc +++ b/src/core/ext/transport/chttp2/transport/frame_data.cc @@ -104,7 +104,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( uint8_t* end = nullptr; uint8_t* cur = nullptr; - grpc_slice* slice = grpc_slice_buffer_mutable_first(slices); + grpc_slice* slice = grpc_slice_buffer_peek_first(slices); beg = GRPC_SLICE_START_PTR(*slice); end = GRPC_SLICE_END_PTR(*slice); cur = beg; diff --git a/src/core/lib/compression/stream_compression_gzip.cc b/src/core/lib/compression/stream_compression_gzip.cc index ca687066136..f2c4bb92981 100644 --- a/src/core/lib/compression/stream_compression_gzip.cc +++ b/src/core/lib/compression/stream_compression_gzip.cc @@ -53,7 +53,7 @@ static bool gzip_flate(grpc_stream_compression_context_gzip* ctx, ctx->zs.avail_out = static_cast(slice_size); ctx->zs.next_out = GRPC_SLICE_START_PTR(slice_out); while (ctx->zs.avail_out > 0 && in->length > 0 && !eoc) { - grpc_slice* slice = grpc_slice_buffer_mutable_first(in); + grpc_slice* slice = grpc_slice_buffer_peek_first(in); ctx->zs.avail_in = static_cast GRPC_SLICE_LENGTH(*slice); ctx->zs.next_in = GRPC_SLICE_START_PTR(*slice); r = ctx->flate(&ctx->zs, Z_NO_FLUSH); diff --git a/src/core/lib/security/transport/security_handshaker.cc b/src/core/lib/security/transport/security_handshaker.cc index 7c0792f2846..117e01a77a7 100644 --- a/src/core/lib/security/transport/security_handshaker.cc +++ b/src/core/lib/security/transport/security_handshaker.cc @@ -144,8 +144,7 @@ size_t SecurityHandshaker::MoveReadBufferIntoHandshakeBuffer() { } size_t offset = 0; while (args_->read_buffer->count > 0) { - grpc_slice* next_slice = - grpc_slice_buffer_mutable_first(args_->read_buffer); + grpc_slice* next_slice = grpc_slice_buffer_peek_first(args_->read_buffer); memcpy(handshake_buffer_ + offset, GRPC_SLICE_START_PTR(*next_slice), GRPC_SLICE_LENGTH(*next_slice)); offset += GRPC_SLICE_LENGTH(*next_slice); diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc index 76da64b858f..501d600cb97 100644 --- a/src/core/lib/slice/slice_buffer.cc +++ b/src/core/lib/slice/slice_buffer.cc @@ -371,7 +371,7 @@ grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer* sb) { } void grpc_slice_buffer_consume_first(grpc_slice_buffer* sb) { - GPR_ASSERT(sb->count > 0); + GPR_DEBUG_ASSERT(sb->count > 0); sb->length -= GRPC_SLICE_LENGTH(sb->slices[0]); grpc_slice_unref_internal(sb->slices[0]); sb->slices++; diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index 4c4ace443dc..e6563f4720d 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -243,7 +243,7 @@ void grpc_slice_buffer_partial_unref_internal(grpc_slice_buffer* sb, void grpc_slice_buffer_destroy_internal(grpc_slice_buffer* sb); // Returns the first slice in the slice buffer. -inline grpc_slice* grpc_slice_buffer_mutable_first(grpc_slice_buffer* sb) { +inline grpc_slice* grpc_slice_buffer_peek_first(grpc_slice_buffer* sb) { GPR_DEBUG_ASSERT(sb->count > 0); return &sb->slices[0]; } diff --git a/test/core/slice/slice_buffer_test.cc b/test/core/slice/slice_buffer_test.cc index 8aa58a3ac0d..5ad11a34563 100644 --- a/test/core/slice/slice_buffer_test.cc +++ b/test/core/slice/slice_buffer_test.cc @@ -119,25 +119,25 @@ void test_slice_buffer_first() { grpc_slice_buffer_add_indexed(&buf, slices[idx]); } - grpc_slice* first = grpc_slice_buffer_mutable_first(&buf); + grpc_slice* first = grpc_slice_buffer_peek_first(&buf); GPR_ASSERT(GPR_SLICE_LENGTH(*first) == GPR_SLICE_LENGTH(slices[0])); GPR_ASSERT(buf.count == 3); GPR_ASSERT(buf.length == 12); grpc_slice_buffer_sub_first(&buf, 1, 2); - first = grpc_slice_buffer_mutable_first(&buf); + first = grpc_slice_buffer_peek_first(&buf); GPR_ASSERT(GPR_SLICE_LENGTH(*first) == 1); GPR_ASSERT(buf.count == 3); GPR_ASSERT(buf.length == 10); grpc_slice_buffer_consume_first(&buf); - first = grpc_slice_buffer_mutable_first(&buf); + first = grpc_slice_buffer_peek_first(&buf); GPR_ASSERT(GPR_SLICE_LENGTH(*first) == GPR_SLICE_LENGTH(slices[1])); GPR_ASSERT(buf.count == 2); GPR_ASSERT(buf.length == 9); grpc_slice_buffer_consume_first(&buf); - first = grpc_slice_buffer_mutable_first(&buf); + first = grpc_slice_buffer_peek_first(&buf); GPR_ASSERT(GPR_SLICE_LENGTH(*first) == GPR_SLICE_LENGTH(slices[2])); GPR_ASSERT(buf.count == 1); GPR_ASSERT(buf.length == 5); From 1775faa5957a01d5aaaabcca1601b751c5668d9f Mon Sep 17 00:00:00 2001 From: yang-g Date: Tue, 30 Apr 2019 22:51:09 -0700 Subject: [PATCH 0089/1555] Fix epoll1 for release fd --- src/core/lib/iomgr/ev_epoll1_linux.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/lib/iomgr/ev_epoll1_linux.cc b/src/core/lib/iomgr/ev_epoll1_linux.cc index c2165341964..4dff4579dac 100644 --- a/src/core/lib/iomgr/ev_epoll1_linux.cc +++ b/src/core/lib/iomgr/ev_epoll1_linux.cc @@ -383,6 +383,10 @@ static void fd_shutdown_internal(grpc_fd* fd, grpc_error* why, if (fd->read_closure->SetShutdown(GRPC_ERROR_REF(why))) { if (!releasing_fd) { shutdown(fd->fd, SHUT_RDWR); + } else { + if (epoll_ctl(g_epoll_set.epfd, EPOLL_CTL_DEL, fd->fd, nullptr) != 0) { + gpr_log(GPR_ERROR, "epoll_ctl failed: %s", strerror(errno)); + } } fd->write_closure->SetShutdown(GRPC_ERROR_REF(why)); fd->error_closure->SetShutdown(GRPC_ERROR_REF(why)); From f5f030e675369a2c1c81c7551bf774d3909668b4 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Wed, 1 May 2019 13:41:19 -0400 Subject: [PATCH 0090/1555] Use end - begin instead of GRPC_SLICE_LENGTH(). --- src/core/lib/slice/slice_buffer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc index 501d600cb97..083e35791db 100644 --- a/src/core/lib/slice/slice_buffer.cc +++ b/src/core/lib/slice/slice_buffer.cc @@ -385,7 +385,7 @@ void grpc_slice_buffer_sub_first(grpc_slice_buffer* sb, size_t begin, // TODO(soheil): Introduce a ptr version for sub. sb->length -= GRPC_SLICE_LENGTH(sb->slices[0]); sb->slices[0] = grpc_slice_sub_no_ref(sb->slices[0], begin, end); - sb->length += GRPC_SLICE_LENGTH(sb->slices[0]); + sb->length += end - begin; } void grpc_slice_buffer_undo_take_first(grpc_slice_buffer* sb, From b3fb277da6468de843e41bd6434b6b6d4ec46dc3 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Wed, 1 May 2019 13:52:58 -0400 Subject: [PATCH 0091/1555] Reset slices pointer to base_slices when slice_bufer length is 0. Currently, we keep increasing the slice pointer, and can run out of the inline space or try to realloc the non-inline space unncessarily. Simply set slices back to the start of the base_slices, when we know the length of the slice_buffer is 0. Note: This will change the behavior of undo_take_first(), if user tries to grow the slie_buffer, between take_first() and undo_take_first() calls. That said, it's not legal to add something to the buffer in between take_first() and undo_take_first(). So, we shouldn't have any issue. --- src/core/lib/slice/slice_buffer.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc index 1f1c08b1594..ce3b5512d1d 100644 --- a/src/core/lib/slice/slice_buffer.cc +++ b/src/core/lib/slice/slice_buffer.cc @@ -33,6 +33,10 @@ #define GROW(x) (3 * (x) / 2) static void maybe_embiggen(grpc_slice_buffer* sb) { + if (sb->length == 0) { + sb->slices = sb->base_slices; + } + /* How far away from sb->base_slices is sb->slices pointer */ size_t slice_offset = static_cast(sb->slices - sb->base_slices); size_t slice_count = sb->count + slice_offset; @@ -177,6 +181,7 @@ void grpc_slice_buffer_reset_and_unref_internal(grpc_slice_buffer* sb) { sb->count = 0; sb->length = 0; + sb->slices = sb->base_slices; } void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer* sb) { From 7d3fdec4450df73791602d478fb361ec3f62cfbe Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Wed, 1 May 2019 11:29:28 -0700 Subject: [PATCH 0092/1555] Add microbenchmark for callback completion queue --- test/cpp/microbenchmarks/bm_callback_cq.cc | 231 +++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 test/cpp/microbenchmarks/bm_callback_cq.cc diff --git a/test/cpp/microbenchmarks/bm_callback_cq.cc b/test/cpp/microbenchmarks/bm_callback_cq.cc new file mode 100644 index 00000000000..bc2e4cef969 --- /dev/null +++ b/test/cpp/microbenchmarks/bm_callback_cq.cc @@ -0,0 +1,231 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/* This benchmark exists to ensure that immediately-firing alarms are fast */ + +#include +#include +#include +#include +#include +#include "test/core/util/test_config.h" +#include "test/cpp/microbenchmarks/helpers.h" +#include "test/cpp/util/test_config.h" + +#include "src/core/lib/surface/completion_queue.h" +#include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/iomgr/iomgr.h" + +namespace grpc { +namespace testing { + +auto& force_library_initialization = Library::get(); + +class TagCallback : public grpc_experimental_completion_queue_functor { + public: + TagCallback(int* counter, int tag) : counter_(counter), tag_(tag) { + functor_run = &TagCallback::Run; + } + ~TagCallback() {} + static void Run(grpc_experimental_completion_queue_functor* cb, + int ok) { + GPR_ASSERT(static_cast(ok)); + auto* callback = static_cast(cb); + *callback->counter_ += callback->tag_; + grpc_core::Delete(callback); + }; + + private: + int* counter_; + int tag_; +}; + +class ShutdownCallback : public grpc_experimental_completion_queue_functor { + public: + ShutdownCallback(bool* done) : done_(done) { + functor_run = &ShutdownCallback::Run; + } + ~ShutdownCallback() {} + static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { + *static_cast(cb)->done_ = static_cast(ok); + } + + private: + bool* done_; +}; + +/* helper for tests to shutdown correctly and tersely */ +static void shutdown_and_destroy(grpc_completion_queue* cc) { + grpc_completion_queue_shutdown(cc); + grpc_completion_queue_destroy(cc); +} + +static void do_nothing_end_completion(void* arg, grpc_cq_completion* c) {} + +static void BM_Callback_CQ_Default_Polling(benchmark::State& state) { + int tag_size = state.range(0); + grpc_completion_queue* cc; + void* tags[tag_size]; + grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)]; + + grpc_completion_queue_attributes attr; + unsigned i; + bool got_shutdown = false; + ShutdownCallback shutdown_cb(&got_shutdown); + + attr.version = 2; + attr.cq_completion_type = GRPC_CQ_CALLBACK; + attr.cq_shutdown_cb = &shutdown_cb; + while (state.KeepRunning()) { + int sumtags = 0; + int counter = 0; + { + // reset exec_ctx types + grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; + grpc_core::ExecCtx exec_ctx; + attr.cq_polling_type = GRPC_CQ_DEFAULT_POLLING; + cc = grpc_completion_queue_create( + grpc_completion_queue_factory_lookup(&attr), &attr, nullptr); + + for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { + tags[i] = + static_cast(grpc_core::New(&counter, i)); + sumtags += i; + } + + for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { + GPR_ASSERT(grpc_cq_begin_op(cc, tags[i])); + grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, + do_nothing_end_completion, nullptr, &completions[i]); + } + + shutdown_and_destroy(cc); + } + GPR_ASSERT(sumtags == counter); + GPR_ASSERT(got_shutdown); + got_shutdown = false; + } +} +BENCHMARK(BM_Callback_CQ_Default_Polling)->Range(1, 128 * 1024); + +static void BM_Callback_CQ_Non_Listening(benchmark::State& state) { + int tag_size = state.range(0); + grpc_completion_queue* cc; + void* tags[tag_size]; + grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)]; + grpc_completion_queue_attributes attr; + unsigned i; + bool got_shutdown = false; + ShutdownCallback shutdown_cb(&got_shutdown); + + attr.version = 2; + attr.cq_completion_type = GRPC_CQ_CALLBACK; + attr.cq_shutdown_cb = &shutdown_cb; + while (state.KeepRunning()) { + int sumtags = 0; + int counter = 0; + { + // reset exec_ctx types + grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; + grpc_core::ExecCtx exec_ctx; + attr.cq_polling_type = GRPC_CQ_NON_LISTENING; + cc = grpc_completion_queue_create( + grpc_completion_queue_factory_lookup(&attr), &attr, nullptr); + + for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { + tags[i] = + static_cast(grpc_core::New(&counter, i)); + sumtags += i; + } + + for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { + GPR_ASSERT(grpc_cq_begin_op(cc, tags[i])); + grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, + do_nothing_end_completion, nullptr, &completions[i]); + } + + shutdown_and_destroy(cc); + } + GPR_ASSERT(sumtags == counter); + GPR_ASSERT(got_shutdown); + got_shutdown = false; + } +} +BENCHMARK(BM_Callback_CQ_Non_Listening)->Range(1, 128 * 1024); + +static void BM_Callback_CQ_Non_Polling(benchmark::State& state) { + int tag_size = state.range(0); + grpc_completion_queue* cc; + void* tags[tag_size]; + grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)]; + grpc_completion_queue_attributes attr; + unsigned i; + bool got_shutdown = false; + ShutdownCallback shutdown_cb(&got_shutdown); + + attr.version = 2; + attr.cq_completion_type = GRPC_CQ_CALLBACK; + attr.cq_shutdown_cb = &shutdown_cb; + while (state.KeepRunning()) { + int sumtags = 0; + int counter = 0; + { + // reset exec_ctx types + grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; + grpc_core::ExecCtx exec_ctx; + attr.cq_polling_type = GRPC_CQ_DEFAULT_POLLING; + cc = grpc_completion_queue_create( + grpc_completion_queue_factory_lookup(&attr), &attr, nullptr); + + for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { + tags[i] = + static_cast(grpc_core::New(&counter, i)); + sumtags += i; + } + + for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { + GPR_ASSERT(grpc_cq_begin_op(cc, tags[i])); + grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, + do_nothing_end_completion, nullptr, &completions[i]); + } + + shutdown_and_destroy(cc); + } + GPR_ASSERT(sumtags == counter); + GPR_ASSERT(got_shutdown); + got_shutdown = false; + } +} +BENCHMARK(BM_Callback_CQ_Non_Polling)->Range(1, 128 * 1024); + +} // namespace testing +} // namespace grpc + +// Some distros have RunSpecifiedBenchmarks under the benchmark namespace, +// and others do not. This allows us to support both modes. +namespace benchmark { +void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } +} // namespace benchmark + +int main(int argc, char** argv) { + ::benchmark::Initialize(&argc, argv); + ::grpc::testing::InitTest(&argc, &argv, false); + benchmark::RunTheBenchmarksNamespaced(); + return 0; +} From 8f0934d739c340824ff070c76c75000928fa83e5 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 1 May 2019 11:39:01 -0700 Subject: [PATCH 0093/1555] Another Cronet mulitple initialization problem --- .../tests/InteropTests/InteropTestsMultipleChannels.m | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m index c0beb107fad..506d7807de2 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m +++ b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m @@ -27,6 +27,7 @@ #import #import "InteropTestsBlockCallbacks.h" +#import "../EnableCronet" #define NSStringize_helper(x) #x #define NSStringize(x) @NSStringize_helper(x) @@ -88,10 +89,7 @@ dispatch_once_t initCronet; _remoteService = [RMTTestService serviceWithHost:kRemoteSSLHost callOptions:nil]; - dispatch_once(&initCronet, ^{ - [Cronet setHttp2Enabled:YES]; - [Cronet start]; - }); + enableCronet(); // Default stack with remote host GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; From a0cf95a88abc573882329ac9ea4e7d7544725b15 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 1 May 2019 11:40:11 -0700 Subject: [PATCH 0094/1555] Add log to debug --- src/objective-c/tests/EnableCronet.m | 1 + 1 file changed, 1 insertion(+) diff --git a/src/objective-c/tests/EnableCronet.m b/src/objective-c/tests/EnableCronet.m index ff6e4612d88..b618ec74706 100644 --- a/src/objective-c/tests/EnableCronet.m +++ b/src/objective-c/tests/EnableCronet.m @@ -24,6 +24,7 @@ void enableCronet(void) { static dispatch_once_t enableCronet; dispatch_once(&enableCronet, ^{ + NSLog(@"enableCronet()"); [Cronet setHttp2Enabled:YES]; [Cronet setSslKeyLogFileName:@"Documents/key"]; [Cronet enableTestCertVerifierForTesting]; From f9defc92794d2ee3bcd7db729bea77c0d06c206e Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 1 May 2019 13:12:32 -0700 Subject: [PATCH 0095/1555] prototype issue --- src/objective-c/tests/EnableCronet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/tests/EnableCronet.h b/src/objective-c/tests/EnableCronet.h index e544e76345d..720aace4075 100644 --- a/src/objective-c/tests/EnableCronet.h +++ b/src/objective-c/tests/EnableCronet.h @@ -25,7 +25,7 @@ extern "C" { /** * Enable Cronet for once. */ -void enableCronet(); +void enableCronet(void); #ifdef __cplusplus } From 926bbe3a2e3f94eec591fbf19795a28f598806c1 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Tue, 30 Apr 2019 18:47:16 -0400 Subject: [PATCH 0096/1555] Add a fast path in grpc_error_get_status() for GRPC_ERROR_NONE. In most of the cases, as we hope, RPCs shouldn't have errors. But, in grpc_error_get_status() we treat GRPC_ERROR_NONE similar to other errors, and waste quite a few cycles. This patch is part of a larger performance improvements. On client side, this particular code path accounts for 0.5%+. --- src/core/lib/transport/error_utils.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/core/lib/transport/error_utils.cc b/src/core/lib/transport/error_utils.cc index 558f1d494cd..eb4e8c3a282 100644 --- a/src/core/lib/transport/error_utils.cc +++ b/src/core/lib/transport/error_utils.cc @@ -48,6 +48,18 @@ void grpc_error_get_status(grpc_error* error, grpc_millis deadline, grpc_status_code* code, grpc_slice* slice, grpc_http2_error_code* http_error, const char** error_string) { + // Fast path: We expect no error. + if (GPR_LIKELY(error == GRPC_ERROR_NONE)) { + if (code != nullptr) *code = GRPC_STATUS_OK; + if (slice != nullptr) { + grpc_error_get_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, slice); + } + if (http_error != nullptr) { + *http_error = GRPC_HTTP2_NO_ERROR; + } + return; + } + // Start with the parent error and recurse through the tree of children // until we find the first one that has a status code. grpc_error* found_error = From bcbff503ec3f3afd87978822a29b19dc9b4fddf6 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 1 May 2019 14:20:26 -0700 Subject: [PATCH 0097/1555] nit --- src/objective-c/tests/InteropTests/InteropTests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 3204f689c48..91fdd0fd841 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -37,7 +37,7 @@ #import #import "InteropTestsBlockCallbacks.h" -#import "../enableCronet.h" +#import "../EnableCronet.h" #define TEST_TIMEOUT 32 From 4ca3431715e660a08d94e1776837269867768cf1 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 1 May 2019 15:48:11 -0700 Subject: [PATCH 0098/1555] nit fix --- .../tests/InteropTests/InteropTestsMultipleChannels.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m index 506d7807de2..58946825f98 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m +++ b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m @@ -27,7 +27,7 @@ #import #import "InteropTestsBlockCallbacks.h" -#import "../EnableCronet" +#import "../EnableCronet.h" #define NSStringize_helper(x) #x #define NSStringize(x) @NSStringize_helper(x) From 1f0476267b92943679bcedcdc0c520218dcc11f0 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Thu, 2 May 2019 13:55:15 -0400 Subject: [PATCH 0099/1555] Add a better comment and rename consume_first to remove_first. --- .../transport/chttp2/transport/frame_data.cc | 30 +++++++++---------- .../compression/stream_compression_gzip.cc | 4 +-- src/core/lib/iomgr/tcp_posix.cc | 2 +- .../security/transport/security_handshaker.cc | 2 +- src/core/lib/slice/slice_buffer.cc | 2 +- src/core/lib/slice/slice_internal.h | 7 +++-- test/core/slice/slice_buffer_test.cc | 6 ++-- 7 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/frame_data.cc b/src/core/ext/transport/chttp2/transport/frame_data.cc index 5a0492f72ab..3734c0150b7 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.cc +++ b/src/core/ext/transport/chttp2/transport/frame_data.cc @@ -112,14 +112,14 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( char* msg; if (cur == end) { - grpc_slice_buffer_consume_first(slices); + grpc_slice_buffer_remove_first(slices); continue; } switch (p->state) { case GRPC_CHTTP2_DATA_ERROR: p->state = GRPC_CHTTP2_DATA_ERROR; - grpc_slice_buffer_consume_first(slices); + grpc_slice_buffer_remove_first(slices); return GRPC_ERROR_REF(p->error); case GRPC_CHTTP2_DATA_FH_0: s->stats.incoming.framing_bytes++; @@ -144,12 +144,12 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( p->error = grpc_error_set_int(p->error, GRPC_ERROR_INT_OFFSET, cur - beg); p->state = GRPC_CHTTP2_DATA_ERROR; - grpc_slice_buffer_consume_first(slices); + grpc_slice_buffer_remove_first(slices); return GRPC_ERROR_REF(p->error); } if (++cur == end) { p->state = GRPC_CHTTP2_DATA_FH_1; - grpc_slice_buffer_consume_first(slices); + grpc_slice_buffer_remove_first(slices); continue; } /* fallthrough */ @@ -158,7 +158,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( p->frame_size = (static_cast(*cur)) << 24; if (++cur == end) { p->state = GRPC_CHTTP2_DATA_FH_2; - grpc_slice_buffer_consume_first(slices); + grpc_slice_buffer_remove_first(slices); continue; } /* fallthrough */ @@ -167,7 +167,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( p->frame_size |= (static_cast(*cur)) << 16; if (++cur == end) { p->state = GRPC_CHTTP2_DATA_FH_3; - grpc_slice_buffer_consume_first(slices); + grpc_slice_buffer_remove_first(slices); continue; } /* fallthrough */ @@ -176,7 +176,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( p->frame_size |= (static_cast(*cur)) << 8; if (++cur == end) { p->state = GRPC_CHTTP2_DATA_FH_4; - grpc_slice_buffer_consume_first(slices); + grpc_slice_buffer_remove_first(slices); continue; } /* fallthrough */ @@ -207,14 +207,14 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( grpc_slice_buffer_sub_first(slices, static_cast(cur - beg), static_cast(end - beg)); } else { - grpc_slice_buffer_consume_first(slices); + grpc_slice_buffer_remove_first(slices); } return GRPC_ERROR_NONE; case GRPC_CHTTP2_DATA_FRAME: { GPR_ASSERT(p->parsing_frame != nullptr); GPR_ASSERT(slice_out != nullptr); if (cur == end) { - grpc_slice_buffer_consume_first(slices); + grpc_slice_buffer_remove_first(slices); continue; } uint32_t remaining = static_cast(end - cur); @@ -225,17 +225,17 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( grpc_slice_sub(*slice, static_cast(cur - beg), static_cast(end - beg)), slice_out))) { - grpc_slice_buffer_consume_first(slices); + grpc_slice_buffer_remove_first(slices); return error; } if (GRPC_ERROR_NONE != (error = p->parsing_frame->Finished(GRPC_ERROR_NONE, true))) { - grpc_slice_buffer_consume_first(slices); + grpc_slice_buffer_remove_first(slices); return error; } p->parsing_frame = nullptr; p->state = GRPC_CHTTP2_DATA_FH_0; - grpc_slice_buffer_consume_first(slices); + grpc_slice_buffer_remove_first(slices); return GRPC_ERROR_NONE; } else if (remaining < p->frame_size) { s->stats.incoming.data_bytes += remaining; @@ -247,7 +247,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( return error; } p->frame_size -= remaining; - grpc_slice_buffer_consume_first(slices); + grpc_slice_buffer_remove_first(slices); return GRPC_ERROR_NONE; } else { GPR_ASSERT(remaining > p->frame_size); @@ -258,12 +258,12 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( *slice, static_cast(cur - beg), static_cast(cur + p->frame_size - beg)), slice_out)) { - grpc_slice_buffer_consume_first(slices); + grpc_slice_buffer_remove_first(slices); return error; } if (GRPC_ERROR_NONE != (error = p->parsing_frame->Finished(GRPC_ERROR_NONE, true))) { - grpc_slice_buffer_consume_first(slices); + grpc_slice_buffer_remove_first(slices); return error; } p->parsing_frame = nullptr; diff --git a/src/core/lib/compression/stream_compression_gzip.cc b/src/core/lib/compression/stream_compression_gzip.cc index f2c4bb92981..452b22b7628 100644 --- a/src/core/lib/compression/stream_compression_gzip.cc +++ b/src/core/lib/compression/stream_compression_gzip.cc @@ -60,7 +60,7 @@ static bool gzip_flate(grpc_stream_compression_context_gzip* ctx, if (r < 0 && r != Z_BUF_ERROR) { gpr_log(GPR_ERROR, "zlib error (%d)", r); grpc_slice_unref_internal(slice_out); - grpc_slice_buffer_consume_first(in); + grpc_slice_buffer_remove_first(in); return false; } else if (r == Z_STREAM_END && ctx->flate == inflate) { eoc = true; @@ -70,7 +70,7 @@ static bool gzip_flate(grpc_stream_compression_context_gzip* ctx, in, GRPC_SLICE_LENGTH(*slice) - ctx->zs.avail_in, GRPC_SLICE_LENGTH(*slice)); } else { - grpc_slice_buffer_consume_first(in); + grpc_slice_buffer_remove_first(in); } } if (flush != 0 && ctx->zs.avail_out > 0 && !eoc) { diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index 45af4931cf5..6c1955669cd 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -980,7 +980,7 @@ static bool tcp_flush(grpc_tcp* tcp, grpc_error** error) { // unref all and forget about all slices that have been written to this // point for (size_t idx = 0; idx < unwind_slice_idx; ++idx) { - grpc_slice_buffer_consume_first(tcp->outgoing_buffer); + grpc_slice_buffer_remove_first(tcp->outgoing_buffer); } return false; } else if (errno == EPIPE) { diff --git a/src/core/lib/security/transport/security_handshaker.cc b/src/core/lib/security/transport/security_handshaker.cc index 117e01a77a7..fdc64727b96 100644 --- a/src/core/lib/security/transport/security_handshaker.cc +++ b/src/core/lib/security/transport/security_handshaker.cc @@ -148,7 +148,7 @@ size_t SecurityHandshaker::MoveReadBufferIntoHandshakeBuffer() { memcpy(handshake_buffer_ + offset, GRPC_SLICE_START_PTR(*next_slice), GRPC_SLICE_LENGTH(*next_slice)); offset += GRPC_SLICE_LENGTH(*next_slice); - grpc_slice_buffer_consume_first(args_->read_buffer); + grpc_slice_buffer_remove_first(args_->read_buffer); } return bytes_in_read_buffer; } diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc index 083e35791db..29937bfc9bf 100644 --- a/src/core/lib/slice/slice_buffer.cc +++ b/src/core/lib/slice/slice_buffer.cc @@ -370,7 +370,7 @@ grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer* sb) { return slice; } -void grpc_slice_buffer_consume_first(grpc_slice_buffer* sb) { +void grpc_slice_buffer_remove_first(grpc_slice_buffer* sb) { GPR_DEBUG_ASSERT(sb->count > 0); sb->length -= GRPC_SLICE_LENGTH(sb->slices[0]); grpc_slice_unref_internal(sb->slices[0]); diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index e6563f4720d..aa7c3dbce96 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -242,14 +242,15 @@ void grpc_slice_buffer_partial_unref_internal(grpc_slice_buffer* sb, size_t idx); void grpc_slice_buffer_destroy_internal(grpc_slice_buffer* sb); -// Returns the first slice in the slice buffer. +// Returns a pointer to the first slice in the slice buffer without giving +// ownership to or a reference count on that slice. inline grpc_slice* grpc_slice_buffer_peek_first(grpc_slice_buffer* sb) { GPR_DEBUG_ASSERT(sb->count > 0); return &sb->slices[0]; } -// Consumes the first slice in the slice buffer. -void grpc_slice_buffer_consume_first(grpc_slice_buffer* sb); +// Removes the first slice from the slice buffer. +void grpc_slice_buffer_remove_first(grpc_slice_buffer* sb); // Calls grpc_slice_sub with the given parameters on the first slice. void grpc_slice_buffer_sub_first(grpc_slice_buffer* sb, size_t begin, diff --git a/test/core/slice/slice_buffer_test.cc b/test/core/slice/slice_buffer_test.cc index 5ad11a34563..7d4acfed003 100644 --- a/test/core/slice/slice_buffer_test.cc +++ b/test/core/slice/slice_buffer_test.cc @@ -130,19 +130,19 @@ void test_slice_buffer_first() { GPR_ASSERT(buf.count == 3); GPR_ASSERT(buf.length == 10); - grpc_slice_buffer_consume_first(&buf); + grpc_slice_buffer_remove_first(&buf); first = grpc_slice_buffer_peek_first(&buf); GPR_ASSERT(GPR_SLICE_LENGTH(*first) == GPR_SLICE_LENGTH(slices[1])); GPR_ASSERT(buf.count == 2); GPR_ASSERT(buf.length == 9); - grpc_slice_buffer_consume_first(&buf); + grpc_slice_buffer_remove_first(&buf); first = grpc_slice_buffer_peek_first(&buf); GPR_ASSERT(GPR_SLICE_LENGTH(*first) == GPR_SLICE_LENGTH(slices[2])); GPR_ASSERT(buf.count == 1); GPR_ASSERT(buf.length == 5); - grpc_slice_buffer_consume_first(&buf); + grpc_slice_buffer_remove_first(&buf); GPR_ASSERT(buf.count == 0); GPR_ASSERT(buf.length == 0); } From 25128d18c1517778f9ded375a368708554057bb6 Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Thu, 2 May 2019 15:14:44 -0700 Subject: [PATCH 0100/1555] Modify unary ping pong to send next rpc in callback function --- .../bm_callback_unary_ping_pong.cc | 56 ----------------- .../microbenchmarks/callback_test_service.cc | 9 ++- .../microbenchmarks/callback_test_service.h | 7 ++- .../callback_unary_ping_pong.h | 63 ++++++++++++------- 4 files changed, 53 insertions(+), 82 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc b/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc index bcbde5db035..1ba99f0a689 100644 --- a/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc +++ b/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc @@ -49,12 +49,6 @@ BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, MinInProcess, NoOpMutator, NoOpMutator) ->Apply(SweepSizesArgs); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, - NoOpMutator) - ->Apply(SweepSizesArgs); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, MinInProcessCHTTP2, NoOpMutator, - NoOpMutator) - ->Apply(SweepSizesArgs); // Client context with different metadata BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, @@ -86,35 +80,6 @@ BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, Client_AddMetadata, 1>, NoOpMutator) ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, - Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, - Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, - Client_AddMetadata, 1>, - NoOpMutator) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, - Client_AddMetadata, 2>, NoOpMutator) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, - Client_AddMetadata, 2>, NoOpMutator) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, - Client_AddMetadata, 2>, - NoOpMutator) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, - Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, - Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, - Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 0}); // Server context with different metadata BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, @@ -138,27 +103,6 @@ BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcess, NoOpMutator, Server_AddInitialMetadata, 100>) ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 0}); -BENCHMARK_TEMPLATE(BM_CallbackUnaryPingPong, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 100>) - ->Args({0, 0}); } // namespace testing } // namespace grpc diff --git a/test/cpp/microbenchmarks/callback_test_service.cc b/test/cpp/microbenchmarks/callback_test_service.cc index eebf6e31241..ffd87572db0 100644 --- a/test/cpp/microbenchmarks/callback_test_service.cc +++ b/test/cpp/microbenchmarks/callback_test_service.cc @@ -49,6 +49,13 @@ int GetIntValueFromMetadata( void CallbackStreamingTestService::Echo( ServerContext* context, const EchoRequest* request, EchoResponse* response, experimental::ServerCallbackRpcController* controller) { + int response_msgs_size = GetIntValueFromMetadata(kServerMessageSize, + context->client_metadata(), 0); + if (response_msgs_size > 0) { + response->set_message(std::string(response_msgs_size, 'a')); + } else { + response->set_message(""); + } controller->Finish(Status::OK); } @@ -62,7 +69,7 @@ CallbackStreamingTestService::BidiStream() { ctx_ = context; server_write_last_ = GetIntValueFromMetadata( kServerFinishAfterNReads, context->client_metadata(), 0); - message_size_ = GetIntValueFromMetadata(kServerResponseStreamsToSend, + message_size_ = GetIntValueFromMetadata(kServerMessageSize, context->client_metadata(), 0); StartRead(&request_); on_started_done_ = true; diff --git a/test/cpp/microbenchmarks/callback_test_service.h b/test/cpp/microbenchmarks/callback_test_service.h index aba5c0cfa67..622229d8800 100644 --- a/test/cpp/microbenchmarks/callback_test_service.h +++ b/test/cpp/microbenchmarks/callback_test_service.h @@ -30,7 +30,7 @@ namespace grpc { namespace testing { const char* const kServerFinishAfterNReads = "server_finish_after_n_reads"; -const char* const kServerResponseStreamsToSend = "server_responses_to_send"; +const char* const kServerMessageSize = "server_message_size"; class CallbackStreamingTestService : public EchoTestService::ExperimentalCallbackService { @@ -61,7 +61,10 @@ class BidiClient } void OnReadDone(bool ok) override { - if (ok && reads_complete_ < msgs_to_send_) { + if (!ok) { + return; + } + if (reads_complete_ < msgs_to_send_) { reads_complete_++; StartRead(response_); } diff --git a/test/cpp/microbenchmarks/callback_unary_ping_pong.h b/test/cpp/microbenchmarks/callback_unary_ping_pong.h index 19449341747..e4a48ad5883 100644 --- a/test/cpp/microbenchmarks/callback_unary_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_unary_ping_pong.h @@ -36,6 +36,32 @@ namespace testing { * BENCHMARKING KERNELS */ +// Send next rpc when callback function is evoked. +void SendCallbackUnaryPingPong(benchmark::State& state, EchoRequest* request, + EchoResponse* response, + EchoTestService::Stub* stub_, + bool &done, + std::mutex& mu, + std::condition_variable& cv) { + int response_msgs_size = state.range(1); + ClientContext* cli_ctx = new ClientContext(); + cli_ctx->AddMetadata(kServerMessageSize, + grpc::to_string(response_msgs_size)); + stub_->experimental_async()->Echo( + cli_ctx, request, response, + [&state, cli_ctx, request, response, stub_, &done, &mu, &cv](Status s) { + GPR_ASSERT(s.ok()); + if (state.KeepRunning()) { + SendCallbackUnaryPingPong(state, request, response, stub_, done, mu, cv); + } else { + std::lock_guard l(mu); + done = true; + cv.notify_one(); + } + delete cli_ctx; + }); +} + template static void BM_CallbackUnaryPingPong(benchmark::State& state) { int request_msgs_size = state.range(0); @@ -47,40 +73,31 @@ static void BM_CallbackUnaryPingPong(benchmark::State& state) { EchoRequest request; EchoResponse response; - if (state.range(0) > 0) { - request.set_message(std::string(state.range(0), 'a')); + if (request_msgs_size > 0) { + request.set_message(std::string(request_msgs_size, 'a')); } else { request.set_message(""); } - if (state.range(1) > 0) { - response.set_message(std::string(state.range(1), 'a')); - } else { - response.set_message(""); - } - while (state.KeepRunning()) { + std::mutex mu; + std::condition_variable cv; + bool done = false; + if (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); - ClientContext cli_ctx; - std::mutex mu; - std::condition_variable cv; - bool done = false; - stub_->experimental_async()->Echo(&cli_ctx, &request, &response, - [&done, &mu, &cv](Status s) { - GPR_ASSERT(s.ok()); - std::lock_guard l(mu); - done = true; - cv.notify_one(); - }); - std::unique_lock l(mu); - while (!done) { - cv.wait(l); - } + SendCallbackUnaryPingPong(state, &request, &response, stub_.get(), + done, mu, cv); + } + std::unique_lock l(mu); + while (!done) { + cv.wait(l); } fixture->Finish(state); fixture.reset(); state.SetBytesProcessed(request_msgs_size * state.iterations() + response_msgs_size * state.iterations()); } + + } // namespace testing } // namespace grpc From e18ed03c043d237b81bc32ddbd7d79593e2f7f19 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Thu, 2 May 2019 16:58:37 -0700 Subject: [PATCH 0101/1555] Made gRPC inialized after entering main function in microbenchmarks. --- test/cpp/microbenchmarks/bm_alarm.cc | 3 +-- test/cpp/microbenchmarks/bm_byte_buffer.cc | 4 +--- test/cpp/microbenchmarks/bm_call_create.cc | 3 +-- test/cpp/microbenchmarks/bm_channel.cc | 3 +-- test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 3 +-- test/cpp/microbenchmarks/bm_chttp2_transport.cc | 6 +++--- test/cpp/microbenchmarks/bm_closure.cc | 3 +-- test/cpp/microbenchmarks/bm_cq.cc | 3 +-- test/cpp/microbenchmarks/bm_error.cc | 3 +-- .../bm_fullstack_streaming_ping_pong.cc | 4 +--- .../bm_fullstack_streaming_pump.cc | 4 +--- .../cpp/microbenchmarks/bm_fullstack_trickle.cc | 8 +++----- .../bm_fullstack_unary_ping_pong.cc | 4 +--- test/cpp/microbenchmarks/bm_metadata.cc | 3 +-- test/cpp/microbenchmarks/bm_pollset.cc | 3 +-- test/cpp/microbenchmarks/bm_timer.cc | 3 +-- test/cpp/microbenchmarks/fullstack_fixtures.h | 4 ++-- test/cpp/microbenchmarks/helpers.cc | 17 ++++++++++++++++- test/cpp/microbenchmarks/helpers.h | 14 +++++--------- 19 files changed, 43 insertions(+), 52 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_alarm.cc b/test/cpp/microbenchmarks/bm_alarm.cc index 64aad6476de..d95771a57c6 100644 --- a/test/cpp/microbenchmarks/bm_alarm.cc +++ b/test/cpp/microbenchmarks/bm_alarm.cc @@ -30,8 +30,6 @@ namespace grpc { namespace testing { -auto& force_library_initialization = Library::get(); - static void BM_Alarm_Tag_Immediate(benchmark::State& state) { TrackCounters track_counters; CompletionQueue cq; @@ -57,6 +55,7 @@ void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } } // namespace benchmark int main(int argc, char** argv) { + LibraryInitializer libInit; ::benchmark::Initialize(&argc, argv); ::grpc::testing::InitTest(&argc, &argv, false); benchmark::RunTheBenchmarksNamespaced(); diff --git a/test/cpp/microbenchmarks/bm_byte_buffer.cc b/test/cpp/microbenchmarks/bm_byte_buffer.cc index 644c27c4873..595cc734b69 100644 --- a/test/cpp/microbenchmarks/bm_byte_buffer.cc +++ b/test/cpp/microbenchmarks/bm_byte_buffer.cc @@ -30,7 +30,6 @@ namespace grpc { namespace testing { static void BM_ByteBuffer_Copy(benchmark::State& state) { - Library::get(); int num_slices = state.range(0); size_t slice_size = state.range(1); std::vector slices; @@ -48,7 +47,6 @@ static void BM_ByteBuffer_Copy(benchmark::State& state) { BENCHMARK(BM_ByteBuffer_Copy)->Ranges({{1, 64}, {1, 1024 * 1024}}); static void BM_ByteBufferReader_Next(benchmark::State& state) { - Library::get(); const int num_slices = state.range(0); constexpr size_t kSliceSize = 16; std::vector slices; @@ -82,7 +80,6 @@ static void BM_ByteBufferReader_Next(benchmark::State& state) { BENCHMARK(BM_ByteBufferReader_Next)->Ranges({{64 * 1024, 1024 * 1024}}); static void BM_ByteBufferReader_Peek(benchmark::State& state) { - Library::get(); const int num_slices = state.range(0); constexpr size_t kSliceSize = 16; std::vector slices; @@ -125,6 +122,7 @@ void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } } // namespace benchmark int main(int argc, char** argv) { + LibraryInitializer libInit; ::benchmark::Initialize(&argc, argv); ::grpc::testing::InitTest(&argc, &argv, false); benchmark::RunTheBenchmarksNamespaced(); diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 53087a551b5..3bd1464b2aa 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -47,8 +47,6 @@ #include "test/cpp/microbenchmarks/helpers.h" #include "test/cpp/util/test_config.h" -auto& force_library_initialization = Library::get(); - void BM_Zalloc(benchmark::State& state) { // speed of light for call creation is zalloc, so benchmark a few interesting // sizes @@ -823,6 +821,7 @@ void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } } // namespace benchmark int main(int argc, char** argv) { + LibraryInitializer libInit; ::benchmark::Initialize(&argc, argv); ::grpc::testing::InitTest(&argc, &argv, false); benchmark::RunTheBenchmarksNamespaced(); diff --git a/test/cpp/microbenchmarks/bm_channel.cc b/test/cpp/microbenchmarks/bm_channel.cc index 15ac9975400..88856c3439b 100644 --- a/test/cpp/microbenchmarks/bm_channel.cc +++ b/test/cpp/microbenchmarks/bm_channel.cc @@ -23,8 +23,6 @@ #include "test/cpp/microbenchmarks/helpers.h" #include "test/cpp/util/test_config.h" -auto& force_library_initialization = Library::get(); - class ChannelDestroyerFixture { public: ChannelDestroyerFixture() {} @@ -83,6 +81,7 @@ void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } } // namespace benchmark int main(int argc, char** argv) { + LibraryInitializer libInit; ::benchmark::Initialize(&argc, argv); ::grpc::testing::InitTest(&argc, &argv, false); benchmark::RunTheBenchmarksNamespaced(); diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index 0521166db95..d0ed1da7671 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -36,8 +36,6 @@ #include "test/cpp/microbenchmarks/helpers.h" #include "test/cpp/util/test_config.h" -auto& force_library_initialization = Library::get(); - static grpc_slice MakeSlice(std::vector bytes) { grpc_slice s = grpc_slice_malloc(bytes.size()); uint8_t* p = GRPC_SLICE_START_PTR(s); @@ -928,6 +926,7 @@ void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } } // namespace benchmark int main(int argc, char** argv) { + LibraryInitializer libInit; ::benchmark::Initialize(&argc, argv); ::grpc::testing::InitTest(&argc, &argv, false); benchmark::RunTheBenchmarksNamespaced(); diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc index dc10fcb89d3..05504584c20 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc @@ -36,8 +36,6 @@ #include "test/cpp/microbenchmarks/helpers.h" #include "test/cpp/util/test_config.h" -auto& force_library_initialization = Library::get(); - //////////////////////////////////////////////////////////////////////////////// // Helper classes // @@ -57,7 +55,8 @@ class DummyEndpoint : public grpc_endpoint { get_fd, can_track_err}; grpc_endpoint::vtable = &my_vtable; - ru_ = grpc_resource_user_create(Library::get().rq(), "dummy_endpoint"); + ru_ = grpc_resource_user_create(LibraryInitializer::get().rq(), + "dummy_endpoint"); } void PushInput(grpc_slice slice) { @@ -642,6 +641,7 @@ void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } } // namespace benchmark int main(int argc, char** argv) { + LibraryInitializer libInit; ::benchmark::Initialize(&argc, argv); ::grpc::testing::InitTest(&argc, &argv, false); benchmark::RunTheBenchmarksNamespaced(); diff --git a/test/cpp/microbenchmarks/bm_closure.cc b/test/cpp/microbenchmarks/bm_closure.cc index e1f1e92d4d8..84b1c536bf0 100644 --- a/test/cpp/microbenchmarks/bm_closure.cc +++ b/test/cpp/microbenchmarks/bm_closure.cc @@ -30,8 +30,6 @@ #include "test/cpp/microbenchmarks/helpers.h" #include "test/cpp/util/test_config.h" -auto& force_library_initialization = Library::get(); - static void BM_NoOpExecCtx(benchmark::State& state) { TrackCounters track_counters; while (state.KeepRunning()) { @@ -425,6 +423,7 @@ void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } } // namespace benchmark int main(int argc, char** argv) { + LibraryInitializer libInit; ::benchmark::Initialize(&argc, argv); ::grpc::testing::InitTest(&argc, &argv, false); benchmark::RunTheBenchmarksNamespaced(); diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index a7cb939265f..263314deb93 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -32,8 +32,6 @@ namespace grpc { namespace testing { -auto& force_library_initialization = Library::get(); - static void BM_CreateDestroyCpp(benchmark::State& state) { TrackCounters track_counters; while (state.KeepRunning()) { @@ -156,6 +154,7 @@ void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } } // namespace benchmark int main(int argc, char** argv) { + LibraryInitializer libInit; ::benchmark::Initialize(&argc, argv); ::grpc::testing::InitTest(&argc, &argv, false); benchmark::RunTheBenchmarksNamespaced(); diff --git a/test/cpp/microbenchmarks/bm_error.cc b/test/cpp/microbenchmarks/bm_error.cc index ae557a580aa..a71817f7e54 100644 --- a/test/cpp/microbenchmarks/bm_error.cc +++ b/test/cpp/microbenchmarks/bm_error.cc @@ -27,8 +27,6 @@ #include "test/cpp/microbenchmarks/helpers.h" #include "test/cpp/util/test_config.h" -auto& force_library_initialization = Library::get(); - class ErrorDeleter { public: void operator()(grpc_error* error) { GRPC_ERROR_UNREF(error); } @@ -318,6 +316,7 @@ void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } } // namespace benchmark int main(int argc, char** argv) { + LibraryInitializer libInit; ::benchmark::Initialize(&argc, argv); ::grpc::testing::InitTest(&argc, &argv, false); benchmark::RunTheBenchmarksNamespaced(); diff --git a/test/cpp/microbenchmarks/bm_fullstack_streaming_ping_pong.cc b/test/cpp/microbenchmarks/bm_fullstack_streaming_ping_pong.cc index 34df77aca3c..60ca9a093ed 100644 --- a/test/cpp/microbenchmarks/bm_fullstack_streaming_ping_pong.cc +++ b/test/cpp/microbenchmarks/bm_fullstack_streaming_ping_pong.cc @@ -24,9 +24,6 @@ namespace grpc { namespace testing { -// force library initialization -auto& force_library_initialization = Library::get(); - /******************************************************************************* * CONFIGURATIONS */ @@ -122,6 +119,7 @@ void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } } // namespace benchmark int main(int argc, char** argv) { + LibraryInitializer libInit; ::benchmark::Initialize(&argc, argv); ::grpc::testing::InitTest(&argc, &argv, false); benchmark::RunTheBenchmarksNamespaced(); diff --git a/test/cpp/microbenchmarks/bm_fullstack_streaming_pump.cc b/test/cpp/microbenchmarks/bm_fullstack_streaming_pump.cc index da98f3cbcd4..d4533e6c78e 100644 --- a/test/cpp/microbenchmarks/bm_fullstack_streaming_pump.cc +++ b/test/cpp/microbenchmarks/bm_fullstack_streaming_pump.cc @@ -28,9 +28,6 @@ namespace testing { * CONFIGURATIONS */ -// force library initialization -auto& force_library_initialization = Library::get(); - BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, TCP) ->Range(0, 128 * 1024 * 1024); BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, UDS) @@ -72,6 +69,7 @@ void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } } // namespace benchmark int main(int argc, char** argv) { + LibraryInitializer libInit; ::benchmark::Initialize(&argc, argv); ::grpc::testing::InitTest(&argc, &argv, false); benchmark::RunTheBenchmarksNamespaced(); diff --git a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc index 1af92d2c80c..2d733bcaa42 100644 --- a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc +++ b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc @@ -214,8 +214,8 @@ class TrickledCHTTP2 : public EndpointPairFixture { static grpc_endpoint_pair MakeEndpoints(size_t kilobits, grpc_passthru_endpoint_stats* stats) { grpc_endpoint_pair p; - grpc_passthru_endpoint_create(&p.client, &p.server, Library::get().rq(), - stats); + grpc_passthru_endpoint_create(&p.client, &p.server, + LibraryInitializer::get().rq(), stats); double bytes_per_second = 125.0 * kilobits; p.client = grpc_trickle_endpoint_create(p.client, bytes_per_second); p.server = grpc_trickle_endpoint_create(p.server, bytes_per_second); @@ -235,9 +235,6 @@ class TrickledCHTTP2 : public EndpointPairFixture { } }; -// force library initialization -auto& force_library_initialization = Library::get(); - static void TrickleCQNext(TrickledCHTTP2* fixture, void** t, bool* ok, int64_t iteration) { while (true) { @@ -465,6 +462,7 @@ void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } } // namespace benchmark int main(int argc, char** argv) { + LibraryInitializer libInit; ::benchmark::Initialize(&argc, argv); ::grpc::testing::InitTest(&argc, &argv, false); grpc_timer_manager_set_threading(false); diff --git a/test/cpp/microbenchmarks/bm_fullstack_unary_ping_pong.cc b/test/cpp/microbenchmarks/bm_fullstack_unary_ping_pong.cc index d4bd58b9838..3e8f9344021 100644 --- a/test/cpp/microbenchmarks/bm_fullstack_unary_ping_pong.cc +++ b/test/cpp/microbenchmarks/bm_fullstack_unary_ping_pong.cc @@ -24,9 +24,6 @@ namespace grpc { namespace testing { -// force library initialization -auto& force_library_initialization = Library::get(); - /******************************************************************************* * CONFIGURATIONS */ @@ -174,6 +171,7 @@ void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } } // namespace benchmark int main(int argc, char** argv) { + LibraryInitializer libInit; ::benchmark::Initialize(&argc, argv); ::grpc::testing::InitTest(&argc, &argv, false); benchmark::RunTheBenchmarksNamespaced(); diff --git a/test/cpp/microbenchmarks/bm_metadata.cc b/test/cpp/microbenchmarks/bm_metadata.cc index 553b33c4028..ff8fe541dfc 100644 --- a/test/cpp/microbenchmarks/bm_metadata.cc +++ b/test/cpp/microbenchmarks/bm_metadata.cc @@ -27,8 +27,6 @@ #include "test/cpp/microbenchmarks/helpers.h" #include "test/cpp/util/test_config.h" -auto& force_library_initialization = Library::get(); - static void BM_SliceFromStatic(benchmark::State& state) { TrackCounters track_counters; while (state.KeepRunning()) { @@ -298,6 +296,7 @@ void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } } // namespace benchmark int main(int argc, char** argv) { + LibraryInitializer libInit; ::benchmark::Initialize(&argc, argv); ::grpc::testing::InitTest(&argc, &argv, false); benchmark::RunTheBenchmarksNamespaced(); diff --git a/test/cpp/microbenchmarks/bm_pollset.cc b/test/cpp/microbenchmarks/bm_pollset.cc index 050c7f7c171..f8e36f178e4 100644 --- a/test/cpp/microbenchmarks/bm_pollset.cc +++ b/test/cpp/microbenchmarks/bm_pollset.cc @@ -40,8 +40,6 @@ #include #endif -auto& force_library_initialization = Library::get(); - static void shutdown_ps(void* ps, grpc_error* error) { grpc_pollset_destroy(static_cast(ps)); } @@ -264,6 +262,7 @@ void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } } // namespace benchmark int main(int argc, char** argv) { + LibraryInitializer libInit; ::benchmark::Initialize(&argc, argv); ::grpc::testing::InitTest(&argc, &argv, false); benchmark::RunTheBenchmarksNamespaced(); diff --git a/test/cpp/microbenchmarks/bm_timer.cc b/test/cpp/microbenchmarks/bm_timer.cc index f5a411251b5..53aaead992d 100644 --- a/test/cpp/microbenchmarks/bm_timer.cc +++ b/test/cpp/microbenchmarks/bm_timer.cc @@ -32,8 +32,6 @@ namespace grpc { namespace testing { -auto& force_library_initialization = Library::get(); - struct TimerClosure { grpc_timer timer; grpc_closure closure; @@ -111,6 +109,7 @@ void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } } // namespace benchmark int main(int argc, char** argv) { + LibraryInitializer libInit; ::benchmark::Initialize(&argc, argv); ::grpc::testing::InitTest(&argc, &argv, false); benchmark::RunTheBenchmarksNamespaced(); diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h index 80ccab3e6ef..075a09c63eb 100644 --- a/test/cpp/microbenchmarks/fullstack_fixtures.h +++ b/test/cpp/microbenchmarks/fullstack_fixtures.h @@ -299,8 +299,8 @@ class InProcessCHTTP2WithExplicitStats : public EndpointPairFixture { static grpc_endpoint_pair MakeEndpoints(grpc_passthru_endpoint_stats* stats) { grpc_endpoint_pair p; - grpc_passthru_endpoint_create(&p.client, &p.server, Library::get().rq(), - stats); + grpc_passthru_endpoint_create(&p.client, &p.server, + LibraryInitializer::get().rq(), stats); return p; } }; diff --git a/test/cpp/microbenchmarks/helpers.cc b/test/cpp/microbenchmarks/helpers.cc index d4070de7481..7d78e21aef7 100644 --- a/test/cpp/microbenchmarks/helpers.cc +++ b/test/cpp/microbenchmarks/helpers.cc @@ -21,8 +21,12 @@ #include "test/cpp/microbenchmarks/helpers.h" static grpc::internal::GrpcLibraryInitializer g_gli_initializer; +static LibraryInitializer* g_libraryInitializer; + +LibraryInitializer::LibraryInitializer() { + GPR_ASSERT(g_libraryInitializer == nullptr); + g_libraryInitializer = this; -Library::Library() { g_gli_initializer.summon(); #ifdef GPR_LOW_LEVEL_COUNTERS grpc_memory_counters_init(); @@ -31,6 +35,17 @@ Library::Library() { rq_ = grpc_resource_quota_create("bm"); } +LibraryInitializer::~LibraryInitializer() { + g_libraryInitializer = nullptr; + init_lib_.shutdown(); + grpc_resource_quota_unref(rq_); +} + +LibraryInitializer& LibraryInitializer::get() { + GPR_ASSERT(g_libraryInitializer != nullptr); + return *g_libraryInitializer; +} + void TrackCounters::Finish(benchmark::State& state) { std::ostringstream out; for (const auto& l : labels_) { diff --git a/test/cpp/microbenchmarks/helpers.h b/test/cpp/microbenchmarks/helpers.h index 770966aa189..b712c85d354 100644 --- a/test/cpp/microbenchmarks/helpers.h +++ b/test/cpp/microbenchmarks/helpers.h @@ -29,20 +29,16 @@ #include #include -class Library { +class LibraryInitializer { public: - static Library& get() { - static Library lib; - return lib; - } + LibraryInitializer(); + ~LibraryInitializer(); grpc_resource_quota* rq() { return rq_; } + static LibraryInitializer& get(); + private: - Library(); - - ~Library() { init_lib_.shutdown(); } - grpc::internal::GrpcLibrary init_lib_; grpc_resource_quota* rq_; }; From 5748665bc546f8839ead6b5a92525960ff011ee7 Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Thu, 2 May 2019 17:21:55 -0700 Subject: [PATCH 0102/1555] Add callback completion queue and modify callback streaming ping pong --- CMakeLists.txt | 48 ++++++++++++ Makefile | 49 ++++++++++++ build.yaml | 23 ++++++ test/cpp/microbenchmarks/BUILD | 11 +++ .../bm_callback_streaming_ping_pong.cc | 74 +------------------ .../callback_streaming_ping_pong.h | 2 +- .../microbenchmarks/callback_test_service.cc | 52 ++++++------- .../microbenchmarks/callback_test_service.h | 7 +- .../generated/sources_and_headers.json | 21 ++++++ tools/run_tests/generated/tests.json | 26 +++++++ 10 files changed, 209 insertions(+), 104 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6eaa01c56d9..f36f436d0ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -556,6 +556,9 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx bm_call_create) endif() if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) +add_dependencies(buildtests_cxx bm_callback_cq) +endif() +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx bm_callback_streaming_ping_pong) endif() if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) @@ -11641,6 +11644,51 @@ target_link_libraries(bm_call_create ) +endif() +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) + +add_executable(bm_callback_cq + test/cpp/microbenchmarks/bm_callback_cq.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(bm_callback_cq + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(bm_callback_cq + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_benchmark + ${_gRPC_BENCHMARK_LIBRARIES} + grpc++_test_util_unsecure + grpc_test_util_unsecure + grpc++_unsecure + grpc_unsecure + gpr + grpc++_test_config + ${_gRPC_GFLAGS_LIBRARIES} +) + + endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index 698184ecafd..448d7167eb4 100644 --- a/Makefile +++ b/Makefile @@ -1162,6 +1162,7 @@ bm_alarm: $(BINDIR)/$(CONFIG)/bm_alarm bm_arena: $(BINDIR)/$(CONFIG)/bm_arena bm_byte_buffer: $(BINDIR)/$(CONFIG)/bm_byte_buffer bm_call_create: $(BINDIR)/$(CONFIG)/bm_call_create +bm_callback_cq: $(BINDIR)/$(CONFIG)/bm_callback_cq bm_callback_streaming_ping_pong: $(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong bm_callback_unary_ping_pong: $(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong bm_channel: $(BINDIR)/$(CONFIG)/bm_channel @@ -1640,6 +1641,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_arena \ $(BINDIR)/$(CONFIG)/bm_byte_buffer \ $(BINDIR)/$(CONFIG)/bm_call_create \ + $(BINDIR)/$(CONFIG)/bm_callback_cq \ $(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong \ $(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong \ $(BINDIR)/$(CONFIG)/bm_channel \ @@ -1786,6 +1788,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_arena \ $(BINDIR)/$(CONFIG)/bm_byte_buffer \ $(BINDIR)/$(CONFIG)/bm_call_create \ + $(BINDIR)/$(CONFIG)/bm_callback_cq \ $(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong \ $(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong \ $(BINDIR)/$(CONFIG)/bm_channel \ @@ -2238,6 +2241,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/bm_byte_buffer || ( echo test bm_byte_buffer failed ; exit 1 ) $(E) "[RUN] Testing bm_call_create" $(Q) $(BINDIR)/$(CONFIG)/bm_call_create || ( echo test bm_call_create failed ; exit 1 ) + $(E) "[RUN] Testing bm_callback_cq" + $(Q) $(BINDIR)/$(CONFIG)/bm_callback_cq || ( echo test bm_callback_cq failed ; exit 1 ) $(E) "[RUN] Testing bm_callback_streaming_ping_pong" $(Q) $(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong || ( echo test bm_callback_streaming_ping_pong failed ; exit 1 ) $(E) "[RUN] Testing bm_callback_unary_ping_pong" @@ -14568,6 +14573,50 @@ endif endif +BM_CALLBACK_CQ_SRC = \ + test/cpp/microbenchmarks/bm_callback_cq.cc \ + +BM_CALLBACK_CQ_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BM_CALLBACK_CQ_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/bm_callback_cq: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/bm_callback_cq: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/bm_callback_cq: $(PROTOBUF_DEP) $(BM_CALLBACK_CQ_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(BM_CALLBACK_CQ_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/bm_callback_cq + +endif + +endif + +$(BM_CALLBACK_CQ_OBJS): CPPFLAGS += -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX +$(OBJDIR)/$(CONFIG)/test/cpp/microbenchmarks/bm_callback_cq.o: $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a + +deps_bm_callback_cq: $(BM_CALLBACK_CQ_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(BM_CALLBACK_CQ_OBJS:.o=.dep) +endif +endif + + BM_CALLBACK_STREAMING_PING_PONG_SRC = \ test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc \ diff --git a/build.yaml b/build.yaml index 562b3216356..fc465dcb719 100644 --- a/build.yaml +++ b/build.yaml @@ -4040,6 +4040,29 @@ targets: - linux - posix uses_polling: false +- name: bm_callback_cq + build: test + language: c++ + src: + - test/cpp/microbenchmarks/bm_callback_cq.cc + deps: + - grpc_benchmark + - benchmark + - grpc++_test_util_unsecure + - grpc_test_util_unsecure + - grpc++_unsecure + - grpc_unsecure + - gpr + - grpc++_test_config + benchmark: true + defaults: benchmark + excluded_poll_engines: + - poll + platforms: + - mac + - linux + - posix + timeout_seconds: 1200 - name: bm_callback_streaming_ping_pong build: test language: c++ diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD index 116180d1688..0be64c3b319 100644 --- a/test/cpp/microbenchmarks/BUILD +++ b/test/cpp/microbenchmarks/BUILD @@ -276,3 +276,14 @@ grpc_cc_binary( tags = ["no_windows"], deps = [":callback_streaming_ping_pong_h"], ) + +grpc_cc_binary( + name = "bm_callback_cq", + testonly = 1, + srcs = ["bm_callback_cq.cc"], + language = "C++", + deps = [ + ":helpers", + "//test/cpp/util:test_util", + ], +) diff --git a/test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc b/test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc index f7e3469f2e4..cfdc0a0cab6 100644 --- a/test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc +++ b/test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc @@ -32,13 +32,11 @@ auto& force_library_initialization = Library::get(); // Replace "benchmark::internal::Benchmark" with "::testing::Benchmark" to use // internal microbenchmarking tooling static void StreamingPingPongMsgSizeArgs(benchmark::internal::Benchmark* b) { - int msg_size = 0; // base case: 0 byte ping-pong msgs b->Args({0, 1}); b->Args({0, 2}); - for (msg_size = 0; msg_size <= 128 * 1024 * 1024; - msg_size == 0 ? msg_size++ : msg_size *= 8) { + for (int msg_size = 1; msg_size <= 128 * 1024 * 1024; msg_size *= 8) { b->Args({msg_size, 1}); b->Args({msg_size, 2}); } @@ -47,13 +45,9 @@ static void StreamingPingPongMsgSizeArgs(benchmark::internal::Benchmark* b) { // Replace "benchmark::internal::Benchmark" with "::testing::Benchmark" to use // internal microbenchmarking tooling static void StreamingPingPongMsgsNumberArgs(benchmark::internal::Benchmark* b) { - int msg_number = 0; - - for (msg_number = 0; msg_number <= 128 * 1024; - msg_number == 0 ? msg_number++ : msg_number *= 8) { + for (int msg_number = 1; msg_number <= 256 * 1024; msg_number *= 8) { b->Args({0, msg_number}); - // 64 KiB same as the synthetic test configuration - b->Args({64 * 1024, msg_number}); + b->Args({1024, msg_number}); } } @@ -64,12 +58,6 @@ BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, MinInProcess, NoOpMutator, NoOpMutator) ->Apply(StreamingPingPongMsgSizeArgs); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, - NoOpMutator) - ->Apply(StreamingPingPongMsgSizeArgs); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, MinInProcessCHTTP2, NoOpMutator, - NoOpMutator) - ->Apply(StreamingPingPongMsgSizeArgs); // Streaming with different message number BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, @@ -78,43 +66,8 @@ BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, MinInProcess, NoOpMutator, NoOpMutator) ->Apply(StreamingPingPongMsgsNumberArgs); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, - NoOpMutator) - ->Apply(StreamingPingPongMsgsNumberArgs); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, MinInProcessCHTTP2, NoOpMutator, - NoOpMutator) - ->Apply(StreamingPingPongMsgsNumberArgs); // Client context with different metadata -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, - Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 1}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, - Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 1}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, - Client_AddMetadata, 1>, - NoOpMutator) - ->Args({0, 1}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, - Client_AddMetadata, 2>, NoOpMutator) - ->Args({0, 1}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, - Client_AddMetadata, 2>, NoOpMutator) - ->Args({0, 1}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, - Client_AddMetadata, 2>, - NoOpMutator) - ->Args({0, 1}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, - Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 1}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, - Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 1}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, - Client_AddMetadata, 1>, NoOpMutator) - ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, Client_AddMetadata, 1>, NoOpMutator) ->Args({0, 1}); @@ -146,27 +99,6 @@ BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, ->Args({0, 1}); // Server context with different metadata -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 1}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 1}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 1}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 1}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 1}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 1>) - ->Args({0, 1}); -BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcessCHTTP2, NoOpMutator, - Server_AddInitialMetadata, 100>) - ->Args({0, 1}); BENCHMARK_TEMPLATE(BM_CallbackBidiStreaming, InProcess, NoOpMutator, Server_AddInitialMetadata, 1>) ->Args({0, 1}); diff --git a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h index fc74e2757ba..a5064936f8f 100644 --- a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h @@ -54,7 +54,7 @@ static void BM_CallbackBidiStreaming(benchmark::State& state) { ClientContext cli_ctx; cli_ctx.AddMetadata(kServerFinishAfterNReads, grpc::to_string(max_ping_pongs)); - cli_ctx.AddMetadata(kServerResponseStreamsToSend, + cli_ctx.AddMetadata(kServerMessageSize, grpc::to_string(message_size)); BidiClient test{stub_.get(), &request, &response, &cli_ctx, max_ping_pongs}; test.Await(); diff --git a/test/cpp/microbenchmarks/callback_test_service.cc b/test/cpp/microbenchmarks/callback_test_service.cc index ffd87572db0..c104b7a8921 100644 --- a/test/cpp/microbenchmarks/callback_test_service.cc +++ b/test/cpp/microbenchmarks/callback_test_service.cc @@ -72,52 +72,48 @@ CallbackStreamingTestService::BidiStream() { message_size_ = GetIntValueFromMetadata(kServerMessageSize, context->client_metadata(), 0); StartRead(&request_); - on_started_done_ = true; } - void OnDone() override { delete this; } + void OnDone() override { + GPR_ASSERT(finished_); + delete this; + } void OnCancel() override {} void OnReadDone(bool ok) override { - if (ok) { - num_msgs_read_++; - if (message_size_ > 0) { - response_.set_message(std::string(message_size_, 'a')); - } else { - response_.set_message(""); - } - if (num_msgs_read_ == server_write_last_) { - StartWriteLast(&response_, WriteOptions()); - } else { - StartWrite(&response_); - return; - } + if (!ok) { + return; + } + num_msgs_read_++; + if (message_size_ > 0) { + response_.set_message(std::string(message_size_, 'a')); + } else { + response_.set_message(""); + } + if (num_msgs_read_ == server_write_last_) { + StartWriteLast(&response_, WriteOptions()); + } else { + StartWrite(&response_); } - FinishOnce(Status::OK); } void OnWriteDone(bool ok) override { - std::lock_guard l(finish_mu_); - if (!finished_) { - StartRead(&request_); + if (!ok) { + return; } - } - - private: - void FinishOnce(const Status& s) { - std::lock_guard l(finish_mu_); - if (!finished_) { - Finish(s); + if (num_msgs_read_ < server_write_last_) { + StartRead(&request_); + } else { + Finish(::grpc::Status::OK); finished_ = true; } } + private: ServerContext* ctx_; EchoRequest request_; EchoResponse response_; int num_msgs_read_{0}; int server_write_last_; int message_size_; - std::mutex finish_mu_; bool finished_{false}; - bool on_started_done_{false}; }; return new Reactor; diff --git a/test/cpp/microbenchmarks/callback_test_service.h b/test/cpp/microbenchmarks/callback_test_service.h index 622229d8800..2bad3dac264 100644 --- a/test/cpp/microbenchmarks/callback_test_service.h +++ b/test/cpp/microbenchmarks/callback_test_service.h @@ -56,7 +56,6 @@ class BidiClient msgs_to_send_{num_msgs_to_send} { stub->experimental_async()->BidiStream(context_, this); MaybeWrite(); - StartRead(response_); StartCall(); } @@ -64,9 +63,9 @@ class BidiClient if (!ok) { return; } - if (reads_complete_ < msgs_to_send_) { + if (ok && reads_complete_ < msgs_to_send_) { reads_complete_++; - StartRead(response_); + MaybeWrite(); } } @@ -75,7 +74,7 @@ class BidiClient return; } writes_complete_++; - MaybeWrite(); + StartRead(response_); } void OnDone(const Status& s) override { diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index c87b79e624b..6803c495654 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -2776,6 +2776,27 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "benchmark", + "gpr", + "grpc++_test_config", + "grpc++_test_util_unsecure", + "grpc++_unsecure", + "grpc_benchmark", + "grpc_test_util_unsecure", + "grpc_unsecure" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "bm_callback_cq", + "src": [ + "test/cpp/microbenchmarks/bm_callback_cq.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "benchmark", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index d442c3b9744..fce6f3c37ae 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -3479,6 +3479,32 @@ ], "uses_polling": false }, + { + "args": [], + "benchmark": true, + "ci_platforms": [ + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "excluded_poll_engines": [ + "poll" + ], + "flaky": false, + "gtest": false, + "language": "c++", + "name": "bm_callback_cq", + "platforms": [ + "linux", + "mac", + "posix" + ], + "timeout_seconds": 1200, + "uses_polling": true + }, { "args": [], "benchmark": true, From 927c2f2c618dbfc2ec0988e1abcfd9d5452f2163 Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Thu, 2 May 2019 17:24:54 -0700 Subject: [PATCH 0103/1555] Change format --- test/cpp/microbenchmarks/bm_callback_cq.cc | 26 ++++++------- .../callback_streaming_ping_pong.h | 9 ++--- .../microbenchmarks/callback_test_service.cc | 4 +- .../callback_unary_ping_pong.h | 39 +++++++++---------- 4 files changed, 35 insertions(+), 43 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_callback_cq.cc b/test/cpp/microbenchmarks/bm_callback_cq.cc index bc2e4cef969..1a76e85e6f3 100644 --- a/test/cpp/microbenchmarks/bm_callback_cq.cc +++ b/test/cpp/microbenchmarks/bm_callback_cq.cc @@ -27,10 +27,10 @@ #include "test/cpp/microbenchmarks/helpers.h" #include "test/cpp/util/test_config.h" -#include "src/core/lib/surface/completion_queue.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/iomgr.h" +#include "src/core/lib/surface/completion_queue.h" namespace grpc { namespace testing { @@ -43,8 +43,7 @@ class TagCallback : public grpc_experimental_completion_queue_functor { functor_run = &TagCallback::Run; } ~TagCallback() {} - static void Run(grpc_experimental_completion_queue_functor* cb, - int ok) { + static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { GPR_ASSERT(static_cast(ok)); auto* callback = static_cast(cb); *callback->counter_ += callback->tag_; @@ -104,15 +103,14 @@ static void BM_Callback_CQ_Default_Polling(benchmark::State& state) { grpc_completion_queue_factory_lookup(&attr), &attr, nullptr); for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { - tags[i] = - static_cast(grpc_core::New(&counter, i)); + tags[i] = static_cast(grpc_core::New(&counter, i)); sumtags += i; } for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { GPR_ASSERT(grpc_cq_begin_op(cc, tags[i])); - grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, - do_nothing_end_completion, nullptr, &completions[i]); + grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, do_nothing_end_completion, + nullptr, &completions[i]); } shutdown_and_destroy(cc); @@ -149,15 +147,14 @@ static void BM_Callback_CQ_Non_Listening(benchmark::State& state) { grpc_completion_queue_factory_lookup(&attr), &attr, nullptr); for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { - tags[i] = - static_cast(grpc_core::New(&counter, i)); + tags[i] = static_cast(grpc_core::New(&counter, i)); sumtags += i; } for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { GPR_ASSERT(grpc_cq_begin_op(cc, tags[i])); - grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, - do_nothing_end_completion, nullptr, &completions[i]); + grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, do_nothing_end_completion, + nullptr, &completions[i]); } shutdown_and_destroy(cc); @@ -194,15 +191,14 @@ static void BM_Callback_CQ_Non_Polling(benchmark::State& state) { grpc_completion_queue_factory_lookup(&attr), &attr, nullptr); for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { - tags[i] = - static_cast(grpc_core::New(&counter, i)); + tags[i] = static_cast(grpc_core::New(&counter, i)); sumtags += i; } for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { GPR_ASSERT(grpc_cq_begin_op(cc, tags[i])); - grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, - do_nothing_end_completion, nullptr, &completions[i]); + grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, do_nothing_end_completion, + nullptr, &completions[i]); } shutdown_and_destroy(cc); diff --git a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h index a5064936f8f..f7cfd06d7e7 100644 --- a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h @@ -53,16 +53,15 @@ static void BM_CallbackBidiStreaming(benchmark::State& state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); ClientContext cli_ctx; cli_ctx.AddMetadata(kServerFinishAfterNReads, - grpc::to_string(max_ping_pongs)); - cli_ctx.AddMetadata(kServerMessageSize, - grpc::to_string(message_size)); + grpc::to_string(max_ping_pongs)); + cli_ctx.AddMetadata(kServerMessageSize, grpc::to_string(message_size)); BidiClient test{stub_.get(), &request, &response, &cli_ctx, max_ping_pongs}; test.Await(); } fixture->Finish(state); fixture.reset(); - state.SetBytesProcessed(2 * message_size * max_ping_pongs - * state.iterations()); + state.SetBytesProcessed(2 * message_size * max_ping_pongs * + state.iterations()); } } // namespace testing diff --git a/test/cpp/microbenchmarks/callback_test_service.cc b/test/cpp/microbenchmarks/callback_test_service.cc index c104b7a8921..328b9254869 100644 --- a/test/cpp/microbenchmarks/callback_test_service.cc +++ b/test/cpp/microbenchmarks/callback_test_service.cc @@ -49,8 +49,8 @@ int GetIntValueFromMetadata( void CallbackStreamingTestService::Echo( ServerContext* context, const EchoRequest* request, EchoResponse* response, experimental::ServerCallbackRpcController* controller) { - int response_msgs_size = GetIntValueFromMetadata(kServerMessageSize, - context->client_metadata(), 0); + int response_msgs_size = GetIntValueFromMetadata( + kServerMessageSize, context->client_metadata(), 0); if (response_msgs_size > 0) { response->set_message(std::string(response_msgs_size, 'a')); } else { diff --git a/test/cpp/microbenchmarks/callback_unary_ping_pong.h b/test/cpp/microbenchmarks/callback_unary_ping_pong.h index e4a48ad5883..065ca689bb8 100644 --- a/test/cpp/microbenchmarks/callback_unary_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_unary_ping_pong.h @@ -39,27 +39,25 @@ namespace testing { // Send next rpc when callback function is evoked. void SendCallbackUnaryPingPong(benchmark::State& state, EchoRequest* request, EchoResponse* response, - EchoTestService::Stub* stub_, - bool &done, - std::mutex& mu, - std::condition_variable& cv) { + EchoTestService::Stub* stub_, bool& done, + std::mutex& mu, std::condition_variable& cv) { int response_msgs_size = state.range(1); ClientContext* cli_ctx = new ClientContext(); - cli_ctx->AddMetadata(kServerMessageSize, - grpc::to_string(response_msgs_size)); + cli_ctx->AddMetadata(kServerMessageSize, grpc::to_string(response_msgs_size)); stub_->experimental_async()->Echo( - cli_ctx, request, response, - [&state, cli_ctx, request, response, stub_, &done, &mu, &cv](Status s) { - GPR_ASSERT(s.ok()); - if (state.KeepRunning()) { - SendCallbackUnaryPingPong(state, request, response, stub_, done, mu, cv); - } else { - std::lock_guard l(mu); - done = true; - cv.notify_one(); - } - delete cli_ctx; - }); + cli_ctx, request, response, + [&state, cli_ctx, request, response, stub_, &done, &mu, &cv](Status s) { + GPR_ASSERT(s.ok()); + if (state.KeepRunning()) { + SendCallbackUnaryPingPong(state, request, response, stub_, done, mu, + cv); + } else { + std::lock_guard l(mu); + done = true; + cv.notify_one(); + } + delete cli_ctx; + }); } template @@ -84,8 +82,8 @@ static void BM_CallbackUnaryPingPong(benchmark::State& state) { bool done = false; if (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); - SendCallbackUnaryPingPong(state, &request, &response, stub_.get(), - done, mu, cv); + SendCallbackUnaryPingPong(state, &request, &response, stub_.get(), done, mu, + cv); } std::unique_lock l(mu); while (!done) { @@ -97,7 +95,6 @@ static void BM_CallbackUnaryPingPong(benchmark::State& state) { response_msgs_size * state.iterations()); } - } // namespace testing } // namespace grpc From db1ccad0399fd57bcf0ad3b6c3d40b3a47979abc Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 2 May 2019 18:03:02 -0700 Subject: [PATCH 0104/1555] Service Config Changes to set channel in transient failure on invalid service config --- CMakeLists.txt | 48 ++ Makefile | 52 +++ build.yaml | 13 + .../filters/client_channel/client_channel.cc | 12 +- .../resolver/dns/c_ares/dns_resolver_ares.cc | 24 +- .../client_channel/resolver_result_parsing.cc | 17 +- .../client_channel/resolver_result_parsing.h | 9 + .../client_channel/resolving_lb_policy.cc | 10 +- .../client_channel/resolving_lb_policy.h | 3 +- test/cpp/end2end/BUILD | 21 + .../end2end/service_config_end2end_test.cc | 442 ++++++++++++++++++ .../generated/sources_and_headers.json | 22 + tools/run_tests/generated/tests.json | 24 + 13 files changed, 683 insertions(+), 14 deletions(-) create mode 100644 test/cpp/end2end/service_config_end2end_test.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d9a411b134..42ea919f4a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -703,6 +703,7 @@ add_dependencies(buildtests_cxx server_crash_test_client) add_dependencies(buildtests_cxx server_early_return_test) add_dependencies(buildtests_cxx server_interceptors_end2end_test) add_dependencies(buildtests_cxx server_request_call_test) +add_dependencies(buildtests_cxx service_config_end2end_test) add_dependencies(buildtests_cxx service_config_test) add_dependencies(buildtests_cxx shutdown_test) add_dependencies(buildtests_cxx slice_hash_table_test) @@ -15936,6 +15937,53 @@ target_link_libraries(server_request_call_test ) +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + +add_executable(service_config_end2end_test + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.grpc.pb.h + test/cpp/end2end/service_config_end2end_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + +protobuf_generate_grpc_cpp( + src/proto/grpc/lb/v1/load_balancer.proto +) + +target_include_directories(service_config_end2end_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(service_config_end2end_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc++_test_util + grpc_test_util + grpc++ + grpc + gpr + ${_gRPC_GFLAGS_LIBRARIES} +) + + endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index 91ddebc7c25..b605550a38a 100644 --- a/Makefile +++ b/Makefile @@ -1265,6 +1265,7 @@ server_crash_test_client: $(BINDIR)/$(CONFIG)/server_crash_test_client server_early_return_test: $(BINDIR)/$(CONFIG)/server_early_return_test server_interceptors_end2end_test: $(BINDIR)/$(CONFIG)/server_interceptors_end2end_test server_request_call_test: $(BINDIR)/$(CONFIG)/server_request_call_test +service_config_end2end_test: $(BINDIR)/$(CONFIG)/service_config_end2end_test service_config_test: $(BINDIR)/$(CONFIG)/service_config_test shutdown_test: $(BINDIR)/$(CONFIG)/shutdown_test slice_hash_table_test: $(BINDIR)/$(CONFIG)/slice_hash_table_test @@ -1736,6 +1737,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/server_early_return_test \ $(BINDIR)/$(CONFIG)/server_interceptors_end2end_test \ $(BINDIR)/$(CONFIG)/server_request_call_test \ + $(BINDIR)/$(CONFIG)/service_config_end2end_test \ $(BINDIR)/$(CONFIG)/service_config_test \ $(BINDIR)/$(CONFIG)/shutdown_test \ $(BINDIR)/$(CONFIG)/slice_hash_table_test \ @@ -1882,6 +1884,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/server_early_return_test \ $(BINDIR)/$(CONFIG)/server_interceptors_end2end_test \ $(BINDIR)/$(CONFIG)/server_request_call_test \ + $(BINDIR)/$(CONFIG)/service_config_end2end_test \ $(BINDIR)/$(CONFIG)/service_config_test \ $(BINDIR)/$(CONFIG)/shutdown_test \ $(BINDIR)/$(CONFIG)/slice_hash_table_test \ @@ -2402,6 +2405,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/server_interceptors_end2end_test || ( echo test server_interceptors_end2end_test failed ; exit 1 ) $(E) "[RUN] Testing server_request_call_test" $(Q) $(BINDIR)/$(CONFIG)/server_request_call_test || ( echo test server_request_call_test failed ; exit 1 ) + $(E) "[RUN] Testing service_config_end2end_test" + $(Q) $(BINDIR)/$(CONFIG)/service_config_end2end_test || ( echo test service_config_end2end_test failed ; exit 1 ) $(E) "[RUN] Testing service_config_test" $(Q) $(BINDIR)/$(CONFIG)/service_config_test || ( echo test service_config_test failed ; exit 1 ) $(E) "[RUN] Testing shutdown_test" @@ -18895,6 +18900,53 @@ endif $(OBJDIR)/$(CONFIG)/test/cpp/server/server_request_call_test.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc +SERVICE_CONFIG_END2END_TEST_SRC = \ + $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc \ + test/cpp/end2end/service_config_end2end_test.cc \ + +SERVICE_CONFIG_END2END_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SERVICE_CONFIG_END2END_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/service_config_end2end_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/service_config_end2end_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/service_config_end2end_test: $(PROTOBUF_DEP) $(SERVICE_CONFIG_END2END_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(SERVICE_CONFIG_END2END_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/service_config_end2end_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/src/proto/grpc/lb/v1/load_balancer.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + +$(OBJDIR)/$(CONFIG)/test/cpp/end2end/service_config_end2end_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_service_config_end2end_test: $(SERVICE_CONFIG_END2END_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(SERVICE_CONFIG_END2END_TEST_OBJS:.o=.dep) +endif +endif +$(OBJDIR)/$(CONFIG)/test/cpp/end2end/service_config_end2end_test.o: $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc + + SERVICE_CONFIG_TEST_SRC = \ test/core/client_channel/service_config_test.cc \ diff --git a/build.yaml b/build.yaml index e56284d4d3c..46b016c6be4 100644 --- a/build.yaml +++ b/build.yaml @@ -5520,6 +5520,19 @@ targets: - grpc++_unsecure - grpc_unsecure - gpr +- name: service_config_end2end_test + gtest: true + build: test + language: c++ + src: + - src/proto/grpc/lb/v1/load_balancer.proto + - test/cpp/end2end/service_config_end2end_test.cc + deps: + - grpc++_test_util + - grpc_test_util + - grpc++ + - grpc + - gpr - name: service_config_test gtest: true build: test diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 248e7811bba..6aa1d615b7f 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -224,7 +224,8 @@ class ChannelData { static bool ProcessResolverResultLocked( void* arg, const Resolver::Result& result, const char** lb_policy_name, - RefCountedPtr* lb_policy_config); + RefCountedPtr* lb_policy_config, + grpc_error** service_config_error); grpc_error* DoPingLocked(grpc_transport_op* op); @@ -1132,9 +1133,16 @@ ChannelData::~ChannelData() { // resolver result update. bool ChannelData::ProcessResolverResultLocked( void* arg, const Resolver::Result& result, const char** lb_policy_name, - RefCountedPtr* lb_policy_config) { + RefCountedPtr* lb_policy_config, + grpc_error** service_config_error) { ChannelData* chand = static_cast(arg); ProcessedResolverResult resolver_result(result); + + *service_config_error = resolver_result.service_config_error(); + if (*service_config_error != GRPC_ERROR_NONE) { + // We got an invalid service config. + return false; + } char* service_config_json = gpr_strdup(resolver_result.service_config_json()); if (grpc_client_channel_routing_trace.enabled()) { gpr_log(GPR_INFO, "chand=%p: resolver returned service config: \"%s\"", diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index 6994f63bee4..0f11eeda39c 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -110,6 +110,8 @@ class AresDnsResolver : public Resolver { UniquePtr addresses_; /// currently resolving service config char* service_config_json_ = nullptr; + /// last valid service config + RefCountedPtr saved_service_config_; // has shutdown been initiated bool shutdown_initiated_ = false; // timeout in milliseconds for active DNS queries @@ -310,13 +312,29 @@ void AresDnsResolver::OnResolvedLocked(void* arg, grpc_error* error) { GRPC_CARES_TRACE_LOG("resolver:%p selected service config choice: %s", r, service_config_string); grpc_error* service_config_error = GRPC_ERROR_NONE; - result.service_config = + auto new_service_config = ServiceConfig::Create(service_config_string, &service_config_error); - // Error is currently unused. - GRPC_ERROR_UNREF(service_config_error); + if (service_config_error == GRPC_ERROR_NONE) { + // Valid service config receivd + r->saved_service_config_ = std::move(new_service_config); + } else { + if (r->saved_service_config_ != nullptr) { + // Ignore the new service config error, since we have a previously + // saved service config + GRPC_ERROR_UNREF(service_config_error); + } else { + // No previously valid service config found. + // service_config_error is passed to the channel. + result.service_config_error = service_config_error; + } + } } gpr_free(service_config_string); + } else { + // No service config received + r->saved_service_config_.reset(); } + result.service_config = r->saved_service_config_; result.args = grpc_channel_args_copy(r->channel_args_); r->result_handler()->ReturnResult(std::move(result)); r->addresses_.reset(); diff --git a/src/core/ext/filters/client_channel/resolver_result_parsing.cc b/src/core/ext/filters/client_channel/resolver_result_parsing.cc index 452dea6a0f7..6b3d26c32b8 100644 --- a/src/core/ext/filters/client_channel/resolver_result_parsing.cc +++ b/src/core/ext/filters/client_channel/resolver_result_parsing.cc @@ -61,17 +61,24 @@ void ClientChannelServiceConfigParser::Register() { ProcessedResolverResult::ProcessedResolverResult( const Resolver::Result& resolver_result) : service_config_(resolver_result.service_config) { - // If resolver did not return a service config, use the default + // If resolver did not return a service config or returned an invalid service config, use the default // specified via the client API. if (service_config_ == nullptr) { const char* service_config_json = grpc_channel_arg_get_string( grpc_channel_args_find(resolver_result.args, GRPC_ARG_SERVICE_CONFIG)); if (service_config_json != nullptr) { - grpc_error* error = GRPC_ERROR_NONE; - service_config_ = ServiceConfig::Create(service_config_json, &error); - // Error is currently unused. - GRPC_ERROR_UNREF(error); + service_config_ = + ServiceConfig::Create(service_config_json, &service_config_error_); + } else { + service_config_error_ = GRPC_ERROR_REF(resolver_result.service_config_error); } + } else { + service_config_error_ = + GRPC_ERROR_REF(resolver_result.service_config_error); + } + if (service_config_error_ != GRPC_ERROR_NONE) { + // We got an invalid service config. Don't process any further. + return; } // Process service config. const ClientChannelGlobalParsedObject* parsed_object = nullptr; diff --git a/src/core/ext/filters/client_channel/resolver_result_parsing.h b/src/core/ext/filters/client_channel/resolver_result_parsing.h index 7307149496f..3845aab5b25 100644 --- a/src/core/ext/filters/client_channel/resolver_result_parsing.h +++ b/src/core/ext/filters/client_channel/resolver_result_parsing.h @@ -127,6 +127,8 @@ class ProcessedResolverResult { // for later consumption. ProcessedResolverResult(const Resolver::Result& resolver_result); + ~ProcessedResolverResult() { GRPC_ERROR_UNREF(service_config_error_); } + // Getters. Any managed object's ownership is transferred. const char* service_config_json() { return service_config_json_; } @@ -144,6 +146,12 @@ class ProcessedResolverResult { const char* health_check_service_name() { return health_check_service_name_; } + grpc_error* service_config_error() { + grpc_error* return_error = service_config_error_; + service_config_error_ = GRPC_ERROR_NONE; + return return_error; + } + private: // Finds the service config; extracts LB config and (maybe) retry throttle // params from it. @@ -167,6 +175,7 @@ class ProcessedResolverResult { // Service config. const char* service_config_json_ = nullptr; RefCountedPtr service_config_; + grpc_error* service_config_error_ = GRPC_ERROR_NONE; // LB policy. UniquePtr lb_policy_name_; RefCountedPtr lb_policy_config_; diff --git a/src/core/ext/filters/client_channel/resolving_lb_policy.cc b/src/core/ext/filters/client_channel/resolving_lb_policy.cc index 193c9e256ed..a0d5d02a6d4 100644 --- a/src/core/ext/filters/client_channel/resolving_lb_policy.cc +++ b/src/core/ext/filters/client_channel/resolving_lb_policy.cc @@ -533,9 +533,13 @@ void ResolvingLoadBalancingPolicy::OnResolverResultChangedLocked( RefCountedPtr lb_policy_config; bool service_config_changed = false; if (process_resolver_result_ != nullptr) { - service_config_changed = - process_resolver_result_(process_resolver_result_user_data_, result, - &lb_policy_name, &lb_policy_config); + grpc_error* service_config_error = GRPC_ERROR_NONE; + service_config_changed = process_resolver_result_( + process_resolver_result_user_data_, result, &lb_policy_name, + &lb_policy_config, &service_config_error); + if (service_config_error != GRPC_ERROR_NONE) { + return OnResolverError(service_config_error); + } } else { lb_policy_name = child_policy_name_.get(); lb_policy_config = child_lb_config_; diff --git a/src/core/ext/filters/client_channel/resolving_lb_policy.h b/src/core/ext/filters/client_channel/resolving_lb_policy.h index dd8a1de6c7a..fa609aac5f2 100644 --- a/src/core/ext/filters/client_channel/resolving_lb_policy.h +++ b/src/core/ext/filters/client_channel/resolving_lb_policy.h @@ -68,7 +68,8 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy { typedef bool (*ProcessResolverResultCallback)( void* user_data, const Resolver::Result& result, const char** lb_policy_name, - RefCountedPtr* lb_policy_config); + RefCountedPtr* lb_policy_config, + grpc_error** service_config_error); // If error is set when this returns, then construction failed, and // the caller may not use the new object. ResolvingLoadBalancingPolicy( diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD index 56fc5e06008..d211a9e8441 100644 --- a/test/cpp/end2end/BUILD +++ b/test/cpp/end2end/BUILD @@ -423,6 +423,27 @@ grpc_cc_test( ], ) +grpc_cc_test( + name = "service_config_end2end_test", + srcs = ["service_config_end2end_test.cc"], + external_deps = [ + "gmock", + "gtest", + ], + deps = [ + ":test_service_impl", + "//:gpr", + "//:grpc", + "//:grpc++", + "//src/proto/grpc/testing:echo_messages_proto", + "//src/proto/grpc/testing:echo_proto", + "//src/proto/grpc/testing/duplicate:echo_duplicate_proto", + "//test/core/util:grpc_test_util", + "//test/core/util:test_lb_policies", + "//test/cpp/util:test_util", + ], +) + grpc_cc_test( name = "grpclb_end2end_test", srcs = ["grpclb_end2end_test.cc"], diff --git a/test/cpp/end2end/service_config_end2end_test.cc b/test/cpp/end2end/service_config_end2end_test.cc new file mode 100644 index 00000000000..cf0c6d259c1 --- /dev/null +++ b/test/cpp/end2end/service_config_end2end_test.cc @@ -0,0 +1,442 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "src/core/ext/filters/client_channel/backup_poller.h" +#include "src/core/ext/filters/client_channel/global_subchannel_pool.h" +#include "src/core/ext/filters/client_channel/parse_address.h" +#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" +#include "src/core/ext/filters/client_channel/server_address.h" +#include "src/core/lib/backoff/backoff.h" +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gprpp/debug_location.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" +#include "src/core/lib/iomgr/tcp_client.h" +#include "src/core/lib/security/credentials/fake/fake_credentials.h" +#include "src/cpp/client/secure_credentials.h" +#include "src/cpp/server/secure_server_credentials.h" + +#include "src/proto/grpc/testing/echo.grpc.pb.h" +#include "test/core/util/port.h" +#include "test/core/util/test_config.h" +#include "test/core/util/test_lb_policies.h" +#include "test/cpp/end2end/test_service_impl.h" + +#include +#include + +using grpc::testing::EchoRequest; +using grpc::testing::EchoResponse; +using std::chrono::system_clock; + +namespace grpc { +namespace testing { +namespace { + +// Subclass of TestServiceImpl that increments a request counter for +// every call to the Echo RPC. +class MyTestServiceImpl : public TestServiceImpl { + public: + MyTestServiceImpl() : request_count_(0) {} + + Status Echo(ServerContext* context, const EchoRequest* request, + EchoResponse* response) override { + { + grpc::internal::MutexLock lock(&mu_); + ++request_count_; + } + AddClient(context->peer()); + return TestServiceImpl::Echo(context, request, response); + } + + int request_count() { + grpc::internal::MutexLock lock(&mu_); + return request_count_; + } + + void ResetCounters() { + grpc::internal::MutexLock lock(&mu_); + request_count_ = 0; + } + + std::set clients() { + grpc::internal::MutexLock lock(&clients_mu_); + return clients_; + } + + private: + void AddClient(const grpc::string& client) { + grpc::internal::MutexLock lock(&clients_mu_); + clients_.insert(client); + } + + grpc::internal::Mutex mu_; + int request_count_; + grpc::internal::Mutex clients_mu_; + std::set clients_; +}; + +class ServiceConfigEnd2endTest : public ::testing::Test { + protected: + ServiceConfigEnd2endTest() + : server_host_("localhost"), + kRequestMessage_("Live long and prosper."), + creds_(new SecureChannelCredentials( + grpc_fake_transport_security_credentials_create())) { + // Make the backup poller poll very frequently in order to pick up + // updates from all the subchannels's FDs. + GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + } + + void SetUp() override { + grpc_init(); + response_generator_ = + grpc_core::MakeRefCounted(); + } + + void TearDown() override { + for (size_t i = 0; i < servers_.size(); ++i) { + servers_[i]->Shutdown(); + } + // Explicitly destroy all the members so that we can make sure grpc_shutdown + // has finished by the end of this function, and thus all the registered + // LB policy factories are removed. + stub_.reset(); + servers_.clear(); + creds_.reset(); + grpc_shutdown_blocking(); + } + + void CreateServers(size_t num_servers, + std::vector ports = std::vector()) { + servers_.clear(); + for (size_t i = 0; i < num_servers; ++i) { + int port = 0; + if (ports.size() == num_servers) port = ports[i]; + servers_.emplace_back(new ServerData(port)); + } + } + + void StartServer(size_t index) { servers_[index]->Start(server_host_); } + + void StartServers(size_t num_servers, + std::vector ports = std::vector()) { + CreateServers(num_servers, std::move(ports)); + for (size_t i = 0; i < num_servers; ++i) { + StartServer(i); + } + } + + grpc_core::Resolver::Result BuildFakeResults(const std::vector& ports) { + grpc_core::Resolver::Result result; + for (const int& port : ports) { + char* lb_uri_str; + gpr_asprintf(&lb_uri_str, "ipv4:127.0.0.1:%d", port); + grpc_uri* lb_uri = grpc_uri_parse(lb_uri_str, true); + GPR_ASSERT(lb_uri != nullptr); + grpc_resolved_address address; + GPR_ASSERT(grpc_parse_uri(lb_uri, &address)); + result.addresses.emplace_back(address.addr, address.len, + nullptr /* args */); + grpc_uri_destroy(lb_uri); + gpr_free(lb_uri_str); + } + return result; + } + + void SetNextResolutionNoServiceConfig(const std::vector& ports) { + grpc_core::ExecCtx exec_ctx; + grpc_core::Resolver::Result result = BuildFakeResults(ports); + response_generator_->SetResponse(result); + } + + void SetNextResolutionValidServiceConfig(const std::vector& ports) { + grpc_core::ExecCtx exec_ctx; + grpc_core::Resolver::Result result = BuildFakeResults(ports); + result.service_config = grpc_core::ServiceConfig::Create("{}", &result.service_config_error); + response_generator_->SetResponse(result); + } + + void SetNextResolutionInvalidServiceConfig(const std::vector& ports) { + grpc_core::ExecCtx exec_ctx; + grpc_core::Resolver::Result result = BuildFakeResults(ports); + result.service_config = grpc_core::ServiceConfig::Create("{", &result.service_config_error); + response_generator_->SetResponse(result); + } + + void SetNextResolutionUponError(const std::vector& ports) { + grpc_core::ExecCtx exec_ctx; + response_generator_->SetReresolutionResponse(BuildFakeResults(ports)); + } + + void SetFailureOnReresolution() { + grpc_core::ExecCtx exec_ctx; + response_generator_->SetFailureOnReresolution(); + } + + std::vector GetServersPorts(size_t start_index = 0) { + std::vector ports; + for (size_t i = start_index; i < servers_.size(); ++i) { + ports.push_back(servers_[i]->port_); + } + return ports; + } + + std::unique_ptr BuildStub( + const std::shared_ptr& channel) { + return grpc::testing::EchoTestService::NewStub(channel); + } + + std::shared_ptr BuildChannel( + ChannelArguments args = ChannelArguments()) { + args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, + response_generator_.get()); + return ::grpc::CreateCustomChannel("fake:///", creds_, args); + } + + bool SendRpc( + const std::unique_ptr& stub, + EchoResponse* response = nullptr, int timeout_ms = 1000, + Status* result = nullptr, bool wait_for_ready = false) { + const bool local_response = (response == nullptr); + if (local_response) response = new EchoResponse; + EchoRequest request; + request.set_message(kRequestMessage_); + ClientContext context; + context.set_deadline(grpc_timeout_milliseconds_to_deadline(timeout_ms)); + if (wait_for_ready) context.set_wait_for_ready(true); + Status status = stub->Echo(&context, request, response); + if (result != nullptr) *result = status; + if (local_response) delete response; + return status.ok(); + } + + void CheckRpcSendOk( + const std::unique_ptr& stub, + const grpc_core::DebugLocation& location, bool wait_for_ready = false) { + EchoResponse response; + Status status; + const bool success = + SendRpc(stub, &response, 2000, &status, wait_for_ready); + ASSERT_TRUE(success) << "From " << location.file() << ":" << location.line() + << "\n" + << "Error: " << status.error_message() << " " + << status.error_details(); + ASSERT_EQ(response.message(), kRequestMessage_) + << "From " << location.file() << ":" << location.line(); + if (!success) abort(); + } + + void CheckRpcSendFailure( + const std::unique_ptr& stub) { + const bool success = SendRpc(stub); + EXPECT_FALSE(success); + } + + struct ServerData { + int port_; + std::unique_ptr server_; + MyTestServiceImpl service_; + std::unique_ptr thread_; + bool server_ready_ = false; + bool started_ = false; + + explicit ServerData(int port = 0) { + port_ = port > 0 ? port : grpc_pick_unused_port_or_die(); + } + + void Start(const grpc::string& server_host) { + gpr_log(GPR_INFO, "starting server on port %d", port_); + started_ = true; + grpc::internal::Mutex mu; + grpc::internal::MutexLock lock(&mu); + grpc::internal::CondVar cond; + thread_.reset(new std::thread( + std::bind(&ServerData::Serve, this, server_host, &mu, &cond))); + cond.WaitUntil(&mu, [this] { return server_ready_; }); + server_ready_ = false; + gpr_log(GPR_INFO, "server startup complete"); + } + + void Serve(const grpc::string& server_host, grpc::internal::Mutex* mu, + grpc::internal::CondVar* cond) { + std::ostringstream server_address; + server_address << server_host << ":" << port_; + ServerBuilder builder; + std::shared_ptr creds(new SecureServerCredentials( + grpc_fake_transport_security_server_credentials_create())); + builder.AddListeningPort(server_address.str(), std::move(creds)); + builder.RegisterService(&service_); + server_ = builder.BuildAndStart(); + grpc::internal::MutexLock lock(mu); + server_ready_ = true; + cond->Signal(); + } + + void Shutdown() { + if (!started_) return; + server_->Shutdown(grpc_timeout_milliseconds_to_deadline(0)); + thread_->join(); + started_ = false; + } + + void SetServingStatus(const grpc::string& service, bool serving) { + server_->GetHealthCheckService()->SetServingStatus(service, serving); + } + }; + + void ResetCounters() { + for (const auto& server : servers_) server->service_.ResetCounters(); + } + + void WaitForServer( + const std::unique_ptr& stub, + size_t server_idx, const grpc_core::DebugLocation& location, + bool ignore_failure = false) { + do { + if (ignore_failure) { + SendRpc(stub); + } else { + CheckRpcSendOk(stub, location, true); + } + } while (servers_[server_idx]->service_.request_count() == 0); + ResetCounters(); + } + + bool WaitForChannelNotReady(Channel* channel, int timeout_seconds = 5) { + const gpr_timespec deadline = + grpc_timeout_seconds_to_deadline(timeout_seconds); + grpc_connectivity_state state; + while ((state = channel->GetState(false /* try_to_connect */)) == + GRPC_CHANNEL_READY) { + if (!channel->WaitForStateChange(state, deadline)) return false; + } + return true; + } + + bool WaitForChannelReady(Channel* channel, int timeout_seconds = 5) { + const gpr_timespec deadline = + grpc_timeout_seconds_to_deadline(timeout_seconds); + grpc_connectivity_state state; + while ((state = channel->GetState(true /* try_to_connect */)) != + GRPC_CHANNEL_READY) { + if (!channel->WaitForStateChange(state, deadline)) return false; + } + return true; + } + + bool SeenAllServers() { + for (const auto& server : servers_) { + if (server->service_.request_count() == 0) return false; + } + return true; + } + + // Updates \a connection_order by appending to it the index of the newly + // connected server. Must be called after every single RPC. + void UpdateConnectionOrder( + const std::vector>& servers, + std::vector* connection_order) { + for (size_t i = 0; i < servers.size(); ++i) { + if (servers[i]->service_.request_count() == 1) { + // Was the server index known? If not, update connection_order. + const auto it = + std::find(connection_order->begin(), connection_order->end(), i); + if (it == connection_order->end()) { + connection_order->push_back(i); + return; + } + } + } + } + + const grpc::string server_host_; + std::unique_ptr stub_; + std::vector> servers_; + grpc_core::RefCountedPtr + response_generator_; + const grpc::string kRequestMessage_; + std::shared_ptr creds_; +}; + +TEST_F(ServiceConfigEnd2endTest, BasicTest) { + StartServers(1); + auto channel = BuildChannel(); + auto stub = BuildStub(channel); + SetNextResolutionNoServiceConfig(GetServersPorts()); + CheckRpcSendOk(stub, DEBUG_LOCATION); +} + +TEST_F(ServiceConfigEnd2endTest, InvalidServiceConfigTest) { + StartServers(1); + auto channel = BuildChannel(); + auto stub = BuildStub(channel); + SetNextResolutionInvalidServiceConfig(GetServersPorts()); + CheckRpcSendFailure(stub); +} + +TEST_F(ServiceConfigEnd2endTest, ValidServiceConfigAfterInvalidTest) { + StartServers(1); + auto channel = BuildChannel(); + auto stub = BuildStub(channel); + SetNextResolutionInvalidServiceConfig(GetServersPorts()); + CheckRpcSendFailure(stub); + SetNextResolutionValidServiceConfig(GetServersPorts()); + CheckRpcSendOk(stub, DEBUG_LOCATION); +} + +TEST_F(ServiceConfigEnd2endTest, InvalidServiceConfigWithDefaultConfigTest) { + StartServers(1); + ChannelArguments args; + args.SetServiceConfigJSON("{}"); + auto channel = BuildChannel(args); + auto stub = BuildStub(channel); + SetNextResolutionInvalidServiceConfig(GetServersPorts()); + CheckRpcSendOk(stub, DEBUG_LOCATION); +} + +} // namespace +} // namespace testing +} // namespace grpc + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + grpc::testing::TestEnvironment env(argc, argv); + const auto result = RUN_ALL_TESTS(); + return result; +} diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 825f8771006..e535a335a7b 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -4795,6 +4795,28 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "grpc", + "grpc++", + "grpc++_test_util", + "grpc_test_util" + ], + "headers": [ + "src/proto/grpc/lb/v1/load_balancer.grpc.pb.h", + "src/proto/grpc/lb/v1/load_balancer.pb.h", + "src/proto/grpc/lb/v1/load_balancer_mock.grpc.pb.h" + ], + "is_filegroup": false, + "language": "c++", + "name": "service_config_end2end_test", + "src": [ + "test/cpp/end2end/service_config_end2end_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 8c14282acbb..c156c8347ae 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -5445,6 +5445,30 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "service_config_end2end_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": true + }, { "args": [], "benchmark": false, From 71085f3e3b314a3a633925ae801dc881ee3adf0b Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 2 May 2019 18:21:52 -0700 Subject: [PATCH 0105/1555] Changes --- .../resolver/dns/c_ares/dns_resolver_ares.cc | 58 +++++++++++-------- .../client_channel/resolver_result_parsing.cc | 7 ++- .../end2end/service_config_end2end_test.cc | 10 ++-- 3 files changed, 45 insertions(+), 30 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index 0f11eeda39c..e49dbf21fdd 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -229,17 +229,20 @@ bool ValueInJsonArray(grpc_json* array, const char* value) { return false; } -char* ChooseServiceConfig(char* service_config_choice_json) { +char* ChooseServiceConfig(char* service_config_choice_json, + grpc_error** error) { grpc_json* choices_json = grpc_json_parse_string(service_config_choice_json); if (choices_json == nullptr || choices_json->type != GRPC_JSON_ARRAY) { - gpr_log(GPR_ERROR, "cannot parse service config JSON string"); + *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "cannot parse service config JSON string"); return nullptr; } char* service_config = nullptr; for (grpc_json* choice = choices_json->child; choice != nullptr; choice = choice->next) { if (choice->type != GRPC_JSON_OBJECT) { - gpr_log(GPR_ERROR, "cannot parse service config JSON string"); + *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "cannot parse service config JSON string"); break; } grpc_json* service_config_json = nullptr; @@ -305,31 +308,40 @@ void AresDnsResolver::OnResolvedLocked(void* arg, grpc_error* error) { Result result; result.addresses = std::move(*r->addresses_); if (r->service_config_json_ != nullptr) { + grpc_error* service_config_error = GRPC_ERROR_NONE; char* service_config_string = - ChooseServiceConfig(r->service_config_json_); + ChooseServiceConfig(r->service_config_json_, &service_config_error); gpr_free(r->service_config_json_); - if (service_config_string != nullptr) { - GRPC_CARES_TRACE_LOG("resolver:%p selected service config choice: %s", - r, service_config_string); - grpc_error* service_config_error = GRPC_ERROR_NONE; - auto new_service_config = - ServiceConfig::Create(service_config_string, &service_config_error); - if (service_config_error == GRPC_ERROR_NONE) { - // Valid service config receivd - r->saved_service_config_ = std::move(new_service_config); + RefCountedPtr new_service_config; + if (service_config_error == GRPC_ERROR_NONE) { + if (service_config_string != nullptr) { + GRPC_CARES_TRACE_LOG("resolver:%p selected service config choice: %s", + r, service_config_string); + new_service_config = ServiceConfig::Create(service_config_string, + &service_config_error); + gpr_free(service_config_string); } else { - if (r->saved_service_config_ != nullptr) { - // Ignore the new service config error, since we have a previously - // saved service config - GRPC_ERROR_UNREF(service_config_error); - } else { - // No previously valid service config found. - // service_config_error is passed to the channel. - result.service_config_error = service_config_error; - } + // Use an empty service config since we did not find a choice + GRPC_CARES_TRACE_LOG("resolver:%p selected service config choice: {}", + r); + new_service_config = + ServiceConfig::Create("{}", &service_config_error); + } + } + if (service_config_error == GRPC_ERROR_NONE) { + // Valid service config receivd + r->saved_service_config_ = std::move(new_service_config); + } else { + if (r->saved_service_config_ != nullptr) { + // Ignore the new service config error, since we have a previously + // saved service config + GRPC_ERROR_UNREF(service_config_error); + } else { + // No previously valid service config found. + // service_config_error is passed to the channel. + result.service_config_error = service_config_error; } } - gpr_free(service_config_string); } else { // No service config received r->saved_service_config_.reset(); diff --git a/src/core/ext/filters/client_channel/resolver_result_parsing.cc b/src/core/ext/filters/client_channel/resolver_result_parsing.cc index 6b3d26c32b8..4632561c7ea 100644 --- a/src/core/ext/filters/client_channel/resolver_result_parsing.cc +++ b/src/core/ext/filters/client_channel/resolver_result_parsing.cc @@ -61,8 +61,8 @@ void ClientChannelServiceConfigParser::Register() { ProcessedResolverResult::ProcessedResolverResult( const Resolver::Result& resolver_result) : service_config_(resolver_result.service_config) { - // If resolver did not return a service config or returned an invalid service config, use the default - // specified via the client API. + // If resolver did not return a service config or returned an invalid service + // config, use the default specified via the client API. if (service_config_ == nullptr) { const char* service_config_json = grpc_channel_arg_get_string( grpc_channel_args_find(resolver_result.args, GRPC_ARG_SERVICE_CONFIG)); @@ -70,7 +70,8 @@ ProcessedResolverResult::ProcessedResolverResult( service_config_ = ServiceConfig::Create(service_config_json, &service_config_error_); } else { - service_config_error_ = GRPC_ERROR_REF(resolver_result.service_config_error); + service_config_error_ = + GRPC_ERROR_REF(resolver_result.service_config_error); } } else { service_config_error_ = diff --git a/test/cpp/end2end/service_config_end2end_test.cc b/test/cpp/end2end/service_config_end2end_test.cc index cf0c6d259c1..5d3be598a32 100644 --- a/test/cpp/end2end/service_config_end2end_test.cc +++ b/test/cpp/end2end/service_config_end2end_test.cc @@ -188,14 +188,16 @@ class ServiceConfigEnd2endTest : public ::testing::Test { void SetNextResolutionValidServiceConfig(const std::vector& ports) { grpc_core::ExecCtx exec_ctx; grpc_core::Resolver::Result result = BuildFakeResults(ports); - result.service_config = grpc_core::ServiceConfig::Create("{}", &result.service_config_error); + result.service_config = + grpc_core::ServiceConfig::Create("{}", &result.service_config_error); response_generator_->SetResponse(result); } void SetNextResolutionInvalidServiceConfig(const std::vector& ports) { grpc_core::ExecCtx exec_ctx; grpc_core::Resolver::Result result = BuildFakeResults(ports); - result.service_config = grpc_core::ServiceConfig::Create("{", &result.service_config_error); + result.service_config = + grpc_core::ServiceConfig::Create("{", &result.service_config_error); response_generator_->SetResponse(result); } @@ -415,7 +417,7 @@ TEST_F(ServiceConfigEnd2endTest, ValidServiceConfigAfterInvalidTest) { auto channel = BuildChannel(); auto stub = BuildStub(channel); SetNextResolutionInvalidServiceConfig(GetServersPorts()); - CheckRpcSendFailure(stub); + CheckRpcSendFailure(stub); SetNextResolutionValidServiceConfig(GetServersPorts()); CheckRpcSendOk(stub, DEBUG_LOCATION); } @@ -427,7 +429,7 @@ TEST_F(ServiceConfigEnd2endTest, InvalidServiceConfigWithDefaultConfigTest) { auto channel = BuildChannel(args); auto stub = BuildStub(channel); SetNextResolutionInvalidServiceConfig(GetServersPorts()); - CheckRpcSendOk(stub, DEBUG_LOCATION); + CheckRpcSendOk(stub, DEBUG_LOCATION); } } // namespace From 0217450e2ca2f3b52fe18f62e7516326d4a355b2 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 3 May 2019 10:05:32 -0700 Subject: [PATCH 0106/1555] Sanitized some sources --- .../resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc | 2 +- .../resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc | 2 +- .../resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc | 2 +- src/python/grpcio_tests/tests/interop/service.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc index e272e5a8800..04e36fbcee7 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc @@ -176,4 +176,4 @@ UniquePtr NewGrpcPolledFdFactory(grpc_combiner* combiner) { } // namespace grpc_core -#endif /* GRPC_ARES == 1 && defined(GRPC_UV) */ \ No newline at end of file +#endif /* GRPC_ARES == 1 && defined(GRPC_UV) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc index cab74f8ba64..fdbb8969a1f 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc @@ -49,4 +49,4 @@ bool grpc_ares_maybe_resolve_localhost_manually_locked( return out; } -#endif /* GRPC_ARES == 1 && defined(GRPC_UV) */ \ No newline at end of file +#endif /* GRPC_ARES == 1 && defined(GRPC_UV) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc index 07906f282aa..1232fc9d57c 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc @@ -80,4 +80,4 @@ bool inner_maybe_resolve_localhost_manually_locked( return false; } -#endif /* GRPC_ARES == 1 && (defined(GRPC_UV) || defined(GPR_WINDOWS)) */ \ No newline at end of file +#endif /* GRPC_ARES == 1 && (defined(GRPC_UV) || defined(GPR_WINDOWS)) */ diff --git a/src/python/grpcio_tests/tests/interop/service.py b/src/python/grpcio_tests/tests/interop/service.py index 20f76fceebf..37e4404c141 100644 --- a/src/python/grpcio_tests/tests/interop/service.py +++ b/src/python/grpcio_tests/tests/interop/service.py @@ -94,4 +94,4 @@ class TestService(test_pb2_grpc.TestServiceServicer): # NOTE(nathaniel): Apparently this is the same as the full-duplex call? # NOTE(atash): It isn't even called in the interop spec (Oct 22 2015)... def HalfDuplexCall(self, request_iterator, context): - return self.FullDuplexCall(request_iterator, context) \ No newline at end of file + return self.FullDuplexCall(request_iterator, context) From 2787dedd7049370c642e9315af3adc41a962545c Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Fri, 3 May 2019 10:40:49 -0700 Subject: [PATCH 0107/1555] Modify dependency of callback_test_service --- CMakeLists.txt | 117 +----------------- Makefile | 107 +--------------- build.yaml | 15 +-- grpc.gyp | 8 +- test/cpp/microbenchmarks/BUILD | 7 ++ .../generated/sources_and_headers.json | 9 +- 6 files changed, 35 insertions(+), 228 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f36f436d0ce..f7adb03c959 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2910,7 +2910,6 @@ if (gRPC_BUILD_TESTS) add_library(callback_test_service test/cpp/microbenchmarks/callback_test_service.cc - src/cpp/codegen/codegen_init.cc ) if(WIN32 AND MSVC) @@ -2945,121 +2944,17 @@ target_include_directories(callback_test_service target_link_libraries(callback_test_service ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - grpc++_unsecure + grpc_benchmark + ${_gRPC_BENCHMARK_LIBRARIES} + grpc++_test_util_unsecure grpc_test_util_unsecure + grpc++_unsecure grpc_unsecure + gpr + grpc++_test_config ${_gRPC_GFLAGS_LIBRARIES} ) -foreach(_hdr - include/grpc++/impl/codegen/async_stream.h - include/grpc++/impl/codegen/async_unary_call.h - include/grpc++/impl/codegen/byte_buffer.h - include/grpc++/impl/codegen/call.h - include/grpc++/impl/codegen/call_hook.h - include/grpc++/impl/codegen/channel_interface.h - include/grpc++/impl/codegen/client_context.h - include/grpc++/impl/codegen/client_unary_call.h - include/grpc++/impl/codegen/completion_queue.h - include/grpc++/impl/codegen/completion_queue_tag.h - include/grpc++/impl/codegen/config.h - include/grpc++/impl/codegen/core_codegen_interface.h - include/grpc++/impl/codegen/create_auth_context.h - include/grpc++/impl/codegen/grpc_library.h - include/grpc++/impl/codegen/metadata_map.h - include/grpc++/impl/codegen/method_handler_impl.h - include/grpc++/impl/codegen/rpc_method.h - include/grpc++/impl/codegen/rpc_service_method.h - include/grpc++/impl/codegen/security/auth_context.h - include/grpc++/impl/codegen/serialization_traits.h - include/grpc++/impl/codegen/server_context.h - include/grpc++/impl/codegen/server_interface.h - include/grpc++/impl/codegen/service_type.h - include/grpc++/impl/codegen/slice.h - include/grpc++/impl/codegen/status.h - include/grpc++/impl/codegen/status_code_enum.h - include/grpc++/impl/codegen/string_ref.h - include/grpc++/impl/codegen/stub_options.h - include/grpc++/impl/codegen/sync_stream.h - include/grpc++/impl/codegen/time.h - include/grpcpp/impl/codegen/async_generic_service.h - include/grpcpp/impl/codegen/async_stream.h - include/grpcpp/impl/codegen/async_unary_call.h - include/grpcpp/impl/codegen/byte_buffer.h - include/grpcpp/impl/codegen/call.h - include/grpcpp/impl/codegen/call_hook.h - include/grpcpp/impl/codegen/call_op_set.h - include/grpcpp/impl/codegen/call_op_set_interface.h - include/grpcpp/impl/codegen/callback_common.h - include/grpcpp/impl/codegen/channel_interface.h - include/grpcpp/impl/codegen/client_callback.h - include/grpcpp/impl/codegen/client_context.h - include/grpcpp/impl/codegen/client_interceptor.h - include/grpcpp/impl/codegen/client_unary_call.h - include/grpcpp/impl/codegen/completion_queue.h - include/grpcpp/impl/codegen/completion_queue_tag.h - include/grpcpp/impl/codegen/config.h - include/grpcpp/impl/codegen/core_codegen_interface.h - include/grpcpp/impl/codegen/create_auth_context.h - include/grpcpp/impl/codegen/grpc_library.h - include/grpcpp/impl/codegen/intercepted_channel.h - include/grpcpp/impl/codegen/interceptor.h - include/grpcpp/impl/codegen/interceptor_common.h - include/grpcpp/impl/codegen/message_allocator.h - include/grpcpp/impl/codegen/metadata_map.h - include/grpcpp/impl/codegen/method_handler_impl.h - include/grpcpp/impl/codegen/rpc_method.h - include/grpcpp/impl/codegen/rpc_service_method.h - include/grpcpp/impl/codegen/security/auth_context.h - include/grpcpp/impl/codegen/serialization_traits.h - include/grpcpp/impl/codegen/server_callback.h - include/grpcpp/impl/codegen/server_context.h - include/grpcpp/impl/codegen/server_interceptor.h - include/grpcpp/impl/codegen/server_interface.h - include/grpcpp/impl/codegen/service_type.h - include/grpcpp/impl/codegen/slice.h - include/grpcpp/impl/codegen/status.h - include/grpcpp/impl/codegen/status_code_enum.h - include/grpcpp/impl/codegen/string_ref.h - include/grpcpp/impl/codegen/stub_options.h - include/grpcpp/impl/codegen/sync_stream.h - include/grpcpp/impl/codegen/time.h - include/grpc/impl/codegen/byte_buffer.h - include/grpc/impl/codegen/byte_buffer_reader.h - include/grpc/impl/codegen/compression_types.h - include/grpc/impl/codegen/connectivity_state.h - include/grpc/impl/codegen/grpc_types.h - include/grpc/impl/codegen/propagation_bits.h - include/grpc/impl/codegen/slice.h - include/grpc/impl/codegen/status.h - include/grpc/impl/codegen/atm.h - include/grpc/impl/codegen/atm_gcc_atomic.h - include/grpc/impl/codegen/atm_gcc_sync.h - include/grpc/impl/codegen/atm_windows.h - include/grpc/impl/codegen/fork.h - include/grpc/impl/codegen/gpr_slice.h - include/grpc/impl/codegen/gpr_types.h - include/grpc/impl/codegen/log.h - include/grpc/impl/codegen/port_platform.h - include/grpc/impl/codegen/sync.h - include/grpc/impl/codegen/sync_custom.h - include/grpc/impl/codegen/sync_generic.h - include/grpc/impl/codegen/sync_posix.h - include/grpc/impl/codegen/sync_windows.h - include/grpcpp/impl/codegen/sync.h - include/grpc++/impl/codegen/proto_utils.h - include/grpcpp/impl/codegen/proto_buffer_reader.h - include/grpcpp/impl/codegen/proto_buffer_writer.h - include/grpcpp/impl/codegen/proto_utils.h - include/grpc++/impl/codegen/config_protobuf.h - include/grpcpp/impl/codegen/config_protobuf.h -) - string(REPLACE "include/" "" _path ${_hdr}) - get_filename_component(_path ${_path} PATH) - install(FILES ${_hdr} - DESTINATION "${gRPC_INSTALL_INCLUDEDIR}/${_path}" - ) -endforeach() endif (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index 448d7167eb4..ab8302265e1 100644 --- a/Makefile +++ b/Makefile @@ -1412,9 +1412,9 @@ pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc ifeq ($(EMBED_OPENSSL),true) -privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libcallback_test_service.a $(LIBDIR)/$(CONFIG)/libgrpc++_core_stats.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libhttp2_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libbenchmark.a +privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_core_stats.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libhttp2_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libbenchmark.a else -privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libcallback_test_service.a $(LIBDIR)/$(CONFIG)/libgrpc++_core_stats.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libhttp2_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libbenchmark.a +privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_core_stats.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libhttp2_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libbenchmark.a endif @@ -5290,113 +5290,12 @@ endif LIBCALLBACK_TEST_SERVICE_SRC = \ test/cpp/microbenchmarks/callback_test_service.cc \ - src/cpp/codegen/codegen_init.cc \ PUBLIC_HEADERS_CXX += \ - include/grpc++/impl/codegen/async_stream.h \ - include/grpc++/impl/codegen/async_unary_call.h \ - include/grpc++/impl/codegen/byte_buffer.h \ - include/grpc++/impl/codegen/call.h \ - include/grpc++/impl/codegen/call_hook.h \ - include/grpc++/impl/codegen/channel_interface.h \ - include/grpc++/impl/codegen/client_context.h \ - include/grpc++/impl/codegen/client_unary_call.h \ - include/grpc++/impl/codegen/completion_queue.h \ - include/grpc++/impl/codegen/completion_queue_tag.h \ - include/grpc++/impl/codegen/config.h \ - include/grpc++/impl/codegen/core_codegen_interface.h \ - include/grpc++/impl/codegen/create_auth_context.h \ - include/grpc++/impl/codegen/grpc_library.h \ - include/grpc++/impl/codegen/metadata_map.h \ - include/grpc++/impl/codegen/method_handler_impl.h \ - include/grpc++/impl/codegen/rpc_method.h \ - include/grpc++/impl/codegen/rpc_service_method.h \ - include/grpc++/impl/codegen/security/auth_context.h \ - include/grpc++/impl/codegen/serialization_traits.h \ - include/grpc++/impl/codegen/server_context.h \ - include/grpc++/impl/codegen/server_interface.h \ - include/grpc++/impl/codegen/service_type.h \ - include/grpc++/impl/codegen/slice.h \ - include/grpc++/impl/codegen/status.h \ - include/grpc++/impl/codegen/status_code_enum.h \ - include/grpc++/impl/codegen/string_ref.h \ - include/grpc++/impl/codegen/stub_options.h \ - include/grpc++/impl/codegen/sync_stream.h \ - include/grpc++/impl/codegen/time.h \ - include/grpcpp/impl/codegen/async_generic_service.h \ - include/grpcpp/impl/codegen/async_stream.h \ - include/grpcpp/impl/codegen/async_unary_call.h \ - include/grpcpp/impl/codegen/byte_buffer.h \ - include/grpcpp/impl/codegen/call.h \ - include/grpcpp/impl/codegen/call_hook.h \ - include/grpcpp/impl/codegen/call_op_set.h \ - include/grpcpp/impl/codegen/call_op_set_interface.h \ - include/grpcpp/impl/codegen/callback_common.h \ - include/grpcpp/impl/codegen/channel_interface.h \ - include/grpcpp/impl/codegen/client_callback.h \ - include/grpcpp/impl/codegen/client_context.h \ - include/grpcpp/impl/codegen/client_interceptor.h \ - include/grpcpp/impl/codegen/client_unary_call.h \ - include/grpcpp/impl/codegen/completion_queue.h \ - include/grpcpp/impl/codegen/completion_queue_tag.h \ - include/grpcpp/impl/codegen/config.h \ - include/grpcpp/impl/codegen/core_codegen_interface.h \ - include/grpcpp/impl/codegen/create_auth_context.h \ - include/grpcpp/impl/codegen/grpc_library.h \ - include/grpcpp/impl/codegen/intercepted_channel.h \ - include/grpcpp/impl/codegen/interceptor.h \ - include/grpcpp/impl/codegen/interceptor_common.h \ - include/grpcpp/impl/codegen/message_allocator.h \ - include/grpcpp/impl/codegen/metadata_map.h \ - include/grpcpp/impl/codegen/method_handler_impl.h \ - include/grpcpp/impl/codegen/rpc_method.h \ - include/grpcpp/impl/codegen/rpc_service_method.h \ - include/grpcpp/impl/codegen/security/auth_context.h \ - include/grpcpp/impl/codegen/serialization_traits.h \ - include/grpcpp/impl/codegen/server_callback.h \ - include/grpcpp/impl/codegen/server_context.h \ - include/grpcpp/impl/codegen/server_interceptor.h \ - include/grpcpp/impl/codegen/server_interface.h \ - include/grpcpp/impl/codegen/service_type.h \ - include/grpcpp/impl/codegen/slice.h \ - include/grpcpp/impl/codegen/status.h \ - include/grpcpp/impl/codegen/status_code_enum.h \ - include/grpcpp/impl/codegen/string_ref.h \ - include/grpcpp/impl/codegen/stub_options.h \ - include/grpcpp/impl/codegen/sync_stream.h \ - include/grpcpp/impl/codegen/time.h \ - include/grpc/impl/codegen/byte_buffer.h \ - include/grpc/impl/codegen/byte_buffer_reader.h \ - include/grpc/impl/codegen/compression_types.h \ - include/grpc/impl/codegen/connectivity_state.h \ - include/grpc/impl/codegen/grpc_types.h \ - include/grpc/impl/codegen/propagation_bits.h \ - include/grpc/impl/codegen/slice.h \ - include/grpc/impl/codegen/status.h \ - include/grpc/impl/codegen/atm.h \ - include/grpc/impl/codegen/atm_gcc_atomic.h \ - include/grpc/impl/codegen/atm_gcc_sync.h \ - include/grpc/impl/codegen/atm_windows.h \ - include/grpc/impl/codegen/fork.h \ - include/grpc/impl/codegen/gpr_slice.h \ - include/grpc/impl/codegen/gpr_types.h \ - include/grpc/impl/codegen/log.h \ - include/grpc/impl/codegen/port_platform.h \ - include/grpc/impl/codegen/sync.h \ - include/grpc/impl/codegen/sync_custom.h \ - include/grpc/impl/codegen/sync_generic.h \ - include/grpc/impl/codegen/sync_posix.h \ - include/grpc/impl/codegen/sync_windows.h \ - include/grpcpp/impl/codegen/sync.h \ - include/grpc++/impl/codegen/proto_utils.h \ - include/grpcpp/impl/codegen/proto_buffer_reader.h \ - include/grpcpp/impl/codegen/proto_buffer_writer.h \ - include/grpcpp/impl/codegen/proto_utils.h \ - include/grpc++/impl/codegen/config_protobuf.h \ - include/grpcpp/impl/codegen/config_protobuf.h \ LIBCALLBACK_TEST_SERVICE_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBCALLBACK_TEST_SERVICE_SRC)))) +$(LIBCALLBACK_TEST_SERVICE_OBJS): CPPFLAGS += -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX ifeq ($(NO_SECURE),true) diff --git a/build.yaml b/build.yaml index fc465dcb719..bae2c217ae7 100644 --- a/build.yaml +++ b/build.yaml @@ -1666,21 +1666,22 @@ libs: - grpc - gpr - name: callback_test_service - build: private + build: test language: c++ headers: - test/cpp/microbenchmarks/callback_test_service.h src: - test/cpp/microbenchmarks/callback_test_service.cc deps: - - grpc++_unsecure + - grpc_benchmark + - benchmark + - grpc++_test_util_unsecure - grpc_test_util_unsecure + - grpc++_unsecure - grpc_unsecure - filegroups: - - grpc++_codegen_base - - grpc++_codegen_base_src - - grpc++_codegen_proto - - grpc++_config_proto + - gpr + - grpc++_test_config + defaults: benchmark - name: grpc++ build: all language: c++ diff --git a/grpc.gyp b/grpc.gyp index 30e155f421f..10e98b1011a 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -1402,13 +1402,17 @@ 'target_name': 'callback_test_service', 'type': 'static_library', 'dependencies': [ - 'grpc++_unsecure', + 'grpc_benchmark', + 'benchmark', + 'grpc++_test_util_unsecure', 'grpc_test_util_unsecure', + 'grpc++_unsecure', 'grpc_unsecure', + 'gpr', + 'grpc++_test_config', ], 'sources': [ 'test/cpp/microbenchmarks/callback_test_service.cc', - 'src/cpp/codegen/codegen_init.cc', ], }, { diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD index 0be64c3b319..4af453740b4 100644 --- a/test/cpp/microbenchmarks/BUILD +++ b/test/cpp/microbenchmarks/BUILD @@ -227,8 +227,15 @@ grpc_cc_library( testonly = 1, srcs = ["callback_test_service.cc"], hdrs = ["callback_test_service.h"], + external_deps = [ + "benchmark", + ], + tags = ["no_windows"], deps = [ + "//:grpc++_unsecure", "//src/proto/grpc/testing:echo_proto", + "//test/core/util:grpc_test_util_unsecure", + "//test/cpp/util:test_config", "//test/cpp/util:test_util", ], ) diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 6803c495654..b1f579492fe 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -6646,11 +6646,12 @@ }, { "deps": [ - "grpc++_codegen_base", - "grpc++_codegen_base_src", - "grpc++_codegen_proto", - "grpc++_config_proto", + "benchmark", + "gpr", + "grpc++_test_config", + "grpc++_test_util_unsecure", "grpc++_unsecure", + "grpc_benchmark", "grpc_test_util_unsecure", "grpc_unsecure" ], From 93dc228a8a795a9b3820a0ce0f57277408694b6b Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Fri, 3 May 2019 16:35:09 -0400 Subject: [PATCH 0108/1555] Avoid copy on slice_ref. This was accidentially added in PR #18407 --- src/core/lib/slice/slice_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index db8c8e5c7cc..a9f6087e11f 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -222,7 +222,7 @@ inline uint32_t grpc_slice_refcount::Hash(const grpc_slice& slice) { g_hash_seed); } -inline grpc_slice grpc_slice_ref_internal(const grpc_slice& slice) { +inline const grpc_slice& grpc_slice_ref_internal(const grpc_slice& slice) { if (slice.refcount) { slice.refcount->Ref(); } From 587ae4a2d9239d330825f8d06a8b56dcc101c328 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 3 May 2019 14:39:11 -0700 Subject: [PATCH 0109/1555] Fix existing tests --- .../resolver/dns/c_ares/dns_resolver_ares.cc | 21 ++++-------- test/core/end2end/tests/retry_throttled.cc | 2 +- .../naming/resolver_component_tests_runner.py | 12 +++---- .../naming/resolver_test_record_groups.yaml | 34 +++++++++---------- 4 files changed, 31 insertions(+), 38 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index e49dbf21fdd..6b8f907502b 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -313,21 +313,14 @@ void AresDnsResolver::OnResolvedLocked(void* arg, grpc_error* error) { ChooseServiceConfig(r->service_config_json_, &service_config_error); gpr_free(r->service_config_json_); RefCountedPtr new_service_config; - if (service_config_error == GRPC_ERROR_NONE) { - if (service_config_string != nullptr) { - GRPC_CARES_TRACE_LOG("resolver:%p selected service config choice: %s", - r, service_config_string); - new_service_config = ServiceConfig::Create(service_config_string, - &service_config_error); - gpr_free(service_config_string); - } else { - // Use an empty service config since we did not find a choice - GRPC_CARES_TRACE_LOG("resolver:%p selected service config choice: {}", - r); - new_service_config = - ServiceConfig::Create("{}", &service_config_error); - } + if (service_config_error == GRPC_ERROR_NONE && + service_config_string != nullptr) { + GRPC_CARES_TRACE_LOG("resolver:%p selected service config choice: %s", + r, service_config_string); + new_service_config = + ServiceConfig::Create(service_config_string, &service_config_error); } + gpr_free(service_config_string); if (service_config_error == GRPC_ERROR_NONE) { // Valid service config receivd r->saved_service_config_ = std::move(new_service_config); diff --git a/test/core/end2end/tests/retry_throttled.cc b/test/core/end2end/tests/retry_throttled.cc index f5b28def0ad..0e286c3d17c 100644 --- a/test/core/end2end/tests/retry_throttled.cc +++ b/test/core/end2end/tests/retry_throttled.cc @@ -141,7 +141,7 @@ static void test_retry_throttled(grpc_end2end_test_config config) { // purposes of this test.) " \"retryThrottling\": {\n" " \"maxTokens\": 2,\n" - " \"tokenRatio\": 1.0,\n" + " \"tokenRatio\": 1.0\n" " }\n" "}"); grpc_channel_args client_args = {1, &arg}; diff --git a/test/cpp/naming/resolver_component_tests_runner.py b/test/cpp/naming/resolver_component_tests_runner.py index a0eda79ec62..2d875ce00ae 100755 --- a/test/cpp/naming/resolver_component_tests_runner.py +++ b/test/cpp/naming/resolver_component_tests_runner.py @@ -193,7 +193,7 @@ current_test_subprocess = subprocess.Popen([ args.test_bin_path, '--target_name', 'srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '1.2.3.4:1234,True', - '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]}]}', + '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService"}],"waitForReady":true}]}', '--expected_lb_policy', 'round_robin', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', @@ -207,7 +207,7 @@ current_test_subprocess = subprocess.Popen([ args.test_bin_path, '--target_name', 'ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '1.2.3.4:443,False', - '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"NoSrvSimpleService","waitForReady":true}]}]}', + '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"NoSrvSimpleService"}],"waitForReady":true}]}', '--expected_lb_policy', 'round_robin', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', @@ -249,7 +249,7 @@ current_test_subprocess = subprocess.Popen([ args.test_bin_path, '--target_name', 'ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '1.2.3.4:443,False', - '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService","waitForReady":true}]}]}', + '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService"}],"waitForReady":true}]}', '--expected_lb_policy', 'round_robin', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', @@ -263,7 +263,7 @@ current_test_subprocess = subprocess.Popen([ args.test_bin_path, '--target_name', 'ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '1.2.3.4:443,False', - '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"AlwaysPickedService","waitForReady":true}]}]}', + '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"AlwaysPickedService"}],"waitForReady":true}]}', '--expected_lb_policy', 'round_robin', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', @@ -305,7 +305,7 @@ current_test_subprocess = subprocess.Popen([ args.test_bin_path, '--target_name', 'ipv4-config-causing-fallback-to-tcp.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '1.2.3.4:443,False', - '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooThree","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFour","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFive","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSix","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSeven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEight","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooNine","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTen","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEleven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]}]}', + '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwo","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooThree","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooFour","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooFive","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooSix","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooSeven","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooEight","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooNine","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTen","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooEleven","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true}]}', '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', @@ -375,7 +375,7 @@ current_test_subprocess = subprocess.Popen([ args.test_bin_path, '--target_name', 'srv-ipv4-simple-service-config-srv-disabled.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '5.5.3.4:443,False', - '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]}]}', + '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService"}],"waitForReady":true}]}', '--expected_lb_policy', 'round_robin', '--enable_srv_queries', 'False', '--enable_txt_queries', 'True', diff --git a/test/cpp/naming/resolver_test_record_groups.yaml b/test/cpp/naming/resolver_test_record_groups.yaml index 738fe658939..bfb8b4ede2d 100644 --- a/test/cpp/naming/resolver_test_record_groups.yaml +++ b/test/cpp/naming/resolver_test_record_groups.yaml @@ -69,7 +69,7 @@ resolver_component_tests: - {TTL: '2100', data: '2607:f8b0:400a:801::1004', type: AAAA} - expected_addrs: - {address: '1.2.3.4:1234', is_balancer: true} - expected_chosen_service_config: '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]}]}' + expected_chosen_service_config: '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService"}],"waitForReady":true}]}' expected_lb_policy: round_robin enable_srv_queries: true enable_txt_queries: true @@ -80,11 +80,11 @@ resolver_component_tests: ipv4-simple-service-config: - {TTL: '2100', data: 1.2.3.4, type: A} _grpc_config.srv-ipv4-simple-service-config: - - {TTL: '2100', data: 'grpc_config=[{"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]}]}}]', + - {TTL: '2100', data: 'grpc_config=[{"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService"}],"waitForReady":true}]}}]', type: TXT} - expected_addrs: - {address: '1.2.3.4:443', is_balancer: false} - expected_chosen_service_config: '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"NoSrvSimpleService","waitForReady":true}]}]}' + expected_chosen_service_config: '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"NoSrvSimpleService"}],"waitForReady":true}]}' expected_lb_policy: round_robin enable_srv_queries: true enable_txt_queries: true @@ -93,7 +93,7 @@ resolver_component_tests: ipv4-no-srv-simple-service-config: - {TTL: '2100', data: 1.2.3.4, type: A} _grpc_config.ipv4-no-srv-simple-service-config: - - {TTL: '2100', data: 'grpc_config=[{"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"NoSrvSimpleService","waitForReady":true}]}]}}]', + - {TTL: '2100', data: 'grpc_config=[{"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"NoSrvSimpleService"}],"waitForReady":true}]}}]', type: TXT} - expected_addrs: - {address: '1.2.3.4:443', is_balancer: false} @@ -106,7 +106,7 @@ resolver_component_tests: ipv4-no-config-for-cpp: - {TTL: '2100', data: 1.2.3.4, type: A} _grpc_config.ipv4-no-config-for-cpp: - - {TTL: '2100', data: 'grpc_config=[{"clientLanguage":["python"],"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"PythonService","waitForReady":true}]}]}}]', + - {TTL: '2100', data: 'grpc_config=[{"clientLanguage":["python"],"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"PythonService"}],"waitForReady":true}]}}]', type: TXT} - expected_addrs: - {address: '1.2.3.4:443', is_balancer: false} @@ -119,11 +119,11 @@ resolver_component_tests: ipv4-cpp-config-has-zero-percentage: - {TTL: '2100', data: 1.2.3.4, type: A} _grpc_config.ipv4-cpp-config-has-zero-percentage: - - {TTL: '2100', data: 'grpc_config=[{"percentage":0,"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService","waitForReady":true}]}]}}]', + - {TTL: '2100', data: 'grpc_config=[{"percentage":0,"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService"}],"waitForReady":true}]}}]', type: TXT} - expected_addrs: - {address: '1.2.3.4:443', is_balancer: false} - expected_chosen_service_config: '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService","waitForReady":true}]}]}' + expected_chosen_service_config: '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService"}],"waitForReady":true}]}' expected_lb_policy: round_robin enable_srv_queries: true enable_txt_queries: true @@ -132,11 +132,11 @@ resolver_component_tests: ipv4-second-language-is-cpp: - {TTL: '2100', data: 1.2.3.4, type: A} _grpc_config.ipv4-second-language-is-cpp: - - {TTL: '2100', data: 'grpc_config=[{"clientLanguage":["go"],"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"GoService","waitForReady":true}]}]}},{"clientLanguage":["c++"],"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService","waitForReady":true}]}]}}]', + - {TTL: '2100', data: 'grpc_config=[{"clientLanguage":["go"],"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"GoService"}],"waitForReady":true}]}},{"clientLanguage":["c++"],"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService"}],"waitForReady":true}]}}]', type: TXT} - expected_addrs: - {address: '1.2.3.4:443', is_balancer: false} - expected_chosen_service_config: '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"AlwaysPickedService","waitForReady":true}]}]}' + expected_chosen_service_config: '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"AlwaysPickedService"}],"waitForReady":true}]}' expected_lb_policy: round_robin enable_srv_queries: true enable_txt_queries: true @@ -145,7 +145,7 @@ resolver_component_tests: ipv4-config-with-percentages: - {TTL: '2100', data: 1.2.3.4, type: A} _grpc_config.ipv4-config-with-percentages: - - {TTL: '2100', data: 'grpc_config=[{"percentage":0,"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"NeverPickedService","waitForReady":true}]}]}},{"percentage":100,"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"AlwaysPickedService","waitForReady":true}]}]}}]', + - {TTL: '2100', data: 'grpc_config=[{"percentage":0,"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"NeverPickedService"}],"waitForReady":true}]}},{"percentage":100,"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"AlwaysPickedService"}],"waitForReady":true}]}}]', type: TXT} - expected_addrs: - {address: '1.2.3.4:1234', is_balancer: true} @@ -179,7 +179,7 @@ resolver_component_tests: - {TTL: '2100', data: '2607:f8b0:400a:801::1002', type: AAAA} - expected_addrs: - {address: '1.2.3.4:443', is_balancer: false} - expected_chosen_service_config: '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooThree","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFour","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFive","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSix","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSeven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEight","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooNine","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTen","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEleven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]}]}' + expected_chosen_service_config: '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwo","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooThree","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooFour","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooFive","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooSix","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooSeven","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooEight","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooNine","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTen","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooEleven","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true}]}' expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true @@ -188,7 +188,7 @@ resolver_component_tests: ipv4-config-causing-fallback-to-tcp: - {TTL: '2100', data: 1.2.3.4, type: A} _grpc_config.ipv4-config-causing-fallback-to-tcp: - - {TTL: '2100', data: 'grpc_config=[{"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooThree","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFour","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFive","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSix","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSeven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEight","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooNine","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTen","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEleven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]}]}}]', + - {TTL: '2100', data: 'grpc_config=[{"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwo","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooThree","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooFour","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooFive","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooSix","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooSeven","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooEight","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooNine","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTen","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooEleven","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true}]}}]', type: TXT} # Tests for which we don't enable SRV queries - expected_addrs: @@ -261,7 +261,7 @@ resolver_component_tests: - {TTL: '2100', data: '2600::1004', type: AAAA} - expected_addrs: - {address: '5.5.3.4:443', is_balancer: false} - expected_chosen_service_config: '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]}]}' + expected_chosen_service_config: '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService"}],"waitForReady":true}]}' expected_lb_policy: round_robin enable_srv_queries: false enable_txt_queries: true @@ -274,7 +274,7 @@ resolver_component_tests: srv-ipv4-simple-service-config-srv-disabled: - {TTL: '2100', data: 5.5.3.4, type: A} _grpc_config.srv-ipv4-simple-service-config-srv-disabled: - - {TTL: '2100', data: 'grpc_config=[{"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]}]}}]', + - {TTL: '2100', data: 'grpc_config=[{"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService"}],"waitForReady":true}]}}]', type: TXT} - expected_addrs: - {address: '1.2.3.4:1234', is_balancer: true} @@ -289,7 +289,7 @@ resolver_component_tests: ipv4-simple-service-config-txt-disabled: - {TTL: '2100', data: 1.2.3.4, type: A} _grpc_config.srv-ipv4-simple-service-config-txt-disabled: - - {TTL: '2100', data: 'grpc_config=[{"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]}]}}]', + - {TTL: '2100', data: 'grpc_config=[{"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService"}],"waitForReady":true}]}}]', type: TXT} - expected_addrs: - {address: '1.2.3.4:443', is_balancer: false} @@ -302,7 +302,7 @@ resolver_component_tests: ipv4-cpp-config-has-zero-percentage-txt-disabled: - {TTL: '2100', data: 1.2.3.4, type: A} _grpc_config.ipv4-cpp-config-has-zero-percentage-txt-disabled: - - {TTL: '2100', data: 'grpc_config=[{"percentage":0,"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService","waitForReady":true}]}]}}]', + - {TTL: '2100', data: 'grpc_config=[{"percentage":0,"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService"}],"waitForReady":true}]}}]', type: TXT} - expected_addrs: - {address: '1.2.3.4:443', is_balancer: false} @@ -315,5 +315,5 @@ resolver_component_tests: ipv4-second-language-is-cpp-txt-disabled: - {TTL: '2100', data: 1.2.3.4, type: A} _grpc_config.ipv4-second-language-is-cpp-txt-disabled: - - {TTL: '2100', data: 'grpc_config=[{"clientLanguage":["go"],"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"GoService","waitForReady":true}]}]}},{"clientLanguage":["c++"],"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService","waitForReady":true}]}]}}]', + - {TTL: '2100', data: 'grpc_config=[{"clientLanguage":["go"],"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"GoService"}],"waitForReady":true}]}},{"clientLanguage":["c++"],"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService"}],"waitForReady":true}]}}]', type: TXT} From 4269ce08f4e6c6fb7a91a662e04469b26ceb0c30 Mon Sep 17 00:00:00 2001 From: vam Date: Fri, 3 May 2019 16:43:54 -0700 Subject: [PATCH 0110/1555] Make cc_grpc_library compatible with native proto_library and cc_proto_library rules. This is needed to comply with bazel best practices (each proto file is first processed by proto_library: https://docs.bazel.build/versions/master/be/protocol-buffer.html#proto_library) and generally bring cc_grcp_library rule up to date with latest Bazel changes (the rule hasn't gotten much updates since 2016). Detailed description. Bazel has native `cc_proto_library` rule, but it does not have `cc_grpc_library`. The rule in cc_grpc_library in this repo seems like the best candidate. This change makes possible using `cc_grpc_library` to generate on grpc library, and consume protobuf protion as dependencies. The typical `BUILD.bazel` file configuraiton now should look like the following: ```python proto_library( name = "my_proto", srcs = ["my.proto"], ) cc_proto_library( name = "my_cc_proto", deps = [":my_proto"] ) cc_grpc_library( name = "my_cc_grpc", srcs = [":my_proto"], deps = [":my_cc_proto"] ) ``` This allows to decouple all thre phases: proto descriptors generation (`proto_library`), protobuf messages library creation (`cc_proto_library`), grpc library creatio (`cc_grpc_library`). Notice how `cc_grpc_library` depends on `proto_library` (as `src`) and on `cc_proto_library` (as `deps`). Currently cc_grpc_library is designed in a way that it encapsulates all of the above and directly accepts .proto files as srcs. The previous version (before this PR) of cc_proto_library was encapsulating all of the 3 phases inside single `cc_proto_library` and also was doing it manually (without relying on the native `cc_proto_library`). The `cc_proto_library` is kept backward-compatible with the old version. --- bazel/BUILD | 12 ---- bazel/cc_grpc_library.bzl | 146 ++++++++++++++++++++++---------------- examples/BUILD | 27 +++++-- 3 files changed, 107 insertions(+), 78 deletions(-) diff --git a/bazel/BUILD b/bazel/BUILD index 32402892cc3..c3c82c9c0c7 100644 --- a/bazel/BUILD +++ b/bazel/BUILD @@ -17,15 +17,3 @@ licenses(["notice"]) # Apache v2 package(default_visibility = ["//:__subpackages__"]) load(":cc_grpc_library.bzl", "cc_grpc_library") - -proto_library( - name = "well_known_protos_list", - srcs = ["@com_google_protobuf//:well_known_protos"], -) - -cc_grpc_library( - name = "well_known_protos", - srcs = "well_known_protos_list", - proto_only = True, - deps = [], -) diff --git a/bazel/cc_grpc_library.bzl b/bazel/cc_grpc_library.bzl index 6bfcd653f51..6bfd9e0c185 100644 --- a/bazel/cc_grpc_library.bzl +++ b/bazel/cc_grpc_library.bzl @@ -2,70 +2,94 @@ load("//bazel:generate_cc.bzl", "generate_cc") -def cc_grpc_library(name, srcs, deps, proto_only, well_known_protos, generate_mocks = False, use_external = False, **kwargs): - """Generates C++ grpc classes from a .proto file. +def cc_grpc_library( + name, + srcs, + deps, + proto_only = False, + well_known_protos = True, + generate_mocks = False, + use_external = False, + grpc_only = False, + **kwargs): + """Generates C++ grpc classes for services defined in a proto file. - Assumes the generated classes will be used in cc_api_version = 2. + If grpc_only is True, this rule is compatible with proto_library and + cc_proto_library native rules such that it expects proto_library target + as srcs argument and generates only grpc library classes, expecting + protobuf messages classes library (cc_proto_library target) to be passed in + deps argument. By default grpc_only is False which makes this rule to behave + in a backwards-compatible mode (trying to generate both proto and grpc + classes). - Arguments: - name: name of rule. - srcs: a single proto_library, which wraps the .proto files with services. - deps: a list of C++ proto_library (or cc_proto_library) which provides - the compiled code of any message that the services depend on. - well_known_protos: Should this library additionally depend on well known - protos - use_external: When True the grpc deps are prefixed with //external. This - allows grpc to be used as a dependency in other bazel projects. - generate_mocks: When True, Google Mock code for client stub is generated. - **kwargs: rest of arguments, e.g., compatible_with and visibility. - """ - if len(srcs) > 1: - fail("Only one srcs value supported", "srcs") + Assumes the generated classes will be used in cc_api_version = 2. - proto_target = "_" + name + "_only" - codegen_target = "_" + name + "_codegen" - codegen_grpc_target = "_" + name + "_grpc_codegen" - proto_deps = ["_" + dep + "_only" for dep in deps if dep.find(':') == -1] - proto_deps += [dep.split(':')[0] + ':' + "_" + dep.split(':')[1] + "_only" for dep in deps if dep.find(':') != -1] + Args: + name (str): Name of rule. + srcs (list): A single .proto file which contains services definitions, + or if grpc_only parameter is True, a single proto_library which + contains services descriptors. + deps (list): A list of C++ proto_library (or cc_proto_library) which + provides the compiled code of any message that the services depend on. + proto_only (bool): If True, create only C++ proto classes library, + avoid creating C++ grpc classes library (expect it in deps). + well_known_protos (bool): Should this library additionally depend on + well known protos. + generate_mocks: when True, Google Mock code for client stub is generated. + use_external: Not used. + grpc_only: if True, generate only grpc library, expecting protobuf + messages library (cc_proto_library target) to be passed as deps. + **kwargs: rest of arguments, e.g., compatible_with and visibility + """ + if len(srcs) > 1: + fail("Only one srcs value supported", "srcs") + if grpc_only and proto_only: + fail("A mutualy exclusive configuraiton is specified: grpc_only = True and proto_only = True") - native.proto_library( - name = proto_target, - srcs = srcs, - deps = proto_deps, - **kwargs - ) + extra_deps = [] - generate_cc( - name = codegen_target, - srcs = [proto_target], - well_known_protos = well_known_protos, - **kwargs - ) + if not grpc_only: + proto_target = "_" + name + "_only" + cc_proto_target = name if proto_only else "_" + name + "_cc_proto" - if not proto_only: - plugin = "@com_github_grpc_grpc//:grpc_cpp_plugin" - generate_cc( - name = codegen_grpc_target, - srcs = [proto_target], - plugin = plugin, - well_known_protos = well_known_protos, - generate_mocks = generate_mocks, - **kwargs - ) - grpc_deps = ["@com_github_grpc_grpc//:grpc++_codegen_proto", - "//external:protobuf"] - native.cc_library( - name = name, - srcs = [":" + codegen_grpc_target, ":" + codegen_target], - hdrs = [":" + codegen_grpc_target, ":" + codegen_target], - deps = deps + grpc_deps, - **kwargs - ) - else: - native.cc_library( - name = name, - srcs = [":" + codegen_target], - hdrs = [":" + codegen_target], - deps = deps + ["//external:protobuf"], - **kwargs - ) + proto_deps = ["_" + dep + "_only" for dep in deps if dep.find(":") == -1] + proto_deps += [dep.split(":")[0] + ":" + "_" + dep.split(":")[1] + "_only" for dep in deps if dep.find(":") != -1] + + native.proto_library( + name = proto_target, + srcs = srcs, + deps = proto_deps, + **kwargs + ) + + native.cc_proto_library( + name = cc_proto_target, + deps = [":" + proto_target], + **kwargs + ) + extra_deps.append(":" + cc_proto_target) + else: + if not srcs: + fail("srcs cannot be empty", "srcs") + proto_target = srcs[0] + + if not proto_only: + codegen_grpc_target = "_" + name + "_grpc_codegen" + generate_cc( + name = codegen_grpc_target, + srcs = [proto_target], + plugin = "@com_github_grpc_grpc//:grpc_cpp_plugin", + well_known_protos = well_known_protos, + generate_mocks = generate_mocks, + **kwargs + ) + + native.cc_library( + name = name, + srcs = [":" + codegen_grpc_target], + hdrs = [":" + codegen_grpc_target], + deps = deps + + extra_deps + + ["@com_github_grpc_grpc//:grpc++_codegen_proto"], + **kwargs + ) diff --git a/examples/BUILD b/examples/BUILD index d2b39b87f4d..80f2762ff43 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -18,6 +18,7 @@ package(default_visibility = ["//visibility:public"]) load("@grpc_python_dependencies//:requirements.bzl", "requirement") load("//bazel:grpc_build_system.bzl", "grpc_proto_library") +load("//bazel:cc_grpc_library.bzl", "cc_grpc_library") load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_library") grpc_proto_library( @@ -30,11 +31,25 @@ grpc_proto_library( srcs = ["protos/hellostreamingworld.proto"], ) -grpc_proto_library( - name = "helloworld", +# The following three rules demonstrate the usage of the cc_grpc_library rule in +# in a mode compatible with the native proto_library and cc_proto_library rules. +proto_library( + name = "helloworld_proto", srcs = ["protos/helloworld.proto"], ) +cc_proto_library( + name = "helloworld_cc_proto", + deps = [":helloworld_proto"], +) + +cc_grpc_library( + name = "helloworld_cc_grpc", + srcs = [":helloworld_proto"], + grpc_only = True, + deps = [":helloworld_cc_proto"], +) + grpc_proto_library( name = "route_guide", srcs = ["protos/route_guide.proto"], @@ -49,7 +64,7 @@ py_proto_library( name = "py_helloworld", protos = ["protos/helloworld.proto"], with_grpc = True, - deps = [requirement('protobuf'),], + deps = [requirement("protobuf")], ) cc_binary( @@ -164,8 +179,10 @@ cc_binary( cc_binary( name = "keyvaluestore_client", - srcs = ["cpp/keyvaluestore/caching_interceptor.h", - "cpp/keyvaluestore/client.cc"], + srcs = [ + "cpp/keyvaluestore/caching_interceptor.h", + "cpp/keyvaluestore/client.cc", + ], defines = ["BAZEL_BUILD"], deps = [ ":keyvaluestore", From 1dab7cf91abe80b071227fde60ffefa8cc9a7644 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Sat, 4 May 2019 19:04:39 +0200 Subject: [PATCH 0111/1555] job split followup: increase timeout for macos and windows C/C++ jobs --- tools/internal_ci/macos/grpc_basictests_c_cpp.cfg | 2 +- tools/internal_ci/windows/grpc_basictests_c.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/internal_ci/macos/grpc_basictests_c_cpp.cfg b/tools/internal_ci/macos/grpc_basictests_c_cpp.cfg index 9783dd64673..f16e3e8ee68 100644 --- a/tools/internal_ci/macos/grpc_basictests_c_cpp.cfg +++ b/tools/internal_ci/macos/grpc_basictests_c_cpp.cfg @@ -17,7 +17,7 @@ # Location of the continuous shell script in repository. build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" -timeout_mins: 60 +timeout_mins: 120 action { define_artifacts { regex: "**/*sponge_log.*" diff --git a/tools/internal_ci/windows/grpc_basictests_c.cfg b/tools/internal_ci/windows/grpc_basictests_c.cfg index 150a28e3f89..223cf389d0e 100644 --- a/tools/internal_ci/windows/grpc_basictests_c.cfg +++ b/tools/internal_ci/windows/grpc_basictests_c.cfg @@ -16,7 +16,7 @@ # Location of the continuous shell script in repository. build_file: "grpc/tools/internal_ci/windows/grpc_run_tests_matrix.bat" -timeout_mins: 60 +timeout_mins: 120 action { define_artifacts { regex: "**/*sponge_log.*" From 57c4877352b00fd4c86e557d7ab3f3d523240774 Mon Sep 17 00:00:00 2001 From: John Luo Date: Sat, 4 May 2019 22:29:08 -0700 Subject: [PATCH 0112/1555] Remove non-compatible workaround Will add this to Grpc.AspNetCore.Server instead --- .../build/_protobuf/Google.Protobuf.Tools.targets | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets b/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets index b3fd02d4faa..b1030ba1f8b 100644 --- a/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets +++ b/src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets @@ -39,15 +39,6 @@ - - - - - - - - - %" PRId64, static_cast(shard - g_shards), shard->queue_deadline_cap); } @@ -512,7 +512,7 @@ static bool refill_heap(timer_shard* shard, grpc_millis now) { next = timer->next; if (timer->deadline < shard->queue_deadline_cap) { - if (grpc_timer_check_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) { gpr_log(GPR_INFO, " .. add timer with deadline %" PRId64 " to heap", timer->deadline); } @@ -529,7 +529,7 @@ static bool refill_heap(timer_shard* shard, grpc_millis now) { static grpc_timer* pop_one(timer_shard* shard, grpc_millis now) { grpc_timer* timer; for (;;) { - if (grpc_timer_check_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) { gpr_log(GPR_INFO, " .. shard[%d]: heap_empty=%s", static_cast(shard - g_shards), grpc_timer_heap_is_empty(&shard->heap) ? "true" : "false"); @@ -539,13 +539,13 @@ static grpc_timer* pop_one(timer_shard* shard, grpc_millis now) { if (!refill_heap(shard, now)) return nullptr; } timer = grpc_timer_heap_top(&shard->heap); - if (grpc_timer_check_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) { gpr_log(GPR_INFO, " .. check top timer deadline=%" PRId64 " now=%" PRId64, timer->deadline, now); } if (timer->deadline > now) return nullptr; - if (grpc_timer_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_trace)) { gpr_log(GPR_INFO, "TIMER %p: FIRE %" PRId64 "ms late via %s scheduler", timer, now - timer->deadline, timer->closure->scheduler->vtable->name); @@ -569,7 +569,7 @@ static size_t pop_timers(timer_shard* shard, grpc_millis now, } *new_min_deadline = compute_min_deadline(shard); gpr_mu_unlock(&shard->mu); - if (grpc_timer_check_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) { gpr_log(GPR_INFO, " .. shard[%d] popped %" PRIdPTR, static_cast(shard - g_shards), n); } @@ -606,7 +606,7 @@ static grpc_timer_check_result run_some_expired_timers(grpc_millis now, gpr_mu_lock(&g_shared_mutables.mu); result = GRPC_TIMERS_CHECKED_AND_EMPTY; - if (grpc_timer_check_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) { gpr_log(GPR_INFO, " .. shard[%d]->min_deadline = %" PRId64, static_cast(g_shard_queue[0] - g_shards), g_shard_queue[0]->min_deadline); @@ -624,7 +624,7 @@ static grpc_timer_check_result run_some_expired_timers(grpc_millis now, result = GRPC_TIMERS_FIRED; } - if (grpc_timer_check_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) { gpr_log(GPR_INFO, " .. result --> %d" ", shard[%d]->min_deadline %" PRId64 " --> %" PRId64 @@ -691,7 +691,7 @@ static grpc_timer_check_result timer_check(grpc_millis* next) { if (next != nullptr) { *next = GPR_MIN(*next, min_timer); } - if (grpc_timer_check_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) { gpr_log(GPR_INFO, "TIMER CHECK SKIP: now=%" PRId64 " min_timer=%" PRId64, now, min_timer); } @@ -704,7 +704,7 @@ static grpc_timer_check_result timer_check(grpc_millis* next) { : GRPC_ERROR_CREATE_FROM_STATIC_STRING("Shutting down timer system"); // tracing - if (grpc_timer_check_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) { char* next_str; if (next == nullptr) { next_str = gpr_strdup("NULL"); @@ -728,7 +728,7 @@ static grpc_timer_check_result timer_check(grpc_millis* next) { grpc_timer_check_result r = run_some_expired_timers(now, next, shutdown_error); // tracing - if (grpc_timer_check_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) { char* next_str; if (next == nullptr) { next_str = gpr_strdup("NULL"); diff --git a/src/core/lib/iomgr/timer_manager.cc b/src/core/lib/iomgr/timer_manager.cc index 4469db70dd0..bdf54909b4c 100644 --- a/src/core/lib/iomgr/timer_manager.cc +++ b/src/core/lib/iomgr/timer_manager.cc @@ -90,7 +90,7 @@ static void start_timer_thread_and_unlock(void) { ++g_waiter_count; ++g_thread_count; gpr_mu_unlock(&g_mu); - if (grpc_timer_check_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) { gpr_log(GPR_INFO, "Spawn timer thread"); } completed_thread* ct = @@ -126,7 +126,7 @@ static void run_some_timers() { // if there's no thread waiting with a timeout, kick an existing untimed // waiter so that the next deadline is not missed if (!g_has_timed_waiter) { - if (grpc_timer_check_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) { gpr_log(GPR_INFO, "kick untimed waiter"); } gpr_cv_signal(&g_cv_wait); @@ -134,7 +134,7 @@ static void run_some_timers() { gpr_mu_unlock(&g_mu); } // without our lock, flush the exec_ctx - if (grpc_timer_check_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) { gpr_log(GPR_INFO, "flush exec_ctx"); } grpc_core::ExecCtx::Get()->Flush(); @@ -189,7 +189,7 @@ static bool wait_until(grpc_millis next) { g_has_timed_waiter = true; g_timed_waiter_deadline = next; - if (grpc_timer_check_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) { grpc_millis wait_time = next - grpc_core::ExecCtx::Get()->Now(); gpr_log(GPR_INFO, "sleep for a %" PRId64 " milliseconds", wait_time); } @@ -198,7 +198,8 @@ static bool wait_until(grpc_millis next) { } } - if (grpc_timer_check_trace.enabled() && next == GRPC_MILLIS_INF_FUTURE) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace) && + next == GRPC_MILLIS_INF_FUTURE) { gpr_log(GPR_INFO, "sleep until kicked"); } @@ -210,7 +211,7 @@ static bool wait_until(grpc_millis next) { gpr_cv_wait(&g_cv_wait, &g_mu, grpc_millis_to_timespec(next, GPR_CLOCK_MONOTONIC)); - if (grpc_timer_check_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) { gpr_log(GPR_INFO, "wait ended: was_timed:%d kicked:%d", my_timed_waiter_generation == g_timed_waiter_generation, g_kicked); @@ -255,7 +256,7 @@ static void timer_main_loop() { Consequently, we can just sleep forever here and be happy at some saved wakeup cycles. */ - if (grpc_timer_check_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) { gpr_log(GPR_INFO, "timers not checked: expect another thread to"); } next = GRPC_MILLIS_INF_FUTURE; @@ -281,7 +282,7 @@ static void timer_thread_cleanup(completed_thread* ct) { ct->next = g_completed_threads; g_completed_threads = ct; gpr_mu_unlock(&g_mu); - if (grpc_timer_check_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) { gpr_log(GPR_INFO, "End timer thread"); } } @@ -327,18 +328,18 @@ void grpc_timer_manager_init(void) { static void stop_threads(void) { gpr_mu_lock(&g_mu); - if (grpc_timer_check_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) { gpr_log(GPR_INFO, "stop timer threads: threaded=%d", g_threaded); } if (g_threaded) { g_threaded = false; gpr_cv_broadcast(&g_cv_wait); - if (grpc_timer_check_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) { gpr_log(GPR_INFO, "num timer threads: %d", g_thread_count); } while (g_thread_count > 0) { gpr_cv_wait(&g_cv_shutdown, &g_mu, gpr_inf_future(GPR_CLOCK_MONOTONIC)); - if (grpc_timer_check_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_check_trace)) { gpr_log(GPR_INFO, "num timer threads: %d", g_thread_count); } gc_completed_threads(); diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.cc b/src/core/lib/security/credentials/jwt/jwt_credentials.cc index 70fe45e56dc..df1d05c83b3 100644 --- a/src/core/lib/security/credentials/jwt/jwt_credentials.cc +++ b/src/core/lib/security/credentials/jwt/jwt_credentials.cc @@ -160,7 +160,7 @@ static char* redact_private_key(const char* json_key) { grpc_call_credentials* grpc_service_account_jwt_access_credentials_create( const char* json_key, gpr_timespec token_lifetime, void* reserved) { - if (grpc_api_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace)) { char* clean_json = redact_private_key(json_key); gpr_log(GPR_INFO, "grpc_service_account_jwt_access_credentials_create(" diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc index b9af757d05e..b001868b3d3 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc @@ -459,7 +459,7 @@ grpc_call_credentials* grpc_google_refresh_token_credentials_create( const char* json_refresh_token, void* reserved) { grpc_auth_refresh_token token = grpc_auth_refresh_token_create_from_string(json_refresh_token); - if (grpc_api_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace)) { char* loggable_token = create_loggable_refresh_token(&token); gpr_log(GPR_INFO, "grpc_refresh_token_credentials_create(json_refresh_token=%s, " diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/src/core/lib/security/credentials/plugin/plugin_credentials.cc index 59fecbca992..333366d0f0a 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.cc +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc @@ -119,7 +119,7 @@ static void plugin_md_request_metadata_ready(void* request, GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP); grpc_plugin_credentials::pending_request* r = static_cast(request); - if (grpc_plugin_credentials_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_plugin_credentials_trace)) { gpr_log(GPR_INFO, "plugin_credentials[%p]: request %p: plugin returned " "asynchronously", @@ -132,7 +132,7 @@ static void plugin_md_request_metadata_ready(void* request, grpc_error* error = process_plugin_result(r, md, num_md, status, error_details); GRPC_CLOSURE_SCHED(r->on_request_metadata, error); - } else if (grpc_plugin_credentials_trace.enabled()) { + } else if (GRPC_TRACE_FLAG_ENABLED(grpc_plugin_credentials_trace)) { gpr_log(GPR_INFO, "plugin_credentials[%p]: request %p: plugin was previously " "cancelled", @@ -162,7 +162,7 @@ bool grpc_plugin_credentials::get_request_metadata( pending_requests_ = request; gpr_mu_unlock(&mu_); // Invoke the plugin. The callback holds a ref to us. - if (grpc_plugin_credentials_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_plugin_credentials_trace)) { gpr_log(GPR_INFO, "plugin_credentials[%p]: request %p: invoking plugin", this, request); } @@ -174,7 +174,7 @@ bool grpc_plugin_credentials::get_request_metadata( if (!plugin_.get_metadata( plugin_.state, context, plugin_md_request_metadata_ready, request, creds_md, &num_creds_md, &status, &error_details)) { - if (grpc_plugin_credentials_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_plugin_credentials_trace)) { gpr_log(GPR_INFO, "plugin_credentials[%p]: request %p: plugin will return " "asynchronously", @@ -189,7 +189,7 @@ bool grpc_plugin_credentials::get_request_metadata( // asynchronously by plugin_cancel_get_request_metadata(), so return // false. Otherwise, process the result. if (request->cancelled) { - if (grpc_plugin_credentials_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_plugin_credentials_trace)) { gpr_log(GPR_INFO, "plugin_credentials[%p]: request %p was cancelled, error " "will be returned asynchronously", @@ -197,7 +197,7 @@ bool grpc_plugin_credentials::get_request_metadata( } retval = false; } else { - if (grpc_plugin_credentials_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_plugin_credentials_trace)) { gpr_log(GPR_INFO, "plugin_credentials[%p]: request %p: plugin returned " "synchronously", @@ -223,7 +223,7 @@ void grpc_plugin_credentials::cancel_get_request_metadata( for (pending_request* pending_request = pending_requests_; pending_request != nullptr; pending_request = pending_request->next) { if (pending_request->md_array == md_array) { - if (grpc_plugin_credentials_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_plugin_credentials_trace)) { gpr_log(GPR_INFO, "plugin_credentials[%p]: cancelling request %p", this, pending_request); } diff --git a/src/core/lib/security/transport/secure_endpoint.cc b/src/core/lib/security/transport/secure_endpoint.cc index 2a862492bd7..0aac7d8d780 100644 --- a/src/core/lib/security/transport/secure_endpoint.cc +++ b/src/core/lib/security/transport/secure_endpoint.cc @@ -113,7 +113,7 @@ static void destroy(secure_endpoint* ep) { grpc_core::Delete(ep); } secure_endpoint_ref((ep), (reason), __FILE__, __LINE__) static void secure_endpoint_unref(secure_endpoint* ep, const char* reason, const char* file, int line) { - if (grpc_trace_secure_endpoint.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_secure_endpoint)) { gpr_atm val = gpr_atm_no_barrier_load(&ep->ref.count); gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "SECENDP unref %p : %s %" PRIdPTR " -> %" PRIdPTR, ep, reason, val, @@ -126,7 +126,7 @@ static void secure_endpoint_unref(secure_endpoint* ep, const char* reason, static void secure_endpoint_ref(secure_endpoint* ep, const char* reason, const char* file, int line) { - if (grpc_trace_secure_endpoint.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_secure_endpoint)) { gpr_atm val = gpr_atm_no_barrier_load(&ep->ref.count); gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "SECENDP ref %p : %s %" PRIdPTR " -> %" PRIdPTR, ep, reason, val, @@ -155,7 +155,7 @@ static void flush_read_staging_buffer(secure_endpoint* ep, uint8_t** cur, } static void call_read_cb(secure_endpoint* ep, grpc_error* error) { - if (grpc_trace_secure_endpoint.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_secure_endpoint)) { size_t i; for (i = 0; i < ep->read_buffer->count; i++) { char* data = grpc_dump_slice(ep->read_buffer->slices[i], @@ -292,7 +292,7 @@ static void endpoint_write(grpc_endpoint* secure_ep, grpc_slice_buffer* slices, grpc_slice_buffer_reset_and_unref_internal(&ep->output_buffer); - if (grpc_trace_secure_endpoint.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_secure_endpoint)) { for (i = 0; i < slices->count; i++) { char* data = grpc_dump_slice(slices->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII); diff --git a/src/core/lib/surface/api_trace.h b/src/core/lib/surface/api_trace.h index 72ed830554f..51d1f522230 100644 --- a/src/core/lib/surface/api_trace.h +++ b/src/core/lib/surface/api_trace.h @@ -45,7 +45,7 @@ extern grpc_core::TraceFlag grpc_api_trace; /* Due to the limitations of C89's preprocessor, the arity of the var-arg list 'nargs' must be specified. */ #define GRPC_API_TRACE(fmt, nargs, args) \ - if (grpc_api_trace.enabled()) { \ + if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace)) { \ gpr_log(GPR_INFO, fmt GRPC_API_TRACE_UNWRAP##nargs args); \ } diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index bd140021c96..d0cddfa5a12 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -723,7 +723,7 @@ static void cancel_with_status(grpc_call* c, grpc_status_code status, } static void set_final_status(grpc_call* call, grpc_error* error) { - if (grpc_call_error_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_call_error_trace)) { gpr_log(GPR_DEBUG, "set_final_status %s", call->is_client ? "CLI" : "SVR"); gpr_log(GPR_DEBUG, "%s", grpc_error_string(error)); } @@ -1280,7 +1280,7 @@ static void receiving_slice_ready(void* bctlp, grpc_error* error) { } if (error != GRPC_ERROR_NONE) { - if (grpc_trace_operation_failures.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures)) { GRPC_LOG_IF_ERROR("receiving_slice_ready", GRPC_ERROR_REF(error)); } call->receiving_stream.reset(); @@ -1404,7 +1404,7 @@ static void validate_filtered_metadata(batch_control* bctl) { GPR_ASSERT(call->encodings_accepted_by_peer != 0); if (!GPR_BITGET(call->encodings_accepted_by_peer, compression_algorithm)) { - if (grpc_compression_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_compression_trace)) { const char* algo_name = nullptr; grpc_compression_algorithm_name(compression_algorithm, &algo_name); gpr_log(GPR_ERROR, diff --git a/src/core/lib/surface/call.h b/src/core/lib/surface/call.h index d9cb97cb31b..11bde0787cb 100644 --- a/src/core/lib/surface/call.h +++ b/src/core/lib/surface/call.h @@ -102,7 +102,8 @@ void grpc_call_context_set(grpc_call* call, grpc_context_index elem, void* grpc_call_context_get(grpc_call* call, grpc_context_index elem); #define GRPC_CALL_LOG_BATCH(sev, call, ops, nops, tag) \ - if (grpc_api_trace.enabled()) grpc_call_log_batch(sev, call, ops, nops, tag) + if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace)) \ + grpc_call_log_batch(sev, call, ops, nops, tag) uint8_t grpc_call_is_client(grpc_call* call); diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index 3a32d292a7b..bb5921a6a55 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -411,12 +411,13 @@ static const cq_vtable g_cq_vtable[] = { grpc_core::TraceFlag grpc_cq_pluck_trace(false, "queue_pluck"); -#define GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, event) \ - if (grpc_api_trace.enabled() && (grpc_cq_pluck_trace.enabled() || \ - (event)->type != GRPC_QUEUE_TIMEOUT)) { \ - char* _ev = grpc_event_string(event); \ - gpr_log(GPR_INFO, "RETURN_EVENT[%p]: %s", cq, _ev); \ - gpr_free(_ev); \ +#define GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, event) \ + if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) && \ + (GRPC_TRACE_FLAG_ENABLED(grpc_cq_pluck_trace) || \ + (event)->type != GRPC_QUEUE_TIMEOUT)) { \ + char* _ev = grpc_event_string(event); \ + gpr_log(GPR_INFO, "RETURN_EVENT[%p]: %s", cq, _ev); \ + gpr_free(_ev); \ } static void on_pollset_shutdown_done(void* cq, grpc_error* error); @@ -572,7 +573,7 @@ int grpc_get_cq_poll_num(grpc_completion_queue* cq) { #ifndef NDEBUG void grpc_cq_internal_ref(grpc_completion_queue* cq, const char* reason, const char* file, int line) { - if (grpc_trace_cq_refcount.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_cq_refcount)) { gpr_atm val = gpr_atm_no_barrier_load(&cq->owning_refs.count); gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "CQ:%p ref %" PRIdPTR " -> %" PRIdPTR " %s", cq, val, val + 1, @@ -592,7 +593,7 @@ static void on_pollset_shutdown_done(void* arg, grpc_error* error) { #ifndef NDEBUG void grpc_cq_internal_unref(grpc_completion_queue* cq, const char* reason, const char* file, int line) { - if (grpc_trace_cq_refcount.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_cq_refcount)) { gpr_atm val = gpr_atm_no_barrier_load(&cq->owning_refs.count); gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "CQ:%p unref %" PRIdPTR " -> %" PRIdPTR " %s", cq, val, val - 1, @@ -678,14 +679,16 @@ static void cq_end_op_for_next(grpc_completion_queue* cq, void* tag, void* done_arg, grpc_cq_completion* storage) { GPR_TIMER_SCOPE("cq_end_op_for_next", 0); - if (grpc_api_trace.enabled() || - (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE)) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) || + (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) && + error != GRPC_ERROR_NONE)) { const char* errmsg = grpc_error_string(error); GRPC_API_TRACE( "cq_end_op_for_next(cq=%p, tag=%p, error=%s, " "done=%p, done_arg=%p, storage=%p)", 6, (cq, tag, errmsg, done, done_arg, storage)); - if (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) && + error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg); } } @@ -759,14 +762,16 @@ static void cq_end_op_for_pluck(grpc_completion_queue* cq, void* tag, cq_pluck_data* cqd = static_cast DATA_FROM_CQ(cq); int is_success = (error == GRPC_ERROR_NONE); - if (grpc_api_trace.enabled() || - (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE)) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) || + (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) && + error != GRPC_ERROR_NONE)) { const char* errmsg = grpc_error_string(error); GRPC_API_TRACE( "cq_end_op_for_pluck(cq=%p, tag=%p, error=%s, " "done=%p, done_arg=%p, storage=%p)", 6, (cq, tag, errmsg, done, done_arg, storage)); - if (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) && + error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg); } } @@ -824,14 +829,16 @@ static void cq_end_op_for_callback( cq_callback_data* cqd = static_cast DATA_FROM_CQ(cq); bool is_success = (error == GRPC_ERROR_NONE); - if (grpc_api_trace.enabled() || - (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE)) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) || + (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) && + error != GRPC_ERROR_NONE)) { const char* errmsg = grpc_error_string(error); GRPC_API_TRACE( "cq_end_op_for_callback(cq=%p, tag=%p, error=%s, " "done=%p, done_arg=%p, storage=%p)", 6, (cq, tag, errmsg, done, done_arg, storage)); - if (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) && + error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg); } } @@ -906,7 +913,7 @@ class ExecCtxNext : public grpc_core::ExecCtx { #ifndef NDEBUG static void dump_pending_tags(grpc_completion_queue* cq) { - if (!grpc_trace_pending_tags.enabled()) return; + if (!GRPC_TRACE_FLAG_ENABLED(grpc_trace_pending_tags)) return; gpr_strvec v; gpr_strvec_init(&v); @@ -1176,7 +1183,7 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag, grpc_pollset_worker* worker = nullptr; cq_pluck_data* cqd = static_cast DATA_FROM_CQ(cq); - if (grpc_cq_pluck_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_cq_pluck_trace)) { GRPC_API_TRACE( "grpc_completion_queue_pluck(" "cq=%p, tag=%p, " diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 443d199898d..2377c4d8f23 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -464,7 +464,8 @@ static void destroy_channel(channel_data* chand, grpc_error* error) { GRPC_CLOSURE_INIT(&chand->finish_destroy_channel_closure, finish_destroy_channel, chand, grpc_schedule_on_exec_ctx); - if (grpc_server_channel_trace.enabled() && error != GRPC_ERROR_NONE) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_server_channel_trace) && + error != GRPC_ERROR_NONE) { const char* msg = grpc_error_string(error); gpr_log(GPR_INFO, "Disconnected client: %s", msg); } diff --git a/src/core/lib/transport/bdp_estimator.cc b/src/core/lib/transport/bdp_estimator.cc index 8e71f869894..8835e32bcff 100644 --- a/src/core/lib/transport/bdp_estimator.cc +++ b/src/core/lib/transport/bdp_estimator.cc @@ -46,7 +46,7 @@ grpc_millis BdpEstimator::CompletePing() { 1e-9 * static_cast(dt_ts.tv_nsec); double bw = dt > 0 ? (static_cast(accumulator_) / dt) : 0; int start_inter_ping_delay = inter_ping_delay_; - if (grpc_bdp_estimator_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace)) { gpr_log(GPR_INFO, "bdp[%s]:complete acc=%" PRId64 " est=%" PRId64 " dt=%lf bw=%lfMbs bw_est=%lfMbs", @@ -57,7 +57,7 @@ grpc_millis BdpEstimator::CompletePing() { if (accumulator_ > 2 * estimate_ / 3 && bw > bw_est_) { estimate_ = GPR_MAX(accumulator_, estimate_ * 2); bw_est_ = bw; - if (grpc_bdp_estimator_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace)) { gpr_log(GPR_INFO, "bdp[%s]: estimate increased to %" PRId64, name_, estimate_); } @@ -74,7 +74,7 @@ grpc_millis BdpEstimator::CompletePing() { } if (start_inter_ping_delay != inter_ping_delay_) { stable_estimate_count_ = 0; - if (grpc_bdp_estimator_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace)) { gpr_log(GPR_INFO, "bdp[%s]:update_inter_time to %dms", name_, inter_ping_delay_); } diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h index ab13ae4be4c..6dc4d6bb05e 100644 --- a/src/core/lib/transport/bdp_estimator.h +++ b/src/core/lib/transport/bdp_estimator.h @@ -49,7 +49,7 @@ class BdpEstimator { // grpc_bdp_estimator_add_incoming_bytes once a ping has been scheduled by a // transport (but not necessarily started) void SchedulePing() { - if (grpc_bdp_estimator_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace)) { gpr_log(GPR_INFO, "bdp[%s]:sched acc=%" PRId64 " est=%" PRId64, name_, accumulator_, estimate_); } @@ -62,7 +62,7 @@ class BdpEstimator { // once // the ping is on the wire void StartPing() { - if (grpc_bdp_estimator_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace)) { gpr_log(GPR_INFO, "bdp[%s]:start acc=%" PRId64 " est=%" PRId64, name_, accumulator_, estimate_); } diff --git a/src/core/lib/transport/connectivity_state.cc b/src/core/lib/transport/connectivity_state.cc index 5b73085c7f3..bf35fd09def 100644 --- a/src/core/lib/transport/connectivity_state.cc +++ b/src/core/lib/transport/connectivity_state.cc @@ -75,7 +75,7 @@ grpc_connectivity_state grpc_connectivity_state_check( grpc_connectivity_state_tracker* tracker) { grpc_connectivity_state cur = static_cast( gpr_atm_no_barrier_load(&tracker->current_state_atm)); - if (grpc_connectivity_state_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_connectivity_state_trace)) { gpr_log(GPR_INFO, "CONWATCH: %p %s: get %s", tracker, tracker->name, grpc_connectivity_state_name(cur)); } @@ -92,7 +92,7 @@ bool grpc_connectivity_state_notify_on_state_change( grpc_closure* notify) { grpc_connectivity_state cur = static_cast( gpr_atm_no_barrier_load(&tracker->current_state_atm)); - if (grpc_connectivity_state_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_connectivity_state_trace)) { if (current == nullptr) { gpr_log(GPR_INFO, "CONWATCH: %p %s: unsubscribe notify=%p", tracker, tracker->name, notify); @@ -143,7 +143,7 @@ void grpc_connectivity_state_set(grpc_connectivity_state_tracker* tracker, grpc_connectivity_state cur = static_cast( gpr_atm_no_barrier_load(&tracker->current_state_atm)); grpc_connectivity_state_watcher* w; - if (grpc_connectivity_state_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_connectivity_state_trace)) { gpr_log(GPR_INFO, "SET: %p %s: %s --> %s [%s]", tracker, tracker->name, grpc_connectivity_state_name(cur), grpc_connectivity_state_name(state), reason); @@ -156,7 +156,7 @@ void grpc_connectivity_state_set(grpc_connectivity_state_tracker* tracker, while ((w = tracker->watchers) != nullptr) { *w->current = state; tracker->watchers = w->next; - if (grpc_connectivity_state_trace.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_connectivity_state_trace)) { gpr_log(GPR_INFO, "NOTIFY: %p %s: %p", tracker, tracker->name, w->notify); } GRPC_CLOSURE_SCHED(w->notify, GRPC_ERROR_NONE); diff --git a/src/core/tsi/fake_transport_security.cc b/src/core/tsi/fake_transport_security.cc index 4d4c4950451..fde88dd819b 100644 --- a/src/core/tsi/fake_transport_security.cc +++ b/src/core/tsi/fake_transport_security.cc @@ -585,7 +585,7 @@ static tsi_result fake_handshaker_get_bytes_to_send_to_peer( if (next_message_to_send > TSI_FAKE_HANDSHAKE_MESSAGE_MAX) { next_message_to_send = TSI_FAKE_HANDSHAKE_MESSAGE_MAX; } - if (tsi_tracing_enabled.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(tsi_tracing_enabled)) { gpr_log(GPR_INFO, "%s prepared %s.", impl->is_client ? "Client" : "Server", tsi_fake_handshake_message_to_string(impl->next_message_to_send)); @@ -597,7 +597,7 @@ static tsi_result fake_handshaker_get_bytes_to_send_to_peer( if (!impl->is_client && impl->next_message_to_send == TSI_FAKE_HANDSHAKE_MESSAGE_MAX) { /* We're done. */ - if (tsi_tracing_enabled.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(tsi_tracing_enabled)) { gpr_log(GPR_INFO, "Server is done."); } impl->result = TSI_OK; @@ -636,7 +636,7 @@ static tsi_result fake_handshaker_process_bytes_from_peer( tsi_fake_handshake_message_to_string(received_msg), tsi_fake_handshake_message_to_string(expected_msg)); } - if (tsi_tracing_enabled.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(tsi_tracing_enabled)) { gpr_log(GPR_INFO, "%s received %s.", impl->is_client ? "Client" : "Server", tsi_fake_handshake_message_to_string(received_msg)); } @@ -644,7 +644,7 @@ static tsi_result fake_handshaker_process_bytes_from_peer( impl->needs_incoming_message = 0; if (impl->next_message_to_send == TSI_FAKE_HANDSHAKE_MESSAGE_MAX) { /* We're done. */ - if (tsi_tracing_enabled.enabled()) { + if (GRPC_TRACE_FLAG_ENABLED(tsi_tracing_enabled)) { gpr_log(GPR_INFO, "%s is done.", impl->is_client ? "Client" : "Server"); } impl->result = TSI_OK; diff --git a/src/core/tsi/ssl_transport_security.cc b/src/core/tsi/ssl_transport_security.cc index cbdb4227b31..25ae2cee285 100644 --- a/src/core/tsi/ssl_transport_security.cc +++ b/src/core/tsi/ssl_transport_security.cc @@ -213,7 +213,7 @@ static const char* ssl_error_string(int error) { /* TODO(jboeuf): Remove when we are past the debugging phase with this code. */ static void ssl_log_where_info(const SSL* ssl, int where, int flag, const char* msg) { - if ((where & flag) && tsi_tracing_enabled.enabled()) { + if ((where & flag) && GRPC_TRACE_FLAG_ENABLED(tsi_tracing_enabled)) { gpr_log(GPR_INFO, "%20.20s - %30.30s - %5.10s", msg, SSL_state_string_long(ssl), SSL_state_string(ssl)); } From 2ade64a685094546943daafdec22028f4117ab17 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Tue, 7 May 2019 15:53:22 -0400 Subject: [PATCH 0150/1555] Use grpc_core::RefCount for grpc_call and mark Unref path unlikely. Unfortunately, we cannot use RefCount for `batch`, unless we support reset API. So, for now, let's mark its unref path as unlikely. --- src/core/lib/surface/call.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index bd140021c96..a826a619542 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -39,6 +39,7 @@ #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/arena.h" #include "src/core/lib/gprpp/manual_constructor.h" +#include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/profiling/timers.h" #include "src/core/lib/slice/slice_internal.h" @@ -130,7 +131,6 @@ struct grpc_call { channel(args.channel), is_client(args.server_transport_data == nullptr), stream_op_payload(context) { - gpr_ref_init(&ext_ref, 1); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { metadata_batch[i][j].deadline = GRPC_MILLIS_INF_FUTURE; @@ -142,7 +142,7 @@ struct grpc_call { gpr_free(static_cast(const_cast(final_info.error_string))); } - gpr_refcount ext_ref; + grpc_core::RefCount ext_ref; grpc_core::Arena* arena; grpc_core::CallCombiner call_combiner; grpc_completion_queue* cq; @@ -553,10 +553,10 @@ static void destroy_call(void* call, grpc_error* error) { grpc_schedule_on_exec_ctx)); } -void grpc_call_ref(grpc_call* c) { gpr_ref(&c->ext_ref); } +void grpc_call_ref(grpc_call* c) { c->ext_ref.Ref(); } void grpc_call_unref(grpc_call* c) { - if (!gpr_unref(&c->ext_ref)) return; + if (GPR_LIKELY(!c->ext_ref.Unref())) return; GPR_TIMER_SCOPE("grpc_call_unref", 0); @@ -1225,7 +1225,7 @@ static void post_batch_completion(batch_control* bctl) { } static void finish_batch_step(batch_control* bctl) { - if (gpr_unref(&bctl->steps_to_complete)) { + if (GPR_UNLIKELY(gpr_unref(&bctl->steps_to_complete))) { post_batch_completion(bctl); } } From 898fc0da1e68a6d946f28db3f24c7ff46112f76e Mon Sep 17 00:00:00 2001 From: yang-g Date: Tue, 7 May 2019 22:45:39 -0700 Subject: [PATCH 0151/1555] More fixes --- include/grpcpp/impl/codegen/byte_buffer.h | 7 ++--- include/grpcpp/server_builder_impl.h | 29 ++++++++++++------- include/grpcpp/server_impl.h | 11 ++++--- .../external_connection_acceptor_impl.cc | 17 ++++++----- .../external_connection_acceptor_impl.h | 12 ++++---- src/cpp/server/server_builder.cc | 4 +-- src/cpp/server/server_cc.cc | 2 +- test/cpp/end2end/port_sharing_end2end_test.cc | 8 +++-- 8 files changed, 50 insertions(+), 40 deletions(-) diff --git a/include/grpcpp/impl/codegen/byte_buffer.h b/include/grpcpp/impl/codegen/byte_buffer.h index aabaefc4319..e2ba9344bcb 100644 --- a/include/grpcpp/impl/codegen/byte_buffer.h +++ b/include/grpcpp/impl/codegen/byte_buffer.h @@ -29,10 +29,6 @@ #include -namespace grpc_impl { -class ExternalConnectionAcceptorImpl; -} // namespace grpc_impl - namespace grpc { class ServerInterface; @@ -55,6 +51,7 @@ template class CallbackServerStreamingHandler; template class ErrorMethodHandler; +class ExternalConnectionAcceptorImpl; template class DeserializeFuncType; class GrpcByteBufferPeer; @@ -189,7 +186,7 @@ class ByteBuffer final { friend class ProtoBufferReader; friend class ProtoBufferWriter; friend class internal::GrpcByteBufferPeer; - friend class ::grpc_impl::ExternalConnectionAcceptorImpl; + friend class internal::ExternalConnectionAcceptorImpl; grpc_byte_buffer* buffer_; diff --git a/include/grpcpp/server_builder_impl.h b/include/grpcpp/server_builder_impl.h index e98bb883cfd..ea3907d4f58 100644 --- a/include/grpcpp/server_builder_impl.h +++ b/include/grpcpp/server_builder_impl.h @@ -37,7 +37,6 @@ struct grpc_resource_quota; namespace grpc_impl { -class ExternalConnectionAcceptorImpl; class ResourceQuota; class ServerCredentials; } // namespace grpc_impl @@ -52,13 +51,17 @@ namespace testing { class ServerBuilderPluginTest; } // namespace testing +namespace internal { +class ExternalConnectionAcceptorImpl; +} // namespace internal + namespace experimental { class CallbackGenericService; -} // EXPERIMENTAL API: -// Interface for a grpc server to handle connections created out of band. -// See ServerBuilder's AddExternalConnectionAcceptor API for usage. +// Interface for a grpc server to build transports with connections created out +// of band. +// See ServerBuilder's AddExternalConnectionAcceptor API. class ExternalConnectionAcceptor { public: struct NewConnectionParameters { @@ -66,11 +69,12 @@ class ExternalConnectionAcceptor { ByteBuffer read_buffer; // data intended for the grpc server }; virtual ~ExternalConnectionAcceptor() {} - // If called before grpc::Server is started, the new connection will be - // closed. + // If called before grpc::Server is started or after it is shut down, the new + // connection will be closed. virtual void HandleNewConnection(NewConnectionParameters* p) = 0; }; +} // namespace experimental } // namespace grpc namespace grpc_impl { @@ -265,13 +269,15 @@ class ServerBuilder { ServerBuilder& RegisterCallbackGenericService( grpc::experimental::CallbackGenericService* service); - enum ExternalConnectionType { + enum class ExternalConnectionType { CONNECTION_FROM_FD = 0 // in the form of a file descriptor }; - // Create an acceptor to take in external connections and pass them to the - // gRPC server. - std::unique_ptr + /// Register an acceptor to handle the externally accepted connection in + /// grpc server. The returned acceptor can be used to pass the connection + /// to grpc server, where a channel will be created with the provided + /// server credentials. + std::unique_ptr AddExternalConnectionAcceptor(ExternalConnectionType type, std::shared_ptr creds); @@ -374,7 +380,8 @@ class ServerBuilder { std::vector< std::unique_ptr> interceptor_creators_; - std::vector> acceptors_; + std::vector> + acceptors_; }; } // namespace grpc_impl diff --git a/include/grpcpp/server_impl.h b/include/grpcpp/server_impl.h index 39f19226f8c..1541b0af87f 100644 --- a/include/grpcpp/server_impl.h +++ b/include/grpcpp/server_impl.h @@ -42,14 +42,16 @@ struct grpc_server; namespace grpc { - class AsyncGenericService; class ServerContext; +namespace internal { +class ExternalConnectionAcceptorImpl; +} // namespace internal + } // namespace grpc namespace grpc_impl { -class ExternalConnectionAcceptorImpl; class HealthCheckServiceInterface; class ServerInitializer; @@ -184,7 +186,8 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { std::shared_ptr>> sync_server_cqs, int min_pollers, int max_pollers, int sync_cq_timeout_msec, - std::vector> + std::vector< + std::shared_ptr> acceptors, grpc_resource_quota* server_rq = nullptr, std::vector> + std::vector> acceptors_; // A vector of interceptor factory objects. diff --git a/src/cpp/server/external_connection_acceptor_impl.cc b/src/cpp/server/external_connection_acceptor_impl.cc index cbc2c724a56..a2caca8189b 100644 --- a/src/cpp/server/external_connection_acceptor_impl.cc +++ b/src/cpp/server/external_connection_acceptor_impl.cc @@ -23,9 +23,10 @@ #include #include -namespace grpc_impl { +namespace grpc { +namespace internal { namespace { -class InternalAcceptor : public grpc::ExternalConnectionAcceptor { +class InternalAcceptor : public experimental::ExternalConnectionAcceptor { public: explicit InternalAcceptor( std::shared_ptr impl) @@ -48,17 +49,17 @@ ExternalConnectionAcceptorImpl::ExternalConnectionAcceptorImpl( CONNECTION_FROM_FD); } -std::unique_ptr +std::unique_ptr ExternalConnectionAcceptorImpl::GetAcceptor() { std::lock_guard lock(mu_); GPR_ASSERT(!has_acceptor_); has_acceptor_ = true; - return std::unique_ptr( + return std::unique_ptr( new InternalAcceptor(shared_from_this())); } void ExternalConnectionAcceptorImpl::HandleNewConnection( - grpc::ExternalConnectionAcceptor::NewConnectionParameters* p) { + experimental::ExternalConnectionAcceptor::NewConnectionParameters* p) { std::lock_guard lock(mu_); if (shutdown_ || !started_) { // TODO(yangg) clean up. @@ -86,9 +87,9 @@ void ExternalConnectionAcceptorImpl::Start() { started_ = true; } -void ExternalConnectionAcceptorImpl::SetToChannelArgs( - ::grpc::ChannelArguments* args) { +void ExternalConnectionAcceptorImpl::SetToChannelArgs(ChannelArguments* args) { args->SetPointer(name_.c_str(), &handler_); } -} // namespace grpc_impl +} // namespace internal +} // namespace grpc diff --git a/src/cpp/server/external_connection_acceptor_impl.h b/src/cpp/server/external_connection_acceptor_impl.h index 94bca74ca70..b5bd935c784 100644 --- a/src/cpp/server/external_connection_acceptor_impl.h +++ b/src/cpp/server/external_connection_acceptor_impl.h @@ -30,9 +30,8 @@ #include "src/core/lib/iomgr/tcp_server.h" -namespace grpc_impl { - -typedef void (*RawConnectionHandler)(int fd, grpc_byte_buffer* buffer); +namespace grpc { +namespace internal { class ExternalConnectionAcceptorImpl : public std::enable_shared_from_this { @@ -42,10 +41,10 @@ class ExternalConnectionAcceptorImpl ServerBuilder::experimental_type::ExternalConnectionType type, std::shared_ptr creds); // Should only be called once. - std::unique_ptr GetAcceptor(); + std::unique_ptr GetAcceptor(); void HandleNewConnection( - grpc::ExternalConnectionAcceptor::NewConnectionParameters* p); + experimental::ExternalConnectionAcceptor::NewConnectionParameters* p); void Shutdown(); @@ -67,6 +66,7 @@ class ExternalConnectionAcceptorImpl bool shutdown_ = false; }; -} // namespace grpc_impl +} // namespace internal +} // namespace grpc #endif // SRC_CPP_SERVER_EXTERNAL_CONNECTION_ACCEPTOR_IMPL_H_ diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index 6566cf53496..1ba9ae1c9dc 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -116,7 +116,7 @@ ServerBuilder& ServerBuilder::experimental_type::RegisterCallbackGenericService( return *builder_; } -std::unique_ptr +std::unique_ptr ServerBuilder::experimental_type::AddExternalConnectionAcceptor( experimental_type::ExternalConnectionType type, std::shared_ptr creds) { @@ -124,7 +124,7 @@ ServerBuilder::experimental_type::AddExternalConnectionAcceptor( char count_str[GPR_LTOA_MIN_BUFSIZE]; gpr_ltoa(static_cast(builder_->acceptors_.size()), count_str); builder_->acceptors_.emplace_back( - std::make_shared( + std::make_shared( name_prefix.append(count_str), type, creds)); return builder_->acceptors_.back()->GetAcceptor(); } diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc index 823cfdbb278..02cfb59c0e6 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -938,7 +938,7 @@ Server::Server( std::shared_ptr>> sync_server_cqs, int min_pollers, int max_pollers, int sync_cq_timeout_msec, - std::vector> + std::vector> acceptors, grpc_resource_quota* server_rq, std::vector< diff --git a/test/cpp/end2end/port_sharing_end2end_test.cc b/test/cpp/end2end/port_sharing_end2end_test.cc index 03b9dae6939..597ba3e4f29 100644 --- a/test/cpp/end2end/port_sharing_end2end_test.cc +++ b/test/cpp/end2end/port_sharing_end2end_test.cc @@ -116,7 +116,8 @@ class TestTcpServer { const grpc::string& address() { return address_; } - void SetAcceptor(std::unique_ptr acceptor) { + void SetAcceptor( + std::unique_ptr acceptor) { connection_acceptor_ = std::move(acceptor); } @@ -164,7 +165,7 @@ class TestTcpServer { void OnFdReleased(grpc_error* err) { EXPECT_EQ(GRPC_ERROR_NONE, err); - ExternalConnectionAcceptor::NewConnectionParameters p; + experimental::ExternalConnectionAcceptor::NewConnectionParameters p; p.fd = fd_; if (queue_data_) { char buf[1024]; @@ -190,7 +191,8 @@ class TestTcpServer { std::thread running_thread_; int port_; grpc::string address_; - std::unique_ptr connection_acceptor_; + std::unique_ptr + connection_acceptor_; test_tcp_server tcp_server_; }; From 6cba63eb4794bc0a603ad0bd4fbe1a1180fe3541 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 8 May 2019 03:36:37 -0700 Subject: [PATCH 0152/1555] reviewer comments and tests --- .../filters/client_channel/client_channel.cc | 26 +++--- .../client_channel/resolving_lb_policy.cc | 27 +++--- test/core/util/test_lb_policies.cc | 1 + test/cpp/end2end/BUILD | 1 - .../end2end/service_config_end2end_test.cc | 1 - test/cpp/naming/gen_build_yaml.py | 1 + test/cpp/naming/resolver_component_test.cc | 15 +++- .../naming/resolver_component_tests_runner.py | 82 +++++++++++++++++++ .../naming/resolver_test_record_groups.yaml | 78 ++++++++++++++++++ 9 files changed, 206 insertions(+), 26 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 93070bdc64e..5d5436b8f67 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -1242,20 +1242,20 @@ bool ChannelData::ProcessResolverResultLocked( bool service_config_changed = service_config != chand->saved_service_config_; if (service_config_changed) { chand->saved_service_config_ = std::move(service_config); - Optional - retry_throttle_data; - if (parsed_object != nullptr) { - chand->health_check_service_name_.reset( - gpr_strdup(parsed_object->health_check_service_name())); - retry_throttle_data = parsed_object->retry_throttling(); - } else { - chand->health_check_service_name_.reset(); - } - // Create service config setter to update channel state in the data - // plane combiner. Destroys itself when done. - New(chand, retry_throttle_data, - chand->saved_service_config_); } + Optional + retry_throttle_data; + if (parsed_object != nullptr) { + chand->health_check_service_name_.reset( + gpr_strdup(parsed_object->health_check_service_name())); + retry_throttle_data = parsed_object->retry_throttling(); + } else { + chand->health_check_service_name_.reset(); + } + // Create service config setter to update channel state in the data + // plane combiner. Destroys itself when done. + New(chand, retry_throttle_data, + chand->saved_service_config_); UniquePtr processed_lb_policy_name; chand->ProcessLbPolicy(result, parsed_object, &processed_lb_policy_name, lb_policy_config); diff --git a/src/core/ext/filters/client_channel/resolving_lb_policy.cc b/src/core/ext/filters/client_channel/resolving_lb_policy.cc index 698433c3854..4824f4e22c3 100644 --- a/src/core/ext/filters/client_channel/resolving_lb_policy.cc +++ b/src/core/ext/filters/client_channel/resolving_lb_policy.cc @@ -532,31 +532,33 @@ void ResolvingLoadBalancingPolicy::OnResolverResultChangedLocked( const char* lb_policy_name = nullptr; RefCountedPtr lb_policy_config; bool service_config_changed = false; + char* service_config_error_string = nullptr; if (process_resolver_result_ != nullptr) { grpc_error* service_config_error = GRPC_ERROR_NONE; service_config_changed = process_resolver_result_( process_resolver_result_user_data_, result, &lb_policy_name, &lb_policy_config, &service_config_error); if (service_config_error != GRPC_ERROR_NONE) { - if (channelz_node() != nullptr) { - trace_strings.push_back( - gpr_strdup(grpc_error_string(service_config_error))); - } + service_config_error_string = + gpr_strdup(grpc_error_string(service_config_error)); if (lb_policy_name == nullptr) { // Use an empty lb_policy_name as an indicator that we received an // invalid service config and we don't have a fallback service config. - return OnResolverError(service_config_error); + OnResolverError(service_config_error); + } else { + GRPC_ERROR_UNREF(service_config_error); } - GRPC_ERROR_UNREF(service_config_error); } } else { lb_policy_name = child_policy_name_.get(); lb_policy_config = child_lb_config_; } - GPR_ASSERT(lb_policy_name != nullptr); - // Create or update LB policy, as needed. - CreateOrUpdateLbPolicyLocked(lb_policy_name, lb_policy_config, - std::move(result), &trace_strings); + if (lb_policy_name != nullptr) { + gpr_log(GPR_ERROR, "%s", lb_policy_name); + // Create or update LB policy, as needed. + CreateOrUpdateLbPolicyLocked(lb_policy_name, lb_policy_config, + std::move(result), &trace_strings); + } // Add channel trace event. if (channelz_node() != nullptr) { if (service_config_changed) { @@ -564,10 +566,15 @@ void ResolvingLoadBalancingPolicy::OnResolverResultChangedLocked( // config in the trace, at the risk of bloating the trace logs. trace_strings.push_back(gpr_strdup("Service config changed")); } + if (service_config_error_string != nullptr) { + trace_strings.push_back(service_config_error_string); + service_config_error_string = nullptr; + } MaybeAddTraceMessagesForAddressChangesLocked(resolution_contains_addresses, &trace_strings); ConcatenateAndAddChannelTraceLocked(&trace_strings); } + gpr_free(service_config_error_string); } } // namespace grpc_core diff --git a/test/core/util/test_lb_policies.cc b/test/core/util/test_lb_policies.cc index b871f04bc9e..8f5458e782a 100644 --- a/test/core/util/test_lb_policies.cc +++ b/test/core/util/test_lb_policies.cc @@ -209,6 +209,7 @@ class InterceptTrailingFactory : public LoadBalancingPolicyFactory { OrphanablePtr CreateLoadBalancingPolicy( LoadBalancingPolicy::Args args) const override { + gpr_log(GPR_ERROR, "creating"); return OrphanablePtr( New(std::move(args), cb_, user_data_)); diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD index d211a9e8441..519a33fd8a4 100644 --- a/test/cpp/end2end/BUILD +++ b/test/cpp/end2end/BUILD @@ -439,7 +439,6 @@ grpc_cc_test( "//src/proto/grpc/testing:echo_proto", "//src/proto/grpc/testing/duplicate:echo_duplicate_proto", "//test/core/util:grpc_test_util", - "//test/core/util:test_lb_policies", "//test/cpp/util:test_util", ], ) diff --git a/test/cpp/end2end/service_config_end2end_test.cc b/test/cpp/end2end/service_config_end2end_test.cc index b695a9f8c97..9b259bd6342 100644 --- a/test/cpp/end2end/service_config_end2end_test.cc +++ b/test/cpp/end2end/service_config_end2end_test.cc @@ -54,7 +54,6 @@ #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -#include "test/core/util/test_lb_policies.h" #include "test/cpp/end2end/test_service_impl.h" #include diff --git a/test/cpp/naming/gen_build_yaml.py b/test/cpp/naming/gen_build_yaml.py index 9bf5ae9b2f8..ef757aeeb52 100755 --- a/test/cpp/naming/gen_build_yaml.py +++ b/test/cpp/naming/gen_build_yaml.py @@ -47,6 +47,7 @@ def _resolver_test_cases(resolver_component_data): _build_expected_addrs_cmd_arg(test_case['expected_addrs'])), ('expected_chosen_service_config', (test_case['expected_chosen_service_config'] or '')), + ('expected_service_config_error', (test_case['expected_service_config_error'] or '')), ('expected_lb_policy', (test_case['expected_lb_policy'] or '')), ('enable_srv_queries', test_case['enable_srv_queries']), ('enable_txt_queries', test_case['enable_txt_queries']), diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index 4d1beb7ec37..7903f2a932f 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -89,6 +89,8 @@ DEFINE_string(expected_addrs, "", DEFINE_string(expected_chosen_service_config, "", "Expected service config json string that gets chosen (no " "whitespace). Empty for none."); +DEFINE_string(expected_service_config_error, "", + "Expected service config error. Empty for none."); DEFINE_string( local_dns_server_address, "", "Optional. This address is placed as the uri authority if present."); @@ -179,6 +181,7 @@ struct ArgsStruct { grpc_channel_args* channel_args; vector expected_addrs; std::string expected_service_config_string; + std::string expected_service_config_error; std::string expected_lb_policy; }; @@ -241,6 +244,7 @@ void PollPollsetUntilRequestDone(ArgsStruct* args) { } void CheckServiceConfigResultLocked(const char* service_config_json, + grpc_error* service_config_error, ArgsStruct* args) { if (args->expected_service_config_string != "") { GPR_ASSERT(service_config_json != nullptr); @@ -248,6 +252,13 @@ void CheckServiceConfigResultLocked(const char* service_config_json, } else { GPR_ASSERT(service_config_json == nullptr); } + if (args->expected_service_config_error == "") { + EXPECT_EQ(service_config_error, GRPC_ERROR_NONE); + } else { + EXPECT_THAT(grpc_error_string(service_config_error), + testing::HasSubstr(args->expected_service_config_error)); + } + GRPC_ERROR_UNREF(service_config_error); } void CheckLBPolicyResultLocked(const grpc_channel_args* channel_args, @@ -462,7 +473,8 @@ class CheckingResultHandler : public ResultHandler { result.service_config == nullptr ? nullptr : result.service_config->service_config_json(); - CheckServiceConfigResultLocked(service_config_json, args); + CheckServiceConfigResultLocked( + service_config_json, GRPC_ERROR_REF(result.service_config_error), args); if (args->expected_service_config_string == "") { CheckLBPolicyResultLocked(result.args, args); } @@ -477,6 +489,7 @@ void RunResolvesRelevantRecordsTest( ArgsInit(&args); args.expected_addrs = ParseExpectedAddrs(FLAGS_expected_addrs); args.expected_service_config_string = FLAGS_expected_chosen_service_config; + args.expected_service_config_error = FLAGS_expected_service_config_error; args.expected_lb_policy = FLAGS_expected_lb_policy; // maybe build the address with an authority char* whole_uri = nullptr; diff --git a/test/cpp/naming/resolver_component_tests_runner.py b/test/cpp/naming/resolver_component_tests_runner.py index 2d875ce00ae..356574b6086 100755 --- a/test/cpp/naming/resolver_component_tests_runner.py +++ b/test/cpp/naming/resolver_component_tests_runner.py @@ -124,6 +124,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'no-srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '5.5.5.5:443,False', '--expected_chosen_service_config', '', + '--expected_service_config_error', '', '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', @@ -138,6 +139,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '1.2.3.4:1234,True', '--expected_chosen_service_config', '', + '--expected_service_config_error', '', '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', @@ -152,6 +154,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'srv-ipv4-multi-target.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '1.2.3.5:1234,True;1.2.3.6:1234,True;1.2.3.7:1234,True', '--expected_chosen_service_config', '', + '--expected_service_config_error', '', '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', @@ -166,6 +169,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'srv-ipv6-single-target.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '[2607:f8b0:400a:801::1001]:1234,True', '--expected_chosen_service_config', '', + '--expected_service_config_error', '', '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', @@ -180,6 +184,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'srv-ipv6-multi-target.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '[2607:f8b0:400a:801::1002]:1234,True;[2607:f8b0:400a:801::1003]:1234,True;[2607:f8b0:400a:801::1004]:1234,True', '--expected_chosen_service_config', '', + '--expected_service_config_error', '', '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', @@ -194,6 +199,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '1.2.3.4:1234,True', '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService"}],"waitForReady":true}]}', + '--expected_service_config_error', '', '--expected_lb_policy', 'round_robin', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', @@ -208,6 +214,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '1.2.3.4:443,False', '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"NoSrvSimpleService"}],"waitForReady":true}]}', + '--expected_service_config_error', '', '--expected_lb_policy', 'round_robin', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', @@ -222,6 +229,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '1.2.3.4:443,False', '--expected_chosen_service_config', '', + '--expected_service_config_error', '', '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', @@ -236,6 +244,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '1.2.3.4:443,False', '--expected_chosen_service_config', '', + '--expected_service_config_error', '', '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', @@ -250,6 +259,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '1.2.3.4:443,False', '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService"}],"waitForReady":true}]}', + '--expected_service_config_error', '', '--expected_lb_policy', 'round_robin', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', @@ -264,6 +274,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '1.2.3.4:443,False', '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"AlwaysPickedService"}],"waitForReady":true}]}', + '--expected_service_config_error', '', '--expected_lb_policy', 'round_robin', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', @@ -278,6 +289,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '1.2.3.4:1234,True;1.2.3.4:443,False', '--expected_chosen_service_config', '', + '--expected_service_config_error', '', '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', @@ -292,6 +304,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '[2607:f8b0:400a:801::1002]:1234,True;[2607:f8b0:400a:801::1002]:443,False', '--expected_chosen_service_config', '', + '--expected_service_config_error', '', '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', @@ -306,6 +319,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'ipv4-config-causing-fallback-to-tcp.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '1.2.3.4:443,False', '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwo","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooThree","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooFour","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooFive","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooSix","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooSeven","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooEight","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooNine","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTen","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooEleven","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true}]}', + '--expected_service_config_error', '', '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', @@ -320,6 +334,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'srv-ipv4-single-target-srv-disabled.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '2.3.4.5:443,False', '--expected_chosen_service_config', '', + '--expected_service_config_error', '', '--expected_lb_policy', '', '--enable_srv_queries', 'False', '--enable_txt_queries', 'True', @@ -334,6 +349,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'srv-ipv4-multi-target-srv-disabled.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '9.2.3.5:443,False;9.2.3.6:443,False;9.2.3.7:443,False', '--expected_chosen_service_config', '', + '--expected_service_config_error', '', '--expected_lb_policy', '', '--enable_srv_queries', 'False', '--enable_txt_queries', 'True', @@ -348,6 +364,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'srv-ipv6-single-target-srv-disabled.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '[2600::1001]:443,False', '--expected_chosen_service_config', '', + '--expected_service_config_error', '', '--expected_lb_policy', '', '--enable_srv_queries', 'False', '--enable_txt_queries', 'True', @@ -362,6 +379,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'srv-ipv6-multi-target-srv-disabled.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '[2600::1002]:443,False;[2600::1003]:443,False;[2600::1004]:443,False', '--expected_chosen_service_config', '', + '--expected_service_config_error', '', '--expected_lb_policy', '', '--enable_srv_queries', 'False', '--enable_txt_queries', 'True', @@ -376,6 +394,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'srv-ipv4-simple-service-config-srv-disabled.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '5.5.3.4:443,False', '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService"}],"waitForReady":true}]}', + '--expected_service_config_error', '', '--expected_lb_policy', 'round_robin', '--enable_srv_queries', 'False', '--enable_txt_queries', 'True', @@ -390,6 +409,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'srv-ipv4-simple-service-config-txt-disabled.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '1.2.3.4:1234,True', '--expected_chosen_service_config', '', + '--expected_service_config_error', '', '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'False', @@ -404,6 +424,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'ipv4-cpp-config-has-zero-percentage-txt-disabled.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '1.2.3.4:443,False', '--expected_chosen_service_config', '', + '--expected_service_config_error', '', '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'False', @@ -418,6 +439,7 @@ current_test_subprocess = subprocess.Popen([ '--target_name', 'ipv4-second-language-is-cpp-txt-disabled.resolver-tests-version-4.grpctestingexp.', '--expected_addrs', '1.2.3.4:443,False', '--expected_chosen_service_config', '', + '--expected_service_config_error', '', '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'False', @@ -426,6 +448,66 @@ current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: num_test_failures += 1 +test_runner_log('Run test with target: %s' % 'ipv4-svc_cfg_bad_json.resolver-tests-version-4.grpctestingexp.') +current_test_subprocess = subprocess.Popen([ + args.test_bin_path, + '--target_name', 'ipv4-svc_cfg_bad_json.resolver-tests-version-4.grpctestingexp.', + '--expected_addrs', '1.2.3.4:443,False', + '--expected_chosen_service_config', '', + '--expected_service_config_error', 'could not parse', + '--expected_lb_policy', '', + '--enable_srv_queries', 'True', + '--enable_txt_queries', 'True', + '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) +current_test_subprocess.communicate() +if current_test_subprocess.returncode != 0: + num_test_failures += 1 + +test_runner_log('Run test with target: %s' % 'ipv4-svc_cfg_bad_client_language.resolver-tests-version-4.grpctestingexp.') +current_test_subprocess = subprocess.Popen([ + args.test_bin_path, + '--target_name', 'ipv4-svc_cfg_bad_client_language.resolver-tests-version-4.grpctestingexp.', + '--expected_addrs', '1.2.3.4:443,False', + '--expected_chosen_service_config', '', + '--expected_service_config_error', 'field:clientLanguage error:should be of type array', + '--expected_lb_policy', '', + '--enable_srv_queries', 'True', + '--enable_txt_queries', 'True', + '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) +current_test_subprocess.communicate() +if current_test_subprocess.returncode != 0: + num_test_failures += 1 + +test_runner_log('Run test with target: %s' % 'ipv4-svc_cfg_bad_percentage.resolver-tests-version-4.grpctestingexp.') +current_test_subprocess = subprocess.Popen([ + args.test_bin_path, + '--target_name', 'ipv4-svc_cfg_bad_percentage.resolver-tests-version-4.grpctestingexp.', + '--expected_addrs', '1.2.3.4:443,False', + '--expected_chosen_service_config', '', + '--expected_service_config_error', 'field:percentage error:should be of type number', + '--expected_lb_policy', '', + '--enable_srv_queries', 'True', + '--enable_txt_queries', 'True', + '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) +current_test_subprocess.communicate() +if current_test_subprocess.returncode != 0: + num_test_failures += 1 + +test_runner_log('Run test with target: %s' % 'ipv4-svc_cfg_bad_wait_for_ready.resolver-tests-version-4.grpctestingexp.') +current_test_subprocess = subprocess.Popen([ + args.test_bin_path, + '--target_name', 'ipv4-svc_cfg_bad_wait_for_ready.resolver-tests-version-4.grpctestingexp.', + '--expected_addrs', '1.2.3.4:443,False', + '--expected_chosen_service_config', '', + '--expected_service_config_error', 'field:waitForReady error:Type should be true/false', + '--expected_lb_policy', '', + '--enable_srv_queries', 'True', + '--enable_txt_queries', 'True', + '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) +current_test_subprocess.communicate() +if current_test_subprocess.returncode != 0: + num_test_failures += 1 + test_runner_log('now kill DNS server') dns_server_subprocess.kill() dns_server_subprocess.wait() diff --git a/test/cpp/naming/resolver_test_record_groups.yaml b/test/cpp/naming/resolver_test_record_groups.yaml index bfb8b4ede2d..23d09ea896a 100644 --- a/test/cpp/naming/resolver_test_record_groups.yaml +++ b/test/cpp/naming/resolver_test_record_groups.yaml @@ -4,6 +4,7 @@ resolver_component_tests: - expected_addrs: - {address: '5.5.5.5:443', is_balancer: false} expected_chosen_service_config: null + expected_service_config_error: null expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true @@ -14,6 +15,7 @@ resolver_component_tests: - expected_addrs: - {address: '1.2.3.4:1234', is_balancer: true} expected_chosen_service_config: null + expected_service_config_error: null expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true @@ -28,6 +30,7 @@ resolver_component_tests: - {address: '1.2.3.6:1234', is_balancer: true} - {address: '1.2.3.7:1234', is_balancer: true} expected_chosen_service_config: null + expected_service_config_error: null expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true @@ -42,6 +45,7 @@ resolver_component_tests: - expected_addrs: - {address: '[2607:f8b0:400a:801::1001]:1234', is_balancer: true} expected_chosen_service_config: null + expected_service_config_error: null expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true @@ -56,6 +60,7 @@ resolver_component_tests: - {address: '[2607:f8b0:400a:801::1003]:1234', is_balancer: true} - {address: '[2607:f8b0:400a:801::1004]:1234', is_balancer: true} expected_chosen_service_config: null + expected_service_config_error: null expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true @@ -70,6 +75,7 @@ resolver_component_tests: - expected_addrs: - {address: '1.2.3.4:1234', is_balancer: true} expected_chosen_service_config: '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService"}],"waitForReady":true}]}' + expected_service_config_error: null expected_lb_policy: round_robin enable_srv_queries: true enable_txt_queries: true @@ -85,6 +91,7 @@ resolver_component_tests: - expected_addrs: - {address: '1.2.3.4:443', is_balancer: false} expected_chosen_service_config: '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"NoSrvSimpleService"}],"waitForReady":true}]}' + expected_service_config_error: null expected_lb_policy: round_robin enable_srv_queries: true enable_txt_queries: true @@ -98,6 +105,7 @@ resolver_component_tests: - expected_addrs: - {address: '1.2.3.4:443', is_balancer: false} expected_chosen_service_config: null + expected_service_config_error: null expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true @@ -111,6 +119,7 @@ resolver_component_tests: - expected_addrs: - {address: '1.2.3.4:443', is_balancer: false} expected_chosen_service_config: null + expected_service_config_error: null expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true @@ -124,6 +133,7 @@ resolver_component_tests: - expected_addrs: - {address: '1.2.3.4:443', is_balancer: false} expected_chosen_service_config: '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService"}],"waitForReady":true}]}' + expected_service_config_error: null expected_lb_policy: round_robin enable_srv_queries: true enable_txt_queries: true @@ -137,6 +147,7 @@ resolver_component_tests: - expected_addrs: - {address: '1.2.3.4:443', is_balancer: false} expected_chosen_service_config: '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"AlwaysPickedService"}],"waitForReady":true}]}' + expected_service_config_error: null expected_lb_policy: round_robin enable_srv_queries: true enable_txt_queries: true @@ -151,6 +162,7 @@ resolver_component_tests: - {address: '1.2.3.4:1234', is_balancer: true} - {address: '1.2.3.4:443', is_balancer: false} expected_chosen_service_config: null + expected_service_config_error: null expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true @@ -166,6 +178,7 @@ resolver_component_tests: - {address: '[2607:f8b0:400a:801::1002]:1234', is_balancer: true} - {address: '[2607:f8b0:400a:801::1002]:443', is_balancer: false} expected_chosen_service_config: null + expected_service_config_error: null expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true @@ -180,6 +193,7 @@ resolver_component_tests: - expected_addrs: - {address: '1.2.3.4:443', is_balancer: false} expected_chosen_service_config: '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwo","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooThree","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooFour","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooFive","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooSix","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooSeven","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooEight","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooNine","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTen","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooEleven","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true}]}' + expected_service_config_error: null expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true @@ -194,6 +208,7 @@ resolver_component_tests: - expected_addrs: - {address: '2.3.4.5:443', is_balancer: false} expected_chosen_service_config: null + expected_service_config_error: null expected_lb_policy: null enable_srv_queries: false enable_txt_queries: true @@ -210,6 +225,7 @@ resolver_component_tests: - {address: '9.2.3.6:443', is_balancer: false} - {address: '9.2.3.7:443', is_balancer: false} expected_chosen_service_config: null + expected_service_config_error: null expected_lb_policy: null enable_srv_queries: false enable_txt_queries: true @@ -228,6 +244,7 @@ resolver_component_tests: - expected_addrs: - {address: '[2600::1001]:443', is_balancer: false} expected_chosen_service_config: null + expected_service_config_error: null expected_lb_policy: null enable_srv_queries: false enable_txt_queries: true @@ -244,6 +261,7 @@ resolver_component_tests: - {address: '[2600::1003]:443', is_balancer: false} - {address: '[2600::1004]:443', is_balancer: false} expected_chosen_service_config: null + expected_service_config_error: null expected_lb_policy: null enable_srv_queries: false enable_txt_queries: true @@ -262,6 +280,7 @@ resolver_component_tests: - expected_addrs: - {address: '5.5.3.4:443', is_balancer: false} expected_chosen_service_config: '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService"}],"waitForReady":true}]}' + expected_service_config_error: null expected_lb_policy: round_robin enable_srv_queries: false enable_txt_queries: true @@ -279,6 +298,7 @@ resolver_component_tests: - expected_addrs: - {address: '1.2.3.4:1234', is_balancer: true} expected_chosen_service_config: null + expected_service_config_error: null expected_lb_policy: null enable_srv_queries: true enable_txt_queries: false @@ -294,6 +314,7 @@ resolver_component_tests: - expected_addrs: - {address: '1.2.3.4:443', is_balancer: false} expected_chosen_service_config: null + expected_service_config_error: null expected_lb_policy: null enable_srv_queries: true enable_txt_queries: false @@ -307,6 +328,7 @@ resolver_component_tests: - expected_addrs: - {address: '1.2.3.4:443', is_balancer: false} expected_chosen_service_config: null + expected_service_config_error: null expected_lb_policy: null enable_srv_queries: true enable_txt_queries: false @@ -317,3 +339,59 @@ resolver_component_tests: _grpc_config.ipv4-second-language-is-cpp-txt-disabled: - {TTL: '2100', data: 'grpc_config=[{"clientLanguage":["go"],"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"GoService"}],"waitForReady":true}]}},{"clientLanguage":["c++"],"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService"}],"waitForReady":true}]}}]', type: TXT} +- expected_addrs: + - {address: '1.2.3.4:443', is_balancer: false} + expected_chosen_service_config: null + expected_service_config_error: 'could not parse' + expected_lb_policy: null + enable_srv_queries: true + enable_txt_queries: true + record_to_resolve: ipv4-svc_cfg_bad_json + records: + ipv4-svc_cfg_bad_json: + - {TTL: '2100', data: 1.2.3.4, type: A} + _grpc_config.ipv4-svc_cfg_bad_json: + - {TTL: '2100', data: 'grpc_config=[{]', + type: TXT} +- expected_addrs: + - {address: '1.2.3.4:443', is_balancer: false} + expected_chosen_service_config: null + expected_service_config_error: 'field:clientLanguage error:should be of type array' + expected_lb_policy: null + enable_srv_queries: true + enable_txt_queries: true + record_to_resolve: ipv4-svc_cfg_bad_client_language + records: + ipv4-svc_cfg_bad_client_language: + - {TTL: '2100', data: 1.2.3.4, type: A} + _grpc_config.ipv4-svc_cfg_bad_client_language: + - {TTL: '2100', data: 'grpc_config=[{"clientLanguage":"go","serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"GoService"}],"waitForReady":true}]}},{"clientLanguage":["c++"],"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService"}],"waitForReady":true}]}}]', + type: TXT} +- expected_addrs: + - {address: '1.2.3.4:443', is_balancer: false} + expected_chosen_service_config: null + expected_service_config_error: 'field:percentage error:should be of type number' + expected_lb_policy: null + enable_srv_queries: true + enable_txt_queries: true + record_to_resolve: ipv4-svc_cfg_bad_percentage + records: + ipv4-svc_cfg_bad_percentage: + - {TTL: '2100', data: 1.2.3.4, type: A} + _grpc_config.ipv4-svc_cfg_bad_percentage: + - {TTL: '2100', data: 'grpc_config=[{"percentage":"0","serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"GoService"}],"waitForReady":true}]}},{"clientLanguage":["c++"],"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService"}],"waitForReady":true}]}}]', + type: TXT} +- expected_addrs: + - {address: '1.2.3.4:443', is_balancer: false} + expected_chosen_service_config: null + expected_service_config_error: 'field:waitForReady error:Type should be true/false' + expected_lb_policy: null + enable_srv_queries: true + enable_txt_queries: true + record_to_resolve: ipv4-svc_cfg_bad_wait_for_ready + records: + ipv4-svc_cfg_bad_wait_for_ready: + - {TTL: '2100', data: 1.2.3.4, type: A} + _grpc_config.ipv4-svc_cfg_bad_wait_for_ready: + - {TTL: '2100', data: 'grpc_config=[{"serviceConfig":{"methodConfig":[{"name":[{"method":"Foo","service":"CppService"}],"waitForReady":"true"}]}}]', + type: TXT} From 02bd17ff15c74849537a19b872167cb1dd536ebb Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 8 May 2019 03:46:48 -0700 Subject: [PATCH 0153/1555] cleanup --- CMakeLists.txt | 7 ------- Makefile | 4 ---- build.yaml | 1 - test/core/util/test_lb_policies.cc | 1 - tools/run_tests/generated/sources_and_headers.json | 6 +----- 5 files changed, 1 insertion(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 42ea919f4a6..263d9a2b9f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15941,18 +15941,11 @@ endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(service_config_end2end_test - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.grpc.pb.h test/cpp/end2end/service_config_end2end_test.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc ) -protobuf_generate_grpc_cpp( - src/proto/grpc/lb/v1/load_balancer.proto -) target_include_directories(service_config_end2end_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/Makefile b/Makefile index b605550a38a..650d3ad66f3 100644 --- a/Makefile +++ b/Makefile @@ -18901,7 +18901,6 @@ $(OBJDIR)/$(CONFIG)/test/cpp/server/server_request_call_test.o: $(GENDIR)/src/pr SERVICE_CONFIG_END2END_TEST_SRC = \ - $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc \ test/cpp/end2end/service_config_end2end_test.cc \ SERVICE_CONFIG_END2END_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SERVICE_CONFIG_END2END_TEST_SRC)))) @@ -18933,8 +18932,6 @@ endif endif -$(OBJDIR)/$(CONFIG)/src/proto/grpc/lb/v1/load_balancer.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(OBJDIR)/$(CONFIG)/test/cpp/end2end/service_config_end2end_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a deps_service_config_end2end_test: $(SERVICE_CONFIG_END2END_TEST_OBJS:.o=.dep) @@ -18944,7 +18941,6 @@ ifneq ($(NO_DEPS),true) -include $(SERVICE_CONFIG_END2END_TEST_OBJS:.o=.dep) endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/end2end/service_config_end2end_test.o: $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc SERVICE_CONFIG_TEST_SRC = \ diff --git a/build.yaml b/build.yaml index 46b016c6be4..08b2cbd7ee6 100644 --- a/build.yaml +++ b/build.yaml @@ -5525,7 +5525,6 @@ targets: build: test language: c++ src: - - src/proto/grpc/lb/v1/load_balancer.proto - test/cpp/end2end/service_config_end2end_test.cc deps: - grpc++_test_util diff --git a/test/core/util/test_lb_policies.cc b/test/core/util/test_lb_policies.cc index 8f5458e782a..b871f04bc9e 100644 --- a/test/core/util/test_lb_policies.cc +++ b/test/core/util/test_lb_policies.cc @@ -209,7 +209,6 @@ class InterceptTrailingFactory : public LoadBalancingPolicyFactory { OrphanablePtr CreateLoadBalancingPolicy( LoadBalancingPolicy::Args args) const override { - gpr_log(GPR_ERROR, "creating"); return OrphanablePtr( New(std::move(args), cb_, user_data_)); diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index e535a335a7b..4ece3f64a1d 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -4803,11 +4803,7 @@ "grpc++_test_util", "grpc_test_util" ], - "headers": [ - "src/proto/grpc/lb/v1/load_balancer.grpc.pb.h", - "src/proto/grpc/lb/v1/load_balancer.pb.h", - "src/proto/grpc/lb/v1/load_balancer_mock.grpc.pb.h" - ], + "headers": [], "is_filegroup": false, "language": "c++", "name": "service_config_end2end_test", From 7c051556a6af640189bfda9931ab3278775a1d5c Mon Sep 17 00:00:00 2001 From: yang-g Date: Wed, 8 May 2019 08:54:54 -0700 Subject: [PATCH 0154/1555] Rename internal class --- src/cpp/server/external_connection_acceptor_impl.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cpp/server/external_connection_acceptor_impl.cc b/src/cpp/server/external_connection_acceptor_impl.cc index a2caca8189b..39048be4aab 100644 --- a/src/cpp/server/external_connection_acceptor_impl.cc +++ b/src/cpp/server/external_connection_acceptor_impl.cc @@ -26,10 +26,11 @@ namespace grpc { namespace internal { namespace { -class InternalAcceptor : public experimental::ExternalConnectionAcceptor { +// The actual type to return to user. It co-owns the internal impl object with +// the server. +class AcceptorWrapper : public experimental::ExternalConnectionAcceptor { public: - explicit InternalAcceptor( - std::shared_ptr impl) + explicit AcceptorWrapper(std::shared_ptr impl) : impl_(std::move(impl)) {} void HandleNewConnection(NewConnectionParameters* p) override { impl_->HandleNewConnection(p); @@ -55,7 +56,7 @@ ExternalConnectionAcceptorImpl::GetAcceptor() { GPR_ASSERT(!has_acceptor_); has_acceptor_ = true; return std::unique_ptr( - new InternalAcceptor(shared_from_this())); + new AcceptorWrapper(shared_from_this())); } void ExternalConnectionAcceptorImpl::HandleNewConnection( From 3bcae1e3682e45ad528587f47f4c46e5f5d11fbb Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Wed, 8 May 2019 12:22:06 -0400 Subject: [PATCH 0155/1555] Apply do {...} while(0) to the remaining macros. --- .../resolver/dns/c_ares/grpc_ares_wrapper.h | 10 ++++++---- .../ext/transport/chttp2/transport/internal.h | 10 ++++++---- src/core/lib/iomgr/executor.cc | 20 +++++++++++-------- src/core/lib/surface/call.h | 7 +++++-- src/core/lib/surface/completion_queue.cc | 18 +++++++++-------- 5 files changed, 39 insertions(+), 26 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h index 881dfcdcee6..a707c1ae7c4 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h @@ -32,10 +32,12 @@ extern grpc_core::TraceFlag grpc_trace_cares_address_sorting; extern grpc_core::TraceFlag grpc_trace_cares_resolver; -#define GRPC_CARES_TRACE_LOG(format, ...) \ - if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_cares_resolver)) { \ - gpr_log(GPR_DEBUG, "(c-ares resolver) " format, __VA_ARGS__); \ - } +#define GRPC_CARES_TRACE_LOG(format, ...) \ + do { \ + if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_cares_resolver)) { \ + gpr_log(GPR_DEBUG, "(c-ares resolver) " format, __VA_ARGS__); \ + } \ + } while (0) typedef struct grpc_ares_request grpc_ares_request; diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index b3a2545a189..11936dc8cce 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -771,10 +771,12 @@ void grpc_chttp2_complete_closure_step(grpc_chttp2_transport* t, // extern grpc_core::TraceFlag grpc_http_trace; // extern grpc_core::TraceFlag grpc_flowctl_trace; -#define GRPC_CHTTP2_IF_TRACING(stmt) \ - if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { \ - (stmt); \ - } +#define GRPC_CHTTP2_IF_TRACING(stmt) \ + do { \ + if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { \ + (stmt); \ + } \ + } while (0) void grpc_chttp2_fake_status(grpc_chttp2_transport* t, grpc_chttp2_stream* stream, grpc_error* error); diff --git a/src/core/lib/iomgr/executor.cc b/src/core/lib/iomgr/executor.cc index 9b967a4fe7a..8adc0902bd1 100644 --- a/src/core/lib/iomgr/executor.cc +++ b/src/core/lib/iomgr/executor.cc @@ -36,15 +36,19 @@ #define MAX_DEPTH 2 -#define EXECUTOR_TRACE(format, ...) \ - if (GRPC_TRACE_FLAG_ENABLED(executor_trace)) { \ - gpr_log(GPR_INFO, "EXECUTOR " format, __VA_ARGS__); \ - } +#define EXECUTOR_TRACE(format, ...) \ + do { \ + if (GRPC_TRACE_FLAG_ENABLED(executor_trace)) { \ + gpr_log(GPR_INFO, "EXECUTOR " format, __VA_ARGS__); \ + } \ + } while (0) -#define EXECUTOR_TRACE0(str) \ - if (GRPC_TRACE_FLAG_ENABLED(executor_trace)) { \ - gpr_log(GPR_INFO, "EXECUTOR " str); \ - } +#define EXECUTOR_TRACE0(str) \ + do { \ + if (GRPC_TRACE_FLAG_ENABLED(executor_trace)) { \ + gpr_log(GPR_INFO, "EXECUTOR " str); \ + } \ + } while (0) namespace grpc_core { namespace { diff --git a/src/core/lib/surface/call.h b/src/core/lib/surface/call.h index 11bde0787cb..15392fea6dc 100644 --- a/src/core/lib/surface/call.h +++ b/src/core/lib/surface/call.h @@ -102,8 +102,11 @@ void grpc_call_context_set(grpc_call* call, grpc_context_index elem, void* grpc_call_context_get(grpc_call* call, grpc_context_index elem); #define GRPC_CALL_LOG_BATCH(sev, call, ops, nops, tag) \ - if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace)) \ - grpc_call_log_batch(sev, call, ops, nops, tag) + do { \ + if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace)) { \ + grpc_call_log_batch(sev, call, ops, nops, tag); \ + } \ + } while (0) uint8_t grpc_call_is_client(grpc_call* call); diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index bb5921a6a55..e796071eedc 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -411,14 +411,16 @@ static const cq_vtable g_cq_vtable[] = { grpc_core::TraceFlag grpc_cq_pluck_trace(false, "queue_pluck"); -#define GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, event) \ - if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) && \ - (GRPC_TRACE_FLAG_ENABLED(grpc_cq_pluck_trace) || \ - (event)->type != GRPC_QUEUE_TIMEOUT)) { \ - char* _ev = grpc_event_string(event); \ - gpr_log(GPR_INFO, "RETURN_EVENT[%p]: %s", cq, _ev); \ - gpr_free(_ev); \ - } +#define GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, event) \ + do { \ + if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) && \ + (GRPC_TRACE_FLAG_ENABLED(grpc_cq_pluck_trace) || \ + (event)->type != GRPC_QUEUE_TIMEOUT)) { \ + char* _ev = grpc_event_string(event); \ + gpr_log(GPR_INFO, "RETURN_EVENT[%p]: %s", cq, _ev); \ + gpr_free(_ev); \ + } \ + } while (0) static void on_pollset_shutdown_done(void* cq, grpc_error* error); From ce77350b50898687fc0954bc82ccc1aa00cfe793 Mon Sep 17 00:00:00 2001 From: jiangtaoli2016 Date: Wed, 8 May 2019 09:48:37 -0700 Subject: [PATCH 0156/1555] Montly update of room pem certificates --- etc/roots.pem | 146 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) diff --git a/etc/roots.pem b/etc/roots.pem index be598710ddd..22bd2ab88dd 100644 --- a/etc/roots.pem +++ b/etc/roots.pem @@ -4552,3 +4552,149 @@ Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayh jWZSaX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw 3kAP+HwV96LOPNdeE4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0= -----END CERTIFICATE----- + +# Issuer: CN=emSign Root CA - G1 O=eMudhra Technologies Limited OU=emSign PKI +# Subject: CN=emSign Root CA - G1 O=eMudhra Technologies Limited OU=emSign PKI +# Label: "emSign Root CA - G1" +# Serial: 235931866688319308814040 +# MD5 Fingerprint: 9c:42:84:57:dd:cb:0b:a7:2e:95:ad:b6:f3:da:bc:ac +# SHA1 Fingerprint: 8a:c7:ad:8f:73:ac:4e:c1:b5:75:4d:a5:40:f4:fc:cf:7c:b5:8e:8c +# SHA256 Fingerprint: 40:f6:af:03:46:a9:9a:a1:cd:1d:55:5a:4e:9c:ce:62:c7:f9:63:46:03:ee:40:66:15:83:3d:c8:c8:d0:03:67 +-----BEGIN CERTIFICATE----- +MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYD +VQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBU +ZWNobm9sb2dpZXMgTGltaXRlZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBH +MTAeFw0xODAyMTgxODMwMDBaFw00MzAyMTgxODMwMDBaMGcxCzAJBgNVBAYTAklO +MRMwEQYDVQQLEwplbVNpZ24gUEtJMSUwIwYDVQQKExxlTXVkaHJhIFRlY2hub2xv +Z2llcyBMaW1pdGVkMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEcxMIIBIjAN +BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0u76WaK7p1b1TST0Bsew+eeuGQz +f2N4aLTNLnF115sgxk0pvLZoYIr3IZpWNVrzdr3YzZr/k1ZLpVkGoZM0Kd0WNHVO +8oG0x5ZOrRkVUkr+PHB1cM2vK6sVmjM8qrOLqs1D/fXqcP/tzxE7lM5OMhbTI0Aq +d7OvPAEsbO2ZLIvZTmmYsvePQbAyeGHWDV/D+qJAkh1cF+ZwPjXnorfCYuKrpDhM +tTk1b+oDafo6VGiFbdbyL0NVHpENDtjVaqSW0RM8LHhQ6DqS0hdW5TUaQBw+jSzt +Od9C4INBdN+jzcKGYEho42kLVACL5HZpIQ15TjQIXhTCzLG3rdd8cIrHhQIDAQAB +o0IwQDAdBgNVHQ4EFgQU++8Nhp6w492pufEhF38+/PB3KxowDgYDVR0PAQH/BAQD +AgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFn/8oz1h31x +PaOfG1vR2vjTnGs2vZupYeveFix0PZ7mddrXuqe8QhfnPZHr5X3dPpzxz5KsbEjM +wiI/aTvFthUvozXGaCocV685743QNcMYDHsAVhzNixl03r4PEuDQqqE/AjSxcM6d +GNYIAwlG7mDgfrbESQRRfXBgvKqy/3lyeqYdPV8q+Mri/Tm3R7nrft8EI6/6nAYH +6ftjk4BAtcZsCjEozgyfz7MjNYBBjWzEN3uBL4ChQEKF6dk4jeihU80Bv2noWgby +RQuQ+q7hv53yrlc8pa6yVvSLZUDp/TGBLPQ5Cdjua6e0ph0VpZj3AYHYhX3zUVxx +iN66zB+Afko= +-----END CERTIFICATE----- + +# Issuer: CN=emSign ECC Root CA - G3 O=eMudhra Technologies Limited OU=emSign PKI +# Subject: CN=emSign ECC Root CA - G3 O=eMudhra Technologies Limited OU=emSign PKI +# Label: "emSign ECC Root CA - G3" +# Serial: 287880440101571086945156 +# MD5 Fingerprint: ce:0b:72:d1:9f:88:8e:d0:50:03:e8:e3:b8:8b:67:40 +# SHA1 Fingerprint: 30:43:fa:4f:f2:57:dc:a0:c3:80:ee:2e:58:ea:78:b2:3f:e6:bb:c1 +# SHA256 Fingerprint: 86:a1:ec:ba:08:9c:4a:8d:3b:be:27:34:c6:12:ba:34:1d:81:3e:04:3c:f9:e8:a8:62:cd:5c:57:a3:6b:be:6b +-----BEGIN CERTIFICATE----- +MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQG +EwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNo +bm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g +RzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4MTgzMDAwWjBrMQswCQYDVQQGEwJJ +TjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9s +b2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMw +djAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0 +WXTsuwYc58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xyS +fvalY8L1X44uT6EYGQIrMgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuB +zhccLikenEhjQjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggq +hkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+DCBeQyh+KTOgNG3qxrdWB +CUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7jHvrZQnD ++JbNR6iC8hZVdyR+EhCVBCyj +-----END CERTIFICATE----- + +# Issuer: CN=emSign Root CA - C1 O=eMudhra Inc OU=emSign PKI +# Subject: CN=emSign Root CA - C1 O=eMudhra Inc OU=emSign PKI +# Label: "emSign Root CA - C1" +# Serial: 825510296613316004955058 +# MD5 Fingerprint: d8:e3:5d:01:21:fa:78:5a:b0:df:ba:d2:ee:2a:5f:68 +# SHA1 Fingerprint: e7:2e:f1:df:fc:b2:09:28:cf:5d:d4:d5:67:37:b1:51:cb:86:4f:01 +# SHA256 Fingerprint: 12:56:09:aa:30:1d:a0:a2:49:b9:7a:82:39:cb:6a:34:21:6f:44:dc:ac:9f:39:54:b1:42:92:f2:e8:c8:60:8f +-----BEGIN CERTIFICATE----- +MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELBQAwVjELMAkG +A1UEBhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEg +SW5jMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEMxMB4XDTE4MDIxODE4MzAw +MFoXDTQzMDIxODE4MzAwMFowVjELMAkGA1UEBhMCVVMxEzARBgNVBAsTCmVtU2ln +biBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQDExNlbVNpZ24gUm9v +dCBDQSAtIEMxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+upufGZ +BczYKCFK83M0UYRWEPWgTywS4/oTmifQz/l5GnRfHXk5/Fv4cI7gklL35CX5VIPZ +HdPIWoU/Xse2B+4+wM6ar6xWQio5JXDWv7V7Nq2s9nPczdcdioOl+yuQFTdrHCZH +3DspVpNqs8FqOp099cGXOFgFixwR4+S0uF2FHYP+eF8LRWgYSKVGczQ7/g/IdrvH +GPMF0Ybzhe3nudkyrVWIzqa2kbBPrH4VI5b2P/AgNBbeCsbEBEV5f6f9vtKppa+c +xSMq9zwhbL2vj07FOrLzNBL834AaSaTUqZX3noleoomslMuoaJuvimUnzYnu3Yy1 +aylwQ6BpC+S5DwIDAQABo0IwQDAdBgNVHQ4EFgQU/qHgcB4qAzlSWkK+XJGFehiq +TbUwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEL +BQADggEBAMJKVvoVIXsoounlHfv4LcQ5lkFMOycsxGwYFYDGrK9HWS8mC+M2sO87 +/kOXSTKZEhVb3xEp/6tT+LvBeA+snFOvV71ojD1pM/CjoCNjO2RnIkSt1XHLVip4 +kqNPEjE2NuLe/gDEo2APJ62gsIq1NnpSob0n9CAnYuhNlCQT5AoE6TyrLshDCUrG +YQTlSTR+08TI9Q/Aqum6VF7zYytPT1DU/rl7mYw9wC68AivTxEDkigcxHpvOJpkT ++xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQBmIMMMAVSKeo +WXzhriKi4gp6D/piq1JM4fHfyr6DDUI= +-----END CERTIFICATE----- + +# Issuer: CN=emSign ECC Root CA - C3 O=eMudhra Inc OU=emSign PKI +# Subject: CN=emSign ECC Root CA - C3 O=eMudhra Inc OU=emSign PKI +# Label: "emSign ECC Root CA - C3" +# Serial: 582948710642506000014504 +# MD5 Fingerprint: 3e:53:b3:a3:81:ee:d7:10:f8:d3:b0:1d:17:92:f5:d5 +# SHA1 Fingerprint: b6:af:43:c2:9b:81:53:7d:f6:ef:6b:c3:1f:1f:60:15:0c:ee:48:66 +# SHA256 Fingerprint: bc:4d:80:9b:15:18:9d:78:db:3e:1d:8c:f4:f9:72:6a:79:5d:a1:64:3c:a5:f1:35:8e:1d:db:0e:dc:0d:7e:b3 +-----BEGIN CERTIFICATE----- +MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQG +EwJVUzETMBEGA1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMx +IDAeBgNVBAMTF2VtU2lnbiBFQ0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAw +MFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UEBhMCVVMxEzARBgNVBAsTCmVtU2ln +biBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQDExdlbVNpZ24gRUND +IFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd6bci +MK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4Ojavti +sIGJAnB9SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0O +BBYEFPtaSNCAIEDyqOkAB2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB +Af8EBTADAQH/MAoGCCqGSM49BAMDA2gAMGUCMQC02C8Cif22TGK6Q04ThHK1rt0c +3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwUZOR8loMRnLDRWmFLpg9J +0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ== +-----END CERTIFICATE----- + +# Issuer: CN=Hongkong Post Root CA 3 O=Hongkong Post +# Subject: CN=Hongkong Post Root CA 3 O=Hongkong Post +# Label: "Hongkong Post Root CA 3" +# Serial: 46170865288971385588281144162979347873371282084 +# MD5 Fingerprint: 11:fc:9f:bd:73:30:02:8a:fd:3f:f3:58:b9:cb:20:f0 +# SHA1 Fingerprint: 58:a2:d0:ec:20:52:81:5b:c1:f3:f8:64:02:24:4e:c2:8e:02:4b:02 +# SHA256 Fingerprint: 5a:2f:c0:3f:0c:83:b0:90:bb:fa:40:60:4b:09:88:44:6c:76:36:18:3d:f9:84:6e:17:10:1a:44:7f:b8:ef:d6 +-----BEGIN CERTIFICATE----- +MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQEL +BQAwbzELMAkGA1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJ +SG9uZyBLb25nMRYwFAYDVQQKEw1Ib25na29uZyBQb3N0MSAwHgYDVQQDExdIb25n +a29uZyBQb3N0IFJvb3QgQ0EgMzAeFw0xNzA2MDMwMjI5NDZaFw00MjA2MDMwMjI5 +NDZaMG8xCzAJBgNVBAYTAkhLMRIwEAYDVQQIEwlIb25nIEtvbmcxEjAQBgNVBAcT +CUhvbmcgS29uZzEWMBQGA1UEChMNSG9uZ2tvbmcgUG9zdDEgMB4GA1UEAxMXSG9u +Z2tvbmcgUG9zdCBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK +AoICAQCziNfqzg8gTr7m1gNt7ln8wlffKWihgw4+aMdoWJwcYEuJQwy51BWy7sFO +dem1p+/l6TWZ5Mwc50tfjTMwIDNT2aa71T4Tjukfh0mtUC1Qyhi+AViiE3CWu4mI +VoBc+L0sPOFMV4i707mV78vH9toxdCim5lSJ9UExyuUmGs2C4HDaOym71QP1mbpV +9WTRYA6ziUm4ii8F0oRFKHyPaFASePwLtVPLwpgchKOesL4jpNrcyCse2m5FHomY +2vkALgbpDDtw1VAliJnLzXNg99X/NWfFobxeq81KuEXryGgeDQ0URhLj0mRiikKY +vLTGCAj4/ahMZJx2Ab0vqWwzD9g/KLg8aQFChn5pwckGyuV6RmXpwtZQQS4/t+Tt +bNe/JgERohYpSms0BpDsE9K2+2p20jzt8NYt3eEV7KObLyzJPivkaTv/ciWxNoZb +x39ri1UbSsUgYT2uy1DhCDq+sI9jQVMwCFk8mB13umOResoQUGC/8Ne8lYePl8X+ +l2oBlKN8W4UdKjk60FSh0Tlxnf0h+bV78OLgAo9uliQlLKAeLKjEiafv7ZkGL7YK +TE/bosw3Gq9HhS2KX8Q0NEwA/RiTZxPRN+ZItIsGxVd7GYYKecsAyVKvQv83j+Gj +Hno9UKtjBucVtT+2RTeUN7F+8kjDf8V1/peNRY8apxpyKBpADwIDAQABo2MwYTAP +BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBQXnc0e +i9Y5K3DTXNSguB+wAPzFYTAdBgNVHQ4EFgQUF53NHovWOStw01zUoLgfsAD8xWEw +DQYJKoZIhvcNAQELBQADggIBAFbVe27mIgHSQpsY1Q7XZiNc4/6gx5LS6ZStS6LG +7BJ8dNVI0lkUmcDrudHr9EgwW62nV3OZqdPlt9EuWSRY3GguLmLYauRwCy0gUCCk +MpXRAJi70/33MvJJrsZ64Ee+bs7Lo3I6LWldy8joRTnU+kLBEUx3XZL7av9YROXr +gZ6voJmtvqkBZss4HTzfQx/0TW60uhdG/H39h4F5ag0zD/ov+BS5gLNdTaqX4fnk +GMX41TiMJjz98iji7lpJiCzfeT2OnpA8vUFKOt1b9pq0zj8lMH8yfaIDlNDceqFS +3m6TjRgm/VWsvY+b0s+v54Ysyx8Jb6NvqYTUc79NoXQbTiNg8swOqn+knEwlqLJm +Ozj/2ZQw9nKEvmhVEA/GcywWaZMH/rFF7buiVWqw2rVKAiUnhde3t4ZEFolsgCs+ +l6mc1X5VTMbeRRAc6uk7nwNT7u56AQIWeNTowr5GdogTPyK7SBIdUgC0An4hGh6c +JfTzPV4e0hz5sy229zdcxsshTrD3mUcYhcErulWuBurQB7Lcq9CClnXO0lD+mefP +L5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB60PZ2Pierc+xYw5F9KBa +LJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fqdBb9HxEG +mpv0 +-----END CERTIFICATE----- From 983f678cb841060cd20e4f71757b67679890941c Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Wed, 8 May 2019 12:49:38 -0400 Subject: [PATCH 0157/1555] Mark it unlikely for Unref() to return true. In the hot path, specially when the dtor of a class is inlined, we will have to skip quite a few instructions (for Delete and dtor) before returning. Mark Unref() as unlikely so that compiler moves the decrement-refcnt-and-return code instructions to the front. --- src/core/ext/transport/chttp2/transport/internal.h | 2 +- src/core/lib/gprpp/orphanable.h | 4 ++-- src/core/lib/gprpp/ref_counted.h | 4 ++-- src/core/lib/transport/metadata.cc | 4 ++-- src/core/lib/transport/transport.h | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 0a55ee111ee..4cbe02ac463 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -238,7 +238,7 @@ class Chttp2IncomingByteStream : public ByteStream { // switch to std::shared_ptr<>. void Ref() { refs_.Ref(); } void Unref() { - if (refs_.Unref()) { + if (GPR_UNLIKELY(refs_.Unref())) { grpc_core::Delete(this); } } diff --git a/src/core/lib/gprpp/orphanable.h b/src/core/lib/gprpp/orphanable.h index dda5026cbca..2e467e49060 100644 --- a/src/core/lib/gprpp/orphanable.h +++ b/src/core/lib/gprpp/orphanable.h @@ -110,12 +110,12 @@ class InternallyRefCounted : public Orphanable { } void Unref() { - if (refs_.Unref()) { + if (GPR_UNLIKELY(refs_.Unref())) { Delete(static_cast(this)); } } void Unref(const DebugLocation& location, const char* reason) { - if (refs_.Unref(location, reason)) { + if (GPR_UNLIKELY(refs_.Unref(location, reason))) { Delete(static_cast(this)); } } diff --git a/src/core/lib/gprpp/ref_counted.h b/src/core/lib/gprpp/ref_counted.h index 87b342e0093..83e9429ba37 100644 --- a/src/core/lib/gprpp/ref_counted.h +++ b/src/core/lib/gprpp/ref_counted.h @@ -211,12 +211,12 @@ class RefCounted : public Impl { // private, since it will only be used by RefCountedPtr<>, which is a // friend of this class. void Unref() { - if (refs_.Unref()) { + if (GPR_UNLIKELY(refs_.Unref())) { Delete(static_cast(this)); } } void Unref(const DebugLocation& location, const char* reason) { - if (refs_.Unref(location, reason)) { + if (GPR_UNLIKELY(refs_.Unref(location, reason))) { Delete(static_cast(this)); } } diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc index 7e0b2163246..4609eb42cdc 100644 --- a/src/core/lib/transport/metadata.cc +++ b/src/core/lib/transport/metadata.cc @@ -466,7 +466,7 @@ void grpc_mdelem_do_unref(grpc_mdelem gmd DEBUG_ARGS) { case GRPC_MDELEM_STORAGE_INTERNED: { auto* md = reinterpret_cast GRPC_MDELEM_DATA(gmd); uint32_t hash = md->hash(); - if (md->Unref(FWD_DEBUG_ARGS)) { + if (GPR_UNLIKELY(md->Unref(FWD_DEBUG_ARGS))) { /* once the refcount hits zero, some other thread can come along and free md at any time: it's unsafe from this point on to access it */ note_disposed_interned_metadata(hash); @@ -475,7 +475,7 @@ void grpc_mdelem_do_unref(grpc_mdelem gmd DEBUG_ARGS) { } case GRPC_MDELEM_STORAGE_ALLOCATED: { auto* md = reinterpret_cast GRPC_MDELEM_DATA(gmd); - if (md->Unref(FWD_DEBUG_ARGS)) { + if (GPR_UNLIKELY(md->Unref(FWD_DEBUG_ARGS))) { grpc_core::Delete(md); } break; diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h index aac136b92dd..a6a6e904f08 100644 --- a/src/core/lib/transport/transport.h +++ b/src/core/lib/transport/transport.h @@ -98,7 +98,7 @@ inline void grpc_stream_unref(grpc_stream_refcount* refcount, #else inline void grpc_stream_unref(grpc_stream_refcount* refcount) { #endif - if (refcount->refs.Unref()) { + if (GPR_UNLIKELY(refcount->refs.Unref())) { grpc_stream_destroy(refcount); } } From 3d5d2a122de06018ebd71fcfb63c744879f1de25 Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Tue, 7 May 2019 16:49:12 -0700 Subject: [PATCH 0158/1555] Extracted the code of Cpp Generator into a header --- BUILD | 1 + src/compiler/cpp_plugin.cc | 132 +------------------------------ src/compiler/cpp_plugin.h | 154 +++++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+), 131 deletions(-) create mode 100644 src/compiler/cpp_plugin.h diff --git a/BUILD b/BUILD index 7f7add436fb..a03d2b61be4 100644 --- a/BUILD +++ b/BUILD @@ -433,6 +433,7 @@ grpc_cc_library( "src/compiler/config.h", "src/compiler/cpp_generator.h", "src/compiler/cpp_generator_helpers.h", + "src/compiler/cpp_plugin.h", "src/compiler/csharp_generator.h", "src/compiler/csharp_generator_helpers.h", "src/compiler/generator_helpers.h", diff --git a/src/compiler/cpp_plugin.cc b/src/compiler/cpp_plugin.cc index 3c09b6feb24..2de2745445f 100644 --- a/src/compiler/cpp_plugin.cc +++ b/src/compiler/cpp_plugin.cc @@ -18,137 +18,7 @@ // Generates cpp gRPC service interface out of Protobuf IDL. // - -#include -#include - -#include "src/compiler/config.h" - -#include "src/compiler/cpp_generator.h" -#include "src/compiler/generator_helpers.h" -#include "src/compiler/protobuf_plugin.h" - -class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { - public: - CppGrpcGenerator() {} - virtual ~CppGrpcGenerator() {} - - virtual bool Generate(const grpc::protobuf::FileDescriptor* file, - const grpc::string& parameter, - grpc::protobuf::compiler::GeneratorContext* context, - grpc::string* error) const { - if (file->options().cc_generic_services()) { - *error = - "cpp grpc proto compiler plugin does not work with generic " - "services. To generate cpp grpc APIs, please set \"" - "cc_generic_service = false\"."; - return false; - } - - grpc_cpp_generator::Parameters generator_parameters; - generator_parameters.use_system_headers = true; - generator_parameters.generate_mock_code = false; - generator_parameters.include_import_headers = false; - - ProtoBufFile pbfile(file); - - if (!parameter.empty()) { - std::vector parameters_list = - grpc_generator::tokenize(parameter, ","); - for (auto parameter_string = parameters_list.begin(); - parameter_string != parameters_list.end(); parameter_string++) { - std::vector param = - grpc_generator::tokenize(*parameter_string, "="); - if (param[0] == "services_namespace") { - generator_parameters.services_namespace = param[1]; - } else if (param[0] == "use_system_headers") { - if (param[1] == "true") { - generator_parameters.use_system_headers = true; - } else if (param[1] == "false") { - generator_parameters.use_system_headers = false; - } else { - *error = grpc::string("Invalid parameter: ") + *parameter_string; - return false; - } - } else if (param[0] == "grpc_search_path") { - generator_parameters.grpc_search_path = param[1]; - } else if (param[0] == "generate_mock_code") { - if (param[1] == "true") { - generator_parameters.generate_mock_code = true; - } else if (param[1] != "false") { - *error = grpc::string("Invalid parameter: ") + *parameter_string; - return false; - } - } else if (param[0] == "gmock_search_path") { - generator_parameters.gmock_search_path = param[1]; - } else if (param[0] == "additional_header_includes") { - generator_parameters.additional_header_includes = - grpc_generator::tokenize(param[1], ":"); - } else if (param[0] == "message_header_extension") { - generator_parameters.message_header_extension = param[1]; - } else if (param[0] == "include_import_headers") { - if (param[1] == "true") { - generator_parameters.include_import_headers = true; - } else if (param[1] != "false") { - *error = grpc::string("Invalid parameter: ") + *parameter_string; - return false; - } - } else { - *error = grpc::string("Unknown parameter: ") + *parameter_string; - return false; - } - } - } - - grpc::string file_name = grpc_generator::StripProto(file->name()); - - grpc::string header_code = - grpc_cpp_generator::GetHeaderPrologue(&pbfile, generator_parameters) + - grpc_cpp_generator::GetHeaderIncludes(&pbfile, generator_parameters) + - grpc_cpp_generator::GetHeaderServices(&pbfile, generator_parameters) + - grpc_cpp_generator::GetHeaderEpilogue(&pbfile, generator_parameters); - std::unique_ptr header_output( - context->Open(file_name + ".grpc.pb.h")); - grpc::protobuf::io::CodedOutputStream header_coded_out(header_output.get()); - header_coded_out.WriteRaw(header_code.data(), header_code.size()); - - grpc::string source_code = - grpc_cpp_generator::GetSourcePrologue(&pbfile, generator_parameters) + - grpc_cpp_generator::GetSourceIncludes(&pbfile, generator_parameters) + - grpc_cpp_generator::GetSourceServices(&pbfile, generator_parameters) + - grpc_cpp_generator::GetSourceEpilogue(&pbfile, generator_parameters); - std::unique_ptr source_output( - context->Open(file_name + ".grpc.pb.cc")); - grpc::protobuf::io::CodedOutputStream source_coded_out(source_output.get()); - source_coded_out.WriteRaw(source_code.data(), source_code.size()); - - if (!generator_parameters.generate_mock_code) { - return true; - } - grpc::string mock_code = - grpc_cpp_generator::GetMockPrologue(&pbfile, generator_parameters) + - grpc_cpp_generator::GetMockIncludes(&pbfile, generator_parameters) + - grpc_cpp_generator::GetMockServices(&pbfile, generator_parameters) + - grpc_cpp_generator::GetMockEpilogue(&pbfile, generator_parameters); - std::unique_ptr mock_output( - context->Open(file_name + "_mock.grpc.pb.h")); - grpc::protobuf::io::CodedOutputStream mock_coded_out(mock_output.get()); - mock_coded_out.WriteRaw(mock_code.data(), mock_code.size()); - - return true; - } - - private: - // Insert the given code into the given file at the given insertion point. - void Insert(grpc::protobuf::compiler::GeneratorContext* context, - const grpc::string& filename, const grpc::string& insertion_point, - const grpc::string& code) const { - std::unique_ptr output( - context->OpenForInsert(filename, insertion_point)); - grpc::protobuf::io::CodedOutputStream coded_out(output.get()); - coded_out.WriteRaw(code.data(), code.size()); - } -}; +#include "src/compiler/cpp_plugin.h" int main(int argc, char* argv[]) { CppGrpcGenerator generator; diff --git a/src/compiler/cpp_plugin.h b/src/compiler/cpp_plugin.h new file mode 100644 index 00000000000..1cdf0b3c196 --- /dev/null +++ b/src/compiler/cpp_plugin.h @@ -0,0 +1,154 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_INTERNAL_COMPILER_CPP_PLUGIN_H +#define GRPC_INTERNAL_COMPILER_CPP_PLUGIN_H + +#include +#include + +#include "src/compiler/config.h" + +#include "src/compiler/cpp_generator.h" +#include "src/compiler/generator_helpers.h" +#include "src/compiler/protobuf_plugin.h" + +// Cpp Generator for Protobug IDL +class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { + public: + CppGrpcGenerator() {} + virtual ~CppGrpcGenerator() {} + + virtual bool Generate(const grpc::protobuf::FileDescriptor* file, + const grpc::string& parameter, + grpc::protobuf::compiler::GeneratorContext* context, + grpc::string* error) const { + if (file->options().cc_generic_services()) { + *error = + "cpp grpc proto compiler plugin does not work with generic " + "services. To generate cpp grpc APIs, please set \"" + "cc_generic_service = false\"."; + return false; + } + + grpc_cpp_generator::Parameters generator_parameters; + generator_parameters.use_system_headers = true; + generator_parameters.generate_mock_code = false; + generator_parameters.include_import_headers = false; + + ProtoBufFile pbfile(file); + + if (!parameter.empty()) { + std::vector parameters_list = + grpc_generator::tokenize(parameter, ","); + for (auto parameter_string = parameters_list.begin(); + parameter_string != parameters_list.end(); parameter_string++) { + std::vector param = + grpc_generator::tokenize(*parameter_string, "="); + if (param[0] == "services_namespace") { + generator_parameters.services_namespace = param[1]; + } else if (param[0] == "use_system_headers") { + if (param[1] == "true") { + generator_parameters.use_system_headers = true; + } else if (param[1] == "false") { + generator_parameters.use_system_headers = false; + } else { + *error = grpc::string("Invalid parameter: ") + *parameter_string; + return false; + } + } else if (param[0] == "grpc_search_path") { + generator_parameters.grpc_search_path = param[1]; + } else if (param[0] == "generate_mock_code") { + if (param[1] == "true") { + generator_parameters.generate_mock_code = true; + } else if (param[1] != "false") { + *error = grpc::string("Invalid parameter: ") + *parameter_string; + return false; + } + } else if (param[0] == "gmock_search_path") { + generator_parameters.gmock_search_path = param[1]; + } else if (param[0] == "additional_header_includes") { + generator_parameters.additional_header_includes = + grpc_generator::tokenize(param[1], ":"); + } else if (param[0] == "message_header_extension") { + generator_parameters.message_header_extension = param[1]; + } else if (param[0] == "include_import_headers") { + if (param[1] == "true") { + generator_parameters.include_import_headers = true; + } else if (param[1] != "false") { + *error = grpc::string("Invalid parameter: ") + *parameter_string; + return false; + } + } else { + *error = grpc::string("Unknown parameter: ") + *parameter_string; + return false; + } + } + } + + grpc::string file_name = grpc_generator::StripProto(file->name()); + + grpc::string header_code = + grpc_cpp_generator::GetHeaderPrologue(&pbfile, generator_parameters) + + grpc_cpp_generator::GetHeaderIncludes(&pbfile, generator_parameters) + + grpc_cpp_generator::GetHeaderServices(&pbfile, generator_parameters) + + grpc_cpp_generator::GetHeaderEpilogue(&pbfile, generator_parameters); + std::unique_ptr header_output( + context->Open(file_name + ".grpc.pb.h")); + grpc::protobuf::io::CodedOutputStream header_coded_out(header_output.get()); + header_coded_out.WriteRaw(header_code.data(), header_code.size()); + + grpc::string source_code = + grpc_cpp_generator::GetSourcePrologue(&pbfile, generator_parameters) + + grpc_cpp_generator::GetSourceIncludes(&pbfile, generator_parameters) + + grpc_cpp_generator::GetSourceServices(&pbfile, generator_parameters) + + grpc_cpp_generator::GetSourceEpilogue(&pbfile, generator_parameters); + std::unique_ptr source_output( + context->Open(file_name + ".grpc.pb.cc")); + grpc::protobuf::io::CodedOutputStream source_coded_out(source_output.get()); + source_coded_out.WriteRaw(source_code.data(), source_code.size()); + + if (!generator_parameters.generate_mock_code) { + return true; + } + grpc::string mock_code = + grpc_cpp_generator::GetMockPrologue(&pbfile, generator_parameters) + + grpc_cpp_generator::GetMockIncludes(&pbfile, generator_parameters) + + grpc_cpp_generator::GetMockServices(&pbfile, generator_parameters) + + grpc_cpp_generator::GetMockEpilogue(&pbfile, generator_parameters); + std::unique_ptr mock_output( + context->Open(file_name + "_mock.grpc.pb.h")); + grpc::protobuf::io::CodedOutputStream mock_coded_out(mock_output.get()); + mock_coded_out.WriteRaw(mock_code.data(), mock_code.size()); + + return true; + } + + private: + // Insert the given code into the given file at the given insertion point. + void Insert(grpc::protobuf::compiler::GeneratorContext* context, + const grpc::string& filename, const grpc::string& insertion_point, + const grpc::string& code) const { + std::unique_ptr output( + context->OpenForInsert(filename, insertion_point)); + grpc::protobuf::io::CodedOutputStream coded_out(output.get()); + coded_out.WriteRaw(code.data(), code.size()); + } +}; + +#endif // GRPC_INTERNAL_COMPILER_CPP_PLUGIN_H From 2a4d62819be0b35261b6dcd7a03644451b9875c8 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 10 Jan 2019 03:18:18 -0800 Subject: [PATCH 0159/1555] Revise c-ares timeouts to use c-ares's internal timeout/retry logic --- CMakeLists.txt | 46 +++++++++ Makefile | 72 +++++++++++--- build.yaml | 7 ++ grpc.gyp | 9 ++ include/grpc/impl/codegen/grpc_types.h | 10 +- .../dns/c_ares/grpc_ares_ev_driver.cc | 80 +++++++++++++++ .../resolver/dns/c_ares/grpc_ares_ev_driver.h | 3 + .../dns/c_ares/grpc_ares_ev_driver_windows.cc | 13 ++- .../resolver/dns/c_ares/grpc_ares_wrapper.h | 2 +- test/core/iomgr/resolve_address_test.cc | 17 ++-- test/cpp/naming/BUILD | 13 ++- test/cpp/naming/cancel_ares_query_test.cc | 35 +------ test/cpp/naming/dns_test_util.cc | 97 ++++++++++++++++++ test/cpp/naming/dns_test_util.h | 38 +++++++ test/cpp/naming/gen_build_yaml.py | 3 + .../generate_resolver_component_tests.bzl | 1 + test/cpp/naming/resolver_component_test.cc | 99 +++++++++++++++++-- .../naming/resolver_component_tests_runner.py | 52 ++++++++++ .../naming/resolver_test_record_groups.yaml | 48 +++++++++ .../generated/sources_and_headers.json | 18 ++++ 20 files changed, 594 insertions(+), 69 deletions(-) create mode 100644 test/cpp/naming/dns_test_util.cc create mode 100644 test/cpp/naming/dns_test_util.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e3fc44e4354..8382fb7318f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2905,6 +2905,49 @@ target_link_libraries(test_tcp_server ) +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + +add_library(dns_test_util + test/cpp/naming/dns_test_util.cc +) + +if(WIN32 AND MSVC) + set_target_properties(dns_test_util PROPERTIES COMPILE_PDB_NAME "dns_test_util" + COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" + ) + if (gRPC_INSTALL) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dns_test_util.pdb + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL + ) + endif() +endif() + + +target_include_directories(dns_test_util + PUBLIC $ $ + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) +target_link_libraries(dns_test_util + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + ${_gRPC_GFLAGS_LIBRARIES} +) + + endif (gRPC_BUILD_TESTS) add_library(grpc++ @@ -18490,6 +18533,7 @@ target_include_directories(resolver_component_test_unsecure target_link_libraries(resolver_component_test_unsecure ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} + dns_test_util grpc++_test_util_unsecure grpc_test_util_unsecure grpc++_unsecure @@ -18531,6 +18575,7 @@ target_include_directories(resolver_component_test target_link_libraries(resolver_component_test ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} + dns_test_util grpc++_test_util grpc_test_util grpc++ @@ -18740,6 +18785,7 @@ target_include_directories(cancel_ares_query_test target_link_libraries(cancel_ares_query_test ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} + dns_test_util grpc++_test_util grpc_test_util grpc++ diff --git a/Makefile b/Makefile index 949751ae9b8..3b0e60ecef4 100644 --- a/Makefile +++ b/Makefile @@ -1411,9 +1411,9 @@ pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc ifeq ($(EMBED_OPENSSL),true) -privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_core_stats.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libhttp2_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libbenchmark.a +privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libdns_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_core_stats.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libhttp2_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libbenchmark.a else -privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_core_stats.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libhttp2_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libbenchmark.a +privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libdns_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_core_stats.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libhttp2_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libbenchmark.a endif @@ -5290,6 +5290,55 @@ endif endif +LIBDNS_TEST_UTIL_SRC = \ + test/cpp/naming/dns_test_util.cc \ + +PUBLIC_HEADERS_CXX += \ + +LIBDNS_TEST_UTIL_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBDNS_TEST_UTIL_SRC)))) + + +ifeq ($(NO_SECURE),true) + +# You can't build secure libraries if you don't have OpenSSL. + +$(LIBDIR)/$(CONFIG)/libdns_test_util.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)/libdns_test_util.a: protobuf_dep_error + + +else + +$(LIBDIR)/$(CONFIG)/libdns_test_util.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(PROTOBUF_DEP) $(LIBDNS_TEST_UTIL_OBJS) + $(E) "[AR] Creating $@" + $(Q) mkdir -p `dirname $@` + $(Q) rm -f $(LIBDIR)/$(CONFIG)/libdns_test_util.a + $(Q) $(AR) $(AROPTS) $(LIBDIR)/$(CONFIG)/libdns_test_util.a $(LIBDNS_TEST_UTIL_OBJS) +ifeq ($(SYSTEM),Darwin) + $(Q) ranlib -no_warning_for_no_symbols $(LIBDIR)/$(CONFIG)/libdns_test_util.a +endif + + + + +endif + +endif + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(LIBDNS_TEST_UTIL_OBJS:.o=.dep) +endif +endif + + LIBGRPC++_SRC = \ src/cpp/client/insecure_credentials.cc \ src/cpp/client/secure_credentials.cc \ @@ -21283,16 +21332,16 @@ $(BINDIR)/$(CONFIG)/resolver_component_test_unsecure: protobuf_dep_error else -$(BINDIR)/$(CONFIG)/resolver_component_test_unsecure: $(PROTOBUF_DEP) $(RESOLVER_COMPONENT_TEST_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a +$(BINDIR)/$(CONFIG)/resolver_component_test_unsecure: $(PROTOBUF_DEP) $(RESOLVER_COMPONENT_TEST_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libdns_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(RESOLVER_COMPONENT_TEST_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/resolver_component_test_unsecure + $(Q) $(LDXX) $(LDFLAGS) $(RESOLVER_COMPONENT_TEST_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libdns_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/resolver_component_test_unsecure endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/naming/resolver_component_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a +$(OBJDIR)/$(CONFIG)/test/cpp/naming/resolver_component_test.o: $(LIBDIR)/$(CONFIG)/libdns_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a deps_resolver_component_test_unsecure: $(RESOLVER_COMPONENT_TEST_UNSECURE_OBJS:.o=.dep) @@ -21326,16 +21375,16 @@ $(BINDIR)/$(CONFIG)/resolver_component_test: protobuf_dep_error else -$(BINDIR)/$(CONFIG)/resolver_component_test: $(PROTOBUF_DEP) $(RESOLVER_COMPONENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a +$(BINDIR)/$(CONFIG)/resolver_component_test: $(PROTOBUF_DEP) $(RESOLVER_COMPONENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libdns_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(RESOLVER_COMPONENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/resolver_component_test + $(Q) $(LDXX) $(LDFLAGS) $(RESOLVER_COMPONENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libdns_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/resolver_component_test endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/naming/resolver_component_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a +$(OBJDIR)/$(CONFIG)/test/cpp/naming/resolver_component_test.o: $(LIBDIR)/$(CONFIG)/libdns_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a deps_resolver_component_test: $(RESOLVER_COMPONENT_TEST_OBJS:.o=.dep) @@ -21541,16 +21590,16 @@ $(BINDIR)/$(CONFIG)/cancel_ares_query_test: protobuf_dep_error else -$(BINDIR)/$(CONFIG)/cancel_ares_query_test: $(PROTOBUF_DEP) $(CANCEL_ARES_QUERY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a +$(BINDIR)/$(CONFIG)/cancel_ares_query_test: $(PROTOBUF_DEP) $(CANCEL_ARES_QUERY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libdns_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(CANCEL_ARES_QUERY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/cancel_ares_query_test + $(Q) $(LDXX) $(LDFLAGS) $(CANCEL_ARES_QUERY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libdns_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/cancel_ares_query_test endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/naming/cancel_ares_query_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a +$(OBJDIR)/$(CONFIG)/test/cpp/naming/cancel_ares_query_test.o: $(LIBDIR)/$(CONFIG)/libdns_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a deps_cancel_ares_query_test: $(CANCEL_ARES_QUERY_TEST_OBJS:.o=.dep) @@ -22180,6 +22229,7 @@ test/cpp/interop/interop_server.cc: $(OPENSSL_DEP) test/cpp/interop/interop_server_bootstrap.cc: $(OPENSSL_DEP) test/cpp/interop/server_helper.cc: $(OPENSSL_DEP) test/cpp/microbenchmarks/helpers.cc: $(OPENSSL_DEP) +test/cpp/naming/dns_test_util.cc: $(OPENSSL_DEP) test/cpp/qps/benchmark_config.cc: $(OPENSSL_DEP) test/cpp/qps/client_async.cc: $(OPENSSL_DEP) test/cpp/qps/client_callback.cc: $(OPENSSL_DEP) diff --git a/build.yaml b/build.yaml index 3638e3ce7e7..a61b7987a4e 100644 --- a/build.yaml +++ b/build.yaml @@ -1677,6 +1677,13 @@ libs: - grpc_test_util - grpc - gpr +- name: dns_test_util + build: private + language: c++ + headers: + - test/cpp/naming/dns_test_util.h + src: + - test/cpp/naming/dns_test_util.cc - name: grpc++ build: all language: c++ diff --git a/grpc.gyp b/grpc.gyp index ff77c6fcd59..e6ed4d7318d 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -1405,6 +1405,15 @@ 'test/core/util/test_tcp_server.cc', ], }, + { + 'target_name': 'dns_test_util', + 'type': 'static_library', + 'dependencies': [ + ], + 'sources': [ + 'test/cpp/naming/dns_test_util.cc', + ], + }, { 'target_name': 'grpc++', 'type': 'static_library', diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 33c160b4240..65582e6e85d 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -359,10 +359,12 @@ typedef struct { * load balancing policy. Note that this only works with the "ares" * DNS resolver, and isn't supported by the "native" DNS resolver. */ #define GRPC_ARG_DNS_ENABLE_SRV_QUERIES "grpc.dns_enable_srv_queries" -/** If set, determines the number of milliseconds that the c-ares based - * DNS resolver will wait on queries before cancelling them. The default value - * is 10000. Setting this to "0" will disable c-ares query timeouts - * entirely. */ +/** If set, determines an upper bound on the number of milliseconds that the + * c-ares based DNS resolver will wait on queries before cancelling them. + * The default value is 120,000. Setting this to "0" will disable the + * overall timeout entirely. Note that this doesn't include internal c-ares + * timeouts/backoff/retry logic, and so the actual DNS resolution may time out + * sooner than the value specified here. */ #define GRPC_ARG_DNS_ARES_QUERY_TIMEOUT_MS "grpc.dns_ares_query_timeout" /** If set, uses a local subchannel pool within the channel. Otherwise, uses the * global subchannel pool. */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc index 9fff92da52f..4ad80786519 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc @@ -84,6 +84,10 @@ struct grpc_ares_ev_driver { grpc_timer query_timeout; /** cancels queries on a timeout */ grpc_closure on_timeout_locked; + /** alarm to poll ares_process on in case fd events don't happen */ + grpc_timer ares_backup_poll_alarm; + /** polls ares_process on a periodic timer */ + grpc_closure on_ares_backup_poll_alarm_locked; }; static void grpc_ares_notify_on_event_locked(grpc_ares_ev_driver* ev_driver); @@ -130,6 +134,13 @@ static void fd_node_shutdown_locked(fd_node* fdn, const char* reason) { static void on_timeout_locked(void* arg, grpc_error* error); +static void on_ares_backup_poll_alarm_locked(void* arg, grpc_error* error); + +static void noop_inject_channel_config(ares_channel channel) {} + +void (*grpc_ares_test_only_inject_config)(ares_channel channel) = + noop_inject_channel_config; + grpc_error* grpc_ares_ev_driver_create_locked(grpc_ares_ev_driver** ev_driver, grpc_pollset_set* pollset_set, int query_timeout_ms, @@ -140,6 +151,7 @@ grpc_error* grpc_ares_ev_driver_create_locked(grpc_ares_ev_driver** ev_driver, memset(&opts, 0, sizeof(opts)); opts.flags |= ARES_FLAG_STAYOPEN; int status = ares_init_options(&(*ev_driver)->channel, &opts, ARES_OPT_FLAGS); + grpc_ares_test_only_inject_config((*ev_driver)->channel); GRPC_CARES_TRACE_LOG("request:%p grpc_ares_ev_driver_create_locked", request); if (status != ARES_SUCCESS) { char* err_msg; @@ -163,6 +175,9 @@ grpc_error* grpc_ares_ev_driver_create_locked(grpc_ares_ev_driver** ev_driver, ->polled_fd_factory->ConfigureAresChannelLocked((*ev_driver)->channel); GRPC_CLOSURE_INIT(&(*ev_driver)->on_timeout_locked, on_timeout_locked, *ev_driver, grpc_combiner_scheduler(combiner)); + GRPC_CLOSURE_INIT(&(*ev_driver)->on_ares_backup_poll_alarm_locked, + on_ares_backup_poll_alarm_locked, *ev_driver, + grpc_combiner_scheduler(combiner)); (*ev_driver)->query_timeout_ms = query_timeout_ms; return GRPC_ERROR_NONE; } @@ -174,6 +189,7 @@ void grpc_ares_ev_driver_on_queries_complete_locked( // fds; if it's not working, there are no fds to shut down. ev_driver->shutting_down = true; grpc_timer_cancel(&ev_driver->query_timeout); + grpc_timer_cancel(&ev_driver->ares_backup_poll_alarm); grpc_ares_ev_driver_unref(ev_driver); } @@ -204,6 +220,21 @@ static fd_node* pop_fd_node_locked(fd_node** head, ares_socket_t as) { return nullptr; } +static grpc_millis calculate_next_ares_backup_poll_alarm_ms( + grpc_ares_ev_driver* driver) { + // An alternative here could be to use ares_timeout to try to be more + // accurate, but that would require using "struct timeval"'s, which just makes + // things a bit more complicated. So just poll every second, as suggested + // by the c-ares code comments. + grpc_millis ms_until_next_ares_backup_poll_alarm = 1000; + GRPC_CARES_TRACE_LOG( + "request:%p ev_driver=%p. next ares process poll time in " + "%" PRId64 " ms", + driver->request, driver, ms_until_next_ares_backup_poll_alarm); + return ms_until_next_ares_backup_poll_alarm + + grpc_core::ExecCtx::Get()->Now(); +} + static void on_timeout_locked(void* arg, grpc_error* error) { grpc_ares_ev_driver* driver = static_cast(arg); GRPC_CARES_TRACE_LOG( @@ -216,6 +247,47 @@ static void on_timeout_locked(void* arg, grpc_error* error) { grpc_ares_ev_driver_unref(driver); } +/* In case of non-responsive DNS servers, dropped packets, etc., c-ares has + * intelligent timeout and retry logic, which we can take advantage of by + * polling ares_process_fd on time intervals. Overall, the c-ares library is + * meant to be called into and given a chance to proceed name resolution: + * a) when fd events happen + * b) when some time has passed without fd events having happened + * For the latter, we use this backup poller. Also see + * https://github.com/grpc/grpc/pull/17688 description for more details. */ +static void on_ares_backup_poll_alarm_locked(void* arg, grpc_error* error) { + grpc_ares_ev_driver* driver = static_cast(arg); + GRPC_CARES_TRACE_LOG( + "request:%p ev_driver=%p on_ares_backup_poll_alarm_locked. " + "driver->shutting_down=%d. " + "err=%s", + driver->request, driver, driver->shutting_down, grpc_error_string(error)); + if (!driver->shutting_down && error == GRPC_ERROR_NONE) { + fd_node* fdn = driver->fds; + while (fdn != nullptr) { + if (!fdn->already_shutdown) { + GRPC_CARES_TRACE_LOG( + "request:%p ev_driver=%p on_ares_backup_poll_alarm_locked; " + "ares_process_fd. fd=%s", + driver->request, driver, fdn->grpc_polled_fd->GetName()); + ares_socket_t as = fdn->grpc_polled_fd->GetWrappedAresSocketLocked(); + ares_process_fd(driver->channel, as, as); + } + fdn = fdn->next; + } + if (!driver->shutting_down) { + grpc_millis next_ares_backup_poll_alarm = + calculate_next_ares_backup_poll_alarm_ms(driver); + grpc_ares_ev_driver_ref(driver); + grpc_timer_init(&driver->ares_backup_poll_alarm, + next_ares_backup_poll_alarm, + &driver->on_ares_backup_poll_alarm_locked); + } + grpc_ares_notify_on_event_locked(driver); + } + grpc_ares_ev_driver_unref(driver); +} + static void on_readable_locked(void* arg, grpc_error* error) { fd_node* fdn = static_cast(arg); GPR_ASSERT(fdn->readable_registered); @@ -353,6 +425,7 @@ void grpc_ares_ev_driver_start_locked(grpc_ares_ev_driver* ev_driver) { if (!ev_driver->working) { ev_driver->working = true; grpc_ares_notify_on_event_locked(ev_driver); + // Initialize overall DNS resolution timeout alarm grpc_millis timeout = ev_driver->query_timeout_ms == 0 ? GRPC_MILLIS_INF_FUTURE @@ -364,6 +437,13 @@ void grpc_ares_ev_driver_start_locked(grpc_ares_ev_driver* ev_driver) { grpc_ares_ev_driver_ref(ev_driver); grpc_timer_init(&ev_driver->query_timeout, timeout, &ev_driver->on_timeout_locked); + // Initialize the backup poll alarm + grpc_millis next_ares_backup_poll_alarm = + calculate_next_ares_backup_poll_alarm_ms(ev_driver); + grpc_ares_ev_driver_ref(ev_driver); + grpc_timer_init(&ev_driver->ares_backup_poll_alarm, + next_ares_backup_poll_alarm, + &ev_driver->on_ares_backup_poll_alarm_locked); } } diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h index b8cefd9470e..2d172eb3d1e 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h @@ -54,6 +54,9 @@ void grpc_ares_ev_driver_on_queries_complete_locked( /* Shutdown all the grpc_fds used by \a ev_driver */ void grpc_ares_ev_driver_shutdown_locked(grpc_ares_ev_driver* ev_driver); +/* Exposed in this header for C-core tests only */ +extern void (*grpc_ares_test_only_inject_config)(ares_channel channel); + namespace grpc_core { /* A wrapped fd that integrates with the grpc iomgr of the current platform. diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc index 7e7e9156461..ce39007f905 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc @@ -109,6 +109,7 @@ class GrpcPolledFdWindows : public GrpcPolledFd { read_closure_ = read_closure; GPR_ASSERT(GRPC_SLICE_LENGTH(read_buf_) == 0); grpc_slice_unref_internal(read_buf_); + GPR_ASSERT(!read_buf_has_data_); read_buf_ = GRPC_SLICE_MALLOC(4192); WSABUF buffer; buffer.buf = (char*)GRPC_SLICE_START_PTR(read_buf_); @@ -175,7 +176,7 @@ class GrpcPolledFdWindows : public GrpcPolledFd { GRPC_CARES_TRACE_LOG( "RecvFrom called on fd:|%s|. Current read buf length:|%d|", GetName(), GRPC_SLICE_LENGTH(read_buf_)); - if (GRPC_SLICE_LENGTH(read_buf_) == 0) { + if (!read_buf_has_data_) { WSASetLastError(WSAEWOULDBLOCK); return -1; } @@ -186,6 +187,9 @@ class GrpcPolledFdWindows : public GrpcPolledFd { } read_buf_ = grpc_slice_sub_no_ref(read_buf_, bytes_read, GRPC_SLICE_LENGTH(read_buf_)); + if (GRPC_SLICE_LENGTH(read_buf_) == 0) { + read_buf_has_data_ = false; + } /* c-ares overloads this recv_from virtual socket function to receive * data on both UDP and TCP sockets, and from is nullptr for TCP. */ if (from != nullptr) { @@ -302,6 +306,11 @@ class GrpcPolledFdWindows : public GrpcPolledFd { polled_fd->OnIocpReadableInner(error); } + // TODO(apolcyn): improve this error handling to be less conversative. + // An e.g. ECONNRESET error here should result in errors when + // c-ares reads from this socket later, but it shouldn't necessarily cancel + // the entire resolution attempt. Doing so will allow the "inject broken + // nameserver list" test to pass on Windows. void OnIocpReadableInner(grpc_error* error) { if (error == GRPC_ERROR_NONE) { if (winsocket_->read_info.wsa_error != 0) { @@ -323,6 +332,7 @@ class GrpcPolledFdWindows : public GrpcPolledFd { if (error == GRPC_ERROR_NONE) { read_buf_ = grpc_slice_sub_no_ref(read_buf_, 0, winsocket_->read_info.bytes_transfered); + read_buf_has_data_ = true; } else { grpc_slice_unref_internal(read_buf_); read_buf_ = grpc_empty_slice(); @@ -370,6 +380,7 @@ class GrpcPolledFdWindows : public GrpcPolledFd { char recv_from_source_addr_[200]; ares_socklen_t recv_from_source_addr_len_; grpc_slice read_buf_; + bool read_buf_has_data_ = false; grpc_slice write_buf_; grpc_closure* read_closure_ = nullptr; grpc_closure* write_closure_ = nullptr; diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h index 28082504565..33d866c0ff0 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h @@ -26,7 +26,7 @@ #include "src/core/lib/iomgr/polling_entity.h" #include "src/core/lib/iomgr/resolve_address.h" -#define GRPC_DNS_ARES_DEFAULT_QUERY_TIMEOUT_MS 10000 +#define GRPC_DNS_ARES_DEFAULT_QUERY_TIMEOUT_MS 120000 extern grpc_core::TraceFlag grpc_trace_cares_address_sorting; diff --git a/test/core/iomgr/resolve_address_test.cc b/test/core/iomgr/resolve_address_test.cc index f59a992416d..1f0c0e3e835 100644 --- a/test/core/iomgr/resolve_address_test.cc +++ b/test/core/iomgr/resolve_address_test.cc @@ -83,7 +83,9 @@ static grpc_millis n_sec_deadline(int seconds) { static void poll_pollset_until_request_done(args_struct* args) { grpc_core::ExecCtx exec_ctx; - grpc_millis deadline = n_sec_deadline(10); + // Try to give enough time for c-ares to run through its retries + // a few times if needed. + grpc_millis deadline = n_sec_deadline(90); while (true) { bool done = gpr_atm_acq_load(&args->done_atm) != 0; if (done) { @@ -371,15 +373,10 @@ int main(int argc, char** argv) { test_missing_default_port(); test_ipv6_with_port(); test_ipv6_without_port(); - if (gpr_stricmp(resolver_type, "ares") != 0) { - // These tests can trigger DNS queries to the nearby nameserver - // that need to come back in order for the test to succeed. - // c-ares is prone to not using the local system caches that the - // native getaddrinfo implementations take advantage of, so running - // these unit tests under c-ares risks flakiness. - test_invalid_ip_addresses(); - test_unparseable_hostports(); - } else { + test_invalid_ip_addresses(); + test_unparseable_hostports(); + if (gpr_stricmp(resolver_type, "ares") == 0) { + // This behavior expectation is specific to c-ares. test_localhost_result_has_ipv6_first(); } grpc_core::Executor::ShutdownAll(); diff --git a/test/cpp/naming/BUILD b/test/cpp/naming/BUILD index 58e70480acf..7db435a3fd4 100644 --- a/test/cpp/naming/BUILD +++ b/test/cpp/naming/BUILD @@ -22,7 +22,7 @@ package( licenses(["notice"]) # Apache v2 -load("//bazel:grpc_build_system.bzl", "grpc_py_binary", "grpc_cc_test") +load("//bazel:grpc_build_system.bzl", "grpc_py_binary", "grpc_cc_test", "grpc_cc_library") load(":generate_resolver_component_tests.bzl", "generate_resolver_component_tests") # Meant to be invoked only through the top-level shell script driver. @@ -39,6 +39,7 @@ grpc_cc_test( srcs = ["cancel_ares_query_test.cc"], external_deps = ["gmock"], deps = [ + ":dns_test_util", "//:gpr", "//:grpc", "//:grpc++", @@ -49,4 +50,14 @@ grpc_cc_test( ], ) +grpc_cc_library( + name = "dns_test_util", + hdrs = ["dns_test_util.h"], + srcs = ["dns_test_util.cc"], + deps = [ + "//:gpr", + "//:grpc", + ], +) + generate_resolver_component_tests() diff --git a/test/cpp/naming/cancel_ares_query_test.cc b/test/cpp/naming/cancel_ares_query_test.cc index bcf96aa1dc5..674e72fdc52 100644 --- a/test/cpp/naming/cancel_ares_query_test.cc +++ b/test/cpp/naming/cancel_ares_query_test.cc @@ -44,6 +44,7 @@ #include "test/core/util/cmdline.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" +#include "test/cpp/naming/dns_test_util.h" #ifdef GPR_WINDOWS #include "src/core/lib/iomgr/sockaddr_windows.h" @@ -76,36 +77,6 @@ void EndTest(grpc_channel* client, grpc_completion_queue* cq) { grpc_completion_queue_destroy(cq); } -class FakeNonResponsiveDNSServer { - public: - FakeNonResponsiveDNSServer(int port) { - socket_ = socket(AF_INET6, SOCK_DGRAM, 0); - if (socket_ == BAD_SOCKET_RETURN_VAL) { - gpr_log(GPR_DEBUG, "Failed to create UDP ipv6 socket"); - abort(); - } - sockaddr_in6 addr; - memset(&addr, 0, sizeof(addr)); - addr.sin6_family = AF_INET6; - addr.sin6_port = htons(port); - ((char*)&addr.sin6_addr)[15] = 1; - if (bind(socket_, (const sockaddr*)&addr, sizeof(addr)) != 0) { - gpr_log(GPR_DEBUG, "Failed to bind UDP ipv6 socket to [::1]:%d", port); - abort(); - } - } - ~FakeNonResponsiveDNSServer() { -#ifdef GPR_WINDOWS - closesocket(socket_); -#else - close(socket_); -#endif - } - - private: - int socket_; -}; - struct ArgsStruct { gpr_atm done_atm; gpr_mu* mu; @@ -184,7 +155,7 @@ class AssertFailureResultHandler : public grpc_core::Resolver::ResultHandler { void TestCancelActiveDNSQuery(ArgsStruct* args) { int fake_dns_port = grpc_pick_unused_port_or_die(); - FakeNonResponsiveDNSServer fake_dns_server(fake_dns_port); + grpc::testing::FakeNonResponsiveDNSServer fake_dns_server(fake_dns_port); char* client_target; GPR_ASSERT(gpr_asprintf( &client_target, @@ -282,7 +253,7 @@ void TestCancelDuringActiveQuery( cancellation_test_query_timeout_setting query_timeout_setting) { // Start up fake non responsive DNS server int fake_dns_port = grpc_pick_unused_port_or_die(); - FakeNonResponsiveDNSServer fake_dns_server(fake_dns_port); + grpc::testing::FakeNonResponsiveDNSServer fake_dns_server(fake_dns_port); // Create a call that will try to use the fake DNS server char* client_target = nullptr; GPR_ASSERT(gpr_asprintf( diff --git a/test/cpp/naming/dns_test_util.cc b/test/cpp/naming/dns_test_util.cc new file mode 100644 index 00000000000..1380d0ab423 --- /dev/null +++ b/test/cpp/naming/dns_test_util.cc @@ -0,0 +1,97 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +#include +#include + +#include "test/cpp/naming/dns_test_util.h" + +#ifdef GPR_WINDOWS +#include "src/core/lib/iomgr/sockaddr_windows.h" +#include "src/core/lib/iomgr/socket_windows.h" +#define BAD_SOCKET_RETURN_VAL INVALID_SOCKET +#else +#include "src/core/lib/iomgr/sockaddr_posix.h" +#define BAD_SOCKET_RETURN_VAL -1 +#endif + +namespace grpc { +namespace testing { + +FakeNonResponsiveDNSServer::FakeNonResponsiveDNSServer(int port) { + udp_socket_ = socket(AF_INET6, SOCK_DGRAM, 0); + tcp_socket_ = socket(AF_INET6, SOCK_STREAM, 0); + if (udp_socket_ == BAD_SOCKET_RETURN_VAL) { + gpr_log(GPR_DEBUG, "Failed to create UDP ipv6 socket"); + abort(); + } + if (tcp_socket_ == BAD_SOCKET_RETURN_VAL) { + gpr_log(GPR_DEBUG, "Failed to create TCP ipv6 socket"); + abort(); + } + sockaddr_in6 addr; + memset(&addr, 0, sizeof(addr)); + addr.sin6_family = AF_INET6; + addr.sin6_port = htons(port); + ((char*)&addr.sin6_addr)[15] = 1; + if (bind(udp_socket_, (const sockaddr*)&addr, sizeof(addr)) != 0) { + gpr_log(GPR_DEBUG, "Failed to bind UDP ipv6 socket to [::1]:%d", port); + abort(); + } +#ifdef GPR_WINDOWS + char val = 1; + if (setsockopt(tcp_socket_, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) == + SOCKET_ERROR) { + gpr_log(GPR_DEBUG, + "Failed to set SO_REUSEADDR on TCP ipv6 socket to [::1]:%d", port); + abort(); + } +#else + int val = 1; + if (setsockopt(tcp_socket_, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) != + 0) { + gpr_log(GPR_DEBUG, + "Failed to set SO_REUSEADDR on TCP ipv6 socket to [::1]:%d", port); + abort(); + } +#endif + if (bind(tcp_socket_, (const sockaddr*)&addr, sizeof(addr)) != 0) { + gpr_log(GPR_DEBUG, "Failed to bind TCP ipv6 socket to [::1]:%d", port); + abort(); + } + if (listen(tcp_socket_, 100)) { + gpr_log(GPR_DEBUG, "Failed to listen on TCP ipv6 socket to [::1]:%d", port); + abort(); + } +} + +FakeNonResponsiveDNSServer::~FakeNonResponsiveDNSServer() { +#ifdef GPR_WINDOWS + closesocket(udp_socket_); + closesocket(tcp_socket_); +#else + close(udp_socket_); + close(tcp_socket_); +#endif +} + +} // namespace testing +} // namespace grpc diff --git a/test/cpp/naming/dns_test_util.h b/test/cpp/naming/dns_test_util.h new file mode 100644 index 00000000000..d5e50992672 --- /dev/null +++ b/test/cpp/naming/dns_test_util.h @@ -0,0 +1,38 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_DNS_TEST_UTIL_H +#define GRPC_DNS_TEST_UTIL_H + +namespace grpc { +namespace testing { + +class FakeNonResponsiveDNSServer { + public: + explicit FakeNonResponsiveDNSServer(int port); + virtual ~FakeNonResponsiveDNSServer(); + + private: + int udp_socket_; + int tcp_socket_; +}; + +} // namespace testing +} // namespace grpc + +#endif /* GRPC_DNS_TEST_UTIL_H */ diff --git a/test/cpp/naming/gen_build_yaml.py b/test/cpp/naming/gen_build_yaml.py index 9bf5ae9b2f8..9cbbbb69254 100755 --- a/test/cpp/naming/gen_build_yaml.py +++ b/test/cpp/naming/gen_build_yaml.py @@ -50,6 +50,7 @@ def _resolver_test_cases(resolver_component_data): ('expected_lb_policy', (test_case['expected_lb_policy'] or '')), ('enable_srv_queries', test_case['enable_srv_queries']), ('enable_txt_queries', test_case['enable_txt_queries']), + ('inject_broken_nameserver_list', test_case['inject_broken_nameserver_list']), ], }) return out @@ -72,6 +73,7 @@ def main(): 'src': ['test/cpp/naming/resolver_component_test.cc'], 'platforms': ['linux', 'posix', 'mac', 'windows'], 'deps': [ + 'dns_test_util', 'grpc++_test_util' + unsecure_build_config_suffix, 'grpc_test_util' + unsecure_build_config_suffix, 'grpc++' + unsecure_build_config_suffix, @@ -130,6 +132,7 @@ def main(): 'src': ['test/cpp/naming/cancel_ares_query_test.cc'], 'platforms': ['linux', 'posix', 'mac', 'windows'], 'deps': [ + 'dns_test_util', 'grpc++_test_util', 'grpc_test_util', 'grpc++', diff --git a/test/cpp/naming/generate_resolver_component_tests.bzl b/test/cpp/naming/generate_resolver_component_tests.bzl index 589176762e6..bcc62f62871 100755 --- a/test/cpp/naming/generate_resolver_component_tests.bzl +++ b/test/cpp/naming/generate_resolver_component_tests.bzl @@ -46,6 +46,7 @@ def generate_resolver_component_tests(): "gmock", ], deps = [ + ":dns_test_util", "//test/cpp/util:test_util%s" % unsecure_build_config_suffix, "//test/core/util:grpc_test_util%s" % unsecure_build_config_suffix, "//:grpc++%s" % unsecure_build_config_suffix, diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index 4d1beb7ec37..e3f3e94d2de 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -39,7 +39,9 @@ #include "test/cpp/util/test_config.h" #include "src/core/ext/filters/client_channel/client_channel.h" +#include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver.h" +#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" @@ -53,9 +55,12 @@ #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/sockaddr_utils.h" +#include "src/core/lib/iomgr/socket_utils.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" +#include "test/cpp/naming/dns_test_util.h" + // TODO: pull in different headers when enabling this // test on windows. Also set BAD_SOCKET_RETURN_VAL // to INVALID_SOCKET on windows. @@ -106,6 +111,17 @@ DEFINE_string( "generate " "the python script runner doesn't allow us to pass a gflags bool to this " "binary."); +DEFINE_string( + inject_broken_nameserver_list, "", + "Whether or not to configure c-ares to use a broken nameserver list, in " + "which " + "the first nameserver in the list is non-responsive, but the second one " + "works, i.e " + "serves the expected DNS records; using for testing such a real scenario." + "It would be better if this arg could be bool, but the way that we " + "generate " + "the python script runner doesn't allow us to pass a gflags bool to this " + "binary."); DEFINE_string(expected_lb_policy, "", "Expected lb policy name that appears in resolver result channel " "arg. Empty for none."); @@ -217,7 +233,10 @@ gpr_timespec NSecondDeadline(int seconds) { } void PollPollsetUntilRequestDone(ArgsStruct* args) { - gpr_timespec deadline = NSecondDeadline(10); + // Use a 20-second timeout to give room for the tests that involve + // a non-responsive name server (c-ares uses a ~5 second query timeout + // for that server before succeeding with the healthy one). + gpr_timespec deadline = NSecondDeadline(20); while (true) { bool done = gpr_atm_acq_load(&args->done_atm) != 0; if (done) { @@ -469,6 +488,50 @@ class CheckingResultHandler : public ResultHandler { } }; +int g_fake_non_responsive_dns_server_port = -1; + +/* This function will configure any ares_channel created by the c-ares based + * resolver. This is useful to effectively mock /etc/resolv.conf settings + * (and equivalent on Windows), which unit tests don't have write permissions. + */ +void InjectBrokenNameServerList(ares_channel channel) { + struct ares_addr_port_node dns_server_addrs[2]; + memset(dns_server_addrs, 0, sizeof(dns_server_addrs)); + char* unused_host; + char* local_dns_server_port; + GPR_ASSERT(gpr_split_host_port(FLAGS_local_dns_server_address.c_str(), + &unused_host, &local_dns_server_port)); + gpr_log(GPR_DEBUG, + "Injecting broken nameserver list. Bad server address:|[::1]:%d|. " + "Good server address:%s", + g_fake_non_responsive_dns_server_port, + FLAGS_local_dns_server_address.c_str()); + // Put the non-responsive DNS server at the front of c-ares's nameserver list. + dns_server_addrs[0].family = AF_INET6; + ((char*)&dns_server_addrs[0].addr.addr6)[15] = 0x1; + dns_server_addrs[0].tcp_port = g_fake_non_responsive_dns_server_port; + dns_server_addrs[0].udp_port = g_fake_non_responsive_dns_server_port; + dns_server_addrs[0].next = &dns_server_addrs[1]; + // Put the actual healthy DNS server after the first one. The expectation is + // that the resolver will timeout the query to the non-responsive DNS server + // and will skip over to this healthy DNS server, without causing any DNS + // resolution errors. + dns_server_addrs[1].family = AF_INET; + ((char*)&dns_server_addrs[1].addr.addr4)[0] = 0x7f; + ((char*)&dns_server_addrs[1].addr.addr4)[3] = 0x1; + dns_server_addrs[1].tcp_port = atoi(local_dns_server_port); + dns_server_addrs[1].udp_port = atoi(local_dns_server_port); + dns_server_addrs[1].next = nullptr; + GPR_ASSERT(ares_set_servers_ports(channel, dns_server_addrs) == ARES_SUCCESS); + gpr_free(local_dns_server_port); + gpr_free(unused_host); +} + +void StartResolvingLocked(void* arg, grpc_error* unused) { + grpc_core::Resolver* r = static_cast(arg); + r->StartLocked(); +} + void RunResolvesRelevantRecordsTest( grpc_core::UniquePtr ( *CreateResultHandler)(ArgsStruct* args)) { @@ -480,9 +543,29 @@ void RunResolvesRelevantRecordsTest( args.expected_lb_policy = FLAGS_expected_lb_policy; // maybe build the address with an authority char* whole_uri = nullptr; - GPR_ASSERT(gpr_asprintf(&whole_uri, "dns://%s/%s", - FLAGS_local_dns_server_address.c_str(), - FLAGS_target_name.c_str())); + gpr_log(GPR_DEBUG, + "resolver_component_test: --inject_broken_nameserver_list: %s", + FLAGS_inject_broken_nameserver_list.c_str()); + grpc_core::UniquePtr + fake_non_responsive_dns_server; + if (FLAGS_inject_broken_nameserver_list == "True") { + g_fake_non_responsive_dns_server_port = grpc_pick_unused_port_or_die(); + fake_non_responsive_dns_server.reset( + grpc_core::New( + g_fake_non_responsive_dns_server_port)); + grpc_ares_test_only_inject_config = InjectBrokenNameServerList; + GPR_ASSERT( + gpr_asprintf(&whole_uri, "dns:///%s", FLAGS_target_name.c_str())); + } else if (FLAGS_inject_broken_nameserver_list == "False") { + gpr_log(GPR_INFO, "Specifying authority in uris to: %s", + FLAGS_local_dns_server_address.c_str()); + GPR_ASSERT(gpr_asprintf(&whole_uri, "dns://%s/%s", + FLAGS_local_dns_server_address.c_str(), + FLAGS_target_name.c_str())); + } else { + gpr_log(GPR_DEBUG, "Invalid value for --inject_broken_nameserver_list."); + abort(); + } gpr_log(GPR_DEBUG, "resolver_component_test: --enable_srv_queries: %s", FLAGS_enable_srv_queries.c_str()); grpc_channel_args* resolver_args = nullptr; @@ -525,7 +608,9 @@ void RunResolvesRelevantRecordsTest( CreateResultHandler(&args)); grpc_channel_args_destroy(resolver_args); gpr_free(whole_uri); - resolver->StartLocked(); + GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(StartResolvingLocked, resolver.get(), + grpc_combiner_scheduler(args.lock)), + GRPC_ERROR_NONE); grpc_core::ExecCtx::Get()->Flush(); PollPollsetUntilRequestDone(&args); ArgsFinish(&args); @@ -560,10 +645,6 @@ int main(int argc, char** argv) { gpr_log(GPR_ERROR, "Missing target_name param."); abort(); } - if (FLAGS_local_dns_server_address != "") { - gpr_log(GPR_INFO, "Specifying authority in uris to: %s", - FLAGS_local_dns_server_address.c_str()); - } auto result = RUN_ALL_TESTS(); grpc_shutdown(); return result; diff --git a/test/cpp/naming/resolver_component_tests_runner.py b/test/cpp/naming/resolver_component_tests_runner.py index a0eda79ec62..a5e4485c0ac 100755 --- a/test/cpp/naming/resolver_component_tests_runner.py +++ b/test/cpp/naming/resolver_component_tests_runner.py @@ -127,6 +127,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -141,6 +142,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -155,6 +157,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -169,6 +172,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -183,6 +187,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -197,6 +202,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', 'round_robin', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -211,6 +217,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', 'round_robin', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -225,6 +232,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -239,6 +247,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -253,6 +262,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', 'round_robin', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -267,6 +277,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', 'round_robin', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -281,6 +292,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -295,6 +307,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -309,6 +322,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -323,6 +337,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', '', '--enable_srv_queries', 'False', '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -337,6 +352,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', '', '--enable_srv_queries', 'False', '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -351,6 +367,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', '', '--enable_srv_queries', 'False', '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -365,6 +382,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', '', '--enable_srv_queries', 'False', '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -379,6 +397,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', 'round_robin', '--enable_srv_queries', 'False', '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -393,6 +412,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'False', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -407,6 +427,7 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'False', + '--inject_broken_nameserver_list', 'False', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: @@ -421,6 +442,37 @@ current_test_subprocess = subprocess.Popen([ '--expected_lb_policy', '', '--enable_srv_queries', 'True', '--enable_txt_queries', 'False', + '--inject_broken_nameserver_list', 'False', + '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) +current_test_subprocess.communicate() +if current_test_subprocess.returncode != 0: + num_test_failures += 1 + +test_runner_log('Run test with target: %s' % 'no-srv-ipv4-single-target-inject-broken-nameservers.resolver-tests-version-4.grpctestingexp.') +current_test_subprocess = subprocess.Popen([ + args.test_bin_path, + '--target_name', 'no-srv-ipv4-single-target-inject-broken-nameservers.resolver-tests-version-4.grpctestingexp.', + '--expected_addrs', '5.5.5.5:443,False', + '--expected_chosen_service_config', '', + '--expected_lb_policy', '', + '--enable_srv_queries', 'True', + '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'True', + '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) +current_test_subprocess.communicate() +if current_test_subprocess.returncode != 0: + num_test_failures += 1 + +test_runner_log('Run test with target: %s' % 'ipv4-config-causing-fallback-to-tcp-inject-broken-nameservers.resolver-tests-version-4.grpctestingexp.') +current_test_subprocess = subprocess.Popen([ + args.test_bin_path, + '--target_name', 'ipv4-config-causing-fallback-to-tcp-inject-broken-nameservers.resolver-tests-version-4.grpctestingexp.', + '--expected_addrs', '1.2.3.4:443,False', + '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooThree","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFour","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFive","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSix","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSeven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEight","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooNine","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTen","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEleven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]}]}', + '--expected_lb_policy', '', + '--enable_srv_queries', 'True', + '--enable_txt_queries', 'True', + '--inject_broken_nameserver_list', 'True', '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) current_test_subprocess.communicate() if current_test_subprocess.returncode != 0: diff --git a/test/cpp/naming/resolver_test_record_groups.yaml b/test/cpp/naming/resolver_test_record_groups.yaml index 738fe658939..d236fd743d9 100644 --- a/test/cpp/naming/resolver_test_record_groups.yaml +++ b/test/cpp/naming/resolver_test_record_groups.yaml @@ -7,6 +7,7 @@ resolver_component_tests: expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true + inject_broken_nameserver_list: false record_to_resolve: no-srv-ipv4-single-target records: no-srv-ipv4-single-target: @@ -17,6 +18,7 @@ resolver_component_tests: expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true + inject_broken_nameserver_list: false record_to_resolve: srv-ipv4-single-target records: _grpclb._tcp.srv-ipv4-single-target: @@ -31,6 +33,7 @@ resolver_component_tests: expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true + inject_broken_nameserver_list: false record_to_resolve: srv-ipv4-multi-target records: _grpclb._tcp.srv-ipv4-multi-target: @@ -45,6 +48,7 @@ resolver_component_tests: expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true + inject_broken_nameserver_list: false record_to_resolve: srv-ipv6-single-target records: _grpclb._tcp.srv-ipv6-single-target: @@ -59,6 +63,7 @@ resolver_component_tests: expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true + inject_broken_nameserver_list: false record_to_resolve: srv-ipv6-multi-target records: _grpclb._tcp.srv-ipv6-multi-target: @@ -73,6 +78,7 @@ resolver_component_tests: expected_lb_policy: round_robin enable_srv_queries: true enable_txt_queries: true + inject_broken_nameserver_list: false record_to_resolve: srv-ipv4-simple-service-config records: _grpclb._tcp.srv-ipv4-simple-service-config: @@ -88,6 +94,7 @@ resolver_component_tests: expected_lb_policy: round_robin enable_srv_queries: true enable_txt_queries: true + inject_broken_nameserver_list: false record_to_resolve: ipv4-no-srv-simple-service-config records: ipv4-no-srv-simple-service-config: @@ -101,6 +108,7 @@ resolver_component_tests: expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true + inject_broken_nameserver_list: false record_to_resolve: ipv4-no-config-for-cpp records: ipv4-no-config-for-cpp: @@ -114,6 +122,7 @@ resolver_component_tests: expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true + inject_broken_nameserver_list: false record_to_resolve: ipv4-cpp-config-has-zero-percentage records: ipv4-cpp-config-has-zero-percentage: @@ -127,6 +136,7 @@ resolver_component_tests: expected_lb_policy: round_robin enable_srv_queries: true enable_txt_queries: true + inject_broken_nameserver_list: false record_to_resolve: ipv4-second-language-is-cpp records: ipv4-second-language-is-cpp: @@ -140,6 +150,7 @@ resolver_component_tests: expected_lb_policy: round_robin enable_srv_queries: true enable_txt_queries: true + inject_broken_nameserver_list: false record_to_resolve: ipv4-config-with-percentages records: ipv4-config-with-percentages: @@ -154,6 +165,7 @@ resolver_component_tests: expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true + inject_broken_nameserver_list: false record_to_resolve: srv-ipv4-target-has-backend-and-balancer records: _grpclb._tcp.srv-ipv4-target-has-backend-and-balancer: @@ -169,6 +181,7 @@ resolver_component_tests: expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true + inject_broken_nameserver_list: false record_to_resolve: srv-ipv6-target-has-backend-and-balancer records: _grpclb._tcp.srv-ipv6-target-has-backend-and-balancer: @@ -183,6 +196,7 @@ resolver_component_tests: expected_lb_policy: null enable_srv_queries: true enable_txt_queries: true + inject_broken_nameserver_list: false record_to_resolve: ipv4-config-causing-fallback-to-tcp records: ipv4-config-causing-fallback-to-tcp: @@ -197,6 +211,7 @@ resolver_component_tests: expected_lb_policy: null enable_srv_queries: false enable_txt_queries: true + inject_broken_nameserver_list: false record_to_resolve: srv-ipv4-single-target-srv-disabled records: _grpclb._tcp.srv-ipv4-single-target-srv-disabled: @@ -213,6 +228,7 @@ resolver_component_tests: expected_lb_policy: null enable_srv_queries: false enable_txt_queries: true + inject_broken_nameserver_list: false record_to_resolve: srv-ipv4-multi-target-srv-disabled records: _grpclb._tcp.srv-ipv4-multi-target-srv-disabled: @@ -231,6 +247,7 @@ resolver_component_tests: expected_lb_policy: null enable_srv_queries: false enable_txt_queries: true + inject_broken_nameserver_list: false record_to_resolve: srv-ipv6-single-target-srv-disabled records: _grpclb._tcp.srv-ipv6-single-target-srv-disabled: @@ -247,6 +264,7 @@ resolver_component_tests: expected_lb_policy: null enable_srv_queries: false enable_txt_queries: true + inject_broken_nameserver_list: false record_to_resolve: srv-ipv6-multi-target-srv-disabled records: _grpclb._tcp.srv-ipv6-multi-target-srv-disabled: @@ -265,6 +283,7 @@ resolver_component_tests: expected_lb_policy: round_robin enable_srv_queries: false enable_txt_queries: true + inject_broken_nameserver_list: false record_to_resolve: srv-ipv4-simple-service-config-srv-disabled records: _grpclb._tcp.srv-ipv4-simple-service-config-srv-disabled: @@ -282,6 +301,7 @@ resolver_component_tests: expected_lb_policy: null enable_srv_queries: true enable_txt_queries: false + inject_broken_nameserver_list: false record_to_resolve: srv-ipv4-simple-service-config-txt-disabled records: _grpclb._tcp.srv-ipv4-simple-service-config-txt-disabled: @@ -297,6 +317,7 @@ resolver_component_tests: expected_lb_policy: null enable_srv_queries: true enable_txt_queries: false + inject_broken_nameserver_list: false record_to_resolve: ipv4-cpp-config-has-zero-percentage-txt-disabled records: ipv4-cpp-config-has-zero-percentage-txt-disabled: @@ -310,6 +331,7 @@ resolver_component_tests: expected_lb_policy: null enable_srv_queries: true enable_txt_queries: false + inject_broken_nameserver_list: false record_to_resolve: ipv4-second-language-is-cpp-txt-disabled records: ipv4-second-language-is-cpp-txt-disabled: @@ -317,3 +339,29 @@ resolver_component_tests: _grpc_config.ipv4-second-language-is-cpp-txt-disabled: - {TTL: '2100', data: 'grpc_config=[{"clientLanguage":["go"],"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"GoService","waitForReady":true}]}]}},{"clientLanguage":["c++"],"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService","waitForReady":true}]}]}}]', type: TXT} +# Tests for which we also exercise the resolver's ability to skip past a broken DNS server in its nameserver list +- expected_addrs: + - {address: '5.5.5.5:443', is_balancer: false} + expected_chosen_service_config: null + expected_lb_policy: null + enable_srv_queries: true + enable_txt_queries: true + inject_broken_nameserver_list: true + record_to_resolve: no-srv-ipv4-single-target-inject-broken-nameservers + records: + no-srv-ipv4-single-target-inject-broken-nameservers: + - {TTL: '2100', data: 5.5.5.5, type: A} +- expected_addrs: + - {address: '1.2.3.4:443', is_balancer: false} + expected_chosen_service_config: '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooThree","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFour","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFive","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSix","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSeven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEight","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooNine","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTen","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEleven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]}]}' + expected_lb_policy: null + enable_srv_queries: true + enable_txt_queries: true + inject_broken_nameserver_list: true + record_to_resolve: ipv4-config-causing-fallback-to-tcp-inject-broken-nameservers + records: + ipv4-config-causing-fallback-to-tcp-inject-broken-nameservers: + - {TTL: '2100', data: 1.2.3.4, type: A} + _grpc_config.ipv4-config-causing-fallback-to-tcp-inject-broken-nameservers: + - {TTL: '2100', data: 'grpc_config=[{"serviceConfig":{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooThree","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFour","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFive","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSix","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSeven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEight","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooNine","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTen","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEleven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]}]}}]', + type: TXT} diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index a24c76c9042..242f6677d6a 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -6014,6 +6014,7 @@ }, { "deps": [ + "dns_test_util", "gpr", "grpc++_test_config", "grpc++_test_util_unsecure", @@ -6033,6 +6034,7 @@ }, { "deps": [ + "dns_test_util", "gpr", "grpc", "grpc++", @@ -6128,6 +6130,7 @@ }, { "deps": [ + "dns_test_util", "gpr", "grpc", "grpc++", @@ -6603,6 +6606,21 @@ "third_party": false, "type": "lib" }, + { + "deps": [], + "headers": [ + "test/cpp/naming/dns_test_util.h" + ], + "is_filegroup": false, + "language": "c++", + "name": "dns_test_util", + "src": [ + "test/cpp/naming/dns_test_util.cc", + "test/cpp/naming/dns_test_util.h" + ], + "third_party": false, + "type": "lib" + }, { "deps": [ "gpr", From 3fc702510faa1f201ea4f1e1a86ea2e60a89ee69 Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Wed, 8 May 2019 10:15:43 -0700 Subject: [PATCH 0160/1555] Reuse reactor to send new RPC --- .../callback_streaming_ping_pong.h | 11 +--- .../microbenchmarks/callback_test_service.h | 50 +++++++++---------- 2 files changed, 27 insertions(+), 34 deletions(-) diff --git a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h index 7861aa67780..af2db947800 100644 --- a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h @@ -51,15 +51,8 @@ static void BM_CallbackBidiStreaming(benchmark::State& state) { } if (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); - std::mutex mu; - std::condition_variable cv; - bool done = false; - BidiClient test{&state, stub_.get(), &request, &response, &mu, &cv, &done}; - test.StartNewRpc(); - std::unique_lock l(mu); - while (!done) { - cv.wait(l); - } + BidiClient test{&state, stub_.get(), &request, &response}; + test.Await(); } fixture->Finish(state); fixture.reset(); diff --git a/test/cpp/microbenchmarks/callback_test_service.h b/test/cpp/microbenchmarks/callback_test_service.h index 0d371c4c740..b7b76fd806c 100644 --- a/test/cpp/microbenchmarks/callback_test_service.h +++ b/test/cpp/microbenchmarks/callback_test_service.h @@ -49,17 +49,11 @@ class BidiClient : public grpc::experimental::ClientBidiReactor { public: BidiClient(benchmark::State* state, EchoTestService::Stub* stub, - EchoRequest* request, EchoResponse* response, std::mutex* mu, - std::condition_variable* cv, bool* done) - : state_{state}, - stub_{stub}, - request_{request}, - response_{response}, - mu_{mu}, - cv_{cv}, - done_(done) { + EchoRequest* request, EchoResponse* response) + : state_{state}, stub_{stub}, request_{request}, response_{response} { msgs_size_ = state->range(0); msgs_to_send_ = state->range(1); + StartNewRpc(); } void OnReadDone(bool ok) override { @@ -82,27 +76,33 @@ class BidiClient void OnDone(const Status& s) override { GPR_ASSERT(s.ok()); if (state_->KeepRunning()) { - BidiClient* test = - new BidiClient(state_, stub_, request_, response_, mu_, cv_, done_); - test->StartNewRpc(); + writes_complete_ = 0; + StartNewRpc(); } else { - std::unique_lock l(*mu_); - *done_ = true; - cv_->notify_one(); + std::unique_lock l(mu); + done = true; + cv.notify_one(); } - delete cli_ctx_; } void StartNewRpc() { - cli_ctx_ = new ClientContext(); - cli_ctx_->AddMetadata(kServerFinishAfterNReads, - grpc::to_string(msgs_to_send_)); - cli_ctx_->AddMetadata(kServerMessageSize, grpc::to_string(msgs_size_)); - stub_->experimental_async()->BidiStream(cli_ctx_, this); + cli_ctx_.reset(new ClientContext); + cli_ctx_.get()->AddMetadata(kServerFinishAfterNReads, + grpc::to_string(msgs_to_send_)); + cli_ctx_.get()->AddMetadata(kServerMessageSize, + grpc::to_string(msgs_size_)); + stub_->experimental_async()->BidiStream(cli_ctx_.get(), this); MaybeWrite(); StartCall(); } + void Await() { + std::unique_lock l(mu); + while (!done) { + cv.wait(l); + } + } + private: void MaybeWrite() { if (writes_complete_ < msgs_to_send_) { @@ -112,7 +112,7 @@ class BidiClient } } - ClientContext* cli_ctx_; + std::unique_ptr cli_ctx_; benchmark::State* state_; EchoTestService::Stub* stub_; EchoRequest* request_; @@ -120,9 +120,9 @@ class BidiClient int writes_complete_{0}; int msgs_to_send_; int msgs_size_; - std::mutex* mu_; - std::condition_variable* cv_; - bool* done_; + std::mutex mu; + std::condition_variable cv; + bool done; }; } // namespace testing From abfe14e3ed9b4ab7326fe437359fa9b167d010ac Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 8 May 2019 10:44:56 -0700 Subject: [PATCH 0161/1555] Reviewer comments --- .../filters/client_channel/client_channel.cc | 63 ++++++++++++------- .../resolver/dns/c_ares/dns_resolver_ares.cc | 7 +-- .../client_channel/resolving_lb_policy.cc | 1 - .../client_channel/resolving_lb_policy.h | 3 + 4 files changed, 45 insertions(+), 29 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 5d5436b8f67..99066e4e82c 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -273,6 +273,7 @@ class ChannelData { ExternalConnectivityWatcher::WatcherList external_connectivity_watcher_list_; UniquePtr health_check_service_name_; RefCountedPtr saved_service_config_; + bool set_service_config_ = false; // // Fields accessed from both data plane and control plane combiners. @@ -1077,6 +1078,8 @@ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error) // Get default service config const char* service_config_json = grpc_channel_arg_get_string( grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVICE_CONFIG)); + // Make sure we set the channel in TRANSIENT_FAILURE on an invalid default + // service config if (service_config_json != nullptr) { *error = GRPC_ERROR_NONE; default_service_config_ = ServiceConfig::Create(service_config_json, error); @@ -1155,23 +1158,25 @@ void ChannelData::ProcessLbPolicy( // Prefer the LB policy name found in the service config. if (parsed_object != nullptr) { if (parsed_object->parsed_lb_config() != nullptr) { - (*lb_policy_name) - .reset(gpr_strdup(parsed_object->parsed_lb_config()->name())); + lb_policy_name->reset( + gpr_strdup(parsed_object->parsed_lb_config()->name())); *lb_policy_config = parsed_object->parsed_lb_config(); - } else { - (*lb_policy_name) - .reset(gpr_strdup(parsed_object->parsed_deprecated_lb_policy())); + return; + } else if (parsed_object->parsed_deprecated_lb_policy() != nullptr) { + lb_policy_name->reset( + gpr_strdup(parsed_object->parsed_deprecated_lb_policy())); } } // Otherwise, find the LB policy name set by the client API. if (*lb_policy_name == nullptr) { const grpc_arg* channel_arg = grpc_channel_args_find(resolver_result.args, GRPC_ARG_LB_POLICY_NAME); - (*lb_policy_name) - .reset(gpr_strdup(grpc_channel_arg_get_string(channel_arg))); + lb_policy_name->reset(gpr_strdup(grpc_channel_arg_get_string(channel_arg))); } // Special case: If at least one balancer address is present, we use // the grpclb policy, regardless of what the resolver has returned. + // TODO(yashkt) : Test that we do not use this special case if the we have set + // the lb policy from the loadBalancingConfig field bool found_balancer_address = false; for (size_t i = 0; i < resolver_result.addresses.size(); ++i) { const ServerAddress& address = resolver_result.addresses[i]; @@ -1182,18 +1187,18 @@ void ChannelData::ProcessLbPolicy( } if (found_balancer_address) { if (*lb_policy_name != nullptr && - strcmp((*lb_policy_name).get(), "grpclb") != 0) { + strcmp(lb_policy_name->get(), "grpclb") != 0) { gpr_log(GPR_INFO, "resolver requested LB policy %s but provided at least one " "balancer address -- forcing use of grpclb LB policy", - (*lb_policy_name).get()); + lb_policy_name->get()); } - (*lb_policy_name).reset(gpr_strdup("grpclb")); + lb_policy_name->reset(gpr_strdup("grpclb")); } // Use pick_first if nothing was specified and we didn't select grpclb // above. if (*lb_policy_name == nullptr) { - (*lb_policy_name).reset(gpr_strdup("pick_first")); + lb_policy_name->reset(gpr_strdup("pick_first")); } } @@ -1239,23 +1244,33 @@ bool ChannelData::ProcessResolverResultLocked( internal::ClientChannelServiceConfigParser::ParserIndex())); service_config_json = gpr_strdup(service_config->service_config_json()); } - bool service_config_changed = service_config != chand->saved_service_config_; + bool service_config_changed = + ((service_config == nullptr) != + (chand->saved_service_config_ == nullptr)) || + (service_config != nullptr && + strcmp(service_config->service_config_json(), + chand->saved_service_config_->service_config_json()) != 0); if (service_config_changed) { chand->saved_service_config_ = std::move(service_config); + if (parsed_object != nullptr) { + chand->health_check_service_name_.reset( + gpr_strdup(parsed_object->health_check_service_name())); + } else { + chand->health_check_service_name_.reset(); + } } - Optional - retry_throttle_data; - if (parsed_object != nullptr) { - chand->health_check_service_name_.reset( - gpr_strdup(parsed_object->health_check_service_name())); - retry_throttle_data = parsed_object->retry_throttling(); - } else { - chand->health_check_service_name_.reset(); + if (service_config_changed || !chand->set_service_config_) { + chand->set_service_config_ = true; + Optional + retry_throttle_data; + if (parsed_object != nullptr) { + retry_throttle_data = parsed_object->retry_throttling(); + } + // Create service config setter to update channel state in the data + // plane combiner. Destroys itself when done. + New(chand, retry_throttle_data, + chand->saved_service_config_); } - // Create service config setter to update channel state in the data - // plane combiner. Destroys itself when done. - New(chand, retry_throttle_data, - chand->saved_service_config_); UniquePtr processed_lb_policy_name; chand->ProcessLbPolicy(result, parsed_object, &processed_lb_policy_name, lb_policy_config); diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index 25ce81b3692..77adc475bc2 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -309,14 +309,13 @@ char* ChooseServiceConfig(char* service_config_choice_json, } } grpc_json_destroy(choices_json); - if (error_list.empty()) { - return service_config; - } else { + if (!error_list.empty()) { gpr_free(service_config); + service_config = nullptr; *error = GRPC_ERROR_CREATE_FROM_VECTOR("Service Config Choices Parser", &error_list); - return nullptr; } + return service_config; } void AresDnsResolver::OnResolvedLocked(void* arg, grpc_error* error) { diff --git a/src/core/ext/filters/client_channel/resolving_lb_policy.cc b/src/core/ext/filters/client_channel/resolving_lb_policy.cc index 4824f4e22c3..35862f89d9c 100644 --- a/src/core/ext/filters/client_channel/resolving_lb_policy.cc +++ b/src/core/ext/filters/client_channel/resolving_lb_policy.cc @@ -554,7 +554,6 @@ void ResolvingLoadBalancingPolicy::OnResolverResultChangedLocked( lb_policy_config = child_lb_config_; } if (lb_policy_name != nullptr) { - gpr_log(GPR_ERROR, "%s", lb_policy_name); // Create or update LB policy, as needed. CreateOrUpdateLbPolicyLocked(lb_policy_name, lb_policy_config, std::move(result), &trace_strings); diff --git a/src/core/ext/filters/client_channel/resolving_lb_policy.h b/src/core/ext/filters/client_channel/resolving_lb_policy.h index fa609aac5f2..b7d99dcc7de 100644 --- a/src/core/ext/filters/client_channel/resolving_lb_policy.h +++ b/src/core/ext/filters/client_channel/resolving_lb_policy.h @@ -65,6 +65,9 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy { // Synchronous callback that takes the resolver result and sets // lb_policy_name and lb_policy_config to point to the right data. // Returns true if the service config has changed since the last result. + // If the returned service_config_error is not none and lb_policy_name is + // empty, it means that we don't have a valid service config to use, and we + // should set the channel to be in TRANSIENT_FAILURE. typedef bool (*ProcessResolverResultCallback)( void* user_data, const Resolver::Result& result, const char** lb_policy_name, From 40b6123d1498468033ddcdbe324c38ec56e93e19 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 8 May 2019 10:53:26 -0700 Subject: [PATCH 0162/1555] Fix TODOs --- src/core/ext/filters/client_channel/client_channel.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 99066e4e82c..787fe2f4750 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -1078,8 +1078,8 @@ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error) // Get default service config const char* service_config_json = grpc_channel_arg_get_string( grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVICE_CONFIG)); - // Make sure we set the channel in TRANSIENT_FAILURE on an invalid default - // service config + // TODO(yashkt): Make sure we set the channel in TRANSIENT_FAILURE on an + // invalid default service config if (service_config_json != nullptr) { *error = GRPC_ERROR_NONE; default_service_config_ = ServiceConfig::Create(service_config_json, error); @@ -1175,7 +1175,7 @@ void ChannelData::ProcessLbPolicy( } // Special case: If at least one balancer address is present, we use // the grpclb policy, regardless of what the resolver has returned. - // TODO(yashkt) : Test that we do not use this special case if the we have set + // TODO(yashkt) : Test that we do not use this special case if we have set // the lb policy from the loadBalancingConfig field bool found_balancer_address = false; for (size_t i = 0; i < resolver_result.addresses.size(); ++i) { From b6c7cb81f025426a02346ed32425999203aa65fb Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 8 May 2019 11:23:06 -0700 Subject: [PATCH 0163/1555] Fix resolver component test --- test/cpp/naming/resolver_component_test.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index 7903f2a932f..7a0aa1c6fc2 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -249,8 +249,6 @@ void CheckServiceConfigResultLocked(const char* service_config_json, if (args->expected_service_config_string != "") { GPR_ASSERT(service_config_json != nullptr); EXPECT_EQ(service_config_json, args->expected_service_config_string); - } else { - GPR_ASSERT(service_config_json == nullptr); } if (args->expected_service_config_error == "") { EXPECT_EQ(service_config_error, GRPC_ERROR_NONE); From b53465c1061c9fd31e168046a1a0ac26c13da130 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 8 May 2019 14:27:58 -0700 Subject: [PATCH 0164/1555] Add test for not special casing grpclb if loadbalancingconfig is used --- .../filters/client_channel/client_channel.cc | 116 ++++++++++-------- .../lb_policy/subchannel_list.h | 4 +- test/cpp/end2end/grpclb_end2end_test.cc | 32 +++++ 3 files changed, 102 insertions(+), 50 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 787fe2f4750..1dc6ac48d57 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -1156,49 +1156,47 @@ void ChannelData::ProcessLbPolicy( UniquePtr* lb_policy_name, RefCountedPtr* lb_policy_config) { // Prefer the LB policy name found in the service config. - if (parsed_object != nullptr) { - if (parsed_object->parsed_lb_config() != nullptr) { - lb_policy_name->reset( - gpr_strdup(parsed_object->parsed_lb_config()->name())); - *lb_policy_config = parsed_object->parsed_lb_config(); - return; - } else if (parsed_object->parsed_deprecated_lb_policy() != nullptr) { - lb_policy_name->reset( - gpr_strdup(parsed_object->parsed_deprecated_lb_policy())); + if (parsed_object != nullptr && + parsed_object->parsed_lb_config() != nullptr) { + lb_policy_name->reset( + gpr_strdup(parsed_object->parsed_lb_config()->name())); + *lb_policy_config = parsed_object->parsed_lb_config(); + } else { + const char* local_policy_name = nullptr; + if (parsed_object != nullptr && + parsed_object->parsed_deprecated_lb_policy() != nullptr) { + local_policy_name = parsed_object->parsed_deprecated_lb_policy(); + } else { + const grpc_arg* channel_arg = + grpc_channel_args_find(resolver_result.args, GRPC_ARG_LB_POLICY_NAME); + local_policy_name = grpc_channel_arg_get_string(channel_arg); } - } - // Otherwise, find the LB policy name set by the client API. - if (*lb_policy_name == nullptr) { - const grpc_arg* channel_arg = - grpc_channel_args_find(resolver_result.args, GRPC_ARG_LB_POLICY_NAME); - lb_policy_name->reset(gpr_strdup(grpc_channel_arg_get_string(channel_arg))); - } - // Special case: If at least one balancer address is present, we use - // the grpclb policy, regardless of what the resolver has returned. - // TODO(yashkt) : Test that we do not use this special case if we have set - // the lb policy from the loadBalancingConfig field - bool found_balancer_address = false; - for (size_t i = 0; i < resolver_result.addresses.size(); ++i) { - const ServerAddress& address = resolver_result.addresses[i]; - if (address.IsBalancer()) { - found_balancer_address = true; - break; + // Special case: If at least one balancer address is present, we use + // the grpclb policy, regardless of what the resolver has returned. + bool found_balancer_address = false; + for (size_t i = 0; i < resolver_result.addresses.size(); ++i) { + const ServerAddress& address = resolver_result.addresses[i]; + if (address.IsBalancer()) { + found_balancer_address = true; + break; + } } - } - if (found_balancer_address) { - if (*lb_policy_name != nullptr && - strcmp(lb_policy_name->get(), "grpclb") != 0) { - gpr_log(GPR_INFO, - "resolver requested LB policy %s but provided at least one " - "balancer address -- forcing use of grpclb LB policy", - lb_policy_name->get()); + if (found_balancer_address) { + if (local_policy_name != nullptr && + strcmp(local_policy_name, "grpclb") != 0) { + gpr_log(GPR_INFO, + "resolver requested LB policy %s but provided at least one " + "balancer address -- forcing use of grpclb LB policy", + local_policy_name); + } + local_policy_name = "grpclb"; } - lb_policy_name->reset(gpr_strdup("grpclb")); - } - // Use pick_first if nothing was specified and we didn't select grpclb - // above. - if (*lb_policy_name == nullptr) { - lb_policy_name->reset(gpr_strdup("pick_first")); + // Use pick_first if nothing was specified and we didn't select grpclb + // above. + if (local_policy_name == nullptr) { + local_policy_name = "pick_first"; + } + lb_policy_name->reset(gpr_strdup(local_policy_name)); } } @@ -1218,11 +1216,28 @@ bool ChannelData::ProcessResolverResultLocked( // API if (chand->saved_service_config_ != nullptr) { service_config = chand->saved_service_config_; + if (grpc_client_channel_routing_trace.enabled()) { + gpr_log(GPR_INFO, + "chand=%p: resolver returned invalid service config. " + "Continuing to use previous service config.", + chand); + } } else if (chand->default_service_config_ != nullptr) { + if (grpc_client_channel_routing_trace.enabled()) { + gpr_log(GPR_INFO, + "chand=%p: resolver returned invalid service config. Using " + "default service config provided by client API.", + chand); + } service_config = chand->default_service_config_; } } else if (result.service_config == nullptr) { - // We got no service config. Fallback to default service config + if (grpc_client_channel_routing_trace.enabled()) { + gpr_log(GPR_INFO, + "chand=%p: resolver returned no service config. Using default " + "service config provided by client API.", + chand); + } if (chand->default_service_config_ != nullptr) { service_config = chand->default_service_config_; } @@ -1234,7 +1249,7 @@ bool ChannelData::ProcessResolverResultLocked( result.service_config_error != GRPC_ERROR_NONE) { return false; } - char* service_config_json = nullptr; + UniquePtr service_config_json = nullptr; // Process service config. const internal::ClientChannelGlobalParsedObject* parsed_object = nullptr; if (service_config != nullptr) { @@ -1242,15 +1257,20 @@ bool ChannelData::ProcessResolverResultLocked( static_cast( service_config->GetParsedGlobalServiceConfigObject( internal::ClientChannelServiceConfigParser::ParserIndex())); - service_config_json = gpr_strdup(service_config->service_config_json()); } - bool service_config_changed = + const bool service_config_changed = ((service_config == nullptr) != (chand->saved_service_config_ == nullptr)) || (service_config != nullptr && strcmp(service_config->service_config_json(), chand->saved_service_config_->service_config_json()) != 0); if (service_config_changed) { + service_config_json.reset( + gpr_strdup(service_config->service_config_json())); + if (grpc_client_channel_routing_trace.enabled()) { + gpr_log(GPR_INFO, "chand=%p: resolver returned service config: \"%s\"", + chand, service_config_json.get()); + } chand->saved_service_config_ = std::move(service_config); if (parsed_object != nullptr) { chand->health_check_service_name_.reset( @@ -1274,15 +1294,13 @@ bool ChannelData::ProcessResolverResultLocked( UniquePtr processed_lb_policy_name; chand->ProcessLbPolicy(result, parsed_object, &processed_lb_policy_name, lb_policy_config); - if (grpc_client_channel_routing_trace.enabled()) { - gpr_log(GPR_INFO, "chand=%p: resolver returned service config: \"%s\"", - chand, service_config_json); - } // Swap out the data used by GetChannelInfo(). { MutexLock lock(&chand->info_mu_); chand->info_lb_policy_name_ = std::move(processed_lb_policy_name); - chand->info_service_config_json_.reset(service_config_json); + if (service_config_json != nullptr) { + chand->info_service_config_json_ = std::move(service_config_json); + } } // Return results. *lb_policy_name = chand->info_lb_policy_name_.get(); diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h index 004ee04459b..c222985cf18 100644 --- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h @@ -506,7 +506,9 @@ SubchannelList::SubchannelList( GRPC_ARG_INHIBIT_HEALTH_CHECKING}; // Create a subchannel for each address. for (size_t i = 0; i < addresses.size(); i++) { - GPR_ASSERT(!addresses[i].IsBalancer()); + if (addresses[i].IsBalancer()) { + continue; + } InlinedVector args_to_add; const size_t subchannel_address_arg_index = args_to_add.size(); args_to_add.emplace_back( diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc index 5e0faf0265a..3ac28ec7e43 100644 --- a/test/cpp/end2end/grpclb_end2end_test.cc +++ b/test/cpp/end2end/grpclb_end2end_test.cc @@ -737,6 +737,38 @@ TEST_F(SingleBalancerTest, SelectGrpclbWithMigrationServiceConfig) { EXPECT_EQ("grpclb", channel_->GetLoadBalancingPolicyName()); } +TEST_F(SingleBalancerTest, + DoNotSpecialCaseUseGrpclbWithLoadBalancingConfigTest1) { + const int kFallbackTimeoutMs = 200 * grpc_test_slowdown_factor(); + ResetStub(kFallbackTimeoutMs); + SetNextResolution({AddressData{backends_[0]->port_, false, ""}, + AddressData{balancers_[0]->port_, true, ""}}, + "{\n" + " \"loadBalancingConfig\":[\n" + " {\"pick_first\":{} }\n" + " ]\n" + "}"); + CheckRpcSendOk(); + // Check LB policy name for the channel. + EXPECT_EQ("pick_first", channel_->GetLoadBalancingPolicyName()); +} + +TEST_F(SingleBalancerTest, + DoNotSpecialCaseUseGrpclbWithLoadBalancingConfigTest2) { + const int kFallbackTimeoutMs = 200 * grpc_test_slowdown_factor(); + ResetStub(kFallbackTimeoutMs); + SetNextResolution({AddressData{balancers_[0]->port_, true, ""}}, + "{\n" + " \"loadBalancingConfig\":[\n" + " {\"pick_first\":{} }\n" + " ]\n" + "}"); + // This should fail since we do not have a non-balancer backend + CheckRpcSendFailure(); + // Check LB policy name for the channel. + EXPECT_EQ("pick_first", channel_->GetLoadBalancingPolicyName()); +} + TEST_F(SingleBalancerTest, SelectGrpclbWithMigrationServiceConfigAndNoAddresses) { const int kFallbackTimeoutMs = 200 * grpc_test_slowdown_factor(); From 3c4e8a9be2a7900580e52b00cdea4f0f7f0a40a9 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 8 May 2019 15:46:32 -0700 Subject: [PATCH 0165/1555] Fix test failure --- src/core/ext/filters/client_channel/client_channel.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 1dc6ac48d57..9144df93c12 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -1265,8 +1265,12 @@ bool ChannelData::ProcessResolverResultLocked( strcmp(service_config->service_config_json(), chand->saved_service_config_->service_config_json()) != 0); if (service_config_changed) { - service_config_json.reset( - gpr_strdup(service_config->service_config_json())); + if (service_config != nullptr) { + service_config_json.reset( + gpr_strdup(service_config->service_config_json())); + } else { + service_config_json.reset(gpr_strdup("")); + } if (grpc_client_channel_routing_trace.enabled()) { gpr_log(GPR_INFO, "chand=%p: resolver returned service config: \"%s\"", chand, service_config_json.get()); From 070902b871ea7c7149f9746bb2464da5e5dc94cf Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Wed, 8 May 2019 15:51:58 -0700 Subject: [PATCH 0166/1555] Merge bm_callback_cq to bm_cq --- CMakeLists.txt | 62 +---- Makefile | 81 ++----- build.yaml | 29 +-- grpc.gyp | 2 +- test/cpp/microbenchmarks/BUILD | 11 - test/cpp/microbenchmarks/bm_callback_cq.cc | 226 ------------------ test/cpp/microbenchmarks/bm_cq.cc | 50 ++++ .../generated/sources_and_headers.json | 27 +-- tools/run_tests/generated/tests.json | 26 -- 9 files changed, 80 insertions(+), 434 deletions(-) delete mode 100644 test/cpp/microbenchmarks/bm_callback_cq.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 3de0e88adfc..cd2f91c0e3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -556,9 +556,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx bm_call_create) endif() if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) -add_dependencies(buildtests_cxx bm_callback_cq) -endif() -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx bm_callback_streaming_ping_pong) endif() if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) @@ -2918,7 +2915,7 @@ endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) if (gRPC_BUILD_CODEGEN) -add_library(callback_test_service +add_library(bm_callback_test_service_impl ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.pb.h @@ -2928,11 +2925,11 @@ add_library(callback_test_service ) if(WIN32 AND MSVC) - set_target_properties(callback_test_service PROPERTIES COMPILE_PDB_NAME "callback_test_service" + set_target_properties(bm_callback_test_service_impl PROPERTIES COMPILE_PDB_NAME "bm_callback_test_service_impl" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) if (gRPC_INSTALL) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/callback_test_service.pdb + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bm_callback_test_service_impl.pdb DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() @@ -2942,7 +2939,7 @@ protobuf_generate_grpc_cpp( src/proto/grpc/testing/echo.proto ) -target_include_directories(callback_test_service +target_include_directories(bm_callback_test_service_impl PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} @@ -2959,7 +2956,7 @@ target_include_directories(callback_test_service PRIVATE third_party/googletest/googlemock PRIVATE ${_gRPC_PROTO_GENS_DIR} ) -target_link_libraries(callback_test_service +target_link_libraries(bm_callback_test_service_impl ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} grpc_benchmark @@ -11567,51 +11564,6 @@ target_link_libraries(bm_call_create ) -endif() -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - -add_executable(bm_callback_cq - test/cpp/microbenchmarks/bm_callback_cq.cc - third_party/googletest/googletest/src/gtest-all.cc - third_party/googletest/googlemock/src/gmock-all.cc -) - - -target_include_directories(bm_callback_cq - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} - PRIVATE third_party/googletest/googletest/include - PRIVATE third_party/googletest/googletest - PRIVATE third_party/googletest/googlemock/include - PRIVATE third_party/googletest/googlemock - PRIVATE ${_gRPC_PROTO_GENS_DIR} -) - -target_link_libraries(bm_callback_cq - ${_gRPC_PROTOBUF_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_benchmark - ${_gRPC_BENCHMARK_LIBRARIES} - grpc++_test_util_unsecure - grpc_test_util_unsecure - grpc++_unsecure - grpc_unsecure - gpr - grpc++_test_config - ${_gRPC_GFLAGS_LIBRARIES} -) - - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -11653,7 +11605,7 @@ target_link_libraries(bm_callback_streaming_ping_pong grpc_unsecure gpr grpc++_test_config - callback_test_service + bm_callback_test_service_impl ${_gRPC_GFLAGS_LIBRARIES} ) @@ -11699,7 +11651,7 @@ target_link_libraries(bm_callback_unary_ping_pong grpc_unsecure gpr grpc++_test_config - callback_test_service + bm_callback_test_service_impl ${_gRPC_GFLAGS_LIBRARIES} ) diff --git a/Makefile b/Makefile index 42598797bd9..e2451d573c4 100644 --- a/Makefile +++ b/Makefile @@ -1162,7 +1162,6 @@ bm_alarm: $(BINDIR)/$(CONFIG)/bm_alarm bm_arena: $(BINDIR)/$(CONFIG)/bm_arena bm_byte_buffer: $(BINDIR)/$(CONFIG)/bm_byte_buffer bm_call_create: $(BINDIR)/$(CONFIG)/bm_call_create -bm_callback_cq: $(BINDIR)/$(CONFIG)/bm_callback_cq bm_callback_streaming_ping_pong: $(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong bm_callback_unary_ping_pong: $(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong bm_channel: $(BINDIR)/$(CONFIG)/bm_channel @@ -1643,7 +1642,6 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_arena \ $(BINDIR)/$(CONFIG)/bm_byte_buffer \ $(BINDIR)/$(CONFIG)/bm_call_create \ - $(BINDIR)/$(CONFIG)/bm_callback_cq \ $(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong \ $(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong \ $(BINDIR)/$(CONFIG)/bm_channel \ @@ -1792,7 +1790,6 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_arena \ $(BINDIR)/$(CONFIG)/bm_byte_buffer \ $(BINDIR)/$(CONFIG)/bm_call_create \ - $(BINDIR)/$(CONFIG)/bm_callback_cq \ $(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong \ $(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong \ $(BINDIR)/$(CONFIG)/bm_channel \ @@ -2247,8 +2244,6 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/bm_byte_buffer || ( echo test bm_byte_buffer failed ; exit 1 ) $(E) "[RUN] Testing bm_call_create" $(Q) $(BINDIR)/$(CONFIG)/bm_call_create || ( echo test bm_call_create failed ; exit 1 ) - $(E) "[RUN] Testing bm_callback_cq" - $(Q) $(BINDIR)/$(CONFIG)/bm_callback_cq || ( echo test bm_callback_cq failed ; exit 1 ) $(E) "[RUN] Testing bm_callback_streaming_ping_pong" $(Q) $(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong || ( echo test bm_callback_streaming_ping_pong failed ; exit 1 ) $(E) "[RUN] Testing bm_callback_unary_ping_pong" @@ -5305,21 +5300,21 @@ endif endif -LIBCALLBACK_TEST_SERVICE_SRC = \ +LIBBM_CALLBACK_TEST_SERVICE_IMPL_SRC = \ $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc \ test/cpp/microbenchmarks/callback_test_service.cc \ PUBLIC_HEADERS_CXX += \ -LIBCALLBACK_TEST_SERVICE_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBCALLBACK_TEST_SERVICE_SRC)))) +LIBBM_CALLBACK_TEST_SERVICE_IMPL_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBM_CALLBACK_TEST_SERVICE_IMPL_SRC)))) -$(LIBCALLBACK_TEST_SERVICE_OBJS): CPPFLAGS += -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX +$(LIBBM_CALLBACK_TEST_SERVICE_IMPL_OBJS): CPPFLAGS += -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX ifeq ($(NO_SECURE),true) # You can't build secure libraries if you don't have OpenSSL. -$(LIBDIR)/$(CONFIG)/libcallback_test_service.a: openssl_dep_error +$(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a: openssl_dep_error else @@ -5328,18 +5323,18 @@ 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)/libcallback_test_service.a: protobuf_dep_error +$(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a: protobuf_dep_error else -$(LIBDIR)/$(CONFIG)/libcallback_test_service.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(PROTOBUF_DEP) $(LIBCALLBACK_TEST_SERVICE_OBJS) +$(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(PROTOBUF_DEP) $(LIBBM_CALLBACK_TEST_SERVICE_IMPL_OBJS) $(E) "[AR] Creating $@" $(Q) mkdir -p `dirname $@` - $(Q) rm -f $(LIBDIR)/$(CONFIG)/libcallback_test_service.a - $(Q) $(AR) $(AROPTS) $(LIBDIR)/$(CONFIG)/libcallback_test_service.a $(LIBCALLBACK_TEST_SERVICE_OBJS) + $(Q) rm -f $(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a + $(Q) $(AR) $(AROPTS) $(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a $(LIBBM_CALLBACK_TEST_SERVICE_IMPL_OBJS) ifeq ($(SYSTEM),Darwin) - $(Q) ranlib -no_warning_for_no_symbols $(LIBDIR)/$(CONFIG)/libcallback_test_service.a + $(Q) ranlib -no_warning_for_no_symbols $(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a endif @@ -5351,7 +5346,7 @@ endif ifneq ($(NO_SECURE),true) ifneq ($(NO_DEPS),true) --include $(LIBCALLBACK_TEST_SERVICE_OBJS:.o=.dep) +-include $(LIBBM_CALLBACK_TEST_SERVICE_IMPL_OBJS:.o=.dep) endif endif $(OBJDIR)/$(CONFIG)/test/cpp/microbenchmarks/callback_test_service.o: $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc @@ -14500,50 +14495,6 @@ endif endif -BM_CALLBACK_CQ_SRC = \ - test/cpp/microbenchmarks/bm_callback_cq.cc \ - -BM_CALLBACK_CQ_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BM_CALLBACK_CQ_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/bm_callback_cq: openssl_dep_error - -else - - - - -ifeq ($(NO_PROTOBUF),true) - -# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. - -$(BINDIR)/$(CONFIG)/bm_callback_cq: protobuf_dep_error - -else - -$(BINDIR)/$(CONFIG)/bm_callback_cq: $(PROTOBUF_DEP) $(BM_CALLBACK_CQ_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(BM_CALLBACK_CQ_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/bm_callback_cq - -endif - -endif - -$(BM_CALLBACK_CQ_OBJS): CPPFLAGS += -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX -$(OBJDIR)/$(CONFIG)/test/cpp/microbenchmarks/bm_callback_cq.o: $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a - -deps_bm_callback_cq: $(BM_CALLBACK_CQ_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(BM_CALLBACK_CQ_OBJS:.o=.dep) -endif -endif - - BM_CALLBACK_STREAMING_PING_PONG_SRC = \ test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc \ @@ -14567,17 +14518,17 @@ $(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong: protobuf_dep_error else -$(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong: $(PROTOBUF_DEP) $(BM_CALLBACK_STREAMING_PING_PONG_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libcallback_test_service.a +$(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong: $(PROTOBUF_DEP) $(BM_CALLBACK_STREAMING_PING_PONG_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(BM_CALLBACK_STREAMING_PING_PONG_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libcallback_test_service.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong + $(Q) $(LDXX) $(LDFLAGS) $(BM_CALLBACK_STREAMING_PING_PONG_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong endif endif $(BM_CALLBACK_STREAMING_PING_PONG_OBJS): CPPFLAGS += -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX -$(OBJDIR)/$(CONFIG)/test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.o: $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libcallback_test_service.a +$(OBJDIR)/$(CONFIG)/test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.o: $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a deps_bm_callback_streaming_ping_pong: $(BM_CALLBACK_STREAMING_PING_PONG_OBJS:.o=.dep) @@ -14611,17 +14562,17 @@ $(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong: protobuf_dep_error else -$(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong: $(PROTOBUF_DEP) $(BM_CALLBACK_UNARY_PING_PONG_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libcallback_test_service.a +$(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong: $(PROTOBUF_DEP) $(BM_CALLBACK_UNARY_PING_PONG_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(BM_CALLBACK_UNARY_PING_PONG_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libcallback_test_service.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong + $(Q) $(LDXX) $(LDFLAGS) $(BM_CALLBACK_UNARY_PING_PONG_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong endif endif $(BM_CALLBACK_UNARY_PING_PONG_OBJS): CPPFLAGS += -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX -$(OBJDIR)/$(CONFIG)/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.o: $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libcallback_test_service.a +$(OBJDIR)/$(CONFIG)/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.o: $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a deps_bm_callback_unary_ping_pong: $(BM_CALLBACK_UNARY_PING_PONG_OBJS:.o=.dep) diff --git a/build.yaml b/build.yaml index a271a8bb52f..975fc4ed2c4 100644 --- a/build.yaml +++ b/build.yaml @@ -1677,7 +1677,7 @@ libs: - grpc_test_util - grpc - gpr -- name: callback_test_service +- name: bm_callback_test_service_impl build: test language: c++ headers: @@ -4054,29 +4054,6 @@ targets: - linux - posix uses_polling: false -- name: bm_callback_cq - build: test - language: c++ - src: - - test/cpp/microbenchmarks/bm_callback_cq.cc - deps: - - grpc_benchmark - - benchmark - - grpc++_test_util_unsecure - - grpc_test_util_unsecure - - grpc++_unsecure - - grpc_unsecure - - gpr - - grpc++_test_config - benchmark: true - defaults: benchmark - excluded_poll_engines: - - poll - platforms: - - mac - - linux - - posix - timeout_seconds: 1200 - name: bm_callback_streaming_ping_pong build: test language: c++ @@ -4093,7 +4070,7 @@ targets: - grpc_unsecure - gpr - grpc++_test_config - - callback_test_service + - bm_callback_test_service_impl benchmark: true defaults: benchmark platforms: @@ -4116,7 +4093,7 @@ targets: - grpc_unsecure - gpr - grpc++_test_config - - callback_test_service + - bm_callback_test_service_impl benchmark: true defaults: benchmark platforms: diff --git a/grpc.gyp b/grpc.gyp index a625152979d..e693e762ba0 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -1406,7 +1406,7 @@ ], }, { - 'target_name': 'callback_test_service', + 'target_name': 'bm_callback_test_service_impl', 'type': 'static_library', 'dependencies': [ 'grpc_benchmark', diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD index e25f15161cb..dea835b716b 100644 --- a/test/cpp/microbenchmarks/BUILD +++ b/test/cpp/microbenchmarks/BUILD @@ -281,14 +281,3 @@ grpc_cc_binary( tags = ["no_windows"], deps = [":callback_streaming_ping_pong_h"], ) - -grpc_cc_binary( - name = "bm_callback_cq", - testonly = 1, - srcs = ["bm_callback_cq.cc"], - language = "C++", - deps = [ - ":helpers", - "//test/cpp/util:test_util", - ], -) diff --git a/test/cpp/microbenchmarks/bm_callback_cq.cc b/test/cpp/microbenchmarks/bm_callback_cq.cc deleted file mode 100644 index 307dfe4a911..00000000000 --- a/test/cpp/microbenchmarks/bm_callback_cq.cc +++ /dev/null @@ -1,226 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/* This benchmark exists to ensure that immediately-firing alarms are fast */ - -#include -#include -#include -#include -#include -#include "test/core/util/test_config.h" -#include "test/cpp/microbenchmarks/helpers.h" -#include "test/cpp/util/test_config.h" - -#include "src/core/lib/gpr/useful.h" -#include "src/core/lib/gprpp/memory.h" -#include "src/core/lib/iomgr/iomgr.h" -#include "src/core/lib/surface/completion_queue.h" - -namespace grpc { -namespace testing { - -class TagCallback : public grpc_experimental_completion_queue_functor { - public: - TagCallback(int* counter, int tag) : counter_(counter), tag_(tag) { - functor_run = &TagCallback::Run; - } - ~TagCallback() {} - static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { - GPR_ASSERT(static_cast(ok)); - auto* callback = static_cast(cb); - *callback->counter_ += callback->tag_; - grpc_core::Delete(callback); - }; - - private: - int* counter_; - int tag_; -}; - -class ShutdownCallback : public grpc_experimental_completion_queue_functor { - public: - ShutdownCallback(bool* done) : done_(done) { - functor_run = &ShutdownCallback::Run; - } - ~ShutdownCallback() {} - static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { - *static_cast(cb)->done_ = static_cast(ok); - } - - private: - bool* done_; -}; - -/* helper for tests to shutdown correctly and tersely */ -static void shutdown_and_destroy(grpc_completion_queue* cc) { - grpc_completion_queue_shutdown(cc); - grpc_completion_queue_destroy(cc); -} - -static void do_nothing_end_completion(void* arg, grpc_cq_completion* c) {} - -static void BM_Callback_CQ_Default_Polling(benchmark::State& state) { - int tag_size = state.range(0); - grpc_completion_queue* cc; - void* tags[tag_size]; - grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)]; - - grpc_completion_queue_attributes attr; - unsigned i; - bool got_shutdown = false; - ShutdownCallback shutdown_cb(&got_shutdown); - - attr.version = 2; - attr.cq_completion_type = GRPC_CQ_CALLBACK; - attr.cq_shutdown_cb = &shutdown_cb; - while (state.KeepRunning()) { - int sumtags = 0; - int counter = 0; - { - // reset exec_ctx types - grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; - grpc_core::ExecCtx exec_ctx; - attr.cq_polling_type = GRPC_CQ_DEFAULT_POLLING; - cc = grpc_completion_queue_create( - grpc_completion_queue_factory_lookup(&attr), &attr, nullptr); - - for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { - tags[i] = static_cast(grpc_core::New(&counter, i)); - sumtags += i; - } - - for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { - GPR_ASSERT(grpc_cq_begin_op(cc, tags[i])); - grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, do_nothing_end_completion, - nullptr, &completions[i]); - } - - shutdown_and_destroy(cc); - } - GPR_ASSERT(sumtags == counter); - GPR_ASSERT(got_shutdown); - got_shutdown = false; - } -} -BENCHMARK(BM_Callback_CQ_Default_Polling)->Range(1, 128 * 1024); - -static void BM_Callback_CQ_Non_Listening(benchmark::State& state) { - int tag_size = state.range(0); - grpc_completion_queue* cc; - void* tags[tag_size]; - grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)]; - grpc_completion_queue_attributes attr; - unsigned i; - bool got_shutdown = false; - ShutdownCallback shutdown_cb(&got_shutdown); - - attr.version = 2; - attr.cq_completion_type = GRPC_CQ_CALLBACK; - attr.cq_shutdown_cb = &shutdown_cb; - while (state.KeepRunning()) { - int sumtags = 0; - int counter = 0; - { - // reset exec_ctx types - grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; - grpc_core::ExecCtx exec_ctx; - attr.cq_polling_type = GRPC_CQ_NON_LISTENING; - cc = grpc_completion_queue_create( - grpc_completion_queue_factory_lookup(&attr), &attr, nullptr); - - for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { - tags[i] = static_cast(grpc_core::New(&counter, i)); - sumtags += i; - } - - for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { - GPR_ASSERT(grpc_cq_begin_op(cc, tags[i])); - grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, do_nothing_end_completion, - nullptr, &completions[i]); - } - - shutdown_and_destroy(cc); - } - GPR_ASSERT(sumtags == counter); - GPR_ASSERT(got_shutdown); - got_shutdown = false; - } -} -BENCHMARK(BM_Callback_CQ_Non_Listening)->Range(1, 128 * 1024); - -static void BM_Callback_CQ_Non_Polling(benchmark::State& state) { - int tag_size = state.range(0); - grpc_completion_queue* cc; - void* tags[tag_size]; - grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)]; - grpc_completion_queue_attributes attr; - unsigned i; - bool got_shutdown = false; - ShutdownCallback shutdown_cb(&got_shutdown); - - attr.version = 2; - attr.cq_completion_type = GRPC_CQ_CALLBACK; - attr.cq_shutdown_cb = &shutdown_cb; - while (state.KeepRunning()) { - int sumtags = 0; - int counter = 0; - { - // reset exec_ctx types - grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; - grpc_core::ExecCtx exec_ctx; - attr.cq_polling_type = GRPC_CQ_DEFAULT_POLLING; - cc = grpc_completion_queue_create( - grpc_completion_queue_factory_lookup(&attr), &attr, nullptr); - - for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { - tags[i] = static_cast(grpc_core::New(&counter, i)); - sumtags += i; - } - - for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { - GPR_ASSERT(grpc_cq_begin_op(cc, tags[i])); - grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, do_nothing_end_completion, - nullptr, &completions[i]); - } - - shutdown_and_destroy(cc); - } - GPR_ASSERT(sumtags == counter); - GPR_ASSERT(got_shutdown); - got_shutdown = false; - } -} -BENCHMARK(BM_Callback_CQ_Non_Polling)->Range(1, 128 * 1024); - -} // namespace testing -} // namespace grpc - -// Some distros have RunSpecifiedBenchmarks under the benchmark namespace, -// and others do not. This allows us to support both modes. -namespace benchmark { -void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } -} // namespace benchmark - -int main(int argc, char** argv) { - LibraryInitializer libInit; - ::benchmark::Initialize(&argc, argv); - ::grpc::testing::InitTest(&argc, &argv, false); - benchmark::RunTheBenchmarksNamespaced(); - return 0; -} diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index 263314deb93..c72a526c5ef 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -144,6 +144,56 @@ static void BM_EmptyCore(benchmark::State& state) { } BENCHMARK(BM_EmptyCore); +// helper for tests to shutdown correctly and tersely +static void shutdown_and_destroy(grpc_completion_queue* cc) { + grpc_completion_queue_shutdown(cc); + grpc_completion_queue_destroy(cc); +} + +class TagCallback : public grpc_experimental_completion_queue_functor { + public: + TagCallback() { functor_run = &TagCallback::Run; } + ~TagCallback() {} + static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { + GPR_ASSERT(static_cast(ok)); + }; +}; + +class ShutdownCallback : public grpc_experimental_completion_queue_functor { + public: + ShutdownCallback(bool* done) : done_(done) { + functor_run = &ShutdownCallback::Run; + } + ~ShutdownCallback() {} + static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { + *static_cast(cb)->done_ = static_cast(ok); + } + + private: + bool* done_; +}; + +static void BM_Callback_CQ_Pass1Core(benchmark::State& state) { + TrackCounters track_counters; + TagCallback tag; + bool got_shutdown = false; + ShutdownCallback shutdown_cb(&got_shutdown); + grpc_completion_queue* cc = + grpc_completion_queue_create_for_callback(&shutdown_cb, nullptr); + while (state.KeepRunning()) { + grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; + grpc_core::ExecCtx exec_ctx; + grpc_cq_completion completion; + GPR_ASSERT(grpc_cq_begin_op(cc, &tag)); + grpc_cq_end_op(cc, &tag, GRPC_ERROR_NONE, DoneWithCompletionOnStack, + nullptr, &completion); + } + shutdown_and_destroy(cc); + GPR_ASSERT(got_shutdown); + track_counters.Finish(state); +} +BENCHMARK(BM_Callback_CQ_Pass1Core); + } // namespace testing } // namespace grpc diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 35c8996c9e3..ad4004213f9 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -2779,28 +2779,7 @@ { "deps": [ "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "bm_callback_cq", - "src": [ - "test/cpp/microbenchmarks/bm_callback_cq.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "callback_test_service", + "bm_callback_test_service_impl", "gpr", "grpc++_test_config", "grpc++_test_util_unsecure", @@ -2825,7 +2804,7 @@ { "deps": [ "benchmark", - "callback_test_service", + "bm_callback_test_service_impl", "gpr", "grpc++_test_config", "grpc++_test_util_unsecure", @@ -6693,7 +6672,7 @@ ], "is_filegroup": false, "language": "c++", - "name": "callback_test_service", + "name": "bm_callback_test_service_impl", "src": [ "test/cpp/microbenchmarks/callback_test_service.cc", "test/cpp/microbenchmarks/callback_test_service.h" diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index b3f8087042d..bed602361bb 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -3479,32 +3479,6 @@ ], "uses_polling": false }, - { - "args": [], - "benchmark": true, - "ci_platforms": [ - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "excluded_poll_engines": [ - "poll" - ], - "flaky": false, - "gtest": false, - "language": "c++", - "name": "bm_callback_cq", - "platforms": [ - "linux", - "mac", - "posix" - ], - "timeout_seconds": 1200, - "uses_polling": true - }, { "args": [], "benchmark": true, From 1984b3479795d66c3d87e7158b51fc0417b8cc7a Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 8 May 2019 16:22:10 -0700 Subject: [PATCH 0167/1555] Try getting around clang tidy issue --- .../end2end/service_config_end2end_test.cc | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/cpp/end2end/service_config_end2end_test.cc b/test/cpp/end2end/service_config_end2end_test.cc index 9b259bd6342..2d05fd42635 100644 --- a/test/cpp/end2end/service_config_end2end_test.cc +++ b/test/cpp/end2end/service_config_end2end_test.cc @@ -222,8 +222,16 @@ class ServiceConfigEnd2endTest : public ::testing::Test { return grpc::testing::EchoTestService::NewStub(channel); } - std::shared_ptr BuildChannel( - ChannelArguments args = ChannelArguments()) { + std::shared_ptr BuildChannel() { + ChannelArguments args; + args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, + response_generator_.get()); + return ::grpc::CreateCustomChannel("fake:///", creds_, args); + } + + std::shared_ptr BuildChannelWithDefaultServiceConfig() { + ChannelArguments args; + args.SetServiceConfigJSON(ValidDefaultServiceConfig()); args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, response_generator_.get()); return ::grpc::CreateCustomChannel("fake:///", creds_, args); @@ -417,9 +425,7 @@ TEST_F(ServiceConfigEnd2endTest, NoServiceConfigTest) { TEST_F(ServiceConfigEnd2endTest, NoServiceConfigWithDefaultConfigTest) { StartServers(1); - ChannelArguments args; - args.SetServiceConfigJSON(ValidDefaultServiceConfig()); - auto channel = BuildChannel(args); + auto channel = BuildChannelWithDefaultServiceConfig(); auto stub = BuildStub(channel); SetNextResolutionNoServiceConfig(GetServersPorts()); CheckRpcSendOk(stub, DEBUG_LOCATION); @@ -437,9 +443,7 @@ TEST_F(ServiceConfigEnd2endTest, InvalidServiceConfigTest) { TEST_F(ServiceConfigEnd2endTest, InvalidServiceConfigWithDefaultConfigTest) { StartServers(1); - ChannelArguments args; - args.SetServiceConfigJSON(ValidDefaultServiceConfig()); - auto channel = BuildChannel(args); + auto channel = BuildChannelWithDefaultServiceConfig(); auto stub = BuildStub(channel); SetNextResolutionInvalidServiceConfig(GetServersPorts()); CheckRpcSendOk(stub, DEBUG_LOCATION); @@ -475,9 +479,7 @@ TEST_F(ServiceConfigEnd2endTest, TEST_F(ServiceConfigEnd2endTest, NoServiceConfigUpdateAfterValidServiceConfigWithDefaultConfigTest) { StartServers(1); - ChannelArguments args; - args.SetServiceConfigJSON(ValidDefaultServiceConfig()); - auto channel = BuildChannel(args); + auto channel = BuildChannelWithDefaultServiceConfig(); auto stub = BuildStub(channel); SetNextResolutionWithServiceConfig(GetServersPorts(), ValidServiceConfigV1()); CheckRpcSendOk(stub, DEBUG_LOCATION); @@ -504,9 +506,7 @@ TEST_F(ServiceConfigEnd2endTest, TEST_F(ServiceConfigEnd2endTest, InvalidServiceConfigUpdateAfterValidServiceConfigWithDefaultConfigTest) { StartServers(1); - ChannelArguments args; - args.SetServiceConfigJSON(ValidDefaultServiceConfig()); - auto channel = BuildChannel(args); + auto channel = BuildChannelWithDefaultServiceConfig(); auto stub = BuildStub(channel); SetNextResolutionWithServiceConfig(GetServersPorts(), ValidServiceConfigV1()); CheckRpcSendOk(stub, DEBUG_LOCATION); From 762e58b574686c4b9ba4e208ec6f9cf1c5ec88bc Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Wed, 8 May 2019 17:34:27 -0700 Subject: [PATCH 0168/1555] Change client context allocation --- .../microbenchmarks/callback_unary_ping_pong.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/cpp/microbenchmarks/callback_unary_ping_pong.h b/test/cpp/microbenchmarks/callback_unary_ping_pong.h index 804d2808a32..6078a77f78f 100644 --- a/test/cpp/microbenchmarks/callback_unary_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_unary_ping_pong.h @@ -37,26 +37,26 @@ namespace testing { */ // Send next rpc when callback function is evoked. -void SendCallbackUnaryPingPong(benchmark::State* state, EchoRequest* request, - EchoResponse* response, +void SendCallbackUnaryPingPong(benchmark::State* state, ClientContext* cli_ctx, + EchoRequest* request, EchoResponse* response, EchoTestService::Stub* stub_, bool* done, std::mutex* mu, std::condition_variable* cv) { int response_msgs_size = state->range(1); - ClientContext* cli_ctx = new ClientContext(); cli_ctx->AddMetadata(kServerMessageSize, grpc::to_string(response_msgs_size)); stub_->experimental_async()->Echo( cli_ctx, request, response, [state, cli_ctx, request, response, stub_, done, mu, cv](Status s) { GPR_ASSERT(s.ok()); if (state->KeepRunning()) { - SendCallbackUnaryPingPong(state, request, response, stub_, done, mu, - cv); + cli_ctx->~ClientContext(); + new (cli_ctx) ClientContext(); + SendCallbackUnaryPingPong(state, cli_ctx, request, response, stub_, + done, mu, cv); } else { std::lock_guard l(*mu); *done = true; cv->notify_one(); } - delete cli_ctx; }); }; @@ -70,6 +70,7 @@ static void BM_CallbackUnaryPingPong(benchmark::State& state) { EchoTestService::NewStub(fixture->channel())); EchoRequest request; EchoResponse response; + ClientContext cli_ctx; if (request_msgs_size > 0) { request.set_message(std::string(request_msgs_size, 'a')); @@ -82,7 +83,7 @@ static void BM_CallbackUnaryPingPong(benchmark::State& state) { bool done = false; if (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); - SendCallbackUnaryPingPong(&state, &request, &response, stub_.get(), &done, + SendCallbackUnaryPingPong(&state, &cli_ctx, &request, &response, stub_.get(), &done, &mu, &cv); } std::unique_lock l(mu); From 569d33f49b52d62d22d934ccf620e322e1982b1a Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Wed, 8 May 2019 17:49:52 -0700 Subject: [PATCH 0169/1555] Add two more trace logs to the c-ares resolver --- .../client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc index 97ef61d2f33..e6845f74d44 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc @@ -154,6 +154,10 @@ void grpc_ares_complete_request_locked(grpc_ares_request* r) { static grpc_ares_hostbyname_request* create_hostbyname_request_locked( grpc_ares_request* parent_request, char* host, uint16_t port, bool is_balancer) { + GRPC_CARES_TRACE_LOG( + "request:%p create_hostbyname_request_locked host:%s port:%d " + "is_balancer:%d", + parent_request, host, port, is_balancer); grpc_ares_hostbyname_request* hr = static_cast( gpr_zalloc(sizeof(grpc_ares_hostbyname_request))); hr->parent_request = parent_request; @@ -251,6 +255,8 @@ static void on_srv_query_done_locked(void* arg, int status, int timeouts, GRPC_CARES_TRACE_LOG("request:%p on_srv_query_done_locked ARES_SUCCESS", r); struct ares_srv_reply* reply; const int parse_status = ares_parse_srv_reply(abuf, alen, &reply); + GRPC_CARES_TRACE_LOG("request:%p ares_parse_srv_reply: %d", r, + parse_status); if (parse_status == ARES_SUCCESS) { ares_channel* channel = grpc_ares_ev_driver_get_channel_locked(r->ev_driver); From 360e501db21abae4b77f27dae9e3f5827c3bdfca Mon Sep 17 00:00:00 2001 From: Daniel Alm Date: Tue, 30 Apr 2019 14:17:35 +0200 Subject: [PATCH 0170/1555] Add `void` arguments to two function declarations. --- include/grpc/grpc_security.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h index 53189097b9b..d0b2be9e25e 100644 --- a/include/grpc/grpc_security.h +++ b/include/grpc/grpc_security.h @@ -641,7 +641,7 @@ typedef struct grpc_tls_credentials_options grpc_tls_credentials_options; /** Create an empty TLS credentials options. It is used for * experimental purpose for now and subject to change. */ -GRPCAPI grpc_tls_credentials_options* grpc_tls_credentials_options_create(); +GRPCAPI grpc_tls_credentials_options* grpc_tls_credentials_options_create(void); /** Set grpc_ssl_client_certificate_request_type field in credentials options with the provided type. options should not be NULL. @@ -683,7 +683,7 @@ GRPCAPI int grpc_tls_credentials_options_set_server_authorization_check_config( /** Create an empty grpc_tls_key_materials_config instance. * It is used for experimental purpose for now and subject to change. */ -GRPCAPI grpc_tls_key_materials_config* grpc_tls_key_materials_config_create(); +GRPCAPI grpc_tls_key_materials_config* grpc_tls_key_materials_config_create(void); /** Set grpc_tls_key_materials_config instance with provided a TLS certificate. config will take the ownership of pem_root_certs and pem_key_cert_pairs. From cb8c4afdea4a791ee5dfd4621a386311625a22b0 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 1 May 2019 22:45:21 -0700 Subject: [PATCH 0171/1555] Resolve consistency checks --- include/grpc/grpc_security.h | 3 ++- src/ruby/ext/grpc/rb_grpc_imports.generated.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h index d0b2be9e25e..ebdf86b7d50 100644 --- a/include/grpc/grpc_security.h +++ b/include/grpc/grpc_security.h @@ -683,7 +683,8 @@ GRPCAPI int grpc_tls_credentials_options_set_server_authorization_check_config( /** Create an empty grpc_tls_key_materials_config instance. * It is used for experimental purpose for now and subject to change. */ -GRPCAPI grpc_tls_key_materials_config* grpc_tls_key_materials_config_create(void); +GRPCAPI grpc_tls_key_materials_config* grpc_tls_key_materials_config_create( + void); /** Set grpc_tls_key_materials_config instance with provided a TLS certificate. config will take the ownership of pem_root_certs and pem_key_cert_pairs. diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index 275ca6e9cbf..c25d789a95b 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -440,7 +440,7 @@ extern grpc_local_credentials_create_type grpc_local_credentials_create_import; typedef grpc_server_credentials*(*grpc_local_server_credentials_create_type)(grpc_local_connect_type type); extern grpc_local_server_credentials_create_type grpc_local_server_credentials_create_import; #define grpc_local_server_credentials_create grpc_local_server_credentials_create_import -typedef grpc_tls_credentials_options*(*grpc_tls_credentials_options_create_type)(); +typedef grpc_tls_credentials_options*(*grpc_tls_credentials_options_create_type)(void); extern grpc_tls_credentials_options_create_type grpc_tls_credentials_options_create_import; #define grpc_tls_credentials_options_create grpc_tls_credentials_options_create_import typedef int(*grpc_tls_credentials_options_set_cert_request_type_type)(grpc_tls_credentials_options* options, grpc_ssl_client_certificate_request_type type); @@ -455,7 +455,7 @@ extern grpc_tls_credentials_options_set_credential_reload_config_type grpc_tls_c typedef int(*grpc_tls_credentials_options_set_server_authorization_check_config_type)(grpc_tls_credentials_options* options, grpc_tls_server_authorization_check_config* config); extern grpc_tls_credentials_options_set_server_authorization_check_config_type grpc_tls_credentials_options_set_server_authorization_check_config_import; #define grpc_tls_credentials_options_set_server_authorization_check_config grpc_tls_credentials_options_set_server_authorization_check_config_import -typedef grpc_tls_key_materials_config*(*grpc_tls_key_materials_config_create_type)(); +typedef grpc_tls_key_materials_config*(*grpc_tls_key_materials_config_create_type)(void); extern grpc_tls_key_materials_config_create_type grpc_tls_key_materials_config_create_import; #define grpc_tls_key_materials_config_create grpc_tls_key_materials_config_create_import typedef int(*grpc_tls_key_materials_config_set_key_materials_type)(grpc_tls_key_materials_config* config, const char* pem_root_certs, const grpc_ssl_pem_key_cert_pair** pem_key_cert_pairs, size_t num_key_cert_pairs); From 98d8f85d4e99c1ace1e1883eaa4ac7c1435cf947 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 9 May 2019 10:58:00 -0700 Subject: [PATCH 0172/1555] Reviewer comments --- .../filters/client_channel/client_channel.cc | 25 +++++++++++-------- .../lb_policy/subchannel_list.h | 4 +++ test/cpp/end2end/grpclb_end2end_test.cc | 7 +++--- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 9144df93c12..3fdabda8c53 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -273,7 +273,7 @@ class ChannelData { ExternalConnectivityWatcher::WatcherList external_connectivity_watcher_list_; UniquePtr health_check_service_name_; RefCountedPtr saved_service_config_; - bool set_service_config_ = false; + bool received_first_resolver_result_ = false; // // Fields accessed from both data plane and control plane combiners. @@ -1249,7 +1249,7 @@ bool ChannelData::ProcessResolverResultLocked( result.service_config_error != GRPC_ERROR_NONE) { return false; } - UniquePtr service_config_json = nullptr; + UniquePtr service_config_json; // Process service config. const internal::ClientChannelGlobalParsedObject* parsed_object = nullptr; if (service_config != nullptr) { @@ -1265,14 +1265,12 @@ bool ChannelData::ProcessResolverResultLocked( strcmp(service_config->service_config_json(), chand->saved_service_config_->service_config_json()) != 0); if (service_config_changed) { - if (service_config != nullptr) { - service_config_json.reset( - gpr_strdup(service_config->service_config_json())); - } else { - service_config_json.reset(gpr_strdup("")); - } + service_config_json.reset(gpr_strdup( + service_config != nullptr ? service_config->service_config_json() + : "")); if (grpc_client_channel_routing_trace.enabled()) { - gpr_log(GPR_INFO, "chand=%p: resolver returned service config: \"%s\"", + gpr_log(GPR_INFO, + "chand=%p: resolver returned updated service config: \"%s\"", chand, service_config_json.get()); } chand->saved_service_config_ = std::move(service_config); @@ -1283,8 +1281,11 @@ bool ChannelData::ProcessResolverResultLocked( chand->health_check_service_name_.reset(); } } - if (service_config_changed || !chand->set_service_config_) { - chand->set_service_config_ = true; + // We want to set the service config atleast once. This should not really be + // needed, but we are doing it as a defensive approach. This can be removed, + // if we feel it is unnecessary. + if (service_config_changed || !chand->received_first_resolver_result_) { + chand->received_first_resolver_result_ = true; Optional retry_throttle_data; if (parsed_object != nullptr) { @@ -3029,6 +3030,8 @@ void CallData::AddSubchannelBatchesForPendingBatches( // If we're not retrying, just send the batch as-is. if (method_params_ == nullptr || method_params_->retry_policy() == nullptr || retry_committed_) { + // TODO(roth) : We should probably call + // MaybeInjectRecvTrailingMetadataReadyForLoadBalancingPolicy here. AddClosureForSubchannelBatch(elem, batch, closures); PendingBatchClear(pending); continue; diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h index c222985cf18..be49fd02837 100644 --- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h @@ -506,6 +506,10 @@ SubchannelList::SubchannelList( GRPC_ARG_INHIBIT_HEALTH_CHECKING}; // Create a subchannel for each address. for (size_t i = 0; i < addresses.size(); i++) { + // TODO(roth): we should ideally hide this from the LB policy code. In + // principle, if we're dealing with this special case in the client_channel + // code for selecting grpclb, then we should also strip out these addresses + // there if we're not using grpclb. if (addresses[i].IsBalancer()) { continue; } diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc index 3ac28ec7e43..50b1383e7e1 100644 --- a/test/cpp/end2end/grpclb_end2end_test.cc +++ b/test/cpp/end2end/grpclb_end2end_test.cc @@ -738,7 +738,7 @@ TEST_F(SingleBalancerTest, SelectGrpclbWithMigrationServiceConfig) { } TEST_F(SingleBalancerTest, - DoNotSpecialCaseUseGrpclbWithLoadBalancingConfigTest1) { + DoNotSpecialCaseUseGrpclbWithLoadBalancingConfigTest) { const int kFallbackTimeoutMs = 200 * grpc_test_slowdown_factor(); ResetStub(kFallbackTimeoutMs); SetNextResolution({AddressData{backends_[0]->port_, false, ""}, @@ -753,8 +753,9 @@ TEST_F(SingleBalancerTest, EXPECT_EQ("pick_first", channel_->GetLoadBalancingPolicyName()); } -TEST_F(SingleBalancerTest, - DoNotSpecialCaseUseGrpclbWithLoadBalancingConfigTest2) { +TEST_F( + SingleBalancerTest, + DoNotSpecialCaseUseGrpclbWithLoadBalancingConfigTestAndNoBackendAddress) { const int kFallbackTimeoutMs = 200 * grpc_test_slowdown_factor(); ResetStub(kFallbackTimeoutMs); SetNextResolution({AddressData{balancers_[0]->port_, true, ""}}, From ca541c9c5f5389f9123c16f77fbcca7fcad40ae1 Mon Sep 17 00:00:00 2001 From: Guantao Liu Date: Thu, 9 May 2019 11:37:19 -0700 Subject: [PATCH 0173/1555] Address review comments. --- test/cpp/qps/client_callback.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/cpp/qps/client_callback.cc b/test/cpp/qps/client_callback.cc index ade23e13a72..d22264d21e3 100644 --- a/test/cpp/qps/client_callback.cc +++ b/test/cpp/qps/client_callback.cc @@ -293,9 +293,6 @@ class CallbackStreamingPingPongReactor final gpr_timespec next_issue_time = client_->NextRPCIssueTime(); // Start an alarm callback to run the internal callback after // next_issue_time - if (ctx_->alarm_ == nullptr) { - ctx_->alarm_.reset(new Alarm); - } ctx_->alarm_->experimental().Set(next_issue_time, [this](bool ok) { write_time_ = UsageTimer::Now(); StartWrite(client_->request()); From 1ea651aee3b257e4073169f49e5b0b94388552e7 Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Thu, 9 May 2019 12:22:55 -0700 Subject: [PATCH 0174/1555] Add assertion --- test/cpp/microbenchmarks/BUILD | 1 - test/cpp/microbenchmarks/bm_cq.cc | 20 +++- .../callback_streaming_ping_pong.h | 95 ++++++++++++++++++- .../microbenchmarks/callback_test_service.cc | 3 + .../microbenchmarks/callback_test_service.h | 81 ---------------- .../callback_unary_ping_pong.h | 1 - 6 files changed, 110 insertions(+), 91 deletions(-) diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD index c42c5d53de9..d9424f24f16 100644 --- a/test/cpp/microbenchmarks/BUILD +++ b/test/cpp/microbenchmarks/BUILD @@ -230,7 +230,6 @@ grpc_cc_library( external_deps = [ "benchmark", ], - tags = ["no_windows"], deps = [ ":helpers", "//src/proto/grpc/testing:echo_proto", diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index c72a526c5ef..f4d02e2991b 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -144,21 +144,29 @@ static void BM_EmptyCore(benchmark::State& state) { } BENCHMARK(BM_EmptyCore); -// helper for tests to shutdown correctly and tersely +// Helper for tests to shutdown correctly and tersely static void shutdown_and_destroy(grpc_completion_queue* cc) { grpc_completion_queue_shutdown(cc); grpc_completion_queue_destroy(cc); } +// Tag completion queue iterate times class TagCallback : public grpc_experimental_completion_queue_functor { public: - TagCallback() { functor_run = &TagCallback::Run; } + TagCallback(int* iter) : iter_ (iter) { + functor_run = &TagCallback::Run; + } ~TagCallback() {} static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { GPR_ASSERT(static_cast(ok)); + *static_cast(cb)->iter_ += 1; }; + + private: + int* iter_; }; +// Check if completion queue is shut down class ShutdownCallback : public grpc_experimental_completion_queue_functor { public: ShutdownCallback(bool* done) : done_(done) { @@ -175,7 +183,8 @@ class ShutdownCallback : public grpc_experimental_completion_queue_functor { static void BM_Callback_CQ_Pass1Core(benchmark::State& state) { TrackCounters track_counters; - TagCallback tag; + int iteration = 0; + TagCallback tag_cb(&iteration); bool got_shutdown = false; ShutdownCallback shutdown_cb(&got_shutdown); grpc_completion_queue* cc = @@ -184,12 +193,13 @@ static void BM_Callback_CQ_Pass1Core(benchmark::State& state) { grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; grpc_cq_completion completion; - GPR_ASSERT(grpc_cq_begin_op(cc, &tag)); - grpc_cq_end_op(cc, &tag, GRPC_ERROR_NONE, DoneWithCompletionOnStack, + GPR_ASSERT(grpc_cq_begin_op(cc, &tag_cb)); + grpc_cq_end_op(cc, &tag_cb, GRPC_ERROR_NONE, DoneWithCompletionOnStack, nullptr, &completion); } shutdown_and_destroy(cc); GPR_ASSERT(got_shutdown); + GPR_ASSERT(iteration == static_cast(state.iterations())); track_counters.Finish(state); } BENCHMARK(BM_Callback_CQ_Pass1Core); diff --git a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h index af2db947800..8f10fabc43b 100644 --- a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h @@ -34,16 +34,105 @@ namespace testing { * BENCHMARKING KERNELS */ +class BidiClient + : public grpc::experimental::ClientBidiReactor { + public: + BidiClient(benchmark::State* state, EchoTestService::Stub* stub, + ClientContext* cli_ctx, EchoRequest* request, + EchoResponse* response) + : state_{state}, + stub_{stub}, + cli_ctx_{cli_ctx}, + request_{request}, + response_{response} { + msgs_size_ = state->range(0); + msgs_to_send_ = state->range(1); + StartNewRpc(); + } + + void OnReadDone(bool ok) override { + if (!ok) { + gpr_log(GPR_ERROR, "Client read failed"); + return; + } + if (writes_complete_ < msgs_to_send_) { + MaybeWrite(); + } + } + + void OnWriteDone(bool ok) override { + if (!ok) { + gpr_log(GPR_ERROR, "Client write failed"); + return; + } + writes_complete_++; + StartRead(response_); + } + + void OnDone(const Status& s) override { + GPR_ASSERT(s.ok()); + GPR_ASSERT(writes_complete_ == msgs_to_send_); + if (state_->KeepRunning()) { + writes_complete_ = 0; + StartNewRpc(); + } else { + std::unique_lock l(mu); + done = true; + cv.notify_one(); + } + } + + void StartNewRpc() { + cli_ctx_->~ClientContext(); + new (cli_ctx_) ClientContext(); + cli_ctx_->AddMetadata(kServerFinishAfterNReads, + grpc::to_string(msgs_to_send_)); + cli_ctx_->AddMetadata(kServerMessageSize, grpc::to_string(msgs_size_)); + stub_->experimental_async()->BidiStream(cli_ctx_, this); + MaybeWrite(); + StartCall(); + } + + void Await() { + std::unique_lock l(mu); + while (!done) { + cv.wait(l); + } + } + + private: + void MaybeWrite() { + if (writes_complete_ < msgs_to_send_) { + StartWrite(request_); + } else { + StartWritesDone(); + } + } + + benchmark::State* state_; + EchoTestService::Stub* stub_; + ClientContext* cli_ctx_; + EchoRequest* request_; + EchoResponse* response_; + int writes_complete_{0}; + int msgs_to_send_; + int msgs_size_; + std::mutex mu; + std::condition_variable cv; + bool done; +}; + template static void BM_CallbackBidiStreaming(benchmark::State& state) { - const int message_size = state.range(0); - const int max_ping_pongs = state.range(1); + int message_size = state.range(0); + int max_ping_pongs = state.range(1); CallbackStreamingTestService service; std::unique_ptr fixture(new Fixture(&service)); std::unique_ptr stub_( EchoTestService::NewStub(fixture->channel())); EchoRequest request; EchoResponse response; + ClientContext cli_ctx; if (message_size > 0) { request.set_message(std::string(message_size, 'a')); } else { @@ -51,7 +140,7 @@ static void BM_CallbackBidiStreaming(benchmark::State& state) { } if (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); - BidiClient test{&state, stub_.get(), &request, &response}; + BidiClient test{&state, stub_.get(), &cli_ctx, &request, &response}; test.Await(); } fixture->Finish(state); diff --git a/test/cpp/microbenchmarks/callback_test_service.cc b/test/cpp/microbenchmarks/callback_test_service.cc index 650e5372da7..2473dc5f31d 100644 --- a/test/cpp/microbenchmarks/callback_test_service.cc +++ b/test/cpp/microbenchmarks/callback_test_service.cc @@ -75,11 +75,13 @@ CallbackStreamingTestService::BidiStream() { } void OnDone() override { GPR_ASSERT(finished_); + GPR_ASSERT(num_msgs_read_ == server_write_last_); delete this; } void OnCancel() override {} void OnReadDone(bool ok) override { if (!ok) { + gpr_log(GPR_ERROR, "Server read failed"); return; } num_msgs_read_++; @@ -96,6 +98,7 @@ CallbackStreamingTestService::BidiStream() { } void OnWriteDone(bool ok) override { if (!ok) { + gpr_log(GPR_ERROR, "Server write failed"); return; } if (num_msgs_read_ < server_write_last_) { diff --git a/test/cpp/microbenchmarks/callback_test_service.h b/test/cpp/microbenchmarks/callback_test_service.h index b7b76fd806c..dd7977a5913 100644 --- a/test/cpp/microbenchmarks/callback_test_service.h +++ b/test/cpp/microbenchmarks/callback_test_service.h @@ -44,87 +44,6 @@ class CallbackStreamingTestService experimental::ServerBidiReactor* BidiStream() override; }; - -class BidiClient - : public grpc::experimental::ClientBidiReactor { - public: - BidiClient(benchmark::State* state, EchoTestService::Stub* stub, - EchoRequest* request, EchoResponse* response) - : state_{state}, stub_{stub}, request_{request}, response_{response} { - msgs_size_ = state->range(0); - msgs_to_send_ = state->range(1); - StartNewRpc(); - } - - void OnReadDone(bool ok) override { - if (!ok) { - return; - } - if (writes_complete_ < msgs_to_send_) { - MaybeWrite(); - } - } - - void OnWriteDone(bool ok) override { - if (!ok) { - return; - } - writes_complete_++; - StartRead(response_); - } - - void OnDone(const Status& s) override { - GPR_ASSERT(s.ok()); - if (state_->KeepRunning()) { - writes_complete_ = 0; - StartNewRpc(); - } else { - std::unique_lock l(mu); - done = true; - cv.notify_one(); - } - } - - void StartNewRpc() { - cli_ctx_.reset(new ClientContext); - cli_ctx_.get()->AddMetadata(kServerFinishAfterNReads, - grpc::to_string(msgs_to_send_)); - cli_ctx_.get()->AddMetadata(kServerMessageSize, - grpc::to_string(msgs_size_)); - stub_->experimental_async()->BidiStream(cli_ctx_.get(), this); - MaybeWrite(); - StartCall(); - } - - void Await() { - std::unique_lock l(mu); - while (!done) { - cv.wait(l); - } - } - - private: - void MaybeWrite() { - if (writes_complete_ < msgs_to_send_) { - StartWrite(request_); - } else { - StartWritesDone(); - } - } - - std::unique_ptr cli_ctx_; - benchmark::State* state_; - EchoTestService::Stub* stub_; - EchoRequest* request_; - EchoResponse* response_; - int writes_complete_{0}; - int msgs_to_send_; - int msgs_size_; - std::mutex mu; - std::condition_variable cv; - bool done; -}; - } // namespace testing } // namespace grpc #endif // TEST_CPP_MICROBENCHMARKS_CALLBACK_TEST_SERVICE_H diff --git a/test/cpp/microbenchmarks/callback_unary_ping_pong.h b/test/cpp/microbenchmarks/callback_unary_ping_pong.h index 9ba388b8876..359b91eb6fe 100644 --- a/test/cpp/microbenchmarks/callback_unary_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_unary_ping_pong.h @@ -36,7 +36,6 @@ namespace testing { * BENCHMARKING KERNELS */ -// Send next rpc when callback function is evoked. void SendCallbackUnaryPingPong(benchmark::State* state, ClientContext* cli_ctx, EchoRequest* request, EchoResponse* response, EchoTestService::Stub* stub_, bool* done, From a2daa4ff083a95cfefbcc2cfe2d3ea8936572f64 Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Thu, 9 May 2019 12:29:05 -0700 Subject: [PATCH 0175/1555] Clean format' --- test/cpp/microbenchmarks/bm_cq.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index f4d02e2991b..caa5e7d6d31 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -153,9 +153,7 @@ static void shutdown_and_destroy(grpc_completion_queue* cc) { // Tag completion queue iterate times class TagCallback : public grpc_experimental_completion_queue_functor { public: - TagCallback(int* iter) : iter_ (iter) { - functor_run = &TagCallback::Run; - } + TagCallback(int* iter) : iter_(iter) { functor_run = &TagCallback::Run; } ~TagCallback() {} static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { GPR_ASSERT(static_cast(ok)); From 87905ae5ead879a3baff731b3bed5408249beacd Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Thu, 9 May 2019 12:29:38 -0700 Subject: [PATCH 0176/1555] Config migration --- BUILD | 16 +++++++ BUILD.gn | 2 + CMakeLists.txt | 2 + Makefile | 2 + build.yaml | 9 ++++ config.m4 | 2 + config.w32 | 1 + gRPC-C++.podspec | 1 + gRPC-Core.podspec | 3 ++ grpc.gemspec | 2 + grpc.gyp | 2 + package.xml | 2 + .../interop/app/src/main/cpp/grpc-interop.cc | 6 +-- .../filters/client_channel/backup_poller.cc | 11 +++-- .../client_channel/http_connect_handshaker.cc | 1 - .../resolver/dns/c_ares/dns_resolver_ares.cc | 14 +++--- .../resolver/dns/dns_resolver_selection.cc | 28 ++++++++++++ .../resolver/dns/dns_resolver_selection.h | 29 ++++++++++++ .../resolver/dns/native/dns_resolver.cc | 8 ++-- .../chttp2/transport/chttp2_plugin.cc | 7 ++- src/core/lib/debug/trace.cc | 20 ++++++--- src/core/lib/debug/trace.h | 8 ++++ src/core/lib/gpr/env.h | 6 --- src/core/lib/gpr/env_linux.cc | 2 +- src/core/lib/gpr/env_windows.cc | 5 --- src/core/lib/gpr/log.cc | 22 ++++------ src/core/lib/gprpp/fork.cc | 41 +++++------------ src/core/lib/iomgr/ev_posix.cc | 26 ++++++----- src/core/lib/iomgr/ev_posix.h | 3 ++ src/core/lib/iomgr/fork_posix.cc | 1 - src/core/lib/iomgr/iomgr.cc | 3 +- src/core/lib/profiling/basic_timers.cc | 14 ++++-- .../load_system_roots_linux.cc | 12 ++--- .../security_connector/security_connector.cc | 1 - .../security/security_connector/ssl_utils.cc | 44 +++++++++++-------- .../security/security_connector/ssl_utils.h | 6 ++- src/core/lib/surface/init.cc | 2 +- .../private/GRPCSecureChannelFactory.m | 3 +- .../CoreCronetEnd2EndTests.mm | 4 +- src/python/grpcio/grpc_core_dependencies.py | 1 + test/core/bad_connection/close_fd_test.cc | 1 - test/core/bad_ssl/bad_ssl_test.cc | 4 +- .../resolvers/dns_resolver_test.cc | 8 ++-- test/core/end2end/fixtures/h2_full+trace.cc | 4 +- .../end2end/fixtures/h2_sockpair+trace.cc | 5 ++- test/core/end2end/fixtures/h2_spiffe.cc | 3 +- test/core/end2end/fixtures/h2_ssl.cc | 4 +- .../end2end/fixtures/h2_ssl_cred_reload.cc | 4 +- test/core/end2end/fixtures/h2_ssl_proxy.cc | 4 +- test/core/end2end/h2_ssl_cert_test.cc | 4 +- .../core/end2end/h2_ssl_session_reuse_test.cc | 4 +- test/core/end2end/tests/keepalive_timeout.cc | 14 +++--- test/core/gpr/log_test.cc | 13 ++++-- test/core/http/httpscli_test.cc | 3 +- test/core/iomgr/resolve_address_posix_test.cc | 18 ++++---- test/core/iomgr/resolve_address_test.cc | 13 +++--- test/core/security/credentials_test.cc | 2 +- test/core/security/security_connector_test.cc | 10 ++--- test/core/util/test_config.cc | 1 - test/cpp/end2end/async_end2end_test.cc | 12 +++-- test/cpp/end2end/end2end_test.cc | 12 +++-- test/cpp/naming/address_sorting_test.cc | 14 +++--- test/cpp/naming/cancel_ares_query_test.cc | 4 +- test/cpp/naming/resolver_component_test.cc | 1 - tools/doxygen/Doxyfile.core.internal | 2 + .../generated/sources_and_headers.json | 24 +++++++++- tools/run_tests/run_microbenchmark.py | 2 +- .../run_tests/sanity/core_banned_functions.py | 4 -- 68 files changed, 358 insertions(+), 208 deletions(-) create mode 100644 src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc create mode 100644 src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h diff --git a/BUILD b/BUILD index a03d2b61be4..5c3ecc8f466 100644 --- a/BUILD +++ b/BUILD @@ -1560,6 +1560,20 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "grpc_resolver_dns_selection", + srcs = [ + "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc", + ], + hdrs = [ + "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h", + ], + language = "c++", + deps = [ + "grpc_base", + ], +) + grpc_cc_library( name = "grpc_resolver_dns_native", srcs = [ @@ -1569,6 +1583,7 @@ grpc_cc_library( deps = [ "grpc_base", "grpc_client_channel", + "grpc_resolver_dns_selection", ], ) @@ -1600,6 +1615,7 @@ grpc_cc_library( deps = [ "grpc_base", "grpc_client_channel", + "grpc_resolver_dns_selection", ], ) diff --git a/BUILD.gn b/BUILD.gn index 9a416d7f41d..6d9d9368d7f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -326,6 +326,8 @@ config("grpc_config") { "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", + "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc", + "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h", "src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc", "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc", "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 8382fb7318f..1823e97f989 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1301,6 +1301,7 @@ add_library(grpc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc + src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc src/core/ext/filters/census/grpc_context.cc @@ -2697,6 +2698,7 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc + src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc diff --git a/Makefile b/Makefile index 3b0e60ecef4..49692e1de67 100644 --- a/Makefile +++ b/Makefile @@ -3769,6 +3769,7 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ + src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ src/core/ext/filters/census/grpc_context.cc \ @@ -5113,6 +5114,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ + src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ diff --git a/build.yaml b/build.yaml index a61b7987a4e..38699956c50 100644 --- a/build.yaml +++ b/build.yaml @@ -797,6 +797,7 @@ filegroups: uses: - grpc_base - grpc_client_channel + - grpc_resolver_dns_selection - name: grpc_resolver_dns_native src: - src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc @@ -804,6 +805,14 @@ filegroups: uses: - grpc_base - grpc_client_channel + - grpc_resolver_dns_selection +- name: grpc_resolver_dns_selection + headers: + - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h + src: + - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc + uses: + - grpc_base - name: grpc_resolver_fake headers: - src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h diff --git a/config.m4 b/config.m4 index c5ecf7cfd6a..d90a8e94e6d 100644 --- a/config.m4 +++ b/config.m4 @@ -412,6 +412,7 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ + src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ src/core/ext/filters/census/grpc_context.cc \ @@ -695,6 +696,7 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/pick_first) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/round_robin) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/xds) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns/c_ares) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns/native) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/fake) diff --git a/config.w32 b/config.w32 index 6bcc54f6630..70ac245d9fa 100644 --- a/config.w32 +++ b/config.w32 @@ -387,6 +387,7 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_libuv_windows.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_posix.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_windows.cc " + + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\dns_resolver_selection.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\native\\dns_resolver.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\sockaddr\\sockaddr_resolver.cc " + "src\\core\\ext\\filters\\census\\grpc_context.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 04f23b9f5c0..9f3428d3cff 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -561,6 +561,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h', + 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', 'src/core/ext/filters/http/client_authority_filter.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index b0b678565e2..cbf0a4b2924 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -539,6 +539,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h', + 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', 'src/core/ext/filters/http/client_authority_filter.h', @@ -869,6 +870,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', + 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/census/grpc_context.cc', @@ -1190,6 +1192,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h', + 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', 'src/core/ext/filters/http/client_authority_filter.h', diff --git a/grpc.gemspec b/grpc.gemspec index 063b6d6422c..6e229a5ab71 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -473,6 +473,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h ) + s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h ) s.files += %w( src/core/ext/filters/max_age/max_age_filter.h ) s.files += %w( src/core/ext/filters/message_size/message_size_filter.h ) s.files += %w( src/core/ext/filters/http/client_authority_filter.h ) @@ -806,6 +807,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc ) + s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc ) s.files += %w( src/core/ext/filters/census/grpc_context.cc ) diff --git a/grpc.gyp b/grpc.gyp index e6ed4d7318d..833a0b48715 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -594,6 +594,7 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', + 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/census/grpc_context.cc', @@ -1354,6 +1355,7 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', + 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', diff --git a/package.xml b/package.xml index 15fe7908b9e..04d9f35cf03 100644 --- a/package.xml +++ b/package.xml @@ -478,6 +478,7 @@ + @@ -811,6 +812,7 @@ + diff --git a/src/android/test/interop/app/src/main/cpp/grpc-interop.cc b/src/android/test/interop/app/src/main/cpp/grpc-interop.cc index 07834250d22..b5075529be2 100644 --- a/src/android/test/interop/app/src/main/cpp/grpc-interop.cc +++ b/src/android/test/interop/app/src/main/cpp/grpc-interop.cc @@ -18,8 +18,8 @@ #include #include -#include +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/cpp/interop/interop_client.h" extern "C" JNIEXPORT void JNICALL @@ -28,7 +28,7 @@ Java_io_grpc_interop_cpp_InteropActivity_configureSslRoots(JNIEnv* env, jstring path_raw) { const char* path = env->GetStringUTFChars(path_raw, (jboolean*)0); - gpr_setenv("GRPC_DEFAULT_SSL_ROOTS_FILE_PATH", path); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, path); } std::shared_ptr GetClient(const char* host, @@ -45,7 +45,7 @@ std::shared_ptr GetClient(const char* host, credentials = grpc::InsecureChannelCredentials(); } - grpc::testing::ChannelCreationFunc channel_creation_func = + grpc::testing::ChannelCreationFunc channel_creation_func = std::bind(grpc::CreateChannel, host_port, credentials); return std::shared_ptr( new grpc::testing::InteropClient(channel_creation_func, true, false)); diff --git a/src/core/ext/filters/client_channel/backup_poller.cc b/src/core/ext/filters/client_channel/backup_poller.cc index a2d45c04026..dd761694414 100644 --- a/src/core/ext/filters/client_channel/backup_poller.cc +++ b/src/core/ext/filters/client_channel/backup_poller.cc @@ -56,9 +56,14 @@ static backup_poller* g_poller = nullptr; // guarded by g_poller_mu // treated as const. static int g_poll_interval_ms = DEFAULT_POLL_INTERVAL_MS; -GPR_GLOBAL_CONFIG_DEFINE_INT32(grpc_client_channel_backup_poll_interval_ms, - DEFAULT_POLL_INTERVAL_MS, - "Client channel backup poll interval (ms)"); +GPR_GLOBAL_CONFIG_DEFINE_INT32( + grpc_client_channel_backup_poll_interval_ms, DEFAULT_POLL_INTERVAL_MS, + "Declares the interval in ms between two backup polls on client channels. " + "These polls are run in the timer thread so that gRPC can process " + "connection failures while there is no active polling thread. " + "They help reconnect disconnected client channels (mostly due to " + "idleness), so that the next RPC on this channel won't fail. Set to 0 to " + "turn off the backup polls."); static void init_globals() { gpr_mu_init(&g_poller_mu); diff --git a/src/core/ext/filters/client_channel/http_connect_handshaker.cc b/src/core/ext/filters/client_channel/http_connect_handshaker.cc index 90a79843458..95366b57386 100644 --- a/src/core/ext/filters/client_channel/http_connect_handshaker.cc +++ b/src/core/ext/filters/client_channel/http_connect_handshaker.cc @@ -31,7 +31,6 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker_registry.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/http/format_request.h" diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index f91adb09e52..92d64450ea4 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -32,12 +32,12 @@ #include "src/core/ext/filters/client_channel/http_connect_handshaker.h" #include "src/core/ext/filters/client_channel/lb_policy_registry.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" +#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/ext/filters/client_channel/service_config.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" @@ -447,8 +447,9 @@ static bool should_use_ares(const char* resolver_env) { #endif /* GRPC_UV */ void grpc_resolver_dns_ares_init() { - char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER"); - if (should_use_ares(resolver_env)) { + grpc_core::UniquePtr resolver = + GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); + if (should_use_ares(resolver.get())) { gpr_log(GPR_DEBUG, "Using ares dns resolver"); address_sorting_init(); grpc_error* error = grpc_ares_init(); @@ -464,16 +465,15 @@ void grpc_resolver_dns_ares_init() { grpc_core::UniquePtr( grpc_core::New())); } - gpr_free(resolver_env); } void grpc_resolver_dns_ares_shutdown() { - char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER"); - if (should_use_ares(resolver_env)) { + grpc_core::UniquePtr resolver = + GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); + if (should_use_ares(resolver.get())) { address_sorting_shutdown(); grpc_ares_cleanup(); } - gpr_free(resolver_env); } #else /* GRPC_ARES == 1 */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc b/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc new file mode 100644 index 00000000000..07a617c14d5 --- /dev/null +++ b/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc @@ -0,0 +1,28 @@ +// +// Copyright 2019 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// This is similar to the sockaddr resolver, except that it supports a +// bunch of query args that are useful for dependency injection in tests. + +#include + +#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" + +GPR_GLOBAL_CONFIG_DEFINE_STRING( + grpc_dns_resolver, "", + "Declares which DNS resolver to use. The default is ares if gRPC is built " + "with c-ares support. Otherwise, the value of this environment variable is " + "ignored.") diff --git a/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h b/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h new file mode 100644 index 00000000000..d0a3486ea38 --- /dev/null +++ b/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h @@ -0,0 +1,29 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_DNS_RESOLVER_SELECTION_H +#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_DNS_RESOLVER_SELECTION_H + +#include + +#include "src/core/lib/gprpp/global_config.h" + +GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_dns_resolver); + +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_DNS_RESOLVER_SELECTION_H \ + */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc index 164d308c0dd..5ab75d02793 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc @@ -26,11 +26,11 @@ #include #include +#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" @@ -274,8 +274,9 @@ class NativeDnsResolverFactory : public ResolverFactory { } // namespace grpc_core void grpc_resolver_dns_native_init() { - char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER"); - if (resolver_env != nullptr && gpr_stricmp(resolver_env, "native") == 0) { + grpc_core::UniquePtr resolver = + GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); + if (gpr_stricmp(resolver.get(), "native") == 0) { gpr_log(GPR_DEBUG, "Using native dns resolver"); grpc_core::ResolverRegistry::Builder::RegisterResolverFactory( grpc_core::UniquePtr( @@ -291,7 +292,6 @@ void grpc_resolver_dns_native_init() { grpc_core::New())); } } - gpr_free(resolver_env); } void grpc_resolver_dns_native_shutdown() {} diff --git a/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc b/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc index 4c929d00ec9..ac13d73d3b5 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc @@ -23,8 +23,11 @@ #include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/transport/metadata.h" -GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_experimental_disable_flow_control, false, - "Disable flow control"); +GPR_GLOBAL_CONFIG_DEFINE_BOOL( + grpc_experimental_disable_flow_control, false, + "If set, flow control will be effectively disabled. Max out all values and " + "assume the remote peer does the same. Thus we can ignore any flow control " + "bookkeeping, error checking, and decision making"); void grpc_chttp2_plugin_init(void) { g_flow_control_enabled = diff --git a/src/core/lib/debug/trace.cc b/src/core/lib/debug/trace.cc index cafdb15c699..84c0a3805d3 100644 --- a/src/core/lib/debug/trace.cc +++ b/src/core/lib/debug/trace.cc @@ -26,7 +26,11 @@ #include #include #include -#include "src/core/lib/gpr/env.h" + +GPR_GLOBAL_CONFIG_DEFINE_STRING( + grpc_trace, "", + "A comma separated list of tracers that provide additional insight into " + "how gRPC C core is processing requests via debug logs."); int grpc_tracer_set_enabled(const char* name, int enabled); @@ -133,12 +137,14 @@ static void parse(const char* s) { gpr_free(strings); } -void grpc_tracer_init(const char* env_var) { - char* e = gpr_getenv(env_var); - if (e != nullptr) { - parse(e); - gpr_free(e); - } +void grpc_tracer_init(const char* env_var_name) { + (void)env_var_name; // suppress unused variable error + grpc_tracer_init(); +} + +void grpc_tracer_init() { + grpc_core::UniquePtr value = GPR_GLOBAL_CONFIG_GET(grpc_trace); + parse(value.get()); } void grpc_tracer_shutdown(void) {} diff --git a/src/core/lib/debug/trace.h b/src/core/lib/debug/trace.h index 72e1a4eded7..6a4a8031ec4 100644 --- a/src/core/lib/debug/trace.h +++ b/src/core/lib/debug/trace.h @@ -24,7 +24,15 @@ #include #include +#include "src/core/lib/gprpp/global_config.h" + +GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_trace); + +// TODO(veblush): Remove this deprecated function once codes depending on this +// function are updated in the internal repo. void grpc_tracer_init(const char* env_var_name); + +void grpc_tracer_init(); void grpc_tracer_shutdown(void); #if defined(__has_feature) diff --git a/src/core/lib/gpr/env.h b/src/core/lib/gpr/env.h index 5956d17fcfe..11db17c83da 100644 --- a/src/core/lib/gpr/env.h +++ b/src/core/lib/gpr/env.h @@ -34,12 +34,6 @@ char* gpr_getenv(const char* name); /* Sets the environment with the specified name to the specified value. */ void gpr_setenv(const char* name, const char* value); -/* This is a version of gpr_getenv that does not produce any output if it has to - use an insecure version of the function. It is ONLY to be used to solve the - problem in which we need to check an env variable to configure the verbosity - level of logging. So DO NOT USE THIS. */ -const char* gpr_getenv_silent(const char* name, char** dst); - /* Deletes the variable name from the environment. */ void gpr_unsetenv(const char* name); diff --git a/src/core/lib/gpr/env_linux.cc b/src/core/lib/gpr/env_linux.cc index e84a9f6064c..3a3aa541672 100644 --- a/src/core/lib/gpr/env_linux.cc +++ b/src/core/lib/gpr/env_linux.cc @@ -38,7 +38,7 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" -const char* gpr_getenv_silent(const char* name, char** dst) { +static const char* gpr_getenv_silent(const char* name, char** dst) { const char* insecure_func_used = nullptr; char* result = nullptr; #if defined(GPR_BACKWARDS_COMPATIBILITY_MODE) diff --git a/src/core/lib/gpr/env_windows.cc b/src/core/lib/gpr/env_windows.cc index 72850a9587d..76c45fb87a7 100644 --- a/src/core/lib/gpr/env_windows.cc +++ b/src/core/lib/gpr/env_windows.cc @@ -30,11 +30,6 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/string_windows.h" -const char* gpr_getenv_silent(const char* name, char** dst) { - *dst = gpr_getenv(name); - return NULL; -} - char* gpr_getenv(const char* name) { char* result = NULL; DWORD size; diff --git a/src/core/lib/gpr/log.cc b/src/core/lib/gpr/log.cc index 01ef112fb31..8a229b2adf1 100644 --- a/src/core/lib/gpr/log.cc +++ b/src/core/lib/gpr/log.cc @@ -22,12 +22,15 @@ #include #include -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/global_config.h" #include #include +GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_verbosity, "ERROR", + "Default gRPC logging verbosity") + void gpr_default_log(gpr_log_func_args* args); static gpr_atm g_log_func = (gpr_atm)gpr_default_log; static gpr_atm g_min_severity_to_print = GPR_LOG_VERBOSITY_UNSET; @@ -72,29 +75,22 @@ void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print) { } void gpr_log_verbosity_init() { - char* verbosity = nullptr; - const char* insecure_getenv = gpr_getenv_silent("GRPC_VERBOSITY", &verbosity); + grpc_core::UniquePtr verbosity = GPR_GLOBAL_CONFIG_GET(grpc_verbosity); gpr_atm min_severity_to_print = GPR_LOG_SEVERITY_ERROR; - if (verbosity != nullptr) { - if (gpr_stricmp(verbosity, "DEBUG") == 0) { + if (strlen(verbosity.get()) > 0) { + if (gpr_stricmp(verbosity.get(), "DEBUG") == 0) { min_severity_to_print = static_cast(GPR_LOG_SEVERITY_DEBUG); - } else if (gpr_stricmp(verbosity, "INFO") == 0) { + } else if (gpr_stricmp(verbosity.get(), "INFO") == 0) { min_severity_to_print = static_cast(GPR_LOG_SEVERITY_INFO); - } else if (gpr_stricmp(verbosity, "ERROR") == 0) { + } else if (gpr_stricmp(verbosity.get(), "ERROR") == 0) { min_severity_to_print = static_cast(GPR_LOG_SEVERITY_ERROR); } - gpr_free(verbosity); } if ((gpr_atm_no_barrier_load(&g_min_severity_to_print)) == GPR_LOG_VERBOSITY_UNSET) { gpr_atm_no_barrier_store(&g_min_severity_to_print, min_severity_to_print); } - - if (insecure_getenv != nullptr) { - gpr_log(GPR_DEBUG, "Warning: insecure environment read function '%s' used", - insecure_getenv); - } } void gpr_set_log_function(gpr_log_func f) { diff --git a/src/core/lib/gprpp/fork.cc b/src/core/lib/gprpp/fork.cc index c4b1cbc2233..cacf5e82e5a 100644 --- a/src/core/lib/gprpp/fork.cc +++ b/src/core/lib/gprpp/fork.cc @@ -26,8 +26,8 @@ #include #include -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/memory.h" /* @@ -35,6 +35,16 @@ * AROUND VERY SPECIFIC USE CASES. */ +#ifdef GRPC_ENABLE_FORK_SUPPORT +#define GRPC_ENABLE_FORK_SUPPORT_DEFAULT true +#else +#define GRPC_ENABLE_FORK_SUPPORT_DEFAULT false +#endif // GRPC_ENABLE_FORK_SUPPORT + +GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_enable_fork_support, + GRPC_ENABLE_FORK_SUPPORT_DEFAULT, + "Enable folk support"); + namespace grpc_core { namespace internal { // The exec_ctx_count has 2 modes, blocked and unblocked. @@ -158,34 +168,7 @@ class ThreadState { void Fork::GlobalInit() { if (!override_enabled_) { -#ifdef GRPC_ENABLE_FORK_SUPPORT - support_enabled_ = true; -#endif - bool env_var_set = false; - char* env = gpr_getenv("GRPC_ENABLE_FORK_SUPPORT"); - if (env != nullptr) { - static const char* truthy[] = {"yes", "Yes", "YES", "true", - "True", "TRUE", "1"}; - static const char* falsey[] = {"no", "No", "NO", "false", - "False", "FALSE", "0"}; - for (size_t i = 0; i < GPR_ARRAY_SIZE(truthy); i++) { - if (0 == strcmp(env, truthy[i])) { - support_enabled_ = true; - env_var_set = true; - break; - } - } - if (!env_var_set) { - for (size_t i = 0; i < GPR_ARRAY_SIZE(falsey); i++) { - if (0 == strcmp(env, falsey[i])) { - support_enabled_ = false; - env_var_set = true; - break; - } - } - } - gpr_free(env); - } + support_enabled_ = GPR_GLOBAL_CONFIG_GET(grpc_enable_fork_support); } if (support_enabled_) { exec_ctx_state_ = grpc_core::New(); diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc index 47cf5b83b17..ddafb7b5539 100644 --- a/src/core/lib/iomgr/ev_posix.cc +++ b/src/core/lib/iomgr/ev_posix.cc @@ -31,13 +31,19 @@ #include #include "src/core/lib/debug/trace.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/iomgr/ev_epoll1_linux.h" #include "src/core/lib/iomgr/ev_epollex_linux.h" #include "src/core/lib/iomgr/ev_poll_posix.h" #include "src/core/lib/iomgr/internal_errqueue.h" +GPR_GLOBAL_CONFIG_DEFINE_STRING( + grpc_poll_strategy, "all", + "Declares which polling engines to try when starting gRPC. " + "This is a comma-separated list of engines, which are tried in priority " + "order first -> last.") + grpc_core::TraceFlag grpc_polling_trace(false, "polling"); /* Disabled by default */ @@ -46,16 +52,15 @@ grpc_core::TraceFlag grpc_fd_trace(false, "fd_trace"); grpc_core::DebugOnlyTraceFlag grpc_trace_fd_refcount(false, "fd_refcount"); grpc_core::DebugOnlyTraceFlag grpc_polling_api_trace(false, "polling_api"); -#ifndef NDEBUG - // Polling API trace only enabled in debug builds +#ifndef NDEBUG #define GRPC_POLLING_API_TRACE(format, ...) \ if (GRPC_TRACE_FLAG_ENABLED(grpc_polling_api_trace)) { \ gpr_log(GPR_INFO, "(polling-api) " format, __VA_ARGS__); \ } #else #define GRPC_POLLING_API_TRACE(...) -#endif +#endif // NDEBUG /** Default poll() function - a pointer so that it can be overridden by some * tests */ @@ -66,7 +71,7 @@ int aix_poll(struct pollfd fds[], nfds_t nfds, int timeout) { return poll(fds, nfds, timeout); } grpc_poll_function_type grpc_poll_function = aix_poll; -#endif +#endif // GPR_AIX grpc_wakeup_fd grpc_global_wakeup_fd; @@ -205,14 +210,11 @@ void grpc_register_event_engine_factory(const char* name, const char* grpc_get_poll_strategy_name() { return g_poll_strategy_name; } void grpc_event_engine_init(void) { - char* s = gpr_getenv("GRPC_POLL_STRATEGY"); - if (s == nullptr) { - s = gpr_strdup("all"); - } + grpc_core::UniquePtr value = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); char** strings = nullptr; size_t nstrings = 0; - split(s, &strings, &nstrings); + split(value.get(), &strings, &nstrings); for (size_t i = 0; g_event_engine == nullptr && i < nstrings; i++) { try_engine(strings[i]); @@ -224,10 +226,10 @@ void grpc_event_engine_init(void) { gpr_free(strings); if (g_event_engine == nullptr) { - gpr_log(GPR_ERROR, "No event engine could be initialized from %s", s); + gpr_log(GPR_ERROR, "No event engine could be initialized from %s", + value.get()); abort(); } - gpr_free(s); } void grpc_event_engine_shutdown(void) { diff --git a/src/core/lib/iomgr/ev_posix.h b/src/core/lib/iomgr/ev_posix.h index 0ca3a6f82fd..30bb5e40faf 100644 --- a/src/core/lib/iomgr/ev_posix.h +++ b/src/core/lib/iomgr/ev_posix.h @@ -24,11 +24,14 @@ #include #include "src/core/lib/debug/trace.h" +#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/iomgr/pollset_set.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" +GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_poll_strategy); + extern grpc_core::TraceFlag grpc_fd_trace; /* Disabled by default */ extern grpc_core::TraceFlag grpc_polling_trace; /* Disabled by default */ diff --git a/src/core/lib/iomgr/fork_posix.cc b/src/core/lib/iomgr/fork_posix.cc index 7f8fb7e828b..629b08162fb 100644 --- a/src/core/lib/iomgr/fork_posix.cc +++ b/src/core/lib/iomgr/fork_posix.cc @@ -28,7 +28,6 @@ #include #include -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gprpp/fork.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/ev_posix.h" diff --git a/src/core/lib/iomgr/iomgr.cc b/src/core/lib/iomgr/iomgr.cc index fd011788a06..b86aa6f2d76 100644 --- a/src/core/lib/iomgr/iomgr.cc +++ b/src/core/lib/iomgr/iomgr.cc @@ -42,7 +42,8 @@ #include "src/core/lib/iomgr/timer_manager.h" GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_abort_on_leaks, false, - "Abort when leak is found"); + "A debugging aid to cause a call to abort() when " + "gRPC objects are leaked past grpc_shutdown()"); static gpr_mu g_mu; static gpr_cv g_rcv; diff --git a/src/core/lib/profiling/basic_timers.cc b/src/core/lib/profiling/basic_timers.cc index b19ad9fc23d..37689fe89d1 100644 --- a/src/core/lib/profiling/basic_timers.cc +++ b/src/core/lib/profiling/basic_timers.cc @@ -31,7 +31,8 @@ #include #include -#include "src/core/lib/gpr/env.h" +#include "src/core/lib/gprpp/global_config.h" +#include "src/core/lib/profiling/timers.h" typedef enum { BEGIN = '{', END = '}', MARK = '.' } marker_type; @@ -74,11 +75,16 @@ static __thread int g_thread_id; static int g_next_thread_id; static int g_writing_enabled = 1; +GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_latency_trace, "latency_trace.txt", + "Output file name for latency trace") + static const char* output_filename() { if (output_filename_or_null == NULL) { - output_filename_or_null = gpr_getenv("LATENCY_TRACE"); - if (output_filename_or_null == NULL || - strlen(output_filename_or_null) == 0) { + grpc_core::UniquePtr value = + GPR_GLOBAL_CONFIG_GET(grpc_latency_trace); + if (strlen(value.get()) > 0) { + output_filename_or_null = value.release(); + } else { output_filename_or_null = "latency_trace.txt"; } } diff --git a/src/core/lib/security/security_connector/load_system_roots_linux.cc b/src/core/lib/security/security_connector/load_system_roots_linux.cc index 924fa8a3e26..82d5bf6bcdd 100644 --- a/src/core/lib/security/security_connector/load_system_roots_linux.cc +++ b/src/core/lib/security/security_connector/load_system_roots_linux.cc @@ -38,12 +38,15 @@ #include #include -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/iomgr/load_file.h" +GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_system_ssl_roots_dir, "", + "Custom directory to SSL Roots"); + namespace grpc_core { namespace { @@ -139,10 +142,9 @@ grpc_slice CreateRootCertsBundle(const char* certs_directory) { grpc_slice LoadSystemRootCerts() { grpc_slice result = grpc_empty_slice(); // Prioritize user-specified custom directory if flag is set. - char* custom_dir = gpr_getenv("GRPC_SYSTEM_SSL_ROOTS_DIR"); - if (custom_dir != nullptr) { - result = CreateRootCertsBundle(custom_dir); - gpr_free(custom_dir); + UniquePtr custom_dir = GPR_GLOBAL_CONFIG_GET(grpc_system_ssl_roots_dir); + if (strlen(custom_dir.get()) > 0) { + result = CreateRootCertsBundle(custom_dir.get()); } // If the custom directory is empty/invalid/not specified, fallback to // distribution-specific directory. diff --git a/src/core/lib/security/security_connector/security_connector.cc b/src/core/lib/security/security_connector/security_connector.cc index 96a19605466..47c0ad5aa3d 100644 --- a/src/core/lib/security/security_connector/security_connector.cc +++ b/src/core/lib/security/security_connector/security_connector.cc @@ -28,7 +28,6 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/load_file.h" diff --git a/src/core/lib/security/security_connector/ssl_utils.cc b/src/core/lib/security/security_connector/ssl_utils.cc index 1eefff6fe24..cb0d5437988 100644 --- a/src/core/lib/security/security_connector/ssl_utils.cc +++ b/src/core/lib/security/security_connector/ssl_utils.cc @@ -27,7 +27,6 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/global_config.h" @@ -46,7 +45,13 @@ static const char* installed_roots_path = INSTALL_PREFIX "/share/grpc/roots.pem"; #endif -/** Environment variable used as a flag to enable/disable loading system root +/** Config variable that points to the default SSL roots file. This file + must be a PEM encoded file with all the roots such as the one that can be + downloaded from https://pki.google.com/roots.pem. */ +GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_default_ssl_roots_file_path, "", + "Path to the default SSL roots file."); + +/** Config variable used as a flag to enable/disable loading system root certificates from the OS trust store. */ GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_not_use_system_ssl_roots, false, "Disable loading system root certificates."); @@ -65,20 +70,22 @@ void grpc_set_ssl_roots_override_callback(grpc_ssl_roots_override_callback cb) { /* -- Cipher suites. -- */ -/* Defines the cipher suites that we accept by default. All these cipher suites - are compliant with HTTP2. */ -#define GRPC_SSL_CIPHER_SUITES \ - "ECDHE-ECDSA-AES128-GCM-SHA256:" \ - "ECDHE-ECDSA-AES256-GCM-SHA384:" \ - "ECDHE-RSA-AES128-GCM-SHA256:" \ - "ECDHE-RSA-AES256-GCM-SHA384" - static gpr_once cipher_suites_once = GPR_ONCE_INIT; static const char* cipher_suites = nullptr; +// All cipher suites for default are compliant with HTTP2. +GPR_GLOBAL_CONFIG_DEFINE_STRING( + grpc_ssl_cipher_suites, + "ECDHE-ECDSA-AES128-GCM-SHA256:" + "ECDHE-ECDSA-AES256-GCM-SHA384:" + "ECDHE-RSA-AES128-GCM-SHA256:" + "ECDHE-RSA-AES256-GCM-SHA384", + "A colon separated list of cipher suites to use with OpenSSL") + static void init_cipher_suites(void) { - char* overridden = gpr_getenv("GRPC_SSL_CIPHER_SUITES"); - cipher_suites = overridden != nullptr ? overridden : GRPC_SSL_CIPHER_SUITES; + grpc_core::UniquePtr value = + GPR_GLOBAL_CONFIG_GET(grpc_ssl_cipher_suites); + cipher_suites = value.release(); } /* --- Util --- */ @@ -430,13 +437,12 @@ grpc_slice DefaultSslRootStore::ComputePemRootCerts() { grpc_slice result = grpc_empty_slice(); const bool not_use_system_roots = GPR_GLOBAL_CONFIG_GET(grpc_not_use_system_ssl_roots); - // First try to load the roots from the environment. - char* default_root_certs_path = - gpr_getenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR); - if (default_root_certs_path != nullptr) { - GRPC_LOG_IF_ERROR("load_file", - grpc_load_file(default_root_certs_path, 1, &result)); - gpr_free(default_root_certs_path); + // First try to load the roots from the configuration. + UniquePtr default_root_certs_path = + GPR_GLOBAL_CONFIG_GET(grpc_default_ssl_roots_file_path); + if (strlen(default_root_certs_path.get()) > 0) { + GRPC_LOG_IF_ERROR( + "load_file", grpc_load_file(default_root_certs_path.get(), 1, &result)); } // Try overridden roots if needed. grpc_ssl_roots_override_result ovrd_res = GRPC_SSL_ROOTS_OVERRIDE_FAIL; diff --git a/src/core/lib/security/security_connector/ssl_utils.h b/src/core/lib/security/security_connector/ssl_utils.h index 080e277f944..1765a344c2a 100644 --- a/src/core/lib/security/security_connector/ssl_utils.h +++ b/src/core/lib/security/security_connector/ssl_utils.h @@ -26,6 +26,7 @@ #include #include +#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/security/security_connector/security_connector.h" @@ -33,7 +34,10 @@ #include "src/core/tsi/transport_security.h" #include "src/core/tsi/transport_security_interface.h" -/* --- Util. --- */ +GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_default_ssl_roots_file_path); +GPR_GLOBAL_CONFIG_DECLARE_BOOL(grpc_not_use_system_ssl_roots); + +/* --- Util --- */ /* --- URL schemes. --- */ #define GRPC_SSL_URL_SCHEME "https" diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index 1ed1a66b184..2a6d307ddab 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -154,7 +154,7 @@ void grpc_init(void) { * at the appropriate time */ grpc_register_security_filters(); register_builtin_channel_init(); - grpc_tracer_init("GRPC_TRACE"); + grpc_tracer_init(); /* no more changes to channel init pipelines */ grpc_channel_init_finalize(); grpc_iomgr_start(); diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m index 7557367ed4a..e6522d7a27e 100644 --- a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m @@ -61,8 +61,7 @@ NSBundle *resourceBundle = [NSBundle bundleWithURL:[[bundle resourceURL] URLByAppendingPathComponent:resourceBundlePath]]; NSString *path = [resourceBundle pathForResource:rootsPEM ofType:@"pem"]; - setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, - [path cStringUsingEncoding:NSUTF8StringEncoding], 1); + setenv("GRPC_DEFAULT_SSL_ROOTS_FILE_PATH", [path cStringUsingEncoding:NSUTF8StringEncoding], 1); }); NSData *rootsASCII = nil; diff --git a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm index 2fac1be3d0e..0d081e4a410 100644 --- a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm +++ b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm @@ -37,11 +37,11 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -172,7 +172,7 @@ static char *roots_filename; GPR_ASSERT(roots_file != NULL); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); grpc_init(); diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 97c9f2f7c94..61524eb7fc9 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -386,6 +386,7 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', + 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/census/grpc_context.cc', diff --git a/test/core/bad_connection/close_fd_test.cc b/test/core/bad_connection/close_fd_test.cc index e8f297e77ea..78a1a5cc9a4 100644 --- a/test/core/bad_connection/close_fd_test.cc +++ b/test/core/bad_connection/close_fd_test.cc @@ -39,7 +39,6 @@ #include #include #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/endpoint_pair.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/completion_queue.h" diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc index 73d251eff4a..8dd55f64944 100644 --- a/test/core/bad_ssl/bad_ssl_test.cc +++ b/test/core/bad_ssl/bad_ssl_test.cc @@ -25,9 +25,9 @@ #include #include -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" @@ -133,7 +133,7 @@ int main(int argc, char** argv) { strcpy(root, "."); } if (argc == 2) { - gpr_setenv("GRPC_DEFAULT_SSL_ROOTS_FILE_PATH", argv[1]); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, argv[1]); } /* figure out our test name */ tmp = lunder - 1; diff --git a/test/core/client_channel/resolvers/dns_resolver_test.cc b/test/core/client_channel/resolvers/dns_resolver_test.cc index ed3b4e66472..129866b7d7f 100644 --- a/test/core/client_channel/resolvers/dns_resolver_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_test.cc @@ -21,8 +21,8 @@ #include #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" +#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/combiner.h" #include "test/core/util/test_config.h" @@ -78,13 +78,13 @@ int main(int argc, char** argv) { test_succeeds(dns, "dns:10.2.1.1:1234"); test_succeeds(dns, "dns:www.google.com"); test_succeeds(dns, "dns:///www.google.com"); - char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER"); - if (resolver_env != nullptr && gpr_stricmp(resolver_env, "native") == 0) { + grpc_core::UniquePtr resolver = + GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); + if (gpr_stricmp(resolver.get(), "native") == 0) { test_fails(dns, "dns://8.8.8.8/8.8.8.8:8888"); } else { test_succeeds(dns, "dns://8.8.8.8/8.8.8.8:8888"); } - gpr_free(resolver_env); { grpc_core::ExecCtx exec_ctx; GRPC_COMBINER_UNREF(g_combiner, "test"); diff --git a/test/core/end2end/fixtures/h2_full+trace.cc b/test/core/end2end/fixtures/h2_full+trace.cc index ce8f6bf13a5..b8dbe261183 100644 --- a/test/core/end2end/fixtures/h2_full+trace.cc +++ b/test/core/end2end/fixtures/h2_full+trace.cc @@ -33,7 +33,7 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/env.h" +#include "src/core/lib/debug/trace.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" @@ -105,7 +105,7 @@ int main(int argc, char** argv) { /* force tracing on, with a value to force many code paths in trace.c to be taken */ - gpr_setenv("GRPC_TRACE", "doesnt-exist,http,all"); + GPR_GLOBAL_CONFIG_SET(grpc_trace, "doesnt-exist,http,all"); #ifdef GRPC_POSIX_SOCKET g_fixture_slowdown_factor = isatty(STDOUT_FILENO) ? 10 : 1; diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.cc b/test/core/end2end/fixtures/h2_sockpair+trace.cc index 4494d5c4746..7954bc1ddfc 100644 --- a/test/core/end2end/fixtures/h2_sockpair+trace.cc +++ b/test/core/end2end/fixtures/h2_sockpair+trace.cc @@ -35,7 +35,7 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/env.h" +#include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/endpoint_pair.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/surface/channel.h" @@ -133,7 +133,8 @@ int main(int argc, char** argv) { /* force tracing on, with a value to force many code paths in trace.c to be taken */ - gpr_setenv("GRPC_TRACE", "doesnt-exist,http,all"); + GPR_GLOBAL_CONFIG_SET(grpc_trace, "doesnt-exist,http,all"); + #ifdef GRPC_POSIX_SOCKET g_fixture_slowdown_factor = isatty(STDOUT_FILENO) ? 10 : 1; #else diff --git a/test/core/end2end/fixtures/h2_spiffe.cc b/test/core/end2end/fixtures/h2_spiffe.cc index 9ab796ea429..cdf091bac10 100644 --- a/test/core/end2end/fixtures/h2_spiffe.cc +++ b/test/core/end2end/fixtures/h2_spiffe.cc @@ -35,6 +35,7 @@ #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h" +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -277,7 +278,7 @@ int main(int argc, char** argv) { GPR_ASSERT(roots_file != nullptr); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); grpc_init(); for (size_t ind = 0; ind < sizeof(configs) / sizeof(*configs); ind++) { grpc_end2end_tests(argc, argv, configs[ind]); diff --git a/test/core/end2end/fixtures/h2_ssl.cc b/test/core/end2end/fixtures/h2_ssl.cc index 1fcd785e251..3fc9bc7f329 100644 --- a/test/core/end2end/fixtures/h2_ssl.cc +++ b/test/core/end2end/fixtures/h2_ssl.cc @@ -25,11 +25,11 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -167,7 +167,7 @@ int main(int argc, char** argv) { GPR_ASSERT(roots_file != nullptr); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); grpc_init(); diff --git a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc index 04d876ce3cd..1d54a431364 100644 --- a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc +++ b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc @@ -25,11 +25,11 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -190,7 +190,7 @@ int main(int argc, char** argv) { GPR_ASSERT(roots_file != nullptr); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); grpc_init(); diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.cc b/test/core/end2end/fixtures/h2_ssl_proxy.cc index f1858079426..d5f695b1575 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.cc +++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc @@ -25,11 +25,11 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/end2end/fixtures/proxy.h" #include "test/core/util/port.h" @@ -208,7 +208,7 @@ int main(int argc, char** argv) { GPR_ASSERT(roots_file != nullptr); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); grpc_init(); diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc index cb0800bf899..e9285778a2d 100644 --- a/test/core/end2end/h2_ssl_cert_test.cc +++ b/test/core/end2end/h2_ssl_cert_test.cc @@ -25,11 +25,11 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" @@ -366,7 +366,7 @@ int main(int argc, char** argv) { GPR_ASSERT(roots_file != nullptr); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); grpc_init(); ::testing::InitGoogleTest(&argc, argv); diff --git a/test/core/end2end/h2_ssl_session_reuse_test.cc b/test/core/end2end/h2_ssl_session_reuse_test.cc index fbcdcc4b3f3..b2d0a5e1133 100644 --- a/test/core/end2end/h2_ssl_session_reuse_test.cc +++ b/test/core/end2end/h2_ssl_session_reuse_test.cc @@ -25,11 +25,11 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" @@ -265,7 +265,7 @@ int main(int argc, char** argv) { GPR_ASSERT(roots_file != nullptr); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); grpc_init(); ::testing::InitGoogleTest(&argc, argv); diff --git a/test/core/end2end/tests/keepalive_timeout.cc b/test/core/end2end/tests/keepalive_timeout.cc index 3c33f0419ad..1750f6fe5ee 100644 --- a/test/core/end2end/tests/keepalive_timeout.cc +++ b/test/core/end2end/tests/keepalive_timeout.cc @@ -28,11 +28,15 @@ #include "src/core/ext/transport/chttp2/transport/frame_ping.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/iomgr.h" #include "test/core/end2end/cq_verifier.h" +#ifdef GRPC_POSIX_SOCKET +#include "src/core/lib/iomgr/ev_posix.h" +#endif // GRPC_POSIX_SOCKET + static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -225,13 +229,13 @@ static void test_keepalive_timeout(grpc_end2end_test_config config) { * 200ms. In the success case, each ping ack should reset the keepalive timer so * that the keepalive ping is never sent. */ static void test_read_delays_keepalive(grpc_end2end_test_config config) { - char* poller = gpr_getenv("GRPC_POLL_STRATEGY"); +#ifdef GRPC_POSIX_SOCKET + grpc_core::UniquePtr poller = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); /* It is hard to get the timing right for the polling engine poll. */ - if (poller != nullptr && (0 == strcmp(poller, "poll"))) { - gpr_free(poller); + if ((0 == strcmp(poller.get(), "poll"))) { return; } - gpr_free(poller); +#endif // GRPC_POSIX_SOCKET const int kPingIntervalMS = 100; grpc_arg keepalive_arg_elems[3]; keepalive_arg_elems[0].type = GRPC_ARG_INTEGER; diff --git a/test/core/gpr/log_test.cc b/test/core/gpr/log_test.cc index f96257738b2..e320daa33a7 100644 --- a/test/core/gpr/log_test.cc +++ b/test/core/gpr/log_test.cc @@ -21,9 +21,14 @@ #include #include -#include "src/core/lib/gpr/env.h" +#include "src/core/lib/gprpp/global_config.h" #include "test/core/util/test_config.h" +// Config declaration is supposed to be located at log.h but +// log.h doesn't include global_config headers because it has to +// be a strict C so declaration statement gets to be here. +GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_verbosity); + static bool log_func_reached = false; static void test_callback(gpr_log_func_args* args) { @@ -67,7 +72,7 @@ int main(int argc, char** argv) { /* gpr_log_verbosity_init() will be effective only once, and only before * gpr_set_log_verbosity() is called */ - gpr_setenv("GRPC_VERBOSITY", "ERROR"); + GPR_GLOBAL_CONFIG_SET(grpc_verbosity, "ERROR"); gpr_log_verbosity_init(); test_log_function_reached(GPR_ERROR); @@ -75,7 +80,7 @@ int main(int argc, char** argv) { test_log_function_unreached(GPR_DEBUG); /* gpr_log_verbosity_init() should not be effective */ - gpr_setenv("GRPC_VERBOSITY", "DEBUG"); + GPR_GLOBAL_CONFIG_SET(grpc_verbosity, "DEBUG"); gpr_log_verbosity_init(); test_log_function_reached(GPR_ERROR); test_log_function_unreached(GPR_INFO); @@ -97,7 +102,7 @@ int main(int argc, char** argv) { test_log_function_unreached(GPR_DEBUG); /* gpr_log_verbosity_init() should not be effective */ - gpr_setenv("GRPC_VERBOSITY", "DEBUG"); + GPR_GLOBAL_CONFIG_SET(grpc_verbosity, "DEBUG"); gpr_log_verbosity_init(); test_log_function_reached(GPR_ERROR); test_log_function_unreached(GPR_INFO); diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc index 326b0e95e25..e7250c206d8 100644 --- a/test/core/http/httpscli_test.cc +++ b/test/core/http/httpscli_test.cc @@ -29,6 +29,7 @@ #include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/iomgr.h" +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" #include "test/core/util/test_config.h" @@ -184,7 +185,7 @@ int main(int argc, char** argv) { /* Set the environment variable for the SSL certificate file */ char* pem_file; gpr_asprintf(&pem_file, "%s/src/core/tsi/test_creds/ca.pem", root); - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, pem_file); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, pem_file); gpr_free(pem_file); /* start the server */ diff --git a/test/core/iomgr/resolve_address_posix_test.cc b/test/core/iomgr/resolve_address_posix_test.cc index 826c7e1fafa..112d7c2791b 100644 --- a/test/core/iomgr/resolve_address_posix_test.cc +++ b/test/core/iomgr/resolve_address_posix_test.cc @@ -29,6 +29,7 @@ #include #include +#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" @@ -224,15 +225,16 @@ int main(int argc, char** argv) { // --resolver will always be the first one, so only parse the first argument // (other arguments may be unknown to cl) gpr_cmdline_parse(cl, argc > 2 ? 2 : argc, argv); - const char* cur_resolver = gpr_getenv("GRPC_DNS_RESOLVER"); - if (cur_resolver != nullptr && strlen(cur_resolver) != 0) { + grpc_core::UniquePtr resolver = + GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); + if (strlen(resolver.get()) != 0) { gpr_log(GPR_INFO, "Warning: overriding resolver setting of %s", - cur_resolver); + resolver.get()); } if (gpr_stricmp(resolver_type, "native") == 0) { - gpr_setenv("GRPC_DNS_RESOLVER", "native"); + GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "native"); } else if (gpr_stricmp(resolver_type, "ares") == 0) { - gpr_setenv("GRPC_DNS_RESOLVER", "ares"); + GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "ares"); } else { gpr_log(GPR_ERROR, "--resolver_type was not set to ares or native"); abort(); @@ -246,12 +248,12 @@ int main(int argc, char** argv) { // c-ares resolver doesn't support UDS (ability for native DNS resolver // to handle this is only expected to be used by servers, which // unconditionally use the native DNS resolver). - char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER"); - if (resolver_env == nullptr || gpr_stricmp(resolver_env, "native") == 0) { + grpc_core::UniquePtr resolver = + GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); + if (gpr_stricmp(resolver.get(), "native") == 0) { test_unix_socket(); test_unix_socket_path_name_too_long(); } - gpr_free(resolver_env); } gpr_cmdline_destroy(cl); diff --git a/test/core/iomgr/resolve_address_test.cc b/test/core/iomgr/resolve_address_test.cc index 1f0c0e3e835..cbc03485d7f 100644 --- a/test/core/iomgr/resolve_address_test.cc +++ b/test/core/iomgr/resolve_address_test.cc @@ -27,7 +27,7 @@ #include -#include "src/core/lib/gpr/env.h" +#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr.h" @@ -347,16 +347,17 @@ int main(int argc, char** argv) { // --resolver will always be the first one, so only parse the first argument // (other arguments may be unknown to cl) gpr_cmdline_parse(cl, argc > 2 ? 2 : argc, argv); - const char* cur_resolver = gpr_getenv("GRPC_DNS_RESOLVER"); - if (cur_resolver != nullptr && strlen(cur_resolver) != 0) { + grpc_core::UniquePtr resolver = + GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); + if (strlen(resolver.get()) != 0) { gpr_log(GPR_INFO, "Warning: overriding resolver setting of %s", - cur_resolver); + resolver.get()); } if (gpr_stricmp(resolver_type, "native") == 0) { - gpr_setenv("GRPC_DNS_RESOLVER", "native"); + GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "native"); } else if (gpr_stricmp(resolver_type, "ares") == 0) { #ifndef GRPC_UV - gpr_setenv("GRPC_DNS_RESOLVER", "ares"); + GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "ares"); #endif } else { gpr_log(GPR_ERROR, "--resolver_type was not set to ares or native"); diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc index 11cfc8cc905..141346bca94 100644 --- a/test/core/security/credentials_test.cc +++ b/test/core/security/credentials_test.cc @@ -1161,7 +1161,7 @@ static void test_get_well_known_google_credentials_file_path(void) { GPR_ASSERT(path != nullptr); gpr_free(path); #if defined(GPR_POSIX_ENV) || defined(GPR_LINUX_ENV) - unsetenv("HOME"); + gpr_unsetenv("HOME"); path = grpc_get_well_known_google_credentials_file_path(); GPR_ASSERT(path == nullptr); gpr_setenv("HOME", home); diff --git a/test/core/security/security_connector_test.cc b/test/core/security/security_connector_test.cc index 496f064439c..c888c90c646 100644 --- a/test/core/security/security_connector_test.cc +++ b/test/core/security/security_connector_test.cc @@ -24,7 +24,6 @@ #include #include -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" @@ -394,7 +393,7 @@ static void test_default_ssl_roots(void) { /* First let's get the root through the override: set the env to an invalid value. */ - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, ""); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, ""); grpc_set_ssl_roots_override_callback(override_roots_success); grpc_slice roots = grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting(); @@ -405,7 +404,8 @@ static void test_default_ssl_roots(void) { /* Now let's set the env var: We should get the contents pointed value instead. */ - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_env_var_file_path); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, + roots_env_var_file_path); roots = grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting(); roots_contents = grpc_slice_to_c_string(roots); grpc_slice_unref(roots); @@ -414,7 +414,7 @@ static void test_default_ssl_roots(void) { /* Now reset the env var. We should fall back to the value overridden using the api. */ - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, ""); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, ""); roots = grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting(); roots_contents = grpc_slice_to_c_string(roots); grpc_slice_unref(roots); @@ -423,7 +423,7 @@ static void test_default_ssl_roots(void) { /* Now setup a permanent failure for the overridden roots and we should get an empty slice. */ - gpr_setenv("GRPC_NOT_USE_SYSTEM_SSL_ROOTS", "true"); + GPR_GLOBAL_CONFIG_SET(grpc_not_use_system_ssl_roots, true); grpc_set_ssl_roots_override_callback(override_roots_permanent_failure); roots = grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting(); GPR_ASSERT(GRPC_SLICE_IS_EMPTY(roots)); diff --git a/test/core/util/test_config.cc b/test/core/util/test_config.cc index 476e424b1eb..5b248a01daa 100644 --- a/test/core/util/test_config.cc +++ b/test/core/util/test_config.cc @@ -28,7 +28,6 @@ #include #include -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/surface/init.h" diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 97275db6276..6ca0edf123e 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -33,7 +33,6 @@ #include #include "src/core/ext/filters/client_channel/backup_poller.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/tls.h" #include "src/core/lib/iomgr/port.h" #include "src/proto/grpc/health/v1/health.grpc.pb.h" @@ -44,6 +43,10 @@ #include "test/cpp/util/string_ref_helper.h" #include "test/cpp/util/test_credentials_provider.h" +#ifdef GRPC_POSIX_SOCKET +#include "src/core/lib/iomgr/ev_posix.h" +#endif // GRPC_POSIX_SOCKET + #include using grpc::testing::EchoRequest; @@ -359,13 +362,14 @@ TEST_P(AsyncEnd2endTest, ReconnectChannel) { return; } int poller_slowdown_factor = 1; +#ifdef GRPC_POSIX_SOCKET // It needs 2 pollset_works to reconnect the channel with polling engine // "poll" - char* s = gpr_getenv("GRPC_POLL_STRATEGY"); - if (s != nullptr && 0 == strcmp(s, "poll")) { + grpc_core::UniquePtr poller = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); + if (0 == strcmp(poller.get(), "poll")) { poller_slowdown_factor = 2; } - gpr_free(s); +#endif // GRPC_POSIX_SOCKET ResetStub(); SendRpc(1); server_->Shutdown(); diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index e5dc88ae6d7..8fae2da217f 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -35,7 +35,6 @@ #include #include "src/core/ext/filters/client_channel/backup_poller.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" @@ -47,6 +46,10 @@ #include "test/cpp/util/string_ref_helper.h" #include "test/cpp/util/test_credentials_provider.h" +#ifdef GRPC_POSIX_SOCKET +#include "src/core/lib/iomgr/ev_posix.h" +#endif // GRPC_POSIX_SOCKET + #include using grpc::testing::EchoRequest; @@ -809,11 +812,12 @@ TEST_P(End2endTest, ReconnectChannel) { int poller_slowdown_factor = 1; // It needs 2 pollset_works to reconnect the channel with polling engine // "poll" - char* s = gpr_getenv("GRPC_POLL_STRATEGY"); - if (s != nullptr && 0 == strcmp(s, "poll")) { +#ifdef GRPC_POSIX_SOCKET + grpc_core::UniquePtr poller = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); + if (0 == strcmp(poller.get(), "poll")) { poller_slowdown_factor = 2; } - gpr_free(s); +#endif // GRPC_POSIX_SOCKET ResetStub(); SendRpc(stub_.get(), 1, false); RestartServer(std::shared_ptr()); diff --git a/test/cpp/naming/address_sorting_test.cc b/test/cpp/naming/address_sorting_test.cc index bd685632c33..affc75bc634 100644 --- a/test/cpp/naming/address_sorting_test.cc +++ b/test/cpp/naming/address_sorting_test.cc @@ -36,10 +36,10 @@ #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/client_channel/resolver.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" +#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/combiner.h" @@ -829,13 +829,13 @@ TEST_F(AddressSortingTest, TestSorterKnowsIpv6LoopbackIsAvailable) { } // namespace int main(int argc, char** argv) { - char* resolver = gpr_getenv("GRPC_DNS_RESOLVER"); - if (resolver == nullptr || strlen(resolver) == 0) { - gpr_setenv("GRPC_DNS_RESOLVER", "ares"); - } else if (strcmp("ares", resolver)) { - gpr_log(GPR_INFO, "GRPC_DNS_RESOLVER != ares: %s.", resolver); + grpc_core::UniquePtr resolver = + GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); + if (strlen(resolver.get()) == 0) { + GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "ares"); + } else if (strcmp("ares", resolver.get())) { + gpr_log(GPR_INFO, "GRPC_DNS_RESOLVER != ares: %s.", resolver.get()); } - gpr_free(resolver); grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); auto result = RUN_ALL_TESTS(); diff --git a/test/cpp/naming/cancel_ares_query_test.cc b/test/cpp/naming/cancel_ares_query_test.cc index 674e72fdc52..667011ae291 100644 --- a/test/cpp/naming/cancel_ares_query_test.cc +++ b/test/cpp/naming/cancel_ares_query_test.cc @@ -29,10 +29,10 @@ #include #include "include/grpc/support/string_util.h" #include "src/core/ext/filters/client_channel/resolver.h" +#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/stats.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/orphanable.h" @@ -374,7 +374,7 @@ TEST( int main(int argc, char** argv) { grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); - gpr_setenv("GRPC_DNS_RESOLVER", "ares"); + GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "ares"); // Sanity check the time that it takes to run the test // including the teardown time (the teardown // part of the test involves cancelling the DNS query, diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index e3f3e94d2de..b56dc9bc631 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -46,7 +46,6 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/orphanable.h" diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 0839f8c6386..293a6e1f9c1 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -953,6 +953,8 @@ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ +src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ +src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h \ src/core/ext/filters/client_channel/resolver/dns/native/README.md \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 242f6677d6a..b5ba965ea98 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -9155,7 +9155,8 @@ "deps": [ "gpr", "grpc_base", - "grpc_client_channel" + "grpc_client_channel", + "grpc_resolver_dns_selection" ], "headers": [ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h", @@ -9188,7 +9189,8 @@ "deps": [ "gpr", "grpc_base", - "grpc_client_channel" + "grpc_client_channel", + "grpc_resolver_dns_selection" ], "headers": [], "is_filegroup": true, @@ -9200,6 +9202,24 @@ "third_party": false, "type": "filegroup" }, + { + "deps": [ + "gpr", + "grpc_base" + ], + "headers": [ + "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" + ], + "is_filegroup": true, + "language": "c", + "name": "grpc_resolver_dns_selection", + "src": [ + "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc", + "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" + ], + "third_party": false, + "type": "filegroup" + }, { "deps": [ "gpr", diff --git a/tools/run_tests/run_microbenchmark.py b/tools/run_tests/run_microbenchmark.py index 4e4d05cdcd4..a7fde3007af 100755 --- a/tools/run_tests/run_microbenchmark.py +++ b/tools/run_tests/run_microbenchmark.py @@ -96,7 +96,7 @@ def collect_latency(bm_name, args): '--benchmark_filter=^%s$' % line, '--benchmark_min_time=0.05' ], - environ={'LATENCY_TRACE': '%s.trace' % fnize(line)}, + environ={'GRPC_LATENCY_TRACE': '%s.trace' % fnize(line)}, shortname='profile-%s' % fnize(line))) profile_analysis.append( jobset.JobSpec( diff --git a/tools/run_tests/sanity/core_banned_functions.py b/tools/run_tests/sanity/core_banned_functions.py index 549ae14f5ab..ce9ff0dae21 100755 --- a/tools/run_tests/sanity/core_banned_functions.py +++ b/tools/run_tests/sanity/core_banned_functions.py @@ -45,10 +45,6 @@ BANNED_EXCEPT = { 'grpc_closure_sched(': ['src/core/lib/iomgr/closure.cc'], 'grpc_closure_run(': ['src/core/lib/iomgr/closure.cc'], 'grpc_closure_list_sched(': ['src/core/lib/iomgr/closure.cc'], - 'gpr_getenv_silent(': [ - 'src/core/lib/gpr/log.cc', 'src/core/lib/gpr/env_linux.cc', - 'src/core/lib/gpr/env_posix.cc', 'src/core/lib/gpr/env_windows.cc' - ], } errors = 0 From b11a36e4b3ecb511cb78826a8379a793083a8a76 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 9 May 2019 14:12:39 -0700 Subject: [PATCH 0177/1555] mark marshaller WIP --- src/objective-c/GRPCClient/GRPCCall.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index 1a941571951..cf66531ab0c 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -182,7 +182,7 @@ extern NSString *const kGRPCTrailersKey; /** * Issued when a decompressed message is received from the server. The message is decompressed, and - * deserialized if a marshaller is provided to the call. + * deserialized if a marshaller is provided to the call (marshaller is work in progress). */ - (void)didReceiveData:(id)data; @@ -271,7 +271,8 @@ extern NSString *const kGRPCTrailersKey; - (void)cancel; /** - * Send a message to the server. The data is subject to marshaller serialization and compression. + * Send a message to the server. The data is subject to marshaller serialization and compression + * (marshaller is work in progress). */ - (void)writeData:(id)data; From a01674e3dcd190f2c3b9b7e9d6ac31396b1abd1c Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 9 May 2019 14:15:17 -0700 Subject: [PATCH 0178/1555] Fix interop tests types --- src/objective-c/tests/InteropTests.m | 41 ++++++++++++---------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/objective-c/tests/InteropTests.m b/src/objective-c/tests/InteropTests.m index 93316c0ff5a..690c5cee0a2 100644 --- a/src/objective-c/tests/InteropTests.m +++ b/src/objective-c/tests/InteropTests.m @@ -175,13 +175,13 @@ BOOL isRemoteInteropTest(NSString *host) { initWithDispatchQueue:(dispatch_queue_t)dispatchQueue startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))writeDataHook + writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, GRPCInterceptorManager *manager))receiveNextMessagesHook responseHeaderHook:(void (^)(NSDictionary *initialMetadata, GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))responseDataHook + responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager))responseCloseHook didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook; @@ -198,13 +198,13 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))writeDataHook + writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, GRPCInterceptorManager *manager))receiveNextMessagesHook responseHeaderHook:(void (^)(NSDictionary *initialMetadata, GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))responseDataHook + responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager))responseCloseHook didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook; @@ -214,11 +214,11 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager @implementation HookInterceptorFactory { void (^_startHook)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager); - void (^_writeDataHook)(NSData *data, GRPCInterceptorManager *manager); + void (^_writeDataHook)(id data, GRPCInterceptorManager *manager); void (^_finishHook)(GRPCInterceptorManager *manager); void (^_receiveNextMessagesHook)(NSUInteger numberOfMessages, GRPCInterceptorManager *manager); void (^_responseHeaderHook)(NSDictionary *initialMetadata, GRPCInterceptorManager *manager); - void (^_responseDataHook)(NSData *data, GRPCInterceptorManager *manager); + void (^_responseDataHook)(id data, GRPCInterceptorManager *manager); void (^_responseCloseHook)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager); void (^_didWriteDataHook)(GRPCInterceptorManager *manager); @@ -229,13 +229,13 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager initWithDispatchQueue:(dispatch_queue_t)dispatchQueue startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))writeDataHook + writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, GRPCInterceptorManager *manager))receiveNextMessagesHook responseHeaderHook:(void (^)(NSDictionary *initialMetadata, GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))responseDataHook + responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager))responseCloseHook didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { @@ -272,11 +272,11 @@ receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, @implementation HookIntercetpor { void (^_startHook)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager); - void (^_writeDataHook)(NSData *data, GRPCInterceptorManager *manager); + void (^_writeDataHook)(id data, GRPCInterceptorManager *manager); void (^_finishHook)(GRPCInterceptorManager *manager); void (^_receiveNextMessagesHook)(NSUInteger numberOfMessages, GRPCInterceptorManager *manager); void (^_responseHeaderHook)(NSDictionary *initialMetadata, GRPCInterceptorManager *manager); - void (^_responseDataHook)(NSData *data, GRPCInterceptorManager *manager); + void (^_responseDataHook)(id data, GRPCInterceptorManager *manager); void (^_responseCloseHook)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager); void (^_didWriteDataHook)(GRPCInterceptorManager *manager); @@ -298,13 +298,13 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))writeDataHook + writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, GRPCInterceptorManager *manager))receiveNextMessagesHook responseHeaderHook:(void (^)(NSDictionary *initialMetadata, GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(NSData *data, GRPCInterceptorManager *manager))responseDataHook + responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager))responseCloseHook didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { @@ -332,7 +332,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager } } -- (void)writeData:(NSData *)data { +- (void)writeData:(id )data { if (_writeDataHook) { _writeDataHook(data, _manager); } @@ -356,7 +356,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager } } -- (void)didReceiveData:(NSData *)data { +- (void)didReceiveData:(id )data { if (_responseDataHook) { _responseDataHook(data, _manager); } @@ -1355,22 +1355,18 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager) { startCount++; - NSLog(@"Interceptor - started call, %@, %@", requestOptions, callOptions); XCTAssertEqualObjects(requestOptions.host, [[self class] host]); XCTAssertEqualObjects(requestOptions.path, @"/grpc.testing.TestService/FullDuplexCall"); XCTAssertEqual(requestOptions.safety, GRPCCallSafetyDefault); [manager startNextInterceptorWithRequest:[requestOptions copy] callOptions:[callOptions copy]]; } - writeDataHook:^(NSData *data, GRPCInterceptorManager *manager) { + writeDataHook:^(id data, GRPCInterceptorManager *manager) { writeDataCount++; - NSLog(@"Interceptor - send data, %@", data); - XCTAssertNotEqual(data.length, 0); [manager writeNextInterceptorWithData:data]; } finishHook:^(GRPCInterceptorManager *manager) { finishCount++; - NSLog(@"Interceptor - finish call"); [manager finishNextInterceptor]; } receiveNextMessagesHook:^(NSUInteger numberOfMessages, GRPCInterceptorManager *manager) { @@ -1383,10 +1379,9 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager NSLog(@"Interceptor - received initial metadata, %@", initialMetadata); [manager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; } - responseDataHook:^(NSData *data, GRPCInterceptorManager *manager) { + responseDataHook:^(id data, GRPCInterceptorManager *manager) { responseDataCount++; NSLog(@"Interceptor - received data, %@", data); - XCTAssertNotEqual(data.length, 0); [manager forwardPreviousIntercetporWithData:data]; } responseCloseHook:^(NSDictionary *trailingMetadata, NSError *error, @@ -1491,7 +1486,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager [manager startNextInterceptorWithRequest:[requestOptions copy] callOptions:[callOptions copy]]; } - writeDataHook:^(NSData *data, GRPCInterceptorManager *manager) { + writeDataHook:^(id data, GRPCInterceptorManager *manager) { writeDataCount++; if (index < kCancelAfterWrites) { [manager writeNextInterceptorWithData:data]; @@ -1517,7 +1512,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager responseHeaderCount++; [manager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; } - responseDataHook:^(NSData *data, GRPCInterceptorManager *manager) { + responseDataHook:^(id data, GRPCInterceptorManager *manager) { responseDataCount++; [manager forwardPreviousIntercetporWithData:data]; } From 12fbdaa6a87ba6c2ec66b168d7e6d0f410702450 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 9 May 2019 14:17:30 -0700 Subject: [PATCH 0179/1555] Fix ref-counting bug in health check client. --- .../health/health_check_client.cc | 43 ++++++++++--------- .../health/health_check_client.h | 8 ++-- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/core/ext/filters/client_channel/health/health_check_client.cc b/src/core/ext/filters/client_channel/health/health_check_client.cc index a4467236662..bfac773899d 100644 --- a/src/core/ext/filters/client_channel/health/health_check_client.cc +++ b/src/core/ext/filters/client_channel/health/health_check_client.cc @@ -277,8 +277,7 @@ bool DecodeResponse(grpc_slice_buffer* slice_buffer, grpc_error** error) { HealthCheckClient::CallState::CallState( RefCountedPtr health_check_client, grpc_pollset_set* interested_parties) - : InternallyRefCounted(&grpc_health_check_client_trace), - health_check_client_(std::move(health_check_client)), + : health_check_client_(std::move(health_check_client)), pollent_(grpc_polling_entity_create_from_pollset_set(interested_parties)), arena_(Arena::Create(health_check_client_->connected_subchannel_ ->GetInitialCallSizeEstimate(0))), @@ -322,7 +321,8 @@ void HealthCheckClient::CallState::StartCall() { 0, // parent_data_size }; grpc_error* error = GRPC_ERROR_NONE; - call_ = health_check_client_->connected_subchannel_->CreateCall(args, &error); + call_ = health_check_client_->connected_subchannel_->CreateCall(args, &error) + .release(); if (error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "HealthCheckClient %p CallState %p: error creating health " @@ -331,18 +331,22 @@ void HealthCheckClient::CallState::StartCall() { GRPC_ERROR_UNREF(error); // Schedule instead of running directly, since we must not be // holding health_check_client_->mu_ when CallEnded() is called. - Ref(DEBUG_LOCATION, "call_end_closure").release(); + call_->Ref(DEBUG_LOCATION, "call_end_closure").release(); GRPC_CLOSURE_SCHED( GRPC_CLOSURE_INIT(&batch_.handler_private.closure, CallEndedRetry, this, grpc_schedule_on_exec_ctx), GRPC_ERROR_NONE); return; } + // Register after-destruction callback. + GRPC_CLOSURE_INIT(&after_call_stack_destruction_, AfterCallStackDestruction, + this, grpc_schedule_on_exec_ctx); + call_->SetAfterCallStackDestroy(&after_call_stack_destruction_); // Initialize payload and batch. payload_.context = context_; batch_.payload = &payload_; // on_complete callback takes ref, handled manually. - Ref(DEBUG_LOCATION, "on_complete").release(); + call_->Ref(DEBUG_LOCATION, "on_complete").release(); batch_.on_complete = GRPC_CLOSURE_INIT(&on_complete_, OnComplete, this, grpc_schedule_on_exec_ctx); // Add send_initial_metadata op. @@ -375,7 +379,7 @@ void HealthCheckClient::CallState::StartCall() { payload_.recv_initial_metadata.trailing_metadata_available = nullptr; payload_.recv_initial_metadata.peer_string = nullptr; // recv_initial_metadata_ready callback takes ref, handled manually. - Ref(DEBUG_LOCATION, "recv_initial_metadata_ready").release(); + call_->Ref(DEBUG_LOCATION, "recv_initial_metadata_ready").release(); payload_.recv_initial_metadata.recv_initial_metadata_ready = GRPC_CLOSURE_INIT(&recv_initial_metadata_ready_, RecvInitialMetadataReady, this, grpc_schedule_on_exec_ctx); @@ -383,7 +387,7 @@ void HealthCheckClient::CallState::StartCall() { // Add recv_message op. payload_.recv_message.recv_message = &recv_message_; // recv_message callback takes ref, handled manually. - Ref(DEBUG_LOCATION, "recv_message_ready").release(); + call_->Ref(DEBUG_LOCATION, "recv_message_ready").release(); payload_.recv_message.recv_message_ready = GRPC_CLOSURE_INIT( &recv_message_ready_, RecvMessageReady, this, grpc_schedule_on_exec_ctx); batch_.recv_message = true; @@ -419,7 +423,7 @@ void HealthCheckClient::CallState::StartBatchInCallCombiner(void* arg, void HealthCheckClient::CallState::StartBatch( grpc_transport_stream_op_batch* batch) { - batch->handler_private.extra_arg = call_.get(); + batch->handler_private.extra_arg = call_; GRPC_CLOSURE_INIT(&batch->handler_private.closure, StartBatchInCallCombiner, batch, grpc_schedule_on_exec_ctx); GRPC_CALL_COMBINER_START(&call_combiner_, &batch->handler_private.closure, @@ -430,7 +434,7 @@ void HealthCheckClient::CallState::AfterCallStackDestruction( void* arg, grpc_error* error) { HealthCheckClient::CallState* self = static_cast(arg); - self->Unref(DEBUG_LOCATION, "cancel"); + Delete(self); } void HealthCheckClient::CallState::OnCancelComplete(void* arg, @@ -438,10 +442,7 @@ void HealthCheckClient::CallState::OnCancelComplete(void* arg, HealthCheckClient::CallState* self = static_cast(arg); GRPC_CALL_COMBINER_STOP(&self->call_combiner_, "health_cancel"); - GRPC_CLOSURE_INIT(&self->after_call_stack_destruction_, - AfterCallStackDestruction, self, grpc_schedule_on_exec_ctx); - self->call_->SetAfterCallStackDestroy(&self->after_call_stack_destruction_); - self->call_.reset(); + self->call_->Unref(DEBUG_LOCATION, "cancel"); } void HealthCheckClient::CallState::StartCancel(void* arg, grpc_error* error) { @@ -458,7 +459,7 @@ void HealthCheckClient::CallState::Cancel() { bool expected = false; if (cancelled_.CompareExchangeStrong(&expected, true, MemoryOrder::ACQ_REL, MemoryOrder::ACQUIRE)) { - Ref(DEBUG_LOCATION, "cancel").release(); + call_->Ref(DEBUG_LOCATION, "cancel").release(); GRPC_CALL_COMBINER_START( &call_combiner_, GRPC_CLOSURE_CREATE(StartCancel, this, grpc_schedule_on_exec_ctx), @@ -472,7 +473,7 @@ void HealthCheckClient::CallState::OnComplete(void* arg, grpc_error* error) { GRPC_CALL_COMBINER_STOP(&self->call_combiner_, "on_complete"); grpc_metadata_batch_destroy(&self->send_initial_metadata_); grpc_metadata_batch_destroy(&self->send_trailing_metadata_); - self->Unref(DEBUG_LOCATION, "on_complete"); + self->call_->Unref(DEBUG_LOCATION, "on_complete"); } void HealthCheckClient::CallState::RecvInitialMetadataReady(void* arg, @@ -481,7 +482,7 @@ void HealthCheckClient::CallState::RecvInitialMetadataReady(void* arg, static_cast(arg); GRPC_CALL_COMBINER_STOP(&self->call_combiner_, "recv_initial_metadata_ready"); grpc_metadata_batch_destroy(&self->recv_initial_metadata_); - self->Unref(DEBUG_LOCATION, "recv_initial_metadata_ready"); + self->call_->Unref(DEBUG_LOCATION, "recv_initial_metadata_ready"); } void HealthCheckClient::CallState::DoneReadingRecvMessage(grpc_error* error) { @@ -490,7 +491,7 @@ void HealthCheckClient::CallState::DoneReadingRecvMessage(grpc_error* error) { GRPC_ERROR_UNREF(error); Cancel(); grpc_slice_buffer_destroy_internal(&recv_message_buffer_); - Unref(DEBUG_LOCATION, "recv_message_ready"); + call_->Unref(DEBUG_LOCATION, "recv_message_ready"); return; } const bool healthy = DecodeResponse(&recv_message_buffer_, &error); @@ -563,7 +564,7 @@ void HealthCheckClient::CallState::RecvMessageReady(void* arg, static_cast(arg); GRPC_CALL_COMBINER_STOP(&self->call_combiner_, "recv_message_ready"); if (self->recv_message_ == nullptr) { - self->Unref(DEBUG_LOCATION, "recv_message_ready"); + self->call_->Unref(DEBUG_LOCATION, "recv_message_ready"); return; } grpc_slice_buffer_init(&self->recv_message_buffer_); @@ -621,7 +622,7 @@ void HealthCheckClient::CallState::CallEndedRetry(void* arg, HealthCheckClient::CallState* self = static_cast(arg); self->CallEnded(true /* retry */); - self->Unref(DEBUG_LOCATION, "call_end_closure"); + self->call_->Unref(DEBUG_LOCATION, "call_end_closure"); } void HealthCheckClient::CallState::CallEnded(bool retry) { @@ -644,7 +645,9 @@ void HealthCheckClient::CallState::CallEnded(bool retry) { } } } - Unref(DEBUG_LOCATION, "call_ended"); + // When the last ref to the call stack goes away, the CallState object + // will be automatically destroyed. + call_->Unref(DEBUG_LOCATION, "call_ended"); } } // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/health/health_check_client.h b/src/core/ext/filters/client_channel/health/health_check_client.h index daf61c38155..956c1095550 100644 --- a/src/core/ext/filters/client_channel/health/health_check_client.h +++ b/src/core/ext/filters/client_channel/health/health_check_client.h @@ -61,7 +61,7 @@ class HealthCheckClient : public InternallyRefCounted { private: // Contains a call to the backend and all the data related to the call. - class CallState : public InternallyRefCounted { + class CallState : public Orphanable { public: CallState(RefCountedPtr health_check_client, grpc_pollset_set* interested_parties_); @@ -101,8 +101,10 @@ class HealthCheckClient : public InternallyRefCounted { grpc_core::CallCombiner call_combiner_; grpc_call_context_element context_[GRPC_CONTEXT_COUNT] = {}; - // The streaming call to the backend. Always non-NULL. - RefCountedPtr call_; + // The streaming call to the backend. Always non-null. + // Refs are tracked manually; when the last ref is released, the + // CallState object will be automatically destroyed. + SubchannelCall* call_; grpc_transport_stream_op_batch_payload payload_; grpc_transport_stream_op_batch batch_; From d56bbf19d263b0cf94e1ff5c34650741231cf455 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 9 May 2019 15:50:52 -0700 Subject: [PATCH 0180/1555] Reviewer comments --- .../filters/client_channel/client_channel.cc | 121 +++++++++--------- 1 file changed, 60 insertions(+), 61 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 21f63348f54..f774c985c30 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -234,7 +234,7 @@ class ChannelData { void ProcessLbPolicy( const Resolver::Result& resolver_result, - const internal::ClientChannelGlobalParsedObject* parsed_object, + const internal::ClientChannelGlobalParsedObject* parsed_service_config, UniquePtr* lb_policy_name, RefCountedPtr* lb_policy_config); @@ -1152,52 +1152,50 @@ ChannelData::~ChannelData() { void ChannelData::ProcessLbPolicy( const Resolver::Result& resolver_result, - const internal::ClientChannelGlobalParsedObject* parsed_object, + const internal::ClientChannelGlobalParsedObject* parsed_service_config, UniquePtr* lb_policy_name, RefCountedPtr* lb_policy_config) { // Prefer the LB policy name found in the service config. - if (parsed_object != nullptr && - parsed_object->parsed_lb_config() != nullptr) { + if (parsed_service_config != nullptr && + parsed_service_config->parsed_lb_config() != nullptr) { lb_policy_name->reset( - gpr_strdup(parsed_object->parsed_lb_config()->name())); - *lb_policy_config = parsed_object->parsed_lb_config(); - } else { - const char* local_policy_name = nullptr; - if (parsed_object != nullptr && - parsed_object->parsed_deprecated_lb_policy() != nullptr) { - local_policy_name = parsed_object->parsed_deprecated_lb_policy(); - } else { - const grpc_arg* channel_arg = - grpc_channel_args_find(resolver_result.args, GRPC_ARG_LB_POLICY_NAME); - local_policy_name = grpc_channel_arg_get_string(channel_arg); - } - // Special case: If at least one balancer address is present, we use - // the grpclb policy, regardless of what the resolver has returned. - bool found_balancer_address = false; - for (size_t i = 0; i < resolver_result.addresses.size(); ++i) { - const ServerAddress& address = resolver_result.addresses[i]; - if (address.IsBalancer()) { - found_balancer_address = true; - break; - } - } - if (found_balancer_address) { - if (local_policy_name != nullptr && - strcmp(local_policy_name, "grpclb") != 0) { - gpr_log(GPR_INFO, - "resolver requested LB policy %s but provided at least one " - "balancer address -- forcing use of grpclb LB policy", - local_policy_name); - } - local_policy_name = "grpclb"; - } - // Use pick_first if nothing was specified and we didn't select grpclb - // above. - if (local_policy_name == nullptr) { - local_policy_name = "pick_first"; - } - lb_policy_name->reset(gpr_strdup(local_policy_name)); + gpr_strdup(parsed_service_config->parsed_lb_config()->name())); + *lb_policy_config = parsed_service_config->parsed_lb_config(); + return; } + const char* local_policy_name = nullptr; + if (parsed_service_config != nullptr && + parsed_service_config->parsed_deprecated_lb_policy() != nullptr) { + local_policy_name = parsed_service_config->parsed_deprecated_lb_policy(); + } else { + const grpc_arg* channel_arg = + grpc_channel_args_find(resolver_result.args, GRPC_ARG_LB_POLICY_NAME); + local_policy_name = grpc_channel_arg_get_string(channel_arg); + } + // Special case: If at least one balancer address is present, we use + // the grpclb policy, regardless of what the resolver has returned. + bool found_balancer_address = false; + for (size_t i = 0; i < resolver_result.addresses.size(); ++i) { + const ServerAddress& address = resolver_result.addresses[i]; + if (address.IsBalancer()) { + found_balancer_address = true; + break; + } + } + if (found_balancer_address) { + if (local_policy_name != nullptr && + strcmp(local_policy_name, "grpclb") != 0) { + gpr_log(GPR_INFO, + "resolver requested LB policy %s but provided at least one " + "balancer address -- forcing use of grpclb LB policy", + local_policy_name); + } + local_policy_name = "grpclb"; + } + // Use pick_first if nothing was specified and we didn't select grpclb + // above. + lb_policy_name->reset(gpr_strdup( + local_policy_name == nullptr ? "pick_first" : local_policy_name)); } // Synchronous callback from ResolvingLoadBalancingPolicy to process a @@ -1209,11 +1207,11 @@ bool ChannelData::ProcessResolverResultLocked( ChannelData* chand = static_cast(arg); RefCountedPtr service_config; // If resolver did not return a service config or returned an invalid service - // config, we need a fallback service config + // config, we need a fallback service config. if (result.service_config_error != GRPC_ERROR_NONE) { - // If the service config was invalid, then prefer using the saved service - // config, otherwise use the default service config provided by the client - // API + // If the service config was invalid, then fallback to the saved service + // config. If there is no saved config either, use the default service + // config. if (chand->saved_service_config_ != nullptr) { service_config = chand->saved_service_config_; if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { @@ -1232,13 +1230,13 @@ bool ChannelData::ProcessResolverResultLocked( service_config = chand->default_service_config_; } } else if (result.service_config == nullptr) { - if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { - gpr_log(GPR_INFO, - "chand=%p: resolver returned no service config. Using default " - "service config provided by client API.", - chand); - } if (chand->default_service_config_ != nullptr) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { + gpr_log(GPR_INFO, + "chand=%p: resolver returned no service config. Using default " + "service config provided by client API.", + chand); + } service_config = chand->default_service_config_; } } else { @@ -1251,9 +1249,10 @@ bool ChannelData::ProcessResolverResultLocked( } UniquePtr service_config_json; // Process service config. - const internal::ClientChannelGlobalParsedObject* parsed_object = nullptr; + const internal::ClientChannelGlobalParsedObject* parsed_service_config = + nullptr; if (service_config != nullptr) { - parsed_object = + parsed_service_config = static_cast( service_config->GetParsedGlobalServiceConfigObject( internal::ClientChannelServiceConfigParser::ParserIndex())); @@ -1274,22 +1273,22 @@ bool ChannelData::ProcessResolverResultLocked( chand, service_config_json.get()); } chand->saved_service_config_ = std::move(service_config); - if (parsed_object != nullptr) { + if (parsed_service_config != nullptr) { chand->health_check_service_name_.reset( - gpr_strdup(parsed_object->health_check_service_name())); + gpr_strdup(parsed_service_config->health_check_service_name())); } else { chand->health_check_service_name_.reset(); } } - // We want to set the service config atleast once. This should not really be + // We want to set the service config at least once. This should not really be // needed, but we are doing it as a defensive approach. This can be removed, // if we feel it is unnecessary. if (service_config_changed || !chand->received_first_resolver_result_) { chand->received_first_resolver_result_ = true; Optional retry_throttle_data; - if (parsed_object != nullptr) { - retry_throttle_data = parsed_object->retry_throttling(); + if (parsed_service_config != nullptr) { + retry_throttle_data = parsed_service_config->retry_throttling(); } // Create service config setter to update channel state in the data // plane combiner. Destroys itself when done. @@ -1297,8 +1296,8 @@ bool ChannelData::ProcessResolverResultLocked( chand->saved_service_config_); } UniquePtr processed_lb_policy_name; - chand->ProcessLbPolicy(result, parsed_object, &processed_lb_policy_name, - lb_policy_config); + chand->ProcessLbPolicy(result, parsed_service_config, + &processed_lb_policy_name, lb_policy_config); // Swap out the data used by GetChannelInfo(). { MutexLock lock(&chand->info_mu_); From a8139b4da12beb0663e7f58b2a25d58c51d77f00 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Thu, 9 May 2019 16:54:22 -0700 Subject: [PATCH 0181/1555] Fix node interop build scripts --- .../interoptest/grpc_interop_node/build_interop.sh | 4 +--- .../interoptest/grpc_interop_nodepurejs/build_interop.sh | 6 +----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/tools/dockerfile/interoptest/grpc_interop_node/build_interop.sh b/tools/dockerfile/interoptest/grpc_interop_node/build_interop.sh index c16efc1d354..aeb82e0c9c3 100755 --- a/tools/dockerfile/interoptest/grpc_interop_node/build_interop.sh +++ b/tools/dockerfile/interoptest/grpc_interop_node/build_interop.sh @@ -29,6 +29,4 @@ cp -r /var/local/jenkins/service_account $HOME || true cd /var/local/git/grpc-node # build Node interop client & server -npm install -g node-gyp gulp -npm install -gulp setup +./setup_interop.sh diff --git a/tools/dockerfile/interoptest/grpc_interop_nodepurejs/build_interop.sh b/tools/dockerfile/interoptest/grpc_interop_nodepurejs/build_interop.sh index d41ccacd2f9..db55f5a19f3 100755 --- a/tools/dockerfile/interoptest/grpc_interop_nodepurejs/build_interop.sh +++ b/tools/dockerfile/interoptest/grpc_interop_nodepurejs/build_interop.sh @@ -29,8 +29,4 @@ cp -r /var/local/jenkins/service_account $HOME || true cd /var/local/git/grpc-node # build Node interop client & server -npm install -g gulp -npm install -gulp js.core.install -gulp protobuf.install -gulp internal.test.install +./setup_interop_purejs.sh From a4d4bb82c98bfb103dae818b5cdf4a32704f9cd0 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 10 May 2019 07:57:11 -0700 Subject: [PATCH 0182/1555] Revamp subchannel connectivity state monitoring APIs. --- .../filters/client_channel/client_channel.cc | 51 +- .../client_channel/client_channel_channelz.cc | 4 +- .../lb_policy/pick_first/pick_first.cc | 29 +- .../lb_policy/round_robin/round_robin.cc | 10 +- .../lb_policy/subchannel_list.h | 360 +++++++------- .../client_channel/resolving_lb_policy.cc | 2 +- .../client_channel/resolving_lb_policy.h | 3 +- .../ext/filters/client_channel/subchannel.cc | 452 +++++++++++------- .../ext/filters/client_channel/subchannel.h | 138 +++++- test/cpp/end2end/client_lb_end2end_test.cc | 67 ++- 10 files changed, 674 insertions(+), 442 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index f774c985c30..757ac2a35e7 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -222,7 +222,7 @@ class ChannelData { ~ChannelData(); static bool ProcessResolverResultLocked( - void* arg, const Resolver::Result& result, const char** lb_policy_name, + void* arg, Resolver::Result* result, const char** lb_policy_name, RefCountedPtr* lb_policy_config, grpc_error** service_config_error); @@ -271,7 +271,6 @@ class ChannelData { OrphanablePtr resolving_lb_policy_; grpc_connectivity_state_tracker state_tracker_; ExternalConnectivityWatcher::WatcherList external_connectivity_watcher_list_; - UniquePtr health_check_service_name_; RefCountedPtr saved_service_config_; bool received_first_resolver_result_ = false; @@ -951,18 +950,10 @@ class ChannelData::ClientChannelControlHelper } Subchannel* CreateSubchannel(const grpc_channel_args& args) override { - grpc_arg args_to_add[2]; - int num_args_to_add = 0; - if (chand_->health_check_service_name_ != nullptr) { - args_to_add[0] = grpc_channel_arg_string_create( - const_cast("grpc.temp.health_check"), - const_cast(chand_->health_check_service_name_.get())); - num_args_to_add++; - } - args_to_add[num_args_to_add++] = SubchannelPoolInterface::CreateChannelArg( + grpc_arg arg = SubchannelPoolInterface::CreateChannelArg( chand_->subchannel_pool_.get()); grpc_channel_args* new_args = - grpc_channel_args_copy_and_add(&args, args_to_add, num_args_to_add); + grpc_channel_args_copy_and_add(&args, &arg, 1); Subchannel* subchannel = chand_->client_channel_factory_->CreateSubchannel(new_args); grpc_channel_args_destroy(new_args); @@ -1201,14 +1192,14 @@ void ChannelData::ProcessLbPolicy( // Synchronous callback from ResolvingLoadBalancingPolicy to process a // resolver result update. bool ChannelData::ProcessResolverResultLocked( - void* arg, const Resolver::Result& result, const char** lb_policy_name, + void* arg, Resolver::Result* result, const char** lb_policy_name, RefCountedPtr* lb_policy_config, grpc_error** service_config_error) { ChannelData* chand = static_cast(arg); RefCountedPtr service_config; // If resolver did not return a service config or returned an invalid service // config, we need a fallback service config. - if (result.service_config_error != GRPC_ERROR_NONE) { + if (result->service_config_error != GRPC_ERROR_NONE) { // If the service config was invalid, then fallback to the saved service // config. If there is no saved config either, use the default service // config. @@ -1229,7 +1220,7 @@ bool ChannelData::ProcessResolverResultLocked( } service_config = chand->default_service_config_; } - } else if (result.service_config == nullptr) { + } else if (result->service_config == nullptr) { if (chand->default_service_config_ != nullptr) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { gpr_log(GPR_INFO, @@ -1240,15 +1231,15 @@ bool ChannelData::ProcessResolverResultLocked( service_config = chand->default_service_config_; } } else { - service_config = result.service_config; + service_config = result->service_config; } - *service_config_error = GRPC_ERROR_REF(result.service_config_error); + *service_config_error = GRPC_ERROR_REF(result->service_config_error); if (service_config == nullptr && - result.service_config_error != GRPC_ERROR_NONE) { + result->service_config_error != GRPC_ERROR_NONE) { return false; } - UniquePtr service_config_json; // Process service config. + UniquePtr service_config_json; const internal::ClientChannelGlobalParsedObject* parsed_service_config = nullptr; if (service_config != nullptr) { @@ -1257,6 +1248,20 @@ bool ChannelData::ProcessResolverResultLocked( service_config->GetParsedGlobalServiceConfigObject( internal::ClientChannelServiceConfigParser::ParserIndex())); } + // TODO(roth): Eliminate this hack as part of hiding health check + // service name from LB policy API. As part of this, change the API + // for this function to pass in result as a const reference. + if (parsed_service_config != nullptr && + parsed_service_config->health_check_service_name() != nullptr) { + grpc_arg new_arg = grpc_channel_arg_string_create( + const_cast("grpc.temp.health_check"), + const_cast(parsed_service_config->health_check_service_name())); + grpc_channel_args* new_args = + grpc_channel_args_copy_and_add(result->args, &new_arg, 1); + grpc_channel_args_destroy(result->args); + result->args = new_args; + } + // Check if the config has changed. const bool service_config_changed = ((service_config == nullptr) != (chand->saved_service_config_ == nullptr)) || @@ -1273,12 +1278,6 @@ bool ChannelData::ProcessResolverResultLocked( chand, service_config_json.get()); } chand->saved_service_config_ = std::move(service_config); - if (parsed_service_config != nullptr) { - chand->health_check_service_name_.reset( - gpr_strdup(parsed_service_config->health_check_service_name())); - } else { - chand->health_check_service_name_.reset(); - } } // We want to set the service config at least once. This should not really be // needed, but we are doing it as a defensive approach. This can be removed, @@ -1296,7 +1295,7 @@ bool ChannelData::ProcessResolverResultLocked( chand->saved_service_config_); } UniquePtr processed_lb_policy_name; - chand->ProcessLbPolicy(result, parsed_service_config, + chand->ProcessLbPolicy(*result, parsed_service_config, &processed_lb_policy_name, lb_policy_config); // Swap out the data used by GetChannelInfo(). { diff --git a/src/core/ext/filters/client_channel/client_channel_channelz.cc b/src/core/ext/filters/client_channel/client_channel_channelz.cc index a7a47e9eb10..de61819ef54 100644 --- a/src/core/ext/filters/client_channel/client_channel_channelz.cc +++ b/src/core/ext/filters/client_channel/client_channel_channelz.cc @@ -127,7 +127,9 @@ void SubchannelNode::PopulateConnectivityState(grpc_json* json) { if (subchannel_ == nullptr) { state = GRPC_CHANNEL_SHUTDOWN; } else { - state = subchannel_->CheckConnectivity(true /* inhibit_health_checking */); + state = subchannel_->CheckConnectivityState( + nullptr /* health_check_service_name */, + nullptr /* connected_subchannel */); } json = grpc_json_create_child(nullptr, json, "state", nullptr, GRPC_JSON_OBJECT, false); diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index bc2f6e5efd6..199e973e72c 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -68,9 +68,8 @@ class PickFirst : public LoadBalancingPolicy { PickFirstSubchannelData( SubchannelList* subchannel_list, - const ServerAddress& address, Subchannel* subchannel, - grpc_combiner* combiner) - : SubchannelData(subchannel_list, address, subchannel, combiner) {} + const ServerAddress& address, Subchannel* subchannel) + : SubchannelData(subchannel_list, address, subchannel) {} void ProcessConnectivityChangeLocked( grpc_connectivity_state connectivity_state) override; @@ -312,6 +311,7 @@ void PickFirst::UpdateLocked(UpdateArgs args) { // here, since we've already checked the initial connectivity // state of all subchannels above. subchannel_list_->subchannel(0)->StartConnectivityWatchLocked(); + subchannel_list_->subchannel(0)->subchannel()->AttemptToConnect(); } } else { // We do have a selected subchannel (which means it's READY), so keep @@ -334,6 +334,9 @@ void PickFirst::UpdateLocked(UpdateArgs args) { // state of all subchannels above. latest_pending_subchannel_list_->subchannel(0) ->StartConnectivityWatchLocked(); + latest_pending_subchannel_list_->subchannel(0) + ->subchannel() + ->AttemptToConnect(); } } } @@ -366,7 +369,8 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( p->subchannel_list_.get()); } p->selected_ = nullptr; - StopConnectivityWatchLocked(); + CancelConnectivityWatchLocked( + "selected subchannel failed; switching to pending update"); p->subchannel_list_ = std::move(p->latest_pending_subchannel_list_); // Set our state to that of the pending subchannel list. if (p->subchannel_list_->in_transient_failure()) { @@ -391,7 +395,7 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( p->idle_ = true; p->channel_control_helper()->RequestReresolution(); p->selected_ = nullptr; - StopConnectivityWatchLocked(); + CancelConnectivityWatchLocked("selected subchannel failed; going IDLE"); p->channel_control_helper()->UpdateState( GRPC_CHANNEL_IDLE, UniquePtr(New(p->Ref()))); @@ -408,8 +412,6 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( connectivity_state, UniquePtr(New(p->Ref()))); } - // Renew notification. - RenewConnectivityWatchLocked(); } } return; @@ -426,13 +428,11 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( subchannel_list()->set_in_transient_failure(false); switch (connectivity_state) { case GRPC_CHANNEL_READY: { - // Renew notification. - RenewConnectivityWatchLocked(); ProcessUnselectedReadyLocked(); break; } case GRPC_CHANNEL_TRANSIENT_FAILURE: { - StopConnectivityWatchLocked(); + CancelConnectivityWatchLocked("connection attempt failed"); PickFirstSubchannelData* sd = this; size_t next_index = (sd->Index() + 1) % subchannel_list()->num_subchannels(); @@ -468,8 +468,6 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( GRPC_CHANNEL_CONNECTING, UniquePtr(New(p->Ref()))); } - // Renew notification. - RenewConnectivityWatchLocked(); break; } case GRPC_CHANNEL_SHUTDOWN: @@ -521,8 +519,11 @@ void PickFirst::PickFirstSubchannelData:: // If current state is READY, select the subchannel now, since we started // watching from this state and will not get a notification of it // transitioning into this state. - if (p->selected_ != this && current_state == GRPC_CHANNEL_READY) { - ProcessUnselectedReadyLocked(); + // If the current state is not READY, attempt to connect. + if (current_state == GRPC_CHANNEL_READY) { + if (p->selected_ != this) ProcessUnselectedReadyLocked(); + } else { + subchannel()->AttemptToConnect(); } } diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc index 6d603913d82..1693032ea24 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc @@ -83,9 +83,8 @@ class RoundRobin : public LoadBalancingPolicy { RoundRobinSubchannelData( SubchannelList* subchannel_list, - const ServerAddress& address, Subchannel* subchannel, - grpc_combiner* combiner) - : SubchannelData(subchannel_list, address, subchannel, combiner) {} + const ServerAddress& address, Subchannel* subchannel) + : SubchannelData(subchannel_list, address, subchannel) {} grpc_connectivity_state connectivity_state() const { return last_connectivity_state_; @@ -320,6 +319,7 @@ void RoundRobin::RoundRobinSubchannelList::StartWatchingLocked() { for (size_t i = 0; i < num_subchannels(); i++) { if (subchannel(i)->subchannel() != nullptr) { subchannel(i)->StartConnectivityWatchLocked(); + subchannel(i)->subchannel()->AttemptToConnect(); } } // Now set the LB policy's state based on the subchannels' states. @@ -448,6 +448,7 @@ void RoundRobin::RoundRobinSubchannelData::ProcessConnectivityChangeLocked( // Otherwise, if the subchannel was already in state TRANSIENT_FAILURE // when the subchannel list was created, we'd wind up in a constant // loop of re-resolution. + // Also attempt to reconnect. if (connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) { if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_round_robin_trace)) { gpr_log(GPR_INFO, @@ -456,9 +457,8 @@ void RoundRobin::RoundRobinSubchannelData::ProcessConnectivityChangeLocked( p, subchannel()); } p->channel_control_helper()->RequestReresolution(); + subchannel()->AttemptToConnect(); } - // Renew connectivity watch. - RenewConnectivityWatchLocked(); // Update state counters. UpdateConnectivityStateLocked(connectivity_state); // Update overall state and renew notification. diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h index 4c48045f978..93b4bbd369a 100644 --- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h @@ -98,15 +98,13 @@ class SubchannelData { // Synchronously checks the subchannel's connectivity state. // Must not be called while there is a connectivity notification - // pending (i.e., between calling StartConnectivityWatchLocked() or - // RenewConnectivityWatchLocked() and the resulting invocation of - // ProcessConnectivityChangeLocked()). + // pending (i.e., between calling StartConnectivityWatchLocked() and + // calling CancelConnectivityWatchLocked()). grpc_connectivity_state CheckConnectivityStateLocked() { - GPR_ASSERT(!connectivity_notification_pending_); - pending_connectivity_state_unsafe_ = subchannel()->CheckConnectivity( - subchannel_list_->inhibit_health_checking()); - UpdateConnectedSubchannelLocked(); - return pending_connectivity_state_unsafe_; + GPR_ASSERT(pending_watcher_ == nullptr); + connectivity_state_ = subchannel()->CheckConnectivityState( + subchannel_list_->health_check_service_name(), &connected_subchannel_); + return connectivity_state_; } // Resets the connection backoff. @@ -115,23 +113,11 @@ class SubchannelData { void ResetBackoffLocked(); // Starts watching the connectivity state of the subchannel. - // ProcessConnectivityChangeLocked() will be called when the + // ProcessConnectivityChangeLocked() will be called whenever the // connectivity state changes. void StartConnectivityWatchLocked(); - // Renews watching the connectivity state of the subchannel. - void RenewConnectivityWatchLocked(); - - // Stops watching the connectivity state of the subchannel. - void StopConnectivityWatchLocked(); - // Cancels watching the connectivity state of the subchannel. - // Must be called only while there is a connectivity notification - // pending (i.e., between calling StartConnectivityWatchLocked() or - // RenewConnectivityWatchLocked() and the resulting invocation of - // ProcessConnectivityChangeLocked()). - // From within ProcessConnectivityChangeLocked(), use - // StopConnectivityWatchLocked() instead. void CancelConnectivityWatchLocked(const char* reason); // Cancels any pending connectivity watch and unrefs the subchannel. @@ -142,44 +128,80 @@ class SubchannelData { protected: SubchannelData( SubchannelList* subchannel_list, - const ServerAddress& address, Subchannel* subchannel, - grpc_combiner* combiner); + const ServerAddress& address, Subchannel* subchannel); virtual ~SubchannelData(); - // After StartConnectivityWatchLocked() or RenewConnectivityWatchLocked() - // is called, this method will be invoked when the subchannel's connectivity - // state changes. - // Implementations must invoke either RenewConnectivityWatchLocked() or - // StopConnectivityWatchLocked() before returning. + // After StartConnectivityWatchLocked() is called, this method will be + // invoked whenever the subchannel's connectivity state changes. + // To stop watching, use CancelConnectivityWatchLocked(). virtual void ProcessConnectivityChangeLocked( grpc_connectivity_state connectivity_state) GRPC_ABSTRACT; + private: + // Watcher for subchannel connectivity state. + class Watcher : public Subchannel::ConnectivityStateWatcher { + public: + Watcher( + SubchannelData* subchannel_data, + RefCountedPtr subchannel_list) + : subchannel_data_(subchannel_data), + subchannel_list_(std::move(subchannel_list)) {} + + ~Watcher() { subchannel_list_.reset(DEBUG_LOCATION, "Watcher dtor"); } + + void OnConnectivityStateChange( + grpc_connectivity_state new_state, + RefCountedPtr connected_subchannel) override; + + grpc_pollset_set* interested_parties() override { + return subchannel_list_->policy()->interested_parties(); + } + + private: + // A fire-and-forget class that bounces into the combiner to process + // a connectivity state update. + class Updater { + public: + Updater( + SubchannelData* + subchannel_data, + RefCountedPtr> + subchannel_list, + grpc_connectivity_state state, + RefCountedPtr connected_subchannel); + + ~Updater() { + subchannel_list_.reset(DEBUG_LOCATION, "Watcher::Updater dtor"); + } + + private: + static void OnUpdateLocked(void* arg, grpc_error* error); + + SubchannelData* subchannel_data_; + RefCountedPtr> + subchannel_list_; + const grpc_connectivity_state state_; + RefCountedPtr connected_subchannel_; + grpc_closure closure_; + }; + + SubchannelData* subchannel_data_; + RefCountedPtr subchannel_list_; + }; + // Unrefs the subchannel. void UnrefSubchannelLocked(const char* reason); - private: - // Updates connected_subchannel_ based on pending_connectivity_state_unsafe_. - // Returns true if the connectivity state should be reported. - bool UpdateConnectedSubchannelLocked(); - - static void OnConnectivityChangedLocked(void* arg, grpc_error* error); - // Backpointer to owning subchannel list. Not owned. SubchannelList* subchannel_list_; - - // The subchannel and connected subchannel. + // The subchannel. Subchannel* subchannel_; + // Will be non-null when the subchannel's state is being watched. + Subchannel::ConnectivityStateWatcher* pending_watcher_ = nullptr; + // Data updated by the watcher. + grpc_connectivity_state connectivity_state_; RefCountedPtr connected_subchannel_; - - // Notification that connectivity has changed on subchannel. - grpc_closure connectivity_changed_closure_; - // Is a connectivity notification pending? - bool connectivity_notification_pending_ = false; - // Connectivity state to be updated by - // grpc_subchannel_notify_on_state_change(), not guarded by - // the combiner. - grpc_connectivity_state pending_connectivity_state_unsafe_; }; // A list of subchannels. @@ -213,7 +235,9 @@ class SubchannelList : public InternallyRefCounted { // Accessors. LoadBalancingPolicy* policy() const { return policy_; } TraceFlag* tracer() const { return tracer_; } - bool inhibit_health_checking() const { return inhibit_health_checking_; } + const char* health_check_service_name() const { + return health_check_service_name_.get(); + } // Resets connection backoff of all subchannels. // TODO(roth): We will probably need to rethink this as part of moving @@ -251,7 +275,7 @@ class SubchannelList : public InternallyRefCounted { TraceFlag* tracer_; - bool inhibit_health_checking_; + UniquePtr health_check_service_name_; grpc_combiner* combiner_; @@ -268,6 +292,67 @@ class SubchannelList : public InternallyRefCounted { // implementation -- no user-servicable parts below // +// +// SubchannelData::Watcher +// + +template +void SubchannelData::Watcher:: + OnConnectivityStateChange( + grpc_connectivity_state new_state, + RefCountedPtr connected_subchannel) { + // Will delete itself. + New(subchannel_data_, + subchannel_list_->Ref(DEBUG_LOCATION, "Watcher::Updater"), + new_state, std::move(connected_subchannel)); +} + +template +SubchannelData::Watcher::Updater:: + Updater( + SubchannelData* subchannel_data, + RefCountedPtr> + subchannel_list, + grpc_connectivity_state state, + RefCountedPtr connected_subchannel) + : subchannel_data_(subchannel_data), + subchannel_list_(std::move(subchannel_list)), + state_(state), + connected_subchannel_(std::move(connected_subchannel)) { + GRPC_CLOSURE_INIT(&closure_, &OnUpdateLocked, this, + grpc_combiner_scheduler(subchannel_list_->combiner_)); + GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE); +} + +template +void SubchannelData::Watcher::Updater:: + OnUpdateLocked(void* arg, grpc_error* error) { + Updater* self = static_cast(arg); + SubchannelData* sd = self->subchannel_data_; + if (GRPC_TRACE_FLAG_ENABLED(*sd->subchannel_list_->tracer())) { + gpr_log(GPR_INFO, + "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR + " (subchannel %p): connectivity changed: state=%s, " + "connected_subchannel=%p, shutting_down=%d, pending_watcher=%p", + sd->subchannel_list_->tracer()->name(), + sd->subchannel_list_->policy(), sd->subchannel_list_, sd->Index(), + sd->subchannel_list_->num_subchannels(), sd->subchannel_, + grpc_connectivity_state_name(self->state_), + self->connected_subchannel_.get(), + sd->subchannel_list_->shutting_down(), sd->pending_watcher_); + } + if (!sd->subchannel_list_->shutting_down() && + sd->pending_watcher_ != nullptr) { + sd->connectivity_state_ = self->state_; + // Get or release ref to connected subchannel. + sd->connected_subchannel_ = std::move(self->connected_subchannel_); + // Call the subclass's ProcessConnectivityChangeLocked() method. + sd->ProcessConnectivityChangeLocked(sd->connectivity_state_); + } + // Clean up. + Delete(self); +} + // // SubchannelData // @@ -275,23 +360,16 @@ class SubchannelList : public InternallyRefCounted { template SubchannelData::SubchannelData( SubchannelList* subchannel_list, - const ServerAddress& address, Subchannel* subchannel, - grpc_combiner* combiner) + const ServerAddress& address, Subchannel* subchannel) : subchannel_list_(subchannel_list), subchannel_(subchannel), // We assume that the current state is IDLE. If not, we'll get a // callback telling us that. - pending_connectivity_state_unsafe_(GRPC_CHANNEL_IDLE) { - GRPC_CLOSURE_INIT( - &connectivity_changed_closure_, - (&SubchannelData::OnConnectivityChangedLocked), - this, grpc_combiner_scheduler(combiner)); -} + connectivity_state_(GRPC_CHANNEL_IDLE) {} template SubchannelData::~SubchannelData() { - UnrefSubchannelLocked("subchannel_data_destroy"); + GPR_ASSERT(subchannel_ == nullptr); } template @@ -326,56 +404,19 @@ void SubchannelDatatracer())) { gpr_log(GPR_INFO, "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR - " (subchannel %p): starting watch: requesting connectivity change " - "notification (from %s)", + " (subchannel %p): starting watch (from %s)", subchannel_list_->tracer()->name(), subchannel_list_->policy(), subchannel_list_, Index(), subchannel_list_->num_subchannels(), - subchannel_, - grpc_connectivity_state_name(pending_connectivity_state_unsafe_)); + subchannel_, grpc_connectivity_state_name(connectivity_state_)); } - GPR_ASSERT(!connectivity_notification_pending_); - connectivity_notification_pending_ = true; - subchannel_list()->Ref(DEBUG_LOCATION, "connectivity_watch").release(); - subchannel_->NotifyOnStateChange( - subchannel_list_->policy()->interested_parties(), - &pending_connectivity_state_unsafe_, &connectivity_changed_closure_, - subchannel_list_->inhibit_health_checking()); -} - -template -void SubchannelData::RenewConnectivityWatchLocked() { - if (GRPC_TRACE_FLAG_ENABLED(*subchannel_list_->tracer())) { - gpr_log(GPR_INFO, - "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR - " (subchannel %p): renewing watch: requesting connectivity change " - "notification (from %s)", - subchannel_list_->tracer()->name(), subchannel_list_->policy(), - subchannel_list_, Index(), subchannel_list_->num_subchannels(), - subchannel_, - grpc_connectivity_state_name(pending_connectivity_state_unsafe_)); - } - GPR_ASSERT(connectivity_notification_pending_); - subchannel_->NotifyOnStateChange( - subchannel_list_->policy()->interested_parties(), - &pending_connectivity_state_unsafe_, &connectivity_changed_closure_, - subchannel_list_->inhibit_health_checking()); -} - -template -void SubchannelData::StopConnectivityWatchLocked() { - if (GRPC_TRACE_FLAG_ENABLED(*subchannel_list_->tracer())) { - gpr_log(GPR_INFO, - "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR - " (subchannel %p): stopping connectivity watch", - subchannel_list_->tracer()->name(), subchannel_list_->policy(), - subchannel_list_, Index(), subchannel_list_->num_subchannels(), - subchannel_); - } - GPR_ASSERT(connectivity_notification_pending_); - connectivity_notification_pending_ = false; - subchannel_list()->Unref(DEBUG_LOCATION, "connectivity_watch"); + GPR_ASSERT(pending_watcher_ == nullptr); + pending_watcher_ = + New(this, subchannel_list()->Ref(DEBUG_LOCATION, "Watcher")); + subchannel_->WatchConnectivityState( + connectivity_state_, + UniquePtr( + gpr_strdup(subchannel_list_->health_check_service_name())), + UniquePtr(pending_watcher_)); } template @@ -389,91 +430,17 @@ void SubchannelData:: subchannel_list_, Index(), subchannel_list_->num_subchannels(), subchannel_, reason); } - GPR_ASSERT(connectivity_notification_pending_); - subchannel_->NotifyOnStateChange(nullptr, nullptr, - &connectivity_changed_closure_, - subchannel_list_->inhibit_health_checking()); -} - -template -bool SubchannelData::UpdateConnectedSubchannelLocked() { - // If the subchannel is READY, take a ref to the connected subchannel. - if (pending_connectivity_state_unsafe_ == GRPC_CHANNEL_READY) { - connected_subchannel_ = subchannel_->connected_subchannel(); - // If the subchannel became disconnected between the time that READY - // was reported and the time we got here (e.g., between when a - // notification callback is scheduled and when it was actually run in - // the combiner), then the connected subchannel may have disappeared out - // from under us. In that case, we don't actually want to consider the - // subchannel to be in state READY. Instead, we use IDLE as the - // basis for any future connectivity watch; this is the one state that - // the subchannel will never transition back into, so this ensures - // that we will get a notification for the next state, even if that state - // is READY again (e.g., if the subchannel has transitioned back to - // READY before the next watch gets requested). - if (connected_subchannel_ == nullptr) { - if (GRPC_TRACE_FLAG_ENABLED(*subchannel_list_->tracer())) { - gpr_log(GPR_INFO, - "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR - " (subchannel %p): state is READY but connected subchannel is " - "null; moving to state IDLE", - subchannel_list_->tracer()->name(), subchannel_list_->policy(), - subchannel_list_, Index(), subchannel_list_->num_subchannels(), - subchannel_); - } - pending_connectivity_state_unsafe_ = GRPC_CHANNEL_IDLE; - return false; - } - } else { - // For any state other than READY, unref the connected subchannel. - connected_subchannel_.reset(); + if (pending_watcher_ != nullptr) { + subchannel_->CancelConnectivityStateWatch( + subchannel_list_->health_check_service_name(), pending_watcher_); + pending_watcher_ = nullptr; } - return true; -} - -template -void SubchannelData:: - OnConnectivityChangedLocked(void* arg, grpc_error* error) { - SubchannelData* sd = static_cast(arg); - if (GRPC_TRACE_FLAG_ENABLED(*sd->subchannel_list_->tracer())) { - gpr_log( - GPR_INFO, - "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR - " (subchannel %p): connectivity changed: state=%s, error=%s, " - "shutting_down=%d", - sd->subchannel_list_->tracer()->name(), sd->subchannel_list_->policy(), - sd->subchannel_list_, sd->Index(), - sd->subchannel_list_->num_subchannels(), sd->subchannel_, - grpc_connectivity_state_name(sd->pending_connectivity_state_unsafe_), - grpc_error_string(error), sd->subchannel_list_->shutting_down()); - } - // If shutting down, unref subchannel and stop watching. - if (sd->subchannel_list_->shutting_down() || error == GRPC_ERROR_CANCELLED) { - sd->UnrefSubchannelLocked("connectivity_shutdown"); - sd->StopConnectivityWatchLocked(); - return; - } - // Get or release ref to connected subchannel. - if (!sd->UpdateConnectedSubchannelLocked()) { - // We don't want to report this connectivity state, so renew the watch. - sd->RenewConnectivityWatchLocked(); - return; - } - // Call the subclass's ProcessConnectivityChangeLocked() method. - sd->ProcessConnectivityChangeLocked(sd->pending_connectivity_state_unsafe_); } template void SubchannelData::ShutdownLocked() { - // If there's a pending notification for this subchannel, cancel it; - // the callback is responsible for unreffing the subchannel. - // Otherwise, unref the subchannel directly. - if (connectivity_notification_pending_) { - CancelConnectivityWatchLocked("shutdown"); - } else if (subchannel_ != nullptr) { - UnrefSubchannelLocked("shutdown"); - } + if (pending_watcher_ != nullptr) CancelConnectivityWatchLocked("shutdown"); + UnrefSubchannelLocked("shutdown"); } // @@ -496,14 +463,25 @@ SubchannelList::SubchannelList( tracer_->name(), policy, this, addresses.size()); } subchannels_.reserve(addresses.size()); + // Find health check service name. + const bool inhibit_health_checking = grpc_channel_arg_get_bool( + grpc_channel_args_find(&args, GRPC_ARG_INHIBIT_HEALTH_CHECKING), false); + if (!inhibit_health_checking) { + const char* health_check_service_name = grpc_channel_arg_get_string( + grpc_channel_args_find(&args, "grpc.temp.health_check")); + if (health_check_service_name != nullptr) { + health_check_service_name_.reset(gpr_strdup(health_check_service_name)); + } + } // We need to remove the LB addresses in order to be able to compare the // subchannel keys of subchannels from a different batch of addresses. - // We also remove the inhibit-health-checking arg, since we are + // We also remove the health-checking-related args, since we are // handling that here. - inhibit_health_checking_ = grpc_channel_arg_get_bool( - grpc_channel_args_find(&args, GRPC_ARG_INHIBIT_HEALTH_CHECKING), false); - static const char* keys_to_remove[] = {GRPC_ARG_SUBCHANNEL_ADDRESS, - GRPC_ARG_INHIBIT_HEALTH_CHECKING}; + // We remove the service config, since it will be passed into the + // subchannel via call context. + static const char* keys_to_remove[] = { + GRPC_ARG_SUBCHANNEL_ADDRESS, "grpc.temp.health_check", + GRPC_ARG_INHIBIT_HEALTH_CHECKING, GRPC_ARG_SERVICE_CONFIG}; // Create a subchannel for each address. for (size_t i = 0; i < addresses.size(); i++) { // TODO(roth): we should ideally hide this from the LB policy code. In @@ -549,7 +527,7 @@ SubchannelList::SubchannelList( address_uri); gpr_free(address_uri); } - subchannels_.emplace_back(this, addresses[i], subchannel, combiner); + subchannels_.emplace_back(this, addresses[i], subchannel); } } diff --git a/src/core/ext/filters/client_channel/resolving_lb_policy.cc b/src/core/ext/filters/client_channel/resolving_lb_policy.cc index b6bc3eabc49..4e383f65dd1 100644 --- a/src/core/ext/filters/client_channel/resolving_lb_policy.cc +++ b/src/core/ext/filters/client_channel/resolving_lb_policy.cc @@ -536,7 +536,7 @@ void ResolvingLoadBalancingPolicy::OnResolverResultChangedLocked( if (process_resolver_result_ != nullptr) { grpc_error* service_config_error = GRPC_ERROR_NONE; service_config_changed = process_resolver_result_( - process_resolver_result_user_data_, result, &lb_policy_name, + process_resolver_result_user_data_, &result, &lb_policy_name, &lb_policy_config, &service_config_error); if (service_config_error != GRPC_ERROR_NONE) { service_config_error_string = diff --git a/src/core/ext/filters/client_channel/resolving_lb_policy.h b/src/core/ext/filters/client_channel/resolving_lb_policy.h index b7d99dcc7de..0ca6c9563f9 100644 --- a/src/core/ext/filters/client_channel/resolving_lb_policy.h +++ b/src/core/ext/filters/client_channel/resolving_lb_policy.h @@ -69,8 +69,7 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy { // empty, it means that we don't have a valid service config to use, and we // should set the channel to be in TRANSIENT_FAILURE. typedef bool (*ProcessResolverResultCallback)( - void* user_data, const Resolver::Result& result, - const char** lb_policy_name, + void* user_data, Resolver::Result* result, const char** lb_policy_name, RefCountedPtr* lb_policy_config, grpc_error** service_config_error); // If error is set when this returns, then construction failed, and diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index a284e692b09..cd778976166 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -303,8 +303,7 @@ void SubchannelCall::IncrementRefCount(const grpc_core::DebugLocation& location, // Subchannel::ConnectedSubchannelStateWatcher // -class Subchannel::ConnectedSubchannelStateWatcher - : public InternallyRefCounted { +class Subchannel::ConnectedSubchannelStateWatcher { public: // Must be instantiated while holding c->mu. explicit ConnectedSubchannelStateWatcher(Subchannel* c) : subchannel_(c) { @@ -312,38 +311,17 @@ class Subchannel::ConnectedSubchannelStateWatcher GRPC_SUBCHANNEL_WEAK_REF(subchannel_, "state_watcher"); GRPC_SUBCHANNEL_WEAK_UNREF(subchannel_, "connecting"); // Start watching for connectivity state changes. - // Callback uses initial ref to this. GRPC_CLOSURE_INIT(&on_connectivity_changed_, OnConnectivityChanged, this, grpc_schedule_on_exec_ctx); c->connected_subchannel_->NotifyOnStateChange(c->pollset_set_, &pending_connectivity_state_, &on_connectivity_changed_); - // Start health check if needed. - grpc_connectivity_state health_state = GRPC_CHANNEL_READY; - if (c->health_check_service_name_ != nullptr) { - health_check_client_ = MakeOrphanable( - c->health_check_service_name_.get(), c->connected_subchannel_, - c->pollset_set_, c->channelz_node_); - GRPC_CLOSURE_INIT(&on_health_changed_, OnHealthChanged, this, - grpc_schedule_on_exec_ctx); - Ref().release(); // Ref for health callback tracked manually. - health_check_client_->NotifyOnHealthChange(&health_state_, - &on_health_changed_); - health_state = GRPC_CHANNEL_CONNECTING; - } - // Report initial state. - c->SetConnectivityStateLocked(GRPC_CHANNEL_READY, "subchannel_connected"); - grpc_connectivity_state_set(&c->state_and_health_tracker_, health_state, - "subchannel_connected"); } ~ConnectedSubchannelStateWatcher() { GRPC_SUBCHANNEL_WEAK_UNREF(subchannel_, "state_watcher"); } - // Must be called while holding subchannel_->mu. - void Orphan() override { health_check_client_.reset(); } - private: static void OnConnectivityChanged(void* arg, grpc_error* error) { auto* self = static_cast(arg); @@ -363,20 +341,10 @@ class Subchannel::ConnectedSubchannelStateWatcher self->pending_connectivity_state_)); } c->connected_subchannel_.reset(); - c->connected_subchannel_watcher_.reset(); - self->last_connectivity_state_ = GRPC_CHANNEL_TRANSIENT_FAILURE; - c->SetConnectivityStateLocked(GRPC_CHANNEL_TRANSIENT_FAILURE, - "reflect_child"); - grpc_connectivity_state_set(&c->state_and_health_tracker_, - GRPC_CHANNEL_TRANSIENT_FAILURE, - "reflect_child"); + c->SetConnectivityStateLocked(GRPC_CHANNEL_TRANSIENT_FAILURE); c->backoff_begun_ = false; c->backoff_.Reset(); - c->MaybeStartConnectingLocked(); - } else { - self->last_connectivity_state_ = GRPC_CHANNEL_SHUTDOWN; } - self->health_check_client_.reset(); break; } default: { @@ -384,96 +352,246 @@ class Subchannel::ConnectedSubchannelStateWatcher // a callback for READY, because that was the state we started // this watch from. And a connected subchannel should never go // from READY to CONNECTING or IDLE. - self->last_connectivity_state_ = self->pending_connectivity_state_; - c->SetConnectivityStateLocked(self->pending_connectivity_state_, - "reflect_child"); - if (self->pending_connectivity_state_ != GRPC_CHANNEL_READY) { - grpc_connectivity_state_set(&c->state_and_health_tracker_, - self->pending_connectivity_state_, - "reflect_child"); - } + c->SetConnectivityStateLocked(self->pending_connectivity_state_); c->connected_subchannel_->NotifyOnStateChange( nullptr, &self->pending_connectivity_state_, &self->on_connectivity_changed_); - self = nullptr; // So we don't unref below. + return; // So we don't delete ourself below. } } } - // Don't unref until we've released the lock, because this might + // Don't delete until we've released the lock, because this might // cause the subchannel (which contains the lock) to be destroyed. - if (self != nullptr) self->Unref(); - } - - static void OnHealthChanged(void* arg, grpc_error* error) { - auto* self = static_cast(arg); - Subchannel* c = self->subchannel_; - { - MutexLock lock(&c->mu_); - if (self->health_state_ != GRPC_CHANNEL_SHUTDOWN && - self->health_check_client_ != nullptr) { - if (self->last_connectivity_state_ == GRPC_CHANNEL_READY) { - grpc_connectivity_state_set(&c->state_and_health_tracker_, - self->health_state_, "health_changed"); - } - self->health_check_client_->NotifyOnHealthChange( - &self->health_state_, &self->on_health_changed_); - self = nullptr; // So we don't unref below. - } - } - // Don't unref until we've released the lock, because this might - // cause the subchannel (which contains the lock) to be destroyed. - if (self != nullptr) self->Unref(); + Delete(self); } Subchannel* subchannel_; grpc_closure on_connectivity_changed_; grpc_connectivity_state pending_connectivity_state_ = GRPC_CHANNEL_READY; - grpc_connectivity_state last_connectivity_state_ = GRPC_CHANNEL_READY; +}; + +// +// Subchannel::ConnectivityStateWatcherList +// + +void Subchannel::ConnectivityStateWatcherList::AddWatcherLocked( + UniquePtr watcher) { + watcher->next_ = head_; + head_ = watcher.release(); +} + +void Subchannel::ConnectivityStateWatcherList::RemoveWatcherLocked( + ConnectivityStateWatcher* watcher) { + for (ConnectivityStateWatcher** w = &head_; *w != nullptr; w = &(*w)->next_) { + if (*w == watcher) { + *w = watcher->next_; + Delete(watcher); + return; + } + } + GPR_UNREACHABLE_CODE(return ); +} + +void Subchannel::ConnectivityStateWatcherList::NotifyLocked( + Subchannel* subchannel, grpc_connectivity_state state) { + for (ConnectivityStateWatcher* w = head_; w != nullptr; w = w->next_) { + RefCountedPtr connected_subchannel; + if (state == GRPC_CHANNEL_READY) { + connected_subchannel = subchannel->connected_subchannel_; + } + // TODO(roth): In principle, it seems wrong to send this notification + // to the watcher while holding the subchannel's mutex, since it could + // lead to a deadlock if the watcher calls back into the subchannel + // before returning back to us. In practice, this doesn't happen, + // because the LB policy code that watches subchannels always bounces + // the notification into the client_channel control-plane combiner + // before processing it. But if we ever have any other callers here, + // we will probably need to change this. + w->OnConnectivityStateChange(state, std::move(connected_subchannel)); + } +} + +void Subchannel::ConnectivityStateWatcherList::Clear() { + while (head_ != nullptr) { + ConnectivityStateWatcher* next = head_->next_; + Delete(head_); + head_ = next; + } +} + +// +// Subchannel::HealthWatcherMap::HealthWatcher +// + +// State needed for tracking the connectivity state with a particular +// health check service name. +class Subchannel::HealthWatcherMap::HealthWatcher + : public InternallyRefCounted { + public: + HealthWatcher(Subchannel* c, UniquePtr health_check_service_name, + grpc_connectivity_state subchannel_state) + : subchannel_(c), + health_check_service_name_(std::move(health_check_service_name)), + state_(subchannel_state == GRPC_CHANNEL_READY ? GRPC_CHANNEL_CONNECTING + : subchannel_state) { + GRPC_SUBCHANNEL_WEAK_REF(subchannel_, "health_watcher"); + GRPC_CLOSURE_INIT(&on_health_changed_, OnHealthChanged, this, + grpc_schedule_on_exec_ctx); + // If the subchannel is already connected, start health checking. + if (subchannel_state == GRPC_CHANNEL_READY) StartHealthCheckingLocked(); + } + + ~HealthWatcher() { + GRPC_SUBCHANNEL_WEAK_UNREF(subchannel_, "health_watcher"); + } + + const char* health_check_service_name() const { + return health_check_service_name_.get(); + } + + grpc_connectivity_state state() const { return state_; } + + void AddWatcherLocked(grpc_connectivity_state initial_state, + UniquePtr watcher) { + if (state_ != initial_state) { + RefCountedPtr connected_subchannel; + if (state_ == GRPC_CHANNEL_READY) { + connected_subchannel = subchannel_->connected_subchannel_; + } + watcher->OnConnectivityStateChange(state_, + std::move(connected_subchannel)); + } + watcher_list_.AddWatcherLocked(std::move(watcher)); + } + + void RemoveWatcherLocked(ConnectivityStateWatcher* watcher) { + watcher_list_.RemoveWatcherLocked(watcher); + } + + bool HasWatchers() const { return !watcher_list_.empty(); } + + void NotifyLocked(grpc_connectivity_state state) { + if (state == GRPC_CHANNEL_READY) { + // If we had not already notified for CONNECTING state, do so now. + // (We may have missed this earlier, because if the transition + // from IDLE to CONNECTING to READY was too quick, the connected + // subchannel may not have sent us a notification for CONNECTING.) + if (state_ != GRPC_CHANNEL_CONNECTING) { + state_ = GRPC_CHANNEL_CONNECTING; + watcher_list_.NotifyLocked(subchannel_, state_); + } + // If we've become connected, start health checking. + StartHealthCheckingLocked(); + } else { + state_ = state; + watcher_list_.NotifyLocked(subchannel_, state_); + // We're not connected, so stop health checking. + health_check_client_.reset(); + } + } + + void Orphan() override { + watcher_list_.Clear(); + health_check_client_.reset(); + Unref(); + } + + private: + void StartHealthCheckingLocked() { + GPR_ASSERT(health_check_client_ == nullptr); + health_check_client_ = MakeOrphanable( + health_check_service_name_.get(), subchannel_->connected_subchannel_, + subchannel_->pollset_set_, subchannel_->channelz_node_); + Ref().release(); // Ref for health callback tracked manually. + health_check_client_->NotifyOnHealthChange(&state_, &on_health_changed_); + } + + static void OnHealthChanged(void* arg, grpc_error* error) { + auto* self = static_cast(arg); + Subchannel* c = self->subchannel_; + { + MutexLock lock(&c->mu_); + if (self->state_ != GRPC_CHANNEL_SHUTDOWN && + self->health_check_client_ != nullptr) { + self->watcher_list_.NotifyLocked(c, self->state_); + // Renew watch. + self->health_check_client_->NotifyOnHealthChange( + &self->state_, &self->on_health_changed_); + return; // So we don't unref below. + } + } + // Don't unref until we've released the lock, because this might + // cause the subchannel (which contains the lock) to be destroyed. + self->Unref(); + } + + Subchannel* subchannel_; + UniquePtr health_check_service_name_; OrphanablePtr health_check_client_; grpc_closure on_health_changed_; - grpc_connectivity_state health_state_ = GRPC_CHANNEL_CONNECTING; + grpc_connectivity_state state_; + ConnectivityStateWatcherList watcher_list_; }; // -// Subchannel::ExternalStateWatcher +// Subchannel::HealthWatcherMap // -struct Subchannel::ExternalStateWatcher { - ExternalStateWatcher(Subchannel* subchannel, grpc_pollset_set* pollset_set, - grpc_closure* notify) - : subchannel(subchannel), pollset_set(pollset_set), notify(notify) { - GRPC_SUBCHANNEL_WEAK_REF(subchannel, "external_state_watcher+init"); - GRPC_CLOSURE_INIT(&on_state_changed, OnStateChanged, this, - grpc_schedule_on_exec_ctx); +void Subchannel::HealthWatcherMap::AddWatcherLocked( + Subchannel* subchannel, grpc_connectivity_state initial_state, + UniquePtr health_check_service_name, + UniquePtr watcher) { + // If the health check service name is not already present in the map, + // add it. + auto it = map_.find(health_check_service_name.get()); + HealthWatcher* health_watcher; + if (it == map_.end()) { + const char* key = health_check_service_name.get(); + auto w = MakeOrphanable( + subchannel, std::move(health_check_service_name), subchannel->state_); + health_watcher = w.get(); + map_[key] = std::move(w); + } else { + health_watcher = it->second.get(); } + // Add the watcher to the entry. + health_watcher->AddWatcherLocked(initial_state, std::move(watcher)); +} - static void OnStateChanged(void* arg, grpc_error* error) { - ExternalStateWatcher* w = static_cast(arg); - grpc_closure* follow_up = w->notify; - if (w->pollset_set != nullptr) { - grpc_pollset_set_del_pollset_set(w->subchannel->pollset_set_, - w->pollset_set); - } - { - MutexLock lock(&w->subchannel->mu_); - if (w->subchannel->external_state_watcher_list_ == w) { - w->subchannel->external_state_watcher_list_ = w->next; - } - if (w->next != nullptr) w->next->prev = w->prev; - if (w->prev != nullptr) w->prev->next = w->next; - } - GRPC_SUBCHANNEL_WEAK_UNREF(w->subchannel, "external_state_watcher+done"); - Delete(w); - GRPC_CLOSURE_SCHED(follow_up, GRPC_ERROR_REF(error)); +void Subchannel::HealthWatcherMap::RemoveWatcherLocked( + const char* health_check_service_name, ConnectivityStateWatcher* watcher) { + auto it = map_.find(health_check_service_name); + GPR_ASSERT(it != map_.end()); + it->second->RemoveWatcherLocked(watcher); + // If we just removed the last watcher for this service name, remove + // the map entry. + if (!it->second->HasWatchers()) map_.erase(it); +} + +void Subchannel::HealthWatcherMap::NotifyLocked(grpc_connectivity_state state) { + for (const auto& p : map_) { + p.second->NotifyLocked(state); } +} - Subchannel* subchannel; - grpc_pollset_set* pollset_set; - grpc_closure* notify; - grpc_closure on_state_changed; - ExternalStateWatcher* next = nullptr; - ExternalStateWatcher* prev = nullptr; -}; +grpc_connectivity_state +Subchannel::HealthWatcherMap::CheckConnectivityStateLocked( + Subchannel* subchannel, const char* health_check_service_name) { + auto it = map_.find(health_check_service_name); + if (it == map_.end()) { + // If the health check service name is not found in the map, we're + // not currently doing a health check for that service name. If the + // subchannel's state without health checking is READY, report + // CONNECTING, since that's what we'd be in as soon as we do start a + // watch. Otherwise, report the channel's state without health checking. + return subchannel->state_ == GRPC_CHANNEL_READY ? GRPC_CHANNEL_CONNECTING + : subchannel->state_; + } + HealthWatcher* health_watcher = it->second.get(); + return health_watcher->state(); +} + +void Subchannel::HealthWatcherMap::ShutdownLocked() { map_.clear(); } // // Subchannel @@ -560,13 +678,6 @@ Subchannel::Subchannel(SubchannelKey* key, grpc_connector* connector, if (new_args != nullptr) grpc_channel_args_destroy(new_args); GRPC_CLOSURE_INIT(&on_connecting_finished_, OnConnectingFinished, this, grpc_schedule_on_exec_ctx); - grpc_connectivity_state_init(&state_tracker_, GRPC_CHANNEL_IDLE, - "subchannel"); - grpc_connectivity_state_init(&state_and_health_tracker_, GRPC_CHANNEL_IDLE, - "subchannel"); - health_check_service_name_ = - UniquePtr(gpr_strdup(grpc_channel_arg_get_string( - grpc_channel_args_find(args_, "grpc.temp.health_check")))); const grpc_arg* arg = grpc_channel_args_find(args_, GRPC_ARG_ENABLE_CHANNELZ); const bool channelz_enabled = grpc_channel_arg_get_bool(arg, GRPC_ENABLE_CHANNELZ_DEFAULT); @@ -593,8 +704,6 @@ Subchannel::~Subchannel() { channelz_node_->MarkSubchannelDestroyed(); } grpc_channel_args_destroy(args_); - grpc_connectivity_state_destroy(&state_tracker_); - grpc_connectivity_state_destroy(&state_and_health_tracker_); grpc_connector_unref(connector_); grpc_pollset_set_destroy(pollset_set_); Delete(key_); @@ -698,53 +807,65 @@ const char* Subchannel::GetTargetAddress() { return addr_str; } -RefCountedPtr Subchannel::connected_subchannel() { - MutexLock lock(&mu_); - return connected_subchannel_; -} - channelz::SubchannelNode* Subchannel::channelz_node() { return channelz_node_.get(); } -grpc_connectivity_state Subchannel::CheckConnectivity( - bool inhibit_health_checking) { - grpc_connectivity_state_tracker* tracker = - inhibit_health_checking ? &state_tracker_ : &state_and_health_tracker_; - grpc_connectivity_state state = grpc_connectivity_state_check(tracker); +grpc_connectivity_state Subchannel::CheckConnectivityState( + const char* health_check_service_name, + RefCountedPtr* connected_subchannel) { + MutexLock lock(&mu_); + grpc_connectivity_state state; + if (health_check_service_name == nullptr) { + state = state_; + } else { + state = health_watcher_map_.CheckConnectivityStateLocked( + this, health_check_service_name); + } + if (connected_subchannel != nullptr && state == GRPC_CHANNEL_READY) { + *connected_subchannel = connected_subchannel_; + } return state; } -void Subchannel::NotifyOnStateChange(grpc_pollset_set* interested_parties, - grpc_connectivity_state* state, - grpc_closure* notify, - bool inhibit_health_checking) { - grpc_connectivity_state_tracker* tracker = - inhibit_health_checking ? &state_tracker_ : &state_and_health_tracker_; - ExternalStateWatcher* w; - if (state == nullptr) { - MutexLock lock(&mu_); - for (w = external_state_watcher_list_; w != nullptr; w = w->next) { - if (w->notify == notify) { - grpc_connectivity_state_notify_on_state_change(tracker, nullptr, - &w->on_state_changed); - } - } - } else { - w = New(this, interested_parties, notify); - if (interested_parties != nullptr) { - grpc_pollset_set_add_pollset_set(pollset_set_, interested_parties); - } - MutexLock lock(&mu_); - if (external_state_watcher_list_ != nullptr) { - w->next = external_state_watcher_list_; - w->next->prev = w; - } - external_state_watcher_list_ = w; - grpc_connectivity_state_notify_on_state_change(tracker, state, - &w->on_state_changed); - MaybeStartConnectingLocked(); +void Subchannel::WatchConnectivityState( + grpc_connectivity_state initial_state, + UniquePtr health_check_service_name, + UniquePtr watcher) { + MutexLock lock(&mu_); + grpc_pollset_set* interested_parties = watcher->interested_parties(); + if (interested_parties != nullptr) { + grpc_pollset_set_add_pollset_set(pollset_set_, interested_parties); } + if (health_check_service_name == nullptr) { + if (state_ != initial_state) { + watcher->OnConnectivityStateChange(state_, connected_subchannel_); + } + watcher_list_.AddWatcherLocked(std::move(watcher)); + } else { + health_watcher_map_.AddWatcherLocked(this, initial_state, + std::move(health_check_service_name), + std::move(watcher)); + } +} + +void Subchannel::CancelConnectivityStateWatch( + const char* health_check_service_name, ConnectivityStateWatcher* watcher) { + MutexLock lock(&mu_); + grpc_pollset_set* interested_parties = watcher->interested_parties(); + if (interested_parties != nullptr) { + grpc_pollset_set_del_pollset_set(pollset_set_, interested_parties); + } + if (health_check_service_name == nullptr) { + watcher_list_.RemoveWatcherLocked(watcher); + } else { + health_watcher_map_.RemoveWatcherLocked(health_check_service_name, watcher); + } +} + +void Subchannel::AttemptToConnect() { + MutexLock lock(&mu_); + MaybeStartConnectingLocked(); } void Subchannel::ResetBackoff() { @@ -818,15 +939,19 @@ const char* SubchannelConnectivityStateChangeString( } // namespace -void Subchannel::SetConnectivityStateLocked(grpc_connectivity_state state, - const char* reason) { +// Note: Must be called with a state that is different from the current state. +void Subchannel::SetConnectivityStateLocked(grpc_connectivity_state state) { + state_ = state; if (channelz_node_ != nullptr) { channelz_node_->AddTraceEvent( channelz::ChannelTrace::Severity::Info, grpc_slice_from_static_string( SubchannelConnectivityStateChangeString(state))); } - grpc_connectivity_state_set(&state_tracker_, state, reason); + // Notify non-health watchers. + watcher_list_.NotifyLocked(this, state); + // Notify health watchers. + health_watcher_map_.NotifyLocked(state); } void Subchannel::MaybeStartConnectingLocked() { @@ -842,11 +967,6 @@ void Subchannel::MaybeStartConnectingLocked() { // Already connected: don't restart. return; } - if (!grpc_connectivity_state_has_watchers(&state_tracker_) && - !grpc_connectivity_state_has_watchers(&state_and_health_tracker_)) { - // Nobody is interested in connecting: so don't just yet. - return; - } connecting_ = true; GRPC_SUBCHANNEL_WEAK_REF(this, "connecting"); if (!backoff_begun_) { @@ -903,9 +1023,7 @@ void Subchannel::ContinueConnectingLocked() { next_attempt_deadline_ = backoff_.NextAttemptTime(); args.deadline = std::max(next_attempt_deadline_, min_deadline); args.channel_args = args_; - SetConnectivityStateLocked(GRPC_CHANNEL_CONNECTING, "connecting"); - grpc_connectivity_state_set(&state_and_health_tracker_, - GRPC_CHANNEL_CONNECTING, "connecting"); + SetConnectivityStateLocked(GRPC_CHANNEL_CONNECTING); grpc_connector_connect(connector_, &args, &connecting_result_, &on_connecting_finished_); } @@ -924,12 +1042,7 @@ void Subchannel::OnConnectingFinished(void* arg, grpc_error* error) { GRPC_SUBCHANNEL_WEAK_UNREF(c, "connecting"); } else { gpr_log(GPR_INFO, "Connect failed: %s", grpc_error_string(error)); - c->SetConnectivityStateLocked(GRPC_CHANNEL_TRANSIENT_FAILURE, - "connect_failed"); - grpc_connectivity_state_set(&c->state_and_health_tracker_, - GRPC_CHANNEL_TRANSIENT_FAILURE, - "connect_failed"); - c->MaybeStartConnectingLocked(); + c->SetConnectivityStateLocked(GRPC_CHANNEL_TRANSIENT_FAILURE); GRPC_SUBCHANNEL_WEAK_UNREF(c, "connecting"); } } @@ -982,8 +1095,9 @@ bool Subchannel::PublishTransportLocked() { gpr_log(GPR_INFO, "New connected subchannel at %p for subchannel %p", connected_subchannel_.get(), this); // Instantiate state watcher. Will clean itself up. - connected_subchannel_watcher_ = - MakeOrphanable(this); + New(this); + // Report initial state. + SetConnectivityStateLocked(GRPC_CHANNEL_READY); return true; } @@ -1000,7 +1114,7 @@ void Subchannel::Disconnect() { grpc_connector_shutdown(connector_, GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Subchannel disconnected")); connected_subchannel_.reset(); - connected_subchannel_watcher_.reset(); + health_watcher_map_.ShutdownLocked(); } gpr_atm Subchannel::RefMutate( diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h index e3efc8900ae..e0741bb28fa 100644 --- a/src/core/ext/filters/client_channel/subchannel.h +++ b/src/core/ext/filters/client_channel/subchannel.h @@ -27,6 +27,7 @@ #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/gprpp/arena.h" +#include "src/core/lib/gprpp/map.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/sync.h" @@ -77,7 +78,7 @@ class ConnectedSubchannel : public RefCounted { grpc_millis deadline; Arena* arena; grpc_call_context_element* context; - grpc_core::CallCombiner* call_combiner; + CallCombiner* call_combiner; size_t parent_data_size; }; @@ -175,7 +176,38 @@ class SubchannelCall { // A subchannel that knows how to connect to exactly one target address. It // provides a target for load balancing. class Subchannel { + private: + class ConnectivityStateWatcherList; // Forward declaration. + public: + class ConnectivityStateWatcher { + public: + virtual ~ConnectivityStateWatcher() = default; + + // Will be invoked whenever the subchannel's connectivity state + // changes. There will be only one invocation of this method on a + // given watcher instance at any given time. + // + // When the state changes to READY, connected_subchannel will + // contain a ref to the connected subchannel. When it changes from + // READY to some other state, the implementation must release its + // ref to the connected subchannel. + virtual void OnConnectivityStateChange( + grpc_connectivity_state new_state, + RefCountedPtr connected_subchannel) // NOLINT + GRPC_ABSTRACT; + + virtual grpc_pollset_set* interested_parties() GRPC_ABSTRACT; + + GRPC_ABSTRACT_BASE_CLASS + + private: + // For access to next_. + friend class Subchannel::ConnectivityStateWatcherList; + + ConnectivityStateWatcher* next_ = nullptr; + }; + // The ctor and dtor are not intended to use directly. Subchannel(SubchannelKey* key, grpc_connector* connector, const grpc_channel_args* args); @@ -201,20 +233,36 @@ class Subchannel { // Caller doesn't take ownership. const char* GetTargetAddress(); - // Gets the connected subchannel - or nullptr if not connected (which may - // happen before it initially connects or during transient failures). - RefCountedPtr connected_subchannel(); - channelz::SubchannelNode* channelz_node(); - // Polls the current connectivity state of the subchannel. - grpc_connectivity_state CheckConnectivity(bool inhibit_health_checking); + // Returns the current connectivity state of the subchannel. + // If health_check_service_name is non-null, the returned connectivity + // state will be based on the state reported by the backend for that + // service name. + // If the return value is GRPC_CHANNEL_READY, also sets *connected_subchannel. + grpc_connectivity_state CheckConnectivityState( + const char* health_check_service_name, + RefCountedPtr* connected_subchannel); - // When the connectivity state of the subchannel changes from \a *state, - // invokes \a notify and updates \a *state with the new state. - void NotifyOnStateChange(grpc_pollset_set* interested_parties, - grpc_connectivity_state* state, grpc_closure* notify, - bool inhibit_health_checking); + // Starts watching the subchannel's connectivity state. + // The first callback to the watcher will be delivered when the + // subchannel's connectivity state becomes a value other than + // initial_state, which may happen immediately. + // Subsequent callbacks will be delivered as the subchannel's state + // changes. + // The watcher will be destroyed either when the subchannel is + // destroyed or when CancelConnectivityStateWatch() is called. + void WatchConnectivityState(grpc_connectivity_state initial_state, + UniquePtr health_check_service_name, + UniquePtr watcher); + + // Cancels a connectivity state watch. + // If the watcher has already been destroyed, this is a no-op. + void CancelConnectivityStateWatch(const char* health_check_service_name, + ConnectivityStateWatcher* watcher); + + // Attempt to connect to the backend. Has no effect if already connected. + void AttemptToConnect(); // Resets the connection backoff of the subchannel. // TODO(roth): Move connection backoff out of subchannels and up into LB @@ -236,12 +284,62 @@ class Subchannel { grpc_resolved_address* addr); private: - struct ExternalStateWatcher; + // A linked list of ConnectivityStateWatchers that are monitoring the + // subchannel's state. + class ConnectivityStateWatcherList { + public: + ~ConnectivityStateWatcherList() { Clear(); } + + void AddWatcherLocked(UniquePtr watcher); + void RemoveWatcherLocked(ConnectivityStateWatcher* watcher); + + // Notifies all watchers in the list about a change to state. + void NotifyLocked(Subchannel* subchannel, grpc_connectivity_state state); + + void Clear(); + + bool empty() const { return head_ == nullptr; } + + private: + ConnectivityStateWatcher* head_ = nullptr; + }; + + // A map that tracks ConnectivityStateWatchers using a particular health + // check service name. + // + // There is one entry in the map for each health check service name. + // Entries exist only as long as there are watchers using the + // corresponding service name. + // + // A health check client is maintained only while the subchannel is in + // state READY. + class HealthWatcherMap { + public: + void AddWatcherLocked(Subchannel* subchannel, + grpc_connectivity_state initial_state, + UniquePtr health_check_service_name, + UniquePtr watcher); + void RemoveWatcherLocked(const char* health_check_service_name, + ConnectivityStateWatcher* watcher); + + // Notifies the watcher when the subchannel's state changes. + void NotifyLocked(grpc_connectivity_state state); + + grpc_connectivity_state CheckConnectivityStateLocked( + Subchannel* subchannel, const char* health_check_service_name); + + void ShutdownLocked(); + + private: + class HealthWatcher; + + Map, StringLess> map_; + }; + class ConnectedSubchannelStateWatcher; // Sets the subchannel's connectivity state to \a state. - void SetConnectivityStateLocked(grpc_connectivity_state state, - const char* reason); + void SetConnectivityStateLocked(grpc_connectivity_state state); // Methods for connection. void MaybeStartConnectingLocked(); @@ -279,15 +377,15 @@ class Subchannel { grpc_closure on_connecting_finished_; // Active connection, or null. RefCountedPtr connected_subchannel_; - OrphanablePtr connected_subchannel_watcher_; bool connecting_ = false; bool disconnected_ = false; // Connectivity state tracking. - grpc_connectivity_state_tracker state_tracker_; - grpc_connectivity_state_tracker state_and_health_tracker_; - UniquePtr health_check_service_name_; - ExternalStateWatcher* external_state_watcher_list_ = nullptr; + grpc_connectivity_state state_ = GRPC_CHANNEL_IDLE; + // The list of watchers without a health check service name. + ConnectivityStateWatcherList watcher_list_; + // The map of watchers with health check service names. + HealthWatcherMap health_watcher_map_; // Backoff state. BackOff backoff_; diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index 766c38a64a1..b623348e13f 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -1019,8 +1019,8 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) { auto channel = BuildChannel("round_robin"); auto stub = BuildStub(channel); std::vector ports; - // Start with a single server. + gpr_log(GPR_INFO, "*** FIRST BACKEND ***"); ports.emplace_back(servers_[0]->port_); SetNextResolution(ports); WaitForServer(stub, 0, DEBUG_LOCATION); @@ -1030,36 +1030,33 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) { EXPECT_EQ(0, servers_[1]->service_.request_count()); EXPECT_EQ(0, servers_[2]->service_.request_count()); servers_[0]->service_.ResetCounters(); - // And now for the second server. + gpr_log(GPR_INFO, "*** SECOND BACKEND ***"); ports.clear(); ports.emplace_back(servers_[1]->port_); SetNextResolution(ports); - // Wait until update has been processed, as signaled by the second backend // receiving a request. EXPECT_EQ(0, servers_[1]->service_.request_count()); WaitForServer(stub, 1, DEBUG_LOCATION); - for (size_t i = 0; i < 10; ++i) CheckRpcSendOk(stub, DEBUG_LOCATION); EXPECT_EQ(0, servers_[0]->service_.request_count()); EXPECT_EQ(10, servers_[1]->service_.request_count()); EXPECT_EQ(0, servers_[2]->service_.request_count()); servers_[1]->service_.ResetCounters(); - // ... and for the last server. + gpr_log(GPR_INFO, "*** THIRD BACKEND ***"); ports.clear(); ports.emplace_back(servers_[2]->port_); SetNextResolution(ports); WaitForServer(stub, 2, DEBUG_LOCATION); - for (size_t i = 0; i < 10; ++i) CheckRpcSendOk(stub, DEBUG_LOCATION); EXPECT_EQ(0, servers_[0]->service_.request_count()); EXPECT_EQ(0, servers_[1]->service_.request_count()); EXPECT_EQ(10, servers_[2]->service_.request_count()); servers_[2]->service_.ResetCounters(); - // Back to all servers. + gpr_log(GPR_INFO, "*** ALL BACKENDS ***"); ports.clear(); ports.emplace_back(servers_[0]->port_); ports.emplace_back(servers_[1]->port_); @@ -1068,14 +1065,13 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) { WaitForServer(stub, 0, DEBUG_LOCATION); WaitForServer(stub, 1, DEBUG_LOCATION); WaitForServer(stub, 2, DEBUG_LOCATION); - // Send three RPCs, one per server. for (size_t i = 0; i < 3; ++i) CheckRpcSendOk(stub, DEBUG_LOCATION); EXPECT_EQ(1, servers_[0]->service_.request_count()); EXPECT_EQ(1, servers_[1]->service_.request_count()); EXPECT_EQ(1, servers_[2]->service_.request_count()); - // An empty update will result in the channel going into TRANSIENT_FAILURE. + gpr_log(GPR_INFO, "*** NO BACKENDS ***"); ports.clear(); SetNextResolution(ports); grpc_connectivity_state channel_state; @@ -1084,15 +1080,14 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) { } while (channel_state == GRPC_CHANNEL_READY); ASSERT_NE(channel_state, GRPC_CHANNEL_READY); servers_[0]->service_.ResetCounters(); - // Next update introduces servers_[1], making the channel recover. + gpr_log(GPR_INFO, "*** BACK TO SECOND BACKEND ***"); ports.clear(); ports.emplace_back(servers_[1]->port_); SetNextResolution(ports); WaitForServer(stub, 1, DEBUG_LOCATION); channel_state = channel->GetState(false /* try to connect */); ASSERT_EQ(channel_state, GRPC_CHANNEL_READY); - // Check LB policy name for the channel. EXPECT_EQ("round_robin", channel->GetLoadBalancingPolicyName()); } @@ -1211,8 +1206,9 @@ TEST_F(ClientLbEnd2endTest, RoundRobinSingleReconnect) { auto channel = BuildChannel("round_robin"); auto stub = BuildStub(channel); SetNextResolution(ports); - for (size_t i = 0; i < kNumServers; ++i) + for (size_t i = 0; i < kNumServers; ++i) { WaitForServer(stub, i, DEBUG_LOCATION); + } for (size_t i = 0; i < servers_.size(); ++i) { CheckRpcSendOk(stub, DEBUG_LOCATION); EXPECT_EQ(1, servers_[i]->service_.request_count()) << "for backend #" << i; @@ -1236,7 +1232,6 @@ TEST_F(ClientLbEnd2endTest, RoundRobinSingleReconnect) { // No requests have gone to the deceased server. EXPECT_EQ(pre_death, post_death); // Bring the first server back up. - servers_[0].reset(new ServerData(ports[0])); StartServer(0); // Requests should start arriving at the first server either right away (if // the server managed to start before the RR policy retried the subchannel) or @@ -1360,6 +1355,52 @@ TEST_F(ClientLbEnd2endTest, RoundRobinWithHealthCheckingInhibitPerChannel) { // Second channel should be READY. EXPECT_TRUE(WaitForChannelReady(channel2.get(), 1)); CheckRpcSendOk(stub2, DEBUG_LOCATION); + // Enable health checks on the backend and wait for channel 1 to succeed. + servers_[0]->SetServingStatus("health_check_service_name", true); + CheckRpcSendOk(stub1, DEBUG_LOCATION, true /* wait_for_ready */); + // Check that we created only one subchannel to the backend. + EXPECT_EQ(1UL, servers_[0]->service_.clients().size()); + // Clean up. + EnableDefaultHealthCheckService(false); +} + +TEST_F(ClientLbEnd2endTest, RoundRobinWithHealthCheckingServiceNamePerChannel) { + EnableDefaultHealthCheckService(true); + // Start server. + const int kNumServers = 1; + StartServers(kNumServers); + // Create a channel with health-checking enabled. + ChannelArguments args; + args.SetServiceConfigJSON( + "{\"healthCheckConfig\": " + "{\"serviceName\": \"health_check_service_name\"}}"); + auto channel1 = BuildChannel("round_robin", args); + auto stub1 = BuildStub(channel1); + std::vector ports = GetServersPorts(); + SetNextResolution(ports); + // Create a channel with health-checking enabled with a different + // service name. + ChannelArguments args2; + args2.SetServiceConfigJSON( + "{\"healthCheckConfig\": " + "{\"serviceName\": \"health_check_service_name2\"}}"); + auto channel2 = BuildChannel("round_robin", args2); + auto stub2 = BuildStub(channel2); + SetNextResolution(ports); + // Allow health checks from channel 2 to succeed. + servers_[0]->SetServingStatus("health_check_service_name2", true); + // First channel should not become READY, because health checks should be + // failing. + EXPECT_FALSE(WaitForChannelReady(channel1.get(), 1)); + CheckRpcSendFailure(stub1); + // Second channel should be READY. + EXPECT_TRUE(WaitForChannelReady(channel2.get(), 1)); + CheckRpcSendOk(stub2, DEBUG_LOCATION); + // Enable health checks for channel 1 and wait for it to succeed. + servers_[0]->SetServingStatus("health_check_service_name", true); + CheckRpcSendOk(stub1, DEBUG_LOCATION, true /* wait_for_ready */); + // Check that we created only one subchannel to the backend. + EXPECT_EQ(1UL, servers_[0]->service_.clients().size()); // Clean up. EnableDefaultHealthCheckService(false); } From c7a319a6fc22405e759466367f9661d977cfedfb Mon Sep 17 00:00:00 2001 From: Srini Polavarapu Date: Fri, 10 May 2019 10:37:23 -0700 Subject: [PATCH 0183/1555] Bump version to v1.22.0-dev --- BUILD | 4 ++-- build.yaml | 4 ++-- doc/g_stands_for.md | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/BUILD b/BUILD index 5c05c9e4549..cffa12b4142 100644 --- a/BUILD +++ b/BUILD @@ -74,11 +74,11 @@ config_setting( ) # This should be updated along with build.yaml -g_stands_for = "gandalf" +g_stands_for = "gale" core_version = "7.0.0" -version = "1.21.0-dev" +version = "1.22.0-dev" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index fabb041b386..5131a57e05d 100644 --- a/build.yaml +++ b/build.yaml @@ -13,8 +13,8 @@ settings: '#09': Per-language overrides are possible with (eg) ruby_version tag here '#10': See the expand_version.py for all the quirks here core_version: 7.0.0 - g_stands_for: gandalf - version: 1.21.0-dev + g_stands_for: gale + version: 1.22.0-dev filegroups: - name: alts_proto headers: diff --git a/doc/g_stands_for.md b/doc/g_stands_for.md index b926db191de..90202b1b880 100644 --- a/doc/g_stands_for.md +++ b/doc/g_stands_for.md @@ -20,4 +20,5 @@ - 1.18 'g' stands for ['goose'](https://github.com/grpc/grpc/tree/v1.18.x) - 1.19 'g' stands for ['gold'](https://github.com/grpc/grpc/tree/v1.19.x) - 1.20 'g' stands for ['godric'](https://github.com/grpc/grpc/tree/v1.20.x) -- 1.21 'g' stands for ['gandalf'](https://github.com/grpc/grpc/tree/master) +- 1.21 'g' stands for ['gandalf'](https://github.com/grpc/grpc/tree/v1.21.x) +- 1.22 'g' stands for ['gale'](https://github.com/grpc/grpc/tree/master) From 6bc2ff1b5f46848fb2ab7072692f1a11bcb7fcd4 Mon Sep 17 00:00:00 2001 From: Srini Polavarapu Date: Fri, 10 May 2019 10:38:59 -0700 Subject: [PATCH 0184/1555] Regenerate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 4 ++-- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 4 ++-- src/core/lib/surface/version.cc | 2 +- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 4 ++-- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/composer.json | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 31 files changed, 35 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index accc28807b4..429d083d279 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.21.0-dev") +set(PACKAGE_VERSION "1.22.0-dev") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index c4a62228b64..605e533e8a8 100644 --- a/Makefile +++ b/Makefile @@ -460,8 +460,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.21.0-dev -CSHARP_VERSION = 1.21.0-dev +CPP_VERSION = 1.22.0-dev +CSHARP_VERSION = 1.22.0-dev CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 1dc2258538a..b739dc4ce75 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,7 +23,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.21.0-dev' + # version = '1.22.0-dev' version = '0.0.8-dev' s.version = version s.summary = 'gRPC C++ library' @@ -31,7 +31,7 @@ Pod::Spec.new do |s| s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.21.0-dev' + grpc_version = '1.22.0-dev' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index cbf0a4b2924..f865fca7a40 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.21.0-dev' + version = '1.22.0-dev' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 0e905bd97bd..1cac59c6cc4 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.21.0-dev' + version = '1.22.0-dev' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index df86ef7ed34..6f033ea71b7 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.21.0-dev' + version = '1.22.0-dev' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index b3c7a55a2e1..e9c3fd7bee0 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.21.0-dev' + version = '1.22.0-dev' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index 04d9f35cf03..60a22d63561 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2018-01-19 - 1.21.0dev - 1.21.0dev + 1.22.0dev + 1.22.0dev beta diff --git a/src/core/lib/surface/version.cc b/src/core/lib/surface/version.cc index 8aeadaf5078..7d9d49bc2aa 100644 --- a/src/core/lib/surface/version.cc +++ b/src/core/lib/surface/version.cc @@ -25,4 +25,4 @@ const char* grpc_version_string(void) { return "7.0.0"; } -const char* grpc_g_stands_for(void) { return "gandalf"; } +const char* grpc_g_stands_for(void) { return "gale"; } diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 166c2d39b35..76e2773e938 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.21.0-dev"; } +grpc::string Version() { return "1.22.0-dev"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index 1b2602e219d..fb67fe622b5 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -33,11 +33,11 @@ namespace Grpc.Core /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "1.21.0.0"; + public const string CurrentAssemblyFileVersion = "1.22.0.0"; /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.21.0-dev"; + public const string CurrentVersion = "1.22.0-dev"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index b018aac0f8e..dd5f172c27b 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 1.21.0-dev + 1.22.0-dev 3.7.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index 8c7718f727f..2f4cd2739da 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=1.21.0-dev +set VERSION=1.22.0-dev @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 88b8d2975d6..401540209af 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.21.0-dev' + v = '1.22.0-dev' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index fcbdfb21539..6fe0c396dd3 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.22.0-dev" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 87516de11e8..c835c1da190 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.22.0-dev" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/composer.json b/src/php/composer.json index a9d0aebffca..ca1001b6d2b 100644 --- a/src/php/composer.json +++ b/src/php/composer.json @@ -2,7 +2,7 @@ "name": "grpc/grpc-dev", "description": "gRPC library for PHP - for Developement use only", "license": "Apache-2.0", - "version": "1.21.0", + "version": "1.22.0", "require": { "php": ">=5.5.0", "google/protobuf": "^v3.3.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 43b3fa629ff..3e9f88c61d6 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.21.0dev" +#define PHP_GRPC_VERSION "1.22.0dev" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index 651f8f778f2..9f7ca9d5603 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.21.0.dev0""" +__version__ = """1.22.0.dev0""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index e430cc20a6d..971fd37afb6 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.21.0.dev0' +VERSION = '1.22.0.dev0' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index d716b953f4b..52baab4c30f 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.21.0.dev0' +VERSION = '1.22.0.dev0' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index 2bb47aaf133..be4ca841361 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.21.0.dev0' +VERSION = '1.22.0.dev0' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index e1c4f3df694..1efc4ee2c8d 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.21.0.dev0' +VERSION = '1.22.0.dev0' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index b484a7ba478..9e443087755 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.21.0.dev0' +VERSION = '1.22.0.dev0' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 21981ee79d2..18d17e40464 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.21.0.dev0' +VERSION = '1.22.0.dev0' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index 8ce4fdb627d..401b0bd9697 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.21.0.dev0' +VERSION = '1.22.0.dev0' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index cca795b64ec..75e6191216d 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.21.0.dev' + VERSION = '1.22.0.dev' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index 5604e215b58..fbd0041fa35 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.21.0.dev' + VERSION = '1.22.0.dev' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 22d04c5a1af..24ec4301b65 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.21.0.dev0' +VERSION = '1.22.0.dev0' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index d5874920752..667b9b3541e 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.0-dev +PROJECT_NUMBER = 1.22.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index ab0968b3252..41abf2e96bc 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.0-dev +PROJECT_NUMBER = 1.22.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From d29804f611d2f5834f16c7a8fcf4641e6c60918a Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 10 May 2019 10:40:01 -0700 Subject: [PATCH 0185/1555] Fix Windows vs libuv platform detection in cares code --- .../resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc | 2 +- src/core/lib/iomgr/port.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc index ce39007f905..85f5cd84ca0 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc @@ -18,7 +18,7 @@ #include #include "src/core/lib/iomgr/port.h" -#if GRPC_ARES == 1 && defined(GPR_WINDOWS) +#if GRPC_ARES == 1 && defined(GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER) #include diff --git a/src/core/lib/iomgr/port.h b/src/core/lib/iomgr/port.h index d387de5b13c..0b3681868f7 100644 --- a/src/core/lib/iomgr/port.h +++ b/src/core/lib/iomgr/port.h @@ -44,6 +44,7 @@ #elif defined(GPR_WINDOWS) #define GRPC_WINSOCK_SOCKET 1 #define GRPC_WINDOWS_SOCKETUTILS 1 +#define GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER #elif defined(GPR_ANDROID) #define GRPC_HAVE_IPV6_RECVPKTINFO 1 #define GRPC_HAVE_IP_PKTINFO 1 From aa79909f94cd1f1dbfab8c15407b83415d5f3804 Mon Sep 17 00:00:00 2001 From: Srini Polavarapu Date: Fri, 10 May 2019 10:44:41 -0700 Subject: [PATCH 0186/1555] Bump version to v1.21.0-pre1 --- BUILD | 2 +- build.yaml | 2 +- doc/g_stands_for.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/BUILD b/BUILD index 5c05c9e4549..b066f384ca0 100644 --- a/BUILD +++ b/BUILD @@ -78,7 +78,7 @@ g_stands_for = "gandalf" core_version = "7.0.0" -version = "1.21.0-dev" +version = "1.21.0-pre1" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index fabb041b386..3b40102a675 100644 --- a/build.yaml +++ b/build.yaml @@ -14,7 +14,7 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 7.0.0 g_stands_for: gandalf - version: 1.21.0-dev + version: 1.21.0-pre1 filegroups: - name: alts_proto headers: diff --git a/doc/g_stands_for.md b/doc/g_stands_for.md index b926db191de..ba0ba58fbfc 100644 --- a/doc/g_stands_for.md +++ b/doc/g_stands_for.md @@ -20,4 +20,4 @@ - 1.18 'g' stands for ['goose'](https://github.com/grpc/grpc/tree/v1.18.x) - 1.19 'g' stands for ['gold'](https://github.com/grpc/grpc/tree/v1.19.x) - 1.20 'g' stands for ['godric'](https://github.com/grpc/grpc/tree/v1.20.x) -- 1.21 'g' stands for ['gandalf'](https://github.com/grpc/grpc/tree/master) +- 1.21 'g' stands for ['gandalf'](https://github.com/grpc/grpc/tree/v1.21.x) From 1aefcbb357538ec22c102a6c1e939114742068ca Mon Sep 17 00:00:00 2001 From: Srini Polavarapu Date: Fri, 10 May 2019 10:48:05 -0700 Subject: [PATCH 0187/1555] Regenerate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 6 +++--- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 4 ++-- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 2 +- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 29 files changed, 33 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index accc28807b4..f0c14873d76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.21.0-dev") +set(PACKAGE_VERSION "1.21.0-pre1") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index c4a62228b64..b68529b5b0f 100644 --- a/Makefile +++ b/Makefile @@ -460,8 +460,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.21.0-dev -CSHARP_VERSION = 1.21.0-dev +CPP_VERSION = 1.21.0-pre1 +CSHARP_VERSION = 1.21.0-pre1 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 1dc2258538a..6f445a71929 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,15 +23,15 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.21.0-dev' - version = '0.0.8-dev' + # version = '1.21.0-pre1' + version = '0.0.8-pre1' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.21.0-dev' + grpc_version = '1.21.0-pre1' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index cbf0a4b2924..3df5539e9fe 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.21.0-dev' + version = '1.21.0-pre1' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 0e905bd97bd..af515fb529b 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.21.0-dev' + version = '1.21.0-pre1' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index df86ef7ed34..df8fcae0b41 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.21.0-dev' + version = '1.21.0-pre1' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index b3c7a55a2e1..5458725ad76 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.21.0-dev' + version = '1.21.0-pre1' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index 04d9f35cf03..e0587098a66 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2018-01-19 - 1.21.0dev - 1.21.0dev + 1.21.0RC1 + 1.21.0RC1 beta diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 166c2d39b35..8aeb99f2566 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.21.0-dev"; } +grpc::string Version() { return "1.21.0-pre1"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index 1b2602e219d..402d251446a 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -38,6 +38,6 @@ namespace Grpc.Core /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.21.0-dev"; + public const string CurrentVersion = "1.21.0-pre1"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index b018aac0f8e..67647c7a96c 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 1.21.0-dev + 1.21.0-pre1 3.7.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index 8c7718f727f..b8e247f8613 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=1.21.0-dev +set VERSION=1.21.0-pre1 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 88b8d2975d6..d7db86900c7 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.21.0-dev' + v = '1.21.0-pre1' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index fcbdfb21539..b011dd53275 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.21.0-pre1" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 87516de11e8..28b45771ace 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.21.0-pre1" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 43b3fa629ff..7d6f86c9bfe 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.21.0dev" +#define PHP_GRPC_VERSION "1.21.0RC1" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index 651f8f778f2..3a9cfc7a5e9 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.21.0.dev0""" +__version__ = """1.21.0rc1""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index e430cc20a6d..d8434992dd5 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.21.0.dev0' +VERSION = '1.21.0rc1' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index d716b953f4b..cbe46b76837 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.21.0.dev0' +VERSION = '1.21.0rc1' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index 2bb47aaf133..cfa296588e8 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.21.0.dev0' +VERSION = '1.21.0rc1' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index e1c4f3df694..54261c77f1d 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.21.0.dev0' +VERSION = '1.21.0rc1' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index b484a7ba478..9a5e728adfb 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.21.0.dev0' +VERSION = '1.21.0rc1' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 21981ee79d2..7cd0ffa30c1 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.21.0.dev0' +VERSION = '1.21.0rc1' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index 8ce4fdb627d..1a5e9f5385e 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.21.0.dev0' +VERSION = '1.21.0rc1' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index cca795b64ec..30c4b3adae0 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.21.0.dev' + VERSION = '1.21.0.pre1' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index 5604e215b58..19c79e4f854 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.21.0.dev' + VERSION = '1.21.0.pre1' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 22d04c5a1af..a91af1be0d2 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.21.0.dev0' +VERSION = '1.21.0rc1' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index d5874920752..0a399e0d1d7 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.0-dev +PROJECT_NUMBER = 1.21.0-pre1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index ab0968b3252..e314e7e969e 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.0-dev +PROJECT_NUMBER = 1.21.0-pre1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From 4b4006f8331fe1152d7459a7a4004f818d958aad Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 10 May 2019 11:15:12 -0700 Subject: [PATCH 0188/1555] libuv cares: scope manual localhost resolution to only Windows --- BUILD | 4 +- BUILD.gn | 4 +- CMakeLists.txt | 4 + Makefile | 4 + build.yaml | 4 +- config.m4 | 2 + config.w32 | 2 + gRPC-C++.podspec | 2 +- gRPC-Core.podspec | 6 +- grpc.gemspec | 4 +- grpc.gyp | 4 + package.xml | 4 +- .../dns/c_ares/grpc_ares_wrapper_libuv.cc | 19 ----- .../grpc_ares_wrapper_libuv_nonwindows.cc | 39 +++++++++ .../c_ares/grpc_ares_wrapper_libuv_windows.cc | 64 +++----------- .../dns/c_ares/grpc_ares_wrapper_windows.cc | 4 +- .../c_ares/grpc_ares_wrapper_windows_inner.cc | 83 +++++++++++++++++++ ...ws.h => grpc_ares_wrapper_windows_inner.h} | 0 src/python/grpcio/grpc_core_dependencies.py | 2 + tools/doxygen/Doxyfile.core.internal | 4 +- .../generated/sources_and_headers.json | 10 ++- 21 files changed, 184 insertions(+), 85 deletions(-) create mode 100644 src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc create mode 100644 src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc rename src/core/ext/filters/client_channel/resolver/dns/c_ares/{grpc_ares_wrapper_libuv_windows.h => grpc_ares_wrapper_windows_inner.h} (100%) diff --git a/BUILD b/BUILD index 5c05c9e4549..3defbf38867 100644 --- a/BUILD +++ b/BUILD @@ -1600,13 +1600,15 @@ grpc_cc_library( "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc", ], hdrs = [ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h", ], external_deps = [ "cares", diff --git a/BUILD.gn b/BUILD.gn index 47b2747065d..be43b5e4217 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -318,14 +318,16 @@ config("grpc_config") { "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc", "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc", "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h", "src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc", diff --git a/CMakeLists.txt b/CMakeLists.txt index accc28807b4..2f45a109cce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1299,9 +1299,11 @@ add_library(grpc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc @@ -2696,9 +2698,11 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc diff --git a/Makefile b/Makefile index c4a62228b64..f7689fabf98 100644 --- a/Makefile +++ b/Makefile @@ -3771,9 +3771,11 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ @@ -5116,9 +5118,11 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ diff --git a/build.yaml b/build.yaml index fabb041b386..537127f16a0 100644 --- a/build.yaml +++ b/build.yaml @@ -779,8 +779,8 @@ filegroups: - name: grpc_resolver_dns_ares headers: - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h + - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h - - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h src: - src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc @@ -790,9 +790,11 @@ filegroups: - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc + - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc + - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc plugin: grpc_resolver_dns_ares uses: - grpc_base diff --git a/config.m4 b/config.m4 index d90a8e94e6d..2f512cc8400 100644 --- a/config.m4 +++ b/config.m4 @@ -409,9 +409,11 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ diff --git a/config.w32 b/config.w32 index 70ac245d9fa..d4943e8893e 100644 --- a/config.w32 +++ b/config.w32 @@ -384,9 +384,11 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_fallback.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_libuv.cc " + + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_libuv_nonwindows.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_libuv_windows.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_posix.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_windows.cc " + + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_windows_inner.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\dns_resolver_selection.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\native\\dns_resolver.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\sockaddr\\sockaddr_resolver.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 1dc2258538a..65af7f5f3e6 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -561,8 +561,8 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index cbf0a4b2924..8498476a6e9 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -537,8 +537,8 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', @@ -867,9 +867,11 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', @@ -1190,8 +1192,8 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', diff --git a/grpc.gemspec b/grpc.gemspec index 6e229a5ab71..d13b007c395 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -471,8 +471,8 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/subchannel_list.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h ) + s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h ) - s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h ) s.files += %w( src/core/ext/filters/max_age/max_age_filter.h ) s.files += %w( src/core/ext/filters/message_size/message_size_filter.h ) @@ -804,9 +804,11 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc ) + s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc ) + s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc ) diff --git a/grpc.gyp b/grpc.gyp index 833a0b48715..5b7bf481dd2 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -591,9 +591,11 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', @@ -1352,9 +1354,11 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', diff --git a/package.xml b/package.xml index 04d9f35cf03..d3935a6235b 100644 --- a/package.xml +++ b/package.xml @@ -476,8 +476,8 @@ + - @@ -809,9 +809,11 @@ + + diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc index fdbb8969a1f..252fba916ff 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc @@ -23,13 +23,6 @@ #include -#include "src/core/ext/filters/client_channel/parse_address.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h" -#include "src/core/ext/filters/client_channel/server_address.h" -#include "src/core/lib/gpr/host_port.h" -#include "src/core/lib/gpr/string.h" - bool grpc_ares_query_ipv6() { /* The libuv grpc code currently does not have the code to probe for this, * so we assume for now that IPv6 is always available in contexts where this @@ -37,16 +30,4 @@ bool grpc_ares_query_ipv6() { return true; } -bool grpc_ares_maybe_resolve_localhost_manually_locked( - const char* name, const char* default_port, - grpc_core::UniquePtr* addrs) { - char* host = nullptr; - char* port = nullptr; - bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port, - addrs, &host, &port); - gpr_free(host); - gpr_free(port); - return out; -} - #endif /* GRPC_ARES == 1 && defined(GRPC_UV) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc new file mode 100644 index 00000000000..dc8d051e2af --- /dev/null +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc @@ -0,0 +1,39 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/iomgr/port.h" +#if GRPC_ARES == 1 && defined(GRPC_UV) && !defined(GPR_WINDOWS) + +#include + +#include "src/core/ext/filters/client_channel/parse_address.h" +#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" +#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" +#include "src/core/ext/filters/client_channel/server_address.h" +#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gpr/string.h" + +bool grpc_ares_maybe_resolve_localhost_manually_locked( + const char* name, const char* default_port, + grpc_core::UniquePtr* addrs) { + return false; +} + +#endif /* GRPC_ARES == 1 && defined(GRPC_UV) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc index 1232fc9d57c..d4f3944fdc7 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2019 gRPC authors. + * Copyright 2016 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,65 +19,27 @@ #include #include "src/core/lib/iomgr/port.h" -#if GRPC_ARES == 1 && (defined(GRPC_UV) || defined(GPR_WINDOWS)) +#if GRPC_ARES == 1 && defined(GRPC_UV) && defined(GPR_WINDOWS) #include #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h" +#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -bool inner_maybe_resolve_localhost_manually_locked( +bool grpc_ares_maybe_resolve_localhost_manually_locked( const char* name, const char* default_port, - grpc_core::UniquePtr* addrs, char** host, - char** port) { - gpr_split_host_port(name, host, port); - if (*host == nullptr) { - gpr_log(GPR_ERROR, - "Failed to parse %s into host:port during manual localhost " - "resolution check.", - name); - return false; - } - if (*port == nullptr) { - if (default_port == nullptr) { - gpr_log(GPR_ERROR, - "No port or default port for %s during manual localhost " - "resolution check.", - name); - return false; - } - *port = gpr_strdup(default_port); - } - if (gpr_stricmp(*host, "localhost") == 0) { - GPR_ASSERT(*addrs == nullptr); - *addrs = grpc_core::MakeUnique(); - uint16_t numeric_port = grpc_strhtons(*port); - // Append the ipv6 loopback address. - struct sockaddr_in6 ipv6_loopback_addr; - memset(&ipv6_loopback_addr, 0, sizeof(ipv6_loopback_addr)); - ((char*)&ipv6_loopback_addr.sin6_addr)[15] = 1; - ipv6_loopback_addr.sin6_family = AF_INET6; - ipv6_loopback_addr.sin6_port = numeric_port; - (*addrs)->emplace_back(&ipv6_loopback_addr, sizeof(ipv6_loopback_addr), - nullptr /* args */); - // Append the ipv4 loopback address. - struct sockaddr_in ipv4_loopback_addr; - memset(&ipv4_loopback_addr, 0, sizeof(ipv4_loopback_addr)); - ((char*)&ipv4_loopback_addr.sin_addr)[0] = 0x7f; - ((char*)&ipv4_loopback_addr.sin_addr)[3] = 0x01; - ipv4_loopback_addr.sin_family = AF_INET; - ipv4_loopback_addr.sin_port = numeric_port; - (*addrs)->emplace_back(&ipv4_loopback_addr, sizeof(ipv4_loopback_addr), - nullptr /* args */); - // Let the address sorter figure out which one should be tried first. - grpc_cares_wrapper_address_sorting_sort(addrs->get()); - return true; - } - return false; + grpc_core::UniquePtr* addrs) { + char* host = nullptr; + char* port = nullptr; + bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port, + addrs, &host, &port); + gpr_free(host); + gpr_free(port); + return out; } -#endif /* GRPC_ARES == 1 && (defined(GRPC_UV) || defined(GPR_WINDOWS)) */ +#endif /* GRPC_ARES == 1 && defined(GRPC_UV) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc index 60398c6aedd..fcb47eb5b58 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc @@ -19,13 +19,13 @@ #include #include "src/core/lib/iomgr/port.h" -#if GRPC_ARES == 1 && defined(GPR_WINDOWS) +#if GRPC_ARES == 1 && defined(GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER) #include #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h" +#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc new file mode 100644 index 00000000000..ee37144eca7 --- /dev/null +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc @@ -0,0 +1,83 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/iomgr/port.h" +#if GRPC_ARES == 1 && (defined(GRPC_UV) || defined(GPR_WINDOWS)) + +#include + +#include "src/core/ext/filters/client_channel/parse_address.h" +#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" +#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" +#include "src/core/ext/filters/client_channel/server_address.h" +#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gpr/string.h" + +bool inner_maybe_resolve_localhost_manually_locked( + const char* name, const char* default_port, + grpc_core::UniquePtr* addrs, char** host, + char** port) { + gpr_split_host_port(name, host, port); + if (*host == nullptr) { + gpr_log(GPR_ERROR, + "Failed to parse %s into host:port during manual localhost " + "resolution check.", + name); + return false; + } + if (*port == nullptr) { + if (default_port == nullptr) { + gpr_log(GPR_ERROR, + "No port or default port for %s during manual localhost " + "resolution check.", + name); + return false; + } + *port = gpr_strdup(default_port); + } + if (gpr_stricmp(*host, "localhost") == 0) { + GPR_ASSERT(*addrs == nullptr); + *addrs = grpc_core::MakeUnique(); + uint16_t numeric_port = grpc_strhtons(*port); + // Append the ipv6 loopback address. + struct sockaddr_in6 ipv6_loopback_addr; + memset(&ipv6_loopback_addr, 0, sizeof(ipv6_loopback_addr)); + ((char*)&ipv6_loopback_addr.sin6_addr)[15] = 1; + ipv6_loopback_addr.sin6_family = AF_INET6; + ipv6_loopback_addr.sin6_port = numeric_port; + (*addrs)->emplace_back(&ipv6_loopback_addr, sizeof(ipv6_loopback_addr), + nullptr /* args */); + // Append the ipv4 loopback address. + struct sockaddr_in ipv4_loopback_addr; + memset(&ipv4_loopback_addr, 0, sizeof(ipv4_loopback_addr)); + ((char*)&ipv4_loopback_addr.sin_addr)[0] = 0x7f; + ((char*)&ipv4_loopback_addr.sin_addr)[3] = 0x01; + ipv4_loopback_addr.sin_family = AF_INET; + ipv4_loopback_addr.sin_port = numeric_port; + (*addrs)->emplace_back(&ipv4_loopback_addr, sizeof(ipv4_loopback_addr), + nullptr /* args */); + // Let the address sorter figure out which one should be tried first. + grpc_cares_wrapper_address_sorting_sort(addrs->get()); + return true; + } + return false; +} + +#endif /* GRPC_ARES == 1 && (defined(GRPC_UV) || defined(GPR_WINDOWS)) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h similarity index 100% rename from src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h rename to src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 61524eb7fc9..db78061a63d 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -383,9 +383,11 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 293a6e1f9c1..4905bd365d0 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -945,14 +945,16 @@ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc \ +src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ +src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ -src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ +src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h \ src/core/ext/filters/client_channel/resolver/dns/native/README.md \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index de8015ac52a..b358e855c07 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -9178,8 +9178,8 @@ ], "headers": [ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h" + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" ], "is_filegroup": true, "language": "c", @@ -9191,14 +9191,16 @@ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc" + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc" ], "third_party": false, "type": "filegroup" From 87d75d2a881ee2a71ada38ae52e87af38debea72 Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Fri, 10 May 2019 11:23:24 -0700 Subject: [PATCH 0189/1555] Add explicit and fix error --- test/cpp/microbenchmarks/bm_cq.cc | 6 ++++-- test/cpp/microbenchmarks/callback_streaming_ping_pong.h | 4 +--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index caa5e7d6d31..50eb9454fbe 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -153,7 +153,9 @@ static void shutdown_and_destroy(grpc_completion_queue* cc) { // Tag completion queue iterate times class TagCallback : public grpc_experimental_completion_queue_functor { public: - TagCallback(int* iter) : iter_(iter) { functor_run = &TagCallback::Run; } + explicit TagCallback(int* iter) : iter_(iter) { + functor_run = &TagCallback::Run; + } ~TagCallback() {} static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { GPR_ASSERT(static_cast(ok)); @@ -167,7 +169,7 @@ class TagCallback : public grpc_experimental_completion_queue_functor { // Check if completion queue is shut down class ShutdownCallback : public grpc_experimental_completion_queue_functor { public: - ShutdownCallback(bool* done) : done_(done) { + explicit ShutdownCallback(bool* done) : done_(done) { functor_run = &ShutdownCallback::Run; } ~ShutdownCallback() {} diff --git a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h index 8f10fabc43b..0f4549df3ff 100644 --- a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h @@ -55,9 +55,7 @@ class BidiClient gpr_log(GPR_ERROR, "Client read failed"); return; } - if (writes_complete_ < msgs_to_send_) { - MaybeWrite(); - } + MaybeWrite(); } void OnWriteDone(bool ok) override { From f65208af02714799faa6ba3ceeae5c73d0bf6dfa Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Mon, 29 Apr 2019 15:59:20 -0700 Subject: [PATCH 0190/1555] Added slice equality when static fastpath. --- BUILD | 1 + BUILD.gn | 2 + build.yaml | 1 + gRPC-C++.podspec | 2 + gRPC-Core.podspec | 2 + grpc.gemspec | 1 + package.xml | 1 + .../ext/transport/chttp2/transport/parsing.cc | 96 ++++++++----------- .../cronet/transport/cronet_transport.cc | 14 +-- src/core/lib/compression/compression.cc | 21 ++-- .../lib/compression/compression_internal.cc | 24 +++-- .../lib/compression/stream_compression.cc | 5 +- src/core/lib/slice/slice.cc | 25 +++++ src/core/lib/slice/slice_intern.cc | 10 +- src/core/lib/slice/slice_utils.h | 50 ++++++++++ src/core/lib/surface/call.cc | 6 +- src/core/lib/transport/metadata.h | 3 +- src/core/lib/transport/static_metadata.cc | 4 +- src/core/lib/transport/static_metadata.h | 17 ++-- tools/codegen/core/gen_static_metadata.py | 14 +-- tools/doxygen/Doxyfile.c++.internal | 1 + tools/doxygen/Doxyfile.core.internal | 1 + .../generated/sources_and_headers.json | 2 + 23 files changed, 198 insertions(+), 105 deletions(-) create mode 100644 src/core/lib/slice/slice_utils.h diff --git a/BUILD b/BUILD index 5c05c9e4549..750ebb2a48d 100644 --- a/BUILD +++ b/BUILD @@ -997,6 +997,7 @@ grpc_cc_library( "src/core/lib/slice/slice_hash_table.h", "src/core/lib/slice/slice_internal.h", "src/core/lib/slice/slice_string_helpers.h", + "src/core/lib/slice/slice_utils.h", "src/core/lib/slice/slice_weak_hash_table.h", "src/core/lib/surface/api_trace.h", "src/core/lib/surface/call.h", diff --git a/BUILD.gn b/BUILD.gn index 47b2747065d..dcd5bc880eb 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -739,6 +739,7 @@ config("grpc_config") { "src/core/lib/slice/slice_internal.h", "src/core/lib/slice/slice_string_helpers.cc", "src/core/lib/slice/slice_string_helpers.h", + "src/core/lib/slice/slice_utils.h", "src/core/lib/slice/slice_weak_hash_table.h", "src/core/lib/surface/api_trace.cc", "src/core/lib/surface/api_trace.h", @@ -1283,6 +1284,7 @@ config("grpc_config") { "src/core/lib/slice/slice_hash_table.h", "src/core/lib/slice/slice_internal.h", "src/core/lib/slice/slice_string_helpers.h", + "src/core/lib/slice/slice_utils.h", "src/core/lib/slice/slice_weak_hash_table.h", "src/core/lib/surface/api_trace.h", "src/core/lib/surface/call.h", diff --git a/build.yaml b/build.yaml index fabb041b386..c46d5ab423f 100644 --- a/build.yaml +++ b/build.yaml @@ -525,6 +525,7 @@ filegroups: - src/core/lib/slice/slice_hash_table.h - src/core/lib/slice/slice_internal.h - src/core/lib/slice/slice_string_helpers.h + - src/core/lib/slice/slice_utils.h - src/core/lib/slice/slice_weak_hash_table.h - src/core/lib/surface/api_trace.h - src/core/lib/surface/call.h diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 1dc2258538a..316fd349da9 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -518,6 +518,7 @@ Pod::Spec.new do |s| 'src/core/lib/slice/slice_hash_table.h', 'src/core/lib/slice/slice_internal.h', 'src/core/lib/slice/slice_string_helpers.h', + 'src/core/lib/slice/slice_utils.h', 'src/core/lib/slice/slice_weak_hash_table.h', 'src/core/lib/surface/api_trace.h', 'src/core/lib/surface/call.h', @@ -721,6 +722,7 @@ Pod::Spec.new do |s| 'src/core/lib/slice/slice_hash_table.h', 'src/core/lib/slice/slice_internal.h', 'src/core/lib/slice/slice_string_helpers.h', + 'src/core/lib/slice/slice_utils.h', 'src/core/lib/slice/slice_weak_hash_table.h', 'src/core/lib/surface/api_trace.h', 'src/core/lib/surface/call.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index cbf0a4b2924..c36ba13000f 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -494,6 +494,7 @@ Pod::Spec.new do |s| 'src/core/lib/slice/slice_hash_table.h', 'src/core/lib/slice/slice_internal.h', 'src/core/lib/slice/slice_string_helpers.h', + 'src/core/lib/slice/slice_utils.h', 'src/core/lib/slice/slice_weak_hash_table.h', 'src/core/lib/surface/api_trace.h', 'src/core/lib/surface/call.h', @@ -1147,6 +1148,7 @@ Pod::Spec.new do |s| 'src/core/lib/slice/slice_hash_table.h', 'src/core/lib/slice/slice_internal.h', 'src/core/lib/slice/slice_string_helpers.h', + 'src/core/lib/slice/slice_utils.h', 'src/core/lib/slice/slice_weak_hash_table.h', 'src/core/lib/surface/api_trace.h', 'src/core/lib/surface/call.h', diff --git a/grpc.gemspec b/grpc.gemspec index 6e229a5ab71..03b0116e149 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -428,6 +428,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/slice/slice_hash_table.h ) s.files += %w( src/core/lib/slice/slice_internal.h ) s.files += %w( src/core/lib/slice/slice_string_helpers.h ) + s.files += %w( src/core/lib/slice/slice_utils.h ) s.files += %w( src/core/lib/slice/slice_weak_hash_table.h ) s.files += %w( src/core/lib/surface/api_trace.h ) s.files += %w( src/core/lib/surface/call.h ) diff --git a/package.xml b/package.xml index 04d9f35cf03..5c97e0e307b 100644 --- a/package.xml +++ b/package.xml @@ -433,6 +433,7 @@ + diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index 15648c06fcd..1aa6d971684 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -28,6 +28,7 @@ #include "src/core/lib/profiling/timers.h" #include "src/core/lib/slice/slice_string_helpers.h" +#include "src/core/lib/slice/slice_utils.h" #include "src/core/lib/transport/http2_errors.h" #include "src/core/lib/transport/static_metadata.h" #include "src/core/lib/transport/status_conversion.h" @@ -410,53 +411,42 @@ static void on_initial_header(void* tp, grpc_mdelem md) { gpr_free(value); } - if (GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_STATIC) { - // We don't use grpc_mdelem_eq here to avoid executing additional - // instructions. The reasoning is if the payload is not equal, we already - // know that the metadata elements are not equal because the md is - // confirmed to be static. If we had used grpc_mdelem_eq here, then if the - // payloads are not equal, grpc_mdelem_eq executes more instructions to - // determine if they're equal or not. - if (md.payload == GRPC_MDELEM_GRPC_STATUS_1.payload || - md.payload == GRPC_MDELEM_GRPC_STATUS_2.payload) { - s->seen_error = true; - } - } else { - if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_STATUS) && - !grpc_mdelem_eq(md, GRPC_MDELEM_GRPC_STATUS_0)) { - /* TODO(ctiller): check for a status like " 0" */ - s->seen_error = true; - } - - if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_TIMEOUT)) { - grpc_millis* cached_timeout = static_cast( - grpc_mdelem_get_user_data(md, free_timeout)); - grpc_millis timeout; - if (cached_timeout != nullptr) { - timeout = *cached_timeout; - } else { - if (GPR_UNLIKELY( - !grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout))) { - char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); - gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'", val); - gpr_free(val); - timeout = GRPC_MILLIS_INF_FUTURE; - } - if (GRPC_MDELEM_IS_INTERNED(md)) { - /* store the result */ - cached_timeout = - static_cast(gpr_malloc(sizeof(grpc_millis))); - *cached_timeout = timeout; - grpc_mdelem_set_user_data(md, free_timeout, cached_timeout); - } + // If md.payload == GRPC_MDELEM_GRPC_STATUS_1 or GRPC_MDELEM_GRPC_STATUS_2, + // then we have seen an error. In fact, if it is a GRPC_STATUS and it's + // not equal to GRPC_MDELEM_GRPC_STATUS_0, then we have seen an error. + if (grpc_slice_eq_static_interned(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_STATUS) && + !grpc_mdelem_static_value_eq(md, GRPC_MDELEM_GRPC_STATUS_0)) { + /* TODO(ctiller): check for a status like " 0" */ + s->seen_error = true; + } else if (grpc_slice_eq_static_interned(GRPC_MDKEY(md), + GRPC_MDSTR_GRPC_TIMEOUT)) { + grpc_millis* cached_timeout = + static_cast(grpc_mdelem_get_user_data(md, free_timeout)); + grpc_millis timeout; + if (cached_timeout != nullptr) { + timeout = *cached_timeout; + } else { + if (GPR_UNLIKELY( + !grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout))) { + char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); + gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'", val); + gpr_free(val); + timeout = GRPC_MILLIS_INF_FUTURE; } - if (timeout != GRPC_MILLIS_INF_FUTURE) { - grpc_chttp2_incoming_metadata_buffer_set_deadline( - &s->metadata_buffer[0], grpc_core::ExecCtx::Get()->Now() + timeout); + if (GRPC_MDELEM_IS_INTERNED(md)) { + /* store the result */ + cached_timeout = + static_cast(gpr_malloc(sizeof(grpc_millis))); + *cached_timeout = timeout; + grpc_mdelem_set_user_data(md, free_timeout, cached_timeout); } - GRPC_MDELEM_UNREF(md); - return; } + if (timeout != GRPC_MILLIS_INF_FUTURE) { + grpc_chttp2_incoming_metadata_buffer_set_deadline( + &s->metadata_buffer[0], grpc_core::ExecCtx::Get()->Now() + timeout); + } + GRPC_MDELEM_UNREF(md); + return; } const size_t new_size = s->metadata_buffer[0].size + GRPC_MDELEM_LENGTH(md); @@ -506,19 +496,11 @@ static void on_trailing_header(void* tp, grpc_mdelem md) { gpr_free(value); } - if (GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_STATIC) { - // We don't use grpc_mdelem_eq here to avoid executing additional - // instructions. The reasoning is if the payload is not equal, we already - // know that the metadata elements are not equal because the md is - // confirmed to be static. If we had used grpc_mdelem_eq here, then if the - // payloads are not equal, grpc_mdelem_eq executes more instructions to - // determine if they're equal or not. - if (md.payload == GRPC_MDELEM_GRPC_STATUS_1.payload || - md.payload == GRPC_MDELEM_GRPC_STATUS_2.payload) { - s->seen_error = true; - } - } else if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_STATUS) && - !grpc_mdelem_eq(md, GRPC_MDELEM_GRPC_STATUS_0)) { + // If md.payload == GRPC_MDELEM_GRPC_STATUS_1 or GRPC_MDELEM_GRPC_STATUS_2, + // then we have seen an error. In fact, if it is a GRPC_STATUS and it's + // not equal to GRPC_MDELEM_GRPC_STATUS_0, then we have seen an error. + if (grpc_slice_eq_static_interned(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_STATUS) && + !grpc_mdelem_static_value_eq(md, GRPC_MDELEM_GRPC_STATUS_0)) { /* TODO(ctiller): check for a status like " 0" */ s->seen_error = true; } diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc index 320b5297251..413de807638 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.cc +++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc @@ -753,15 +753,16 @@ static void convert_metadata_to_cronet_headers( } else { value = grpc_slice_to_c_string(GRPC_MDVALUE(mdelem)); } - if (grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_SCHEME) || - grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_AUTHORITY)) { + if (grpc_slice_eq_static_interned(GRPC_MDKEY(mdelem), GRPC_MDSTR_SCHEME) || + grpc_slice_eq_static_interned(GRPC_MDKEY(mdelem), + GRPC_MDSTR_AUTHORITY)) { /* Cronet populates these fields on its own */ gpr_free(key); gpr_free(value); continue; } - if (grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_METHOD)) { - if (grpc_slice_eq(GRPC_MDVALUE(mdelem), GRPC_MDSTR_PUT)) { + if (grpc_slice_eq_static_interned(GRPC_MDKEY(mdelem), GRPC_MDSTR_METHOD)) { + if (grpc_slice_eq_static_interned(GRPC_MDVALUE(mdelem), GRPC_MDSTR_PUT)) { *method = "PUT"; } else { /* POST method in default*/ @@ -771,7 +772,7 @@ static void convert_metadata_to_cronet_headers( gpr_free(value); continue; } - if (grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_PATH)) { + if (grpc_slice_eq_static_interned(GRPC_MDKEY(mdelem), GRPC_MDSTR_PATH)) { /* Create URL by appending :path value to the hostname */ gpr_asprintf(pp_url, "https://%s%s", host, value); gpr_free(key); @@ -803,7 +804,8 @@ static void parse_grpc_header(const uint8_t* data, int* length, static bool header_has_authority(grpc_linked_mdelem* head) { while (head != nullptr) { - if (grpc_slice_eq(GRPC_MDKEY(head->md), GRPC_MDSTR_AUTHORITY)) { + if (grpc_slice_eq_static_interned(GRPC_MDKEY(head->md), + GRPC_MDSTR_AUTHORITY)) { return true; } head = head->next; diff --git a/src/core/lib/compression/compression.cc b/src/core/lib/compression/compression.cc index 9139fa04ee5..a3a069d9266 100644 --- a/src/core/lib/compression/compression.cc +++ b/src/core/lib/compression/compression.cc @@ -26,6 +26,7 @@ #include "src/core/lib/compression/algorithm_metadata.h" #include "src/core/lib/compression/compression_internal.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/slice/slice_utils.h" #include "src/core/lib/surface/api_trace.h" #include "src/core/lib/transport/static_metadata.h" @@ -42,16 +43,17 @@ int grpc_compression_algorithm_is_stream(grpc_compression_algorithm algorithm) { int grpc_compression_algorithm_parse(grpc_slice name, grpc_compression_algorithm* algorithm) { - if (grpc_slice_eq(name, GRPC_MDSTR_IDENTITY)) { + if (grpc_slice_eq_static_interned(name, GRPC_MDSTR_IDENTITY)) { *algorithm = GRPC_COMPRESS_NONE; return 1; - } else if (grpc_slice_eq(name, GRPC_MDSTR_DEFLATE)) { + } else if (grpc_slice_eq_static_interned(name, GRPC_MDSTR_DEFLATE)) { *algorithm = GRPC_COMPRESS_DEFLATE; return 1; - } else if (grpc_slice_eq(name, GRPC_MDSTR_GZIP)) { + } else if (grpc_slice_eq_static_interned(name, GRPC_MDSTR_GZIP)) { *algorithm = GRPC_COMPRESS_GZIP; return 1; - } else if (grpc_slice_eq(name, GRPC_MDSTR_STREAM_SLASH_GZIP)) { + } else if (grpc_slice_eq_static_interned(name, + GRPC_MDSTR_STREAM_SLASH_GZIP)) { *algorithm = GRPC_COMPRESS_STREAM_GZIP; return 1; } else { @@ -148,10 +150,13 @@ grpc_slice grpc_compression_algorithm_slice( grpc_compression_algorithm grpc_compression_algorithm_from_slice( const grpc_slice& str) { - if (grpc_slice_eq(str, GRPC_MDSTR_IDENTITY)) return GRPC_COMPRESS_NONE; - if (grpc_slice_eq(str, GRPC_MDSTR_DEFLATE)) return GRPC_COMPRESS_DEFLATE; - if (grpc_slice_eq(str, GRPC_MDSTR_GZIP)) return GRPC_COMPRESS_GZIP; - if (grpc_slice_eq(str, GRPC_MDSTR_STREAM_SLASH_GZIP)) + if (grpc_slice_eq_static_interned(str, GRPC_MDSTR_IDENTITY)) + return GRPC_COMPRESS_NONE; + if (grpc_slice_eq_static_interned(str, GRPC_MDSTR_DEFLATE)) + return GRPC_COMPRESS_DEFLATE; + if (grpc_slice_eq_static_interned(str, GRPC_MDSTR_GZIP)) + return GRPC_COMPRESS_GZIP; + if (grpc_slice_eq_static_interned(str, GRPC_MDSTR_STREAM_SLASH_GZIP)) return GRPC_COMPRESS_STREAM_GZIP; return GRPC_COMPRESS_ALGORITHMS_COUNT; } diff --git a/src/core/lib/compression/compression_internal.cc b/src/core/lib/compression/compression_internal.cc index 65a36de4290..e0d73ef6d83 100644 --- a/src/core/lib/compression/compression_internal.cc +++ b/src/core/lib/compression/compression_internal.cc @@ -26,6 +26,7 @@ #include "src/core/lib/compression/algorithm_metadata.h" #include "src/core/lib/compression/compression_internal.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/slice/slice_utils.h" #include "src/core/lib/surface/api_trace.h" #include "src/core/lib/transport/static_metadata.h" @@ -33,18 +34,21 @@ grpc_message_compression_algorithm grpc_message_compression_algorithm_from_slice(const grpc_slice& str) { - if (grpc_slice_eq(str, GRPC_MDSTR_IDENTITY)) + if (grpc_slice_eq_static_interned(str, GRPC_MDSTR_IDENTITY)) return GRPC_MESSAGE_COMPRESS_NONE; - if (grpc_slice_eq(str, GRPC_MDSTR_DEFLATE)) + if (grpc_slice_eq_static_interned(str, GRPC_MDSTR_DEFLATE)) return GRPC_MESSAGE_COMPRESS_DEFLATE; - if (grpc_slice_eq(str, GRPC_MDSTR_GZIP)) return GRPC_MESSAGE_COMPRESS_GZIP; + if (grpc_slice_eq_static_interned(str, GRPC_MDSTR_GZIP)) + return GRPC_MESSAGE_COMPRESS_GZIP; return GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT; } grpc_stream_compression_algorithm grpc_stream_compression_algorithm_from_slice( const grpc_slice& str) { - if (grpc_slice_eq(str, GRPC_MDSTR_IDENTITY)) return GRPC_STREAM_COMPRESS_NONE; - if (grpc_slice_eq(str, GRPC_MDSTR_GZIP)) return GRPC_STREAM_COMPRESS_GZIP; + if (grpc_slice_eq_static_interned(str, GRPC_MDSTR_IDENTITY)) + return GRPC_STREAM_COMPRESS_NONE; + if (grpc_slice_eq_static_interned(str, GRPC_MDSTR_GZIP)) + return GRPC_STREAM_COMPRESS_GZIP; return GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT; } @@ -244,13 +248,13 @@ grpc_message_compression_algorithm grpc_message_compression_algorithm_for_level( int grpc_message_compression_algorithm_parse( grpc_slice value, grpc_message_compression_algorithm* algorithm) { - if (grpc_slice_eq(value, GRPC_MDSTR_IDENTITY)) { + if (grpc_slice_eq_static_interned(value, GRPC_MDSTR_IDENTITY)) { *algorithm = GRPC_MESSAGE_COMPRESS_NONE; return 1; - } else if (grpc_slice_eq(value, GRPC_MDSTR_DEFLATE)) { + } else if (grpc_slice_eq_static_interned(value, GRPC_MDSTR_DEFLATE)) { *algorithm = GRPC_MESSAGE_COMPRESS_DEFLATE; return 1; - } else if (grpc_slice_eq(value, GRPC_MDSTR_GZIP)) { + } else if (grpc_slice_eq_static_interned(value, GRPC_MDSTR_GZIP)) { *algorithm = GRPC_MESSAGE_COMPRESS_GZIP; return 1; } else { @@ -263,10 +267,10 @@ int grpc_message_compression_algorithm_parse( int grpc_stream_compression_algorithm_parse( grpc_slice value, grpc_stream_compression_algorithm* algorithm) { - if (grpc_slice_eq(value, GRPC_MDSTR_IDENTITY)) { + if (grpc_slice_eq_static_interned(value, GRPC_MDSTR_IDENTITY)) { *algorithm = GRPC_STREAM_COMPRESS_NONE; return 1; - } else if (grpc_slice_eq(value, GRPC_MDSTR_GZIP)) { + } else if (grpc_slice_eq_static_interned(value, GRPC_MDSTR_GZIP)) { *algorithm = GRPC_STREAM_COMPRESS_GZIP; return 1; } else { diff --git a/src/core/lib/compression/stream_compression.cc b/src/core/lib/compression/stream_compression.cc index 46cb3daf4cc..e0857988643 100644 --- a/src/core/lib/compression/stream_compression.cc +++ b/src/core/lib/compression/stream_compression.cc @@ -22,6 +22,7 @@ #include "src/core/lib/compression/stream_compression.h" #include "src/core/lib/compression/stream_compression_gzip.h" +#include "src/core/lib/slice/slice_utils.h" extern const grpc_stream_compression_vtable grpc_stream_compression_identity_vtable; @@ -65,11 +66,11 @@ void grpc_stream_compression_context_destroy( int grpc_stream_compression_method_parse( grpc_slice value, bool is_compress, grpc_stream_compression_method* method) { - if (grpc_slice_eq(value, GRPC_MDSTR_IDENTITY)) { + if (grpc_slice_eq_static_interned(value, GRPC_MDSTR_IDENTITY)) { *method = is_compress ? GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS : GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS; return 1; - } else if (grpc_slice_eq(value, GRPC_MDSTR_GZIP)) { + } else if (grpc_slice_eq_static_interned(value, GRPC_MDSTR_GZIP)) { *method = is_compress ? GRPC_STREAM_COMPRESSION_GZIP_COMPRESS : GRPC_STREAM_COMPRESSION_GZIP_DECOMPRESS; return 1; diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc index 2bf2b0f499f..75acb28e99c 100644 --- a/src/core/lib/slice/slice.cc +++ b/src/core/lib/slice/slice.cc @@ -410,6 +410,31 @@ int grpc_slice_eq(grpc_slice a, grpc_slice b) { return grpc_slice_default_eq_impl(a, b); } +int grpc_slice_differs_refcounted(const grpc_slice& a, + const grpc_slice& b_not_inline) { + size_t a_len; + const uint8_t* a_ptr; + if (a.refcount) { + a_len = a.data.refcounted.length; + a_ptr = a.data.refcounted.bytes; + } else { + a_len = a.data.inlined.length; + a_ptr = &a.data.inlined.bytes[0]; + } + if (a_len != b_not_inline.data.refcounted.length) { + return true; + } + if (a_len == 0) { + return false; + } + // This check *must* occur after the a_len == 0 check + // to retain compatibility with grpc_slice_eq. + if (a_ptr == nullptr) { + return true; + } + return memcmp(a_ptr, b_not_inline.data.refcounted.bytes, a_len); +} + int grpc_slice_cmp(grpc_slice a, grpc_slice b) { int d = static_cast(GRPC_SLICE_LENGTH(a) - GRPC_SLICE_LENGTH(b)); if (d != 0) return d; diff --git a/src/core/lib/slice/slice_intern.cc b/src/core/lib/slice/slice_intern.cc index 0f190c186fa..15909d9b96f 100644 --- a/src/core/lib/slice/slice_intern.cc +++ b/src/core/lib/slice/slice_intern.cc @@ -19,6 +19,7 @@ #include #include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/slice/slice_utils.h" #include #include @@ -143,7 +144,8 @@ grpc_slice grpc_slice_maybe_static_intern(grpc_slice slice, static_metadata_hash_ent ent = static_metadata_hash[(hash + i) % GPR_ARRAY_SIZE(static_metadata_hash)]; if (ent.hash == hash && ent.idx < GRPC_STATIC_MDSTR_COUNT && - grpc_slice_eq(grpc_static_slice_table[ent.idx], slice)) { + grpc_slice_eq_static_interned(slice, + grpc_static_slice_table[ent.idx])) { *returned_slice_is_different = true; return grpc_static_slice_table[ent.idx]; } @@ -170,7 +172,8 @@ grpc_slice grpc_slice_intern(grpc_slice slice) { static_metadata_hash_ent ent = static_metadata_hash[(hash + i) % GPR_ARRAY_SIZE(static_metadata_hash)]; if (ent.hash == hash && ent.idx < GRPC_STATIC_MDSTR_COUNT && - grpc_slice_eq(grpc_static_slice_table[ent.idx], slice)) { + grpc_slice_eq_static_interned(slice, + grpc_static_slice_table[ent.idx])) { return grpc_static_slice_table[ent.idx]; } } @@ -183,7 +186,8 @@ grpc_slice grpc_slice_intern(grpc_slice slice) { /* search for an existing string */ size_t idx = TABLE_IDX(hash, shard->capacity); for (s = shard->strs[idx]; s; s = s->bucket_next) { - if (s->hash == hash && grpc_slice_eq(slice, materialize(s))) { + if (s->hash == hash && + grpc_slice_eq_static_interned(slice, materialize(s))) { if (s->refcnt.RefIfNonZero()) { gpr_mu_unlock(&shard->mu); return materialize(s); diff --git a/src/core/lib/slice/slice_utils.h b/src/core/lib/slice/slice_utils.h new file mode 100644 index 00000000000..7589bf8f0f7 --- /dev/null +++ b/src/core/lib/slice/slice_utils.h @@ -0,0 +1,50 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_SLICE_SLICE_UTILS_H +#define GRPC_CORE_LIB_SLICE_SLICE_UTILS_H + +#include + +#include + +// When we compare two slices, and we know the latter is not inlined, we can +// short circuit our comparison operator. We specifically use differs() +// semantics instead of equals() semantics due to more favourable code +// generation when using differs(). Specifically, we may use the output of +// grpc_slice_differs_refcounted for control flow. If we use differs() +// semantics, we end with a tailcall to memcmp(). If we use equals() semantics, +// we need to invert the result that memcmp provides us, which costs several +// instructions to do so. If we're using the result for control flow (i.e. +// branching based on the output) then we're just performing the extra +// operations to invert the result pointlessly. Concretely, we save 6 ops on +// x86-64/clang with differs(). +int grpc_slice_differs_refcounted(const grpc_slice& a, + const grpc_slice& b_not_inline); +// When we compare two slices, and we *know* that one of them is static or +// interned, we can short circuit our slice equality function. The second slice +// here must be static or interned; slice a can be any slice, inlined or not. +inline bool grpc_slice_eq_static_interned(const grpc_slice& a, + const grpc_slice& b_static_interned) { + if (a.refcount == b_static_interned.refcount) { + return true; + } + return !grpc_slice_differs_refcounted(a, b_static_interned); +} + +#endif /* GRPC_CORE_LIB_SLICE_SLICE_UTILS_H */ diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 275111f3213..254476f47e3 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -42,8 +42,8 @@ #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/profiling/timers.h" -#include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_string_helpers.h" +#include "src/core/lib/slice/slice_utils.h" #include "src/core/lib/surface/api_trace.h" #include "src/core/lib/surface/call.h" #include "src/core/lib/surface/call_test_only.h" @@ -349,8 +349,8 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args, MAX_SEND_EXTRA_METADATA_COUNT); for (size_t i = 0; i < args->add_initial_metadata_count; i++) { call->send_extra_metadata[i].md = args->add_initial_metadata[i]; - if (grpc_slice_eq(GRPC_MDKEY(args->add_initial_metadata[i]), - GRPC_MDSTR_PATH)) { + if (grpc_slice_eq_static_interned( + GRPC_MDKEY(args->add_initial_metadata[i]), GRPC_MDSTR_PATH)) { path = grpc_slice_ref_internal( GRPC_MDVALUE(args->add_initial_metadata[i])); } diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h index c0d1ab36351..3ff5a35dd2d 100644 --- a/src/core/lib/transport/metadata.h +++ b/src/core/lib/transport/metadata.h @@ -30,6 +30,7 @@ #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/atomic.h" #include "src/core/lib/gprpp/sync.h" +#include "src/core/lib/slice/slice_utils.h" extern grpc_core::DebugOnlyTraceFlag grpc_trace_metadata; @@ -138,7 +139,7 @@ bool grpc_mdelem_eq(grpc_mdelem a, grpc_mdelem b); * grpc_mdelem_eq and remove unnecessary checks. */ inline bool grpc_mdelem_static_value_eq(grpc_mdelem a, grpc_mdelem b_static) { if (a.payload == b_static.payload) return true; - return grpc_slice_eq(GRPC_MDVALUE(a), GRPC_MDVALUE(b_static)); + return grpc_slice_eq_static_interned(GRPC_MDVALUE(a), GRPC_MDVALUE(b_static)); } /* Mutator and accessor for grpc_mdelem user data. The destructor function diff --git a/src/core/lib/transport/static_metadata.cc b/src/core/lib/transport/static_metadata.cc index fc5bb647573..61ee1d46f77 100644 --- a/src/core/lib/transport/static_metadata.cc +++ b/src/core/lib/transport/static_metadata.cc @@ -384,9 +384,9 @@ static const uint8_t elem_idxs[] = { 52, 53, 54, 76, 69, 55, 56, 70, 58, 78, 80, 81, 82, 83, 59, 64, 60, 75, 72, 255, 85, 255, 255, 68, 255, 255, 0}; -grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b) { +grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b) { if (a == -1 || b == -1) return GRPC_MDNULL; - uint32_t k = (uint32_t)(a * 107 + b); + uint32_t k = static_cast(a * 107 + b); uint32_t h = elems_phash(k); return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k && elem_idxs[h] != 255 diff --git a/src/core/lib/transport/static_metadata.h b/src/core/lib/transport/static_metadata.h index 88293ae0613..a3f23de0953 100644 --- a/src/core/lib/transport/static_metadata.h +++ b/src/core/lib/transport/static_metadata.h @@ -29,6 +29,8 @@ #include +#include + #include "src/core/lib/transport/metadata.h" #define GRPC_STATIC_MDSTR_COUNT 107 @@ -263,7 +265,8 @@ extern grpc_slice_refcount (slice).refcount->GetType() == grpc_slice_refcount::Type::STATIC) #define GRPC_STATIC_METADATA_INDEX(static_slice) \ - ((int)((static_slice).refcount - grpc_static_metadata_refcounts)) + (static_cast( \ + ((static_slice).refcount - grpc_static_metadata_refcounts))) #define GRPC_STATIC_MDELEM_COUNT 86 extern grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT]; @@ -527,7 +530,7 @@ extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT]; #define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \ (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[85], GRPC_MDELEM_STORAGE_STATIC)) -grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b); +grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b); typedef enum { GRPC_BATCH_PATH, GRPC_BATCH_METHOD, @@ -586,11 +589,11 @@ typedef union { } named; } grpc_metadata_batch_callouts; -#define GRPC_BATCH_INDEX_OF(slice) \ - (GRPC_IS_STATIC_METADATA_STRING((slice)) \ - ? (grpc_metadata_batch_callouts_index)GPR_CLAMP( \ - GRPC_STATIC_METADATA_INDEX((slice)), 0, \ - GRPC_BATCH_CALLOUTS_COUNT) \ +#define GRPC_BATCH_INDEX_OF(slice) \ + (GRPC_IS_STATIC_METADATA_STRING((slice)) \ + ? static_cast( \ + GPR_CLAMP(GRPC_STATIC_METADATA_INDEX((slice)), 0, \ + static_cast(GRPC_BATCH_CALLOUTS_COUNT))) \ : GRPC_BATCH_CALLOUTS_COUNT) extern const uint8_t grpc_static_accept_encoding_metadata[8]; diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py index 5545e871117..d66fdc3e835 100755 --- a/tools/codegen/core/gen_static_metadata.py +++ b/tools/codegen/core/gen_static_metadata.py @@ -376,6 +376,8 @@ print >> H, '#define GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H' print >> H print >> H, '#include ' print >> H +print >> H, '#include ' +print >> H print >> H, '#include "src/core/lib/transport/metadata.h"' print >> H print >> C, '#include ' @@ -433,8 +435,8 @@ for i, elem in enumerate(all_strs): print >> C, '};' print >> C print >> H, '#define GRPC_STATIC_METADATA_INDEX(static_slice) \\' -print >> H, (' ((int)((static_slice).refcount - ' - 'grpc_static_metadata_refcounts))') +print >> H, (' (static_cast(((static_slice).refcount - ' + 'grpc_static_metadata_refcounts)))') print >> H print >> D, '# hpack fuzzing dictionary' @@ -537,10 +539,10 @@ print >> C, 'static const uint8_t elem_idxs[] = {%s};' % ','.join( '%d' % i for i in idxs) print >> C -print >> H, 'grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b);' -print >> C, 'grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b) {' +print >> H, 'grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b);' +print >> C, 'grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b) {' print >> C, ' if (a == -1 || b == -1) return GRPC_MDNULL;' -print >> C, ' uint32_t k = (uint32_t)(a * %d + b);' % len(all_strs) +print >> C, ' uint32_t k = static_cast(a * %d + b);' % len(all_strs) print >> C, ' uint32_t h = elems_phash(k);' print >> C, ' return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k && elem_idxs[h] != 255 ? GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[elem_idxs[h]], GRPC_MDELEM_STORAGE_STATIC) : GRPC_MDNULL;' print >> C, '}' @@ -566,7 +568,7 @@ print >> H, ' } named;' print >> H, '} grpc_metadata_batch_callouts;' print >> H print >> H, '#define GRPC_BATCH_INDEX_OF(slice) \\' -print >> H, ' (GRPC_IS_STATIC_METADATA_STRING((slice)) ? (grpc_metadata_batch_callouts_index)GPR_CLAMP(GRPC_STATIC_METADATA_INDEX((slice)), 0, GRPC_BATCH_CALLOUTS_COUNT) : GRPC_BATCH_CALLOUTS_COUNT)' +print >> H, ' (GRPC_IS_STATIC_METADATA_STRING((slice)) ? static_cast(GPR_CLAMP(GRPC_STATIC_METADATA_INDEX((slice)), 0, static_cast(GRPC_BATCH_CALLOUTS_COUNT))) : GRPC_BATCH_CALLOUTS_COUNT)' print >> H print >> H, 'extern const uint8_t grpc_static_accept_encoding_metadata[%d];' % ( diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index ab0968b3252..489e76efd89 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1188,6 +1188,7 @@ src/core/lib/slice/percent_encoding.h \ src/core/lib/slice/slice_hash_table.h \ src/core/lib/slice/slice_internal.h \ src/core/lib/slice/slice_string_helpers.h \ +src/core/lib/slice/slice_utils.h \ src/core/lib/slice/slice_weak_hash_table.h \ src/core/lib/surface/api_trace.h \ src/core/lib/surface/call.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 293a6e1f9c1..f7c268a8105 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1451,6 +1451,7 @@ src/core/lib/slice/slice_intern.cc \ src/core/lib/slice/slice_internal.h \ src/core/lib/slice/slice_string_helpers.cc \ src/core/lib/slice/slice_string_helpers.h \ +src/core/lib/slice/slice_utils.h \ src/core/lib/slice/slice_weak_hash_table.h \ src/core/lib/surface/README.md \ src/core/lib/surface/api_trace.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index de8015ac52a..e67465d1602 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -8574,6 +8574,7 @@ "src/core/lib/slice/slice_hash_table.h", "src/core/lib/slice/slice_internal.h", "src/core/lib/slice/slice_string_helpers.h", + "src/core/lib/slice/slice_utils.h", "src/core/lib/slice/slice_weak_hash_table.h", "src/core/lib/surface/api_trace.h", "src/core/lib/surface/call.h", @@ -8730,6 +8731,7 @@ "src/core/lib/slice/slice_hash_table.h", "src/core/lib/slice/slice_internal.h", "src/core/lib/slice/slice_string_helpers.h", + "src/core/lib/slice/slice_utils.h", "src/core/lib/slice/slice_weak_hash_table.h", "src/core/lib/surface/api_trace.h", "src/core/lib/surface/call.h", From 1ff5791e47bcf2e6bdab3572f074ef5d3be5dc99 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 10 May 2019 14:33:22 -0700 Subject: [PATCH 0191/1555] Add tests for setting a channel to lame on an invalid default service config --- .../filters/client_channel/client_channel.cc | 2 - .../end2end/service_config_end2end_test.cc | 55 ++++++++++++++++++- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 757ac2a35e7..cc4bfdded13 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -1069,8 +1069,6 @@ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error) // Get default service config const char* service_config_json = grpc_channel_arg_get_string( grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVICE_CONFIG)); - // TODO(yashkt): Make sure we set the channel in TRANSIENT_FAILURE on an - // invalid default service config if (service_config_json != nullptr) { *error = GRPC_ERROR_NONE; default_service_config_ = ServiceConfig::Create(service_config_json, error); diff --git a/test/cpp/end2end/service_config_end2end_test.cc b/test/cpp/end2end/service_config_end2end_test.cc index 2d05fd42635..b3299232763 100644 --- a/test/cpp/end2end/service_config_end2end_test.cc +++ b/test/cpp/end2end/service_config_end2end_test.cc @@ -237,6 +237,14 @@ class ServiceConfigEnd2endTest : public ::testing::Test { return ::grpc::CreateCustomChannel("fake:///", creds_, args); } + std::shared_ptr BuildChannelWithInvalidDefaultServiceConfig() { + ChannelArguments args; + args.SetServiceConfigJSON(InvalidDefaultServiceConfig()); + args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, + response_generator_.get()); + return ::grpc::CreateCustomChannel("fake:///", creds_, args); + } + bool SendRpc( const std::unique_ptr& stub, EchoResponse* response = nullptr, int timeout_ms = 1000, @@ -402,7 +410,7 @@ class ServiceConfigEnd2endTest : public ::testing::Test { } const char* InvalidDefaultServiceConfig() { - return "{\"version\": \"invalid_default\"}"; + return "{\"version\": \"invalid_default\""; } const grpc::string server_host_; @@ -549,6 +557,51 @@ TEST_F(ServiceConfigEnd2endTest, CheckRpcSendFailure(stub); } +TEST_F(ServiceConfigEnd2endTest, InvalidDefaultServiceConfigTest) { + StartServers(1); + auto channel = BuildChannelWithInvalidDefaultServiceConfig(); + auto stub = BuildStub(channel); + // An invalid default service config results in a lame channel which fails all + // RPCs + CheckRpcSendFailure(stub); +} + +TEST_F(ServiceConfigEnd2endTest, + InvalidDefaultServiceConfigTestWithValidServiceConfig) { + StartServers(1); + auto channel = BuildChannelWithInvalidDefaultServiceConfig(); + auto stub = BuildStub(channel); + CheckRpcSendFailure(stub); + // An invalid default service config results in a lame channel which fails all + // RPCs + SetNextResolutionValidServiceConfig(GetServersPorts()); + CheckRpcSendFailure(stub); +} + +TEST_F(ServiceConfigEnd2endTest, + InvalidDefaultServiceConfigTestWithInvalidServiceConfig) { + StartServers(1); + auto channel = BuildChannelWithInvalidDefaultServiceConfig(); + auto stub = BuildStub(channel); + CheckRpcSendFailure(stub); + // An invalid default service config results in a lame channel which fails all + // RPCs + SetNextResolutionInvalidServiceConfig(GetServersPorts()); + CheckRpcSendFailure(stub); +} + +TEST_F(ServiceConfigEnd2endTest, + InvalidDefaultServiceConfigTestWithNoServiceConfig) { + StartServers(1); + auto channel = BuildChannelWithInvalidDefaultServiceConfig(); + auto stub = BuildStub(channel); + CheckRpcSendFailure(stub); + // An invalid default service config results in a lame channel which fails all + // RPCs + SetNextResolutionNoServiceConfig(GetServersPorts()); + CheckRpcSendFailure(stub); +} + } // namespace } // namespace testing } // namespace grpc From 90e52f00a14a2bd59c9cbc2c285399c5fd6a931f Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 10 May 2019 14:46:15 -0700 Subject: [PATCH 0192/1555] Moved code back into one file with a #ifdef --- BUILD | 2 - BUILD.gn | 2 - CMakeLists.txt | 4 -- Makefile | 4 -- build.yaml | 2 - config.m4 | 2 - config.w32 | 2 - gRPC-Core.podspec | 2 - grpc.gemspec | 2 - grpc.gyp | 4 -- package.xml | 2 - .../dns/c_ares/grpc_ares_wrapper_libuv.cc | 23 ++++++++++ .../grpc_ares_wrapper_libuv_nonwindows.cc | 39 ---------------- .../c_ares/grpc_ares_wrapper_libuv_windows.cc | 45 ------------------- .../dns/c_ares/grpc_ares_wrapper_windows.cc | 2 +- .../c_ares/grpc_ares_wrapper_windows_inner.cc | 4 +- src/core/lib/iomgr/port.h | 3 +- src/python/grpcio/grpc_core_dependencies.py | 2 - tools/doxygen/Doxyfile.core.internal | 2 - .../generated/sources_and_headers.json | 2 - 20 files changed, 28 insertions(+), 122 deletions(-) delete mode 100644 src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc delete mode 100644 src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc diff --git a/BUILD b/BUILD index 3defbf38867..9dde10224ce 100644 --- a/BUILD +++ b/BUILD @@ -1599,8 +1599,6 @@ grpc_cc_library( "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc", diff --git a/BUILD.gn b/BUILD.gn index be43b5e4217..465e808b719 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -323,8 +323,6 @@ config("grpc_config") { "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc", diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f45a109cce..e74d4bdf643 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1299,8 +1299,6 @@ add_library(grpc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc @@ -2698,8 +2696,6 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc diff --git a/Makefile b/Makefile index f7689fabf98..4cecfba196f 100644 --- a/Makefile +++ b/Makefile @@ -3771,8 +3771,6 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc \ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ @@ -5118,8 +5116,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc \ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ diff --git a/build.yaml b/build.yaml index 537127f16a0..62fefd02258 100644 --- a/build.yaml +++ b/build.yaml @@ -790,8 +790,6 @@ filegroups: - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc - - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc - - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc diff --git a/config.m4 b/config.m4 index 2f512cc8400..f29cb0c705b 100644 --- a/config.m4 +++ b/config.m4 @@ -409,8 +409,6 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc \ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ diff --git a/config.w32 b/config.w32 index d4943e8893e..4f0225974f7 100644 --- a/config.w32 +++ b/config.w32 @@ -384,8 +384,6 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_fallback.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_libuv.cc " + - "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_libuv_nonwindows.cc " + - "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_libuv_windows.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_posix.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_windows.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_windows_inner.cc " + diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 8498476a6e9..dc445811cc5 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -867,8 +867,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', diff --git a/grpc.gemspec b/grpc.gemspec index d13b007c395..aedcf57573b 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -804,8 +804,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc ) - s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc ) - s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc ) diff --git a/grpc.gyp b/grpc.gyp index 5b7bf481dd2..5feaabd456d 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -591,8 +591,6 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', @@ -1354,8 +1352,6 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', diff --git a/package.xml b/package.xml index d3935a6235b..70489bef5ce 100644 --- a/package.xml +++ b/package.xml @@ -809,8 +809,6 @@ - - diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc index 252fba916ff..eb0b3dab4a4 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc @@ -23,6 +23,13 @@ #include +#include "src/core/ext/filters/client_channel/parse_address.h" +#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" +#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" +#include "src/core/ext/filters/client_channel/server_address.h" +#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gpr/string.h" + bool grpc_ares_query_ipv6() { /* The libuv grpc code currently does not have the code to probe for this, * so we assume for now that IPv6 is always available in contexts where this @@ -30,4 +37,20 @@ bool grpc_ares_query_ipv6() { return true; } +bool grpc_ares_maybe_resolve_localhost_manually_locked( + const char* name, const char* default_port, + grpc_core::UniquePtr* addrs) { +#ifdef GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY + char* host = nullptr; + char* port = nullptr; + bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port, + addrs, &host, &port); + gpr_free(host); + gpr_free(port); + return out; +#else /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ + return false; +#endif /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ +} + #endif /* GRPC_ARES == 1 && defined(GRPC_UV) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc deleted file mode 100644 index dc8d051e2af..00000000000 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/lib/iomgr/port.h" -#if GRPC_ARES == 1 && defined(GRPC_UV) && !defined(GPR_WINDOWS) - -#include - -#include "src/core/ext/filters/client_channel/parse_address.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" -#include "src/core/ext/filters/client_channel/server_address.h" -#include "src/core/lib/gpr/host_port.h" -#include "src/core/lib/gpr/string.h" - -bool grpc_ares_maybe_resolve_localhost_manually_locked( - const char* name, const char* default_port, - grpc_core::UniquePtr* addrs) { - return false; -} - -#endif /* GRPC_ARES == 1 && defined(GRPC_UV) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc deleted file mode 100644 index d4f3944fdc7..00000000000 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/lib/iomgr/port.h" -#if GRPC_ARES == 1 && defined(GRPC_UV) && defined(GPR_WINDOWS) - -#include - -#include "src/core/ext/filters/client_channel/parse_address.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" -#include "src/core/ext/filters/client_channel/server_address.h" -#include "src/core/lib/gpr/host_port.h" -#include "src/core/lib/gpr/string.h" - -bool grpc_ares_maybe_resolve_localhost_manually_locked( - const char* name, const char* default_port, - grpc_core::UniquePtr* addrs) { - char* host = nullptr; - char* port = nullptr; - bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port, - addrs, &host, &port); - gpr_free(host); - gpr_free(port); - return out; -} - -#endif /* GRPC_ARES == 1 && defined(GRPC_UV) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc index fcb47eb5b58..e48f9501752 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc @@ -45,4 +45,4 @@ bool grpc_ares_maybe_resolve_localhost_manually_locked( return out; } -#endif /* GRPC_ARES == 1 && defined(GPR_WINDOWS) */ +#endif /* GRPC_ARES == 1 && defined(GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc index ee37144eca7..1331a6a67f5 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc @@ -19,7 +19,7 @@ #include #include "src/core/lib/iomgr/port.h" -#if GRPC_ARES == 1 && (defined(GRPC_UV) || defined(GPR_WINDOWS)) +#if GRPC_ARES == 1 && defined(GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY) #include @@ -80,4 +80,4 @@ bool inner_maybe_resolve_localhost_manually_locked( return false; } -#endif /* GRPC_ARES == 1 && (defined(GRPC_UV) || defined(GPR_WINDOWS)) */ +#endif /* GRPC_ARES == 1 && defined(GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY) */ diff --git a/src/core/lib/iomgr/port.h b/src/core/lib/iomgr/port.h index 0b3681868f7..605692ac0d6 100644 --- a/src/core/lib/iomgr/port.h +++ b/src/core/lib/iomgr/port.h @@ -44,7 +44,8 @@ #elif defined(GPR_WINDOWS) #define GRPC_WINSOCK_SOCKET 1 #define GRPC_WINDOWS_SOCKETUTILS 1 -#define GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER +#define GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER 1 +#define GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY 1 #elif defined(GPR_ANDROID) #define GRPC_HAVE_IPV6_RECVPKTINFO 1 #define GRPC_HAVE_IP_PKTINFO 1 diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index db78061a63d..c9217aded63 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -383,8 +383,6 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 4905bd365d0..765abbebd42 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -950,8 +950,6 @@ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ -src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc \ -src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index b358e855c07..512c2d51d48 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -9196,8 +9196,6 @@ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc" From f2fb11030b225cbee5534e8da86126d4d0de8dff Mon Sep 17 00:00:00 2001 From: hcaseyal Date: Thu, 9 May 2019 12:43:20 -0700 Subject: [PATCH 0193/1555] Add protected getters and setters for server health check fields --- include/grpcpp/server_impl.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/grpcpp/server_impl.h b/include/grpcpp/server_impl.h index 46bacf81d26..d4f33f185d9 100644 --- a/include/grpcpp/server_impl.h +++ b/include/grpcpp/server_impl.h @@ -199,6 +199,18 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { grpc_server* server() override { return server_; } + protected: + /// NOTE: This method is not part of the public API for this class. + void set_health_check_service( + std::unique_ptr service) { + health_check_service_ = std::move(service); + } + + /// NOTE: This method is not part of the public API for this class. + bool health_check_service_disabled() const { + return health_check_service_disabled_; + } + private: std::vector< std::unique_ptr>* From 85b9520a900663e0e8abe01651960957402760b3 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 10 May 2019 15:43:04 -0700 Subject: [PATCH 0194/1555] Fix sanity --- .../resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h index ed40e58f7cc..783b781154c 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h @@ -16,8 +16,8 @@ * */ -#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_LIBUV_WINDOWS_H -#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_LIBUV_WINDOWS_H +#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_WINDOWS_INNER_H +#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_WINDOWS_INNER_H #include @@ -30,5 +30,5 @@ bool inner_maybe_resolve_localhost_manually_locked( grpc_core::UniquePtr* addrs, char** host, char** port); -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_LIBUV_WINDOWS_H \ +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_WINDOWS_INNER_H \ */ From e16a0d45998e531154f4e085d892600f544f8409 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 10 May 2019 15:53:45 -0700 Subject: [PATCH 0195/1555] Fix typo --- BUILD.gn | 2 +- build.yaml | 2 +- gRPC-C++.podspec | 2 +- gRPC-Core.podspec | 4 ++-- grpc.gemspec | 2 +- package.xml | 2 +- tools/doxygen/Doxyfile.core.internal | 2 +- tools/run_tests/generated/sources_and_headers.json | 8 ++++---- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 465e808b719..7357d0f9595 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -318,7 +318,6 @@ config("grpc_config") { "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", @@ -326,6 +325,7 @@ config("grpc_config") { "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h", "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc", "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h", "src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc", diff --git a/build.yaml b/build.yaml index 62fefd02258..d1d69ef5f95 100644 --- a/build.yaml +++ b/build.yaml @@ -779,8 +779,8 @@ filegroups: - name: grpc_resolver_dns_ares headers: - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h - - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h + - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h src: - src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 65af7f5f3e6..67e07670ead 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -561,8 +561,8 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index dc445811cc5..393a9100933 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -537,8 +537,8 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', @@ -1190,8 +1190,8 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', diff --git a/grpc.gemspec b/grpc.gemspec index aedcf57573b..b0ea43b9d92 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -471,8 +471,8 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/subchannel_list.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h ) - s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h ) + s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h ) s.files += %w( src/core/ext/filters/max_age/max_age_filter.h ) s.files += %w( src/core/ext/filters/message_size/message_size_filter.h ) diff --git a/package.xml b/package.xml index 70489bef5ce..2335e3527ba 100644 --- a/package.xml +++ b/package.xml @@ -476,8 +476,8 @@ - + diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 765abbebd42..483e639be66 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -945,7 +945,6 @@ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc \ -src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ @@ -953,6 +952,7 @@ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv. src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ +src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h \ src/core/ext/filters/client_channel/resolver/dns/native/README.md \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 512c2d51d48..de08e38a838 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -9178,8 +9178,8 @@ ], "headers": [ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" ], "is_filegroup": true, "language": "c", @@ -9191,14 +9191,14 @@ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc" + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" ], "third_party": false, "type": "filegroup" From 86febe4121cbc00e5fc6a3ec32971d3dbce5f496 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Mon, 13 May 2019 10:56:58 -0700 Subject: [PATCH 0196/1555] Made Fork.support_enabled_ atomic --- src/core/lib/gprpp/fork.cc | 2 +- src/core/lib/gprpp/fork.h | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/lib/gprpp/fork.cc b/src/core/lib/gprpp/fork.cc index cacf5e82e5a..37552692373 100644 --- a/src/core/lib/gprpp/fork.cc +++ b/src/core/lib/gprpp/fork.cc @@ -243,7 +243,7 @@ void Fork::AwaitThreads() { internal::ExecCtxState* Fork::exec_ctx_state_ = nullptr; internal::ThreadState* Fork::thread_state_ = nullptr; -bool Fork::support_enabled_ = false; +std::atomic Fork::support_enabled_; bool Fork::override_enabled_ = false; Fork::child_postfork_func Fork::reset_child_polling_engine_ = nullptr; } // namespace grpc_core diff --git a/src/core/lib/gprpp/fork.h b/src/core/lib/gprpp/fork.h index 5a7404f0d91..73f2fa56aa7 100644 --- a/src/core/lib/gprpp/fork.h +++ b/src/core/lib/gprpp/fork.h @@ -19,6 +19,10 @@ #ifndef GRPC_CORE_LIB_GPRPP_FORK_H #define GRPC_CORE_LIB_GPRPP_FORK_H +#include + +#include + /* * NOTE: FORKING IS NOT GENERALLY SUPPORTED, THIS IS ONLY INTENDED TO WORK * AROUND VERY SPECIFIC USE CASES. @@ -78,7 +82,7 @@ class Fork { private: static internal::ExecCtxState* exec_ctx_state_; static internal::ThreadState* thread_state_; - static bool support_enabled_; + static std::atomic support_enabled_; static bool override_enabled_; static child_postfork_func reset_child_polling_engine_; }; From a02c76dfb920da5039a48faad0b3daac0ead05d1 Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Mon, 13 May 2019 13:29:06 -0700 Subject: [PATCH 0197/1555] Cancel predefine number of streaming --- .../callback_streaming_ping_pong.h | 2 -- .../microbenchmarks/callback_test_service.cc | 23 ++++--------------- .../microbenchmarks/callback_test_service.h | 1 - 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h index 0f4549df3ff..9fb86bd8299 100644 --- a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h @@ -83,8 +83,6 @@ class BidiClient void StartNewRpc() { cli_ctx_->~ClientContext(); new (cli_ctx_) ClientContext(); - cli_ctx_->AddMetadata(kServerFinishAfterNReads, - grpc::to_string(msgs_to_send_)); cli_ctx_->AddMetadata(kServerMessageSize, grpc::to_string(msgs_size_)); stub_->experimental_async()->BidiStream(cli_ctx_, this); MaybeWrite(); diff --git a/test/cpp/microbenchmarks/callback_test_service.cc b/test/cpp/microbenchmarks/callback_test_service.cc index 2473dc5f31d..321a5b39184 100644 --- a/test/cpp/microbenchmarks/callback_test_service.cc +++ b/test/cpp/microbenchmarks/callback_test_service.cc @@ -67,54 +67,41 @@ CallbackStreamingTestService::BidiStream() { Reactor() {} void OnStarted(ServerContext* context) override { ctx_ = context; - server_write_last_ = GetIntValueFromMetadata( - kServerFinishAfterNReads, context->client_metadata(), 0); message_size_ = GetIntValueFromMetadata(kServerMessageSize, context->client_metadata(), 0); StartRead(&request_); } void OnDone() override { GPR_ASSERT(finished_); - GPR_ASSERT(num_msgs_read_ == server_write_last_); delete this; } void OnCancel() override {} void OnReadDone(bool ok) override { if (!ok) { - gpr_log(GPR_ERROR, "Server read failed"); + // Stream is over + Finish(::grpc::Status::OK); + finished_ = true; return; } - num_msgs_read_++; if (message_size_ > 0) { response_.set_message(std::string(message_size_, 'a')); } else { response_.set_message(""); } - if (num_msgs_read_ < server_write_last_) { - StartWrite(&response_); - } else { - StartWriteLast(&response_, WriteOptions()); - } + StartWrite(&response_); } void OnWriteDone(bool ok) override { if (!ok) { gpr_log(GPR_ERROR, "Server write failed"); return; } - if (num_msgs_read_ < server_write_last_) { - StartRead(&request_); - } else { - Finish(::grpc::Status::OK); - finished_ = true; - } + StartRead(&request_); } private: ServerContext* ctx_; EchoRequest request_; EchoResponse response_; - int num_msgs_read_{0}; - int server_write_last_; int message_size_; bool finished_{false}; }; diff --git a/test/cpp/microbenchmarks/callback_test_service.h b/test/cpp/microbenchmarks/callback_test_service.h index dd7977a5913..97188595382 100644 --- a/test/cpp/microbenchmarks/callback_test_service.h +++ b/test/cpp/microbenchmarks/callback_test_service.h @@ -30,7 +30,6 @@ namespace grpc { namespace testing { -const char* const kServerFinishAfterNReads = "server_finish_after_n_reads"; const char* const kServerMessageSize = "server_message_size"; class CallbackStreamingTestService From 4e711fab644fb30c2e0cae6cb7f01aa56e9dbd75 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 13 May 2019 13:51:14 -0700 Subject: [PATCH 0198/1555] Add method to validate and set service config json --- .../grpcpp/support/channel_arguments_impl.h | 23 ++++++++++++++++++- src/cpp/common/channel_arguments.cc | 15 +++++++++++- .../end2end/service_config_end2end_test.cc | 8 ++++++- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/include/grpcpp/support/channel_arguments_impl.h b/include/grpcpp/support/channel_arguments_impl.h index 0efeadca880..631992d28c3 100644 --- a/include/grpcpp/support/channel_arguments_impl.h +++ b/include/grpcpp/support/channel_arguments_impl.h @@ -40,8 +40,24 @@ class SecureChannelCredentials; /// Options for channel creation. The user can use generic setters to pass /// key value pairs down to C channel creation code. For gRPC related options, /// concrete setters are provided. -class ChannelArguments { +class ChannelArguments : private ::grpc::GrpcLibraryCodegen { public: + /// NOTE: class experimental_type is not part of the public API of this class. + /// TODO(yashykt): Integrate into public API when this is no longer + /// experimental. + class experimental_type { + public: + explicit experimental_type(ChannelArguments* args) : args_(args) {} + + /// Validates \a service_config_json. If valid, set the service config and + /// returns an empty string. If invalid, returns the validation error. + grpc::string ValidateAndSetServiceConfigJSON( + const grpc::string& service_config_json); + + private: + ChannelArguments* args_; + }; + ChannelArguments(); ~ChannelArguments(); @@ -125,6 +141,11 @@ class ChannelArguments { return out; } + /// NOTE: The function experimental() is not stable public API. It is a view + /// to the experimental components of this class. It may be changed or removed + /// at any time. + experimental_type experimental() { return experimental_type(this); } + private: friend class grpc_impl::SecureChannelCredentials; friend class grpc::testing::ChannelArgumentsTest; diff --git a/src/cpp/common/channel_arguments.cc b/src/cpp/common/channel_arguments.cc index 932139890fe..faea3316c58 100644 --- a/src/cpp/common/channel_arguments.cc +++ b/src/cpp/common/channel_arguments.cc @@ -23,6 +23,7 @@ #include #include #include +#include "src/core/ext/filters/client_channel/service_config.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/socket_mutator.h" @@ -35,7 +36,7 @@ ChannelArguments::ChannelArguments() { } ChannelArguments::ChannelArguments(const ChannelArguments& other) - : strings_(other.strings_) { + : ::grpc::GrpcLibraryCodegen(), strings_(other.strings_) { args_.reserve(other.args_.size()); auto list_it_dst = strings_.begin(); auto list_it_src = other.strings_.begin(); @@ -215,4 +216,16 @@ void ChannelArguments::SetChannelArgs(grpc_channel_args* channel_args) const { } } +grpc::string +ChannelArguments::experimental_type::ValidateAndSetServiceConfigJSON( + const grpc::string& service_config_json) { + grpc_error* error = GRPC_ERROR_NONE; + grpc_core::ServiceConfig::Create(service_config_json.c_str(), &error); + if (error != GRPC_ERROR_NONE) { + return grpc_error_string(error); + } + args_->SetServiceConfigJSON(service_config_json); + return ""; +} + } // namespace grpc_impl diff --git a/test/cpp/end2end/service_config_end2end_test.cc b/test/cpp/end2end/service_config_end2end_test.cc index b3299232763..74a304f6b26 100644 --- a/test/cpp/end2end/service_config_end2end_test.cc +++ b/test/cpp/end2end/service_config_end2end_test.cc @@ -231,7 +231,9 @@ class ServiceConfigEnd2endTest : public ::testing::Test { std::shared_ptr BuildChannelWithDefaultServiceConfig() { ChannelArguments args; - args.SetServiceConfigJSON(ValidDefaultServiceConfig()); + EXPECT_THAT(args.experimental().ValidateAndSetServiceConfigJSON( + ValidDefaultServiceConfig()), + ::testing::StrEq("")); args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, response_generator_.get()); return ::grpc::CreateCustomChannel("fake:///", creds_, args); @@ -239,6 +241,10 @@ class ServiceConfigEnd2endTest : public ::testing::Test { std::shared_ptr BuildChannelWithInvalidDefaultServiceConfig() { ChannelArguments args; + EXPECT_THAT( + args.experimental().ValidateAndSetServiceConfigJSON( + InvalidDefaultServiceConfig()), + ::testing::HasSubstr("failed to parse JSON for service config")); args.SetServiceConfigJSON(InvalidDefaultServiceConfig()); args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, response_generator_.get()); From d115e39a4a301321b647782c14ddb771b7129e01 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 13 May 2019 15:04:23 -0700 Subject: [PATCH 0199/1555] Add initialization note --- include/grpcpp/support/channel_arguments_impl.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/grpcpp/support/channel_arguments_impl.h b/include/grpcpp/support/channel_arguments_impl.h index 631992d28c3..e31f7e80db0 100644 --- a/include/grpcpp/support/channel_arguments_impl.h +++ b/include/grpcpp/support/channel_arguments_impl.h @@ -40,6 +40,9 @@ class SecureChannelCredentials; /// Options for channel creation. The user can use generic setters to pass /// key value pairs down to C channel creation code. For gRPC related options, /// concrete setters are provided. +/// This class derives from GrpcLibraryCodegen so that gRPC is initialized +/// before ValidateAndSetServiceConfigJSON is used. (Service config validation +/// methods are registered at initialization.) class ChannelArguments : private ::grpc::GrpcLibraryCodegen { public: /// NOTE: class experimental_type is not part of the public API of this class. From 3a9c96301a259d469ff5cc975c008f402af2cbe8 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 13 May 2019 15:05:43 -0700 Subject: [PATCH 0200/1555] s/set/sets --- include/grpcpp/support/channel_arguments_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grpcpp/support/channel_arguments_impl.h b/include/grpcpp/support/channel_arguments_impl.h index e31f7e80db0..9a034078033 100644 --- a/include/grpcpp/support/channel_arguments_impl.h +++ b/include/grpcpp/support/channel_arguments_impl.h @@ -52,7 +52,7 @@ class ChannelArguments : private ::grpc::GrpcLibraryCodegen { public: explicit experimental_type(ChannelArguments* args) : args_(args) {} - /// Validates \a service_config_json. If valid, set the service config and + /// Validates \a service_config_json. If valid, sets the service config and /// returns an empty string. If invalid, returns the validation error. grpc::string ValidateAndSetServiceConfigJSON( const grpc::string& service_config_json); From 15d8fd9b23d1b01bb8da7563dcddb22c09288bb8 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 13 May 2019 16:09:48 -0700 Subject: [PATCH 0201/1555] Missing error unref --- src/cpp/common/channel_arguments.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cpp/common/channel_arguments.cc b/src/cpp/common/channel_arguments.cc index faea3316c58..84b786299c6 100644 --- a/src/cpp/common/channel_arguments.cc +++ b/src/cpp/common/channel_arguments.cc @@ -222,7 +222,9 @@ ChannelArguments::experimental_type::ValidateAndSetServiceConfigJSON( grpc_error* error = GRPC_ERROR_NONE; grpc_core::ServiceConfig::Create(service_config_json.c_str(), &error); if (error != GRPC_ERROR_NONE) { - return grpc_error_string(error); + grpc::string return_value = grpc_error_string(error); + GRPC_ERROR_UNREF(error); + return return_value; } args_->SetServiceConfigJSON(service_config_json); return ""; From 57e090989aa826073e95ed58397ddf327eb320d5 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Tue, 14 May 2019 21:20:31 +1200 Subject: [PATCH 0202/1555] Add managed .NET gRPC client to interop tests --- .../grpc_interop_aspnetcore/build_interop.sh.template | 3 +-- .../grpc_interop_aspnetcore/build_interop.sh | 3 +-- tools/run_tests/run_interop_tests.py | 11 ++++++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/templates/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh.template b/templates/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh.template index 05ad947e944..d64286ab03c 100644 --- a/templates/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh.template +++ b/templates/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh.template @@ -41,5 +41,4 @@ ./build/get-grpc.sh - cd testassets/InteropTestsWebsite - dotnet build --configuration Debug + dotnet build --configuration Debug Grpc.AspNetCore.sln diff --git a/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh b/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh index 2a3e6f3a0ee..65e848ded32 100644 --- a/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh +++ b/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh @@ -39,5 +39,4 @@ fi ./build/get-grpc.sh -cd testassets/InteropTestsWebsite -dotnet build --configuration Debug +dotnet build --configuration Debug Grpc.AspNetCore.sln diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py index 567c628d8e0..cc6901bdebe 100755 --- a/tools/run_tests/run_interop_tests.py +++ b/tools/run_tests/run_interop_tests.py @@ -192,7 +192,7 @@ class CSharpCoreCLRLanguage: class AspNetCoreLanguage: def __init__(self): - self.client_cwd = '../grpc-dotnet' + self.client_cwd = '../grpc-dotnet/testassets/InteropTestsClient/bin/Debug/netcoreapp3.0' self.server_cwd = '../grpc-dotnet/testassets/InteropTestsWebsite/bin/Debug/netcoreapp3.0' self.safename = str(self) @@ -200,8 +200,7 @@ class AspNetCoreLanguage: return {} def client_cmd(self, args): - # attempt to run client should fail - return ['dotnet' 'exec', 'CLIENT_NOT_SUPPORTED'] + args + return ['dotnet', 'exec', 'InteropTestsClient.dll'] + args def server_cmd(self, args): return ['dotnet', 'exec', 'InteropTestsWebsite.dll'] + args @@ -210,8 +209,10 @@ class AspNetCoreLanguage: return {} def unimplemented_test_cases(self): - # aspnetcore doesn't have a client so ignore all test cases. - return _TEST_CASES + _AUTH_TEST_CASES + return _SKIP_COMPRESSION + \ + _SKIP_SPECIAL_STATUS_MESSAGE + \ + _AUTH_TEST_CASES + \ + ['cancel_after_first_response', 'ping_pong'] def unimplemented_test_cases_server(self): return _SKIP_COMPRESSION + _SKIP_SPECIAL_STATUS_MESSAGE From f299391f15927561927282a495c50e8d97c1ea16 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 14 May 2019 10:36:49 -0700 Subject: [PATCH 0203/1555] Add GrpcLibraryInitializer --- src/cpp/common/channel_arguments.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cpp/common/channel_arguments.cc b/src/cpp/common/channel_arguments.cc index 84b786299c6..48dfe815042 100644 --- a/src/cpp/common/channel_arguments.cc +++ b/src/cpp/common/channel_arguments.cc @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "src/core/ext/filters/client_channel/service_config.h" #include "src/core/lib/channel/channel_args.h" @@ -30,7 +31,12 @@ namespace grpc_impl { +namespace { +::grpc::internal::GrpcLibraryInitializer g_gli_initializer; +} // namespace + ChannelArguments::ChannelArguments() { + g_gli_initializer.summon(); // This will be ignored if used on the server side. SetString(GRPC_ARG_PRIMARY_USER_AGENT_STRING, "grpc-c++/" + grpc::Version()); } From 2ba3209b336e147cff3f12ca18f449db7705f7c3 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 14 May 2019 11:57:08 -0700 Subject: [PATCH 0204/1555] Fix bug from #19002. --- .../filters/client_channel/health/health_check_client.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/ext/filters/client_channel/health/health_check_client.cc b/src/core/ext/filters/client_channel/health/health_check_client.cc index bfac773899d..faa2ba5b3b1 100644 --- a/src/core/ext/filters/client_channel/health/health_check_client.cc +++ b/src/core/ext/filters/client_channel/health/health_check_client.cc @@ -323,6 +323,11 @@ void HealthCheckClient::CallState::StartCall() { grpc_error* error = GRPC_ERROR_NONE; call_ = health_check_client_->connected_subchannel_->CreateCall(args, &error) .release(); + // Register after-destruction callback. + GRPC_CLOSURE_INIT(&after_call_stack_destruction_, AfterCallStackDestruction, + this, grpc_schedule_on_exec_ctx); + call_->SetAfterCallStackDestroy(&after_call_stack_destruction_); + // Check if creation failed. if (error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "HealthCheckClient %p CallState %p: error creating health " @@ -338,10 +343,6 @@ void HealthCheckClient::CallState::StartCall() { GRPC_ERROR_NONE); return; } - // Register after-destruction callback. - GRPC_CLOSURE_INIT(&after_call_stack_destruction_, AfterCallStackDestruction, - this, grpc_schedule_on_exec_ctx); - call_->SetAfterCallStackDestroy(&after_call_stack_destruction_); // Initialize payload and batch. payload_.context = context_; batch_.payload = &payload_; From e68316dda5c607118c9a20e79d46a2b99c72fccb Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 14 May 2019 12:07:05 -0700 Subject: [PATCH 0205/1555] Fix errors from clang format script --- src/core/lib/surface/completion_queue.cc | 18 ++++++++---------- test/core/surface/completion_queue_test.cc | 3 ++- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index 18cc15d8b7a..2b60033c42c 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -862,11 +862,10 @@ static void cq_end_op_for_callback( } auto* functor = static_cast(tag); - GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_CREATE( - functor_callback, functor, - grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::LONG)), - GRPC_ERROR_REF(error)); + GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(functor_callback, functor, + grpc_core::Executor::Scheduler( + grpc_core::ExecutorJobType::LONG)), + GRPC_ERROR_REF(error)); GRPC_ERROR_UNREF(error); } @@ -1352,11 +1351,10 @@ static void cq_finish_shutdown_callback(grpc_completion_queue* cq) { GPR_ASSERT(cqd->shutdown_called); cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done); - GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_CREATE( - functor_callback, callback, - grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::LONG)), - GRPC_ERROR_NONE); + GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(functor_callback, callback, + grpc_core::Executor::Scheduler( + grpc_core::ExecutorJobType::LONG)), + GRPC_ERROR_NONE); } static void cq_shutdown_callback(grpc_completion_queue* cq) { diff --git a/test/core/surface/completion_queue_test.cc b/test/core/surface/completion_queue_test.cc index 214d673cdf6..35a67387335 100644 --- a/test/core/surface/completion_queue_test.cc +++ b/test/core/surface/completion_queue_test.cc @@ -463,7 +463,8 @@ static void test_callback(void) { gpr_mu_lock(&shutdown_mu); while (!got_shutdown) { // Wait for the shutdown callback to complete. - gpr_cv_wait(&shutdown_cv, &shutdown_mu, gpr_inf_future(GPR_CLOCK_REALTIME)); + gpr_cv_wait(&shutdown_cv, &shutdown_mu, + gpr_inf_future(GPR_CLOCK_REALTIME)); } gpr_mu_unlock(&shutdown_mu); } From a73f22bd73d72223136658d8ce1cd3da46d6457f Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 14 May 2019 12:10:17 -0700 Subject: [PATCH 0206/1555] Make the executor SHORT instead of LONG. --- src/core/lib/surface/completion_queue.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index 2b60033c42c..8dce0e01141 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -864,7 +864,7 @@ static void cq_end_op_for_callback( auto* functor = static_cast(tag); GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(functor_callback, functor, grpc_core::Executor::Scheduler( - grpc_core::ExecutorJobType::LONG)), + grpc_core::ExecutorJobType::SHORT)), GRPC_ERROR_REF(error)); GRPC_ERROR_UNREF(error); @@ -1353,7 +1353,7 @@ static void cq_finish_shutdown_callback(grpc_completion_queue* cq) { cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done); GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(functor_callback, callback, grpc_core::Executor::Scheduler( - grpc_core::ExecutorJobType::LONG)), + grpc_core::ExecutorJobType::SHORT)), GRPC_ERROR_NONE); } From 091c12ad79049558c80bc3831c0198ea216c6673 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 14 May 2019 12:55:20 -0700 Subject: [PATCH 0207/1555] Fix clang errors --- src/core/lib/surface/completion_queue.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index 8dce0e01141..cdf1020051f 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -862,10 +862,11 @@ static void cq_end_op_for_callback( } auto* functor = static_cast(tag); - GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(functor_callback, functor, - grpc_core::Executor::Scheduler( - grpc_core::ExecutorJobType::SHORT)), - GRPC_ERROR_REF(error)); + GRPC_CLOSURE_SCHED( + GRPC_CLOSURE_CREATE( + functor_callback, functor, + grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), + GRPC_ERROR_REF(error)); GRPC_ERROR_UNREF(error); } @@ -1351,10 +1352,11 @@ static void cq_finish_shutdown_callback(grpc_completion_queue* cq) { GPR_ASSERT(cqd->shutdown_called); cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done); - GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(functor_callback, callback, - grpc_core::Executor::Scheduler( - grpc_core::ExecutorJobType::SHORT)), - GRPC_ERROR_NONE); + GRPC_CLOSURE_SCHED( + GRPC_CLOSURE_CREATE( + functor_callback, callback, + grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), + GRPC_ERROR_NONE); } static void cq_shutdown_callback(grpc_completion_queue* cq) { From 053c62c78f4505a9ee833cfb240dff030dea585d Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 14 May 2019 22:43:23 +0200 Subject: [PATCH 0208/1555] Adding bazel wrapper for our sanctified version of bazel. --- .gitignore | 3 ++- tools/bazel.sh | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100755 tools/bazel.sh diff --git a/.gitignore b/.gitignore index 7b4c5d36cb4..bc324b5f826 100644 --- a/.gitignore +++ b/.gitignore @@ -109,13 +109,14 @@ Podfile.lock # IDE specific folder for JetBrains IDEs .idea/ -# Blaze files +# Bazel files bazel-bin bazel-genfiles bazel-grpc bazel-out bazel-testlogs bazel_format_virtual_environment/ +tools/bazel-* # Debug output gdb.txt diff --git a/tools/bazel.sh b/tools/bazel.sh new file mode 100755 index 00000000000..804b974700b --- /dev/null +++ b/tools/bazel.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# Keeping up with Bazel's breaking changes is currently difficult. +# This script wraps calling bazel by downloading the currently +# supported version, and then calling it. This way, we can make sure +# that running bazel will always get meaningful results, at least +# until Bazel 1.0 is released. + +set -e + +VERSION=0.24.1 + +CWD=`pwd` +BASEURL=https://github.com/bazelbuild/bazel/releases/download/ +cd `dirname $0` +TOOLDIR=`pwd` + +case `uname -sm` in + "Linux x86_64") + suffix=linux-x86_64 + ;; + "Darwin x86_64") + suffix=darwin-x86_64 + ;; + *) + echo "Unsupported architecture: `uname -sm`" + exit 1 + ;; +esac + +filename=bazel-$VERSION-$suffix + +if [ ! -x $filename ] ; then + curl -L $BASEURL/$VERSION/$filename > $filename + chmod a+x $filename +fi + +cd $CWD +$TOOLDIR/$filename $@ From 236ae12bb115c307d1cd7d0b88c7aaa082e3dd0a Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Tue, 14 May 2019 14:36:33 -0700 Subject: [PATCH 0209/1555] Revert "Config migration" This reverts commit 87905ae5ead879a3baff731b3bed5408249beacd. --- BUILD | 16 ------- BUILD.gn | 2 - CMakeLists.txt | 2 - Makefile | 2 - build.yaml | 9 ---- config.m4 | 2 - config.w32 | 1 - gRPC-C++.podspec | 1 - gRPC-Core.podspec | 3 -- grpc.gemspec | 2 - grpc.gyp | 2 - package.xml | 2 - .../interop/app/src/main/cpp/grpc-interop.cc | 6 +-- .../filters/client_channel/backup_poller.cc | 11 ++--- .../client_channel/http_connect_handshaker.cc | 1 + .../resolver/dns/c_ares/dns_resolver_ares.cc | 14 +++--- .../resolver/dns/dns_resolver_selection.cc | 28 ------------ .../resolver/dns/dns_resolver_selection.h | 29 ------------ .../resolver/dns/native/dns_resolver.cc | 8 ++-- .../chttp2/transport/chttp2_plugin.cc | 7 +-- src/core/lib/debug/trace.cc | 20 +++------ src/core/lib/debug/trace.h | 8 ---- src/core/lib/gpr/env.h | 6 +++ src/core/lib/gpr/env_linux.cc | 2 +- src/core/lib/gpr/env_windows.cc | 5 +++ src/core/lib/gpr/log.cc | 22 ++++++---- src/core/lib/gprpp/fork.cc | 41 ++++++++++++----- src/core/lib/iomgr/ev_posix.cc | 26 +++++------ src/core/lib/iomgr/ev_posix.h | 3 -- src/core/lib/iomgr/fork_posix.cc | 1 + src/core/lib/iomgr/iomgr.cc | 3 +- src/core/lib/profiling/basic_timers.cc | 14 ++---- .../load_system_roots_linux.cc | 12 +++-- .../security_connector/security_connector.cc | 1 + .../security/security_connector/ssl_utils.cc | 44 ++++++++----------- .../security/security_connector/ssl_utils.h | 6 +-- src/core/lib/surface/init.cc | 2 +- .../private/GRPCSecureChannelFactory.m | 3 +- .../CoreCronetEnd2EndTests.mm | 4 +- src/python/grpcio/grpc_core_dependencies.py | 1 - test/core/bad_connection/close_fd_test.cc | 1 + test/core/bad_ssl/bad_ssl_test.cc | 4 +- .../resolvers/dns_resolver_test.cc | 8 ++-- test/core/end2end/fixtures/h2_full+trace.cc | 4 +- .../end2end/fixtures/h2_sockpair+trace.cc | 5 +-- test/core/end2end/fixtures/h2_spiffe.cc | 3 +- test/core/end2end/fixtures/h2_ssl.cc | 4 +- .../end2end/fixtures/h2_ssl_cred_reload.cc | 4 +- test/core/end2end/fixtures/h2_ssl_proxy.cc | 4 +- test/core/end2end/h2_ssl_cert_test.cc | 4 +- .../core/end2end/h2_ssl_session_reuse_test.cc | 4 +- test/core/end2end/tests/keepalive_timeout.cc | 14 +++--- test/core/gpr/log_test.cc | 13 ++---- test/core/http/httpscli_test.cc | 3 +- test/core/iomgr/resolve_address_posix_test.cc | 18 ++++---- test/core/iomgr/resolve_address_test.cc | 13 +++--- test/core/security/credentials_test.cc | 2 +- test/core/security/security_connector_test.cc | 10 ++--- test/core/util/test_config.cc | 1 + test/cpp/end2end/async_end2end_test.cc | 12 ++--- test/cpp/end2end/end2end_test.cc | 12 ++--- test/cpp/naming/address_sorting_test.cc | 14 +++--- test/cpp/naming/cancel_ares_query_test.cc | 4 +- test/cpp/naming/resolver_component_test.cc | 1 + tools/doxygen/Doxyfile.core.internal | 2 - .../generated/sources_and_headers.json | 24 +--------- tools/run_tests/run_microbenchmark.py | 2 +- .../run_tests/sanity/core_banned_functions.py | 4 ++ 68 files changed, 208 insertions(+), 358 deletions(-) delete mode 100644 src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc delete mode 100644 src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h diff --git a/BUILD b/BUILD index ddd1f97b541..61a031ec022 100644 --- a/BUILD +++ b/BUILD @@ -1562,20 +1562,6 @@ grpc_cc_library( ], ) -grpc_cc_library( - name = "grpc_resolver_dns_selection", - srcs = [ - "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc", - ], - hdrs = [ - "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h", - ], - language = "c++", - deps = [ - "grpc_base", - ], -) - grpc_cc_library( name = "grpc_resolver_dns_native", srcs = [ @@ -1585,7 +1571,6 @@ grpc_cc_library( deps = [ "grpc_base", "grpc_client_channel", - "grpc_resolver_dns_selection", ], ) @@ -1617,7 +1602,6 @@ grpc_cc_library( deps = [ "grpc_base", "grpc_client_channel", - "grpc_resolver_dns_selection", ], ) diff --git a/BUILD.gn b/BUILD.gn index dcd5bc880eb..a46e70e1565 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -326,8 +326,6 @@ config("grpc_config") { "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc", - "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h", "src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc", "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc", "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f137969aea..37fbc14fc26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1308,7 +1308,6 @@ add_library(grpc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc src/core/ext/filters/census/grpc_context.cc @@ -2705,7 +2704,6 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc diff --git a/Makefile b/Makefile index f7aa0461183..26883daedec 100644 --- a/Makefile +++ b/Makefile @@ -3784,7 +3784,6 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ src/core/ext/filters/census/grpc_context.cc \ @@ -5129,7 +5128,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ diff --git a/build.yaml b/build.yaml index 0f48db4cbc6..65abbc469e6 100644 --- a/build.yaml +++ b/build.yaml @@ -798,7 +798,6 @@ filegroups: uses: - grpc_base - grpc_client_channel - - grpc_resolver_dns_selection - name: grpc_resolver_dns_native src: - src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc @@ -806,14 +805,6 @@ filegroups: uses: - grpc_base - grpc_client_channel - - grpc_resolver_dns_selection -- name: grpc_resolver_dns_selection - headers: - - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h - src: - - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc - uses: - - grpc_base - name: grpc_resolver_fake headers: - src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h diff --git a/config.m4 b/config.m4 index d90a8e94e6d..c5ecf7cfd6a 100644 --- a/config.m4 +++ b/config.m4 @@ -412,7 +412,6 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ src/core/ext/filters/census/grpc_context.cc \ @@ -696,7 +695,6 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/pick_first) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/round_robin) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/xds) - PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns/c_ares) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns/native) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/fake) diff --git a/config.w32 b/config.w32 index 70ac245d9fa..6bcc54f6630 100644 --- a/config.w32 +++ b/config.w32 @@ -387,7 +387,6 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_libuv_windows.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_posix.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_windows.cc " + - "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\dns_resolver_selection.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\native\\dns_resolver.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\sockaddr\\sockaddr_resolver.cc " + "src\\core\\ext\\filters\\census\\grpc_context.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 10e37bb5f47..e9cf58438e8 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -564,7 +564,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h', - 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', 'src/core/ext/filters/http/client_authority_filter.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 318150c85d5..dd68bbbd609 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -540,7 +540,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h', - 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', 'src/core/ext/filters/http/client_authority_filter.h', @@ -871,7 +870,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/census/grpc_context.cc', @@ -1194,7 +1192,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h', - 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', 'src/core/ext/filters/http/client_authority_filter.h', diff --git a/grpc.gemspec b/grpc.gemspec index 03b0116e149..ecf17e998ac 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -474,7 +474,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h ) - s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h ) s.files += %w( src/core/ext/filters/max_age/max_age_filter.h ) s.files += %w( src/core/ext/filters/message_size/message_size_filter.h ) s.files += %w( src/core/ext/filters/http/client_authority_filter.h ) @@ -808,7 +807,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc ) - s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc ) s.files += %w( src/core/ext/filters/census/grpc_context.cc ) diff --git a/grpc.gyp b/grpc.gyp index 3e2e984ccbf..02342d441bb 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -594,7 +594,6 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/census/grpc_context.cc', @@ -1355,7 +1354,6 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', diff --git a/package.xml b/package.xml index feb55cc777f..7d33a000fae 100644 --- a/package.xml +++ b/package.xml @@ -479,7 +479,6 @@ - @@ -813,7 +812,6 @@ - diff --git a/src/android/test/interop/app/src/main/cpp/grpc-interop.cc b/src/android/test/interop/app/src/main/cpp/grpc-interop.cc index b5075529be2..07834250d22 100644 --- a/src/android/test/interop/app/src/main/cpp/grpc-interop.cc +++ b/src/android/test/interop/app/src/main/cpp/grpc-interop.cc @@ -18,8 +18,8 @@ #include #include +#include -#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/cpp/interop/interop_client.h" extern "C" JNIEXPORT void JNICALL @@ -28,7 +28,7 @@ Java_io_grpc_interop_cpp_InteropActivity_configureSslRoots(JNIEnv* env, jstring path_raw) { const char* path = env->GetStringUTFChars(path_raw, (jboolean*)0); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, path); + gpr_setenv("GRPC_DEFAULT_SSL_ROOTS_FILE_PATH", path); } std::shared_ptr GetClient(const char* host, @@ -45,7 +45,7 @@ std::shared_ptr GetClient(const char* host, credentials = grpc::InsecureChannelCredentials(); } - grpc::testing::ChannelCreationFunc channel_creation_func = + grpc::testing::ChannelCreationFunc channel_creation_func = std::bind(grpc::CreateChannel, host_port, credentials); return std::shared_ptr( new grpc::testing::InteropClient(channel_creation_func, true, false)); diff --git a/src/core/ext/filters/client_channel/backup_poller.cc b/src/core/ext/filters/client_channel/backup_poller.cc index dd761694414..a2d45c04026 100644 --- a/src/core/ext/filters/client_channel/backup_poller.cc +++ b/src/core/ext/filters/client_channel/backup_poller.cc @@ -56,14 +56,9 @@ static backup_poller* g_poller = nullptr; // guarded by g_poller_mu // treated as const. static int g_poll_interval_ms = DEFAULT_POLL_INTERVAL_MS; -GPR_GLOBAL_CONFIG_DEFINE_INT32( - grpc_client_channel_backup_poll_interval_ms, DEFAULT_POLL_INTERVAL_MS, - "Declares the interval in ms between two backup polls on client channels. " - "These polls are run in the timer thread so that gRPC can process " - "connection failures while there is no active polling thread. " - "They help reconnect disconnected client channels (mostly due to " - "idleness), so that the next RPC on this channel won't fail. Set to 0 to " - "turn off the backup polls."); +GPR_GLOBAL_CONFIG_DEFINE_INT32(grpc_client_channel_backup_poll_interval_ms, + DEFAULT_POLL_INTERVAL_MS, + "Client channel backup poll interval (ms)"); static void init_globals() { gpr_mu_init(&g_poller_mu); diff --git a/src/core/ext/filters/client_channel/http_connect_handshaker.cc b/src/core/ext/filters/client_channel/http_connect_handshaker.cc index 95366b57386..90a79843458 100644 --- a/src/core/ext/filters/client_channel/http_connect_handshaker.cc +++ b/src/core/ext/filters/client_channel/http_connect_handshaker.cc @@ -31,6 +31,7 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker_registry.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/http/format_request.h" diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index 00358736a94..27d543363a3 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -32,12 +32,12 @@ #include "src/core/ext/filters/client_channel/http_connect_handshaker.h" #include "src/core/ext/filters/client_channel/lb_policy_registry.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/ext/filters/client_channel/service_config.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" @@ -474,9 +474,8 @@ static bool should_use_ares(const char* resolver_env) { #endif /* GRPC_UV */ void grpc_resolver_dns_ares_init() { - grpc_core::UniquePtr resolver = - GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); - if (should_use_ares(resolver.get())) { + char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER"); + if (should_use_ares(resolver_env)) { gpr_log(GPR_DEBUG, "Using ares dns resolver"); address_sorting_init(); grpc_error* error = grpc_ares_init(); @@ -492,15 +491,16 @@ void grpc_resolver_dns_ares_init() { grpc_core::UniquePtr( grpc_core::New())); } + gpr_free(resolver_env); } void grpc_resolver_dns_ares_shutdown() { - grpc_core::UniquePtr resolver = - GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); - if (should_use_ares(resolver.get())) { + char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER"); + if (should_use_ares(resolver_env)) { address_sorting_shutdown(); grpc_ares_cleanup(); } + gpr_free(resolver_env); } #else /* GRPC_ARES == 1 */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc b/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc deleted file mode 100644 index 07a617c14d5..00000000000 --- a/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc +++ /dev/null @@ -1,28 +0,0 @@ -// -// Copyright 2019 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -// This is similar to the sockaddr resolver, except that it supports a -// bunch of query args that are useful for dependency injection in tests. - -#include - -#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" - -GPR_GLOBAL_CONFIG_DEFINE_STRING( - grpc_dns_resolver, "", - "Declares which DNS resolver to use. The default is ares if gRPC is built " - "with c-ares support. Otherwise, the value of this environment variable is " - "ignored.") diff --git a/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h b/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h deleted file mode 100644 index d0a3486ea38..00000000000 --- a/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_DNS_RESOLVER_SELECTION_H -#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_DNS_RESOLVER_SELECTION_H - -#include - -#include "src/core/lib/gprpp/global_config.h" - -GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_dns_resolver); - -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_DNS_RESOLVER_SELECTION_H \ - */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc index 5ab75d02793..164d308c0dd 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc @@ -26,11 +26,11 @@ #include #include -#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" @@ -274,9 +274,8 @@ class NativeDnsResolverFactory : public ResolverFactory { } // namespace grpc_core void grpc_resolver_dns_native_init() { - grpc_core::UniquePtr resolver = - GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); - if (gpr_stricmp(resolver.get(), "native") == 0) { + char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER"); + if (resolver_env != nullptr && gpr_stricmp(resolver_env, "native") == 0) { gpr_log(GPR_DEBUG, "Using native dns resolver"); grpc_core::ResolverRegistry::Builder::RegisterResolverFactory( grpc_core::UniquePtr( @@ -292,6 +291,7 @@ void grpc_resolver_dns_native_init() { grpc_core::New())); } } + gpr_free(resolver_env); } void grpc_resolver_dns_native_shutdown() {} diff --git a/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc b/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc index ac13d73d3b5..4c929d00ec9 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc @@ -23,11 +23,8 @@ #include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/transport/metadata.h" -GPR_GLOBAL_CONFIG_DEFINE_BOOL( - grpc_experimental_disable_flow_control, false, - "If set, flow control will be effectively disabled. Max out all values and " - "assume the remote peer does the same. Thus we can ignore any flow control " - "bookkeeping, error checking, and decision making"); +GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_experimental_disable_flow_control, false, + "Disable flow control"); void grpc_chttp2_plugin_init(void) { g_flow_control_enabled = diff --git a/src/core/lib/debug/trace.cc b/src/core/lib/debug/trace.cc index 84c0a3805d3..cafdb15c699 100644 --- a/src/core/lib/debug/trace.cc +++ b/src/core/lib/debug/trace.cc @@ -26,11 +26,7 @@ #include #include #include - -GPR_GLOBAL_CONFIG_DEFINE_STRING( - grpc_trace, "", - "A comma separated list of tracers that provide additional insight into " - "how gRPC C core is processing requests via debug logs."); +#include "src/core/lib/gpr/env.h" int grpc_tracer_set_enabled(const char* name, int enabled); @@ -137,14 +133,12 @@ static void parse(const char* s) { gpr_free(strings); } -void grpc_tracer_init(const char* env_var_name) { - (void)env_var_name; // suppress unused variable error - grpc_tracer_init(); -} - -void grpc_tracer_init() { - grpc_core::UniquePtr value = GPR_GLOBAL_CONFIG_GET(grpc_trace); - parse(value.get()); +void grpc_tracer_init(const char* env_var) { + char* e = gpr_getenv(env_var); + if (e != nullptr) { + parse(e); + gpr_free(e); + } } void grpc_tracer_shutdown(void) {} diff --git a/src/core/lib/debug/trace.h b/src/core/lib/debug/trace.h index 6a4a8031ec4..72e1a4eded7 100644 --- a/src/core/lib/debug/trace.h +++ b/src/core/lib/debug/trace.h @@ -24,15 +24,7 @@ #include #include -#include "src/core/lib/gprpp/global_config.h" - -GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_trace); - -// TODO(veblush): Remove this deprecated function once codes depending on this -// function are updated in the internal repo. void grpc_tracer_init(const char* env_var_name); - -void grpc_tracer_init(); void grpc_tracer_shutdown(void); #if defined(__has_feature) diff --git a/src/core/lib/gpr/env.h b/src/core/lib/gpr/env.h index f5016c6fa06..fb9e0636d10 100644 --- a/src/core/lib/gpr/env.h +++ b/src/core/lib/gpr/env.h @@ -34,6 +34,12 @@ char* gpr_getenv(const char* name); /* Sets the environment with the specified name to the specified value. */ void gpr_setenv(const char* name, const char* value); +/* This is a version of gpr_getenv that does not produce any output if it has to + use an insecure version of the function. It is ONLY to be used to solve the + problem in which we need to check an env variable to configure the verbosity + level of logging. So DO NOT USE THIS. */ +const char* gpr_getenv_silent(const char* name, char** dst); + /* Deletes the variable name from the environment. */ void gpr_unsetenv(const char* name); diff --git a/src/core/lib/gpr/env_linux.cc b/src/core/lib/gpr/env_linux.cc index 3a3aa541672..e84a9f6064c 100644 --- a/src/core/lib/gpr/env_linux.cc +++ b/src/core/lib/gpr/env_linux.cc @@ -38,7 +38,7 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" -static const char* gpr_getenv_silent(const char* name, char** dst) { +const char* gpr_getenv_silent(const char* name, char** dst) { const char* insecure_func_used = nullptr; char* result = nullptr; #if defined(GPR_BACKWARDS_COMPATIBILITY_MODE) diff --git a/src/core/lib/gpr/env_windows.cc b/src/core/lib/gpr/env_windows.cc index 76c45fb87a7..72850a9587d 100644 --- a/src/core/lib/gpr/env_windows.cc +++ b/src/core/lib/gpr/env_windows.cc @@ -30,6 +30,11 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/string_windows.h" +const char* gpr_getenv_silent(const char* name, char** dst) { + *dst = gpr_getenv(name); + return NULL; +} + char* gpr_getenv(const char* name) { char* result = NULL; DWORD size; diff --git a/src/core/lib/gpr/log.cc b/src/core/lib/gpr/log.cc index 8a229b2adf1..01ef112fb31 100644 --- a/src/core/lib/gpr/log.cc +++ b/src/core/lib/gpr/log.cc @@ -22,15 +22,12 @@ #include #include +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/global_config.h" #include #include -GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_verbosity, "ERROR", - "Default gRPC logging verbosity") - void gpr_default_log(gpr_log_func_args* args); static gpr_atm g_log_func = (gpr_atm)gpr_default_log; static gpr_atm g_min_severity_to_print = GPR_LOG_VERBOSITY_UNSET; @@ -75,22 +72,29 @@ void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print) { } void gpr_log_verbosity_init() { - grpc_core::UniquePtr verbosity = GPR_GLOBAL_CONFIG_GET(grpc_verbosity); + char* verbosity = nullptr; + const char* insecure_getenv = gpr_getenv_silent("GRPC_VERBOSITY", &verbosity); gpr_atm min_severity_to_print = GPR_LOG_SEVERITY_ERROR; - if (strlen(verbosity.get()) > 0) { - if (gpr_stricmp(verbosity.get(), "DEBUG") == 0) { + if (verbosity != nullptr) { + if (gpr_stricmp(verbosity, "DEBUG") == 0) { min_severity_to_print = static_cast(GPR_LOG_SEVERITY_DEBUG); - } else if (gpr_stricmp(verbosity.get(), "INFO") == 0) { + } else if (gpr_stricmp(verbosity, "INFO") == 0) { min_severity_to_print = static_cast(GPR_LOG_SEVERITY_INFO); - } else if (gpr_stricmp(verbosity.get(), "ERROR") == 0) { + } else if (gpr_stricmp(verbosity, "ERROR") == 0) { min_severity_to_print = static_cast(GPR_LOG_SEVERITY_ERROR); } + gpr_free(verbosity); } if ((gpr_atm_no_barrier_load(&g_min_severity_to_print)) == GPR_LOG_VERBOSITY_UNSET) { gpr_atm_no_barrier_store(&g_min_severity_to_print, min_severity_to_print); } + + if (insecure_getenv != nullptr) { + gpr_log(GPR_DEBUG, "Warning: insecure environment read function '%s' used", + insecure_getenv); + } } void gpr_set_log_function(gpr_log_func f) { diff --git a/src/core/lib/gprpp/fork.cc b/src/core/lib/gprpp/fork.cc index 37552692373..fdc7c5354bd 100644 --- a/src/core/lib/gprpp/fork.cc +++ b/src/core/lib/gprpp/fork.cc @@ -26,8 +26,8 @@ #include #include +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/useful.h" -#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/memory.h" /* @@ -35,16 +35,6 @@ * AROUND VERY SPECIFIC USE CASES. */ -#ifdef GRPC_ENABLE_FORK_SUPPORT -#define GRPC_ENABLE_FORK_SUPPORT_DEFAULT true -#else -#define GRPC_ENABLE_FORK_SUPPORT_DEFAULT false -#endif // GRPC_ENABLE_FORK_SUPPORT - -GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_enable_fork_support, - GRPC_ENABLE_FORK_SUPPORT_DEFAULT, - "Enable folk support"); - namespace grpc_core { namespace internal { // The exec_ctx_count has 2 modes, blocked and unblocked. @@ -168,7 +158,34 @@ class ThreadState { void Fork::GlobalInit() { if (!override_enabled_) { - support_enabled_ = GPR_GLOBAL_CONFIG_GET(grpc_enable_fork_support); +#ifdef GRPC_ENABLE_FORK_SUPPORT + support_enabled_ = true; +#endif + bool env_var_set = false; + char* env = gpr_getenv("GRPC_ENABLE_FORK_SUPPORT"); + if (env != nullptr) { + static const char* truthy[] = {"yes", "Yes", "YES", "true", + "True", "TRUE", "1"}; + static const char* falsey[] = {"no", "No", "NO", "false", + "False", "FALSE", "0"}; + for (size_t i = 0; i < GPR_ARRAY_SIZE(truthy); i++) { + if (0 == strcmp(env, truthy[i])) { + support_enabled_ = true; + env_var_set = true; + break; + } + } + if (!env_var_set) { + for (size_t i = 0; i < GPR_ARRAY_SIZE(falsey); i++) { + if (0 == strcmp(env, falsey[i])) { + support_enabled_ = false; + env_var_set = true; + break; + } + } + } + gpr_free(env); + } } if (support_enabled_) { exec_ctx_state_ = grpc_core::New(); diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc index ddafb7b5539..47cf5b83b17 100644 --- a/src/core/lib/iomgr/ev_posix.cc +++ b/src/core/lib/iomgr/ev_posix.cc @@ -31,19 +31,13 @@ #include #include "src/core/lib/debug/trace.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/useful.h" -#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/iomgr/ev_epoll1_linux.h" #include "src/core/lib/iomgr/ev_epollex_linux.h" #include "src/core/lib/iomgr/ev_poll_posix.h" #include "src/core/lib/iomgr/internal_errqueue.h" -GPR_GLOBAL_CONFIG_DEFINE_STRING( - grpc_poll_strategy, "all", - "Declares which polling engines to try when starting gRPC. " - "This is a comma-separated list of engines, which are tried in priority " - "order first -> last.") - grpc_core::TraceFlag grpc_polling_trace(false, "polling"); /* Disabled by default */ @@ -52,15 +46,16 @@ grpc_core::TraceFlag grpc_fd_trace(false, "fd_trace"); grpc_core::DebugOnlyTraceFlag grpc_trace_fd_refcount(false, "fd_refcount"); grpc_core::DebugOnlyTraceFlag grpc_polling_api_trace(false, "polling_api"); -// Polling API trace only enabled in debug builds #ifndef NDEBUG + +// Polling API trace only enabled in debug builds #define GRPC_POLLING_API_TRACE(format, ...) \ if (GRPC_TRACE_FLAG_ENABLED(grpc_polling_api_trace)) { \ gpr_log(GPR_INFO, "(polling-api) " format, __VA_ARGS__); \ } #else #define GRPC_POLLING_API_TRACE(...) -#endif // NDEBUG +#endif /** Default poll() function - a pointer so that it can be overridden by some * tests */ @@ -71,7 +66,7 @@ int aix_poll(struct pollfd fds[], nfds_t nfds, int timeout) { return poll(fds, nfds, timeout); } grpc_poll_function_type grpc_poll_function = aix_poll; -#endif // GPR_AIX +#endif grpc_wakeup_fd grpc_global_wakeup_fd; @@ -210,11 +205,14 @@ void grpc_register_event_engine_factory(const char* name, const char* grpc_get_poll_strategy_name() { return g_poll_strategy_name; } void grpc_event_engine_init(void) { - grpc_core::UniquePtr value = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); + char* s = gpr_getenv("GRPC_POLL_STRATEGY"); + if (s == nullptr) { + s = gpr_strdup("all"); + } char** strings = nullptr; size_t nstrings = 0; - split(value.get(), &strings, &nstrings); + split(s, &strings, &nstrings); for (size_t i = 0; g_event_engine == nullptr && i < nstrings; i++) { try_engine(strings[i]); @@ -226,10 +224,10 @@ void grpc_event_engine_init(void) { gpr_free(strings); if (g_event_engine == nullptr) { - gpr_log(GPR_ERROR, "No event engine could be initialized from %s", - value.get()); + gpr_log(GPR_ERROR, "No event engine could be initialized from %s", s); abort(); } + gpr_free(s); } void grpc_event_engine_shutdown(void) { diff --git a/src/core/lib/iomgr/ev_posix.h b/src/core/lib/iomgr/ev_posix.h index 30bb5e40faf..0ca3a6f82fd 100644 --- a/src/core/lib/iomgr/ev_posix.h +++ b/src/core/lib/iomgr/ev_posix.h @@ -24,14 +24,11 @@ #include #include "src/core/lib/debug/trace.h" -#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/iomgr/pollset_set.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" -GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_poll_strategy); - extern grpc_core::TraceFlag grpc_fd_trace; /* Disabled by default */ extern grpc_core::TraceFlag grpc_polling_trace; /* Disabled by default */ diff --git a/src/core/lib/iomgr/fork_posix.cc b/src/core/lib/iomgr/fork_posix.cc index 629b08162fb..7f8fb7e828b 100644 --- a/src/core/lib/iomgr/fork_posix.cc +++ b/src/core/lib/iomgr/fork_posix.cc @@ -28,6 +28,7 @@ #include #include +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gprpp/fork.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/ev_posix.h" diff --git a/src/core/lib/iomgr/iomgr.cc b/src/core/lib/iomgr/iomgr.cc index b86aa6f2d76..fd011788a06 100644 --- a/src/core/lib/iomgr/iomgr.cc +++ b/src/core/lib/iomgr/iomgr.cc @@ -42,8 +42,7 @@ #include "src/core/lib/iomgr/timer_manager.h" GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_abort_on_leaks, false, - "A debugging aid to cause a call to abort() when " - "gRPC objects are leaked past grpc_shutdown()"); + "Abort when leak is found"); static gpr_mu g_mu; static gpr_cv g_rcv; diff --git a/src/core/lib/profiling/basic_timers.cc b/src/core/lib/profiling/basic_timers.cc index 37689fe89d1..b19ad9fc23d 100644 --- a/src/core/lib/profiling/basic_timers.cc +++ b/src/core/lib/profiling/basic_timers.cc @@ -31,8 +31,7 @@ #include #include -#include "src/core/lib/gprpp/global_config.h" -#include "src/core/lib/profiling/timers.h" +#include "src/core/lib/gpr/env.h" typedef enum { BEGIN = '{', END = '}', MARK = '.' } marker_type; @@ -75,16 +74,11 @@ static __thread int g_thread_id; static int g_next_thread_id; static int g_writing_enabled = 1; -GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_latency_trace, "latency_trace.txt", - "Output file name for latency trace") - static const char* output_filename() { if (output_filename_or_null == NULL) { - grpc_core::UniquePtr value = - GPR_GLOBAL_CONFIG_GET(grpc_latency_trace); - if (strlen(value.get()) > 0) { - output_filename_or_null = value.release(); - } else { + output_filename_or_null = gpr_getenv("LATENCY_TRACE"); + if (output_filename_or_null == NULL || + strlen(output_filename_or_null) == 0) { output_filename_or_null = "latency_trace.txt"; } } diff --git a/src/core/lib/security/security_connector/load_system_roots_linux.cc b/src/core/lib/security/security_connector/load_system_roots_linux.cc index 82d5bf6bcdd..924fa8a3e26 100644 --- a/src/core/lib/security/security_connector/load_system_roots_linux.cc +++ b/src/core/lib/security/security_connector/load_system_roots_linux.cc @@ -38,15 +38,12 @@ #include #include +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" -#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/iomgr/load_file.h" -GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_system_ssl_roots_dir, "", - "Custom directory to SSL Roots"); - namespace grpc_core { namespace { @@ -142,9 +139,10 @@ grpc_slice CreateRootCertsBundle(const char* certs_directory) { grpc_slice LoadSystemRootCerts() { grpc_slice result = grpc_empty_slice(); // Prioritize user-specified custom directory if flag is set. - UniquePtr custom_dir = GPR_GLOBAL_CONFIG_GET(grpc_system_ssl_roots_dir); - if (strlen(custom_dir.get()) > 0) { - result = CreateRootCertsBundle(custom_dir.get()); + char* custom_dir = gpr_getenv("GRPC_SYSTEM_SSL_ROOTS_DIR"); + if (custom_dir != nullptr) { + result = CreateRootCertsBundle(custom_dir); + gpr_free(custom_dir); } // If the custom directory is empty/invalid/not specified, fallback to // distribution-specific directory. diff --git a/src/core/lib/security/security_connector/security_connector.cc b/src/core/lib/security/security_connector/security_connector.cc index 47c0ad5aa3d..96a19605466 100644 --- a/src/core/lib/security/security_connector/security_connector.cc +++ b/src/core/lib/security/security_connector/security_connector.cc @@ -28,6 +28,7 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/load_file.h" diff --git a/src/core/lib/security/security_connector/ssl_utils.cc b/src/core/lib/security/security_connector/ssl_utils.cc index cb0d5437988..1eefff6fe24 100644 --- a/src/core/lib/security/security_connector/ssl_utils.cc +++ b/src/core/lib/security/security_connector/ssl_utils.cc @@ -27,6 +27,7 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/global_config.h" @@ -45,13 +46,7 @@ static const char* installed_roots_path = INSTALL_PREFIX "/share/grpc/roots.pem"; #endif -/** Config variable that points to the default SSL roots file. This file - must be a PEM encoded file with all the roots such as the one that can be - downloaded from https://pki.google.com/roots.pem. */ -GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_default_ssl_roots_file_path, "", - "Path to the default SSL roots file."); - -/** Config variable used as a flag to enable/disable loading system root +/** Environment variable used as a flag to enable/disable loading system root certificates from the OS trust store. */ GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_not_use_system_ssl_roots, false, "Disable loading system root certificates."); @@ -70,22 +65,20 @@ void grpc_set_ssl_roots_override_callback(grpc_ssl_roots_override_callback cb) { /* -- Cipher suites. -- */ +/* Defines the cipher suites that we accept by default. All these cipher suites + are compliant with HTTP2. */ +#define GRPC_SSL_CIPHER_SUITES \ + "ECDHE-ECDSA-AES128-GCM-SHA256:" \ + "ECDHE-ECDSA-AES256-GCM-SHA384:" \ + "ECDHE-RSA-AES128-GCM-SHA256:" \ + "ECDHE-RSA-AES256-GCM-SHA384" + static gpr_once cipher_suites_once = GPR_ONCE_INIT; static const char* cipher_suites = nullptr; -// All cipher suites for default are compliant with HTTP2. -GPR_GLOBAL_CONFIG_DEFINE_STRING( - grpc_ssl_cipher_suites, - "ECDHE-ECDSA-AES128-GCM-SHA256:" - "ECDHE-ECDSA-AES256-GCM-SHA384:" - "ECDHE-RSA-AES128-GCM-SHA256:" - "ECDHE-RSA-AES256-GCM-SHA384", - "A colon separated list of cipher suites to use with OpenSSL") - static void init_cipher_suites(void) { - grpc_core::UniquePtr value = - GPR_GLOBAL_CONFIG_GET(grpc_ssl_cipher_suites); - cipher_suites = value.release(); + char* overridden = gpr_getenv("GRPC_SSL_CIPHER_SUITES"); + cipher_suites = overridden != nullptr ? overridden : GRPC_SSL_CIPHER_SUITES; } /* --- Util --- */ @@ -437,12 +430,13 @@ grpc_slice DefaultSslRootStore::ComputePemRootCerts() { grpc_slice result = grpc_empty_slice(); const bool not_use_system_roots = GPR_GLOBAL_CONFIG_GET(grpc_not_use_system_ssl_roots); - // First try to load the roots from the configuration. - UniquePtr default_root_certs_path = - GPR_GLOBAL_CONFIG_GET(grpc_default_ssl_roots_file_path); - if (strlen(default_root_certs_path.get()) > 0) { - GRPC_LOG_IF_ERROR( - "load_file", grpc_load_file(default_root_certs_path.get(), 1, &result)); + // First try to load the roots from the environment. + char* default_root_certs_path = + gpr_getenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR); + if (default_root_certs_path != nullptr) { + GRPC_LOG_IF_ERROR("load_file", + grpc_load_file(default_root_certs_path, 1, &result)); + gpr_free(default_root_certs_path); } // Try overridden roots if needed. grpc_ssl_roots_override_result ovrd_res = GRPC_SSL_ROOTS_OVERRIDE_FAIL; diff --git a/src/core/lib/security/security_connector/ssl_utils.h b/src/core/lib/security/security_connector/ssl_utils.h index 1765a344c2a..080e277f944 100644 --- a/src/core/lib/security/security_connector/ssl_utils.h +++ b/src/core/lib/security/security_connector/ssl_utils.h @@ -26,7 +26,6 @@ #include #include -#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/security/security_connector/security_connector.h" @@ -34,10 +33,7 @@ #include "src/core/tsi/transport_security.h" #include "src/core/tsi/transport_security_interface.h" -GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_default_ssl_roots_file_path); -GPR_GLOBAL_CONFIG_DECLARE_BOOL(grpc_not_use_system_ssl_roots); - -/* --- Util --- */ +/* --- Util. --- */ /* --- URL schemes. --- */ #define GRPC_SSL_URL_SCHEME "https" diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index 2a6d307ddab..1ed1a66b184 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -154,7 +154,7 @@ void grpc_init(void) { * at the appropriate time */ grpc_register_security_filters(); register_builtin_channel_init(); - grpc_tracer_init(); + grpc_tracer_init("GRPC_TRACE"); /* no more changes to channel init pipelines */ grpc_channel_init_finalize(); grpc_iomgr_start(); diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m index e6522d7a27e..7557367ed4a 100644 --- a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m @@ -61,7 +61,8 @@ NSBundle *resourceBundle = [NSBundle bundleWithURL:[[bundle resourceURL] URLByAppendingPathComponent:resourceBundlePath]]; NSString *path = [resourceBundle pathForResource:rootsPEM ofType:@"pem"]; - setenv("GRPC_DEFAULT_SSL_ROOTS_FILE_PATH", [path cStringUsingEncoding:NSUTF8StringEncoding], 1); + setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, + [path cStringUsingEncoding:NSUTF8StringEncoding], 1); }); NSData *rootsASCII = nil; diff --git a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm index 0d081e4a410..2fac1be3d0e 100644 --- a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm +++ b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm @@ -37,11 +37,11 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -172,7 +172,7 @@ static char *roots_filename; GPR_ASSERT(roots_file != NULL); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); + gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); grpc_init(); diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 61524eb7fc9..97c9f2f7c94 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -386,7 +386,6 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/census/grpc_context.cc', diff --git a/test/core/bad_connection/close_fd_test.cc b/test/core/bad_connection/close_fd_test.cc index 78a1a5cc9a4..e8f297e77ea 100644 --- a/test/core/bad_connection/close_fd_test.cc +++ b/test/core/bad_connection/close_fd_test.cc @@ -39,6 +39,7 @@ #include #include #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/endpoint_pair.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/completion_queue.h" diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc index 8dd55f64944..73d251eff4a 100644 --- a/test/core/bad_ssl/bad_ssl_test.cc +++ b/test/core/bad_ssl/bad_ssl_test.cc @@ -25,9 +25,9 @@ #include #include +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" @@ -133,7 +133,7 @@ int main(int argc, char** argv) { strcpy(root, "."); } if (argc == 2) { - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, argv[1]); + gpr_setenv("GRPC_DEFAULT_SSL_ROOTS_FILE_PATH", argv[1]); } /* figure out our test name */ tmp = lunder - 1; diff --git a/test/core/client_channel/resolvers/dns_resolver_test.cc b/test/core/client_channel/resolvers/dns_resolver_test.cc index 129866b7d7f..ed3b4e66472 100644 --- a/test/core/client_channel/resolvers/dns_resolver_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_test.cc @@ -21,8 +21,8 @@ #include #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/combiner.h" #include "test/core/util/test_config.h" @@ -78,13 +78,13 @@ int main(int argc, char** argv) { test_succeeds(dns, "dns:10.2.1.1:1234"); test_succeeds(dns, "dns:www.google.com"); test_succeeds(dns, "dns:///www.google.com"); - grpc_core::UniquePtr resolver = - GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); - if (gpr_stricmp(resolver.get(), "native") == 0) { + char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER"); + if (resolver_env != nullptr && gpr_stricmp(resolver_env, "native") == 0) { test_fails(dns, "dns://8.8.8.8/8.8.8.8:8888"); } else { test_succeeds(dns, "dns://8.8.8.8/8.8.8.8:8888"); } + gpr_free(resolver_env); { grpc_core::ExecCtx exec_ctx; GRPC_COMBINER_UNREF(g_combiner, "test"); diff --git a/test/core/end2end/fixtures/h2_full+trace.cc b/test/core/end2end/fixtures/h2_full+trace.cc index b8dbe261183..ce8f6bf13a5 100644 --- a/test/core/end2end/fixtures/h2_full+trace.cc +++ b/test/core/end2end/fixtures/h2_full+trace.cc @@ -33,7 +33,7 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/debug/trace.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" @@ -105,7 +105,7 @@ int main(int argc, char** argv) { /* force tracing on, with a value to force many code paths in trace.c to be taken */ - GPR_GLOBAL_CONFIG_SET(grpc_trace, "doesnt-exist,http,all"); + gpr_setenv("GRPC_TRACE", "doesnt-exist,http,all"); #ifdef GRPC_POSIX_SOCKET g_fixture_slowdown_factor = isatty(STDOUT_FILENO) ? 10 : 1; diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.cc b/test/core/end2end/fixtures/h2_sockpair+trace.cc index 7954bc1ddfc..4494d5c4746 100644 --- a/test/core/end2end/fixtures/h2_sockpair+trace.cc +++ b/test/core/end2end/fixtures/h2_sockpair+trace.cc @@ -35,7 +35,7 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/debug/trace.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/endpoint_pair.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/surface/channel.h" @@ -133,8 +133,7 @@ int main(int argc, char** argv) { /* force tracing on, with a value to force many code paths in trace.c to be taken */ - GPR_GLOBAL_CONFIG_SET(grpc_trace, "doesnt-exist,http,all"); - + gpr_setenv("GRPC_TRACE", "doesnt-exist,http,all"); #ifdef GRPC_POSIX_SOCKET g_fixture_slowdown_factor = isatty(STDOUT_FILENO) ? 10 : 1; #else diff --git a/test/core/end2end/fixtures/h2_spiffe.cc b/test/core/end2end/fixtures/h2_spiffe.cc index cdf091bac10..9ab796ea429 100644 --- a/test/core/end2end/fixtures/h2_spiffe.cc +++ b/test/core/end2end/fixtures/h2_spiffe.cc @@ -35,7 +35,6 @@ #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -278,7 +277,7 @@ int main(int argc, char** argv) { GPR_ASSERT(roots_file != nullptr); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); + gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); grpc_init(); for (size_t ind = 0; ind < sizeof(configs) / sizeof(*configs); ind++) { grpc_end2end_tests(argc, argv, configs[ind]); diff --git a/test/core/end2end/fixtures/h2_ssl.cc b/test/core/end2end/fixtures/h2_ssl.cc index 3fc9bc7f329..1fcd785e251 100644 --- a/test/core/end2end/fixtures/h2_ssl.cc +++ b/test/core/end2end/fixtures/h2_ssl.cc @@ -25,11 +25,11 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -167,7 +167,7 @@ int main(int argc, char** argv) { GPR_ASSERT(roots_file != nullptr); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); + gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); grpc_init(); diff --git a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc index 1d54a431364..04d876ce3cd 100644 --- a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc +++ b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc @@ -25,11 +25,11 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -190,7 +190,7 @@ int main(int argc, char** argv) { GPR_ASSERT(roots_file != nullptr); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); + gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); grpc_init(); diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.cc b/test/core/end2end/fixtures/h2_ssl_proxy.cc index d5f695b1575..f1858079426 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.cc +++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc @@ -25,11 +25,11 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/end2end/fixtures/proxy.h" #include "test/core/util/port.h" @@ -208,7 +208,7 @@ int main(int argc, char** argv) { GPR_ASSERT(roots_file != nullptr); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); + gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); grpc_init(); diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc index e9285778a2d..cb0800bf899 100644 --- a/test/core/end2end/h2_ssl_cert_test.cc +++ b/test/core/end2end/h2_ssl_cert_test.cc @@ -25,11 +25,11 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" @@ -366,7 +366,7 @@ int main(int argc, char** argv) { GPR_ASSERT(roots_file != nullptr); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); + gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); grpc_init(); ::testing::InitGoogleTest(&argc, argv); diff --git a/test/core/end2end/h2_ssl_session_reuse_test.cc b/test/core/end2end/h2_ssl_session_reuse_test.cc index b2d0a5e1133..fbcdcc4b3f3 100644 --- a/test/core/end2end/h2_ssl_session_reuse_test.cc +++ b/test/core/end2end/h2_ssl_session_reuse_test.cc @@ -25,11 +25,11 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" @@ -265,7 +265,7 @@ int main(int argc, char** argv) { GPR_ASSERT(roots_file != nullptr); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); + gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); grpc_init(); ::testing::InitGoogleTest(&argc, argv); diff --git a/test/core/end2end/tests/keepalive_timeout.cc b/test/core/end2end/tests/keepalive_timeout.cc index 1750f6fe5ee..3c33f0419ad 100644 --- a/test/core/end2end/tests/keepalive_timeout.cc +++ b/test/core/end2end/tests/keepalive_timeout.cc @@ -28,15 +28,11 @@ #include "src/core/ext/transport/chttp2/transport/frame_ping.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" -#include "src/core/lib/iomgr/iomgr.h" #include "test/core/end2end/cq_verifier.h" -#ifdef GRPC_POSIX_SOCKET -#include "src/core/lib/iomgr/ev_posix.h" -#endif // GRPC_POSIX_SOCKET - static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -229,13 +225,13 @@ static void test_keepalive_timeout(grpc_end2end_test_config config) { * 200ms. In the success case, each ping ack should reset the keepalive timer so * that the keepalive ping is never sent. */ static void test_read_delays_keepalive(grpc_end2end_test_config config) { -#ifdef GRPC_POSIX_SOCKET - grpc_core::UniquePtr poller = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); + char* poller = gpr_getenv("GRPC_POLL_STRATEGY"); /* It is hard to get the timing right for the polling engine poll. */ - if ((0 == strcmp(poller.get(), "poll"))) { + if (poller != nullptr && (0 == strcmp(poller, "poll"))) { + gpr_free(poller); return; } -#endif // GRPC_POSIX_SOCKET + gpr_free(poller); const int kPingIntervalMS = 100; grpc_arg keepalive_arg_elems[3]; keepalive_arg_elems[0].type = GRPC_ARG_INTEGER; diff --git a/test/core/gpr/log_test.cc b/test/core/gpr/log_test.cc index e320daa33a7..f96257738b2 100644 --- a/test/core/gpr/log_test.cc +++ b/test/core/gpr/log_test.cc @@ -21,14 +21,9 @@ #include #include -#include "src/core/lib/gprpp/global_config.h" +#include "src/core/lib/gpr/env.h" #include "test/core/util/test_config.h" -// Config declaration is supposed to be located at log.h but -// log.h doesn't include global_config headers because it has to -// be a strict C so declaration statement gets to be here. -GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_verbosity); - static bool log_func_reached = false; static void test_callback(gpr_log_func_args* args) { @@ -72,7 +67,7 @@ int main(int argc, char** argv) { /* gpr_log_verbosity_init() will be effective only once, and only before * gpr_set_log_verbosity() is called */ - GPR_GLOBAL_CONFIG_SET(grpc_verbosity, "ERROR"); + gpr_setenv("GRPC_VERBOSITY", "ERROR"); gpr_log_verbosity_init(); test_log_function_reached(GPR_ERROR); @@ -80,7 +75,7 @@ int main(int argc, char** argv) { test_log_function_unreached(GPR_DEBUG); /* gpr_log_verbosity_init() should not be effective */ - GPR_GLOBAL_CONFIG_SET(grpc_verbosity, "DEBUG"); + gpr_setenv("GRPC_VERBOSITY", "DEBUG"); gpr_log_verbosity_init(); test_log_function_reached(GPR_ERROR); test_log_function_unreached(GPR_INFO); @@ -102,7 +97,7 @@ int main(int argc, char** argv) { test_log_function_unreached(GPR_DEBUG); /* gpr_log_verbosity_init() should not be effective */ - GPR_GLOBAL_CONFIG_SET(grpc_verbosity, "DEBUG"); + gpr_setenv("GRPC_VERBOSITY", "DEBUG"); gpr_log_verbosity_init(); test_log_function_reached(GPR_ERROR); test_log_function_unreached(GPR_INFO); diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc index e7250c206d8..326b0e95e25 100644 --- a/test/core/http/httpscli_test.cc +++ b/test/core/http/httpscli_test.cc @@ -29,7 +29,6 @@ #include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/iomgr.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" #include "test/core/util/test_config.h" @@ -185,7 +184,7 @@ int main(int argc, char** argv) { /* Set the environment variable for the SSL certificate file */ char* pem_file; gpr_asprintf(&pem_file, "%s/src/core/tsi/test_creds/ca.pem", root); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, pem_file); + gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, pem_file); gpr_free(pem_file); /* start the server */ diff --git a/test/core/iomgr/resolve_address_posix_test.cc b/test/core/iomgr/resolve_address_posix_test.cc index 112d7c2791b..826c7e1fafa 100644 --- a/test/core/iomgr/resolve_address_posix_test.cc +++ b/test/core/iomgr/resolve_address_posix_test.cc @@ -29,7 +29,6 @@ #include #include -#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" @@ -225,16 +224,15 @@ int main(int argc, char** argv) { // --resolver will always be the first one, so only parse the first argument // (other arguments may be unknown to cl) gpr_cmdline_parse(cl, argc > 2 ? 2 : argc, argv); - grpc_core::UniquePtr resolver = - GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); - if (strlen(resolver.get()) != 0) { + const char* cur_resolver = gpr_getenv("GRPC_DNS_RESOLVER"); + if (cur_resolver != nullptr && strlen(cur_resolver) != 0) { gpr_log(GPR_INFO, "Warning: overriding resolver setting of %s", - resolver.get()); + cur_resolver); } if (gpr_stricmp(resolver_type, "native") == 0) { - GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "native"); + gpr_setenv("GRPC_DNS_RESOLVER", "native"); } else if (gpr_stricmp(resolver_type, "ares") == 0) { - GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "ares"); + gpr_setenv("GRPC_DNS_RESOLVER", "ares"); } else { gpr_log(GPR_ERROR, "--resolver_type was not set to ares or native"); abort(); @@ -248,12 +246,12 @@ int main(int argc, char** argv) { // c-ares resolver doesn't support UDS (ability for native DNS resolver // to handle this is only expected to be used by servers, which // unconditionally use the native DNS resolver). - grpc_core::UniquePtr resolver = - GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); - if (gpr_stricmp(resolver.get(), "native") == 0) { + char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER"); + if (resolver_env == nullptr || gpr_stricmp(resolver_env, "native") == 0) { test_unix_socket(); test_unix_socket_path_name_too_long(); } + gpr_free(resolver_env); } gpr_cmdline_destroy(cl); diff --git a/test/core/iomgr/resolve_address_test.cc b/test/core/iomgr/resolve_address_test.cc index cbc03485d7f..1f0c0e3e835 100644 --- a/test/core/iomgr/resolve_address_test.cc +++ b/test/core/iomgr/resolve_address_test.cc @@ -27,7 +27,7 @@ #include -#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr.h" @@ -347,17 +347,16 @@ int main(int argc, char** argv) { // --resolver will always be the first one, so only parse the first argument // (other arguments may be unknown to cl) gpr_cmdline_parse(cl, argc > 2 ? 2 : argc, argv); - grpc_core::UniquePtr resolver = - GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); - if (strlen(resolver.get()) != 0) { + const char* cur_resolver = gpr_getenv("GRPC_DNS_RESOLVER"); + if (cur_resolver != nullptr && strlen(cur_resolver) != 0) { gpr_log(GPR_INFO, "Warning: overriding resolver setting of %s", - resolver.get()); + cur_resolver); } if (gpr_stricmp(resolver_type, "native") == 0) { - GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "native"); + gpr_setenv("GRPC_DNS_RESOLVER", "native"); } else if (gpr_stricmp(resolver_type, "ares") == 0) { #ifndef GRPC_UV - GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "ares"); + gpr_setenv("GRPC_DNS_RESOLVER", "ares"); #endif } else { gpr_log(GPR_ERROR, "--resolver_type was not set to ares or native"); diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc index 141346bca94..11cfc8cc905 100644 --- a/test/core/security/credentials_test.cc +++ b/test/core/security/credentials_test.cc @@ -1161,7 +1161,7 @@ static void test_get_well_known_google_credentials_file_path(void) { GPR_ASSERT(path != nullptr); gpr_free(path); #if defined(GPR_POSIX_ENV) || defined(GPR_LINUX_ENV) - gpr_unsetenv("HOME"); + unsetenv("HOME"); path = grpc_get_well_known_google_credentials_file_path(); GPR_ASSERT(path == nullptr); gpr_setenv("HOME", home); diff --git a/test/core/security/security_connector_test.cc b/test/core/security/security_connector_test.cc index c888c90c646..496f064439c 100644 --- a/test/core/security/security_connector_test.cc +++ b/test/core/security/security_connector_test.cc @@ -24,6 +24,7 @@ #include #include +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" @@ -393,7 +394,7 @@ static void test_default_ssl_roots(void) { /* First let's get the root through the override: set the env to an invalid value. */ - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, ""); + gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, ""); grpc_set_ssl_roots_override_callback(override_roots_success); grpc_slice roots = grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting(); @@ -404,8 +405,7 @@ static void test_default_ssl_roots(void) { /* Now let's set the env var: We should get the contents pointed value instead. */ - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, - roots_env_var_file_path); + gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_env_var_file_path); roots = grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting(); roots_contents = grpc_slice_to_c_string(roots); grpc_slice_unref(roots); @@ -414,7 +414,7 @@ static void test_default_ssl_roots(void) { /* Now reset the env var. We should fall back to the value overridden using the api. */ - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, ""); + gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, ""); roots = grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting(); roots_contents = grpc_slice_to_c_string(roots); grpc_slice_unref(roots); @@ -423,7 +423,7 @@ static void test_default_ssl_roots(void) { /* Now setup a permanent failure for the overridden roots and we should get an empty slice. */ - GPR_GLOBAL_CONFIG_SET(grpc_not_use_system_ssl_roots, true); + gpr_setenv("GRPC_NOT_USE_SYSTEM_SSL_ROOTS", "true"); grpc_set_ssl_roots_override_callback(override_roots_permanent_failure); roots = grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting(); GPR_ASSERT(GRPC_SLICE_IS_EMPTY(roots)); diff --git a/test/core/util/test_config.cc b/test/core/util/test_config.cc index 5b248a01daa..476e424b1eb 100644 --- a/test/core/util/test_config.cc +++ b/test/core/util/test_config.cc @@ -28,6 +28,7 @@ #include #include +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/surface/init.h" diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 6ca0edf123e..97275db6276 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -33,6 +33,7 @@ #include #include "src/core/ext/filters/client_channel/backup_poller.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/tls.h" #include "src/core/lib/iomgr/port.h" #include "src/proto/grpc/health/v1/health.grpc.pb.h" @@ -43,10 +44,6 @@ #include "test/cpp/util/string_ref_helper.h" #include "test/cpp/util/test_credentials_provider.h" -#ifdef GRPC_POSIX_SOCKET -#include "src/core/lib/iomgr/ev_posix.h" -#endif // GRPC_POSIX_SOCKET - #include using grpc::testing::EchoRequest; @@ -362,14 +359,13 @@ TEST_P(AsyncEnd2endTest, ReconnectChannel) { return; } int poller_slowdown_factor = 1; -#ifdef GRPC_POSIX_SOCKET // It needs 2 pollset_works to reconnect the channel with polling engine // "poll" - grpc_core::UniquePtr poller = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); - if (0 == strcmp(poller.get(), "poll")) { + char* s = gpr_getenv("GRPC_POLL_STRATEGY"); + if (s != nullptr && 0 == strcmp(s, "poll")) { poller_slowdown_factor = 2; } -#endif // GRPC_POSIX_SOCKET + gpr_free(s); ResetStub(); SendRpc(1); server_->Shutdown(); diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 8fae2da217f..e5dc88ae6d7 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -35,6 +35,7 @@ #include #include "src/core/ext/filters/client_channel/backup_poller.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" @@ -46,10 +47,6 @@ #include "test/cpp/util/string_ref_helper.h" #include "test/cpp/util/test_credentials_provider.h" -#ifdef GRPC_POSIX_SOCKET -#include "src/core/lib/iomgr/ev_posix.h" -#endif // GRPC_POSIX_SOCKET - #include using grpc::testing::EchoRequest; @@ -812,12 +809,11 @@ TEST_P(End2endTest, ReconnectChannel) { int poller_slowdown_factor = 1; // It needs 2 pollset_works to reconnect the channel with polling engine // "poll" -#ifdef GRPC_POSIX_SOCKET - grpc_core::UniquePtr poller = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); - if (0 == strcmp(poller.get(), "poll")) { + char* s = gpr_getenv("GRPC_POLL_STRATEGY"); + if (s != nullptr && 0 == strcmp(s, "poll")) { poller_slowdown_factor = 2; } -#endif // GRPC_POSIX_SOCKET + gpr_free(s); ResetStub(); SendRpc(stub_.get(), 1, false); RestartServer(std::shared_ptr()); diff --git a/test/cpp/naming/address_sorting_test.cc b/test/cpp/naming/address_sorting_test.cc index affc75bc634..bd685632c33 100644 --- a/test/cpp/naming/address_sorting_test.cc +++ b/test/cpp/naming/address_sorting_test.cc @@ -36,10 +36,10 @@ #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/client_channel/resolver.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/combiner.h" @@ -829,13 +829,13 @@ TEST_F(AddressSortingTest, TestSorterKnowsIpv6LoopbackIsAvailable) { } // namespace int main(int argc, char** argv) { - grpc_core::UniquePtr resolver = - GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); - if (strlen(resolver.get()) == 0) { - GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "ares"); - } else if (strcmp("ares", resolver.get())) { - gpr_log(GPR_INFO, "GRPC_DNS_RESOLVER != ares: %s.", resolver.get()); + char* resolver = gpr_getenv("GRPC_DNS_RESOLVER"); + if (resolver == nullptr || strlen(resolver) == 0) { + gpr_setenv("GRPC_DNS_RESOLVER", "ares"); + } else if (strcmp("ares", resolver)) { + gpr_log(GPR_INFO, "GRPC_DNS_RESOLVER != ares: %s.", resolver); } + gpr_free(resolver); grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); auto result = RUN_ALL_TESTS(); diff --git a/test/cpp/naming/cancel_ares_query_test.cc b/test/cpp/naming/cancel_ares_query_test.cc index 667011ae291..674e72fdc52 100644 --- a/test/cpp/naming/cancel_ares_query_test.cc +++ b/test/cpp/naming/cancel_ares_query_test.cc @@ -29,10 +29,10 @@ #include #include "include/grpc/support/string_util.h" #include "src/core/ext/filters/client_channel/resolver.h" -#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/stats.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/orphanable.h" @@ -374,7 +374,7 @@ TEST( int main(int argc, char** argv) { grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); - GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "ares"); + gpr_setenv("GRPC_DNS_RESOLVER", "ares"); // Sanity check the time that it takes to run the test // including the teardown time (the teardown // part of the test involves cancelling the DNS query, diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index 6cea8143907..93a92f68a6d 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -46,6 +46,7 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/orphanable.h" diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index f7c268a8105..25c113f59c5 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -953,8 +953,6 @@ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ -src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ -src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h \ src/core/ext/filters/client_channel/resolver/dns/native/README.md \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index a8ece17b555..452cad3022d 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -9252,8 +9252,7 @@ "deps": [ "gpr", "grpc_base", - "grpc_client_channel", - "grpc_resolver_dns_selection" + "grpc_client_channel" ], "headers": [ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h", @@ -9286,8 +9285,7 @@ "deps": [ "gpr", "grpc_base", - "grpc_client_channel", - "grpc_resolver_dns_selection" + "grpc_client_channel" ], "headers": [], "is_filegroup": true, @@ -9299,24 +9297,6 @@ "third_party": false, "type": "filegroup" }, - { - "deps": [ - "gpr", - "grpc_base" - ], - "headers": [ - "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_resolver_dns_selection", - "src": [ - "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc", - "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" - ], - "third_party": false, - "type": "filegroup" - }, { "deps": [ "gpr", diff --git a/tools/run_tests/run_microbenchmark.py b/tools/run_tests/run_microbenchmark.py index a7fde3007af..4e4d05cdcd4 100755 --- a/tools/run_tests/run_microbenchmark.py +++ b/tools/run_tests/run_microbenchmark.py @@ -96,7 +96,7 @@ def collect_latency(bm_name, args): '--benchmark_filter=^%s$' % line, '--benchmark_min_time=0.05' ], - environ={'GRPC_LATENCY_TRACE': '%s.trace' % fnize(line)}, + environ={'LATENCY_TRACE': '%s.trace' % fnize(line)}, shortname='profile-%s' % fnize(line))) profile_analysis.append( jobset.JobSpec( diff --git a/tools/run_tests/sanity/core_banned_functions.py b/tools/run_tests/sanity/core_banned_functions.py index ce9ff0dae21..549ae14f5ab 100755 --- a/tools/run_tests/sanity/core_banned_functions.py +++ b/tools/run_tests/sanity/core_banned_functions.py @@ -45,6 +45,10 @@ BANNED_EXCEPT = { 'grpc_closure_sched(': ['src/core/lib/iomgr/closure.cc'], 'grpc_closure_run(': ['src/core/lib/iomgr/closure.cc'], 'grpc_closure_list_sched(': ['src/core/lib/iomgr/closure.cc'], + 'gpr_getenv_silent(': [ + 'src/core/lib/gpr/log.cc', 'src/core/lib/gpr/env_linux.cc', + 'src/core/lib/gpr/env_posix.cc', 'src/core/lib/gpr/env_windows.cc' + ], } errors = 0 From fb3fa43e61c05bca59974523d327a176b40e1aa8 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 14 May 2019 23:44:44 +0200 Subject: [PATCH 0210/1555] Adding (c) statement. --- tools/bazel.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/bazel.sh b/tools/bazel.sh index 804b974700b..37fd2a242bf 100755 --- a/tools/bazel.sh +++ b/tools/bazel.sh @@ -1,4 +1,18 @@ #!/bin/bash +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Keeping up with Bazel's breaking changes is currently difficult. # This script wraps calling bazel by downloading the currently From 7743130f645b3d7777c80ad6a0cf5f479bba97c2 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Tue, 14 May 2019 15:26:56 -0700 Subject: [PATCH 0211/1555] Consolidate conditional localhost resolution into existing file --- BUILD | 2 - BUILD.gn | 2 - CMakeLists.txt | 2 - Makefile | 2 - build.yaml | 2 - config.m4 | 1 - config.w32 | 1 - gRPC-C++.podspec | 1 - gRPC-Core.podspec | 3 - grpc.gemspec | 2 - grpc.gyp | 2 - package.xml | 2 - .../resolver/dns/c_ares/grpc_ares_wrapper.cc | 68 +++++++++++++++ .../resolver/dns/c_ares/grpc_ares_wrapper.h | 8 -- .../dns/c_ares/grpc_ares_wrapper_libuv.cc | 17 ---- .../dns/c_ares/grpc_ares_wrapper_posix.cc | 6 -- .../dns/c_ares/grpc_ares_wrapper_windows.cc | 13 --- .../c_ares/grpc_ares_wrapper_windows_inner.cc | 83 ------------------- .../c_ares/grpc_ares_wrapper_windows_inner.h | 34 -------- src/python/grpcio/grpc_core_dependencies.py | 1 - tools/doxygen/Doxyfile.core.internal | 2 - .../generated/sources_and_headers.json | 7 +- 22 files changed, 70 insertions(+), 191 deletions(-) delete mode 100644 src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc delete mode 100644 src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h diff --git a/BUILD b/BUILD index 9dde10224ce..55c467edd53 100644 --- a/BUILD +++ b/BUILD @@ -1601,12 +1601,10 @@ grpc_cc_library( "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc", ], hdrs = [ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h", ], external_deps = [ "cares", diff --git a/BUILD.gn b/BUILD.gn index 7357d0f9595..d3c1186f7a6 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -324,8 +324,6 @@ config("grpc_config") { "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h", "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc", "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h", "src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc", diff --git a/CMakeLists.txt b/CMakeLists.txt index e74d4bdf643..431afd40fce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1301,7 +1301,6 @@ add_library(grpc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc @@ -2698,7 +2697,6 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc diff --git a/Makefile b/Makefile index 4cecfba196f..847144bd874 100644 --- a/Makefile +++ b/Makefile @@ -3773,7 +3773,6 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ @@ -5118,7 +5117,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ diff --git a/build.yaml b/build.yaml index d1d69ef5f95..6368db397bd 100644 --- a/build.yaml +++ b/build.yaml @@ -780,7 +780,6 @@ filegroups: headers: - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h - - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h src: - src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc @@ -792,7 +791,6 @@ filegroups: - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc - - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc plugin: grpc_resolver_dns_ares uses: - grpc_base diff --git a/config.m4 b/config.m4 index f29cb0c705b..bb30be56910 100644 --- a/config.m4 +++ b/config.m4 @@ -411,7 +411,6 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ diff --git a/config.w32 b/config.w32 index 4f0225974f7..c9faa8d9ac8 100644 --- a/config.w32 +++ b/config.w32 @@ -386,7 +386,6 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_libuv.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_posix.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_windows.cc " + - "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_windows_inner.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\dns_resolver_selection.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\native\\dns_resolver.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\sockaddr\\sockaddr_resolver.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 67e07670ead..86c5f211f27 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -562,7 +562,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 393a9100933..069c319ec0b 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -538,7 +538,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', @@ -869,7 +868,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', @@ -1191,7 +1189,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', diff --git a/grpc.gemspec b/grpc.gemspec index b0ea43b9d92..5a34687b4d9 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -472,7 +472,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/lb_policy/subchannel_list.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h ) - s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h ) s.files += %w( src/core/ext/filters/max_age/max_age_filter.h ) s.files += %w( src/core/ext/filters/message_size/message_size_filter.h ) @@ -806,7 +805,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc ) - s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc ) diff --git a/grpc.gyp b/grpc.gyp index 5feaabd456d..1cc6e46b4be 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -593,7 +593,6 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', @@ -1354,7 +1353,6 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', diff --git a/package.xml b/package.xml index 2335e3527ba..201b4a3e951 100644 --- a/package.xml +++ b/package.xml @@ -477,7 +477,6 @@ - @@ -811,7 +810,6 @@ - diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc index 0f04f14fd8a..86a9bb30cb4 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc @@ -522,6 +522,74 @@ static bool target_matches_localhost(const char* name) { return out; } +#ifdef GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY +static bool inner_maybe_resolve_localhost_manually_locked( + const char* name, const char* default_port, + grpc_core::UniquePtr* addrs, char** host, + char** port) { + gpr_split_host_port(name, host, port); + if (*host == nullptr) { + gpr_log(GPR_ERROR, + "Failed to parse %s into host:port during manual localhost " + "resolution check.", + name); + return false; + } + if (*port == nullptr) { + if (default_port == nullptr) { + gpr_log(GPR_ERROR, + "No port or default port for %s during manual localhost " + "resolution check.", + name); + return false; + } + *port = gpr_strdup(default_port); + } + if (gpr_stricmp(*host, "localhost") == 0) { + GPR_ASSERT(*addrs == nullptr); + *addrs = grpc_core::MakeUnique(); + uint16_t numeric_port = grpc_strhtons(*port); + // Append the ipv6 loopback address. + struct sockaddr_in6 ipv6_loopback_addr; + memset(&ipv6_loopback_addr, 0, sizeof(ipv6_loopback_addr)); + ((char*)&ipv6_loopback_addr.sin6_addr)[15] = 1; + ipv6_loopback_addr.sin6_family = AF_INET6; + ipv6_loopback_addr.sin6_port = numeric_port; + (*addrs)->emplace_back(&ipv6_loopback_addr, sizeof(ipv6_loopback_addr), + nullptr /* args */); + // Append the ipv4 loopback address. + struct sockaddr_in ipv4_loopback_addr; + memset(&ipv4_loopback_addr, 0, sizeof(ipv4_loopback_addr)); + ((char*)&ipv4_loopback_addr.sin_addr)[0] = 0x7f; + ((char*)&ipv4_loopback_addr.sin_addr)[3] = 0x01; + ipv4_loopback_addr.sin_family = AF_INET; + ipv4_loopback_addr.sin_port = numeric_port; + (*addrs)->emplace_back(&ipv4_loopback_addr, sizeof(ipv4_loopback_addr), + nullptr /* args */); + // Let the address sorter figure out which one should be tried first. + grpc_cares_wrapper_address_sorting_sort(addrs->get()); + return true; + } + return false; +} +#endif /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ + +static bool grpc_ares_maybe_resolve_localhost_manually_locked( + const char* name, const char* default_port, + grpc_core::UniquePtr* addrs) { +#ifdef GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY + char* host = nullptr; + char* port = nullptr; + bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port, + addrs, &host, &port); + gpr_free(host); + gpr_free(port); + return out; +#else /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ + return false; +#endif /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ +} + static grpc_ares_request* grpc_dns_lookup_ares_locked_impl( const char* dns_server, const char* name, const char* default_port, grpc_pollset_set* interested_parties, grpc_closure* on_done, diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h index 2cb7c9e53a5..cc977c06b25 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h @@ -87,14 +87,6 @@ void grpc_ares_complete_request_locked(grpc_ares_request* request); /* E.g., return false if ipv6 is known to not be available. */ bool grpc_ares_query_ipv6(); -/* Maybe (depending on the current platform) checks if "name" matches - * "localhost" and if so fills in addrs with the correct sockaddr structures. - * Returns a bool indicating whether or not such an action was performed. - * See https://github.com/grpc/grpc/issues/15158. */ -bool grpc_ares_maybe_resolve_localhost_manually_locked( - const char* name, const char* default_port, - grpc_core::UniquePtr* addrs); - /* Sorts destinations in lb_addrs according to RFC 6724. */ void grpc_cares_wrapper_address_sorting_sort( grpc_core::ServerAddressList* addresses); diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc index eb0b3dab4a4..f85feb674dd 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc @@ -25,7 +25,6 @@ #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" @@ -37,20 +36,4 @@ bool grpc_ares_query_ipv6() { return true; } -bool grpc_ares_maybe_resolve_localhost_manually_locked( - const char* name, const char* default_port, - grpc_core::UniquePtr* addrs) { -#ifdef GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY - char* host = nullptr; - char* port = nullptr; - bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port, - addrs, &host, &port); - gpr_free(host); - gpr_free(port); - return out; -#else /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ - return false; -#endif /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ -} - #endif /* GRPC_ARES == 1 && defined(GRPC_UV) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc index 028d8442169..23c0fec74f3 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc @@ -26,10 +26,4 @@ bool grpc_ares_query_ipv6() { return grpc_ipv6_loopback_available(); } -bool grpc_ares_maybe_resolve_localhost_manually_locked( - const char* name, const char* default_port, - grpc_core::UniquePtr* addrs) { - return false; -} - #endif /* GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_ARES_EV_DRIVER) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc index e48f9501752..06cd5722ce3 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc @@ -25,7 +25,6 @@ #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" @@ -33,16 +32,4 @@ bool grpc_ares_query_ipv6() { return grpc_ipv6_loopback_available(); } -bool grpc_ares_maybe_resolve_localhost_manually_locked( - const char* name, const char* default_port, - grpc_core::UniquePtr* addrs) { - char* host = nullptr; - char* port = nullptr; - bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port, - addrs, &host, &port); - gpr_free(host); - gpr_free(port); - return out; -} - #endif /* GRPC_ARES == 1 && defined(GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc deleted file mode 100644 index 1331a6a67f5..00000000000 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc +++ /dev/null @@ -1,83 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/lib/iomgr/port.h" -#if GRPC_ARES == 1 && defined(GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY) - -#include - -#include "src/core/ext/filters/client_channel/parse_address.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" -#include "src/core/ext/filters/client_channel/server_address.h" -#include "src/core/lib/gpr/host_port.h" -#include "src/core/lib/gpr/string.h" - -bool inner_maybe_resolve_localhost_manually_locked( - const char* name, const char* default_port, - grpc_core::UniquePtr* addrs, char** host, - char** port) { - gpr_split_host_port(name, host, port); - if (*host == nullptr) { - gpr_log(GPR_ERROR, - "Failed to parse %s into host:port during manual localhost " - "resolution check.", - name); - return false; - } - if (*port == nullptr) { - if (default_port == nullptr) { - gpr_log(GPR_ERROR, - "No port or default port for %s during manual localhost " - "resolution check.", - name); - return false; - } - *port = gpr_strdup(default_port); - } - if (gpr_stricmp(*host, "localhost") == 0) { - GPR_ASSERT(*addrs == nullptr); - *addrs = grpc_core::MakeUnique(); - uint16_t numeric_port = grpc_strhtons(*port); - // Append the ipv6 loopback address. - struct sockaddr_in6 ipv6_loopback_addr; - memset(&ipv6_loopback_addr, 0, sizeof(ipv6_loopback_addr)); - ((char*)&ipv6_loopback_addr.sin6_addr)[15] = 1; - ipv6_loopback_addr.sin6_family = AF_INET6; - ipv6_loopback_addr.sin6_port = numeric_port; - (*addrs)->emplace_back(&ipv6_loopback_addr, sizeof(ipv6_loopback_addr), - nullptr /* args */); - // Append the ipv4 loopback address. - struct sockaddr_in ipv4_loopback_addr; - memset(&ipv4_loopback_addr, 0, sizeof(ipv4_loopback_addr)); - ((char*)&ipv4_loopback_addr.sin_addr)[0] = 0x7f; - ((char*)&ipv4_loopback_addr.sin_addr)[3] = 0x01; - ipv4_loopback_addr.sin_family = AF_INET; - ipv4_loopback_addr.sin_port = numeric_port; - (*addrs)->emplace_back(&ipv4_loopback_addr, sizeof(ipv4_loopback_addr), - nullptr /* args */); - // Let the address sorter figure out which one should be tried first. - grpc_cares_wrapper_address_sorting_sort(addrs->get()); - return true; - } - return false; -} - -#endif /* GRPC_ARES == 1 && defined(GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h deleted file mode 100644 index 783b781154c..00000000000 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_WINDOWS_INNER_H -#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_WINDOWS_INNER_H - -#include - -#include - -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" - -bool inner_maybe_resolve_localhost_manually_locked( - const char* name, const char* default_port, - grpc_core::UniquePtr* addrs, char** host, - char** port); - -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_WINDOWS_INNER_H \ - */ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index c9217aded63..2619ccf9740 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -385,7 +385,6 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 483e639be66..b34c7734621 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -951,8 +951,6 @@ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallba src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ -src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ -src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h \ src/core/ext/filters/client_channel/resolver/dns/native/README.md \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index de08e38a838..39ee76b1a9c 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -9178,8 +9178,7 @@ ], "headers": [ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" ], "is_filegroup": true, "language": "c", @@ -9196,9 +9195,7 @@ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc" ], "third_party": false, "type": "filegroup" From 172bb1b30f15b1d656603190c5bad2f426ac1354 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 14 May 2019 15:04:39 -0700 Subject: [PATCH 0212/1555] Whitelist internal code path to use ApplicationExecCtx --- src/core/lib/surface/completion_queue.cc | 27 +++++++++++++++--------- src/core/lib/surface/completion_queue.h | 2 +- src/core/lib/surface/server.cc | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index cdf1020051f..d040e91b796 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -201,7 +201,7 @@ struct cq_vtable { bool (*begin_op)(grpc_completion_queue* cq, void* tag); void (*end_op)(grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage); + void* done_arg, grpc_cq_completion* storage, bool internal); grpc_event (*next)(grpc_completion_queue* cq, gpr_timespec deadline, void* reserved); grpc_event (*pluck)(grpc_completion_queue* cq, void* tag, @@ -359,19 +359,19 @@ static void cq_end_op_for_next(grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage); + void* done_arg, grpc_cq_completion* storage, bool internal = false); static void cq_end_op_for_pluck(grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage); + void* done_arg, grpc_cq_completion* storage, bool internal = false); static void cq_end_op_for_callback(grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage); + void* done_arg, grpc_cq_completion* storage, bool internal = false); static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline, void* reserved); @@ -679,7 +679,8 @@ static void cq_end_op_for_next(grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage) { + void* done_arg, grpc_cq_completion* storage, + bool internal) { GPR_TIMER_SCOPE("cq_end_op_for_next", 0); if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) || @@ -759,7 +760,8 @@ static void cq_end_op_for_pluck(grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage) { + void* done_arg, grpc_cq_completion* storage, + bool internal) { GPR_TIMER_SCOPE("cq_end_op_for_pluck", 0); cq_pluck_data* cqd = static_cast DATA_FROM_CQ(cq); @@ -831,7 +833,8 @@ static void functor_callback(void* arg, grpc_error* error) { static void cq_end_op_for_callback( grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage) { + grpc_cq_completion* storage, + bool internal) { GPR_TIMER_SCOPE("cq_end_op_for_callback", 0); cq_callback_data* cqd = static_cast DATA_FROM_CQ(cq); @@ -862,19 +865,23 @@ static void cq_end_op_for_callback( } auto* functor = static_cast(tag); - GRPC_CLOSURE_SCHED( + if (internal) { + grpc_core::ApplicationCallbackExecCtx::Enqueue(functor, (error == GRPC_ERROR_NONE)); + } else { + GRPC_CLOSURE_SCHED( GRPC_CLOSURE_CREATE( functor_callback, functor, grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), GRPC_ERROR_REF(error)); + } GRPC_ERROR_UNREF(error); } void grpc_cq_end_op(grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage) { - cq->vtable->end_op(cq, tag, error, done, done_arg, storage); + void* done_arg, grpc_cq_completion* storage, bool internal) { + cq->vtable->end_op(cq, tag, error, done, done_arg, storage, internal); } typedef struct { diff --git a/src/core/lib/surface/completion_queue.h b/src/core/lib/surface/completion_queue.h index d60fe6d6efe..f5b0822fcb4 100644 --- a/src/core/lib/surface/completion_queue.h +++ b/src/core/lib/surface/completion_queue.h @@ -77,7 +77,7 @@ bool grpc_cq_begin_op(grpc_completion_queue* cc, void* tag); grpc_cq_begin_op */ void grpc_cq_end_op(grpc_completion_queue* cc, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage); + void* done_arg, grpc_cq_completion* storage, bool internal); grpc_pollset* grpc_cq_pollset(grpc_completion_queue* cc); diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 2377c4d8f23..19f61c548d6 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -513,7 +513,7 @@ static void publish_call(grpc_server* server, call_data* calld, size_t cq_idx, } grpc_cq_end_op(calld->cq_new, rc->tag, GRPC_ERROR_NONE, done_request_event, - rc, &rc->completion); + rc, &rc->completion, true); } static void publish_new_rpc(void* arg, grpc_error* error) { From 5f0e68636e66b0bf4a7bfa116124f44fae12b609 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Tue, 14 May 2019 15:45:02 -0700 Subject: [PATCH 0213/1555] Move ifdefs around --- .../resolver/dns/c_ares/grpc_ares_wrapper.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc index 86a9bb30cb4..ad0f1460121 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc @@ -572,12 +572,10 @@ static bool inner_maybe_resolve_localhost_manually_locked( } return false; } -#endif /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ static bool grpc_ares_maybe_resolve_localhost_manually_locked( const char* name, const char* default_port, grpc_core::UniquePtr* addrs) { -#ifdef GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY char* host = nullptr; char* port = nullptr; bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port, @@ -585,10 +583,14 @@ static bool grpc_ares_maybe_resolve_localhost_manually_locked( gpr_free(host); gpr_free(port); return out; -#else /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ - return false; -#endif /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ } +#else /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ +static bool grpc_ares_maybe_resolve_localhost_manually_locked( + const char* name, const char* default_port, + grpc_core::UniquePtr* addrs) { + return false; +} +#endif /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ static grpc_ares_request* grpc_dns_lookup_ares_locked_impl( const char* dns_server, const char* name, const char* default_port, From c7343ea03d4e9382dec1ff9c25f5629c68fc87bb Mon Sep 17 00:00:00 2001 From: Mehrdad Afshari Date: Tue, 14 May 2019 16:20:21 -0700 Subject: [PATCH 0214/1555] Unsubscribe all connectivity callbacks on Channel.close --- src/python/grpcio/grpc/_channel.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/python/grpcio/grpc/_channel.py b/src/python/grpcio/grpc/_channel.py index 1272ee802bc..f566fd698ad 100644 --- a/src/python/grpcio/grpc/_channel.py +++ b/src/python/grpcio/grpc/_channel.py @@ -1000,6 +1000,11 @@ def _unsubscribe(state, callback): break +def _unsubscribe_all(state): + with state.lock: + del state.callbacks_and_connectivities[:] + + def _augment_options(base_options, compression): compression_option = _compression.create_channel_option(compression) return tuple(base_options) + compression_option + (( @@ -1067,6 +1072,7 @@ class Channel(grpc.Channel): _common.encode(method), request_serializer, response_deserializer) def _close(self): + _unsubscribe_all(self._connectivity_state) self._channel.close(cygrpc.StatusCode.cancelled, 'Channel closed!') cygrpc.fork_unregister_channel(self) _moot(self._connectivity_state) From 356e7c21079659aa083e131acb0c5cb4d6709feb Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 14 May 2019 14:37:20 -0700 Subject: [PATCH 0215/1555] Clean up some names in the service config code. --- .../filters/client_channel/client_channel.cc | 26 ++-- .../client_channel/resolver_result_parsing.cc | 14 +- .../client_channel/resolver_result_parsing.h | 8 +- .../filters/client_channel/service_config.cc | 42 +++-- .../filters/client_channel/service_config.h | 54 ++++--- .../message_size/message_size_filter.cc | 24 +-- .../message_size/message_size_filter.h | 4 +- src/core/lib/channel/context.h | 2 +- .../client_channel/service_config_test.cc | 144 +++++++++--------- 9 files changed, 157 insertions(+), 161 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index cc4bfdded13..c0586d459b2 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -66,7 +66,7 @@ #include "src/core/lib/transport/static_metadata.h" #include "src/core/lib/transport/status_metadata.h" -using grpc_core::internal::ClientChannelMethodParsedObject; +using grpc_core::internal::ClientChannelMethodParsedConfig; using grpc_core::internal::ServerRetryThrottleData; // @@ -234,7 +234,7 @@ class ChannelData { void ProcessLbPolicy( const Resolver::Result& resolver_result, - const internal::ClientChannelGlobalParsedObject* parsed_service_config, + const internal::ClientChannelGlobalParsedConfig* parsed_service_config, UniquePtr* lb_policy_name, RefCountedPtr* lb_policy_config); @@ -629,7 +629,7 @@ class CallData { RefCountedPtr retry_throttle_data_; ServiceConfig::CallData service_config_call_data_; - const ClientChannelMethodParsedObject* method_params_ = nullptr; + const ClientChannelMethodParsedConfig* method_params_ = nullptr; RefCountedPtr subchannel_call_; @@ -772,7 +772,7 @@ class ChannelData::ServiceConfigSetter { public: ServiceConfigSetter( ChannelData* chand, - Optional + Optional retry_throttle_data, RefCountedPtr service_config) : chand_(chand), @@ -811,7 +811,7 @@ class ChannelData::ServiceConfigSetter { } ChannelData* chand_; - Optional + Optional retry_throttle_data_; RefCountedPtr service_config_; grpc_closure closure_; @@ -1141,7 +1141,7 @@ ChannelData::~ChannelData() { void ChannelData::ProcessLbPolicy( const Resolver::Result& resolver_result, - const internal::ClientChannelGlobalParsedObject* parsed_service_config, + const internal::ClientChannelGlobalParsedConfig* parsed_service_config, UniquePtr* lb_policy_name, RefCountedPtr* lb_policy_config) { // Prefer the LB policy name found in the service config. @@ -1238,12 +1238,12 @@ bool ChannelData::ProcessResolverResultLocked( } // Process service config. UniquePtr service_config_json; - const internal::ClientChannelGlobalParsedObject* parsed_service_config = + const internal::ClientChannelGlobalParsedConfig* parsed_service_config = nullptr; if (service_config != nullptr) { parsed_service_config = - static_cast( - service_config->GetParsedGlobalServiceConfigObject( + static_cast( + service_config->GetGlobalParsedConfig( internal::ClientChannelServiceConfigParser::ParserIndex())); } // TODO(roth): Eliminate this hack as part of hiding health check @@ -1282,7 +1282,7 @@ bool ChannelData::ProcessResolverResultLocked( // if we feel it is unnecessary. if (service_config_changed || !chand->received_first_resolver_result_) { chand->received_first_resolver_result_ = true; - Optional + Optional retry_throttle_data; if (parsed_service_config != nullptr) { retry_throttle_data = parsed_service_config->retry_throttling(); @@ -3245,10 +3245,10 @@ void CallData::ApplyServiceConfigToCallLocked(grpc_call_element* elem) { service_config_call_data_ = ServiceConfig::CallData(chand->service_config(), path_); if (service_config_call_data_.service_config() != nullptr) { - call_context_[GRPC_SERVICE_CONFIG_CALL_DATA].value = + call_context_[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA].value = &service_config_call_data_; - method_params_ = static_cast( - service_config_call_data_.GetMethodParsedObject( + method_params_ = static_cast( + service_config_call_data_.GetMethodParsedConfig( internal::ClientChannelServiceConfigParser::ParserIndex())); } retry_throttle_data_ = chand->retry_throttle_data(); diff --git a/src/core/ext/filters/client_channel/resolver_result_parsing.cc b/src/core/ext/filters/client_channel/resolver_result_parsing.cc index ac6bc7ed16a..6a811a2d936 100644 --- a/src/core/ext/filters/client_channel/resolver_result_parsing.cc +++ b/src/core/ext/filters/client_channel/resolver_result_parsing.cc @@ -92,11 +92,11 @@ bool ParseDuration(grpc_json* field, grpc_millis* duration) { return true; } -UniquePtr ParseRetryPolicy( +UniquePtr ParseRetryPolicy( grpc_json* field, grpc_error** error) { GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); auto retry_policy = - MakeUnique(); + MakeUnique(); if (field->type != GRPC_JSON_OBJECT) { *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "field:retryPolicy error:should be of type object"); @@ -270,7 +270,7 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json, InlinedVector error_list; RefCountedPtr parsed_lb_config; UniquePtr lb_policy_name; - Optional retry_throttling; + Optional retry_throttling; const char* health_check_service_name = nullptr; for (grpc_json* field = json->child; field != nullptr; field = field->next) { if (field->key == nullptr) { @@ -409,7 +409,7 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json, } } } - ClientChannelGlobalParsedObject::RetryThrottling data; + ClientChannelGlobalParsedConfig::RetryThrottling data; if (!max_milli_tokens.has_value()) { error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( "field:retryThrottling field:maxTokens error:Not found")); @@ -440,7 +440,7 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json, &error_list); if (*error == GRPC_ERROR_NONE) { return UniquePtr( - New( + New( std::move(parsed_lb_config), std::move(lb_policy_name), retry_throttling, health_check_service_name)); } @@ -454,7 +454,7 @@ ClientChannelServiceConfigParser::ParsePerMethodParams(const grpc_json* json, InlinedVector error_list; Optional wait_for_ready; grpc_millis timeout = 0; - UniquePtr retry_policy; + UniquePtr retry_policy; for (grpc_json* field = json->child; field != nullptr; field = field->next) { if (field->key == nullptr) continue; if (strcmp(field->key, "waitForReady") == 0) { @@ -494,7 +494,7 @@ ClientChannelServiceConfigParser::ParsePerMethodParams(const grpc_json* json, *error = GRPC_ERROR_CREATE_FROM_VECTOR("Client channel parser", &error_list); if (*error == GRPC_ERROR_NONE) { return UniquePtr( - New(timeout, wait_for_ready, + New(timeout, wait_for_ready, std::move(retry_policy))); } return nullptr; diff --git a/src/core/ext/filters/client_channel/resolver_result_parsing.h b/src/core/ext/filters/client_channel/resolver_result_parsing.h index 9af8b16876a..7750791c779 100644 --- a/src/core/ext/filters/client_channel/resolver_result_parsing.h +++ b/src/core/ext/filters/client_channel/resolver_result_parsing.h @@ -37,14 +37,14 @@ namespace grpc_core { namespace internal { -class ClientChannelGlobalParsedObject : public ServiceConfig::ParsedConfig { +class ClientChannelGlobalParsedConfig : public ServiceConfig::ParsedConfig { public: struct RetryThrottling { intptr_t max_milli_tokens = 0; intptr_t milli_token_ratio = 0; }; - ClientChannelGlobalParsedObject( + ClientChannelGlobalParsedConfig( RefCountedPtr parsed_lb_config, UniquePtr parsed_deprecated_lb_policy, const Optional& retry_throttling, @@ -77,7 +77,7 @@ class ClientChannelGlobalParsedObject : public ServiceConfig::ParsedConfig { const char* health_check_service_name_; }; -class ClientChannelMethodParsedObject : public ServiceConfig::ParsedConfig { +class ClientChannelMethodParsedConfig : public ServiceConfig::ParsedConfig { public: struct RetryPolicy { int max_attempts = 0; @@ -87,7 +87,7 @@ class ClientChannelMethodParsedObject : public ServiceConfig::ParsedConfig { StatusCodeSet retryable_status_codes; }; - ClientChannelMethodParsedObject(grpc_millis timeout, + ClientChannelMethodParsedConfig(grpc_millis timeout, const Optional& wait_for_ready, UniquePtr retry_policy) : timeout_(timeout), diff --git a/src/core/ext/filters/client_channel/service_config.cc b/src/core/ext/filters/client_channel/service_config.cc index 86d4f7368c0..d41859bf45a 100644 --- a/src/core/ext/filters/client_channel/service_config.cc +++ b/src/core/ext/filters/client_channel/service_config.cc @@ -96,16 +96,15 @@ grpc_error* ServiceConfig::ParseGlobalParams(const grpc_json* json_tree) { if (parser_error != GRPC_ERROR_NONE) { error_list.push_back(parser_error); } - parsed_global_service_config_objects_.push_back(std::move(parsed_obj)); + parsed_global_configs_.push_back(std::move(parsed_obj)); } return GRPC_ERROR_CREATE_FROM_VECTOR("Global Params", &error_list); } -grpc_error* ServiceConfig::ParseJsonMethodConfigToServiceConfigObjectsTable( +grpc_error* ServiceConfig::ParseJsonMethodConfigToServiceConfigVectorTable( const grpc_json* json, - SliceHashTable::Entry* entries, - size_t* idx) { - auto objs_vector = MakeUnique(); + SliceHashTable::Entry* entries, size_t* idx) { + auto objs_vector = MakeUnique(); InlinedVector error_list; for (size_t i = 0; i < g_registered_parsers->size(); i++) { grpc_error* parser_error = GRPC_ERROR_NONE; @@ -116,10 +115,10 @@ grpc_error* ServiceConfig::ParseJsonMethodConfigToServiceConfigObjectsTable( } objs_vector->push_back(std::move(parsed_obj)); } - service_config_objects_vectors_storage_.push_back(std::move(objs_vector)); + parsed_method_config_vectors_storage_.push_back(std::move(objs_vector)); const auto* vector_ptr = - service_config_objects_vectors_storage_ - [service_config_objects_vectors_storage_.size() - 1] + parsed_method_config_vectors_storage_ + [parsed_method_config_vectors_storage_.size() - 1] .get(); // Construct list of paths. InlinedVector, 10> paths; @@ -160,7 +159,7 @@ wrap_error: grpc_error* ServiceConfig::ParsePerMethodParams(const grpc_json* json_tree) { GPR_DEBUG_ASSERT(json_tree_->type == GRPC_JSON_OBJECT); GPR_DEBUG_ASSERT(json_tree_->key == nullptr); - SliceHashTable::Entry* entries = nullptr; + SliceHashTable::Entry* entries = nullptr; size_t num_entries = 0; InlinedVector error_list; for (grpc_json* field = json_tree->child; field != nullptr; @@ -187,14 +186,13 @@ grpc_error* ServiceConfig::ParsePerMethodParams(const grpc_json* json_tree) { } num_entries += static_cast(count); } - entries = static_cast< - SliceHashTable::Entry*>(gpr_zalloc( - num_entries * - sizeof(SliceHashTable::Entry))); + entries = static_cast::Entry*>( + gpr_zalloc(num_entries * + sizeof(SliceHashTable::Entry))); size_t idx = 0; for (grpc_json* method = field->child; method != nullptr; method = method->next) { - grpc_error* error = ParseJsonMethodConfigToServiceConfigObjectsTable( + grpc_error* error = ParseJsonMethodConfigToServiceConfigVectorTable( method, entries, &idx); if (error != GRPC_ERROR_NONE) { error_list.push_back(error); @@ -206,9 +204,9 @@ grpc_error* ServiceConfig::ParsePerMethodParams(const grpc_json* json_tree) { } } if (entries != nullptr) { - parsed_method_service_config_objects_table_ = - SliceHashTable::Create( - num_entries, entries, nullptr); + parsed_method_configs_table_ = + SliceHashTable::Create(num_entries, entries, + nullptr); gpr_free(entries); } return GRPC_ERROR_CREATE_FROM_VECTOR("Method Params", &error_list); @@ -287,12 +285,12 @@ UniquePtr ServiceConfig::ParseJsonMethodName(grpc_json* json, return UniquePtr(path); } -const ServiceConfig::ServiceConfigObjectsVector* -ServiceConfig::GetMethodServiceConfigObjectsVector(const grpc_slice& path) { - if (parsed_method_service_config_objects_table_.get() == nullptr) { +const ServiceConfig::ParsedConfigVector* +ServiceConfig::GetMethodParsedConfigVector(const grpc_slice& path) { + if (parsed_method_configs_table_.get() == nullptr) { return nullptr; } - const auto* value = parsed_method_service_config_objects_table_->Get(path); + const auto* value = parsed_method_configs_table_->Get(path); // If we didn't find a match for the path, try looking for a wildcard // entry (i.e., change "/service/method" to "/service/*"). if (value == nullptr) { @@ -305,7 +303,7 @@ ServiceConfig::GetMethodServiceConfigObjectsVector(const grpc_slice& path) { buf[len + 1] = '\0'; grpc_slice wildcard_path = grpc_slice_from_copied_string(buf); gpr_free(buf); - value = parsed_method_service_config_objects_table_->Get(wildcard_path); + value = parsed_method_configs_table_->Get(wildcard_path); grpc_slice_unref_internal(wildcard_path); gpr_free(path_str); if (value == nullptr) return nullptr; diff --git a/src/core/ext/filters/client_channel/service_config.h b/src/core/ext/filters/client_channel/service_config.h index e6f855ad934..189a0b9bca2 100644 --- a/src/core/ext/filters/client_channel/service_config.h +++ b/src/core/ext/filters/client_channel/service_config.h @@ -88,7 +88,7 @@ class ServiceConfig : public RefCounted { static constexpr int kNumPreallocatedParsers = 4; typedef InlinedVector, kNumPreallocatedParsers> - ServiceConfigObjectsVector; + ParsedConfigVector; /// When a service config is applied to a call in the client_channel_filter, /// we create an instance of this object and store it in the call_data for @@ -102,25 +102,25 @@ class ServiceConfig : public RefCounted { : service_config_(std::move(svc_cfg)) { if (service_config_ != nullptr) { method_params_vector_ = - service_config_->GetMethodServiceConfigObjectsVector(path); + service_config_->GetMethodParsedConfigVector(path); } } ServiceConfig* service_config() { return service_config_.get(); } - ParsedConfig* GetMethodParsedObject(size_t index) const { + ParsedConfig* GetMethodParsedConfig(size_t index) const { return method_params_vector_ != nullptr ? (*method_params_vector_)[index].get() : nullptr; } - ParsedConfig* GetGlobalParsedObject(size_t index) const { - return service_config_->GetParsedGlobalServiceConfigObject(index); + ParsedConfig* GetGlobalParsedConfig(size_t index) const { + return service_config_->GetGlobalParsedConfig(index); } private: RefCountedPtr service_config_; - const ServiceConfigObjectsVector* method_params_vector_ = nullptr; + const ParsedConfigVector* method_params_vector_ = nullptr; }; /// Creates a new service config from parsing \a json_string. @@ -132,25 +132,24 @@ class ServiceConfig : public RefCounted { const char* service_config_json() const { return service_config_json_.get(); } - /// Retrieves the parsed global service config object at index \a index. The + /// Retrieves the global parsed config at index \a index. The /// lifetime of the returned object is tied to the lifetime of the /// ServiceConfig object. - ParsedConfig* GetParsedGlobalServiceConfigObject(size_t index) { - GPR_DEBUG_ASSERT(index < parsed_global_service_config_objects_.size()); - return parsed_global_service_config_objects_[index].get(); + ParsedConfig* GetGlobalParsedConfig(size_t index) { + GPR_DEBUG_ASSERT(index < parsed_global_configs_.size()); + return parsed_global_configs_[index].get(); } - /// Retrieves the vector of method service config objects for a given path \a - /// path. The lifetime of the returned vector and contained objects is tied to - /// the lifetime of the ServiceConfig object. - const ServiceConfigObjectsVector* GetMethodServiceConfigObjectsVector( - const grpc_slice& path); + /// Retrieves the vector of parsed configs for the method identified + /// by \a path. The lifetime of the returned vector and contained objects + /// is tied to the lifetime of the ServiceConfig object. + const ParsedConfigVector* GetMethodParsedConfigVector(const grpc_slice& path); /// Globally register a service config parser. On successful registration, it /// returns the index at which the parser was registered. On failure, -1 is /// returned. Each new service config update will go through all the /// registered parser. Each parser is responsible for reading the service - /// config json and returning a parsed object. This parsed object can later be + /// config json and returning a parsed config. This parsed config can later be /// retrieved using the same index that was returned at registration time. static size_t RegisterParser(UniquePtr parser); @@ -180,26 +179,25 @@ class ServiceConfig : public RefCounted { static UniquePtr ParseJsonMethodName(grpc_json* json, grpc_error** error); - grpc_error* ParseJsonMethodConfigToServiceConfigObjectsTable( + grpc_error* ParseJsonMethodConfigToServiceConfigVectorTable( const grpc_json* json, - SliceHashTable::Entry* entries, - size_t* idx); + SliceHashTable::Entry* entries, size_t* idx); UniquePtr service_config_json_; UniquePtr json_string_; // Underlying storage for json_tree. grpc_json* json_tree_; InlinedVector, kNumPreallocatedParsers> - parsed_global_service_config_objects_; - // A map from the method name to the service config objects vector. Note that - // we are using a raw pointer and not a unique pointer so that we can use the - // same vector for multiple names. - RefCountedPtr> - parsed_method_service_config_objects_table_; + parsed_global_configs_; + // A map from the method name to the parsed config vector. Note that we are + // using a raw pointer and not a unique pointer so that we can use the same + // vector for multiple names. + RefCountedPtr> + parsed_method_configs_table_; // Storage for all the vectors that are being used in - // parsed_method_service_config_objects_table_. - InlinedVector, 32> - service_config_objects_vectors_storage_; + // parsed_method_configs_table_. + InlinedVector, 32> + parsed_method_config_vectors_storage_; }; } // namespace grpc_core diff --git a/src/core/ext/filters/message_size/message_size_filter.cc b/src/core/ext/filters/message_size/message_size_filter.cc index a973cbca121..8e93d11c9c0 100644 --- a/src/core/ext/filters/message_size/message_size_filter.cc +++ b/src/core/ext/filters/message_size/message_size_filter.cc @@ -88,7 +88,7 @@ UniquePtr MessageSizeParser::ParsePerMethodParams( *error = GRPC_ERROR_CREATE_FROM_VECTOR("Message size parser", &error_list); return nullptr; } - return UniquePtr(New( + return UniquePtr(New( max_request_message_bytes, max_response_message_bytes)); } @@ -102,7 +102,7 @@ size_t MessageSizeParser::ParserIndex() { return g_message_size_parser_index; } namespace { struct channel_data { - grpc_core::MessageSizeParsedObject::message_size_limits limits; + grpc_core::MessageSizeParsedConfig::message_size_limits limits; grpc_core::RefCountedPtr svc_cfg; }; @@ -119,21 +119,21 @@ struct call_data { // Note: Per-method config is only available on the client, so we // apply the max request size to the send limit and the max response // size to the receive limit. - const grpc_core::MessageSizeParsedObject* limits = nullptr; + const grpc_core::MessageSizeParsedConfig* limits = nullptr; grpc_core::ServiceConfig::CallData* svc_cfg_call_data = nullptr; if (args.context != nullptr) { svc_cfg_call_data = static_cast( - args.context[GRPC_SERVICE_CONFIG_CALL_DATA].value); + args.context[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA].value); } if (svc_cfg_call_data != nullptr) { - limits = static_cast( - svc_cfg_call_data->GetMethodParsedObject( + limits = static_cast( + svc_cfg_call_data->GetMethodParsedConfig( grpc_core::MessageSizeParser::ParserIndex())); } else if (chand.svc_cfg != nullptr) { const auto* objs_vector = - chand.svc_cfg->GetMethodServiceConfigObjectsVector(args.path); + chand.svc_cfg->GetMethodParsedConfigVector(args.path); if (objs_vector != nullptr) { - limits = static_cast( + limits = static_cast( (*objs_vector)[grpc_core::MessageSizeParser::ParserIndex()].get()); } } @@ -154,7 +154,7 @@ struct call_data { ~call_data() { GRPC_ERROR_UNREF(error); } grpc_core::CallCombiner* call_combiner; - grpc_core::MessageSizeParsedObject::message_size_limits limits; + grpc_core::MessageSizeParsedConfig::message_size_limits limits; // Receive closures are chained: we inject this closure as the // recv_message_ready up-call on transport_stream_op, and remember to // call our next_recv_message_ready member after handling it. @@ -300,9 +300,9 @@ static int default_size(const grpc_channel_args* args, return without_minimal_stack; } -grpc_core::MessageSizeParsedObject::message_size_limits get_message_size_limits( +grpc_core::MessageSizeParsedConfig::message_size_limits get_message_size_limits( const grpc_channel_args* channel_args) { - grpc_core::MessageSizeParsedObject::message_size_limits lim; + grpc_core::MessageSizeParsedConfig::message_size_limits lim; lim.max_send_size = default_size(channel_args, GRPC_DEFAULT_MAX_SEND_MESSAGE_LENGTH); lim.max_recv_size = @@ -392,7 +392,7 @@ static bool maybe_add_message_size_filter(grpc_channel_stack_builder* builder, const grpc_channel_args* channel_args = grpc_channel_stack_builder_get_channel_arguments(builder); bool enable = false; - grpc_core::MessageSizeParsedObject::message_size_limits lim = + grpc_core::MessageSizeParsedConfig::message_size_limits lim = get_message_size_limits(channel_args); if (lim.max_send_size != -1 || lim.max_recv_size != -1) { enable = true; diff --git a/src/core/ext/filters/message_size/message_size_filter.h b/src/core/ext/filters/message_size/message_size_filter.h index cab8bd9627f..1dde55f40b1 100644 --- a/src/core/ext/filters/message_size/message_size_filter.h +++ b/src/core/ext/filters/message_size/message_size_filter.h @@ -26,14 +26,14 @@ extern const grpc_channel_filter grpc_message_size_filter; namespace grpc_core { -class MessageSizeParsedObject : public ServiceConfig::ParsedConfig { +class MessageSizeParsedConfig : public ServiceConfig::ParsedConfig { public: struct message_size_limits { int max_send_size; int max_recv_size; }; - MessageSizeParsedObject(int max_send_size, int max_recv_size) { + MessageSizeParsedConfig(int max_send_size, int max_recv_size) { limits_.max_send_size = max_send_size; limits_.max_recv_size = max_recv_size; } diff --git a/src/core/lib/channel/context.h b/src/core/lib/channel/context.h index fd9d0ce711a..e8a024547f6 100644 --- a/src/core/lib/channel/context.h +++ b/src/core/lib/channel/context.h @@ -36,7 +36,7 @@ typedef enum { GRPC_CONTEXT_TRAFFIC, /// Holds a pointer to ServiceConfig::CallData associated with this call. - GRPC_SERVICE_CONFIG_CALL_DATA, + GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA, GRPC_CONTEXT_COUNT } grpc_context_index; diff --git a/test/core/client_channel/service_config_test.cc b/test/core/client_channel/service_config_test.cc index 9734304c9ac..919441d706a 100644 --- a/test/core/client_channel/service_config_test.cc +++ b/test/core/client_channel/service_config_test.cc @@ -31,9 +31,9 @@ namespace grpc_core { namespace testing { -class TestParsedObject1 : public ServiceConfig::ParsedConfig { +class TestParsedConfig1 : public ServiceConfig::ParsedConfig { public: - TestParsedObject1(int value) : value_(value) {} + TestParsedConfig1(int value) : value_(value) {} int value() const { return value_; } @@ -61,7 +61,7 @@ class TestParser1 : public ServiceConfig::Parser { return nullptr; } return UniquePtr( - New(value)); + New(value)); } } return nullptr; @@ -99,7 +99,7 @@ class TestParser2 : public ServiceConfig::Parser { return nullptr; } return UniquePtr( - New(value)); + New(value)); } } return nullptr; @@ -216,10 +216,10 @@ TEST_F(ServiceConfigTest, Parser1BasicTest1) { grpc_error* error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(test_json, &error); ASSERT_TRUE(error == GRPC_ERROR_NONE); - EXPECT_TRUE((static_cast( - svc_cfg->GetParsedGlobalServiceConfigObject(0))) - ->value() == 5); - EXPECT_TRUE(svc_cfg->GetMethodServiceConfigObjectsVector( + EXPECT_TRUE( + (static_cast(svc_cfg->GetGlobalParsedConfig(0))) + ->value() == 5); + EXPECT_TRUE(svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")) == nullptr); } @@ -229,9 +229,9 @@ TEST_F(ServiceConfigTest, Parser1BasicTest2) { grpc_error* error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(test_json, &error); ASSERT_TRUE(error == GRPC_ERROR_NONE); - EXPECT_TRUE((static_cast( - svc_cfg->GetParsedGlobalServiceConfigObject(0))) - ->value() == 1000); + EXPECT_TRUE( + (static_cast(svc_cfg->GetGlobalParsedConfig(0))) + ->value() == 1000); } TEST_F(ServiceConfigTest, Parser1ErrorInvalidType) { @@ -267,11 +267,11 @@ TEST_F(ServiceConfigTest, Parser2BasicTest) { grpc_error* error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(test_json, &error); ASSERT_TRUE(error == GRPC_ERROR_NONE); - const auto* vector_ptr = svc_cfg->GetMethodServiceConfigObjectsVector( + const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); EXPECT_TRUE(vector_ptr != nullptr); - auto parsed_object = ((*vector_ptr)[1]).get(); - EXPECT_TRUE(static_cast(parsed_object)->value() == 5); + auto parsed_config = ((*vector_ptr)[1]).get(); + EXPECT_TRUE(static_cast(parsed_config)->value() == 5); } TEST_F(ServiceConfigTest, Parser2ErrorInvalidType) { @@ -371,10 +371,10 @@ TEST_F(ClientChannelParserTest, ValidLoadBalancingConfigPickFirst) { grpc_error* error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(test_json, &error); ASSERT_TRUE(error == GRPC_ERROR_NONE); - const auto* parsed_object = - static_cast( - svc_cfg->GetParsedGlobalServiceConfigObject(0)); - auto lb_config = parsed_object->parsed_lb_config(); + const auto* parsed_config = + static_cast( + svc_cfg->GetGlobalParsedConfig(0)); + auto lb_config = parsed_config->parsed_lb_config(); EXPECT_TRUE(strcmp(lb_config->name(), "pick_first") == 0); } @@ -384,10 +384,10 @@ TEST_F(ClientChannelParserTest, ValidLoadBalancingConfigRoundRobin) { grpc_error* error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(test_json, &error); ASSERT_TRUE(error == GRPC_ERROR_NONE); - auto parsed_object = - static_cast( - svc_cfg->GetParsedGlobalServiceConfigObject(0)); - auto lb_config = parsed_object->parsed_lb_config(); + auto parsed_config = + static_cast( + svc_cfg->GetGlobalParsedConfig(0)); + auto lb_config = parsed_config->parsed_lb_config(); EXPECT_TRUE(strcmp(lb_config->name(), "round_robin") == 0); } @@ -398,10 +398,10 @@ TEST_F(ClientChannelParserTest, ValidLoadBalancingConfigGrpclb) { grpc_error* error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(test_json, &error); ASSERT_TRUE(error == GRPC_ERROR_NONE); - const auto* parsed_object = - static_cast( - svc_cfg->GetParsedGlobalServiceConfigObject(0)); - auto lb_config = parsed_object->parsed_lb_config(); + const auto* parsed_config = + static_cast( + svc_cfg->GetGlobalParsedConfig(0)); + auto lb_config = parsed_config->parsed_lb_config(); EXPECT_TRUE(strcmp(lb_config->name(), "grpclb") == 0); } @@ -417,10 +417,10 @@ TEST_F(ClientChannelParserTest, ValidLoadBalancingConfigXds) { auto svc_cfg = ServiceConfig::Create(test_json, &error); gpr_log(GPR_ERROR, "%s", grpc_error_string(error)); ASSERT_TRUE(error == GRPC_ERROR_NONE); - const auto* parsed_object = - static_cast( - svc_cfg->GetParsedGlobalServiceConfigObject(0)); - auto lb_config = parsed_object->parsed_lb_config(); + const auto* parsed_config = + static_cast( + svc_cfg->GetGlobalParsedConfig(0)); + auto lb_config = parsed_config->parsed_lb_config(); EXPECT_TRUE(strcmp(lb_config->name(), "xds_experimental") == 0); } @@ -484,10 +484,10 @@ TEST_F(ClientChannelParserTest, ValidLoadBalancingPolicy) { grpc_error* error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(test_json, &error); ASSERT_TRUE(error == GRPC_ERROR_NONE); - const auto* parsed_object = - static_cast( - svc_cfg->GetParsedGlobalServiceConfigObject(0)); - const auto* lb_policy = parsed_object->parsed_deprecated_lb_policy(); + const auto* parsed_config = + static_cast( + svc_cfg->GetGlobalParsedConfig(0)); + const auto* lb_policy = parsed_config->parsed_deprecated_lb_policy(); ASSERT_TRUE(lb_policy != nullptr); EXPECT_TRUE(strcmp(lb_policy, "pick_first") == 0); } @@ -498,10 +498,10 @@ TEST_F(ClientChannelParserTest, ValidLoadBalancingPolicyAllCaps) { auto svc_cfg = ServiceConfig::Create(test_json, &error); gpr_log(GPR_ERROR, "%s", grpc_error_string(error)); ASSERT_TRUE(error == GRPC_ERROR_NONE); - const auto* parsed_object = - static_cast( - svc_cfg->GetParsedGlobalServiceConfigObject(0)); - const auto* lb_policy = parsed_object->parsed_deprecated_lb_policy(); + const auto* parsed_config = + static_cast( + svc_cfg->GetGlobalParsedConfig(0)); + const auto* lb_policy = parsed_config->parsed_deprecated_lb_policy(); ASSERT_TRUE(lb_policy != nullptr); EXPECT_TRUE(strcmp(lb_policy, "pick_first") == 0); } @@ -549,10 +549,10 @@ TEST_F(ClientChannelParserTest, ValidRetryThrottling) { auto svc_cfg = ServiceConfig::Create(test_json, &error); gpr_log(GPR_ERROR, "%s", grpc_error_string(error)); ASSERT_TRUE(error == GRPC_ERROR_NONE); - const auto* parsed_object = - static_cast( - svc_cfg->GetParsedGlobalServiceConfigObject(0)); - const auto retryThrottling = parsed_object->retry_throttling(); + const auto* parsed_config = + static_cast( + svc_cfg->GetGlobalParsedConfig(0)); + const auto retryThrottling = parsed_config->retry_throttling(); ASSERT_TRUE(retryThrottling.has_value()); EXPECT_EQ(retryThrottling.value().max_milli_tokens, 2000); EXPECT_EQ(retryThrottling.value().milli_token_ratio, 1000); @@ -633,12 +633,12 @@ TEST_F(ClientChannelParserTest, ValidTimeout) { grpc_error* error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(test_json, &error); ASSERT_TRUE(error == GRPC_ERROR_NONE); - const auto* vector_ptr = svc_cfg->GetMethodServiceConfigObjectsVector( + const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); EXPECT_TRUE(vector_ptr != nullptr); - auto parsed_object = ((*vector_ptr)[0]).get(); - EXPECT_EQ((static_cast( - parsed_object)) + auto parsed_config = ((*vector_ptr)[0]).get(); + EXPECT_EQ((static_cast( + parsed_config)) ->timeout(), 5000); } @@ -680,18 +680,18 @@ TEST_F(ClientChannelParserTest, ValidWaitForReady) { grpc_error* error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(test_json, &error); ASSERT_TRUE(error == GRPC_ERROR_NONE); - const auto* vector_ptr = svc_cfg->GetMethodServiceConfigObjectsVector( + const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); EXPECT_TRUE(vector_ptr != nullptr); - auto parsed_object = ((*vector_ptr)[0]).get(); + auto parsed_config = ((*vector_ptr)[0]).get(); EXPECT_TRUE( - (static_cast( - parsed_object)) + (static_cast( + parsed_config)) ->wait_for_ready() .has_value()); EXPECT_TRUE( - (static_cast( - parsed_object)) + (static_cast( + parsed_config)) ->wait_for_ready() .value()); } @@ -740,18 +740,18 @@ TEST_F(ClientChannelParserTest, ValidRetryPolicy) { auto svc_cfg = ServiceConfig::Create(test_json, &error); gpr_log(GPR_ERROR, "%s", grpc_error_string(error)); ASSERT_TRUE(error == GRPC_ERROR_NONE); - const auto* vector_ptr = svc_cfg->GetMethodServiceConfigObjectsVector( + const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); EXPECT_TRUE(vector_ptr != nullptr); - const auto* parsed_object = - static_cast( + const auto* parsed_config = + static_cast( ((*vector_ptr)[0]).get()); - EXPECT_TRUE(parsed_object->retry_policy() != nullptr); - EXPECT_EQ(parsed_object->retry_policy()->max_attempts, 3); - EXPECT_EQ(parsed_object->retry_policy()->initial_backoff, 1000); - EXPECT_EQ(parsed_object->retry_policy()->max_backoff, 120000); - EXPECT_EQ(parsed_object->retry_policy()->backoff_multiplier, 1.6f); - EXPECT_TRUE(parsed_object->retry_policy()->retryable_status_codes.Contains( + EXPECT_TRUE(parsed_config->retry_policy() != nullptr); + EXPECT_EQ(parsed_config->retry_policy()->max_attempts, 3); + EXPECT_EQ(parsed_config->retry_policy()->initial_backoff, 1000); + EXPECT_EQ(parsed_config->retry_policy()->max_backoff, 120000); + EXPECT_EQ(parsed_config->retry_policy()->backoff_multiplier, 1.6f); + EXPECT_TRUE(parsed_config->retry_policy()->retryable_status_codes.Contains( GRPC_STATUS_ABORTED)); } @@ -915,11 +915,11 @@ TEST_F(ClientChannelParserTest, ValidHealthCheck) { grpc_error* error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(test_json, &error); ASSERT_TRUE(error == GRPC_ERROR_NONE); - const auto* parsed_object = - static_cast( - svc_cfg->GetParsedGlobalServiceConfigObject(0)); - ASSERT_TRUE(parsed_object != nullptr); - EXPECT_EQ(strcmp(parsed_object->health_check_service_name(), + const auto* parsed_config = + static_cast( + svc_cfg->GetGlobalParsedConfig(0)); + ASSERT_TRUE(parsed_config != nullptr); + EXPECT_EQ(strcmp(parsed_config->health_check_service_name(), "health_check_service_name"), 0); } @@ -974,14 +974,14 @@ TEST_F(MessageSizeParserTest, Valid) { auto svc_cfg = ServiceConfig::Create(test_json, &error); gpr_log(GPR_ERROR, "%s", grpc_error_string(error)); ASSERT_TRUE(error == GRPC_ERROR_NONE); - const auto* vector_ptr = svc_cfg->GetMethodServiceConfigObjectsVector( + const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); EXPECT_TRUE(vector_ptr != nullptr); - auto parsed_object = - static_cast(((*vector_ptr)[0]).get()); - ASSERT_TRUE(parsed_object != nullptr); - EXPECT_EQ(parsed_object->limits().max_send_size, 1024); - EXPECT_EQ(parsed_object->limits().max_recv_size, 1024); + auto parsed_config = + static_cast(((*vector_ptr)[0]).get()); + ASSERT_TRUE(parsed_config != nullptr); + EXPECT_EQ(parsed_config->limits().max_send_size, 1024); + EXPECT_EQ(parsed_config->limits().max_recv_size, 1024); } TEST_F(MessageSizeParserTest, InvalidMaxRequestMessageBytes) { From d2876cc6b6a67e02163d258e33faf9ff53f0bcef Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 10 May 2019 10:40:01 -0700 Subject: [PATCH 0216/1555] Fix Windows vs libuv platform detection in cares code --- .../resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc | 2 +- src/core/lib/iomgr/port.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc index ce39007f905..85f5cd84ca0 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc @@ -18,7 +18,7 @@ #include #include "src/core/lib/iomgr/port.h" -#if GRPC_ARES == 1 && defined(GPR_WINDOWS) +#if GRPC_ARES == 1 && defined(GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER) #include diff --git a/src/core/lib/iomgr/port.h b/src/core/lib/iomgr/port.h index d387de5b13c..0b3681868f7 100644 --- a/src/core/lib/iomgr/port.h +++ b/src/core/lib/iomgr/port.h @@ -44,6 +44,7 @@ #elif defined(GPR_WINDOWS) #define GRPC_WINSOCK_SOCKET 1 #define GRPC_WINDOWS_SOCKETUTILS 1 +#define GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER #elif defined(GPR_ANDROID) #define GRPC_HAVE_IPV6_RECVPKTINFO 1 #define GRPC_HAVE_IP_PKTINFO 1 From 710cbb02e6bdbd2efea0b63ec8ac34ebea27a0ca Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 10 May 2019 11:15:12 -0700 Subject: [PATCH 0217/1555] libuv cares: scope manual localhost resolution to only Windows --- BUILD | 4 +- BUILD.gn | 4 +- CMakeLists.txt | 4 + Makefile | 4 + build.yaml | 4 +- config.m4 | 2 + config.w32 | 2 + gRPC-C++.podspec | 2 +- gRPC-Core.podspec | 6 +- grpc.gemspec | 4 +- grpc.gyp | 4 + package.xml | 4 +- .../dns/c_ares/grpc_ares_wrapper_libuv.cc | 19 ----- .../grpc_ares_wrapper_libuv_nonwindows.cc | 39 +++++++++ .../c_ares/grpc_ares_wrapper_libuv_windows.cc | 64 +++----------- .../dns/c_ares/grpc_ares_wrapper_windows.cc | 4 +- .../c_ares/grpc_ares_wrapper_windows_inner.cc | 83 +++++++++++++++++++ ...ws.h => grpc_ares_wrapper_windows_inner.h} | 0 src/python/grpcio/grpc_core_dependencies.py | 2 + tools/doxygen/Doxyfile.core.internal | 4 +- .../generated/sources_and_headers.json | 10 ++- 21 files changed, 184 insertions(+), 85 deletions(-) create mode 100644 src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc create mode 100644 src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc rename src/core/ext/filters/client_channel/resolver/dns/c_ares/{grpc_ares_wrapper_libuv_windows.h => grpc_ares_wrapper_windows_inner.h} (100%) diff --git a/BUILD b/BUILD index b066f384ca0..dafe1031e17 100644 --- a/BUILD +++ b/BUILD @@ -1600,13 +1600,15 @@ grpc_cc_library( "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc", ], hdrs = [ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h", ], external_deps = [ "cares", diff --git a/BUILD.gn b/BUILD.gn index 47b2747065d..be43b5e4217 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -318,14 +318,16 @@ config("grpc_config") { "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc", "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc", "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h", "src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc", diff --git a/CMakeLists.txt b/CMakeLists.txt index f0c14873d76..eed7ac07e0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1299,9 +1299,11 @@ add_library(grpc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc @@ -2696,9 +2698,11 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc diff --git a/Makefile b/Makefile index b68529b5b0f..29828e60fe2 100644 --- a/Makefile +++ b/Makefile @@ -3771,9 +3771,11 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ @@ -5116,9 +5118,11 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ diff --git a/build.yaml b/build.yaml index 3b40102a675..91f9b671d29 100644 --- a/build.yaml +++ b/build.yaml @@ -779,8 +779,8 @@ filegroups: - name: grpc_resolver_dns_ares headers: - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h + - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h - - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h src: - src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc @@ -790,9 +790,11 @@ filegroups: - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc + - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc + - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc plugin: grpc_resolver_dns_ares uses: - grpc_base diff --git a/config.m4 b/config.m4 index d90a8e94e6d..2f512cc8400 100644 --- a/config.m4 +++ b/config.m4 @@ -409,9 +409,11 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ + src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ diff --git a/config.w32 b/config.w32 index 70ac245d9fa..d4943e8893e 100644 --- a/config.w32 +++ b/config.w32 @@ -384,9 +384,11 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_fallback.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_libuv.cc " + + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_libuv_nonwindows.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_libuv_windows.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_posix.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_windows.cc " + + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_windows_inner.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\dns_resolver_selection.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\native\\dns_resolver.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\sockaddr\\sockaddr_resolver.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 6f445a71929..c969446a957 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -561,8 +561,8 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 3df5539e9fe..850d7b5c387 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -537,8 +537,8 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', @@ -867,9 +867,11 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', @@ -1190,8 +1192,8 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', diff --git a/grpc.gemspec b/grpc.gemspec index 6e229a5ab71..d13b007c395 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -471,8 +471,8 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/subchannel_list.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h ) + s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h ) - s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h ) s.files += %w( src/core/ext/filters/max_age/max_age_filter.h ) s.files += %w( src/core/ext/filters/message_size/message_size_filter.h ) @@ -804,9 +804,11 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc ) + s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc ) + s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc ) diff --git a/grpc.gyp b/grpc.gyp index 833a0b48715..5b7bf481dd2 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -591,9 +591,11 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', @@ -1352,9 +1354,11 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', diff --git a/package.xml b/package.xml index e0587098a66..7f9a7888f90 100644 --- a/package.xml +++ b/package.xml @@ -476,8 +476,8 @@ + - @@ -809,9 +809,11 @@ + + diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc index fdbb8969a1f..252fba916ff 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc @@ -23,13 +23,6 @@ #include -#include "src/core/ext/filters/client_channel/parse_address.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h" -#include "src/core/ext/filters/client_channel/server_address.h" -#include "src/core/lib/gpr/host_port.h" -#include "src/core/lib/gpr/string.h" - bool grpc_ares_query_ipv6() { /* The libuv grpc code currently does not have the code to probe for this, * so we assume for now that IPv6 is always available in contexts where this @@ -37,16 +30,4 @@ bool grpc_ares_query_ipv6() { return true; } -bool grpc_ares_maybe_resolve_localhost_manually_locked( - const char* name, const char* default_port, - grpc_core::UniquePtr* addrs) { - char* host = nullptr; - char* port = nullptr; - bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port, - addrs, &host, &port); - gpr_free(host); - gpr_free(port); - return out; -} - #endif /* GRPC_ARES == 1 && defined(GRPC_UV) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc new file mode 100644 index 00000000000..dc8d051e2af --- /dev/null +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc @@ -0,0 +1,39 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/iomgr/port.h" +#if GRPC_ARES == 1 && defined(GRPC_UV) && !defined(GPR_WINDOWS) + +#include + +#include "src/core/ext/filters/client_channel/parse_address.h" +#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" +#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" +#include "src/core/ext/filters/client_channel/server_address.h" +#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gpr/string.h" + +bool grpc_ares_maybe_resolve_localhost_manually_locked( + const char* name, const char* default_port, + grpc_core::UniquePtr* addrs) { + return false; +} + +#endif /* GRPC_ARES == 1 && defined(GRPC_UV) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc index 1232fc9d57c..d4f3944fdc7 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2019 gRPC authors. + * Copyright 2016 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,65 +19,27 @@ #include #include "src/core/lib/iomgr/port.h" -#if GRPC_ARES == 1 && (defined(GRPC_UV) || defined(GPR_WINDOWS)) +#if GRPC_ARES == 1 && defined(GRPC_UV) && defined(GPR_WINDOWS) #include #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h" +#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -bool inner_maybe_resolve_localhost_manually_locked( +bool grpc_ares_maybe_resolve_localhost_manually_locked( const char* name, const char* default_port, - grpc_core::UniquePtr* addrs, char** host, - char** port) { - gpr_split_host_port(name, host, port); - if (*host == nullptr) { - gpr_log(GPR_ERROR, - "Failed to parse %s into host:port during manual localhost " - "resolution check.", - name); - return false; - } - if (*port == nullptr) { - if (default_port == nullptr) { - gpr_log(GPR_ERROR, - "No port or default port for %s during manual localhost " - "resolution check.", - name); - return false; - } - *port = gpr_strdup(default_port); - } - if (gpr_stricmp(*host, "localhost") == 0) { - GPR_ASSERT(*addrs == nullptr); - *addrs = grpc_core::MakeUnique(); - uint16_t numeric_port = grpc_strhtons(*port); - // Append the ipv6 loopback address. - struct sockaddr_in6 ipv6_loopback_addr; - memset(&ipv6_loopback_addr, 0, sizeof(ipv6_loopback_addr)); - ((char*)&ipv6_loopback_addr.sin6_addr)[15] = 1; - ipv6_loopback_addr.sin6_family = AF_INET6; - ipv6_loopback_addr.sin6_port = numeric_port; - (*addrs)->emplace_back(&ipv6_loopback_addr, sizeof(ipv6_loopback_addr), - nullptr /* args */); - // Append the ipv4 loopback address. - struct sockaddr_in ipv4_loopback_addr; - memset(&ipv4_loopback_addr, 0, sizeof(ipv4_loopback_addr)); - ((char*)&ipv4_loopback_addr.sin_addr)[0] = 0x7f; - ((char*)&ipv4_loopback_addr.sin_addr)[3] = 0x01; - ipv4_loopback_addr.sin_family = AF_INET; - ipv4_loopback_addr.sin_port = numeric_port; - (*addrs)->emplace_back(&ipv4_loopback_addr, sizeof(ipv4_loopback_addr), - nullptr /* args */); - // Let the address sorter figure out which one should be tried first. - grpc_cares_wrapper_address_sorting_sort(addrs->get()); - return true; - } - return false; + grpc_core::UniquePtr* addrs) { + char* host = nullptr; + char* port = nullptr; + bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port, + addrs, &host, &port); + gpr_free(host); + gpr_free(port); + return out; } -#endif /* GRPC_ARES == 1 && (defined(GRPC_UV) || defined(GPR_WINDOWS)) */ +#endif /* GRPC_ARES == 1 && defined(GRPC_UV) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc index 60398c6aedd..fcb47eb5b58 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc @@ -19,13 +19,13 @@ #include #include "src/core/lib/iomgr/port.h" -#if GRPC_ARES == 1 && defined(GPR_WINDOWS) +#if GRPC_ARES == 1 && defined(GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER) #include #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h" +#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc new file mode 100644 index 00000000000..ee37144eca7 --- /dev/null +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc @@ -0,0 +1,83 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/iomgr/port.h" +#if GRPC_ARES == 1 && (defined(GRPC_UV) || defined(GPR_WINDOWS)) + +#include + +#include "src/core/ext/filters/client_channel/parse_address.h" +#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" +#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" +#include "src/core/ext/filters/client_channel/server_address.h" +#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gpr/string.h" + +bool inner_maybe_resolve_localhost_manually_locked( + const char* name, const char* default_port, + grpc_core::UniquePtr* addrs, char** host, + char** port) { + gpr_split_host_port(name, host, port); + if (*host == nullptr) { + gpr_log(GPR_ERROR, + "Failed to parse %s into host:port during manual localhost " + "resolution check.", + name); + return false; + } + if (*port == nullptr) { + if (default_port == nullptr) { + gpr_log(GPR_ERROR, + "No port or default port for %s during manual localhost " + "resolution check.", + name); + return false; + } + *port = gpr_strdup(default_port); + } + if (gpr_stricmp(*host, "localhost") == 0) { + GPR_ASSERT(*addrs == nullptr); + *addrs = grpc_core::MakeUnique(); + uint16_t numeric_port = grpc_strhtons(*port); + // Append the ipv6 loopback address. + struct sockaddr_in6 ipv6_loopback_addr; + memset(&ipv6_loopback_addr, 0, sizeof(ipv6_loopback_addr)); + ((char*)&ipv6_loopback_addr.sin6_addr)[15] = 1; + ipv6_loopback_addr.sin6_family = AF_INET6; + ipv6_loopback_addr.sin6_port = numeric_port; + (*addrs)->emplace_back(&ipv6_loopback_addr, sizeof(ipv6_loopback_addr), + nullptr /* args */); + // Append the ipv4 loopback address. + struct sockaddr_in ipv4_loopback_addr; + memset(&ipv4_loopback_addr, 0, sizeof(ipv4_loopback_addr)); + ((char*)&ipv4_loopback_addr.sin_addr)[0] = 0x7f; + ((char*)&ipv4_loopback_addr.sin_addr)[3] = 0x01; + ipv4_loopback_addr.sin_family = AF_INET; + ipv4_loopback_addr.sin_port = numeric_port; + (*addrs)->emplace_back(&ipv4_loopback_addr, sizeof(ipv4_loopback_addr), + nullptr /* args */); + // Let the address sorter figure out which one should be tried first. + grpc_cares_wrapper_address_sorting_sort(addrs->get()); + return true; + } + return false; +} + +#endif /* GRPC_ARES == 1 && (defined(GRPC_UV) || defined(GPR_WINDOWS)) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h similarity index 100% rename from src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h rename to src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 61524eb7fc9..db78061a63d 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -383,9 +383,11 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 293a6e1f9c1..4905bd365d0 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -945,14 +945,16 @@ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc \ +src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ +src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ -src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ +src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h \ src/core/ext/filters/client_channel/resolver/dns/native/README.md \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index de8015ac52a..b358e855c07 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -9178,8 +9178,8 @@ ], "headers": [ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h" + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" ], "is_filegroup": true, "language": "c", @@ -9191,14 +9191,16 @@ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc" + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc" ], "third_party": false, "type": "filegroup" From a0b32609ffcba5d4ac8bb042a7ae492aa493d926 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 10 May 2019 14:46:15 -0700 Subject: [PATCH 0218/1555] Moved code back into one file with a #ifdef --- BUILD | 2 - BUILD.gn | 2 - CMakeLists.txt | 4 -- Makefile | 4 -- build.yaml | 2 - config.m4 | 2 - config.w32 | 2 - gRPC-Core.podspec | 2 - grpc.gemspec | 2 - grpc.gyp | 4 -- package.xml | 2 - .../dns/c_ares/grpc_ares_wrapper_libuv.cc | 23 ++++++++++ .../grpc_ares_wrapper_libuv_nonwindows.cc | 39 ---------------- .../c_ares/grpc_ares_wrapper_libuv_windows.cc | 45 ------------------- .../dns/c_ares/grpc_ares_wrapper_windows.cc | 2 +- .../c_ares/grpc_ares_wrapper_windows_inner.cc | 4 +- src/core/lib/iomgr/port.h | 3 +- src/python/grpcio/grpc_core_dependencies.py | 2 - tools/doxygen/Doxyfile.core.internal | 2 - .../generated/sources_and_headers.json | 2 - 20 files changed, 28 insertions(+), 122 deletions(-) delete mode 100644 src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc delete mode 100644 src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc diff --git a/BUILD b/BUILD index dafe1031e17..03507cc1777 100644 --- a/BUILD +++ b/BUILD @@ -1599,8 +1599,6 @@ grpc_cc_library( "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc", diff --git a/BUILD.gn b/BUILD.gn index be43b5e4217..465e808b719 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -323,8 +323,6 @@ config("grpc_config") { "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc", diff --git a/CMakeLists.txt b/CMakeLists.txt index eed7ac07e0c..eb011f445c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1299,8 +1299,6 @@ add_library(grpc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc @@ -2698,8 +2696,6 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc diff --git a/Makefile b/Makefile index 29828e60fe2..98c3ce29f66 100644 --- a/Makefile +++ b/Makefile @@ -3771,8 +3771,6 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc \ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ @@ -5118,8 +5116,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc \ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ diff --git a/build.yaml b/build.yaml index 91f9b671d29..8f3f6ad929f 100644 --- a/build.yaml +++ b/build.yaml @@ -790,8 +790,6 @@ filegroups: - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc - - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc - - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc diff --git a/config.m4 b/config.m4 index 2f512cc8400..f29cb0c705b 100644 --- a/config.m4 +++ b/config.m4 @@ -409,8 +409,6 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc \ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ diff --git a/config.w32 b/config.w32 index d4943e8893e..4f0225974f7 100644 --- a/config.w32 +++ b/config.w32 @@ -384,8 +384,6 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_fallback.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_libuv.cc " + - "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_libuv_nonwindows.cc " + - "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_libuv_windows.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_posix.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_windows.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_windows_inner.cc " + diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 850d7b5c387..57f1db47edb 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -867,8 +867,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', diff --git a/grpc.gemspec b/grpc.gemspec index d13b007c395..aedcf57573b 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -804,8 +804,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc ) - s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc ) - s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc ) diff --git a/grpc.gyp b/grpc.gyp index 5b7bf481dd2..5feaabd456d 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -591,8 +591,6 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', @@ -1354,8 +1352,6 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', diff --git a/package.xml b/package.xml index 7f9a7888f90..273274acaaf 100644 --- a/package.xml +++ b/package.xml @@ -809,8 +809,6 @@ - - diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc index 252fba916ff..eb0b3dab4a4 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc @@ -23,6 +23,13 @@ #include +#include "src/core/ext/filters/client_channel/parse_address.h" +#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" +#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" +#include "src/core/ext/filters/client_channel/server_address.h" +#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gpr/string.h" + bool grpc_ares_query_ipv6() { /* The libuv grpc code currently does not have the code to probe for this, * so we assume for now that IPv6 is always available in contexts where this @@ -30,4 +37,20 @@ bool grpc_ares_query_ipv6() { return true; } +bool grpc_ares_maybe_resolve_localhost_manually_locked( + const char* name, const char* default_port, + grpc_core::UniquePtr* addrs) { +#ifdef GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY + char* host = nullptr; + char* port = nullptr; + bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port, + addrs, &host, &port); + gpr_free(host); + gpr_free(port); + return out; +#else /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ + return false; +#endif /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ +} + #endif /* GRPC_ARES == 1 && defined(GRPC_UV) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc deleted file mode 100644 index dc8d051e2af..00000000000 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/lib/iomgr/port.h" -#if GRPC_ARES == 1 && defined(GRPC_UV) && !defined(GPR_WINDOWS) - -#include - -#include "src/core/ext/filters/client_channel/parse_address.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" -#include "src/core/ext/filters/client_channel/server_address.h" -#include "src/core/lib/gpr/host_port.h" -#include "src/core/lib/gpr/string.h" - -bool grpc_ares_maybe_resolve_localhost_manually_locked( - const char* name, const char* default_port, - grpc_core::UniquePtr* addrs) { - return false; -} - -#endif /* GRPC_ARES == 1 && defined(GRPC_UV) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc deleted file mode 100644 index d4f3944fdc7..00000000000 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/lib/iomgr/port.h" -#if GRPC_ARES == 1 && defined(GRPC_UV) && defined(GPR_WINDOWS) - -#include - -#include "src/core/ext/filters/client_channel/parse_address.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" -#include "src/core/ext/filters/client_channel/server_address.h" -#include "src/core/lib/gpr/host_port.h" -#include "src/core/lib/gpr/string.h" - -bool grpc_ares_maybe_resolve_localhost_manually_locked( - const char* name, const char* default_port, - grpc_core::UniquePtr* addrs) { - char* host = nullptr; - char* port = nullptr; - bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port, - addrs, &host, &port); - gpr_free(host); - gpr_free(port); - return out; -} - -#endif /* GRPC_ARES == 1 && defined(GRPC_UV) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc index fcb47eb5b58..e48f9501752 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc @@ -45,4 +45,4 @@ bool grpc_ares_maybe_resolve_localhost_manually_locked( return out; } -#endif /* GRPC_ARES == 1 && defined(GPR_WINDOWS) */ +#endif /* GRPC_ARES == 1 && defined(GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc index ee37144eca7..1331a6a67f5 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc @@ -19,7 +19,7 @@ #include #include "src/core/lib/iomgr/port.h" -#if GRPC_ARES == 1 && (defined(GRPC_UV) || defined(GPR_WINDOWS)) +#if GRPC_ARES == 1 && defined(GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY) #include @@ -80,4 +80,4 @@ bool inner_maybe_resolve_localhost_manually_locked( return false; } -#endif /* GRPC_ARES == 1 && (defined(GRPC_UV) || defined(GPR_WINDOWS)) */ +#endif /* GRPC_ARES == 1 && defined(GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY) */ diff --git a/src/core/lib/iomgr/port.h b/src/core/lib/iomgr/port.h index 0b3681868f7..605692ac0d6 100644 --- a/src/core/lib/iomgr/port.h +++ b/src/core/lib/iomgr/port.h @@ -44,7 +44,8 @@ #elif defined(GPR_WINDOWS) #define GRPC_WINSOCK_SOCKET 1 #define GRPC_WINDOWS_SOCKETUTILS 1 -#define GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER +#define GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER 1 +#define GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY 1 #elif defined(GPR_ANDROID) #define GRPC_HAVE_IPV6_RECVPKTINFO 1 #define GRPC_HAVE_IP_PKTINFO 1 diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index db78061a63d..c9217aded63 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -383,8 +383,6 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 4905bd365d0..765abbebd42 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -950,8 +950,6 @@ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ -src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc \ -src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index b358e855c07..512c2d51d48 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -9196,8 +9196,6 @@ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_nonwindows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv_windows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc" From e2571a708f28c780c15bd5669b0021cb1c004b2a Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 10 May 2019 15:43:04 -0700 Subject: [PATCH 0219/1555] Fix sanity --- .../resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h index ed40e58f7cc..783b781154c 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h @@ -16,8 +16,8 @@ * */ -#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_LIBUV_WINDOWS_H -#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_LIBUV_WINDOWS_H +#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_WINDOWS_INNER_H +#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_WINDOWS_INNER_H #include @@ -30,5 +30,5 @@ bool inner_maybe_resolve_localhost_manually_locked( grpc_core::UniquePtr* addrs, char** host, char** port); -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_LIBUV_WINDOWS_H \ +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_WINDOWS_INNER_H \ */ From 718d0ac621596861d677bf5428b2484409dec37a Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 10 May 2019 15:53:45 -0700 Subject: [PATCH 0220/1555] Fix typo --- BUILD.gn | 2 +- build.yaml | 2 +- gRPC-C++.podspec | 2 +- gRPC-Core.podspec | 4 ++-- grpc.gemspec | 2 +- package.xml | 2 +- tools/doxygen/Doxyfile.core.internal | 2 +- tools/run_tests/generated/sources_and_headers.json | 8 ++++---- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 465e808b719..7357d0f9595 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -318,7 +318,6 @@ config("grpc_config") { "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", @@ -326,6 +325,7 @@ config("grpc_config") { "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h", "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc", "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h", "src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc", diff --git a/build.yaml b/build.yaml index 8f3f6ad929f..f6ce3d79ae8 100644 --- a/build.yaml +++ b/build.yaml @@ -779,8 +779,8 @@ filegroups: - name: grpc_resolver_dns_ares headers: - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h - - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h + - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h src: - src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index c969446a957..22cb70b80a3 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -561,8 +561,8 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 57f1db47edb..7338b01099f 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -537,8 +537,8 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', @@ -1190,8 +1190,8 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', + 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', diff --git a/grpc.gemspec b/grpc.gemspec index aedcf57573b..b0ea43b9d92 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -471,8 +471,8 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/subchannel_list.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h ) - s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h ) + s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h ) s.files += %w( src/core/ext/filters/max_age/max_age_filter.h ) s.files += %w( src/core/ext/filters/message_size/message_size_filter.h ) diff --git a/package.xml b/package.xml index 273274acaaf..560b422d94d 100644 --- a/package.xml +++ b/package.xml @@ -476,8 +476,8 @@ - + diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 765abbebd42..483e639be66 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -945,7 +945,6 @@ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc \ -src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ @@ -953,6 +952,7 @@ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv. src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ +src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h \ src/core/ext/filters/client_channel/resolver/dns/native/README.md \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 512c2d51d48..de08e38a838 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -9178,8 +9178,8 @@ ], "headers": [ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" ], "is_filegroup": true, "language": "c", @@ -9191,14 +9191,14 @@ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrappe_windows_inner.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc" + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc", + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" ], "third_party": false, "type": "filegroup" From 4242c85bed501bac246eeca814429b163a37d125 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Tue, 14 May 2019 15:26:56 -0700 Subject: [PATCH 0221/1555] Consolidate conditional localhost resolution into existing file --- BUILD | 2 - BUILD.gn | 2 - CMakeLists.txt | 2 - Makefile | 2 - build.yaml | 2 - config.m4 | 1 - config.w32 | 1 - gRPC-C++.podspec | 1 - gRPC-Core.podspec | 3 - grpc.gemspec | 2 - grpc.gyp | 2 - package.xml | 2 - .../resolver/dns/c_ares/grpc_ares_wrapper.cc | 68 +++++++++++++++ .../resolver/dns/c_ares/grpc_ares_wrapper.h | 8 -- .../dns/c_ares/grpc_ares_wrapper_libuv.cc | 17 ---- .../dns/c_ares/grpc_ares_wrapper_posix.cc | 6 -- .../dns/c_ares/grpc_ares_wrapper_windows.cc | 13 --- .../c_ares/grpc_ares_wrapper_windows_inner.cc | 83 ------------------- .../c_ares/grpc_ares_wrapper_windows_inner.h | 34 -------- src/python/grpcio/grpc_core_dependencies.py | 1 - tools/doxygen/Doxyfile.core.internal | 2 - .../generated/sources_and_headers.json | 7 +- 22 files changed, 70 insertions(+), 191 deletions(-) delete mode 100644 src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc delete mode 100644 src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h diff --git a/BUILD b/BUILD index 03507cc1777..2cffca4ffc2 100644 --- a/BUILD +++ b/BUILD @@ -1601,12 +1601,10 @@ grpc_cc_library( "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc", ], hdrs = [ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h", ], external_deps = [ "cares", diff --git a/BUILD.gn b/BUILD.gn index 7357d0f9595..d3c1186f7a6 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -324,8 +324,6 @@ config("grpc_config") { "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h", "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc", "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h", "src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc", diff --git a/CMakeLists.txt b/CMakeLists.txt index eb011f445c1..7457016c3cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1301,7 +1301,6 @@ add_library(grpc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc @@ -2698,7 +2697,6 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc diff --git a/Makefile b/Makefile index 98c3ce29f66..99238d17428 100644 --- a/Makefile +++ b/Makefile @@ -3773,7 +3773,6 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ @@ -5118,7 +5117,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ diff --git a/build.yaml b/build.yaml index f6ce3d79ae8..25f80af37e2 100644 --- a/build.yaml +++ b/build.yaml @@ -780,7 +780,6 @@ filegroups: headers: - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h - - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h src: - src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc @@ -792,7 +791,6 @@ filegroups: - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc - - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc plugin: grpc_resolver_dns_ares uses: - grpc_base diff --git a/config.m4 b/config.m4 index f29cb0c705b..bb30be56910 100644 --- a/config.m4 +++ b/config.m4 @@ -411,7 +411,6 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ diff --git a/config.w32 b/config.w32 index 4f0225974f7..c9faa8d9ac8 100644 --- a/config.w32 +++ b/config.w32 @@ -386,7 +386,6 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_libuv.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_posix.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_windows.cc " + - "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_windows_inner.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\dns_resolver_selection.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\native\\dns_resolver.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\sockaddr\\sockaddr_resolver.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 22cb70b80a3..3f42684be03 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -562,7 +562,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 7338b01099f..6d369950b09 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -538,7 +538,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', @@ -869,7 +868,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', @@ -1191,7 +1189,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', diff --git a/grpc.gemspec b/grpc.gemspec index b0ea43b9d92..5a34687b4d9 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -472,7 +472,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/lb_policy/subchannel_list.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h ) - s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h ) s.files += %w( src/core/ext/filters/max_age/max_age_filter.h ) s.files += %w( src/core/ext/filters/message_size/message_size_filter.h ) @@ -806,7 +805,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc ) - s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc ) diff --git a/grpc.gyp b/grpc.gyp index 5feaabd456d..1cc6e46b4be 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -593,7 +593,6 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', @@ -1354,7 +1353,6 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', diff --git a/package.xml b/package.xml index 560b422d94d..7ced9e795f8 100644 --- a/package.xml +++ b/package.xml @@ -477,7 +477,6 @@ - @@ -811,7 +810,6 @@ - diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc index 0f04f14fd8a..86a9bb30cb4 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc @@ -522,6 +522,74 @@ static bool target_matches_localhost(const char* name) { return out; } +#ifdef GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY +static bool inner_maybe_resolve_localhost_manually_locked( + const char* name, const char* default_port, + grpc_core::UniquePtr* addrs, char** host, + char** port) { + gpr_split_host_port(name, host, port); + if (*host == nullptr) { + gpr_log(GPR_ERROR, + "Failed to parse %s into host:port during manual localhost " + "resolution check.", + name); + return false; + } + if (*port == nullptr) { + if (default_port == nullptr) { + gpr_log(GPR_ERROR, + "No port or default port for %s during manual localhost " + "resolution check.", + name); + return false; + } + *port = gpr_strdup(default_port); + } + if (gpr_stricmp(*host, "localhost") == 0) { + GPR_ASSERT(*addrs == nullptr); + *addrs = grpc_core::MakeUnique(); + uint16_t numeric_port = grpc_strhtons(*port); + // Append the ipv6 loopback address. + struct sockaddr_in6 ipv6_loopback_addr; + memset(&ipv6_loopback_addr, 0, sizeof(ipv6_loopback_addr)); + ((char*)&ipv6_loopback_addr.sin6_addr)[15] = 1; + ipv6_loopback_addr.sin6_family = AF_INET6; + ipv6_loopback_addr.sin6_port = numeric_port; + (*addrs)->emplace_back(&ipv6_loopback_addr, sizeof(ipv6_loopback_addr), + nullptr /* args */); + // Append the ipv4 loopback address. + struct sockaddr_in ipv4_loopback_addr; + memset(&ipv4_loopback_addr, 0, sizeof(ipv4_loopback_addr)); + ((char*)&ipv4_loopback_addr.sin_addr)[0] = 0x7f; + ((char*)&ipv4_loopback_addr.sin_addr)[3] = 0x01; + ipv4_loopback_addr.sin_family = AF_INET; + ipv4_loopback_addr.sin_port = numeric_port; + (*addrs)->emplace_back(&ipv4_loopback_addr, sizeof(ipv4_loopback_addr), + nullptr /* args */); + // Let the address sorter figure out which one should be tried first. + grpc_cares_wrapper_address_sorting_sort(addrs->get()); + return true; + } + return false; +} +#endif /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ + +static bool grpc_ares_maybe_resolve_localhost_manually_locked( + const char* name, const char* default_port, + grpc_core::UniquePtr* addrs) { +#ifdef GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY + char* host = nullptr; + char* port = nullptr; + bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port, + addrs, &host, &port); + gpr_free(host); + gpr_free(port); + return out; +#else /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ + return false; +#endif /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ +} + static grpc_ares_request* grpc_dns_lookup_ares_locked_impl( const char* dns_server, const char* name, const char* default_port, grpc_pollset_set* interested_parties, grpc_closure* on_done, diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h index 2cb7c9e53a5..cc977c06b25 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h @@ -87,14 +87,6 @@ void grpc_ares_complete_request_locked(grpc_ares_request* request); /* E.g., return false if ipv6 is known to not be available. */ bool grpc_ares_query_ipv6(); -/* Maybe (depending on the current platform) checks if "name" matches - * "localhost" and if so fills in addrs with the correct sockaddr structures. - * Returns a bool indicating whether or not such an action was performed. - * See https://github.com/grpc/grpc/issues/15158. */ -bool grpc_ares_maybe_resolve_localhost_manually_locked( - const char* name, const char* default_port, - grpc_core::UniquePtr* addrs); - /* Sorts destinations in lb_addrs according to RFC 6724. */ void grpc_cares_wrapper_address_sorting_sort( grpc_core::ServerAddressList* addresses); diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc index eb0b3dab4a4..f85feb674dd 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc @@ -25,7 +25,6 @@ #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" @@ -37,20 +36,4 @@ bool grpc_ares_query_ipv6() { return true; } -bool grpc_ares_maybe_resolve_localhost_manually_locked( - const char* name, const char* default_port, - grpc_core::UniquePtr* addrs) { -#ifdef GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY - char* host = nullptr; - char* port = nullptr; - bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port, - addrs, &host, &port); - gpr_free(host); - gpr_free(port); - return out; -#else /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ - return false; -#endif /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ -} - #endif /* GRPC_ARES == 1 && defined(GRPC_UV) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc index 028d8442169..23c0fec74f3 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc @@ -26,10 +26,4 @@ bool grpc_ares_query_ipv6() { return grpc_ipv6_loopback_available(); } -bool grpc_ares_maybe_resolve_localhost_manually_locked( - const char* name, const char* default_port, - grpc_core::UniquePtr* addrs) { - return false; -} - #endif /* GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_ARES_EV_DRIVER) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc index e48f9501752..06cd5722ce3 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc @@ -25,7 +25,6 @@ #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" @@ -33,16 +32,4 @@ bool grpc_ares_query_ipv6() { return grpc_ipv6_loopback_available(); } -bool grpc_ares_maybe_resolve_localhost_manually_locked( - const char* name, const char* default_port, - grpc_core::UniquePtr* addrs) { - char* host = nullptr; - char* port = nullptr; - bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port, - addrs, &host, &port); - gpr_free(host); - gpr_free(port); - return out; -} - #endif /* GRPC_ARES == 1 && defined(GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc deleted file mode 100644 index 1331a6a67f5..00000000000 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc +++ /dev/null @@ -1,83 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/lib/iomgr/port.h" -#if GRPC_ARES == 1 && defined(GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY) - -#include - -#include "src/core/ext/filters/client_channel/parse_address.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" -#include "src/core/ext/filters/client_channel/server_address.h" -#include "src/core/lib/gpr/host_port.h" -#include "src/core/lib/gpr/string.h" - -bool inner_maybe_resolve_localhost_manually_locked( - const char* name, const char* default_port, - grpc_core::UniquePtr* addrs, char** host, - char** port) { - gpr_split_host_port(name, host, port); - if (*host == nullptr) { - gpr_log(GPR_ERROR, - "Failed to parse %s into host:port during manual localhost " - "resolution check.", - name); - return false; - } - if (*port == nullptr) { - if (default_port == nullptr) { - gpr_log(GPR_ERROR, - "No port or default port for %s during manual localhost " - "resolution check.", - name); - return false; - } - *port = gpr_strdup(default_port); - } - if (gpr_stricmp(*host, "localhost") == 0) { - GPR_ASSERT(*addrs == nullptr); - *addrs = grpc_core::MakeUnique(); - uint16_t numeric_port = grpc_strhtons(*port); - // Append the ipv6 loopback address. - struct sockaddr_in6 ipv6_loopback_addr; - memset(&ipv6_loopback_addr, 0, sizeof(ipv6_loopback_addr)); - ((char*)&ipv6_loopback_addr.sin6_addr)[15] = 1; - ipv6_loopback_addr.sin6_family = AF_INET6; - ipv6_loopback_addr.sin6_port = numeric_port; - (*addrs)->emplace_back(&ipv6_loopback_addr, sizeof(ipv6_loopback_addr), - nullptr /* args */); - // Append the ipv4 loopback address. - struct sockaddr_in ipv4_loopback_addr; - memset(&ipv4_loopback_addr, 0, sizeof(ipv4_loopback_addr)); - ((char*)&ipv4_loopback_addr.sin_addr)[0] = 0x7f; - ((char*)&ipv4_loopback_addr.sin_addr)[3] = 0x01; - ipv4_loopback_addr.sin_family = AF_INET; - ipv4_loopback_addr.sin_port = numeric_port; - (*addrs)->emplace_back(&ipv4_loopback_addr, sizeof(ipv4_loopback_addr), - nullptr /* args */); - // Let the address sorter figure out which one should be tried first. - grpc_cares_wrapper_address_sorting_sort(addrs->get()); - return true; - } - return false; -} - -#endif /* GRPC_ARES == 1 && defined(GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY) */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h deleted file mode 100644 index 783b781154c..00000000000 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_WINDOWS_INNER_H -#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_WINDOWS_INNER_H - -#include - -#include - -#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" - -bool inner_maybe_resolve_localhost_manually_locked( - const char* name, const char* default_port, - grpc_core::UniquePtr* addrs, char** host, - char** port); - -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_WINDOWS_INNER_H \ - */ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index c9217aded63..2619ccf9740 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -385,7 +385,6 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc', 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 483e639be66..b34c7734621 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -951,8 +951,6 @@ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallba src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ -src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc \ -src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h \ src/core/ext/filters/client_channel/resolver/dns/native/README.md \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index de08e38a838..39ee76b1a9c 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -9178,8 +9178,7 @@ ], "headers": [ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" ], "is_filegroup": true, "language": "c", @@ -9196,9 +9195,7 @@ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows_inner.h" + "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc" ], "third_party": false, "type": "filegroup" From beca35661a5f1b3e14db3dff7cb693bbaa92d600 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Tue, 14 May 2019 15:45:02 -0700 Subject: [PATCH 0222/1555] Move ifdefs around --- .../resolver/dns/c_ares/grpc_ares_wrapper.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc index 86a9bb30cb4..ad0f1460121 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc @@ -572,12 +572,10 @@ static bool inner_maybe_resolve_localhost_manually_locked( } return false; } -#endif /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ static bool grpc_ares_maybe_resolve_localhost_manually_locked( const char* name, const char* default_port, grpc_core::UniquePtr* addrs) { -#ifdef GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY char* host = nullptr; char* port = nullptr; bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port, @@ -585,10 +583,14 @@ static bool grpc_ares_maybe_resolve_localhost_manually_locked( gpr_free(host); gpr_free(port); return out; -#else /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ - return false; -#endif /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ } +#else /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ +static bool grpc_ares_maybe_resolve_localhost_manually_locked( + const char* name, const char* default_port, + grpc_core::UniquePtr* addrs) { + return false; +} +#endif /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ static grpc_ares_request* grpc_dns_lookup_ares_locked_impl( const char* dns_server, const char* name, const char* default_port, From 6be0b06c69741e861a6a027a3ce60ae3afec45e1 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 15 May 2019 13:38:34 -0700 Subject: [PATCH 0223/1555] Revert "Fold CompletionQueue and ServerCompletionQueue into grpc_impl" --- BUILD | 1 - BUILD.gn | 1 - CMakeLists.txt | 5 - Makefile | 5 - build.yaml | 1 - gRPC-C++.podspec | 1 - include/grpcpp/channel_impl.h | 1 - include/grpcpp/create_channel_impl.h | 1 + include/grpcpp/generic/generic_stub_impl.h | 2 +- include/grpcpp/impl/codegen/async_stream.h | 2 + .../grpcpp/impl/codegen/async_unary_call.h | 1 + include/grpcpp/impl/codegen/call.h | 16 +- include/grpcpp/impl/codegen/call_op_set.h | 1 + .../grpcpp/impl/codegen/channel_interface.h | 16 +- include/grpcpp/impl/codegen/client_callback.h | 1 + include/grpcpp/impl/codegen/client_context.h | 2 +- .../grpcpp/impl/codegen/client_unary_call.h | 2 + .../grpcpp/impl/codegen/completion_queue.h | 392 +++++++++++++++- .../impl/codegen/completion_queue_impl.h | 422 ------------------ .../grpcpp/impl/codegen/intercepted_channel.h | 13 +- include/grpcpp/impl/codegen/server_context.h | 5 +- .../grpcpp/impl/codegen/server_interface.h | 71 ++- include/grpcpp/impl/codegen/service_type.h | 3 +- include/grpcpp/server_builder.h | 7 + include/grpcpp/server_builder_impl.h | 9 +- src/compiler/cpp_generator.cc | 6 +- src/cpp/common/completion_queue_cc.cc | 12 +- test/cpp/codegen/compiler_test_golden | 7 +- tools/doxygen/Doxyfile.c++ | 1 - tools/doxygen/Doxyfile.c++.internal | 1 - .../generated/sources_and_headers.json | 2 - 31 files changed, 472 insertions(+), 538 deletions(-) delete mode 100644 include/grpcpp/impl/codegen/completion_queue_impl.h diff --git a/BUILD b/BUILD index 0e2b9ee3a38..4a6dc7de969 100644 --- a/BUILD +++ b/BUILD @@ -2146,7 +2146,6 @@ grpc_cc_library( "include/grpcpp/impl/codegen/client_interceptor.h", "include/grpcpp/impl/codegen/client_unary_call.h", "include/grpcpp/impl/codegen/completion_queue.h", - "include/grpcpp/impl/codegen/completion_queue_impl.h", "include/grpcpp/impl/codegen/completion_queue_tag.h", "include/grpcpp/impl/codegen/config.h", "include/grpcpp/impl/codegen/core_codegen_interface.h", diff --git a/BUILD.gn b/BUILD.gn index 4454dc7220d..25f1c69253a 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1054,7 +1054,6 @@ config("grpc_config") { "include/grpcpp/impl/codegen/client_interceptor.h", "include/grpcpp/impl/codegen/client_unary_call.h", "include/grpcpp/impl/codegen/completion_queue.h", - "include/grpcpp/impl/codegen/completion_queue_impl.h", "include/grpcpp/impl/codegen/completion_queue_tag.h", "include/grpcpp/impl/codegen/config.h", "include/grpcpp/impl/codegen/config_protobuf.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ba68c4a13b..2a65c46a81e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3310,7 +3310,6 @@ foreach(_hdr include/grpcpp/impl/codegen/client_interceptor.h include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/completion_queue.h - include/grpcpp/impl/codegen/completion_queue_impl.h include/grpcpp/impl/codegen/completion_queue_tag.h include/grpcpp/impl/codegen/config.h include/grpcpp/impl/codegen/core_codegen_interface.h @@ -3926,7 +3925,6 @@ foreach(_hdr include/grpcpp/impl/codegen/client_interceptor.h include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/completion_queue.h - include/grpcpp/impl/codegen/completion_queue_impl.h include/grpcpp/impl/codegen/completion_queue_tag.h include/grpcpp/impl/codegen/config.h include/grpcpp/impl/codegen/core_codegen_interface.h @@ -4361,7 +4359,6 @@ foreach(_hdr include/grpcpp/impl/codegen/client_interceptor.h include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/completion_queue.h - include/grpcpp/impl/codegen/completion_queue_impl.h include/grpcpp/impl/codegen/completion_queue_tag.h include/grpcpp/impl/codegen/config.h include/grpcpp/impl/codegen/core_codegen_interface.h @@ -4560,7 +4557,6 @@ foreach(_hdr include/grpcpp/impl/codegen/client_interceptor.h include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/completion_queue.h - include/grpcpp/impl/codegen/completion_queue_impl.h include/grpcpp/impl/codegen/completion_queue_tag.h include/grpcpp/impl/codegen/config.h include/grpcpp/impl/codegen/core_codegen_interface.h @@ -4916,7 +4912,6 @@ foreach(_hdr include/grpcpp/impl/codegen/client_interceptor.h include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/completion_queue.h - include/grpcpp/impl/codegen/completion_queue_impl.h include/grpcpp/impl/codegen/completion_queue_tag.h include/grpcpp/impl/codegen/config.h include/grpcpp/impl/codegen/core_codegen_interface.h diff --git a/Makefile b/Makefile index ae125cb1aa5..0c86c313b1f 100644 --- a/Makefile +++ b/Makefile @@ -5663,7 +5663,6 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ - include/grpcpp/impl/codegen/completion_queue_impl.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/config.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \ @@ -6287,7 +6286,6 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ - include/grpcpp/impl/codegen/completion_queue_impl.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/config.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \ @@ -6694,7 +6692,6 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ - include/grpcpp/impl/codegen/completion_queue_impl.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/config.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \ @@ -6864,7 +6861,6 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ - include/grpcpp/impl/codegen/completion_queue_impl.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/config.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \ @@ -7226,7 +7222,6 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ - include/grpcpp/impl/codegen/completion_queue_impl.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/config.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \ diff --git a/build.yaml b/build.yaml index 6a16596ac83..a5a46194772 100644 --- a/build.yaml +++ b/build.yaml @@ -1253,7 +1253,6 @@ filegroups: - include/grpcpp/impl/codegen/client_interceptor.h - include/grpcpp/impl/codegen/client_unary_call.h - include/grpcpp/impl/codegen/completion_queue.h - - include/grpcpp/impl/codegen/completion_queue_impl.h - include/grpcpp/impl/codegen/completion_queue_tag.h - include/grpcpp/impl/codegen/config.h - include/grpcpp/impl/codegen/core_codegen_interface.h diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index a4b38bcbdc0..e1000342e0e 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -163,7 +163,6 @@ Pod::Spec.new do |s| 'include/grpcpp/impl/codegen/client_interceptor.h', 'include/grpcpp/impl/codegen/client_unary_call.h', 'include/grpcpp/impl/codegen/completion_queue.h', - 'include/grpcpp/impl/codegen/completion_queue_impl.h', 'include/grpcpp/impl/codegen/completion_queue_tag.h', 'include/grpcpp/impl/codegen/config.h', 'include/grpcpp/impl/codegen/core_codegen_interface.h', diff --git a/include/grpcpp/channel_impl.h b/include/grpcpp/channel_impl.h index 39917d2eb74..94dcd2ff5bd 100644 --- a/include/grpcpp/channel_impl.h +++ b/include/grpcpp/channel_impl.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/include/grpcpp/create_channel_impl.h b/include/grpcpp/create_channel_impl.h index 02896e66444..ebf8b96973e 100644 --- a/include/grpcpp/create_channel_impl.h +++ b/include/grpcpp/create_channel_impl.h @@ -28,6 +28,7 @@ #include namespace grpc_impl { + /// Create a new \a Channel pointing to \a target. /// /// \param target The URI of the endpoint to connect to. diff --git a/include/grpcpp/generic/generic_stub_impl.h b/include/grpcpp/generic/generic_stub_impl.h index 90414611cbd..0a7338228c1 100644 --- a/include/grpcpp/generic/generic_stub_impl.h +++ b/include/grpcpp/generic/generic_stub_impl.h @@ -29,12 +29,12 @@ namespace grpc { +class CompletionQueue; typedef ClientAsyncReaderWriter GenericClientAsyncReaderWriter; typedef ClientAsyncResponseReader GenericClientAsyncResponseReader; } // namespace grpc namespace grpc_impl { -class CompletionQueue; /// Generic stubs provide a type-unsafe interface to call gRPC methods /// by name. diff --git a/include/grpcpp/impl/codegen/async_stream.h b/include/grpcpp/impl/codegen/async_stream.h index f95772650a2..6a23363bd6d 100644 --- a/include/grpcpp/impl/codegen/async_stream.h +++ b/include/grpcpp/impl/codegen/async_stream.h @@ -28,6 +28,8 @@ namespace grpc { +class CompletionQueue; + namespace internal { /// Common interface for all client side asynchronous streaming. class ClientAsyncStreamingInterface { diff --git a/include/grpcpp/impl/codegen/async_unary_call.h b/include/grpcpp/impl/codegen/async_unary_call.h index 4b97cf29018..89dcb124189 100644 --- a/include/grpcpp/impl/codegen/async_unary_call.h +++ b/include/grpcpp/impl/codegen/async_unary_call.h @@ -29,6 +29,7 @@ namespace grpc { +class CompletionQueue; extern CoreCodegenInterface* g_core_codegen_interface; /// An interface relevant for async client side unary RPCs (which send diff --git a/include/grpcpp/impl/codegen/call.h b/include/grpcpp/impl/codegen/call.h index eefa4a7f9cd..c040c30dd9d 100644 --- a/include/grpcpp/impl/codegen/call.h +++ b/include/grpcpp/impl/codegen/call.h @@ -21,11 +21,9 @@ #include #include -namespace grpc_impl { -class CompletionQueue; -} - namespace grpc { +class CompletionQueue; + namespace experimental { class ClientRpcInfo; class ServerRpcInfo; @@ -43,13 +41,13 @@ class Call final { call_(nullptr), max_receive_message_size_(-1) {} /** call is owned by the caller */ - Call(grpc_call* call, CallHook* call_hook, ::grpc_impl::CompletionQueue* cq) + Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq) : call_hook_(call_hook), cq_(cq), call_(call), max_receive_message_size_(-1) {} - Call(grpc_call* call, CallHook* call_hook, ::grpc_impl::CompletionQueue* cq, + Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq, experimental::ClientRpcInfo* rpc_info) : call_hook_(call_hook), cq_(cq), @@ -57,7 +55,7 @@ class Call final { max_receive_message_size_(-1), client_rpc_info_(rpc_info) {} - Call(grpc_call* call, CallHook* call_hook, ::grpc_impl::CompletionQueue* cq, + Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq, int max_receive_message_size, experimental::ServerRpcInfo* rpc_info) : call_hook_(call_hook), cq_(cq), @@ -70,7 +68,7 @@ class Call final { } grpc_call* call() const { return call_; } - ::grpc_impl::CompletionQueue* cq() const { return cq_; } + CompletionQueue* cq() const { return cq_; } int max_receive_message_size() const { return max_receive_message_size_; } @@ -84,7 +82,7 @@ class Call final { private: CallHook* call_hook_; - ::grpc_impl::CompletionQueue* cq_; + CompletionQueue* cq_; grpc_call* call_; int max_receive_message_size_; experimental::ClientRpcInfo* client_rpc_info_ = nullptr; diff --git a/include/grpcpp/impl/codegen/call_op_set.h b/include/grpcpp/impl/codegen/call_op_set.h index d810625b3e4..4ca87a99fca 100644 --- a/include/grpcpp/impl/codegen/call_op_set.h +++ b/include/grpcpp/impl/codegen/call_op_set.h @@ -48,6 +48,7 @@ namespace grpc { +class CompletionQueue; extern CoreCodegenInterface* g_core_codegen_interface; namespace internal { diff --git a/include/grpcpp/impl/codegen/channel_interface.h b/include/grpcpp/impl/codegen/channel_interface.h index 9df233b5500..57555285e18 100644 --- a/include/grpcpp/impl/codegen/channel_interface.h +++ b/include/grpcpp/impl/codegen/channel_interface.h @@ -24,13 +24,10 @@ #include #include -namespace grpc_impl { -class CompletionQueue; -} - namespace grpc { class ChannelInterface; class ClientContext; +class CompletionQueue; template class ClientReader; @@ -77,7 +74,7 @@ class ChannelInterface { /// deadline expires. \a GetState needs to called to get the current state. template void NotifyOnStateChange(grpc_connectivity_state last_observed, T deadline, - ::grpc_impl::CompletionQueue* cq, void* tag) { + CompletionQueue* cq, void* tag) { TimePoint deadline_tp(deadline); NotifyOnStateChangeImpl(last_observed, deadline_tp.raw_time(), cq, tag); } @@ -130,14 +127,13 @@ class ChannelInterface { friend class ::grpc::internal::InterceptedChannel; virtual internal::Call CreateCall(const internal::RpcMethod& method, ClientContext* context, - ::grpc_impl::CompletionQueue* cq) = 0; + CompletionQueue* cq) = 0; virtual void PerformOpsOnCall(internal::CallOpSetInterface* ops, internal::Call* call) = 0; virtual void* RegisterMethod(const char* method) = 0; virtual void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline, - ::grpc_impl::CompletionQueue* cq, - void* tag) = 0; + CompletionQueue* cq, void* tag) = 0; virtual bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline) = 0; @@ -150,7 +146,7 @@ class ChannelInterface { // change (even though this is private and non-API) virtual internal::Call CreateCallInternal(const internal::RpcMethod& method, ClientContext* context, - ::grpc_impl::CompletionQueue* cq, + CompletionQueue* cq, size_t interceptor_pos) { return internal::Call(); } @@ -163,7 +159,7 @@ class ChannelInterface { // Returns nullptr (rather than being pure) since this is a post-1.0 method // and adding a new pure method to an interface would be a breaking change // (even though this is private and non-API) - virtual ::grpc_impl::CompletionQueue* CallbackCQ() { return nullptr; } + virtual CompletionQueue* CallbackCQ() { return nullptr; } }; } // namespace grpc diff --git a/include/grpcpp/impl/codegen/client_callback.h b/include/grpcpp/impl/codegen/client_callback.h index dda9aec29f3..f0499858a05 100644 --- a/include/grpcpp/impl/codegen/client_callback.h +++ b/include/grpcpp/impl/codegen/client_callback.h @@ -36,6 +36,7 @@ class Channel; namespace grpc { class ClientContext; +class CompletionQueue; namespace internal { class RpcMethod; diff --git a/include/grpcpp/impl/codegen/client_context.h b/include/grpcpp/impl/codegen/client_context.h index 999d8fcbfe7..2e03e08712e 100644 --- a/include/grpcpp/impl/codegen/client_context.h +++ b/include/grpcpp/impl/codegen/client_context.h @@ -61,11 +61,11 @@ namespace grpc_impl { class CallCredentials; class Channel; -class CompletionQueue; } // namespace grpc_impl namespace grpc { class ChannelInterface; +class CompletionQueue; class ClientContext; namespace internal { diff --git a/include/grpcpp/impl/codegen/client_unary_call.h b/include/grpcpp/impl/codegen/client_unary_call.h index e0f692b1783..b9f8e1663f1 100644 --- a/include/grpcpp/impl/codegen/client_unary_call.h +++ b/include/grpcpp/impl/codegen/client_unary_call.h @@ -27,7 +27,9 @@ namespace grpc { +class Channel; class ClientContext; +class CompletionQueue; namespace internal { class RpcMethod; diff --git a/include/grpcpp/impl/codegen/completion_queue.h b/include/grpcpp/impl/codegen/completion_queue.h index f67a3780979..c0b1e04d007 100644 --- a/include/grpcpp/impl/codegen/completion_queue.h +++ b/include/grpcpp/impl/codegen/completion_queue.h @@ -16,15 +16,401 @@ * */ +/// A completion queue implements a concurrent producer-consumer queue, with +/// two main API-exposed methods: \a Next and \a AsyncNext. These +/// methods are the essential component of the gRPC C++ asynchronous API. +/// There is also a \a Shutdown method to indicate that a given completion queue +/// will no longer have regular events. This must be called before the +/// completion queue is destroyed. +/// All completion queue APIs are thread-safe and may be used concurrently with +/// any other completion queue API invocation; it is acceptable to have +/// multiple threads calling \a Next or \a AsyncNext on the same or different +/// completion queues, or to call these methods concurrently with a \a Shutdown +/// elsewhere. +/// \remark{All other API calls on completion queue should be completed before +/// a completion queue destructor is called.} #ifndef GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_H #define GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_H -#include +#include +#include +#include +#include +#include +#include +struct grpc_completion_queue; + +namespace grpc_impl { + +class Channel; +class Server; +class ServerBuilder; +} // namespace grpc_impl namespace grpc { -typedef ::grpc_impl::CompletionQueue CompletionQueue; -typedef ::grpc_impl::ServerCompletionQueue ServerCompletionQueue; +template +class ClientReader; +template +class ClientWriter; +template +class ClientReaderWriter; +template +class ServerReader; +template +class ServerWriter; +namespace internal { +template +class ServerReaderWriterBody; +} // namespace internal + +class ChannelInterface; +class ClientContext; +class CompletionQueue; +class ServerContext; +class ServerInterface; + +namespace internal { +class CompletionQueueTag; +class RpcMethod; +template +class RpcMethodHandler; +template +class ClientStreamingHandler; +template +class ServerStreamingHandler; +template +class BidiStreamingHandler; +template +class TemplatedBidiStreamingHandler; +template +class ErrorMethodHandler; +template +class BlockingUnaryCallImpl; +template +class CallOpSet; +} // namespace internal + +extern CoreCodegenInterface* g_core_codegen_interface; + +/// A thin wrapper around \ref grpc_completion_queue (see \ref +/// src/core/lib/surface/completion_queue.h). +/// See \ref doc/cpp/perf_notes.md for notes on best practices for high +/// performance servers. +class CompletionQueue : private GrpcLibraryCodegen { + public: + /// Default constructor. Implicitly creates a \a grpc_completion_queue + /// instance. + CompletionQueue() + : CompletionQueue(grpc_completion_queue_attributes{ + GRPC_CQ_CURRENT_VERSION, GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, + nullptr}) {} + + /// Wrap \a take, taking ownership of the instance. + /// + /// \param take The completion queue instance to wrap. Ownership is taken. + explicit CompletionQueue(grpc_completion_queue* take); + + /// Destructor. Destroys the owned wrapped completion queue / instance. + ~CompletionQueue() { + g_core_codegen_interface->grpc_completion_queue_destroy(cq_); + } + + /// Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT. + enum NextStatus { + SHUTDOWN, ///< The completion queue has been shutdown and fully-drained + GOT_EVENT, ///< Got a new event; \a tag will be filled in with its + ///< associated value; \a ok indicating its success. + TIMEOUT ///< deadline was reached. + }; + + /// Read from the queue, blocking until an event is available or the queue is + /// shutting down. + /// + /// \param tag [out] Updated to point to the read event's tag. + /// \param ok [out] true if read a successful event, false otherwise. + /// + /// Note that each tag sent to the completion queue (through RPC operations + /// or alarms) will be delivered out of the completion queue by a call to + /// Next (or a related method), regardless of whether the operation succeeded + /// or not. Success here means that this operation completed in the normal + /// valid manner. + /// + /// Server-side RPC request: \a ok indicates that the RPC has indeed + /// been started. If it is false, the server has been Shutdown + /// before this particular call got matched to an incoming RPC. + /// + /// Client-side StartCall/RPC invocation: \a ok indicates that the RPC is + /// going to go to the wire. If it is false, it not going to the wire. This + /// would happen if the channel is either permanently broken or + /// transiently broken but with the fail-fast option. (Note that async unary + /// RPCs don't post a CQ tag at this point, nor do client-streaming + /// or bidi-streaming RPCs that have the initial metadata corked option set.) + /// + /// Client-side Write, Client-side WritesDone, Server-side Write, + /// Server-side Finish, Server-side SendInitialMetadata (which is + /// typically included in Write or Finish when not done explicitly): + /// \a ok means that the data/metadata/status/etc is going to go to the + /// wire. If it is false, it not going to the wire because the call + /// is already dead (i.e., canceled, deadline expired, other side + /// dropped the channel, etc). + /// + /// Client-side Read, Server-side Read, Client-side + /// RecvInitialMetadata (which is typically included in Read if not + /// done explicitly): \a ok indicates whether there is a valid message + /// that got read. If not, you know that there are certainly no more + /// messages that can ever be read from this stream. For the client-side + /// operations, this only happens because the call is dead. For the + /// server-sider operation, though, this could happen because the client + /// has done a WritesDone already. + /// + /// Client-side Finish: \a ok should always be true + /// + /// Server-side AsyncNotifyWhenDone: \a ok should always be true + /// + /// Alarm: \a ok is true if it expired, false if it was canceled + /// + /// \return true if got an event, false if the queue is fully drained and + /// shut down. + bool Next(void** tag, bool* ok) { + return (AsyncNextInternal(tag, ok, + g_core_codegen_interface->gpr_inf_future( + GPR_CLOCK_REALTIME)) != SHUTDOWN); + } + + /// Read from the queue, blocking up to \a deadline (or the queue's shutdown). + /// Both \a tag and \a ok are updated upon success (if an event is available + /// within the \a deadline). A \a tag points to an arbitrary location usually + /// employed to uniquely identify an event. + /// + /// \param tag [out] Upon success, updated to point to the event's tag. + /// \param ok [out] Upon success, true if a successful event, false otherwise + /// See documentation for CompletionQueue::Next for explanation of ok + /// \param deadline [in] How long to block in wait for an event. + /// + /// \return The type of event read. + template + NextStatus AsyncNext(void** tag, bool* ok, const T& deadline) { + TimePoint deadline_tp(deadline); + return AsyncNextInternal(tag, ok, deadline_tp.raw_time()); + } + + /// EXPERIMENTAL + /// First executes \a F, then reads from the queue, blocking up to + /// \a deadline (or the queue's shutdown). + /// Both \a tag and \a ok are updated upon success (if an event is available + /// within the \a deadline). A \a tag points to an arbitrary location usually + /// employed to uniquely identify an event. + /// + /// \param f [in] Function to execute before calling AsyncNext on this queue. + /// \param tag [out] Upon success, updated to point to the event's tag. + /// \param ok [out] Upon success, true if read a regular event, false + /// otherwise. + /// \param deadline [in] How long to block in wait for an event. + /// + /// \return The type of event read. + template + NextStatus DoThenAsyncNext(F&& f, void** tag, bool* ok, const T& deadline) { + CompletionQueueTLSCache cache = CompletionQueueTLSCache(this); + f(); + if (cache.Flush(tag, ok)) { + return GOT_EVENT; + } else { + return AsyncNext(tag, ok, deadline); + } + } + + /// Request the shutdown of the queue. + /// + /// \warning This method must be called at some point if this completion queue + /// is accessed with Next or AsyncNext. \a Next will not return false + /// until this method has been called and all pending tags have been drained. + /// (Likewise for \a AsyncNext returning \a NextStatus::SHUTDOWN .) + /// Only once either one of these methods does that (that is, once the queue + /// has been \em drained) can an instance of this class be destroyed. + /// Also note that applications must ensure that no work is enqueued on this + /// completion queue after this method is called. + void Shutdown(); + + /// Returns a \em raw pointer to the underlying \a grpc_completion_queue + /// instance. + /// + /// \warning Remember that the returned instance is owned. No transfer of + /// owership is performed. + grpc_completion_queue* cq() { return cq_; } + + protected: + /// Private constructor of CompletionQueue only visible to friend classes + CompletionQueue(const grpc_completion_queue_attributes& attributes) { + cq_ = g_core_codegen_interface->grpc_completion_queue_create( + g_core_codegen_interface->grpc_completion_queue_factory_lookup( + &attributes), + &attributes, NULL); + InitialAvalanching(); // reserve this for the future shutdown + } + + private: + // Friend synchronous wrappers so that they can access Pluck(), which is + // a semi-private API geared towards the synchronous implementation. + template + friend class ::grpc::ClientReader; + template + friend class ::grpc::ClientWriter; + template + friend class ::grpc::ClientReaderWriter; + template + friend class ::grpc::ServerReader; + template + friend class ::grpc::ServerWriter; + template + friend class ::grpc::internal::ServerReaderWriterBody; + template + friend class ::grpc::internal::RpcMethodHandler; + template + friend class ::grpc::internal::ClientStreamingHandler; + template + friend class ::grpc::internal::ServerStreamingHandler; + template + friend class ::grpc::internal::TemplatedBidiStreamingHandler; + template + friend class ::grpc::internal::ErrorMethodHandler; + friend class ::grpc_impl::Server; + friend class ::grpc::ServerContext; + friend class ::grpc::ServerInterface; + template + friend class ::grpc::internal::BlockingUnaryCallImpl; + + // Friends that need access to constructor for callback CQ + friend class ::grpc_impl::Channel; + + // For access to Register/CompleteAvalanching + template + friend class ::grpc::internal::CallOpSet; + + /// EXPERIMENTAL + /// Creates a Thread Local cache to store the first event + /// On this completion queue queued from this thread. Once + /// initialized, it must be flushed on the same thread. + class CompletionQueueTLSCache { + public: + CompletionQueueTLSCache(CompletionQueue* cq); + ~CompletionQueueTLSCache(); + bool Flush(void** tag, bool* ok); + + private: + CompletionQueue* cq_; + bool flushed_; + }; + + NextStatus AsyncNextInternal(void** tag, bool* ok, gpr_timespec deadline); + + /// Wraps \a grpc_completion_queue_pluck. + /// \warning Must not be mixed with calls to \a Next. + bool Pluck(internal::CompletionQueueTag* tag) { + auto deadline = + g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_REALTIME); + while (true) { + auto ev = g_core_codegen_interface->grpc_completion_queue_pluck( + cq_, tag, deadline, nullptr); + bool ok = ev.success != 0; + void* ignored = tag; + if (tag->FinalizeResult(&ignored, &ok)) { + GPR_CODEGEN_ASSERT(ignored == tag); + return ok; + } + } + } + + /// Performs a single polling pluck on \a tag. + /// \warning Must not be mixed with calls to \a Next. + /// + /// TODO: sreek - This calls tag->FinalizeResult() even if the cq_ is already + /// shutdown. This is most likely a bug and if it is a bug, then change this + /// implementation to simple call the other TryPluck function with a zero + /// timeout. i.e: + /// TryPluck(tag, gpr_time_0(GPR_CLOCK_REALTIME)) + void TryPluck(internal::CompletionQueueTag* tag) { + auto deadline = g_core_codegen_interface->gpr_time_0(GPR_CLOCK_REALTIME); + auto ev = g_core_codegen_interface->grpc_completion_queue_pluck( + cq_, tag, deadline, nullptr); + if (ev.type == GRPC_QUEUE_TIMEOUT) return; + bool ok = ev.success != 0; + void* ignored = tag; + // the tag must be swallowed if using TryPluck + GPR_CODEGEN_ASSERT(!tag->FinalizeResult(&ignored, &ok)); + } + + /// Performs a single polling pluck on \a tag. Calls tag->FinalizeResult if + /// the pluck() was successful and returned the tag. + /// + /// This exects tag->FinalizeResult (if called) to return 'false' i.e expects + /// that the tag is internal not something that is returned to the user. + void TryPluck(internal::CompletionQueueTag* tag, gpr_timespec deadline) { + auto ev = g_core_codegen_interface->grpc_completion_queue_pluck( + cq_, tag, deadline, nullptr); + if (ev.type == GRPC_QUEUE_TIMEOUT || ev.type == GRPC_QUEUE_SHUTDOWN) { + return; + } + + bool ok = ev.success != 0; + void* ignored = tag; + GPR_CODEGEN_ASSERT(!tag->FinalizeResult(&ignored, &ok)); + } + + /// Manage state of avalanching operations : completion queue tags that + /// trigger other completion queue operations. The underlying core completion + /// queue should not really shutdown until all avalanching operations have + /// been finalized. Note that we maintain the requirement that an avalanche + /// registration must take place before CQ shutdown (which must be maintained + /// elsewhere) + void InitialAvalanching() { + gpr_atm_rel_store(&avalanches_in_flight_, static_cast(1)); + } + void RegisterAvalanching() { + gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_, + static_cast(1)); + } + void CompleteAvalanching() { + if (gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_, + static_cast(-1)) == 1) { + g_core_codegen_interface->grpc_completion_queue_shutdown(cq_); + } + } + + grpc_completion_queue* cq_; // owned + + gpr_atm avalanches_in_flight_; +}; + +/// A specific type of completion queue used by the processing of notifications +/// by servers. Instantiated by \a ServerBuilder. +class ServerCompletionQueue : public CompletionQueue { + public: + bool IsFrequentlyPolled() { return polling_type_ != GRPC_CQ_NON_LISTENING; } + + protected: + /// Default constructor + ServerCompletionQueue() : polling_type_(GRPC_CQ_DEFAULT_POLLING) {} + + private: + /// \param completion_type indicates whether this is a NEXT or CALLBACK + /// completion queue. + /// \param polling_type Informs the GRPC library about the type of polling + /// allowed on this completion queue. See grpc_cq_polling_type's description + /// in grpc_types.h for more details. + /// \param shutdown_cb is the shutdown callback used for CALLBACK api queues + ServerCompletionQueue(grpc_cq_completion_type completion_type, + grpc_cq_polling_type polling_type, + grpc_experimental_completion_queue_functor* shutdown_cb) + : CompletionQueue(grpc_completion_queue_attributes{ + GRPC_CQ_CURRENT_VERSION, completion_type, polling_type, + shutdown_cb}), + polling_type_(polling_type) {} + + grpc_cq_polling_type polling_type_; + friend class grpc_impl::ServerBuilder; + friend class grpc_impl::Server; +}; } // namespace grpc diff --git a/include/grpcpp/impl/codegen/completion_queue_impl.h b/include/grpcpp/impl/codegen/completion_queue_impl.h deleted file mode 100644 index 5435f2fa165..00000000000 --- a/include/grpcpp/impl/codegen/completion_queue_impl.h +++ /dev/null @@ -1,422 +0,0 @@ -/* - * - * Copyright 2015-2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/// A completion queue implements a concurrent producer-consumer queue, with -/// two main API-exposed methods: \a Next and \a AsyncNext. These -/// methods are the essential component of the gRPC C++ asynchronous API. -/// There is also a \a Shutdown method to indicate that a given completion queue -/// will no longer have regular events. This must be called before the -/// completion queue is destroyed. -/// All completion queue APIs are thread-safe and may be used concurrently with -/// any other completion queue API invocation; it is acceptable to have -/// multiple threads calling \a Next or \a AsyncNext on the same or different -/// completion queues, or to call these methods concurrently with a \a Shutdown -/// elsewhere. -/// \remark{All other API calls on completion queue should be completed before -/// a completion queue destructor is called.} -#ifndef GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_IMPL_H -#define GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_IMPL_H - -#include -#include -#include -#include -#include -#include - -struct grpc_completion_queue; - -namespace grpc_impl { - -class Channel; -class Server; -class ServerBuilder; -} // namespace grpc_impl -namespace grpc { - -template -class ClientReader; -template -class ClientWriter; -template -class ClientReaderWriter; -template -class ServerReader; -template -class ServerWriter; -namespace internal { -template -class ServerReaderWriterBody; -} // namespace internal - -class ChannelInterface; -class ClientContext; -class ServerContext; -class ServerInterface; - -namespace internal { -class CompletionQueueTag; -class RpcMethod; -template -class RpcMethodHandler; -template -class ClientStreamingHandler; -template -class ServerStreamingHandler; -template -class BidiStreamingHandler; -template -class TemplatedBidiStreamingHandler; -template -class ErrorMethodHandler; -template -class BlockingUnaryCallImpl; -template -class CallOpSet; -} // namespace internal - -extern CoreCodegenInterface* g_core_codegen_interface; - -} // namespace grpc - -namespace grpc_impl { - -/// A thin wrapper around \ref grpc_completion_queue (see \ref -/// src/core/lib/surface/completion_queue.h). -/// See \ref doc/cpp/perf_notes.md for notes on best practices for high -/// performance servers. -class CompletionQueue : private ::grpc::GrpcLibraryCodegen { - public: - /// Default constructor. Implicitly creates a \a grpc_completion_queue - /// instance. - CompletionQueue() - : CompletionQueue(grpc_completion_queue_attributes{ - GRPC_CQ_CURRENT_VERSION, GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, - nullptr}) {} - - /// Wrap \a take, taking ownership of the instance. - /// - /// \param take The completion queue instance to wrap. Ownership is taken. - explicit CompletionQueue(grpc_completion_queue* take); - - /// Destructor. Destroys the owned wrapped completion queue / instance. - ~CompletionQueue() { - ::grpc::g_core_codegen_interface->grpc_completion_queue_destroy(cq_); - } - - /// Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT. - enum NextStatus { - SHUTDOWN, ///< The completion queue has been shutdown and fully-drained - GOT_EVENT, ///< Got a new event; \a tag will be filled in with its - ///< associated value; \a ok indicating its success. - TIMEOUT ///< deadline was reached. - }; - - /// Read from the queue, blocking until an event is available or the queue is - /// shutting down. - /// - /// \param tag [out] Updated to point to the read event's tag. - /// \param ok [out] true if read a successful event, false otherwise. - /// - /// Note that each tag sent to the completion queue (through RPC operations - /// or alarms) will be delivered out of the completion queue by a call to - /// Next (or a related method), regardless of whether the operation succeeded - /// or not. Success here means that this operation completed in the normal - /// valid manner. - /// - /// Server-side RPC request: \a ok indicates that the RPC has indeed - /// been started. If it is false, the server has been Shutdown - /// before this particular call got matched to an incoming RPC. - /// - /// Client-side StartCall/RPC invocation: \a ok indicates that the RPC is - /// going to go to the wire. If it is false, it not going to the wire. This - /// would happen if the channel is either permanently broken or - /// transiently broken but with the fail-fast option. (Note that async unary - /// RPCs don't post a CQ tag at this point, nor do client-streaming - /// or bidi-streaming RPCs that have the initial metadata corked option set.) - /// - /// Client-side Write, Client-side WritesDone, Server-side Write, - /// Server-side Finish, Server-side SendInitialMetadata (which is - /// typically included in Write or Finish when not done explicitly): - /// \a ok means that the data/metadata/status/etc is going to go to the - /// wire. If it is false, it not going to the wire because the call - /// is already dead (i.e., canceled, deadline expired, other side - /// dropped the channel, etc). - /// - /// Client-side Read, Server-side Read, Client-side - /// RecvInitialMetadata (which is typically included in Read if not - /// done explicitly): \a ok indicates whether there is a valid message - /// that got read. If not, you know that there are certainly no more - /// messages that can ever be read from this stream. For the client-side - /// operations, this only happens because the call is dead. For the - /// server-sider operation, though, this could happen because the client - /// has done a WritesDone already. - /// - /// Client-side Finish: \a ok should always be true - /// - /// Server-side AsyncNotifyWhenDone: \a ok should always be true - /// - /// Alarm: \a ok is true if it expired, false if it was canceled - /// - /// \return true if got an event, false if the queue is fully drained and - /// shut down. - bool Next(void** tag, bool* ok) { - return (AsyncNextInternal(tag, ok, - ::grpc::g_core_codegen_interface->gpr_inf_future( - GPR_CLOCK_REALTIME)) != SHUTDOWN); - } - - /// Read from the queue, blocking up to \a deadline (or the queue's shutdown). - /// Both \a tag and \a ok are updated upon success (if an event is available - /// within the \a deadline). A \a tag points to an arbitrary location usually - /// employed to uniquely identify an event. - /// - /// \param tag [out] Upon sucess, updated to point to the event's tag. - /// \param ok [out] Upon sucess, true if a successful event, false otherwise - /// See documentation for CompletionQueue::Next for explanation of ok - /// \param deadline [in] How long to block in wait for an event. - /// - /// \return The type of event read. - template - NextStatus AsyncNext(void** tag, bool* ok, const T& deadline) { - ::grpc::TimePoint deadline_tp(deadline); - return AsyncNextInternal(tag, ok, deadline_tp.raw_time()); - } - - /// EXPERIMENTAL - /// First executes \a F, then reads from the queue, blocking up to - /// \a deadline (or the queue's shutdown). - /// Both \a tag and \a ok are updated upon success (if an event is available - /// within the \a deadline). A \a tag points to an arbitrary location usually - /// employed to uniquely identify an event. - /// - /// \param f [in] Function to execute before calling AsyncNext on this queue. - /// \param tag [out] Upon sucess, updated to point to the event's tag. - /// \param ok [out] Upon sucess, true if read a regular event, false - /// otherwise. - /// \param deadline [in] How long to block in wait for an event. - /// - /// \return The type of event read. - template - NextStatus DoThenAsyncNext(F&& f, void** tag, bool* ok, const T& deadline) { - CompletionQueueTLSCache cache = CompletionQueueTLSCache(this); - f(); - if (cache.Flush(tag, ok)) { - return GOT_EVENT; - } else { - return AsyncNext(tag, ok, deadline); - } - } - - /// Request the shutdown of the queue. - /// - /// \warning This method must be called at some point if this completion queue - /// is accessed with Next or AsyncNext. \a Next will not return false - /// until this method has been called and all pending tags have been drained. - /// (Likewise for \a AsyncNext returning \a NextStatus::SHUTDOWN .) - /// Only once either one of these methods does that (that is, once the queue - /// has been \em drained) can an instance of this class be destroyed. - /// Also note that applications must ensure that no work is enqueued on this - /// completion queue after this method is called. - void Shutdown(); - - /// Returns a \em raw pointer to the underlying \a grpc_completion_queue - /// instance. - /// - /// \warning Remember that the returned instance is owned. No transfer of - /// owership is performed. - grpc_completion_queue* cq() { return cq_; } - - protected: - /// Private constructor of CompletionQueue only visible to friend classes - CompletionQueue(const grpc_completion_queue_attributes& attributes) { - cq_ = ::grpc::g_core_codegen_interface->grpc_completion_queue_create( - ::grpc::g_core_codegen_interface->grpc_completion_queue_factory_lookup( - &attributes), - &attributes, NULL); - InitialAvalanching(); // reserve this for the future shutdown - } - - private: - // Friend synchronous wrappers so that they can access Pluck(), which is - // a semi-private API geared towards the synchronous implementation. - template - friend class ::grpc::ClientReader; - template - friend class ::grpc::ClientWriter; - template - friend class ::grpc::ClientReaderWriter; - template - friend class ::grpc::ServerReader; - template - friend class ::grpc::ServerWriter; - template - friend class ::grpc::internal::ServerReaderWriterBody; - template - friend class ::grpc::internal::RpcMethodHandler; - template - friend class ::grpc::internal::ClientStreamingHandler; - template - friend class ::grpc::internal::ServerStreamingHandler; - template - friend class ::grpc::internal::TemplatedBidiStreamingHandler; - template <::grpc::StatusCode code> - friend class ::grpc::internal::ErrorMethodHandler; - friend class ::grpc_impl::Server; - friend class ::grpc::ServerContext; - friend class ::grpc::ServerInterface; - template - friend class ::grpc::internal::BlockingUnaryCallImpl; - - // Friends that need access to constructor for callback CQ - friend class ::grpc_impl::Channel; - - // For access to Register/CompleteAvalanching - template - friend class ::grpc::internal::CallOpSet; - - /// EXPERIMENTAL - /// Creates a Thread Local cache to store the first event - /// On this completion queue queued from this thread. Once - /// initialized, it must be flushed on the same thread. - class CompletionQueueTLSCache { - public: - CompletionQueueTLSCache(CompletionQueue* cq); - ~CompletionQueueTLSCache(); - bool Flush(void** tag, bool* ok); - - private: - CompletionQueue* cq_; - bool flushed_; - }; - - NextStatus AsyncNextInternal(void** tag, bool* ok, gpr_timespec deadline); - - /// Wraps \a grpc_completion_queue_pluck. - /// \warning Must not be mixed with calls to \a Next. - bool Pluck(::grpc::internal::CompletionQueueTag* tag) { - auto deadline = - ::grpc::g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_REALTIME); - while (true) { - auto ev = ::grpc::g_core_codegen_interface->grpc_completion_queue_pluck( - cq_, tag, deadline, nullptr); - bool ok = ev.success != 0; - void* ignored = tag; - if (tag->FinalizeResult(&ignored, &ok)) { - GPR_CODEGEN_ASSERT(ignored == tag); - return ok; - } - } - } - - /// Performs a single polling pluck on \a tag. - /// \warning Must not be mixed with calls to \a Next. - /// - /// TODO: sreek - This calls tag->FinalizeResult() even if the cq_ is already - /// shutdown. This is most likely a bug and if it is a bug, then change this - /// implementation to simple call the other TryPluck function with a zero - /// timeout. i.e: - /// TryPluck(tag, gpr_time_0(GPR_CLOCK_REALTIME)) - void TryPluck(::grpc::internal::CompletionQueueTag* tag) { - auto deadline = - ::grpc::g_core_codegen_interface->gpr_time_0(GPR_CLOCK_REALTIME); - auto ev = ::grpc::g_core_codegen_interface->grpc_completion_queue_pluck( - cq_, tag, deadline, nullptr); - if (ev.type == GRPC_QUEUE_TIMEOUT) return; - bool ok = ev.success != 0; - void* ignored = tag; - // the tag must be swallowed if using TryPluck - GPR_CODEGEN_ASSERT(!tag->FinalizeResult(&ignored, &ok)); - } - - /// Performs a single polling pluck on \a tag. Calls tag->FinalizeResult if - /// the pluck() was successful and returned the tag. - /// - /// This exects tag->FinalizeResult (if called) to return 'false' i.e expects - /// that the tag is internal not something that is returned to the user. - void TryPluck(::grpc::internal::CompletionQueueTag* tag, - gpr_timespec deadline) { - auto ev = ::grpc::g_core_codegen_interface->grpc_completion_queue_pluck( - cq_, tag, deadline, nullptr); - if (ev.type == GRPC_QUEUE_TIMEOUT || ev.type == GRPC_QUEUE_SHUTDOWN) { - return; - } - - bool ok = ev.success != 0; - void* ignored = tag; - GPR_CODEGEN_ASSERT(!tag->FinalizeResult(&ignored, &ok)); - } - - /// Manage state of avalanching operations : completion queue tags that - /// trigger other completion queue operations. The underlying core completion - /// queue should not really shutdown until all avalanching operations have - /// been finalized. Note that we maintain the requirement that an avalanche - /// registration must take place before CQ shutdown (which must be maintained - /// elsehwere) - void InitialAvalanching() { - gpr_atm_rel_store(&avalanches_in_flight_, static_cast(1)); - } - void RegisterAvalanching() { - gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_, - static_cast(1)); - } - void CompleteAvalanching() { - if (gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_, - static_cast(-1)) == 1) { - ::grpc::g_core_codegen_interface->grpc_completion_queue_shutdown(cq_); - } - } - - grpc_completion_queue* cq_; // owned - - gpr_atm avalanches_in_flight_; -}; - -/// A specific type of completion queue used by the processing of notifications -/// by servers. Instantiated by \a ServerBuilder. -class ServerCompletionQueue : public CompletionQueue { - public: - bool IsFrequentlyPolled() { return polling_type_ != GRPC_CQ_NON_LISTENING; } - - protected: - /// Default constructor - ServerCompletionQueue() : polling_type_(GRPC_CQ_DEFAULT_POLLING) {} - - private: - /// \param completion_type indicates whether this is a NEXT or CALLBACK - /// completion queue. - /// \param polling_type Informs the GRPC library about the type of polling - /// allowed on this completion queue. See grpc_cq_polling_type's description - /// in grpc_types.h for more details. - /// \param shutdown_cb is the shutdown callback used for CALLBACK api queues - ServerCompletionQueue(grpc_cq_completion_type completion_type, - grpc_cq_polling_type polling_type, - grpc_experimental_completion_queue_functor* shutdown_cb) - : CompletionQueue(grpc_completion_queue_attributes{ - GRPC_CQ_CURRENT_VERSION, completion_type, polling_type, - shutdown_cb}), - polling_type_(polling_type) {} - - grpc_cq_polling_type polling_type_; - friend class ::grpc_impl::ServerBuilder; - friend class ::grpc_impl::Server; -}; - -} // namespace grpc_impl - -#endif // GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_IMPL_H diff --git a/include/grpcpp/impl/codegen/intercepted_channel.h b/include/grpcpp/impl/codegen/intercepted_channel.h index cd0fcc06753..5255a6d1472 100644 --- a/include/grpcpp/impl/codegen/intercepted_channel.h +++ b/include/grpcpp/impl/codegen/intercepted_channel.h @@ -21,10 +21,6 @@ #include -namespace grpc_impl { -class CompletionQueue; -} - namespace grpc { namespace internal { @@ -50,7 +46,7 @@ class InterceptedChannel : public ChannelInterface { : channel_(channel), interceptor_pos_(pos) {} Call CreateCall(const RpcMethod& method, ClientContext* context, - ::grpc_impl::CompletionQueue* cq) override { + CompletionQueue* cq) override { return channel_->CreateCallInternal(method, context, cq, interceptor_pos_); } @@ -62,8 +58,7 @@ class InterceptedChannel : public ChannelInterface { } void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, - gpr_timespec deadline, - ::grpc_impl::CompletionQueue* cq, + gpr_timespec deadline, CompletionQueue* cq, void* tag) override { return channel_->NotifyOnStateChangeImpl(last_observed, deadline, cq, tag); } @@ -72,9 +67,7 @@ class InterceptedChannel : public ChannelInterface { return channel_->WaitForStateChangeImpl(last_observed, deadline); } - ::grpc_impl::CompletionQueue* CallbackCQ() override { - return channel_->CallbackCQ(); - } + CompletionQueue* CallbackCQ() override { return channel_->CallbackCQ(); } ChannelInterface* channel_; size_t interceptor_pos_; diff --git a/include/grpcpp/impl/codegen/server_context.h b/include/grpcpp/impl/codegen/server_context.h index c6903743938..f65598db41f 100644 --- a/include/grpcpp/impl/codegen/server_context.h +++ b/include/grpcpp/impl/codegen/server_context.h @@ -43,12 +43,12 @@ struct census_context; namespace grpc_impl { -class CompletionQueue; class Server; } // namespace grpc_impl namespace grpc { class ClientContext; class GenericServerContext; +class CompletionQueue; class ServerInterface; template class ServerAsyncReader; @@ -90,7 +90,6 @@ class Call; class ServerReactor; } // namespace internal -class ServerInterface; namespace testing { class InteropServerContextInspector; class ServerContextTestSpouse; @@ -355,7 +354,7 @@ class ServerContext { gpr_timespec deadline_; grpc_call* call_; - ::grpc_impl::CompletionQueue* cq_; + CompletionQueue* cq_; bool sent_initial_metadata_; mutable std::shared_ptr auth_context_; mutable internal::MetadataMap client_metadata_; diff --git a/include/grpcpp/impl/codegen/server_interface.h b/include/grpcpp/impl/codegen/server_interface.h index 10dc6ab7c13..8e666d23339 100644 --- a/include/grpcpp/impl/codegen/server_interface.h +++ b/include/grpcpp/impl/codegen/server_interface.h @@ -30,8 +30,6 @@ namespace grpc_impl { -class CompletionQueue; -class ServerCompletionQueue; class Channel; class ServerCredentials; } // namespace grpc_impl @@ -39,6 +37,7 @@ namespace grpc { class AsyncGenericService; class GenericServerContext; +class ServerCompletionQueue; class ServerContext; class Service; @@ -162,8 +161,7 @@ class ServerInterface : public internal::CallHook { /// caller is required to keep all completion queues live until the server is /// destroyed. /// \param num_cqs How many completion queues does \a cqs hold. - virtual void Start(::grpc_impl::ServerCompletionQueue** cqs, - size_t num_cqs) = 0; + virtual void Start(ServerCompletionQueue** cqs, size_t num_cqs) = 0; virtual void ShutdownInternal(gpr_timespec deadline) = 0; @@ -178,9 +176,9 @@ class ServerInterface : public internal::CallHook { public: BaseAsyncRequest(ServerInterface* server, ServerContext* context, internal::ServerAsyncStreamingInterface* stream, - ::grpc_impl::CompletionQueue* call_cq, - ::grpc_impl::ServerCompletionQueue* notification_cq, - void* tag, bool delete_on_finalize); + CompletionQueue* call_cq, + ServerCompletionQueue* notification_cq, void* tag, + bool delete_on_finalize); virtual ~BaseAsyncRequest(); bool FinalizeResult(void** tag, bool* status) override; @@ -192,8 +190,8 @@ class ServerInterface : public internal::CallHook { ServerInterface* const server_; ServerContext* const context_; internal::ServerAsyncStreamingInterface* const stream_; - ::grpc_impl::CompletionQueue* const call_cq_; - ::grpc_impl::ServerCompletionQueue* const notification_cq_; + CompletionQueue* const call_cq_; + ServerCompletionQueue* const notification_cq_; void* const tag_; const bool delete_on_finalize_; grpc_call* call_; @@ -207,17 +205,16 @@ class ServerInterface : public internal::CallHook { public: RegisteredAsyncRequest(ServerInterface* server, ServerContext* context, internal::ServerAsyncStreamingInterface* stream, - ::grpc_impl::CompletionQueue* call_cq, - ::grpc_impl::ServerCompletionQueue* notification_cq, - void* tag, const char* name, - internal::RpcMethod::RpcType type); + CompletionQueue* call_cq, + ServerCompletionQueue* notification_cq, void* tag, + const char* name, internal::RpcMethod::RpcType type); virtual bool FinalizeResult(void** tag, bool* status) override { /* If we are done intercepting, then there is nothing more for us to do */ if (done_intercepting_) { return BaseAsyncRequest::FinalizeResult(tag, status); } - call_wrapper_ = ::grpc::internal::Call( + call_wrapper_ = internal::Call( call_, server_, call_cq_, server_->max_receive_message_size(), context_->set_server_rpc_info(name_, type_, *server_->interceptor_creators())); @@ -226,7 +223,7 @@ class ServerInterface : public internal::CallHook { protected: void IssueRequest(void* registered_method, grpc_byte_buffer** payload, - ::grpc_impl::ServerCompletionQueue* notification_cq); + ServerCompletionQueue* notification_cq); const char* name_; const internal::RpcMethod::RpcType type_; }; @@ -236,9 +233,8 @@ class ServerInterface : public internal::CallHook { NoPayloadAsyncRequest(internal::RpcServiceMethod* registered_method, ServerInterface* server, ServerContext* context, internal::ServerAsyncStreamingInterface* stream, - ::grpc_impl::CompletionQueue* call_cq, - ::grpc_impl::ServerCompletionQueue* notification_cq, - void* tag) + CompletionQueue* call_cq, + ServerCompletionQueue* notification_cq, void* tag) : RegisteredAsyncRequest( server, context, stream, call_cq, notification_cq, tag, registered_method->name(), registered_method->method_type()) { @@ -254,9 +250,9 @@ class ServerInterface : public internal::CallHook { PayloadAsyncRequest(internal::RpcServiceMethod* registered_method, ServerInterface* server, ServerContext* context, internal::ServerAsyncStreamingInterface* stream, - ::grpc_impl::CompletionQueue* call_cq, - ::grpc_impl::ServerCompletionQueue* notification_cq, - void* tag, Message* request) + CompletionQueue* call_cq, + ServerCompletionQueue* notification_cq, void* tag, + Message* request) : RegisteredAsyncRequest( server, context, stream, call_cq, notification_cq, tag, registered_method->name(), registered_method->method_type()), @@ -311,9 +307,9 @@ class ServerInterface : public internal::CallHook { ServerInterface* const server_; ServerContext* const context_; internal::ServerAsyncStreamingInterface* const stream_; - ::grpc_impl::CompletionQueue* const call_cq_; + CompletionQueue* const call_cq_; - ::grpc_impl::ServerCompletionQueue* const notification_cq_; + ServerCompletionQueue* const notification_cq_; void* const tag_; Message* const request_; ByteBuffer payload_; @@ -323,9 +319,9 @@ class ServerInterface : public internal::CallHook { public: GenericAsyncRequest(ServerInterface* server, GenericServerContext* context, internal::ServerAsyncStreamingInterface* stream, - ::grpc_impl::CompletionQueue* call_cq, - ::grpc_impl::ServerCompletionQueue* notification_cq, - void* tag, bool delete_on_finalize); + CompletionQueue* call_cq, + ServerCompletionQueue* notification_cq, void* tag, + bool delete_on_finalize); bool FinalizeResult(void** tag, bool* status) override; @@ -337,9 +333,9 @@ class ServerInterface : public internal::CallHook { void RequestAsyncCall(internal::RpcServiceMethod* method, ServerContext* context, internal::ServerAsyncStreamingInterface* stream, - ::grpc_impl::CompletionQueue* call_cq, - ::grpc_impl::ServerCompletionQueue* notification_cq, - void* tag, Message* message) { + CompletionQueue* call_cq, + ServerCompletionQueue* notification_cq, void* tag, + Message* message) { GPR_CODEGEN_ASSERT(method); new PayloadAsyncRequest(method, this, context, stream, call_cq, notification_cq, tag, message); @@ -348,19 +344,18 @@ class ServerInterface : public internal::CallHook { void RequestAsyncCall(internal::RpcServiceMethod* method, ServerContext* context, internal::ServerAsyncStreamingInterface* stream, - ::grpc_impl::CompletionQueue* call_cq, - ::grpc_impl::ServerCompletionQueue* notification_cq, - void* tag) { + CompletionQueue* call_cq, + ServerCompletionQueue* notification_cq, void* tag) { GPR_CODEGEN_ASSERT(method); new NoPayloadAsyncRequest(method, this, context, stream, call_cq, notification_cq, tag); } - void RequestAsyncGenericCall( - GenericServerContext* context, - internal::ServerAsyncStreamingInterface* stream, - ::grpc_impl::CompletionQueue* call_cq, - ::grpc_impl::ServerCompletionQueue* notification_cq, void* tag) { + void RequestAsyncGenericCall(GenericServerContext* context, + internal::ServerAsyncStreamingInterface* stream, + CompletionQueue* call_cq, + ServerCompletionQueue* notification_cq, + void* tag) { new GenericAsyncRequest(this, context, stream, call_cq, notification_cq, tag, true); } @@ -385,7 +380,7 @@ class ServerInterface : public internal::CallHook { // Returns nullptr (rather than being pure) since this is a post-1.0 method // and adding a new pure method to an interface would be a breaking change // (even though this is private and non-API) - virtual ::grpc_impl::CompletionQueue* CallbackCQ() { return nullptr; } + virtual CompletionQueue* CallbackCQ() { return nullptr; } }; } // namespace grpc diff --git a/include/grpcpp/impl/codegen/service_type.h b/include/grpcpp/impl/codegen/service_type.h index f1d1272dc20..762b049212f 100644 --- a/include/grpcpp/impl/codegen/service_type.h +++ b/include/grpcpp/impl/codegen/service_type.h @@ -29,11 +29,12 @@ namespace grpc_impl { class Server; -class CompletionQueue; } // namespace grpc_impl namespace grpc { +class CompletionQueue; class ServerInterface; +class ServerCompletionQueue; class ServerContext; namespace internal { diff --git a/include/grpcpp/server_builder.h b/include/grpcpp/server_builder.h index d9ec7c42f3d..89c4eba1d95 100644 --- a/include/grpcpp/server_builder.h +++ b/include/grpcpp/server_builder.h @@ -21,6 +21,13 @@ #include +namespace grpc_impl { + +class Server; +class ServerCredentials; +class ResourceQuota; +} // namespace grpc_impl + namespace grpc { typedef ::grpc_impl::ServerBuilder ServerBuilder; diff --git a/include/grpcpp/server_builder_impl.h b/include/grpcpp/server_builder_impl.h index 57f8dc076a4..f7624deba5f 100644 --- a/include/grpcpp/server_builder_impl.h +++ b/include/grpcpp/server_builder_impl.h @@ -38,15 +38,14 @@ struct grpc_resource_quota; namespace grpc_impl { -class CompletionQueue; class ResourceQuota; -class Server; -class ServerCompletionQueue; class ServerCredentials; } // namespace grpc_impl namespace grpc { class AsyncGenericService; +class CompletionQueue; +class ServerCompletionQueue; class Service; namespace testing { @@ -134,7 +133,7 @@ class ServerBuilder { /// not polling the completion queue frequently) will have a significantly /// negative performance impact and hence should not be used in production /// use cases. - std::unique_ptr AddCompletionQueue( + std::unique_ptr AddCompletionQueue( bool is_frequently_polled = true); ////////////////////////////////////////////////////////////////////////////// @@ -328,7 +327,7 @@ class ServerBuilder { SyncServerSettings sync_server_settings_; /// List of completion queues added via \a AddCompletionQueue method. - std::vector cqs_; + std::vector cqs_; std::shared_ptr creds_; std::vector> plugins_; diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index 77cd7b5ab35..b9133c2ed0a 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -156,16 +156,14 @@ grpc::string GetHeaderIncludes(grpc_generator::File* file, printer->Print(vars, "\n"); printer->Print(vars, "namespace grpc_impl {\n"); printer->Print(vars, "class Channel;\n"); - printer->Print(vars, "class CompletionQueue;\n"); - printer->Print(vars, "class ServerCompletionQueue;\n"); printer->Print(vars, "} // namespace grpc_impl\n\n"); printer->Print(vars, "namespace grpc {\n"); printer->Print(vars, "namespace experimental {\n"); printer->Print(vars, "template \n"); printer->Print(vars, "class MessageAllocator;\n"); printer->Print(vars, "} // namespace experimental\n"); - printer->Print(vars, "} // namespace grpc_impl\n\n"); - printer->Print(vars, "namespace grpc {\n"); + printer->Print(vars, "class CompletionQueue;\n"); + printer->Print(vars, "class ServerCompletionQueue;\n"); printer->Print(vars, "class ServerContext;\n"); printer->Print(vars, "} // namespace grpc\n\n"); diff --git a/src/cpp/common/completion_queue_cc.cc b/src/cpp/common/completion_queue_cc.cc index 43c2eee96f8..4bb3bcbd8b6 100644 --- a/src/cpp/common/completion_queue_cc.cc +++ b/src/cpp/common/completion_queue_cc.cc @@ -24,9 +24,9 @@ #include #include -namespace grpc_impl { +namespace grpc { -static ::grpc::internal::GrpcLibraryInitializer g_gli_initializer; +static internal::GrpcLibraryInitializer g_gli_initializer; // 'CompletionQueue' constructor can safely call GrpcLibraryCodegen(false) here // i.e not have GrpcLibraryCodegen call grpc_init(). This is because, to create @@ -52,8 +52,7 @@ CompletionQueue::NextStatus CompletionQueue::AsyncNextInternal( case GRPC_QUEUE_SHUTDOWN: return SHUTDOWN; case GRPC_OP_COMPLETE: - auto core_cq_tag = - static_cast<::grpc::internal::CompletionQueueTag*>(ev.tag); + auto core_cq_tag = static_cast(ev.tag); *ok = ev.success != 0; *tag = core_cq_tag; if (core_cq_tag->FinalizeResult(tag, ok)) { @@ -80,8 +79,7 @@ bool CompletionQueue::CompletionQueueTLSCache::Flush(void** tag, bool* ok) { flushed_ = true; if (grpc_completion_queue_thread_local_cache_flush(cq_->cq_, &res_tag, &res)) { - auto core_cq_tag = - static_cast<::grpc::internal::CompletionQueueTag*>(res_tag); + auto core_cq_tag = static_cast(res_tag); *ok = res == 1; if (core_cq_tag->FinalizeResult(tag, ok)) { return true; @@ -90,4 +88,4 @@ bool CompletionQueue::CompletionQueueTLSCache::Flush(void** tag, bool* ok) { return false; } -} // namespace grpc_impl +} // namespace grpc diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index e571a95bb3e..30e0a17e4c7 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -42,8 +42,6 @@ namespace grpc_impl { class Channel; -class CompletionQueue; -class ServerCompletionQueue; } // namespace grpc_impl namespace grpc { @@ -51,9 +49,8 @@ namespace experimental { template class MessageAllocator; } // namespace experimental -} // namespace grpc_impl - -namespace grpc { +class CompletionQueue; +class ServerCompletionQueue; class ServerContext; } // namespace grpc diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 667b9b3541e..4e524077e37 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -959,7 +959,6 @@ include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ -include/grpcpp/impl/codegen/completion_queue_impl.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/config.h \ include/grpcpp/impl/codegen/config_protobuf.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 529b35a2c39..6741ffb5ace 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -960,7 +960,6 @@ include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ -include/grpcpp/impl/codegen/completion_queue_impl.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/config.h \ include/grpcpp/impl/codegen/config_protobuf.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 2754bf2171e..ea40c25195f 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -10092,7 +10092,6 @@ "include/grpcpp/impl/codegen/client_interceptor.h", "include/grpcpp/impl/codegen/client_unary_call.h", "include/grpcpp/impl/codegen/completion_queue.h", - "include/grpcpp/impl/codegen/completion_queue_impl.h", "include/grpcpp/impl/codegen/completion_queue_tag.h", "include/grpcpp/impl/codegen/config.h", "include/grpcpp/impl/codegen/core_codegen_interface.h", @@ -10170,7 +10169,6 @@ "include/grpcpp/impl/codegen/client_interceptor.h", "include/grpcpp/impl/codegen/client_unary_call.h", "include/grpcpp/impl/codegen/completion_queue.h", - "include/grpcpp/impl/codegen/completion_queue_impl.h", "include/grpcpp/impl/codegen/completion_queue_tag.h", "include/grpcpp/impl/codegen/config.h", "include/grpcpp/impl/codegen/core_codegen_interface.h", From 772a74acedbcf95a2b04b4211788648eaa30d29a Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 15 May 2019 13:55:45 -0700 Subject: [PATCH 0224/1555] Revert changes to Channel --- BUILD | 1 - BUILD.gn | 1 - CMakeLists.txt | 3 - Makefile | 3 - build.yaml | 1 - gRPC-C++.podspec | 1 - include/grpcpp/channel.h | 94 ++++++++++++- include/grpcpp/channel_impl.h | 124 ------------------ include/grpcpp/impl/codegen/client_callback.h | 5 +- include/grpcpp/impl/codegen/client_context.h | 8 +- .../grpcpp/impl/codegen/client_interceptor.h | 6 +- .../grpcpp/impl/codegen/completion_queue.h | 4 +- .../grpcpp/impl/codegen/server_interface.h | 2 +- include/grpcpp/security/credentials_impl.h | 1 - include/grpcpp/server_impl.h | 5 +- src/compiler/cpp_generator.cc | 4 +- src/cpp/client/channel_cc.cc | 49 ++++--- src/cpp/client/client_context.cc | 7 +- src/cpp/client/create_channel_internal.cc | 2 +- src/cpp/client/create_channel_internal.h | 2 +- src/cpp/client/create_channel_posix.cc | 6 +- src/cpp/client/secure_credentials.h | 2 - test/cpp/codegen/compiler_test_golden | 5 +- test/cpp/codegen/golden_file_test.cc | 2 +- test/cpp/microbenchmarks/fullstack_fixtures.h | 2 +- test/cpp/performance/writes_per_rpc_test.cc | 2 +- test/cpp/util/create_test_channel.h | 18 +-- tools/doxygen/Doxyfile.c++ | 1 - tools/doxygen/Doxyfile.c++.internal | 1 - .../generated/sources_and_headers.json | 2 - 30 files changed, 138 insertions(+), 226 deletions(-) delete mode 100644 include/grpcpp/channel_impl.h diff --git a/BUILD b/BUILD index 4a6dc7de969..fef4a5e8646 100644 --- a/BUILD +++ b/BUILD @@ -216,7 +216,6 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/alarm.h", "include/grpcpp/alarm_impl.h", "include/grpcpp/channel.h", - "include/grpcpp/channel_impl.h", "include/grpcpp/client_context.h", "include/grpcpp/completion_queue.h", "include/grpcpp/create_channel.h", diff --git a/BUILD.gn b/BUILD.gn index 25f1c69253a..9b6e4e5b392 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1022,7 +1022,6 @@ config("grpc_config") { "include/grpcpp/alarm.h", "include/grpcpp/alarm_impl.h", "include/grpcpp/channel.h", - "include/grpcpp/channel_impl.h", "include/grpcpp/client_context.h", "include/grpcpp/completion_queue.h", "include/grpcpp/create_channel.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a65c46a81e..2096e961a71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3148,7 +3148,6 @@ foreach(_hdr include/grpcpp/alarm.h include/grpcpp/alarm_impl.h include/grpcpp/channel.h - include/grpcpp/channel_impl.h include/grpcpp/client_context.h include/grpcpp/completion_queue.h include/grpcpp/create_channel.h @@ -3763,7 +3762,6 @@ foreach(_hdr include/grpcpp/alarm.h include/grpcpp/alarm_impl.h include/grpcpp/channel.h - include/grpcpp/channel_impl.h include/grpcpp/client_context.h include/grpcpp/completion_queue.h include/grpcpp/create_channel.h @@ -4750,7 +4748,6 @@ foreach(_hdr include/grpcpp/alarm.h include/grpcpp/alarm_impl.h include/grpcpp/channel.h - include/grpcpp/channel_impl.h include/grpcpp/client_context.h include/grpcpp/completion_queue.h include/grpcpp/create_channel.h diff --git a/Makefile b/Makefile index 0c86c313b1f..78e4a42608a 100644 --- a/Makefile +++ b/Makefile @@ -5501,7 +5501,6 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/alarm.h \ include/grpcpp/alarm_impl.h \ include/grpcpp/channel.h \ - include/grpcpp/channel_impl.h \ include/grpcpp/client_context.h \ include/grpcpp/completion_queue.h \ include/grpcpp/create_channel.h \ @@ -6124,7 +6123,6 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/alarm.h \ include/grpcpp/alarm_impl.h \ include/grpcpp/channel.h \ - include/grpcpp/channel_impl.h \ include/grpcpp/client_context.h \ include/grpcpp/completion_queue.h \ include/grpcpp/create_channel.h \ @@ -7060,7 +7058,6 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/alarm.h \ include/grpcpp/alarm_impl.h \ include/grpcpp/channel.h \ - include/grpcpp/channel_impl.h \ include/grpcpp/client_context.h \ include/grpcpp/completion_queue.h \ include/grpcpp/create_channel.h \ diff --git a/build.yaml b/build.yaml index a5a46194772..c58eb12d8e9 100644 --- a/build.yaml +++ b/build.yaml @@ -1350,7 +1350,6 @@ filegroups: - include/grpcpp/alarm.h - include/grpcpp/alarm_impl.h - include/grpcpp/channel.h - - include/grpcpp/channel_impl.h - include/grpcpp/client_context.h - include/grpcpp/completion_queue.h - include/grpcpp/create_channel.h diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index e1000342e0e..e2eb65b309a 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -82,7 +82,6 @@ Pod::Spec.new do |s| ss.source_files = 'include/grpcpp/alarm.h', 'include/grpcpp/alarm_impl.h', 'include/grpcpp/channel.h', - 'include/grpcpp/channel_impl.h', 'include/grpcpp/client_context.h', 'include/grpcpp/completion_queue.h', 'include/grpcpp/create_channel.h', diff --git a/include/grpcpp/channel.h b/include/grpcpp/channel.h index 163c804ffbe..434f2688da8 100644 --- a/include/grpcpp/channel.h +++ b/include/grpcpp/channel.h @@ -16,15 +16,25 @@ * */ -#ifndef GRPCPP_CHANNEL_H -#define GRPCPP_CHANNEL_H +#ifndef GRPCPP_CHANNEL_IMPL_H +#define GRPCPP_CHANNEL_IMPL_H -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +struct grpc_channel; namespace grpc { -typedef ::grpc_impl::Channel Channel; - namespace experimental { /// Resets the channel's connection backoff. /// TODO(roth): Once we see whether this proves useful, either create a gRFC @@ -32,6 +42,76 @@ namespace experimental { void ChannelResetConnectionBackoff(Channel* channel); } // namespace experimental -} // namespace grpc +/// Channels represent a connection to an endpoint. Created by \a CreateChannel. +class Channel final : public ChannelInterface, + public internal::CallHook, + public std::enable_shared_from_this, + private GrpcLibraryCodegen { + public: + ~Channel(); -#endif // GRPCPP_CHANNEL_H + /// Get the current channel state. If the channel is in IDLE and + /// \a try_to_connect is set to true, try to connect. + grpc_connectivity_state GetState(bool try_to_connect) override; + + /// Returns the LB policy name, or the empty string if not yet available. + grpc::string GetLoadBalancingPolicyName() const; + + /// Returns the service config in JSON form, or the empty string if + /// not available. + grpc::string GetServiceConfigJSON() const; + + private: + template + friend class internal::BlockingUnaryCallImpl; + friend void experimental::ChannelResetConnectionBackoff(Channel* channel); + friend std::shared_ptr CreateChannelInternal( + const grpc::string& host, grpc_channel* c_channel, + std::vector> + interceptor_creators); + friend class internal::InterceptedChannel; + Channel(const grpc::string& host, grpc_channel* c_channel, + std::vector> + interceptor_creators); + + internal::Call CreateCall(const internal::RpcMethod& method, + ClientContext* context, + CompletionQueue* cq) override; + void PerformOpsOnCall(internal::CallOpSetInterface* ops, + internal::Call* call) override; + void* RegisterMethod(const char* method) override; + + void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline, + CompletionQueue* cq, void* tag) override; + bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline) override; + + CompletionQueue* CallbackCQ() override; + + internal::Call CreateCallInternal( + const internal::RpcMethod& method, ClientContext* context, + CompletionQueue* cq, size_t interceptor_pos) override; + + const grpc::string host_; + grpc_channel* const c_channel_; // owned + + // mu_ protects callback_cq_ (the per-channel callbackable completion queue) + grpc::internal::Mutex mu_; + + // callback_cq_ references the callbackable completion queue associated + // with this channel (if any). It is set on the first call to CallbackCQ(). + // It is _not owned_ by the channel; ownership belongs with its internal + // shutdown callback tag (invoked when the CQ is fully shutdown). + CompletionQueue* callback_cq_ = nullptr; + + std::vector< + std::unique_ptr> + interceptor_creators_; +}; + +} // namespace grpc_impl + +#endif // GRPCPP_CHANNEL_IMPL_H diff --git a/include/grpcpp/channel_impl.h b/include/grpcpp/channel_impl.h deleted file mode 100644 index 94dcd2ff5bd..00000000000 --- a/include/grpcpp/channel_impl.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_CHANNEL_IMPL_H -#define GRPCPP_CHANNEL_IMPL_H - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -struct grpc_channel; - -namespace grpc { - -std::shared_ptr<::grpc_impl::Channel> CreateChannelInternal( - const grpc::string& host, grpc_channel* c_channel, - std::vector< - std::unique_ptr> - interceptor_creators); -} // namespace grpc -namespace grpc_impl { - -namespace experimental { -/// Resets the channel's connection backoff. -/// TODO(roth): Once we see whether this proves useful, either create a gRFC -/// and change this to be a method of the Channel class, or remove it. -void ChannelResetConnectionBackoff(Channel* channel); -} // namespace experimental - -/// Channels represent a connection to an endpoint. Created by \a CreateChannel. -class Channel final : public ::grpc::ChannelInterface, - public ::grpc::internal::CallHook, - public std::enable_shared_from_this, - private ::grpc::GrpcLibraryCodegen { - public: - ~Channel(); - - /// Get the current channel state. If the channel is in IDLE and - /// \a try_to_connect is set to true, try to connect. - grpc_connectivity_state GetState(bool try_to_connect) override; - - /// Returns the LB policy name, or the empty string if not yet available. - grpc::string GetLoadBalancingPolicyName() const; - - /// Returns the service config in JSON form, or the empty string if - /// not available. - grpc::string GetServiceConfigJSON() const; - - private: - template - friend class ::grpc::internal::BlockingUnaryCallImpl; - friend void experimental::ChannelResetConnectionBackoff(Channel* channel); - friend std::shared_ptr grpc::CreateChannelInternal( - const grpc::string& host, grpc_channel* c_channel, - std::vector> - interceptor_creators); - friend class ::grpc::internal::InterceptedChannel; - Channel(const grpc::string& host, grpc_channel* c_channel, - std::vector> - interceptor_creators); - - ::grpc::internal::Call CreateCall(const ::grpc::internal::RpcMethod& method, - ::grpc::ClientContext* context, - ::grpc::CompletionQueue* cq) override; - void PerformOpsOnCall(::grpc::internal::CallOpSetInterface* ops, - ::grpc::internal::Call* call) override; - void* RegisterMethod(const char* method) override; - - void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, - gpr_timespec deadline, - ::grpc::CompletionQueue* cq, void* tag) override; - bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, - gpr_timespec deadline) override; - - ::grpc::CompletionQueue* CallbackCQ() override; - - ::grpc::internal::Call CreateCallInternal( - const ::grpc::internal::RpcMethod& method, ::grpc::ClientContext* context, - ::grpc::CompletionQueue* cq, size_t interceptor_pos) override; - - const grpc::string host_; - grpc_channel* const c_channel_; // owned - - // mu_ protects callback_cq_ (the per-channel callbackable completion queue) - grpc::internal::Mutex mu_; - - // callback_cq_ references the callbackable completion queue associated - // with this channel (if any). It is set on the first call to CallbackCQ(). - // It is _not owned_ by the channel; ownership belongs with its internal - // shutdown callback tag (invoked when the CQ is fully shutdown). - ::grpc::CompletionQueue* callback_cq_ = nullptr; - - std::vector< - std::unique_ptr<::grpc::experimental::ClientInterceptorFactoryInterface>> - interceptor_creators_; -}; - -} // namespace grpc_impl - -#endif // GRPCPP_CHANNEL_IMPL_H diff --git a/include/grpcpp/impl/codegen/client_callback.h b/include/grpcpp/impl/codegen/client_callback.h index f0499858a05..c897f6676d9 100644 --- a/include/grpcpp/impl/codegen/client_callback.h +++ b/include/grpcpp/impl/codegen/client_callback.h @@ -29,12 +29,9 @@ #include #include -namespace grpc_impl { -class Channel; -} - namespace grpc { +class Channel; class ClientContext; class CompletionQueue; diff --git a/include/grpcpp/impl/codegen/client_context.h b/include/grpcpp/impl/codegen/client_context.h index 2e03e08712e..9f0a80f1077 100644 --- a/include/grpcpp/impl/codegen/client_context.h +++ b/include/grpcpp/impl/codegen/client_context.h @@ -60,10 +60,10 @@ struct grpc_call; namespace grpc_impl { class CallCredentials; -class Channel; } // namespace grpc_impl namespace grpc { +class Channel; class ChannelInterface; class CompletionQueue; class ClientContext; @@ -397,7 +397,7 @@ class ClientContext { friend class ::grpc::testing::InteropClientContextInspector; friend class ::grpc::internal::CallOpClientRecvStatus; friend class ::grpc::internal::CallOpRecvInitialMetadata; - friend class ::grpc_impl::Channel; + friend class Channel; template friend class ::grpc::ClientReader; template @@ -431,7 +431,7 @@ class ClientContext { grpc_call* call() const { return call_; } void set_call(grpc_call* call, - const std::shared_ptr<::grpc_impl::Channel>& channel); + const std::shared_ptr& channel); experimental::ClientRpcInfo* set_client_rpc_info( const char* method, internal::RpcMethod::RpcType type, @@ -464,7 +464,7 @@ class ClientContext { bool wait_for_ready_explicitly_set_; bool idempotent_; bool cacheable_; - std::shared_ptr<::grpc_impl::Channel> channel_; + std::shared_ptr channel_; grpc::internal::Mutex mu_; grpc_call* call_; bool call_canceled_; diff --git a/include/grpcpp/impl/codegen/client_interceptor.h b/include/grpcpp/impl/codegen/client_interceptor.h index a4c85a76da5..19106545089 100644 --- a/include/grpcpp/impl/codegen/client_interceptor.h +++ b/include/grpcpp/impl/codegen/client_interceptor.h @@ -26,14 +26,10 @@ #include #include -namespace grpc_impl { - -class Channel; -} - namespace grpc { class ClientContext; +class Channel; namespace internal { class InterceptorBatchMethodsImpl; diff --git a/include/grpcpp/impl/codegen/completion_queue.h b/include/grpcpp/impl/codegen/completion_queue.h index c0b1e04d007..5afff52bfb1 100644 --- a/include/grpcpp/impl/codegen/completion_queue.h +++ b/include/grpcpp/impl/codegen/completion_queue.h @@ -43,7 +43,6 @@ struct grpc_completion_queue; namespace grpc_impl { -class Channel; class Server; class ServerBuilder; } // namespace grpc_impl @@ -64,6 +63,7 @@ template class ServerReaderWriterBody; } // namespace internal +class Channel; class ChannelInterface; class ClientContext; class CompletionQueue; @@ -281,7 +281,7 @@ class CompletionQueue : private GrpcLibraryCodegen { friend class ::grpc::internal::BlockingUnaryCallImpl; // Friends that need access to constructor for callback CQ - friend class ::grpc_impl::Channel; + friend class ::grpc::Channel; // For access to Register/CompleteAvalanching template diff --git a/include/grpcpp/impl/codegen/server_interface.h b/include/grpcpp/impl/codegen/server_interface.h index 8e666d23339..ebad4eb25e1 100644 --- a/include/grpcpp/impl/codegen/server_interface.h +++ b/include/grpcpp/impl/codegen/server_interface.h @@ -30,12 +30,12 @@ namespace grpc_impl { -class Channel; class ServerCredentials; } // namespace grpc_impl namespace grpc { class AsyncGenericService; +class Channel; class GenericServerContext; class ServerCompletionQueue; class ServerContext; diff --git a/include/grpcpp/security/credentials_impl.h b/include/grpcpp/security/credentials_impl.h index 29ba2075c29..dec60b11eb4 100644 --- a/include/grpcpp/security/credentials_impl.h +++ b/include/grpcpp/security/credentials_impl.h @@ -24,7 +24,6 @@ #include #include -#include #include #include #include diff --git a/include/grpcpp/server_impl.h b/include/grpcpp/server_impl.h index 9d02af8d11f..d4f33f185d9 100644 --- a/include/grpcpp/server_impl.h +++ b/include/grpcpp/server_impl.h @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -105,7 +104,7 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { } /// Establish a channel for in-process communication - std::shared_ptr<::grpc::Channel> InProcessChannel( + std::shared_ptr InProcessChannel( const grpc::ChannelArguments& args); /// NOTE: class experimental_type is not part of the public API of this class. @@ -117,7 +116,7 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { /// Establish a channel for in-process communication with client /// interceptors - std::shared_ptr<::grpc::Channel> InProcessChannelWithInterceptors( + std::shared_ptr InProcessChannelWithInterceptors( const grpc::ChannelArguments& args, std::vector> diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index b9133c2ed0a..ecec3206577 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -154,15 +154,13 @@ grpc::string GetHeaderIncludes(grpc_generator::File* file, PrintIncludes(printer.get(), headers, params.use_system_headers, params.grpc_search_path); printer->Print(vars, "\n"); - printer->Print(vars, "namespace grpc_impl {\n"); - printer->Print(vars, "class Channel;\n"); - printer->Print(vars, "} // namespace grpc_impl\n\n"); printer->Print(vars, "namespace grpc {\n"); printer->Print(vars, "namespace experimental {\n"); printer->Print(vars, "template \n"); printer->Print(vars, "class MessageAllocator;\n"); printer->Print(vars, "} // namespace experimental\n"); printer->Print(vars, "class CompletionQueue;\n"); + printer->Print(vars, "class Channel;\n"); printer->Print(vars, "class ServerCompletionQueue;\n"); printer->Print(vars, "class ServerContext;\n"); printer->Print(vars, "} // namespace grpc\n\n"); diff --git a/src/cpp/client/channel_cc.cc b/src/cpp/client/channel_cc.cc index 58f012d8c82..bc0005dab1f 100644 --- a/src/cpp/client/channel_cc.cc +++ b/src/cpp/client/channel_cc.cc @@ -42,17 +42,12 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/surface/completion_queue.h" -void grpc::experimental::ChannelResetConnectionBackoff( - ::grpc::Channel* channel) { - grpc_impl::experimental::ChannelResetConnectionBackoff(channel); -} +namespace grpc { -namespace grpc_impl { - -static ::grpc::internal::GrpcLibraryInitializer g_gli_initializer; +static internal::GrpcLibraryInitializer g_gli_initializer; Channel::Channel(const grpc::string& host, grpc_channel* channel, std::vector> + experimental::ClientInterceptorFactoryInterface>> interceptor_creators) : host_(host), c_channel_(channel) { interceptor_creators_ = std::move(interceptor_creators); @@ -69,7 +64,7 @@ Channel::~Channel() { namespace { inline grpc_slice SliceFromArray(const char* arr, size_t len) { - return ::grpc::g_core_codegen_interface->grpc_slice_from_copied_buffer(arr, + return g_core_codegen_interface->grpc_slice_from_copied_buffer(arr, len); } @@ -108,9 +103,9 @@ void ChannelResetConnectionBackoff(Channel* channel) { } // namespace experimental -::grpc::internal::Call Channel::CreateCallInternal( - const ::grpc::internal::RpcMethod& method, ::grpc::ClientContext* context, - ::grpc::CompletionQueue* cq, size_t interceptor_pos) { +internal::Call Channel::CreateCallInternal( + const internal::RpcMethod& method, ClientContext* context, + CompletionQueue* cq, size_t interceptor_pos) { const bool kRegistered = method.channel_tag() && context->authority().empty(); grpc_call* c_call = nullptr; if (kRegistered) { @@ -119,7 +114,7 @@ void ChannelResetConnectionBackoff(Channel* channel) { context->propagation_options_.c_bitmask(), cq->cq(), method.channel_tag(), context->raw_deadline(), nullptr); } else { - const ::grpc::string* host_str = nullptr; + const string* host_str = nullptr; if (!context->authority_.empty()) { host_str = &context->authority_; } else if (!host_.empty()) { @@ -129,7 +124,7 @@ void ChannelResetConnectionBackoff(Channel* channel) { SliceFromArray(method.name(), strlen(method.name())); grpc_slice host_slice; if (host_str != nullptr) { - host_slice = ::grpc::SliceFromCopiedString(*host_str); + host_slice = SliceFromCopiedString(*host_str); } c_call = grpc_channel_create_call( c_channel_, context->propagate_from_call_, @@ -151,17 +146,17 @@ void ChannelResetConnectionBackoff(Channel* channel) { interceptor_creators_, interceptor_pos); context->set_call(c_call, shared_from_this()); - return ::grpc::internal::Call(c_call, this, cq, info); + return internal::Call(c_call, this, cq, info); } ::grpc::internal::Call Channel::CreateCall( - const ::grpc::internal::RpcMethod& method, ::grpc::ClientContext* context, - ::grpc::CompletionQueue* cq) { + const internal::RpcMethod& method, ClientContext* context, + CompletionQueue* cq) { return CreateCallInternal(method, context, cq, 0); } -void Channel::PerformOpsOnCall(::grpc::internal::CallOpSetInterface* ops, - ::grpc::internal::Call* call) { +void Channel::PerformOpsOnCall(internal::CallOpSetInterface* ops, + internal::Call* call) { ops->FillOps( call); // Make a copy of call. It's fine since Call just has pointers } @@ -177,7 +172,7 @@ grpc_connectivity_state Channel::GetState(bool try_to_connect) { namespace { -class TagSaver final : public ::grpc::internal::CompletionQueueTag { +class TagSaver final : public internal::CompletionQueueTag { public: explicit TagSaver(void* tag) : tag_(tag) {} ~TagSaver() override {} @@ -195,7 +190,7 @@ class TagSaver final : public ::grpc::internal::CompletionQueueTag { void Channel::NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline, - ::grpc::CompletionQueue* cq, void* tag) { + CompletionQueue* cq, void* tag) { TagSaver* tag_saver = new TagSaver(tag); grpc_channel_watch_connectivity_state(c_channel_, last_observed, deadline, cq->cq(), tag_saver); @@ -203,7 +198,7 @@ void Channel::NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, bool Channel::WaitForStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline) { - ::grpc::CompletionQueue cq; + CompletionQueue cq; bool ok = false; void* tag = nullptr; NotifyOnStateChangeImpl(last_observed, deadline, &cq, nullptr); @@ -218,7 +213,7 @@ class ShutdownCallback : public grpc_experimental_completion_queue_functor { ShutdownCallback() { functor_run = &ShutdownCallback::Run; } // TakeCQ takes ownership of the cq into the shutdown callback // so that the shutdown callback will be responsible for destroying it - void TakeCQ(::grpc::CompletionQueue* cq) { cq_ = cq; } + void TakeCQ(CompletionQueue* cq) { cq_ = cq; } // The Run function will get invoked by the completion queue library // when the shutdown is actually complete @@ -229,17 +224,17 @@ class ShutdownCallback : public grpc_experimental_completion_queue_functor { } private: - ::grpc::CompletionQueue* cq_ = nullptr; + CompletionQueue* cq_ = nullptr; }; } // namespace -::grpc::CompletionQueue* Channel::CallbackCQ() { +CompletionQueue* Channel::CallbackCQ() { // TODO(vjpai): Consider using a single global CQ for the default CQ // if there is no explicit per-channel CQ registered grpc::internal::MutexLock l(&mu_); if (callback_cq_ == nullptr) { auto* shutdown_callback = new ShutdownCallback; - callback_cq_ = new ::grpc::CompletionQueue(grpc_completion_queue_attributes{ + callback_cq_ = new CompletionQueue(grpc_completion_queue_attributes{ GRPC_CQ_CURRENT_VERSION, GRPC_CQ_CALLBACK, GRPC_CQ_DEFAULT_POLLING, shutdown_callback}); @@ -249,4 +244,4 @@ class ShutdownCallback : public grpc_experimental_completion_queue_functor { return callback_cq_; } -} // namespace grpc_impl +} // namespace grpc diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index 0ae1ecbf4ba..a2e928f0d4f 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -31,11 +31,6 @@ #include #include -namespace grpc_impl { - -class Channel; -} - namespace grpc { class DefaultGlobalClientCallbacks final @@ -89,7 +84,7 @@ void ClientContext::AddMetadata(const grpc::string& meta_key, } void ClientContext::set_call( - grpc_call* call, const std::shared_ptr<::grpc_impl::Channel>& channel) { + grpc_call* call, const std::shared_ptr& channel) { grpc::internal::MutexLock lock(&mu_); GPR_ASSERT(call_ == nullptr); call_ = call; diff --git a/src/cpp/client/create_channel_internal.cc b/src/cpp/client/create_channel_internal.cc index 63e1d14eb34..e4978a1b4d3 100644 --- a/src/cpp/client/create_channel_internal.cc +++ b/src/cpp/client/create_channel_internal.cc @@ -27,7 +27,7 @@ namespace grpc { std::shared_ptr CreateChannelInternal( const grpc::string& host, grpc_channel* c_channel, std::vector> + experimental::ClientInterceptorFactoryInterface>> interceptor_creators) { return std::shared_ptr( new Channel(host, c_channel, std::move(interceptor_creators))); diff --git a/src/cpp/client/create_channel_internal.h b/src/cpp/client/create_channel_internal.h index 3b201afb5a7..784908e1138 100644 --- a/src/cpp/client/create_channel_internal.h +++ b/src/cpp/client/create_channel_internal.h @@ -31,7 +31,7 @@ namespace grpc { std::shared_ptr CreateChannelInternal( const grpc::string& host, grpc_channel* c_channel, std::vector> + experimental::ClientInterceptorFactoryInterface>> interceptor_creators); } // namespace grpc diff --git a/src/cpp/client/create_channel_posix.cc b/src/cpp/client/create_channel_posix.cc index ca26c3f0a9f..61260a27c66 100644 --- a/src/cpp/client/create_channel_posix.cc +++ b/src/cpp/client/create_channel_posix.cc @@ -34,7 +34,7 @@ std::shared_ptr CreateInsecureChannelFromFd( const grpc::string& target, int fd) { grpc::internal::GrpcLibrary init_lib; init_lib.init(); - return ::grpc::CreateChannelInternal( + return grpc::CreateChannelInternal( "", grpc_insecure_channel_create_from_fd(target.c_str(), fd, nullptr), std::vector>()); @@ -46,7 +46,7 @@ std::shared_ptr CreateCustomInsecureChannelFromFd( init_lib.init(); grpc_channel_args channel_args; args.SetChannelArgs(&channel_args); - return ::grpc::CreateChannelInternal( + return grpc::CreateChannelInternal( "", grpc_insecure_channel_create_from_fd(target.c_str(), fd, &channel_args), std::vector #include -namespace grpc_impl { -class Channel; -} // namespace grpc_impl - namespace grpc { namespace experimental { template class MessageAllocator; } // namespace experimental class CompletionQueue; +class Channel; class ServerCompletionQueue; class ServerContext; } // namespace grpc diff --git a/test/cpp/codegen/golden_file_test.cc b/test/cpp/codegen/golden_file_test.cc index 8951060b94e..16346b7e237 100644 --- a/test/cpp/codegen/golden_file_test.cc +++ b/test/cpp/codegen/golden_file_test.cc @@ -33,7 +33,7 @@ using namespace gflags; DEFINE_string( generated_file_path, "", - "path to the directory containing generated files compiler_test.grpc.pb.h " + "path to the directory containing generated files compiler_test.grpc.pb.h" "and compiler_test_mock.grpc.pb.h"); const char kGoldenFilePath[] = "test/cpp/codegen/compiler_test_golden"; diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h index 4d60e97d5f6..075a09c63eb 100644 --- a/test/cpp/microbenchmarks/fullstack_fixtures.h +++ b/test/cpp/microbenchmarks/fullstack_fixtures.h @@ -218,7 +218,7 @@ class EndpointPairFixture : public BaseFixture { "target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport_); grpc_chttp2_transport_start_reading(client_transport_, nullptr, nullptr); - channel_ = ::grpc::CreateChannelInternal( + channel_ = CreateChannelInternal( "", channel, std::vector>()); diff --git a/test/cpp/performance/writes_per_rpc_test.cc b/test/cpp/performance/writes_per_rpc_test.cc index b74f4d0466b..7b22f23cf00 100644 --- a/test/cpp/performance/writes_per_rpc_test.cc +++ b/test/cpp/performance/writes_per_rpc_test.cc @@ -118,7 +118,7 @@ class EndpointPairFixture { "target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, transport); grpc_chttp2_transport_start_reading(transport, nullptr, nullptr); - channel_ = ::grpc::CreateChannelInternal( + channel_ = CreateChannelInternal( "", channel, std::vector>()); diff --git a/test/cpp/util/create_test_channel.h b/test/cpp/util/create_test_channel.h index 42564a31ec8..b50131b385c 100644 --- a/test/cpp/util/create_test_channel.h +++ b/test/cpp/util/create_test_channel.h @@ -24,12 +24,8 @@ #include #include -namespace grpc_impl { - -class Channel; -} - namespace grpc { +class Channel; namespace testing { @@ -37,31 +33,31 @@ typedef enum { INSECURE = 0, TLS, ALTS } transport_security; } // namespace testing -std::shared_ptr<::grpc_impl::Channel> CreateTestChannel( +std::shared_ptr CreateTestChannel( const grpc::string& server, testing::transport_security security_type); -std::shared_ptr<::grpc_impl::Channel> CreateTestChannel( +std::shared_ptr CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, testing::transport_security security_type, bool use_prod_roots); -std::shared_ptr<::grpc_impl::Channel> CreateTestChannel( +std::shared_ptr CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, testing::transport_security security_type, bool use_prod_roots, const std::shared_ptr& creds); -std::shared_ptr<::grpc_impl::Channel> CreateTestChannel( +std::shared_ptr CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, testing::transport_security security_type, bool use_prod_roots, const std::shared_ptr& creds, const ChannelArguments& args); -std::shared_ptr<::grpc_impl::Channel> CreateTestChannel( +std::shared_ptr CreateTestChannel( const grpc::string& server, const grpc::string& cred_type, const grpc::string& override_hostname, bool use_prod_roots, const std::shared_ptr& creds, const ChannelArguments& args); -std::shared_ptr<::grpc_impl::Channel> CreateTestChannel( +std::shared_ptr CreateTestChannel( const grpc::string& server, const grpc::string& credential_type, const std::shared_ptr& creds); diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 4e524077e37..eda8eb5764c 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -927,7 +927,6 @@ include/grpc/support/workaround_list.h \ include/grpcpp/alarm.h \ include/grpcpp/alarm_impl.h \ include/grpcpp/channel.h \ -include/grpcpp/channel_impl.h \ include/grpcpp/client_context.h \ include/grpcpp/completion_queue.h \ include/grpcpp/create_channel.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 6741ffb5ace..1d25422c3fd 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -928,7 +928,6 @@ include/grpc/support/workaround_list.h \ include/grpcpp/alarm.h \ include/grpcpp/alarm_impl.h \ include/grpcpp/channel.h \ -include/grpcpp/channel_impl.h \ include/grpcpp/client_context.h \ include/grpcpp/completion_queue.h \ include/grpcpp/create_channel.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index ea40c25195f..02d3d62c963 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -10297,7 +10297,6 @@ "include/grpcpp/alarm.h", "include/grpcpp/alarm_impl.h", "include/grpcpp/channel.h", - "include/grpcpp/channel_impl.h", "include/grpcpp/client_context.h", "include/grpcpp/completion_queue.h", "include/grpcpp/create_channel.h", @@ -10422,7 +10421,6 @@ "include/grpcpp/alarm.h", "include/grpcpp/alarm_impl.h", "include/grpcpp/channel.h", - "include/grpcpp/channel_impl.h", "include/grpcpp/client_context.h", "include/grpcpp/completion_queue.h", "include/grpcpp/create_channel.h", From 39965993920350bfe36911550aee38021b7ffddb Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 15 May 2019 14:30:33 -0700 Subject: [PATCH 0225/1555] Fix clang script errors --- include/grpcpp/channel.h | 23 +++++++++--------- include/grpcpp/impl/codegen/client_context.h | 3 +-- src/cpp/client/channel_cc.cc | 25 ++++++++++---------- src/cpp/client/client_context.cc | 4 ++-- src/cpp/client/create_channel_internal.cc | 4 ++-- src/cpp/client/create_channel_internal.h | 4 ++-- 6 files changed, 31 insertions(+), 32 deletions(-) diff --git a/include/grpcpp/channel.h b/include/grpcpp/channel.h index 434f2688da8..bbb88d059ef 100644 --- a/include/grpcpp/channel.h +++ b/include/grpcpp/channel.h @@ -72,28 +72,28 @@ class Channel final : public ChannelInterface, interceptor_creators); friend class internal::InterceptedChannel; Channel(const grpc::string& host, grpc_channel* c_channel, - std::vector> + std::vector< + std::unique_ptr> interceptor_creators); internal::Call CreateCall(const internal::RpcMethod& method, - ClientContext* context, - CompletionQueue* cq) override; + ClientContext* context, + CompletionQueue* cq) override; void PerformOpsOnCall(internal::CallOpSetInterface* ops, internal::Call* call) override; void* RegisterMethod(const char* method) override; void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, - gpr_timespec deadline, - CompletionQueue* cq, void* tag) override; + gpr_timespec deadline, CompletionQueue* cq, + void* tag) override; bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline) override; CompletionQueue* CallbackCQ() override; - internal::Call CreateCallInternal( - const internal::RpcMethod& method, ClientContext* context, - CompletionQueue* cq, size_t interceptor_pos) override; + internal::Call CreateCallInternal(const internal::RpcMethod& method, + ClientContext* context, CompletionQueue* cq, + size_t interceptor_pos) override; const grpc::string host_; grpc_channel* const c_channel_; // owned @@ -107,11 +107,10 @@ class Channel final : public ChannelInterface, // shutdown callback tag (invoked when the CQ is fully shutdown). CompletionQueue* callback_cq_ = nullptr; - std::vector< - std::unique_ptr> + std::vector> interceptor_creators_; }; -} // namespace grpc_impl +} // namespace grpc #endif // GRPCPP_CHANNEL_IMPL_H diff --git a/include/grpcpp/impl/codegen/client_context.h b/include/grpcpp/impl/codegen/client_context.h index 9f0a80f1077..355ac557b3a 100644 --- a/include/grpcpp/impl/codegen/client_context.h +++ b/include/grpcpp/impl/codegen/client_context.h @@ -430,8 +430,7 @@ class ClientContext { } grpc_call* call() const { return call_; } - void set_call(grpc_call* call, - const std::shared_ptr& channel); + void set_call(grpc_call* call, const std::shared_ptr& channel); experimental::ClientRpcInfo* set_client_rpc_info( const char* method, internal::RpcMethod::RpcType type, diff --git a/src/cpp/client/channel_cc.cc b/src/cpp/client/channel_cc.cc index bc0005dab1f..5812e96771f 100644 --- a/src/cpp/client/channel_cc.cc +++ b/src/cpp/client/channel_cc.cc @@ -45,10 +45,11 @@ namespace grpc { static internal::GrpcLibraryInitializer g_gli_initializer; -Channel::Channel(const grpc::string& host, grpc_channel* channel, - std::vector> - interceptor_creators) +Channel::Channel( + const grpc::string& host, grpc_channel* channel, + std::vector< + std::unique_ptr> + interceptor_creators) : host_(host), c_channel_(channel) { interceptor_creators_ = std::move(interceptor_creators); g_gli_initializer.summon(); @@ -64,8 +65,7 @@ Channel::~Channel() { namespace { inline grpc_slice SliceFromArray(const char* arr, size_t len) { - return g_core_codegen_interface->grpc_slice_from_copied_buffer(arr, - len); + return g_core_codegen_interface->grpc_slice_from_copied_buffer(arr, len); } grpc::string GetChannelInfoField(grpc_channel* channel, @@ -103,9 +103,10 @@ void ChannelResetConnectionBackoff(Channel* channel) { } // namespace experimental -internal::Call Channel::CreateCallInternal( - const internal::RpcMethod& method, ClientContext* context, - CompletionQueue* cq, size_t interceptor_pos) { +internal::Call Channel::CreateCallInternal(const internal::RpcMethod& method, + ClientContext* context, + CompletionQueue* cq, + size_t interceptor_pos) { const bool kRegistered = method.channel_tag() && context->authority().empty(); grpc_call* c_call = nullptr; if (kRegistered) { @@ -149,9 +150,9 @@ internal::Call Channel::CreateCallInternal( return internal::Call(c_call, this, cq, info); } -::grpc::internal::Call Channel::CreateCall( - const internal::RpcMethod& method, ClientContext* context, - CompletionQueue* cq) { +::grpc::internal::Call Channel::CreateCall(const internal::RpcMethod& method, + ClientContext* context, + CompletionQueue* cq) { return CreateCallInternal(method, context, cq, 0); } diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index a2e928f0d4f..b4fce79b99a 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -83,8 +83,8 @@ void ClientContext::AddMetadata(const grpc::string& meta_key, send_initial_metadata_.insert(std::make_pair(meta_key, meta_value)); } -void ClientContext::set_call( - grpc_call* call, const std::shared_ptr& channel) { +void ClientContext::set_call(grpc_call* call, + const std::shared_ptr& channel) { grpc::internal::MutexLock lock(&mu_); GPR_ASSERT(call_ == nullptr); call_ = call; diff --git a/src/cpp/client/create_channel_internal.cc b/src/cpp/client/create_channel_internal.cc index e4978a1b4d3..0ea311367e4 100644 --- a/src/cpp/client/create_channel_internal.cc +++ b/src/cpp/client/create_channel_internal.cc @@ -26,8 +26,8 @@ namespace grpc { std::shared_ptr CreateChannelInternal( const grpc::string& host, grpc_channel* c_channel, - std::vector> + std::vector< + std::unique_ptr> interceptor_creators) { return std::shared_ptr( new Channel(host, c_channel, std::move(interceptor_creators))); diff --git a/src/cpp/client/create_channel_internal.h b/src/cpp/client/create_channel_internal.h index 784908e1138..4a87076fb10 100644 --- a/src/cpp/client/create_channel_internal.h +++ b/src/cpp/client/create_channel_internal.h @@ -30,8 +30,8 @@ namespace grpc { std::shared_ptr CreateChannelInternal( const grpc::string& host, grpc_channel* c_channel, - std::vector> + std::vector< + std::unique_ptr> interceptor_creators); } // namespace grpc From e8bfcf829c6860b52d72ffb52e6996888078275c Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 15 May 2019 14:53:28 -0700 Subject: [PATCH 0226/1555] Fix erroneous header guards --- include/grpcpp/channel.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/grpcpp/channel.h b/include/grpcpp/channel.h index bbb88d059ef..b3c4703d9d5 100644 --- a/include/grpcpp/channel.h +++ b/include/grpcpp/channel.h @@ -16,8 +16,8 @@ * */ -#ifndef GRPCPP_CHANNEL_IMPL_H -#define GRPCPP_CHANNEL_IMPL_H +#ifndef GRPCPP_CHANNEL_H +#define GRPCPP_CHANNEL_H #include #include @@ -113,4 +113,4 @@ class Channel final : public ChannelInterface, } // namespace grpc -#endif // GRPCPP_CHANNEL_IMPL_H +#endif // GRPCPP_CHANNEL_H From 02069b48da048efbca2fb49d09108c4d5b62f027 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 15 May 2019 23:33:07 -0700 Subject: [PATCH 0227/1555] Remove get-grpc.sh --- .../grpc_interop_aspnetcore/build_interop.sh.template | 2 -- .../interoptest/grpc_interop_aspnetcore/build_interop.sh | 2 -- 2 files changed, 4 deletions(-) diff --git a/templates/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh.template b/templates/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh.template index d64286ab03c..55ecfb30192 100644 --- a/templates/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh.template +++ b/templates/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh.template @@ -38,7 +38,5 @@ then ln -s $(pwd)/.dotnet/dotnet /usr/local/bin/dotnet fi - - ./build/get-grpc.sh dotnet build --configuration Debug Grpc.AspNetCore.sln diff --git a/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh b/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh index 65e848ded32..0b32638b54b 100644 --- a/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh +++ b/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh @@ -37,6 +37,4 @@ then ln -s $(pwd)/.dotnet/dotnet /usr/local/bin/dotnet fi -./build/get-grpc.sh - dotnet build --configuration Debug Grpc.AspNetCore.sln From 39be72a230d4a89c7441220780edf41a8a76bb95 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 16 May 2019 08:46:45 -0700 Subject: [PATCH 0228/1555] Remove "class Channel" forward reference from generated code --- src/compiler/cpp_generator.cc | 1 - test/cpp/codegen/compiler_test_golden | 1 - 2 files changed, 2 deletions(-) diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index ecec3206577..3380aeb257b 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -160,7 +160,6 @@ grpc::string GetHeaderIncludes(grpc_generator::File* file, printer->Print(vars, "class MessageAllocator;\n"); printer->Print(vars, "} // namespace experimental\n"); printer->Print(vars, "class CompletionQueue;\n"); - printer->Print(vars, "class Channel;\n"); printer->Print(vars, "class ServerCompletionQueue;\n"); printer->Print(vars, "class ServerContext;\n"); printer->Print(vars, "} // namespace grpc\n\n"); diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index 9e99bc7b0a2..46efdf1603a 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -46,7 +46,6 @@ template class MessageAllocator; } // namespace experimental class CompletionQueue; -class Channel; class ServerCompletionQueue; class ServerContext; } // namespace grpc From ec6e7fd9417045e2c37a237202707e45f395d750 Mon Sep 17 00:00:00 2001 From: yang-g Date: Thu, 16 May 2019 09:07:34 -0700 Subject: [PATCH 0229/1555] Rename enum --- include/grpcpp/server_builder_impl.h | 2 +- src/cpp/server/external_connection_acceptor_impl.cc | 4 ++-- test/cpp/end2end/port_sharing_end2end_test.cc | 6 ++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/include/grpcpp/server_builder_impl.h b/include/grpcpp/server_builder_impl.h index 939c848a794..0de72cc397c 100644 --- a/include/grpcpp/server_builder_impl.h +++ b/include/grpcpp/server_builder_impl.h @@ -272,7 +272,7 @@ class ServerBuilder { grpc::experimental::CallbackGenericService* service); enum class ExternalConnectionType { - CONNECTION_FROM_FD = 0 // in the form of a file descriptor + FROM_FD = 0 // in the form of a file descriptor }; /// Register an acceptor to handle the externally accepted connection in diff --git a/src/cpp/server/external_connection_acceptor_impl.cc b/src/cpp/server/external_connection_acceptor_impl.cc index 39048be4aab..afc90679398 100644 --- a/src/cpp/server/external_connection_acceptor_impl.cc +++ b/src/cpp/server/external_connection_acceptor_impl.cc @@ -46,8 +46,8 @@ ExternalConnectionAcceptorImpl::ExternalConnectionAcceptorImpl( ServerBuilder::experimental_type::ExternalConnectionType type, std::shared_ptr creds) : name_(name), creds_(std::move(creds)) { - GPR_ASSERT(type == ServerBuilder::experimental_type::ExternalConnectionType:: - CONNECTION_FROM_FD); + GPR_ASSERT(type == + ServerBuilder::experimental_type::ExternalConnectionType::FROM_FD); } std::unique_ptr diff --git a/test/cpp/end2end/port_sharing_end2end_test.cc b/test/cpp/end2end/port_sharing_end2end_test.cc index 597ba3e4f29..a2b9417d172 100644 --- a/test/cpp/end2end/port_sharing_end2end_test.cc +++ b/test/cpp/end2end/port_sharing_end2end_test.cc @@ -223,13 +223,11 @@ class PortSharingEnd2endTest : public ::testing::TestWithParam { auto server_creds = GetCredentialsProvider()->GetServerCredentials( GetParam().credentials_type); auto acceptor1 = builder.experimental().AddExternalConnectionAcceptor( - ServerBuilder::experimental_type::ExternalConnectionType:: - CONNECTION_FROM_FD, + ServerBuilder::experimental_type::ExternalConnectionType::FROM_FD, server_creds); tcp_server1_.SetAcceptor(std::move(acceptor1)); auto acceptor2 = builder.experimental().AddExternalConnectionAcceptor( - ServerBuilder::experimental_type::ExternalConnectionType:: - CONNECTION_FROM_FD, + ServerBuilder::experimental_type::ExternalConnectionType::FROM_FD, server_creds); tcp_server2_.SetAcceptor(std::move(acceptor2)); builder.RegisterService(&service_); From 4b89514919cbf1bb62294400587f9d98af323284 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 15 May 2019 12:04:13 -0700 Subject: [PATCH 0230/1555] Fix default value compile issues --- src/core/lib/surface/completion_queue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/surface/completion_queue.h b/src/core/lib/surface/completion_queue.h index f5b0822fcb4..16550ac61eb 100644 --- a/src/core/lib/surface/completion_queue.h +++ b/src/core/lib/surface/completion_queue.h @@ -77,7 +77,7 @@ bool grpc_cq_begin_op(grpc_completion_queue* cc, void* tag); grpc_cq_begin_op */ void grpc_cq_end_op(grpc_completion_queue* cc, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage, bool internal); + void* done_arg, grpc_cq_completion* storage, bool internal = false); grpc_pollset* grpc_cq_pollset(grpc_completion_queue* cc); From 51210ba9222a9e6a9e23523d7b9834b3c3810de1 Mon Sep 17 00:00:00 2001 From: yang-g Date: Fri, 10 May 2019 21:38:59 -0700 Subject: [PATCH 0231/1555] Update the message allocator API --- .../grpcpp/impl/codegen/message_allocator.h | 49 +++--- include/grpcpp/impl/codegen/server_callback.h | 101 +++++-------- .../end2end/message_allocator_end2end_test.cc | 143 ++++++++++-------- 3 files changed, 151 insertions(+), 142 deletions(-) diff --git a/include/grpcpp/impl/codegen/message_allocator.h b/include/grpcpp/impl/codegen/message_allocator.h index 107bec62f1d..c3054313864 100644 --- a/include/grpcpp/impl/codegen/message_allocator.h +++ b/include/grpcpp/impl/codegen/message_allocator.h @@ -22,31 +22,42 @@ namespace grpc { namespace experimental { -// This is per rpc struct for the allocator. We can potentially put the grpc -// call arena in here in the future. -template -struct RpcAllocatorInfo { - RequestT* request; - ResponseT* response; - // per rpc allocator internal state. MessageAllocator can set it when - // AllocateMessages is called and use it later. - void* allocator_state; +// NOTE: This is an API for advanced users who need custom allocators. +// Per rpc struct for the allocator. This is the interface to return to user. +class RpcAllocatorState { + public: + virtual ~RpcAllocatorState() = default; + // Optionally deallocate request early to reduce the size of working set. + // A custom MessageAllocator needs to be registered to make use of this. + // This is not abstract because implementing it is optional. + virtual void FreeRequest() {} }; -// Implementations need to be thread-safe +// This is the interface returned by the allocator. +// grpc library will call the methods to get request/response pointers and to +// release the object when it is done. +template +class MessageHolder : public RpcAllocatorState { + public: + virtual void Release() { delete this; } + RequestT* request() { return request_; } + ResponseT* response() { return response_; } + + protected: + // NOTE: subclasses should set these pointers. + RequestT* request_; + ResponseT* response_; +}; + +// A custom allocator can be set via the generated code to a callback unary +// method, such as SetMessageAllocatorFor_Echo(custom_allocator). The allocator +// needs to be alive for the lifetime of the server. +// Implementations need to be thread-safe. template class MessageAllocator { public: virtual ~MessageAllocator() = default; - // Allocate both request and response - virtual void AllocateMessages( - RpcAllocatorInfo* info) = 0; - // Optional: deallocate request early, called by - // ServerCallbackRpcController::ReleaseRequest - virtual void DeallocateRequest(RpcAllocatorInfo* info) {} - // Deallocate response and request (if applicable) - virtual void DeallocateMessages( - RpcAllocatorInfo* info) = 0; + virtual MessageHolder* AllocateMessages() = 0; }; } // namespace experimental diff --git a/include/grpcpp/impl/codegen/server_callback.h b/include/grpcpp/impl/codegen/server_callback.h index 3f6d5cd3555..62cdd452308 100644 --- a/include/grpcpp/impl/codegen/server_callback.h +++ b/include/grpcpp/impl/codegen/server_callback.h @@ -77,6 +77,24 @@ class ServerReactor { std::atomic_int on_cancel_conditions_remaining_{2}; }; +template +class DefaultMessageHolder + : public experimental::MessageHolder { + public: + DefaultMessageHolder() { + this->request_ = &request_obj_; + this->response_ = &response_obj_; + } + void Release() override { + // the object is allocated in the call arena. + this->~DefaultMessageHolder(); + } + + private: + Request request_obj_; + Response response_obj_; +}; + } // namespace internal namespace experimental { @@ -137,13 +155,9 @@ class ServerCallbackRpcController { virtual void SetCancelCallback(std::function callback) = 0; virtual void ClearCancelCallback() = 0; - // NOTE: This is an API for advanced users who need custom allocators. - // Optionally deallocate request early to reduce the size of working set. - // A custom MessageAllocator needs to be registered to make use of this. - virtual void FreeRequest() = 0; // NOTE: This is an API for advanced users who need custom allocators. // Get and maybe mutate the allocator state associated with the current RPC. - virtual void* GetAllocatorState() = 0; + virtual RpcAllocatorState* GetRpcAllocatorState() = 0; }; // NOTE: The actual streaming object classes are provided @@ -465,13 +479,13 @@ class CallbackUnaryHandler : public MethodHandler { void RunHandler(const HandlerParameter& param) final { // Arena allocate a controller structure (that includes request/response) g_core_codegen_interface->grpc_call_ref(param.call->call()); - auto* allocator_info = - static_cast*>( + auto* allocator_state = + static_cast*>( param.internal_data); auto* controller = new (g_core_codegen_interface->grpc_call_arena_alloc( param.call->call(), sizeof(ServerCallbackRpcControllerImpl))) ServerCallbackRpcControllerImpl(param.server_context, param.call, - allocator_info, allocator_, + allocator_state, std::move(param.call_requester)); Status status = param.status; if (status.ok()) { @@ -489,36 +503,24 @@ class CallbackUnaryHandler : public MethodHandler { ByteBuffer buf; buf.set_buffer(req); RequestType* request = nullptr; - experimental::RpcAllocatorInfo* allocator_info = - new (g_core_codegen_interface->grpc_call_arena_alloc( - call, sizeof(*allocator_info))) - experimental::RpcAllocatorInfo(); + experimental::MessageHolder* allocator_state = + nullptr; if (allocator_ != nullptr) { - allocator_->AllocateMessages(allocator_info); + allocator_state = allocator_->AllocateMessages(); } else { - allocator_info->request = - new (g_core_codegen_interface->grpc_call_arena_alloc( - call, sizeof(RequestType))) RequestType(); - allocator_info->response = - new (g_core_codegen_interface->grpc_call_arena_alloc( - call, sizeof(ResponseType))) ResponseType(); + allocator_state = new (g_core_codegen_interface->grpc_call_arena_alloc( + call, sizeof(DefaultMessageHolder))) + DefaultMessageHolder(); } - *handler_data = allocator_info; - request = allocator_info->request; + *handler_data = allocator_state; + request = allocator_state->request(); *status = SerializationTraits::Deserialize(&buf, request); buf.Release(); if (status->ok()) { return request; } // Clean up on deserialization failure. - if (allocator_ != nullptr) { - allocator_->DeallocateMessages(allocator_info); - } else { - allocator_info->request->~RequestType(); - allocator_info->response->~ResponseType(); - allocator_info->request = nullptr; - allocator_info->response = nullptr; - } + allocator_state->Release(); return nullptr; } @@ -548,9 +550,8 @@ class CallbackUnaryHandler : public MethodHandler { } // The response is dropped if the status is not OK. if (s.ok()) { - finish_ops_.ServerSendStatus( - &ctx_->trailing_metadata_, - finish_ops_.SendMessagePtr(allocator_info_->response)); + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, + finish_ops_.SendMessagePtr(response())); } else { finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); } @@ -588,14 +589,8 @@ class CallbackUnaryHandler : public MethodHandler { void ClearCancelCallback() override { ctx_->ClearCancelCallback(); } - void FreeRequest() override { - if (allocator_ != nullptr) { - allocator_->DeallocateRequest(allocator_info_); - } - } - - void* GetAllocatorState() override { - return allocator_info_->allocator_state; + experimental::RpcAllocatorState* GetRpcAllocatorState() override { + return allocator_state_; } private: @@ -603,35 +598,23 @@ class CallbackUnaryHandler : public MethodHandler { ServerCallbackRpcControllerImpl( ServerContext* ctx, Call* call, - experimental::RpcAllocatorInfo* - allocator_info, - experimental::MessageAllocator* allocator, + experimental::MessageHolder* allocator_state, std::function call_requester) : ctx_(ctx), call_(*call), - allocator_info_(allocator_info), - allocator_(allocator), + allocator_state_(allocator_state), call_requester_(std::move(call_requester)) { ctx_->BeginCompletionOp(call, [this](bool) { MaybeDone(); }, nullptr); } - const RequestType* request() { return allocator_info_->request; } - ResponseType* response() { return allocator_info_->response; } + const RequestType* request() { return allocator_state_->request(); } + ResponseType* response() { return allocator_state_->response(); } void MaybeDone() { if (--callbacks_outstanding_ == 0) { grpc_call* call = call_.call(); auto call_requester = std::move(call_requester_); - if (allocator_ != nullptr) { - allocator_->DeallocateMessages(allocator_info_); - } else { - if (allocator_info_->request != nullptr) { - allocator_info_->request->~RequestType(); - } - if (allocator_info_->response != nullptr) { - allocator_info_->response->~ResponseType(); - } - } + allocator_state_->Release(); this->~ServerCallbackRpcControllerImpl(); // explicitly call destructor g_core_codegen_interface->grpc_call_unref(call); call_requester(); @@ -647,8 +630,8 @@ class CallbackUnaryHandler : public MethodHandler { ServerContext* ctx_; Call call_; - experimental::RpcAllocatorInfo* allocator_info_; - experimental::MessageAllocator* allocator_; + experimental::MessageHolder* const + allocator_state_; std::function call_requester_; std::atomic_int callbacks_outstanding_{ 2}; // reserve for Finish and CompletionOp diff --git a/test/cpp/end2end/message_allocator_end2end_test.cc b/test/cpp/end2end/message_allocator_end2end_test.cc index c833a4ff1b6..b4ed1d47f8f 100644 --- a/test/cpp/end2end/message_allocator_end2end_test.cc +++ b/test/cpp/end2end/message_allocator_end2end_test.cc @@ -25,6 +25,7 @@ #include +#include #include #include @@ -62,11 +63,9 @@ class CallbackTestServiceImpl public: explicit CallbackTestServiceImpl() {} - void SetFreeRequest() { free_request_ = true; } - void SetAllocatorMutator( - std::function + std::function mutator) { allocator_mutator_ = mutator; } @@ -75,18 +74,15 @@ class CallbackTestServiceImpl EchoResponse* response, experimental::ServerCallbackRpcController* controller) override { response->set_message(request->message()); - if (free_request_) { - controller->FreeRequest(); - } else if (allocator_mutator_) { - allocator_mutator_(controller->GetAllocatorState(), request, response); + if (allocator_mutator_) { + allocator_mutator_(controller->GetRpcAllocatorState(), request, response); } controller->Finish(Status::OK); } private: - bool free_request_ = false; - std::function + std::function allocator_mutator_; }; @@ -230,26 +226,44 @@ class SimpleAllocatorTest : public MessageAllocatorEnd2endTestBase { class SimpleAllocator : public experimental::MessageAllocator { public: - void AllocateMessages( - experimental::RpcAllocatorInfo* info) { - allocation_count++; - info->request = new EchoRequest; - info->response = new EchoResponse; - info->allocator_state = info; - } - void DeallocateRequest( - experimental::RpcAllocatorInfo* info) { - request_deallocation_count++; - delete info->request; - info->request = nullptr; - } - void DeallocateMessages( - experimental::RpcAllocatorInfo* info) { - messages_deallocation_count++; - delete info->request; - delete info->response; - } + class MessageHolderImpl + : public experimental::MessageHolder { + public: + MessageHolderImpl(int* request_deallocation_count, + int* messages_deallocation_count) + : request_deallocation_count_(request_deallocation_count), + messages_deallocation_count_(messages_deallocation_count) { + request_ = new EchoRequest; + response_ = new EchoResponse; + } + void Release() override { + (*messages_deallocation_count_)++; + delete request_; + delete response_; + delete this; + } + void FreeRequest() override { + (*request_deallocation_count_)++; + delete request_; + request_ = nullptr; + } + EchoRequest* ReleaseRequest() { + auto* ret = request_; + request_ = nullptr; + return ret; + } + + private: + int* request_deallocation_count_; + int* messages_deallocation_count_; + }; + experimental::MessageHolder* AllocateMessages() + override { + allocation_count++; + return new MessageHolderImpl(&request_deallocation_count, + &messages_deallocation_count); + } int allocation_count = 0; int request_deallocation_count = 0; int messages_deallocation_count = 0; @@ -272,7 +286,16 @@ TEST_P(SimpleAllocatorTest, RpcWithEarlyFreeRequest) { MAYBE_SKIP_TEST; const int kRpcCount = 10; std::unique_ptr allocator(new SimpleAllocator); - callback_service_.SetFreeRequest(); + auto mutator = [](experimental::RpcAllocatorState* allocator_state, + const EchoRequest* req, EchoResponse* resp) { + auto* info = + static_cast(allocator_state); + EXPECT_EQ(req, info->request()); + EXPECT_EQ(resp, info->response()); + allocator_state->FreeRequest(); + EXPECT_EQ(nullptr, info->request()); + }; + callback_service_.SetAllocatorMutator(mutator); CreateServer(allocator.get()); ResetStub(); SendRpcs(kRpcCount); @@ -286,17 +309,15 @@ TEST_P(SimpleAllocatorTest, RpcWithReleaseRequest) { const int kRpcCount = 10; std::unique_ptr allocator(new SimpleAllocator); std::vector released_requests; - auto mutator = [&released_requests](void* allocator_state, - const EchoRequest* req, - EchoResponse* resp) { + auto mutator = [&released_requests]( + experimental::RpcAllocatorState* allocator_state, + const EchoRequest* req, EchoResponse* resp) { auto* info = - static_cast*>( - allocator_state); - EXPECT_EQ(req, info->request); - EXPECT_EQ(resp, info->response); - EXPECT_EQ(allocator_state, info->allocator_state); - released_requests.push_back(info->request); - info->request = nullptr; + static_cast(allocator_state); + EXPECT_EQ(req, info->request()); + EXPECT_EQ(resp, info->response()); + released_requests.push_back(info->ReleaseRequest()); + EXPECT_EQ(nullptr, info->request()); }; callback_service_.SetAllocatorMutator(mutator); CreateServer(allocator.get()); @@ -316,30 +337,25 @@ class ArenaAllocatorTest : public MessageAllocatorEnd2endTestBase { class ArenaAllocator : public experimental::MessageAllocator { public: - void AllocateMessages( - experimental::RpcAllocatorInfo* info) { - allocation_count++; - auto* arena = new google::protobuf::Arena; - info->allocator_state = arena; - info->request = - google::protobuf::Arena::CreateMessage(arena); - info->response = - google::protobuf::Arena::CreateMessage(arena); - } - void DeallocateRequest( - experimental::RpcAllocatorInfo* info) { - GPR_ASSERT(0); - } - void DeallocateMessages( - experimental::RpcAllocatorInfo* info) { - deallocation_count++; - auto* arena = - static_cast(info->allocator_state); - delete arena; - } + class MessageHolderImpl + : public experimental::MessageHolder { + public: + MessageHolderImpl() { + request_ = google::protobuf::Arena::CreateMessage(&arena_); + response_ = + google::protobuf::Arena::CreateMessage(&arena_); + } + void FreeRequest() override { GPR_ASSERT(0); } + private: + google::protobuf::Arena arena_; + }; + experimental::MessageHolder* AllocateMessages() + override { + allocation_count++; + return new MessageHolderImpl; + } int allocation_count = 0; - int deallocation_count = 0; }; }; @@ -351,7 +367,6 @@ TEST_P(ArenaAllocatorTest, SimpleRpc) { ResetStub(); SendRpcs(kRpcCount); EXPECT_EQ(kRpcCount, allocator->allocation_count); - EXPECT_EQ(kRpcCount, allocator->deallocation_count); } std::vector CreateTestScenarios(bool test_insecure) { From 7c5bfbbb3237a9a662be6b1c9f5dcb3112a25922 Mon Sep 17 00:00:00 2001 From: yang-g Date: Tue, 14 May 2019 15:37:10 -0700 Subject: [PATCH 0232/1555] Resolve comments --- .../grpcpp/impl/codegen/message_allocator.h | 4 +++- include/grpcpp/impl/codegen/server_callback.h | 4 ++-- .../end2end/message_allocator_end2end_test.cc | 23 ++++++++++--------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/include/grpcpp/impl/codegen/message_allocator.h b/include/grpcpp/impl/codegen/message_allocator.h index c3054313864..422f8c2ea21 100644 --- a/include/grpcpp/impl/codegen/message_allocator.h +++ b/include/grpcpp/impl/codegen/message_allocator.h @@ -42,8 +42,10 @@ class MessageHolder : public RpcAllocatorState { virtual void Release() { delete this; } RequestT* request() { return request_; } ResponseT* response() { return response_; } + void set_request(RequestT* request) { request_ = request; } + void set_response(ResponseT* response) { response_ = response; } - protected: + private: // NOTE: subclasses should set these pointers. RequestT* request_; ResponseT* response_; diff --git a/include/grpcpp/impl/codegen/server_callback.h b/include/grpcpp/impl/codegen/server_callback.h index 62cdd452308..9254518b605 100644 --- a/include/grpcpp/impl/codegen/server_callback.h +++ b/include/grpcpp/impl/codegen/server_callback.h @@ -82,8 +82,8 @@ class DefaultMessageHolder : public experimental::MessageHolder { public: DefaultMessageHolder() { - this->request_ = &request_obj_; - this->response_ = &response_obj_; + this->set_request(&request_obj_); + this->set_response(&response_obj_); } void Release() override { // the object is allocated in the call arena. diff --git a/test/cpp/end2end/message_allocator_end2end_test.cc b/test/cpp/end2end/message_allocator_end2end_test.cc index b4ed1d47f8f..2abe26fe825 100644 --- a/test/cpp/end2end/message_allocator_end2end_test.cc +++ b/test/cpp/end2end/message_allocator_end2end_test.cc @@ -233,24 +233,24 @@ class SimpleAllocatorTest : public MessageAllocatorEnd2endTestBase { int* messages_deallocation_count) : request_deallocation_count_(request_deallocation_count), messages_deallocation_count_(messages_deallocation_count) { - request_ = new EchoRequest; - response_ = new EchoResponse; + set_request(new EchoRequest); + set_response(new EchoResponse); } void Release() override { (*messages_deallocation_count_)++; - delete request_; - delete response_; + delete request(); + delete response(); delete this; } void FreeRequest() override { (*request_deallocation_count_)++; - delete request_; - request_ = nullptr; + delete request(); + set_request(nullptr); } EchoRequest* ReleaseRequest() { - auto* ret = request_; - request_ = nullptr; + auto* ret = request(); + set_request(nullptr); return ret; } @@ -341,9 +341,10 @@ class ArenaAllocatorTest : public MessageAllocatorEnd2endTestBase { : public experimental::MessageHolder { public: MessageHolderImpl() { - request_ = google::protobuf::Arena::CreateMessage(&arena_); - response_ = - google::protobuf::Arena::CreateMessage(&arena_); + set_request( + google::protobuf::Arena::CreateMessage(&arena_)); + set_response( + google::protobuf::Arena::CreateMessage(&arena_)); } void FreeRequest() override { GPR_ASSERT(0); } From 26ba981deeda821fae3a185b21308d16adcbbfe4 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Thu, 16 May 2019 09:34:20 -0700 Subject: [PATCH 0233/1555] Fix clang errors --- src/core/lib/surface/completion_queue.cc | 64 +++++++++++------------- src/core/lib/surface/completion_queue.h | 3 +- 2 files changed, 31 insertions(+), 36 deletions(-) diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index d040e91b796..f1b31e9cbba 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -355,23 +355,20 @@ static bool cq_begin_op_for_callback(grpc_completion_queue* cq, void* tag); // queue. The done argument is a callback that will be invoked when it is // safe to free up that storage. The storage MUST NOT be freed until the // done callback is invoked. -static void cq_end_op_for_next(grpc_completion_queue* cq, void* tag, - grpc_error* error, - void (*done)(void* done_arg, - grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage, bool internal = false); +static void cq_end_op_for_next( + grpc_completion_queue* cq, void* tag, grpc_error* error, + void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, + grpc_cq_completion* storage, bool internal = false); -static void cq_end_op_for_pluck(grpc_completion_queue* cq, void* tag, - grpc_error* error, - void (*done)(void* done_arg, - grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage, bool internal = false); +static void cq_end_op_for_pluck( + grpc_completion_queue* cq, void* tag, grpc_error* error, + void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, + grpc_cq_completion* storage, bool internal = false); -static void cq_end_op_for_callback(grpc_completion_queue* cq, void* tag, - grpc_error* error, - void (*done)(void* done_arg, - grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage, bool internal = false); +static void cq_end_op_for_callback( + grpc_completion_queue* cq, void* tag, grpc_error* error, + void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, + grpc_cq_completion* storage, bool internal = false); static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline, void* reserved); @@ -675,12 +672,10 @@ bool grpc_cq_begin_op(grpc_completion_queue* cq, void* tag) { /* Queue a GRPC_OP_COMPLETED operation to a completion queue (with a * completion * type of GRPC_CQ_NEXT) */ -static void cq_end_op_for_next(grpc_completion_queue* cq, void* tag, - grpc_error* error, - void (*done)(void* done_arg, - grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage, - bool internal) { +static void cq_end_op_for_next( + grpc_completion_queue* cq, void* tag, grpc_error* error, + void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, + grpc_cq_completion* storage, bool internal) { GPR_TIMER_SCOPE("cq_end_op_for_next", 0); if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) || @@ -756,12 +751,10 @@ static void cq_end_op_for_next(grpc_completion_queue* cq, void* tag, /* Queue a GRPC_OP_COMPLETED operation to a completion queue (with a * completion * type of GRPC_CQ_PLUCK) */ -static void cq_end_op_for_pluck(grpc_completion_queue* cq, void* tag, - grpc_error* error, - void (*done)(void* done_arg, - grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage, - bool internal) { +static void cq_end_op_for_pluck( + grpc_completion_queue* cq, void* tag, grpc_error* error, + void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, + grpc_cq_completion* storage, bool internal) { GPR_TIMER_SCOPE("cq_end_op_for_pluck", 0); cq_pluck_data* cqd = static_cast DATA_FROM_CQ(cq); @@ -833,8 +826,7 @@ static void functor_callback(void* arg, grpc_error* error) { static void cq_end_op_for_callback( grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage, - bool internal) { + grpc_cq_completion* storage, bool internal) { GPR_TIMER_SCOPE("cq_end_op_for_callback", 0); cq_callback_data* cqd = static_cast DATA_FROM_CQ(cq); @@ -866,13 +858,14 @@ static void cq_end_op_for_callback( auto* functor = static_cast(tag); if (internal) { - grpc_core::ApplicationCallbackExecCtx::Enqueue(functor, (error == GRPC_ERROR_NONE)); + grpc_core::ApplicationCallbackExecCtx::Enqueue(functor, + (error == GRPC_ERROR_NONE)); } else { GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_CREATE( - functor_callback, functor, - grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), - GRPC_ERROR_REF(error)); + GRPC_CLOSURE_CREATE( + functor_callback, functor, + grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), + GRPC_ERROR_REF(error)); } GRPC_ERROR_UNREF(error); @@ -880,7 +873,8 @@ static void cq_end_op_for_callback( void grpc_cq_end_op(grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage, bool internal) { + void* done_arg, grpc_cq_completion* storage, + bool internal) { cq->vtable->end_op(cq, tag, error, done, done_arg, storage, internal); } diff --git a/src/core/lib/surface/completion_queue.h b/src/core/lib/surface/completion_queue.h index 16550ac61eb..3ba9fbb8765 100644 --- a/src/core/lib/surface/completion_queue.h +++ b/src/core/lib/surface/completion_queue.h @@ -77,7 +77,8 @@ bool grpc_cq_begin_op(grpc_completion_queue* cc, void* tag); grpc_cq_begin_op */ void grpc_cq_end_op(grpc_completion_queue* cc, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage, bool internal = false); + void* done_arg, grpc_cq_completion* storage, + bool internal = false); grpc_pollset* grpc_cq_pollset(grpc_completion_queue* cc); From 1d5357d1bbfd1e83bad7f5b02c1b4937bdc9b61f Mon Sep 17 00:00:00 2001 From: ZhouyihaiDing Date: Thu, 16 May 2019 09:55:18 -0700 Subject: [PATCH 0234/1555] Change persistent log to gpr_log --- src/php/ext/grpc/channel.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/php/ext/grpc/channel.c b/src/php/ext/grpc/channel.c index c06bdea7feb..860d38be34a 100644 --- a/src/php/ext/grpc/channel.c +++ b/src/php/ext/grpc/channel.c @@ -30,6 +30,7 @@ #include #include +#include #include "completion_queue.h" #include "channel_credentials.h" @@ -247,12 +248,12 @@ void create_and_add_channel_to_persistent_list( // If no channel can be deleted from the persistent map, // do not persist this one. create_channel(channel, target, args, creds); - php_printf("[Warning] The number of channel for the" + gpr_log(GPR_INFO, "[Warning] The number of channel for the" " target %s is maxed out bounded.\n", target); - php_printf("[Warning] Target upper bound: %d. Current size: %d.\n", + gpr_log(GPR_INFO, "[Warning] Target upper bound: %d. Current size: %d.\n", target_bound_status->upper_bound, target_bound_status->current_count); - php_printf("[Warning] Target %s will not be persisted.\n", target); + gpr_log(GPR_INFO, "[Warning] Target %s will not be persisted.\n", target); return; } } From 1bc44a1a5a54dba6b02159d79fbd5c8680935694 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Thu, 9 May 2019 16:54:22 -0700 Subject: [PATCH 0235/1555] Fix node interop build scripts --- .../interoptest/grpc_interop_node/build_interop.sh | 4 +--- .../interoptest/grpc_interop_nodepurejs/build_interop.sh | 6 +----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/tools/dockerfile/interoptest/grpc_interop_node/build_interop.sh b/tools/dockerfile/interoptest/grpc_interop_node/build_interop.sh index c16efc1d354..aeb82e0c9c3 100755 --- a/tools/dockerfile/interoptest/grpc_interop_node/build_interop.sh +++ b/tools/dockerfile/interoptest/grpc_interop_node/build_interop.sh @@ -29,6 +29,4 @@ cp -r /var/local/jenkins/service_account $HOME || true cd /var/local/git/grpc-node # build Node interop client & server -npm install -g node-gyp gulp -npm install -gulp setup +./setup_interop.sh diff --git a/tools/dockerfile/interoptest/grpc_interop_nodepurejs/build_interop.sh b/tools/dockerfile/interoptest/grpc_interop_nodepurejs/build_interop.sh index d41ccacd2f9..db55f5a19f3 100755 --- a/tools/dockerfile/interoptest/grpc_interop_nodepurejs/build_interop.sh +++ b/tools/dockerfile/interoptest/grpc_interop_nodepurejs/build_interop.sh @@ -29,8 +29,4 @@ cp -r /var/local/jenkins/service_account $HOME || true cd /var/local/git/grpc-node # build Node interop client & server -npm install -g gulp -npm install -gulp js.core.install -gulp protobuf.install -gulp internal.test.install +./setup_interop_purejs.sh From 41191323ecdde5df1b09a399cc2e17b46c4cc8de Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 16 May 2019 13:37:54 -0700 Subject: [PATCH 0236/1555] Make sure event_engine is alive before checking for MAYBE_SKIP_TEST --- test/cpp/end2end/client_callback_end2end_test.cc | 8 ++++---- test/cpp/end2end/end2end_test.cc | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/test/cpp/end2end/client_callback_end2end_test.cc b/test/cpp/end2end/client_callback_end2end_test.cc index ede24f333ba..a154324216b 100644 --- a/test/cpp/end2end/client_callback_end2end_test.cc +++ b/test/cpp/end2end/client_callback_end2end_test.cc @@ -104,10 +104,6 @@ class ClientCallbackEnd2endTest // TODO(vjpai): Support testing of AuthMetadataProcessor if (GetParam().protocol == Protocol::TCP) { - if (!grpc_iomgr_run_in_background()) { - do_not_test_ = true; - return; - } picked_port_ = grpc_pick_unused_port_or_die(); server_address_ << "localhost:" << picked_port_; builder.AddListeningPort(server_address_.str(), server_creds); @@ -133,6 +129,10 @@ class ClientCallbackEnd2endTest server_ = builder.BuildAndStart(); is_server_started_ = true; + if (GetParam().protocol == Protocol::TCP && + !grpc_iomgr_run_in_background()) { + do_not_test_ = true; + } } void ResetStub() { diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index e5dc88ae6d7..bf3b374adc0 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -2110,6 +2110,10 @@ INSTANTIATE_TEST_CASE_P( int main(int argc, char** argv) { GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 200); grpc::testing::TestEnvironment env(argc, argv); + // The grpc_init is to cover the MAYBE_SKIP_TEST. + grpc_init(); ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + int ret = RUN_ALL_TESTS(); + grpc_shutdown(); + return ret; } From 62b422c4ee5d5950c0febd4ef20e00ff4c897047 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 16 May 2019 17:00:18 -0700 Subject: [PATCH 0237/1555] Grab a ref on fake resolver generator before scheduling a closure --- .../ext/filters/client_channel/resolver/fake/fake_resolver.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc index 85b9bea6f70..7f613ee21bc 100644 --- a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc @@ -175,11 +175,13 @@ void FakeResolverResponseGenerator::SetResponseLocked(void* arg, resolver->next_result_ = std::move(closure_arg->result); resolver->has_next_result_ = true; resolver->MaybeSendResultLocked(); + closure_arg->generator->Unref(); Delete(closure_arg); } void FakeResolverResponseGenerator::SetResponse(Resolver::Result result) { if (resolver_ != nullptr) { + Ref().release(); // ref to be held by closure SetResponseClosureArg* closure_arg = New(); closure_arg->generator = this; closure_arg->result = std::move(result); From a0aa16a0787e0f20515bb49fc708ea9e4ee7871b Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Fri, 17 May 2019 15:58:10 +1200 Subject: [PATCH 0238/1555] Remove System.Interactive.Async dependency --- src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj | 4 -- .../Grpc.Core.Api/IAsyncStreamReader.cs | 22 +++++--- src/csharp/Grpc.Core/Grpc.Core.csproj | 6 +-- .../Grpc.Core/Utils/AsyncStreamExtensions.cs | 53 +++++++++++++++++++ .../ReflectionClientServerTest.cs | 3 +- 5 files changed, 72 insertions(+), 16 deletions(-) diff --git a/src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj b/src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj index 8a32bc757df..7d9a236284d 100755 --- a/src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj +++ b/src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj @@ -25,10 +25,6 @@ - - - - diff --git a/src/csharp/Grpc.Core.Api/IAsyncStreamReader.cs b/src/csharp/Grpc.Core.Api/IAsyncStreamReader.cs index 3751d549e39..7ad4f2687b8 100644 --- a/src/csharp/Grpc.Core.Api/IAsyncStreamReader.cs +++ b/src/csharp/Grpc.Core.Api/IAsyncStreamReader.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2015 gRPC authors. // @@ -16,10 +16,7 @@ #endregion -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Threading; using System.Threading.Tasks; namespace Grpc.Core @@ -50,7 +47,20 @@ namespace Grpc.Core /// /// /// The message type. - public interface IAsyncStreamReader : IAsyncEnumerator + public interface IAsyncStreamReader { + /// + /// Gets the current element in the iteration. + /// + T Current { get; } + + /// + /// Advances the reader to the next element in the sequence, returning the result asynchronously. + /// + /// Cancellation token that can be used to cancel the operation. + /// + /// Task containing the result of the operation: true if the reader was successfully advanced + /// to the next element; false if the reader has passed the end of the sequence. + Task MoveNext(CancellationToken cancellationToken); } } diff --git a/src/csharp/Grpc.Core/Grpc.Core.csproj b/src/csharp/Grpc.Core/Grpc.Core.csproj index afd60e73a21..78392e9df58 100755 --- a/src/csharp/Grpc.Core/Grpc.Core.csproj +++ b/src/csharp/Grpc.Core/Grpc.Core.csproj @@ -1,4 +1,4 @@ - + @@ -98,10 +98,6 @@ - - - - diff --git a/src/csharp/Grpc.Core/Utils/AsyncStreamExtensions.cs b/src/csharp/Grpc.Core/Utils/AsyncStreamExtensions.cs index fce53c70074..6ca72a1139b 100644 --- a/src/csharp/Grpc.Core/Utils/AsyncStreamExtensions.cs +++ b/src/csharp/Grpc.Core/Utils/AsyncStreamExtensions.cs @@ -18,6 +18,7 @@ using System; using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; namespace Grpc.Core.Utils @@ -27,12 +28,41 @@ namespace Grpc.Core.Utils /// public static class AsyncStreamExtensions { + /// + /// Advances the stream reader to the next element in the sequence, returning the result asynchronously. + /// + /// The message type. + /// The stream reader. + /// + /// Task containing the result of the operation: true if the reader was successfully advanced + /// to the next element; false if the reader has passed the end of the sequence. + /// + public static Task MoveNext(this IAsyncStreamReader streamReader) + where T : class + { + if (streamReader == null) + { + throw new ArgumentNullException(nameof(streamReader)); + } + + return streamReader.MoveNext(CancellationToken.None); + } + /// /// Reads the entire stream and executes an async action for each element. /// public static async Task ForEachAsync(this IAsyncStreamReader streamReader, Func asyncAction) where T : class { + if (streamReader == null) + { + throw new ArgumentNullException(nameof(streamReader)); + } + if (asyncAction == null) + { + throw new ArgumentNullException(nameof(asyncAction)); + } + while (await streamReader.MoveNext().ConfigureAwait(false)) { await asyncAction(streamReader.Current).ConfigureAwait(false); @@ -45,6 +75,11 @@ namespace Grpc.Core.Utils public static async Task> ToListAsync(this IAsyncStreamReader streamReader) where T : class { + if (streamReader == null) + { + throw new ArgumentNullException(nameof(streamReader)); + } + var result = new List(); while (await streamReader.MoveNext().ConfigureAwait(false)) { @@ -60,6 +95,15 @@ namespace Grpc.Core.Utils public static async Task WriteAllAsync(this IClientStreamWriter streamWriter, IEnumerable elements, bool complete = true) where T : class { + if (streamWriter == null) + { + throw new ArgumentNullException(nameof(streamWriter)); + } + if (elements == null) + { + throw new ArgumentNullException(nameof(elements)); + } + foreach (var element in elements) { await streamWriter.WriteAsync(element).ConfigureAwait(false); @@ -76,6 +120,15 @@ namespace Grpc.Core.Utils public static async Task WriteAllAsync(this IServerStreamWriter streamWriter, IEnumerable elements) where T : class { + if (streamWriter == null) + { + throw new ArgumentNullException(nameof(streamWriter)); + } + if (elements == null) + { + throw new ArgumentNullException(nameof(elements)); + } + foreach (var element in elements) { await streamWriter.WriteAsync(element).ConfigureAwait(false); diff --git a/src/csharp/Grpc.Reflection.Tests/ReflectionClientServerTest.cs b/src/csharp/Grpc.Reflection.Tests/ReflectionClientServerTest.cs index 76f8cfadcfd..9ef9680f71c 100644 --- a/src/csharp/Grpc.Reflection.Tests/ReflectionClientServerTest.cs +++ b/src/csharp/Grpc.Reflection.Tests/ReflectionClientServerTest.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2015 gRPC authors. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,6 +21,7 @@ using System.Text; using System.Threading.Tasks; using Grpc.Core; +using Grpc.Core.Utils; using Grpc.Reflection; using Grpc.Reflection.V1Alpha; using NUnit.Framework; From 47660b784b3b6a15e12a2718a7df758cb70f6dc5 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Fri, 17 May 2019 16:21:08 +1200 Subject: [PATCH 0239/1555] Add missing namespace --- src/csharp/Grpc.Core.Tests/Internal/AsyncCallServerTest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallServerTest.cs b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallServerTest.cs index fd221613c04..d343271ffbe 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallServerTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallServerTest.cs @@ -23,6 +23,7 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; using Grpc.Core.Internal; +using Grpc.Core.Utils; using NUnit.Framework; namespace Grpc.Core.Internal.Tests From 40210d3b8a92a285d174322ee9f1e823d619cec3 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Thu, 16 May 2019 22:31:12 -0700 Subject: [PATCH 0240/1555] Move Channel to grpc_impl --- BUILD | 1 + BUILD.gn | 1 + CMakeLists.txt | 3 + Makefile | 3 + build.yaml | 1 + gRPC-C++.podspec | 1 + include/grpcpp/channel.h | 85 +--- include/grpcpp/channel_impl.h | 125 ++++++ include/grpcpp/impl/codegen/client_callback.h | 5 +- include/grpcpp/impl/codegen/client_context.h | 11 +- .../grpcpp/impl/codegen/client_interceptor.h | 6 +- .../grpcpp/impl/codegen/completion_queue.h | 372 +----------------- .../grpcpp/impl/codegen/server_interface.h | 4 +- include/grpcpp/security/credentials_impl.h | 1 + include/grpcpp/server_builder_impl.h | 2 - include/grpcpp/server_impl.h | 5 +- src/cpp/client/channel_cc.cc | 59 +-- src/cpp/client/client_context.cc | 9 +- src/cpp/client/create_channel.cc | 2 +- src/cpp/client/create_channel_internal.cc | 4 +- src/cpp/client/create_channel_internal.h | 4 +- src/cpp/client/create_channel_posix.cc | 6 +- src/cpp/client/secure_credentials.h | 2 + test/cpp/codegen/golden_file_test.cc | 2 +- test/cpp/microbenchmarks/fullstack_fixtures.h | 2 +- test/cpp/performance/writes_per_rpc_test.cc | 2 +- test/cpp/util/create_test_channel.h | 18 +- tools/doxygen/Doxyfile.c++ | 1 + tools/doxygen/Doxyfile.c++.internal | 1 + .../generated/sources_and_headers.json | 2 + 30 files changed, 228 insertions(+), 512 deletions(-) create mode 100644 include/grpcpp/channel_impl.h diff --git a/BUILD b/BUILD index 52c469f0b4a..da5439648d4 100644 --- a/BUILD +++ b/BUILD @@ -218,6 +218,7 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/alarm.h", "include/grpcpp/alarm_impl.h", "include/grpcpp/channel.h", + "include/grpcpp/channel_impl.h", "include/grpcpp/client_context.h", "include/grpcpp/completion_queue.h", "include/grpcpp/create_channel.h", diff --git a/BUILD.gn b/BUILD.gn index ea5d544972f..8ea6eeeced0 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1022,6 +1022,7 @@ config("grpc_config") { "include/grpcpp/alarm.h", "include/grpcpp/alarm_impl.h", "include/grpcpp/channel.h", + "include/grpcpp/channel_impl.h", "include/grpcpp/client_context.h", "include/grpcpp/completion_queue.h", "include/grpcpp/create_channel.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index f85bff572e6..4e79f073a5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3150,6 +3150,7 @@ foreach(_hdr include/grpcpp/alarm.h include/grpcpp/alarm_impl.h include/grpcpp/channel.h + include/grpcpp/channel_impl.h include/grpcpp/client_context.h include/grpcpp/completion_queue.h include/grpcpp/create_channel.h @@ -3765,6 +3766,7 @@ foreach(_hdr include/grpcpp/alarm.h include/grpcpp/alarm_impl.h include/grpcpp/channel.h + include/grpcpp/channel_impl.h include/grpcpp/client_context.h include/grpcpp/completion_queue.h include/grpcpp/create_channel.h @@ -4752,6 +4754,7 @@ foreach(_hdr include/grpcpp/alarm.h include/grpcpp/alarm_impl.h include/grpcpp/channel.h + include/grpcpp/channel_impl.h include/grpcpp/client_context.h include/grpcpp/completion_queue.h include/grpcpp/create_channel.h diff --git a/Makefile b/Makefile index 9cf0ab03f09..4bcc6417816 100644 --- a/Makefile +++ b/Makefile @@ -5507,6 +5507,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/alarm.h \ include/grpcpp/alarm_impl.h \ include/grpcpp/channel.h \ + include/grpcpp/channel_impl.h \ include/grpcpp/client_context.h \ include/grpcpp/completion_queue.h \ include/grpcpp/create_channel.h \ @@ -6130,6 +6131,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/alarm.h \ include/grpcpp/alarm_impl.h \ include/grpcpp/channel.h \ + include/grpcpp/channel_impl.h \ include/grpcpp/client_context.h \ include/grpcpp/completion_queue.h \ include/grpcpp/create_channel.h \ @@ -7066,6 +7068,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/alarm.h \ include/grpcpp/alarm_impl.h \ include/grpcpp/channel.h \ + include/grpcpp/channel_impl.h \ include/grpcpp/client_context.h \ include/grpcpp/completion_queue.h \ include/grpcpp/create_channel.h \ diff --git a/build.yaml b/build.yaml index fbfa0df86cd..0364be34caa 100644 --- a/build.yaml +++ b/build.yaml @@ -1350,6 +1350,7 @@ filegroups: - include/grpcpp/alarm.h - include/grpcpp/alarm_impl.h - include/grpcpp/channel.h + - include/grpcpp/channel_impl.h - include/grpcpp/client_context.h - include/grpcpp/completion_queue.h - include/grpcpp/create_channel.h diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 57743df8c7c..a62b9c84a63 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -82,6 +82,7 @@ Pod::Spec.new do |s| ss.source_files = 'include/grpcpp/alarm.h', 'include/grpcpp/alarm_impl.h', 'include/grpcpp/channel.h', + 'include/grpcpp/channel_impl.h', 'include/grpcpp/client_context.h', 'include/grpcpp/completion_queue.h', 'include/grpcpp/create_channel.h', diff --git a/include/grpcpp/channel.h b/include/grpcpp/channel.h index b3c4703d9d5..163c804ffbe 100644 --- a/include/grpcpp/channel.h +++ b/include/grpcpp/channel.h @@ -19,22 +19,12 @@ #ifndef GRPCPP_CHANNEL_H #define GRPCPP_CHANNEL_H -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -struct grpc_channel; +#include namespace grpc { +typedef ::grpc_impl::Channel Channel; + namespace experimental { /// Resets the channel's connection backoff. /// TODO(roth): Once we see whether this proves useful, either create a gRFC @@ -42,75 +32,6 @@ namespace experimental { void ChannelResetConnectionBackoff(Channel* channel); } // namespace experimental -/// Channels represent a connection to an endpoint. Created by \a CreateChannel. -class Channel final : public ChannelInterface, - public internal::CallHook, - public std::enable_shared_from_this, - private GrpcLibraryCodegen { - public: - ~Channel(); - - /// Get the current channel state. If the channel is in IDLE and - /// \a try_to_connect is set to true, try to connect. - grpc_connectivity_state GetState(bool try_to_connect) override; - - /// Returns the LB policy name, or the empty string if not yet available. - grpc::string GetLoadBalancingPolicyName() const; - - /// Returns the service config in JSON form, or the empty string if - /// not available. - grpc::string GetServiceConfigJSON() const; - - private: - template - friend class internal::BlockingUnaryCallImpl; - friend void experimental::ChannelResetConnectionBackoff(Channel* channel); - friend std::shared_ptr CreateChannelInternal( - const grpc::string& host, grpc_channel* c_channel, - std::vector> - interceptor_creators); - friend class internal::InterceptedChannel; - Channel(const grpc::string& host, grpc_channel* c_channel, - std::vector< - std::unique_ptr> - interceptor_creators); - - internal::Call CreateCall(const internal::RpcMethod& method, - ClientContext* context, - CompletionQueue* cq) override; - void PerformOpsOnCall(internal::CallOpSetInterface* ops, - internal::Call* call) override; - void* RegisterMethod(const char* method) override; - - void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, - gpr_timespec deadline, CompletionQueue* cq, - void* tag) override; - bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, - gpr_timespec deadline) override; - - CompletionQueue* CallbackCQ() override; - - internal::Call CreateCallInternal(const internal::RpcMethod& method, - ClientContext* context, CompletionQueue* cq, - size_t interceptor_pos) override; - - const grpc::string host_; - grpc_channel* const c_channel_; // owned - - // mu_ protects callback_cq_ (the per-channel callbackable completion queue) - grpc::internal::Mutex mu_; - - // callback_cq_ references the callbackable completion queue associated - // with this channel (if any). It is set on the first call to CallbackCQ(). - // It is _not owned_ by the channel; ownership belongs with its internal - // shutdown callback tag (invoked when the CQ is fully shutdown). - CompletionQueue* callback_cq_ = nullptr; - - std::vector> - interceptor_creators_; -}; - } // namespace grpc #endif // GRPCPP_CHANNEL_H diff --git a/include/grpcpp/channel_impl.h b/include/grpcpp/channel_impl.h new file mode 100644 index 00000000000..39917d2eb74 --- /dev/null +++ b/include/grpcpp/channel_impl.h @@ -0,0 +1,125 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_CHANNEL_IMPL_H +#define GRPCPP_CHANNEL_IMPL_H + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +struct grpc_channel; + +namespace grpc { + +std::shared_ptr<::grpc_impl::Channel> CreateChannelInternal( + const grpc::string& host, grpc_channel* c_channel, + std::vector< + std::unique_ptr> + interceptor_creators); +} // namespace grpc +namespace grpc_impl { + +namespace experimental { +/// Resets the channel's connection backoff. +/// TODO(roth): Once we see whether this proves useful, either create a gRFC +/// and change this to be a method of the Channel class, or remove it. +void ChannelResetConnectionBackoff(Channel* channel); +} // namespace experimental + +/// Channels represent a connection to an endpoint. Created by \a CreateChannel. +class Channel final : public ::grpc::ChannelInterface, + public ::grpc::internal::CallHook, + public std::enable_shared_from_this, + private ::grpc::GrpcLibraryCodegen { + public: + ~Channel(); + + /// Get the current channel state. If the channel is in IDLE and + /// \a try_to_connect is set to true, try to connect. + grpc_connectivity_state GetState(bool try_to_connect) override; + + /// Returns the LB policy name, or the empty string if not yet available. + grpc::string GetLoadBalancingPolicyName() const; + + /// Returns the service config in JSON form, or the empty string if + /// not available. + grpc::string GetServiceConfigJSON() const; + + private: + template + friend class ::grpc::internal::BlockingUnaryCallImpl; + friend void experimental::ChannelResetConnectionBackoff(Channel* channel); + friend std::shared_ptr grpc::CreateChannelInternal( + const grpc::string& host, grpc_channel* c_channel, + std::vector> + interceptor_creators); + friend class ::grpc::internal::InterceptedChannel; + Channel(const grpc::string& host, grpc_channel* c_channel, + std::vector> + interceptor_creators); + + ::grpc::internal::Call CreateCall(const ::grpc::internal::RpcMethod& method, + ::grpc::ClientContext* context, + ::grpc::CompletionQueue* cq) override; + void PerformOpsOnCall(::grpc::internal::CallOpSetInterface* ops, + ::grpc::internal::Call* call) override; + void* RegisterMethod(const char* method) override; + + void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline, + ::grpc::CompletionQueue* cq, void* tag) override; + bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline) override; + + ::grpc::CompletionQueue* CallbackCQ() override; + + ::grpc::internal::Call CreateCallInternal( + const ::grpc::internal::RpcMethod& method, ::grpc::ClientContext* context, + ::grpc::CompletionQueue* cq, size_t interceptor_pos) override; + + const grpc::string host_; + grpc_channel* const c_channel_; // owned + + // mu_ protects callback_cq_ (the per-channel callbackable completion queue) + grpc::internal::Mutex mu_; + + // callback_cq_ references the callbackable completion queue associated + // with this channel (if any). It is set on the first call to CallbackCQ(). + // It is _not owned_ by the channel; ownership belongs with its internal + // shutdown callback tag (invoked when the CQ is fully shutdown). + ::grpc::CompletionQueue* callback_cq_ = nullptr; + + std::vector< + std::unique_ptr<::grpc::experimental::ClientInterceptorFactoryInterface>> + interceptor_creators_; +}; + +} // namespace grpc_impl + +#endif // GRPCPP_CHANNEL_IMPL_H diff --git a/include/grpcpp/impl/codegen/client_callback.h b/include/grpcpp/impl/codegen/client_callback.h index c897f6676d9..f0499858a05 100644 --- a/include/grpcpp/impl/codegen/client_callback.h +++ b/include/grpcpp/impl/codegen/client_callback.h @@ -29,9 +29,12 @@ #include #include +namespace grpc_impl { +class Channel; +} + namespace grpc { -class Channel; class ClientContext; class CompletionQueue; diff --git a/include/grpcpp/impl/codegen/client_context.h b/include/grpcpp/impl/codegen/client_context.h index 355ac557b3a..999d8fcbfe7 100644 --- a/include/grpcpp/impl/codegen/client_context.h +++ b/include/grpcpp/impl/codegen/client_context.h @@ -60,12 +60,12 @@ struct grpc_call; namespace grpc_impl { class CallCredentials; +class Channel; +class CompletionQueue; } // namespace grpc_impl namespace grpc { -class Channel; class ChannelInterface; -class CompletionQueue; class ClientContext; namespace internal { @@ -397,7 +397,7 @@ class ClientContext { friend class ::grpc::testing::InteropClientContextInspector; friend class ::grpc::internal::CallOpClientRecvStatus; friend class ::grpc::internal::CallOpRecvInitialMetadata; - friend class Channel; + friend class ::grpc_impl::Channel; template friend class ::grpc::ClientReader; template @@ -430,7 +430,8 @@ class ClientContext { } grpc_call* call() const { return call_; } - void set_call(grpc_call* call, const std::shared_ptr& channel); + void set_call(grpc_call* call, + const std::shared_ptr<::grpc_impl::Channel>& channel); experimental::ClientRpcInfo* set_client_rpc_info( const char* method, internal::RpcMethod::RpcType type, @@ -463,7 +464,7 @@ class ClientContext { bool wait_for_ready_explicitly_set_; bool idempotent_; bool cacheable_; - std::shared_ptr channel_; + std::shared_ptr<::grpc_impl::Channel> channel_; grpc::internal::Mutex mu_; grpc_call* call_; bool call_canceled_; diff --git a/include/grpcpp/impl/codegen/client_interceptor.h b/include/grpcpp/impl/codegen/client_interceptor.h index 19106545089..a4c85a76da5 100644 --- a/include/grpcpp/impl/codegen/client_interceptor.h +++ b/include/grpcpp/impl/codegen/client_interceptor.h @@ -26,10 +26,14 @@ #include #include +namespace grpc_impl { + +class Channel; +} + namespace grpc { class ClientContext; -class Channel; namespace internal { class InterceptorBatchMethodsImpl; diff --git a/include/grpcpp/impl/codegen/completion_queue.h b/include/grpcpp/impl/codegen/completion_queue.h index 5afff52bfb1..472d95504dc 100644 --- a/include/grpcpp/impl/codegen/completion_queue.h +++ b/include/grpcpp/impl/codegen/completion_queue.h @@ -39,378 +39,10 @@ #include #include -struct grpc_completion_queue; - -namespace grpc_impl { - -class Server; -class ServerBuilder; -} // namespace grpc_impl namespace grpc { -template -class ClientReader; -template -class ClientWriter; -template -class ClientReaderWriter; -template -class ServerReader; -template -class ServerWriter; -namespace internal { -template -class ServerReaderWriterBody; -} // namespace internal - -class Channel; -class ChannelInterface; -class ClientContext; -class CompletionQueue; -class ServerContext; -class ServerInterface; - -namespace internal { -class CompletionQueueTag; -class RpcMethod; -template -class RpcMethodHandler; -template -class ClientStreamingHandler; -template -class ServerStreamingHandler; -template -class BidiStreamingHandler; -template -class TemplatedBidiStreamingHandler; -template -class ErrorMethodHandler; -template -class BlockingUnaryCallImpl; -template -class CallOpSet; -} // namespace internal - -extern CoreCodegenInterface* g_core_codegen_interface; - -/// A thin wrapper around \ref grpc_completion_queue (see \ref -/// src/core/lib/surface/completion_queue.h). -/// See \ref doc/cpp/perf_notes.md for notes on best practices for high -/// performance servers. -class CompletionQueue : private GrpcLibraryCodegen { - public: - /// Default constructor. Implicitly creates a \a grpc_completion_queue - /// instance. - CompletionQueue() - : CompletionQueue(grpc_completion_queue_attributes{ - GRPC_CQ_CURRENT_VERSION, GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, - nullptr}) {} - - /// Wrap \a take, taking ownership of the instance. - /// - /// \param take The completion queue instance to wrap. Ownership is taken. - explicit CompletionQueue(grpc_completion_queue* take); - - /// Destructor. Destroys the owned wrapped completion queue / instance. - ~CompletionQueue() { - g_core_codegen_interface->grpc_completion_queue_destroy(cq_); - } - - /// Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT. - enum NextStatus { - SHUTDOWN, ///< The completion queue has been shutdown and fully-drained - GOT_EVENT, ///< Got a new event; \a tag will be filled in with its - ///< associated value; \a ok indicating its success. - TIMEOUT ///< deadline was reached. - }; - - /// Read from the queue, blocking until an event is available or the queue is - /// shutting down. - /// - /// \param tag [out] Updated to point to the read event's tag. - /// \param ok [out] true if read a successful event, false otherwise. - /// - /// Note that each tag sent to the completion queue (through RPC operations - /// or alarms) will be delivered out of the completion queue by a call to - /// Next (or a related method), regardless of whether the operation succeeded - /// or not. Success here means that this operation completed in the normal - /// valid manner. - /// - /// Server-side RPC request: \a ok indicates that the RPC has indeed - /// been started. If it is false, the server has been Shutdown - /// before this particular call got matched to an incoming RPC. - /// - /// Client-side StartCall/RPC invocation: \a ok indicates that the RPC is - /// going to go to the wire. If it is false, it not going to the wire. This - /// would happen if the channel is either permanently broken or - /// transiently broken but with the fail-fast option. (Note that async unary - /// RPCs don't post a CQ tag at this point, nor do client-streaming - /// or bidi-streaming RPCs that have the initial metadata corked option set.) - /// - /// Client-side Write, Client-side WritesDone, Server-side Write, - /// Server-side Finish, Server-side SendInitialMetadata (which is - /// typically included in Write or Finish when not done explicitly): - /// \a ok means that the data/metadata/status/etc is going to go to the - /// wire. If it is false, it not going to the wire because the call - /// is already dead (i.e., canceled, deadline expired, other side - /// dropped the channel, etc). - /// - /// Client-side Read, Server-side Read, Client-side - /// RecvInitialMetadata (which is typically included in Read if not - /// done explicitly): \a ok indicates whether there is a valid message - /// that got read. If not, you know that there are certainly no more - /// messages that can ever be read from this stream. For the client-side - /// operations, this only happens because the call is dead. For the - /// server-sider operation, though, this could happen because the client - /// has done a WritesDone already. - /// - /// Client-side Finish: \a ok should always be true - /// - /// Server-side AsyncNotifyWhenDone: \a ok should always be true - /// - /// Alarm: \a ok is true if it expired, false if it was canceled - /// - /// \return true if got an event, false if the queue is fully drained and - /// shut down. - bool Next(void** tag, bool* ok) { - return (AsyncNextInternal(tag, ok, - g_core_codegen_interface->gpr_inf_future( - GPR_CLOCK_REALTIME)) != SHUTDOWN); - } - - /// Read from the queue, blocking up to \a deadline (or the queue's shutdown). - /// Both \a tag and \a ok are updated upon success (if an event is available - /// within the \a deadline). A \a tag points to an arbitrary location usually - /// employed to uniquely identify an event. - /// - /// \param tag [out] Upon success, updated to point to the event's tag. - /// \param ok [out] Upon success, true if a successful event, false otherwise - /// See documentation for CompletionQueue::Next for explanation of ok - /// \param deadline [in] How long to block in wait for an event. - /// - /// \return The type of event read. - template - NextStatus AsyncNext(void** tag, bool* ok, const T& deadline) { - TimePoint deadline_tp(deadline); - return AsyncNextInternal(tag, ok, deadline_tp.raw_time()); - } - - /// EXPERIMENTAL - /// First executes \a F, then reads from the queue, blocking up to - /// \a deadline (or the queue's shutdown). - /// Both \a tag and \a ok are updated upon success (if an event is available - /// within the \a deadline). A \a tag points to an arbitrary location usually - /// employed to uniquely identify an event. - /// - /// \param f [in] Function to execute before calling AsyncNext on this queue. - /// \param tag [out] Upon success, updated to point to the event's tag. - /// \param ok [out] Upon success, true if read a regular event, false - /// otherwise. - /// \param deadline [in] How long to block in wait for an event. - /// - /// \return The type of event read. - template - NextStatus DoThenAsyncNext(F&& f, void** tag, bool* ok, const T& deadline) { - CompletionQueueTLSCache cache = CompletionQueueTLSCache(this); - f(); - if (cache.Flush(tag, ok)) { - return GOT_EVENT; - } else { - return AsyncNext(tag, ok, deadline); - } - } - - /// Request the shutdown of the queue. - /// - /// \warning This method must be called at some point if this completion queue - /// is accessed with Next or AsyncNext. \a Next will not return false - /// until this method has been called and all pending tags have been drained. - /// (Likewise for \a AsyncNext returning \a NextStatus::SHUTDOWN .) - /// Only once either one of these methods does that (that is, once the queue - /// has been \em drained) can an instance of this class be destroyed. - /// Also note that applications must ensure that no work is enqueued on this - /// completion queue after this method is called. - void Shutdown(); - - /// Returns a \em raw pointer to the underlying \a grpc_completion_queue - /// instance. - /// - /// \warning Remember that the returned instance is owned. No transfer of - /// owership is performed. - grpc_completion_queue* cq() { return cq_; } - - protected: - /// Private constructor of CompletionQueue only visible to friend classes - CompletionQueue(const grpc_completion_queue_attributes& attributes) { - cq_ = g_core_codegen_interface->grpc_completion_queue_create( - g_core_codegen_interface->grpc_completion_queue_factory_lookup( - &attributes), - &attributes, NULL); - InitialAvalanching(); // reserve this for the future shutdown - } - - private: - // Friend synchronous wrappers so that they can access Pluck(), which is - // a semi-private API geared towards the synchronous implementation. - template - friend class ::grpc::ClientReader; - template - friend class ::grpc::ClientWriter; - template - friend class ::grpc::ClientReaderWriter; - template - friend class ::grpc::ServerReader; - template - friend class ::grpc::ServerWriter; - template - friend class ::grpc::internal::ServerReaderWriterBody; - template - friend class ::grpc::internal::RpcMethodHandler; - template - friend class ::grpc::internal::ClientStreamingHandler; - template - friend class ::grpc::internal::ServerStreamingHandler; - template - friend class ::grpc::internal::TemplatedBidiStreamingHandler; - template - friend class ::grpc::internal::ErrorMethodHandler; - friend class ::grpc_impl::Server; - friend class ::grpc::ServerContext; - friend class ::grpc::ServerInterface; - template - friend class ::grpc::internal::BlockingUnaryCallImpl; - - // Friends that need access to constructor for callback CQ - friend class ::grpc::Channel; - - // For access to Register/CompleteAvalanching - template - friend class ::grpc::internal::CallOpSet; - - /// EXPERIMENTAL - /// Creates a Thread Local cache to store the first event - /// On this completion queue queued from this thread. Once - /// initialized, it must be flushed on the same thread. - class CompletionQueueTLSCache { - public: - CompletionQueueTLSCache(CompletionQueue* cq); - ~CompletionQueueTLSCache(); - bool Flush(void** tag, bool* ok); - - private: - CompletionQueue* cq_; - bool flushed_; - }; - - NextStatus AsyncNextInternal(void** tag, bool* ok, gpr_timespec deadline); - - /// Wraps \a grpc_completion_queue_pluck. - /// \warning Must not be mixed with calls to \a Next. - bool Pluck(internal::CompletionQueueTag* tag) { - auto deadline = - g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_REALTIME); - while (true) { - auto ev = g_core_codegen_interface->grpc_completion_queue_pluck( - cq_, tag, deadline, nullptr); - bool ok = ev.success != 0; - void* ignored = tag; - if (tag->FinalizeResult(&ignored, &ok)) { - GPR_CODEGEN_ASSERT(ignored == tag); - return ok; - } - } - } - - /// Performs a single polling pluck on \a tag. - /// \warning Must not be mixed with calls to \a Next. - /// - /// TODO: sreek - This calls tag->FinalizeResult() even if the cq_ is already - /// shutdown. This is most likely a bug and if it is a bug, then change this - /// implementation to simple call the other TryPluck function with a zero - /// timeout. i.e: - /// TryPluck(tag, gpr_time_0(GPR_CLOCK_REALTIME)) - void TryPluck(internal::CompletionQueueTag* tag) { - auto deadline = g_core_codegen_interface->gpr_time_0(GPR_CLOCK_REALTIME); - auto ev = g_core_codegen_interface->grpc_completion_queue_pluck( - cq_, tag, deadline, nullptr); - if (ev.type == GRPC_QUEUE_TIMEOUT) return; - bool ok = ev.success != 0; - void* ignored = tag; - // the tag must be swallowed if using TryPluck - GPR_CODEGEN_ASSERT(!tag->FinalizeResult(&ignored, &ok)); - } - - /// Performs a single polling pluck on \a tag. Calls tag->FinalizeResult if - /// the pluck() was successful and returned the tag. - /// - /// This exects tag->FinalizeResult (if called) to return 'false' i.e expects - /// that the tag is internal not something that is returned to the user. - void TryPluck(internal::CompletionQueueTag* tag, gpr_timespec deadline) { - auto ev = g_core_codegen_interface->grpc_completion_queue_pluck( - cq_, tag, deadline, nullptr); - if (ev.type == GRPC_QUEUE_TIMEOUT || ev.type == GRPC_QUEUE_SHUTDOWN) { - return; - } - - bool ok = ev.success != 0; - void* ignored = tag; - GPR_CODEGEN_ASSERT(!tag->FinalizeResult(&ignored, &ok)); - } - - /// Manage state of avalanching operations : completion queue tags that - /// trigger other completion queue operations. The underlying core completion - /// queue should not really shutdown until all avalanching operations have - /// been finalized. Note that we maintain the requirement that an avalanche - /// registration must take place before CQ shutdown (which must be maintained - /// elsewhere) - void InitialAvalanching() { - gpr_atm_rel_store(&avalanches_in_flight_, static_cast(1)); - } - void RegisterAvalanching() { - gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_, - static_cast(1)); - } - void CompleteAvalanching() { - if (gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_, - static_cast(-1)) == 1) { - g_core_codegen_interface->grpc_completion_queue_shutdown(cq_); - } - } - - grpc_completion_queue* cq_; // owned - - gpr_atm avalanches_in_flight_; -}; - -/// A specific type of completion queue used by the processing of notifications -/// by servers. Instantiated by \a ServerBuilder. -class ServerCompletionQueue : public CompletionQueue { - public: - bool IsFrequentlyPolled() { return polling_type_ != GRPC_CQ_NON_LISTENING; } - - protected: - /// Default constructor - ServerCompletionQueue() : polling_type_(GRPC_CQ_DEFAULT_POLLING) {} - - private: - /// \param completion_type indicates whether this is a NEXT or CALLBACK - /// completion queue. - /// \param polling_type Informs the GRPC library about the type of polling - /// allowed on this completion queue. See grpc_cq_polling_type's description - /// in grpc_types.h for more details. - /// \param shutdown_cb is the shutdown callback used for CALLBACK api queues - ServerCompletionQueue(grpc_cq_completion_type completion_type, - grpc_cq_polling_type polling_type, - grpc_experimental_completion_queue_functor* shutdown_cb) - : CompletionQueue(grpc_completion_queue_attributes{ - GRPC_CQ_CURRENT_VERSION, completion_type, polling_type, - shutdown_cb}), - polling_type_(polling_type) {} - - grpc_cq_polling_type polling_type_; - friend class grpc_impl::ServerBuilder; - friend class grpc_impl::Server; -}; +typedef ::grpc_impl::CompletionQueue CompletionQueue; +typedef ::grpc_impl::ServerCompletionQueue ServerCompletionQueue; } // namespace grpc diff --git a/include/grpcpp/impl/codegen/server_interface.h b/include/grpcpp/impl/codegen/server_interface.h index ebad4eb25e1..26e997bfb56 100644 --- a/include/grpcpp/impl/codegen/server_interface.h +++ b/include/grpcpp/impl/codegen/server_interface.h @@ -30,12 +30,14 @@ namespace grpc_impl { +class Channel; +class CompletionQueue; +class ServerCompletionQueue; class ServerCredentials; } // namespace grpc_impl namespace grpc { class AsyncGenericService; -class Channel; class GenericServerContext; class ServerCompletionQueue; class ServerContext; diff --git a/include/grpcpp/security/credentials_impl.h b/include/grpcpp/security/credentials_impl.h index dec60b11eb4..29ba2075c29 100644 --- a/include/grpcpp/security/credentials_impl.h +++ b/include/grpcpp/security/credentials_impl.h @@ -24,6 +24,7 @@ #include #include +#include #include #include #include diff --git a/include/grpcpp/server_builder_impl.h b/include/grpcpp/server_builder_impl.h index 0551862d38f..7c197a52f09 100644 --- a/include/grpcpp/server_builder_impl.h +++ b/include/grpcpp/server_builder_impl.h @@ -45,8 +45,6 @@ class ServerCredentials; namespace grpc { class AsyncGenericService; -class CompletionQueue; -class ServerCompletionQueue; class Service; namespace testing { class ServerBuilderPluginTest; diff --git a/include/grpcpp/server_impl.h b/include/grpcpp/server_impl.h index 035c22136e4..59a780276e0 100644 --- a/include/grpcpp/server_impl.h +++ b/include/grpcpp/server_impl.h @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -107,7 +108,7 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { } /// Establish a channel for in-process communication - std::shared_ptr InProcessChannel( + std::shared_ptr<::grpc::Channel> InProcessChannel( const grpc::ChannelArguments& args); /// NOTE: class experimental_type is not part of the public API of this class. @@ -119,7 +120,7 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { /// Establish a channel for in-process communication with client /// interceptors - std::shared_ptr InProcessChannelWithInterceptors( + std::shared_ptr<::grpc::Channel> InProcessChannelWithInterceptors( const grpc::ChannelArguments& args, std::vector> diff --git a/src/cpp/client/channel_cc.cc b/src/cpp/client/channel_cc.cc index 5812e96771f..f0aa8e4017a 100644 --- a/src/cpp/client/channel_cc.cc +++ b/src/cpp/client/channel_cc.cc @@ -42,14 +42,17 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/surface/completion_queue.h" -namespace grpc { +void ::grpc::experimental::ChannelResetConnectionBackoff(Channel* channel) { + grpc_impl::experimental::ChannelResetConnectionBackoff(channel); +} -static internal::GrpcLibraryInitializer g_gli_initializer; -Channel::Channel( - const grpc::string& host, grpc_channel* channel, - std::vector< - std::unique_ptr> - interceptor_creators) +namespace grpc_impl { + +static ::grpc::internal::GrpcLibraryInitializer g_gli_initializer; +Channel::Channel(const grpc::string& host, grpc_channel* channel, + std::vector> + interceptor_creators) : host_(host), c_channel_(channel) { interceptor_creators_ = std::move(interceptor_creators); g_gli_initializer.summon(); @@ -65,7 +68,8 @@ Channel::~Channel() { namespace { inline grpc_slice SliceFromArray(const char* arr, size_t len) { - return g_core_codegen_interface->grpc_slice_from_copied_buffer(arr, len); + return ::grpc::g_core_codegen_interface->grpc_slice_from_copied_buffer(arr, + len); } grpc::string GetChannelInfoField(grpc_channel* channel, @@ -103,10 +107,9 @@ void ChannelResetConnectionBackoff(Channel* channel) { } // namespace experimental -internal::Call Channel::CreateCallInternal(const internal::RpcMethod& method, - ClientContext* context, - CompletionQueue* cq, - size_t interceptor_pos) { +::grpc::internal::Call Channel::CreateCallInternal( + const ::grpc::internal::RpcMethod& method, ::grpc::ClientContext* context, + ::grpc::CompletionQueue* cq, size_t interceptor_pos) { const bool kRegistered = method.channel_tag() && context->authority().empty(); grpc_call* c_call = nullptr; if (kRegistered) { @@ -115,7 +118,7 @@ internal::Call Channel::CreateCallInternal(const internal::RpcMethod& method, context->propagation_options_.c_bitmask(), cq->cq(), method.channel_tag(), context->raw_deadline(), nullptr); } else { - const string* host_str = nullptr; + const ::grpc::string* host_str = nullptr; if (!context->authority_.empty()) { host_str = &context->authority_; } else if (!host_.empty()) { @@ -125,7 +128,7 @@ internal::Call Channel::CreateCallInternal(const internal::RpcMethod& method, SliceFromArray(method.name(), strlen(method.name())); grpc_slice host_slice; if (host_str != nullptr) { - host_slice = SliceFromCopiedString(*host_str); + host_slice = ::grpc::SliceFromCopiedString(*host_str); } c_call = grpc_channel_create_call( c_channel_, context->propagate_from_call_, @@ -147,17 +150,17 @@ internal::Call Channel::CreateCallInternal(const internal::RpcMethod& method, interceptor_creators_, interceptor_pos); context->set_call(c_call, shared_from_this()); - return internal::Call(c_call, this, cq, info); + return ::grpc::internal::Call(c_call, this, cq, info); } -::grpc::internal::Call Channel::CreateCall(const internal::RpcMethod& method, - ClientContext* context, - CompletionQueue* cq) { +::grpc::internal::Call Channel::CreateCall( + const ::grpc::internal::RpcMethod& method, ::grpc::ClientContext* context, + CompletionQueue* cq) { return CreateCallInternal(method, context, cq, 0); } -void Channel::PerformOpsOnCall(internal::CallOpSetInterface* ops, - internal::Call* call) { +void Channel::PerformOpsOnCall(::grpc::internal::CallOpSetInterface* ops, + ::grpc::internal::Call* call) { ops->FillOps( call); // Make a copy of call. It's fine since Call just has pointers } @@ -173,7 +176,7 @@ grpc_connectivity_state Channel::GetState(bool try_to_connect) { namespace { -class TagSaver final : public internal::CompletionQueueTag { +class TagSaver final : public ::grpc::internal::CompletionQueueTag { public: explicit TagSaver(void* tag) : tag_(tag) {} ~TagSaver() override {} @@ -191,7 +194,7 @@ class TagSaver final : public internal::CompletionQueueTag { void Channel::NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline, - CompletionQueue* cq, void* tag) { + ::grpc::CompletionQueue* cq, void* tag) { TagSaver* tag_saver = new TagSaver(tag); grpc_channel_watch_connectivity_state(c_channel_, last_observed, deadline, cq->cq(), tag_saver); @@ -199,7 +202,7 @@ void Channel::NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, bool Channel::WaitForStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline) { - CompletionQueue cq; + ::grpc::CompletionQueue cq; bool ok = false; void* tag = nullptr; NotifyOnStateChangeImpl(last_observed, deadline, &cq, nullptr); @@ -214,7 +217,7 @@ class ShutdownCallback : public grpc_experimental_completion_queue_functor { ShutdownCallback() { functor_run = &ShutdownCallback::Run; } // TakeCQ takes ownership of the cq into the shutdown callback // so that the shutdown callback will be responsible for destroying it - void TakeCQ(CompletionQueue* cq) { cq_ = cq; } + void TakeCQ(::grpc::CompletionQueue* cq) { cq_ = cq; } // The Run function will get invoked by the completion queue library // when the shutdown is actually complete @@ -225,17 +228,17 @@ class ShutdownCallback : public grpc_experimental_completion_queue_functor { } private: - CompletionQueue* cq_ = nullptr; + ::grpc::CompletionQueue* cq_ = nullptr; }; } // namespace -CompletionQueue* Channel::CallbackCQ() { +::grpc::CompletionQueue* Channel::CallbackCQ() { // TODO(vjpai): Consider using a single global CQ for the default CQ // if there is no explicit per-channel CQ registered grpc::internal::MutexLock l(&mu_); if (callback_cq_ == nullptr) { auto* shutdown_callback = new ShutdownCallback; - callback_cq_ = new CompletionQueue(grpc_completion_queue_attributes{ + callback_cq_ = new ::grpc::CompletionQueue(grpc_completion_queue_attributes{ GRPC_CQ_CURRENT_VERSION, GRPC_CQ_CALLBACK, GRPC_CQ_DEFAULT_POLLING, shutdown_callback}); @@ -245,4 +248,4 @@ CompletionQueue* Channel::CallbackCQ() { return callback_cq_; } -} // namespace grpc +} // namespace grpc_impl diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index b4fce79b99a..0ae1ecbf4ba 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -31,6 +31,11 @@ #include #include +namespace grpc_impl { + +class Channel; +} + namespace grpc { class DefaultGlobalClientCallbacks final @@ -83,8 +88,8 @@ void ClientContext::AddMetadata(const grpc::string& meta_key, send_initial_metadata_.insert(std::make_pair(meta_key, meta_value)); } -void ClientContext::set_call(grpc_call* call, - const std::shared_ptr& channel) { +void ClientContext::set_call( + grpc_call* call, const std::shared_ptr<::grpc_impl::Channel>& channel) { grpc::internal::MutexLock lock(&mu_); GPR_ASSERT(call_ == nullptr); call_ = call; diff --git a/src/cpp/client/create_channel.cc b/src/cpp/client/create_channel.cc index 3318ded7268..ca7038b8893 100644 --- a/src/cpp/client/create_channel.cc +++ b/src/cpp/client/create_channel.cc @@ -71,7 +71,7 @@ std::shared_ptr CreateCustomChannelWithInterceptors( interceptor_creators) { return creds ? creds->CreateChannelWithInterceptors( target, args, std::move(interceptor_creators)) - : ::grpc::CreateChannelInternal( + : grpc::CreateChannelInternal( "", grpc_lame_client_channel_create( nullptr, GRPC_STATUS_INVALID_ARGUMENT, diff --git a/src/cpp/client/create_channel_internal.cc b/src/cpp/client/create_channel_internal.cc index 0ea311367e4..63e1d14eb34 100644 --- a/src/cpp/client/create_channel_internal.cc +++ b/src/cpp/client/create_channel_internal.cc @@ -26,8 +26,8 @@ namespace grpc { std::shared_ptr CreateChannelInternal( const grpc::string& host, grpc_channel* c_channel, - std::vector< - std::unique_ptr> + std::vector> interceptor_creators) { return std::shared_ptr( new Channel(host, c_channel, std::move(interceptor_creators))); diff --git a/src/cpp/client/create_channel_internal.h b/src/cpp/client/create_channel_internal.h index 4a87076fb10..3b201afb5a7 100644 --- a/src/cpp/client/create_channel_internal.h +++ b/src/cpp/client/create_channel_internal.h @@ -30,8 +30,8 @@ namespace grpc { std::shared_ptr CreateChannelInternal( const grpc::string& host, grpc_channel* c_channel, - std::vector< - std::unique_ptr> + std::vector> interceptor_creators); } // namespace grpc diff --git a/src/cpp/client/create_channel_posix.cc b/src/cpp/client/create_channel_posix.cc index 61260a27c66..ca26c3f0a9f 100644 --- a/src/cpp/client/create_channel_posix.cc +++ b/src/cpp/client/create_channel_posix.cc @@ -34,7 +34,7 @@ std::shared_ptr CreateInsecureChannelFromFd( const grpc::string& target, int fd) { grpc::internal::GrpcLibrary init_lib; init_lib.init(); - return grpc::CreateChannelInternal( + return ::grpc::CreateChannelInternal( "", grpc_insecure_channel_create_from_fd(target.c_str(), fd, nullptr), std::vector>()); @@ -46,7 +46,7 @@ std::shared_ptr CreateCustomInsecureChannelFromFd( init_lib.init(); grpc_channel_args channel_args; args.SetChannelArgs(&channel_args); - return grpc::CreateChannelInternal( + return ::grpc::CreateChannelInternal( "", grpc_insecure_channel_create_from_fd(target.c_str(), fd, &channel_args), std::vector>()); diff --git a/test/cpp/performance/writes_per_rpc_test.cc b/test/cpp/performance/writes_per_rpc_test.cc index 7b22f23cf00..b74f4d0466b 100644 --- a/test/cpp/performance/writes_per_rpc_test.cc +++ b/test/cpp/performance/writes_per_rpc_test.cc @@ -118,7 +118,7 @@ class EndpointPairFixture { "target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, transport); grpc_chttp2_transport_start_reading(transport, nullptr, nullptr); - channel_ = CreateChannelInternal( + channel_ = ::grpc::CreateChannelInternal( "", channel, std::vector>()); diff --git a/test/cpp/util/create_test_channel.h b/test/cpp/util/create_test_channel.h index b50131b385c..42564a31ec8 100644 --- a/test/cpp/util/create_test_channel.h +++ b/test/cpp/util/create_test_channel.h @@ -24,8 +24,12 @@ #include #include -namespace grpc { +namespace grpc_impl { + class Channel; +} + +namespace grpc { namespace testing { @@ -33,31 +37,31 @@ typedef enum { INSECURE = 0, TLS, ALTS } transport_security; } // namespace testing -std::shared_ptr CreateTestChannel( +std::shared_ptr<::grpc_impl::Channel> CreateTestChannel( const grpc::string& server, testing::transport_security security_type); -std::shared_ptr CreateTestChannel( +std::shared_ptr<::grpc_impl::Channel> CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, testing::transport_security security_type, bool use_prod_roots); -std::shared_ptr CreateTestChannel( +std::shared_ptr<::grpc_impl::Channel> CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, testing::transport_security security_type, bool use_prod_roots, const std::shared_ptr& creds); -std::shared_ptr CreateTestChannel( +std::shared_ptr<::grpc_impl::Channel> CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, testing::transport_security security_type, bool use_prod_roots, const std::shared_ptr& creds, const ChannelArguments& args); -std::shared_ptr CreateTestChannel( +std::shared_ptr<::grpc_impl::Channel> CreateTestChannel( const grpc::string& server, const grpc::string& cred_type, const grpc::string& override_hostname, bool use_prod_roots, const std::shared_ptr& creds, const ChannelArguments& args); -std::shared_ptr CreateTestChannel( +std::shared_ptr<::grpc_impl::Channel> CreateTestChannel( const grpc::string& server, const grpc::string& credential_type, const std::shared_ptr& creds); diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index eda8eb5764c..4e524077e37 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -927,6 +927,7 @@ include/grpc/support/workaround_list.h \ include/grpcpp/alarm.h \ include/grpcpp/alarm_impl.h \ include/grpcpp/channel.h \ +include/grpcpp/channel_impl.h \ include/grpcpp/client_context.h \ include/grpcpp/completion_queue.h \ include/grpcpp/create_channel.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index a20e0706895..6e83956b8d8 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -928,6 +928,7 @@ include/grpc/support/workaround_list.h \ include/grpcpp/alarm.h \ include/grpcpp/alarm_impl.h \ include/grpcpp/channel.h \ +include/grpcpp/channel_impl.h \ include/grpcpp/client_context.h \ include/grpcpp/completion_queue.h \ include/grpcpp/create_channel.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index a73abacdd22..e78efd4fa8e 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -10316,6 +10316,7 @@ "include/grpcpp/alarm.h", "include/grpcpp/alarm_impl.h", "include/grpcpp/channel.h", + "include/grpcpp/channel_impl.h", "include/grpcpp/client_context.h", "include/grpcpp/completion_queue.h", "include/grpcpp/create_channel.h", @@ -10441,6 +10442,7 @@ "include/grpcpp/alarm.h", "include/grpcpp/alarm_impl.h", "include/grpcpp/channel.h", + "include/grpcpp/channel_impl.h", "include/grpcpp/client_context.h", "include/grpcpp/completion_queue.h", "include/grpcpp/create_channel.h", From 03b079499cba1390fb394f2d476988aa6347c41e Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Thu, 16 May 2019 22:18:31 -0700 Subject: [PATCH 0241/1555] Move CompletionQueue and Channel --- BUILD | 1 + BUILD.gn | 1 + CMakeLists.txt | 5 + Makefile | 5 + build.yaml | 1 + gRPC-C++.podspec | 1 + include/grpcpp/create_channel_impl.h | 1 - include/grpcpp/generic/generic_stub_impl.h | 2 +- include/grpcpp/impl/codegen/async_stream.h | 2 - .../grpcpp/impl/codegen/async_unary_call.h | 1 - include/grpcpp/impl/codegen/call.h | 14 +- include/grpcpp/impl/codegen/call_op_set.h | 1 - .../grpcpp/impl/codegen/channel_interface.h | 16 +- include/grpcpp/impl/codegen/client_callback.h | 1 - .../grpcpp/impl/codegen/client_unary_call.h | 2 - .../grpcpp/impl/codegen/completion_queue.h | 20 +- .../impl/codegen/completion_queue_impl.h | 422 ++++++++++++++++++ .../grpcpp/impl/codegen/intercepted_channel.h | 13 +- include/grpcpp/impl/codegen/server_context.h | 5 +- .../grpcpp/impl/codegen/server_interface.h | 69 +-- include/grpcpp/impl/codegen/service_type.h | 3 +- include/grpcpp/server_builder.h | 7 - include/grpcpp/server_builder_impl.h | 7 +- src/compiler/cpp_generator.cc | 7 +- src/cpp/common/completion_queue_cc.cc | 12 +- test/cpp/codegen/compiler_test_golden | 8 +- tools/doxygen/Doxyfile.c++ | 1 + tools/doxygen/Doxyfile.c++.internal | 1 + .../generated/sources_and_headers.json | 2 + 29 files changed, 532 insertions(+), 99 deletions(-) create mode 100644 include/grpcpp/impl/codegen/completion_queue_impl.h diff --git a/BUILD b/BUILD index da5439648d4..e4d74f0f42e 100644 --- a/BUILD +++ b/BUILD @@ -2148,6 +2148,7 @@ grpc_cc_library( "include/grpcpp/impl/codegen/client_interceptor.h", "include/grpcpp/impl/codegen/client_unary_call.h", "include/grpcpp/impl/codegen/completion_queue.h", + "include/grpcpp/impl/codegen/completion_queue_impl.h", "include/grpcpp/impl/codegen/completion_queue_tag.h", "include/grpcpp/impl/codegen/config.h", "include/grpcpp/impl/codegen/core_codegen_interface.h", diff --git a/BUILD.gn b/BUILD.gn index 8ea6eeeced0..956ec372121 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1054,6 +1054,7 @@ config("grpc_config") { "include/grpcpp/impl/codegen/client_interceptor.h", "include/grpcpp/impl/codegen/client_unary_call.h", "include/grpcpp/impl/codegen/completion_queue.h", + "include/grpcpp/impl/codegen/completion_queue_impl.h", "include/grpcpp/impl/codegen/completion_queue_tag.h", "include/grpcpp/impl/codegen/config.h", "include/grpcpp/impl/codegen/config_protobuf.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e79f073a5f..1d206536d8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3312,6 +3312,7 @@ foreach(_hdr include/grpcpp/impl/codegen/client_interceptor.h include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/completion_queue.h + include/grpcpp/impl/codegen/completion_queue_impl.h include/grpcpp/impl/codegen/completion_queue_tag.h include/grpcpp/impl/codegen/config.h include/grpcpp/impl/codegen/core_codegen_interface.h @@ -3928,6 +3929,7 @@ foreach(_hdr include/grpcpp/impl/codegen/client_interceptor.h include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/completion_queue.h + include/grpcpp/impl/codegen/completion_queue_impl.h include/grpcpp/impl/codegen/completion_queue_tag.h include/grpcpp/impl/codegen/config.h include/grpcpp/impl/codegen/core_codegen_interface.h @@ -4362,6 +4364,7 @@ foreach(_hdr include/grpcpp/impl/codegen/client_interceptor.h include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/completion_queue.h + include/grpcpp/impl/codegen/completion_queue_impl.h include/grpcpp/impl/codegen/completion_queue_tag.h include/grpcpp/impl/codegen/config.h include/grpcpp/impl/codegen/core_codegen_interface.h @@ -4560,6 +4563,7 @@ foreach(_hdr include/grpcpp/impl/codegen/client_interceptor.h include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/completion_queue.h + include/grpcpp/impl/codegen/completion_queue_impl.h include/grpcpp/impl/codegen/completion_queue_tag.h include/grpcpp/impl/codegen/config.h include/grpcpp/impl/codegen/core_codegen_interface.h @@ -4916,6 +4920,7 @@ foreach(_hdr include/grpcpp/impl/codegen/client_interceptor.h include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/completion_queue.h + include/grpcpp/impl/codegen/completion_queue_impl.h include/grpcpp/impl/codegen/completion_queue_tag.h include/grpcpp/impl/codegen/config.h include/grpcpp/impl/codegen/core_codegen_interface.h diff --git a/Makefile b/Makefile index 4bcc6417816..763ed2be215 100644 --- a/Makefile +++ b/Makefile @@ -5669,6 +5669,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ + include/grpcpp/impl/codegen/completion_queue_impl.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/config.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \ @@ -6293,6 +6294,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ + include/grpcpp/impl/codegen/completion_queue_impl.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/config.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \ @@ -6699,6 +6701,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ + include/grpcpp/impl/codegen/completion_queue_impl.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/config.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \ @@ -6868,6 +6871,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ + include/grpcpp/impl/codegen/completion_queue_impl.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/config.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \ @@ -7230,6 +7234,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ + include/grpcpp/impl/codegen/completion_queue_impl.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/config.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \ diff --git a/build.yaml b/build.yaml index 0364be34caa..50b5d98bcf3 100644 --- a/build.yaml +++ b/build.yaml @@ -1253,6 +1253,7 @@ filegroups: - include/grpcpp/impl/codegen/client_interceptor.h - include/grpcpp/impl/codegen/client_unary_call.h - include/grpcpp/impl/codegen/completion_queue.h + - include/grpcpp/impl/codegen/completion_queue_impl.h - include/grpcpp/impl/codegen/completion_queue_tag.h - include/grpcpp/impl/codegen/config.h - include/grpcpp/impl/codegen/core_codegen_interface.h diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index a62b9c84a63..02de7798b5b 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -163,6 +163,7 @@ Pod::Spec.new do |s| 'include/grpcpp/impl/codegen/client_interceptor.h', 'include/grpcpp/impl/codegen/client_unary_call.h', 'include/grpcpp/impl/codegen/completion_queue.h', + 'include/grpcpp/impl/codegen/completion_queue_impl.h', 'include/grpcpp/impl/codegen/completion_queue_tag.h', 'include/grpcpp/impl/codegen/config.h', 'include/grpcpp/impl/codegen/core_codegen_interface.h', diff --git a/include/grpcpp/create_channel_impl.h b/include/grpcpp/create_channel_impl.h index ebf8b96973e..02896e66444 100644 --- a/include/grpcpp/create_channel_impl.h +++ b/include/grpcpp/create_channel_impl.h @@ -28,7 +28,6 @@ #include namespace grpc_impl { - /// Create a new \a Channel pointing to \a target. /// /// \param target The URI of the endpoint to connect to. diff --git a/include/grpcpp/generic/generic_stub_impl.h b/include/grpcpp/generic/generic_stub_impl.h index 0a7338228c1..90414611cbd 100644 --- a/include/grpcpp/generic/generic_stub_impl.h +++ b/include/grpcpp/generic/generic_stub_impl.h @@ -29,12 +29,12 @@ namespace grpc { -class CompletionQueue; typedef ClientAsyncReaderWriter GenericClientAsyncReaderWriter; typedef ClientAsyncResponseReader GenericClientAsyncResponseReader; } // namespace grpc namespace grpc_impl { +class CompletionQueue; /// Generic stubs provide a type-unsafe interface to call gRPC methods /// by name. diff --git a/include/grpcpp/impl/codegen/async_stream.h b/include/grpcpp/impl/codegen/async_stream.h index 6a23363bd6d..f95772650a2 100644 --- a/include/grpcpp/impl/codegen/async_stream.h +++ b/include/grpcpp/impl/codegen/async_stream.h @@ -28,8 +28,6 @@ namespace grpc { -class CompletionQueue; - namespace internal { /// Common interface for all client side asynchronous streaming. class ClientAsyncStreamingInterface { diff --git a/include/grpcpp/impl/codegen/async_unary_call.h b/include/grpcpp/impl/codegen/async_unary_call.h index 89dcb124189..4b97cf29018 100644 --- a/include/grpcpp/impl/codegen/async_unary_call.h +++ b/include/grpcpp/impl/codegen/async_unary_call.h @@ -29,7 +29,6 @@ namespace grpc { -class CompletionQueue; extern CoreCodegenInterface* g_core_codegen_interface; /// An interface relevant for async client side unary RPCs (which send diff --git a/include/grpcpp/impl/codegen/call.h b/include/grpcpp/impl/codegen/call.h index c040c30dd9d..eefa4a7f9cd 100644 --- a/include/grpcpp/impl/codegen/call.h +++ b/include/grpcpp/impl/codegen/call.h @@ -21,9 +21,11 @@ #include #include -namespace grpc { +namespace grpc_impl { class CompletionQueue; +} +namespace grpc { namespace experimental { class ClientRpcInfo; class ServerRpcInfo; @@ -41,13 +43,13 @@ class Call final { call_(nullptr), max_receive_message_size_(-1) {} /** call is owned by the caller */ - Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq) + Call(grpc_call* call, CallHook* call_hook, ::grpc_impl::CompletionQueue* cq) : call_hook_(call_hook), cq_(cq), call_(call), max_receive_message_size_(-1) {} - Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq, + Call(grpc_call* call, CallHook* call_hook, ::grpc_impl::CompletionQueue* cq, experimental::ClientRpcInfo* rpc_info) : call_hook_(call_hook), cq_(cq), @@ -55,7 +57,7 @@ class Call final { max_receive_message_size_(-1), client_rpc_info_(rpc_info) {} - Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq, + Call(grpc_call* call, CallHook* call_hook, ::grpc_impl::CompletionQueue* cq, int max_receive_message_size, experimental::ServerRpcInfo* rpc_info) : call_hook_(call_hook), cq_(cq), @@ -68,7 +70,7 @@ class Call final { } grpc_call* call() const { return call_; } - CompletionQueue* cq() const { return cq_; } + ::grpc_impl::CompletionQueue* cq() const { return cq_; } int max_receive_message_size() const { return max_receive_message_size_; } @@ -82,7 +84,7 @@ class Call final { private: CallHook* call_hook_; - CompletionQueue* cq_; + ::grpc_impl::CompletionQueue* cq_; grpc_call* call_; int max_receive_message_size_; experimental::ClientRpcInfo* client_rpc_info_ = nullptr; diff --git a/include/grpcpp/impl/codegen/call_op_set.h b/include/grpcpp/impl/codegen/call_op_set.h index 4ca87a99fca..d810625b3e4 100644 --- a/include/grpcpp/impl/codegen/call_op_set.h +++ b/include/grpcpp/impl/codegen/call_op_set.h @@ -48,7 +48,6 @@ namespace grpc { -class CompletionQueue; extern CoreCodegenInterface* g_core_codegen_interface; namespace internal { diff --git a/include/grpcpp/impl/codegen/channel_interface.h b/include/grpcpp/impl/codegen/channel_interface.h index 57555285e18..9df233b5500 100644 --- a/include/grpcpp/impl/codegen/channel_interface.h +++ b/include/grpcpp/impl/codegen/channel_interface.h @@ -24,10 +24,13 @@ #include #include +namespace grpc_impl { +class CompletionQueue; +} + namespace grpc { class ChannelInterface; class ClientContext; -class CompletionQueue; template class ClientReader; @@ -74,7 +77,7 @@ class ChannelInterface { /// deadline expires. \a GetState needs to called to get the current state. template void NotifyOnStateChange(grpc_connectivity_state last_observed, T deadline, - CompletionQueue* cq, void* tag) { + ::grpc_impl::CompletionQueue* cq, void* tag) { TimePoint deadline_tp(deadline); NotifyOnStateChangeImpl(last_observed, deadline_tp.raw_time(), cq, tag); } @@ -127,13 +130,14 @@ class ChannelInterface { friend class ::grpc::internal::InterceptedChannel; virtual internal::Call CreateCall(const internal::RpcMethod& method, ClientContext* context, - CompletionQueue* cq) = 0; + ::grpc_impl::CompletionQueue* cq) = 0; virtual void PerformOpsOnCall(internal::CallOpSetInterface* ops, internal::Call* call) = 0; virtual void* RegisterMethod(const char* method) = 0; virtual void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline, - CompletionQueue* cq, void* tag) = 0; + ::grpc_impl::CompletionQueue* cq, + void* tag) = 0; virtual bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline) = 0; @@ -146,7 +150,7 @@ class ChannelInterface { // change (even though this is private and non-API) virtual internal::Call CreateCallInternal(const internal::RpcMethod& method, ClientContext* context, - CompletionQueue* cq, + ::grpc_impl::CompletionQueue* cq, size_t interceptor_pos) { return internal::Call(); } @@ -159,7 +163,7 @@ class ChannelInterface { // Returns nullptr (rather than being pure) since this is a post-1.0 method // and adding a new pure method to an interface would be a breaking change // (even though this is private and non-API) - virtual CompletionQueue* CallbackCQ() { return nullptr; } + virtual ::grpc_impl::CompletionQueue* CallbackCQ() { return nullptr; } }; } // namespace grpc diff --git a/include/grpcpp/impl/codegen/client_callback.h b/include/grpcpp/impl/codegen/client_callback.h index f0499858a05..dda9aec29f3 100644 --- a/include/grpcpp/impl/codegen/client_callback.h +++ b/include/grpcpp/impl/codegen/client_callback.h @@ -36,7 +36,6 @@ class Channel; namespace grpc { class ClientContext; -class CompletionQueue; namespace internal { class RpcMethod; diff --git a/include/grpcpp/impl/codegen/client_unary_call.h b/include/grpcpp/impl/codegen/client_unary_call.h index b9f8e1663f1..e0f692b1783 100644 --- a/include/grpcpp/impl/codegen/client_unary_call.h +++ b/include/grpcpp/impl/codegen/client_unary_call.h @@ -27,9 +27,7 @@ namespace grpc { -class Channel; class ClientContext; -class CompletionQueue; namespace internal { class RpcMethod; diff --git a/include/grpcpp/impl/codegen/completion_queue.h b/include/grpcpp/impl/codegen/completion_queue.h index 472d95504dc..f67a3780979 100644 --- a/include/grpcpp/impl/codegen/completion_queue.h +++ b/include/grpcpp/impl/codegen/completion_queue.h @@ -16,28 +16,10 @@ * */ -/// A completion queue implements a concurrent producer-consumer queue, with -/// two main API-exposed methods: \a Next and \a AsyncNext. These -/// methods are the essential component of the gRPC C++ asynchronous API. -/// There is also a \a Shutdown method to indicate that a given completion queue -/// will no longer have regular events. This must be called before the -/// completion queue is destroyed. -/// All completion queue APIs are thread-safe and may be used concurrently with -/// any other completion queue API invocation; it is acceptable to have -/// multiple threads calling \a Next or \a AsyncNext on the same or different -/// completion queues, or to call these methods concurrently with a \a Shutdown -/// elsewhere. -/// \remark{All other API calls on completion queue should be completed before -/// a completion queue destructor is called.} #ifndef GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_H #define GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_H -#include -#include -#include -#include -#include -#include +#include namespace grpc { diff --git a/include/grpcpp/impl/codegen/completion_queue_impl.h b/include/grpcpp/impl/codegen/completion_queue_impl.h new file mode 100644 index 00000000000..5435f2fa165 --- /dev/null +++ b/include/grpcpp/impl/codegen/completion_queue_impl.h @@ -0,0 +1,422 @@ +/* + * + * Copyright 2015-2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/// A completion queue implements a concurrent producer-consumer queue, with +/// two main API-exposed methods: \a Next and \a AsyncNext. These +/// methods are the essential component of the gRPC C++ asynchronous API. +/// There is also a \a Shutdown method to indicate that a given completion queue +/// will no longer have regular events. This must be called before the +/// completion queue is destroyed. +/// All completion queue APIs are thread-safe and may be used concurrently with +/// any other completion queue API invocation; it is acceptable to have +/// multiple threads calling \a Next or \a AsyncNext on the same or different +/// completion queues, or to call these methods concurrently with a \a Shutdown +/// elsewhere. +/// \remark{All other API calls on completion queue should be completed before +/// a completion queue destructor is called.} +#ifndef GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_IMPL_H +#define GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_IMPL_H + +#include +#include +#include +#include +#include +#include + +struct grpc_completion_queue; + +namespace grpc_impl { + +class Channel; +class Server; +class ServerBuilder; +} // namespace grpc_impl +namespace grpc { + +template +class ClientReader; +template +class ClientWriter; +template +class ClientReaderWriter; +template +class ServerReader; +template +class ServerWriter; +namespace internal { +template +class ServerReaderWriterBody; +} // namespace internal + +class ChannelInterface; +class ClientContext; +class ServerContext; +class ServerInterface; + +namespace internal { +class CompletionQueueTag; +class RpcMethod; +template +class RpcMethodHandler; +template +class ClientStreamingHandler; +template +class ServerStreamingHandler; +template +class BidiStreamingHandler; +template +class TemplatedBidiStreamingHandler; +template +class ErrorMethodHandler; +template +class BlockingUnaryCallImpl; +template +class CallOpSet; +} // namespace internal + +extern CoreCodegenInterface* g_core_codegen_interface; + +} // namespace grpc + +namespace grpc_impl { + +/// A thin wrapper around \ref grpc_completion_queue (see \ref +/// src/core/lib/surface/completion_queue.h). +/// See \ref doc/cpp/perf_notes.md for notes on best practices for high +/// performance servers. +class CompletionQueue : private ::grpc::GrpcLibraryCodegen { + public: + /// Default constructor. Implicitly creates a \a grpc_completion_queue + /// instance. + CompletionQueue() + : CompletionQueue(grpc_completion_queue_attributes{ + GRPC_CQ_CURRENT_VERSION, GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, + nullptr}) {} + + /// Wrap \a take, taking ownership of the instance. + /// + /// \param take The completion queue instance to wrap. Ownership is taken. + explicit CompletionQueue(grpc_completion_queue* take); + + /// Destructor. Destroys the owned wrapped completion queue / instance. + ~CompletionQueue() { + ::grpc::g_core_codegen_interface->grpc_completion_queue_destroy(cq_); + } + + /// Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT. + enum NextStatus { + SHUTDOWN, ///< The completion queue has been shutdown and fully-drained + GOT_EVENT, ///< Got a new event; \a tag will be filled in with its + ///< associated value; \a ok indicating its success. + TIMEOUT ///< deadline was reached. + }; + + /// Read from the queue, blocking until an event is available or the queue is + /// shutting down. + /// + /// \param tag [out] Updated to point to the read event's tag. + /// \param ok [out] true if read a successful event, false otherwise. + /// + /// Note that each tag sent to the completion queue (through RPC operations + /// or alarms) will be delivered out of the completion queue by a call to + /// Next (or a related method), regardless of whether the operation succeeded + /// or not. Success here means that this operation completed in the normal + /// valid manner. + /// + /// Server-side RPC request: \a ok indicates that the RPC has indeed + /// been started. If it is false, the server has been Shutdown + /// before this particular call got matched to an incoming RPC. + /// + /// Client-side StartCall/RPC invocation: \a ok indicates that the RPC is + /// going to go to the wire. If it is false, it not going to the wire. This + /// would happen if the channel is either permanently broken or + /// transiently broken but with the fail-fast option. (Note that async unary + /// RPCs don't post a CQ tag at this point, nor do client-streaming + /// or bidi-streaming RPCs that have the initial metadata corked option set.) + /// + /// Client-side Write, Client-side WritesDone, Server-side Write, + /// Server-side Finish, Server-side SendInitialMetadata (which is + /// typically included in Write or Finish when not done explicitly): + /// \a ok means that the data/metadata/status/etc is going to go to the + /// wire. If it is false, it not going to the wire because the call + /// is already dead (i.e., canceled, deadline expired, other side + /// dropped the channel, etc). + /// + /// Client-side Read, Server-side Read, Client-side + /// RecvInitialMetadata (which is typically included in Read if not + /// done explicitly): \a ok indicates whether there is a valid message + /// that got read. If not, you know that there are certainly no more + /// messages that can ever be read from this stream. For the client-side + /// operations, this only happens because the call is dead. For the + /// server-sider operation, though, this could happen because the client + /// has done a WritesDone already. + /// + /// Client-side Finish: \a ok should always be true + /// + /// Server-side AsyncNotifyWhenDone: \a ok should always be true + /// + /// Alarm: \a ok is true if it expired, false if it was canceled + /// + /// \return true if got an event, false if the queue is fully drained and + /// shut down. + bool Next(void** tag, bool* ok) { + return (AsyncNextInternal(tag, ok, + ::grpc::g_core_codegen_interface->gpr_inf_future( + GPR_CLOCK_REALTIME)) != SHUTDOWN); + } + + /// Read from the queue, blocking up to \a deadline (or the queue's shutdown). + /// Both \a tag and \a ok are updated upon success (if an event is available + /// within the \a deadline). A \a tag points to an arbitrary location usually + /// employed to uniquely identify an event. + /// + /// \param tag [out] Upon sucess, updated to point to the event's tag. + /// \param ok [out] Upon sucess, true if a successful event, false otherwise + /// See documentation for CompletionQueue::Next for explanation of ok + /// \param deadline [in] How long to block in wait for an event. + /// + /// \return The type of event read. + template + NextStatus AsyncNext(void** tag, bool* ok, const T& deadline) { + ::grpc::TimePoint deadline_tp(deadline); + return AsyncNextInternal(tag, ok, deadline_tp.raw_time()); + } + + /// EXPERIMENTAL + /// First executes \a F, then reads from the queue, blocking up to + /// \a deadline (or the queue's shutdown). + /// Both \a tag and \a ok are updated upon success (if an event is available + /// within the \a deadline). A \a tag points to an arbitrary location usually + /// employed to uniquely identify an event. + /// + /// \param f [in] Function to execute before calling AsyncNext on this queue. + /// \param tag [out] Upon sucess, updated to point to the event's tag. + /// \param ok [out] Upon sucess, true if read a regular event, false + /// otherwise. + /// \param deadline [in] How long to block in wait for an event. + /// + /// \return The type of event read. + template + NextStatus DoThenAsyncNext(F&& f, void** tag, bool* ok, const T& deadline) { + CompletionQueueTLSCache cache = CompletionQueueTLSCache(this); + f(); + if (cache.Flush(tag, ok)) { + return GOT_EVENT; + } else { + return AsyncNext(tag, ok, deadline); + } + } + + /// Request the shutdown of the queue. + /// + /// \warning This method must be called at some point if this completion queue + /// is accessed with Next or AsyncNext. \a Next will not return false + /// until this method has been called and all pending tags have been drained. + /// (Likewise for \a AsyncNext returning \a NextStatus::SHUTDOWN .) + /// Only once either one of these methods does that (that is, once the queue + /// has been \em drained) can an instance of this class be destroyed. + /// Also note that applications must ensure that no work is enqueued on this + /// completion queue after this method is called. + void Shutdown(); + + /// Returns a \em raw pointer to the underlying \a grpc_completion_queue + /// instance. + /// + /// \warning Remember that the returned instance is owned. No transfer of + /// owership is performed. + grpc_completion_queue* cq() { return cq_; } + + protected: + /// Private constructor of CompletionQueue only visible to friend classes + CompletionQueue(const grpc_completion_queue_attributes& attributes) { + cq_ = ::grpc::g_core_codegen_interface->grpc_completion_queue_create( + ::grpc::g_core_codegen_interface->grpc_completion_queue_factory_lookup( + &attributes), + &attributes, NULL); + InitialAvalanching(); // reserve this for the future shutdown + } + + private: + // Friend synchronous wrappers so that they can access Pluck(), which is + // a semi-private API geared towards the synchronous implementation. + template + friend class ::grpc::ClientReader; + template + friend class ::grpc::ClientWriter; + template + friend class ::grpc::ClientReaderWriter; + template + friend class ::grpc::ServerReader; + template + friend class ::grpc::ServerWriter; + template + friend class ::grpc::internal::ServerReaderWriterBody; + template + friend class ::grpc::internal::RpcMethodHandler; + template + friend class ::grpc::internal::ClientStreamingHandler; + template + friend class ::grpc::internal::ServerStreamingHandler; + template + friend class ::grpc::internal::TemplatedBidiStreamingHandler; + template <::grpc::StatusCode code> + friend class ::grpc::internal::ErrorMethodHandler; + friend class ::grpc_impl::Server; + friend class ::grpc::ServerContext; + friend class ::grpc::ServerInterface; + template + friend class ::grpc::internal::BlockingUnaryCallImpl; + + // Friends that need access to constructor for callback CQ + friend class ::grpc_impl::Channel; + + // For access to Register/CompleteAvalanching + template + friend class ::grpc::internal::CallOpSet; + + /// EXPERIMENTAL + /// Creates a Thread Local cache to store the first event + /// On this completion queue queued from this thread. Once + /// initialized, it must be flushed on the same thread. + class CompletionQueueTLSCache { + public: + CompletionQueueTLSCache(CompletionQueue* cq); + ~CompletionQueueTLSCache(); + bool Flush(void** tag, bool* ok); + + private: + CompletionQueue* cq_; + bool flushed_; + }; + + NextStatus AsyncNextInternal(void** tag, bool* ok, gpr_timespec deadline); + + /// Wraps \a grpc_completion_queue_pluck. + /// \warning Must not be mixed with calls to \a Next. + bool Pluck(::grpc::internal::CompletionQueueTag* tag) { + auto deadline = + ::grpc::g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_REALTIME); + while (true) { + auto ev = ::grpc::g_core_codegen_interface->grpc_completion_queue_pluck( + cq_, tag, deadline, nullptr); + bool ok = ev.success != 0; + void* ignored = tag; + if (tag->FinalizeResult(&ignored, &ok)) { + GPR_CODEGEN_ASSERT(ignored == tag); + return ok; + } + } + } + + /// Performs a single polling pluck on \a tag. + /// \warning Must not be mixed with calls to \a Next. + /// + /// TODO: sreek - This calls tag->FinalizeResult() even if the cq_ is already + /// shutdown. This is most likely a bug and if it is a bug, then change this + /// implementation to simple call the other TryPluck function with a zero + /// timeout. i.e: + /// TryPluck(tag, gpr_time_0(GPR_CLOCK_REALTIME)) + void TryPluck(::grpc::internal::CompletionQueueTag* tag) { + auto deadline = + ::grpc::g_core_codegen_interface->gpr_time_0(GPR_CLOCK_REALTIME); + auto ev = ::grpc::g_core_codegen_interface->grpc_completion_queue_pluck( + cq_, tag, deadline, nullptr); + if (ev.type == GRPC_QUEUE_TIMEOUT) return; + bool ok = ev.success != 0; + void* ignored = tag; + // the tag must be swallowed if using TryPluck + GPR_CODEGEN_ASSERT(!tag->FinalizeResult(&ignored, &ok)); + } + + /// Performs a single polling pluck on \a tag. Calls tag->FinalizeResult if + /// the pluck() was successful and returned the tag. + /// + /// This exects tag->FinalizeResult (if called) to return 'false' i.e expects + /// that the tag is internal not something that is returned to the user. + void TryPluck(::grpc::internal::CompletionQueueTag* tag, + gpr_timespec deadline) { + auto ev = ::grpc::g_core_codegen_interface->grpc_completion_queue_pluck( + cq_, tag, deadline, nullptr); + if (ev.type == GRPC_QUEUE_TIMEOUT || ev.type == GRPC_QUEUE_SHUTDOWN) { + return; + } + + bool ok = ev.success != 0; + void* ignored = tag; + GPR_CODEGEN_ASSERT(!tag->FinalizeResult(&ignored, &ok)); + } + + /// Manage state of avalanching operations : completion queue tags that + /// trigger other completion queue operations. The underlying core completion + /// queue should not really shutdown until all avalanching operations have + /// been finalized. Note that we maintain the requirement that an avalanche + /// registration must take place before CQ shutdown (which must be maintained + /// elsehwere) + void InitialAvalanching() { + gpr_atm_rel_store(&avalanches_in_flight_, static_cast(1)); + } + void RegisterAvalanching() { + gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_, + static_cast(1)); + } + void CompleteAvalanching() { + if (gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_, + static_cast(-1)) == 1) { + ::grpc::g_core_codegen_interface->grpc_completion_queue_shutdown(cq_); + } + } + + grpc_completion_queue* cq_; // owned + + gpr_atm avalanches_in_flight_; +}; + +/// A specific type of completion queue used by the processing of notifications +/// by servers. Instantiated by \a ServerBuilder. +class ServerCompletionQueue : public CompletionQueue { + public: + bool IsFrequentlyPolled() { return polling_type_ != GRPC_CQ_NON_LISTENING; } + + protected: + /// Default constructor + ServerCompletionQueue() : polling_type_(GRPC_CQ_DEFAULT_POLLING) {} + + private: + /// \param completion_type indicates whether this is a NEXT or CALLBACK + /// completion queue. + /// \param polling_type Informs the GRPC library about the type of polling + /// allowed on this completion queue. See grpc_cq_polling_type's description + /// in grpc_types.h for more details. + /// \param shutdown_cb is the shutdown callback used for CALLBACK api queues + ServerCompletionQueue(grpc_cq_completion_type completion_type, + grpc_cq_polling_type polling_type, + grpc_experimental_completion_queue_functor* shutdown_cb) + : CompletionQueue(grpc_completion_queue_attributes{ + GRPC_CQ_CURRENT_VERSION, completion_type, polling_type, + shutdown_cb}), + polling_type_(polling_type) {} + + grpc_cq_polling_type polling_type_; + friend class ::grpc_impl::ServerBuilder; + friend class ::grpc_impl::Server; +}; + +} // namespace grpc_impl + +#endif // GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_IMPL_H diff --git a/include/grpcpp/impl/codegen/intercepted_channel.h b/include/grpcpp/impl/codegen/intercepted_channel.h index 5255a6d1472..cd0fcc06753 100644 --- a/include/grpcpp/impl/codegen/intercepted_channel.h +++ b/include/grpcpp/impl/codegen/intercepted_channel.h @@ -21,6 +21,10 @@ #include +namespace grpc_impl { +class CompletionQueue; +} + namespace grpc { namespace internal { @@ -46,7 +50,7 @@ class InterceptedChannel : public ChannelInterface { : channel_(channel), interceptor_pos_(pos) {} Call CreateCall(const RpcMethod& method, ClientContext* context, - CompletionQueue* cq) override { + ::grpc_impl::CompletionQueue* cq) override { return channel_->CreateCallInternal(method, context, cq, interceptor_pos_); } @@ -58,7 +62,8 @@ class InterceptedChannel : public ChannelInterface { } void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, - gpr_timespec deadline, CompletionQueue* cq, + gpr_timespec deadline, + ::grpc_impl::CompletionQueue* cq, void* tag) override { return channel_->NotifyOnStateChangeImpl(last_observed, deadline, cq, tag); } @@ -67,7 +72,9 @@ class InterceptedChannel : public ChannelInterface { return channel_->WaitForStateChangeImpl(last_observed, deadline); } - CompletionQueue* CallbackCQ() override { return channel_->CallbackCQ(); } + ::grpc_impl::CompletionQueue* CallbackCQ() override { + return channel_->CallbackCQ(); + } ChannelInterface* channel_; size_t interceptor_pos_; diff --git a/include/grpcpp/impl/codegen/server_context.h b/include/grpcpp/impl/codegen/server_context.h index f65598db41f..c6903743938 100644 --- a/include/grpcpp/impl/codegen/server_context.h +++ b/include/grpcpp/impl/codegen/server_context.h @@ -43,12 +43,12 @@ struct census_context; namespace grpc_impl { +class CompletionQueue; class Server; } // namespace grpc_impl namespace grpc { class ClientContext; class GenericServerContext; -class CompletionQueue; class ServerInterface; template class ServerAsyncReader; @@ -90,6 +90,7 @@ class Call; class ServerReactor; } // namespace internal +class ServerInterface; namespace testing { class InteropServerContextInspector; class ServerContextTestSpouse; @@ -354,7 +355,7 @@ class ServerContext { gpr_timespec deadline_; grpc_call* call_; - CompletionQueue* cq_; + ::grpc_impl::CompletionQueue* cq_; bool sent_initial_metadata_; mutable std::shared_ptr auth_context_; mutable internal::MetadataMap client_metadata_; diff --git a/include/grpcpp/impl/codegen/server_interface.h b/include/grpcpp/impl/codegen/server_interface.h index 26e997bfb56..d8d49344965 100644 --- a/include/grpcpp/impl/codegen/server_interface.h +++ b/include/grpcpp/impl/codegen/server_interface.h @@ -39,7 +39,6 @@ namespace grpc { class AsyncGenericService; class GenericServerContext; -class ServerCompletionQueue; class ServerContext; class Service; @@ -163,7 +162,8 @@ class ServerInterface : public internal::CallHook { /// caller is required to keep all completion queues live until the server is /// destroyed. /// \param num_cqs How many completion queues does \a cqs hold. - virtual void Start(ServerCompletionQueue** cqs, size_t num_cqs) = 0; + virtual void Start(::grpc_impl::ServerCompletionQueue** cqs, + size_t num_cqs) = 0; virtual void ShutdownInternal(gpr_timespec deadline) = 0; @@ -178,9 +178,9 @@ class ServerInterface : public internal::CallHook { public: BaseAsyncRequest(ServerInterface* server, ServerContext* context, internal::ServerAsyncStreamingInterface* stream, - CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag, - bool delete_on_finalize); + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag, bool delete_on_finalize); virtual ~BaseAsyncRequest(); bool FinalizeResult(void** tag, bool* status) override; @@ -192,8 +192,8 @@ class ServerInterface : public internal::CallHook { ServerInterface* const server_; ServerContext* const context_; internal::ServerAsyncStreamingInterface* const stream_; - CompletionQueue* const call_cq_; - ServerCompletionQueue* const notification_cq_; + ::grpc_impl::CompletionQueue* const call_cq_; + ::grpc_impl::ServerCompletionQueue* const notification_cq_; void* const tag_; const bool delete_on_finalize_; grpc_call* call_; @@ -207,16 +207,17 @@ class ServerInterface : public internal::CallHook { public: RegisteredAsyncRequest(ServerInterface* server, ServerContext* context, internal::ServerAsyncStreamingInterface* stream, - CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag, - const char* name, internal::RpcMethod::RpcType type); + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag, const char* name, + internal::RpcMethod::RpcType type); virtual bool FinalizeResult(void** tag, bool* status) override { /* If we are done intercepting, then there is nothing more for us to do */ if (done_intercepting_) { return BaseAsyncRequest::FinalizeResult(tag, status); } - call_wrapper_ = internal::Call( + call_wrapper_ = ::grpc::internal::Call( call_, server_, call_cq_, server_->max_receive_message_size(), context_->set_server_rpc_info(name_, type_, *server_->interceptor_creators())); @@ -225,7 +226,7 @@ class ServerInterface : public internal::CallHook { protected: void IssueRequest(void* registered_method, grpc_byte_buffer** payload, - ServerCompletionQueue* notification_cq); + ::grpc_impl::ServerCompletionQueue* notification_cq); const char* name_; const internal::RpcMethod::RpcType type_; }; @@ -235,8 +236,9 @@ class ServerInterface : public internal::CallHook { NoPayloadAsyncRequest(internal::RpcServiceMethod* registered_method, ServerInterface* server, ServerContext* context, internal::ServerAsyncStreamingInterface* stream, - CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag) + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag) : RegisteredAsyncRequest( server, context, stream, call_cq, notification_cq, tag, registered_method->name(), registered_method->method_type()) { @@ -252,9 +254,9 @@ class ServerInterface : public internal::CallHook { PayloadAsyncRequest(internal::RpcServiceMethod* registered_method, ServerInterface* server, ServerContext* context, internal::ServerAsyncStreamingInterface* stream, - CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag, - Message* request) + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag, Message* request) : RegisteredAsyncRequest( server, context, stream, call_cq, notification_cq, tag, registered_method->name(), registered_method->method_type()), @@ -309,9 +311,9 @@ class ServerInterface : public internal::CallHook { ServerInterface* const server_; ServerContext* const context_; internal::ServerAsyncStreamingInterface* const stream_; - CompletionQueue* const call_cq_; + ::grpc_impl::CompletionQueue* const call_cq_; - ServerCompletionQueue* const notification_cq_; + ::grpc_impl::ServerCompletionQueue* const notification_cq_; void* const tag_; Message* const request_; ByteBuffer payload_; @@ -321,9 +323,9 @@ class ServerInterface : public internal::CallHook { public: GenericAsyncRequest(ServerInterface* server, GenericServerContext* context, internal::ServerAsyncStreamingInterface* stream, - CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag, - bool delete_on_finalize); + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag, bool delete_on_finalize); bool FinalizeResult(void** tag, bool* status) override; @@ -335,9 +337,9 @@ class ServerInterface : public internal::CallHook { void RequestAsyncCall(internal::RpcServiceMethod* method, ServerContext* context, internal::ServerAsyncStreamingInterface* stream, - CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag, - Message* message) { + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag, Message* message) { GPR_CODEGEN_ASSERT(method); new PayloadAsyncRequest(method, this, context, stream, call_cq, notification_cq, tag, message); @@ -346,18 +348,19 @@ class ServerInterface : public internal::CallHook { void RequestAsyncCall(internal::RpcServiceMethod* method, ServerContext* context, internal::ServerAsyncStreamingInterface* stream, - CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag) { + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag) { GPR_CODEGEN_ASSERT(method); new NoPayloadAsyncRequest(method, this, context, stream, call_cq, notification_cq, tag); } - void RequestAsyncGenericCall(GenericServerContext* context, - internal::ServerAsyncStreamingInterface* stream, - CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, - void* tag) { + void RequestAsyncGenericCall( + GenericServerContext* context, + internal::ServerAsyncStreamingInterface* stream, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, void* tag) { new GenericAsyncRequest(this, context, stream, call_cq, notification_cq, tag, true); } @@ -382,7 +385,7 @@ class ServerInterface : public internal::CallHook { // Returns nullptr (rather than being pure) since this is a post-1.0 method // and adding a new pure method to an interface would be a breaking change // (even though this is private and non-API) - virtual CompletionQueue* CallbackCQ() { return nullptr; } + virtual ::grpc_impl::CompletionQueue* CallbackCQ() { return nullptr; } }; } // namespace grpc diff --git a/include/grpcpp/impl/codegen/service_type.h b/include/grpcpp/impl/codegen/service_type.h index 762b049212f..f1d1272dc20 100644 --- a/include/grpcpp/impl/codegen/service_type.h +++ b/include/grpcpp/impl/codegen/service_type.h @@ -29,12 +29,11 @@ namespace grpc_impl { class Server; +class CompletionQueue; } // namespace grpc_impl namespace grpc { -class CompletionQueue; class ServerInterface; -class ServerCompletionQueue; class ServerContext; namespace internal { diff --git a/include/grpcpp/server_builder.h b/include/grpcpp/server_builder.h index 89c4eba1d95..d9ec7c42f3d 100644 --- a/include/grpcpp/server_builder.h +++ b/include/grpcpp/server_builder.h @@ -21,13 +21,6 @@ #include -namespace grpc_impl { - -class Server; -class ServerCredentials; -class ResourceQuota; -} // namespace grpc_impl - namespace grpc { typedef ::grpc_impl::ServerBuilder ServerBuilder; diff --git a/include/grpcpp/server_builder_impl.h b/include/grpcpp/server_builder_impl.h index 7c197a52f09..0de72cc397c 100644 --- a/include/grpcpp/server_builder_impl.h +++ b/include/grpcpp/server_builder_impl.h @@ -38,7 +38,10 @@ struct grpc_resource_quota; namespace grpc_impl { +class CompletionQueue; class ResourceQuota; +class Server; +class ServerCompletionQueue; class ServerCredentials; } // namespace grpc_impl @@ -153,7 +156,7 @@ class ServerBuilder { /// not polling the completion queue frequently) will have a significantly /// negative performance impact and hence should not be used in production /// use cases. - std::unique_ptr AddCompletionQueue( + std::unique_ptr AddCompletionQueue( bool is_frequently_polled = true); ////////////////////////////////////////////////////////////////////////////// @@ -359,7 +362,7 @@ class ServerBuilder { SyncServerSettings sync_server_settings_; /// List of completion queues added via \a AddCompletionQueue method. - std::vector cqs_; + std::vector cqs_; std::shared_ptr creds_; std::vector> plugins_; diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index ecec3206577..bcc849035c6 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -154,14 +154,15 @@ grpc::string GetHeaderIncludes(grpc_generator::File* file, PrintIncludes(printer.get(), headers, params.use_system_headers, params.grpc_search_path); printer->Print(vars, "\n"); + printer->Print(vars, "namespace grpc_impl {\n"); + printer->Print(vars, "class CompletionQueue;\n"); + printer->Print(vars, "class ServerCompletionQueue;\n"); + printer->Print(vars, "} // namespace grpc_impl\n\n"); printer->Print(vars, "namespace grpc {\n"); printer->Print(vars, "namespace experimental {\n"); printer->Print(vars, "template \n"); printer->Print(vars, "class MessageAllocator;\n"); printer->Print(vars, "} // namespace experimental\n"); - printer->Print(vars, "class CompletionQueue;\n"); - printer->Print(vars, "class Channel;\n"); - printer->Print(vars, "class ServerCompletionQueue;\n"); printer->Print(vars, "class ServerContext;\n"); printer->Print(vars, "} // namespace grpc\n\n"); diff --git a/src/cpp/common/completion_queue_cc.cc b/src/cpp/common/completion_queue_cc.cc index 4bb3bcbd8b6..43c2eee96f8 100644 --- a/src/cpp/common/completion_queue_cc.cc +++ b/src/cpp/common/completion_queue_cc.cc @@ -24,9 +24,9 @@ #include #include -namespace grpc { +namespace grpc_impl { -static internal::GrpcLibraryInitializer g_gli_initializer; +static ::grpc::internal::GrpcLibraryInitializer g_gli_initializer; // 'CompletionQueue' constructor can safely call GrpcLibraryCodegen(false) here // i.e not have GrpcLibraryCodegen call grpc_init(). This is because, to create @@ -52,7 +52,8 @@ CompletionQueue::NextStatus CompletionQueue::AsyncNextInternal( case GRPC_QUEUE_SHUTDOWN: return SHUTDOWN; case GRPC_OP_COMPLETE: - auto core_cq_tag = static_cast(ev.tag); + auto core_cq_tag = + static_cast<::grpc::internal::CompletionQueueTag*>(ev.tag); *ok = ev.success != 0; *tag = core_cq_tag; if (core_cq_tag->FinalizeResult(tag, ok)) { @@ -79,7 +80,8 @@ bool CompletionQueue::CompletionQueueTLSCache::Flush(void** tag, bool* ok) { flushed_ = true; if (grpc_completion_queue_thread_local_cache_flush(cq_->cq_, &res_tag, &res)) { - auto core_cq_tag = static_cast(res_tag); + auto core_cq_tag = + static_cast<::grpc::internal::CompletionQueueTag*>(res_tag); *ok = res == 1; if (core_cq_tag->FinalizeResult(tag, ok)) { return true; @@ -88,4 +90,4 @@ bool CompletionQueue::CompletionQueueTLSCache::Flush(void** tag, bool* ok) { return false; } -} // namespace grpc +} // namespace grpc_impl diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index 9e99bc7b0a2..2ad8e549899 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -40,14 +40,18 @@ #include #include +namespace grpc_impl { +class CompletionQueue; +class ServerCompletionQueue; +c +} // namespace grpc_impl + namespace grpc { namespace experimental { template class MessageAllocator; } // namespace experimental -class CompletionQueue; class Channel; -class ServerCompletionQueue; class ServerContext; } // namespace grpc diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 4e524077e37..667b9b3541e 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -959,6 +959,7 @@ include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ +include/grpcpp/impl/codegen/completion_queue_impl.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/config.h \ include/grpcpp/impl/codegen/config_protobuf.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 6e83956b8d8..f4e6caa418a 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -960,6 +960,7 @@ include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ +include/grpcpp/impl/codegen/completion_queue_impl.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/config.h \ include/grpcpp/impl/codegen/config_protobuf.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index e78efd4fa8e..34004d7d52d 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -10111,6 +10111,7 @@ "include/grpcpp/impl/codegen/client_interceptor.h", "include/grpcpp/impl/codegen/client_unary_call.h", "include/grpcpp/impl/codegen/completion_queue.h", + "include/grpcpp/impl/codegen/completion_queue_impl.h", "include/grpcpp/impl/codegen/completion_queue_tag.h", "include/grpcpp/impl/codegen/config.h", "include/grpcpp/impl/codegen/core_codegen_interface.h", @@ -10188,6 +10189,7 @@ "include/grpcpp/impl/codegen/client_interceptor.h", "include/grpcpp/impl/codegen/client_unary_call.h", "include/grpcpp/impl/codegen/completion_queue.h", + "include/grpcpp/impl/codegen/completion_queue_impl.h", "include/grpcpp/impl/codegen/completion_queue_tag.h", "include/grpcpp/impl/codegen/config.h", "include/grpcpp/impl/codegen/core_codegen_interface.h", From b4ef5388fcc50e3ec415c05035e6587e55e2d7a5 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Fri, 17 May 2019 09:35:40 -0700 Subject: [PATCH 0242/1555] Fix golden file --- test/cpp/codegen/compiler_test_golden | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index 649ddca62fc..761c3ac6106 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -43,7 +43,6 @@ namespace grpc_impl { class CompletionQueue; class ServerCompletionQueue; -c } // namespace grpc_impl namespace grpc { @@ -51,9 +50,6 @@ namespace experimental { template class MessageAllocator; } // namespace experimental -class Channel; -class CompletionQueue; -class ServerCompletionQueue; class ServerContext; } // namespace grpc From fe85756a8afd6e257b378b73cea1681785efb58d Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Fri, 17 May 2019 10:15:41 -0700 Subject: [PATCH 0243/1555] Fix end2end tests --- test/cpp/end2end/client_callback_end2end_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/end2end/client_callback_end2end_test.cc b/test/cpp/end2end/client_callback_end2end_test.cc index ed7482b4be5..8cf6def1073 100644 --- a/test/cpp/end2end/client_callback_end2end_test.cc +++ b/test/cpp/end2end/client_callback_end2end_test.cc @@ -379,7 +379,7 @@ TEST_P(ClientCallbackEnd2endTest, SimpleRpcUnderLock) { ResetStub(); std::mutex mu; std::condition_variable cv; - bool done; + bool done = false; EchoRequest request; request.set_message("Hello locked world."); EchoResponse response; From 570bf332bc19f1a6e53df3604df85193db558bf4 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Fri, 17 May 2019 10:27:18 -0700 Subject: [PATCH 0244/1555] Memset in channel_filter ctor not needed and causes compiler warnings. Thanks to @KeithMoyer in #19044 and @soheilhy --- src/cpp/common/channel_filter.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cpp/common/channel_filter.cc b/src/cpp/common/channel_filter.cc index 422e7bb65ee..8df6c7b98f5 100644 --- a/src/cpp/common/channel_filter.cc +++ b/src/cpp/common/channel_filter.cc @@ -30,7 +30,6 @@ namespace grpc { grpc_linked_mdelem* MetadataBatch::AddMetadata(const string& key, const string& value) { grpc_linked_mdelem* storage = new grpc_linked_mdelem; - memset(storage, 0, sizeof(grpc_linked_mdelem)); storage->md = grpc_mdelem_from_slices(SliceFromCopiedString(key), SliceFromCopiedString(value)); GRPC_LOG_IF_ERROR("MetadataBatch::AddMetadata", From 92aa0530fa5c1c4a0419413223cc6016529a661a Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Fri, 17 May 2019 12:17:16 -0700 Subject: [PATCH 0245/1555] Changes to locking order --- test/core/surface/completion_queue_test.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/core/surface/completion_queue_test.cc b/test/core/surface/completion_queue_test.cc index 35a67387335..32f4debef13 100644 --- a/test/core/surface/completion_queue_test.cc +++ b/test/core/surface/completion_queue_test.cc @@ -388,9 +388,9 @@ static void test_callback(void) { static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { gpr_mu_lock(&shutdown_mu); *static_cast(cb)->done_ = static_cast(ok); - gpr_mu_unlock(&shutdown_mu); // Signal when the shutdown callback is completed. gpr_cv_signal(&shutdown_cv); + gpr_mu_unlock(&shutdown_mu); } private: @@ -469,17 +469,18 @@ static void test_callback(void) { gpr_mu_unlock(&shutdown_mu); } - gpr_mu_lock(&mu); // Run the assertions to check if the test ran successfully. GPR_ASSERT(sumtags == counter); GPR_ASSERT(got_shutdown); - gpr_mu_unlock(&mu); + gpr_mu_lock(&shutdown_mu); got_shutdown = false; + gpr_mu_unlock(&shutdown_mu); } - gpr_mu_destroy(&mu); - gpr_mu_destroy(&shutdown_mu); + gpr_cv_destroy(&cv); gpr_cv_destroy(&shutdown_cv); + gpr_mu_destroy(&mu); + gpr_mu_destroy(&shutdown_mu); } struct thread_state { From a89b1763afa69d8a943a129971e36e2b0129751f Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Fri, 17 May 2019 15:35:12 -0700 Subject: [PATCH 0246/1555] changes --- src/core/lib/surface/completion_queue.cc | 37 ++++++++++-------------- src/core/lib/surface/completion_queue.h | 3 +- src/core/lib/surface/server.cc | 2 +- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index f1b31e9cbba..b62f3fa6add 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -201,7 +201,7 @@ struct cq_vtable { bool (*begin_op)(grpc_completion_queue* cq, void* tag); void (*end_op)(grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage, bool internal); + void* done_arg, grpc_cq_completion* storage); grpc_event (*next)(grpc_completion_queue* cq, gpr_timespec deadline, void* reserved); grpc_event (*pluck)(grpc_completion_queue* cq, void* tag, @@ -358,17 +358,17 @@ static bool cq_begin_op_for_callback(grpc_completion_queue* cq, void* tag); static void cq_end_op_for_next( grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage, bool internal = false); + grpc_cq_completion* storage); static void cq_end_op_for_pluck( grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage, bool internal = false); + grpc_cq_completion* storage); static void cq_end_op_for_callback( grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage, bool internal = false); + grpc_cq_completion* storage); static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline, void* reserved); @@ -675,7 +675,7 @@ bool grpc_cq_begin_op(grpc_completion_queue* cq, void* tag) { static void cq_end_op_for_next( grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage, bool internal) { + grpc_cq_completion* storage) { GPR_TIMER_SCOPE("cq_end_op_for_next", 0); if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) || @@ -754,7 +754,7 @@ static void cq_end_op_for_next( static void cq_end_op_for_pluck( grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage, bool internal) { + grpc_cq_completion* storage) { GPR_TIMER_SCOPE("cq_end_op_for_pluck", 0); cq_pluck_data* cqd = static_cast DATA_FROM_CQ(cq); @@ -826,7 +826,7 @@ static void functor_callback(void* arg, grpc_error* error) { static void cq_end_op_for_callback( grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage, bool internal) { + grpc_cq_completion* storage) { GPR_TIMER_SCOPE("cq_end_op_for_callback", 0); cq_callback_data* cqd = static_cast DATA_FROM_CQ(cq); @@ -857,25 +857,18 @@ static void cq_end_op_for_callback( } auto* functor = static_cast(tag); - if (internal) { - grpc_core::ApplicationCallbackExecCtx::Enqueue(functor, - (error == GRPC_ERROR_NONE)); - } else { - GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_CREATE( - functor_callback, functor, - grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), - GRPC_ERROR_REF(error)); - } - + GRPC_CLOSURE_RUN( + GRPC_CLOSURE_CREATE( + functor_callback, functor, + grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), + GRPC_ERROR_REF(error)); GRPC_ERROR_UNREF(error); } void grpc_cq_end_op(grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage, - bool internal) { - cq->vtable->end_op(cq, tag, error, done, done_arg, storage, internal); + void* done_arg, grpc_cq_completion* storage) { + cq->vtable->end_op(cq, tag, error, done, done_arg, storage); } typedef struct { @@ -1353,7 +1346,7 @@ static void cq_finish_shutdown_callback(grpc_completion_queue* cq) { GPR_ASSERT(cqd->shutdown_called); cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done); - GRPC_CLOSURE_SCHED( + GRPC_CLOSURE_RUN( GRPC_CLOSURE_CREATE( functor_callback, callback, grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), diff --git a/src/core/lib/surface/completion_queue.h b/src/core/lib/surface/completion_queue.h index 3ba9fbb8765..d60fe6d6efe 100644 --- a/src/core/lib/surface/completion_queue.h +++ b/src/core/lib/surface/completion_queue.h @@ -77,8 +77,7 @@ bool grpc_cq_begin_op(grpc_completion_queue* cc, void* tag); grpc_cq_begin_op */ void grpc_cq_end_op(grpc_completion_queue* cc, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage, - bool internal = false); + void* done_arg, grpc_cq_completion* storage); grpc_pollset* grpc_cq_pollset(grpc_completion_queue* cc); diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 19f61c548d6..2377c4d8f23 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -513,7 +513,7 @@ static void publish_call(grpc_server* server, call_data* calld, size_t cq_idx, } grpc_cq_end_op(calld->cq_new, rc->tag, GRPC_ERROR_NONE, done_request_event, - rc, &rc->completion, true); + rc, &rc->completion); } static void publish_new_rpc(void* arg, grpc_error* error) { From 6215ccb587810e87d76513cd03bcbe81e87c28d4 Mon Sep 17 00:00:00 2001 From: yang-g Date: Fri, 17 May 2019 16:22:43 -0700 Subject: [PATCH 0247/1555] resolve comments --- include/grpcpp/impl/codegen/message_allocator.h | 7 ++++++- test/cpp/end2end/message_allocator_end2end_test.cc | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/grpcpp/impl/codegen/message_allocator.h b/include/grpcpp/impl/codegen/message_allocator.h index 422f8c2ea21..83544c64068 100644 --- a/include/grpcpp/impl/codegen/message_allocator.h +++ b/include/grpcpp/impl/codegen/message_allocator.h @@ -39,9 +39,14 @@ class RpcAllocatorState { template class MessageHolder : public RpcAllocatorState { public: - virtual void Release() { delete this; } + // Release this object. For example, if the custom allocator's + // AllocateMessasge creates an instance of a subclass with new, the Release() + // should do a "delete this;". + virtual void Release() = 0; RequestT* request() { return request_; } ResponseT* response() { return response_; } + + protected: void set_request(RequestT* request) { request_ = request; } void set_response(ResponseT* response) { response_ = response; } diff --git a/test/cpp/end2end/message_allocator_end2end_test.cc b/test/cpp/end2end/message_allocator_end2end_test.cc index 2abe26fe825..1c52259088a 100644 --- a/test/cpp/end2end/message_allocator_end2end_test.cc +++ b/test/cpp/end2end/message_allocator_end2end_test.cc @@ -346,6 +346,7 @@ class ArenaAllocatorTest : public MessageAllocatorEnd2endTestBase { set_response( google::protobuf::Arena::CreateMessage(&arena_)); } + void Release() override { delete this; } void FreeRequest() override { GPR_ASSERT(0); } private: From 98461b0fa86caa0eb342c651e331662b3a373392 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Mon, 13 May 2019 10:56:57 -0700 Subject: [PATCH 0248/1555] xds enter fallback mode as long as no child policy is ready --- .../filters/client_channel/lb_policy/xds/xds.cc | 13 ++++++------- test/cpp/end2end/xds_end2end_test.cc | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index 3eb94371c71..819bad6c00d 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -493,9 +493,8 @@ class XdsLb : public LoadBalancingPolicy { // 1. The fallback timer fires, we enter fallback mode. // 2. Before the fallback timer fires, the LB channel becomes // TRANSIENT_FAILURE or the LB call fails, we enter fallback mode. - // 3. Before the fallback timer fires, we receive a response from the - // balancer, we cancel the fallback timer and use the response to update the - // locality map. + // 3. Before the fallback timer fires, if any child policy in the locality map + // becomes READY, we cancel the fallback timer. bool fallback_at_startup_checks_pending_ = false; // Timeout in milliseconds for before using fallback backend addresses. // 0 means not using fallback. @@ -1197,9 +1196,6 @@ void XdsLb::BalancerChannelState::BalancerCallState:: xds_grpclb_destroy_serverlist( xdslb_policy->locality_serverlist_[0]->serverlist); } else { - // This is the first serverlist we've received, don't enter fallback - // mode. - xdslb_policy->MaybeCancelFallbackAtStartupChecks(); // Initialize locality serverlist, currently the list only handles // one child. xdslb_policy->locality_serverlist_.emplace_back( @@ -2046,7 +2042,10 @@ void XdsLb::LocalityMap::LocalityEntry::Helper::UpdateState( return; } // At this point, child_ must be the current child policy. - if (state == GRPC_CHANNEL_READY) entry_->parent_->MaybeExitFallbackMode(); + if (state == GRPC_CHANNEL_READY) { + entry_->parent_->MaybeCancelFallbackAtStartupChecks(); + entry_->parent_->MaybeExitFallbackMode(); + } // If we are in fallback mode, ignore update request from the child policy. if (entry_->parent_->fallback_policy_ != nullptr) return; GPR_ASSERT(entry_->parent_->lb_chand_ != nullptr); diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index b876e062426..87a231c588d 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -1015,6 +1015,22 @@ TEST_F(SingleBalancerTest, FallbackEarlyWhenBalancerCallFails) { /* wait_for_ready */ false); } +TEST_F(SingleBalancerTest, FallbackIfResponseReceivedButChildNotReady) { + const int kFallbackTimeoutMs = 500 * grpc_test_slowdown_factor(); + ResetStub(kFallbackTimeoutMs); + SetNextResolution({backends_[0]->port_}, kDefaultServiceConfig_.c_str()); + SetNextResolutionForLbChannelAllBalancers(); + // Send a serverlist that only contains an unreachable backend before fallback + // timeout. + ScheduleResponseForBalancer(0, + BalancerServiceImpl::BuildResponseForBackends( + {grpc_pick_unused_port_or_die()}, {}), + 0); + // Because no child policy is ready before fallback timeout, we enter fallback + // mode. + WaitForBackend(0); +} + TEST_F(SingleBalancerTest, FallbackModeIsExitedWhenBalancerSaysToDropAllCalls) { // Return an unreachable balancer and one fallback backend. SetNextResolution({backends_[0]->port_}, kDefaultServiceConfig_.c_str()); From 44bc1cdaeb282f1ed80f2e905598a880b5fd340c Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Mon, 20 May 2019 21:26:03 +1200 Subject: [PATCH 0249/1555] PR feedback --- .../AsyncStreamReaderExtensions.cs | 50 +++++++++++++++++ .../Internal/AsyncCallServerTest.cs | 1 - .../Grpc.Core/Utils/AsyncStreamExtensions.cs | 53 ------------------- .../ReflectionClientServerTest.cs | 1 - 4 files changed, 50 insertions(+), 55 deletions(-) create mode 100644 src/csharp/Grpc.Core.Api/AsyncStreamReaderExtensions.cs diff --git a/src/csharp/Grpc.Core.Api/AsyncStreamReaderExtensions.cs b/src/csharp/Grpc.Core.Api/AsyncStreamReaderExtensions.cs new file mode 100644 index 00000000000..a1f895723ed --- /dev/null +++ b/src/csharp/Grpc.Core.Api/AsyncStreamReaderExtensions.cs @@ -0,0 +1,50 @@ +#region Copyright notice and license + +// Copyright 2015 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace Grpc.Core +{ + /// + /// Extension methods for . + /// + public static class AsyncStreamReaderExtensions + { + /// + /// Advances the stream reader to the next element in the sequence, returning the result asynchronously. + /// + /// The message type. + /// The stream reader. + /// + /// Task containing the result of the operation: true if the reader was successfully advanced + /// to the next element; false if the reader has passed the end of the sequence. + /// + public static Task MoveNext(this IAsyncStreamReader streamReader) + where T : class + { + if (streamReader == null) + { + throw new ArgumentNullException(nameof(streamReader)); + } + + return streamReader.MoveNext(CancellationToken.None); + } + } +} diff --git a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallServerTest.cs b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallServerTest.cs index d343271ffbe..fd221613c04 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallServerTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallServerTest.cs @@ -23,7 +23,6 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; using Grpc.Core.Internal; -using Grpc.Core.Utils; using NUnit.Framework; namespace Grpc.Core.Internal.Tests diff --git a/src/csharp/Grpc.Core/Utils/AsyncStreamExtensions.cs b/src/csharp/Grpc.Core/Utils/AsyncStreamExtensions.cs index 6ca72a1139b..fce53c70074 100644 --- a/src/csharp/Grpc.Core/Utils/AsyncStreamExtensions.cs +++ b/src/csharp/Grpc.Core/Utils/AsyncStreamExtensions.cs @@ -18,7 +18,6 @@ using System; using System.Collections.Generic; -using System.Threading; using System.Threading.Tasks; namespace Grpc.Core.Utils @@ -28,41 +27,12 @@ namespace Grpc.Core.Utils /// public static class AsyncStreamExtensions { - /// - /// Advances the stream reader to the next element in the sequence, returning the result asynchronously. - /// - /// The message type. - /// The stream reader. - /// - /// Task containing the result of the operation: true if the reader was successfully advanced - /// to the next element; false if the reader has passed the end of the sequence. - /// - public static Task MoveNext(this IAsyncStreamReader streamReader) - where T : class - { - if (streamReader == null) - { - throw new ArgumentNullException(nameof(streamReader)); - } - - return streamReader.MoveNext(CancellationToken.None); - } - /// /// Reads the entire stream and executes an async action for each element. /// public static async Task ForEachAsync(this IAsyncStreamReader streamReader, Func asyncAction) where T : class { - if (streamReader == null) - { - throw new ArgumentNullException(nameof(streamReader)); - } - if (asyncAction == null) - { - throw new ArgumentNullException(nameof(asyncAction)); - } - while (await streamReader.MoveNext().ConfigureAwait(false)) { await asyncAction(streamReader.Current).ConfigureAwait(false); @@ -75,11 +45,6 @@ namespace Grpc.Core.Utils public static async Task> ToListAsync(this IAsyncStreamReader streamReader) where T : class { - if (streamReader == null) - { - throw new ArgumentNullException(nameof(streamReader)); - } - var result = new List(); while (await streamReader.MoveNext().ConfigureAwait(false)) { @@ -95,15 +60,6 @@ namespace Grpc.Core.Utils public static async Task WriteAllAsync(this IClientStreamWriter streamWriter, IEnumerable elements, bool complete = true) where T : class { - if (streamWriter == null) - { - throw new ArgumentNullException(nameof(streamWriter)); - } - if (elements == null) - { - throw new ArgumentNullException(nameof(elements)); - } - foreach (var element in elements) { await streamWriter.WriteAsync(element).ConfigureAwait(false); @@ -120,15 +76,6 @@ namespace Grpc.Core.Utils public static async Task WriteAllAsync(this IServerStreamWriter streamWriter, IEnumerable elements) where T : class { - if (streamWriter == null) - { - throw new ArgumentNullException(nameof(streamWriter)); - } - if (elements == null) - { - throw new ArgumentNullException(nameof(elements)); - } - foreach (var element in elements) { await streamWriter.WriteAsync(element).ConfigureAwait(false); diff --git a/src/csharp/Grpc.Reflection.Tests/ReflectionClientServerTest.cs b/src/csharp/Grpc.Reflection.Tests/ReflectionClientServerTest.cs index 9ef9680f71c..b77f245667c 100644 --- a/src/csharp/Grpc.Reflection.Tests/ReflectionClientServerTest.cs +++ b/src/csharp/Grpc.Reflection.Tests/ReflectionClientServerTest.cs @@ -21,7 +21,6 @@ using System.Text; using System.Threading.Tasks; using Grpc.Core; -using Grpc.Core.Utils; using Grpc.Reflection; using Grpc.Reflection.V1Alpha; using NUnit.Framework; From 440e9b79bfdaed986f89003fd8827910bcd87a77 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Mon, 20 May 2019 07:50:03 -0700 Subject: [PATCH 0250/1555] Fix bug in test health check service implementation. --- test/cpp/end2end/test_health_check_service_impl.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/test/cpp/end2end/test_health_check_service_impl.cc b/test/cpp/end2end/test_health_check_service_impl.cc index 0801e301996..5898527a6cd 100644 --- a/test/cpp/end2end/test_health_check_service_impl.cc +++ b/test/cpp/end2end/test_health_check_service_impl.cc @@ -54,6 +54,7 @@ Status HealthCheckServiceImpl::Watch( } if (response.status() != last_state) { writer->Write(response, ::grpc::WriteOptions()); + last_state = response.status(); } } gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), From 557a3e578db4cf307169547e21d7465dcadbbb76 Mon Sep 17 00:00:00 2001 From: yang-g Date: Fri, 17 May 2019 10:43:10 -0700 Subject: [PATCH 0251/1555] Remove 5s deadline on test server shutdown --- test/core/util/test_tcp_server.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/test/core/util/test_tcp_server.cc b/test/core/util/test_tcp_server.cc index 80d0634a9b9..a36cd80c83a 100644 --- a/test/core/util/test_tcp_server.cc +++ b/test/core/util/test_tcp_server.cc @@ -95,16 +95,13 @@ static void finish_pollset(void* arg, grpc_error* error) { void test_tcp_server_destroy(test_tcp_server* server) { grpc_core::ExecCtx exec_ctx; - gpr_timespec shutdown_deadline; grpc_closure do_nothing_cb; grpc_tcp_server_unref(server->tcp_server); GRPC_CLOSURE_INIT(&do_nothing_cb, do_nothing, nullptr, grpc_schedule_on_exec_ctx); - shutdown_deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_seconds(5, GPR_TIMESPAN)); - while (!server->shutdown && - gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), shutdown_deadline) < 0) { - test_tcp_server_poll(server, 1000); + grpc_core::ExecCtx::Get()->Flush(); + while (!server->shutdown) { + test_tcp_server_poll(server, 100); } grpc_pollset_shutdown(server->pollset, GRPC_CLOSURE_CREATE(finish_pollset, server->pollset, From d22997e1ea5b5799cd1110f222025e207d1c554e Mon Sep 17 00:00:00 2001 From: yang-g Date: Mon, 20 May 2019 10:22:30 -0700 Subject: [PATCH 0252/1555] Add back deadline --- test/core/util/test_tcp_server.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/core/util/test_tcp_server.cc b/test/core/util/test_tcp_server.cc index a36cd80c83a..170584df2b9 100644 --- a/test/core/util/test_tcp_server.cc +++ b/test/core/util/test_tcp_server.cc @@ -95,13 +95,17 @@ static void finish_pollset(void* arg, grpc_error* error) { void test_tcp_server_destroy(test_tcp_server* server) { grpc_core::ExecCtx exec_ctx; + gpr_timespec shutdown_deadline; grpc_closure do_nothing_cb; grpc_tcp_server_unref(server->tcp_server); GRPC_CLOSURE_INIT(&do_nothing_cb, do_nothing, nullptr, grpc_schedule_on_exec_ctx); + shutdown_deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_seconds(5, GPR_TIMESPAN)); grpc_core::ExecCtx::Get()->Flush(); - while (!server->shutdown) { - test_tcp_server_poll(server, 100); + while (!server->shutdown && + gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), shutdown_deadline) < 0) { + test_tcp_server_poll(server, 1000); } grpc_pollset_shutdown(server->pollset, GRPC_CLOSURE_CREATE(finish_pollset, server->pollset, From 56ff5a918f114372e7dfd9f130d4411b474bc466 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Mon, 20 May 2019 11:35:45 -0700 Subject: [PATCH 0253/1555] Address review comments - 1 --- test/core/surface/completion_queue_test.cc | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/core/surface/completion_queue_test.cc b/test/core/surface/completion_queue_test.cc index 32f4debef13..ff6722ffb17 100644 --- a/test/core/surface/completion_queue_test.cc +++ b/test/core/surface/completion_queue_test.cc @@ -376,9 +376,7 @@ static void test_callback(void) { LOG_TEST("test_callback"); - gpr_mu_lock(&shutdown_mu); bool got_shutdown = false; - gpr_mu_unlock(&shutdown_mu); class ShutdownCallback : public grpc_experimental_completion_queue_functor { public: ShutdownCallback(bool* done) : done_(done) { @@ -405,9 +403,7 @@ static void test_callback(void) { for (size_t pidx = 0; pidx < GPR_ARRAY_SIZE(polling_types); pidx++) { int sumtags = 0; int counter = 0; - gpr_mu_lock(&mu); cb_counter = 0; - gpr_mu_unlock(&mu); { // reset exec_ctx types grpc_core::ExecCtx exec_ctx; @@ -472,9 +468,7 @@ static void test_callback(void) { // Run the assertions to check if the test ran successfully. GPR_ASSERT(sumtags == counter); GPR_ASSERT(got_shutdown); - gpr_mu_lock(&shutdown_mu); got_shutdown = false; - gpr_mu_unlock(&shutdown_mu); } gpr_cv_destroy(&cv); From f63dde8e8e7c0f7b0ec855f87085eba1f8ed23b5 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 20 May 2019 11:45:07 -0700 Subject: [PATCH 0254/1555] Make validation function a global function --- .../grpcpp/support/channel_arguments_impl.h | 35 ++++++------------- src/cpp/common/channel_arguments.cc | 27 +++++++------- .../end2end/service_config_end2end_test.cc | 5 +-- 3 files changed, 26 insertions(+), 41 deletions(-) diff --git a/include/grpcpp/support/channel_arguments_impl.h b/include/grpcpp/support/channel_arguments_impl.h index 9a034078033..a137a5b7c7d 100644 --- a/include/grpcpp/support/channel_arguments_impl.h +++ b/include/grpcpp/support/channel_arguments_impl.h @@ -31,6 +31,15 @@ namespace grpc { namespace testing { class ChannelArgumentsTest; } // namespace testing + +namespace experimental { +/// Validates \a service_config_json. If valid, returns an empty string. +/// Otherwise, returns the validation error. +/// TODO(yashykt): Promote it to out of experimental once it is proved useful +/// and gRFC is accepted. +grpc::string ValidateServiceConfigJSON(const grpc::string& service_config_json); +} // namespace experimental + } // namespace grpc namespace grpc_impl { @@ -40,27 +49,8 @@ class SecureChannelCredentials; /// Options for channel creation. The user can use generic setters to pass /// key value pairs down to C channel creation code. For gRPC related options, /// concrete setters are provided. -/// This class derives from GrpcLibraryCodegen so that gRPC is initialized -/// before ValidateAndSetServiceConfigJSON is used. (Service config validation -/// methods are registered at initialization.) -class ChannelArguments : private ::grpc::GrpcLibraryCodegen { +class ChannelArguments { public: - /// NOTE: class experimental_type is not part of the public API of this class. - /// TODO(yashykt): Integrate into public API when this is no longer - /// experimental. - class experimental_type { - public: - explicit experimental_type(ChannelArguments* args) : args_(args) {} - - /// Validates \a service_config_json. If valid, sets the service config and - /// returns an empty string. If invalid, returns the validation error. - grpc::string ValidateAndSetServiceConfigJSON( - const grpc::string& service_config_json); - - private: - ChannelArguments* args_; - }; - ChannelArguments(); ~ChannelArguments(); @@ -144,11 +134,6 @@ class ChannelArguments : private ::grpc::GrpcLibraryCodegen { return out; } - /// NOTE: The function experimental() is not stable public API. It is a view - /// to the experimental components of this class. It may be changed or removed - /// at any time. - experimental_type experimental() { return experimental_type(this); } - private: friend class grpc_impl::SecureChannelCredentials; friend class grpc::testing::ChannelArgumentsTest; diff --git a/src/cpp/common/channel_arguments.cc b/src/cpp/common/channel_arguments.cc index 48dfe815042..2f32703814e 100644 --- a/src/cpp/common/channel_arguments.cc +++ b/src/cpp/common/channel_arguments.cc @@ -31,18 +31,13 @@ namespace grpc_impl { -namespace { -::grpc::internal::GrpcLibraryInitializer g_gli_initializer; -} // namespace - ChannelArguments::ChannelArguments() { - g_gli_initializer.summon(); // This will be ignored if used on the server side. SetString(GRPC_ARG_PRIMARY_USER_AGENT_STRING, "grpc-c++/" + grpc::Version()); } ChannelArguments::ChannelArguments(const ChannelArguments& other) - : ::grpc::GrpcLibraryCodegen(), strings_(other.strings_) { + : strings_(other.strings_) { args_.reserve(other.args_.size()); auto list_it_dst = strings_.begin(); auto list_it_src = other.strings_.begin(); @@ -222,18 +217,22 @@ void ChannelArguments::SetChannelArgs(grpc_channel_args* channel_args) const { } } -grpc::string -ChannelArguments::experimental_type::ValidateAndSetServiceConfigJSON( +} // namespace grpc_impl + +namespace grpc { +namespace experimental { +grpc::string ValidateServiceConfigJSON( const grpc::string& service_config_json) { + grpc_init(); grpc_error* error = GRPC_ERROR_NONE; grpc_core::ServiceConfig::Create(service_config_json.c_str(), &error); + grpc::string return_value; if (error != GRPC_ERROR_NONE) { - grpc::string return_value = grpc_error_string(error); + return_value = grpc_error_string(error); GRPC_ERROR_UNREF(error); - return return_value; } - args_->SetServiceConfigJSON(service_config_json); - return ""; + grpc_shutdown(); + return return_value; } - -} // namespace grpc_impl +} // namespace experimental +} // namespace grpc diff --git a/test/cpp/end2end/service_config_end2end_test.cc b/test/cpp/end2end/service_config_end2end_test.cc index 74a304f6b26..e5c3a8e3eff 100644 --- a/test/cpp/end2end/service_config_end2end_test.cc +++ b/test/cpp/end2end/service_config_end2end_test.cc @@ -231,9 +231,10 @@ class ServiceConfigEnd2endTest : public ::testing::Test { std::shared_ptr BuildChannelWithDefaultServiceConfig() { ChannelArguments args; - EXPECT_THAT(args.experimental().ValidateAndSetServiceConfigJSON( + EXPECT_THAT(grpc::experimental::ValidateServiceConfigJSON( ValidDefaultServiceConfig()), ::testing::StrEq("")); + args.SetServiceConfigJSON(ValidDefaultServiceConfig()); args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, response_generator_.get()); return ::grpc::CreateCustomChannel("fake:///", creds_, args); @@ -242,7 +243,7 @@ class ServiceConfigEnd2endTest : public ::testing::Test { std::shared_ptr BuildChannelWithInvalidDefaultServiceConfig() { ChannelArguments args; EXPECT_THAT( - args.experimental().ValidateAndSetServiceConfigJSON( + grpc::experimental::ValidateServiceConfigJSON( InvalidDefaultServiceConfig()), ::testing::HasSubstr("failed to parse JSON for service config")); args.SetServiceConfigJSON(InvalidDefaultServiceConfig()); From 41ae267107706b4166ba057f027a0bc66d6e93ec Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 20 May 2019 11:46:18 -0700 Subject: [PATCH 0255/1555] Remove unnecessary header --- src/cpp/common/channel_arguments.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cpp/common/channel_arguments.cc b/src/cpp/common/channel_arguments.cc index 2f32703814e..b97e1ed8da9 100644 --- a/src/cpp/common/channel_arguments.cc +++ b/src/cpp/common/channel_arguments.cc @@ -22,7 +22,6 @@ #include #include #include -#include #include #include "src/core/ext/filters/client_channel/service_config.h" #include "src/core/lib/channel/channel_args.h" From f6601e1fc1c05f9eb47929fade49aecf1b80e569 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 20 May 2019 12:45:16 -0700 Subject: [PATCH 0256/1555] Add python deprecation notices. --- src/python/grpcio/README.rst | 8 ++++++++ src/python/grpcio_channelz/README.rst | 8 ++++++++ src/python/grpcio_health_checking/README.rst | 8 ++++++++ src/python/grpcio_reflection/README.rst | 8 ++++++++ src/python/grpcio_status/README.rst | 8 ++++++++ src/python/grpcio_testing/README.rst | 8 ++++++++ tools/distrib/python/grpcio_tools/README.rst | 8 ++++++++ 7 files changed, 56 insertions(+) diff --git a/src/python/grpcio/README.rst b/src/python/grpcio/README.rst index f047243f82d..44d516ef6cb 100644 --- a/src/python/grpcio/README.rst +++ b/src/python/grpcio/README.rst @@ -3,6 +3,14 @@ gRPC Python Package for gRPC Python. +Supported Python Versions +------------------------- +Python >= 3.5 + +Deprecated Python Versions +-------------------------- +Python == 2.7. Python 2.7 support will be removed on January 1, 2020. + Installation ------------ diff --git a/src/python/grpcio_channelz/README.rst b/src/python/grpcio_channelz/README.rst index efeaa560646..d66d0c4f922 100644 --- a/src/python/grpcio_channelz/README.rst +++ b/src/python/grpcio_channelz/README.rst @@ -3,6 +3,14 @@ gRPC Python Channelz package Channelz is a live debug tool in gRPC Python. +Supported Python Versions +------------------------- +Python >= 3.5 + +Deprecated Python Versions +-------------------------- +Python == 2.7. Python 2.7 support will be removed on January 1, 2020. + Dependencies ------------ diff --git a/src/python/grpcio_health_checking/README.rst b/src/python/grpcio_health_checking/README.rst index 600734e50df..044377a5828 100644 --- a/src/python/grpcio_health_checking/README.rst +++ b/src/python/grpcio_health_checking/README.rst @@ -3,6 +3,14 @@ gRPC Python Health Checking Reference package for GRPC Python health checking. +Supported Python Versions +------------------------- +Python >= 3.5 + +Deprecated Python Versions +-------------------------- +Python == 2.7. Python 2.7 support will be removed on January 1, 2020. + Dependencies ------------ diff --git a/src/python/grpcio_reflection/README.rst b/src/python/grpcio_reflection/README.rst index da99a449044..56f9953373b 100644 --- a/src/python/grpcio_reflection/README.rst +++ b/src/python/grpcio_reflection/README.rst @@ -3,6 +3,14 @@ gRPC Python Reflection package Reference package for reflection in GRPC Python. +Supported Python Versions +------------------------- +Python >= 3.5 + +Deprecated Python Versions +-------------------------- +Python == 2.7. Python 2.7 support will be removed on January 1, 2020. + Dependencies ------------ diff --git a/src/python/grpcio_status/README.rst b/src/python/grpcio_status/README.rst index dc2f7b1dab1..16c59387a61 100644 --- a/src/python/grpcio_status/README.rst +++ b/src/python/grpcio_status/README.rst @@ -3,6 +3,14 @@ gRPC Python Status Proto Reference package for GRPC Python status proto mapping. +Supported Python Versions +------------------------- +Python >= 3.5 + +Deprecated Python Versions +-------------------------- +Python == 2.7. Python 2.7 support will be removed on January 1, 2020. + Dependencies ------------ diff --git a/src/python/grpcio_testing/README.rst b/src/python/grpcio_testing/README.rst index c699b80fb67..968dec85071 100644 --- a/src/python/grpcio_testing/README.rst +++ b/src/python/grpcio_testing/README.rst @@ -3,6 +3,14 @@ gRPC Python Testing Package Testing utilities for gRPC Python +Supported Python Versions +------------------------- +Python >= 3.5 + +Deprecated Python Versions +-------------------------- +Python == 2.7. Python 2.7 support will be removed on January 1, 2020. + Dependencies ------------ diff --git a/tools/distrib/python/grpcio_tools/README.rst b/tools/distrib/python/grpcio_tools/README.rst index 32873b291fa..cc974eda315 100644 --- a/tools/distrib/python/grpcio_tools/README.rst +++ b/tools/distrib/python/grpcio_tools/README.rst @@ -3,6 +3,14 @@ gRPC Python Tools Package for gRPC Python tools. +Supported Python Versions +------------------------- +Python >= 3.5 + +Deprecated Python Versions +-------------------------- +Python == 2.7. Python 2.7 support will be removed on January 1, 2020. + Installation ------------ From cb9e2188ab05f983f447ed4cf8fb93b299bd224d Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 20 May 2019 12:45:16 -0700 Subject: [PATCH 0257/1555] Add python deprecation notices. --- src/python/grpcio/README.rst | 8 ++++++++ src/python/grpcio_channelz/README.rst | 8 ++++++++ src/python/grpcio_health_checking/README.rst | 8 ++++++++ src/python/grpcio_reflection/README.rst | 8 ++++++++ src/python/grpcio_status/README.rst | 8 ++++++++ src/python/grpcio_testing/README.rst | 8 ++++++++ tools/distrib/python/grpcio_tools/README.rst | 8 ++++++++ 7 files changed, 56 insertions(+) diff --git a/src/python/grpcio/README.rst b/src/python/grpcio/README.rst index f047243f82d..44d516ef6cb 100644 --- a/src/python/grpcio/README.rst +++ b/src/python/grpcio/README.rst @@ -3,6 +3,14 @@ gRPC Python Package for gRPC Python. +Supported Python Versions +------------------------- +Python >= 3.5 + +Deprecated Python Versions +-------------------------- +Python == 2.7. Python 2.7 support will be removed on January 1, 2020. + Installation ------------ diff --git a/src/python/grpcio_channelz/README.rst b/src/python/grpcio_channelz/README.rst index efeaa560646..d66d0c4f922 100644 --- a/src/python/grpcio_channelz/README.rst +++ b/src/python/grpcio_channelz/README.rst @@ -3,6 +3,14 @@ gRPC Python Channelz package Channelz is a live debug tool in gRPC Python. +Supported Python Versions +------------------------- +Python >= 3.5 + +Deprecated Python Versions +-------------------------- +Python == 2.7. Python 2.7 support will be removed on January 1, 2020. + Dependencies ------------ diff --git a/src/python/grpcio_health_checking/README.rst b/src/python/grpcio_health_checking/README.rst index 600734e50df..044377a5828 100644 --- a/src/python/grpcio_health_checking/README.rst +++ b/src/python/grpcio_health_checking/README.rst @@ -3,6 +3,14 @@ gRPC Python Health Checking Reference package for GRPC Python health checking. +Supported Python Versions +------------------------- +Python >= 3.5 + +Deprecated Python Versions +-------------------------- +Python == 2.7. Python 2.7 support will be removed on January 1, 2020. + Dependencies ------------ diff --git a/src/python/grpcio_reflection/README.rst b/src/python/grpcio_reflection/README.rst index da99a449044..56f9953373b 100644 --- a/src/python/grpcio_reflection/README.rst +++ b/src/python/grpcio_reflection/README.rst @@ -3,6 +3,14 @@ gRPC Python Reflection package Reference package for reflection in GRPC Python. +Supported Python Versions +------------------------- +Python >= 3.5 + +Deprecated Python Versions +-------------------------- +Python == 2.7. Python 2.7 support will be removed on January 1, 2020. + Dependencies ------------ diff --git a/src/python/grpcio_status/README.rst b/src/python/grpcio_status/README.rst index dc2f7b1dab1..16c59387a61 100644 --- a/src/python/grpcio_status/README.rst +++ b/src/python/grpcio_status/README.rst @@ -3,6 +3,14 @@ gRPC Python Status Proto Reference package for GRPC Python status proto mapping. +Supported Python Versions +------------------------- +Python >= 3.5 + +Deprecated Python Versions +-------------------------- +Python == 2.7. Python 2.7 support will be removed on January 1, 2020. + Dependencies ------------ diff --git a/src/python/grpcio_testing/README.rst b/src/python/grpcio_testing/README.rst index c699b80fb67..968dec85071 100644 --- a/src/python/grpcio_testing/README.rst +++ b/src/python/grpcio_testing/README.rst @@ -3,6 +3,14 @@ gRPC Python Testing Package Testing utilities for gRPC Python +Supported Python Versions +------------------------- +Python >= 3.5 + +Deprecated Python Versions +-------------------------- +Python == 2.7. Python 2.7 support will be removed on January 1, 2020. + Dependencies ------------ diff --git a/tools/distrib/python/grpcio_tools/README.rst b/tools/distrib/python/grpcio_tools/README.rst index 32873b291fa..cc974eda315 100644 --- a/tools/distrib/python/grpcio_tools/README.rst +++ b/tools/distrib/python/grpcio_tools/README.rst @@ -3,6 +3,14 @@ gRPC Python Tools Package for gRPC Python tools. +Supported Python Versions +------------------------- +Python >= 3.5 + +Deprecated Python Versions +-------------------------- +Python == 2.7. Python 2.7 support will be removed on January 1, 2020. + Installation ------------ From 061dfc911f54c8a641ff7126dec77ac0c27430e7 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Mon, 20 May 2019 13:51:27 -0700 Subject: [PATCH 0258/1555] Bring back the internalization --- src/core/lib/surface/completion_queue.cc | 23 ++++++++++++++--------- src/core/lib/surface/completion_queue.h | 3 ++- src/core/lib/surface/server.cc | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index b62f3fa6add..64ceb45cf24 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -201,7 +201,7 @@ struct cq_vtable { bool (*begin_op)(grpc_completion_queue* cq, void* tag); void (*end_op)(grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage); + void* done_arg, grpc_cq_completion* storage, bool internal); grpc_event (*next)(grpc_completion_queue* cq, gpr_timespec deadline, void* reserved); grpc_event (*pluck)(grpc_completion_queue* cq, void* tag, @@ -358,17 +358,17 @@ static bool cq_begin_op_for_callback(grpc_completion_queue* cq, void* tag); static void cq_end_op_for_next( grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage); + grpc_cq_completion* storage, bool internal); static void cq_end_op_for_pluck( grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage); + grpc_cq_completion* storage, bool internal); static void cq_end_op_for_callback( grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage); + grpc_cq_completion* storage, bool internal); static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline, void* reserved); @@ -675,7 +675,7 @@ bool grpc_cq_begin_op(grpc_completion_queue* cq, void* tag) { static void cq_end_op_for_next( grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage) { + grpc_cq_completion* storage, bool internal) { GPR_TIMER_SCOPE("cq_end_op_for_next", 0); if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) || @@ -754,7 +754,7 @@ static void cq_end_op_for_next( static void cq_end_op_for_pluck( grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage) { + grpc_cq_completion* storage, bool internal) { GPR_TIMER_SCOPE("cq_end_op_for_pluck", 0); cq_pluck_data* cqd = static_cast DATA_FROM_CQ(cq); @@ -826,7 +826,7 @@ static void functor_callback(void* arg, grpc_error* error) { static void cq_end_op_for_callback( grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage) { + grpc_cq_completion* storage, bool internal) { GPR_TIMER_SCOPE("cq_end_op_for_callback", 0); cq_callback_data* cqd = static_cast DATA_FROM_CQ(cq); @@ -857,18 +857,23 @@ static void cq_end_op_for_callback( } auto* functor = static_cast(tag); + if (internal) { + grpc_core::ApplicationCallbackExecCtx::Enqueue(functor, + (error == GRPC_ERROR_NONE)); + } else { GRPC_CLOSURE_RUN( GRPC_CLOSURE_CREATE( functor_callback, functor, grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), GRPC_ERROR_REF(error)); + } GRPC_ERROR_UNREF(error); } void grpc_cq_end_op(grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage) { - cq->vtable->end_op(cq, tag, error, done, done_arg, storage); + void* done_arg, grpc_cq_completion* storage, bool internal) { + cq->vtable->end_op(cq, tag, error, done, done_arg, storage, internal); } typedef struct { diff --git a/src/core/lib/surface/completion_queue.h b/src/core/lib/surface/completion_queue.h index d60fe6d6efe..3ba9fbb8765 100644 --- a/src/core/lib/surface/completion_queue.h +++ b/src/core/lib/surface/completion_queue.h @@ -77,7 +77,8 @@ bool grpc_cq_begin_op(grpc_completion_queue* cc, void* tag); grpc_cq_begin_op */ void grpc_cq_end_op(grpc_completion_queue* cc, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage); + void* done_arg, grpc_cq_completion* storage, + bool internal = false); grpc_pollset* grpc_cq_pollset(grpc_completion_queue* cc); diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 2377c4d8f23..19f61c548d6 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -513,7 +513,7 @@ static void publish_call(grpc_server* server, call_data* calld, size_t cq_idx, } grpc_cq_end_op(calld->cq_new, rc->tag, GRPC_ERROR_NONE, done_request_event, - rc, &rc->completion); + rc, &rc->completion, true); } static void publish_new_rpc(void* arg, grpc_error* error) { From 5d95bf037d2ef325c0221d17a4c2ece586349f46 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 20 May 2019 14:09:10 -0700 Subject: [PATCH 0259/1555] Actually include README.rst in all packages --- src/python/grpcio_channelz/setup.py | 4 ++++ src/python/grpcio_health_checking/setup.py | 4 ++++ src/python/grpcio_reflection/setup.py | 4 ++++ src/python/grpcio_status/setup.py | 4 ++++ src/python/grpcio_testing/setup.py | 4 ++++ tools/distrib/python/grpcio_tools/setup.py | 4 ++++ 6 files changed, 24 insertions(+) diff --git a/src/python/grpcio_channelz/setup.py b/src/python/grpcio_channelz/setup.py index f8c0e93913d..cc03809dda8 100644 --- a/src/python/grpcio_channelz/setup.py +++ b/src/python/grpcio_channelz/setup.py @@ -18,6 +18,9 @@ import sys import setuptools +_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) +_README_PATH = os.path.join(_PACKAGE_PATH, 'README.rst') + # Ensure we're in the proper directory whether or not we're being used by pip. os.chdir(os.path.dirname(os.path.abspath(__file__))) @@ -85,6 +88,7 @@ setuptools.setup( version=grpc_version.VERSION, license='Apache License 2.0', description='Channel Level Live Debug Information Service for gRPC', + long_description=open(_README_PATH, 'r').read(), author='The gRPC Authors', author_email='grpc-io@googlegroups.com', classifiers=CLASSIFIERS, diff --git a/src/python/grpcio_health_checking/setup.py b/src/python/grpcio_health_checking/setup.py index 5a09a80f6ae..dc2a69c1f43 100644 --- a/src/python/grpcio_health_checking/setup.py +++ b/src/python/grpcio_health_checking/setup.py @@ -17,6 +17,9 @@ import os import setuptools +_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) +_README_PATH = os.path.join(_PACKAGE_PATH, 'README.rst') + # Ensure we're in the proper directory whether or not we're being used by pip. os.chdir(os.path.dirname(os.path.abspath(__file__))) @@ -83,6 +86,7 @@ setuptools.setup( name='grpcio-health-checking', version=grpc_version.VERSION, description='Standard Health Checking Service for gRPC', + long_description=open(_README_PATH, 'r').read(), author='The gRPC Authors', author_email='grpc-io@googlegroups.com', url='https://grpc.io', diff --git a/src/python/grpcio_reflection/setup.py b/src/python/grpcio_reflection/setup.py index f205069acd5..3fbcfda3229 100644 --- a/src/python/grpcio_reflection/setup.py +++ b/src/python/grpcio_reflection/setup.py @@ -18,6 +18,9 @@ import sys import setuptools +_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) +_README_PATH = os.path.join(_PACKAGE_PATH, 'README.rst') + # Ensure we're in the proper directory whether or not we're being used by pip. os.chdir(os.path.dirname(os.path.abspath(__file__))) @@ -85,6 +88,7 @@ setuptools.setup( version=grpc_version.VERSION, license='Apache License 2.0', description='Standard Protobuf Reflection Service for gRPC', + long_description=open(_README_PATH, 'r').read(), author='The gRPC Authors', author_email='grpc-io@googlegroups.com', classifiers=CLASSIFIERS, diff --git a/src/python/grpcio_status/setup.py b/src/python/grpcio_status/setup.py index 983d3ea430b..06d5dcfa8aa 100644 --- a/src/python/grpcio_status/setup.py +++ b/src/python/grpcio_status/setup.py @@ -17,6 +17,9 @@ import os import setuptools +_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) +_README_PATH = os.path.join(_PACKAGE_PATH, 'README.rst') + # Ensure we're in the proper directory whether or not we're being used by pip. os.chdir(os.path.dirname(os.path.abspath(__file__))) @@ -82,6 +85,7 @@ setuptools.setup( name='grpcio-status', version=grpc_version.VERSION, description='Status proto mapping for gRPC', + long_description=open(_README_PATH, 'r').read(), author='The gRPC Authors', author_email='grpc-io@googlegroups.com', url='https://grpc.io', diff --git a/src/python/grpcio_testing/setup.py b/src/python/grpcio_testing/setup.py index 18db71e0f09..05d2a130ed6 100644 --- a/src/python/grpcio_testing/setup.py +++ b/src/python/grpcio_testing/setup.py @@ -18,6 +18,9 @@ import sys import setuptools +_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) +_README_PATH = os.path.join(_PACKAGE_PATH, 'README.rst') + # Ensure we're in the proper directory whether or not we're being used by pip. os.chdir(os.path.dirname(os.path.abspath(__file__))) @@ -68,6 +71,7 @@ setuptools.setup( version=grpc_version.VERSION, license='Apache License 2.0', description='Testing utilities for gRPC Python', + long_description=open(_README_PATH, 'r').read(), author='The gRPC Authors', author_email='grpc-io@googlegroups.com', url='https://grpc.io', diff --git a/tools/distrib/python/grpcio_tools/setup.py b/tools/distrib/python/grpcio_tools/setup.py index 64c468cbf7b..e83e08b0431 100644 --- a/tools/distrib/python/grpcio_tools/setup.py +++ b/tools/distrib/python/grpcio_tools/setup.py @@ -31,6 +31,9 @@ from setuptools.command import build_ext # TODO(atash) add flag to disable Cython use +_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) +_README_PATH = os.path.join(_PACKAGE_PATH, 'README.rst') + os.chdir(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, os.path.abspath('.')) @@ -191,6 +194,7 @@ setuptools.setup( name='grpcio-tools', version=grpc_version.VERSION, description='Protobuf code generator for gRPC', + long_description=open(_README_PATH, 'r').read(), author='The gRPC Authors', author_email='grpc-io@googlegroups.com', url='https://grpc.io', From 2628983fb44f0718a61e3c87993b9729c47895fb Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 20 May 2019 14:09:10 -0700 Subject: [PATCH 0260/1555] Actually include README.rst in all packages --- src/python/grpcio_channelz/setup.py | 4 ++++ src/python/grpcio_health_checking/setup.py | 4 ++++ src/python/grpcio_reflection/setup.py | 4 ++++ src/python/grpcio_status/setup.py | 4 ++++ src/python/grpcio_testing/setup.py | 4 ++++ tools/distrib/python/grpcio_tools/setup.py | 4 ++++ 6 files changed, 24 insertions(+) diff --git a/src/python/grpcio_channelz/setup.py b/src/python/grpcio_channelz/setup.py index f8c0e93913d..cc03809dda8 100644 --- a/src/python/grpcio_channelz/setup.py +++ b/src/python/grpcio_channelz/setup.py @@ -18,6 +18,9 @@ import sys import setuptools +_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) +_README_PATH = os.path.join(_PACKAGE_PATH, 'README.rst') + # Ensure we're in the proper directory whether or not we're being used by pip. os.chdir(os.path.dirname(os.path.abspath(__file__))) @@ -85,6 +88,7 @@ setuptools.setup( version=grpc_version.VERSION, license='Apache License 2.0', description='Channel Level Live Debug Information Service for gRPC', + long_description=open(_README_PATH, 'r').read(), author='The gRPC Authors', author_email='grpc-io@googlegroups.com', classifiers=CLASSIFIERS, diff --git a/src/python/grpcio_health_checking/setup.py b/src/python/grpcio_health_checking/setup.py index 5a09a80f6ae..dc2a69c1f43 100644 --- a/src/python/grpcio_health_checking/setup.py +++ b/src/python/grpcio_health_checking/setup.py @@ -17,6 +17,9 @@ import os import setuptools +_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) +_README_PATH = os.path.join(_PACKAGE_PATH, 'README.rst') + # Ensure we're in the proper directory whether or not we're being used by pip. os.chdir(os.path.dirname(os.path.abspath(__file__))) @@ -83,6 +86,7 @@ setuptools.setup( name='grpcio-health-checking', version=grpc_version.VERSION, description='Standard Health Checking Service for gRPC', + long_description=open(_README_PATH, 'r').read(), author='The gRPC Authors', author_email='grpc-io@googlegroups.com', url='https://grpc.io', diff --git a/src/python/grpcio_reflection/setup.py b/src/python/grpcio_reflection/setup.py index f205069acd5..3fbcfda3229 100644 --- a/src/python/grpcio_reflection/setup.py +++ b/src/python/grpcio_reflection/setup.py @@ -18,6 +18,9 @@ import sys import setuptools +_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) +_README_PATH = os.path.join(_PACKAGE_PATH, 'README.rst') + # Ensure we're in the proper directory whether or not we're being used by pip. os.chdir(os.path.dirname(os.path.abspath(__file__))) @@ -85,6 +88,7 @@ setuptools.setup( version=grpc_version.VERSION, license='Apache License 2.0', description='Standard Protobuf Reflection Service for gRPC', + long_description=open(_README_PATH, 'r').read(), author='The gRPC Authors', author_email='grpc-io@googlegroups.com', classifiers=CLASSIFIERS, diff --git a/src/python/grpcio_status/setup.py b/src/python/grpcio_status/setup.py index 983d3ea430b..06d5dcfa8aa 100644 --- a/src/python/grpcio_status/setup.py +++ b/src/python/grpcio_status/setup.py @@ -17,6 +17,9 @@ import os import setuptools +_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) +_README_PATH = os.path.join(_PACKAGE_PATH, 'README.rst') + # Ensure we're in the proper directory whether or not we're being used by pip. os.chdir(os.path.dirname(os.path.abspath(__file__))) @@ -82,6 +85,7 @@ setuptools.setup( name='grpcio-status', version=grpc_version.VERSION, description='Status proto mapping for gRPC', + long_description=open(_README_PATH, 'r').read(), author='The gRPC Authors', author_email='grpc-io@googlegroups.com', url='https://grpc.io', diff --git a/src/python/grpcio_testing/setup.py b/src/python/grpcio_testing/setup.py index 18db71e0f09..05d2a130ed6 100644 --- a/src/python/grpcio_testing/setup.py +++ b/src/python/grpcio_testing/setup.py @@ -18,6 +18,9 @@ import sys import setuptools +_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) +_README_PATH = os.path.join(_PACKAGE_PATH, 'README.rst') + # Ensure we're in the proper directory whether or not we're being used by pip. os.chdir(os.path.dirname(os.path.abspath(__file__))) @@ -68,6 +71,7 @@ setuptools.setup( version=grpc_version.VERSION, license='Apache License 2.0', description='Testing utilities for gRPC Python', + long_description=open(_README_PATH, 'r').read(), author='The gRPC Authors', author_email='grpc-io@googlegroups.com', url='https://grpc.io', diff --git a/tools/distrib/python/grpcio_tools/setup.py b/tools/distrib/python/grpcio_tools/setup.py index 64c468cbf7b..e83e08b0431 100644 --- a/tools/distrib/python/grpcio_tools/setup.py +++ b/tools/distrib/python/grpcio_tools/setup.py @@ -31,6 +31,9 @@ from setuptools.command import build_ext # TODO(atash) add flag to disable Cython use +_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) +_README_PATH = os.path.join(_PACKAGE_PATH, 'README.rst') + os.chdir(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, os.path.abspath('.')) @@ -191,6 +194,7 @@ setuptools.setup( name='grpcio-tools', version=grpc_version.VERSION, description='Protobuf code generator for gRPC', + long_description=open(_README_PATH, 'r').read(), author='The gRPC Authors', author_email='grpc-io@googlegroups.com', url='https://grpc.io', From c681ff8e4b864622ffcaaa9476604a04de944636 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 20 May 2019 14:51:16 -0700 Subject: [PATCH 0261/1555] Rename root certificate bundle in gRPC-C++ pod --- gRPC-C++.podspec | 4 ++-- templates/gRPC-C++.podspec.template | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 57743df8c7c..55549b49af9 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -24,7 +24,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized # version = '1.22.0-dev' - version = '0.0.8-dev' + version = '0.0.9-dev' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' @@ -72,7 +72,7 @@ Pod::Spec.new do |s| s.default_subspecs = 'Interface', 'Implementation' # Certificates, to be able to establish TLS connections: - s.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } + s.resource_bundles = { 'gRPCCertificates-Cpp' => ['etc/roots.pem'] } s.header_mappings_dir = 'include/grpcpp' diff --git a/templates/gRPC-C++.podspec.template b/templates/gRPC-C++.podspec.template index 43cb6db66c6..40368e422d9 100644 --- a/templates/gRPC-C++.podspec.template +++ b/templates/gRPC-C++.podspec.template @@ -140,7 +140,7 @@ s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized # version = '${settings.version}' - version = '${modify_podspec_version_string('0.0.8', settings.version)}' + version = '${modify_podspec_version_string('0.0.9', settings.version)}' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' @@ -188,7 +188,7 @@ s.default_subspecs = 'Interface', 'Implementation' # Certificates, to be able to establish TLS connections: - s.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } + s.resource_bundles = { 'gRPCCertificates-Cpp' => ['etc/roots.pem'] } s.header_mappings_dir = 'include/grpcpp' From 90fbdc92f522af9f98297e08c0ed174361977d46 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Mon, 20 May 2019 08:05:01 -0700 Subject: [PATCH 0262/1555] Roll-forward "Config migration" This reverts commit 236ae12bb115c307d1cd7d0b88c7aaa082e3dd0a. --- BUILD | 16 +++++++ BUILD.gn | 2 + CMakeLists.txt | 2 + Makefile | 2 + build.yaml | 9 ++++ config.m4 | 2 + config.w32 | 1 + gRPC-C++.podspec | 1 + gRPC-Core.podspec | 3 ++ grpc.gemspec | 2 + grpc.gyp | 2 + package.xml | 2 + .../interop/app/src/main/cpp/grpc-interop.cc | 6 +-- .../filters/client_channel/backup_poller.cc | 11 +++-- .../client_channel/http_connect_handshaker.cc | 1 - .../resolver/dns/c_ares/dns_resolver_ares.cc | 14 +++--- .../resolver/dns/dns_resolver_selection.cc | 28 ++++++++++++ .../resolver/dns/dns_resolver_selection.h | 29 ++++++++++++ .../resolver/dns/native/dns_resolver.cc | 8 ++-- .../chttp2/transport/chttp2_plugin.cc | 7 ++- src/core/lib/debug/trace.cc | 20 ++++++--- src/core/lib/debug/trace.h | 8 ++++ src/core/lib/gpr/env.h | 6 --- src/core/lib/gpr/env_linux.cc | 2 +- src/core/lib/gpr/env_windows.cc | 5 --- src/core/lib/gpr/log.cc | 22 ++++------ src/core/lib/gprpp/fork.cc | 41 +++++------------ src/core/lib/iomgr/ev_posix.cc | 26 ++++++----- src/core/lib/iomgr/ev_posix.h | 3 ++ src/core/lib/iomgr/fork_posix.cc | 1 - src/core/lib/iomgr/iomgr.cc | 3 +- src/core/lib/profiling/basic_timers.cc | 14 ++++-- .../load_system_roots_linux.cc | 12 ++--- .../security_connector/security_connector.cc | 1 - .../security/security_connector/ssl_utils.cc | 44 +++++++++++-------- .../security/security_connector/ssl_utils.h | 6 ++- src/core/lib/surface/init.cc | 2 +- .../private/GRPCSecureChannelFactory.m | 3 +- .../CoreCronetEnd2EndTests.mm | 4 +- src/python/grpcio/grpc_core_dependencies.py | 1 + test/core/bad_connection/close_fd_test.cc | 1 - test/core/bad_ssl/bad_ssl_test.cc | 4 +- .../resolvers/dns_resolver_test.cc | 8 ++-- test/core/end2end/fixtures/h2_full+trace.cc | 4 +- .../end2end/fixtures/h2_sockpair+trace.cc | 5 ++- test/core/end2end/fixtures/h2_spiffe.cc | 3 +- test/core/end2end/fixtures/h2_ssl.cc | 4 +- .../end2end/fixtures/h2_ssl_cred_reload.cc | 4 +- test/core/end2end/fixtures/h2_ssl_proxy.cc | 4 +- test/core/end2end/h2_ssl_cert_test.cc | 4 +- .../core/end2end/h2_ssl_session_reuse_test.cc | 4 +- test/core/end2end/tests/keepalive_timeout.cc | 14 +++--- test/core/gpr/log_test.cc | 13 ++++-- test/core/http/httpscli_test.cc | 3 +- test/core/iomgr/resolve_address_posix_test.cc | 18 ++++---- test/core/iomgr/resolve_address_test.cc | 13 +++--- test/core/security/credentials_test.cc | 2 +- test/core/security/security_connector_test.cc | 10 ++--- test/core/util/test_config.cc | 1 - test/cpp/end2end/async_end2end_test.cc | 12 +++-- test/cpp/end2end/end2end_test.cc | 12 +++-- test/cpp/naming/address_sorting_test.cc | 14 +++--- test/cpp/naming/cancel_ares_query_test.cc | 4 +- test/cpp/naming/resolver_component_test.cc | 1 - tools/doxygen/Doxyfile.core.internal | 2 + .../generated/sources_and_headers.json | 24 +++++++++- tools/run_tests/run_microbenchmark.py | 2 +- .../run_tests/sanity/core_banned_functions.py | 4 -- 68 files changed, 358 insertions(+), 208 deletions(-) create mode 100644 src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc create mode 100644 src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h diff --git a/BUILD b/BUILD index 52c469f0b4a..d36aba2387c 100644 --- a/BUILD +++ b/BUILD @@ -1563,6 +1563,20 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "grpc_resolver_dns_selection", + srcs = [ + "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc", + ], + hdrs = [ + "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h", + ], + language = "c++", + deps = [ + "grpc_base", + ], +) + grpc_cc_library( name = "grpc_resolver_dns_native", srcs = [ @@ -1572,6 +1586,7 @@ grpc_cc_library( deps = [ "grpc_base", "grpc_client_channel", + "grpc_resolver_dns_selection", ], ) @@ -1601,6 +1616,7 @@ grpc_cc_library( deps = [ "grpc_base", "grpc_client_channel", + "grpc_resolver_dns_selection", ], ) diff --git a/BUILD.gn b/BUILD.gn index ea5d544972f..62877a74539 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -324,6 +324,8 @@ config("grpc_config") { "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc", + "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc", + "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h", "src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc", "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc", "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index f85bff572e6..2e4886b7b38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1308,6 +1308,7 @@ add_library(grpc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc + src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc src/core/ext/filters/census/grpc_context.cc @@ -2703,6 +2704,7 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc + src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc diff --git a/Makefile b/Makefile index 9cf0ab03f09..f76b6878729 100644 --- a/Makefile +++ b/Makefile @@ -3788,6 +3788,7 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ + src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ src/core/ext/filters/census/grpc_context.cc \ @@ -5131,6 +5132,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ + src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ diff --git a/build.yaml b/build.yaml index fbfa0df86cd..3d7f44976b2 100644 --- a/build.yaml +++ b/build.yaml @@ -796,6 +796,7 @@ filegroups: uses: - grpc_base - grpc_client_channel + - grpc_resolver_dns_selection - name: grpc_resolver_dns_native src: - src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc @@ -803,6 +804,14 @@ filegroups: uses: - grpc_base - grpc_client_channel + - grpc_resolver_dns_selection +- name: grpc_resolver_dns_selection + headers: + - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h + src: + - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc + uses: + - grpc_base - name: grpc_resolver_fake headers: - src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h diff --git a/config.m4 b/config.m4 index 4dc6a7ce34e..bb30be56910 100644 --- a/config.m4 +++ b/config.m4 @@ -411,6 +411,7 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ + src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ src/core/ext/filters/census/grpc_context.cc \ @@ -694,6 +695,7 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/pick_first) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/round_robin) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/xds) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns/c_ares) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns/native) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/fake) diff --git a/config.w32 b/config.w32 index ec65248e0d6..c9faa8d9ac8 100644 --- a/config.w32 +++ b/config.w32 @@ -386,6 +386,7 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_libuv.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_posix.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_windows.cc " + + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\dns_resolver_selection.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\native\\dns_resolver.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\sockaddr\\sockaddr_resolver.cc " + "src\\core\\ext\\filters\\census\\grpc_context.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 57743df8c7c..df030f3a3dd 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -563,6 +563,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', + 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', 'src/core/ext/filters/http/client_authority_filter.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 682b7d80277..8ad00aad096 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -539,6 +539,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', + 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', 'src/core/ext/filters/http/client_authority_filter.h', @@ -868,6 +869,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', + 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/census/grpc_context.cc', @@ -1189,6 +1191,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', + 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', 'src/core/ext/filters/http/client_authority_filter.h', diff --git a/grpc.gemspec b/grpc.gemspec index 36b325f8f0d..0bbf10fb361 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -473,6 +473,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/lb_policy/subchannel_list.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h ) + s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h ) s.files += %w( src/core/ext/filters/max_age/max_age_filter.h ) s.files += %w( src/core/ext/filters/message_size/message_size_filter.h ) s.files += %w( src/core/ext/filters/http/client_authority_filter.h ) @@ -805,6 +806,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc ) + s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc ) s.files += %w( src/core/ext/filters/census/grpc_context.cc ) diff --git a/grpc.gyp b/grpc.gyp index 3a90eac28b5..eff5ab816b8 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -593,6 +593,7 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', + 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/census/grpc_context.cc', @@ -1352,6 +1353,7 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', + 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', diff --git a/package.xml b/package.xml index da12917dbee..eca74c8f167 100644 --- a/package.xml +++ b/package.xml @@ -478,6 +478,7 @@ + @@ -810,6 +811,7 @@ + diff --git a/src/android/test/interop/app/src/main/cpp/grpc-interop.cc b/src/android/test/interop/app/src/main/cpp/grpc-interop.cc index 07834250d22..b5075529be2 100644 --- a/src/android/test/interop/app/src/main/cpp/grpc-interop.cc +++ b/src/android/test/interop/app/src/main/cpp/grpc-interop.cc @@ -18,8 +18,8 @@ #include #include -#include +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/cpp/interop/interop_client.h" extern "C" JNIEXPORT void JNICALL @@ -28,7 +28,7 @@ Java_io_grpc_interop_cpp_InteropActivity_configureSslRoots(JNIEnv* env, jstring path_raw) { const char* path = env->GetStringUTFChars(path_raw, (jboolean*)0); - gpr_setenv("GRPC_DEFAULT_SSL_ROOTS_FILE_PATH", path); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, path); } std::shared_ptr GetClient(const char* host, @@ -45,7 +45,7 @@ std::shared_ptr GetClient(const char* host, credentials = grpc::InsecureChannelCredentials(); } - grpc::testing::ChannelCreationFunc channel_creation_func = + grpc::testing::ChannelCreationFunc channel_creation_func = std::bind(grpc::CreateChannel, host_port, credentials); return std::shared_ptr( new grpc::testing::InteropClient(channel_creation_func, true, false)); diff --git a/src/core/ext/filters/client_channel/backup_poller.cc b/src/core/ext/filters/client_channel/backup_poller.cc index a2d45c04026..dd761694414 100644 --- a/src/core/ext/filters/client_channel/backup_poller.cc +++ b/src/core/ext/filters/client_channel/backup_poller.cc @@ -56,9 +56,14 @@ static backup_poller* g_poller = nullptr; // guarded by g_poller_mu // treated as const. static int g_poll_interval_ms = DEFAULT_POLL_INTERVAL_MS; -GPR_GLOBAL_CONFIG_DEFINE_INT32(grpc_client_channel_backup_poll_interval_ms, - DEFAULT_POLL_INTERVAL_MS, - "Client channel backup poll interval (ms)"); +GPR_GLOBAL_CONFIG_DEFINE_INT32( + grpc_client_channel_backup_poll_interval_ms, DEFAULT_POLL_INTERVAL_MS, + "Declares the interval in ms between two backup polls on client channels. " + "These polls are run in the timer thread so that gRPC can process " + "connection failures while there is no active polling thread. " + "They help reconnect disconnected client channels (mostly due to " + "idleness), so that the next RPC on this channel won't fail. Set to 0 to " + "turn off the backup polls."); static void init_globals() { gpr_mu_init(&g_poller_mu); diff --git a/src/core/ext/filters/client_channel/http_connect_handshaker.cc b/src/core/ext/filters/client_channel/http_connect_handshaker.cc index 90a79843458..95366b57386 100644 --- a/src/core/ext/filters/client_channel/http_connect_handshaker.cc +++ b/src/core/ext/filters/client_channel/http_connect_handshaker.cc @@ -31,7 +31,6 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker_registry.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/http/format_request.h" diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index 27d543363a3..00358736a94 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -32,12 +32,12 @@ #include "src/core/ext/filters/client_channel/http_connect_handshaker.h" #include "src/core/ext/filters/client_channel/lb_policy_registry.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" +#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/ext/filters/client_channel/service_config.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" @@ -474,8 +474,9 @@ static bool should_use_ares(const char* resolver_env) { #endif /* GRPC_UV */ void grpc_resolver_dns_ares_init() { - char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER"); - if (should_use_ares(resolver_env)) { + grpc_core::UniquePtr resolver = + GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); + if (should_use_ares(resolver.get())) { gpr_log(GPR_DEBUG, "Using ares dns resolver"); address_sorting_init(); grpc_error* error = grpc_ares_init(); @@ -491,16 +492,15 @@ void grpc_resolver_dns_ares_init() { grpc_core::UniquePtr( grpc_core::New())); } - gpr_free(resolver_env); } void grpc_resolver_dns_ares_shutdown() { - char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER"); - if (should_use_ares(resolver_env)) { + grpc_core::UniquePtr resolver = + GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); + if (should_use_ares(resolver.get())) { address_sorting_shutdown(); grpc_ares_cleanup(); } - gpr_free(resolver_env); } #else /* GRPC_ARES == 1 */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc b/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc new file mode 100644 index 00000000000..07a617c14d5 --- /dev/null +++ b/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc @@ -0,0 +1,28 @@ +// +// Copyright 2019 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// This is similar to the sockaddr resolver, except that it supports a +// bunch of query args that are useful for dependency injection in tests. + +#include + +#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" + +GPR_GLOBAL_CONFIG_DEFINE_STRING( + grpc_dns_resolver, "", + "Declares which DNS resolver to use. The default is ares if gRPC is built " + "with c-ares support. Otherwise, the value of this environment variable is " + "ignored.") diff --git a/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h b/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h new file mode 100644 index 00000000000..d0a3486ea38 --- /dev/null +++ b/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h @@ -0,0 +1,29 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_DNS_RESOLVER_SELECTION_H +#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_DNS_RESOLVER_SELECTION_H + +#include + +#include "src/core/lib/gprpp/global_config.h" + +GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_dns_resolver); + +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_DNS_RESOLVER_SELECTION_H \ + */ diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc index 164d308c0dd..5ab75d02793 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc @@ -26,11 +26,11 @@ #include #include +#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" @@ -274,8 +274,9 @@ class NativeDnsResolverFactory : public ResolverFactory { } // namespace grpc_core void grpc_resolver_dns_native_init() { - char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER"); - if (resolver_env != nullptr && gpr_stricmp(resolver_env, "native") == 0) { + grpc_core::UniquePtr resolver = + GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); + if (gpr_stricmp(resolver.get(), "native") == 0) { gpr_log(GPR_DEBUG, "Using native dns resolver"); grpc_core::ResolverRegistry::Builder::RegisterResolverFactory( grpc_core::UniquePtr( @@ -291,7 +292,6 @@ void grpc_resolver_dns_native_init() { grpc_core::New())); } } - gpr_free(resolver_env); } void grpc_resolver_dns_native_shutdown() {} diff --git a/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc b/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc index 4c929d00ec9..ac13d73d3b5 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc @@ -23,8 +23,11 @@ #include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/transport/metadata.h" -GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_experimental_disable_flow_control, false, - "Disable flow control"); +GPR_GLOBAL_CONFIG_DEFINE_BOOL( + grpc_experimental_disable_flow_control, false, + "If set, flow control will be effectively disabled. Max out all values and " + "assume the remote peer does the same. Thus we can ignore any flow control " + "bookkeeping, error checking, and decision making"); void grpc_chttp2_plugin_init(void) { g_flow_control_enabled = diff --git a/src/core/lib/debug/trace.cc b/src/core/lib/debug/trace.cc index cafdb15c699..84c0a3805d3 100644 --- a/src/core/lib/debug/trace.cc +++ b/src/core/lib/debug/trace.cc @@ -26,7 +26,11 @@ #include #include #include -#include "src/core/lib/gpr/env.h" + +GPR_GLOBAL_CONFIG_DEFINE_STRING( + grpc_trace, "", + "A comma separated list of tracers that provide additional insight into " + "how gRPC C core is processing requests via debug logs."); int grpc_tracer_set_enabled(const char* name, int enabled); @@ -133,12 +137,14 @@ static void parse(const char* s) { gpr_free(strings); } -void grpc_tracer_init(const char* env_var) { - char* e = gpr_getenv(env_var); - if (e != nullptr) { - parse(e); - gpr_free(e); - } +void grpc_tracer_init(const char* env_var_name) { + (void)env_var_name; // suppress unused variable error + grpc_tracer_init(); +} + +void grpc_tracer_init() { + grpc_core::UniquePtr value = GPR_GLOBAL_CONFIG_GET(grpc_trace); + parse(value.get()); } void grpc_tracer_shutdown(void) {} diff --git a/src/core/lib/debug/trace.h b/src/core/lib/debug/trace.h index 72e1a4eded7..6a4a8031ec4 100644 --- a/src/core/lib/debug/trace.h +++ b/src/core/lib/debug/trace.h @@ -24,7 +24,15 @@ #include #include +#include "src/core/lib/gprpp/global_config.h" + +GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_trace); + +// TODO(veblush): Remove this deprecated function once codes depending on this +// function are updated in the internal repo. void grpc_tracer_init(const char* env_var_name); + +void grpc_tracer_init(); void grpc_tracer_shutdown(void); #if defined(__has_feature) diff --git a/src/core/lib/gpr/env.h b/src/core/lib/gpr/env.h index fb9e0636d10..f5016c6fa06 100644 --- a/src/core/lib/gpr/env.h +++ b/src/core/lib/gpr/env.h @@ -34,12 +34,6 @@ char* gpr_getenv(const char* name); /* Sets the environment with the specified name to the specified value. */ void gpr_setenv(const char* name, const char* value); -/* This is a version of gpr_getenv that does not produce any output if it has to - use an insecure version of the function. It is ONLY to be used to solve the - problem in which we need to check an env variable to configure the verbosity - level of logging. So DO NOT USE THIS. */ -const char* gpr_getenv_silent(const char* name, char** dst); - /* Deletes the variable name from the environment. */ void gpr_unsetenv(const char* name); diff --git a/src/core/lib/gpr/env_linux.cc b/src/core/lib/gpr/env_linux.cc index e84a9f6064c..3a3aa541672 100644 --- a/src/core/lib/gpr/env_linux.cc +++ b/src/core/lib/gpr/env_linux.cc @@ -38,7 +38,7 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" -const char* gpr_getenv_silent(const char* name, char** dst) { +static const char* gpr_getenv_silent(const char* name, char** dst) { const char* insecure_func_used = nullptr; char* result = nullptr; #if defined(GPR_BACKWARDS_COMPATIBILITY_MODE) diff --git a/src/core/lib/gpr/env_windows.cc b/src/core/lib/gpr/env_windows.cc index 72850a9587d..76c45fb87a7 100644 --- a/src/core/lib/gpr/env_windows.cc +++ b/src/core/lib/gpr/env_windows.cc @@ -30,11 +30,6 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/string_windows.h" -const char* gpr_getenv_silent(const char* name, char** dst) { - *dst = gpr_getenv(name); - return NULL; -} - char* gpr_getenv(const char* name) { char* result = NULL; DWORD size; diff --git a/src/core/lib/gpr/log.cc b/src/core/lib/gpr/log.cc index 01ef112fb31..8a229b2adf1 100644 --- a/src/core/lib/gpr/log.cc +++ b/src/core/lib/gpr/log.cc @@ -22,12 +22,15 @@ #include #include -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/global_config.h" #include #include +GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_verbosity, "ERROR", + "Default gRPC logging verbosity") + void gpr_default_log(gpr_log_func_args* args); static gpr_atm g_log_func = (gpr_atm)gpr_default_log; static gpr_atm g_min_severity_to_print = GPR_LOG_VERBOSITY_UNSET; @@ -72,29 +75,22 @@ void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print) { } void gpr_log_verbosity_init() { - char* verbosity = nullptr; - const char* insecure_getenv = gpr_getenv_silent("GRPC_VERBOSITY", &verbosity); + grpc_core::UniquePtr verbosity = GPR_GLOBAL_CONFIG_GET(grpc_verbosity); gpr_atm min_severity_to_print = GPR_LOG_SEVERITY_ERROR; - if (verbosity != nullptr) { - if (gpr_stricmp(verbosity, "DEBUG") == 0) { + if (strlen(verbosity.get()) > 0) { + if (gpr_stricmp(verbosity.get(), "DEBUG") == 0) { min_severity_to_print = static_cast(GPR_LOG_SEVERITY_DEBUG); - } else if (gpr_stricmp(verbosity, "INFO") == 0) { + } else if (gpr_stricmp(verbosity.get(), "INFO") == 0) { min_severity_to_print = static_cast(GPR_LOG_SEVERITY_INFO); - } else if (gpr_stricmp(verbosity, "ERROR") == 0) { + } else if (gpr_stricmp(verbosity.get(), "ERROR") == 0) { min_severity_to_print = static_cast(GPR_LOG_SEVERITY_ERROR); } - gpr_free(verbosity); } if ((gpr_atm_no_barrier_load(&g_min_severity_to_print)) == GPR_LOG_VERBOSITY_UNSET) { gpr_atm_no_barrier_store(&g_min_severity_to_print, min_severity_to_print); } - - if (insecure_getenv != nullptr) { - gpr_log(GPR_DEBUG, "Warning: insecure environment read function '%s' used", - insecure_getenv); - } } void gpr_set_log_function(gpr_log_func f) { diff --git a/src/core/lib/gprpp/fork.cc b/src/core/lib/gprpp/fork.cc index fdc7c5354bd..37552692373 100644 --- a/src/core/lib/gprpp/fork.cc +++ b/src/core/lib/gprpp/fork.cc @@ -26,8 +26,8 @@ #include #include -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/memory.h" /* @@ -35,6 +35,16 @@ * AROUND VERY SPECIFIC USE CASES. */ +#ifdef GRPC_ENABLE_FORK_SUPPORT +#define GRPC_ENABLE_FORK_SUPPORT_DEFAULT true +#else +#define GRPC_ENABLE_FORK_SUPPORT_DEFAULT false +#endif // GRPC_ENABLE_FORK_SUPPORT + +GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_enable_fork_support, + GRPC_ENABLE_FORK_SUPPORT_DEFAULT, + "Enable folk support"); + namespace grpc_core { namespace internal { // The exec_ctx_count has 2 modes, blocked and unblocked. @@ -158,34 +168,7 @@ class ThreadState { void Fork::GlobalInit() { if (!override_enabled_) { -#ifdef GRPC_ENABLE_FORK_SUPPORT - support_enabled_ = true; -#endif - bool env_var_set = false; - char* env = gpr_getenv("GRPC_ENABLE_FORK_SUPPORT"); - if (env != nullptr) { - static const char* truthy[] = {"yes", "Yes", "YES", "true", - "True", "TRUE", "1"}; - static const char* falsey[] = {"no", "No", "NO", "false", - "False", "FALSE", "0"}; - for (size_t i = 0; i < GPR_ARRAY_SIZE(truthy); i++) { - if (0 == strcmp(env, truthy[i])) { - support_enabled_ = true; - env_var_set = true; - break; - } - } - if (!env_var_set) { - for (size_t i = 0; i < GPR_ARRAY_SIZE(falsey); i++) { - if (0 == strcmp(env, falsey[i])) { - support_enabled_ = false; - env_var_set = true; - break; - } - } - } - gpr_free(env); - } + support_enabled_ = GPR_GLOBAL_CONFIG_GET(grpc_enable_fork_support); } if (support_enabled_) { exec_ctx_state_ = grpc_core::New(); diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc index 47cf5b83b17..ddafb7b5539 100644 --- a/src/core/lib/iomgr/ev_posix.cc +++ b/src/core/lib/iomgr/ev_posix.cc @@ -31,13 +31,19 @@ #include #include "src/core/lib/debug/trace.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/iomgr/ev_epoll1_linux.h" #include "src/core/lib/iomgr/ev_epollex_linux.h" #include "src/core/lib/iomgr/ev_poll_posix.h" #include "src/core/lib/iomgr/internal_errqueue.h" +GPR_GLOBAL_CONFIG_DEFINE_STRING( + grpc_poll_strategy, "all", + "Declares which polling engines to try when starting gRPC. " + "This is a comma-separated list of engines, which are tried in priority " + "order first -> last.") + grpc_core::TraceFlag grpc_polling_trace(false, "polling"); /* Disabled by default */ @@ -46,16 +52,15 @@ grpc_core::TraceFlag grpc_fd_trace(false, "fd_trace"); grpc_core::DebugOnlyTraceFlag grpc_trace_fd_refcount(false, "fd_refcount"); grpc_core::DebugOnlyTraceFlag grpc_polling_api_trace(false, "polling_api"); -#ifndef NDEBUG - // Polling API trace only enabled in debug builds +#ifndef NDEBUG #define GRPC_POLLING_API_TRACE(format, ...) \ if (GRPC_TRACE_FLAG_ENABLED(grpc_polling_api_trace)) { \ gpr_log(GPR_INFO, "(polling-api) " format, __VA_ARGS__); \ } #else #define GRPC_POLLING_API_TRACE(...) -#endif +#endif // NDEBUG /** Default poll() function - a pointer so that it can be overridden by some * tests */ @@ -66,7 +71,7 @@ int aix_poll(struct pollfd fds[], nfds_t nfds, int timeout) { return poll(fds, nfds, timeout); } grpc_poll_function_type grpc_poll_function = aix_poll; -#endif +#endif // GPR_AIX grpc_wakeup_fd grpc_global_wakeup_fd; @@ -205,14 +210,11 @@ void grpc_register_event_engine_factory(const char* name, const char* grpc_get_poll_strategy_name() { return g_poll_strategy_name; } void grpc_event_engine_init(void) { - char* s = gpr_getenv("GRPC_POLL_STRATEGY"); - if (s == nullptr) { - s = gpr_strdup("all"); - } + grpc_core::UniquePtr value = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); char** strings = nullptr; size_t nstrings = 0; - split(s, &strings, &nstrings); + split(value.get(), &strings, &nstrings); for (size_t i = 0; g_event_engine == nullptr && i < nstrings; i++) { try_engine(strings[i]); @@ -224,10 +226,10 @@ void grpc_event_engine_init(void) { gpr_free(strings); if (g_event_engine == nullptr) { - gpr_log(GPR_ERROR, "No event engine could be initialized from %s", s); + gpr_log(GPR_ERROR, "No event engine could be initialized from %s", + value.get()); abort(); } - gpr_free(s); } void grpc_event_engine_shutdown(void) { diff --git a/src/core/lib/iomgr/ev_posix.h b/src/core/lib/iomgr/ev_posix.h index 0ca3a6f82fd..30bb5e40faf 100644 --- a/src/core/lib/iomgr/ev_posix.h +++ b/src/core/lib/iomgr/ev_posix.h @@ -24,11 +24,14 @@ #include #include "src/core/lib/debug/trace.h" +#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/iomgr/pollset_set.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" +GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_poll_strategy); + extern grpc_core::TraceFlag grpc_fd_trace; /* Disabled by default */ extern grpc_core::TraceFlag grpc_polling_trace; /* Disabled by default */ diff --git a/src/core/lib/iomgr/fork_posix.cc b/src/core/lib/iomgr/fork_posix.cc index 7f8fb7e828b..629b08162fb 100644 --- a/src/core/lib/iomgr/fork_posix.cc +++ b/src/core/lib/iomgr/fork_posix.cc @@ -28,7 +28,6 @@ #include #include -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gprpp/fork.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/ev_posix.h" diff --git a/src/core/lib/iomgr/iomgr.cc b/src/core/lib/iomgr/iomgr.cc index fd011788a06..b86aa6f2d76 100644 --- a/src/core/lib/iomgr/iomgr.cc +++ b/src/core/lib/iomgr/iomgr.cc @@ -42,7 +42,8 @@ #include "src/core/lib/iomgr/timer_manager.h" GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_abort_on_leaks, false, - "Abort when leak is found"); + "A debugging aid to cause a call to abort() when " + "gRPC objects are leaked past grpc_shutdown()"); static gpr_mu g_mu; static gpr_cv g_rcv; diff --git a/src/core/lib/profiling/basic_timers.cc b/src/core/lib/profiling/basic_timers.cc index b19ad9fc23d..37689fe89d1 100644 --- a/src/core/lib/profiling/basic_timers.cc +++ b/src/core/lib/profiling/basic_timers.cc @@ -31,7 +31,8 @@ #include #include -#include "src/core/lib/gpr/env.h" +#include "src/core/lib/gprpp/global_config.h" +#include "src/core/lib/profiling/timers.h" typedef enum { BEGIN = '{', END = '}', MARK = '.' } marker_type; @@ -74,11 +75,16 @@ static __thread int g_thread_id; static int g_next_thread_id; static int g_writing_enabled = 1; +GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_latency_trace, "latency_trace.txt", + "Output file name for latency trace") + static const char* output_filename() { if (output_filename_or_null == NULL) { - output_filename_or_null = gpr_getenv("LATENCY_TRACE"); - if (output_filename_or_null == NULL || - strlen(output_filename_or_null) == 0) { + grpc_core::UniquePtr value = + GPR_GLOBAL_CONFIG_GET(grpc_latency_trace); + if (strlen(value.get()) > 0) { + output_filename_or_null = value.release(); + } else { output_filename_or_null = "latency_trace.txt"; } } diff --git a/src/core/lib/security/security_connector/load_system_roots_linux.cc b/src/core/lib/security/security_connector/load_system_roots_linux.cc index 924fa8a3e26..82d5bf6bcdd 100644 --- a/src/core/lib/security/security_connector/load_system_roots_linux.cc +++ b/src/core/lib/security/security_connector/load_system_roots_linux.cc @@ -38,12 +38,15 @@ #include #include -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/iomgr/load_file.h" +GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_system_ssl_roots_dir, "", + "Custom directory to SSL Roots"); + namespace grpc_core { namespace { @@ -139,10 +142,9 @@ grpc_slice CreateRootCertsBundle(const char* certs_directory) { grpc_slice LoadSystemRootCerts() { grpc_slice result = grpc_empty_slice(); // Prioritize user-specified custom directory if flag is set. - char* custom_dir = gpr_getenv("GRPC_SYSTEM_SSL_ROOTS_DIR"); - if (custom_dir != nullptr) { - result = CreateRootCertsBundle(custom_dir); - gpr_free(custom_dir); + UniquePtr custom_dir = GPR_GLOBAL_CONFIG_GET(grpc_system_ssl_roots_dir); + if (strlen(custom_dir.get()) > 0) { + result = CreateRootCertsBundle(custom_dir.get()); } // If the custom directory is empty/invalid/not specified, fallback to // distribution-specific directory. diff --git a/src/core/lib/security/security_connector/security_connector.cc b/src/core/lib/security/security_connector/security_connector.cc index 96a19605466..47c0ad5aa3d 100644 --- a/src/core/lib/security/security_connector/security_connector.cc +++ b/src/core/lib/security/security_connector/security_connector.cc @@ -28,7 +28,6 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/load_file.h" diff --git a/src/core/lib/security/security_connector/ssl_utils.cc b/src/core/lib/security/security_connector/ssl_utils.cc index 1eefff6fe24..cb0d5437988 100644 --- a/src/core/lib/security/security_connector/ssl_utils.cc +++ b/src/core/lib/security/security_connector/ssl_utils.cc @@ -27,7 +27,6 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/global_config.h" @@ -46,7 +45,13 @@ static const char* installed_roots_path = INSTALL_PREFIX "/share/grpc/roots.pem"; #endif -/** Environment variable used as a flag to enable/disable loading system root +/** Config variable that points to the default SSL roots file. This file + must be a PEM encoded file with all the roots such as the one that can be + downloaded from https://pki.google.com/roots.pem. */ +GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_default_ssl_roots_file_path, "", + "Path to the default SSL roots file."); + +/** Config variable used as a flag to enable/disable loading system root certificates from the OS trust store. */ GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_not_use_system_ssl_roots, false, "Disable loading system root certificates."); @@ -65,20 +70,22 @@ void grpc_set_ssl_roots_override_callback(grpc_ssl_roots_override_callback cb) { /* -- Cipher suites. -- */ -/* Defines the cipher suites that we accept by default. All these cipher suites - are compliant with HTTP2. */ -#define GRPC_SSL_CIPHER_SUITES \ - "ECDHE-ECDSA-AES128-GCM-SHA256:" \ - "ECDHE-ECDSA-AES256-GCM-SHA384:" \ - "ECDHE-RSA-AES128-GCM-SHA256:" \ - "ECDHE-RSA-AES256-GCM-SHA384" - static gpr_once cipher_suites_once = GPR_ONCE_INIT; static const char* cipher_suites = nullptr; +// All cipher suites for default are compliant with HTTP2. +GPR_GLOBAL_CONFIG_DEFINE_STRING( + grpc_ssl_cipher_suites, + "ECDHE-ECDSA-AES128-GCM-SHA256:" + "ECDHE-ECDSA-AES256-GCM-SHA384:" + "ECDHE-RSA-AES128-GCM-SHA256:" + "ECDHE-RSA-AES256-GCM-SHA384", + "A colon separated list of cipher suites to use with OpenSSL") + static void init_cipher_suites(void) { - char* overridden = gpr_getenv("GRPC_SSL_CIPHER_SUITES"); - cipher_suites = overridden != nullptr ? overridden : GRPC_SSL_CIPHER_SUITES; + grpc_core::UniquePtr value = + GPR_GLOBAL_CONFIG_GET(grpc_ssl_cipher_suites); + cipher_suites = value.release(); } /* --- Util --- */ @@ -430,13 +437,12 @@ grpc_slice DefaultSslRootStore::ComputePemRootCerts() { grpc_slice result = grpc_empty_slice(); const bool not_use_system_roots = GPR_GLOBAL_CONFIG_GET(grpc_not_use_system_ssl_roots); - // First try to load the roots from the environment. - char* default_root_certs_path = - gpr_getenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR); - if (default_root_certs_path != nullptr) { - GRPC_LOG_IF_ERROR("load_file", - grpc_load_file(default_root_certs_path, 1, &result)); - gpr_free(default_root_certs_path); + // First try to load the roots from the configuration. + UniquePtr default_root_certs_path = + GPR_GLOBAL_CONFIG_GET(grpc_default_ssl_roots_file_path); + if (strlen(default_root_certs_path.get()) > 0) { + GRPC_LOG_IF_ERROR( + "load_file", grpc_load_file(default_root_certs_path.get(), 1, &result)); } // Try overridden roots if needed. grpc_ssl_roots_override_result ovrd_res = GRPC_SSL_ROOTS_OVERRIDE_FAIL; diff --git a/src/core/lib/security/security_connector/ssl_utils.h b/src/core/lib/security/security_connector/ssl_utils.h index 080e277f944..1765a344c2a 100644 --- a/src/core/lib/security/security_connector/ssl_utils.h +++ b/src/core/lib/security/security_connector/ssl_utils.h @@ -26,6 +26,7 @@ #include #include +#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/security/security_connector/security_connector.h" @@ -33,7 +34,10 @@ #include "src/core/tsi/transport_security.h" #include "src/core/tsi/transport_security_interface.h" -/* --- Util. --- */ +GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_default_ssl_roots_file_path); +GPR_GLOBAL_CONFIG_DECLARE_BOOL(grpc_not_use_system_ssl_roots); + +/* --- Util --- */ /* --- URL schemes. --- */ #define GRPC_SSL_URL_SCHEME "https" diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index 1ed1a66b184..2a6d307ddab 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -154,7 +154,7 @@ void grpc_init(void) { * at the appropriate time */ grpc_register_security_filters(); register_builtin_channel_init(); - grpc_tracer_init("GRPC_TRACE"); + grpc_tracer_init(); /* no more changes to channel init pipelines */ grpc_channel_init_finalize(); grpc_iomgr_start(); diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m index 7557367ed4a..e6522d7a27e 100644 --- a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m @@ -61,8 +61,7 @@ NSBundle *resourceBundle = [NSBundle bundleWithURL:[[bundle resourceURL] URLByAppendingPathComponent:resourceBundlePath]]; NSString *path = [resourceBundle pathForResource:rootsPEM ofType:@"pem"]; - setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, - [path cStringUsingEncoding:NSUTF8StringEncoding], 1); + setenv("GRPC_DEFAULT_SSL_ROOTS_FILE_PATH", [path cStringUsingEncoding:NSUTF8StringEncoding], 1); }); NSData *rootsASCII = nil; diff --git a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm index 2fac1be3d0e..0d081e4a410 100644 --- a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm +++ b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm @@ -37,11 +37,11 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -172,7 +172,7 @@ static char *roots_filename; GPR_ASSERT(roots_file != NULL); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); grpc_init(); diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 77753d7766c..2619ccf9740 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -385,6 +385,7 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', + 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/census/grpc_context.cc', diff --git a/test/core/bad_connection/close_fd_test.cc b/test/core/bad_connection/close_fd_test.cc index e8f297e77ea..78a1a5cc9a4 100644 --- a/test/core/bad_connection/close_fd_test.cc +++ b/test/core/bad_connection/close_fd_test.cc @@ -39,7 +39,6 @@ #include #include #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/endpoint_pair.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/completion_queue.h" diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc index 73d251eff4a..8dd55f64944 100644 --- a/test/core/bad_ssl/bad_ssl_test.cc +++ b/test/core/bad_ssl/bad_ssl_test.cc @@ -25,9 +25,9 @@ #include #include -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" @@ -133,7 +133,7 @@ int main(int argc, char** argv) { strcpy(root, "."); } if (argc == 2) { - gpr_setenv("GRPC_DEFAULT_SSL_ROOTS_FILE_PATH", argv[1]); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, argv[1]); } /* figure out our test name */ tmp = lunder - 1; diff --git a/test/core/client_channel/resolvers/dns_resolver_test.cc b/test/core/client_channel/resolvers/dns_resolver_test.cc index ed3b4e66472..129866b7d7f 100644 --- a/test/core/client_channel/resolvers/dns_resolver_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_test.cc @@ -21,8 +21,8 @@ #include #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" +#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/combiner.h" #include "test/core/util/test_config.h" @@ -78,13 +78,13 @@ int main(int argc, char** argv) { test_succeeds(dns, "dns:10.2.1.1:1234"); test_succeeds(dns, "dns:www.google.com"); test_succeeds(dns, "dns:///www.google.com"); - char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER"); - if (resolver_env != nullptr && gpr_stricmp(resolver_env, "native") == 0) { + grpc_core::UniquePtr resolver = + GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); + if (gpr_stricmp(resolver.get(), "native") == 0) { test_fails(dns, "dns://8.8.8.8/8.8.8.8:8888"); } else { test_succeeds(dns, "dns://8.8.8.8/8.8.8.8:8888"); } - gpr_free(resolver_env); { grpc_core::ExecCtx exec_ctx; GRPC_COMBINER_UNREF(g_combiner, "test"); diff --git a/test/core/end2end/fixtures/h2_full+trace.cc b/test/core/end2end/fixtures/h2_full+trace.cc index ce8f6bf13a5..b8dbe261183 100644 --- a/test/core/end2end/fixtures/h2_full+trace.cc +++ b/test/core/end2end/fixtures/h2_full+trace.cc @@ -33,7 +33,7 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/env.h" +#include "src/core/lib/debug/trace.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" @@ -105,7 +105,7 @@ int main(int argc, char** argv) { /* force tracing on, with a value to force many code paths in trace.c to be taken */ - gpr_setenv("GRPC_TRACE", "doesnt-exist,http,all"); + GPR_GLOBAL_CONFIG_SET(grpc_trace, "doesnt-exist,http,all"); #ifdef GRPC_POSIX_SOCKET g_fixture_slowdown_factor = isatty(STDOUT_FILENO) ? 10 : 1; diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.cc b/test/core/end2end/fixtures/h2_sockpair+trace.cc index 4494d5c4746..7954bc1ddfc 100644 --- a/test/core/end2end/fixtures/h2_sockpair+trace.cc +++ b/test/core/end2end/fixtures/h2_sockpair+trace.cc @@ -35,7 +35,7 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/env.h" +#include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/endpoint_pair.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/surface/channel.h" @@ -133,7 +133,8 @@ int main(int argc, char** argv) { /* force tracing on, with a value to force many code paths in trace.c to be taken */ - gpr_setenv("GRPC_TRACE", "doesnt-exist,http,all"); + GPR_GLOBAL_CONFIG_SET(grpc_trace, "doesnt-exist,http,all"); + #ifdef GRPC_POSIX_SOCKET g_fixture_slowdown_factor = isatty(STDOUT_FILENO) ? 10 : 1; #else diff --git a/test/core/end2end/fixtures/h2_spiffe.cc b/test/core/end2end/fixtures/h2_spiffe.cc index 9ab796ea429..cdf091bac10 100644 --- a/test/core/end2end/fixtures/h2_spiffe.cc +++ b/test/core/end2end/fixtures/h2_spiffe.cc @@ -35,6 +35,7 @@ #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h" +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -277,7 +278,7 @@ int main(int argc, char** argv) { GPR_ASSERT(roots_file != nullptr); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); grpc_init(); for (size_t ind = 0; ind < sizeof(configs) / sizeof(*configs); ind++) { grpc_end2end_tests(argc, argv, configs[ind]); diff --git a/test/core/end2end/fixtures/h2_ssl.cc b/test/core/end2end/fixtures/h2_ssl.cc index 1fcd785e251..3fc9bc7f329 100644 --- a/test/core/end2end/fixtures/h2_ssl.cc +++ b/test/core/end2end/fixtures/h2_ssl.cc @@ -25,11 +25,11 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -167,7 +167,7 @@ int main(int argc, char** argv) { GPR_ASSERT(roots_file != nullptr); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); grpc_init(); diff --git a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc index 04d876ce3cd..1d54a431364 100644 --- a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc +++ b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc @@ -25,11 +25,11 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -190,7 +190,7 @@ int main(int argc, char** argv) { GPR_ASSERT(roots_file != nullptr); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); grpc_init(); diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.cc b/test/core/end2end/fixtures/h2_ssl_proxy.cc index f1858079426..d5f695b1575 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.cc +++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc @@ -25,11 +25,11 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/end2end/fixtures/proxy.h" #include "test/core/util/port.h" @@ -208,7 +208,7 @@ int main(int argc, char** argv) { GPR_ASSERT(roots_file != nullptr); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); grpc_init(); diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc index cb0800bf899..e9285778a2d 100644 --- a/test/core/end2end/h2_ssl_cert_test.cc +++ b/test/core/end2end/h2_ssl_cert_test.cc @@ -25,11 +25,11 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" @@ -366,7 +366,7 @@ int main(int argc, char** argv) { GPR_ASSERT(roots_file != nullptr); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); grpc_init(); ::testing::InitGoogleTest(&argc, argv); diff --git a/test/core/end2end/h2_ssl_session_reuse_test.cc b/test/core/end2end/h2_ssl_session_reuse_test.cc index fbcdcc4b3f3..b2d0a5e1133 100644 --- a/test/core/end2end/h2_ssl_session_reuse_test.cc +++ b/test/core/end2end/h2_ssl_session_reuse_test.cc @@ -25,11 +25,11 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" @@ -265,7 +265,7 @@ int main(int argc, char** argv) { GPR_ASSERT(roots_file != nullptr); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); grpc_init(); ::testing::InitGoogleTest(&argc, argv); diff --git a/test/core/end2end/tests/keepalive_timeout.cc b/test/core/end2end/tests/keepalive_timeout.cc index 3c33f0419ad..1750f6fe5ee 100644 --- a/test/core/end2end/tests/keepalive_timeout.cc +++ b/test/core/end2end/tests/keepalive_timeout.cc @@ -28,11 +28,15 @@ #include "src/core/ext/transport/chttp2/transport/frame_ping.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/iomgr.h" #include "test/core/end2end/cq_verifier.h" +#ifdef GRPC_POSIX_SOCKET +#include "src/core/lib/iomgr/ev_posix.h" +#endif // GRPC_POSIX_SOCKET + static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -225,13 +229,13 @@ static void test_keepalive_timeout(grpc_end2end_test_config config) { * 200ms. In the success case, each ping ack should reset the keepalive timer so * that the keepalive ping is never sent. */ static void test_read_delays_keepalive(grpc_end2end_test_config config) { - char* poller = gpr_getenv("GRPC_POLL_STRATEGY"); +#ifdef GRPC_POSIX_SOCKET + grpc_core::UniquePtr poller = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); /* It is hard to get the timing right for the polling engine poll. */ - if (poller != nullptr && (0 == strcmp(poller, "poll"))) { - gpr_free(poller); + if ((0 == strcmp(poller.get(), "poll"))) { return; } - gpr_free(poller); +#endif // GRPC_POSIX_SOCKET const int kPingIntervalMS = 100; grpc_arg keepalive_arg_elems[3]; keepalive_arg_elems[0].type = GRPC_ARG_INTEGER; diff --git a/test/core/gpr/log_test.cc b/test/core/gpr/log_test.cc index f96257738b2..e320daa33a7 100644 --- a/test/core/gpr/log_test.cc +++ b/test/core/gpr/log_test.cc @@ -21,9 +21,14 @@ #include #include -#include "src/core/lib/gpr/env.h" +#include "src/core/lib/gprpp/global_config.h" #include "test/core/util/test_config.h" +// Config declaration is supposed to be located at log.h but +// log.h doesn't include global_config headers because it has to +// be a strict C so declaration statement gets to be here. +GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_verbosity); + static bool log_func_reached = false; static void test_callback(gpr_log_func_args* args) { @@ -67,7 +72,7 @@ int main(int argc, char** argv) { /* gpr_log_verbosity_init() will be effective only once, and only before * gpr_set_log_verbosity() is called */ - gpr_setenv("GRPC_VERBOSITY", "ERROR"); + GPR_GLOBAL_CONFIG_SET(grpc_verbosity, "ERROR"); gpr_log_verbosity_init(); test_log_function_reached(GPR_ERROR); @@ -75,7 +80,7 @@ int main(int argc, char** argv) { test_log_function_unreached(GPR_DEBUG); /* gpr_log_verbosity_init() should not be effective */ - gpr_setenv("GRPC_VERBOSITY", "DEBUG"); + GPR_GLOBAL_CONFIG_SET(grpc_verbosity, "DEBUG"); gpr_log_verbosity_init(); test_log_function_reached(GPR_ERROR); test_log_function_unreached(GPR_INFO); @@ -97,7 +102,7 @@ int main(int argc, char** argv) { test_log_function_unreached(GPR_DEBUG); /* gpr_log_verbosity_init() should not be effective */ - gpr_setenv("GRPC_VERBOSITY", "DEBUG"); + GPR_GLOBAL_CONFIG_SET(grpc_verbosity, "DEBUG"); gpr_log_verbosity_init(); test_log_function_reached(GPR_ERROR); test_log_function_unreached(GPR_INFO); diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc index 326b0e95e25..e7250c206d8 100644 --- a/test/core/http/httpscli_test.cc +++ b/test/core/http/httpscli_test.cc @@ -29,6 +29,7 @@ #include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/iomgr.h" +#include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" #include "test/core/util/test_config.h" @@ -184,7 +185,7 @@ int main(int argc, char** argv) { /* Set the environment variable for the SSL certificate file */ char* pem_file; gpr_asprintf(&pem_file, "%s/src/core/tsi/test_creds/ca.pem", root); - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, pem_file); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, pem_file); gpr_free(pem_file); /* start the server */ diff --git a/test/core/iomgr/resolve_address_posix_test.cc b/test/core/iomgr/resolve_address_posix_test.cc index 826c7e1fafa..112d7c2791b 100644 --- a/test/core/iomgr/resolve_address_posix_test.cc +++ b/test/core/iomgr/resolve_address_posix_test.cc @@ -29,6 +29,7 @@ #include #include +#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" @@ -224,15 +225,16 @@ int main(int argc, char** argv) { // --resolver will always be the first one, so only parse the first argument // (other arguments may be unknown to cl) gpr_cmdline_parse(cl, argc > 2 ? 2 : argc, argv); - const char* cur_resolver = gpr_getenv("GRPC_DNS_RESOLVER"); - if (cur_resolver != nullptr && strlen(cur_resolver) != 0) { + grpc_core::UniquePtr resolver = + GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); + if (strlen(resolver.get()) != 0) { gpr_log(GPR_INFO, "Warning: overriding resolver setting of %s", - cur_resolver); + resolver.get()); } if (gpr_stricmp(resolver_type, "native") == 0) { - gpr_setenv("GRPC_DNS_RESOLVER", "native"); + GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "native"); } else if (gpr_stricmp(resolver_type, "ares") == 0) { - gpr_setenv("GRPC_DNS_RESOLVER", "ares"); + GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "ares"); } else { gpr_log(GPR_ERROR, "--resolver_type was not set to ares or native"); abort(); @@ -246,12 +248,12 @@ int main(int argc, char** argv) { // c-ares resolver doesn't support UDS (ability for native DNS resolver // to handle this is only expected to be used by servers, which // unconditionally use the native DNS resolver). - char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER"); - if (resolver_env == nullptr || gpr_stricmp(resolver_env, "native") == 0) { + grpc_core::UniquePtr resolver = + GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); + if (gpr_stricmp(resolver.get(), "native") == 0) { test_unix_socket(); test_unix_socket_path_name_too_long(); } - gpr_free(resolver_env); } gpr_cmdline_destroy(cl); diff --git a/test/core/iomgr/resolve_address_test.cc b/test/core/iomgr/resolve_address_test.cc index 1f0c0e3e835..cbc03485d7f 100644 --- a/test/core/iomgr/resolve_address_test.cc +++ b/test/core/iomgr/resolve_address_test.cc @@ -27,7 +27,7 @@ #include -#include "src/core/lib/gpr/env.h" +#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr.h" @@ -347,16 +347,17 @@ int main(int argc, char** argv) { // --resolver will always be the first one, so only parse the first argument // (other arguments may be unknown to cl) gpr_cmdline_parse(cl, argc > 2 ? 2 : argc, argv); - const char* cur_resolver = gpr_getenv("GRPC_DNS_RESOLVER"); - if (cur_resolver != nullptr && strlen(cur_resolver) != 0) { + grpc_core::UniquePtr resolver = + GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); + if (strlen(resolver.get()) != 0) { gpr_log(GPR_INFO, "Warning: overriding resolver setting of %s", - cur_resolver); + resolver.get()); } if (gpr_stricmp(resolver_type, "native") == 0) { - gpr_setenv("GRPC_DNS_RESOLVER", "native"); + GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "native"); } else if (gpr_stricmp(resolver_type, "ares") == 0) { #ifndef GRPC_UV - gpr_setenv("GRPC_DNS_RESOLVER", "ares"); + GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "ares"); #endif } else { gpr_log(GPR_ERROR, "--resolver_type was not set to ares or native"); diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc index 11cfc8cc905..141346bca94 100644 --- a/test/core/security/credentials_test.cc +++ b/test/core/security/credentials_test.cc @@ -1161,7 +1161,7 @@ static void test_get_well_known_google_credentials_file_path(void) { GPR_ASSERT(path != nullptr); gpr_free(path); #if defined(GPR_POSIX_ENV) || defined(GPR_LINUX_ENV) - unsetenv("HOME"); + gpr_unsetenv("HOME"); path = grpc_get_well_known_google_credentials_file_path(); GPR_ASSERT(path == nullptr); gpr_setenv("HOME", home); diff --git a/test/core/security/security_connector_test.cc b/test/core/security/security_connector_test.cc index 496f064439c..c888c90c646 100644 --- a/test/core/security/security_connector_test.cc +++ b/test/core/security/security_connector_test.cc @@ -24,7 +24,6 @@ #include #include -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" @@ -394,7 +393,7 @@ static void test_default_ssl_roots(void) { /* First let's get the root through the override: set the env to an invalid value. */ - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, ""); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, ""); grpc_set_ssl_roots_override_callback(override_roots_success); grpc_slice roots = grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting(); @@ -405,7 +404,8 @@ static void test_default_ssl_roots(void) { /* Now let's set the env var: We should get the contents pointed value instead. */ - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_env_var_file_path); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, + roots_env_var_file_path); roots = grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting(); roots_contents = grpc_slice_to_c_string(roots); grpc_slice_unref(roots); @@ -414,7 +414,7 @@ static void test_default_ssl_roots(void) { /* Now reset the env var. We should fall back to the value overridden using the api. */ - gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, ""); + GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, ""); roots = grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting(); roots_contents = grpc_slice_to_c_string(roots); grpc_slice_unref(roots); @@ -423,7 +423,7 @@ static void test_default_ssl_roots(void) { /* Now setup a permanent failure for the overridden roots and we should get an empty slice. */ - gpr_setenv("GRPC_NOT_USE_SYSTEM_SSL_ROOTS", "true"); + GPR_GLOBAL_CONFIG_SET(grpc_not_use_system_ssl_roots, true); grpc_set_ssl_roots_override_callback(override_roots_permanent_failure); roots = grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting(); GPR_ASSERT(GRPC_SLICE_IS_EMPTY(roots)); diff --git a/test/core/util/test_config.cc b/test/core/util/test_config.cc index 476e424b1eb..5b248a01daa 100644 --- a/test/core/util/test_config.cc +++ b/test/core/util/test_config.cc @@ -28,7 +28,6 @@ #include #include -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/surface/init.h" diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 97275db6276..6ca0edf123e 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -33,7 +33,6 @@ #include #include "src/core/ext/filters/client_channel/backup_poller.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/tls.h" #include "src/core/lib/iomgr/port.h" #include "src/proto/grpc/health/v1/health.grpc.pb.h" @@ -44,6 +43,10 @@ #include "test/cpp/util/string_ref_helper.h" #include "test/cpp/util/test_credentials_provider.h" +#ifdef GRPC_POSIX_SOCKET +#include "src/core/lib/iomgr/ev_posix.h" +#endif // GRPC_POSIX_SOCKET + #include using grpc::testing::EchoRequest; @@ -359,13 +362,14 @@ TEST_P(AsyncEnd2endTest, ReconnectChannel) { return; } int poller_slowdown_factor = 1; +#ifdef GRPC_POSIX_SOCKET // It needs 2 pollset_works to reconnect the channel with polling engine // "poll" - char* s = gpr_getenv("GRPC_POLL_STRATEGY"); - if (s != nullptr && 0 == strcmp(s, "poll")) { + grpc_core::UniquePtr poller = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); + if (0 == strcmp(poller.get(), "poll")) { poller_slowdown_factor = 2; } - gpr_free(s); +#endif // GRPC_POSIX_SOCKET ResetStub(); SendRpc(1); server_->Shutdown(); diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index bf3b374adc0..c027e5954ec 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -35,7 +35,6 @@ #include #include "src/core/ext/filters/client_channel/backup_poller.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" @@ -47,6 +46,10 @@ #include "test/cpp/util/string_ref_helper.h" #include "test/cpp/util/test_credentials_provider.h" +#ifdef GRPC_POSIX_SOCKET +#include "src/core/lib/iomgr/ev_posix.h" +#endif // GRPC_POSIX_SOCKET + #include using grpc::testing::EchoRequest; @@ -809,11 +812,12 @@ TEST_P(End2endTest, ReconnectChannel) { int poller_slowdown_factor = 1; // It needs 2 pollset_works to reconnect the channel with polling engine // "poll" - char* s = gpr_getenv("GRPC_POLL_STRATEGY"); - if (s != nullptr && 0 == strcmp(s, "poll")) { +#ifdef GRPC_POSIX_SOCKET + grpc_core::UniquePtr poller = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); + if (0 == strcmp(poller.get(), "poll")) { poller_slowdown_factor = 2; } - gpr_free(s); +#endif // GRPC_POSIX_SOCKET ResetStub(); SendRpc(stub_.get(), 1, false); RestartServer(std::shared_ptr()); diff --git a/test/cpp/naming/address_sorting_test.cc b/test/cpp/naming/address_sorting_test.cc index bd685632c33..affc75bc634 100644 --- a/test/cpp/naming/address_sorting_test.cc +++ b/test/cpp/naming/address_sorting_test.cc @@ -36,10 +36,10 @@ #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/client_channel/resolver.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" +#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/combiner.h" @@ -829,13 +829,13 @@ TEST_F(AddressSortingTest, TestSorterKnowsIpv6LoopbackIsAvailable) { } // namespace int main(int argc, char** argv) { - char* resolver = gpr_getenv("GRPC_DNS_RESOLVER"); - if (resolver == nullptr || strlen(resolver) == 0) { - gpr_setenv("GRPC_DNS_RESOLVER", "ares"); - } else if (strcmp("ares", resolver)) { - gpr_log(GPR_INFO, "GRPC_DNS_RESOLVER != ares: %s.", resolver); + grpc_core::UniquePtr resolver = + GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); + if (strlen(resolver.get()) == 0) { + GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "ares"); + } else if (strcmp("ares", resolver.get())) { + gpr_log(GPR_INFO, "GRPC_DNS_RESOLVER != ares: %s.", resolver.get()); } - gpr_free(resolver); grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); auto result = RUN_ALL_TESTS(); diff --git a/test/cpp/naming/cancel_ares_query_test.cc b/test/cpp/naming/cancel_ares_query_test.cc index 674e72fdc52..667011ae291 100644 --- a/test/cpp/naming/cancel_ares_query_test.cc +++ b/test/cpp/naming/cancel_ares_query_test.cc @@ -29,10 +29,10 @@ #include #include "include/grpc/support/string_util.h" #include "src/core/ext/filters/client_channel/resolver.h" +#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/stats.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/orphanable.h" @@ -374,7 +374,7 @@ TEST( int main(int argc, char** argv) { grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); - gpr_setenv("GRPC_DNS_RESOLVER", "ares"); + GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "ares"); // Sanity check the time that it takes to run the test // including the teardown time (the teardown // part of the test involves cancelling the DNS query, diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index 93a92f68a6d..6cea8143907 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -46,7 +46,6 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/orphanable.h" diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 0365f284573..2c20d69e6e3 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -951,6 +951,8 @@ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallba src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ +src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ +src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h \ src/core/ext/filters/client_channel/resolver/dns/native/README.md \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index a73abacdd22..8341971f51a 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -9271,7 +9271,8 @@ "deps": [ "gpr", "grpc_base", - "grpc_client_channel" + "grpc_client_channel", + "grpc_resolver_dns_selection" ], "headers": [ "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h", @@ -9301,7 +9302,8 @@ "deps": [ "gpr", "grpc_base", - "grpc_client_channel" + "grpc_client_channel", + "grpc_resolver_dns_selection" ], "headers": [], "is_filegroup": true, @@ -9313,6 +9315,24 @@ "third_party": false, "type": "filegroup" }, + { + "deps": [ + "gpr", + "grpc_base" + ], + "headers": [ + "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" + ], + "is_filegroup": true, + "language": "c", + "name": "grpc_resolver_dns_selection", + "src": [ + "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc", + "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" + ], + "third_party": false, + "type": "filegroup" + }, { "deps": [ "gpr", diff --git a/tools/run_tests/run_microbenchmark.py b/tools/run_tests/run_microbenchmark.py index 4e4d05cdcd4..a7fde3007af 100755 --- a/tools/run_tests/run_microbenchmark.py +++ b/tools/run_tests/run_microbenchmark.py @@ -96,7 +96,7 @@ def collect_latency(bm_name, args): '--benchmark_filter=^%s$' % line, '--benchmark_min_time=0.05' ], - environ={'LATENCY_TRACE': '%s.trace' % fnize(line)}, + environ={'GRPC_LATENCY_TRACE': '%s.trace' % fnize(line)}, shortname='profile-%s' % fnize(line))) profile_analysis.append( jobset.JobSpec( diff --git a/tools/run_tests/sanity/core_banned_functions.py b/tools/run_tests/sanity/core_banned_functions.py index 549ae14f5ab..ce9ff0dae21 100755 --- a/tools/run_tests/sanity/core_banned_functions.py +++ b/tools/run_tests/sanity/core_banned_functions.py @@ -45,10 +45,6 @@ BANNED_EXCEPT = { 'grpc_closure_sched(': ['src/core/lib/iomgr/closure.cc'], 'grpc_closure_run(': ['src/core/lib/iomgr/closure.cc'], 'grpc_closure_list_sched(': ['src/core/lib/iomgr/closure.cc'], - 'gpr_getenv_silent(': [ - 'src/core/lib/gpr/log.cc', 'src/core/lib/gpr/env_linux.cc', - 'src/core/lib/gpr/env_posix.cc', 'src/core/lib/gpr/env_windows.cc' - ], } errors = 0 From 0f21350b85c5887b570ab2553dbf3fcd19f57a63 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Mon, 20 May 2019 16:34:42 -0700 Subject: [PATCH 0263/1555] Gallantly fix typo --- src/core/ext/transport/chttp2/transport/chttp2_transport.cc | 2 +- src/core/ext/transport/chttp2/transport/internal.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 4a04b9f1939..48c3d002bbd 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -2262,7 +2262,7 @@ void grpc_chttp2_mark_stream_closed(grpc_chttp2_transport* t, if (closed_read) { for (int i = 0; i < 2; i++) { if (s->published_metadata[i] == GRPC_METADATA_NOT_PUBLISHED) { - s->published_metadata[i] = GPRC_METADATA_PUBLISHED_AT_CLOSE; + s->published_metadata[i] = GRPC_METADATA_PUBLISHED_AT_CLOSE; } } grpc_chttp2_maybe_complete_recv_initial_metadata(t, s); diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 0322dc72837..4ab46f9808b 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -499,7 +499,7 @@ typedef enum { GRPC_METADATA_NOT_PUBLISHED, GRPC_METADATA_SYNTHESIZED_FROM_FAKE, GRPC_METADATA_PUBLISHED_FROM_WIRE, - GPRC_METADATA_PUBLISHED_AT_CLOSE + GRPC_METADATA_PUBLISHED_AT_CLOSE } grpc_published_metadata_method; struct grpc_chttp2_stream { From de94662bc1e3bbb2cc37c84650faf313d1bde34b Mon Sep 17 00:00:00 2001 From: Srini Polavarapu Date: Mon, 20 May 2019 17:34:11 -0700 Subject: [PATCH 0264/1555] version bump to v1.21.0 --- BUILD | 2 +- build.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index 2cffca4ffc2..bf128416cf9 100644 --- a/BUILD +++ b/BUILD @@ -78,7 +78,7 @@ g_stands_for = "gandalf" core_version = "7.0.0" -version = "1.21.0-pre1" +version = "1.21.0" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index 25f80af37e2..39f55d49dd2 100644 --- a/build.yaml +++ b/build.yaml @@ -14,7 +14,7 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 7.0.0 g_stands_for: gandalf - version: 1.21.0-pre1 + version: 1.21.0 filegroups: - name: alts_proto headers: From 535d0b150496f44544b3606f01636185ed19599c Mon Sep 17 00:00:00 2001 From: Srini Polavarapu Date: Mon, 20 May 2019 17:36:31 -0700 Subject: [PATCH 0265/1555] Regenerate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 6 +++--- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 8 ++++---- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 2 +- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 29 files changed, 35 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7457016c3cd..dd3b5e3eb5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.21.0-pre1") +set(PACKAGE_VERSION "1.21.0") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 99238d17428..67495f250be 100644 --- a/Makefile +++ b/Makefile @@ -460,8 +460,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.21.0-pre1 -CSHARP_VERSION = 1.21.0-pre1 +CPP_VERSION = 1.21.0 +CSHARP_VERSION = 1.21.0 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 3f42684be03..a8bc964f582 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,15 +23,15 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.21.0-pre1' - version = '0.0.8-pre1' + # version = '1.21.0' + version = '0.0.8' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.21.0-pre1' + grpc_version = '1.21.0' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 6d369950b09..76f8cb3c8be 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.21.0-pre1' + version = '1.21.0' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index af515fb529b..4a48257b215 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.21.0-pre1' + version = '1.21.0' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index df8fcae0b41..8db3c7dc179 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.21.0-pre1' + version = '1.21.0' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index 5458725ad76..83317db3b86 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.21.0-pre1' + version = '1.21.0' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index 7ced9e795f8..96af492c9d9 100644 --- a/package.xml +++ b/package.xml @@ -13,12 +13,12 @@ 2018-01-19 - 1.21.0RC1 - 1.21.0RC1 + 1.21.0 + 1.21.0 - beta - beta + stable + stable Apache 2.0 diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 8aeb99f2566..10801e5b713 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.21.0-pre1"; } +grpc::string Version() { return "1.21.0"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index 402d251446a..494ce145dac 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -38,6 +38,6 @@ namespace Grpc.Core /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.21.0-pre1"; + public const string CurrentVersion = "1.21.0"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index 67647c7a96c..fe280590fd6 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 1.21.0-pre1 + 1.21.0 3.7.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index b8e247f8613..6cfe3a1ab8e 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=1.21.0-pre1 +set VERSION=1.21.0 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index d7db86900c7..77d6d4842eb 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.21.0-pre1' + v = '1.21.0' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index b011dd53275..4686dc2d1b7 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.0-pre1" +#define GRPC_OBJC_VERSION_STRING @"1.21.0" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 28b45771ace..30f9ad18021 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.0-pre1" +#define GRPC_OBJC_VERSION_STRING @"1.21.0" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 7d6f86c9bfe..33adae484ea 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.21.0RC1" +#define PHP_GRPC_VERSION "1.21.0" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index 3a9cfc7a5e9..2b68fd5ff04 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.21.0rc1""" +__version__ = """1.21.0""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index d8434992dd5..cba5f3c0ebd 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.21.0rc1' +VERSION = '1.21.0' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index cbe46b76837..29a7523e926 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.21.0rc1' +VERSION = '1.21.0' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index cfa296588e8..80257d78a5d 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.21.0rc1' +VERSION = '1.21.0' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 54261c77f1d..bf61f4576a9 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.21.0rc1' +VERSION = '1.21.0' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index 9a5e728adfb..850704d2f99 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.21.0rc1' +VERSION = '1.21.0' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 7cd0ffa30c1..2a6b1c4b65a 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.21.0rc1' +VERSION = '1.21.0' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index 1a5e9f5385e..73cbe3913f6 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.21.0rc1' +VERSION = '1.21.0' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 30c4b3adae0..272a05310d6 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.21.0.pre1' + VERSION = '1.21.0' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index 19c79e4f854..3f1c59e3592 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.21.0.pre1' + VERSION = '1.21.0' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index a91af1be0d2..5577597ef5d 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.21.0rc1' +VERSION = '1.21.0' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 0a399e0d1d7..ac397ab8202 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.0-pre1 +PROJECT_NUMBER = 1.21.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index e314e7e969e..e0ffeff6650 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.0-pre1 +PROJECT_NUMBER = 1.21.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From 12ffbb8a83182d3e76eb3f386ba9b99546779bcd Mon Sep 17 00:00:00 2001 From: kwasimensah Date: Tue, 21 May 2019 01:27:59 -0400 Subject: [PATCH 0266/1555] Add MessageLite type to grpc's config --- include/grpcpp/impl/codegen/config_protobuf.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/grpcpp/impl/codegen/config_protobuf.h b/include/grpcpp/impl/codegen/config_protobuf.h index 8c2e9e67927..ce28f855529 100644 --- a/include/grpcpp/impl/codegen/config_protobuf.h +++ b/include/grpcpp/impl/codegen/config_protobuf.h @@ -30,9 +30,11 @@ #ifdef GRPC_USE_PROTO_LITE #include #define GRPC_CUSTOM_MESSAGE ::google::protobuf::MessageLite +#define GRPC_CUSTOM_MESSAGELITE ::google::protobuf::MessageLite #else #include #define GRPC_CUSTOM_MESSAGE ::google::protobuf::Message +#define GRPC_CUSTOM_MESSAGELITE ::google::protobuf::MessageLite #endif #endif @@ -76,6 +78,7 @@ namespace grpc { namespace protobuf { typedef GRPC_CUSTOM_MESSAGE Message; +typedef GRPC_CUSTOM_MESSAGE MessageLite; typedef GRPC_CUSTOM_PROTOBUF_INT64 int64; typedef GRPC_CUSTOM_DESCRIPTOR Descriptor; From 51a228002973be6b20a0ca9f133a5d581d3685bc Mon Sep 17 00:00:00 2001 From: kwasimensah Date: Tue, 21 May 2019 01:29:47 -0400 Subject: [PATCH 0267/1555] Add MessageLite overloads to proto serialization --- include/grpcpp/impl/codegen/proto_utils.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/grpcpp/impl/codegen/proto_utils.h b/include/grpcpp/impl/codegen/proto_utils.h index d9db6de05c0..9d3fcee0c98 100644 --- a/include/grpcpp/impl/codegen/proto_utils.h +++ b/include/grpcpp/impl/codegen/proto_utils.h @@ -42,7 +42,7 @@ extern CoreCodegenInterface* g_core_codegen_interface; // ProtoBufferWriter must be a subclass of ::protobuf::io::ZeroCopyOutputStream. template -Status GenericSerialize(const grpc::protobuf::Message& msg, ByteBuffer* bb, +Status GenericSerialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb, bool* own_buffer) { static_assert(std::is_base_of::value, @@ -68,7 +68,7 @@ Status GenericSerialize(const grpc::protobuf::Message& msg, ByteBuffer* bb, // BufferReader must be a subclass of ::protobuf::io::ZeroCopyInputStream. template -Status GenericDeserialize(ByteBuffer* buffer, grpc::protobuf::Message* msg) { +Status GenericDeserialize(ByteBuffer* buffer, grpc::protobuf::MessageLite* msg) { static_assert(std::is_base_of::value, "ProtoBufferReader must be a subclass of " @@ -103,14 +103,14 @@ Status GenericDeserialize(ByteBuffer* buffer, grpc::protobuf::Message* msg) { // be found in include/grpcpp/impl/codegen/serialization_traits.h. template class SerializationTraits::value>::type> { + grpc::protobuf::MessageLite, T>::value>::type> { public: - static Status Serialize(const grpc::protobuf::Message& msg, ByteBuffer* bb, + static Status Serialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb, bool* own_buffer) { return GenericSerialize(msg, bb, own_buffer); } - static Status Deserialize(ByteBuffer* buffer, grpc::protobuf::Message* msg) { + static Status Deserialize(ByteBuffer* buffer, grpc::protobuf::MessageLite* msg) { return GenericDeserialize(buffer, msg); } }; From 3ec0967c1ef11c8b159b7cd7993846c050686b9d Mon Sep 17 00:00:00 2001 From: kwasimensah Date: Tue, 21 May 2019 01:52:36 -0400 Subject: [PATCH 0268/1555] Fix typo for using MessageLite --- include/grpcpp/impl/codegen/config_protobuf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grpcpp/impl/codegen/config_protobuf.h b/include/grpcpp/impl/codegen/config_protobuf.h index ce28f855529..3c9ab3442af 100644 --- a/include/grpcpp/impl/codegen/config_protobuf.h +++ b/include/grpcpp/impl/codegen/config_protobuf.h @@ -78,7 +78,7 @@ namespace grpc { namespace protobuf { typedef GRPC_CUSTOM_MESSAGE Message; -typedef GRPC_CUSTOM_MESSAGE MessageLite; +typedef GRPC_CUSTOM_MESSAGELITE MessageLite; typedef GRPC_CUSTOM_PROTOBUF_INT64 int64; typedef GRPC_CUSTOM_DESCRIPTOR Descriptor; From cd0e02ae1c66c308debbea7476a0e40fedbaf5fd Mon Sep 17 00:00:00 2001 From: kwasimensah Date: Tue, 21 May 2019 02:29:00 -0400 Subject: [PATCH 0270/1555] Fixing formatting --- include/grpcpp/impl/codegen/proto_utils.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/include/grpcpp/impl/codegen/proto_utils.h b/include/grpcpp/impl/codegen/proto_utils.h index 9d3fcee0c98..f9a7d3c0b34 100644 --- a/include/grpcpp/impl/codegen/proto_utils.h +++ b/include/grpcpp/impl/codegen/proto_utils.h @@ -68,7 +68,8 @@ Status GenericSerialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb, // BufferReader must be a subclass of ::protobuf::io::ZeroCopyInputStream. template -Status GenericDeserialize(ByteBuffer* buffer, grpc::protobuf::MessageLite* msg) { +Status GenericDeserialize(ByteBuffer* buffer, + grpc::protobuf::MessageLite* msg) { static_assert(std::is_base_of::value, "ProtoBufferReader must be a subclass of " @@ -102,15 +103,17 @@ Status GenericDeserialize(ByteBuffer* buffer, grpc::protobuf::MessageLite* msg) // objects and grpc_byte_buffers. More information about SerializationTraits can // be found in include/grpcpp/impl/codegen/serialization_traits.h. template -class SerializationTraits::value>::type> { +class SerializationTraits< + T, typename std::enable_if< + std::is_base_of::value>::type> { public: - static Status Serialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb, - bool* own_buffer) { + static Status Serialize(const grpc::protobuf::MessageLite& msg, + ByteBuffer* bb, bool* own_buffer) { return GenericSerialize(msg, bb, own_buffer); } - static Status Deserialize(ByteBuffer* buffer, grpc::protobuf::MessageLite* msg) { + static Status Deserialize(ByteBuffer* buffer, + grpc::protobuf::MessageLite* msg) { return GenericDeserialize(buffer, msg); } }; From 118623d2933160891adfc0cb0c57cdf865758405 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 20 May 2019 14:51:16 -0700 Subject: [PATCH 0271/1555] Rename root certificate bundle in gRPC-C++ pod --- gRPC-C++.podspec | 4 ++-- templates/gRPC-C++.podspec.template | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index a8bc964f582..91a72e75191 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -24,7 +24,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized # version = '1.21.0' - version = '0.0.8' + version = '0.0.9' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' @@ -72,7 +72,7 @@ Pod::Spec.new do |s| s.default_subspecs = 'Interface', 'Implementation' # Certificates, to be able to establish TLS connections: - s.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } + s.resource_bundles = { 'gRPCCertificates-Cpp' => ['etc/roots.pem'] } s.header_mappings_dir = 'include/grpcpp' diff --git a/templates/gRPC-C++.podspec.template b/templates/gRPC-C++.podspec.template index 43cb6db66c6..40368e422d9 100644 --- a/templates/gRPC-C++.podspec.template +++ b/templates/gRPC-C++.podspec.template @@ -140,7 +140,7 @@ s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized # version = '${settings.version}' - version = '${modify_podspec_version_string('0.0.8', settings.version)}' + version = '${modify_podspec_version_string('0.0.9', settings.version)}' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' @@ -188,7 +188,7 @@ s.default_subspecs = 'Interface', 'Implementation' # Certificates, to be able to establish TLS connections: - s.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } + s.resource_bundles = { 'gRPCCertificates-Cpp' => ['etc/roots.pem'] } s.header_mappings_dir = 'include/grpcpp' From 8ab582eb84ec9499bac58202f132a624f8e06dac Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 21 May 2019 10:21:39 -0700 Subject: [PATCH 0272/1555] Bump up version to 1.21.1 --- CMakeLists.txt | 2 +- Makefile | 4 ++-- build.yaml | 2 +- gRPC-C++.podspec | 4 ++-- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 4 ++-- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 4 ++-- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/composer.json | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 31 files changed, 35 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd3b5e3eb5b..0b0c75c0811 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.21.0") +set(PACKAGE_VERSION "1.21.1") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 67495f250be..0d148ab3cd2 100644 --- a/Makefile +++ b/Makefile @@ -460,8 +460,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.21.0 -CSHARP_VERSION = 1.21.0 +CPP_VERSION = 1.21.1 +CSHARP_VERSION = 1.21.1 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/build.yaml b/build.yaml index 39f55d49dd2..0344ce18053 100644 --- a/build.yaml +++ b/build.yaml @@ -14,7 +14,7 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 7.0.0 g_stands_for: gandalf - version: 1.21.0 + version: 1.21.1 filegroups: - name: alts_proto headers: diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 91a72e75191..ca27e4f34f3 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,7 +23,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.21.0' + # version = '1.21.1' version = '0.0.9' s.version = version s.summary = 'gRPC C++ library' @@ -31,7 +31,7 @@ Pod::Spec.new do |s| s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.21.0' + grpc_version = '1.21.1' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 76f8cb3c8be..ca3225b3694 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.21.0' + version = '1.21.1' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 4a48257b215..2012515bbe9 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.21.0' + version = '1.21.1' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 8db3c7dc179..c4a9f2889e9 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.21.0' + version = '1.21.1' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index 83317db3b86..31a1c448aa1 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.21.0' + version = '1.21.1' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index 96af492c9d9..6bcbd807566 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2018-01-19 - 1.21.0 - 1.21.0 + 1.21.1 + 1.21.1 stable diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 10801e5b713..619220ce4e3 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.21.0"; } +grpc::string Version() { return "1.21.1"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index 494ce145dac..5cf75df63ab 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -33,11 +33,11 @@ namespace Grpc.Core /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "1.21.0.0"; + public const string CurrentAssemblyFileVersion = "1.21.1.0"; /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.21.0"; + public const string CurrentVersion = "1.21.1"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index fe280590fd6..c4c40fe0c66 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 1.21.0 + 1.21.1 3.7.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index 6cfe3a1ab8e..65deb40679c 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=1.21.0 +set VERSION=1.21.1 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 77d6d4842eb..8ac2dd7d303 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.21.0' + v = '1.21.1' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 4686dc2d1b7..e410f8da012 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.0" +#define GRPC_OBJC_VERSION_STRING @"1.21.1" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 30f9ad18021..95b112b156f 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.0" +#define GRPC_OBJC_VERSION_STRING @"1.21.1" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/composer.json b/src/php/composer.json index a9d0aebffca..3171442cc03 100644 --- a/src/php/composer.json +++ b/src/php/composer.json @@ -2,7 +2,7 @@ "name": "grpc/grpc-dev", "description": "gRPC library for PHP - for Developement use only", "license": "Apache-2.0", - "version": "1.21.0", + "version": "1.21.1", "require": { "php": ">=5.5.0", "google/protobuf": "^v3.3.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 33adae484ea..07a73698015 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.21.0" +#define PHP_GRPC_VERSION "1.21.1" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index 2b68fd5ff04..4624e467fd8 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.21.0""" +__version__ = """1.21.1""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index cba5f3c0ebd..2451ef4a538 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.21.0' +VERSION = '1.21.1' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index 29a7523e926..591b5bd8fc5 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.21.0' +VERSION = '1.21.1' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index 80257d78a5d..c11487af7e8 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.21.0' +VERSION = '1.21.1' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index bf61f4576a9..47628416c26 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.21.0' +VERSION = '1.21.1' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index 850704d2f99..713746a1598 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.21.0' +VERSION = '1.21.1' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 2a6b1c4b65a..3fe457f304c 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.21.0' +VERSION = '1.21.1' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index 73cbe3913f6..103b532f38f 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.21.0' +VERSION = '1.21.1' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 272a05310d6..1308aa4652e 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.21.0' + VERSION = '1.21.1' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index 3f1c59e3592..38f7129d139 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.21.0' + VERSION = '1.21.1' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 5577597ef5d..872f821c2f6 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.21.0' +VERSION = '1.21.1' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index ac397ab8202..c683fe91df1 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.0 +PROJECT_NUMBER = 1.21.1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index e0ffeff6650..69f6a345afa 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.0 +PROJECT_NUMBER = 1.21.1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From 035bf8eb14cc119dafec0aebd19e953e65142cb9 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 21 May 2019 10:50:18 -0700 Subject: [PATCH 0273/1555] Fix clang errors --- src/core/lib/surface/completion_queue.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index 64ceb45cf24..5fa36392da5 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -861,18 +861,19 @@ static void cq_end_op_for_callback( grpc_core::ApplicationCallbackExecCtx::Enqueue(functor, (error == GRPC_ERROR_NONE)); } else { - GRPC_CLOSURE_RUN( - GRPC_CLOSURE_CREATE( - functor_callback, functor, - grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), - GRPC_ERROR_REF(error)); + GRPC_CLOSURE_RUN( + GRPC_CLOSURE_CREATE( + functor_callback, functor, + grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), + GRPC_ERROR_REF(error)); } GRPC_ERROR_UNREF(error); } void grpc_cq_end_op(grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage, bool internal) { + void* done_arg, grpc_cq_completion* storage, + bool internal) { cq->vtable->end_op(cq, tag, error, done, done_arg, storage, internal); } @@ -1351,11 +1352,10 @@ static void cq_finish_shutdown_callback(grpc_completion_queue* cq) { GPR_ASSERT(cqd->shutdown_called); cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done); - GRPC_CLOSURE_RUN( - GRPC_CLOSURE_CREATE( - functor_callback, callback, - grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), - GRPC_ERROR_NONE); + GRPC_CLOSURE_RUN(GRPC_CLOSURE_CREATE(functor_callback, callback, + grpc_core::Executor::Scheduler( + grpc_core::ExecutorJobType::SHORT)), + GRPC_ERROR_NONE); } static void cq_shutdown_callback(grpc_completion_queue* cq) { From 5b3e0732ab926febe31ebe3f796da2c65b19e232 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 21 May 2019 10:59:17 -0700 Subject: [PATCH 0274/1555] Revert "Bump up version to 1.21.1" This reverts commit 8ab582eb84ec9499bac58202f132a624f8e06dac. --- CMakeLists.txt | 2 +- Makefile | 4 ++-- build.yaml | 2 +- gRPC-C++.podspec | 4 ++-- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 4 ++-- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 4 ++-- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/composer.json | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 31 files changed, 35 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b0c75c0811..dd3b5e3eb5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.21.1") +set(PACKAGE_VERSION "1.21.0") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 0d148ab3cd2..67495f250be 100644 --- a/Makefile +++ b/Makefile @@ -460,8 +460,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.21.1 -CSHARP_VERSION = 1.21.1 +CPP_VERSION = 1.21.0 +CSHARP_VERSION = 1.21.0 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/build.yaml b/build.yaml index 0344ce18053..39f55d49dd2 100644 --- a/build.yaml +++ b/build.yaml @@ -14,7 +14,7 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 7.0.0 g_stands_for: gandalf - version: 1.21.1 + version: 1.21.0 filegroups: - name: alts_proto headers: diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index ca27e4f34f3..91a72e75191 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,7 +23,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.21.1' + # version = '1.21.0' version = '0.0.9' s.version = version s.summary = 'gRPC C++ library' @@ -31,7 +31,7 @@ Pod::Spec.new do |s| s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.21.1' + grpc_version = '1.21.0' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index ca3225b3694..76f8cb3c8be 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.21.1' + version = '1.21.0' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 2012515bbe9..4a48257b215 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.21.1' + version = '1.21.0' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index c4a9f2889e9..8db3c7dc179 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.21.1' + version = '1.21.0' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index 31a1c448aa1..83317db3b86 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.21.1' + version = '1.21.0' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index 6bcbd807566..96af492c9d9 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2018-01-19 - 1.21.1 - 1.21.1 + 1.21.0 + 1.21.0 stable diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 619220ce4e3..10801e5b713 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.21.1"; } +grpc::string Version() { return "1.21.0"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index 5cf75df63ab..494ce145dac 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -33,11 +33,11 @@ namespace Grpc.Core /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "1.21.1.0"; + public const string CurrentAssemblyFileVersion = "1.21.0.0"; /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.21.1"; + public const string CurrentVersion = "1.21.0"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index c4c40fe0c66..fe280590fd6 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 1.21.1 + 1.21.0 3.7.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index 65deb40679c..6cfe3a1ab8e 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=1.21.1 +set VERSION=1.21.0 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 8ac2dd7d303..77d6d4842eb 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.21.1' + v = '1.21.0' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index e410f8da012..4686dc2d1b7 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.1" +#define GRPC_OBJC_VERSION_STRING @"1.21.0" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 95b112b156f..30f9ad18021 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.1" +#define GRPC_OBJC_VERSION_STRING @"1.21.0" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/composer.json b/src/php/composer.json index 3171442cc03..a9d0aebffca 100644 --- a/src/php/composer.json +++ b/src/php/composer.json @@ -2,7 +2,7 @@ "name": "grpc/grpc-dev", "description": "gRPC library for PHP - for Developement use only", "license": "Apache-2.0", - "version": "1.21.1", + "version": "1.21.0", "require": { "php": ">=5.5.0", "google/protobuf": "^v3.3.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 07a73698015..33adae484ea 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.21.1" +#define PHP_GRPC_VERSION "1.21.0" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index 4624e467fd8..2b68fd5ff04 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.21.1""" +__version__ = """1.21.0""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index 2451ef4a538..cba5f3c0ebd 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.21.1' +VERSION = '1.21.0' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index 591b5bd8fc5..29a7523e926 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.21.1' +VERSION = '1.21.0' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index c11487af7e8..80257d78a5d 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.21.1' +VERSION = '1.21.0' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 47628416c26..bf61f4576a9 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.21.1' +VERSION = '1.21.0' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index 713746a1598..850704d2f99 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.21.1' +VERSION = '1.21.0' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 3fe457f304c..2a6b1c4b65a 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.21.1' +VERSION = '1.21.0' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index 103b532f38f..73cbe3913f6 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.21.1' +VERSION = '1.21.0' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 1308aa4652e..272a05310d6 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.21.1' + VERSION = '1.21.0' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index 38f7129d139..3f1c59e3592 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.21.1' + VERSION = '1.21.0' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 872f821c2f6..5577597ef5d 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.21.1' +VERSION = '1.21.0' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index c683fe91df1..ac397ab8202 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.1 +PROJECT_NUMBER = 1.21.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 69f6a345afa..e0ffeff6650 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.1 +PROJECT_NUMBER = 1.21.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From ccc105f3fdc0e017b8510f694f2ebb9c67c90324 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 21 May 2019 11:07:43 -0700 Subject: [PATCH 0275/1555] Move GRPC_CLOSURE_RUN to GRPC_CLOSURE_SCHED - As here we want it to be scheduled for execution later. --- src/core/lib/surface/completion_queue.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index 5fa36392da5..d0ed1a9f673 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -861,7 +861,7 @@ static void cq_end_op_for_callback( grpc_core::ApplicationCallbackExecCtx::Enqueue(functor, (error == GRPC_ERROR_NONE)); } else { - GRPC_CLOSURE_RUN( + GRPC_CLOSURE_SCHED( GRPC_CLOSURE_CREATE( functor_callback, functor, grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), @@ -1352,10 +1352,11 @@ static void cq_finish_shutdown_callback(grpc_completion_queue* cq) { GPR_ASSERT(cqd->shutdown_called); cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done); - GRPC_CLOSURE_RUN(GRPC_CLOSURE_CREATE(functor_callback, callback, - grpc_core::Executor::Scheduler( - grpc_core::ExecutorJobType::SHORT)), - GRPC_ERROR_NONE); + GRPC_CLOSURE_SCHED( + GRPC_CLOSURE_CREATE( + functor_callback, callback, + grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), + GRPC_ERROR_NONE); } static void cq_shutdown_callback(grpc_completion_queue* cq) { From f131adf89c0fb510b755a390a4b833c887c0706c Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Tue, 21 May 2019 15:52:40 -0700 Subject: [PATCH 0276/1555] Fix bazel incompatible changes When building grpc with the upcoming `--incompatible_depset_is_not_iterable` flag, these violations were found --- bazel/generate_cc.bzl | 6 +++--- bazel/python_rules.bzl | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bazel/generate_cc.bzl b/bazel/generate_cc.bzl index 29a888f608f..b7edcda702f 100644 --- a/bazel/generate_cc.bzl +++ b/bazel/generate_cc.bzl @@ -41,11 +41,11 @@ def _join_directories(directories): def generate_cc_impl(ctx): """Implementation of the generate_cc rule.""" - protos = [f for src in ctx.attr.srcs for f in src.proto.check_deps_sources] + protos = [f for src in ctx.attr.srcs for f in src.proto.check_deps_sources.to_list()] includes = [ f for src in ctx.attr.srcs - for f in src.proto.transitive_imports + for f in src.proto.transitive_imports.to_list() ] outs = [] proto_root = get_proto_root( @@ -128,7 +128,7 @@ def generate_cc_impl(ctx): arguments += ["-I{0}".format(f + "/../..")] well_known_proto_files = [ f - for f in ctx.attr.well_known_protos.files + for f in ctx.attr.well_known_protos.files.to_list() ] ctx.actions.run( diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index 2f3b38af002..17004f3474d 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -33,7 +33,7 @@ def _generate_py_impl(context): includes = [ file for src in context.attr.deps - for file in src.proto.transitive_imports + for file in src.proto.transitive_imports.to_list() ] proto_root = get_proto_root(context.label.workspace_root) format_str = (_GENERATED_GRPC_PROTO_FORMAT if context.executable.plugin else _GENERATED_PROTO_FORMAT) From b30b8e378f16430754bfaafb90f1206d52a08efc Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 21 May 2019 18:33:05 -0700 Subject: [PATCH 0277/1555] Verify the validity of python artifacts --- tools/run_tests/artifacts/build_artifact_python.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/run_tests/artifacts/build_artifact_python.sh b/tools/run_tests/artifacts/build_artifact_python.sh index e451ced338f..831566d51e4 100755 --- a/tools/run_tests/artifacts/build_artifact_python.sh +++ b/tools/run_tests/artifacts/build_artifact_python.sh @@ -130,5 +130,8 @@ then cp -r src/python/grpcio_status/dist/* "$ARTIFACT_DIR" fi +"${PIP}" install twine + +twine check dist/* tools/distrib/python/grpcio_tools/dist/* cp -r dist/* "$ARTIFACT_DIR" cp -r tools/distrib/python/grpcio_tools/dist/* "$ARTIFACT_DIR" From 189697eb30c3da55f80e66a23eb9a118e1c833d2 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 21 May 2019 19:47:12 -0700 Subject: [PATCH 0278/1555] Compensate for https://github.com/pypa/wheel/issues/189 --- src/python/grpcio/README.rst | 8 ++++---- tools/distrib/python/grpcio_tools/README.rst | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/python/grpcio/README.rst b/src/python/grpcio/README.rst index 44d516ef6cb..07c94342de1 100644 --- a/src/python/grpcio/README.rst +++ b/src/python/grpcio/README.rst @@ -16,8 +16,8 @@ Installation gRPC Python is available for Linux, macOS, and Windows. -From PyPI -~~~~~~~~~ +Installing From PyPI +~~~~~~~~~~~~~~~~~~~~ If you are installing locally... @@ -45,8 +45,8 @@ n.b. On Windows and on Mac OS X one *must* have a recent release of :code:`pip` to retrieve the proper wheel from PyPI. Be sure to upgrade to the latest version! -From Source -~~~~~~~~~~~ +Installing From Source +~~~~~~~~~~~~~~~~~~~~~~ Building from source requires that you have the Python headers (usually a package named :code:`python-dev`). diff --git a/tools/distrib/python/grpcio_tools/README.rst b/tools/distrib/python/grpcio_tools/README.rst index cc974eda315..2fe79350a84 100644 --- a/tools/distrib/python/grpcio_tools/README.rst +++ b/tools/distrib/python/grpcio_tools/README.rst @@ -17,8 +17,8 @@ Installation The gRPC Python tools package is available for Linux, Mac OS X, and Windows running Python 2.7. -From PyPI -~~~~~~~~~ +Installing From PyPI +~~~~~~~~~~~~~~~~~~~~ If you are installing locally... @@ -50,8 +50,8 @@ You might also need to install Cython to handle installation via the source distribution if gRPC Python's system coverage with wheels does not happen to include your system. -From Source -~~~~~~~~~~~ +Installing From Source +~~~~~~~~~~~~~~~~~~~~~~ Building from source requires that you have the Python headers (usually a package named :code:`python-dev`) and Cython installed. It further requires a From 705a34884c748cda85facd4b52e5c4f513f41555 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 22 May 2019 09:42:56 -0700 Subject: [PATCH 0279/1555] Properly invoke twine --- tools/run_tests/artifacts/build_artifact_python.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/run_tests/artifacts/build_artifact_python.sh b/tools/run_tests/artifacts/build_artifact_python.sh index 831566d51e4..e35a3b67bb4 100755 --- a/tools/run_tests/artifacts/build_artifact_python.sh +++ b/tools/run_tests/artifacts/build_artifact_python.sh @@ -130,8 +130,9 @@ then cp -r src/python/grpcio_status/dist/* "$ARTIFACT_DIR" fi +# Ensure the generated artifacts are valid. "${PIP}" install twine +"${PYTHON}" -m twine check dist/* tools/distrib/python/grpcio_tools/dist/* -twine check dist/* tools/distrib/python/grpcio_tools/dist/* cp -r dist/* "$ARTIFACT_DIR" cp -r tools/distrib/python/grpcio_tools/dist/* "$ARTIFACT_DIR" From 18a9e00b333d8aa6d2a270ce229ae32657033baa Mon Sep 17 00:00:00 2001 From: Sanjay Pujare Date: Wed, 22 May 2019 09:53:18 -0700 Subject: [PATCH 0280/1555] Document the Watch() method that got added to health/v1/health.proto --- doc/health-checking.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/health-checking.md b/doc/health-checking.md index 7be8107b60f..22b6e1b4c09 100644 --- a/doc/health-checking.md +++ b/doc/health-checking.md @@ -43,6 +43,8 @@ message HealthCheckResponse { service Health { rpc Check(HealthCheckRequest) returns (HealthCheckResponse); + + rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse); } ``` @@ -68,3 +70,8 @@ matching semantics that both the client and server agree upon. A client can declare the server as unhealthy if the rpc is not finished after some amount of time. The client should be able to handle the case where server does not have the Health service. + +A client can call the `Watch` method to perform a streaming health-check. +The server will immediately send back a message indicating the current +serving status. It will then subsequently send a new message whenever +the service's serving status changes. From 64d26e617f7866cb7aa322b71dc56e7498367d88 Mon Sep 17 00:00:00 2001 From: Srini Polavarapu Date: Wed, 22 May 2019 10:30:22 -0700 Subject: [PATCH 0281/1555] Bump version to v1.21.1-pre1 --- BUILD | 2 +- build.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index bf128416cf9..39777d9f723 100644 --- a/BUILD +++ b/BUILD @@ -78,7 +78,7 @@ g_stands_for = "gandalf" core_version = "7.0.0" -version = "1.21.0" +version = "1.21.1-pre1" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index 39f55d49dd2..b6508734295 100644 --- a/build.yaml +++ b/build.yaml @@ -14,7 +14,7 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 7.0.0 g_stands_for: gandalf - version: 1.21.0 + version: 1.21.1-pre1 filegroups: - name: alts_proto headers: From 5207867e2d69737a7aa4fb6c158298cdb69c6a70 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 22 May 2019 10:37:00 -0700 Subject: [PATCH 0282/1555] Ensure windows artifacts are valid as well. --- tools/run_tests/artifacts/build_artifact_python.bat | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/run_tests/artifacts/build_artifact_python.bat b/tools/run_tests/artifacts/build_artifact_python.bat index 795e80dc40d..e160a101228 100644 --- a/tools/run_tests/artifacts/build_artifact_python.bat +++ b/tools/run_tests/artifacts/build_artifact_python.bat @@ -46,6 +46,10 @@ pushd tools\distrib\python\grpcio_tools python setup.py bdist_wheel || goto :error popd +@rem Ensure the generate artifacts are valid. +pip install twine +python -m twine check dist\* tools\distrib\python\grpcio_tools\dist\* || goto :error + xcopy /Y /I /S dist\* %ARTIFACT_DIR% || goto :error xcopy /Y /I /S tools\distrib\python\grpcio_tools\dist\* %ARTIFACT_DIR% || goto :error From 2e31120724ace26a939bb2c34892e1eb2b9cc8d0 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 22 May 2019 10:42:39 -0700 Subject: [PATCH 0283/1555] Fix StressTests on Mac --- src/objective-c/tests/Podfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile index 146abf5b0e0..c9d620ca2e9 100644 --- a/src/objective-c/tests/Podfile +++ b/src/objective-c/tests/Podfile @@ -112,7 +112,7 @@ post_install do |installer| # GPR_UNREACHABLE_CODE causes "Control may reach end of non-void # function" warning config.build_settings['GCC_WARN_ABOUT_RETURN_TYPE'] = 'NO' - config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_CRONET_WITH_PACKET_COALESCING=1' + config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_CRONET_WITH_PACKET_COALESCING=1 GRPC_CFSTREAM=1' end end From 4f7f561564e52b0f2dd97ac661594d2449886df4 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 22 May 2019 10:42:50 -0700 Subject: [PATCH 0284/1555] Add synchronization to bm test - since we made the callback run on another thread, add synchronization in bm tests as well --- test/cpp/microbenchmarks/bm_cq.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index 50eb9454fbe..1f0b9621b21 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -166,6 +166,9 @@ class TagCallback : public grpc_experimental_completion_queue_functor { int* iter_; }; +static gpr_mu shutdown_mu; +static gpr_cv shutdown_cv; + // Check if completion queue is shut down class ShutdownCallback : public grpc_experimental_completion_queue_functor { public: @@ -174,7 +177,10 @@ class ShutdownCallback : public grpc_experimental_completion_queue_functor { } ~ShutdownCallback() {} static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { + gpr_mu_lock(&shutdown_mu); *static_cast(cb)->done_ = static_cast(ok); + gpr_cv_signal(&shutdown_cv); + gpr_mu_unlock(&shutdown_mu); } private: @@ -185,6 +191,8 @@ static void BM_Callback_CQ_Pass1Core(benchmark::State& state) { TrackCounters track_counters; int iteration = 0; TagCallback tag_cb(&iteration); + gpr_mu_init(&shutdown_mu); + gpr_cv_init(&shutdown_cv); bool got_shutdown = false; ShutdownCallback shutdown_cb(&got_shutdown); grpc_completion_queue* cc = @@ -198,9 +206,19 @@ static void BM_Callback_CQ_Pass1Core(benchmark::State& state) { nullptr, &completion); } shutdown_and_destroy(cc); + + gpr_mu_lock(&shutdown_mu); + while (!got_shutdown) { + // Wait for the shutdown callback to complete. + gpr_cv_wait(&shutdown_cv, &shutdown_mu, + gpr_inf_future(GPR_CLOCK_REALTIME)); + } + gpr_mu_unlock(&shutdown_mu); GPR_ASSERT(got_shutdown); GPR_ASSERT(iteration == static_cast(state.iterations())); track_counters.Finish(state); + gpr_cv_destroy(&shutdown_cv); + gpr_mu_destroy(&shutdown_mu); } BENCHMARK(BM_Callback_CQ_Pass1Core); From 4a208f0071b0ece3a36bf3be4fc3c7602cce2cd8 Mon Sep 17 00:00:00 2001 From: Can Guler Date: Wed, 22 May 2019 10:48:54 -0700 Subject: [PATCH 0285/1555] Add v1.21.0 releases of grpc-go to interop matrix --- tools/interop_matrix/client_matrix.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index 234c71295b3..f9c069f6389 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -124,6 +124,7 @@ LANG_RELEASE_MATRIX = { ('v1.18.0', ReleaseInfo(runtime_subset=['go1.11'])), ('v1.19.0', ReleaseInfo(runtime_subset=['go1.11'])), ('v1.20.0', ReleaseInfo(runtime_subset=['go1.11'])), + ('v1.21.0', ReleaseInfo(runtime_subset=['go1.11'])), ]), 'java': OrderedDict([ From 60f23bd38c6dd95a14fcb123d0c9a9cf6729a25e Mon Sep 17 00:00:00 2001 From: Srini Polavarapu Date: Wed, 22 May 2019 10:53:58 -0700 Subject: [PATCH 0286/1555] Regenerate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 6 +++--- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 8 ++++---- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 4 ++-- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/composer.json | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 30 files changed, 37 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd3b5e3eb5b..d335591779c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.21.0") +set(PACKAGE_VERSION "1.21.1-pre1") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 67495f250be..36f3f051dd3 100644 --- a/Makefile +++ b/Makefile @@ -460,8 +460,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.21.0 -CSHARP_VERSION = 1.21.0 +CPP_VERSION = 1.21.1-pre1 +CSHARP_VERSION = 1.21.1-pre1 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 91a72e75191..4286e3d57e7 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,15 +23,15 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.21.0' - version = '0.0.9' + # version = '1.21.1-pre1' + version = '0.0.9-pre1' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.21.0' + grpc_version = '1.21.1-pre1' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 76f8cb3c8be..484601bb46b 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.21.0' + version = '1.21.1-pre1' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 4a48257b215..879d7232285 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.21.0' + version = '1.21.1-pre1' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 8db3c7dc179..cb0026c8ab6 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.21.0' + version = '1.21.1-pre1' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index 83317db3b86..4531fa1fd52 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.21.0' + version = '1.21.1-pre1' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index 96af492c9d9..bab2565d93f 100644 --- a/package.xml +++ b/package.xml @@ -13,12 +13,12 @@ 2018-01-19 - 1.21.0 - 1.21.0 + 1.21.1RC1 + 1.21.1RC1 - stable - stable + beta + beta Apache 2.0 diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 10801e5b713..e57b20e0345 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.21.0"; } +grpc::string Version() { return "1.21.1-pre1"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index 494ce145dac..76404a70b05 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -33,11 +33,11 @@ namespace Grpc.Core /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "1.21.0.0"; + public const string CurrentAssemblyFileVersion = "1.21.1.0"; /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.21.0"; + public const string CurrentVersion = "1.21.1-pre1"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index fe280590fd6..9cf56e62028 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 1.21.0 + 1.21.1-pre1 3.7.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index 6cfe3a1ab8e..05a236e8bc8 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=1.21.0 +set VERSION=1.21.1-pre1 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 77d6d4842eb..4c5759acf21 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.21.0' + v = '1.21.1-pre1' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 4686dc2d1b7..adaed0e8069 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.0" +#define GRPC_OBJC_VERSION_STRING @"1.21.1-pre1" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 30f9ad18021..4995d24b035 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.0" +#define GRPC_OBJC_VERSION_STRING @"1.21.1-pre1" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/composer.json b/src/php/composer.json index a9d0aebffca..3171442cc03 100644 --- a/src/php/composer.json +++ b/src/php/composer.json @@ -2,7 +2,7 @@ "name": "grpc/grpc-dev", "description": "gRPC library for PHP - for Developement use only", "license": "Apache-2.0", - "version": "1.21.0", + "version": "1.21.1", "require": { "php": ">=5.5.0", "google/protobuf": "^v3.3.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 33adae484ea..e8b9c89cf0d 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.21.0" +#define PHP_GRPC_VERSION "1.21.1RC1" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index 2b68fd5ff04..47cc5285ffa 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.21.0""" +__version__ = """1.21.1rc1""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index cba5f3c0ebd..190dd3742fa 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.21.0' +VERSION = '1.21.1rc1' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index 29a7523e926..503642e0de7 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.21.0' +VERSION = '1.21.1rc1' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index 80257d78a5d..f30051b73eb 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.21.0' +VERSION = '1.21.1rc1' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index bf61f4576a9..33990f871c7 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.21.0' +VERSION = '1.21.1rc1' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index 850704d2f99..ef6fb804fe6 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.21.0' +VERSION = '1.21.1rc1' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 2a6b1c4b65a..ca3e64b5334 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.21.0' +VERSION = '1.21.1rc1' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index 73cbe3913f6..40978182efe 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.21.0' +VERSION = '1.21.1rc1' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 272a05310d6..b2c5f8f7085 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.21.0' + VERSION = '1.21.1.pre1' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index 3f1c59e3592..b27d73529a6 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.21.0' + VERSION = '1.21.1.pre1' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 5577597ef5d..b0f145cff90 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.21.0' +VERSION = '1.21.1rc1' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index ac397ab8202..08250515ecf 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.0 +PROJECT_NUMBER = 1.21.1-pre1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index e0ffeff6650..91ad7a334ef 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.0 +PROJECT_NUMBER = 1.21.1-pre1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From 0b50670b23999a1c5451daccf9a14fdf01219c92 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 22 May 2019 12:39:22 -0700 Subject: [PATCH 0287/1555] Make some test fixes --- tools/run_tests/generated/sources_and_headers.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 34004d7d52d..852119f8e25 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -10321,6 +10321,7 @@ "include/grpcpp/channel_impl.h", "include/grpcpp/client_context.h", "include/grpcpp/completion_queue.h", + "include/grpcpp/completion_queue_impl.h", "include/grpcpp/create_channel.h", "include/grpcpp/create_channel_impl.h", "include/grpcpp/create_channel_posix.h", @@ -10447,6 +10448,7 @@ "include/grpcpp/channel_impl.h", "include/grpcpp/client_context.h", "include/grpcpp/completion_queue.h", + "include/grpcpp/completion_queue_impl.h", "include/grpcpp/create_channel.h", "include/grpcpp/create_channel_impl.h", "include/grpcpp/create_channel_posix.h", From 5ffb32c069ab0aa2e99eaeb1b5e3e432c8f8489a Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 22 May 2019 13:43:07 -0700 Subject: [PATCH 0288/1555] Fix clang errors --- tools/run_tests/generated/sources_and_headers.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 852119f8e25..34004d7d52d 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -10321,7 +10321,6 @@ "include/grpcpp/channel_impl.h", "include/grpcpp/client_context.h", "include/grpcpp/completion_queue.h", - "include/grpcpp/completion_queue_impl.h", "include/grpcpp/create_channel.h", "include/grpcpp/create_channel_impl.h", "include/grpcpp/create_channel_posix.h", @@ -10448,7 +10447,6 @@ "include/grpcpp/channel_impl.h", "include/grpcpp/client_context.h", "include/grpcpp/completion_queue.h", - "include/grpcpp/completion_queue_impl.h", "include/grpcpp/create_channel.h", "include/grpcpp/create_channel_impl.h", "include/grpcpp/create_channel_posix.h", From e1f62278e316d8b20dc5a2d7f91f76b117d6199b Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 22 May 2019 13:53:10 -0700 Subject: [PATCH 0289/1555] Fix clang error --- test/cpp/microbenchmarks/bm_cq.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index 1f0b9621b21..6ab4b083c13 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -210,8 +210,7 @@ static void BM_Callback_CQ_Pass1Core(benchmark::State& state) { gpr_mu_lock(&shutdown_mu); while (!got_shutdown) { // Wait for the shutdown callback to complete. - gpr_cv_wait(&shutdown_cv, &shutdown_mu, - gpr_inf_future(GPR_CLOCK_REALTIME)); + gpr_cv_wait(&shutdown_cv, &shutdown_mu, gpr_inf_future(GPR_CLOCK_REALTIME)); } gpr_mu_unlock(&shutdown_mu); GPR_ASSERT(got_shutdown); From e9ab0e0cd94bc6521921b73f724ac28f49fd2bbd Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 22 May 2019 13:56:50 -0700 Subject: [PATCH 0290/1555] Ensure twine is installed on Windows --- tools/run_tests/artifacts/build_artifact_python.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/artifacts/build_artifact_python.bat b/tools/run_tests/artifacts/build_artifact_python.bat index e160a101228..c946cd98061 100644 --- a/tools/run_tests/artifacts/build_artifact_python.bat +++ b/tools/run_tests/artifacts/build_artifact_python.bat @@ -47,7 +47,7 @@ python setup.py bdist_wheel || goto :error popd @rem Ensure the generate artifacts are valid. -pip install twine +python -m pip install twine python -m twine check dist\* tools\distrib\python\grpcio_tools\dist\* || goto :error xcopy /Y /I /S dist\* %ARTIFACT_DIR% || goto :error From 3d258e89aec313c2b3687a38eb06cc61559a1cda Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 22 May 2019 14:59:33 -0700 Subject: [PATCH 0291/1555] Fix windows compiler errors --- test/core/surface/completion_queue_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/surface/completion_queue_test.cc b/test/core/surface/completion_queue_test.cc index ff6722ffb17..4a33b934f43 100644 --- a/test/core/surface/completion_queue_test.cc +++ b/test/core/surface/completion_queue_test.cc @@ -360,7 +360,7 @@ static void test_pluck_after_shutdown(void) { static void test_callback(void) { grpc_completion_queue* cc; - void* tags[128]; + static void* tags[128]; grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)]; grpc_cq_polling_type polling_types[] = { GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; From edc506849f3429c6b4a6d90ec604aeb1b7b0eb54 Mon Sep 17 00:00:00 2001 From: Wayne Zhang Date: Wed, 22 May 2019 15:24:33 -0700 Subject: [PATCH 0292/1555] Expose interop test for others --- src/proto/grpc/testing/BUILD | 25 ++++++++----- test/cpp/interop/BUILD | 21 ++++++++++- test/cpp/util/BUILD | 1 + test/cpp/util/test_credentials_provider.cc | 43 ++++++++++++++++++++-- 4 files changed, 76 insertions(+), 14 deletions(-) diff --git a/src/proto/grpc/testing/BUILD b/src/proto/grpc/testing/BUILD index 727c99cf99c..212f0f3cca7 100644 --- a/src/proto/grpc/testing/BUILD +++ b/src/proto/grpc/testing/BUILD @@ -18,11 +18,17 @@ load("//bazel:grpc_build_system.bzl", "grpc_proto_library", "grpc_package") load("@grpc_python_dependencies//:requirements.bzl", "requirement") load("//bazel:python_rules.bzl", "py_proto_library") -grpc_package(name = "testing", visibility = "public") +grpc_package( + name = "testing", + visibility = "public", +) exports_files([ "echo.proto", "echo_messages.proto", + "test.proto", + "empty.proto", + "messages.proto", ]) grpc_proto_library( @@ -50,9 +56,11 @@ grpc_proto_library( grpc_proto_library( name = "echo_proto", srcs = ["echo.proto"], - deps = ["echo_messages_proto", - "simple_messages_proto"], generate_mocks = True, + deps = [ + "echo_messages_proto", + "simple_messages_proto", + ], ) grpc_proto_library( @@ -102,7 +110,7 @@ grpc_proto_library( name = "benchmark_service_proto", srcs = ["benchmark_service.proto"], deps = [ - "messages_proto", + "messages_proto", ], ) @@ -110,7 +118,7 @@ grpc_proto_library( name = "report_qps_scenario_service_proto", srcs = ["report_qps_scenario_service.proto"], deps = [ - "control_proto", + "control_proto", ], ) @@ -118,7 +126,7 @@ grpc_proto_library( name = "worker_service_proto", srcs = ["worker_service.proto"], deps = [ - "control_proto", + "control_proto", ], ) @@ -134,7 +142,7 @@ grpc_proto_library( has_services = False, deps = [ "//src/proto/grpc/core:stats_proto", - ] + ], ) grpc_proto_library( @@ -190,6 +198,5 @@ py_proto_library( name = "py_test_proto", deps = [ ":test_proto_descriptor", - ] + ], ) - diff --git a/test/cpp/interop/BUILD b/test/cpp/interop/BUILD index 6cf4719c17b..802302bc8bf 100644 --- a/test/cpp/interop/BUILD +++ b/test/cpp/interop/BUILD @@ -16,7 +16,10 @@ licenses(["notice"]) # Apache v2 load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_cc_binary", "grpc_package") -grpc_package(name = "test/cpp/interop") +grpc_package( + name = "test/cpp/interop", + visibility = "public", +) grpc_cc_library( name = "server_helper_lib", @@ -103,6 +106,20 @@ grpc_cc_binary( ], ) +grpc_cc_binary( + name = "metrics_client", + srcs = ["metrics_client.cc"], + external_deps = [ + "gflags", + ], + language = "C++", + deps = [ + "//:grpc++", + "//test/cpp/util:metrics_server_lib", + "//test/cpp/util:test_config", + ], +) + grpc_cc_binary( name = "reconnect_interop_client", srcs = [ @@ -153,6 +170,7 @@ grpc_cc_test( external_deps = [ "gflags", ], + tags = ["no_windows"], deps = [ "//:gpr", "//:grpc", @@ -161,5 +179,4 @@ grpc_cc_test( "//test/cpp/util:test_config", "//test/cpp/util:test_util", ], - tags = ["no_windows"], ) diff --git a/test/cpp/util/BUILD b/test/cpp/util/BUILD index bb1ca868ffb..d112611ef35 100644 --- a/test/cpp/util/BUILD +++ b/test/cpp/util/BUILD @@ -75,6 +75,7 @@ grpc_cc_library( "test_credentials_provider.h", ], external_deps = [ + "gflags", "protobuf", ], deps = [ diff --git a/test/cpp/util/test_credentials_provider.cc b/test/cpp/util/test_credentials_provider.cc index 455f94e33d4..41779327cb9 100644 --- a/test/cpp/util/test_credentials_provider.cc +++ b/test/cpp/util/test_credentials_provider.cc @@ -19,21 +19,50 @@ #include "test/cpp/util/test_credentials_provider.h" +#include +#include +#include + #include #include +#include #include #include #include #include "test/core/end2end/data/ssl_test_data.h" +DEFINE_string(tls_cert_file, "", "The TLS cert file used when --use_tls=true"); +DEFINE_string(tls_key_file, "", "The TLS key file used when --use_tls=true"); + namespace grpc { namespace testing { namespace { +grpc::string ReadFile(const grpc::string& src_path) { + std::ifstream src; + src.open(src_path, std::ifstream::in | std::ifstream::binary); + + grpc::string contents; + src.seekg(0, std::ios::end); + contents.reserve(src.tellg()); + src.seekg(0, std::ios::beg); + contents.assign((std::istreambuf_iterator(src)), + (std::istreambuf_iterator())); + return contents; +} + class DefaultCredentialsProvider : public CredentialsProvider { public: + DefaultCredentialsProvider() { + if (!FLAGS_tls_key_file.empty()) { + custom_server_key_ = ReadFile(FLAGS_tls_key_file); + } + if (!FLAGS_tls_cert_file.empty()) { + custom_server_cert_ = ReadFile(FLAGS_tls_cert_file); + } + } ~DefaultCredentialsProvider() override {} void AddSecureType( @@ -87,11 +116,17 @@ class DefaultCredentialsProvider : public CredentialsProvider { grpc::experimental::AltsServerCredentialsOptions alts_opts; return grpc::experimental::AltsServerCredentials(alts_opts); } else if (type == grpc::testing::kTlsCredentialsType) { - SslServerCredentialsOptions::PemKeyCertPair pkcp = {test_server1_key, - test_server1_cert}; SslServerCredentialsOptions ssl_opts; ssl_opts.pem_root_certs = ""; - ssl_opts.pem_key_cert_pairs.push_back(pkcp); + if (!custom_server_key_.empty() && !custom_server_cert_.empty()) { + SslServerCredentialsOptions::PemKeyCertPair pkcp = {custom_server_key_, + custom_server_cert_}; + ssl_opts.pem_key_cert_pairs.push_back(pkcp); + } else { + SslServerCredentialsOptions::PemKeyCertPair pkcp = {test_server1_key, + test_server1_cert}; + ssl_opts.pem_key_cert_pairs.push_back(pkcp); + } return SslServerCredentials(ssl_opts); } else { std::unique_lock lock(mu_); @@ -121,6 +156,8 @@ class DefaultCredentialsProvider : public CredentialsProvider { std::vector added_secure_type_names_; std::vector> added_secure_type_providers_; + grpc::string custom_server_key_; + grpc::string custom_server_cert_; }; CredentialsProvider* g_provider = nullptr; From e8a18969bb4e9ee913b361e90078207ed13e3a59 Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Wed, 22 May 2019 15:30:21 -0700 Subject: [PATCH 0293/1555] Added upb repo to grpc workspace --- WORKSPACE | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/WORKSPACE b/WORKSPACE index 2db3c5db2ff..fe3cb5810fe 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -65,3 +65,13 @@ rbe_autoconfig( }, ), ) + +git_repository( + name = "upb", + commit = "d16bf99ac4658793748cda3251226059892b3b7b", + remote = "https://github.com/protocolbuffers/upb.git", +) + +load("//third_party/upb/bazel:workspace_deps.bzl", "upb_deps") + +upb_deps() From 8d058dc02077d32d9474211228284e3727bfe969 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 22 May 2019 16:15:47 -0700 Subject: [PATCH 0294/1555] Correct include style --- src/core/lib/transport/metadata.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h index 3ff5a35dd2d..f59476ccc21 100644 --- a/src/core/lib/transport/metadata.h +++ b/src/core/lib/transport/metadata.h @@ -21,7 +21,7 @@ #include -#include "include/grpc/impl/codegen/log.h" +#include #include #include From 6c3e3aeb7796d71f4b104e452bd4aa0c9659f239 Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Wed, 22 May 2019 16:35:29 -0700 Subject: [PATCH 0295/1555] Removed git repo from WORKSPACE as that was the incorrect location. Added the code to grpc_deps.bzl instead --- WORKSPACE | 10 ---------- bazel/grpc_deps.bzl | 9 +++++---- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index fe3cb5810fe..2db3c5db2ff 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -65,13 +65,3 @@ rbe_autoconfig( }, ), ) - -git_repository( - name = "upb", - commit = "d16bf99ac4658793748cda3251226059892b3b7b", - remote = "https://github.com/protocolbuffers/upb.git", -) - -load("//third_party/upb/bazel:workspace_deps.bzl", "upb_deps") - -upb_deps() diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index a4e6509782d..74b36008771 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -209,14 +209,15 @@ def grpc_deps(): strip_prefix = "opencensus-cpp-9b1e354e89bf3d92aedc00af45b418ce870f3d77", url = "https://github.com/census-instrumentation/opencensus-cpp/archive/9b1e354e89bf3d92aedc00af45b418ce870f3d77.tar.gz", ) - if "upb" not in native.existing_rules(): http_archive( name = "upb", - sha256 = "0e749a8973968397f849a3b42e28ee9c85dc418c2477954c2a6a4495f323241d", - strip_prefix = "upb-ed9faae0993704b033c594b072d65e1bf19207fa", - url = "https://github.com/google/upb/archive/ed9faae0993704b033c594b072d65e1bf19207fa.tar.gz", + sha256 = "34136146171af0214bc5578bd22adace4c5a98fd00cff758eb57b7151cd16b51", + strip_prefix = "upb-d16bf99ac4658793748cda3251226059892b3b7b", + url = "https://github.com/google/upb/archive/d16bf99ac4658793748cda3251226059892b3b7b.tar.gz", ) + load("@upb//bazel:workspace_deps.bzl", "upb_deps") + upb_deps() # TODO: move some dependencies from "grpc_deps" here? def grpc_test_only_deps(): From 8a167a7f3994de009f7572376b6492268ec7d172 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Wed, 22 May 2019 16:44:29 -0700 Subject: [PATCH 0296/1555] Add grpc-java 1.21.0 to client_matrix.py --- tools/interop_matrix/client_matrix.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index 234c71295b3..f19e9399af1 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -148,6 +148,7 @@ LANG_RELEASE_MATRIX = { ('v1.18.0', ReleaseInfo()), ('v1.19.0', ReleaseInfo()), ('v1.20.0', ReleaseInfo()), + ('v1.21.0', ReleaseInfo()), ]), 'python': OrderedDict([ From 7dae1b919b0c78b7b492ef57b66779a20e7ee262 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 22 May 2019 16:56:03 -0700 Subject: [PATCH 0297/1555] And the same on Posix systems --- tools/run_tests/artifacts/build_artifact_python.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/artifacts/build_artifact_python.sh b/tools/run_tests/artifacts/build_artifact_python.sh index e35a3b67bb4..df4fcdbbe3c 100755 --- a/tools/run_tests/artifacts/build_artifact_python.sh +++ b/tools/run_tests/artifacts/build_artifact_python.sh @@ -131,7 +131,7 @@ then fi # Ensure the generated artifacts are valid. -"${PIP}" install twine +"${PYTHON}" -m pip install twine "${PYTHON}" -m twine check dist/* tools/distrib/python/grpcio_tools/dist/* cp -r dist/* "$ARTIFACT_DIR" From 3693fe84cf7e3e728f6d45064ef10942fb88cbe6 Mon Sep 17 00:00:00 2001 From: jiangtaoli2016 Date: Wed, 22 May 2019 22:37:15 -0700 Subject: [PATCH 0298/1555] Update comment on ssl hotname override --- include/grpcpp/support/channel_arguments_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/grpcpp/support/channel_arguments_impl.h b/include/grpcpp/support/channel_arguments_impl.h index 0efeadca880..ac3b6c4a7e2 100644 --- a/include/grpcpp/support/channel_arguments_impl.h +++ b/include/grpcpp/support/channel_arguments_impl.h @@ -61,8 +61,8 @@ class ChannelArguments { void SetChannelArgs(grpc_channel_args* channel_args) const; // gRPC specific channel argument setters - /// Set target name override for SSL host name checking. This option is for - /// testing only and should never be used in production. + /// Set target name override for SSL host name checking. This option should + /// be used with caution in production. void SetSslTargetNameOverride(const grpc::string& name); // TODO(yangg) add flow control options /// Set the compression algorithm for the channel. From 019e9a432b82bd415483c406c36418097e95d2c8 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 23 May 2019 10:45:23 +0200 Subject: [PATCH 0299/1555] use kokoro env variable to get the PRs target branch --- .../internal_ci/helper_scripts/prepare_build_linux_perf_rc | 6 ------ tools/internal_ci/helper_scripts/prepare_build_macos_rc | 5 +---- tools/internal_ci/helper_scripts/prepare_build_windows.bat | 5 +---- tools/internal_ci/linux/grpc_microbenchmark_diff.sh | 4 ++-- tools/internal_ci/linux/grpc_run_tests_matrix.sh | 5 +---- tools/internal_ci/linux/grpc_trickle_diff.sh | 2 +- tools/internal_ci/linux/run_if_c_cpp_modified.sh | 4 +--- tools/internal_ci/macos/grpc_ios_binary_size.sh | 2 +- 8 files changed, 8 insertions(+), 25 deletions(-) diff --git a/tools/internal_ci/helper_scripts/prepare_build_linux_perf_rc b/tools/internal_ci/helper_scripts/prepare_build_linux_perf_rc index ff5593e031a..bd8c30041c2 100644 --- a/tools/internal_ci/helper_scripts/prepare_build_linux_perf_rc +++ b/tools/internal_ci/helper_scripts/prepare_build_linux_perf_rc @@ -19,12 +19,6 @@ ulimit -n 32768 ulimit -c unlimited -# Performance PR testing needs GH API key and PR metadata to comment results -if [ -n "$KOKORO_GITHUB_PULL_REQUEST_NUMBER" ]; then - sudo apt-get install -y jq - export ghprbTargetBranch=$(curl -s https://api.github.com/repos/grpc/grpc/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER | jq -r .base.ref) -fi - sudo pip install tabulate # Python dependencies for tools/run_tests/python_utils/check_on_pr.py diff --git a/tools/internal_ci/helper_scripts/prepare_build_macos_rc b/tools/internal_ci/helper_scripts/prepare_build_macos_rc index e9ec07cd0f9..b8f37560148 100644 --- a/tools/internal_ci/helper_scripts/prepare_build_macos_rc +++ b/tools/internal_ci/helper_scripts/prepare_build_macos_rc @@ -25,10 +25,7 @@ export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/GrpcTesting-d0eeee2db3 # If this is a PR using RUN_TESTS_FLAGS var, then add flags to filter tests if [ -n "$KOKORO_GITHUB_PULL_REQUEST_NUMBER" ]; then - brew update - brew install jq || brew upgrade jq - ghprbTargetBranch=$(curl -s https://api.github.com/repos/grpc/grpc/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER | jq -r .base.ref) - export RUN_TESTS_FLAGS="$RUN_TESTS_FLAGS --filter_pr_tests --base_branch origin/$ghprbTargetBranch" + export RUN_TESTS_FLAGS="$RUN_TESTS_FLAGS --filter_pr_tests --base_branch origin/$KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH" fi set +ex # rvm script is very verbose and exits with errorcode diff --git a/tools/internal_ci/helper_scripts/prepare_build_windows.bat b/tools/internal_ci/helper_scripts/prepare_build_windows.bat index bee59159331..c27710ffba4 100644 --- a/tools/internal_ci/helper_scripts/prepare_build_windows.bat +++ b/tools/internal_ci/helper_scripts/prepare_build_windows.bat @@ -18,10 +18,7 @@ set PATH=C:\tools\msys64\usr\bin;C:\Python27;%PATH% @rem If this is a PR using RUN_TESTS_FLAGS var, then add flags to filter tests if defined KOKORO_GITHUB_PULL_REQUEST_NUMBER if defined RUN_TESTS_FLAGS ( - chocolatey install -y jq - for /f "usebackq delims=" %%x in (`curl -s https://api.github.com/repos/grpc/grpc/pulls/%KOKORO_GITHUB_PULL_REQUEST_NUMBER% ^| jq -r .base.ref`) do ( - set RUN_TESTS_FLAGS=%RUN_TESTS_FLAGS% --filter_pr_tests --base_branch origin/%%x - ) + set RUN_TESTS_FLAGS=%RUN_TESTS_FLAGS% --filter_pr_tests --base_branch origin/%KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH% ) @rem Update DNS settings to: diff --git a/tools/internal_ci/linux/grpc_microbenchmark_diff.sh b/tools/internal_ci/linux/grpc_microbenchmark_diff.sh index 9834aaa0534..c03383d1461 100755 --- a/tools/internal_ci/linux/grpc_microbenchmark_diff.sh +++ b/tools/internal_ci/linux/grpc_microbenchmark_diff.sh @@ -26,9 +26,9 @@ source tools/internal_ci/helper_scripts/prepare_build_linux_perf_rc tools/run_tests/start_port_server.py tools/internal_ci/linux/run_if_c_cpp_modified.sh tools/profiling/bloat/bloat_diff.py \ - -d origin/$ghprbTargetBranch || FAILED="true" + -d "origin/$KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH" || FAILED="true" tools/internal_ci/linux/run_if_c_cpp_modified.sh tools/profiling/microbenchmarks/bm_diff/bm_main.py \ - -d origin/$ghprbTargetBranch \ + -d "origin/$KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH" \ -b $BENCHMARKS_TO_RUN || FAILED="true" # kill port_server.py to prevent the build from hanging diff --git a/tools/internal_ci/linux/grpc_run_tests_matrix.sh b/tools/internal_ci/linux/grpc_run_tests_matrix.sh index f9acd814ae8..a0ce71aeb7d 100755 --- a/tools/internal_ci/linux/grpc_run_tests_matrix.sh +++ b/tools/internal_ci/linux/grpc_run_tests_matrix.sh @@ -22,10 +22,7 @@ source tools/internal_ci/helper_scripts/prepare_build_linux_rc # If this is a PR using RUN_TESTS_FLAGS var, then add flags to filter tests if [ -n "$KOKORO_GITHUB_PULL_REQUEST_NUMBER" ] && [ -n "$RUN_TESTS_FLAGS" ]; then - sudo apt-get update - sudo apt-get install -y jq - ghprbTargetBranch=$(curl -s https://api.github.com/repos/grpc/grpc/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER | jq -r .base.ref) - export RUN_TESTS_FLAGS="$RUN_TESTS_FLAGS --filter_pr_tests --base_branch origin/$ghprbTargetBranch" + export RUN_TESTS_FLAGS="$RUN_TESTS_FLAGS --filter_pr_tests --base_branch origin/$KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH" fi tools/run_tests/run_tests_matrix.py $RUN_TESTS_FLAGS || FAILED="true" diff --git a/tools/internal_ci/linux/grpc_trickle_diff.sh b/tools/internal_ci/linux/grpc_trickle_diff.sh index 4ed1b73f9e8..49c3d4b2db0 100755 --- a/tools/internal_ci/linux/grpc_trickle_diff.sh +++ b/tools/internal_ci/linux/grpc_trickle_diff.sh @@ -26,7 +26,7 @@ source tools/internal_ci/helper_scripts/prepare_build_linux_perf_rc tools/run_tests/start_port_server.py tools/internal_ci/linux/run_if_c_cpp_modified.sh tools/profiling/microbenchmarks/bm_diff/bm_main.py \ - -d origin/$ghprbTargetBranch \ + -d "origin/$KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH" \ -b bm_fullstack_trickle \ -l 4 \ -t $BENCHMARKS_TO_RUN \ diff --git a/tools/internal_ci/linux/run_if_c_cpp_modified.sh b/tools/internal_ci/linux/run_if_c_cpp_modified.sh index 736d7594234..2414dcca7c9 100755 --- a/tools/internal_ci/linux/run_if_c_cpp_modified.sh +++ b/tools/internal_ci/linux/run_if_c_cpp_modified.sh @@ -20,13 +20,11 @@ set -ex # Enter the gRPC repo root cd $(dirname $0)/../../.. -# TODO(jtattermusch): the "ghprbTargetBranch" is Jenkins specific and probably -# does not work on kokoro? AFFECTS_C_CPP=`python -c 'import os; \ import sys; \ sys.path.insert(0, "tools/run_tests/python_utils"); \ import filter_pull_request_tests as filter; \ - github_target_branch = os.environ.get("ghprbTargetBranch"); \ + github_target_branch = os.environ.get("KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH"); \ print(filter.affects_c_cpp("origin/%s" % github_target_branch))'` if [ $AFFECTS_C_CPP == "False" ] ; then diff --git a/tools/internal_ci/macos/grpc_ios_binary_size.sh b/tools/internal_ci/macos/grpc_ios_binary_size.sh index ea39b0d6e94..17937a30d41 100755 --- a/tools/internal_ci/macos/grpc_ios_binary_size.sh +++ b/tools/internal_ci/macos/grpc_ios_binary_size.sh @@ -24,4 +24,4 @@ cd $(dirname $0)/../../.. source tools/internal_ci/helper_scripts/prepare_build_macos_rc tools/profiling/ios_bin/binary_size.py \ - -d origin/$ghprbTargetBranch + -d "origin/$KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH" From b53e707c3c155171d746e99e7020f311f0af3d8b Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 23 May 2019 17:54:40 +0200 Subject: [PATCH 0300/1555] update bazel version in dockerfile --- templates/tools/dockerfile/bazel.include | 9 ++++++--- tools/dockerfile/test/bazel/Dockerfile | 9 ++++++--- tools/dockerfile/test/sanity/Dockerfile | 9 ++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/templates/tools/dockerfile/bazel.include b/templates/tools/dockerfile/bazel.include index 8888e938f43..3744dacc281 100644 --- a/templates/tools/dockerfile/bazel.include +++ b/templates/tools/dockerfile/bazel.include @@ -1,7 +1,10 @@ #======================== # Bazel installation +# Must be in sync with tools/bazel.sh +ENV BAZEL_VERSION 0.24.1 + RUN apt-get update && apt-get install -y wget && apt-get clean -RUN wget https://github.com/bazelbuild/bazel/releases/download/0.23.2/bazel-0.23.2-installer-linux-x86_64.sh && ${'\\'} - bash ./bazel-0.23.2-installer-linux-x86_64.sh && ${'\\'} - rm bazel-0.23.2-installer-linux-x86_64.sh +RUN wget "https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh" && ${'\\'} + bash ./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && ${'\\'} + rm bazel-$BAZEL_VERSION-installer-linux-x86_64.sh diff --git a/tools/dockerfile/test/bazel/Dockerfile b/tools/dockerfile/test/bazel/Dockerfile index 2536fe299cb..b9fc409d939 100644 --- a/tools/dockerfile/test/bazel/Dockerfile +++ b/tools/dockerfile/test/bazel/Dockerfile @@ -51,10 +51,13 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.2.post1 six==1.10.0 t #======================== # Bazel installation +# Must be in sync with tools/bazel.sh +ENV BAZEL_VERSION 0.24.1 + RUN apt-get update && apt-get install -y wget && apt-get clean -RUN wget https://github.com/bazelbuild/bazel/releases/download/0.23.2/bazel-0.23.2-installer-linux-x86_64.sh && \ - bash ./bazel-0.23.2-installer-linux-x86_64.sh && \ - rm bazel-0.23.2-installer-linux-x86_64.sh +RUN wget "https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh" && \ + bash ./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \ + rm bazel-$BAZEL_VERSION-installer-linux-x86_64.sh RUN mkdir -p /var/local/jenkins diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index 765bd7267a4..4ef4a0a9454 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -97,10 +97,13 @@ ENV CLANG_TIDY=clang-tidy #======================== # Bazel installation +# Must be in sync with tools/bazel.sh +ENV BAZEL_VERSION 0.24.1 + RUN apt-get update && apt-get install -y wget && apt-get clean -RUN wget https://github.com/bazelbuild/bazel/releases/download/0.23.2/bazel-0.23.2-installer-linux-x86_64.sh && \ - bash ./bazel-0.23.2-installer-linux-x86_64.sh && \ - rm bazel-0.23.2-installer-linux-x86_64.sh +RUN wget "https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh" && \ + bash ./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \ + rm bazel-$BAZEL_VERSION-installer-linux-x86_64.sh # Define the default command. From a651957c94f871ae2a429df80e1a7d4ab30e221f Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Thu, 23 May 2019 09:41:29 -0700 Subject: [PATCH 0301/1555] Use a virtual environment --- tools/run_tests/artifacts/build_artifact_python.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/run_tests/artifacts/build_artifact_python.sh b/tools/run_tests/artifacts/build_artifact_python.sh index df4fcdbbe3c..9af11980eba 100755 --- a/tools/run_tests/artifacts/build_artifact_python.sh +++ b/tools/run_tests/artifacts/build_artifact_python.sh @@ -131,8 +131,10 @@ then fi # Ensure the generated artifacts are valid. -"${PYTHON}" -m pip install twine -"${PYTHON}" -m twine check dist/* tools/distrib/python/grpcio_tools/dist/* +"${PYTHON}" -m virtualenv venv +venv/bin/python -m pip install twine +venv/bin/python -m twine check dist/* tools/distrib/python/grpcio_tools/dist/* +rm -rf venv/ cp -r dist/* "$ARTIFACT_DIR" cp -r tools/distrib/python/grpcio_tools/dist/* "$ARTIFACT_DIR" From 374ff3139a955b5df1fdb10b7a4cf228f597e1eb Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 23 May 2019 17:56:52 +0200 Subject: [PATCH 0302/1555] use bazel.sh for foundry RBE tests --- .../internal_ci/linux/grpc_bazel_on_foundry_base.sh | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tools/internal_ci/linux/grpc_bazel_on_foundry_base.sh b/tools/internal_ci/linux/grpc_bazel_on_foundry_base.sh index 93399f81e79..bcde79ecd8e 100755 --- a/tools/internal_ci/linux/grpc_bazel_on_foundry_base.sh +++ b/tools/internal_ci/linux/grpc_bazel_on_foundry_base.sh @@ -15,26 +15,21 @@ set -ex -# Download bazel -temp_dir="$(mktemp -d)" -wget -q https://github.com/bazelbuild/bazel/releases/download/0.23.2/bazel-0.23.2-linux-x86_64 -O "${temp_dir}/bazel" -chmod 755 "${temp_dir}/bazel" -export PATH="${temp_dir}:${PATH}" -# This should show ${temp_dir}/bazel -which bazel - # change to grpc repo root cd $(dirname $0)/../../.. source tools/internal_ci/helper_scripts/prepare_build_linux_rc +# make sure bazel is available +tools/bazel.sh version + # to get "bazel" link for kokoro build, we need to generate # invocation UUID, set a flag for bazel to use it # and upload "bazel_invocation_ids" file as artifact. BAZEL_INVOCATION_ID="$(uuidgen)" echo "${BAZEL_INVOCATION_ID}" >"${KOKORO_ARTIFACTS_DIR}/bazel_invocation_ids" -bazel \ +tools/bazel.sh \ --bazelrc=tools/remote_build/kokoro.bazelrc \ test \ --invocation_id="${BAZEL_INVOCATION_ID}" \ From a3cc5ee574ca0e4c059ff353616ea307894aa223 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 23 May 2019 17:57:52 +0200 Subject: [PATCH 0303/1555] use bazel.sh in bazel RBE readme --- tools/remote_build/README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/remote_build/README.md b/tools/remote_build/README.md index 2cd5f03daf1..4cc3c7a0ea1 100644 --- a/tools/remote_build/README.md +++ b/tools/remote_build/README.md @@ -17,22 +17,27 @@ and tests run by Kokoro CI. ## Running remote build manually from dev workstation +*At the time being, tools/bazel.sh is used instead of invoking "bazel" directly +to overcome the bazel versioning problem (our BUILD files currently only work with +a specific window of bazel version and bazel.sh wrapper makes sure that version +is used).* + Run from repository root (opt, dbg): ``` # manual run of bazel tests remotely on Foundry -bazel --bazelrc=tools/remote_build/manual.bazelrc test --config=opt //test/... +tools/bazel.sh --bazelrc=tools/remote_build/manual.bazelrc test --config=opt //test/... ``` Sanitizer runs (asan, msan, tsan, ubsan): ``` # manual run of bazel tests remotely on Foundry with given sanitizer -bazel --bazelrc=tools/remote_build/manual.bazelrc test --config=asan //test/... +tools/bazel.sh --bazelrc=tools/remote_build/manual.bazelrc test --config=asan //test/... ``` Run on Windows MSVC: ``` # RBE manual run only for c-core (must be run on a Windows host machine) -bazel --bazelrc=tools/remote_build/windows.bazelrc build :all [--credentials_json=(path to service account credentials)] +tools/bazel.sh --bazelrc=tools/remote_build/windows.bazelrc build :all [--credentials_json=(path to service account credentials)] ``` Available command line options can be found in From af279949d49109ee54d484b345abe5b78b8614ea Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 23 May 2019 18:16:03 +0200 Subject: [PATCH 0304/1555] update bazel_rbe.bat --- tools/internal_ci/windows/bazel_rbe.bat | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat index 8f2c534c5ef..30c66896edf 100644 --- a/tools/internal_ci/windows/bazel_rbe.bat +++ b/tools/internal_ci/windows/bazel_rbe.bat @@ -13,7 +13,8 @@ @rem limitations under the License. @rem TODO(jtattermusch): make this generate less output -choco install bazel -y --version 0.23.2 --limit-output +@rem TODO(jtattermusch): use tools/bazel.sh script to keep the versions in sync +choco install bazel -y --version 0.24.1 --limit-output cd github/grpc set PATH=C:\tools\msys64\usr\bin;C:\Python27;%PATH% From d721b3ac1e8a6c1d915167733e0dccb00c262cd4 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Thu, 23 May 2019 10:38:57 -0700 Subject: [PATCH 0305/1555] Compensate for no virtualenv module on Linux kokoro workers --- tools/run_tests/artifacts/build_artifact_python.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/artifacts/build_artifact_python.sh b/tools/run_tests/artifacts/build_artifact_python.sh index 9af11980eba..c5e380fe5dc 100755 --- a/tools/run_tests/artifacts/build_artifact_python.sh +++ b/tools/run_tests/artifacts/build_artifact_python.sh @@ -131,7 +131,7 @@ then fi # Ensure the generated artifacts are valid. -"${PYTHON}" -m virtualenv venv +"${PYTHON}" -m virtualenv venv || { "${PYTHON}" -m pip install virtualenv && "${PYTHON}" -m virtualenv venv; } venv/bin/python -m pip install twine venv/bin/python -m twine check dist/* tools/distrib/python/grpcio_tools/dist/* rm -rf venv/ From 0cafd4110aa47645996d61739750cabe313937b9 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Thu, 23 May 2019 11:12:08 -0700 Subject: [PATCH 0306/1555] Fix typo --- include/grpcpp/impl/codegen/completion_queue_impl.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/grpcpp/impl/codegen/completion_queue_impl.h b/include/grpcpp/impl/codegen/completion_queue_impl.h index 5435f2fa165..d5c4bb0f201 100644 --- a/include/grpcpp/impl/codegen/completion_queue_impl.h +++ b/include/grpcpp/impl/codegen/completion_queue_impl.h @@ -186,8 +186,8 @@ class CompletionQueue : private ::grpc::GrpcLibraryCodegen { /// within the \a deadline). A \a tag points to an arbitrary location usually /// employed to uniquely identify an event. /// - /// \param tag [out] Upon sucess, updated to point to the event's tag. - /// \param ok [out] Upon sucess, true if a successful event, false otherwise + /// \param tag [out] Upon success, updated to point to the event's tag. + /// \param ok [out] Upon success, true if a successful event, false otherwise /// See documentation for CompletionQueue::Next for explanation of ok /// \param deadline [in] How long to block in wait for an event. /// @@ -206,8 +206,8 @@ class CompletionQueue : private ::grpc::GrpcLibraryCodegen { /// employed to uniquely identify an event. /// /// \param f [in] Function to execute before calling AsyncNext on this queue. - /// \param tag [out] Upon sucess, updated to point to the event's tag. - /// \param ok [out] Upon sucess, true if read a regular event, false + /// \param tag [out] Upon success, updated to point to the event's tag. + /// \param ok [out] Upon success, true if read a regular event, false /// otherwise. /// \param deadline [in] How long to block in wait for an event. /// From 1ac1ab73965bebb6f7a5850bf62245a390c31ad6 Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Mon, 20 May 2019 12:24:47 -0700 Subject: [PATCH 0307/1555] Flaky network test enhancements and cleanups - Parameterized flaky_network_test to run with different packet sizes and credentials. - Cleanup debugger_macros Parametrize flaky_network_test to run with different packet sizes and credentials. --- .../test/core/end2end/end2end_defs.include | 2 - test/core/end2end/end2end_nosec_tests.cc | 2 - test/core/end2end/end2end_tests.cc | 2 - test/core/util/debugger_macros.cc | 3 - test/core/util/debugger_macros.h | 5 +- test/cpp/end2end/flaky_network_test.cc | 115 +++++++++++++----- .../linux/grpc_flaky_network_in_docker.sh | 2 +- 7 files changed, 89 insertions(+), 42 deletions(-) diff --git a/templates/test/core/end2end/end2end_defs.include b/templates/test/core/end2end/end2end_defs.include index d40ba2065be..91fa1d9502a 100644 --- a/templates/test/core/end2end/end2end_defs.include +++ b/templates/test/core/end2end/end2end_defs.include @@ -27,7 +27,6 @@ #include -#include "test/core/util/debugger_macros.h" static bool g_pre_init_called = false; @@ -39,7 +38,6 @@ extern void ${test}_pre_init(void); void grpc_end2end_tests_pre_init(void) { GPR_ASSERT(!g_pre_init_called); g_pre_init_called = true; - grpc_summon_debugger_macros(); % for test in tests: ${test}_pre_init(); % endfor diff --git a/test/core/end2end/end2end_nosec_tests.cc b/test/core/end2end/end2end_nosec_tests.cc index 3ab55527da6..e01e6ad0104 100644 --- a/test/core/end2end/end2end_nosec_tests.cc +++ b/test/core/end2end/end2end_nosec_tests.cc @@ -26,7 +26,6 @@ #include -#include "test/core/util/debugger_macros.h" static bool g_pre_init_called = false; @@ -188,7 +187,6 @@ extern void write_buffering_at_end_pre_init(void); void grpc_end2end_tests_pre_init(void) { GPR_ASSERT(!g_pre_init_called); g_pre_init_called = true; - grpc_summon_debugger_macros(); authority_not_supported_pre_init(); bad_hostname_pre_init(); bad_ping_pre_init(); diff --git a/test/core/end2end/end2end_tests.cc b/test/core/end2end/end2end_tests.cc index b680da4433f..76fb046b367 100644 --- a/test/core/end2end/end2end_tests.cc +++ b/test/core/end2end/end2end_tests.cc @@ -26,7 +26,6 @@ #include -#include "test/core/util/debugger_macros.h" static bool g_pre_init_called = false; @@ -190,7 +189,6 @@ extern void write_buffering_at_end_pre_init(void); void grpc_end2end_tests_pre_init(void) { GPR_ASSERT(!g_pre_init_called); g_pre_init_called = true; - grpc_summon_debugger_macros(); authority_not_supported_pre_init(); bad_hostname_pre_init(); bad_ping_pre_init(); diff --git a/test/core/util/debugger_macros.cc b/test/core/util/debugger_macros.cc index fed6ad97285..fde68f32178 100644 --- a/test/core/util/debugger_macros.cc +++ b/test/core/util/debugger_macros.cc @@ -21,7 +21,6 @@ * Not intended to be robust for main-line code, often cuts across abstraction * boundaries. */ - #include #include "src/core/ext/filters/client_channel/client_channel.h" @@ -29,8 +28,6 @@ #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/surface/call.h" -void grpc_summon_debugger_macros() {} - grpc_stream* grpc_transport_stream_from_call(grpc_call* call) { grpc_call_stack* cs = grpc_call_get_call_stack(call); for (;;) { diff --git a/test/core/util/debugger_macros.h b/test/core/util/debugger_macros.h index c6b3720c5ad..71228c6e875 100644 --- a/test/core/util/debugger_macros.h +++ b/test/core/util/debugger_macros.h @@ -19,6 +19,9 @@ #ifndef GRPC_TEST_CORE_UTIL_DEBUGGER_MACROS_H #define GRPC_TEST_CORE_UTIL_DEBUGGER_MACROS_H -void grpc_summon_debugger_macros(); +#include "src/core/ext/transport/chttp2/transport/internal.h" +#include "src/core/lib/surface/call.h" + +grpc_chttp2_stream* grpc_chttp2_stream_from_call(grpc_call* call); #endif /* GRPC_TEST_CORE_UTIL_DEBUGGER_MACROS_H */ diff --git a/test/cpp/end2end/flaky_network_test.cc b/test/cpp/end2end/flaky_network_test.cc index 63a6897f931..626b5a56226 100644 --- a/test/cpp/end2end/flaky_network_test.cc +++ b/test/cpp/end2end/flaky_network_test.cc @@ -16,12 +16,6 @@ * */ -#include -#include -#include -#include -#include - #include #include #include @@ -35,16 +29,22 @@ #include #include #include +#include + +#include +#include +#include +#include +#include #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/gpr/env.h" - #include "src/proto/grpc/testing/echo.grpc.pb.h" +#include "test/core/util/debugger_macros.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" #include "test/cpp/end2end/test_service_impl.h" - -#include +#include "test/cpp/util/test_credentials_provider.h" #ifdef GPR_LINUX using grpc::testing::EchoRequest; @@ -54,14 +54,20 @@ namespace grpc { namespace testing { namespace { -class FlakyNetworkTest : public ::testing::Test { +struct TestScenario { + TestScenario(const grpc::string& creds_type, const grpc::string& content) + : credentials_type(creds_type), message_content(content) {} + const grpc::string credentials_type; + const grpc::string message_content; +}; + +class FlakyNetworkTest : public ::testing::TestWithParam { protected: FlakyNetworkTest() : server_host_("grpctest"), interface_("lo:1"), ipv4_address_("10.0.0.1"), - netmask_("/32"), - kRequestMessage_("🖖") {} + netmask_("/32") {} void InterfaceUp() { std::ostringstream cmd; @@ -129,10 +135,11 @@ class FlakyNetworkTest : public ::testing::Test { void FlakeNetwork() { std::ostringstream cmd; // Emulate a flaky network connection over interface_. Add a delay of 100ms - // +/- 590ms, 3% packet loss, 1% duplicates and 0.1% corrupt packets. + // +/- 20ms, 0.1% packet loss, 1% duplicates and 0.01% corrupt packets. cmd << "tc qdisc replace dev " << interface_ - << " root netem delay 100ms 50ms distribution normal loss 3% duplicate " - "1% corrupt 0.1% "; + << " root netem delay 100ms 20ms distribution normal loss 0.1% " + "duplicate " + "0.1% corrupt 0.01% "; std::system(cmd.str().c_str()); } @@ -172,7 +179,7 @@ class FlakyNetworkTest : public ::testing::Test { // ip6-looopback, but ipv6 support is not enabled by default in docker. port_ = SERVER_PORT; - server_.reset(new ServerData(port_)); + server_.reset(new ServerData(port_, GetParam().credentials_type)); server_->Start(server_host_); } void StopServer() { server_->Shutdown(); } @@ -188,10 +195,11 @@ class FlakyNetworkTest : public ::testing::Test { if (lb_policy_name.size() > 0) { args.SetLoadBalancingPolicyName(lb_policy_name); } // else, default to pick first + auto channel_creds = GetCredentialsProvider()->GetChannelCredentials( + GetParam().credentials_type, &args); std::ostringstream server_address; server_address << server_host_ << ":" << port_; - return CreateCustomChannel(server_address.str(), - InsecureChannelCredentials(), args); + return CreateCustomChannel(server_address.str(), channel_creds, args); } bool SendRpc( @@ -199,7 +207,8 @@ class FlakyNetworkTest : public ::testing::Test { int timeout_ms = 0, bool wait_for_ready = false) { auto response = std::unique_ptr(new EchoResponse()); EchoRequest request; - request.set_message(kRequestMessage_); + auto& msg = GetParam().message_content; + request.set_message(msg); ClientContext context; if (timeout_ms > 0) { context.set_deadline(grpc_timeout_milliseconds_to_deadline(timeout_ms)); @@ -211,22 +220,33 @@ class FlakyNetworkTest : public ::testing::Test { } Status status = stub->Echo(&context, request, response.get()); auto ok = status.ok(); + int stream_id = 0; + grpc_call* call = context.c_call(); + if (call) { + grpc_chttp2_stream* stream = grpc_chttp2_stream_from_call(call); + if (stream) { + stream_id = stream->id; + } + } if (ok) { - gpr_log(GPR_DEBUG, "RPC returned %s\n", response->message().c_str()); + gpr_log(GPR_DEBUG, "RPC with stream_id %d succeeded", stream_id); } else { - gpr_log(GPR_DEBUG, "RPC failed: %s", status.error_message().c_str()); + gpr_log(GPR_DEBUG, "RPC with stream_id %d failed: %s", stream_id, + status.error_message().c_str()); } return ok; } struct ServerData { int port_; + const grpc::string creds_; std::unique_ptr server_; TestServiceImpl service_; std::unique_ptr thread_; bool server_ready_ = false; - explicit ServerData(int port) { port_ = port; } + ServerData(int port, const grpc::string& creds) + : port_(port), creds_(creds) {} void Start(const grpc::string& server_host) { gpr_log(GPR_INFO, "starting server on port %d", port_); @@ -245,8 +265,9 @@ class FlakyNetworkTest : public ::testing::Test { std::ostringstream server_address; server_address << server_host << ":" << port_; ServerBuilder builder; - builder.AddListeningPort(server_address.str(), - InsecureServerCredentials()); + auto server_creds = + GetCredentialsProvider()->GetServerCredentials(creds_); + builder.AddListeningPort(server_address.str(), server_creds); builder.RegisterService(&service_); server_ = builder.BuildAndStart(); std::lock_guard lock(*mu); @@ -291,11 +312,43 @@ class FlakyNetworkTest : public ::testing::Test { std::unique_ptr server_; const int SERVER_PORT = 32750; int port_; - const grpc::string kRequestMessage_; }; +std::vector CreateTestScenarios() { + std::vector scenarios; + std::vector credentials_types; + std::vector messages; + + credentials_types.push_back(kInsecureCredentialsType); + auto sec_list = GetCredentialsProvider()->GetSecureCredentialsTypeList(); + for (auto sec = sec_list.begin(); sec != sec_list.end(); sec++) { + credentials_types.push_back(*sec); + } + + messages.push_back("🖖"); + for (size_t k = 1; k < GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH / 1024; k *= 32) { + grpc::string big_msg; + for (size_t i = 0; i < k * 1024; ++i) { + char c = 'a' + (i % 26); + big_msg += c; + } + messages.push_back(big_msg); + } + for (auto cred = credentials_types.begin(); cred != credentials_types.end(); + ++cred) { + for (auto msg = messages.begin(); msg != messages.end(); msg++) { + scenarios.emplace_back(*cred, *msg); + } + } + + return scenarios; +} + +INSTANTIATE_TEST_CASE_P(FlakyNetworkTest, FlakyNetworkTest, + ::testing::ValuesIn(CreateTestScenarios())); + // Network interface connected to server flaps -TEST_F(FlakyNetworkTest, NetworkTransition) { +TEST_P(FlakyNetworkTest, NetworkTransition) { const int kKeepAliveTimeMs = 1000; const int kKeepAliveTimeoutMs = 1000; ChannelArguments args; @@ -336,7 +389,7 @@ TEST_F(FlakyNetworkTest, NetworkTransition) { } // Traffic to server server is blackholed temporarily with keepalives enabled -TEST_F(FlakyNetworkTest, ServerUnreachableWithKeepalive) { +TEST_P(FlakyNetworkTest, ServerUnreachableWithKeepalive) { const int kKeepAliveTimeMs = 1000; const int kKeepAliveTimeoutMs = 1000; const int kReconnectBackoffMs = 1000; @@ -385,7 +438,7 @@ TEST_F(FlakyNetworkTest, ServerUnreachableWithKeepalive) { // // Traffic to server server is blackholed temporarily with keepalives disabled -TEST_F(FlakyNetworkTest, ServerUnreachableNoKeepalive) { +TEST_P(FlakyNetworkTest, ServerUnreachableNoKeepalive) { auto channel = BuildChannel("pick_first", ChannelArguments()); auto stub = BuildStub(channel); // Channel should be in READY state after we send an RPC @@ -411,7 +464,7 @@ TEST_F(FlakyNetworkTest, ServerUnreachableNoKeepalive) { } // Send RPCs over a flaky network connection -TEST_F(FlakyNetworkTest, FlakyNetwork) { +TEST_P(FlakyNetworkTest, FlakyNetwork) { const int kKeepAliveTimeMs = 1000; const int kKeepAliveTimeoutMs = 1000; const int kMessageCount = 100; @@ -438,7 +491,7 @@ TEST_F(FlakyNetworkTest, FlakyNetwork) { } // Server is shutdown gracefully and restarted. Client keepalives are enabled -TEST_F(FlakyNetworkTest, ServerRestartKeepaliveEnabled) { +TEST_P(FlakyNetworkTest, ServerRestartKeepaliveEnabled) { const int kKeepAliveTimeMs = 1000; const int kKeepAliveTimeoutMs = 1000; ChannelArguments args; @@ -468,7 +521,7 @@ TEST_F(FlakyNetworkTest, ServerRestartKeepaliveEnabled) { } // Server is shutdown gracefully and restarted. Client keepalives are enabled -TEST_F(FlakyNetworkTest, ServerRestartKeepaliveDisabled) { +TEST_P(FlakyNetworkTest, ServerRestartKeepaliveDisabled) { auto channel = BuildChannel("pick_first", ChannelArguments()); auto stub = BuildStub(channel); // Channel should be in READY state after we send an RPC diff --git a/tools/internal_ci/linux/grpc_flaky_network_in_docker.sh b/tools/internal_ci/linux/grpc_flaky_network_in_docker.sh index 7fc8f146727..d574638d3ef 100755 --- a/tools/internal_ci/linux/grpc_flaky_network_in_docker.sh +++ b/tools/internal_ci/linux/grpc_flaky_network_in_docker.sh @@ -28,4 +28,4 @@ cd /var/local/git/grpc/test/cpp/end2end # iptables is used to drop traffic between client and server apt-get install -y iptables -bazel test --spawn_strategy=standalone --genrule_strategy=standalone --test_output=all :flaky_network_test --test_env=GRPC_VERBOSITY=debug --test_env=GRPC_TRACE=channel,client_channel,call_error,connectivity_state,tcp +bazel test --spawn_strategy=standalone --genrule_strategy=standalone --test_output=all --test_timeout=1200 :flaky_network_test --test_env=GRPC_TRACE=http --test_env=GRPC_VERBOSITY=DEBUG From 796744596864229ffe1d2307e42add2c7b17761c Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Wed, 22 May 2019 13:14:53 -0700 Subject: [PATCH 0308/1555] Fix PHP extension segfault --- src/php/ext/grpc/php_grpc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/php/ext/grpc/php_grpc.c b/src/php/ext/grpc/php_grpc.c index f6c2f85ed47..1098075690a 100644 --- a/src/php/ext/grpc/php_grpc.c +++ b/src/php/ext/grpc/php_grpc.c @@ -205,7 +205,9 @@ void register_fork_handlers() { void apply_ini_settings() { if (GRPC_G(enable_fork_support)) { - putenv("GRPC_ENABLE_FORK_SUPPORT=1"); + char *enable_str = malloc(sizeof("GRPC_ENABLE_FORK_SUPPORT=1")); + strcpy(enable_str, "GRPC_ENABLE_FORK_SUPPORT=1"); + putenv(enable_str); } if (GRPC_G(poll_strategy)) { From fb1a6b1d4804782f8ee9b6e1a563a4397f436714 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 23 May 2019 13:25:04 -0700 Subject: [PATCH 0309/1555] clang-format --- .../tests/CronetTests/CronetUnitTests.mm | 2 +- src/objective-c/tests/EnableCronet.m | 2 +- .../tests/InteropTests/InteropTests.m | 2 +- .../InteropTestsMultipleChannels.m | 177 ++++++++++-------- 4 files changed, 104 insertions(+), 79 deletions(-) diff --git a/src/objective-c/tests/CronetTests/CronetUnitTests.mm b/src/objective-c/tests/CronetTests/CronetUnitTests.mm index b17bc334479..b0f3a3000f1 100644 --- a/src/objective-c/tests/CronetTests/CronetUnitTests.mm +++ b/src/objective-c/tests/CronetTests/CronetUnitTests.mm @@ -40,8 +40,8 @@ #import "test/core/util/test_config.h" #define GRPC_SHADOW_BORINGSSL_SYMBOLS -#import "src/core/tsi/grpc_shadow_boringssl.h" #import " +#import "src/core/tsi/grpc_shadow_boringssl.h" static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; diff --git a/src/objective-c/tests/EnableCronet.m b/src/objective-c/tests/EnableCronet.m index b618ec74706..5e0c933d835 100644 --- a/src/objective-c/tests/EnableCronet.m +++ b/src/objective-c/tests/EnableCronet.m @@ -18,8 +18,8 @@ #ifdef GRPC_COMPILE_WITH_CRONET -#import #import "EnableCronet.h" +#import void enableCronet(void) { static dispatch_once_t enableCronet; diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 91fdd0fd841..89f5b96c38b 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -36,8 +36,8 @@ #import #import -#import "InteropTestsBlockCallbacks.h" #import "../EnableCronet.h" +#import "InteropTestsBlockCallbacks.h" #define TEST_TIMEOUT 32 diff --git a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m index 58946825f98..ffda48719e7 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m +++ b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m @@ -26,8 +26,8 @@ #import #import -#import "InteropTestsBlockCallbacks.h" #import "../EnableCronet.h" +#import "InteropTestsBlockCallbacks.h" #define NSStringize_helper(x) #x #define NSStringize(x) @NSStringize_helper(x) @@ -67,8 +67,6 @@ static const NSTimeInterval TEST_TIMEOUT = 8000; } @end - - @interface InteropTestsMultipleChannels : XCTestCase @end @@ -97,7 +95,6 @@ dispatch_once_t initCronet; // Cronet stack with remote host _remoteCronetService = [RMTTestService serviceWithHost:kRemoteSSLHost callOptions:options]; - // Local stack with no SSL options = [[GRPCMutableCallOptions alloc] init]; options.transportType = GRPCTransportTypeInsecure; @@ -134,42 +131,54 @@ dispatch_once_t initCronet; XCTAssertEqualObjects(message, expectedResponse); }; - GRPCUnaryProtoCall *callRemote = [_remoteService emptyCallWithMessage:request - responseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil - messageCallback:messageHandler - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - XCTAssertNil(error); - [expectRemote fulfill]; - } - writeMessageCallback:nil] - callOptions:nil]; - GRPCUnaryProtoCall *callCronet = [_remoteCronetService emptyCallWithMessage:request - responseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil - messageCallback:messageHandler - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - XCTAssertNil(error); - [expectCronetRemote fulfill]; - } - writeMessageCallback:nil] - callOptions:nil]; - GRPCUnaryProtoCall *callCleartext = [_localCleartextService emptyCallWithMessage:request - responseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil - messageCallback:messageHandler - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - XCTAssertNil(error); - [expectCleartext fulfill]; - } - writeMessageCallback:nil] - callOptions:nil]; - GRPCUnaryProtoCall *callSSL = [_localSSLService emptyCallWithMessage:request - responseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil - messageCallback:messageHandler - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - XCTAssertNil(error); - [expectSSL fulfill]; - } - writeMessageCallback:nil] - callOptions:nil]; + GRPCUnaryProtoCall *callRemote = [_remoteService + emptyCallWithMessage:request + responseHandler:[[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:messageHandler + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + XCTAssertNil(error); + [expectRemote fulfill]; + } + writeMessageCallback:nil] + callOptions:nil]; + GRPCUnaryProtoCall *callCronet = [_remoteCronetService + emptyCallWithMessage:request + responseHandler:[[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:messageHandler + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + XCTAssertNil(error); + [expectCronetRemote fulfill]; + } + writeMessageCallback:nil] + callOptions:nil]; + GRPCUnaryProtoCall *callCleartext = [_localCleartextService + emptyCallWithMessage:request + responseHandler:[[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:messageHandler + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + XCTAssertNil(error); + [expectCleartext fulfill]; + } + writeMessageCallback:nil] + callOptions:nil]; + GRPCUnaryProtoCall *callSSL = [_localSSLService + emptyCallWithMessage:request + responseHandler:[[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:messageHandler + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + XCTAssertNil(error); + [expectSSL fulfill]; + } + writeMessageCallback:nil] + callOptions:nil]; [callRemote start]; [callCronet start]; [callCleartext start]; @@ -219,42 +228,58 @@ dispatch_once_t initCronet; } }; - calls[0] = [_remoteService fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil - messageCallback:^(id message) { - handler(0, message); - } - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - XCTAssertNil(error); - [expectRemote fulfill]; - } writeMessageCallback:nil] - callOptions:nil]; - calls[1] = [_remoteCronetService fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil - messageCallback:^(id message) { - handler(1, message); - } - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - XCTAssertNil(error); - [expectCronetRemote fulfill]; - } writeMessageCallback:nil] - callOptions:nil]; - calls[2] = [_localCleartextService fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil - messageCallback:^(id message) { - handler(2, message); - } - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - XCTAssertNil(error); - [expectCleartext fulfill]; - } writeMessageCallback:nil] - callOptions:nil]; - calls[3] = [_localSSLService fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil - messageCallback:^(id message) { - handler(3, message); - } - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - XCTAssertNil(error); - [expectSSL fulfill]; - } writeMessageCallback:nil] - callOptions:nil]; + calls[0] = [_remoteService + fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:^(id message) { + handler(0, message); + } + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + XCTAssertNil(error); + [expectRemote fulfill]; + } + writeMessageCallback:nil] + callOptions:nil]; + calls[1] = [_remoteCronetService + fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:^(id message) { + handler(1, message); + } + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + XCTAssertNil(error); + [expectCronetRemote fulfill]; + } + writeMessageCallback:nil] + callOptions:nil]; + calls[2] = [_localCleartextService + fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:^(id message) { + handler(2, message); + } + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + XCTAssertNil(error); + [expectCleartext fulfill]; + } + writeMessageCallback:nil] + callOptions:nil]; + calls[3] = [_localSSLService + fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:^(id message) { + handler(3, message); + } + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + XCTAssertNil(error); + [expectSSL fulfill]; + } + writeMessageCallback:nil] + callOptions:nil]; for (int i = 0; i < 4; i++) { [calls[i] start]; [calls[i] writeMessage:requests[0]]; From 0a57193dec25db5e5b44e7a7445fb7b0a55fe571 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Thu, 23 May 2019 16:11:23 -0700 Subject: [PATCH 0310/1555] Replaced gpr_ref with grpc_core::Atomic in call batch struct --- src/core/lib/surface/call.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 254476f47e3..271b3ddd560 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -74,7 +74,7 @@ #define ESTIMATED_MDELEM_COUNT 16 struct batch_control { - batch_control() { gpr_ref_init(&steps_to_complete, 0); } + batch_control() = default; grpc_call* call = nullptr; grpc_transport_stream_op_batch op; @@ -99,8 +99,14 @@ struct batch_control { } completion_data; grpc_closure start_batch; grpc_closure finish_batch; - gpr_refcount steps_to_complete; + grpc_core::Atomic steps_to_complete; gpr_atm batch_error = reinterpret_cast(GRPC_ERROR_NONE); + void set_num_steps_to_complete(uintptr_t steps) { + steps_to_complete.Store(steps, grpc_core::MemoryOrder::RELEASE); + } + bool completed_batch_step() { + return steps_to_complete.FetchSub(1, grpc_core::MemoryOrder::ACQ_REL) == 1; + } }; struct parent_call { @@ -1225,7 +1231,7 @@ static void post_batch_completion(batch_control* bctl) { } static void finish_batch_step(batch_control* bctl) { - if (GPR_UNLIKELY(gpr_unref(&bctl->steps_to_complete))) { + if (GPR_UNLIKELY(bctl->completed_batch_step())) { post_batch_completion(bctl); } } @@ -1866,7 +1872,7 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops, if (!is_notify_tag_closure) { GPR_ASSERT(grpc_cq_begin_op(call->cq, notify_tag)); } - gpr_ref_init(&bctl->steps_to_complete, (has_send_ops ? 1 : 0) + num_recv_ops); + bctl->set_num_steps_to_complete((has_send_ops ? 1 : 0) + num_recv_ops); if (has_send_ops) { GRPC_CLOSURE_INIT(&bctl->finish_batch, finish_batch, bctl, From 1bb3f72abee4e5276b44aded69ce3ee59b478a84 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 23 May 2019 17:08:51 -0700 Subject: [PATCH 0311/1555] clang-format --- src/objective-c/tests/InteropTests.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/objective-c/tests/InteropTests.m b/src/objective-c/tests/InteropTests.m index 690c5cee0a2..c96d3436144 100644 --- a/src/objective-c/tests/InteropTests.m +++ b/src/objective-c/tests/InteropTests.m @@ -332,7 +332,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager } } -- (void)writeData:(id )data { +- (void)writeData:(id)data { if (_writeDataHook) { _writeDataHook(data, _manager); } @@ -356,7 +356,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager } } -- (void)didReceiveData:(id )data { +- (void)didReceiveData:(id)data { if (_responseDataHook) { _responseDataHook(data, _manager); } From d2c8eb94c954914e14f979229e963964211c80f8 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Thu, 23 May 2019 18:09:12 -0700 Subject: [PATCH 0312/1555] Fix microbenchmark failures --- test/cpp/microbenchmarks/callback_streaming_ping_pong.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h index 9fb86bd8299..0d27e0efa50 100644 --- a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h @@ -115,7 +115,7 @@ class BidiClient int msgs_size_; std::mutex mu; std::condition_variable cv; - bool done; + bool done = false; }; template From b18faa6c95bee22f03730ad4bc9b192440b5403b Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Thu, 23 May 2019 20:08:45 -0700 Subject: [PATCH 0313/1555] Fix tsan error --- test/cpp/microbenchmarks/bm_cq.cc | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index 6ab4b083c13..edbff9c2be3 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -150,6 +150,9 @@ static void shutdown_and_destroy(grpc_completion_queue* cc) { grpc_completion_queue_destroy(cc); } +static gpr_mu shutdown_mu, mu; +static gpr_cv shutdown_cv, cv; + // Tag completion queue iterate times class TagCallback : public grpc_experimental_completion_queue_functor { public: @@ -158,17 +161,17 @@ class TagCallback : public grpc_experimental_completion_queue_functor { } ~TagCallback() {} static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { + gpr_mu_lock(&mu); GPR_ASSERT(static_cast(ok)); *static_cast(cb)->iter_ += 1; + gpr_cv_signal(&cv); + gpr_mu_unlock(&mu); }; private: int* iter_; }; -static gpr_mu shutdown_mu; -static gpr_cv shutdown_cv; - // Check if completion queue is shut down class ShutdownCallback : public grpc_experimental_completion_queue_functor { public: @@ -189,8 +192,10 @@ class ShutdownCallback : public grpc_experimental_completion_queue_functor { static void BM_Callback_CQ_Pass1Core(benchmark::State& state) { TrackCounters track_counters; - int iteration = 0; + int iteration = 0, current_iterations = 0; TagCallback tag_cb(&iteration); + gpr_mu_init(&mu); + gpr_cv_init(&cv); gpr_mu_init(&shutdown_mu); gpr_cv_init(&shutdown_cv); bool got_shutdown = false; @@ -207,15 +212,26 @@ static void BM_Callback_CQ_Pass1Core(benchmark::State& state) { } shutdown_and_destroy(cc); + gpr_mu_lock(&mu); + current_iterations = static_cast(state.iterations()); + while (current_iterations != iteration) { + // Wait for all the callbacks to complete. + gpr_cv_wait(&cv, &mu, gpr_inf_future(GPR_CLOCK_REALTIME)); + } + gpr_mu_unlock(&mu); + gpr_mu_lock(&shutdown_mu); while (!got_shutdown) { // Wait for the shutdown callback to complete. gpr_cv_wait(&shutdown_cv, &shutdown_mu, gpr_inf_future(GPR_CLOCK_REALTIME)); } gpr_mu_unlock(&shutdown_mu); + GPR_ASSERT(got_shutdown); GPR_ASSERT(iteration == static_cast(state.iterations())); track_counters.Finish(state); + gpr_cv_destroy(&cv); + gpr_mu_destroy(&mu); gpr_cv_destroy(&shutdown_cv); gpr_mu_destroy(&shutdown_mu); } From 088319bc40f2d0b38c69a7b3c557749131451810 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Thu, 23 May 2019 22:10:53 -0700 Subject: [PATCH 0314/1555] IWYU in core_codegen_interface core_codegen_interface requires ByteBuffer in generated code and needs to include byte_buffer.h NO_BUG=Cleanup --- include/grpcpp/impl/codegen/core_codegen_interface.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/grpcpp/impl/codegen/core_codegen_interface.h b/include/grpcpp/impl/codegen/core_codegen_interface.h index 3792c3d4693..02b5033c51f 100644 --- a/include/grpcpp/impl/codegen/core_codegen_interface.h +++ b/include/grpcpp/impl/codegen/core_codegen_interface.h @@ -19,6 +19,7 @@ #ifndef GRPCPP_IMPL_CODEGEN_CORE_CODEGEN_INTERFACE_H #define GRPCPP_IMPL_CODEGEN_CORE_CODEGEN_INTERFACE_H +#include #include #include #include From a0164889fb251c9b0e0570736241490b7316356b Mon Sep 17 00:00:00 2001 From: Srini Polavarapu Date: Fri, 24 May 2019 09:19:49 -0700 Subject: [PATCH 0315/1555] Bump version to v1.21.1 --- BUILD | 2 +- build.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index 39777d9f723..c75a5d124fc 100644 --- a/BUILD +++ b/BUILD @@ -78,7 +78,7 @@ g_stands_for = "gandalf" core_version = "7.0.0" -version = "1.21.1-pre1" +version = "1.21.1" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index b6508734295..0344ce18053 100644 --- a/build.yaml +++ b/build.yaml @@ -14,7 +14,7 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 7.0.0 g_stands_for: gandalf - version: 1.21.1-pre1 + version: 1.21.1 filegroups: - name: alts_proto headers: From 8a01f6340f03bb98e016fabd1c7845dcb3c35d1e Mon Sep 17 00:00:00 2001 From: Srini Polavarapu Date: Fri, 24 May 2019 09:24:35 -0700 Subject: [PATCH 0316/1555] regenerate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 6 +++--- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 8 ++++---- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 2 +- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 29 files changed, 35 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d335591779c..0b0c75c0811 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.21.1-pre1") +set(PACKAGE_VERSION "1.21.1") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 36f3f051dd3..0d148ab3cd2 100644 --- a/Makefile +++ b/Makefile @@ -460,8 +460,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.21.1-pre1 -CSHARP_VERSION = 1.21.1-pre1 +CPP_VERSION = 1.21.1 +CSHARP_VERSION = 1.21.1 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 4286e3d57e7..ca27e4f34f3 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,15 +23,15 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.21.1-pre1' - version = '0.0.9-pre1' + # version = '1.21.1' + version = '0.0.9' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.21.1-pre1' + grpc_version = '1.21.1' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 484601bb46b..ca3225b3694 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.21.1-pre1' + version = '1.21.1' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 879d7232285..2012515bbe9 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.21.1-pre1' + version = '1.21.1' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index cb0026c8ab6..c4a9f2889e9 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.21.1-pre1' + version = '1.21.1' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index 4531fa1fd52..31a1c448aa1 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.21.1-pre1' + version = '1.21.1' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index bab2565d93f..6bcbd807566 100644 --- a/package.xml +++ b/package.xml @@ -13,12 +13,12 @@ 2018-01-19 - 1.21.1RC1 - 1.21.1RC1 + 1.21.1 + 1.21.1 - beta - beta + stable + stable Apache 2.0 diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index e57b20e0345..619220ce4e3 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.21.1-pre1"; } +grpc::string Version() { return "1.21.1"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index 76404a70b05..5cf75df63ab 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -38,6 +38,6 @@ namespace Grpc.Core /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.21.1-pre1"; + public const string CurrentVersion = "1.21.1"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index 9cf56e62028..c4c40fe0c66 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 1.21.1-pre1 + 1.21.1 3.7.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index 05a236e8bc8..65deb40679c 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=1.21.1-pre1 +set VERSION=1.21.1 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 4c5759acf21..8ac2dd7d303 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.21.1-pre1' + v = '1.21.1' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index adaed0e8069..e410f8da012 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.1-pre1" +#define GRPC_OBJC_VERSION_STRING @"1.21.1" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 4995d24b035..95b112b156f 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.1-pre1" +#define GRPC_OBJC_VERSION_STRING @"1.21.1" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index e8b9c89cf0d..07a73698015 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.21.1RC1" +#define PHP_GRPC_VERSION "1.21.1" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index 47cc5285ffa..4624e467fd8 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.21.1rc1""" +__version__ = """1.21.1""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index 190dd3742fa..2451ef4a538 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.21.1rc1' +VERSION = '1.21.1' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index 503642e0de7..591b5bd8fc5 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.21.1rc1' +VERSION = '1.21.1' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index f30051b73eb..c11487af7e8 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.21.1rc1' +VERSION = '1.21.1' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 33990f871c7..47628416c26 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.21.1rc1' +VERSION = '1.21.1' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index ef6fb804fe6..713746a1598 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.21.1rc1' +VERSION = '1.21.1' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index ca3e64b5334..3fe457f304c 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.21.1rc1' +VERSION = '1.21.1' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index 40978182efe..103b532f38f 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.21.1rc1' +VERSION = '1.21.1' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index b2c5f8f7085..1308aa4652e 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.21.1.pre1' + VERSION = '1.21.1' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index b27d73529a6..38f7129d139 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.21.1.pre1' + VERSION = '1.21.1' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index b0f145cff90..872f821c2f6 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.21.1rc1' +VERSION = '1.21.1' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 08250515ecf..c683fe91df1 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.1-pre1 +PROJECT_NUMBER = 1.21.1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 91ad7a334ef..69f6a345afa 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.1-pre1 +PROJECT_NUMBER = 1.21.1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From caa965bd1d0b12e388cd95da5593880049675b1b Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 24 May 2019 09:25:17 -0700 Subject: [PATCH 0317/1555] Address comments --- .../{EnableCronet.h => ConfigureCronet.h} | 2 +- .../{EnableCronet.m => ConfigureCronet.m} | 10 ++--- .../CronetTests/CoreCronetEnd2EndTests.mm | 4 +- .../tests/CronetTests/CronetUnitTests.mm | 6 +-- .../tests/InteropTests/InteropTests.m | 4 +- .../InteropTestsMultipleChannels.m | 4 +- src/objective-c/tests/Podfile | 26 ++++++------- .../tests/Tests.xcodeproj/project.pbxproj | 37 +++++-------------- .../xcschemes/InteropTests.xcscheme | 2 +- 9 files changed, 36 insertions(+), 59 deletions(-) rename src/objective-c/tests/{EnableCronet.h => ConfigureCronet.h} (96%) rename src/objective-c/tests/{EnableCronet.m => ConfigureCronet.m} (86%) diff --git a/src/objective-c/tests/EnableCronet.h b/src/objective-c/tests/ConfigureCronet.h similarity index 96% rename from src/objective-c/tests/EnableCronet.h rename to src/objective-c/tests/ConfigureCronet.h index 720aace4075..cc5c038f3c6 100644 --- a/src/objective-c/tests/EnableCronet.h +++ b/src/objective-c/tests/ConfigureCronet.h @@ -25,7 +25,7 @@ extern "C" { /** * Enable Cronet for once. */ -void enableCronet(void); +void configureCronet(void); #ifdef __cplusplus } diff --git a/src/objective-c/tests/EnableCronet.m b/src/objective-c/tests/ConfigureCronet.m similarity index 86% rename from src/objective-c/tests/EnableCronet.m rename to src/objective-c/tests/ConfigureCronet.m index 5e0c933d835..ab137e28cad 100644 --- a/src/objective-c/tests/EnableCronet.m +++ b/src/objective-c/tests/ConfigureCronet.m @@ -18,13 +18,13 @@ #ifdef GRPC_COMPILE_WITH_CRONET -#import "EnableCronet.h" +#import "ConfigureCronet.h" #import -void enableCronet(void) { - static dispatch_once_t enableCronet; - dispatch_once(&enableCronet, ^{ - NSLog(@"enableCronet()"); +void configureCronet(void) { + static dispatch_once_t configureCronet; + dispatch_once(&configureCronet, ^{ + NSLog(@"configureCronet()"); [Cronet setHttp2Enabled:YES]; [Cronet setSslKeyLogFileName:@"Documents/key"]; [Cronet enableTestCertVerifierForTesting]; diff --git a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm index 034d06b1976..a24734024dc 100644 --- a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm +++ b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm @@ -49,7 +49,7 @@ #import #include -#import "../EnableCronet.h" +#import "../ConfigureCronet.h" typedef struct fullstack_secure_fixture_data { char *localaddr; @@ -178,7 +178,7 @@ static char *roots_filename; grpc_init(); - enableCronet(); + configureCronet(); } // The tearDown() function is run after all test cases finish running diff --git a/src/objective-c/tests/CronetTests/CronetUnitTests.mm b/src/objective-c/tests/CronetTests/CronetUnitTests.mm index b0f3a3000f1..5ae0d77e37f 100644 --- a/src/objective-c/tests/CronetTests/CronetUnitTests.mm +++ b/src/objective-c/tests/CronetTests/CronetUnitTests.mm @@ -20,7 +20,7 @@ #import #import -#import "../EnableCronet.h" +#import "../ConfigureCronet.h" #import #import @@ -40,8 +40,8 @@ #import "test/core/util/test_config.h" #define GRPC_SHADOW_BORINGSSL_SYMBOLS -#import " #import "src/core/tsi/grpc_shadow_boringssl.h" +#import " static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; @@ -63,7 +63,7 @@ static void drain_cq(grpc_completion_queue *cq) { grpc_test_init(1, argv); grpc_init(); - enableCronet(); + configureCronet(); init_ssl(); } diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 89f5b96c38b..767c7c9c3c5 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -36,7 +36,7 @@ #import #import -#import "../EnableCronet.h" +#import "../ConfigureCronet.h" #import "InteropTestsBlockCallbacks.h" #define TEST_TIMEOUT 32 @@ -115,7 +115,7 @@ BOOL isRemoteInteropTest(NSString *host) { + (void)setUp { NSLog(@"InteropTest Started, class: %@", [[self class] description]); #ifdef GRPC_COMPILE_WITH_CRONET - enableCronet(); + configureCronet(); if ([self useCronet]) { [GRPCCall useCronetWithEngine:[Cronet getGlobalEngine]]; } diff --git a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m index ffda48719e7..14ba2871aa2 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m +++ b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m @@ -26,7 +26,7 @@ #import #import -#import "../EnableCronet.h" +#import "../ConfigureCronet.h" #import "InteropTestsBlockCallbacks.h" #define NSStringize_helper(x) #x @@ -87,7 +87,7 @@ dispatch_once_t initCronet; _remoteService = [RMTTestService serviceWithHost:kRemoteSSLHost callOptions:nil]; - enableCronet(); + configureCronet(); // Default stack with remote host GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile index c9d620ca2e9..60d2a98fba2 100644 --- a/src/objective-c/tests/Podfile +++ b/src/objective-c/tests/Podfile @@ -21,24 +21,20 @@ target 'MacTests' do pod 'RemoteTest', :path => "RemoteTestClient", :inhibit_warnings => true end -%w( - UnitTests -).each do |target_name| - target target_name do - platform :ios, '8.0' - pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf", :inhibit_warnings => true +target 'UnitTests' do + platform :ios, '8.0' + pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf", :inhibit_warnings => true - pod '!ProtoCompiler', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" - pod '!ProtoCompiler-gRPCPlugin', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" + pod '!ProtoCompiler', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" + pod '!ProtoCompiler-gRPCPlugin', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" - pod 'BoringSSL-GRPC', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true + pod 'BoringSSL-GRPC', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true - pod 'gRPC', :path => GRPC_LOCAL_SRC - pod 'gRPC-Core', :path => GRPC_LOCAL_SRC - pod 'gRPC-RxLibrary', :path => GRPC_LOCAL_SRC - pod 'gRPC-ProtoRPC', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true - pod 'RemoteTest', :path => "RemoteTestClient", :inhibit_warnings => true - end + pod 'gRPC', :path => GRPC_LOCAL_SRC + pod 'gRPC-Core', :path => GRPC_LOCAL_SRC + pod 'gRPC-RxLibrary', :path => GRPC_LOCAL_SRC + pod 'gRPC-ProtoRPC', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true + pod 'RemoteTest', :path => "RemoteTestClient", :inhibit_warnings => true end %w( diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index c226e29d83b..737d52b547d 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -11,8 +11,8 @@ 5E3F14842278B461007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; 5E3F14852278BF5D007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; 5E3F14862278BFFF007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; - 5E3F148D22792856007C6D90 /* EnableCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F1487227918AA007C6D90 /* EnableCronet.m */; }; - 5E3F148E22792AF5007C6D90 /* EnableCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F1487227918AA007C6D90 /* EnableCronet.m */; }; + 5E3F148D22792856007C6D90 /* ConfigureCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F1487227918AA007C6D90 /* ConfigureCronet.m */; }; + 5E3F148E22792AF5007C6D90 /* ConfigureCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F1487227918AA007C6D90 /* ConfigureCronet.m */; }; 5E7F486422775B37006656AD /* InteropTestsRemoteWithCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE84BF31D4717E40050C6CC /* InteropTestsRemoteWithCronet.m */; }; 5E7F486522775B41006656AD /* CronetUnitTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5EAD6D261E27047400002378 /* CronetUnitTests.mm */; }; 5E7F486E22778086006656AD /* CoreCronetEnd2EndTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F486D22778086006656AD /* CoreCronetEnd2EndTests.mm */; }; @@ -94,8 +94,8 @@ 5E0282E8215AA697007AC99D /* NSErrorUnitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NSErrorUnitTests.m; sourceTree = ""; }; 5E3F14822278B42D007C6D90 /* InteropTestsBlockCallbacks.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InteropTestsBlockCallbacks.h; sourceTree = ""; }; 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InteropTestsBlockCallbacks.m; sourceTree = ""; }; - 5E3F1487227918AA007C6D90 /* EnableCronet.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EnableCronet.m; sourceTree = ""; }; - 5E3F148A227918C4007C6D90 /* EnableCronet.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EnableCronet.h; sourceTree = ""; }; + 5E3F1487227918AA007C6D90 /* ConfigureCronet.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ConfigureCronet.m; sourceTree = ""; }; + 5E3F148A227918C4007C6D90 /* ConfigureCronet.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ConfigureCronet.h; sourceTree = ""; }; 5E7F485922775B15006656AD /* CronetTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CronetTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 5E7F486622776AD8006656AD /* Cronet.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cronet.framework; path = Pods/CronetFramework/Cronet.framework; sourceTree = ""; }; 5E7F486D22778086006656AD /* CoreCronetEnd2EndTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CoreCronetEnd2EndTests.mm; sourceTree = ""; }; @@ -396,8 +396,8 @@ 635697C91B14FC11007A7283 /* Tests */ = { isa = PBXGroup; children = ( - 5E3F148A227918C4007C6D90 /* EnableCronet.h */, - 5E3F1487227918AA007C6D90 /* EnableCronet.m */, + 5E3F148A227918C4007C6D90 /* ConfigureCronet.h */, + 5E3F1487227918AA007C6D90 /* ConfigureCronet.m */, 5EAFE8271F8EFB87007F2189 /* version.h */, 635697D71B14FC11007A7283 /* Supporting Files */, ); @@ -537,6 +537,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = 635697BE1B14FC11007A7283; @@ -591,15 +592,11 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-frameworks.sh", "${PODS_ROOT}/CronetFramework/Cronet.framework", ); name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - ); outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", ); @@ -613,15 +610,11 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-frameworks.sh", "${PODS_ROOT}/CronetFramework/Cronet.framework", ); name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - ); outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", ); @@ -635,15 +628,11 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - ); outputPaths = ( "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", ); @@ -679,15 +668,11 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-MacTests/Pods-MacTests-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-macOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - ); outputPaths = ( "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", ); @@ -741,15 +726,11 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - ); outputPaths = ( "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", ); @@ -819,7 +800,7 @@ buildActionMask = 2147483647; files = ( 5E3F14852278BF5D007C6D90 /* InteropTestsBlockCallbacks.m in Sources */, - 5E3F148D22792856007C6D90 /* EnableCronet.m in Sources */, + 5E3F148D22792856007C6D90 /* ConfigureCronet.m in Sources */, 5E7F486E22778086006656AD /* CoreCronetEnd2EndTests.mm in Sources */, 5E7F488522778A88006656AD /* InteropTests.m in Sources */, 5E7F486422775B37006656AD /* InteropTestsRemoteWithCronet.m in Sources */, @@ -832,7 +813,7 @@ buildActionMask = 2147483647; files = ( 5E3F14842278B461007C6D90 /* InteropTestsBlockCallbacks.m in Sources */, - 5E3F148E22792AF5007C6D90 /* EnableCronet.m in Sources */, + 5E3F148E22792AF5007C6D90 /* ConfigureCronet.m in Sources */, 5E7F488922778B04006656AD /* InteropTestsRemote.m in Sources */, 5E7F487922778226006656AD /* InteropTestsMultipleChannels.m in Sources */, 5EA477042273617B000F72FC /* InteropTestsLocalCleartext.m in Sources */, diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme index a2b1614b991..adb3c366af2 100644 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme +++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme @@ -86,7 +86,7 @@ + buildConfiguration = "Cronet"> Date: Fri, 24 May 2019 10:58:14 -0700 Subject: [PATCH 0318/1555] Swap java interop tests to openjdk8 Since openjdk8 is dead to us (see #19113), we cannot leave openjdk8 in the list of runtimes in client_matrix.py. The list of runtimes is now the defaults to use, which includes master, and you can specify alternative runtimes per-release. Fixes #19113 --- .../Dockerfile.include | 6 +- .../grpc_interop_java/Dockerfile.template | 3 +- .../build_interop.sh.template | 2 +- .../grpc_interop_java/java_deps.include | 17 --- .../Dockerfile.template | 3 - .../build_interop.sh.template | 3 - .../java_deps.include | 12 --- .../interoptest/grpc_interop_java/Dockerfile | 18 +--- .../grpc_interop_java/build_interop.sh | 2 +- .../grpc_interop_java_oracle8/Dockerfile | 34 ------ .../build_interop.sh | 44 -------- tools/interop_matrix/README.md | 6 +- tools/interop_matrix/client_matrix.py | 100 +++++++++--------- 13 files changed, 64 insertions(+), 186 deletions(-) rename templates/tools/dockerfile/interoptest/{grpc_interop_java_oracle8 => grpc_interop_java}/Dockerfile.include (63%) delete mode 100644 templates/tools/dockerfile/interoptest/grpc_interop_java/java_deps.include delete mode 100644 templates/tools/dockerfile/interoptest/grpc_interop_java_oracle8/Dockerfile.template delete mode 100644 templates/tools/dockerfile/interoptest/grpc_interop_java_oracle8/build_interop.sh.template delete mode 100644 templates/tools/dockerfile/interoptest/grpc_interop_java_oracle8/java_deps.include delete mode 100644 tools/dockerfile/interoptest/grpc_interop_java_oracle8/Dockerfile delete mode 100644 tools/dockerfile/interoptest/grpc_interop_java_oracle8/build_interop.sh diff --git a/templates/tools/dockerfile/interoptest/grpc_interop_java_oracle8/Dockerfile.include b/templates/tools/dockerfile/interoptest/grpc_interop_java/Dockerfile.include similarity index 63% rename from templates/tools/dockerfile/interoptest/grpc_interop_java_oracle8/Dockerfile.include rename to templates/tools/dockerfile/interoptest/grpc_interop_java/Dockerfile.include index 7307e29f0a0..c0b2b745c14 100644 --- a/templates/tools/dockerfile/interoptest/grpc_interop_java_oracle8/Dockerfile.include +++ b/templates/tools/dockerfile/interoptest/grpc_interop_java/Dockerfile.include @@ -14,7 +14,11 @@ <%include file="../../debian_jessie_header.include"/> -<%include file="java_deps.include"/> +RUN echo "deb http://archive.debian.org/debian/ jessie-backports main contrib non-free" > /etc/apt/sources.list.d/jessie-backports.list && ${'\\'} + echo 'Acquire::Check-Valid-Until no;' > /etc/apt/apt.conf.d/99no-check-valid-until && ${'\\'} + apt-get update && ${'\\'} + apt-get install -y --no-install-recommends -t jessie-backports openjdk-8-jdk-headless && ${'\\'} + apt-get clean # Define the default command. CMD ["bash"] diff --git a/templates/tools/dockerfile/interoptest/grpc_interop_java/Dockerfile.template b/templates/tools/dockerfile/interoptest/grpc_interop_java/Dockerfile.template index 74d01809e22..8eaa9a9dbbc 100644 --- a/templates/tools/dockerfile/interoptest/grpc_interop_java/Dockerfile.template +++ b/templates/tools/dockerfile/interoptest/grpc_interop_java/Dockerfile.template @@ -1,4 +1,3 @@ %YAML 1.2 --- | - <%include file="../grpc_interop_java_oracle8/Dockerfile.include"/> - + <%include file="Dockerfile.include"/> diff --git a/templates/tools/dockerfile/interoptest/grpc_interop_java/build_interop.sh.template b/templates/tools/dockerfile/interoptest/grpc_interop_java/build_interop.sh.template index 42eb4d8b96e..db5d40d5488 100644 --- a/templates/tools/dockerfile/interoptest/grpc_interop_java/build_interop.sh.template +++ b/templates/tools/dockerfile/interoptest/grpc_interop_java/build_interop.sh.template @@ -1,3 +1,3 @@ %YAML 1.2 --- | - <%include file="../../java_build_interop.sh.include"/> + <%include file="../../java_build_interop.sh.include"/> diff --git a/templates/tools/dockerfile/interoptest/grpc_interop_java/java_deps.include b/templates/tools/dockerfile/interoptest/grpc_interop_java/java_deps.include deleted file mode 100644 index 40d70e06d1a..00000000000 --- a/templates/tools/dockerfile/interoptest/grpc_interop_java/java_deps.include +++ /dev/null @@ -1,17 +0,0 @@ -# Install JDK 8 and Git -# -RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && ${'\\'} - echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list && ${'\\'} - echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list && ${'\\'} - apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 - -RUN apt-get update && apt-get -y install ${'\\'} - git ${'\\'} - libapr1 ${'\\'} - oracle-java8-installer ${'\\'} - && ${'\\'} - apt-get clean && rm -r /var/cache/oracle-jdk8-installer/ - -ENV JAVA_HOME /usr/lib/jvm/java-8-oracle -ENV PATH $PATH:$JAVA_HOME/bin - diff --git a/templates/tools/dockerfile/interoptest/grpc_interop_java_oracle8/Dockerfile.template b/templates/tools/dockerfile/interoptest/grpc_interop_java_oracle8/Dockerfile.template deleted file mode 100644 index 8eaa9a9dbbc..00000000000 --- a/templates/tools/dockerfile/interoptest/grpc_interop_java_oracle8/Dockerfile.template +++ /dev/null @@ -1,3 +0,0 @@ -%YAML 1.2 ---- | - <%include file="Dockerfile.include"/> diff --git a/templates/tools/dockerfile/interoptest/grpc_interop_java_oracle8/build_interop.sh.template b/templates/tools/dockerfile/interoptest/grpc_interop_java_oracle8/build_interop.sh.template deleted file mode 100644 index db5d40d5488..00000000000 --- a/templates/tools/dockerfile/interoptest/grpc_interop_java_oracle8/build_interop.sh.template +++ /dev/null @@ -1,3 +0,0 @@ -%YAML 1.2 ---- | - <%include file="../../java_build_interop.sh.include"/> diff --git a/templates/tools/dockerfile/interoptest/grpc_interop_java_oracle8/java_deps.include b/templates/tools/dockerfile/interoptest/grpc_interop_java_oracle8/java_deps.include deleted file mode 100644 index c05b5642393..00000000000 --- a/templates/tools/dockerfile/interoptest/grpc_interop_java_oracle8/java_deps.include +++ /dev/null @@ -1,12 +0,0 @@ -# Install JDK 8 -# -RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && ${'\\'} - echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list && ${'\\'} - echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list && ${'\\'} - apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 && ${'\\'} - apt-get update && apt-get -y install oracle-java8-installer && ${'\\'} - apt-get clean && rm -r /var/cache/oracle-jdk8-installer/ - -ENV JAVA_HOME /usr/lib/jvm/java-8-oracle -ENV PATH $PATH:$JAVA_HOME/bin - diff --git a/tools/dockerfile/interoptest/grpc_interop_java/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_java/Dockerfile index 979c14db3f6..b7664b3c4c1 100644 --- a/tools/dockerfile/interoptest/grpc_interop_java/Dockerfile +++ b/tools/dockerfile/interoptest/grpc_interop_java/Dockerfile @@ -15,19 +15,11 @@ FROM debian:jessie -# Install JDK 8 -# -RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \ - echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list && \ - echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list && \ - apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 && \ - apt-get update && apt-get -y install oracle-java8-installer && \ - apt-get clean && rm -r /var/cache/oracle-jdk8-installer/ - -ENV JAVA_HOME /usr/lib/jvm/java-8-oracle -ENV PATH $PATH:$JAVA_HOME/bin - - +RUN echo "deb http://archive.debian.org/debian/ jessie-backports main contrib non-free" > /etc/apt/sources.list.d/jessie-backports.list && \ + echo 'Acquire::Check-Valid-Until no;' > /etc/apt/apt.conf.d/99no-check-valid-until && \ + apt-get update && \ + apt-get install -y --no-install-recommends -t jessie-backports openjdk-8-jdk-headless && \ + apt-get clean # Define the default command. CMD ["bash"] diff --git a/tools/dockerfile/interoptest/grpc_interop_java/build_interop.sh b/tools/dockerfile/interoptest/grpc_interop_java/build_interop.sh index 8e1154679d7..77d322882f7 100644 --- a/tools/dockerfile/interoptest/grpc_interop_java/build_interop.sh +++ b/tools/dockerfile/interoptest/grpc_interop_java/build_interop.sh @@ -41,4 +41,4 @@ java.util.logging.ConsoleHandler.level = ALL .level = FINE io.grpc.netty.NettyClientHandler = ALL io.grpc.netty.NettyServerHandler = ALL" > /var/local/grpc_java_logging/logconf.txt - + diff --git a/tools/dockerfile/interoptest/grpc_interop_java_oracle8/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_java_oracle8/Dockerfile deleted file mode 100644 index 979c14db3f6..00000000000 --- a/tools/dockerfile/interoptest/grpc_interop_java_oracle8/Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FROM debian:jessie - - -# Install JDK 8 -# -RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \ - echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list && \ - echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list && \ - apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 && \ - apt-get update && apt-get -y install oracle-java8-installer && \ - apt-get clean && rm -r /var/cache/oracle-jdk8-installer/ - -ENV JAVA_HOME /usr/lib/jvm/java-8-oracle -ENV PATH $PATH:$JAVA_HOME/bin - - - -# Define the default command. -CMD ["bash"] - diff --git a/tools/dockerfile/interoptest/grpc_interop_java_oracle8/build_interop.sh b/tools/dockerfile/interoptest/grpc_interop_java_oracle8/build_interop.sh deleted file mode 100644 index 77d322882f7..00000000000 --- a/tools/dockerfile/interoptest/grpc_interop_java_oracle8/build_interop.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# Copyright 2015 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Builds Java interop server and client in a base image. -set -e - -cp -r /var/local/jenkins/grpc-java /tmp/grpc-java - -# copy service account keys if available -cp -r /var/local/jenkins/service_account $HOME || true - -pushd /tmp/grpc-java -./gradlew :grpc-interop-testing:installDist -PskipCodegen=true - -mkdir -p /var/local/git/grpc-java/ -cp -r --parents -t /var/local/git/grpc-java/ \ - interop-testing/build/install/ \ - run-test-client.sh \ - run-test-server.sh - -popd -rm -r /tmp/grpc-java -rm -r "$HOME/.gradle" - -# enable extra java logging -mkdir -p /var/local/grpc_java_logging -echo "handlers = java.util.logging.ConsoleHandler -java.util.logging.ConsoleHandler.level = ALL -.level = FINE -io.grpc.netty.NettyClientHandler = ALL -io.grpc.netty.NettyServerHandler = ALL" > /var/local/grpc_java_logging/logconf.txt - diff --git a/tools/interop_matrix/README.md b/tools/interop_matrix/README.md index 9d5c777cdee..2b37ee7d033 100644 --- a/tools/interop_matrix/README.md +++ b/tools/interop_matrix/README.md @@ -12,11 +12,11 @@ We have continuous nightly test setup to test gRPC backward compatibility betwee - `tools/interop_matrix/create_matrix_images.py --git_checkout --release=v1.9.9 --upload_images --language cxx csharp python ruby php` - Verify that the new docker image was built successfully and uploaded to GCR. For example, - `gcloud container images list --repository gcr.io/grpc-testing` lists available images. - - `gcloud container images list-tags gcr.io/grpc-testing/grpc_interop_java_oracle8` should show an image entry with tag `v1.9.9`. + - `gcloud container images list-tags gcr.io/grpc-testing/grpc_interop_java` should show an image entry with tag `v1.9.9`. - images can also be viewed in https://pantheon.corp.google.com/gcr/images/grpc-testing?project=grpc-testing - Verify the just-created docker client image would pass backward compatibility test (it should). For example, - - `gcloud docker -- pull gcr.io/grpc-testing/grpc_interop_java_oracle8:v1.9.9` followed by - - `docker_image=gcr.io/grpc-testing/grpc_interop_java_oracle8:v1.9.9 tools/interop_matrix/testcases/java__master` + - `gcloud docker -- pull gcr.io/grpc-testing/grpc_interop_java:v1.9.9` followed by + - `docker_image=gcr.io/grpc-testing/grpc_interop_java:v1.9.9 tools/interop_matrix/testcases/java__master` - git commit the change and merge it to upstream/master. - (Optional) clean up the tmp directory to where grpc source is cloned at `/export/hda3/tmp/grpc_matrix/`. For more details on each step, refer to sections below. diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index f9c069f6389..56fbbcab033 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -37,12 +37,8 @@ def get_runtimes_for_lang_release(lang, release): """Get list of valid runtimes for given release of lang.""" runtimes = list(LANG_RUNTIME_MATRIX[lang]) release_info = LANG_RELEASE_MATRIX[lang].get(release) - if release_info and release_info.runtime_subset: - runtimes = list(release_info.runtime_subset) - - # check that all selected runtimes are valid for given language - for runtime in runtimes: - assert runtime in LANG_RUNTIME_MATRIX[lang] + if release_info and release_info.runtimes: + runtimes = list(release_info.runtimes) return runtimes @@ -55,11 +51,11 @@ def should_build_docker_interop_image_from_release_tag(lang): return True -# Dictionary of runtimes per language +# Dictionary of default runtimes per language LANG_RUNTIME_MATRIX = { 'cxx': ['cxx'], # This is actually debian8. 'go': ['go1.8', 'go1.11'], - 'java': ['java_oracle8'], + 'java': ['java'], 'python': ['python'], 'node': ['node'], 'ruby': ['ruby'], @@ -71,9 +67,9 @@ LANG_RUNTIME_MATRIX = { class ReleaseInfo: """Info about a single release of a language""" - def __init__(self, patch=[], runtime_subset=[], testcases_file=None): + def __init__(self, patch=[], runtimes=[], testcases_file=None): self.patch = patch - self.runtime_subset = runtime_subset + self.runtimes = runtimes self.testcases_file = testcases_file @@ -104,51 +100,51 @@ LANG_RELEASE_MATRIX = { ]), 'go': OrderedDict([ - ('v1.0.5', ReleaseInfo(runtime_subset=['go1.8'])), - ('v1.2.1', ReleaseInfo(runtime_subset=['go1.8'])), - ('v1.3.0', ReleaseInfo(runtime_subset=['go1.8'])), - ('v1.4.2', ReleaseInfo(runtime_subset=['go1.8'])), - ('v1.5.2', ReleaseInfo(runtime_subset=['go1.8'])), - ('v1.6.0', ReleaseInfo(runtime_subset=['go1.8'])), - ('v1.7.4', ReleaseInfo(runtime_subset=['go1.8'])), - ('v1.8.2', ReleaseInfo(runtime_subset=['go1.8'])), - ('v1.9.2', ReleaseInfo(runtime_subset=['go1.8'])), - ('v1.10.1', ReleaseInfo(runtime_subset=['go1.8'])), - ('v1.11.3', ReleaseInfo(runtime_subset=['go1.8'])), - ('v1.12.2', ReleaseInfo(runtime_subset=['go1.8'])), - ('v1.13.0', ReleaseInfo(runtime_subset=['go1.8'])), - ('v1.14.0', ReleaseInfo(runtime_subset=['go1.8'])), - ('v1.15.0', ReleaseInfo(runtime_subset=['go1.8'])), - ('v1.16.0', ReleaseInfo(runtime_subset=['go1.8'])), - ('v1.17.0', ReleaseInfo(runtime_subset=['go1.11'])), - ('v1.18.0', ReleaseInfo(runtime_subset=['go1.11'])), - ('v1.19.0', ReleaseInfo(runtime_subset=['go1.11'])), - ('v1.20.0', ReleaseInfo(runtime_subset=['go1.11'])), - ('v1.21.0', ReleaseInfo(runtime_subset=['go1.11'])), + ('v1.0.5', ReleaseInfo(runtimes=['go1.8'])), + ('v1.2.1', ReleaseInfo(runtimes=['go1.8'])), + ('v1.3.0', ReleaseInfo(runtimes=['go1.8'])), + ('v1.4.2', ReleaseInfo(runtimes=['go1.8'])), + ('v1.5.2', ReleaseInfo(runtimes=['go1.8'])), + ('v1.6.0', ReleaseInfo(runtimes=['go1.8'])), + ('v1.7.4', ReleaseInfo(runtimes=['go1.8'])), + ('v1.8.2', ReleaseInfo(runtimes=['go1.8'])), + ('v1.9.2', ReleaseInfo(runtimes=['go1.8'])), + ('v1.10.1', ReleaseInfo(runtimes=['go1.8'])), + ('v1.11.3', ReleaseInfo(runtimes=['go1.8'])), + ('v1.12.2', ReleaseInfo(runtimes=['go1.8'])), + ('v1.13.0', ReleaseInfo(runtimes=['go1.8'])), + ('v1.14.0', ReleaseInfo(runtimes=['go1.8'])), + ('v1.15.0', ReleaseInfo(runtimes=['go1.8'])), + ('v1.16.0', ReleaseInfo(runtimes=['go1.8'])), + ('v1.17.0', ReleaseInfo(runtimes=['go1.11'])), + ('v1.18.0', ReleaseInfo(runtimes=['go1.11'])), + ('v1.19.0', ReleaseInfo(runtimes=['go1.11'])), + ('v1.20.0', ReleaseInfo(runtimes=['go1.11'])), + ('v1.21.0', ReleaseInfo(runtimes=['go1.11'])), ]), 'java': OrderedDict([ - ('v1.0.3', ReleaseInfo()), - ('v1.1.2', ReleaseInfo()), - ('v1.2.0', ReleaseInfo()), - ('v1.3.1', ReleaseInfo()), - ('v1.4.0', ReleaseInfo()), - ('v1.5.0', ReleaseInfo()), - ('v1.6.1', ReleaseInfo()), - ('v1.7.0', ReleaseInfo()), - ('v1.8.0', ReleaseInfo()), - ('v1.9.1', ReleaseInfo()), - ('v1.10.1', ReleaseInfo()), - ('v1.11.0', ReleaseInfo()), - ('v1.12.0', ReleaseInfo()), - ('v1.13.1', ReleaseInfo()), - ('v1.14.0', ReleaseInfo()), - ('v1.15.0', ReleaseInfo()), - ('v1.16.1', ReleaseInfo()), - ('v1.17.1', ReleaseInfo()), - ('v1.18.0', ReleaseInfo()), - ('v1.19.0', ReleaseInfo()), - ('v1.20.0', ReleaseInfo()), + ('v1.0.3', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.1.2', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.2.0', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.3.1', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.4.0', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.5.0', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.6.1', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.7.0', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.8.0', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.9.1', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.10.1', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.11.0', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.12.0', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.13.1', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.14.0', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.15.0', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.16.1', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.17.1', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.18.0', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.19.0', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.20.0', ReleaseInfo(runtimes=['java_oracle8'])), ]), 'python': OrderedDict([ From 155ca4be68571ea56f3dee85c11196c8c44e39b5 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 24 May 2019 12:37:33 -0700 Subject: [PATCH 0319/1555] Polish scheme configurations --- .../xcshareddata/xcschemes/CronetTests.xcscheme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CronetTests.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CronetTests.xcscheme index ac8cfc971c8..0156c906971 100644 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CronetTests.xcscheme +++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/CronetTests.xcscheme @@ -70,7 +70,7 @@ + buildConfiguration = "Cronet"> Date: Fri, 24 May 2019 12:51:14 -0700 Subject: [PATCH 0320/1555] clang-format --- src/objective-c/tests/CronetTests/CronetUnitTests.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/tests/CronetTests/CronetUnitTests.mm b/src/objective-c/tests/CronetTests/CronetUnitTests.mm index 5ae0d77e37f..595a1d19708 100644 --- a/src/objective-c/tests/CronetTests/CronetUnitTests.mm +++ b/src/objective-c/tests/CronetTests/CronetUnitTests.mm @@ -40,8 +40,8 @@ #import "test/core/util/test_config.h" #define GRPC_SHADOW_BORINGSSL_SYMBOLS -#import "src/core/tsi/grpc_shadow_boringssl.h" #import " +#import "src/core/tsi/grpc_shadow_boringssl.h" static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; From 886dc10daa669d96c7e9722a736efee60d5eaee3 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 24 May 2019 14:29:16 -0700 Subject: [PATCH 0321/1555] Move validate_service_config to a new file --- BUILD | 2 + BUILD.gn | 2 + CMakeLists.txt | 6 +++ Makefile | 6 +++ build.yaml | 2 + gRPC-C++.podspec | 2 + grpc.gyp | 2 + .../grpcpp/support/channel_arguments_impl.h | 9 ----- .../grpcpp/support/validate_service_config.h | 36 +++++++++++++++++ src/cpp/common/channel_arguments.cc | 18 --------- src/cpp/common/validate_service_config.cc | 40 +++++++++++++++++++ .../end2end/service_config_end2end_test.cc | 1 + tools/doxygen/Doxyfile.c++ | 3 +- tools/doxygen/Doxyfile.c++.internal | 2 + .../generated/sources_and_headers.json | 3 ++ 15 files changed, 106 insertions(+), 28 deletions(-) create mode 100644 include/grpcpp/support/validate_service_config.h create mode 100644 src/cpp/common/validate_service_config.cc diff --git a/BUILD b/BUILD index ddd1f97b541..edfc19a6080 100644 --- a/BUILD +++ b/BUILD @@ -137,6 +137,7 @@ GRPCXX_SRCS = [ "src/cpp/common/resource_quota_cc.cc", "src/cpp/common/rpc_method.cc", "src/cpp/common/version_cc.cc", + "src/cpp/common/validate_service_config.cc", "src/cpp/server/async_generic_service.cc", "src/cpp/server/channel_argument_option.cc", "src/cpp/server/create_default_thread_pool.cc", @@ -284,6 +285,7 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/support/stub_options.h", "include/grpcpp/support/sync_stream.h", "include/grpcpp/support/time.h", + "include/grpcpp/support/validate_service_config.h", ] grpc_cc_library( diff --git a/BUILD.gn b/BUILD.gn index dcd5bc880eb..8e493af7540 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1141,6 +1141,7 @@ config("grpc_config") { "include/grpcpp/support/stub_options.h", "include/grpcpp/support/sync_stream.h", "include/grpcpp/support/time.h", + "include/grpcpp/support/validate_service_config.h", "src/core/ext/transport/inproc/inproc_transport.h", "src/core/lib/avl/avl.h", "src/core/lib/backoff/backoff.h", @@ -1340,6 +1341,7 @@ config("grpc_config") { "src/cpp/common/secure_auth_context.h", "src/cpp/common/secure_channel_arguments.cc", "src/cpp/common/secure_create_auth_context.cc", + "src/cpp/common/validate_service_config.cc", "src/cpp/common/version_cc.cc", "src/cpp/server/async_generic_service.cc", "src/cpp/server/channel_argument_option.cc", diff --git a/CMakeLists.txt b/CMakeLists.txt index 429d083d279..c2da881909d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2977,6 +2977,7 @@ add_library(grpc++ src/cpp/common/core_codegen.cc src/cpp/common/resource_quota_cc.cc src/cpp/common/rpc_method.cc + src/cpp/common/validate_service_config.cc src/cpp/common/version_cc.cc src/cpp/server/async_generic_service.cc src/cpp/server/channel_argument_option.cc @@ -3151,6 +3152,7 @@ foreach(_hdr include/grpcpp/support/stub_options.h include/grpcpp/support/sync_stream.h include/grpcpp/support/time.h + include/grpcpp/support/validate_service_config.h include/grpc/support/alloc.h include/grpc/support/atm.h include/grpc/support/atm_gcc_atomic.h @@ -3373,6 +3375,7 @@ add_library(grpc++_cronet src/cpp/common/core_codegen.cc src/cpp/common/resource_quota_cc.cc src/cpp/common/rpc_method.cc + src/cpp/common/validate_service_config.cc src/cpp/common/version_cc.cc src/cpp/server/async_generic_service.cc src/cpp/server/channel_argument_option.cc @@ -3767,6 +3770,7 @@ foreach(_hdr include/grpcpp/support/stub_options.h include/grpcpp/support/sync_stream.h include/grpcpp/support/time.h + include/grpcpp/support/validate_service_config.h include/grpc/support/alloc.h include/grpc/support/atm.h include/grpc/support/atm_gcc_atomic.h @@ -4584,6 +4588,7 @@ add_library(grpc++_unsecure src/cpp/common/core_codegen.cc src/cpp/common/resource_quota_cc.cc src/cpp/common/rpc_method.cc + src/cpp/common/validate_service_config.cc src/cpp/common/version_cc.cc src/cpp/server/async_generic_service.cc src/cpp/server/channel_argument_option.cc @@ -4757,6 +4762,7 @@ foreach(_hdr include/grpcpp/support/stub_options.h include/grpcpp/support/sync_stream.h include/grpcpp/support/time.h + include/grpcpp/support/validate_service_config.h include/grpc/support/alloc.h include/grpc/support/atm.h include/grpc/support/atm_gcc_atomic.h diff --git a/Makefile b/Makefile index 605e533e8a8..a462b5c5074 100644 --- a/Makefile +++ b/Makefile @@ -5370,6 +5370,7 @@ LIBGRPC++_SRC = \ src/cpp/common/core_codegen.cc \ src/cpp/common/resource_quota_cc.cc \ src/cpp/common/rpc_method.cc \ + src/cpp/common/validate_service_config.cc \ src/cpp/common/version_cc.cc \ src/cpp/server/async_generic_service.cc \ src/cpp/server/channel_argument_option.cc \ @@ -5509,6 +5510,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ include/grpcpp/support/time.h \ + include/grpcpp/support/validate_service_config.h \ include/grpc/support/alloc.h \ include/grpc/support/atm.h \ include/grpc/support/atm_gcc_atomic.h \ @@ -5775,6 +5777,7 @@ LIBGRPC++_CRONET_SRC = \ src/cpp/common/core_codegen.cc \ src/cpp/common/resource_quota_cc.cc \ src/cpp/common/rpc_method.cc \ + src/cpp/common/validate_service_config.cc \ src/cpp/common/version_cc.cc \ src/cpp/server/async_generic_service.cc \ src/cpp/server/channel_argument_option.cc \ @@ -6133,6 +6136,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ include/grpcpp/support/time.h \ + include/grpcpp/support/validate_service_config.h \ include/grpc/support/alloc.h \ include/grpc/support/atm.h \ include/grpc/support/atm_gcc_atomic.h \ @@ -6933,6 +6937,7 @@ LIBGRPC++_UNSECURE_SRC = \ src/cpp/common/core_codegen.cc \ src/cpp/common/resource_quota_cc.cc \ src/cpp/common/rpc_method.cc \ + src/cpp/common/validate_service_config.cc \ src/cpp/common/version_cc.cc \ src/cpp/server/async_generic_service.cc \ src/cpp/server/channel_argument_option.cc \ @@ -7072,6 +7077,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ include/grpcpp/support/time.h \ + include/grpcpp/support/validate_service_config.h \ include/grpc/support/alloc.h \ include/grpc/support/atm.h \ include/grpc/support/atm_gcc_atomic.h \ diff --git a/build.yaml b/build.yaml index e2a1b75dda5..99820507a6f 100644 --- a/build.yaml +++ b/build.yaml @@ -1428,6 +1428,7 @@ filegroups: - include/grpcpp/support/stub_options.h - include/grpcpp/support/sync_stream.h - include/grpcpp/support/time.h + - include/grpcpp/support/validate_service_config.h headers: - src/cpp/client/create_channel_internal.h - src/cpp/common/channel_filter.h @@ -1451,6 +1452,7 @@ filegroups: - src/cpp/common/core_codegen.cc - src/cpp/common/resource_quota_cc.cc - src/cpp/common/rpc_method.cc + - src/cpp/common/validate_service_config.cc - src/cpp/common/version_cc.cc - src/cpp/server/async_generic_service.cc - src/cpp/server/channel_argument_option.cc diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 10e37bb5f47..17a87304aae 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -148,6 +148,7 @@ Pod::Spec.new do |s| 'include/grpcpp/support/stub_options.h', 'include/grpcpp/support/sync_stream.h', 'include/grpcpp/support/time.h', + 'include/grpcpp/support/validate_service_config.h', 'include/grpcpp/impl/codegen/async_generic_service.h', 'include/grpcpp/impl/codegen/async_stream.h', 'include/grpcpp/impl/codegen/async_unary_call.h', @@ -233,6 +234,7 @@ Pod::Spec.new do |s| 'src/cpp/common/core_codegen.cc', 'src/cpp/common/resource_quota_cc.cc', 'src/cpp/common/rpc_method.cc', + 'src/cpp/common/validate_service_config.cc', 'src/cpp/common/version_cc.cc', 'src/cpp/server/async_generic_service.cc', 'src/cpp/server/channel_argument_option.cc', diff --git a/grpc.gyp b/grpc.gyp index 833a0b48715..1668900a3c7 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -1447,6 +1447,7 @@ 'src/cpp/common/core_codegen.cc', 'src/cpp/common/resource_quota_cc.cc', 'src/cpp/common/rpc_method.cc', + 'src/cpp/common/validate_service_config.cc', 'src/cpp/common/version_cc.cc', 'src/cpp/server/async_generic_service.cc', 'src/cpp/server/channel_argument_option.cc', @@ -1602,6 +1603,7 @@ 'src/cpp/common/core_codegen.cc', 'src/cpp/common/resource_quota_cc.cc', 'src/cpp/common/rpc_method.cc', + 'src/cpp/common/validate_service_config.cc', 'src/cpp/common/version_cc.cc', 'src/cpp/server/async_generic_service.cc', 'src/cpp/server/channel_argument_option.cc', diff --git a/include/grpcpp/support/channel_arguments_impl.h b/include/grpcpp/support/channel_arguments_impl.h index a137a5b7c7d..0efeadca880 100644 --- a/include/grpcpp/support/channel_arguments_impl.h +++ b/include/grpcpp/support/channel_arguments_impl.h @@ -31,15 +31,6 @@ namespace grpc { namespace testing { class ChannelArgumentsTest; } // namespace testing - -namespace experimental { -/// Validates \a service_config_json. If valid, returns an empty string. -/// Otherwise, returns the validation error. -/// TODO(yashykt): Promote it to out of experimental once it is proved useful -/// and gRFC is accepted. -grpc::string ValidateServiceConfigJSON(const grpc::string& service_config_json); -} // namespace experimental - } // namespace grpc namespace grpc_impl { diff --git a/include/grpcpp/support/validate_service_config.h b/include/grpcpp/support/validate_service_config.h new file mode 100644 index 00000000000..d5ea521a1ef --- /dev/null +++ b/include/grpcpp/support/validate_service_config.h @@ -0,0 +1,36 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_VALIDATE_SERVICE_CONFIG_H +#define GRPCPP_SUPPORT_VALIDATE_SERVICE_CONFIG_H + +#include + +namespace grpc { + +namespace experimental { +/// Validates \a service_config_json. If valid, returns an empty string. +/// Otherwise, returns the validation error. +/// TODO(yashykt): Promote it to out of experimental once it is proved useful +/// and gRFC is accepted. +grpc::string ValidateServiceConfigJSON(const grpc::string& service_config_json); +} // namespace experimental + +} // namespace grpc + +#endif // GRPCPP_SUPPORT_VALIDATE_SERVICE_CONFIG_H \ No newline at end of file diff --git a/src/cpp/common/channel_arguments.cc b/src/cpp/common/channel_arguments.cc index b97e1ed8da9..f35c91572eb 100644 --- a/src/cpp/common/channel_arguments.cc +++ b/src/cpp/common/channel_arguments.cc @@ -217,21 +217,3 @@ void ChannelArguments::SetChannelArgs(grpc_channel_args* channel_args) const { } } // namespace grpc_impl - -namespace grpc { -namespace experimental { -grpc::string ValidateServiceConfigJSON( - const grpc::string& service_config_json) { - grpc_init(); - grpc_error* error = GRPC_ERROR_NONE; - grpc_core::ServiceConfig::Create(service_config_json.c_str(), &error); - grpc::string return_value; - if (error != GRPC_ERROR_NONE) { - return_value = grpc_error_string(error); - GRPC_ERROR_UNREF(error); - } - grpc_shutdown(); - return return_value; -} -} // namespace experimental -} // namespace grpc diff --git a/src/cpp/common/validate_service_config.cc b/src/cpp/common/validate_service_config.cc new file mode 100644 index 00000000000..0f193cf1c42 --- /dev/null +++ b/src/cpp/common/validate_service_config.cc @@ -0,0 +1,40 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +#include "src/core/ext/filters/client_channel/service_config.h" + +namespace grpc { +namespace experimental { +grpc::string ValidateServiceConfigJSON( + const grpc::string& service_config_json) { + grpc_init(); + grpc_error* error = GRPC_ERROR_NONE; + grpc_core::ServiceConfig::Create(service_config_json.c_str(), &error); + grpc::string return_value; + if (error != GRPC_ERROR_NONE) { + return_value = grpc_error_string(error); + GRPC_ERROR_UNREF(error); + } + grpc_shutdown(); + return return_value; +} +} // namespace experimental +} // namespace grpc diff --git a/test/cpp/end2end/service_config_end2end_test.cc b/test/cpp/end2end/service_config_end2end_test.cc index e5c3a8e3eff..14786b98f85 100644 --- a/test/cpp/end2end/service_config_end2end_test.cc +++ b/test/cpp/end2end/service_config_end2end_test.cc @@ -36,6 +36,7 @@ #include #include #include +#include #include "src/core/ext/filters/client_channel/backup_poller.h" #include "src/core/ext/filters/client_channel/global_subchannel_pool.h" diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 667b9b3541e..913d7be993b 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -1040,7 +1040,8 @@ include/grpcpp/support/status_code_enum.h \ include/grpcpp/support/string_ref.h \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ -include/grpcpp/support/time.h +include/grpcpp/support/time.h \ +include/grpcpp/support/validate_service_config.h # 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/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 529b35a2c39..58192bfc34b 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1043,6 +1043,7 @@ include/grpcpp/support/string_ref.h \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ include/grpcpp/support/time.h \ +include/grpcpp/support/validate_service_config.h \ src/core/ext/filters/client_channel/health/health.pb.c \ src/core/ext/filters/client_channel/health/health.pb.h \ src/core/ext/transport/inproc/inproc_transport.h \ @@ -1245,6 +1246,7 @@ src/cpp/common/secure_auth_context.cc \ src/cpp/common/secure_auth_context.h \ src/cpp/common/secure_channel_arguments.cc \ src/cpp/common/secure_create_auth_context.cc \ +src/cpp/common/validate_service_config.cc \ src/cpp/common/version_cc.cc \ src/cpp/server/async_generic_service.cc \ src/cpp/server/channel_argument_option.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index e67465d1602..677fff1d48b 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -10311,6 +10311,7 @@ "include/grpcpp/support/stub_options.h", "include/grpcpp/support/sync_stream.h", "include/grpcpp/support/time.h", + "include/grpcpp/support/validate_service_config.h", "src/cpp/client/create_channel_internal.h", "src/cpp/common/channel_filter.h", "src/cpp/server/dynamic_thread_pool.h", @@ -10436,6 +10437,7 @@ "include/grpcpp/support/stub_options.h", "include/grpcpp/support/sync_stream.h", "include/grpcpp/support/time.h", + "include/grpcpp/support/validate_service_config.h", "src/cpp/client/channel_cc.cc", "src/cpp/client/client_context.cc", "src/cpp/client/client_interceptor.cc", @@ -10453,6 +10455,7 @@ "src/cpp/common/core_codegen.cc", "src/cpp/common/resource_quota_cc.cc", "src/cpp/common/rpc_method.cc", + "src/cpp/common/validate_service_config.cc", "src/cpp/common/version_cc.cc", "src/cpp/server/async_generic_service.cc", "src/cpp/server/channel_argument_option.cc", From 49956702579c05f6c2e9535c1478d42a5768b3bb Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Fri, 24 May 2019 14:31:52 -0700 Subject: [PATCH 0322/1555] Add support to import envoy protos --- BUILD | 31 +++++++++++++++++++++++-------- WORKSPACE | 7 +++++++ bazel/grpc_deps.bzl | 9 +++++++-- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/BUILD b/BUILD index d36aba2387c..99dc61a86e9 100644 --- a/BUILD +++ b/BUILD @@ -33,6 +33,8 @@ load( "grpc_proto_plugin", ) +load("@upb//bazel:upb_proto_library.bzl", "upb_proto_library") + config_setting( name = "grpc_no_ares", values = {"define": "grpc_no_ares=true"}, @@ -2363,17 +2365,28 @@ grpc_cc_library( ], ) +upb_proto_library( + name = "upb_load_report", + deps = "@data_plane_api//envoy/api/v2/endpoint:load_report.proto" +) + + +upb_proto_library( + name = "upb_lrs", + deps = "@data_plane_api//envoy/service/load_stats/v2:lrs.proto" +) + #TODO: Get this into build.yaml once we start using it. grpc_cc_library( name = "envoy_lrs_upb", - srcs = [ - "src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c", - "src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c", - ], - hdrs = [ - "src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h", - "src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h", - ], +# srcs = [ +# "src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c", +# "src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c", +# ], +# hdrs = [ +# "src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h", +# "src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h", +# ], language = "c++", external_deps = [ "upb_lib", @@ -2382,6 +2395,8 @@ grpc_cc_library( ":envoy_core_upb", ":google_api_upb", ":proto_gen_validate_upb", + ":upb_load_report", + ":upb_lrs" ], tags = ["no_windows"], ) diff --git a/WORKSPACE b/WORKSPACE index 2db3c5db2ff..ad44ff05222 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -65,3 +65,10 @@ rbe_autoconfig( }, ), ) + + +load("@upb//bazel:workspace_deps.bzl", "upb_deps") +upb_deps() + +load("@data_plane_api//bazel:repositories.bzl", "api_dependencies") +api_dependencies() diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 74b36008771..7173a98c13e 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -216,8 +216,13 @@ def grpc_deps(): strip_prefix = "upb-d16bf99ac4658793748cda3251226059892b3b7b", url = "https://github.com/google/upb/archive/d16bf99ac4658793748cda3251226059892b3b7b.tar.gz", ) - load("@upb//bazel:workspace_deps.bzl", "upb_deps") - upb_deps() + if "data_plane_api" not in native.existing_rules(): + http_archive( + name = "data_plane_api", + sha256 = "9b9e0e3882df11f1a174aac7d78c2238a8bfbadad271b673f351a86137613cde", + strip_prefix = "data-plane-api-911001cdca003337bdb93fab32740cde61bafee3", + url = "https://github.com/envoyproxy/data-plane-api/archive/911001cdca003337bdb93fab32740cde61bafee3.tar.gz", + ) # TODO: move some dependencies from "grpc_deps" here? def grpc_test_only_deps(): From 384f15ab6eb68610d04b1149e1341564f428e2e4 Mon Sep 17 00:00:00 2001 From: yang-g Date: Fri, 24 May 2019 14:46:12 -0700 Subject: [PATCH 0323/1555] Delay calling plugin_creds callback --- .../credentials/plugin/plugin_credentials.cc | 62 +++++-------- .../credentials/plugin/plugin_credentials.h | 7 +- .../security/transport/client_auth_filter.cc | 2 - test/cpp/end2end/end2end_test.cc | 88 +++++++++++++++---- 4 files changed, 94 insertions(+), 65 deletions(-) diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/src/core/lib/security/credentials/plugin/plugin_credentials.cc index 333366d0f0a..8e926de59da 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.cc +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc @@ -54,15 +54,10 @@ void grpc_plugin_credentials::pending_request_remove_locked( } } -// Checks if the request has been cancelled. -// If not, removes it from the pending list, so that it cannot be -// cancelled out from under us. -// When this returns, r->cancelled indicates whether the request was -// cancelled before completion. void grpc_plugin_credentials::pending_request_complete(pending_request* r) { GPR_DEBUG_ASSERT(r->creds == this); gpr_mu_lock(&mu_); - if (!r->cancelled) pending_request_remove_locked(r); + pending_request_remove_locked(r); gpr_mu_unlock(&mu_); // Ref to credentials not needed anymore. Unref(); @@ -76,7 +71,8 @@ static grpc_error* process_plugin_result( char* msg; gpr_asprintf(&msg, "Getting metadata from plugin failed with error: %s", error_details); - error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg); + error = grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg), + GRPC_ERROR_INT_GRPC_STATUS, status); gpr_free(msg); } else { bool seen_illegal_header = false; @@ -95,7 +91,9 @@ static grpc_error* process_plugin_result( } } if (seen_illegal_header) { - error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal metadata"); + error = grpc_error_set_int( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal metadata."), + GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_INTERNAL); } else { for (size_t i = 0; i < num_md; ++i) { grpc_mdelem mdelem = @@ -125,19 +123,18 @@ static void plugin_md_request_metadata_ready(void* request, "asynchronously", r->creds, r); } - // Remove request from pending list if not previously cancelled. + // Remove request from pending list r->creds->pending_request_complete(r); // If it has not been cancelled, process it. - if (!r->cancelled) { - grpc_error* error = - process_plugin_result(r, md, num_md, status, error_details); - GRPC_CLOSURE_SCHED(r->on_request_metadata, error); + if (r->error == GRPC_ERROR_NONE) { + r->error = process_plugin_result(r, md, num_md, status, error_details); } else if (GRPC_TRACE_FLAG_ENABLED(grpc_plugin_credentials_trace)) { gpr_log(GPR_INFO, "plugin_credentials[%p]: request %p: plugin was previously " "cancelled", r->creds, r); } + GRPC_CLOSURE_SCHED(r->on_request_metadata, r->error); gpr_free(r); } @@ -145,11 +142,11 @@ bool grpc_plugin_credentials::get_request_metadata( grpc_polling_entity* pollent, grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata, grpc_error** error) { - bool retval = true; // Synchronous return. if (plugin_.get_metadata != nullptr) { // Create pending_request object. pending_request* request = static_cast(gpr_zalloc(sizeof(*request))); + request->error = GRPC_ERROR_NONE; request->creds = this; request->md_array = md_array; request->on_request_metadata = on_request_metadata; @@ -183,29 +180,16 @@ bool grpc_plugin_credentials::get_request_metadata( return false; // Asynchronous return. } // Returned synchronously. - // Remove request from pending list if not previously cancelled. + // Remove request from pending list. request->creds->pending_request_complete(request); - // If the request was cancelled, the error will have been returned - // asynchronously by plugin_cancel_get_request_metadata(), so return - // false. Otherwise, process the result. - if (request->cancelled) { - if (GRPC_TRACE_FLAG_ENABLED(grpc_plugin_credentials_trace)) { - gpr_log(GPR_INFO, - "plugin_credentials[%p]: request %p was cancelled, error " - "will be returned asynchronously", - this, request); - } - retval = false; - } else { - if (GRPC_TRACE_FLAG_ENABLED(grpc_plugin_credentials_trace)) { - gpr_log(GPR_INFO, - "plugin_credentials[%p]: request %p: plugin returned " - "synchronously", - this, request); - } - *error = process_plugin_result(request, creds_md, num_creds_md, status, - error_details); + if (GRPC_TRACE_FLAG_ENABLED(grpc_plugin_credentials_trace)) { + gpr_log(GPR_INFO, + "plugin_credentials[%p]: request %p: plugin returned " + "synchronously", + this, request); } + *error = process_plugin_result(request, creds_md, num_creds_md, status, + error_details); // Clean up. for (size_t i = 0; i < num_creds_md; ++i) { grpc_slice_unref_internal(creds_md[i].key); @@ -214,7 +198,7 @@ bool grpc_plugin_credentials::get_request_metadata( gpr_free((void*)error_details); gpr_free(request); } - return retval; + return true; // Synchronous return. } void grpc_plugin_credentials::cancel_get_request_metadata( @@ -227,15 +211,11 @@ void grpc_plugin_credentials::cancel_get_request_metadata( gpr_log(GPR_INFO, "plugin_credentials[%p]: cancelling request %p", this, pending_request); } - pending_request->cancelled = true; - GRPC_CLOSURE_SCHED(pending_request->on_request_metadata, - GRPC_ERROR_REF(error)); - pending_request_remove_locked(pending_request); + pending_request->error = error; break; } } gpr_mu_unlock(&mu_); - GRPC_ERROR_UNREF(error); } grpc_plugin_credentials::grpc_plugin_credentials( diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.h b/src/core/lib/security/credentials/plugin/plugin_credentials.h index 77a957e5137..7350b37f8a5 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.h +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.h @@ -31,7 +31,7 @@ extern grpc_core::TraceFlag grpc_plugin_credentials_trace; struct grpc_plugin_credentials final : public grpc_call_credentials { public: struct pending_request { - bool cancelled; + grpc_error* error; struct grpc_plugin_credentials* creds; grpc_credentials_mdelem_array* md_array; grpc_closure* on_request_metadata; @@ -51,11 +51,6 @@ struct grpc_plugin_credentials final : public grpc_call_credentials { void cancel_get_request_metadata(grpc_credentials_mdelem_array* md_array, grpc_error* error) override; - // Checks if the request has been cancelled. - // If not, removes it from the pending list, so that it cannot be - // cancelled out from under us. - // When this returns, r->cancelled indicates whether the request was - // cancelled before completion. void pending_request_complete(pending_request* r); private: diff --git a/src/core/lib/security/transport/client_auth_filter.cc b/src/core/lib/security/transport/client_auth_filter.cc index 0c40dd7ff1e..40393de2b13 100644 --- a/src/core/lib/security/transport/client_auth_filter.cc +++ b/src/core/lib/security/transport/client_auth_filter.cc @@ -160,8 +160,6 @@ static void on_credentials_metadata(void* arg, grpc_error* input_error) { if (error == GRPC_ERROR_NONE) { grpc_call_next_op(elem, batch); } else { - error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS, - GRPC_STATUS_UNAVAILABLE); grpc_transport_stream_op_batch_finish_with_failure(batch, error, calld->call_combiner); } diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index c027e5954ec..a505d1a633f 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -90,11 +90,13 @@ class TestMetadataCredentialsPlugin : public MetadataCredentialsPlugin { TestMetadataCredentialsPlugin(const grpc::string_ref& metadata_key, const grpc::string_ref& metadata_value, - bool is_blocking, bool is_successful) + bool is_blocking, bool is_successful, + int delay_ms) : metadata_key_(metadata_key.data(), metadata_key.length()), metadata_value_(metadata_value.data(), metadata_value.length()), is_blocking_(is_blocking), - is_successful_(is_successful) {} + is_successful_(is_successful), + delay_ms_(delay_ms) {} bool IsBlocking() const override { return is_blocking_; } @@ -102,6 +104,11 @@ class TestMetadataCredentialsPlugin : public MetadataCredentialsPlugin { grpc::string_ref service_url, grpc::string_ref method_name, const grpc::AuthContext& channel_auth_context, std::multimap* metadata) override { + if (delay_ms_ != 0) { + gpr_sleep_until( + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_millis(delay_ms_, GPR_TIMESPAN))); + } EXPECT_GT(service_url.length(), 0UL); EXPECT_GT(method_name.length(), 0UL); EXPECT_TRUE(channel_auth_context.IsPeerAuthenticated()); @@ -119,6 +126,7 @@ class TestMetadataCredentialsPlugin : public MetadataCredentialsPlugin { grpc::string metadata_value_; bool is_blocking_; bool is_successful_; + int delay_ms_; }; const char TestMetadataCredentialsPlugin::kBadMetadataKey[] = @@ -137,7 +145,7 @@ class TestAuthMetadataProcessor : public AuthMetadataProcessor { std::unique_ptr( new TestMetadataCredentialsPlugin( TestMetadataCredentialsPlugin::kGoodMetadataKey, kGoodGuy, - is_blocking_, true))); + is_blocking_, true, 0))); } std::shared_ptr GetIncompatibleClientCreds() { @@ -145,7 +153,7 @@ class TestAuthMetadataProcessor : public AuthMetadataProcessor { std::unique_ptr( new TestMetadataCredentialsPlugin( TestMetadataCredentialsPlugin::kGoodMetadataKey, "Mr Hyde", - is_blocking_, true))); + is_blocking_, true, 0))); } // Interface implementation @@ -1835,12 +1843,13 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginKeyFailure) { std::unique_ptr( new TestMetadataCredentialsPlugin( TestMetadataCredentialsPlugin::kBadMetadataKey, - "Does not matter, will fail the key is invalid.", false, true)))); + "Does not matter, will fail the key is invalid.", false, true, + 0)))); request.set_message("Hello"); Status s = stub_->Echo(&context, request, &response); EXPECT_FALSE(s.ok()); - EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE); + EXPECT_EQ(s.error_code(), StatusCode::INTERNAL); } TEST_P(SecureEnd2endTest, AuthMetadataPluginValueFailure) { @@ -1853,12 +1862,59 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginValueFailure) { std::unique_ptr( new TestMetadataCredentialsPlugin( TestMetadataCredentialsPlugin::kGoodMetadataKey, - "With illegal \n value.", false, true)))); + "With illegal \n value.", false, true, 0)))); request.set_message("Hello"); Status s = stub_->Echo(&context, request, &response); EXPECT_FALSE(s.ok()); - EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE); + EXPECT_EQ(s.error_code(), StatusCode::INTERNAL); +} + +TEST_P(SecureEnd2endTest, AuthMetadataPluginWithDeadline) { + MAYBE_SKIP_TEST; + ResetStub(); + EchoRequest request; + EchoResponse response; + ClientContext context; + const int delay = 100; + std::chrono::system_clock::time_point deadline = + std::chrono::system_clock::now() + std::chrono::milliseconds(delay); + context.set_deadline(deadline); + context.set_credentials(grpc::MetadataCredentialsFromPlugin( + std::unique_ptr( + new TestMetadataCredentialsPlugin("meta_key", "Does not matter", true, + true, delay)))); + request.set_message("Hello"); + + Status s = stub_->Echo(&context, request, &response); + if (!s.ok()) { + EXPECT_EQ(StatusCode::DEADLINE_EXCEEDED, s.error_code()); + } +} + +TEST_P(SecureEnd2endTest, AuthMetadataPluginWithCancel) { + MAYBE_SKIP_TEST; + ResetStub(); + EchoRequest request; + EchoResponse response; + ClientContext context; + const int delay = 100; + context.set_credentials(grpc::MetadataCredentialsFromPlugin( + std::unique_ptr( + new TestMetadataCredentialsPlugin("meta_key", "Does not matter", true, + true, delay)))); + request.set_message("Hello"); + + std::thread cancel_thread([&context] { + gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_millis(delay, GPR_TIMESPAN))); + context.TryCancel(); + }); + Status s = stub_->Echo(&context, request, &response); + if (!s.ok()) { + EXPECT_EQ(StatusCode::CANCELLED, s.error_code()); + } + cancel_thread.join(); } TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginFailure) { @@ -1871,13 +1927,13 @@ TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginFailure) { std::unique_ptr( new TestMetadataCredentialsPlugin( TestMetadataCredentialsPlugin::kGoodMetadataKey, - "Does not matter, will fail anyway (see 3rd param)", false, - false)))); + "Does not matter, will fail anyway (see 3rd param)", false, false, + 0)))); request.set_message("Hello"); Status s = stub_->Echo(&context, request, &response); EXPECT_FALSE(s.ok()); - EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE); + EXPECT_EQ(s.error_code(), StatusCode::NOT_FOUND); EXPECT_EQ(s.error_message(), grpc::string("Getting metadata from plugin failed with error: ") + kTestCredsPluginErrorMsg); @@ -1935,13 +1991,13 @@ TEST_P(SecureEnd2endTest, BlockingAuthMetadataPluginFailure) { std::unique_ptr( new TestMetadataCredentialsPlugin( TestMetadataCredentialsPlugin::kGoodMetadataKey, - "Does not matter, will fail anyway (see 3rd param)", true, - false)))); + "Does not matter, will fail anyway (see 3rd param)", true, false, + 0)))); request.set_message("Hello"); Status s = stub_->Echo(&context, request, &response); EXPECT_FALSE(s.ok()); - EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE); + EXPECT_EQ(s.error_code(), StatusCode::NOT_FOUND); EXPECT_EQ(s.error_message(), grpc::string("Getting metadata from plugin failed with error: ") + kTestCredsPluginErrorMsg); @@ -1962,11 +2018,11 @@ TEST_P(SecureEnd2endTest, CompositeCallCreds) { grpc::MetadataCredentialsFromPlugin( std::unique_ptr( new TestMetadataCredentialsPlugin(kMetadataKey1, kMetadataVal1, - true, true))), + true, true, 0))), grpc::MetadataCredentialsFromPlugin( std::unique_ptr( new TestMetadataCredentialsPlugin(kMetadataKey2, kMetadataVal2, - true, true))))); + true, true, 0))))); request.set_message("Hello"); request.mutable_param()->set_echo_metadata(true); From b1147052d362e13ee25418d0ee079b2d7ec626c3 Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Fri, 24 May 2019 14:10:11 -0700 Subject: [PATCH 0324/1555] cfstream_test: print HTTP2 stream id of completed RPCs Log stream id of completed RPCs. This helps in debugging test failures. --- test/cpp/end2end/cfstream_test.cc | 37 ++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/test/cpp/end2end/cfstream_test.cc b/test/cpp/end2end/cfstream_test.cc index 59cf98ffc20..b0c55616de3 100644 --- a/test/cpp/end2end/cfstream_test.cc +++ b/test/cpp/end2end/cfstream_test.cc @@ -42,6 +42,7 @@ #include "src/core/lib/gpr/env.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" +#include "test/core/util/debugger_macros.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" #include "test/cpp/end2end/test_service_impl.h" @@ -144,6 +145,18 @@ class CFStreamTest : public ::testing::TestWithParam { return CreateCustomChannel(server_address.str(), channel_creds, args); } + int GetStreamID(ClientContext& context) { + int stream_id = 0; + grpc_call* call = context.c_call(); + if (call) { + grpc_chttp2_stream* stream = grpc_chttp2_stream_from_call(call); + if (stream) { + stream_id = stream->id; + } + } + return stream_id; + } + void SendRpc( const std::unique_ptr& stub, bool expect_success = false) { @@ -153,10 +166,13 @@ class CFStreamTest : public ::testing::TestWithParam { request.set_message(msg); ClientContext context; Status status = stub->Echo(&context, request, response.get()); + int stream_id = GetStreamID(context); if (status.ok()) { + gpr_log(GPR_DEBUG, "RPC with stream_id %d succeeded", stream_id); EXPECT_EQ(msg, response->message()); } else { - gpr_log(GPR_DEBUG, "RPC failed: %s", status.error_message().c_str()); + gpr_log(GPR_DEBUG, "RPC with stream_id %d failed: %s", stream_id, + status.error_message().c_str()); } if (expect_success) { EXPECT_TRUE(status.ok()); @@ -359,14 +375,17 @@ TEST_P(CFStreamTest, NetworkFlapRpcsInFlight) { ++total_completions; GPR_ASSERT(ok); AsyncClientCall* call = static_cast(got_tag); + int stream_id = GetStreamID(call->context); if (!call->status.ok()) { - gpr_log(GPR_DEBUG, "RPC failed with error: %s", - call->status.error_message().c_str()); + gpr_log(GPR_DEBUG, "RPC with stream_id %d failed with error: %s", + stream_id, call->status.error_message().c_str()); // Bring network up when RPCs start failing if (network_down) { NetworkUp(); network_down = false; } + } else { + gpr_log(GPR_DEBUG, "RPC with stream_id %d succeeded", stream_id); } delete call; } @@ -393,21 +412,19 @@ TEST_P(CFStreamTest, ConcurrentRpc) { std::thread thd = std::thread([this, &rpcs_sent]() { void* got_tag; bool ok = false; - bool network_down = true; int total_completions = 0; while (CQNext(&got_tag, &ok)) { ++total_completions; GPR_ASSERT(ok); AsyncClientCall* call = static_cast(got_tag); + int stream_id = GetStreamID(call->context); if (!call->status.ok()) { - gpr_log(GPR_DEBUG, "RPC failed: %s", - call->status.error_message().c_str()); + gpr_log(GPR_DEBUG, "RPC with stream_id %d failed with error: %s", + stream_id, call->status.error_message().c_str()); // Bring network up when RPCs start failing - if (network_down) { - NetworkUp(); - network_down = false; - } + } else { + gpr_log(GPR_DEBUG, "RPC with stream_id %d succeeded", stream_id); } delete call; } From 49e7f4b2e46606d5950816edde95010c9555e468 Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Fri, 24 May 2019 16:04:43 -0700 Subject: [PATCH 0325/1555] Added more rules to resolve deps --- BUILD | 14 ++++++++++++-- WORKSPACE | 4 ++++ bazel/grpc_deps.bzl | 6 ++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index 99dc61a86e9..2b3c2b1d21e 100644 --- a/BUILD +++ b/BUILD @@ -2365,15 +2365,25 @@ grpc_cc_library( ], ) +proto_library( + name = "load_report_proto", + srcs = ["@data_plane_api//envoy/api/v2/endpoint:load_report.proto"] +) + upb_proto_library( name = "upb_load_report", - deps = "@data_plane_api//envoy/api/v2/endpoint:load_report.proto" + deps = [":load_report_proto"] ) +proto_library( + name = "lrs_proto", + srcs = ["@data_plane_api//envoy/service/load_stats/v2:lrs.proto"] +) + upb_proto_library( name = "upb_lrs", - deps = "@data_plane_api//envoy/service/load_stats/v2:lrs.proto" + deps = [":lrs_proto"] ) #TODO: Get this into build.yaml once we start using it. diff --git a/WORKSPACE b/WORKSPACE index ad44ff05222..755760efefc 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -72,3 +72,7 @@ upb_deps() load("@data_plane_api//bazel:repositories.bzl", "api_dependencies") api_dependencies() + +load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains") +go_rules_dependencies() +go_register_toolchains() diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 7173a98c13e..8cc2354ed78 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -224,6 +224,12 @@ def grpc_deps(): url = "https://github.com/envoyproxy/data-plane-api/archive/911001cdca003337bdb93fab32740cde61bafee3.tar.gz", ) + if "io_bazel_rules_go" not in native.existing_rules(): + http_archive( + name = "io_bazel_rules_go", + urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.18.5/rules_go-0.18.5.tar.gz"], + sha256 = "a82a352bffae6bee4e95f68a8d80a70e87f42c4741e6a448bec11998fcc82329", + ) # TODO: move some dependencies from "grpc_deps" here? def grpc_test_only_deps(): """Internal, not intended for use by packages that are consuming grpc. From 2c24998c360e866198440184a9eaa4887055cdc3 Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Fri, 24 May 2019 16:12:50 -0700 Subject: [PATCH 0326/1555] Trying to directly access envoy proto libs --- BUILD | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/BUILD b/BUILD index 2b3c2b1d21e..32cc58b5b31 100644 --- a/BUILD +++ b/BUILD @@ -2365,25 +2365,14 @@ grpc_cc_library( ], ) -proto_library( - name = "load_report_proto", - srcs = ["@data_plane_api//envoy/api/v2/endpoint:load_report.proto"] -) - upb_proto_library( name = "upb_load_report", - deps = [":load_report_proto"] -) - - -proto_library( - name = "lrs_proto", - srcs = ["@data_plane_api//envoy/service/load_stats/v2:lrs.proto"] + deps = ["@data_plane_api//envoy/api/v2/endpoint:load_report"] ) upb_proto_library( name = "upb_lrs", - deps = [":lrs_proto"] + deps = ["@data_plane_api//envoy/service/load_stats/v2:lrs"] ) #TODO: Get this into build.yaml once we start using it. From 67bdbbdf6f6592d63d6b0749f1e73a5c846b59fa Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 24 May 2019 16:58:56 -0700 Subject: [PATCH 0327/1555] Fix a bug where POST_RECV_MESSAGE is not being triggered --- include/grpcpp/impl/codegen/call_op_set.h | 7 +- .../client_interceptors_end2end_test.cc | 74 ++++++++++++++++++- test/cpp/end2end/interceptors_util.cc | 6 +- test/cpp/end2end/interceptors_util.h | 2 + 4 files changed, 79 insertions(+), 10 deletions(-) diff --git a/include/grpcpp/impl/codegen/call_op_set.h b/include/grpcpp/impl/codegen/call_op_set.h index d810625b3e4..fdd0b5e91b7 100644 --- a/include/grpcpp/impl/codegen/call_op_set.h +++ b/include/grpcpp/impl/codegen/call_op_set.h @@ -433,7 +433,9 @@ class CallOpRecvMessage { message_(nullptr), allow_not_getting_message_(false) {} - void RecvMessage(R* message) { message_ = message; } + void RecvMessage(R* message) { + message_ = message; + } // Do not change status if no message is received. void AllowNoMessage() { allow_not_getting_message_ = true; } @@ -468,7 +470,6 @@ class CallOpRecvMessage { *status = false; } } - message_ = nullptr; } void SetInterceptionHookPoint( @@ -565,7 +566,6 @@ class CallOpGenericRecvMessage { *status = false; } } - deserialize_.reset(); } void SetInterceptionHookPoint( @@ -580,6 +580,7 @@ class CallOpGenericRecvMessage { interceptor_methods->AddInterceptionHookPoint( experimental::InterceptionHookPoints::POST_RECV_MESSAGE); if (!got_message) interceptor_methods->SetRecvMessage(nullptr, nullptr); + deserialize_.reset(); } void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) { hijacked_ = true; diff --git a/test/cpp/end2end/client_interceptors_end2end_test.cc b/test/cpp/end2end/client_interceptors_end2end_test.cc index f1aed093dc4..70b0ecdf585 100644 --- a/test/cpp/end2end/client_interceptors_end2end_test.cc +++ b/test/cpp/end2end/client_interceptors_end2end_test.cc @@ -501,7 +501,14 @@ class BidiStreamingRpcHijackingInterceptorFactory class LoggingInterceptor : public experimental::Interceptor { public: - LoggingInterceptor(experimental::ClientRpcInfo* info) { info_ = info; } + LoggingInterceptor(experimental::ClientRpcInfo* info) : info_(info) { + pre_send_initial_metadata_ = false; + pre_send_message_count_ = 0; + pre_send_close_ = false; + post_recv_initial_metadata_ = false; + post_recv_message_count_ = 0; + post_recv_status_ = false; + } virtual void Intercept(experimental::InterceptorBatchMethods* methods) { if (methods->QueryInterceptionHookPoint( @@ -512,6 +519,8 @@ class LoggingInterceptor : public experimental::Interceptor { auto iterator = map->begin(); EXPECT_EQ("testkey", iterator->first); EXPECT_EQ("testvalue", iterator->second); + ASSERT_FALSE(pre_send_initial_metadata_); + pre_send_initial_metadata_ = true; } if (methods->QueryInterceptionHookPoint( experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)) { @@ -526,22 +535,28 @@ class LoggingInterceptor : public experimental::Interceptor { SerializationTraits::Deserialize(&copied_buffer, &req) .ok()); EXPECT_TRUE(req.message().find("Hello") == 0u); + pre_send_message_count_++; } if (methods->QueryInterceptionHookPoint( experimental::InterceptionHookPoints::PRE_SEND_CLOSE)) { // Got nothing to do here for now + pre_send_close_ = true; } if (methods->QueryInterceptionHookPoint( experimental::InterceptionHookPoints::POST_RECV_INITIAL_METADATA)) { auto* map = methods->GetRecvInitialMetadata(); // Got nothing better to do here for now EXPECT_EQ(map->size(), static_cast(0)); + post_recv_initial_metadata_ = true; } if (methods->QueryInterceptionHookPoint( experimental::InterceptionHookPoints::POST_RECV_MESSAGE)) { EchoResponse* resp = static_cast(methods->GetRecvMessage()); - EXPECT_TRUE(resp->message().find("Hello") == 0u); + if(resp != nullptr) { + EXPECT_TRUE(resp->message().find("Hello") == 0u); + post_recv_message_count_++; + } } if (methods->QueryInterceptionHookPoint( experimental::InterceptionHookPoints::POST_RECV_STATUS)) { @@ -556,14 +571,59 @@ class LoggingInterceptor : public experimental::Interceptor { EXPECT_EQ(found, true); auto* status = methods->GetRecvStatus(); EXPECT_EQ(status->ok(), true); + post_recv_status_ = true; } methods->Proceed(); } + static void VerifyCallCommon() { + EXPECT_TRUE(pre_send_initial_metadata_); + EXPECT_TRUE(pre_send_close_); + EXPECT_TRUE(post_recv_initial_metadata_); + EXPECT_TRUE(post_recv_status_); + } + + static void VerifyUnaryCall() { + VerifyCallCommon(); + EXPECT_EQ(pre_send_message_count_, 1); + EXPECT_EQ(post_recv_message_count_, 1); + } + + static void VerifyClientStreamingCall() { + VerifyCallCommon(); + EXPECT_EQ(pre_send_message_count_, kNumStreamingMessages); + EXPECT_EQ(post_recv_message_count_, 1); + } + + static void VerifyServerStreamingCall() { + VerifyCallCommon(); + EXPECT_EQ(pre_send_message_count_, 1); + EXPECT_EQ(post_recv_message_count_, kNumStreamingMessages); + } + + static void VerifyBidiStreamingCall() { + VerifyCallCommon(); + EXPECT_EQ(pre_send_message_count_, kNumStreamingMessages); + EXPECT_EQ(post_recv_message_count_, kNumStreamingMessages); + } + private: experimental::ClientRpcInfo* info_; + static bool pre_send_initial_metadata_; + static int pre_send_message_count_; + static bool pre_send_close_; + static bool post_recv_initial_metadata_; + static int post_recv_message_count_; + static bool post_recv_status_; }; +bool LoggingInterceptor::pre_send_initial_metadata_; +int LoggingInterceptor::pre_send_message_count_; +bool LoggingInterceptor::pre_send_close_; +bool LoggingInterceptor::post_recv_initial_metadata_; +int LoggingInterceptor::post_recv_message_count_; +bool LoggingInterceptor::post_recv_status_; + class LoggingInterceptorFactory : public experimental::ClientInterceptorFactoryInterface { public: @@ -607,6 +667,7 @@ TEST_F(ClientInterceptorsEnd2endTest, ClientInterceptorLoggingTest) { auto channel = experimental::CreateCustomChannelWithInterceptors( server_address_, InsecureChannelCredentials(), args, std::move(creators)); MakeCall(channel); + LoggingInterceptor::VerifyUnaryCall(); // Make sure all 20 dummy interceptors were run EXPECT_EQ(DummyInterceptor::GetNumTimesRun(), 20); } @@ -643,7 +704,6 @@ TEST_F(ClientInterceptorsEnd2endTest, ClientInterceptorHijackingTest) { } auto channel = experimental::CreateCustomChannelWithInterceptors( server_address_, InsecureChannelCredentials(), args, std::move(creators)); - MakeCall(channel); // Make sure only 20 dummy interceptors were run EXPECT_EQ(DummyInterceptor::GetNumTimesRun(), 20); @@ -659,8 +719,8 @@ TEST_F(ClientInterceptorsEnd2endTest, ClientInterceptorLogThenHijackTest) { new HijackingInterceptorFactory())); auto channel = experimental::CreateCustomChannelWithInterceptors( server_address_, InsecureChannelCredentials(), args, std::move(creators)); - MakeCall(channel); + LoggingInterceptor::VerifyUnaryCall(); } TEST_F(ClientInterceptorsEnd2endTest, @@ -708,6 +768,7 @@ TEST_F(ClientInterceptorsEnd2endTest, auto channel = server_->experimental().InProcessChannelWithInterceptors( args, std::move(creators)); MakeCallbackCall(channel); + LoggingInterceptor::VerifyUnaryCall(); // Make sure all 20 dummy interceptors were run EXPECT_EQ(DummyInterceptor::GetNumTimesRun(), 20); } @@ -730,6 +791,7 @@ TEST_F(ClientInterceptorsEnd2endTest, auto channel = server_->experimental().InProcessChannelWithInterceptors( args, std::move(creators)); MakeCallbackCall(channel); + LoggingInterceptor::VerifyUnaryCall(); // Make sure all 20 dummy interceptors were run EXPECT_EQ(DummyInterceptor::GetNumTimesRun(), 20); } @@ -768,6 +830,7 @@ TEST_F(ClientInterceptorsStreamingEnd2endTest, ClientStreamingTest) { auto channel = experimental::CreateCustomChannelWithInterceptors( server_address_, InsecureChannelCredentials(), args, std::move(creators)); MakeClientStreamingCall(channel); + LoggingInterceptor::VerifyClientStreamingCall(); // Make sure all 20 dummy interceptors were run EXPECT_EQ(DummyInterceptor::GetNumTimesRun(), 20); } @@ -787,6 +850,7 @@ TEST_F(ClientInterceptorsStreamingEnd2endTest, ServerStreamingTest) { auto channel = experimental::CreateCustomChannelWithInterceptors( server_address_, InsecureChannelCredentials(), args, std::move(creators)); MakeServerStreamingCall(channel); + LoggingInterceptor::VerifyServerStreamingCall(); // Make sure all 20 dummy interceptors were run EXPECT_EQ(DummyInterceptor::GetNumTimesRun(), 20); } @@ -862,6 +926,7 @@ TEST_F(ClientInterceptorsStreamingEnd2endTest, BidiStreamingTest) { auto channel = experimental::CreateCustomChannelWithInterceptors( server_address_, InsecureChannelCredentials(), args, std::move(creators)); MakeBidiStreamingCall(channel); + LoggingInterceptor::VerifyBidiStreamingCall(); // Make sure all 20 dummy interceptors were run EXPECT_EQ(DummyInterceptor::GetNumTimesRun(), 20); } @@ -928,6 +993,7 @@ TEST_F(ClientGlobalInterceptorEnd2endTest, LoggingGlobalInterceptor) { auto channel = experimental::CreateCustomChannelWithInterceptors( server_address_, InsecureChannelCredentials(), args, std::move(creators)); MakeCall(channel); + LoggingInterceptor::VerifyUnaryCall(); // Make sure all 20 dummy interceptors were run EXPECT_EQ(DummyInterceptor::GetNumTimesRun(), 20); experimental::TestOnlyResetGlobalClientInterceptorFactory(); diff --git a/test/cpp/end2end/interceptors_util.cc b/test/cpp/end2end/interceptors_util.cc index 900f02b5f36..6321c35ba4a 100644 --- a/test/cpp/end2end/interceptors_util.cc +++ b/test/cpp/end2end/interceptors_util.cc @@ -48,7 +48,7 @@ void MakeClientStreamingCall(const std::shared_ptr& channel) { EchoResponse resp; string expected_resp = ""; auto writer = stub->RequestStream(&ctx, &resp); - for (int i = 0; i < 10; i++) { + for (int i = 0; i < kNumStreamingMessages; i++) { writer->Write(req); expected_resp += "Hello"; } @@ -73,7 +73,7 @@ void MakeServerStreamingCall(const std::shared_ptr& channel) { EXPECT_EQ(resp.message(), "Hello"); count++; } - ASSERT_EQ(count, 10); + ASSERT_EQ(count, kNumStreamingMessages); Status s = reader->Finish(); EXPECT_EQ(s.ok(), true); } @@ -85,7 +85,7 @@ void MakeBidiStreamingCall(const std::shared_ptr& channel) { EchoResponse resp; ctx.AddMetadata("testkey", "testvalue"); auto stream = stub->BidiStream(&ctx); - for (auto i = 0; i < 10; i++) { + for (auto i = 0; i < kNumStreamingMessages; i++) { req.set_message("Hello" + std::to_string(i)); stream->Write(req); stream->Read(&resp); diff --git a/test/cpp/end2end/interceptors_util.h b/test/cpp/end2end/interceptors_util.h index 419845e5f61..1cd1448a6fa 100644 --- a/test/cpp/end2end/interceptors_util.h +++ b/test/cpp/end2end/interceptors_util.h @@ -152,6 +152,8 @@ class EchoTestServiceStreamingImpl : public EchoTestService::Service { } }; +constexpr int kNumStreamingMessages = 10; + void MakeCall(const std::shared_ptr& channel); void MakeClientStreamingCall(const std::shared_ptr& channel); From c58b4a396480b29df4fec3a0a1624e64fb7fe091 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 24 May 2019 17:00:54 -0700 Subject: [PATCH 0328/1555] Clang format --- include/grpcpp/impl/codegen/call_op_set.h | 4 +--- .../client_interceptors_end2end_test.cc | 22 +++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/include/grpcpp/impl/codegen/call_op_set.h b/include/grpcpp/impl/codegen/call_op_set.h index fdd0b5e91b7..95664a800fa 100644 --- a/include/grpcpp/impl/codegen/call_op_set.h +++ b/include/grpcpp/impl/codegen/call_op_set.h @@ -433,9 +433,7 @@ class CallOpRecvMessage { message_(nullptr), allow_not_getting_message_(false) {} - void RecvMessage(R* message) { - message_ = message; - } + void RecvMessage(R* message) { message_ = message; } // Do not change status if no message is received. void AllowNoMessage() { allow_not_getting_message_ = true; } diff --git a/test/cpp/end2end/client_interceptors_end2end_test.cc b/test/cpp/end2end/client_interceptors_end2end_test.cc index 70b0ecdf585..ae4fba45532 100644 --- a/test/cpp/end2end/client_interceptors_end2end_test.cc +++ b/test/cpp/end2end/client_interceptors_end2end_test.cc @@ -502,12 +502,12 @@ class BidiStreamingRpcHijackingInterceptorFactory class LoggingInterceptor : public experimental::Interceptor { public: LoggingInterceptor(experimental::ClientRpcInfo* info) : info_(info) { - pre_send_initial_metadata_ = false; - pre_send_message_count_ = 0; - pre_send_close_ = false; - post_recv_initial_metadata_ = false; - post_recv_message_count_ = 0; - post_recv_status_ = false; + pre_send_initial_metadata_ = false; + pre_send_message_count_ = 0; + pre_send_close_ = false; + post_recv_initial_metadata_ = false; + post_recv_message_count_ = 0; + post_recv_status_ = false; } virtual void Intercept(experimental::InterceptorBatchMethods* methods) { @@ -540,7 +540,7 @@ class LoggingInterceptor : public experimental::Interceptor { if (methods->QueryInterceptionHookPoint( experimental::InterceptionHookPoints::PRE_SEND_CLOSE)) { // Got nothing to do here for now - pre_send_close_ = true; + pre_send_close_ = true; } if (methods->QueryInterceptionHookPoint( experimental::InterceptionHookPoints::POST_RECV_INITIAL_METADATA)) { @@ -553,7 +553,7 @@ class LoggingInterceptor : public experimental::Interceptor { experimental::InterceptionHookPoints::POST_RECV_MESSAGE)) { EchoResponse* resp = static_cast(methods->GetRecvMessage()); - if(resp != nullptr) { + if (resp != nullptr) { EXPECT_TRUE(resp->message().find("Hello") == 0u); post_recv_message_count_++; } @@ -590,19 +590,19 @@ class LoggingInterceptor : public experimental::Interceptor { } static void VerifyClientStreamingCall() { - VerifyCallCommon(); + VerifyCallCommon(); EXPECT_EQ(pre_send_message_count_, kNumStreamingMessages); EXPECT_EQ(post_recv_message_count_, 1); } static void VerifyServerStreamingCall() { - VerifyCallCommon(); + VerifyCallCommon(); EXPECT_EQ(pre_send_message_count_, 1); EXPECT_EQ(post_recv_message_count_, kNumStreamingMessages); } static void VerifyBidiStreamingCall() { - VerifyCallCommon(); + VerifyCallCommon(); EXPECT_EQ(pre_send_message_count_, kNumStreamingMessages); EXPECT_EQ(post_recv_message_count_, kNumStreamingMessages); } From 6a2da31a360151ad71049f06bf66e41ba85832a6 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 24 May 2019 17:22:42 -0700 Subject: [PATCH 0329/1555] Remove unused variable --- test/cpp/end2end/client_interceptors_end2end_test.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/cpp/end2end/client_interceptors_end2end_test.cc b/test/cpp/end2end/client_interceptors_end2end_test.cc index ae4fba45532..d548a023bd1 100644 --- a/test/cpp/end2end/client_interceptors_end2end_test.cc +++ b/test/cpp/end2end/client_interceptors_end2end_test.cc @@ -501,7 +501,7 @@ class BidiStreamingRpcHijackingInterceptorFactory class LoggingInterceptor : public experimental::Interceptor { public: - LoggingInterceptor(experimental::ClientRpcInfo* info) : info_(info) { + LoggingInterceptor(experimental::ClientRpcInfo* info) { pre_send_initial_metadata_ = false; pre_send_message_count_ = 0; pre_send_close_ = false; @@ -608,7 +608,6 @@ class LoggingInterceptor : public experimental::Interceptor { } private: - experimental::ClientRpcInfo* info_; static bool pre_send_initial_metadata_; static int pre_send_message_count_; static bool pre_send_close_; From 57cc401597f9464809ee9d9402bd448aa1e0aecc Mon Sep 17 00:00:00 2001 From: weiyongji <232589621@qq.com> Date: Sat, 25 May 2019 11:20:08 +0800 Subject: [PATCH 0330/1555] typo fix --- src/cpp/thread_manager/thread_manager.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cpp/thread_manager/thread_manager.h b/src/cpp/thread_manager/thread_manager.h index 2fbf309d421..62b1beebc37 100644 --- a/src/cpp/thread_manager/thread_manager.h +++ b/src/cpp/thread_manager/thread_manager.h @@ -56,7 +56,7 @@ class ThreadManager { // DoWork() // // If the return value is SHUTDOWN:, - // - ThreadManager WILL NOT call DoWork() and terminates the thead + // - ThreadManager WILL NOT call DoWork() and terminates the thread // // If the return value is TIMEOUT:, // - ThreadManager WILL NOT call DoWork() @@ -133,7 +133,7 @@ class ThreadManager { grpc_core::Thread thd_; }; - // The main funtion in ThreadManager + // The main function in ThreadManager void MainWorkLoop(); void MarkAsCompleted(WorkerThread* thd); From a2f7ce699be7678ff72870c6a164317762b1b30d Mon Sep 17 00:00:00 2001 From: weiyongji <232589621@qq.com> Date: Sat, 25 May 2019 15:07:24 +0800 Subject: [PATCH 0331/1555] call destroy function in test_serial() --- test/core/gpr/mpscq_test.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/test/core/gpr/mpscq_test.cc b/test/core/gpr/mpscq_test.cc index 744cea934c5..552fe8d9687 100644 --- a/test/core/gpr/mpscq_test.cc +++ b/test/core/gpr/mpscq_test.cc @@ -55,6 +55,7 @@ static void test_serial(void) { GPR_ASSERT(n->i == i); gpr_free(n); } + gpr_mpscq_destroy(&q); } typedef struct { From bd0d6fc7b6b7499f3385a92c42e853a8d55ce16e Mon Sep 17 00:00:00 2001 From: weiyongji <232589621@qq.com> Date: Sat, 25 May 2019 15:46:28 +0800 Subject: [PATCH 0332/1555] cancel the modification in mpscq_test.cc --- test/core/gpr/mpscq_test.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/test/core/gpr/mpscq_test.cc b/test/core/gpr/mpscq_test.cc index 552fe8d9687..744cea934c5 100644 --- a/test/core/gpr/mpscq_test.cc +++ b/test/core/gpr/mpscq_test.cc @@ -55,7 +55,6 @@ static void test_serial(void) { GPR_ASSERT(n->i == i); gpr_free(n); } - gpr_mpscq_destroy(&q); } typedef struct { From 13011a9787405b412b6f4126da46a71eb7339b57 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Wed, 22 May 2019 13:14:53 -0700 Subject: [PATCH 0333/1555] Fix PHP extension segfault --- src/php/ext/grpc/php_grpc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/php/ext/grpc/php_grpc.c b/src/php/ext/grpc/php_grpc.c index f6c2f85ed47..1098075690a 100644 --- a/src/php/ext/grpc/php_grpc.c +++ b/src/php/ext/grpc/php_grpc.c @@ -205,7 +205,9 @@ void register_fork_handlers() { void apply_ini_settings() { if (GRPC_G(enable_fork_support)) { - putenv("GRPC_ENABLE_FORK_SUPPORT=1"); + char *enable_str = malloc(sizeof("GRPC_ENABLE_FORK_SUPPORT=1")); + strcpy(enable_str, "GRPC_ENABLE_FORK_SUPPORT=1"); + putenv(enable_str); } if (GRPC_G(poll_strategy)) { From e3c280d61373312f3f69ad786c7fbd0d7cae6f51 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 24 May 2019 15:26:05 -0700 Subject: [PATCH 0334/1555] build fix --- src/objective-c/tests/CronetTests/CronetUnitTests.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/objective-c/tests/CronetTests/CronetUnitTests.mm b/src/objective-c/tests/CronetTests/CronetUnitTests.mm index 595a1d19708..2473cf612be 100644 --- a/src/objective-c/tests/CronetTests/CronetUnitTests.mm +++ b/src/objective-c/tests/CronetTests/CronetUnitTests.mm @@ -40,9 +40,10 @@ #import "test/core/util/test_config.h" #define GRPC_SHADOW_BORINGSSL_SYMBOLS -#import " #import "src/core/tsi/grpc_shadow_boringssl.h" +#import + static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; do { From e24a7a3452caf1930dd1ddb6ad4949302c55c191 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Tue, 28 May 2019 09:29:40 -0700 Subject: [PATCH 0335/1555] Bump version to 1.21.2 --- BUILD | 2 +- build.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index c75a5d124fc..37046f67a83 100644 --- a/BUILD +++ b/BUILD @@ -78,7 +78,7 @@ g_stands_for = "gandalf" core_version = "7.0.0" -version = "1.21.1" +version = "1.21.2" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index 0344ce18053..3fc8b651714 100644 --- a/build.yaml +++ b/build.yaml @@ -14,7 +14,7 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 7.0.0 g_stands_for: gandalf - version: 1.21.1 + version: 1.21.2 filegroups: - name: alts_proto headers: From ec640a53c6001321af759c13efae24350117e4bd Mon Sep 17 00:00:00 2001 From: Srini Polavarapu <35056280+srini100@users.noreply.github.com> Date: Thu, 23 May 2019 13:18:36 -0700 Subject: [PATCH 0336/1555] Merge pull request #19105 from gnossen/twine_check_artifacts Produce Python Wheels with a Valid long_description field --- src/python/grpcio/README.rst | 8 ++++---- tools/distrib/python/grpcio_tools/README.rst | 8 ++++---- tools/run_tests/artifacts/build_artifact_python.bat | 4 ++++ tools/run_tests/artifacts/build_artifact_python.sh | 6 ++++++ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/python/grpcio/README.rst b/src/python/grpcio/README.rst index f047243f82d..04a3bcbc204 100644 --- a/src/python/grpcio/README.rst +++ b/src/python/grpcio/README.rst @@ -8,8 +8,8 @@ Installation gRPC Python is available for Linux, macOS, and Windows. -From PyPI -~~~~~~~~~ +Installing From PyPI +~~~~~~~~~~~~~~~~~~~~ If you are installing locally... @@ -37,8 +37,8 @@ n.b. On Windows and on Mac OS X one *must* have a recent release of :code:`pip` to retrieve the proper wheel from PyPI. Be sure to upgrade to the latest version! -From Source -~~~~~~~~~~~ +Installing From Source +~~~~~~~~~~~~~~~~~~~~~~ Building from source requires that you have the Python headers (usually a package named :code:`python-dev`). diff --git a/tools/distrib/python/grpcio_tools/README.rst b/tools/distrib/python/grpcio_tools/README.rst index 32873b291fa..17816deff61 100644 --- a/tools/distrib/python/grpcio_tools/README.rst +++ b/tools/distrib/python/grpcio_tools/README.rst @@ -9,8 +9,8 @@ Installation The gRPC Python tools package is available for Linux, Mac OS X, and Windows running Python 2.7. -From PyPI -~~~~~~~~~ +Installing From PyPI +~~~~~~~~~~~~~~~~~~~~ If you are installing locally... @@ -42,8 +42,8 @@ You might also need to install Cython to handle installation via the source distribution if gRPC Python's system coverage with wheels does not happen to include your system. -From Source -~~~~~~~~~~~ +Installing From Source +~~~~~~~~~~~~~~~~~~~~~~ Building from source requires that you have the Python headers (usually a package named :code:`python-dev`) and Cython installed. It further requires a diff --git a/tools/run_tests/artifacts/build_artifact_python.bat b/tools/run_tests/artifacts/build_artifact_python.bat index 795e80dc40d..c946cd98061 100644 --- a/tools/run_tests/artifacts/build_artifact_python.bat +++ b/tools/run_tests/artifacts/build_artifact_python.bat @@ -46,6 +46,10 @@ pushd tools\distrib\python\grpcio_tools python setup.py bdist_wheel || goto :error popd +@rem Ensure the generate artifacts are valid. +python -m pip install twine +python -m twine check dist\* tools\distrib\python\grpcio_tools\dist\* || goto :error + xcopy /Y /I /S dist\* %ARTIFACT_DIR% || goto :error xcopy /Y /I /S tools\distrib\python\grpcio_tools\dist\* %ARTIFACT_DIR% || goto :error diff --git a/tools/run_tests/artifacts/build_artifact_python.sh b/tools/run_tests/artifacts/build_artifact_python.sh index e451ced338f..c5e380fe5dc 100755 --- a/tools/run_tests/artifacts/build_artifact_python.sh +++ b/tools/run_tests/artifacts/build_artifact_python.sh @@ -130,5 +130,11 @@ then cp -r src/python/grpcio_status/dist/* "$ARTIFACT_DIR" fi +# Ensure the generated artifacts are valid. +"${PYTHON}" -m virtualenv venv || { "${PYTHON}" -m pip install virtualenv && "${PYTHON}" -m virtualenv venv; } +venv/bin/python -m pip install twine +venv/bin/python -m twine check dist/* tools/distrib/python/grpcio_tools/dist/* +rm -rf venv/ + cp -r dist/* "$ARTIFACT_DIR" cp -r tools/distrib/python/grpcio_tools/dist/* "$ARTIFACT_DIR" From 66c7560fc48b90abe39ed4e7711816af4d0e851f Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 28 May 2019 11:25:56 -0700 Subject: [PATCH 0337/1555] Fix server interceptors end2end test --- test/cpp/end2end/server_interceptors_end2end_test.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/cpp/end2end/server_interceptors_end2end_test.cc b/test/cpp/end2end/server_interceptors_end2end_test.cc index 68103f7ed34..34409fe375c 100644 --- a/test/cpp/end2end/server_interceptors_end2end_test.cc +++ b/test/cpp/end2end/server_interceptors_end2end_test.cc @@ -120,7 +120,9 @@ class LoggingInterceptor : public experimental::Interceptor { experimental::InterceptionHookPoints::POST_RECV_MESSAGE)) { EchoResponse* resp = static_cast(methods->GetRecvMessage()); - EXPECT_TRUE(resp->message().find("Hello") == 0); + if (resp != nullptr) { + EXPECT_TRUE(resp->message().find("Hello") == 0); + } } if (methods->QueryInterceptionHookPoint( experimental::InterceptionHookPoints::POST_RECV_CLOSE)) { From 3893a6379bd64d7a1c945819b598d7b5518eee6e Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 28 May 2019 11:57:57 -0700 Subject: [PATCH 0338/1555] Clean up --- include/grpcpp/support/validate_service_config.h | 2 +- src/cpp/common/channel_arguments.cc | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/grpcpp/support/validate_service_config.h b/include/grpcpp/support/validate_service_config.h index d5ea521a1ef..41f2c636bd9 100644 --- a/include/grpcpp/support/validate_service_config.h +++ b/include/grpcpp/support/validate_service_config.h @@ -33,4 +33,4 @@ grpc::string ValidateServiceConfigJSON(const grpc::string& service_config_json); } // namespace grpc -#endif // GRPCPP_SUPPORT_VALIDATE_SERVICE_CONFIG_H \ No newline at end of file +#endif // GRPCPP_SUPPORT_VALIDATE_SERVICE_CONFIG_H diff --git a/src/cpp/common/channel_arguments.cc b/src/cpp/common/channel_arguments.cc index f35c91572eb..932139890fe 100644 --- a/src/cpp/common/channel_arguments.cc +++ b/src/cpp/common/channel_arguments.cc @@ -23,7 +23,6 @@ #include #include #include -#include "src/core/ext/filters/client_channel/service_config.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/socket_mutator.h" From 56db3850af264f7224ba4b0a4611d5a28ca955f5 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Tue, 28 May 2019 14:02:39 -0700 Subject: [PATCH 0339/1555] Re-generate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 4 ++-- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 4 ++-- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 4 ++-- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/composer.json | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 30 files changed, 34 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b0c75c0811..0c8d64b7f0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.21.1") +set(PACKAGE_VERSION "1.21.2") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 0d148ab3cd2..6d717454fe5 100644 --- a/Makefile +++ b/Makefile @@ -460,8 +460,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.21.1 -CSHARP_VERSION = 1.21.1 +CPP_VERSION = 1.21.2 +CSHARP_VERSION = 1.21.2 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index ca27e4f34f3..3fc781b9355 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,7 +23,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.21.1' + # version = '1.21.2' version = '0.0.9' s.version = version s.summary = 'gRPC C++ library' @@ -31,7 +31,7 @@ Pod::Spec.new do |s| s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.21.1' + grpc_version = '1.21.2' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index ca3225b3694..220d3af3b4b 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.21.1' + version = '1.21.2' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 2012515bbe9..b49ccb9006a 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.21.1' + version = '1.21.2' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index c4a9f2889e9..673e7bce88b 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.21.1' + version = '1.21.2' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index 31a1c448aa1..1352c4c612b 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.21.1' + version = '1.21.2' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index 6bcbd807566..64c740e265a 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2018-01-19 - 1.21.1 - 1.21.1 + 1.21.2 + 1.21.2 stable diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 619220ce4e3..0a70066da99 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.21.1"; } +grpc::string Version() { return "1.21.2"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index 5cf75df63ab..dd609b57861 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -33,11 +33,11 @@ namespace Grpc.Core /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "1.21.1.0"; + public const string CurrentAssemblyFileVersion = "1.21.2.0"; /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.21.1"; + public const string CurrentVersion = "1.21.2"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index c4c40fe0c66..ee7c7deba2b 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 1.21.1 + 1.21.2 3.7.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index 65deb40679c..ba058320ae0 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=1.21.1 +set VERSION=1.21.2 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 8ac2dd7d303..c40eeace00e 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.21.1' + v = '1.21.2' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index e410f8da012..681da2b810a 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.1" +#define GRPC_OBJC_VERSION_STRING @"1.21.2" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 95b112b156f..44d99eb284a 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.1" +#define GRPC_OBJC_VERSION_STRING @"1.21.2" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/composer.json b/src/php/composer.json index 3171442cc03..e76014083f7 100644 --- a/src/php/composer.json +++ b/src/php/composer.json @@ -2,7 +2,7 @@ "name": "grpc/grpc-dev", "description": "gRPC library for PHP - for Developement use only", "license": "Apache-2.0", - "version": "1.21.1", + "version": "1.21.2", "require": { "php": ">=5.5.0", "google/protobuf": "^v3.3.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 07a73698015..5371146a432 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.21.1" +#define PHP_GRPC_VERSION "1.21.2" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index 4624e467fd8..3af536e9f37 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.21.1""" +__version__ = """1.21.2""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index 2451ef4a538..514df8b0ef4 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.21.1' +VERSION = '1.21.2' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index 591b5bd8fc5..961939cb2ad 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.21.1' +VERSION = '1.21.2' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index c11487af7e8..1497d526468 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.21.1' +VERSION = '1.21.2' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 47628416c26..7731b932266 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.21.1' +VERSION = '1.21.2' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index 713746a1598..d8714f76d5b 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.21.1' +VERSION = '1.21.2' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 3fe457f304c..2e9d29235bf 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.21.1' +VERSION = '1.21.2' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index 103b532f38f..715493c169f 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.21.1' +VERSION = '1.21.2' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 1308aa4652e..b31c382f0c2 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.21.1' + VERSION = '1.21.2' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index 38f7129d139..46d8d13cebc 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.21.1' + VERSION = '1.21.2' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 872f821c2f6..7299a21a23f 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.21.1' +VERSION = '1.21.2' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index c683fe91df1..b7d5569f8d3 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.1 +PROJECT_NUMBER = 1.21.2 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 69f6a345afa..7848ef8f3a3 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.1 +PROJECT_NUMBER = 1.21.2 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From 477ebef532b0163d87ba8c068c84d2adb67a3477 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 28 May 2019 14:18:15 -0700 Subject: [PATCH 0340/1555] Remove CreateChannel() method from LB helper API. --- .../filters/client_channel/client_channel.cc | 5 -- .../client_channel/client_channel_factory.h | 4 -- .../ext/filters/client_channel/lb_policy.h | 6 --- .../client_channel/lb_policy/grpclb/grpclb.cc | 18 ++----- .../lb_policy/grpclb/grpclb_channel.cc | 15 +++++- .../lb_policy/grpclb/grpclb_channel.h | 11 ++++- .../lb_policy/grpclb/grpclb_channel_secure.cc | 48 ++++++++++++------- .../client_channel/lb_policy/xds/xds.cc | 31 ++---------- .../lb_policy/xds/xds_channel.cc | 14 +++++- .../lb_policy/xds/xds_channel.h | 10 +++- .../lb_policy/xds/xds_channel_secure.cc | 41 +++++++++++----- .../client_channel/resolving_lb_policy.cc | 7 --- .../chttp2/client/insecure/channel_create.cc | 45 +++++++++-------- .../client/secure/secure_channel_create.cc | 45 +++++++++-------- test/core/util/test_lb_policies.cc | 5 -- test/cpp/microbenchmarks/bm_call_create.cc | 4 -- 16 files changed, 157 insertions(+), 152 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index c0586d459b2..acbf1238113 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -960,11 +960,6 @@ class ChannelData::ClientChannelControlHelper return subchannel; } - grpc_channel* CreateChannel(const char* target, - const grpc_channel_args& args) override { - return chand_->client_channel_factory_->CreateChannel(target, &args); - } - void UpdateState( grpc_connectivity_state state, UniquePtr picker) override { diff --git a/src/core/ext/filters/client_channel/client_channel_factory.h b/src/core/ext/filters/client_channel/client_channel_factory.h index 21f78a833df..42bc7cb505f 100644 --- a/src/core/ext/filters/client_channel/client_channel_factory.h +++ b/src/core/ext/filters/client_channel/client_channel_factory.h @@ -36,10 +36,6 @@ class ClientChannelFactory { virtual Subchannel* CreateSubchannel(const grpc_channel_args* args) GRPC_ABSTRACT; - // Creates a channel for the specified target with the specified args. - virtual grpc_channel* CreateChannel( - const char* target, const grpc_channel_args* args) GRPC_ABSTRACT; - // Returns a channel arg containing the specified factory. static grpc_arg CreateChannelArg(ClientChannelFactory* factory); diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h index 2ac7df63b7d..237b5930d4a 100644 --- a/src/core/ext/filters/client_channel/lb_policy.h +++ b/src/core/ext/filters/client_channel/lb_policy.h @@ -191,12 +191,6 @@ class LoadBalancingPolicy : public InternallyRefCounted { virtual Subchannel* CreateSubchannel(const grpc_channel_args& args) GRPC_ABSTRACT; - /// Creates a channel with the specified target and channel args. - /// This can be used in cases where the LB policy needs to create a - /// channel for its own use (e.g., to talk to an external load balancer). - virtual grpc_channel* CreateChannel( - const char* target, const grpc_channel_args& args) GRPC_ABSTRACT; - /// Sets the connectivity state and returns a new picker to be used /// by the client channel. virtual void UpdateState(grpc_connectivity_state state, diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index ed6e8de3f21..26c9fdfc9c1 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -294,8 +294,6 @@ class GrpcLb : public LoadBalancingPolicy { : parent_(std::move(parent)) {} Subchannel* CreateSubchannel(const grpc_channel_args& args) override; - grpc_channel* CreateChannel(const char* target, - const grpc_channel_args& args) override; void UpdateState(grpc_connectivity_state state, UniquePtr picker) override; void RequestReresolution() override; @@ -625,15 +623,6 @@ Subchannel* GrpcLb::Helper::CreateSubchannel(const grpc_channel_args& args) { return parent_->channel_control_helper()->CreateSubchannel(args); } -grpc_channel* GrpcLb::Helper::CreateChannel(const char* target, - const grpc_channel_args& args) { - if (parent_->shutting_down_ || - (!CalledByPendingChild() && !CalledByCurrentChild())) { - return nullptr; - } - return parent_->channel_control_helper()->CreateChannel(target, args); -} - void GrpcLb::Helper::UpdateState(grpc_connectivity_state state, UniquePtr picker) { if (parent_->shutting_down_) return; @@ -1232,7 +1221,7 @@ grpc_channel_args* BuildBalancerChannelArgs( // the LB channel. GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, // The LB channel should use the authority indicated by the target - // authority table (see \a grpc_lb_policy_grpclb_modify_lb_channel_args), + // authority table (see \a ModifyGrpclbBalancerChannelArgs), // as opposed to the authority from the parent channel. GRPC_ARG_DEFAULT_AUTHORITY, // Just as for \a GRPC_ARG_DEFAULT_AUTHORITY, the LB channel should be @@ -1259,7 +1248,7 @@ grpc_channel_args* BuildBalancerChannelArgs( args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove), args_to_add, GPR_ARRAY_SIZE(args_to_add)); // Make any necessary modifications for security. - return grpc_lb_policy_grpclb_modify_lb_channel_args(addresses, new_args); + return ModifyGrpclbBalancerChannelArgs(addresses, new_args); } // @@ -1464,8 +1453,7 @@ void GrpcLb::ProcessAddressesAndChannelArgsLocked( if (lb_channel_ == nullptr) { char* uri_str; gpr_asprintf(&uri_str, "fake:///%s", server_name_); - lb_channel_ = - channel_control_helper()->CreateChannel(uri_str, *lb_channel_args); + lb_channel_ = CreateGrpclbBalancerChannel(uri_str, *lb_channel_args); GPR_ASSERT(lb_channel_ != nullptr); grpc_core::channelz::ChannelNode* channel_node = grpc_channel_get_channelz_node(lb_channel_); diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc index b713e26713f..c7237632c0a 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc @@ -18,9 +18,20 @@ #include +#include + #include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h" -grpc_channel_args* grpc_lb_policy_grpclb_modify_lb_channel_args( - const grpc_core::ServerAddressList& addresses, grpc_channel_args* args) { +namespace grpc_core { + +grpc_channel_args* ModifyGrpclbBalancerChannelArgs( + const ServerAddressList& addresses, grpc_channel_args* args) { return args; } + +grpc_channel* CreateGrpclbBalancerChannel(const char* target_uri, + const grpc_channel_args& args) { + return grpc_insecure_channel_create(target_uri, &args, nullptr); +} + +} // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h index c78ba36cf1d..1458233022f 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h @@ -25,14 +25,21 @@ #include "src/core/ext/filters/client_channel/server_address.h" +namespace grpc_core { + /// Makes any necessary modifications to \a args for use in the grpclb /// balancer channel. /// /// Takes ownership of \a args. /// /// Caller takes ownership of the returned args. -grpc_channel_args* grpc_lb_policy_grpclb_modify_lb_channel_args( - const grpc_core::ServerAddressList& addresses, grpc_channel_args* args); +grpc_channel_args* ModifyGrpclbBalancerChannelArgs( + const ServerAddressList& addresses, grpc_channel_args* args); + +grpc_channel* CreateGrpclbBalancerChannel(const char* target_uri, + const grpc_channel_args& args); + +} // namespace grpc_core #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_GRPCLB_CHANNEL_H \ */ diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc index 892cdeb27b7..376209fa7e2 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc @@ -22,6 +22,7 @@ #include +#include #include #include @@ -35,6 +36,7 @@ #include "src/core/lib/slice/slice_internal.h" namespace grpc_core { + namespace { int BalancerNameCmp(const grpc_core::UniquePtr& a, @@ -65,37 +67,49 @@ RefCountedPtr CreateTargetAuthorityTable( } } // namespace -} // namespace grpc_core -grpc_channel_args* grpc_lb_policy_grpclb_modify_lb_channel_args( - const grpc_core::ServerAddressList& addresses, grpc_channel_args* args) { - const char* args_to_remove[1]; - size_t num_args_to_remove = 0; - grpc_arg args_to_add[2]; - size_t num_args_to_add = 0; +grpc_channel_args* ModifyGrpclbBalancerChannelArgs( + const ServerAddressList& addresses, grpc_channel_args* args) { + InlinedVector args_to_remove; + InlinedVector args_to_add; // Add arg for targets info table. - grpc_core::RefCountedPtr - target_authority_table = grpc_core::CreateTargetAuthorityTable(addresses); - args_to_add[num_args_to_add++] = - grpc_core::CreateTargetAuthorityTableChannelArg( - target_authority_table.get()); + RefCountedPtr target_authority_table = + CreateTargetAuthorityTable(addresses); + args_to_add.emplace_back( + CreateTargetAuthorityTableChannelArg(target_authority_table.get())); // Substitute the channel credentials with a version without call // credentials: the load balancer is not necessarily trusted to handle // bearer token credentials. grpc_channel_credentials* channel_credentials = grpc_channel_credentials_find_in_args(args); - grpc_core::RefCountedPtr creds_sans_call_creds; + RefCountedPtr creds_sans_call_creds; if (channel_credentials != nullptr) { creds_sans_call_creds = channel_credentials->duplicate_without_call_credentials(); GPR_ASSERT(creds_sans_call_creds != nullptr); - args_to_remove[num_args_to_remove++] = GRPC_ARG_CHANNEL_CREDENTIALS; - args_to_add[num_args_to_add++] = - grpc_channel_credentials_to_arg(creds_sans_call_creds.get()); + args_to_remove.emplace_back(GRPC_ARG_CHANNEL_CREDENTIALS); + args_to_add.emplace_back( + grpc_channel_credentials_to_arg(creds_sans_call_creds.get())); } grpc_channel_args* result = grpc_channel_args_copy_and_add_and_remove( - args, args_to_remove, num_args_to_remove, args_to_add, num_args_to_add); + args, args_to_remove.data(), args_to_remove.size(), args_to_add.data(), + args_to_add.size()); // Clean up. grpc_channel_args_destroy(args); return result; } + +grpc_channel* CreateGrpclbBalancerChannel(const char* target_uri, + const grpc_channel_args& args) { + grpc_channel_credentials* creds = + grpc_channel_credentials_find_in_args(&args); + const char* arg_to_remove = GRPC_ARG_CHANNEL_CREDENTIALS; + grpc_channel_args* new_args = + grpc_channel_args_copy_and_remove(&args, &arg_to_remove, 1); + grpc_channel* channel = + grpc_secure_channel_create(creds, target_uri, new_args, nullptr); + grpc_channel_args_destroy(new_args); + return channel; +} + +} // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index 819bad6c00d..08ecec5c8ba 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -338,8 +338,6 @@ class XdsLb : public LoadBalancingPolicy { : parent_(std::move(parent)) {} Subchannel* CreateSubchannel(const grpc_channel_args& args) override; - grpc_channel* CreateChannel(const char* target, - const grpc_channel_args& args) override; void UpdateState(grpc_connectivity_state state, UniquePtr picker) override; void RequestReresolution() override; @@ -378,8 +376,6 @@ class XdsLb : public LoadBalancingPolicy { : entry_(std::move(entry)) {} Subchannel* CreateSubchannel(const grpc_channel_args& args) override; - grpc_channel* CreateChannel(const char* target, - const grpc_channel_args& args) override; void UpdateState(grpc_connectivity_state state, UniquePtr picker) override; void RequestReresolution() override; @@ -592,15 +588,6 @@ Subchannel* XdsLb::FallbackHelper::CreateSubchannel( return parent_->channel_control_helper()->CreateSubchannel(args); } -grpc_channel* XdsLb::FallbackHelper::CreateChannel( - const char* target, const grpc_channel_args& args) { - if (parent_->shutting_down_ || - (!CalledByPendingFallback() && !CalledByCurrentFallback())) { - return nullptr; - } - return parent_->channel_control_helper()->CreateChannel(target, args); -} - void XdsLb::FallbackHelper::UpdateState(grpc_connectivity_state state, UniquePtr picker) { if (parent_->shutting_down_) return; @@ -722,7 +709,7 @@ ServerAddressList ProcessServerlist(const xds_grpclb_serverlist* serverlist) { XdsLb::BalancerChannelState::BalancerChannelState( const char* balancer_name, const grpc_channel_args& args, - grpc_core::RefCountedPtr parent_xdslb_policy) + RefCountedPtr parent_xdslb_policy) : InternallyRefCounted(&grpc_lb_xds_trace), xdslb_policy_(std::move(parent_xdslb_policy)), lb_call_backoff_( @@ -735,8 +722,7 @@ XdsLb::BalancerChannelState::BalancerChannelState( GRPC_CLOSURE_INIT(&on_connectivity_changed_, &XdsLb::BalancerChannelState::OnConnectivityChangedLocked, this, grpc_combiner_scheduler(xdslb_policy_->combiner())); - channel_ = xdslb_policy_->channel_control_helper()->CreateChannel( - balancer_name, args); + channel_ = CreateXdsBalancerChannel(balancer_name, args); GPR_ASSERT(channel_ != nullptr); StartCallLocked(); } @@ -1325,7 +1311,7 @@ grpc_channel_args* BuildBalancerChannelArgs(const grpc_channel_args* args) { // factory will re-add this arg with the right value. GRPC_ARG_SERVER_URI, // The LB channel should use the authority indicated by the target - // authority table (see \a grpc_lb_policy_xds_modify_lb_channel_args), + // authority table (see \a ModifyXdsBalancerChannelArgs), // as opposed to the authority from the parent channel. GRPC_ARG_DEFAULT_AUTHORITY, // Just as for \a GRPC_ARG_DEFAULT_AUTHORITY, the LB channel should be @@ -1348,7 +1334,7 @@ grpc_channel_args* BuildBalancerChannelArgs(const grpc_channel_args* args) { args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove), args_to_add, GPR_ARRAY_SIZE(args_to_add)); // Make any necessary modifications for security. - return grpc_lb_policy_xds_modify_lb_channel_args(new_args); + return ModifyXdsBalancerChannelArgs(new_args); } // @@ -2010,15 +1996,6 @@ Subchannel* XdsLb::LocalityMap::LocalityEntry::Helper::CreateSubchannel( return entry_->parent_->channel_control_helper()->CreateSubchannel(args); } -grpc_channel* XdsLb::LocalityMap::LocalityEntry::Helper::CreateChannel( - const char* target, const grpc_channel_args& args) { - if (entry_->parent_->shutting_down_ || - (!CalledByPendingChild() && !CalledByCurrentChild())) { - return nullptr; - } - return entry_->parent_->channel_control_helper()->CreateChannel(target, args); -} - void XdsLb::LocalityMap::LocalityEntry::Helper::UpdateState( grpc_connectivity_state state, UniquePtr picker) { if (entry_->parent_->shutting_down_) return; diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc index 0aa145a24e5..386517d6427 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc @@ -18,9 +18,19 @@ #include +#include + #include "src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h" -grpc_channel_args* grpc_lb_policy_xds_modify_lb_channel_args( - grpc_channel_args* args) { +namespace grpc_core { + +grpc_channel_args* ModifyXdsBalancerChannelArgs(grpc_channel_args* args) { return args; } + +grpc_channel* CreateXdsBalancerChannel(const char* target_uri, + const grpc_channel_args& args) { + return grpc_insecure_channel_create(target_uri, &args, nullptr); +} + +} // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h b/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h index f713b7f563d..516bac1df25 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h @@ -23,14 +23,20 @@ #include +namespace grpc_core { + /// Makes any necessary modifications to \a args for use in the xds /// balancer channel. /// /// Takes ownership of \a args. /// /// Caller takes ownership of the returned args. -grpc_channel_args* grpc_lb_policy_xds_modify_lb_channel_args( - grpc_channel_args* args); +grpc_channel_args* ModifyXdsBalancerChannelArgs(grpc_channel_args* args); + +grpc_channel* CreateXdsBalancerChannel(const char* target_uri, + const grpc_channel_args& args); + +} // namespace grpc_core #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_XDS_XDS_CHANNEL_H \ */ diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc index 7f8c232d6d0..ad5e7cbbc2e 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc @@ -20,9 +20,11 @@ #include "src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h" +#include + +#include #include #include -#include #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/client_channel/server_address.h" @@ -33,29 +35,44 @@ #include "src/core/lib/security/transport/target_authority_table.h" #include "src/core/lib/slice/slice_internal.h" -grpc_channel_args* grpc_lb_policy_xds_modify_lb_channel_args( - grpc_channel_args* args) { - const char* args_to_remove[1]; - size_t num_args_to_remove = 0; - grpc_arg args_to_add[2]; - size_t num_args_to_add = 0; +namespace grpc_core { + +grpc_channel_args* ModifyXdsBalancerChannelArgs(grpc_channel_args* args) { + InlinedVector args_to_remove; + InlinedVector args_to_add; // Substitute the channel credentials with a version without call // credentials: the load balancer is not necessarily trusted to handle // bearer token credentials. grpc_channel_credentials* channel_credentials = grpc_channel_credentials_find_in_args(args); - grpc_core::RefCountedPtr creds_sans_call_creds; + RefCountedPtr creds_sans_call_creds; if (channel_credentials != nullptr) { creds_sans_call_creds = channel_credentials->duplicate_without_call_credentials(); GPR_ASSERT(creds_sans_call_creds != nullptr); - args_to_remove[num_args_to_remove++] = GRPC_ARG_CHANNEL_CREDENTIALS; - args_to_add[num_args_to_add++] = - grpc_channel_credentials_to_arg(creds_sans_call_creds.get()); + args_to_remove.emplace_back(GRPC_ARG_CHANNEL_CREDENTIALS); + args_to_add.emplace_back( + grpc_channel_credentials_to_arg(creds_sans_call_creds.get())); } grpc_channel_args* result = grpc_channel_args_copy_and_add_and_remove( - args, args_to_remove, num_args_to_remove, args_to_add, num_args_to_add); + args, args_to_remove.data(), args_to_remove.size(), args_to_add.data(), + args_to_add.size()); // Clean up. grpc_channel_args_destroy(args); return result; } + +grpc_channel* CreateXdsBalancerChannel(const char* target_uri, + const grpc_channel_args& args) { + grpc_channel_credentials* creds = + grpc_channel_credentials_find_in_args(&args); + const char* arg_to_remove = GRPC_ARG_CHANNEL_CREDENTIALS; + grpc_channel_args* new_args = + grpc_channel_args_copy_and_remove(&args, &arg_to_remove, 1); + grpc_channel* channel = + grpc_secure_channel_create(creds, target_uri, new_args, nullptr); + grpc_channel_args_destroy(new_args); + return channel; +} + +} // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/resolving_lb_policy.cc b/src/core/ext/filters/client_channel/resolving_lb_policy.cc index 4e383f65dd1..6f3cfe813e8 100644 --- a/src/core/ext/filters/client_channel/resolving_lb_policy.cc +++ b/src/core/ext/filters/client_channel/resolving_lb_policy.cc @@ -112,13 +112,6 @@ class ResolvingLoadBalancingPolicy::ResolvingControlHelper return parent_->channel_control_helper()->CreateSubchannel(args); } - grpc_channel* CreateChannel(const char* target, - const grpc_channel_args& args) override { - if (parent_->resolver_ == nullptr) return nullptr; // Shutting down. - if (!CalledByCurrentChild() && !CalledByPendingChild()) return nullptr; - return parent_->channel_control_helper()->CreateChannel(target, args); - } - void UpdateState(grpc_connectivity_state state, UniquePtr picker) override { if (parent_->resolver_ == nullptr) return; // Shutting down. diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc index 0d61abd2a01..cbd522d6e50 100644 --- a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc @@ -46,28 +46,31 @@ class Chttp2InsecureClientChannelFactory : public ClientChannelFactory { grpc_channel_args_destroy(new_args); return s; } - - grpc_channel* CreateChannel(const char* target, - const grpc_channel_args* args) override { - if (target == nullptr) { - gpr_log(GPR_ERROR, "cannot create channel with NULL target name"); - return nullptr; - } - // Add channel arg containing the server URI. - UniquePtr canonical_target = - ResolverRegistry::AddDefaultPrefixIfNeeded(target); - grpc_arg arg = grpc_channel_arg_string_create( - const_cast(GRPC_ARG_SERVER_URI), canonical_target.get()); - const char* to_remove[] = {GRPC_ARG_SERVER_URI}; - grpc_channel_args* new_args = - grpc_channel_args_copy_and_add_and_remove(args, to_remove, 1, &arg, 1); - grpc_channel* channel = - grpc_channel_create(target, new_args, GRPC_CLIENT_CHANNEL, nullptr); - grpc_channel_args_destroy(new_args); - return channel; - } }; +namespace { + +grpc_channel* CreateChannel(const char* target, const grpc_channel_args* args) { + if (target == nullptr) { + gpr_log(GPR_ERROR, "cannot create channel with NULL target name"); + return nullptr; + } + // Add channel arg containing the server URI. + UniquePtr canonical_target = + ResolverRegistry::AddDefaultPrefixIfNeeded(target); + grpc_arg arg = grpc_channel_arg_string_create( + const_cast(GRPC_ARG_SERVER_URI), canonical_target.get()); + const char* to_remove[] = {GRPC_ARG_SERVER_URI}; + grpc_channel_args* new_args = + grpc_channel_args_copy_and_add_and_remove(args, to_remove, 1, &arg, 1); + grpc_channel* channel = + grpc_channel_create(target, new_args, GRPC_CLIENT_CHANNEL, nullptr); + grpc_channel_args_destroy(new_args); + return channel; +} + +} // namespace + } // namespace grpc_core namespace { @@ -98,7 +101,7 @@ grpc_channel* grpc_insecure_channel_create(const char* target, grpc_arg arg = grpc_core::ClientChannelFactory::CreateChannelArg(g_factory); grpc_channel_args* new_args = grpc_channel_args_copy_and_add(args, &arg, 1); // Create channel. - grpc_channel* channel = g_factory->CreateChannel(target, new_args); + grpc_channel* channel = grpc_core::CreateChannel(target, new_args); // Clean up. grpc_channel_args_destroy(new_args); return channel != nullptr ? channel diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc index bc38ff25c79..b18d742ed12 100644 --- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc @@ -58,26 +58,6 @@ class Chttp2SecureClientChannelFactory : public ClientChannelFactory { return s; } - grpc_channel* CreateChannel(const char* target, - const grpc_channel_args* args) override { - if (target == nullptr) { - gpr_log(GPR_ERROR, "cannot create channel with NULL target name"); - return nullptr; - } - // Add channel arg containing the server URI. - UniquePtr canonical_target = - ResolverRegistry::AddDefaultPrefixIfNeeded(target); - grpc_arg arg = grpc_channel_arg_string_create( - const_cast(GRPC_ARG_SERVER_URI), canonical_target.get()); - const char* to_remove[] = {GRPC_ARG_SERVER_URI}; - grpc_channel_args* new_args = - grpc_channel_args_copy_and_add_and_remove(args, to_remove, 1, &arg, 1); - grpc_channel* channel = - grpc_channel_create(target, new_args, GRPC_CLIENT_CHANNEL, nullptr); - grpc_channel_args_destroy(new_args); - return channel; - } - private: static grpc_channel_args* GetSecureNamingChannelArgs( const grpc_channel_args* args) { @@ -170,6 +150,29 @@ class Chttp2SecureClientChannelFactory : public ClientChannelFactory { } }; +namespace { + +grpc_channel* CreateChannel(const char* target, const grpc_channel_args* args) { + if (target == nullptr) { + gpr_log(GPR_ERROR, "cannot create channel with NULL target name"); + return nullptr; + } + // Add channel arg containing the server URI. + UniquePtr canonical_target = + ResolverRegistry::AddDefaultPrefixIfNeeded(target); + grpc_arg arg = grpc_channel_arg_string_create( + const_cast(GRPC_ARG_SERVER_URI), canonical_target.get()); + const char* to_remove[] = {GRPC_ARG_SERVER_URI}; + grpc_channel_args* new_args = + grpc_channel_args_copy_and_add_and_remove(args, to_remove, 1, &arg, 1); + grpc_channel* channel = + grpc_channel_create(target, new_args, GRPC_CLIENT_CHANNEL, nullptr); + grpc_channel_args_destroy(new_args); + return channel; +} + +} // namespace + } // namespace grpc_core namespace { @@ -209,7 +212,7 @@ grpc_channel* grpc_secure_channel_create(grpc_channel_credentials* creds, args, args_to_add, GPR_ARRAY_SIZE(args_to_add)); new_args = creds->update_arguments(new_args); // Create channel. - channel = g_factory->CreateChannel(target, new_args); + channel = grpc_core::CreateChannel(target, new_args); // Clean up. grpc_channel_args_destroy(new_args); } diff --git a/test/core/util/test_lb_policies.cc b/test/core/util/test_lb_policies.cc index b871f04bc9e..684e7495d36 100644 --- a/test/core/util/test_lb_policies.cc +++ b/test/core/util/test_lb_policies.cc @@ -145,11 +145,6 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy return parent_->channel_control_helper()->CreateSubchannel(args); } - grpc_channel* CreateChannel(const char* target, - const grpc_channel_args& args) override { - return parent_->channel_control_helper()->CreateChannel(target, args); - } - void UpdateState(grpc_connectivity_state state, UniquePtr picker) override { parent_->channel_control_helper()->UpdateState( diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 3bd1464b2aa..e687c644516 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -322,10 +322,6 @@ class FakeClientChannelFactory : public grpc_core::ClientChannelFactory { const grpc_channel_args* args) override { return nullptr; } - grpc_channel* CreateChannel(const char* target, - const grpc_channel_args* args) override { - return nullptr; - } }; static grpc_arg StringArg(const char* key, const char* value) { From 31ec9a74aebfe9d7036a5a1b0099e3e23be5bea1 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 28 May 2019 14:23:01 -0700 Subject: [PATCH 0341/1555] More LB policy API improvements. --- .../filters/client_channel/client_channel.cc | 164 +++++++++++------- .../ext/filters/client_channel/lb_policy.cc | 18 +- .../ext/filters/client_channel/lb_policy.h | 154 ++++++++-------- .../client_channel/lb_policy/grpclb/grpclb.cc | 43 ++--- .../lb_policy/pick_first/pick_first.cc | 14 +- .../lb_policy/round_robin/round_robin.cc | 17 +- .../client_channel/lb_policy/xds/xds.cc | 56 +++--- .../client_channel/lb_policy_factory.h | 2 +- .../client_channel/lb_policy_registry.cc | 2 +- .../client_channel/lb_policy_registry.h | 2 +- .../client_channel/resolver_result_parsing.cc | 2 +- .../client_channel/resolver_result_parsing.h | 6 +- .../client_channel/resolving_lb_policy.cc | 6 +- .../client_channel/resolving_lb_policy.h | 8 +- test/core/util/test_lb_policies.cc | 34 ++-- 15 files changed, 291 insertions(+), 237 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index c0586d459b2..5717d3e66d2 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -105,7 +105,6 @@ namespace { class ChannelData { public: struct QueuedPick { - LoadBalancingPolicy::PickArgs pick; grpc_call_element* elem; QueuedPick* next = nullptr; }; @@ -223,7 +222,7 @@ class ChannelData { static bool ProcessResolverResultLocked( void* arg, Resolver::Result* result, const char** lb_policy_name, - RefCountedPtr* lb_policy_config, + RefCountedPtr* lb_policy_config, grpc_error** service_config_error); grpc_error* DoPingLocked(grpc_transport_op* op); @@ -236,7 +235,7 @@ class ChannelData { const Resolver::Result& resolver_result, const internal::ClientChannelGlobalParsedConfig* parsed_service_config, UniquePtr* lb_policy_name, - RefCountedPtr* lb_policy_config); + RefCountedPtr* lb_policy_config); // // Fields set at construction and never modified. @@ -314,6 +313,16 @@ class CallData { private: class QueuedPickCanceller; + class LbCallState : public LoadBalancingPolicy::CallState { + public: + explicit LbCallState(CallData* calld) : calld_(calld) {} + + void* Alloc(size_t size) override { return calld_->arena_->Alloc(size); } + + private: + CallData* calld_; + }; + // State used for starting a retryable batch on a subchannel call. // This provides its own grpc_transport_stream_op_batch and other data // structures needed to populate the ops in the batch. @@ -449,8 +458,9 @@ class CallData { grpc_call_element* elem, SubchannelCallBatchData* batch_data, SubchannelCallRetryState* retry_state); - static void MaybeInjectRecvTrailingMetadataReadyForLoadBalancingPolicy( - const LoadBalancingPolicy::PickArgs& pick, + static void RecvTrailingMetadataReadyForLoadBalancingPolicy( + void* arg, grpc_error* error); + void MaybeInjectRecvTrailingMetadataReadyForLoadBalancingPolicy( grpc_transport_stream_op_batch* batch); // Returns the index into pending_batches_ to be used for batch. @@ -640,8 +650,19 @@ class CallData { bool pick_queued_ = false; bool service_config_applied_ = false; QueuedPickCanceller* pick_canceller_ = nullptr; + LbCallState lb_call_state_; + RefCountedPtr connected_subchannel_; + void (*lb_recv_trailing_metadata_ready_)( + void* user_data, grpc_metadata_batch* recv_trailing_metadata, + LoadBalancingPolicy::CallState* call_state) = nullptr; + void* lb_recv_trailing_metadata_ready_user_data_ = nullptr; grpc_closure pick_closure_; + // For intercepting recv_trailing_metadata_ready for the LB policy. + grpc_metadata_batch* recv_trailing_metadata_ = nullptr; + grpc_closure recv_trailing_metadata_ready_; + grpc_closure* original_recv_trailing_metadata_ready_ = nullptr; + grpc_polling_entity* pollent_ = nullptr; // Batches are added to this list when received from above. @@ -1143,7 +1164,7 @@ void ChannelData::ProcessLbPolicy( const Resolver::Result& resolver_result, const internal::ClientChannelGlobalParsedConfig* parsed_service_config, UniquePtr* lb_policy_name, - RefCountedPtr* lb_policy_config) { + RefCountedPtr* lb_policy_config) { // Prefer the LB policy name found in the service config. if (parsed_service_config != nullptr && parsed_service_config->parsed_lb_config() != nullptr) { @@ -1191,7 +1212,7 @@ void ChannelData::ProcessLbPolicy( // resolver result update. bool ChannelData::ProcessResolverResultLocked( void* arg, Resolver::Result* result, const char** lb_policy_name, - RefCountedPtr* lb_policy_config, + RefCountedPtr* lb_policy_config, grpc_error** service_config_error) { ChannelData* chand = static_cast(arg); RefCountedPtr service_config; @@ -1312,19 +1333,18 @@ grpc_error* ChannelData::DoPingLocked(grpc_transport_op* op) { if (grpc_connectivity_state_check(&state_tracker_) != GRPC_CHANNEL_READY) { return GRPC_ERROR_CREATE_FROM_STATIC_STRING("channel not connected"); } - LoadBalancingPolicy::PickArgs pick; - grpc_error* error = GRPC_ERROR_NONE; - picker_->Pick(&pick, &error); - if (pick.connected_subchannel != nullptr) { - pick.connected_subchannel->Ping(op->send_ping.on_initiate, - op->send_ping.on_ack); + LoadBalancingPolicy::PickResult result = + picker_->Pick(LoadBalancingPolicy::PickArgs()); + if (result.connected_subchannel != nullptr) { + result.connected_subchannel->Ping(op->send_ping.on_initiate, + op->send_ping.on_ack); } else { - if (error == GRPC_ERROR_NONE) { - error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( + if (result.error == GRPC_ERROR_NONE) { + result.error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "LB policy dropped call on ping"); } } - return error; + return result.error; } void ChannelData::StartTransportOpLocked(void* arg, grpc_error* ignored) { @@ -1505,6 +1525,7 @@ CallData::CallData(grpc_call_element* elem, const ChannelData& chand, owning_call_(args.call_stack), call_combiner_(args.call_combiner), call_context_(args.context), + lb_call_state_(this), pending_send_initial_metadata_(false), pending_send_message_(false), pending_send_trailing_metadata_(false), @@ -1737,18 +1758,30 @@ void CallData::FreeCachedSendOpDataForCompletedBatch( // LB recv_trailing_metadata_ready handling // +void CallData::RecvTrailingMetadataReadyForLoadBalancingPolicy( + void* arg, grpc_error* error) { + CallData* calld = static_cast(arg); + // Invoke callback to LB policy. + calld->lb_recv_trailing_metadata_ready_( + calld->lb_recv_trailing_metadata_ready_user_data_, + calld->recv_trailing_metadata_, &calld->lb_call_state_); + // Chain to original callback. + GRPC_CLOSURE_RUN(calld->original_recv_trailing_metadata_ready_, + GRPC_ERROR_REF(error)); +} + void CallData::MaybeInjectRecvTrailingMetadataReadyForLoadBalancingPolicy( - const LoadBalancingPolicy::PickArgs& pick, grpc_transport_stream_op_batch* batch) { - if (pick.recv_trailing_metadata_ready != nullptr) { - *pick.original_recv_trailing_metadata_ready = + if (lb_recv_trailing_metadata_ready_ != nullptr) { + recv_trailing_metadata_ = + batch->payload->recv_trailing_metadata.recv_trailing_metadata; + original_recv_trailing_metadata_ready_ = batch->payload->recv_trailing_metadata.recv_trailing_metadata_ready; + GRPC_CLOSURE_INIT(&recv_trailing_metadata_ready_, + RecvTrailingMetadataReadyForLoadBalancingPolicy, this, + grpc_schedule_on_exec_ctx); batch->payload->recv_trailing_metadata.recv_trailing_metadata_ready = - pick.recv_trailing_metadata_ready; - if (pick.recv_trailing_metadata != nullptr) { - *pick.recv_trailing_metadata = - batch->payload->recv_trailing_metadata.recv_trailing_metadata; - } + &recv_trailing_metadata_ready_; } } @@ -1894,8 +1927,7 @@ void CallData::PendingBatchesFail( grpc_transport_stream_op_batch* batch = pending->batch; if (batch != nullptr) { if (batch->recv_trailing_metadata) { - MaybeInjectRecvTrailingMetadataReadyForLoadBalancingPolicy(pick_.pick, - batch); + MaybeInjectRecvTrailingMetadataReadyForLoadBalancingPolicy(batch); } batch->handler_private.extra_arg = this; GRPC_CLOSURE_INIT(&batch->handler_private.closure, @@ -1949,8 +1981,7 @@ void CallData::PendingBatchesResume(grpc_call_element* elem) { grpc_transport_stream_op_batch* batch = pending->batch; if (batch != nullptr) { if (batch->recv_trailing_metadata) { - MaybeInjectRecvTrailingMetadataReadyForLoadBalancingPolicy(pick_.pick, - batch); + MaybeInjectRecvTrailingMetadataReadyForLoadBalancingPolicy(batch); } batch->handler_private.extra_arg = subchannel_call_.get(); GRPC_CLOSURE_INIT(&batch->handler_private.closure, @@ -2011,7 +2042,7 @@ void CallData::DoRetry(grpc_call_element* elem, GPR_ASSERT(retry_policy != nullptr); // Reset subchannel call and connected subchannel. subchannel_call_.reset(); - pick_.pick.connected_subchannel.reset(); + connected_subchannel_.reset(); // Compute backoff delay. grpc_millis next_attempt_time; if (server_pushback_ms >= 0) { @@ -2868,7 +2899,7 @@ void CallData::AddRetriableRecvTrailingMetadataOp( .recv_trailing_metadata_ready = &retry_state->recv_trailing_metadata_ready; MaybeInjectRecvTrailingMetadataReadyForLoadBalancingPolicy( - pick_.pick, &batch_data->batch); + &batch_data->batch); } void CallData::StartInternalRecvTrailingMetadata(grpc_call_element* elem) { @@ -3135,8 +3166,7 @@ void CallData::CreateSubchannelCall(grpc_call_element* elem) { // need to use a separate call context for each subchannel call. call_context_, call_combiner_, parent_data_size}; grpc_error* error = GRPC_ERROR_NONE; - subchannel_call_ = - pick_.pick.connected_subchannel->CreateCall(call_args, &error); + subchannel_call_ = connected_subchannel_->CreateCall(call_args, &error); if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { gpr_log(GPR_INFO, "chand=%p calld=%p: create subchannel_call=%p: error=%s", chand, this, subchannel_call_.get(), grpc_error_string(error)); @@ -3297,13 +3327,14 @@ void CallData::MaybeApplyServiceConfigToCallLocked(grpc_call_element* elem) { } } -const char* PickResultName(LoadBalancingPolicy::PickResult result) { - switch (result) { - case LoadBalancingPolicy::PICK_COMPLETE: +const char* PickResultTypeName( + LoadBalancingPolicy::PickResult::ResultType type) { + switch (type) { + case LoadBalancingPolicy::PickResult::PICK_COMPLETE: return "COMPLETE"; - case LoadBalancingPolicy::PICK_QUEUE: + case LoadBalancingPolicy::PickResult::PICK_QUEUE: return "QUEUE"; - case LoadBalancingPolicy::PICK_TRANSIENT_FAILURE: + case LoadBalancingPolicy::PickResult::PICK_TRANSIENT_FAILURE: return "TRANSIENT_FAILURE"; } GPR_UNREACHABLE_CODE(return "UNKNOWN"); @@ -3313,8 +3344,10 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { grpc_call_element* elem = static_cast(arg); CallData* calld = static_cast(elem->call_data); ChannelData* chand = static_cast(elem->channel_data); - GPR_ASSERT(calld->pick_.pick.connected_subchannel == nullptr); + GPR_ASSERT(calld->connected_subchannel_ == nullptr); GPR_ASSERT(calld->subchannel_call_ == nullptr); + // Apply service config to call if needed. + calld->MaybeApplyServiceConfigToCallLocked(elem); // If this is a retry, use the send_initial_metadata payload that // we've cached; otherwise, use the pending batch. The // send_initial_metadata batch will be the first pending batch in the @@ -3325,58 +3358,58 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { // allocate the subchannel batch earlier so that we can give the // subchannel's copy of the metadata batch (which is copied for each // attempt) to the LB policy instead the one from the parent channel. - calld->pick_.pick.initial_metadata = + LoadBalancingPolicy::PickArgs pick_args; + pick_args.call_state = &calld->lb_call_state_; + pick_args.initial_metadata = calld->seen_send_initial_metadata_ ? &calld->send_initial_metadata_ : calld->pending_batches_[0] .batch->payload->send_initial_metadata.send_initial_metadata; - uint32_t* send_initial_metadata_flags = + // Grab initial metadata flags so that we can check later if the call has + // wait_for_ready enabled. + const uint32_t send_initial_metadata_flags = calld->seen_send_initial_metadata_ - ? &calld->send_initial_metadata_flags_ - : &calld->pending_batches_[0] - .batch->payload->send_initial_metadata - .send_initial_metadata_flags; - // Apply service config to call if needed. - calld->MaybeApplyServiceConfigToCallLocked(elem); + ? calld->send_initial_metadata_flags_ + : calld->pending_batches_[0] + .batch->payload->send_initial_metadata + .send_initial_metadata_flags; // When done, we schedule this closure to leave the data plane combiner. GRPC_CLOSURE_INIT(&calld->pick_closure_, PickDone, elem, grpc_schedule_on_exec_ctx); // Attempt pick. - error = GRPC_ERROR_NONE; - auto pick_result = chand->picker()->Pick(&calld->pick_.pick, &error); + auto result = chand->picker()->Pick(pick_args); if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { gpr_log(GPR_INFO, "chand=%p calld=%p: LB pick returned %s (connected_subchannel=%p, " "error=%s)", - chand, calld, PickResultName(pick_result), - calld->pick_.pick.connected_subchannel.get(), - grpc_error_string(error)); + chand, calld, PickResultTypeName(result.type), + result.connected_subchannel.get(), grpc_error_string(result.error)); } - switch (pick_result) { - case LoadBalancingPolicy::PICK_TRANSIENT_FAILURE: { + switch (result.type) { + case LoadBalancingPolicy::PickResult::PICK_TRANSIENT_FAILURE: { // If we're shutting down, fail all RPCs. grpc_error* disconnect_error = chand->disconnect_error(); if (disconnect_error != GRPC_ERROR_NONE) { - GRPC_ERROR_UNREF(error); + GRPC_ERROR_UNREF(result.error); GRPC_CLOSURE_SCHED(&calld->pick_closure_, GRPC_ERROR_REF(disconnect_error)); break; } // If wait_for_ready is false, then the error indicates the RPC // attempt's final status. - if ((*send_initial_metadata_flags & + if ((send_initial_metadata_flags & GRPC_INITIAL_METADATA_WAIT_FOR_READY) == 0) { // Retry if appropriate; otherwise, fail. grpc_status_code status = GRPC_STATUS_OK; - grpc_error_get_status(error, calld->deadline_, &status, nullptr, + grpc_error_get_status(result.error, calld->deadline_, &status, nullptr, nullptr, nullptr); if (!calld->enable_retries_ || !calld->MaybeRetry(elem, nullptr /* batch_data */, status, nullptr /* server_pushback_md */)) { grpc_error* new_error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( - "Failed to pick subchannel", &error, 1); - GRPC_ERROR_UNREF(error); + "Failed to pick subchannel", &result.error, 1); + GRPC_ERROR_UNREF(result.error); GRPC_CLOSURE_SCHED(&calld->pick_closure_, new_error); } if (calld->pick_queued_) calld->RemoveCallFromQueuedPicksLocked(elem); @@ -3384,19 +3417,24 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { } // If wait_for_ready is true, then queue to retry when we get a new // picker. - GRPC_ERROR_UNREF(error); + GRPC_ERROR_UNREF(result.error); } // Fallthrough - case LoadBalancingPolicy::PICK_QUEUE: + case LoadBalancingPolicy::PickResult::PICK_QUEUE: if (!calld->pick_queued_) calld->AddCallToQueuedPicksLocked(elem); break; default: // PICK_COMPLETE // Handle drops. - if (GPR_UNLIKELY(calld->pick_.pick.connected_subchannel == nullptr)) { - error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( + if (GPR_UNLIKELY(result.connected_subchannel == nullptr)) { + result.error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Call dropped by load balancing policy"); } - GRPC_CLOSURE_SCHED(&calld->pick_closure_, error); + calld->connected_subchannel_ = std::move(result.connected_subchannel); + calld->lb_recv_trailing_metadata_ready_ = + result.recv_trailing_metadata_ready; + calld->lb_recv_trailing_metadata_ready_user_data_ = + result.recv_trailing_metadata_ready_user_data; + GRPC_CLOSURE_SCHED(&calld->pick_closure_, result.error); if (calld->pick_queued_) calld->RemoveCallFromQueuedPicksLocked(elem); } } diff --git a/src/core/ext/filters/client_channel/lb_policy.cc b/src/core/ext/filters/client_channel/lb_policy.cc index 6fa799343ca..3e4d3703c82 100644 --- a/src/core/ext/filters/client_channel/lb_policy.cc +++ b/src/core/ext/filters/client_channel/lb_policy.cc @@ -105,7 +105,7 @@ LoadBalancingPolicy::UpdateArgs& LoadBalancingPolicy::UpdateArgs::operator=( // LoadBalancingPolicy::PickResult LoadBalancingPolicy::QueuePicker::Pick( - PickArgs* pick, grpc_error** error) { + PickArgs args) { // We invoke the parent's ExitIdleLocked() via a closure instead // of doing it directly here, for two reasons: // 1. ExitIdleLocked() may cause the policy's state to change and @@ -125,7 +125,9 @@ LoadBalancingPolicy::PickResult LoadBalancingPolicy::QueuePicker::Pick( grpc_combiner_scheduler(parent_->combiner())), GRPC_ERROR_NONE); } - return PICK_QUEUE; + PickResult result; + result.type = PickResult::PICK_QUEUE; + return result; } void LoadBalancingPolicy::QueuePicker::CallExitIdle(void* arg, @@ -135,4 +137,16 @@ void LoadBalancingPolicy::QueuePicker::CallExitIdle(void* arg, parent->Unref(); } +// +// LoadBalancingPolicy::TransientFailurePicker +// + +LoadBalancingPolicy::PickResult +LoadBalancingPolicy::TransientFailurePicker::Pick(PickArgs args) { + PickResult result; + result.type = PickResult::PICK_TRANSIENT_FAILURE; + result.error = GRPC_ERROR_REF(error_); + return result; +} + } // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h index 2ac7df63b7d..5920254a9ef 100644 --- a/src/core/ext/filters/client_channel/lb_policy.h +++ b/src/core/ext/filters/client_channel/lb_policy.h @@ -32,21 +32,9 @@ #include "src/core/lib/iomgr/polling_entity.h" #include "src/core/lib/transport/connectivity_state.h" -extern grpc_core::DebugOnlyTraceFlag grpc_trace_lb_policy_refcount; - namespace grpc_core { -/// Interface for parsed forms of load balancing configs found in a service -/// config. -class ParsedLoadBalancingConfig : public RefCounted { - public: - virtual ~ParsedLoadBalancingConfig() = default; - - // Returns the load balancing policy name - virtual const char* name() const GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS; -}; +extern DebugOnlyTraceFlag grpc_trace_lb_policy_refcount; /// Interface for load balancing policies. /// @@ -89,66 +77,77 @@ class ParsedLoadBalancingConfig : public RefCounted { // interested_parties() hooks from the API. class LoadBalancingPolicy : public InternallyRefCounted { public: + /// Interface for accessing per-call state. + class CallState { + public: + CallState() = default; + virtual ~CallState() = default; + + /// Allocates memory associated with the call, which will be + /// automatically freed when the call is complete. + /// It is more efficient to use this than to allocate memory directly + /// for allocations that need to be made on a per-call basis. + virtual void* Alloc(size_t size) GRPC_ABSTRACT; + + GRPC_ABSTRACT_BASE_CLASS + }; + /// Arguments used when picking a subchannel for an RPC. struct PickArgs { - /// - /// Input parameters. - /// /// Initial metadata associated with the picking call. /// The LB policy may use the existing metadata to influence its routing /// decision, and it may add new metadata elements to be sent with the /// call to the chosen backend. // TODO(roth): Provide a more generic metadata API here. grpc_metadata_batch* initial_metadata = nullptr; - /// Storage for LB token in \a initial_metadata, or nullptr if not used. - // TODO(roth): Remove this from the API. Maybe have the LB policy - // allocate this on the arena instead? - grpc_linked_mdelem lb_token_mdelem_storage; - /// - /// Output parameters. - /// - /// Will be set to the selected subchannel, or nullptr on failure or when - /// the LB policy decides to drop the call. - RefCountedPtr connected_subchannel; - /// Callback set by lb policy to be notified of trailing metadata. - /// The callback must be scheduled on grpc_schedule_on_exec_ctx. - // TODO(roth): Provide a cleaner callback API. - grpc_closure* recv_trailing_metadata_ready = nullptr; - /// The address that will be set to point to the original - /// recv_trailing_metadata_ready callback, to be invoked by the LB - /// policy's recv_trailing_metadata_ready callback when complete. - /// Must be non-null if recv_trailing_metadata_ready is non-null. - // TODO(roth): Consider making the recv_trailing_metadata closure a - // synchronous callback, in which case it is not responsible for - // chaining to the next callback, so this can be removed from the API. - grpc_closure** original_recv_trailing_metadata_ready = nullptr; - /// If this is not nullptr, then the client channel will point it to the - /// call's trailing metadata before invoking recv_trailing_metadata_ready. - /// If this is nullptr, then the callback will still be called. - /// The lb does not have ownership of the metadata. - // TODO(roth): If we make this a synchronous callback, then this can - // be passed to the callback as a parameter and can be removed from - // the API here. - grpc_metadata_batch** recv_trailing_metadata = nullptr; + /// An interface for accessing call state. Can be used to allocate + /// data associated with the call in an efficient way. + CallState* call_state; }; /// The result of picking a subchannel for an RPC. - enum PickResult { - // Pick complete. If connected_subchannel is non-null, client channel - // can immediately proceed with the call on connected_subchannel; - // otherwise, call should be dropped. - PICK_COMPLETE, - // Pick cannot be completed until something changes on the control - // plane. Client channel will queue the pick and try again the - // next time the picker is updated. - PICK_QUEUE, - // LB policy is in transient failure. If the pick is wait_for_ready, - // client channel will wait for the next picker and try again; - // otherwise, the call will be failed immediately (although it may - // be retried if the client channel is configured to do so). - // The Pick() method will set its error parameter if this value is - // returned. - PICK_TRANSIENT_FAILURE, + struct PickResult { + enum ResultType { + /// Pick complete. If connected_subchannel is non-null, client channel + /// can immediately proceed with the call on connected_subchannel; + /// otherwise, call should be dropped. + PICK_COMPLETE, + /// Pick cannot be completed until something changes on the control + /// plane. Client channel will queue the pick and try again the + /// next time the picker is updated. + PICK_QUEUE, + /// LB policy is in transient failure. If the pick is wait_for_ready, + /// client channel will wait for the next picker and try again; + /// otherwise, the call will be failed immediately (although it may + /// be retried if the client channel is configured to do so). + /// The Pick() method will set its error parameter if this value is + /// returned. + PICK_TRANSIENT_FAILURE, + }; + ResultType type; + + /// Used only if type is PICK_COMPLETE. Will be set to the selected + /// subchannel, or nullptr if the LB policy decides to drop the call. + RefCountedPtr connected_subchannel; + + /// Used only if type is PICK_TRANSIENT_FAILURE. + /// Error to be set when returning a transient failure. + // TODO(roth): Replace this with something similar to grpc::Status, + // so that we don't expose grpc_error to this API. + grpc_error* error = GRPC_ERROR_NONE; + + /// Used only if type is PICK_COMPLETE. + /// Callback set by lb policy to be notified of trailing metadata. + /// The user_data argument will be set to the + /// recv_trailing_metadata_ready_user_data field. + /// recv_trailing_metadata will be set to the metadata, which may be + /// modified by the callback. The callback does not take ownership, + /// however, so any data that needs to be used after returning must + /// be copied. + void (*recv_trailing_metadata_ready)( + void* user_data, grpc_metadata_batch* recv_trailing_metadata, + CallState* call_state) = nullptr; + void* recv_trailing_metadata_ready_user_data = nullptr; }; /// A subchannel picker is the object used to pick the subchannel to @@ -162,17 +161,14 @@ class LoadBalancingPolicy : public InternallyRefCounted { /// live in the LB policy object itself. /// /// Currently, pickers are always accessed from within the - /// client_channel combiner, so they do not have to be thread-safe. - // TODO(roth): In a subsequent PR, split the data plane work (i.e., - // the interaction with the picker) and the control plane work (i.e., - // the interaction with the LB policy) into two different - // synchronization mechanisms, to avoid lock contention between the two. + /// client_channel data plane combiner, so they do not have to be + /// thread-safe. class SubchannelPicker { public: SubchannelPicker() = default; virtual ~SubchannelPicker() = default; - virtual PickResult Pick(PickArgs* pick, grpc_error** error) GRPC_ABSTRACT; + virtual PickResult Pick(PickArgs args) GRPC_ABSTRACT; GRPC_ABSTRACT_BASE_CLASS }; @@ -208,11 +204,24 @@ class LoadBalancingPolicy : public InternallyRefCounted { GRPC_ABSTRACT_BASE_CLASS }; + /// Interface for configuration data used by an LB policy implementation. + /// Individual implementations will create a subclass that adds methods to + /// return the parameters they need. + class Config : public RefCounted { + public: + virtual ~Config() = default; + + // Returns the load balancing policy name + virtual const char* name() const GRPC_ABSTRACT; + + GRPC_ABSTRACT_BASE_CLASS + }; + /// Data passed to the UpdateLocked() method when new addresses and /// config are available. struct UpdateArgs { ServerAddressList addresses; - RefCountedPtr config; + RefCountedPtr config; const grpc_channel_args* args = nullptr; // TODO(roth): Remove everything below once channel args is @@ -291,7 +300,7 @@ class LoadBalancingPolicy : public InternallyRefCounted { explicit QueuePicker(RefCountedPtr parent) : parent_(std::move(parent)) {} - PickResult Pick(PickArgs* pick, grpc_error** error) override; + PickResult Pick(PickArgs args) override; private: static void CallExitIdle(void* arg, grpc_error* error); @@ -306,10 +315,7 @@ class LoadBalancingPolicy : public InternallyRefCounted { explicit TransientFailurePicker(grpc_error* error) : error_(error) {} ~TransientFailurePicker() override { GRPC_ERROR_UNREF(error_); } - PickResult Pick(PickArgs* pick, grpc_error** error) override { - *error = GRPC_ERROR_REF(error_); - return PICK_TRANSIENT_FAILURE; - } + PickResult Pick(PickArgs args) override; private: grpc_error* error_; diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index ed6e8de3f21..2c652e4c6e6 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -118,19 +118,19 @@ namespace { constexpr char kGrpclb[] = "grpclb"; -class ParsedGrpcLbConfig : public ParsedLoadBalancingConfig { +class ParsedGrpcLbConfig : public LoadBalancingPolicy::Config { public: explicit ParsedGrpcLbConfig( - RefCountedPtr child_policy) + RefCountedPtr child_policy) : child_policy_(std::move(child_policy)) {} const char* name() const override { return kGrpclb; } - RefCountedPtr child_policy() const { + RefCountedPtr child_policy() const { return child_policy_; } private: - RefCountedPtr child_policy_; + RefCountedPtr child_policy_; }; class GrpcLb : public LoadBalancingPolicy { @@ -274,7 +274,7 @@ class GrpcLb : public LoadBalancingPolicy { child_picker_(std::move(child_picker)), client_stats_(std::move(client_stats)) {} - PickResult Pick(PickArgs* pick, grpc_error** error) override; + PickResult Pick(PickArgs args) override; private: // Storing the address for logging, but not holding a ref. @@ -394,7 +394,7 @@ class GrpcLb : public LoadBalancingPolicy { // until it reports READY, at which point it will be moved to child_policy_. OrphanablePtr pending_child_policy_; // The child policy config. - RefCountedPtr child_policy_config_; + RefCountedPtr child_policy_config_; // Child policy in state READY. bool child_policy_ready_ = false; }; @@ -561,7 +561,8 @@ const char* GrpcLb::Serverlist::ShouldDrop() { // GrpcLb::Picker // -GrpcLb::PickResult GrpcLb::Picker::Pick(PickArgs* pick, grpc_error** error) { +GrpcLb::PickResult GrpcLb::Picker::Pick(PickArgs args) { + PickResult result; // Check if we should drop the call. const char* drop_token = serverlist_->ShouldDrop(); if (drop_token != nullptr) { @@ -573,26 +574,28 @@ GrpcLb::PickResult GrpcLb::Picker::Pick(PickArgs* pick, grpc_error** error) { if (client_stats_ != nullptr) { client_stats_->AddCallDropped(drop_token); } - return PICK_COMPLETE; + result.type = PickResult::PICK_COMPLETE; + return result; } // Forward pick to child policy. - PickResult result = child_picker_->Pick(pick, error); + result = child_picker_->Pick(args); // If pick succeeded, add LB token to initial metadata. - if (result == PickResult::PICK_COMPLETE && - pick->connected_subchannel != nullptr) { + if (result.type == PickResult::PICK_COMPLETE && + result.connected_subchannel != nullptr) { const grpc_arg* arg = grpc_channel_args_find( - pick->connected_subchannel->args(), GRPC_ARG_GRPCLB_ADDRESS_LB_TOKEN); + result.connected_subchannel->args(), GRPC_ARG_GRPCLB_ADDRESS_LB_TOKEN); if (arg == nullptr) { gpr_log(GPR_ERROR, - "[grpclb %p picker %p] No LB token for connected subchannel " - "pick %p", - parent_, this, pick); + "[grpclb %p picker %p] No LB token for connected subchannel %p", + parent_, this, result.connected_subchannel.get()); abort(); } grpc_mdelem lb_token = {reinterpret_cast(arg->value.pointer.p)}; GPR_ASSERT(!GRPC_MDISNULL(lb_token)); + grpc_linked_mdelem* mdelem_storage = static_cast( + args.call_state->Alloc(sizeof(grpc_linked_mdelem))); GPR_ASSERT(grpc_metadata_batch_add_tail( - pick->initial_metadata, &pick->lb_token_mdelem_storage, + args.initial_metadata, mdelem_storage, GRPC_MDELEM_REF(lb_token)) == GRPC_ERROR_NONE); GrpcLbClientStats* client_stats = static_cast( grpc_mdelem_get_user_data(lb_token, GrpcLbClientStats::Destroy)); @@ -1800,15 +1803,15 @@ class GrpcLbFactory : public LoadBalancingPolicyFactory { const char* name() const override { return kGrpclb; } - RefCountedPtr ParseLoadBalancingConfig( + RefCountedPtr ParseLoadBalancingConfig( const grpc_json* json, grpc_error** error) const override { GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); if (json == nullptr) { - return RefCountedPtr( + return RefCountedPtr( New(nullptr)); } InlinedVector error_list; - RefCountedPtr child_policy; + RefCountedPtr child_policy; for (const grpc_json* field = json->child; field != nullptr; field = field->next) { if (field->key == nullptr) continue; @@ -1826,7 +1829,7 @@ class GrpcLbFactory : public LoadBalancingPolicyFactory { } } if (error_list.empty()) { - return RefCountedPtr( + return RefCountedPtr( New(std::move(child_policy))); } else { *error = GRPC_ERROR_CREATE_FROM_VECTOR("GrpcLb Parser", &error_list); diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index 199e973e72c..1b0dd230b49 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -115,9 +115,11 @@ class PickFirst : public LoadBalancingPolicy { explicit Picker(RefCountedPtr connected_subchannel) : connected_subchannel_(std::move(connected_subchannel)) {} - PickResult Pick(PickArgs* pick, grpc_error** error) override { - pick->connected_subchannel = connected_subchannel_; - return PICK_COMPLETE; + PickResult Pick(PickArgs args) override { + PickResult result; + result.type = PickResult::PICK_COMPLETE; + result.connected_subchannel = connected_subchannel_; + return result; } private: @@ -527,7 +529,7 @@ void PickFirst::PickFirstSubchannelData:: } } -class ParsedPickFirstConfig : public ParsedLoadBalancingConfig { +class ParsedPickFirstConfig : public LoadBalancingPolicy::Config { public: const char* name() const override { return kPickFirst; } }; @@ -545,12 +547,12 @@ class PickFirstFactory : public LoadBalancingPolicyFactory { const char* name() const override { return kPickFirst; } - RefCountedPtr ParseLoadBalancingConfig( + RefCountedPtr ParseLoadBalancingConfig( const grpc_json* json, grpc_error** error) const override { if (json != nullptr) { GPR_DEBUG_ASSERT(strcmp(json->key, name()) == 0); } - return RefCountedPtr( + return RefCountedPtr( New()); } }; diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc index 1693032ea24..0b9915de28e 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc @@ -149,7 +149,7 @@ class RoundRobin : public LoadBalancingPolicy { public: Picker(RoundRobin* parent, RoundRobinSubchannelList* subchannel_list); - PickResult Pick(PickArgs* pick, grpc_error** error) override; + PickResult Pick(PickArgs args) override; private: // Using pointer value only, no ref held -- do not dereference! @@ -220,8 +220,7 @@ RoundRobin::Picker::Picker(RoundRobin* parent, } } -RoundRobin::PickResult RoundRobin::Picker::Pick(PickArgs* pick, - grpc_error** error) { +RoundRobin::PickResult RoundRobin::Picker::Pick(PickArgs args) { last_picked_index_ = (last_picked_index_ + 1) % subchannels_.size(); if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_round_robin_trace)) { gpr_log(GPR_INFO, @@ -230,8 +229,10 @@ RoundRobin::PickResult RoundRobin::Picker::Pick(PickArgs* pick, parent_, this, last_picked_index_, subchannels_[last_picked_index_].get()); } - pick->connected_subchannel = subchannels_[last_picked_index_]; - return PICK_COMPLETE; + PickResult result; + result.type = PickResult::PICK_COMPLETE; + result.connected_subchannel = subchannels_[last_picked_index_]; + return result; } // @@ -503,7 +504,7 @@ void RoundRobin::UpdateLocked(UpdateArgs args) { } } -class ParsedRoundRobinConfig : public ParsedLoadBalancingConfig { +class ParsedRoundRobinConfig : public LoadBalancingPolicy::Config { public: const char* name() const override { return kRoundRobin; } }; @@ -521,12 +522,12 @@ class RoundRobinFactory : public LoadBalancingPolicyFactory { const char* name() const override { return kRoundRobin; } - RefCountedPtr ParseLoadBalancingConfig( + RefCountedPtr ParseLoadBalancingConfig( const grpc_json* json, grpc_error** error) const override { if (json != nullptr) { GPR_DEBUG_ASSERT(strcmp(json->key, name()) == 0); } - return RefCountedPtr( + return RefCountedPtr( New()); } }; diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index 819bad6c00d..d70042af229 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -120,11 +120,11 @@ constexpr char kXds[] = "xds_experimental"; constexpr char kDefaultLocalityName[] = "xds_default_locality"; constexpr uint32_t kDefaultLocalityWeight = 3; -class ParsedXdsConfig : public ParsedLoadBalancingConfig { +class ParsedXdsConfig : public LoadBalancingPolicy::Config { public: ParsedXdsConfig(const char* balancer_name, - RefCountedPtr child_policy, - RefCountedPtr fallback_policy) + RefCountedPtr child_policy, + RefCountedPtr fallback_policy) : balancer_name_(balancer_name), child_policy_(std::move(child_policy)), fallback_policy_(std::move(fallback_policy)) {} @@ -133,18 +133,18 @@ class ParsedXdsConfig : public ParsedLoadBalancingConfig { const char* balancer_name() const { return balancer_name_; }; - RefCountedPtr child_policy() const { + RefCountedPtr child_policy() const { return child_policy_; } - RefCountedPtr fallback_policy() const { + RefCountedPtr fallback_policy() const { return fallback_policy_; } private: const char* balancer_name_ = nullptr; - RefCountedPtr child_policy_; - RefCountedPtr fallback_policy_; + RefCountedPtr child_policy_; + RefCountedPtr fallback_policy_; }; class XdsLb : public LoadBalancingPolicy { @@ -300,9 +300,7 @@ class XdsLb : public LoadBalancingPolicy { public: explicit PickerRef(UniquePtr picker) : picker_(std::move(picker)) {} - PickResult Pick(PickArgs* pick, grpc_error** error) { - return picker_->Pick(pick, error); - } + PickResult Pick(PickArgs args) { return picker_->Pick(args); } private: UniquePtr picker_; @@ -322,12 +320,11 @@ class XdsLb : public LoadBalancingPolicy { : client_stats_(std::move(client_stats)), pickers_(std::move(pickers)) {} - PickResult Pick(PickArgs* pick, grpc_error** error) override; + PickResult Pick(PickArgs args) override; private: // Calls the picker of the locality that the key falls within - PickResult PickFromLocality(const uint32_t key, PickArgs* pick, - grpc_error** error); + PickResult PickFromLocality(const uint32_t key, PickArgs args); RefCountedPtr client_stats_; PickerList pickers_; }; @@ -363,7 +360,7 @@ class XdsLb : public LoadBalancingPolicy { ~LocalityEntry() = default; void UpdateLocked(xds_grpclb_serverlist* serverlist, - ParsedLoadBalancingConfig* child_policy_config, + LoadBalancingPolicy::Config* child_policy_config, const grpc_channel_args* args); void ShutdownLocked(); void ResetBackoffLocked(); @@ -410,7 +407,7 @@ class XdsLb : public LoadBalancingPolicy { }; void UpdateLocked(const LocalityList& locality_list, - ParsedLoadBalancingConfig* child_policy_config, + LoadBalancingPolicy::Config* child_policy_config, const grpc_channel_args* args, XdsLb* parent); void ShutdownLocked(); void ResetBackoffLocked(); @@ -506,7 +503,7 @@ class XdsLb : public LoadBalancingPolicy { grpc_closure lb_on_fallback_; // The policy to use for the fallback backends. - RefCountedPtr fallback_policy_config_; + RefCountedPtr fallback_policy_config_; // Lock held when modifying the value of fallback_policy_ or // pending_fallback_policy_. Mutex fallback_policy_mu_; @@ -515,7 +512,7 @@ class XdsLb : public LoadBalancingPolicy { OrphanablePtr pending_fallback_policy_; // The policy to use for the backends. - RefCountedPtr child_policy_config_; + RefCountedPtr child_policy_config_; // Map of policies to use in the backend LocalityMap locality_map_; // TODO(mhaidry) : Add support for multiple maps of localities @@ -530,25 +527,24 @@ class XdsLb : public LoadBalancingPolicy { // XdsLb::Picker // -XdsLb::PickResult XdsLb::Picker::Pick(PickArgs* pick, grpc_error** error) { +XdsLb::PickResult XdsLb::Picker::Pick(PickArgs args) { // TODO(roth): Add support for drop handling. // Generate a random number between 0 and the total weight const uint32_t key = (rand() * pickers_[pickers_.size() - 1].first) / RAND_MAX; // Forward pick to whichever locality maps to the range in which the // random number falls in. - PickResult result = PickFromLocality(key, pick, error); + PickResult result = PickFromLocality(key, args); // If pick succeeded, add client stats. - if (result == PickResult::PICK_COMPLETE && - pick->connected_subchannel != nullptr && client_stats_ != nullptr) { + if (result.type == PickResult::PICK_COMPLETE && + result.connected_subchannel != nullptr && client_stats_ != nullptr) { // TODO(roth): Add support for client stats. } return result; } XdsLb::PickResult XdsLb::Picker::PickFromLocality(const uint32_t key, - PickArgs* pick, - grpc_error** error) { + PickArgs args) { size_t mid = 0; size_t start_index = 0; size_t end_index = pickers_.size() - 1; @@ -566,7 +562,7 @@ XdsLb::PickResult XdsLb::Picker::PickFromLocality(const uint32_t key, } if (index == 0) index = start_index; GPR_ASSERT(pickers_[index].first > key); - return pickers_[index].second->Pick(pick, error); + return pickers_[index].second->Pick(args); } // @@ -1744,7 +1740,7 @@ void XdsLb::LocalityMap::PruneLocalities(const LocalityList& locality_list) { void XdsLb::LocalityMap::UpdateLocked( const LocalityList& locality_serverlist, - ParsedLoadBalancingConfig* child_policy_config, + LoadBalancingPolicy::Config* child_policy_config, const grpc_channel_args* args, XdsLb* parent) { if (parent->shutting_down_) return; for (size_t i = 0; i < locality_serverlist.size(); i++) { @@ -1839,7 +1835,7 @@ XdsLb::LocalityMap::LocalityEntry::CreateChildPolicyLocked( void XdsLb::LocalityMap::LocalityEntry::UpdateLocked( xds_grpclb_serverlist* serverlist, - ParsedLoadBalancingConfig* child_policy_config, + LoadBalancingPolicy::Config* child_policy_config, const grpc_channel_args* args_in) { if (parent_->shutting_down_) return; // Construct update args. @@ -2158,7 +2154,7 @@ class XdsFactory : public LoadBalancingPolicyFactory { const char* name() const override { return kXds; } - RefCountedPtr ParseLoadBalancingConfig( + RefCountedPtr ParseLoadBalancingConfig( const grpc_json* json, grpc_error** error) const override { GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); if (json == nullptr) { @@ -2174,8 +2170,8 @@ class XdsFactory : public LoadBalancingPolicyFactory { InlinedVector error_list; const char* balancer_name = nullptr; - RefCountedPtr child_policy; - RefCountedPtr fallback_policy; + RefCountedPtr child_policy; + RefCountedPtr fallback_policy; for (const grpc_json* field = json->child; field != nullptr; field = field->next) { if (field->key == nullptr) continue; @@ -2221,7 +2217,7 @@ class XdsFactory : public LoadBalancingPolicyFactory { "field:balancerName error:not found")); } if (error_list.empty()) { - return RefCountedPtr(New( + return RefCountedPtr(New( balancer_name, std::move(child_policy), std::move(fallback_policy))); } else { *error = GRPC_ERROR_CREATE_FROM_VECTOR("Xds Parser", &error_list); diff --git a/src/core/ext/filters/client_channel/lb_policy_factory.h b/src/core/ext/filters/client_channel/lb_policy_factory.h index aaf3e959542..3b8c9faa180 100644 --- a/src/core/ext/filters/client_channel/lb_policy_factory.h +++ b/src/core/ext/filters/client_channel/lb_policy_factory.h @@ -37,7 +37,7 @@ class LoadBalancingPolicyFactory { /// Caller does NOT take ownership of result. virtual const char* name() const GRPC_ABSTRACT; - virtual RefCountedPtr ParseLoadBalancingConfig( + virtual RefCountedPtr ParseLoadBalancingConfig( const grpc_json* json, grpc_error** error) const GRPC_ABSTRACT; virtual ~LoadBalancingPolicyFactory() {} diff --git a/src/core/ext/filters/client_channel/lb_policy_registry.cc b/src/core/ext/filters/client_channel/lb_policy_registry.cc index 973aa26d0f6..20099b52d6c 100644 --- a/src/core/ext/filters/client_channel/lb_policy_registry.cc +++ b/src/core/ext/filters/client_channel/lb_policy_registry.cc @@ -176,7 +176,7 @@ grpc_json* ParseLoadBalancingConfigHelper(const grpc_json* lb_config_array, } } // namespace -RefCountedPtr +RefCountedPtr LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(const grpc_json* json, grpc_error** error) { GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); diff --git a/src/core/ext/filters/client_channel/lb_policy_registry.h b/src/core/ext/filters/client_channel/lb_policy_registry.h index 6820cfc9334..c5f02953a1b 100644 --- a/src/core/ext/filters/client_channel/lb_policy_registry.h +++ b/src/core/ext/filters/client_channel/lb_policy_registry.h @@ -56,7 +56,7 @@ class LoadBalancingPolicyRegistry { /// Returns a parsed object of the load balancing policy to be used from a /// LoadBalancingConfig array \a json. - static RefCountedPtr ParseLoadBalancingConfig( + static RefCountedPtr ParseLoadBalancingConfig( const grpc_json* json, grpc_error** error); }; diff --git a/src/core/ext/filters/client_channel/resolver_result_parsing.cc b/src/core/ext/filters/client_channel/resolver_result_parsing.cc index 6a811a2d936..3a1960bfded 100644 --- a/src/core/ext/filters/client_channel/resolver_result_parsing.cc +++ b/src/core/ext/filters/client_channel/resolver_result_parsing.cc @@ -268,7 +268,7 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json, grpc_error** error) { GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); InlinedVector error_list; - RefCountedPtr parsed_lb_config; + RefCountedPtr parsed_lb_config; UniquePtr lb_policy_name; Optional retry_throttling; const char* health_check_service_name = nullptr; diff --git a/src/core/ext/filters/client_channel/resolver_result_parsing.h b/src/core/ext/filters/client_channel/resolver_result_parsing.h index 7750791c779..d0a0456875d 100644 --- a/src/core/ext/filters/client_channel/resolver_result_parsing.h +++ b/src/core/ext/filters/client_channel/resolver_result_parsing.h @@ -45,7 +45,7 @@ class ClientChannelGlobalParsedConfig : public ServiceConfig::ParsedConfig { }; ClientChannelGlobalParsedConfig( - RefCountedPtr parsed_lb_config, + RefCountedPtr parsed_lb_config, UniquePtr parsed_deprecated_lb_policy, const Optional& retry_throttling, const char* health_check_service_name) @@ -58,7 +58,7 @@ class ClientChannelGlobalParsedConfig : public ServiceConfig::ParsedConfig { return retry_throttling_; } - RefCountedPtr parsed_lb_config() const { + RefCountedPtr parsed_lb_config() const { return parsed_lb_config_; } @@ -71,7 +71,7 @@ class ClientChannelGlobalParsedConfig : public ServiceConfig::ParsedConfig { } private: - RefCountedPtr parsed_lb_config_; + RefCountedPtr parsed_lb_config_; UniquePtr parsed_deprecated_lb_policy_; Optional retry_throttling_; const char* health_check_service_name_; diff --git a/src/core/ext/filters/client_channel/resolving_lb_policy.cc b/src/core/ext/filters/client_channel/resolving_lb_policy.cc index 4e383f65dd1..3fe2ee74c92 100644 --- a/src/core/ext/filters/client_channel/resolving_lb_policy.cc +++ b/src/core/ext/filters/client_channel/resolving_lb_policy.cc @@ -184,7 +184,7 @@ class ResolvingLoadBalancingPolicy::ResolvingControlHelper ResolvingLoadBalancingPolicy::ResolvingLoadBalancingPolicy( Args args, TraceFlag* tracer, UniquePtr target_uri, UniquePtr child_policy_name, - RefCountedPtr child_lb_config, + RefCountedPtr child_lb_config, grpc_error** error) : LoadBalancingPolicy(std::move(args)), tracer_(tracer), @@ -333,7 +333,7 @@ void ResolvingLoadBalancingPolicy::OnResolverError(grpc_error* error) { void ResolvingLoadBalancingPolicy::CreateOrUpdateLbPolicyLocked( const char* lb_policy_name, - RefCountedPtr lb_policy_config, + RefCountedPtr lb_policy_config, Resolver::Result result, TraceStringVector* trace_strings) { // If the child policy name changes, we need to create a new child // policy. When this happens, we leave child_policy_ as-is and store @@ -530,7 +530,7 @@ void ResolvingLoadBalancingPolicy::OnResolverResultChangedLocked( const bool resolution_contains_addresses = result.addresses.size() > 0; // Process the resolver result. const char* lb_policy_name = nullptr; - RefCountedPtr lb_policy_config; + RefCountedPtr lb_policy_config; bool service_config_changed = false; char* service_config_error_string = nullptr; if (process_resolver_result_ != nullptr) { diff --git a/src/core/ext/filters/client_channel/resolving_lb_policy.h b/src/core/ext/filters/client_channel/resolving_lb_policy.h index 0ca6c9563f9..cc9f3176cce 100644 --- a/src/core/ext/filters/client_channel/resolving_lb_policy.h +++ b/src/core/ext/filters/client_channel/resolving_lb_policy.h @@ -57,7 +57,7 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy { ResolvingLoadBalancingPolicy( Args args, TraceFlag* tracer, UniquePtr target_uri, UniquePtr child_policy_name, - RefCountedPtr child_lb_config, + RefCountedPtr child_lb_config, grpc_error** error); // Private ctor, to be used by client_channel only! @@ -70,7 +70,7 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy { // should set the channel to be in TRANSIENT_FAILURE. typedef bool (*ProcessResolverResultCallback)( void* user_data, Resolver::Result* result, const char** lb_policy_name, - RefCountedPtr* lb_policy_config, + RefCountedPtr* lb_policy_config, grpc_error** service_config_error); // If error is set when this returns, then construction failed, and // the caller may not use the new object. @@ -109,7 +109,7 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy { void OnResolverError(grpc_error* error); void CreateOrUpdateLbPolicyLocked( const char* lb_policy_name, - RefCountedPtr lb_policy_config, + RefCountedPtr lb_policy_config, Resolver::Result result, TraceStringVector* trace_strings); OrphanablePtr CreateLbPolicyLocked( const char* lb_policy_name, const grpc_channel_args& args, @@ -126,7 +126,7 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy { ProcessResolverResultCallback process_resolver_result_ = nullptr; void* process_resolver_result_user_data_ = nullptr; UniquePtr child_policy_name_; - RefCountedPtr child_lb_config_; + RefCountedPtr child_lb_config_; // Resolver and associated state. OrphanablePtr resolver_; diff --git a/test/core/util/test_lb_policies.cc b/test/core/util/test_lb_policies.cc index b871f04bc9e..bd28422bcd1 100644 --- a/test/core/util/test_lb_policies.cc +++ b/test/core/util/test_lb_policies.cc @@ -120,10 +120,12 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy cb_(cb), user_data_(user_data) {} - PickResult Pick(PickArgs* pick, grpc_error** error) override { - PickResult result = delegate_picker_->Pick(pick, error); - if (result == PICK_COMPLETE && pick->connected_subchannel != nullptr) { - New(pick, cb_, user_data_); // deletes itself + PickResult Pick(PickArgs args) override { + PickResult result = delegate_picker_->Pick(args); + if (result.type == PickResult::PICK_COMPLETE && + result.connected_subchannel != nullptr) { + new (args.call_state->Alloc(sizeof(TrailingMetadataHandler))) + TrailingMetadataHandler(&result, cb_, user_data_); } return result; } @@ -169,35 +171,27 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy class TrailingMetadataHandler { public: - TrailingMetadataHandler(PickArgs* pick, + TrailingMetadataHandler(PickResult* result, InterceptRecvTrailingMetadataCallback cb, void* user_data) : cb_(cb), user_data_(user_data) { - GRPC_CLOSURE_INIT(&recv_trailing_metadata_ready_, - RecordRecvTrailingMetadata, this, - grpc_schedule_on_exec_ctx); - pick->recv_trailing_metadata_ready = &recv_trailing_metadata_ready_; - pick->original_recv_trailing_metadata_ready = - &original_recv_trailing_metadata_ready_; - pick->recv_trailing_metadata = &recv_trailing_metadata_; + result->recv_trailing_metadata_ready = &RecordRecvTrailingMetadata; + result->recv_trailing_metadata_ready_user_data = this; } private: - static void RecordRecvTrailingMetadata(void* arg, grpc_error* err) { + static void RecordRecvTrailingMetadata( + void* arg, grpc_metadata_batch* recv_trailing_metadata, + CallState* call_state) { TrailingMetadataHandler* self = static_cast(arg); - GPR_ASSERT(self->recv_trailing_metadata_ != nullptr); + GPR_ASSERT(recv_trailing_metadata != nullptr); self->cb_(self->user_data_); - GRPC_CLOSURE_SCHED(self->original_recv_trailing_metadata_ready_, - GRPC_ERROR_REF(err)); - Delete(self); + self->~TrailingMetadataHandler(); } InterceptRecvTrailingMetadataCallback cb_; void* user_data_; - grpc_closure recv_trailing_metadata_ready_; - grpc_closure* original_recv_trailing_metadata_ready_ = nullptr; - grpc_metadata_batch* recv_trailing_metadata_ = nullptr; }; }; From 0f83755c6e676d1e0e67b5f99d06e525bd618944 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Fri, 10 May 2019 13:57:01 -0700 Subject: [PATCH 0342/1555] chttp2 hpack encoder: fast-pathed static md/slice ops --- .../chttp2/transport/hpack_encoder.cc | 105 +++-- .../transport/chttp2/transport/hpack_table.cc | 10 - .../transport/chttp2/transport/hpack_table.h | 11 +- src/core/lib/slice/slice.cc | 3 +- src/core/lib/slice/slice_hash_table.h | 4 +- src/core/lib/slice/slice_intern.cc | 21 +- src/core/lib/slice/slice_internal.h | 31 ++ src/core/lib/slice/slice_weak_hash_table.h | 4 +- src/core/lib/surface/server.cc | 10 +- src/core/lib/transport/metadata.cc | 36 +- src/core/lib/transport/metadata.h | 30 +- src/core/lib/transport/static_metadata.cc | 434 ++++++++++------- src/core/lib/transport/static_metadata.h | 435 +++++++++++------- tools/codegen/core/gen_static_metadata.py | 18 +- 14 files changed, 705 insertions(+), 447 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc index d2607e97707..65f9ef4a53a 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc @@ -56,7 +56,10 @@ /* don't consider adding anything bigger than this to the hpack table */ #define MAX_DECODER_SPACE_USAGE 512 -static grpc_slice_refcount terminal_slice_refcount; +#define DATA_FRAME_HEADER_SIZE 9 + +static grpc_slice_refcount terminal_slice_refcount( + grpc_slice_refcount::Type::STATIC); static const grpc_slice terminal_slice = { &terminal_slice_refcount, /* refcount */ {{0, nullptr}} /* data.refcounted */ @@ -80,7 +83,8 @@ typedef struct { bool use_true_binary_metadata; } framer_state; -/* fills p (which is expected to be 9 bytes long) with a data frame header */ +/* fills p (which is expected to be DATA_FRAME_HEADER_SIZE bytes long) + * with a data frame header */ static void fill_header(uint8_t* p, uint8_t type, uint32_t id, size_t len, uint8_t flags) { GPR_ASSERT(len < 16777316); @@ -107,15 +111,17 @@ static void finish_frame(framer_state* st, int is_header_boundary, static_cast( (is_last_in_stream ? GRPC_CHTTP2_DATA_FLAG_END_STREAM : 0) | (is_header_boundary ? GRPC_CHTTP2_DATA_FLAG_END_HEADERS : 0))); - st->stats->framing_bytes += 9; + st->stats->framing_bytes += DATA_FRAME_HEADER_SIZE; st->is_first_frame = 0; } /* begin a new frame: reserve off header space, remember how many bytes we'd output before beginning */ static void begin_frame(framer_state* st) { - st->header_idx = - grpc_slice_buffer_add_indexed(st->output, GRPC_SLICE_MALLOC(9)); + grpc_slice reserved; + reserved.refcount = nullptr; + reserved.data.inlined.length = DATA_FRAME_HEADER_SIZE; + st->header_idx = grpc_slice_buffer_add_indexed(st->output, reserved); st->output_length_at_start_of_frame = st->output->length; } @@ -188,8 +194,9 @@ static void evict_entry(grpc_chttp2_hpack_compressor* c) { static uint32_t prepare_space_for_new_elem(grpc_chttp2_hpack_compressor* c, size_t elem_size) { uint32_t new_index = c->tail_remote_index + c->table_elems + 1; - GPR_ASSERT(elem_size < 65536); + GPR_DEBUG_ASSERT(elem_size < 65536); + // TODO(arjunroy): Re-examine semantics if (elem_size > c->max_table_size) { while (c->table_size > 0) { evict_entry(c); @@ -203,6 +210,7 @@ static uint32_t prepare_space_for_new_elem(grpc_chttp2_hpack_compressor* c, while (c->table_size + elem_size > c->max_table_size) { evict_entry(c); } + // TODO(arjunroy): Are we conflating size in bytes vs. membership? GPR_ASSERT(c->table_elems < c->max_table_size); c->table_elem_size[new_index % c->cap_table_elems] = static_cast(elem_size); @@ -215,19 +223,19 @@ static uint32_t prepare_space_for_new_elem(grpc_chttp2_hpack_compressor* c, // Add a key to the dynamic table. Both key and value will be added to table at // the decoder. static void add_key_with_index(grpc_chttp2_hpack_compressor* c, - grpc_mdelem elem, uint32_t new_index) { + grpc_mdelem elem, uint32_t new_index, + uint32_t key_hash) { if (new_index == 0) { return; } - uint32_t key_hash = grpc_slice_hash(GRPC_MDKEY(elem)); - /* Store the key into {entries,indices}_keys */ - if (grpc_slice_eq(c->entries_keys[HASH_FRAGMENT_2(key_hash)], - GRPC_MDKEY(elem))) { + if (grpc_slice_static_interned_equal( + c->entries_keys[HASH_FRAGMENT_2(key_hash)], GRPC_MDKEY(elem))) { c->indices_keys[HASH_FRAGMENT_2(key_hash)] = new_index; - } else if (grpc_slice_eq(c->entries_keys[HASH_FRAGMENT_3(key_hash)], - GRPC_MDKEY(elem))) { + } else if (grpc_slice_static_interned_equal( + c->entries_keys[HASH_FRAGMENT_3(key_hash)], + GRPC_MDKEY(elem))) { c->indices_keys[HASH_FRAGMENT_3(key_hash)] = new_index; } else if (c->entries_keys[HASH_FRAGMENT_2(key_hash)].refcount == &terminal_slice_refcount) { @@ -255,22 +263,20 @@ static void add_key_with_index(grpc_chttp2_hpack_compressor* c, /* add an element to the decoder table */ static void add_elem_with_index(grpc_chttp2_hpack_compressor* c, - grpc_mdelem elem, uint32_t new_index) { + grpc_mdelem elem, uint32_t new_index, + uint32_t elem_hash, uint32_t key_hash) { if (new_index == 0) { return; } - GPR_ASSERT(GRPC_MDELEM_IS_INTERNED(elem)); - - uint32_t key_hash = grpc_slice_hash(GRPC_MDKEY(elem)); - uint32_t value_hash = grpc_slice_hash(GRPC_MDVALUE(elem)); - uint32_t elem_hash = GRPC_MDSTR_KV_HASH(key_hash, value_hash); + GPR_DEBUG_ASSERT(GRPC_MDELEM_IS_INTERNED(elem)); /* Store this element into {entries,indices}_elem */ - if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem)) { + if (grpc_mdelem_both_interned_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], + elem)) { /* already there: update with new index */ c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index; - } else if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_3(elem_hash)], - elem)) { + } else if (grpc_mdelem_both_interned_eq( + c->entries_elems[HASH_FRAGMENT_3(elem_hash)], elem)) { /* already there (cuckoo): update with new index */ c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index; } else if (GRPC_MDISNULL(c->entries_elems[HASH_FRAGMENT_2(elem_hash)])) { @@ -294,19 +300,19 @@ static void add_elem_with_index(grpc_chttp2_hpack_compressor* c, c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index; } - add_key_with_index(c, elem, new_index); + add_key_with_index(c, elem, new_index, key_hash); } static void add_elem(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, - size_t elem_size) { + size_t elem_size, uint32_t elem_hash, uint32_t key_hash) { uint32_t new_index = prepare_space_for_new_elem(c, elem_size); - add_elem_with_index(c, elem, new_index); + add_elem_with_index(c, elem, new_index, elem_hash, key_hash); } static void add_key(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, - size_t elem_size) { + size_t elem_size, uint32_t key_hash) { uint32_t new_index = prepare_space_for_new_elem(c, elem_size); - add_key_with_index(c, elem, new_index); + add_key_with_index(c, elem, new_index, key_hash); } static void emit_indexed(grpc_chttp2_hpack_compressor* c, uint32_t elem_index, @@ -488,27 +494,33 @@ static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, return; } - uint32_t key_hash = grpc_slice_hash(GRPC_MDKEY(elem)); uint32_t elem_hash = 0; if (elem_interned) { - uint32_t value_hash = grpc_slice_hash(GRPC_MDVALUE(elem)); - elem_hash = GRPC_MDSTR_KV_HASH(key_hash, value_hash); + if (GRPC_MDELEM_STORAGE(elem) == GRPC_MDELEM_STORAGE_INTERNED) { + elem_hash = + reinterpret_cast(GRPC_MDELEM_DATA(elem)) + ->hash(); + } else { + elem_hash = + reinterpret_cast(GRPC_MDELEM_DATA(elem)) + ->hash(); + } inc_filter(HASH_FRAGMENT_1(elem_hash), &c->filter_elems_sum, c->filter_elems); /* is this elem currently in the decoders table? */ - - if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem) && + if (grpc_mdelem_both_interned_eq( + c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem) && c->indices_elems[HASH_FRAGMENT_2(elem_hash)] > c->tail_remote_index) { /* HIT: complete element (first cuckoo hash) */ emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_2(elem_hash)]), st); return; } - - if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_3(elem_hash)], elem) && + if (grpc_mdelem_both_interned_eq( + c->entries_elems[HASH_FRAGMENT_3(elem_hash)], elem) && c->indices_elems[HASH_FRAGMENT_3(elem_hash)] > c->tail_remote_index) { /* HIT: complete element (second cuckoo hash) */ emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_3(elem_hash)]), @@ -527,11 +539,12 @@ static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, c->filter_elems[HASH_FRAGMENT_1(elem_hash)] >= c->filter_elems_sum / ONE_ON_ADD_PROBABILITY; + uint32_t key_hash = GRPC_MDKEY(elem).refcount->Hash(GRPC_MDKEY(elem)); auto emit_maybe_add = [&should_add_elem, &elem, &st, &c, &indices_key, - &decoder_space_usage] { + &decoder_space_usage, &elem_hash, &key_hash] { if (should_add_elem) { emit_lithdr_incidx(c, dynidx(c, indices_key), elem, st); - add_elem(c, elem, decoder_space_usage); + add_elem(c, elem, decoder_space_usage, elem_hash, key_hash); } else { emit_lithdr_noidx(c, dynidx(c, indices_key), elem, st); } @@ -539,8 +552,8 @@ static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, /* no hits for the elem... maybe there's a key? */ indices_key = c->indices_keys[HASH_FRAGMENT_2(key_hash)]; - if (grpc_slice_eq(c->entries_keys[HASH_FRAGMENT_2(key_hash)], - GRPC_MDKEY(elem)) && + if (grpc_slice_static_interned_equal( + c->entries_keys[HASH_FRAGMENT_2(key_hash)], GRPC_MDKEY(elem)) && indices_key > c->tail_remote_index) { /* HIT: key (first cuckoo hash) */ emit_maybe_add(); @@ -548,8 +561,8 @@ static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, } indices_key = c->indices_keys[HASH_FRAGMENT_3(key_hash)]; - if (grpc_slice_eq(c->entries_keys[HASH_FRAGMENT_3(key_hash)], - GRPC_MDKEY(elem)) && + if (grpc_slice_static_interned_equal( + c->entries_keys[HASH_FRAGMENT_3(key_hash)], GRPC_MDKEY(elem)) && indices_key > c->tail_remote_index) { /* HIT: key (first cuckoo hash) */ emit_maybe_add(); @@ -565,9 +578,9 @@ static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, emit_lithdr_noidx_v(c, 0, elem, st); } if (should_add_elem) { - add_elem(c, elem, decoder_space_usage); + add_elem(c, elem, decoder_space_usage, elem_hash, key_hash); } else if (should_add_key) { - add_key(c, elem, decoder_space_usage); + add_key(c, elem, decoder_space_usage, key_hash); } } @@ -692,18 +705,18 @@ void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor* c, } for (size_t i = 0; i < extra_headers_size; ++i) { grpc_mdelem md = *extra_headers[i]; - uint8_t static_index = grpc_chttp2_get_static_hpack_table_index(md); + uintptr_t static_index = grpc_chttp2_get_static_hpack_table_index(md); if (static_index) { - emit_indexed(c, static_index, &st); + emit_indexed(c, static_cast(static_index), &st); } else { hpack_enc(c, md, &st); } } grpc_metadata_batch_assert_ok(metadata); for (grpc_linked_mdelem* l = metadata->list.head; l; l = l->next) { - uint8_t static_index = grpc_chttp2_get_static_hpack_table_index(l->md); + uintptr_t static_index = grpc_chttp2_get_static_hpack_table_index(l->md); if (static_index) { - emit_indexed(c, static_index, &st); + emit_indexed(c, static_cast(static_index), &st); } else { hpack_enc(c, l->md, &st); } diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.cc b/src/core/ext/transport/chttp2/transport/hpack_table.cc index 16aeb49df4d..f2cbd26f6b8 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_table.cc @@ -385,13 +385,3 @@ size_t grpc_chttp2_get_size_in_hpack_table(grpc_mdelem elem, return overhead_and_key + value_len; } } - -uint8_t grpc_chttp2_get_static_hpack_table_index(grpc_mdelem md) { - if (GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_STATIC) { - uint8_t index = GRPC_MDELEM_DATA(md) - grpc_static_mdelem_table; - if (index < GRPC_CHTTP2_LAST_STATIC_ENTRY) { - return index + 1; // Hpack static metadata element indices start at 1 - } - } - return 0; -} diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.h b/src/core/ext/transport/chttp2/transport/hpack_table.h index a0ffc6fab77..38f8bdda6ae 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.h +++ b/src/core/ext/transport/chttp2/transport/hpack_table.h @@ -24,6 +24,7 @@ #include #include "src/core/lib/iomgr/error.h" #include "src/core/lib/transport/metadata.h" +#include "src/core/lib/transport/static_metadata.h" /* HPACK header table */ @@ -90,7 +91,15 @@ size_t grpc_chttp2_get_size_in_hpack_table(grpc_mdelem elem, /* Returns the static hpack table index that corresponds to /a elem. Returns 0 if /a elem is not statically stored or if it is not in the static hpack table */ -uint8_t grpc_chttp2_get_static_hpack_table_index(grpc_mdelem md); +inline uintptr_t grpc_chttp2_get_static_hpack_table_index(grpc_mdelem md) { + uintptr_t index = + reinterpret_cast(GRPC_MDELEM_DATA(md)) - + grpc_static_mdelem_table; + if (index < GRPC_CHTTP2_LAST_STATIC_ENTRY) { + return index + 1; // Hpack static metadata element indices start at 1 + } + return 0; +} /* Find a key/value pair in the table... returns the index in the table of the most similar entry, or 0 if the value was not found */ diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc index 75acb28e99c..3a3edebdc7a 100644 --- a/src/core/lib/slice/slice.cc +++ b/src/core/lib/slice/slice.cc @@ -68,7 +68,8 @@ void grpc_slice_unref(grpc_slice slice) { /* grpc_slice_from_static_string support structure - a refcount that does nothing */ -static grpc_slice_refcount NoopRefcount; +static grpc_slice_refcount NoopRefcount = + grpc_slice_refcount(grpc_slice_refcount::Type::NOP); size_t grpc_slice_memory_usage(grpc_slice s) { if (s.refcount == nullptr || s.refcount == &NoopRefcount) { diff --git a/src/core/lib/slice/slice_hash_table.h b/src/core/lib/slice/slice_hash_table.h index 942830a3e9c..c20eca9db77 100644 --- a/src/core/lib/slice/slice_hash_table.h +++ b/src/core/lib/slice/slice_hash_table.h @@ -138,7 +138,7 @@ SliceHashTable::~SliceHashTable() { template void SliceHashTable::Add(const grpc_slice& key, T& value) { - const size_t hash = grpc_slice_hash(key); + const size_t hash = grpc_slice_hash_internal(key); for (size_t offset = 0; offset < size_; ++offset) { const size_t idx = (hash + offset) % size_; if (!entries_[idx].is_set) { @@ -156,7 +156,7 @@ void SliceHashTable::Add(const grpc_slice& key, T& value) { template const T* SliceHashTable::Get(const grpc_slice& key) const { - const size_t hash = grpc_slice_hash(key); + const size_t hash = grpc_slice_hash_internal(key); // We cap the number of probes at the max number recorded when // populating the table. for (size_t offset = 0; offset <= max_num_probes_; ++offset) { diff --git a/src/core/lib/slice/slice_intern.cc b/src/core/lib/slice/slice_intern.cc index 15909d9b96f..81d34ddce25 100644 --- a/src/core/lib/slice/slice_intern.cc +++ b/src/core/lib/slice/slice_intern.cc @@ -128,10 +128,7 @@ int grpc_static_slice_eq(grpc_slice a, grpc_slice b) { return GRPC_STATIC_METADATA_INDEX(a) == GRPC_STATIC_METADATA_INDEX(b); } -uint32_t grpc_slice_hash(grpc_slice s) { - return s.refcount == nullptr ? grpc_slice_default_hash_impl(s) - : s.refcount->Hash(s); -} +uint32_t grpc_slice_hash(grpc_slice s) { return grpc_slice_hash_internal(s); } grpc_slice grpc_slice_maybe_static_intern(grpc_slice slice, bool* returned_slice_is_different) { @@ -139,7 +136,7 @@ grpc_slice grpc_slice_maybe_static_intern(grpc_slice slice, return slice; } - uint32_t hash = grpc_slice_hash(slice); + uint32_t hash = grpc_slice_hash_internal(slice); for (uint32_t i = 0; i <= max_static_metadata_hash_probe; i++) { static_metadata_hash_ent ent = static_metadata_hash[(hash + i) % GPR_ARRAY_SIZE(static_metadata_hash)]; @@ -154,19 +151,13 @@ grpc_slice grpc_slice_maybe_static_intern(grpc_slice slice, return slice; } -bool grpc_slice_is_interned(const grpc_slice& slice) { - return (slice.refcount && - (slice.refcount->GetType() == grpc_slice_refcount::Type::INTERNED || - GRPC_IS_STATIC_METADATA_STRING(slice))); -} - grpc_slice grpc_slice_intern(grpc_slice slice) { GPR_TIMER_SCOPE("grpc_slice_intern", 0); if (GRPC_IS_STATIC_METADATA_STRING(slice)) { return slice; } - uint32_t hash = grpc_slice_hash(slice); + uint32_t hash = grpc_slice_hash_internal(slice); for (uint32_t i = 0; i <= max_static_metadata_hash_probe; i++) { static_metadata_hash_ent ent = @@ -238,7 +229,7 @@ void grpc_slice_intern_init(void) { max_static_metadata_hash_probe = 0; for (size_t i = 0; i < GRPC_STATIC_MDSTR_COUNT; i++) { grpc_static_metadata_hash_values[i] = - grpc_slice_default_hash_impl(grpc_static_slice_table[i]); + grpc_slice_default_hash_internal(grpc_static_slice_table[i]); for (size_t j = 0; j < GPR_ARRAY_SIZE(static_metadata_hash); j++) { size_t slot = (grpc_static_metadata_hash_values[i] + j) % GPR_ARRAY_SIZE(static_metadata_hash); @@ -252,6 +243,10 @@ void grpc_slice_intern_init(void) { } } } + // Handle KV hash for all static mdelems. + for (size_t i = 0; i < GRPC_STATIC_MDELEM_COUNT; ++i) { + grpc_static_mdelem_table[i].HashInit(); + } } void grpc_slice_intern_shutdown(void) { diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index e4aba015315..23a2f6b81bc 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -99,12 +99,15 @@ struct grpc_slice_refcount { enum class Type { STATIC, // Refcount for a static metadata slice. INTERNED, // Refcount for an interned slice. + NOP, // No-Op REGULAR // Refcount for non-static-metadata, non-interned slices. }; typedef void (*DestroyerFn)(void*); grpc_slice_refcount() = default; + explicit grpc_slice_refcount(Type t) : ref_type_(t) {} + explicit grpc_slice_refcount(grpc_slice_refcount* sub) : sub_refcount_(sub) {} // Regular constructor for grpc_slice_refcount. // @@ -200,6 +203,7 @@ inline int grpc_slice_refcount::Eq(const grpc_slice& a, const grpc_slice& b) { return GRPC_STATIC_METADATA_INDEX(a) == GRPC_STATIC_METADATA_INDEX(b); case Type::INTERNED: return a.refcount == b.refcount; + case Type::NOP: case Type::REGULAR: break; } @@ -217,6 +221,7 @@ inline uint32_t grpc_slice_refcount::Hash(const grpc_slice& slice) { case Type::INTERNED: return reinterpret_cast(slice.refcount) ->hash; + case Type::NOP: case Type::REGULAR: break; } @@ -258,6 +263,17 @@ void grpc_slice_buffer_sub_first(grpc_slice_buffer* sb, size_t begin, /* Check if a slice is interned */ bool grpc_slice_is_interned(const grpc_slice& slice); +inline bool grpc_slice_is_interned(const grpc_slice& slice) { + return (slice.refcount && + (slice.refcount->GetType() == grpc_slice_refcount::Type::INTERNED || + slice.refcount->GetType() == grpc_slice_refcount::Type::STATIC)); +} + +inline bool grpc_slice_static_interned_equal(const grpc_slice& a, + const grpc_slice& b) { + GPR_DEBUG_ASSERT(grpc_slice_is_interned(a) && grpc_slice_is_interned(b)); + return a.refcount == b.refcount; +} void grpc_slice_intern_init(void); void grpc_slice_intern_shutdown(void); @@ -271,6 +287,21 @@ grpc_slice grpc_slice_maybe_static_intern(grpc_slice slice, uint32_t grpc_static_slice_hash(grpc_slice s); int grpc_static_slice_eq(grpc_slice a, grpc_slice b); +inline uint32_t grpc_slice_hash_refcounted(const grpc_slice& s) { + GPR_DEBUG_ASSERT(s.refcount != nullptr); + return s.refcount->Hash(s); +} + +inline uint32_t grpc_slice_default_hash_internal(const grpc_slice& s) { + return gpr_murmur_hash3(GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s), + g_hash_seed); +} + +inline uint32_t grpc_slice_hash_internal(const grpc_slice& s) { + return s.refcount == nullptr ? grpc_slice_default_hash_internal(s) + : grpc_slice_hash_refcounted(s); +} + // Returns the memory used by this slice, not counting the slice structure // itself. This means that inlined and slices from static strings will return // 0. All other slices will return the size of the allocated chars. diff --git a/src/core/lib/slice/slice_weak_hash_table.h b/src/core/lib/slice/slice_weak_hash_table.h index 1335c817a39..8c5562bf196 100644 --- a/src/core/lib/slice/slice_weak_hash_table.h +++ b/src/core/lib/slice/slice_weak_hash_table.h @@ -47,7 +47,7 @@ class SliceWeakHashTable : public RefCounted> { /// Add a mapping from \a key to \a value, taking ownership of \a key. This /// operation will always succeed. It may discard older entries. void Add(const grpc_slice& key, T value) { - const size_t idx = grpc_slice_hash(key) % Size; + const size_t idx = grpc_slice_hash_internal(key) % Size; entries_[idx].Set(key, std::move(value)); return; } @@ -55,7 +55,7 @@ class SliceWeakHashTable : public RefCounted> { /// Returns the value from the table associated with / \a key or null if not /// found. const T* Get(const grpc_slice& key) const { - const size_t idx = grpc_slice_hash(key) % Size; + const size_t idx = grpc_slice_hash_internal(key) % Size; const auto& entry = entries_[idx]; return grpc_slice_eq(entry.key(), key) ? entry.value() : nullptr; } diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 19f61c548d6..44de0cd42dd 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -625,8 +625,8 @@ static void start_new_rpc(grpc_call_element* elem) { if (chand->registered_methods && calld->path_set && calld->host_set) { /* TODO(ctiller): unify these two searches */ /* check for an exact match with host */ - hash = GRPC_MDSTR_KV_HASH(grpc_slice_hash(calld->host), - grpc_slice_hash(calld->path)); + hash = GRPC_MDSTR_KV_HASH(grpc_slice_hash_internal(calld->host), + grpc_slice_hash_internal(calld->path)); for (i = 0; i <= chand->registered_method_max_probes; i++) { rm = &chand->registered_methods[(hash + i) % chand->registered_method_slots]; @@ -644,7 +644,7 @@ static void start_new_rpc(grpc_call_element* elem) { return; } /* check for a wildcard method definition (no host set) */ - hash = GRPC_MDSTR_KV_HASH(0, grpc_slice_hash(calld->path)); + hash = GRPC_MDSTR_KV_HASH(0, grpc_slice_hash_internal(calld->path)); for (i = 0; i <= chand->registered_method_max_probes; i++) { rm = &chand->registered_methods[(hash + i) % chand->registered_method_slots]; @@ -1200,8 +1200,8 @@ void grpc_server_setup_transport( has_host = false; } method = grpc_slice_intern(grpc_slice_from_static_string(rm->method)); - hash = GRPC_MDSTR_KV_HASH(has_host ? grpc_slice_hash(host) : 0, - grpc_slice_hash(method)); + hash = GRPC_MDSTR_KV_HASH(has_host ? grpc_slice_hash_internal(host) : 0, + grpc_slice_hash_internal(method)); for (probes = 0; chand->registered_methods[(hash + probes) % slots] .server_registered_method != nullptr; probes++) diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc index 4609eb42cdc..2fdecc99d3e 100644 --- a/src/core/lib/transport/metadata.cc +++ b/src/core/lib/transport/metadata.cc @@ -43,6 +43,7 @@ using grpc_core::AllocatedMetadata; using grpc_core::InternedMetadata; +using grpc_core::StaticMetadata; using grpc_core::UserData; /* There are two kinds of mdelem and mdstr instances. @@ -100,6 +101,12 @@ void grpc_mdelem_trace_unref(void* md, const grpc_slice& key, #define TABLE_IDX(hash, capacity) (((hash) >> (LOG2_SHARD_COUNT)) % (capacity)) #define SHARD_IDX(hash) ((hash) & ((1 << (LOG2_SHARD_COUNT)) - 1)) +void StaticMetadata::HashInit() { + uint32_t k_hash = grpc_slice_hash_internal(kv_.key); + uint32_t v_hash = grpc_slice_hash_internal(kv_.value); + hash_ = GRPC_MDSTR_KV_HASH(k_hash, v_hash); +} + AllocatedMetadata::AllocatedMetadata(const grpc_slice& key, const grpc_slice& value) : key_(grpc_slice_ref_internal(key)), @@ -133,8 +140,8 @@ InternedMetadata::InternedMetadata(const grpc_slice& key, InternedMetadata* next) : key_(grpc_slice_ref_internal(key)), value_(grpc_slice_ref_internal(value)), - refcnt_(1), hash_(hash), + refcnt_(1), link_(next) { #ifndef NDEBUG if (grpc_trace_metadata.enabled()) { @@ -223,11 +230,14 @@ void grpc_mdctx_global_shutdown() { } } +#ifndef NDEBUG static int is_mdelem_static(grpc_mdelem e) { - return GRPC_MDELEM_DATA(e) >= &grpc_static_mdelem_table[0] && - GRPC_MDELEM_DATA(e) < + return reinterpret_cast(GRPC_MDELEM_DATA(e)) >= + &grpc_static_mdelem_table[0] && + reinterpret_cast(GRPC_MDELEM_DATA(e)) < &grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT]; } +#endif void InternedMetadata::RefWithShardLocked(mdtab_shard* shard) { #ifndef NDEBUG @@ -323,8 +333,8 @@ grpc_mdelem grpc_mdelem_create( } } - uint32_t hash = - GRPC_MDSTR_KV_HASH(grpc_slice_hash(key), grpc_slice_hash(value)); + uint32_t hash = GRPC_MDSTR_KV_HASH(grpc_slice_hash_refcounted(key), + grpc_slice_hash_refcounted(value)); InternedMetadata* md; mdtab_shard* shard = &g_shards[SHARD_IDX(hash)]; size_t idx; @@ -391,8 +401,11 @@ void* grpc_mdelem_get_user_data(grpc_mdelem md, void (*destroy_func)(void*)) { case GRPC_MDELEM_STORAGE_EXTERNAL: return nullptr; case GRPC_MDELEM_STORAGE_STATIC: - return (void*)grpc_static_mdelem_user_data[GRPC_MDELEM_DATA(md) - - grpc_static_mdelem_table]; + return reinterpret_cast( + grpc_static_mdelem_user_data + [reinterpret_cast( + GRPC_MDELEM_DATA(md)) - + grpc_static_mdelem_table]); case GRPC_MDELEM_STORAGE_ALLOCATED: { auto* am = reinterpret_cast(GRPC_MDELEM_DATA(md)); return get_user_data(am->user_data(), destroy_func); @@ -430,15 +443,18 @@ void* grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void*), return nullptr; case GRPC_MDELEM_STORAGE_STATIC: destroy_func(data); - return (void*)grpc_static_mdelem_user_data[GRPC_MDELEM_DATA(md) - - grpc_static_mdelem_table]; + return reinterpret_cast( + grpc_static_mdelem_user_data + [reinterpret_cast( + GRPC_MDELEM_DATA(md)) - + grpc_static_mdelem_table]); case GRPC_MDELEM_STORAGE_ALLOCATED: { auto* am = reinterpret_cast(GRPC_MDELEM_DATA(md)); return set_user_data(am->user_data(), destroy_func, data); } case GRPC_MDELEM_STORAGE_INTERNED: { auto* im = reinterpret_cast GRPC_MDELEM_DATA(md); - GPR_ASSERT(!is_mdelem_static(md)); + GPR_DEBUG_ASSERT(!is_mdelem_static(md)); return set_user_data(im->user_data(), destroy_func, data); } } diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h index f59476ccc21..74c69f97584 100644 --- a/src/core/lib/transport/metadata.h +++ b/src/core/lib/transport/metadata.h @@ -141,6 +141,16 @@ inline bool grpc_mdelem_static_value_eq(grpc_mdelem a, grpc_mdelem b_static) { if (a.payload == b_static.payload) return true; return grpc_slice_eq_static_interned(GRPC_MDVALUE(a), GRPC_MDVALUE(b_static)); } +#define GRPC_MDISNULL(md) (GRPC_MDELEM_DATA(md) == NULL) + +inline bool grpc_mdelem_both_interned_eq(grpc_mdelem a_interned, + grpc_mdelem b_interned) { + GPR_DEBUG_ASSERT(GRPC_MDELEM_IS_INTERNED(a_interned) || + GRPC_MDISNULL(a_interned)); + GPR_DEBUG_ASSERT(GRPC_MDELEM_IS_INTERNED(b_interned) || + GRPC_MDISNULL(b_interned)); + return a_interned.payload == b_interned.payload; +} /* Mutator and accessor for grpc_mdelem user data. The destructor function is used as a type tag and is checked during user_data fetch. */ @@ -169,6 +179,23 @@ struct UserData { grpc_core::Atomic data; }; +class StaticMetadata { + public: + StaticMetadata(const grpc_slice& key, const grpc_slice& value) + : kv_({key, value}), hash_(0) {} + + const grpc_mdelem_data& data() const { return kv_; } + + void HashInit(); + uint32_t hash() { return hash_; } + + private: + grpc_mdelem_data kv_; + + /* private only data */ + uint32_t hash_; +}; + class InternedMetadata { public: struct BucketLink { @@ -227,8 +254,8 @@ class InternedMetadata { grpc_slice value_; /* private only data */ - grpc_core::Atomic refcnt_; uint32_t hash_; + grpc_core::Atomic refcnt_; UserData user_data_; @@ -344,7 +371,6 @@ inline void grpc_mdelem_unref(grpc_mdelem gmd) { } #define GRPC_MDNULL GRPC_MAKE_MDELEM(NULL, GRPC_MDELEM_STORAGE_EXTERNAL) -#define GRPC_MDISNULL(md) (GRPC_MDELEM_DATA(md) == NULL) /* We add 32 bytes of padding as per RFC-7540 section 6.5.2. */ #define GRPC_MDELEM_LENGTH(e) \ diff --git a/src/core/lib/transport/static_metadata.cc b/src/core/lib/transport/static_metadata.cc index 61ee1d46f77..bbf1736b595 100644 --- a/src/core/lib/transport/static_metadata.cc +++ b/src/core/lib/transport/static_metadata.cc @@ -390,184 +390,270 @@ grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b) { uint32_t h = elems_phash(k); return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k && elem_idxs[h] != 255 - ? GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[elem_idxs[h]], + ? GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[elem_idxs[h]].data(), GRPC_MDELEM_STORAGE_STATIC) : GRPC_MDNULL; } -grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { - {{&grpc_static_metadata_refcounts[3], {{10, g_bytes + 19}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, - {&grpc_static_metadata_refcounts[40], {{3, g_bytes + 612}}}}, - {{&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, - {&grpc_static_metadata_refcounts[41], {{4, g_bytes + 615}}}}, - {{&grpc_static_metadata_refcounts[0], {{5, g_bytes + 0}}}, - {&grpc_static_metadata_refcounts[42], {{1, g_bytes + 619}}}}, - {{&grpc_static_metadata_refcounts[0], {{5, g_bytes + 0}}}, - {&grpc_static_metadata_refcounts[43], {{11, g_bytes + 620}}}}, - {{&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, - {&grpc_static_metadata_refcounts[44], {{4, g_bytes + 631}}}}, - {{&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, - {&grpc_static_metadata_refcounts[45], {{5, g_bytes + 635}}}}, - {{&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[46], {{3, g_bytes + 640}}}}, - {{&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[47], {{3, g_bytes + 643}}}}, - {{&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[48], {{3, g_bytes + 646}}}}, - {{&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[49], {{3, g_bytes + 649}}}}, - {{&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[50], {{3, g_bytes + 652}}}}, - {{&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[51], {{3, g_bytes + 655}}}}, - {{&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[52], {{3, g_bytes + 658}}}}, - {{&grpc_static_metadata_refcounts[53], {{14, g_bytes + 661}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[54], {{13, g_bytes + 675}}}}, - {{&grpc_static_metadata_refcounts[55], {{15, g_bytes + 688}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[56], {{13, g_bytes + 703}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[57], {{6, g_bytes + 716}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[58], {{27, g_bytes + 722}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[59], {{3, g_bytes + 749}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[60], {{5, g_bytes + 752}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[61], {{13, g_bytes + 757}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[62], {{13, g_bytes + 770}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[63], {{19, g_bytes + 783}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[64], {{16, g_bytes + 802}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[65], {{14, g_bytes + 818}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[66], {{16, g_bytes + 832}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[67], {{13, g_bytes + 848}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[14], {{12, g_bytes + 158}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[68], {{6, g_bytes + 861}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[69], {{4, g_bytes + 867}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[70], {{4, g_bytes + 871}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[71], {{6, g_bytes + 875}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[72], {{7, g_bytes + 881}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[73], {{4, g_bytes + 888}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[20], {{4, g_bytes + 278}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[74], {{8, g_bytes + 892}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[75], {{17, g_bytes + 900}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[76], {{13, g_bytes + 917}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[77], {{8, g_bytes + 930}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[78], {{19, g_bytes + 938}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[79], {{13, g_bytes + 957}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[80], {{4, g_bytes + 970}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[81], {{8, g_bytes + 974}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[82], {{12, g_bytes + 982}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[83], {{18, g_bytes + 994}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[84], {{19, g_bytes + 1012}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[85], {{5, g_bytes + 1031}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[86], {{7, g_bytes + 1036}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[87], {{7, g_bytes + 1043}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[88], {{11, g_bytes + 1050}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[89], {{6, g_bytes + 1061}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[90], {{10, g_bytes + 1067}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[91], {{25, g_bytes + 1077}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[92], {{17, g_bytes + 1102}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[19], {{10, g_bytes + 268}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[93], {{4, g_bytes + 1119}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[94], {{3, g_bytes + 1123}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[95], {{16, g_bytes + 1126}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, - {&grpc_static_metadata_refcounts[96], {{1, g_bytes + 1142}}}}, - {{&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, - {&grpc_static_metadata_refcounts[25], {{1, g_bytes + 350}}}}, - {{&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, - {&grpc_static_metadata_refcounts[26], {{1, g_bytes + 351}}}}, - {{&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, - {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}}, - {{&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, - {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}}, - {{&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, - {&grpc_static_metadata_refcounts[37], {{7, g_bytes + 590}}}}, - {{&grpc_static_metadata_refcounts[5], {{2, g_bytes + 36}}}, - {&grpc_static_metadata_refcounts[98], {{8, g_bytes + 1151}}}}, - {{&grpc_static_metadata_refcounts[14], {{12, g_bytes + 158}}}, - {&grpc_static_metadata_refcounts[99], {{16, g_bytes + 1159}}}}, - {{&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, - {&grpc_static_metadata_refcounts[100], {{4, g_bytes + 1175}}}}, - {{&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, - {&grpc_static_metadata_refcounts[101], {{3, g_bytes + 1179}}}}, - {{&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, - {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}}, - {{&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, - {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}}, - {{&grpc_static_metadata_refcounts[21], {{8, g_bytes + 282}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[102], {{11, g_bytes + 1182}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}}, - {{&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}}, - {{&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[37], {{7, g_bytes + 590}}}}, - {{&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[103], {{16, g_bytes + 1193}}}}, - {{&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}}, - {{&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[104], {{13, g_bytes + 1209}}}}, - {{&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[105], {{12, g_bytes + 1222}}}}, - {{&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[106], {{21, g_bytes + 1234}}}}, - {{&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}}, - {{&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}}, - {{&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[104], {{13, g_bytes + 1209}}}}, +grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[3], {{10, g_bytes + 19}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, + {&grpc_static_metadata_refcounts[40], {{3, g_bytes + 612}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, + {&grpc_static_metadata_refcounts[41], {{4, g_bytes + 615}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[0], {{5, g_bytes + 0}}}, + {&grpc_static_metadata_refcounts[42], {{1, g_bytes + 619}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[0], {{5, g_bytes + 0}}}, + {&grpc_static_metadata_refcounts[43], {{11, g_bytes + 620}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, + {&grpc_static_metadata_refcounts[44], {{4, g_bytes + 631}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, + {&grpc_static_metadata_refcounts[45], {{5, g_bytes + 635}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, + {&grpc_static_metadata_refcounts[46], {{3, g_bytes + 640}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, + {&grpc_static_metadata_refcounts[47], {{3, g_bytes + 643}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, + {&grpc_static_metadata_refcounts[48], {{3, g_bytes + 646}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, + {&grpc_static_metadata_refcounts[49], {{3, g_bytes + 649}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, + {&grpc_static_metadata_refcounts[50], {{3, g_bytes + 652}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, + {&grpc_static_metadata_refcounts[51], {{3, g_bytes + 655}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, + {&grpc_static_metadata_refcounts[52], {{3, g_bytes + 658}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[53], {{14, g_bytes + 661}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, + {&grpc_static_metadata_refcounts[54], {{13, g_bytes + 675}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[55], {{15, g_bytes + 688}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[56], {{13, g_bytes + 703}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[57], {{6, g_bytes + 716}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[58], {{27, g_bytes + 722}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[59], {{3, g_bytes + 749}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[60], {{5, g_bytes + 752}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[61], {{13, g_bytes + 757}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[62], {{13, g_bytes + 770}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[63], {{19, g_bytes + 783}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[64], {{16, g_bytes + 802}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[65], {{14, g_bytes + 818}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[66], {{16, g_bytes + 832}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[67], {{13, g_bytes + 848}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[14], {{12, g_bytes + 158}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[68], {{6, g_bytes + 861}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[69], {{4, g_bytes + 867}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[70], {{4, g_bytes + 871}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[71], {{6, g_bytes + 875}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[72], {{7, g_bytes + 881}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[73], {{4, g_bytes + 888}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[20], {{4, g_bytes + 278}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[74], {{8, g_bytes + 892}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[75], {{17, g_bytes + 900}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[76], {{13, g_bytes + 917}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[77], {{8, g_bytes + 930}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[78], {{19, g_bytes + 938}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[79], {{13, g_bytes + 957}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[80], {{4, g_bytes + 970}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[81], {{8, g_bytes + 974}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[82], {{12, g_bytes + 982}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[83], {{18, g_bytes + 994}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[84], {{19, g_bytes + 1012}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[85], {{5, g_bytes + 1031}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[86], {{7, g_bytes + 1036}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[87], {{7, g_bytes + 1043}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[88], {{11, g_bytes + 1050}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[89], {{6, g_bytes + 1061}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[90], {{10, g_bytes + 1067}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[91], {{25, g_bytes + 1077}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[92], {{17, g_bytes + 1102}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[19], {{10, g_bytes + 268}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[93], {{4, g_bytes + 1119}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[94], {{3, g_bytes + 1123}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[95], {{16, g_bytes + 1126}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, + {&grpc_static_metadata_refcounts[96], {{1, g_bytes + 1142}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, + {&grpc_static_metadata_refcounts[25], {{1, g_bytes + 350}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, + {&grpc_static_metadata_refcounts[26], {{1, g_bytes + 351}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, + {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, + {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, + {&grpc_static_metadata_refcounts[37], {{7, g_bytes + 590}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[5], {{2, g_bytes + 36}}}, + {&grpc_static_metadata_refcounts[98], {{8, g_bytes + 1151}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[14], {{12, g_bytes + 158}}}, + {&grpc_static_metadata_refcounts[99], {{16, g_bytes + 1159}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, + {&grpc_static_metadata_refcounts[100], {{4, g_bytes + 1175}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, + {&grpc_static_metadata_refcounts[101], {{3, g_bytes + 1179}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, + {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, + {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[21], {{8, g_bytes + 282}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[102], {{11, g_bytes + 1182}}}, + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, + {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, + {&grpc_static_metadata_refcounts[37], {{7, g_bytes + 590}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, + {&grpc_static_metadata_refcounts[103], {{16, g_bytes + 1193}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, + {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, + {&grpc_static_metadata_refcounts[104], {{13, g_bytes + 1209}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, + {&grpc_static_metadata_refcounts[105], {{12, g_bytes + 1222}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, + {&grpc_static_metadata_refcounts[106], {{21, g_bytes + 1234}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, + {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, + {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}), + grpc_core::StaticMetadata( + {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, + {&grpc_static_metadata_refcounts[104], {{13, g_bytes + 1209}}}), }; const uint8_t grpc_static_accept_encoding_metadata[8] = {0, 76, 77, 78, 79, 80, 81, 82}; diff --git a/src/core/lib/transport/static_metadata.h b/src/core/lib/transport/static_metadata.h index a3f23de0953..800ee04d6f9 100644 --- a/src/core/lib/transport/static_metadata.h +++ b/src/core/lib/transport/static_metadata.h @@ -269,266 +269,353 @@ extern grpc_slice_refcount ((static_slice).refcount - grpc_static_metadata_refcounts))) #define GRPC_STATIC_MDELEM_COUNT 86 -extern grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT]; +extern grpc_core::StaticMetadata + grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT]; extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT]; /* ":authority": "" */ -#define GRPC_MDELEM_AUTHORITY_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[0], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_AUTHORITY_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[0].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":method": "GET" */ -#define GRPC_MDELEM_METHOD_GET \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[1], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_METHOD_GET \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[1].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":method": "POST" */ -#define GRPC_MDELEM_METHOD_POST \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[2], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_METHOD_POST \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[2].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":path": "/" */ -#define GRPC_MDELEM_PATH_SLASH \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[3], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_PATH_SLASH \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[3].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":path": "/index.html" */ -#define GRPC_MDELEM_PATH_SLASH_INDEX_DOT_HTML \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[4], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_PATH_SLASH_INDEX_DOT_HTML \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[4].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":scheme": "http" */ -#define GRPC_MDELEM_SCHEME_HTTP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[5], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_SCHEME_HTTP \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[5].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":scheme": "https" */ -#define GRPC_MDELEM_SCHEME_HTTPS \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[6], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_SCHEME_HTTPS \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[6].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":status": "200" */ -#define GRPC_MDELEM_STATUS_200 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[7], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_200 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[7].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":status": "204" */ -#define GRPC_MDELEM_STATUS_204 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[8], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_204 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[8].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":status": "206" */ -#define GRPC_MDELEM_STATUS_206 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[9], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_206 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[9].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":status": "304" */ -#define GRPC_MDELEM_STATUS_304 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[10], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_304 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[10].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":status": "400" */ -#define GRPC_MDELEM_STATUS_400 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[11], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_400 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[11].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":status": "404" */ -#define GRPC_MDELEM_STATUS_404 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[12], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_404 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[12].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":status": "500" */ -#define GRPC_MDELEM_STATUS_500 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[13], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_500 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[13].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "accept-charset": "" */ -#define GRPC_MDELEM_ACCEPT_CHARSET_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[14], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_CHARSET_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[14].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "accept-encoding": "gzip, deflate" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP_COMMA_DEFLATE \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[15], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP_COMMA_DEFLATE \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[15].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "accept-language": "" */ -#define GRPC_MDELEM_ACCEPT_LANGUAGE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[16], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_LANGUAGE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[16].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "accept-ranges": "" */ -#define GRPC_MDELEM_ACCEPT_RANGES_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[17], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_RANGES_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[17].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "accept": "" */ -#define GRPC_MDELEM_ACCEPT_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[18], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[18].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "access-control-allow-origin": "" */ -#define GRPC_MDELEM_ACCESS_CONTROL_ALLOW_ORIGIN_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[19], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCESS_CONTROL_ALLOW_ORIGIN_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[19].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "age": "" */ -#define GRPC_MDELEM_AGE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[20], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_AGE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[20].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "allow": "" */ -#define GRPC_MDELEM_ALLOW_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[21], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ALLOW_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[21].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "authorization": "" */ -#define GRPC_MDELEM_AUTHORIZATION_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[22], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_AUTHORIZATION_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[22].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "cache-control": "" */ -#define GRPC_MDELEM_CACHE_CONTROL_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[23], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CACHE_CONTROL_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[23].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-disposition": "" */ -#define GRPC_MDELEM_CONTENT_DISPOSITION_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[24], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_DISPOSITION_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[24].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-encoding": "" */ -#define GRPC_MDELEM_CONTENT_ENCODING_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[25], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_ENCODING_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[25].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-language": "" */ -#define GRPC_MDELEM_CONTENT_LANGUAGE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[26], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_LANGUAGE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[26].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-length": "" */ -#define GRPC_MDELEM_CONTENT_LENGTH_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[27], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_LENGTH_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[27].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-location": "" */ -#define GRPC_MDELEM_CONTENT_LOCATION_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[28], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_LOCATION_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[28].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-range": "" */ -#define GRPC_MDELEM_CONTENT_RANGE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[29], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_RANGE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[29].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-type": "" */ -#define GRPC_MDELEM_CONTENT_TYPE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[30], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_TYPE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[30].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "cookie": "" */ -#define GRPC_MDELEM_COOKIE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[31], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_COOKIE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[31].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "date": "" */ -#define GRPC_MDELEM_DATE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[32], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_DATE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[32].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "etag": "" */ -#define GRPC_MDELEM_ETAG_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[33], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ETAG_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[33].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "expect": "" */ -#define GRPC_MDELEM_EXPECT_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[34], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_EXPECT_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[34].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "expires": "" */ -#define GRPC_MDELEM_EXPIRES_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[35], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_EXPIRES_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[35].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "from": "" */ -#define GRPC_MDELEM_FROM_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[36], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_FROM_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[36].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "host": "" */ -#define GRPC_MDELEM_HOST_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[37], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_HOST_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[37].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "if-match": "" */ -#define GRPC_MDELEM_IF_MATCH_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[38], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_IF_MATCH_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[38].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "if-modified-since": "" */ -#define GRPC_MDELEM_IF_MODIFIED_SINCE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[39], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_IF_MODIFIED_SINCE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[39].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "if-none-match": "" */ -#define GRPC_MDELEM_IF_NONE_MATCH_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[40], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_IF_NONE_MATCH_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[40].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "if-range": "" */ -#define GRPC_MDELEM_IF_RANGE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[41], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_IF_RANGE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[41].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "if-unmodified-since": "" */ -#define GRPC_MDELEM_IF_UNMODIFIED_SINCE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[42], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_IF_UNMODIFIED_SINCE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[42].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "last-modified": "" */ -#define GRPC_MDELEM_LAST_MODIFIED_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[43], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_LAST_MODIFIED_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[43].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "link": "" */ -#define GRPC_MDELEM_LINK_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[44], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_LINK_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[44].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "location": "" */ -#define GRPC_MDELEM_LOCATION_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[45], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_LOCATION_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[45].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "max-forwards": "" */ -#define GRPC_MDELEM_MAX_FORWARDS_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[46], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_MAX_FORWARDS_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[46].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "proxy-authenticate": "" */ -#define GRPC_MDELEM_PROXY_AUTHENTICATE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[47], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_PROXY_AUTHENTICATE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[47].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "proxy-authorization": "" */ -#define GRPC_MDELEM_PROXY_AUTHORIZATION_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[48], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_PROXY_AUTHORIZATION_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[48].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "range": "" */ -#define GRPC_MDELEM_RANGE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[49], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_RANGE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[49].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "referer": "" */ -#define GRPC_MDELEM_REFERER_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[50], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_REFERER_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[50].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "refresh": "" */ -#define GRPC_MDELEM_REFRESH_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[51], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_REFRESH_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[51].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "retry-after": "" */ -#define GRPC_MDELEM_RETRY_AFTER_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[52], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_RETRY_AFTER_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[52].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "server": "" */ -#define GRPC_MDELEM_SERVER_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[53], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_SERVER_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[53].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "set-cookie": "" */ -#define GRPC_MDELEM_SET_COOKIE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[54], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_SET_COOKIE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[54].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "strict-transport-security": "" */ -#define GRPC_MDELEM_STRICT_TRANSPORT_SECURITY_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[55], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STRICT_TRANSPORT_SECURITY_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[55].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "transfer-encoding": "" */ -#define GRPC_MDELEM_TRANSFER_ENCODING_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[56], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_TRANSFER_ENCODING_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[56].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "user-agent": "" */ -#define GRPC_MDELEM_USER_AGENT_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[57], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_USER_AGENT_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[57].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "vary": "" */ -#define GRPC_MDELEM_VARY_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[58], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_VARY_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[58].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "via": "" */ -#define GRPC_MDELEM_VIA_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[59], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_VIA_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[59].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "www-authenticate": "" */ -#define GRPC_MDELEM_WWW_AUTHENTICATE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[60], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_WWW_AUTHENTICATE_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[60].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-status": "0" */ -#define GRPC_MDELEM_GRPC_STATUS_0 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[61], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_STATUS_0 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[61].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-status": "1" */ -#define GRPC_MDELEM_GRPC_STATUS_1 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[62], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_STATUS_1 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[62].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-status": "2" */ -#define GRPC_MDELEM_GRPC_STATUS_2 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[63], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_STATUS_2 \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[63].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-encoding": "identity" */ -#define GRPC_MDELEM_GRPC_ENCODING_IDENTITY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[64], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_ENCODING_IDENTITY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[64].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-encoding": "gzip" */ -#define GRPC_MDELEM_GRPC_ENCODING_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[65], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_ENCODING_GZIP \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[65].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-encoding": "deflate" */ -#define GRPC_MDELEM_GRPC_ENCODING_DEFLATE \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[66], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_ENCODING_DEFLATE \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[66].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "te": "trailers" */ -#define GRPC_MDELEM_TE_TRAILERS \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[67], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_TE_TRAILERS \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[67].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-type": "application/grpc" */ -#define GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[68], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[68].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":scheme": "grpc" */ -#define GRPC_MDELEM_SCHEME_GRPC \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[69], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_SCHEME_GRPC \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[69].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* ":method": "PUT" */ -#define GRPC_MDELEM_METHOD_PUT \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[70], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_METHOD_PUT \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[70].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "accept-encoding": "" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[71], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_ENCODING_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[71].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-encoding": "identity" */ -#define GRPC_MDELEM_CONTENT_ENCODING_IDENTITY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[72], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_ENCODING_IDENTITY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[72].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "content-encoding": "gzip" */ -#define GRPC_MDELEM_CONTENT_ENCODING_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[73], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_ENCODING_GZIP \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[73].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "lb-token": "" */ -#define GRPC_MDELEM_LB_TOKEN_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[74], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_LB_TOKEN_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[74].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "lb-cost-bin": "" */ -#define GRPC_MDELEM_LB_COST_BIN_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[75], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_LB_COST_BIN_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[75].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "identity" */ -#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[76], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[76].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "deflate" */ -#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[77], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[77].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "identity,deflate" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[78], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[78].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "gzip" */ -#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[79], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_GZIP \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[79].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "identity,gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[80], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[80].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "deflate,gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE_COMMA_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[81], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[81].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "identity,deflate,gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[82], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[82].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "accept-encoding": "identity" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[83], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[83].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "accept-encoding": "gzip" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[84], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[84].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) /* "accept-encoding": "identity,gzip" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[85], GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[85].data(), \ + GRPC_MDELEM_STORAGE_STATIC)) grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b); typedef enum { @@ -597,14 +684,16 @@ typedef union { : GRPC_BATCH_CALLOUTS_COUNT) extern const uint8_t grpc_static_accept_encoding_metadata[8]; -#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) \ - (GRPC_MAKE_MDELEM( \ - &grpc_static_mdelem_table[grpc_static_accept_encoding_metadata[(algs)]], \ +#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) \ + (GRPC_MAKE_MDELEM( \ + &grpc_static_mdelem_table[grpc_static_accept_encoding_metadata[(algs)]] \ + .data(), \ GRPC_MDELEM_STORAGE_STATIC)) extern const uint8_t grpc_static_accept_stream_encoding_metadata[4]; #define GRPC_MDELEM_ACCEPT_STREAM_ENCODING_FOR_ALGORITHMS(algs) \ (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table \ - [grpc_static_accept_stream_encoding_metadata[(algs)]], \ + [grpc_static_accept_stream_encoding_metadata[(algs)]] \ + .data(), \ GRPC_MDELEM_STORAGE_STATIC)) #endif /* GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H */ diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py index d66fdc3e835..b534d8dab7e 100755 --- a/tools/codegen/core/gen_static_metadata.py +++ b/tools/codegen/core/gen_static_metadata.py @@ -447,14 +447,15 @@ for i, elem in enumerate(all_elems): [len(elem[1])] + [ord(c) for c in elem[1]])) print >> H, '#define GRPC_STATIC_MDELEM_COUNT %d' % len(all_elems) -print >> H, ('extern grpc_mdelem_data ' +print >> H, ('extern grpc_core::StaticMetadata ' 'grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];') print >> H, ('extern uintptr_t ' 'grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT];') for i, elem in enumerate(all_elems): print >> H, '/* "%s": "%s" */' % elem - print >> H, ('#define %s (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[%d], ' - 'GRPC_MDELEM_STORAGE_STATIC))') % (mangle(elem).upper(), i) + print >> H, ( + '#define %s (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[%d].data(), ' + 'GRPC_MDELEM_STORAGE_STATIC))') % (mangle(elem).upper(), i) print >> H print >> C, ('uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] ' @@ -544,13 +545,14 @@ print >> C, 'grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intpt print >> C, ' if (a == -1 || b == -1) return GRPC_MDNULL;' print >> C, ' uint32_t k = static_cast(a * %d + b);' % len(all_strs) print >> C, ' uint32_t h = elems_phash(k);' -print >> C, ' return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k && elem_idxs[h] != 255 ? GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[elem_idxs[h]], GRPC_MDELEM_STORAGE_STATIC) : GRPC_MDNULL;' +print >> C, ' return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k && elem_idxs[h] != 255 ? GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[elem_idxs[h]].data(), GRPC_MDELEM_STORAGE_STATIC) : GRPC_MDNULL;' print >> C, '}' print >> C -print >> C, 'grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = {' +print >> C, 'grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = {' for a, b in all_elems: - print >> C, '{%s,%s},' % (slice_def(str_idx(a)), slice_def(str_idx(b))) + print >> C, 'grpc_core::StaticMetadata(%s,%s),' % (slice_def(str_idx(a)), + slice_def(str_idx(b))) print >> C, '};' print >> H, 'typedef enum {' @@ -579,7 +581,7 @@ print >> C, '0,%s' % ','.join('%d' % md_idx(elem) for elem in compression_elems) print >> C, '};' print >> C -print >> H, '#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[grpc_static_accept_encoding_metadata[(algs)]], GRPC_MDELEM_STORAGE_STATIC))' +print >> H, '#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[grpc_static_accept_encoding_metadata[(algs)]].data(), GRPC_MDELEM_STORAGE_STATIC))' print >> H print >> H, 'extern const uint8_t grpc_static_accept_stream_encoding_metadata[%d];' % ( @@ -590,7 +592,7 @@ print >> C, '0,%s' % ','.join( '%d' % md_idx(elem) for elem in stream_compression_elems) print >> C, '};' -print >> H, '#define GRPC_MDELEM_ACCEPT_STREAM_ENCODING_FOR_ALGORITHMS(algs) (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[grpc_static_accept_stream_encoding_metadata[(algs)]], GRPC_MDELEM_STORAGE_STATIC))' +print >> H, '#define GRPC_MDELEM_ACCEPT_STREAM_ENCODING_FOR_ALGORITHMS(algs) (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[grpc_static_accept_stream_encoding_metadata[(algs)]].data(), GRPC_MDELEM_STORAGE_STATIC))' print >> H, '#endif /* GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H */' From f13abc071cb91c06e90f7121c66f39bae59ec691 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Tue, 21 May 2019 19:02:27 -0700 Subject: [PATCH 0343/1555] Inlined and saved some ops for grpc_is_binary_header. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Various improvements for parsing/encoding: BM_HpackEncoderEncodeDeadline 171ns ± 0% 164ns ± 0% -3.74% (p=0.000 n=20+17) BM_HpackEncoderEncodeHeader/0/16384 102ns ± 1% 98ns ± 0% -3.28% (p=0.000 n=20+19) BM_HpackParserParseHeader 177ns ± 1% 165ns ± 1% -6.41% (p=0.000 n=19+18) BM_HpackParserParseHeader, UnrefHeader> 212ns ± 2% 199ns ± 1% -6.28% (p=0.000 n=20+18) --- .../chttp2/transport/hpack_encoder.cc | 18 +++-- .../chttp2/transport/hpack_parser.cc | 21 +++++- .../transport/chttp2/transport/hpack_table.cc | 7 +- .../cronet/transport/cronet_transport.cc | 5 +- src/core/lib/iomgr/error.cc | 6 +- src/core/lib/iomgr/error.h | 12 +++- .../credentials/plugin/plugin_credentials.cc | 2 +- src/core/lib/slice/slice_string_helpers.cc | 2 +- src/core/lib/slice/slice_string_helpers.h | 2 +- src/core/lib/surface/call.cc | 2 +- src/core/lib/surface/channel.cc | 57 +--------------- src/core/lib/surface/channel.h | 66 +++++++++++++++++-- src/core/lib/surface/validate_metadata.cc | 18 +++-- src/core/lib/surface/validate_metadata.h | 15 ++++- 14 files changed, 141 insertions(+), 92 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc index d2607e97707..b9871a3633e 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc @@ -37,6 +37,7 @@ #include "src/core/lib/debug/stats.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_string_helpers.h" +#include "src/core/lib/surface/validate_metadata.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/static_metadata.h" #include "src/core/lib/transport/timeout_encoding.h" @@ -323,9 +324,14 @@ typedef struct { bool insert_null_before_wire_value; } wire_value; +template static wire_value get_wire_value(grpc_mdelem elem, bool true_binary_enabled) { wire_value wire_val; - if (grpc_is_binary_header(GRPC_MDKEY(elem))) { + bool is_bin_hdr = + mdkey_definitely_interned + ? grpc_is_refcounted_slice_binary_header(GRPC_MDKEY(elem)) + : grpc_is_binary_header_internal(GRPC_MDKEY(elem)); + if (is_bin_hdr) { if (true_binary_enabled) { GRPC_STATS_INC_HPACK_SEND_BINARY(); wire_val.huffman_prefix = 0x00; @@ -363,7 +369,7 @@ static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor* c, framer_state* st) { GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX(); uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2); - wire_value value = get_wire_value(elem, st->use_true_binary_metadata); + wire_value value = get_wire_value(elem, st->use_true_binary_metadata); size_t len_val = wire_value_length(value); uint32_t len_val_len; GPR_ASSERT(len_val <= UINT32_MAX); @@ -380,7 +386,7 @@ static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor* c, framer_state* st) { GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX(); uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4); - wire_value value = get_wire_value(elem, st->use_true_binary_metadata); + wire_value value = get_wire_value(elem, st->use_true_binary_metadata); size_t len_val = wire_value_length(value); uint32_t len_val_len; GPR_ASSERT(len_val <= UINT32_MAX); @@ -399,7 +405,7 @@ static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor* c, GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX_V(); GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(); uint32_t len_key = static_cast GRPC_SLICE_LENGTH(GRPC_MDKEY(elem)); - wire_value value = get_wire_value(elem, st->use_true_binary_metadata); + wire_value value = get_wire_value(elem, st->use_true_binary_metadata); uint32_t len_val = static_cast(wire_value_length(value)); uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1); uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); @@ -421,7 +427,7 @@ static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor* c, GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX_V(); GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(); uint32_t len_key = static_cast GRPC_SLICE_LENGTH(GRPC_MDKEY(elem)); - wire_value value = get_wire_value(elem, st->use_true_binary_metadata); + wire_value value = get_wire_value(elem, st->use_true_binary_metadata); uint32_t len_val = static_cast(wire_value_length(value)); uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1); uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); @@ -464,7 +470,7 @@ static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { char* k = grpc_slice_to_c_string(GRPC_MDKEY(elem)); char* v = nullptr; - if (grpc_is_binary_header(GRPC_MDKEY(elem))) { + if (grpc_is_binary_header_internal(GRPC_MDKEY(elem))) { v = grpc_dump_slice(GRPC_MDVALUE(elem), GPR_DUMP_HEX); } else { v = grpc_slice_to_c_string(GRPC_MDVALUE(elem)); diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index 6e422127511..7d5c39e5144 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -35,6 +35,7 @@ #include "src/core/lib/profiling/timers.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_string_helpers.h" +#include "src/core/lib/surface/validate_metadata.h" #include "src/core/lib/transport/http2_errors.h" typedef enum { @@ -627,7 +628,7 @@ static grpc_error* on_hdr(grpc_chttp2_hpack_parser* p, grpc_mdelem md, if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { char* k = grpc_slice_to_c_string(GRPC_MDKEY(md)); char* v = nullptr; - if (grpc_is_binary_header(GRPC_MDKEY(md))) { + if (grpc_is_binary_header_internal(GRPC_MDKEY(md))) { v = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX); } else { v = grpc_slice_to_c_string(GRPC_MDVALUE(md)); @@ -1494,7 +1495,13 @@ static grpc_error* parse_key_string(grpc_chttp2_hpack_parser* p, /* check if a key represents a binary header or not */ static bool is_binary_literal_header(grpc_chttp2_hpack_parser* p) { - return grpc_is_binary_header( + /* We know that either argument here is a reference counter slice. + * 1. If a result of grpc_slice_from_static_buffer, the refcount is set to + * NoopRefcount. + * 2. If it's p->key.data.referenced, then p->key.copied was set to false, + * which occurs in begin_parse_string() - where the refcount is set to + * p->current_slice_refcount, which is not null. */ + return grpc_is_refcounted_slice_binary_header( p->key.copied ? grpc_slice_from_static_buffer(p->key.data.copied.str, p->key.data.copied.length) : p->key.data.referenced); @@ -1511,7 +1518,15 @@ static grpc_error* is_binary_indexed_header(grpc_chttp2_hpack_parser* p, static_cast(p->index)), GRPC_ERROR_INT_SIZE, static_cast(p->table.num_ents)); } - *is = grpc_is_binary_header(GRPC_MDKEY(elem)); + /* We know that GRPC_MDKEY(elem) points to a reference counted slice since: + * 1. elem was a result of grpc_chttp2_hptbl_lookup + * 2. An item in this table is either static (see entries with + * index < GRPC_CHTTP2_LAST_STATIC_ENTRY or added via + * grpc_chttp2_hptbl_add). + * 3. If added via grpc_chttp2_hptbl_add, the entry is either static or + * interned. + * 4. Both static and interned element slices have non-null refcounts. */ + *is = grpc_is_refcounted_slice_binary_header(GRPC_MDKEY(elem)); return GRPC_ERROR_NONE; } diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.cc b/src/core/ext/transport/chttp2/transport/hpack_table.cc index 16aeb49df4d..f1cf4acf7dd 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_table.cc @@ -29,6 +29,7 @@ #include "src/core/lib/debug/trace.h" #include "src/core/lib/gpr/murmur_hash.h" +#include "src/core/lib/surface/validate_metadata.h" #include "src/core/lib/transport/static_metadata.h" extern grpc_core::TraceFlag grpc_http_trace; @@ -375,9 +376,11 @@ static size_t get_base64_encoded_size(size_t raw_length) { size_t grpc_chttp2_get_size_in_hpack_table(grpc_mdelem elem, bool use_true_binary_metadata) { - size_t overhead_and_key = 32 + GRPC_SLICE_LENGTH(GRPC_MDKEY(elem)); + const uint8_t* key_buf = GRPC_SLICE_START_PTR(GRPC_MDKEY(elem)); + size_t key_len = GRPC_SLICE_LENGTH(GRPC_MDKEY(elem)); + size_t overhead_and_key = 32 + key_len; size_t value_len = GRPC_SLICE_LENGTH(GRPC_MDVALUE(elem)); - if (grpc_is_binary_header(GRPC_MDKEY(elem))) { + if (grpc_key_is_binary_header(key_buf, key_len)) { return overhead_and_key + (use_true_binary_metadata ? value_len + 1 : get_base64_encoded_size(value_len)); diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc index 413de807638..3ddda268cfb 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.cc +++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc @@ -38,6 +38,7 @@ #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_string_helpers.h" #include "src/core/lib/surface/channel.h" +#include "src/core/lib/surface/validate_metadata.h" #include "src/core/lib/transport/metadata_batch.h" #include "src/core/lib/transport/static_metadata.h" #include "src/core/lib/transport/transport_impl.h" @@ -419,7 +420,7 @@ static void convert_cronet_array_to_metadata( grpc_slice key = grpc_slice_intern( grpc_slice_from_static_string(header_array->headers[i].key)); grpc_slice value; - if (grpc_is_binary_header(key)) { + if (grpc_is_refcounted_slice_binary_header(key)) { value = grpc_slice_from_static_string(header_array->headers[i].value); value = grpc_slice_intern(grpc_chttp2_base64_decode_with_length( value, grpc_chttp2_base64_infer_length_after_decode(value))); @@ -746,7 +747,7 @@ static void convert_metadata_to_cronet_headers( curr = curr->next; char* key = grpc_slice_to_c_string(GRPC_MDKEY(mdelem)); char* value; - if (grpc_is_binary_header(GRPC_MDKEY(mdelem))) { + if (grpc_is_binary_header_internal(GRPC_MDKEY(mdelem))) { grpc_slice wire_value = grpc_chttp2_base64_encode(GRPC_MDVALUE(mdelem)); value = grpc_slice_to_c_string(wire_value); grpc_slice_unref_internal(wire_value); diff --git a/src/core/lib/iomgr/error.cc b/src/core/lib/iomgr/error.cc index f194eb62d48..ebec9dc704a 100644 --- a/src/core/lib/iomgr/error.cc +++ b/src/core/lib/iomgr/error.cc @@ -795,9 +795,9 @@ grpc_error* grpc_wsa_error(const char* file, int line, int err, } #endif -bool grpc_log_if_error(const char* what, grpc_error* error, const char* file, - int line) { - if (error == GRPC_ERROR_NONE) return true; +bool grpc_log_error(const char* what, grpc_error* error, const char* file, + int line) { + GPR_DEBUG_ASSERT(error != GRPC_ERROR_NONE); const char* msg = grpc_error_string(error); gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, "%s: %s", what, msg); GRPC_ERROR_UNREF(error); diff --git a/src/core/lib/iomgr/error.h b/src/core/lib/iomgr/error.h index 7b04888e9ec..0a72e5ca101 100644 --- a/src/core/lib/iomgr/error.h +++ b/src/core/lib/iomgr/error.h @@ -261,9 +261,15 @@ grpc_error* grpc_wsa_error(const char* file, int line, int err, #define GRPC_WSA_ERROR(err, call_name) \ grpc_wsa_error(__FILE__, __LINE__, err, call_name) -bool grpc_log_if_error(const char* what, grpc_error* error, const char* file, - int line); +bool grpc_log_error(const char* what, grpc_error* error, const char* file, + int line); +inline bool grpc_log_if_error(const char* what, grpc_error* error, + const char* file, int line) { + return error == GRPC_ERROR_NONE ? true + : grpc_log_error(what, error, file, line); +} + #define GRPC_LOG_IF_ERROR(what, error) \ - grpc_log_if_error((what), (error), __FILE__, __LINE__) + (grpc_log_if_error((what), (error), __FILE__, __LINE__)) #endif /* GRPC_CORE_LIB_IOMGR_ERROR_H */ diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/src/core/lib/security/credentials/plugin/plugin_credentials.cc index 333366d0f0a..92af88aee0b 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.cc +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc @@ -85,7 +85,7 @@ static grpc_error* process_plugin_result( grpc_validate_header_key_is_legal(md[i].key))) { seen_illegal_header = true; break; - } else if (!grpc_is_binary_header(md[i].key) && + } else if (!grpc_is_binary_header_internal(md[i].key) && !GRPC_LOG_IF_ERROR( "validate_metadata_from_plugin", grpc_validate_header_nonbin_value_is_legal(md[i].value))) { diff --git a/src/core/lib/slice/slice_string_helpers.cc b/src/core/lib/slice/slice_string_helpers.cc index 6af9c33eb56..c2392fd392f 100644 --- a/src/core/lib/slice/slice_string_helpers.cc +++ b/src/core/lib/slice/slice_string_helpers.cc @@ -27,7 +27,7 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/slice/slice_internal.h" -char* grpc_dump_slice(grpc_slice s, uint32_t flags) { +char* grpc_dump_slice(const grpc_slice& s, uint32_t flags) { return gpr_dump(reinterpret_cast GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s), flags); } diff --git a/src/core/lib/slice/slice_string_helpers.h b/src/core/lib/slice/slice_string_helpers.h index 976f72411a8..cb1df658fa5 100644 --- a/src/core/lib/slice/slice_string_helpers.h +++ b/src/core/lib/slice/slice_string_helpers.h @@ -30,7 +30,7 @@ #include "src/core/lib/gpr/string.h" /* Calls gpr_dump on a slice. */ -char* grpc_dump_slice(grpc_slice slice, uint32_t flags); +char* grpc_dump_slice(const grpc_slice& slice, uint32_t flags); /** Split \a str by the separator \a sep. Results are stored in \a dst, which * should be a properly initialized instance. */ diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 254476f47e3..0ae7de29070 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -899,7 +899,7 @@ static int prepare_application_metadata(grpc_call* call, int count, if (!GRPC_LOG_IF_ERROR("validate_metadata", grpc_validate_header_key_is_legal(md->key))) { break; - } else if (!grpc_is_binary_header(md->key) && + } else if (!grpc_is_binary_header_internal(md->key) && !GRPC_LOG_IF_ERROR( "validate_metadata", grpc_validate_header_nonbin_value_is_legal(md->value))) { diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index e47cb4360ea..12869b7780d 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -59,23 +59,6 @@ typedef struct registered_call { struct registered_call* next; } registered_call; -struct grpc_channel { - int is_client; - grpc_compression_options compression_options; - - gpr_atm call_size_estimate; - grpc_resource_user* resource_user; - - gpr_mu registered_call_mu; - registered_call* registered_calls; - - grpc_core::RefCountedPtr channelz_channel; - - char* target; -}; - -#define CHANNEL_STACK_FROM_CHANNEL(c) ((grpc_channel_stack*)((c) + 1)) - static void destroy_channel(void* arg, grpc_error* error); grpc_channel* grpc_channel_create_with_builder( @@ -214,11 +197,6 @@ static grpc_channel_args* build_channel_args( return grpc_channel_args_copy_and_add(input_args, new_args, num_new_args); } -grpc_core::channelz::ChannelNode* grpc_channel_get_channelz_node( - grpc_channel* channel) { - return channel->channelz_channel.get(); -} - grpc_channel* grpc_channel_create(const char* target, const grpc_channel_args* input_args, grpc_channel_stack_type channel_stack_type, @@ -421,21 +399,6 @@ grpc_call* grpc_channel_create_registered_call( return call; } -#ifndef NDEBUG -#define REF_REASON reason -#define REF_ARG , const char* reason -#else -#define REF_REASON "" -#define REF_ARG -#endif -void grpc_channel_internal_ref(grpc_channel* c REF_ARG) { - GRPC_CHANNEL_STACK_REF(CHANNEL_STACK_FROM_CHANNEL(c), REF_REASON); -} - -void grpc_channel_internal_unref(grpc_channel* c REF_ARG) { - GRPC_CHANNEL_STACK_UNREF(CHANNEL_STACK_FROM_CHANNEL(c), REF_REASON); -} - static void destroy_channel(void* arg, grpc_error* error) { grpc_channel* channel = static_cast(arg); if (channel->channelz_channel != nullptr) { @@ -475,25 +438,9 @@ void grpc_channel_destroy(grpc_channel* channel) { GRPC_CHANNEL_INTERNAL_UNREF(channel, "channel"); } -grpc_channel_stack* grpc_channel_get_channel_stack(grpc_channel* channel) { - return CHANNEL_STACK_FROM_CHANNEL(channel); -} - -grpc_compression_options grpc_channel_compression_options( - const grpc_channel* channel) { - return channel->compression_options; -} - -grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_channel* channel, int i) { +grpc_mdelem grpc_channel_get_reffed_status_elem_slowpath(grpc_channel* channel, + int i) { char tmp[GPR_LTOA_MIN_BUFSIZE]; - switch (i) { - case 0: - return GRPC_MDELEM_GRPC_STATUS_0; - case 1: - return GRPC_MDELEM_GRPC_STATUS_1; - case 2: - return GRPC_MDELEM_GRPC_STATUS_2; - } gpr_ltoa(i, tmp); return grpc_mdelem_from_slices(GRPC_MDSTR_GRPC_STATUS, grpc_slice_from_copied_string(tmp)); diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h index ab00b8e94f7..5d666220745 100644 --- a/src/core/lib/surface/channel.h +++ b/src/core/lib/surface/channel.h @@ -59,22 +59,76 @@ grpc_core::channelz::ChannelNode* grpc_channel_get_channelz_node( status_code. The returned elem is owned by the caller. */ -grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_channel* channel, - int status_code); +grpc_mdelem grpc_channel_get_reffed_status_elem_slowpath(grpc_channel* channel, + int status_code); +inline grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_channel* channel, + int status_code) { + switch (status_code) { + case 0: + return GRPC_MDELEM_GRPC_STATUS_0; + case 1: + return GRPC_MDELEM_GRPC_STATUS_1; + case 2: + return GRPC_MDELEM_GRPC_STATUS_2; + } + return grpc_channel_get_reffed_status_elem_slowpath(channel, status_code); +} size_t grpc_channel_get_call_size_estimate(grpc_channel* channel); void grpc_channel_update_call_size_estimate(grpc_channel* channel, size_t size); +struct registered_call; +struct grpc_channel { + int is_client; + grpc_compression_options compression_options; + + gpr_atm call_size_estimate; + grpc_resource_user* resource_user; + + gpr_mu registered_call_mu; + registered_call* registered_calls; + + grpc_core::RefCountedPtr channelz_channel; + + char* target; +}; +#define CHANNEL_STACK_FROM_CHANNEL(c) ((grpc_channel_stack*)((c) + 1)) + +inline grpc_compression_options grpc_channel_compression_options( + const grpc_channel* channel) { + return channel->compression_options; +} + +inline grpc_channel_stack* grpc_channel_get_channel_stack( + grpc_channel* channel) { + return CHANNEL_STACK_FROM_CHANNEL(channel); +} + +inline grpc_core::channelz::ChannelNode* grpc_channel_get_channelz_node( + grpc_channel* channel) { + return channel->channelz_channel.get(); +} + #ifndef NDEBUG -void grpc_channel_internal_ref(grpc_channel* channel, const char* reason); -void grpc_channel_internal_unref(grpc_channel* channel, const char* reason); +inline void grpc_channel_internal_ref(grpc_channel* channel, + const char* reason) { + GRPC_CHANNEL_STACK_REF(CHANNEL_STACK_FROM_CHANNEL(channel), reason); +} +inline void grpc_channel_internal_unref(grpc_channel* channel, + const char* reason) { + GRPC_CHANNEL_STACK_UNREF(CHANNEL_STACK_FROM_CHANNEL(channel), reason); +} #define GRPC_CHANNEL_INTERNAL_REF(channel, reason) \ grpc_channel_internal_ref(channel, reason) #define GRPC_CHANNEL_INTERNAL_UNREF(channel, reason) \ grpc_channel_internal_unref(channel, reason) #else -void grpc_channel_internal_ref(grpc_channel* channel); -void grpc_channel_internal_unref(grpc_channel* channel); +inline void grpc_channel_internal_ref(grpc_channel* channel) { + GRPC_CHANNEL_STACK_REF(CHANNEL_STACK_FROM_CHANNEL(channel), "unused"); +} +inline void grpc_channel_internal_unref(grpc_channel* channel) { + GRPC_CHANNEL_STACK_UNREF(CHANNEL_STACK_FROM_CHANNEL(channel), "unused"); +} #define GRPC_CHANNEL_INTERNAL_REF(channel, reason) \ grpc_channel_internal_ref(channel) #define GRPC_CHANNEL_INTERNAL_UNREF(channel, reason) \ diff --git a/src/core/lib/surface/validate_metadata.cc b/src/core/lib/surface/validate_metadata.cc index 2dd18f3dd3f..a92ab823a38 100644 --- a/src/core/lib/surface/validate_metadata.cc +++ b/src/core/lib/surface/validate_metadata.cc @@ -29,7 +29,8 @@ #include "src/core/lib/slice/slice_string_helpers.h" #include "src/core/lib/surface/validate_metadata.h" -static grpc_error* conforms_to(grpc_slice slice, const uint8_t* legal_bits, +static grpc_error* conforms_to(const grpc_slice& slice, + const uint8_t* legal_bits, const char* err_desc) { const uint8_t* p = GRPC_SLICE_START_PTR(slice); const uint8_t* e = GRPC_SLICE_END_PTR(slice); @@ -57,7 +58,7 @@ static int error2int(grpc_error* error) { return r; } -grpc_error* grpc_validate_header_key_is_legal(grpc_slice slice) { +grpc_error* grpc_validate_header_key_is_legal(const grpc_slice& slice) { static const uint8_t legal_header_bits[256 / 8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xff, 0x03, 0x00, 0x00, 0x00, 0x80, 0xfe, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -77,7 +78,8 @@ int grpc_header_key_is_legal(grpc_slice slice) { return error2int(grpc_validate_header_key_is_legal(slice)); } -grpc_error* grpc_validate_header_nonbin_value_is_legal(grpc_slice slice) { +grpc_error* grpc_validate_header_nonbin_value_is_legal( + const grpc_slice& slice) { static const uint8_t legal_header_bits[256 / 8] = { 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -89,7 +91,11 @@ int grpc_header_nonbin_value_is_legal(grpc_slice slice) { return error2int(grpc_validate_header_nonbin_value_is_legal(slice)); } -int grpc_is_binary_header(grpc_slice slice) { - if (GRPC_SLICE_LENGTH(slice) < 5) return 0; - return 0 == memcmp(GRPC_SLICE_END_PTR(slice) - 4, "-bin", 4); +int grpc_is_binary_header_internal(const grpc_slice& slice) { + return grpc_key_is_binary_header(GRPC_SLICE_START_PTR(slice), + GRPC_SLICE_LENGTH(slice)); +} + +int grpc_is_binary_header(grpc_slice slice) { + return grpc_is_binary_header_internal(slice); } diff --git a/src/core/lib/surface/validate_metadata.h b/src/core/lib/surface/validate_metadata.h index e87fb7beedc..db3be684c11 100644 --- a/src/core/lib/surface/validate_metadata.h +++ b/src/core/lib/surface/validate_metadata.h @@ -24,7 +24,18 @@ #include #include "src/core/lib/iomgr/error.h" -grpc_error* grpc_validate_header_key_is_legal(grpc_slice slice); -grpc_error* grpc_validate_header_nonbin_value_is_legal(grpc_slice slice); +grpc_error* grpc_validate_header_key_is_legal(const grpc_slice& slice); +grpc_error* grpc_validate_header_nonbin_value_is_legal(const grpc_slice& slice); + +int grpc_is_binary_header_internal(const grpc_slice& slice); +inline int grpc_key_is_binary_header(const uint8_t* buf, size_t length) { + if (length < 5) return 0; + return 0 == memcmp(buf + length - 4, "-bin", 4); +} +inline int grpc_is_refcounted_slice_binary_header(const grpc_slice& slice) { + GPR_DEBUG_ASSERT(slice.refcount != nullptr); + return grpc_key_is_binary_header(slice.data.refcounted.bytes, + slice.data.refcounted.length); +} #endif /* GRPC_CORE_LIB_SURFACE_VALIDATE_METADATA_H */ From bd2756e482b90df42bc3f60105cb06841331aad9 Mon Sep 17 00:00:00 2001 From: Wayne Zhang Date: Tue, 28 May 2019 15:39:53 -0700 Subject: [PATCH 0344/1555] Fix format --- test/cpp/util/test_credentials_provider.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cpp/util/test_credentials_provider.cc b/test/cpp/util/test_credentials_provider.cc index 41779327cb9..fd796372c8c 100644 --- a/test/cpp/util/test_credentials_provider.cc +++ b/test/cpp/util/test_credentials_provider.cc @@ -119,8 +119,8 @@ class DefaultCredentialsProvider : public CredentialsProvider { SslServerCredentialsOptions ssl_opts; ssl_opts.pem_root_certs = ""; if (!custom_server_key_.empty() && !custom_server_cert_.empty()) { - SslServerCredentialsOptions::PemKeyCertPair pkcp = {custom_server_key_, - custom_server_cert_}; + SslServerCredentialsOptions::PemKeyCertPair pkcp = { + custom_server_key_, custom_server_cert_}; ssl_opts.pem_key_cert_pairs.push_back(pkcp); } else { SslServerCredentialsOptions::PemKeyCertPair pkcp = {test_server1_key, From 740c931e239a6a823e0fb86ced095f930fae9730 Mon Sep 17 00:00:00 2001 From: Guantao Liu Date: Tue, 28 May 2019 16:25:01 -0700 Subject: [PATCH 0345/1555] Adjust the order of IOMgr initialization, so as to set up a customized timer correctly. Also, change the comment of grpc_timer::heap_index. --- src/core/lib/iomgr/iomgr.cc | 2 +- src/core/lib/iomgr/timer.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/iomgr.cc b/src/core/lib/iomgr/iomgr.cc index b86aa6f2d76..b09d19fa759 100644 --- a/src/core/lib/iomgr/iomgr.cc +++ b/src/core/lib/iomgr/iomgr.cc @@ -57,10 +57,10 @@ void grpc_iomgr_init() { gpr_mu_init(&g_mu); gpr_cv_init(&g_rcv); grpc_core::Executor::InitAll(); - grpc_timer_list_init(); g_root_object.next = g_root_object.prev = &g_root_object; g_root_object.name = (char*)"root"; grpc_iomgr_platform_init(); + grpc_timer_list_init(); grpc_core::grpc_errqueue_init(); } diff --git a/src/core/lib/iomgr/timer.h b/src/core/lib/iomgr/timer.h index 17e933b8658..11da1496523 100644 --- a/src/core/lib/iomgr/timer.h +++ b/src/core/lib/iomgr/timer.h @@ -29,7 +29,8 @@ typedef struct grpc_timer { grpc_millis deadline; - uint32_t heap_index; /* INVALID_HEAP_INDEX if not in heap */ + // Uninitialized if not using heap, or INVALID_HEAP_INDEX if not in heap. + uint32_t heap_index; bool pending; struct grpc_timer* next; struct grpc_timer* prev; From 7ec666948126320145a33ccb902b90f037301410 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 28 May 2019 16:56:25 -0700 Subject: [PATCH 0346/1555] address comments --- src/objective-c/GRPCClient/GRPCCall.m | 29 +------ src/objective-c/GRPCClient/GRPCInterceptor.h | 2 +- src/objective-c/GRPCClient/GRPCInterceptor.m | 52 +++++------- .../project.pbxproj | 9 +- .../InterceptorSample/CacheInterceptor.m | 4 + .../tests/Tests.xcodeproj/project.pbxproj | 84 +++++++++---------- 6 files changed, 67 insertions(+), 113 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 617208b8079..cee86d6704e 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -152,7 +152,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; } else { for (int i = (int)interceptorFactories.count - 1; i >= 0; i--) { GRPCInterceptorManager *manager = - [[GRPCInterceptorManager alloc] initWithNextInerceptor:nextInterceptor]; + [[GRPCInterceptorManager alloc] initWithNextInterceptor:nextInterceptor]; GRPCInterceptor *interceptor = [interceptorFactories[i] createInterceptorWithManager:manager]; NSAssert(interceptor != nil, @"Failed to create interceptor"); @@ -244,33 +244,6 @@ const char *kCFStreamVarName = "grpc_cfstream"; } } -- (void)issueDidWriteData { - @synchronized(self) { - if (_callOptions.flowControlEnabled && [_handler respondsToSelector:@selector(didWriteData)]) { - dispatch_async(_dispatchQueue, ^{ - id copiedHandler = nil; - @synchronized(self) { - copiedHandler = self->_handler; - }; - [copiedHandler didWriteData]; - }); - } - } -} - -- (void)receiveNextMessages:(NSUInteger)numberOfMessages { - // branching based on _callOptions.flowControlEnabled is handled inside _call - GRPCCall *copiedCall = nil; - @synchronized(self) { - copiedCall = _call; - if (copiedCall == nil) { - _pendingReceiveNextMessages += numberOfMessages; - return; - } - } - [copiedCall receiveNextMessages:numberOfMessages]; -} - @end // The following methods of a C gRPC call object aren't reentrant, and thus diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.h b/src/objective-c/GRPCClient/GRPCInterceptor.h index 931f6e4aa5a..aa1c4d18565 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.h +++ b/src/objective-c/GRPCClient/GRPCInterceptor.h @@ -177,7 +177,7 @@ NS_ASSUME_NONNULL_BEGIN + (instancetype) new NS_UNAVAILABLE; -- (nullable instancetype)initWithNextInerceptor:(id)nextInterceptor +- (nullable instancetype)initWithNextInterceptor:(id)nextInterceptor NS_DESIGNATED_INITIALIZER; /** Set the previous interceptor in the chain. Can only be set once. */ diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.m b/src/objective-c/GRPCClient/GRPCInterceptor.m index 1c1f0b53114..6be27d74c11 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.m +++ b/src/objective-c/GRPCClient/GRPCInterceptor.m @@ -25,7 +25,7 @@ id _previousInterceptor; } -- (instancetype)initWithNextInerceptor:(id)nextInterceptor { +- (instancetype)initWithNextInterceptor:(id)nextInterceptor { if ((self = [super init])) { _nextInterceptor = nextInterceptor; } @@ -44,49 +44,39 @@ - (void)startNextInterceptorWithRequest:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { - if ([_nextInterceptor respondsToSelector:@selector(startWithRequestOptions:callOptions:)]) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; - }); - } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ + [copiedNextInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; + }); } - (void)writeNextInterceptorWithData:(id)data { - if ([_nextInterceptor respondsToSelector:@selector(writeData:)]) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor writeData:data]; - }); - } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ + [copiedNextInterceptor writeData:data]; + }); } - (void)finishNextInterceptor { - if ([_nextInterceptor respondsToSelector:@selector(finish)]) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor finish]; - }); - } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ + [copiedNextInterceptor finish]; + }); } - (void)cancelNextInterceptor { - if ([_nextInterceptor respondsToSelector:@selector(cancel)]) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor cancel]; - }); - } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ + [copiedNextInterceptor cancel]; + }); } /** Notify the next interceptor in the chain to receive more messages */ - (void)receiveNextInterceptorMessages:(NSUInteger)numberOfMessages { - if ([_nextInterceptor respondsToSelector:@selector(receiveNextMessages:)]) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor receiveNextMessages:numberOfMessages]; - }); - } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ + [copiedNextInterceptor receiveNextMessages:numberOfMessages]; + }); } // Methods to forward GRPCResponseHandler callbacks to the previous object diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj b/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj index e72ef6edc61..8b8811d4c62 100644 --- a/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj @@ -174,16 +174,11 @@ files = ( ); inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC/gRPCCertificates.bundle", + "${PODS_ROOT}/Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample-resources-${CONFIGURATION}-input-files.xcfilelist", ); name = "[CP] Copy Pods Resources"; outputFileListPaths = ( - ); - outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", + "${PODS_ROOT}/Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample-resources-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.m b/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.m index 082bd303dec..4e0cf2c90ed 100644 --- a/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.m +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.m @@ -145,6 +145,10 @@ ResponseCacheEntry *response = nil; @synchronized(self) { response = [_cache objectForKey:request]; + if ([response.deadline timeIntervalSinceNow] < 0) { + [_cache removeObjectForKey:request]; + response = nil; + } } return response; } diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index 27a617c83b4..de5461f1d2f 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -1360,7 +1360,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; @@ -1369,7 +1369,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels-resources.sh\"\n"; showEnvVarsInLog = 0; }; 1EAF0CBDBFAB18D4DA64535D /* [CP] Copy Pods Resources */ = { @@ -1378,7 +1378,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-ChannelTests/Pods-ChannelTests-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; @@ -1387,7 +1387,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ChannelTests/Pods-ChannelTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; 252A376345E38FD452A89C3D /* [CP] Check Pods Manifest.lock */ = { @@ -1432,7 +1432,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet-frameworks.sh", + "${PODS_ROOT}/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet-frameworks.sh", "${PODS_ROOT}/CronetFramework/Cronet.framework", ); name = "[CP] Embed Pods Frameworks"; @@ -1441,7 +1441,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; 452FDC3918FEC23ECAFD31EC /* [CP] Copy Pods Resources */ = { @@ -1449,21 +1449,17 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-MacTests/Pods-MacTests-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-MacTests/Pods-MacTests-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-macOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - ); outputPaths = ( "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-MacTests/Pods-MacTests-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MacTests/Pods-MacTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; 483CDBBAEAEFCB530ADDDDD5 /* [CP] Check Pods Manifest.lock */ = { @@ -1508,7 +1504,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; @@ -1517,7 +1513,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream-resources.sh\"\n"; showEnvVarsInLog = 0; }; 5C20DCCB71C3991E6FE78C22 /* [CP] Check Pods Manifest.lock */ = { @@ -1544,7 +1540,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; @@ -1553,7 +1549,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL-resources.sh\"\n"; showEnvVarsInLog = 0; }; 6BA6D00B1816306453BF82D4 /* [CP] Copy Pods Resources */ = { @@ -1562,7 +1558,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; @@ -1571,7 +1567,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions-resources.sh\"\n"; showEnvVarsInLog = 0; }; 7418AC7B3844B29E48D24FC7 /* [CP] Check Pods Manifest.lock */ = { @@ -1616,7 +1612,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; @@ -1625,7 +1621,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext-resources.sh\"\n"; showEnvVarsInLog = 0; }; 8C1ED025E07C4D457C355336 /* [CP] Check Pods Manifest.lock */ = { @@ -1652,7 +1648,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels-frameworks.sh", + "${PODS_ROOT}/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels-frameworks.sh", "${PODS_ROOT}/CronetFramework/Cronet.framework", ); name = "[CP] Embed Pods Frameworks"; @@ -1661,7 +1657,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; 914ADDD7106BA9BB8A7E569F /* [CP] Check Pods Manifest.lock */ = { @@ -1688,7 +1684,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; @@ -1697,7 +1693,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream-resources.sh\"\n"; showEnvVarsInLog = 0; }; 9AD0B5E94F2AA5962EA6AA36 /* [CP] Copy Pods Resources */ = { @@ -1706,7 +1702,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-UnitTests/Pods-UnitTests-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; @@ -1715,7 +1711,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-UnitTests/Pods-UnitTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; A023FB55205A7EA37D413549 /* [CP] Copy Pods Resources */ = { @@ -1724,7 +1720,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; @@ -1733,7 +1729,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream-resources.sh\"\n"; showEnvVarsInLog = 0; }; A441F71824DCB9D0CA297748 /* [CP] Copy Pods Resources */ = { @@ -1742,7 +1738,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-AllTests/Pods-AllTests-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-AllTests/Pods-AllTests-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; @@ -1751,7 +1747,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AllTests/Pods-AllTests-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-AllTests/Pods-AllTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; A686B9967BB4CB81B1CBF8F8 /* [CP] Embed Pods Frameworks */ = { @@ -1760,7 +1756,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests-frameworks.sh", + "${PODS_ROOT}/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests-frameworks.sh", "${PODS_ROOT}/CronetFramework/Cronet.framework", ); name = "[CP] Embed Pods Frameworks"; @@ -1769,7 +1765,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; B2986CEEE8CDD4901C97598B /* [CP] Check Pods Manifest.lock */ = { @@ -1813,21 +1809,17 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - ); outputPaths = ( "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests-resources.sh\"\n"; showEnvVarsInLog = 0; }; C2E09DC4BD239F71160F0CC1 /* [CP] Copy Pods Resources */ = { @@ -1836,7 +1828,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; @@ -1845,7 +1837,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote-resources.sh\"\n"; showEnvVarsInLog = 0; }; C977426A8727267BBAC7D48E /* [CP] Copy Pods Resources */ = { @@ -1854,7 +1846,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; @@ -1863,7 +1855,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; DB4D0E73C229F2FF3B364AB3 /* [CP] Copy Pods Resources */ = { @@ -1872,7 +1864,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; @@ -1881,7 +1873,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet-resources.sh\"\n"; showEnvVarsInLog = 0; }; E5B20F69559C6AE299DFEA7C /* [CP] Check Pods Manifest.lock */ = { @@ -1912,7 +1904,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests-frameworks.sh", + "${PODS_ROOT}/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests-frameworks.sh", "${PODS_ROOT}/CronetFramework/Cronet.framework", ); name = "[CP] Embed Pods Frameworks"; @@ -1921,7 +1913,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; EDDD3FA856BCA3443ED36D1E /* [CP] Check Pods Manifest.lock */ = { From 7c8d6f63756ff0871cd8e251973375078f151f4f Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Tue, 28 May 2019 17:13:41 -0700 Subject: [PATCH 0347/1555] s/uintptr_t/intptr_t as requested --- src/core/lib/surface/call.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 271b3ddd560..e00ac1810de 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -99,7 +99,7 @@ struct batch_control { } completion_data; grpc_closure start_batch; grpc_closure finish_batch; - grpc_core::Atomic steps_to_complete; + grpc_core::Atomic steps_to_complete; gpr_atm batch_error = reinterpret_cast(GRPC_ERROR_NONE); void set_num_steps_to_complete(uintptr_t steps) { steps_to_complete.Store(steps, grpc_core::MemoryOrder::RELEASE); From 14c55dea4ab8a7a24003f0497c6b166079096be1 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Tue, 14 May 2019 16:19:07 -0700 Subject: [PATCH 0348/1555] Inline more of md_unref for interned metadata. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the common case, unref() for interned metadata was performing some unnecessary branches. This patch reduces the instruction count from about 19 to 12 in the case where an unref() occured but it wasn't the last reference. This has various speedups for chttp2_hpack, metadata and fullstack pingpong benchmarks. As a tradeoff, static/external metadata unref regresses slightly (fraction of a nanosecond increase in CPU time) while interned improves (roughly 5 nanoseconds reduction in CPU time). Examples: Fullstack: BM_UnaryPingPong/8/8 [polls/iter:0 ] 7.12µs ± 4% 6.91µs ± 3% -3.00% (p=0.000 n=20+19) BM_UnaryPingPong/0/32768 [polls/iter:3.0001 ] 35.3µs ± 2% 34.9µs ± 0% -1.15% (p=0.048 n=8+4) BM_UnaryPingPong/32768/32768 [polls/iter:3.00014 ] 49.6µs ± 1% 49.0µs ± 1% -1.15% (p=0.017 n=7+3) HpackParser: BM_HpackEncoderInitDestroy 274ns ± 0% 254ns ± 0% -7.12% (p=0.000 n=19+19) BM_HpackParserParseHeader 173ns ± 0% 140ns ± 0% -19.04% (p=0.000 n=18+16) BM_HpackParserParseHeader 751ns ± 1% 702ns ± 2% -6.50% (p=0.000 n=20+20) BM_HpackParserParseHeader 50.6ns ± 0% 46.9ns ± 0% -7.29% (p=0.000 n=14+19) BM_HpackParserParseHeader 486ns ± 1% 455ns ± 0% -6.42% (p=0.000 n=20+19) BM_HpackParserParseHeader 1.17µs ± 1% 1.12µs ± 1% -4.18% (p=0.000 n=18+20) BM_HpackParserParseHeader 163ns ± 1% 155ns ± 0% -4.52% (p=0.000 n=18+17) Metadata: BM_MetadataFromInternedKeyWithBackingStore 7.32ns ± 1% 6.67ns ± 0% -8.89% (p=0.000 n=20+17) BM_MetadataFromStaticMetadataStringsNotIndexed 77.4ns ± 2% 79.6ns ± 0% +2.86% (p=0.000 n=18+19) BM_MetadataRefUnrefExternal 1.74ns ± 0% 1.79ns ± 0% +2.65% (p=0.000 n=20+19) BM_MetadataRefUnrefInterned 18.5ns ± 0% 13.3ns ± 0% -28.00% (p=0.000 n=17+17) BM_MetadataRefUnrefAllocated 18.5ns ± 0% 13.3ns ± 0% -28.00% (p=0.000 n=17+18) --- src/core/lib/transport/metadata.cc | 48 ++++++---- src/core/lib/transport/metadata.h | 135 +++++++++++++---------------- 2 files changed, 93 insertions(+), 90 deletions(-) diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc index 2fdecc99d3e..1523ced16d8 100644 --- a/src/core/lib/transport/metadata.cc +++ b/src/core/lib/transport/metadata.cc @@ -109,13 +109,12 @@ void StaticMetadata::HashInit() { AllocatedMetadata::AllocatedMetadata(const grpc_slice& key, const grpc_slice& value) - : key_(grpc_slice_ref_internal(key)), - value_(grpc_slice_ref_internal(value)), - refcnt_(1) { + : RefcountedMdBase(grpc_slice_ref_internal(key), + grpc_slice_ref_internal(value)) { #ifndef NDEBUG if (grpc_trace_metadata.enabled()) { - char* key_str = grpc_slice_to_c_string(key_); - char* value_str = grpc_slice_to_c_string(value_); + char* key_str = grpc_slice_to_c_string(key); + char* value_str = grpc_slice_to_c_string(value); gpr_log(GPR_DEBUG, "ELM ALLOC:%p:%" PRIdPTR ": '%s' = '%s'", this, RefValue(), key_str, value_str); gpr_free(key_str); @@ -125,8 +124,8 @@ AllocatedMetadata::AllocatedMetadata(const grpc_slice& key, } AllocatedMetadata::~AllocatedMetadata() { - grpc_slice_unref_internal(key_); - grpc_slice_unref_internal(value_); + grpc_slice_unref_internal(key()); + grpc_slice_unref_internal(value()); void* user_data = user_data_.data.Load(grpc_core::MemoryOrder::RELAXED); if (user_data) { destroy_user_data_func destroy_user_data = @@ -138,15 +137,13 @@ AllocatedMetadata::~AllocatedMetadata() { InternedMetadata::InternedMetadata(const grpc_slice& key, const grpc_slice& value, uint32_t hash, InternedMetadata* next) - : key_(grpc_slice_ref_internal(key)), - value_(grpc_slice_ref_internal(value)), - hash_(hash), - refcnt_(1), + : RefcountedMdBase(grpc_slice_ref_internal(key), + grpc_slice_ref_internal(value), hash), link_(next) { #ifndef NDEBUG if (grpc_trace_metadata.enabled()) { - char* key_str = grpc_slice_to_c_string(key_); - char* value_str = grpc_slice_to_c_string(value_); + char* key_str = grpc_slice_to_c_string(key); + char* value_str = grpc_slice_to_c_string(value); gpr_log(GPR_DEBUG, "ELM NEW:%p:%" PRIdPTR ": '%s' = '%s'", this, RefValue(), key_str, value_str); gpr_free(key_str); @@ -156,8 +153,8 @@ InternedMetadata::InternedMetadata(const grpc_slice& key, } InternedMetadata::~InternedMetadata() { - grpc_slice_unref_internal(key_); - grpc_slice_unref_internal(value_); + grpc_slice_unref_internal(key()); + grpc_slice_unref_internal(value()); void* user_data = user_data_.data.Load(grpc_core::MemoryOrder::RELAXED); if (user_data) { destroy_user_data_func destroy_user_data = @@ -242,8 +239,8 @@ static int is_mdelem_static(grpc_mdelem e) { void InternedMetadata::RefWithShardLocked(mdtab_shard* shard) { #ifndef NDEBUG if (grpc_trace_metadata.enabled()) { - char* key_str = grpc_slice_to_c_string(key_); - char* value_str = grpc_slice_to_c_string(value_); + char* key_str = grpc_slice_to_c_string(key()); + char* value_str = grpc_slice_to_c_string(value()); intptr_t value = RefValue(); gpr_log(__FILE__, __LINE__, GPR_LOG_SEVERITY_DEBUG, "ELM REF:%p:%" PRIdPTR "->%" PRIdPTR ": '%s' = '%s'", this, value, @@ -498,3 +495,20 @@ void grpc_mdelem_do_unref(grpc_mdelem gmd DEBUG_ARGS) { } } } + +void grpc_mdelem_on_final_unref(grpc_mdelem_data_storage storage, void* ptr, + uint32_t hash DEBUG_ARGS) { + switch (storage) { + case GRPC_MDELEM_STORAGE_EXTERNAL: + case GRPC_MDELEM_STORAGE_STATIC: + return; + case GRPC_MDELEM_STORAGE_INTERNED: { + note_disposed_interned_metadata(hash); + break; + } + case GRPC_MDELEM_STORAGE_ALLOCATED: { + grpc_core::Delete(reinterpret_cast(ptr)); + break; + } + } +} diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h index 74c69f97584..3cef031031d 100644 --- a/src/core/lib/transport/metadata.h +++ b/src/core/lib/transport/metadata.h @@ -80,17 +80,22 @@ typedef struct grpc_mdelem_data { this bit set in their integer value */ #define GRPC_MDELEM_STORAGE_INTERNED_BIT 1 +/* External and static storage metadata has no refcount to ref/unref. Allocated + * and interned metadata do have a refcount. Metadata ref and unref methods use + * a switch statement on this enum to determine which behaviour to execute. + * Keeping the no-ref cases together and the ref-cases together leads to + * slightly better code generation (9 inlined instructions rather than 10). */ typedef enum { /* memory pointed to by grpc_mdelem::payload is owned by an external system */ GRPC_MDELEM_STORAGE_EXTERNAL = 0, - /* memory pointed to by grpc_mdelem::payload is interned by the metadata - system */ - GRPC_MDELEM_STORAGE_INTERNED = GRPC_MDELEM_STORAGE_INTERNED_BIT, + /* memory is in the static metadata table */ + GRPC_MDELEM_STORAGE_STATIC = GRPC_MDELEM_STORAGE_INTERNED_BIT, /* memory pointed to by grpc_mdelem::payload is allocated by the metadata system */ GRPC_MDELEM_STORAGE_ALLOCATED = 2, - /* memory is in the static metadata table */ - GRPC_MDELEM_STORAGE_STATIC = 2 | GRPC_MDELEM_STORAGE_INTERNED_BIT, + /* memory pointed to by grpc_mdelem::payload is interned by the metadata + system */ + GRPC_MDELEM_STORAGE_INTERNED = 2 | GRPC_MDELEM_STORAGE_INTERNED_BIT, } grpc_mdelem_data_storage; struct grpc_mdelem { @@ -196,17 +201,17 @@ class StaticMetadata { uint32_t hash_; }; -class InternedMetadata { +class RefcountedMdBase { public: - struct BucketLink { - explicit BucketLink(InternedMetadata* md) : next(md) {} + RefcountedMdBase(const grpc_slice& key, const grpc_slice& value) + : key_(key), value_(value), refcnt_(1) {} + RefcountedMdBase(const grpc_slice& key, const grpc_slice& value, + uint32_t hash) + : key_(key), value_(value), refcnt_(1), hash_(hash) {} - InternedMetadata* next = nullptr; - }; - - InternedMetadata(const grpc_slice& key, const grpc_slice& value, - uint32_t hash, InternedMetadata* next); - ~InternedMetadata(); + const grpc_slice& key() const { return key_; } + const grpc_slice& value() const { return value_; } + uint32_t hash() { return hash_; } #ifndef NDEBUG void Ref(const char* file, int line) { @@ -218,92 +223,65 @@ class InternedMetadata { grpc_mdelem_trace_unref(this, key_, value_, RefValue(), file, line); return Unref(); } -#else - // We define a naked Ref() in the else-clause to make sure we don't - // inadvertently skip the assert on debug builds. +#endif void Ref() { /* we can assume the ref count is >= 1 as the application is calling this function - meaning that no adjustment to mdtab_free is necessary, simplifying the logic here to be just an atomic increment */ refcnt_.FetchAdd(1, MemoryOrder::RELAXED); } -#endif // ifndef NDEBUG bool Unref() { const intptr_t prior = refcnt_.FetchSub(1, MemoryOrder::ACQ_REL); GPR_DEBUG_ASSERT(prior > 0); return prior == 1; } + protected: + intptr_t RefValue() { return refcnt_.Load(MemoryOrder::RELAXED); } + bool AllRefsDropped() { return refcnt_.Load(MemoryOrder::ACQUIRE) == 0; } + bool FirstRef() { return refcnt_.FetchAdd(1, MemoryOrder::RELAXED) == 0; } + + private: + /* must be byte compatible with grpc_mdelem_data */ + grpc_slice key_; + grpc_slice value_; + grpc_core::Atomic refcnt_; + uint32_t hash_ = 0; +}; + +class InternedMetadata : public RefcountedMdBase { + public: + struct BucketLink { + explicit BucketLink(InternedMetadata* md) : next(md) {} + + InternedMetadata* next = nullptr; + }; + + InternedMetadata(const grpc_slice& key, const grpc_slice& value, + uint32_t hash, InternedMetadata* next); + ~InternedMetadata(); + void RefWithShardLocked(mdtab_shard* shard); - const grpc_slice& key() const { return key_; } - const grpc_slice& value() const { return value_; } UserData* user_data() { return &user_data_; } - uint32_t hash() { return hash_; } InternedMetadata* bucket_next() { return link_.next; } void set_bucket_next(InternedMetadata* md) { link_.next = md; } static size_t CleanupLinkedMetadata(BucketLink* head); private: - bool AllRefsDropped() { return refcnt_.Load(MemoryOrder::ACQUIRE) == 0; } - bool FirstRef() { return refcnt_.FetchAdd(1, MemoryOrder::RELAXED) == 0; } - intptr_t RefValue() { return refcnt_.Load(MemoryOrder::RELAXED); } - - /* must be byte compatible with grpc_mdelem_data */ - grpc_slice key_; - grpc_slice value_; - - /* private only data */ - uint32_t hash_; - grpc_core::Atomic refcnt_; - UserData user_data_; - BucketLink link_; }; /* Shadow structure for grpc_mdelem_data for allocated elements */ -class AllocatedMetadata { +class AllocatedMetadata : public RefcountedMdBase { public: AllocatedMetadata(const grpc_slice& key, const grpc_slice& value); ~AllocatedMetadata(); - const grpc_slice& key() const { return key_; } - const grpc_slice& value() const { return value_; } UserData* user_data() { return &user_data_; } -#ifndef NDEBUG - void Ref(const char* file, int line) { - grpc_mdelem_trace_ref(this, key_, value_, RefValue(), file, line); - Ref(); - } - bool Unref(const char* file, int line) { - grpc_mdelem_trace_unref(this, key_, value_, RefValue(), file, line); - return Unref(); - } -#endif // ifndef NDEBUG - void Ref() { - /* we can assume the ref count is >= 1 as the application is calling - this function - meaning that no adjustment to mdtab_free is necessary, - simplifying the logic here to be just an atomic increment */ - refcnt_.FetchAdd(1, MemoryOrder::RELAXED); - } - bool Unref() { - const intptr_t prior = refcnt_.FetchSub(1, MemoryOrder::ACQ_REL); - GPR_DEBUG_ASSERT(prior > 0); - return prior == 1; - } - private: - intptr_t RefValue() { return refcnt_.Load(MemoryOrder::RELAXED); } - - /* must be byte compatible with grpc_mdelem_data */ - grpc_slice key_; - grpc_slice value_; - - /* private only data */ - grpc_core::Atomic refcnt_; - UserData user_data_; }; @@ -348,24 +326,35 @@ inline grpc_mdelem grpc_mdelem_ref(grpc_mdelem gmd) { #ifndef NDEBUG #define GRPC_MDELEM_UNREF(s) grpc_mdelem_unref((s), __FILE__, __LINE__) -void grpc_mdelem_do_unref(grpc_mdelem gmd, const char* file, int line); +void grpc_mdelem_on_final_unref(grpc_mdelem_data_storage storage, void* ptr, + uint32_t hash, const char* file, int line); inline void grpc_mdelem_unref(grpc_mdelem gmd, const char* file, int line) { #else #define GRPC_MDELEM_UNREF(s) grpc_mdelem_unref((s)) -void grpc_mdelem_do_unref(grpc_mdelem gmd); +void grpc_mdelem_on_final_unref(grpc_mdelem_data_storage storage, void* ptr, + uint32_t hash); inline void grpc_mdelem_unref(grpc_mdelem gmd) { #endif - switch (GRPC_MDELEM_STORAGE(gmd)) { + const grpc_mdelem_data_storage storage = GRPC_MDELEM_STORAGE(gmd); + switch (storage) { case GRPC_MDELEM_STORAGE_EXTERNAL: case GRPC_MDELEM_STORAGE_STATIC: return; case GRPC_MDELEM_STORAGE_INTERNED: case GRPC_MDELEM_STORAGE_ALLOCATED: + auto* md = + reinterpret_cast GRPC_MDELEM_DATA(gmd); + /* once the refcount hits zero, some other thread can come along and + free an interned md at any time: it's unsafe from this point on to + access it so we read the hash now. */ + uint32_t hash = md->hash(); + if (GPR_UNLIKELY(md->Unref())) { #ifndef NDEBUG - grpc_mdelem_do_unref(gmd, file, line); + grpc_mdelem_on_final_unref(storage, md, hash, file, line); #else - grpc_mdelem_do_unref(gmd); + grpc_mdelem_on_final_unref(storage, md, hash); #endif + } return; } } From 2cb1892c77529bfbcf5560ec222a239330ed3aa0 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 28 May 2019 20:59:00 -0700 Subject: [PATCH 0349/1555] address comments --- src/objective-c/GRPCClient/GRPCCall.m | 2 - src/objective-c/GRPCClient/GRPCInterceptor.h | 2 +- src/objective-c/GRPCClient/GRPCInterceptor.m | 4 +- .../InterceptorSample/CacheInterceptor.m | 29 +++-- src/objective-c/tests/InteropTests.m | 110 +++++++++--------- 5 files changed, 73 insertions(+), 74 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index cee86d6704e..d05f90f7dd2 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -68,8 +68,6 @@ const char *kCFStreamVarName = "grpc_cfstream"; callOptions:(GRPCCallOptions *)callOptions writeDone:(void (^)(void))writeDone; -- (void)receiveNextMessages:(NSUInteger)numberOfMessages; - @end @implementation GRPCRequestOptions diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.h b/src/objective-c/GRPCClient/GRPCInterceptor.h index aa1c4d18565..4b7bcdbff40 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.h +++ b/src/objective-c/GRPCClient/GRPCInterceptor.h @@ -210,7 +210,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)forwardPreviousInterceptorWithInitialMetadata:(nullable NSDictionary *)initialMetadata; /** Forward a received message to the previous interceptor in the chain */ -- (void)forwardPreviousIntercetporWithData:(nullable id)data; +- (void)forwardPreviousInterceptorWithData:(nullable id)data; /** Forward call close and trailing metadata to the previous interceptor in the chain */ - (void)forwardPreviousInterceptorCloseWithTrailingMetadata: diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.m b/src/objective-c/GRPCClient/GRPCInterceptor.m index 6be27d74c11..bf043fcd1f5 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.m +++ b/src/objective-c/GRPCClient/GRPCInterceptor.m @@ -92,7 +92,7 @@ } /** Forward a received message to the previous interceptor in the chain */ -- (void)forwardPreviousIntercetporWithData:(id)data { +- (void)forwardPreviousInterceptorWithData:(id)data { if ([_previousInterceptor respondsToSelector:@selector(didReceiveData:)]) { id copiedPreviousInterceptor = _previousInterceptor; dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ @@ -194,7 +194,7 @@ } - (void)didReceiveData:(id)data { - [_manager forwardPreviousIntercetporWithData:data]; + [_manager forwardPreviousInterceptorWithData:data]; } - (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.m b/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.m index 4e0cf2c90ed..c8e584d37bc 100644 --- a/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.m +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.m @@ -167,7 +167,8 @@ dispatch_queue_t _dispatchQueue; BOOL _cacheable; - BOOL _messageSeen; + BOOL _writeMessageSeen; + BOOL _readMessageSeen; GRPCCallOptions *_callOptions; GRPCRequestOptions *_requestOptions; id _requestMessage; @@ -193,7 +194,8 @@ _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); _cacheable = YES; - _messageSeen = NO; + _writeMessageSeen = NO; + _readMessageSeen = NO; _request = nil; _response = nil; } @@ -202,9 +204,7 @@ - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { - NSLog(@"start"); if (requestOptions.safety != GRPCCallSafetyCacheableRequest) { - NSLog(@"no cache"); _cacheable = NO; [_manager startNextInterceptorWithRequest:requestOptions callOptions:callOptions]; } else { @@ -214,21 +214,19 @@ } - (void)writeData:(id)data { - NSLog(@"writeData"); if (!_cacheable) { [_manager writeNextInterceptorWithData:data]; } else { - NSAssert(!_messageSeen, @"CacheInterceptor does not support streaming call"); - if (_messageSeen) { + NSAssert(!_writeMessageSeen, @"CacheInterceptor does not support streaming call"); + if (_writeMessageSeen) { NSLog(@"CacheInterceptor does not support streaming call"); } - _messageSeen = YES; + _writeMessageSeen = YES; _requestMessage = [data copy]; } } - (void)finish { - NSLog(@"finish"); if (!_cacheable) { [_manager finishNextInterceptor]; } else { @@ -236,14 +234,13 @@ _request.path = _requestOptions.path; _request.message = [_requestMessage copy]; _response = [[_context getCachedResponseForRequest:_request] copy]; - NSLog(@"Read cache for %@", _request); if (!_response) { [_manager startNextInterceptorWithRequest:_requestOptions callOptions:_callOptions]; [_manager writeNextInterceptorWithData:_requestMessage]; [_manager finishNextInterceptor]; } else { [_manager forwardPreviousInterceptorWithInitialMetadata:_response.headers]; - [_manager forwardPreviousIntercetporWithData:_response.message]; + [_manager forwardPreviousInterceptorWithData:_response.message]; [_manager forwardPreviousInterceptorCloseWithTrailingMetadata:_response.trailers error:nil]; [_manager shutDown]; } @@ -251,7 +248,6 @@ } - (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata { - NSLog(@"initialMetadata"); if (_cacheable) { NSDate *deadline = nil; for (NSString *key in initialMetadata) { @@ -286,15 +282,18 @@ } - (void)didReceiveData:(id)data { - NSLog(@"receiveData"); if (_cacheable) { + NSAssert(!_readMessageSeen, @"CacheInterceptor does not support streaming call"); + if (_readMessageSeen) { + NSLog(@"CacheInterceptor does not support streaming call"); + } + _readMessageSeen = YES; _response.message = [data copy]; } - [_manager forwardPreviousIntercetporWithData:data]; + [_manager forwardPreviousInterceptorWithData:data]; } - (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { - NSLog(@"close"); if (error == nil && _cacheable) { _response.trailers = [trailingMetadata copy]; [_context setCachedResponse:_response forRequest:_request]; diff --git a/src/objective-c/tests/InteropTests.m b/src/objective-c/tests/InteropTests.m index c96d3436144..6b29d61a173 100644 --- a/src/objective-c/tests/InteropTests.m +++ b/src/objective-c/tests/InteropTests.m @@ -172,19 +172,21 @@ BOOL isRemoteInteropTest(NSString *host) { @interface HookInterceptorFactory : NSObject - (instancetype) - initWithDispatchQueue:(dispatch_queue_t)dispatchQueue - startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, - GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook - finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook -receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, - GRPCInterceptorManager *manager))receiveNextMessagesHook - responseHeaderHook:(void (^)(NSDictionary *initialMetadata, - GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook - responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, - GRPCInterceptorManager *manager))responseCloseHook - didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook; +initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue + responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue + startHook:(void (^)(GRPCRequestOptions *requestOptions, + GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager))startHook + writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook + finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook + receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, + GRPCInterceptorManager *manager))receiveNextMessagesHook + responseHeaderHook:(void (^)(NSDictionary *initialMetadata, + GRPCInterceptorManager *manager))responseHeaderHook + responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook + responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager))responseCloseHook + didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook; - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager; @@ -194,7 +196,8 @@ receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, - (instancetype) initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - dispatchQueue:(dispatch_queue_t)dispatchQueue + requestDispatchQueue:(dispatch_queue_t)requestDispatchQueue + responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook @@ -222,25 +225,29 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager void (^_responseCloseHook)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager); void (^_didWriteDataHook)(GRPCInterceptorManager *manager); - dispatch_queue_t _dispatchQueue; + dispatch_queue_t _requestDispatchQueue; + dispatch_queue_t _responseDispatchQueue; } - (instancetype) - initWithDispatchQueue:(dispatch_queue_t)dispatchQueue - startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, - GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook - finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook -receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, - GRPCInterceptorManager *manager))receiveNextMessagesHook - responseHeaderHook:(void (^)(NSDictionary *initialMetadata, - GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook - responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, - GRPCInterceptorManager *manager))responseCloseHook - didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { +initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue + responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue + startHook:(void (^)(GRPCRequestOptions *requestOptions, + GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager))startHook + writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook + finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook + receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, + GRPCInterceptorManager *manager))receiveNextMessagesHook + responseHeaderHook:(void (^)(NSDictionary *initialMetadata, + GRPCInterceptorManager *manager))responseHeaderHook + responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook + responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager))responseCloseHook + didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { if ((self = [super init])) { - _dispatchQueue = dispatchQueue; + _requestDispatchQueue = requestDispatchQueue; + _responseDispatchQueue = responseDispatchQueue; _startHook = startHook; _writeDataHook = writeDataHook; _finishHook = finishHook; @@ -249,14 +256,14 @@ receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, _responseDataHook = responseDataHook; _responseCloseHook = responseCloseHook; _didWriteDataHook = didWriteDataHook; - _dispatchQueue = dispatchQueue; } return self; } - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { return [[HookIntercetpor alloc] initWithInterceptorManager:interceptorManager - dispatchQueue:_dispatchQueue + requestDispatchQueue:_requestDispatchQueue + responseDispatchQueue:_responseDispatchQueue startHook:_startHook writeDataHook:_writeDataHook finishHook:_finishHook @@ -281,20 +288,22 @@ receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, GRPCInterceptorManager *manager); void (^_didWriteDataHook)(GRPCInterceptorManager *manager); GRPCInterceptorManager *_manager; - dispatch_queue_t _dispatchQueue; + dispatch_queue_t _requestDispatchQueue; + dispatch_queue_t _responseDispatchQueue; } - (dispatch_queue_t)requestDispatchQueue { - return _dispatchQueue; + return _requestDispatchQueue; } - (dispatch_queue_t)dispatchQueue { - return _dispatchQueue; + return _responseDispatchQueue; } - (instancetype) initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - dispatchQueue:(dispatch_queue_t)dispatchQueue + requestDispatchQueue:(dispatch_queue_t)requestDispatchQueue + responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook @@ -309,8 +318,8 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager GRPCInterceptorManager *manager))responseCloseHook didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { if ((self = [super initWithInterceptorManager:interceptorManager - requestDispatchQueue:dispatchQueue - responseDispatchQueue:dispatchQueue])) { + requestDispatchQueue:requestDispatchQueue + responseDispatchQueue:responseDispatchQueue])) { _startHook = startHook; _writeDataHook = writeDataHook; _finishHook = finishHook; @@ -319,7 +328,8 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager _responseDataHook = responseDataHook; _responseCloseHook = responseCloseHook; _didWriteDataHook = didWriteDataHook; - _dispatchQueue = dispatchQueue; + _requestDispatchQueue = requestDispatchQueue; + _responseDispatchQueue = responseDispatchQueue; _manager = interceptorManager; } return self; @@ -406,7 +416,6 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager } + (void)setUp { - NSLog(@"InteropTest Started, class: %@", [[self class] description]); #ifdef GRPC_COMPILE_WITH_CRONET // Cronet setup [Cronet setHttp2Enabled:YES]; @@ -1316,8 +1325,6 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager } else { [call finish]; } - // DEBUG - NSLog(@"Received message"); } closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { @@ -1328,8 +1335,6 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager @"Received %i responses instead of 4.", index); [expectation fulfill]; - // DEBUG - NSLog(@"Received close"); }] callOptions:options]; [call start]; @@ -1351,7 +1356,8 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager __block NSUInteger responseCloseCount = 0; __block NSUInteger didWriteDataCount = 0; id factory = [[HookInterceptorFactory alloc] - initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager) { startCount++; @@ -1371,28 +1377,23 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager } receiveNextMessagesHook:^(NSUInteger numberOfMessages, GRPCInterceptorManager *manager) { receiveNextMessageCount++; - NSLog(@"Interceptor - receive next messages, %lu", (unsigned long)numberOfMessages); [manager receiveNextInterceptorMessages:numberOfMessages]; } responseHeaderHook:^(NSDictionary *initialMetadata, GRPCInterceptorManager *manager) { responseHeaderCount++; - NSLog(@"Interceptor - received initial metadata, %@", initialMetadata); [manager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; } responseDataHook:^(id data, GRPCInterceptorManager *manager) { responseDataCount++; - NSLog(@"Interceptor - received data, %@", data); - [manager forwardPreviousIntercetporWithData:data]; + [manager forwardPreviousInterceptorWithData:data]; } responseCloseHook:^(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager) { responseCloseCount++; - NSLog(@"Interceptor - received close, %@, %@", trailingMetadata, error); [manager forwardPreviousInterceptorCloseWithTrailingMetadata:trailingMetadata error:error]; } didWriteDataHook:^(GRPCInterceptorManager *manager) { didWriteDataCount++; - NSLog(@"Interceptor - received did-write-data"); [manager forwardPreviousInterceptorDidWriteData]; }]; @@ -1479,7 +1480,8 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager __block NSUInteger responseDataCount = 0; __block NSUInteger responseCloseCount = 0; id factory = [[HookInterceptorFactory alloc] - initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager) { startCount++; @@ -1492,11 +1494,11 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager [manager writeNextInterceptorWithData:data]; } else if (index == kCancelAfterWrites) { [manager cancelNextInterceptor]; - [manager forwardPreviousIntercetporWithData:[[RMTStreamingOutputCallResponse + [manager forwardPreviousInterceptorWithData:[[RMTStreamingOutputCallResponse messageWithPayloadSize:responses[index]] data]]; } else { // (index > kCancelAfterWrites) - [manager forwardPreviousIntercetporWithData:[[RMTStreamingOutputCallResponse + [manager forwardPreviousInterceptorWithData:[[RMTStreamingOutputCallResponse messageWithPayloadSize:responses[index]] data]]; } @@ -1514,7 +1516,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager } responseDataHook:^(id data, GRPCInterceptorManager *manager) { responseDataCount++; - [manager forwardPreviousIntercetporWithData:data]; + [manager forwardPreviousInterceptorWithData:data]; } responseCloseHook:^(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager) { From 757aba8f3c0dc159a3372dc6874fc1069141c0d3 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Tue, 28 May 2019 13:58:59 -0700 Subject: [PATCH 0350/1555] PHP: Fix ZTS build error --- src/php/ext/grpc/php_grpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/php/ext/grpc/php_grpc.c b/src/php/ext/grpc/php_grpc.c index 1098075690a..74f536ea07b 100644 --- a/src/php/ext/grpc/php_grpc.c +++ b/src/php/ext/grpc/php_grpc.c @@ -203,7 +203,7 @@ void register_fork_handlers() { } } -void apply_ini_settings() { +void apply_ini_settings(TSRMLS_D) { if (GRPC_G(enable_fork_support)) { char *enable_str = malloc(sizeof("GRPC_ENABLE_FORK_SUPPORT=1")); strcpy(enable_str, "GRPC_ENABLE_FORK_SUPPORT=1"); @@ -392,7 +392,7 @@ PHP_MINFO_FUNCTION(grpc) { */ PHP_RINIT_FUNCTION(grpc) { if (!GRPC_G(initialized)) { - apply_ini_settings(); + apply_ini_settings(TSRMLS_C); grpc_init(); register_fork_handlers(); grpc_php_init_completion_queue(TSRMLS_C); From 47dbf1dd263e0bf7aba7dbd9651b2bcb570d6889 Mon Sep 17 00:00:00 2001 From: yang-g Date: Tue, 28 May 2019 23:47:29 -0700 Subject: [PATCH 0351/1555] Second approach --- .../credentials/plugin/plugin_credentials.cc | 62 ++++++++++++------- .../credentials/plugin/plugin_credentials.h | 7 ++- .../lib/security/transport/auth_filters.h | 3 + .../security/transport/client_auth_filter.cc | 16 +++++ src/cpp/client/secure_credentials.cc | 8 ++- test/cpp/end2end/end2end_test.cc | 12 ++-- 6 files changed, 78 insertions(+), 30 deletions(-) diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/src/core/lib/security/credentials/plugin/plugin_credentials.cc index 8e926de59da..333366d0f0a 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.cc +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc @@ -54,10 +54,15 @@ void grpc_plugin_credentials::pending_request_remove_locked( } } +// Checks if the request has been cancelled. +// If not, removes it from the pending list, so that it cannot be +// cancelled out from under us. +// When this returns, r->cancelled indicates whether the request was +// cancelled before completion. void grpc_plugin_credentials::pending_request_complete(pending_request* r) { GPR_DEBUG_ASSERT(r->creds == this); gpr_mu_lock(&mu_); - pending_request_remove_locked(r); + if (!r->cancelled) pending_request_remove_locked(r); gpr_mu_unlock(&mu_); // Ref to credentials not needed anymore. Unref(); @@ -71,8 +76,7 @@ static grpc_error* process_plugin_result( char* msg; gpr_asprintf(&msg, "Getting metadata from plugin failed with error: %s", error_details); - error = grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg), - GRPC_ERROR_INT_GRPC_STATUS, status); + error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg); gpr_free(msg); } else { bool seen_illegal_header = false; @@ -91,9 +95,7 @@ static grpc_error* process_plugin_result( } } if (seen_illegal_header) { - error = grpc_error_set_int( - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal metadata."), - GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_INTERNAL); + error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal metadata"); } else { for (size_t i = 0; i < num_md; ++i) { grpc_mdelem mdelem = @@ -123,18 +125,19 @@ static void plugin_md_request_metadata_ready(void* request, "asynchronously", r->creds, r); } - // Remove request from pending list + // Remove request from pending list if not previously cancelled. r->creds->pending_request_complete(r); // If it has not been cancelled, process it. - if (r->error == GRPC_ERROR_NONE) { - r->error = process_plugin_result(r, md, num_md, status, error_details); + if (!r->cancelled) { + grpc_error* error = + process_plugin_result(r, md, num_md, status, error_details); + GRPC_CLOSURE_SCHED(r->on_request_metadata, error); } else if (GRPC_TRACE_FLAG_ENABLED(grpc_plugin_credentials_trace)) { gpr_log(GPR_INFO, "plugin_credentials[%p]: request %p: plugin was previously " "cancelled", r->creds, r); } - GRPC_CLOSURE_SCHED(r->on_request_metadata, r->error); gpr_free(r); } @@ -142,11 +145,11 @@ bool grpc_plugin_credentials::get_request_metadata( grpc_polling_entity* pollent, grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata, grpc_error** error) { + bool retval = true; // Synchronous return. if (plugin_.get_metadata != nullptr) { // Create pending_request object. pending_request* request = static_cast(gpr_zalloc(sizeof(*request))); - request->error = GRPC_ERROR_NONE; request->creds = this; request->md_array = md_array; request->on_request_metadata = on_request_metadata; @@ -180,16 +183,29 @@ bool grpc_plugin_credentials::get_request_metadata( return false; // Asynchronous return. } // Returned synchronously. - // Remove request from pending list. + // Remove request from pending list if not previously cancelled. request->creds->pending_request_complete(request); - if (GRPC_TRACE_FLAG_ENABLED(grpc_plugin_credentials_trace)) { - gpr_log(GPR_INFO, - "plugin_credentials[%p]: request %p: plugin returned " - "synchronously", - this, request); + // If the request was cancelled, the error will have been returned + // asynchronously by plugin_cancel_get_request_metadata(), so return + // false. Otherwise, process the result. + if (request->cancelled) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_plugin_credentials_trace)) { + gpr_log(GPR_INFO, + "plugin_credentials[%p]: request %p was cancelled, error " + "will be returned asynchronously", + this, request); + } + retval = false; + } else { + if (GRPC_TRACE_FLAG_ENABLED(grpc_plugin_credentials_trace)) { + gpr_log(GPR_INFO, + "plugin_credentials[%p]: request %p: plugin returned " + "synchronously", + this, request); + } + *error = process_plugin_result(request, creds_md, num_creds_md, status, + error_details); } - *error = process_plugin_result(request, creds_md, num_creds_md, status, - error_details); // Clean up. for (size_t i = 0; i < num_creds_md; ++i) { grpc_slice_unref_internal(creds_md[i].key); @@ -198,7 +214,7 @@ bool grpc_plugin_credentials::get_request_metadata( gpr_free((void*)error_details); gpr_free(request); } - return true; // Synchronous return. + return retval; } void grpc_plugin_credentials::cancel_get_request_metadata( @@ -211,11 +227,15 @@ void grpc_plugin_credentials::cancel_get_request_metadata( gpr_log(GPR_INFO, "plugin_credentials[%p]: cancelling request %p", this, pending_request); } - pending_request->error = error; + pending_request->cancelled = true; + GRPC_CLOSURE_SCHED(pending_request->on_request_metadata, + GRPC_ERROR_REF(error)); + pending_request_remove_locked(pending_request); break; } } gpr_mu_unlock(&mu_); + GRPC_ERROR_UNREF(error); } grpc_plugin_credentials::grpc_plugin_credentials( diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.h b/src/core/lib/security/credentials/plugin/plugin_credentials.h index 7350b37f8a5..77a957e5137 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.h +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.h @@ -31,7 +31,7 @@ extern grpc_core::TraceFlag grpc_plugin_credentials_trace; struct grpc_plugin_credentials final : public grpc_call_credentials { public: struct pending_request { - grpc_error* error; + bool cancelled; struct grpc_plugin_credentials* creds; grpc_credentials_mdelem_array* md_array; grpc_closure* on_request_metadata; @@ -51,6 +51,11 @@ struct grpc_plugin_credentials final : public grpc_call_credentials { void cancel_get_request_metadata(grpc_credentials_mdelem_array* md_array, grpc_error* error) override; + // Checks if the request has been cancelled. + // If not, removes it from the pending list, so that it cannot be + // cancelled out from under us. + // When this returns, r->cancelled indicates whether the request was + // cancelled before completion. void pending_request_complete(pending_request* r); private: diff --git a/src/core/lib/security/transport/auth_filters.h b/src/core/lib/security/transport/auth_filters.h index 16a8e58ed9a..5e73c21cc44 100644 --- a/src/core/lib/security/transport/auth_filters.h +++ b/src/core/lib/security/transport/auth_filters.h @@ -32,6 +32,9 @@ void grpc_auth_metadata_context_build( const grpc_slice& call_method, grpc_auth_context* auth_context, grpc_auth_metadata_context* auth_md_context); +void grpc_auth_metadata_context_copy(grpc_auth_metadata_context* from, + grpc_auth_metadata_context* to); + void grpc_auth_metadata_context_reset(grpc_auth_metadata_context* context); #endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_AUTH_FILTERS_H */ diff --git a/src/core/lib/security/transport/client_auth_filter.cc b/src/core/lib/security/transport/client_auth_filter.cc index 40393de2b13..dbe288237d4 100644 --- a/src/core/lib/security/transport/client_auth_filter.cc +++ b/src/core/lib/security/transport/client_auth_filter.cc @@ -112,6 +112,20 @@ struct call_data { } // namespace +void grpc_auth_metadata_context_copy(grpc_auth_metadata_context* from, + grpc_auth_metadata_context* to) { + grpc_auth_metadata_context_reset(to); + to->channel_auth_context = from->channel_auth_context; + if (to->channel_auth_context != nullptr) { + const_cast(to->channel_auth_context) + ->Ref(DEBUG_LOCATION, "grpc_auth_metadata_context_copy") + .release(); + } + to->service_url = + (from->service_url == nullptr) ? nullptr : strdup(from->service_url); + to->method_name = + (from->method_name == nullptr) ? nullptr : strdup(from->method_name); +} void grpc_auth_metadata_context_reset( grpc_auth_metadata_context* auth_md_context) { if (auth_md_context->service_url != nullptr) { @@ -160,6 +174,8 @@ static void on_credentials_metadata(void* arg, grpc_error* input_error) { if (error == GRPC_ERROR_NONE) { grpc_call_next_op(elem, batch); } else { + error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS, + GRPC_STATUS_UNAVAILABLE); grpc_transport_stream_op_batch_finish_with_failure(batch, error, calld->call_combiner); } diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index 724a43a9709..2d041a28664 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -22,6 +22,7 @@ #include #include #include +#include "src/core/lib/security/transport/auth_filters.h" #include "src/cpp/client/create_channel_internal.h" #include "src/cpp/common/secure_auth_context.h" @@ -247,10 +248,13 @@ int MetadataCredentialsPluginWrapper::GetMetadata( return true; } if (w->plugin_->IsBlocking()) { + grpc_auth_metadata_context context_copy = grpc_auth_metadata_context(); + grpc_auth_metadata_context_copy(&context, &context_copy); // Asynchronous return. - w->thread_pool_->Add([w, context, cb, user_data] { + w->thread_pool_->Add([w, context_copy, cb, user_data]() mutable { w->MetadataCredentialsPluginWrapper::InvokePlugin( - context, cb, user_data, nullptr, nullptr, nullptr, nullptr); + context_copy, cb, user_data, nullptr, nullptr, nullptr, nullptr); + grpc_auth_metadata_context_reset(&context_copy); }); return 0; } else { diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index a505d1a633f..1d699e97b5d 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -1849,7 +1849,7 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginKeyFailure) { Status s = stub_->Echo(&context, request, &response); EXPECT_FALSE(s.ok()); - EXPECT_EQ(s.error_code(), StatusCode::INTERNAL); + EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE); } TEST_P(SecureEnd2endTest, AuthMetadataPluginValueFailure) { @@ -1867,7 +1867,7 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginValueFailure) { Status s = stub_->Echo(&context, request, &response); EXPECT_FALSE(s.ok()); - EXPECT_EQ(s.error_code(), StatusCode::INTERNAL); + EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE); } TEST_P(SecureEnd2endTest, AuthMetadataPluginWithDeadline) { @@ -1888,7 +1888,7 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginWithDeadline) { Status s = stub_->Echo(&context, request, &response); if (!s.ok()) { - EXPECT_EQ(StatusCode::DEADLINE_EXCEEDED, s.error_code()); + EXPECT_EQ(StatusCode::UNAVAILABLE, s.error_code()); } } @@ -1912,7 +1912,7 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginWithCancel) { }); Status s = stub_->Echo(&context, request, &response); if (!s.ok()) { - EXPECT_EQ(StatusCode::CANCELLED, s.error_code()); + EXPECT_EQ(StatusCode::UNAVAILABLE, s.error_code()); } cancel_thread.join(); } @@ -1933,7 +1933,7 @@ TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginFailure) { Status s = stub_->Echo(&context, request, &response); EXPECT_FALSE(s.ok()); - EXPECT_EQ(s.error_code(), StatusCode::NOT_FOUND); + EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE); EXPECT_EQ(s.error_message(), grpc::string("Getting metadata from plugin failed with error: ") + kTestCredsPluginErrorMsg); @@ -1997,7 +1997,7 @@ TEST_P(SecureEnd2endTest, BlockingAuthMetadataPluginFailure) { Status s = stub_->Echo(&context, request, &response); EXPECT_FALSE(s.ok()); - EXPECT_EQ(s.error_code(), StatusCode::NOT_FOUND); + EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE); EXPECT_EQ(s.error_message(), grpc::string("Getting metadata from plugin failed with error: ") + kTestCredsPluginErrorMsg); From 659f71099c163a4046c595460c119fa4cd16829d Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 29 May 2019 04:03:47 -0400 Subject: [PATCH 0352/1555] upgrade bazel toolchain to fix ubsan RBE build --- bazel/grpc_deps.bzl | 8 ++++---- tools/remote_build/rbe_common.bazelrc | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index a4e6509782d..db24c7645b0 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -186,11 +186,11 @@ def grpc_deps(): if "bazel_toolchains" not in native.existing_rules(): http_archive( name = "bazel_toolchains", - sha256 = "67335b3563d9b67dc2550b8f27cc689b64fadac491e69ce78763d9ba894cc5cc", - strip_prefix = "bazel-toolchains-cddc376d428ada2927ad359211c3e356bd9c9fbb", + sha256 = "88e818f9f03628eef609c8429c210ecf265ffe46c2af095f36c7ef8b1855fef5", + strip_prefix = "bazel-toolchains-92dd8a7a518a2fb7ba992d47c8b38299fe0be825", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/cddc376d428ada2927ad359211c3e356bd9c9fbb.tar.gz", - "https://github.com/bazelbuild/bazel-toolchains/archive/cddc376d428ada2927ad359211c3e356bd9c9fbb.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/92dd8a7a518a2fb7ba992d47c8b38299fe0be825.tar.gz", + "https://github.com/bazelbuild/bazel-toolchains/archive/92dd8a7a518a2fb7ba992d47c8b38299fe0be825.tar.gz", ], ) diff --git a/tools/remote_build/rbe_common.bazelrc b/tools/remote_build/rbe_common.bazelrc index 69394fe092b..63b49c5c42d 100644 --- a/tools/remote_build/rbe_common.bazelrc +++ b/tools/remote_build/rbe_common.bazelrc @@ -84,4 +84,4 @@ build:ubsan --copt=-gmlt # TODO(jtattermusch): use more reasonable test timeout build:ubsan --test_timeout=3600 # override the config-agnostic crosstool_top -build:ubsan --crosstool_top=@bazel_toolchains//configs/experimental/ubuntu16_04_clang/1.2/bazel_0.21.0/ubsan:toolchain +build:ubsan --crosstool_top=@bazel_toolchains//configs/experimental/ubuntu16_04_clang/1.2/bazel_0.23.0/ubsan:toolchain From 3d52eca5b9a7cddcd1d2b67547c22c28847aa085 Mon Sep 17 00:00:00 2001 From: "1524995078@qq.com" <51152648+OceanOfWest@users.noreply.github.com> Date: Wed, 29 May 2019 16:22:21 +0800 Subject: [PATCH 0353/1555] fix print format for python3 add brackets of print in run_tests/start_port_server.py --- tools/run_tests/start_port_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/start_port_server.py b/tools/run_tests/start_port_server.py index 0eeceb4ce95..5b776f3b305 100755 --- a/tools/run_tests/start_port_server.py +++ b/tools/run_tests/start_port_server.py @@ -27,4 +27,4 @@ import python_utils.start_port_server as start_port_server start_port_server.start_port_server() -print "Port server started successfully" +print("Port server started successfully") From fa6c944f4c53acd28aa1392f1d3e8045c1340029 Mon Sep 17 00:00:00 2001 From: HarrisonXi Date: Wed, 29 May 2019 18:39:30 +0800 Subject: [PATCH 0354/1555] remove notification observer to avoid iOS 8 crash --- src/objective-c/GRPCClient/GRPCCall.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 495f94289e7..ba91640269e 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -648,6 +648,8 @@ const char *kCFStreamVarName = "grpc_cfstream"; } - (void)dealloc { + [GRPCConnectivityMonitor unregisterObserver:self]; + __block GRPCWrappedCall *wrappedCall = _wrappedCall; dispatch_async(_callQueue, ^{ wrappedCall = nil; From 9d3288e4082f9be89d75a4d221161443a5feccb8 Mon Sep 17 00:00:00 2001 From: yang-g Date: Wed, 29 May 2019 09:22:17 -0700 Subject: [PATCH 0355/1555] Fix test bugs --- test/cpp/end2end/end2end_test.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 1d699e97b5d..983714c044a 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -1888,7 +1889,8 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginWithDeadline) { Status s = stub_->Echo(&context, request, &response); if (!s.ok()) { - EXPECT_EQ(StatusCode::UNAVAILABLE, s.error_code()); + EXPECT_TRUE(s.error_code() == StatusCode::DEADLINE_EXCEEDED || + s.error_code() == StatusCode::UNAVAILABLE); } } @@ -1905,14 +1907,15 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginWithCancel) { true, delay)))); request.set_message("Hello"); - std::thread cancel_thread([&context] { + std::thread cancel_thread([&] { gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(delay, GPR_TIMESPAN))); context.TryCancel(); }); Status s = stub_->Echo(&context, request, &response); if (!s.ok()) { - EXPECT_EQ(StatusCode::UNAVAILABLE, s.error_code()); + EXPECT_TRUE(s.error_code() == StatusCode::CANCELLED || + s.error_code() == StatusCode::UNAVAILABLE); } cancel_thread.join(); } From 8cecf605dac9d1401c5a6611fb92521c9e1c6793 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 26 Mar 2019 14:21:11 -0700 Subject: [PATCH 0356/1555] add LiteClientBase --- src/csharp/Grpc.Core.Api/LiteClientBase.cs | 96 ++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 src/csharp/Grpc.Core.Api/LiteClientBase.cs diff --git a/src/csharp/Grpc.Core.Api/LiteClientBase.cs b/src/csharp/Grpc.Core.Api/LiteClientBase.cs new file mode 100644 index 00000000000..a978cdf09e0 --- /dev/null +++ b/src/csharp/Grpc.Core.Api/LiteClientBase.cs @@ -0,0 +1,96 @@ +#region Copyright notice and license + +// Copyright 2019 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; + +namespace Grpc.Core +{ + /// + /// Base class for lightweight client-side stubs. + /// All calls are invoked via a CallInvoker. + /// Lite client stubs have no configuration knobs, all configuration + /// is provided by decorating the call invoker. + /// Note: experimental API that can change or be removed without any prior notice. + /// + public abstract class LiteClientBase + { + readonly CallInvoker callInvoker; + + /// + /// Initializes a new instance of LiteClientBase class that + /// throws NotImplementedException upon invocation of any RPC. + /// This constructor is only provided to allow creation of test doubles + /// for client classes (e.g. mocking requires a parameterless constructor). + /// + protected LiteClientBase() : this(new UnimplementedCallInvoker()) + { + } + + /// + /// Initializes a new instance of ClientBase class. + /// + /// The CallInvoker for remote call invocation. + public LiteClientBase(CallInvoker callInvoker) + { + this.callInvoker = callInvoker; + } + + /// + /// Gets the call invoker. + /// + protected CallInvoker CallInvoker + { + get { return this.callInvoker; } + } + + /// + /// Call invoker that throws NotImplementedException for all requests. + /// + private class UnimplementedCallInvoker : CallInvoker + { + public UnimplementedCallInvoker() + { + } + + public override TResponse BlockingUnaryCall(Method method, string host, CallOptions options, TRequest request) + { + throw new NotImplementedException(); + } + + public override AsyncUnaryCall AsyncUnaryCall(Method method, string host, CallOptions options, TRequest request) + { + throw new NotImplementedException(); + } + + public override AsyncServerStreamingCall AsyncServerStreamingCall(Method method, string host, CallOptions options, TRequest request) + { + throw new NotImplementedException(); + } + + public override AsyncClientStreamingCall AsyncClientStreamingCall(Method method, string host, CallOptions options) + { + throw new NotImplementedException(); + } + + public override AsyncDuplexStreamingCall AsyncDuplexStreamingCall(Method method, string host, CallOptions options) + { + throw new NotImplementedException(); + } + } + } +} From 25e3d26e8cb361692101555cdb199933079cd90f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 26 Apr 2019 07:37:21 -0400 Subject: [PATCH 0357/1555] C# lite client codegen --- src/compiler/csharp_generator.cc | 116 ++++++++++++++++++------------- src/compiler/csharp_generator.h | 4 +- src/compiler/csharp_plugin.cc | 7 +- 3 files changed, 77 insertions(+), 50 deletions(-) diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc index 778e5c39284..10737c5e8db 100644 --- a/src/compiler/csharp_generator.cc +++ b/src/compiler/csharp_generator.cc @@ -176,8 +176,9 @@ std::string GetServiceClassName(const ServiceDescriptor* service) { return service->name(); } -std::string GetClientClassName(const ServiceDescriptor* service) { - return service->name() + "Client"; +std::string GetClientClassName(const ServiceDescriptor* service, + bool lite_client) { + return service->name() + (lite_client ? "LiteClient" : "Client"); } std::string GetServerClassName(const ServiceDescriptor* service) { @@ -414,24 +415,34 @@ void GenerateServerClass(Printer* out, const ServiceDescriptor* service) { out->Print("\n"); } -void GenerateClientStub(Printer* out, const ServiceDescriptor* service) { - out->Print("/// Client for $servicename$\n", "servicename", - GetServiceClassName(service)); - out->Print("public partial class $name$ : grpc::ClientBase<$name$>\n", "name", - GetClientClassName(service)); +void GenerateClientStub(Printer* out, const ServiceDescriptor* service, + bool lite_client) { + if (!lite_client) { + out->Print("/// Client for $servicename$\n", + "servicename", GetServiceClassName(service)); + out->Print("public partial class $name$ : grpc::ClientBase<$name$>\n", + "name", GetClientClassName(service, lite_client)); + } else { + out->Print("/// Lite client for $servicename$\n", + "servicename", GetServiceClassName(service)); + out->Print("public partial class $name$ : grpc::LiteClientBase\n", "name", + GetClientClassName(service, lite_client)); + } out->Print("{\n"); out->Indent(); // constructors - out->Print( - "/// Creates a new client for $servicename$\n" - "/// The channel to use to make remote " - "calls.\n", - "servicename", GetServiceClassName(service)); - out->Print("public $name$(grpc::Channel channel) : base(channel)\n", "name", - GetClientClassName(service)); - out->Print("{\n"); - out->Print("}\n"); + if (!lite_client) { + out->Print( + "/// Creates a new client for $servicename$\n" + "/// The channel to use to make remote " + "calls.\n", + "servicename", GetServiceClassName(service)); + out->Print("public $name$(grpc::Channel channel) : base(channel)\n", "name", + GetClientClassName(service, lite_client)); + out->Print("{\n"); + out->Print("}\n"); + } out->Print( "/// Creates a new client for $servicename$ that uses a custom " "CallInvoker.\n" @@ -440,26 +451,30 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor* service) { "servicename", GetServiceClassName(service)); out->Print( "public $name$(grpc::CallInvoker callInvoker) : base(callInvoker)\n", - "name", GetClientClassName(service)); + "name", GetClientClassName(service, lite_client)); out->Print("{\n"); out->Print("}\n"); out->Print( "/// Protected parameterless constructor to allow creation" " of test doubles.\n"); out->Print("protected $name$() : base()\n", "name", - GetClientClassName(service)); + GetClientClassName(service, lite_client)); out->Print("{\n"); out->Print("}\n"); - out->Print( - "/// Protected constructor to allow creation of configured " - "clients.\n" - "/// The client configuration.\n"); - out->Print( - "protected $name$(ClientBaseConfiguration configuration)" - " : base(configuration)\n", - "name", GetClientClassName(service)); - out->Print("{\n"); - out->Print("}\n\n"); + if (!lite_client) { + out->Print( + "/// Protected constructor to allow creation of configured " + "clients.\n" + "/// The client " + "configuration.\n"); + out->Print( + "protected $name$(ClientBaseConfiguration configuration)" + " : base(configuration)\n", + "name", GetClientClassName(service, lite_client)); + out->Print("{\n"); + out->Print("}\n"); + } + out->Print("\n"); for (int i = 0; i < service->method_count(); i++) { const MethodDescriptor* method = service->method(i); @@ -577,19 +592,21 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor* service) { } // override NewInstance method - out->Print( - "/// Creates a new instance of client from given " - "ClientBaseConfiguration.\n"); - out->Print( - "protected override $name$ NewInstance(ClientBaseConfiguration " - "configuration)\n", - "name", GetClientClassName(service)); - out->Print("{\n"); - out->Indent(); - out->Print("return new $name$(configuration);\n", "name", - GetClientClassName(service)); - out->Outdent(); - out->Print("}\n"); + if (!lite_client) { + out->Print( + "/// Creates a new instance of client from given " + "ClientBaseConfiguration.\n"); + out->Print( + "protected override $name$ NewInstance(ClientBaseConfiguration " + "configuration)\n", + "name", GetClientClassName(service, lite_client)); + out->Print("{\n"); + out->Indent(); + out->Print("return new $name$(configuration);\n", "name", + GetClientClassName(service, lite_client)); + out->Outdent(); + out->Print("}\n"); + } out->Outdent(); out->Print("}\n"); @@ -670,8 +687,8 @@ void GenerateBindServiceWithBinderMethod(Printer* out, } void GenerateService(Printer* out, const ServiceDescriptor* service, - bool generate_client, bool generate_server, - bool internal_access) { + bool generate_client, bool generate_lite_client, + bool generate_server, bool internal_access) { GenerateDocCommentBody(out, service); out->Print("$access_level$ static partial class $classname$\n", "access_level", GetAccessLevel(internal_access), "classname", @@ -693,8 +710,12 @@ void GenerateService(Printer* out, const ServiceDescriptor* service, GenerateServerClass(out, service); } if (generate_client) { - GenerateClientStub(out, service); + GenerateClientStub(out, service, false); } + if (generate_lite_client) { + GenerateClientStub(out, service, true); + } + if (generate_server) { GenerateBindServiceMethod(out, service); GenerateBindServiceWithBinderMethod(out, service); @@ -707,7 +728,8 @@ void GenerateService(Printer* out, const ServiceDescriptor* service, } // anonymous namespace grpc::string GetServices(const FileDescriptor* file, bool generate_client, - bool generate_server, bool internal_access) { + bool generate_lite_client, bool generate_server, + bool internal_access) { grpc::string output; { // Scope the output stream so it closes and finalizes output to the string. @@ -748,8 +770,8 @@ grpc::string GetServices(const FileDescriptor* file, bool generate_client, out.Indent(); } for (int i = 0; i < file->service_count(); i++) { - GenerateService(&out, file->service(i), generate_client, generate_server, - internal_access); + GenerateService(&out, file->service(i), generate_client, + generate_lite_client, generate_server, internal_access); } if (file_namespace != "") { out.Outdent(); diff --git a/src/compiler/csharp_generator.h b/src/compiler/csharp_generator.h index fd36e11851b..842d136494c 100644 --- a/src/compiler/csharp_generator.h +++ b/src/compiler/csharp_generator.h @@ -26,8 +26,8 @@ namespace grpc_csharp_generator { grpc::string GetServices(const grpc::protobuf::FileDescriptor* file, - bool generate_client, bool generate_server, - bool internal_access); + bool generate_client, bool generate_lite_client, + bool generate_server, bool internal_access); } // namespace grpc_csharp_generator diff --git a/src/compiler/csharp_plugin.cc b/src/compiler/csharp_plugin.cc index 5f13aa6749e..a495f876792 100644 --- a/src/compiler/csharp_plugin.cc +++ b/src/compiler/csharp_plugin.cc @@ -38,10 +38,14 @@ class CSharpGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { bool generate_client = true; bool generate_server = true; + bool generate_lite_client = true; bool internal_access = false; for (size_t i = 0; i < options.size(); i++) { if (options[i].first == "no_client") { generate_client = false; + } else if (options[i].first == "no_lite_client") { + // TODO: better option + generate_lite_client = false; } else if (options[i].first == "no_server") { generate_server = false; } else if (options[i].first == "internal_access") { @@ -53,7 +57,8 @@ class CSharpGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { } grpc::string code = grpc_csharp_generator::GetServices( - file, generate_client, generate_server, internal_access); + file, generate_client, generate_lite_client, generate_server, + internal_access); if (code.size() == 0) { return true; // don't generate a file if there are no services } From 285cea16b3151ce7296e3d370d5e3683e80f8cb3 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 29 May 2019 10:14:52 -0700 Subject: [PATCH 0358/1555] Reorganize tests --- src/objective-c/tests/run_one_test.sh | 49 +++++++++++ tools/run_tests/run_tests.py | 116 +++++++++++++++----------- tools/run_tests/run_tests_matrix.py | 4 +- 3 files changed, 119 insertions(+), 50 deletions(-) create mode 100644 src/objective-c/tests/run_one_test.sh diff --git a/src/objective-c/tests/run_one_test.sh b/src/objective-c/tests/run_one_test.sh new file mode 100644 index 00000000000..af8a5b6351e --- /dev/null +++ b/src/objective-c/tests/run_one_test.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Don't run this script standalone. Instead, run from the repository root: +# ./tools/run_tests/run_tests.py -l objc + +set -ev + +cd $(dirname $0) + +BINDIR=../../../bins/$CONFIG + +[ -f $BINDIR/interop_server ] || { + echo >&2 "Can't find the test server. Make sure run_tests.py is making" \ + "interop_server before calling this script." + exit 1 +} +$BINDIR/interop_server --port=5050 --max_send_message_size=8388608 & +$BINDIR/interop_server --port=5051 --max_send_message_size=8388608 --use_tls & + +trap 'kill -9 `jobs -p` ; echo "EXIT TIME: $(date)"' EXIT + +set -o pipefail + +XCODEBUILD_FILTER='(^CompileC |^Ld |^ *[^ ]*clang |^ *cd |^ *export |^Libtool |^ *[^ ]*libtool |^CpHeader |^ *builtin-copy )' + +xcodebuild \ + -workspace Tests.xcworkspace \ + -scheme SCHEME \ + -destination name="iPhone 8" \ + HOST_PORT_LOCALSSL=localhost:5051 \ + HOST_PORT_LOCAL=localhost:5050 \ + HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ + test \ + | egrep -v "$XCODEBUILD_FILTER" \ + | egrep -v '^$' \ + | egrep -v "(GPBDictionary|GPBArray)" - diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index a7a9dbd48d0..d99bbf43ffa 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1048,54 +1048,74 @@ class ObjCLanguage(object): _check_compiler(self.args.compiler, ['default']) def test_specs(self): - return [ - self.config.job_spec( - ['src/objective-c/tests/run_tests.sh'], - timeout_seconds=60 * 60, - shortname='objc-tests', - cpu_cost=1e6, - environ=_FORCE_ENVIRON_FOR_WRAPPERS), - self.config.job_spec( - ['src/objective-c/tests/run_plugin_tests.sh'], - timeout_seconds=60 * 60, - shortname='objc-plugin-tests', - cpu_cost=1e6, - environ=_FORCE_ENVIRON_FOR_WRAPPERS), - self.config.job_spec( - ['src/objective-c/tests/build_one_example.sh'], - timeout_seconds=10 * 60, - shortname='objc-build-example-sample', - cpu_cost=1e6, - environ={ - 'SCHEME': 'Sample', - 'EXAMPLE_PATH': 'src/objective-c/examples/Sample' - }), - self.config.job_spec( - ['src/objective-c/tests/build_one_example.sh'], - timeout_seconds=10 * 60, - shortname='objc-build-example-sample-frameworks', - cpu_cost=1e6, - environ={ - 'SCHEME': 'Sample', - 'EXAMPLE_PATH': 'src/objective-c/examples/Sample', - 'FRAMEWORKS': 'YES' - }), - self.config.job_spec( - ['src/objective-c/tests/build_one_example.sh'], - timeout_seconds=10 * 60, - shortname='objc-build-example-switftsample', - cpu_cost=1e6, - environ={ - 'SCHEME': 'SwiftSample', - 'EXAMPLE_PATH': 'src/objective-c/examples/SwiftSample' - }), - self.config.job_spec( - ['test/core/iomgr/ios/CFStreamTests/run_tests.sh'], - timeout_seconds=20 * 60, - shortname='cfstream-tests', - cpu_cost=1e6, - environ=_FORCE_ENVIRON_FOR_WRAPPERS), - ] + out = [] + if self.config == 'dbg': + out += self.config.job_spec( + ['src/objective-c/tests/build_one_example.sh'], + timeout_seconds=10 * 60, + shortname='ios-buildtest-example-sample', + cpu_cost=1e6, + environ={ + 'SCHEME': 'Sample', + 'EXAMPLE_PATH': 'src/objective-c/examples/Sample' + }) + out += job_spec( + ['src/objective-c/tests/build_one_example.sh'], + timeout_seconds=10 * 60, + shortname='ios-buildtest-example-sample-frameworks', + cpu_cost=1e6, + environ={ + 'SCHEME': 'Sample', + 'EXAMPLE_PATH': 'src/objective-c/examples/Sample', + 'FRAMEWORKS': 'YES' + }) + out += self.config.job_spec( + ['src/objective-c/tests/build_one_example.sh'], + timeout_seconds=10 * 60, + shortname='ios-buildtest-example-switftsample', + cpu_cost=1e6, + environ={ + 'SCHEME': 'SwiftSample', + 'EXAMPLE_PATH': 'src/objective-c/examples/SwiftSample' + }) + out += self.config.job_spec( + ['src/objective-c/tests/run_plugin_tests.sh'], + timeout_seconds=60 * 60, + shortname='ios-test-plugintest', + cpu_cost=1e6, + environ=_FORCE_ENVIRON_FOR_WRAPPERS) + out += self.config.job_spec( + ['test/core/iomgr/ios/CFStreamTests/run_tests.sh'], + timeout_seconds=20 * 60, + shortname='ios-test-cfstream-tests', + cpu_cost=1e6, + environ=_FORCE_ENVIRON_FOR_WRAPPERS) + out += self.config.job_spec( + ['src/objective-c/tests/run_one_test.sh'], + timeout_seconds=60 * 60, + shortname='ios-test-unittests', + cpu_cost=1e6, + environ={SCHEME: 'UnitTests'}) + out += self.config.job_spec( + ['src/objective-c/tests/run_one_test.sh'], + timeout_seconds=60 * 60, + shortname='ios-test-interoptests', + cpu_cost=1e6, + environ={SCHEME: 'InteropTests'}) + out += self.config.job_spec( + ['src/objective-c/tests/run_one_test.sh'], + timeout_seconds=60 * 60, + shortname='ios-test-cronettests', + cpu_cost=1e6, + environ={SCHEME: 'CronetTests'}) + out += self.config.job_spec( + ['src/objective-c/tests/run_one_test.sh'], + timeout_seconds=60 * 60, + shortname='mac-test-basictests', + cpu_cost=1e6, + environ={SCHEME: 'MacTests'}) + + return sorted(out); def pre_build_steps(self): return [] diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index 785dff36eab..cfd67b99f34 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -246,10 +246,10 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): # supported on mac only. test_jobs += _generate_jobs( languages=['objc'], - configs=['dbg', 'opt'], + configs=['dbg'], platforms=['macos'], labels=['basictests', 'multilang'], - extra_args=extra_args, + extra_args=extra_args + os.getenv('GRPC_OBJC_TEST_EXTRA_ARGS', '.*'), inner_jobs=inner_jobs, timeout_seconds=_OBJC_RUNTESTS_TIMEOUT) From d835d1bb1f455fd150b10aa2125659b404697db2 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Wed, 29 May 2019 10:41:38 -0700 Subject: [PATCH 0359/1555] Surface exception from metadata credentails plugin methods --- src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi | 4 ++-- src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi | 4 ++-- src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi index af069acc287..05892b37324 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi @@ -26,9 +26,9 @@ cdef int _get_metadata( grpc_credentials_plugin_metadata_cb cb, void *user_data, grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], size_t *num_creds_md, grpc_status_code *status, - const char **error_details) with gil + const char **error_details) except * with gil -cdef void _destroy(void *state) with gil +cdef void _destroy(void *state) except * with gil cdef class MetadataPluginCallCredentials(CallCredentials): diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi index 52ca92f2e9f..2ec1c0bc427 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi @@ -42,7 +42,7 @@ cdef int _get_metadata( grpc_credentials_plugin_metadata_cb cb, void *user_data, grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], size_t *num_creds_md, grpc_status_code *status, - const char **error_details) with gil: + const char **error_details) except * with gil: cdef size_t metadata_count cdef grpc_metadata *c_metadata def callback(metadata, grpc_status_code status, bytes error_details): @@ -57,7 +57,7 @@ cdef int _get_metadata( return 0 # Asynchronous return -cdef void _destroy(void *state) with gil: +cdef void _destroy(void *state) except * with gil: cpython.Py_DECREF(state) grpc_shutdown_blocking() diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index 057d0776983..a674c34bb23 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -546,8 +546,8 @@ cdef extern from "grpc/grpc_security.h": grpc_credentials_plugin_metadata_cb cb, void *user_data, grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], size_t *num_creds_md, grpc_status_code *status, - const char **error_details) - void (*destroy)(void *state) + const char **error_details) except * + void (*destroy)(void *state) except * void *state const char *type From 1b8418b5460a63c331288cd475db7198cb2c494a Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 29 May 2019 13:37:48 -0400 Subject: [PATCH 0360/1555] only generate full or lite client, never both --- src/compiler/csharp_generator.cc | 38 ++++++++++++++------------------ src/compiler/csharp_generator.h | 4 ++-- src/compiler/csharp_plugin.cc | 12 +++++----- 3 files changed, 25 insertions(+), 29 deletions(-) diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc index 10737c5e8db..a45408a4cb8 100644 --- a/src/compiler/csharp_generator.cc +++ b/src/compiler/csharp_generator.cc @@ -176,9 +176,8 @@ std::string GetServiceClassName(const ServiceDescriptor* service) { return service->name(); } -std::string GetClientClassName(const ServiceDescriptor* service, - bool lite_client) { - return service->name() + (lite_client ? "LiteClient" : "Client"); +std::string GetClientClassName(const ServiceDescriptor* service) { + return service->name() + "Client"; } std::string GetServerClassName(const ServiceDescriptor* service) { @@ -421,12 +420,12 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor* service, out->Print("/// Client for $servicename$\n", "servicename", GetServiceClassName(service)); out->Print("public partial class $name$ : grpc::ClientBase<$name$>\n", - "name", GetClientClassName(service, lite_client)); + "name", GetClientClassName(service)); } else { out->Print("/// Lite client for $servicename$\n", "servicename", GetServiceClassName(service)); out->Print("public partial class $name$ : grpc::LiteClientBase\n", "name", - GetClientClassName(service, lite_client)); + GetClientClassName(service)); } out->Print("{\n"); out->Indent(); @@ -439,7 +438,7 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor* service, "calls.\n", "servicename", GetServiceClassName(service)); out->Print("public $name$(grpc::Channel channel) : base(channel)\n", "name", - GetClientClassName(service, lite_client)); + GetClientClassName(service)); out->Print("{\n"); out->Print("}\n"); } @@ -451,14 +450,14 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor* service, "servicename", GetServiceClassName(service)); out->Print( "public $name$(grpc::CallInvoker callInvoker) : base(callInvoker)\n", - "name", GetClientClassName(service, lite_client)); + "name", GetClientClassName(service)); out->Print("{\n"); out->Print("}\n"); out->Print( "/// Protected parameterless constructor to allow creation" " of test doubles.\n"); out->Print("protected $name$() : base()\n", "name", - GetClientClassName(service, lite_client)); + GetClientClassName(service)); out->Print("{\n"); out->Print("}\n"); if (!lite_client) { @@ -470,7 +469,7 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor* service, out->Print( "protected $name$(ClientBaseConfiguration configuration)" " : base(configuration)\n", - "name", GetClientClassName(service, lite_client)); + "name", GetClientClassName(service)); out->Print("{\n"); out->Print("}\n"); } @@ -599,11 +598,11 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor* service, out->Print( "protected override $name$ NewInstance(ClientBaseConfiguration " "configuration)\n", - "name", GetClientClassName(service, lite_client)); + "name", GetClientClassName(service)); out->Print("{\n"); out->Indent(); out->Print("return new $name$(configuration);\n", "name", - GetClientClassName(service, lite_client)); + GetClientClassName(service)); out->Outdent(); out->Print("}\n"); } @@ -687,8 +686,8 @@ void GenerateBindServiceWithBinderMethod(Printer* out, } void GenerateService(Printer* out, const ServiceDescriptor* service, - bool generate_client, bool generate_lite_client, - bool generate_server, bool internal_access) { + bool generate_client, bool generate_server, + bool internal_access, bool lite_client) { GenerateDocCommentBody(out, service); out->Print("$access_level$ static partial class $classname$\n", "access_level", GetAccessLevel(internal_access), "classname", @@ -710,10 +709,7 @@ void GenerateService(Printer* out, const ServiceDescriptor* service, GenerateServerClass(out, service); } if (generate_client) { - GenerateClientStub(out, service, false); - } - if (generate_lite_client) { - GenerateClientStub(out, service, true); + GenerateClientStub(out, service, lite_client); } if (generate_server) { @@ -728,8 +724,8 @@ void GenerateService(Printer* out, const ServiceDescriptor* service, } // anonymous namespace grpc::string GetServices(const FileDescriptor* file, bool generate_client, - bool generate_lite_client, bool generate_server, - bool internal_access) { + bool generate_server, bool internal_access, + bool lite_client) { grpc::string output; { // Scope the output stream so it closes and finalizes output to the string. @@ -770,8 +766,8 @@ grpc::string GetServices(const FileDescriptor* file, bool generate_client, out.Indent(); } for (int i = 0; i < file->service_count(); i++) { - GenerateService(&out, file->service(i), generate_client, - generate_lite_client, generate_server, internal_access); + GenerateService(&out, file->service(i), generate_client, generate_server, + internal_access, lite_client); } if (file_namespace != "") { out.Outdent(); diff --git a/src/compiler/csharp_generator.h b/src/compiler/csharp_generator.h index 842d136494c..d4c13c67363 100644 --- a/src/compiler/csharp_generator.h +++ b/src/compiler/csharp_generator.h @@ -26,8 +26,8 @@ namespace grpc_csharp_generator { grpc::string GetServices(const grpc::protobuf::FileDescriptor* file, - bool generate_client, bool generate_lite_client, - bool generate_server, bool internal_access); + bool generate_client, bool generate_server, + bool internal_access, bool lite_client); } // namespace grpc_csharp_generator diff --git a/src/compiler/csharp_plugin.cc b/src/compiler/csharp_plugin.cc index a495f876792..c503fd61ded 100644 --- a/src/compiler/csharp_plugin.cc +++ b/src/compiler/csharp_plugin.cc @@ -38,18 +38,19 @@ class CSharpGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { bool generate_client = true; bool generate_server = true; - bool generate_lite_client = true; bool internal_access = false; + bool lite_client = false; for (size_t i = 0; i < options.size(); i++) { if (options[i].first == "no_client") { generate_client = false; - } else if (options[i].first == "no_lite_client") { - // TODO: better option - generate_lite_client = false; } else if (options[i].first == "no_server") { generate_server = false; } else if (options[i].first == "internal_access") { internal_access = true; + } else if (options[i].first == "lite_client") { + // will only be used if generate_client is true. + // NOTE: experimental option, can be removed in future release + lite_client = true; } else { *error = "Unknown generator option: " + options[i].first; return false; @@ -57,8 +58,7 @@ class CSharpGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { } grpc::string code = grpc_csharp_generator::GetServices( - file, generate_client, generate_lite_client, generate_server, - internal_access); + file, generate_client, generate_server, internal_access, lite_client); if (code.size() == 0) { return true; // don't generate a file if there are no services } From 81a2c849abf822870667a54476f26c29ee867529 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 26 Apr 2019 07:38:40 -0400 Subject: [PATCH 0361/1555] regenerate C# protos --- .../Grpc.IntegrationTesting/EchoMessages.cs | 45 +++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/src/csharp/Grpc.IntegrationTesting/EchoMessages.cs b/src/csharp/Grpc.IntegrationTesting/EchoMessages.cs index e5af4a93e99..bbba68eeac1 100644 --- a/src/csharp/Grpc.IntegrationTesting/EchoMessages.cs +++ b/src/csharp/Grpc.IntegrationTesting/EchoMessages.cs @@ -28,7 +28,7 @@ namespace Grpc.Testing { "DGdycGMudGVzdGluZyIyCglEZWJ1Z0luZm8SFQoNc3RhY2tfZW50cmllcxgB", "IAMoCRIOCgZkZXRhaWwYAiABKAkiUAoLRXJyb3JTdGF0dXMSDAoEY29kZRgB", "IAEoBRIVCg1lcnJvcl9tZXNzYWdlGAIgASgJEhwKFGJpbmFyeV9lcnJvcl9k", - "ZXRhaWxzGAMgASgJIv8DCg1SZXF1ZXN0UGFyYW1zEhUKDWVjaG9fZGVhZGxp", + "ZXRhaWxzGAMgASgJIqAECg1SZXF1ZXN0UGFyYW1zEhUKDWVjaG9fZGVhZGxp", "bmUYASABKAgSHgoWY2xpZW50X2NhbmNlbF9hZnRlcl91cxgCIAEoBRIeChZz", "ZXJ2ZXJfY2FuY2VsX2FmdGVyX3VzGAMgASgFEhUKDWVjaG9fbWV0YWRhdGEY", "BCABKAgSGgoSY2hlY2tfYXV0aF9jb250ZXh0GAUgASgIEh8KF3Jlc3BvbnNl", @@ -39,18 +39,19 @@ namespace Grpc.Testing { "Zy5EZWJ1Z0luZm8SEgoKc2VydmVyX2RpZRgMIAEoCBIcChRiaW5hcnlfZXJy", "b3JfZGV0YWlscxgNIAEoCRIxCg5leHBlY3RlZF9lcnJvchgOIAEoCzIZLmdy", "cGMudGVzdGluZy5FcnJvclN0YXR1cxIXCg9zZXJ2ZXJfc2xlZXBfdXMYDyAB", - "KAUSGwoTYmFja2VuZF9jaGFubmVsX2lkeBgQIAEoBSJKCgtFY2hvUmVxdWVz", - "dBIPCgdtZXNzYWdlGAEgASgJEioKBXBhcmFtGAIgASgLMhsuZ3JwYy50ZXN0", - "aW5nLlJlcXVlc3RQYXJhbXMiRgoOUmVzcG9uc2VQYXJhbXMSGAoQcmVxdWVz", - "dF9kZWFkbGluZRgBIAEoAxIMCgRob3N0GAIgASgJEgwKBHBlZXIYAyABKAki", - "TAoMRWNob1Jlc3BvbnNlEg8KB21lc3NhZ2UYASABKAkSKwoFcGFyYW0YAiAB", - "KAsyHC5ncnBjLnRlc3RpbmcuUmVzcG9uc2VQYXJhbXNiBnByb3RvMw==")); + "KAUSGwoTYmFja2VuZF9jaGFubmVsX2lkeBgQIAEoBRIfChdlY2hvX21ldGFk", + "YXRhX2luaXRpYWxseRgRIAEoCCJKCgtFY2hvUmVxdWVzdBIPCgdtZXNzYWdl", + "GAEgASgJEioKBXBhcmFtGAIgASgLMhsuZ3JwYy50ZXN0aW5nLlJlcXVlc3RQ", + "YXJhbXMiRgoOUmVzcG9uc2VQYXJhbXMSGAoQcmVxdWVzdF9kZWFkbGluZRgB", + "IAEoAxIMCgRob3N0GAIgASgJEgwKBHBlZXIYAyABKAkiTAoMRWNob1Jlc3Bv", + "bnNlEg8KB21lc3NhZ2UYASABKAkSKwoFcGFyYW0YAiABKAsyHC5ncnBjLnRl", + "c3RpbmcuUmVzcG9uc2VQYXJhbXNCA/gBAWIGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.DebugInfo), global::Grpc.Testing.DebugInfo.Parser, new[]{ "StackEntries", "Detail" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ErrorStatus), global::Grpc.Testing.ErrorStatus.Parser, new[]{ "Code", "ErrorMessage", "BinaryErrorDetails" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.RequestParams), global::Grpc.Testing.RequestParams.Parser, new[]{ "EchoDeadline", "ClientCancelAfterUs", "ServerCancelAfterUs", "EchoMetadata", "CheckAuthContext", "ResponseMessageLength", "EchoPeer", "ExpectedClientIdentity", "SkipCancelledCheck", "ExpectedTransportSecurityType", "DebugInfo", "ServerDie", "BinaryErrorDetails", "ExpectedError", "ServerSleepUs", "BackendChannelIdx" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.RequestParams), global::Grpc.Testing.RequestParams.Parser, new[]{ "EchoDeadline", "ClientCancelAfterUs", "ServerCancelAfterUs", "EchoMetadata", "CheckAuthContext", "ResponseMessageLength", "EchoPeer", "ExpectedClientIdentity", "SkipCancelledCheck", "ExpectedTransportSecurityType", "DebugInfo", "ServerDie", "BinaryErrorDetails", "ExpectedError", "ServerSleepUs", "BackendChannelIdx", "EchoMetadataInitially" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.EchoRequest), global::Grpc.Testing.EchoRequest.Parser, new[]{ "Message", "Param" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ResponseParams), global::Grpc.Testing.ResponseParams.Parser, new[]{ "RequestDeadline", "Host", "Peer" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.EchoResponse), global::Grpc.Testing.EchoResponse.Parser, new[]{ "Message", "Param" }, null, null, null) @@ -441,6 +442,7 @@ namespace Grpc.Testing { expectedError_ = other.expectedError_ != null ? other.expectedError_.Clone() : null; serverSleepUs_ = other.serverSleepUs_; backendChannelIdx_ = other.backendChannelIdx_; + echoMetadataInitially_ = other.echoMetadataInitially_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -637,6 +639,17 @@ namespace Grpc.Testing { } } + /// Field number for the "echo_metadata_initially" field. + public const int EchoMetadataInitiallyFieldNumber = 17; + private bool echoMetadataInitially_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool EchoMetadataInitially { + get { return echoMetadataInitially_; } + set { + echoMetadataInitially_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as RequestParams); @@ -666,6 +679,7 @@ namespace Grpc.Testing { if (!object.Equals(ExpectedError, other.ExpectedError)) return false; if (ServerSleepUs != other.ServerSleepUs) return false; if (BackendChannelIdx != other.BackendChannelIdx) return false; + if (EchoMetadataInitially != other.EchoMetadataInitially) return false; return Equals(_unknownFields, other._unknownFields); } @@ -688,6 +702,7 @@ namespace Grpc.Testing { if (expectedError_ != null) hash ^= ExpectedError.GetHashCode(); if (ServerSleepUs != 0) hash ^= ServerSleepUs.GetHashCode(); if (BackendChannelIdx != 0) hash ^= BackendChannelIdx.GetHashCode(); + if (EchoMetadataInitially != false) hash ^= EchoMetadataInitially.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } @@ -765,6 +780,10 @@ namespace Grpc.Testing { output.WriteRawTag(128, 1); output.WriteInt32(BackendChannelIdx); } + if (EchoMetadataInitially != false) { + output.WriteRawTag(136, 1); + output.WriteBool(EchoMetadataInitially); + } if (_unknownFields != null) { _unknownFields.WriteTo(output); } @@ -821,6 +840,9 @@ namespace Grpc.Testing { if (BackendChannelIdx != 0) { size += 2 + pb::CodedOutputStream.ComputeInt32Size(BackendChannelIdx); } + if (EchoMetadataInitially != false) { + size += 2 + 1; + } if (_unknownFields != null) { size += _unknownFields.CalculateSize(); } @@ -886,6 +908,9 @@ namespace Grpc.Testing { if (other.BackendChannelIdx != 0) { BackendChannelIdx = other.BackendChannelIdx; } + if (other.EchoMetadataInitially != false) { + EchoMetadataInitially = other.EchoMetadataInitially; + } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } @@ -967,6 +992,10 @@ namespace Grpc.Testing { BackendChannelIdx = input.ReadInt32(); break; } + case 136: { + EchoMetadataInitially = input.ReadBool(); + break; + } } } } From 5ab4022fcf97ba78333689c96870da7c162d9610 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 29 May 2019 10:47:25 -0700 Subject: [PATCH 0362/1555] update kokoro cfg files --- ..._objc_dbg.cfg => grpc_basictests_objc.cfg} | 5 +++ .../macos/grpc_buildtests_objc.cfg | 36 +++++++++++++++++++ ...ts_objc_opt.cfg => grpc_mactests_objc.cfg} | 7 +++- 3 files changed, 47 insertions(+), 1 deletion(-) rename tools/internal_ci/macos/{grpc_basictests_objc_dbg.cfg => grpc_basictests_objc.cfg} (93%) create mode 100644 tools/internal_ci/macos/grpc_buildtests_objc.cfg rename tools/internal_ci/macos/{grpc_basictests_objc_opt.cfg => grpc_mactests_objc.cfg} (88%) diff --git a/tools/internal_ci/macos/grpc_basictests_objc_dbg.cfg b/tools/internal_ci/macos/grpc_basictests_objc.cfg similarity index 93% rename from tools/internal_ci/macos/grpc_basictests_objc_dbg.cfg rename to tools/internal_ci/macos/grpc_basictests_objc.cfg index 068961234be..6563fa69d02 100644 --- a/tools/internal_ci/macos/grpc_basictests_objc_dbg.cfg +++ b/tools/internal_ci/macos/grpc_basictests_objc.cfg @@ -29,3 +29,8 @@ env_vars { key: "RUN_TESTS_FLAGS" value: "-f basictests macos objc dbg --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results" } + +env_vars { + key: "GRPC_OBJC_TEST_EXTRA_ARGS" + value: "-r ios-test-.*" +} diff --git a/tools/internal_ci/macos/grpc_buildtests_objc.cfg b/tools/internal_ci/macos/grpc_buildtests_objc.cfg new file mode 100644 index 00000000000..d1a802eef5e --- /dev/null +++ b/tools/internal_ci/macos/grpc_buildtests_objc.cfg @@ -0,0 +1,36 @@ +# Copyright 2018 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" +timeout_mins: 120 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests macos objc dbg --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results" +} + +env_vars { + key: "GRPC_OBJC_TEST_EXTRA_ARGS" + value: "-r ios-buildtest-.*" +} diff --git a/tools/internal_ci/macos/grpc_basictests_objc_opt.cfg b/tools/internal_ci/macos/grpc_mactests_objc.cfg similarity index 88% rename from tools/internal_ci/macos/grpc_basictests_objc_opt.cfg rename to tools/internal_ci/macos/grpc_mactests_objc.cfg index 927fa50deb0..945bcb8c466 100644 --- a/tools/internal_ci/macos/grpc_basictests_objc_opt.cfg +++ b/tools/internal_ci/macos/grpc_mactests_objc.cfg @@ -27,5 +27,10 @@ action { env_vars { key: "RUN_TESTS_FLAGS" - value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results" + value: "-f basictests macos objc dbg --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results" +} + +env_vars { + key: "GRPC_OBJC_TEST_EXTRA_ARGS" + value: "-r mac-test-.*" } From b790c24e5c3b0135a16e472a7badb868334d7eb6 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 29 May 2019 11:20:36 -0700 Subject: [PATCH 0363/1555] Revert "Start supporting a callback-based RPC under lock" --- src/core/lib/surface/completion_queue.cc | 81 ++++++++----------- src/core/lib/surface/completion_queue.h | 3 +- src/core/lib/surface/server.cc | 2 +- test/core/surface/completion_queue_test.cc | 44 +--------- .../end2end/client_callback_end2end_test.cc | 28 ------- test/cpp/microbenchmarks/bm_cq.cc | 35 +------- .../callback_streaming_ping_pong.h | 2 +- 7 files changed, 40 insertions(+), 155 deletions(-) diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index d0ed1a9f673..e796071eedc 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -34,7 +34,6 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tls.h" #include "src/core/lib/gprpp/atomic.h" -#include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/profiling/timers.h" @@ -201,7 +200,7 @@ struct cq_vtable { bool (*begin_op)(grpc_completion_queue* cq, void* tag); void (*end_op)(grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage, bool internal); + void* done_arg, grpc_cq_completion* storage); grpc_event (*next)(grpc_completion_queue* cq, gpr_timespec deadline, void* reserved); grpc_event (*pluck)(grpc_completion_queue* cq, void* tag, @@ -355,20 +354,23 @@ static bool cq_begin_op_for_callback(grpc_completion_queue* cq, void* tag); // queue. The done argument is a callback that will be invoked when it is // safe to free up that storage. The storage MUST NOT be freed until the // done callback is invoked. -static void cq_end_op_for_next( - grpc_completion_queue* cq, void* tag, grpc_error* error, - void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage, bool internal); +static void cq_end_op_for_next(grpc_completion_queue* cq, void* tag, + grpc_error* error, + void (*done)(void* done_arg, + grpc_cq_completion* storage), + void* done_arg, grpc_cq_completion* storage); -static void cq_end_op_for_pluck( - grpc_completion_queue* cq, void* tag, grpc_error* error, - void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage, bool internal); +static void cq_end_op_for_pluck(grpc_completion_queue* cq, void* tag, + grpc_error* error, + void (*done)(void* done_arg, + grpc_cq_completion* storage), + void* done_arg, grpc_cq_completion* storage); -static void cq_end_op_for_callback( - grpc_completion_queue* cq, void* tag, grpc_error* error, - void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage, bool internal); +static void cq_end_op_for_callback(grpc_completion_queue* cq, void* tag, + grpc_error* error, + void (*done)(void* done_arg, + grpc_cq_completion* storage), + void* done_arg, grpc_cq_completion* storage); static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline, void* reserved); @@ -672,10 +674,11 @@ bool grpc_cq_begin_op(grpc_completion_queue* cq, void* tag) { /* Queue a GRPC_OP_COMPLETED operation to a completion queue (with a * completion * type of GRPC_CQ_NEXT) */ -static void cq_end_op_for_next( - grpc_completion_queue* cq, void* tag, grpc_error* error, - void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage, bool internal) { +static void cq_end_op_for_next(grpc_completion_queue* cq, void* tag, + grpc_error* error, + void (*done)(void* done_arg, + grpc_cq_completion* storage), + void* done_arg, grpc_cq_completion* storage) { GPR_TIMER_SCOPE("cq_end_op_for_next", 0); if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) || @@ -751,10 +754,11 @@ static void cq_end_op_for_next( /* Queue a GRPC_OP_COMPLETED operation to a completion queue (with a * completion * type of GRPC_CQ_PLUCK) */ -static void cq_end_op_for_pluck( - grpc_completion_queue* cq, void* tag, grpc_error* error, - void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage, bool internal) { +static void cq_end_op_for_pluck(grpc_completion_queue* cq, void* tag, + grpc_error* error, + void (*done)(void* done_arg, + grpc_cq_completion* storage), + void* done_arg, grpc_cq_completion* storage) { GPR_TIMER_SCOPE("cq_end_op_for_pluck", 0); cq_pluck_data* cqd = static_cast DATA_FROM_CQ(cq); @@ -817,19 +821,15 @@ static void cq_end_op_for_pluck( GRPC_ERROR_UNREF(error); } -static void functor_callback(void* arg, grpc_error* error) { - auto* functor = static_cast(arg); - functor->functor_run(functor, error == GRPC_ERROR_NONE); -} - /* Complete an event on a completion queue of type GRPC_CQ_CALLBACK */ static void cq_end_op_for_callback( grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage, bool internal) { + grpc_cq_completion* storage) { GPR_TIMER_SCOPE("cq_end_op_for_callback", 0); cq_callback_data* cqd = static_cast DATA_FROM_CQ(cq); + bool is_success = (error == GRPC_ERROR_NONE); if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) || (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) && @@ -856,25 +856,16 @@ static void cq_end_op_for_callback( cq_finish_shutdown_callback(cq); } - auto* functor = static_cast(tag); - if (internal) { - grpc_core::ApplicationCallbackExecCtx::Enqueue(functor, - (error == GRPC_ERROR_NONE)); - } else { - GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_CREATE( - functor_callback, functor, - grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), - GRPC_ERROR_REF(error)); - } GRPC_ERROR_UNREF(error); + + auto* functor = static_cast(tag); + grpc_core::ApplicationCallbackExecCtx::Enqueue(functor, is_success); } void grpc_cq_end_op(grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage, - bool internal) { - cq->vtable->end_op(cq, tag, error, done, done_arg, storage, internal); + void* done_arg, grpc_cq_completion* storage) { + cq->vtable->end_op(cq, tag, error, done, done_arg, storage); } typedef struct { @@ -1352,11 +1343,7 @@ static void cq_finish_shutdown_callback(grpc_completion_queue* cq) { GPR_ASSERT(cqd->shutdown_called); cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done); - GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_CREATE( - functor_callback, callback, - grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), - GRPC_ERROR_NONE); + grpc_core::ApplicationCallbackExecCtx::Enqueue(callback, true); } static void cq_shutdown_callback(grpc_completion_queue* cq) { diff --git a/src/core/lib/surface/completion_queue.h b/src/core/lib/surface/completion_queue.h index 3ba9fbb8765..d60fe6d6efe 100644 --- a/src/core/lib/surface/completion_queue.h +++ b/src/core/lib/surface/completion_queue.h @@ -77,8 +77,7 @@ bool grpc_cq_begin_op(grpc_completion_queue* cc, void* tag); grpc_cq_begin_op */ void grpc_cq_end_op(grpc_completion_queue* cc, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage, - bool internal = false); + void* done_arg, grpc_cq_completion* storage); grpc_pollset* grpc_cq_pollset(grpc_completion_queue* cc); diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 44de0cd42dd..5ecd5662c2c 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -513,7 +513,7 @@ static void publish_call(grpc_server* server, call_data* calld, size_t cq_idx, } grpc_cq_end_op(calld->cq_new, rc->tag, GRPC_ERROR_NONE, done_request_event, - rc, &rc->completion, true); + rc, &rc->completion); } static void publish_new_rpc(void* arg, grpc_error* error) { diff --git a/test/core/surface/completion_queue_test.cc b/test/core/surface/completion_queue_test.cc index 4a33b934f43..7c3630eaf18 100644 --- a/test/core/surface/completion_queue_test.cc +++ b/test/core/surface/completion_queue_test.cc @@ -23,7 +23,6 @@ #include #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/memory.h" -#include "src/core/lib/gprpp/sync.h" #include "src/core/lib/iomgr/iomgr.h" #include "test/core/util/test_config.h" @@ -360,19 +359,12 @@ static void test_pluck_after_shutdown(void) { static void test_callback(void) { grpc_completion_queue* cc; - static void* tags[128]; + void* tags[128]; grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)]; grpc_cq_polling_type polling_types[] = { GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; grpc_completion_queue_attributes attr; unsigned i; - static gpr_mu mu, shutdown_mu; - static gpr_cv cv, shutdown_cv; - static int cb_counter; - gpr_mu_init(&mu); - gpr_mu_init(&shutdown_mu); - gpr_cv_init(&cv); - gpr_cv_init(&shutdown_cv); LOG_TEST("test_callback"); @@ -384,11 +376,7 @@ static void test_callback(void) { } ~ShutdownCallback() {} static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { - gpr_mu_lock(&shutdown_mu); *static_cast(cb)->done_ = static_cast(ok); - // Signal when the shutdown callback is completed. - gpr_cv_signal(&shutdown_cv); - gpr_mu_unlock(&shutdown_mu); } private: @@ -403,9 +391,9 @@ static void test_callback(void) { for (size_t pidx = 0; pidx < GPR_ARRAY_SIZE(polling_types); pidx++) { int sumtags = 0; int counter = 0; - cb_counter = 0; { // reset exec_ctx types + grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; attr.cq_polling_type = polling_types[pidx]; cc = grpc_completion_queue_create( @@ -421,13 +409,7 @@ static void test_callback(void) { int ok) { GPR_ASSERT(static_cast(ok)); auto* callback = static_cast(cb); - gpr_mu_lock(&mu); - cb_counter++; *callback->counter_ += callback->tag_; - if (cb_counter == GPR_ARRAY_SIZE(tags)) { - gpr_cv_signal(&cv); - } - gpr_mu_unlock(&mu); grpc_core::Delete(callback); }; @@ -447,34 +429,12 @@ static void test_callback(void) { nullptr, &completions[i]); } - gpr_mu_lock(&mu); - while (cb_counter != GPR_ARRAY_SIZE(tags)) { - // Wait for all the callbacks to complete. - gpr_cv_wait(&cv, &mu, gpr_inf_future(GPR_CLOCK_REALTIME)); - } - gpr_mu_unlock(&mu); - shutdown_and_destroy(cc); - - gpr_mu_lock(&shutdown_mu); - while (!got_shutdown) { - // Wait for the shutdown callback to complete. - gpr_cv_wait(&shutdown_cv, &shutdown_mu, - gpr_inf_future(GPR_CLOCK_REALTIME)); - } - gpr_mu_unlock(&shutdown_mu); } - - // Run the assertions to check if the test ran successfully. GPR_ASSERT(sumtags == counter); GPR_ASSERT(got_shutdown); got_shutdown = false; } - - gpr_cv_destroy(&cv); - gpr_cv_destroy(&shutdown_cv); - gpr_mu_destroy(&mu); - gpr_mu_destroy(&shutdown_mu); } struct thread_state { diff --git a/test/cpp/end2end/client_callback_end2end_test.cc b/test/cpp/end2end/client_callback_end2end_test.cc index 8cf6def1073..a154324216b 100644 --- a/test/cpp/end2end/client_callback_end2end_test.cc +++ b/test/cpp/end2end/client_callback_end2end_test.cc @@ -374,34 +374,6 @@ TEST_P(ClientCallbackEnd2endTest, SimpleRpc) { SendRpcs(1, false); } -TEST_P(ClientCallbackEnd2endTest, SimpleRpcUnderLock) { - MAYBE_SKIP_TEST; - ResetStub(); - std::mutex mu; - std::condition_variable cv; - bool done = false; - EchoRequest request; - request.set_message("Hello locked world."); - EchoResponse response; - ClientContext cli_ctx; - { - std::lock_guard l(mu); - stub_->experimental_async()->Echo( - &cli_ctx, &request, &response, - [&mu, &cv, &done, &request, &response](Status s) { - std::lock_guard l(mu); - EXPECT_TRUE(s.ok()); - EXPECT_EQ(request.message(), response.message()); - done = true; - cv.notify_one(); - }); - } - std::unique_lock l(mu); - while (!done) { - cv.wait(l); - } -} - TEST_P(ClientCallbackEnd2endTest, SequentialRpcs) { MAYBE_SKIP_TEST; ResetStub(); diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index edbff9c2be3..50eb9454fbe 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -150,9 +150,6 @@ static void shutdown_and_destroy(grpc_completion_queue* cc) { grpc_completion_queue_destroy(cc); } -static gpr_mu shutdown_mu, mu; -static gpr_cv shutdown_cv, cv; - // Tag completion queue iterate times class TagCallback : public grpc_experimental_completion_queue_functor { public: @@ -161,11 +158,8 @@ class TagCallback : public grpc_experimental_completion_queue_functor { } ~TagCallback() {} static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { - gpr_mu_lock(&mu); GPR_ASSERT(static_cast(ok)); *static_cast(cb)->iter_ += 1; - gpr_cv_signal(&cv); - gpr_mu_unlock(&mu); }; private: @@ -180,10 +174,7 @@ class ShutdownCallback : public grpc_experimental_completion_queue_functor { } ~ShutdownCallback() {} static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { - gpr_mu_lock(&shutdown_mu); *static_cast(cb)->done_ = static_cast(ok); - gpr_cv_signal(&shutdown_cv); - gpr_mu_unlock(&shutdown_mu); } private: @@ -192,12 +183,8 @@ class ShutdownCallback : public grpc_experimental_completion_queue_functor { static void BM_Callback_CQ_Pass1Core(benchmark::State& state) { TrackCounters track_counters; - int iteration = 0, current_iterations = 0; + int iteration = 0; TagCallback tag_cb(&iteration); - gpr_mu_init(&mu); - gpr_cv_init(&cv); - gpr_mu_init(&shutdown_mu); - gpr_cv_init(&shutdown_cv); bool got_shutdown = false; ShutdownCallback shutdown_cb(&got_shutdown); grpc_completion_queue* cc = @@ -211,29 +198,9 @@ static void BM_Callback_CQ_Pass1Core(benchmark::State& state) { nullptr, &completion); } shutdown_and_destroy(cc); - - gpr_mu_lock(&mu); - current_iterations = static_cast(state.iterations()); - while (current_iterations != iteration) { - // Wait for all the callbacks to complete. - gpr_cv_wait(&cv, &mu, gpr_inf_future(GPR_CLOCK_REALTIME)); - } - gpr_mu_unlock(&mu); - - gpr_mu_lock(&shutdown_mu); - while (!got_shutdown) { - // Wait for the shutdown callback to complete. - gpr_cv_wait(&shutdown_cv, &shutdown_mu, gpr_inf_future(GPR_CLOCK_REALTIME)); - } - gpr_mu_unlock(&shutdown_mu); - GPR_ASSERT(got_shutdown); GPR_ASSERT(iteration == static_cast(state.iterations())); track_counters.Finish(state); - gpr_cv_destroy(&cv); - gpr_mu_destroy(&mu); - gpr_cv_destroy(&shutdown_cv); - gpr_mu_destroy(&shutdown_mu); } BENCHMARK(BM_Callback_CQ_Pass1Core); diff --git a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h index 0d27e0efa50..9fb86bd8299 100644 --- a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h @@ -115,7 +115,7 @@ class BidiClient int msgs_size_; std::mutex mu; std::condition_variable cv; - bool done = false; + bool done; }; template From 28ccd61cf5ebab2b48301b51b98efb7743f39246 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 29 May 2019 12:21:15 -0700 Subject: [PATCH 0364/1555] Use SubchannelInterface to hide implementation from LB policy API. --- BUILD | 1 + BUILD.gn | 1 + build.yaml | 1 + gRPC-C++.podspec | 1 + gRPC-Core.podspec | 2 + grpc.gemspec | 1 + package.xml | 1 + .../filters/client_channel/client_channel.cc | 123 ++++++++++++++---- .../ext/filters/client_channel/lb_policy.h | 8 +- .../client_channel/lb_policy/grpclb/grpclb.cc | 6 +- .../lb_policy/pick_first/pick_first.cc | 10 +- .../lb_policy/round_robin/round_robin.cc | 7 +- .../lb_policy/subchannel_list.h | 91 ++++++------- .../client_channel/lb_policy/xds/xds.cc | 11 +- .../client_channel/resolving_lb_policy.cc | 5 +- .../client_channel/resolving_lb_policy.h | 3 +- .../ext/filters/client_channel/subchannel.cc | 26 +--- .../ext/filters/client_channel/subchannel.h | 46 ++----- .../client_channel/subchannel_interface.h | 109 ++++++++++++++++ test/core/util/test_lb_policies.cc | 3 +- tools/doxygen/Doxyfile.core.internal | 1 + .../generated/sources_and_headers.json | 2 + 22 files changed, 302 insertions(+), 157 deletions(-) create mode 100644 src/core/ext/filters/client_channel/subchannel_interface.h diff --git a/BUILD b/BUILD index 63744760bfd..e0827d46cb1 100644 --- a/BUILD +++ b/BUILD @@ -1143,6 +1143,7 @@ grpc_cc_library( "src/core/ext/filters/client_channel/server_address.h", "src/core/ext/filters/client_channel/service_config.h", "src/core/ext/filters/client_channel/subchannel.h", + "src/core/ext/filters/client_channel/subchannel_interface.h", "src/core/ext/filters/client_channel/subchannel_pool_interface.h", ], language = "c++", diff --git a/BUILD.gn b/BUILD.gn index 14e5c3f0b5f..258cdc9f873 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -345,6 +345,7 @@ config("grpc_config") { "src/core/ext/filters/client_channel/service_config.h", "src/core/ext/filters/client_channel/subchannel.cc", "src/core/ext/filters/client_channel/subchannel.h", + "src/core/ext/filters/client_channel/subchannel_interface.h", "src/core/ext/filters/client_channel/subchannel_pool_interface.cc", "src/core/ext/filters/client_channel/subchannel_pool_interface.h", "src/core/ext/filters/deadline/deadline_filter.cc", diff --git a/build.yaml b/build.yaml index 529afecbb33..5c085f18787 100644 --- a/build.yaml +++ b/build.yaml @@ -595,6 +595,7 @@ filegroups: - src/core/ext/filters/client_channel/server_address.h - src/core/ext/filters/client_channel/service_config.h - src/core/ext/filters/client_channel/subchannel.h + - src/core/ext/filters/client_channel/subchannel_interface.h - src/core/ext/filters/client_channel/subchannel_pool_interface.h src: - src/core/ext/filters/client_channel/backup_poller.cc diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 0ce31532629..3b463cf7b90 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -399,6 +399,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/server_address.h', 'src/core/ext/filters/client_channel/service_config.h', 'src/core/ext/filters/client_channel/subchannel.h', + 'src/core/ext/filters/client_channel/subchannel_interface.h', 'src/core/ext/filters/client_channel/subchannel_pool_interface.h', 'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/ext/filters/client_channel/health/health.pb.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 8ad00aad096..85add8fb7a2 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -371,6 +371,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/server_address.h', 'src/core/ext/filters/client_channel/service_config.h', 'src/core/ext/filters/client_channel/subchannel.h', + 'src/core/ext/filters/client_channel/subchannel_interface.h', 'src/core/ext/filters/client_channel/subchannel_pool_interface.h', 'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/ext/filters/client_channel/health/health.pb.h', @@ -1023,6 +1024,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/server_address.h', 'src/core/ext/filters/client_channel/service_config.h', 'src/core/ext/filters/client_channel/subchannel.h', + 'src/core/ext/filters/client_channel/subchannel_interface.h', 'src/core/ext/filters/client_channel/subchannel_pool_interface.h', 'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/ext/filters/client_channel/health/health.pb.h', diff --git a/grpc.gemspec b/grpc.gemspec index 0bbf10fb361..e9d215bf10f 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -305,6 +305,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/server_address.h ) s.files += %w( src/core/ext/filters/client_channel/service_config.h ) s.files += %w( src/core/ext/filters/client_channel/subchannel.h ) + s.files += %w( src/core/ext/filters/client_channel/subchannel_interface.h ) s.files += %w( src/core/ext/filters/client_channel/subchannel_pool_interface.h ) s.files += %w( src/core/ext/filters/deadline/deadline_filter.h ) s.files += %w( src/core/ext/filters/client_channel/health/health.pb.h ) diff --git a/package.xml b/package.xml index eca74c8f167..fd712698a62 100644 --- a/package.xml +++ b/package.xml @@ -310,6 +310,7 @@ + diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 5717d3e66d2..6b6045c98f6 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -51,6 +51,7 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/gprpp/manual_constructor.h" +#include "src/core/lib/gprpp/map.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/iomgr.h" @@ -174,6 +175,7 @@ class ChannelData { private: class ConnectivityStateAndPickerSetter; class ServiceConfigSetter; + class GrpcSubchannel; class ClientChannelControlHelper; class ExternalConnectivityWatcher { @@ -221,7 +223,7 @@ class ChannelData { ~ChannelData(); static bool ProcessResolverResultLocked( - void* arg, Resolver::Result* result, const char** lb_policy_name, + void* arg, const Resolver::Result& result, const char** lb_policy_name, RefCountedPtr* lb_policy_config, grpc_error** service_config_error); @@ -270,6 +272,7 @@ class ChannelData { OrphanablePtr resolving_lb_policy_; grpc_connectivity_state_tracker state_tracker_; ExternalConnectivityWatcher::WatcherList external_connectivity_watcher_list_; + UniquePtr health_check_service_name_; RefCountedPtr saved_service_config_; bool received_first_resolver_result_ = false; @@ -954,6 +957,65 @@ void ChannelData::ExternalConnectivityWatcher::WatchConnectivityStateLocked( &self->chand_->state_tracker_, self->state_, &self->my_closure_); } +// +// ChannelData::GrpcSubchannel +// + +// This class is a wrapper for Subchannel that hides details of the +// channel's implementation (such as the health check service name) from +// the LB policy API. +// +// Note that no synchronization is needed here, because even if the +// underlying subchannel is shared between channels, this wrapper will only +// be used within one channel, so it will always be synchronized by the +// control plane combiner. +class ChannelData::GrpcSubchannel : public SubchannelInterface { + public: + GrpcSubchannel(Subchannel* subchannel, + UniquePtr health_check_service_name) + : subchannel_(subchannel), + health_check_service_name_(std::move(health_check_service_name)) {} + + ~GrpcSubchannel() { GRPC_SUBCHANNEL_UNREF(subchannel_, "unref from LB"); } + + grpc_connectivity_state CheckConnectivityState( + RefCountedPtr* connected_subchannel) + override { + RefCountedPtr tmp; + auto retval = subchannel_->CheckConnectivityState( + health_check_service_name_.get(), &tmp); + *connected_subchannel = std::move(tmp); + return retval; + } + + void WatchConnectivityState( + grpc_connectivity_state initial_state, + UniquePtr watcher) override { + subchannel_->WatchConnectivityState( + initial_state, + UniquePtr(gpr_strdup(health_check_service_name_.get())), + std::move(watcher)); + } + + void CancelConnectivityStateWatch( + ConnectivityStateWatcher* watcher) override { + subchannel_->CancelConnectivityStateWatch(health_check_service_name_.get(), + watcher); + } + + void AttemptToConnect() override { subchannel_->AttemptToConnect(); } + + channelz::SubchannelNode* channelz_node() override { + return subchannel_->channelz_node(); + } + + void ResetBackoff() override { subchannel_->ResetBackoff(); } + + private: + Subchannel* subchannel_; + UniquePtr health_check_service_name_; +}; + // // ChannelData::ClientChannelControlHelper // @@ -970,15 +1032,26 @@ class ChannelData::ClientChannelControlHelper "ClientChannelControlHelper"); } - Subchannel* CreateSubchannel(const grpc_channel_args& args) override { + RefCountedPtr CreateSubchannel( + const grpc_channel_args& args) override { + bool inhibit_health_checking = grpc_channel_arg_get_bool( + grpc_channel_args_find(&args, GRPC_ARG_INHIBIT_HEALTH_CHECKING), false); + UniquePtr health_check_service_name; + if (!inhibit_health_checking) { + health_check_service_name.reset( + gpr_strdup(chand_->health_check_service_name_.get())); + } + static const char* args_to_remove[] = {GRPC_ARG_INHIBIT_HEALTH_CHECKING}; grpc_arg arg = SubchannelPoolInterface::CreateChannelArg( chand_->subchannel_pool_.get()); - grpc_channel_args* new_args = - grpc_channel_args_copy_and_add(&args, &arg, 1); + grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove( + &args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove), &arg, 1); Subchannel* subchannel = chand_->client_channel_factory_->CreateSubchannel(new_args); grpc_channel_args_destroy(new_args); - return subchannel; + if (subchannel == nullptr) return nullptr; + return MakeRefCounted(subchannel, + std::move(health_check_service_name)); } grpc_channel* CreateChannel(const char* target, @@ -1211,14 +1284,14 @@ void ChannelData::ProcessLbPolicy( // Synchronous callback from ResolvingLoadBalancingPolicy to process a // resolver result update. bool ChannelData::ProcessResolverResultLocked( - void* arg, Resolver::Result* result, const char** lb_policy_name, + void* arg, const Resolver::Result& result, const char** lb_policy_name, RefCountedPtr* lb_policy_config, grpc_error** service_config_error) { ChannelData* chand = static_cast(arg); RefCountedPtr service_config; // If resolver did not return a service config or returned an invalid service // config, we need a fallback service config. - if (result->service_config_error != GRPC_ERROR_NONE) { + if (result.service_config_error != GRPC_ERROR_NONE) { // If the service config was invalid, then fallback to the saved service // config. If there is no saved config either, use the default service // config. @@ -1239,7 +1312,7 @@ bool ChannelData::ProcessResolverResultLocked( } service_config = chand->default_service_config_; } - } else if (result->service_config == nullptr) { + } else if (result.service_config == nullptr) { if (chand->default_service_config_ != nullptr) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { gpr_log(GPR_INFO, @@ -1250,11 +1323,11 @@ bool ChannelData::ProcessResolverResultLocked( service_config = chand->default_service_config_; } } else { - service_config = result->service_config; + service_config = result.service_config; } - *service_config_error = GRPC_ERROR_REF(result->service_config_error); + *service_config_error = GRPC_ERROR_REF(result.service_config_error); if (service_config == nullptr && - result->service_config_error != GRPC_ERROR_NONE) { + result.service_config_error != GRPC_ERROR_NONE) { return false; } // Process service config. @@ -1267,19 +1340,6 @@ bool ChannelData::ProcessResolverResultLocked( service_config->GetGlobalParsedConfig( internal::ClientChannelServiceConfigParser::ParserIndex())); } - // TODO(roth): Eliminate this hack as part of hiding health check - // service name from LB policy API. As part of this, change the API - // for this function to pass in result as a const reference. - if (parsed_service_config != nullptr && - parsed_service_config->health_check_service_name() != nullptr) { - grpc_arg new_arg = grpc_channel_arg_string_create( - const_cast("grpc.temp.health_check"), - const_cast(parsed_service_config->health_check_service_name())); - grpc_channel_args* new_args = - grpc_channel_args_copy_and_add(result->args, &new_arg, 1); - grpc_channel_args_destroy(result->args); - result->args = new_args; - } // Check if the config has changed. const bool service_config_changed = ((service_config == nullptr) != @@ -1296,6 +1356,14 @@ bool ChannelData::ProcessResolverResultLocked( "chand=%p: resolver returned updated service config: \"%s\"", chand, service_config_json.get()); } + // Save health check service name. + if (service_config != nullptr) { + chand->health_check_service_name_.reset( + gpr_strdup(parsed_service_config->health_check_service_name())); + } else { + chand->health_check_service_name_.reset(); + } + // Save service config. chand->saved_service_config_ = std::move(service_config); } // We want to set the service config at least once. This should not really be @@ -1314,7 +1382,7 @@ bool ChannelData::ProcessResolverResultLocked( chand->saved_service_config_); } UniquePtr processed_lb_policy_name; - chand->ProcessLbPolicy(*result, parsed_service_config, + chand->ProcessLbPolicy(result, parsed_service_config, &processed_lb_policy_name, lb_policy_config); // Swap out the data used by GetChannelInfo(). { @@ -1336,8 +1404,9 @@ grpc_error* ChannelData::DoPingLocked(grpc_transport_op* op) { LoadBalancingPolicy::PickResult result = picker_->Pick(LoadBalancingPolicy::PickArgs()); if (result.connected_subchannel != nullptr) { - result.connected_subchannel->Ping(op->send_ping.on_initiate, - op->send_ping.on_ack); + ConnectedSubchannel* connected_subchannel = + static_cast(result.connected_subchannel.get()); + connected_subchannel->Ping(op->send_ping.on_initiate, op->send_ping.on_ack); } else { if (result.error == GRPC_ERROR_NONE) { result.error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h index 5920254a9ef..2cadcc31998 100644 --- a/src/core/ext/filters/client_channel/lb_policy.h +++ b/src/core/ext/filters/client_channel/lb_policy.h @@ -24,7 +24,7 @@ #include "src/core/ext/filters/client_channel/client_channel_channelz.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/ext/filters/client_channel/service_config.h" -#include "src/core/ext/filters/client_channel/subchannel.h" +#include "src/core/ext/filters/client_channel/subchannel_interface.h" #include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" @@ -128,7 +128,7 @@ class LoadBalancingPolicy : public InternallyRefCounted { /// Used only if type is PICK_COMPLETE. Will be set to the selected /// subchannel, or nullptr if the LB policy decides to drop the call. - RefCountedPtr connected_subchannel; + RefCountedPtr connected_subchannel; /// Used only if type is PICK_TRANSIENT_FAILURE. /// Error to be set when returning a transient failure. @@ -184,8 +184,8 @@ class LoadBalancingPolicy : public InternallyRefCounted { virtual ~ChannelControlHelper() = default; /// Creates a new subchannel with the specified channel args. - virtual Subchannel* CreateSubchannel(const grpc_channel_args& args) - GRPC_ABSTRACT; + virtual RefCountedPtr CreateSubchannel( + const grpc_channel_args& args) GRPC_ABSTRACT; /// Creates a channel with the specified target and channel args. /// This can be used in cases where the LB policy needs to create a diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 2c652e4c6e6..a3a2a44eb0e 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -293,7 +293,8 @@ class GrpcLb : public LoadBalancingPolicy { explicit Helper(RefCountedPtr parent) : parent_(std::move(parent)) {} - Subchannel* CreateSubchannel(const grpc_channel_args& args) override; + RefCountedPtr CreateSubchannel( + const grpc_channel_args& args) override; grpc_channel* CreateChannel(const char* target, const grpc_channel_args& args) override; void UpdateState(grpc_connectivity_state state, @@ -620,7 +621,8 @@ bool GrpcLb::Helper::CalledByCurrentChild() const { return child_ == parent_->child_policy_.get(); } -Subchannel* GrpcLb::Helper::CreateSubchannel(const grpc_channel_args& args) { +RefCountedPtr GrpcLb::Helper::CreateSubchannel( + const grpc_channel_args& args) { if (parent_->shutting_down_ || (!CalledByPendingChild() && !CalledByCurrentChild())) { return nullptr; diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index 1b0dd230b49..4680117fede 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -68,8 +68,9 @@ class PickFirst : public LoadBalancingPolicy { PickFirstSubchannelData( SubchannelList* subchannel_list, - const ServerAddress& address, Subchannel* subchannel) - : SubchannelData(subchannel_list, address, subchannel) {} + const ServerAddress& address, + RefCountedPtr subchannel) + : SubchannelData(subchannel_list, address, std::move(subchannel)) {} void ProcessConnectivityChangeLocked( grpc_connectivity_state connectivity_state) override; @@ -112,7 +113,8 @@ class PickFirst : public LoadBalancingPolicy { class Picker : public SubchannelPicker { public: - explicit Picker(RefCountedPtr connected_subchannel) + explicit Picker( + RefCountedPtr connected_subchannel) : connected_subchannel_(std::move(connected_subchannel)) {} PickResult Pick(PickArgs args) override { @@ -123,7 +125,7 @@ class PickFirst : public LoadBalancingPolicy { } private: - RefCountedPtr connected_subchannel_; + RefCountedPtr connected_subchannel_; }; // Helper class to ensure that any function that modifies the child refs diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc index 0b9915de28e..3b8ec4f2872 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc @@ -83,8 +83,9 @@ class RoundRobin : public LoadBalancingPolicy { RoundRobinSubchannelData( SubchannelList* subchannel_list, - const ServerAddress& address, Subchannel* subchannel) - : SubchannelData(subchannel_list, address, subchannel) {} + const ServerAddress& address, + RefCountedPtr subchannel) + : SubchannelData(subchannel_list, address, std::move(subchannel)) {} grpc_connectivity_state connectivity_state() const { return last_connectivity_state_; @@ -156,7 +157,7 @@ class RoundRobin : public LoadBalancingPolicy { RoundRobin* parent_; size_t last_picked_index_; - InlinedVector, 10> subchannels_; + InlinedVector, 10> subchannels_; }; // Helper class to ensure that any function that modifies the child refs diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h index 93b4bbd369a..8929bc4ab1e 100644 --- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h @@ -27,7 +27,10 @@ #include "src/core/ext/filters/client_channel/lb_policy_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" +// TODO(roth): Should not need the include of subchannel.h here, since +// that implementation should be hidden from the LB policy API. #include "src/core/ext/filters/client_channel/subchannel.h" +#include "src/core/ext/filters/client_channel/subchannel_interface.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/abstract.h" @@ -88,11 +91,11 @@ class SubchannelData { } // Returns a pointer to the subchannel. - Subchannel* subchannel() const { return subchannel_; } + SubchannelInterface* subchannel() const { return subchannel_.get(); } // Returns the connected subchannel. Will be null if the subchannel // is not connected. - ConnectedSubchannel* connected_subchannel() const { + ConnectedSubchannelInterface* connected_subchannel() const { return connected_subchannel_.get(); } @@ -102,8 +105,8 @@ class SubchannelData { // calling CancelConnectivityWatchLocked()). grpc_connectivity_state CheckConnectivityStateLocked() { GPR_ASSERT(pending_watcher_ == nullptr); - connectivity_state_ = subchannel()->CheckConnectivityState( - subchannel_list_->health_check_service_name(), &connected_subchannel_); + connectivity_state_ = + subchannel()->CheckConnectivityState(&connected_subchannel_); return connectivity_state_; } @@ -128,7 +131,8 @@ class SubchannelData { protected: SubchannelData( SubchannelList* subchannel_list, - const ServerAddress& address, Subchannel* subchannel); + const ServerAddress& address, + RefCountedPtr subchannel); virtual ~SubchannelData(); @@ -140,7 +144,7 @@ class SubchannelData { private: // Watcher for subchannel connectivity state. - class Watcher : public Subchannel::ConnectivityStateWatcher { + class Watcher : public SubchannelInterface::ConnectivityStateWatcher { public: Watcher( SubchannelData* subchannel_data, @@ -150,9 +154,9 @@ class SubchannelData { ~Watcher() { subchannel_list_.reset(DEBUG_LOCATION, "Watcher dtor"); } - void OnConnectivityStateChange( - grpc_connectivity_state new_state, - RefCountedPtr connected_subchannel) override; + void OnConnectivityStateChange(grpc_connectivity_state new_state, + RefCountedPtr + connected_subchannel) override; grpc_pollset_set* interested_parties() override { return subchannel_list_->policy()->interested_parties(); @@ -169,7 +173,7 @@ class SubchannelData { RefCountedPtr> subchannel_list, grpc_connectivity_state state, - RefCountedPtr connected_subchannel); + RefCountedPtr connected_subchannel); ~Updater() { subchannel_list_.reset(DEBUG_LOCATION, "Watcher::Updater dtor"); @@ -182,7 +186,7 @@ class SubchannelData { RefCountedPtr> subchannel_list_; const grpc_connectivity_state state_; - RefCountedPtr connected_subchannel_; + RefCountedPtr connected_subchannel_; grpc_closure closure_; }; @@ -196,12 +200,12 @@ class SubchannelData { // Backpointer to owning subchannel list. Not owned. SubchannelList* subchannel_list_; // The subchannel. - Subchannel* subchannel_; + RefCountedPtr subchannel_; // Will be non-null when the subchannel's state is being watched. - Subchannel::ConnectivityStateWatcher* pending_watcher_ = nullptr; + SubchannelInterface::ConnectivityStateWatcher* pending_watcher_ = nullptr; // Data updated by the watcher. grpc_connectivity_state connectivity_state_; - RefCountedPtr connected_subchannel_; + RefCountedPtr connected_subchannel_; }; // A list of subchannels. @@ -235,9 +239,6 @@ class SubchannelList : public InternallyRefCounted { // Accessors. LoadBalancingPolicy* policy() const { return policy_; } TraceFlag* tracer() const { return tracer_; } - const char* health_check_service_name() const { - return health_check_service_name_.get(); - } // Resets connection backoff of all subchannels. // TODO(roth): We will probably need to rethink this as part of moving @@ -275,8 +276,6 @@ class SubchannelList : public InternallyRefCounted { TraceFlag* tracer_; - UniquePtr health_check_service_name_; - grpc_combiner* combiner_; // The list of subchannels. @@ -300,7 +299,7 @@ template void SubchannelData::Watcher:: OnConnectivityStateChange( grpc_connectivity_state new_state, - RefCountedPtr connected_subchannel) { + RefCountedPtr connected_subchannel) { // Will delete itself. New(subchannel_data_, subchannel_list_->Ref(DEBUG_LOCATION, "Watcher::Updater"), @@ -314,7 +313,7 @@ SubchannelData::Watcher::Updater:: RefCountedPtr> subchannel_list, grpc_connectivity_state state, - RefCountedPtr connected_subchannel) + RefCountedPtr connected_subchannel) : subchannel_data_(subchannel_data), subchannel_list_(std::move(subchannel_list)), state_(state), @@ -336,7 +335,7 @@ void SubchannelData::Watcher::Updater:: "connected_subchannel=%p, shutting_down=%d, pending_watcher=%p", sd->subchannel_list_->tracer()->name(), sd->subchannel_list_->policy(), sd->subchannel_list_, sd->Index(), - sd->subchannel_list_->num_subchannels(), sd->subchannel_, + sd->subchannel_list_->num_subchannels(), sd->subchannel_.get(), grpc_connectivity_state_name(self->state_), self->connected_subchannel_.get(), sd->subchannel_list_->shutting_down(), sd->pending_watcher_); @@ -360,9 +359,9 @@ void SubchannelData::Watcher::Updater:: template SubchannelData::SubchannelData( SubchannelList* subchannel_list, - const ServerAddress& address, Subchannel* subchannel) + const ServerAddress& address, RefCountedPtr subchannel) : subchannel_list_(subchannel_list), - subchannel_(subchannel), + subchannel_(std::move(subchannel)), // We assume that the current state is IDLE. If not, we'll get a // callback telling us that. connectivity_state_(GRPC_CHANNEL_IDLE) {} @@ -382,10 +381,9 @@ void SubchannelData:: " (subchannel %p): unreffing subchannel", subchannel_list_->tracer()->name(), subchannel_list_->policy(), subchannel_list_, Index(), subchannel_list_->num_subchannels(), - subchannel_); + subchannel_.get()); } - GRPC_SUBCHANNEL_UNREF(subchannel_, reason); - subchannel_ = nullptr; + subchannel_.reset(); connected_subchannel_.reset(); } } @@ -407,16 +405,16 @@ void SubchannelDatatracer()->name(), subchannel_list_->policy(), subchannel_list_, Index(), subchannel_list_->num_subchannels(), - subchannel_, grpc_connectivity_state_name(connectivity_state_)); + subchannel_.get(), + grpc_connectivity_state_name(connectivity_state_)); } GPR_ASSERT(pending_watcher_ == nullptr); pending_watcher_ = New(this, subchannel_list()->Ref(DEBUG_LOCATION, "Watcher")); subchannel_->WatchConnectivityState( connectivity_state_, - UniquePtr( - gpr_strdup(subchannel_list_->health_check_service_name())), - UniquePtr(pending_watcher_)); + UniquePtr( + pending_watcher_)); } template @@ -428,11 +426,10 @@ void SubchannelData:: " (subchannel %p): canceling connectivity watch (%s)", subchannel_list_->tracer()->name(), subchannel_list_->policy(), subchannel_list_, Index(), subchannel_list_->num_subchannels(), - subchannel_, reason); + subchannel_.get(), reason); } if (pending_watcher_ != nullptr) { - subchannel_->CancelConnectivityStateWatch( - subchannel_list_->health_check_service_name(), pending_watcher_); + subchannel_->CancelConnectivityStateWatch(pending_watcher_); pending_watcher_ = nullptr; } } @@ -463,25 +460,12 @@ SubchannelList::SubchannelList( tracer_->name(), policy, this, addresses.size()); } subchannels_.reserve(addresses.size()); - // Find health check service name. - const bool inhibit_health_checking = grpc_channel_arg_get_bool( - grpc_channel_args_find(&args, GRPC_ARG_INHIBIT_HEALTH_CHECKING), false); - if (!inhibit_health_checking) { - const char* health_check_service_name = grpc_channel_arg_get_string( - grpc_channel_args_find(&args, "grpc.temp.health_check")); - if (health_check_service_name != nullptr) { - health_check_service_name_.reset(gpr_strdup(health_check_service_name)); - } - } // We need to remove the LB addresses in order to be able to compare the // subchannel keys of subchannels from a different batch of addresses. - // We also remove the health-checking-related args, since we are - // handling that here. // We remove the service config, since it will be passed into the // subchannel via call context. - static const char* keys_to_remove[] = { - GRPC_ARG_SUBCHANNEL_ADDRESS, "grpc.temp.health_check", - GRPC_ARG_INHIBIT_HEALTH_CHECKING, GRPC_ARG_SERVICE_CONFIG}; + static const char* keys_to_remove[] = {GRPC_ARG_SUBCHANNEL_ADDRESS, + GRPC_ARG_SERVICE_CONFIG}; // Create a subchannel for each address. for (size_t i = 0; i < addresses.size(); i++) { // TODO(roth): we should ideally hide this from the LB policy code. In @@ -504,7 +488,8 @@ SubchannelList::SubchannelList( &args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), args_to_add.data(), args_to_add.size()); gpr_free(args_to_add[subchannel_address_arg_index].value.string); - Subchannel* subchannel = helper->CreateSubchannel(*new_args); + RefCountedPtr subchannel = + helper->CreateSubchannel(*new_args); grpc_channel_args_destroy(new_args); if (subchannel == nullptr) { // Subchannel could not be created. @@ -523,11 +508,11 @@ SubchannelList::SubchannelList( gpr_log(GPR_INFO, "[%s %p] subchannel list %p index %" PRIuPTR ": Created subchannel %p for address uri %s", - tracer_->name(), policy_, this, subchannels_.size(), subchannel, - address_uri); + tracer_->name(), policy_, this, subchannels_.size(), + subchannel.get(), address_uri); gpr_free(address_uri); } - subchannels_.emplace_back(this, addresses[i], subchannel); + subchannels_.emplace_back(this, addresses[i], std::move(subchannel)); } } diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index d70042af229..b198e0e8637 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -334,7 +334,8 @@ class XdsLb : public LoadBalancingPolicy { explicit FallbackHelper(RefCountedPtr parent) : parent_(std::move(parent)) {} - Subchannel* CreateSubchannel(const grpc_channel_args& args) override; + RefCountedPtr CreateSubchannel( + const grpc_channel_args& args) override; grpc_channel* CreateChannel(const char* target, const grpc_channel_args& args) override; void UpdateState(grpc_connectivity_state state, @@ -374,7 +375,8 @@ class XdsLb : public LoadBalancingPolicy { explicit Helper(RefCountedPtr entry) : entry_(std::move(entry)) {} - Subchannel* CreateSubchannel(const grpc_channel_args& args) override; + RefCountedPtr CreateSubchannel( + const grpc_channel_args& args) override; grpc_channel* CreateChannel(const char* target, const grpc_channel_args& args) override; void UpdateState(grpc_connectivity_state state, @@ -579,7 +581,7 @@ bool XdsLb::FallbackHelper::CalledByCurrentFallback() const { return child_ == parent_->fallback_policy_.get(); } -Subchannel* XdsLb::FallbackHelper::CreateSubchannel( +RefCountedPtr XdsLb::FallbackHelper::CreateSubchannel( const grpc_channel_args& args) { if (parent_->shutting_down_ || (!CalledByPendingFallback() && !CalledByCurrentFallback())) { @@ -1997,7 +1999,8 @@ bool XdsLb::LocalityMap::LocalityEntry::Helper::CalledByCurrentChild() const { return child_ == entry_->child_policy_.get(); } -Subchannel* XdsLb::LocalityMap::LocalityEntry::Helper::CreateSubchannel( +RefCountedPtr +XdsLb::LocalityMap::LocalityEntry::Helper::CreateSubchannel( const grpc_channel_args& args) { if (entry_->parent_->shutting_down_ || (!CalledByPendingChild() && !CalledByCurrentChild())) { diff --git a/src/core/ext/filters/client_channel/resolving_lb_policy.cc b/src/core/ext/filters/client_channel/resolving_lb_policy.cc index 3fe2ee74c92..d23ac1f4e33 100644 --- a/src/core/ext/filters/client_channel/resolving_lb_policy.cc +++ b/src/core/ext/filters/client_channel/resolving_lb_policy.cc @@ -106,7 +106,8 @@ class ResolvingLoadBalancingPolicy::ResolvingControlHelper RefCountedPtr parent) : parent_(std::move(parent)) {} - Subchannel* CreateSubchannel(const grpc_channel_args& args) override { + RefCountedPtr CreateSubchannel( + const grpc_channel_args& args) override { if (parent_->resolver_ == nullptr) return nullptr; // Shutting down. if (!CalledByCurrentChild() && !CalledByPendingChild()) return nullptr; return parent_->channel_control_helper()->CreateSubchannel(args); @@ -536,7 +537,7 @@ void ResolvingLoadBalancingPolicy::OnResolverResultChangedLocked( if (process_resolver_result_ != nullptr) { grpc_error* service_config_error = GRPC_ERROR_NONE; service_config_changed = process_resolver_result_( - process_resolver_result_user_data_, &result, &lb_policy_name, + process_resolver_result_user_data_, result, &lb_policy_name, &lb_policy_config, &service_config_error); if (service_config_error != GRPC_ERROR_NONE) { service_config_error_string = diff --git a/src/core/ext/filters/client_channel/resolving_lb_policy.h b/src/core/ext/filters/client_channel/resolving_lb_policy.h index cc9f3176cce..679c8d0fba0 100644 --- a/src/core/ext/filters/client_channel/resolving_lb_policy.h +++ b/src/core/ext/filters/client_channel/resolving_lb_policy.h @@ -69,7 +69,8 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy { // empty, it means that we don't have a valid service config to use, and we // should set the channel to be in TRANSIENT_FAILURE. typedef bool (*ProcessResolverResultCallback)( - void* user_data, Resolver::Result* result, const char** lb_policy_name, + void* user_data, const Resolver::Result& result, + const char** lb_policy_name, RefCountedPtr* lb_policy_config, grpc_error** service_config_error); // If error is set when this returns, then construction failed, and diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index cd778976166..cc3457e1e96 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -83,7 +83,7 @@ ConnectedSubchannel::ConnectedSubchannel( grpc_channel_stack* channel_stack, const grpc_channel_args* args, RefCountedPtr channelz_subchannel, intptr_t socket_uuid) - : RefCounted(&grpc_trace_stream_refcount), + : ConnectedSubchannelInterface(&grpc_trace_stream_refcount), channel_stack_(channel_stack), args_(grpc_channel_args_copy(args)), channelz_subchannel_(std::move(channelz_subchannel)), @@ -376,25 +376,17 @@ class Subchannel::ConnectedSubchannelStateWatcher { void Subchannel::ConnectivityStateWatcherList::AddWatcherLocked( UniquePtr watcher) { - watcher->next_ = head_; - head_ = watcher.release(); + watchers_.insert(MakePair(watcher.get(), std::move(watcher))); } void Subchannel::ConnectivityStateWatcherList::RemoveWatcherLocked( ConnectivityStateWatcher* watcher) { - for (ConnectivityStateWatcher** w = &head_; *w != nullptr; w = &(*w)->next_) { - if (*w == watcher) { - *w = watcher->next_; - Delete(watcher); - return; - } - } - GPR_UNREACHABLE_CODE(return ); + watchers_.erase(watcher); } void Subchannel::ConnectivityStateWatcherList::NotifyLocked( Subchannel* subchannel, grpc_connectivity_state state) { - for (ConnectivityStateWatcher* w = head_; w != nullptr; w = w->next_) { + for (const auto& p : watchers_) { RefCountedPtr connected_subchannel; if (state == GRPC_CHANNEL_READY) { connected_subchannel = subchannel->connected_subchannel_; @@ -407,15 +399,7 @@ void Subchannel::ConnectivityStateWatcherList::NotifyLocked( // the notification into the client_channel control-plane combiner // before processing it. But if we ever have any other callers here, // we will probably need to change this. - w->OnConnectivityStateChange(state, std::move(connected_subchannel)); - } -} - -void Subchannel::ConnectivityStateWatcherList::Clear() { - while (head_ != nullptr) { - ConnectivityStateWatcher* next = head_->next_; - Delete(head_); - head_ = next; + p.second->OnConnectivityStateChange(state, std::move(connected_subchannel)); } } diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h index e0741bb28fa..2f05792b872 100644 --- a/src/core/ext/filters/client_channel/subchannel.h +++ b/src/core/ext/filters/client_channel/subchannel.h @@ -23,6 +23,7 @@ #include "src/core/ext/filters/client_channel/client_channel_channelz.h" #include "src/core/ext/filters/client_channel/connector.h" +#include "src/core/ext/filters/client_channel/subchannel_interface.h" #include "src/core/ext/filters/client_channel/subchannel_pool_interface.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_stack.h" @@ -69,7 +70,7 @@ namespace grpc_core { class SubchannelCall; -class ConnectedSubchannel : public RefCounted { +class ConnectedSubchannel : public ConnectedSubchannelInterface { public: struct CallArgs { grpc_polling_entity* pollent; @@ -96,7 +97,7 @@ class ConnectedSubchannel : public RefCounted { grpc_error** error); grpc_channel_stack* channel_stack() const { return channel_stack_; } - const grpc_channel_args* args() const { return args_; } + const grpc_channel_args* args() const override { return args_; } channelz::SubchannelNode* channelz_subchannel() const { return channelz_subchannel_.get(); } @@ -176,37 +177,9 @@ class SubchannelCall { // A subchannel that knows how to connect to exactly one target address. It // provides a target for load balancing. class Subchannel { - private: - class ConnectivityStateWatcherList; // Forward declaration. - public: - class ConnectivityStateWatcher { - public: - virtual ~ConnectivityStateWatcher() = default; - - // Will be invoked whenever the subchannel's connectivity state - // changes. There will be only one invocation of this method on a - // given watcher instance at any given time. - // - // When the state changes to READY, connected_subchannel will - // contain a ref to the connected subchannel. When it changes from - // READY to some other state, the implementation must release its - // ref to the connected subchannel. - virtual void OnConnectivityStateChange( - grpc_connectivity_state new_state, - RefCountedPtr connected_subchannel) // NOLINT - GRPC_ABSTRACT; - - virtual grpc_pollset_set* interested_parties() GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS - - private: - // For access to next_. - friend class Subchannel::ConnectivityStateWatcherList; - - ConnectivityStateWatcher* next_ = nullptr; - }; + typedef SubchannelInterface::ConnectivityStateWatcher + ConnectivityStateWatcher; // The ctor and dtor are not intended to use directly. Subchannel(SubchannelKey* key, grpc_connector* connector, @@ -296,12 +269,15 @@ class Subchannel { // Notifies all watchers in the list about a change to state. void NotifyLocked(Subchannel* subchannel, grpc_connectivity_state state); - void Clear(); + void Clear() { watchers_.clear(); } - bool empty() const { return head_ == nullptr; } + bool empty() const { return watchers_.empty(); } private: - ConnectivityStateWatcher* head_ = nullptr; + // TODO(roth): This could be a set instead of a map if we had a set + // implementation. + Map> + watchers_; }; // A map that tracks ConnectivityStateWatchers using a particular health diff --git a/src/core/ext/filters/client_channel/subchannel_interface.h b/src/core/ext/filters/client_channel/subchannel_interface.h new file mode 100644 index 00000000000..0a471045f03 --- /dev/null +++ b/src/core/ext/filters/client_channel/subchannel_interface.h @@ -0,0 +1,109 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SUBCHANNEL_INTERFACE_H +#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SUBCHANNEL_INTERFACE_H + +#include + +#include "src/core/lib/debug/trace.h" +#include "src/core/lib/gprpp/ref_counted.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" + +namespace grpc_core { + +// TODO(roth): In a subsequent PR, remove this from this API. +class ConnectedSubchannelInterface + : public RefCounted { + public: + virtual const grpc_channel_args* args() const GRPC_ABSTRACT; + + protected: + template + explicit ConnectedSubchannelInterface(TraceFlagT* trace_flag = nullptr) + : RefCounted(trace_flag) {} +}; + +class SubchannelInterface : public RefCounted { + public: + class ConnectivityStateWatcher { + public: + virtual ~ConnectivityStateWatcher() = default; + + // Will be invoked whenever the subchannel's connectivity state + // changes. There will be only one invocation of this method on a + // given watcher instance at any given time. + // + // When the state changes to READY, connected_subchannel will + // contain a ref to the connected subchannel. When it changes from + // READY to some other state, the implementation must release its + // ref to the connected subchannel. + virtual void OnConnectivityStateChange( + grpc_connectivity_state new_state, + RefCountedPtr + connected_subchannel) // NOLINT + GRPC_ABSTRACT; + + // TODO(roth): Remove this as soon as we move to EventManager-based + // polling. + virtual grpc_pollset_set* interested_parties() GRPC_ABSTRACT; + + GRPC_ABSTRACT_BASE_CLASS + }; + + virtual ~SubchannelInterface() = default; + + // Returns the current connectivity state of the subchannel. + virtual grpc_connectivity_state CheckConnectivityState( + RefCountedPtr* connected_subchannel) + GRPC_ABSTRACT; + + // Starts watching the subchannel's connectivity state. + // The first callback to the watcher will be delivered when the + // subchannel's connectivity state becomes a value other than + // initial_state, which may happen immediately. + // Subsequent callbacks will be delivered as the subchannel's state + // changes. + // The watcher will be destroyed either when the subchannel is + // destroyed or when CancelConnectivityStateWatch() is called. + // There can be only one watcher of a given subchannel. It is not + // valid to call this method a second time without first cancelling + // the previous watcher using CancelConnectivityStateWatch(). + virtual void WatchConnectivityState( + grpc_connectivity_state initial_state, + UniquePtr watcher) GRPC_ABSTRACT; + + // Cancels a connectivity state watch. + // If the watcher has already been destroyed, this is a no-op. + virtual void CancelConnectivityStateWatch(ConnectivityStateWatcher* watcher) + GRPC_ABSTRACT; + + // Attempt to connect to the backend. Has no effect if already connected. + virtual void AttemptToConnect() GRPC_ABSTRACT; + + // TODO(roth): These methods should be removed from this interface to + // bettter hide grpc-specific functionality from the LB policy API. + virtual channelz::SubchannelNode* channelz_node() GRPC_ABSTRACT; + virtual void ResetBackoff() GRPC_ABSTRACT; + + GRPC_ABSTRACT_BASE_CLASS +}; + +} // namespace grpc_core + +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SUBCHANNEL_INTERFACE_H */ diff --git a/test/core/util/test_lb_policies.cc b/test/core/util/test_lb_policies.cc index bd28422bcd1..ced6d9d8027 100644 --- a/test/core/util/test_lb_policies.cc +++ b/test/core/util/test_lb_policies.cc @@ -143,7 +143,8 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy InterceptRecvTrailingMetadataCallback cb, void* user_data) : parent_(std::move(parent)), cb_(cb), user_data_(user_data) {} - Subchannel* CreateSubchannel(const grpc_channel_args& args) override { + RefCountedPtr CreateSubchannel( + const grpc_channel_args& args) override { return parent_->channel_control_helper()->CreateSubchannel(args); } diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 2c20d69e6e3..7768bca30f5 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -974,6 +974,7 @@ src/core/ext/filters/client_channel/service_config.cc \ src/core/ext/filters/client_channel/service_config.h \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel.h \ +src/core/ext/filters/client_channel/subchannel_interface.h \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.h \ src/core/ext/filters/deadline/deadline_filter.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index a9dc9fcfe3f..a479a00509a 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -8912,6 +8912,7 @@ "src/core/ext/filters/client_channel/server_address.h", "src/core/ext/filters/client_channel/service_config.h", "src/core/ext/filters/client_channel/subchannel.h", + "src/core/ext/filters/client_channel/subchannel_interface.h", "src/core/ext/filters/client_channel/subchannel_pool_interface.h" ], "is_filegroup": true, @@ -8968,6 +8969,7 @@ "src/core/ext/filters/client_channel/service_config.h", "src/core/ext/filters/client_channel/subchannel.cc", "src/core/ext/filters/client_channel/subchannel.h", + "src/core/ext/filters/client_channel/subchannel_interface.h", "src/core/ext/filters/client_channel/subchannel_pool_interface.cc", "src/core/ext/filters/client_channel/subchannel_pool_interface.h" ], From 5ce3f688800cf6dfe8ba7be14dd824b8c399aa6d Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 29 May 2019 12:52:05 -0700 Subject: [PATCH 0365/1555] fix handling of insecure channels in grpclb and xds --- .../client_channel/lb_policy/grpclb/grpclb_channel_secure.cc | 4 ++++ .../client_channel/lb_policy/xds/xds_channel_secure.cc | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc index 376209fa7e2..5bc4f5157ad 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc @@ -103,6 +103,10 @@ grpc_channel* CreateGrpclbBalancerChannel(const char* target_uri, const grpc_channel_args& args) { grpc_channel_credentials* creds = grpc_channel_credentials_find_in_args(&args); + if (creds == nullptr) { + // Build with security but parent channel is insecure. + return grpc_insecure_channel_create(target_uri, &args, nullptr); + } const char* arg_to_remove = GRPC_ARG_CHANNEL_CREDENTIALS; grpc_channel_args* new_args = grpc_channel_args_copy_and_remove(&args, &arg_to_remove, 1); diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc index ad5e7cbbc2e..720d5a01d9d 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc @@ -66,6 +66,10 @@ grpc_channel* CreateXdsBalancerChannel(const char* target_uri, const grpc_channel_args& args) { grpc_channel_credentials* creds = grpc_channel_credentials_find_in_args(&args); + if (creds == nullptr) { + // Build with security but parent channel is insecure. + return grpc_insecure_channel_create(target_uri, &args, nullptr); + } const char* arg_to_remove = GRPC_ARG_CHANNEL_CREDENTIALS; grpc_channel_args* new_args = grpc_channel_args_copy_and_remove(&args, &arg_to_remove, 1); From 196b0aa3a3a249dc1edc38a9ca6c035e9ab4ddf8 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 29 May 2019 13:15:47 -0700 Subject: [PATCH 0366/1555] Revert "Revert "Start supporting a callback-based RPC under lock"" --- src/core/lib/surface/completion_queue.cc | 81 +++++++++++-------- src/core/lib/surface/completion_queue.h | 3 +- src/core/lib/surface/server.cc | 2 +- test/core/surface/completion_queue_test.cc | 44 +++++++++- .../end2end/client_callback_end2end_test.cc | 28 +++++++ test/cpp/microbenchmarks/bm_cq.cc | 35 +++++++- .../callback_streaming_ping_pong.h | 2 +- 7 files changed, 155 insertions(+), 40 deletions(-) diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index e796071eedc..d0ed1a9f673 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -34,6 +34,7 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tls.h" #include "src/core/lib/gprpp/atomic.h" +#include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/profiling/timers.h" @@ -200,7 +201,7 @@ struct cq_vtable { bool (*begin_op)(grpc_completion_queue* cq, void* tag); void (*end_op)(grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage); + void* done_arg, grpc_cq_completion* storage, bool internal); grpc_event (*next)(grpc_completion_queue* cq, gpr_timespec deadline, void* reserved); grpc_event (*pluck)(grpc_completion_queue* cq, void* tag, @@ -354,23 +355,20 @@ static bool cq_begin_op_for_callback(grpc_completion_queue* cq, void* tag); // queue. The done argument is a callback that will be invoked when it is // safe to free up that storage. The storage MUST NOT be freed until the // done callback is invoked. -static void cq_end_op_for_next(grpc_completion_queue* cq, void* tag, - grpc_error* error, - void (*done)(void* done_arg, - grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage); +static void cq_end_op_for_next( + grpc_completion_queue* cq, void* tag, grpc_error* error, + void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, + grpc_cq_completion* storage, bool internal); -static void cq_end_op_for_pluck(grpc_completion_queue* cq, void* tag, - grpc_error* error, - void (*done)(void* done_arg, - grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage); +static void cq_end_op_for_pluck( + grpc_completion_queue* cq, void* tag, grpc_error* error, + void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, + grpc_cq_completion* storage, bool internal); -static void cq_end_op_for_callback(grpc_completion_queue* cq, void* tag, - grpc_error* error, - void (*done)(void* done_arg, - grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage); +static void cq_end_op_for_callback( + grpc_completion_queue* cq, void* tag, grpc_error* error, + void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, + grpc_cq_completion* storage, bool internal); static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline, void* reserved); @@ -674,11 +672,10 @@ bool grpc_cq_begin_op(grpc_completion_queue* cq, void* tag) { /* Queue a GRPC_OP_COMPLETED operation to a completion queue (with a * completion * type of GRPC_CQ_NEXT) */ -static void cq_end_op_for_next(grpc_completion_queue* cq, void* tag, - grpc_error* error, - void (*done)(void* done_arg, - grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage) { +static void cq_end_op_for_next( + grpc_completion_queue* cq, void* tag, grpc_error* error, + void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, + grpc_cq_completion* storage, bool internal) { GPR_TIMER_SCOPE("cq_end_op_for_next", 0); if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) || @@ -754,11 +751,10 @@ static void cq_end_op_for_next(grpc_completion_queue* cq, void* tag, /* Queue a GRPC_OP_COMPLETED operation to a completion queue (with a * completion * type of GRPC_CQ_PLUCK) */ -static void cq_end_op_for_pluck(grpc_completion_queue* cq, void* tag, - grpc_error* error, - void (*done)(void* done_arg, - grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage) { +static void cq_end_op_for_pluck( + grpc_completion_queue* cq, void* tag, grpc_error* error, + void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, + grpc_cq_completion* storage, bool internal) { GPR_TIMER_SCOPE("cq_end_op_for_pluck", 0); cq_pluck_data* cqd = static_cast DATA_FROM_CQ(cq); @@ -821,15 +817,19 @@ static void cq_end_op_for_pluck(grpc_completion_queue* cq, void* tag, GRPC_ERROR_UNREF(error); } +static void functor_callback(void* arg, grpc_error* error) { + auto* functor = static_cast(arg); + functor->functor_run(functor, error == GRPC_ERROR_NONE); +} + /* Complete an event on a completion queue of type GRPC_CQ_CALLBACK */ static void cq_end_op_for_callback( grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, - grpc_cq_completion* storage) { + grpc_cq_completion* storage, bool internal) { GPR_TIMER_SCOPE("cq_end_op_for_callback", 0); cq_callback_data* cqd = static_cast DATA_FROM_CQ(cq); - bool is_success = (error == GRPC_ERROR_NONE); if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) || (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) && @@ -856,16 +856,25 @@ static void cq_end_op_for_callback( cq_finish_shutdown_callback(cq); } - GRPC_ERROR_UNREF(error); - auto* functor = static_cast(tag); - grpc_core::ApplicationCallbackExecCtx::Enqueue(functor, is_success); + if (internal) { + grpc_core::ApplicationCallbackExecCtx::Enqueue(functor, + (error == GRPC_ERROR_NONE)); + } else { + GRPC_CLOSURE_SCHED( + GRPC_CLOSURE_CREATE( + functor_callback, functor, + grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), + GRPC_ERROR_REF(error)); + } + GRPC_ERROR_UNREF(error); } void grpc_cq_end_op(grpc_completion_queue* cq, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage) { - cq->vtable->end_op(cq, tag, error, done, done_arg, storage); + void* done_arg, grpc_cq_completion* storage, + bool internal) { + cq->vtable->end_op(cq, tag, error, done, done_arg, storage, internal); } typedef struct { @@ -1343,7 +1352,11 @@ static void cq_finish_shutdown_callback(grpc_completion_queue* cq) { GPR_ASSERT(cqd->shutdown_called); cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done); - grpc_core::ApplicationCallbackExecCtx::Enqueue(callback, true); + GRPC_CLOSURE_SCHED( + GRPC_CLOSURE_CREATE( + functor_callback, callback, + grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), + GRPC_ERROR_NONE); } static void cq_shutdown_callback(grpc_completion_queue* cq) { diff --git a/src/core/lib/surface/completion_queue.h b/src/core/lib/surface/completion_queue.h index d60fe6d6efe..3ba9fbb8765 100644 --- a/src/core/lib/surface/completion_queue.h +++ b/src/core/lib/surface/completion_queue.h @@ -77,7 +77,8 @@ bool grpc_cq_begin_op(grpc_completion_queue* cc, void* tag); grpc_cq_begin_op */ void grpc_cq_end_op(grpc_completion_queue* cc, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), - void* done_arg, grpc_cq_completion* storage); + void* done_arg, grpc_cq_completion* storage, + bool internal = false); grpc_pollset* grpc_cq_pollset(grpc_completion_queue* cc); diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 5ecd5662c2c..44de0cd42dd 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -513,7 +513,7 @@ static void publish_call(grpc_server* server, call_data* calld, size_t cq_idx, } grpc_cq_end_op(calld->cq_new, rc->tag, GRPC_ERROR_NONE, done_request_event, - rc, &rc->completion); + rc, &rc->completion, true); } static void publish_new_rpc(void* arg, grpc_error* error) { diff --git a/test/core/surface/completion_queue_test.cc b/test/core/surface/completion_queue_test.cc index 7c3630eaf18..4a33b934f43 100644 --- a/test/core/surface/completion_queue_test.cc +++ b/test/core/surface/completion_queue_test.cc @@ -23,6 +23,7 @@ #include #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/gprpp/sync.h" #include "src/core/lib/iomgr/iomgr.h" #include "test/core/util/test_config.h" @@ -359,12 +360,19 @@ static void test_pluck_after_shutdown(void) { static void test_callback(void) { grpc_completion_queue* cc; - void* tags[128]; + static void* tags[128]; grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)]; grpc_cq_polling_type polling_types[] = { GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; grpc_completion_queue_attributes attr; unsigned i; + static gpr_mu mu, shutdown_mu; + static gpr_cv cv, shutdown_cv; + static int cb_counter; + gpr_mu_init(&mu); + gpr_mu_init(&shutdown_mu); + gpr_cv_init(&cv); + gpr_cv_init(&shutdown_cv); LOG_TEST("test_callback"); @@ -376,7 +384,11 @@ static void test_callback(void) { } ~ShutdownCallback() {} static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { + gpr_mu_lock(&shutdown_mu); *static_cast(cb)->done_ = static_cast(ok); + // Signal when the shutdown callback is completed. + gpr_cv_signal(&shutdown_cv); + gpr_mu_unlock(&shutdown_mu); } private: @@ -391,9 +403,9 @@ static void test_callback(void) { for (size_t pidx = 0; pidx < GPR_ARRAY_SIZE(polling_types); pidx++) { int sumtags = 0; int counter = 0; + cb_counter = 0; { // reset exec_ctx types - grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; attr.cq_polling_type = polling_types[pidx]; cc = grpc_completion_queue_create( @@ -409,7 +421,13 @@ static void test_callback(void) { int ok) { GPR_ASSERT(static_cast(ok)); auto* callback = static_cast(cb); + gpr_mu_lock(&mu); + cb_counter++; *callback->counter_ += callback->tag_; + if (cb_counter == GPR_ARRAY_SIZE(tags)) { + gpr_cv_signal(&cv); + } + gpr_mu_unlock(&mu); grpc_core::Delete(callback); }; @@ -429,12 +447,34 @@ static void test_callback(void) { nullptr, &completions[i]); } + gpr_mu_lock(&mu); + while (cb_counter != GPR_ARRAY_SIZE(tags)) { + // Wait for all the callbacks to complete. + gpr_cv_wait(&cv, &mu, gpr_inf_future(GPR_CLOCK_REALTIME)); + } + gpr_mu_unlock(&mu); + shutdown_and_destroy(cc); + + gpr_mu_lock(&shutdown_mu); + while (!got_shutdown) { + // Wait for the shutdown callback to complete. + gpr_cv_wait(&shutdown_cv, &shutdown_mu, + gpr_inf_future(GPR_CLOCK_REALTIME)); + } + gpr_mu_unlock(&shutdown_mu); } + + // Run the assertions to check if the test ran successfully. GPR_ASSERT(sumtags == counter); GPR_ASSERT(got_shutdown); got_shutdown = false; } + + gpr_cv_destroy(&cv); + gpr_cv_destroy(&shutdown_cv); + gpr_mu_destroy(&mu); + gpr_mu_destroy(&shutdown_mu); } struct thread_state { diff --git a/test/cpp/end2end/client_callback_end2end_test.cc b/test/cpp/end2end/client_callback_end2end_test.cc index a154324216b..8cf6def1073 100644 --- a/test/cpp/end2end/client_callback_end2end_test.cc +++ b/test/cpp/end2end/client_callback_end2end_test.cc @@ -374,6 +374,34 @@ TEST_P(ClientCallbackEnd2endTest, SimpleRpc) { SendRpcs(1, false); } +TEST_P(ClientCallbackEnd2endTest, SimpleRpcUnderLock) { + MAYBE_SKIP_TEST; + ResetStub(); + std::mutex mu; + std::condition_variable cv; + bool done = false; + EchoRequest request; + request.set_message("Hello locked world."); + EchoResponse response; + ClientContext cli_ctx; + { + std::lock_guard l(mu); + stub_->experimental_async()->Echo( + &cli_ctx, &request, &response, + [&mu, &cv, &done, &request, &response](Status s) { + std::lock_guard l(mu); + EXPECT_TRUE(s.ok()); + EXPECT_EQ(request.message(), response.message()); + done = true; + cv.notify_one(); + }); + } + std::unique_lock l(mu); + while (!done) { + cv.wait(l); + } +} + TEST_P(ClientCallbackEnd2endTest, SequentialRpcs) { MAYBE_SKIP_TEST; ResetStub(); diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index 50eb9454fbe..edbff9c2be3 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -150,6 +150,9 @@ static void shutdown_and_destroy(grpc_completion_queue* cc) { grpc_completion_queue_destroy(cc); } +static gpr_mu shutdown_mu, mu; +static gpr_cv shutdown_cv, cv; + // Tag completion queue iterate times class TagCallback : public grpc_experimental_completion_queue_functor { public: @@ -158,8 +161,11 @@ class TagCallback : public grpc_experimental_completion_queue_functor { } ~TagCallback() {} static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { + gpr_mu_lock(&mu); GPR_ASSERT(static_cast(ok)); *static_cast(cb)->iter_ += 1; + gpr_cv_signal(&cv); + gpr_mu_unlock(&mu); }; private: @@ -174,7 +180,10 @@ class ShutdownCallback : public grpc_experimental_completion_queue_functor { } ~ShutdownCallback() {} static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { + gpr_mu_lock(&shutdown_mu); *static_cast(cb)->done_ = static_cast(ok); + gpr_cv_signal(&shutdown_cv); + gpr_mu_unlock(&shutdown_mu); } private: @@ -183,8 +192,12 @@ class ShutdownCallback : public grpc_experimental_completion_queue_functor { static void BM_Callback_CQ_Pass1Core(benchmark::State& state) { TrackCounters track_counters; - int iteration = 0; + int iteration = 0, current_iterations = 0; TagCallback tag_cb(&iteration); + gpr_mu_init(&mu); + gpr_cv_init(&cv); + gpr_mu_init(&shutdown_mu); + gpr_cv_init(&shutdown_cv); bool got_shutdown = false; ShutdownCallback shutdown_cb(&got_shutdown); grpc_completion_queue* cc = @@ -198,9 +211,29 @@ static void BM_Callback_CQ_Pass1Core(benchmark::State& state) { nullptr, &completion); } shutdown_and_destroy(cc); + + gpr_mu_lock(&mu); + current_iterations = static_cast(state.iterations()); + while (current_iterations != iteration) { + // Wait for all the callbacks to complete. + gpr_cv_wait(&cv, &mu, gpr_inf_future(GPR_CLOCK_REALTIME)); + } + gpr_mu_unlock(&mu); + + gpr_mu_lock(&shutdown_mu); + while (!got_shutdown) { + // Wait for the shutdown callback to complete. + gpr_cv_wait(&shutdown_cv, &shutdown_mu, gpr_inf_future(GPR_CLOCK_REALTIME)); + } + gpr_mu_unlock(&shutdown_mu); + GPR_ASSERT(got_shutdown); GPR_ASSERT(iteration == static_cast(state.iterations())); track_counters.Finish(state); + gpr_cv_destroy(&cv); + gpr_mu_destroy(&mu); + gpr_cv_destroy(&shutdown_cv); + gpr_mu_destroy(&shutdown_mu); } BENCHMARK(BM_Callback_CQ_Pass1Core); diff --git a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h index 9fb86bd8299..0d27e0efa50 100644 --- a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h @@ -115,7 +115,7 @@ class BidiClient int msgs_size_; std::mutex mu; std::condition_variable cv; - bool done; + bool done = false; }; template From bd97b1361df0a2d7ac0bbd02a2a7e618fab299cc Mon Sep 17 00:00:00 2001 From: yang-g Date: Wed, 29 May 2019 12:04:40 -0700 Subject: [PATCH 0367/1555] Delete wrapper in executor thread to avoid self-joining deadlock --- src/cpp/client/secure_credentials.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index 2d041a28664..3d2a123180b 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -22,6 +22,7 @@ #include #include #include +#include "src/core/lib/iomgr/executor.h" #include "src/core/lib/security/transport/auth_filters.h" #include "src/cpp/client/create_channel_internal.h" #include "src/cpp/common/secure_auth_context.h" @@ -224,13 +225,23 @@ std::shared_ptr MetadataCredentialsFromPlugin( } // namespace grpc_impl namespace grpc { - -void MetadataCredentialsPluginWrapper::Destroy(void* wrapper) { - if (wrapper == nullptr) return; +namespace { +void DeleteWrapper(void* wrapper, grpc_error* ignored) { MetadataCredentialsPluginWrapper* w = static_cast(wrapper); delete w; } +} // namespace + +void MetadataCredentialsPluginWrapper::Destroy(void* wrapper) { + if (wrapper == nullptr) return; + grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; + grpc_core::ExecCtx exec_ctx; + GRPC_CLOSURE_RUN(GRPC_CLOSURE_CREATE(DeleteWrapper, wrapper, + grpc_core::Executor::Scheduler( + grpc_core::ExecutorJobType::SHORT)), + GRPC_ERROR_NONE); +} int MetadataCredentialsPluginWrapper::GetMetadata( void* wrapper, grpc_auth_metadata_context context, From 8ef2152c801a4210c6e630012095af5b1fd7edee Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 29 May 2019 14:28:56 -0700 Subject: [PATCH 0368/1555] Fix the memory leak. --- src/core/lib/surface/completion_queue.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index d0ed1a9f673..9b30b3998a5 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -820,6 +820,7 @@ static void cq_end_op_for_pluck( static void functor_callback(void* arg, grpc_error* error) { auto* functor = static_cast(arg); functor->functor_run(functor, error == GRPC_ERROR_NONE); + GRPC_ERROR_UNREF(error); } /* Complete an event on a completion queue of type GRPC_CQ_CALLBACK */ @@ -860,14 +861,14 @@ static void cq_end_op_for_callback( if (internal) { grpc_core::ApplicationCallbackExecCtx::Enqueue(functor, (error == GRPC_ERROR_NONE)); + GRPC_ERROR_UNREF(error); } else { GRPC_CLOSURE_SCHED( GRPC_CLOSURE_CREATE( functor_callback, functor, grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), - GRPC_ERROR_REF(error)); + error); } - GRPC_ERROR_UNREF(error); } void grpc_cq_end_op(grpc_completion_queue* cq, void* tag, grpc_error* error, @@ -1356,7 +1357,7 @@ static void cq_finish_shutdown_callback(grpc_completion_queue* cq) { GRPC_CLOSURE_CREATE( functor_callback, callback, grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), - GRPC_ERROR_NONE); + GRPC_ERROR_REF(GRPC_ERROR_NONE)); } static void cq_shutdown_callback(grpc_completion_queue* cq) { From b483c27cd040f81764e40ad2e9435fd5269e9ba3 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Wed, 29 May 2019 16:35:24 -0700 Subject: [PATCH 0369/1555] Update protobuf submodule version --- third_party/protobuf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/protobuf b/third_party/protobuf index 582743bf40c..09745575a92 160000 --- a/third_party/protobuf +++ b/third_party/protobuf @@ -1 +1 @@ -Subproject commit 582743bf40c5d3639a70f98f183914a2c0cd0680 +Subproject commit 09745575a923640154bcf307fba8aedff47f240a From 1ddaafd677ee678f3f14c56a65cbb7783765ba73 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Wed, 29 May 2019 16:37:10 -0700 Subject: [PATCH 0370/1555] Update protobuf version --- bazel/grpc_deps.bzl | 6 +-- grpc.gemspec | 2 +- src/csharp/Grpc.Core/Version.csproj.include | 2 +- .../Grpc.IntegrationTesting/EchoMessages.cs | 45 +++++++++++++++---- templates/grpc.gemspec.template | 2 +- .../python/grpcio_tools/protoc_lib_deps.py | 4 +- tools/run_tests/sanity/check_submodules.sh | 2 +- 7 files changed, 46 insertions(+), 17 deletions(-) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index a4e6509782d..08022942be0 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -127,9 +127,9 @@ def grpc_deps(): if "com_google_protobuf" not in native.existing_rules(): http_archive( name = "com_google_protobuf", - sha256 = "cf9e2fb1d2cd30ec9d51ff1749045208bd641f290f64b85046485934b0e03783", - strip_prefix = "protobuf-582743bf40c5d3639a70f98f183914a2c0cd0680", - url = "https://github.com/google/protobuf/archive/582743bf40c5d3639a70f98f183914a2c0cd0680.tar.gz", + sha256 = "416212e14481cff8fd4849b1c1c1200a7f34808a54377e22d7447efdf54ad758", + strip_prefix = "protobuf-09745575a923640154bcf307fba8aedff47f240a", + url = "https://github.com/google/protobuf/archive/09745575a923640154bcf307fba8aedff47f240a.tar.gz", ) if "com_github_nanopb_nanopb" not in native.existing_rules(): diff --git a/grpc.gemspec b/grpc.gemspec index 36b325f8f0d..0f66332d48f 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -29,7 +29,7 @@ Gem::Specification.new do |s| s.require_paths = %w( src/ruby/lib src/ruby/bin src/ruby/pb ) s.platform = Gem::Platform::RUBY - s.add_dependency 'google-protobuf', '~> 3.7' + s.add_dependency 'google-protobuf', '~> 3.8.0' s.add_dependency 'googleapis-common-protos-types', '~> 1.0' s.add_development_dependency 'bundler', '~> 1.9' diff --git a/src/csharp/Grpc.Core/Version.csproj.include b/src/csharp/Grpc.Core/Version.csproj.include index 6354a053965..e24afdad605 100755 --- a/src/csharp/Grpc.Core/Version.csproj.include +++ b/src/csharp/Grpc.Core/Version.csproj.include @@ -2,6 +2,6 @@ 1.19.1 - 3.6.1 + 3.8.0 diff --git a/src/csharp/Grpc.IntegrationTesting/EchoMessages.cs b/src/csharp/Grpc.IntegrationTesting/EchoMessages.cs index e5af4a93e99..bbba68eeac1 100644 --- a/src/csharp/Grpc.IntegrationTesting/EchoMessages.cs +++ b/src/csharp/Grpc.IntegrationTesting/EchoMessages.cs @@ -28,7 +28,7 @@ namespace Grpc.Testing { "DGdycGMudGVzdGluZyIyCglEZWJ1Z0luZm8SFQoNc3RhY2tfZW50cmllcxgB", "IAMoCRIOCgZkZXRhaWwYAiABKAkiUAoLRXJyb3JTdGF0dXMSDAoEY29kZRgB", "IAEoBRIVCg1lcnJvcl9tZXNzYWdlGAIgASgJEhwKFGJpbmFyeV9lcnJvcl9k", - "ZXRhaWxzGAMgASgJIv8DCg1SZXF1ZXN0UGFyYW1zEhUKDWVjaG9fZGVhZGxp", + "ZXRhaWxzGAMgASgJIqAECg1SZXF1ZXN0UGFyYW1zEhUKDWVjaG9fZGVhZGxp", "bmUYASABKAgSHgoWY2xpZW50X2NhbmNlbF9hZnRlcl91cxgCIAEoBRIeChZz", "ZXJ2ZXJfY2FuY2VsX2FmdGVyX3VzGAMgASgFEhUKDWVjaG9fbWV0YWRhdGEY", "BCABKAgSGgoSY2hlY2tfYXV0aF9jb250ZXh0GAUgASgIEh8KF3Jlc3BvbnNl", @@ -39,18 +39,19 @@ namespace Grpc.Testing { "Zy5EZWJ1Z0luZm8SEgoKc2VydmVyX2RpZRgMIAEoCBIcChRiaW5hcnlfZXJy", "b3JfZGV0YWlscxgNIAEoCRIxCg5leHBlY3RlZF9lcnJvchgOIAEoCzIZLmdy", "cGMudGVzdGluZy5FcnJvclN0YXR1cxIXCg9zZXJ2ZXJfc2xlZXBfdXMYDyAB", - "KAUSGwoTYmFja2VuZF9jaGFubmVsX2lkeBgQIAEoBSJKCgtFY2hvUmVxdWVz", - "dBIPCgdtZXNzYWdlGAEgASgJEioKBXBhcmFtGAIgASgLMhsuZ3JwYy50ZXN0", - "aW5nLlJlcXVlc3RQYXJhbXMiRgoOUmVzcG9uc2VQYXJhbXMSGAoQcmVxdWVz", - "dF9kZWFkbGluZRgBIAEoAxIMCgRob3N0GAIgASgJEgwKBHBlZXIYAyABKAki", - "TAoMRWNob1Jlc3BvbnNlEg8KB21lc3NhZ2UYASABKAkSKwoFcGFyYW0YAiAB", - "KAsyHC5ncnBjLnRlc3RpbmcuUmVzcG9uc2VQYXJhbXNiBnByb3RvMw==")); + "KAUSGwoTYmFja2VuZF9jaGFubmVsX2lkeBgQIAEoBRIfChdlY2hvX21ldGFk", + "YXRhX2luaXRpYWxseRgRIAEoCCJKCgtFY2hvUmVxdWVzdBIPCgdtZXNzYWdl", + "GAEgASgJEioKBXBhcmFtGAIgASgLMhsuZ3JwYy50ZXN0aW5nLlJlcXVlc3RQ", + "YXJhbXMiRgoOUmVzcG9uc2VQYXJhbXMSGAoQcmVxdWVzdF9kZWFkbGluZRgB", + "IAEoAxIMCgRob3N0GAIgASgJEgwKBHBlZXIYAyABKAkiTAoMRWNob1Jlc3Bv", + "bnNlEg8KB21lc3NhZ2UYASABKAkSKwoFcGFyYW0YAiABKAsyHC5ncnBjLnRl", + "c3RpbmcuUmVzcG9uc2VQYXJhbXNCA/gBAWIGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.DebugInfo), global::Grpc.Testing.DebugInfo.Parser, new[]{ "StackEntries", "Detail" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ErrorStatus), global::Grpc.Testing.ErrorStatus.Parser, new[]{ "Code", "ErrorMessage", "BinaryErrorDetails" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.RequestParams), global::Grpc.Testing.RequestParams.Parser, new[]{ "EchoDeadline", "ClientCancelAfterUs", "ServerCancelAfterUs", "EchoMetadata", "CheckAuthContext", "ResponseMessageLength", "EchoPeer", "ExpectedClientIdentity", "SkipCancelledCheck", "ExpectedTransportSecurityType", "DebugInfo", "ServerDie", "BinaryErrorDetails", "ExpectedError", "ServerSleepUs", "BackendChannelIdx" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.RequestParams), global::Grpc.Testing.RequestParams.Parser, new[]{ "EchoDeadline", "ClientCancelAfterUs", "ServerCancelAfterUs", "EchoMetadata", "CheckAuthContext", "ResponseMessageLength", "EchoPeer", "ExpectedClientIdentity", "SkipCancelledCheck", "ExpectedTransportSecurityType", "DebugInfo", "ServerDie", "BinaryErrorDetails", "ExpectedError", "ServerSleepUs", "BackendChannelIdx", "EchoMetadataInitially" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.EchoRequest), global::Grpc.Testing.EchoRequest.Parser, new[]{ "Message", "Param" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ResponseParams), global::Grpc.Testing.ResponseParams.Parser, new[]{ "RequestDeadline", "Host", "Peer" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.EchoResponse), global::Grpc.Testing.EchoResponse.Parser, new[]{ "Message", "Param" }, null, null, null) @@ -441,6 +442,7 @@ namespace Grpc.Testing { expectedError_ = other.expectedError_ != null ? other.expectedError_.Clone() : null; serverSleepUs_ = other.serverSleepUs_; backendChannelIdx_ = other.backendChannelIdx_; + echoMetadataInitially_ = other.echoMetadataInitially_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -637,6 +639,17 @@ namespace Grpc.Testing { } } + /// Field number for the "echo_metadata_initially" field. + public const int EchoMetadataInitiallyFieldNumber = 17; + private bool echoMetadataInitially_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool EchoMetadataInitially { + get { return echoMetadataInitially_; } + set { + echoMetadataInitially_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as RequestParams); @@ -666,6 +679,7 @@ namespace Grpc.Testing { if (!object.Equals(ExpectedError, other.ExpectedError)) return false; if (ServerSleepUs != other.ServerSleepUs) return false; if (BackendChannelIdx != other.BackendChannelIdx) return false; + if (EchoMetadataInitially != other.EchoMetadataInitially) return false; return Equals(_unknownFields, other._unknownFields); } @@ -688,6 +702,7 @@ namespace Grpc.Testing { if (expectedError_ != null) hash ^= ExpectedError.GetHashCode(); if (ServerSleepUs != 0) hash ^= ServerSleepUs.GetHashCode(); if (BackendChannelIdx != 0) hash ^= BackendChannelIdx.GetHashCode(); + if (EchoMetadataInitially != false) hash ^= EchoMetadataInitially.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } @@ -765,6 +780,10 @@ namespace Grpc.Testing { output.WriteRawTag(128, 1); output.WriteInt32(BackendChannelIdx); } + if (EchoMetadataInitially != false) { + output.WriteRawTag(136, 1); + output.WriteBool(EchoMetadataInitially); + } if (_unknownFields != null) { _unknownFields.WriteTo(output); } @@ -821,6 +840,9 @@ namespace Grpc.Testing { if (BackendChannelIdx != 0) { size += 2 + pb::CodedOutputStream.ComputeInt32Size(BackendChannelIdx); } + if (EchoMetadataInitially != false) { + size += 2 + 1; + } if (_unknownFields != null) { size += _unknownFields.CalculateSize(); } @@ -886,6 +908,9 @@ namespace Grpc.Testing { if (other.BackendChannelIdx != 0) { BackendChannelIdx = other.BackendChannelIdx; } + if (other.EchoMetadataInitially != false) { + EchoMetadataInitially = other.EchoMetadataInitially; + } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } @@ -967,6 +992,10 @@ namespace Grpc.Testing { BackendChannelIdx = input.ReadInt32(); break; } + case 136: { + EchoMetadataInitially = input.ReadBool(); + break; + } } } } diff --git a/templates/grpc.gemspec.template b/templates/grpc.gemspec.template index d2b54a9c2f5..9ca797fe913 100644 --- a/templates/grpc.gemspec.template +++ b/templates/grpc.gemspec.template @@ -31,7 +31,7 @@ s.require_paths = %w( src/ruby/lib src/ruby/bin src/ruby/pb ) s.platform = Gem::Platform::RUBY - s.add_dependency 'google-protobuf', '~> 3.7' + s.add_dependency 'google-protobuf', '~> 3.8.0' s.add_dependency 'googleapis-common-protos-types', '~> 1.0' s.add_development_dependency 'bundler', '~> 1.9' diff --git a/tools/distrib/python/grpcio_tools/protoc_lib_deps.py b/tools/distrib/python/grpcio_tools/protoc_lib_deps.py index e7e4ba307ec..3eef24f7075 100644 --- a/tools/distrib/python/grpcio_tools/protoc_lib_deps.py +++ b/tools/distrib/python/grpcio_tools/protoc_lib_deps.py @@ -14,10 +14,10 @@ # limitations under the License. # AUTO-GENERATED BY make_grpcio_tools.py! -CC_FILES=['google/protobuf/compiler/zip_writer.cc', 'google/protobuf/compiler/subprocess.cc', 'google/protobuf/compiler/ruby/ruby_generator.cc', 'google/protobuf/compiler/python/python_generator.cc', 'google/protobuf/compiler/plugin.pb.cc', 'google/protobuf/compiler/plugin.cc', 'google/protobuf/compiler/php/php_generator.cc', 'google/protobuf/compiler/objectivec/objectivec_primitive_field.cc', 'google/protobuf/compiler/objectivec/objectivec_oneof.cc', 'google/protobuf/compiler/objectivec/objectivec_message_field.cc', 'google/protobuf/compiler/objectivec/objectivec_message.cc', 'google/protobuf/compiler/objectivec/objectivec_map_field.cc', 'google/protobuf/compiler/objectivec/objectivec_helpers.cc', 'google/protobuf/compiler/objectivec/objectivec_generator.cc', 'google/protobuf/compiler/objectivec/objectivec_file.cc', 'google/protobuf/compiler/objectivec/objectivec_field.cc', 'google/protobuf/compiler/objectivec/objectivec_extension.cc', 'google/protobuf/compiler/objectivec/objectivec_enum_field.cc', 'google/protobuf/compiler/objectivec/objectivec_enum.cc', 'google/protobuf/compiler/js/well_known_types_embed.cc', 'google/protobuf/compiler/js/js_generator.cc', 'google/protobuf/compiler/java/java_string_field_lite.cc', 'google/protobuf/compiler/java/java_string_field.cc', 'google/protobuf/compiler/java/java_shared_code_generator.cc', 'google/protobuf/compiler/java/java_service.cc', 'google/protobuf/compiler/java/java_primitive_field_lite.cc', 'google/protobuf/compiler/java/java_primitive_field.cc', 'google/protobuf/compiler/java/java_name_resolver.cc', 'google/protobuf/compiler/java/java_message_lite.cc', 'google/protobuf/compiler/java/java_message_field_lite.cc', 'google/protobuf/compiler/java/java_message_field.cc', 'google/protobuf/compiler/java/java_message_builder_lite.cc', 'google/protobuf/compiler/java/java_message_builder.cc', 'google/protobuf/compiler/java/java_message.cc', 'google/protobuf/compiler/java/java_map_field_lite.cc', 'google/protobuf/compiler/java/java_map_field.cc', 'google/protobuf/compiler/java/java_helpers.cc', 'google/protobuf/compiler/java/java_generator_factory.cc', 'google/protobuf/compiler/java/java_generator.cc', 'google/protobuf/compiler/java/java_file.cc', 'google/protobuf/compiler/java/java_field.cc', 'google/protobuf/compiler/java/java_extension_lite.cc', 'google/protobuf/compiler/java/java_extension.cc', 'google/protobuf/compiler/java/java_enum_lite.cc', 'google/protobuf/compiler/java/java_enum_field_lite.cc', 'google/protobuf/compiler/java/java_enum_field.cc', 'google/protobuf/compiler/java/java_enum.cc', 'google/protobuf/compiler/java/java_doc_comment.cc', 'google/protobuf/compiler/java/java_context.cc', 'google/protobuf/compiler/csharp/csharp_wrapper_field.cc', 'google/protobuf/compiler/csharp/csharp_source_generator_base.cc', 'google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc', 'google/protobuf/compiler/csharp/csharp_repeated_message_field.cc', 'google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc', 'google/protobuf/compiler/csharp/csharp_reflection_class.cc', 'google/protobuf/compiler/csharp/csharp_primitive_field.cc', 'google/protobuf/compiler/csharp/csharp_message_field.cc', 'google/protobuf/compiler/csharp/csharp_message.cc', 'google/protobuf/compiler/csharp/csharp_map_field.cc', 'google/protobuf/compiler/csharp/csharp_helpers.cc', 'google/protobuf/compiler/csharp/csharp_generator.cc', 'google/protobuf/compiler/csharp/csharp_field_base.cc', 'google/protobuf/compiler/csharp/csharp_enum_field.cc', 'google/protobuf/compiler/csharp/csharp_enum.cc', 'google/protobuf/compiler/csharp/csharp_doc_comment.cc', 'google/protobuf/compiler/cpp/cpp_string_field.cc', 'google/protobuf/compiler/cpp/cpp_service.cc', 'google/protobuf/compiler/cpp/cpp_primitive_field.cc', 'google/protobuf/compiler/cpp/cpp_padding_optimizer.cc', 'google/protobuf/compiler/cpp/cpp_message_field.cc', 'google/protobuf/compiler/cpp/cpp_message.cc', 'google/protobuf/compiler/cpp/cpp_map_field.cc', 'google/protobuf/compiler/cpp/cpp_helpers.cc', 'google/protobuf/compiler/cpp/cpp_generator.cc', 'google/protobuf/compiler/cpp/cpp_file.cc', 'google/protobuf/compiler/cpp/cpp_field.cc', 'google/protobuf/compiler/cpp/cpp_extension.cc', 'google/protobuf/compiler/cpp/cpp_enum_field.cc', 'google/protobuf/compiler/cpp/cpp_enum.cc', 'google/protobuf/compiler/command_line_interface.cc', 'google/protobuf/compiler/code_generator.cc', 'google/protobuf/wrappers.pb.cc', 'google/protobuf/wire_format.cc', 'google/protobuf/util/type_resolver_util.cc', 'google/protobuf/util/time_util.cc', 'google/protobuf/util/message_differencer.cc', 'google/protobuf/util/json_util.cc', 'google/protobuf/util/internal/utility.cc', 'google/protobuf/util/internal/type_info_test_helper.cc', 'google/protobuf/util/internal/type_info.cc', 'google/protobuf/util/internal/protostream_objectwriter.cc', 'google/protobuf/util/internal/protostream_objectsource.cc', 'google/protobuf/util/internal/proto_writer.cc', 'google/protobuf/util/internal/object_writer.cc', 'google/protobuf/util/internal/json_stream_parser.cc', 'google/protobuf/util/internal/json_objectwriter.cc', 'google/protobuf/util/internal/json_escaping.cc', 'google/protobuf/util/internal/field_mask_utility.cc', 'google/protobuf/util/internal/error_listener.cc', 'google/protobuf/util/internal/default_value_objectwriter.cc', 'google/protobuf/util/internal/datapiece.cc', 'google/protobuf/util/field_mask_util.cc', 'google/protobuf/util/field_comparator.cc', 'google/protobuf/util/delimited_message_util.cc', 'google/protobuf/unknown_field_set.cc', 'google/protobuf/type.pb.cc', 'google/protobuf/timestamp.pb.cc', 'google/protobuf/text_format.cc', 'google/protobuf/stubs/substitute.cc', 'google/protobuf/stubs/mathlimits.cc', 'google/protobuf/struct.pb.cc', 'google/protobuf/source_context.pb.cc', 'google/protobuf/service.cc', 'google/protobuf/reflection_ops.cc', 'google/protobuf/message.cc', 'google/protobuf/map_field.cc', 'google/protobuf/io/zero_copy_stream_impl.cc', 'google/protobuf/io/tokenizer.cc', 'google/protobuf/io/strtod.cc', 'google/protobuf/io/printer.cc', 'google/protobuf/io/gzip_stream.cc', 'google/protobuf/generated_message_table_driven.cc', 'google/protobuf/generated_message_reflection.cc', 'google/protobuf/field_mask.pb.cc', 'google/protobuf/extension_set_heavy.cc', 'google/protobuf/empty.pb.cc', 'google/protobuf/dynamic_message.cc', 'google/protobuf/duration.pb.cc', 'google/protobuf/descriptor_database.cc', 'google/protobuf/descriptor.pb.cc', 'google/protobuf/descriptor.cc', 'google/protobuf/compiler/parser.cc', 'google/protobuf/compiler/importer.cc', 'google/protobuf/api.pb.cc', 'google/protobuf/any.pb.cc', 'google/protobuf/any.cc', 'google/protobuf/wire_format_lite.cc', 'google/protobuf/stubs/time.cc', 'google/protobuf/stubs/strutil.cc', 'google/protobuf/stubs/structurally_valid.cc', 'google/protobuf/stubs/stringprintf.cc', 'google/protobuf/stubs/stringpiece.cc', 'google/protobuf/stubs/statusor.cc', 'google/protobuf/stubs/status.cc', 'google/protobuf/stubs/io_win32.cc', 'google/protobuf/stubs/int128.cc', 'google/protobuf/stubs/common.cc', 'google/protobuf/stubs/bytestream.cc', 'google/protobuf/repeated_field.cc', 'google/protobuf/message_lite.cc', 'google/protobuf/io/zero_copy_stream_impl_lite.cc', 'google/protobuf/io/zero_copy_stream.cc', 'google/protobuf/io/coded_stream.cc', 'google/protobuf/implicit_weak_message.cc', 'google/protobuf/generated_message_util.cc', 'google/protobuf/generated_message_table_driven_lite.cc', 'google/protobuf/extension_set.cc', 'google/protobuf/arena.cc'] +CC_FILES=['google/protobuf/compiler/zip_writer.cc', 'google/protobuf/compiler/subprocess.cc', 'google/protobuf/compiler/ruby/ruby_generator.cc', 'google/protobuf/compiler/python/python_generator.cc', 'google/protobuf/compiler/plugin.pb.cc', 'google/protobuf/compiler/plugin.cc', 'google/protobuf/compiler/php/php_generator.cc', 'google/protobuf/compiler/objectivec/objectivec_primitive_field.cc', 'google/protobuf/compiler/objectivec/objectivec_oneof.cc', 'google/protobuf/compiler/objectivec/objectivec_message_field.cc', 'google/protobuf/compiler/objectivec/objectivec_message.cc', 'google/protobuf/compiler/objectivec/objectivec_map_field.cc', 'google/protobuf/compiler/objectivec/objectivec_helpers.cc', 'google/protobuf/compiler/objectivec/objectivec_generator.cc', 'google/protobuf/compiler/objectivec/objectivec_file.cc', 'google/protobuf/compiler/objectivec/objectivec_field.cc', 'google/protobuf/compiler/objectivec/objectivec_extension.cc', 'google/protobuf/compiler/objectivec/objectivec_enum_field.cc', 'google/protobuf/compiler/objectivec/objectivec_enum.cc', 'google/protobuf/compiler/js/well_known_types_embed.cc', 'google/protobuf/compiler/js/js_generator.cc', 'google/protobuf/compiler/java/java_string_field_lite.cc', 'google/protobuf/compiler/java/java_string_field.cc', 'google/protobuf/compiler/java/java_shared_code_generator.cc', 'google/protobuf/compiler/java/java_service.cc', 'google/protobuf/compiler/java/java_primitive_field_lite.cc', 'google/protobuf/compiler/java/java_primitive_field.cc', 'google/protobuf/compiler/java/java_name_resolver.cc', 'google/protobuf/compiler/java/java_message_lite.cc', 'google/protobuf/compiler/java/java_message_field_lite.cc', 'google/protobuf/compiler/java/java_message_field.cc', 'google/protobuf/compiler/java/java_message_builder_lite.cc', 'google/protobuf/compiler/java/java_message_builder.cc', 'google/protobuf/compiler/java/java_message.cc', 'google/protobuf/compiler/java/java_map_field_lite.cc', 'google/protobuf/compiler/java/java_map_field.cc', 'google/protobuf/compiler/java/java_helpers.cc', 'google/protobuf/compiler/java/java_generator_factory.cc', 'google/protobuf/compiler/java/java_generator.cc', 'google/protobuf/compiler/java/java_file.cc', 'google/protobuf/compiler/java/java_field.cc', 'google/protobuf/compiler/java/java_extension_lite.cc', 'google/protobuf/compiler/java/java_extension.cc', 'google/protobuf/compiler/java/java_enum_lite.cc', 'google/protobuf/compiler/java/java_enum_field_lite.cc', 'google/protobuf/compiler/java/java_enum_field.cc', 'google/protobuf/compiler/java/java_enum.cc', 'google/protobuf/compiler/java/java_doc_comment.cc', 'google/protobuf/compiler/java/java_context.cc', 'google/protobuf/compiler/csharp/csharp_wrapper_field.cc', 'google/protobuf/compiler/csharp/csharp_source_generator_base.cc', 'google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc', 'google/protobuf/compiler/csharp/csharp_repeated_message_field.cc', 'google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc', 'google/protobuf/compiler/csharp/csharp_reflection_class.cc', 'google/protobuf/compiler/csharp/csharp_primitive_field.cc', 'google/protobuf/compiler/csharp/csharp_message_field.cc', 'google/protobuf/compiler/csharp/csharp_message.cc', 'google/protobuf/compiler/csharp/csharp_map_field.cc', 'google/protobuf/compiler/csharp/csharp_helpers.cc', 'google/protobuf/compiler/csharp/csharp_generator.cc', 'google/protobuf/compiler/csharp/csharp_field_base.cc', 'google/protobuf/compiler/csharp/csharp_enum_field.cc', 'google/protobuf/compiler/csharp/csharp_enum.cc', 'google/protobuf/compiler/csharp/csharp_doc_comment.cc', 'google/protobuf/compiler/cpp/cpp_string_field.cc', 'google/protobuf/compiler/cpp/cpp_service.cc', 'google/protobuf/compiler/cpp/cpp_primitive_field.cc', 'google/protobuf/compiler/cpp/cpp_padding_optimizer.cc', 'google/protobuf/compiler/cpp/cpp_message_field.cc', 'google/protobuf/compiler/cpp/cpp_message.cc', 'google/protobuf/compiler/cpp/cpp_map_field.cc', 'google/protobuf/compiler/cpp/cpp_helpers.cc', 'google/protobuf/compiler/cpp/cpp_generator.cc', 'google/protobuf/compiler/cpp/cpp_file.cc', 'google/protobuf/compiler/cpp/cpp_field.cc', 'google/protobuf/compiler/cpp/cpp_extension.cc', 'google/protobuf/compiler/cpp/cpp_enum_field.cc', 'google/protobuf/compiler/cpp/cpp_enum.cc', 'google/protobuf/compiler/command_line_interface.cc', 'google/protobuf/compiler/code_generator.cc', 'google/protobuf/wrappers.pb.cc', 'google/protobuf/wire_format.cc', 'google/protobuf/util/type_resolver_util.cc', 'google/protobuf/util/time_util.cc', 'google/protobuf/util/message_differencer.cc', 'google/protobuf/util/json_util.cc', 'google/protobuf/util/internal/utility.cc', 'google/protobuf/util/internal/type_info_test_helper.cc', 'google/protobuf/util/internal/type_info.cc', 'google/protobuf/util/internal/protostream_objectwriter.cc', 'google/protobuf/util/internal/protostream_objectsource.cc', 'google/protobuf/util/internal/proto_writer.cc', 'google/protobuf/util/internal/object_writer.cc', 'google/protobuf/util/internal/json_stream_parser.cc', 'google/protobuf/util/internal/json_objectwriter.cc', 'google/protobuf/util/internal/json_escaping.cc', 'google/protobuf/util/internal/field_mask_utility.cc', 'google/protobuf/util/internal/error_listener.cc', 'google/protobuf/util/internal/default_value_objectwriter.cc', 'google/protobuf/util/internal/datapiece.cc', 'google/protobuf/util/field_mask_util.cc', 'google/protobuf/util/field_comparator.cc', 'google/protobuf/util/delimited_message_util.cc', 'google/protobuf/unknown_field_set.cc', 'google/protobuf/type.pb.cc', 'google/protobuf/timestamp.pb.cc', 'google/protobuf/text_format.cc', 'google/protobuf/stubs/substitute.cc', 'google/protobuf/stubs/mathlimits.cc', 'google/protobuf/struct.pb.cc', 'google/protobuf/source_context.pb.cc', 'google/protobuf/service.cc', 'google/protobuf/reflection_ops.cc', 'google/protobuf/message.cc', 'google/protobuf/map_field.cc', 'google/protobuf/io/zero_copy_stream_impl.cc', 'google/protobuf/io/tokenizer.cc', 'google/protobuf/io/printer.cc', 'google/protobuf/io/gzip_stream.cc', 'google/protobuf/generated_message_table_driven.cc', 'google/protobuf/generated_message_reflection.cc', 'google/protobuf/field_mask.pb.cc', 'google/protobuf/extension_set_heavy.cc', 'google/protobuf/empty.pb.cc', 'google/protobuf/dynamic_message.cc', 'google/protobuf/duration.pb.cc', 'google/protobuf/descriptor_database.cc', 'google/protobuf/descriptor.pb.cc', 'google/protobuf/descriptor.cc', 'google/protobuf/compiler/parser.cc', 'google/protobuf/compiler/importer.cc', 'google/protobuf/api.pb.cc', 'google/protobuf/any.pb.cc', 'google/protobuf/any.cc', 'google/protobuf/wire_format_lite.cc', 'google/protobuf/stubs/time.cc', 'google/protobuf/stubs/strutil.cc', 'google/protobuf/stubs/structurally_valid.cc', 'google/protobuf/stubs/stringprintf.cc', 'google/protobuf/stubs/stringpiece.cc', 'google/protobuf/stubs/statusor.cc', 'google/protobuf/stubs/status.cc', 'google/protobuf/stubs/int128.cc', 'google/protobuf/stubs/common.cc', 'google/protobuf/stubs/bytestream.cc', 'google/protobuf/repeated_field.cc', 'google/protobuf/parse_context.cc', 'google/protobuf/message_lite.cc', 'google/protobuf/io/zero_copy_stream_impl_lite.cc', 'google/protobuf/io/zero_copy_stream.cc', 'google/protobuf/io/strtod.cc', 'google/protobuf/io/io_win32.cc', 'google/protobuf/io/coded_stream.cc', 'google/protobuf/implicit_weak_message.cc', 'google/protobuf/generated_message_util.cc', 'google/protobuf/generated_message_table_driven_lite.cc', 'google/protobuf/extension_set.cc', 'google/protobuf/arena.cc', 'google/protobuf/any_lite.cc'] PROTO_FILES=['google/protobuf/wrappers.proto', 'google/protobuf/type.proto', 'google/protobuf/timestamp.proto', 'google/protobuf/struct.proto', 'google/protobuf/source_context.proto', 'google/protobuf/field_mask.proto', 'google/protobuf/empty.proto', 'google/protobuf/duration.proto', 'google/protobuf/descriptor.proto', 'google/protobuf/compiler/plugin.proto', 'google/protobuf/api.proto', 'google/protobuf/any.proto'] CC_INCLUDE='third_party/protobuf/src' PROTO_INCLUDE='third_party/protobuf/src' -PROTOBUF_SUBMODULE_VERSION="582743bf40c5d3639a70f98f183914a2c0cd0680" +PROTOBUF_SUBMODULE_VERSION="09745575a923640154bcf307fba8aedff47f240a" diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index b15b8d3b077..487479ba3da 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -38,7 +38,7 @@ cat << EOF | awk '{ print $1 }' | sort > "$want_submodules" ec44c6c1675c25b9827aacd08c02433cccde7780 third_party/googletest (release-1.8.0) 6599cac0965be8e5a835ab7a5684bbef033d5ad0 third_party/libcxx (heads/release_60) 9245d481eb3e890f708ff2d7dadf2a10c04748ba third_party/libcxxabi (heads/release_60) - 582743bf40c5d3639a70f98f183914a2c0cd0680 third_party/protobuf (v3.7.0-rc.2-20-g582743bf) + 09745575a923640154bcf307fba8aedff47f240a third_party/protobuf (v3.7.0-rc.2-247-g09745575) e143189bf6f37b3957fb31743df6a1bcf4a8c685 third_party/protoc-gen-validate (v0.0.10) fa88c6017ddb490aa78c57bea682193f533ed69a third_party/upb (heads/master) cacf7f1d4e3d44d871b605da3b647f07d718623f third_party/zlib (v1.2.11) From 724565372f3b1301f98776bfdc2460b58b50fcbc Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 29 May 2019 16:42:06 -0700 Subject: [PATCH 0371/1555] Fix the ref count issue --- src/core/lib/surface/completion_queue.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index 9b30b3998a5..e883d472278 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -820,7 +820,6 @@ static void cq_end_op_for_pluck( static void functor_callback(void* arg, grpc_error* error) { auto* functor = static_cast(arg); functor->functor_run(functor, error == GRPC_ERROR_NONE); - GRPC_ERROR_UNREF(error); } /* Complete an event on a completion queue of type GRPC_CQ_CALLBACK */ From fc002a4d02656a7f21c29dbb6ac22a93181e7c75 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 29 May 2019 16:59:10 -0700 Subject: [PATCH 0372/1555] Remove ref for GRPC_ERROR_NONE --- src/core/lib/surface/completion_queue.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index e883d472278..60a7d78b525 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -1356,7 +1356,7 @@ static void cq_finish_shutdown_callback(grpc_completion_queue* cq) { GRPC_CLOSURE_CREATE( functor_callback, callback, grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), - GRPC_ERROR_REF(GRPC_ERROR_NONE)); + GRPC_ERROR_NONE); } static void cq_shutdown_callback(grpc_completion_queue* cq) { From 79f7abb45eab9f6f49ba694d4f8ce70f8e142b1d Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Wed, 29 May 2019 17:07:00 -0700 Subject: [PATCH 0373/1555] Update zlib dependency --- BUILD | 2 +- bazel/grpc_deps.bzl | 8 ++++---- third_party/zlib.BUILD | 2 +- tools/run_tests/sanity/check_bazel_workspace.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/BUILD b/BUILD index 52c469f0b4a..b944d96c64b 100644 --- a/BUILD +++ b/BUILD @@ -1030,7 +1030,7 @@ grpc_cc_library( "src/core/lib/uri/uri_parser.h", ], external_deps = [ - "zlib", + "madler_zlib", ], language = "c++", public_hdrs = GRPC_PUBLIC_HDRS, diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 08022942be0..ac1ed5cbbef 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -32,8 +32,8 @@ def grpc_deps(): ) native.bind( - name = "zlib", - actual = "@com_github_madler_zlib//:z", + name = "madler_zlib", + actual = "@zlib//:zlib", ) native.bind( @@ -115,9 +115,9 @@ def grpc_deps(): url = "https://boringssl.googlesource.com/boringssl/+archive/afc30d43eef92979b05776ec0963c9cede5fb80f.tar.gz", ) - if "com_github_madler_zlib" not in native.existing_rules(): + if "zlib" not in native.existing_rules(): http_archive( - name = "com_github_madler_zlib", + name = "zlib", build_file = "@com_github_grpc_grpc//third_party:zlib.BUILD", sha256 = "6d4d6640ca3121620995ee255945161821218752b551a1a180f4215f7d124d45", strip_prefix = "zlib-cacf7f1d4e3d44d871b605da3b647f07d718623f", diff --git a/third_party/zlib.BUILD b/third_party/zlib.BUILD index a71c85fa98d..95ae7c5a89c 100644 --- a/third_party/zlib.BUILD +++ b/third_party/zlib.BUILD @@ -1,5 +1,5 @@ cc_library( - name = "z", + name = "zlib", srcs = [ "adler32.c", "compress.c", diff --git a/tools/run_tests/sanity/check_bazel_workspace.py b/tools/run_tests/sanity/check_bazel_workspace.py index 2017f58323c..65aa72183d0 100755 --- a/tools/run_tests/sanity/check_bazel_workspace.py +++ b/tools/run_tests/sanity/check_bazel_workspace.py @@ -45,7 +45,7 @@ _TWISTED_CONSTANTLY_DEP_NAME = 'com_github_twisted_constantly' _GRPC_DEP_NAMES = [ 'upb', 'boringssl', - 'com_github_madler_zlib', + 'zlib', 'com_google_protobuf', 'com_github_google_googletest', 'com_github_gflags_gflags', From facf4b30118a513ed264e21ca3b51eed954ba707 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Wed, 29 May 2019 22:02:11 -0700 Subject: [PATCH 0374/1555] PHP: Fix ZTS build error --- src/php/ext/grpc/php_grpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/php/ext/grpc/php_grpc.c b/src/php/ext/grpc/php_grpc.c index 1098075690a..74f536ea07b 100644 --- a/src/php/ext/grpc/php_grpc.c +++ b/src/php/ext/grpc/php_grpc.c @@ -203,7 +203,7 @@ void register_fork_handlers() { } } -void apply_ini_settings() { +void apply_ini_settings(TSRMLS_D) { if (GRPC_G(enable_fork_support)) { char *enable_str = malloc(sizeof("GRPC_ENABLE_FORK_SUPPORT=1")); strcpy(enable_str, "GRPC_ENABLE_FORK_SUPPORT=1"); @@ -392,7 +392,7 @@ PHP_MINFO_FUNCTION(grpc) { */ PHP_RINIT_FUNCTION(grpc) { if (!GRPC_G(initialized)) { - apply_ini_settings(); + apply_ini_settings(TSRMLS_C); grpc_init(); register_fork_handlers(); grpc_php_init_completion_queue(TSRMLS_C); From 1259579a945ee442225bb79cbcf0ef01fd470d52 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 30 May 2019 08:25:17 -0700 Subject: [PATCH 0375/1555] clang-format --- src/objective-c/GRPCClient/GRPCCall.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index ba91640269e..52ba1356929 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -649,7 +649,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; - (void)dealloc { [GRPCConnectivityMonitor unregisterObserver:self]; - + __block GRPCWrappedCall *wrappedCall = _wrappedCall; dispatch_async(_callQueue, ^{ wrappedCall = nil; From eb62ad3fae8a213c3d60ba24312c71323c1de7bf Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 30 May 2019 10:22:39 -0700 Subject: [PATCH 0376/1555] address comments --- src/objective-c/GRPCClient/GRPCInterceptor.h | 2 +- src/objective-c/GRPCClient/GRPCInterceptor.m | 50 ++++++++++++-------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.h b/src/objective-c/GRPCClient/GRPCInterceptor.h index 4b7bcdbff40..3b62c1b3ec0 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.h +++ b/src/objective-c/GRPCClient/GRPCInterceptor.h @@ -74,7 +74,7 @@ * receiveNextMessages * didReceiveInitialMetadata * didReceiveData - * didWriteData + * didWriteData receiveNextmessages * writeData ----- ----- ---- didReceiveInitialMetadata * receiveNextMessages | | | | | | didReceiveData * | V | V | V didWriteData diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.m b/src/objective-c/GRPCClient/GRPCInterceptor.m index bf043fcd1f5..a385ecd7813 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.m +++ b/src/objective-c/GRPCClient/GRPCInterceptor.m @@ -44,39 +44,49 @@ - (void)startNextInterceptorWithRequest:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; - }); + if (_nextInterceptor != nil) { + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ + [copiedNextInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; + }); + } } - (void)writeNextInterceptorWithData:(id)data { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor writeData:data]; - }); + if (_nextInterceptor != nil) { + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ + [copiedNextInterceptor writeData:data]; + }); + } } - (void)finishNextInterceptor { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor finish]; - }); + if (_nextInterceptor != nil) { + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ + [copiedNextInterceptor finish]; + }); + } } - (void)cancelNextInterceptor { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor cancel]; - }); + if (_nextInterceptor != nil) { + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ + [copiedNextInterceptor cancel]; + }); + } } /** Notify the next interceptor in the chain to receive more messages */ - (void)receiveNextInterceptorMessages:(NSUInteger)numberOfMessages { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor receiveNextMessages:numberOfMessages]; - }); + if (_nextInterceptor != nil) { + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ + [copiedNextInterceptor receiveNextMessages:numberOfMessages]; + }); + } } // Methods to forward GRPCResponseHandler callbacks to the previous object From cf0559197193581607030297edbc96e376f32131 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 30 May 2019 14:50:28 -0700 Subject: [PATCH 0377/1555] Add comment about LoggingInterceptor --- test/cpp/end2end/client_interceptors_end2end_test.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/cpp/end2end/client_interceptors_end2end_test.cc b/test/cpp/end2end/client_interceptors_end2end_test.cc index d548a023bd1..583513edaa4 100644 --- a/test/cpp/end2end/client_interceptors_end2end_test.cc +++ b/test/cpp/end2end/client_interceptors_end2end_test.cc @@ -499,6 +499,10 @@ class BidiStreamingRpcHijackingInterceptorFactory } }; +// The logging interceptor is for testing purposes only. It is used to verify +// that all the appropriate hook points are invoked for an RPC. The counts are +// reset each time a new object of LoggingInterceptor is created, so only a +// single RPC should be made on the channel before calling the Verify methods. class LoggingInterceptor : public experimental::Interceptor { public: LoggingInterceptor(experimental::ClientRpcInfo* info) { From a874fd8bbbcb3bbc729cc98857e5417a9b523ed1 Mon Sep 17 00:00:00 2001 From: yang-g Date: Thu, 30 May 2019 15:20:10 -0700 Subject: [PATCH 0378/1555] Resolve review comments --- src/core/lib/security/transport/client_auth_filter.cc | 7 +++---- src/cpp/client/secure_credentials.cc | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/lib/security/transport/client_auth_filter.cc b/src/core/lib/security/transport/client_auth_filter.cc index dbe288237d4..1062fc2f4fa 100644 --- a/src/core/lib/security/transport/client_auth_filter.cc +++ b/src/core/lib/security/transport/client_auth_filter.cc @@ -121,11 +121,10 @@ void grpc_auth_metadata_context_copy(grpc_auth_metadata_context* from, ->Ref(DEBUG_LOCATION, "grpc_auth_metadata_context_copy") .release(); } - to->service_url = - (from->service_url == nullptr) ? nullptr : strdup(from->service_url); - to->method_name = - (from->method_name == nullptr) ? nullptr : strdup(from->method_name); + to->service_url = gpr_strdup(from->service_url); + to->method_name = gpr_strdup(from->method_name); } + void grpc_auth_metadata_context_reset( grpc_auth_metadata_context* auth_md_context) { if (auth_md_context->service_url != nullptr) { diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index 3d2a123180b..197112d4bb7 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -259,6 +259,8 @@ int MetadataCredentialsPluginWrapper::GetMetadata( return true; } if (w->plugin_->IsBlocking()) { + // The internals of context may be destroyed if GetMetadata is cancelled. + // Make a copy for InvokePlugin. grpc_auth_metadata_context context_copy = grpc_auth_metadata_context(); grpc_auth_metadata_context_copy(&context, &context_copy); // Asynchronous return. From f671b3d1366df06619a7d31e4b45b73d0898ef84 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 30 May 2019 15:39:37 -0700 Subject: [PATCH 0379/1555] Add hijacking interception hook points as valid for the GetRecv* functions --- include/grpcpp/impl/codegen/interceptor.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/include/grpcpp/impl/codegen/interceptor.h b/include/grpcpp/impl/codegen/interceptor.h index b0f57f71196..18c7cf33e2f 100644 --- a/include/grpcpp/impl/codegen/interceptor.h +++ b/include/grpcpp/impl/codegen/interceptor.h @@ -174,20 +174,22 @@ class InterceptorBatchMethods { /// Returns a pointer to the modifiable received message. Note that the /// message is already deserialized but the type is not set; the interceptor /// should static_cast to the appropriate type before using it. This is valid - /// for POST_RECV_MESSAGE interceptions; nullptr for not valid + /// for PRE_RECV_MESSAGE and POST_RECV_MESSAGE interceptions; nullptr for not + /// valid virtual void* GetRecvMessage() = 0; /// Returns a modifiable multimap of the received initial metadata. - /// Valid for POST_RECV_INITIAL_METADATA interceptions; nullptr if not valid + /// Valid for PRE_RECV_INITIAL_METADATA and POST_RECV_INITIAL_METADATA + /// interceptions; nullptr if not valid virtual std::multimap* GetRecvInitialMetadata() = 0; - /// Returns a modifiable view of the received status on POST_RECV_STATUS - /// interceptions; nullptr if not valid. + /// Returns a modifiable view of the received status on PRE_RECV_STATUS and + /// POST_RECV_STATUS interceptions; nullptr if not valid. virtual Status* GetRecvStatus() = 0; /// Returns a modifiable multimap of the received trailing metadata on - /// POST_RECV_STATUS interceptions; nullptr if not valid + /// PRE_RECV_STATUS and POST_RECV_STATUS interceptions; nullptr if not valid virtual std::multimap* GetRecvTrailingMetadata() = 0; From a887f35a9ba5faff7416290e4bde37a062683386 Mon Sep 17 00:00:00 2001 From: Yihua Zhang Date: Thu, 30 May 2019 16:00:50 -0700 Subject: [PATCH 0380/1555] add a new struct - grpc_ssl_verify_peer_options and an API - grpc_ssl_credentials_create_ex. --- grpc.def | 1 + include/grpc/grpc_security.h | 61 ++++++++++++++++++- .../credentials/ssl/ssl_credentials.cc | 22 ++++++- .../credentials/ssl/ssl_credentials.h | 4 +- src/ruby/ext/grpc/rb_grpc_imports.generated.c | 2 + src/ruby/ext/grpc/rb_grpc_imports.generated.h | 3 + .../core/surface/public_headers_must_be_c89.c | 1 + 7 files changed, 87 insertions(+), 7 deletions(-) diff --git a/grpc.def b/grpc.def index 922f95383a3..32289dffeb7 100644 --- a/grpc.def +++ b/grpc.def @@ -101,6 +101,7 @@ EXPORTS grpc_google_default_credentials_create grpc_set_ssl_roots_override_callback grpc_ssl_credentials_create + grpc_ssl_credentials_create_ex grpc_call_credentials_release grpc_composite_channel_credentials_create grpc_composite_call_credentials_create diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h index ebdf86b7d50..12a94dc95ea 100644 --- a/include/grpc/grpc_security.h +++ b/include/grpc/grpc_security.h @@ -163,8 +163,10 @@ typedef struct { const char* cert_chain; } grpc_ssl_pem_key_cert_pair; -/** Object that holds additional peer-verification options on a secure - channel. */ +/** Deprecated in favor of grpc_ssl_verify_peer_options. It will be removed + after all of its call sites are migrated to grpc_ssl_verify_peer_options. + Object that holds additional peer-verification options on a secure + channel. */ typedef struct { /** If non-NULL this callback will be invoked with the expected target_name, the peer's certificate (in PEM format), and whatever @@ -183,7 +185,29 @@ typedef struct { void (*verify_peer_destruct)(void* userdata); } verify_peer_options; -/** Creates an SSL credentials object. +/** Object that holds additional peer-verification options on a secure + channel. */ +typedef struct { + /** If non-NULL this callback will be invoked with the expected + target_name, the peer's certificate (in PEM format), and whatever + userdata pointer is set below. If a non-zero value is returned by this + callback then it is treated as a verification failure. Invocation of + the callback is blocking, so any implementation should be light-weight. + */ + int (*verify_peer_callback)(const char* target_name, const char* peer_pem, + void* userdata); + /** Arbitrary userdata that will be passed as the last argument to + verify_peer_callback. */ + void* verify_peer_callback_userdata; + /** A destruct callback that will be invoked when the channel is being + cleaned up. The userdata argument will be passed to it. The intent is + to perform any cleanup associated with that userdata. */ + void (*verify_peer_destruct)(void* userdata); +} grpc_ssl_verify_peer_options; + +/** Deprecated in favor of grpc_ssl_server_credentials_create_ex. It will be + removed after all of its call sites are migrated to + grpc_ssl_server_credentials_create_ex. Creates an SSL credentials object. - pem_root_certs is the NULL-terminated string containing the PEM encoding of the server root certificates. If this parameter is NULL, the implementation will first try to dereference the file pointed by the @@ -214,6 +238,37 @@ GRPCAPI grpc_channel_credentials* grpc_ssl_credentials_create( const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, const verify_peer_options* verify_options, void* reserved); +/* Creates an SSL credentials object. + - pem_root_certs is the NULL-terminated string containing the PEM encoding + of the server root certificates. If this parameter is NULL, the + implementation will first try to dereference the file pointed by the + GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment variable, and if that fails, + try to get the roots set by grpc_override_ssl_default_roots. Eventually, + if all these fail, it will try to get the roots from a well-known place on + disk (in the grpc install directory). + + gRPC has implemented root cache if the underlying OpenSSL library supports + it. The gRPC root certificates cache is only applicable on the default + root certificates, which is used when this parameter is nullptr. If user + provides their own pem_root_certs, when creating an SSL credential object, + gRPC would not be able to cache it, and each subchannel will generate a + copy of the root store. So it is recommended to avoid providing large room + pem with pem_root_certs parameter to avoid excessive memory consumption, + particularly on mobile platforms such as iOS. + - pem_key_cert_pair is a pointer on the object containing client's private + key and certificate chain. This parameter can be NULL if the client does + not have such a key/cert pair. + - verify_options is an optional verify_peer_options object which holds + additional options controlling how peer certificates are verified. For + example, you can supply a callback which receives the peer's certificate + with which you can do additional verification. Can be NULL, in which + case verification will retain default behavior. Any settings in + verify_options are copied during this call, so the verify_options + object can be released afterwards. */ +GRPCAPI grpc_channel_credentials* grpc_ssl_credentials_create_ex( + const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, + const grpc_ssl_verify_peer_options* verify_options, void* reserved); + /** --- grpc_call_credentials object. A call credentials object represents a way to authenticate on a particular diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.cc b/src/core/lib/security/credentials/ssl/ssl_credentials.cc index 83db86f1eac..65e57cebeb5 100644 --- a/src/core/lib/security/credentials/ssl/ssl_credentials.cc +++ b/src/core/lib/security/credentials/ssl/ssl_credentials.cc @@ -46,7 +46,7 @@ void grpc_tsi_ssl_pem_key_cert_pairs_destroy(tsi_ssl_pem_key_cert_pair* kp, grpc_ssl_credentials::grpc_ssl_credentials( const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, - const verify_peer_options* verify_options) + const grpc_ssl_verify_peer_options* verify_options) : grpc_channel_credentials(GRPC_CHANNEL_CREDENTIALS_TYPE_SSL) { build_config(pem_root_certs, pem_key_cert_pair, verify_options); } @@ -94,7 +94,7 @@ grpc_ssl_credentials::create_security_connector( void grpc_ssl_credentials::build_config( const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, - const verify_peer_options* verify_options) { + const grpc_ssl_verify_peer_options* verify_options) { config_.pem_root_certs = gpr_strdup(pem_root_certs); if (pem_key_cert_pair != nullptr) { GPR_ASSERT(pem_key_cert_pair->private_key != nullptr); @@ -117,6 +117,8 @@ void grpc_ssl_credentials::build_config( } } +/* Deprecated in favor of grpc_ssl_credentials_create_ex. Will be removed + * once all of its call sites are migrated to grpc_ssl_credentials_create_ex. */ grpc_channel_credentials* grpc_ssl_credentials_create( const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, const verify_peer_options* verify_options, void* reserved) { @@ -128,6 +130,22 @@ grpc_channel_credentials* grpc_ssl_credentials_create( 4, (pem_root_certs, pem_key_cert_pair, verify_options, reserved)); GPR_ASSERT(reserved == nullptr); + return grpc_core::New( + pem_root_certs, pem_key_cert_pair, + reinterpret_cast(verify_options)); +} + +grpc_channel_credentials* grpc_ssl_credentials_create_ex( + const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, + const grpc_ssl_verify_peer_options* verify_options, void* reserved) { + GRPC_API_TRACE( + "grpc_ssl_credentials_create(pem_root_certs=%s, " + "pem_key_cert_pair=%p, " + "verify_options=%p, " + "reserved=%p)", + 4, (pem_root_certs, pem_key_cert_pair, verify_options, reserved)); + GPR_ASSERT(reserved == nullptr); + return grpc_core::New(pem_root_certs, pem_key_cert_pair, verify_options); } diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.h b/src/core/lib/security/credentials/ssl/ssl_credentials.h index e1174327b30..545a27f0be4 100644 --- a/src/core/lib/security/credentials/ssl/ssl_credentials.h +++ b/src/core/lib/security/credentials/ssl/ssl_credentials.h @@ -28,7 +28,7 @@ class grpc_ssl_credentials : public grpc_channel_credentials { public: grpc_ssl_credentials(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, - const verify_peer_options* verify_options); + const grpc_ssl_verify_peer_options* verify_options); ~grpc_ssl_credentials() override; @@ -41,7 +41,7 @@ class grpc_ssl_credentials : public grpc_channel_credentials { private: void build_config(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, - const verify_peer_options* verify_options); + const grpc_ssl_verify_peer_options* verify_options); grpc_ssl_config config_; }; diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index f8a31286115..b1165a6d6eb 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -124,6 +124,7 @@ grpc_channel_credentials_release_type grpc_channel_credentials_release_import; grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import; grpc_set_ssl_roots_override_callback_type grpc_set_ssl_roots_override_callback_import; grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import; +grpc_ssl_credentials_create_ex_type grpc_ssl_credentials_create_ex_import; grpc_call_credentials_release_type grpc_call_credentials_release_import; grpc_composite_channel_credentials_create_type grpc_composite_channel_credentials_create_import; grpc_composite_call_credentials_create_type grpc_composite_call_credentials_create_import; @@ -393,6 +394,7 @@ void grpc_rb_load_imports(HMODULE library) { grpc_google_default_credentials_create_import = (grpc_google_default_credentials_create_type) GetProcAddress(library, "grpc_google_default_credentials_create"); grpc_set_ssl_roots_override_callback_import = (grpc_set_ssl_roots_override_callback_type) GetProcAddress(library, "grpc_set_ssl_roots_override_callback"); grpc_ssl_credentials_create_import = (grpc_ssl_credentials_create_type) GetProcAddress(library, "grpc_ssl_credentials_create"); + grpc_ssl_credentials_create_ex_import = (grpc_ssl_credentials_create_ex_type) GetProcAddress(library, "grpc_ssl_credentials_create_ex"); grpc_call_credentials_release_import = (grpc_call_credentials_release_type) GetProcAddress(library, "grpc_call_credentials_release"); grpc_composite_channel_credentials_create_import = (grpc_composite_channel_credentials_create_type) GetProcAddress(library, "grpc_composite_channel_credentials_create"); grpc_composite_call_credentials_create_import = (grpc_composite_call_credentials_create_type) GetProcAddress(library, "grpc_composite_call_credentials_create"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index c25d789a95b..5809194f1ae 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -347,6 +347,9 @@ extern grpc_set_ssl_roots_override_callback_type grpc_set_ssl_roots_override_cal typedef grpc_channel_credentials*(*grpc_ssl_credentials_create_type)(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, const verify_peer_options* verify_options, void* reserved); extern grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import; #define grpc_ssl_credentials_create grpc_ssl_credentials_create_import +typedef grpc_channel_credentials*(*grpc_ssl_credentials_create_ex_type)(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, const grpc_ssl_verify_peer_options* verify_options, void* reserved); +extern grpc_ssl_credentials_create_ex_type grpc_ssl_credentials_create_ex_import; +#define grpc_ssl_credentials_create_ex grpc_ssl_credentials_create_ex_import typedef void(*grpc_call_credentials_release_type)(grpc_call_credentials* creds); extern grpc_call_credentials_release_type grpc_call_credentials_release_import; #define grpc_call_credentials_release grpc_call_credentials_release_import diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c index fa02e76ec92..3aaa1e709ee 100644 --- a/test/core/surface/public_headers_must_be_c89.c +++ b/test/core/surface/public_headers_must_be_c89.c @@ -161,6 +161,7 @@ int main(int argc, char **argv) { printf("%lx", (unsigned long) grpc_google_default_credentials_create); printf("%lx", (unsigned long) grpc_set_ssl_roots_override_callback); printf("%lx", (unsigned long) grpc_ssl_credentials_create); + printf("%lx", (unsigned long) grpc_ssl_credentials_create_ex); printf("%lx", (unsigned long) grpc_call_credentials_release); printf("%lx", (unsigned long) grpc_composite_channel_credentials_create); printf("%lx", (unsigned long) grpc_composite_call_credentials_create); From b6e5827315e0b28c54c23c7ab9755814defb184e Mon Sep 17 00:00:00 2001 From: "1524995078@qq.com" <51152648+OceanOfWest@users.noreply.github.com> Date: Fri, 31 May 2019 10:31:37 +0800 Subject: [PATCH 0381/1555] remove python version number to release binding to exact version --- tools/run_tests/start_port_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/start_port_server.py b/tools/run_tests/start_port_server.py index 5b776f3b305..cca9859d1e9 100755 --- a/tools/run_tests/start_port_server.py +++ b/tools/run_tests/start_port_server.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python # Copyright 2017 gRPC authors. # From e3f976f4d5885d6645e0b5fa57f2eeb9af74652d Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 31 May 2019 07:27:18 -0700 Subject: [PATCH 0382/1555] Resolve merge issue --- .../tests/InteropTests/InteropTests.m | 75 ------------------- 1 file changed, 75 deletions(-) diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 70e75bf6990..7d4aee0bc90 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -80,81 +80,6 @@ BOOL isRemoteInteropTest(NSString *host) { return [host isEqualToString:@"grpc-test.sandbox.googleapis.com"]; } -// Convenience class to use blocks as callbacks -@interface InteropTestsBlockCallbacks : NSObject - -- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback - messageCallback:(void (^)(id))messageCallback - closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback - writeMessageCallback:(void (^)(void))writeMessageCallback; - -- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback - messageCallback:(void (^)(id))messageCallback - closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback; - -@end - -@implementation InteropTestsBlockCallbacks { - void (^_initialMetadataCallback)(NSDictionary *); - void (^_messageCallback)(id); - void (^_closeCallback)(NSDictionary *, NSError *); - void (^_writeMessageCallback)(void); - dispatch_queue_t _dispatchQueue; -} - -- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback - messageCallback:(void (^)(id))messageCallback - closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback - writeMessageCallback:(void (^)(void))writeMessageCallback { - if ((self = [super init])) { - _initialMetadataCallback = initialMetadataCallback; - _messageCallback = messageCallback; - _closeCallback = closeCallback; - _writeMessageCallback = writeMessageCallback; - _dispatchQueue = dispatch_queue_create(nil, DISPATCH_QUEUE_SERIAL); - } - return self; -} - -- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback - messageCallback:(void (^)(id))messageCallback - closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback { - return [self initWithInitialMetadataCallback:initialMetadataCallback - messageCallback:messageCallback - closeCallback:closeCallback - writeMessageCallback:nil]; -} - -- (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata { - if (_initialMetadataCallback) { - _initialMetadataCallback(initialMetadata); - } -} - -- (void)didReceiveProtoMessage:(GPBMessage *)message { - if (_messageCallback) { - _messageCallback(message); - } -} - -- (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { - if (_closeCallback) { - _closeCallback(trailingMetadata, error); - } -} - -- (void)didWriteMessage { - if (_writeMessageCallback) { - _writeMessageCallback(); - } -} - -- (dispatch_queue_t)dispatchQueue { - return _dispatchQueue; -} - -@end - @interface DefaultInterceptorFactory : NSObject - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager; From 4a4cf280a1d5f8690ee063a22a6b4b1d1d49f27f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 31 May 2019 10:37:58 -0400 Subject: [PATCH 0383/1555] also generate code with "lite_client" option set --- .../math_with_protoc_options.proto | 65 +++++++++++++++++++ src/csharp/generate_proto_csharp.sh | 2 + 2 files changed, 67 insertions(+) create mode 100644 src/csharp/Grpc.Examples/math_with_protoc_options.proto diff --git a/src/csharp/Grpc.Examples/math_with_protoc_options.proto b/src/csharp/Grpc.Examples/math_with_protoc_options.proto new file mode 100644 index 00000000000..ca13c6d4466 --- /dev/null +++ b/src/csharp/Grpc.Examples/math_with_protoc_options.proto @@ -0,0 +1,65 @@ + +// Copyright 2015 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package math_with_protoc_options; + +message DivArgs { + int64 dividend = 1; + int64 divisor = 2; +} + +message DivReply { + int64 quotient = 1; + int64 remainder = 2; +} + +message FibArgs { + int64 limit = 1; +} + +message Num { + int64 num = 1; +} + +message FibReply { + int64 count = 1; +} + +service Math { + // Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient + // and remainder. + rpc Div (DivArgs) returns (DivReply) { + } + + // DivMany accepts an arbitrary number of division args from the client stream + // and sends back the results in the reply stream. The stream continues until + // the client closes its end; the server does the same after sending all the + // replies. The stream ends immediately if either end aborts. + rpc DivMany (stream DivArgs) returns (stream DivReply) { + } + + // Fib generates numbers in the Fibonacci sequence. If FibArgs.limit > 0, Fib + // generates up to limit numbers; otherwise it continues until the call is + // canceled. Unlike Fib above, Fib has no final FibReply. + rpc Fib (FibArgs) returns (stream Num) { + } + + // Sum sums a stream of numbers, returning the final result once the stream + // is closed. + rpc Sum (stream Num) returns (Num) { + } +} diff --git a/src/csharp/generate_proto_csharp.sh b/src/csharp/generate_proto_csharp.sh index e79728ff959..81463ace6ad 100755 --- a/src/csharp/generate_proto_csharp.sh +++ b/src/csharp/generate_proto_csharp.sh @@ -26,6 +26,8 @@ TESTING_DIR=src/csharp/Grpc.IntegrationTesting $PROTOC --plugin=$PLUGIN --csharp_out=$EXAMPLES_DIR --grpc_out=$EXAMPLES_DIR \ -I src/proto src/proto/math/math.proto +$PROTOC --plugin=$PLUGIN --csharp_out=$EXAMPLES_DIR --grpc_out=$EXAMPLES_DIR --grpc_opt=lite_client,no_server \ + -I src/csharp/Grpc.Examples src/csharp/Grpc.Examples/math_with_protoc_options.proto $PROTOC --plugin=$PLUGIN --csharp_out=$HEALTHCHECK_DIR --grpc_out=$HEALTHCHECK_DIR \ -I src/proto src/proto/grpc/health/v1/health.proto From 8c27e86b8b0eaa163ed1186f10e33346d06bf040 Mon Sep 17 00:00:00 2001 From: "yuangongji (A)" <82787816@qq.com> Date: Fri, 31 May 2019 22:40:55 +0800 Subject: [PATCH 0384/1555] some typo errors --- include/grpc/grpc_security_constants.h | 2 +- include/grpc/impl/codegen/gpr_types.h | 2 +- include/grpc/slice.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/grpc/grpc_security_constants.h b/include/grpc/grpc_security_constants.h index a082f670107..1be524a78f8 100644 --- a/include/grpc/grpc_security_constants.h +++ b/include/grpc/grpc_security_constants.h @@ -96,7 +96,7 @@ typedef enum { /** Server requests client certificate and enforces that the client presents a certificate. - The cerificate presented by the client is verified by the gRPC framework. + The certificate presented by the client is verified by the gRPC framework. (For a successful connection the client needs to present a certificate that can be verified against the root certificate configured by the server) diff --git a/include/grpc/impl/codegen/gpr_types.h b/include/grpc/impl/codegen/gpr_types.h index d7bb54527ec..6daf3398619 100644 --- a/include/grpc/impl/codegen/gpr_types.h +++ b/include/grpc/impl/codegen/gpr_types.h @@ -48,7 +48,7 @@ typedef struct gpr_timespec { int64_t tv_sec; int32_t tv_nsec; /** Against which clock was this time measured? (or GPR_TIMESPAN if - this is a relative time meaure) */ + this is a relative time measure) */ gpr_clock_type clock_type; } gpr_timespec; diff --git a/include/grpc/slice.h b/include/grpc/slice.h index 192a8cfeef4..51fc62b44df 100644 --- a/include/grpc/slice.h +++ b/include/grpc/slice.h @@ -107,7 +107,7 @@ GPRAPI grpc_slice grpc_slice_sub_no_ref(grpc_slice s, size_t begin, size_t end); /** Splits s into two: modifies s to be s[0:split], and returns a new slice, sharing a refcount with s, that contains s[split:s.length]. - Requires s intialized, split <= s.length */ + Requires s initialized, split <= s.length */ GPRAPI grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split); typedef enum { @@ -124,7 +124,7 @@ GPRAPI grpc_slice grpc_slice_split_tail_maybe_ref(grpc_slice* s, size_t split, /** Splits s into two: modifies s to be s[split:s.length], and returns a new slice, sharing a refcount with s, that contains s[0:split]. - Requires s intialized, split <= s.length */ + Requires s initialized, split <= s.length */ GPRAPI grpc_slice grpc_slice_split_head(grpc_slice* s, size_t split); GPRAPI grpc_slice grpc_empty_slice(void); From 8cb8d5818574024ff18359be48c17729423e1fec Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 31 May 2019 10:53:06 -0400 Subject: [PATCH 0385/1555] add generated code for math_with_protoc_options.proto --- .../Grpc.Examples/MathWithProtocOptions.cs | 759 ++++++++++++++++++ .../MathWithProtocOptionsGrpc.cs | 208 +++++ 2 files changed, 967 insertions(+) create mode 100644 src/csharp/Grpc.Examples/MathWithProtocOptions.cs create mode 100644 src/csharp/Grpc.Examples/MathWithProtocOptionsGrpc.cs diff --git a/src/csharp/Grpc.Examples/MathWithProtocOptions.cs b/src/csharp/Grpc.Examples/MathWithProtocOptions.cs new file mode 100644 index 00000000000..ef9a5a4ff5c --- /dev/null +++ b/src/csharp/Grpc.Examples/MathWithProtocOptions.cs @@ -0,0 +1,759 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: math_with_protoc_options.proto +// +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace MathWithProtocOptions { + + /// Holder for reflection information generated from math_with_protoc_options.proto + public static partial class MathWithProtocOptionsReflection { + + #region Descriptor + /// File descriptor for math_with_protoc_options.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static MathWithProtocOptionsReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ch5tYXRoX3dpdGhfcHJvdG9jX29wdGlvbnMucHJvdG8SGG1hdGhfd2l0aF9w", + "cm90b2Nfb3B0aW9ucyIsCgdEaXZBcmdzEhAKCGRpdmlkZW5kGAEgASgDEg8K", + "B2Rpdmlzb3IYAiABKAMiLwoIRGl2UmVwbHkSEAoIcXVvdGllbnQYASABKAMS", + "EQoJcmVtYWluZGVyGAIgASgDIhgKB0ZpYkFyZ3MSDQoFbGltaXQYASABKAMi", + "EgoDTnVtEgsKA251bRgBIAEoAyIZCghGaWJSZXBseRINCgVjb3VudBgBIAEo", + "AzLEAgoETWF0aBJOCgNEaXYSIS5tYXRoX3dpdGhfcHJvdG9jX29wdGlvbnMu", + "RGl2QXJncxoiLm1hdGhfd2l0aF9wcm90b2Nfb3B0aW9ucy5EaXZSZXBseSIA", + "ElYKB0Rpdk1hbnkSIS5tYXRoX3dpdGhfcHJvdG9jX29wdGlvbnMuRGl2QXJn", + "cxoiLm1hdGhfd2l0aF9wcm90b2Nfb3B0aW9ucy5EaXZSZXBseSIAKAEwARJL", + "CgNGaWISIS5tYXRoX3dpdGhfcHJvdG9jX29wdGlvbnMuRmliQXJncxodLm1h", + "dGhfd2l0aF9wcm90b2Nfb3B0aW9ucy5OdW0iADABEkcKA1N1bRIdLm1hdGhf", + "d2l0aF9wcm90b2Nfb3B0aW9ucy5OdW0aHS5tYXRoX3dpdGhfcHJvdG9jX29w", + "dGlvbnMuTnVtIgAoAWIGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::MathWithProtocOptions.DivArgs), global::MathWithProtocOptions.DivArgs.Parser, new[]{ "Dividend", "Divisor" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::MathWithProtocOptions.DivReply), global::MathWithProtocOptions.DivReply.Parser, new[]{ "Quotient", "Remainder" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::MathWithProtocOptions.FibArgs), global::MathWithProtocOptions.FibArgs.Parser, new[]{ "Limit" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::MathWithProtocOptions.Num), global::MathWithProtocOptions.Num.Parser, new[]{ "Num_" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::MathWithProtocOptions.FibReply), global::MathWithProtocOptions.FibReply.Parser, new[]{ "Count" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class DivArgs : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DivArgs()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::MathWithProtocOptions.MathWithProtocOptionsReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DivArgs() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DivArgs(DivArgs other) : this() { + dividend_ = other.dividend_; + divisor_ = other.divisor_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DivArgs Clone() { + return new DivArgs(this); + } + + /// Field number for the "dividend" field. + public const int DividendFieldNumber = 1; + private long dividend_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Dividend { + get { return dividend_; } + set { + dividend_ = value; + } + } + + /// Field number for the "divisor" field. + public const int DivisorFieldNumber = 2; + private long divisor_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Divisor { + get { return divisor_; } + set { + divisor_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DivArgs); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DivArgs other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Dividend != other.Dividend) return false; + if (Divisor != other.Divisor) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Dividend != 0L) hash ^= Dividend.GetHashCode(); + if (Divisor != 0L) hash ^= Divisor.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Dividend != 0L) { + output.WriteRawTag(8); + output.WriteInt64(Dividend); + } + if (Divisor != 0L) { + output.WriteRawTag(16); + output.WriteInt64(Divisor); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Dividend != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Dividend); + } + if (Divisor != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Divisor); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DivArgs other) { + if (other == null) { + return; + } + if (other.Dividend != 0L) { + Dividend = other.Dividend; + } + if (other.Divisor != 0L) { + Divisor = other.Divisor; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + Dividend = input.ReadInt64(); + break; + } + case 16: { + Divisor = input.ReadInt64(); + break; + } + } + } + } + + } + + public sealed partial class DivReply : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DivReply()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::MathWithProtocOptions.MathWithProtocOptionsReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DivReply() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DivReply(DivReply other) : this() { + quotient_ = other.quotient_; + remainder_ = other.remainder_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DivReply Clone() { + return new DivReply(this); + } + + /// Field number for the "quotient" field. + public const int QuotientFieldNumber = 1; + private long quotient_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Quotient { + get { return quotient_; } + set { + quotient_ = value; + } + } + + /// Field number for the "remainder" field. + public const int RemainderFieldNumber = 2; + private long remainder_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Remainder { + get { return remainder_; } + set { + remainder_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DivReply); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DivReply other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Quotient != other.Quotient) return false; + if (Remainder != other.Remainder) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Quotient != 0L) hash ^= Quotient.GetHashCode(); + if (Remainder != 0L) hash ^= Remainder.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Quotient != 0L) { + output.WriteRawTag(8); + output.WriteInt64(Quotient); + } + if (Remainder != 0L) { + output.WriteRawTag(16); + output.WriteInt64(Remainder); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Quotient != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Quotient); + } + if (Remainder != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Remainder); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DivReply other) { + if (other == null) { + return; + } + if (other.Quotient != 0L) { + Quotient = other.Quotient; + } + if (other.Remainder != 0L) { + Remainder = other.Remainder; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + Quotient = input.ReadInt64(); + break; + } + case 16: { + Remainder = input.ReadInt64(); + break; + } + } + } + } + + } + + public sealed partial class FibArgs : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FibArgs()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::MathWithProtocOptions.MathWithProtocOptionsReflection.Descriptor.MessageTypes[2]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public FibArgs() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public FibArgs(FibArgs other) : this() { + limit_ = other.limit_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public FibArgs Clone() { + return new FibArgs(this); + } + + /// Field number for the "limit" field. + public const int LimitFieldNumber = 1; + private long limit_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Limit { + get { return limit_; } + set { + limit_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as FibArgs); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(FibArgs other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Limit != other.Limit) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Limit != 0L) hash ^= Limit.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Limit != 0L) { + output.WriteRawTag(8); + output.WriteInt64(Limit); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Limit != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Limit); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(FibArgs other) { + if (other == null) { + return; + } + if (other.Limit != 0L) { + Limit = other.Limit; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + Limit = input.ReadInt64(); + break; + } + } + } + } + + } + + public sealed partial class Num : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Num()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::MathWithProtocOptions.MathWithProtocOptionsReflection.Descriptor.MessageTypes[3]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Num() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Num(Num other) : this() { + num_ = other.num_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Num Clone() { + return new Num(this); + } + + /// Field number for the "num" field. + public const int Num_FieldNumber = 1; + private long num_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Num_ { + get { return num_; } + set { + num_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Num); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Num other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Num_ != other.Num_) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Num_ != 0L) hash ^= Num_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Num_ != 0L) { + output.WriteRawTag(8); + output.WriteInt64(Num_); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Num_ != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Num_); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Num other) { + if (other == null) { + return; + } + if (other.Num_ != 0L) { + Num_ = other.Num_; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + Num_ = input.ReadInt64(); + break; + } + } + } + } + + } + + public sealed partial class FibReply : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FibReply()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::MathWithProtocOptions.MathWithProtocOptionsReflection.Descriptor.MessageTypes[4]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public FibReply() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public FibReply(FibReply other) : this() { + count_ = other.count_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public FibReply Clone() { + return new FibReply(this); + } + + /// Field number for the "count" field. + public const int CountFieldNumber = 1; + private long count_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Count { + get { return count_; } + set { + count_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as FibReply); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(FibReply other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Count != other.Count) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Count != 0L) hash ^= Count.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Count != 0L) { + output.WriteRawTag(8); + output.WriteInt64(Count); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Count != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Count); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(FibReply other) { + if (other == null) { + return; + } + if (other.Count != 0L) { + Count = other.Count; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + Count = input.ReadInt64(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/src/csharp/Grpc.Examples/MathWithProtocOptionsGrpc.cs b/src/csharp/Grpc.Examples/MathWithProtocOptionsGrpc.cs new file mode 100644 index 00000000000..dd61b72163f --- /dev/null +++ b/src/csharp/Grpc.Examples/MathWithProtocOptionsGrpc.cs @@ -0,0 +1,208 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: math_with_protoc_options.proto +// +// Original file comments: +// Copyright 2015 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#pragma warning disable 0414, 1591 +#region Designer generated code + +using grpc = global::Grpc.Core; + +namespace MathWithProtocOptions { + public static partial class Math + { + static readonly string __ServiceName = "math_with_protoc_options.Math"; + + static readonly grpc::Marshaller __Marshaller_math_with_protoc_options_DivArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::MathWithProtocOptions.DivArgs.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_math_with_protoc_options_DivReply = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::MathWithProtocOptions.DivReply.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_math_with_protoc_options_FibArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::MathWithProtocOptions.FibArgs.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_math_with_protoc_options_Num = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::MathWithProtocOptions.Num.Parser.ParseFrom); + + static readonly grpc::Method __Method_Div = new grpc::Method( + grpc::MethodType.Unary, + __ServiceName, + "Div", + __Marshaller_math_with_protoc_options_DivArgs, + __Marshaller_math_with_protoc_options_DivReply); + + static readonly grpc::Method __Method_DivMany = new grpc::Method( + grpc::MethodType.DuplexStreaming, + __ServiceName, + "DivMany", + __Marshaller_math_with_protoc_options_DivArgs, + __Marshaller_math_with_protoc_options_DivReply); + + static readonly grpc::Method __Method_Fib = new grpc::Method( + grpc::MethodType.ServerStreaming, + __ServiceName, + "Fib", + __Marshaller_math_with_protoc_options_FibArgs, + __Marshaller_math_with_protoc_options_Num); + + static readonly grpc::Method __Method_Sum = new grpc::Method( + grpc::MethodType.ClientStreaming, + __ServiceName, + "Sum", + __Marshaller_math_with_protoc_options_Num, + __Marshaller_math_with_protoc_options_Num); + + /// Service descriptor + public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor + { + get { return global::MathWithProtocOptions.MathWithProtocOptionsReflection.Descriptor.Services[0]; } + } + + /// Lite client for Math + public partial class MathClient : grpc::LiteClientBase + { + /// Creates a new client for Math that uses a custom CallInvoker. + /// The callInvoker to use to make remote calls. + public MathClient(grpc::CallInvoker callInvoker) : base(callInvoker) + { + } + /// Protected parameterless constructor to allow creation of test doubles. + protected MathClient() : base() + { + } + + /// + /// Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient + /// and remainder. + /// + /// The request to send to the server. + /// The initial metadata to send with the call. This parameter is optional. + /// An optional deadline for the call. The call will be cancelled if deadline is hit. + /// An optional token for canceling the call. + /// The response received from the server. + public virtual global::MathWithProtocOptions.DivReply Div(global::MathWithProtocOptions.DivArgs request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + { + return Div(request, new grpc::CallOptions(headers, deadline, cancellationToken)); + } + /// + /// Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient + /// and remainder. + /// + /// The request to send to the server. + /// The options for the call. + /// The response received from the server. + public virtual global::MathWithProtocOptions.DivReply Div(global::MathWithProtocOptions.DivArgs request, grpc::CallOptions options) + { + return CallInvoker.BlockingUnaryCall(__Method_Div, null, options, request); + } + /// + /// Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient + /// and remainder. + /// + /// The request to send to the server. + /// The initial metadata to send with the call. This parameter is optional. + /// An optional deadline for the call. The call will be cancelled if deadline is hit. + /// An optional token for canceling the call. + /// The call object. + public virtual grpc::AsyncUnaryCall DivAsync(global::MathWithProtocOptions.DivArgs request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + { + return DivAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); + } + /// + /// Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient + /// and remainder. + /// + /// The request to send to the server. + /// The options for the call. + /// The call object. + public virtual grpc::AsyncUnaryCall DivAsync(global::MathWithProtocOptions.DivArgs request, grpc::CallOptions options) + { + return CallInvoker.AsyncUnaryCall(__Method_Div, null, options, request); + } + /// + /// DivMany accepts an arbitrary number of division args from the client stream + /// and sends back the results in the reply stream. The stream continues until + /// the client closes its end; the server does the same after sending all the + /// replies. The stream ends immediately if either end aborts. + /// + /// The initial metadata to send with the call. This parameter is optional. + /// An optional deadline for the call. The call will be cancelled if deadline is hit. + /// An optional token for canceling the call. + /// The call object. + public virtual grpc::AsyncDuplexStreamingCall DivMany(grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + { + return DivMany(new grpc::CallOptions(headers, deadline, cancellationToken)); + } + /// + /// DivMany accepts an arbitrary number of division args from the client stream + /// and sends back the results in the reply stream. The stream continues until + /// the client closes its end; the server does the same after sending all the + /// replies. The stream ends immediately if either end aborts. + /// + /// The options for the call. + /// The call object. + public virtual grpc::AsyncDuplexStreamingCall DivMany(grpc::CallOptions options) + { + return CallInvoker.AsyncDuplexStreamingCall(__Method_DivMany, null, options); + } + /// + /// Fib generates numbers in the Fibonacci sequence. If FibArgs.limit > 0, Fib + /// generates up to limit numbers; otherwise it continues until the call is + /// canceled. Unlike Fib above, Fib has no final FibReply. + /// + /// The request to send to the server. + /// The initial metadata to send with the call. This parameter is optional. + /// An optional deadline for the call. The call will be cancelled if deadline is hit. + /// An optional token for canceling the call. + /// The call object. + public virtual grpc::AsyncServerStreamingCall Fib(global::MathWithProtocOptions.FibArgs request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + { + return Fib(request, new grpc::CallOptions(headers, deadline, cancellationToken)); + } + /// + /// Fib generates numbers in the Fibonacci sequence. If FibArgs.limit > 0, Fib + /// generates up to limit numbers; otherwise it continues until the call is + /// canceled. Unlike Fib above, Fib has no final FibReply. + /// + /// The request to send to the server. + /// The options for the call. + /// The call object. + public virtual grpc::AsyncServerStreamingCall Fib(global::MathWithProtocOptions.FibArgs request, grpc::CallOptions options) + { + return CallInvoker.AsyncServerStreamingCall(__Method_Fib, null, options, request); + } + /// + /// Sum sums a stream of numbers, returning the final result once the stream + /// is closed. + /// + /// The initial metadata to send with the call. This parameter is optional. + /// An optional deadline for the call. The call will be cancelled if deadline is hit. + /// An optional token for canceling the call. + /// The call object. + public virtual grpc::AsyncClientStreamingCall Sum(grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + { + return Sum(new grpc::CallOptions(headers, deadline, cancellationToken)); + } + /// + /// Sum sums a stream of numbers, returning the final result once the stream + /// is closed. + /// + /// The options for the call. + /// The call object. + public virtual grpc::AsyncClientStreamingCall Sum(grpc::CallOptions options) + { + return CallInvoker.AsyncClientStreamingCall(__Method_Sum, null, options); + } + } + + } +} +#endregion From a432e2f50276ba4997c2aecdf41f7f6f75c454ee Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 31 May 2019 10:53:40 -0400 Subject: [PATCH 0386/1555] check callInvoker is not null --- src/csharp/Grpc.Core.Api/LiteClientBase.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/csharp/Grpc.Core.Api/LiteClientBase.cs b/src/csharp/Grpc.Core.Api/LiteClientBase.cs index a978cdf09e0..c3215f016a0 100644 --- a/src/csharp/Grpc.Core.Api/LiteClientBase.cs +++ b/src/csharp/Grpc.Core.Api/LiteClientBase.cs @@ -17,6 +17,7 @@ #endregion using System; +using Grpc.Core.Utils; namespace Grpc.Core { @@ -47,7 +48,7 @@ namespace Grpc.Core /// The CallInvoker for remote call invocation. public LiteClientBase(CallInvoker callInvoker) { - this.callInvoker = callInvoker; + this.callInvoker = GrpcPreconditions.CheckNotNull(callInvoker, nameof(callInvoker)); } /// From 381126fe2bd3bee25dc9b7aadc140f8782bfcf9d Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 31 May 2019 14:03:51 -0700 Subject: [PATCH 0387/1555] Fix typo --- src/objective-c/GRPCClient/GRPCCall.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index 4a1d98b7ba5..d02ec601727 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -174,7 +174,7 @@ extern NSString *const kGRPCTrailersKey; * interceptor, implement didReceiveData: instead. To implement an interceptor, please leave this * method unimplemented and implement didReceiveData: method instead. If this method and * didReceiveRawMessage are implemented at the same time, implementation of this method will be - * ingored. + * ignored. * * Issued when a message is received from the server. The message is the raw data received from the * server, with decompression and without proto deserialization. From 434b3b62e585e122e07d34d55d71a6e5a4cba7ad Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 24 May 2019 10:24:17 -0700 Subject: [PATCH 0388/1555] Applied the best practice using global configuration --- src/core/ext/filters/client_channel/backup_poller.cc | 5 ++--- src/core/ext/filters/client_channel/backup_poller.h | 7 +++++-- .../ext/filters/client_channel/client_channel_plugin.cc | 2 ++ .../resolver/dns/c_ares/dns_resolver_ares.cc | 9 ++++++--- src/core/lib/gprpp/global_config.h | 9 +++++++++ src/core/lib/iomgr/iomgr.cc | 6 +++--- test/cpp/end2end/client_lb_end2end_test.cc | 9 ++++----- test/cpp/end2end/grpclb_end2end_test.cc | 9 ++++----- test/cpp/end2end/service_config_end2end_test.cc | 9 ++++----- test/cpp/end2end/xds_end2end_test.cc | 9 ++++----- 10 files changed, 43 insertions(+), 31 deletions(-) diff --git a/src/core/ext/filters/client_channel/backup_poller.cc b/src/core/ext/filters/client_channel/backup_poller.cc index dd761694414..9e51a83415e 100644 --- a/src/core/ext/filters/client_channel/backup_poller.cc +++ b/src/core/ext/filters/client_channel/backup_poller.cc @@ -65,8 +65,8 @@ GPR_GLOBAL_CONFIG_DEFINE_INT32( "idleness), so that the next RPC on this channel won't fail. Set to 0 to " "turn off the backup polls."); -static void init_globals() { - gpr_mu_init(&g_poller_mu); +void grpc_client_channel_global_init_backup_polling() { + gpr_once_init(&g_once, [] { gpr_mu_init(&g_poller_mu); }); int32_t poll_interval_ms = GPR_GLOBAL_CONFIG_GET(grpc_client_channel_backup_poll_interval_ms); if (poll_interval_ms < 0) { @@ -153,7 +153,6 @@ static void g_poller_init_locked() { void grpc_client_channel_start_backup_polling( grpc_pollset_set* interested_parties) { - gpr_once_init(&g_once, init_globals); if (g_poll_interval_ms == 0) { return; } diff --git a/src/core/ext/filters/client_channel/backup_poller.h b/src/core/ext/filters/client_channel/backup_poller.h index e1bf4f88b2a..b412081b960 100644 --- a/src/core/ext/filters/client_channel/backup_poller.h +++ b/src/core/ext/filters/client_channel/backup_poller.h @@ -27,11 +27,14 @@ GPR_GLOBAL_CONFIG_DECLARE_INT32(grpc_client_channel_backup_poll_interval_ms); -/* Start polling \a interested_parties periodically in the timer thread */ +/* Initializes backup polling. */ +void grpc_client_channel_global_init_backup_polling(); + +/* Starts polling \a interested_parties periodically in the timer thread. */ void grpc_client_channel_start_backup_polling( grpc_pollset_set* interested_parties); -/* Stop polling \a interested_parties */ +/* Stops polling \a interested_parties. */ void grpc_client_channel_stop_backup_polling( grpc_pollset_set* interested_parties); diff --git a/src/core/ext/filters/client_channel/client_channel_plugin.cc b/src/core/ext/filters/client_channel/client_channel_plugin.cc index e564df8be33..3a7492d82d9 100644 --- a/src/core/ext/filters/client_channel/client_channel_plugin.cc +++ b/src/core/ext/filters/client_channel/client_channel_plugin.cc @@ -24,6 +24,7 @@ #include +#include "src/core/ext/filters/client_channel/backup_poller.h" #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/client_channel/client_channel_channelz.h" #include "src/core/ext/filters/client_channel/global_subchannel_pool.h" @@ -62,6 +63,7 @@ void grpc_client_channel_init(void) { GRPC_CLIENT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, append_filter, (void*)&grpc_client_channel_filter); grpc_http_connect_register_handshaker_factory(); + grpc_client_channel_global_init_backup_polling(); } void grpc_client_channel_shutdown(void) { diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index 00358736a94..32a339af359 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -473,10 +473,13 @@ static bool should_use_ares(const char* resolver_env) { } #endif /* GRPC_UV */ +static bool g_use_ares_dns_resolver; + void grpc_resolver_dns_ares_init() { grpc_core::UniquePtr resolver = GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); if (should_use_ares(resolver.get())) { + g_use_ares_dns_resolver = true; gpr_log(GPR_DEBUG, "Using ares dns resolver"); address_sorting_init(); grpc_error* error = grpc_ares_init(); @@ -491,13 +494,13 @@ void grpc_resolver_dns_ares_init() { grpc_core::ResolverRegistry::Builder::RegisterResolverFactory( grpc_core::UniquePtr( grpc_core::New())); + } else { + g_use_ares_dns_resolver = false; } } void grpc_resolver_dns_ares_shutdown() { - grpc_core::UniquePtr resolver = - GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); - if (should_use_ares(resolver.get())) { + if (g_use_ares_dns_resolver) { address_sorting_shutdown(); grpc_ares_cleanup(); } diff --git a/src/core/lib/gprpp/global_config.h b/src/core/lib/gprpp/global_config.h index a1bbf07564c..ed986b8e04d 100644 --- a/src/core/lib/gprpp/global_config.h +++ b/src/core/lib/gprpp/global_config.h @@ -59,6 +59,15 @@ // // Declaring config variables for other modules to access: // GPR_GLOBAL_CONFIG_DECLARE_*TYPE*(name) +// +// * Caveat for setting global configs at runtime +// +// Setting global configs at runtime multiple times is safe but it doesn't +// mean that it will have a valid effect on the module depending configs. +// In unit tests, it may be unpredictable to set different global configs +// between test cases because grpc init and shutdown can ignore changes. +// It's considered safe to set global configs before the first call to +// grpc_init(). // -------------------------------------------------------------------- // How to customize the global configuration system: diff --git a/src/core/lib/iomgr/iomgr.cc b/src/core/lib/iomgr/iomgr.cc index b09d19fa759..802e3bdcb4d 100644 --- a/src/core/lib/iomgr/iomgr.cc +++ b/src/core/lib/iomgr/iomgr.cc @@ -49,6 +49,7 @@ static gpr_mu g_mu; static gpr_cv g_rcv; static int g_shutdown; static grpc_iomgr_object g_root_object; +static bool g_grpc_abort_on_leaks; void grpc_iomgr_init() { grpc_core::ExecCtx exec_ctx; @@ -62,6 +63,7 @@ void grpc_iomgr_init() { grpc_iomgr_platform_init(); grpc_timer_list_init(); grpc_core::grpc_errqueue_init(); + g_grpc_abort_on_leaks = GPR_GLOBAL_CONFIG_GET(grpc_abort_on_leaks); } void grpc_iomgr_start() { grpc_timer_manager_init(); } @@ -189,6 +191,4 @@ void grpc_iomgr_unregister_object(grpc_iomgr_object* obj) { gpr_free(obj->name); } -bool grpc_iomgr_abort_on_leaks(void) { - return GPR_GLOBAL_CONFIG_GET(grpc_abort_on_leaks); -} +bool grpc_iomgr_abort_on_leaks(void) { return g_grpc_abort_on_leaks; } diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index b623348e13f..f6d4a48b6f0 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -139,11 +139,7 @@ class ClientLbEnd2endTest : public ::testing::Test { : server_host_("localhost"), kRequestMessage_("Live long and prosper."), creds_(new SecureChannelCredentials( - grpc_fake_transport_security_credentials_create())) { - // Make the backup poller poll very frequently in order to pick up - // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); - } + grpc_fake_transport_security_credentials_create())) {} void SetUp() override { grpc_init(); @@ -1485,6 +1481,9 @@ TEST_F(ClientLbInterceptTrailingMetadataTest, InterceptsRetriesEnabled) { } // namespace grpc int main(int argc, char** argv) { + // Make the backup poller poll very frequently in order to pick up + // updates from all the subchannels's FDs. + GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); ::testing::InitGoogleTest(&argc, argv); grpc::testing::TestEnvironment env(argc, argv); const auto result = RUN_ALL_TESTS(); diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc index 50b1383e7e1..70c443412aa 100644 --- a/test/cpp/end2end/grpclb_end2end_test.cc +++ b/test/cpp/end2end/grpclb_end2end_test.cc @@ -372,11 +372,7 @@ class GrpclbEnd2endTest : public ::testing::Test { num_backends_(num_backends), num_balancers_(num_balancers), client_load_reporting_interval_seconds_( - client_load_reporting_interval_seconds) { - // Make the backup poller poll very frequently in order to pick up - // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); - } + client_load_reporting_interval_seconds) {} void SetUp() override { response_generator_ = @@ -1994,6 +1990,9 @@ TEST_F(SingleBalancerWithClientLoadReportingTest, Drop) { } // namespace grpc int main(int argc, char** argv) { + // Make the backup poller poll very frequently in order to pick up + // updates from all the subchannels's FDs. + GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); grpc_init(); grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); diff --git a/test/cpp/end2end/service_config_end2end_test.cc b/test/cpp/end2end/service_config_end2end_test.cc index 14786b98f85..8bf4a7c22ff 100644 --- a/test/cpp/end2end/service_config_end2end_test.cc +++ b/test/cpp/end2end/service_config_end2end_test.cc @@ -117,11 +117,7 @@ class ServiceConfigEnd2endTest : public ::testing::Test { : server_host_("localhost"), kRequestMessage_("Live long and prosper."), creds_(new SecureChannelCredentials( - grpc_fake_transport_security_credentials_create())) { - // Make the backup poller poll very frequently in order to pick up - // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); - } + grpc_fake_transport_security_credentials_create())) {} void SetUp() override { grpc_init(); @@ -615,6 +611,9 @@ TEST_F(ServiceConfigEnd2endTest, } // namespace grpc int main(int argc, char** argv) { + // Make the backup poller poll very frequently in order to pick up + // updates from all the subchannels's FDs. + GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); ::testing::InitGoogleTest(&argc, argv); grpc::testing::TestEnvironment env(argc, argv); const auto result = RUN_ALL_TESTS(); diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index 87a231c588d..eac6f32a538 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -368,11 +368,7 @@ class XdsEnd2endTest : public ::testing::Test { num_backends_(num_backends), num_balancers_(num_balancers), client_load_reporting_interval_seconds_( - client_load_reporting_interval_seconds) { - // Make the backup poller poll very frequently in order to pick up - // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); - } + client_load_reporting_interval_seconds) {} void SetUp() override { response_generator_ = @@ -1405,6 +1401,9 @@ class SingleBalancerWithClientLoadReportingTest : public XdsEnd2endTest { } // namespace grpc int main(int argc, char** argv) { + // Make the backup poller poll very frequently in order to pick up + // updates from all the subchannels's FDs. + GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); grpc_init(); grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); From 8fa95462a1101a837cefb549d3052fec7b7a01e5 Mon Sep 17 00:00:00 2001 From: Mehrdad Afshari Date: Fri, 31 May 2019 14:07:07 -0700 Subject: [PATCH 0389/1555] Put strncpy in parens to silence GCC warning GCC warns (-Wstringop-truncation) because the destination buffer size is identical to max-size, leading to a potential char[] with no null terminator. nanopb can handle it fine, and parantheses around strncpy silence that compiler warning. nanopb treatment of string buffers with specific max length seems dangerous in general, specifically when read from, but this particular case should be correct, as the buffer is only ever read by nanopb itself, which takes the max size into consideration, in addition to the null terminator. --- .../client_channel/lb_policy/grpclb/load_balancer_api.cc | 8 ++++++-- .../client_channel/lb_policy/xds/xds_load_balancer_api.cc | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc index b51db110395..22cefc937b0 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc @@ -67,8 +67,12 @@ grpc_grpclb_request* grpc_grpclb_request_create(const char* lb_service_name) { req->has_client_stats = false; req->has_initial_request = true; req->initial_request.has_name = true; - strncpy(req->initial_request.name, lb_service_name, - GRPC_GRPCLB_SERVICE_NAME_MAX_LENGTH); + // GCC warns (-Wstringop-truncation) because the destination + // buffer size is identical to max-size, leading to a potential + // char[] with no null terminator. nanopb can handle it fine, + // and parantheses around strncpy silence that compiler warning. + (strncpy(req->initial_request.name, lb_service_name, + GRPC_GRPCLB_SERVICE_NAME_MAX_LENGTH)); return req; } diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc index 90094974a14..58f26bf54ec 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc @@ -67,8 +67,12 @@ xds_grpclb_request* xds_grpclb_request_create(const char* lb_service_name) { req->has_client_stats = false; req->has_initial_request = true; req->initial_request.has_name = true; - strncpy(req->initial_request.name, lb_service_name, - XDS_SERVICE_NAME_MAX_LENGTH); + // GCC warns (-Wstringop-truncation) because the destination + // buffer size is identical to max-size, leading to a potential + // char[] with no null terminator. nanopb can handle it fine, + // and parantheses around strncpy silence that compiler warning. + (strncpy(req->initial_request.name, lb_service_name, + XDS_SERVICE_NAME_MAX_LENGTH)); return req; } From 371a55a0fff1480818932c44feaf76fe00e124dc Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Fri, 31 May 2019 10:36:00 -0700 Subject: [PATCH 0390/1555] Update Python packages before building ARM wheels. --- tools/dockerfile/grpc_artifact_linux_armv6/Dockerfile | 6 ++++-- tools/dockerfile/grpc_artifact_linux_armv7/Dockerfile | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/dockerfile/grpc_artifact_linux_armv6/Dockerfile b/tools/dockerfile/grpc_artifact_linux_armv6/Dockerfile index fb83a5ca6aa..e2c406599dc 100644 --- a/tools/dockerfile/grpc_artifact_linux_armv6/Dockerfile +++ b/tools/dockerfile/grpc_artifact_linux_armv6/Dockerfile @@ -14,11 +14,13 @@ # Docker file for building gRPC Raspbian binaries +# TODO(https://github.com/grpc/grpc/issues/19199): Move off of this image. FROM quay.io/grpc/raspbian_armv6 # Place any extra build instructions between these commands # Recommend modifying upstream docker image (quay.io/grpc/raspbian_armv6) # for build steps because running them under QEMU is very slow # (https://github.com/kpayson64/armv7hf-debian-qemu) -# RUN [ "cross-build-start" ] -# RUN [ "cross-build-end" ] +RUN [ "cross-build-start" ] +RUN find /usr/local/bin -regex '.*python[0-9]+\.[0-9]+' | xargs -n1 -i{} bash -c "{} -m pip install --upgrade wheel setuptools" +RUN [ "cross-build-end" ] diff --git a/tools/dockerfile/grpc_artifact_linux_armv7/Dockerfile b/tools/dockerfile/grpc_artifact_linux_armv7/Dockerfile index 0b68df52d12..735c2e85b26 100644 --- a/tools/dockerfile/grpc_artifact_linux_armv7/Dockerfile +++ b/tools/dockerfile/grpc_artifact_linux_armv7/Dockerfile @@ -14,11 +14,13 @@ # Docker file for building gRPC Raspbian binaries +# TODO(https://github.com/grpc/grpc/issues/19199): Move off of this base image. FROM quay.io/grpc/raspbian_armv7 # Place any extra build instructions between these commands # Recommend modifying upstream docker image (quay.io/grpc/raspbian_armv7) # for build steps because running them under QEMU is very slow # (https://github.com/kpayson64/armv7hf-debian-qemu) -# RUN [ "cross-build-start" ] -# RUN [ "cross-build-end" ] +RUN [ "cross-build-start" ] +RUN find /usr/local/bin -regex '.*python[0-9]+\.[0-9]+' | xargs -n1 -i{} bash -c "{} -m pip install --upgrade wheel setuptools" +RUN [ "cross-build-end" ] From 6040249a61020aca939c88a5d2af67a429221d1d Mon Sep 17 00:00:00 2001 From: weiyongji <232589621@qq.com> Date: Sat, 1 Jun 2019 11:31:23 +0800 Subject: [PATCH 0391/1555] fix a windows compile warning --- .../resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc index 85f5cd84ca0..7d5215938e3 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc @@ -231,7 +231,6 @@ class GrpcPolledFdWindows : public GrpcPolledFd { ares_ssize_t TrySendWriteBufSyncNonBlocking() { GPR_ASSERT(write_state_ == WRITE_IDLE); - ares_ssize_t total_sent; DWORD bytes_sent = 0; if (SendWriteBuf(&bytes_sent, nullptr) != 0) { int wsa_last_error = WSAGetLastError(); From a04dcb9da97de4ee928ab772255a4ec8c2048407 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Sat, 1 Jun 2019 00:25:11 -0700 Subject: [PATCH 0392/1555] PHP: Fix ZTS build shutdown segfault --- src/php/ext/grpc/php_grpc.c | 16 +++++++++++----- src/php/ext/grpc/php_grpc.h | 2 ++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/php/ext/grpc/php_grpc.c b/src/php/ext/grpc/php_grpc.c index 74f536ea07b..6d66e790459 100644 --- a/src/php/ext/grpc/php_grpc.c +++ b/src/php/ext/grpc/php_grpc.c @@ -42,6 +42,8 @@ const zend_function_entry grpc_functions[] = { }; /* }}} */ +ZEND_DECLARE_MODULE_GLOBALS(grpc); + /* {{{ grpc_module_entry */ zend_module_entry grpc_module_entry = { @@ -77,10 +79,13 @@ ZEND_GET_MODULE(grpc) /* {{{ php_grpc_init_globals */ -static void php_grpc_init_globals(zend_grpc_globals *grpc_globals) { - grpc_globals->enable_fork_support = 0; - grpc_globals->poll_strategy = NULL; -} +/* Uncomment this function if you have INI entries + static void php_grpc_init_globals(zend_grpc_globals *grpc_globals) + { + grpc_globals->global_value = 0; + grpc_globals->global_string = NULL; + } +*/ /* }}} */ void create_new_channel( @@ -222,7 +227,6 @@ void apply_ini_settings(TSRMLS_D) { /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(grpc) { - ZEND_INIT_MODULE_GLOBALS(grpc, php_grpc_init_globals, NULL); REGISTER_INI_ENTRIES(); /* Register call error constants */ @@ -406,6 +410,8 @@ PHP_RINIT_FUNCTION(grpc) { */ static PHP_GINIT_FUNCTION(grpc) { grpc_globals->initialized = 0; + grpc_globals->enable_fork_support = 0; + grpc_globals->poll_strategy = NULL; } /* }}} */ diff --git a/src/php/ext/grpc/php_grpc.h b/src/php/ext/grpc/php_grpc.h index 2629b1bbd78..1c7973b9ef8 100644 --- a/src/php/ext/grpc/php_grpc.h +++ b/src/php/ext/grpc/php_grpc.h @@ -70,6 +70,8 @@ ZEND_BEGIN_MODULE_GLOBALS(grpc) char *poll_strategy; ZEND_END_MODULE_GLOBALS(grpc) +ZEND_EXTERN_MODULE_GLOBALS(grpc); + /* In every utility function you add that needs to use variables in php_grpc_globals, call TSRMLS_FETCH(); after declaring other variables used by that function, or better yet, pass in TSRMLS_CC From aa3b2d1e865eae1204ae6339efec1b9338e2ffac Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Sat, 1 Jun 2019 00:25:11 -0700 Subject: [PATCH 0393/1555] PHP: Fix ZTS build shutdown segfault --- src/php/ext/grpc/php_grpc.c | 16 +++++++++++----- src/php/ext/grpc/php_grpc.h | 2 ++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/php/ext/grpc/php_grpc.c b/src/php/ext/grpc/php_grpc.c index 74f536ea07b..6d66e790459 100644 --- a/src/php/ext/grpc/php_grpc.c +++ b/src/php/ext/grpc/php_grpc.c @@ -42,6 +42,8 @@ const zend_function_entry grpc_functions[] = { }; /* }}} */ +ZEND_DECLARE_MODULE_GLOBALS(grpc); + /* {{{ grpc_module_entry */ zend_module_entry grpc_module_entry = { @@ -77,10 +79,13 @@ ZEND_GET_MODULE(grpc) /* {{{ php_grpc_init_globals */ -static void php_grpc_init_globals(zend_grpc_globals *grpc_globals) { - grpc_globals->enable_fork_support = 0; - grpc_globals->poll_strategy = NULL; -} +/* Uncomment this function if you have INI entries + static void php_grpc_init_globals(zend_grpc_globals *grpc_globals) + { + grpc_globals->global_value = 0; + grpc_globals->global_string = NULL; + } +*/ /* }}} */ void create_new_channel( @@ -222,7 +227,6 @@ void apply_ini_settings(TSRMLS_D) { /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(grpc) { - ZEND_INIT_MODULE_GLOBALS(grpc, php_grpc_init_globals, NULL); REGISTER_INI_ENTRIES(); /* Register call error constants */ @@ -406,6 +410,8 @@ PHP_RINIT_FUNCTION(grpc) { */ static PHP_GINIT_FUNCTION(grpc) { grpc_globals->initialized = 0; + grpc_globals->enable_fork_support = 0; + grpc_globals->poll_strategy = NULL; } /* }}} */ diff --git a/src/php/ext/grpc/php_grpc.h b/src/php/ext/grpc/php_grpc.h index 2629b1bbd78..1c7973b9ef8 100644 --- a/src/php/ext/grpc/php_grpc.h +++ b/src/php/ext/grpc/php_grpc.h @@ -70,6 +70,8 @@ ZEND_BEGIN_MODULE_GLOBALS(grpc) char *poll_strategy; ZEND_END_MODULE_GLOBALS(grpc) +ZEND_EXTERN_MODULE_GLOBALS(grpc); + /* In every utility function you add that needs to use variables in php_grpc_globals, call TSRMLS_FETCH(); after declaring other variables used by that function, or better yet, pass in TSRMLS_CC From 187ef99e66852ff825b4d1762b3150b5f35535d6 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Sun, 2 Jun 2019 21:09:34 -0700 Subject: [PATCH 0394/1555] Bump version to v1.21.3-pre1 --- BUILD | 2 +- build.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index 37046f67a83..e0113d48a18 100644 --- a/BUILD +++ b/BUILD @@ -78,7 +78,7 @@ g_stands_for = "gandalf" core_version = "7.0.0" -version = "1.21.2" +version = "1.21.3-pre1" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index 3fc8b651714..6bc58bf4411 100644 --- a/build.yaml +++ b/build.yaml @@ -14,7 +14,7 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 7.0.0 g_stands_for: gandalf - version: 1.21.2 + version: 1.21.3-pre1 filegroups: - name: alts_proto headers: From f7425cb318c416e13a80a801bc6e5fe09324565a Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Sun, 2 Jun 2019 21:10:23 -0700 Subject: [PATCH 0395/1555] Re-generate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 6 +++--- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 8 ++++---- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 4 ++-- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/composer.json | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 30 files changed, 37 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c8d64b7f0c..0067454a2d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.21.2") +set(PACKAGE_VERSION "1.21.3-pre1") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 6d717454fe5..2b150815592 100644 --- a/Makefile +++ b/Makefile @@ -460,8 +460,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.21.2 -CSHARP_VERSION = 1.21.2 +CPP_VERSION = 1.21.3-pre1 +CSHARP_VERSION = 1.21.3-pre1 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 3fc781b9355..47b18b9b75d 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,15 +23,15 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.21.2' - version = '0.0.9' + # version = '1.21.3-pre1' + version = '0.0.9-pre1' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.21.2' + grpc_version = '1.21.3-pre1' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 220d3af3b4b..ce9a7d6a525 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.21.2' + version = '1.21.3-pre1' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index b49ccb9006a..3f8180c4d3e 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.21.2' + version = '1.21.3-pre1' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 673e7bce88b..6a8a7b89061 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.21.2' + version = '1.21.3-pre1' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index 1352c4c612b..1afc2e68623 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.21.2' + version = '1.21.3-pre1' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index 64c740e265a..7292aa634eb 100644 --- a/package.xml +++ b/package.xml @@ -13,12 +13,12 @@ 2018-01-19 - 1.21.2 - 1.21.2 + 1.21.3RC1 + 1.21.3RC1 - stable - stable + beta + beta Apache 2.0 diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 0a70066da99..fcb80876989 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.21.2"; } +grpc::string Version() { return "1.21.3-pre1"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index dd609b57861..f3420552430 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -33,11 +33,11 @@ namespace Grpc.Core /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "1.21.2.0"; + public const string CurrentAssemblyFileVersion = "1.21.3.0"; /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.21.2"; + public const string CurrentVersion = "1.21.3-pre1"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index ee7c7deba2b..0819b58b5f1 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 1.21.2 + 1.21.3-pre1 3.7.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index ba058320ae0..0504ee05855 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=1.21.2 +set VERSION=1.21.3-pre1 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index c40eeace00e..958f30a5994 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.21.2' + v = '1.21.3-pre1' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 681da2b810a..4ab2203fd09 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.2" +#define GRPC_OBJC_VERSION_STRING @"1.21.3-pre1" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 44d99eb284a..20f3f55cf44 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.2" +#define GRPC_OBJC_VERSION_STRING @"1.21.3-pre1" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/composer.json b/src/php/composer.json index e76014083f7..48dfde56d86 100644 --- a/src/php/composer.json +++ b/src/php/composer.json @@ -2,7 +2,7 @@ "name": "grpc/grpc-dev", "description": "gRPC library for PHP - for Developement use only", "license": "Apache-2.0", - "version": "1.21.2", + "version": "1.21.3", "require": { "php": ">=5.5.0", "google/protobuf": "^v3.3.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 5371146a432..0619b687a5b 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.21.2" +#define PHP_GRPC_VERSION "1.21.3RC1" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index 3af536e9f37..94a507ace4e 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.21.2""" +__version__ = """1.21.3rc1""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index 514df8b0ef4..2ae2edfad44 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.21.2' +VERSION = '1.21.3rc1' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index 961939cb2ad..19a2283ed55 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.21.2' +VERSION = '1.21.3rc1' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index 1497d526468..19cefb59977 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.21.2' +VERSION = '1.21.3rc1' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 7731b932266..2bc839f13a1 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.21.2' +VERSION = '1.21.3rc1' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index d8714f76d5b..c1f396d0bc8 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.21.2' +VERSION = '1.21.3rc1' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 2e9d29235bf..4b0438ad4d5 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.21.2' +VERSION = '1.21.3rc1' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index 715493c169f..7f12f28c47b 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.21.2' +VERSION = '1.21.3rc1' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index b31c382f0c2..9ae6bcfe1c7 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.21.2' + VERSION = '1.21.3.pre1' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index 46d8d13cebc..1febd620e61 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.21.2' + VERSION = '1.21.3.pre1' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 7299a21a23f..5ff025d1fa1 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.21.2' +VERSION = '1.21.3rc1' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index b7d5569f8d3..6264bf30779 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.2 +PROJECT_NUMBER = 1.21.3-pre1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 7848ef8f3a3..bb4f9791e90 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.2 +PROJECT_NUMBER = 1.21.3-pre1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From ad103834caf394a93a46fbadbe90ee9cd3bbd58b Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 3 Jun 2019 13:55:13 +0200 Subject: [PATCH 0396/1555] Fix syntax error --- tools/interop_matrix/client_matrix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index 6def5fbf286..6733c2f99c6 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -145,7 +145,7 @@ LANG_RELEASE_MATRIX = { ('v1.18.0', ReleaseInfo(runtimes=['java_oracle8'])), ('v1.19.0', ReleaseInfo(runtimes=['java_oracle8'])), ('v1.20.0', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.21.0', ReleaseInfo(runtimes=['java_oracle8']))), + ('v1.21.0', ReleaseInfo(runtimes=['java_oracle8'])), ]), 'python': OrderedDict([ From 04a3d9c2aa915fce17a4182b6bfd45b1d61e40c5 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 3 Jun 2019 08:49:29 -0700 Subject: [PATCH 0397/1555] build failure fix --- tools/run_tests/run_tests_matrix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index cfd67b99f34..ac9acbce730 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -249,7 +249,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['dbg'], platforms=['macos'], labels=['basictests', 'multilang'], - extra_args=extra_args + os.getenv('GRPC_OBJC_TEST_EXTRA_ARGS', '.*'), + extra_args=extra_args + [os.getenv('GRPC_OBJC_TEST_EXTRA_ARGS', '.*')], inner_jobs=inner_jobs, timeout_seconds=_OBJC_RUNTESTS_TIMEOUT) From 06f38432816613becfd5c5093a998c7cc76206ea Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 26 Apr 2019 05:11:06 -0400 Subject: [PATCH 0398/1555] refresh of interop matrix testcases --- tools/interop_matrix/testcases/cxx__master | 58 +++++++++----- tools/interop_matrix/testcases/go__master | 76 ++++++++++++++----- tools/interop_matrix/testcases/java__master | 76 ++++++++++++++----- tools/interop_matrix/testcases/php__master | 40 +++++----- tools/interop_matrix/testcases/python__master | 2 +- tools/interop_matrix/testcases/ruby__master | 40 +++++----- 6 files changed, 196 insertions(+), 96 deletions(-) diff --git a/tools/interop_matrix/testcases/cxx__master b/tools/interop_matrix/testcases/cxx__master index 629da1afd0d..eb43a15df7d 100755 --- a/tools/interop_matrix/testcases/cxx__master +++ b/tools/interop_matrix/testcases/cxx__master @@ -1,20 +1,40 @@ #!/bin/bash -echo "Testing ${docker_image:=grpc_interop_cxx:78de6f80-524d-4bc9-bfb2-f00c24ceafed}" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +# DO NOT MODIFY +# This file is generated by run_interop_tests.py/create_testcases.sh +echo "Testing ${docker_image:=grpc_interop_cxx:e5d09e32-2654-4e12-9a2e-1f0715768d1a}" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=large_unary --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=large_unary --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=google_default_credentials" diff --git a/tools/interop_matrix/testcases/go__master b/tools/interop_matrix/testcases/go__master index a7f83ae1693..ce61e14e3a1 100755 --- a/tools/interop_matrix/testcases/go__master +++ b/tools/interop_matrix/testcases/go__master @@ -1,20 +1,58 @@ #!/bin/bash -echo "Testing ${docker_image:=grpc_interop_go:dd8fbf3a-4964-4387-9997-5dadeea09835}" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +# DO NOT MODIFY +# This file is generated by run_interop_tests.py/create_testcases.sh +echo "Testing ${docker_image:=grpc_interop_go:27323929-b77f-4b15-9fe5-21403a49fa31}" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=large_unary --use_tls=true" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --use_tls=true" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --use_tls=true" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --use_tls=true" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --use_tls=true" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --use_tls=true" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --use_tls=true" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --use_tls=true" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --use_tls=true" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=large_unary --use_tls=true" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --use_tls=true" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --use_tls=true" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --use_tls=true" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --use_tls=true" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --use_tls=true" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --use_tls=true" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --use_tls=true" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --use_tls=true" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=compute_engine_channel_creds" diff --git a/tools/interop_matrix/testcases/java__master b/tools/interop_matrix/testcases/java__master index 95a9c2834f4..ac6b9aed5e6 100755 --- a/tools/interop_matrix/testcases/java__master +++ b/tools/interop_matrix/testcases/java__master @@ -1,20 +1,58 @@ #!/bin/bash -echo "Testing ${docker_image:=grpc_interop_java:a764b50c-1788-4387-9b9e-5cfa93927006}" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +# DO NOT MODIFY +# This file is generated by run_interop_tests.py/create_testcases.sh +echo "Testing ${docker_image:=grpc_interop_java:45b54245-f0e4-4e80-ad47-03826412871f}" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=large_unary --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=large_unary --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=compute_engine_channel_creds" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=google_default_credentials" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=compute_engine_channel_creds" diff --git a/tools/interop_matrix/testcases/php__master b/tools/interop_matrix/testcases/php__master index f99cb176212..3d7e99728aa 100755 --- a/tools/interop_matrix/testcases/php__master +++ b/tools/interop_matrix/testcases/php__master @@ -1,20 +1,22 @@ #!/bin/bash -echo "Testing ${docker_image:=grpc_interop_php:b290f404-9940-4968-8fc2-19f5291c8eb7}" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +# DO NOT MODIFY +# This file is generated by run_interop_tests.py/create_testcases.sh +echo "Testing ${docker_image:=grpc_interop_php:e00a3b45-27f0-4143-8c23-128cb4ffc46a}" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=large_unary --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=large_unary --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --use_tls=true" diff --git a/tools/interop_matrix/testcases/python__master b/tools/interop_matrix/testcases/python__master index 39e160188c7..0fc23810d0e 100755 --- a/tools/interop_matrix/testcases/python__master +++ b/tools/interop_matrix/testcases/python__master @@ -1,7 +1,7 @@ #!/bin/bash # DO NOT MODIFY # This file is generated by run_interop_tests.py/create_testcases.sh -echo "Testing ${docker_image:=grpc_interop_python:4fa5bb4b-5d57-4882-8c8e-551fb899b86a}" +echo "Testing ${docker_image:=grpc_interop_python:8f586cb2-054e-4653-91a4-3ffdc94e71fc}" docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py37_native/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=large_unary --use_tls=true\"" docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py37_native/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --use_tls=true\"" docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py37_native/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --use_tls=true\"" diff --git a/tools/interop_matrix/testcases/ruby__master b/tools/interop_matrix/testcases/ruby__master index 784ba689f6f..670171f3dbb 100755 --- a/tools/interop_matrix/testcases/ruby__master +++ b/tools/interop_matrix/testcases/ruby__master @@ -1,20 +1,22 @@ #!/bin/bash -echo "Testing ${docker_image:=grpc_interop_ruby:6bd1f0eb-51a4-4ad8-861c-1cbd7a929f33}" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +# DO NOT MODIFY +# This file is generated by run_interop_tests.py/create_testcases.sh +echo "Testing ${docker_image:=grpc_interop_ruby:e60da8f6-d7e0-47d3-8bfe-330ce76077b4}" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=large_unary --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=large_unary --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --use_tls=true" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --use_tls=true" From 7898ec24dd7e29730d8dded0813d13b9db8ef030 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 23 May 2019 14:33:33 -0400 Subject: [PATCH 0399/1555] fix client_matrix.py for php and ruby --- tools/interop_matrix/client_matrix.py | 66 ++++++++++----------- tools/interop_matrix/testcases/php__v1.0.1 | 20 +++++++ tools/interop_matrix/testcases/ruby__v1.1.4 | 20 +++++++ 3 files changed, 73 insertions(+), 33 deletions(-) create mode 100755 tools/interop_matrix/testcases/php__v1.0.1 create mode 100755 tools/interop_matrix/testcases/ruby__v1.1.4 diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index 9144be15443..57684a1af7d 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -195,22 +195,22 @@ LANG_RELEASE_MATRIX = { 'tools/dockerfile/interoptest/grpc_interop_ruby/build_interop.sh', ], testcases_file='ruby__v1.0.1')), - ('v1.1.4', ReleaseInfo()), - ('v1.2.5', ReleaseInfo()), - ('v1.3.9', ReleaseInfo()), - ('v1.4.2', ReleaseInfo()), - ('v1.6.6', ReleaseInfo()), - ('v1.7.2', ReleaseInfo()), - ('v1.8.0', ReleaseInfo()), - ('v1.9.1', ReleaseInfo()), - ('v1.10.1', ReleaseInfo()), - ('v1.11.1', ReleaseInfo()), - ('v1.12.0', ReleaseInfo()), - ('v1.13.0', ReleaseInfo()), - ('v1.14.1', ReleaseInfo()), - ('v1.15.0', ReleaseInfo()), - ('v1.16.0', ReleaseInfo()), - ('v1.17.1', ReleaseInfo()), + ('v1.1.4', ReleaseInfo(testcases_file='ruby__v1.1.4')), + ('v1.2.5', ReleaseInfo(testcases_file='ruby__v1.1.4')), + ('v1.3.9', ReleaseInfo(testcases_file='ruby__v1.1.4')), + ('v1.4.2', ReleaseInfo(testcases_file='ruby__v1.1.4')), + ('v1.6.6', ReleaseInfo(testcases_file='ruby__v1.1.4')), + ('v1.7.2', ReleaseInfo(testcases_file='ruby__v1.1.4')), + ('v1.8.0', ReleaseInfo(testcases_file='ruby__v1.1.4')), + ('v1.9.1', ReleaseInfo(testcases_file='ruby__v1.1.4')), + ('v1.10.1', ReleaseInfo(testcases_file='ruby__v1.1.4')), + ('v1.11.1', ReleaseInfo(testcases_file='ruby__v1.1.4')), + ('v1.12.0', ReleaseInfo(testcases_file='ruby__v1.1.4')), + ('v1.13.0', ReleaseInfo(testcases_file='ruby__v1.1.4')), + ('v1.14.1', ReleaseInfo(testcases_file='ruby__v1.1.4')), + ('v1.15.0', ReleaseInfo(testcases_file='ruby__v1.1.4')), + ('v1.16.0', ReleaseInfo(testcases_file='ruby__v1.1.4')), + ('v1.17.1', ReleaseInfo(testcases_file='ruby__v1.1.4')), ('v1.18.0', ReleaseInfo(patch=[ 'tools/dockerfile/interoptest/grpc_interop_ruby/build_interop.sh', @@ -223,23 +223,23 @@ LANG_RELEASE_MATRIX = { ]), 'php': OrderedDict([ - ('v1.0.1', ReleaseInfo()), - ('v1.1.4', ReleaseInfo()), - ('v1.2.5', ReleaseInfo()), - ('v1.3.9', ReleaseInfo()), - ('v1.4.2', ReleaseInfo()), - ('v1.6.6', ReleaseInfo()), - ('v1.7.2', ReleaseInfo()), - ('v1.8.0', ReleaseInfo()), - ('v1.9.1', ReleaseInfo()), - ('v1.10.1', ReleaseInfo()), - ('v1.11.1', ReleaseInfo()), - ('v1.12.0', ReleaseInfo()), - ('v1.13.0', ReleaseInfo()), - ('v1.14.1', ReleaseInfo()), - ('v1.15.0', ReleaseInfo()), - ('v1.16.0', ReleaseInfo()), - ('v1.17.1', ReleaseInfo()), + ('v1.0.1', ReleaseInfo(testcases_file='php__v1.0.1')), + ('v1.1.4', ReleaseInfo(testcases_file='php__v1.0.1')), + ('v1.2.5', ReleaseInfo(testcases_file='php__v1.0.1')), + ('v1.3.9', ReleaseInfo(testcases_file='php__v1.0.1')), + ('v1.4.2', ReleaseInfo(testcases_file='php__v1.0.1')), + ('v1.6.6', ReleaseInfo(testcases_file='php__v1.0.1')), + ('v1.7.2', ReleaseInfo(testcases_file='php__v1.0.1')), + ('v1.8.0', ReleaseInfo(testcases_file='php__v1.0.1')), + ('v1.9.1', ReleaseInfo(testcases_file='php__v1.0.1')), + ('v1.10.1', ReleaseInfo(testcases_file='php__v1.0.1')), + ('v1.11.1', ReleaseInfo(testcases_file='php__v1.0.1')), + ('v1.12.0', ReleaseInfo(testcases_file='php__v1.0.1')), + ('v1.13.0', ReleaseInfo(testcases_file='php__v1.0.1')), + ('v1.14.1', ReleaseInfo(testcases_file='php__v1.0.1')), + ('v1.15.0', ReleaseInfo(testcases_file='php__v1.0.1')), + ('v1.16.0', ReleaseInfo(testcases_file='php__v1.0.1')), + ('v1.17.1', ReleaseInfo(testcases_file='php__v1.0.1')), ('v1.18.0', ReleaseInfo()), # TODO:https://github.com/grpc/grpc/issues/18264 # Error in above issues needs to be resolved. diff --git a/tools/interop_matrix/testcases/php__v1.0.1 b/tools/interop_matrix/testcases/php__v1.0.1 new file mode 100755 index 00000000000..f99cb176212 --- /dev/null +++ b/tools/interop_matrix/testcases/php__v1.0.1 @@ -0,0 +1,20 @@ +#!/bin/bash +echo "Testing ${docker_image:=grpc_interop_php:b290f404-9940-4968-8fc2-19f5291c8eb7}" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" diff --git a/tools/interop_matrix/testcases/ruby__v1.1.4 b/tools/interop_matrix/testcases/ruby__v1.1.4 new file mode 100755 index 00000000000..784ba689f6f --- /dev/null +++ b/tools/interop_matrix/testcases/ruby__v1.1.4 @@ -0,0 +1,20 @@ +#!/bin/bash +echo "Testing ${docker_image:=grpc_interop_ruby:6bd1f0eb-51a4-4ad8-861c-1cbd7a929f33}" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" From fc0556ef03e64f2f15ce03c34bd8c34d39c4a519 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 23 May 2019 14:43:01 -0400 Subject: [PATCH 0400/1555] fix c++ client_matrix.py --- tools/interop_matrix/client_matrix.py | 38 +++++++++++----------- tools/interop_matrix/testcases/cxx__v1.0.1 | 20 ++++++++++++ 2 files changed, 39 insertions(+), 19 deletions(-) create mode 100755 tools/interop_matrix/testcases/cxx__v1.0.1 diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index 57684a1af7d..68426141dc5 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -77,25 +77,25 @@ class ReleaseInfo: LANG_RELEASE_MATRIX = { 'cxx': OrderedDict([ - ('v1.0.1', ReleaseInfo()), - ('v1.1.4', ReleaseInfo()), - ('v1.2.5', ReleaseInfo()), - ('v1.3.9', ReleaseInfo()), - ('v1.4.2', ReleaseInfo()), - ('v1.6.6', ReleaseInfo()), - ('v1.7.2', ReleaseInfo()), - ('v1.8.0', ReleaseInfo()), - ('v1.9.1', ReleaseInfo()), - ('v1.10.1', ReleaseInfo()), - ('v1.11.1', ReleaseInfo()), - ('v1.12.0', ReleaseInfo()), - ('v1.13.0', ReleaseInfo()), - ('v1.14.1', ReleaseInfo()), - ('v1.15.0', ReleaseInfo()), - ('v1.16.0', ReleaseInfo()), - ('v1.17.1', ReleaseInfo()), - ('v1.18.0', ReleaseInfo()), - ('v1.19.0', ReleaseInfo()), + ('v1.0.1', ReleaseInfo(testcases_file='cxx__v1.0.1')), + ('v1.1.4', ReleaseInfo(testcases_file='cxx__v1.0.1')), + ('v1.2.5', ReleaseInfo(testcases_file='cxx__v1.0.1')), + ('v1.3.9', ReleaseInfo(testcases_file='cxx__v1.0.1')), + ('v1.4.2', ReleaseInfo(testcases_file='cxx__v1.0.1')), + ('v1.6.6', ReleaseInfo(testcases_file='cxx__v1.0.1')), + ('v1.7.2', ReleaseInfo(testcases_file='cxx__v1.0.1')), + ('v1.8.0', ReleaseInfo(testcases_file='cxx__v1.0.1')), + ('v1.9.1', ReleaseInfo(testcases_file='cxx__v1.0.1')), + ('v1.10.1', ReleaseInfo(testcases_file='cxx__v1.0.1')), + ('v1.11.1', ReleaseInfo(testcases_file='cxx__v1.0.1')), + ('v1.12.0', ReleaseInfo(testcases_file='cxx__v1.0.1')), + ('v1.13.0', ReleaseInfo(testcases_file='cxx__v1.0.1')), + ('v1.14.1', ReleaseInfo(testcases_file='cxx__v1.0.1')), + ('v1.15.0', ReleaseInfo(testcases_file='cxx__v1.0.1')), + ('v1.16.0', ReleaseInfo(testcases_file='cxx__v1.0.1')), + ('v1.17.1', ReleaseInfo(testcases_file='cxx__v1.0.1')), + ('v1.18.0', ReleaseInfo(testcases_file='cxx__v1.0.1')), + ('v1.19.0', ReleaseInfo(testcases_file='cxx__v1.0.1')), ('v1.20.0', ReleaseInfo()), ]), 'go': diff --git a/tools/interop_matrix/testcases/cxx__v1.0.1 b/tools/interop_matrix/testcases/cxx__v1.0.1 new file mode 100755 index 00000000000..629da1afd0d --- /dev/null +++ b/tools/interop_matrix/testcases/cxx__v1.0.1 @@ -0,0 +1,20 @@ +#!/bin/bash +echo "Testing ${docker_image:=grpc_interop_cxx:78de6f80-524d-4bc9-bfb2-f00c24ceafed}" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" From 9c6830a3f5edf000a4c1060a10b5eab385a98015 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 23 May 2019 14:46:53 -0400 Subject: [PATCH 0401/1555] fix java client_matrix.py --- tools/interop_matrix/client_matrix.py | 40 ++++++++++----------- tools/interop_matrix/testcases/java__v1.0.3 | 20 +++++++++++ 2 files changed, 40 insertions(+), 20 deletions(-) create mode 100755 tools/interop_matrix/testcases/java__v1.0.3 diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index 68426141dc5..f4b05057ab3 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -124,26 +124,26 @@ LANG_RELEASE_MATRIX = { ]), 'java': OrderedDict([ - ('v1.0.3', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.1.2', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.2.0', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.3.1', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.4.0', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.5.0', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.6.1', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.7.0', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.8.0', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.9.1', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.10.1', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.11.0', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.12.0', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.13.1', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.14.0', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.15.0', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.16.1', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.17.1', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.18.0', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.19.0', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.0.3', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.1.2', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.2.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.3.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.4.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.5.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.6.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.7.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.8.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.9.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.10.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.11.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.12.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.13.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.14.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.15.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.16.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.17.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.18.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.19.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.20.0', ReleaseInfo(runtimes=['java_oracle8'])), ('v1.21.0', ReleaseInfo(runtimes=['java_oracle8'])), ]), diff --git a/tools/interop_matrix/testcases/java__v1.0.3 b/tools/interop_matrix/testcases/java__v1.0.3 new file mode 100755 index 00000000000..95a9c2834f4 --- /dev/null +++ b/tools/interop_matrix/testcases/java__v1.0.3 @@ -0,0 +1,20 @@ +#!/bin/bash +echo "Testing ${docker_image:=grpc_interop_java:a764b50c-1788-4387-9b9e-5cfa93927006}" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" From cc0fc17301d5aef9e4f27b3814b29c7b51a85b9e Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 23 May 2019 14:51:44 -0400 Subject: [PATCH 0402/1555] fix go client_matrix.py --- tools/interop_matrix/client_matrix.py | 38 +++++++++++------------ tools/interop_matrix/testcases/go__v1.0.5 | 20 ++++++++++++ 2 files changed, 39 insertions(+), 19 deletions(-) create mode 100755 tools/interop_matrix/testcases/go__v1.0.5 diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index f4b05057ab3..38cd94553a4 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -100,25 +100,25 @@ LANG_RELEASE_MATRIX = { ]), 'go': OrderedDict([ - ('v1.0.5', ReleaseInfo(runtimes=['go1.8'])), - ('v1.2.1', ReleaseInfo(runtimes=['go1.8'])), - ('v1.3.0', ReleaseInfo(runtimes=['go1.8'])), - ('v1.4.2', ReleaseInfo(runtimes=['go1.8'])), - ('v1.5.2', ReleaseInfo(runtimes=['go1.8'])), - ('v1.6.0', ReleaseInfo(runtimes=['go1.8'])), - ('v1.7.4', ReleaseInfo(runtimes=['go1.8'])), - ('v1.8.2', ReleaseInfo(runtimes=['go1.8'])), - ('v1.9.2', ReleaseInfo(runtimes=['go1.8'])), - ('v1.10.1', ReleaseInfo(runtimes=['go1.8'])), - ('v1.11.3', ReleaseInfo(runtimes=['go1.8'])), - ('v1.12.2', ReleaseInfo(runtimes=['go1.8'])), - ('v1.13.0', ReleaseInfo(runtimes=['go1.8'])), - ('v1.14.0', ReleaseInfo(runtimes=['go1.8'])), - ('v1.15.0', ReleaseInfo(runtimes=['go1.8'])), - ('v1.16.0', ReleaseInfo(runtimes=['go1.8'])), - ('v1.17.0', ReleaseInfo(runtimes=['go1.11'])), - ('v1.18.0', ReleaseInfo(runtimes=['go1.11'])), - ('v1.19.0', ReleaseInfo(runtimes=['go1.11'])), + ('v1.0.5', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.2.1', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.3.0', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.4.2', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.5.2', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.6.0', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.7.4', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.8.2', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.9.2', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.10.1', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.11.3', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.12.2', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.13.0', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.14.0', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.15.0', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.16.0', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.17.0', ReleaseInfo(runtimes=['go1.11'], testcases_file='go__v1.0.5')), + ('v1.18.0', ReleaseInfo(runtimes=['go1.11'], testcases_file='go__v1.0.5')), + ('v1.19.0', ReleaseInfo(runtimes=['go1.11'], testcases_file='go__v1.0.5')), ('v1.20.0', ReleaseInfo(runtimes=['go1.11'])), ('v1.21.0', ReleaseInfo(runtimes=['go1.11'])), ]), diff --git a/tools/interop_matrix/testcases/go__v1.0.5 b/tools/interop_matrix/testcases/go__v1.0.5 new file mode 100755 index 00000000000..a7f83ae1693 --- /dev/null +++ b/tools/interop_matrix/testcases/go__v1.0.5 @@ -0,0 +1,20 @@ +#!/bin/bash +echo "Testing ${docker_image:=grpc_interop_go:dd8fbf3a-4964-4387-9997-5dadeea09835}" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" From 62b35286a79464cec036597f5d292b9f57ed4764 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 24 May 2019 03:12:22 -0400 Subject: [PATCH 0403/1555] yapf --- tools/interop_matrix/client_matrix.py | 126 +++++++++++++++++--------- 1 file changed, 83 insertions(+), 43 deletions(-) diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index 38cd94553a4..43002c3b222 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -99,51 +99,91 @@ LANG_RELEASE_MATRIX = { ('v1.20.0', ReleaseInfo()), ]), 'go': - OrderedDict([ - ('v1.0.5', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), - ('v1.2.1', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), - ('v1.3.0', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), - ('v1.4.2', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), - ('v1.5.2', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), - ('v1.6.0', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), - ('v1.7.4', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), - ('v1.8.2', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), - ('v1.9.2', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), - ('v1.10.1', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), - ('v1.11.3', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), - ('v1.12.2', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), - ('v1.13.0', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), - ('v1.14.0', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), - ('v1.15.0', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), - ('v1.16.0', ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), - ('v1.17.0', ReleaseInfo(runtimes=['go1.11'], testcases_file='go__v1.0.5')), - ('v1.18.0', ReleaseInfo(runtimes=['go1.11'], testcases_file='go__v1.0.5')), - ('v1.19.0', ReleaseInfo(runtimes=['go1.11'], testcases_file='go__v1.0.5')), - ('v1.20.0', ReleaseInfo(runtimes=['go1.11'])), - ('v1.21.0', ReleaseInfo(runtimes=['go1.11'])), - ]), + OrderedDict( + [ + ('v1.0.5', + ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.2.1', + ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.3.0', + ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.4.2', + ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.5.2', + ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.6.0', + ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.7.4', + ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.8.2', + ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.9.2', + ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.10.1', + ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.11.3', + ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.12.2', + ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.13.0', + ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.14.0', + ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.15.0', + ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.16.0', + ReleaseInfo(runtimes=['go1.8'], testcases_file='go__v1.0.5')), + ('v1.17.0', + ReleaseInfo(runtimes=['go1.11'], testcases_file='go__v1.0.5')), + ('v1.18.0', + ReleaseInfo(runtimes=['go1.11'], testcases_file='go__v1.0.5')), + ('v1.19.0', + ReleaseInfo(runtimes=['go1.11'], testcases_file='go__v1.0.5')), + ('v1.20.0', ReleaseInfo(runtimes=['go1.11'])), + ('v1.21.0', ReleaseInfo(runtimes=['go1.11'])), + ]), 'java': OrderedDict([ - ('v1.0.3', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.1.2', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.2.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.3.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.4.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.5.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.6.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.7.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.8.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.9.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.10.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.11.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.12.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.13.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.14.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.15.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.16.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.17.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.18.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.19.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.0.3', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.1.2', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.2.0', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.3.1', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.4.0', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.5.0', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.6.1', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.7.0', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.8.0', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.9.1', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.10.1', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.11.0', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.12.0', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.13.1', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.14.0', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.15.0', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.16.1', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.17.1', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.18.0', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ('v1.19.0', + ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.20.0', ReleaseInfo(runtimes=['java_oracle8'])), ('v1.21.0', ReleaseInfo(runtimes=['java_oracle8'])), ]), From 97921f5d77f50496660bd3cc230df6a0bd6140e1 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 3 Jun 2019 08:16:32 -0400 Subject: [PATCH 0404/1555] add comments to interop scripts --- tools/interop_matrix/run_interop_matrix_tests.py | 2 ++ tools/run_tests/run_interop_tests.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/interop_matrix/run_interop_matrix_tests.py b/tools/interop_matrix/run_interop_matrix_tests.py index 3f92c8e6641..120ba08b465 100755 --- a/tools/interop_matrix/run_interop_matrix_tests.py +++ b/tools/interop_matrix/run_interop_matrix_tests.py @@ -86,6 +86,8 @@ argp.add_argument( type=str, nargs='?', help='Upload test results to a specified BQ table.') +# Requests will be routed through specified VIP by default. +# See go/grpc-interop-tests (internal-only) for details. argp.add_argument( '--server_host', default='74.125.206.210', diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py index cc6901bdebe..108f91e8383 100755 --- a/tools/run_tests/run_interop_tests.py +++ b/tools/run_tests/run_interop_tests.py @@ -1152,7 +1152,8 @@ def aggregate_http2_results(stdout): } -# A dictionary of prod servers to test. +# A dictionary of prod servers to test against. +# See go/grpc-interop-tests (internal-only) for details. prod_servers = { 'default': 'grpc-test.sandbox.googleapis.com', 'gateway_v4': 'grpc-test4.sandbox.googleapis.com', From c15665399735ae4de59d59606aeee2603a54bdc8 Mon Sep 17 00:00:00 2001 From: yang-g Date: Mon, 3 Jun 2019 10:38:37 -0700 Subject: [PATCH 0405/1555] Add listner fd as part of the external connection parameters --- include/grpcpp/server_builder_impl.h | 1 + src/core/lib/iomgr/tcp_server.h | 4 +++- src/core/lib/iomgr/tcp_server_posix.cc | 3 ++- src/cpp/server/external_connection_acceptor_impl.cc | 2 +- test/cpp/end2end/port_sharing_end2end_test.cc | 8 ++++++-- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/include/grpcpp/server_builder_impl.h b/include/grpcpp/server_builder_impl.h index 0de72cc397c..7f85e807d07 100644 --- a/include/grpcpp/server_builder_impl.h +++ b/include/grpcpp/server_builder_impl.h @@ -67,6 +67,7 @@ class CallbackGenericService; class ExternalConnectionAcceptor { public: struct NewConnectionParameters { + int listener_fd = -1; int fd = -1; ByteBuffer read_buffer; // data intended for the grpc server }; diff --git a/src/core/lib/iomgr/tcp_server.h b/src/core/lib/iomgr/tcp_server.h index 774f06ee17a..0d16b66230f 100644 --- a/src/core/lib/iomgr/tcp_server.h +++ b/src/core/lib/iomgr/tcp_server.h @@ -41,6 +41,7 @@ typedef struct grpc_tcp_server_acceptor { unsigned fd_index; /* Data when the connection is passed to tcp_server from external. */ bool external_connection; + int listener_fd; grpc_byte_buffer* pending_data; } grpc_tcp_server_acceptor; @@ -55,7 +56,8 @@ namespace grpc_core { class TcpServerFdHandler { public: virtual ~TcpServerFdHandler() = default; - virtual void Handle(int fd, grpc_byte_buffer* pending_read) GRPC_ABSTRACT; + virtual void Handle(int listener_fd, int fd, + grpc_byte_buffer* pending_read) GRPC_ABSTRACT; GRPC_ABSTRACT_BASE_CLASS; }; diff --git a/src/core/lib/iomgr/tcp_server_posix.cc b/src/core/lib/iomgr/tcp_server_posix.cc index 001f786b65d..689c005bf0d 100644 --- a/src/core/lib/iomgr/tcp_server_posix.cc +++ b/src/core/lib/iomgr/tcp_server_posix.cc @@ -572,7 +572,7 @@ class ExternalConnectionHandler : public grpc_core::TcpServerFdHandler { explicit ExternalConnectionHandler(grpc_tcp_server* s) : s_(s) {} // TODO(yangg) resolve duplicate code with on_read - void Handle(int fd, grpc_byte_buffer* buf) override { + void Handle(int listener_fd, int fd, grpc_byte_buffer* buf) override { grpc_pollset* read_notifier_pollset; grpc_resolved_address addr; char* addr_str; @@ -606,6 +606,7 @@ class ExternalConnectionHandler : public grpc_core::TcpServerFdHandler { acceptor->port_index = -1; acceptor->fd_index = -1; acceptor->external_connection = true; + acceptor->listener_fd = listener_fd; acceptor->pending_data = buf; s_->on_accept_cb(s_->on_accept_cb_arg, grpc_tcp_create(fdobj, s_->channel_args, addr_str), diff --git a/src/cpp/server/external_connection_acceptor_impl.cc b/src/cpp/server/external_connection_acceptor_impl.cc index afc90679398..7f0e2dcfe93 100644 --- a/src/cpp/server/external_connection_acceptor_impl.cc +++ b/src/cpp/server/external_connection_acceptor_impl.cc @@ -71,7 +71,7 @@ void ExternalConnectionAcceptorImpl::HandleNewConnection( return; } if (handler_) { - handler_->Handle(p->fd, p->read_buffer.c_buffer()); + handler_->Handle(p->listener_fd, p->fd, p->read_buffer.c_buffer()); } } diff --git a/test/cpp/end2end/port_sharing_end2end_test.cc b/test/cpp/end2end/port_sharing_end2end_test.cc index a2b9417d172..7ea5c046dc6 100644 --- a/test/cpp/end2end/port_sharing_end2end_test.cc +++ b/test/cpp/end2end/port_sharing_end2end_test.cc @@ -159,6 +159,8 @@ class TestTcpServer { gpr_log(GPR_INFO, "Got incoming connection! from %s", peer); gpr_free(peer); EXPECT_FALSE(acceptor->external_connection); + listener_fd_ = grpc_tcp_server_port_fd( + acceptor->from_server, acceptor->port_index, acceptor->fd_index); gpr_free(acceptor); grpc_tcp_destroy_and_release_fd(tcp, &fd_, &on_fd_released_); } @@ -166,6 +168,7 @@ class TestTcpServer { void OnFdReleased(grpc_error* err) { EXPECT_EQ(GRPC_ERROR_NONE, err); experimental::ExternalConnectionAcceptor::NewConnectionParameters p; + p.listener_fd = listener_fd_; p.fd = fd_; if (queue_data_) { char buf[1024]; @@ -176,14 +179,15 @@ class TestTcpServer { Slice data(buf, read_bytes); p.read_buffer = ByteBuffer(&data, 1); } - gpr_log(GPR_INFO, "Handing off fd %d with data size %d", fd_, - static_cast(p.read_buffer.Length())); + gpr_log(GPR_INFO, "Handing off fd %d with data size %d from listener fd %d", + fd_, static_cast(p.read_buffer.Length()), listener_fd_); connection_acceptor_->HandleNewConnection(&p); } std::mutex mu_; bool shutdown_; + int listener_fd_; int fd_; bool queue_data_; From 8e159df5e8ddf647675f1e17af97120a51d50eca Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Sat, 1 Jun 2019 18:59:41 -0700 Subject: [PATCH 0406/1555] Bump to version 1.21.3 --- BUILD | 2 +- build.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index e0113d48a18..af1d7847cef 100644 --- a/BUILD +++ b/BUILD @@ -78,7 +78,7 @@ g_stands_for = "gandalf" core_version = "7.0.0" -version = "1.21.3-pre1" +version = "1.21.3" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index 6bc58bf4411..d9a72738f48 100644 --- a/build.yaml +++ b/build.yaml @@ -14,7 +14,7 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 7.0.0 g_stands_for: gandalf - version: 1.21.3-pre1 + version: 1.21.3 filegroups: - name: alts_proto headers: From 961ca7ec9d9a5812e06e1605b6349a2f284e48d4 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Mon, 3 Jun 2019 10:49:11 -0700 Subject: [PATCH 0407/1555] Re-generate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 6 +++--- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 8 ++++---- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 2 +- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 29 files changed, 35 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0067454a2d7..1f01e790264 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.21.3-pre1") +set(PACKAGE_VERSION "1.21.3") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 2b150815592..fd29aa3fc73 100644 --- a/Makefile +++ b/Makefile @@ -460,8 +460,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.21.3-pre1 -CSHARP_VERSION = 1.21.3-pre1 +CPP_VERSION = 1.21.3 +CSHARP_VERSION = 1.21.3 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 47b18b9b75d..1fdd6423a7e 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,15 +23,15 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.21.3-pre1' - version = '0.0.9-pre1' + # version = '1.21.3' + version = '0.0.9' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.21.3-pre1' + grpc_version = '1.21.3' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index ce9a7d6a525..061d3a27504 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.21.3-pre1' + version = '1.21.3' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 3f8180c4d3e..c38719b7d52 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.21.3-pre1' + version = '1.21.3' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 6a8a7b89061..20f93164969 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.21.3-pre1' + version = '1.21.3' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index 1afc2e68623..e268a8b21aa 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.21.3-pre1' + version = '1.21.3' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index 7292aa634eb..f03c4e694d8 100644 --- a/package.xml +++ b/package.xml @@ -13,12 +13,12 @@ 2018-01-19 - 1.21.3RC1 - 1.21.3RC1 + 1.21.3 + 1.21.3 - beta - beta + stable + stable Apache 2.0 diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index fcb80876989..98c1ba34470 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.21.3-pre1"; } +grpc::string Version() { return "1.21.3"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index f3420552430..3d4bdd9ee78 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -38,6 +38,6 @@ namespace Grpc.Core /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.21.3-pre1"; + public const string CurrentVersion = "1.21.3"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index 0819b58b5f1..949b683ccb5 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 1.21.3-pre1 + 1.21.3 3.7.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index 0504ee05855..a371568fab8 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=1.21.3-pre1 +set VERSION=1.21.3 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 958f30a5994..c4b588824de 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.21.3-pre1' + v = '1.21.3' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 4ab2203fd09..20cf2ac4811 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.3-pre1" +#define GRPC_OBJC_VERSION_STRING @"1.21.3" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 20f3f55cf44..0aa72ca70da 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.3-pre1" +#define GRPC_OBJC_VERSION_STRING @"1.21.3" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 0619b687a5b..d401a7d2095 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.21.3RC1" +#define PHP_GRPC_VERSION "1.21.3" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index 94a507ace4e..ea4600f7d0a 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.21.3rc1""" +__version__ = """1.21.3""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index 2ae2edfad44..ad12bf478ed 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.21.3rc1' +VERSION = '1.21.3' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index 19a2283ed55..73ecfb1c3c7 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.21.3rc1' +VERSION = '1.21.3' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index 19cefb59977..c26d3697972 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.21.3rc1' +VERSION = '1.21.3' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 2bc839f13a1..b434ba9422e 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.21.3rc1' +VERSION = '1.21.3' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index c1f396d0bc8..4516db48837 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.21.3rc1' +VERSION = '1.21.3' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 4b0438ad4d5..735c66a9081 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.21.3rc1' +VERSION = '1.21.3' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index 7f12f28c47b..ab2507f2c94 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.21.3rc1' +VERSION = '1.21.3' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 9ae6bcfe1c7..55b26e434a6 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.21.3.pre1' + VERSION = '1.21.3' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index 1febd620e61..4effc70d476 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.21.3.pre1' + VERSION = '1.21.3' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 5ff025d1fa1..bb7110142ae 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.21.3rc1' +VERSION = '1.21.3' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 6264bf30779..15f82e95211 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.3-pre1 +PROJECT_NUMBER = 1.21.3 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index bb4f9791e90..63614418486 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.3-pre1 +PROJECT_NUMBER = 1.21.3 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From 21f512eddf243b05f650431b942758b38582b518 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 3 Jun 2019 11:22:30 -0700 Subject: [PATCH 0408/1555] Make a copy of received headers --- src/objective-c/GRPCClient/GRPCCall.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 71b03f15f17..5a3440f84ed 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -714,7 +714,12 @@ const char *kCFStreamVarName = "grpc_cfstream"; __strong GRPCCall *strongSelf = weakSelf; if (strongSelf) { @synchronized(strongSelf) { - strongSelf.responseHeaders = headers; + // it is ok to set nil because headers are only received once + strongSelf.responseHeaders = nil; + // copy the header so that the GRPCOpRecvMetadata object may be dealloc'ed + NSDictionary *copiedHeaders = [[NSDictionary alloc] initWithDictionary:headers + copyItems:YES]; + strongSelf.responseHeaders = copiedHeaders; strongSelf->_pendingCoreRead = NO; [strongSelf maybeStartNextRead]; } From 6ced31ee8963be25506e16d8978e4cfd5ba18957 Mon Sep 17 00:00:00 2001 From: yang-g Date: Mon, 3 Jun 2019 13:10:12 -0700 Subject: [PATCH 0409/1555] resolve review comments --- test/cpp/end2end/port_sharing_end2end_test.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/cpp/end2end/port_sharing_end2end_test.cc b/test/cpp/end2end/port_sharing_end2end_test.cc index 7ea5c046dc6..4f30290d815 100644 --- a/test/cpp/end2end/port_sharing_end2end_test.cc +++ b/test/cpp/end2end/port_sharing_end2end_test.cc @@ -187,13 +187,13 @@ class TestTcpServer { std::mutex mu_; bool shutdown_; - int listener_fd_; - int fd_; - bool queue_data_; + int listener_fd_ = -1; + int fd_ = -1; + bool queue_data_ = false; grpc_closure on_fd_released_; std::thread running_thread_; - int port_; + int port_ = -1; grpc::string address_; std::unique_ptr connection_acceptor_; From 91eb1141a98d374ebdad56e0b139aebf3ac12535 Mon Sep 17 00:00:00 2001 From: yang-g Date: Mon, 3 Jun 2019 13:16:48 -0700 Subject: [PATCH 0410/1555] Ask server to skip cancel check --- test/cpp/end2end/end2end_test.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 983714c044a..a8592fd97c2 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -1875,6 +1875,7 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginWithDeadline) { MAYBE_SKIP_TEST; ResetStub(); EchoRequest request; + request.mutable_param()->set_skip_cancelled_check(true); EchoResponse response; ClientContext context; const int delay = 100; @@ -1898,6 +1899,7 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginWithCancel) { MAYBE_SKIP_TEST; ResetStub(); EchoRequest request; + request.mutable_param()->set_skip_cancelled_check(true); EchoResponse response; ClientContext context; const int delay = 100; From b0ef377ebdfb1b4ea4ea7b5e4910d163140dc8e1 Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Mon, 3 Jun 2019 09:22:08 -0700 Subject: [PATCH 0411/1555] Fixed erase() method by changing RemoveRecursive() to return a new iterator to the successor in addition to the new root. Both are returned as a single pair --- src/core/lib/gprpp/map.h | 49 ++++++++++++++++------------- test/core/gprpp/map_test.cc | 62 ++++++++++++++++++++++++------------- 2 files changed, 69 insertions(+), 42 deletions(-) diff --git a/src/core/lib/gprpp/map.h b/src/core/lib/gprpp/map.h index b210c26cbff..525c25347f4 100644 --- a/src/core/lib/gprpp/map.h +++ b/src/core/lib/gprpp/map.h @@ -112,7 +112,10 @@ class Map { // inserted entry and the second value being the new root of the subtree // after a rebalance Pair InsertRecursive(Entry* root, value_type&& p); - static Entry* RemoveRecursive(Entry* root, const key_type& k); + // Returns a pair with the first value being an iterator pointing to the + // successor of the deleted entry and the second value being the new root of + // the subtree after a rebalance + Pair RemoveRecursive(Entry* root, const key_type& k); // Return 0 if lhs = rhs // 1 if lhs > rhs // -1 if lhs < rhs @@ -233,10 +236,10 @@ typename Map::iterator Map::erase( iterator iter) { if (iter == end()) return iter; key_type& del_key = iter->first; - iter++; - root_ = RemoveRecursive(root_, del_key); + Pair ret = RemoveRecursive(root_, del_key); + root_ = ret.second; size_--; - return iter; + return ret.first; } template @@ -373,34 +376,38 @@ Map::RebalanceTreeAfterDeletion(Entry* root) { } template -typename Map::Entry* Map::RemoveRecursive( - Entry* root, const key_type& k) { - if (root == nullptr) return root; +typename ::grpc_core::Pair::iterator, + typename Map::Entry*> +Map::RemoveRecursive(Entry* root, const key_type& k) { + Pair ret = MakePair(end(), root); + if (root == nullptr) return ret; int comp = CompareKeys(root->pair.first, k); if (comp > 0) { - root->left = RemoveRecursive(root->left, k); + ret = RemoveRecursive(root->left, k); + root->left = ret.second; } else if (comp < 0) { - root->right = RemoveRecursive(root->right, k); + ret = RemoveRecursive(root->right, k); + root->right = ret.second; } else { - Entry* ret; + Entry* entry; + Entry* successor = InOrderSuccessor(root); if (root->left == nullptr) { - ret = root->right; + entry = root->right; Delete(root); - return ret; + return MakePair(iterator(this, successor), entry); } else if (root->right == nullptr) { - ret = root->left; + entry = root->left; Delete(root); - return ret; + return MakePair(iterator(this, successor), entry); } else { - ret = root->right; - while (ret->left != nullptr) { - ret = ret->left; - } - root->pair.swap(ret->pair); - root->right = RemoveRecursive(root->right, ret->pair.first); + entry = successor; + root->pair.swap(entry->pair); + ret = RemoveRecursive(root->right, entry->pair.first); + root->right = ret.second; + ret.first = iterator(this, root); } } - return RebalanceTreeAfterDeletion(root); + return MakePair(ret.first, RebalanceTreeAfterDeletion(root)); } template diff --git a/test/core/gprpp/map_test.cc b/test/core/gprpp/map_test.cc index e70bf38f111..6e70a2a2ac2 100644 --- a/test/core/gprpp/map_test.cc +++ b/test/core/gprpp/map_test.cc @@ -17,7 +17,9 @@ */ #include "src/core/lib/gprpp/map.h" + #include + #include "include/grpc/support/string_util.h" #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/gprpp/memory.h" @@ -319,43 +321,49 @@ TEST_F(MapTest, MapRandomInsertions) { // Test Map iterator TEST_F(MapTest, Iteration) { Map test_map; - for (int i = 0; i < 5; i++) { + for (int i = 4; i >= 0; --i) { test_map.emplace(kKeys[i], Payload(i)); } - int count = 0; - for (auto iter = test_map.begin(); iter != test_map.end(); iter++) { - EXPECT_EQ(iter->second.data(), count); - count++; + auto it = test_map.begin(); + for (int i = 0; i < 5; ++i) { + ASSERT_NE(it, test_map.end()); + EXPECT_STREQ(kKeys[i], it->first); + EXPECT_EQ(i, it->second.data()); + ++it; } - EXPECT_EQ(count, 5); + EXPECT_EQ(it, test_map.end()); } // Test Map iterator with unique ptr payload TEST_F(MapTest, IterationWithUniquePtrValue) { Map, StringLess> test_map; - for (int i = 0; i < 5; i++) { + for (int i = 4; i >= 0; --i) { test_map.emplace(kKeys[i], MakeUnique(i)); } - int count = 0; - for (auto iter = test_map.begin(); iter != test_map.end(); iter++) { - EXPECT_EQ(iter->second->data(), count); - count++; + auto it = test_map.begin(); + for (int i = 0; i < 5; ++i) { + ASSERT_NE(it, test_map.end()); + EXPECT_STREQ(kKeys[i], it->first); + EXPECT_EQ(i, it->second->data()); + ++it; } - EXPECT_EQ(count, 5); + EXPECT_EQ(it, test_map.end()); } // Test Map iterator with unique ptr to char key TEST_F(MapTest, IterationWithUniquePtrKey) { Map, Payload, StringLess> test_map; - for (int i = 0; i < 5; i++) { + for (int i = 4; i >= 0; --i) { test_map.emplace(CopyString(kKeys[i]), Payload(i)); } - int count = 0; - for (auto iter = test_map.begin(); iter != test_map.end(); iter++) { - EXPECT_EQ(iter->second.data(), count); - count++; + auto it = test_map.begin(); + for (int i = 0; i < 5; ++i) { + ASSERT_NE(it, test_map.end()); + EXPECT_STREQ(kKeys[i], it->first.get()); + EXPECT_EQ(i, it->second.data()); + ++it; } - EXPECT_EQ(count, 5); + EXPECT_EQ(it, test_map.end()); } // Test removing entries while iterating the map @@ -367,11 +375,23 @@ TEST_F(MapTest, EraseUsingIterator) { int count = 0; for (auto iter = test_map.begin(); iter != test_map.end();) { EXPECT_EQ(iter->second.data(), count); - iter = test_map.erase(iter); - count++; + if (count % 2 == 1) { + iter = test_map.erase(iter); + } else { + ++iter; + } + ++count; } EXPECT_EQ(count, 5); - EXPECT_TRUE(test_map.empty()); + auto it = test_map.begin(); + for (int i = 0; i < 5; ++i) { + if (i % 2 == 0) { + EXPECT_STREQ(kKeys[i], it->first); + EXPECT_EQ(i, it->second.data()); + ++it; + } + } + EXPECT_EQ(it, test_map.end()); } // Random ops on a Map with Integer key of Payload value, From 58771fa12adada9b282ed8729f25eac365571f7e Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Mon, 3 Jun 2019 22:08:40 -0700 Subject: [PATCH 0412/1555] Fix cfstream_test flake Ask server to skip cancel check in network flap test. --- test/cpp/end2end/cfstream_test.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/cpp/end2end/cfstream_test.cc b/test/cpp/end2end/cfstream_test.cc index 59cf98ffc20..613bc1d0b09 100644 --- a/test/cpp/end2end/cfstream_test.cc +++ b/test/cpp/end2end/cfstream_test.cc @@ -341,7 +341,9 @@ TEST_P(CFStreamTest, NetworkFlapRpcsInFlight) { // Channel should be in READY state after we send some RPCs for (int i = 0; i < 10; ++i) { - SendAsyncRpc(stub); + RequestParams param; + param.set_skip_cancelled_check(true); + SendAsyncRpc(stub, param); ++rpcs_sent; } EXPECT_TRUE(WaitForChannelReady(channel.get())); @@ -374,7 +376,9 @@ TEST_P(CFStreamTest, NetworkFlapRpcsInFlight) { }); for (int i = 0; i < 100; ++i) { - SendAsyncRpc(stub); + RequestParams param; + param.set_skip_cancelled_check(true); + SendAsyncRpc(stub, param); std::this_thread::sleep_for(std::chrono::milliseconds(10)); ++rpcs_sent; } From 9fdc46aa0849428768635dbc9f3485d51c9afd48 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 4 Jun 2019 07:22:24 -0400 Subject: [PATCH 0413/1555] php interop client: construct channel target like other languages do --- src/php/tests/interop/interop_client.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php index 19cbf21bc2b..e4750475dc5 100755 --- a/src/php/tests/interop/interop_client.php +++ b/src/php/tests/interop/interop_client.php @@ -530,12 +530,7 @@ function _makeStub($args) throw new Exception('Missing argument: --test_case is required'); } - if ($args['server_port'] === '443') { - $server_address = $args['server_host']; - } else { - $server_address = $args['server_host'].':'.$args['server_port']; - } - + $server_address = $args['server_host'].':'.$args['server_port']; $test_case = $args['test_case']; $host_override = ''; From 15cae38cbd38f06846c15df437a901fe70662a37 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 4 Jun 2019 10:27:59 -0400 Subject: [PATCH 0414/1555] remove port suffix from JWT audience --- src/php/lib/Grpc/BaseStub.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/php/lib/Grpc/BaseStub.php b/src/php/lib/Grpc/BaseStub.php index fe81e377610..1d2c30341dd 100644 --- a/src/php/lib/Grpc/BaseStub.php +++ b/src/php/lib/Grpc/BaseStub.php @@ -199,6 +199,13 @@ class BaseStub */ private function _get_jwt_aud_uri($method) { + // TODO(jtattermusch): This is not the correct implementation + // of extracting JWT "aud" claim. We should rely on + // grpc_metadata_credentials_plugin which + // also provides the correct value of "aud" claim + // in the grpc_auth_metadata_context.service_url field. + // Trying to do the construction of "aud" field ourselves + // is bad. $last_slash_idx = strrpos($method, '/'); if ($last_slash_idx === false) { throw new \InvalidArgumentException( @@ -213,6 +220,12 @@ class BaseStub $hostname = $this->hostname; } + // Remove the port if it is 443 + // See https://github.com/grpc/grpc/blob/07c9f7a36b2a0d34fcffebc85649cf3b8c339b5d/src/core/lib/security/transport/client_auth_filter.cc#L205 + if ((strlen($hostname) > 4) && (substr($hostname, -4) === ":443")) { + $hostname = substr($hostname, 0, -4); + } + return 'https://'.$hostname.$service_name; } From e8cb29dd1ebb02867d0f493d4490ff728c440c20 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 4 Jun 2019 09:47:29 -0400 Subject: [PATCH 0415/1555] allow dots in metadata keys --- src/php/lib/Grpc/BaseStub.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/php/lib/Grpc/BaseStub.php b/src/php/lib/Grpc/BaseStub.php index fe81e377610..d2f293257ce 100644 --- a/src/php/lib/Grpc/BaseStub.php +++ b/src/php/lib/Grpc/BaseStub.php @@ -228,10 +228,10 @@ class BaseStub { $metadata_copy = []; foreach ($metadata as $key => $value) { - if (!preg_match('/^[A-Za-z\d_-]+$/', $key)) { + if (!preg_match('/^[.A-Za-z\d_-]+$/', $key)) { throw new \InvalidArgumentException( 'Metadata keys must be nonempty strings containing only '. - 'alphanumeric characters, hyphens and underscores' + 'alphanumeric characters, hyphens, underscores and dots' ); } $metadata_copy[strtolower($key)] = $value; From c0dd83e9a0fb603731454745954e01637701c8d8 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Tue, 4 Jun 2019 11:12:23 -0700 Subject: [PATCH 0416/1555] Add documentation about CallCredentials restriction --- src/python/grpcio/grpc/__init__.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index 6175180e92a..f0c198db66d 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -584,6 +584,9 @@ class ChannelCredentials(object): class CallCredentials(object): """An encapsulation of the data required to assert an identity over a call. + A CallCredentials has to be used with secure Channel, otherwise the + metadata will not be transmitted to the server. + A CallCredentials may be composed with ChannelCredentials to always assert identity for every call over that Channel. @@ -682,7 +685,8 @@ class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): for the RPC. metadata: Optional :term:`metadata` to be transmitted to the service-side of the RPC. - credentials: An optional CallCredentials for the RPC. + credentials: An optional CallCredentials for the RPC. Only valid for + secure Channel. wait_for_ready: This is an EXPERIMENTAL argument. An optional flag to enable wait for ready mechanism compression: An element of grpc.compression, e.g. @@ -714,7 +718,8 @@ class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): the RPC. metadata: Optional :term:`metadata` to be transmitted to the service-side of the RPC. - credentials: An optional CallCredentials for the RPC. + credentials: An optional CallCredentials for the RPC. Only valid for + secure Channel. wait_for_ready: This is an EXPERIMENTAL argument. An optional flag to enable wait for ready mechanism compression: An element of grpc.compression, e.g. @@ -746,7 +751,8 @@ class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): the RPC. metadata: Optional :term:`metadata` to be transmitted to the service-side of the RPC. - credentials: An optional CallCredentials for the RPC. + credentials: An optional CallCredentials for the RPC. Only valid for + secure Channel. wait_for_ready: This is an EXPERIMENTAL argument. An optional flag to enable wait for ready mechanism compression: An element of grpc.compression, e.g. @@ -781,7 +787,8 @@ class UnaryStreamMultiCallable(six.with_metaclass(abc.ABCMeta)): the RPC. If None, the timeout is considered infinite. metadata: An optional :term:`metadata` to be transmitted to the service-side of the RPC. - credentials: An optional CallCredentials for the RPC. + credentials: An optional CallCredentials for the RPC. Only valid for + secure Channel. wait_for_ready: This is an EXPERIMENTAL argument. An optional flag to enable wait for ready mechanism compression: An element of grpc.compression, e.g. @@ -816,7 +823,8 @@ class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): the RPC. If None, the timeout is considered infinite. metadata: Optional :term:`metadata` to be transmitted to the service-side of the RPC. - credentials: An optional CallCredentials for the RPC. + credentials: An optional CallCredentials for the RPC. Only valid for + secure Channel. wait_for_ready: This is an EXPERIMENTAL argument. An optional flag to enable wait for ready mechanism compression: An element of grpc.compression, e.g. @@ -849,7 +857,8 @@ class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): the RPC. If None, the timeout is considered infinite. metadata: Optional :term:`metadata` to be transmitted to the service-side of the RPC. - credentials: An optional CallCredentials for the RPC. + credentials: An optional CallCredentials for the RPC. Only valid for + secure Channel. wait_for_ready: This is an EXPERIMENTAL argument. An optional flag to enable wait for ready mechanism compression: An element of grpc.compression, e.g. @@ -881,7 +890,8 @@ class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): the RPC. If None, the timeout is considered infinite. metadata: Optional :term:`metadata` to be transmitted to the service-side of the RPC. - credentials: An optional CallCredentials for the RPC. + credentials: An optional CallCredentials for the RPC. Only valid for + secure Channel. wait_for_ready: This is an EXPERIMENTAL argument. An optional flag to enable wait for ready mechanism compression: An element of grpc.compression, e.g. @@ -916,7 +926,8 @@ class StreamStreamMultiCallable(six.with_metaclass(abc.ABCMeta)): the RPC. If not specified, the timeout is considered infinite. metadata: Optional :term:`metadata` to be transmitted to the service-side of the RPC. - credentials: An optional CallCredentials for the RPC. + credentials: An optional CallCredentials for the RPC. Only valid for + secure Channel. wait_for_ready: This is an EXPERIMENTAL argument. An optional flag to enable wait for ready mechanism compression: An element of grpc.compression, e.g. From 873b39d81e5544469ca4607f616021080d14e5e0 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Tue, 4 Jun 2019 13:56:25 -0700 Subject: [PATCH 0417/1555] Update server_side_auth about the CallCredential --- doc/server_side_auth.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/server_side_auth.md b/doc/server_side_auth.md index d260237928d..e425289faa9 100644 --- a/doc/server_side_auth.md +++ b/doc/server_side_auth.md @@ -2,6 +2,7 @@ Server-side API for Authenticating Clients ========================================== NOTE: This document describes how server-side authentication works in C-core based gRPC implementations only. In gRPC Java and Go, server side authentication is handled differently. +NOTE2: `CallCredentials` class is only valid for secure channels in C-Core. So, for connections under insecure channels, features below might not be avaiable. ## AuthContext From 05e26ff4cfd167d29c30b40ca689879075c9b585 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 3 Jun 2019 11:50:48 -0400 Subject: [PATCH 0418/1555] introduce --custom_credentials_type to run_interop_tests.py --- tools/run_tests/run_interop_tests.py | 68 ++++++++++++---------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py index 108f91e8383..0845647ecd6 100755 --- a/tools/run_tests/run_interop_tests.py +++ b/tools/run_tests/run_interop_tests.py @@ -738,6 +738,10 @@ _SERVERS_FOR_ALTS_TEST_CASES = ['java', 'go', 'c++'] _TRANSPORT_SECURITY_OPTIONS = ['tls', 'alts', 'insecure'] +_CUSTOM_CREDENTIALS_TYPE_OPTIONS = [ + 'tls', 'google_default_credentials', 'compute_engine_channel_creds' +] + DOCKER_WORKDIR_ROOT = '/var/local/git/grpc' @@ -1267,6 +1271,14 @@ argp.add_argument( nargs='?', const=True, help='Which transport security mechanism to use.') +argp.add_argument( + '--custom_credentials_type', + choices=_CUSTOM_CREDENTIALS_TYPE_OPTIONS, + default=_CUSTOM_CREDENTIALS_TYPE_OPTIONS, + nargs='+', + help= + 'Credential types to test in the cloud_to_prod setup. Default is to test with all creds types possible.' +) argp.add_argument( '--skip_compute_engine_creds', default=False, @@ -1436,23 +1448,20 @@ try: for test_case in _TEST_CASES: if not test_case in language.unimplemented_test_cases(): if not test_case in _SKIP_ADVANCED + _SKIP_COMPRESSION + _SKIP_SPECIAL_STATUS_MESSAGE: - tls_test_job = cloud_to_prod_jobspec( - language, - test_case, - server_host_nickname, - prod_servers[server_host_nickname], - google_default_creds_use_key_file=args. - google_default_creds_use_key_file, - docker_image=docker_images.get(str(language)), - manual_cmd_log=client_manual_cmd_log, - service_account_key_file=args. - service_account_key_file, - transport_security='tls') - jobs.append(tls_test_job) - if str(language) in [ - 'c++', 'go', 'java', 'javaokhttp' - ]: - google_default_creds_test_job = cloud_to_prod_jobspec( + for transport_security in args.custom_credentials_type: + # google_default_credentials not yet supported by all languages + if transport_security == 'google_default_credentials' and str( + language) not in [ + 'c++', 'go', 'java', 'javaokhttp' + ]: + continue + # compute_engine_channel_creds not yet supported by all languages + if transport_security == 'compute_engine_channel_creds' and str( + language) not in [ + 'go', 'java', 'javaokhttp' + ]: + continue + test_job = cloud_to_prod_jobspec( language, test_case, server_host_nickname, @@ -1464,27 +1473,8 @@ try: manual_cmd_log=client_manual_cmd_log, service_account_key_file=args. service_account_key_file, - transport_security= - 'google_default_credentials') - jobs.append(google_default_creds_test_job) - if str(language) in ['go', 'java', 'javaokhttp']: - compute_engine_channel_creds_test_job = cloud_to_prod_jobspec( - language, - test_case, - server_host_nickname, - prod_servers[server_host_nickname], - google_default_creds_use_key_file=args. - google_default_creds_use_key_file, - docker_image=docker_images.get( - str(language)), - manual_cmd_log=client_manual_cmd_log, - service_account_key_file=args. - service_account_key_file, - transport_security= - 'compute_engine_channel_creds') - jobs.append( - compute_engine_channel_creds_test_job) - + transport_security=transport_security) + jobs.append(test_job) if args.http2_interop: for test_case in _HTTP2_TEST_CASES: test_job = cloud_to_prod_jobspec( @@ -1516,6 +1506,8 @@ try: transport_security = 'compute_engine_channel_creds' else: transport_security = 'tls' + if transport_security not in args.custom_credentials_type: + continue test_job = cloud_to_prod_jobspec( language, test_case, From a1538246fdbfb8b0f6efbaf68fbee0e810ee10fa Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 3 Jun 2019 12:16:13 -0400 Subject: [PATCH 0419/1555] only generate TLS-based testcases for interop_matrix --- tools/interop_matrix/create_testcases.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/interop_matrix/create_testcases.sh b/tools/interop_matrix/create_testcases.sh index fa33fa4615f..b3e3ee6cd25 100755 --- a/tools/interop_matrix/create_testcases.sh +++ b/tools/interop_matrix/create_testcases.sh @@ -60,7 +60,7 @@ fi echo $client_lang ${GRPC_ROOT}/tools/run_tests/run_interop_tests.py -l $client_lang --use_docker \ - --cloud_to_prod --prod_servers default gateway_v4 --manual_run + --cloud_to_prod --prod_servers default gateway_v4 --manual_run --custom_credentials_type tls trap cleanup EXIT # TODO(adelez): add test auth tests but do not run if not testing on GCE. From 91b4be4da6030d37461e45e1eb028cc71d03e89c Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 3 Jun 2019 13:15:51 -0400 Subject: [PATCH 0420/1555] regenerate master tescases for c++, java and go --- tools/interop_matrix/testcases/cxx__master | 20 +---------- tools/interop_matrix/testcases/go__master | 38 +-------------------- tools/interop_matrix/testcases/java__master | 38 +-------------------- 3 files changed, 3 insertions(+), 93 deletions(-) diff --git a/tools/interop_matrix/testcases/cxx__master b/tools/interop_matrix/testcases/cxx__master index eb43a15df7d..5739d6649e7 100755 --- a/tools/interop_matrix/testcases/cxx__master +++ b/tools/interop_matrix/testcases/cxx__master @@ -1,40 +1,22 @@ #!/bin/bash # DO NOT MODIFY # This file is generated by run_interop_tests.py/create_testcases.sh -echo "Testing ${docker_image:=grpc_interop_cxx:e5d09e32-2654-4e12-9a2e-1f0715768d1a}" +echo "Testing ${docker_image:=grpc_interop_cxx:f5a2f91d-342a-4bc8-a5ca-eb113dd3a8a2}" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=large_unary --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=google_default_credentials" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=google_default_credentials" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=google_default_credentials" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=google_default_credentials" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=google_default_credentials" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=google_default_credentials" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=google_default_credentials" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=google_default_credentials" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=google_default_credentials" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=large_unary --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=google_default_credentials" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=google_default_credentials" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=google_default_credentials" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=google_default_credentials" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=google_default_credentials" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=google_default_credentials" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=google_default_credentials" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=google_default_credentials" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=google_default_credentials" diff --git a/tools/interop_matrix/testcases/go__master b/tools/interop_matrix/testcases/go__master index ce61e14e3a1..ab83d6beb0a 100755 --- a/tools/interop_matrix/testcases/go__master +++ b/tools/interop_matrix/testcases/go__master @@ -1,58 +1,22 @@ #!/bin/bash # DO NOT MODIFY # This file is generated by run_interop_tests.py/create_testcases.sh -echo "Testing ${docker_image:=grpc_interop_go:27323929-b77f-4b15-9fe5-21403a49fa31}" +echo "Testing ${docker_image:=grpc_interop_go:45617187-1a75-4f2f-b7af-c602d882bbc0}" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=large_unary --use_tls=true" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --use_tls=true" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --use_tls=true" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --use_tls=true" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --use_tls=true" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --use_tls=true" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --use_tls=true" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --use_tls=true" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --use_tls=true" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=large_unary --use_tls=true" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --use_tls=true" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --use_tls=true" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --use_tls=true" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --use_tls=true" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --use_tls=true" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --use_tls=true" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --use_tls=true" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --use_tls=true" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=compute_engine_channel_creds" diff --git a/tools/interop_matrix/testcases/java__master b/tools/interop_matrix/testcases/java__master index ac6b9aed5e6..4f576db754f 100755 --- a/tools/interop_matrix/testcases/java__master +++ b/tools/interop_matrix/testcases/java__master @@ -1,58 +1,22 @@ #!/bin/bash # DO NOT MODIFY # This file is generated by run_interop_tests.py/create_testcases.sh -echo "Testing ${docker_image:=grpc_interop_java:45b54245-f0e4-4e80-ad47-03826412871f}" +echo "Testing ${docker_image:=grpc_interop_java:564ef0d0-f4d8-4611-88a9-bb6a99bf68a8}" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=large_unary --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=large_unary --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=large_unary --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_unary --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=ping_pong --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=empty_stream --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=client_streaming --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=server_streaming --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_begin --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=cancel_after_first_response --custom_credentials_type=compute_engine_channel_creds" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --use_tls=true" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=google_default_credentials" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_port=443 --test_case=timeout_on_sleeping_server --custom_credentials_type=compute_engine_channel_creds" From e8bece9c71f93828fc65dc856ec5401fc45e3fe9 Mon Sep 17 00:00:00 2001 From: yuangongji <82787816@qq.com> Date: Wed, 5 Jun 2019 09:33:38 +0800 Subject: [PATCH 0421/1555] some typo errors too. --- include/grpc/grpc_security.h | 2 +- src/csharp/Grpc.Core/ServerCredentials.cs | 2 +- test/cpp/qps/client_async.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h index ebdf86b7d50..909cd2e51ca 100644 --- a/include/grpc/grpc_security.h +++ b/include/grpc/grpc_security.h @@ -435,7 +435,7 @@ GRPCAPI grpc_server_credentials* grpc_ssl_server_credentials_create( /** Deprecated in favor of grpc_ssl_server_credentials_create_with_options. Same as grpc_ssl_server_credentials_create method except uses grpc_ssl_client_certificate_request_type enum to support more ways to - authenticate client cerificates.*/ + authenticate client certificates.*/ GRPCAPI grpc_server_credentials* grpc_ssl_server_credentials_create_ex( const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, size_t num_key_cert_pairs, diff --git a/src/csharp/Grpc.Core/ServerCredentials.cs b/src/csharp/Grpc.Core/ServerCredentials.cs index 8e4e44ba504..d0fc600f85a 100644 --- a/src/csharp/Grpc.Core/ServerCredentials.cs +++ b/src/csharp/Grpc.Core/ServerCredentials.cs @@ -103,7 +103,7 @@ namespace Grpc.Core /// /// Server requests client certificate and enforces that the client presents a /// certificate. - /// The cerificate presented by the client is verified by the gRPC framework. + /// The certificate presented by the client is verified by the gRPC framework. /// (For a successful connection the client needs to present a certificate that /// can be verified against the root certificate configured by the server) /// The client's key certificate pair must be valid for the SSL connection to diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index bad24cf04a2..059dc4f9002 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -479,7 +479,7 @@ class ClientRpcContextStreamingPingPongImpl : public ClientRpcContext { next_state_ = State::STREAM_IDLE; stream_->StartCall(ClientRpcContext::tag(this)); if (coalesce_) { - // When the intial metadata is corked, the tag will not come back and we + // When the initial metadata is corked, the tag will not come back and we // need to manually drive the state machine. RunNextState(true, nullptr); } From 206ca33dd5d320c5cc879b4152641a6128cd4022 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 5 Jun 2019 15:19:55 +1200 Subject: [PATCH 0422/1555] Enable duplex streaming and special status message interop tests --- tools/run_tests/run_interop_tests.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py index cc6901bdebe..ab724e5badc 100755 --- a/tools/run_tests/run_interop_tests.py +++ b/tools/run_tests/run_interop_tests.py @@ -210,12 +210,10 @@ class AspNetCoreLanguage: def unimplemented_test_cases(self): return _SKIP_COMPRESSION + \ - _SKIP_SPECIAL_STATUS_MESSAGE + \ - _AUTH_TEST_CASES + \ - ['cancel_after_first_response', 'ping_pong'] + _AUTH_TEST_CASES def unimplemented_test_cases_server(self): - return _SKIP_COMPRESSION + _SKIP_SPECIAL_STATUS_MESSAGE + return _SKIP_COMPRESSION def __str__(self): return 'aspnetcore' From de0e9d10269752fa38032f02e1a2e0bb73f271bf Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 20 Mar 2019 07:08:05 -0700 Subject: [PATCH 0423/1555] enable special_status_message interop for C# --- tools/run_tests/run_interop_tests.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py index 0845647ecd6..f26111fbf2b 100755 --- a/tools/run_tests/run_interop_tests.py +++ b/tools/run_tests/run_interop_tests.py @@ -145,7 +145,6 @@ class CSharpLanguage: def unimplemented_test_cases(self): return _SKIP_SERVER_COMPRESSION + \ _SKIP_DATA_FRAME_PADDING + \ - _SKIP_SPECIAL_STATUS_MESSAGE + \ _SKIP_GOOGLE_DEFAULT_CREDS + \ _SKIP_COMPUTE_ENGINE_CHANNEL_CREDS @@ -178,7 +177,6 @@ class CSharpCoreCLRLanguage: def unimplemented_test_cases(self): return _SKIP_SERVER_COMPRESSION + \ _SKIP_DATA_FRAME_PADDING + \ - _SKIP_SPECIAL_STATUS_MESSAGE + \ _SKIP_GOOGLE_DEFAULT_CREDS + \ _SKIP_COMPUTE_ENGINE_CHANNEL_CREDS From 4686f6d5183100d8507ca3b6abab95b911c45c40 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 20 Mar 2019 07:08:46 -0700 Subject: [PATCH 0424/1555] enable special_status_message interop for grpc-dotnet server --- tools/run_tests/run_interop_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py index f26111fbf2b..e69e501af5f 100755 --- a/tools/run_tests/run_interop_tests.py +++ b/tools/run_tests/run_interop_tests.py @@ -213,7 +213,7 @@ class AspNetCoreLanguage: ['cancel_after_first_response', 'ping_pong'] def unimplemented_test_cases_server(self): - return _SKIP_COMPRESSION + _SKIP_SPECIAL_STATUS_MESSAGE + return _SKIP_COMPRESSION def __str__(self): return 'aspnetcore' From 877f426d352de8e1f062aa28c2ea4d2039ef96bf Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 5 Jun 2019 10:52:53 -0400 Subject: [PATCH 0425/1555] add special_status_message testcase to C# interop client --- .../Grpc.IntegrationTesting/InteropClient.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/csharp/Grpc.IntegrationTesting/InteropClient.cs b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs index 47503530820..83b0095f7f0 100644 --- a/src/csharp/Grpc.IntegrationTesting/InteropClient.cs +++ b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs @@ -185,6 +185,9 @@ namespace Grpc.IntegrationTesting case "unimplemented_service": RunUnimplementedService(new UnimplementedService.UnimplementedServiceClient(channel)); break; + case "special_status_message": + await RunSpecialStatusMessageAsync(client); + break; case "unimplemented_method": RunUnimplementedMethod(client); break; @@ -567,6 +570,33 @@ namespace Grpc.IntegrationTesting Console.WriteLine("Passed!"); } + private static async Task RunSpecialStatusMessageAsync(TestService.TestServiceClient client) + { + Console.WriteLine("running special_status_message"); + + var echoStatus = new EchoStatus + { + Code = 2, + Message = "\t\ntest with whitespace\r\nand Unicode BMP ☺ and non-BMP 😈\t\n" + }; + + try + { + await client.UnaryCallAsync(new SimpleRequest + { + ResponseStatus = echoStatus + }); + Assert.Fail(); + } + catch (RpcException e) + { + Assert.AreEqual(StatusCode.Unknown, e.Status.StatusCode); + Assert.AreEqual(echoStatus.Message, e.Status.Detail); + } + + Console.WriteLine("Passed!"); + } + public static void RunUnimplementedService(UnimplementedService.UnimplementedServiceClient client) { Console.WriteLine("running unimplemented_service"); From a7e3e76aed60244db57975ef2ee1e2209f47e8b3 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 16 Apr 2019 09:04:07 -0400 Subject: [PATCH 0426/1555] use different service_account_key for interop tests --- .../helper_scripts/prepare_build_interop_rc | 5 ++--- tools/internal_ci/linux/grpc_interop_toprod.cfg | 9 +++++++++ .../linux/pull_request/grpc_interop_toprod.cfg | 9 +++++++++ tools/internal_ci/macos/grpc_interop_toprod.cfg | 10 +++++++++- tools/internal_ci/macos/grpc_interop_toprod.sh | 2 +- tools/run_tests/run_interop_tests.py | 3 ++- 6 files changed, 32 insertions(+), 6 deletions(-) diff --git a/tools/internal_ci/helper_scripts/prepare_build_interop_rc b/tools/internal_ci/helper_scripts/prepare_build_interop_rc index e462a83e522..03105d9a689 100644 --- a/tools/internal_ci/helper_scripts/prepare_build_interop_rc +++ b/tools/internal_ci/helper_scripts/prepare_build_interop_rc @@ -30,7 +30,6 @@ git clone --recursive https://github.com/grpc/grpc-node ./../grpc-node git clone --recursive https://github.com/grpc/grpc-dart ./../grpc-dart git clone --recursive https://github.com/grpc/grpc-dotnet ./../grpc-dotnet -# Download json file. +# Grab the service account key to run interop tests against prod backends. mkdir ~/service_account -gsutil cp gs://grpc-testing-secrets/interop/service_account/GrpcTesting-726eb1347f15.json ~/service_account -export GOOGLE_APPLICATION_CREDENTIALS=~/service_account/GrpcTesting-726eb1347f15.json +cp "${KOKORO_KEYSTORE_DIR}/73836_interop_to_prod_tests_service_account_key" ~/service_account/grpc-testing-ebe7c1ac7381.json || true diff --git a/tools/internal_ci/linux/grpc_interop_toprod.cfg b/tools/internal_ci/linux/grpc_interop_toprod.cfg index de4db81e6ba..377dff771fe 100644 --- a/tools/internal_ci/linux/grpc_interop_toprod.cfg +++ b/tools/internal_ci/linux/grpc_interop_toprod.cfg @@ -28,3 +28,12 @@ env_vars { key: "RUN_TESTS_FLAGS" value: "-l all --cloud_to_prod --cloud_to_prod_auth --prod_servers default gateway_v4 --use_docker --internal_ci -t -j 8 --bq_result_table interop_results" } + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73836 + keyname: "interop_to_prod_tests_service_account_key" + } + } +} diff --git a/tools/internal_ci/linux/pull_request/grpc_interop_toprod.cfg b/tools/internal_ci/linux/pull_request/grpc_interop_toprod.cfg index 7321effc123..636f979473b 100644 --- a/tools/internal_ci/linux/pull_request/grpc_interop_toprod.cfg +++ b/tools/internal_ci/linux/pull_request/grpc_interop_toprod.cfg @@ -28,3 +28,12 @@ env_vars { key: "RUN_TESTS_FLAGS" value: "-l all --cloud_to_prod --cloud_to_prod_auth --prod_servers default gateway_v4 --use_docker --internal_ci -t -j 12" } + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73836 + keyname: "interop_to_prod_tests_service_account_key" + } + } +} diff --git a/tools/internal_ci/macos/grpc_interop_toprod.cfg b/tools/internal_ci/macos/grpc_interop_toprod.cfg index 2cfc8a2d6de..3c11c749e2f 100644 --- a/tools/internal_ci/macos/grpc_interop_toprod.cfg +++ b/tools/internal_ci/macos/grpc_interop_toprod.cfg @@ -17,7 +17,6 @@ # Location of the continuous shell script in repository. build_file: "grpc/tools/internal_ci/macos/grpc_interop_toprod.sh" gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" -gfile_resources: "/bigstore/grpc-testing-secrets/interop/service_account/GrpcTesting-726eb1347f15.json" timeout_mins: 240 action { define_artifacts { @@ -25,3 +24,12 @@ action { regex: "github/grpc/reports/**" } } + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73836 + keyname: "interop_to_prod_tests_service_account_key" + } + } +} diff --git a/tools/internal_ci/macos/grpc_interop_toprod.sh b/tools/internal_ci/macos/grpc_interop_toprod.sh index 654da373a26..36e5a2103d9 100755 --- a/tools/internal_ci/macos/grpc_interop_toprod.sh +++ b/tools/internal_ci/macos/grpc_interop_toprod.sh @@ -33,7 +33,7 @@ tools/run_tests/run_interop_tests.py -l c++ \ --cloud_to_prod --cloud_to_prod_auth \ --google_default_creds_use_key_file \ --prod_servers default gateway_v4 \ - --service_account_key_file="${KOKORO_GFILE_DIR}/GrpcTesting-726eb1347f15.json" \ + --service_account_key_file="${KOKORO_KEYSTORE_DIR}/73836_interop_to_prod_tests_service_account_key" \ --skip_compute_engine_creds --internal_ci -t -j 4 || FAILED="true" tools/internal_ci/helper_scripts/delete_nonartifacts.sh || true diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py index 0845647ecd6..c0f153f0106 100755 --- a/tools/run_tests/run_interop_tests.py +++ b/tools/run_tests/run_interop_tests.py @@ -823,9 +823,10 @@ def auth_options(language, if not service_account_key_file: # this file path only works inside docker - service_account_key_file = '/root/service_account/GrpcTesting-726eb1347f15.json' + service_account_key_file = '/root/service_account/grpc-testing-ebe7c1ac7381.json' oauth_scope_arg = '--oauth_scope=https://www.googleapis.com/auth/xapi.zoo' key_file_arg = '--service_account_key_file=%s' % service_account_key_file + # default compute engine credentials associated with the testing VMs in "grpc-testing" cloud project default_account_arg = '--default_service_account=830293263384-compute@developer.gserviceaccount.com' if test_case in ['jwt_token_creds', 'per_rpc_creds', 'oauth2_auth_token']: From 2699ee6243a31cea7cb1884e1e9bf31b7b7f74eb Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 5 Jun 2019 18:34:10 +0200 Subject: [PATCH 0427/1555] improve C# readme.md --- src/csharp/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/csharp/README.md b/src/csharp/README.md index c01cae0422d..13c8502af61 100644 --- a/src/csharp/README.md +++ b/src/csharp/README.md @@ -17,20 +17,20 @@ PREREQUISITES When using gRPC C# under .NET Core you only need to [install .NET Core](https://www.microsoft.com/net/core). In addition to that, you can also use gRPC C# with these runtimes / IDEs -- Windows: .NET Framework 4.5+, Visual Studio 2013, 2015, 2017, Visual Studio Code -- Linux: Mono 4+, Visual Studio Code, MonoDevelop 5.9+ -- Mac OS X: Mono 4+, Visual Studio Code, Xamarin Studio 5.9+ +- Windows: .NET Framework 4.5+, Visual Studio 2013 or newer, Visual Studio Code +- Linux: Mono 4+, Visual Studio Code +- Mac OS X: Mono 4+, Visual Studio Code, Visual Studio for Mac HOW TO USE -------------- **Windows, Linux, Mac OS X** -- Open Visual Studio / MonoDevelop / Xamarin Studio and start a new project/solution (alternatively, you can create a new project from command line with `dotnet` SDK) +- Open Visual Studio and start a new project/solution (alternatively, you can create a new project from command line with `dotnet` SDK) - Add the [Grpc](https://www.nuget.org/packages/Grpc/) NuGet package as a dependency (Project options -> Manage NuGet Packages). -- To be able to generate code from Protocol Buffer (`.proto`) file definitions, add the [Grpc.Tools](https://www.nuget.org/packages/Grpc.Tools/) NuGet package that contains Protocol Buffers compiler (_protoc_) and the gRPC _protoc_ plugin. +- To be able to generate code from Protocol Buffer (`.proto`) file definitions, add the [Grpc.Tools](https://www.nuget.org/packages/Grpc.Tools/) NuGet package which provides [code generation integrated into your build](BUILD-INTEGRATION.md). **Xamarin.Android and Xamarin.iOS (Experimental only)** From f32a49d05f966329b3e97d05082d44329229abfa Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 5 Jun 2019 18:34:48 +0200 Subject: [PATCH 0428/1555] document grpc_csharp_plugin options --- src/csharp/BUILD-INTEGRATION.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/csharp/BUILD-INTEGRATION.md b/src/csharp/BUILD-INTEGRATION.md index 3addc2403c5..400365ab24a 100644 --- a/src/csharp/BUILD-INTEGRATION.md +++ b/src/csharp/BUILD-INTEGRATION.md @@ -355,3 +355,24 @@ Unless explicitly set, will follow `OutputDir` for any given file. * __Access__ Sets generated class access on _both_ generated message and gRPC stub classes. + +`grpc_csharp_plugin` command line options +--------- + +Under the hood, the `Grpc.Tools` build integration invokes the `protoc` and `grpc_csharp_plugin` binaries +to perform code generation. Here is an overview of the available `grpc_csharp_plugin` options: + +| Name | Default | Synopsis | +|---------------- |-----------|----------------------------------------------------------| +| no_client | off | Don't generate the client stub | +| no_server | off | Don't generate the server-side stub | +| internal_access | off | Generate classes with "internal" visibility | +| lite_client | off | Generate client stubs that inherit from "LiteClientBase" | + +Note that the protocol buffer compiler has a special commandline syntax for plugin options. +Example: +``` +protoc --plugin=protoc-gen-grpc=grpc_csharp_plugin --csharp_out=OUT_DIR \ + --grpc_out=OUT_DIR --grpc_opt=lite_client,no_server \ + -I INCLUDE_DIR foo.proto +``` \ No newline at end of file From e466546743b485e1d7c9060f7bffc1ee3f3de8fd Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 5 Jun 2019 18:56:24 +0200 Subject: [PATCH 0429/1555] make reference docs tooling to docfx directory to avoid collision --- src/csharp/{doc => docfx}/.gitignore | 0 src/csharp/{doc => docfx}/README.md | 0 src/csharp/{doc => docfx}/docfx.json | 0 src/csharp/{doc => docfx}/generate_reference_docs.sh | 4 ++-- src/csharp/{doc => docfx}/toc.yml | 0 5 files changed, 2 insertions(+), 2 deletions(-) rename src/csharp/{doc => docfx}/.gitignore (100%) rename src/csharp/{doc => docfx}/README.md (100%) rename src/csharp/{doc => docfx}/docfx.json (100%) rename src/csharp/{doc => docfx}/generate_reference_docs.sh (90%) rename src/csharp/{doc => docfx}/toc.yml (100%) diff --git a/src/csharp/doc/.gitignore b/src/csharp/docfx/.gitignore similarity index 100% rename from src/csharp/doc/.gitignore rename to src/csharp/docfx/.gitignore diff --git a/src/csharp/doc/README.md b/src/csharp/docfx/README.md similarity index 100% rename from src/csharp/doc/README.md rename to src/csharp/docfx/README.md diff --git a/src/csharp/doc/docfx.json b/src/csharp/docfx/docfx.json similarity index 100% rename from src/csharp/doc/docfx.json rename to src/csharp/docfx/docfx.json diff --git a/src/csharp/doc/generate_reference_docs.sh b/src/csharp/docfx/generate_reference_docs.sh similarity index 90% rename from src/csharp/doc/generate_reference_docs.sh rename to src/csharp/docfx/generate_reference_docs.sh index c20d6c30bd3..dbed2bad27f 100755 --- a/src/csharp/doc/generate_reference_docs.sh +++ b/src/csharp/docfx/generate_reference_docs.sh @@ -23,7 +23,7 @@ rm -rf html obj grpc-gh-pages # generate into src/csharp/doc/html directory cd .. docker run --rm -v "$(pwd)":/work -w /work/doc --user "$(id -u):$(id -g)" -it tsgkadot/docker-docfx:latest docfx -cd doc +cd docfx # prepare a clone of "gh-pages" branch where the generated docs are stored GITHUB_USER="${USER}" @@ -35,4 +35,4 @@ git remote add origin "git@github.com:${GITHUB_USER}/grpc.git" rm -r csharp cp -r ../html csharp -echo "Done. Go to src/csharp/doc/grpc-gh-pages git repository and create a pull request to update the generated docs." +echo "Done. Go to src/csharp/docfx/grpc-gh-pages git repository and create a pull request to update the generated docs." diff --git a/src/csharp/doc/toc.yml b/src/csharp/docfx/toc.yml similarity index 100% rename from src/csharp/doc/toc.yml rename to src/csharp/docfx/toc.yml From 76508bd450b13eab03b222e270cd9ad22b573edb Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 5 Jun 2019 08:34:30 -0700 Subject: [PATCH 0430/1555] Change ChannelzRegistry::Get() to return a RefCountedPtr<>. --- src/core/lib/channel/channelz_registry.cc | 118 ++++++++++++-------- src/core/lib/channel/channelz_registry.h | 6 +- src/core/lib/gprpp/ref_counted.h | 5 + test/core/channel/channelz_registry_test.cc | 76 +++++++------ 4 files changed, 120 insertions(+), 85 deletions(-) diff --git a/src/core/lib/channel/channelz_registry.cc b/src/core/lib/channel/channelz_registry.cc index b6a660b18fd..0c033a14c60 100644 --- a/src/core/lib/channel/channelz_registry.cc +++ b/src/core/lib/channel/channelz_registry.cc @@ -117,36 +117,46 @@ void ChannelzRegistry::InternalUnregister(intptr_t uuid) { MaybePerformCompactionLocked(); } -BaseNode* ChannelzRegistry::InternalGet(intptr_t uuid) { +RefCountedPtr ChannelzRegistry::InternalGet(intptr_t uuid) { MutexLock lock(&mu_); if (uuid < 1 || uuid > uuid_generator_) { return nullptr; } int idx = FindByUuidLocked(uuid, true); - return idx < 0 ? nullptr : entities_[idx]; + if (idx < 0 || entities_[idx] == nullptr) return nullptr; + // Found node. Return only if its refcount is not zero (i.e., when we + // know that there is no other thread about to destroy it). + if (!entities_[idx]->RefIfNonZero()) return nullptr; + return RefCountedPtr(entities_[idx]); } char* ChannelzRegistry::InternalGetTopChannels(intptr_t start_channel_id) { - MutexLock lock(&mu_); grpc_json* top_level_json = grpc_json_create(GRPC_JSON_OBJECT); grpc_json* json = top_level_json; grpc_json* json_iterator = nullptr; - InlinedVector top_level_channels; - bool reached_pagination_limit = false; - int start_idx = GPR_MAX(FindByUuidLocked(start_channel_id, false), 0); - for (size_t i = start_idx; i < entities_.size(); ++i) { - if (entities_[i] != nullptr && - entities_[i]->type() == - grpc_core::channelz::BaseNode::EntityType::kTopLevelChannel && - entities_[i]->uuid() >= start_channel_id) { - // check if we are over pagination limit to determine if we need to set - // the "end" element. If we don't go through this block, we know that - // when the loop terminates, we have <= to kPaginationLimit. - if (top_level_channels.size() == kPaginationLimit) { - reached_pagination_limit = true; - break; + InlinedVector, 10> top_level_channels; + RefCountedPtr node_after_pagination_limit; + { + MutexLock lock(&mu_); + const int start_idx = GPR_MAX(FindByUuidLocked(start_channel_id, false), 0); + for (size_t i = start_idx; i < entities_.size(); ++i) { + if (entities_[i] != nullptr && + entities_[i]->type() == + grpc_core::channelz::BaseNode::EntityType::kTopLevelChannel && + entities_[i]->uuid() >= start_channel_id && + entities_[i]->RefIfNonZero()) { + // Check if we are over pagination limit to determine if we need to set + // the "end" element. If we don't go through this block, we know that + // when the loop terminates, we have <= to kPaginationLimit. + // Note that because we have already increased this node's + // refcount, we need to decrease it, but we can't unref while + // holding the lock, because this may lead to a deadlock. + if (top_level_channels.size() == kPaginationLimit) { + node_after_pagination_limit.reset(entities_[i]); + break; + } + top_level_channels.emplace_back(entities_[i]); } - top_level_channels.push_back(entities_[i]); } } if (!top_level_channels.empty()) { @@ -159,7 +169,7 @@ char* ChannelzRegistry::InternalGetTopChannels(intptr_t start_channel_id) { grpc_json_link_child(array_parent, channel_json, json_iterator); } } - if (!reached_pagination_limit) { + if (node_after_pagination_limit == nullptr) { grpc_json_create_child(nullptr, json, "end", nullptr, GRPC_JSON_TRUE, false); } @@ -169,26 +179,32 @@ char* ChannelzRegistry::InternalGetTopChannels(intptr_t start_channel_id) { } char* ChannelzRegistry::InternalGetServers(intptr_t start_server_id) { - MutexLock lock(&mu_); grpc_json* top_level_json = grpc_json_create(GRPC_JSON_OBJECT); grpc_json* json = top_level_json; grpc_json* json_iterator = nullptr; - InlinedVector servers; - bool reached_pagination_limit = false; - int start_idx = GPR_MAX(FindByUuidLocked(start_server_id, false), 0); - for (size_t i = start_idx; i < entities_.size(); ++i) { - if (entities_[i] != nullptr && - entities_[i]->type() == - grpc_core::channelz::BaseNode::EntityType::kServer && - entities_[i]->uuid() >= start_server_id) { - // check if we are over pagination limit to determine if we need to set - // the "end" element. If we don't go through this block, we know that - // when the loop terminates, we have <= to kPaginationLimit. - if (servers.size() == kPaginationLimit) { - reached_pagination_limit = true; - break; + InlinedVector, 10> servers; + RefCountedPtr node_after_pagination_limit; + { + MutexLock lock(&mu_); + const int start_idx = GPR_MAX(FindByUuidLocked(start_server_id, false), 0); + for (size_t i = start_idx; i < entities_.size(); ++i) { + if (entities_[i] != nullptr && + entities_[i]->type() == + grpc_core::channelz::BaseNode::EntityType::kServer && + entities_[i]->uuid() >= start_server_id && + entities_[i]->RefIfNonZero()) { + // Check if we are over pagination limit to determine if we need to set + // the "end" element. If we don't go through this block, we know that + // when the loop terminates, we have <= to kPaginationLimit. + // Note that because we have already increased this node's + // refcount, we need to decrease it, but we can't unref while + // holding the lock, because this may lead to a deadlock. + if (servers.size() == kPaginationLimit) { + node_after_pagination_limit.reset(entities_[i]); + break; + } + servers.emplace_back(entities_[i]); } - servers.push_back(entities_[i]); } } if (!servers.empty()) { @@ -201,7 +217,7 @@ char* ChannelzRegistry::InternalGetServers(intptr_t start_server_id) { grpc_json_link_child(array_parent, server_json, json_iterator); } } - if (!reached_pagination_limit) { + if (node_after_pagination_limit == nullptr) { grpc_json_create_child(nullptr, json, "end", nullptr, GRPC_JSON_TRUE, false); } @@ -211,14 +227,20 @@ char* ChannelzRegistry::InternalGetServers(intptr_t start_server_id) { } void ChannelzRegistry::InternalLogAllEntities() { - MutexLock lock(&mu_); - for (size_t i = 0; i < entities_.size(); ++i) { - if (entities_[i] != nullptr) { - char* json = entities_[i]->RenderJsonString(); - gpr_log(GPR_INFO, "%s", json); - gpr_free(json); + InlinedVector, 10> nodes; + { + MutexLock lock(&mu_); + for (size_t i = 0; i < entities_.size(); ++i) { + if (entities_[i] != nullptr && entities_[i]->RefIfNonZero()) { + nodes.emplace_back(entities_[i]); + } } } + for (size_t i = 0; i < nodes.size(); ++i) { + char* json = nodes[i]->RenderJsonString(); + gpr_log(GPR_INFO, "%s", json); + gpr_free(json); + } } } // namespace channelz @@ -234,7 +256,7 @@ char* grpc_channelz_get_servers(intptr_t start_server_id) { } char* grpc_channelz_get_server(intptr_t server_id) { - grpc_core::channelz::BaseNode* server_node = + grpc_core::RefCountedPtr server_node = grpc_core::channelz::ChannelzRegistry::Get(server_id); if (server_node == nullptr || server_node->type() != @@ -254,7 +276,7 @@ char* grpc_channelz_get_server(intptr_t server_id) { char* grpc_channelz_get_server_sockets(intptr_t server_id, intptr_t start_socket_id, intptr_t max_results) { - grpc_core::channelz::BaseNode* base_node = + grpc_core::RefCountedPtr base_node = grpc_core::channelz::ChannelzRegistry::Get(server_id); if (base_node == nullptr || base_node->type() != grpc_core::channelz::BaseNode::EntityType::kServer) { @@ -263,12 +285,12 @@ char* grpc_channelz_get_server_sockets(intptr_t server_id, // This cast is ok since we have just checked to make sure base_node is // actually a server node grpc_core::channelz::ServerNode* server_node = - static_cast(base_node); + static_cast(base_node.get()); return server_node->RenderServerSockets(start_socket_id, max_results); } char* grpc_channelz_get_channel(intptr_t channel_id) { - grpc_core::channelz::BaseNode* channel_node = + grpc_core::RefCountedPtr channel_node = grpc_core::channelz::ChannelzRegistry::Get(channel_id); if (channel_node == nullptr || (channel_node->type() != @@ -288,7 +310,7 @@ char* grpc_channelz_get_channel(intptr_t channel_id) { } char* grpc_channelz_get_subchannel(intptr_t subchannel_id) { - grpc_core::channelz::BaseNode* subchannel_node = + grpc_core::RefCountedPtr subchannel_node = grpc_core::channelz::ChannelzRegistry::Get(subchannel_id); if (subchannel_node == nullptr || subchannel_node->type() != @@ -306,7 +328,7 @@ char* grpc_channelz_get_subchannel(intptr_t subchannel_id) { } char* grpc_channelz_get_socket(intptr_t socket_id) { - grpc_core::channelz::BaseNode* socket_node = + grpc_core::RefCountedPtr socket_node = grpc_core::channelz::ChannelzRegistry::Get(socket_id); if (socket_node == nullptr || socket_node->type() != diff --git a/src/core/lib/channel/channelz_registry.h b/src/core/lib/channel/channelz_registry.h index 73b330785d2..aa87b64e5b2 100644 --- a/src/core/lib/channel/channelz_registry.h +++ b/src/core/lib/channel/channelz_registry.h @@ -48,7 +48,9 @@ class ChannelzRegistry { return Default()->InternalRegister(node); } static void Unregister(intptr_t uuid) { Default()->InternalUnregister(uuid); } - static BaseNode* Get(intptr_t uuid) { return Default()->InternalGet(uuid); } + static RefCountedPtr Get(intptr_t uuid) { + return Default()->InternalGet(uuid); + } // Returns the allocated JSON string that represents the proto // GetTopChannelsResponse as per channelz.proto. @@ -86,7 +88,7 @@ class ChannelzRegistry { // if object with uuid has previously been registered as the correct type, // returns the void* associated with that uuid. Else returns nullptr. - BaseNode* InternalGet(intptr_t uuid); + RefCountedPtr InternalGet(intptr_t uuid); char* InternalGetTopChannels(intptr_t start_channel_id); char* InternalGetServers(intptr_t start_server_id); diff --git a/src/core/lib/gprpp/ref_counted.h b/src/core/lib/gprpp/ref_counted.h index 4de50985dcf..392c12a3bd1 100644 --- a/src/core/lib/gprpp/ref_counted.h +++ b/src/core/lib/gprpp/ref_counted.h @@ -221,6 +221,11 @@ class RefCounted : public Impl { } } + bool RefIfNonZero() { return refs_.RefIfNonZero(); } + bool RefIfNonZero(const DebugLocation& location, const char* reason) { + return refs_.RefIfNonZero(location, reason); + } + // Not copyable nor movable. RefCounted(const RefCounted&) = delete; RefCounted& operator=(const RefCounted&) = delete; diff --git a/test/core/channel/channelz_registry_test.cc b/test/core/channel/channelz_registry_test.cc index 31841f9f967..030d52fd548 100644 --- a/test/core/channel/channelz_registry_test.cc +++ b/test/core/channel/channelz_registry_test.cc @@ -62,8 +62,8 @@ class ChannelzRegistryTest : public ::testing::Test { }; TEST_F(ChannelzRegistryTest, UuidStartsAboveZeroTest) { - UniquePtr channelz_channel = - MakeUnique(BaseNode::EntityType::kTopLevelChannel); + RefCountedPtr channelz_channel = + MakeRefCounted(BaseNode::EntityType::kTopLevelChannel); intptr_t uuid = channelz_channel->uuid(); EXPECT_GT(uuid, 0) << "First uuid chose must be greater than zero. Zero if " "reserved according to " @@ -72,11 +72,11 @@ TEST_F(ChannelzRegistryTest, UuidStartsAboveZeroTest) { } TEST_F(ChannelzRegistryTest, UuidsAreIncreasing) { - std::vector> channelz_channels; + std::vector> channelz_channels; channelz_channels.reserve(10); for (int i = 0; i < 10; ++i) { channelz_channels.push_back( - MakeUnique(BaseNode::EntityType::kTopLevelChannel)); + MakeRefCounted(BaseNode::EntityType::kTopLevelChannel)); } for (size_t i = 1; i < channelz_channels.size(); ++i) { EXPECT_LT(channelz_channels[i - 1]->uuid(), channelz_channels[i]->uuid()) @@ -85,46 +85,50 @@ TEST_F(ChannelzRegistryTest, UuidsAreIncreasing) { } TEST_F(ChannelzRegistryTest, RegisterGetTest) { - UniquePtr channelz_channel = - MakeUnique(BaseNode::EntityType::kTopLevelChannel); - BaseNode* retrieved = ChannelzRegistry::Get(channelz_channel->uuid()); - EXPECT_EQ(channelz_channel.get(), retrieved); + RefCountedPtr channelz_channel = + MakeRefCounted(BaseNode::EntityType::kTopLevelChannel); + RefCountedPtr retrieved = + ChannelzRegistry::Get(channelz_channel->uuid()); + EXPECT_EQ(channelz_channel, retrieved); } TEST_F(ChannelzRegistryTest, RegisterManyItems) { - std::vector> channelz_channels; + std::vector> channelz_channels; for (int i = 0; i < 100; i++) { channelz_channels.push_back( - MakeUnique(BaseNode::EntityType::kTopLevelChannel)); - BaseNode* retrieved = ChannelzRegistry::Get(channelz_channels[i]->uuid()); - EXPECT_EQ(channelz_channels[i].get(), retrieved); + MakeRefCounted(BaseNode::EntityType::kTopLevelChannel)); + RefCountedPtr retrieved = + ChannelzRegistry::Get(channelz_channels[i]->uuid()); + EXPECT_EQ(channelz_channels[i], retrieved); } } TEST_F(ChannelzRegistryTest, NullIfNotPresentTest) { - UniquePtr channelz_channel = - MakeUnique(BaseNode::EntityType::kTopLevelChannel); + RefCountedPtr channelz_channel = + MakeRefCounted(BaseNode::EntityType::kTopLevelChannel); // try to pull out a uuid that does not exist. - BaseNode* nonexistant = ChannelzRegistry::Get(channelz_channel->uuid() + 1); + RefCountedPtr nonexistant = + ChannelzRegistry::Get(channelz_channel->uuid() + 1); EXPECT_EQ(nonexistant, nullptr); - BaseNode* retrieved = ChannelzRegistry::Get(channelz_channel->uuid()); - EXPECT_EQ(channelz_channel.get(), retrieved); + RefCountedPtr retrieved = + ChannelzRegistry::Get(channelz_channel->uuid()); + EXPECT_EQ(channelz_channel, retrieved); } TEST_F(ChannelzRegistryTest, TestCompaction) { const int kLoopIterations = 300; // These channels that will stay in the registry for the duration of the test. - std::vector> even_channels; + std::vector> even_channels; even_channels.reserve(kLoopIterations); { // The channels will unregister themselves at the end of the for block. - std::vector> odd_channels; + std::vector> odd_channels; odd_channels.reserve(kLoopIterations); for (int i = 0; i < kLoopIterations; i++) { even_channels.push_back( - MakeUnique(BaseNode::EntityType::kTopLevelChannel)); + MakeRefCounted(BaseNode::EntityType::kTopLevelChannel)); odd_channels.push_back( - MakeUnique(BaseNode::EntityType::kTopLevelChannel)); + MakeRefCounted(BaseNode::EntityType::kTopLevelChannel)); } } // without compaction, there would be exactly kLoopIterations empty slots at @@ -137,25 +141,26 @@ TEST_F(ChannelzRegistryTest, TestCompaction) { TEST_F(ChannelzRegistryTest, TestGetAfterCompaction) { const int kLoopIterations = 100; // These channels that will stay in the registry for the duration of the test. - std::vector> even_channels; + std::vector> even_channels; even_channels.reserve(kLoopIterations); std::vector odd_uuids; odd_uuids.reserve(kLoopIterations); { // The channels will unregister themselves at the end of the for block. - std::vector> odd_channels; + std::vector> odd_channels; odd_channels.reserve(kLoopIterations); for (int i = 0; i < kLoopIterations; i++) { even_channels.push_back( - MakeUnique(BaseNode::EntityType::kTopLevelChannel)); + MakeRefCounted(BaseNode::EntityType::kTopLevelChannel)); odd_channels.push_back( - MakeUnique(BaseNode::EntityType::kTopLevelChannel)); + MakeRefCounted(BaseNode::EntityType::kTopLevelChannel)); odd_uuids.push_back(odd_channels[i]->uuid()); } } for (int i = 0; i < kLoopIterations; i++) { - BaseNode* retrieved = ChannelzRegistry::Get(even_channels[i]->uuid()); - EXPECT_EQ(even_channels[i].get(), retrieved); + RefCountedPtr retrieved = + ChannelzRegistry::Get(even_channels[i]->uuid()); + EXPECT_EQ(even_channels[i], retrieved); retrieved = ChannelzRegistry::Get(odd_uuids[i]); EXPECT_EQ(retrieved, nullptr); } @@ -164,29 +169,30 @@ TEST_F(ChannelzRegistryTest, TestGetAfterCompaction) { TEST_F(ChannelzRegistryTest, TestAddAfterCompaction) { const int kLoopIterations = 100; // These channels that will stay in the registry for the duration of the test. - std::vector> even_channels; + std::vector> even_channels; even_channels.reserve(kLoopIterations); std::vector odd_uuids; odd_uuids.reserve(kLoopIterations); { // The channels will unregister themselves at the end of the for block. - std::vector> odd_channels; + std::vector> odd_channels; odd_channels.reserve(kLoopIterations); for (int i = 0; i < kLoopIterations; i++) { even_channels.push_back( - MakeUnique(BaseNode::EntityType::kTopLevelChannel)); + MakeRefCounted(BaseNode::EntityType::kTopLevelChannel)); odd_channels.push_back( - MakeUnique(BaseNode::EntityType::kTopLevelChannel)); + MakeRefCounted(BaseNode::EntityType::kTopLevelChannel)); odd_uuids.push_back(odd_channels[i]->uuid()); } } - std::vector> more_channels; + std::vector> more_channels; more_channels.reserve(kLoopIterations); for (int i = 0; i < kLoopIterations; i++) { more_channels.push_back( - MakeUnique(BaseNode::EntityType::kTopLevelChannel)); - BaseNode* retrieved = ChannelzRegistry::Get(more_channels[i]->uuid()); - EXPECT_EQ(more_channels[i].get(), retrieved); + MakeRefCounted(BaseNode::EntityType::kTopLevelChannel)); + RefCountedPtr retrieved = + ChannelzRegistry::Get(more_channels[i]->uuid()); + EXPECT_EQ(more_channels[i], retrieved); } } From 226e63dd0c84c378918cb3c91299b7d57887ec3c Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Tue, 4 Jun 2019 15:01:25 -0700 Subject: [PATCH 0431/1555] Move server context implementation to grpc_impl namespace and typedef the ref to it --- .gitignore | 2 + BUILD | 1 + BUILD.gn | 1 + CMakeLists.txt | 5 + Makefile | 5 + build.yaml | 1 + gRPC-C++.podspec | 1 + include/grpcpp/impl/codegen/client_context.h | 6 +- .../impl/codegen/completion_queue_impl.h | 4 +- .../grpcpp/impl/codegen/rpc_service_method.h | 8 +- include/grpcpp/impl/codegen/server_callback.h | 42 +- include/grpcpp/impl/codegen/server_context.h | 355 +---------------- .../grpcpp/impl/codegen/server_context_impl.h | 377 ++++++++++++++++++ .../grpcpp/impl/codegen/server_interceptor.h | 14 +- .../grpcpp/impl/codegen/server_interface.h | 22 +- include/grpcpp/impl/codegen/service_type.h | 11 +- include/grpcpp/opencensus.h | 2 +- include/grpcpp/opencensus_impl.h | 8 +- include/grpcpp/server_impl.h | 6 +- src/compiler/cpp_generator.cc | 2 +- src/cpp/ext/filters/census/grpc_plugin.h | 5 +- src/cpp/server/server_context.cc | 38 +- test/cpp/codegen/compiler_test_golden | 2 +- tools/doxygen/Doxyfile.c++ | 1 + tools/doxygen/Doxyfile.c++.internal | 1 + .../generated/sources_and_headers.json | 2 + 26 files changed, 491 insertions(+), 431 deletions(-) create mode 100644 include/grpcpp/impl/codegen/server_context_impl.h diff --git a/.gitignore b/.gitignore index bc324b5f826..a8c58277c34 100644 --- a/.gitignore +++ b/.gitignore @@ -144,3 +144,5 @@ bm_*.json !.vscode/launch.json !.vscode/extensions.json +# Clion artifacts +cmake-build-debug/ diff --git a/BUILD b/BUILD index e0827d46cb1..398099774e6 100644 --- a/BUILD +++ b/BUILD @@ -2185,6 +2185,7 @@ grpc_cc_library( "include/grpcpp/impl/codegen/serialization_traits.h", "include/grpcpp/impl/codegen/server_callback.h", "include/grpcpp/impl/codegen/server_context.h", + "include/grpcpp/impl/codegen/server_context_impl.h", "include/grpcpp/impl/codegen/server_interceptor.h", "include/grpcpp/impl/codegen/server_interface.h", "include/grpcpp/impl/codegen/service_type.h", diff --git a/BUILD.gn b/BUILD.gn index 258cdc9f873..61982917aca 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1081,6 +1081,7 @@ config("grpc_config") { "include/grpcpp/impl/codegen/serialization_traits.h", "include/grpcpp/impl/codegen/server_callback.h", "include/grpcpp/impl/codegen/server_context.h", + "include/grpcpp/impl/codegen/server_context_impl.h", "include/grpcpp/impl/codegen/server_interceptor.h", "include/grpcpp/impl/codegen/server_interface.h", "include/grpcpp/impl/codegen/service_type.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index e9d2168b8de..868de744eaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3334,6 +3334,7 @@ foreach(_hdr include/grpcpp/impl/codegen/serialization_traits.h include/grpcpp/impl/codegen/server_callback.h include/grpcpp/impl/codegen/server_context.h + include/grpcpp/impl/codegen/server_context_impl.h include/grpcpp/impl/codegen/server_interceptor.h include/grpcpp/impl/codegen/server_interface.h include/grpcpp/impl/codegen/service_type.h @@ -3953,6 +3954,7 @@ foreach(_hdr include/grpcpp/impl/codegen/serialization_traits.h include/grpcpp/impl/codegen/server_callback.h include/grpcpp/impl/codegen/server_context.h + include/grpcpp/impl/codegen/server_context_impl.h include/grpcpp/impl/codegen/server_interceptor.h include/grpcpp/impl/codegen/server_interface.h include/grpcpp/impl/codegen/service_type.h @@ -4388,6 +4390,7 @@ foreach(_hdr include/grpcpp/impl/codegen/serialization_traits.h include/grpcpp/impl/codegen/server_callback.h include/grpcpp/impl/codegen/server_context.h + include/grpcpp/impl/codegen/server_context_impl.h include/grpcpp/impl/codegen/server_interceptor.h include/grpcpp/impl/codegen/server_interface.h include/grpcpp/impl/codegen/service_type.h @@ -4587,6 +4590,7 @@ foreach(_hdr include/grpcpp/impl/codegen/serialization_traits.h include/grpcpp/impl/codegen/server_callback.h include/grpcpp/impl/codegen/server_context.h + include/grpcpp/impl/codegen/server_context_impl.h include/grpcpp/impl/codegen/server_interceptor.h include/grpcpp/impl/codegen/server_interface.h include/grpcpp/impl/codegen/service_type.h @@ -4946,6 +4950,7 @@ foreach(_hdr include/grpcpp/impl/codegen/serialization_traits.h include/grpcpp/impl/codegen/server_callback.h include/grpcpp/impl/codegen/server_context.h + include/grpcpp/impl/codegen/server_context_impl.h include/grpcpp/impl/codegen/server_interceptor.h include/grpcpp/impl/codegen/server_interface.h include/grpcpp/impl/codegen/service_type.h diff --git a/Makefile b/Makefile index e56c5ec4e47..3ece4e0cc0c 100644 --- a/Makefile +++ b/Makefile @@ -5691,6 +5691,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ include/grpcpp/impl/codegen/server_context.h \ + include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ include/grpcpp/impl/codegen/server_interface.h \ include/grpcpp/impl/codegen/service_type.h \ @@ -6318,6 +6319,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ include/grpcpp/impl/codegen/server_context.h \ + include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ include/grpcpp/impl/codegen/server_interface.h \ include/grpcpp/impl/codegen/service_type.h \ @@ -6725,6 +6727,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ include/grpcpp/impl/codegen/server_context.h \ + include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ include/grpcpp/impl/codegen/server_interface.h \ include/grpcpp/impl/codegen/service_type.h \ @@ -6895,6 +6898,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ include/grpcpp/impl/codegen/server_context.h \ + include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ include/grpcpp/impl/codegen/server_interface.h \ include/grpcpp/impl/codegen/service_type.h \ @@ -7260,6 +7264,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ include/grpcpp/impl/codegen/server_context.h \ + include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ include/grpcpp/impl/codegen/server_interface.h \ include/grpcpp/impl/codegen/service_type.h \ diff --git a/build.yaml b/build.yaml index 5c085f18787..6f4dafefd3f 100644 --- a/build.yaml +++ b/build.yaml @@ -1281,6 +1281,7 @@ filegroups: - include/grpcpp/impl/codegen/serialization_traits.h - include/grpcpp/impl/codegen/server_callback.h - include/grpcpp/impl/codegen/server_context.h + - include/grpcpp/impl/codegen/server_context_impl.h - include/grpcpp/impl/codegen/server_interceptor.h - include/grpcpp/impl/codegen/server_interface.h - include/grpcpp/impl/codegen/service_type.h diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 3b463cf7b90..f7df93f213e 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -182,6 +182,7 @@ Pod::Spec.new do |s| 'include/grpcpp/impl/codegen/serialization_traits.h', 'include/grpcpp/impl/codegen/server_callback.h', 'include/grpcpp/impl/codegen/server_context.h', + 'include/grpcpp/impl/codegen/server_context_impl.h', 'include/grpcpp/impl/codegen/server_interceptor.h', 'include/grpcpp/impl/codegen/server_interface.h', 'include/grpcpp/impl/codegen/service_type.h', diff --git a/include/grpcpp/impl/codegen/client_context.h b/include/grpcpp/impl/codegen/client_context.h index 999d8fcbfe7..28eece5deba 100644 --- a/include/grpcpp/impl/codegen/client_context.h +++ b/include/grpcpp/impl/codegen/client_context.h @@ -62,6 +62,7 @@ namespace grpc_impl { class CallCredentials; class Channel; class CompletionQueue; +class ServerContext; } // namespace grpc_impl namespace grpc { @@ -99,7 +100,6 @@ template class ClientAsyncReaderWriter; template class ClientAsyncResponseReader; -class ServerContext; /// Options for \a ClientContext::FromServerContext specifying which traits from /// the \a ServerContext to propagate (copy) from it into a new \a @@ -192,12 +192,12 @@ class ClientContext { /// \return A newly constructed \a ClientContext instance based on \a /// server_context, with traits propagated (copied) according to \a options. static std::unique_ptr FromServerContext( - const ServerContext& server_context, + const ::grpc_impl::ServerContext& server_context, PropagationOptions options = PropagationOptions()); /// Add the (\a meta_key, \a meta_value) pair to the metadata associated with /// a client call. These are made available at the server side by the \a - /// grpc::ServerContext::client_metadata() method. + /// grpc_impl::ServerContext::client_metadata() method. /// /// \warning This method should only be called before invoking the rpc. /// diff --git a/include/grpcpp/impl/codegen/completion_queue_impl.h b/include/grpcpp/impl/codegen/completion_queue_impl.h index d5c4bb0f201..a4cd1d0abfb 100644 --- a/include/grpcpp/impl/codegen/completion_queue_impl.h +++ b/include/grpcpp/impl/codegen/completion_queue_impl.h @@ -46,6 +46,7 @@ namespace grpc_impl { class Channel; class Server; class ServerBuilder; +class ServerContext; } // namespace grpc_impl namespace grpc { @@ -66,7 +67,6 @@ class ServerReaderWriterBody; class ChannelInterface; class ClientContext; -class ServerContext; class ServerInterface; namespace internal { @@ -278,7 +278,7 @@ class CompletionQueue : private ::grpc::GrpcLibraryCodegen { template <::grpc::StatusCode code> friend class ::grpc::internal::ErrorMethodHandler; friend class ::grpc_impl::Server; - friend class ::grpc::ServerContext; + friend class ::grpc_impl::ServerContext; friend class ::grpc::ServerInterface; template friend class ::grpc::internal::BlockingUnaryCallImpl; diff --git a/include/grpcpp/impl/codegen/rpc_service_method.h b/include/grpcpp/impl/codegen/rpc_service_method.h index 21fb2ac2130..0b16feed820 100644 --- a/include/grpcpp/impl/codegen/rpc_service_method.h +++ b/include/grpcpp/impl/codegen/rpc_service_method.h @@ -31,9 +31,11 @@ #include #include -namespace grpc { +namespace grpc_impl { class ServerContext; +} +namespace grpc { namespace internal { /// Base class for running an RPC handler. class MethodHandler { @@ -50,7 +52,7 @@ class MethodHandler { /// \param requester : used only by the callback API. It is a function /// called by the RPC Controller to request another RPC (and also /// to set up the state required to make that request possible) - HandlerParameter(Call* c, ServerContext* context, void* req, + HandlerParameter(Call* c, ::grpc_impl::ServerContext* context, void* req, Status req_status, void* handler_data, std::function requester) : call(c), @@ -61,7 +63,7 @@ class MethodHandler { call_requester(std::move(requester)) {} ~HandlerParameter() {} Call* call; - ServerContext* server_context; + ::grpc_impl::ServerContext* server_context; void* request; Status status; void* internal_data; diff --git a/include/grpcpp/impl/codegen/server_callback.h b/include/grpcpp/impl/codegen/server_callback.h index 9254518b605..da08ec963e4 100644 --- a/include/grpcpp/impl/codegen/server_callback.h +++ b/include/grpcpp/impl/codegen/server_callback.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include @@ -53,7 +53,7 @@ class ServerReactor { virtual void OnCancel() = 0; private: - friend class ::grpc::ServerContext; + friend class ::grpc_impl::ServerContext; template friend class CallbackClientStreamingHandler; template @@ -313,7 +313,7 @@ class ServerBidiReactor : public internal::ServerReactor { /// is a result of the client calling StartCall(). /// /// \param[in] context The context object now associated with this RPC - virtual void OnStarted(ServerContext* context) {} + virtual void OnStarted(::grpc_impl::ServerContext* context) {} /// Notifies the application that an explicit StartSendInitialMetadata /// operation completed. Not used when the sending of initial metadata @@ -372,7 +372,7 @@ class ServerReadReactor : public internal::ServerReactor { /// /// \param[in] context The context object now associated with this RPC /// \param[in] resp The response object to be used by this RPC - virtual void OnStarted(ServerContext* context, Response* resp) {} + virtual void OnStarted(::grpc_impl::ServerContext* context, Response* resp) {} /// The following notifications are exactly like ServerBidiReactor. virtual void OnSendInitialMetadataDone(bool ok) {} @@ -413,7 +413,8 @@ class ServerWriteReactor : public internal::ServerReactor { /// /// \param[in] context The context object now associated with this RPC /// \param[in] req The request object sent by the client - virtual void OnStarted(ServerContext* context, const Request* req) {} + virtual void OnStarted(::grpc_impl::ServerContext* context, + const Request* req) {} /// The following notifications are exactly like ServerBidiReactor. virtual void OnSendInitialMetadataDone(bool ok) {} @@ -437,7 +438,7 @@ class UnimplementedReadReactor : public experimental::ServerReadReactor { public: void OnDone() override { delete this; } - void OnStarted(ServerContext*, Response*) override { + void OnStarted(::grpc_impl::ServerContext*, Response*) override { this->Finish(Status(StatusCode::UNIMPLEMENTED, "")); } }; @@ -447,7 +448,7 @@ class UnimplementedWriteReactor : public experimental::ServerWriteReactor { public: void OnDone() override { delete this; } - void OnStarted(ServerContext*, const Request*) override { + void OnStarted(::grpc_impl::ServerContext*, const Request*) override { this->Finish(Status(StatusCode::UNIMPLEMENTED, "")); } }; @@ -457,7 +458,7 @@ class UnimplementedBidiReactor : public experimental::ServerBidiReactor { public: void OnDone() override { delete this; } - void OnStarted(ServerContext*) override { + void OnStarted(::grpc_impl::ServerContext*) override { this->Finish(Status(StatusCode::UNIMPLEMENTED, "")); } }; @@ -466,7 +467,8 @@ template class CallbackUnaryHandler : public MethodHandler { public: CallbackUnaryHandler( - std::function func) : func_(func) {} @@ -525,8 +527,8 @@ class CallbackUnaryHandler : public MethodHandler { } private: - std::function + std::function func_; experimental::MessageAllocator* allocator_ = nullptr; @@ -597,7 +599,7 @@ class CallbackUnaryHandler : public MethodHandler { friend class CallbackUnaryHandler; ServerCallbackRpcControllerImpl( - ServerContext* ctx, Call* call, + ::grpc_impl::ServerContext* ctx, Call* call, experimental::MessageHolder* allocator_state, std::function call_requester) : ctx_(ctx), @@ -628,7 +630,7 @@ class CallbackUnaryHandler : public MethodHandler { finish_ops_; CallbackWithSuccessTag finish_tag_; - ServerContext* ctx_; + ::grpc_impl::ServerContext* ctx_; Call call_; experimental::MessageHolder* const allocator_state_; @@ -732,7 +734,8 @@ class CallbackClientStreamingHandler : public MethodHandler { friend class CallbackClientStreamingHandler; ServerCallbackReaderImpl( - ServerContext* ctx, Call* call, std::function call_requester, + ::grpc_impl::ServerContext* ctx, Call* call, + std::function call_requester, experimental::ServerReadReactor* reactor) : ctx_(ctx), call_(*call), @@ -772,7 +775,7 @@ class CallbackClientStreamingHandler : public MethodHandler { CallOpSet> read_ops_; CallbackWithSuccessTag read_tag_; - ServerContext* ctx_; + ::grpc_impl::ServerContext* ctx_; Call call_; ResponseType resp_; std::function call_requester_; @@ -909,7 +912,7 @@ class CallbackServerStreamingHandler : public MethodHandler { friend class CallbackServerStreamingHandler; ServerCallbackWriterImpl( - ServerContext* ctx, Call* call, const RequestType* req, + ::grpc_impl::ServerContext* ctx, Call* call, const RequestType* req, std::function call_requester, experimental::ServerWriteReactor* reactor) : ctx_(ctx), @@ -950,7 +953,7 @@ class CallbackServerStreamingHandler : public MethodHandler { CallOpSet write_ops_; CallbackWithSuccessTag write_tag_; - ServerContext* ctx_; + ::grpc_impl::ServerContext* ctx_; Call call_; const RequestType* req_; std::function call_requester_; @@ -1078,7 +1081,8 @@ class CallbackBidiHandler : public MethodHandler { friend class CallbackBidiHandler; ServerCallbackReaderWriterImpl( - ServerContext* ctx, Call* call, std::function call_requester, + ::grpc_impl::ServerContext* ctx, Call* call, + std::function call_requester, experimental::ServerBidiReactor* reactor) : ctx_(ctx), call_(*call), @@ -1124,7 +1128,7 @@ class CallbackBidiHandler : public MethodHandler { CallOpSet> read_ops_; CallbackWithSuccessTag read_tag_; - ServerContext* ctx_; + ::grpc_impl::ServerContext* ctx_; Call call_; std::function call_requester_; experimental::ServerBidiReactor* reactor_; diff --git a/include/grpcpp/impl/codegen/server_context.h b/include/grpcpp/impl/codegen/server_context.h index c6903743938..7ae12755a1c 100644 --- a/include/grpcpp/impl/codegen/server_context.h +++ b/include/grpcpp/impl/codegen/server_context.h @@ -19,361 +19,10 @@ #ifndef GRPCPP_IMPL_CODEGEN_SERVER_CONTEXT_H #define GRPCPP_IMPL_CODEGEN_SERVER_CONTEXT_H -#include -#include -#include +#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct grpc_metadata; -struct grpc_call; -struct census_context; - -namespace grpc_impl { - -class CompletionQueue; -class Server; -} // namespace grpc_impl namespace grpc { -class ClientContext; -class GenericServerContext; -class ServerInterface; -template -class ServerAsyncReader; -template -class ServerAsyncWriter; -template -class ServerAsyncResponseWriter; -template -class ServerAsyncReaderWriter; -template -class ServerReader; -template -class ServerWriter; - -namespace internal { -template -class ServerReaderWriterBody; -template -class RpcMethodHandler; -template -class ClientStreamingHandler; -template -class ServerStreamingHandler; -template -class BidiStreamingHandler; -template -class CallbackUnaryHandler; -template -class CallbackClientStreamingHandler; -template -class CallbackServerStreamingHandler; -template -class CallbackBidiHandler; -template -class TemplatedBidiStreamingHandler; -template -class ErrorMethodHandler; -class Call; -class ServerReactor; -} // namespace internal - -class ServerInterface; -namespace testing { -class InteropServerContextInspector; -class ServerContextTestSpouse; -} // namespace testing - -/// A ServerContext allows the person implementing a service handler to: -/// -/// - Add custom initial and trailing metadata key-value pairs that will -/// propagated to the client side. -/// - Control call settings such as compression and authentication. -/// - Access metadata coming from the client. -/// - Get performance metrics (ie, census). -/// -/// Context settings are only relevant to the call handler they are supplied to, -/// that is to say, they aren't sticky across multiple calls. Some of these -/// settings, such as the compression options, can be made persistent at server -/// construction time by specifying the appropriate \a ChannelArguments -/// to a \a grpc::ServerBuilder, via \a ServerBuilder::AddChannelArgument. -/// -/// \warning ServerContext instances should \em not be reused across rpcs. -class ServerContext { - public: - ServerContext(); // for async calls - ~ServerContext(); - - /// Return the deadline for the server call. - std::chrono::system_clock::time_point deadline() const { - return Timespec2Timepoint(deadline_); - } - - /// Return a \a gpr_timespec representation of the server call's deadline. - gpr_timespec raw_deadline() const { return deadline_; } - - /// Add the (\a key, \a value) pair to the initial metadata - /// associated with a server call. These are made available at the client side - /// by the \a grpc::ClientContext::GetServerInitialMetadata() method. - /// - /// \warning This method should only be called before sending initial metadata - /// to the client (which can happen explicitly, or implicitly when sending a - /// a response message or status to the client). - /// - /// \param key The metadata key. If \a value is binary data, it must - /// end in "-bin". - /// \param value The metadata value. If its value is binary, the key name - /// must end in "-bin". - /// - /// Metadata must conform to the following format: - /// Custom-Metadata -> Binary-Header / ASCII-Header - /// Binary-Header -> {Header-Name "-bin" } {binary value} - /// ASCII-Header -> Header-Name ASCII-Value - /// Header-Name -> 1*( %x30-39 / %x61-7A / "_" / "-" / ".") ; 0-9 a-z _ - . - /// ASCII-Value -> 1*( %x20-%x7E ) ; space and printable ASCII - void AddInitialMetadata(const grpc::string& key, const grpc::string& value); - - /// Add the (\a key, \a value) pair to the initial metadata - /// associated with a server call. These are made available at the client - /// side by the \a grpc::ClientContext::GetServerTrailingMetadata() method. - /// - /// \warning This method should only be called before sending trailing - /// metadata to the client (which happens when the call is finished and a - /// status is sent to the client). - /// - /// \param key The metadata key. If \a value is binary data, - /// it must end in "-bin". - /// \param value The metadata value. If its value is binary, the key name - /// must end in "-bin". - /// - /// Metadata must conform to the following format: - /// Custom-Metadata -> Binary-Header / ASCII-Header - /// Binary-Header -> {Header-Name "-bin" } {binary value} - /// ASCII-Header -> Header-Name ASCII-Value - /// Header-Name -> 1*( %x30-39 / %x61-7A / "_" / "-" / ".") ; 0-9 a-z _ - . - /// ASCII-Value -> 1*( %x20-%x7E ) ; space and printable ASCII - void AddTrailingMetadata(const grpc::string& key, const grpc::string& value); - - /// IsCancelled is always safe to call when using sync or callback API. - /// When using async API, it is only safe to call IsCancelled after - /// the AsyncNotifyWhenDone tag has been delivered. - bool IsCancelled() const; - - /// Cancel the Call from the server. This is a best-effort API and - /// depending on when it is called, the RPC may still appear successful to - /// the client. - /// For example, if TryCancel() is called on a separate thread, it might race - /// with the server handler which might return success to the client before - /// TryCancel() was even started by the thread. - /// - /// It is the caller's responsibility to prevent such races and ensure that if - /// TryCancel() is called, the serverhandler must return Status::CANCELLED. - /// The only exception is that if the serverhandler is already returning an - /// error status code, it is ok to not return Status::CANCELLED even if - /// TryCancel() was called. - /// - /// Note that TryCancel() does not change any of the tags that are pending - /// on the completion queue. All pending tags will still be delivered - /// (though their ok result may reflect the effect of cancellation). - void TryCancel() const; - - /// Return a collection of initial metadata key-value pairs sent from the - /// client. Note that keys may happen more than - /// once (ie, a \a std::multimap is returned). - /// - /// It is safe to use this method after initial metadata has been received, - /// Calls always begin with the client sending initial metadata, so this is - /// safe to access as soon as the call has begun on the server side. - /// - /// \return A multimap of initial metadata key-value pairs from the server. - const std::multimap& client_metadata() - const { - return *client_metadata_.map(); - } - - /// Return the compression algorithm to be used by the server call. - grpc_compression_level compression_level() const { - return compression_level_; - } - - /// Set \a level to be the compression level used for the server call. - /// - /// \param level The compression level used for the server call. - void set_compression_level(grpc_compression_level level) { - compression_level_set_ = true; - compression_level_ = level; - } - - /// Return a bool indicating whether the compression level for this call - /// has been set (either implicitly or through a previous call to - /// \a set_compression_level. - bool compression_level_set() const { return compression_level_set_; } - - /// Return the compression algorithm the server call will request be used. - /// Note that the gRPC runtime may decide to ignore this request, for example, - /// due to resource constraints, or if the server is aware the client doesn't - /// support the requested algorithm. - grpc_compression_algorithm compression_algorithm() const { - return compression_algorithm_; - } - /// Set \a algorithm to be the compression algorithm used for the server call. - /// - /// \param algorithm The compression algorithm used for the server call. - void set_compression_algorithm(grpc_compression_algorithm algorithm); - - /// Set the serialized load reporting costs in \a cost_data for the call. - void SetLoadReportingCosts(const std::vector& cost_data); - - /// Return the authentication context for this server call. - /// - /// \see grpc::AuthContext. - std::shared_ptr auth_context() const { - if (auth_context_.get() == nullptr) { - auth_context_ = CreateAuthContext(call_); - } - return auth_context_; - } - - /// Return the peer uri in a string. - /// WARNING: this value is never authenticated or subject to any security - /// related code. It must not be used for any authentication related - /// functionality. Instead, use auth_context. - grpc::string peer() const; - - /// Get the census context associated with this server call. - const struct census_context* census_context() const; - - /// Async only. Has to be called before the rpc starts. - /// Returns the tag in completion queue when the rpc finishes. - /// IsCancelled() can then be called to check whether the rpc was cancelled. - /// TODO(vjpai): Fix this so that the tag is returned even if the call never - /// starts (https://github.com/grpc/grpc/issues/10136). - void AsyncNotifyWhenDone(void* tag) { - has_notify_when_done_tag_ = true; - async_notify_when_done_tag_ = tag; - } - - /// Should be used for framework-level extensions only. - /// Applications never need to call this method. - grpc_call* c_call() { return call_; } - - private: - friend class ::grpc::testing::InteropServerContextInspector; - friend class ::grpc::testing::ServerContextTestSpouse; - friend class ::grpc::ServerInterface; - friend class ::grpc_impl::Server; - template - friend class ::grpc::ServerAsyncReader; - template - friend class ::grpc::ServerAsyncWriter; - template - friend class ::grpc::ServerAsyncResponseWriter; - template - friend class ::grpc::ServerAsyncReaderWriter; - template - friend class ::grpc::ServerReader; - template - friend class ::grpc::ServerWriter; - template - friend class ::grpc::internal::ServerReaderWriterBody; - template - friend class ::grpc::internal::RpcMethodHandler; - template - friend class ::grpc::internal::ClientStreamingHandler; - template - friend class ::grpc::internal::ServerStreamingHandler; - template - friend class ::grpc::internal::TemplatedBidiStreamingHandler; - template - friend class ::grpc::internal::CallbackUnaryHandler; - template - friend class ::grpc::internal::CallbackClientStreamingHandler; - template - friend class ::grpc::internal::CallbackServerStreamingHandler; - template - friend class ::grpc::internal::CallbackBidiHandler; - template - friend class internal::ErrorMethodHandler; - friend class ::grpc::ClientContext; - friend class ::grpc::GenericServerContext; - - /// Prevent copying. - ServerContext(const ServerContext&); - ServerContext& operator=(const ServerContext&); - - class CompletionOp; - - void BeginCompletionOp(internal::Call* call, - std::function callback, - internal::ServerReactor* reactor); - /// Return the tag queued by BeginCompletionOp() - internal::CompletionQueueTag* GetCompletionOpTag(); - - ServerContext(gpr_timespec deadline, grpc_metadata_array* arr); - - void set_call(grpc_call* call) { call_ = call; } - - void BindDeadlineAndMetadata(gpr_timespec deadline, grpc_metadata_array* arr); - - void Clear(); - - void Setup(gpr_timespec deadline); - - uint32_t initial_metadata_flags() const { return 0; } - - void SetCancelCallback(std::function callback); - void ClearCancelCallback(); - - experimental::ServerRpcInfo* set_server_rpc_info( - const char* method, internal::RpcMethod::RpcType type, - const std::vector< - std::unique_ptr>& - creators) { - if (creators.size() != 0) { - rpc_info_ = new experimental::ServerRpcInfo(this, method, type); - rpc_info_->RegisterInterceptors(creators); - } - return rpc_info_; - } - - CompletionOp* completion_op_; - bool has_notify_when_done_tag_; - void* async_notify_when_done_tag_; - internal::CallbackWithSuccessTag completion_tag_; - - gpr_timespec deadline_; - grpc_call* call_; - ::grpc_impl::CompletionQueue* cq_; - bool sent_initial_metadata_; - mutable std::shared_ptr auth_context_; - mutable internal::MetadataMap client_metadata_; - std::multimap initial_metadata_; - std::multimap trailing_metadata_; - - bool compression_level_set_; - grpc_compression_level compression_level_; - grpc_compression_algorithm compression_algorithm_; - - internal::CallOpSet - pending_ops_; - bool has_pending_ops_; - - experimental::ServerRpcInfo* rpc_info_; -}; - +typedef ::grpc_impl::ServerContext ServerContext; } // namespace grpc #endif // GRPCPP_IMPL_CODEGEN_SERVER_CONTEXT_H diff --git a/include/grpcpp/impl/codegen/server_context_impl.h b/include/grpcpp/impl/codegen/server_context_impl.h new file mode 100644 index 00000000000..5694aaf64dd --- /dev/null +++ b/include/grpcpp/impl/codegen/server_context_impl.h @@ -0,0 +1,377 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SERVER_CONTEXT_IMPL_H +#define GRPCPP_IMPL_CODEGEN_SERVER_CONTEXT_IMPL_H +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct grpc_metadata; +struct grpc_call; +struct census_context; + +namespace grpc_impl { + +class CompletionQueue; +class Server; +} // namespace grpc_impl +namespace grpc { +class ClientContext; +class GenericServerContext; +class ServerInterface; +template +class ServerAsyncReader; +template +class ServerAsyncWriter; +template +class ServerAsyncResponseWriter; +template +class ServerAsyncReaderWriter; +template +class ServerReader; +template +class ServerWriter; + +namespace internal { +template +class ServerReaderWriterBody; +template +class RpcMethodHandler; +template +class ClientStreamingHandler; +template +class ServerStreamingHandler; +template +class BidiStreamingHandler; +template +class CallbackUnaryHandler; +template +class CallbackClientStreamingHandler; +template +class CallbackServerStreamingHandler; +template +class CallbackBidiHandler; +template +class TemplatedBidiStreamingHandler; +template +class ErrorMethodHandler; +class Call; +class ServerReactor; +} // namespace internal + +class ServerInterface; +namespace testing { +class InteropServerContextInspector; +class ServerContextTestSpouse; +} // namespace testing +} // namespace grpc + +namespace grpc_impl { +/// A ServerContext allows the person implementing a service handler to: +/// +/// - Add custom initial and trailing metadata key-value pairs that will +/// propagated to the client side. +/// - Control call settings such as compression and authentication. +/// - Access metadata coming from the client. +/// - Get performance metrics (ie, census). +/// +/// Context settings are only relevant to the call handler they are supplied to, +/// that is to say, they aren't sticky across multiple calls. Some of these +/// settings, such as the compression options, can be made persistent at server +/// construction time by specifying the appropriate \a ChannelArguments +/// to a \a grpc::ServerBuilder, via \a ServerBuilder::AddChannelArgument. +/// +/// \warning ServerContext instances should \em not be reused across rpcs. +class ServerContext { + public: + ServerContext(); // for async calls + ~ServerContext(); + + /// Return the deadline for the server call. + std::chrono::system_clock::time_point deadline() const { + return ::grpc::Timespec2Timepoint(deadline_); + } + + /// Return a \a gpr_timespec representation of the server call's deadline. + gpr_timespec raw_deadline() const { return deadline_; } + + /// Add the (\a key, \a value) pair to the initial metadata + /// associated with a server call. These are made available at the client side + /// by the \a grpc::ClientContext::GetServerInitialMetadata() method. + /// + /// \warning This method should only be called before sending initial metadata + /// to the client (which can happen explicitly, or implicitly when sending a + /// a response message or status to the client). + /// + /// \param key The metadata key. If \a value is binary data, it must + /// end in "-bin". + /// \param value The metadata value. If its value is binary, the key name + /// must end in "-bin". + /// + /// Metadata must conform to the following format: + /// Custom-Metadata -> Binary-Header / ASCII-Header + /// Binary-Header -> {Header-Name "-bin" } {binary value} + /// ASCII-Header -> Header-Name ASCII-Value + /// Header-Name -> 1*( %x30-39 / %x61-7A / "_" / "-" / ".") ; 0-9 a-z _ - . + /// ASCII-Value -> 1*( %x20-%x7E ) ; space and printable ASCII + void AddInitialMetadata(const grpc::string& key, const grpc::string& value); + + /// Add the (\a key, \a value) pair to the initial metadata + /// associated with a server call. These are made available at the client + /// side by the \a grpc::ClientContext::GetServerTrailingMetadata() method. + /// + /// \warning This method should only be called before sending trailing + /// metadata to the client (which happens when the call is finished and a + /// status is sent to the client). + /// + /// \param key The metadata key. If \a value is binary data, + /// it must end in "-bin". + /// \param value The metadata value. If its value is binary, the key name + /// must end in "-bin". + /// + /// Metadata must conform to the following format: + /// Custom-Metadata -> Binary-Header / ASCII-Header + /// Binary-Header -> {Header-Name "-bin" } {binary value} + /// ASCII-Header -> Header-Name ASCII-Value + /// Header-Name -> 1*( %x30-39 / %x61-7A / "_" / "-" / ".") ; 0-9 a-z _ - . + /// ASCII-Value -> 1*( %x20-%x7E ) ; space and printable ASCII + void AddTrailingMetadata(const grpc::string& key, const grpc::string& value); + + /// IsCancelled is always safe to call when using sync or callback API. + /// When using async API, it is only safe to call IsCancelled after + /// the AsyncNotifyWhenDone tag has been delivered. + bool IsCancelled() const; + + /// Cancel the Call from the server. This is a best-effort API and + /// depending on when it is called, the RPC may still appear successful to + /// the client. + /// For example, if TryCancel() is called on a separate thread, it might race + /// with the server handler which might return success to the client before + /// TryCancel() was even started by the thread. + /// + /// It is the caller's responsibility to prevent such races and ensure that if + /// TryCancel() is called, the serverhandler must return Status::CANCELLED. + /// The only exception is that if the serverhandler is already returning an + /// error status code, it is ok to not return Status::CANCELLED even if + /// TryCancel() was called. + /// + /// Note that TryCancel() does not change any of the tags that are pending + /// on the completion queue. All pending tags will still be delivered + /// (though their ok result may reflect the effect of cancellation). + void TryCancel() const; + + /// Return a collection of initial metadata key-value pairs sent from the + /// client. Note that keys may happen more than + /// once (ie, a \a std::multimap is returned). + /// + /// It is safe to use this method after initial metadata has been received, + /// Calls always begin with the client sending initial metadata, so this is + /// safe to access as soon as the call has begun on the server side. + /// + /// \return A multimap of initial metadata key-value pairs from the server. + const std::multimap& client_metadata() + const { + return *client_metadata_.map(); + } + + /// Return the compression algorithm to be used by the server call. + grpc_compression_level compression_level() const { + return compression_level_; + } + + /// Set \a level to be the compression level used for the server call. + /// + /// \param level The compression level used for the server call. + void set_compression_level(grpc_compression_level level) { + compression_level_set_ = true; + compression_level_ = level; + } + + /// Return a bool indicating whether the compression level for this call + /// has been set (either implicitly or through a previous call to + /// \a set_compression_level. + bool compression_level_set() const { return compression_level_set_; } + + /// Return the compression algorithm the server call will request be used. + /// Note that the gRPC runtime may decide to ignore this request, for example, + /// due to resource constraints, or if the server is aware the client doesn't + /// support the requested algorithm. + grpc_compression_algorithm compression_algorithm() const { + return compression_algorithm_; + } + /// Set \a algorithm to be the compression algorithm used for the server call. + /// + /// \param algorithm The compression algorithm used for the server call. + void set_compression_algorithm(grpc_compression_algorithm algorithm); + + /// Set the serialized load reporting costs in \a cost_data for the call. + void SetLoadReportingCosts(const std::vector& cost_data); + + /// Return the authentication context for this server call. + /// + /// \see grpc::AuthContext. + std::shared_ptr auth_context() const { + if (auth_context_.get() == nullptr) { + auth_context_ = ::grpc::CreateAuthContext(call_); + } + return auth_context_; + } + + /// Return the peer uri in a string. + /// WARNING: this value is never authenticated or subject to any security + /// related code. It must not be used for any authentication related + /// functionality. Instead, use auth_context. + grpc::string peer() const; + + /// Get the census context associated with this server call. + const struct census_context* census_context() const; + + /// Async only. Has to be called before the rpc starts. + /// Returns the tag in completion queue when the rpc finishes. + /// IsCancelled() can then be called to check whether the rpc was cancelled. + /// TODO(vjpai): Fix this so that the tag is returned even if the call never + /// starts (https://github.com/grpc/grpc/issues/10136). + void AsyncNotifyWhenDone(void* tag) { + has_notify_when_done_tag_ = true; + async_notify_when_done_tag_ = tag; + } + + /// Should be used for framework-level extensions only. + /// Applications never need to call this method. + grpc_call* c_call() { return call_; } + + private: + friend class ::grpc::testing::InteropServerContextInspector; + friend class ::grpc::testing::ServerContextTestSpouse; + friend class ::grpc::ServerInterface; + friend class ::grpc_impl::Server; + template + friend class ::grpc::ServerAsyncReader; + template + friend class ::grpc::ServerAsyncWriter; + template + friend class ::grpc::ServerAsyncResponseWriter; + template + friend class ::grpc::ServerAsyncReaderWriter; + template + friend class ::grpc::ServerReader; + template + friend class ::grpc::ServerWriter; + template + friend class ::grpc::internal::ServerReaderWriterBody; + template + friend class ::grpc::internal::RpcMethodHandler; + template + friend class ::grpc::internal::ClientStreamingHandler; + template + friend class ::grpc::internal::ServerStreamingHandler; + template + friend class ::grpc::internal::TemplatedBidiStreamingHandler; + template + friend class ::grpc::internal::CallbackUnaryHandler; + template + friend class ::grpc::internal::CallbackClientStreamingHandler; + template + friend class ::grpc::internal::CallbackServerStreamingHandler; + template + friend class ::grpc::internal::CallbackBidiHandler; + template <::grpc::StatusCode code> + friend class ::grpc::internal::ErrorMethodHandler; + friend class ::grpc::ClientContext; + friend class ::grpc::GenericServerContext; + + /// Prevent copying. + ServerContext(const ServerContext&); + ServerContext& operator=(const ServerContext&); + + class CompletionOp; + + void BeginCompletionOp(::grpc::internal::Call* call, + std::function callback, + ::grpc::internal::ServerReactor* reactor); + /// Return the tag queued by BeginCompletionOp() + ::grpc::internal::CompletionQueueTag* GetCompletionOpTag(); + + ServerContext(gpr_timespec deadline, grpc_metadata_array* arr); + + void set_call(grpc_call* call) { call_ = call; } + + void BindDeadlineAndMetadata(gpr_timespec deadline, grpc_metadata_array* arr); + + void Clear(); + + void Setup(gpr_timespec deadline); + + uint32_t initial_metadata_flags() const { return 0; } + + void SetCancelCallback(std::function callback); + void ClearCancelCallback(); + + ::grpc::experimental::ServerRpcInfo* set_server_rpc_info( + const char* method, ::grpc::internal::RpcMethod::RpcType type, + const std::vector>& creators) { + if (creators.size() != 0) { + rpc_info_ = new ::grpc::experimental::ServerRpcInfo(this, method, type); + rpc_info_->RegisterInterceptors(creators); + } + return rpc_info_; + } + + CompletionOp* completion_op_; + bool has_notify_when_done_tag_; + void* async_notify_when_done_tag_; + ::grpc::internal::CallbackWithSuccessTag completion_tag_; + + gpr_timespec deadline_; + grpc_call* call_; + ::grpc_impl::CompletionQueue* cq_; + bool sent_initial_metadata_; + mutable std::shared_ptr auth_context_; + mutable ::grpc::internal::MetadataMap client_metadata_; + std::multimap initial_metadata_; + std::multimap trailing_metadata_; + + bool compression_level_set_; + grpc_compression_level compression_level_; + grpc_compression_algorithm compression_algorithm_; + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage> + pending_ops_; + bool has_pending_ops_; + + ::grpc::experimental::ServerRpcInfo* rpc_info_; +}; +} // namespace grpc_impl +#endif // GRPCPP_IMPL_CODEGEN_SERVER_CONTEXT_IMPL_H diff --git a/include/grpcpp/impl/codegen/server_interceptor.h b/include/grpcpp/impl/codegen/server_interceptor.h index 8875a28bf32..28fdc27ec68 100644 --- a/include/grpcpp/impl/codegen/server_interceptor.h +++ b/include/grpcpp/impl/codegen/server_interceptor.h @@ -26,9 +26,11 @@ #include #include -namespace grpc { - +namespace grpc_impl { class ServerContext; +} + +namespace grpc { namespace internal { class InterceptorBatchMethodsImpl; @@ -78,7 +80,7 @@ class ServerRpcInfo { /// Return a pointer to the underlying ServerContext structure associated /// with the RPC to support features that apply to it - grpc::ServerContext* server_context() { return ctx_; } + grpc_impl::ServerContext* server_context() { return ctx_; } private: static_assert(Type::UNARY == @@ -94,7 +96,7 @@ class ServerRpcInfo { static_cast(internal::RpcMethod::BIDI_STREAMING), "violated expectation about Type enum"); - ServerRpcInfo(grpc::ServerContext* ctx, const char* method, + ServerRpcInfo(grpc_impl::ServerContext* ctx, const char* method, internal::RpcMethod::RpcType type) : ctx_(ctx), method_(method), type_(static_cast(type)) { ref_.store(1); @@ -127,14 +129,14 @@ class ServerRpcInfo { } } - grpc::ServerContext* ctx_ = nullptr; + grpc_impl::ServerContext* ctx_ = nullptr; const char* method_ = nullptr; const Type type_; std::atomic_int ref_; std::vector> interceptors_; friend class internal::InterceptorBatchMethodsImpl; - friend class grpc::ServerContext; + friend class grpc_impl::ServerContext; }; } // namespace experimental diff --git a/include/grpcpp/impl/codegen/server_interface.h b/include/grpcpp/impl/codegen/server_interface.h index d8d49344965..9600e5f053d 100644 --- a/include/grpcpp/impl/codegen/server_interface.h +++ b/include/grpcpp/impl/codegen/server_interface.h @@ -34,12 +34,12 @@ class Channel; class CompletionQueue; class ServerCompletionQueue; class ServerCredentials; +class ServerContext; } // namespace grpc_impl namespace grpc { class AsyncGenericService; class GenericServerContext; -class ServerContext; class Service; extern CoreCodegenInterface* g_core_codegen_interface; @@ -176,7 +176,8 @@ class ServerInterface : public internal::CallHook { class BaseAsyncRequest : public internal::CompletionQueueTag { public: - BaseAsyncRequest(ServerInterface* server, ServerContext* context, + BaseAsyncRequest(ServerInterface* server, + ::grpc_impl::ServerContext* context, internal::ServerAsyncStreamingInterface* stream, ::grpc_impl::CompletionQueue* call_cq, ::grpc_impl::ServerCompletionQueue* notification_cq, @@ -190,7 +191,7 @@ class ServerInterface : public internal::CallHook { protected: ServerInterface* const server_; - ServerContext* const context_; + ::grpc_impl::ServerContext* const context_; internal::ServerAsyncStreamingInterface* const stream_; ::grpc_impl::CompletionQueue* const call_cq_; ::grpc_impl::ServerCompletionQueue* const notification_cq_; @@ -205,7 +206,8 @@ class ServerInterface : public internal::CallHook { /// RegisteredAsyncRequest is not part of the C++ API class RegisteredAsyncRequest : public BaseAsyncRequest { public: - RegisteredAsyncRequest(ServerInterface* server, ServerContext* context, + RegisteredAsyncRequest(ServerInterface* server, + ::grpc_impl::ServerContext* context, internal::ServerAsyncStreamingInterface* stream, ::grpc_impl::CompletionQueue* call_cq, ::grpc_impl::ServerCompletionQueue* notification_cq, @@ -234,7 +236,8 @@ class ServerInterface : public internal::CallHook { class NoPayloadAsyncRequest final : public RegisteredAsyncRequest { public: NoPayloadAsyncRequest(internal::RpcServiceMethod* registered_method, - ServerInterface* server, ServerContext* context, + ServerInterface* server, + ::grpc_impl::ServerContext* context, internal::ServerAsyncStreamingInterface* stream, ::grpc_impl::CompletionQueue* call_cq, ::grpc_impl::ServerCompletionQueue* notification_cq, @@ -252,7 +255,8 @@ class ServerInterface : public internal::CallHook { class PayloadAsyncRequest final : public RegisteredAsyncRequest { public: PayloadAsyncRequest(internal::RpcServiceMethod* registered_method, - ServerInterface* server, ServerContext* context, + ServerInterface* server, + ::grpc_impl::ServerContext* context, internal::ServerAsyncStreamingInterface* stream, ::grpc_impl::CompletionQueue* call_cq, ::grpc_impl::ServerCompletionQueue* notification_cq, @@ -309,7 +313,7 @@ class ServerInterface : public internal::CallHook { private: internal::RpcServiceMethod* const registered_method_; ServerInterface* const server_; - ServerContext* const context_; + ::grpc_impl::ServerContext* const context_; internal::ServerAsyncStreamingInterface* const stream_; ::grpc_impl::CompletionQueue* const call_cq_; @@ -335,7 +339,7 @@ class ServerInterface : public internal::CallHook { template void RequestAsyncCall(internal::RpcServiceMethod* method, - ServerContext* context, + ::grpc_impl::ServerContext* context, internal::ServerAsyncStreamingInterface* stream, ::grpc_impl::CompletionQueue* call_cq, ::grpc_impl::ServerCompletionQueue* notification_cq, @@ -346,7 +350,7 @@ class ServerInterface : public internal::CallHook { } void RequestAsyncCall(internal::RpcServiceMethod* method, - ServerContext* context, + ::grpc_impl::ServerContext* context, internal::ServerAsyncStreamingInterface* stream, ::grpc_impl::CompletionQueue* call_cq, ::grpc_impl::ServerCompletionQueue* notification_cq, diff --git a/include/grpcpp/impl/codegen/service_type.h b/include/grpcpp/impl/codegen/service_type.h index f1d1272dc20..4109ee1b504 100644 --- a/include/grpcpp/impl/codegen/service_type.h +++ b/include/grpcpp/impl/codegen/service_type.h @@ -30,11 +30,11 @@ namespace grpc_impl { class Server; class CompletionQueue; +class ServerContext; } // namespace grpc_impl namespace grpc { class ServerInterface; -class ServerContext; namespace internal { class Call; @@ -146,7 +146,8 @@ class Service { experimental_type experimental() { return experimental_type(this); } template - void RequestAsyncUnary(int index, ServerContext* context, Message* request, + void RequestAsyncUnary(int index, ::grpc_impl::ServerContext* context, + Message* request, internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, ServerCompletionQueue* notification_cq, void* tag) { @@ -158,7 +159,7 @@ class Service { notification_cq, tag, request); } void RequestAsyncClientStreaming( - int index, ServerContext* context, + int index, ::grpc_impl::ServerContext* context, internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, ServerCompletionQueue* notification_cq, void* tag) { size_t idx = static_cast(index); @@ -167,7 +168,7 @@ class Service { } template void RequestAsyncServerStreaming( - int index, ServerContext* context, Message* request, + int index, ::grpc_impl::ServerContext* context, Message* request, internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, ServerCompletionQueue* notification_cq, void* tag) { size_t idx = static_cast(index); @@ -175,7 +176,7 @@ class Service { notification_cq, tag, request); } void RequestAsyncBidiStreaming( - int index, ServerContext* context, + int index, ::grpc_impl::ServerContext* context, internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, ServerCompletionQueue* notification_cq, void* tag) { size_t idx = static_cast(index); diff --git a/include/grpcpp/opencensus.h b/include/grpcpp/opencensus.h index 14c6add1d9e..39bac6bc28c 100644 --- a/include/grpcpp/opencensus.h +++ b/include/grpcpp/opencensus.h @@ -30,7 +30,7 @@ static inline void RegisterOpenCensusViewsForExport() { ::grpc_impl::RegisterOpenCensusViewsForExport(); } static inline ::opencensus::trace::Span GetSpanFromServerContext( - ServerContext* context) { + ::grpc_impl::ServerContext* context) { return ::grpc_impl::GetSpanFromServerContext(context); } diff --git a/include/grpcpp/opencensus_impl.h b/include/grpcpp/opencensus_impl.h index 631d2b861fd..dbcb7c9caeb 100644 --- a/include/grpcpp/opencensus_impl.h +++ b/include/grpcpp/opencensus_impl.h @@ -21,11 +21,8 @@ #include "opencensus/trace/span.h" -namespace grpc { - -class ServerContext; -} namespace grpc_impl { +class ServerContext; // These symbols in this file will not be included in the binary unless // grpc_opencensus_plugin build target was added as a dependency. At the moment // it is only setup to be built with Bazel. @@ -43,8 +40,7 @@ void RegisterOpenCensusPlugin(); void RegisterOpenCensusViewsForExport(); // Returns the tracing Span for the current RPC. -::opencensus::trace::Span GetSpanFromServerContext( - grpc::ServerContext* context); +::opencensus::trace::Span GetSpanFromServerContext(ServerContext* context); } // namespace grpc_impl diff --git a/include/grpcpp/server_impl.h b/include/grpcpp/server_impl.h index 59a780276e0..90019e25032 100644 --- a/include/grpcpp/server_impl.h +++ b/include/grpcpp/server_impl.h @@ -44,7 +44,6 @@ struct grpc_server; namespace grpc { class AsyncGenericService; -class ServerContext; namespace internal { class ExternalConnectionAcceptorImpl; @@ -54,6 +53,7 @@ class ExternalConnectionAcceptorImpl; namespace grpc_impl { class HealthCheckServiceInterface; +class ServerContext; class ServerInitializer; /// Represents a gRPC server. @@ -82,9 +82,9 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { /// Called before server is created. virtual void UpdateArguments(grpc::ChannelArguments* args) {} /// Called before application callback for each synchronous server request - virtual void PreSynchronousRequest(grpc::ServerContext* context) = 0; + virtual void PreSynchronousRequest(grpc_impl::ServerContext* context) = 0; /// Called after application callback for each synchronous server request - virtual void PostSynchronousRequest(grpc::ServerContext* context) = 0; + virtual void PostSynchronousRequest(grpc_impl::ServerContext* context) = 0; /// Called before server is started. virtual void PreServerStart(Server* server) {} /// Called after a server port is added. diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index bcc849035c6..23e3bd50eff 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -157,13 +157,13 @@ grpc::string GetHeaderIncludes(grpc_generator::File* file, printer->Print(vars, "namespace grpc_impl {\n"); printer->Print(vars, "class CompletionQueue;\n"); printer->Print(vars, "class ServerCompletionQueue;\n"); + printer->Print(vars, "class ServerContext;\n"); printer->Print(vars, "} // namespace grpc_impl\n\n"); printer->Print(vars, "namespace grpc {\n"); printer->Print(vars, "namespace experimental {\n"); printer->Print(vars, "template \n"); printer->Print(vars, "class MessageAllocator;\n"); printer->Print(vars, "} // namespace experimental\n"); - printer->Print(vars, "class ServerContext;\n"); printer->Print(vars, "} // namespace grpc\n\n"); vars["message_header_ext"] = params.message_header_extension.empty() diff --git a/src/cpp/ext/filters/census/grpc_plugin.h b/src/cpp/ext/filters/census/grpc_plugin.h index 993faae0a94..13176759e37 100644 --- a/src/cpp/ext/filters/census/grpc_plugin.h +++ b/src/cpp/ext/filters/census/grpc_plugin.h @@ -25,8 +25,11 @@ #include "include/grpcpp/opencensus.h" #include "opencensus/stats/stats.h" -namespace grpc { +namespace grpc_impl { class ServerContext; +} + +namespace grpc { // The tag keys set when recording RPC stats. ::opencensus::stats::TagKey ClientMethodTagKey(); diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc index eced89d1a79..ba834237ae9 100644 --- a/src/cpp/server/server_context.cc +++ b/src/cpp/server/server_context.cc @@ -16,7 +16,7 @@ * */ -#include +#include #include #include @@ -28,23 +28,25 @@ #include #include #include -#include #include +#include #include #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/surface/call.h" -namespace grpc { +namespace grpc_impl { // CompletionOp -class ServerContext::CompletionOp final : public internal::CallOpSetInterface { +class ServerContext::CompletionOp final + : public ::grpc::internal::CallOpSetInterface { public: // initial refs: one in the server context, one in the cq // must ref the call before calling constructor and after deleting this - CompletionOp(internal::Call* call, internal::ServerReactor* reactor) + CompletionOp(::grpc::internal::Call* call, + ::grpc::internal::ServerReactor* reactor) : call_(*call), reactor_(reactor), has_tag_(false), @@ -67,7 +69,7 @@ class ServerContext::CompletionOp final : public internal::CallOpSetInterface { } } - void FillOps(internal::Call* call) override; + void FillOps(::grpc::internal::Call* call) override; // This should always be arena allocated in the call, so override delete. // But this class is not trivially destructible, so must actually call delete @@ -149,8 +151,8 @@ class ServerContext::CompletionOp final : public internal::CallOpSetInterface { return finalized_ ? (cancelled_ != 0) : false; } - internal::Call call_; - internal::ServerReactor* const reactor_; + ::grpc::internal::Call call_; + ::grpc::internal::ServerReactor* const reactor_; bool has_tag_; void* tag_; void* core_cq_tag_; @@ -160,7 +162,7 @@ class ServerContext::CompletionOp final : public internal::CallOpSetInterface { int cancelled_; // This is an int (not bool) because it is passed to core std::function cancel_callback_; bool done_intercepting_; - internal::InterceptorBatchMethodsImpl interceptor_methods_; + ::grpc::internal::InterceptorBatchMethodsImpl interceptor_methods_; }; void ServerContext::CompletionOp::Unref() { @@ -171,7 +173,7 @@ void ServerContext::CompletionOp::Unref() { } } -void ServerContext::CompletionOp::FillOps(internal::Call* call) { +void ServerContext::CompletionOp::FillOps(::grpc::internal::Call* call) { grpc_op ops; ops.op = GRPC_OP_RECV_CLOSE_ON_SERVER; ops.data.recv_close_on_server.cancelled = &cancelled_; @@ -227,7 +229,7 @@ bool ServerContext::CompletionOp::FinalizeResult(void** tag, bool* status) { } /* Add interception point and run through interceptors */ interceptor_methods_.AddInterceptionHookPoint( - experimental::InterceptionHookPoints::POST_RECV_CLOSE); + ::grpc::experimental::InterceptionHookPoints::POST_RECV_CLOSE); if (interceptor_methods_.RunInterceptors()) { /* No interceptors were run */ if (has_tag_) { @@ -292,9 +294,9 @@ void ServerContext::Clear() { } } -void ServerContext::BeginCompletionOp(internal::Call* call, - std::function callback, - internal::ServerReactor* reactor) { +void ServerContext::BeginCompletionOp( + ::grpc::internal::Call* call, std::function callback, + ::grpc::internal::ServerReactor* reactor) { GPR_ASSERT(!completion_op_); if (rpc_info_) { rpc_info_->Ref(); @@ -313,8 +315,8 @@ void ServerContext::BeginCompletionOp(internal::Call* call, call->PerformOps(completion_op_); } -internal::CompletionQueueTag* ServerContext::GetCompletionOpTag() { - return static_cast(completion_op_); +::grpc::internal::CompletionQueueTag* ServerContext::GetCompletionOpTag() { + return static_cast<::grpc::internal::CompletionQueueTag*>(completion_op_); } void ServerContext::AddInitialMetadata(const grpc::string& key, @@ -328,7 +330,7 @@ void ServerContext::AddTrailingMetadata(const grpc::string& key, } void ServerContext::TryCancel() const { - internal::CancelInterceptorBatchMethods cancel_methods; + ::grpc::internal::CancelInterceptorBatchMethods cancel_methods; if (rpc_info_) { for (size_t i = 0; i < rpc_info_->interceptors_.size(); i++) { rpc_info_->RunInterceptor(&cancel_methods, i); @@ -398,4 +400,4 @@ void ServerContext::SetLoadReportingCosts( } } -} // namespace grpc +} // namespace grpc_impl diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index 761c3ac6106..64ab123123b 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -43,6 +43,7 @@ namespace grpc_impl { class CompletionQueue; class ServerCompletionQueue; +class ServerContext; } // namespace grpc_impl namespace grpc { @@ -50,7 +51,6 @@ namespace experimental { template class MessageAllocator; } // namespace experimental -class ServerContext; } // namespace grpc namespace grpc { diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 913d7be993b..859bfdd9d16 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -982,6 +982,7 @@ include/grpcpp/impl/codegen/security/auth_context.h \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ include/grpcpp/impl/codegen/server_context.h \ +include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ include/grpcpp/impl/codegen/server_interface.h \ include/grpcpp/impl/codegen/service_type.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 8b664d8ac01..db5ff65a7e9 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -984,6 +984,7 @@ include/grpcpp/impl/codegen/security/auth_context.h \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ include/grpcpp/impl/codegen/server_context.h \ +include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ include/grpcpp/impl/codegen/server_interface.h \ include/grpcpp/impl/codegen/service_type.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index a479a00509a..119319758f3 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -10151,6 +10151,7 @@ "include/grpcpp/impl/codegen/serialization_traits.h", "include/grpcpp/impl/codegen/server_callback.h", "include/grpcpp/impl/codegen/server_context.h", + "include/grpcpp/impl/codegen/server_context_impl.h", "include/grpcpp/impl/codegen/server_interceptor.h", "include/grpcpp/impl/codegen/server_interface.h", "include/grpcpp/impl/codegen/service_type.h", @@ -10229,6 +10230,7 @@ "include/grpcpp/impl/codegen/serialization_traits.h", "include/grpcpp/impl/codegen/server_callback.h", "include/grpcpp/impl/codegen/server_context.h", + "include/grpcpp/impl/codegen/server_context_impl.h", "include/grpcpp/impl/codegen/server_interceptor.h", "include/grpcpp/impl/codegen/server_interface.h", "include/grpcpp/impl/codegen/service_type.h", From a64ddff19c4ca8b5c2c9ae1aa41b70830a20eaed Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 5 Jun 2019 14:16:51 -0400 Subject: [PATCH 0432/1555] hijack bazel invocations in grpc workspace --- tools/{bazel.sh => bazel} | 28 ++++++++++++++++------------ tools/remote_build/README.md | 11 +++-------- 2 files changed, 19 insertions(+), 20 deletions(-) rename tools/{bazel.sh => bazel} (65%) diff --git a/tools/bazel.sh b/tools/bazel similarity index 65% rename from tools/bazel.sh rename to tools/bazel index 37fd2a242bf..15c78dd0ffa 100755 --- a/tools/bazel.sh +++ b/tools/bazel @@ -19,17 +19,21 @@ # supported version, and then calling it. This way, we can make sure # that running bazel will always get meaningful results, at least # until Bazel 1.0 is released. +# NOTE: This script relies on bazel's feature where //tools/bazel +# script can be used to hijack "bazel" invocations in given workspace. set -e VERSION=0.24.1 -CWD=`pwd` -BASEURL=https://github.com/bazelbuild/bazel/releases/download/ -cd `dirname $0` -TOOLDIR=`pwd` +echo "INFO: Running bazel wrapper (see //tools/bazel for details), bazel version $VERSION will be used instead of system-wide bazel installation." -case `uname -sm` in +CWD=$(pwd) +BASEURL=https://github.com/bazelbuild/bazel/releases/download/ +cd "$(dirname "$0")" +TOOLDIR=$(pwd) + +case $(uname -sm) in "Linux x86_64") suffix=linux-x86_64 ;; @@ -37,17 +41,17 @@ case `uname -sm` in suffix=darwin-x86_64 ;; *) - echo "Unsupported architecture: `uname -sm`" + echo "Unsupported architecture: $(uname -sm)" exit 1 ;; esac -filename=bazel-$VERSION-$suffix +filename="bazel-$VERSION-$suffix" -if [ ! -x $filename ] ; then - curl -L $BASEURL/$VERSION/$filename > $filename - chmod a+x $filename +if [ ! -x "$filename" ] ; then + curl -L "$BASEURL/$VERSION/$filename" > "$filename" + chmod a+x "$filename" fi -cd $CWD -$TOOLDIR/$filename $@ +cd "$CWD" +"$TOOLDIR/$filename" $@ diff --git a/tools/remote_build/README.md b/tools/remote_build/README.md index 4cc3c7a0ea1..2cd5f03daf1 100644 --- a/tools/remote_build/README.md +++ b/tools/remote_build/README.md @@ -17,27 +17,22 @@ and tests run by Kokoro CI. ## Running remote build manually from dev workstation -*At the time being, tools/bazel.sh is used instead of invoking "bazel" directly -to overcome the bazel versioning problem (our BUILD files currently only work with -a specific window of bazel version and bazel.sh wrapper makes sure that version -is used).* - Run from repository root (opt, dbg): ``` # manual run of bazel tests remotely on Foundry -tools/bazel.sh --bazelrc=tools/remote_build/manual.bazelrc test --config=opt //test/... +bazel --bazelrc=tools/remote_build/manual.bazelrc test --config=opt //test/... ``` Sanitizer runs (asan, msan, tsan, ubsan): ``` # manual run of bazel tests remotely on Foundry with given sanitizer -tools/bazel.sh --bazelrc=tools/remote_build/manual.bazelrc test --config=asan //test/... +bazel --bazelrc=tools/remote_build/manual.bazelrc test --config=asan //test/... ``` Run on Windows MSVC: ``` # RBE manual run only for c-core (must be run on a Windows host machine) -tools/bazel.sh --bazelrc=tools/remote_build/windows.bazelrc build :all [--credentials_json=(path to service account credentials)] +bazel --bazelrc=tools/remote_build/windows.bazelrc build :all [--credentials_json=(path to service account credentials)] ``` Available command line options can be found in From ed7e8c53e0a4b3a10b65919e059999e00c12a0bb Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 5 Jun 2019 14:21:51 -0400 Subject: [PATCH 0433/1555] update scripts --- templates/tools/dockerfile/bazel.include | 2 +- tools/dockerfile/test/bazel/Dockerfile | 2 +- tools/dockerfile/test/sanity/Dockerfile | 2 +- tools/internal_ci/linux/grpc_bazel_on_foundry_base.sh | 4 ++-- tools/internal_ci/windows/bazel_rbe.bat | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/tools/dockerfile/bazel.include b/templates/tools/dockerfile/bazel.include index 3744dacc281..b46845e218d 100644 --- a/templates/tools/dockerfile/bazel.include +++ b/templates/tools/dockerfile/bazel.include @@ -1,7 +1,7 @@ #======================== # Bazel installation -# Must be in sync with tools/bazel.sh +# Must be in sync with tools/bazel ENV BAZEL_VERSION 0.24.1 RUN apt-get update && apt-get install -y wget && apt-get clean diff --git a/tools/dockerfile/test/bazel/Dockerfile b/tools/dockerfile/test/bazel/Dockerfile index b9fc409d939..0e958542f9a 100644 --- a/tools/dockerfile/test/bazel/Dockerfile +++ b/tools/dockerfile/test/bazel/Dockerfile @@ -51,7 +51,7 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.2.post1 six==1.10.0 t #======================== # Bazel installation -# Must be in sync with tools/bazel.sh +# Must be in sync with tools/bazel ENV BAZEL_VERSION 0.24.1 RUN apt-get update && apt-get install -y wget && apt-get clean diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index 4ef4a0a9454..18aa89d8bf9 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -97,7 +97,7 @@ ENV CLANG_TIDY=clang-tidy #======================== # Bazel installation -# Must be in sync with tools/bazel.sh +# Must be in sync with tools/bazel ENV BAZEL_VERSION 0.24.1 RUN apt-get update && apt-get install -y wget && apt-get clean diff --git a/tools/internal_ci/linux/grpc_bazel_on_foundry_base.sh b/tools/internal_ci/linux/grpc_bazel_on_foundry_base.sh index bcde79ecd8e..5a358acc09d 100755 --- a/tools/internal_ci/linux/grpc_bazel_on_foundry_base.sh +++ b/tools/internal_ci/linux/grpc_bazel_on_foundry_base.sh @@ -21,7 +21,7 @@ cd $(dirname $0)/../../.. source tools/internal_ci/helper_scripts/prepare_build_linux_rc # make sure bazel is available -tools/bazel.sh version +tools/bazel version # to get "bazel" link for kokoro build, we need to generate # invocation UUID, set a flag for bazel to use it @@ -29,7 +29,7 @@ tools/bazel.sh version BAZEL_INVOCATION_ID="$(uuidgen)" echo "${BAZEL_INVOCATION_ID}" >"${KOKORO_ARTIFACTS_DIR}/bazel_invocation_ids" -tools/bazel.sh \ +tools/bazel \ --bazelrc=tools/remote_build/kokoro.bazelrc \ test \ --invocation_id="${BAZEL_INVOCATION_ID}" \ diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat index 30c66896edf..8abab687ed2 100644 --- a/tools/internal_ci/windows/bazel_rbe.bat +++ b/tools/internal_ci/windows/bazel_rbe.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem TODO(jtattermusch): make this generate less output -@rem TODO(jtattermusch): use tools/bazel.sh script to keep the versions in sync +@rem TODO(jtattermusch): use tools/bazel script to keep the versions in sync choco install bazel -y --version 0.24.1 --limit-output cd github/grpc From bc9d2f6b19b4a46b3829181e0beab19fc6cb355a Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 5 Jun 2019 12:54:56 -0700 Subject: [PATCH 0434/1555] clang-format --- src/objective-c/GRPCClient/GRPCCall.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 5a3440f84ed..e97ed6e3a9e 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -717,8 +717,8 @@ const char *kCFStreamVarName = "grpc_cfstream"; // it is ok to set nil because headers are only received once strongSelf.responseHeaders = nil; // copy the header so that the GRPCOpRecvMetadata object may be dealloc'ed - NSDictionary *copiedHeaders = [[NSDictionary alloc] initWithDictionary:headers - copyItems:YES]; + NSDictionary *copiedHeaders = + [[NSDictionary alloc] initWithDictionary:headers copyItems:YES]; strongSelf.responseHeaders = copiedHeaders; strongSelf->_pendingCoreRead = NO; [strongSelf maybeStartNextRead]; From 43fa11e4184814b9be5b3289bc36d3d2d321b132 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 15 Mar 2019 16:32:39 -0700 Subject: [PATCH 0435/1555] Unpin Cython from 0.28.3 --- requirements.bazel.txt | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.bazel.txt b/requirements.bazel.txt index e97843794e4..e2618c950f3 100644 --- a/requirements.bazel.txt +++ b/requirements.bazel.txt @@ -1,6 +1,6 @@ # GRPC Python setup requirements coverage>=4.0 -cython==0.28.3 +cython>=0.28.3 enum34>=1.0.4 protobuf>=3.5.0.post1 six>=1.10 diff --git a/requirements.txt b/requirements.txt index 6c978246214..f583fc94eb4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ # GRPC Python setup requirements coverage>=4.0 -cython==0.28.3 +cython>=0.28.3 enum34>=1.0.4 protobuf>=3.5.0.post1 six>=1.10 From f13727dfd110b7e1c95d24acf607d08ca44c4a35 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 5 Jun 2019 16:45:41 -0400 Subject: [PATCH 0436/1555] add option to disable bazel wrapper --- tools/bazel | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/bazel b/tools/bazel index 15c78dd0ffa..bacfeaddfd2 100755 --- a/tools/bazel +++ b/tools/bazel @@ -24,13 +24,20 @@ set -e +# First of all, if DISABLE_BAZEL_WRAPPER is set, just use BAZEL_REAL as set by +# https://github.com/bazelbuild/bazel/blob/master/scripts/packages/bazel.sh +# that originally invoked this script. +if [ "${BAZEL_REAL}" != "" ] && [ "${DISABLE_BAZEL_WRAPPER}" != "" ] +then + exec -a "$0" "${BAZEL_REAL}" "$@" +fi + VERSION=0.24.1 echo "INFO: Running bazel wrapper (see //tools/bazel for details), bazel version $VERSION will be used instead of system-wide bazel installation." -CWD=$(pwd) BASEURL=https://github.com/bazelbuild/bazel/releases/download/ -cd "$(dirname "$0")" +pushd "$(dirname "$0")" >/dev/null TOOLDIR=$(pwd) case $(uname -sm) in @@ -53,5 +60,5 @@ if [ ! -x "$filename" ] ; then chmod a+x "$filename" fi -cd "$CWD" -"$TOOLDIR/$filename" $@ +popd >/dev/null +exec "$TOOLDIR/$filename" "$@" From e66fb82495da076607eb27cc940714748d870762 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 5 Jun 2019 16:53:12 -0400 Subject: [PATCH 0437/1555] disable bazel wrapper inside docker containers --- templates/tools/dockerfile/bazel.include | 3 +++ tools/dockerfile/test/bazel/Dockerfile | 3 +++ tools/dockerfile/test/sanity/Dockerfile | 3 +++ 3 files changed, 9 insertions(+) diff --git a/templates/tools/dockerfile/bazel.include b/templates/tools/dockerfile/bazel.include index b46845e218d..272936007da 100644 --- a/templates/tools/dockerfile/bazel.include +++ b/templates/tools/dockerfile/bazel.include @@ -4,6 +4,9 @@ # Must be in sync with tools/bazel ENV BAZEL_VERSION 0.24.1 +# The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. +ENV DISABLE_BAZEL_WRAPPER 1 + RUN apt-get update && apt-get install -y wget && apt-get clean RUN wget "https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh" && ${'\\'} bash ./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && ${'\\'} diff --git a/tools/dockerfile/test/bazel/Dockerfile b/tools/dockerfile/test/bazel/Dockerfile index 0e958542f9a..df7a7a2f32a 100644 --- a/tools/dockerfile/test/bazel/Dockerfile +++ b/tools/dockerfile/test/bazel/Dockerfile @@ -54,6 +54,9 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.2.post1 six==1.10.0 t # Must be in sync with tools/bazel ENV BAZEL_VERSION 0.24.1 +# The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. +ENV DISABLE_BAZEL_WRAPPER 1 + RUN apt-get update && apt-get install -y wget && apt-get clean RUN wget "https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh" && \ bash ./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \ diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index 18aa89d8bf9..9a080d0efb2 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -100,6 +100,9 @@ ENV CLANG_TIDY=clang-tidy # Must be in sync with tools/bazel ENV BAZEL_VERSION 0.24.1 +# The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. +ENV DISABLE_BAZEL_WRAPPER 1 + RUN apt-get update && apt-get install -y wget && apt-get clean RUN wget "https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh" && \ bash ./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \ From b6c89f36cbc2e8effd20d6c22187e226ea984705 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Wed, 5 Jun 2019 14:14:08 -0700 Subject: [PATCH 0438/1555] Change locality name to a class --- .../client_channel/lb_policy/xds/xds.cc | 62 +++++++++++++++---- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index b198e0e8637..041c1e46231 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -117,7 +117,9 @@ TraceFlag grpc_lb_xds_trace(false, "xds"); namespace { constexpr char kXds[] = "xds_experimental"; -constexpr char kDefaultLocalityName[] = "xds_default_locality"; +constexpr char kDefaultLocalityRegion[] = "xds_default_locality_region"; +constexpr char kDefaultLocalityZone[] = "xds_default_locality_zone"; +constexpr char kDefaultLocalitySubzone[] = "xds_default_locality_subzone"; constexpr uint32_t kDefaultLocalityWeight = 3; class ParsedXdsConfig : public LoadBalancingPolicy::Config { @@ -352,6 +354,37 @@ class XdsLb : public LoadBalancingPolicy { LoadBalancingPolicy* child_ = nullptr; }; + class LocalityName : public RefCounted { + public: + struct Less { + bool operator()(const RefCountedPtr& lhs, + const RefCountedPtr& rhs) { + int cmp_result = strcmp(lhs->region_.get(), rhs->region_.get()); + if (cmp_result != 0) return cmp_result < 0; + cmp_result = strcmp(lhs->zone_.get(), rhs->zone_.get()); + if (cmp_result != 0) return cmp_result < 0; + return strcmp(lhs->subzone_.get(), rhs->subzone_.get()) < 0; + } + }; + + LocalityName(UniquePtr region, UniquePtr zone, + UniquePtr subzone) + : region_(std::move(region)), + zone_(std::move(zone)), + subzone_(std::move(subzone)) {} + + bool operator==(const LocalityName& other) const { + return strcmp(region_.get(), other.region_.get()) == 0 && + strcmp(zone_.get(), other.zone_.get()) == 0 && + strcmp(subzone_.get(), other.subzone_.get()) == 0; + } + + private: + UniquePtr region_; + UniquePtr zone_; + UniquePtr subzone_; + }; + class LocalityMap { public: class LocalityEntry : public InternallyRefCounted { @@ -418,19 +451,18 @@ class XdsLb : public LoadBalancingPolicy { private: void PruneLocalities(const LocalityList& locality_list); - Map, OrphanablePtr, StringLess> map_; + Map, OrphanablePtr, + LocalityName::Less> + map_; // Lock held while filling child refs for all localities // inside the map Mutex child_refs_mu_; }; struct LocalityServerlistEntry { - ~LocalityServerlistEntry() { - gpr_free(locality_name); - xds_grpclb_destroy_serverlist(serverlist); - } + ~LocalityServerlistEntry() { xds_grpclb_destroy_serverlist(serverlist); } - char* locality_name; + RefCountedPtr locality_name; uint32_t locality_weight; // The deserialized response from the balancer. May be nullptr until one // such response has arrived. @@ -1199,7 +1231,10 @@ void XdsLb::BalancerChannelState::BalancerCallState:: xdslb_policy->locality_serverlist_.emplace_back( MakeUnique()); xdslb_policy->locality_serverlist_[0]->locality_name = - static_cast(gpr_strdup(kDefaultLocalityName)); + MakeRefCounted( + UniquePtr(gpr_strdup(kDefaultLocalityRegion)), + UniquePtr(gpr_strdup(kDefaultLocalityZone)), + UniquePtr(gpr_strdup(kDefaultLocalitySubzone))); xdslb_policy->locality_serverlist_[0]->locality_weight = kDefaultLocalityWeight; } @@ -1728,8 +1763,9 @@ void XdsLb::LocalityMap::PruneLocalities(const LocalityList& locality_list) { for (auto iter = map_.begin(); iter != map_.end();) { bool found = false; for (size_t i = 0; i < locality_list.size(); i++) { - if (!gpr_stricmp(locality_list[i]->locality_name, iter->first.get())) { + if (*locality_list[i]->locality_name == *iter->first) { found = true; + break; } } if (!found) { // Remove entries not present in the locality list @@ -1746,14 +1782,14 @@ void XdsLb::LocalityMap::UpdateLocked( const grpc_channel_args* args, XdsLb* parent) { if (parent->shutting_down_) return; for (size_t i = 0; i < locality_serverlist.size(); i++) { - UniquePtr locality_name( - gpr_strdup(locality_serverlist[i]->locality_name)); - auto iter = map_.find(locality_name); + auto iter = map_.find(locality_serverlist[i]->locality_name); if (iter == map_.end()) { OrphanablePtr new_entry = MakeOrphanable( parent->Ref(), locality_serverlist[i]->locality_weight); MutexLock lock(&child_refs_mu_); - iter = map_.emplace(std::move(locality_name), std::move(new_entry)).first; + iter = map_.emplace(locality_serverlist[i]->locality_name, + std::move(new_entry)) + .first; } // Don't create new child policies if not directed to xds_grpclb_serverlist* serverlist = From e360dd4f76a9e04c1df5e695ec4804b1884dc05b Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Wed, 5 Jun 2019 23:54:59 +0200 Subject: [PATCH 0439/1555] Upgrading to bazel 0.26. --- bazel/grpc_deps.bzl | 12 ++++++------ tools/bazel.sh | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index db24c7645b0..4182a7157a0 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -178,9 +178,9 @@ def grpc_deps(): if "com_google_absl" not in native.existing_rules(): http_archive( name = "com_google_absl", - sha256 = "5fe2a3a8f8378e81d4d3db6541f48030e04233ccd2d6c7e9d981ed577b314ae8", - strip_prefix = "abseil-cpp-308ce31528a7edfa39f5f6d36142278a0ae1bf45", - url = "https://github.com/abseil/abseil-cpp/archive/308ce31528a7edfa39f5f6d36142278a0ae1bf45.tar.gz", + sha256 = "7ddf863ddced6fa5bf7304103f9c7aa619c20a2fcf84475512c8d3834b9d14fa", + strip_prefix = "abseil-cpp-61c9bf3e3e1c28a4aa6d7f1be4b37fd473bb5529", + url = "https://github.com/abseil/abseil-cpp/archive/61c9bf3e3e1c28a4aa6d7f1be4b37fd473bb5529.tar.gz", ) if "bazel_toolchains" not in native.existing_rules(): @@ -205,9 +205,9 @@ def grpc_deps(): if "io_opencensus_cpp" not in native.existing_rules(): http_archive( name = "io_opencensus_cpp", - sha256 = "3436ca23dc1b3345186defd0f46d64244079ba3d3234a0c5d6ef5e8d5d06c8b5", - strip_prefix = "opencensus-cpp-9b1e354e89bf3d92aedc00af45b418ce870f3d77", - url = "https://github.com/census-instrumentation/opencensus-cpp/archive/9b1e354e89bf3d92aedc00af45b418ce870f3d77.tar.gz", + sha256 = "90d6fafa8b1a2ea613bf662731d3086e1c2ed286f458a95c81744df2dbae41b1", + strip_prefix = "opencensus-cpp-c9a4da319bc669a772928ffc55af4a61be1a1176", + url = "https://github.com/census-instrumentation/opencensus-cpp/archive/c9a4da319bc669a772928ffc55af4a61be1a1176.tar.gz", ) if "upb" not in native.existing_rules(): diff --git a/tools/bazel.sh b/tools/bazel.sh index 37fd2a242bf..b0508bddbd9 100755 --- a/tools/bazel.sh +++ b/tools/bazel.sh @@ -22,7 +22,7 @@ set -e -VERSION=0.24.1 +VERSION=0.26.0 CWD=`pwd` BASEURL=https://github.com/bazelbuild/bazel/releases/download/ From f04aabc0f36e0446b9f5efb89b6d8396c83b17ab Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Wed, 5 Jun 2019 15:06:44 -0700 Subject: [PATCH 0440/1555] PHP: update generated code tests --- examples/node/dynamic_codegen/math_server.js | 127 ++++++++++++++++++ src/php/README.md | 4 +- .../AbstractGeneratedCodeTest.php | 2 + 3 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 examples/node/dynamic_codegen/math_server.js diff --git a/examples/node/dynamic_codegen/math_server.js b/examples/node/dynamic_codegen/math_server.js new file mode 100644 index 00000000000..d4eb310fc88 --- /dev/null +++ b/examples/node/dynamic_codegen/math_server.js @@ -0,0 +1,127 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +var PROTO_PATH = __dirname + '/../../../src/proto/math/math.proto'; + +var grpc = require('grpc'); +var protoLoader = require('@grpc/proto-loader'); +var packageDefinition = protoLoader.loadSync( + PROTO_PATH, + {keepCase: true, + longs: String, + enums: String, + defaults: true, + oneofs: true + }); +var math_proto = grpc.loadPackageDefinition(packageDefinition).math; + +/** + * Implements the Div RPC method. + */ +function Div(call, callback) { + var divisor = call.request.divisor; + var dividend = call.request.dividend; + if (divisor == 0) { + callback({ + code: grpc.status.INVALID_ARGUMENT, + details: 'Cannot divide by zero' + }); + } else { + setTimeout(function () { + callback(null, { + quotient: Math.floor(dividend / divisor), + remainder: dividend % divisor + }); + }, 1); // 1 millisecond, to make sure 1 microsecond timeout from test + // will hit. TODO: Consider fixing this. + } +} + +/** + * Implements the Fib RPC method. + */ +function Fib(stream) { + var previous = 0, current = 1; + for (var i = 0; i < stream.request.limit; i++) { + stream.write({ + num: current + }); + var temp = current; + current += previous; + previous = temp; + } + stream.end(); +} + +/** + * Implements the Sum RPC method. + */ +function Sum(call, callback) { + var sum = 0; + call.on('data', function(data) { + sum += parseInt(data.num); + }); + call.on('end', function() { + callback(null, { + num: sum + }); + }); +} + +/** + * Implements the DivMany RPC method. + */ +function DivMany(stream) { + stream.on('data', function(div_args) { + var divisor = div_args.divisor; + var dividend = div_args.dividend; + if (divisor == 0) { + stream.emit('error', { + code: grpc.status.INVALID_ARGUMENT, + details: 'Cannot divide by zero' + }); + } else { + stream.write({ + quotient: Math.floor(dividend / divisor), + remainder: dividend % divisor + }); + } + }); + stream.on('end', function() { + stream.end(); + }); +} + + +/** + * Starts an RPC server that receives requests for the Math service at the + * sample server port + */ +function main() { + var server = new grpc.Server(); + server.addService(math_proto.Math.service, { + Div: Div, + Fib: Fib, + Sum: Sum, + DivMany: DivMany, + }); + server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure()); + server.start(); +} + +main(); diff --git a/src/php/README.md b/src/php/README.md index 5e9fa387636..69f4bbf42c2 100644 --- a/src/php/README.md +++ b/src/php/README.md @@ -294,9 +294,9 @@ Run a local server serving the math services. Please see [Node][] for how to run an example server. ```sh -$ cd grpc +$ cd grpc/examples/node $ npm install -$ node src/node/test/math/math_server.js +$ node dynamic_codegen/math_server.js ``` ### Run test client diff --git a/src/php/tests/generated_code/AbstractGeneratedCodeTest.php b/src/php/tests/generated_code/AbstractGeneratedCodeTest.php index c050a26cbf5..8b655a7d83f 100644 --- a/src/php/tests/generated_code/AbstractGeneratedCodeTest.php +++ b/src/php/tests/generated_code/AbstractGeneratedCodeTest.php @@ -81,6 +81,8 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase public function testTimeout() { $div_arg = new Math\DivArgs(); + $div_arg->setDividend(7); + $div_arg->setDivisor(4); $call = self::$client->Div($div_arg, [], ['timeout' => 1]); list($response, $status) = $call->wait(); $this->assertSame(\Grpc\STATUS_DEADLINE_EXCEEDED, $status->code); From 1a3dd36c891acc419af0ef24b85498c28fc50ae7 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Wed, 5 Jun 2019 23:54:59 +0200 Subject: [PATCH 0441/1555] Upgrading to bazel 0.26. --- bazel/grpc_deps.bzl | 12 ++++++------ tools/bazel.sh | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 8cc2354ed78..dc7294de5cd 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -178,9 +178,9 @@ def grpc_deps(): if "com_google_absl" not in native.existing_rules(): http_archive( name = "com_google_absl", - sha256 = "5fe2a3a8f8378e81d4d3db6541f48030e04233ccd2d6c7e9d981ed577b314ae8", - strip_prefix = "abseil-cpp-308ce31528a7edfa39f5f6d36142278a0ae1bf45", - url = "https://github.com/abseil/abseil-cpp/archive/308ce31528a7edfa39f5f6d36142278a0ae1bf45.tar.gz", + sha256 = "7ddf863ddced6fa5bf7304103f9c7aa619c20a2fcf84475512c8d3834b9d14fa", + strip_prefix = "abseil-cpp-61c9bf3e3e1c28a4aa6d7f1be4b37fd473bb5529", + url = "https://github.com/abseil/abseil-cpp/archive/61c9bf3e3e1c28a4aa6d7f1be4b37fd473bb5529.tar.gz", ) if "bazel_toolchains" not in native.existing_rules(): @@ -205,9 +205,9 @@ def grpc_deps(): if "io_opencensus_cpp" not in native.existing_rules(): http_archive( name = "io_opencensus_cpp", - sha256 = "3436ca23dc1b3345186defd0f46d64244079ba3d3234a0c5d6ef5e8d5d06c8b5", - strip_prefix = "opencensus-cpp-9b1e354e89bf3d92aedc00af45b418ce870f3d77", - url = "https://github.com/census-instrumentation/opencensus-cpp/archive/9b1e354e89bf3d92aedc00af45b418ce870f3d77.tar.gz", + sha256 = "90d6fafa8b1a2ea613bf662731d3086e1c2ed286f458a95c81744df2dbae41b1", + strip_prefix = "opencensus-cpp-c9a4da319bc669a772928ffc55af4a61be1a1176", + url = "https://github.com/census-instrumentation/opencensus-cpp/archive/c9a4da319bc669a772928ffc55af4a61be1a1176.tar.gz", ) if "upb" not in native.existing_rules(): http_archive( diff --git a/tools/bazel.sh b/tools/bazel.sh index 37fd2a242bf..b0508bddbd9 100755 --- a/tools/bazel.sh +++ b/tools/bazel.sh @@ -22,7 +22,7 @@ set -e -VERSION=0.24.1 +VERSION=0.26.0 CWD=`pwd` BASEURL=https://github.com/bazelbuild/bazel/releases/download/ From 975ee2185fdb0981fa20f82614b23b6416f02d2f Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Thu, 6 Jun 2019 00:32:34 +0200 Subject: [PATCH 0442/1555] Fixing exports. --- BUILD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index 32cc58b5b31..214c5ddf078 100644 --- a/BUILD +++ b/BUILD @@ -2367,12 +2367,12 @@ grpc_cc_library( upb_proto_library( name = "upb_load_report", - deps = ["@data_plane_api//envoy/api/v2/endpoint:load_report"] + deps = ["@data_plane_api//envoy/api/v2/endpoint:load_report_export"] ) upb_proto_library( name = "upb_lrs", - deps = ["@data_plane_api//envoy/service/load_stats/v2:lrs"] + deps = ["@data_plane_api//envoy/service/load_stats/v2:lrs_export"] ) #TODO: Get this into build.yaml once we start using it. From e62d439d71c81252577419d9478dff65e6e795ae Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 5 Jun 2019 15:44:47 -0700 Subject: [PATCH 0443/1555] Avoid regex inefficiencies in no-match scenarios --- src/csharp/Grpc.Tools/ProtoCompile.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/csharp/Grpc.Tools/ProtoCompile.cs b/src/csharp/Grpc.Tools/ProtoCompile.cs index 40cfbeb029b..b6fd94209d2 100644 --- a/src/csharp/Grpc.Tools/ProtoCompile.cs +++ b/src/csharp/Grpc.Tools/ProtoCompile.cs @@ -136,7 +136,7 @@ namespace Grpc.Tools new ErrorListFilter { Pattern = new Regex( - pattern: "(?'FILENAME'.+)\\((?'LINE'\\d+)\\) ?: ?warning in column=(?'COLUMN'\\d+) ?: ?(?'TEXT'.*)", + pattern: "(?'FILENAME'[^\\(]+)\\((?'LINE'\\d+)\\) ?: ?warning in column=(?'COLUMN'\\d+) ?: ?(?'TEXT'.*)", options: RegexOptions.Compiled | RegexOptions.IgnoreCase, matchTimeout: s_regexTimeout), LogAction = (log, match) => @@ -162,7 +162,7 @@ namespace Grpc.Tools new ErrorListFilter { Pattern = new Regex( - pattern: "(?'FILENAME'.+)\\((?'LINE'\\d+)\\) ?: ?error in column=(?'COLUMN'\\d+) ?: ?(?'TEXT'.*)", + pattern: "(?'FILENAME'[^\\(]+)\\((?'LINE'\\d+)\\) ?: ?error in column=(?'COLUMN'\\d+) ?: ?(?'TEXT'.*)", options: RegexOptions.Compiled | RegexOptions.IgnoreCase, matchTimeout: s_regexTimeout), LogAction = (log, match) => @@ -185,10 +185,10 @@ namespace Grpc.Tools // Example warning without location //../Protos/greet.proto: warning: Import google/protobuf/empty.proto but not used. - new ErrorListFilter + new ErrorListFilter { Pattern = new Regex( - pattern: "(?'FILENAME'.+): ?warning: ?(?'TEXT'.*)", + pattern: "(?'FILENAME'[^:]+): ?warning: ?(?'TEXT'.*)", options: RegexOptions.Compiled | RegexOptions.IgnoreCase, matchTimeout: s_regexTimeout), LogAction = (log, match) => @@ -211,7 +211,7 @@ namespace Grpc.Tools new ErrorListFilter { Pattern = new Regex( - pattern: "(?'FILENAME'.+): ?(?'TEXT'.*)", + pattern: "(?'FILENAME'[^:]+): ?(?'TEXT'.*)", options: RegexOptions.Compiled | RegexOptions.IgnoreCase, matchTimeout: s_regexTimeout), LogAction = (log, match) => @@ -518,7 +518,7 @@ namespace Grpc.Tools foreach (ErrorListFilter filter in s_errorListFilters) { Match match = filter.Pattern.Match(singleLine); - + if (match.Success) { filter.LogAction(Log, match); From a517c375fed5113eaf461c0f7891130b45502a0e Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 5 Jun 2019 15:56:37 -0700 Subject: [PATCH 0444/1555] Use port server for interop tests --- src/objective-c/tests/run_one_test.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/objective-c/tests/run_one_test.sh b/src/objective-c/tests/run_one_test.sh index af8a5b6351e..04cba0e321a 100644 --- a/src/objective-c/tests/run_one_test.sh +++ b/src/objective-c/tests/run_one_test.sh @@ -27,8 +27,17 @@ BINDIR=../../../bins/$CONFIG "interop_server before calling this script." exit 1 } -$BINDIR/interop_server --port=5050 --max_send_message_size=8388608 & -$BINDIR/interop_server --port=5051 --max_send_message_size=8388608 --use_tls & + +[ -z "$(ps aux |egrep 'port_server\.py.*-p\s32766')" ] && { + echo >&2 "Can't find the port server. Start port server with tools/run_tests/start_port_server.py." + exit 1 +} + +PLAIN_PORT=$(curl localhost:32766/get) +TLS_PORT=$(curl localhost:32766/get) + +$BINDIR/interop_server --port=$PLAIN_PORT --max_send_message_size=8388608 & +$BINDIR/interop_server --port=$TLS_PORT --max_send_message_size=8388608 --use_tls & trap 'kill -9 `jobs -p` ; echo "EXIT TIME: $(date)"' EXIT @@ -40,8 +49,8 @@ xcodebuild \ -workspace Tests.xcworkspace \ -scheme SCHEME \ -destination name="iPhone 8" \ - HOST_PORT_LOCALSSL=localhost:5051 \ - HOST_PORT_LOCAL=localhost:5050 \ + HOST_PORT_LOCALSSL=localhost:$TLS_PORT \ + HOST_PORT_LOCAL=localhost:$PLAIN_PORT \ HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ test \ | egrep -v "$XCODEBUILD_FILTER" \ From f2dc650f8b624de20372bb2c4abfc5d191e8fc72 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 5 Jun 2019 16:27:09 -0700 Subject: [PATCH 0445/1555] Do not reset outgoing buffer on failsafe path --- src/core/lib/iomgr/tcp_posix.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index cda7bba0d3a..889272f6299 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -685,7 +685,6 @@ static bool tcp_write_with_timestamps(grpc_tcp* tcp, struct msghdr* msg, uint32_t opt = grpc_core::kTimestampingSocketOptions; if (setsockopt(tcp->fd, SOL_SOCKET, SO_TIMESTAMPING, static_cast(&opt), sizeof(opt)) != 0) { - grpc_slice_buffer_reset_and_unref_internal(tcp->outgoing_buffer); if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { gpr_log(GPR_ERROR, "Failed to set timestamping options on the socket."); } From 522ddfe273b69207ec49a512b8275b560e378812 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 5 Jun 2019 16:31:39 -0700 Subject: [PATCH 0446/1555] Move ClientContext to grpc_impl ClientContext is another file which needs to be moved from grpc to grpc_impl for referencing it. --- BUILD | 1 + BUILD.gn | 1 + CMakeLists.txt | 5 + Makefile | 5 + build.yaml | 1 + gRPC-C++.podspec | 1 + include/grpcpp/channel_impl.h | 4 +- .../grpcpp/impl/codegen/channel_interface.h | 6 +- include/grpcpp/impl/codegen/client_callback.h | 3 +- include/grpcpp/impl/codegen/client_context.h | 469 +---------------- .../grpcpp/impl/codegen/client_context_impl.h | 492 ++++++++++++++++++ .../grpcpp/impl/codegen/client_interceptor.h | 11 +- .../grpcpp/impl/codegen/client_unary_call.h | 8 +- .../impl/codegen/completion_queue_impl.h | 1 - include/grpcpp/impl/codegen/server_context.h | 4 +- src/cpp/client/client_context.cc | 11 +- test/cpp/util/cli_call.h | 6 +- tools/doxygen/Doxyfile.c++ | 1 + tools/doxygen/Doxyfile.c++.internal | 1 + .../generated/sources_and_headers.json | 2 + 20 files changed, 539 insertions(+), 494 deletions(-) create mode 100644 include/grpcpp/impl/codegen/client_context_impl.h diff --git a/BUILD b/BUILD index e0827d46cb1..4247d491fc5 100644 --- a/BUILD +++ b/BUILD @@ -2164,6 +2164,7 @@ grpc_cc_library( "include/grpcpp/impl/codegen/channel_interface.h", "include/grpcpp/impl/codegen/client_callback.h", "include/grpcpp/impl/codegen/client_context.h", + "include/grpcpp/impl/codegen/client_context_impl.h", "include/grpcpp/impl/codegen/client_interceptor.h", "include/grpcpp/impl/codegen/client_unary_call.h", "include/grpcpp/impl/codegen/completion_queue.h", diff --git a/BUILD.gn b/BUILD.gn index 258cdc9f873..3041adef98a 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1054,6 +1054,7 @@ config("grpc_config") { "include/grpcpp/impl/codegen/channel_interface.h", "include/grpcpp/impl/codegen/client_callback.h", "include/grpcpp/impl/codegen/client_context.h", + "include/grpcpp/impl/codegen/client_context_impl.h", "include/grpcpp/impl/codegen/client_interceptor.h", "include/grpcpp/impl/codegen/client_unary_call.h", "include/grpcpp/impl/codegen/completion_queue.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index e9d2168b8de..1d3ba81ac3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3313,6 +3313,7 @@ foreach(_hdr include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/client_callback.h include/grpcpp/impl/codegen/client_context.h + include/grpcpp/impl/codegen/client_context_impl.h include/grpcpp/impl/codegen/client_interceptor.h include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/completion_queue.h @@ -3932,6 +3933,7 @@ foreach(_hdr include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/client_callback.h include/grpcpp/impl/codegen/client_context.h + include/grpcpp/impl/codegen/client_context_impl.h include/grpcpp/impl/codegen/client_interceptor.h include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/completion_queue.h @@ -4367,6 +4369,7 @@ foreach(_hdr include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/client_callback.h include/grpcpp/impl/codegen/client_context.h + include/grpcpp/impl/codegen/client_context_impl.h include/grpcpp/impl/codegen/client_interceptor.h include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/completion_queue.h @@ -4566,6 +4569,7 @@ foreach(_hdr include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/client_callback.h include/grpcpp/impl/codegen/client_context.h + include/grpcpp/impl/codegen/client_context_impl.h include/grpcpp/impl/codegen/client_interceptor.h include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/completion_queue.h @@ -4925,6 +4929,7 @@ foreach(_hdr include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/client_callback.h include/grpcpp/impl/codegen/client_context.h + include/grpcpp/impl/codegen/client_context_impl.h include/grpcpp/impl/codegen/client_interceptor.h include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/completion_queue.h diff --git a/Makefile b/Makefile index e56c5ec4e47..44e18c1f474 100644 --- a/Makefile +++ b/Makefile @@ -5670,6 +5670,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ include/grpcpp/impl/codegen/client_context.h \ + include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ @@ -6297,6 +6298,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ include/grpcpp/impl/codegen/client_context.h \ + include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ @@ -6704,6 +6706,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ include/grpcpp/impl/codegen/client_context.h \ + include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ @@ -6874,6 +6877,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ include/grpcpp/impl/codegen/client_context.h \ + include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ @@ -7239,6 +7243,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ include/grpcpp/impl/codegen/client_context.h \ + include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ diff --git a/build.yaml b/build.yaml index 5c085f18787..580cda1baab 100644 --- a/build.yaml +++ b/build.yaml @@ -1260,6 +1260,7 @@ filegroups: - include/grpcpp/impl/codegen/channel_interface.h - include/grpcpp/impl/codegen/client_callback.h - include/grpcpp/impl/codegen/client_context.h + - include/grpcpp/impl/codegen/client_context_impl.h - include/grpcpp/impl/codegen/client_interceptor.h - include/grpcpp/impl/codegen/client_unary_call.h - include/grpcpp/impl/codegen/completion_queue.h diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 3b463cf7b90..861f757bb7f 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -161,6 +161,7 @@ Pod::Spec.new do |s| 'include/grpcpp/impl/codegen/channel_interface.h', 'include/grpcpp/impl/codegen/client_callback.h', 'include/grpcpp/impl/codegen/client_context.h', + 'include/grpcpp/impl/codegen/client_context_impl.h', 'include/grpcpp/impl/codegen/client_interceptor.h', 'include/grpcpp/impl/codegen/client_unary_call.h', 'include/grpcpp/impl/codegen/completion_queue.h', diff --git a/include/grpcpp/channel_impl.h b/include/grpcpp/channel_impl.h index 39917d2eb74..3ead8ee090e 100644 --- a/include/grpcpp/channel_impl.h +++ b/include/grpcpp/channel_impl.h @@ -85,7 +85,7 @@ class Channel final : public ::grpc::ChannelInterface, interceptor_creators); ::grpc::internal::Call CreateCall(const ::grpc::internal::RpcMethod& method, - ::grpc::ClientContext* context, + ::grpc_impl::ClientContext* context, ::grpc::CompletionQueue* cq) override; void PerformOpsOnCall(::grpc::internal::CallOpSetInterface* ops, ::grpc::internal::Call* call) override; @@ -100,7 +100,7 @@ class Channel final : public ::grpc::ChannelInterface, ::grpc::CompletionQueue* CallbackCQ() override; ::grpc::internal::Call CreateCallInternal( - const ::grpc::internal::RpcMethod& method, ::grpc::ClientContext* context, + const ::grpc::internal::RpcMethod& method, ::grpc_impl::ClientContext* context, ::grpc::CompletionQueue* cq, size_t interceptor_pos) override; const grpc::string host_; diff --git a/include/grpcpp/impl/codegen/channel_interface.h b/include/grpcpp/impl/codegen/channel_interface.h index 9df233b5500..9d0f07f3ff0 100644 --- a/include/grpcpp/impl/codegen/channel_interface.h +++ b/include/grpcpp/impl/codegen/channel_interface.h @@ -25,12 +25,12 @@ #include namespace grpc_impl { +class ClientContext; class CompletionQueue; } namespace grpc { class ChannelInterface; -class ClientContext; template class ClientReader; @@ -129,7 +129,7 @@ class ChannelInterface { friend class ::grpc::internal::RpcMethod; friend class ::grpc::internal::InterceptedChannel; virtual internal::Call CreateCall(const internal::RpcMethod& method, - ClientContext* context, + ::grpc_impl::ClientContext* context, ::grpc_impl::CompletionQueue* cq) = 0; virtual void PerformOpsOnCall(internal::CallOpSetInterface* ops, internal::Call* call) = 0; @@ -149,7 +149,7 @@ class ChannelInterface { // method and adding a new pure method to an interface would be a breaking // change (even though this is private and non-API) virtual internal::Call CreateCallInternal(const internal::RpcMethod& method, - ClientContext* context, + ::grpc_impl::ClientContext* context, ::grpc_impl::CompletionQueue* cq, size_t interceptor_pos) { return internal::Call(); diff --git a/include/grpcpp/impl/codegen/client_callback.h b/include/grpcpp/impl/codegen/client_callback.h index dda9aec29f3..bd438879543 100644 --- a/include/grpcpp/impl/codegen/client_callback.h +++ b/include/grpcpp/impl/codegen/client_callback.h @@ -31,12 +31,11 @@ namespace grpc_impl { class Channel; +class ClientContext; } namespace grpc { -class ClientContext; - namespace internal { class RpcMethod; diff --git a/include/grpcpp/impl/codegen/client_context.h b/include/grpcpp/impl/codegen/client_context.h index 999d8fcbfe7..8c3b669f2b7 100644 --- a/include/grpcpp/impl/codegen/client_context.h +++ b/include/grpcpp/impl/codegen/client_context.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015 gRPC authors. + * Copyright 2019 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,477 +16,14 @@ * */ -/// A ClientContext allows the person implementing a service client to: -/// -/// - Add custom metadata key-value pairs that will propagated to the server -/// side. -/// - Control call settings such as compression and authentication. -/// - Initial and trailing metadata coming from the server. -/// - Get performance metrics (ie, census). -/// -/// Context settings are only relevant to the call they are invoked with, that -/// is to say, they aren't sticky. Some of these settings, such as the -/// compression options, can be made persistent at channel construction time -/// (see \a grpc::CreateCustomChannel). -/// -/// \warning ClientContext instances should \em not be reused across rpcs. - #ifndef GRPCPP_IMPL_CODEGEN_CLIENT_CONTEXT_H #define GRPCPP_IMPL_CODEGEN_CLIENT_CONTEXT_H -#include -#include -#include -#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct census_context; -struct grpc_call; - -namespace grpc_impl { - -class CallCredentials; -class Channel; -class CompletionQueue; -} // namespace grpc_impl namespace grpc { -class ChannelInterface; -class ClientContext; - -namespace internal { -class RpcMethod; -class CallOpClientRecvStatus; -class CallOpRecvInitialMetadata; -template -class BlockingUnaryCallImpl; -template -class CallbackUnaryCallImpl; -template -class ClientCallbackReaderWriterImpl; -template -class ClientCallbackReaderImpl; -template -class ClientCallbackWriterImpl; -class ClientCallbackUnaryImpl; -} // namespace internal - -template -class ClientReader; -template -class ClientWriter; -template -class ClientReaderWriter; -template -class ClientAsyncReader; -template -class ClientAsyncWriter; -template -class ClientAsyncReaderWriter; -template -class ClientAsyncResponseReader; -class ServerContext; - -/// Options for \a ClientContext::FromServerContext specifying which traits from -/// the \a ServerContext to propagate (copy) from it into a new \a -/// ClientContext. -/// -/// \see ClientContext::FromServerContext -class PropagationOptions { - public: - PropagationOptions() : propagate_(GRPC_PROPAGATE_DEFAULTS) {} - - PropagationOptions& enable_deadline_propagation() { - propagate_ |= GRPC_PROPAGATE_DEADLINE; - return *this; - } - - PropagationOptions& disable_deadline_propagation() { - propagate_ &= ~GRPC_PROPAGATE_DEADLINE; - return *this; - } - - PropagationOptions& enable_census_stats_propagation() { - propagate_ |= GRPC_PROPAGATE_CENSUS_STATS_CONTEXT; - return *this; - } - - PropagationOptions& disable_census_stats_propagation() { - propagate_ &= ~GRPC_PROPAGATE_CENSUS_STATS_CONTEXT; - return *this; - } - - PropagationOptions& enable_census_tracing_propagation() { - propagate_ |= GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT; - return *this; - } - - PropagationOptions& disable_census_tracing_propagation() { - propagate_ &= ~GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT; - return *this; - } - - PropagationOptions& enable_cancellation_propagation() { - propagate_ |= GRPC_PROPAGATE_CANCELLATION; - return *this; - } - - PropagationOptions& disable_cancellation_propagation() { - propagate_ &= ~GRPC_PROPAGATE_CANCELLATION; - return *this; - } - - uint32_t c_bitmask() const { return propagate_; } - - private: - uint32_t propagate_; -}; - -namespace testing { -class InteropClientContextInspector; -} // namespace testing - -/// A ClientContext allows the person implementing a service client to: -/// -/// - Add custom metadata key-value pairs that will propagated to the server -/// side. -/// - Control call settings such as compression and authentication. -/// - Initial and trailing metadata coming from the server. -/// - Get performance metrics (ie, census). -/// -/// Context settings are only relevant to the call they are invoked with, that -/// is to say, they aren't sticky. Some of these settings, such as the -/// compression options, can be made persistent at channel construction time -/// (see \a grpc::CreateCustomChannel). -/// -/// \warning ClientContext instances should \em not be reused across rpcs. -/// \warning The ClientContext instance used for creating an rpc must remain -/// alive and valid for the lifetime of the rpc. -class ClientContext { - public: - ClientContext(); - ~ClientContext(); - - /// Create a new \a ClientContext as a child of an incoming server call, - /// according to \a options (\see PropagationOptions). - /// - /// \param server_context The source server context to use as the basis for - /// constructing the client context. - /// \param options The options controlling what to copy from the \a - /// server_context. - /// - /// \return A newly constructed \a ClientContext instance based on \a - /// server_context, with traits propagated (copied) according to \a options. - static std::unique_ptr FromServerContext( - const ServerContext& server_context, - PropagationOptions options = PropagationOptions()); - - /// Add the (\a meta_key, \a meta_value) pair to the metadata associated with - /// a client call. These are made available at the server side by the \a - /// grpc::ServerContext::client_metadata() method. - /// - /// \warning This method should only be called before invoking the rpc. - /// - /// \param meta_key The metadata key. If \a meta_value is binary data, it must - /// end in "-bin". - /// \param meta_value The metadata value. If its value is binary, the key name - /// must end in "-bin". - /// - /// Metadata must conform to the following format: - /// Custom-Metadata -> Binary-Header / ASCII-Header - /// Binary-Header -> {Header-Name "-bin" } {binary value} - /// ASCII-Header -> Header-Name ASCII-Value - /// Header-Name -> 1*( %x30-39 / %x61-7A / "_" / "-" / ".") ; 0-9 a-z _ - . - /// ASCII-Value -> 1*( %x20-%x7E ) ; space and printable ASCII - void AddMetadata(const grpc::string& meta_key, - const grpc::string& meta_value); - - /// Return a collection of initial metadata key-value pairs. Note that keys - /// may happen more than once (ie, a \a std::multimap is returned). - /// - /// \warning This method should only be called after initial metadata has been - /// received. For streaming calls, see \a - /// ClientReaderInterface::WaitForInitialMetadata(). - /// - /// \return A multimap of initial metadata key-value pairs from the server. - const std::multimap& - GetServerInitialMetadata() const { - GPR_CODEGEN_ASSERT(initial_metadata_received_); - return *recv_initial_metadata_.map(); - } - - /// Return a collection of trailing metadata key-value pairs. Note that keys - /// may happen more than once (ie, a \a std::multimap is returned). - /// - /// \warning This method is only callable once the stream has finished. - /// - /// \return A multimap of metadata trailing key-value pairs from the server. - const std::multimap& - GetServerTrailingMetadata() const { - // TODO(yangg) check finished - return *trailing_metadata_.map(); - } - - /// Set the deadline for the client call. - /// - /// \warning This method should only be called before invoking the rpc. - /// - /// \param deadline the deadline for the client call. Units are determined by - /// the type used. The deadline is an absolute (not relative) time. - template - void set_deadline(const T& deadline) { - TimePoint deadline_tp(deadline); - deadline_ = deadline_tp.raw_time(); - } - - /// EXPERIMENTAL: Indicate that this request is idempotent. - /// By default, RPCs are assumed to not be idempotent. - /// - /// If true, the gRPC library assumes that it's safe to initiate - /// this RPC multiple times. - void set_idempotent(bool idempotent) { idempotent_ = idempotent; } - - /// EXPERIMENTAL: Set this request to be cacheable. - /// If set, grpc is free to use the HTTP GET verb for sending the request, - /// with the possibility of receiving a cached response. - void set_cacheable(bool cacheable) { cacheable_ = cacheable; } - - /// EXPERIMENTAL: Trigger wait-for-ready or not on this request. - /// See https://github.com/grpc/grpc/blob/master/doc/wait-for-ready.md. - /// If set, if an RPC is made when a channel's connectivity state is - /// TRANSIENT_FAILURE or CONNECTING, the call will not "fail fast", - /// and the channel will wait until the channel is READY before making the - /// call. - void set_wait_for_ready(bool wait_for_ready) { - wait_for_ready_ = wait_for_ready; - wait_for_ready_explicitly_set_ = true; - } - - /// DEPRECATED: Use set_wait_for_ready() instead. - void set_fail_fast(bool fail_fast) { set_wait_for_ready(!fail_fast); } - - /// Return the deadline for the client call. - std::chrono::system_clock::time_point deadline() const { - return Timespec2Timepoint(deadline_); - } - - /// Return a \a gpr_timespec representation of the client call's deadline. - gpr_timespec raw_deadline() const { return deadline_; } - - /// Set the per call authority header (see - /// https://tools.ietf.org/html/rfc7540#section-8.1.2.3). - void set_authority(const grpc::string& authority) { authority_ = authority; } - - /// Return the authentication context for this client call. - /// - /// \see grpc::AuthContext. - std::shared_ptr auth_context() const { - if (auth_context_.get() == nullptr) { - auth_context_ = CreateAuthContext(call_); - } - return auth_context_; - } - - /// Set credentials for the client call. - /// - /// A credentials object encapsulates all the state needed by a client to - /// authenticate with a server and make various assertions, e.g., about the - /// client’s identity, role, or whether it is authorized to make a particular - /// call. - /// - /// \see https://grpc.io/docs/guides/auth.html - void set_credentials( - const std::shared_ptr& creds) { - creds_ = creds; - } - - /// Return the compression algorithm the client call will request be used. - /// Note that the gRPC runtime may decide to ignore this request, for example, - /// due to resource constraints. - grpc_compression_algorithm compression_algorithm() const { - return compression_algorithm_; - } - - /// Set \a algorithm to be the compression algorithm used for the client call. - /// - /// \param algorithm The compression algorithm used for the client call. - void set_compression_algorithm(grpc_compression_algorithm algorithm); - - /// Flag whether the initial metadata should be \a corked - /// - /// If \a corked is true, then the initial metadata will be coalesced with the - /// write of first message in the stream. As a result, any tag set for the - /// initial metadata operation (starting a client-streaming or bidi-streaming - /// RPC) will not actually be sent to the completion queue or delivered - /// via Next. - /// - /// \param corked The flag indicating whether the initial metadata is to be - /// corked or not. - void set_initial_metadata_corked(bool corked) { - initial_metadata_corked_ = corked; - } - - /// Return the peer uri in a string. - /// - /// \warning This value is never authenticated or subject to any security - /// related code. It must not be used for any authentication related - /// functionality. Instead, use auth_context. - /// - /// \return The call's peer URI. - grpc::string peer() const; - - /// Get and set census context. - void set_census_context(struct census_context* ccp) { census_context_ = ccp; } - struct census_context* census_context() const { - return census_context_; - } - - /// Send a best-effort out-of-band cancel on the call associated with - /// this client context. The call could be in any stage; e.g., if it is - /// already finished, it may still return success. - /// - /// There is no guarantee the call will be cancelled. - /// - /// Note that TryCancel() does not change any of the tags that are pending - /// on the completion queue. All pending tags will still be delivered - /// (though their ok result may reflect the effect of cancellation). - void TryCancel(); - - /// Global Callbacks - /// - /// Can be set exactly once per application to install hooks whenever - /// a client context is constructed and destructed. - class GlobalCallbacks { - public: - virtual ~GlobalCallbacks() {} - virtual void DefaultConstructor(ClientContext* context) = 0; - virtual void Destructor(ClientContext* context) = 0; - }; - static void SetGlobalCallbacks(GlobalCallbacks* callbacks); - - /// Should be used for framework-level extensions only. - /// Applications never need to call this method. - grpc_call* c_call() { return call_; } - - /// EXPERIMENTAL debugging API - /// - /// if status is not ok() for an RPC, this will return a detailed string - /// of the gRPC Core error that led to the failure. It should not be relied - /// upon for anything other than gaining more debug data in failure cases. - grpc::string debug_error_string() const { return debug_error_string_; } - - private: - // Disallow copy and assign. - ClientContext(const ClientContext&); - ClientContext& operator=(const ClientContext&); - - friend class ::grpc::testing::InteropClientContextInspector; - friend class ::grpc::internal::CallOpClientRecvStatus; - friend class ::grpc::internal::CallOpRecvInitialMetadata; - friend class ::grpc_impl::Channel; - template - friend class ::grpc::ClientReader; - template - friend class ::grpc::ClientWriter; - template - friend class ::grpc::ClientReaderWriter; - template - friend class ::grpc::ClientAsyncReader; - template - friend class ::grpc::ClientAsyncWriter; - template - friend class ::grpc::ClientAsyncReaderWriter; - template - friend class ::grpc::ClientAsyncResponseReader; - template - friend class ::grpc::internal::BlockingUnaryCallImpl; - template - friend class ::grpc::internal::CallbackUnaryCallImpl; - template - friend class ::grpc::internal::ClientCallbackReaderWriterImpl; - template - friend class ::grpc::internal::ClientCallbackReaderImpl; - template - friend class ::grpc::internal::ClientCallbackWriterImpl; - friend class ::grpc::internal::ClientCallbackUnaryImpl; - - // Used by friend class CallOpClientRecvStatus - void set_debug_error_string(const grpc::string& debug_error_string) { - debug_error_string_ = debug_error_string; - } - - grpc_call* call() const { return call_; } - void set_call(grpc_call* call, - const std::shared_ptr<::grpc_impl::Channel>& channel); - - experimental::ClientRpcInfo* set_client_rpc_info( - const char* method, internal::RpcMethod::RpcType type, - grpc::ChannelInterface* channel, - const std::vector< - std::unique_ptr>& - creators, - size_t interceptor_pos) { - rpc_info_ = experimental::ClientRpcInfo(this, type, method, channel); - rpc_info_.RegisterInterceptors(creators, interceptor_pos); - return &rpc_info_; - } - - uint32_t initial_metadata_flags() const { - return (idempotent_ ? GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST : 0) | - (wait_for_ready_ ? GRPC_INITIAL_METADATA_WAIT_FOR_READY : 0) | - (cacheable_ ? GRPC_INITIAL_METADATA_CACHEABLE_REQUEST : 0) | - (wait_for_ready_explicitly_set_ - ? GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET - : 0) | - (initial_metadata_corked_ ? GRPC_INITIAL_METADATA_CORKED : 0); - } - - grpc::string authority() { return authority_; } - - void SendCancelToInterceptors(); - - bool initial_metadata_received_; - bool wait_for_ready_; - bool wait_for_ready_explicitly_set_; - bool idempotent_; - bool cacheable_; - std::shared_ptr<::grpc_impl::Channel> channel_; - grpc::internal::Mutex mu_; - grpc_call* call_; - bool call_canceled_; - gpr_timespec deadline_; - grpc::string authority_; - std::shared_ptr creds_; - mutable std::shared_ptr auth_context_; - struct census_context* census_context_; - std::multimap send_initial_metadata_; - mutable internal::MetadataMap recv_initial_metadata_; - mutable internal::MetadataMap trailing_metadata_; - - grpc_call* propagate_from_call_; - PropagationOptions propagation_options_; - - grpc_compression_algorithm compression_algorithm_; - bool initial_metadata_corked_; - - grpc::string debug_error_string_; - - experimental::ClientRpcInfo rpc_info_; -}; +typedef ::grpc_impl::ClientContext ClientContext; } // namespace grpc diff --git a/include/grpcpp/impl/codegen/client_context_impl.h b/include/grpcpp/impl/codegen/client_context_impl.h new file mode 100644 index 00000000000..76655c63d31 --- /dev/null +++ b/include/grpcpp/impl/codegen/client_context_impl.h @@ -0,0 +1,492 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/// A ClientContext allows the person implementing a service client to: +/// +/// - Add custom metadata key-value pairs that will propagated to the server +/// side. +/// - Control call settings such as compression and authentication. +/// - Initial and trailing metadata coming from the server. +/// - Get performance metrics (ie, census). +/// +/// Context settings are only relevant to the call they are invoked with, that +/// is to say, they aren't sticky. Some of these settings, such as the +/// compression options, can be made persistent at channel construction time +/// (see \a grpc::CreateCustomChannel). +/// +/// \warning ClientContext instances should \em not be reused across rpcs. + +#ifndef GRPCPP_IMPL_CODEGEN_CLIENT_CONTEXT_IMPL_H +#define GRPCPP_IMPL_CODEGEN_CLIENT_CONTEXT_IMPL_H + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct census_context; +struct grpc_call; + +namespace grpc { + +class ChannelInterface; + +namespace internal { +class RpcMethod; +class CallOpClientRecvStatus; +class CallOpRecvInitialMetadata; +template +class BlockingUnaryCallImpl; +template +class CallbackUnaryCallImpl; +template +class ClientCallbackReaderWriterImpl; +template +class ClientCallbackReaderImpl; +template +class ClientCallbackWriterImpl; +class ClientCallbackUnaryImpl; +} // namespace internal + +template +class ClientReader; +template +class ClientWriter; +template +class ClientReaderWriter; +template +class ClientAsyncReader; +template +class ClientAsyncWriter; +template +class ClientAsyncReaderWriter; +template +class ClientAsyncResponseReader; +class ServerContext; + +namespace testing { +class InteropClientContextInspector; +} // namespace testing +} // namespace grpc +namespace grpc_impl { + +class CallCredentials; +class Channel; +class CompletionQueue; + +/// Options for \a ClientContext::FromServerContext specifying which traits from +/// the \a ServerContext to propagate (copy) from it into a new \a +/// ClientContext. +/// +/// \see ClientContext::FromServerContext +class PropagationOptions { + public: + PropagationOptions() : propagate_(GRPC_PROPAGATE_DEFAULTS) {} + + PropagationOptions& enable_deadline_propagation() { + propagate_ |= GRPC_PROPAGATE_DEADLINE; + return *this; + } + + PropagationOptions& disable_deadline_propagation() { + propagate_ &= ~GRPC_PROPAGATE_DEADLINE; + return *this; + } + + PropagationOptions& enable_census_stats_propagation() { + propagate_ |= GRPC_PROPAGATE_CENSUS_STATS_CONTEXT; + return *this; + } + + PropagationOptions& disable_census_stats_propagation() { + propagate_ &= ~GRPC_PROPAGATE_CENSUS_STATS_CONTEXT; + return *this; + } + + PropagationOptions& enable_census_tracing_propagation() { + propagate_ |= GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT; + return *this; + } + + PropagationOptions& disable_census_tracing_propagation() { + propagate_ &= ~GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT; + return *this; + } + + PropagationOptions& enable_cancellation_propagation() { + propagate_ |= GRPC_PROPAGATE_CANCELLATION; + return *this; + } + + PropagationOptions& disable_cancellation_propagation() { + propagate_ &= ~GRPC_PROPAGATE_CANCELLATION; + return *this; + } + + uint32_t c_bitmask() const { return propagate_; } + + private: + uint32_t propagate_; +}; + +/// A ClientContext allows the person implementing a service client to: +/// +/// - Add custom metadata key-value pairs that will propagated to the server +/// side. +/// - Control call settings such as compression and authentication. +/// - Initial and trailing metadata coming from the server. +/// - Get performance metrics (ie, census). +/// +/// Context settings are only relevant to the call they are invoked with, that +/// is to say, they aren't sticky. Some of these settings, such as the +/// compression options, can be made persistent at channel construction time +/// (see \a grpc::CreateCustomChannel). +/// +/// \warning ClientContext instances should \em not be reused across rpcs. +/// \warning The ClientContext instance used for creating an rpc must remain +/// alive and valid for the lifetime of the rpc. +class ClientContext { + public: + ClientContext(); + ~ClientContext(); + + /// Create a new \a ClientContext as a child of an incoming server call, + /// according to \a options (\see PropagationOptions). + /// + /// \param server_context The source server context to use as the basis for + /// constructing the client context. + /// \param options The options controlling what to copy from the \a + /// server_context. + /// + /// \return A newly constructed \a ClientContext instance based on \a + /// server_context, with traits propagated (copied) according to \a options. + static std::unique_ptr FromServerContext( + const grpc::ServerContext& server_context, + PropagationOptions options = PropagationOptions()); + + /// Add the (\a meta_key, \a meta_value) pair to the metadata associated with + /// a client call. These are made available at the server side by the \a + /// grpc::ServerContext::client_metadata() method. + /// + /// \warning This method should only be called before invoking the rpc. + /// + /// \param meta_key The metadata key. If \a meta_value is binary data, it must + /// end in "-bin". + /// \param meta_value The metadata value. If its value is binary, the key name + /// must end in "-bin". + /// + /// Metadata must conform to the following format: + /// Custom-Metadata -> Binary-Header / ASCII-Header + /// Binary-Header -> {Header-Name "-bin" } {binary value} + /// ASCII-Header -> Header-Name ASCII-Value + /// Header-Name -> 1*( %x30-39 / %x61-7A / "_" / "-" / ".") ; 0-9 a-z _ - . + /// ASCII-Value -> 1*( %x20-%x7E ) ; space and printable ASCII + void AddMetadata(const grpc::string& meta_key, + const grpc::string& meta_value); + + /// Return a collection of initial metadata key-value pairs. Note that keys + /// may happen more than once (ie, a \a std::multimap is returned). + /// + /// \warning This method should only be called after initial metadata has been + /// received. For streaming calls, see \a + /// ClientReaderInterface::WaitForInitialMetadata(). + /// + /// \return A multimap of initial metadata key-value pairs from the server. + const std::multimap& + GetServerInitialMetadata() const { + GPR_CODEGEN_ASSERT(initial_metadata_received_); + return *recv_initial_metadata_.map(); + } + + /// Return a collection of trailing metadata key-value pairs. Note that keys + /// may happen more than once (ie, a \a std::multimap is returned). + /// + /// \warning This method is only callable once the stream has finished. + /// + /// \return A multimap of metadata trailing key-value pairs from the server. + const std::multimap& + GetServerTrailingMetadata() const { + // TODO(yangg) check finished + return *trailing_metadata_.map(); + } + + /// Set the deadline for the client call. + /// + /// \warning This method should only be called before invoking the rpc. + /// + /// \param deadline the deadline for the client call. Units are determined by + /// the type used. The deadline is an absolute (not relative) time. + template + void set_deadline(const T& deadline) { + grpc::TimePoint deadline_tp(deadline); + deadline_ = deadline_tp.raw_time(); + } + + /// EXPERIMENTAL: Indicate that this request is idempotent. + /// By default, RPCs are assumed to not be idempotent. + /// + /// If true, the gRPC library assumes that it's safe to initiate + /// this RPC multiple times. + void set_idempotent(bool idempotent) { idempotent_ = idempotent; } + + /// EXPERIMENTAL: Set this request to be cacheable. + /// If set, grpc is free to use the HTTP GET verb for sending the request, + /// with the possibility of receiving a cached response. + void set_cacheable(bool cacheable) { cacheable_ = cacheable; } + + /// EXPERIMENTAL: Trigger wait-for-ready or not on this request. + /// See https://github.com/grpc/grpc/blob/master/doc/wait-for-ready.md. + /// If set, if an RPC is made when a channel's connectivity state is + /// TRANSIENT_FAILURE or CONNECTING, the call will not "fail fast", + /// and the channel will wait until the channel is READY before making the + /// call. + void set_wait_for_ready(bool wait_for_ready) { + wait_for_ready_ = wait_for_ready; + wait_for_ready_explicitly_set_ = true; + } + + /// DEPRECATED: Use set_wait_for_ready() instead. + void set_fail_fast(bool fail_fast) { set_wait_for_ready(!fail_fast); } + + /// Return the deadline for the client call. + std::chrono::system_clock::time_point deadline() const { + return grpc::Timespec2Timepoint(deadline_); + } + + /// Return a \a gpr_timespec representation of the client call's deadline. + gpr_timespec raw_deadline() const { return deadline_; } + + /// Set the per call authority header (see + /// https://tools.ietf.org/html/rfc7540#section-8.1.2.3). + void set_authority(const grpc::string& authority) { authority_ = authority; } + + /// Return the authentication context for this client call. + /// + /// \see grpc::AuthContext. + std::shared_ptr auth_context() const { + if (auth_context_.get() == nullptr) { + auth_context_ = grpc::CreateAuthContext(call_); + } + return auth_context_; + } + + /// Set credentials for the client call. + /// + /// A credentials object encapsulates all the state needed by a client to + /// authenticate with a server and make various assertions, e.g., about the + /// client’s identity, role, or whether it is authorized to make a particular + /// call. + /// + /// \see https://grpc.io/docs/guides/auth.html + void set_credentials( + const std::shared_ptr& creds) { + creds_ = creds; + } + + /// Return the compression algorithm the client call will request be used. + /// Note that the gRPC runtime may decide to ignore this request, for example, + /// due to resource constraints. + grpc_compression_algorithm compression_algorithm() const { + return compression_algorithm_; + } + + /// Set \a algorithm to be the compression algorithm used for the client call. + /// + /// \param algorithm The compression algorithm used for the client call. + void set_compression_algorithm(grpc_compression_algorithm algorithm); + + /// Flag whether the initial metadata should be \a corked + /// + /// If \a corked is true, then the initial metadata will be coalesced with the + /// write of first message in the stream. As a result, any tag set for the + /// initial metadata operation (starting a client-streaming or bidi-streaming + /// RPC) will not actually be sent to the completion queue or delivered + /// via Next. + /// + /// \param corked The flag indicating whether the initial metadata is to be + /// corked or not. + void set_initial_metadata_corked(bool corked) { + initial_metadata_corked_ = corked; + } + + /// Return the peer uri in a string. + /// + /// \warning This value is never authenticated or subject to any security + /// related code. It must not be used for any authentication related + /// functionality. Instead, use auth_context. + /// + /// \return The call's peer URI. + grpc::string peer() const; + + /// Get and set census context. + void set_census_context(struct census_context* ccp) { census_context_ = ccp; } + struct census_context* census_context() const { + return census_context_; + } + + /// Send a best-effort out-of-band cancel on the call associated with + /// this client context. The call could be in any stage; e.g., if it is + /// already finished, it may still return success. + /// + /// There is no guarantee the call will be cancelled. + /// + /// Note that TryCancel() does not change any of the tags that are pending + /// on the completion queue. All pending tags will still be delivered + /// (though their ok result may reflect the effect of cancellation). + void TryCancel(); + + /// Global Callbacks + /// + /// Can be set exactly once per application to install hooks whenever + /// a client context is constructed and destructed. + class GlobalCallbacks { + public: + virtual ~GlobalCallbacks() {} + virtual void DefaultConstructor(ClientContext* context) = 0; + virtual void Destructor(ClientContext* context) = 0; + }; + static void SetGlobalCallbacks(GlobalCallbacks* callbacks); + + /// Should be used for framework-level extensions only. + /// Applications never need to call this method. + grpc_call* c_call() { return call_; } + + /// EXPERIMENTAL debugging API + /// + /// if status is not ok() for an RPC, this will return a detailed string + /// of the gRPC Core error that led to the failure. It should not be relied + /// upon for anything other than gaining more debug data in failure cases. + grpc::string debug_error_string() const { return debug_error_string_; } + + private: + // Disallow copy and assign. + ClientContext(const ClientContext&); + ClientContext& operator=(const ClientContext&); + + friend class ::grpc::testing::InteropClientContextInspector; + friend class ::grpc::internal::CallOpClientRecvStatus; + friend class ::grpc::internal::CallOpRecvInitialMetadata; + friend class ::grpc_impl::Channel; + template + friend class ::grpc::ClientReader; + template + friend class ::grpc::ClientWriter; + template + friend class ::grpc::ClientReaderWriter; + template + friend class ::grpc::ClientAsyncReader; + template + friend class ::grpc::ClientAsyncWriter; + template + friend class ::grpc::ClientAsyncReaderWriter; + template + friend class ::grpc::ClientAsyncResponseReader; + template + friend class ::grpc::internal::BlockingUnaryCallImpl; + template + friend class ::grpc::internal::CallbackUnaryCallImpl; + template + friend class ::grpc::internal::ClientCallbackReaderWriterImpl; + template + friend class ::grpc::internal::ClientCallbackReaderImpl; + template + friend class ::grpc::internal::ClientCallbackWriterImpl; + friend class ::grpc::internal::ClientCallbackUnaryImpl; + + // Used by friend class CallOpClientRecvStatus + void set_debug_error_string(const grpc::string& debug_error_string) { + debug_error_string_ = debug_error_string; + } + + grpc_call* call() const { return call_; } + void set_call(grpc_call* call, + const std::shared_ptr<::grpc_impl::Channel>& channel); + + grpc::experimental::ClientRpcInfo* set_client_rpc_info( + const char* method, grpc::internal::RpcMethod::RpcType type, + grpc::ChannelInterface* channel, + const std::vector< + std::unique_ptr>& + creators, + size_t interceptor_pos) { + rpc_info_ = grpc::experimental::ClientRpcInfo(this, type, method, channel); + rpc_info_.RegisterInterceptors(creators, interceptor_pos); + return &rpc_info_; + } + + uint32_t initial_metadata_flags() const { + return (idempotent_ ? GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST : 0) | + (wait_for_ready_ ? GRPC_INITIAL_METADATA_WAIT_FOR_READY : 0) | + (cacheable_ ? GRPC_INITIAL_METADATA_CACHEABLE_REQUEST : 0) | + (wait_for_ready_explicitly_set_ + ? GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET + : 0) | + (initial_metadata_corked_ ? GRPC_INITIAL_METADATA_CORKED : 0); + } + + grpc::string authority() { return authority_; } + + void SendCancelToInterceptors(); + + bool initial_metadata_received_; + bool wait_for_ready_; + bool wait_for_ready_explicitly_set_; + bool idempotent_; + bool cacheable_; + std::shared_ptr<::grpc_impl::Channel> channel_; + grpc::internal::Mutex mu_; + grpc_call* call_; + bool call_canceled_; + gpr_timespec deadline_; + grpc::string authority_; + std::shared_ptr creds_; + mutable std::shared_ptr auth_context_; + struct census_context* census_context_; + std::multimap send_initial_metadata_; + mutable grpc::internal::MetadataMap recv_initial_metadata_; + mutable grpc::internal::MetadataMap trailing_metadata_; + + grpc_call* propagate_from_call_; + PropagationOptions propagation_options_; + + grpc_compression_algorithm compression_algorithm_; + bool initial_metadata_corked_; + + grpc::string debug_error_string_; + + grpc::experimental::ClientRpcInfo rpc_info_; +}; + +} // namespace grpc_impl + +#endif // GRPCPP_IMPL_CODEGEN_CLIENT_CONTEXT_IMPL_H diff --git a/include/grpcpp/impl/codegen/client_interceptor.h b/include/grpcpp/impl/codegen/client_interceptor.h index a4c85a76da5..c0269edb16e 100644 --- a/include/grpcpp/impl/codegen/client_interceptor.h +++ b/include/grpcpp/impl/codegen/client_interceptor.h @@ -29,12 +29,11 @@ namespace grpc_impl { class Channel; +class ClientContext; } namespace grpc { -class ClientContext; - namespace internal { class InterceptorBatchMethodsImpl; } @@ -96,7 +95,7 @@ class ClientRpcInfo { /// Return a pointer to the underlying ClientContext structure associated /// with the RPC to support features that apply to it - grpc::ClientContext* client_context() { return ctx_; } + grpc_impl::ClientContext* client_context() { return ctx_; } /// Return the type of the RPC (unary or a streaming flavor) Type type() const { return type_; } @@ -119,7 +118,7 @@ class ClientRpcInfo { ClientRpcInfo() = default; // Constructor will only be called from ClientContext - ClientRpcInfo(grpc::ClientContext* ctx, internal::RpcMethod::RpcType type, + ClientRpcInfo(grpc_impl::ClientContext* ctx, internal::RpcMethod::RpcType type, const char* method, grpc::ChannelInterface* channel) : ctx_(ctx), type_(static_cast(type)), @@ -160,7 +159,7 @@ class ClientRpcInfo { } } - grpc::ClientContext* ctx_ = nullptr; + grpc_impl::ClientContext* ctx_ = nullptr; // TODO(yashykt): make type_ const once move-assignment is deleted Type type_{Type::UNKNOWN}; const char* method_ = nullptr; @@ -170,7 +169,7 @@ class ClientRpcInfo { size_t hijacked_interceptor_ = 0; friend class internal::InterceptorBatchMethodsImpl; - friend class grpc::ClientContext; + friend class grpc_impl::ClientContext; }; // PLEASE DO NOT USE THIS. ALWAYS PREFER PER CHANNEL INTERCEPTORS OVER A GLOBAL diff --git a/include/grpcpp/impl/codegen/client_unary_call.h b/include/grpcpp/impl/codegen/client_unary_call.h index e0f692b1783..d312aacf036 100644 --- a/include/grpcpp/impl/codegen/client_unary_call.h +++ b/include/grpcpp/impl/codegen/client_unary_call.h @@ -25,16 +25,18 @@ #include #include -namespace grpc { +namespace grpc_impl { class ClientContext; +} // namespace grpc_impl +namespace grpc { namespace internal { class RpcMethod; /// Wrapper that performs a blocking unary call template Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method, - ClientContext* context, const InputMessage& request, + grpc_impl::ClientContext* context, const InputMessage& request, OutputMessage* result) { return BlockingUnaryCallImpl( channel, method, context, request, result) @@ -45,7 +47,7 @@ template class BlockingUnaryCallImpl { public: BlockingUnaryCallImpl(ChannelInterface* channel, const RpcMethod& method, - ClientContext* context, const InputMessage& request, + grpc_impl::ClientContext* context, const InputMessage& request, OutputMessage* result) { CompletionQueue cq(grpc_completion_queue_attributes{ GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, diff --git a/include/grpcpp/impl/codegen/completion_queue_impl.h b/include/grpcpp/impl/codegen/completion_queue_impl.h index d5c4bb0f201..d78c410704a 100644 --- a/include/grpcpp/impl/codegen/completion_queue_impl.h +++ b/include/grpcpp/impl/codegen/completion_queue_impl.h @@ -65,7 +65,6 @@ class ServerReaderWriterBody; } // namespace internal class ChannelInterface; -class ClientContext; class ServerContext; class ServerInterface; diff --git a/include/grpcpp/impl/codegen/server_context.h b/include/grpcpp/impl/codegen/server_context.h index c6903743938..7f3280b3d4c 100644 --- a/include/grpcpp/impl/codegen/server_context.h +++ b/include/grpcpp/impl/codegen/server_context.h @@ -43,11 +43,11 @@ struct census_context; namespace grpc_impl { +class ClientContext; class CompletionQueue; class Server; } // namespace grpc_impl namespace grpc { -class ClientContext; class GenericServerContext; class ServerInterface; template @@ -306,7 +306,7 @@ class ServerContext { friend class ::grpc::internal::CallbackBidiHandler; template friend class internal::ErrorMethodHandler; - friend class ::grpc::ClientContext; + friend class ::grpc_impl::ClientContext; friend class ::grpc::GenericServerContext; /// Prevent copying. diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index 0ae1ecbf4ba..efb10a44006 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -34,9 +34,6 @@ namespace grpc_impl { class Channel; -} - -namespace grpc { class DefaultGlobalClientCallbacks final : public ClientContext::GlobalCallbacks { @@ -46,7 +43,7 @@ class DefaultGlobalClientCallbacks final void Destructor(ClientContext* context) override {} }; -static internal::GrpcLibraryInitializer g_gli_initializer; +static grpc::internal::GrpcLibraryInitializer g_gli_initializer; static DefaultGlobalClientCallbacks* g_default_client_callbacks = new DefaultGlobalClientCallbacks(); static ClientContext::GlobalCallbacks* g_client_callbacks = @@ -76,7 +73,7 @@ ClientContext::~ClientContext() { } std::unique_ptr ClientContext::FromServerContext( - const ServerContext& context, PropagationOptions options) { + const grpc::ServerContext& context, PropagationOptions options) { std::unique_ptr ctx(new ClientContext); ctx->propagate_from_call_ = context.call_; ctx->propagation_options_ = options; @@ -130,7 +127,7 @@ void ClientContext::TryCancel() { } void ClientContext::SendCancelToInterceptors() { - internal::CancelInterceptorBatchMethods cancel_methods; + grpc::internal::CancelInterceptorBatchMethods cancel_methods; for (size_t i = 0; i < rpc_info_.interceptors_.size(); i++) { rpc_info_.RunInterceptor(&cancel_methods, i); } @@ -153,4 +150,4 @@ void ClientContext::SetGlobalCallbacks(GlobalCallbacks* client_callbacks) { g_client_callbacks = client_callbacks; } -} // namespace grpc +} // namespace grpc_impl diff --git a/test/cpp/util/cli_call.h b/test/cpp/util/cli_call.h index 3f279095a42..65144a1892c 100644 --- a/test/cpp/util/cli_call.h +++ b/test/cpp/util/cli_call.h @@ -27,9 +27,11 @@ #include #include -namespace grpc { +namespace grpc_impl { class ClientContext; +} // namespace grpc_impl +namespace grpc { namespace testing { @@ -85,7 +87,7 @@ class CliCall final { private: std::unique_ptr stub_; - grpc::ClientContext ctx_; + grpc_impl::ClientContext ctx_; std::unique_ptr call_; grpc::CompletionQueue cq_; gpr_mu write_mu_; diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 913d7be993b..3daf46f580c 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -956,6 +956,7 @@ include/grpcpp/impl/codegen/callback_common.h \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ include/grpcpp/impl/codegen/client_context.h \ +include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 8b664d8ac01..0bf0682fb7e 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -957,6 +957,7 @@ include/grpcpp/impl/codegen/callback_common.h \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ include/grpcpp/impl/codegen/client_context.h \ +include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/completion_queue.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index a479a00509a..a9a5a372128 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -10130,6 +10130,7 @@ "include/grpcpp/impl/codegen/channel_interface.h", "include/grpcpp/impl/codegen/client_callback.h", "include/grpcpp/impl/codegen/client_context.h", + "include/grpcpp/impl/codegen/client_context_impl.h", "include/grpcpp/impl/codegen/client_interceptor.h", "include/grpcpp/impl/codegen/client_unary_call.h", "include/grpcpp/impl/codegen/completion_queue.h", @@ -10208,6 +10209,7 @@ "include/grpcpp/impl/codegen/channel_interface.h", "include/grpcpp/impl/codegen/client_callback.h", "include/grpcpp/impl/codegen/client_context.h", + "include/grpcpp/impl/codegen/client_context_impl.h", "include/grpcpp/impl/codegen/client_interceptor.h", "include/grpcpp/impl/codegen/client_unary_call.h", "include/grpcpp/impl/codegen/completion_queue.h", From 7e18e6cf3fe6a93166b67d0614f5b69791887a63 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 5 Jun 2019 16:47:29 -0700 Subject: [PATCH 0447/1555] Fix clang errors. --- include/grpcpp/channel_impl.h | 5 +++-- include/grpcpp/impl/codegen/channel_interface.h | 2 +- include/grpcpp/impl/codegen/client_callback.h | 2 +- include/grpcpp/impl/codegen/client_context_impl.h | 5 ++--- include/grpcpp/impl/codegen/client_interceptor.h | 7 ++++--- include/grpcpp/impl/codegen/client_unary_call.h | 8 ++++---- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/include/grpcpp/channel_impl.h b/include/grpcpp/channel_impl.h index 3ead8ee090e..a7eee2b8981 100644 --- a/include/grpcpp/channel_impl.h +++ b/include/grpcpp/channel_impl.h @@ -100,8 +100,9 @@ class Channel final : public ::grpc::ChannelInterface, ::grpc::CompletionQueue* CallbackCQ() override; ::grpc::internal::Call CreateCallInternal( - const ::grpc::internal::RpcMethod& method, ::grpc_impl::ClientContext* context, - ::grpc::CompletionQueue* cq, size_t interceptor_pos) override; + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, ::grpc::CompletionQueue* cq, + size_t interceptor_pos) override; const grpc::string host_; grpc_channel* const c_channel_; // owned diff --git a/include/grpcpp/impl/codegen/channel_interface.h b/include/grpcpp/impl/codegen/channel_interface.h index 9d0f07f3ff0..836c287e509 100644 --- a/include/grpcpp/impl/codegen/channel_interface.h +++ b/include/grpcpp/impl/codegen/channel_interface.h @@ -27,7 +27,7 @@ namespace grpc_impl { class ClientContext; class CompletionQueue; -} +} // namespace grpc_impl namespace grpc { class ChannelInterface; diff --git a/include/grpcpp/impl/codegen/client_callback.h b/include/grpcpp/impl/codegen/client_callback.h index bd438879543..6cba5830e4b 100644 --- a/include/grpcpp/impl/codegen/client_callback.h +++ b/include/grpcpp/impl/codegen/client_callback.h @@ -32,7 +32,7 @@ namespace grpc_impl { class Channel; class ClientContext; -} +} // namespace grpc_impl namespace grpc { diff --git a/include/grpcpp/impl/codegen/client_context_impl.h b/include/grpcpp/impl/codegen/client_context_impl.h index 76655c63d31..e730450a5c9 100644 --- a/include/grpcpp/impl/codegen/client_context_impl.h +++ b/include/grpcpp/impl/codegen/client_context_impl.h @@ -435,9 +435,8 @@ class ClientContext { grpc::experimental::ClientRpcInfo* set_client_rpc_info( const char* method, grpc::internal::RpcMethod::RpcType type, grpc::ChannelInterface* channel, - const std::vector< - std::unique_ptr>& - creators, + const std::vector>& creators, size_t interceptor_pos) { rpc_info_ = grpc::experimental::ClientRpcInfo(this, type, method, channel); rpc_info_.RegisterInterceptors(creators, interceptor_pos); diff --git a/include/grpcpp/impl/codegen/client_interceptor.h b/include/grpcpp/impl/codegen/client_interceptor.h index c0269edb16e..9e978b6a53e 100644 --- a/include/grpcpp/impl/codegen/client_interceptor.h +++ b/include/grpcpp/impl/codegen/client_interceptor.h @@ -30,7 +30,7 @@ namespace grpc_impl { class Channel; class ClientContext; -} +} // namespace grpc_impl namespace grpc { @@ -118,8 +118,9 @@ class ClientRpcInfo { ClientRpcInfo() = default; // Constructor will only be called from ClientContext - ClientRpcInfo(grpc_impl::ClientContext* ctx, internal::RpcMethod::RpcType type, - const char* method, grpc::ChannelInterface* channel) + ClientRpcInfo(grpc_impl::ClientContext* ctx, + internal::RpcMethod::RpcType type, const char* method, + grpc::ChannelInterface* channel) : ctx_(ctx), type_(static_cast(type)), method_(method), diff --git a/include/grpcpp/impl/codegen/client_unary_call.h b/include/grpcpp/impl/codegen/client_unary_call.h index d312aacf036..599dd1ecac9 100644 --- a/include/grpcpp/impl/codegen/client_unary_call.h +++ b/include/grpcpp/impl/codegen/client_unary_call.h @@ -36,8 +36,8 @@ class RpcMethod; /// Wrapper that performs a blocking unary call template Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method, - grpc_impl::ClientContext* context, const InputMessage& request, - OutputMessage* result) { + grpc_impl::ClientContext* context, + const InputMessage& request, OutputMessage* result) { return BlockingUnaryCallImpl( channel, method, context, request, result) .status(); @@ -47,8 +47,8 @@ template class BlockingUnaryCallImpl { public: BlockingUnaryCallImpl(ChannelInterface* channel, const RpcMethod& method, - grpc_impl::ClientContext* context, const InputMessage& request, - OutputMessage* result) { + grpc_impl::ClientContext* context, + const InputMessage& request, OutputMessage* result) { CompletionQueue cq(grpc_completion_queue_attributes{ GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, nullptr}); // Pluckable completion queue From 7bf845aeefaa68ae2db2d71ffc0723002541dc63 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Wed, 5 Jun 2019 23:42:56 -0400 Subject: [PATCH 0448/1555] Do not intern method and host for registered methods. Registered methods already have a strdup() of host and method. Since we have the copy, the strings are guaranteed to remain valid. --- src/core/lib/surface/server.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 44de0cd42dd..8f6df482aa9 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -1194,12 +1194,12 @@ void grpc_server_setup_transport( bool has_host; grpc_slice method; if (rm->host != nullptr) { - host = grpc_slice_intern(grpc_slice_from_static_string(rm->host)); + host = grpc_slice_from_static_string(rm->host); has_host = true; } else { has_host = false; } - method = grpc_slice_intern(grpc_slice_from_static_string(rm->method)); + method = grpc_slice_from_static_string(rm->method); hash = GRPC_MDSTR_KV_HASH(has_host ? grpc_slice_hash_internal(host) : 0, grpc_slice_hash_internal(method)); for (probes = 0; chand->registered_methods[(hash + probes) % slots] From c43b77b73838e110cb67b6a3250bd3dba0c14bf8 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Wed, 5 Jun 2019 21:40:17 -0700 Subject: [PATCH 0449/1555] Add tests for allowing dots in metadata keys --- .../AbstractGeneratedCodeTest.php | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/php/tests/generated_code/AbstractGeneratedCodeTest.php b/src/php/tests/generated_code/AbstractGeneratedCodeTest.php index c050a26cbf5..f7b47359992 100644 --- a/src/php/tests/generated_code/AbstractGeneratedCodeTest.php +++ b/src/php/tests/generated_code/AbstractGeneratedCodeTest.php @@ -71,6 +71,33 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase $call = self::$client->Div($div_arg, [' ' => 'abc123']); } + public function testMetadata() + { + $div_arg = new Math\DivArgs(); + $call = self::$client->Div($div_arg, ['somekey' => ['abc123']]); + } + + public function testMetadataKey() + { + $div_arg = new Math\DivArgs(); + $call = self::$client->Div($div_arg, ['somekey_-1' => ['abc123']]); + } + + public function testMetadataKeyWithDot() + { + $div_arg = new Math\DivArgs(); + $call = self::$client->Div($div_arg, ['someKEY._-1' => ['abc123']]); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testMetadataInvalidKey() + { + $div_arg = new Math\DivArgs(); + $call = self::$client->Div($div_arg, ['(somekey)' => ['abc123']]); + } + public function testGetCallMetadata() { $div_arg = new Math\DivArgs(); @@ -81,6 +108,8 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase public function testTimeout() { $div_arg = new Math\DivArgs(); + $div_arg->setDividend(7); + $div_arg->setDivisor(4); $call = self::$client->Div($div_arg, [], ['timeout' => 1]); list($response, $status) = $call->wait(); $this->assertSame(\Grpc\STATUS_DEADLINE_EXCEEDED, $status->code); From bf4c7f45ef9dc63306bbd6ef9461ed0646a0b843 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 6 Jun 2019 08:58:41 -0400 Subject: [PATCH 0450/1555] use bazelisk to grab latest bazel version --- .../linux/grpc_bazel_rbe_incompatible_changes.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/internal_ci/linux/grpc_bazel_rbe_incompatible_changes.sh b/tools/internal_ci/linux/grpc_bazel_rbe_incompatible_changes.sh index 9c3712a07da..85b82443bcd 100644 --- a/tools/internal_ci/linux/grpc_bazel_rbe_incompatible_changes.sh +++ b/tools/internal_ci/linux/grpc_bazel_rbe_incompatible_changes.sh @@ -15,9 +15,14 @@ set -ex -# TODO(jtattermusch): use the latest version of bazel +# Use bazelisk to download the right bazel version +wget https://github.com/bazelbuild/bazelisk/releases/download/v0.0.7/bazelisk-linux-amd64 +chmod u+x bazelisk-linux-amd64 -# Use --all_incompatible_changes to give an early warning about future -# bazel incompatibilities. -EXTRA_FLAGS="--config=opt --cache_test_results=no --all_incompatible_changes" +# We want bazelisk to run the latest stable version +export USE_BAZEL_VERSION=latest +# Use bazelisk instead of our usual //tools/bazel wrapper +mv bazelisk-linux-amd64 github/grpc/tools/bazel + +EXTRA_FLAGS="--config=opt --cache_test_results=no" github/grpc/tools/internal_ci/linux/grpc_bazel_on_foundry_base.sh "${EXTRA_FLAGS}" From 957e71ecd29f03dd4c37aa89834c4f6d97b3f6ae Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 6 Jun 2019 16:13:47 +0200 Subject: [PATCH 0451/1555] add config for C/C++ build only PR job --- .../grpc_basictests_c_cpp_build_only.cfg | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tools/internal_ci/linux/pull_request/grpc_basictests_c_cpp_build_only.cfg diff --git a/tools/internal_ci/linux/pull_request/grpc_basictests_c_cpp_build_only.cfg b/tools/internal_ci/linux/pull_request/grpc_basictests_c_cpp_build_only.cfg new file mode 100644 index 00000000000..0eb27206eeb --- /dev/null +++ b/tools/internal_ci/linux/pull_request/grpc_basictests_c_cpp_build_only.cfg @@ -0,0 +1,30 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/linux/grpc_run_tests_matrix.sh" +timeout_mins: 60 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests linux corelang --inner_jobs 16 -j 1 --internal_ci --build_only" +} From e7aca312fc9187e959e59703a68dbc313ee73b8e Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 6 Jun 2019 10:25:37 -0700 Subject: [PATCH 0452/1555] Stop misspelling our own project name --- src/core/ext/filters/client_channel/resolver.h | 2 +- src/core/lib/channel/channelz_registry.h | 4 ++-- src/core/lib/gprpp/memory.h | 4 ++-- src/core/lib/gprpp/orphanable.h | 2 +- src/core/lib/gprpp/ref_counted.h | 6 +++--- src/core/lib/iomgr/buffer_list.h | 2 +- src/core/lib/slice/slice.cc | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver.h b/src/core/ext/filters/client_channel/resolver.h index 9aa504225ad..87a4442d75b 100644 --- a/src/core/ext/filters/client_channel/resolver.h +++ b/src/core/ext/filters/client_channel/resolver.h @@ -128,7 +128,7 @@ class Resolver : public InternallyRefCounted { GRPC_ABSTRACT_BASE_CLASS protected: - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE /// Does NOT take ownership of the reference to \a combiner. // TODO(roth): Once we have a C++-like interface for combiners, this diff --git a/src/core/lib/channel/channelz_registry.h b/src/core/lib/channel/channelz_registry.h index aa87b64e5b2..b9d42ecf4d6 100644 --- a/src/core/lib/channel/channelz_registry.h +++ b/src/core/lib/channel/channelz_registry.h @@ -69,8 +69,8 @@ class ChannelzRegistry { static void LogAllEntities() { Default()->InternalLogAllEntities(); } private: - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE friend class testing::ChannelzRegistryPeer; ChannelzRegistry(); diff --git a/src/core/lib/gprpp/memory.h b/src/core/lib/gprpp/memory.h index b4b63ae771a..70ad430c51d 100644 --- a/src/core/lib/gprpp/memory.h +++ b/src/core/lib/gprpp/memory.h @@ -29,12 +29,12 @@ // Add this to a class that want to use Delete(), but has a private or // protected destructor. -#define GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE \ +#define GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE \ template \ friend void grpc_core::Delete(T*); // Add this to a class that want to use New(), but has a private or // protected constructor. -#define GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW \ +#define GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW \ template \ friend T* grpc_core::New(Args&&...); diff --git a/src/core/lib/gprpp/orphanable.h b/src/core/lib/gprpp/orphanable.h index 2e467e49060..82350a19a2c 100644 --- a/src/core/lib/gprpp/orphanable.h +++ b/src/core/lib/gprpp/orphanable.h @@ -84,7 +84,7 @@ class InternallyRefCounted : public Orphanable { GRPC_ABSTRACT_BASE_CLASS protected: - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE // Allow RefCountedPtr<> to access Unref() and IncrementRefCount(). template diff --git a/src/core/lib/gprpp/ref_counted.h b/src/core/lib/gprpp/ref_counted.h index 392c12a3bd1..cab1aaaaab1 100644 --- a/src/core/lib/gprpp/ref_counted.h +++ b/src/core/lib/gprpp/ref_counted.h @@ -44,7 +44,7 @@ class PolymorphicRefCount { GRPC_ABSTRACT_BASE_CLASS protected: - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE virtual ~PolymorphicRefCount() = default; }; @@ -57,7 +57,7 @@ class NonPolymorphicRefCount { GRPC_ABSTRACT_BASE_CLASS protected: - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE ~NonPolymorphicRefCount() = default; }; @@ -233,7 +233,7 @@ class RefCounted : public Impl { GRPC_ABSTRACT_BASE_CLASS protected: - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE // TraceFlagT is defined to accept both DebugOnlyTraceFlag and TraceFlag. // Note: RefCount tracing is only enabled on debug builds, even when a diff --git a/src/core/lib/iomgr/buffer_list.h b/src/core/lib/iomgr/buffer_list.h index 8bb271867c2..755ce02ba95 100644 --- a/src/core/lib/iomgr/buffer_list.h +++ b/src/core/lib/iomgr/buffer_list.h @@ -133,7 +133,7 @@ class TracedBuffer { grpc_error* shutdown_err); private: - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW TracedBuffer(uint32_t seq_no, void* arg) : seq_no_(seq_no), arg_(arg), next_(nullptr) {} diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc index 3a3edebdc7a..566ad94d705 100644 --- a/src/core/lib/slice/slice.cc +++ b/src/core/lib/slice/slice.cc @@ -106,7 +106,7 @@ class NewSliceRefcount { user_destroy_(destroy), user_data_(user_data) {} - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE grpc_slice_refcount* base_refcount() { return &rc_; } @@ -155,7 +155,7 @@ class NewWithLenSliceRefcount { user_length_(user_length), user_destroy_(destroy) {} - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE grpc_slice_refcount* base_refcount() { return &rc_; } From 22daa0de6f4ed97c501355c25c331ba59df0c7a0 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 6 Jun 2019 13:45:51 -0400 Subject: [PATCH 0453/1555] remove unused objc interop tests configs --- tools/internal_ci/macos/grpc_interop.cfg | 26 -------------------- tools/internal_ci/macos/grpc_interop.sh | 31 ------------------------ 2 files changed, 57 deletions(-) delete mode 100644 tools/internal_ci/macos/grpc_interop.cfg delete mode 100755 tools/internal_ci/macos/grpc_interop.sh diff --git a/tools/internal_ci/macos/grpc_interop.cfg b/tools/internal_ci/macos/grpc_interop.cfg deleted file mode 100644 index 434ecd19c4d..00000000000 --- a/tools/internal_ci/macos/grpc_interop.cfg +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Config file for the internal CI (in protobuf text format) - -# Location of the continuous shell script in repository. -build_file: "grpc/tools/internal_ci/macos/grpc_interop.sh" -gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" -timeout_mins: 240 -action { - define_artifacts { - regex: "**/*sponge_log.*" - regex: "github/grpc/reports/**" - } -} diff --git a/tools/internal_ci/macos/grpc_interop.sh b/tools/internal_ci/macos/grpc_interop.sh deleted file mode 100755 index e290ed60c47..00000000000 --- a/tools/internal_ci/macos/grpc_interop.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -ex - -# change to grpc repo root -cd $(dirname $0)/../../.. - -source tools/internal_ci/helper_scripts/prepare_build_macos_interop_rc -source tools/internal_ci/helper_scripts/prepare_build_macos_rc - -tools/run_tests/run_interop_tests.py -l objc -s all --use_docker -t -j 1 || FAILED="true" - -tools/internal_ci/helper_scripts/delete_nonartifacts.sh || true - -if [ "$FAILED" != "" ] -then - exit 1 -fi From ed045828b9e66108ae0f3b2da08a19017ab1329e Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 6 Jun 2019 14:12:55 -0400 Subject: [PATCH 0454/1555] make default service account email configurable --- tools/run_tests/run_interop_tests.py | 35 ++++++++++++++++------------ 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py index 96e5ee340fc..e71d308dcbe 100755 --- a/tools/run_tests/run_interop_tests.py +++ b/tools/run_tests/run_interop_tests.py @@ -807,23 +807,17 @@ def compute_engine_creds_required(language, test_case): return False -def auth_options(language, - test_case, - google_default_creds_use_key_file, - service_account_key_file=None): +def auth_options(language, test_case, google_default_creds_use_key_file, + service_account_key_file, default_service_account): """Returns (cmdline, env) tuple with cloud_to_prod_auth test options.""" language = str(language) cmdargs = [] env = {} - if not service_account_key_file: - # this file path only works inside docker - service_account_key_file = '/root/service_account/grpc-testing-ebe7c1ac7381.json' oauth_scope_arg = '--oauth_scope=https://www.googleapis.com/auth/xapi.zoo' key_file_arg = '--service_account_key_file=%s' % service_account_key_file - # default compute engine credentials associated with the testing VMs in "grpc-testing" cloud project - default_account_arg = '--default_service_account=830293263384-compute@developer.gserviceaccount.com' + default_account_arg = '--default_service_account=%s' % default_service_account if test_case in ['jwt_token_creds', 'per_rpc_creds', 'oauth2_auth_token']: if language in [ @@ -874,6 +868,7 @@ def cloud_to_prod_jobspec(language, auth=False, manual_cmd_log=None, service_account_key_file=None, + default_service_account=None, transport_security='tls'): """Creates jobspec for cloud-to-prod interop test""" container_name = None @@ -901,9 +896,9 @@ def cloud_to_prod_jobspec(language, cmdargs = cmdargs + transport_security_options environ = dict(language.cloud_to_prod_env(), **language.global_env()) if auth: - auth_cmdargs, auth_env = auth_options(language, test_case, - google_default_creds_use_key_file, - service_account_key_file) + auth_cmdargs, auth_env = auth_options( + language, test_case, google_default_creds_use_key_file, + service_account_key_file, default_service_account) cmdargs += auth_cmdargs environ.update(auth_env) cmdline = bash_cmdline(language.client_cmd(cmdargs)) @@ -1212,12 +1207,17 @@ argp.add_argument( help= 'Use servername=HOST:PORT to explicitly specify a server. E.g. csharp=localhost:50000', default=[]) +# TODO(jtattermusch): the default service_account_key_file only works when --use_docker is used. argp.add_argument( '--service_account_key_file', type=str, - help= - 'Override the default service account key file to use for auth interop tests.', - default=None) + help='The service account key file to use for some auth interop tests.', + default='/root/service_account/grpc-testing-ebe7c1ac7381.json') +argp.add_argument( + '--default_service_account', + type=str, + help='Default GCE service account email to use for some auth interop tests.', + default='830293263384-compute@developer.gserviceaccount.com') argp.add_argument( '-t', '--travis', default=False, action='store_const', const=True) argp.add_argument( @@ -1470,6 +1470,8 @@ try: manual_cmd_log=client_manual_cmd_log, service_account_key_file=args. service_account_key_file, + default_service_account=args. + default_service_account, transport_security=transport_security) jobs.append(test_job) if args.http2_interop: @@ -1484,6 +1486,7 @@ try: docker_image=docker_images.get(str(http2Interop)), manual_cmd_log=client_manual_cmd_log, service_account_key_file=args.service_account_key_file, + default_service_account=args.default_service_account, transport_security=args.transport_security) jobs.append(test_job) @@ -1517,6 +1520,8 @@ try: manual_cmd_log=client_manual_cmd_log, service_account_key_file=args. service_account_key_file, + default_service_account=args. + default_service_account, transport_security=transport_security) jobs.append(test_job) for server in args.override_server: From 7f72d114df4ec6ee336ce1e994b8b3dfbe29160d Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 6 Jun 2019 14:13:19 -0400 Subject: [PATCH 0455/1555] fix macos interop toprod tests --- tools/internal_ci/macos/grpc_interop_toprod.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/internal_ci/macos/grpc_interop_toprod.sh b/tools/internal_ci/macos/grpc_interop_toprod.sh index 36e5a2103d9..13bf58ad1b2 100755 --- a/tools/internal_ci/macos/grpc_interop_toprod.sh +++ b/tools/internal_ci/macos/grpc_interop_toprod.sh @@ -34,6 +34,7 @@ tools/run_tests/run_interop_tests.py -l c++ \ --google_default_creds_use_key_file \ --prod_servers default gateway_v4 \ --service_account_key_file="${KOKORO_KEYSTORE_DIR}/73836_interop_to_prod_tests_service_account_key" \ + --default_service_account="interop-to-prod-tests@grpc-testing.iam.gserviceaccount.com" \ --skip_compute_engine_creds --internal_ci -t -j 4 || FAILED="true" tools/internal_ci/helper_scripts/delete_nonartifacts.sh || true From 7994ea53fcd956f4c1745814e8dd09aae2113693 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 6 Jun 2019 11:49:57 -0700 Subject: [PATCH 0456/1555] Add detailed unknown frame type tests --- CMakeLists.txt | 189 ++++++++----- Makefile | 262 ++++++++++++++---- test/core/bad_client/gen_build_yaml.py | 4 +- test/core/bad_client/tests/unknown_frame.cc | 26 +- .../generated/sources_and_headers.json | 24 +- tools/run_tests/generated/tests.json | 22 +- 6 files changed, 362 insertions(+), 165 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e9d2168b8de..72e870024d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -438,17 +438,6 @@ add_dependencies(buildtests_c udp_server_test) endif() add_dependencies(buildtests_c uri_parser_test) add_dependencies(buildtests_c public_headers_must_be_c89) -add_dependencies(buildtests_c badreq_bad_client_test) -add_dependencies(buildtests_c connection_prefix_bad_client_test) -add_dependencies(buildtests_c duplicate_header_bad_client_test) -add_dependencies(buildtests_c head_of_line_blocking_bad_client_test) -add_dependencies(buildtests_c headers_bad_client_test) -add_dependencies(buildtests_c initial_settings_frame_bad_client_test) -add_dependencies(buildtests_c large_metadata_bad_client_test) -add_dependencies(buildtests_c server_registered_method_bad_client_test) -add_dependencies(buildtests_c simple_request_bad_client_test) -add_dependencies(buildtests_c unknown_frame_bad_client_test) -add_dependencies(buildtests_c window_overflow_bad_client_test) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_c bad_ssl_cert_server) endif() @@ -733,6 +722,17 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx writes_per_rpc_test) endif() add_dependencies(buildtests_cxx xds_end2end_test) +add_dependencies(buildtests_cxx badreq_bad_client_test) +add_dependencies(buildtests_cxx connection_prefix_bad_client_test) +add_dependencies(buildtests_cxx duplicate_header_bad_client_test) +add_dependencies(buildtests_cxx head_of_line_blocking_bad_client_test) +add_dependencies(buildtests_cxx headers_bad_client_test) +add_dependencies(buildtests_cxx initial_settings_frame_bad_client_test) +add_dependencies(buildtests_cxx large_metadata_bad_client_test) +add_dependencies(buildtests_cxx server_registered_method_bad_client_test) +add_dependencies(buildtests_cxx simple_request_bad_client_test) +add_dependencies(buildtests_cxx unknown_frame_bad_client_test) +add_dependencies(buildtests_cxx window_overflow_bad_client_test) add_dependencies(buildtests_cxx resolver_component_test_unsecure) add_dependencies(buildtests_cxx resolver_component_test) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) @@ -5833,18 +5833,19 @@ target_include_directories(bad_client_test PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(bad_client_test PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(bad_client_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(bad_client_test + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util_unsecure grpc_unsecure gpr + ${_gRPC_GFLAGS_LIBRARIES} ) @@ -17019,6 +17020,8 @@ if (gRPC_BUILD_TESTS) add_executable(badreq_bad_client_test test/core/bad_client/tests/badreq.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) @@ -17033,28 +17036,32 @@ target_include_directories(badreq_bad_client_test PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} ) target_link_libraries(badreq_bad_client_test ${_gRPC_SSL_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test grpc_test_util_unsecure grpc_unsecure gpr + ${_gRPC_GFLAGS_LIBRARIES} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(badreq_bad_client_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(badreq_bad_client_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(connection_prefix_bad_client_test test/core/bad_client/tests/connection_prefix.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) @@ -17069,28 +17076,32 @@ target_include_directories(connection_prefix_bad_client_test PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} ) target_link_libraries(connection_prefix_bad_client_test ${_gRPC_SSL_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test grpc_test_util_unsecure grpc_unsecure gpr + ${_gRPC_GFLAGS_LIBRARIES} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(connection_prefix_bad_client_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(connection_prefix_bad_client_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(duplicate_header_bad_client_test test/core/bad_client/tests/duplicate_header.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) @@ -17105,28 +17116,32 @@ target_include_directories(duplicate_header_bad_client_test PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} ) target_link_libraries(duplicate_header_bad_client_test ${_gRPC_SSL_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test grpc_test_util_unsecure grpc_unsecure gpr + ${_gRPC_GFLAGS_LIBRARIES} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(duplicate_header_bad_client_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(duplicate_header_bad_client_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(head_of_line_blocking_bad_client_test test/core/bad_client/tests/head_of_line_blocking.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) @@ -17141,28 +17156,32 @@ target_include_directories(head_of_line_blocking_bad_client_test PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} ) target_link_libraries(head_of_line_blocking_bad_client_test ${_gRPC_SSL_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test grpc_test_util_unsecure grpc_unsecure gpr + ${_gRPC_GFLAGS_LIBRARIES} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(head_of_line_blocking_bad_client_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(head_of_line_blocking_bad_client_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(headers_bad_client_test test/core/bad_client/tests/headers.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) @@ -17177,28 +17196,32 @@ target_include_directories(headers_bad_client_test PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} ) target_link_libraries(headers_bad_client_test ${_gRPC_SSL_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test grpc_test_util_unsecure grpc_unsecure gpr + ${_gRPC_GFLAGS_LIBRARIES} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(headers_bad_client_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(headers_bad_client_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(initial_settings_frame_bad_client_test test/core/bad_client/tests/initial_settings_frame.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) @@ -17213,28 +17236,32 @@ target_include_directories(initial_settings_frame_bad_client_test PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} ) target_link_libraries(initial_settings_frame_bad_client_test ${_gRPC_SSL_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test grpc_test_util_unsecure grpc_unsecure gpr + ${_gRPC_GFLAGS_LIBRARIES} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(initial_settings_frame_bad_client_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(initial_settings_frame_bad_client_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(large_metadata_bad_client_test test/core/bad_client/tests/large_metadata.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) @@ -17249,28 +17276,32 @@ target_include_directories(large_metadata_bad_client_test PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} ) target_link_libraries(large_metadata_bad_client_test ${_gRPC_SSL_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test grpc_test_util_unsecure grpc_unsecure gpr + ${_gRPC_GFLAGS_LIBRARIES} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(large_metadata_bad_client_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(large_metadata_bad_client_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(server_registered_method_bad_client_test test/core/bad_client/tests/server_registered_method.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) @@ -17285,28 +17316,32 @@ target_include_directories(server_registered_method_bad_client_test PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} ) target_link_libraries(server_registered_method_bad_client_test ${_gRPC_SSL_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test grpc_test_util_unsecure grpc_unsecure gpr + ${_gRPC_GFLAGS_LIBRARIES} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(server_registered_method_bad_client_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(server_registered_method_bad_client_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(simple_request_bad_client_test test/core/bad_client/tests/simple_request.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) @@ -17321,28 +17356,32 @@ target_include_directories(simple_request_bad_client_test PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} ) target_link_libraries(simple_request_bad_client_test ${_gRPC_SSL_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test grpc_test_util_unsecure grpc_unsecure gpr + ${_gRPC_GFLAGS_LIBRARIES} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(simple_request_bad_client_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(simple_request_bad_client_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(unknown_frame_bad_client_test test/core/bad_client/tests/unknown_frame.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) @@ -17357,28 +17396,32 @@ target_include_directories(unknown_frame_bad_client_test PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} ) target_link_libraries(unknown_frame_bad_client_test ${_gRPC_SSL_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test grpc_test_util_unsecure grpc_unsecure gpr + ${_gRPC_GFLAGS_LIBRARIES} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(unknown_frame_bad_client_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(unknown_frame_bad_client_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(window_overflow_bad_client_test test/core/bad_client/tests/window_overflow.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc ) @@ -17393,22 +17436,24 @@ target_include_directories(window_overflow_bad_client_test PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} ) target_link_libraries(window_overflow_bad_client_test ${_gRPC_SSL_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test grpc_test_util_unsecure grpc_unsecure gpr + ${_gRPC_GFLAGS_LIBRARIES} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(window_overflow_bad_client_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(window_overflow_bad_client_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index e56c5ec4e47..84b40cb9af0 100644 --- a/Makefile +++ b/Makefile @@ -1405,7 +1405,7 @@ plugins: $(PROTOC_PLUGINS) privatelibs: privatelibs_c privatelibs_cxx -privatelibs_c: $(LIBDIR)/$(CONFIG)/libalts_test_util.a $(LIBDIR)/$(CONFIG)/libcxxabi.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libreconnect_server.a $(LIBDIR)/$(CONFIG)/libtest_tcp_server.a $(LIBDIR)/$(CONFIG)/libupb.a $(LIBDIR)/$(CONFIG)/libz.a $(LIBDIR)/$(CONFIG)/libares.a $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libbad_ssl_test_server.a $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a +privatelibs_c: $(LIBDIR)/$(CONFIG)/libalts_test_util.a $(LIBDIR)/$(CONFIG)/libcxxabi.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libreconnect_server.a $(LIBDIR)/$(CONFIG)/libtest_tcp_server.a $(LIBDIR)/$(CONFIG)/libupb.a $(LIBDIR)/$(CONFIG)/libz.a $(LIBDIR)/$(CONFIG)/libares.a $(LIBDIR)/$(CONFIG)/libbad_ssl_test_server.a $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a pc_c: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc pc_c_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc @@ -1415,9 +1415,9 @@ pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc ifeq ($(EMBED_OPENSSL),true) -privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libdns_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_core_stats.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libhttp2_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libbenchmark.a +privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libdns_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_core_stats.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libhttp2_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libbad_client_test.a else -privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libdns_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_core_stats.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libhttp2_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libbenchmark.a +privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libdns_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_core_stats.a $(LIBDIR)/$(CONFIG)/libgrpc++_proto_reflection_desc_db.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libhttp2_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_lib.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libbad_client_test.a endif @@ -1555,17 +1555,6 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/udp_server_test \ $(BINDIR)/$(CONFIG)/uri_parser_test \ $(BINDIR)/$(CONFIG)/public_headers_must_be_c89 \ - $(BINDIR)/$(CONFIG)/badreq_bad_client_test \ - $(BINDIR)/$(CONFIG)/connection_prefix_bad_client_test \ - $(BINDIR)/$(CONFIG)/duplicate_header_bad_client_test \ - $(BINDIR)/$(CONFIG)/head_of_line_blocking_bad_client_test \ - $(BINDIR)/$(CONFIG)/headers_bad_client_test \ - $(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test \ - $(BINDIR)/$(CONFIG)/large_metadata_bad_client_test \ - $(BINDIR)/$(CONFIG)/server_registered_method_bad_client_test \ - $(BINDIR)/$(CONFIG)/simple_request_bad_client_test \ - $(BINDIR)/$(CONFIG)/unknown_frame_bad_client_test \ - $(BINDIR)/$(CONFIG)/window_overflow_bad_client_test \ $(BINDIR)/$(CONFIG)/bad_ssl_cert_server \ $(BINDIR)/$(CONFIG)/bad_ssl_cert_test \ $(BINDIR)/$(CONFIG)/h2_census_test \ @@ -1762,6 +1751,17 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/xds_end2end_test \ $(BINDIR)/$(CONFIG)/boringssl_ssl_test \ $(BINDIR)/$(CONFIG)/boringssl_crypto_test \ + $(BINDIR)/$(CONFIG)/badreq_bad_client_test \ + $(BINDIR)/$(CONFIG)/connection_prefix_bad_client_test \ + $(BINDIR)/$(CONFIG)/duplicate_header_bad_client_test \ + $(BINDIR)/$(CONFIG)/head_of_line_blocking_bad_client_test \ + $(BINDIR)/$(CONFIG)/headers_bad_client_test \ + $(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test \ + $(BINDIR)/$(CONFIG)/large_metadata_bad_client_test \ + $(BINDIR)/$(CONFIG)/server_registered_method_bad_client_test \ + $(BINDIR)/$(CONFIG)/simple_request_bad_client_test \ + $(BINDIR)/$(CONFIG)/unknown_frame_bad_client_test \ + $(BINDIR)/$(CONFIG)/window_overflow_bad_client_test \ $(BINDIR)/$(CONFIG)/resolver_component_test_unsecure \ $(BINDIR)/$(CONFIG)/resolver_component_test \ $(BINDIR)/$(CONFIG)/resolver_component_tests_runner_invoker_unsecure \ @@ -1910,6 +1910,17 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/transport_security_common_api_test \ $(BINDIR)/$(CONFIG)/writes_per_rpc_test \ $(BINDIR)/$(CONFIG)/xds_end2end_test \ + $(BINDIR)/$(CONFIG)/badreq_bad_client_test \ + $(BINDIR)/$(CONFIG)/connection_prefix_bad_client_test \ + $(BINDIR)/$(CONFIG)/duplicate_header_bad_client_test \ + $(BINDIR)/$(CONFIG)/head_of_line_blocking_bad_client_test \ + $(BINDIR)/$(CONFIG)/headers_bad_client_test \ + $(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test \ + $(BINDIR)/$(CONFIG)/large_metadata_bad_client_test \ + $(BINDIR)/$(CONFIG)/server_registered_method_bad_client_test \ + $(BINDIR)/$(CONFIG)/simple_request_bad_client_test \ + $(BINDIR)/$(CONFIG)/unknown_frame_bad_client_test \ + $(BINDIR)/$(CONFIG)/window_overflow_bad_client_test \ $(BINDIR)/$(CONFIG)/resolver_component_test_unsecure \ $(BINDIR)/$(CONFIG)/resolver_component_test \ $(BINDIR)/$(CONFIG)/resolver_component_tests_runner_invoker_unsecure \ @@ -2176,28 +2187,6 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/uri_parser_test || ( echo test uri_parser_test failed ; exit 1 ) $(E) "[RUN] Testing public_headers_must_be_c89" $(Q) $(BINDIR)/$(CONFIG)/public_headers_must_be_c89 || ( echo test public_headers_must_be_c89 failed ; exit 1 ) - $(E) "[RUN] Testing badreq_bad_client_test" - $(Q) $(BINDIR)/$(CONFIG)/badreq_bad_client_test || ( echo test badreq_bad_client_test failed ; exit 1 ) - $(E) "[RUN] Testing connection_prefix_bad_client_test" - $(Q) $(BINDIR)/$(CONFIG)/connection_prefix_bad_client_test || ( echo test connection_prefix_bad_client_test failed ; exit 1 ) - $(E) "[RUN] Testing duplicate_header_bad_client_test" - $(Q) $(BINDIR)/$(CONFIG)/duplicate_header_bad_client_test || ( echo test duplicate_header_bad_client_test failed ; exit 1 ) - $(E) "[RUN] Testing head_of_line_blocking_bad_client_test" - $(Q) $(BINDIR)/$(CONFIG)/head_of_line_blocking_bad_client_test || ( echo test head_of_line_blocking_bad_client_test failed ; exit 1 ) - $(E) "[RUN] Testing headers_bad_client_test" - $(Q) $(BINDIR)/$(CONFIG)/headers_bad_client_test || ( echo test headers_bad_client_test failed ; exit 1 ) - $(E) "[RUN] Testing initial_settings_frame_bad_client_test" - $(Q) $(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test || ( echo test initial_settings_frame_bad_client_test failed ; exit 1 ) - $(E) "[RUN] Testing large_metadata_bad_client_test" - $(Q) $(BINDIR)/$(CONFIG)/large_metadata_bad_client_test || ( echo test large_metadata_bad_client_test failed ; exit 1 ) - $(E) "[RUN] Testing server_registered_method_bad_client_test" - $(Q) $(BINDIR)/$(CONFIG)/server_registered_method_bad_client_test || ( echo test server_registered_method_bad_client_test failed ; exit 1 ) - $(E) "[RUN] Testing simple_request_bad_client_test" - $(Q) $(BINDIR)/$(CONFIG)/simple_request_bad_client_test || ( echo test simple_request_bad_client_test failed ; exit 1 ) - $(E) "[RUN] Testing unknown_frame_bad_client_test" - $(Q) $(BINDIR)/$(CONFIG)/unknown_frame_bad_client_test || ( echo test unknown_frame_bad_client_test failed ; exit 1 ) - $(E) "[RUN] Testing window_overflow_bad_client_test" - $(Q) $(BINDIR)/$(CONFIG)/window_overflow_bad_client_test || ( echo test window_overflow_bad_client_test failed ; exit 1 ) $(E) "[RUN] Testing bad_ssl_cert_test" $(Q) $(BINDIR)/$(CONFIG)/bad_ssl_cert_test || ( echo test bad_ssl_cert_test failed ; exit 1 ) @@ -2452,6 +2441,28 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/writes_per_rpc_test || ( echo test writes_per_rpc_test failed ; exit 1 ) $(E) "[RUN] Testing xds_end2end_test" $(Q) $(BINDIR)/$(CONFIG)/xds_end2end_test || ( echo test xds_end2end_test failed ; exit 1 ) + $(E) "[RUN] Testing badreq_bad_client_test" + $(Q) $(BINDIR)/$(CONFIG)/badreq_bad_client_test || ( echo test badreq_bad_client_test failed ; exit 1 ) + $(E) "[RUN] Testing connection_prefix_bad_client_test" + $(Q) $(BINDIR)/$(CONFIG)/connection_prefix_bad_client_test || ( echo test connection_prefix_bad_client_test failed ; exit 1 ) + $(E) "[RUN] Testing duplicate_header_bad_client_test" + $(Q) $(BINDIR)/$(CONFIG)/duplicate_header_bad_client_test || ( echo test duplicate_header_bad_client_test failed ; exit 1 ) + $(E) "[RUN] Testing head_of_line_blocking_bad_client_test" + $(Q) $(BINDIR)/$(CONFIG)/head_of_line_blocking_bad_client_test || ( echo test head_of_line_blocking_bad_client_test failed ; exit 1 ) + $(E) "[RUN] Testing headers_bad_client_test" + $(Q) $(BINDIR)/$(CONFIG)/headers_bad_client_test || ( echo test headers_bad_client_test failed ; exit 1 ) + $(E) "[RUN] Testing initial_settings_frame_bad_client_test" + $(Q) $(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test || ( echo test initial_settings_frame_bad_client_test failed ; exit 1 ) + $(E) "[RUN] Testing large_metadata_bad_client_test" + $(Q) $(BINDIR)/$(CONFIG)/large_metadata_bad_client_test || ( echo test large_metadata_bad_client_test failed ; exit 1 ) + $(E) "[RUN] Testing server_registered_method_bad_client_test" + $(Q) $(BINDIR)/$(CONFIG)/server_registered_method_bad_client_test || ( echo test server_registered_method_bad_client_test failed ; exit 1 ) + $(E) "[RUN] Testing simple_request_bad_client_test" + $(Q) $(BINDIR)/$(CONFIG)/simple_request_bad_client_test || ( echo test simple_request_bad_client_test failed ; exit 1 ) + $(E) "[RUN] Testing unknown_frame_bad_client_test" + $(Q) $(BINDIR)/$(CONFIG)/unknown_frame_bad_client_test || ( echo test unknown_frame_bad_client_test failed ; exit 1 ) + $(E) "[RUN] Testing window_overflow_bad_client_test" + $(Q) $(BINDIR)/$(CONFIG)/window_overflow_bad_client_test || ( echo test window_overflow_bad_client_test failed ; exit 1 ) $(E) "[RUN] Testing resolver_component_tests_runner_invoker_unsecure" $(Q) $(BINDIR)/$(CONFIG)/resolver_component_tests_runner_invoker_unsecure || ( echo test resolver_component_tests_runner_invoker_unsecure failed ; exit 1 ) $(E) "[RUN] Testing resolver_component_tests_runner_invoker" @@ -8529,7 +8540,7 @@ endif LIBBAD_CLIENT_TEST_SRC = \ test/core/bad_client/bad_client.cc \ -PUBLIC_HEADERS_C += \ +PUBLIC_HEADERS_CXX += \ LIBBAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBAD_CLIENT_TEST_SRC)))) @@ -8543,8 +8554,16 @@ $(LIBDIR)/$(CONFIG)/libbad_client_test.a: openssl_dep_error else +ifeq ($(NO_PROTOBUF),true) -$(LIBDIR)/$(CONFIG)/libbad_client_test.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBBAD_CLIENT_TEST_OBJS) +# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay. + +$(LIBDIR)/$(CONFIG)/libbad_client_test.a: protobuf_dep_error + + +else + +$(LIBDIR)/$(CONFIG)/libbad_client_test.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(PROTOBUF_DEP) $(LIBBAD_CLIENT_TEST_OBJS) $(E) "[AR] Creating $@" $(Q) mkdir -p `dirname $@` $(Q) rm -f $(LIBDIR)/$(CONFIG)/libbad_client_test.a @@ -8556,6 +8575,8 @@ endif +endif + endif ifneq ($(NO_SECURE),true) @@ -20298,10 +20319,21 @@ BADREQ_BAD_CLIENT_TEST_SRC = \ BADREQ_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BADREQ_BAD_CLIENT_TEST_SRC)))) -$(BINDIR)/$(CONFIG)/badreq_bad_client_test: $(BADREQ_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/badreq_bad_client_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/badreq_bad_client_test: $(PROTOBUF_DEP) $(BADREQ_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(BADREQ_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/badreq_bad_client_test + $(Q) $(LDXX) $(LDFLAGS) $(BADREQ_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/badreq_bad_client_test + +endif $(OBJDIR)/$(CONFIG)/test/core/bad_client/tests/badreq.o: $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -20318,10 +20350,21 @@ CONNECTION_PREFIX_BAD_CLIENT_TEST_SRC = \ CONNECTION_PREFIX_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CONNECTION_PREFIX_BAD_CLIENT_TEST_SRC)))) -$(BINDIR)/$(CONFIG)/connection_prefix_bad_client_test: $(CONNECTION_PREFIX_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/connection_prefix_bad_client_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/connection_prefix_bad_client_test: $(PROTOBUF_DEP) $(CONNECTION_PREFIX_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CONNECTION_PREFIX_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/connection_prefix_bad_client_test + $(Q) $(LDXX) $(LDFLAGS) $(CONNECTION_PREFIX_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/connection_prefix_bad_client_test + +endif $(OBJDIR)/$(CONFIG)/test/core/bad_client/tests/connection_prefix.o: $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -20338,10 +20381,21 @@ DUPLICATE_HEADER_BAD_CLIENT_TEST_SRC = \ DUPLICATE_HEADER_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(DUPLICATE_HEADER_BAD_CLIENT_TEST_SRC)))) -$(BINDIR)/$(CONFIG)/duplicate_header_bad_client_test: $(DUPLICATE_HEADER_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/duplicate_header_bad_client_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/duplicate_header_bad_client_test: $(PROTOBUF_DEP) $(DUPLICATE_HEADER_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(DUPLICATE_HEADER_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/duplicate_header_bad_client_test + $(Q) $(LDXX) $(LDFLAGS) $(DUPLICATE_HEADER_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/duplicate_header_bad_client_test + +endif $(OBJDIR)/$(CONFIG)/test/core/bad_client/tests/duplicate_header.o: $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -20358,10 +20412,21 @@ HEAD_OF_LINE_BLOCKING_BAD_CLIENT_TEST_SRC = \ HEAD_OF_LINE_BLOCKING_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HEAD_OF_LINE_BLOCKING_BAD_CLIENT_TEST_SRC)))) -$(BINDIR)/$(CONFIG)/head_of_line_blocking_bad_client_test: $(HEAD_OF_LINE_BLOCKING_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/head_of_line_blocking_bad_client_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/head_of_line_blocking_bad_client_test: $(PROTOBUF_DEP) $(HEAD_OF_LINE_BLOCKING_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HEAD_OF_LINE_BLOCKING_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/head_of_line_blocking_bad_client_test + $(Q) $(LDXX) $(LDFLAGS) $(HEAD_OF_LINE_BLOCKING_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/head_of_line_blocking_bad_client_test + +endif $(OBJDIR)/$(CONFIG)/test/core/bad_client/tests/head_of_line_blocking.o: $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -20378,10 +20443,21 @@ HEADERS_BAD_CLIENT_TEST_SRC = \ HEADERS_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HEADERS_BAD_CLIENT_TEST_SRC)))) -$(BINDIR)/$(CONFIG)/headers_bad_client_test: $(HEADERS_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/headers_bad_client_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/headers_bad_client_test: $(PROTOBUF_DEP) $(HEADERS_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HEADERS_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/headers_bad_client_test + $(Q) $(LDXX) $(LDFLAGS) $(HEADERS_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/headers_bad_client_test + +endif $(OBJDIR)/$(CONFIG)/test/core/bad_client/tests/headers.o: $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -20398,10 +20474,21 @@ INITIAL_SETTINGS_FRAME_BAD_CLIENT_TEST_SRC = \ INITIAL_SETTINGS_FRAME_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(INITIAL_SETTINGS_FRAME_BAD_CLIENT_TEST_SRC)))) -$(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test: $(INITIAL_SETTINGS_FRAME_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test: $(PROTOBUF_DEP) $(INITIAL_SETTINGS_FRAME_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(INITIAL_SETTINGS_FRAME_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test + $(Q) $(LDXX) $(LDFLAGS) $(INITIAL_SETTINGS_FRAME_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test + +endif $(OBJDIR)/$(CONFIG)/test/core/bad_client/tests/initial_settings_frame.o: $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -20418,10 +20505,21 @@ LARGE_METADATA_BAD_CLIENT_TEST_SRC = \ LARGE_METADATA_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LARGE_METADATA_BAD_CLIENT_TEST_SRC)))) -$(BINDIR)/$(CONFIG)/large_metadata_bad_client_test: $(LARGE_METADATA_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/large_metadata_bad_client_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/large_metadata_bad_client_test: $(PROTOBUF_DEP) $(LARGE_METADATA_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(LARGE_METADATA_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/large_metadata_bad_client_test + $(Q) $(LDXX) $(LDFLAGS) $(LARGE_METADATA_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/large_metadata_bad_client_test + +endif $(OBJDIR)/$(CONFIG)/test/core/bad_client/tests/large_metadata.o: $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -20438,10 +20536,21 @@ SERVER_REGISTERED_METHOD_BAD_CLIENT_TEST_SRC = \ SERVER_REGISTERED_METHOD_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SERVER_REGISTERED_METHOD_BAD_CLIENT_TEST_SRC)))) -$(BINDIR)/$(CONFIG)/server_registered_method_bad_client_test: $(SERVER_REGISTERED_METHOD_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/server_registered_method_bad_client_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/server_registered_method_bad_client_test: $(PROTOBUF_DEP) $(SERVER_REGISTERED_METHOD_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SERVER_REGISTERED_METHOD_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/server_registered_method_bad_client_test + $(Q) $(LDXX) $(LDFLAGS) $(SERVER_REGISTERED_METHOD_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/server_registered_method_bad_client_test + +endif $(OBJDIR)/$(CONFIG)/test/core/bad_client/tests/server_registered_method.o: $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -20458,10 +20567,21 @@ SIMPLE_REQUEST_BAD_CLIENT_TEST_SRC = \ SIMPLE_REQUEST_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SIMPLE_REQUEST_BAD_CLIENT_TEST_SRC)))) -$(BINDIR)/$(CONFIG)/simple_request_bad_client_test: $(SIMPLE_REQUEST_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/simple_request_bad_client_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/simple_request_bad_client_test: $(PROTOBUF_DEP) $(SIMPLE_REQUEST_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SIMPLE_REQUEST_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/simple_request_bad_client_test + $(Q) $(LDXX) $(LDFLAGS) $(SIMPLE_REQUEST_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/simple_request_bad_client_test + +endif $(OBJDIR)/$(CONFIG)/test/core/bad_client/tests/simple_request.o: $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -20478,10 +20598,21 @@ UNKNOWN_FRAME_BAD_CLIENT_TEST_SRC = \ UNKNOWN_FRAME_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(UNKNOWN_FRAME_BAD_CLIENT_TEST_SRC)))) -$(BINDIR)/$(CONFIG)/unknown_frame_bad_client_test: $(UNKNOWN_FRAME_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/unknown_frame_bad_client_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/unknown_frame_bad_client_test: $(PROTOBUF_DEP) $(UNKNOWN_FRAME_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(UNKNOWN_FRAME_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/unknown_frame_bad_client_test + $(Q) $(LDXX) $(LDFLAGS) $(UNKNOWN_FRAME_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/unknown_frame_bad_client_test + +endif $(OBJDIR)/$(CONFIG)/test/core/bad_client/tests/unknown_frame.o: $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -20498,10 +20629,21 @@ WINDOW_OVERFLOW_BAD_CLIENT_TEST_SRC = \ WINDOW_OVERFLOW_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(WINDOW_OVERFLOW_BAD_CLIENT_TEST_SRC)))) -$(BINDIR)/$(CONFIG)/window_overflow_bad_client_test: $(WINDOW_OVERFLOW_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/window_overflow_bad_client_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/window_overflow_bad_client_test: $(PROTOBUF_DEP) $(WINDOW_OVERFLOW_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(WINDOW_OVERFLOW_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/window_overflow_bad_client_test + $(Q) $(LDXX) $(LDFLAGS) $(WINDOW_OVERFLOW_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/window_overflow_bad_client_test + +endif $(OBJDIR)/$(CONFIG)/test/core/bad_client/tests/window_overflow.o: $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a diff --git a/test/core/bad_client/gen_build_yaml.py b/test/core/bad_client/gen_build_yaml.py index 6a40b4e5e9d..bd311ccfd90 100755 --- a/test/core/bad_client/gen_build_yaml.py +++ b/test/core/bad_client/gen_build_yaml.py @@ -45,7 +45,7 @@ def main(): { 'name': 'bad_client_test', 'build': 'private', - 'language': 'c', + 'language': 'c++', 'src': [ 'test/core/bad_client/bad_client.cc' ], @@ -64,7 +64,7 @@ def main(): 'name': '%s_bad_client_test' % t, 'cpu_cost': BAD_CLIENT_TESTS[t].cpu_cost, 'build': 'test', - 'language': 'c', + 'language': 'c++', 'secure': 'no', 'src': ['test/core/bad_client/tests/%s.cc' % t], 'vs_proj_dir': 'test', diff --git a/test/core/bad_client/tests/unknown_frame.cc b/test/core/bad_client/tests/unknown_frame.cc index 9e0cf3f6a90..fa29ace2e35 100644 --- a/test/core/bad_client/tests/unknown_frame.cc +++ b/test/core/bad_client/tests/unknown_frame.cc @@ -16,13 +16,12 @@ * */ +#include + +#include #include "src/core/lib/surface/server.h" #include "test/core/bad_client/bad_client.h" -#define PFX_STR \ - "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ - "\x00\x00\x00\x04\x00\x00\x00\x00\x00" - static void verifier(grpc_server* server, grpc_completion_queue* cq, void* registered_method) { while (grpc_server_has_open_connections(server)) { @@ -36,10 +35,21 @@ int main(int argc, char** argv) { grpc_init(); grpc::testing::TestEnvironment env(argc, argv); - /* test adding prioritization data */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, - PFX_STR "\x00\x00\x00\x88\x00\x00\x00\x00\x01", - GRPC_BAD_CLIENT_DISCONNECT); + /* test that all invalid/unknown frame types are handled */ + for (int i = 10; i <= 255; i++) { + std::string unknown_frame_string; + unknown_frame_string.append("\x01\x01\x01", sizeof("\x00\x00\x00") - 1); + char frame_type = static_cast(i); + unknown_frame_string.append(&frame_type, 1); + unknown_frame_string.append("\x01\x02\x03\x04\x05", + sizeof("\x00\x00\x00\x00\x01") - 1); + grpc_bad_client_arg args[2]; + args[0] = connection_preface_arg; + args[1].client_validator = nullptr; + args[1].client_payload = unknown_frame_string.c_str(); + args[1].client_payload_length = unknown_frame_string.size(); + grpc_run_bad_client_test(verifier, args, 2, GRPC_BAD_CLIENT_DISCONNECT); + } grpc_shutdown(); return 0; diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index a479a00509a..6e31e5fdd30 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -5276,7 +5276,7 @@ ], "headers": [], "is_filegroup": false, - "language": "c", + "language": "c++", "name": "badreq_bad_client_test", "src": [ "test/core/bad_client/tests/badreq.cc" @@ -5293,7 +5293,7 @@ ], "headers": [], "is_filegroup": false, - "language": "c", + "language": "c++", "name": "connection_prefix_bad_client_test", "src": [ "test/core/bad_client/tests/connection_prefix.cc" @@ -5310,7 +5310,7 @@ ], "headers": [], "is_filegroup": false, - "language": "c", + "language": "c++", "name": "duplicate_header_bad_client_test", "src": [ "test/core/bad_client/tests/duplicate_header.cc" @@ -5327,7 +5327,7 @@ ], "headers": [], "is_filegroup": false, - "language": "c", + "language": "c++", "name": "head_of_line_blocking_bad_client_test", "src": [ "test/core/bad_client/tests/head_of_line_blocking.cc" @@ -5344,7 +5344,7 @@ ], "headers": [], "is_filegroup": false, - "language": "c", + "language": "c++", "name": "headers_bad_client_test", "src": [ "test/core/bad_client/tests/headers.cc" @@ -5361,7 +5361,7 @@ ], "headers": [], "is_filegroup": false, - "language": "c", + "language": "c++", "name": "initial_settings_frame_bad_client_test", "src": [ "test/core/bad_client/tests/initial_settings_frame.cc" @@ -5378,7 +5378,7 @@ ], "headers": [], "is_filegroup": false, - "language": "c", + "language": "c++", "name": "large_metadata_bad_client_test", "src": [ "test/core/bad_client/tests/large_metadata.cc" @@ -5395,7 +5395,7 @@ ], "headers": [], "is_filegroup": false, - "language": "c", + "language": "c++", "name": "server_registered_method_bad_client_test", "src": [ "test/core/bad_client/tests/server_registered_method.cc" @@ -5412,7 +5412,7 @@ ], "headers": [], "is_filegroup": false, - "language": "c", + "language": "c++", "name": "simple_request_bad_client_test", "src": [ "test/core/bad_client/tests/simple_request.cc" @@ -5429,7 +5429,7 @@ ], "headers": [], "is_filegroup": false, - "language": "c", + "language": "c++", "name": "unknown_frame_bad_client_test", "src": [ "test/core/bad_client/tests/unknown_frame.cc" @@ -5446,7 +5446,7 @@ ], "headers": [], "is_filegroup": false, - "language": "c", + "language": "c++", "name": "window_overflow_bad_client_test", "src": [ "test/core/bad_client/tests/window_overflow.cc" @@ -7740,7 +7740,7 @@ "test/core/bad_client/bad_client.h" ], "is_filegroup": false, - "language": "c", + "language": "c++", "name": "bad_client_test", "src": [ "test/core/bad_client/bad_client.cc", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 473e2e26c3a..37a69a47b23 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -5934,7 +5934,7 @@ ], "flaky": false, "gtest": false, - "language": "c", + "language": "c++", "name": "badreq_bad_client_test", "platforms": [ "linux", @@ -5960,7 +5960,7 @@ ], "flaky": false, "gtest": false, - "language": "c", + "language": "c++", "name": "connection_prefix_bad_client_test", "platforms": [ "linux", @@ -5986,7 +5986,7 @@ ], "flaky": false, "gtest": false, - "language": "c", + "language": "c++", "name": "duplicate_header_bad_client_test", "platforms": [ "linux", @@ -6012,7 +6012,7 @@ ], "flaky": false, "gtest": false, - "language": "c", + "language": "c++", "name": "head_of_line_blocking_bad_client_test", "platforms": [ "linux", @@ -6038,7 +6038,7 @@ ], "flaky": false, "gtest": false, - "language": "c", + "language": "c++", "name": "headers_bad_client_test", "platforms": [ "linux", @@ -6064,7 +6064,7 @@ ], "flaky": false, "gtest": false, - "language": "c", + "language": "c++", "name": "initial_settings_frame_bad_client_test", "platforms": [ "linux", @@ -6090,7 +6090,7 @@ ], "flaky": false, "gtest": false, - "language": "c", + "language": "c++", "name": "large_metadata_bad_client_test", "platforms": [ "linux", @@ -6116,7 +6116,7 @@ ], "flaky": false, "gtest": false, - "language": "c", + "language": "c++", "name": "server_registered_method_bad_client_test", "platforms": [ "linux", @@ -6142,7 +6142,7 @@ ], "flaky": false, "gtest": false, - "language": "c", + "language": "c++", "name": "simple_request_bad_client_test", "platforms": [ "linux", @@ -6168,7 +6168,7 @@ ], "flaky": false, "gtest": false, - "language": "c", + "language": "c++", "name": "unknown_frame_bad_client_test", "platforms": [ "linux", @@ -6194,7 +6194,7 @@ ], "flaky": false, "gtest": false, - "language": "c", + "language": "c++", "name": "window_overflow_bad_client_test", "platforms": [ "linux", From cd848e17f21e547bef8895946756520fc2794dda Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 6 Jun 2019 12:58:34 -0700 Subject: [PATCH 0457/1555] Bump up the Cython version to 0.29.8 --- requirements.bazel.txt | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.bazel.txt b/requirements.bazel.txt index e2618c950f3..4d52beb9e11 100644 --- a/requirements.bazel.txt +++ b/requirements.bazel.txt @@ -1,6 +1,6 @@ # GRPC Python setup requirements coverage>=4.0 -cython>=0.28.3 +cython>=0.29.8 enum34>=1.0.4 protobuf>=3.5.0.post1 six>=1.10 diff --git a/requirements.txt b/requirements.txt index f583fc94eb4..27dd7d9f63b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ # GRPC Python setup requirements coverage>=4.0 -cython>=0.28.3 +cython>=0.29.8 enum34>=1.0.4 protobuf>=3.5.0.post1 six>=1.10 From d30d538dbab5fd5f19edad59dd6282e515bb85a3 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Thu, 6 Jun 2019 13:56:46 -0700 Subject: [PATCH 0458/1555] Move math_server.js out of examples/ directory --- src/php/README.md | 4 ++-- .../php/tests/generated_code}/math_server.js | 2 +- src/php/tests/generated_code/package.json | 11 +++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) rename {examples/node/dynamic_codegen => src/php/tests/generated_code}/math_server.js (97%) create mode 100644 src/php/tests/generated_code/package.json diff --git a/src/php/README.md b/src/php/README.md index 69f4bbf42c2..dde6152cfce 100644 --- a/src/php/README.md +++ b/src/php/README.md @@ -294,9 +294,9 @@ Run a local server serving the math services. Please see [Node][] for how to run an example server. ```sh -$ cd grpc/examples/node +$ cd grpc/src/php/tests/generated_code $ npm install -$ node dynamic_codegen/math_server.js +$ node math_server.js ``` ### Run test client diff --git a/examples/node/dynamic_codegen/math_server.js b/src/php/tests/generated_code/math_server.js similarity index 97% rename from examples/node/dynamic_codegen/math_server.js rename to src/php/tests/generated_code/math_server.js index d4eb310fc88..1492c936e13 100644 --- a/examples/node/dynamic_codegen/math_server.js +++ b/src/php/tests/generated_code/math_server.js @@ -16,7 +16,7 @@ * */ -var PROTO_PATH = __dirname + '/../../../src/proto/math/math.proto'; +var PROTO_PATH = __dirname + '/../../../proto/math/math.proto'; var grpc = require('grpc'); var protoLoader = require('@grpc/proto-loader'); diff --git a/src/php/tests/generated_code/package.json b/src/php/tests/generated_code/package.json new file mode 100644 index 00000000000..318ef4fd01f --- /dev/null +++ b/src/php/tests/generated_code/package.json @@ -0,0 +1,11 @@ +{ + "name": "grpc-examples", + "version": "0.1.0", + "dependencies": { + "@grpc/proto-loader": "^0.1.0", + "async": "^1.5.2", + "grpc": "^1.11.0", + "lodash": "^4.6.1", + "minimist": "^1.2.0" + } +} From 3b61d3efa3f3d3b4b4e9f4feed45a3e859fc827a Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Thu, 6 Jun 2019 14:05:08 -0700 Subject: [PATCH 0459/1555] Further simplify package.json --- src/php/tests/generated_code/package.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/php/tests/generated_code/package.json b/src/php/tests/generated_code/package.json index 318ef4fd01f..5cc28be35d2 100644 --- a/src/php/tests/generated_code/package.json +++ b/src/php/tests/generated_code/package.json @@ -3,9 +3,6 @@ "version": "0.1.0", "dependencies": { "@grpc/proto-loader": "^0.1.0", - "async": "^1.5.2", - "grpc": "^1.11.0", - "lodash": "^4.6.1", - "minimist": "^1.2.0" + "grpc": "^1.11.0" } } From 46e3df3dead7d5f26094c65323ff19eb18859d93 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 4 Jun 2019 07:22:24 -0400 Subject: [PATCH 0460/1555] php interop client: construct channel target like other languages do --- src/php/tests/interop/interop_client.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php index 19cbf21bc2b..e4750475dc5 100755 --- a/src/php/tests/interop/interop_client.php +++ b/src/php/tests/interop/interop_client.php @@ -530,12 +530,7 @@ function _makeStub($args) throw new Exception('Missing argument: --test_case is required'); } - if ($args['server_port'] === '443') { - $server_address = $args['server_host']; - } else { - $server_address = $args['server_host'].':'.$args['server_port']; - } - + $server_address = $args['server_host'].':'.$args['server_port']; $test_case = $args['test_case']; $host_override = ''; From 3b742f1fabdc6d09ecf81ebd5b527b1b49dac57f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 4 Jun 2019 10:27:59 -0400 Subject: [PATCH 0461/1555] remove port suffix from JWT audience --- src/php/lib/Grpc/BaseStub.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/php/lib/Grpc/BaseStub.php b/src/php/lib/Grpc/BaseStub.php index fe81e377610..1d2c30341dd 100644 --- a/src/php/lib/Grpc/BaseStub.php +++ b/src/php/lib/Grpc/BaseStub.php @@ -199,6 +199,13 @@ class BaseStub */ private function _get_jwt_aud_uri($method) { + // TODO(jtattermusch): This is not the correct implementation + // of extracting JWT "aud" claim. We should rely on + // grpc_metadata_credentials_plugin which + // also provides the correct value of "aud" claim + // in the grpc_auth_metadata_context.service_url field. + // Trying to do the construction of "aud" field ourselves + // is bad. $last_slash_idx = strrpos($method, '/'); if ($last_slash_idx === false) { throw new \InvalidArgumentException( @@ -213,6 +220,12 @@ class BaseStub $hostname = $this->hostname; } + // Remove the port if it is 443 + // See https://github.com/grpc/grpc/blob/07c9f7a36b2a0d34fcffebc85649cf3b8c339b5d/src/core/lib/security/transport/client_auth_filter.cc#L205 + if ((strlen($hostname) > 4) && (substr($hostname, -4) === ":443")) { + $hostname = substr($hostname, 0, -4); + } + return 'https://'.$hostname.$service_name; } From 195aae6cb5c56dd119b358586c44c5569529aa63 Mon Sep 17 00:00:00 2001 From: Lily Li Date: Thu, 6 Jun 2019 16:34:48 -0700 Subject: [PATCH 0462/1555] add compatibility check badge to README --- src/python/grpcio/README.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/python/grpcio/README.rst b/src/python/grpcio/README.rst index 07c94342de1..c7c6aa497d5 100644 --- a/src/python/grpcio/README.rst +++ b/src/python/grpcio/README.rst @@ -1,8 +1,13 @@ gRPC Python =========== +|compat_check_pypi| + Package for gRPC Python. +.. |compat_check_pypi| image:: https://python-compatibility-tools.appspot.com/one_badge_image?package=grpcio + :target: https://python-compatibility-tools.appspot.com/one_badge_target?package=grpcio + Supported Python Versions ------------------------- Python >= 3.5 From 597a67a2b57364d7e8336fe1cccb2ae03cec25b8 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 6 Jun 2019 18:18:30 -0700 Subject: [PATCH 0463/1555] Covert to GTEST --- test/core/bad_client/generate_tests.bzl | 4 ++++ test/core/bad_client/tests/unknown_frame.cc | 25 +++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/test/core/bad_client/generate_tests.bzl b/test/core/bad_client/generate_tests.bzl index 2769d5c3bb6..9ff55877c53 100755 --- a/test/core/bad_client/generate_tests.bzl +++ b/test/core/bad_client/generate_tests.bzl @@ -42,6 +42,10 @@ def grpc_bad_client_tests(): name = 'bad_client_test', srcs = ['bad_client.cc'], hdrs = ['bad_client.h'], + external_deps = [ + "gtest", + ], + language = "C++", deps = ['//test/core/util:grpc_test_util', '//:grpc', '//:gpr', '//test/core/end2end:cq_verifier'] ) for t, topt in BAD_CLIENT_TESTS.items(): diff --git a/test/core/bad_client/tests/unknown_frame.cc b/test/core/bad_client/tests/unknown_frame.cc index fa29ace2e35..a9f56548c2a 100644 --- a/test/core/bad_client/tests/unknown_frame.cc +++ b/test/core/bad_client/tests/unknown_frame.cc @@ -18,6 +18,8 @@ #include +#include + #include #include "src/core/lib/surface/server.h" #include "test/core/bad_client/bad_client.h" @@ -31,17 +33,15 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq, } } -int main(int argc, char** argv) { - grpc_init(); - grpc::testing::TestEnvironment env(argc, argv); - +namespace { +TEST(UnknownFrameType, Test) { /* test that all invalid/unknown frame types are handled */ for (int i = 10; i <= 255; i++) { std::string unknown_frame_string; - unknown_frame_string.append("\x01\x01\x01", sizeof("\x00\x00\x00") - 1); + unknown_frame_string.append("\x00\x00\x00", sizeof("\x00\x00\x00") - 1); char frame_type = static_cast(i); unknown_frame_string.append(&frame_type, 1); - unknown_frame_string.append("\x01\x02\x03\x04\x05", + unknown_frame_string.append("\x00\x00\x00\x00\x01", sizeof("\x00\x00\x00\x00\x01") - 1); grpc_bad_client_arg args[2]; args[0] = connection_preface_arg; @@ -50,7 +50,14 @@ int main(int argc, char** argv) { args[1].client_payload_length = unknown_frame_string.size(); grpc_run_bad_client_test(verifier, args, 2, GRPC_BAD_CLIENT_DISCONNECT); } - - grpc_shutdown(); - return 0; +} +} // namespace + +int main(int argc, char** argv) { + grpc_init(); + grpc::testing::TestEnvironment env(argc, argv); + ::testing::InitGoogleTest(&argc, argv); + int retval = RUN_ALL_TESTS(); + grpc_shutdown(); + return retval; } From b015b437bb279e8ea4d469fed49b6c9d70276bd6 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Thu, 6 Jun 2019 22:59:49 -0700 Subject: [PATCH 0464/1555] Bump version to v1.21.4-pre1 --- BUILD | 2 +- build.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index af1d7847cef..894516243e4 100644 --- a/BUILD +++ b/BUILD @@ -78,7 +78,7 @@ g_stands_for = "gandalf" core_version = "7.0.0" -version = "1.21.3" +version = "1.21.4-pre1" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index d9a72738f48..0d3ce2406bb 100644 --- a/build.yaml +++ b/build.yaml @@ -14,7 +14,7 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 7.0.0 g_stands_for: gandalf - version: 1.21.3 + version: 1.21.4-pre1 filegroups: - name: alts_proto headers: From 40a914e8466c621283570037a7fd9cbc0dd634d2 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Thu, 6 Jun 2019 23:00:48 -0700 Subject: [PATCH 0465/1555] Re-generate projects; --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 6 +++--- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 8 ++++---- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 4 ++-- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/composer.json | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 30 files changed, 37 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f01e790264..0bb9b9312b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.21.3") +set(PACKAGE_VERSION "1.21.4-pre1") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index fd29aa3fc73..ec7f34dc57a 100644 --- a/Makefile +++ b/Makefile @@ -460,8 +460,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.21.3 -CSHARP_VERSION = 1.21.3 +CPP_VERSION = 1.21.4-pre1 +CSHARP_VERSION = 1.21.4-pre1 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 1fdd6423a7e..5e65031a6f4 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,15 +23,15 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.21.3' - version = '0.0.9' + # version = '1.21.4-pre1' + version = '0.0.9-pre1' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.21.3' + grpc_version = '1.21.4-pre1' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 061d3a27504..901d91173a8 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.21.3' + version = '1.21.4-pre1' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index c38719b7d52..9c1bb7881be 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.21.3' + version = '1.21.4-pre1' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 20f93164969..0b7ba325e35 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.21.3' + version = '1.21.4-pre1' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index e268a8b21aa..5b57e7270f3 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.21.3' + version = '1.21.4-pre1' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index f03c4e694d8..8f528b8f721 100644 --- a/package.xml +++ b/package.xml @@ -13,12 +13,12 @@ 2018-01-19 - 1.21.3 - 1.21.3 + 1.21.4RC1 + 1.21.4RC1 - stable - stable + beta + beta Apache 2.0 diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 98c1ba34470..6fb5d2f23be 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.21.3"; } +grpc::string Version() { return "1.21.4-pre1"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index 3d4bdd9ee78..d7a68c43ffc 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -33,11 +33,11 @@ namespace Grpc.Core /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "1.21.3.0"; + public const string CurrentAssemblyFileVersion = "1.21.4.0"; /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.21.3"; + public const string CurrentVersion = "1.21.4-pre1"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index 949b683ccb5..bcab16551ff 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 1.21.3 + 1.21.4-pre1 3.7.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index a371568fab8..6852a761d6a 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=1.21.3 +set VERSION=1.21.4-pre1 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index c4b588824de..cf558c97c13 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.21.3' + v = '1.21.4-pre1' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 20cf2ac4811..b5385b26a43 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.3" +#define GRPC_OBJC_VERSION_STRING @"1.21.4-pre1" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 0aa72ca70da..38cf3d9585c 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.3" +#define GRPC_OBJC_VERSION_STRING @"1.21.4-pre1" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/composer.json b/src/php/composer.json index 48dfde56d86..1369fd34bc6 100644 --- a/src/php/composer.json +++ b/src/php/composer.json @@ -2,7 +2,7 @@ "name": "grpc/grpc-dev", "description": "gRPC library for PHP - for Developement use only", "license": "Apache-2.0", - "version": "1.21.3", + "version": "1.21.4", "require": { "php": ">=5.5.0", "google/protobuf": "^v3.3.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index d401a7d2095..78e627e70f0 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.21.3" +#define PHP_GRPC_VERSION "1.21.4RC1" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index ea4600f7d0a..b54340e02e4 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.21.3""" +__version__ = """1.21.4rc1""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index ad12bf478ed..ef2cab7665f 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.21.3' +VERSION = '1.21.4rc1' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index 73ecfb1c3c7..9a3b2997b40 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.21.3' +VERSION = '1.21.4rc1' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index c26d3697972..a3fe3a2bed5 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.21.3' +VERSION = '1.21.4rc1' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index b434ba9422e..f835fd96941 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.21.3' +VERSION = '1.21.4rc1' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index 4516db48837..e6825a4545c 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.21.3' +VERSION = '1.21.4rc1' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 735c66a9081..fa200e63a13 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.21.3' +VERSION = '1.21.4rc1' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index ab2507f2c94..f3e90cef876 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.21.3' +VERSION = '1.21.4rc1' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 55b26e434a6..987be56d824 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.21.3' + VERSION = '1.21.4.pre1' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index 4effc70d476..e53b605d1fb 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.21.3' + VERSION = '1.21.4.pre1' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index bb7110142ae..ff2dc093b0a 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.21.3' +VERSION = '1.21.4rc1' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 15f82e95211..d6a55647d75 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.3 +PROJECT_NUMBER = 1.21.4-pre1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 63614418486..ce404fca6dd 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.3 +PROJECT_NUMBER = 1.21.4-pre1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From e8800dc1dce557c0f83e08027a3d72af0cfceef3 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Fri, 7 Jun 2019 01:29:01 -0700 Subject: [PATCH 0466/1555] Bump to version v1.21.4 --- BUILD | 2 +- build.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index 894516243e4..534c203dc3d 100644 --- a/BUILD +++ b/BUILD @@ -78,7 +78,7 @@ g_stands_for = "gandalf" core_version = "7.0.0" -version = "1.21.4-pre1" +version = "1.21.4" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index 0d3ce2406bb..03d0275cc9c 100644 --- a/build.yaml +++ b/build.yaml @@ -14,7 +14,7 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 7.0.0 g_stands_for: gandalf - version: 1.21.4-pre1 + version: 1.21.4 filegroups: - name: alts_proto headers: From 795e31a84bdf30d4dfe40dd5aa1ec71587ca172b Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Fri, 7 Jun 2019 01:29:45 -0700 Subject: [PATCH 0467/1555] Re-generate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 6 +++--- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 8 ++++---- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 2 +- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 29 files changed, 35 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0bb9b9312b2..6c936b1f5db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.21.4-pre1") +set(PACKAGE_VERSION "1.21.4") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index ec7f34dc57a..2dbb86a679f 100644 --- a/Makefile +++ b/Makefile @@ -460,8 +460,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.21.4-pre1 -CSHARP_VERSION = 1.21.4-pre1 +CPP_VERSION = 1.21.4 +CSHARP_VERSION = 1.21.4 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 5e65031a6f4..2be3fdf9fdd 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,15 +23,15 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.21.4-pre1' - version = '0.0.9-pre1' + # version = '1.21.4' + version = '0.0.9' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.21.4-pre1' + grpc_version = '1.21.4' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 901d91173a8..46715bc8715 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.21.4-pre1' + version = '1.21.4' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 9c1bb7881be..49004350d28 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.21.4-pre1' + version = '1.21.4' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 0b7ba325e35..ea440649c72 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.21.4-pre1' + version = '1.21.4' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index 5b57e7270f3..1901d00c372 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.21.4-pre1' + version = '1.21.4' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index 8f528b8f721..6a7a49929b1 100644 --- a/package.xml +++ b/package.xml @@ -13,12 +13,12 @@ 2018-01-19 - 1.21.4RC1 - 1.21.4RC1 + 1.21.4 + 1.21.4 - beta - beta + stable + stable Apache 2.0 diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 6fb5d2f23be..cc238901a74 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.21.4-pre1"; } +grpc::string Version() { return "1.21.4"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index d7a68c43ffc..3c6d92354bf 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -38,6 +38,6 @@ namespace Grpc.Core /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.21.4-pre1"; + public const string CurrentVersion = "1.21.4"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index bcab16551ff..a51f6f9acca 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 1.21.4-pre1 + 1.21.4 3.7.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index 6852a761d6a..214db46b787 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=1.21.4-pre1 +set VERSION=1.21.4 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index cf558c97c13..9aba47a3c67 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.21.4-pre1' + v = '1.21.4' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index b5385b26a43..87791c04498 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.4-pre1" +#define GRPC_OBJC_VERSION_STRING @"1.21.4" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 38cf3d9585c..8f1b5c75983 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.21.4-pre1" +#define GRPC_OBJC_VERSION_STRING @"1.21.4" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 78e627e70f0..2ec4cd814a6 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.21.4RC1" +#define PHP_GRPC_VERSION "1.21.4" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index b54340e02e4..8f794a197e9 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.21.4rc1""" +__version__ = """1.21.4""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index ef2cab7665f..e31c9ba513a 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.21.4rc1' +VERSION = '1.21.4' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index 9a3b2997b40..1c80bec0ab2 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.21.4rc1' +VERSION = '1.21.4' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index a3fe3a2bed5..20fd62b19a1 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.21.4rc1' +VERSION = '1.21.4' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index f835fd96941..7d0b5feb9b2 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.21.4rc1' +VERSION = '1.21.4' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index e6825a4545c..8cfbf946b07 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.21.4rc1' +VERSION = '1.21.4' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index fa200e63a13..73f1e1484c5 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.21.4rc1' +VERSION = '1.21.4' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index f3e90cef876..2497489a049 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.21.4rc1' +VERSION = '1.21.4' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 987be56d824..46dfae0919e 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.21.4.pre1' + VERSION = '1.21.4' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index e53b605d1fb..697e166eada 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.21.4.pre1' + VERSION = '1.21.4' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index ff2dc093b0a..4b72433b70f 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.21.4rc1' +VERSION = '1.21.4' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index d6a55647d75..b99ee5e30d2 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.4-pre1 +PROJECT_NUMBER = 1.21.4 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index ce404fca6dd..00e9cad77f4 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.21.4-pre1 +PROJECT_NUMBER = 1.21.4 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From cfb31818ef40c401dd50bd4a20492ff2812472d3 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 7 Jun 2019 07:09:39 -0700 Subject: [PATCH 0468/1555] Remove channelz from LB policy API. --- .../filters/client_channel/client_channel.cc | 105 +++++++---- .../filters/client_channel/client_channel.h | 8 - .../client_channel/client_channel_channelz.cc | 83 --------- .../client_channel/client_channel_channelz.h | 30 +--- .../client_channel/client_channel_plugin.cc | 8 - .../ext/filters/client_channel/lb_policy.h | 28 +-- .../client_channel/lb_policy/grpclb/grpclb.cc | 101 ++++------- .../lb_policy/pick_first/pick_first.cc | 59 ------ .../lb_policy/round_robin/round_robin.cc | 58 ------ .../lb_policy/subchannel_list.h | 13 -- .../client_channel/lb_policy/xds/xds.cc | 170 ++++++------------ .../client_channel/resolving_lb_policy.cc | 83 +++------ .../client_channel/resolving_lb_policy.h | 8 - .../client_channel/subchannel_interface.h | 10 +- src/core/lib/channel/channelz.cc | 155 ++++++++++++++-- src/core/lib/channel/channelz.h | 76 ++++---- src/core/lib/surface/channel.cc | 133 +++++++++----- src/core/lib/surface/channel.h | 4 +- test/core/channel/channel_trace_test.cc | 11 +- test/core/channel/channelz_test.cc | 3 +- test/core/util/test_lb_policies.cc | 10 +- test/cpp/end2end/channelz_service_test.cc | 3 +- 22 files changed, 466 insertions(+), 693 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 6b6045c98f6..81562ab2107 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -118,18 +118,6 @@ class ChannelData { static void GetChannelInfo(grpc_channel_element* elem, const grpc_channel_info* info); - void set_channelz_node(channelz::ClientChannelNode* node) { - channelz_node_ = node; - resolving_lb_policy_->set_channelz_node(node->Ref()); - } - void FillChildRefsForChannelz(channelz::ChildRefsList* child_subchannels, - channelz::ChildRefsList* child_channels) { - if (resolving_lb_policy_ != nullptr) { - resolving_lb_policy_->FillChildRefsForChannelz(child_subchannels, - child_channels); - } - } - bool deadline_checking_enabled() const { return deadline_checking_enabled_; } bool enable_retries() const { return enable_retries_; } size_t per_rpc_retry_buffer_size() const { @@ -249,8 +237,7 @@ class ChannelData { ClientChannelFactory* client_channel_factory_; UniquePtr server_name_; RefCountedPtr default_service_config_; - // Initialized shortly after construction. - channelz::ClientChannelNode* channelz_node_ = nullptr; + channelz::ChannelNode* channelz_node_; // // Fields used in the data plane. Guarded by data_plane_combiner. @@ -269,12 +256,13 @@ class ChannelData { grpc_combiner* combiner_; grpc_pollset_set* interested_parties_; RefCountedPtr subchannel_pool_; - OrphanablePtr resolving_lb_policy_; + OrphanablePtr resolving_lb_policy_; grpc_connectivity_state_tracker state_tracker_; ExternalConnectivityWatcher::WatcherList external_connectivity_watcher_list_; UniquePtr health_check_service_name_; RefCountedPtr saved_service_config_; bool received_first_resolver_result_ = false; + Map subchannel_refcount_map_; // // Fields accessed from both data plane and control plane combiners. @@ -735,6 +723,7 @@ class ChannelData::ConnectivityStateAndPickerSetter { // Update connectivity state here, while holding control plane combiner. grpc_connectivity_state_set(&chand->state_tracker_, state, reason); if (chand->channelz_node_ != nullptr) { + chand->channelz_node_->SetConnectivityState(state); chand->channelz_node_->AddTraceEvent( channelz::ChannelTrace::Severity::Info, grpc_slice_from_static_string( @@ -971,12 +960,39 @@ void ChannelData::ExternalConnectivityWatcher::WatchConnectivityStateLocked( // control plane combiner. class ChannelData::GrpcSubchannel : public SubchannelInterface { public: - GrpcSubchannel(Subchannel* subchannel, + GrpcSubchannel(ChannelData* chand, Subchannel* subchannel, UniquePtr health_check_service_name) - : subchannel_(subchannel), - health_check_service_name_(std::move(health_check_service_name)) {} + : chand_(chand), + subchannel_(subchannel), + health_check_service_name_(std::move(health_check_service_name)) { + GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "GrpcSubchannel"); + auto* subchannel_node = subchannel_->channelz_node(); + if (subchannel_node != nullptr) { + intptr_t subchannel_uuid = subchannel_node->uuid(); + auto it = chand_->subchannel_refcount_map_.find(subchannel_); + if (it == chand_->subchannel_refcount_map_.end()) { + chand_->channelz_node_->AddChildSubchannel(subchannel_uuid); + it = chand_->subchannel_refcount_map_.emplace(subchannel_, 0).first; + } + ++it->second; + } + } - ~GrpcSubchannel() { GRPC_SUBCHANNEL_UNREF(subchannel_, "unref from LB"); } + ~GrpcSubchannel() { + auto* subchannel_node = subchannel_->channelz_node(); + if (subchannel_node != nullptr) { + intptr_t subchannel_uuid = subchannel_node->uuid(); + auto it = chand_->subchannel_refcount_map_.find(subchannel_); + GPR_ASSERT(it != chand_->subchannel_refcount_map_.end()); + --it->second; + if (it->second == 0) { + chand_->channelz_node_->RemoveChildSubchannel(subchannel_uuid); + chand_->subchannel_refcount_map_.erase(it); + } + } + GRPC_SUBCHANNEL_UNREF(subchannel_, "unref from LB"); + GRPC_CHANNEL_STACK_UNREF(chand_->owning_stack_, "GrpcSubchannel"); + } grpc_connectivity_state CheckConnectivityState( RefCountedPtr* connected_subchannel) @@ -1005,13 +1021,10 @@ class ChannelData::GrpcSubchannel : public SubchannelInterface { void AttemptToConnect() override { subchannel_->AttemptToConnect(); } - channelz::SubchannelNode* channelz_node() override { - return subchannel_->channelz_node(); - } - void ResetBackoff() override { subchannel_->ResetBackoff(); } private: + ChannelData* chand_; Subchannel* subchannel_; UniquePtr health_check_service_name_; }; @@ -1041,7 +1054,10 @@ class ChannelData::ClientChannelControlHelper health_check_service_name.reset( gpr_strdup(chand_->health_check_service_name_.get())); } - static const char* args_to_remove[] = {GRPC_ARG_INHIBIT_HEALTH_CHECKING}; + static const char* args_to_remove[] = { + GRPC_ARG_INHIBIT_HEALTH_CHECKING, + GRPC_ARG_CHANNELZ_CHANNEL_NODE, + }; grpc_arg arg = SubchannelPoolInterface::CreateChannelArg( chand_->subchannel_pool_.get()); grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove( @@ -1050,7 +1066,7 @@ class ChannelData::ClientChannelControlHelper chand_->client_channel_factory_->CreateSubchannel(new_args); grpc_channel_args_destroy(new_args); if (subchannel == nullptr) return nullptr; - return MakeRefCounted(subchannel, + return MakeRefCounted(chand_, subchannel, std::move(health_check_service_name)); } @@ -1082,7 +1098,22 @@ class ChannelData::ClientChannelControlHelper // No-op -- we should never get this from ResolvingLoadBalancingPolicy. void RequestReresolution() override {} + void AddTraceEvent(TraceSeverity severity, const char* message) override { + if (chand_->channelz_node_ != nullptr) { + chand_->channelz_node_->AddTraceEvent( + ConvertSeverityEnum(severity), + grpc_slice_from_copied_string(message)); + } + } + private: + static channelz::ChannelTrace::Severity ConvertSeverityEnum( + TraceSeverity severity) { + if (severity == TRACE_INFO) return channelz::ChannelTrace::Info; + if (severity == TRACE_WARNING) return channelz::ChannelTrace::Warning; + return channelz::ChannelTrace::Error; + } + ChannelData* chand_; }; @@ -1125,6 +1156,15 @@ RefCountedPtr GetSubchannelPool( return GlobalSubchannelPool::instance(); } +channelz::ChannelNode* GetChannelzNode(const grpc_channel_args* args) { + const grpc_arg* arg = + grpc_channel_args_find(args, GRPC_ARG_CHANNELZ_CHANNEL_NODE); + if (arg != nullptr && arg->type == GRPC_ARG_POINTER) { + return static_cast(arg->value.pointer.p); + } + return nullptr; +} + ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error) : deadline_checking_enabled_( grpc_deadline_checking_enabled(args->channel_args)), @@ -1134,6 +1174,7 @@ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error) owning_stack_(args->channel_stack), client_channel_factory_( ClientChannelFactory::GetFromChannelArgs(args->channel_args)), + channelz_node_(GetChannelzNode(args->channel_args)), data_plane_combiner_(grpc_combiner_create()), combiner_(grpc_combiner_create()), interested_parties_(grpc_pollset_set_create()), @@ -3532,20 +3573,6 @@ const grpc_channel_filter grpc_client_channel_filter = { "client-channel", }; -void grpc_client_channel_set_channelz_node( - grpc_channel_element* elem, grpc_core::channelz::ClientChannelNode* node) { - auto* chand = static_cast(elem->channel_data); - chand->set_channelz_node(node); -} - -void grpc_client_channel_populate_child_refs( - grpc_channel_element* elem, - grpc_core::channelz::ChildRefsList* child_subchannels, - grpc_core::channelz::ChildRefsList* child_channels) { - auto* chand = static_cast(elem->channel_data); - chand->FillChildRefsForChannelz(child_subchannels, child_channels); -} - grpc_connectivity_state grpc_client_channel_check_connectivity_state( grpc_channel_element* elem, int try_to_connect) { auto* chand = static_cast(elem->channel_data); diff --git a/src/core/ext/filters/client_channel/client_channel.h b/src/core/ext/filters/client_channel/client_channel.h index 5bfff4df9cd..caaa079dd9b 100644 --- a/src/core/ext/filters/client_channel/client_channel.h +++ b/src/core/ext/filters/client_channel/client_channel.h @@ -40,14 +40,6 @@ extern grpc_core::TraceFlag grpc_client_channel_trace; extern const grpc_channel_filter grpc_client_channel_filter; -void grpc_client_channel_set_channelz_node( - grpc_channel_element* elem, grpc_core::channelz::ClientChannelNode* node); - -void grpc_client_channel_populate_child_refs( - grpc_channel_element* elem, - grpc_core::channelz::ChildRefsList* child_subchannels, - grpc_core::channelz::ChildRefsList* child_channels); - grpc_connectivity_state grpc_client_channel_check_connectivity_state( grpc_channel_element* elem, int try_to_connect); diff --git a/src/core/ext/filters/client_channel/client_channel_channelz.cc b/src/core/ext/filters/client_channel/client_channel_channelz.cc index de61819ef54..e068d11dc41 100644 --- a/src/core/ext/filters/client_channel/client_channel_channelz.cc +++ b/src/core/ext/filters/client_channel/client_channel_channelz.cc @@ -29,89 +29,6 @@ namespace grpc_core { namespace channelz { -namespace { - -void* client_channel_channelz_copy(void* p) { return p; } - -void client_channel_channelz_destroy(void* p) {} - -int client_channel_channelz_cmp(void* a, void* b) { return GPR_ICMP(a, b); } - -} // namespace - -static const grpc_arg_pointer_vtable client_channel_channelz_vtable = { - client_channel_channelz_copy, client_channel_channelz_destroy, - client_channel_channelz_cmp}; - -ClientChannelNode::ClientChannelNode(grpc_channel* channel, - size_t channel_tracer_max_nodes, - bool is_top_level_channel) - : ChannelNode(channel, channel_tracer_max_nodes, is_top_level_channel) { - client_channel_ = - grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel)); - GPR_ASSERT(client_channel_->filter == &grpc_client_channel_filter); - grpc_client_channel_set_channelz_node(client_channel_, this); -} - -void ClientChannelNode::PopulateConnectivityState(grpc_json* json) { - grpc_connectivity_state state; - if (ChannelIsDestroyed()) { - state = GRPC_CHANNEL_SHUTDOWN; - } else { - state = - grpc_client_channel_check_connectivity_state(client_channel_, false); - } - json = grpc_json_create_child(nullptr, json, "state", nullptr, - GRPC_JSON_OBJECT, false); - grpc_json_create_child(nullptr, json, "state", - grpc_connectivity_state_name(state), GRPC_JSON_STRING, - false); -} - -void ClientChannelNode::PopulateChildRefs(grpc_json* json) { - ChildRefsList child_subchannels; - ChildRefsList child_channels; - grpc_json* json_iterator = nullptr; - grpc_client_channel_populate_child_refs(client_channel_, &child_subchannels, - &child_channels); - if (!child_subchannels.empty()) { - grpc_json* array_parent = grpc_json_create_child( - nullptr, json, "subchannelRef", nullptr, GRPC_JSON_ARRAY, false); - for (size_t i = 0; i < child_subchannels.size(); ++i) { - json_iterator = - grpc_json_create_child(json_iterator, array_parent, nullptr, nullptr, - GRPC_JSON_OBJECT, false); - grpc_json_add_number_string_child(json_iterator, nullptr, "subchannelId", - child_subchannels[i]); - } - } - if (!child_channels.empty()) { - grpc_json* array_parent = grpc_json_create_child( - nullptr, json, "channelRef", nullptr, GRPC_JSON_ARRAY, false); - json_iterator = nullptr; - for (size_t i = 0; i < child_channels.size(); ++i) { - json_iterator = - grpc_json_create_child(json_iterator, array_parent, nullptr, nullptr, - GRPC_JSON_OBJECT, false); - grpc_json_add_number_string_child(json_iterator, nullptr, "channelId", - child_channels[i]); - } - } -} - -grpc_arg ClientChannelNode::CreateChannelArg() { - return grpc_channel_arg_pointer_create( - const_cast(GRPC_ARG_CHANNELZ_CHANNEL_NODE_CREATION_FUNC), - reinterpret_cast(MakeClientChannelNode), - &client_channel_channelz_vtable); -} - -RefCountedPtr ClientChannelNode::MakeClientChannelNode( - grpc_channel* channel, size_t channel_tracer_max_nodes, - bool is_top_level_channel) { - return MakeRefCounted(channel, channel_tracer_max_nodes, - is_top_level_channel); -} SubchannelNode::SubchannelNode(Subchannel* subchannel, size_t channel_tracer_max_nodes) diff --git a/src/core/ext/filters/client_channel/client_channel_channelz.h b/src/core/ext/filters/client_channel/client_channel_channelz.h index 9272116882e..9f11e928998 100644 --- a/src/core/ext/filters/client_channel/client_channel_channelz.h +++ b/src/core/ext/filters/client_channel/client_channel_channelz.h @@ -32,32 +32,6 @@ class Subchannel; namespace channelz { -// Subtype of ChannelNode that overrides and provides client_channel specific -// functionality like querying for connectivity_state and subchannel data. -class ClientChannelNode : public ChannelNode { - public: - static RefCountedPtr MakeClientChannelNode( - grpc_channel* channel, size_t channel_tracer_max_nodes, - bool is_top_level_channel); - - ClientChannelNode(grpc_channel* channel, size_t channel_tracer_max_nodes, - bool is_top_level_channel); - virtual ~ClientChannelNode() {} - - // Overriding template methods from ChannelNode to render information that - // only ClientChannelNode knows about. - void PopulateConnectivityState(grpc_json* json) override; - void PopulateChildRefs(grpc_json* json) override; - - // Helper to create a channel arg to ensure this type of ChannelNode is - // created. - static grpc_arg CreateChannelArg(); - - private: - grpc_channel_element* client_channel_; -}; - -// Handles channelz bookkeeping for sockets class SubchannelNode : public BaseNode { public: SubchannelNode(Subchannel* subchannel, size_t channel_tracer_max_nodes); @@ -85,12 +59,12 @@ class SubchannelNode : public BaseNode { void RecordCallSucceeded() { call_counter_.RecordCallSucceeded(); } private: + void PopulateConnectivityState(grpc_json* json); + Subchannel* subchannel_; UniquePtr target_; CallCountingHelper call_counter_; ChannelTrace trace_; - - void PopulateConnectivityState(grpc_json* json); }; } // namespace channelz diff --git a/src/core/ext/filters/client_channel/client_channel_plugin.cc b/src/core/ext/filters/client_channel/client_channel_plugin.cc index 3a7492d82d9..c5662e22a20 100644 --- a/src/core/ext/filters/client_channel/client_channel_plugin.cc +++ b/src/core/ext/filters/client_channel/client_channel_plugin.cc @@ -38,14 +38,6 @@ #include "src/core/lib/surface/channel_init.h" static bool append_filter(grpc_channel_stack_builder* builder, void* arg) { - const grpc_channel_args* args = - grpc_channel_stack_builder_get_channel_arguments(builder); - grpc_arg args_to_add[] = { - grpc_core::channelz::ClientChannelNode::CreateChannelArg()}; - grpc_channel_args* new_args = grpc_channel_args_copy_and_add( - args, args_to_add, GPR_ARRAY_SIZE(args_to_add)); - grpc_channel_stack_builder_set_channel_arguments(builder, new_args); - grpc_channel_args_destroy(new_args); return grpc_channel_stack_builder_append_filter( builder, static_cast(arg), nullptr, nullptr); } diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h index 2cadcc31998..d508932015d 100644 --- a/src/core/ext/filters/client_channel/lb_policy.h +++ b/src/core/ext/filters/client_channel/lb_policy.h @@ -21,7 +21,6 @@ #include -#include "src/core/ext/filters/client_channel/client_channel_channelz.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/ext/filters/client_channel/service_config.h" #include "src/core/ext/filters/client_channel/subchannel_interface.h" @@ -31,6 +30,7 @@ #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/polling_entity.h" #include "src/core/lib/transport/connectivity_state.h" +#include "src/core/lib/transport/metadata_batch.h" namespace grpc_core { @@ -201,6 +201,12 @@ class LoadBalancingPolicy : public InternallyRefCounted { /// Requests that the resolver re-resolve. virtual void RequestReresolution() GRPC_ABSTRACT; + /// Adds a trace message associated with the channel. + /// Does NOT take ownership of \a message. + enum TraceSeverity { TRACE_INFO, TRACE_WARNING, TRACE_ERROR }; + virtual void AddTraceEvent(TraceSeverity severity, + const char* message) GRPC_ABSTRACT; + GRPC_ABSTRACT_BASE_CLASS }; @@ -274,20 +280,6 @@ class LoadBalancingPolicy : public InternallyRefCounted { /// Resets connection backoff. virtual void ResetBackoffLocked() GRPC_ABSTRACT; - /// Populates child_subchannels and child_channels with the uuids of this - /// LB policy's referenced children. - /// - /// This is not invoked from the client_channel's combiner. The - /// implementation is responsible for providing its own synchronization. - virtual void FillChildRefsForChannelz( - channelz::ChildRefsList* child_subchannels, - channelz::ChildRefsList* child_channels) GRPC_ABSTRACT; - - void set_channelz_node( - RefCountedPtr channelz_node) { - channelz_node_ = std::move(channelz_node); - } - grpc_pollset_set* interested_parties() const { return interested_parties_; } void Orphan() override; @@ -333,10 +325,6 @@ class LoadBalancingPolicy : public InternallyRefCounted { return channel_control_helper_.get(); } - channelz::ClientChannelNode* channelz_node() const { - return channelz_node_.get(); - } - /// Shuts down the policy. virtual void ShutdownLocked() GRPC_ABSTRACT; @@ -349,8 +337,6 @@ class LoadBalancingPolicy : public InternallyRefCounted { grpc_pollset_set* interested_parties_; /// Channel control helper. UniquePtr channel_control_helper_; - /// Channelz node. - RefCountedPtr channelz_node_; }; } // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index a3a2a44eb0e..a87dfda7321 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -141,9 +141,6 @@ class GrpcLb : public LoadBalancingPolicy { void UpdateLocked(UpdateArgs args) override; void ResetBackoffLocked() override; - void FillChildRefsForChannelz( - channelz::ChildRefsList* child_subchannels, - channelz::ChildRefsList* child_channels) override; private: /// Contains a call to the LB server and all the data related to the call. @@ -300,6 +297,7 @@ class GrpcLb : public LoadBalancingPolicy { void UpdateState(grpc_connectivity_state state, UniquePtr picker) override; void RequestReresolution() override; + void AddTraceEvent(TraceSeverity severity, const char* message) override; void set_child(LoadBalancingPolicy* child) { child_ = child; } @@ -349,8 +347,6 @@ class GrpcLb : public LoadBalancingPolicy { // The channel for communicating with the LB server. grpc_channel* lb_channel_ = nullptr; - // Uuid of the lb channel. Used for channelz. - gpr_atm lb_channel_uuid_ = 0; // Response generator to inject address updates into lb_channel_. RefCountedPtr response_generator_; @@ -386,9 +382,6 @@ class GrpcLb : public LoadBalancingPolicy { grpc_connectivity_state lb_channel_connectivity_ = GRPC_CHANNEL_IDLE; grpc_closure lb_channel_on_connectivity_changed_; - // Lock held when modifying the value of child_policy_ or - // pending_child_policy_. - gpr_mu child_policy_mu_; // The child policy to use for the backends. OrphanablePtr child_policy_; // When switching child policies, the new policy will be stored here @@ -655,7 +648,6 @@ void GrpcLb::Helper::UpdateState(grpc_connectivity_state state, grpc_pollset_set_del_pollset_set( parent_->child_policy_->interested_parties(), parent_->interested_parties()); - MutexLock lock(&parent_->child_policy_mu_); parent_->child_policy_ = std::move(parent_->pending_child_policy_); } else if (!CalledByCurrentChild()) { // This request is from an outdated child, so ignore it. @@ -735,6 +727,15 @@ void GrpcLb::Helper::RequestReresolution() { } } +void GrpcLb::Helper::AddTraceEvent(TraceSeverity severity, + const char* message) { + if (parent_->shutting_down_ || + (!CalledByPendingChild() && !CalledByCurrentChild())) { + return; + } + parent_->channel_control_helper()->AddTraceEvent(severity, message); +} + // // GrpcLb::BalancerCallState // @@ -1244,25 +1245,34 @@ grpc_channel_args* BuildBalancerChannelArgs( // treated as a stand-alone channel and not inherit this argument from the // args of the parent channel. GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, + // Don't want to pass down channelz node from parent; the balancer + // channel will get its own. + GRPC_ARG_CHANNELZ_CHANNEL_NODE, }; // Channel args to add. - const grpc_arg args_to_add[] = { - // The fake resolver response generator, which we use to inject - // address updates into the LB channel. + InlinedVector args_to_add; + // The fake resolver response generator, which we use to inject + // address updates into the LB channel. + args_to_add.emplace_back( grpc_core::FakeResolverResponseGenerator::MakeChannelArg( - response_generator), - // A channel arg indicating the target is a grpclb load balancer. - grpc_channel_arg_integer_create( - const_cast(GRPC_ARG_ADDRESS_IS_GRPCLB_LOAD_BALANCER), 1), - // A channel arg indicating this is an internal channels, aka it is - // owned by components in Core, not by the user application. - grpc_channel_arg_integer_create( - const_cast(GRPC_ARG_CHANNELZ_CHANNEL_IS_INTERNAL_CHANNEL), 1), - }; + response_generator)); + // A channel arg indicating the target is a grpclb load balancer. + args_to_add.emplace_back(grpc_channel_arg_integer_create( + const_cast(GRPC_ARG_ADDRESS_IS_GRPCLB_LOAD_BALANCER), 1)); + // The parent channel's channelz uuid. + channelz::ChannelNode* channelz_node = nullptr; + const grpc_arg* arg = + grpc_channel_args_find(args, GRPC_ARG_CHANNELZ_CHANNEL_NODE); + if (arg != nullptr && arg->type == GRPC_ARG_POINTER && + arg->value.pointer.p != nullptr) { + channelz_node = static_cast(arg->value.pointer.p); + args_to_add.emplace_back( + channelz::MakeParentUuidArg(channelz_node->uuid())); + } // Construct channel args. grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove( - args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove), args_to_add, - GPR_ARRAY_SIZE(args_to_add)); + args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove), args_to_add.data(), + args_to_add.size()); // Make any necessary modifications for security. return grpc_lb_policy_grpclb_modify_lb_channel_args(addresses, new_args); } @@ -1288,7 +1298,6 @@ GrpcLb::GrpcLb(Args args) GRPC_CLOSURE_INIT(&lb_channel_on_connectivity_changed_, &GrpcLb::OnBalancerChannelConnectivityChangedLocked, this, grpc_combiner_scheduler(args.combiner)); - gpr_mu_init(&child_policy_mu_); // Record server name. const grpc_arg* arg = grpc_channel_args_find(args.args, GRPC_ARG_SERVER_URI); const char* server_uri = grpc_channel_arg_get_string(arg); @@ -1314,7 +1323,6 @@ GrpcLb::GrpcLb(Args args) GrpcLb::~GrpcLb() { gpr_free((void*)server_name_); grpc_channel_args_destroy(args_); - gpr_mu_destroy(&child_policy_mu_); } void GrpcLb::ShutdownLocked() { @@ -1335,11 +1343,8 @@ void GrpcLb::ShutdownLocked() { grpc_pollset_set_del_pollset_set( pending_child_policy_->interested_parties(), interested_parties()); } - { - MutexLock lock(&child_policy_mu_); - child_policy_.reset(); - pending_child_policy_.reset(); - } + child_policy_.reset(); + pending_child_policy_.reset(); // We destroy the LB channel here instead of in our destructor because // destroying the channel triggers a last callback to // OnBalancerChannelConnectivityChangedLocked(), and we need to be @@ -1347,7 +1352,6 @@ void GrpcLb::ShutdownLocked() { if (lb_channel_ != nullptr) { grpc_channel_destroy(lb_channel_); lb_channel_ = nullptr; - gpr_atm_no_barrier_store(&lb_channel_uuid_, 0); } } @@ -1367,29 +1371,6 @@ void GrpcLb::ResetBackoffLocked() { } } -void GrpcLb::FillChildRefsForChannelz( - channelz::ChildRefsList* child_subchannels, - channelz::ChildRefsList* child_channels) { - { - // Delegate to the child policy to fill the children subchannels. - // This must be done holding child_policy_mu_, since this method - // does not run in the combiner. - MutexLock lock(&child_policy_mu_); - if (child_policy_ != nullptr) { - child_policy_->FillChildRefsForChannelz(child_subchannels, - child_channels); - } - if (pending_child_policy_ != nullptr) { - pending_child_policy_->FillChildRefsForChannelz(child_subchannels, - child_channels); - } - } - gpr_atm uuid = gpr_atm_no_barrier_load(&lb_channel_uuid_); - if (uuid != 0) { - child_channels->push_back(uuid); - } -} - void GrpcLb::UpdateLocked(UpdateArgs args) { const bool is_initial_update = lb_channel_ == nullptr; auto* grpclb_config = @@ -1472,11 +1453,6 @@ void GrpcLb::ProcessAddressesAndChannelArgsLocked( lb_channel_ = channel_control_helper()->CreateChannel(uri_str, *lb_channel_args); GPR_ASSERT(lb_channel_ != nullptr); - grpc_core::channelz::ChannelNode* channel_node = - grpc_channel_get_channelz_node(lb_channel_); - if (channel_node != nullptr) { - gpr_atm_no_barrier_store(&lb_channel_uuid_, channel_node->uuid()); - } gpr_free(uri_str); } // Propagate updates to the LB channel (pick_first) through the fake @@ -1764,15 +1740,10 @@ void GrpcLb::CreateOrUpdateChildPolicyLocked() { gpr_log(GPR_INFO, "[grpclb %p] Creating new %schild policy %s", this, child_policy_ == nullptr ? "" : "pending ", child_policy_name); } - auto new_policy = - CreateChildPolicyLocked(child_policy_name, update_args.args); // Swap the policy into place. auto& lb_policy = child_policy_ == nullptr ? child_policy_ : pending_child_policy_; - { - MutexLock lock(&child_policy_mu_); - lb_policy = std::move(new_policy); - } + lb_policy = CreateChildPolicyLocked(child_policy_name, update_args.args); policy_to_update = lb_policy.get(); } else { // Cases 2a and 3a: update an existing policy. diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index 4680117fede..e4b58eb7558 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -53,8 +53,6 @@ class PickFirst : public LoadBalancingPolicy { void UpdateLocked(UpdateArgs args) override; void ExitIdleLocked() override; void ResetBackoffLocked() override; - void FillChildRefsForChannelz(channelz::ChildRefsList* child_subchannels, - channelz::ChildRefsList* ignored) override; private: ~PickFirst(); @@ -128,22 +126,8 @@ class PickFirst : public LoadBalancingPolicy { RefCountedPtr connected_subchannel_; }; - // Helper class to ensure that any function that modifies the child refs - // data structures will update the channelz snapshot data structures before - // returning. - class AutoChildRefsUpdater { - public: - explicit AutoChildRefsUpdater(PickFirst* pf) : pf_(pf) {} - ~AutoChildRefsUpdater() { pf_->UpdateChildRefsLocked(); } - - private: - PickFirst* pf_; - }; - void ShutdownLocked() override; - void UpdateChildRefsLocked(); - // All our subchannels. OrphanablePtr subchannel_list_; // Latest pending subchannel list. @@ -154,12 +138,6 @@ class PickFirst : public LoadBalancingPolicy { bool idle_ = false; // Are we shut down? bool shutdown_ = false; - - /// Lock and data used to capture snapshots of this channels child - /// channels and subchannels. This data is consumed by channelz. - Mutex child_refs_mu_; - channelz::ChildRefsList child_subchannels_; - channelz::ChildRefsList child_channels_; }; PickFirst::PickFirst(Args args) : LoadBalancingPolicy(std::move(args)) { @@ -177,7 +155,6 @@ PickFirst::~PickFirst() { } void PickFirst::ShutdownLocked() { - AutoChildRefsUpdater guard(this); if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_pick_first_trace)) { gpr_log(GPR_INFO, "Pick First %p Shutting down", this); } @@ -212,42 +189,7 @@ void PickFirst::ResetBackoffLocked() { } } -void PickFirst::FillChildRefsForChannelz( - channelz::ChildRefsList* child_subchannels_to_fill, - channelz::ChildRefsList* ignored) { - MutexLock lock(&child_refs_mu_); - for (size_t i = 0; i < child_subchannels_.size(); ++i) { - // TODO(ncteisen): implement a de dup loop that is not O(n^2). Might - // have to implement lightweight set. For now, we don't care about - // performance when channelz requests are made. - bool found = false; - for (size_t j = 0; j < child_subchannels_to_fill->size(); ++j) { - if ((*child_subchannels_to_fill)[j] == child_subchannels_[i]) { - found = true; - break; - } - } - if (!found) { - child_subchannels_to_fill->push_back(child_subchannels_[i]); - } - } -} - -void PickFirst::UpdateChildRefsLocked() { - channelz::ChildRefsList cs; - if (subchannel_list_ != nullptr) { - subchannel_list_->PopulateChildRefsList(&cs); - } - if (latest_pending_subchannel_list_ != nullptr) { - latest_pending_subchannel_list_->PopulateChildRefsList(&cs); - } - // atomically update the data that channelz will actually be looking at. - MutexLock lock(&child_refs_mu_); - child_subchannels_ = std::move(cs); -} - void PickFirst::UpdateLocked(UpdateArgs args) { - AutoChildRefsUpdater guard(this); if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_pick_first_trace)) { gpr_log(GPR_INFO, "Pick First %p received update with %" PRIuPTR " addresses", this, @@ -348,7 +290,6 @@ void PickFirst::UpdateLocked(UpdateArgs args) { void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( grpc_connectivity_state connectivity_state) { PickFirst* p = static_cast(subchannel_list()->policy()); - AutoChildRefsUpdater guard(p); // The notification must be for a subchannel in either the current or // latest pending subchannel lists. GPR_ASSERT(subchannel_list() == p->subchannel_list_.get() || diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc index 3b8ec4f2872..17c65d8b551 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc @@ -63,8 +63,6 @@ class RoundRobin : public LoadBalancingPolicy { void UpdateLocked(UpdateArgs args) override; void ResetBackoffLocked() override; - void FillChildRefsForChannelz(channelz::ChildRefsList* child_subchannels, - channelz::ChildRefsList* ignored) override; private: ~RoundRobin(); @@ -160,22 +158,8 @@ class RoundRobin : public LoadBalancingPolicy { InlinedVector, 10> subchannels_; }; - // Helper class to ensure that any function that modifies the child refs - // data structures will update the channelz snapshot data structures before - // returning. - class AutoChildRefsUpdater { - public: - explicit AutoChildRefsUpdater(RoundRobin* rr) : rr_(rr) {} - ~AutoChildRefsUpdater() { rr_->UpdateChildRefsLocked(); } - - private: - RoundRobin* rr_; - }; - void ShutdownLocked() override; - void UpdateChildRefsLocked(); - /** list of subchannels */ OrphanablePtr subchannel_list_; /** Latest version of the subchannel list. @@ -186,11 +170,6 @@ class RoundRobin : public LoadBalancingPolicy { OrphanablePtr latest_pending_subchannel_list_; /** are we shutting down? */ bool shutdown_ = false; - /// Lock and data used to capture snapshots of this channel's child - /// channels and subchannels. This data is consumed by channelz. - Mutex child_refs_mu_; - channelz::ChildRefsList child_subchannels_; - channelz::ChildRefsList child_channels_; }; // @@ -255,7 +234,6 @@ RoundRobin::~RoundRobin() { } void RoundRobin::ShutdownLocked() { - AutoChildRefsUpdater guard(this); if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_round_robin_trace)) { gpr_log(GPR_INFO, "[RR %p] Shutting down", this); } @@ -271,40 +249,6 @@ void RoundRobin::ResetBackoffLocked() { } } -void RoundRobin::FillChildRefsForChannelz( - channelz::ChildRefsList* child_subchannels_to_fill, - channelz::ChildRefsList* ignored) { - MutexLock lock(&child_refs_mu_); - for (size_t i = 0; i < child_subchannels_.size(); ++i) { - // TODO(ncteisen): implement a de dup loop that is not O(n^2). Might - // have to implement lightweight set. For now, we don't care about - // performance when channelz requests are made. - bool found = false; - for (size_t j = 0; j < child_subchannels_to_fill->size(); ++j) { - if ((*child_subchannels_to_fill)[j] == child_subchannels_[i]) { - found = true; - break; - } - } - if (!found) { - child_subchannels_to_fill->push_back(child_subchannels_[i]); - } - } -} - -void RoundRobin::UpdateChildRefsLocked() { - channelz::ChildRefsList cs; - if (subchannel_list_ != nullptr) { - subchannel_list_->PopulateChildRefsList(&cs); - } - if (latest_pending_subchannel_list_ != nullptr) { - latest_pending_subchannel_list_->PopulateChildRefsList(&cs); - } - // atomically update the data that channelz will actually be looking at. - MutexLock lock(&child_refs_mu_); - child_subchannels_ = std::move(cs); -} - void RoundRobin::RoundRobinSubchannelList::StartWatchingLocked() { if (num_subchannels() == 0) return; // Check current state of each subchannel synchronously, since any @@ -396,7 +340,6 @@ void RoundRobin::RoundRobinSubchannelList:: void RoundRobin::RoundRobinSubchannelList:: UpdateRoundRobinStateFromSubchannelStateCountsLocked() { RoundRobin* p = static_cast(policy()); - AutoChildRefsUpdater guard(p); if (num_ready_ > 0) { if (p->subchannel_list_.get() != this) { // Promote this list to p->subchannel_list_. @@ -468,7 +411,6 @@ void RoundRobin::RoundRobinSubchannelData::ProcessConnectivityChangeLocked( } void RoundRobin::UpdateLocked(UpdateArgs args) { - AutoChildRefsUpdater guard(this); if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_round_robin_trace)) { gpr_log(GPR_INFO, "[RR %p] received update with %" PRIuPTR " addresses", this, args.addresses.size()); diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h index 8929bc4ab1e..7d70928a83c 100644 --- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h @@ -223,19 +223,6 @@ class SubchannelList : public InternallyRefCounted { // Returns true if the subchannel list is shutting down. bool shutting_down() const { return shutting_down_; } - // Populates refs_list with the uuids of this SubchannelLists's subchannels. - void PopulateChildRefsList(channelz::ChildRefsList* refs_list) { - for (size_t i = 0; i < subchannels_.size(); ++i) { - if (subchannels_[i].subchannel() != nullptr) { - grpc_core::channelz::SubchannelNode* subchannel_node = - subchannels_[i].subchannel()->channelz_node(); - if (subchannel_node != nullptr) { - refs_list->push_back(subchannel_node->uuid()); - } - } - } - } - // Accessors. LoadBalancingPolicy* policy() const { return policy_; } TraceFlag* tracer() const { return tracer_; } diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index 041c1e46231..136d85bba14 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -157,9 +157,6 @@ class XdsLb : public LoadBalancingPolicy { void UpdateLocked(UpdateArgs args) override; void ResetBackoffLocked() override; - void FillChildRefsForChannelz( - channelz::ChildRefsList* child_subchannels, - channelz::ChildRefsList* child_channels) override; private: struct LocalityServerlistEntry; @@ -343,6 +340,7 @@ class XdsLb : public LoadBalancingPolicy { void UpdateState(grpc_connectivity_state state, UniquePtr picker) override; void RequestReresolution() override; + void AddTraceEvent(TraceSeverity severity, const char* message) override; void set_child(LoadBalancingPolicy* child) { child_ = child; } @@ -398,8 +396,6 @@ class XdsLb : public LoadBalancingPolicy { const grpc_channel_args* args); void ShutdownLocked(); void ResetBackoffLocked(); - void FillChildRefsForChannelz(channelz::ChildRefsList* child_subchannels, - channelz::ChildRefsList* child_channels); void Orphan() override; private: @@ -415,6 +411,8 @@ class XdsLb : public LoadBalancingPolicy { void UpdateState(grpc_connectivity_state state, UniquePtr picker) override; void RequestReresolution() override; + void AddTraceEvent(TraceSeverity severity, + const char* message) override; void set_child(LoadBalancingPolicy* child) { child_ = child; } private: @@ -432,9 +430,6 @@ class XdsLb : public LoadBalancingPolicy { OrphanablePtr child_policy_; OrphanablePtr pending_child_policy_; - // Lock held when modifying the value of child_policy_ or - // pending_child_policy_. - Mutex child_policy_mu_; RefCountedPtr parent_; RefCountedPtr picker_ref_; grpc_connectivity_state connectivity_state_; @@ -446,17 +441,12 @@ class XdsLb : public LoadBalancingPolicy { const grpc_channel_args* args, XdsLb* parent); void ShutdownLocked(); void ResetBackoffLocked(); - void FillChildRefsForChannelz(channelz::ChildRefsList* child_subchannels, - channelz::ChildRefsList* child_channels); private: void PruneLocalities(const LocalityList& locality_list); Map, OrphanablePtr, LocalityName::Less> map_; - // Lock held while filling child refs for all localities - // inside the map - Mutex child_refs_mu_; }; struct LocalityServerlistEntry { @@ -511,10 +501,6 @@ class XdsLb : public LoadBalancingPolicy { // The channel for communicating with the LB server. OrphanablePtr lb_chand_; OrphanablePtr pending_lb_chand_; - // Mutex to protect the channel to the LB server. This is used when - // processing a channelz request. - // TODO(juanlishen): Replace this with atomic. - Mutex lb_chand_mu_; // Timeout in milliseconds for the LB call. 0 means no deadline. int lb_call_timeout_ms_ = 0; @@ -538,9 +524,6 @@ class XdsLb : public LoadBalancingPolicy { // The policy to use for the fallback backends. RefCountedPtr fallback_policy_config_; - // Lock held when modifying the value of fallback_policy_ or - // pending_fallback_policy_. - Mutex fallback_policy_mu_; // Non-null iff we are in fallback mode. OrphanablePtr fallback_policy_; OrphanablePtr pending_fallback_policy_; @@ -648,7 +631,6 @@ void XdsLb::FallbackHelper::UpdateState(grpc_connectivity_state state, grpc_pollset_set_del_pollset_set( parent_->fallback_policy_->interested_parties(), parent_->interested_parties()); - MutexLock lock(&parent_->fallback_policy_mu_); parent_->fallback_policy_ = std::move(parent_->pending_fallback_policy_); } else if (!CalledByCurrentFallback()) { // This request is from an outdated fallback policy, so ignore it. @@ -673,6 +655,15 @@ void XdsLb::FallbackHelper::RequestReresolution() { parent_->channel_control_helper()->RequestReresolution(); } +void XdsLb::FallbackHelper::AddTraceEvent(TraceSeverity severity, + const char* message) { + if (parent_->shutting_down_ || + (!CalledByPendingFallback() && !CalledByCurrentFallback())) { + return; + } + parent_->channel_control_helper()->AddTraceEvent(severity, message); +} + // // serverlist parsing code // @@ -1365,21 +1356,29 @@ grpc_channel_args* BuildBalancerChannelArgs(const grpc_channel_args* args) { // treated as a stand-alone channel and not inherit this argument from the // args of the parent channel. GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, + // Don't want to pass down channelz node from parent; the balancer + // channel will get its own. + GRPC_ARG_CHANNELZ_CHANNEL_NODE, }; // Channel args to add. - const grpc_arg args_to_add[] = { - // A channel arg indicating the target is a xds load balancer. - grpc_channel_arg_integer_create( - const_cast(GRPC_ARG_ADDRESS_IS_XDS_LOAD_BALANCER), 1), - // A channel arg indicating this is an internal channels, aka it is - // owned by components in Core, not by the user application. - grpc_channel_arg_integer_create( - const_cast(GRPC_ARG_CHANNELZ_CHANNEL_IS_INTERNAL_CHANNEL), 1), - }; + InlinedVector args_to_add; + // A channel arg indicating the target is a xds load balancer. + args_to_add.emplace_back(grpc_channel_arg_integer_create( + const_cast(GRPC_ARG_ADDRESS_IS_XDS_LOAD_BALANCER), 1)); + // The parent channel's channelz uuid. + channelz::ChannelNode* channelz_node = nullptr; + const grpc_arg* arg = + grpc_channel_args_find(args, GRPC_ARG_CHANNELZ_CHANNEL_NODE); + if (arg != nullptr && arg->type == GRPC_ARG_POINTER && + arg->value.pointer.p != nullptr) { + channelz_node = static_cast(arg->value.pointer.p); + args_to_add.emplace_back( + channelz::MakeParentUuidArg(channelz_node->uuid())); + } // Construct channel args. grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove( - args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove), args_to_add, - GPR_ARRAY_SIZE(args_to_add)); + args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove), args_to_add.data(), + args_to_add.size()); // Make any necessary modifications for security. return grpc_lb_policy_xds_modify_lb_channel_args(new_args); } @@ -1434,18 +1433,12 @@ void XdsLb::ShutdownLocked() { grpc_pollset_set_del_pollset_set( pending_fallback_policy_->interested_parties(), interested_parties()); } - { - MutexLock lock(&fallback_policy_mu_); - fallback_policy_.reset(); - pending_fallback_policy_.reset(); - } + fallback_policy_.reset(); + pending_fallback_policy_.reset(); // We reset the LB channels here instead of in our destructor because they // hold refs to XdsLb. - { - MutexLock lock(&lb_chand_mu_); - lb_chand_.reset(); - pending_lb_chand_.reset(); - } + lb_chand_.reset(); + pending_lb_chand_.reset(); } // @@ -1468,40 +1461,6 @@ void XdsLb::ResetBackoffLocked() { } } -void XdsLb::FillChildRefsForChannelz(channelz::ChildRefsList* child_subchannels, - channelz::ChildRefsList* child_channels) { - // Delegate to the locality_map_ to fill the children subchannels. - locality_map_.FillChildRefsForChannelz(child_subchannels, child_channels); - { - // This must be done holding fallback_policy_mu_, since this method does not - // run in the combiner. - MutexLock lock(&fallback_policy_mu_); - if (fallback_policy_ != nullptr) { - fallback_policy_->FillChildRefsForChannelz(child_subchannels, - child_channels); - } - if (pending_fallback_policy_ != nullptr) { - pending_fallback_policy_->FillChildRefsForChannelz(child_subchannels, - child_channels); - } - } - MutexLock lock(&lb_chand_mu_); - if (lb_chand_ != nullptr) { - grpc_core::channelz::ChannelNode* channel_node = - grpc_channel_get_channelz_node(lb_chand_->channel()); - if (channel_node != nullptr) { - child_channels->push_back(channel_node->uuid()); - } - } - if (pending_lb_chand_ != nullptr) { - grpc_core::channelz::ChannelNode* channel_node = - grpc_channel_get_channelz_node(pending_lb_chand_->channel()); - if (channel_node != nullptr) { - child_channels->push_back(channel_node->uuid()); - } - } -} - void XdsLb::ProcessAddressesAndChannelArgsLocked( const ServerAddressList& addresses, const grpc_channel_args& args) { // Update fallback address list. @@ -1691,14 +1650,10 @@ void XdsLb::UpdateFallbackPolicyLocked() { fallback_policy_ == nullptr ? "" : "pending ", fallback_policy_name); } - auto new_policy = - CreateFallbackPolicyLocked(fallback_policy_name, update_args.args); auto& lb_policy = fallback_policy_ == nullptr ? fallback_policy_ : pending_fallback_policy_; - { - MutexLock lock(&fallback_policy_mu_); - lb_policy = std::move(new_policy); - } + lb_policy = + CreateFallbackPolicyLocked(fallback_policy_name, update_args.args); policy_to_update = lb_policy.get(); } else { // Cases 2a and 3a: update an existing policy. @@ -1769,7 +1724,6 @@ void XdsLb::LocalityMap::PruneLocalities(const LocalityList& locality_list) { } } if (!found) { // Remove entries not present in the locality list - MutexLock lock(&child_refs_mu_); iter = map_.erase(iter); } else iter++; @@ -1786,7 +1740,6 @@ void XdsLb::LocalityMap::UpdateLocked( if (iter == map_.end()) { OrphanablePtr new_entry = MakeOrphanable( parent->Ref(), locality_serverlist[i]->locality_weight); - MutexLock lock(&child_refs_mu_); iter = map_.emplace(locality_serverlist[i]->locality_name, std::move(new_entry)) .first; @@ -1799,10 +1752,7 @@ void XdsLb::LocalityMap::UpdateLocked( PruneLocalities(locality_serverlist); } -void XdsLb::LocalityMap::ShutdownLocked() { - MutexLock lock(&child_refs_mu_); - map_.clear(); -} +void XdsLb::LocalityMap::ShutdownLocked() { map_.clear(); } void XdsLb::LocalityMap::ResetBackoffLocked() { for (auto& p : map_) { @@ -1810,15 +1760,6 @@ void XdsLb::LocalityMap::ResetBackoffLocked() { } } -void XdsLb::LocalityMap::FillChildRefsForChannelz( - channelz::ChildRefsList* child_subchannels, - channelz::ChildRefsList* child_channels) { - MutexLock lock(&child_refs_mu_); - for (auto& p : map_) { - p.second->FillChildRefsForChannelz(child_subchannels, child_channels); - } -} - // // XdsLb::LocalityMap::LocalityEntry // @@ -1954,14 +1895,9 @@ void XdsLb::LocalityMap::LocalityEntry::UpdateLocked( gpr_log(GPR_INFO, "[xdslb %p] Creating new %schild policy %s", this, child_policy_ == nullptr ? "" : "pending ", child_policy_name); } - auto new_policy = - CreateChildPolicyLocked(child_policy_name, update_args.args); auto& lb_policy = child_policy_ == nullptr ? child_policy_ : pending_child_policy_; - { - MutexLock lock(&child_policy_mu_); - lb_policy = std::move(new_policy); - } + lb_policy = CreateChildPolicyLocked(child_policy_name, update_args.args); policy_to_update = lb_policy.get(); } else { // Cases 2a and 3a: update an existing policy. @@ -1991,11 +1927,8 @@ void XdsLb::LocalityMap::LocalityEntry::ShutdownLocked() { pending_child_policy_->interested_parties(), parent_->interested_parties()); } - { - MutexLock lock(&child_policy_mu_); - child_policy_.reset(); - pending_child_policy_.reset(); - } + child_policy_.reset(); + pending_child_policy_.reset(); } void XdsLb::LocalityMap::LocalityEntry::ResetBackoffLocked() { @@ -2005,17 +1938,6 @@ void XdsLb::LocalityMap::LocalityEntry::ResetBackoffLocked() { } } -void XdsLb::LocalityMap::LocalityEntry::FillChildRefsForChannelz( - channelz::ChildRefsList* child_subchannels, - channelz::ChildRefsList* child_channels) { - MutexLock lock(&child_policy_mu_); - child_policy_->FillChildRefsForChannelz(child_subchannels, child_channels); - if (pending_child_policy_ != nullptr) { - pending_child_policy_->FillChildRefsForChannelz(child_subchannels, - child_channels); - } -} - void XdsLb::LocalityMap::LocalityEntry::Orphan() { ShutdownLocked(); Unref(); @@ -2070,7 +1992,6 @@ void XdsLb::LocalityMap::LocalityEntry::Helper::UpdateState( grpc_pollset_set_del_pollset_set( entry_->child_policy_->interested_parties(), entry_->parent_->interested_parties()); - MutexLock lock(&entry_->child_policy_mu_); entry_->child_policy_ = std::move(entry_->pending_child_policy_); } else if (!CalledByCurrentChild()) { // This request is from an outdated child, so ignore it. @@ -2180,6 +2101,15 @@ void XdsLb::LocalityMap::LocalityEntry::Helper::RequestReresolution() { } } +void XdsLb::LocalityMap::LocalityEntry::Helper::AddTraceEvent( + TraceSeverity severity, const char* message) { + if (entry_->parent_->shutting_down_ || + (!CalledByPendingChild() && !CalledByCurrentChild())) { + return; + } + entry_->parent_->channel_control_helper()->AddTraceEvent(severity, message); +} + // // factory // diff --git a/src/core/ext/filters/client_channel/resolving_lb_policy.cc b/src/core/ext/filters/client_channel/resolving_lb_policy.cc index d23ac1f4e33..180b0fcbbf4 100644 --- a/src/core/ext/filters/client_channel/resolving_lb_policy.cc +++ b/src/core/ext/filters/client_channel/resolving_lb_policy.cc @@ -137,7 +137,6 @@ class ResolvingLoadBalancingPolicy::ResolvingControlHelper grpc_pollset_set_del_pollset_set( parent_->lb_policy_->interested_parties(), parent_->interested_parties()); - MutexLock lock(&parent_->lb_policy_mu_); parent_->lb_policy_ = std::move(parent_->pending_lb_policy_); } else if (!CalledByCurrentChild()) { // This request is from an outdated child, so ignore it. @@ -214,7 +213,6 @@ ResolvingLoadBalancingPolicy::ResolvingLoadBalancingPolicy( process_resolver_result_(process_resolver_result), process_resolver_result_user_data_(process_resolver_result_user_data) { GPR_ASSERT(process_resolver_result != nullptr); - gpr_mu_init(&lb_policy_mu_); *error = Init(*args.args); } @@ -234,13 +232,11 @@ grpc_error* ResolvingLoadBalancingPolicy::Init(const grpc_channel_args& args) { ResolvingLoadBalancingPolicy::~ResolvingLoadBalancingPolicy() { GPR_ASSERT(resolver_ == nullptr); GPR_ASSERT(lb_policy_ == nullptr); - gpr_mu_destroy(&lb_policy_mu_); } void ResolvingLoadBalancingPolicy::ShutdownLocked() { if (resolver_ != nullptr) { resolver_.reset(); - MutexLock lock(&lb_policy_mu_); if (lb_policy_ != nullptr) { if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) { gpr_log(GPR_INFO, "resolving_lb=%p: shutting down lb_policy=%p", this, @@ -282,22 +278,6 @@ void ResolvingLoadBalancingPolicy::ResetBackoffLocked() { if (pending_lb_policy_ != nullptr) pending_lb_policy_->ResetBackoffLocked(); } -void ResolvingLoadBalancingPolicy::FillChildRefsForChannelz( - channelz::ChildRefsList* child_subchannels, - channelz::ChildRefsList* child_channels) { - // Delegate to the lb_policy_ to fill the children subchannels. - // This must be done holding lb_policy_mu_, since this method does not - // run in the combiner. - MutexLock lock(&lb_policy_mu_); - if (lb_policy_ != nullptr) { - lb_policy_->FillChildRefsForChannelz(child_subchannels, child_channels); - } - if (pending_lb_policy_ != nullptr) { - pending_lb_policy_->FillChildRefsForChannelz(child_subchannels, - child_channels); - } -} - void ResolvingLoadBalancingPolicy::StartResolvingLocked() { if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) { gpr_log(GPR_INFO, "resolving_lb=%p: starting name resolution", this); @@ -403,13 +383,9 @@ void ResolvingLoadBalancingPolicy::CreateOrUpdateLbPolicyLocked( gpr_log(GPR_INFO, "resolving_lb=%p: Creating new %schild policy %s", this, lb_policy_ == nullptr ? "" : "pending ", lb_policy_name); } - auto new_policy = - CreateLbPolicyLocked(lb_policy_name, *result.args, trace_strings); auto& lb_policy = lb_policy_ == nullptr ? lb_policy_ : pending_lb_policy_; - { - MutexLock lock(&lb_policy_mu_); - lb_policy = std::move(new_policy); - } + lb_policy = + CreateLbPolicyLocked(lb_policy_name, *result.args, trace_strings); policy_to_update = lb_policy.get(); } else { // Cases 2a and 3a: update an existing policy. @@ -451,11 +427,9 @@ ResolvingLoadBalancingPolicy::CreateLbPolicyLocked( lb_policy_name, std::move(lb_policy_args)); if (GPR_UNLIKELY(lb_policy == nullptr)) { gpr_log(GPR_ERROR, "could not create LB policy \"%s\"", lb_policy_name); - if (channelz_node() != nullptr) { - char* str; - gpr_asprintf(&str, "Could not create LB policy \"%s\"", lb_policy_name); - trace_strings->push_back(str); - } + char* str; + gpr_asprintf(&str, "Could not create LB policy \"%s\"", lb_policy_name); + trace_strings->push_back(str); return nullptr; } helper->set_child(lb_policy.get()); @@ -463,16 +437,9 @@ ResolvingLoadBalancingPolicy::CreateLbPolicyLocked( gpr_log(GPR_INFO, "resolving_lb=%p: created new LB policy \"%s\" (%p)", this, lb_policy_name, lb_policy.get()); } - if (channelz_node() != nullptr) { - char* str; - gpr_asprintf(&str, "Created new LB policy \"%s\"", lb_policy_name); - trace_strings->push_back(str); - } - // Propagate channelz node. - auto* channelz = channelz_node(); - if (channelz != nullptr) { - lb_policy->set_channelz_node(channelz->Ref()); - } + char* str; + gpr_asprintf(&str, "Created new LB policy \"%s\"", lb_policy_name); + trace_strings->push_back(str); grpc_pollset_set_add_pollset_set(lb_policy->interested_parties(), interested_parties()); return lb_policy; @@ -502,11 +469,10 @@ void ResolvingLoadBalancingPolicy::ConcatenateAndAddChannelTraceLocked( is_first = false; gpr_strvec_add(&v, (*trace_strings)[i]); } - char* flat; - size_t flat_len = 0; - flat = gpr_strvec_flatten(&v, &flat_len); - channelz_node()->AddTraceEvent(channelz::ChannelTrace::Severity::Info, - grpc_slice_new(flat, flat_len, gpr_free)); + size_t len = 0; + UniquePtr message(gpr_strvec_flatten(&v, &len)); + channel_control_helper()->AddTraceEvent(ChannelControlHelper::TRACE_INFO, + message.get()); gpr_strvec_destroy(&v); } } @@ -560,21 +526,18 @@ void ResolvingLoadBalancingPolicy::OnResolverResultChangedLocked( std::move(result), &trace_strings); } // Add channel trace event. - if (channelz_node() != nullptr) { - if (service_config_changed) { - // TODO(ncteisen): might be worth somehow including a snippet of the - // config in the trace, at the risk of bloating the trace logs. - trace_strings.push_back(gpr_strdup("Service config changed")); - } - if (service_config_error_string != nullptr) { - trace_strings.push_back(service_config_error_string); - service_config_error_string = nullptr; - } - MaybeAddTraceMessagesForAddressChangesLocked(resolution_contains_addresses, - &trace_strings); - ConcatenateAndAddChannelTraceLocked(&trace_strings); + if (service_config_changed) { + // TODO(ncteisen): might be worth somehow including a snippet of the + // config in the trace, at the risk of bloating the trace logs. + trace_strings.push_back(gpr_strdup("Service config changed")); } - gpr_free(service_config_error_string); + if (service_config_error_string != nullptr) { + trace_strings.push_back(service_config_error_string); + service_config_error_string = nullptr; + } + MaybeAddTraceMessagesForAddressChangesLocked(resolution_contains_addresses, + &trace_strings); + ConcatenateAndAddChannelTraceLocked(&trace_strings); } } // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/resolving_lb_policy.h b/src/core/ext/filters/client_channel/resolving_lb_policy.h index 679c8d0fba0..e91ea832661 100644 --- a/src/core/ext/filters/client_channel/resolving_lb_policy.h +++ b/src/core/ext/filters/client_channel/resolving_lb_policy.h @@ -21,7 +21,6 @@ #include -#include "src/core/ext/filters/client_channel/client_channel_channelz.h" #include "src/core/ext/filters/client_channel/lb_policy.h" #include "src/core/ext/filters/client_channel/lb_policy_factory.h" #include "src/core/ext/filters/client_channel/resolver.h" @@ -91,10 +90,6 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy { void ResetBackoffLocked() override; - void FillChildRefsForChannelz( - channelz::ChildRefsList* child_subchannels, - channelz::ChildRefsList* child_channels) override; - private: using TraceStringVector = InlinedVector; @@ -137,9 +132,6 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy { // Child LB policy. OrphanablePtr lb_policy_; OrphanablePtr pending_lb_policy_; - // Lock held when modifying the value of child_policy_ or - // pending_child_policy_. - gpr_mu lb_policy_mu_; }; } // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/subchannel_interface.h b/src/core/ext/filters/client_channel/subchannel_interface.h index 0a471045f03..10b1bf124c2 100644 --- a/src/core/ext/filters/client_channel/subchannel_interface.h +++ b/src/core/ext/filters/client_channel/subchannel_interface.h @@ -94,11 +94,15 @@ class SubchannelInterface : public RefCounted { GRPC_ABSTRACT; // Attempt to connect to the backend. Has no effect if already connected. + // If the subchannel is currently in backoff delay due to a previously + // failed attempt, the new connection attempt will not start until the + // backoff delay has elapsed. virtual void AttemptToConnect() GRPC_ABSTRACT; - // TODO(roth): These methods should be removed from this interface to - // bettter hide grpc-specific functionality from the LB policy API. - virtual channelz::SubchannelNode* channelz_node() GRPC_ABSTRACT; + // Resets the subchannel's connection backoff state. If AttemptToConnect() + // has been called since the subchannel entered TRANSIENT_FAILURE state, + // starts a new connection attempt immediately; otherwise, a new connection + // attempt will be started as soon as AttemptToConnect() is called. virtual void ResetBackoff() GRPC_ABSTRACT; GRPC_ABSTRACT_BASE_CLASS diff --git a/src/core/lib/channel/channelz.cc b/src/core/lib/channel/channelz.cc index 0eed9a59fef..4b130372e46 100644 --- a/src/core/lib/channel/channelz.cc +++ b/src/core/lib/channel/channelz.cc @@ -40,12 +40,51 @@ #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" +#include "src/core/lib/transport/connectivity_state.h" #include "src/core/lib/transport/error_utils.h" #include "src/core/lib/uri/uri_parser.h" namespace grpc_core { namespace channelz { +// +// channel arg code +// + +namespace { + +void* parent_uuid_copy(void* p) { return p; } +void parent_uuid_destroy(void* p) {} +int parent_uuid_cmp(void* p1, void* p2) { return GPR_ICMP(p1, p2); } +const grpc_arg_pointer_vtable parent_uuid_vtable = { + parent_uuid_copy, parent_uuid_destroy, parent_uuid_cmp}; + +} // namespace + +grpc_arg MakeParentUuidArg(intptr_t parent_uuid) { + // We would ideally like to store the uuid in an integer argument. + // Unfortunately, that won't work, because intptr_t (the type used for + // uuids) doesn't fit in an int (the type used for integer args). + // So instead, we use a hack to store it as a pointer, because + // intptr_t should be the same size as void*. + static_assert(sizeof(intptr_t) <= sizeof(void*), + "can't fit intptr_t inside of void*"); + return grpc_channel_arg_pointer_create( + const_cast(GRPC_ARG_CHANNELZ_PARENT_UUID), + reinterpret_cast(parent_uuid), &parent_uuid_vtable); +} + +intptr_t GetParentUuidFromArgs(const grpc_channel_args& args) { + const grpc_arg* arg = + grpc_channel_args_find(&args, GRPC_ARG_CHANNELZ_PARENT_UUID); + if (arg == nullptr || arg->type != GRPC_ARG_POINTER) return 0; + return reinterpret_cast(arg->value.pointer.p); +} + +// +// BaseNode +// + BaseNode::BaseNode(EntityType type) : type_(type), uuid_(-1) { // The registry will set uuid_ under its lock. ChannelzRegistry::Register(this); @@ -61,6 +100,10 @@ char* BaseNode::RenderJsonString() { return json_str; } +// +// CallCountingHelper +// + CallCountingHelper::CallCountingHelper() { num_cores_ = GPR_MAX(1, gpr_cpu_num_cores()); per_cpu_counter_data_storage_ = static_cast( @@ -137,15 +180,17 @@ void CallCountingHelper::PopulateCallCounts(grpc_json* json) { } } -ChannelNode::ChannelNode(grpc_channel* channel, size_t channel_tracer_max_nodes, - bool is_top_level_channel) - : BaseNode(is_top_level_channel ? EntityType::kTopLevelChannel - : EntityType::kInternalChannel), - channel_(channel), - target_(UniquePtr(grpc_channel_get_target(channel_))), - trace_(channel_tracer_max_nodes) {} +// +// ChannelNode +// -ChannelNode::~ChannelNode() {} +ChannelNode::ChannelNode(UniquePtr target, + size_t channel_tracer_max_nodes, intptr_t parent_uuid) + : BaseNode(parent_uuid == 0 ? EntityType::kTopLevelChannel + : EntityType::kInternalChannel), + target_(std::move(target)), + trace_(channel_tracer_max_nodes), + parent_uuid_(parent_uuid) {} grpc_json* ChannelNode::RenderJson() { // We need to track these three json objects to build our object @@ -167,9 +212,19 @@ grpc_json* ChannelNode::RenderJson() { GRPC_JSON_OBJECT, false); json = data; json_iterator = nullptr; - // template method. Child classes may override this to add their specific - // functionality. - PopulateConnectivityState(json); + // connectivity state + // If low-order bit is on, then the field is set. + int state_field = connectivity_state_.Load(MemoryOrder::RELAXED); + if ((state_field & 1) != 0) { + grpc_connectivity_state state = + static_cast(state_field >> 1); + json = grpc_json_create_child(nullptr, json, "state", nullptr, + GRPC_JSON_OBJECT, false); + grpc_json_create_child(nullptr, json, "state", + grpc_connectivity_state_name(state), + GRPC_JSON_STRING, false); + json = data; + } // populate the target. GPR_ASSERT(target_.get() != nullptr); grpc_json_create_child(nullptr, json, "target", target_.get(), @@ -189,13 +244,64 @@ grpc_json* ChannelNode::RenderJson() { return top_level_json; } -RefCountedPtr ChannelNode::MakeChannelNode( - grpc_channel* channel, size_t channel_tracer_max_nodes, - bool is_top_level_channel) { - return MakeRefCounted( - channel, channel_tracer_max_nodes, is_top_level_channel); +void ChannelNode::PopulateChildRefs(grpc_json* json) { + MutexLock lock(&child_mu_); + grpc_json* json_iterator = nullptr; + if (!child_subchannels_.empty()) { + grpc_json* array_parent = grpc_json_create_child( + nullptr, json, "subchannelRef", nullptr, GRPC_JSON_ARRAY, false); + for (const auto& p : child_subchannels_) { + json_iterator = + grpc_json_create_child(json_iterator, array_parent, nullptr, nullptr, + GRPC_JSON_OBJECT, false); + grpc_json_add_number_string_child(json_iterator, nullptr, "subchannelId", + p.first); + } + } + if (!child_channels_.empty()) { + grpc_json* array_parent = grpc_json_create_child( + nullptr, json, "channelRef", nullptr, GRPC_JSON_ARRAY, false); + json_iterator = nullptr; + for (const auto& p : child_channels_) { + json_iterator = + grpc_json_create_child(json_iterator, array_parent, nullptr, nullptr, + GRPC_JSON_OBJECT, false); + grpc_json_add_number_string_child(json_iterator, nullptr, "channelId", + p.first); + } + } } +void ChannelNode::SetConnectivityState(grpc_connectivity_state state) { + // Store with low-order bit set to indicate that the field is set. + int state_field = (state << 1) + 1; + connectivity_state_.Store(state_field, MemoryOrder::RELAXED); +} + +void ChannelNode::AddChildChannel(intptr_t child_uuid) { + MutexLock lock(&child_mu_); + child_channels_.insert(MakePair(child_uuid, true)); +} + +void ChannelNode::RemoveChildChannel(intptr_t child_uuid) { + MutexLock lock(&child_mu_); + child_channels_.erase(child_uuid); +} + +void ChannelNode::AddChildSubchannel(intptr_t child_uuid) { + MutexLock lock(&child_mu_); + child_subchannels_.insert(MakePair(child_uuid, true)); +} + +void ChannelNode::RemoveChildSubchannel(intptr_t child_uuid) { + MutexLock lock(&child_mu_); + child_subchannels_.erase(child_uuid); +} + +// +// ServerNode +// + ServerNode::ServerNode(grpc_server* server, size_t channel_tracer_max_nodes) : BaseNode(EntityType::kServer), server_(server), @@ -281,8 +387,14 @@ grpc_json* ServerNode::RenderJson() { return top_level_json; } -static void PopulateSocketAddressJson(grpc_json* json, const char* name, - const char* addr_str) { +// +// SocketNode +// + +namespace { + +void PopulateSocketAddressJson(grpc_json* json, const char* name, + const char* addr_str) { if (addr_str == nullptr) return; grpc_json* json_iterator = nullptr; json_iterator = grpc_json_create_child(json_iterator, json, name, nullptr, @@ -312,7 +424,6 @@ static void PopulateSocketAddressJson(grpc_json* json, const char* name, b64_host, GRPC_JSON_STRING, true); gpr_free(host); gpr_free(port); - } else if (uri != nullptr && strcmp(uri->scheme, "unix") == 0) { json_iterator = grpc_json_create_child(json_iterator, json, "uds_address", nullptr, GRPC_JSON_OBJECT, false); @@ -332,6 +443,8 @@ static void PopulateSocketAddressJson(grpc_json* json, const char* name, grpc_uri_destroy(uri); } +} // namespace + SocketNode::SocketNode(UniquePtr local, UniquePtr remote) : BaseNode(EntityType::kSocket), local_(std::move(local)), @@ -448,6 +561,10 @@ grpc_json* SocketNode::RenderJson() { return top_level_json; } +// +// ListenSocketNode +// + ListenSocketNode::ListenSocketNode(UniquePtr local_addr) : BaseNode(EntityType::kSocket), local_addr_(std::move(local_addr)) {} diff --git a/src/core/lib/channel/channelz.h b/src/core/lib/channel/channelz.h index e543cda1c2b..f8acb531e8a 100644 --- a/src/core/lib/channel/channelz.h +++ b/src/core/lib/channel/channelz.h @@ -26,19 +26,19 @@ #include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/gprpp/manual_constructor.h" +#include "src/core/lib/gprpp/map.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" +#include "src/core/lib/gprpp/sync.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/json/json.h" -// Channel arg key for client channel factory. -#define GRPC_ARG_CHANNELZ_CHANNEL_NODE_CREATION_FUNC \ - "grpc.channelz_channel_node_creation_func" +// Channel arg key for channelz node. +#define GRPC_ARG_CHANNELZ_CHANNEL_NODE "grpc.channelz_channel_node" -// Channel arg key to signal that the channel is an internal channel. -#define GRPC_ARG_CHANNELZ_CHANNEL_IS_INTERNAL_CHANNEL \ - "grpc.channelz_channel_is_internal_channel" +// Channel arg key to encode the channelz uuid of the channel's parent. +#define GRPC_ARG_CHANNELZ_PARENT_UUID "grpc.channelz_parent_uuid" /** This is the default value for whether or not to enable channelz. If * GRPC_ARG_ENABLE_CHANNELZ is set, it will override this default value. */ @@ -54,6 +54,10 @@ namespace grpc_core { namespace channelz { +// Helpers for getting and setting GRPC_ARG_CHANNELZ_PARENT_UUID. +grpc_arg MakeParentUuidArg(intptr_t parent_uuid); +intptr_t GetParentUuidFromArgs(const grpc_channel_args& args); + // TODO(ncteisen), this only contains the uuids of the children for now, // since that is all that is strictly needed. In a future enhancement we will // add human readable names as in the channelz.proto @@ -147,38 +151,13 @@ class CallCountingHelper { // Handles channelz bookkeeping for channels class ChannelNode : public BaseNode { public: - static RefCountedPtr MakeChannelNode( - grpc_channel* channel, size_t channel_tracer_max_nodes, - bool is_top_level_channel); + ChannelNode(UniquePtr target, size_t channel_tracer_max_nodes, + intptr_t parent_uuid); - ChannelNode(grpc_channel* channel, size_t channel_tracer_max_nodes, - bool is_top_level_channel); - ~ChannelNode() override; + intptr_t parent_uuid() const { return parent_uuid_; } grpc_json* RenderJson() override; - // template methods. RenderJSON uses these methods to render its JSON - // representation. These are virtual so that children classes may provide - // their specific mechanism for populating these parts of the channelz - // object. - // - // ChannelNode does not have a notion of connectivity state or child refs, - // so it leaves these implementations blank. - // - // This is utilizing the template method design pattern. - // - // TODO(ncteisen): remove these template methods in favor of manual traversal - // and mutation of the grpc_json object. - virtual void PopulateConnectivityState(grpc_json* json) {} - virtual void PopulateChildRefs(grpc_json* json) {} - - void MarkChannelDestroyed() { - GPR_ASSERT(channel_ != nullptr); - channel_ = nullptr; - } - - bool ChannelIsDestroyed() { return channel_ == nullptr; } - // proxy methods to composed classes. void AddTraceEvent(ChannelTrace::Severity severity, const grpc_slice& data) { trace_.AddTraceEvent(severity, data); @@ -193,13 +172,35 @@ class ChannelNode : public BaseNode { void RecordCallFailed() { call_counter_.RecordCallFailed(); } void RecordCallSucceeded() { call_counter_.RecordCallSucceeded(); } + void SetConnectivityState(grpc_connectivity_state state); + + void AddChildChannel(intptr_t child_uuid); + void RemoveChildChannel(intptr_t child_uuid); + + void AddChildSubchannel(intptr_t child_uuid); + void RemoveChildSubchannel(intptr_t child_uuid); + private: + void PopulateChildRefs(grpc_json* json); + // to allow the channel trace test to access trace_. friend class testing::ChannelNodePeer; - grpc_channel* channel_ = nullptr; + UniquePtr target_; CallCountingHelper call_counter_; ChannelTrace trace_; + const intptr_t parent_uuid_; + + // Least significant bit indicates whether the value is set. Remaining + // bits are a grpc_connectivity_state value. + Atomic connectivity_state_{0}; + + Mutex child_mu_; // Guards child maps below. + // TODO(roth): We don't actually use the values here, only the keys, so + // these should be sets instead of maps, but we don't currently have a set + // implementation. Change this if/when we have one. + Map child_channels_; + Map child_subchannels_; }; // Handles channelz bookkeeping for servers @@ -285,11 +286,6 @@ class ListenSocketNode : public BaseNode { UniquePtr local_addr_; }; -// Creation functions - -typedef RefCountedPtr (*ChannelNodeCreationFunc)(grpc_channel*, - size_t, bool); - } // namespace channelz } // namespace grpc_core diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 12869b7780d..e61550743b7 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -33,6 +33,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/channel/channelz.h" +#include "src/core/lib/channel/channelz_registry.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" @@ -86,18 +87,9 @@ grpc_channel* grpc_channel_create_with_builder( grpc_channel_args_destroy(args); return channel; } - channel->target = target; channel->resource_user = resource_user; channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); - bool channelz_enabled = GRPC_ENABLE_CHANNELZ_DEFAULT; - size_t channel_tracer_max_memory = - GRPC_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE_DEFAULT; - bool internal_channel = false; - // this creates the default ChannelNode. Different types of channels may - // override this to ensure a correct ChannelNode is created. - grpc_core::channelz::ChannelNodeCreationFunc channel_node_create_func = - grpc_core::channelz::ChannelNode::MakeChannelNode; gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = nullptr; @@ -129,40 +121,16 @@ grpc_channel* grpc_channel_create_with_builder( channel->compression_options.enabled_algorithms_bitset = static_cast(args->args[i].value.integer) | 0x1; /* always support no compression */ - } else if (0 == strcmp(args->args[i].key, - GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE)) { - const grpc_integer_options options = { - GRPC_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE_DEFAULT, 0, INT_MAX}; - channel_tracer_max_memory = - (size_t)grpc_channel_arg_get_integer(&args->args[i], options); - } else if (0 == strcmp(args->args[i].key, GRPC_ARG_ENABLE_CHANNELZ)) { - // channelz will not be enabled by default until all concerns in - // https://github.com/grpc/grpc/issues/15986 are addressed. - channelz_enabled = grpc_channel_arg_get_bool( - &args->args[i], GRPC_ENABLE_CHANNELZ_DEFAULT); - } else if (0 == strcmp(args->args[i].key, - GRPC_ARG_CHANNELZ_CHANNEL_NODE_CREATION_FUNC)) { + } else if (0 == strcmp(args->args[i].key, GRPC_ARG_CHANNELZ_CHANNEL_NODE)) { GPR_ASSERT(args->args[i].type == GRPC_ARG_POINTER); GPR_ASSERT(args->args[i].value.pointer.p != nullptr); - channel_node_create_func = - reinterpret_cast( - args->args[i].value.pointer.p); - } else if (0 == strcmp(args->args[i].key, - GRPC_ARG_CHANNELZ_CHANNEL_IS_INTERNAL_CHANNEL)) { - internal_channel = grpc_channel_arg_get_bool(&args->args[i], false); + channel->channelz_node = static_cast( + args->args[i].value.pointer.p) + ->Ref(); } } grpc_channel_args_destroy(args); - // we only need to do the channelz bookkeeping for clients here. The channelz - // bookkeeping for server channels occurs in src/core/lib/surface/server.cc - if (channelz_enabled && channel->is_client) { - channel->channelz_channel = channel_node_create_func( - channel, channel_tracer_max_memory, !internal_channel); - channel->channelz_channel->AddTraceEvent( - grpc_core::channelz::ChannelTrace::Severity::Info, - grpc_slice_from_static_string("Channel created")); - } return channel; } @@ -197,6 +165,71 @@ static grpc_channel_args* build_channel_args( return grpc_channel_args_copy_and_add(input_args, new_args, num_new_args); } +namespace { + +void* channelz_node_copy(void* p) { + grpc_core::channelz::ChannelNode* node = + static_cast(p); + node->Ref().release(); + return p; +} +void channelz_node_destroy(void* p) { + grpc_core::channelz::ChannelNode* node = + static_cast(p); + node->Unref(); +} +int channelz_node_cmp(void* p1, void* p2) { return GPR_ICMP(p1, p2); } +const grpc_arg_pointer_vtable channelz_node_arg_vtable = { + channelz_node_copy, channelz_node_destroy, channelz_node_cmp}; + +void CreateChannelzNode(grpc_channel_stack_builder* builder) { + const grpc_channel_args* args = + grpc_channel_stack_builder_get_channel_arguments(builder); + // Check whether channelz is enabled. + const bool channelz_enabled = grpc_channel_arg_get_bool( + grpc_channel_args_find(args, GRPC_ARG_ENABLE_CHANNELZ), + GRPC_ENABLE_CHANNELZ_DEFAULT); + if (!channelz_enabled) return; + // Get parameters needed to create the channelz node. + const size_t channel_tracer_max_memory = grpc_channel_arg_get_integer( + grpc_channel_args_find(args, + GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE), + {GRPC_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE_DEFAULT, 0, INT_MAX}); + const intptr_t channelz_parent_uuid = + grpc_core::channelz::GetParentUuidFromArgs(*args); + // Create the channelz node. + grpc_core::RefCountedPtr channelz_node = + grpc_core::MakeRefCounted( + grpc_core::UniquePtr( + gpr_strdup(grpc_channel_stack_builder_get_target(builder))), + channel_tracer_max_memory, channelz_parent_uuid); + channelz_node->AddTraceEvent( + grpc_core::channelz::ChannelTrace::Severity::Info, + grpc_slice_from_static_string("Channel created")); + // Update parent channel node, if any. + if (channelz_parent_uuid > 0) { + grpc_core::RefCountedPtr parent_node = + grpc_core::channelz::ChannelzRegistry::Get(channelz_parent_uuid); + if (parent_node != nullptr) { + grpc_core::channelz::ChannelNode* parent = + static_cast(parent_node.get()); + parent->AddChildChannel(channelz_node->uuid()); + } + } + // Add channelz node to channel args. + // We remove the arg for the parent uuid, since we no longer need it. + grpc_arg new_arg = grpc_channel_arg_pointer_create( + const_cast(GRPC_ARG_CHANNELZ_CHANNEL_NODE), channelz_node.get(), + &channelz_node_arg_vtable); + const char* args_to_remove[] = {GRPC_ARG_CHANNELZ_PARENT_UUID}; + grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove( + args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove), &new_arg, 1); + grpc_channel_stack_builder_set_channel_arguments(builder, new_args); + grpc_channel_args_destroy(new_args); +} + +} // namespace + grpc_channel* grpc_channel_create(const char* target, const grpc_channel_args* input_args, grpc_channel_stack_type channel_stack_type, @@ -219,9 +252,12 @@ grpc_channel* grpc_channel_create(const char* target, } return nullptr; } - grpc_channel* channel = - grpc_channel_create_with_builder(builder, channel_stack_type); - return channel; + // We only need to do this for clients here. For servers, this will be + // done in src/core/lib/surface/server.cc. + if (grpc_channel_stack_type_is_client(channel_stack_type)) { + CreateChannelzNode(builder); + } + return grpc_channel_create_with_builder(builder, channel_stack_type); } size_t grpc_channel_get_call_size_estimate(grpc_channel* channel) { @@ -401,12 +437,21 @@ grpc_call* grpc_channel_create_registered_call( static void destroy_channel(void* arg, grpc_error* error) { grpc_channel* channel = static_cast(arg); - if (channel->channelz_channel != nullptr) { - channel->channelz_channel->AddTraceEvent( + if (channel->channelz_node != nullptr) { + if (channel->channelz_node->parent_uuid() > 0) { + grpc_core::RefCountedPtr parent_node = + grpc_core::channelz::ChannelzRegistry::Get( + channel->channelz_node->parent_uuid()); + if (parent_node != nullptr) { + grpc_core::channelz::ChannelNode* parent = + static_cast(parent_node.get()); + parent->RemoveChildChannel(channel->channelz_node->uuid()); + } + } + channel->channelz_node->AddTraceEvent( grpc_core::channelz::ChannelTrace::Severity::Info, grpc_slice_from_static_string("Channel destroyed")); - channel->channelz_channel->MarkChannelDestroyed(); - channel->channelz_channel.reset(); + channel->channelz_node.reset(); } grpc_channel_stack_destroy(CHANNEL_STACK_FROM_CHANNEL(channel)); while (channel->registered_calls) { diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h index 5d666220745..a4cac748f2d 100644 --- a/src/core/lib/surface/channel.h +++ b/src/core/lib/surface/channel.h @@ -88,7 +88,7 @@ struct grpc_channel { gpr_mu registered_call_mu; registered_call* registered_calls; - grpc_core::RefCountedPtr channelz_channel; + grpc_core::RefCountedPtr channelz_node; char* target; }; @@ -106,7 +106,7 @@ inline grpc_channel_stack* grpc_channel_get_channel_stack( inline grpc_core::channelz::ChannelNode* grpc_channel_get_channelz_node( grpc_channel* channel) { - return channel->channelz_channel.get(); + return channel->channelz_node.get(); } #ifndef NDEBUG diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc index b3c0b368982..5ac7f0871a4 100644 --- a/test/core/channel/channel_trace_test.cc +++ b/test/core/channel/channel_trace_test.cc @@ -23,6 +23,7 @@ #include #include +#include #include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/channel/channelz.h" @@ -174,7 +175,7 @@ TEST(ChannelTracerTest, ComplexTest) { AddSimpleTrace(&tracer); ChannelFixture channel1(kEventListMemoryLimit); RefCountedPtr sc1 = MakeRefCounted( - channel1.channel(), kEventListMemoryLimit, true); + UniquePtr(gpr_strdup("fake_target")), kEventListMemoryLimit, 0); ChannelNodePeer sc1_peer(sc1.get()); tracer.AddTraceEventWithReference( ChannelTrace::Severity::Info, @@ -193,7 +194,7 @@ TEST(ChannelTracerTest, ComplexTest) { ValidateChannelTrace(&tracer, 5); ChannelFixture channel2(kEventListMemoryLimit); RefCountedPtr sc2 = MakeRefCounted( - channel2.channel(), kEventListMemoryLimit, true); + UniquePtr(gpr_strdup("fake_target")), kEventListMemoryLimit, 0); tracer.AddTraceEventWithReference( ChannelTrace::Severity::Info, grpc_slice_from_static_string("LB channel two created"), sc2); @@ -222,7 +223,7 @@ TEST(ChannelTracerTest, TestNesting) { ValidateChannelTrace(&tracer, 2); ChannelFixture channel1(kEventListMemoryLimit); RefCountedPtr sc1 = MakeRefCounted( - channel1.channel(), kEventListMemoryLimit, true); + UniquePtr(gpr_strdup("fake_target")), kEventListMemoryLimit, 0); ChannelNodePeer sc1_peer(sc1.get()); tracer.AddTraceEventWithReference( ChannelTrace::Severity::Info, @@ -231,7 +232,7 @@ TEST(ChannelTracerTest, TestNesting) { AddSimpleTrace(sc1_peer.trace()); ChannelFixture channel2(kEventListMemoryLimit); RefCountedPtr conn1 = MakeRefCounted( - channel2.channel(), kEventListMemoryLimit, true); + UniquePtr(gpr_strdup("fake_target")), kEventListMemoryLimit, 0); ChannelNodePeer conn1_peer(conn1.get()); // nesting one level deeper. sc1_peer.trace()->AddTraceEventWithReference( @@ -245,7 +246,7 @@ TEST(ChannelTracerTest, TestNesting) { ValidateChannelTrace(conn1_peer.trace(), 1); ChannelFixture channel3(kEventListMemoryLimit); RefCountedPtr sc2 = MakeRefCounted( - channel3.channel(), kEventListMemoryLimit, true); + UniquePtr(gpr_strdup("fake_target")), kEventListMemoryLimit, 0); tracer.AddTraceEventWithReference( ChannelTrace::Severity::Info, grpc_slice_from_static_string("subchannel two created"), sc2); diff --git a/test/core/channel/channelz_test.cc b/test/core/channel/channelz_test.cc index abd1601ad14..7c55f9ffe0f 100644 --- a/test/core/channel/channelz_test.cc +++ b/test/core/channel/channelz_test.cc @@ -486,8 +486,7 @@ TEST_F(ChannelzRegistryBasedTest, InternalChannelTest) { (void)channels; // suppress unused variable error // create an internal channel grpc_arg client_a[2]; - client_a[0] = grpc_channel_arg_integer_create( - const_cast(GRPC_ARG_CHANNELZ_CHANNEL_IS_INTERNAL_CHANNEL), true); + client_a[0] = grpc_core::channelz::MakeParentUuidArg(1); client_a[1] = grpc_channel_arg_integer_create( const_cast(GRPC_ARG_ENABLE_CHANNELZ), true); grpc_channel_args client_args = {GPR_ARRAY_SIZE(client_a), client_a}; diff --git a/test/core/util/test_lb_policies.cc b/test/core/util/test_lb_policies.cc index ced6d9d8027..2c1f988d173 100644 --- a/test/core/util/test_lb_policies.cc +++ b/test/core/util/test_lb_policies.cc @@ -72,12 +72,6 @@ class ForwardingLoadBalancingPolicy : public LoadBalancingPolicy { void ResetBackoffLocked() override { delegate_->ResetBackoffLocked(); } - void FillChildRefsForChannelz( - channelz::ChildRefsList* child_subchannels, - channelz::ChildRefsList* child_channels) override { - delegate_->FillChildRefsForChannelz(child_subchannels, child_channels); - } - private: void ShutdownLocked() override { delegate_.reset(); } @@ -164,6 +158,10 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy parent_->channel_control_helper()->RequestReresolution(); } + void AddTraceEvent(TraceSeverity severity, const char* message) override { + parent_->channel_control_helper()->AddTraceEvent(severity, message); + } + private: RefCountedPtr parent_; InterceptRecvTrailingMetadataCallback cb_; diff --git a/test/cpp/end2end/channelz_service_test.cc b/test/cpp/end2end/channelz_service_test.cc index 26ef59fbeb3..69c56c574f9 100644 --- a/test/cpp/end2end/channelz_service_test.cc +++ b/test/cpp/end2end/channelz_service_test.cc @@ -163,13 +163,12 @@ class ChannelzServerTest : public ::testing::Test { } std::unique_ptr NewEchoStub() { - static int salt = 0; string target = "dns:localhost:" + to_string(proxy_port_); ChannelArguments args; // disable channelz. We only want to focus on proxy to backend outbound. args.SetInt(GRPC_ARG_ENABLE_CHANNELZ, 0); // This ensures that gRPC will not do connection sharing. - args.SetInt("salt", salt++); + args.SetInt(GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL, true); std::shared_ptr channel = ::grpc::CreateCustomChannel(target, InsecureChannelCredentials(), args); return grpc::testing::EchoTestService::NewStub(channel); From f9fcdc015d03c7c4d12eb3ed5202e1a2aa90520a Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 7 Jun 2019 09:51:29 -0700 Subject: [PATCH 0469/1555] Convert ChannelzRegistry to use Map<> instead of InlinedVector<>. --- src/core/lib/channel/channelz_registry.cc | 110 +++++--------------- src/core/lib/channel/channelz_registry.h | 32 ++---- src/core/lib/gprpp/map.h | 10 ++ test/core/channel/channelz_registry_test.cc | 63 ++--------- test/core/gprpp/map_test.cc | 18 ++++ 5 files changed, 68 insertions(+), 165 deletions(-) diff --git a/src/core/lib/channel/channelz_registry.cc b/src/core/lib/channel/channelz_registry.cc index 0c033a14c60..553e1fe97b5 100644 --- a/src/core/lib/channel/channelz_registry.cc +++ b/src/core/lib/channel/channelz_registry.cc @@ -18,6 +18,9 @@ #include +#include +#include + #include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/channel/channelz.h" #include "src/core/lib/channel/channelz_registry.h" @@ -29,8 +32,6 @@ #include #include -#include - namespace grpc_core { namespace channelz { namespace { @@ -51,70 +52,17 @@ ChannelzRegistry* ChannelzRegistry::Default() { return g_channelz_registry; } -ChannelzRegistry::ChannelzRegistry() { gpr_mu_init(&mu_); } - -ChannelzRegistry::~ChannelzRegistry() { gpr_mu_destroy(&mu_); } - void ChannelzRegistry::InternalRegister(BaseNode* node) { MutexLock lock(&mu_); - entities_.push_back(node); node->uuid_ = ++uuid_generator_; -} - -void ChannelzRegistry::MaybePerformCompactionLocked() { - constexpr double kEmptinessTheshold = 1. / 3; - double emptiness_ratio = - double(num_empty_slots_) / double(entities_.capacity()); - if (emptiness_ratio > kEmptinessTheshold) { - int front = 0; - for (size_t i = 0; i < entities_.size(); ++i) { - if (entities_[i] != nullptr) { - entities_[front++] = entities_[i]; - } - } - for (int i = 0; i < num_empty_slots_; ++i) { - entities_.pop_back(); - } - num_empty_slots_ = 0; - } -} - -int ChannelzRegistry::FindByUuidLocked(intptr_t target_uuid, - bool direct_hit_needed) { - int left = 0; - int right = int(entities_.size() - 1); - while (left <= right) { - int true_middle = left + (right - left) / 2; - int first_non_null = true_middle; - while (first_non_null < right && entities_[first_non_null] == nullptr) { - first_non_null++; - } - if (entities_[first_non_null] == nullptr) { - right = true_middle - 1; - continue; - } - intptr_t uuid = entities_[first_non_null]->uuid(); - if (uuid == target_uuid) { - return int(first_non_null); - } - if (uuid < target_uuid) { - left = first_non_null + 1; - } else { - right = true_middle - 1; - } - } - return direct_hit_needed ? -1 : left; + node_map_[node->uuid_] = node; } void ChannelzRegistry::InternalUnregister(intptr_t uuid) { GPR_ASSERT(uuid >= 1); MutexLock lock(&mu_); GPR_ASSERT(uuid <= uuid_generator_); - int idx = FindByUuidLocked(uuid, true); - GPR_ASSERT(idx >= 0); - entities_[idx] = nullptr; - num_empty_slots_++; - MaybePerformCompactionLocked(); + node_map_.erase(uuid); } RefCountedPtr ChannelzRegistry::InternalGet(intptr_t uuid) { @@ -122,12 +70,13 @@ RefCountedPtr ChannelzRegistry::InternalGet(intptr_t uuid) { if (uuid < 1 || uuid > uuid_generator_) { return nullptr; } - int idx = FindByUuidLocked(uuid, true); - if (idx < 0 || entities_[idx] == nullptr) return nullptr; + auto it = node_map_.find(uuid); + if (it == node_map_.end()) return nullptr; // Found node. Return only if its refcount is not zero (i.e., when we // know that there is no other thread about to destroy it). - if (!entities_[idx]->RefIfNonZero()) return nullptr; - return RefCountedPtr(entities_[idx]); + BaseNode* node = it->second; + if (!node->RefIfNonZero()) return nullptr; + return RefCountedPtr(node); } char* ChannelzRegistry::InternalGetTopChannels(intptr_t start_channel_id) { @@ -138,13 +87,11 @@ char* ChannelzRegistry::InternalGetTopChannels(intptr_t start_channel_id) { RefCountedPtr node_after_pagination_limit; { MutexLock lock(&mu_); - const int start_idx = GPR_MAX(FindByUuidLocked(start_channel_id, false), 0); - for (size_t i = start_idx; i < entities_.size(); ++i) { - if (entities_[i] != nullptr && - entities_[i]->type() == - grpc_core::channelz::BaseNode::EntityType::kTopLevelChannel && - entities_[i]->uuid() >= start_channel_id && - entities_[i]->RefIfNonZero()) { + for (auto it = node_map_.lower_bound(start_channel_id); + it != node_map_.end(); ++it) { + BaseNode* node = it->second; + if (node->type() == BaseNode::EntityType::kTopLevelChannel && + node->RefIfNonZero()) { // Check if we are over pagination limit to determine if we need to set // the "end" element. If we don't go through this block, we know that // when the loop terminates, we have <= to kPaginationLimit. @@ -152,10 +99,10 @@ char* ChannelzRegistry::InternalGetTopChannels(intptr_t start_channel_id) { // refcount, we need to decrease it, but we can't unref while // holding the lock, because this may lead to a deadlock. if (top_level_channels.size() == kPaginationLimit) { - node_after_pagination_limit.reset(entities_[i]); + node_after_pagination_limit.reset(node); break; } - top_level_channels.emplace_back(entities_[i]); + top_level_channels.emplace_back(node); } } } @@ -186,13 +133,11 @@ char* ChannelzRegistry::InternalGetServers(intptr_t start_server_id) { RefCountedPtr node_after_pagination_limit; { MutexLock lock(&mu_); - const int start_idx = GPR_MAX(FindByUuidLocked(start_server_id, false), 0); - for (size_t i = start_idx; i < entities_.size(); ++i) { - if (entities_[i] != nullptr && - entities_[i]->type() == - grpc_core::channelz::BaseNode::EntityType::kServer && - entities_[i]->uuid() >= start_server_id && - entities_[i]->RefIfNonZero()) { + for (auto it = node_map_.lower_bound(start_server_id); + it != node_map_.end(); ++it) { + BaseNode* node = it->second; + if (node->type() == BaseNode::EntityType::kServer && + node->RefIfNonZero()) { // Check if we are over pagination limit to determine if we need to set // the "end" element. If we don't go through this block, we know that // when the loop terminates, we have <= to kPaginationLimit. @@ -200,10 +145,10 @@ char* ChannelzRegistry::InternalGetServers(intptr_t start_server_id) { // refcount, we need to decrease it, but we can't unref while // holding the lock, because this may lead to a deadlock. if (servers.size() == kPaginationLimit) { - node_after_pagination_limit.reset(entities_[i]); + node_after_pagination_limit.reset(node); break; } - servers.emplace_back(entities_[i]); + servers.emplace_back(node); } } } @@ -230,9 +175,10 @@ void ChannelzRegistry::InternalLogAllEntities() { InlinedVector, 10> nodes; { MutexLock lock(&mu_); - for (size_t i = 0; i < entities_.size(); ++i) { - if (entities_[i] != nullptr && entities_[i]->RefIfNonZero()) { - nodes.emplace_back(entities_[i]); + for (auto& p : node_map_) { + BaseNode* node = p.second; + if (node->RefIfNonZero()) { + nodes.emplace_back(node); } } } diff --git a/src/core/lib/channel/channelz_registry.h b/src/core/lib/channel/channelz_registry.h index b9d42ecf4d6..e04d7c44888 100644 --- a/src/core/lib/channel/channelz_registry.h +++ b/src/core/lib/channel/channelz_registry.h @@ -21,19 +21,16 @@ #include +#include + #include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/channel/channelz.h" -#include "src/core/lib/gprpp/inlined_vector.h" - -#include +#include "src/core/lib/gprpp/map.h" +#include "src/core/lib/gprpp/sync.h" namespace grpc_core { namespace channelz { -namespace testing { -class ChannelzRegistryPeer; -} - // singleton registry object to track all objects that are needed to support // channelz bookkeeping. All objects share globally distributed uuids. class ChannelzRegistry { @@ -69,13 +66,6 @@ class ChannelzRegistry { static void LogAllEntities() { Default()->InternalLogAllEntities(); } private: - GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW - GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE - friend class testing::ChannelzRegistryPeer; - - ChannelzRegistry(); - ~ChannelzRegistry(); - // Returned the singleton instance of ChannelzRegistry; static ChannelzRegistry* Default(); @@ -93,22 +83,12 @@ class ChannelzRegistry { char* InternalGetTopChannels(intptr_t start_channel_id); char* InternalGetServers(intptr_t start_server_id); - // If entities_ has over a certain threshold of empty slots, it will - // compact the vector and move all used slots to the front. - void MaybePerformCompactionLocked(); - - // Performs binary search on entities_ to find the index with that uuid. - // If direct_hit_needed, then will return -1 in case of absence. - // Else, will return idx of the first uuid higher than the target. - int FindByUuidLocked(intptr_t uuid, bool direct_hit_needed); - void InternalLogAllEntities(); // protects members - gpr_mu mu_; - InlinedVector entities_; + Mutex mu_; + Map node_map_; intptr_t uuid_generator_ = 0; - int num_empty_slots_ = 0; }; } // namespace channelz diff --git a/src/core/lib/gprpp/map.h b/src/core/lib/gprpp/map.h index 525c25347f4..36e32d60c07 100644 --- a/src/core/lib/gprpp/map.h +++ b/src/core/lib/gprpp/map.h @@ -22,8 +22,11 @@ #include #include + +#include #include #include + #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/pair.h" @@ -88,6 +91,13 @@ class Map { iterator end() { return iterator(this, nullptr); } + iterator lower_bound(const Key& k) { + key_compare compare; + return std::find_if(begin(), end(), [&k, &compare](const value_type& v) { + return !compare(v.first, k); + }); + } + private: friend class testing::MapTest; struct Entry { diff --git a/test/core/channel/channelz_registry_test.cc b/test/core/channel/channelz_registry_test.cc index 030d52fd548..deb85d85624 100644 --- a/test/core/channel/channelz_registry_test.cc +++ b/test/core/channel/channelz_registry_test.cc @@ -43,16 +43,6 @@ namespace grpc_core { namespace channelz { namespace testing { -class ChannelzRegistryPeer { - public: - const InlinedVector* entities() { - return &ChannelzRegistry::Default()->entities_; - } - int num_empty_slots() { - return ChannelzRegistry::Default()->num_empty_slots_; - } -}; - class ChannelzRegistryTest : public ::testing::Test { protected: // ensure we always have a fresh registry for tests. @@ -115,38 +105,15 @@ TEST_F(ChannelzRegistryTest, NullIfNotPresentTest) { EXPECT_EQ(channelz_channel, retrieved); } -TEST_F(ChannelzRegistryTest, TestCompaction) { - const int kLoopIterations = 300; - // These channels that will stay in the registry for the duration of the test. - std::vector> even_channels; - even_channels.reserve(kLoopIterations); - { - // The channels will unregister themselves at the end of the for block. - std::vector> odd_channels; - odd_channels.reserve(kLoopIterations); - for (int i = 0; i < kLoopIterations; i++) { - even_channels.push_back( - MakeRefCounted(BaseNode::EntityType::kTopLevelChannel)); - odd_channels.push_back( - MakeRefCounted(BaseNode::EntityType::kTopLevelChannel)); - } - } - // without compaction, there would be exactly kLoopIterations empty slots at - // this point. However, one of the unregisters should have triggered - // compaction. - ChannelzRegistryPeer peer; - EXPECT_LT(peer.num_empty_slots(), kLoopIterations); -} - -TEST_F(ChannelzRegistryTest, TestGetAfterCompaction) { +TEST_F(ChannelzRegistryTest, TestUnregistration) { const int kLoopIterations = 100; - // These channels that will stay in the registry for the duration of the test. + // These channels will stay in the registry for the duration of the test. std::vector> even_channels; even_channels.reserve(kLoopIterations); std::vector odd_uuids; odd_uuids.reserve(kLoopIterations); { - // The channels will unregister themselves at the end of the for block. + // These channels will unregister themselves at the end of this block. std::vector> odd_channels; odd_channels.reserve(kLoopIterations); for (int i = 0; i < kLoopIterations; i++) { @@ -157,6 +124,7 @@ TEST_F(ChannelzRegistryTest, TestGetAfterCompaction) { odd_uuids.push_back(odd_channels[i]->uuid()); } } + // Check that the even channels are present and the odd channels are not. for (int i = 0; i < kLoopIterations; i++) { RefCountedPtr retrieved = ChannelzRegistry::Get(even_channels[i]->uuid()); @@ -164,27 +132,8 @@ TEST_F(ChannelzRegistryTest, TestGetAfterCompaction) { retrieved = ChannelzRegistry::Get(odd_uuids[i]); EXPECT_EQ(retrieved, nullptr); } -} - -TEST_F(ChannelzRegistryTest, TestAddAfterCompaction) { - const int kLoopIterations = 100; - // These channels that will stay in the registry for the duration of the test. - std::vector> even_channels; - even_channels.reserve(kLoopIterations); - std::vector odd_uuids; - odd_uuids.reserve(kLoopIterations); - { - // The channels will unregister themselves at the end of the for block. - std::vector> odd_channels; - odd_channels.reserve(kLoopIterations); - for (int i = 0; i < kLoopIterations; i++) { - even_channels.push_back( - MakeRefCounted(BaseNode::EntityType::kTopLevelChannel)); - odd_channels.push_back( - MakeRefCounted(BaseNode::EntityType::kTopLevelChannel)); - odd_uuids.push_back(odd_channels[i]->uuid()); - } - } + // Add more channels and verify that they get added correctly, to make + // sure that the unregistration didn't leave the registry in a weird state. std::vector> more_channels; more_channels.reserve(kLoopIterations); for (int i = 0; i < kLoopIterations; i++) { diff --git a/test/core/gprpp/map_test.cc b/test/core/gprpp/map_test.cc index 6e70a2a2ac2..30d9eb0b207 100644 --- a/test/core/gprpp/map_test.cc +++ b/test/core/gprpp/map_test.cc @@ -419,6 +419,24 @@ TEST_F(MapTest, RandomOpsWithIntKey) { EXPECT_TRUE(test_map.empty()); } +// Tests lower_bound(). +TEST_F(MapTest, LowerBound) { + Map test_map; + for (int i = 0; i < 10; i += 2) { + test_map.emplace(i, Payload(i)); + } + auto it = test_map.lower_bound(-1); + EXPECT_EQ(it, test_map.begin()); + it = test_map.lower_bound(0); + EXPECT_EQ(it, test_map.begin()); + it = test_map.lower_bound(2); + EXPECT_EQ(it->first, 2); + it = test_map.lower_bound(3); + EXPECT_EQ(it->first, 4); + it = test_map.lower_bound(9); + EXPECT_EQ(it, test_map.end()); +} + } // namespace testing } // namespace grpc_core From 79ffaced7d01a38d7ba0aa37ce75767420cbaa8e Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Fri, 7 Jun 2019 10:09:07 -0700 Subject: [PATCH 0470/1555] Add python 3.8 test --- .../Dockerfile.template | 28 +++++++ .../test/python_stretch_3.8_x64/Dockerfile | 79 +++++++++++++++++++ .../python_stretch_3.8_x64/get_cpython.sh | 15 ++++ tools/run_tests/run_tests.py | 13 ++- 4 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 templates/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile.template create mode 100644 tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile create mode 100644 tools/dockerfile/test/python_stretch_3.8_x64/get_cpython.sh diff --git a/templates/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile.template new file mode 100644 index 00000000000..8f2585a4d59 --- /dev/null +++ b/templates/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile.template @@ -0,0 +1,28 @@ + +%YAML 1.2 +--- | + # Copyright 2019 The gRPC Authors + # + # Licensed under the Apache License, Version 2.0 (the "License"); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + + <%include file="../../python_stretch.include"/> + RUN apt-get install -y jq zlib1g-dev libssl-dev + + COPY get_cpython.sh /tmp + RUN apt-get install -y jq build-essential libffi-dev && ${'\\'} + chmod +x /tmp/get_cpython.sh && ${'\\'} + /tmp/get_cpython.sh && ${'\\'} + rm /tmp/get_cpython.sh + + RUN python3.8 -m ensurepip && ${'\\'} + python3.8 -m pip install coverage diff --git a/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile b/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile new file mode 100644 index 00000000000..d5ecbc7110a --- /dev/null +++ b/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile @@ -0,0 +1,79 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM debian:stretch + +# Install Git and basic packages. +RUN apt-get update && apt-get install -y \ + autoconf \ + autotools-dev \ + build-essential \ + bzip2 \ + ccache \ + curl \ + dnsutils \ + gcc \ + gcc-multilib \ + git \ + golang \ + gyp \ + lcov \ + libc6 \ + libc6-dbg \ + libc6-dev \ + libgtest-dev \ + libtool \ + make \ + perl \ + strace \ + python-dev \ + python-setuptools \ + python-yaml \ + telnet \ + unzip \ + wget \ + zip && apt-get clean + +#================ +# Build profiling +RUN apt-get update && apt-get install -y time && apt-get clean + +# Google Cloud platform API libraries +RUN apt-get update && apt-get install -y python-pip && apt-get clean +RUN pip install --upgrade google-api-python-client oauth2client + +# Install Python 2.7 +RUN apt-get update && apt-get install -y python2.7 python-all-dev +RUN curl https://bootstrap.pypa.io/get-pip.py | python2.7 + +# Add Debian 'testing' repository +RUN echo 'deb http://ftp.de.debian.org/debian testing main' >> /etc/apt/sources.list +RUN echo 'APT::Default-Release "stable";' | tee -a /etc/apt/apt.conf.d/00local + + +RUN mkdir /var/local/jenkins + +# Define the default command. +CMD ["bash"] + +RUN apt-get install -y jq zlib1g-dev libssl-dev + +COPY get_cpython.sh /tmp +RUN apt-get install -y jq build-essential libffi-dev && \ + chmod +x /tmp/get_cpython.sh && \ + /tmp/get_cpython.sh && \ + rm /tmp/get_cpython.sh + +RUN python3.8 -m ensurepip && \ + python3.8 -m pip install coverage diff --git a/tools/dockerfile/test/python_stretch_3.8_x64/get_cpython.sh b/tools/dockerfile/test/python_stretch_3.8_x64/get_cpython.sh new file mode 100644 index 00000000000..c01c6ebb0d2 --- /dev/null +++ b/tools/dockerfile/test/python_stretch_3.8_x64/get_cpython.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +VERSION_REGEX="v3.8.*" +REPO="python/cpython" + +LATEST=$(curl -s https://api.github.com/repos/$REPO/tags | \ + jq -r '.[] | select(.name|test("'$VERSION_REGEX'")) | .name' \ + | sort | tail -n1) + +wget https://github.com/$REPO/archive/$LATEST.tar.gz +tar xzvf *.tar.gz +( cd cpython* + ./configure + make install +) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index a7a9dbd48d0..108cf29c0a8 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -753,7 +753,7 @@ class PythonLanguage(object): def _python_manager_name(self): """Choose the docker image to use based on python version.""" if self.args.compiler in [ - 'python2.7', 'python3.5', 'python3.6', 'python3.7' + 'python2.7', 'python3.5', 'python3.6', 'python3.7', 'python3.8' ]: return 'stretch_' + self.args.compiler[len('python'):] elif self.args.compiler == 'python_alpine': @@ -829,6 +829,12 @@ class PythonLanguage(object): minor='7', bits=bits, config_vars=config_vars) + python38_config = _python_config_generator( + name='py38', + major='3', + minor='8', + bits=bits, + config_vars=config_vars) pypy27_config = _pypy_config_generator( name='pypy', major='2', config_vars=config_vars) pypy32_config = _pypy_config_generator( @@ -852,6 +858,8 @@ class PythonLanguage(object): return (python36_config,) elif args.compiler == 'python3.7': return (python37_config,) + elif args.compiler == 'python3.8': + return (python38_config,) elif args.compiler == 'pypy': return (pypy27_config,) elif args.compiler == 'pypy3': @@ -865,6 +873,7 @@ class PythonLanguage(object): python35_config, python36_config, python37_config, + # TODO: Add Python 3.8 once it's released. ) else: raise Exception('Compiler %s not supported.' % args.compiler) @@ -1340,7 +1349,7 @@ argp.add_argument( choices=[ 'default', 'gcc4.4', 'gcc4.6', 'gcc4.8', 'gcc4.9', 'gcc5.3', 'gcc7.2', 'gcc_musl', 'clang3.4', 'clang3.5', 'clang3.6', 'clang3.7', 'clang7.0', - 'python2.7', 'python3.4', 'python3.5', 'python3.6', 'python3.7', 'pypy', + 'python2.7', 'python3.4', 'python3.5', 'python3.6', 'python3.7', 'python3.8', 'pypy', 'pypy3', 'python_alpine', 'all_the_cpythons', 'electron1.3', 'electron1.6', 'coreclr', 'cmake', 'cmake_vs2015', 'cmake_vs2017' ], From 2b6e7c44235522c125dbc14e6b82e18c8aab62cd Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Wed, 8 May 2019 14:29:11 -0700 Subject: [PATCH 0471/1555] Added some Objective C tests and minor bug fixes. Objective-C tests: metadata, compression, keepalives, channel args. Stress tests: network flap while streaming call in progress. Bug fixes: Stream gzip handling in interop server. Keep alive, backoff time truncation bug in Obj-C layer. --- .../GRPCClient/GRPCCall+ChannelArg.m | 3 + src/objective-c/GRPCClient/GRPCCallOptions.h | 5 +- src/objective-c/GRPCClient/GRPCCallOptions.m | 10 +- .../GRPCClient/private/GRPCChannel.m | 2 + .../GRPCClient/private/GRPCChannelPool.m | 4 +- src/objective-c/GRPCClient/private/GRPCHost.m | 10 +- .../InteropTestsRemoteWithCronet.m | 4 + .../tests/InteropTests/InteropTests.h | 6 + .../tests/InteropTests/InteropTests.m | 190 ++++++++- .../tests/InteropTests/InteropTestsRemote.m | 4 + src/objective-c/tests/MacTests/StressTests.m | 383 +++++++++++++++++- src/objective-c/tests/UnitTests/APIv2Tests.m | 330 ++++++++++++++- test/cpp/interop/interop_server.cc | 3 +- 13 files changed, 921 insertions(+), 33 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m index ae60d6208e1..78fe687b3d4 100644 --- a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m @@ -51,6 +51,9 @@ case GRPCCompressGzip: hostConfig.compressAlgorithm = GRPC_COMPRESS_GZIP; break; + case GRPCStreamCompressGzip: + hostConfig.compressAlgorithm = GRPC_COMPRESS_STREAM_GZIP; + break; default: NSLog(@"Invalid compression algorithm"); abort(); diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.h b/src/objective-c/GRPCClient/GRPCCallOptions.h index 98511e3f5cb..b957e11fbea 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.h +++ b/src/objective-c/GRPCClient/GRPCCallOptions.h @@ -156,7 +156,8 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { // HTTP/2 keep-alive feature. The parameter \a keepaliveInterval specifies the interval between two // PING frames. The parameter \a keepaliveTimeout specifies the length of the period for which the // call should wait for PING ACK. If PING ACK is not received after this period, the call fails. -// Negative values are not allowed. +// Negative values are invalid; setting these parameters to negative value will reset the +// corresponding parameter to the internal default value. @property(readonly) NSTimeInterval keepaliveInterval; @property(readonly) NSTimeInterval keepaliveTimeout; @@ -320,7 +321,7 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { // PING frames. The parameter \a keepaliveTimeout specifies the length of the period for which the // call should wait for PING ACK. If PING ACK is not received after this period, the call fails. // Negative values are invalid; setting these parameters to negative value will reset the -// corresponding parameter to 0. +// corresponding parameter to the internal default value. @property(readwrite) NSTimeInterval keepaliveInterval; @property(readwrite) NSTimeInterval keepaliveTimeout; diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.m b/src/objective-c/GRPCClient/GRPCCallOptions.m index 392e42a9d47..f02486a7c44 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.m +++ b/src/objective-c/GRPCClient/GRPCCallOptions.m @@ -30,7 +30,7 @@ static const NSUInteger kDefaultResponseSizeLimit = 0; static const GRPCCompressionAlgorithm kDefaultCompressionAlgorithm = GRPCCompressNone; static const BOOL kDefaultRetryEnabled = YES; static const NSTimeInterval kDefaultKeepaliveInterval = 0; -static const NSTimeInterval kDefaultKeepaliveTimeout = 0; +static const NSTimeInterval kDefaultKeepaliveTimeout = -1; static const NSTimeInterval kDefaultConnectMinTimeout = 0; static const NSTimeInterval kDefaultConnectInitialBackoff = 0; static const NSTimeInterval kDefaultConnectMaxBackoff = 0; @@ -181,7 +181,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { _compressionAlgorithm = compressionAlgorithm; _retryEnabled = retryEnabled; _keepaliveInterval = keepaliveInterval < 0 ? 0 : keepaliveInterval; - _keepaliveTimeout = keepaliveTimeout < 0 ? 0 : keepaliveTimeout; + _keepaliveTimeout = keepaliveTimeout; _connectMinTimeout = connectMinTimeout < 0 ? 0 : connectMinTimeout; _connectInitialBackoff = connectInitialBackoff < 0 ? 0 : connectInitialBackoff; _connectMaxBackoff = connectMaxBackoff < 0 ? 0 : connectMaxBackoff; @@ -486,11 +486,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { } - (void)setKeepaliveTimeout:(NSTimeInterval)keepaliveTimeout { - if (keepaliveTimeout < 0) { - _keepaliveTimeout = 0; - } else { - _keepaliveTimeout = keepaliveTimeout; - } + _keepaliveTimeout = keepaliveTimeout; } - (void)setConnectMinTimeout:(NSTimeInterval)connectMinTimeout { diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m index 1a79fb04a0d..4a187ae9081 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCChannel.m @@ -109,6 +109,8 @@ if (_callOptions.keepaliveInterval != 0) { args[@GRPC_ARG_KEEPALIVE_TIME_MS] = [NSNumber numberWithUnsignedInteger:(NSUInteger)(_callOptions.keepaliveInterval * 1000)]; + } + if (_callOptions.keepaliveTimeout >= 0) { args[@GRPC_ARG_KEEPALIVE_TIMEOUT_MS] = [NSNumber numberWithUnsignedInteger:(NSUInteger)(_callOptions.keepaliveTimeout * 1000)]; } diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.m b/src/objective-c/GRPCClient/private/GRPCChannelPool.m index 60a33eda824..24ed83d3341 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannelPool.m +++ b/src/objective-c/GRPCClient/private/GRPCChannelPool.m @@ -118,9 +118,7 @@ static const NSTimeInterval kDefaultChannelDestroyDelay = 30; _lastTimedDestroy = nil; grpc_call *unmanagedCall = - [_wrappedChannel unmanagedCallWithPath:path - completionQueue:[GRPCCompletionQueue completionQueue] - callOptions:callOptions]; + [_wrappedChannel unmanagedCallWithPath:path completionQueue:queue callOptions:callOptions]; if (unmanagedCall == NULL) { NSAssert(unmanagedCall != NULL, @"Unable to create grpc_call object"); return nil; diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m index 24348c3aed7..c4287731efd 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCHost.m @@ -105,11 +105,11 @@ static NSMutableDictionary *gHostCache; options.responseSizeLimit = _responseSizeLimitOverride; options.compressionAlgorithm = (GRPCCompressionAlgorithm)_compressAlgorithm; options.retryEnabled = _retryEnabled; - options.keepaliveInterval = (NSTimeInterval)_keepaliveInterval / 1000; - options.keepaliveTimeout = (NSTimeInterval)_keepaliveTimeout / 1000; - options.connectMinTimeout = (NSTimeInterval)_minConnectTimeout / 1000; - options.connectInitialBackoff = (NSTimeInterval)_initialConnectBackoff / 1000; - options.connectMaxBackoff = (NSTimeInterval)_maxConnectBackoff / 1000; + options.keepaliveInterval = (NSTimeInterval)_keepaliveInterval / 1000.0; + options.keepaliveTimeout = (NSTimeInterval)_keepaliveTimeout / 1000.0; + options.connectMinTimeout = (NSTimeInterval)_minConnectTimeout / 1000.0; + options.connectInitialBackoff = (NSTimeInterval)_initialConnectBackoff / 1000.0; + options.connectMaxBackoff = (NSTimeInterval)_maxConnectBackoff / 1000.0; options.PEMRootCertificates = _PEMRootCertificates; options.PEMPrivateKey = _PEMPrivateKey; options.PEMCertificateChain = _PEMCertificateChain; diff --git a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m index a2a79c46316..30741e9a0da 100644 --- a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m +++ b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m @@ -48,6 +48,10 @@ static int32_t kRemoteInteropServerOverhead = 12; return YES; } ++ (BOOL)canRunCompressionTest { + return NO; +} + - (int32_t)encodingOverhead { return kRemoteInteropServerOverhead; // bytes } diff --git a/src/objective-c/tests/InteropTests/InteropTests.h b/src/objective-c/tests/InteropTests/InteropTests.h index cffa90ac497..0c896ae18a8 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.h +++ b/src/objective-c/tests/InteropTests/InteropTests.h @@ -64,4 +64,10 @@ */ + (BOOL)useCronet; +/** + * Whether we can run compression tests in the test suite. + */ + ++ (BOOL)canRunCompressionTest; + @end diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 7d4aee0bc90..aa7a41163d4 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -347,6 +347,10 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager return NO; } ++ (BOOL)canRunCompressionTest { + return YES; +} + + (void)setUp { #ifdef GRPC_COMPILE_WITH_CRONET configureCronet(); @@ -430,10 +434,16 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager __block BOOL messageReceived = NO; __block BOOL done = NO; + __block BOOL initialMetadataReceived = YES; NSCondition *cond = [[NSCondition alloc] init]; GRPCUnaryProtoCall *call = [_service emptyCallWithMessage:request - responseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil + responseHandler:[[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { + [cond lock]; + initialMetadataReceived = YES; + [cond unlock]; + } messageCallback:^(id message) { if (message) { id expectedResponse = [GPBEmpty message]; @@ -459,6 +469,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager while (!done && [deadline timeIntervalSinceNow] > 0) { [cond waitUntilDate:deadline]; } + XCTAssertTrue(initialMetadataReceived); XCTAssertTrue(messageReceived); XCTAssertTrue(done); [cond unlock]; @@ -1014,6 +1025,78 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; } +- (void)testInitialMetadataWithV2API { + __weak XCTestExpectation *initialMetadataReceived = + [self expectationWithDescription:@"Received initial metadata."]; + __weak XCTestExpectation *closeReceived = [self expectationWithDescription:@"RPC completed."]; + + __block NSDictionary *init_md = + [NSDictionary dictionaryWithObjectsAndKeys:@"FOOBAR", @"x-grpc-test-echo-initial", nil]; + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + options.initialMetadata = init_md; + options.transportType = self.class.transportType; + options.PEMRootCertificates = self.class.PEMRootCertificates; + options.hostNameOverride = [[self class] hostNameOverride]; + RMTSimpleRequest *request = [RMTSimpleRequest message]; + __block bool init_md_received = NO; + GRPCUnaryProtoCall *call = [_service + unaryCallWithMessage:request + responseHandler:[[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { + XCTAssertEqualObjects(initialMetadata[@"x-grpc-test-echo-initial"], + init_md[@"x-grpc-test-echo-initial"]); + init_md_received = YES; + [initialMetadataReceived fulfill]; + } + messageCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + XCTAssertNil(error, @"Unexpected error: %@", error); + [closeReceived fulfill]; + }] + callOptions:options]; + + [call start]; + [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; +} + +- (void)testTrailingMetadataWithV2API { + // This test needs to be disabled for remote test because interop server grpc-test + // does not send trailing binary metadata. + if (isRemoteInteropTest([[self class] host])) { + return; + } + + __weak XCTestExpectation *expectation = + [self expectationWithDescription:@"Received trailing metadata."]; + const unsigned char raw_bytes[] = {0x1, 0x2, 0x3, 0x4}; + NSData *trailer_data = [NSData dataWithBytes:raw_bytes length:sizeof(raw_bytes)]; + __block NSDictionary *trailer = [NSDictionary + dictionaryWithObjectsAndKeys:trailer_data, @"x-grpc-test-echo-trailing-bin", nil]; + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + options.initialMetadata = trailer; + options.transportType = self.class.transportType; + options.PEMRootCertificates = self.class.PEMRootCertificates; + options.hostNameOverride = [[self class] hostNameOverride]; + RMTSimpleRequest *request = [RMTSimpleRequest message]; + GRPCUnaryProtoCall *call = [_service + unaryCallWithMessage:request + responseHandler: + [[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + XCTAssertNil(error, @"Unexpected error: %@", error); + XCTAssertEqualObjects( + trailingMetadata[@"x-grpc-test-echo-trailing-bin"], + trailer[@"x-grpc-test-echo-trailing-bin"]); + [expectation fulfill]; + }] + callOptions:options]; + [call start]; + [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; +} + - (void)testCancelAfterFirstResponseRPC { XCTAssertNotNil([[self class] host]); __weak XCTestExpectation *expectation = @@ -1148,13 +1231,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; } -- (void)testCompressedUnaryRPC { - // This test needs to be disabled for remote test because interop server grpc-test - // does not support compression. - if (isRemoteInteropTest([[self class] host])) { - return; - } - XCTAssertNotNil([[self class] host]); +- (void)RPCWithCompressMethod:(GRPCCompressionAlgorithm)compressMethod { __weak XCTestExpectation *expectation = [self expectationWithDescription:@"LargeUnary"]; RMTSimpleRequest *request = [RMTSimpleRequest message]; @@ -1162,7 +1239,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager request.responseSize = 314159; request.payload.body = [NSMutableData dataWithLength:271828]; request.expectCompressed.value = YES; - [GRPCCall setDefaultCompressMethod:GRPCCompressGzip forhost:[[self class] host]]; + [GRPCCall setDefaultCompressMethod:compressMethod forhost:[[self class] host]]; [_service unaryCallWithRequest:request handler:^(RMTSimpleResponse *response, NSError *error) { @@ -1179,6 +1256,67 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; } +- (void)RPCWithCompressMethodWithV2API:(GRPCCompressionAlgorithm)compressMethod { + __weak XCTestExpectation *expectMessage = + [self expectationWithDescription:@"Reived response from server."]; + __weak XCTestExpectation *expectComplete = [self expectationWithDescription:@"RPC completed."]; + + RMTSimpleRequest *request = [RMTSimpleRequest message]; + request.responseType = RMTPayloadType_Compressable; + request.responseSize = 314159; + request.payload.body = [NSMutableData dataWithLength:271828]; + request.expectCompressed.value = YES; + + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + options.transportType = self.class.transportType; + options.PEMRootCertificates = self.class.PEMRootCertificates; + options.hostNameOverride = [[self class] hostNameOverride]; + options.compressionAlgorithm = compressMethod; + + GRPCUnaryProtoCall *call = [_service + unaryCallWithMessage:request + responseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil + messageCallback:^(id message) { + XCTAssertNotNil(message); + if (message) { + RMTSimpleResponse *expectedResponse = + [RMTSimpleResponse message]; + expectedResponse.payload.type = RMTPayloadType_Compressable; + expectedResponse.payload.body = + [NSMutableData dataWithLength:314159]; + XCTAssertEqualObjects(message, expectedResponse); + + [expectMessage fulfill]; + } + } + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + XCTAssertNil(error, @"Unexpected error: %@", error); + [expectComplete fulfill]; + }] + callOptions:options]; + [call start]; + + [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; +} + +- (void)testCompressedUnaryRPC { + if ([[self class] canRunCompressionTest]) { + for (GRPCCompressionAlgorithm compress = GRPCCompressDeflate; + compress <= GRPCStreamCompressGzip; ++compress) { + [self RPCWithCompressMethod:compress]; + } + } +} + +- (void)testCompressedUnaryRPCWithV2API { + if ([[self class] canRunCompressionTest]) { + for (GRPCCompressionAlgorithm compress = GRPCCompressDeflate; + compress <= GRPCStreamCompressGzip; ++compress) { + [self RPCWithCompressMethodWithV2API:compress]; + } + } +} + #ifndef GRPC_COMPILE_WITH_CRONET - (void)testKeepalive { XCTAssertNotNil([[self class] host]); @@ -1220,6 +1358,40 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; } + +- (void)testKeepaliveWithV2API { + XCTAssertNotNil([[self class] host]); + __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Keepalive"]; + + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + options.transportType = self.class.transportType; + options.PEMRootCertificates = self.class.PEMRootCertificates; + options.hostNameOverride = [[self class] hostNameOverride]; + options.keepaliveInterval = 1.5; + options.keepaliveTimeout = 0; + + id request = + [RMTStreamingOutputCallRequest messageWithPayloadSize:@21782 requestedResponseSize:@31415]; + + __block GRPCStreamingProtoCall *call = [_service + fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:nil + closeCallback:^( + NSDictionary *trailingMetadata, + NSError *error) { + XCTAssertNotNil(error); + XCTAssertEqual( + error.code, + GRPC_STATUS_UNAVAILABLE); + [expectation fulfill]; + }] + callOptions:options]; + [call start]; + [call writeMessage:request]; + + [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; +} #endif - (void)testDefaultInterceptor { diff --git a/src/objective-c/tests/InteropTests/InteropTestsRemote.m b/src/objective-c/tests/InteropTests/InteropTestsRemote.m index c1cd9b81efc..7bd5b28780c 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsRemote.m +++ b/src/objective-c/tests/InteropTests/InteropTestsRemote.m @@ -49,6 +49,10 @@ static int32_t kRemoteInteropServerOverhead = 12; return nil; } ++ (BOOL)canRunCompressionTest { + return NO; +} + - (int32_t)encodingOverhead { return kRemoteInteropServerOverhead; // bytes } diff --git a/src/objective-c/tests/MacTests/StressTests.m b/src/objective-c/tests/MacTests/StressTests.m index 22174b58665..7475dc77fcc 100644 --- a/src/objective-c/tests/MacTests/StressTests.m +++ b/src/objective-c/tests/MacTests/StressTests.m @@ -29,7 +29,7 @@ #import #import -#define TEST_TIMEOUT 32 +#define TEST_TIMEOUT 64 extern const char *kCFStreamVarName; @@ -136,7 +136,11 @@ extern const char *kCFStreamVarName; return GRPCTransportTypeChttp2BoringSSL; } -- (void)testNetworkFlapWithV2API { +- (int)getRandomNumberBetween:(int)min max:(int)max { + return min + arc4random_uniform((max - min + 1)); +} + +- (void)testNetworkFlapOnUnaryCallWithV2API { NSMutableArray *completeExpectations = [NSMutableArray array]; NSMutableArray *calls = [NSMutableArray array]; int num_rpcs = 100; @@ -175,6 +179,7 @@ extern const char *kCFStreamVarName; UTF8String]); address_removed = YES; } else if (error != nil && !address_readded) { + XCTAssertTrue(address_removed); system([ [NSString stringWithFormat:@"sudo ifconfig lo0 alias %@", [[self class] hostAddress]] @@ -196,7 +201,241 @@ extern const char *kCFStreamVarName; [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; } -- (void)testNetworkFlapWithV1API { +- (void)testNetworkFlapOnClientStreamingCallWithV2API { + NSMutableArray *completeExpectations = [NSMutableArray array]; + NSMutableArray *calls = [NSMutableArray array]; + int num_rpcs = 100; + __block BOOL address_removed = FALSE; + __block BOOL address_readded = FALSE; + for (int i = 0; i < num_rpcs; ++i) { + [completeExpectations + addObject:[self expectationWithDescription: + [NSString stringWithFormat:@"Received trailer for RPC %d", i]]]; + + GRPCStreamingProtoCall *call = [_service + streamingInputCallWithResponseHandler: + [[MacTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + @synchronized(self) { + if (error == nil && !address_removed) { + system([[NSString + stringWithFormat:@"sudo ifconfig lo0 -alias %@", + [[self class] hostAddress]] + UTF8String]); + address_removed = YES; + } else if (error != nil && !address_readded) { + XCTAssertTrue(address_removed); + system([[NSString + stringWithFormat:@"sudo ifconfig lo0 alias %@", + [[self class] hostAddress]] + UTF8String]); + address_readded = YES; + } + } + [completeExpectations[i] fulfill]; + }] + callOptions:nil]; + [calls addObject:call]; + } + + for (int i = 0; i < num_rpcs; ++i) { + GRPCStreamingProtoCall *call = calls[i]; + [call start]; + RMTStreamingInputCallRequest *request1 = [RMTStreamingInputCallRequest message]; + request1.payload.body = [NSMutableData dataWithLength:27182]; + RMTStreamingInputCallRequest *request2 = [RMTStreamingInputCallRequest message]; + request2.payload.body = [NSMutableData dataWithLength:8]; + + [call writeMessage:request1]; + [NSThread sleepForTimeInterval:0.1f]; + [call writeMessage:request2]; + [call finish]; + } + [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; +} + +- (void)testNetworkFlapOnServerStreamingCallWithV2API { + NSMutableArray *completeExpectations = [NSMutableArray array]; + NSMutableArray *calls = [NSMutableArray array]; + int num_rpcs = 100; + __block BOOL address_removed = FALSE; + __block BOOL address_readded = FALSE; + for (int i = 0; i < num_rpcs; ++i) { + [completeExpectations + addObject:[self expectationWithDescription: + [NSString stringWithFormat:@"Received trailer for RPC %d", i]]]; + + RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; + for (int i = 0; i < 5; i++) { + RMTResponseParameters *parameters = [RMTResponseParameters message]; + parameters.size = 10000; + [request.responseParametersArray addObject:parameters]; + } + + request.payload.body = [NSMutableData dataWithLength:100]; + + GRPCUnaryProtoCall *call = [_service + streamingOutputCallWithMessage:request + responseHandler: + [[MacTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + @synchronized(self) { + if (error == nil && !address_removed) { + system([[NSString + stringWithFormat: + @"sudo ifconfig lo0 -alias %@", + [[self class] hostAddress]] + UTF8String]); + address_removed = YES; + } else if (error != nil && !address_readded) { + XCTAssertTrue(address_removed); + system([[NSString + stringWithFormat: + @"sudo ifconfig lo0 alias %@", + [[self class] hostAddress]] + UTF8String]); + address_readded = YES; + } + } + [completeExpectations[i] fulfill]; + }] + callOptions:nil]; + [calls addObject:call]; + } + + for (int i = 0; i < num_rpcs; ++i) { + GRPCStreamingProtoCall *call = calls[i]; + [call start]; + [NSThread sleepForTimeInterval:0.1f]; + } + [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; +} + +- (void)testNetworkFlapOnHalfDuplexCallWithV2API { + NSMutableArray *completeExpectations = [NSMutableArray array]; + NSMutableArray *calls = [NSMutableArray array]; + int num_rpcs = 100; + __block BOOL address_removed = FALSE; + __block BOOL address_readded = FALSE; + for (int i = 0; i < num_rpcs; ++i) { + [completeExpectations + addObject:[self expectationWithDescription: + [NSString stringWithFormat:@"Received trailer for RPC %d", i]]]; + + GRPCStreamingProtoCall *call = [_service + halfDuplexCallWithResponseHandler: + [[MacTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + @synchronized(self) { + if (error == nil && !address_removed) { + system([[NSString + stringWithFormat:@"sudo ifconfig lo0 -alias %@", + [[self class] hostAddress]] + UTF8String]); + address_removed = YES; + } else if (error != nil && !address_readded) { + XCTAssertTrue(address_removed); + system([[NSString + stringWithFormat:@"sudo ifconfig lo0 alias %@", + [[self class] hostAddress]] + UTF8String]); + address_readded = YES; + } + } + [completeExpectations[i] fulfill]; + }] + callOptions:nil]; + [calls addObject:call]; + } + + for (int i = 0; i < num_rpcs; ++i) { + GRPCStreamingProtoCall *call = calls[i]; + [call start]; + RMTStreamingOutputCallRequest *request1 = [RMTStreamingOutputCallRequest message]; + RMTStreamingOutputCallRequest *request2 = [RMTStreamingOutputCallRequest message]; + for (int i = 0; i < 5; i++) { + RMTResponseParameters *parameters = [RMTResponseParameters message]; + parameters.size = 1000; + [request1.responseParametersArray addObject:parameters]; + [request2.responseParametersArray addObject:parameters]; + } + + request1.payload.body = [NSMutableData dataWithLength:100]; + request2.payload.body = [NSMutableData dataWithLength:100]; + + [call writeMessage:request1]; + [NSThread sleepForTimeInterval:0.1f]; + [call writeMessage:request2]; + [call finish]; + } + [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; +} + +- (void)testNetworkFlapOnFullDuplexCallWithV2API { + NSMutableArray *completeExpectations = [NSMutableArray array]; + NSMutableArray *calls = [NSMutableArray array]; + int num_rpcs = 100; + __block BOOL address_removed = FALSE; + __block BOOL address_readded = FALSE; + for (int i = 0; i < num_rpcs; ++i) { + [completeExpectations + addObject:[self expectationWithDescription: + [NSString stringWithFormat:@"Received trailer for RPC %d", i]]]; + + GRPCStreamingProtoCall *call = [_service + fullDuplexCallWithResponseHandler: + [[MacTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + @synchronized(self) { + if (error == nil && !address_removed) { + system([[NSString + stringWithFormat:@"sudo ifconfig lo0 -alias %@", + [[self class] hostAddress]] + UTF8String]); + address_removed = YES; + } else if (error != nil && !address_readded) { + XCTAssertTrue(address_removed); + system([[NSString + stringWithFormat:@"sudo ifconfig lo0 alias %@", + [[self class] hostAddress]] + UTF8String]); + address_readded = YES; + } + } + [completeExpectations[i] fulfill]; + }] + callOptions:nil]; + [calls addObject:call]; + } + + for (int i = 0; i < num_rpcs; ++i) { + GRPCStreamingProtoCall *call = calls[i]; + [call start]; + + RMTResponseParameters *parameters = [RMTResponseParameters message]; + parameters.size = 1000; + for (int i = 0; i < 5; i++) { + RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; + [request.responseParametersArray addObject:parameters]; + request.payload.body = [NSMutableData dataWithLength:100]; + [call writeMessage:request]; + } + [call finish]; + [NSThread sleepForTimeInterval:0.1f]; + } + [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; +} + +- (void)testNetworkFlapOnUnaryCallWithV1API { NSMutableArray *completeExpectations = [NSMutableArray array]; int num_rpcs = 100; __block BOOL address_removed = FALSE; @@ -220,6 +459,7 @@ extern const char *kCFStreamVarName; UTF8String]); address_removed = YES; } else if (error != nil && !address_readded) { + XCTAssertTrue(address_removed); system([[NSString stringWithFormat:@"sudo ifconfig lo0 alias %@", [[self class] hostAddress]] UTF8String]); @@ -234,4 +474,141 @@ extern const char *kCFStreamVarName; } } +- (void)testTimeoutOnFullDuplexCallWithV2API { + NSMutableArray *completeExpectations = [NSMutableArray array]; + NSMutableArray *calls = [NSMutableArray array]; + int num_rpcs = 100; + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + options.transportType = [[self class] transportType]; + options.PEMRootCertificates = [[self class] PEMRootCertificates]; + options.hostNameOverride = [[self class] hostNameOverride]; + options.timeout = 0.3; + for (int i = 0; i < num_rpcs; ++i) { + [completeExpectations + addObject:[self expectationWithDescription: + [NSString stringWithFormat:@"Received trailer for RPC %d", i]]]; + + GRPCStreamingProtoCall *call = [_service + fullDuplexCallWithResponseHandler: + [[MacTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + if (error != nil) { + XCTAssertEqual(error.code, GRPC_STATUS_DEADLINE_EXCEEDED); + } + [completeExpectations[i] fulfill]; + }] + callOptions:options]; + [calls addObject:call]; + } + + for (int i = 0; i < num_rpcs; ++i) { + GRPCStreamingProtoCall *call = calls[i]; + [call start]; + RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; + RMTResponseParameters *parameters = [RMTResponseParameters message]; + parameters.size = 1000; + // delay response by 100-200 milliseconds + parameters.intervalUs = [self getRandomNumberBetween:100 * 1000 max:200 * 1000]; + [request.responseParametersArray addObject:parameters]; + request.payload.body = [NSMutableData dataWithLength:100]; + + [call writeMessage:request]; + [call writeMessage:request]; + [call finish]; + } + [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; +} + +- (void)testServerStreamingCallSlowClientWithV2API { + NSMutableArray *completeExpectations = [NSMutableArray array]; + NSMutableArray *calls = [NSMutableArray array]; + int num_rpcs = 100; + dispatch_queue_t q = dispatch_queue_create(NULL, DISPATCH_QUEUE_CONCURRENT); + for (int i = 0; i < num_rpcs; ++i) { + [completeExpectations + addObject:[self expectationWithDescription: + [NSString stringWithFormat:@"Received trailer for RPC %d", i]]]; + + RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; + for (int i = 0; i < 5; i++) { + RMTResponseParameters *parameters = [RMTResponseParameters message]; + parameters.size = 10000; + [request.responseParametersArray addObject:parameters]; + [request.responseParametersArray addObject:parameters]; + [request.responseParametersArray addObject:parameters]; + [request.responseParametersArray addObject:parameters]; + [request.responseParametersArray addObject:parameters]; + } + + request.payload.body = [NSMutableData dataWithLength:100]; + + GRPCUnaryProtoCall *call = [_service + streamingOutputCallWithMessage:request + responseHandler:[[MacTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:^(id message) { + // inject a delay + [NSThread sleepForTimeInterval:0.5f]; + } + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + XCTAssertNil(error, @"Unexpected error: %@", error); + [completeExpectations[i] fulfill]; + }] + callOptions:nil]; + [calls addObject:call]; + } + + for (int i = 0; i < num_rpcs; ++i) { + dispatch_async(q, ^{ + GRPCStreamingProtoCall *call = calls[i]; + [call start]; + }); + } + [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; +} + +- (void)testCancelOnFullDuplexCallWithV2API { + NSMutableArray *completeExpectations = [NSMutableArray array]; + NSMutableArray *calls = [NSMutableArray array]; + int num_rpcs = 100; + dispatch_queue_t q = dispatch_queue_create(NULL, DISPATCH_QUEUE_CONCURRENT); + for (int i = 0; i < num_rpcs; ++i) { + [completeExpectations + addObject:[self expectationWithDescription: + [NSString stringWithFormat:@"Received trailer for RPC %d", i]]]; + + GRPCStreamingProtoCall *call = [_service + fullDuplexCallWithResponseHandler:[[MacTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:nil + closeCallback:^( + NSDictionary *trailingMetadata, + NSError *error) { + [completeExpectations[i] fulfill]; + }] + callOptions:nil]; + [calls addObject:call]; + } + + for (int i = 0; i < num_rpcs; ++i) { + GRPCStreamingProtoCall *call = calls[i]; + [call start]; + dispatch_async(q, ^{ + RMTResponseParameters *parameters = [RMTResponseParameters message]; + parameters.size = 1000; + for (int i = 0; i < 100; i++) { + RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; + [request.responseParametersArray addObject:parameters]; + [call writeMessage:request]; + } + [NSThread sleepForTimeInterval:0.01f]; + [call cancel]; + }); + } + [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; +} + @end diff --git a/src/objective-c/tests/UnitTests/APIv2Tests.m b/src/objective-c/tests/UnitTests/APIv2Tests.m index db293750ca3..066800613f6 100644 --- a/src/objective-c/tests/UnitTests/APIv2Tests.m +++ b/src/objective-c/tests/UnitTests/APIv2Tests.m @@ -21,6 +21,11 @@ #import #import +#import "../../GRPCClient/private/GRPCCallInternal.h" +#import "../../GRPCClient/private/GRPCChannel.h" +#import "../../GRPCClient/private/GRPCChannelPool.h" +#import "../../GRPCClient/private/GRPCWrappedCall.h" + #include #include @@ -48,12 +53,41 @@ static const int kSimpleDataLength = 100; static const NSTimeInterval kTestTimeout = 8; static const NSTimeInterval kInvertedTimeout = 2; -// Reveal the _class ivar for testing access +// Reveal the _class ivars for testing access @interface GRPCCall2 () { + @public + id _firstInterceptor; +} +@end + +@interface GRPCCall2Internal () { @public GRPCCall *_call; } +@end +@interface GRPCCall () { + @public + GRPCWrappedCall *_wrappedCall; +} +@end + +@interface GRPCWrappedCall () { + @public + GRPCPooledChannel *_pooledChannel; +} +@end + +@interface GRPCPooledChannel () { + @public + GRPCChannel *_wrappedChannel; +} +@end + +@interface GRPCChannel () { + @public + grpc_channel *_unmanagedChannel; +} @end // Convenience class to use blocks as callbacks @@ -148,6 +182,7 @@ static const NSTimeInterval kInvertedTimeout = 2; kOutputStreamingCallMethod = [[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"StreamingOutputCall"]; + kFullDuplexCallMethod = [[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"FullDuplexCall"]; } @@ -179,7 +214,7 @@ static const NSTimeInterval kInvertedTimeout = 2; closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { trailing_md = trailingMetadata; if (error) { - XCTAssertEqual(error.code, 16, + XCTAssertEqual(error.code, GRPCErrorCodeUnauthenticated, @"Finished with unexpected error: %@", error); XCTAssertEqualObjects(init_md, error.userInfo[kGRPCHeadersKey]); @@ -759,7 +794,7 @@ static const NSTimeInterval kInvertedTimeout = 2; } closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { XCTAssertNotNil(error, @"Expecting non-nil error"); - XCTAssertEqual(error.code, 2); + XCTAssertEqual(error.code, GRPCErrorCodeUnknown); [completion fulfill]; }] callOptions:options]; @@ -770,4 +805,293 @@ static const NSTimeInterval kInvertedTimeout = 2; [self waitForExpectationsWithTimeout:kTestTimeout handler:nil]; } +- (void)testAdditionalChannelArgs { + __weak XCTestExpectation *completion = [self expectationWithDescription:@"RPC completed."]; + + GRPCRequestOptions *requestOptions = + [[GRPCRequestOptions alloc] initWithHost:kHostAddress + path:kUnaryCallMethod.HTTPPath + safety:GRPCCallSafetyDefault]; + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // set max message length = 1 byte. + options.additionalChannelArgs = + [NSDictionary dictionaryWithObjectsAndKeys:@1, @GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, nil]; + options.transportType = GRPCTransportTypeInsecure; + + RMTSimpleRequest *request = [RMTSimpleRequest message]; + request.payload.body = [NSMutableData dataWithLength:options.responseSizeLimit]; + + GRPCCall2 *call = [[GRPCCall2 alloc] + initWithRequestOptions:requestOptions + responseHandler:[[ClientTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil + messageCallback:^(NSData *data) { + XCTFail(@"Received unexpected message"); + } + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + XCTAssertNotNil(error, @"Expecting non-nil error"); + NSLog(@"Got error: %@", error); + XCTAssertEqual(error.code, GRPCErrorCodeResourceExhausted, + @"Finished with unexpected error: %@", error); + + [completion fulfill]; + }] + callOptions:options]; + [call writeData:[request data]]; + [call start]; + [call finish]; + + [self waitForExpectationsWithTimeout:kTestTimeout handler:nil]; +} + +- (void)testChannelReuseIdentical { + __weak XCTestExpectation *completion1 = [self expectationWithDescription:@"RPC1 completed."]; + __weak XCTestExpectation *completion2 = [self expectationWithDescription:@"RPC2 completed."]; + NSArray *rpcDone = [NSArray arrayWithObjects:completion1, completion2, nil]; + __weak XCTestExpectation *metadata1 = + [self expectationWithDescription:@"Received initial metadata for RPC1."]; + __weak XCTestExpectation *metadata2 = + [self expectationWithDescription:@"Received initial metadata for RPC2."]; + NSArray *initialMetadataDone = [NSArray arrayWithObjects:metadata1, metadata2, nil]; + + RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; + RMTResponseParameters *parameters = [RMTResponseParameters message]; + parameters.size = kSimpleDataLength; + [request.responseParametersArray addObject:parameters]; + request.payload.body = [NSMutableData dataWithLength:kSimpleDataLength]; + + GRPCRequestOptions *requestOptions = + [[GRPCRequestOptions alloc] initWithHost:kHostAddress + path:kFullDuplexCallMethod.HTTPPath + safety:GRPCCallSafetyDefault]; + GRPCMutableCallOptions *callOptions = [[GRPCMutableCallOptions alloc] init]; + callOptions.transportType = GRPCTransportTypeInsecure; + GRPCCall2 *call1 = [[GRPCCall2 alloc] + initWithRequestOptions:requestOptions + responseHandler:[[ClientTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { + [metadata1 fulfill]; + } + messageCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + [completion1 fulfill]; + }] + callOptions:callOptions]; + GRPCCall2 *call2 = [[GRPCCall2 alloc] + initWithRequestOptions:requestOptions + responseHandler:[[ClientTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { + [metadata2 fulfill]; + } + messageCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + [completion2 fulfill]; + }] + callOptions:callOptions]; + [call1 start]; + [call2 start]; + [call1 writeData:[request data]]; + [call2 writeData:[request data]]; + [self waitForExpectations:initialMetadataDone timeout:kTestTimeout]; + GRPCCall2Internal *internalCall1 = call1->_firstInterceptor; + GRPCCall2Internal *internalCall2 = call2->_firstInterceptor; + XCTAssertEqual( + internalCall1->_call->_wrappedCall->_pooledChannel->_wrappedChannel->_unmanagedChannel, + internalCall2->_call->_wrappedCall->_pooledChannel->_wrappedChannel->_unmanagedChannel); + [call1 finish]; + [call2 finish]; + [self waitForExpectations:rpcDone timeout:kTestTimeout]; +} + +- (void)testChannelReuseDifferentCallSafety { + __weak XCTestExpectation *completion1 = [self expectationWithDescription:@"RPC1 completed."]; + __weak XCTestExpectation *completion2 = [self expectationWithDescription:@"RPC2 completed."]; + NSArray *rpcDone = [NSArray arrayWithObjects:completion1, completion2, nil]; + __weak XCTestExpectation *metadata1 = + [self expectationWithDescription:@"Received initial metadata for RPC1."]; + __weak XCTestExpectation *metadata2 = + [self expectationWithDescription:@"Received initial metadata for RPC2."]; + NSArray *initialMetadataDone = [NSArray arrayWithObjects:metadata1, metadata2, nil]; + + RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; + RMTResponseParameters *parameters = [RMTResponseParameters message]; + parameters.size = kSimpleDataLength; + [request.responseParametersArray addObject:parameters]; + request.payload.body = [NSMutableData dataWithLength:kSimpleDataLength]; + + GRPCRequestOptions *requestOptions1 = + [[GRPCRequestOptions alloc] initWithHost:kHostAddress + path:kFullDuplexCallMethod.HTTPPath + safety:GRPCCallSafetyDefault]; + GRPCRequestOptions *requestOptions2 = + [[GRPCRequestOptions alloc] initWithHost:kHostAddress + path:kFullDuplexCallMethod.HTTPPath + safety:GRPCCallSafetyIdempotentRequest]; + + GRPCMutableCallOptions *callOptions = [[GRPCMutableCallOptions alloc] init]; + callOptions.transportType = GRPCTransportTypeInsecure; + GRPCCall2 *call1 = [[GRPCCall2 alloc] + initWithRequestOptions:requestOptions1 + responseHandler:[[ClientTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { + [metadata1 fulfill]; + } + messageCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + [completion1 fulfill]; + }] + callOptions:callOptions]; + GRPCCall2 *call2 = [[GRPCCall2 alloc] + initWithRequestOptions:requestOptions2 + responseHandler:[[ClientTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { + [metadata2 fulfill]; + } + messageCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + [completion2 fulfill]; + }] + callOptions:callOptions]; + [call1 start]; + [call2 start]; + [call1 writeData:[request data]]; + [call2 writeData:[request data]]; + [self waitForExpectations:initialMetadataDone timeout:kTestTimeout]; + GRPCCall2Internal *internalCall1 = call1->_firstInterceptor; + GRPCCall2Internal *internalCall2 = call2->_firstInterceptor; + XCTAssertEqual( + internalCall1->_call->_wrappedCall->_pooledChannel->_wrappedChannel->_unmanagedChannel, + internalCall2->_call->_wrappedCall->_pooledChannel->_wrappedChannel->_unmanagedChannel); + [call1 finish]; + [call2 finish]; + [self waitForExpectations:rpcDone timeout:kTestTimeout]; +} + +- (void)testChannelReuseDifferentHost { + __weak XCTestExpectation *completion1 = [self expectationWithDescription:@"RPC1 completed."]; + __weak XCTestExpectation *completion2 = [self expectationWithDescription:@"RPC2 completed."]; + NSArray *rpcDone = [NSArray arrayWithObjects:completion1, completion2, nil]; + __weak XCTestExpectation *metadata1 = + [self expectationWithDescription:@"Received initial metadata for RPC1."]; + __weak XCTestExpectation *metadata2 = + [self expectationWithDescription:@"Received initial metadata for RPC2."]; + NSArray *initialMetadataDone = [NSArray arrayWithObjects:metadata1, metadata2, nil]; + + RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; + RMTResponseParameters *parameters = [RMTResponseParameters message]; + parameters.size = kSimpleDataLength; + [request.responseParametersArray addObject:parameters]; + request.payload.body = [NSMutableData dataWithLength:kSimpleDataLength]; + + GRPCRequestOptions *requestOptions1 = + [[GRPCRequestOptions alloc] initWithHost:@"[::1]:5050" + path:kFullDuplexCallMethod.HTTPPath + safety:GRPCCallSafetyDefault]; + GRPCRequestOptions *requestOptions2 = + [[GRPCRequestOptions alloc] initWithHost:@"127.0.0.1:5050" + path:kFullDuplexCallMethod.HTTPPath + safety:GRPCCallSafetyDefault]; + + GRPCMutableCallOptions *callOptions = [[GRPCMutableCallOptions alloc] init]; + callOptions.transportType = GRPCTransportTypeInsecure; + + GRPCCall2 *call1 = [[GRPCCall2 alloc] + initWithRequestOptions:requestOptions1 + responseHandler:[[ClientTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { + [metadata1 fulfill]; + } + messageCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + [completion1 fulfill]; + }] + callOptions:callOptions]; + GRPCCall2 *call2 = [[GRPCCall2 alloc] + initWithRequestOptions:requestOptions2 + responseHandler:[[ClientTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { + [metadata2 fulfill]; + } + messageCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + [completion2 fulfill]; + }] + callOptions:callOptions]; + [call1 start]; + [call2 start]; + [call1 writeData:[request data]]; + [call2 writeData:[request data]]; + [self waitForExpectations:initialMetadataDone timeout:kTestTimeout]; + GRPCCall2Internal *internalCall1 = call1->_firstInterceptor; + GRPCCall2Internal *internalCall2 = call2->_firstInterceptor; + XCTAssertNotEqual( + internalCall1->_call->_wrappedCall->_pooledChannel->_wrappedChannel->_unmanagedChannel, + internalCall2->_call->_wrappedCall->_pooledChannel->_wrappedChannel->_unmanagedChannel); + [call1 finish]; + [call2 finish]; + [self waitForExpectations:rpcDone timeout:kTestTimeout]; +} + +- (void)testChannelReuseDifferentChannelArgs { + __weak XCTestExpectation *completion1 = [self expectationWithDescription:@"RPC1 completed."]; + __weak XCTestExpectation *completion2 = [self expectationWithDescription:@"RPC2 completed."]; + NSArray *rpcDone = [NSArray arrayWithObjects:completion1, completion2, nil]; + __weak XCTestExpectation *metadata1 = + [self expectationWithDescription:@"Received initial metadata for RPC1."]; + __weak XCTestExpectation *metadata2 = + [self expectationWithDescription:@"Received initial metadata for RPC2."]; + NSArray *initialMetadataDone = [NSArray arrayWithObjects:metadata1, metadata2, nil]; + + RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; + RMTResponseParameters *parameters = [RMTResponseParameters message]; + parameters.size = kSimpleDataLength; + [request.responseParametersArray addObject:parameters]; + request.payload.body = [NSMutableData dataWithLength:kSimpleDataLength]; + + GRPCRequestOptions *requestOptions = + [[GRPCRequestOptions alloc] initWithHost:kHostAddress + path:kFullDuplexCallMethod.HTTPPath + safety:GRPCCallSafetyDefault]; + GRPCMutableCallOptions *callOptions1 = [[GRPCMutableCallOptions alloc] init]; + callOptions1.transportType = GRPCTransportTypeInsecure; + GRPCMutableCallOptions *callOptions2 = [[GRPCMutableCallOptions alloc] init]; + callOptions2.transportType = GRPCTransportTypeInsecure; + callOptions2.channelID = 2; + + GRPCCall2 *call1 = [[GRPCCall2 alloc] + initWithRequestOptions:requestOptions + responseHandler:[[ClientTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { + [metadata1 fulfill]; + } + messageCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + [completion1 fulfill]; + }] + callOptions:callOptions1]; + GRPCCall2 *call2 = [[GRPCCall2 alloc] + initWithRequestOptions:requestOptions + responseHandler:[[ClientTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { + [metadata2 fulfill]; + } + messageCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + [completion2 fulfill]; + }] + callOptions:callOptions2]; + [call1 start]; + [call2 start]; + [call1 writeData:[request data]]; + [call2 writeData:[request data]]; + [self waitForExpectations:initialMetadataDone timeout:kTestTimeout]; + GRPCCall2Internal *internalCall1 = call1->_firstInterceptor; + GRPCCall2Internal *internalCall2 = call2->_firstInterceptor; + XCTAssertNotEqual( + internalCall1->_call->_wrappedCall->_pooledChannel->_wrappedChannel->_unmanagedChannel, + internalCall2->_call->_wrappedCall->_pooledChannel->_wrappedChannel->_unmanagedChannel); + [call1 finish]; + [call2 finish]; + [self waitForExpectations:rpcDone timeout:kTestTimeout]; +} + @end diff --git a/test/cpp/interop/interop_server.cc b/test/cpp/interop/interop_server.cc index 6570bbf9696..cf55efa5409 100644 --- a/test/cpp/interop/interop_server.cc +++ b/test/cpp/interop/interop_server.cc @@ -118,7 +118,8 @@ bool CheckExpectedCompression(const ServerContext& context, "Expected compression but got uncompressed request from client."); return false; } - if (!(inspector.GetMessageFlags() & GRPC_WRITE_INTERNAL_COMPRESS)) { + if (!(inspector.GetMessageFlags() & GRPC_WRITE_INTERNAL_COMPRESS) && + received_compression != GRPC_COMPRESS_STREAM_GZIP) { gpr_log(GPR_ERROR, "Failure: Requested compression in a compressable request, but " "compression bit in message flags not set."); From eb48acd9272291cdb357289ee98ff316fc5c9992 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Fri, 7 Jun 2019 11:33:26 -0700 Subject: [PATCH 0472/1555] Add copyright header --- .../test/python_stretch_3.8_x64/get_cpython.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/dockerfile/test/python_stretch_3.8_x64/get_cpython.sh b/tools/dockerfile/test/python_stretch_3.8_x64/get_cpython.sh index c01c6ebb0d2..e051e974b38 100644 --- a/tools/dockerfile/test/python_stretch_3.8_x64/get_cpython.sh +++ b/tools/dockerfile/test/python_stretch_3.8_x64/get_cpython.sh @@ -1,5 +1,19 @@ #!/bin/bash +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + VERSION_REGEX="v3.8.*" REPO="python/cpython" From 21bf2a2a839ed87883b8d1400141c1b911ee02d5 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 7 Jun 2019 11:56:37 -0700 Subject: [PATCH 0473/1555] Better fix --- src/csharp/Grpc.Tools/ProtoCompile.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/csharp/Grpc.Tools/ProtoCompile.cs b/src/csharp/Grpc.Tools/ProtoCompile.cs index b6fd94209d2..36a0ea36cee 100644 --- a/src/csharp/Grpc.Tools/ProtoCompile.cs +++ b/src/csharp/Grpc.Tools/ProtoCompile.cs @@ -136,7 +136,7 @@ namespace Grpc.Tools new ErrorListFilter { Pattern = new Regex( - pattern: "(?'FILENAME'[^\\(]+)\\((?'LINE'\\d+)\\) ?: ?warning in column=(?'COLUMN'\\d+) ?: ?(?'TEXT'.*)", + pattern: "^(?'FILENAME'.+?)\\((?'LINE'\\d+)\\) ?: ?warning in column=(?'COLUMN'\\d+) ?: ?(?'TEXT'.*)", options: RegexOptions.Compiled | RegexOptions.IgnoreCase, matchTimeout: s_regexTimeout), LogAction = (log, match) => @@ -162,7 +162,7 @@ namespace Grpc.Tools new ErrorListFilter { Pattern = new Regex( - pattern: "(?'FILENAME'[^\\(]+)\\((?'LINE'\\d+)\\) ?: ?error in column=(?'COLUMN'\\d+) ?: ?(?'TEXT'.*)", + pattern: "^(?'FILENAME'.+?)\\((?'LINE'\\d+)\\) ?: ?error in column=(?'COLUMN'\\d+) ?: ?(?'TEXT'.*)", options: RegexOptions.Compiled | RegexOptions.IgnoreCase, matchTimeout: s_regexTimeout), LogAction = (log, match) => @@ -188,7 +188,7 @@ namespace Grpc.Tools new ErrorListFilter { Pattern = new Regex( - pattern: "(?'FILENAME'[^:]+): ?warning: ?(?'TEXT'.*)", + pattern: "^(?'FILENAME'.+?): ?warning: ?(?'TEXT'.*)", options: RegexOptions.Compiled | RegexOptions.IgnoreCase, matchTimeout: s_regexTimeout), LogAction = (log, match) => @@ -211,7 +211,7 @@ namespace Grpc.Tools new ErrorListFilter { Pattern = new Regex( - pattern: "(?'FILENAME'[^:]+): ?(?'TEXT'.*)", + pattern: "^(?'FILENAME'.+?): ?(?'TEXT'.*)", options: RegexOptions.Compiled | RegexOptions.IgnoreCase, matchTimeout: s_regexTimeout), LogAction = (log, match) => From 385beb95ce5c77126b9a4c85a84c6a86a6222cf3 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Fri, 7 Jun 2019 13:12:51 -0700 Subject: [PATCH 0474/1555] Yapf --- tools/run_tests/run_tests.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 108cf29c0a8..43d8c64da0b 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1349,9 +1349,10 @@ argp.add_argument( choices=[ 'default', 'gcc4.4', 'gcc4.6', 'gcc4.8', 'gcc4.9', 'gcc5.3', 'gcc7.2', 'gcc_musl', 'clang3.4', 'clang3.5', 'clang3.6', 'clang3.7', 'clang7.0', - 'python2.7', 'python3.4', 'python3.5', 'python3.6', 'python3.7', 'python3.8', 'pypy', - 'pypy3', 'python_alpine', 'all_the_cpythons', 'electron1.3', - 'electron1.6', 'coreclr', 'cmake', 'cmake_vs2015', 'cmake_vs2017' + 'python2.7', 'python3.4', 'python3.5', 'python3.6', 'python3.7', + 'python3.8', 'pypy', 'pypy3', 'python_alpine', 'all_the_cpythons', + 'electron1.3', 'electron1.6', 'coreclr', 'cmake', 'cmake_vs2015', + 'cmake_vs2017' ], default='default', help= From 9601b46ffa10b68ea54453ac5cdf62bcf19f834f Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 7 Jun 2019 15:10:49 -0700 Subject: [PATCH 0475/1555] Resolving testResponsesOver4MBAreAcceptedIfOptedIn delayed callback --- src/objective-c/tests/InteropTests/InteropTests.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 7d4aee0bc90..4bdacbe4fa8 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -18,6 +18,8 @@ #import "InteropTests.h" +#import + #include #ifdef GRPC_COMPILE_WITH_CRONET @@ -701,21 +703,21 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager XCTAssertNotNil([[self class] host]); __weak XCTestExpectation *expectation = [self expectationWithDescription:@"HigherResponseSizeLimit"]; + __block NSError *callError = nil; RMTSimpleRequest *request = [RMTSimpleRequest message]; const size_t kPayloadSize = 5 * 1024 * 1024; // 5MB request.responseSize = kPayloadSize; [GRPCCall setResponseSizeLimit:6 * 1024 * 1024 forHost:[[self class] host]]; - [_service unaryCallWithRequest:request handler:^(RMTSimpleResponse *response, NSError *error) { - XCTAssertNil(error, @"Finished with unexpected error: %@", error); - XCTAssertEqual(response.payload.body.length, kPayloadSize); + callError = error; [expectation fulfill]; }]; [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; + XCTAssertNil(callError, @"Finished with unexpected error: %@", callError); } - (void)testClientStreamingRPC { From 45a0e5bd4f9c673429b6a7f7a3207a2b0cd9564d Mon Sep 17 00:00:00 2001 From: Mehrdad Afshari Date: Fri, 7 Jun 2019 11:09:12 -0700 Subject: [PATCH 0476/1555] Clean up Channel.__del__ logic --- src/python/grpcio/grpc/_channel.py | 31 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/python/grpcio/grpc/_channel.py b/src/python/grpcio/grpc/_channel.py index f566fd698ad..4b761bfe5f8 100644 --- a/src/python/grpcio/grpc/_channel.py +++ b/src/python/grpcio/grpc/_channel.py @@ -966,11 +966,6 @@ def _poll_connectivity(state, channel, initial_try_to_connect): _spawn_delivery(state, callbacks) -def _moot(state): - with state.lock: - del state.callbacks_and_connectivities[:] - - def _subscribe(state, callback, try_to_connect): with state.lock: if not state.callbacks_and_connectivities and not state.polling: @@ -1000,11 +995,6 @@ def _unsubscribe(state, callback): break -def _unsubscribe_all(state): - with state.lock: - del state.callbacks_and_connectivities[:] - - def _augment_options(base_options, compression): compression_option = _compression.create_channel_option(compression) return tuple(base_options) + compression_option + (( @@ -1071,16 +1061,21 @@ class Channel(grpc.Channel): self._channel, _channel_managed_call_management(self._call_state), _common.encode(method), request_serializer, response_deserializer) + def _unsubscribe_all(self): + state = self._connectivity_state + if state: + with state.lock: + del state.callbacks_and_connectivities[:] + def _close(self): - _unsubscribe_all(self._connectivity_state) + self._unsubscribe_all() self._channel.close(cygrpc.StatusCode.cancelled, 'Channel closed!') cygrpc.fork_unregister_channel(self) - _moot(self._connectivity_state) def _close_on_fork(self): + self._unsubscribe_all() self._channel.close_on_fork(cygrpc.StatusCode.cancelled, 'Channel closed due to fork') - _moot(self._connectivity_state) def __enter__(self): return self @@ -1102,7 +1097,9 @@ class Channel(grpc.Channel): # for as long as they are in use and to close them after using them, # then deletion of this grpc._channel.Channel instance can be made to # effect closure of the underlying cygrpc.Channel instance. - # This prevent the failed-at-initializing object removal from failing. - # Though the __init__ failed, the removal will still trigger __del__. - if _moot is not None and hasattr(self, '_connectivity_state'): - _moot(self._connectivity_state) + try: + self._unsubscribe_all() + except: + # Exceptions in __del__ are ignored by Python anyway, but they can + # keep spamming logs. Just silence them. + pass From 6ed651356d6d77d61d9d933444b7784d85e399f4 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 7 Jun 2019 16:28:31 -0700 Subject: [PATCH 0477/1555] Fix typo --- src/cpp/client/channel_cc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpp/client/channel_cc.cc b/src/cpp/client/channel_cc.cc index f0aa8e4017a..de0f4e1787b 100644 --- a/src/cpp/client/channel_cc.cc +++ b/src/cpp/client/channel_cc.cc @@ -144,7 +144,7 @@ void ChannelResetConnectionBackoff(Channel* channel) { // ClientRpcInfo should be set before call because set_call also checks // whether the call has been cancelled, and if the call was cancelled, we - // should notify the interceptors too/ + // should notify the interceptors too. auto* info = context->set_client_rpc_info(method.name(), method.method_type(), this, interceptor_creators_, interceptor_pos); From 5bd4c0c7d069611d485bcbcff50c713d751e95c5 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Fri, 7 Jun 2019 17:39:08 -0700 Subject: [PATCH 0478/1555] Add operator== for ServerAddress and InlinedVector --- .../filters/client_channel/server_address.cc | 10 ++++------ .../filters/client_channel/server_address.h | 4 +--- src/core/lib/gprpp/inlined_vector.h | 8 ++++++++ test/core/gprpp/inlined_vector_test.cc | 18 ++++++++++++++++++ 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/core/ext/filters/client_channel/server_address.cc b/src/core/ext/filters/client_channel/server_address.cc index c2941afbcfd..31c0edaca17 100644 --- a/src/core/ext/filters/client_channel/server_address.cc +++ b/src/core/ext/filters/client_channel/server_address.cc @@ -39,12 +39,10 @@ ServerAddress::ServerAddress(const void* address, size_t address_len, address_.len = static_cast(address_len); } -int ServerAddress::Cmp(const ServerAddress& other) const { - if (address_.len > other.address_.len) return 1; - if (address_.len < other.address_.len) return -1; - int retval = memcmp(address_.addr, other.address_.addr, address_.len); - if (retval != 0) return retval; - return grpc_channel_args_compare(args_, other.args_); +bool ServerAddress::operator==(const grpc_core::ServerAddress& other) const { + return address_.len == other.address_.len && + memcmp(address_.addr, other.address_.addr, address_.len) == 0 && + grpc_channel_args_compare(args_, other.args_) == 0; } bool ServerAddress::IsBalancer() const { diff --git a/src/core/ext/filters/client_channel/server_address.h b/src/core/ext/filters/client_channel/server_address.h index 040cd2ee317..1b68a59ed85 100644 --- a/src/core/ext/filters/client_channel/server_address.h +++ b/src/core/ext/filters/client_channel/server_address.h @@ -73,9 +73,7 @@ class ServerAddress { return *this; } - bool operator==(const ServerAddress& other) const { return Cmp(other) == 0; } - - int Cmp(const ServerAddress& other) const; + bool operator==(const ServerAddress& other) const; const grpc_resolved_address& address() const { return address_; } const grpc_channel_args* args() const { return args_; } diff --git a/src/core/lib/gprpp/inlined_vector.h b/src/core/lib/gprpp/inlined_vector.h index 66dc751a567..ffc37387ec3 100644 --- a/src/core/lib/gprpp/inlined_vector.h +++ b/src/core/lib/gprpp/inlined_vector.h @@ -97,6 +97,14 @@ class InlinedVector { return data()[offset]; } + bool operator==(const InlinedVector& other) const { + if (size_ != other.size_) return false; + for (size_t i = 0; i < size_; ++i) { + if (data()[i] != other.data()[i]) return false; + } + return true; + } + void reserve(size_t capacity) { if (capacity > capacity_) { T* new_dynamic = static_cast(gpr_malloc(sizeof(T) * capacity)); diff --git a/test/core/gprpp/inlined_vector_test.cc b/test/core/gprpp/inlined_vector_test.cc index f943128f53c..4b7e46761c0 100644 --- a/test/core/gprpp/inlined_vector_test.cc +++ b/test/core/gprpp/inlined_vector_test.cc @@ -109,6 +109,24 @@ TEST(InlinedVectorTest, ConstIndexOperator) { const_func(v); } +TEST(InlinedVectorTest, EqualOperator) { + constexpr int kNumElements = 10; + // Both v1 and v2 are empty. + InlinedVector v1; + InlinedVector v2; + EXPECT_TRUE(v1 == v2); + // Both v1 and v2 contains the same data. + FillVector(&v1, kNumElements); + FillVector(&v2, kNumElements); + EXPECT_TRUE(v1 == v2); + // The sizes of v1 and v2 are different. + v1.push_back(0); + EXPECT_FALSE(v1 == v2); + // The contents of v1 and v2 are different although their sizes are the same. + v2.push_back(1); + EXPECT_FALSE(v1 == v2); +} + // the following constants and typedefs are used for copy/move // construction/assignment const size_t kInlinedLength = 8; From cbf70f2db208f97589aeb7d35707c9db33a056e7 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 7 Jun 2019 17:40:56 -0700 Subject: [PATCH 0479/1555] Remove unneeded import --- src/objective-c/tests/InteropTests/InteropTests.m | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 4bdacbe4fa8..91e133a1300 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -18,8 +18,6 @@ #import "InteropTests.h" -#import - #include #ifdef GRPC_COMPILE_WITH_CRONET From 0d6cffd6c4bef4dc03108c93b29c03c89a99bfed Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Fri, 7 Jun 2019 10:40:04 -0400 Subject: [PATCH 0480/1555] Introduce grpc_slice_from_moved_string. Suggested by @markdroth to avoid extra allocation and copy when it's not needed. --- .../transport/chttp2/transport/frame_data.cc | 10 ++-- .../chttp2/transport/frame_rst_stream.cc | 5 +- src/core/lib/http/httpcli.cc | 6 +- src/core/lib/slice/slice.cc | 55 ++++++++++++++++--- src/core/lib/slice/slice_internal.h | 3 + src/core/lib/surface/validate_metadata.cc | 5 +- test/core/slice/slice_test.cc | 30 ++++++++++ 7 files changed, 95 insertions(+), 19 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/frame_data.cc b/src/core/ext/transport/chttp2/transport/frame_data.cc index 3734c0150b7..c50d7e48d41 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.cc +++ b/src/core/ext/transport/chttp2/transport/frame_data.cc @@ -109,7 +109,6 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( end = GRPC_SLICE_END_PTR(*slice); cur = beg; uint32_t message_flags; - char* msg; if (cur == end) { grpc_slice_buffer_remove_first(slices); @@ -132,15 +131,16 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( p->is_frame_compressed = true; /* GPR_TRUE */ break; default: + char* msg; gpr_asprintf(&msg, "Bad GRPC frame type 0x%02x", p->frame_type); p->error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg); p->error = grpc_error_set_int(p->error, GRPC_ERROR_INT_STREAM_ID, static_cast(s->id)); gpr_free(msg); - msg = grpc_dump_slice(*slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); - p->error = grpc_error_set_str(p->error, GRPC_ERROR_STR_RAW_BYTES, - grpc_slice_from_copied_string(msg)); - gpr_free(msg); + p->error = grpc_error_set_str( + p->error, GRPC_ERROR_STR_RAW_BYTES, + grpc_slice_from_moved_string(grpc_core::UniquePtr( + grpc_dump_slice(*slice, GPR_DUMP_HEX | GPR_DUMP_ASCII)))); p->error = grpc_error_set_int(p->error, GRPC_ERROR_INT_OFFSET, cur - beg); p->state = GRPC_CHTTP2_DATA_ERROR; diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc b/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc index ccde36cbc48..cda09c3dea1 100644 --- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc @@ -26,6 +26,7 @@ #include #include "src/core/ext/transport/chttp2/transport/frame.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/transport/http2_errors.h" grpc_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code, @@ -102,9 +103,9 @@ grpc_error* grpc_chttp2_rst_stream_parser_parse(void* parser, error = grpc_error_set_int( grpc_error_set_str(GRPC_ERROR_CREATE_FROM_STATIC_STRING("RST_STREAM"), GRPC_ERROR_STR_GRPC_MESSAGE, - grpc_slice_from_copied_string(message)), + grpc_slice_from_moved_string( + grpc_core::UniquePtr(message))), GRPC_ERROR_INT_HTTP2_ERROR, static_cast(reason)); - gpr_free(message); } grpc_chttp2_mark_stream_closed(t, s, true, true, error); } diff --git a/src/core/lib/http/httpcli.cc b/src/core/lib/http/httpcli.cc index 8a8da8b1604..93bb1432b16 100644 --- a/src/core/lib/http/httpcli.cc +++ b/src/core/lib/http/httpcli.cc @@ -28,6 +28,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/http/format_request.h" #include "src/core/lib/http/parser.h" #include "src/core/lib/iomgr/endpoint.h" @@ -112,12 +113,11 @@ static void append_error(internal_request* req, grpc_error* error) { GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed HTTP/1 client request"); } grpc_resolved_address* addr = &req->addresses->addrs[req->next_address - 1]; - char* addr_text = grpc_sockaddr_to_uri(addr); + grpc_core::UniquePtr addr_text(grpc_sockaddr_to_uri(addr)); req->overall_error = grpc_error_add_child( req->overall_error, grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS, - grpc_slice_from_copied_string(addr_text))); - gpr_free(addr_text); + grpc_slice_from_moved_string(std::move(addr_text)))); } static void do_read(internal_request* req) { diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc index 566ad94d705..0f8ea6ae018 100644 --- a/src/core/lib/slice/slice.cc +++ b/src/core/lib/slice/slice.cc @@ -102,18 +102,19 @@ class NewSliceRefcount { } NewSliceRefcount(void (*destroy)(void*), void* user_data) - : rc_(grpc_slice_refcount::Type::REGULAR, &refs_, Destroy, this, &rc_), + : base_(grpc_slice_refcount::Type::REGULAR, &refs_, Destroy, this, + &base_), user_destroy_(destroy), user_data_(user_data) {} GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE - grpc_slice_refcount* base_refcount() { return &rc_; } + grpc_slice_refcount* base_refcount() { return &base_; } private: ~NewSliceRefcount() { user_destroy_(user_data_); } - grpc_slice_refcount rc_; + grpc_slice_refcount base_; RefCount refs_; void (*user_destroy_)(void*); void* user_data_; @@ -141,7 +142,6 @@ grpc_slice grpc_slice_new(void* p, size_t len, void (*destroy)(void*)) { namespace grpc_core { /* grpc_slice_new_with_len support structures - we create a refcount object extended with the user provided data pointer & destroy function */ - class NewWithLenSliceRefcount { public: static void Destroy(void* arg) { @@ -150,25 +150,48 @@ class NewWithLenSliceRefcount { NewWithLenSliceRefcount(void (*destroy)(void*, size_t), void* user_data, size_t user_length) - : rc_(grpc_slice_refcount::Type::REGULAR, &refs_, Destroy, this, &rc_), + : base_(grpc_slice_refcount::Type::REGULAR, &refs_, Destroy, this, + &base_), user_data_(user_data), user_length_(user_length), user_destroy_(destroy) {} GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE - grpc_slice_refcount* base_refcount() { return &rc_; } + grpc_slice_refcount* base_refcount() { return &base_; } private: ~NewWithLenSliceRefcount() { user_destroy_(user_data_, user_length_); } - grpc_slice_refcount rc_; + grpc_slice_refcount base_; RefCount refs_; void* user_data_; size_t user_length_; void (*user_destroy_)(void*, size_t); }; +/** grpc_slice_from_moved_(string|buffer) ref count .*/ +class MovedStringSliceRefCount { + public: + MovedStringSliceRefCount(grpc_core::UniquePtr&& str) + : base_(grpc_slice_refcount::Type::REGULAR, &refs_, Destroy, this, + &base_), + str_(std::move(str)) {} + + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE + + grpc_slice_refcount* base_refcount() { return &base_; } + + private: + static void Destroy(void* arg) { + Delete(static_cast(arg)); + } + + grpc_slice_refcount base_; + grpc_core::RefCount refs_; + grpc_core::UniquePtr str_; +}; + } // namespace grpc_core grpc_slice grpc_slice_new_with_len(void* p, size_t len, @@ -193,6 +216,24 @@ grpc_slice grpc_slice_from_copied_string(const char* source) { return grpc_slice_from_copied_buffer(source, strlen(source)); } +grpc_slice grpc_slice_from_moved_string(grpc_core::UniquePtr p) { + const size_t len = strlen(p.get()); + uint8_t* ptr = reinterpret_cast(p.get()); + grpc_slice slice; + if (len <= sizeof(slice.data.inlined.bytes)) { + slice.refcount = nullptr; + slice.data.inlined.length = len; + memcpy(GRPC_SLICE_START_PTR(slice), ptr, len); + } else { + slice.refcount = + grpc_core::New(std::move(p)) + ->base_refcount(); + slice.data.refcounted.bytes = ptr; + slice.data.refcounted.length = len; + } + return slice; +} + namespace { class MallocRefCount { diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index 23a2f6b81bc..457b76700ed 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -28,6 +28,7 @@ #include #include "src/core/lib/gpr/murmur_hash.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/transport/static_metadata.h" @@ -302,6 +303,8 @@ inline uint32_t grpc_slice_hash_internal(const grpc_slice& s) { : grpc_slice_hash_refcounted(s); } +grpc_slice grpc_slice_from_moved_string(grpc_core::UniquePtr p); + // Returns the memory used by this slice, not counting the slice structure // itself. This means that inlined and slices from static strings will return // 0. All other slices will return the size of the allocated chars. diff --git a/src/core/lib/surface/validate_metadata.cc b/src/core/lib/surface/validate_metadata.cc index a92ab823a38..46554596235 100644 --- a/src/core/lib/surface/validate_metadata.cc +++ b/src/core/lib/surface/validate_metadata.cc @@ -24,6 +24,7 @@ #include #include +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_string_helpers.h" @@ -44,8 +45,8 @@ static grpc_error* conforms_to(const grpc_slice& slice, grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(err_desc), GRPC_ERROR_INT_OFFSET, p - GRPC_SLICE_START_PTR(slice)), - GRPC_ERROR_STR_RAW_BYTES, grpc_slice_from_copied_string(dump)); - gpr_free(dump); + GRPC_ERROR_STR_RAW_BYTES, + grpc_slice_from_moved_string(grpc_core::UniquePtr(dump))); return error; } } diff --git a/test/core/slice/slice_test.cc b/test/core/slice/slice_test.cc index 6ed02366fe2..3c9c0572a43 100644 --- a/test/core/slice/slice_test.cc +++ b/test/core/slice/slice_test.cc @@ -27,6 +27,7 @@ #include #include +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/static_metadata.h" #include "test/core/util/test_config.h" @@ -285,6 +286,34 @@ static void test_static_slice_copy_interning(void) { grpc_shutdown(); } +static void test_moved_string_slice(void) { + LOG_TEST_NAME("test_moved_string_slice"); + + grpc_init(); + + // Small string should be inlined. + constexpr char kSmallStr[] = "hello12345"; + char* small_ptr = strdup(kSmallStr); + grpc_slice small = + grpc_slice_from_moved_string(grpc_core::UniquePtr(small_ptr)); + GPR_ASSERT(GRPC_SLICE_LENGTH(small) == strlen(kSmallStr)); + GPR_ASSERT(GRPC_SLICE_START_PTR(small) != + reinterpret_cast(small_ptr)); + grpc_slice_unref(small); + + // Large string should be move the reference. + constexpr char kSLargeStr[] = "hello123456789123456789123456789"; + char* large_ptr = strdup(kSLargeStr); + grpc_slice large = + grpc_slice_from_moved_string(grpc_core::UniquePtr(large_ptr)); + GPR_ASSERT(GRPC_SLICE_LENGTH(large) == strlen(kSLargeStr)); + GPR_ASSERT(GRPC_SLICE_START_PTR(large) == + reinterpret_cast(large_ptr)); + grpc_slice_unref(large); + + grpc_shutdown(); +} + int main(int argc, char** argv) { unsigned length; grpc::testing::TestEnvironment env(argc, argv); @@ -302,6 +331,7 @@ int main(int argc, char** argv) { test_slice_interning(); test_static_slice_interning(); test_static_slice_copy_interning(); + test_moved_string_slice(); grpc_shutdown(); return 0; } From a5090c5875af64b2ebe1883604c31ee1d4040463 Mon Sep 17 00:00:00 2001 From: Jonas Vautherin Date: Sat, 8 Jun 2019 17:50:55 +0200 Subject: [PATCH 0481/1555] Add support for CMAKE_SYSTEM_NAME=iOS An iOS toolchain is now part of CMake (3.14+), and therefore it makes sense to consider it. Note: it used to report "Darwin" and now it reports "iOS". Reference: https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-ios-tvos-or-watchos --- CMakeLists.txt | 6 ++++-- templates/CMakeLists.txt.template | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e9d2168b8de..e78df7d8d40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,8 @@ if(UNIX) set(_gRPC_PLATFORM_LINUX ON) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(_gRPC_PLATFORM_MAC ON) + elseif(${CMAKE_SYSTEM_NAME} MATCHES "iOS") + set(_gRPC_PLATFORM_IOS ON) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android") set(_gRPC_PLATFORM_ANDROID ON) else() @@ -124,7 +126,7 @@ if(gRPC_BACKWARDS_COMPATIBILITY_MODE) endif() endif() -if (_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC) +if (_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_IOS) # C core has C++ source code, but should not depend on libstc++ (for better portability). # We need to use a few tricks to convince cmake to do that. # https://stackoverflow.com/questions/15058403/how-to-stop-cmake-from-linking-against-libstdc @@ -149,7 +151,7 @@ if(NOT MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") endif() -if(_gRPC_PLATFORM_MAC) +if(_gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_IOS) set(_gRPC_ALLTARGETS_LIBRARIES ${CMAKE_DL_LIBS} m pthread) elseif(_gRPC_PLATFORM_ANDROID) set(_gRPC_ALLTARGETS_LIBRARIES ${CMAKE_DL_LIBS} m) diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index 4057da40c16..43bc063aee5 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -130,6 +130,8 @@ set(_gRPC_PLATFORM_LINUX ON) elseif(<%text>${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(_gRPC_PLATFORM_MAC ON) + elseif(<%text>${CMAKE_SYSTEM_NAME} MATCHES "iOS") + set(_gRPC_PLATFORM_IOS ON) elseif(<%text>${CMAKE_SYSTEM_NAME} MATCHES "Android") set(_gRPC_PLATFORM_ANDROID ON) else() @@ -173,7 +175,7 @@ endif() endif() - if (_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC) + if (_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_IOS) # C core has C++ source code, but should not depend on libstc++ (for better portability). # We need to use a few tricks to convince cmake to do that. # https://stackoverflow.com/questions/15058403/how-to-stop-cmake-from-linking-against-libstdc @@ -198,7 +200,7 @@ set(CMAKE_CXX_FLAGS "<%text>${CMAKE_CXX_FLAGS} -std=c++11") endif() - if(_gRPC_PLATFORM_MAC) + if(_gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_IOS) set(_gRPC_ALLTARGETS_LIBRARIES <%text>${CMAKE_DL_LIBS} m pthread) elseif(_gRPC_PLATFORM_ANDROID) set(_gRPC_ALLTARGETS_LIBRARIES <%text>${CMAKE_DL_LIBS} m) From 7b239a287e93ad9e0b4f3933b80921c03e5364c2 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Sun, 9 Jun 2019 10:29:42 -0700 Subject: [PATCH 0482/1555] Move extra args into RUN_TESTS_FLAGS --- tools/internal_ci/macos/grpc_basictests_objc.cfg | 7 +------ tools/internal_ci/macos/grpc_buildtests_objc.cfg | 7 +------ tools/internal_ci/macos/grpc_mactests_objc.cfg | 7 +------ tools/run_tests/run_tests_matrix.py | 9 ++++++++- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/tools/internal_ci/macos/grpc_basictests_objc.cfg b/tools/internal_ci/macos/grpc_basictests_objc.cfg index 6563fa69d02..c5ee5015c3c 100644 --- a/tools/internal_ci/macos/grpc_basictests_objc.cfg +++ b/tools/internal_ci/macos/grpc_basictests_objc.cfg @@ -27,10 +27,5 @@ action { env_vars { key: "RUN_TESTS_FLAGS" - value: "-f basictests macos objc dbg --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results" -} - -env_vars { - key: "GRPC_OBJC_TEST_EXTRA_ARGS" - value: "-r ios-test-.*" + value: "-f basictests macos objc dbg --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results --extra_args '-r ios-test-.*'" } diff --git a/tools/internal_ci/macos/grpc_buildtests_objc.cfg b/tools/internal_ci/macos/grpc_buildtests_objc.cfg index d1a802eef5e..d4bbcf5ab47 100644 --- a/tools/internal_ci/macos/grpc_buildtests_objc.cfg +++ b/tools/internal_ci/macos/grpc_buildtests_objc.cfg @@ -27,10 +27,5 @@ action { env_vars { key: "RUN_TESTS_FLAGS" - value: "-f basictests macos objc dbg --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results" -} - -env_vars { - key: "GRPC_OBJC_TEST_EXTRA_ARGS" - value: "-r ios-buildtest-.*" + value: "-f basictests macos objc dbg --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results --extra_args '-r ios-buildtest-.*'" } diff --git a/tools/internal_ci/macos/grpc_mactests_objc.cfg b/tools/internal_ci/macos/grpc_mactests_objc.cfg index 945bcb8c466..2147e12eb85 100644 --- a/tools/internal_ci/macos/grpc_mactests_objc.cfg +++ b/tools/internal_ci/macos/grpc_mactests_objc.cfg @@ -27,10 +27,5 @@ action { env_vars { key: "RUN_TESTS_FLAGS" - value: "-f basictests macos objc dbg --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results" -} - -env_vars { - key: "GRPC_OBJC_TEST_EXTRA_ARGS" - value: "-r mac-test-.*" + value: "-f basictests macos objc dbg --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results --extra_args '-r mac-test-.*'" } diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index ac9acbce730..ffb7e2cc71d 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -249,7 +249,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['dbg'], platforms=['macos'], labels=['basictests', 'multilang'], - extra_args=extra_args + [os.getenv('GRPC_OBJC_TEST_EXTRA_ARGS', '.*')], + extra_args=extra_args, inner_jobs=inner_jobs, timeout_seconds=_OBJC_RUNTESTS_TIMEOUT) @@ -519,6 +519,11 @@ if __name__ == "__main__": type=str, nargs='?', help='Upload test results to a specified BQ table.') + argp.add_argument( + '--extra_args', + default='', + type=str, + help='Extra test args passed to each sub-script.') args = argp.parse_args() extra_args = [] @@ -536,6 +541,8 @@ if __name__ == "__main__": extra_args.append('--bq_result_table') extra_args.append('%s' % args.bq_result_table) extra_args.append('--measure_cpu_costs') + if args.extra_args: + extra_args.append('%s' % args.extra_args) all_jobs = _create_test_jobs(extra_args=extra_args, inner_jobs=args.inner_jobs) + \ _create_portability_test_jobs(extra_args=extra_args, inner_jobs=args.inner_jobs) From 29c3d437524d4b21379be2bbad52c476cbe9d673 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Sun, 9 Jun 2019 10:30:03 -0700 Subject: [PATCH 0483/1555] Make same change to pull request configs --- ..._objc_dbg.cfg => grpc_basictests_objc.cfg} | 2 +- .../pull_request/grpc_buildtests_objc.cfg | 31 +++++++++++++++++++ ...ts_objc_opt.cfg => grpc_mactests_objc.cfg} | 2 +- 3 files changed, 33 insertions(+), 2 deletions(-) rename tools/internal_ci/macos/pull_request/{grpc_basictests_objc_dbg.cfg => grpc_basictests_objc.cfg} (96%) create mode 100644 tools/internal_ci/macos/pull_request/grpc_buildtests_objc.cfg rename tools/internal_ci/macos/pull_request/{grpc_basictests_objc_opt.cfg => grpc_mactests_objc.cfg} (90%) diff --git a/tools/internal_ci/macos/pull_request/grpc_basictests_objc_dbg.cfg b/tools/internal_ci/macos/pull_request/grpc_basictests_objc.cfg similarity index 96% rename from tools/internal_ci/macos/pull_request/grpc_basictests_objc_dbg.cfg rename to tools/internal_ci/macos/pull_request/grpc_basictests_objc.cfg index 775fd355a5b..cb433413504 100644 --- a/tools/internal_ci/macos/pull_request/grpc_basictests_objc_dbg.cfg +++ b/tools/internal_ci/macos/pull_request/grpc_basictests_objc.cfg @@ -27,5 +27,5 @@ action { env_vars { key: "RUN_TESTS_FLAGS" - value: "-f basictests macos objc dbg --internal_ci -j 1 --inner_jobs 4 --max_time=3600" + value: "-f basictests macos objc dbg --internal_ci -j 1 --inner_jobs 4 --extra_args '-r ios-test-.*'" } diff --git a/tools/internal_ci/macos/pull_request/grpc_buildtests_objc.cfg b/tools/internal_ci/macos/pull_request/grpc_buildtests_objc.cfg new file mode 100644 index 00000000000..8f35fda899a --- /dev/null +++ b/tools/internal_ci/macos/pull_request/grpc_buildtests_objc.cfg @@ -0,0 +1,31 @@ +# Copyright 2018 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" +timeout_mins: 120 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests macos objc dbg --internal_ci -j 1 --inner_jobs 4 --extra_args '-r ios-buildtest-.*'" +} diff --git a/tools/internal_ci/macos/pull_request/grpc_basictests_objc_opt.cfg b/tools/internal_ci/macos/pull_request/grpc_mactests_objc.cfg similarity index 90% rename from tools/internal_ci/macos/pull_request/grpc_basictests_objc_opt.cfg rename to tools/internal_ci/macos/pull_request/grpc_mactests_objc.cfg index 652ef1bb77a..5691375392e 100644 --- a/tools/internal_ci/macos/pull_request/grpc_basictests_objc_opt.cfg +++ b/tools/internal_ci/macos/pull_request/grpc_mactests_objc.cfg @@ -27,5 +27,5 @@ action { env_vars { key: "RUN_TESTS_FLAGS" - value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --max_time=3600" + value: "-f basictests macos objc dbg --internal_ci -j 1 --inner_jobs 4 --extra_args '-r mac-test-.*'" } From 9b3c9e3635a360bfe2b7bd8b09e787b5d8f73d11 Mon Sep 17 00:00:00 2001 From: John Luo Date: Sun, 9 Jun 2019 22:31:36 -0700 Subject: [PATCH 0484/1555] Add MSBuild metadata to set LiteClient for client generation. --- src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets | 1 + 1 file changed, 1 insertion(+) diff --git a/src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets b/src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets index dd01b8183db..493212fe7e5 100644 --- a/src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets +++ b/src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets @@ -38,6 +38,7 @@ <_GrpcOutputOptions>%(Protobuf_Compile._GrpcOutputOptions);no_server + <_GrpcOutputOptions Condition=" '%(Protobuf_Compile.ClientType)' == 'LiteClient' ">%(Protobuf_Compile._GrpcOutputOptions);lite_client <_GrpcOutputOptions>%(Protobuf_Compile._GrpcOutputOptions);no_client From c9d928f36d1e497b9911ad5ff1b529b09e810295 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 10 Jun 2019 01:01:30 -0700 Subject: [PATCH 0485/1555] Migrate types required for client interceptors to Grpc.Core.Api --- .../Interceptors/CallInvokerExtensions.cs | 0 .../Interceptors/InterceptingCallInvoker.cs | 0 src/csharp/Grpc.Core/ForwardedTypes.cs | 2 ++ 3 files changed, 2 insertions(+) rename src/csharp/{Grpc.Core => Grpc.Core.Api}/Interceptors/CallInvokerExtensions.cs (100%) rename src/csharp/{Grpc.Core => Grpc.Core.Api}/Interceptors/InterceptingCallInvoker.cs (100%) diff --git a/src/csharp/Grpc.Core/Interceptors/CallInvokerExtensions.cs b/src/csharp/Grpc.Core.Api/Interceptors/CallInvokerExtensions.cs similarity index 100% rename from src/csharp/Grpc.Core/Interceptors/CallInvokerExtensions.cs rename to src/csharp/Grpc.Core.Api/Interceptors/CallInvokerExtensions.cs diff --git a/src/csharp/Grpc.Core/Interceptors/InterceptingCallInvoker.cs b/src/csharp/Grpc.Core.Api/Interceptors/InterceptingCallInvoker.cs similarity index 100% rename from src/csharp/Grpc.Core/Interceptors/InterceptingCallInvoker.cs rename to src/csharp/Grpc.Core.Api/Interceptors/InterceptingCallInvoker.cs diff --git a/src/csharp/Grpc.Core/ForwardedTypes.cs b/src/csharp/Grpc.Core/ForwardedTypes.cs index ab5f5a87c67..fb99cfc018d 100644 --- a/src/csharp/Grpc.Core/ForwardedTypes.cs +++ b/src/csharp/Grpc.Core/ForwardedTypes.cs @@ -36,6 +36,7 @@ using Grpc.Core.Utils; [assembly:TypeForwardedToAttribute(typeof(CallCredentials))] [assembly:TypeForwardedToAttribute(typeof(CallFlags))] [assembly:TypeForwardedToAttribute(typeof(CallInvoker))] +[assembly:TypeForwardedToAttribute(typeof(CallInvokerExtensions))] [assembly:TypeForwardedToAttribute(typeof(CallOptions))] [assembly:TypeForwardedToAttribute(typeof(ClientInterceptorContext<,>))] [assembly:TypeForwardedToAttribute(typeof(ContextPropagationOptions))] @@ -45,6 +46,7 @@ using Grpc.Core.Utils; [assembly:TypeForwardedToAttribute(typeof(IAsyncStreamWriter<>))] [assembly:TypeForwardedToAttribute(typeof(IClientStreamWriter<>))] [assembly:TypeForwardedToAttribute(typeof(Interceptor))] +[assembly:TypeForwardedToAttribute(typeof(InterceptingCallInvoker))] [assembly:TypeForwardedToAttribute(typeof(IServerStreamWriter<>))] [assembly:TypeForwardedToAttribute(typeof(Marshaller<>))] [assembly:TypeForwardedToAttribute(typeof(Marshallers))] From 5d65a9fa7b9cd0111a67c91f4ce3cc6fbd25a5d0 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Mon, 10 Jun 2019 15:07:39 -0400 Subject: [PATCH 0486/1555] Address comments from Vijay. --- src/core/ext/transport/chttp2/transport/frame_data.cc | 8 ++++---- src/core/lib/gpr/string.cc | 9 ++++++++- src/core/lib/gpr/string.h | 7 ++++++- src/core/lib/slice/slice.cc | 9 +++++++-- src/core/lib/slice/slice_internal.h | 2 ++ src/core/lib/slice/slice_string_helpers.cc | 9 +++++++++ src/core/lib/slice/slice_string_helpers.h | 2 ++ src/core/lib/surface/validate_metadata.cc | 3 +-- test/core/slice/slice_test.cc | 10 ++++++++++ 9 files changed, 49 insertions(+), 10 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/frame_data.cc b/src/core/ext/transport/chttp2/transport/frame_data.cc index c50d7e48d41..74c305b820f 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.cc +++ b/src/core/ext/transport/chttp2/transport/frame_data.cc @@ -137,10 +137,10 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( p->error = grpc_error_set_int(p->error, GRPC_ERROR_INT_STREAM_ID, static_cast(s->id)); gpr_free(msg); - p->error = grpc_error_set_str( - p->error, GRPC_ERROR_STR_RAW_BYTES, - grpc_slice_from_moved_string(grpc_core::UniquePtr( - grpc_dump_slice(*slice, GPR_DUMP_HEX | GPR_DUMP_ASCII)))); + p->error = + grpc_error_set_str(p->error, GRPC_ERROR_STR_RAW_BYTES, + grpc_dump_slice_to_slice( + *slice, GPR_DUMP_HEX | GPR_DUMP_ASCII)); p->error = grpc_error_set_int(p->error, GRPC_ERROR_INT_OFFSET, cur - beg); p->state = GRPC_CHTTP2_DATA_ERROR; diff --git a/src/core/lib/gpr/string.cc b/src/core/lib/gpr/string.cc index 31d5fdee5be..a39f56ef926 100644 --- a/src/core/lib/gpr/string.cc +++ b/src/core/lib/gpr/string.cc @@ -126,7 +126,8 @@ static void asciidump(dump_out* out, const char* buf, size_t len) { } } -char* gpr_dump(const char* buf, size_t len, uint32_t flags) { +char* gpr_dump_return_len(const char* buf, size_t len, uint32_t flags, + size_t* out_len) { dump_out out = dump_out_create(); if (flags & GPR_DUMP_HEX) { hexdump(&out, buf, len); @@ -135,9 +136,15 @@ char* gpr_dump(const char* buf, size_t len, uint32_t flags) { asciidump(&out, buf, len); } dump_out_append(&out, 0); + *out_len = out.length; return out.data; } +char* gpr_dump(const char* buf, size_t len, uint32_t flags) { + size_t unused; + return gpr_dump_return_len(buf, len, flags, &unused); +} + int gpr_parse_bytes_to_uint32(const char* buf, size_t len, uint32_t* result) { uint32_t out = 0; uint32_t new_val; diff --git a/src/core/lib/gpr/string.h b/src/core/lib/gpr/string.h index c5efcec3bb1..bf59db7abfe 100644 --- a/src/core/lib/gpr/string.h +++ b/src/core/lib/gpr/string.h @@ -32,9 +32,14 @@ #define GPR_DUMP_HEX 0x00000001 #define GPR_DUMP_ASCII 0x00000002 -/* Converts array buf, of length len, into a C string according to the flags. +/* Converts array buf, of length len, into a C string according to the flags. Result should be freed with gpr_free() */ char* gpr_dump(const char* buf, size_t len, uint32_t flags); +/* Converts array buf, of length len, into a C string according to the flags. + The length of the returned buffer is stored in out_len. + Result should be freed with gpr_free() */ +char* gpr_dump_return_len(const char* buf, size_t len, uint32_t flags, + size_t* out_len); /* Parses an array of bytes into an integer (base 10). Returns 1 on success, 0 on failure. */ diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc index 0f8ea6ae018..eebf66bb882 100644 --- a/src/core/lib/slice/slice.cc +++ b/src/core/lib/slice/slice.cc @@ -216,8 +216,8 @@ grpc_slice grpc_slice_from_copied_string(const char* source) { return grpc_slice_from_copied_buffer(source, strlen(source)); } -grpc_slice grpc_slice_from_moved_string(grpc_core::UniquePtr p) { - const size_t len = strlen(p.get()); +grpc_slice grpc_slice_from_moved_buffer(grpc_core::UniquePtr p, + size_t len) { uint8_t* ptr = reinterpret_cast(p.get()); grpc_slice slice; if (len <= sizeof(slice.data.inlined.bytes)) { @@ -234,6 +234,11 @@ grpc_slice grpc_slice_from_moved_string(grpc_core::UniquePtr p) { return slice; } +grpc_slice grpc_slice_from_moved_string(grpc_core::UniquePtr p) { + const size_t len = strlen(p.get()); + return grpc_slice_from_moved_buffer(std::move(p), len); +} + namespace { class MallocRefCount { diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index 457b76700ed..c6943fe6563 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -303,6 +303,8 @@ inline uint32_t grpc_slice_hash_internal(const grpc_slice& s) { : grpc_slice_hash_refcounted(s); } +grpc_slice grpc_slice_from_moved_buffer(grpc_core::UniquePtr p, + size_t len); grpc_slice grpc_slice_from_moved_string(grpc_core::UniquePtr p); // Returns the memory used by this slice, not counting the slice structure diff --git a/src/core/lib/slice/slice_string_helpers.cc b/src/core/lib/slice/slice_string_helpers.cc index c2392fd392f..7887e0305fb 100644 --- a/src/core/lib/slice/slice_string_helpers.cc +++ b/src/core/lib/slice/slice_string_helpers.cc @@ -25,6 +25,7 @@ #include #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/slice/slice_internal.h" char* grpc_dump_slice(const grpc_slice& s, uint32_t flags) { @@ -32,6 +33,14 @@ char* grpc_dump_slice(const grpc_slice& s, uint32_t flags) { GRPC_SLICE_LENGTH(s), flags); } +grpc_slice grpc_dump_slice_to_slice(const grpc_slice& s, uint32_t flags) { + size_t len; + grpc_core::UniquePtr ptr( + gpr_dump_return_len(reinterpret_cast GRPC_SLICE_START_PTR(s), + GRPC_SLICE_LENGTH(s), flags, &len)); + return grpc_slice_from_moved_buffer(std::move(ptr), len); +} + /** Finds the initial (\a begin) and final (\a end) offsets of the next * substring from \a str + \a read_offset until the next \a sep or the end of \a * str. diff --git a/src/core/lib/slice/slice_string_helpers.h b/src/core/lib/slice/slice_string_helpers.h index cb1df658fa5..6551a6df75d 100644 --- a/src/core/lib/slice/slice_string_helpers.h +++ b/src/core/lib/slice/slice_string_helpers.h @@ -31,6 +31,8 @@ /* Calls gpr_dump on a slice. */ char* grpc_dump_slice(const grpc_slice& slice, uint32_t flags); +/* Calls gpr_dump on a slice and returns the result as a slice. */ +grpc_slice grpc_dump_slice_to_slice(const grpc_slice& slice, uint32_t flags); /** Split \a str by the separator \a sep. Results are stored in \a dst, which * should be a properly initialized instance. */ diff --git a/src/core/lib/surface/validate_metadata.cc b/src/core/lib/surface/validate_metadata.cc index 46554596235..0f65091333d 100644 --- a/src/core/lib/surface/validate_metadata.cc +++ b/src/core/lib/surface/validate_metadata.cc @@ -40,13 +40,12 @@ static grpc_error* conforms_to(const grpc_slice& slice, int byte = idx / 8; int bit = idx % 8; if ((legal_bits[byte] & (1 << bit)) == 0) { - char* dump = grpc_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); grpc_error* error = grpc_error_set_str( grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(err_desc), GRPC_ERROR_INT_OFFSET, p - GRPC_SLICE_START_PTR(slice)), GRPC_ERROR_STR_RAW_BYTES, - grpc_slice_from_moved_string(grpc_core::UniquePtr(dump))); + grpc_dump_slice_to_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII)); return error; } } diff --git a/test/core/slice/slice_test.cc b/test/core/slice/slice_test.cc index 3c9c0572a43..4f824cbd5ad 100644 --- a/test/core/slice/slice_test.cc +++ b/test/core/slice/slice_test.cc @@ -311,6 +311,16 @@ static void test_moved_string_slice(void) { reinterpret_cast(large_ptr)); grpc_slice_unref(large); + // Moved buffer must respect the provided length not the actual length of the + // string. + large_ptr = strdup(kSLargeStr); + small = grpc_slice_from_moved_buffer(grpc_core::UniquePtr(large_ptr), + strlen(kSmallStr)); + GPR_ASSERT(GRPC_SLICE_LENGTH(small) == strlen(kSmallStr)); + GPR_ASSERT(GRPC_SLICE_START_PTR(small) != + reinterpret_cast(large_ptr)); + grpc_slice_unref(small); + grpc_shutdown(); } From 31f0fad9a1fc09e26c3da9c6c4593efdd52a3775 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 10 Jun 2019 13:32:59 -0700 Subject: [PATCH 0487/1555] Fix usage of new and delete --- src/core/lib/iomgr/cfstream_handle.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/cfstream_handle.cc b/src/core/lib/iomgr/cfstream_handle.cc index 2fda160f68a..b77851a6540 100644 --- a/src/core/lib/iomgr/cfstream_handle.cc +++ b/src/core/lib/iomgr/cfstream_handle.cc @@ -47,7 +47,8 @@ void CFStreamHandle::Release(void* info) { CFStreamHandle* CFStreamHandle::CreateStreamHandle( CFReadStreamRef read_stream, CFWriteStreamRef write_stream) { - return new CFStreamHandle(read_stream, write_stream); + CFStreamHandle* handle = static_cast(gpr_malloc(sizeof(CFStreamHandle))); + return new (handle) CFStreamHandle(read_stream, write_stream); } void CFStreamHandle::ReadCallback(CFReadStreamRef stream, @@ -188,7 +189,8 @@ void CFStreamHandle::Unref(const char* file, int line, const char* reason) { reason, val, val - 1); } if (gpr_unref(&refcount_)) { - delete this; + this->~CFStreamHandle(); + gpr_free(this); } } From 52291e5832f5876dc56a74b685a0e7fbb7b7eb65 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Mon, 10 Jun 2019 13:58:34 -0700 Subject: [PATCH 0488/1555] Fix PropogationOptions --- include/grpcpp/impl/codegen/client_context.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/grpcpp/impl/codegen/client_context.h b/include/grpcpp/impl/codegen/client_context.h index 8c3b669f2b7..02389464ce4 100644 --- a/include/grpcpp/impl/codegen/client_context.h +++ b/include/grpcpp/impl/codegen/client_context.h @@ -24,6 +24,7 @@ namespace grpc { typedef ::grpc_impl::ClientContext ClientContext; +typedef ::grpc_impl::PropagationOptions PropagationOptions; } // namespace grpc From a8fe8d4f19c0e563da47a90e9e3cada47ac779f6 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 10 Jun 2019 14:19:39 -0700 Subject: [PATCH 0489/1555] Use grpc_core::New and grpc_core::Delete --- src/core/lib/iomgr/cfstream_handle.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/core/lib/iomgr/cfstream_handle.cc b/src/core/lib/iomgr/cfstream_handle.cc index b77851a6540..b56170cc49a 100644 --- a/src/core/lib/iomgr/cfstream_handle.cc +++ b/src/core/lib/iomgr/cfstream_handle.cc @@ -19,6 +19,7 @@ #include #include "src/core/lib/iomgr/port.h" +#include "src/core/lib/gprpp/memory.h" #ifdef GRPC_CFSTREAM #import @@ -47,8 +48,7 @@ void CFStreamHandle::Release(void* info) { CFStreamHandle* CFStreamHandle::CreateStreamHandle( CFReadStreamRef read_stream, CFWriteStreamRef write_stream) { - CFStreamHandle* handle = static_cast(gpr_malloc(sizeof(CFStreamHandle))); - return new (handle) CFStreamHandle(read_stream, write_stream); + return grpc_core::New(read_stream, write_stream); } void CFStreamHandle::ReadCallback(CFReadStreamRef stream, @@ -189,8 +189,7 @@ void CFStreamHandle::Unref(const char* file, int line, const char* reason) { reason, val, val - 1); } if (gpr_unref(&refcount_)) { - this->~CFStreamHandle(); - gpr_free(this); + grpc_core::Delete(this); } } From 8ff61a3b9c7e838950b47d20ab9c3dbcbab486da Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 10 Jun 2019 14:24:53 -0700 Subject: [PATCH 0490/1555] clang-format --- src/core/lib/iomgr/cfstream_handle.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/cfstream_handle.cc b/src/core/lib/iomgr/cfstream_handle.cc index b56170cc49a..8d01386a8f9 100644 --- a/src/core/lib/iomgr/cfstream_handle.cc +++ b/src/core/lib/iomgr/cfstream_handle.cc @@ -18,8 +18,8 @@ #include -#include "src/core/lib/iomgr/port.h" #include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/iomgr/port.h" #ifdef GRPC_CFSTREAM #import From f7cb9c9f3e2d817a020585236d8b2f0264a120ee Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Mon, 10 Jun 2019 15:20:09 -0700 Subject: [PATCH 0491/1555] Add Debug Example --- examples/python/debug/BUILD.bazel | 59 ++++++++++++ examples/python/debug/README.md | 43 +++++++++ examples/python/debug/debug_server.py | 91 +++++++++++++++++++ examples/python/debug/get_stats.py | 52 +++++++++++ examples/python/debug/send_message.py | 67 ++++++++++++++ .../python/debug/test/_debug_example_test.py | 63 +++++++++++++ 6 files changed, 375 insertions(+) create mode 100644 examples/python/debug/BUILD.bazel create mode 100644 examples/python/debug/README.md create mode 100644 examples/python/debug/debug_server.py create mode 100644 examples/python/debug/get_stats.py create mode 100644 examples/python/debug/send_message.py create mode 100644 examples/python/debug/test/_debug_example_test.py diff --git a/examples/python/debug/BUILD.bazel b/examples/python/debug/BUILD.bazel new file mode 100644 index 00000000000..0134d8675ed --- /dev/null +++ b/examples/python/debug/BUILD.bazel @@ -0,0 +1,59 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@grpc_python_dependencies//:requirements.bzl", "requirement") + +py_binary( + name = "debug_server", + testonly = 1, + srcs = ["debug_server.py"], + deps = [ + "//src/python/grpcio/grpc:grpcio", + "//src/python/grpcio_channelz/grpc_channelz/v1:grpc_channelz", + "//examples:py_helloworld", + ], +) + +py_binary( + name = "send_message", + testonly = 1, + srcs = ["send_message.py"], + deps = [ + "//src/python/grpcio/grpc:grpcio", + "//examples:py_helloworld", + ], +) + +py_binary( + name = "get_stats", + testonly = 1, + srcs = ["get_stats.py"], + deps = [ + "//src/python/grpcio/grpc:grpcio", + "//src/python/grpcio_channelz/grpc_channelz/v1:grpc_channelz", + ], +) + +py_test( + name = "_debug_example_test", + srcs = ["test/_debug_example_test.py"], + deps = [ + "//src/python/grpcio/grpc:grpcio", + "//src/python/grpcio_channelz/grpc_channelz/v1:grpc_channelz", + "//examples:py_helloworld", + ":debug_server", + ":send_message", + ":get_stats", + ], +) \ No newline at end of file diff --git a/examples/python/debug/README.md b/examples/python/debug/README.md new file mode 100644 index 00000000000..db57c79de84 --- /dev/null +++ b/examples/python/debug/README.md @@ -0,0 +1,43 @@ +# gRPC Python Debug Example + +This example demonstrate the usage of Channelz. For a better looking website, the [gdebug](https://github.com/grpc/grpc-experiments/tree/master/gdebug) uses gRPC-Web protocol and will serve all useful information in web pages. + +## Channelz: Live Channel Tracing + +Channelz is a channel tracing feature. It will track statistics like how many messages have been sent, how many of them failed, what are the connected sockets. Since it is implemented in C-Core and has low-overhead, it is recommended to turn on for production services. See [Channelz design doc](https://github.com/grpc/proposal/blob/master/A14-channelz.md). + +## How to enable tracing log +The tracing log generation might have larger overhead, especially when you try to trace transport. It would result in replicating the traffic loads. However, it is still the most powerful tool when you need to dive in. + +### The Most Verbose Tracing Log + +Specify environment variables, then run your application: + +``` +GRPC_VERBOSITY=debug +GRPC_TRACE=all +``` + +For more granularity, please see [environment_variables](https://github.com/grpc/grpc/blob/master/doc/environment_variables.md). + +### Debug Transport Protocol + +``` +GRPC_VERBOSITY=debug +GRPC_TRACE=tcp,http,secure_endpoint,transport_security +``` + +### Debug Connection Behavior + +``` +GRPC_VERBOSITY=debug +GRPC_TRACE=call_error,connectivity_state,pick_first,round_robin,glb +``` + +## How to debug your application? + +`pdb` is a debugging tool that is available for Python interpreters natively. You can set breakpoint, and execute commands while the application is stopped. + +The simplest usage is add a single line in the place you want to inspect: `import pdb; pdb.set_trace()`. When interpreter see this line, it would pop out a interactive command line interface for you to inspect the application state. + +For more detailed usage, see https://docs.python.org/3/library/pdb.html. diff --git a/examples/python/debug/debug_server.py b/examples/python/debug/debug_server.py new file mode 100644 index 00000000000..2866d284267 --- /dev/null +++ b/examples/python/debug/debug_server.py @@ -0,0 +1,91 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""The Python example of utilizing Channelz feature.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import argparse +import logging +import time +from concurrent import futures +import random + +import grpc +from grpc_channelz.v1 import channelz + +from examples import helloworld_pb2 +from examples import helloworld_pb2_grpc + +_LOGGER = logging.getLogger(__name__) +_LOGGER.setLevel(logging.INFO) + +_ONE_DAY_IN_SECONDS = 60 * 60 * 24 +_RANDOM_FAILURE_RATE = 0.3 + + +class FaultInjectGreeter(helloworld_pb2_grpc.GreeterServicer): + + def __init__(self, failure_rate): + self._failure_rate = failure_rate + + def SayHello(self, request, context): + if random.random() < self._failure_rate: + context.abort(grpc.StatusCode.UNAVAILABLE, + 'Randomly injected failure.') + return helloworld_pb2.HelloReply( + message='Hello, %s!' % request.name) + + +def create_server(addr, failure_rate): + server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) + helloworld_pb2_grpc.add_GreeterServicer_to_server( + FaultInjectGreeter(failure_rate), server) + + # Add Channelz Servicer to the gRPC server + channelz.add_channelz_servicer(server) + + server.add_insecure_port(addr) + return server + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument( + '--addr', + nargs=1, + type=str, + default='[::]:50051', + help='the address to listen on') + parser.add_argument( + '--failure_rate', + nargs=1, + type=float, + default=0.3, + help='a float indicates the percentage of failed message injections') + args = parser.parse_args() + + server = create_server(addr=args.addr, failure_rate=args.failure_rate) + server.start() + try: + while True: + time.sleep(_ONE_DAY_IN_SECONDS) + except KeyboardInterrupt: + server.stop(0) + + +if __name__ == '__main__': + logging.basicConfig(level=logging.INFO) + main() diff --git a/examples/python/debug/get_stats.py b/examples/python/debug/get_stats.py new file mode 100644 index 00000000000..22924098d51 --- /dev/null +++ b/examples/python/debug/get_stats.py @@ -0,0 +1,52 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Poll statistics from the server.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import logging +import argparse +import grpc +from grpc_channelz.v1 import channelz_pb2 +from grpc_channelz.v1 import channelz_pb2_grpc + + +def run(addr): + # NOTE(gRPC Python Team): .close() is possible on a channel and should be + # used in circumstances in which the with statement does not fit the needs + # of the code. + with grpc.insecure_channel(addr) as channel: + channelz_stub = channelz_pb2_grpc.ChannelzStub(channel) + response = channelz_stub.GetServers( + channelz_pb2.GetServersRequest(start_server_id=0)) + print('Info for all servers: %s' % response) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument( + '--addr', + nargs=1, + type=str, + default='[::]:50051', + help='the address to request') + args = parser.parse_args() + run(addr=args.addr) + + +if __name__ == '__main__': + logging.basicConfig() + main() diff --git a/examples/python/debug/send_message.py b/examples/python/debug/send_message.py new file mode 100644 index 00000000000..99425263b50 --- /dev/null +++ b/examples/python/debug/send_message.py @@ -0,0 +1,67 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Send multiple greeting messages to the backend.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import logging +import argparse +import grpc +from examples import helloworld_pb2 +from examples import helloworld_pb2_grpc + + +def process(stub, request): + try: + response = stub.SayHello(request) + except grpc.RpcError as rpc_error: + print('Received error: %s' % rpc_error) + else: + print('Received message: %s' % response) + + +def run(addr, n): + # NOTE(gRPC Python Team): .close() is possible on a channel and should be + # used in circumstances in which the with statement does not fit the needs + # of the code. + with grpc.insecure_channel(addr) as channel: + stub = helloworld_pb2_grpc.GreeterStub(channel) + request = helloworld_pb2.HelloRequest(name='you') + for _ in range(n): + process(stub, request) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument( + '--addr', + nargs=1, + type=str, + default='[::]:50051', + help='the address to request') + parser.add_argument( + '-n', + nargs=1, + type=int, + default=10, + help='an integer for number of messages to sent') + args = parser.parse_args() + run(addr=args.addr, n=args.n) + + +if __name__ == '__main__': + logging.basicConfig() + main() diff --git a/examples/python/debug/test/_debug_example_test.py b/examples/python/debug/test/_debug_example_test.py new file mode 100644 index 00000000000..133fee2b0b6 --- /dev/null +++ b/examples/python/debug/test/_debug_example_test.py @@ -0,0 +1,63 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Test for gRPC Python debug example.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import logging +import unittest +from contextlib import contextmanager +import socket + +from examples.python.debug import debug_server +from examples.python.debug import send_message +from examples.python.debug import get_stats + +_LOGGER = logging.getLogger(__name__) +_LOGGER.setLevel(logging.INFO) + +_FAILURE_RATE = 0.5 +_NUMBER_OF_MESSAGES = 100 + + +@contextmanager +def get_free_loopback_tcp_port(): + if socket.has_ipv6: + tcp_socket = socket.socket(socket.AF_INET6) + else: + tcp_socket = socket.socket(socket.AF_INET) + tcp_socket.bind(('', 0)) + address_tuple = tcp_socket.getsockname() + yield "localhost:%s" % (address_tuple[1]) + tcp_socket.close() + + +class DebugExampleTest(unittest.TestCase): + + def test_channelz_example(self): + with get_free_loopback_tcp_port() as addr: + server = debug_server.create_server( + addr=addr, failure_rate=_FAILURE_RATE) + server.start() + send_message.run(addr=addr, n=_NUMBER_OF_MESSAGES) + get_stats.run(addr=addr) + server.stop(None) + # No unhandled exception raised, test passed! + + +if __name__ == '__main__': + logging.basicConfig() + unittest.main(verbosity=2) From ea427791d398ec2198e543361c51c3f378786e48 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 10 Jun 2019 16:22:25 -0700 Subject: [PATCH 0492/1555] Reviewer comments --- test/core/bad_client/tests/unknown_frame.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/core/bad_client/tests/unknown_frame.cc b/test/core/bad_client/tests/unknown_frame.cc index a9f56548c2a..e58166ccd56 100644 --- a/test/core/bad_client/tests/unknown_frame.cc +++ b/test/core/bad_client/tests/unknown_frame.cc @@ -33,16 +33,18 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq, } } +#define APPEND_BUFFER(string, to_append) \ + ((string).append((to_append), sizeof(to_append) - 1)) + namespace { TEST(UnknownFrameType, Test) { /* test that all invalid/unknown frame types are handled */ for (int i = 10; i <= 255; i++) { std::string unknown_frame_string; - unknown_frame_string.append("\x00\x00\x00", sizeof("\x00\x00\x00") - 1); + APPEND_BUFFER(unknown_frame_string, "\x00\x00\x00"); char frame_type = static_cast(i); unknown_frame_string.append(&frame_type, 1); - unknown_frame_string.append("\x00\x00\x00\x00\x01", - sizeof("\x00\x00\x00\x00\x01") - 1); + APPEND_BUFFER(unknown_frame_string, "\x00\x00\x00\x00\x01"); grpc_bad_client_arg args[2]; args[0] = connection_preface_arg; args[1].client_validator = nullptr; From 9847c6364a48700ad633272799ade77530e7de54 Mon Sep 17 00:00:00 2001 From: Mehrdad Afshari Date: Mon, 10 Jun 2019 23:31:51 +0000 Subject: [PATCH 0493/1555] Silence pylint --- src/python/grpcio/grpc/_channel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/grpcio/grpc/_channel.py b/src/python/grpcio/grpc/_channel.py index 4b761bfe5f8..24f928ef69f 100644 --- a/src/python/grpcio/grpc/_channel.py +++ b/src/python/grpcio/grpc/_channel.py @@ -1099,7 +1099,7 @@ class Channel(grpc.Channel): # effect closure of the underlying cygrpc.Channel instance. try: self._unsubscribe_all() - except: + except: # pylint: disable=bare-except # Exceptions in __del__ are ignored by Python anyway, but they can # keep spamming logs. Just silence them. pass From 4155e9cf05aa6af340695862de87456611b1ffa2 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Tue, 11 Jun 2019 18:02:00 +1200 Subject: [PATCH 0494/1555] React to renaming grpc-dotnet sln --- .../grpc_interop_aspnetcore/build_interop.sh.template | 2 +- .../interoptest/grpc_interop_aspnetcore/build_interop.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh.template b/templates/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh.template index 55ecfb30192..acf12579357 100644 --- a/templates/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh.template +++ b/templates/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh.template @@ -39,4 +39,4 @@ ln -s $(pwd)/.dotnet/dotnet /usr/local/bin/dotnet fi - dotnet build --configuration Debug Grpc.AspNetCore.sln + dotnet build --configuration Debug Grpc.DotNet.sln diff --git a/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh b/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh index 0b32638b54b..acb2a0ab2d9 100644 --- a/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh +++ b/tools/dockerfile/interoptest/grpc_interop_aspnetcore/build_interop.sh @@ -37,4 +37,4 @@ then ln -s $(pwd)/.dotnet/dotnet /usr/local/bin/dotnet fi -dotnet build --configuration Debug Grpc.AspNetCore.sln +dotnet build --configuration Debug Grpc.DotNet.sln From a03cc2c8764d0031797749b5271fb41d3bb91290 Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Tue, 11 Jun 2019 10:11:55 -0700 Subject: [PATCH 0495/1555] Update ruby version to just 3.8 --- templates/grpc.gemspec.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/grpc.gemspec.template b/templates/grpc.gemspec.template index 9ca797fe913..f8dd0938936 100644 --- a/templates/grpc.gemspec.template +++ b/templates/grpc.gemspec.template @@ -31,7 +31,7 @@ s.require_paths = %w( src/ruby/lib src/ruby/bin src/ruby/pb ) s.platform = Gem::Platform::RUBY - s.add_dependency 'google-protobuf', '~> 3.8.0' + s.add_dependency 'google-protobuf', '~> 3.8' s.add_dependency 'googleapis-common-protos-types', '~> 1.0' s.add_development_dependency 'bundler', '~> 1.9' From 1f1eff115afc3aa95c6bf288e52490b893488426 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 11 Jun 2019 11:57:37 -0700 Subject: [PATCH 0496/1555] Split extra arguments --- tools/run_tests/run_tests_matrix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index ffb7e2cc71d..7de1cb975d3 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -542,7 +542,7 @@ if __name__ == "__main__": extra_args.append('%s' % args.bq_result_table) extra_args.append('--measure_cpu_costs') if args.extra_args: - extra_args.append('%s' % args.extra_args) + extra_args.extend(('%s' % args.extra_args).split()) all_jobs = _create_test_jobs(extra_args=extra_args, inner_jobs=args.inner_jobs) + \ _create_portability_test_jobs(extra_args=extra_args, inner_jobs=args.inner_jobs) From 3931c0bcd28c97eb9e71caddf1ae26c171bed93c Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 11 Jun 2019 11:57:58 -0700 Subject: [PATCH 0497/1555] yapf_codes --- tools/run_tests/run_tests.py | 138 ++++++++++++++++++----------------- 1 file changed, 73 insertions(+), 65 deletions(-) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index d99bbf43ffa..26762aa4840 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1050,72 +1050,80 @@ class ObjCLanguage(object): def test_specs(self): out = [] if self.config == 'dbg': - out += self.config.job_spec( - ['src/objective-c/tests/build_one_example.sh'], - timeout_seconds=10 * 60, - shortname='ios-buildtest-example-sample', - cpu_cost=1e6, - environ={ - 'SCHEME': 'Sample', - 'EXAMPLE_PATH': 'src/objective-c/examples/Sample' - }) - out += job_spec( - ['src/objective-c/tests/build_one_example.sh'], - timeout_seconds=10 * 60, - shortname='ios-buildtest-example-sample-frameworks', - cpu_cost=1e6, - environ={ - 'SCHEME': 'Sample', - 'EXAMPLE_PATH': 'src/objective-c/examples/Sample', - 'FRAMEWORKS': 'YES' - }) - out += self.config.job_spec( - ['src/objective-c/tests/build_one_example.sh'], - timeout_seconds=10 * 60, - shortname='ios-buildtest-example-switftsample', - cpu_cost=1e6, - environ={ - 'SCHEME': 'SwiftSample', - 'EXAMPLE_PATH': 'src/objective-c/examples/SwiftSample' - }) - out += self.config.job_spec( - ['src/objective-c/tests/run_plugin_tests.sh'], - timeout_seconds=60 * 60, - shortname='ios-test-plugintest', - cpu_cost=1e6, - environ=_FORCE_ENVIRON_FOR_WRAPPERS) - out += self.config.job_spec( - ['test/core/iomgr/ios/CFStreamTests/run_tests.sh'], - timeout_seconds=20 * 60, - shortname='ios-test-cfstream-tests', - cpu_cost=1e6, - environ=_FORCE_ENVIRON_FOR_WRAPPERS) - out += self.config.job_spec( - ['src/objective-c/tests/run_one_test.sh'], - timeout_seconds=60 * 60, - shortname='ios-test-unittests', - cpu_cost=1e6, - environ={SCHEME: 'UnitTests'}) - out += self.config.job_spec( - ['src/objective-c/tests/run_one_test.sh'], - timeout_seconds=60 * 60, - shortname='ios-test-interoptests', - cpu_cost=1e6, - environ={SCHEME: 'InteropTests'}) - out += self.config.job_spec( - ['src/objective-c/tests/run_one_test.sh'], - timeout_seconds=60 * 60, - shortname='ios-test-cronettests', - cpu_cost=1e6, - environ={SCHEME: 'CronetTests'}) - out += self.config.job_spec( - ['src/objective-c/tests/run_one_test.sh'], - timeout_seconds=60 * 60, - shortname='mac-test-basictests', - cpu_cost=1e6, - environ={SCHEME: 'MacTests'}) + out += self.config.job_spec( + ['src/objective-c/tests/build_one_example.sh'], + timeout_seconds=10 * 60, + shortname='ios-buildtest-example-sample', + cpu_cost=1e6, + environ={ + 'SCHEME': 'Sample', + 'EXAMPLE_PATH': 'src/objective-c/examples/Sample' + }) + out += job_spec( + ['src/objective-c/tests/build_one_example.sh'], + timeout_seconds=10 * 60, + shortname='ios-buildtest-example-sample-frameworks', + cpu_cost=1e6, + environ={ + 'SCHEME': 'Sample', + 'EXAMPLE_PATH': 'src/objective-c/examples/Sample', + 'FRAMEWORKS': 'YES' + }) + out += self.config.job_spec( + ['src/objective-c/tests/build_one_example.sh'], + timeout_seconds=10 * 60, + shortname='ios-buildtest-example-switftsample', + cpu_cost=1e6, + environ={ + 'SCHEME': 'SwiftSample', + 'EXAMPLE_PATH': 'src/objective-c/examples/SwiftSample' + }) + out += self.config.job_spec( + ['src/objective-c/tests/run_plugin_tests.sh'], + timeout_seconds=60 * 60, + shortname='ios-test-plugintest', + cpu_cost=1e6, + environ=_FORCE_ENVIRON_FOR_WRAPPERS) + out += self.config.job_spec( + ['test/core/iomgr/ios/CFStreamTests/run_tests.sh'], + timeout_seconds=20 * 60, + shortname='ios-test-cfstream-tests', + cpu_cost=1e6, + environ=_FORCE_ENVIRON_FOR_WRAPPERS) + out += self.config.job_spec( + ['src/objective-c/tests/run_one_test.sh'], + timeout_seconds=60 * 60, + shortname='ios-test-unittests', + cpu_cost=1e6, + environ={ + SCHEME: 'UnitTests' + }) + out += self.config.job_spec( + ['src/objective-c/tests/run_one_test.sh'], + timeout_seconds=60 * 60, + shortname='ios-test-interoptests', + cpu_cost=1e6, + environ={ + SCHEME: 'InteropTests' + }) + out += self.config.job_spec( + ['src/objective-c/tests/run_one_test.sh'], + timeout_seconds=60 * 60, + shortname='ios-test-cronettests', + cpu_cost=1e6, + environ={ + SCHEME: 'CronetTests' + }) + out += self.config.job_spec( + ['src/objective-c/tests/run_one_test.sh'], + timeout_seconds=60 * 60, + shortname='mac-test-basictests', + cpu_cost=1e6, + environ={ + SCHEME: 'MacTests' + }) - return sorted(out); + return sorted(out) def pre_build_steps(self): return [] From 7f787bd08371066e616a4a784712b237f0bab7fa Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Tue, 11 Jun 2019 12:12:33 -0700 Subject: [PATCH 0498/1555] Link against pthread in examples --- examples/cpp/helloworld/Makefile | 2 ++ examples/cpp/route_guide/Makefile | 2 ++ 2 files changed, 4 insertions(+) diff --git a/examples/cpp/helloworld/Makefile b/examples/cpp/helloworld/Makefile index 6af92347aa3..9af7337fd1b 100644 --- a/examples/cpp/helloworld/Makefile +++ b/examples/cpp/helloworld/Makefile @@ -21,10 +21,12 @@ CPPFLAGS += `pkg-config --cflags protobuf grpc` CXXFLAGS += -std=c++11 ifeq ($(SYSTEM),Darwin) LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc`\ + -pthread\ -lgrpc++_reflection\ -ldl else LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc`\ + -pthread\ -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed\ -ldl endif diff --git a/examples/cpp/route_guide/Makefile b/examples/cpp/route_guide/Makefile index 48a2073ba8c..3bf61cb76f1 100644 --- a/examples/cpp/route_guide/Makefile +++ b/examples/cpp/route_guide/Makefile @@ -21,10 +21,12 @@ CPPFLAGS += `pkg-config --cflags protobuf grpc` CXXFLAGS += -std=c++11 ifeq ($(SYSTEM),Darwin) LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++`\ + -pthread\ -lgrpc++_reflection\ -ldl else LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++`\ + -pthread\ -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed\ -ldl endif From 6a71e9f54635592506738ab0bd2d76e0d982eddc Mon Sep 17 00:00:00 2001 From: Hao Nguyen Date: Tue, 11 Jun 2019 13:17:41 -0700 Subject: [PATCH 0499/1555] Change Ruby Protobuf version to 3.8 --- grpc.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grpc.gemspec b/grpc.gemspec index 0f66332d48f..77b4f8c862e 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -29,7 +29,7 @@ Gem::Specification.new do |s| s.require_paths = %w( src/ruby/lib src/ruby/bin src/ruby/pb ) s.platform = Gem::Platform::RUBY - s.add_dependency 'google-protobuf', '~> 3.8.0' + s.add_dependency 'google-protobuf', '~> 3.8' s.add_dependency 'googleapis-common-protos-types', '~> 1.0' s.add_development_dependency 'bundler', '~> 1.9' From bb5f186f3dd6e90872762260708a15dc399b8945 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Tue, 11 Jun 2019 16:27:55 -0400 Subject: [PATCH 0500/1555] Convert TraceFlags in the hot path to DebugTraceFlags. We see up to 4% of cpu reduction and 3% of latency savings in production benchmarks. --- src/core/lib/iomgr/call_combiner.cc | 2 +- src/core/lib/iomgr/call_combiner.h | 2 +- src/core/lib/iomgr/ev_posix.cc | 6 +++--- src/core/lib/iomgr/ev_posix.h | 5 +++-- src/core/lib/iomgr/ev_windows.cc | 4 ++-- src/core/lib/iomgr/lockfree_event.cc | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/core/lib/iomgr/call_combiner.cc b/src/core/lib/iomgr/call_combiner.cc index 6a4e85de4df..6530d1c6ce6 100644 --- a/src/core/lib/iomgr/call_combiner.cc +++ b/src/core/lib/iomgr/call_combiner.cc @@ -28,7 +28,7 @@ namespace grpc_core { -TraceFlag grpc_call_combiner_trace(false, "call_combiner"); +DebugOnlyTraceFlag grpc_call_combiner_trace(false, "call_combiner"); namespace { diff --git a/src/core/lib/iomgr/call_combiner.h b/src/core/lib/iomgr/call_combiner.h index a10b437c15a..b56966f4196 100644 --- a/src/core/lib/iomgr/call_combiner.h +++ b/src/core/lib/iomgr/call_combiner.h @@ -43,7 +43,7 @@ namespace grpc_core { -extern TraceFlag grpc_call_combiner_trace; +extern DebugOnlyTraceFlag grpc_call_combiner_trace; class CallCombiner { public: diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc index ddafb7b5539..92f81c2efb8 100644 --- a/src/core/lib/iomgr/ev_posix.cc +++ b/src/core/lib/iomgr/ev_posix.cc @@ -44,11 +44,11 @@ GPR_GLOBAL_CONFIG_DEFINE_STRING( "This is a comma-separated list of engines, which are tried in priority " "order first -> last.") -grpc_core::TraceFlag grpc_polling_trace(false, - "polling"); /* Disabled by default */ +grpc_core::DebugOnlyTraceFlag grpc_polling_trace( + false, "polling"); /* Disabled by default */ /* Traces fd create/close operations */ -grpc_core::TraceFlag grpc_fd_trace(false, "fd_trace"); +grpc_core::DebugOnlyTraceFlag grpc_fd_trace(false, "fd_trace"); grpc_core::DebugOnlyTraceFlag grpc_trace_fd_refcount(false, "fd_refcount"); grpc_core::DebugOnlyTraceFlag grpc_polling_api_trace(false, "polling_api"); diff --git a/src/core/lib/iomgr/ev_posix.h b/src/core/lib/iomgr/ev_posix.h index 30bb5e40faf..84edabce71e 100644 --- a/src/core/lib/iomgr/ev_posix.h +++ b/src/core/lib/iomgr/ev_posix.h @@ -32,8 +32,9 @@ GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_poll_strategy); -extern grpc_core::TraceFlag grpc_fd_trace; /* Disabled by default */ -extern grpc_core::TraceFlag grpc_polling_trace; /* Disabled by default */ +extern grpc_core::DebugOnlyTraceFlag grpc_fd_trace; /* Disabled by default */ +extern grpc_core::DebugOnlyTraceFlag + grpc_polling_trace; /* Disabled by default */ #define GRPC_FD_TRACE(format, ...) \ if (GRPC_TRACE_FLAG_ENABLED(grpc_fd_trace)) { \ diff --git a/src/core/lib/iomgr/ev_windows.cc b/src/core/lib/iomgr/ev_windows.cc index 32c62b7a762..e3f5715a873 100644 --- a/src/core/lib/iomgr/ev_windows.cc +++ b/src/core/lib/iomgr/ev_windows.cc @@ -24,7 +24,7 @@ #include "src/core/lib/debug/trace.h" -grpc_core::TraceFlag grpc_polling_trace(false, - "polling"); /* Disabled by default */ +grpc_core::DebugOnlyTraceFlag grpc_polling_trace( + false, "polling"); /* Disabled by default */ #endif // GRPC_WINSOCK_SOCKET diff --git a/src/core/lib/iomgr/lockfree_event.cc b/src/core/lib/iomgr/lockfree_event.cc index f0c40b4827d..f33485ee59d 100644 --- a/src/core/lib/iomgr/lockfree_event.cc +++ b/src/core/lib/iomgr/lockfree_event.cc @@ -24,7 +24,7 @@ #include "src/core/lib/debug/trace.h" -extern grpc_core::TraceFlag grpc_polling_trace; +extern grpc_core::DebugOnlyTraceFlag grpc_polling_trace; /* 'state' holds the to call when the fd is readable or writable respectively. It can contain one of the following values: From 94e7edad99a0087fd12587b2e8967489ad2db5fa Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 11 Jun 2019 15:07:12 -0700 Subject: [PATCH 0501/1555] Add Delegating Channel --- BUILD | 1 + BUILD.gn | 1 + CMakeLists.txt | 46 ++++++++ Makefile | 53 ++++++++++ build.yaml | 13 +++ gRPC-C++.podspec | 1 + .../grpcpp/impl/codegen/channel_interface.h | 2 + .../grpcpp/impl/codegen/delegating_channel.h | 87 +++++++++++++++ test/cpp/end2end/BUILD | 18 ++++ test/cpp/end2end/delegating_channel_test.cc | 100 ++++++++++++++++++ tools/doxygen/Doxyfile.c++ | 1 + tools/doxygen/Doxyfile.c++.internal | 1 + .../generated/sources_and_headers.json | 20 ++++ tools/run_tests/generated/tests.json | 24 +++++ 14 files changed, 368 insertions(+) create mode 100644 include/grpcpp/impl/codegen/delegating_channel.h create mode 100644 test/cpp/end2end/delegating_channel_test.cc diff --git a/BUILD b/BUILD index e0827d46cb1..e11c6ed1f49 100644 --- a/BUILD +++ b/BUILD @@ -2172,6 +2172,7 @@ grpc_cc_library( "include/grpcpp/impl/codegen/config.h", "include/grpcpp/impl/codegen/core_codegen_interface.h", "include/grpcpp/impl/codegen/create_auth_context.h", + "include/grpcpp/impl/codegen/delegating_channel.h", "include/grpcpp/impl/codegen/grpc_library.h", "include/grpcpp/impl/codegen/intercepted_channel.h", "include/grpcpp/impl/codegen/interceptor.h", diff --git a/BUILD.gn b/BUILD.gn index 258cdc9f873..9761a0683d5 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1065,6 +1065,7 @@ config("grpc_config") { "include/grpcpp/impl/codegen/core_codegen.h", "include/grpcpp/impl/codegen/core_codegen_interface.h", "include/grpcpp/impl/codegen/create_auth_context.h", + "include/grpcpp/impl/codegen/delegating_channel.h", "include/grpcpp/impl/codegen/grpc_library.h", "include/grpcpp/impl/codegen/intercepted_channel.h", "include/grpcpp/impl/codegen/interceptor.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index e9d2168b8de..6e57ce8e08a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -630,6 +630,7 @@ add_dependencies(buildtests_cxx cxx_byte_buffer_test) add_dependencies(buildtests_cxx cxx_slice_test) add_dependencies(buildtests_cxx cxx_string_ref_test) add_dependencies(buildtests_cxx cxx_time_test) +add_dependencies(buildtests_cxx delegating_channel_test) add_dependencies(buildtests_cxx end2end_test) add_dependencies(buildtests_cxx error_details_test) add_dependencies(buildtests_cxx exception_test) @@ -3321,6 +3322,7 @@ foreach(_hdr include/grpcpp/impl/codegen/config.h include/grpcpp/impl/codegen/core_codegen_interface.h include/grpcpp/impl/codegen/create_auth_context.h + include/grpcpp/impl/codegen/delegating_channel.h include/grpcpp/impl/codegen/grpc_library.h include/grpcpp/impl/codegen/intercepted_channel.h include/grpcpp/impl/codegen/interceptor.h @@ -3940,6 +3942,7 @@ foreach(_hdr include/grpcpp/impl/codegen/config.h include/grpcpp/impl/codegen/core_codegen_interface.h include/grpcpp/impl/codegen/create_auth_context.h + include/grpcpp/impl/codegen/delegating_channel.h include/grpcpp/impl/codegen/grpc_library.h include/grpcpp/impl/codegen/intercepted_channel.h include/grpcpp/impl/codegen/interceptor.h @@ -4375,6 +4378,7 @@ foreach(_hdr include/grpcpp/impl/codegen/config.h include/grpcpp/impl/codegen/core_codegen_interface.h include/grpcpp/impl/codegen/create_auth_context.h + include/grpcpp/impl/codegen/delegating_channel.h include/grpcpp/impl/codegen/grpc_library.h include/grpcpp/impl/codegen/intercepted_channel.h include/grpcpp/impl/codegen/interceptor.h @@ -4574,6 +4578,7 @@ foreach(_hdr include/grpcpp/impl/codegen/config.h include/grpcpp/impl/codegen/core_codegen_interface.h include/grpcpp/impl/codegen/create_auth_context.h + include/grpcpp/impl/codegen/delegating_channel.h include/grpcpp/impl/codegen/grpc_library.h include/grpcpp/impl/codegen/intercepted_channel.h include/grpcpp/impl/codegen/interceptor.h @@ -4933,6 +4938,7 @@ foreach(_hdr include/grpcpp/impl/codegen/config.h include/grpcpp/impl/codegen/core_codegen_interface.h include/grpcpp/impl/codegen/create_auth_context.h + include/grpcpp/impl/codegen/delegating_channel.h include/grpcpp/impl/codegen/grpc_library.h include/grpcpp/impl/codegen/intercepted_channel.h include/grpcpp/impl/codegen/interceptor.h @@ -13456,6 +13462,46 @@ target_link_libraries(cxx_time_test ) +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + +add_executable(delegating_channel_test + test/cpp/end2end/delegating_channel_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(delegating_channel_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(delegating_channel_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc++_test_util + grpc_test_util + grpc++ + grpc + gpr + ${_gRPC_GFLAGS_LIBRARIES} +) + + endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index e56c5ec4e47..c652b17da9a 100644 --- a/Makefile +++ b/Makefile @@ -1203,6 +1203,7 @@ cxx_byte_buffer_test: $(BINDIR)/$(CONFIG)/cxx_byte_buffer_test cxx_slice_test: $(BINDIR)/$(CONFIG)/cxx_slice_test cxx_string_ref_test: $(BINDIR)/$(CONFIG)/cxx_string_ref_test cxx_time_test: $(BINDIR)/$(CONFIG)/cxx_time_test +delegating_channel_test: $(BINDIR)/$(CONFIG)/delegating_channel_test end2end_test: $(BINDIR)/$(CONFIG)/end2end_test error_details_test: $(BINDIR)/$(CONFIG)/error_details_test exception_test: $(BINDIR)/$(CONFIG)/exception_test @@ -1685,6 +1686,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/cxx_slice_test \ $(BINDIR)/$(CONFIG)/cxx_string_ref_test \ $(BINDIR)/$(CONFIG)/cxx_time_test \ + $(BINDIR)/$(CONFIG)/delegating_channel_test \ $(BINDIR)/$(CONFIG)/end2end_test \ $(BINDIR)/$(CONFIG)/error_details_test \ $(BINDIR)/$(CONFIG)/exception_test \ @@ -1835,6 +1837,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/cxx_slice_test \ $(BINDIR)/$(CONFIG)/cxx_string_ref_test \ $(BINDIR)/$(CONFIG)/cxx_time_test \ + $(BINDIR)/$(CONFIG)/delegating_channel_test \ $(BINDIR)/$(CONFIG)/end2end_test \ $(BINDIR)/$(CONFIG)/error_details_test \ $(BINDIR)/$(CONFIG)/exception_test \ @@ -2330,6 +2333,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/cxx_string_ref_test || ( echo test cxx_string_ref_test failed ; exit 1 ) $(E) "[RUN] Testing cxx_time_test" $(Q) $(BINDIR)/$(CONFIG)/cxx_time_test || ( echo test cxx_time_test failed ; exit 1 ) + $(E) "[RUN] Testing delegating_channel_test" + $(Q) $(BINDIR)/$(CONFIG)/delegating_channel_test || ( echo test delegating_channel_test failed ; exit 1 ) $(E) "[RUN] Testing end2end_test" $(Q) $(BINDIR)/$(CONFIG)/end2end_test || ( echo test end2end_test failed ; exit 1 ) $(E) "[RUN] Testing error_details_test" @@ -5678,6 +5683,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/config.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \ include/grpcpp/impl/codegen/create_auth_context.h \ + include/grpcpp/impl/codegen/delegating_channel.h \ include/grpcpp/impl/codegen/grpc_library.h \ include/grpcpp/impl/codegen/intercepted_channel.h \ include/grpcpp/impl/codegen/interceptor.h \ @@ -6305,6 +6311,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/config.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \ include/grpcpp/impl/codegen/create_auth_context.h \ + include/grpcpp/impl/codegen/delegating_channel.h \ include/grpcpp/impl/codegen/grpc_library.h \ include/grpcpp/impl/codegen/intercepted_channel.h \ include/grpcpp/impl/codegen/interceptor.h \ @@ -6712,6 +6719,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/config.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \ include/grpcpp/impl/codegen/create_auth_context.h \ + include/grpcpp/impl/codegen/delegating_channel.h \ include/grpcpp/impl/codegen/grpc_library.h \ include/grpcpp/impl/codegen/intercepted_channel.h \ include/grpcpp/impl/codegen/interceptor.h \ @@ -6882,6 +6890,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/config.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \ include/grpcpp/impl/codegen/create_auth_context.h \ + include/grpcpp/impl/codegen/delegating_channel.h \ include/grpcpp/impl/codegen/grpc_library.h \ include/grpcpp/impl/codegen/intercepted_channel.h \ include/grpcpp/impl/codegen/interceptor.h \ @@ -7247,6 +7256,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/config.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \ include/grpcpp/impl/codegen/create_auth_context.h \ + include/grpcpp/impl/codegen/delegating_channel.h \ include/grpcpp/impl/codegen/grpc_library.h \ include/grpcpp/impl/codegen/intercepted_channel.h \ include/grpcpp/impl/codegen/interceptor.h \ @@ -16420,6 +16430,49 @@ endif endif +DELEGATING_CHANNEL_TEST_SRC = \ + test/cpp/end2end/delegating_channel_test.cc \ + +DELEGATING_CHANNEL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(DELEGATING_CHANNEL_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/delegating_channel_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/delegating_channel_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/delegating_channel_test: $(PROTOBUF_DEP) $(DELEGATING_CHANNEL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(DELEGATING_CHANNEL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/delegating_channel_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/cpp/end2end/delegating_channel_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_delegating_channel_test: $(DELEGATING_CHANNEL_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(DELEGATING_CHANNEL_TEST_OBJS:.o=.dep) +endif +endif + + END2END_TEST_SRC = \ test/cpp/end2end/end2end_test.cc \ test/cpp/end2end/interceptors_util.cc \ diff --git a/build.yaml b/build.yaml index 5c085f18787..38406ede17e 100644 --- a/build.yaml +++ b/build.yaml @@ -1268,6 +1268,7 @@ filegroups: - include/grpcpp/impl/codegen/config.h - include/grpcpp/impl/codegen/core_codegen_interface.h - include/grpcpp/impl/codegen/create_auth_context.h + - include/grpcpp/impl/codegen/delegating_channel.h - include/grpcpp/impl/codegen/grpc_library.h - include/grpcpp/impl/codegen/intercepted_channel.h - include/grpcpp/impl/codegen/interceptor.h @@ -4758,6 +4759,18 @@ targets: - grpc - gpr uses_polling: false +- name: delegating_channel_test + gtest: true + build: test + language: c++ + src: + - test/cpp/end2end/delegating_channel_test.cc + deps: + - grpc++_test_util + - grpc_test_util + - grpc++ + - grpc + - gpr - name: end2end_test gtest: true cpu_cost: 0.5 diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 3b463cf7b90..5bce50dd2cd 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -169,6 +169,7 @@ Pod::Spec.new do |s| 'include/grpcpp/impl/codegen/config.h', 'include/grpcpp/impl/codegen/core_codegen_interface.h', 'include/grpcpp/impl/codegen/create_auth_context.h', + 'include/grpcpp/impl/codegen/delegating_channel.h', 'include/grpcpp/impl/codegen/grpc_library.h', 'include/grpcpp/impl/codegen/intercepted_channel.h', 'include/grpcpp/impl/codegen/interceptor.h', diff --git a/include/grpcpp/impl/codegen/channel_interface.h b/include/grpcpp/impl/codegen/channel_interface.h index 9df233b5500..5c977312dd6 100644 --- a/include/grpcpp/impl/codegen/channel_interface.h +++ b/include/grpcpp/impl/codegen/channel_interface.h @@ -62,6 +62,7 @@ class ClientCallbackReaderFactory; template class ClientCallbackWriterFactory; class ClientCallbackUnaryFactory; +class DelegatingChannel; class InterceptedChannel; } // namespace internal @@ -127,6 +128,7 @@ class ChannelInterface { template friend class ::grpc::internal::CallbackUnaryCallImpl; friend class ::grpc::internal::RpcMethod; + friend class ::grpc::internal::DelegatingChannel; friend class ::grpc::internal::InterceptedChannel; virtual internal::Call CreateCall(const internal::RpcMethod& method, ClientContext* context, diff --git a/include/grpcpp/impl/codegen/delegating_channel.h b/include/grpcpp/impl/codegen/delegating_channel.h new file mode 100644 index 00000000000..0853ad3b5de --- /dev/null +++ b/include/grpcpp/impl/codegen/delegating_channel.h @@ -0,0 +1,87 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H +#define GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H + +namespace grpc { +namespace internal { + +class DelegatingChannel : public ::grpc::ChannelInterface { + public: + virtual ~DelegatingChannel() {} + + DelegatingChannel(std::shared_ptr<::grpc::ChannelInterface> delegate_channel) + : delegate_channel_(delegate_channel) {} + + grpc_connectivity_state GetState(bool try_to_connect) override { + delegate_channel()->GetState(try_to_connect); + } + + std::shared_ptr<::grpc::ChannelInterface> delegate_channel() { + return delegate_channel_; + } + + private: + internal::Call CreateCall(const internal::RpcMethod& method, + ClientContext* context, + ::grpc_impl::CompletionQueue* cq) override { + return delegate_channel()->CreateCall(method, context, cq); + } + + void PerformOpsOnCall(internal::CallOpSetInterface* ops, + internal::Call* call) override { + delegate_channel()->PerformOpsOnCall(ops, call); + } + + void* RegisterMethod(const char* method) override { + return delegate_channel()->RegisterMethod(method); + } + + void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline, + ::grpc_impl::CompletionQueue* cq, + void* tag) override { + delegate_channel()->NotifyOnStateChangeImpl(last_observed, deadline, cq, + tag); + } + + bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline) override { + return delegate_channel()->WaitForStateChangeImpl(last_observed, deadline); + } + + internal::Call CreateCallInternal(const internal::RpcMethod& method, + ClientContext* context, + ::grpc_impl::CompletionQueue* cq, + size_t interceptor_pos) override { + return delegate_channel()->CreateCallInternal(method, context, cq, + interceptor_pos); + } + + ::grpc_impl::CompletionQueue* CallbackCQ() override { + return delegate_channel()->CallbackCQ(); + } + + std::shared_ptr<::grpc::ChannelInterface> delegate_channel_; +}; + +} // namespace internal +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H \ No newline at end of file diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD index d229cc33034..cc407190c6a 100644 --- a/test/cpp/end2end/BUILD +++ b/test/cpp/end2end/BUILD @@ -165,6 +165,24 @@ grpc_cc_test( ], ) +grpc_cc_test( + name = "delegating_channel_test", + srcs = ["delegating_channel_test.cc"], + external_deps = [ + "gtest", + ], + deps = [ + ":test_service_impl", + "//:gpr", + "//:grpc", + "//:grpc++", + "//src/proto/grpc/testing:echo_messages_proto", + "//src/proto/grpc/testing:echo_proto", + "//test/core/util:grpc_test_util", + "//test/cpp/util:test_util", + ], +) + grpc_cc_test( name = "client_interceptors_end2end_test", srcs = ["client_interceptors_end2end_test.cc"], diff --git a/test/cpp/end2end/delegating_channel_test.cc b/test/cpp/end2end/delegating_channel_test.cc new file mode 100644 index 00000000000..22e261d535e --- /dev/null +++ b/test/cpp/end2end/delegating_channel_test.cc @@ -0,0 +1,100 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "src/proto/grpc/testing/echo.grpc.pb.h" +#include "test/core/util/port.h" +#include "test/core/util/test_config.h" +#include "test/cpp/end2end/test_service_impl.h" +#include "test/cpp/util/byte_buffer_proto_helper.h" +#include "test/cpp/util/string_ref_helper.h" + +#include + +namespace grpc { +namespace testing { +namespace { + +class TestChannel : public internal::DelegatingChannel { + public: + TestChannel(std::shared_ptr delegate_channel) + : internal::DelegatingChannel(delegate_channel) {} + // Always returns GRPC_CHANNEL_READY + grpc_connectivity_state GetState(bool try_to_connect) override { + return GRPC_CHANNEL_READY; + } +}; + +class DelegatingChannelTest : public ::testing::Test { + protected: + DelegatingChannelTest() { + int port = grpc_pick_unused_port_or_die(); + ServerBuilder builder; + server_address_ = "localhost:" + std::to_string(port); + builder.AddListeningPort(server_address_, InsecureServerCredentials()); + builder.RegisterService(&service_); + server_ = builder.BuildAndStart(); + } + + ~DelegatingChannelTest() { server_->Shutdown(); } + + std::string server_address_; + TestServiceImpl service_; + std::unique_ptr server_; +}; + +TEST_F(DelegatingChannelTest, SimpleTest) { + auto channel = CreateChannel(server_address_, InsecureChannelCredentials()); + std::shared_ptr test_channel = + std::make_shared(channel); + // gRPC channel should be in idle state at this point but our test channel + // will return ready. + EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_IDLE); + EXPECT_EQ(test_channel->GetState(false), GRPC_CHANNEL_READY); + auto stub = grpc::testing::EchoTestService::NewStub(test_channel); + ClientContext ctx; + EchoRequest req; + req.set_message("Hello"); + EchoResponse resp; + Status s = stub->Echo(&ctx, req, &resp); + EXPECT_EQ(s.ok(), true); + EXPECT_EQ(resp.message(), "Hello"); +} + +} // namespace +} // namespace testing +} // namespace grpc + +int main(int argc, char** argv) { + grpc::testing::TestEnvironment env(argc, argv); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 913d7be993b..bbd5f11c697 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -966,6 +966,7 @@ include/grpcpp/impl/codegen/config_protobuf.h \ include/grpcpp/impl/codegen/core_codegen.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \ include/grpcpp/impl/codegen/create_auth_context.h \ +include/grpcpp/impl/codegen/delegating_channel.h \ include/grpcpp/impl/codegen/grpc_library.h \ include/grpcpp/impl/codegen/intercepted_channel.h \ include/grpcpp/impl/codegen/interceptor.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 8b664d8ac01..77776770ce0 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -968,6 +968,7 @@ include/grpcpp/impl/codegen/core_codegen.h \ include/grpcpp/impl/codegen/core_codegen.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \ include/grpcpp/impl/codegen/create_auth_context.h \ +include/grpcpp/impl/codegen/delegating_channel.h \ include/grpcpp/impl/codegen/grpc_library.h \ include/grpcpp/impl/codegen/intercepted_channel.h \ include/grpcpp/impl/codegen/interceptor.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index a479a00509a..32bb35ae1d0 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -3617,6 +3617,24 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "grpc", + "grpc++", + "grpc++_test_util", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "delegating_channel_test", + "src": [ + "test/cpp/end2end/delegating_channel_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", @@ -10138,6 +10156,7 @@ "include/grpcpp/impl/codegen/config.h", "include/grpcpp/impl/codegen/core_codegen_interface.h", "include/grpcpp/impl/codegen/create_auth_context.h", + "include/grpcpp/impl/codegen/delegating_channel.h", "include/grpcpp/impl/codegen/grpc_library.h", "include/grpcpp/impl/codegen/intercepted_channel.h", "include/grpcpp/impl/codegen/interceptor.h", @@ -10216,6 +10235,7 @@ "include/grpcpp/impl/codegen/config.h", "include/grpcpp/impl/codegen/core_codegen_interface.h", "include/grpcpp/impl/codegen/create_auth_context.h", + "include/grpcpp/impl/codegen/delegating_channel.h", "include/grpcpp/impl/codegen/grpc_library.h", "include/grpcpp/impl/codegen/intercepted_channel.h", "include/grpcpp/impl/codegen/interceptor.h", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 473e2e26c3a..c5531517257 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -4423,6 +4423,30 @@ ], "uses_polling": false }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "delegating_channel_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": true + }, { "args": [], "benchmark": false, From a0adb5003ce6066b795009cc9f2d3abaca9180b7 Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 11 Jun 2019 15:47:54 -0700 Subject: [PATCH 0502/1555] Feedbackg --- src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml | 11 +++++++++++ src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml b/src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml index 66862582dad..dd220bf564d 100644 --- a/src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml +++ b/src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml @@ -26,5 +26,16 @@ + + + + + + + + diff --git a/src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets b/src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets index 493212fe7e5..bc78e340e33 100644 --- a/src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets +++ b/src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets @@ -38,11 +38,13 @@ <_GrpcOutputOptions>%(Protobuf_Compile._GrpcOutputOptions);no_server - <_GrpcOutputOptions Condition=" '%(Protobuf_Compile.ClientType)' == 'LiteClient' ">%(Protobuf_Compile._GrpcOutputOptions);lite_client <_GrpcOutputOptions>%(Protobuf_Compile._GrpcOutputOptions);no_client + + <_GrpcOutputOptions Condition=" '%(Protobuf_Compile.ClientBaseType)' == 'LiteClientBase' ">%(Protobuf_Compile._GrpcOutputOptions);lite_client + From 63e2c91efe31802748219cc903218a49f54a9214 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Wed, 12 Jun 2019 01:32:45 +0200 Subject: [PATCH 0503/1555] New version of upb. --- bazel/grpc_deps.bzl | 6 +++--- third_party/upb | 2 +- tools/run_tests/sanity/check_submodules.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index dc7294de5cd..da96b8118b2 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -212,9 +212,9 @@ def grpc_deps(): if "upb" not in native.existing_rules(): http_archive( name = "upb", - sha256 = "34136146171af0214bc5578bd22adace4c5a98fd00cff758eb57b7151cd16b51", - strip_prefix = "upb-d16bf99ac4658793748cda3251226059892b3b7b", - url = "https://github.com/google/upb/archive/d16bf99ac4658793748cda3251226059892b3b7b.tar.gz", + sha256 = "3aa0c5aff130d97618fe137e3e76603b2381e3698cd7ca7a4a54327f7c44c69c", + strip_prefix = "upb-ef6ce94bfecf36fb57acd8a8b470c0560959f063", + url = "https://github.com/google/upb/archive/ef6ce94bfecf36fb57acd8a8b470c0560959f063.tar.gz", ) if "data_plane_api" not in native.existing_rules(): http_archive( diff --git a/third_party/upb b/third_party/upb index fa88c6017dd..ef6ce94bfec 160000 --- a/third_party/upb +++ b/third_party/upb @@ -1 +1 @@ -Subproject commit fa88c6017ddb490aa78c57bea682193f533ed69a +Subproject commit ef6ce94bfecf36fb57acd8a8b470c0560959f063 diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index b15b8d3b077..9c49d635959 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -40,7 +40,7 @@ cat << EOF | awk '{ print $1 }' | sort > "$want_submodules" 9245d481eb3e890f708ff2d7dadf2a10c04748ba third_party/libcxxabi (heads/release_60) 582743bf40c5d3639a70f98f183914a2c0cd0680 third_party/protobuf (v3.7.0-rc.2-20-g582743bf) e143189bf6f37b3957fb31743df6a1bcf4a8c685 third_party/protoc-gen-validate (v0.0.10) - fa88c6017ddb490aa78c57bea682193f533ed69a third_party/upb (heads/master) + ef6ce94bfecf36fb57acd8a8b470c0560959f063 third_party/upb (heads/master) cacf7f1d4e3d44d871b605da3b647f07d718623f third_party/zlib (v1.2.11) EOF From 8438cc804ff44dae734e113bb2e59539a9d8ac8a Mon Sep 17 00:00:00 2001 From: Qiancheng Zhao Date: Tue, 11 Jun 2019 17:00:32 -0700 Subject: [PATCH 0504/1555] Added debug and non-debug tracers for subchannel. --- doc/environment_variables.md | 2 ++ src/core/ext/filters/client_channel/subchannel.cc | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/environment_variables.md b/doc/environment_variables.md index 778560d4273..6782f1ee6a6 100644 --- a/doc/environment_variables.md +++ b/doc/environment_variables.md @@ -74,6 +74,7 @@ some configuration as environment variables that can be set. - queue_pluck - server_channel - lightweight trace of significant server channel events - secure_endpoint - traces bytes flowing through encrypted channels + - subchannel - traces the connectivity state of subchannel - timer - timers (alarms) in the grpc internals - timer_check - more detailed trace of timer logic in grpc internals - transport_security - traces metadata about secure channel establishment @@ -89,6 +90,7 @@ some configuration as environment variables that can be set. - pending_tags - traces still-in-progress tags on completion queues - polling - traces the selected polling engine - polling_api - traces the api calls to polling engine + - subchannel_refcount - queue_refcount - error_refcount - stream_refcount diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index cc3457e1e96..dd16eded826 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -75,6 +75,9 @@ namespace grpc_core { +TraceFlag grpc_trace_subchannel(false, "subchannel"); +DebugOnlyTraceFlag grpc_trace_subchannel_refcount(false, "subchannel_refcount"); + // // ConnectedSubchannel // @@ -83,7 +86,7 @@ ConnectedSubchannel::ConnectedSubchannel( grpc_channel_stack* channel_stack, const grpc_channel_args* args, RefCountedPtr channelz_subchannel, intptr_t socket_uuid) - : ConnectedSubchannelInterface(&grpc_trace_stream_refcount), + : ConnectedSubchannelInterface(&grpc_trace_subchannel_refcount), channel_stack_(channel_stack), args_(grpc_channel_args_copy(args)), channelz_subchannel_(std::move(channelz_subchannel)), @@ -332,7 +335,7 @@ class Subchannel::ConnectedSubchannelStateWatcher { case GRPC_CHANNEL_TRANSIENT_FAILURE: case GRPC_CHANNEL_SHUTDOWN: { if (!c->disconnected_ && c->connected_subchannel_ != nullptr) { - if (grpc_trace_stream_refcount.enabled()) { + if (grpc_trace_subchannel.enabled()) { gpr_log(GPR_INFO, "Connected subchannel %p of subchannel %p has gone into " "%s. Attempting to reconnect.", @@ -1106,7 +1109,7 @@ gpr_atm Subchannel::RefMutate( gpr_atm old_val = barrier ? gpr_atm_full_fetch_add(&ref_pair_, delta) : gpr_atm_no_barrier_fetch_add(&ref_pair_, delta); #ifndef NDEBUG - if (grpc_trace_stream_refcount.enabled()) { + if (grpc_trace_subchannel_refcount.enabled()) { gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "SUBCHANNEL: %p %12s 0x%" PRIxPTR " -> 0x%" PRIxPTR " [%s]", this, purpose, old_val, old_val + delta, reason); From 84d75d454ee2a0a7585281e56035022770975ccb Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 11 Jun 2019 19:08:50 -0700 Subject: [PATCH 0505/1555] Move error ref to the the closure function instead of an internal function --- src/core/lib/security/transport/security_handshaker.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/security/transport/security_handshaker.cc b/src/core/lib/security/transport/security_handshaker.cc index fdc64727b96..3ad04774837 100644 --- a/src/core/lib/security/transport/security_handshaker.cc +++ b/src/core/lib/security/transport/security_handshaker.cc @@ -195,7 +195,7 @@ void SecurityHandshaker::HandshakeFailedLocked(grpc_error* error) { void SecurityHandshaker::OnPeerCheckedInner(grpc_error* error) { MutexLock lock(&mu_); if (error != GRPC_ERROR_NONE || is_shutdown_) { - HandshakeFailedLocked(GRPC_ERROR_REF(error)); + HandshakeFailedLocked(error); return; } // Create zero-copy frame protector, if implemented. @@ -255,7 +255,7 @@ void SecurityHandshaker::OnPeerCheckedInner(grpc_error* error) { void SecurityHandshaker::OnPeerCheckedFn(void* arg, grpc_error* error) { RefCountedPtr(static_cast(arg)) - ->OnPeerCheckedInner(error); + ->OnPeerCheckedInner(GRPC_ERROR_REF(error)); } grpc_error* SecurityHandshaker::CheckPeerLocked() { From 7767fbe683fc95f562a6ae1a22c67828e80afebe Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 12 Jun 2019 06:44:36 -0700 Subject: [PATCH 0506/1555] Hide ConnectedSubchannel from LB policy API. --- .../filters/client_channel/client_channel.cc | 420 +++++++++++++----- .../ext/filters/client_channel/lb_policy.h | 2 +- .../client_channel/lb_policy/grpclb/grpclb.cc | 9 +- .../lb_policy/pick_first/pick_first.cc | 30 +- .../lb_policy/round_robin/round_robin.cc | 20 +- .../lb_policy/subchannel_list.h | 126 ++---- .../client_channel/lb_policy/xds/xds.cc | 2 +- .../ext/filters/client_channel/subchannel.cc | 23 +- .../ext/filters/client_channel/subchannel.h | 71 ++- .../client_channel/subchannel_interface.h | 45 +- src/core/lib/gprpp/map.h | 28 ++ src/core/lib/transport/metadata.cc | 5 + test/core/gprpp/map_test.cc | 29 ++ test/core/util/test_lb_policies.cc | 2 +- 14 files changed, 514 insertions(+), 298 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 81562ab2107..19cceb6bf4f 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -147,6 +147,9 @@ class ChannelData { return service_config_; } + RefCountedPtr GetConnectedSubchannelInDataPlane( + SubchannelInterface* subchannel) const; + grpc_connectivity_state CheckConnectivityState(bool try_to_connect); void AddExternalConnectivityWatcher(grpc_polling_entity pollent, grpc_connectivity_state* state, @@ -161,9 +164,9 @@ class ChannelData { } private: + class SubchannelWrapper; class ConnectivityStateAndPickerSetter; class ServiceConfigSetter; - class GrpcSubchannel; class ClientChannelControlHelper; class ExternalConnectivityWatcher { @@ -262,7 +265,14 @@ class ChannelData { UniquePtr health_check_service_name_; RefCountedPtr saved_service_config_; bool received_first_resolver_result_ = false; + // The number of SubchannelWrapper instances referencing a given Subchannel. Map subchannel_refcount_map_; + // Pending ConnectedSubchannel updates for each SubchannelWrapper. + // Updates are queued here in the control plane combiner and then applied + // in the data plane combiner when the picker is updated. + Map, RefCountedPtr, + RefCountedPtrLess> + pending_subchannel_updates_; // // Fields accessed from both data plane and control plane combiners. @@ -706,6 +716,247 @@ class CallData { grpc_metadata_batch send_trailing_metadata_; }; +// +// ChannelData::SubchannelWrapper +// + +// This class is a wrapper for Subchannel that hides details of the +// channel's implementation (such as the health check service name and +// connected subchannel) from the LB policy API. +// +// Note that no synchronization is needed here, because even if the +// underlying subchannel is shared between channels, this wrapper will only +// be used within one channel, so it will always be synchronized by the +// control plane combiner. +class ChannelData::SubchannelWrapper : public SubchannelInterface { + public: + SubchannelWrapper(ChannelData* chand, Subchannel* subchannel, + UniquePtr health_check_service_name) + : SubchannelInterface(&grpc_client_channel_routing_trace), + chand_(chand), + subchannel_(subchannel), + health_check_service_name_(std::move(health_check_service_name)) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { + gpr_log(GPR_INFO, + "chand=%p: creating subchannel wrapper %p for subchannel %p", + chand, this, subchannel_); + } + GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "SubchannelWrapper"); + auto* subchannel_node = subchannel_->channelz_node(); + if (subchannel_node != nullptr) { + intptr_t subchannel_uuid = subchannel_node->uuid(); + auto it = chand_->subchannel_refcount_map_.find(subchannel_); + if (it == chand_->subchannel_refcount_map_.end()) { + chand_->channelz_node_->AddChildSubchannel(subchannel_uuid); + it = chand_->subchannel_refcount_map_.emplace(subchannel_, 0).first; + } + ++it->second; + } + } + + ~SubchannelWrapper() { + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { + gpr_log(GPR_INFO, + "chand=%p: destroying subchannel wrapper %p for subchannel %p", + chand_, this, subchannel_); + } + auto* subchannel_node = subchannel_->channelz_node(); + if (subchannel_node != nullptr) { + intptr_t subchannel_uuid = subchannel_node->uuid(); + auto it = chand_->subchannel_refcount_map_.find(subchannel_); + GPR_ASSERT(it != chand_->subchannel_refcount_map_.end()); + --it->second; + if (it->second == 0) { + chand_->channelz_node_->RemoveChildSubchannel(subchannel_uuid); + chand_->subchannel_refcount_map_.erase(it); + } + } + GRPC_SUBCHANNEL_UNREF(subchannel_, "unref from LB"); + GRPC_CHANNEL_STACK_UNREF(chand_->owning_stack_, "SubchannelWrapper"); + } + + grpc_connectivity_state CheckConnectivityState() override { + RefCountedPtr connected_subchannel; + grpc_connectivity_state connectivity_state = + subchannel_->CheckConnectivityState(health_check_service_name_.get(), + &connected_subchannel); + MaybeUpdateConnectedSubchannel(std::move(connected_subchannel)); + return connectivity_state; + } + + void WatchConnectivityState( + grpc_connectivity_state initial_state, + UniquePtr watcher) override { + auto& watcher_wrapper = watcher_map_[watcher.get()]; + GPR_ASSERT(watcher_wrapper == nullptr); + watcher_wrapper = New( + std::move(watcher), Ref(DEBUG_LOCATION, "WatcherWrapper")); + subchannel_->WatchConnectivityState( + initial_state, + UniquePtr(gpr_strdup(health_check_service_name_.get())), + OrphanablePtr( + watcher_wrapper)); + } + + void CancelConnectivityStateWatch( + ConnectivityStateWatcherInterface* watcher) override { + auto it = watcher_map_.find(watcher); + GPR_ASSERT(it != watcher_map_.end()); + subchannel_->CancelConnectivityStateWatch(health_check_service_name_.get(), + it->second); + watcher_map_.erase(it); + } + + void AttemptToConnect() override { subchannel_->AttemptToConnect(); } + + void ResetBackoff() override { subchannel_->ResetBackoff(); } + + const grpc_channel_args* channel_args() override { + return subchannel_->channel_args(); + } + + // Caller must be holding the control-plane combiner. + ConnectedSubchannel* connected_subchannel() const { + return connected_subchannel_.get(); + } + + // Caller must be holding the data-plane combiner. + ConnectedSubchannel* connected_subchannel_in_data_plane() const { + return connected_subchannel_in_data_plane_.get(); + } + void set_connected_subchannel_in_data_plane( + RefCountedPtr connected_subchannel) { + connected_subchannel_in_data_plane_ = std::move(connected_subchannel); + } + + private: + // Subchannel and SubchannelInterface have different interfaces for + // their respective ConnectivityStateWatcherInterface classes. + // The one in Subchannel updates the ConnectedSubchannel along with + // the state, whereas the one in SubchannelInterface does not expose + // the ConnectedSubchannel. + // + // This wrapper provides a bridge between the two. It implements + // Subchannel::ConnectivityStateWatcherInterface and wraps + // the instance of SubchannelInterface::ConnectivityStateWatcherInterface + // that was passed in by the LB policy. We pass an instance of this + // class to the underlying Subchannel, and when we get updates from + // the subchannel, we pass those on to the wrapped watcher to return + // the update to the LB policy. This allows us to set the connected + // subchannel before passing the result back to the LB policy. + class WatcherWrapper : public Subchannel::ConnectivityStateWatcherInterface { + public: + WatcherWrapper( + UniquePtr + watcher, + RefCountedPtr parent) + : watcher_(std::move(watcher)), parent_(std::move(parent)) {} + + ~WatcherWrapper() { parent_.reset(DEBUG_LOCATION, "WatcherWrapper"); } + + void Orphan() override { Unref(); } + + void OnConnectivityStateChange( + grpc_connectivity_state new_state, + RefCountedPtr connected_subchannel) override { + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { + gpr_log(GPR_INFO, + "chand=%p: connectivity change for subchannel wrapper %p " + "subchannel %p (connected_subchannel=%p state=%s); " + "hopping into combiner", + parent_->chand_, parent_.get(), parent_->subchannel_, + connected_subchannel.get(), + grpc_connectivity_state_name(new_state)); + } + // Will delete itself. + New(Ref(), new_state, std::move(connected_subchannel)); + } + + grpc_pollset_set* interested_parties() override { + return watcher_->interested_parties(); + } + + private: + class Updater { + public: + Updater(RefCountedPtr parent, + grpc_connectivity_state new_state, + RefCountedPtr connected_subchannel) + : parent_(std::move(parent)), + state_(new_state), + connected_subchannel_(std::move(connected_subchannel)) { + GRPC_CLOSURE_INIT( + &closure_, ApplyUpdateInControlPlaneCombiner, this, + grpc_combiner_scheduler(parent_->parent_->chand_->combiner_)); + GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE); + } + + private: + static void ApplyUpdateInControlPlaneCombiner(void* arg, + grpc_error* error) { + Updater* self = static_cast(arg); + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { + gpr_log(GPR_INFO, + "chand=%p: processing connectivity change in combiner " + "for subchannel wrapper %p subchannel %p " + "(connected_subchannel=%p state=%s)", + self->parent_->parent_->chand_, self->parent_->parent_.get(), + self->parent_->parent_->subchannel_, + self->connected_subchannel_.get(), + grpc_connectivity_state_name(self->state_)); + } + self->parent_->parent_->MaybeUpdateConnectedSubchannel( + std::move(self->connected_subchannel_)); + self->parent_->watcher_->OnConnectivityStateChange(self->state_); + Delete(self); + } + + RefCountedPtr parent_; + grpc_connectivity_state state_; + RefCountedPtr connected_subchannel_; + grpc_closure closure_; + }; + + UniquePtr watcher_; + RefCountedPtr parent_; + }; + + void MaybeUpdateConnectedSubchannel( + RefCountedPtr connected_subchannel) { + // Update the connected subchannel only if the channel is not shutting + // down. This is because once the channel is shutting down, we + // ignore picker updates from the LB policy, which means that + // ConnectivityStateAndPickerSetter will never process the entries + // in chand_->pending_subchannel_updates_. So we don't want to add + // entries there that will never be processed, since that would + // leave dangling refs to the channel and prevent its destruction. + grpc_error* disconnect_error = chand_->disconnect_error(); + if (disconnect_error != GRPC_ERROR_NONE) return; + // Not shutting down, so do the update. + if (connected_subchannel_ != connected_subchannel) { + connected_subchannel_ = std::move(connected_subchannel); + // Record the new connected subchannel so that it can be updated + // in the data plane combiner the next time the picker is updated. + chand_->pending_subchannel_updates_[Ref( + DEBUG_LOCATION, "ConnectedSubchannelUpdate")] = connected_subchannel_; + } + } + + ChannelData* chand_; + Subchannel* subchannel_; + UniquePtr health_check_service_name_; + // Maps from the address of the watcher passed to us by the LB policy + // to the address of the WrapperWatcher that we passed to the underlying + // subchannel. This is needed so that when the LB policy calls + // CancelConnectivityStateWatch() with its watcher, we know the + // corresponding WrapperWatcher to cancel on the underlying subchannel. + Map watcher_map_; + // To be accessed only in the control plane combiner. + RefCountedPtr connected_subchannel_; + // To be accessed only in the data plane combiner. + RefCountedPtr connected_subchannel_in_data_plane_; +}; + // // ChannelData::ConnectivityStateAndPickerSetter // @@ -729,10 +980,13 @@ class ChannelData::ConnectivityStateAndPickerSetter { grpc_slice_from_static_string( GetChannelConnectivityStateChangeString(state))); } + // Grab any pending subchannel updates. + pending_subchannel_updates_ = + std::move(chand_->pending_subchannel_updates_); // Bounce into the data plane combiner to reset the picker. GRPC_CHANNEL_STACK_REF(chand->owning_stack_, "ConnectivityStateAndPickerSetter"); - GRPC_CLOSURE_INIT(&closure_, SetPicker, this, + GRPC_CLOSURE_INIT(&closure_, SetPickerInDataPlane, this, grpc_combiner_scheduler(chand->data_plane_combiner_)); GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE); } @@ -755,16 +1009,38 @@ class ChannelData::ConnectivityStateAndPickerSetter { GPR_UNREACHABLE_CODE(return "UNKNOWN"); } - static void SetPicker(void* arg, grpc_error* ignored) { + static void SetPickerInDataPlane(void* arg, grpc_error* ignored) { auto* self = static_cast(arg); - // Update picker. - self->chand_->picker_ = std::move(self->picker_); + // Handle subchannel updates. + for (auto& p : self->pending_subchannel_updates_) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { + gpr_log(GPR_INFO, + "chand=%p: updating subchannel wrapper %p data plane " + "connected_subchannel to %p", + self->chand_, p.first.get(), p.second.get()); + } + p.first->set_connected_subchannel_in_data_plane(std::move(p.second)); + } + // Swap out the picker. We hang on to the old picker so that it can + // be deleted in the control-plane combiner, since that's where we need + // to unref the subchannel wrappers that are reffed by the picker. + self->picker_.swap(self->chand_->picker_); // Re-process queued picks. for (QueuedPick* pick = self->chand_->queued_picks_; pick != nullptr; pick = pick->next) { CallData::StartPickLocked(pick->elem, GRPC_ERROR_NONE); } - // Clean up. + // Pop back into the control plane combiner to delete ourself, so + // that we make sure to unref subchannel wrappers there. This + // includes both the ones reffed by the old picker (now stored in + // self->picker_) and the ones in self->pending_subchannel_updates_. + GRPC_CLOSURE_INIT(&self->closure_, CleanUpInControlPlane, self, + grpc_combiner_scheduler(self->chand_->combiner_)); + GRPC_CLOSURE_SCHED(&self->closure_, GRPC_ERROR_NONE); + } + + static void CleanUpInControlPlane(void* arg, grpc_error* ignored) { + auto* self = static_cast(arg); GRPC_CHANNEL_STACK_UNREF(self->chand_->owning_stack_, "ConnectivityStateAndPickerSetter"); Delete(self); @@ -772,6 +1048,9 @@ class ChannelData::ConnectivityStateAndPickerSetter { ChannelData* chand_; UniquePtr picker_; + Map, RefCountedPtr, + RefCountedPtrLess> + pending_subchannel_updates_; grpc_closure closure_; }; @@ -946,89 +1225,6 @@ void ChannelData::ExternalConnectivityWatcher::WatchConnectivityStateLocked( &self->chand_->state_tracker_, self->state_, &self->my_closure_); } -// -// ChannelData::GrpcSubchannel -// - -// This class is a wrapper for Subchannel that hides details of the -// channel's implementation (such as the health check service name) from -// the LB policy API. -// -// Note that no synchronization is needed here, because even if the -// underlying subchannel is shared between channels, this wrapper will only -// be used within one channel, so it will always be synchronized by the -// control plane combiner. -class ChannelData::GrpcSubchannel : public SubchannelInterface { - public: - GrpcSubchannel(ChannelData* chand, Subchannel* subchannel, - UniquePtr health_check_service_name) - : chand_(chand), - subchannel_(subchannel), - health_check_service_name_(std::move(health_check_service_name)) { - GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "GrpcSubchannel"); - auto* subchannel_node = subchannel_->channelz_node(); - if (subchannel_node != nullptr) { - intptr_t subchannel_uuid = subchannel_node->uuid(); - auto it = chand_->subchannel_refcount_map_.find(subchannel_); - if (it == chand_->subchannel_refcount_map_.end()) { - chand_->channelz_node_->AddChildSubchannel(subchannel_uuid); - it = chand_->subchannel_refcount_map_.emplace(subchannel_, 0).first; - } - ++it->second; - } - } - - ~GrpcSubchannel() { - auto* subchannel_node = subchannel_->channelz_node(); - if (subchannel_node != nullptr) { - intptr_t subchannel_uuid = subchannel_node->uuid(); - auto it = chand_->subchannel_refcount_map_.find(subchannel_); - GPR_ASSERT(it != chand_->subchannel_refcount_map_.end()); - --it->second; - if (it->second == 0) { - chand_->channelz_node_->RemoveChildSubchannel(subchannel_uuid); - chand_->subchannel_refcount_map_.erase(it); - } - } - GRPC_SUBCHANNEL_UNREF(subchannel_, "unref from LB"); - GRPC_CHANNEL_STACK_UNREF(chand_->owning_stack_, "GrpcSubchannel"); - } - - grpc_connectivity_state CheckConnectivityState( - RefCountedPtr* connected_subchannel) - override { - RefCountedPtr tmp; - auto retval = subchannel_->CheckConnectivityState( - health_check_service_name_.get(), &tmp); - *connected_subchannel = std::move(tmp); - return retval; - } - - void WatchConnectivityState( - grpc_connectivity_state initial_state, - UniquePtr watcher) override { - subchannel_->WatchConnectivityState( - initial_state, - UniquePtr(gpr_strdup(health_check_service_name_.get())), - std::move(watcher)); - } - - void CancelConnectivityStateWatch( - ConnectivityStateWatcher* watcher) override { - subchannel_->CancelConnectivityStateWatch(health_check_service_name_.get(), - watcher); - } - - void AttemptToConnect() override { subchannel_->AttemptToConnect(); } - - void ResetBackoff() override { subchannel_->ResetBackoff(); } - - private: - ChannelData* chand_; - Subchannel* subchannel_; - UniquePtr health_check_service_name_; -}; - // // ChannelData::ClientChannelControlHelper // @@ -1066,8 +1262,8 @@ class ChannelData::ClientChannelControlHelper chand_->client_channel_factory_->CreateSubchannel(new_args); grpc_channel_args_destroy(new_args); if (subchannel == nullptr) return nullptr; - return MakeRefCounted(chand_, subchannel, - std::move(health_check_service_name)); + return MakeRefCounted( + chand_, subchannel, std::move(health_check_service_name)); } grpc_channel* CreateChannel(const char* target, @@ -1078,8 +1274,7 @@ class ChannelData::ClientChannelControlHelper void UpdateState( grpc_connectivity_state state, UniquePtr picker) override { - grpc_error* disconnect_error = - chand_->disconnect_error_.Load(MemoryOrder::ACQUIRE); + grpc_error* disconnect_error = chand_->disconnect_error(); if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { const char* extra = disconnect_error == GRPC_ERROR_NONE ? "" @@ -1444,9 +1639,13 @@ grpc_error* ChannelData::DoPingLocked(grpc_transport_op* op) { } LoadBalancingPolicy::PickResult result = picker_->Pick(LoadBalancingPolicy::PickArgs()); - if (result.connected_subchannel != nullptr) { - ConnectedSubchannel* connected_subchannel = - static_cast(result.connected_subchannel.get()); + ConnectedSubchannel* connected_subchannel = nullptr; + if (result.subchannel != nullptr) { + SubchannelWrapper* subchannel = + static_cast(result.subchannel.get()); + connected_subchannel = subchannel->connected_subchannel(); + } + if (connected_subchannel != nullptr) { connected_subchannel->Ping(op->send_ping.on_initiate, op->send_ping.on_ack); } else { if (result.error == GRPC_ERROR_NONE) { @@ -1489,6 +1688,10 @@ void ChannelData::StartTransportOpLocked(void* arg, grpc_error* ignored) { } // Disconnect. if (op->disconnect_with_error != GRPC_ERROR_NONE) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) { + gpr_log(GPR_INFO, "chand=%p: channel shut down from API: %s", chand, + grpc_error_string(op->disconnect_with_error)); + } grpc_error* error = GRPC_ERROR_NONE; GPR_ASSERT(chand->disconnect_error_.CompareExchangeStrong( &error, op->disconnect_with_error, MemoryOrder::ACQ_REL, @@ -1563,6 +1766,17 @@ void ChannelData::RemoveQueuedPick(QueuedPick* to_remove, } } +RefCountedPtr +ChannelData::GetConnectedSubchannelInDataPlane( + SubchannelInterface* subchannel) const { + SubchannelWrapper* subchannel_wrapper = + static_cast(subchannel); + ConnectedSubchannel* connected_subchannel = + subchannel_wrapper->connected_subchannel_in_data_plane(); + if (connected_subchannel == nullptr) return nullptr; + return connected_subchannel->Ref(); +} + void ChannelData::TryToConnectLocked(void* arg, grpc_error* error_ignored) { auto* chand = static_cast(arg); if (chand->resolving_lb_policy_ != nullptr) { @@ -3490,10 +3704,9 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { auto result = chand->picker()->Pick(pick_args); if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { gpr_log(GPR_INFO, - "chand=%p calld=%p: LB pick returned %s (connected_subchannel=%p, " - "error=%s)", + "chand=%p calld=%p: LB pick returned %s (subchannel=%p, error=%s)", chand, calld, PickResultTypeName(result.type), - result.connected_subchannel.get(), grpc_error_string(result.error)); + result.subchannel.get(), grpc_error_string(result.error)); } switch (result.type) { case LoadBalancingPolicy::PickResult::PICK_TRANSIENT_FAILURE: { @@ -3535,11 +3748,16 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { break; default: // PICK_COMPLETE // Handle drops. - if (GPR_UNLIKELY(result.connected_subchannel == nullptr)) { + if (GPR_UNLIKELY(result.subchannel == nullptr)) { result.error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Call dropped by load balancing policy"); + } else { + // Grab a ref to the connected subchannel while we're still + // holding the data plane combiner. + calld->connected_subchannel_ = + chand->GetConnectedSubchannelInDataPlane(result.subchannel.get()); + GPR_ASSERT(calld->connected_subchannel_ != nullptr); } - calld->connected_subchannel_ = std::move(result.connected_subchannel); calld->lb_recv_trailing_metadata_ready_ = result.recv_trailing_metadata_ready; calld->lb_recv_trailing_metadata_ready_user_data_ = diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h index d508932015d..ccaeffe269c 100644 --- a/src/core/ext/filters/client_channel/lb_policy.h +++ b/src/core/ext/filters/client_channel/lb_policy.h @@ -128,7 +128,7 @@ class LoadBalancingPolicy : public InternallyRefCounted { /// Used only if type is PICK_COMPLETE. Will be set to the selected /// subchannel, or nullptr if the LB policy decides to drop the call. - RefCountedPtr connected_subchannel; + RefCountedPtr subchannel; /// Used only if type is PICK_TRANSIENT_FAILURE. /// Error to be set when returning a transient failure. diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index a87dfda7321..dad10f0ce86 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -575,13 +575,12 @@ GrpcLb::PickResult GrpcLb::Picker::Pick(PickArgs args) { result = child_picker_->Pick(args); // If pick succeeded, add LB token to initial metadata. if (result.type == PickResult::PICK_COMPLETE && - result.connected_subchannel != nullptr) { + result.subchannel != nullptr) { const grpc_arg* arg = grpc_channel_args_find( - result.connected_subchannel->args(), GRPC_ARG_GRPCLB_ADDRESS_LB_TOKEN); + result.subchannel->channel_args(), GRPC_ARG_GRPCLB_ADDRESS_LB_TOKEN); if (arg == nullptr) { - gpr_log(GPR_ERROR, - "[grpclb %p picker %p] No LB token for connected subchannel %p", - parent_, this, result.connected_subchannel.get()); + gpr_log(GPR_ERROR, "[grpclb %p picker %p] No LB token for subchannel %p", + parent_, this, result.subchannel.get()); abort(); } grpc_mdelem lb_token = {reinterpret_cast(arg->value.pointer.p)}; diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index e4b58eb7558..de17b1f046e 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -28,7 +28,6 @@ #include "src/core/ext/filters/client_channel/subchannel.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/sync.h" -#include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/transport/connectivity_state.h" @@ -85,9 +84,8 @@ class PickFirst : public LoadBalancingPolicy { public: PickFirstSubchannelList(PickFirst* policy, TraceFlag* tracer, const ServerAddressList& addresses, - grpc_combiner* combiner, const grpc_channel_args& args) - : SubchannelList(policy, tracer, addresses, combiner, + : SubchannelList(policy, tracer, addresses, policy->channel_control_helper(), args) { // Need to maintain a ref to the LB policy as long as we maintain // any references to subchannels, since the subchannels' @@ -111,19 +109,18 @@ class PickFirst : public LoadBalancingPolicy { class Picker : public SubchannelPicker { public: - explicit Picker( - RefCountedPtr connected_subchannel) - : connected_subchannel_(std::move(connected_subchannel)) {} + explicit Picker(RefCountedPtr subchannel) + : subchannel_(std::move(subchannel)) {} PickResult Pick(PickArgs args) override { PickResult result; result.type = PickResult::PICK_COMPLETE; - result.connected_subchannel = connected_subchannel_; + result.subchannel = subchannel_; return result; } private: - RefCountedPtr connected_subchannel_; + RefCountedPtr subchannel_; }; void ShutdownLocked() override; @@ -166,6 +163,9 @@ void PickFirst::ShutdownLocked() { void PickFirst::ExitIdleLocked() { if (shutdown_) return; if (idle_) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_pick_first_trace)) { + gpr_log(GPR_INFO, "Pick First %p exiting idle", this); + } idle_ = false; if (subchannel_list_ == nullptr || subchannel_list_->num_subchannels() == 0) { @@ -200,7 +200,7 @@ void PickFirst::UpdateLocked(UpdateArgs args) { grpc_channel_args* new_args = grpc_channel_args_copy_and_add(args.args, &new_arg, 1); auto subchannel_list = MakeOrphanable( - this, &grpc_lb_pick_first_trace, args.addresses, combiner(), *new_args); + this, &grpc_lb_pick_first_trace, args.addresses, *new_args); grpc_channel_args_destroy(new_args); if (subchannel_list->num_subchannels() == 0) { // Empty update or no valid subchannels. Unsubscribe from all current @@ -350,8 +350,8 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( // some connectivity state notifications. if (connectivity_state == GRPC_CHANNEL_READY) { p->channel_control_helper()->UpdateState( - GRPC_CHANNEL_READY, UniquePtr(New( - connected_subchannel()->Ref()))); + GRPC_CHANNEL_READY, + UniquePtr(New(subchannel()->Ref()))); } else { // CONNECTING p->channel_control_helper()->UpdateState( connectivity_state, @@ -445,13 +445,13 @@ void PickFirst::PickFirstSubchannelData::ProcessUnselectedReadyLocked() { p->subchannel_list_ = std::move(p->latest_pending_subchannel_list_); } // Cases 1 and 2. - p->selected_ = this; - p->channel_control_helper()->UpdateState( - GRPC_CHANNEL_READY, - UniquePtr(New(connected_subchannel()->Ref()))); if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_pick_first_trace)) { gpr_log(GPR_INFO, "Pick First %p selected subchannel %p", p, subchannel()); } + p->selected_ = this; + p->channel_control_helper()->UpdateState( + GRPC_CHANNEL_READY, + UniquePtr(New(subchannel()->Ref()))); } void PickFirst::PickFirstSubchannelData:: diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc index 17c65d8b551..02bd319e37e 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc @@ -38,7 +38,6 @@ #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/sync.h" -#include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/transport/connectivity_state.h" #include "src/core/lib/transport/static_metadata.h" @@ -106,9 +105,8 @@ class RoundRobin : public LoadBalancingPolicy { public: RoundRobinSubchannelList(RoundRobin* policy, TraceFlag* tracer, const ServerAddressList& addresses, - grpc_combiner* combiner, const grpc_channel_args& args) - : SubchannelList(policy, tracer, addresses, combiner, + : SubchannelList(policy, tracer, addresses, policy->channel_control_helper(), args) { // Need to maintain a ref to the LB policy as long as we maintain // any references to subchannels, since the subchannels' @@ -155,7 +153,7 @@ class RoundRobin : public LoadBalancingPolicy { RoundRobin* parent_; size_t last_picked_index_; - InlinedVector, 10> subchannels_; + InlinedVector, 10> subchannels_; }; void ShutdownLocked() override; @@ -180,10 +178,9 @@ RoundRobin::Picker::Picker(RoundRobin* parent, RoundRobinSubchannelList* subchannel_list) : parent_(parent) { for (size_t i = 0; i < subchannel_list->num_subchannels(); ++i) { - auto* connected_subchannel = - subchannel_list->subchannel(i)->connected_subchannel(); - if (connected_subchannel != nullptr) { - subchannels_.push_back(connected_subchannel->Ref()); + RoundRobinSubchannelData* sd = subchannel_list->subchannel(i); + if (sd->connectivity_state() == GRPC_CHANNEL_READY) { + subchannels_.push_back(sd->subchannel()->Ref()); } } // For discussion on why we generate a random starting index for @@ -204,14 +201,13 @@ RoundRobin::PickResult RoundRobin::Picker::Pick(PickArgs args) { last_picked_index_ = (last_picked_index_ + 1) % subchannels_.size(); if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_round_robin_trace)) { gpr_log(GPR_INFO, - "[RR %p picker %p] returning index %" PRIuPTR - ", connected_subchannel=%p", + "[RR %p picker %p] returning index %" PRIuPTR ", subchannel=%p", parent_, this, last_picked_index_, subchannels_[last_picked_index_].get()); } PickResult result; result.type = PickResult::PICK_COMPLETE; - result.connected_subchannel = subchannels_[last_picked_index_]; + result.subchannel = subchannels_[last_picked_index_]; return result; } @@ -424,7 +420,7 @@ void RoundRobin::UpdateLocked(UpdateArgs args) { } } latest_pending_subchannel_list_ = MakeOrphanable( - this, &grpc_lb_round_robin_trace, args.addresses, combiner(), *args.args); + this, &grpc_lb_round_robin_trace, args.addresses, *args.args); if (latest_pending_subchannel_list_->num_subchannels() == 0) { // If the new list is empty, immediately promote the new list to the // current list and transition to TRANSIENT_FAILURE. diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h index 7d70928a83c..34cd0f549fe 100644 --- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h @@ -39,7 +39,6 @@ #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/closure.h" -#include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/transport/connectivity_state.h" @@ -64,8 +63,7 @@ class MySubchannelList }; */ -// All methods with a Locked() suffix must be called from within the -// client_channel combiner. +// All methods will be called from within the client_channel combiner. namespace grpc_core { @@ -93,20 +91,13 @@ class SubchannelData { // Returns a pointer to the subchannel. SubchannelInterface* subchannel() const { return subchannel_.get(); } - // Returns the connected subchannel. Will be null if the subchannel - // is not connected. - ConnectedSubchannelInterface* connected_subchannel() const { - return connected_subchannel_.get(); - } - // Synchronously checks the subchannel's connectivity state. // Must not be called while there is a connectivity notification // pending (i.e., between calling StartConnectivityWatchLocked() and // calling CancelConnectivityWatchLocked()). grpc_connectivity_state CheckConnectivityStateLocked() { GPR_ASSERT(pending_watcher_ == nullptr); - connectivity_state_ = - subchannel()->CheckConnectivityState(&connected_subchannel_); + connectivity_state_ = subchannel_->CheckConnectivityState(); return connectivity_state_; } @@ -144,7 +135,8 @@ class SubchannelData { private: // Watcher for subchannel connectivity state. - class Watcher : public SubchannelInterface::ConnectivityStateWatcher { + class Watcher + : public SubchannelInterface::ConnectivityStateWatcherInterface { public: Watcher( SubchannelData* subchannel_data, @@ -154,42 +146,13 @@ class SubchannelData { ~Watcher() { subchannel_list_.reset(DEBUG_LOCATION, "Watcher dtor"); } - void OnConnectivityStateChange(grpc_connectivity_state new_state, - RefCountedPtr - connected_subchannel) override; + void OnConnectivityStateChange(grpc_connectivity_state new_state) override; grpc_pollset_set* interested_parties() override { return subchannel_list_->policy()->interested_parties(); } private: - // A fire-and-forget class that bounces into the combiner to process - // a connectivity state update. - class Updater { - public: - Updater( - SubchannelData* - subchannel_data, - RefCountedPtr> - subchannel_list, - grpc_connectivity_state state, - RefCountedPtr connected_subchannel); - - ~Updater() { - subchannel_list_.reset(DEBUG_LOCATION, "Watcher::Updater dtor"); - } - - private: - static void OnUpdateLocked(void* arg, grpc_error* error); - - SubchannelData* subchannel_data_; - RefCountedPtr> - subchannel_list_; - const grpc_connectivity_state state_; - RefCountedPtr connected_subchannel_; - grpc_closure closure_; - }; - SubchannelData* subchannel_data_; RefCountedPtr subchannel_list_; }; @@ -202,10 +165,10 @@ class SubchannelData { // The subchannel. RefCountedPtr subchannel_; // Will be non-null when the subchannel's state is being watched. - SubchannelInterface::ConnectivityStateWatcher* pending_watcher_ = nullptr; + SubchannelInterface::ConnectivityStateWatcherInterface* pending_watcher_ = + nullptr; // Data updated by the watcher. grpc_connectivity_state connectivity_state_; - RefCountedPtr connected_subchannel_; }; // A list of subchannels. @@ -232,7 +195,6 @@ class SubchannelList : public InternallyRefCounted { // the backoff code out of subchannels and into LB policies. void ResetBackoffLocked(); - // Note: Caller must ensure that this is invoked inside of the combiner. void Orphan() override { ShutdownLocked(); InternallyRefCounted::Unref(DEBUG_LOCATION, "shutdown"); @@ -242,7 +204,7 @@ class SubchannelList : public InternallyRefCounted { protected: SubchannelList(LoadBalancingPolicy* policy, TraceFlag* tracer, - const ServerAddressList& addresses, grpc_combiner* combiner, + const ServerAddressList& addresses, LoadBalancingPolicy::ChannelControlHelper* helper, const grpc_channel_args& args); @@ -263,8 +225,6 @@ class SubchannelList : public InternallyRefCounted { TraceFlag* tracer_; - grpc_combiner* combiner_; - // The list of subchannels. SubchannelVector subchannels_; @@ -284,59 +244,26 @@ class SubchannelList : public InternallyRefCounted { template void SubchannelData::Watcher:: - OnConnectivityStateChange( - grpc_connectivity_state new_state, - RefCountedPtr connected_subchannel) { - // Will delete itself. - New(subchannel_data_, - subchannel_list_->Ref(DEBUG_LOCATION, "Watcher::Updater"), - new_state, std::move(connected_subchannel)); -} - -template -SubchannelData::Watcher::Updater:: - Updater( - SubchannelData* subchannel_data, - RefCountedPtr> - subchannel_list, - grpc_connectivity_state state, - RefCountedPtr connected_subchannel) - : subchannel_data_(subchannel_data), - subchannel_list_(std::move(subchannel_list)), - state_(state), - connected_subchannel_(std::move(connected_subchannel)) { - GRPC_CLOSURE_INIT(&closure_, &OnUpdateLocked, this, - grpc_combiner_scheduler(subchannel_list_->combiner_)); - GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE); -} - -template -void SubchannelData::Watcher::Updater:: - OnUpdateLocked(void* arg, grpc_error* error) { - Updater* self = static_cast(arg); - SubchannelData* sd = self->subchannel_data_; - if (GRPC_TRACE_FLAG_ENABLED(*sd->subchannel_list_->tracer())) { + OnConnectivityStateChange(grpc_connectivity_state new_state) { + if (GRPC_TRACE_FLAG_ENABLED(*subchannel_list_->tracer())) { gpr_log(GPR_INFO, "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR " (subchannel %p): connectivity changed: state=%s, " - "connected_subchannel=%p, shutting_down=%d, pending_watcher=%p", - sd->subchannel_list_->tracer()->name(), - sd->subchannel_list_->policy(), sd->subchannel_list_, sd->Index(), - sd->subchannel_list_->num_subchannels(), sd->subchannel_.get(), - grpc_connectivity_state_name(self->state_), - self->connected_subchannel_.get(), - sd->subchannel_list_->shutting_down(), sd->pending_watcher_); + "shutting_down=%d, pending_watcher=%p", + subchannel_list_->tracer()->name(), subchannel_list_->policy(), + subchannel_list_.get(), subchannel_data_->Index(), + subchannel_list_->num_subchannels(), + subchannel_data_->subchannel_.get(), + grpc_connectivity_state_name(new_state), + subchannel_list_->shutting_down(), + subchannel_data_->pending_watcher_); } - if (!sd->subchannel_list_->shutting_down() && - sd->pending_watcher_ != nullptr) { - sd->connectivity_state_ = self->state_; - // Get or release ref to connected subchannel. - sd->connected_subchannel_ = std::move(self->connected_subchannel_); + if (!subchannel_list_->shutting_down() && + subchannel_data_->pending_watcher_ != nullptr) { + subchannel_data_->connectivity_state_ = new_state; // Call the subclass's ProcessConnectivityChangeLocked() method. - sd->ProcessConnectivityChangeLocked(sd->connectivity_state_); + subchannel_data_->ProcessConnectivityChangeLocked(new_state); } - // Clean up. - Delete(self); } // @@ -371,7 +298,6 @@ void SubchannelData:: subchannel_.get()); } subchannel_.reset(); - connected_subchannel_.reset(); } } @@ -400,7 +326,7 @@ void SubchannelData(this, subchannel_list()->Ref(DEBUG_LOCATION, "Watcher")); subchannel_->WatchConnectivityState( connectivity_state_, - UniquePtr( + UniquePtr( pending_watcher_)); } @@ -434,13 +360,12 @@ void SubchannelData::ShutdownLocked() { template SubchannelList::SubchannelList( LoadBalancingPolicy* policy, TraceFlag* tracer, - const ServerAddressList& addresses, grpc_combiner* combiner, + const ServerAddressList& addresses, LoadBalancingPolicy::ChannelControlHelper* helper, const grpc_channel_args& args) : InternallyRefCounted(tracer), policy_(policy), - tracer_(tracer), - combiner_(GRPC_COMBINER_REF(combiner, "subchannel_list")) { + tracer_(tracer) { if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) { gpr_log(GPR_INFO, "[%s %p] Creating subchannel list %p for %" PRIuPTR " subchannels", @@ -509,7 +434,6 @@ SubchannelList::~SubchannelList() { gpr_log(GPR_INFO, "[%s %p] Destroying subchannel_list %p", tracer_->name(), policy_, this); } - GRPC_COMBINER_UNREF(combiner_, "subchannel_list"); } template diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index 136d85bba14..ad030c17b5e 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -554,7 +554,7 @@ XdsLb::PickResult XdsLb::Picker::Pick(PickArgs args) { PickResult result = PickFromLocality(key, args); // If pick succeeded, add client stats. if (result.type == PickResult::PICK_COMPLETE && - result.connected_subchannel != nullptr && client_stats_ != nullptr) { + result.subchannel != nullptr && client_stats_ != nullptr) { // TODO(roth): Add support for client stats. } return result; diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index dd16eded826..99c7721e5e5 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -86,7 +86,7 @@ ConnectedSubchannel::ConnectedSubchannel( grpc_channel_stack* channel_stack, const grpc_channel_args* args, RefCountedPtr channelz_subchannel, intptr_t socket_uuid) - : ConnectedSubchannelInterface(&grpc_trace_subchannel_refcount), + : RefCounted(&grpc_trace_subchannel_refcount), channel_stack_(channel_stack), args_(grpc_channel_args_copy(args)), channelz_subchannel_(std::move(channelz_subchannel)), @@ -378,12 +378,12 @@ class Subchannel::ConnectedSubchannelStateWatcher { // void Subchannel::ConnectivityStateWatcherList::AddWatcherLocked( - UniquePtr watcher) { + OrphanablePtr watcher) { watchers_.insert(MakePair(watcher.get(), std::move(watcher))); } void Subchannel::ConnectivityStateWatcherList::RemoveWatcherLocked( - ConnectivityStateWatcher* watcher) { + ConnectivityStateWatcherInterface* watcher) { watchers_.erase(watcher); } @@ -438,8 +438,9 @@ class Subchannel::HealthWatcherMap::HealthWatcher grpc_connectivity_state state() const { return state_; } - void AddWatcherLocked(grpc_connectivity_state initial_state, - UniquePtr watcher) { + void AddWatcherLocked( + grpc_connectivity_state initial_state, + OrphanablePtr watcher) { if (state_ != initial_state) { RefCountedPtr connected_subchannel; if (state_ == GRPC_CHANNEL_READY) { @@ -451,7 +452,7 @@ class Subchannel::HealthWatcherMap::HealthWatcher watcher_list_.AddWatcherLocked(std::move(watcher)); } - void RemoveWatcherLocked(ConnectivityStateWatcher* watcher) { + void RemoveWatcherLocked(ConnectivityStateWatcherInterface* watcher) { watcher_list_.RemoveWatcherLocked(watcher); } @@ -527,7 +528,7 @@ class Subchannel::HealthWatcherMap::HealthWatcher void Subchannel::HealthWatcherMap::AddWatcherLocked( Subchannel* subchannel, grpc_connectivity_state initial_state, UniquePtr health_check_service_name, - UniquePtr watcher) { + OrphanablePtr watcher) { // If the health check service name is not already present in the map, // add it. auto it = map_.find(health_check_service_name.get()); @@ -546,7 +547,8 @@ void Subchannel::HealthWatcherMap::AddWatcherLocked( } void Subchannel::HealthWatcherMap::RemoveWatcherLocked( - const char* health_check_service_name, ConnectivityStateWatcher* watcher) { + const char* health_check_service_name, + ConnectivityStateWatcherInterface* watcher) { auto it = map_.find(health_check_service_name); GPR_ASSERT(it != map_.end()); it->second->RemoveWatcherLocked(watcher); @@ -818,7 +820,7 @@ grpc_connectivity_state Subchannel::CheckConnectivityState( void Subchannel::WatchConnectivityState( grpc_connectivity_state initial_state, UniquePtr health_check_service_name, - UniquePtr watcher) { + OrphanablePtr watcher) { MutexLock lock(&mu_); grpc_pollset_set* interested_parties = watcher->interested_parties(); if (interested_parties != nullptr) { @@ -837,7 +839,8 @@ void Subchannel::WatchConnectivityState( } void Subchannel::CancelConnectivityStateWatch( - const char* health_check_service_name, ConnectivityStateWatcher* watcher) { + const char* health_check_service_name, + ConnectivityStateWatcherInterface* watcher) { MutexLock lock(&mu_); grpc_pollset_set* interested_parties = watcher->interested_parties(); if (interested_parties != nullptr) { diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h index 2f05792b872..9e8de767839 100644 --- a/src/core/ext/filters/client_channel/subchannel.h +++ b/src/core/ext/filters/client_channel/subchannel.h @@ -23,7 +23,6 @@ #include "src/core/ext/filters/client_channel/client_channel_channelz.h" #include "src/core/ext/filters/client_channel/connector.h" -#include "src/core/ext/filters/client_channel/subchannel_interface.h" #include "src/core/ext/filters/client_channel/subchannel_pool_interface.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_stack.h" @@ -70,7 +69,7 @@ namespace grpc_core { class SubchannelCall; -class ConnectedSubchannel : public ConnectedSubchannelInterface { +class ConnectedSubchannel : public RefCounted { public: struct CallArgs { grpc_polling_entity* pollent; @@ -97,7 +96,7 @@ class ConnectedSubchannel : public ConnectedSubchannelInterface { grpc_error** error); grpc_channel_stack* channel_stack() const { return channel_stack_; } - const grpc_channel_args* args() const override { return args_; } + const grpc_channel_args* args() const { return args_; } channelz::SubchannelNode* channelz_subchannel() const { return channelz_subchannel_.get(); } @@ -176,10 +175,35 @@ class SubchannelCall { // A subchannel that knows how to connect to exactly one target address. It // provides a target for load balancing. +// +// Note that this is the "real" subchannel implementation, whose API is +// different from the SubchannelInterface that is exposed to LB policy +// implementations. The client channel provides an adaptor class +// (SubchannelWrapper) that "converts" between the two. class Subchannel { public: - typedef SubchannelInterface::ConnectivityStateWatcher - ConnectivityStateWatcher; + class ConnectivityStateWatcherInterface + : public InternallyRefCounted { + public: + virtual ~ConnectivityStateWatcherInterface() = default; + + // Will be invoked whenever the subchannel's connectivity state + // changes. There will be only one invocation of this method on a + // given watcher instance at any given time. + // + // When the state changes to READY, connected_subchannel will + // contain a ref to the connected subchannel. When it changes from + // READY to some other state, the implementation must release its + // ref to the connected subchannel. + virtual void OnConnectivityStateChange( + grpc_connectivity_state new_state, + RefCountedPtr connected_subchannel) // NOLINT + GRPC_ABSTRACT; + + virtual grpc_pollset_set* interested_parties() GRPC_ABSTRACT; + + GRPC_ABSTRACT_BASE_CLASS + }; // The ctor and dtor are not intended to use directly. Subchannel(SubchannelKey* key, grpc_connector* connector, @@ -206,6 +230,8 @@ class Subchannel { // Caller doesn't take ownership. const char* GetTargetAddress(); + const grpc_channel_args* channel_args() const { return args_; } + channelz::SubchannelNode* channelz_node(); // Returns the current connectivity state of the subchannel. @@ -225,14 +251,15 @@ class Subchannel { // changes. // The watcher will be destroyed either when the subchannel is // destroyed or when CancelConnectivityStateWatch() is called. - void WatchConnectivityState(grpc_connectivity_state initial_state, - UniquePtr health_check_service_name, - UniquePtr watcher); + void WatchConnectivityState( + grpc_connectivity_state initial_state, + UniquePtr health_check_service_name, + OrphanablePtr watcher); // Cancels a connectivity state watch. // If the watcher has already been destroyed, this is a no-op. void CancelConnectivityStateWatch(const char* health_check_service_name, - ConnectivityStateWatcher* watcher); + ConnectivityStateWatcherInterface* watcher); // Attempt to connect to the backend. Has no effect if already connected. void AttemptToConnect(); @@ -257,14 +284,15 @@ class Subchannel { grpc_resolved_address* addr); private: - // A linked list of ConnectivityStateWatchers that are monitoring the - // subchannel's state. + // A linked list of ConnectivityStateWatcherInterfaces that are monitoring + // the subchannel's state. class ConnectivityStateWatcherList { public: ~ConnectivityStateWatcherList() { Clear(); } - void AddWatcherLocked(UniquePtr watcher); - void RemoveWatcherLocked(ConnectivityStateWatcher* watcher); + void AddWatcherLocked( + OrphanablePtr watcher); + void RemoveWatcherLocked(ConnectivityStateWatcherInterface* watcher); // Notifies all watchers in the list about a change to state. void NotifyLocked(Subchannel* subchannel, grpc_connectivity_state state); @@ -276,12 +304,13 @@ class Subchannel { private: // TODO(roth): This could be a set instead of a map if we had a set // implementation. - Map> + Map> watchers_; }; - // A map that tracks ConnectivityStateWatchers using a particular health - // check service name. + // A map that tracks ConnectivityStateWatcherInterfaces using a particular + // health check service name. // // There is one entry in the map for each health check service name. // Entries exist only as long as there are watchers using the @@ -291,12 +320,12 @@ class Subchannel { // state READY. class HealthWatcherMap { public: - void AddWatcherLocked(Subchannel* subchannel, - grpc_connectivity_state initial_state, - UniquePtr health_check_service_name, - UniquePtr watcher); + void AddWatcherLocked( + Subchannel* subchannel, grpc_connectivity_state initial_state, + UniquePtr health_check_service_name, + OrphanablePtr watcher); void RemoveWatcherLocked(const char* health_check_service_name, - ConnectivityStateWatcher* watcher); + ConnectivityStateWatcherInterface* watcher); // Notifies the watcher when the subchannel's state changes. void NotifyLocked(grpc_connectivity_state state); diff --git a/src/core/ext/filters/client_channel/subchannel_interface.h b/src/core/ext/filters/client_channel/subchannel_interface.h index 10b1bf124c2..2e448dc5a64 100644 --- a/src/core/ext/filters/client_channel/subchannel_interface.h +++ b/src/core/ext/filters/client_channel/subchannel_interface.h @@ -21,42 +21,22 @@ #include -#include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" namespace grpc_core { -// TODO(roth): In a subsequent PR, remove this from this API. -class ConnectedSubchannelInterface - : public RefCounted { - public: - virtual const grpc_channel_args* args() const GRPC_ABSTRACT; - - protected: - template - explicit ConnectedSubchannelInterface(TraceFlagT* trace_flag = nullptr) - : RefCounted(trace_flag) {} -}; - +// The interface for subchannels that is exposed to LB policy implementations. class SubchannelInterface : public RefCounted { public: - class ConnectivityStateWatcher { + class ConnectivityStateWatcherInterface { public: - virtual ~ConnectivityStateWatcher() = default; + virtual ~ConnectivityStateWatcherInterface() = default; // Will be invoked whenever the subchannel's connectivity state // changes. There will be only one invocation of this method on a // given watcher instance at any given time. - // - // When the state changes to READY, connected_subchannel will - // contain a ref to the connected subchannel. When it changes from - // READY to some other state, the implementation must release its - // ref to the connected subchannel. - virtual void OnConnectivityStateChange( - grpc_connectivity_state new_state, - RefCountedPtr - connected_subchannel) // NOLINT + virtual void OnConnectivityStateChange(grpc_connectivity_state new_state) GRPC_ABSTRACT; // TODO(roth): Remove this as soon as we move to EventManager-based @@ -66,12 +46,14 @@ class SubchannelInterface : public RefCounted { GRPC_ABSTRACT_BASE_CLASS }; + template + explicit SubchannelInterface(TraceFlagT* trace_flag = nullptr) + : RefCounted(trace_flag) {} + virtual ~SubchannelInterface() = default; // Returns the current connectivity state of the subchannel. - virtual grpc_connectivity_state CheckConnectivityState( - RefCountedPtr* connected_subchannel) - GRPC_ABSTRACT; + virtual grpc_connectivity_state CheckConnectivityState() GRPC_ABSTRACT; // Starts watching the subchannel's connectivity state. // The first callback to the watcher will be delivered when the @@ -86,12 +68,12 @@ class SubchannelInterface : public RefCounted { // the previous watcher using CancelConnectivityStateWatch(). virtual void WatchConnectivityState( grpc_connectivity_state initial_state, - UniquePtr watcher) GRPC_ABSTRACT; + UniquePtr watcher) GRPC_ABSTRACT; // Cancels a connectivity state watch. // If the watcher has already been destroyed, this is a no-op. - virtual void CancelConnectivityStateWatch(ConnectivityStateWatcher* watcher) - GRPC_ABSTRACT; + virtual void CancelConnectivityStateWatch( + ConnectivityStateWatcherInterface* watcher) GRPC_ABSTRACT; // Attempt to connect to the backend. Has no effect if already connected. // If the subchannel is currently in backoff delay due to a previously @@ -105,6 +87,9 @@ class SubchannelInterface : public RefCounted { // attempt will be started as soon as AttemptToConnect() is called. virtual void ResetBackoff() GRPC_ABSTRACT; + // TODO(roth): Need a better non-grpc-specific abstraction here. + virtual const grpc_channel_args* channel_args() GRPC_ABSTRACT; + GRPC_ABSTRACT_BASE_CLASS }; diff --git a/src/core/lib/gprpp/map.h b/src/core/lib/gprpp/map.h index 36e32d60c07..566691df580 100644 --- a/src/core/lib/gprpp/map.h +++ b/src/core/lib/gprpp/map.h @@ -30,6 +30,7 @@ #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/pair.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" namespace grpc_core { struct StringLess { @@ -41,6 +42,13 @@ struct StringLess { } }; +template +struct RefCountedPtrLess { + bool operator()(const RefCountedPtr& p1, const RefCountedPtr& p2) { + return p1.get() < p2.get(); + } +}; + namespace testing { class MapTest; } @@ -55,8 +63,28 @@ class Map { typedef Compare key_compare; class iterator; + Map() {} ~Map() { clear(); } + // Copying not currently supported. + Map(const Map& other) = delete; + + // Move support. + Map(Map&& other) : root_(other.root_), size_(other.size_) { + other.root_ = nullptr; + other.size_ = 0; + } + Map& operator=(Map&& other) { + if (this != &other) { + clear(); + root_ = other.root_; + size_ = other.size_; + other.root_ = nullptr; + other.size_ = 0; + } + return *this; + } + T& operator[](key_type&& key); T& operator[](const key_type& key); iterator find(const key_type& k); diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc index 1523ced16d8..7766ee186c6 100644 --- a/src/core/lib/transport/metadata.cc +++ b/src/core/lib/transport/metadata.cc @@ -222,7 +222,12 @@ void grpc_mdctx_global_shutdown() { abort(); } } + // For ASAN builds, we don't want to crash here, because that will + // prevent ASAN from providing leak detection information, which is + // far more useful than this simple assertion. +#ifndef GRPC_ASAN_ENABLED GPR_DEBUG_ASSERT(shard->count == 0); +#endif gpr_free(shard->elems); } } diff --git a/test/core/gprpp/map_test.cc b/test/core/gprpp/map_test.cc index 30d9eb0b207..21aeee82486 100644 --- a/test/core/gprpp/map_test.cc +++ b/test/core/gprpp/map_test.cc @@ -437,6 +437,35 @@ TEST_F(MapTest, LowerBound) { EXPECT_EQ(it, test_map.end()); } +// Test move ctor +TEST_F(MapTest, MoveCtor) { + Map test_map; + for (int i = 0; i < 5; i++) { + test_map.emplace(kKeys[i], Payload(i)); + } + Map test_map2 = std::move(test_map); + for (int i = 0; i < 5; i++) { + EXPECT_EQ(test_map.end(), test_map.find(kKeys[i])); + EXPECT_EQ(i, test_map2.find(kKeys[i])->second.data()); + } +} + +// Test move assignment +TEST_F(MapTest, MoveAssignment) { + Map test_map; + for (int i = 0; i < 5; i++) { + test_map.emplace(kKeys[i], Payload(i)); + } + Map test_map2; + test_map2.emplace("xxx", Payload(123)); + test_map2 = std::move(test_map); + for (int i = 0; i < 5; i++) { + EXPECT_EQ(test_map.end(), test_map.find(kKeys[i])); + EXPECT_EQ(i, test_map2.find(kKeys[i])->second.data()); + } + EXPECT_EQ(test_map2.end(), test_map2.find("xxx")); +} + } // namespace testing } // namespace grpc_core diff --git a/test/core/util/test_lb_policies.cc b/test/core/util/test_lb_policies.cc index 2c1f988d173..041ce1f45a1 100644 --- a/test/core/util/test_lb_policies.cc +++ b/test/core/util/test_lb_policies.cc @@ -117,7 +117,7 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy PickResult Pick(PickArgs args) override { PickResult result = delegate_picker_->Pick(args); if (result.type == PickResult::PICK_COMPLETE && - result.connected_subchannel != nullptr) { + result.subchannel != nullptr) { new (args.call_state->Alloc(sizeof(TrailingMetadataHandler))) TrailingMetadataHandler(&result, cb_, user_data_); } From 93c8088b332c02e505743e3ad06ecbd31ccb863a Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 10 Jun 2019 12:10:08 -0700 Subject: [PATCH 0507/1555] Implement global interceptor --- .../GRPCClient/GRPCCall+Interceptor.h | 29 ++++ .../GRPCClient/GRPCCall+Interceptor.m | 60 +++++++ src/objective-c/GRPCClient/GRPCCall.m | 37 +++- .../tests/InteropTests/InteropTests.m | 158 +++++++++++++++++- 4 files changed, 277 insertions(+), 7 deletions(-) create mode 100644 src/objective-c/GRPCClient/GRPCCall+Interceptor.h create mode 100644 src/objective-c/GRPCClient/GRPCCall+Interceptor.m diff --git a/src/objective-c/GRPCClient/GRPCCall+Interceptor.h b/src/objective-c/GRPCClient/GRPCCall+Interceptor.h new file mode 100644 index 00000000000..953846d8c99 --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCCall+Interceptor.h @@ -0,0 +1,29 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "GRPCCall.h" + +@protocol GRPCInterceptorFactory; + +@interface GRPCCall2 (Interceptor) + ++ (void)registerGlobalInterceptor:(id)interceptorFactory; + ++ (id)globalInterceptorFactory; + +@end diff --git a/src/objective-c/GRPCClient/GRPCCall+Interceptor.m b/src/objective-c/GRPCClient/GRPCCall+Interceptor.m new file mode 100644 index 00000000000..b1cad75d4f3 --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCCall+Interceptor.m @@ -0,0 +1,60 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "GRPCCall+Interceptor.h" +#import "GRPCInterceptor.h" + +static id globalInterceptorFactory = nil; +static NSLock *globalInterceptorLock = nil; +static dispatch_once_t onceToken; + +@implementation GRPCCall2 (Interceptor) + ++ (void)registerGlobalInterceptor:(id)interceptorFactory { + dispatch_once(&onceToken, ^{ + globalInterceptorLock = [[NSLock alloc] init]; + }); + [globalInterceptorLock lock]; + NSAssert(globalInterceptorFactory == nil, + @"Global interceptor is already registered. Only one global interceptor can be " + @"registered in a process"); + if (globalInterceptorFactory != nil) { + NSLog( + @"Global interceptor is already registered. Only one global interceptor can be registered " + @"in a process"); + [globalInterceptorLock unlock]; + return; + } + + globalInterceptorFactory = interceptorFactory; + [globalInterceptorLock unlock]; +} + ++ (id)globalInterceptorFactory { + dispatch_once(&onceToken, ^{ + globalInterceptorLock = [[NSLock alloc] init]; + }); + id factory; + [globalInterceptorLock lock]; + factory = globalInterceptorFactory; + [globalInterceptorLock unlock]; + + return factory; +} + +@end diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index e97ed6e3a9e..684867ae1ee 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -17,6 +17,7 @@ */ #import "GRPCCall.h" +#import "GRPCCall+Interceptor.h" #import "GRPCCall+OAuth2.h" #import "GRPCCallOptions.h" #import "GRPCInterceptor.h" @@ -141,23 +142,51 @@ const char *kCFStreamVarName = "grpc_cfstream"; _responseHandler = responseHandler; // Initialize the interceptor chain + + // First initialize the internal call GRPCCall2Internal *internalCall = [[GRPCCall2Internal alloc] init]; id nextInterceptor = internalCall; GRPCInterceptorManager *nextManager = nil; + + // Then initialize the global interceptor, if applicable + id globalInterceptorFactory = [GRPCCall2 globalInterceptorFactory]; + if (globalInterceptorFactory) { + GRPCInterceptorManager *manager = + [[GRPCInterceptorManager alloc] initWithNextInterceptor:nextInterceptor]; + GRPCInterceptor *interceptor = + [globalInterceptorFactory createInterceptorWithManager:manager]; + NSAssert(interceptor != nil, @"Failed to create interceptor from factory: %@", + globalInterceptorFactory); + if (interceptor == nil) { + NSLog(@"Failed to create interceptor from factory: %@", globalInterceptorFactory); + } else { + [internalCall setResponseHandler:interceptor]; + } + nextInterceptor = interceptor; + nextManager = manager; + } + + // Finanlly initialize the interceptors in the chain NSArray *interceptorFactories = _actualCallOptions.interceptorFactories; if (interceptorFactories.count == 0) { - [internalCall setResponseHandler:_responseHandler]; + if (nextManager == nil) { + [internalCall setResponseHandler:_responseHandler]; + } else { + [nextManager setPreviousInterceptor:_responseHandler]; + } } else { for (int i = (int)interceptorFactories.count - 1; i >= 0; i--) { GRPCInterceptorManager *manager = [[GRPCInterceptorManager alloc] initWithNextInterceptor:nextInterceptor]; GRPCInterceptor *interceptor = [interceptorFactories[i] createInterceptorWithManager:manager]; - NSAssert(interceptor != nil, @"Failed to create interceptor"); + NSAssert(interceptor != nil, @"Failed to create interceptor from factory: %@", + interceptorFactories[i]); if (interceptor == nil) { - return nil; + NSLog(@"Failed to create interceptor from factory: %@", interceptorFactories[i]); + continue; } - if (i == (int)interceptorFactories.count - 1) { + if (nextManager == nil) { [internalCall setResponseHandler:interceptor]; } else { [nextManager setPreviousInterceptor:interceptor]; diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 91e133a1300..ef22a53cd96 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -25,6 +25,7 @@ #endif #import #import +#import #import #import #import @@ -1224,7 +1225,8 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - (void)testDefaultInterceptor { XCTAssertNotNil([[self class] host]); - __weak XCTestExpectation *expectation = [self expectationWithDescription:@"PingPongWithV2API"]; + __weak XCTestExpectation *expectation = + [self expectationWithDescription:@"testDefaultInterceptor"]; NSArray *requests = @[ @27182, @8, @1828, @45904 ]; NSArray *responses = @[ @31415, @9, @2653, @58979 ]; @@ -1277,7 +1279,8 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - (void)testLoggingInterceptor { XCTAssertNotNil([[self class] host]); - __weak XCTestExpectation *expectation = [self expectationWithDescription:@"PingPongWithV2API"]; + __weak XCTestExpectation *expectation = + [self expectationWithDescription:@"testLoggingInterceptor"]; __block NSUInteger startCount = 0; __block NSUInteger writeDataCount = 0; @@ -1400,7 +1403,8 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - (void)testHijackingInterceptor { NSUInteger kCancelAfterWrites = 2; XCTAssertNotNil([[self class] host]); - __weak XCTestExpectation *expectation = [self expectationWithDescription:@"PingPongWithV2API"]; + __weak XCTestExpectation *expectation = + [self expectationWithDescription:@"testHijackingInterceptor"]; NSArray *responses = @[ @1, @2, @3, @4 ]; __block int index = 0; @@ -1514,4 +1518,152 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager XCTAssertEqual(responseCloseCount, 1); } +- (void)testGlobalInterceptor { + XCTAssertNotNil([[self class] host]); + __weak XCTestExpectation *expectation = + [self expectationWithDescription:@"testLoggingInterceptor"]; + + __block NSUInteger startCount = 0; + __block NSUInteger writeDataCount = 0; + __block NSUInteger finishCount = 0; + __block NSUInteger receiveNextMessageCount = 0; + __block NSUInteger responseHeaderCount = 0; + __block NSUInteger responseDataCount = 0; + __block NSUInteger responseCloseCount = 0; + __block NSUInteger didWriteDataCount = 0; + id factory = [[HookInterceptorFactory alloc] + initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager) { + startCount++; + XCTAssertEqualObjects(requestOptions.host, [[self class] host]); + XCTAssertEqualObjects(requestOptions.path, @"/grpc.testing.TestService/FullDuplexCall"); + XCTAssertEqual(requestOptions.safety, GRPCCallSafetyDefault); + [manager startNextInterceptorWithRequest:[requestOptions copy] + callOptions:[callOptions copy]]; + } + writeDataHook:^(id data, GRPCInterceptorManager *manager) { + writeDataCount++; + [manager writeNextInterceptorWithData:data]; + } + finishHook:^(GRPCInterceptorManager *manager) { + finishCount++; + [manager finishNextInterceptor]; + } + receiveNextMessagesHook:^(NSUInteger numberOfMessages, GRPCInterceptorManager *manager) { + receiveNextMessageCount++; + [manager receiveNextInterceptorMessages:numberOfMessages]; + } + responseHeaderHook:^(NSDictionary *initialMetadata, GRPCInterceptorManager *manager) { + responseHeaderCount++; + [manager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; + } + responseDataHook:^(id data, GRPCInterceptorManager *manager) { + responseDataCount++; + [manager forwardPreviousInterceptorWithData:data]; + } + responseCloseHook:^(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager) { + responseCloseCount++; + [manager forwardPreviousInterceptorCloseWithTrailingMetadata:trailingMetadata error:error]; + } + didWriteDataHook:^(GRPCInterceptorManager *manager) { + didWriteDataCount++; + [manager forwardPreviousInterceptorDidWriteData]; + }]; + + NSArray *requests = @[ @1, @2, @3, @4 ]; + NSArray *responses = @[ @1, @2, @3, @4 ]; + + __block int index = 0; + + id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] + requestedResponseSize:responses[index]]; + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + options.transportType = [[self class] transportType]; + options.PEMRootCertificates = [[self class] PEMRootCertificates]; + options.hostNameOverride = [[self class] hostNameOverride]; + options.flowControlEnabled = YES; + [GRPCCall2 registerGlobalInterceptor:factory]; + + __block BOOL canWriteData = NO; + __block GRPCStreamingProtoCall *call = [_service + fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:^(id message) { + XCTAssertLessThan(index, 4, + @"More than 4 responses received."); + index += 1; + if (index < 4) { + id request = [RMTStreamingOutputCallRequest + messageWithPayloadSize:requests[index] + requestedResponseSize:responses[index]]; + XCTAssertTrue(canWriteData); + canWriteData = NO; + [call writeMessage:request]; + [call receiveNextMessage]; + } else { + [call finish]; + } + } + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + XCTAssertNil(error, + @"Finished with unexpected error: %@", + error); + [expectation fulfill]; + } + writeMessageCallback:^{ + canWriteData = YES; + }] + callOptions:options]; + [call start]; + [call receiveNextMessage]; + [call writeMessage:request]; + + [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; + XCTAssertEqual(startCount, 1); + XCTAssertEqual(writeDataCount, 4); + XCTAssertEqual(finishCount, 1); + XCTAssertEqual(receiveNextMessageCount, 4); + XCTAssertEqual(responseHeaderCount, 1); + XCTAssertEqual(responseDataCount, 4); + XCTAssertEqual(responseCloseCount, 1); + XCTAssertEqual(didWriteDataCount, 4); +} + +- (void)testConflictingGlobalInterceptors { + id factory = [[HookInterceptorFactory alloc] + initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + startHook:nil + writeDataHook:nil + finishHook:nil + receiveNextMessagesHook:nil + responseHeaderHook:nil + responseDataHook:nil + responseCloseHook:nil + didWriteDataHook:nil]; + id factory2 = [[HookInterceptorFactory alloc] + initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + startHook:nil + writeDataHook:nil + finishHook:nil + receiveNextMessagesHook:nil + responseHeaderHook:nil + responseDataHook:nil + responseCloseHook:nil + didWriteDataHook:nil]; + + [GRPCCall2 registerGlobalInterceptor:factory]; + @try { + [GRPCCall2 registerGlobalInterceptor:factory2]; + XCTFail(@"Did not receive an exception when registering global interceptor the second time"); + } @catch (NSException *exception) { + NSLog(@"Received exception as expected: %@", exception); + } +} + @end From ad0b0287dfcc137da23b9896b3a8810921d9fc8e Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 12 Jun 2019 10:46:51 -0700 Subject: [PATCH 0508/1555] Resolve build issue --- src/core/lib/iomgr/cfstream_handle.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/lib/iomgr/cfstream_handle.h b/src/core/lib/iomgr/cfstream_handle.h index 4f4d15966e4..05f45ed6251 100644 --- a/src/core/lib/iomgr/cfstream_handle.h +++ b/src/core/lib/iomgr/cfstream_handle.h @@ -29,6 +29,7 @@ #ifdef GRPC_CFSTREAM #import +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/lockfree_event.h" @@ -65,6 +66,9 @@ class CFStreamHandle final { dispatch_queue_t dispatch_queue_; gpr_refcount refcount_; + + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE }; #ifdef DEBUG From 21020d85c2800902f397edcfa103b18190c03546 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Wed, 12 Jun 2019 14:42:07 -0400 Subject: [PATCH 0509/1555] Update the doc for the new debug-only flags. --- doc/environment_variables.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/environment_variables.md b/doc/environment_variables.md index 778560d4273..89ccaf825d2 100644 --- a/doc/environment_variables.md +++ b/doc/environment_variables.md @@ -39,7 +39,6 @@ some configuration as environment variables that can be set. gRPC C core is processing requests via debug logs. Available tracers include: - api - traces api calls to the C core - bdp_estimator - traces behavior of bdp estimation logic - - call_combiner - traces call combiner state - call_error - traces the possible errors contributing to final call status - cares_resolver - traces operations of the c-ares based DNS resolver - cares_address_sorting - traces operations of the c-ares based DNS @@ -52,9 +51,6 @@ some configuration as environment variables that can be set. - connectivity_state - traces connectivity state changes to channels - cronet - traces state in the cronet transport engine - executor - traces grpc's internal thread pool ('the executor') - - fd_trace - traces fd create(), shutdown() and close() calls for channel fds. - Also traces epoll fd create()/close() calls in epollex polling engine - traces epoll-fd creation/close calls for epollex polling engine - glb - traces the grpclb load balancer - handshaker - traces handshaking state - health_check_client - traces health checking client code @@ -85,7 +81,11 @@ some configuration as environment variables that can be set. - alarm_refcount - refcounting traces for grpc_alarm structure - metadata - tracks creation and mutation of metadata - combiner - traces combiner lock state + - call_combiner - traces call combiner state - closure - tracks closure creation, scheduling, and completion + - fd_trace - traces fd create(), shutdown() and close() calls for channel fds. + Also traces epoll fd create()/close() calls in epollex polling engine + traces epoll-fd creation/close calls for epollex polling engine - pending_tags - traces still-in-progress tags on completion queues - polling - traces the selected polling engine - polling_api - traces the api calls to polling engine From f5551f11386f149581aa9898fc9ec3ce2dc1f1fe Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 12 Jun 2019 13:49:17 -0700 Subject: [PATCH 0510/1555] Revert " Added some Objective C tests and minor bug fixes." --- .../GRPCClient/GRPCCall+ChannelArg.m | 3 - src/objective-c/GRPCClient/GRPCCallOptions.h | 5 +- src/objective-c/GRPCClient/GRPCCallOptions.m | 10 +- .../GRPCClient/private/GRPCChannel.m | 2 - .../GRPCClient/private/GRPCChannelPool.m | 4 +- src/objective-c/GRPCClient/private/GRPCHost.m | 10 +- .../InteropTestsRemoteWithCronet.m | 4 - .../tests/InteropTests/InteropTests.h | 6 - .../tests/InteropTests/InteropTests.m | 190 +-------- .../tests/InteropTests/InteropTestsRemote.m | 4 - src/objective-c/tests/MacTests/StressTests.m | 383 +----------------- src/objective-c/tests/UnitTests/APIv2Tests.m | 330 +-------------- test/cpp/interop/interop_server.cc | 3 +- 13 files changed, 33 insertions(+), 921 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m index 78fe687b3d4..ae60d6208e1 100644 --- a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m @@ -51,9 +51,6 @@ case GRPCCompressGzip: hostConfig.compressAlgorithm = GRPC_COMPRESS_GZIP; break; - case GRPCStreamCompressGzip: - hostConfig.compressAlgorithm = GRPC_COMPRESS_STREAM_GZIP; - break; default: NSLog(@"Invalid compression algorithm"); abort(); diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.h b/src/objective-c/GRPCClient/GRPCCallOptions.h index b957e11fbea..98511e3f5cb 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.h +++ b/src/objective-c/GRPCClient/GRPCCallOptions.h @@ -156,8 +156,7 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { // HTTP/2 keep-alive feature. The parameter \a keepaliveInterval specifies the interval between two // PING frames. The parameter \a keepaliveTimeout specifies the length of the period for which the // call should wait for PING ACK. If PING ACK is not received after this period, the call fails. -// Negative values are invalid; setting these parameters to negative value will reset the -// corresponding parameter to the internal default value. +// Negative values are not allowed. @property(readonly) NSTimeInterval keepaliveInterval; @property(readonly) NSTimeInterval keepaliveTimeout; @@ -321,7 +320,7 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { // PING frames. The parameter \a keepaliveTimeout specifies the length of the period for which the // call should wait for PING ACK. If PING ACK is not received after this period, the call fails. // Negative values are invalid; setting these parameters to negative value will reset the -// corresponding parameter to the internal default value. +// corresponding parameter to 0. @property(readwrite) NSTimeInterval keepaliveInterval; @property(readwrite) NSTimeInterval keepaliveTimeout; diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.m b/src/objective-c/GRPCClient/GRPCCallOptions.m index f02486a7c44..392e42a9d47 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.m +++ b/src/objective-c/GRPCClient/GRPCCallOptions.m @@ -30,7 +30,7 @@ static const NSUInteger kDefaultResponseSizeLimit = 0; static const GRPCCompressionAlgorithm kDefaultCompressionAlgorithm = GRPCCompressNone; static const BOOL kDefaultRetryEnabled = YES; static const NSTimeInterval kDefaultKeepaliveInterval = 0; -static const NSTimeInterval kDefaultKeepaliveTimeout = -1; +static const NSTimeInterval kDefaultKeepaliveTimeout = 0; static const NSTimeInterval kDefaultConnectMinTimeout = 0; static const NSTimeInterval kDefaultConnectInitialBackoff = 0; static const NSTimeInterval kDefaultConnectMaxBackoff = 0; @@ -181,7 +181,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { _compressionAlgorithm = compressionAlgorithm; _retryEnabled = retryEnabled; _keepaliveInterval = keepaliveInterval < 0 ? 0 : keepaliveInterval; - _keepaliveTimeout = keepaliveTimeout; + _keepaliveTimeout = keepaliveTimeout < 0 ? 0 : keepaliveTimeout; _connectMinTimeout = connectMinTimeout < 0 ? 0 : connectMinTimeout; _connectInitialBackoff = connectInitialBackoff < 0 ? 0 : connectInitialBackoff; _connectMaxBackoff = connectMaxBackoff < 0 ? 0 : connectMaxBackoff; @@ -486,7 +486,11 @@ static BOOL areObjectsEqual(id obj1, id obj2) { } - (void)setKeepaliveTimeout:(NSTimeInterval)keepaliveTimeout { - _keepaliveTimeout = keepaliveTimeout; + if (keepaliveTimeout < 0) { + _keepaliveTimeout = 0; + } else { + _keepaliveTimeout = keepaliveTimeout; + } } - (void)setConnectMinTimeout:(NSTimeInterval)connectMinTimeout { diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m index 4a187ae9081..1a79fb04a0d 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCChannel.m @@ -109,8 +109,6 @@ if (_callOptions.keepaliveInterval != 0) { args[@GRPC_ARG_KEEPALIVE_TIME_MS] = [NSNumber numberWithUnsignedInteger:(NSUInteger)(_callOptions.keepaliveInterval * 1000)]; - } - if (_callOptions.keepaliveTimeout >= 0) { args[@GRPC_ARG_KEEPALIVE_TIMEOUT_MS] = [NSNumber numberWithUnsignedInteger:(NSUInteger)(_callOptions.keepaliveTimeout * 1000)]; } diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.m b/src/objective-c/GRPCClient/private/GRPCChannelPool.m index 24ed83d3341..60a33eda824 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannelPool.m +++ b/src/objective-c/GRPCClient/private/GRPCChannelPool.m @@ -118,7 +118,9 @@ static const NSTimeInterval kDefaultChannelDestroyDelay = 30; _lastTimedDestroy = nil; grpc_call *unmanagedCall = - [_wrappedChannel unmanagedCallWithPath:path completionQueue:queue callOptions:callOptions]; + [_wrappedChannel unmanagedCallWithPath:path + completionQueue:[GRPCCompletionQueue completionQueue] + callOptions:callOptions]; if (unmanagedCall == NULL) { NSAssert(unmanagedCall != NULL, @"Unable to create grpc_call object"); return nil; diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m index c4287731efd..24348c3aed7 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCHost.m @@ -105,11 +105,11 @@ static NSMutableDictionary *gHostCache; options.responseSizeLimit = _responseSizeLimitOverride; options.compressionAlgorithm = (GRPCCompressionAlgorithm)_compressAlgorithm; options.retryEnabled = _retryEnabled; - options.keepaliveInterval = (NSTimeInterval)_keepaliveInterval / 1000.0; - options.keepaliveTimeout = (NSTimeInterval)_keepaliveTimeout / 1000.0; - options.connectMinTimeout = (NSTimeInterval)_minConnectTimeout / 1000.0; - options.connectInitialBackoff = (NSTimeInterval)_initialConnectBackoff / 1000.0; - options.connectMaxBackoff = (NSTimeInterval)_maxConnectBackoff / 1000.0; + options.keepaliveInterval = (NSTimeInterval)_keepaliveInterval / 1000; + options.keepaliveTimeout = (NSTimeInterval)_keepaliveTimeout / 1000; + options.connectMinTimeout = (NSTimeInterval)_minConnectTimeout / 1000; + options.connectInitialBackoff = (NSTimeInterval)_initialConnectBackoff / 1000; + options.connectMaxBackoff = (NSTimeInterval)_maxConnectBackoff / 1000; options.PEMRootCertificates = _PEMRootCertificates; options.PEMPrivateKey = _PEMPrivateKey; options.PEMCertificateChain = _PEMCertificateChain; diff --git a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m index 30741e9a0da..a2a79c46316 100644 --- a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m +++ b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m @@ -48,10 +48,6 @@ static int32_t kRemoteInteropServerOverhead = 12; return YES; } -+ (BOOL)canRunCompressionTest { - return NO; -} - - (int32_t)encodingOverhead { return kRemoteInteropServerOverhead; // bytes } diff --git a/src/objective-c/tests/InteropTests/InteropTests.h b/src/objective-c/tests/InteropTests/InteropTests.h index 0c896ae18a8..cffa90ac497 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.h +++ b/src/objective-c/tests/InteropTests/InteropTests.h @@ -64,10 +64,4 @@ */ + (BOOL)useCronet; -/** - * Whether we can run compression tests in the test suite. - */ - -+ (BOOL)canRunCompressionTest; - @end diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index e55849fecfa..91e133a1300 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -347,10 +347,6 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager return NO; } -+ (BOOL)canRunCompressionTest { - return YES; -} - + (void)setUp { #ifdef GRPC_COMPILE_WITH_CRONET configureCronet(); @@ -434,16 +430,10 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager __block BOOL messageReceived = NO; __block BOOL done = NO; - __block BOOL initialMetadataReceived = YES; NSCondition *cond = [[NSCondition alloc] init]; GRPCUnaryProtoCall *call = [_service emptyCallWithMessage:request - responseHandler:[[InteropTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { - [cond lock]; - initialMetadataReceived = YES; - [cond unlock]; - } + responseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil messageCallback:^(id message) { if (message) { id expectedResponse = [GPBEmpty message]; @@ -469,7 +459,6 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager while (!done && [deadline timeIntervalSinceNow] > 0) { [cond waitUntilDate:deadline]; } - XCTAssertTrue(initialMetadataReceived); XCTAssertTrue(messageReceived); XCTAssertTrue(done); [cond unlock]; @@ -1025,78 +1014,6 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; } -- (void)testInitialMetadataWithV2API { - __weak XCTestExpectation *initialMetadataReceived = - [self expectationWithDescription:@"Received initial metadata."]; - __weak XCTestExpectation *closeReceived = [self expectationWithDescription:@"RPC completed."]; - - __block NSDictionary *init_md = - [NSDictionary dictionaryWithObjectsAndKeys:@"FOOBAR", @"x-grpc-test-echo-initial", nil]; - GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - options.initialMetadata = init_md; - options.transportType = self.class.transportType; - options.PEMRootCertificates = self.class.PEMRootCertificates; - options.hostNameOverride = [[self class] hostNameOverride]; - RMTSimpleRequest *request = [RMTSimpleRequest message]; - __block bool init_md_received = NO; - GRPCUnaryProtoCall *call = [_service - unaryCallWithMessage:request - responseHandler:[[InteropTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { - XCTAssertEqualObjects(initialMetadata[@"x-grpc-test-echo-initial"], - init_md[@"x-grpc-test-echo-initial"]); - init_md_received = YES; - [initialMetadataReceived fulfill]; - } - messageCallback:nil - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - XCTAssertNil(error, @"Unexpected error: %@", error); - [closeReceived fulfill]; - }] - callOptions:options]; - - [call start]; - [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; -} - -- (void)testTrailingMetadataWithV2API { - // This test needs to be disabled for remote test because interop server grpc-test - // does not send trailing binary metadata. - if (isRemoteInteropTest([[self class] host])) { - return; - } - - __weak XCTestExpectation *expectation = - [self expectationWithDescription:@"Received trailing metadata."]; - const unsigned char raw_bytes[] = {0x1, 0x2, 0x3, 0x4}; - NSData *trailer_data = [NSData dataWithBytes:raw_bytes length:sizeof(raw_bytes)]; - __block NSDictionary *trailer = [NSDictionary - dictionaryWithObjectsAndKeys:trailer_data, @"x-grpc-test-echo-trailing-bin", nil]; - GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - options.initialMetadata = trailer; - options.transportType = self.class.transportType; - options.PEMRootCertificates = self.class.PEMRootCertificates; - options.hostNameOverride = [[self class] hostNameOverride]; - RMTSimpleRequest *request = [RMTSimpleRequest message]; - GRPCUnaryProtoCall *call = [_service - unaryCallWithMessage:request - responseHandler: - [[InteropTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:nil - messageCallback:nil - closeCallback:^(NSDictionary *trailingMetadata, - NSError *error) { - XCTAssertNil(error, @"Unexpected error: %@", error); - XCTAssertEqualObjects( - trailingMetadata[@"x-grpc-test-echo-trailing-bin"], - trailer[@"x-grpc-test-echo-trailing-bin"]); - [expectation fulfill]; - }] - callOptions:options]; - [call start]; - [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; -} - - (void)testCancelAfterFirstResponseRPC { XCTAssertNotNil([[self class] host]); __weak XCTestExpectation *expectation = @@ -1231,7 +1148,13 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; } -- (void)RPCWithCompressMethod:(GRPCCompressionAlgorithm)compressMethod { +- (void)testCompressedUnaryRPC { + // This test needs to be disabled for remote test because interop server grpc-test + // does not support compression. + if (isRemoteInteropTest([[self class] host])) { + return; + } + XCTAssertNotNil([[self class] host]); __weak XCTestExpectation *expectation = [self expectationWithDescription:@"LargeUnary"]; RMTSimpleRequest *request = [RMTSimpleRequest message]; @@ -1239,7 +1162,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager request.responseSize = 314159; request.payload.body = [NSMutableData dataWithLength:271828]; request.expectCompressed.value = YES; - [GRPCCall setDefaultCompressMethod:compressMethod forhost:[[self class] host]]; + [GRPCCall setDefaultCompressMethod:GRPCCompressGzip forhost:[[self class] host]]; [_service unaryCallWithRequest:request handler:^(RMTSimpleResponse *response, NSError *error) { @@ -1256,67 +1179,6 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; } -- (void)RPCWithCompressMethodWithV2API:(GRPCCompressionAlgorithm)compressMethod { - __weak XCTestExpectation *expectMessage = - [self expectationWithDescription:@"Reived response from server."]; - __weak XCTestExpectation *expectComplete = [self expectationWithDescription:@"RPC completed."]; - - RMTSimpleRequest *request = [RMTSimpleRequest message]; - request.responseType = RMTPayloadType_Compressable; - request.responseSize = 314159; - request.payload.body = [NSMutableData dataWithLength:271828]; - request.expectCompressed.value = YES; - - GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - options.transportType = self.class.transportType; - options.PEMRootCertificates = self.class.PEMRootCertificates; - options.hostNameOverride = [[self class] hostNameOverride]; - options.compressionAlgorithm = compressMethod; - - GRPCUnaryProtoCall *call = [_service - unaryCallWithMessage:request - responseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil - messageCallback:^(id message) { - XCTAssertNotNil(message); - if (message) { - RMTSimpleResponse *expectedResponse = - [RMTSimpleResponse message]; - expectedResponse.payload.type = RMTPayloadType_Compressable; - expectedResponse.payload.body = - [NSMutableData dataWithLength:314159]; - XCTAssertEqualObjects(message, expectedResponse); - - [expectMessage fulfill]; - } - } - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - XCTAssertNil(error, @"Unexpected error: %@", error); - [expectComplete fulfill]; - }] - callOptions:options]; - [call start]; - - [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; -} - -- (void)testCompressedUnaryRPC { - if ([[self class] canRunCompressionTest]) { - for (GRPCCompressionAlgorithm compress = GRPCCompressDeflate; - compress <= GRPCStreamCompressGzip; ++compress) { - [self RPCWithCompressMethod:compress]; - } - } -} - -- (void)testCompressedUnaryRPCWithV2API { - if ([[self class] canRunCompressionTest]) { - for (GRPCCompressionAlgorithm compress = GRPCCompressDeflate; - compress <= GRPCStreamCompressGzip; ++compress) { - [self RPCWithCompressMethodWithV2API:compress]; - } - } -} - #ifndef GRPC_COMPILE_WITH_CRONET - (void)testKeepalive { XCTAssertNotNil([[self class] host]); @@ -1358,40 +1220,6 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; } - -- (void)testKeepaliveWithV2API { - XCTAssertNotNil([[self class] host]); - __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Keepalive"]; - - GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - options.transportType = self.class.transportType; - options.PEMRootCertificates = self.class.PEMRootCertificates; - options.hostNameOverride = [[self class] hostNameOverride]; - options.keepaliveInterval = 1.5; - options.keepaliveTimeout = 0; - - id request = - [RMTStreamingOutputCallRequest messageWithPayloadSize:@21782 requestedResponseSize:@31415]; - - __block GRPCStreamingProtoCall *call = [_service - fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:nil - messageCallback:nil - closeCallback:^( - NSDictionary *trailingMetadata, - NSError *error) { - XCTAssertNotNil(error); - XCTAssertEqual( - error.code, - GRPC_STATUS_UNAVAILABLE); - [expectation fulfill]; - }] - callOptions:options]; - [call start]; - [call writeMessage:request]; - - [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; -} #endif - (void)testDefaultInterceptor { diff --git a/src/objective-c/tests/InteropTests/InteropTestsRemote.m b/src/objective-c/tests/InteropTests/InteropTestsRemote.m index 7bd5b28780c..c1cd9b81efc 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsRemote.m +++ b/src/objective-c/tests/InteropTests/InteropTestsRemote.m @@ -49,10 +49,6 @@ static int32_t kRemoteInteropServerOverhead = 12; return nil; } -+ (BOOL)canRunCompressionTest { - return NO; -} - - (int32_t)encodingOverhead { return kRemoteInteropServerOverhead; // bytes } diff --git a/src/objective-c/tests/MacTests/StressTests.m b/src/objective-c/tests/MacTests/StressTests.m index 7475dc77fcc..22174b58665 100644 --- a/src/objective-c/tests/MacTests/StressTests.m +++ b/src/objective-c/tests/MacTests/StressTests.m @@ -29,7 +29,7 @@ #import #import -#define TEST_TIMEOUT 64 +#define TEST_TIMEOUT 32 extern const char *kCFStreamVarName; @@ -136,11 +136,7 @@ extern const char *kCFStreamVarName; return GRPCTransportTypeChttp2BoringSSL; } -- (int)getRandomNumberBetween:(int)min max:(int)max { - return min + arc4random_uniform((max - min + 1)); -} - -- (void)testNetworkFlapOnUnaryCallWithV2API { +- (void)testNetworkFlapWithV2API { NSMutableArray *completeExpectations = [NSMutableArray array]; NSMutableArray *calls = [NSMutableArray array]; int num_rpcs = 100; @@ -179,7 +175,6 @@ extern const char *kCFStreamVarName; UTF8String]); address_removed = YES; } else if (error != nil && !address_readded) { - XCTAssertTrue(address_removed); system([ [NSString stringWithFormat:@"sudo ifconfig lo0 alias %@", [[self class] hostAddress]] @@ -201,241 +196,7 @@ extern const char *kCFStreamVarName; [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; } -- (void)testNetworkFlapOnClientStreamingCallWithV2API { - NSMutableArray *completeExpectations = [NSMutableArray array]; - NSMutableArray *calls = [NSMutableArray array]; - int num_rpcs = 100; - __block BOOL address_removed = FALSE; - __block BOOL address_readded = FALSE; - for (int i = 0; i < num_rpcs; ++i) { - [completeExpectations - addObject:[self expectationWithDescription: - [NSString stringWithFormat:@"Received trailer for RPC %d", i]]]; - - GRPCStreamingProtoCall *call = [_service - streamingInputCallWithResponseHandler: - [[MacTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:nil - messageCallback:nil - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - @synchronized(self) { - if (error == nil && !address_removed) { - system([[NSString - stringWithFormat:@"sudo ifconfig lo0 -alias %@", - [[self class] hostAddress]] - UTF8String]); - address_removed = YES; - } else if (error != nil && !address_readded) { - XCTAssertTrue(address_removed); - system([[NSString - stringWithFormat:@"sudo ifconfig lo0 alias %@", - [[self class] hostAddress]] - UTF8String]); - address_readded = YES; - } - } - [completeExpectations[i] fulfill]; - }] - callOptions:nil]; - [calls addObject:call]; - } - - for (int i = 0; i < num_rpcs; ++i) { - GRPCStreamingProtoCall *call = calls[i]; - [call start]; - RMTStreamingInputCallRequest *request1 = [RMTStreamingInputCallRequest message]; - request1.payload.body = [NSMutableData dataWithLength:27182]; - RMTStreamingInputCallRequest *request2 = [RMTStreamingInputCallRequest message]; - request2.payload.body = [NSMutableData dataWithLength:8]; - - [call writeMessage:request1]; - [NSThread sleepForTimeInterval:0.1f]; - [call writeMessage:request2]; - [call finish]; - } - [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; -} - -- (void)testNetworkFlapOnServerStreamingCallWithV2API { - NSMutableArray *completeExpectations = [NSMutableArray array]; - NSMutableArray *calls = [NSMutableArray array]; - int num_rpcs = 100; - __block BOOL address_removed = FALSE; - __block BOOL address_readded = FALSE; - for (int i = 0; i < num_rpcs; ++i) { - [completeExpectations - addObject:[self expectationWithDescription: - [NSString stringWithFormat:@"Received trailer for RPC %d", i]]]; - - RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; - for (int i = 0; i < 5; i++) { - RMTResponseParameters *parameters = [RMTResponseParameters message]; - parameters.size = 10000; - [request.responseParametersArray addObject:parameters]; - } - - request.payload.body = [NSMutableData dataWithLength:100]; - - GRPCUnaryProtoCall *call = [_service - streamingOutputCallWithMessage:request - responseHandler: - [[MacTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:nil - messageCallback:nil - closeCallback:^(NSDictionary *trailingMetadata, - NSError *error) { - @synchronized(self) { - if (error == nil && !address_removed) { - system([[NSString - stringWithFormat: - @"sudo ifconfig lo0 -alias %@", - [[self class] hostAddress]] - UTF8String]); - address_removed = YES; - } else if (error != nil && !address_readded) { - XCTAssertTrue(address_removed); - system([[NSString - stringWithFormat: - @"sudo ifconfig lo0 alias %@", - [[self class] hostAddress]] - UTF8String]); - address_readded = YES; - } - } - [completeExpectations[i] fulfill]; - }] - callOptions:nil]; - [calls addObject:call]; - } - - for (int i = 0; i < num_rpcs; ++i) { - GRPCStreamingProtoCall *call = calls[i]; - [call start]; - [NSThread sleepForTimeInterval:0.1f]; - } - [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; -} - -- (void)testNetworkFlapOnHalfDuplexCallWithV2API { - NSMutableArray *completeExpectations = [NSMutableArray array]; - NSMutableArray *calls = [NSMutableArray array]; - int num_rpcs = 100; - __block BOOL address_removed = FALSE; - __block BOOL address_readded = FALSE; - for (int i = 0; i < num_rpcs; ++i) { - [completeExpectations - addObject:[self expectationWithDescription: - [NSString stringWithFormat:@"Received trailer for RPC %d", i]]]; - - GRPCStreamingProtoCall *call = [_service - halfDuplexCallWithResponseHandler: - [[MacTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:nil - messageCallback:nil - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - @synchronized(self) { - if (error == nil && !address_removed) { - system([[NSString - stringWithFormat:@"sudo ifconfig lo0 -alias %@", - [[self class] hostAddress]] - UTF8String]); - address_removed = YES; - } else if (error != nil && !address_readded) { - XCTAssertTrue(address_removed); - system([[NSString - stringWithFormat:@"sudo ifconfig lo0 alias %@", - [[self class] hostAddress]] - UTF8String]); - address_readded = YES; - } - } - [completeExpectations[i] fulfill]; - }] - callOptions:nil]; - [calls addObject:call]; - } - - for (int i = 0; i < num_rpcs; ++i) { - GRPCStreamingProtoCall *call = calls[i]; - [call start]; - RMTStreamingOutputCallRequest *request1 = [RMTStreamingOutputCallRequest message]; - RMTStreamingOutputCallRequest *request2 = [RMTStreamingOutputCallRequest message]; - for (int i = 0; i < 5; i++) { - RMTResponseParameters *parameters = [RMTResponseParameters message]; - parameters.size = 1000; - [request1.responseParametersArray addObject:parameters]; - [request2.responseParametersArray addObject:parameters]; - } - - request1.payload.body = [NSMutableData dataWithLength:100]; - request2.payload.body = [NSMutableData dataWithLength:100]; - - [call writeMessage:request1]; - [NSThread sleepForTimeInterval:0.1f]; - [call writeMessage:request2]; - [call finish]; - } - [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; -} - -- (void)testNetworkFlapOnFullDuplexCallWithV2API { - NSMutableArray *completeExpectations = [NSMutableArray array]; - NSMutableArray *calls = [NSMutableArray array]; - int num_rpcs = 100; - __block BOOL address_removed = FALSE; - __block BOOL address_readded = FALSE; - for (int i = 0; i < num_rpcs; ++i) { - [completeExpectations - addObject:[self expectationWithDescription: - [NSString stringWithFormat:@"Received trailer for RPC %d", i]]]; - - GRPCStreamingProtoCall *call = [_service - fullDuplexCallWithResponseHandler: - [[MacTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:nil - messageCallback:nil - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - @synchronized(self) { - if (error == nil && !address_removed) { - system([[NSString - stringWithFormat:@"sudo ifconfig lo0 -alias %@", - [[self class] hostAddress]] - UTF8String]); - address_removed = YES; - } else if (error != nil && !address_readded) { - XCTAssertTrue(address_removed); - system([[NSString - stringWithFormat:@"sudo ifconfig lo0 alias %@", - [[self class] hostAddress]] - UTF8String]); - address_readded = YES; - } - } - [completeExpectations[i] fulfill]; - }] - callOptions:nil]; - [calls addObject:call]; - } - - for (int i = 0; i < num_rpcs; ++i) { - GRPCStreamingProtoCall *call = calls[i]; - [call start]; - - RMTResponseParameters *parameters = [RMTResponseParameters message]; - parameters.size = 1000; - for (int i = 0; i < 5; i++) { - RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; - [request.responseParametersArray addObject:parameters]; - request.payload.body = [NSMutableData dataWithLength:100]; - [call writeMessage:request]; - } - [call finish]; - [NSThread sleepForTimeInterval:0.1f]; - } - [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; -} - -- (void)testNetworkFlapOnUnaryCallWithV1API { +- (void)testNetworkFlapWithV1API { NSMutableArray *completeExpectations = [NSMutableArray array]; int num_rpcs = 100; __block BOOL address_removed = FALSE; @@ -459,7 +220,6 @@ extern const char *kCFStreamVarName; UTF8String]); address_removed = YES; } else if (error != nil && !address_readded) { - XCTAssertTrue(address_removed); system([[NSString stringWithFormat:@"sudo ifconfig lo0 alias %@", [[self class] hostAddress]] UTF8String]); @@ -474,141 +234,4 @@ extern const char *kCFStreamVarName; } } -- (void)testTimeoutOnFullDuplexCallWithV2API { - NSMutableArray *completeExpectations = [NSMutableArray array]; - NSMutableArray *calls = [NSMutableArray array]; - int num_rpcs = 100; - GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - options.transportType = [[self class] transportType]; - options.PEMRootCertificates = [[self class] PEMRootCertificates]; - options.hostNameOverride = [[self class] hostNameOverride]; - options.timeout = 0.3; - for (int i = 0; i < num_rpcs; ++i) { - [completeExpectations - addObject:[self expectationWithDescription: - [NSString stringWithFormat:@"Received trailer for RPC %d", i]]]; - - GRPCStreamingProtoCall *call = [_service - fullDuplexCallWithResponseHandler: - [[MacTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:nil - messageCallback:nil - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - if (error != nil) { - XCTAssertEqual(error.code, GRPC_STATUS_DEADLINE_EXCEEDED); - } - [completeExpectations[i] fulfill]; - }] - callOptions:options]; - [calls addObject:call]; - } - - for (int i = 0; i < num_rpcs; ++i) { - GRPCStreamingProtoCall *call = calls[i]; - [call start]; - RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; - RMTResponseParameters *parameters = [RMTResponseParameters message]; - parameters.size = 1000; - // delay response by 100-200 milliseconds - parameters.intervalUs = [self getRandomNumberBetween:100 * 1000 max:200 * 1000]; - [request.responseParametersArray addObject:parameters]; - request.payload.body = [NSMutableData dataWithLength:100]; - - [call writeMessage:request]; - [call writeMessage:request]; - [call finish]; - } - [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; -} - -- (void)testServerStreamingCallSlowClientWithV2API { - NSMutableArray *completeExpectations = [NSMutableArray array]; - NSMutableArray *calls = [NSMutableArray array]; - int num_rpcs = 100; - dispatch_queue_t q = dispatch_queue_create(NULL, DISPATCH_QUEUE_CONCURRENT); - for (int i = 0; i < num_rpcs; ++i) { - [completeExpectations - addObject:[self expectationWithDescription: - [NSString stringWithFormat:@"Received trailer for RPC %d", i]]]; - - RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; - for (int i = 0; i < 5; i++) { - RMTResponseParameters *parameters = [RMTResponseParameters message]; - parameters.size = 10000; - [request.responseParametersArray addObject:parameters]; - [request.responseParametersArray addObject:parameters]; - [request.responseParametersArray addObject:parameters]; - [request.responseParametersArray addObject:parameters]; - [request.responseParametersArray addObject:parameters]; - } - - request.payload.body = [NSMutableData dataWithLength:100]; - - GRPCUnaryProtoCall *call = [_service - streamingOutputCallWithMessage:request - responseHandler:[[MacTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:nil - messageCallback:^(id message) { - // inject a delay - [NSThread sleepForTimeInterval:0.5f]; - } - closeCallback:^(NSDictionary *trailingMetadata, - NSError *error) { - XCTAssertNil(error, @"Unexpected error: %@", error); - [completeExpectations[i] fulfill]; - }] - callOptions:nil]; - [calls addObject:call]; - } - - for (int i = 0; i < num_rpcs; ++i) { - dispatch_async(q, ^{ - GRPCStreamingProtoCall *call = calls[i]; - [call start]; - }); - } - [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; -} - -- (void)testCancelOnFullDuplexCallWithV2API { - NSMutableArray *completeExpectations = [NSMutableArray array]; - NSMutableArray *calls = [NSMutableArray array]; - int num_rpcs = 100; - dispatch_queue_t q = dispatch_queue_create(NULL, DISPATCH_QUEUE_CONCURRENT); - for (int i = 0; i < num_rpcs; ++i) { - [completeExpectations - addObject:[self expectationWithDescription: - [NSString stringWithFormat:@"Received trailer for RPC %d", i]]]; - - GRPCStreamingProtoCall *call = [_service - fullDuplexCallWithResponseHandler:[[MacTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:nil - messageCallback:nil - closeCallback:^( - NSDictionary *trailingMetadata, - NSError *error) { - [completeExpectations[i] fulfill]; - }] - callOptions:nil]; - [calls addObject:call]; - } - - for (int i = 0; i < num_rpcs; ++i) { - GRPCStreamingProtoCall *call = calls[i]; - [call start]; - dispatch_async(q, ^{ - RMTResponseParameters *parameters = [RMTResponseParameters message]; - parameters.size = 1000; - for (int i = 0; i < 100; i++) { - RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; - [request.responseParametersArray addObject:parameters]; - [call writeMessage:request]; - } - [NSThread sleepForTimeInterval:0.01f]; - [call cancel]; - }); - } - [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; -} - @end diff --git a/src/objective-c/tests/UnitTests/APIv2Tests.m b/src/objective-c/tests/UnitTests/APIv2Tests.m index 066800613f6..db293750ca3 100644 --- a/src/objective-c/tests/UnitTests/APIv2Tests.m +++ b/src/objective-c/tests/UnitTests/APIv2Tests.m @@ -21,11 +21,6 @@ #import #import -#import "../../GRPCClient/private/GRPCCallInternal.h" -#import "../../GRPCClient/private/GRPCChannel.h" -#import "../../GRPCClient/private/GRPCChannelPool.h" -#import "../../GRPCClient/private/GRPCWrappedCall.h" - #include #include @@ -53,41 +48,12 @@ static const int kSimpleDataLength = 100; static const NSTimeInterval kTestTimeout = 8; static const NSTimeInterval kInvertedTimeout = 2; -// Reveal the _class ivars for testing access +// Reveal the _class ivar for testing access @interface GRPCCall2 () { - @public - id _firstInterceptor; -} -@end - -@interface GRPCCall2Internal () { @public GRPCCall *_call; } -@end -@interface GRPCCall () { - @public - GRPCWrappedCall *_wrappedCall; -} -@end - -@interface GRPCWrappedCall () { - @public - GRPCPooledChannel *_pooledChannel; -} -@end - -@interface GRPCPooledChannel () { - @public - GRPCChannel *_wrappedChannel; -} -@end - -@interface GRPCChannel () { - @public - grpc_channel *_unmanagedChannel; -} @end // Convenience class to use blocks as callbacks @@ -182,7 +148,6 @@ static const NSTimeInterval kInvertedTimeout = 2; kOutputStreamingCallMethod = [[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"StreamingOutputCall"]; - kFullDuplexCallMethod = [[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"FullDuplexCall"]; } @@ -214,7 +179,7 @@ static const NSTimeInterval kInvertedTimeout = 2; closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { trailing_md = trailingMetadata; if (error) { - XCTAssertEqual(error.code, GRPCErrorCodeUnauthenticated, + XCTAssertEqual(error.code, 16, @"Finished with unexpected error: %@", error); XCTAssertEqualObjects(init_md, error.userInfo[kGRPCHeadersKey]); @@ -794,7 +759,7 @@ static const NSTimeInterval kInvertedTimeout = 2; } closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { XCTAssertNotNil(error, @"Expecting non-nil error"); - XCTAssertEqual(error.code, GRPCErrorCodeUnknown); + XCTAssertEqual(error.code, 2); [completion fulfill]; }] callOptions:options]; @@ -805,293 +770,4 @@ static const NSTimeInterval kInvertedTimeout = 2; [self waitForExpectationsWithTimeout:kTestTimeout handler:nil]; } -- (void)testAdditionalChannelArgs { - __weak XCTestExpectation *completion = [self expectationWithDescription:@"RPC completed."]; - - GRPCRequestOptions *requestOptions = - [[GRPCRequestOptions alloc] initWithHost:kHostAddress - path:kUnaryCallMethod.HTTPPath - safety:GRPCCallSafetyDefault]; - GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - // set max message length = 1 byte. - options.additionalChannelArgs = - [NSDictionary dictionaryWithObjectsAndKeys:@1, @GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, nil]; - options.transportType = GRPCTransportTypeInsecure; - - RMTSimpleRequest *request = [RMTSimpleRequest message]; - request.payload.body = [NSMutableData dataWithLength:options.responseSizeLimit]; - - GRPCCall2 *call = [[GRPCCall2 alloc] - initWithRequestOptions:requestOptions - responseHandler:[[ClientTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil - messageCallback:^(NSData *data) { - XCTFail(@"Received unexpected message"); - } - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - XCTAssertNotNil(error, @"Expecting non-nil error"); - NSLog(@"Got error: %@", error); - XCTAssertEqual(error.code, GRPCErrorCodeResourceExhausted, - @"Finished with unexpected error: %@", error); - - [completion fulfill]; - }] - callOptions:options]; - [call writeData:[request data]]; - [call start]; - [call finish]; - - [self waitForExpectationsWithTimeout:kTestTimeout handler:nil]; -} - -- (void)testChannelReuseIdentical { - __weak XCTestExpectation *completion1 = [self expectationWithDescription:@"RPC1 completed."]; - __weak XCTestExpectation *completion2 = [self expectationWithDescription:@"RPC2 completed."]; - NSArray *rpcDone = [NSArray arrayWithObjects:completion1, completion2, nil]; - __weak XCTestExpectation *metadata1 = - [self expectationWithDescription:@"Received initial metadata for RPC1."]; - __weak XCTestExpectation *metadata2 = - [self expectationWithDescription:@"Received initial metadata for RPC2."]; - NSArray *initialMetadataDone = [NSArray arrayWithObjects:metadata1, metadata2, nil]; - - RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; - RMTResponseParameters *parameters = [RMTResponseParameters message]; - parameters.size = kSimpleDataLength; - [request.responseParametersArray addObject:parameters]; - request.payload.body = [NSMutableData dataWithLength:kSimpleDataLength]; - - GRPCRequestOptions *requestOptions = - [[GRPCRequestOptions alloc] initWithHost:kHostAddress - path:kFullDuplexCallMethod.HTTPPath - safety:GRPCCallSafetyDefault]; - GRPCMutableCallOptions *callOptions = [[GRPCMutableCallOptions alloc] init]; - callOptions.transportType = GRPCTransportTypeInsecure; - GRPCCall2 *call1 = [[GRPCCall2 alloc] - initWithRequestOptions:requestOptions - responseHandler:[[ClientTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { - [metadata1 fulfill]; - } - messageCallback:nil - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - [completion1 fulfill]; - }] - callOptions:callOptions]; - GRPCCall2 *call2 = [[GRPCCall2 alloc] - initWithRequestOptions:requestOptions - responseHandler:[[ClientTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { - [metadata2 fulfill]; - } - messageCallback:nil - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - [completion2 fulfill]; - }] - callOptions:callOptions]; - [call1 start]; - [call2 start]; - [call1 writeData:[request data]]; - [call2 writeData:[request data]]; - [self waitForExpectations:initialMetadataDone timeout:kTestTimeout]; - GRPCCall2Internal *internalCall1 = call1->_firstInterceptor; - GRPCCall2Internal *internalCall2 = call2->_firstInterceptor; - XCTAssertEqual( - internalCall1->_call->_wrappedCall->_pooledChannel->_wrappedChannel->_unmanagedChannel, - internalCall2->_call->_wrappedCall->_pooledChannel->_wrappedChannel->_unmanagedChannel); - [call1 finish]; - [call2 finish]; - [self waitForExpectations:rpcDone timeout:kTestTimeout]; -} - -- (void)testChannelReuseDifferentCallSafety { - __weak XCTestExpectation *completion1 = [self expectationWithDescription:@"RPC1 completed."]; - __weak XCTestExpectation *completion2 = [self expectationWithDescription:@"RPC2 completed."]; - NSArray *rpcDone = [NSArray arrayWithObjects:completion1, completion2, nil]; - __weak XCTestExpectation *metadata1 = - [self expectationWithDescription:@"Received initial metadata for RPC1."]; - __weak XCTestExpectation *metadata2 = - [self expectationWithDescription:@"Received initial metadata for RPC2."]; - NSArray *initialMetadataDone = [NSArray arrayWithObjects:metadata1, metadata2, nil]; - - RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; - RMTResponseParameters *parameters = [RMTResponseParameters message]; - parameters.size = kSimpleDataLength; - [request.responseParametersArray addObject:parameters]; - request.payload.body = [NSMutableData dataWithLength:kSimpleDataLength]; - - GRPCRequestOptions *requestOptions1 = - [[GRPCRequestOptions alloc] initWithHost:kHostAddress - path:kFullDuplexCallMethod.HTTPPath - safety:GRPCCallSafetyDefault]; - GRPCRequestOptions *requestOptions2 = - [[GRPCRequestOptions alloc] initWithHost:kHostAddress - path:kFullDuplexCallMethod.HTTPPath - safety:GRPCCallSafetyIdempotentRequest]; - - GRPCMutableCallOptions *callOptions = [[GRPCMutableCallOptions alloc] init]; - callOptions.transportType = GRPCTransportTypeInsecure; - GRPCCall2 *call1 = [[GRPCCall2 alloc] - initWithRequestOptions:requestOptions1 - responseHandler:[[ClientTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { - [metadata1 fulfill]; - } - messageCallback:nil - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - [completion1 fulfill]; - }] - callOptions:callOptions]; - GRPCCall2 *call2 = [[GRPCCall2 alloc] - initWithRequestOptions:requestOptions2 - responseHandler:[[ClientTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { - [metadata2 fulfill]; - } - messageCallback:nil - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - [completion2 fulfill]; - }] - callOptions:callOptions]; - [call1 start]; - [call2 start]; - [call1 writeData:[request data]]; - [call2 writeData:[request data]]; - [self waitForExpectations:initialMetadataDone timeout:kTestTimeout]; - GRPCCall2Internal *internalCall1 = call1->_firstInterceptor; - GRPCCall2Internal *internalCall2 = call2->_firstInterceptor; - XCTAssertEqual( - internalCall1->_call->_wrappedCall->_pooledChannel->_wrappedChannel->_unmanagedChannel, - internalCall2->_call->_wrappedCall->_pooledChannel->_wrappedChannel->_unmanagedChannel); - [call1 finish]; - [call2 finish]; - [self waitForExpectations:rpcDone timeout:kTestTimeout]; -} - -- (void)testChannelReuseDifferentHost { - __weak XCTestExpectation *completion1 = [self expectationWithDescription:@"RPC1 completed."]; - __weak XCTestExpectation *completion2 = [self expectationWithDescription:@"RPC2 completed."]; - NSArray *rpcDone = [NSArray arrayWithObjects:completion1, completion2, nil]; - __weak XCTestExpectation *metadata1 = - [self expectationWithDescription:@"Received initial metadata for RPC1."]; - __weak XCTestExpectation *metadata2 = - [self expectationWithDescription:@"Received initial metadata for RPC2."]; - NSArray *initialMetadataDone = [NSArray arrayWithObjects:metadata1, metadata2, nil]; - - RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; - RMTResponseParameters *parameters = [RMTResponseParameters message]; - parameters.size = kSimpleDataLength; - [request.responseParametersArray addObject:parameters]; - request.payload.body = [NSMutableData dataWithLength:kSimpleDataLength]; - - GRPCRequestOptions *requestOptions1 = - [[GRPCRequestOptions alloc] initWithHost:@"[::1]:5050" - path:kFullDuplexCallMethod.HTTPPath - safety:GRPCCallSafetyDefault]; - GRPCRequestOptions *requestOptions2 = - [[GRPCRequestOptions alloc] initWithHost:@"127.0.0.1:5050" - path:kFullDuplexCallMethod.HTTPPath - safety:GRPCCallSafetyDefault]; - - GRPCMutableCallOptions *callOptions = [[GRPCMutableCallOptions alloc] init]; - callOptions.transportType = GRPCTransportTypeInsecure; - - GRPCCall2 *call1 = [[GRPCCall2 alloc] - initWithRequestOptions:requestOptions1 - responseHandler:[[ClientTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { - [metadata1 fulfill]; - } - messageCallback:nil - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - [completion1 fulfill]; - }] - callOptions:callOptions]; - GRPCCall2 *call2 = [[GRPCCall2 alloc] - initWithRequestOptions:requestOptions2 - responseHandler:[[ClientTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { - [metadata2 fulfill]; - } - messageCallback:nil - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - [completion2 fulfill]; - }] - callOptions:callOptions]; - [call1 start]; - [call2 start]; - [call1 writeData:[request data]]; - [call2 writeData:[request data]]; - [self waitForExpectations:initialMetadataDone timeout:kTestTimeout]; - GRPCCall2Internal *internalCall1 = call1->_firstInterceptor; - GRPCCall2Internal *internalCall2 = call2->_firstInterceptor; - XCTAssertNotEqual( - internalCall1->_call->_wrappedCall->_pooledChannel->_wrappedChannel->_unmanagedChannel, - internalCall2->_call->_wrappedCall->_pooledChannel->_wrappedChannel->_unmanagedChannel); - [call1 finish]; - [call2 finish]; - [self waitForExpectations:rpcDone timeout:kTestTimeout]; -} - -- (void)testChannelReuseDifferentChannelArgs { - __weak XCTestExpectation *completion1 = [self expectationWithDescription:@"RPC1 completed."]; - __weak XCTestExpectation *completion2 = [self expectationWithDescription:@"RPC2 completed."]; - NSArray *rpcDone = [NSArray arrayWithObjects:completion1, completion2, nil]; - __weak XCTestExpectation *metadata1 = - [self expectationWithDescription:@"Received initial metadata for RPC1."]; - __weak XCTestExpectation *metadata2 = - [self expectationWithDescription:@"Received initial metadata for RPC2."]; - NSArray *initialMetadataDone = [NSArray arrayWithObjects:metadata1, metadata2, nil]; - - RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; - RMTResponseParameters *parameters = [RMTResponseParameters message]; - parameters.size = kSimpleDataLength; - [request.responseParametersArray addObject:parameters]; - request.payload.body = [NSMutableData dataWithLength:kSimpleDataLength]; - - GRPCRequestOptions *requestOptions = - [[GRPCRequestOptions alloc] initWithHost:kHostAddress - path:kFullDuplexCallMethod.HTTPPath - safety:GRPCCallSafetyDefault]; - GRPCMutableCallOptions *callOptions1 = [[GRPCMutableCallOptions alloc] init]; - callOptions1.transportType = GRPCTransportTypeInsecure; - GRPCMutableCallOptions *callOptions2 = [[GRPCMutableCallOptions alloc] init]; - callOptions2.transportType = GRPCTransportTypeInsecure; - callOptions2.channelID = 2; - - GRPCCall2 *call1 = [[GRPCCall2 alloc] - initWithRequestOptions:requestOptions - responseHandler:[[ClientTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { - [metadata1 fulfill]; - } - messageCallback:nil - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - [completion1 fulfill]; - }] - callOptions:callOptions1]; - GRPCCall2 *call2 = [[GRPCCall2 alloc] - initWithRequestOptions:requestOptions - responseHandler:[[ClientTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) { - [metadata2 fulfill]; - } - messageCallback:nil - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - [completion2 fulfill]; - }] - callOptions:callOptions2]; - [call1 start]; - [call2 start]; - [call1 writeData:[request data]]; - [call2 writeData:[request data]]; - [self waitForExpectations:initialMetadataDone timeout:kTestTimeout]; - GRPCCall2Internal *internalCall1 = call1->_firstInterceptor; - GRPCCall2Internal *internalCall2 = call2->_firstInterceptor; - XCTAssertNotEqual( - internalCall1->_call->_wrappedCall->_pooledChannel->_wrappedChannel->_unmanagedChannel, - internalCall2->_call->_wrappedCall->_pooledChannel->_wrappedChannel->_unmanagedChannel); - [call1 finish]; - [call2 finish]; - [self waitForExpectations:rpcDone timeout:kTestTimeout]; -} - @end diff --git a/test/cpp/interop/interop_server.cc b/test/cpp/interop/interop_server.cc index cf55efa5409..6570bbf9696 100644 --- a/test/cpp/interop/interop_server.cc +++ b/test/cpp/interop/interop_server.cc @@ -118,8 +118,7 @@ bool CheckExpectedCompression(const ServerContext& context, "Expected compression but got uncompressed request from client."); return false; } - if (!(inspector.GetMessageFlags() & GRPC_WRITE_INTERNAL_COMPRESS) && - received_compression != GRPC_COMPRESS_STREAM_GZIP) { + if (!(inspector.GetMessageFlags() & GRPC_WRITE_INTERNAL_COMPRESS)) { gpr_log(GPR_ERROR, "Failure: Requested compression in a compressable request, but " "compression bit in message flags not set."); From e00aeaeb2696ef710c0faed713b4ed5ace87b330 Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Wed, 12 Jun 2019 23:57:54 +0000 Subject: [PATCH 0511/1555] Fix bugs with libuv cares integration on Windows --- src/core/lib/iomgr/port.h | 6 +++++- src/core/lib/iomgr/tcp_uv.cc | 11 +++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/core/lib/iomgr/port.h b/src/core/lib/iomgr/port.h index 605692ac0d6..63a0269ed62 100644 --- a/src/core/lib/iomgr/port.h +++ b/src/core/lib/iomgr/port.h @@ -26,6 +26,11 @@ #define GRPC_CUSTOM_SOCKET #endif #endif +/* This needs to be separate from the other conditions because it needs to + * apply to custom sockets too */ +#ifdef GPR_WINDOWS +#define GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY 1 +#endif #if defined(GRPC_CUSTOM_SOCKET) // Do Nothing #elif defined(GPR_MANYLINUX1) @@ -45,7 +50,6 @@ #define GRPC_WINSOCK_SOCKET 1 #define GRPC_WINDOWS_SOCKETUTILS 1 #define GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER 1 -#define GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY 1 #elif defined(GPR_ANDROID) #define GRPC_HAVE_IPV6_RECVPKTINFO 1 #define GRPC_HAVE_IP_PKTINFO 1 diff --git a/src/core/lib/iomgr/tcp_uv.cc b/src/core/lib/iomgr/tcp_uv.cc index e53ff472fef..f0847a195ca 100644 --- a/src/core/lib/iomgr/tcp_uv.cc +++ b/src/core/lib/iomgr/tcp_uv.cc @@ -53,7 +53,7 @@ typedef struct uv_socket_t { char* read_buf; size_t read_len; - bool pending_connection; + int pending_connections; grpc_custom_socket* accept_socket; grpc_error* accept_error; @@ -206,7 +206,7 @@ static grpc_error* uv_socket_init_helper(uv_socket_t* uv_socket, int domain) { // Node uses a garbage collector to call destructors, so we don't // want to hold the uv loop open with active gRPC objects. uv_unref((uv_handle_t*)uv_socket->handle); - uv_socket->pending_connection = false; + uv_socket->pending_connections = 0; uv_socket->accept_socket = nullptr; uv_socket->accept_error = GRPC_ERROR_NONE; return GRPC_ERROR_NONE; @@ -243,14 +243,14 @@ static grpc_error* uv_socket_getsockname(grpc_custom_socket* socket, static void accept_new_connection(grpc_custom_socket* socket) { uv_socket_t* uv_socket = (uv_socket_t*)socket->impl; - if (!uv_socket->pending_connection || !uv_socket->accept_socket) { + if (uv_socket->pending_connections == 0 || !uv_socket->accept_socket) { return; } grpc_custom_socket* new_socket = uv_socket->accept_socket; grpc_error* error = uv_socket->accept_error; uv_socket->accept_socket = nullptr; uv_socket->accept_error = GRPC_ERROR_NONE; - uv_socket->pending_connection = false; + uv_socket->pending_connections -= 1; if (uv_socket->accept_error != GRPC_ERROR_NONE) { uv_stream_t dummy_handle; uv_accept((uv_stream_t*)uv_socket->handle, &dummy_handle); @@ -270,8 +270,6 @@ static void accept_new_connection(grpc_custom_socket* socket) { static void uv_on_connect(uv_stream_t* server, int status) { grpc_custom_socket* socket = (grpc_custom_socket*)server->data; uv_socket_t* uv_socket = (uv_socket_t*)socket->impl; - GPR_ASSERT(!uv_socket->pending_connection); - uv_socket->pending_connection = true; if (status < 0) { switch (status) { case UV_EINTR: @@ -281,6 +279,7 @@ static void uv_on_connect(uv_stream_t* server, int status) { uv_socket->accept_error = tcp_error_create("accept failed", status); } } + uv_socket->pending_connections += 1; accept_new_connection(socket); } From 16e66c83070f2900f520520ab9ce48a4ce137cb0 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 13 Jun 2019 08:16:03 -0700 Subject: [PATCH 0512/1555] Fix debug logging of stream refcounts. --- src/core/ext/filters/client_channel/client_channel.cc | 7 +++++++ src/core/lib/transport/transport.cc | 2 +- src/core/lib/transport/transport.h | 10 ++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 81562ab2107..0b612e67a33 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -1180,6 +1180,10 @@ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error) interested_parties_(grpc_pollset_set_create()), subchannel_pool_(GetSubchannelPool(args->channel_args)), disconnect_error_(GRPC_ERROR_NONE) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { + gpr_log(GPR_INFO, "chand=%p: creating client_channel for channel stack %p", + this, owning_stack_); + } // Initialize data members. grpc_connectivity_state_init(&state_tracker_, GRPC_CHANNEL_IDLE, "client_channel"); @@ -1259,6 +1263,9 @@ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error) } ChannelData::~ChannelData() { + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { + gpr_log(GPR_INFO, "chand=%p: destroying channel", this); + } if (resolving_lb_policy_ != nullptr) { grpc_pollset_set_del_pollset_set(resolving_lb_policy_->interested_parties(), interested_parties_); diff --git a/src/core/lib/transport/transport.cc b/src/core/lib/transport/transport.cc index 29c1e561891..80ffabce0e5 100644 --- a/src/core/lib/transport/transport.cc +++ b/src/core/lib/transport/transport.cc @@ -90,7 +90,7 @@ void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs, #endif GRPC_CLOSURE_INIT(&refcount->destroy, cb, cb_arg, grpc_schedule_on_exec_ctx); - new (&refcount->refs) grpc_core::RefCount(); + new (&refcount->refs) grpc_core::RefCount(1, &grpc_trace_stream_refcount); new (&refcount->slice_refcount) grpc_slice_refcount( grpc_slice_refcount::Type::REGULAR, &refcount->refs, slice_stream_destroy, refcount, &refcount->slice_refcount); diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h index a6a6e904f08..17608f4bc60 100644 --- a/src/core/lib/transport/transport.h +++ b/src/core/lib/transport/transport.h @@ -80,11 +80,13 @@ inline void grpc_stream_ref(grpc_stream_refcount* refcount, gpr_log(GPR_DEBUG, "%s %p:%p REF %s", refcount->object_type, refcount, refcount->destroy.cb_arg, reason); } + refcount->refs.RefNonZero(DEBUG_LOCATION, reason); +} #else inline void grpc_stream_ref(grpc_stream_refcount* refcount) { -#endif refcount->refs.RefNonZero(); } +#endif void grpc_stream_destroy(grpc_stream_refcount* refcount); @@ -95,13 +97,17 @@ inline void grpc_stream_unref(grpc_stream_refcount* refcount, gpr_log(GPR_DEBUG, "%s %p:%p UNREF %s", refcount->object_type, refcount, refcount->destroy.cb_arg, reason); } + if (GPR_UNLIKELY(refcount->refs.Unref(DEBUG_LOCATION, reason))) { + grpc_stream_destroy(refcount); + } +} #else inline void grpc_stream_unref(grpc_stream_refcount* refcount) { -#endif if (GPR_UNLIKELY(refcount->refs.Unref())) { grpc_stream_destroy(refcount); } } +#endif /* Wrap a buffer that is owned by some stream object into a slice that shares the same refcount */ From 9417a6a08075e3a898072c8742fe4e207ce601d6 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 13 Jun 2019 08:43:56 -0700 Subject: [PATCH 0513/1555] Various LB policy tracing improvements. --- .../ext/filters/client_channel/lb_policy.h | 2 + .../lb_policy/pick_first/pick_first.cc | 14 +-- .../lb_policy/round_robin/round_robin.cc | 4 +- .../client_channel/lb_policy/xds/xds.cc | 100 ++++++++++++++---- 4 files changed, 93 insertions(+), 27 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h index d508932015d..f98a41dee07 100644 --- a/src/core/ext/filters/client_channel/lb_policy.h +++ b/src/core/ext/filters/client_channel/lb_policy.h @@ -292,6 +292,8 @@ class LoadBalancingPolicy : public InternallyRefCounted { explicit QueuePicker(RefCountedPtr parent) : parent_(std::move(parent)) {} + ~QueuePicker() { parent_.reset(DEBUG_LOCATION, "QueuePicker"); } + PickResult Pick(PickArgs args) override; private: diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index e4b58eb7558..00036d8be64 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -329,7 +329,8 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( } else { p->channel_control_helper()->UpdateState( GRPC_CHANNEL_CONNECTING, - UniquePtr(New(p->Ref()))); + UniquePtr( + New(p->Ref(DEBUG_LOCATION, "QueuePicker")))); } } else { if (connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) { @@ -342,8 +343,8 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( p->selected_ = nullptr; CancelConnectivityWatchLocked("selected subchannel failed; going IDLE"); p->channel_control_helper()->UpdateState( - GRPC_CHANNEL_IDLE, - UniquePtr(New(p->Ref()))); + GRPC_CHANNEL_IDLE, UniquePtr(New( + p->Ref(DEBUG_LOCATION, "QueuePicker")))); } else { // This is unlikely but can happen when a subchannel has been asked // to reconnect by a different channel and this channel has dropped @@ -354,8 +355,8 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( connected_subchannel()->Ref()))); } else { // CONNECTING p->channel_control_helper()->UpdateState( - connectivity_state, - UniquePtr(New(p->Ref()))); + connectivity_state, UniquePtr(New( + p->Ref(DEBUG_LOCATION, "QueuePicker")))); } } } @@ -411,7 +412,8 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( if (subchannel_list() == p->subchannel_list_.get()) { p->channel_control_helper()->UpdateState( GRPC_CHANNEL_CONNECTING, - UniquePtr(New(p->Ref()))); + UniquePtr( + New(p->Ref(DEBUG_LOCATION, "QueuePicker")))); } break; } diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc index 17c65d8b551..c6655c7d9bb 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc @@ -323,8 +323,8 @@ void RoundRobin::RoundRobinSubchannelList:: } else if (num_connecting_ > 0) { /* 2) CONNECTING */ p->channel_control_helper()->UpdateState( - GRPC_CHANNEL_CONNECTING, - UniquePtr(New(p->Ref()))); + GRPC_CHANNEL_CONNECTING, UniquePtr(New( + p->Ref(DEBUG_LOCATION, "QueuePicker")))); } else if (num_transient_failure_ == num_subchannels()) { /* 3) TRANSIENT_FAILURE */ grpc_error* error = diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index 136d85bba14..e790ec25520 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -333,6 +333,8 @@ class XdsLb : public LoadBalancingPolicy { explicit FallbackHelper(RefCountedPtr parent) : parent_(std::move(parent)) {} + ~FallbackHelper() { parent_.reset(DEBUG_LOCATION, "FallbackHelper"); } + RefCountedPtr CreateSubchannel( const grpc_channel_args& args) override; grpc_channel* CreateChannel(const char* target, @@ -377,19 +379,30 @@ class XdsLb : public LoadBalancingPolicy { strcmp(subzone_.get(), other.subzone_.get()) == 0; } + const char* AsHumanReadableString() { + if (human_readable_string_ == nullptr) { + char* tmp; + gpr_asprintf(&tmp, "{region=\"%s\", zone=\"%s\", subzone=\"%s\"}", + region_.get(), zone_.get(), subzone_.get()); + human_readable_string_.reset(tmp); + } + return human_readable_string_.get(); + } + private: UniquePtr region_; UniquePtr zone_; UniquePtr subzone_; + UniquePtr human_readable_string_; }; class LocalityMap { public: class LocalityEntry : public InternallyRefCounted { public: - LocalityEntry(RefCountedPtr parent, uint32_t locality_weight) - : parent_(std::move(parent)), locality_weight_(locality_weight) {} - ~LocalityEntry() = default; + LocalityEntry(RefCountedPtr parent, + RefCountedPtr name, uint32_t locality_weight); + ~LocalityEntry(); void UpdateLocked(xds_grpclb_serverlist* serverlist, LoadBalancingPolicy::Config* child_policy_config, @@ -404,6 +417,8 @@ class XdsLb : public LoadBalancingPolicy { explicit Helper(RefCountedPtr entry) : entry_(std::move(entry)) {} + ~Helper() { entry_.reset(DEBUG_LOCATION, "Helper"); } + RefCountedPtr CreateSubchannel( const grpc_channel_args& args) override; grpc_channel* CreateChannel(const char* target, @@ -428,9 +443,10 @@ class XdsLb : public LoadBalancingPolicy { grpc_channel_args* CreateChildPolicyArgsLocked( const grpc_channel_args* args); + RefCountedPtr parent_; + RefCountedPtr name_; OrphanablePtr child_policy_; OrphanablePtr pending_child_policy_; - RefCountedPtr parent_; RefCountedPtr picker_ref_; grpc_connectivity_state connectivity_state_; uint32_t locality_weight_; @@ -743,7 +759,7 @@ ServerAddressList ProcessServerlist(const xds_grpclb_serverlist* serverlist) { XdsLb::BalancerChannelState::BalancerChannelState( const char* balancer_name, const grpc_channel_args& args, - grpc_core::RefCountedPtr parent_xdslb_policy) + RefCountedPtr parent_xdslb_policy) : InternallyRefCounted(&grpc_lb_xds_trace), xdslb_policy_(std::move(parent_xdslb_policy)), lb_call_backoff_( @@ -763,6 +779,7 @@ XdsLb::BalancerChannelState::BalancerChannelState( } XdsLb::BalancerChannelState::~BalancerChannelState() { + xdslb_policy_.reset(DEBUG_LOCATION, "BalancerChannelState"); grpc_channel_destroy(channel_); } @@ -1414,12 +1431,18 @@ XdsLb::XdsLb(Args args) } XdsLb::~XdsLb() { + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { + gpr_log(GPR_INFO, "[xdslb %p] destroying xds LB policy", this); + } gpr_free((void*)server_name_); grpc_channel_args_destroy(args_); locality_serverlist_.clear(); } void XdsLb::ShutdownLocked() { + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { + gpr_log(GPR_INFO, "[xdslb %p] shutting down", this); + } shutting_down_ = true; if (fallback_at_startup_checks_pending_) { grpc_timer_cancel(&lb_fallback_timer_); @@ -1486,8 +1509,9 @@ void XdsLb::ProcessAddressesAndChannelArgsLocked( } if (create_lb_channel) { OrphanablePtr lb_chand = - MakeOrphanable(balancer_name_.get(), - *lb_channel_args, Ref()); + MakeOrphanable( + balancer_name_.get(), *lb_channel_args, + Ref(DEBUG_LOCATION, "BalancerChannelState")); if (lb_chand_ == nullptr || !lb_chand_->HasActiveCall()) { GPR_ASSERT(pending_lb_chand_ == nullptr); // If we do not have a working LB channel yet, use the newly created one. @@ -1676,7 +1700,8 @@ void XdsLb::UpdateFallbackPolicyLocked() { OrphanablePtr XdsLb::CreateFallbackPolicyLocked( const char* name, const grpc_channel_args* args) { - FallbackHelper* helper = New(Ref()); + FallbackHelper* helper = + New(Ref(DEBUG_LOCATION, "FallbackHelper")); LoadBalancingPolicy::Args lb_policy_args; lb_policy_args.combiner = combiner(); lb_policy_args.args = args; @@ -1739,7 +1764,9 @@ void XdsLb::LocalityMap::UpdateLocked( auto iter = map_.find(locality_serverlist[i]->locality_name); if (iter == map_.end()) { OrphanablePtr new_entry = MakeOrphanable( - parent->Ref(), locality_serverlist[i]->locality_weight); + parent->Ref(DEBUG_LOCATION, "LocalityEntry"), + locality_serverlist[i]->locality_name, + locality_serverlist[i]->locality_weight); iter = map_.emplace(locality_serverlist[i]->locality_name, std::move(new_entry)) .first; @@ -1764,6 +1791,27 @@ void XdsLb::LocalityMap::ResetBackoffLocked() { // XdsLb::LocalityMap::LocalityEntry // +XdsLb::LocalityMap::LocalityEntry::LocalityEntry( + RefCountedPtr parent, RefCountedPtr name, + uint32_t locality_weight) + : parent_(std::move(parent)), + name_(std::move(name)), + locality_weight_(locality_weight) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { + gpr_log(GPR_INFO, "[xdslb %p] created LocalityEntry %p for %s", + parent_.get(), this, name_->AsHumanReadableString()); + } +} + +XdsLb::LocalityMap::LocalityEntry::~LocalityEntry() { + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { + gpr_log(GPR_INFO, + "[xdslb %p] LocalityEntry %p %s: destroying locality entry", + parent_.get(), this, name_->AsHumanReadableString()); + } + parent_.reset(DEBUG_LOCATION, "LocalityEntry"); +} + grpc_channel_args* XdsLb::LocalityMap::LocalityEntry::CreateChildPolicyArgsLocked( const grpc_channel_args* args_in) { @@ -1785,7 +1833,7 @@ XdsLb::LocalityMap::LocalityEntry::CreateChildPolicyArgsLocked( OrphanablePtr XdsLb::LocalityMap::LocalityEntry::CreateChildPolicyLocked( const char* name, const grpc_channel_args* args) { - Helper* helper = New(this->Ref()); + Helper* helper = New(this->Ref(DEBUG_LOCATION, "Helper")); LoadBalancingPolicy::Args lb_policy_args; lb_policy_args.combiner = parent_->combiner(); lb_policy_args.args = args; @@ -1795,13 +1843,16 @@ XdsLb::LocalityMap::LocalityEntry::CreateChildPolicyLocked( LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy( name, std::move(lb_policy_args)); if (GPR_UNLIKELY(lb_policy == nullptr)) { - gpr_log(GPR_ERROR, "[xdslb %p] Failure creating child policy %s", this, - name); + gpr_log(GPR_ERROR, + "[xdslb %p] LocalityEntry %p %s: failure creating child policy %s", + parent_.get(), this, name_->AsHumanReadableString(), name); return nullptr; } helper->set_child(lb_policy.get()); if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { - gpr_log(GPR_INFO, "[xdslb %p] Created new child policy %s (%p)", this, name, + gpr_log(GPR_INFO, + "[xdslb %p] LocalityEntry %p %s: Created new child policy %s (%p)", + parent_.get(), this, name_->AsHumanReadableString(), name, lb_policy.get()); } // Add the xDS's interested_parties pollset_set to that of the newly created @@ -1892,7 +1943,9 @@ void XdsLb::LocalityMap::LocalityEntry::UpdateLocked( // If child_policy_ is null, we set it (case 1), else we set // pending_child_policy_ (cases 2b and 3b). if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { - gpr_log(GPR_INFO, "[xdslb %p] Creating new %schild policy %s", this, + gpr_log(GPR_INFO, + "[xdslb %p] LocalityEntry %p %s: Creating new %schild policy %s", + parent_.get(), this, name_->AsHumanReadableString(), child_policy_ == nullptr ? "" : "pending ", child_policy_name); } auto& lb_policy = @@ -1910,7 +1963,9 @@ void XdsLb::LocalityMap::LocalityEntry::UpdateLocked( GPR_ASSERT(policy_to_update != nullptr); // Update the policy. if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { - gpr_log(GPR_INFO, "[xdslb %p] Updating %schild policy %p", this, + gpr_log(GPR_INFO, + "[xdslb %p] LocalityEntry %p %s: Updating %schild policy %p", + parent_.get(), this, name_->AsHumanReadableString(), policy_to_update == pending_child_policy_.get() ? "pending " : "", policy_to_update); } @@ -1918,17 +1973,22 @@ void XdsLb::LocalityMap::LocalityEntry::UpdateLocked( } void XdsLb::LocalityMap::LocalityEntry::ShutdownLocked() { + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { + gpr_log(GPR_INFO, + "[xdslb %p] LocalityEntry %p %s: shutting down locality entry", + parent_.get(), this, name_->AsHumanReadableString()); + } // Remove the child policy's interested_parties pollset_set from the // xDS policy. grpc_pollset_set_del_pollset_set(child_policy_->interested_parties(), parent_->interested_parties()); + child_policy_.reset(); if (pending_child_policy_ != nullptr) { grpc_pollset_set_del_pollset_set( pending_child_policy_->interested_parties(), parent_->interested_parties()); + pending_child_policy_.reset(); } - child_policy_.reset(); - pending_child_policy_.reset(); } void XdsLb::LocalityMap::LocalityEntry::ResetBackoffLocked() { @@ -2061,11 +2121,13 @@ void XdsLb::LocalityMap::LocalityEntry::Helper::UpdateState( } else if (num_connecting > 0) { entry_->parent_->channel_control_helper()->UpdateState( GRPC_CHANNEL_CONNECTING, - UniquePtr(New(this->entry_->parent_))); + UniquePtr(New( + this->entry_->parent_->Ref(DEBUG_LOCATION, "QueuePicker")))); } else if (num_idle > 0) { entry_->parent_->channel_control_helper()->UpdateState( GRPC_CHANNEL_IDLE, - UniquePtr(New(this->entry_->parent_))); + UniquePtr(New( + this->entry_->parent_->Ref(DEBUG_LOCATION, "QueuePicker")))); } else { GPR_ASSERT(num_transient_failures == locality_map.size()); grpc_error* error = From 0054afef6e3985a7a6aba61204995b4799c00b20 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 10 Jun 2019 13:32:59 -0700 Subject: [PATCH 0514/1555] Fix usage of new and delete --- src/core/lib/iomgr/cfstream_handle.cc | 5 +++-- src/core/lib/iomgr/cfstream_handle.h | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/cfstream_handle.cc b/src/core/lib/iomgr/cfstream_handle.cc index 2fda160f68a..8d01386a8f9 100644 --- a/src/core/lib/iomgr/cfstream_handle.cc +++ b/src/core/lib/iomgr/cfstream_handle.cc @@ -18,6 +18,7 @@ #include +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/port.h" #ifdef GRPC_CFSTREAM @@ -47,7 +48,7 @@ void CFStreamHandle::Release(void* info) { CFStreamHandle* CFStreamHandle::CreateStreamHandle( CFReadStreamRef read_stream, CFWriteStreamRef write_stream) { - return new CFStreamHandle(read_stream, write_stream); + return grpc_core::New(read_stream, write_stream); } void CFStreamHandle::ReadCallback(CFReadStreamRef stream, @@ -188,7 +189,7 @@ void CFStreamHandle::Unref(const char* file, int line, const char* reason) { reason, val, val - 1); } if (gpr_unref(&refcount_)) { - delete this; + grpc_core::Delete(this); } } diff --git a/src/core/lib/iomgr/cfstream_handle.h b/src/core/lib/iomgr/cfstream_handle.h index 4f4d15966e4..05f45ed6251 100644 --- a/src/core/lib/iomgr/cfstream_handle.h +++ b/src/core/lib/iomgr/cfstream_handle.h @@ -29,6 +29,7 @@ #ifdef GRPC_CFSTREAM #import +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/lockfree_event.h" @@ -65,6 +66,9 @@ class CFStreamHandle final { dispatch_queue_t dispatch_queue_; gpr_refcount refcount_; + + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE }; #ifdef DEBUG From 559023c01d74008b6029c3c3debd748665f630cb Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Wed, 12 Jun 2019 15:05:01 -0700 Subject: [PATCH 0515/1555] Adopt reviewer's advice --- examples/python/debug/README.md | 37 ++++++++++++++++++++++----- examples/python/debug/debug_server.py | 5 ++-- examples/python/debug/get_stats.py | 3 --- examples/python/debug/send_message.py | 3 --- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/examples/python/debug/README.md b/examples/python/debug/README.md index db57c79de84..ceed31ef767 100644 --- a/examples/python/debug/README.md +++ b/examples/python/debug/README.md @@ -1,13 +1,21 @@ # gRPC Python Debug Example -This example demonstrate the usage of Channelz. For a better looking website, the [gdebug](https://github.com/grpc/grpc-experiments/tree/master/gdebug) uses gRPC-Web protocol and will serve all useful information in web pages. +This example demonstrate the usage of Channelz. For a better looking website, +the [gdebug](https://github.com/grpc/grpc-experiments/tree/master/gdebug) uses +gRPC-Web protocol and will serve all useful information in web pages. ## Channelz: Live Channel Tracing -Channelz is a channel tracing feature. It will track statistics like how many messages have been sent, how many of them failed, what are the connected sockets. Since it is implemented in C-Core and has low-overhead, it is recommended to turn on for production services. See [Channelz design doc](https://github.com/grpc/proposal/blob/master/A14-channelz.md). +Channelz is a channel tracing feature. It will track statistics like how many +messages have been sent, how many of them failed, what are the connected +sockets. Since it is implemented in C-Core and has low-overhead, it is +recommended to turn on for production services. See [Channelz design +doc](https://github.com/grpc/proposal/blob/master/A14-channelz.md). ## How to enable tracing log -The tracing log generation might have larger overhead, especially when you try to trace transport. It would result in replicating the traffic loads. However, it is still the most powerful tool when you need to dive in. +The tracing log generation might have larger overhead, especially when you try +to trace transport. It would result in replicating the traffic loads. However, +it is still the most powerful tool when you need to dive in. ### The Most Verbose Tracing Log @@ -18,7 +26,8 @@ GRPC_VERBOSITY=debug GRPC_TRACE=all ``` -For more granularity, please see [environment_variables](https://github.com/grpc/grpc/blob/master/doc/environment_variables.md). +For more granularity, please see +[environment_variables](https://github.com/grpc/grpc/blob/master/doc/environment_variables.md). ### Debug Transport Protocol @@ -36,8 +45,24 @@ GRPC_TRACE=call_error,connectivity_state,pick_first,round_robin,glb ## How to debug your application? -`pdb` is a debugging tool that is available for Python interpreters natively. You can set breakpoint, and execute commands while the application is stopped. +`pdb` is a debugging tool that is available for Python interpreters natively. +You can set breakpoint, and execute commands while the application is stopped. -The simplest usage is add a single line in the place you want to inspect: `import pdb; pdb.set_trace()`. When interpreter see this line, it would pop out a interactive command line interface for you to inspect the application state. +The simplest usage is add a single line in the place you want to inspect: +`import pdb; pdb.set_trace()`. When interpreter see this line, it would pop out +a interactive command line interface for you to inspect the application state. For more detailed usage, see https://docs.python.org/3/library/pdb.html. + +**Caveat**: gRPC Python uses C-Extension under-the-hood, so `pdb` may not be +able to trace through the whole stack. + +## gRPC Command Line Tool + +`grpc_cli` is a handy tool to interact with gRPC backend easily. Imageine you can +inspect what service does a server provide without writing any code, and make +gRPC calls just like `curl`. + +The installation guide: https://github.com/grpc/grpc/blob/master/doc/command_line_tool.md#code-location +The usage guide: https://github.com/grpc/grpc/blob/master/doc/command_line_tool.md#usage +The source code: https://github.com/grpc/grpc/blob/master/test/cpp/util/grpc_cli.cc diff --git a/examples/python/debug/debug_server.py b/examples/python/debug/debug_server.py index 2866d284267..64926b53457 100644 --- a/examples/python/debug/debug_server.py +++ b/examples/python/debug/debug_server.py @@ -45,12 +45,11 @@ class FaultInjectGreeter(helloworld_pb2_grpc.GreeterServicer): if random.random() < self._failure_rate: context.abort(grpc.StatusCode.UNAVAILABLE, 'Randomly injected failure.') - return helloworld_pb2.HelloReply( - message='Hello, %s!' % request.name) + return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name) def create_server(addr, failure_rate): - server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) + server = grpc.server(futures.ThreadPoolExecutor()) helloworld_pb2_grpc.add_GreeterServicer_to_server( FaultInjectGreeter(failure_rate), server) diff --git a/examples/python/debug/get_stats.py b/examples/python/debug/get_stats.py index 22924098d51..d0b7061c54f 100644 --- a/examples/python/debug/get_stats.py +++ b/examples/python/debug/get_stats.py @@ -25,9 +25,6 @@ from grpc_channelz.v1 import channelz_pb2_grpc def run(addr): - # NOTE(gRPC Python Team): .close() is possible on a channel and should be - # used in circumstances in which the with statement does not fit the needs - # of the code. with grpc.insecure_channel(addr) as channel: channelz_stub = channelz_pb2_grpc.ChannelzStub(channel) response = channelz_stub.GetServers( diff --git a/examples/python/debug/send_message.py b/examples/python/debug/send_message.py index 99425263b50..3bad52c8fac 100644 --- a/examples/python/debug/send_message.py +++ b/examples/python/debug/send_message.py @@ -34,9 +34,6 @@ def process(stub, request): def run(addr, n): - # NOTE(gRPC Python Team): .close() is possible on a channel and should be - # used in circumstances in which the with statement does not fit the needs - # of the code. with grpc.insecure_channel(addr) as channel: stub = helloworld_pb2_grpc.GreeterStub(channel) request = helloworld_pb2.HelloRequest(name='you') From 4275312e5174149357283c263e10c45c5552dd4b Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 13 Jun 2019 10:54:22 -0700 Subject: [PATCH 0516/1555] Mark as experiemental --- src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml b/src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml index dd220bf564d..2728c8bfdc2 100644 --- a/src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml +++ b/src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml @@ -28,7 +28,7 @@ + Description="The base type to use for the client. This is an experimental feature."> From 94d41f031956357e142278ce34d773da1449e4f1 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 13 Jun 2019 11:46:14 -0700 Subject: [PATCH 0517/1555] Simplify LB policy and resolver shutdown. --- .../filters/client_channel/client_channel.cc | 7 ++----- .../ext/filters/client_channel/lb_policy.cc | 19 ++----------------- .../ext/filters/client_channel/lb_policy.h | 4 +--- .../client_channel/lb_policy/xds/xds.cc | 3 +++ .../ext/filters/client_channel/resolver.h | 14 +++----------- 5 files changed, 11 insertions(+), 36 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index a67792fcd37..40f8cef522b 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -1435,10 +1435,8 @@ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error) std::move(target_uri), ProcessResolverResultLocked, this, error)); grpc_channel_args_destroy(new_args); if (*error != GRPC_ERROR_NONE) { - // Orphan the resolving LB policy and flush the exec_ctx to ensure - // that it finishes shutting down. This ensures that if we are - // failing, we destroy the ClientChannelControlHelper (and thus - // unref the channel stack) before we return. + // Before we return, shut down the resolving LB policy, which destroys + // the ClientChannelControlHelper and therefore unrefs the channel stack. // TODO(roth): This is not a complete solution, because it only // catches the case where channel stack initialization fails in this // particular filter. If there is a failure in a different filter, we @@ -1446,7 +1444,6 @@ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error) // in practice, there are no other filters that can cause failures in // channel stack initialization, so this works for now. resolving_lb_policy_.reset(); - ExecCtx::Get()->Flush(); } else { grpc_pollset_set_add_pollset_set(resolving_lb_policy_->interested_parties(), interested_parties_); diff --git a/src/core/ext/filters/client_channel/lb_policy.cc b/src/core/ext/filters/client_channel/lb_policy.cc index 3e4d3703c82..3207f888044 100644 --- a/src/core/ext/filters/client_channel/lb_policy.cc +++ b/src/core/ext/filters/client_channel/lb_policy.cc @@ -43,23 +43,8 @@ LoadBalancingPolicy::~LoadBalancingPolicy() { } void LoadBalancingPolicy::Orphan() { - // Invoke ShutdownAndUnrefLocked() inside of the combiner. - // TODO(roth): Is this actually needed? We should already be in the - // combiner here. Note that if we directly call ShutdownLocked(), - // then we can probably remove the hack whereby the helper is - // destroyed at shutdown instead of at destruction. - GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_CREATE(&LoadBalancingPolicy::ShutdownAndUnrefLocked, this, - grpc_combiner_scheduler(combiner_)), - GRPC_ERROR_NONE); -} - -void LoadBalancingPolicy::ShutdownAndUnrefLocked(void* arg, - grpc_error* ignored) { - LoadBalancingPolicy* policy = static_cast(arg); - policy->ShutdownLocked(); - policy->channel_control_helper_.reset(); - policy->Unref(); + ShutdownLocked(); + Unref(); } // diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h index c21e9d90ec4..ecc235bb71b 100644 --- a/src/core/ext/filters/client_channel/lb_policy.h +++ b/src/core/ext/filters/client_channel/lb_policy.h @@ -282,6 +282,7 @@ class LoadBalancingPolicy : public InternallyRefCounted { grpc_pollset_set* interested_parties() const { return interested_parties_; } + // Note: This must be invoked while holding the combiner. void Orphan() override; // A picker that returns PICK_QUEUE for all picks. @@ -322,7 +323,6 @@ class LoadBalancingPolicy : public InternallyRefCounted { // Note: LB policies MUST NOT call any method on the helper from their // constructor. - // Note: This will return null after ShutdownLocked() has been called. ChannelControlHelper* channel_control_helper() const { return channel_control_helper_.get(); } @@ -331,8 +331,6 @@ class LoadBalancingPolicy : public InternallyRefCounted { virtual void ShutdownLocked() GRPC_ABSTRACT; private: - static void ShutdownAndUnrefLocked(void* arg, grpc_error* ignored); - /// Combiner under which LB policy actions take place. grpc_combiner* combiner_; /// Owned pointer to interested parties in load balancing decisions. diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index 74660cec92b..ca6ab216515 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -1989,6 +1989,9 @@ void XdsLb::LocalityMap::LocalityEntry::ShutdownLocked() { parent_->interested_parties()); pending_child_policy_.reset(); } + // Drop our ref to the child's picker, in case it's holding a ref to + // the child. + picker_ref_.reset(); } void XdsLb::LocalityMap::LocalityEntry::ResetBackoffLocked() { diff --git a/src/core/ext/filters/client_channel/resolver.h b/src/core/ext/filters/client_channel/resolver.h index 87a4442d75b..829a860040a 100644 --- a/src/core/ext/filters/client_channel/resolver.h +++ b/src/core/ext/filters/client_channel/resolver.h @@ -117,12 +117,10 @@ class Resolver : public InternallyRefCounted { /// implementations. At that point, this method can go away. virtual void ResetBackoffLocked() {} + // Note: This must be invoked while holding the combiner. void Orphan() override { - // Invoke ShutdownAndUnrefLocked() inside of the combiner. - GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_CREATE(&Resolver::ShutdownAndUnrefLocked, this, - grpc_combiner_scheduler(combiner_)), - GRPC_ERROR_NONE); + ShutdownLocked(); + Unref(); } GRPC_ABSTRACT_BASE_CLASS @@ -147,12 +145,6 @@ class Resolver : public InternallyRefCounted { ResultHandler* result_handler() const { return result_handler_.get(); } private: - static void ShutdownAndUnrefLocked(void* arg, grpc_error* ignored) { - Resolver* resolver = static_cast(arg); - resolver->ShutdownLocked(); - resolver->Unref(); - } - UniquePtr result_handler_; grpc_combiner* combiner_; }; From 90f1c32b85e6e49a68ce5310a8455f1a9f04226e Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 13 Jun 2019 12:29:48 -0700 Subject: [PATCH 0518/1555] Sanity checks and return value --- include/grpcpp/impl/codegen/delegating_channel.h | 4 ++-- test/cpp/end2end/delegating_channel_test.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/grpcpp/impl/codegen/delegating_channel.h b/include/grpcpp/impl/codegen/delegating_channel.h index 0853ad3b5de..adc20b3751d 100644 --- a/include/grpcpp/impl/codegen/delegating_channel.h +++ b/include/grpcpp/impl/codegen/delegating_channel.h @@ -30,7 +30,7 @@ class DelegatingChannel : public ::grpc::ChannelInterface { : delegate_channel_(delegate_channel) {} grpc_connectivity_state GetState(bool try_to_connect) override { - delegate_channel()->GetState(try_to_connect); + return delegate_channel()->GetState(try_to_connect); } std::shared_ptr<::grpc::ChannelInterface> delegate_channel() { @@ -84,4 +84,4 @@ class DelegatingChannel : public ::grpc::ChannelInterface { } // namespace internal } // namespace grpc -#endif // GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H \ No newline at end of file +#endif // GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H diff --git a/test/cpp/end2end/delegating_channel_test.cc b/test/cpp/end2end/delegating_channel_test.cc index 22e261d535e..764a3eade88 100644 --- a/test/cpp/end2end/delegating_channel_test.cc +++ b/test/cpp/end2end/delegating_channel_test.cc @@ -46,7 +46,7 @@ namespace { class TestChannel : public internal::DelegatingChannel { public: TestChannel(std::shared_ptr delegate_channel) - : internal::DelegatingChannel(delegate_channel) {} + : internal::DelegatingChannel(std::move(delegate_channel)) {} // Always returns GRPC_CHANNEL_READY grpc_connectivity_state GetState(bool try_to_connect) override { return GRPC_CHANNEL_READY; From c0d9289a7e4093f40ffb89a2c162cbfb56dcc5f1 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 6 Jun 2019 10:25:37 -0700 Subject: [PATCH 0519/1555] Stop misspelling our own project name --- src/core/ext/filters/client_channel/resolver.h | 2 +- src/core/lib/channel/channelz_registry.h | 4 ++-- src/core/lib/gprpp/memory.h | 4 ++-- src/core/lib/gprpp/orphanable.h | 2 +- src/core/lib/gprpp/ref_counted.h | 6 +++--- src/core/lib/iomgr/buffer_list.h | 2 +- src/core/lib/slice/slice.cc | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver.h b/src/core/ext/filters/client_channel/resolver.h index 9aa504225ad..87a4442d75b 100644 --- a/src/core/ext/filters/client_channel/resolver.h +++ b/src/core/ext/filters/client_channel/resolver.h @@ -128,7 +128,7 @@ class Resolver : public InternallyRefCounted { GRPC_ABSTRACT_BASE_CLASS protected: - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE /// Does NOT take ownership of the reference to \a combiner. // TODO(roth): Once we have a C++-like interface for combiners, this diff --git a/src/core/lib/channel/channelz_registry.h b/src/core/lib/channel/channelz_registry.h index 73b330785d2..a0c431e091d 100644 --- a/src/core/lib/channel/channelz_registry.h +++ b/src/core/lib/channel/channelz_registry.h @@ -67,8 +67,8 @@ class ChannelzRegistry { static void LogAllEntities() { Default()->InternalLogAllEntities(); } private: - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE friend class testing::ChannelzRegistryPeer; ChannelzRegistry(); diff --git a/src/core/lib/gprpp/memory.h b/src/core/lib/gprpp/memory.h index b4b63ae771a..70ad430c51d 100644 --- a/src/core/lib/gprpp/memory.h +++ b/src/core/lib/gprpp/memory.h @@ -29,12 +29,12 @@ // Add this to a class that want to use Delete(), but has a private or // protected destructor. -#define GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE \ +#define GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE \ template \ friend void grpc_core::Delete(T*); // Add this to a class that want to use New(), but has a private or // protected constructor. -#define GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW \ +#define GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW \ template \ friend T* grpc_core::New(Args&&...); diff --git a/src/core/lib/gprpp/orphanable.h b/src/core/lib/gprpp/orphanable.h index 2e467e49060..82350a19a2c 100644 --- a/src/core/lib/gprpp/orphanable.h +++ b/src/core/lib/gprpp/orphanable.h @@ -84,7 +84,7 @@ class InternallyRefCounted : public Orphanable { GRPC_ABSTRACT_BASE_CLASS protected: - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE // Allow RefCountedPtr<> to access Unref() and IncrementRefCount(). template diff --git a/src/core/lib/gprpp/ref_counted.h b/src/core/lib/gprpp/ref_counted.h index 83e9429ba37..3ef210e025f 100644 --- a/src/core/lib/gprpp/ref_counted.h +++ b/src/core/lib/gprpp/ref_counted.h @@ -44,7 +44,7 @@ class PolymorphicRefCount { GRPC_ABSTRACT_BASE_CLASS protected: - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE virtual ~PolymorphicRefCount() = default; }; @@ -57,7 +57,7 @@ class NonPolymorphicRefCount { GRPC_ABSTRACT_BASE_CLASS protected: - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE ~NonPolymorphicRefCount() = default; }; @@ -228,7 +228,7 @@ class RefCounted : public Impl { GRPC_ABSTRACT_BASE_CLASS protected: - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE // TraceFlagT is defined to accept both DebugOnlyTraceFlag and TraceFlag. // Note: RefCount tracing is only enabled on debug builds, even when a diff --git a/src/core/lib/iomgr/buffer_list.h b/src/core/lib/iomgr/buffer_list.h index 8bb271867c2..755ce02ba95 100644 --- a/src/core/lib/iomgr/buffer_list.h +++ b/src/core/lib/iomgr/buffer_list.h @@ -133,7 +133,7 @@ class TracedBuffer { grpc_error* shutdown_err); private: - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW TracedBuffer(uint32_t seq_no, void* arg) : seq_no_(seq_no), arg_(arg), next_(nullptr) {} diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc index 2bf2b0f499f..4a17188fdda 100644 --- a/src/core/lib/slice/slice.cc +++ b/src/core/lib/slice/slice.cc @@ -105,7 +105,7 @@ class NewSliceRefcount { user_destroy_(destroy), user_data_(user_data) {} - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE grpc_slice_refcount* base_refcount() { return &rc_; } @@ -154,7 +154,7 @@ class NewWithLenSliceRefcount { user_length_(user_length), user_destroy_(destroy) {} - GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE grpc_slice_refcount* base_refcount() { return &rc_; } From 73180b1c0e2aa7304bdde1aecc3831c94db7cbe1 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Thu, 13 Jun 2019 13:59:52 -0700 Subject: [PATCH 0520/1555] Reduced instruction count for maybe_embiggen common case. --- src/core/lib/slice/slice_buffer.cc | 52 ++++++++++++++++++------------ 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc index e1929250d4a..2b69f576a3c 100644 --- a/src/core/lib/slice/slice_buffer.cc +++ b/src/core/lib/slice/slice_buffer.cc @@ -32,35 +32,45 @@ /* grow a buffer; requires GRPC_SLICE_BUFFER_INLINE_ELEMENTS > 1 */ #define GROW(x) (3 * (x) / 2) +/* Typically, we do not actually need to embiggen (by calling + * memmove/malloc/realloc) - only if we were up against the full capacity of the + * slice buffer. If do_embiggen is inlined, the compiler clobbers multiple + * registers pointlessly in the common case. */ +static void GPR_ATTRIBUTE_NOINLINE do_embiggen(grpc_slice_buffer* sb, + const size_t slice_count, + const size_t slice_offset) { + if (slice_offset != 0) { + /* Make room by moving elements if there's still space unused */ + memmove(sb->base_slices, sb->slices, sb->count * sizeof(grpc_slice)); + sb->slices = sb->base_slices; + } else { + /* Allocate more memory if no more space is available */ + const size_t new_capacity = GROW(sb->capacity); + sb->capacity = new_capacity; + if (sb->base_slices == sb->inlined) { + sb->base_slices = static_cast( + gpr_malloc(new_capacity * sizeof(grpc_slice))); + memcpy(sb->base_slices, sb->inlined, slice_count * sizeof(grpc_slice)); + } else { + sb->base_slices = static_cast( + gpr_realloc(sb->base_slices, new_capacity * sizeof(grpc_slice))); + } + + sb->slices = sb->base_slices + slice_offset; + } +} + static void maybe_embiggen(grpc_slice_buffer* sb) { if (sb->count == 0) { sb->slices = sb->base_slices; + return; } /* How far away from sb->base_slices is sb->slices pointer */ size_t slice_offset = static_cast(sb->slices - sb->base_slices); size_t slice_count = sb->count + slice_offset; - - if (slice_count == sb->capacity) { - if (sb->base_slices != sb->slices) { - /* Make room by moving elements if there's still space unused */ - memmove(sb->base_slices, sb->slices, sb->count * sizeof(grpc_slice)); - sb->slices = sb->base_slices; - } else { - /* Allocate more memory if no more space is available */ - sb->capacity = GROW(sb->capacity); - GPR_ASSERT(sb->capacity > slice_count); - if (sb->base_slices == sb->inlined) { - sb->base_slices = static_cast( - gpr_malloc(sb->capacity * sizeof(grpc_slice))); - memcpy(sb->base_slices, sb->inlined, slice_count * sizeof(grpc_slice)); - } else { - sb->base_slices = static_cast( - gpr_realloc(sb->base_slices, sb->capacity * sizeof(grpc_slice))); - } - - sb->slices = sb->base_slices + slice_offset; - } + if (GPR_UNLIKELY(slice_count == sb->capacity)) { + do_embiggen(sb, slice_count, slice_offset); } } From d8ddd592f94960226e588603eb31a361db6af8dc Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 13 Jun 2019 14:20:48 -0700 Subject: [PATCH 0521/1555] Rename cfg files and use opt configuration --- ...pc_buildtests_objc.cfg => grpc_basictests_objc_examples.cfg} | 2 +- .../{grpc_basictests_objc.cfg => grpc_basictests_objc_ios.cfg} | 2 +- .../{grpc_mactests_objc.cfg => grpc_basictests_objc_mac.cfg} | 2 +- ...pc_buildtests_objc.cfg => grpc_basictests_objc_examples.cfg} | 2 +- .../{grpc_basictests_objc.cfg => grpc_basictests_objc_ios.cfg} | 2 +- .../{grpc_mactests_objc.cfg => grpc_basictests_objc_mac.cfg} | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) rename tools/internal_ci/macos/{grpc_buildtests_objc.cfg => grpc_basictests_objc_examples.cfg} (94%) rename tools/internal_ci/macos/{grpc_basictests_objc.cfg => grpc_basictests_objc_ios.cfg} (94%) rename tools/internal_ci/macos/{grpc_mactests_objc.cfg => grpc_basictests_objc_mac.cfg} (94%) rename tools/internal_ci/macos/pull_request/{grpc_buildtests_objc.cfg => grpc_basictests_objc_examples.cfg} (94%) rename tools/internal_ci/macos/pull_request/{grpc_basictests_objc.cfg => grpc_basictests_objc_ios.cfg} (94%) rename tools/internal_ci/macos/pull_request/{grpc_mactests_objc.cfg => grpc_basictests_objc_mac.cfg} (94%) diff --git a/tools/internal_ci/macos/grpc_buildtests_objc.cfg b/tools/internal_ci/macos/grpc_basictests_objc_examples.cfg similarity index 94% rename from tools/internal_ci/macos/grpc_buildtests_objc.cfg rename to tools/internal_ci/macos/grpc_basictests_objc_examples.cfg index d4bbcf5ab47..ccfc847cbef 100644 --- a/tools/internal_ci/macos/grpc_buildtests_objc.cfg +++ b/tools/internal_ci/macos/grpc_basictests_objc_examples.cfg @@ -27,5 +27,5 @@ action { env_vars { key: "RUN_TESTS_FLAGS" - value: "-f basictests macos objc dbg --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results --extra_args '-r ios-buildtest-.*'" + value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results --extra_args '-r ios-buildtest-.*'" } diff --git a/tools/internal_ci/macos/grpc_basictests_objc.cfg b/tools/internal_ci/macos/grpc_basictests_objc_ios.cfg similarity index 94% rename from tools/internal_ci/macos/grpc_basictests_objc.cfg rename to tools/internal_ci/macos/grpc_basictests_objc_ios.cfg index c5ee5015c3c..c6cf3e071d4 100644 --- a/tools/internal_ci/macos/grpc_basictests_objc.cfg +++ b/tools/internal_ci/macos/grpc_basictests_objc_ios.cfg @@ -27,5 +27,5 @@ action { env_vars { key: "RUN_TESTS_FLAGS" - value: "-f basictests macos objc dbg --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results --extra_args '-r ios-test-.*'" + value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results --extra_args '-r ios-test-.*'" } diff --git a/tools/internal_ci/macos/grpc_mactests_objc.cfg b/tools/internal_ci/macos/grpc_basictests_objc_mac.cfg similarity index 94% rename from tools/internal_ci/macos/grpc_mactests_objc.cfg rename to tools/internal_ci/macos/grpc_basictests_objc_mac.cfg index 2147e12eb85..fc7313e4b28 100644 --- a/tools/internal_ci/macos/grpc_mactests_objc.cfg +++ b/tools/internal_ci/macos/grpc_basictests_objc_mac.cfg @@ -27,5 +27,5 @@ action { env_vars { key: "RUN_TESTS_FLAGS" - value: "-f basictests macos objc dbg --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results --extra_args '-r mac-test-.*'" + value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results --extra_args '-r mac-test-.*'" } diff --git a/tools/internal_ci/macos/pull_request/grpc_buildtests_objc.cfg b/tools/internal_ci/macos/pull_request/grpc_basictests_objc_examples.cfg similarity index 94% rename from tools/internal_ci/macos/pull_request/grpc_buildtests_objc.cfg rename to tools/internal_ci/macos/pull_request/grpc_basictests_objc_examples.cfg index 8f35fda899a..a95c51c8c4a 100644 --- a/tools/internal_ci/macos/pull_request/grpc_buildtests_objc.cfg +++ b/tools/internal_ci/macos/pull_request/grpc_basictests_objc_examples.cfg @@ -27,5 +27,5 @@ action { env_vars { key: "RUN_TESTS_FLAGS" - value: "-f basictests macos objc dbg --internal_ci -j 1 --inner_jobs 4 --extra_args '-r ios-buildtest-.*'" + value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --extra_args '-r ios-buildtest-.*'" } diff --git a/tools/internal_ci/macos/pull_request/grpc_basictests_objc.cfg b/tools/internal_ci/macos/pull_request/grpc_basictests_objc_ios.cfg similarity index 94% rename from tools/internal_ci/macos/pull_request/grpc_basictests_objc.cfg rename to tools/internal_ci/macos/pull_request/grpc_basictests_objc_ios.cfg index cb433413504..8b2fead4342 100644 --- a/tools/internal_ci/macos/pull_request/grpc_basictests_objc.cfg +++ b/tools/internal_ci/macos/pull_request/grpc_basictests_objc_ios.cfg @@ -27,5 +27,5 @@ action { env_vars { key: "RUN_TESTS_FLAGS" - value: "-f basictests macos objc dbg --internal_ci -j 1 --inner_jobs 4 --extra_args '-r ios-test-.*'" + value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --extra_args '-r ios-test-.*'" } diff --git a/tools/internal_ci/macos/pull_request/grpc_mactests_objc.cfg b/tools/internal_ci/macos/pull_request/grpc_basictests_objc_mac.cfg similarity index 94% rename from tools/internal_ci/macos/pull_request/grpc_mactests_objc.cfg rename to tools/internal_ci/macos/pull_request/grpc_basictests_objc_mac.cfg index 5691375392e..43e3ca381ac 100644 --- a/tools/internal_ci/macos/pull_request/grpc_mactests_objc.cfg +++ b/tools/internal_ci/macos/pull_request/grpc_basictests_objc_mac.cfg @@ -27,5 +27,5 @@ action { env_vars { key: "RUN_TESTS_FLAGS" - value: "-f basictests macos objc dbg --internal_ci -j 1 --inner_jobs 4 --extra_args '-r mac-test-.*'" + value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --extra_args '-r mac-test-.*'" } From 8de64087a3da2303eaec05e877ebb8bff6042dfc Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Fri, 14 Jun 2019 00:20:29 +0200 Subject: [PATCH 0522/1555] Clean bazel 0.26 upgrade. --- BUILD | 156 ++------------------- WORKSPACE | 2 +- bazel/grpc_build_system.bzl | 5 + bazel/grpc_deps.bzl | 16 +-- third_party/data-plane-api | 2 +- third_party/upb | 2 +- tools/run_tests/sanity/check_submodules.sh | 2 +- 7 files changed, 28 insertions(+), 157 deletions(-) diff --git a/BUILD b/BUILD index 214c5ddf078..f61bbe39770 100644 --- a/BUILD +++ b/BUILD @@ -31,10 +31,9 @@ load( "grpc_cc_library", "grpc_generate_one_off_targets", "grpc_proto_plugin", + "grpc_upb_proto_library", ) -load("@upb//bazel:upb_proto_library.bzl", "upb_proto_library") - config_setting( name = "grpc_no_ares", values = {"define": "grpc_no_ares=true"}, @@ -2365,35 +2364,29 @@ grpc_cc_library( ], ) -upb_proto_library( +grpc_upb_proto_library( name = "upb_load_report", - deps = ["@data_plane_api//envoy/api/v2/endpoint:load_report_export"] + deps = ["@envoy_api//envoy/api/v2/endpoint:load_report_export"] ) -upb_proto_library( +grpc_upb_proto_library( name = "upb_lrs", - deps = ["@data_plane_api//envoy/service/load_stats/v2:lrs_export"] + deps = ["@envoy_api//envoy/service/load_stats/v2:lrs_export"] +) + +grpc_upb_proto_library( + name = "upb_cds", + deps = ["@envoy_api//envoy/api/v2:cds_export"] ) #TODO: Get this into build.yaml once we start using it. grpc_cc_library( name = "envoy_lrs_upb", -# srcs = [ -# "src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c", -# "src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c", -# ], -# hdrs = [ -# "src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h", -# "src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h", -# ], language = "c++", external_deps = [ "upb_lib", ], deps = [ - ":envoy_core_upb", - ":google_api_upb", - ":proto_gen_validate_upb", ":upb_load_report", ":upb_lrs" ], @@ -2402,143 +2395,16 @@ grpc_cc_library( grpc_cc_library( name = "envoy_ads_upb", - srcs = [ - "src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/cds.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/eds.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c", - "src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c", - ], - hdrs = [ - "src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/cds.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/eds.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h", - "src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h", - ], external_deps = [ "upb_lib", ], language = "c++", deps = [ - ":envoy_core_upb", - ":envoy_type_upb", - ":google_api_upb", - ":proto_gen_validate_upb", + ":upb_cds", ], tags = ["no_windows"], ) -grpc_cc_library( - name = "envoy_core_upb", - srcs = [ - "src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c", - ], - hdrs = [ - "src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h", - ], - external_deps = [ - "upb_lib", - ], - language = "c++", - tags = ["no_windows"], - deps = [ - ":envoy_type_upb", - ":google_api_upb", - ":proto_gen_validate_upb", - ], -) - -grpc_cc_library( - name = "envoy_type_upb", - srcs = [ - "src/core/ext/upb-generated/envoy/type/percent.upb.c", - "src/core/ext/upb-generated/envoy/type/range.upb.c", - ], - hdrs = [ - "src/core/ext/upb-generated/envoy/type/percent.upb.h", - "src/core/ext/upb-generated/envoy/type/range.upb.h", - ], - external_deps = [ - "upb_lib", - ], - language = "c++", - tags = ["no_windows"], - deps = [ - ":google_api_upb", - ":proto_gen_validate_upb", - ], -) - -grpc_cc_library( - name = "proto_gen_validate_upb", - srcs = [ - "src/core/ext/upb-generated/gogoproto/gogo.upb.c", - "src/core/ext/upb-generated/validate/validate.upb.c", - ], - hdrs = [ - "src/core/ext/upb-generated/gogoproto/gogo.upb.h", - "src/core/ext/upb-generated/validate/validate.upb.h", - ], - external_deps = [ - "upb_lib", - ], - language = "c++", - tags = ["no_windows"], - deps = [ - ":google_api_upb", - ], -) - -grpc_cc_library( - name = "google_api_upb", - srcs = [ - "src/core/ext/upb-generated/google/api/annotations.upb.c", - "src/core/ext/upb-generated/google/api/http.upb.c", - "src/core/ext/upb-generated/google/protobuf/any.upb.c", - "src/core/ext/upb-generated/google/protobuf/descriptor.upb.c", - "src/core/ext/upb-generated/google/protobuf/duration.upb.c", - "src/core/ext/upb-generated/google/protobuf/empty.upb.c", - "src/core/ext/upb-generated/google/protobuf/struct.upb.c", - "src/core/ext/upb-generated/google/protobuf/timestamp.upb.c", - "src/core/ext/upb-generated/google/protobuf/wrappers.upb.c", - "src/core/ext/upb-generated/google/rpc/status.upb.c", - ], - hdrs = [ - "src/core/ext/upb-generated/google/api/annotations.upb.h", - "src/core/ext/upb-generated/google/api/http.upb.h", - "src/core/ext/upb-generated/google/protobuf/any.upb.h", - "src/core/ext/upb-generated/google/protobuf/descriptor.upb.h", - "src/core/ext/upb-generated/google/protobuf/duration.upb.h", - "src/core/ext/upb-generated/google/protobuf/empty.upb.h", - "src/core/ext/upb-generated/google/protobuf/struct.upb.h", - "src/core/ext/upb-generated/google/protobuf/timestamp.upb.h", - "src/core/ext/upb-generated/google/protobuf/wrappers.upb.h", - "src/core/ext/upb-generated/google/rpc/status.upb.h", - ], - external_deps = [ - "upb_lib", - ], - language = "c++", - tags = ["no_windows"], -) - grpc_generate_one_off_targets() filegroup( diff --git a/WORKSPACE b/WORKSPACE index 755760efefc..11b30e2a68d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -70,7 +70,7 @@ rbe_autoconfig( load("@upb//bazel:workspace_deps.bzl", "upb_deps") upb_deps() -load("@data_plane_api//bazel:repositories.bzl", "api_dependencies") +load("@envoy_api//bazel:repositories.bzl", "api_dependencies") api_dependencies() load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains") diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 5f8477d7325..ee6dd2ce3d1 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -24,6 +24,7 @@ # load("//bazel:cc_grpc_library.bzl", "cc_grpc_library") +load("@upb//bazel:upb_proto_library.bzl", "upb_proto_library") # The set of pollers to test against if a test exercises polling POLLERS = ["epollex", "epoll1", "poll"] @@ -248,3 +249,7 @@ def grpc_package(name, visibility = "private", features = []): default_visibility = visibility, features = features, ) + +def grpc_upb_proto_library(name, deps): + upb_proto_library(name = name, deps = deps) + diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index da96b8118b2..cb9fe3ed440 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -212,16 +212,16 @@ def grpc_deps(): if "upb" not in native.existing_rules(): http_archive( name = "upb", - sha256 = "3aa0c5aff130d97618fe137e3e76603b2381e3698cd7ca7a4a54327f7c44c69c", - strip_prefix = "upb-ef6ce94bfecf36fb57acd8a8b470c0560959f063", - url = "https://github.com/google/upb/archive/ef6ce94bfecf36fb57acd8a8b470c0560959f063.tar.gz", + sha256 = "909b6fca860a85bea7dda4770aae66f6afd6f12586e8a4cb95460d0707fd66ce", + strip_prefix = "upb-312c6b421a3c749e4f7c0e2193d4775cb997cff7", + url = "https://github.com/haberman/upb/archive/312c6b421a3c749e4f7c0e2193d4775cb997cff7.tar.gz", ) - if "data_plane_api" not in native.existing_rules(): + if "envoy_api" not in native.existing_rules(): http_archive( - name = "data_plane_api", - sha256 = "9b9e0e3882df11f1a174aac7d78c2238a8bfbadad271b673f351a86137613cde", - strip_prefix = "data-plane-api-911001cdca003337bdb93fab32740cde61bafee3", - url = "https://github.com/envoyproxy/data-plane-api/archive/911001cdca003337bdb93fab32740cde61bafee3.tar.gz", + name = "envoy_api", + sha256 = "a2c6e854fa9653b0ed6510e31ec7c51eac43d578b54cd75c0bc1898f7515c60d", + strip_prefix = "data-plane-api-a83394157ad97f4dadbc8ed81f56ad5b3a72e542", + url = "https://github.com/envoyproxy/data-plane-api/archive/a83394157ad97f4dadbc8ed81f56ad5b3a72e542.tar.gz", ) if "io_bazel_rules_go" not in native.existing_rules(): diff --git a/third_party/data-plane-api b/third_party/data-plane-api index 911001cdca0..ed9db8d1c82 160000 --- a/third_party/data-plane-api +++ b/third_party/data-plane-api @@ -1 +1 @@ -Subproject commit 911001cdca003337bdb93fab32740cde61bafee3 +Subproject commit ed9db8d1c8201ccdba2cb50a066f5956d6d91069 diff --git a/third_party/upb b/third_party/upb index ef6ce94bfec..312c6b421a3 160000 --- a/third_party/upb +++ b/third_party/upb @@ -1 +1 @@ -Subproject commit ef6ce94bfecf36fb57acd8a8b470c0560959f063 +Subproject commit 312c6b421a3c749e4f7c0e2193d4775cb997cff7 diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index 9c49d635959..3238fcef7ad 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -40,7 +40,7 @@ cat << EOF | awk '{ print $1 }' | sort > "$want_submodules" 9245d481eb3e890f708ff2d7dadf2a10c04748ba third_party/libcxxabi (heads/release_60) 582743bf40c5d3639a70f98f183914a2c0cd0680 third_party/protobuf (v3.7.0-rc.2-20-g582743bf) e143189bf6f37b3957fb31743df6a1bcf4a8c685 third_party/protoc-gen-validate (v0.0.10) - ef6ce94bfecf36fb57acd8a8b470c0560959f063 third_party/upb (heads/master) + 312c6b421a3c749e4f7c0e2193d4775cb997cff7 third_party/upb (heads/master) cacf7f1d4e3d44d871b605da3b647f07d718623f third_party/zlib (v1.2.11) EOF From 94a18020eb6652976e73d386f355cf0b08c28fc3 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 13 Jun 2019 16:11:17 -0700 Subject: [PATCH 0523/1555] nit fixes --- src/objective-c/GRPCClient/GRPCCall.m | 6 +++--- src/objective-c/tests/InteropTests/InteropTests.m | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 684867ae1ee..5280f8d01f4 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -161,12 +161,12 @@ const char *kCFStreamVarName = "grpc_cfstream"; NSLog(@"Failed to create interceptor from factory: %@", globalInterceptorFactory); } else { [internalCall setResponseHandler:interceptor]; + nextInterceptor = interceptor; + nextManager = manager; } - nextInterceptor = interceptor; - nextManager = manager; } - // Finanlly initialize the interceptors in the chain + // Finally initialize the interceptors in the chain NSArray *interceptorFactories = _actualCallOptions.interceptorFactories; if (interceptorFactories.count == 0) { if (nextManager == nil) { diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index ef22a53cd96..6f00176b20c 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -1521,7 +1521,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - (void)testGlobalInterceptor { XCTAssertNotNil([[self class] host]); __weak XCTestExpectation *expectation = - [self expectationWithDescription:@"testLoggingInterceptor"]; + [self expectationWithDescription:@"testGlobalInterceptor"]; __block NSUInteger startCount = 0; __block NSUInteger writeDataCount = 0; From f08aab26bf132258a75e04266fd217196c5033d6 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 13 Jun 2019 16:11:51 -0700 Subject: [PATCH 0524/1555] Add test for 1 global interceptor and 1 local interceptor --- .../tests/InteropTests/InteropTests.m | 170 ++++++++++++++++++ 1 file changed, 170 insertions(+) diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 6f00176b20c..962a15cbf8c 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -1666,4 +1666,174 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager } } +- (void)testIntecepptorAndGlobalInterceptor { + XCTAssertNotNil([[self class] host]); + __weak XCTestExpectation *expectation = + [self expectationWithDescription:@"testGlobalInterceptor"]; + + __block NSUInteger startCount = 0; + __block NSUInteger writeDataCount = 0; + __block NSUInteger finishCount = 0; + __block NSUInteger receiveNextMessageCount = 0; + __block NSUInteger responseHeaderCount = 0; + __block NSUInteger responseDataCount = 0; + __block NSUInteger responseCloseCount = 0; + __block NSUInteger didWriteDataCount = 0; + + id factory = [[HookInterceptorFactory alloc] + initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager) { + startCount++; + XCTAssertEqualObjects(requestOptions.host, [[self class] host]); + XCTAssertEqualObjects(requestOptions.path, @"/grpc.testing.TestService/FullDuplexCall"); + XCTAssertEqual(requestOptions.safety, GRPCCallSafetyDefault); + [manager startNextInterceptorWithRequest:[requestOptions copy] + callOptions:[callOptions copy]]; + } + writeDataHook:^(id data, GRPCInterceptorManager *manager) { + writeDataCount++; + [manager writeNextInterceptorWithData:data]; + } + finishHook:^(GRPCInterceptorManager *manager) { + finishCount++; + [manager finishNextInterceptor]; + } + receiveNextMessagesHook:^(NSUInteger numberOfMessages, GRPCInterceptorManager *manager) { + receiveNextMessageCount++; + [manager receiveNextInterceptorMessages:numberOfMessages]; + } + responseHeaderHook:^(NSDictionary *initialMetadata, GRPCInterceptorManager *manager) { + responseHeaderCount++; + [manager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; + } + responseDataHook:^(id data, GRPCInterceptorManager *manager) { + responseDataCount++; + [manager forwardPreviousInterceptorWithData:data]; + } + responseCloseHook:^(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager) { + responseCloseCount++; + [manager forwardPreviousInterceptorCloseWithTrailingMetadata:trailingMetadata error:error]; + } + didWriteDataHook:^(GRPCInterceptorManager *manager) { + didWriteDataCount++; + [manager forwardPreviousInterceptorDidWriteData]; + }]; + + __block NSUInteger globalStartCount = 0; + __block NSUInteger globalWriteDataCount = 0; + __block NSUInteger globalFinishCount = 0; + __block NSUInteger globalReceiveNextMessageCount = 0; + __block NSUInteger globalResponseHeaderCount = 0; + __block NSUInteger globalResponseDataCount = 0; + __block NSUInteger globalResponseCloseCount = 0; + __block NSUInteger globalDidWriteDataCount = 0; + + id globalFactory = [[HookInterceptorFactory alloc] + initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager) { + globalStartCount++; + XCTAssertEqualObjects(requestOptions.host, [[self class] host]); + XCTAssertEqualObjects(requestOptions.path, @"/grpc.testing.TestService/FullDuplexCall"); + XCTAssertEqual(requestOptions.safety, GRPCCallSafetyDefault); + [manager startNextInterceptorWithRequest:[requestOptions copy] + callOptions:[callOptions copy]]; + } + writeDataHook:^(id data, GRPCInterceptorManager *manager) { + globalWriteDataCount++; + [manager writeNextInterceptorWithData:data]; + } + finishHook:^(GRPCInterceptorManager *manager) { + globalFinishCount++; + [manager finishNextInterceptor]; + } + receiveNextMessagesHook:^(NSUInteger numberOfMessages, GRPCInterceptorManager *manager) { + globalReceiveNextMessageCount++; + [manager receiveNextInterceptorMessages:numberOfMessages]; + } + responseHeaderHook:^(NSDictionary *initialMetadata, GRPCInterceptorManager *manager) { + globalResponseHeaderCount++; + [manager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; + } + responseDataHook:^(id data, GRPCInterceptorManager *manager) { + globalResponseDataCount++; + [manager forwardPreviousInterceptorWithData:data]; + } + responseCloseHook:^(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager) { + globalResponseCloseCount++; + [manager forwardPreviousInterceptorCloseWithTrailingMetadata:trailingMetadata error:error]; + } + didWriteDataHook:^(GRPCInterceptorManager *manager) { + globalDidWriteDataCount++; + [manager forwardPreviousInterceptorDidWriteData]; + }]; + + NSArray *requests = @[ @1, @2, @3, @4 ]; + NSArray *responses = @[ @1, @2, @3, @4 ]; + + __block int index = 0; + + id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] + requestedResponseSize:responses[index]]; + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + options.transportType = [[self class] transportType]; + options.PEMRootCertificates = [[self class] PEMRootCertificates]; + options.hostNameOverride = [[self class] hostNameOverride]; + options.flowControlEnabled = YES; + options.interceptorFactories = @[ factory ]; + [GRPCCall2 registerGlobalInterceptor:globalFactory]; + + __block BOOL canWriteData = NO; + __block GRPCStreamingProtoCall *call = [_service + fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:^(id message) { + index += 1; + if (index < 4) { + id request = [RMTStreamingOutputCallRequest + messageWithPayloadSize:requests[index] + requestedResponseSize:responses[index]]; + canWriteData = NO; + [call writeMessage:request]; + [call receiveNextMessage]; + } else { + [call finish]; + } + } + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + [expectation fulfill]; + } + writeMessageCallback:^{ + canWriteData = YES; + }] + callOptions:options]; + [call start]; + [call receiveNextMessage]; + [call writeMessage:request]; + + [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; + XCTAssertEqual(startCount, 1); + XCTAssertEqual(writeDataCount, 4); + XCTAssertEqual(finishCount, 1); + XCTAssertEqual(receiveNextMessageCount, 4); + XCTAssertEqual(responseHeaderCount, 1); + XCTAssertEqual(responseDataCount, 4); + XCTAssertEqual(responseCloseCount, 1); + XCTAssertEqual(didWriteDataCount, 4); + XCTAssertEqual(globalStartCount, 1); + XCTAssertEqual(globalWriteDataCount, 4); + XCTAssertEqual(globalFinishCount, 1); + XCTAssertEqual(globalReceiveNextMessageCount, 4); + XCTAssertEqual(globalResponseHeaderCount, 1); + XCTAssertEqual(globalResponseDataCount, 4); + XCTAssertEqual(globalResponseCloseCount, 1); + XCTAssertEqual(globalDidWriteDataCount, 4); +} + @end From 219c3b38aa9d108c3c1126f4bed93c60a341b5c3 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 13 Jun 2019 16:55:37 -0700 Subject: [PATCH 0525/1555] Clang-tidy --- test/cpp/end2end/delegating_channel_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cpp/end2end/delegating_channel_test.cc b/test/cpp/end2end/delegating_channel_test.cc index 764a3eade88..553ec94f1dc 100644 --- a/test/cpp/end2end/delegating_channel_test.cc +++ b/test/cpp/end2end/delegating_channel_test.cc @@ -45,8 +45,8 @@ namespace { class TestChannel : public internal::DelegatingChannel { public: - TestChannel(std::shared_ptr delegate_channel) - : internal::DelegatingChannel(std::move(delegate_channel)) {} + TestChannel(const std::shared_ptr& delegate_channel) + : internal::DelegatingChannel(delegate_channel) {} // Always returns GRPC_CHANNEL_READY grpc_connectivity_state GetState(bool try_to_connect) override { return GRPC_CHANNEL_READY; From cceca10a8a64e503a1cc21b6333736b400e75e1b Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 13 Jun 2019 17:05:51 -0700 Subject: [PATCH 0526/1555] Fix data race, heap use-after-free issue in bm_chttp2_transport --- test/cpp/microbenchmarks/bm_chttp2_transport.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc index 05504584c20..a82b10fc178 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc @@ -387,7 +387,7 @@ static void BM_TransportStreamSend(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; Fixture f(grpc::ChannelArguments(), true); - auto s = std::unique_ptr(new Stream(&f)); + auto* s = new Stream(&f); s->Init(state); grpc_transport_stream_op_batch op; grpc_transport_stream_op_batch_payload op_payload(nullptr); @@ -450,9 +450,8 @@ static void BM_TransportStreamSend(benchmark::State& state) { op.cancel_stream = true; op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED; s->Op(&op); - s->DestroyThen(MakeOnceClosure([](grpc_error* error) {})); + s->DestroyThen(MakeOnceClosure([s](grpc_error* error) { delete s; })); f.FlushExecCtx(); - s.reset(); track_counters.Finish(state); grpc_metadata_batch_destroy(&b); grpc_slice_unref(send_slice); From a0f5cb45285bd9320c2c587c9a3b2fa7b2e7041c Mon Sep 17 00:00:00 2001 From: yang-g Date: Thu, 13 Jun 2019 22:08:09 -0700 Subject: [PATCH 0527/1555] Fix assignment operator --- include/grpcpp/impl/codegen/call_op_set.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/grpcpp/impl/codegen/call_op_set.h b/include/grpcpp/impl/codegen/call_op_set.h index 95664a800fa..c3ae6c4e3d2 100644 --- a/include/grpcpp/impl/codegen/call_op_set.h +++ b/include/grpcpp/impl/codegen/call_op_set.h @@ -188,11 +188,6 @@ class WriteOptions { /// \sa GRPC_WRITE_LAST_MESSAGE bool is_last_message() const { return last_message_; } - WriteOptions& operator=(const WriteOptions& rhs) { - flags_ = rhs.flags_; - return *this; - } - private: void SetBit(const uint32_t mask) { flags_ |= mask; } From b216c3431469af4723cc10ea6712d3f7e8301c98 Mon Sep 17 00:00:00 2001 From: yang-g Date: Thu, 13 Jun 2019 22:15:53 -0700 Subject: [PATCH 0528/1555] Mark some methods virtual --- include/grpcpp/impl/codegen/server_callback.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/grpcpp/impl/codegen/server_callback.h b/include/grpcpp/impl/codegen/server_callback.h index da08ec963e4..ab47873e40a 100644 --- a/include/grpcpp/impl/codegen/server_callback.h +++ b/include/grpcpp/impl/codegen/server_callback.h @@ -348,7 +348,8 @@ class ServerBidiReactor : public internal::ServerReactor { private: friend class ServerCallbackReaderWriter; - void BindStream(ServerCallbackReaderWriter* stream) { + virtual void BindStream( + ServerCallbackReaderWriter* stream) { stream_ = stream; } @@ -382,7 +383,9 @@ class ServerReadReactor : public internal::ServerReactor { private: friend class ServerCallbackReader; - void BindReader(ServerCallbackReader* reader) { reader_ = reader; } + virtual void BindReader(ServerCallbackReader* reader) { + reader_ = reader; + } ServerCallbackReader* reader_; }; @@ -424,7 +427,9 @@ class ServerWriteReactor : public internal::ServerReactor { private: friend class ServerCallbackWriter; - void BindWriter(ServerCallbackWriter* writer) { writer_ = writer; } + virtual void BindWriter(ServerCallbackWriter* writer) { + writer_ = writer; + } ServerCallbackWriter* writer_; }; From 46ed7524f90b1ddbf8fd005bb46dd7177ff7e6f7 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Fri, 14 Jun 2019 00:38:31 +0200 Subject: [PATCH 0529/1555] Bazel version syncup. --- templates/tools/dockerfile/bazel.include | 2 +- tools/dockerfile/test/bazel/Dockerfile | 2 +- tools/dockerfile/test/sanity/Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/tools/dockerfile/bazel.include b/templates/tools/dockerfile/bazel.include index 272936007da..adde6ed4787 100644 --- a/templates/tools/dockerfile/bazel.include +++ b/templates/tools/dockerfile/bazel.include @@ -2,7 +2,7 @@ # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.24.1 +ENV BAZEL_VERSION 0.26.0 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/dockerfile/test/bazel/Dockerfile b/tools/dockerfile/test/bazel/Dockerfile index df7a7a2f32a..7e7903359e7 100644 --- a/tools/dockerfile/test/bazel/Dockerfile +++ b/tools/dockerfile/test/bazel/Dockerfile @@ -52,7 +52,7 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.2.post1 six==1.10.0 t # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.24.1 +ENV BAZEL_VERSION 0.26.0 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index 9a080d0efb2..ca786e264ed 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -98,7 +98,7 @@ ENV CLANG_TIDY=clang-tidy # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.24.1 +ENV BAZEL_VERSION 0.26.0 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 From a0dc6f7e4a94087e4a1c776cb68c0aa16cb1e47c Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Fri, 14 Jun 2019 00:39:25 +0200 Subject: [PATCH 0530/1555] More syncup. --- tools/remote_build/rbe_common.bazelrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/remote_build/rbe_common.bazelrc b/tools/remote_build/rbe_common.bazelrc index 63b49c5c42d..b494e173856 100644 --- a/tools/remote_build/rbe_common.bazelrc +++ b/tools/remote_build/rbe_common.bazelrc @@ -84,4 +84,4 @@ build:ubsan --copt=-gmlt # TODO(jtattermusch): use more reasonable test timeout build:ubsan --test_timeout=3600 # override the config-agnostic crosstool_top -build:ubsan --crosstool_top=@bazel_toolchains//configs/experimental/ubuntu16_04_clang/1.2/bazel_0.23.0/ubsan:toolchain +build:ubsan --crosstool_top=@bazel_toolchains//configs/experimental/ubuntu16_04_clang/1.2/bazel_0.26.0/ubsan:toolchain From 0472933d71d82595d5796bbacce91d90f8ace280 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Fri, 14 Jun 2019 06:41:46 +0200 Subject: [PATCH 0531/1555] Trying to fix build. --- examples/python/multiprocessing/BUILD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/python/multiprocessing/BUILD b/examples/python/multiprocessing/BUILD index 0e135f471f2..8140d80633a 100644 --- a/examples/python/multiprocessing/BUILD +++ b/examples/python/multiprocessing/BUILD @@ -36,7 +36,7 @@ py_binary( "//src/python/grpcio/grpc:grpcio", ":prime_proto_pb2", ], - default_python_version = "PY3", + python_version = "PY3", ) py_binary( @@ -50,7 +50,7 @@ py_binary( "//conditions:default": [requirement("futures")], "//:python3": [], }), - default_python_version = "PY3", + python_version = "PY3", ) py_test( From a3fd28bdbf9638c5a283b7586541b406c6663d51 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 14 Jun 2019 02:33:01 -0400 Subject: [PATCH 0532/1555] fix ubsan build for 0.26 --- bazel/grpc_deps.bzl | 8 ++++---- tools/remote_build/rbe_common.bazelrc | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 4182a7157a0..eeb0546a973 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -186,11 +186,11 @@ def grpc_deps(): if "bazel_toolchains" not in native.existing_rules(): http_archive( name = "bazel_toolchains", - sha256 = "88e818f9f03628eef609c8429c210ecf265ffe46c2af095f36c7ef8b1855fef5", - strip_prefix = "bazel-toolchains-92dd8a7a518a2fb7ba992d47c8b38299fe0be825", + sha256 = "d968b414b32aa99c86977e1171645d31da2b52ac88060de3ac1e49932d5dcbf1", + strip_prefix = "bazel-toolchains-4bd5df80d77aa7f4fb943dfdfad5c9056a62fb47", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/92dd8a7a518a2fb7ba992d47c8b38299fe0be825.tar.gz", - "https://github.com/bazelbuild/bazel-toolchains/archive/92dd8a7a518a2fb7ba992d47c8b38299fe0be825.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/4bd5df80d77aa7f4fb943dfdfad5c9056a62fb47.tar.gz", + "https://github.com/bazelbuild/bazel-toolchains/archive/4bd5df80d77aa7f4fb943dfdfad5c9056a62fb47.tar.gz", ], ) diff --git a/tools/remote_build/rbe_common.bazelrc b/tools/remote_build/rbe_common.bazelrc index b494e173856..6baaf24732c 100644 --- a/tools/remote_build/rbe_common.bazelrc +++ b/tools/remote_build/rbe_common.bazelrc @@ -84,4 +84,7 @@ build:ubsan --copt=-gmlt # TODO(jtattermusch): use more reasonable test timeout build:ubsan --test_timeout=3600 # override the config-agnostic crosstool_top -build:ubsan --crosstool_top=@bazel_toolchains//configs/experimental/ubuntu16_04_clang/1.2/bazel_0.26.0/ubsan:toolchain +# how to update the bazel toolchain for ubsan: +# - check for the latest released version in https://github.com/bazelbuild/bazel-toolchains/tree/master/configs/experimental/ubuntu16_04_clang +# - you might need to update the bazel_toolchains dependency in grpc_deps.bzl +build:ubsan --crosstool_top=@bazel_toolchains//configs/experimental/ubuntu16_04_clang/1.2/bazel_0.23.0/ubsan:toolchain From 19c9b193c560895292917415aac7ffe5333229f1 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 14 Jun 2019 08:11:39 -0700 Subject: [PATCH 0533/1555] fix typos --- src/objective-c/tests/InteropTests/InteropTests.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 962a15cbf8c..2c54fb80f3d 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -1666,10 +1666,10 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager } } -- (void)testIntecepptorAndGlobalInterceptor { +- (void)testInterceptorAndGlobalInterceptor { XCTAssertNotNil([[self class] host]); __weak XCTestExpectation *expectation = - [self expectationWithDescription:@"testGlobalInterceptor"]; + [self expectationWithDescription:@"testInterceptorAndGlobalInterceptor"]; __block NSUInteger startCount = 0; __block NSUInteger writeDataCount = 0; From fce831a694056022275800bed5a9cc9a33b9f488 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 14 Jun 2019 08:20:48 -0700 Subject: [PATCH 0534/1555] Add copyright and comment --- src/objective-c/tests/examples_build_test.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/objective-c/tests/examples_build_test.sh b/src/objective-c/tests/examples_build_test.sh index 7bf4d67d019..047106d8bd2 100755 --- a/src/objective-c/tests/examples_build_test.sh +++ b/src/objective-c/tests/examples_build_test.sh @@ -1,4 +1,19 @@ #!/bin/bash +# Copyright 2015 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This script is used after a release to verify the released pods are working appropriately set -ex From 5a354d79efbd284cf99f445175aea2b18f1b48c3 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 14 Jun 2019 10:16:19 -0700 Subject: [PATCH 0535/1555] fix cannot find tests --- tools/internal_ci/macos/grpc_basictests_objc_examples.cfg | 2 +- tools/internal_ci/macos/grpc_basictests_objc_ios.cfg | 2 +- tools/internal_ci/macos/grpc_basictests_objc_mac.cfg | 2 +- .../macos/pull_request/grpc_basictests_objc_examples.cfg | 2 +- .../macos/pull_request/grpc_basictests_objc_ios.cfg | 2 +- .../macos/pull_request/grpc_basictests_objc_mac.cfg | 2 +- tools/run_tests/run_tests_matrix.py | 5 +++-- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/internal_ci/macos/grpc_basictests_objc_examples.cfg b/tools/internal_ci/macos/grpc_basictests_objc_examples.cfg index ccfc847cbef..bdfd62c7937 100644 --- a/tools/internal_ci/macos/grpc_basictests_objc_examples.cfg +++ b/tools/internal_ci/macos/grpc_basictests_objc_examples.cfg @@ -27,5 +27,5 @@ action { env_vars { key: "RUN_TESTS_FLAGS" - value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results --extra_args '-r ios-buildtest-.*'" + value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results --extra_args -r ios-buildtest-.*" } diff --git a/tools/internal_ci/macos/grpc_basictests_objc_ios.cfg b/tools/internal_ci/macos/grpc_basictests_objc_ios.cfg index c6cf3e071d4..faef331cab5 100644 --- a/tools/internal_ci/macos/grpc_basictests_objc_ios.cfg +++ b/tools/internal_ci/macos/grpc_basictests_objc_ios.cfg @@ -27,5 +27,5 @@ action { env_vars { key: "RUN_TESTS_FLAGS" - value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results --extra_args '-r ios-test-.*'" + value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results --extra_args -r ios-test-.*" } diff --git a/tools/internal_ci/macos/grpc_basictests_objc_mac.cfg b/tools/internal_ci/macos/grpc_basictests_objc_mac.cfg index fc7313e4b28..19849c357f3 100644 --- a/tools/internal_ci/macos/grpc_basictests_objc_mac.cfg +++ b/tools/internal_ci/macos/grpc_basictests_objc_mac.cfg @@ -27,5 +27,5 @@ action { env_vars { key: "RUN_TESTS_FLAGS" - value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results --extra_args '-r mac-test-.*'" + value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results --extra_args -r mac-test-.*" } diff --git a/tools/internal_ci/macos/pull_request/grpc_basictests_objc_examples.cfg b/tools/internal_ci/macos/pull_request/grpc_basictests_objc_examples.cfg index a95c51c8c4a..e2e55777ad1 100644 --- a/tools/internal_ci/macos/pull_request/grpc_basictests_objc_examples.cfg +++ b/tools/internal_ci/macos/pull_request/grpc_basictests_objc_examples.cfg @@ -27,5 +27,5 @@ action { env_vars { key: "RUN_TESTS_FLAGS" - value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --extra_args '-r ios-buildtest-.*'" + value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --extra_args -r ios-buildtest-.*" } diff --git a/tools/internal_ci/macos/pull_request/grpc_basictests_objc_ios.cfg b/tools/internal_ci/macos/pull_request/grpc_basictests_objc_ios.cfg index 8b2fead4342..4a4539b2353 100644 --- a/tools/internal_ci/macos/pull_request/grpc_basictests_objc_ios.cfg +++ b/tools/internal_ci/macos/pull_request/grpc_basictests_objc_ios.cfg @@ -27,5 +27,5 @@ action { env_vars { key: "RUN_TESTS_FLAGS" - value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --extra_args '-r ios-test-.*'" + value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --extra_args -r ios-test-.*" } diff --git a/tools/internal_ci/macos/pull_request/grpc_basictests_objc_mac.cfg b/tools/internal_ci/macos/pull_request/grpc_basictests_objc_mac.cfg index 43e3ca381ac..98cf9345280 100644 --- a/tools/internal_ci/macos/pull_request/grpc_basictests_objc_mac.cfg +++ b/tools/internal_ci/macos/pull_request/grpc_basictests_objc_mac.cfg @@ -27,5 +27,5 @@ action { env_vars { key: "RUN_TESTS_FLAGS" - value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --extra_args '-r mac-test-.*'" + value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --extra_args -r mac-test-.*" } diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index 7de1cb975d3..06a52b0f76e 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -246,7 +246,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): # supported on mac only. test_jobs += _generate_jobs( languages=['objc'], - configs=['dbg'], + configs=['opt'], platforms=['macos'], labels=['basictests', 'multilang'], extra_args=extra_args, @@ -523,6 +523,7 @@ if __name__ == "__main__": '--extra_args', default='', type=str, + nargs=argparse.REMAINDER, help='Extra test args passed to each sub-script.') args = argp.parse_args() @@ -542,7 +543,7 @@ if __name__ == "__main__": extra_args.append('%s' % args.bq_result_table) extra_args.append('--measure_cpu_costs') if args.extra_args: - extra_args.extend(('%s' % args.extra_args).split()) + extra_args.extend(args.extra_args) all_jobs = _create_test_jobs(extra_args=extra_args, inner_jobs=args.inner_jobs) + \ _create_portability_test_jobs(extra_args=extra_args, inner_jobs=args.inner_jobs) From 550dae1c4787531232c1b306dec12db22c7dfd88 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 14 Jun 2019 10:41:35 -0700 Subject: [PATCH 0536/1555] Workaround the address contention issue --- .../python/debug/test/_debug_example_test.py | 31 +++++++------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/examples/python/debug/test/_debug_example_test.py b/examples/python/debug/test/_debug_example_test.py index 133fee2b0b6..af599e6a48b 100644 --- a/examples/python/debug/test/_debug_example_test.py +++ b/examples/python/debug/test/_debug_example_test.py @@ -32,30 +32,21 @@ _LOGGER.setLevel(logging.INFO) _FAILURE_RATE = 0.5 _NUMBER_OF_MESSAGES = 100 - -@contextmanager -def get_free_loopback_tcp_port(): - if socket.has_ipv6: - tcp_socket = socket.socket(socket.AF_INET6) - else: - tcp_socket = socket.socket(socket.AF_INET) - tcp_socket.bind(('', 0)) - address_tuple = tcp_socket.getsockname() - yield "localhost:%s" % (address_tuple[1]) - tcp_socket.close() - +_ADDR_TEMPLATE = 'localhost:%d' class DebugExampleTest(unittest.TestCase): def test_channelz_example(self): - with get_free_loopback_tcp_port() as addr: - server = debug_server.create_server( - addr=addr, failure_rate=_FAILURE_RATE) - server.start() - send_message.run(addr=addr, n=_NUMBER_OF_MESSAGES) - get_stats.run(addr=addr) - server.stop(None) - # No unhandled exception raised, test passed! + server = debug_server.create_server( + addr='[::]:0', failure_rate=_FAILURE_RATE) + port = server.add_insecure_port('[::]:0') + server.start() + address = _ADDR_TEMPLATE % port + + send_message.run(addr=address, n=_NUMBER_OF_MESSAGES) + get_stats.run(addr=address) + server.stop(None) + # No unhandled exception raised, test passed! if __name__ == '__main__': From 0273879aed4ef61f87cf65d537cfdfdc11db40b7 Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Fri, 14 Jun 2019 10:43:09 -0700 Subject: [PATCH 0537/1555] Fix typo --- src/proto/grpc/channelz/channelz.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proto/grpc/channelz/channelz.proto b/src/proto/grpc/channelz/channelz.proto index 20de23f7fa3..f0ebda07213 100644 --- a/src/proto/grpc/channelz/channelz.proto +++ b/src/proto/grpc/channelz/channelz.proto @@ -35,7 +35,7 @@ option java_outer_classname = "ChannelzProto"; // Channel is a logical grouping of channels, subchannels, and sockets. message Channel { - // The identifier for this channel. This should bet set. + // The identifier for this channel. This should be set. ChannelRef ref = 1; // Data specific to this channel. ChannelData data = 2; From 799ffbbd019ee48f8ecd96649c67850f9fc2595f Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 14 Jun 2019 12:25:45 -0700 Subject: [PATCH 0538/1555] Update license --- src/objective-c/tests/examples_build_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/tests/examples_build_test.sh b/src/objective-c/tests/examples_build_test.sh index 047106d8bd2..92ebaacc82c 100755 --- a/src/objective-c/tests/examples_build_test.sh +++ b/src/objective-c/tests/examples_build_test.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2015 gRPC authors. +# Copyright 2019 gRPC authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From 5b329fd1aa5a6a1ff4ae1d9b6c83e33342392c31 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 14 Jun 2019 13:17:37 -0700 Subject: [PATCH 0539/1555] Add experimental notice to global interceptor --- src/objective-c/GRPCClient/GRPCCall+Interceptor.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/objective-c/GRPCClient/GRPCCall+Interceptor.h b/src/objective-c/GRPCClient/GRPCCall+Interceptor.h index 953846d8c99..4183e0aa20e 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Interceptor.h +++ b/src/objective-c/GRPCClient/GRPCCall+Interceptor.h @@ -16,6 +16,8 @@ * */ +// The global interceptor feature is experimental and might be modified or removed at any time. + #import "GRPCCall.h" @protocol GRPCInterceptorFactory; From f05c475f010532c5dabc2d11b726cd00a5802736 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Fri, 14 Jun 2019 14:34:37 -0700 Subject: [PATCH 0540/1555] Fix Python3 incompatibility --- test/core/bad_client/gen_build_yaml.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/core/bad_client/gen_build_yaml.py b/test/core/bad_client/gen_build_yaml.py index bd311ccfd90..a4f3e4a0a34 100755 --- a/test/core/bad_client/gen_build_yaml.py +++ b/test/core/bad_client/gen_build_yaml.py @@ -17,6 +17,7 @@ """Generates the appropriate build.json data for all the bad_client tests.""" +from __future__ import print_function import collections import yaml @@ -77,7 +78,7 @@ def main(): ] } for t in sorted(BAD_CLIENT_TESTS.keys())]} - print yaml.dump(json) + print(yaml.dump(json)) if __name__ == '__main__': From 56a0153f167e1bf504e917fd527a08b67d6ace1e Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 14 Jun 2019 14:44:49 -0700 Subject: [PATCH 0541/1555] Heap allocate the stream object for other benchmark cases too --- .../microbenchmarks/bm_chttp2_transport.cc | 60 ++++++++++--------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc index a82b10fc178..3df979e8ddb 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc @@ -259,18 +259,21 @@ static void BM_StreamCreateDestroy(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; Fixture f(grpc::ChannelArguments(), true); - Stream s(&f); + auto* s = new Stream(&f); grpc_transport_stream_op_batch op; grpc_transport_stream_op_batch_payload op_payload(nullptr); memset(&op, 0, sizeof(op)); op.cancel_stream = true; op.payload = &op_payload; op_payload.cancel_stream.cancel_error = GRPC_ERROR_CANCELLED; - std::unique_ptr next = MakeClosure([&](grpc_error* error) { - if (!state.KeepRunning()) return; - s.Init(state); - s.Op(&op); - s.DestroyThen(next.get()); + std::unique_ptr next = MakeClosure([&, s](grpc_error* error) { + if (!state.KeepRunning()) { + delete s; + return; + } + s->Init(state); + s->Op(&op); + s->DestroyThen(next.get()); }); GRPC_CLOSURE_RUN(next.get(), GRPC_ERROR_NONE); f.FlushExecCtx(); @@ -305,7 +308,7 @@ static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; Fixture f(grpc::ChannelArguments(), true); - Stream s(&f); + auto* s = new Stream(&f); grpc_transport_stream_op_batch op; grpc_transport_stream_op_batch_payload op_payload(nullptr); std::unique_ptr start; @@ -327,21 +330,24 @@ static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State& state) { } f.FlushExecCtx(); - start = MakeClosure([&](grpc_error* error) { - if (!state.KeepRunning()) return; - s.Init(state); + start = MakeClosure([&, s](grpc_error* error) { + if (!state.KeepRunning()) { + delete s; + return; + } + s->Init(state); reset_op(); op.on_complete = done.get(); op.send_initial_metadata = true; op.payload->send_initial_metadata.send_initial_metadata = &b; - s.Op(&op); + s->Op(&op); }); done = MakeClosure([&](grpc_error* error) { reset_op(); op.cancel_stream = true; op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED; - s.Op(&op); - s.DestroyThen(start.get()); + s->Op(&op); + s->DestroyThen(start.get()); }); GRPC_CLOSURE_SCHED(start.get(), GRPC_ERROR_NONE); f.FlushExecCtx(); @@ -355,8 +361,8 @@ static void BM_TransportEmptyOp(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; Fixture f(grpc::ChannelArguments(), true); - Stream s(&f); - s.Init(state); + auto* s = new Stream(&f); + s->Init(state); grpc_transport_stream_op_batch op; grpc_transport_stream_op_batch_payload op_payload(nullptr); auto reset_op = [&]() { @@ -367,15 +373,15 @@ static void BM_TransportEmptyOp(benchmark::State& state) { if (!state.KeepRunning()) return; reset_op(); op.on_complete = c.get(); - s.Op(&op); + s->Op(&op); }); GRPC_CLOSURE_SCHED(c.get(), GRPC_ERROR_NONE); f.FlushExecCtx(); reset_op(); op.cancel_stream = true; op_payload.cancel_stream.cancel_error = GRPC_ERROR_CANCELLED; - s.Op(&op); - s.DestroyThen(MakeOnceClosure([](grpc_error* error) {})); + s->Op(&op); + s->DestroyThen(MakeOnceClosure([s](grpc_error* error) { delete s; })); f.FlushExecCtx(); track_counters.Finish(state); } @@ -519,8 +525,8 @@ static void BM_TransportStreamRecv(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; Fixture f(grpc::ChannelArguments(), true); - Stream s(&f); - s.Init(state); + auto* s = new Stream(&f); + s->Init(state); grpc_transport_stream_op_batch_payload op_payload(nullptr); grpc_transport_stream_op_batch op; grpc_core::OrphanablePtr recv_stream; @@ -556,7 +562,7 @@ static void BM_TransportStreamRecv(benchmark::State& state) { std::unique_ptr c = MakeClosure([&](grpc_error* error) { if (!state.KeepRunning()) return; // force outgoing window to be yuge - s.chttp2_stream()->flow_control->TestOnlyForceHugeWindow(); + s->chttp2_stream()->flow_control->TestOnlyForceHugeWindow(); f.chttp2_transport()->flow_control->TestOnlyForceHugeWindow(); received = 0; reset_op(); @@ -564,7 +570,7 @@ static void BM_TransportStreamRecv(benchmark::State& state) { op.recv_message = true; op.payload->recv_message.recv_message = &recv_stream; op.payload->recv_message.recv_message_ready = drain_start.get(); - s.Op(&op); + s->Op(&op); f.PushInput(grpc_slice_ref(incoming_data)); }); @@ -605,7 +611,7 @@ static void BM_TransportStreamRecv(benchmark::State& state) { op.payload->recv_initial_metadata.recv_initial_metadata_ready = do_nothing.get(); op.on_complete = c.get(); - s.Op(&op); + s->Op(&op); f.PushInput(SLICE_FROM_BUFFER( "\x00\x00\x00\x04\x00\x00\x00\x00\x00" // Generated using: @@ -623,12 +629,12 @@ static void BM_TransportStreamRecv(benchmark::State& state) { reset_op(); op.cancel_stream = true; op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED; - s.Op(&op); - s.DestroyThen(MakeOnceClosure([](grpc_error* error) {})); - f.FlushExecCtx(); - track_counters.Finish(state); + s->Op(&op); + s->DestroyThen(MakeOnceClosure([s](grpc_error* error) { delete s; })); grpc_metadata_batch_destroy(&b); grpc_metadata_batch_destroy(&b_recv); + f.FlushExecCtx(); + track_counters.Finish(state); grpc_slice_unref(incoming_data); } BENCHMARK(BM_TransportStreamRecv)->Range(0, 128 * 1024 * 1024); From 0719ebd2ed3dd057d9630c26c013cdcd186cbede Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 14 Jun 2019 14:58:51 -0700 Subject: [PATCH 0542/1555] Use new connection for every test case --- src/objective-c/tests/InteropTests/InteropTests.m | 5 +++++ src/objective-c/tests/MacTests/StressTests.m | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 91e133a1300..197ab7f3da5 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -364,6 +364,11 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager [GRPCCall resetHostSettings]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + [GRPCCall closeOpenConnections]; +#pragma clang diagnostic pop + _service = [[self class] host] ? [RMTTestService serviceWithHost:[[self class] host]] : nil; } diff --git a/src/objective-c/tests/MacTests/StressTests.m b/src/objective-c/tests/MacTests/StressTests.m index 22174b58665..3c6ecd52610 100644 --- a/src/objective-c/tests/MacTests/StressTests.m +++ b/src/objective-c/tests/MacTests/StressTests.m @@ -118,6 +118,11 @@ extern const char *kCFStreamVarName; [GRPCCall resetHostSettings]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + [GRPCCall closeOpenConnections]; +#pragma clang diagnostic pop + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; options.transportType = [[self class] transportType]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; From 536765b2f3ca2f359c16e7353a2bcf21705e327e Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 14 Jun 2019 15:11:35 -0700 Subject: [PATCH 0543/1555] Surface exceptions in gevent IO manager --- .../grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi | 38 +++++++++---------- .../grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi | 30 +++++++-------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi index 30fdf6a7600..dff6fa2aea5 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi @@ -67,25 +67,25 @@ cdef extern from "src/core/lib/iomgr/tcp_custom.h": ctypedef void (*grpc_custom_close_callback)(grpc_custom_socket* socket) struct grpc_socket_vtable: - grpc_error* (*init)(grpc_custom_socket* socket, int domain); + grpc_error* (*init)(grpc_custom_socket* socket, int domain) except * void (*connect)(grpc_custom_socket* socket, const grpc_sockaddr* addr, - size_t len, grpc_custom_connect_callback cb); - void (*destroy)(grpc_custom_socket* socket); - void (*shutdown)(grpc_custom_socket* socket); - void (*close)(grpc_custom_socket* socket, grpc_custom_close_callback cb); + size_t len, grpc_custom_connect_callback cb) except * + void (*destroy)(grpc_custom_socket* socket) except * + void (*shutdown)(grpc_custom_socket* socket) except * + void (*close)(grpc_custom_socket* socket, grpc_custom_close_callback cb) except * void (*write)(grpc_custom_socket* socket, grpc_slice_buffer* slices, - grpc_custom_write_callback cb); + grpc_custom_write_callback cb) except * void (*read)(grpc_custom_socket* socket, char* buffer, size_t length, - grpc_custom_read_callback cb); + grpc_custom_read_callback cb) except * grpc_error* (*getpeername)(grpc_custom_socket* socket, - const grpc_sockaddr* addr, int* len); + const grpc_sockaddr* addr, int* len) except * grpc_error* (*getsockname)(grpc_custom_socket* socket, - const grpc_sockaddr* addr, int* len); + const grpc_sockaddr* addr, int* len) except * grpc_error* (*bind)(grpc_custom_socket* socket, const grpc_sockaddr* addr, - size_t len, int flags); - grpc_error* (*listen)(grpc_custom_socket* socket); + size_t len, int flags) except * + grpc_error* (*listen)(grpc_custom_socket* socket) except * void (*accept)(grpc_custom_socket* socket, grpc_custom_socket* client, - grpc_custom_accept_callback cb); + grpc_custom_accept_callback cb) except * cdef extern from "src/core/lib/iomgr/timer_custom.h": struct grpc_custom_timer: @@ -94,17 +94,17 @@ cdef extern from "src/core/lib/iomgr/timer_custom.h": # We don't care about the rest of the fields struct grpc_custom_timer_vtable: - void (*start)(grpc_custom_timer* t); - void (*stop)(grpc_custom_timer* t); + void (*start)(grpc_custom_timer* t) except * + void (*stop)(grpc_custom_timer* t) except * - void grpc_custom_timer_callback(grpc_custom_timer* t, grpc_error* error); + void grpc_custom_timer_callback(grpc_custom_timer* t, grpc_error* error) cdef extern from "src/core/lib/iomgr/pollset_custom.h": struct grpc_custom_poller_vtable: - void (*init)() - void (*poll)(size_t timeout_ms) - void (*kick)() - void (*shutdown)() + void (*init)() except * + void (*poll)(size_t timeout_ms) except * + void (*kick)() except * + void (*shutdown)() except * cdef extern from "src/core/lib/iomgr/iomgr_custom.h": void grpc_custom_iomgr_init(grpc_socket_vtable* socket, diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi index a1618d04d0e..3709cfb0296 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi @@ -84,7 +84,7 @@ cdef class SocketWrapper: self.c_buffer = NULL self.len = 0 -cdef grpc_error* socket_init(grpc_custom_socket* socket, int domain) with gil: +cdef grpc_error* socket_init(grpc_custom_socket* socket, int domain) except * with gil: sw = SocketWrapper() sw.c_socket = socket sw.sockopts = [] @@ -112,7 +112,7 @@ def socket_connect_async(socket_wrapper, addr_tuple): cdef void socket_connect(grpc_custom_socket* socket, const grpc_sockaddr* addr, size_t addr_len, - grpc_custom_connect_callback cb) with gil: + grpc_custom_connect_callback cb) except * with gil: py_socket = None socket_wrapper = socket.impl socket_wrapper.connect_cb = cb @@ -125,10 +125,10 @@ cdef void socket_connect(grpc_custom_socket* socket, const grpc_sockaddr* addr, socket_wrapper.socket = py_socket _spawn_greenlet(socket_connect_async, socket_wrapper, addr_tuple) -cdef void socket_destroy(grpc_custom_socket* socket) with gil: +cdef void socket_destroy(grpc_custom_socket* socket) except * with gil: cpython.Py_DECREF(socket.impl) -cdef void socket_shutdown(grpc_custom_socket* socket) with gil: +cdef void socket_shutdown(grpc_custom_socket* socket) except * with gil: try: (socket.impl).socket.shutdown(gevent_socket.SHUT_RDWR) except IOError as io_error: @@ -136,7 +136,7 @@ cdef void socket_shutdown(grpc_custom_socket* socket) with gil: raise io_error cdef void socket_close(grpc_custom_socket* socket, - grpc_custom_close_callback cb) with gil: + grpc_custom_close_callback cb) except * with gil: socket_wrapper = (socket.impl) if socket_wrapper.socket is not None: socket_wrapper.socket.close() @@ -176,7 +176,7 @@ def socket_write_async(socket_wrapper, write_bytes): socket_write_async_cython(socket_wrapper, write_bytes) cdef void socket_write(grpc_custom_socket* socket, grpc_slice_buffer* buffer, - grpc_custom_write_callback cb) with gil: + grpc_custom_write_callback cb) except * with gil: cdef char* start sw = socket.impl sw.write_cb = cb @@ -204,7 +204,7 @@ def socket_read_async(socket_wrapper): socket_read_async_cython(socket_wrapper) cdef void socket_read(grpc_custom_socket* socket, char* buffer, - size_t length, grpc_custom_read_callback cb) with gil: + size_t length, grpc_custom_read_callback cb) except * with gil: sw = socket.impl sw.read_cb = cb sw.c_buffer = buffer @@ -213,7 +213,7 @@ cdef void socket_read(grpc_custom_socket* socket, char* buffer, cdef grpc_error* socket_getpeername(grpc_custom_socket* socket, const grpc_sockaddr* addr, - int* length) with gil: + int* length) except * with gil: cdef char* src_buf peer = (socket.impl).socket.getpeername() @@ -226,7 +226,7 @@ cdef grpc_error* socket_getpeername(grpc_custom_socket* socket, cdef grpc_error* socket_getsockname(grpc_custom_socket* socket, const grpc_sockaddr* addr, - int* length) with gil: + int* length) except * with gil: cdef char* src_buf cdef grpc_resolved_address c_addr if (socket.impl).socket is None: @@ -245,7 +245,7 @@ def applysockopts(s): cdef grpc_error* socket_bind(grpc_custom_socket* socket, const grpc_sockaddr* addr, - size_t len, int flags) with gil: + size_t len, int flags) except * with gil: addr_tuple = sockaddr_to_tuple(addr, len) try: try: @@ -262,7 +262,7 @@ cdef grpc_error* socket_bind(grpc_custom_socket* socket, else: return grpc_error_none() -cdef grpc_error* socket_listen(grpc_custom_socket* socket) with gil: +cdef grpc_error* socket_listen(grpc_custom_socket* socket) except * with gil: (socket.impl).socket.listen(50) return grpc_error_none() @@ -374,16 +374,16 @@ cdef void timer_stop(grpc_custom_timer* t) with gil: ### pollset implementation ### ############################### -cdef void init_loop() with gil: +cdef void init_loop() except * with gil: pass -cdef void destroy_loop() with gil: +cdef void destroy_loop() except * with gil: g_pool.join() -cdef void kick_loop() with gil: +cdef void kick_loop() except * with gil: g_event.set() -cdef void run_loop(size_t timeout_ms) with gil: +cdef void run_loop(size_t timeout_ms) except * with gil: timeout = timeout_ms / 1000.0 if timeout_ms > 0: g_event.wait(timeout) From 9df04d95a2227eb65ea65601f7d8b0eaa902c231 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 14 Jun 2019 15:52:36 -0700 Subject: [PATCH 0544/1555] merge upstream/master --- CMakeLists.txt | 41 ++++++++++++++++++ Makefile | 42 +++++++++++++++++++ .../generated/sources_and_headers.json | 19 +++++++++ tools/run_tests/generated/tests.json | 24 +++++++++++ 4 files changed, 126 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 900b527d9fa..c11643eca6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -378,6 +378,7 @@ add_dependencies(buildtests_c memory_usage_test) endif() add_dependencies(buildtests_c message_compress_test) add_dependencies(buildtests_c minimal_stack_is_minimal_test) +add_dependencies(buildtests_c mpmcqueue_test) add_dependencies(buildtests_c multiple_server_queues_test) add_dependencies(buildtests_c murmur_hash_test) add_dependencies(buildtests_c no_server_test) @@ -1083,6 +1084,7 @@ add_library(grpc src/core/lib/iomgr/tcp_server_windows.cc src/core/lib/iomgr/tcp_uv.cc src/core/lib/iomgr/tcp_windows.cc + src/core/lib/iomgr/threadpool/mpmcqueue.cc src/core/lib/iomgr/time_averaged_stats.cc src/core/lib/iomgr/timer.cc src/core/lib/iomgr/timer_custom.cc @@ -1518,6 +1520,7 @@ add_library(grpc_cronet src/core/lib/iomgr/tcp_server_windows.cc src/core/lib/iomgr/tcp_uv.cc src/core/lib/iomgr/tcp_windows.cc + src/core/lib/iomgr/threadpool/mpmcqueue.cc src/core/lib/iomgr/time_averaged_stats.cc src/core/lib/iomgr/timer.cc src/core/lib/iomgr/timer_custom.cc @@ -1935,6 +1938,7 @@ add_library(grpc_test_util src/core/lib/iomgr/tcp_server_windows.cc src/core/lib/iomgr/tcp_uv.cc src/core/lib/iomgr/tcp_windows.cc + src/core/lib/iomgr/threadpool/mpmcqueue.cc src/core/lib/iomgr/time_averaged_stats.cc src/core/lib/iomgr/timer.cc src/core/lib/iomgr/timer_custom.cc @@ -2265,6 +2269,7 @@ add_library(grpc_test_util_unsecure src/core/lib/iomgr/tcp_server_windows.cc src/core/lib/iomgr/tcp_uv.cc src/core/lib/iomgr/tcp_windows.cc + src/core/lib/iomgr/threadpool/mpmcqueue.cc src/core/lib/iomgr/time_averaged_stats.cc src/core/lib/iomgr/timer.cc src/core/lib/iomgr/timer_custom.cc @@ -2571,6 +2576,7 @@ add_library(grpc_unsecure src/core/lib/iomgr/tcp_server_windows.cc src/core/lib/iomgr/tcp_uv.cc src/core/lib/iomgr/tcp_windows.cc + src/core/lib/iomgr/threadpool/mpmcqueue.cc src/core/lib/iomgr/time_averaged_stats.cc src/core/lib/iomgr/timer.cc src/core/lib/iomgr/timer_custom.cc @@ -3597,6 +3603,7 @@ add_library(grpc++_cronet src/core/lib/iomgr/tcp_server_windows.cc src/core/lib/iomgr/tcp_uv.cc src/core/lib/iomgr/tcp_windows.cc + src/core/lib/iomgr/threadpool/mpmcqueue.cc src/core/lib/iomgr/time_averaged_stats.cc src/core/lib/iomgr/timer.cc src/core/lib/iomgr/timer_custom.cc @@ -9354,6 +9361,40 @@ target_link_libraries(minimal_stack_is_minimal_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) +add_executable(mpmcqueue_test + test/core/iomgr/mpmcqueue_test.cc +) + + +target_include_directories(mpmcqueue_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} +) + +target_link_libraries(mpmcqueue_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + grpc + gpr +) + + # avoid dependency on libstdc++ + if (_gRPC_CORE_NOSTDCXX_FLAGS) + set_target_properties(mpmcqueue_test PROPERTIES LINKER_LANGUAGE C) + target_compile_options(mpmcqueue_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) + endif() + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + add_executable(multiple_server_queues_test test/core/end2end/multiple_server_queues_test.cc ) diff --git a/Makefile b/Makefile index 0325374e39e..9f05975da87 100644 --- a/Makefile +++ b/Makefile @@ -1092,6 +1092,7 @@ memory_usage_server: $(BINDIR)/$(CONFIG)/memory_usage_server memory_usage_test: $(BINDIR)/$(CONFIG)/memory_usage_test message_compress_test: $(BINDIR)/$(CONFIG)/message_compress_test minimal_stack_is_minimal_test: $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test +mpmcqueue_test: $(BINDIR)/$(CONFIG)/mpmcqueue_test multiple_server_queues_test: $(BINDIR)/$(CONFIG)/multiple_server_queues_test murmur_hash_test: $(BINDIR)/$(CONFIG)/murmur_hash_test nanopb_fuzzer_response_test: $(BINDIR)/$(CONFIG)/nanopb_fuzzer_response_test @@ -1513,6 +1514,7 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/memory_usage_test \ $(BINDIR)/$(CONFIG)/message_compress_test \ $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test \ + $(BINDIR)/$(CONFIG)/mpmcqueue_test \ $(BINDIR)/$(CONFIG)/multiple_server_queues_test \ $(BINDIR)/$(CONFIG)/murmur_hash_test \ $(BINDIR)/$(CONFIG)/no_server_test \ @@ -2092,6 +2094,8 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/message_compress_test || ( echo test message_compress_test failed ; exit 1 ) $(E) "[RUN] Testing minimal_stack_is_minimal_test" $(Q) $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test || ( echo test minimal_stack_is_minimal_test failed ; exit 1 ) + $(E) "[RUN] Testing mpmcqueue_test" + $(Q) $(BINDIR)/$(CONFIG)/mpmcqueue_test || ( echo test mpmcqueue_test failed ; exit 1 ) $(E) "[RUN] Testing multiple_server_queues_test" $(Q) $(BINDIR)/$(CONFIG)/multiple_server_queues_test || ( echo test multiple_server_queues_test failed ; exit 1 ) $(E) "[RUN] Testing murmur_hash_test" @@ -3561,6 +3565,7 @@ LIBGRPC_SRC = \ src/core/lib/iomgr/tcp_server_windows.cc \ src/core/lib/iomgr/tcp_uv.cc \ src/core/lib/iomgr/tcp_windows.cc \ + src/core/lib/iomgr/threadpool/mpmcqueue.cc \ src/core/lib/iomgr/time_averaged_stats.cc \ src/core/lib/iomgr/timer.cc \ src/core/lib/iomgr/timer_custom.cc \ @@ -3990,6 +3995,7 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/iomgr/tcp_server_windows.cc \ src/core/lib/iomgr/tcp_uv.cc \ src/core/lib/iomgr/tcp_windows.cc \ + src/core/lib/iomgr/threadpool/mpmcqueue.cc \ src/core/lib/iomgr/time_averaged_stats.cc \ src/core/lib/iomgr/timer.cc \ src/core/lib/iomgr/timer_custom.cc \ @@ -4400,6 +4406,7 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/iomgr/tcp_server_windows.cc \ src/core/lib/iomgr/tcp_uv.cc \ src/core/lib/iomgr/tcp_windows.cc \ + src/core/lib/iomgr/threadpool/mpmcqueue.cc \ src/core/lib/iomgr/time_averaged_stats.cc \ src/core/lib/iomgr/timer.cc \ src/core/lib/iomgr/timer_custom.cc \ @@ -4717,6 +4724,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/lib/iomgr/tcp_server_windows.cc \ src/core/lib/iomgr/tcp_uv.cc \ src/core/lib/iomgr/tcp_windows.cc \ + src/core/lib/iomgr/threadpool/mpmcqueue.cc \ src/core/lib/iomgr/time_averaged_stats.cc \ src/core/lib/iomgr/timer.cc \ src/core/lib/iomgr/timer_custom.cc \ @@ -4997,6 +5005,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/iomgr/tcp_server_windows.cc \ src/core/lib/iomgr/tcp_uv.cc \ src/core/lib/iomgr/tcp_windows.cc \ + src/core/lib/iomgr/threadpool/mpmcqueue.cc \ src/core/lib/iomgr/time_averaged_stats.cc \ src/core/lib/iomgr/timer.cc \ src/core/lib/iomgr/timer_custom.cc \ @@ -5996,6 +6005,7 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/iomgr/tcp_server_windows.cc \ src/core/lib/iomgr/tcp_uv.cc \ src/core/lib/iomgr/tcp_windows.cc \ + src/core/lib/iomgr/threadpool/mpmcqueue.cc \ src/core/lib/iomgr/time_averaged_stats.cc \ src/core/lib/iomgr/timer.cc \ src/core/lib/iomgr/timer_custom.cc \ @@ -12089,6 +12099,38 @@ endif endif +MPMCQUEUE_TEST_SRC = \ + test/core/iomgr/mpmcqueue_test.cc \ + +MPMCQUEUE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(MPMCQUEUE_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/mpmcqueue_test: openssl_dep_error + +else + + + +$(BINDIR)/$(CONFIG)/mpmcqueue_test: $(MPMCQUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LD) $(LDFLAGS) $(MPMCQUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/mpmcqueue_test + +endif + +$(OBJDIR)/$(CONFIG)/test/core/iomgr/mpmcqueue_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_mpmcqueue_test: $(MPMCQUEUE_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(MPMCQUEUE_TEST_OBJS:.o=.dep) +endif +endif + + MULTIPLE_SERVER_QUEUES_TEST_SRC = \ test/core/end2end/multiple_server_queues_test.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 0da1dc36ff9..12827875e32 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -1626,6 +1626,22 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "grpc", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c", + "name": "mpmcqueue_test", + "src": [ + "test/core/iomgr/mpmcqueue_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", @@ -8481,6 +8497,7 @@ "src/core/lib/iomgr/tcp_server_windows.cc", "src/core/lib/iomgr/tcp_uv.cc", "src/core/lib/iomgr/tcp_windows.cc", + "src/core/lib/iomgr/threadpool/mpmcqueue.cc", "src/core/lib/iomgr/time_averaged_stats.cc", "src/core/lib/iomgr/timer.cc", "src/core/lib/iomgr/timer_custom.cc", @@ -8652,6 +8669,7 @@ "src/core/lib/iomgr/tcp_server.h", "src/core/lib/iomgr/tcp_server_utils_posix.h", "src/core/lib/iomgr/tcp_windows.h", + "src/core/lib/iomgr/threadpool/mpmcqueue.h", "src/core/lib/iomgr/time_averaged_stats.h", "src/core/lib/iomgr/timer.h", "src/core/lib/iomgr/timer_custom.h", @@ -8809,6 +8827,7 @@ "src/core/lib/iomgr/tcp_server.h", "src/core/lib/iomgr/tcp_server_utils_posix.h", "src/core/lib/iomgr/tcp_windows.h", + "src/core/lib/iomgr/threadpool/mpmcqueue.h", "src/core/lib/iomgr/time_averaged_stats.h", "src/core/lib/iomgr/timer.h", "src/core/lib/iomgr/timer_custom.h", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 473e2e26c3a..545d9c77233 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -1959,6 +1959,30 @@ ], "uses_polling": false }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": false, + "language": "c", + "name": "mpmcqueue_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": true + }, { "args": [], "benchmark": false, From a633ad381416de7ba352c7a83e76d2619f40474a Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 14 Jun 2019 15:54:59 -0700 Subject: [PATCH 0545/1555] add mpmcqueue implementation ad test --- BUILD | 2 + build.yaml | 11 + src/core/lib/iomgr/threadpool/mpmcqueue.cc | 143 ++++++++++++ src/core/lib/iomgr/threadpool/mpmcqueue.h | 148 ++++++++++++ test/core/iomgr/BUILD | 11 + test/core/iomgr/mpmcqueue_test.cc | 253 +++++++++++++++++++++ 6 files changed, 568 insertions(+) create mode 100644 src/core/lib/iomgr/threadpool/mpmcqueue.cc create mode 100644 src/core/lib/iomgr/threadpool/mpmcqueue.h create mode 100644 test/core/iomgr/mpmcqueue_test.cc diff --git a/BUILD b/BUILD index 29eed995008..10d0d650419 100644 --- a/BUILD +++ b/BUILD @@ -837,6 +837,7 @@ grpc_cc_library( "src/core/lib/iomgr/tcp_server_windows.cc", "src/core/lib/iomgr/tcp_uv.cc", "src/core/lib/iomgr/tcp_windows.cc", + "src/core/lib/iomgr/threadpool/mpmcqueue.cc", "src/core/lib/iomgr/time_averaged_stats.cc", "src/core/lib/iomgr/timer.cc", "src/core/lib/iomgr/timer_custom.cc", @@ -982,6 +983,7 @@ grpc_cc_library( "src/core/lib/iomgr/tcp_server.h", "src/core/lib/iomgr/tcp_server_utils_posix.h", "src/core/lib/iomgr/tcp_windows.h", + "src/core/lib/iomgr/threadpool/mpmcqueue.h", "src/core/lib/iomgr/time_averaged_stats.h", "src/core/lib/iomgr/timer.h", "src/core/lib/iomgr/timer_custom.h", diff --git a/build.yaml b/build.yaml index bb53d6693fe..91d3cfe8c75 100644 --- a/build.yaml +++ b/build.yaml @@ -337,6 +337,7 @@ filegroups: - src/core/lib/iomgr/tcp_server_windows.cc - src/core/lib/iomgr/tcp_uv.cc - src/core/lib/iomgr/tcp_windows.cc + - src/core/lib/iomgr/threadpool/mpmcqueue.cc - src/core/lib/iomgr/time_averaged_stats.cc - src/core/lib/iomgr/timer.cc - src/core/lib/iomgr/timer_custom.cc @@ -507,6 +508,7 @@ filegroups: - src/core/lib/iomgr/tcp_server.h - src/core/lib/iomgr/tcp_server_utils_posix.h - src/core/lib/iomgr/tcp_windows.h + - src/core/lib/iomgr/threadpool/mpmcqueue.h - src/core/lib/iomgr/time_averaged_stats.h - src/core/lib/iomgr/timer.h - src/core/lib/iomgr/timer_custom.h @@ -3266,6 +3268,15 @@ targets: - grpc - gpr uses_polling: false +- name: mpmcqueue_test + build: test + language: c + src: + - test/core/iomgr/mpmcqueue_test.cc + deps: + - grpc_test_util + - grpc + - gpr - name: multiple_server_queues_test build: test language: c diff --git a/src/core/lib/iomgr/threadpool/mpmcqueue.cc b/src/core/lib/iomgr/threadpool/mpmcqueue.cc new file mode 100644 index 00000000000..f33ab0468a8 --- /dev/null +++ b/src/core/lib/iomgr/threadpool/mpmcqueue.cc @@ -0,0 +1,143 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/iomgr/threadpool/mpmcqueue.h" + +#include + +#include +#include +#include +#include +#include + +#include "src/core/lib/gprpp/sync.h" + +namespace grpc_core { + + + +inline void* MPMCQueue::PopFront() { + void* result = queue_head_->content; + Node* head_to_remove = queue_head_; + queue_head_ = queue_head_->next; + + count_.Store(count_.Load(MemoryOrder::RELAXED) - 1, MemoryOrder::RELAXED); + gpr_timespec wait_time = gpr_time_sub(gpr_now(GPR_CLOCK_PRECISE), + head_to_remove->insert_time); + // gpr_free(head_to_remove); + delete head_to_remove; + + // Update Stats info + stats_.num_completed++; + stats_.total_queue_cycles = gpr_time_add(stats_.total_queue_cycles, + wait_time); + stats_.max_queue_cycles = gpr_time_max( + gpr_convert_clock_type(stats_.max_queue_cycles, GPR_TIMESPAN), wait_time); + + if (count_.Load(MemoryOrder::RELAXED) == 0) { + stats_.busy_time_cycles = gpr_time_add( + stats_.busy_time_cycles, + gpr_time_sub(gpr_now(GPR_CLOCK_PRECISE), busy_time)); + } + + // Singal waiting thread + if (count_.Load(MemoryOrder::RELAXED) > 0 && num_waiters_ > 0) { + wait_nonempty_.Signal(); + } + + return result; +} + +MPMCQueue::MPMCQueue() : num_waiters_(0), queue_head_(0), queue_tail_(0) { + count_.Store(0, MemoryOrder::RELAXED); +} + +MPMCQueue::~MPMCQueue() { + GPR_ASSERT(count_.Load(MemoryOrder::RELAXED) == 0); + ReleasableMutexLock l(&mu_); + GPR_ASSERT(num_waiters_ == 0); + l.Unlock(); + PrintStats(); +} + +void MPMCQueue::Put(void* elem) { + MutexLock l(&mu_); + // Node* new_node = static_cast(gpr_malloc(sizeof(Node))); + // new_node->next = nullptr; + // new_node->content = elem; + // new_node->insert_time = gpr_now(GPR_CLOCK_PRECISE); + Node* new_node = static_cast(new Node(elem)); + if (count_.Load(MemoryOrder::RELAXED) == 0) { + busy_time = gpr_now(GPR_CLOCK_PRECISE); + queue_head_ = queue_tail_ = new_node; + } else { + queue_tail_->next = new_node; + queue_tail_ = queue_tail_->next; + } + count_.Store(count_.Load(MemoryOrder::RELAXED) + 1, MemoryOrder::RELAXED); + + // Update Stats info + stats_.num_started++; + + if (num_waiters_ > 0) { + wait_nonempty_.Signal(); + } +} + +void* MPMCQueue::Get() { + MutexLock l(&mu_); + if (count_.Load(MemoryOrder::RELAXED) == 0) { + num_waiters_++; + do { + wait_nonempty_.Wait(&mu_); + } while (count_.Load(MemoryOrder::RELAXED) == 0); + num_waiters_--; + } + GPR_ASSERT(count_.Load(MemoryOrder::RELAXED) > 0); + return PopFront(); +} + +void MPMCQueue::PrintStats() { + MutexLock l(&mu_); + gpr_log(GPR_INFO, "STATS INFO:"); + gpr_log(GPR_INFO, "num_started: %lu", stats_.num_started); + gpr_log(GPR_INFO, "num_completed: %lu", stats_.num_completed); + gpr_log(GPR_INFO, "total_queue_cycles: %d", + gpr_time_to_millis(stats_.total_queue_cycles)); + gpr_log(GPR_INFO, "max_queue_cycles: %d", + gpr_time_to_millis(stats_.max_queue_cycles)); + gpr_log(GPR_INFO, "busy_time_cycles: %d", + gpr_time_to_millis(stats_.busy_time_cycles)); +} + +MPMCQueue::Stats* MPMCQueue::queue_stats() { + MPMCQueue::Stats* result = new Stats(); + MutexLock l(&mu_); + result->total_queue_cycles = gpr_time_add(result->total_queue_cycles, + stats_.total_queue_cycles); + result->max_queue_cycles = gpr_time_add(result->max_queue_cycles, + stats_.max_queue_cycles); + result->busy_time_cycles = gpr_time_add(result->busy_time_cycles, + stats_.busy_time_cycles); + return result; +} + +} // namespace grpc_core diff --git a/src/core/lib/iomgr/threadpool/mpmcqueue.h b/src/core/lib/iomgr/threadpool/mpmcqueue.h new file mode 100644 index 00000000000..153784ae939 --- /dev/null +++ b/src/core/lib/iomgr/threadpool/mpmcqueue.h @@ -0,0 +1,148 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_MPMCQUEUE_H +#define GRPC_CORE_LIB_IOMGR_MPMCQUEUE_H + +#include + +#include +#include "src/core/lib/gprpp/atomic.h" +#include "src/core/lib/gprpp/sync.h" +#include + +namespace grpc_core { + +// Abstract base class of a MPMC queue interface +class MPMCQueueInterface { + public: + MPMCQueueInterface() {} + virtual ~MPMCQueueInterface() {} + + // Put elem into queue immediately at the end of queue. + // This might cause to block on full queue depending on implementation. + virtual void Put(void *elem) = 0; + + // Remove the oldest element from the queue and return it. + // This might cause to block on empty queue depending on implementation. + virtual void* Get() = 0; + + // Return number of elements in the queue currently + virtual int count() const = 0; +}; + +class MPMCQueue : public MPMCQueueInterface { + public: + struct Stats { // Stats of queue + uint64_t num_started; // Number of elements have been added to queue + uint64_t num_completed; // Number of elements have been removed from + // the queue + gpr_timespec total_queue_cycles; // Total waiting time that all the + // removed elements have spent in queue + gpr_timespec max_queue_cycles; // Max waiting time among all removed + // elements + gpr_timespec busy_time_cycles; // Accumulated amount of time that queue + // was not empty + + Stats() { + num_started = 0; + num_completed = 0; + total_queue_cycles = gpr_time_0(GPR_TIMESPAN); + max_queue_cycles = gpr_time_0(GPR_TIMESPAN); + busy_time_cycles = gpr_time_0(GPR_TIMESPAN); + } + void* operator new(size_t n) { + void* p = gpr_malloc(n); + return p; + } + + void operator delete(void* p) { + gpr_free(p); + } + }; + void* operator new(size_t n) { + void* p = gpr_malloc(n); + return p; + } + + void operator delete(void* p) { + gpr_free(p); + } + // Create a new Multiple-Producer-Multiple-Consumer Queue. The queue created + // will have infinite length. + explicit MPMCQueue(); + + // Release all resources hold by the queue. The queue must be empty, and no + // one waiting on conditional variables. + ~MPMCQueue(); + + // Put elem into queue immediately at the end of queue. Since the queue has + // infinite length, this routine will never block and should never fail. + void Put(void* elem); + + // Remove the oldest element from the queue and return it. + // This routine will cause the thread to block if queue is currently empty. + void* Get(); + + // Return number of elements in queue currently. + // There might be concurrently add/remove on queue, so count might change + // quickly. + int count() const { return count_.Load(MemoryOrder::RELAXED); } + + // Print out Stats. Time measurement are printed in millisecond. + void PrintStats(); + + // Return a copy of current stats info. This info will be changed quickly + // when queue is still running. This copy will not deleted by queue. + Stats* queue_stats(); + + private: + void* PopFront(); + + struct Node { + Node *next; // Linking + void *content; // Points to actual element + gpr_timespec insert_time; // Time for stats + Node(void* c) : content(c) { + next = nullptr; + insert_time = gpr_now(GPR_CLOCK_PRECISE); + } + void* operator new(size_t n) { + void* p = gpr_malloc(n); + return p; + } + + void operator delete(void* p) { + gpr_free(p); + } + }; + + Mutex mu_; // Protecting lock + CondVar wait_nonempty_; // Wait on empty queue on get + int num_waiters_; // Number of waiters + + Node *queue_head_; // Head of the queue, remove position + Node *queue_tail_; // End of queue, insert position + Atomic count_; // Number of elements in queue + Stats stats_; // Stats info + gpr_timespec busy_time; // Start time of busy queue +}; + +} // namespace grpc_core + +#endif /* GRPC_CORE_LIB_IOMGR_MPMCQUEUE_H */ diff --git a/test/core/iomgr/BUILD b/test/core/iomgr/BUILD index 1aefa0ab224..af67d5de25e 100644 --- a/test/core/iomgr/BUILD +++ b/test/core/iomgr/BUILD @@ -130,6 +130,17 @@ grpc_cc_test( ], ) +grpc_cc_test( + name = "mpmcqueue_test", + srcs = ["mpmcqueue_test.cc"], + language = "C++", + deps = [ + "//:gpr", + "//:grpc", + "//test/core/util:grpc_test_util", + ], +) + grpc_cc_test( name = "resolve_address_using_ares_resolver_posix_test", srcs = ["resolve_address_posix_test.cc"], diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc new file mode 100644 index 00000000000..d562f3c6722 --- /dev/null +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -0,0 +1,253 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "src/core/lib/iomgr/threadpool/mpmcqueue.h" + +#include +#include +#include + +#include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/thd.h" +#include "test/core/util/test_config.h" + +#define THREAD_SMALL_ITERATION 100 +#define THREAD_LARGE_ITERATION 10000 + +static void test_no_op(void) { + gpr_log(GPR_DEBUG, "test_no_op"); + grpc_core::MPMCQueue mpmcqueue; + gpr_log(GPR_DEBUG, "Checking count..."); + GPR_ASSERT(mpmcqueue.count() == 0); + gpr_log(GPR_DEBUG, "Done."); +} + +// Testing items for queue +struct WorkItem { + int index; + bool done; + + WorkItem(int i) : index(i) { + done = false; + } + void* operator new(size_t n) { + void* p = gpr_malloc(n); + return p; + } + + void operator delete(void* p) { + gpr_free(p); + } +}; + +static void test_small_queue(void) { + gpr_log(GPR_DEBUG, "test_small_queue"); + grpc_core::MPMCQueue small_queue; + for (int i = 0; i < THREAD_SMALL_ITERATION; ++i) { + small_queue.Put(static_cast(new WorkItem(i))); + } + GPR_ASSERT(small_queue.count() == THREAD_SMALL_ITERATION); + // Get items out in FIFO order + for (int i = 0; i < THREAD_SMALL_ITERATION; ++i) { + WorkItem* item = static_cast(small_queue.Get()); + GPR_ASSERT(i == item->index); + delete item; + } +} + +static void test_get_thd(void* args) { + grpc_core::MPMCQueue* mpmcqueue = static_cast(args); + + // count number of Get() called in this thread + int count = 0; + int last_index = -1; + WorkItem* item; + while ((item = static_cast(mpmcqueue->Get())) != NULL) { + count++; + GPR_ASSERT(item->index > last_index); + last_index = item->index; + GPR_ASSERT(!item->done); + delete item; + } + + gpr_log(GPR_DEBUG, "test_get_thd: %d times of Get() called.", count); +} + +static void test_get_empty(void) { + gpr_log(GPR_DEBUG, "test_get_empty"); + grpc_core::MPMCQueue mpmcqueue; + const int num_threads = 10; + grpc_core::Thread thds[num_threads]; + + // Fork threads. Threads should block at the beginning since queue is empty. + for (int i = 0; i < num_threads; ++i) { + thds[i] = grpc_core::Thread("mpmcq_test_ge_thd", test_get_thd, &mpmcqueue); + thds[i].Start(); + } + + for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { + mpmcqueue.Put(static_cast(new WorkItem(i))); + } + + gpr_log(GPR_DEBUG, "Terminating threads..."); + for (int i = 0; i < num_threads; ++i) { + mpmcqueue.Put(NULL); + } + for (int i = 0; i < num_threads; ++i) { + thds[i].Join(); + } + gpr_log(GPR_DEBUG, "Done."); +} + +static void test_large_queue(void) { + gpr_log(GPR_DEBUG, "test_large_queue"); + grpc_core::MPMCQueue large_queue; + for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { + large_queue.Put(static_cast(new WorkItem(i))); + } + GPR_ASSERT(large_queue.count() == THREAD_LARGE_ITERATION); + for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { + WorkItem* item = static_cast(large_queue.Get()); + GPR_ASSERT(i == item->index); + delete item; + } +} + +// Thread for put items into queue +class WorkThread { + public: + WorkThread(grpc_core::MPMCQueue* mpmcqueue, int start_index, int num_items) + : start_index_(start_index), num_items_(num_items), + mpmcqueue_(mpmcqueue) { + items_ = NULL; + thd_ = grpc_core::Thread( + "mpmcq_test_mt_put_thd", + [](void* th) { static_cast(th)->Run(); }, + this); + } + ~WorkThread() { + for (int i = 0; i < num_items_; ++i) { + GPR_ASSERT(items_[i]->done); + delete items_[i]; + } + gpr_free(items_); + } + + void Start() { thd_.Start(); } + void Join() { thd_.Join(); } + + void* operator new(size_t n) { + void* p = gpr_malloc(n); + return p; + } + + void operator delete(void* p) { + gpr_free(p); + } + + private: + void Run() { + items_ = static_cast( + gpr_malloc(sizeof(WorkItem*) * num_items_)); + for (int i = 0; i < num_items_; ++i) { + items_[i] = new WorkItem(start_index_ + i); + mpmcqueue_->Put(items_[i]); + } + } + + int start_index_; + int num_items_; + grpc_core::MPMCQueue* mpmcqueue_; + grpc_core::Thread thd_; + WorkItem** items_; +}; + + +static void test_many_get_thd(void* args) { + grpc_core::MPMCQueue* mpmcqueue = static_cast(args); + + // count number of Get() called in this thread + int count = 0; + + WorkItem* item; + while ((item = static_cast(mpmcqueue->Get())) != NULL) { + count++; + GPR_ASSERT(!item->done); + item->done = true; + } + + gpr_log(GPR_DEBUG, "test_many_get_thd: %d times of Get() called.", count); +} + +static void test_many_thread(void) { + gpr_log(GPR_DEBUG, "test_many_thread"); + const int num_work_thd = 10; + const int num_get_thd = 20; + grpc_core::MPMCQueue mpmcqueue; + WorkThread** work_thds = + static_cast(gpr_malloc(sizeof(WorkThread*) * num_work_thd)); + grpc_core::Thread get_thds[num_get_thd]; + + gpr_log(GPR_DEBUG, "Fork WorkThread..."); + for (int i = 0; i < num_work_thd; ++i) { + work_thds[i] = new WorkThread(&mpmcqueue, i * THREAD_LARGE_ITERATION, + THREAD_LARGE_ITERATION); + work_thds[i]->Start(); + } + gpr_log(GPR_DEBUG, "WorkThread Started."); + gpr_log(GPR_DEBUG, "For Getter Thread..."); + for (int i = 0; i < num_get_thd; ++i) { + get_thds[i] = grpc_core::Thread("mpmcq_test_mt_get_thd", + test_many_get_thd, &mpmcqueue); + get_thds[i].Start(); + } + gpr_log(GPR_DEBUG, "Getter Thread Started."); + gpr_log(GPR_DEBUG, "Waiting WorkThread to finish..."); + for (int i = 0; i < num_work_thd; ++i) { + work_thds[i]->Join(); + } + gpr_log(GPR_DEBUG, "All WorkThread Terminated."); + gpr_log(GPR_DEBUG, "Terminating Getter Thread..."); + for (int i = 0; i < num_get_thd; ++i) { + mpmcqueue.Put(NULL); + } + for (int i = 0; i < num_get_thd; ++i) { + get_thds[i].Join(); + } + gpr_log(GPR_DEBUG, "All Getter Thread Terminated."); + gpr_log(GPR_DEBUG, "Checking WorkItems and Cleaning Up..."); + for (int i = 0; i < num_work_thd; ++i) { + delete work_thds[i]; + } + gpr_free(work_thds); + gpr_log(GPR_DEBUG, "Done."); +} + + +int main(int argc, char** argv) { + grpc::testing::TestEnvironment env(argc, argv); + grpc_init(); + gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG); + test_no_op(); + test_small_queue(); + test_get_empty(); + test_large_queue(); + test_many_thread(); + grpc_shutdown(); + return 0; +} From e60c43ff3ec55c67f99aa8dcece7eae8de177946 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 14 Jun 2019 16:13:19 -0700 Subject: [PATCH 0546/1555] Add out of bounds frame tests --- CMakeLists.txt | 41 +++++++ Makefile | 36 ++++++ test/core/bad_client/gen_build_yaml.py | 1 + test/core/bad_client/generate_tests.bzl | 1 + test/core/bad_client/tests/out_of_bounds.cc | 112 ++++++++++++++++++ .../generated/sources_and_headers.json | 17 +++ tools/run_tests/generated/tests.json | 26 ++++ 7 files changed, 234 insertions(+) create mode 100644 test/core/bad_client/tests/out_of_bounds.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 13d54ec0cda..276a1d64214 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -731,6 +731,7 @@ add_dependencies(buildtests_cxx head_of_line_blocking_bad_client_test) add_dependencies(buildtests_cxx headers_bad_client_test) add_dependencies(buildtests_cxx initial_settings_frame_bad_client_test) add_dependencies(buildtests_cxx large_metadata_bad_client_test) +add_dependencies(buildtests_cxx out_of_bounds_bad_client_test) add_dependencies(buildtests_cxx server_registered_method_bad_client_test) add_dependencies(buildtests_cxx simple_request_bad_client_test) add_dependencies(buildtests_cxx unknown_frame_bad_client_test) @@ -17307,6 +17308,46 @@ target_link_libraries(large_metadata_bad_client_test ) +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + +add_executable(out_of_bounds_bad_client_test + test/core/bad_client/tests/out_of_bounds.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(out_of_bounds_bad_client_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(out_of_bounds_bad_client_test + ${_gRPC_SSL_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + bad_client_test + grpc_test_util_unsecure + grpc_unsecure + gpr + ${_gRPC_GFLAGS_LIBRARIES} +) + + endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index d45c0992370..72c4f6854d2 100644 --- a/Makefile +++ b/Makefile @@ -1298,6 +1298,7 @@ head_of_line_blocking_bad_client_test: $(BINDIR)/$(CONFIG)/head_of_line_blocking headers_bad_client_test: $(BINDIR)/$(CONFIG)/headers_bad_client_test initial_settings_frame_bad_client_test: $(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test large_metadata_bad_client_test: $(BINDIR)/$(CONFIG)/large_metadata_bad_client_test +out_of_bounds_bad_client_test: $(BINDIR)/$(CONFIG)/out_of_bounds_bad_client_test server_registered_method_bad_client_test: $(BINDIR)/$(CONFIG)/server_registered_method_bad_client_test simple_request_bad_client_test: $(BINDIR)/$(CONFIG)/simple_request_bad_client_test unknown_frame_bad_client_test: $(BINDIR)/$(CONFIG)/unknown_frame_bad_client_test @@ -1758,6 +1759,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/headers_bad_client_test \ $(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test \ $(BINDIR)/$(CONFIG)/large_metadata_bad_client_test \ + $(BINDIR)/$(CONFIG)/out_of_bounds_bad_client_test \ $(BINDIR)/$(CONFIG)/server_registered_method_bad_client_test \ $(BINDIR)/$(CONFIG)/simple_request_bad_client_test \ $(BINDIR)/$(CONFIG)/unknown_frame_bad_client_test \ @@ -1917,6 +1919,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/headers_bad_client_test \ $(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test \ $(BINDIR)/$(CONFIG)/large_metadata_bad_client_test \ + $(BINDIR)/$(CONFIG)/out_of_bounds_bad_client_test \ $(BINDIR)/$(CONFIG)/server_registered_method_bad_client_test \ $(BINDIR)/$(CONFIG)/simple_request_bad_client_test \ $(BINDIR)/$(CONFIG)/unknown_frame_bad_client_test \ @@ -2455,6 +2458,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test || ( echo test initial_settings_frame_bad_client_test failed ; exit 1 ) $(E) "[RUN] Testing large_metadata_bad_client_test" $(Q) $(BINDIR)/$(CONFIG)/large_metadata_bad_client_test || ( echo test large_metadata_bad_client_test failed ; exit 1 ) + $(E) "[RUN] Testing out_of_bounds_bad_client_test" + $(Q) $(BINDIR)/$(CONFIG)/out_of_bounds_bad_client_test || ( echo test out_of_bounds_bad_client_test failed ; exit 1 ) $(E) "[RUN] Testing server_registered_method_bad_client_test" $(Q) $(BINDIR)/$(CONFIG)/server_registered_method_bad_client_test || ( echo test server_registered_method_bad_client_test failed ; exit 1 ) $(E) "[RUN] Testing simple_request_bad_client_test" @@ -20540,6 +20545,37 @@ ifneq ($(NO_DEPS),true) endif +OUT_OF_BOUNDS_BAD_CLIENT_TEST_SRC = \ + test/core/bad_client/tests/out_of_bounds.cc \ + +OUT_OF_BOUNDS_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(OUT_OF_BOUNDS_BAD_CLIENT_TEST_SRC)))) + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/out_of_bounds_bad_client_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/out_of_bounds_bad_client_test: $(PROTOBUF_DEP) $(OUT_OF_BOUNDS_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(OUT_OF_BOUNDS_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/out_of_bounds_bad_client_test + +endif + +$(OBJDIR)/$(CONFIG)/test/core/bad_client/tests/out_of_bounds.o: $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_out_of_bounds_bad_client_test: $(OUT_OF_BOUNDS_BAD_CLIENT_TEST_OBJS:.o=.dep) + +ifneq ($(NO_DEPS),true) +-include $(OUT_OF_BOUNDS_BAD_CLIENT_TEST_OBJS:.o=.dep) +endif + + SERVER_REGISTERED_METHOD_BAD_CLIENT_TEST_SRC = \ test/core/bad_client/tests/server_registered_method.cc \ diff --git a/test/core/bad_client/gen_build_yaml.py b/test/core/bad_client/gen_build_yaml.py index bd311ccfd90..aa5ae85cdf4 100755 --- a/test/core/bad_client/gen_build_yaml.py +++ b/test/core/bad_client/gen_build_yaml.py @@ -32,6 +32,7 @@ BAD_CLIENT_TESTS = { 'initial_settings_frame': default_test_options._replace(cpu_cost=0.2), 'head_of_line_blocking': default_test_options, 'large_metadata': default_test_options, + 'out_of_bounds': default_test_options, 'server_registered_method': default_test_options, 'simple_request': default_test_options, 'window_overflow': default_test_options, diff --git a/test/core/bad_client/generate_tests.bzl b/test/core/bad_client/generate_tests.bzl index 9ff55877c53..81216f284cc 100755 --- a/test/core/bad_client/generate_tests.bzl +++ b/test/core/bad_client/generate_tests.bzl @@ -31,6 +31,7 @@ BAD_CLIENT_TESTS = { 'initial_settings_frame': test_options(), 'head_of_line_blocking': test_options(), 'large_metadata': test_options(), + 'out_of_bounds': test_options(), 'server_registered_method': test_options(), 'simple_request': test_options(), 'window_overflow': test_options(), diff --git a/test/core/bad_client/tests/out_of_bounds.cc b/test/core/bad_client/tests/out_of_bounds.cc new file mode 100644 index 00000000000..78d84a638a8 --- /dev/null +++ b/test/core/bad_client/tests/out_of_bounds.cc @@ -0,0 +1,112 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include + +#include +#include "src/core/lib/surface/server.h" +#include "test/core/bad_client/bad_client.h" + +#define APPEND_BUFFER(string, to_append) \ + ((string).append((to_append), sizeof(to_append) - 1)) + +namespace { + +void verifier(grpc_server* server, grpc_completion_queue* cq, + void* registered_method) { + while (grpc_server_has_open_connections(server)) { + GPR_ASSERT(grpc_completion_queue_next( + cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) + .type == GRPC_QUEUE_TIMEOUT); + } +} + +void FrameVerifier(std::string attack_vector) { + grpc_bad_client_arg args[2]; + args[0] = connection_preface_arg; + args[1].client_validator = nullptr; + args[1].client_payload = attack_vector.c_str(); + args[1].client_payload_length = attack_vector.size(); + grpc_run_bad_client_test(verifier, args, 2, GRPC_BAD_CLIENT_DISCONNECT); +} + +TEST(OutOfBounds, MaxFrameSizeDataFrame) { + std::string out_of_bounds_data; + // Send a data frame larger than 2^14 + APPEND_BUFFER(out_of_bounds_data, "\x01\x00\x00\x00\x00\x00\x00\x00\x01"); + out_of_bounds_data.append(1 << 16, 'a'); + FrameVerifier(out_of_bounds_data); +} + +TEST(OutOfBounds, BadSizePriorityFrame) { + std::string bad_size_priority_frame; + // Priority Frame should be a length of 5 octets + APPEND_BUFFER(bad_size_priority_frame, + "\x00\x00\x03\x02\x00\x00\x00\x00\x01" + "\x11\x11\x12"); + FrameVerifier(bad_size_priority_frame); +} + +TEST(OutOfBounds, BadSizeRstStream) { + std::string bad_size_rst_stream; + // Rst Stream Frame should have a length of 4 octets + APPEND_BUFFER(bad_size_rst_stream, + "\x00\x00\x02\x03\x00\x00\x00\x00\x01" + "\x11\x11"); + FrameVerifier(bad_size_rst_stream); +} + +TEST(OutOfBounds, BadSizeSettings) { + std::string bad_size_settings; + // Settings Frame should have a length which is a multiple of 6 octets + APPEND_BUFFER(bad_size_settings, + "\x00\x00\x05\x04\x00\x00\x00\x00\x00" + "\x11\x11\x11\x11\x11"); + FrameVerifier(bad_size_settings); +} + +TEST(OutOfBounds, BadSizePing) { + std::string bad_size_ping; + // Rst Stream Frame should have a length of 8 octets + APPEND_BUFFER(bad_size_ping, + "\x00\x00\x05\x06\x00\x00\x00\x00\x00" + "\x11\x11\x11\x11\x11"); + FrameVerifier(bad_size_ping); +} + +TEST(OutOfBounds, WindowUpdate) { + std::string bad_size_window_update; + // Window Update Frame should have a length of 4 octets + APPEND_BUFFER(bad_size_window_update, + "\x00\x00\x01\x08\x00\x00\x00\x00\x00" + "\x11"); + FrameVerifier(bad_size_window_update); +} + +} // namespace + +int main(int argc, char** argv) { + grpc_init(); + grpc::testing::TestEnvironment env(argc, argv); + ::testing::InitGoogleTest(&argc, argv); + int retval = RUN_ALL_TESTS(); + grpc_shutdown(); + return retval; +} diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 3143f2cc87f..43fc3cc05ec 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -5386,6 +5386,23 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "bad_client_test", + "gpr", + "grpc_test_util_unsecure", + "grpc_unsecure" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "out_of_bounds_bad_client_test", + "src": [ + "test/core/bad_client/tests/out_of_bounds.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "bad_client_test", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 37a69a47b23..5c24ec4fa15 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -6100,6 +6100,32 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "gtest": false, + "language": "c++", + "name": "out_of_bounds_bad_client_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": true + }, { "args": [], "benchmark": false, From 9f10ab5377589ebd6918c3c092b23f7aa8355e8d Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 14 Jun 2019 16:24:12 -0700 Subject: [PATCH 0547/1555] Add gtest dependency to the test instead of library --- test/core/bad_client/generate_tests.bzl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/core/bad_client/generate_tests.bzl b/test/core/bad_client/generate_tests.bzl index 9ff55877c53..da372dd0bc9 100755 --- a/test/core/bad_client/generate_tests.bzl +++ b/test/core/bad_client/generate_tests.bzl @@ -42,9 +42,6 @@ def grpc_bad_client_tests(): name = 'bad_client_test', srcs = ['bad_client.cc'], hdrs = ['bad_client.h'], - external_deps = [ - "gtest", - ], language = "C++", deps = ['//test/core/util:grpc_test_util', '//:grpc', '//:gpr', '//test/core/end2end:cq_verifier'] ) @@ -53,5 +50,8 @@ def grpc_bad_client_tests(): name = '%s_bad_client_test' % t, srcs = ['tests/%s.cc' % t], deps = [':bad_client_test'], + external_deps = [ + "gtest", + ], ) From 9bd526260a014237983246bc3af79c4fe4966474 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 14 Jun 2019 16:49:53 -0700 Subject: [PATCH 0548/1555] Remove unused imports --- examples/python/debug/test/_debug_example_test.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/python/debug/test/_debug_example_test.py b/examples/python/debug/test/_debug_example_test.py index af599e6a48b..8983542cb66 100644 --- a/examples/python/debug/test/_debug_example_test.py +++ b/examples/python/debug/test/_debug_example_test.py @@ -19,8 +19,6 @@ from __future__ import print_function import logging import unittest -from contextlib import contextmanager -import socket from examples.python.debug import debug_server from examples.python.debug import send_message @@ -34,6 +32,7 @@ _NUMBER_OF_MESSAGES = 100 _ADDR_TEMPLATE = 'localhost:%d' + class DebugExampleTest(unittest.TestCase): def test_channelz_example(self): From e0a95c3267eb608bd63c464a92513db3d252bb91 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 14 Jun 2019 16:53:14 -0700 Subject: [PATCH 0549/1555] Add more missing functions --- .../grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi | 6 +++--- .../grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi index dff6fa2aea5..59b3891d9fa 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi @@ -44,12 +44,12 @@ cdef extern from "src/core/lib/iomgr/resolve_address_custom.h": pass struct grpc_custom_resolver_vtable: - grpc_error* (*resolve)(char* host, char* port, grpc_resolved_addresses** res); - void (*resolve_async)(grpc_custom_resolver* resolver, char* host, char* port); + grpc_error* (*resolve)(char* host, char* port, grpc_resolved_addresses** res) except * + void (*resolve_async)(grpc_custom_resolver* resolver, char* host, char* port) except * void grpc_custom_resolve_callback(grpc_custom_resolver* resolver, grpc_resolved_addresses* result, - grpc_error* error); + grpc_error* error) cdef extern from "src/core/lib/iomgr/tcp_custom.h": struct grpc_custom_socket: diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi index 3709cfb0296..f82fca2cce7 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi @@ -56,7 +56,7 @@ cdef sockaddr_is_ipv4(const grpc_sockaddr* address, size_t length): c_addr.len = length return grpc_sockaddr_get_uri_scheme(&c_addr) == b'ipv4' -cdef grpc_resolved_addresses* tuples_to_resolvaddr(tups): +cdef grpc_resolved_addresses* tuples_to_resolvaddr(tups) except *: cdef grpc_resolved_addresses* addresses tups_set = set((tup[4][0], tup[4][1]) for tup in tups) addresses = malloc(sizeof(grpc_resolved_addresses)) @@ -292,7 +292,7 @@ def socket_accept_async(s): accept_callback_cython(s) cdef void socket_accept(grpc_custom_socket* socket, grpc_custom_socket* client, - grpc_custom_accept_callback cb) with gil: + grpc_custom_accept_callback cb) except * with gil: sw = socket.impl sw.accepting_socket = client sw.accept_cb = cb @@ -322,7 +322,7 @@ cdef socket_resolve_async_cython(ResolveWrapper resolve_wrapper): def socket_resolve_async_python(resolve_wrapper): socket_resolve_async_cython(resolve_wrapper) -cdef void socket_resolve_async(grpc_custom_resolver* r, char* host, char* port) with gil: +cdef void socket_resolve_async(grpc_custom_resolver* r, char* host, char* port) except * with gil: rw = ResolveWrapper() rw.c_resolver = r rw.c_host = host @@ -330,7 +330,7 @@ cdef void socket_resolve_async(grpc_custom_resolver* r, char* host, char* port) _spawn_greenlet(socket_resolve_async_python, rw) cdef grpc_error* socket_resolve(char* host, char* port, - grpc_resolved_addresses** res) with gil: + grpc_resolved_addresses** res) except * with gil: try: result = gevent_socket.getaddrinfo(host, port) res[0] = tuples_to_resolvaddr(result) @@ -360,13 +360,13 @@ cdef class TimerWrapper: self.event.set() self.timer.stop() -cdef void timer_start(grpc_custom_timer* t) with gil: +cdef void timer_start(grpc_custom_timer* t) except * with gil: timer = TimerWrapper(t.timeout_ms / 1000.0) timer.c_timer = t t.timer = timer timer.start() -cdef void timer_stop(grpc_custom_timer* t) with gil: +cdef void timer_stop(grpc_custom_timer* t) except * with gil: time_wrapper = t.timer time_wrapper.stop() From 036cdc661647f7c24c95b1c53a1a684b3537fa50 Mon Sep 17 00:00:00 2001 From: Loo Rong Jie Date: Sat, 15 Jun 2019 22:19:03 +0800 Subject: [PATCH 0550/1555] Properly detect C++ exception for MSVC Inspired from protobuf https://github.com/protocolbuffers/protobuf/blob/77f03d932a35e8aa0a98c0c728ad3f5aacfe30ce/src/google/protobuf/stubs/common.h#L50 --- include/grpc/impl/codegen/port_platform.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index d7294d59d41..591385eb705 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -618,10 +618,14 @@ typedef unsigned __int64 uint64_t; /* GRPC_ALLOW_EXCEPTIONS should be 0 or 1 if exceptions are allowed or not */ #ifndef GRPC_ALLOW_EXCEPTIONS -/* If not already set, set to 1 on Windows (style guide standard) but to - * 0 on non-Windows platforms unless the compiler defines __EXCEPTIONS */ #ifdef GPR_WINDOWS +#if defined(_MSC_VER) && defined(_CPPUNWIND) #define GRPC_ALLOW_EXCEPTIONS 1 +#elif defined(__EXCEPTIONS) +#define GRPC_ALLOW_EXCEPTIONS 1 +#else +#define GRPC_ALLOW_EXCEPTIONS 0 +#endif #else /* GPR_WINDOWS */ #ifdef __EXCEPTIONS #define GRPC_ALLOW_EXCEPTIONS 1 From 85f08100d4b30c2ac1d655617d381688b8779169 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Sun, 16 Jun 2019 16:01:46 -0400 Subject: [PATCH 0551/1555] Avoid using seq_cst atomic operations in grpcpp when unnecessary. These cases are almost all in the callback API. Also use atomic insteda of atomic_int for consistency with gpr_atm and grpc_core::Atomic. --- include/grpcpp/impl/codegen/client_callback.h | 51 +++++++++++-------- include/grpcpp/impl/codegen/server_callback.h | 42 ++++++++------- .../grpcpp/impl/codegen/server_interceptor.h | 10 ++-- include/grpcpp/server_impl.h | 2 +- 4 files changed, 59 insertions(+), 46 deletions(-) diff --git a/include/grpcpp/impl/codegen/client_callback.h b/include/grpcpp/impl/codegen/client_callback.h index 6cba5830e4b..86d06b72c91 100644 --- a/include/grpcpp/impl/codegen/client_callback.h +++ b/include/grpcpp/impl/codegen/client_callback.h @@ -19,6 +19,7 @@ #ifndef GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_H #define GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_H +#include #include #include @@ -419,7 +420,8 @@ class ClientCallbackReaderWriterImpl static void operator delete(void*, void*) { assert(0); } void MaybeFinish() { - if (--callbacks_outstanding_ == 0) { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { Status s = std::move(finish_status_); auto* reactor = reactor_; auto* call = call_.call(); @@ -489,7 +491,7 @@ class ClientCallbackReaderWriterImpl void Read(Response* msg) override { read_ops_.RecvMessage(msg); - callbacks_outstanding_++; + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); if (started_) { call_.PerformOps(&read_ops_); } else { @@ -510,7 +512,7 @@ class ClientCallbackReaderWriterImpl } // TODO(vjpai): don't assert GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(msg, options).ok()); - callbacks_outstanding_++; + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); if (started_) { call_.PerformOps(&write_ops_); } else { @@ -531,7 +533,7 @@ class ClientCallbackReaderWriterImpl }, &writes_done_ops_); writes_done_ops_.set_core_cq_tag(&writes_done_tag_); - callbacks_outstanding_++; + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); if (started_) { call_.PerformOps(&writes_done_ops_); } else { @@ -539,8 +541,10 @@ class ClientCallbackReaderWriterImpl } } - virtual void AddHold(int holds) override { callbacks_outstanding_ += holds; } - virtual void RemoveHold() override { MaybeFinish(); } + void AddHold(int holds) override { + callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed); + } + void RemoveHold() override { MaybeFinish(); } private: friend class ClientCallbackReaderWriterFactory; @@ -581,7 +585,7 @@ class ClientCallbackReaderWriterImpl bool read_ops_at_start_{false}; // Minimum of 2 callbacks to pre-register for start and finish - std::atomic_int callbacks_outstanding_{2}; + std::atomic callbacks_outstanding_{2}; bool started_{false}; }; @@ -619,7 +623,8 @@ class ClientCallbackReaderImpl static void operator delete(void*, void*) { assert(0); } void MaybeFinish() { - if (--callbacks_outstanding_ == 0) { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { Status s = std::move(finish_status_); auto* reactor = reactor_; auto* call = call_.call(); @@ -669,7 +674,7 @@ class ClientCallbackReaderImpl void Read(Response* msg) override { read_ops_.RecvMessage(msg); - callbacks_outstanding_++; + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); if (started_) { call_.PerformOps(&read_ops_); } else { @@ -677,8 +682,10 @@ class ClientCallbackReaderImpl } } - virtual void AddHold(int holds) override { callbacks_outstanding_ += holds; } - virtual void RemoveHold() override { MaybeFinish(); } + void AddHold(int holds) override { + callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed); + } + void RemoveHold() override { MaybeFinish(); } private: friend class ClientCallbackReaderFactory; @@ -712,7 +719,7 @@ class ClientCallbackReaderImpl bool read_ops_at_start_{false}; // Minimum of 2 callbacks to pre-register for start and finish - std::atomic_int callbacks_outstanding_{2}; + std::atomic callbacks_outstanding_{2}; bool started_{false}; }; @@ -750,7 +757,8 @@ class ClientCallbackWriterImpl static void operator delete(void*, void*) { assert(0); } void MaybeFinish() { - if (--callbacks_outstanding_ == 0) { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { Status s = std::move(finish_status_); auto* reactor = reactor_; auto* call = call_.call(); @@ -819,7 +827,7 @@ class ClientCallbackWriterImpl } // TODO(vjpai): don't assert GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(msg, options).ok()); - callbacks_outstanding_++; + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); if (started_) { call_.PerformOps(&write_ops_); } else { @@ -840,7 +848,7 @@ class ClientCallbackWriterImpl }, &writes_done_ops_); writes_done_ops_.set_core_cq_tag(&writes_done_tag_); - callbacks_outstanding_++; + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); if (started_) { call_.PerformOps(&writes_done_ops_); } else { @@ -848,8 +856,10 @@ class ClientCallbackWriterImpl } } - virtual void AddHold(int holds) override { callbacks_outstanding_ += holds; } - virtual void RemoveHold() override { MaybeFinish(); } + void AddHold(int holds) override { + callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed); + } + void RemoveHold() override { MaybeFinish(); } private: friend class ClientCallbackWriterFactory; @@ -889,7 +899,7 @@ class ClientCallbackWriterImpl bool writes_done_ops_at_start_{false}; // Minimum of 2 callbacks to pre-register for start and finish - std::atomic_int callbacks_outstanding_{2}; + std::atomic callbacks_outstanding_{2}; bool started_{false}; }; @@ -951,7 +961,8 @@ class ClientCallbackUnaryImpl final } void MaybeFinish() { - if (--callbacks_outstanding_ == 0) { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { Status s = std::move(finish_status_); auto* reactor = reactor_; auto* call = call_.call(); @@ -991,7 +1002,7 @@ class ClientCallbackUnaryImpl final Status finish_status_; // This call will have 2 callbacks: start and finish - std::atomic_int callbacks_outstanding_{2}; + std::atomic callbacks_outstanding_{2}; bool started_{false}; }; diff --git a/include/grpcpp/impl/codegen/server_callback.h b/include/grpcpp/impl/codegen/server_callback.h index ab47873e40a..b0a13917e56 100644 --- a/include/grpcpp/impl/codegen/server_callback.h +++ b/include/grpcpp/impl/codegen/server_callback.h @@ -68,13 +68,13 @@ class ServerReactor { // remain unmet. void MaybeCallOnCancel() { - if (on_cancel_conditions_remaining_.fetch_sub( - 1, std::memory_order_acq_rel) == 1) { + if (GPR_UNLIKELY(on_cancel_conditions_remaining_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { OnCancel(); } } - std::atomic_int on_cancel_conditions_remaining_{2}; + std::atomic on_cancel_conditions_remaining_{2}; }; template @@ -568,7 +568,7 @@ class CallbackUnaryHandler : public MethodHandler { void SendInitialMetadata(std::function f) override { GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - callbacks_outstanding_++; + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); // TODO(vjpai): Consider taking f as a move-capture if we adopt C++14 // and if performance of this operation matters meta_tag_.Set(call_.call(), @@ -618,7 +618,8 @@ class CallbackUnaryHandler : public MethodHandler { ResponseType* response() { return allocator_state_->response(); } void MaybeDone() { - if (--callbacks_outstanding_ == 0) { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { grpc_call* call = call_.call(); auto call_requester = std::move(call_requester_); allocator_state_->Release(); @@ -640,7 +641,7 @@ class CallbackUnaryHandler : public MethodHandler { experimental::MessageHolder* const allocator_state_; std::function call_requester_; - std::atomic_int callbacks_outstanding_{ + std::atomic callbacks_outstanding_{ 2}; // reserve for Finish and CompletionOp }; }; @@ -712,7 +713,7 @@ class CallbackClientStreamingHandler : public MethodHandler { void SendInitialMetadata() override { GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - callbacks_outstanding_++; + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); meta_tag_.Set(call_.call(), [this](bool ok) { reactor_->OnSendInitialMetadataDone(ok); @@ -730,7 +731,7 @@ class CallbackClientStreamingHandler : public MethodHandler { } void Read(RequestType* req) override { - callbacks_outstanding_++; + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); read_ops_.RecvMessage(req); call_.PerformOps(&read_ops_); } @@ -761,7 +762,8 @@ class CallbackClientStreamingHandler : public MethodHandler { ResponseType* response() { return &resp_; } void MaybeDone() { - if (--callbacks_outstanding_ == 0) { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { reactor_->OnDone(); grpc_call* call = call_.call(); auto call_requester = std::move(call_requester_); @@ -785,7 +787,7 @@ class CallbackClientStreamingHandler : public MethodHandler { ResponseType resp_; std::function call_requester_; experimental::ServerReadReactor* reactor_; - std::atomic_int callbacks_outstanding_{ + std::atomic callbacks_outstanding_{ 3}; // reserve for OnStarted, Finish, and CompletionOp }; }; @@ -867,7 +869,7 @@ class CallbackServerStreamingHandler : public MethodHandler { void SendInitialMetadata() override { GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - callbacks_outstanding_++; + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); meta_tag_.Set(call_.call(), [this](bool ok) { reactor_->OnSendInitialMetadataDone(ok); @@ -885,7 +887,7 @@ class CallbackServerStreamingHandler : public MethodHandler { } void Write(const ResponseType* resp, WriteOptions options) override { - callbacks_outstanding_++; + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); if (options.is_last_message()) { options.set_buffer_hint(); } @@ -939,7 +941,8 @@ class CallbackServerStreamingHandler : public MethodHandler { const RequestType* request() { return req_; } void MaybeDone() { - if (--callbacks_outstanding_ == 0) { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { reactor_->OnDone(); grpc_call* call = call_.call(); auto call_requester = std::move(call_requester_); @@ -963,7 +966,7 @@ class CallbackServerStreamingHandler : public MethodHandler { const RequestType* req_; std::function call_requester_; experimental::ServerWriteReactor* reactor_; - std::atomic_int callbacks_outstanding_{ + std::atomic callbacks_outstanding_{ 3}; // reserve for OnStarted, Finish, and CompletionOp }; }; @@ -1031,7 +1034,7 @@ class CallbackBidiHandler : public MethodHandler { void SendInitialMetadata() override { GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - callbacks_outstanding_++; + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); meta_tag_.Set(call_.call(), [this](bool ok) { reactor_->OnSendInitialMetadataDone(ok); @@ -1049,7 +1052,7 @@ class CallbackBidiHandler : public MethodHandler { } void Write(const ResponseType* resp, WriteOptions options) override { - callbacks_outstanding_++; + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); if (options.is_last_message()) { options.set_buffer_hint(); } @@ -1077,7 +1080,7 @@ class CallbackBidiHandler : public MethodHandler { } void Read(RequestType* req) override { - callbacks_outstanding_++; + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); read_ops_.RecvMessage(req); call_.PerformOps(&read_ops_); } @@ -1112,7 +1115,8 @@ class CallbackBidiHandler : public MethodHandler { ~ServerCallbackReaderWriterImpl() {} void MaybeDone() { - if (--callbacks_outstanding_ == 0) { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { reactor_->OnDone(); grpc_call* call = call_.call(); auto call_requester = std::move(call_requester_); @@ -1137,7 +1141,7 @@ class CallbackBidiHandler : public MethodHandler { Call call_; std::function call_requester_; experimental::ServerBidiReactor* reactor_; - std::atomic_int callbacks_outstanding_{ + std::atomic callbacks_outstanding_{ 3}; // reserve for OnStarted, Finish, and CompletionOp }; }; diff --git a/include/grpcpp/impl/codegen/server_interceptor.h b/include/grpcpp/impl/codegen/server_interceptor.h index 28fdc27ec68..dc1da1327af 100644 --- a/include/grpcpp/impl/codegen/server_interceptor.h +++ b/include/grpcpp/impl/codegen/server_interceptor.h @@ -98,9 +98,7 @@ class ServerRpcInfo { ServerRpcInfo(grpc_impl::ServerContext* ctx, const char* method, internal::RpcMethod::RpcType type) - : ctx_(ctx), method_(method), type_(static_cast(type)) { - ref_.store(1); - } + : ctx_(ctx), method_(method), type_(static_cast(type)) {} // Runs interceptor at pos \a pos. void RunInterceptor( @@ -122,9 +120,9 @@ class ServerRpcInfo { } } - void Ref() { ref_++; } + void Ref() { ref_.fetch_add(1, std::memory_order_relaxed); } void Unref() { - if (--ref_ == 0) { + if (GPR_UNLIKELY(ref_.fetch_sub(1, std::memory_order_acq_rel) == 1)) { delete this; } } @@ -132,7 +130,7 @@ class ServerRpcInfo { grpc_impl::ServerContext* ctx_ = nullptr; const char* method_ = nullptr; const Type type_; - std::atomic_int ref_; + std::atomic ref_{1}; std::vector> interceptors_; friend class internal::InterceptorBatchMethodsImpl; diff --git a/include/grpcpp/server_impl.h b/include/grpcpp/server_impl.h index 90019e25032..b75012e5da8 100644 --- a/include/grpcpp/server_impl.h +++ b/include/grpcpp/server_impl.h @@ -342,7 +342,7 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { // during decreasing load, so it is less performance-critical. grpc::internal::Mutex callback_reqs_mu_; grpc::internal::CondVar callback_reqs_done_cv_; - std::atomic_int callback_reqs_outstanding_{0}; + std::atomic callback_reqs_outstanding_{0}; std::shared_ptr global_callbacks_; From 7db36fe0a0944d0157c0126ad0ca6036538483b9 Mon Sep 17 00:00:00 2001 From: yang-g Date: Mon, 17 Jun 2019 11:18:03 -0700 Subject: [PATCH 0552/1555] Add comments and rename internal methods --- include/grpcpp/impl/codegen/server_callback.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/include/grpcpp/impl/codegen/server_callback.h b/include/grpcpp/impl/codegen/server_callback.h index ab47873e40a..6d83bc88e56 100644 --- a/include/grpcpp/impl/codegen/server_callback.h +++ b/include/grpcpp/impl/codegen/server_callback.h @@ -174,7 +174,7 @@ class ServerCallbackReader { protected: template void BindReactor(ServerReadReactor* reactor) { - reactor->BindReader(this); + reactor->InternalBindReader(this); } }; @@ -196,7 +196,7 @@ class ServerCallbackWriter { protected: template void BindReactor(ServerWriteReactor* reactor) { - reactor->BindWriter(this); + reactor->InternalBindWriter(this); } }; @@ -218,7 +218,7 @@ class ServerCallbackReaderWriter { protected: void BindReactor(ServerBidiReactor* reactor) { - reactor->BindStream(this); + reactor->InternalBindStream(this); } }; @@ -348,7 +348,9 @@ class ServerBidiReactor : public internal::ServerReactor { private: friend class ServerCallbackReaderWriter; - virtual void BindStream( + // May be overridden by internal implementation details, this is not a public + // customization point. + virtual void InternalBindStream( ServerCallbackReaderWriter* stream) { stream_ = stream; } @@ -383,7 +385,9 @@ class ServerReadReactor : public internal::ServerReactor { private: friend class ServerCallbackReader; - virtual void BindReader(ServerCallbackReader* reader) { + // May be overridden by internal implementation details, this is not a public + // customization point. + virtual void InternalBindReader(ServerCallbackReader* reader) { reader_ = reader; } @@ -427,7 +431,9 @@ class ServerWriteReactor : public internal::ServerReactor { private: friend class ServerCallbackWriter; - virtual void BindWriter(ServerCallbackWriter* writer) { + // May be overridden by internal implementation details, this is not a public + // customization point. + virtual void InternalBindWriter(ServerCallbackWriter* writer) { writer_ = writer; } From 929f1510164238b36394aa6710a0e506b77344ff Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Mon, 17 Jun 2019 22:42:08 +0200 Subject: [PATCH 0553/1555] Cherry-picking #19349 in. --- examples/python/multiprocessing/BUILD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/python/multiprocessing/BUILD b/examples/python/multiprocessing/BUILD index 8140d80633a..f9fa6598068 100644 --- a/examples/python/multiprocessing/BUILD +++ b/examples/python/multiprocessing/BUILD @@ -36,7 +36,7 @@ py_binary( "//src/python/grpcio/grpc:grpcio", ":prime_proto_pb2", ], - python_version = "PY3", + srcs_version = "PY3", ) py_binary( @@ -50,7 +50,7 @@ py_binary( "//conditions:default": [requirement("futures")], "//:python3": [], }), - python_version = "PY3", + srcs_version = "PY3", ) py_test( From 6fc7d2b18f51a2a9d1069d2e1c168d76b810fd44 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Mon, 17 Jun 2019 14:47:28 -0700 Subject: [PATCH 0554/1555] fix undefined reference to operator delete for MPMCQueue interface class --- build.yaml | 20 +++--- src/core/lib/iomgr/threadpool/mpmcqueue.cc | 44 +++++------- src/core/lib/iomgr/threadpool/mpmcqueue.h | 80 ++++++++-------------- test/core/iomgr/mpmcqueue_test.cc | 43 +++--------- 4 files changed, 68 insertions(+), 119 deletions(-) diff --git a/build.yaml b/build.yaml index 91d3cfe8c75..a02d7f01fcb 100644 --- a/build.yaml +++ b/build.yaml @@ -3268,15 +3268,6 @@ targets: - grpc - gpr uses_polling: false -- name: mpmcqueue_test - build: test - language: c - src: - - test/core/iomgr/mpmcqueue_test.cc - deps: - - grpc_test_util - - grpc - - gpr - name: multiple_server_queues_test build: test language: c @@ -5239,6 +5230,17 @@ targets: - grpc++ - grpc - gpr +- name: mpmcqueue_test + build: test + language: c++ + src: + - test/core/iomgr/mpmcqueue_test.cc + deps: + - grpc++_test_util + - grpc_test_util + - grpc++ + - grpc + - gpr - name: nonblocking_test gtest: true build: test diff --git a/src/core/lib/iomgr/threadpool/mpmcqueue.cc b/src/core/lib/iomgr/threadpool/mpmcqueue.cc index f33ab0468a8..e641ba70faa 100644 --- a/src/core/lib/iomgr/threadpool/mpmcqueue.cc +++ b/src/core/lib/iomgr/threadpool/mpmcqueue.cc @@ -16,46 +16,42 @@ * */ -#include - #include "src/core/lib/iomgr/threadpool/mpmcqueue.h" -#include - #include #include #include +#include #include #include +#include #include "src/core/lib/gprpp/sync.h" namespace grpc_core { - - inline void* MPMCQueue::PopFront() { void* result = queue_head_->content; Node* head_to_remove = queue_head_; queue_head_ = queue_head_->next; count_.Store(count_.Load(MemoryOrder::RELAXED) - 1, MemoryOrder::RELAXED); - gpr_timespec wait_time = gpr_time_sub(gpr_now(GPR_CLOCK_PRECISE), - head_to_remove->insert_time); - // gpr_free(head_to_remove); + gpr_timespec wait_time = + gpr_time_sub(gpr_now(GPR_CLOCK_PRECISE), head_to_remove->insert_time); + delete head_to_remove; // Update Stats info stats_.num_completed++; - stats_.total_queue_cycles = gpr_time_add(stats_.total_queue_cycles, - wait_time); + stats_.total_queue_cycles = + gpr_time_add(stats_.total_queue_cycles, wait_time); stats_.max_queue_cycles = gpr_time_max( gpr_convert_clock_type(stats_.max_queue_cycles, GPR_TIMESPAN), wait_time); if (count_.Load(MemoryOrder::RELAXED) == 0) { - stats_.busy_time_cycles = gpr_time_add( - stats_.busy_time_cycles, - gpr_time_sub(gpr_now(GPR_CLOCK_PRECISE), busy_time)); + stats_.busy_time_cycles = + gpr_time_add(stats_.busy_time_cycles, + gpr_time_sub(gpr_now(GPR_CLOCK_PRECISE), busy_time)); } // Singal waiting thread @@ -66,7 +62,8 @@ inline void* MPMCQueue::PopFront() { return result; } -MPMCQueue::MPMCQueue() : num_waiters_(0), queue_head_(0), queue_tail_(0) { +MPMCQueue::MPMCQueue() : num_waiters_(0), queue_head_(nullptr), + queue_tail_(nullptr) { count_.Store(0, MemoryOrder::RELAXED); } @@ -80,10 +77,7 @@ MPMCQueue::~MPMCQueue() { void MPMCQueue::Put(void* elem) { MutexLock l(&mu_); - // Node* new_node = static_cast(gpr_malloc(sizeof(Node))); - // new_node->next = nullptr; - // new_node->content = elem; - // new_node->insert_time = gpr_now(GPR_CLOCK_PRECISE); + Node* new_node = static_cast(new Node(elem)); if (count_.Load(MemoryOrder::RELAXED) == 0) { busy_time = gpr_now(GPR_CLOCK_PRECISE); @@ -131,12 +125,12 @@ void MPMCQueue::PrintStats() { MPMCQueue::Stats* MPMCQueue::queue_stats() { MPMCQueue::Stats* result = new Stats(); MutexLock l(&mu_); - result->total_queue_cycles = gpr_time_add(result->total_queue_cycles, - stats_.total_queue_cycles); - result->max_queue_cycles = gpr_time_add(result->max_queue_cycles, - stats_.max_queue_cycles); - result->busy_time_cycles = gpr_time_add(result->busy_time_cycles, - stats_.busy_time_cycles); + result->total_queue_cycles = + gpr_time_add(result->total_queue_cycles, stats_.total_queue_cycles); + result->max_queue_cycles = + gpr_time_add(result->max_queue_cycles, stats_.max_queue_cycles); + result->busy_time_cycles = + gpr_time_add(result->busy_time_cycles, stats_.busy_time_cycles); return result; } diff --git a/src/core/lib/iomgr/threadpool/mpmcqueue.h b/src/core/lib/iomgr/threadpool/mpmcqueue.h index 153784ae939..18d30e876ab 100644 --- a/src/core/lib/iomgr/threadpool/mpmcqueue.h +++ b/src/core/lib/iomgr/threadpool/mpmcqueue.h @@ -16,15 +16,15 @@ * */ -#ifndef GRPC_CORE_LIB_IOMGR_MPMCQUEUE_H -#define GRPC_CORE_LIB_IOMGR_MPMCQUEUE_H - -#include +#ifndef GRPC_CORE_LIB_IOMGR_THREADPOOL_MPMCQUEUE_H +#define GRPC_CORE_LIB_IOMGR_THREADPOOL_MPMCQUEUE_H #include +#include +#include + #include "src/core/lib/gprpp/atomic.h" #include "src/core/lib/gprpp/sync.h" -#include namespace grpc_core { @@ -36,7 +36,7 @@ class MPMCQueueInterface { // Put elem into queue immediately at the end of queue. // This might cause to block on full queue depending on implementation. - virtual void Put(void *elem) = 0; + virtual void Put(void* elem) = 0; // Remove the oldest element from the queue and return it. // This might cause to block on empty queue depending on implementation. @@ -48,16 +48,16 @@ class MPMCQueueInterface { class MPMCQueue : public MPMCQueueInterface { public: - struct Stats { // Stats of queue - uint64_t num_started; // Number of elements have been added to queue - uint64_t num_completed; // Number of elements have been removed from - // the queue - gpr_timespec total_queue_cycles; // Total waiting time that all the - // removed elements have spent in queue - gpr_timespec max_queue_cycles; // Max waiting time among all removed - // elements - gpr_timespec busy_time_cycles; // Accumulated amount of time that queue - // was not empty + struct Stats { // Stats of queue + uint64_t num_started; // Number of elements have been added to queue + uint64_t num_completed; // Number of elements have been removed from + // the queue + gpr_timespec total_queue_cycles; // Total waiting time that all the + // removed elements have spent in queue + gpr_timespec max_queue_cycles; // Max waiting time among all removed + // elements + gpr_timespec busy_time_cycles; // Accumulated amount of time that queue + // was not empty Stats() { num_started = 0; @@ -66,23 +66,7 @@ class MPMCQueue : public MPMCQueueInterface { max_queue_cycles = gpr_time_0(GPR_TIMESPAN); busy_time_cycles = gpr_time_0(GPR_TIMESPAN); } - void* operator new(size_t n) { - void* p = gpr_malloc(n); - return p; - } - - void operator delete(void* p) { - gpr_free(p); - } }; - void* operator new(size_t n) { - void* p = gpr_malloc(n); - return p; - } - - void operator delete(void* p) { - gpr_free(p); - } // Create a new Multiple-Producer-Multiple-Consumer Queue. The queue created // will have infinite length. explicit MPMCQueue(); @@ -115,34 +99,26 @@ class MPMCQueue : public MPMCQueueInterface { void* PopFront(); struct Node { - Node *next; // Linking - void *content; // Points to actual element - gpr_timespec insert_time; // Time for stats + Node* next; // Linking + void* content; // Points to actual element + gpr_timespec insert_time; // Time for stats Node(void* c) : content(c) { next = nullptr; insert_time = gpr_now(GPR_CLOCK_PRECISE); } - void* operator new(size_t n) { - void* p = gpr_malloc(n); - return p; - } - - void operator delete(void* p) { - gpr_free(p); - } }; - Mutex mu_; // Protecting lock - CondVar wait_nonempty_; // Wait on empty queue on get - int num_waiters_; // Number of waiters + Mutex mu_; // Protecting lock + CondVar wait_nonempty_; // Wait on empty queue on get + int num_waiters_; // Number of waiters - Node *queue_head_; // Head of the queue, remove position - Node *queue_tail_; // End of queue, insert position - Atomic count_; // Number of elements in queue - Stats stats_; // Stats info - gpr_timespec busy_time; // Start time of busy queue + Node* queue_head_; // Head of the queue, remove position + Node* queue_tail_; // End of queue, insert position + Atomic count_; // Number of elements in queue + Stats stats_; // Stats info + gpr_timespec busy_time; // Start time of busy queue }; } // namespace grpc_core -#endif /* GRPC_CORE_LIB_IOMGR_MPMCQUEUE_H */ +#endif /* GRPC_CORE_LIB_IOMGR_THREADPOOL_MPMCQUEUE_H */ diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index d562f3c6722..60d06d30d77 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -42,17 +42,7 @@ struct WorkItem { int index; bool done; - WorkItem(int i) : index(i) { - done = false; - } - void* operator new(size_t n) { - void* p = gpr_malloc(n); - return p; - } - - void operator delete(void* p) { - gpr_free(p); - } + WorkItem(int i) : index(i) { done = false; } }; static void test_small_queue(void) { @@ -132,38 +122,28 @@ static void test_large_queue(void) { class WorkThread { public: WorkThread(grpc_core::MPMCQueue* mpmcqueue, int start_index, int num_items) - : start_index_(start_index), num_items_(num_items), + : start_index_(start_index), + num_items_(num_items), mpmcqueue_(mpmcqueue) { items_ = NULL; thd_ = grpc_core::Thread( "mpmcq_test_mt_put_thd", - [](void* th) { static_cast(th)->Run(); }, - this); + [](void* th) { static_cast(th)->Run(); }, this); } ~WorkThread() { for (int i = 0; i < num_items_; ++i) { GPR_ASSERT(items_[i]->done); delete items_[i]; } - gpr_free(items_); + delete[] items_; } void Start() { thd_.Start(); } void Join() { thd_.Join(); } - void* operator new(size_t n) { - void* p = gpr_malloc(n); - return p; - } - - void operator delete(void* p) { - gpr_free(p); - } - private: void Run() { - items_ = static_cast( - gpr_malloc(sizeof(WorkItem*) * num_items_)); + items_ = new WorkItem*[num_items_]; for (int i = 0; i < num_items_; ++i) { items_[i] = new WorkItem(start_index_ + i); mpmcqueue_->Put(items_[i]); @@ -177,7 +157,6 @@ class WorkThread { WorkItem** items_; }; - static void test_many_get_thd(void* args) { grpc_core::MPMCQueue* mpmcqueue = static_cast(args); @@ -199,8 +178,7 @@ static void test_many_thread(void) { const int num_work_thd = 10; const int num_get_thd = 20; grpc_core::MPMCQueue mpmcqueue; - WorkThread** work_thds = - static_cast(gpr_malloc(sizeof(WorkThread*) * num_work_thd)); + WorkThread** work_thds = new WorkThread*[num_work_thd]; grpc_core::Thread get_thds[num_get_thd]; gpr_log(GPR_DEBUG, "Fork WorkThread..."); @@ -212,8 +190,8 @@ static void test_many_thread(void) { gpr_log(GPR_DEBUG, "WorkThread Started."); gpr_log(GPR_DEBUG, "For Getter Thread..."); for (int i = 0; i < num_get_thd; ++i) { - get_thds[i] = grpc_core::Thread("mpmcq_test_mt_get_thd", - test_many_get_thd, &mpmcqueue); + get_thds[i] = grpc_core::Thread("mpmcq_test_mt_get_thd", test_many_get_thd, + &mpmcqueue); get_thds[i].Start(); } gpr_log(GPR_DEBUG, "Getter Thread Started."); @@ -234,11 +212,10 @@ static void test_many_thread(void) { for (int i = 0; i < num_work_thd; ++i) { delete work_thds[i]; } - gpr_free(work_thds); + delete[] work_thds; gpr_log(GPR_DEBUG, "Done."); } - int main(int argc, char** argv) { grpc::testing::TestEnvironment env(argc, argv); grpc_init(); From 8c8dc0e3c70594507818d7fd6525ca5e276cd49b Mon Sep 17 00:00:00 2001 From: Srini Polavarapu Date: Mon, 17 Jun 2019 15:01:28 -0700 Subject: [PATCH 0555/1555] 1.21.4 interop for cxx, csharp, php, ruby and python --- tools/interop_matrix/client_matrix.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index 43002c3b222..05c495f5633 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -97,6 +97,7 @@ LANG_RELEASE_MATRIX = { ('v1.18.0', ReleaseInfo(testcases_file='cxx__v1.0.1')), ('v1.19.0', ReleaseInfo(testcases_file='cxx__v1.0.1')), ('v1.20.0', ReleaseInfo()), + ('v1.21.4', ReleaseInfo()), ]), 'go': OrderedDict( @@ -209,6 +210,7 @@ LANG_RELEASE_MATRIX = { ('v1.18.0', ReleaseInfo()), ('v1.19.0', ReleaseInfo()), ('v1.20.0', ReleaseInfo()), + ('v1.21.4', ReleaseInfo()), ]), 'node': OrderedDict([ @@ -257,6 +259,7 @@ LANG_RELEASE_MATRIX = { ])), ('v1.19.0', ReleaseInfo()), ('v1.20.0', ReleaseInfo()), + ('v1.21.4', ReleaseInfo()), # TODO: https://github.com/grpc/grpc/issues/18262. # If you are not encountering the error in above issue # go ahead and upload the docker image for new releases. @@ -281,6 +284,7 @@ LANG_RELEASE_MATRIX = { ('v1.16.0', ReleaseInfo(testcases_file='php__v1.0.1')), ('v1.17.1', ReleaseInfo(testcases_file='php__v1.0.1')), ('v1.18.0', ReleaseInfo()), + ('v1.21.4', ReleaseInfo()), # TODO:https://github.com/grpc/grpc/issues/18264 # Error in above issues needs to be resolved. ]), @@ -312,5 +316,6 @@ LANG_RELEASE_MATRIX = { ('v1.18.0', ReleaseInfo(testcases_file='csharp__v1.18.0')), ('v1.19.0', ReleaseInfo(testcases_file='csharp__v1.18.0')), ('v1.20.0', ReleaseInfo()), + ('v1.21.4', ReleaseInfo()), ]), } From c2db456e16baa39088ede51ff406c9862a023f4c Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Mon, 17 Jun 2019 15:03:23 -0700 Subject: [PATCH 0556/1555] Modify MPMCQueueInterface class defination for c++ compiler --- src/core/lib/iomgr/threadpool/mpmcqueue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/threadpool/mpmcqueue.h b/src/core/lib/iomgr/threadpool/mpmcqueue.h index 18d30e876ab..2aa5ec1cdaa 100644 --- a/src/core/lib/iomgr/threadpool/mpmcqueue.h +++ b/src/core/lib/iomgr/threadpool/mpmcqueue.h @@ -31,7 +31,6 @@ namespace grpc_core { // Abstract base class of a MPMC queue interface class MPMCQueueInterface { public: - MPMCQueueInterface() {} virtual ~MPMCQueueInterface() {} // Put elem into queue immediately at the end of queue. @@ -102,6 +101,7 @@ class MPMCQueue : public MPMCQueueInterface { Node* next; // Linking void* content; // Points to actual element gpr_timespec insert_time; // Time for stats + Node(void* c) : content(c) { next = nullptr; insert_time = gpr_now(GPR_CLOCK_PRECISE); From ee6a462f03094d21b69ff69426062f99526f6743 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 18 Jun 2019 00:23:56 +0200 Subject: [PATCH 0557/1555] Another python fix. --- tools/bazel.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bazel.rc b/tools/bazel.rc index 99347495361..6378b82017e 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -59,5 +59,5 @@ build:basicprof --copt=-DGRPC_BASIC_PROFILER build:basicprof --copt=-DGRPC_TIMERS_RDTSC build:python3 --python_path=python3 -build:python3 --force_python=PY3 +build:python3 --python_version=PY3 build:python3 --action_env=PYTHON_BIN_PATH=python3 From 0a1b6d8304070e7dc0a940e31ab2a7f5a91d2f84 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Mon, 17 Jun 2019 15:33:35 -0700 Subject: [PATCH 0558/1555] Modify format - nullptr --- test/core/iomgr/mpmcqueue_test.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index 60d06d30d77..e40a350c18c 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -67,7 +67,7 @@ static void test_get_thd(void* args) { int count = 0; int last_index = -1; WorkItem* item; - while ((item = static_cast(mpmcqueue->Get())) != NULL) { + while ((item = static_cast(mpmcqueue->Get())) != nullptr) { count++; GPR_ASSERT(item->index > last_index); last_index = item->index; @@ -96,7 +96,7 @@ static void test_get_empty(void) { gpr_log(GPR_DEBUG, "Terminating threads..."); for (int i = 0; i < num_threads; ++i) { - mpmcqueue.Put(NULL); + mpmcqueue.Put(nullptr); } for (int i = 0; i < num_threads; ++i) { thds[i].Join(); @@ -125,7 +125,7 @@ class WorkThread { : start_index_(start_index), num_items_(num_items), mpmcqueue_(mpmcqueue) { - items_ = NULL; + items_ = nullptr; thd_ = grpc_core::Thread( "mpmcq_test_mt_put_thd", [](void* th) { static_cast(th)->Run(); }, this); @@ -164,7 +164,7 @@ static void test_many_get_thd(void* args) { int count = 0; WorkItem* item; - while ((item = static_cast(mpmcqueue->Get())) != NULL) { + while ((item = static_cast(mpmcqueue->Get())) != nullptr) { count++; GPR_ASSERT(!item->done); item->done = true; @@ -202,7 +202,7 @@ static void test_many_thread(void) { gpr_log(GPR_DEBUG, "All WorkThread Terminated."); gpr_log(GPR_DEBUG, "Terminating Getter Thread..."); for (int i = 0; i < num_get_thd; ++i) { - mpmcqueue.Put(NULL); + mpmcqueue.Put(nullptr); } for (int i = 0; i < num_get_thd; ++i) { get_thds[i].Join(); From 559afb59b2cecbba74ddd51b0cc9b7f0b68e3fd8 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Mon, 17 Jun 2019 15:53:31 -0700 Subject: [PATCH 0559/1555] Re-format indentation --- src/core/lib/iomgr/threadpool/mpmcqueue.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/threadpool/mpmcqueue.cc b/src/core/lib/iomgr/threadpool/mpmcqueue.cc index e641ba70faa..a66cd91e92d 100644 --- a/src/core/lib/iomgr/threadpool/mpmcqueue.cc +++ b/src/core/lib/iomgr/threadpool/mpmcqueue.cc @@ -62,8 +62,8 @@ inline void* MPMCQueue::PopFront() { return result; } -MPMCQueue::MPMCQueue() : num_waiters_(0), queue_head_(nullptr), - queue_tail_(nullptr) { +MPMCQueue::MPMCQueue() + : num_waiters_(0), queue_head_(nullptr), queue_tail_(nullptr) { count_.Store(0, MemoryOrder::RELAXED); } From 7866e41a97aa8e11cefb1f20041cda52dc93fa5a Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Mon, 17 Jun 2019 16:17:40 -0700 Subject: [PATCH 0560/1555] Adjust include headers --- src/core/lib/iomgr/threadpool/mpmcqueue.cc | 3 ++- src/core/lib/iomgr/threadpool/mpmcqueue.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/threadpool/mpmcqueue.cc b/src/core/lib/iomgr/threadpool/mpmcqueue.cc index a66cd91e92d..b2e09b9c81b 100644 --- a/src/core/lib/iomgr/threadpool/mpmcqueue.cc +++ b/src/core/lib/iomgr/threadpool/mpmcqueue.cc @@ -16,12 +16,13 @@ * */ +#include + #include "src/core/lib/iomgr/threadpool/mpmcqueue.h" #include #include #include -#include #include #include #include diff --git a/src/core/lib/iomgr/threadpool/mpmcqueue.h b/src/core/lib/iomgr/threadpool/mpmcqueue.h index 2aa5ec1cdaa..8c8395e1d9d 100644 --- a/src/core/lib/iomgr/threadpool/mpmcqueue.h +++ b/src/core/lib/iomgr/threadpool/mpmcqueue.h @@ -19,8 +19,9 @@ #ifndef GRPC_CORE_LIB_IOMGR_THREADPOOL_MPMCQUEUE_H #define GRPC_CORE_LIB_IOMGR_THREADPOOL_MPMCQUEUE_H -#include #include + +#include #include #include "src/core/lib/gprpp/atomic.h" From 4fc02c6bf546fd85076c9cd555eb91f4d04408bd Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 17 Jun 2019 16:30:06 -0700 Subject: [PATCH 0561/1555] add tests for bad stream IDs --- CMakeLists.txt | 41 ++++++ Makefile | 36 +++++ test/core/bad_client/gen_build_yaml.py | 1 + test/core/bad_client/generate_tests.bzl | 1 + .../core/bad_client/tests/bad_streaming_id.cc | 132 ++++++++++++++++++ .../generated/sources_and_headers.json | 17 +++ tools/run_tests/generated/tests.json | 26 ++++ 7 files changed, 254 insertions(+) create mode 100644 test/core/bad_client/tests/bad_streaming_id.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 13d54ec0cda..f0b4dd562f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -724,6 +724,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx writes_per_rpc_test) endif() add_dependencies(buildtests_cxx xds_end2end_test) +add_dependencies(buildtests_cxx bad_streaming_id_bad_client_test) add_dependencies(buildtests_cxx badreq_bad_client_test) add_dependencies(buildtests_cxx connection_prefix_bad_client_test) add_dependencies(buildtests_cxx duplicate_header_bad_client_test) @@ -17030,6 +17031,46 @@ target_link_libraries(gen_percent_encoding_tables if (gRPC_BUILD_TESTS) +add_executable(bad_streaming_id_bad_client_test + test/core/bad_client/tests/bad_streaming_id.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(bad_streaming_id_bad_client_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(bad_streaming_id_bad_client_test + ${_gRPC_SSL_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + bad_client_test + grpc_test_util_unsecure + grpc_unsecure + gpr + ${_gRPC_GFLAGS_LIBRARIES} +) + + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + add_executable(badreq_bad_client_test test/core/bad_client/tests/badreq.cc third_party/googletest/googletest/src/gtest-all.cc diff --git a/Makefile b/Makefile index d45c0992370..4d04ba0e4be 100644 --- a/Makefile +++ b/Makefile @@ -1291,6 +1291,7 @@ gen_legal_metadata_characters: $(BINDIR)/$(CONFIG)/gen_legal_metadata_characters gen_percent_encoding_tables: $(BINDIR)/$(CONFIG)/gen_percent_encoding_tables boringssl_ssl_test: $(BINDIR)/$(CONFIG)/boringssl_ssl_test boringssl_crypto_test: $(BINDIR)/$(CONFIG)/boringssl_crypto_test +bad_streaming_id_bad_client_test: $(BINDIR)/$(CONFIG)/bad_streaming_id_bad_client_test badreq_bad_client_test: $(BINDIR)/$(CONFIG)/badreq_bad_client_test connection_prefix_bad_client_test: $(BINDIR)/$(CONFIG)/connection_prefix_bad_client_test duplicate_header_bad_client_test: $(BINDIR)/$(CONFIG)/duplicate_header_bad_client_test @@ -1751,6 +1752,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/xds_end2end_test \ $(BINDIR)/$(CONFIG)/boringssl_ssl_test \ $(BINDIR)/$(CONFIG)/boringssl_crypto_test \ + $(BINDIR)/$(CONFIG)/bad_streaming_id_bad_client_test \ $(BINDIR)/$(CONFIG)/badreq_bad_client_test \ $(BINDIR)/$(CONFIG)/connection_prefix_bad_client_test \ $(BINDIR)/$(CONFIG)/duplicate_header_bad_client_test \ @@ -1910,6 +1912,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/transport_security_common_api_test \ $(BINDIR)/$(CONFIG)/writes_per_rpc_test \ $(BINDIR)/$(CONFIG)/xds_end2end_test \ + $(BINDIR)/$(CONFIG)/bad_streaming_id_bad_client_test \ $(BINDIR)/$(CONFIG)/badreq_bad_client_test \ $(BINDIR)/$(CONFIG)/connection_prefix_bad_client_test \ $(BINDIR)/$(CONFIG)/duplicate_header_bad_client_test \ @@ -2441,6 +2444,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/writes_per_rpc_test || ( echo test writes_per_rpc_test failed ; exit 1 ) $(E) "[RUN] Testing xds_end2end_test" $(Q) $(BINDIR)/$(CONFIG)/xds_end2end_test || ( echo test xds_end2end_test failed ; exit 1 ) + $(E) "[RUN] Testing bad_streaming_id_bad_client_test" + $(Q) $(BINDIR)/$(CONFIG)/bad_streaming_id_bad_client_test || ( echo test bad_streaming_id_bad_client_test failed ; exit 1 ) $(E) "[RUN] Testing badreq_bad_client_test" $(Q) $(BINDIR)/$(CONFIG)/badreq_bad_client_test || ( echo test badreq_bad_client_test failed ; exit 1 ) $(E) "[RUN] Testing connection_prefix_bad_client_test" @@ -20323,6 +20328,37 @@ ifneq ($(NO_DEPS),true) endif +BAD_STREAMING_ID_BAD_CLIENT_TEST_SRC = \ + test/core/bad_client/tests/bad_streaming_id.cc \ + +BAD_STREAMING_ID_BAD_CLIENT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BAD_STREAMING_ID_BAD_CLIENT_TEST_SRC)))) + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/bad_streaming_id_bad_client_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/bad_streaming_id_bad_client_test: $(PROTOBUF_DEP) $(BAD_STREAMING_ID_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(BAD_STREAMING_ID_BAD_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/bad_streaming_id_bad_client_test + +endif + +$(OBJDIR)/$(CONFIG)/test/core/bad_client/tests/bad_streaming_id.o: $(LIBDIR)/$(CONFIG)/libbad_client_test.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_bad_streaming_id_bad_client_test: $(BAD_STREAMING_ID_BAD_CLIENT_TEST_OBJS:.o=.dep) + +ifneq ($(NO_DEPS),true) +-include $(BAD_STREAMING_ID_BAD_CLIENT_TEST_OBJS:.o=.dep) +endif + + BADREQ_BAD_CLIENT_TEST_SRC = \ test/core/bad_client/tests/badreq.cc \ diff --git a/test/core/bad_client/gen_build_yaml.py b/test/core/bad_client/gen_build_yaml.py index a4f3e4a0a34..d0ac94ae349 100755 --- a/test/core/bad_client/gen_build_yaml.py +++ b/test/core/bad_client/gen_build_yaml.py @@ -27,6 +27,7 @@ default_test_options = TestOptions(False, 1.0) # maps test names to options BAD_CLIENT_TESTS = { 'badreq': default_test_options, + 'bad_streaming_id': default_test_options, 'connection_prefix': default_test_options._replace(cpu_cost=0.2), 'duplicate_header': default_test_options, 'headers': default_test_options._replace(cpu_cost=0.2), diff --git a/test/core/bad_client/generate_tests.bzl b/test/core/bad_client/generate_tests.bzl index da372dd0bc9..5c9e688b82a 100755 --- a/test/core/bad_client/generate_tests.bzl +++ b/test/core/bad_client/generate_tests.bzl @@ -25,6 +25,7 @@ def test_options(): # maps test names to options BAD_CLIENT_TESTS = { 'badreq': test_options(), + 'bad_streaming_id': test_options(), 'connection_prefix': test_options(), 'duplicate_header': test_options(), 'headers': test_options(), diff --git a/test/core/bad_client/tests/bad_streaming_id.cc b/test/core/bad_client/tests/bad_streaming_id.cc new file mode 100644 index 00000000000..287db433880 --- /dev/null +++ b/test/core/bad_client/tests/bad_streaming_id.cc @@ -0,0 +1,132 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include + +#include +#include "src/core/lib/surface/server.h" +#include "test/core/bad_client/bad_client.h" + +#define HEADER_FRAME_ID_1 \ + "\x00\x00\xc9\x01\x05\x00\x00\x00\x01" /* headers: generated from \ + simple_request.headers in this \ + directory */ \ + "\x10\x05:path\x08/foo/bar" \ + "\x10\x07:scheme\x04http" \ + "\x10\x07:method\x04POST" \ + "\x10\x0a:authority\x09localhost" \ + "\x10\x0c" \ + "content-type\x10" \ + "application/grpc" \ + "\x10\x14grpc-accept-encoding\x15" \ + "deflate,identity,gzip" \ + "\x10\x02te\x08trailers" \ + "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)" + +#define HEADER_FRAME_ID_2 \ + "\x00\x00\xc9\x01\x05\x00\x00\x00\x02" /* headers: generated from \ + simple_request.headers in this \ + directory */ \ + "\x10\x05:path\x08/foo/bar" \ + "\x10\x07:scheme\x04http" \ + "\x10\x07:method\x04POST" \ + "\x10\x0a:authority\x09localhost" \ + "\x10\x0c" \ + "content-type\x10" \ + "application/grpc" \ + "\x10\x14grpc-accept-encoding\x15" \ + "deflate,identity,gzip" \ + "\x10\x02te\x08trailers" \ + "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)" + +#define HEADER_FRAME_ID_3 \ + "\x00\x00\xc9\x01\x05\x00\x00\x00\x03" /* headers: generated from \ + simple_request.headers in this \ + directory */ \ + "\x10\x05:path\x08/foo/bar" \ + "\x10\x07:scheme\x04http" \ + "\x10\x07:method\x04POST" \ + "\x10\x0a:authority\x09localhost" \ + "\x10\x0c" \ + "content-type\x10" \ + "application/grpc" \ + "\x10\x14grpc-accept-encoding\x15" \ + "deflate,identity,gzip" \ + "\x10\x02te\x08trailers" \ + "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)" + +namespace { + +void verifier(grpc_server* server, grpc_completion_queue* cq, + void* registered_method) { + while (grpc_server_has_open_connections(server)) { + GPR_ASSERT(grpc_completion_queue_next( + cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) + .type == GRPC_QUEUE_TIMEOUT); + } +} + +TEST(BadStreamingId, RegularHeader) { + grpc_bad_client_arg args[2]; + args[0] = connection_preface_arg; + args[1].client_validator = nullptr; + args[1].client_payload = HEADER_FRAME_ID_1; + args[1].client_payload_length = sizeof(HEADER_FRAME_ID_1) - 1; + grpc_run_bad_client_test(verifier, args, 2, GRPC_BAD_CLIENT_DISCONNECT); +} + +TEST(BadStreamingId, NonClientStreamId) { + grpc_bad_client_arg args[2]; + args[0] = connection_preface_arg; + // send a header frame with non-client stream id 2 + args[1].client_validator = nullptr; + args[1].client_payload = HEADER_FRAME_ID_2; + args[1].client_payload_length = sizeof(HEADER_FRAME_ID_2) - 1; + grpc_run_bad_client_test(verifier, args, 2, GRPC_BAD_CLIENT_DISCONNECT); +} + +TEST(BadStreamingId, ClosedStreamId) { + grpc_bad_client_arg args[4]; + args[0] = connection_preface_arg; + // send a header frame with stream id 1 + args[1].client_validator = nullptr; + args[1].client_payload = HEADER_FRAME_ID_1; + args[1].client_payload_length = sizeof(HEADER_FRAME_ID_1) - 1; + // send a header frame with stream id 3 + args[2].client_validator = nullptr; + args[2].client_payload = HEADER_FRAME_ID_3; + args[2].client_payload_length = sizeof(HEADER_FRAME_ID_3) - 1; + // send a header frame with closed stream id 1 again + args[3].client_validator = nullptr; + args[3].client_payload = HEADER_FRAME_ID_1; + args[3].client_payload_length = sizeof(HEADER_FRAME_ID_1) - 1; + grpc_run_bad_client_test(verifier, args, 4, GRPC_BAD_CLIENT_DISCONNECT); +} + +} // namespace + +int main(int argc, char** argv) { + grpc_init(); + grpc::testing::TestEnvironment env(argc, argv); + ::testing::InitGoogleTest(&argc, argv); + int retval = RUN_ALL_TESTS(); + grpc_shutdown(); + return retval; +} diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 3143f2cc87f..6f59fab77af 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -5267,6 +5267,23 @@ "third_party": true, "type": "target" }, + { + "deps": [ + "bad_client_test", + "gpr", + "grpc_test_util_unsecure", + "grpc_unsecure" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "bad_streaming_id_bad_client_test", + "src": [ + "test/core/bad_client/tests/bad_streaming_id.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "bad_client_test", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 37a69a47b23..43067e3620d 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -5918,6 +5918,32 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "gtest": false, + "language": "c++", + "name": "bad_streaming_id_bad_client_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": true + }, { "args": [], "benchmark": false, From 8a310e50637987902341ed9f9247c9ff443c1f9d Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 17 Jun 2019 16:48:30 -0700 Subject: [PATCH 0562/1555] Clang tidy --- test/core/bad_client/tests/out_of_bounds.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/bad_client/tests/out_of_bounds.cc b/test/core/bad_client/tests/out_of_bounds.cc index 78d84a638a8..b716e952bc1 100644 --- a/test/core/bad_client/tests/out_of_bounds.cc +++ b/test/core/bad_client/tests/out_of_bounds.cc @@ -38,7 +38,7 @@ void verifier(grpc_server* server, grpc_completion_queue* cq, } } -void FrameVerifier(std::string attack_vector) { +void FrameVerifier(const std::string& attack_vector) { grpc_bad_client_arg args[2]; args[0] = connection_preface_arg; args[1].client_validator = nullptr; From 70c8211c85946e2b665198e5cca05b2ed9275c97 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Mon, 17 Jun 2019 16:57:30 -0700 Subject: [PATCH 0563/1555] Add config files --- config.m4 | 2 ++ config.w32 | 2 ++ gRPC-C++.podspec | 2 ++ gRPC-Core.podspec | 3 +++ grpc.gemspec | 2 ++ grpc.gyp | 4 ++++ package.xml | 2 ++ tools/doxygen/Doxyfile.c++.internal | 1 + tools/doxygen/Doxyfile.core.internal | 2 ++ 9 files changed, 20 insertions(+) diff --git a/config.m4 b/config.m4 index bb30be56910..6782f94a2b2 100644 --- a/config.m4 +++ b/config.m4 @@ -184,6 +184,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/iomgr/tcp_server_windows.cc \ src/core/lib/iomgr/tcp_uv.cc \ src/core/lib/iomgr/tcp_windows.cc \ + src/core/lib/iomgr/threadpool/mpmcqueue.cc \ src/core/lib/iomgr/time_averaged_stats.cc \ src/core/lib/iomgr/timer.cc \ src/core/lib/iomgr/timer_custom.cc \ @@ -726,6 +727,7 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/gprpp) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/http) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/iomgr) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/iomgr/threadpool) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/json) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/profiling) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/security/context) diff --git a/config.w32 b/config.w32 index c9faa8d9ac8..8bff737f51f 100644 --- a/config.w32 +++ b/config.w32 @@ -159,6 +159,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\iomgr\\tcp_server_windows.cc " + "src\\core\\lib\\iomgr\\tcp_uv.cc " + "src\\core\\lib\\iomgr\\tcp_windows.cc " + + "src\\core\\lib\\iomgr\\threadpool\\mpmcqueue.cc " + "src\\core\\lib\\iomgr\\time_averaged_stats.cc " + "src\\core\\lib\\iomgr\\timer.cc " + "src\\core\\lib\\iomgr\\timer_custom.cc " + @@ -739,6 +740,7 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\gprpp"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\http"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\iomgr"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\iomgr\\threadpool"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\json"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\profiling"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\security"); diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 18ed5f89102..55e7e9340a1 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -507,6 +507,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/tcp_server.h', 'src/core/lib/iomgr/tcp_server_utils_posix.h', 'src/core/lib/iomgr/tcp_windows.h', + 'src/core/lib/iomgr/threadpool/mpmcqueue.h', 'src/core/lib/iomgr/time_averaged_stats.h', 'src/core/lib/iomgr/timer.h', 'src/core/lib/iomgr/timer_custom.h', @@ -711,6 +712,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/tcp_server.h', 'src/core/lib/iomgr/tcp_server_utils_posix.h', 'src/core/lib/iomgr/tcp_windows.h', + 'src/core/lib/iomgr/threadpool/mpmcqueue.h', 'src/core/lib/iomgr/time_averaged_stats.h', 'src/core/lib/iomgr/timer.h', 'src/core/lib/iomgr/timer_custom.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 85add8fb7a2..56b3d5b0955 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -477,6 +477,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/tcp_server.h', 'src/core/lib/iomgr/tcp_server_utils_posix.h', 'src/core/lib/iomgr/tcp_windows.h', + 'src/core/lib/iomgr/threadpool/mpmcqueue.h', 'src/core/lib/iomgr/time_averaged_stats.h', 'src/core/lib/iomgr/timer.h', 'src/core/lib/iomgr/timer_custom.h', @@ -646,6 +647,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/tcp_server_windows.cc', 'src/core/lib/iomgr/tcp_uv.cc', 'src/core/lib/iomgr/tcp_windows.cc', + 'src/core/lib/iomgr/threadpool/mpmcqueue.cc', 'src/core/lib/iomgr/time_averaged_stats.cc', 'src/core/lib/iomgr/timer.cc', 'src/core/lib/iomgr/timer_custom.cc', @@ -1130,6 +1132,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/tcp_server.h', 'src/core/lib/iomgr/tcp_server_utils_posix.h', 'src/core/lib/iomgr/tcp_windows.h', + 'src/core/lib/iomgr/threadpool/mpmcqueue.h', 'src/core/lib/iomgr/time_averaged_stats.h', 'src/core/lib/iomgr/timer.h', 'src/core/lib/iomgr/timer_custom.h', diff --git a/grpc.gemspec b/grpc.gemspec index e9d215bf10f..0e21836c8d5 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -411,6 +411,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/iomgr/tcp_server.h ) s.files += %w( src/core/lib/iomgr/tcp_server_utils_posix.h ) s.files += %w( src/core/lib/iomgr/tcp_windows.h ) + s.files += %w( src/core/lib/iomgr/threadpool/mpmcqueue.h ) s.files += %w( src/core/lib/iomgr/time_averaged_stats.h ) s.files += %w( src/core/lib/iomgr/timer.h ) s.files += %w( src/core/lib/iomgr/timer_custom.h ) @@ -580,6 +581,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/iomgr/tcp_server_windows.cc ) s.files += %w( src/core/lib/iomgr/tcp_uv.cc ) s.files += %w( src/core/lib/iomgr/tcp_windows.cc ) + s.files += %w( src/core/lib/iomgr/threadpool/mpmcqueue.cc ) s.files += %w( src/core/lib/iomgr/time_averaged_stats.cc ) s.files += %w( src/core/lib/iomgr/timer.cc ) s.files += %w( src/core/lib/iomgr/timer_custom.cc ) diff --git a/grpc.gyp b/grpc.gyp index 6268bed7bb0..f64c80c2008 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -366,6 +366,7 @@ 'src/core/lib/iomgr/tcp_server_windows.cc', 'src/core/lib/iomgr/tcp_uv.cc', 'src/core/lib/iomgr/tcp_windows.cc', + 'src/core/lib/iomgr/threadpool/mpmcqueue.cc', 'src/core/lib/iomgr/time_averaged_stats.cc', 'src/core/lib/iomgr/timer.cc', 'src/core/lib/iomgr/timer_custom.cc', @@ -742,6 +743,7 @@ 'src/core/lib/iomgr/tcp_server_windows.cc', 'src/core/lib/iomgr/tcp_uv.cc', 'src/core/lib/iomgr/tcp_windows.cc', + 'src/core/lib/iomgr/threadpool/mpmcqueue.cc', 'src/core/lib/iomgr/time_averaged_stats.cc', 'src/core/lib/iomgr/timer.cc', 'src/core/lib/iomgr/timer_custom.cc', @@ -992,6 +994,7 @@ 'src/core/lib/iomgr/tcp_server_windows.cc', 'src/core/lib/iomgr/tcp_uv.cc', 'src/core/lib/iomgr/tcp_windows.cc', + 'src/core/lib/iomgr/threadpool/mpmcqueue.cc', 'src/core/lib/iomgr/time_averaged_stats.cc', 'src/core/lib/iomgr/timer.cc', 'src/core/lib/iomgr/timer_custom.cc', @@ -1218,6 +1221,7 @@ 'src/core/lib/iomgr/tcp_server_windows.cc', 'src/core/lib/iomgr/tcp_uv.cc', 'src/core/lib/iomgr/tcp_windows.cc', + 'src/core/lib/iomgr/threadpool/mpmcqueue.cc', 'src/core/lib/iomgr/time_averaged_stats.cc', 'src/core/lib/iomgr/timer.cc', 'src/core/lib/iomgr/timer_custom.cc', diff --git a/package.xml b/package.xml index fd712698a62..77162f3d366 100644 --- a/package.xml +++ b/package.xml @@ -416,6 +416,7 @@ + @@ -585,6 +586,7 @@ + diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 9b0f8f9fcd7..e5e78ffbb4b 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1172,6 +1172,7 @@ src/core/lib/iomgr/tcp_posix.h \ src/core/lib/iomgr/tcp_server.h \ src/core/lib/iomgr/tcp_server_utils_posix.h \ src/core/lib/iomgr/tcp_windows.h \ +src/core/lib/iomgr/threadpool/mpmcqueue.h \ src/core/lib/iomgr/time_averaged_stats.h \ src/core/lib/iomgr/timer.h \ src/core/lib/iomgr/timer_custom.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 7768bca30f5..83a9315d5af 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1331,6 +1331,8 @@ src/core/lib/iomgr/tcp_server_windows.cc \ src/core/lib/iomgr/tcp_uv.cc \ src/core/lib/iomgr/tcp_windows.cc \ src/core/lib/iomgr/tcp_windows.h \ +src/core/lib/iomgr/threadpool/mpmcqueue.cc \ +src/core/lib/iomgr/threadpool/mpmcqueue.h \ src/core/lib/iomgr/time_averaged_stats.cc \ src/core/lib/iomgr/time_averaged_stats.h \ src/core/lib/iomgr/timer.cc \ From 62b53012361d5516c148260532bb8982fe074fdb Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 17 Jun 2019 17:01:17 -0700 Subject: [PATCH 0564/1555] Revert "Simplify LB policy and resolver shutdown." --- .../filters/client_channel/client_channel.cc | 7 +++++-- .../ext/filters/client_channel/lb_policy.cc | 19 +++++++++++++++++-- .../ext/filters/client_channel/lb_policy.h | 4 +++- .../client_channel/lb_policy/xds/xds.cc | 3 --- .../ext/filters/client_channel/resolver.h | 14 +++++++++++--- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 40f8cef522b..a67792fcd37 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -1435,8 +1435,10 @@ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error) std::move(target_uri), ProcessResolverResultLocked, this, error)); grpc_channel_args_destroy(new_args); if (*error != GRPC_ERROR_NONE) { - // Before we return, shut down the resolving LB policy, which destroys - // the ClientChannelControlHelper and therefore unrefs the channel stack. + // Orphan the resolving LB policy and flush the exec_ctx to ensure + // that it finishes shutting down. This ensures that if we are + // failing, we destroy the ClientChannelControlHelper (and thus + // unref the channel stack) before we return. // TODO(roth): This is not a complete solution, because it only // catches the case where channel stack initialization fails in this // particular filter. If there is a failure in a different filter, we @@ -1444,6 +1446,7 @@ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error) // in practice, there are no other filters that can cause failures in // channel stack initialization, so this works for now. resolving_lb_policy_.reset(); + ExecCtx::Get()->Flush(); } else { grpc_pollset_set_add_pollset_set(resolving_lb_policy_->interested_parties(), interested_parties_); diff --git a/src/core/ext/filters/client_channel/lb_policy.cc b/src/core/ext/filters/client_channel/lb_policy.cc index 3207f888044..3e4d3703c82 100644 --- a/src/core/ext/filters/client_channel/lb_policy.cc +++ b/src/core/ext/filters/client_channel/lb_policy.cc @@ -43,8 +43,23 @@ LoadBalancingPolicy::~LoadBalancingPolicy() { } void LoadBalancingPolicy::Orphan() { - ShutdownLocked(); - Unref(); + // Invoke ShutdownAndUnrefLocked() inside of the combiner. + // TODO(roth): Is this actually needed? We should already be in the + // combiner here. Note that if we directly call ShutdownLocked(), + // then we can probably remove the hack whereby the helper is + // destroyed at shutdown instead of at destruction. + GRPC_CLOSURE_SCHED( + GRPC_CLOSURE_CREATE(&LoadBalancingPolicy::ShutdownAndUnrefLocked, this, + grpc_combiner_scheduler(combiner_)), + GRPC_ERROR_NONE); +} + +void LoadBalancingPolicy::ShutdownAndUnrefLocked(void* arg, + grpc_error* ignored) { + LoadBalancingPolicy* policy = static_cast(arg); + policy->ShutdownLocked(); + policy->channel_control_helper_.reset(); + policy->Unref(); } // diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h index ecc235bb71b..c21e9d90ec4 100644 --- a/src/core/ext/filters/client_channel/lb_policy.h +++ b/src/core/ext/filters/client_channel/lb_policy.h @@ -282,7 +282,6 @@ class LoadBalancingPolicy : public InternallyRefCounted { grpc_pollset_set* interested_parties() const { return interested_parties_; } - // Note: This must be invoked while holding the combiner. void Orphan() override; // A picker that returns PICK_QUEUE for all picks. @@ -323,6 +322,7 @@ class LoadBalancingPolicy : public InternallyRefCounted { // Note: LB policies MUST NOT call any method on the helper from their // constructor. + // Note: This will return null after ShutdownLocked() has been called. ChannelControlHelper* channel_control_helper() const { return channel_control_helper_.get(); } @@ -331,6 +331,8 @@ class LoadBalancingPolicy : public InternallyRefCounted { virtual void ShutdownLocked() GRPC_ABSTRACT; private: + static void ShutdownAndUnrefLocked(void* arg, grpc_error* ignored); + /// Combiner under which LB policy actions take place. grpc_combiner* combiner_; /// Owned pointer to interested parties in load balancing decisions. diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index ca6ab216515..74660cec92b 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -1989,9 +1989,6 @@ void XdsLb::LocalityMap::LocalityEntry::ShutdownLocked() { parent_->interested_parties()); pending_child_policy_.reset(); } - // Drop our ref to the child's picker, in case it's holding a ref to - // the child. - picker_ref_.reset(); } void XdsLb::LocalityMap::LocalityEntry::ResetBackoffLocked() { diff --git a/src/core/ext/filters/client_channel/resolver.h b/src/core/ext/filters/client_channel/resolver.h index 829a860040a..87a4442d75b 100644 --- a/src/core/ext/filters/client_channel/resolver.h +++ b/src/core/ext/filters/client_channel/resolver.h @@ -117,10 +117,12 @@ class Resolver : public InternallyRefCounted { /// implementations. At that point, this method can go away. virtual void ResetBackoffLocked() {} - // Note: This must be invoked while holding the combiner. void Orphan() override { - ShutdownLocked(); - Unref(); + // Invoke ShutdownAndUnrefLocked() inside of the combiner. + GRPC_CLOSURE_SCHED( + GRPC_CLOSURE_CREATE(&Resolver::ShutdownAndUnrefLocked, this, + grpc_combiner_scheduler(combiner_)), + GRPC_ERROR_NONE); } GRPC_ABSTRACT_BASE_CLASS @@ -145,6 +147,12 @@ class Resolver : public InternallyRefCounted { ResultHandler* result_handler() const { return result_handler_.get(); } private: + static void ShutdownAndUnrefLocked(void* arg, grpc_error* ignored) { + Resolver* resolver = static_cast(arg); + resolver->ShutdownLocked(); + resolver->Unref(); + } + UniquePtr result_handler_; grpc_combiner* combiner_; }; From 1def76bf1d789ac6bc3d6521ee5742769eab1b60 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Mon, 17 Jun 2019 17:16:46 -0700 Subject: [PATCH 0565/1555] Add Makefile --- BUILD.gn | 3 + CMakeLists.txt | 76 +++++++++-------- Makefile | 84 +++++++++++-------- src/python/grpcio/grpc_core_dependencies.py | 1 + .../generated/sources_and_headers.json | 34 ++++---- tools/run_tests/generated/tests.json | 48 +++++------ 6 files changed, 135 insertions(+), 111 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index e5396f51426..2ec4609c06d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -622,6 +622,8 @@ config("grpc_config") { "src/core/lib/iomgr/tcp_uv.cc", "src/core/lib/iomgr/tcp_windows.cc", "src/core/lib/iomgr/tcp_windows.h", + "src/core/lib/iomgr/threadpool/mpmcqueue.cc", + "src/core/lib/iomgr/threadpool/mpmcqueue.h", "src/core/lib/iomgr/time_averaged_stats.cc", "src/core/lib/iomgr/time_averaged_stats.h", "src/core/lib/iomgr/timer.cc", @@ -1267,6 +1269,7 @@ config("grpc_config") { "src/core/lib/iomgr/tcp_server.h", "src/core/lib/iomgr/tcp_server_utils_posix.h", "src/core/lib/iomgr/tcp_windows.h", + "src/core/lib/iomgr/threadpool/mpmcqueue.h", "src/core/lib/iomgr/time_averaged_stats.h", "src/core/lib/iomgr/timer.h", "src/core/lib/iomgr/timer_custom.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index c43039a4fed..7438eaf37cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -378,7 +378,6 @@ add_dependencies(buildtests_c memory_usage_test) endif() add_dependencies(buildtests_c message_compress_test) add_dependencies(buildtests_c minimal_stack_is_minimal_test) -add_dependencies(buildtests_c mpmcqueue_test) add_dependencies(buildtests_c multiple_server_queues_test) add_dependencies(buildtests_c murmur_hash_test) add_dependencies(buildtests_c no_server_test) @@ -664,6 +663,7 @@ add_dependencies(buildtests_cxx memory_test) add_dependencies(buildtests_cxx message_allocator_end2end_test) add_dependencies(buildtests_cxx metrics_client) add_dependencies(buildtests_cxx mock_test) +add_dependencies(buildtests_cxx mpmcqueue_test) add_dependencies(buildtests_cxx nonblocking_test) add_dependencies(buildtests_cxx noop-benchmark) add_dependencies(buildtests_cxx optional_test) @@ -9362,40 +9362,6 @@ target_link_libraries(minimal_stack_is_minimal_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) -add_executable(mpmcqueue_test - test/core/iomgr/mpmcqueue_test.cc -) - - -target_include_directories(mpmcqueue_test - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} -) - -target_link_libraries(mpmcqueue_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - grpc - gpr -) - - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(mpmcqueue_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(mpmcqueue_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() - -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) - add_executable(multiple_server_queues_test test/core/end2end/multiple_server_queues_test.cc ) @@ -15035,6 +15001,46 @@ target_link_libraries(mock_test ) +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + +add_executable(mpmcqueue_test + test/core/iomgr/mpmcqueue_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(mpmcqueue_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(mpmcqueue_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc++_test_util + grpc_test_util + grpc++ + grpc + gpr + ${_gRPC_GFLAGS_LIBRARIES} +) + + endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index a188ae668d9..717402673b4 100644 --- a/Makefile +++ b/Makefile @@ -1092,7 +1092,6 @@ memory_usage_server: $(BINDIR)/$(CONFIG)/memory_usage_server memory_usage_test: $(BINDIR)/$(CONFIG)/memory_usage_test message_compress_test: $(BINDIR)/$(CONFIG)/message_compress_test minimal_stack_is_minimal_test: $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test -mpmcqueue_test: $(BINDIR)/$(CONFIG)/mpmcqueue_test multiple_server_queues_test: $(BINDIR)/$(CONFIG)/multiple_server_queues_test murmur_hash_test: $(BINDIR)/$(CONFIG)/murmur_hash_test nanopb_fuzzer_response_test: $(BINDIR)/$(CONFIG)/nanopb_fuzzer_response_test @@ -1241,6 +1240,7 @@ memory_test: $(BINDIR)/$(CONFIG)/memory_test message_allocator_end2end_test: $(BINDIR)/$(CONFIG)/message_allocator_end2end_test metrics_client: $(BINDIR)/$(CONFIG)/metrics_client mock_test: $(BINDIR)/$(CONFIG)/mock_test +mpmcqueue_test: $(BINDIR)/$(CONFIG)/mpmcqueue_test nonblocking_test: $(BINDIR)/$(CONFIG)/nonblocking_test noop-benchmark: $(BINDIR)/$(CONFIG)/noop-benchmark optional_test: $(BINDIR)/$(CONFIG)/optional_test @@ -1514,7 +1514,6 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/memory_usage_test \ $(BINDIR)/$(CONFIG)/message_compress_test \ $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test \ - $(BINDIR)/$(CONFIG)/mpmcqueue_test \ $(BINDIR)/$(CONFIG)/multiple_server_queues_test \ $(BINDIR)/$(CONFIG)/murmur_hash_test \ $(BINDIR)/$(CONFIG)/no_server_test \ @@ -1706,6 +1705,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/message_allocator_end2end_test \ $(BINDIR)/$(CONFIG)/metrics_client \ $(BINDIR)/$(CONFIG)/mock_test \ + $(BINDIR)/$(CONFIG)/mpmcqueue_test \ $(BINDIR)/$(CONFIG)/nonblocking_test \ $(BINDIR)/$(CONFIG)/noop-benchmark \ $(BINDIR)/$(CONFIG)/optional_test \ @@ -1867,6 +1867,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/message_allocator_end2end_test \ $(BINDIR)/$(CONFIG)/metrics_client \ $(BINDIR)/$(CONFIG)/mock_test \ + $(BINDIR)/$(CONFIG)/mpmcqueue_test \ $(BINDIR)/$(CONFIG)/nonblocking_test \ $(BINDIR)/$(CONFIG)/noop-benchmark \ $(BINDIR)/$(CONFIG)/optional_test \ @@ -2105,8 +2106,6 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/message_compress_test || ( echo test message_compress_test failed ; exit 1 ) $(E) "[RUN] Testing minimal_stack_is_minimal_test" $(Q) $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test || ( echo test minimal_stack_is_minimal_test failed ; exit 1 ) - $(E) "[RUN] Testing mpmcqueue_test" - $(Q) $(BINDIR)/$(CONFIG)/mpmcqueue_test || ( echo test mpmcqueue_test failed ; exit 1 ) $(E) "[RUN] Testing multiple_server_queues_test" $(Q) $(BINDIR)/$(CONFIG)/multiple_server_queues_test || ( echo test multiple_server_queues_test failed ; exit 1 ) $(E) "[RUN] Testing murmur_hash_test" @@ -2369,6 +2368,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/message_allocator_end2end_test || ( echo test message_allocator_end2end_test failed ; exit 1 ) $(E) "[RUN] Testing mock_test" $(Q) $(BINDIR)/$(CONFIG)/mock_test || ( echo test mock_test failed ; exit 1 ) + $(E) "[RUN] Testing mpmcqueue_test" + $(Q) $(BINDIR)/$(CONFIG)/mpmcqueue_test || ( echo test mpmcqueue_test failed ; exit 1 ) $(E) "[RUN] Testing nonblocking_test" $(Q) $(BINDIR)/$(CONFIG)/nonblocking_test || ( echo test nonblocking_test failed ; exit 1 ) $(E) "[RUN] Testing noop-benchmark" @@ -12120,38 +12121,6 @@ endif endif -MPMCQUEUE_TEST_SRC = \ - test/core/iomgr/mpmcqueue_test.cc \ - -MPMCQUEUE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(MPMCQUEUE_TEST_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/mpmcqueue_test: openssl_dep_error - -else - - - -$(BINDIR)/$(CONFIG)/mpmcqueue_test: $(MPMCQUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(MPMCQUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/mpmcqueue_test - -endif - -$(OBJDIR)/$(CONFIG)/test/core/iomgr/mpmcqueue_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a - -deps_mpmcqueue_test: $(MPMCQUEUE_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(MPMCQUEUE_TEST_OBJS:.o=.dep) -endif -endif - - MULTIPLE_SERVER_QUEUES_TEST_SRC = \ test/core/end2end/multiple_server_queues_test.cc \ @@ -17994,6 +17963,49 @@ endif endif +MPMCQUEUE_TEST_SRC = \ + test/core/iomgr/mpmcqueue_test.cc \ + +MPMCQUEUE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(MPMCQUEUE_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/mpmcqueue_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/mpmcqueue_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/mpmcqueue_test: $(PROTOBUF_DEP) $(MPMCQUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(MPMCQUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/mpmcqueue_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/core/iomgr/mpmcqueue_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_mpmcqueue_test: $(MPMCQUEUE_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(MPMCQUEUE_TEST_OBJS:.o=.dep) +endif +endif + + NONBLOCKING_TEST_SRC = \ test/cpp/end2end/nonblocking_test.cc \ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 2619ccf9740..fc9979f418e 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -158,6 +158,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/iomgr/tcp_server_windows.cc', 'src/core/lib/iomgr/tcp_uv.cc', 'src/core/lib/iomgr/tcp_windows.cc', + 'src/core/lib/iomgr/threadpool/mpmcqueue.cc', 'src/core/lib/iomgr/time_averaged_stats.cc', 'src/core/lib/iomgr/timer.cc', 'src/core/lib/iomgr/timer_custom.cc', diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 6860b8b42ef..3fad15ca046 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -1626,22 +1626,6 @@ "third_party": false, "type": "target" }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "mpmcqueue_test", - "src": [ - "test/core/iomgr/mpmcqueue_test.cc" - ], - "third_party": false, - "type": "target" - }, { "deps": [ "gpr", @@ -4311,6 +4295,24 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "grpc", + "grpc++", + "grpc++_test_util", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "mpmcqueue_test", + "src": [ + "test/core/iomgr/mpmcqueue_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 8a5d0a60e82..681d88fd483 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -1959,30 +1959,6 @@ ], "uses_polling": false }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": false, - "language": "c", - "name": "mpmcqueue_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "uses_polling": true - }, { "args": [], "benchmark": false, @@ -5021,6 +4997,30 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": false, + "language": "c++", + "name": "mpmcqueue_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": true + }, { "args": [], "benchmark": false, From e291396644248a677f86d5bfd8b8df5c19308abf Mon Sep 17 00:00:00 2001 From: yang-g Date: Mon, 17 Jun 2019 22:59:55 -0700 Subject: [PATCH 0566/1555] Cap deadline to 99999999 seconds on wire --- src/core/lib/transport/timeout_encoding.cc | 7 +++++++ src/core/lib/transport/timeout_encoding.h | 5 +++-- test/core/transport/timeout_encoding_test.cc | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/core/lib/transport/timeout_encoding.cc b/src/core/lib/transport/timeout_encoding.cc index fe22c15fa6d..26d4b4a426f 100644 --- a/src/core/lib/transport/timeout_encoding.cc +++ b/src/core/lib/transport/timeout_encoding.cc @@ -44,6 +44,9 @@ static int64_t round_up_to_three_sig_figs(int64_t x) { /* encode our minimum viable timeout value */ static void enc_tiny(char* buffer) { memcpy(buffer, "1n", 3); } +/* encode our maximum timeout value, about 1157 days */ +static void enc_huge(char* buffer) { memcpy(buffer, "99999999S", 10); } + static void enc_ext(char* buffer, int64_t value, char ext) { int n = int64_ttoa(value, buffer); buffer[n] = ext; @@ -51,6 +54,7 @@ static void enc_ext(char* buffer, int64_t value, char ext) { } static void enc_seconds(char* buffer, int64_t sec) { + sec = round_up_to_three_sig_figs(sec); if (sec % 3600 == 0) { enc_ext(buffer, sec / 3600, 'H'); } else if (sec % 60 == 0) { @@ -74,10 +78,13 @@ static void enc_millis(char* buffer, int64_t x) { } void grpc_http2_encode_timeout(grpc_millis timeout, char* buffer) { + const grpc_millis kMaxTimeout = 99999999000; if (timeout <= 0) { enc_tiny(buffer); } else if (timeout < 1000 * GPR_MS_PER_SEC) { enc_millis(buffer, timeout); + } else if (timeout >= kMaxTimeout) { + enc_huge(buffer); } else { enc_seconds(buffer, timeout / GPR_MS_PER_SEC + (timeout % GPR_MS_PER_SEC != 0)); diff --git a/src/core/lib/transport/timeout_encoding.h b/src/core/lib/transport/timeout_encoding.h index cc0d37452fd..c87ff39d491 100644 --- a/src/core/lib/transport/timeout_encoding.h +++ b/src/core/lib/transport/timeout_encoding.h @@ -27,10 +27,11 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/exec_ctx.h" -#define GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE (GPR_LTOA_MIN_BUFSIZE + 1) +#define GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE 10 /* Encode/decode timeouts to the GRPC over HTTP/2 format; - encoding may round up arbitrarily */ + encoding may round up arbitrarily. If the timeout is larger than about 1157 + days, it will be capped and "99999999S" will be sent on the wire. */ void grpc_http2_encode_timeout(grpc_millis timeout, char* buffer); int grpc_http2_decode_timeout(const grpc_slice& text, grpc_millis* timeout); diff --git a/test/core/transport/timeout_encoding_test.cc b/test/core/transport/timeout_encoding_test.cc index 22e68fe5540..61c3061d0c1 100644 --- a/test/core/transport/timeout_encoding_test.cc +++ b/test/core/transport/timeout_encoding_test.cc @@ -62,6 +62,9 @@ void test_encoding(void) { assert_encodes_as(20 * 60 * GPR_MS_PER_SEC, "20M"); assert_encodes_as(60 * 60 * GPR_MS_PER_SEC, "1H"); assert_encodes_as(10 * 60 * 60 * GPR_MS_PER_SEC, "10H"); + assert_encodes_as(60 * 60 * GPR_MS_PER_SEC - 100, "1H"); + assert_encodes_as(100 * 60 * 60 * GPR_MS_PER_SEC, "100H"); + assert_encodes_as(100000000000, "99999999S"); } static void assert_decodes_as(const char* buffer, grpc_millis expected) { From 61886e0d73ecadb4fddab664c9ea6c0d80ca88dc Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Tue, 18 Jun 2019 12:06:17 -0400 Subject: [PATCH 0567/1555] Eliminate a branch in Delete for grpc_core::UniquePtr. This is showing up in microbenchmarks in the StringView PR, becacuse strdup() retruns a grpc_core::UniquePtr now. Removing the branch lowers the difference. --- .../client_channel/lb_policy/grpclb/grpclb.cc | 4 +-- .../client_channel/lb_policy/xds/xds.cc | 4 +-- .../filters/client_channel/retry_throttle.h | 5 ++- src/core/lib/gprpp/memory.h | 35 ++++++++++++++----- src/core/lib/slice/slice_hash_table.h | 10 ++---- src/core/lib/slice/slice_weak_hash_table.h | 9 ++--- .../tsi/ssl/session_cache/ssl_session_cache.h | 9 ++--- 7 files changed, 37 insertions(+), 39 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index dad10f0ce86..886f0c59a7a 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -161,9 +161,7 @@ class GrpcLb : public LoadBalancingPolicy { bool seen_serverlist() const { return seen_serverlist_; } private: - // So Delete() can access our private dtor. - template - friend void grpc_core::Delete(T*); + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE ~BalancerCallState(); diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index ca6ab216515..c67fe6c1b20 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -185,9 +185,7 @@ class XdsLb : public LoadBalancingPolicy { bool seen_initial_response() const { return seen_initial_response_; } private: - // So Delete() can access our private dtor. - template - friend void grpc_core::Delete(T*); + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE ~BalancerCallState(); diff --git a/src/core/ext/filters/client_channel/retry_throttle.h b/src/core/ext/filters/client_channel/retry_throttle.h index fddafcd903e..9e2fff56d24 100644 --- a/src/core/ext/filters/client_channel/retry_throttle.h +++ b/src/core/ext/filters/client_channel/retry_throttle.h @@ -21,6 +21,7 @@ #include +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/ref_counted.h" namespace grpc_core { @@ -42,9 +43,7 @@ class ServerRetryThrottleData : public RefCounted { intptr_t milli_token_ratio() const { return milli_token_ratio_; } private: - // So Delete() can call our private dtor. - template - friend void grpc_core::Delete(T*); + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE ~ServerRetryThrottleData(); diff --git a/src/core/lib/gprpp/memory.h b/src/core/lib/gprpp/memory.h index 70ad430c51d..2e7658e4866 100644 --- a/src/core/lib/gprpp/memory.h +++ b/src/core/lib/gprpp/memory.h @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -29,14 +30,17 @@ // Add this to a class that want to use Delete(), but has a private or // protected destructor. -#define GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE \ - template \ - friend void grpc_core::Delete(T*); +#define GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE \ + template \ + friend void ::grpc_core::Delete(_Delete_T*); \ + template \ + friend void ::grpc_core::Delete(_Delete_T*); + // Add this to a class that want to use New(), but has a private or // protected constructor. -#define GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW \ - template \ - friend T* grpc_core::New(Args&&...); +#define GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW \ + template \ + friend _New_T* grpc_core::New(_New_Args&&...); namespace grpc_core { @@ -48,17 +52,30 @@ inline T* New(Args&&... args) { } // Alternative to delete, since we cannot use it (for fear of libstdc++) -template +// We cannot add a default value for can_be_null, because they are used as +// as friend template methods where we cannot define a default value. +// Instead we simply define two variants, one with and one without the boolean +// argument. +template inline void Delete(T* p) { - if (p == nullptr) return; + GPR_DEBUG_ASSERT(can_be_null || p != nullptr); + if (can_be_null && p == nullptr) return; p->~T(); gpr_free(p); } +template +inline void Delete(T* p) { + Delete(p); +} template class DefaultDelete { public: - void operator()(T* p) { Delete(p); } + void operator()(T* p) { + // std::unique_ptr is gauranteed not to call the deleter + // if the pointer is nullptr. + Delete(p); + } }; template > diff --git a/src/core/lib/slice/slice_hash_table.h b/src/core/lib/slice/slice_hash_table.h index c20eca9db77..bd003c2c5b4 100644 --- a/src/core/lib/slice/slice_hash_table.h +++ b/src/core/lib/slice/slice_hash_table.h @@ -25,6 +25,7 @@ #include #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/slice/slice_internal.h" @@ -77,13 +78,8 @@ class SliceHashTable : public RefCounted> { static int Cmp(const SliceHashTable& a, const SliceHashTable& b); private: - // So New() can call our private ctor. - template - friend T2* New(Args&&... args); - - // So Delete() can call our private dtor. - template - friend void Delete(T2*); + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW SliceHashTable(size_t num_entries, Entry* entries, ValueCmp value_cmp); virtual ~SliceHashTable(); diff --git a/src/core/lib/slice/slice_weak_hash_table.h b/src/core/lib/slice/slice_weak_hash_table.h index 8c5562bf196..bd59a4c2e48 100644 --- a/src/core/lib/slice/slice_weak_hash_table.h +++ b/src/core/lib/slice/slice_weak_hash_table.h @@ -61,13 +61,8 @@ class SliceWeakHashTable : public RefCounted> { } private: - // So New() can call our private ctor. - template - friend T2* New(Args&&... args); - - // So Delete() can call our private dtor. - template - friend void Delete(T2*); + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE SliceWeakHashTable() = default; ~SliceWeakHashTable() = default; diff --git a/src/core/tsi/ssl/session_cache/ssl_session_cache.h b/src/core/tsi/ssl/session_cache/ssl_session_cache.h index 37fa2d124c9..16ab97714a7 100644 --- a/src/core/tsi/ssl/session_cache/ssl_session_cache.h +++ b/src/core/tsi/ssl/session_cache/ssl_session_cache.h @@ -67,13 +67,8 @@ class SslSessionLRUCache : public grpc_core::RefCounted { SslSessionPtr Get(const char* key); private: - // So New() can call our private ctor. - template - friend T* grpc_core::New(Args&&... args); - - // So Delete() can call our private dtor. - template - friend void grpc_core::Delete(T*); + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW + GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE class Node; From e5de1e5e254c00c912032eef86399e2c911771fc Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 18 Jun 2019 10:12:41 -0700 Subject: [PATCH 0568/1555] Update global interceptor comment and raise exception --- src/objective-c/GRPCClient/GRPCCall+Interceptor.h | 11 +++++++++-- src/objective-c/GRPCClient/GRPCCall+Interceptor.m | 10 ++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall+Interceptor.h b/src/objective-c/GRPCClient/GRPCCall+Interceptor.h index 4183e0aa20e..e6da2a7bda4 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Interceptor.h +++ b/src/objective-c/GRPCClient/GRPCCall+Interceptor.h @@ -24,8 +24,15 @@ @interface GRPCCall2 (Interceptor) -+ (void)registerGlobalInterceptor:(id)interceptorFactory; +/** + * Register a global interceptor's factory in the current process. Only one interceptor can be + * registered in a process. If another one attempts to be registered, an exception will be raised. + */ ++ (void)registerGlobalInterceptor:(nonnull id)interceptorFactory; -+ (id)globalInterceptorFactory; +/** + * Get the global interceptor's factory. + */ ++ (nullable id)globalInterceptorFactory; @end diff --git a/src/objective-c/GRPCClient/GRPCCall+Interceptor.m b/src/objective-c/GRPCClient/GRPCCall+Interceptor.m index b1cad75d4f3..eed402f9c7e 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Interceptor.m +++ b/src/objective-c/GRPCClient/GRPCCall+Interceptor.m @@ -26,18 +26,16 @@ static dispatch_once_t onceToken; @implementation GRPCCall2 (Interceptor) + (void)registerGlobalInterceptor:(id)interceptorFactory { + if (interceptorFactory == nil) { + return; + } dispatch_once(&onceToken, ^{ globalInterceptorLock = [[NSLock alloc] init]; }); [globalInterceptorLock lock]; - NSAssert(globalInterceptorFactory == nil, - @"Global interceptor is already registered. Only one global interceptor can be " - @"registered in a process"); if (globalInterceptorFactory != nil) { - NSLog( - @"Global interceptor is already registered. Only one global interceptor can be registered " - @"in a process"); [globalInterceptorLock unlock]; + [NSException raise:NSInternalInconsistencyException format:@"Global interceptor is already registered. Only one global interceptor can be registered in a process."]; return; } From a9ad58e0374ab83b511c6be5be45ae7f75f74b95 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 18 Jun 2019 10:13:13 -0700 Subject: [PATCH 0569/1555] Fix global interceptor tests --- src/objective-c/GRPCClient/GRPCCall.m | 48 +++---- .../tests/InteropTests/InteropTests.m | 133 ++++++++++++++---- 2 files changed, 125 insertions(+), 56 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 5280f8d01f4..c25e8daaf4c 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -155,11 +155,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; [[GRPCInterceptorManager alloc] initWithNextInterceptor:nextInterceptor]; GRPCInterceptor *interceptor = [globalInterceptorFactory createInterceptorWithManager:manager]; - NSAssert(interceptor != nil, @"Failed to create interceptor from factory: %@", - globalInterceptorFactory); - if (interceptor == nil) { - NSLog(@"Failed to create interceptor from factory: %@", globalInterceptorFactory); - } else { + if (interceptor != nil) { [internalCall setResponseHandler:interceptor]; nextInterceptor = interceptor; nextManager = manager; @@ -168,35 +164,31 @@ const char *kCFStreamVarName = "grpc_cfstream"; // Finally initialize the interceptors in the chain NSArray *interceptorFactories = _actualCallOptions.interceptorFactories; - if (interceptorFactories.count == 0) { + for (int i = (int)interceptorFactories.count - 1; i >= 0; i--) { + GRPCInterceptorManager *manager = + [[GRPCInterceptorManager alloc] initWithNextInterceptor:nextInterceptor]; + GRPCInterceptor *interceptor = + [interceptorFactories[i] createInterceptorWithManager:manager]; + NSAssert(interceptor != nil, @"Failed to create interceptor from factory: %@", + interceptorFactories[i]); + if (interceptor == nil) { + NSLog(@"Failed to create interceptor from factory: %@", interceptorFactories[i]); + continue; + } if (nextManager == nil) { - [internalCall setResponseHandler:_responseHandler]; + [internalCall setResponseHandler:interceptor]; } else { - [nextManager setPreviousInterceptor:_responseHandler]; + [nextManager setPreviousInterceptor:interceptor]; } + nextInterceptor = interceptor; + nextManager = manager; + } + if (nextManager == nil) { + [internalCall setResponseHandler:_responseHandler]; } else { - for (int i = (int)interceptorFactories.count - 1; i >= 0; i--) { - GRPCInterceptorManager *manager = - [[GRPCInterceptorManager alloc] initWithNextInterceptor:nextInterceptor]; - GRPCInterceptor *interceptor = - [interceptorFactories[i] createInterceptorWithManager:manager]; - NSAssert(interceptor != nil, @"Failed to create interceptor from factory: %@", - interceptorFactories[i]); - if (interceptor == nil) { - NSLog(@"Failed to create interceptor from factory: %@", interceptorFactories[i]); - continue; - } - if (nextManager == nil) { - [internalCall setResponseHandler:interceptor]; - } else { - [nextManager setPreviousInterceptor:interceptor]; - } - nextInterceptor = interceptor; - nextManager = manager; - } - [nextManager setPreviousInterceptor:_responseHandler]; } + _firstInterceptor = nextInterceptor; } diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 2c54fb80f3d..235fcaed483 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -121,7 +121,7 @@ initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue @end -@interface HookIntercetpor : GRPCInterceptor +@interface HookInterceptor : GRPCInterceptor - (instancetype) initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager @@ -144,6 +144,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager @end @implementation HookInterceptorFactory { +@protected void (^_startHook)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager); void (^_writeDataHook)(id data, GRPCInterceptorManager *manager); @@ -190,7 +191,7 @@ initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue } - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { - return [[HookIntercetpor alloc] initWithInterceptorManager:interceptorManager + return [[HookInterceptor alloc] initWithInterceptorManager:interceptorManager requestDispatchQueue:_requestDispatchQueue responseDispatchQueue:_responseDispatchQueue startHook:_startHook @@ -205,7 +206,7 @@ initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue @end -@implementation HookIntercetpor { +@implementation HookInterceptor { void (^_startHook)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager); void (^_writeDataHook)(id data, GRPCInterceptorManager *manager); @@ -315,6 +316,92 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager @end +@interface GlobalInterceptorFactory : HookInterceptorFactory + +@property BOOL enabled; + +- (instancetype)initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue + responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue; + +- (void)setStartHook:(void (^)(GRPCRequestOptions *requestOptions, + GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager))startHook + writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook + finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook +receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, + GRPCInterceptorManager *manager))receiveNextMessagesHook + responseHeaderHook:(void (^)(NSDictionary *initialMetadata, + GRPCInterceptorManager *manager))responseHeaderHook + responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook + responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager))responseCloseHook + didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook; + +@end + +@implementation GlobalInterceptorFactory + +- (instancetype)initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue + responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue { + _enabled = NO; + return [super initWithRequestDispatchQueue:requestDispatchQueue + responseDispatchQueue:responseDispatchQueue + startHook:nil + writeDataHook:nil + finishHook:nil + receiveNextMessagesHook:nil + responseHeaderHook:nil + responseDataHook:nil + responseCloseHook:nil + didWriteDataHook:nil]; +} + +- (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { + if (_enabled) { + return [[HookInterceptor alloc] initWithInterceptorManager:interceptorManager + requestDispatchQueue:_requestDispatchQueue + responseDispatchQueue:_responseDispatchQueue + startHook:_startHook + writeDataHook:_writeDataHook + finishHook:_finishHook + receiveNextMessagesHook:_receiveNextMessagesHook + responseHeaderHook:_responseHeaderHook + responseDataHook:_responseDataHook + responseCloseHook:_responseCloseHook + didWriteDataHook:_didWriteDataHook]; + } else { + return nil; + } +} + +- (void)setStartHook:(void (^)(GRPCRequestOptions *requestOptions, + GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager))startHook + writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook + finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook +receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, + GRPCInterceptorManager *manager))receiveNextMessagesHook + responseHeaderHook:(void (^)(NSDictionary *initialMetadata, + GRPCInterceptorManager *manager))responseHeaderHook + responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook + responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager))responseCloseHook + didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { + _startHook = startHook; + _writeDataHook = writeDataHook; + _finishHook = finishHook; + _receiveNextMessagesHook = receiveNextMessagesHook; + _responseHeaderHook = responseHeaderHook; + _responseDataHook = responseDataHook; + _responseCloseHook = responseCloseHook; + _didWriteDataHook = didWriteDataHook; +} + +@end + +static GlobalInterceptorFactory *globalInterceptorFactory = nil; +static dispatch_once_t initGlobalInterceptorFactory; + #pragma mark Tests @implementation InteropTests { @@ -358,6 +445,13 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager #ifdef GRPC_CFSTREAM setenv(kCFStreamVarName, "1", 1); #endif + + dispatch_once(&initGlobalInterceptorFactory, ^{ + dispatch_queue_t globalInterceptorQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); + globalInterceptorFactory = [[GlobalInterceptorFactory alloc] initWithRequestDispatchQueue:globalInterceptorQueue + responseDispatchQueue:globalInterceptorQueue]; + [GRPCCall2 registerGlobalInterceptor:globalInterceptorFactory]; + }); } - (void)setUp { @@ -1531,10 +1625,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager __block NSUInteger responseDataCount = 0; __block NSUInteger responseCloseCount = 0; __block NSUInteger didWriteDataCount = 0; - id factory = [[HookInterceptorFactory alloc] - initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, + [globalInterceptorFactory setStartHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager) { startCount++; XCTAssertEqualObjects(requestOptions.host, [[self class] host]); @@ -1585,7 +1676,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.flowControlEnabled = YES; - [GRPCCall2 registerGlobalInterceptor:factory]; + globalInterceptorFactory.enabled = YES; __block BOOL canWriteData = NO; __block GRPCStreamingProtoCall *call = [_service @@ -1631,6 +1722,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager XCTAssertEqual(responseDataCount, 4); XCTAssertEqual(responseCloseCount, 1); XCTAssertEqual(didWriteDataCount, 4); + globalInterceptorFactory.enabled = NO; } - (void)testConflictingGlobalInterceptors { @@ -1645,24 +1737,11 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager responseDataHook:nil responseCloseHook:nil didWriteDataHook:nil]; - id factory2 = [[HookInterceptorFactory alloc] - initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - startHook:nil - writeDataHook:nil - finishHook:nil - receiveNextMessagesHook:nil - responseHeaderHook:nil - responseDataHook:nil - responseCloseHook:nil - didWriteDataHook:nil]; - - [GRPCCall2 registerGlobalInterceptor:factory]; @try { - [GRPCCall2 registerGlobalInterceptor:factory2]; + [GRPCCall2 registerGlobalInterceptor:factory]; XCTFail(@"Did not receive an exception when registering global interceptor the second time"); } @catch (NSException *exception) { - NSLog(@"Received exception as expected: %@", exception); + // Do nothing; test passes } } @@ -1731,10 +1810,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager __block NSUInteger globalResponseCloseCount = 0; __block NSUInteger globalDidWriteDataCount = 0; - id globalFactory = [[HookInterceptorFactory alloc] - initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, + [globalInterceptorFactory setStartHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager) { globalStartCount++; XCTAssertEqualObjects(requestOptions.host, [[self class] host]); @@ -1786,7 +1862,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager options.hostNameOverride = [[self class] hostNameOverride]; options.flowControlEnabled = YES; options.interceptorFactories = @[ factory ]; - [GRPCCall2 registerGlobalInterceptor:globalFactory]; + globalInterceptorFactory.enabled = YES; __block BOOL canWriteData = NO; __block GRPCStreamingProtoCall *call = [_service @@ -1834,6 +1910,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager XCTAssertEqual(globalResponseDataCount, 4); XCTAssertEqual(globalResponseCloseCount, 1); XCTAssertEqual(globalDidWriteDataCount, 4); + globalInterceptorFactory.enabled = NO; } @end From 7f327f1ca7b0bb2e744a9a198d8c4c6038772ccb Mon Sep 17 00:00:00 2001 From: yang-g Date: Tue, 18 Jun 2019 10:33:02 -0700 Subject: [PATCH 0570/1555] Relax csharp deadline test --- src/csharp/Grpc.Core.Tests/ContextPropagationTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/ContextPropagationTest.cs b/src/csharp/Grpc.Core.Tests/ContextPropagationTest.cs index 4158579194f..097db777a30 100644 --- a/src/csharp/Grpc.Core.Tests/ContextPropagationTest.cs +++ b/src/csharp/Grpc.Core.Tests/ContextPropagationTest.cs @@ -108,8 +108,8 @@ namespace Grpc.Core.Tests var deadline = DateTime.UtcNow.AddDays(7); helper.UnaryHandler = new UnaryServerMethod((request, context) => { - Assert.IsTrue(context.Deadline < deadline.AddMinutes(1)); - Assert.IsTrue(context.Deadline > deadline.AddMinutes(-1)); + Assert.IsTrue(context.Deadline < deadline.AddHours(1)); + Assert.IsTrue(context.Deadline > deadline.AddHours(-1)); return Task.FromResult("PASS"); }); From 6124a835d4b130f385e57e1e5b7840ed6766959b Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 18 Jun 2019 09:33:05 -0700 Subject: [PATCH 0571/1555] Revert "Hide ConnectedSubchannel from LB policy API." --- .../filters/client_channel/client_channel.cc | 420 +++++------------- .../ext/filters/client_channel/lb_policy.h | 2 +- .../client_channel/lb_policy/grpclb/grpclb.cc | 9 +- .../lb_policy/pick_first/pick_first.cc | 30 +- .../lb_policy/round_robin/round_robin.cc | 20 +- .../lb_policy/subchannel_list.h | 126 ++++-- .../client_channel/lb_policy/xds/xds.cc | 2 +- .../ext/filters/client_channel/subchannel.cc | 23 +- .../ext/filters/client_channel/subchannel.h | 71 +-- .../client_channel/subchannel_interface.h | 45 +- src/core/lib/gprpp/map.h | 28 -- src/core/lib/transport/metadata.cc | 5 - test/core/gprpp/map_test.cc | 29 -- test/core/util/test_lb_policies.cc | 2 +- 14 files changed, 298 insertions(+), 514 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index a67792fcd37..0b612e67a33 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -147,9 +147,6 @@ class ChannelData { return service_config_; } - RefCountedPtr GetConnectedSubchannelInDataPlane( - SubchannelInterface* subchannel) const; - grpc_connectivity_state CheckConnectivityState(bool try_to_connect); void AddExternalConnectivityWatcher(grpc_polling_entity pollent, grpc_connectivity_state* state, @@ -164,9 +161,9 @@ class ChannelData { } private: - class SubchannelWrapper; class ConnectivityStateAndPickerSetter; class ServiceConfigSetter; + class GrpcSubchannel; class ClientChannelControlHelper; class ExternalConnectivityWatcher { @@ -265,14 +262,7 @@ class ChannelData { UniquePtr health_check_service_name_; RefCountedPtr saved_service_config_; bool received_first_resolver_result_ = false; - // The number of SubchannelWrapper instances referencing a given Subchannel. Map subchannel_refcount_map_; - // Pending ConnectedSubchannel updates for each SubchannelWrapper. - // Updates are queued here in the control plane combiner and then applied - // in the data plane combiner when the picker is updated. - Map, RefCountedPtr, - RefCountedPtrLess> - pending_subchannel_updates_; // // Fields accessed from both data plane and control plane combiners. @@ -716,247 +706,6 @@ class CallData { grpc_metadata_batch send_trailing_metadata_; }; -// -// ChannelData::SubchannelWrapper -// - -// This class is a wrapper for Subchannel that hides details of the -// channel's implementation (such as the health check service name and -// connected subchannel) from the LB policy API. -// -// Note that no synchronization is needed here, because even if the -// underlying subchannel is shared between channels, this wrapper will only -// be used within one channel, so it will always be synchronized by the -// control plane combiner. -class ChannelData::SubchannelWrapper : public SubchannelInterface { - public: - SubchannelWrapper(ChannelData* chand, Subchannel* subchannel, - UniquePtr health_check_service_name) - : SubchannelInterface(&grpc_client_channel_routing_trace), - chand_(chand), - subchannel_(subchannel), - health_check_service_name_(std::move(health_check_service_name)) { - if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { - gpr_log(GPR_INFO, - "chand=%p: creating subchannel wrapper %p for subchannel %p", - chand, this, subchannel_); - } - GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "SubchannelWrapper"); - auto* subchannel_node = subchannel_->channelz_node(); - if (subchannel_node != nullptr) { - intptr_t subchannel_uuid = subchannel_node->uuid(); - auto it = chand_->subchannel_refcount_map_.find(subchannel_); - if (it == chand_->subchannel_refcount_map_.end()) { - chand_->channelz_node_->AddChildSubchannel(subchannel_uuid); - it = chand_->subchannel_refcount_map_.emplace(subchannel_, 0).first; - } - ++it->second; - } - } - - ~SubchannelWrapper() { - if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { - gpr_log(GPR_INFO, - "chand=%p: destroying subchannel wrapper %p for subchannel %p", - chand_, this, subchannel_); - } - auto* subchannel_node = subchannel_->channelz_node(); - if (subchannel_node != nullptr) { - intptr_t subchannel_uuid = subchannel_node->uuid(); - auto it = chand_->subchannel_refcount_map_.find(subchannel_); - GPR_ASSERT(it != chand_->subchannel_refcount_map_.end()); - --it->second; - if (it->second == 0) { - chand_->channelz_node_->RemoveChildSubchannel(subchannel_uuid); - chand_->subchannel_refcount_map_.erase(it); - } - } - GRPC_SUBCHANNEL_UNREF(subchannel_, "unref from LB"); - GRPC_CHANNEL_STACK_UNREF(chand_->owning_stack_, "SubchannelWrapper"); - } - - grpc_connectivity_state CheckConnectivityState() override { - RefCountedPtr connected_subchannel; - grpc_connectivity_state connectivity_state = - subchannel_->CheckConnectivityState(health_check_service_name_.get(), - &connected_subchannel); - MaybeUpdateConnectedSubchannel(std::move(connected_subchannel)); - return connectivity_state; - } - - void WatchConnectivityState( - grpc_connectivity_state initial_state, - UniquePtr watcher) override { - auto& watcher_wrapper = watcher_map_[watcher.get()]; - GPR_ASSERT(watcher_wrapper == nullptr); - watcher_wrapper = New( - std::move(watcher), Ref(DEBUG_LOCATION, "WatcherWrapper")); - subchannel_->WatchConnectivityState( - initial_state, - UniquePtr(gpr_strdup(health_check_service_name_.get())), - OrphanablePtr( - watcher_wrapper)); - } - - void CancelConnectivityStateWatch( - ConnectivityStateWatcherInterface* watcher) override { - auto it = watcher_map_.find(watcher); - GPR_ASSERT(it != watcher_map_.end()); - subchannel_->CancelConnectivityStateWatch(health_check_service_name_.get(), - it->second); - watcher_map_.erase(it); - } - - void AttemptToConnect() override { subchannel_->AttemptToConnect(); } - - void ResetBackoff() override { subchannel_->ResetBackoff(); } - - const grpc_channel_args* channel_args() override { - return subchannel_->channel_args(); - } - - // Caller must be holding the control-plane combiner. - ConnectedSubchannel* connected_subchannel() const { - return connected_subchannel_.get(); - } - - // Caller must be holding the data-plane combiner. - ConnectedSubchannel* connected_subchannel_in_data_plane() const { - return connected_subchannel_in_data_plane_.get(); - } - void set_connected_subchannel_in_data_plane( - RefCountedPtr connected_subchannel) { - connected_subchannel_in_data_plane_ = std::move(connected_subchannel); - } - - private: - // Subchannel and SubchannelInterface have different interfaces for - // their respective ConnectivityStateWatcherInterface classes. - // The one in Subchannel updates the ConnectedSubchannel along with - // the state, whereas the one in SubchannelInterface does not expose - // the ConnectedSubchannel. - // - // This wrapper provides a bridge between the two. It implements - // Subchannel::ConnectivityStateWatcherInterface and wraps - // the instance of SubchannelInterface::ConnectivityStateWatcherInterface - // that was passed in by the LB policy. We pass an instance of this - // class to the underlying Subchannel, and when we get updates from - // the subchannel, we pass those on to the wrapped watcher to return - // the update to the LB policy. This allows us to set the connected - // subchannel before passing the result back to the LB policy. - class WatcherWrapper : public Subchannel::ConnectivityStateWatcherInterface { - public: - WatcherWrapper( - UniquePtr - watcher, - RefCountedPtr parent) - : watcher_(std::move(watcher)), parent_(std::move(parent)) {} - - ~WatcherWrapper() { parent_.reset(DEBUG_LOCATION, "WatcherWrapper"); } - - void Orphan() override { Unref(); } - - void OnConnectivityStateChange( - grpc_connectivity_state new_state, - RefCountedPtr connected_subchannel) override { - if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { - gpr_log(GPR_INFO, - "chand=%p: connectivity change for subchannel wrapper %p " - "subchannel %p (connected_subchannel=%p state=%s); " - "hopping into combiner", - parent_->chand_, parent_.get(), parent_->subchannel_, - connected_subchannel.get(), - grpc_connectivity_state_name(new_state)); - } - // Will delete itself. - New(Ref(), new_state, std::move(connected_subchannel)); - } - - grpc_pollset_set* interested_parties() override { - return watcher_->interested_parties(); - } - - private: - class Updater { - public: - Updater(RefCountedPtr parent, - grpc_connectivity_state new_state, - RefCountedPtr connected_subchannel) - : parent_(std::move(parent)), - state_(new_state), - connected_subchannel_(std::move(connected_subchannel)) { - GRPC_CLOSURE_INIT( - &closure_, ApplyUpdateInControlPlaneCombiner, this, - grpc_combiner_scheduler(parent_->parent_->chand_->combiner_)); - GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE); - } - - private: - static void ApplyUpdateInControlPlaneCombiner(void* arg, - grpc_error* error) { - Updater* self = static_cast(arg); - if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { - gpr_log(GPR_INFO, - "chand=%p: processing connectivity change in combiner " - "for subchannel wrapper %p subchannel %p " - "(connected_subchannel=%p state=%s)", - self->parent_->parent_->chand_, self->parent_->parent_.get(), - self->parent_->parent_->subchannel_, - self->connected_subchannel_.get(), - grpc_connectivity_state_name(self->state_)); - } - self->parent_->parent_->MaybeUpdateConnectedSubchannel( - std::move(self->connected_subchannel_)); - self->parent_->watcher_->OnConnectivityStateChange(self->state_); - Delete(self); - } - - RefCountedPtr parent_; - grpc_connectivity_state state_; - RefCountedPtr connected_subchannel_; - grpc_closure closure_; - }; - - UniquePtr watcher_; - RefCountedPtr parent_; - }; - - void MaybeUpdateConnectedSubchannel( - RefCountedPtr connected_subchannel) { - // Update the connected subchannel only if the channel is not shutting - // down. This is because once the channel is shutting down, we - // ignore picker updates from the LB policy, which means that - // ConnectivityStateAndPickerSetter will never process the entries - // in chand_->pending_subchannel_updates_. So we don't want to add - // entries there that will never be processed, since that would - // leave dangling refs to the channel and prevent its destruction. - grpc_error* disconnect_error = chand_->disconnect_error(); - if (disconnect_error != GRPC_ERROR_NONE) return; - // Not shutting down, so do the update. - if (connected_subchannel_ != connected_subchannel) { - connected_subchannel_ = std::move(connected_subchannel); - // Record the new connected subchannel so that it can be updated - // in the data plane combiner the next time the picker is updated. - chand_->pending_subchannel_updates_[Ref( - DEBUG_LOCATION, "ConnectedSubchannelUpdate")] = connected_subchannel_; - } - } - - ChannelData* chand_; - Subchannel* subchannel_; - UniquePtr health_check_service_name_; - // Maps from the address of the watcher passed to us by the LB policy - // to the address of the WrapperWatcher that we passed to the underlying - // subchannel. This is needed so that when the LB policy calls - // CancelConnectivityStateWatch() with its watcher, we know the - // corresponding WrapperWatcher to cancel on the underlying subchannel. - Map watcher_map_; - // To be accessed only in the control plane combiner. - RefCountedPtr connected_subchannel_; - // To be accessed only in the data plane combiner. - RefCountedPtr connected_subchannel_in_data_plane_; -}; - // // ChannelData::ConnectivityStateAndPickerSetter // @@ -980,13 +729,10 @@ class ChannelData::ConnectivityStateAndPickerSetter { grpc_slice_from_static_string( GetChannelConnectivityStateChangeString(state))); } - // Grab any pending subchannel updates. - pending_subchannel_updates_ = - std::move(chand_->pending_subchannel_updates_); // Bounce into the data plane combiner to reset the picker. GRPC_CHANNEL_STACK_REF(chand->owning_stack_, "ConnectivityStateAndPickerSetter"); - GRPC_CLOSURE_INIT(&closure_, SetPickerInDataPlane, this, + GRPC_CLOSURE_INIT(&closure_, SetPicker, this, grpc_combiner_scheduler(chand->data_plane_combiner_)); GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE); } @@ -1009,38 +755,16 @@ class ChannelData::ConnectivityStateAndPickerSetter { GPR_UNREACHABLE_CODE(return "UNKNOWN"); } - static void SetPickerInDataPlane(void* arg, grpc_error* ignored) { + static void SetPicker(void* arg, grpc_error* ignored) { auto* self = static_cast(arg); - // Handle subchannel updates. - for (auto& p : self->pending_subchannel_updates_) { - if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { - gpr_log(GPR_INFO, - "chand=%p: updating subchannel wrapper %p data plane " - "connected_subchannel to %p", - self->chand_, p.first.get(), p.second.get()); - } - p.first->set_connected_subchannel_in_data_plane(std::move(p.second)); - } - // Swap out the picker. We hang on to the old picker so that it can - // be deleted in the control-plane combiner, since that's where we need - // to unref the subchannel wrappers that are reffed by the picker. - self->picker_.swap(self->chand_->picker_); + // Update picker. + self->chand_->picker_ = std::move(self->picker_); // Re-process queued picks. for (QueuedPick* pick = self->chand_->queued_picks_; pick != nullptr; pick = pick->next) { CallData::StartPickLocked(pick->elem, GRPC_ERROR_NONE); } - // Pop back into the control plane combiner to delete ourself, so - // that we make sure to unref subchannel wrappers there. This - // includes both the ones reffed by the old picker (now stored in - // self->picker_) and the ones in self->pending_subchannel_updates_. - GRPC_CLOSURE_INIT(&self->closure_, CleanUpInControlPlane, self, - grpc_combiner_scheduler(self->chand_->combiner_)); - GRPC_CLOSURE_SCHED(&self->closure_, GRPC_ERROR_NONE); - } - - static void CleanUpInControlPlane(void* arg, grpc_error* ignored) { - auto* self = static_cast(arg); + // Clean up. GRPC_CHANNEL_STACK_UNREF(self->chand_->owning_stack_, "ConnectivityStateAndPickerSetter"); Delete(self); @@ -1048,9 +772,6 @@ class ChannelData::ConnectivityStateAndPickerSetter { ChannelData* chand_; UniquePtr picker_; - Map, RefCountedPtr, - RefCountedPtrLess> - pending_subchannel_updates_; grpc_closure closure_; }; @@ -1225,6 +946,89 @@ void ChannelData::ExternalConnectivityWatcher::WatchConnectivityStateLocked( &self->chand_->state_tracker_, self->state_, &self->my_closure_); } +// +// ChannelData::GrpcSubchannel +// + +// This class is a wrapper for Subchannel that hides details of the +// channel's implementation (such as the health check service name) from +// the LB policy API. +// +// Note that no synchronization is needed here, because even if the +// underlying subchannel is shared between channels, this wrapper will only +// be used within one channel, so it will always be synchronized by the +// control plane combiner. +class ChannelData::GrpcSubchannel : public SubchannelInterface { + public: + GrpcSubchannel(ChannelData* chand, Subchannel* subchannel, + UniquePtr health_check_service_name) + : chand_(chand), + subchannel_(subchannel), + health_check_service_name_(std::move(health_check_service_name)) { + GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "GrpcSubchannel"); + auto* subchannel_node = subchannel_->channelz_node(); + if (subchannel_node != nullptr) { + intptr_t subchannel_uuid = subchannel_node->uuid(); + auto it = chand_->subchannel_refcount_map_.find(subchannel_); + if (it == chand_->subchannel_refcount_map_.end()) { + chand_->channelz_node_->AddChildSubchannel(subchannel_uuid); + it = chand_->subchannel_refcount_map_.emplace(subchannel_, 0).first; + } + ++it->second; + } + } + + ~GrpcSubchannel() { + auto* subchannel_node = subchannel_->channelz_node(); + if (subchannel_node != nullptr) { + intptr_t subchannel_uuid = subchannel_node->uuid(); + auto it = chand_->subchannel_refcount_map_.find(subchannel_); + GPR_ASSERT(it != chand_->subchannel_refcount_map_.end()); + --it->second; + if (it->second == 0) { + chand_->channelz_node_->RemoveChildSubchannel(subchannel_uuid); + chand_->subchannel_refcount_map_.erase(it); + } + } + GRPC_SUBCHANNEL_UNREF(subchannel_, "unref from LB"); + GRPC_CHANNEL_STACK_UNREF(chand_->owning_stack_, "GrpcSubchannel"); + } + + grpc_connectivity_state CheckConnectivityState( + RefCountedPtr* connected_subchannel) + override { + RefCountedPtr tmp; + auto retval = subchannel_->CheckConnectivityState( + health_check_service_name_.get(), &tmp); + *connected_subchannel = std::move(tmp); + return retval; + } + + void WatchConnectivityState( + grpc_connectivity_state initial_state, + UniquePtr watcher) override { + subchannel_->WatchConnectivityState( + initial_state, + UniquePtr(gpr_strdup(health_check_service_name_.get())), + std::move(watcher)); + } + + void CancelConnectivityStateWatch( + ConnectivityStateWatcher* watcher) override { + subchannel_->CancelConnectivityStateWatch(health_check_service_name_.get(), + watcher); + } + + void AttemptToConnect() override { subchannel_->AttemptToConnect(); } + + void ResetBackoff() override { subchannel_->ResetBackoff(); } + + private: + ChannelData* chand_; + Subchannel* subchannel_; + UniquePtr health_check_service_name_; +}; + // // ChannelData::ClientChannelControlHelper // @@ -1262,8 +1066,8 @@ class ChannelData::ClientChannelControlHelper chand_->client_channel_factory_->CreateSubchannel(new_args); grpc_channel_args_destroy(new_args); if (subchannel == nullptr) return nullptr; - return MakeRefCounted( - chand_, subchannel, std::move(health_check_service_name)); + return MakeRefCounted(chand_, subchannel, + std::move(health_check_service_name)); } grpc_channel* CreateChannel(const char* target, @@ -1274,7 +1078,8 @@ class ChannelData::ClientChannelControlHelper void UpdateState( grpc_connectivity_state state, UniquePtr picker) override { - grpc_error* disconnect_error = chand_->disconnect_error(); + grpc_error* disconnect_error = + chand_->disconnect_error_.Load(MemoryOrder::ACQUIRE); if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { const char* extra = disconnect_error == GRPC_ERROR_NONE ? "" @@ -1646,13 +1451,9 @@ grpc_error* ChannelData::DoPingLocked(grpc_transport_op* op) { } LoadBalancingPolicy::PickResult result = picker_->Pick(LoadBalancingPolicy::PickArgs()); - ConnectedSubchannel* connected_subchannel = nullptr; - if (result.subchannel != nullptr) { - SubchannelWrapper* subchannel = - static_cast(result.subchannel.get()); - connected_subchannel = subchannel->connected_subchannel(); - } - if (connected_subchannel != nullptr) { + if (result.connected_subchannel != nullptr) { + ConnectedSubchannel* connected_subchannel = + static_cast(result.connected_subchannel.get()); connected_subchannel->Ping(op->send_ping.on_initiate, op->send_ping.on_ack); } else { if (result.error == GRPC_ERROR_NONE) { @@ -1695,10 +1496,6 @@ void ChannelData::StartTransportOpLocked(void* arg, grpc_error* ignored) { } // Disconnect. if (op->disconnect_with_error != GRPC_ERROR_NONE) { - if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) { - gpr_log(GPR_INFO, "chand=%p: channel shut down from API: %s", chand, - grpc_error_string(op->disconnect_with_error)); - } grpc_error* error = GRPC_ERROR_NONE; GPR_ASSERT(chand->disconnect_error_.CompareExchangeStrong( &error, op->disconnect_with_error, MemoryOrder::ACQ_REL, @@ -1773,17 +1570,6 @@ void ChannelData::RemoveQueuedPick(QueuedPick* to_remove, } } -RefCountedPtr -ChannelData::GetConnectedSubchannelInDataPlane( - SubchannelInterface* subchannel) const { - SubchannelWrapper* subchannel_wrapper = - static_cast(subchannel); - ConnectedSubchannel* connected_subchannel = - subchannel_wrapper->connected_subchannel_in_data_plane(); - if (connected_subchannel == nullptr) return nullptr; - return connected_subchannel->Ref(); -} - void ChannelData::TryToConnectLocked(void* arg, grpc_error* error_ignored) { auto* chand = static_cast(arg); if (chand->resolving_lb_policy_ != nullptr) { @@ -3711,9 +3497,10 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { auto result = chand->picker()->Pick(pick_args); if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { gpr_log(GPR_INFO, - "chand=%p calld=%p: LB pick returned %s (subchannel=%p, error=%s)", + "chand=%p calld=%p: LB pick returned %s (connected_subchannel=%p, " + "error=%s)", chand, calld, PickResultTypeName(result.type), - result.subchannel.get(), grpc_error_string(result.error)); + result.connected_subchannel.get(), grpc_error_string(result.error)); } switch (result.type) { case LoadBalancingPolicy::PickResult::PICK_TRANSIENT_FAILURE: { @@ -3755,16 +3542,11 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { break; default: // PICK_COMPLETE // Handle drops. - if (GPR_UNLIKELY(result.subchannel == nullptr)) { + if (GPR_UNLIKELY(result.connected_subchannel == nullptr)) { result.error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Call dropped by load balancing policy"); - } else { - // Grab a ref to the connected subchannel while we're still - // holding the data plane combiner. - calld->connected_subchannel_ = - chand->GetConnectedSubchannelInDataPlane(result.subchannel.get()); - GPR_ASSERT(calld->connected_subchannel_ != nullptr); } + calld->connected_subchannel_ = std::move(result.connected_subchannel); calld->lb_recv_trailing_metadata_ready_ = result.recv_trailing_metadata_ready; calld->lb_recv_trailing_metadata_ready_user_data_ = diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h index c21e9d90ec4..f98a41dee07 100644 --- a/src/core/ext/filters/client_channel/lb_policy.h +++ b/src/core/ext/filters/client_channel/lb_policy.h @@ -128,7 +128,7 @@ class LoadBalancingPolicy : public InternallyRefCounted { /// Used only if type is PICK_COMPLETE. Will be set to the selected /// subchannel, or nullptr if the LB policy decides to drop the call. - RefCountedPtr subchannel; + RefCountedPtr connected_subchannel; /// Used only if type is PICK_TRANSIENT_FAILURE. /// Error to be set when returning a transient failure. diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index dad10f0ce86..a87dfda7321 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -575,12 +575,13 @@ GrpcLb::PickResult GrpcLb::Picker::Pick(PickArgs args) { result = child_picker_->Pick(args); // If pick succeeded, add LB token to initial metadata. if (result.type == PickResult::PICK_COMPLETE && - result.subchannel != nullptr) { + result.connected_subchannel != nullptr) { const grpc_arg* arg = grpc_channel_args_find( - result.subchannel->channel_args(), GRPC_ARG_GRPCLB_ADDRESS_LB_TOKEN); + result.connected_subchannel->args(), GRPC_ARG_GRPCLB_ADDRESS_LB_TOKEN); if (arg == nullptr) { - gpr_log(GPR_ERROR, "[grpclb %p picker %p] No LB token for subchannel %p", - parent_, this, result.subchannel.get()); + gpr_log(GPR_ERROR, + "[grpclb %p picker %p] No LB token for connected subchannel %p", + parent_, this, result.connected_subchannel.get()); abort(); } grpc_mdelem lb_token = {reinterpret_cast(arg->value.pointer.p)}; diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index 8bf3d825b23..00036d8be64 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -28,6 +28,7 @@ #include "src/core/ext/filters/client_channel/subchannel.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/sync.h" +#include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/transport/connectivity_state.h" @@ -84,8 +85,9 @@ class PickFirst : public LoadBalancingPolicy { public: PickFirstSubchannelList(PickFirst* policy, TraceFlag* tracer, const ServerAddressList& addresses, + grpc_combiner* combiner, const grpc_channel_args& args) - : SubchannelList(policy, tracer, addresses, + : SubchannelList(policy, tracer, addresses, combiner, policy->channel_control_helper(), args) { // Need to maintain a ref to the LB policy as long as we maintain // any references to subchannels, since the subchannels' @@ -109,18 +111,19 @@ class PickFirst : public LoadBalancingPolicy { class Picker : public SubchannelPicker { public: - explicit Picker(RefCountedPtr subchannel) - : subchannel_(std::move(subchannel)) {} + explicit Picker( + RefCountedPtr connected_subchannel) + : connected_subchannel_(std::move(connected_subchannel)) {} PickResult Pick(PickArgs args) override { PickResult result; result.type = PickResult::PICK_COMPLETE; - result.subchannel = subchannel_; + result.connected_subchannel = connected_subchannel_; return result; } private: - RefCountedPtr subchannel_; + RefCountedPtr connected_subchannel_; }; void ShutdownLocked() override; @@ -163,9 +166,6 @@ void PickFirst::ShutdownLocked() { void PickFirst::ExitIdleLocked() { if (shutdown_) return; if (idle_) { - if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_pick_first_trace)) { - gpr_log(GPR_INFO, "Pick First %p exiting idle", this); - } idle_ = false; if (subchannel_list_ == nullptr || subchannel_list_->num_subchannels() == 0) { @@ -200,7 +200,7 @@ void PickFirst::UpdateLocked(UpdateArgs args) { grpc_channel_args* new_args = grpc_channel_args_copy_and_add(args.args, &new_arg, 1); auto subchannel_list = MakeOrphanable( - this, &grpc_lb_pick_first_trace, args.addresses, *new_args); + this, &grpc_lb_pick_first_trace, args.addresses, combiner(), *new_args); grpc_channel_args_destroy(new_args); if (subchannel_list->num_subchannels() == 0) { // Empty update or no valid subchannels. Unsubscribe from all current @@ -351,8 +351,8 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( // some connectivity state notifications. if (connectivity_state == GRPC_CHANNEL_READY) { p->channel_control_helper()->UpdateState( - GRPC_CHANNEL_READY, - UniquePtr(New(subchannel()->Ref()))); + GRPC_CHANNEL_READY, UniquePtr(New( + connected_subchannel()->Ref()))); } else { // CONNECTING p->channel_control_helper()->UpdateState( connectivity_state, UniquePtr(New( @@ -447,13 +447,13 @@ void PickFirst::PickFirstSubchannelData::ProcessUnselectedReadyLocked() { p->subchannel_list_ = std::move(p->latest_pending_subchannel_list_); } // Cases 1 and 2. - if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_pick_first_trace)) { - gpr_log(GPR_INFO, "Pick First %p selected subchannel %p", p, subchannel()); - } p->selected_ = this; p->channel_control_helper()->UpdateState( GRPC_CHANNEL_READY, - UniquePtr(New(subchannel()->Ref()))); + UniquePtr(New(connected_subchannel()->Ref()))); + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_pick_first_trace)) { + gpr_log(GPR_INFO, "Pick First %p selected subchannel %p", p, subchannel()); + } } void PickFirst::PickFirstSubchannelData:: diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc index 04308ee254c..c6655c7d9bb 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc @@ -38,6 +38,7 @@ #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/sync.h" +#include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/transport/connectivity_state.h" #include "src/core/lib/transport/static_metadata.h" @@ -105,8 +106,9 @@ class RoundRobin : public LoadBalancingPolicy { public: RoundRobinSubchannelList(RoundRobin* policy, TraceFlag* tracer, const ServerAddressList& addresses, + grpc_combiner* combiner, const grpc_channel_args& args) - : SubchannelList(policy, tracer, addresses, + : SubchannelList(policy, tracer, addresses, combiner, policy->channel_control_helper(), args) { // Need to maintain a ref to the LB policy as long as we maintain // any references to subchannels, since the subchannels' @@ -153,7 +155,7 @@ class RoundRobin : public LoadBalancingPolicy { RoundRobin* parent_; size_t last_picked_index_; - InlinedVector, 10> subchannels_; + InlinedVector, 10> subchannels_; }; void ShutdownLocked() override; @@ -178,9 +180,10 @@ RoundRobin::Picker::Picker(RoundRobin* parent, RoundRobinSubchannelList* subchannel_list) : parent_(parent) { for (size_t i = 0; i < subchannel_list->num_subchannels(); ++i) { - RoundRobinSubchannelData* sd = subchannel_list->subchannel(i); - if (sd->connectivity_state() == GRPC_CHANNEL_READY) { - subchannels_.push_back(sd->subchannel()->Ref()); + auto* connected_subchannel = + subchannel_list->subchannel(i)->connected_subchannel(); + if (connected_subchannel != nullptr) { + subchannels_.push_back(connected_subchannel->Ref()); } } // For discussion on why we generate a random starting index for @@ -201,13 +204,14 @@ RoundRobin::PickResult RoundRobin::Picker::Pick(PickArgs args) { last_picked_index_ = (last_picked_index_ + 1) % subchannels_.size(); if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_round_robin_trace)) { gpr_log(GPR_INFO, - "[RR %p picker %p] returning index %" PRIuPTR ", subchannel=%p", + "[RR %p picker %p] returning index %" PRIuPTR + ", connected_subchannel=%p", parent_, this, last_picked_index_, subchannels_[last_picked_index_].get()); } PickResult result; result.type = PickResult::PICK_COMPLETE; - result.subchannel = subchannels_[last_picked_index_]; + result.connected_subchannel = subchannels_[last_picked_index_]; return result; } @@ -420,7 +424,7 @@ void RoundRobin::UpdateLocked(UpdateArgs args) { } } latest_pending_subchannel_list_ = MakeOrphanable( - this, &grpc_lb_round_robin_trace, args.addresses, *args.args); + this, &grpc_lb_round_robin_trace, args.addresses, combiner(), *args.args); if (latest_pending_subchannel_list_->num_subchannels() == 0) { // If the new list is empty, immediately promote the new list to the // current list and transition to TRANSIENT_FAILURE. diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h index 34cd0f549fe..7d70928a83c 100644 --- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h @@ -39,6 +39,7 @@ #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/closure.h" +#include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/transport/connectivity_state.h" @@ -63,7 +64,8 @@ class MySubchannelList }; */ -// All methods will be called from within the client_channel combiner. +// All methods with a Locked() suffix must be called from within the +// client_channel combiner. namespace grpc_core { @@ -91,13 +93,20 @@ class SubchannelData { // Returns a pointer to the subchannel. SubchannelInterface* subchannel() const { return subchannel_.get(); } + // Returns the connected subchannel. Will be null if the subchannel + // is not connected. + ConnectedSubchannelInterface* connected_subchannel() const { + return connected_subchannel_.get(); + } + // Synchronously checks the subchannel's connectivity state. // Must not be called while there is a connectivity notification // pending (i.e., between calling StartConnectivityWatchLocked() and // calling CancelConnectivityWatchLocked()). grpc_connectivity_state CheckConnectivityStateLocked() { GPR_ASSERT(pending_watcher_ == nullptr); - connectivity_state_ = subchannel_->CheckConnectivityState(); + connectivity_state_ = + subchannel()->CheckConnectivityState(&connected_subchannel_); return connectivity_state_; } @@ -135,8 +144,7 @@ class SubchannelData { private: // Watcher for subchannel connectivity state. - class Watcher - : public SubchannelInterface::ConnectivityStateWatcherInterface { + class Watcher : public SubchannelInterface::ConnectivityStateWatcher { public: Watcher( SubchannelData* subchannel_data, @@ -146,13 +154,42 @@ class SubchannelData { ~Watcher() { subchannel_list_.reset(DEBUG_LOCATION, "Watcher dtor"); } - void OnConnectivityStateChange(grpc_connectivity_state new_state) override; + void OnConnectivityStateChange(grpc_connectivity_state new_state, + RefCountedPtr + connected_subchannel) override; grpc_pollset_set* interested_parties() override { return subchannel_list_->policy()->interested_parties(); } private: + // A fire-and-forget class that bounces into the combiner to process + // a connectivity state update. + class Updater { + public: + Updater( + SubchannelData* + subchannel_data, + RefCountedPtr> + subchannel_list, + grpc_connectivity_state state, + RefCountedPtr connected_subchannel); + + ~Updater() { + subchannel_list_.reset(DEBUG_LOCATION, "Watcher::Updater dtor"); + } + + private: + static void OnUpdateLocked(void* arg, grpc_error* error); + + SubchannelData* subchannel_data_; + RefCountedPtr> + subchannel_list_; + const grpc_connectivity_state state_; + RefCountedPtr connected_subchannel_; + grpc_closure closure_; + }; + SubchannelData* subchannel_data_; RefCountedPtr subchannel_list_; }; @@ -165,10 +202,10 @@ class SubchannelData { // The subchannel. RefCountedPtr subchannel_; // Will be non-null when the subchannel's state is being watched. - SubchannelInterface::ConnectivityStateWatcherInterface* pending_watcher_ = - nullptr; + SubchannelInterface::ConnectivityStateWatcher* pending_watcher_ = nullptr; // Data updated by the watcher. grpc_connectivity_state connectivity_state_; + RefCountedPtr connected_subchannel_; }; // A list of subchannels. @@ -195,6 +232,7 @@ class SubchannelList : public InternallyRefCounted { // the backoff code out of subchannels and into LB policies. void ResetBackoffLocked(); + // Note: Caller must ensure that this is invoked inside of the combiner. void Orphan() override { ShutdownLocked(); InternallyRefCounted::Unref(DEBUG_LOCATION, "shutdown"); @@ -204,7 +242,7 @@ class SubchannelList : public InternallyRefCounted { protected: SubchannelList(LoadBalancingPolicy* policy, TraceFlag* tracer, - const ServerAddressList& addresses, + const ServerAddressList& addresses, grpc_combiner* combiner, LoadBalancingPolicy::ChannelControlHelper* helper, const grpc_channel_args& args); @@ -225,6 +263,8 @@ class SubchannelList : public InternallyRefCounted { TraceFlag* tracer_; + grpc_combiner* combiner_; + // The list of subchannels. SubchannelVector subchannels_; @@ -244,26 +284,59 @@ class SubchannelList : public InternallyRefCounted { template void SubchannelData::Watcher:: - OnConnectivityStateChange(grpc_connectivity_state new_state) { - if (GRPC_TRACE_FLAG_ENABLED(*subchannel_list_->tracer())) { + OnConnectivityStateChange( + grpc_connectivity_state new_state, + RefCountedPtr connected_subchannel) { + // Will delete itself. + New(subchannel_data_, + subchannel_list_->Ref(DEBUG_LOCATION, "Watcher::Updater"), + new_state, std::move(connected_subchannel)); +} + +template +SubchannelData::Watcher::Updater:: + Updater( + SubchannelData* subchannel_data, + RefCountedPtr> + subchannel_list, + grpc_connectivity_state state, + RefCountedPtr connected_subchannel) + : subchannel_data_(subchannel_data), + subchannel_list_(std::move(subchannel_list)), + state_(state), + connected_subchannel_(std::move(connected_subchannel)) { + GRPC_CLOSURE_INIT(&closure_, &OnUpdateLocked, this, + grpc_combiner_scheduler(subchannel_list_->combiner_)); + GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE); +} + +template +void SubchannelData::Watcher::Updater:: + OnUpdateLocked(void* arg, grpc_error* error) { + Updater* self = static_cast(arg); + SubchannelData* sd = self->subchannel_data_; + if (GRPC_TRACE_FLAG_ENABLED(*sd->subchannel_list_->tracer())) { gpr_log(GPR_INFO, "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR " (subchannel %p): connectivity changed: state=%s, " - "shutting_down=%d, pending_watcher=%p", - subchannel_list_->tracer()->name(), subchannel_list_->policy(), - subchannel_list_.get(), subchannel_data_->Index(), - subchannel_list_->num_subchannels(), - subchannel_data_->subchannel_.get(), - grpc_connectivity_state_name(new_state), - subchannel_list_->shutting_down(), - subchannel_data_->pending_watcher_); + "connected_subchannel=%p, shutting_down=%d, pending_watcher=%p", + sd->subchannel_list_->tracer()->name(), + sd->subchannel_list_->policy(), sd->subchannel_list_, sd->Index(), + sd->subchannel_list_->num_subchannels(), sd->subchannel_.get(), + grpc_connectivity_state_name(self->state_), + self->connected_subchannel_.get(), + sd->subchannel_list_->shutting_down(), sd->pending_watcher_); } - if (!subchannel_list_->shutting_down() && - subchannel_data_->pending_watcher_ != nullptr) { - subchannel_data_->connectivity_state_ = new_state; + if (!sd->subchannel_list_->shutting_down() && + sd->pending_watcher_ != nullptr) { + sd->connectivity_state_ = self->state_; + // Get or release ref to connected subchannel. + sd->connected_subchannel_ = std::move(self->connected_subchannel_); // Call the subclass's ProcessConnectivityChangeLocked() method. - subchannel_data_->ProcessConnectivityChangeLocked(new_state); + sd->ProcessConnectivityChangeLocked(sd->connectivity_state_); } + // Clean up. + Delete(self); } // @@ -298,6 +371,7 @@ void SubchannelData:: subchannel_.get()); } subchannel_.reset(); + connected_subchannel_.reset(); } } @@ -326,7 +400,7 @@ void SubchannelData(this, subchannel_list()->Ref(DEBUG_LOCATION, "Watcher")); subchannel_->WatchConnectivityState( connectivity_state_, - UniquePtr( + UniquePtr( pending_watcher_)); } @@ -360,12 +434,13 @@ void SubchannelData::ShutdownLocked() { template SubchannelList::SubchannelList( LoadBalancingPolicy* policy, TraceFlag* tracer, - const ServerAddressList& addresses, + const ServerAddressList& addresses, grpc_combiner* combiner, LoadBalancingPolicy::ChannelControlHelper* helper, const grpc_channel_args& args) : InternallyRefCounted(tracer), policy_(policy), - tracer_(tracer) { + tracer_(tracer), + combiner_(GRPC_COMBINER_REF(combiner, "subchannel_list")) { if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) { gpr_log(GPR_INFO, "[%s %p] Creating subchannel list %p for %" PRIuPTR " subchannels", @@ -434,6 +509,7 @@ SubchannelList::~SubchannelList() { gpr_log(GPR_INFO, "[%s %p] Destroying subchannel_list %p", tracer_->name(), policy_, this); } + GRPC_COMBINER_UNREF(combiner_, "subchannel_list"); } template diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index 74660cec92b..e790ec25520 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -570,7 +570,7 @@ XdsLb::PickResult XdsLb::Picker::Pick(PickArgs args) { PickResult result = PickFromLocality(key, args); // If pick succeeded, add client stats. if (result.type == PickResult::PICK_COMPLETE && - result.subchannel != nullptr && client_stats_ != nullptr) { + result.connected_subchannel != nullptr && client_stats_ != nullptr) { // TODO(roth): Add support for client stats. } return result; diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 99c7721e5e5..dd16eded826 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -86,7 +86,7 @@ ConnectedSubchannel::ConnectedSubchannel( grpc_channel_stack* channel_stack, const grpc_channel_args* args, RefCountedPtr channelz_subchannel, intptr_t socket_uuid) - : RefCounted(&grpc_trace_subchannel_refcount), + : ConnectedSubchannelInterface(&grpc_trace_subchannel_refcount), channel_stack_(channel_stack), args_(grpc_channel_args_copy(args)), channelz_subchannel_(std::move(channelz_subchannel)), @@ -378,12 +378,12 @@ class Subchannel::ConnectedSubchannelStateWatcher { // void Subchannel::ConnectivityStateWatcherList::AddWatcherLocked( - OrphanablePtr watcher) { + UniquePtr watcher) { watchers_.insert(MakePair(watcher.get(), std::move(watcher))); } void Subchannel::ConnectivityStateWatcherList::RemoveWatcherLocked( - ConnectivityStateWatcherInterface* watcher) { + ConnectivityStateWatcher* watcher) { watchers_.erase(watcher); } @@ -438,9 +438,8 @@ class Subchannel::HealthWatcherMap::HealthWatcher grpc_connectivity_state state() const { return state_; } - void AddWatcherLocked( - grpc_connectivity_state initial_state, - OrphanablePtr watcher) { + void AddWatcherLocked(grpc_connectivity_state initial_state, + UniquePtr watcher) { if (state_ != initial_state) { RefCountedPtr connected_subchannel; if (state_ == GRPC_CHANNEL_READY) { @@ -452,7 +451,7 @@ class Subchannel::HealthWatcherMap::HealthWatcher watcher_list_.AddWatcherLocked(std::move(watcher)); } - void RemoveWatcherLocked(ConnectivityStateWatcherInterface* watcher) { + void RemoveWatcherLocked(ConnectivityStateWatcher* watcher) { watcher_list_.RemoveWatcherLocked(watcher); } @@ -528,7 +527,7 @@ class Subchannel::HealthWatcherMap::HealthWatcher void Subchannel::HealthWatcherMap::AddWatcherLocked( Subchannel* subchannel, grpc_connectivity_state initial_state, UniquePtr health_check_service_name, - OrphanablePtr watcher) { + UniquePtr watcher) { // If the health check service name is not already present in the map, // add it. auto it = map_.find(health_check_service_name.get()); @@ -547,8 +546,7 @@ void Subchannel::HealthWatcherMap::AddWatcherLocked( } void Subchannel::HealthWatcherMap::RemoveWatcherLocked( - const char* health_check_service_name, - ConnectivityStateWatcherInterface* watcher) { + const char* health_check_service_name, ConnectivityStateWatcher* watcher) { auto it = map_.find(health_check_service_name); GPR_ASSERT(it != map_.end()); it->second->RemoveWatcherLocked(watcher); @@ -820,7 +818,7 @@ grpc_connectivity_state Subchannel::CheckConnectivityState( void Subchannel::WatchConnectivityState( grpc_connectivity_state initial_state, UniquePtr health_check_service_name, - OrphanablePtr watcher) { + UniquePtr watcher) { MutexLock lock(&mu_); grpc_pollset_set* interested_parties = watcher->interested_parties(); if (interested_parties != nullptr) { @@ -839,8 +837,7 @@ void Subchannel::WatchConnectivityState( } void Subchannel::CancelConnectivityStateWatch( - const char* health_check_service_name, - ConnectivityStateWatcherInterface* watcher) { + const char* health_check_service_name, ConnectivityStateWatcher* watcher) { MutexLock lock(&mu_); grpc_pollset_set* interested_parties = watcher->interested_parties(); if (interested_parties != nullptr) { diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h index 9e8de767839..2f05792b872 100644 --- a/src/core/ext/filters/client_channel/subchannel.h +++ b/src/core/ext/filters/client_channel/subchannel.h @@ -23,6 +23,7 @@ #include "src/core/ext/filters/client_channel/client_channel_channelz.h" #include "src/core/ext/filters/client_channel/connector.h" +#include "src/core/ext/filters/client_channel/subchannel_interface.h" #include "src/core/ext/filters/client_channel/subchannel_pool_interface.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_stack.h" @@ -69,7 +70,7 @@ namespace grpc_core { class SubchannelCall; -class ConnectedSubchannel : public RefCounted { +class ConnectedSubchannel : public ConnectedSubchannelInterface { public: struct CallArgs { grpc_polling_entity* pollent; @@ -96,7 +97,7 @@ class ConnectedSubchannel : public RefCounted { grpc_error** error); grpc_channel_stack* channel_stack() const { return channel_stack_; } - const grpc_channel_args* args() const { return args_; } + const grpc_channel_args* args() const override { return args_; } channelz::SubchannelNode* channelz_subchannel() const { return channelz_subchannel_.get(); } @@ -175,35 +176,10 @@ class SubchannelCall { // A subchannel that knows how to connect to exactly one target address. It // provides a target for load balancing. -// -// Note that this is the "real" subchannel implementation, whose API is -// different from the SubchannelInterface that is exposed to LB policy -// implementations. The client channel provides an adaptor class -// (SubchannelWrapper) that "converts" between the two. class Subchannel { public: - class ConnectivityStateWatcherInterface - : public InternallyRefCounted { - public: - virtual ~ConnectivityStateWatcherInterface() = default; - - // Will be invoked whenever the subchannel's connectivity state - // changes. There will be only one invocation of this method on a - // given watcher instance at any given time. - // - // When the state changes to READY, connected_subchannel will - // contain a ref to the connected subchannel. When it changes from - // READY to some other state, the implementation must release its - // ref to the connected subchannel. - virtual void OnConnectivityStateChange( - grpc_connectivity_state new_state, - RefCountedPtr connected_subchannel) // NOLINT - GRPC_ABSTRACT; - - virtual grpc_pollset_set* interested_parties() GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS - }; + typedef SubchannelInterface::ConnectivityStateWatcher + ConnectivityStateWatcher; // The ctor and dtor are not intended to use directly. Subchannel(SubchannelKey* key, grpc_connector* connector, @@ -230,8 +206,6 @@ class Subchannel { // Caller doesn't take ownership. const char* GetTargetAddress(); - const grpc_channel_args* channel_args() const { return args_; } - channelz::SubchannelNode* channelz_node(); // Returns the current connectivity state of the subchannel. @@ -251,15 +225,14 @@ class Subchannel { // changes. // The watcher will be destroyed either when the subchannel is // destroyed or when CancelConnectivityStateWatch() is called. - void WatchConnectivityState( - grpc_connectivity_state initial_state, - UniquePtr health_check_service_name, - OrphanablePtr watcher); + void WatchConnectivityState(grpc_connectivity_state initial_state, + UniquePtr health_check_service_name, + UniquePtr watcher); // Cancels a connectivity state watch. // If the watcher has already been destroyed, this is a no-op. void CancelConnectivityStateWatch(const char* health_check_service_name, - ConnectivityStateWatcherInterface* watcher); + ConnectivityStateWatcher* watcher); // Attempt to connect to the backend. Has no effect if already connected. void AttemptToConnect(); @@ -284,15 +257,14 @@ class Subchannel { grpc_resolved_address* addr); private: - // A linked list of ConnectivityStateWatcherInterfaces that are monitoring - // the subchannel's state. + // A linked list of ConnectivityStateWatchers that are monitoring the + // subchannel's state. class ConnectivityStateWatcherList { public: ~ConnectivityStateWatcherList() { Clear(); } - void AddWatcherLocked( - OrphanablePtr watcher); - void RemoveWatcherLocked(ConnectivityStateWatcherInterface* watcher); + void AddWatcherLocked(UniquePtr watcher); + void RemoveWatcherLocked(ConnectivityStateWatcher* watcher); // Notifies all watchers in the list about a change to state. void NotifyLocked(Subchannel* subchannel, grpc_connectivity_state state); @@ -304,13 +276,12 @@ class Subchannel { private: // TODO(roth): This could be a set instead of a map if we had a set // implementation. - Map> + Map> watchers_; }; - // A map that tracks ConnectivityStateWatcherInterfaces using a particular - // health check service name. + // A map that tracks ConnectivityStateWatchers using a particular health + // check service name. // // There is one entry in the map for each health check service name. // Entries exist only as long as there are watchers using the @@ -320,12 +291,12 @@ class Subchannel { // state READY. class HealthWatcherMap { public: - void AddWatcherLocked( - Subchannel* subchannel, grpc_connectivity_state initial_state, - UniquePtr health_check_service_name, - OrphanablePtr watcher); + void AddWatcherLocked(Subchannel* subchannel, + grpc_connectivity_state initial_state, + UniquePtr health_check_service_name, + UniquePtr watcher); void RemoveWatcherLocked(const char* health_check_service_name, - ConnectivityStateWatcherInterface* watcher); + ConnectivityStateWatcher* watcher); // Notifies the watcher when the subchannel's state changes. void NotifyLocked(grpc_connectivity_state state); diff --git a/src/core/ext/filters/client_channel/subchannel_interface.h b/src/core/ext/filters/client_channel/subchannel_interface.h index 2e448dc5a64..10b1bf124c2 100644 --- a/src/core/ext/filters/client_channel/subchannel_interface.h +++ b/src/core/ext/filters/client_channel/subchannel_interface.h @@ -21,22 +21,42 @@ #include +#include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" namespace grpc_core { -// The interface for subchannels that is exposed to LB policy implementations. +// TODO(roth): In a subsequent PR, remove this from this API. +class ConnectedSubchannelInterface + : public RefCounted { + public: + virtual const grpc_channel_args* args() const GRPC_ABSTRACT; + + protected: + template + explicit ConnectedSubchannelInterface(TraceFlagT* trace_flag = nullptr) + : RefCounted(trace_flag) {} +}; + class SubchannelInterface : public RefCounted { public: - class ConnectivityStateWatcherInterface { + class ConnectivityStateWatcher { public: - virtual ~ConnectivityStateWatcherInterface() = default; + virtual ~ConnectivityStateWatcher() = default; // Will be invoked whenever the subchannel's connectivity state // changes. There will be only one invocation of this method on a // given watcher instance at any given time. - virtual void OnConnectivityStateChange(grpc_connectivity_state new_state) + // + // When the state changes to READY, connected_subchannel will + // contain a ref to the connected subchannel. When it changes from + // READY to some other state, the implementation must release its + // ref to the connected subchannel. + virtual void OnConnectivityStateChange( + grpc_connectivity_state new_state, + RefCountedPtr + connected_subchannel) // NOLINT GRPC_ABSTRACT; // TODO(roth): Remove this as soon as we move to EventManager-based @@ -46,14 +66,12 @@ class SubchannelInterface : public RefCounted { GRPC_ABSTRACT_BASE_CLASS }; - template - explicit SubchannelInterface(TraceFlagT* trace_flag = nullptr) - : RefCounted(trace_flag) {} - virtual ~SubchannelInterface() = default; // Returns the current connectivity state of the subchannel. - virtual grpc_connectivity_state CheckConnectivityState() GRPC_ABSTRACT; + virtual grpc_connectivity_state CheckConnectivityState( + RefCountedPtr* connected_subchannel) + GRPC_ABSTRACT; // Starts watching the subchannel's connectivity state. // The first callback to the watcher will be delivered when the @@ -68,12 +86,12 @@ class SubchannelInterface : public RefCounted { // the previous watcher using CancelConnectivityStateWatch(). virtual void WatchConnectivityState( grpc_connectivity_state initial_state, - UniquePtr watcher) GRPC_ABSTRACT; + UniquePtr watcher) GRPC_ABSTRACT; // Cancels a connectivity state watch. // If the watcher has already been destroyed, this is a no-op. - virtual void CancelConnectivityStateWatch( - ConnectivityStateWatcherInterface* watcher) GRPC_ABSTRACT; + virtual void CancelConnectivityStateWatch(ConnectivityStateWatcher* watcher) + GRPC_ABSTRACT; // Attempt to connect to the backend. Has no effect if already connected. // If the subchannel is currently in backoff delay due to a previously @@ -87,9 +105,6 @@ class SubchannelInterface : public RefCounted { // attempt will be started as soon as AttemptToConnect() is called. virtual void ResetBackoff() GRPC_ABSTRACT; - // TODO(roth): Need a better non-grpc-specific abstraction here. - virtual const grpc_channel_args* channel_args() GRPC_ABSTRACT; - GRPC_ABSTRACT_BASE_CLASS }; diff --git a/src/core/lib/gprpp/map.h b/src/core/lib/gprpp/map.h index 566691df580..36e32d60c07 100644 --- a/src/core/lib/gprpp/map.h +++ b/src/core/lib/gprpp/map.h @@ -30,7 +30,6 @@ #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/pair.h" -#include "src/core/lib/gprpp/ref_counted_ptr.h" namespace grpc_core { struct StringLess { @@ -42,13 +41,6 @@ struct StringLess { } }; -template -struct RefCountedPtrLess { - bool operator()(const RefCountedPtr& p1, const RefCountedPtr& p2) { - return p1.get() < p2.get(); - } -}; - namespace testing { class MapTest; } @@ -63,28 +55,8 @@ class Map { typedef Compare key_compare; class iterator; - Map() {} ~Map() { clear(); } - // Copying not currently supported. - Map(const Map& other) = delete; - - // Move support. - Map(Map&& other) : root_(other.root_), size_(other.size_) { - other.root_ = nullptr; - other.size_ = 0; - } - Map& operator=(Map&& other) { - if (this != &other) { - clear(); - root_ = other.root_; - size_ = other.size_; - other.root_ = nullptr; - other.size_ = 0; - } - return *this; - } - T& operator[](key_type&& key); T& operator[](const key_type& key); iterator find(const key_type& k); diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc index 7766ee186c6..1523ced16d8 100644 --- a/src/core/lib/transport/metadata.cc +++ b/src/core/lib/transport/metadata.cc @@ -222,12 +222,7 @@ void grpc_mdctx_global_shutdown() { abort(); } } - // For ASAN builds, we don't want to crash here, because that will - // prevent ASAN from providing leak detection information, which is - // far more useful than this simple assertion. -#ifndef GRPC_ASAN_ENABLED GPR_DEBUG_ASSERT(shard->count == 0); -#endif gpr_free(shard->elems); } } diff --git a/test/core/gprpp/map_test.cc b/test/core/gprpp/map_test.cc index 21aeee82486..30d9eb0b207 100644 --- a/test/core/gprpp/map_test.cc +++ b/test/core/gprpp/map_test.cc @@ -437,35 +437,6 @@ TEST_F(MapTest, LowerBound) { EXPECT_EQ(it, test_map.end()); } -// Test move ctor -TEST_F(MapTest, MoveCtor) { - Map test_map; - for (int i = 0; i < 5; i++) { - test_map.emplace(kKeys[i], Payload(i)); - } - Map test_map2 = std::move(test_map); - for (int i = 0; i < 5; i++) { - EXPECT_EQ(test_map.end(), test_map.find(kKeys[i])); - EXPECT_EQ(i, test_map2.find(kKeys[i])->second.data()); - } -} - -// Test move assignment -TEST_F(MapTest, MoveAssignment) { - Map test_map; - for (int i = 0; i < 5; i++) { - test_map.emplace(kKeys[i], Payload(i)); - } - Map test_map2; - test_map2.emplace("xxx", Payload(123)); - test_map2 = std::move(test_map); - for (int i = 0; i < 5; i++) { - EXPECT_EQ(test_map.end(), test_map.find(kKeys[i])); - EXPECT_EQ(i, test_map2.find(kKeys[i])->second.data()); - } - EXPECT_EQ(test_map2.end(), test_map2.find("xxx")); -} - } // namespace testing } // namespace grpc_core diff --git a/test/core/util/test_lb_policies.cc b/test/core/util/test_lb_policies.cc index 041ce1f45a1..2c1f988d173 100644 --- a/test/core/util/test_lb_policies.cc +++ b/test/core/util/test_lb_policies.cc @@ -117,7 +117,7 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy PickResult Pick(PickArgs args) override { PickResult result = delegate_picker_->Pick(args); if (result.type == PickResult::PICK_COMPLETE && - result.subchannel != nullptr) { + result.connected_subchannel != nullptr) { new (args.call_state->Alloc(sizeof(TrailingMetadataHandler))) TrailingMetadataHandler(&result, cb_, user_data_); } From 662aa1f153853399bcface2928f3230e71f5fc61 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Tue, 18 Jun 2019 10:53:53 -0700 Subject: [PATCH 0572/1555] Modify format printing and Debug trace. --- src/core/lib/iomgr/threadpool/mpmcqueue.cc | 44 ++++++++++--------- src/core/lib/iomgr/threadpool/mpmcqueue.h | 49 ++++++++++------------ 2 files changed, 44 insertions(+), 49 deletions(-) diff --git a/src/core/lib/iomgr/threadpool/mpmcqueue.cc b/src/core/lib/iomgr/threadpool/mpmcqueue.cc index b2e09b9c81b..64f7d19a2a7 100644 --- a/src/core/lib/iomgr/threadpool/mpmcqueue.cc +++ b/src/core/lib/iomgr/threadpool/mpmcqueue.cc @@ -16,21 +16,24 @@ * */ -#include - #include "src/core/lib/iomgr/threadpool/mpmcqueue.h" #include #include #include +#include #include #include +#include #include +#include "src/core/lib/debug/stats.h" #include "src/core/lib/gprpp/sync.h" namespace grpc_core { +DebugOnlyTraceFlag thread_pool_trace(false, "thread_pool_trace"); + inline void* MPMCQueue::PopFront() { void* result = queue_head_->content; Node* head_to_remove = queue_head_; @@ -55,6 +58,10 @@ inline void* MPMCQueue::PopFront() { gpr_time_sub(gpr_now(GPR_CLOCK_PRECISE), busy_time)); } + if (GRPC_TRACE_FLAG_ENABLED(thread_pool_trace)) { + PrintStats(); + } + // Singal waiting thread if (count_.Load(MemoryOrder::RELAXED) > 0 && num_waiters_ > 0) { wait_nonempty_.Signal(); @@ -70,10 +77,11 @@ MPMCQueue::MPMCQueue() MPMCQueue::~MPMCQueue() { GPR_ASSERT(count_.Load(MemoryOrder::RELAXED) == 0); - ReleasableMutexLock l(&mu_); + MutexLock l(&mu_); GPR_ASSERT(num_waiters_ == 0); - l.Unlock(); - PrintStats(); + if (GRPC_TRACE_FLAG_ENABLED(thread_pool_trace)) { + PrintStats(); + } } void MPMCQueue::Put(void* elem) { @@ -91,6 +99,9 @@ void MPMCQueue::Put(void* elem) { // Update Stats info stats_.num_started++; + if (GRPC_TRACE_FLAG_ENABLED(thread_pool_trace)) { + PrintStats(); + } if (num_waiters_ > 0) { wait_nonempty_.Signal(); @@ -111,28 +122,15 @@ void* MPMCQueue::Get() { } void MPMCQueue::PrintStats() { - MutexLock l(&mu_); gpr_log(GPR_INFO, "STATS INFO:"); - gpr_log(GPR_INFO, "num_started: %lu", stats_.num_started); - gpr_log(GPR_INFO, "num_completed: %lu", stats_.num_completed); - gpr_log(GPR_INFO, "total_queue_cycles: %d", + gpr_log(GPR_INFO, "num_started: %" PRIu64, stats_.num_started); + gpr_log(GPR_INFO, "num_completed: %" PRIu64, stats_.num_completed); + gpr_log(GPR_INFO, "total_queue_cycles: %" PRId32, gpr_time_to_millis(stats_.total_queue_cycles)); - gpr_log(GPR_INFO, "max_queue_cycles: %d", + gpr_log(GPR_INFO, "max_queue_cycles: %" PRId32, gpr_time_to_millis(stats_.max_queue_cycles)); - gpr_log(GPR_INFO, "busy_time_cycles: %d", + gpr_log(GPR_INFO, "busy_time_cycles: %" PRId32, gpr_time_to_millis(stats_.busy_time_cycles)); } -MPMCQueue::Stats* MPMCQueue::queue_stats() { - MPMCQueue::Stats* result = new Stats(); - MutexLock l(&mu_); - result->total_queue_cycles = - gpr_time_add(result->total_queue_cycles, stats_.total_queue_cycles); - result->max_queue_cycles = - gpr_time_add(result->max_queue_cycles, stats_.max_queue_cycles); - result->busy_time_cycles = - gpr_time_add(result->busy_time_cycles, stats_.busy_time_cycles); - return result; -} - } // namespace grpc_core diff --git a/src/core/lib/iomgr/threadpool/mpmcqueue.h b/src/core/lib/iomgr/threadpool/mpmcqueue.h index 8c8395e1d9d..b39c9d81f4f 100644 --- a/src/core/lib/iomgr/threadpool/mpmcqueue.h +++ b/src/core/lib/iomgr/threadpool/mpmcqueue.h @@ -48,25 +48,6 @@ class MPMCQueueInterface { class MPMCQueue : public MPMCQueueInterface { public: - struct Stats { // Stats of queue - uint64_t num_started; // Number of elements have been added to queue - uint64_t num_completed; // Number of elements have been removed from - // the queue - gpr_timespec total_queue_cycles; // Total waiting time that all the - // removed elements have spent in queue - gpr_timespec max_queue_cycles; // Max waiting time among all removed - // elements - gpr_timespec busy_time_cycles; // Accumulated amount of time that queue - // was not empty - - Stats() { - num_started = 0; - num_completed = 0; - total_queue_cycles = gpr_time_0(GPR_TIMESPAN); - max_queue_cycles = gpr_time_0(GPR_TIMESPAN); - busy_time_cycles = gpr_time_0(GPR_TIMESPAN); - } - }; // Create a new Multiple-Producer-Multiple-Consumer Queue. The queue created // will have infinite length. explicit MPMCQueue(); @@ -88,16 +69,12 @@ class MPMCQueue : public MPMCQueueInterface { // quickly. int count() const { return count_.Load(MemoryOrder::RELAXED); } - // Print out Stats. Time measurement are printed in millisecond. - void PrintStats(); - - // Return a copy of current stats info. This info will be changed quickly - // when queue is still running. This copy will not deleted by queue. - Stats* queue_stats(); - private: void* PopFront(); + // Print out Stats. Time measurement are printed in millisecond. + void PrintStats(); + struct Node { Node* next; // Linking void* content; // Points to actual element @@ -109,6 +86,26 @@ class MPMCQueue : public MPMCQueueInterface { } }; + struct Stats { // Stats of queue + uint64_t num_started; // Number of elements have been added to queue + uint64_t num_completed; // Number of elements have been removed from + // the queue + gpr_timespec total_queue_cycles; // Total waiting time that all the + // removed elements have spent in queue + gpr_timespec max_queue_cycles; // Max waiting time among all removed + // elements + gpr_timespec busy_time_cycles; // Accumulated amount of time that queue + // was not empty + + Stats() { + num_started = 0; + num_completed = 0; + total_queue_cycles = gpr_time_0(GPR_TIMESPAN); + max_queue_cycles = gpr_time_0(GPR_TIMESPAN); + busy_time_cycles = gpr_time_0(GPR_TIMESPAN); + } + }; + Mutex mu_; // Protecting lock CondVar wait_nonempty_; // Wait on empty queue on get int num_waiters_; // Number of waiters From 9b49f03cf7a28886ff4b1dcacfd2861d6e3f5364 Mon Sep 17 00:00:00 2001 From: yang-g Date: Tue, 18 Jun 2019 11:03:43 -0700 Subject: [PATCH 0573/1555] Relax deadline check in c# --- src/csharp/Grpc.Core.Tests/TimeoutsTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/csharp/Grpc.Core.Tests/TimeoutsTest.cs b/src/csharp/Grpc.Core.Tests/TimeoutsTest.cs index b89c1afcc35..55e69a01813 100644 --- a/src/csharp/Grpc.Core.Tests/TimeoutsTest.cs +++ b/src/csharp/Grpc.Core.Tests/TimeoutsTest.cs @@ -80,7 +80,7 @@ namespace Grpc.Core.Tests // A fairly relaxed check that the deadline set by client and deadline seen by server // are in agreement. C core takes care of the work with transferring deadline over the wire, // so we don't need an exact check here. - Assert.IsTrue(Math.Abs((clientDeadline - context.Deadline).TotalMilliseconds) < 5000); + Assert.IsTrue(Math.Abs((clientDeadline - context.Deadline).TotalHours) < 1); return Task.FromResult("PASS"); }); Calls.BlockingUnaryCall(helper.CreateUnaryCall(new CallOptions(deadline: clientDeadline)), "abc"); From ce856d27f4c25b213250b9577b4a0dd3467a8567 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Tue, 18 Jun 2019 11:16:24 -0700 Subject: [PATCH 0574/1555] Add extern declaration and adjust header --- src/core/lib/iomgr/threadpool/mpmcqueue.cc | 8 +++++--- src/core/lib/iomgr/threadpool/mpmcqueue.h | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/core/lib/iomgr/threadpool/mpmcqueue.cc b/src/core/lib/iomgr/threadpool/mpmcqueue.cc index 64f7d19a2a7..a59d62e5750 100644 --- a/src/core/lib/iomgr/threadpool/mpmcqueue.cc +++ b/src/core/lib/iomgr/threadpool/mpmcqueue.cc @@ -18,14 +18,16 @@ #include "src/core/lib/iomgr/threadpool/mpmcqueue.h" +#include + +#include +#include + #include #include #include -#include #include #include -#include -#include #include "src/core/lib/debug/stats.h" #include "src/core/lib/gprpp/sync.h" diff --git a/src/core/lib/iomgr/threadpool/mpmcqueue.h b/src/core/lib/iomgr/threadpool/mpmcqueue.h index b39c9d81f4f..2d77a281c5b 100644 --- a/src/core/lib/iomgr/threadpool/mpmcqueue.h +++ b/src/core/lib/iomgr/threadpool/mpmcqueue.h @@ -24,11 +24,14 @@ #include #include +#include "src/core/lib/debug/stats.h" #include "src/core/lib/gprpp/atomic.h" #include "src/core/lib/gprpp/sync.h" namespace grpc_core { +extern DebugOnlyTraceFlag thread_pool_trace; + // Abstract base class of a MPMC queue interface class MPMCQueueInterface { public: From 917605735b99a3e367bde88875131532d063122c Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Tue, 18 Jun 2019 11:23:10 -0700 Subject: [PATCH 0575/1555] Adjust port header position --- src/core/lib/iomgr/threadpool/mpmcqueue.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/threadpool/mpmcqueue.cc b/src/core/lib/iomgr/threadpool/mpmcqueue.cc index a59d62e5750..f39abe572c0 100644 --- a/src/core/lib/iomgr/threadpool/mpmcqueue.cc +++ b/src/core/lib/iomgr/threadpool/mpmcqueue.cc @@ -16,10 +16,10 @@ * */ -#include "src/core/lib/iomgr/threadpool/mpmcqueue.h" - #include +#include "src/core/lib/iomgr/threadpool/mpmcqueue.h" + #include #include From 9640bcddc24f9ec32e3ec967ca83986cf35814bf Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 18 Jun 2019 14:17:15 -0700 Subject: [PATCH 0576/1555] fix testHijackingInterceptor --- src/objective-c/tests/InteropTests/InteropTests.m | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 235fcaed483..5587e78bfae 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -1497,8 +1497,10 @@ static dispatch_once_t initGlobalInterceptorFactory; - (void)testHijackingInterceptor { NSUInteger kCancelAfterWrites = 2; XCTAssertNotNil([[self class] host]); - __weak XCTestExpectation *expectation = - [self expectationWithDescription:@"testHijackingInterceptor"]; + __weak XCTestExpectation *expectUserCallComplete = + [self expectationWithDescription:@"User call completed."]; + __weak XCTestExpectation *expectCallInternalComplete = + [self expectationWithDescription:@"Internal gRPC call completed."]; NSArray *responses = @[ @1, @2, @3, @4 ]; __block int index = 0; @@ -1555,6 +1557,7 @@ static dispatch_once_t initGlobalInterceptorFactory; XCTAssertNil(trailingMetadata); XCTAssertNotNil(error); XCTAssertEqual(error.code, GRPC_STATUS_CANCELLED); + [expectCallInternalComplete fulfill]; } didWriteDataHook:nil]; @@ -1596,7 +1599,7 @@ static dispatch_once_t initGlobalInterceptorFactory; XCTAssertEqual(index, 4, @"Received %i responses instead of 4.", index); - [expectation fulfill]; + [expectUserCallComplete fulfill]; }] callOptions:options]; [call start]; From ad61ae12359a0c493170499220e89530e6185c10 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 18 Jun 2019 14:23:06 -0700 Subject: [PATCH 0577/1555] clang-format --- .../GRPCClient/GRPCCall+Interceptor.m | 5 +- src/objective-c/GRPCClient/GRPCCall.m | 5 +- .../tests/InteropTests/InteropTests.m | 89 +++++++++---------- 3 files changed, 50 insertions(+), 49 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall+Interceptor.m b/src/objective-c/GRPCClient/GRPCCall+Interceptor.m index eed402f9c7e..0d9f1f6b9dc 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Interceptor.m +++ b/src/objective-c/GRPCClient/GRPCCall+Interceptor.m @@ -35,7 +35,10 @@ static dispatch_once_t onceToken; [globalInterceptorLock lock]; if (globalInterceptorFactory != nil) { [globalInterceptorLock unlock]; - [NSException raise:NSInternalInconsistencyException format:@"Global interceptor is already registered. Only one global interceptor can be registered in a process."]; + [NSException raise:NSInternalInconsistencyException + format: + @"Global interceptor is already registered. Only one global interceptor can be " + @"registered in a process."]; return; } diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index c25e8daaf4c..d5f4e9a84da 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -166,9 +166,8 @@ const char *kCFStreamVarName = "grpc_cfstream"; NSArray *interceptorFactories = _actualCallOptions.interceptorFactories; for (int i = (int)interceptorFactories.count - 1; i >= 0; i--) { GRPCInterceptorManager *manager = - [[GRPCInterceptorManager alloc] initWithNextInterceptor:nextInterceptor]; - GRPCInterceptor *interceptor = - [interceptorFactories[i] createInterceptorWithManager:manager]; + [[GRPCInterceptorManager alloc] initWithNextInterceptor:nextInterceptor]; + GRPCInterceptor *interceptor = [interceptorFactories[i] createInterceptorWithManager:manager]; NSAssert(interceptor != nil, @"Failed to create interceptor from factory: %@", interceptorFactories[i]); if (interceptor == nil) { diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 5587e78bfae..d8dc3f6c32d 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -144,7 +144,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager @end @implementation HookInterceptorFactory { -@protected + @protected void (^_startHook)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager); void (^_writeDataHook)(id data, GRPCInterceptorManager *manager); @@ -323,19 +323,18 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - (instancetype)initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue; -- (void)setStartHook:(void (^)(GRPCRequestOptions *requestOptions, - GRPCCallOptions *callOptions, +- (void)setStartHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook - finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook -receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, - GRPCInterceptorManager *manager))receiveNextMessagesHook - responseHeaderHook:(void (^)(NSDictionary *initialMetadata, - GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook - responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, - GRPCInterceptorManager *manager))responseCloseHook - didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook; + writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook + finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook + receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, + GRPCInterceptorManager *manager))receiveNextMessagesHook + responseHeaderHook:(void (^)(NSDictionary *initialMetadata, + GRPCInterceptorManager *manager))responseHeaderHook + responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook + responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager))responseCloseHook + didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook; @end @@ -374,19 +373,18 @@ receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, } } -- (void)setStartHook:(void (^)(GRPCRequestOptions *requestOptions, - GRPCCallOptions *callOptions, +- (void)setStartHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook - finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook -receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, - GRPCInterceptorManager *manager))receiveNextMessagesHook - responseHeaderHook:(void (^)(NSDictionary *initialMetadata, - GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook - responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, - GRPCInterceptorManager *manager))responseCloseHook - didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { + writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook + finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook + receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, + GRPCInterceptorManager *manager))receiveNextMessagesHook + responseHeaderHook:(void (^)(NSDictionary *initialMetadata, + GRPCInterceptorManager *manager))responseHeaderHook + responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook + responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager))responseCloseHook + didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { _startHook = startHook; _writeDataHook = writeDataHook; _finishHook = finishHook; @@ -448,8 +446,9 @@ static dispatch_once_t initGlobalInterceptorFactory; dispatch_once(&initGlobalInterceptorFactory, ^{ dispatch_queue_t globalInterceptorQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); - globalInterceptorFactory = [[GlobalInterceptorFactory alloc] initWithRequestDispatchQueue:globalInterceptorQueue - responseDispatchQueue:globalInterceptorQueue]; + globalInterceptorFactory = + [[GlobalInterceptorFactory alloc] initWithRequestDispatchQueue:globalInterceptorQueue + responseDispatchQueue:globalInterceptorQueue]; [GRPCCall2 registerGlobalInterceptor:globalInterceptorFactory]; }); } @@ -1628,15 +1627,15 @@ static dispatch_once_t initGlobalInterceptorFactory; __block NSUInteger responseDataCount = 0; __block NSUInteger responseCloseCount = 0; __block NSUInteger didWriteDataCount = 0; - [globalInterceptorFactory setStartHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, - GRPCInterceptorManager *manager) { - startCount++; - XCTAssertEqualObjects(requestOptions.host, [[self class] host]); - XCTAssertEqualObjects(requestOptions.path, @"/grpc.testing.TestService/FullDuplexCall"); - XCTAssertEqual(requestOptions.safety, GRPCCallSafetyDefault); - [manager startNextInterceptorWithRequest:[requestOptions copy] - callOptions:[callOptions copy]]; - } + [globalInterceptorFactory setStartHook:^(GRPCRequestOptions *requestOptions, + GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager) { + startCount++; + XCTAssertEqualObjects(requestOptions.host, [[self class] host]); + XCTAssertEqualObjects(requestOptions.path, @"/grpc.testing.TestService/FullDuplexCall"); + XCTAssertEqual(requestOptions.safety, GRPCCallSafetyDefault); + [manager startNextInterceptorWithRequest:[requestOptions copy] callOptions:[callOptions copy]]; + } writeDataHook:^(id data, GRPCInterceptorManager *manager) { writeDataCount++; [manager writeNextInterceptorWithData:data]; @@ -1813,15 +1812,15 @@ static dispatch_once_t initGlobalInterceptorFactory; __block NSUInteger globalResponseCloseCount = 0; __block NSUInteger globalDidWriteDataCount = 0; - [globalInterceptorFactory setStartHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, - GRPCInterceptorManager *manager) { - globalStartCount++; - XCTAssertEqualObjects(requestOptions.host, [[self class] host]); - XCTAssertEqualObjects(requestOptions.path, @"/grpc.testing.TestService/FullDuplexCall"); - XCTAssertEqual(requestOptions.safety, GRPCCallSafetyDefault); - [manager startNextInterceptorWithRequest:[requestOptions copy] - callOptions:[callOptions copy]]; - } + [globalInterceptorFactory setStartHook:^(GRPCRequestOptions *requestOptions, + GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager) { + globalStartCount++; + XCTAssertEqualObjects(requestOptions.host, [[self class] host]); + XCTAssertEqualObjects(requestOptions.path, @"/grpc.testing.TestService/FullDuplexCall"); + XCTAssertEqual(requestOptions.safety, GRPCCallSafetyDefault); + [manager startNextInterceptorWithRequest:[requestOptions copy] callOptions:[callOptions copy]]; + } writeDataHook:^(id data, GRPCInterceptorManager *manager) { globalWriteDataCount++; [manager writeNextInterceptorWithData:data]; From 63ffdf135fcd1a3cb9cbfb8751dbc05a62b8e390 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 18 Jun 2019 15:40:19 -0700 Subject: [PATCH 0578/1555] Bump version to 1.23.0 --- BUILD | 4 ++-- build.yaml | 4 ++-- doc/g_stands_for.md | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/BUILD b/BUILD index 108b0f79b94..8fd52808400 100644 --- a/BUILD +++ b/BUILD @@ -74,11 +74,11 @@ config_setting( ) # This should be updated along with build.yaml -g_stands_for = "gale" +g_stands_for = "gangnam" core_version = "7.0.0" -version = "1.22.0-dev" +version = "1.23.0-dev" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index bb53d6693fe..dad2146bd1c 100644 --- a/build.yaml +++ b/build.yaml @@ -13,8 +13,8 @@ settings: '#09': Per-language overrides are possible with (eg) ruby_version tag here '#10': See the expand_version.py for all the quirks here core_version: 7.0.0 - g_stands_for: gale - version: 1.22.0-dev + g_stands_for: gangnam + version: 1.23.0-dev filegroups: - name: alts_proto headers: diff --git a/doc/g_stands_for.md b/doc/g_stands_for.md index 90202b1b880..fe1cbc90005 100644 --- a/doc/g_stands_for.md +++ b/doc/g_stands_for.md @@ -21,4 +21,5 @@ - 1.19 'g' stands for ['gold'](https://github.com/grpc/grpc/tree/v1.19.x) - 1.20 'g' stands for ['godric'](https://github.com/grpc/grpc/tree/v1.20.x) - 1.21 'g' stands for ['gandalf'](https://github.com/grpc/grpc/tree/v1.21.x) -- 1.22 'g' stands for ['gale'](https://github.com/grpc/grpc/tree/master) +- 1.22 'g' stands for ['gale'](https://github.com/grpc/grpc/tree/v1.22.x) +- 1.23 'g' stands for ['gangnam'](https://github.com/grpc/grpc/tree/master) From cd27a369245723d8e3c75f1a9e6129a4f8ad2abd Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 18 Jun 2019 15:40:50 -0700 Subject: [PATCH 0579/1555] Regenerate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 4 ++-- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 4 ++-- src/core/lib/surface/version.cc | 2 +- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 4 ++-- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/composer.json | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 31 files changed, 35 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 13d54ec0cda..12998e1727f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.22.0-dev") +set(PACKAGE_VERSION "1.23.0-dev") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index d45c0992370..f2ef973a42e 100644 --- a/Makefile +++ b/Makefile @@ -460,8 +460,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.22.0-dev -CSHARP_VERSION = 1.22.0-dev +CPP_VERSION = 1.23.0-dev +CSHARP_VERSION = 1.23.0-dev CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 18ed5f89102..f0a4418b20c 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,7 +23,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.22.0-dev' + # version = '1.23.0-dev' version = '0.0.9-dev' s.version = version s.summary = 'gRPC C++ library' @@ -31,7 +31,7 @@ Pod::Spec.new do |s| s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.22.0-dev' + grpc_version = '1.23.0-dev' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 85add8fb7a2..2e34e8d7573 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.22.0-dev' + version = '1.23.0-dev' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 1cac59c6cc4..2c0441ba95c 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.22.0-dev' + version = '1.23.0-dev' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 6f033ea71b7..12a8728ac34 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.22.0-dev' + version = '1.23.0-dev' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index e9c3fd7bee0..bbfd08f9774 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.22.0-dev' + version = '1.23.0-dev' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index fd712698a62..616e1ece20e 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2018-01-19 - 1.22.0dev - 1.22.0dev + 1.23.0dev + 1.23.0dev beta diff --git a/src/core/lib/surface/version.cc b/src/core/lib/surface/version.cc index 7d9d49bc2aa..848a49d1eff 100644 --- a/src/core/lib/surface/version.cc +++ b/src/core/lib/surface/version.cc @@ -25,4 +25,4 @@ const char* grpc_version_string(void) { return "7.0.0"; } -const char* grpc_g_stands_for(void) { return "gale"; } +const char* grpc_g_stands_for(void) { return "gangnam"; } diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 76e2773e938..7fb7823c9f2 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.22.0-dev"; } +grpc::string Version() { return "1.23.0-dev"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index fb67fe622b5..6469aeb3f4b 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -33,11 +33,11 @@ namespace Grpc.Core /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "1.22.0.0"; + public const string CurrentAssemblyFileVersion = "1.23.0.0"; /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.22.0-dev"; + public const string CurrentVersion = "1.23.0-dev"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index dd5f172c27b..d9bf90ff007 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 1.22.0-dev + 1.23.0-dev 3.7.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index 2f4cd2739da..4211d70b235 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=1.22.0-dev +set VERSION=1.23.0-dev @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 401540209af..e9b5645d012 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.22.0-dev' + v = '1.23.0-dev' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 6fe0c396dd3..3b248db0148 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.22.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.23.0-dev" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index c835c1da190..231ba1a9a9f 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.22.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.23.0-dev" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/composer.json b/src/php/composer.json index ca1001b6d2b..e29c9c33fde 100644 --- a/src/php/composer.json +++ b/src/php/composer.json @@ -2,7 +2,7 @@ "name": "grpc/grpc-dev", "description": "gRPC library for PHP - for Developement use only", "license": "Apache-2.0", - "version": "1.22.0", + "version": "1.23.0", "require": { "php": ">=5.5.0", "google/protobuf": "^v3.3.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 3e9f88c61d6..bb707f50a9f 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.22.0dev" +#define PHP_GRPC_VERSION "1.23.0dev" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index 9f7ca9d5603..d2f8be43f34 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.22.0.dev0""" +__version__ = """1.23.0.dev0""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index 971fd37afb6..548d2810b5b 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.22.0.dev0' +VERSION = '1.23.0.dev0' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index 52baab4c30f..f7029fff484 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.22.0.dev0' +VERSION = '1.23.0.dev0' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index be4ca841361..d66daa473ed 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.22.0.dev0' +VERSION = '1.23.0.dev0' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 1efc4ee2c8d..97213872a91 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.22.0.dev0' +VERSION = '1.23.0.dev0' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index 9e443087755..31921b4cc90 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.22.0.dev0' +VERSION = '1.23.0.dev0' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 18d17e40464..5c8926cb6c8 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.22.0.dev0' +VERSION = '1.23.0.dev0' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index 401b0bd9697..a1fc87448a1 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.22.0.dev0' +VERSION = '1.23.0.dev0' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 75e6191216d..051bc067e55 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.22.0.dev' + VERSION = '1.23.0.dev' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index fbd0041fa35..e66a4a799fd 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.22.0.dev' + VERSION = '1.23.0.dev' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 24ec4301b65..127d3c1f9bc 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.22.0.dev0' +VERSION = '1.23.0.dev0' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 466bb5cd5a3..183ab0dff53 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.22.0-dev +PROJECT_NUMBER = 1.23.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 9b0f8f9fcd7..e2d753e02eb 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.22.0-dev +PROJECT_NUMBER = 1.23.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From 26769ae50fa0a29b3179f810ea3bbb1b9088766f Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 18 Jun 2019 15:43:54 -0700 Subject: [PATCH 0580/1555] Bump version to v1.22.0-pre1 --- BUILD | 2 +- build.yaml | 2 +- doc/g_stands_for.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/BUILD b/BUILD index 108b0f79b94..0ca0d9b7fd8 100644 --- a/BUILD +++ b/BUILD @@ -78,7 +78,7 @@ g_stands_for = "gale" core_version = "7.0.0" -version = "1.22.0-dev" +version = "1.22.0-pre1" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index bb53d6693fe..cce7d1bbe5c 100644 --- a/build.yaml +++ b/build.yaml @@ -14,7 +14,7 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 7.0.0 g_stands_for: gale - version: 1.22.0-dev + version: 1.22.0-pre1 filegroups: - name: alts_proto headers: diff --git a/doc/g_stands_for.md b/doc/g_stands_for.md index 90202b1b880..6acee77cf5d 100644 --- a/doc/g_stands_for.md +++ b/doc/g_stands_for.md @@ -21,4 +21,4 @@ - 1.19 'g' stands for ['gold'](https://github.com/grpc/grpc/tree/v1.19.x) - 1.20 'g' stands for ['godric'](https://github.com/grpc/grpc/tree/v1.20.x) - 1.21 'g' stands for ['gandalf'](https://github.com/grpc/grpc/tree/v1.21.x) -- 1.22 'g' stands for ['gale'](https://github.com/grpc/grpc/tree/master) +- 1.22 'g' stands for ['gale'](https://github.com/grpc/grpc/tree/v1.22.x) From ebfd812be149d325967c5b49ca4f2a7d1bb8a108 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 18 Jun 2019 15:44:33 -0700 Subject: [PATCH 0581/1555] Regenerate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 6 +++--- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 4 ++-- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 2 +- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 29 files changed, 33 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 13d54ec0cda..76f19024f0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.22.0-dev") +set(PACKAGE_VERSION "1.22.0-pre1") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index d45c0992370..0b1a9259d91 100644 --- a/Makefile +++ b/Makefile @@ -460,8 +460,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.22.0-dev -CSHARP_VERSION = 1.22.0-dev +CPP_VERSION = 1.22.0-pre1 +CSHARP_VERSION = 1.22.0-pre1 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 18ed5f89102..4cdf65fcc99 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,15 +23,15 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.22.0-dev' - version = '0.0.9-dev' + # version = '1.22.0-pre1' + version = '0.0.9-pre1' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.22.0-dev' + grpc_version = '1.22.0-pre1' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 85add8fb7a2..a40c9511fd2 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.22.0-dev' + version = '1.22.0-pre1' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 1cac59c6cc4..00609603438 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.22.0-dev' + version = '1.22.0-pre1' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 6f033ea71b7..b3423e97791 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.22.0-dev' + version = '1.22.0-pre1' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index e9c3fd7bee0..7b13447ff3f 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.22.0-dev' + version = '1.22.0-pre1' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index fd712698a62..01ed99d0f91 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2018-01-19 - 1.22.0dev - 1.22.0dev + 1.22.0RC1 + 1.22.0RC1 beta diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 76e2773e938..ebd4f7ef023 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.22.0-dev"; } +grpc::string Version() { return "1.22.0-pre1"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index fb67fe622b5..a9b73c24c27 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -38,6 +38,6 @@ namespace Grpc.Core /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.22.0-dev"; + public const string CurrentVersion = "1.22.0-pre1"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index dd5f172c27b..662ac407713 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 1.22.0-dev + 1.22.0-pre1 3.7.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index 2f4cd2739da..b2f855e10e7 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=1.22.0-dev +set VERSION=1.22.0-pre1 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 401540209af..37160fbd3fb 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.22.0-dev' + v = '1.22.0-pre1' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 6fe0c396dd3..05829ac102c 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.22.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.22.0-pre1" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index c835c1da190..68ea0849659 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.22.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.22.0-pre1" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 3e9f88c61d6..4ebb30d2ff5 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.22.0dev" +#define PHP_GRPC_VERSION "1.22.0RC1" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index 9f7ca9d5603..fa594107fec 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.22.0.dev0""" +__version__ = """1.22.0rc1""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index 971fd37afb6..e878336b40c 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.22.0.dev0' +VERSION = '1.22.0rc1' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index 52baab4c30f..edd2b36e5d3 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.22.0.dev0' +VERSION = '1.22.0rc1' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index be4ca841361..44b59737fd9 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.22.0.dev0' +VERSION = '1.22.0rc1' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 1efc4ee2c8d..02fc7b80423 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.22.0.dev0' +VERSION = '1.22.0rc1' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index 9e443087755..0b70be2fd4b 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.22.0.dev0' +VERSION = '1.22.0rc1' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 18d17e40464..21c75d294e8 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.22.0.dev0' +VERSION = '1.22.0rc1' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index 401b0bd9697..2bb40b514a6 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.22.0.dev0' +VERSION = '1.22.0rc1' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 75e6191216d..5e6d6de685a 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.22.0.dev' + VERSION = '1.22.0.pre1' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index fbd0041fa35..e86c6330a70 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.22.0.dev' + VERSION = '1.22.0.pre1' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 24ec4301b65..810493f00da 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.22.0.dev0' +VERSION = '1.22.0rc1' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 466bb5cd5a3..2de0dbb9af7 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.22.0-dev +PROJECT_NUMBER = 1.22.0-pre1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 9b0f8f9fcd7..ba8a287104a 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.22.0-dev +PROJECT_NUMBER = 1.22.0-pre1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From 02813afa65fab0f00209e65a4f687f5bc7712adc Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Tue, 18 Jun 2019 16:32:31 -0700 Subject: [PATCH 0582/1555] Extend thread class to accept setting stack size as a option --- src/core/lib/gprpp/thd.h | 12 +++++++++++- src/core/lib/gprpp/thd_posix.cc | 22 ++++++++++++++++++++++ src/core/lib/gprpp/thd_windows.cc | 10 +++++++++- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/core/lib/gprpp/thd.h b/src/core/lib/gprpp/thd.h index cae707061e0..6f29f82427f 100644 --- a/src/core/lib/gprpp/thd.h +++ b/src/core/lib/gprpp/thd.h @@ -49,7 +49,7 @@ class Thread { public: class Options { public: - Options() : joinable_(true), tracked_(true) {} + Options() : joinable_(true), tracked_(true), stack_size_(0) {} /// Set whether the thread is joinable or detached. Options& set_joinable(bool joinable) { joinable_ = joinable; @@ -64,9 +64,19 @@ class Thread { } bool tracked() const { return tracked_; } + /// Set thread stack size (in bytes). Set to 0 will reset stack size to + /// default value, which is 64KB for Windows threads and 2MB for Posix(x86) + /// threads. + Options& set_stack_size(size_t bytes) { + stack_size_ = bytes; + return *this; + } + size_t stack_size() const { return stack_size_; } + private: bool joinable_; bool tracked_; + size_t stack_size_; }; /// Default constructor only to allow use in structs that lack constructors /// Does not produce a validly-constructed thread; must later diff --git a/src/core/lib/gprpp/thd_posix.cc b/src/core/lib/gprpp/thd_posix.cc index 28932081538..5d202013b1d 100644 --- a/src/core/lib/gprpp/thd_posix.cc +++ b/src/core/lib/gprpp/thd_posix.cc @@ -31,6 +31,7 @@ #include #include #include +#include #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/fork.h" @@ -48,6 +49,22 @@ struct thd_arg { bool tracked; }; +size_t RoundUpToPageSize(size_t size) { + size_t page_size = static_cast(getpagesize()); + return (size + page_size - 1) & ~(page_size - 1); +} + +// Return the minimum valid stack size that can be passed to +// pthread_attr_setstacksize. +size_t MinValidStackSize(size_t request_size) { + if (request_size < _SC_THREAD_STACK_MIN) + request_size = _SC_THREAD_STACK_MIN; + + // On some systems, pthread_attr_setstacksize() can fail if stacksize is + // not a multiple of the system page size. + return RoundUpToPageSize(request_size); +} + class ThreadInternalsPosix : public internal::ThreadInternalsInterface { public: ThreadInternalsPosix(const char* thd_name, void (*thd_body)(void* arg), @@ -79,6 +96,11 @@ class ThreadInternalsPosix : public internal::ThreadInternalsInterface { 0); } + if (options.stack_size() != 0) { + size_t stack_size = MinValidStackSize(options.stack_size()); + GPR_ASSERT(pthread_attr_setstacksize(&attr, stack_size) == 0); + } + *success = (pthread_create(&pthread_id_, &attr, [](void* v) -> void* { diff --git a/src/core/lib/gprpp/thd_windows.cc b/src/core/lib/gprpp/thd_windows.cc index bbb48a58cd6..5014444dcfd 100644 --- a/src/core/lib/gprpp/thd_windows.cc +++ b/src/core/lib/gprpp/thd_windows.cc @@ -75,7 +75,15 @@ class ThreadInternalsWindows return; } } - handle = CreateThread(nullptr, 64 * 1024, thread_body, info_, 0, nullptr); + + if (options.stack_size() != 0) { + // Windows will round up the given stack_size value to nearest page. + handle = CreateThread(nullptr, options.stack_size(), thread_body, info_, + 0, nullptr); + } else { + handle = CreateThread(nullptr, 64 * 1024, thread_body, info_, 0, nullptr); + } + if (handle == nullptr) { destroy_thread(); *success = false; From 17d74286c7b793e9a9e9bc705f92605783de8ce3 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Tue, 18 Jun 2019 17:19:26 -0700 Subject: [PATCH 0583/1555] clang-format --- src/core/lib/gprpp/thd_posix.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/lib/gprpp/thd_posix.cc b/src/core/lib/gprpp/thd_posix.cc index 5d202013b1d..965a3ba229a 100644 --- a/src/core/lib/gprpp/thd_posix.cc +++ b/src/core/lib/gprpp/thd_posix.cc @@ -57,8 +57,9 @@ size_t RoundUpToPageSize(size_t size) { // Return the minimum valid stack size that can be passed to // pthread_attr_setstacksize. size_t MinValidStackSize(size_t request_size) { - if (request_size < _SC_THREAD_STACK_MIN) + if (request_size < _SC_THREAD_STACK_MIN) { request_size = _SC_THREAD_STACK_MIN; + } // On some systems, pthread_attr_setstacksize() can fail if stacksize is // not a multiple of the system page size. From afe91a47f7bb4366f8fe187fa83d12dab9300f57 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 19 Jun 2019 09:48:45 -0700 Subject: [PATCH 0584/1555] Update Protobuf version --- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/!ProtoCompiler.podspec | 2 +- .../src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 37160fbd3fb..2769bb3e4e3 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -101,7 +101,7 @@ Pod::Spec.new do |s| s.preserve_paths = plugin # Restrict the protoc version to the one supported by this plugin. - s.dependency '!ProtoCompiler', '3.7.0' + s.dependency '!ProtoCompiler', '3.8.0' # For the Protobuf dependency not to complain: s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' diff --git a/src/objective-c/!ProtoCompiler.podspec b/src/objective-c/!ProtoCompiler.podspec index 58d74be4d4e..d8ce4d8e89d 100644 --- a/src/objective-c/!ProtoCompiler.podspec +++ b/src/objective-c/!ProtoCompiler.podspec @@ -36,7 +36,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler' - v = '3.7.0' + v = '3.8.0' s.version = v s.summary = 'The Protobuf Compiler (protoc) generates Objective-C files from .proto files' s.description = <<-DESC diff --git a/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template b/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template index 741f9b7e54d..b2335ac8a9e 100644 --- a/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template +++ b/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template @@ -103,7 +103,7 @@ s.preserve_paths = plugin # Restrict the protoc version to the one supported by this plugin. - s.dependency '!ProtoCompiler', '3.7.0' + s.dependency '!ProtoCompiler', '3.8.0' # For the Protobuf dependency not to complain: s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' From 7a22143d7ab5f52620ab3ef2377b6090d1a8a3f7 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 19 Jun 2019 09:54:50 -0700 Subject: [PATCH 0585/1555] Run callbacks on same thread if trigerred from background thread --- src/core/lib/surface/completion_queue.cc | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index 60a7d78b525..55bfb6fcc30 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -857,17 +857,20 @@ static void cq_end_op_for_callback( } auto* functor = static_cast(tag); - if (internal) { + if (internal || grpc_iomgr_is_any_background_poller_thread()) { grpc_core::ApplicationCallbackExecCtx::Enqueue(functor, (error == GRPC_ERROR_NONE)); GRPC_ERROR_UNREF(error); - } else { - GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_CREATE( - functor_callback, functor, - grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), - error); + return; } + + // Schedule the shutdown callback on a closure if not internal or triggered + // from a background poller thread. + GRPC_CLOSURE_SCHED( + GRPC_CLOSURE_CREATE( + functor_callback, functor, + grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), + error); } void grpc_cq_end_op(grpc_completion_queue* cq, void* tag, grpc_error* error, @@ -1352,6 +1355,13 @@ static void cq_finish_shutdown_callback(grpc_completion_queue* cq) { GPR_ASSERT(cqd->shutdown_called); cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done); + if (grpc_iomgr_is_any_background_poller_thread()) { + grpc_core::ApplicationCallbackExecCtx::Enqueue(callback, true); + return; + } + + // Schedule the shutdown callback on a closure if not internal or triggered + // from a background poller thread. GRPC_CLOSURE_SCHED( GRPC_CLOSURE_CREATE( functor_callback, callback, From 7b0ee41fd5e48ba7d21d45511c0198bf520eda48 Mon Sep 17 00:00:00 2001 From: yang-g Date: Wed, 19 Jun 2019 10:28:35 -0700 Subject: [PATCH 0586/1555] Resolve comment --- include/grpcpp/impl/codegen/server_callback.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/grpcpp/impl/codegen/server_callback.h b/include/grpcpp/impl/codegen/server_callback.h index 6d83bc88e56..cd34ea3ff8c 100644 --- a/include/grpcpp/impl/codegen/server_callback.h +++ b/include/grpcpp/impl/codegen/server_callback.h @@ -348,7 +348,7 @@ class ServerBidiReactor : public internal::ServerReactor { private: friend class ServerCallbackReaderWriter; - // May be overridden by internal implementation details, this is not a public + // May be overridden by internal implementation details. This is not a public // customization point. virtual void InternalBindStream( ServerCallbackReaderWriter* stream) { @@ -385,7 +385,7 @@ class ServerReadReactor : public internal::ServerReactor { private: friend class ServerCallbackReader; - // May be overridden by internal implementation details, this is not a public + // May be overridden by internal implementation details. This is not a public // customization point. virtual void InternalBindReader(ServerCallbackReader* reader) { reader_ = reader; @@ -431,7 +431,7 @@ class ServerWriteReactor : public internal::ServerReactor { private: friend class ServerCallbackWriter; - // May be overridden by internal implementation details, this is not a public + // May be overridden by internal implementation details. This is not a public // customization point. virtual void InternalBindWriter(ServerCallbackWriter* writer) { writer_ = writer; From 6a7bbbc1bd4668d2001eed5c846e04f87bd353f8 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 19 Jun 2019 10:31:47 -0700 Subject: [PATCH 0587/1555] Fix objc tests pull request failures --- tools/internal_ci/helper_scripts/prepare_build_macos_rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/internal_ci/helper_scripts/prepare_build_macos_rc b/tools/internal_ci/helper_scripts/prepare_build_macos_rc index b8f37560148..e2f52e73117 100644 --- a/tools/internal_ci/helper_scripts/prepare_build_macos_rc +++ b/tools/internal_ci/helper_scripts/prepare_build_macos_rc @@ -25,7 +25,7 @@ export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/GrpcTesting-d0eeee2db3 # If this is a PR using RUN_TESTS_FLAGS var, then add flags to filter tests if [ -n "$KOKORO_GITHUB_PULL_REQUEST_NUMBER" ]; then - export RUN_TESTS_FLAGS="$RUN_TESTS_FLAGS --filter_pr_tests --base_branch origin/$KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH" + export RUN_TESTS_FLAGS="--filter_pr_tests --base_branch origin/$KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH $RUN_TESTS_FLAGS" fi set +ex # rvm script is very verbose and exits with errorcode From ec8777c6aabcc912d3f5cc501e647ec72f90fa19 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 1 Apr 2019 16:43:06 -0700 Subject: [PATCH 0588/1555] Add protobuf pod version sanitizer --- tools/distrib/check_protobuf_pod_version.sh | 46 +++++++++++++++++++++ tools/run_tests/sanity/sanity_tests.yaml | 1 + 2 files changed, 47 insertions(+) create mode 100755 tools/distrib/check_protobuf_pod_version.sh diff --git a/tools/distrib/check_protobuf_pod_version.sh b/tools/distrib/check_protobuf_pod_version.sh new file mode 100755 index 00000000000..174931a0d18 --- /dev/null +++ b/tools/distrib/check_protobuf_pod_version.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +cd `dirname $0`/../.. + +# get the version of protobuf in /third_party/protobuf +pushd third_party/protobuf + +version1=$(git describe --tags | cut -f 1 -d'-') +v1=${version1:1} + +popd + +# get the version of protobuf in /src/objective-c/!ProtoCompiler.podspec +v2=$(cat src/objective-c/\!ProtoCompiler.podspec | egrep "v = " | cut -f 2 -d"'") + +# get the version of protobuf in /src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +v3=$(cat src/objective-c/\!ProtoCompiler-gRPCPlugin.podspec | egrep 'dependency.*!ProtoCompiler' | cut -f 4 -d"'") + +# compare and emit error +ret=0 +if [ $v1 != $v2 ]; then + echo 'Protobuf version in src/objective-c/!ProtoCompiler.podspec does not match protobuf version in third_party/protobuf.' + ret=1 +fi + +if [ $v1 != $v3 ]; then + echo 'Protobuf version in src/objective-c/!ProtoCompiler-gRPCPlugin.podspec does not match protobuf version in third_party/protobuf.' + ret=1 +fi + +exit $ret diff --git a/tools/run_tests/sanity/sanity_tests.yaml b/tools/run_tests/sanity/sanity_tests.yaml index 1913edd4257..065be90108c 100644 --- a/tools/run_tests/sanity/sanity_tests.yaml +++ b/tools/run_tests/sanity/sanity_tests.yaml @@ -24,4 +24,5 @@ - script: tools/distrib/yapf_code.sh - script: tools/distrib/python/check_grpcio_tools.py - script: tools/distrib/check_shadow_boringssl_symbol_list.sh +- script: tools/distrib/check_protobuf_pod_version.sh cpu_cost: 1000 From 67e6b03e92626bc8c8f236b90bfa676ae7eadbc4 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Wed, 19 Jun 2019 11:34:01 -0700 Subject: [PATCH 0589/1555] Fix compression algorithm parsing --- .../message_compress_filter.cc | 256 ++++++++---------- src/core/lib/compression/compression.cc | 3 +- src/core/lib/compression/compression_args.cc | 19 +- src/core/lib/compression/compression_args.h | 5 +- .../lib/compression/compression_internal.cc | 2 +- src/core/lib/surface/call.cc | 11 +- test/core/compression/algorithm_test.cc | 15 +- test/core/compression/compression_test.cc | 4 +- test/core/end2end/fixtures/h2_compress.cc | 10 +- test/core/end2end/tests/compressed_payload.cc | 10 +- .../stream_compression_compressed_payload.cc | 12 +- .../tests/stream_compression_payload.cc | 10 +- .../stream_compression_ping_pong_streaming.cc | 10 +- .../tests/workaround_cronet_compression.cc | 4 +- 14 files changed, 179 insertions(+), 192 deletions(-) diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.cc b/src/core/ext/filters/http/message_compress/message_compress_filter.cc index d2b1f6794cd..3ce79b305df 100644 --- a/src/core/ext/filters/http/message_compress/message_compress_filter.cc +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.cc @@ -45,18 +45,30 @@ static void send_message_on_complete(void* arg, grpc_error* error); static void on_send_message_next_done(void* arg, grpc_error* error); namespace { -enum initial_metadata_state { - // Initial metadata not yet seen. - INITIAL_METADATA_UNSEEN = 0, - // Initial metadata seen; compression algorithm set. - HAS_COMPRESSION_ALGORITHM, - // Initial metadata seen; no compression algorithm set. - NO_COMPRESSION_ALGORITHM, + +struct channel_data { + /** The default, channel-level, compression algorithm */ + grpc_compression_algorithm default_compression_algorithm; + /** Bitset of enabled compression algorithms */ + uint32_t enabled_compression_algorithms_bitset; + /** Bitset of enabled message compression algorithms */ + uint32_t enabled_message_compression_algorithms_bitset; + /** Bitset of enabled stream compression algorithms */ + uint32_t enabled_stream_compression_algorithms_bitset; }; struct call_data { call_data(grpc_call_element* elem, const grpc_call_element_args& args) : call_combiner(args.call_combiner) { + channel_data* channeld = static_cast(elem->channel_data); + // The call's message compression algorithm is set to channel's default + // setting. It can be overridden later by initial metadata. + if (GPR_LIKELY(GPR_BITGET(channeld->enabled_compression_algorithms_bitset, + channeld->default_compression_algorithm))) { + message_compression_algorithm = + grpc_compression_algorithm_to_message_compression_algorithm( + channeld->default_compression_algorithm); + } GRPC_CLOSURE_INIT(&start_send_message_batch_in_call_combiner, start_send_message_batch, elem, grpc_schedule_on_exec_ctx); @@ -73,15 +85,13 @@ struct call_data { } grpc_core::CallCombiner* call_combiner; - grpc_linked_mdelem compression_algorithm_storage; + grpc_linked_mdelem message_compression_algorithm_storage; grpc_linked_mdelem stream_compression_algorithm_storage; grpc_linked_mdelem accept_encoding_storage; grpc_linked_mdelem accept_stream_encoding_storage; - /** Compression algorithm we'll try to use. It may be given by incoming - * metadata, or by the channel's default compression settings. */ grpc_message_compression_algorithm message_compression_algorithm = GRPC_MESSAGE_COMPRESS_NONE; - initial_metadata_state send_initial_metadata_state = INITIAL_METADATA_UNSEEN; + bool seen_initial_metadata = false; grpc_error* cancel_error = GRPC_ERROR_NONE; grpc_closure start_send_message_batch_in_call_combiner; grpc_transport_stream_op_batch* send_message_batch = nullptr; @@ -93,130 +103,104 @@ struct call_data { grpc_closure on_send_message_next_done; }; -struct channel_data { - /** The default, channel-level, compression algorithm */ - grpc_compression_algorithm default_compression_algorithm; - /** Bitset of enabled compression algorithms */ - uint32_t enabled_algorithms_bitset; - /** Supported compression algorithms */ - uint32_t supported_message_compression_algorithms; - /** Supported stream compression algorithms */ - uint32_t supported_stream_compression_algorithms; -}; } // namespace -static bool skip_compression(grpc_call_element* elem, uint32_t flags, - bool has_compression_algorithm) { +// Returns true if we should skip message compression for the current message. +static bool skip_message_compression(grpc_call_element* elem) { call_data* calld = static_cast(elem->call_data); - channel_data* channeld = static_cast(elem->channel_data); - + // If the flags of this message indicate that it shouldn't be compressed, we + // skip message compression. + uint32_t flags = + calld->send_message_batch->payload->send_message.send_message->flags(); if (flags & (GRPC_WRITE_NO_COMPRESS | GRPC_WRITE_INTERNAL_COMPRESS)) { return true; } - if (has_compression_algorithm) { - if (calld->message_compression_algorithm == GRPC_MESSAGE_COMPRESS_NONE) { - return true; - } - return false; /* we have an actual call-specific algorithm */ - } - /* no per-call compression override */ - return channeld->default_compression_algorithm == GRPC_COMPRESS_NONE; + // If this call doesn't have any message compression algorithm set, skip + // message compression. + return calld->message_compression_algorithm == GRPC_MESSAGE_COMPRESS_NONE; +} + +// Determines the compression algorithm from the initial metadata and the +// channel's default setting. +static grpc_compression_algorithm find_compression_algorithm( + grpc_metadata_batch* initial_metadata, channel_data* channeld) { + if (initial_metadata->idx.named.grpc_internal_encoding_request == nullptr) { + return channeld->default_compression_algorithm; + } + grpc_compression_algorithm compression_algorithm; + // Parse the compression algorithm from the initial metadata. + grpc_mdelem md = + initial_metadata->idx.named.grpc_internal_encoding_request->md; + GPR_ASSERT(grpc_compression_algorithm_parse(GRPC_MDVALUE(md), + &compression_algorithm)); + // Remove this metadata since it's an internal one (i.e., it won't be + // transmitted out). + grpc_metadata_batch_remove( + initial_metadata, + initial_metadata->idx.named.grpc_internal_encoding_request); + // Check if that algorithm is enabled. Note that GRPC_COMPRESS_NONE is always + // enabled. + // TODO(juanlishen): Maybe use channel default or abort() if the algorithm + // from the initial metadata is disabled. + if (GPR_LIKELY(GPR_BITGET(channeld->enabled_compression_algorithms_bitset, + compression_algorithm))) { + return compression_algorithm; + } + const char* algorithm_name; + GPR_ASSERT( + grpc_compression_algorithm_name(compression_algorithm, &algorithm_name)); + gpr_log(GPR_ERROR, + "Invalid compression algorithm from initial metadata: '%s' " + "(previously disabled). " + "Will not compress.", + algorithm_name); + return GRPC_COMPRESS_NONE; } -/** Filter initial metadata */ static grpc_error* process_send_initial_metadata( - grpc_call_element* elem, grpc_metadata_batch* initial_metadata, - bool* has_compression_algorithm) GRPC_MUST_USE_RESULT; + grpc_call_element* elem, + grpc_metadata_batch* initial_metadata) GRPC_MUST_USE_RESULT; static grpc_error* process_send_initial_metadata( - grpc_call_element* elem, grpc_metadata_batch* initial_metadata, - bool* has_compression_algorithm) { + grpc_call_element* elem, grpc_metadata_batch* initial_metadata) { call_data* calld = static_cast(elem->call_data); channel_data* channeld = static_cast(elem->channel_data); - *has_compression_algorithm = false; - grpc_compression_algorithm compression_algorithm; + // Find the compression algorithm. + grpc_compression_algorithm compression_algorithm = + find_compression_algorithm(initial_metadata, channeld); + // Note that at most one of the following algorithms can be set. + calld->message_compression_algorithm = + grpc_compression_algorithm_to_message_compression_algorithm( + compression_algorithm); grpc_stream_compression_algorithm stream_compression_algorithm = - GRPC_STREAM_COMPRESS_NONE; - if (initial_metadata->idx.named.grpc_internal_encoding_request != nullptr) { - grpc_mdelem md = - initial_metadata->idx.named.grpc_internal_encoding_request->md; - if (GPR_UNLIKELY(!grpc_compression_algorithm_parse( - GRPC_MDVALUE(md), &compression_algorithm))) { - char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); - gpr_log(GPR_ERROR, - "Invalid compression algorithm: '%s' (unknown). Ignoring.", val); - gpr_free(val); - calld->message_compression_algorithm = GRPC_MESSAGE_COMPRESS_NONE; - stream_compression_algorithm = GRPC_STREAM_COMPRESS_NONE; - } - if (GPR_UNLIKELY(!GPR_BITGET(channeld->enabled_algorithms_bitset, - compression_algorithm))) { - char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); - gpr_log(GPR_ERROR, - "Invalid compression algorithm: '%s' (previously disabled). " - "Ignoring.", - val); - gpr_free(val); - calld->message_compression_algorithm = GRPC_MESSAGE_COMPRESS_NONE; - stream_compression_algorithm = GRPC_STREAM_COMPRESS_NONE; - } - *has_compression_algorithm = true; - grpc_metadata_batch_remove( - initial_metadata, - initial_metadata->idx.named.grpc_internal_encoding_request); - calld->message_compression_algorithm = - grpc_compression_algorithm_to_message_compression_algorithm( - compression_algorithm); - stream_compression_algorithm = - grpc_compression_algorithm_to_stream_compression_algorithm( - compression_algorithm); - } else { - /* If no algorithm was found in the metadata and we aren't - * exceptionally skipping compression, fall back to the channel - * default */ - if (channeld->default_compression_algorithm != GRPC_COMPRESS_NONE) { - calld->message_compression_algorithm = - grpc_compression_algorithm_to_message_compression_algorithm( - channeld->default_compression_algorithm); - stream_compression_algorithm = - grpc_compression_algorithm_to_stream_compression_algorithm( - channeld->default_compression_algorithm); - } - *has_compression_algorithm = true; - } - + grpc_compression_algorithm_to_stream_compression_algorithm( + compression_algorithm); + // Hint compression algorithm. grpc_error* error = GRPC_ERROR_NONE; - /* hint compression algorithm */ - if (stream_compression_algorithm != GRPC_STREAM_COMPRESS_NONE) { + if (calld->message_compression_algorithm != GRPC_MESSAGE_COMPRESS_NONE) { + error = grpc_metadata_batch_add_tail( + initial_metadata, &calld->message_compression_algorithm_storage, + grpc_message_compression_encoding_mdelem( + calld->message_compression_algorithm)); + } else if (stream_compression_algorithm != GRPC_STREAM_COMPRESS_NONE) { error = grpc_metadata_batch_add_tail( initial_metadata, &calld->stream_compression_algorithm_storage, grpc_stream_compression_encoding_mdelem(stream_compression_algorithm)); - } else if (calld->message_compression_algorithm != - GRPC_MESSAGE_COMPRESS_NONE) { - error = grpc_metadata_batch_add_tail( - initial_metadata, &calld->compression_algorithm_storage, - grpc_message_compression_encoding_mdelem( - calld->message_compression_algorithm)); } - if (error != GRPC_ERROR_NONE) return error; - - /* convey supported compression algorithms */ + // Convey supported compression algorithms. error = grpc_metadata_batch_add_tail( initial_metadata, &calld->accept_encoding_storage, GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS( - channeld->supported_message_compression_algorithms)); - + channeld->enabled_message_compression_algorithms_bitset)); if (error != GRPC_ERROR_NONE) return error; - - /* Do not overwrite accept-encoding header if it already presents (e.g. added - * by some proxy). */ + // Do not overwrite accept-encoding header if it already presents (e.g., added + // by some proxy). if (!initial_metadata->idx.named.accept_encoding) { error = grpc_metadata_batch_add_tail( initial_metadata, &calld->accept_stream_encoding_storage, GRPC_MDELEM_ACCEPT_STREAM_ENCODING_FOR_ALGORITHMS( - channeld->supported_stream_compression_algorithms)); + channeld->enabled_stream_compression_algorithms_bitset)); } - return error; } @@ -358,12 +342,7 @@ static void on_send_message_next_done(void* arg, grpc_error* error) { static void start_send_message_batch(void* arg, grpc_error* unused) { grpc_call_element* elem = static_cast(arg); - call_data* calld = static_cast(elem->call_data); - if (skip_compression( - elem, - calld->send_message_batch->payload->send_message.send_message - ->flags(), - calld->send_initial_metadata_state == HAS_COMPRESSION_ALGORITHM)) { + if (skip_message_compression(elem)) { send_message_batch_continue(elem); } else { continue_reading_send_message(elem); @@ -380,7 +359,7 @@ static void compress_start_transport_stream_op_batch( calld->cancel_error = GRPC_ERROR_REF(batch->payload->cancel_stream.cancel_error); if (calld->send_message_batch != nullptr) { - if (calld->send_initial_metadata_state == INITIAL_METADATA_UNSEEN) { + if (!calld->seen_initial_metadata) { GRPC_CALL_COMBINER_START( calld->call_combiner, GRPC_CLOSURE_CREATE(fail_send_message_batch_in_call_combiner, calld, @@ -398,19 +377,15 @@ static void compress_start_transport_stream_op_batch( } // Handle send_initial_metadata. if (batch->send_initial_metadata) { - GPR_ASSERT(calld->send_initial_metadata_state == INITIAL_METADATA_UNSEEN); - bool has_compression_algorithm; + GPR_ASSERT(!calld->seen_initial_metadata); grpc_error* error = process_send_initial_metadata( - elem, batch->payload->send_initial_metadata.send_initial_metadata, - &has_compression_algorithm); + elem, batch->payload->send_initial_metadata.send_initial_metadata); if (error != GRPC_ERROR_NONE) { grpc_transport_stream_op_batch_finish_with_failure(batch, error, calld->call_combiner); return; } - calld->send_initial_metadata_state = has_compression_algorithm - ? HAS_COMPRESSION_ALGORITHM - : NO_COMPRESSION_ALGORITHM; + calld->seen_initial_metadata = true; // If we had previously received a batch containing a send_message op, // handle it now. Note that we need to re-enter the call combiner // for this, since we can't send two batches down while holding the @@ -431,7 +406,7 @@ static void compress_start_transport_stream_op_batch( // wait. We save the batch in calld and then drop the call // combiner, which we'll have to pick up again later when we get // send_initial_metadata. - if (calld->send_initial_metadata_state == INITIAL_METADATA_UNSEEN) { + if (!calld->seen_initial_metadata) { GRPC_CALL_COMBINER_STOP( calld->call_combiner, "send_message batch pending send_initial_metadata"); @@ -463,34 +438,29 @@ static void destroy_call_elem(grpc_call_element* elem, static grpc_error* init_channel_elem(grpc_channel_element* elem, grpc_channel_element_args* args) { channel_data* channeld = static_cast(elem->channel_data); - - channeld->enabled_algorithms_bitset = + // Get the enabled and the default algorithms from channel args. + channeld->enabled_compression_algorithms_bitset = grpc_channel_args_compression_algorithm_get_states(args->channel_args); channeld->default_compression_algorithm = - grpc_channel_args_get_compression_algorithm(args->channel_args); - - /* Make sure the default isn't disabled. */ - if (!GPR_BITGET(channeld->enabled_algorithms_bitset, + grpc_channel_args_get_channel_default_compression_algorithm( + args->channel_args); + // Make sure the default is enabled. + if (!GPR_BITGET(channeld->enabled_compression_algorithms_bitset, channeld->default_compression_algorithm)) { - gpr_log(GPR_DEBUG, - "compression algorithm %d not enabled: switching to none", - channeld->default_compression_algorithm); + const char* name; + GPR_ASSERT(grpc_compression_algorithm_name( + channeld->default_compression_algorithm, &name) == 1); + gpr_log(GPR_ERROR, + "default compression algorithm %s not enabled: switching to none", + name); channeld->default_compression_algorithm = GRPC_COMPRESS_NONE; } - - uint32_t supported_compression_algorithms = - (((1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1) & - channeld->enabled_algorithms_bitset) | - 1u; - - channeld->supported_message_compression_algorithms = + channeld->enabled_message_compression_algorithms_bitset = grpc_compression_bitset_to_message_bitset( - supported_compression_algorithms); - - channeld->supported_stream_compression_algorithms = + channeld->enabled_compression_algorithms_bitset); + channeld->enabled_stream_compression_algorithms_bitset = grpc_compression_bitset_to_stream_bitset( - supported_compression_algorithms); - + channeld->enabled_compression_algorithms_bitset); GPR_ASSERT(!args->is_last); return GRPC_ERROR_NONE; } diff --git a/src/core/lib/compression/compression.cc b/src/core/lib/compression/compression.cc index a3a069d9266..2f35e5fa03f 100644 --- a/src/core/lib/compression/compression.cc +++ b/src/core/lib/compression/compression.cc @@ -59,12 +59,11 @@ int grpc_compression_algorithm_parse(grpc_slice name, } else { return 0; } - return 0; } int grpc_compression_algorithm_name(grpc_compression_algorithm algorithm, const char** name) { - GRPC_API_TRACE("grpc_compression_algorithm_parse(algorithm=%d, name=%p)", 2, + GRPC_API_TRACE("grpc_compression_algorithm_name(algorithm=%d, name=%p)", 2, ((int)algorithm, name)); switch (algorithm) { case GRPC_COMPRESS_NONE: diff --git a/src/core/lib/compression/compression_args.cc b/src/core/lib/compression/compression_args.cc index 6a8232dc033..6bbda64e263 100644 --- a/src/core/lib/compression/compression_args.cc +++ b/src/core/lib/compression/compression_args.cc @@ -32,21 +32,25 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" -grpc_compression_algorithm grpc_channel_args_get_compression_algorithm( +grpc_compression_algorithm +grpc_channel_args_get_channel_default_compression_algorithm( const grpc_channel_args* a) { size_t i; if (a == nullptr) return GRPC_COMPRESS_NONE; for (i = 0; i < a->num_args; ++i) { if (a->args[i].type == GRPC_ARG_INTEGER && !strcmp(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM, a->args[i].key)) { - return static_cast(a->args[i].value.integer); - break; + grpc_compression_algorithm default_algorithm = + static_cast(a->args[i].value.integer); + return default_algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT + ? default_algorithm + : GRPC_COMPRESS_NONE; } } return GRPC_COMPRESS_NONE; } -grpc_channel_args* grpc_channel_args_set_compression_algorithm( +grpc_channel_args* grpc_channel_args_set_channel_default_compression_algorithm( grpc_channel_args* a, grpc_compression_algorithm algorithm) { GPR_ASSERT(algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT); grpc_arg tmp; @@ -68,7 +72,9 @@ static int find_compression_algorithm_states_bitset(const grpc_channel_args* a, !strcmp(GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET, a->args[i].key)) { *states_arg = &a->args[i].value.integer; - **states_arg |= 0x1; /* forcefully enable support for no compression */ + **states_arg = + (**states_arg & ((1 << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1)) | + 0x1; /* forcefully enable support for no compression */ return 1; } } @@ -83,7 +89,8 @@ grpc_channel_args* grpc_channel_args_compression_algorithm_set_state( const int states_arg_found = find_compression_algorithm_states_bitset(*a, &states_arg); - if (grpc_channel_args_get_compression_algorithm(*a) == algorithm && + if (grpc_channel_args_get_channel_default_compression_algorithm(*a) == + algorithm && state == 0) { const char* algo_name = nullptr; GPR_ASSERT(grpc_compression_algorithm_name(algorithm, &algo_name) != 0); diff --git a/src/core/lib/compression/compression_args.h b/src/core/lib/compression/compression_args.h index 407d6e2b8ca..f1abc122cea 100644 --- a/src/core/lib/compression/compression_args.h +++ b/src/core/lib/compression/compression_args.h @@ -25,13 +25,14 @@ #include /** Returns the compression algorithm set in \a a. */ -grpc_compression_algorithm grpc_channel_args_get_compression_algorithm( +grpc_compression_algorithm +grpc_channel_args_get_channel_default_compression_algorithm( const grpc_channel_args* a); /** Returns a channel arg instance with compression enabled. If \a a is * non-NULL, its args are copied. N.B. GRPC_COMPRESS_NONE disables compression * for the channel. */ -grpc_channel_args* grpc_channel_args_set_compression_algorithm( +grpc_channel_args* grpc_channel_args_set_channel_default_compression_algorithm( grpc_channel_args* a, grpc_compression_algorithm algorithm); /** Sets the support for the given compression algorithm. By default, all diff --git a/src/core/lib/compression/compression_internal.cc b/src/core/lib/compression/compression_internal.cc index e0d73ef6d83..e0cf6d45194 100644 --- a/src/core/lib/compression/compression_internal.cc +++ b/src/core/lib/compression/compression_internal.cc @@ -171,7 +171,7 @@ int grpc_compression_algorithm_from_message_stream_compression_algorithm( int grpc_message_compression_algorithm_name( grpc_message_compression_algorithm algorithm, const char** name) { GRPC_API_TRACE( - "grpc_message_compression_algorithm_parse(algorithm=%d, name=%p)", 2, + "grpc_message_compression_algorithm_name(algorithm=%d, name=%p)", 2, ((int)algorithm, name)); switch (algorithm) { case GRPC_MESSAGE_COMPRESS_NONE: diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 2ccd3355594..13b1d126393 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -1568,6 +1568,10 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops, error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS; goto done_with_error; } + // TODO(juanlishen): If the user has already specified a compression + // algorithm by setting the initial metadata with key of + // GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY, we shouldn't override that + // with the compression algorithm mapped from compression level. /* process compression level */ grpc_metadata& compression_md = call->compression_md; compression_md.key = grpc_empty_slice(); @@ -1589,17 +1593,18 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops, effective_compression_level = copts.default_level.level; } } + // Currently, only server side supports compression level setting. if (level_set && !call->is_client) { const grpc_compression_algorithm calgo = compression_algorithm_for_level_locked( call, effective_compression_level); - /* the following will be picked up by the compress filter and used - * as the call's compression algorithm. */ + // The following metadata will be checked and removed by the message + // compression filter. It will be used as the call's compression + // algorithm. compression_md.key = GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST; compression_md.value = grpc_compression_algorithm_slice(calgo); additional_metadata_count++; } - if (op->data.send_initial_metadata.count + additional_metadata_count > INT_MAX) { error = GRPC_CALL_ERROR_INVALID_METADATA; diff --git a/test/core/compression/algorithm_test.cc b/test/core/compression/algorithm_test.cc index 24fe83774b8..c32820f08f4 100644 --- a/test/core/compression/algorithm_test.cc +++ b/test/core/compression/algorithm_test.cc @@ -80,20 +80,20 @@ static void test_algorithm_mesh(void) { } static void test_algorithm_failure(void) { - grpc_core::ExecCtx exec_ctx; - grpc_slice mdstr; - gpr_log(GPR_DEBUG, "test_algorithm_failure"); - + // Test invalid algorithm name + grpc_slice mdstr = + grpc_slice_from_static_string("this-is-an-invalid-algorithm"); + GPR_ASSERT(grpc_compression_algorithm_from_slice(mdstr) == + GRPC_COMPRESS_ALGORITHMS_COUNT); + grpc_slice_unref_internal(mdstr); + // Test invalid algorithm enum entry. GPR_ASSERT(grpc_compression_algorithm_name(GRPC_COMPRESS_ALGORITHMS_COUNT, nullptr) == 0); GPR_ASSERT( grpc_compression_algorithm_name(static_cast( GRPC_COMPRESS_ALGORITHMS_COUNT + 1), nullptr) == 0); - mdstr = grpc_slice_from_static_string("this-is-an-invalid-algorithm"); - GPR_ASSERT(grpc_compression_algorithm_from_slice(mdstr) == - GRPC_COMPRESS_ALGORITHMS_COUNT); GPR_ASSERT(grpc_slice_eq( grpc_compression_algorithm_slice(GRPC_COMPRESS_ALGORITHMS_COUNT), grpc_empty_slice())); @@ -101,7 +101,6 @@ static void test_algorithm_failure(void) { grpc_compression_algorithm_slice(static_cast( static_cast(GRPC_COMPRESS_ALGORITHMS_COUNT) + 1)), grpc_empty_slice())); - grpc_slice_unref_internal(mdstr); } int main(int argc, char** argv) { diff --git a/test/core/compression/compression_test.cc b/test/core/compression/compression_test.cc index cf6d18847e6..aa54241135c 100644 --- a/test/core/compression/compression_test.cc +++ b/test/core/compression/compression_test.cc @@ -265,8 +265,8 @@ static void test_channel_args_set_compression_algorithm(void) { grpc_core::ExecCtx exec_ctx; grpc_channel_args* ch_args; - ch_args = - grpc_channel_args_set_compression_algorithm(nullptr, GRPC_COMPRESS_GZIP); + ch_args = grpc_channel_args_set_channel_default_compression_algorithm( + nullptr, GRPC_COMPRESS_GZIP); GPR_ASSERT(ch_args->num_args == 1); GPR_ASSERT(strcmp(ch_args->args[0].key, GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM) == 0); diff --git a/test/core/end2end/fixtures/h2_compress.cc b/test/core/end2end/fixtures/h2_compress.cc index f97192fecaa..01e5ae1b7b5 100644 --- a/test/core/end2end/fixtures/h2_compress.cc +++ b/test/core/end2end/fixtures/h2_compress.cc @@ -69,8 +69,9 @@ void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture* f, grpc_core::ExecCtx exec_ctx; grpc_channel_args_destroy(ffd->client_args_compression); } - ffd->client_args_compression = grpc_channel_args_set_compression_algorithm( - client_args, GRPC_COMPRESS_GZIP); + ffd->client_args_compression = + grpc_channel_args_set_channel_default_compression_algorithm( + client_args, GRPC_COMPRESS_GZIP); f->client = grpc_insecure_channel_create( ffd->localaddr, ffd->client_args_compression, nullptr); } @@ -83,8 +84,9 @@ void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture* f, grpc_core::ExecCtx exec_ctx; grpc_channel_args_destroy(ffd->server_args_compression); } - ffd->server_args_compression = grpc_channel_args_set_compression_algorithm( - server_args, GRPC_COMPRESS_GZIP); + ffd->server_args_compression = + grpc_channel_args_set_channel_default_compression_algorithm( + server_args, GRPC_COMPRESS_GZIP); if (f->server) { grpc_server_destroy(f->server); } diff --git a/test/core/end2end/tests/compressed_payload.cc b/test/core/end2end/tests/compressed_payload.cc index 2b9ab5d642a..81e6bfccd10 100644 --- a/test/core/end2end/tests/compressed_payload.cc +++ b/test/core/end2end/tests/compressed_payload.cc @@ -124,10 +124,10 @@ static void request_for_disabled_algorithm( request_payload_slice = grpc_slice_from_copied_string(str); request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - client_args = grpc_channel_args_set_compression_algorithm( + client_args = grpc_channel_args_set_channel_default_compression_algorithm( nullptr, requested_client_compression_algorithm); - server_args = - grpc_channel_args_set_compression_algorithm(nullptr, GRPC_COMPRESS_NONE); + server_args = grpc_channel_args_set_channel_default_compression_algorithm( + nullptr, GRPC_COMPRESS_NONE); { grpc_core::ExecCtx exec_ctx; server_args = grpc_channel_args_compression_algorithm_set_state( @@ -308,9 +308,9 @@ static void request_with_payload_template( grpc_slice response_payload_slice = grpc_slice_from_copied_string(response_str); - client_args = grpc_channel_args_set_compression_algorithm( + client_args = grpc_channel_args_set_channel_default_compression_algorithm( nullptr, default_client_channel_compression_algorithm); - server_args = grpc_channel_args_set_compression_algorithm( + server_args = grpc_channel_args_set_channel_default_compression_algorithm( nullptr, default_server_channel_compression_algorithm); f = begin_test(config, test_name, client_args, server_args); diff --git a/test/core/end2end/tests/stream_compression_compressed_payload.cc b/test/core/end2end/tests/stream_compression_compressed_payload.cc index 39f95b85baa..9f40da100b4 100644 --- a/test/core/end2end/tests/stream_compression_compressed_payload.cc +++ b/test/core/end2end/tests/stream_compression_compressed_payload.cc @@ -124,10 +124,10 @@ static void request_for_disabled_algorithm( request_payload_slice = grpc_slice_from_copied_string(str); request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - client_args = grpc_channel_args_set_compression_algorithm( + client_args = grpc_channel_args_set_channel_default_compression_algorithm( nullptr, requested_client_compression_algorithm); - server_args = - grpc_channel_args_set_compression_algorithm(nullptr, GRPC_COMPRESS_NONE); + server_args = grpc_channel_args_set_channel_default_compression_algorithm( + nullptr, GRPC_COMPRESS_NONE); { grpc_core::ExecCtx exec_ctx; server_args = grpc_channel_args_compression_algorithm_set_state( @@ -310,13 +310,13 @@ static void request_with_payload_template( grpc_slice response_payload_slice = grpc_slice_from_copied_string(response_str); - client_args = grpc_channel_args_set_compression_algorithm( + client_args = grpc_channel_args_set_channel_default_compression_algorithm( nullptr, default_client_channel_compression_algorithm); if (set_default_server_message_compression_algorithm) { - server_args = grpc_channel_args_set_compression_algorithm( + server_args = grpc_channel_args_set_channel_default_compression_algorithm( nullptr, default_server_message_compression_algorithm); } else { - server_args = grpc_channel_args_set_compression_algorithm( + server_args = grpc_channel_args_set_channel_default_compression_algorithm( nullptr, default_server_channel_compression_algorithm); } diff --git a/test/core/end2end/tests/stream_compression_payload.cc b/test/core/end2end/tests/stream_compression_payload.cc index 5f6b9a7f199..ba0557facac 100644 --- a/test/core/end2end/tests/stream_compression_payload.cc +++ b/test/core/end2end/tests/stream_compression_payload.cc @@ -263,10 +263,12 @@ static void request_response_with_payload(grpc_end2end_test_config config, payload and status. */ static void test_invoke_request_response_with_payload( grpc_end2end_test_config config) { - grpc_channel_args* client_args = grpc_channel_args_set_compression_algorithm( - nullptr, GRPC_COMPRESS_STREAM_GZIP); - grpc_channel_args* server_args = grpc_channel_args_set_compression_algorithm( - nullptr, GRPC_COMPRESS_STREAM_GZIP); + grpc_channel_args* client_args = + grpc_channel_args_set_channel_default_compression_algorithm( + nullptr, GRPC_COMPRESS_STREAM_GZIP); + grpc_channel_args* server_args = + grpc_channel_args_set_channel_default_compression_algorithm( + nullptr, GRPC_COMPRESS_STREAM_GZIP); grpc_end2end_test_fixture f = begin_test(config, "test_invoke_request_response_with_payload", client_args, server_args); diff --git a/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc index 6e96f7d2938..39698bde442 100644 --- a/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc +++ b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc @@ -91,10 +91,12 @@ static void end_test(grpc_end2end_test_fixture* f) { /* Client pings and server pongs. Repeat messages rounds before finishing. */ static void test_pingpong_streaming(grpc_end2end_test_config config, int messages) { - grpc_channel_args* client_args = grpc_channel_args_set_compression_algorithm( - nullptr, GRPC_COMPRESS_STREAM_GZIP); - grpc_channel_args* server_args = grpc_channel_args_set_compression_algorithm( - nullptr, GRPC_COMPRESS_STREAM_GZIP); + grpc_channel_args* client_args = + grpc_channel_args_set_channel_default_compression_algorithm( + nullptr, GRPC_COMPRESS_STREAM_GZIP); + grpc_channel_args* server_args = + grpc_channel_args_set_channel_default_compression_algorithm( + nullptr, GRPC_COMPRESS_STREAM_GZIP); grpc_end2end_test_fixture f = begin_test(config, "test_pingpong_streaming", client_args, server_args); grpc_call* c; diff --git a/test/core/end2end/tests/workaround_cronet_compression.cc b/test/core/end2end/tests/workaround_cronet_compression.cc index d79b2a9be3b..1a47244b68d 100644 --- a/test/core/end2end/tests/workaround_cronet_compression.cc +++ b/test/core/end2end/tests/workaround_cronet_compression.cc @@ -136,9 +136,9 @@ static void request_with_payload_template( grpc_slice response_payload_slice = grpc_slice_from_copied_string(response_str); - client_args = grpc_channel_args_set_compression_algorithm( + client_args = grpc_channel_args_set_channel_default_compression_algorithm( nullptr, default_client_channel_compression_algorithm); - server_args = grpc_channel_args_set_compression_algorithm( + server_args = grpc_channel_args_set_channel_default_compression_algorithm( nullptr, default_server_channel_compression_algorithm); if (user_agent_override) { From 8cc345777659c8dec31f42be448fd0a97b96ad44 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 19 Jun 2019 13:48:37 -0700 Subject: [PATCH 0590/1555] fix tests so that they run --- tools/run_tests/run_tests.py | 145 +++++++++++++++++------------------ 1 file changed, 72 insertions(+), 73 deletions(-) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index e5506063091..f251c06d371 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1058,79 +1058,78 @@ class ObjCLanguage(object): def test_specs(self): out = [] - if self.config == 'dbg': - out += self.config.job_spec( - ['src/objective-c/tests/build_one_example.sh'], - timeout_seconds=10 * 60, - shortname='ios-buildtest-example-sample', - cpu_cost=1e6, - environ={ - 'SCHEME': 'Sample', - 'EXAMPLE_PATH': 'src/objective-c/examples/Sample' - }) - out += job_spec( - ['src/objective-c/tests/build_one_example.sh'], - timeout_seconds=10 * 60, - shortname='ios-buildtest-example-sample-frameworks', - cpu_cost=1e6, - environ={ - 'SCHEME': 'Sample', - 'EXAMPLE_PATH': 'src/objective-c/examples/Sample', - 'FRAMEWORKS': 'YES' - }) - out += self.config.job_spec( - ['src/objective-c/tests/build_one_example.sh'], - timeout_seconds=10 * 60, - shortname='ios-buildtest-example-switftsample', - cpu_cost=1e6, - environ={ - 'SCHEME': 'SwiftSample', - 'EXAMPLE_PATH': 'src/objective-c/examples/SwiftSample' - }) - out += self.config.job_spec( - ['src/objective-c/tests/run_plugin_tests.sh'], - timeout_seconds=60 * 60, - shortname='ios-test-plugintest', - cpu_cost=1e6, - environ=_FORCE_ENVIRON_FOR_WRAPPERS) - out += self.config.job_spec( - ['test/core/iomgr/ios/CFStreamTests/run_tests.sh'], - timeout_seconds=20 * 60, - shortname='ios-test-cfstream-tests', - cpu_cost=1e6, - environ=_FORCE_ENVIRON_FOR_WRAPPERS) - out += self.config.job_spec( - ['src/objective-c/tests/run_one_test.sh'], - timeout_seconds=60 * 60, - shortname='ios-test-unittests', - cpu_cost=1e6, - environ={ - SCHEME: 'UnitTests' - }) - out += self.config.job_spec( - ['src/objective-c/tests/run_one_test.sh'], - timeout_seconds=60 * 60, - shortname='ios-test-interoptests', - cpu_cost=1e6, - environ={ - SCHEME: 'InteropTests' - }) - out += self.config.job_spec( - ['src/objective-c/tests/run_one_test.sh'], - timeout_seconds=60 * 60, - shortname='ios-test-cronettests', - cpu_cost=1e6, - environ={ - SCHEME: 'CronetTests' - }) - out += self.config.job_spec( - ['src/objective-c/tests/run_one_test.sh'], - timeout_seconds=60 * 60, - shortname='mac-test-basictests', - cpu_cost=1e6, - environ={ - SCHEME: 'MacTests' - }) + out += self.config.job_spec( + ['src/objective-c/tests/build_one_example.sh'], + timeout_seconds=10 * 60, + shortname='ios-buildtest-example-sample', + cpu_cost=1e6, + environ={ + 'SCHEME': 'Sample', + 'EXAMPLE_PATH': 'src/objective-c/examples/Sample' + }) + out += job_spec( + ['src/objective-c/tests/build_one_example.sh'], + timeout_seconds=10 * 60, + shortname='ios-buildtest-example-sample-frameworks', + cpu_cost=1e6, + environ={ + 'SCHEME': 'Sample', + 'EXAMPLE_PATH': 'src/objective-c/examples/Sample', + 'FRAMEWORKS': 'YES' + }) + out += self.config.job_spec( + ['src/objective-c/tests/build_one_example.sh'], + timeout_seconds=10 * 60, + shortname='ios-buildtest-example-switftsample', + cpu_cost=1e6, + environ={ + 'SCHEME': 'SwiftSample', + 'EXAMPLE_PATH': 'src/objective-c/examples/SwiftSample' + }) + out += self.config.job_spec( + ['src/objective-c/tests/run_plugin_tests.sh'], + timeout_seconds=60 * 60, + shortname='ios-test-plugintest', + cpu_cost=1e6, + environ=_FORCE_ENVIRON_FOR_WRAPPERS) + out += self.config.job_spec( + ['test/core/iomgr/ios/CFStreamTests/run_tests.sh'], + timeout_seconds=20 * 60, + shortname='ios-test-cfstream-tests', + cpu_cost=1e6, + environ=_FORCE_ENVIRON_FOR_WRAPPERS) + out += self.config.job_spec( + ['src/objective-c/tests/run_one_test.sh'], + timeout_seconds=60 * 60, + shortname='ios-test-unittests', + cpu_cost=1e6, + environ={ + SCHEME: 'UnitTests' + }) + out += self.config.job_spec( + ['src/objective-c/tests/run_one_test.sh'], + timeout_seconds=60 * 60, + shortname='ios-test-interoptests', + cpu_cost=1e6, + environ={ + SCHEME: 'InteropTests' + }) + out += self.config.job_spec( + ['src/objective-c/tests/run_one_test.sh'], + timeout_seconds=60 * 60, + shortname='ios-test-cronettests', + cpu_cost=1e6, + environ={ + SCHEME: 'CronetTests' + }) + out += self.config.job_spec( + ['src/objective-c/tests/run_one_test.sh'], + timeout_seconds=60 * 60, + shortname='mac-test-basictests', + cpu_cost=1e6, + environ={ + SCHEME: 'MacTests' + }) return sorted(out) From 03797e0ec36e76f08ecb51c74ebec0531d24fac4 Mon Sep 17 00:00:00 2001 From: Alex Polcyn Date: Mon, 17 Jun 2019 04:41:46 +0000 Subject: [PATCH 0591/1555] Simplify and fix the c-ares TCP path on Windows --- .../dns/c_ares/grpc_ares_ev_driver_windows.cc | 482 +++++++++++++++--- 1 file changed, 402 insertions(+), 80 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc index 7d5215938e3..df40ba1c4bd 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc @@ -31,6 +31,9 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/combiner.h" +#include "src/core/lib/iomgr/iocp_windows.h" +#include "src/core/lib/iomgr/sockaddr_utils.h" +#include "src/core/lib/iomgr/sockaddr_windows.h" #include "src/core/lib/iomgr/socket_windows.h" #include "src/core/lib/iomgr/tcp_windows.h" #include "src/core/lib/slice/slice_internal.h" @@ -50,6 +53,32 @@ struct iovec { namespace grpc_core { +/* c-ares reads and takes action on the error codes of the + * "virtual socket operations" in this file, via the WSAGetLastError + * APIs. If code in this file wants to set a specific WSA error that + * c-ares should read, it must do so by calling SetWSAError() on the + * WSAErrorContext instance passed to it. A WSAErrorContext must only be + * instantiated at the top of the virtual socket function callstack. */ +class WSAErrorContext { + public: + explicit WSAErrorContext(){}; + + ~WSAErrorContext() { + if (error_ != 0) { + WSASetLastError(error_); + } + } + + /* Disallow copy and assignment operators */ + WSAErrorContext(const WSAErrorContext&) = delete; + WSAErrorContext& operator=(const WSAErrorContext&) = delete; + + void SetWSAError(int error) { error_ = error; } + + private: + int error_ = 0; +}; + /* c-ares creates its own sockets and is meant to read them when readable and * write them when writeable. To fit this socket usage model into the grpc * windows poller (which gives notifications when attempted reads and writes are @@ -68,11 +97,14 @@ class GrpcPolledFdWindows : public GrpcPolledFd { WRITE_WAITING_FOR_VERIFICATION_UPON_RETRY, }; - GrpcPolledFdWindows(ares_socket_t as, grpc_combiner* combiner) + GrpcPolledFdWindows(ares_socket_t as, grpc_combiner* combiner, + int address_family, int socket_type) : read_buf_(grpc_empty_slice()), write_buf_(grpc_empty_slice()), - write_state_(WRITE_IDLE), - gotten_into_driver_list_(false) { + tcp_write_state_(WRITE_IDLE), + gotten_into_driver_list_(false), + address_family_(address_family), + socket_type_(socket_type) { gpr_asprintf(&name_, "c-ares socket: %" PRIdPTR, as); winsocket_ = grpc_winsocket_create(as, name_); combiner_ = GRPC_COMBINER_REF(combiner, name_); @@ -82,6 +114,16 @@ class GrpcPolledFdWindows : public GrpcPolledFd { GRPC_CLOSURE_INIT(&outer_write_closure_, &GrpcPolledFdWindows::OnIocpWriteable, this, grpc_combiner_scheduler(combiner_)); + GRPC_CLOSURE_INIT(&on_tcp_connect_locked_, + &GrpcPolledFdWindows::OnTcpConnectLocked, this, + grpc_combiner_scheduler(combiner_)); + GRPC_CLOSURE_INIT(&continue_register_for_on_readable_locked_, + &GrpcPolledFdWindows::ContinueRegisterForOnReadableLocked, + this, grpc_combiner_scheduler(combiner_)); + GRPC_CLOSURE_INIT( + &continue_register_for_on_writeable_locked_, + &GrpcPolledFdWindows::ContinueRegisterForOnWriteableLocked, this, + grpc_combiner_scheduler(combiner_)); } ~GrpcPolledFdWindows() { @@ -111,6 +153,33 @@ class GrpcPolledFdWindows : public GrpcPolledFd { grpc_slice_unref_internal(read_buf_); GPR_ASSERT(!read_buf_has_data_); read_buf_ = GRPC_SLICE_MALLOC(4192); + if (connect_done_) { + GRPC_CLOSURE_SCHED(&continue_register_for_on_readable_locked_, + GRPC_ERROR_NONE); + } else { + GPR_ASSERT(pending_continue_register_for_on_readable_locked_ == nullptr); + pending_continue_register_for_on_readable_locked_ = + &continue_register_for_on_readable_locked_; + } + } + + static void ContinueRegisterForOnReadableLocked(void* arg, + grpc_error* unused_error) { + GrpcPolledFdWindows* grpc_polled_fd = + static_cast(arg); + grpc_polled_fd->InnerContinueRegisterForOnReadableLocked(GRPC_ERROR_NONE); + } + + void InnerContinueRegisterForOnReadableLocked(grpc_error* unused_error) { + GRPC_CARES_TRACE_LOG( + "fd:|%s| InnerContinueRegisterForOnReadableLocked " + "wsa_connect_error_:%d", + GetName(), wsa_connect_error_); + GPR_ASSERT(connect_done_); + if (wsa_connect_error_ != 0) { + ScheduleAndNullReadClosure(GRPC_WSA_ERROR(wsa_connect_error_, "connect")); + return; + } WSABUF buffer; buffer.buf = (char*)GRPC_SLICE_START_PTR(read_buf_); buffer.len = GRPC_SLICE_LENGTH(read_buf_); @@ -123,13 +192,14 @@ class GrpcPolledFdWindows : public GrpcPolledFd { &winsocket_->read_info.overlapped, nullptr)) { int wsa_last_error = WSAGetLastError(); char* msg = gpr_format_message(wsa_last_error); - grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg); GRPC_CARES_TRACE_LOG( - "RegisterForOnReadableLocked: WSARecvFrom error:|%s|. fd:|%s|", msg, - GetName()); + "fd:|%s| RegisterForOnReadableLocked WSARecvFrom error code:|%d| " + "msg:|%s|", + GetName(), wsa_last_error, msg); gpr_free(msg); if (wsa_last_error != WSA_IO_PENDING) { - ScheduleAndNullReadClosure(error); + ScheduleAndNullReadClosure( + GRPC_WSA_ERROR(wsa_last_error, "WSARecvFrom")); return; } } @@ -137,23 +207,68 @@ class GrpcPolledFdWindows : public GrpcPolledFd { } void RegisterForOnWriteableLocked(grpc_closure* write_closure) override { - GRPC_CARES_TRACE_LOG( - "RegisterForOnWriteableLocked. fd:|%s|. Current write state: %d", - GetName(), write_state_); + if (socket_type_ == SOCK_DGRAM) { + GRPC_CARES_TRACE_LOG("fd:|%s| RegisterForOnWriteableLocked called", + GetName()); + } else { + GPR_ASSERT(socket_type_ == SOCK_STREAM); + GRPC_CARES_TRACE_LOG( + "fd:|%s| RegisterForOnWriteableLocked called tcp_write_state_: %d", + GetName(), tcp_write_state_); + } GPR_ASSERT(write_closure_ == nullptr); write_closure_ = write_closure; - switch (write_state_) { - case WRITE_IDLE: - ScheduleAndNullWriteClosure(GRPC_ERROR_NONE); - break; - case WRITE_REQUESTED: - write_state_ = WRITE_PENDING; - SendWriteBuf(nullptr, &winsocket_->write_info.overlapped); - grpc_socket_notify_on_write(winsocket_, &outer_write_closure_); - break; - case WRITE_PENDING: - case WRITE_WAITING_FOR_VERIFICATION_UPON_RETRY: - abort(); + if (connect_done_) { + GRPC_CLOSURE_SCHED(&continue_register_for_on_writeable_locked_, + GRPC_ERROR_NONE); + } else { + GPR_ASSERT(pending_continue_register_for_on_writeable_locked_ == nullptr); + pending_continue_register_for_on_writeable_locked_ = + &continue_register_for_on_writeable_locked_; + } + } + + static void ContinueRegisterForOnWriteableLocked(void* arg, + grpc_error* unused_error) { + GrpcPolledFdWindows* grpc_polled_fd = + static_cast(arg); + grpc_polled_fd->InnerContinueRegisterForOnWriteableLocked(GRPC_ERROR_NONE); + } + + void InnerContinueRegisterForOnWriteableLocked(grpc_error* unused_error) { + GRPC_CARES_TRACE_LOG( + "fd:|%s| InnerContinueRegisterForOnWriteableLocked " + "wsa_connect_error_:%d", + GetName(), wsa_connect_error_); + GPR_ASSERT(connect_done_); + if (wsa_connect_error_ != 0) { + ScheduleAndNullWriteClosure( + GRPC_WSA_ERROR(wsa_connect_error_, "connect")); + return; + } + if (socket_type_ == SOCK_DGRAM) { + ScheduleAndNullWriteClosure(GRPC_ERROR_NONE); + } else { + GPR_ASSERT(socket_type_ == SOCK_STREAM); + int wsa_error_code = 0; + switch (tcp_write_state_) { + case WRITE_IDLE: + ScheduleAndNullWriteClosure(GRPC_ERROR_NONE); + break; + case WRITE_REQUESTED: + tcp_write_state_ = WRITE_PENDING; + if (SendWriteBuf(nullptr, &winsocket_->write_info.overlapped, + &wsa_error_code) != 0) { + ScheduleAndNullWriteClosure( + GRPC_WSA_ERROR(wsa_error_code, "WSASend (overlapped)")); + } else { + grpc_socket_notify_on_write(winsocket_, &outer_write_closure_); + } + break; + case WRITE_PENDING: + case WRITE_WAITING_FOR_VERIFICATION_UPON_RETRY: + abort(); + } } } @@ -171,13 +286,15 @@ class GrpcPolledFdWindows : public GrpcPolledFd { const char* GetName() override { return name_; } - ares_ssize_t RecvFrom(void* data, ares_socket_t data_len, int flags, + ares_ssize_t RecvFrom(WSAErrorContext* wsa_error_ctx, void* data, + ares_socket_t data_len, int flags, struct sockaddr* from, ares_socklen_t* from_len) { GRPC_CARES_TRACE_LOG( - "RecvFrom called on fd:|%s|. Current read buf length:|%d|", GetName(), - GRPC_SLICE_LENGTH(read_buf_)); + "fd:|%s| RecvFrom called read_buf_has_data:%d Current read buf " + "length:|%d|", + GetName(), read_buf_has_data_, GRPC_SLICE_LENGTH(read_buf_)); if (!read_buf_has_data_) { - WSASetLastError(WSAEWOULDBLOCK); + wsa_error_ctx->SetWSAError(WSAEWOULDBLOCK); return -1; } ares_ssize_t bytes_read = 0; @@ -215,54 +332,99 @@ class GrpcPolledFdWindows : public GrpcPolledFd { return out; } - int SendWriteBuf(LPDWORD bytes_sent_ptr, LPWSAOVERLAPPED overlapped) { + int SendWriteBuf(LPDWORD bytes_sent_ptr, LPWSAOVERLAPPED overlapped, + int* wsa_error_code) { WSABUF buf; buf.len = GRPC_SLICE_LENGTH(write_buf_); buf.buf = (char*)GRPC_SLICE_START_PTR(write_buf_); DWORD flags = 0; int out = WSASend(grpc_winsocket_wrapped_socket(winsocket_), &buf, 1, bytes_sent_ptr, flags, overlapped, nullptr); + *wsa_error_code = WSAGetLastError(); GRPC_CARES_TRACE_LOG( - "WSASend: name:%s. buf len:%d. bytes sent: %d. overlapped %p. return " - "val: %d", - GetName(), buf.len, *bytes_sent_ptr, overlapped, out); + "fd:|%s| SendWriteBuf WSASend buf.len:%d *bytes_sent_ptr:%d " + "overlapped:%p " + "return:%d *wsa_error_code:%d", + GetName(), buf.len, bytes_sent_ptr != nullptr ? *bytes_sent_ptr : 0, + overlapped, out, *wsa_error_code); return out; } - ares_ssize_t TrySendWriteBufSyncNonBlocking() { - GPR_ASSERT(write_state_ == WRITE_IDLE); + ares_ssize_t SendV(WSAErrorContext* wsa_error_ctx, const struct iovec* iov, + int iov_count) { + GRPC_CARES_TRACE_LOG( + "fd:|%s| SendV called connect_done_:%d was_connect_error_:%d", + GetName(), connect_done_, wsa_connect_error_); + if (!connect_done_) { + wsa_error_ctx->SetWSAError(WSAEWOULDBLOCK); + return -1; + } + if (wsa_connect_error_ != 0) { + wsa_error_ctx->SetWSAError(wsa_connect_error_); + return -1; + } + switch (socket_type_) { + case SOCK_DGRAM: + return SendVUDP(wsa_error_ctx, iov, iov_count); + case SOCK_STREAM: + return SendVTCP(wsa_error_ctx, iov, iov_count); + default: + abort(); + } + } + + ares_ssize_t SendVUDP(WSAErrorContext* wsa_error_ctx, const struct iovec* iov, + int iov_count) { + // c-ares doesn't handle retryable errors on writes of UDP sockets. + // Therefore, the sendv handler for UDP sockets must only attempt + // to write everything inline. + GRPC_CARES_TRACE_LOG("fd:|%s| SendVUDP called", GetName()); + GPR_ASSERT(GRPC_SLICE_LENGTH(write_buf_) == 0); + grpc_slice_unref_internal(write_buf_); + write_buf_ = FlattenIovec(iov, iov_count); DWORD bytes_sent = 0; - if (SendWriteBuf(&bytes_sent, nullptr) != 0) { - int wsa_last_error = WSAGetLastError(); - char* msg = gpr_format_message(wsa_last_error); + int wsa_error_code = 0; + if (SendWriteBuf(&bytes_sent, nullptr, &wsa_error_code) != 0) { + wsa_error_ctx->SetWSAError(wsa_error_code); + char* msg = gpr_format_message(wsa_error_code); GRPC_CARES_TRACE_LOG( - "TrySendWriteBufSyncNonBlocking: SendWriteBuf error:|%s|. fd:|%s|", - msg, GetName()); + "fd:|%s| SendVUDP SendWriteBuf error code:%d msg:|%s|", GetName(), + wsa_error_code, msg); gpr_free(msg); - if (wsa_last_error == WSA_IO_PENDING) { - WSASetLastError(WSAEWOULDBLOCK); - write_state_ = WRITE_REQUESTED; - } + return -1; } write_buf_ = grpc_slice_sub_no_ref(write_buf_, bytes_sent, GRPC_SLICE_LENGTH(write_buf_)); return bytes_sent; } - ares_ssize_t SendV(const struct iovec* iov, int iov_count) { - GRPC_CARES_TRACE_LOG("SendV called on fd:|%s|. Current write state: %d", - GetName(), write_state_); - switch (write_state_) { + ares_ssize_t SendVTCP(WSAErrorContext* wsa_error_ctx, const struct iovec* iov, + int iov_count) { + // The "sendv" handler on TCP sockets buffers up write + // requests and returns an artifical WSAEWOULDBLOCK. Writing that buffer out + // in the background, and making further send progress in general, will + // happen as long as c-ares continues to show interest in writeability on + // this fd. + GRPC_CARES_TRACE_LOG("fd:|%s| SendVTCP called tcp_write_state_:%d", + GetName(), tcp_write_state_); + switch (tcp_write_state_) { case WRITE_IDLE: + tcp_write_state_ = WRITE_REQUESTED; GPR_ASSERT(GRPC_SLICE_LENGTH(write_buf_) == 0); grpc_slice_unref_internal(write_buf_); write_buf_ = FlattenIovec(iov, iov_count); - return TrySendWriteBufSyncNonBlocking(); + wsa_error_ctx->SetWSAError(WSAEWOULDBLOCK); + return -1; case WRITE_REQUESTED: case WRITE_PENDING: - WSASetLastError(WSAEWOULDBLOCK); + wsa_error_ctx->SetWSAError(WSAEWOULDBLOCK); return -1; case WRITE_WAITING_FOR_VERIFICATION_UPON_RETRY: + // c-ares is retrying a send on data that we previously returned + // WSAEWOULDBLOCK for, but then subsequently wrote out in the + // background. Right now, we assume that c-ares is retrying the same + // send again. If c-ares still needs to send even more data, we'll get + // to it eventually. grpc_slice currently_attempted = FlattenIovec(iov, iov_count); GPR_ASSERT(GRPC_SLICE_LENGTH(currently_attempted) >= GRPC_SLICE_LENGTH(write_buf_)); @@ -272,31 +434,159 @@ class GrpcPolledFdWindows : public GrpcPolledFd { GRPC_SLICE_START_PTR(write_buf_)[i]); total_sent++; } - grpc_slice_unref_internal(write_buf_); - write_buf_ = - grpc_slice_sub_no_ref(currently_attempted, total_sent, - GRPC_SLICE_LENGTH(currently_attempted)); - write_state_ = WRITE_IDLE; - total_sent += TrySendWriteBufSyncNonBlocking(); + grpc_slice_unref_internal(currently_attempted); + tcp_write_state_ = WRITE_IDLE; return total_sent; } abort(); } - int Connect(const struct sockaddr* target, ares_socklen_t target_len) { + static void OnTcpConnectLocked(void* arg, grpc_error* error) { + GrpcPolledFdWindows* grpc_polled_fd = + static_cast(arg); + grpc_polled_fd->InnerOnTcpConnectLocked(error); + } + + void InnerOnTcpConnectLocked(grpc_error* error) { + GRPC_CARES_TRACE_LOG( + "fd:%s InnerOnTcpConnectLocked error:|%s| " + "pending_register_for_readable:%" PRIdPTR + " pending_register_for_writeable:%" PRIdPTR, + GetName(), grpc_error_string(error), + pending_continue_register_for_on_readable_locked_, + pending_continue_register_for_on_writeable_locked_); + GPR_ASSERT(!connect_done_); + connect_done_ = true; + GPR_ASSERT(wsa_connect_error_ == 0); + if (error == GRPC_ERROR_NONE) { + DWORD transfered_bytes = 0; + DWORD flags; + BOOL wsa_success = WSAGetOverlappedResult( + grpc_winsocket_wrapped_socket(winsocket_), + &winsocket_->write_info.overlapped, &transfered_bytes, FALSE, &flags); + GPR_ASSERT(transfered_bytes == 0); + if (!wsa_success) { + wsa_connect_error_ = WSAGetLastError(); + char* msg = gpr_format_message(wsa_connect_error_); + GRPC_CARES_TRACE_LOG( + "fd:%s InnerOnTcpConnectLocked WSA overlapped result code:%d " + "msg:|%s|", + GetName(), wsa_connect_error_, msg); + gpr_free(msg); + } + } else { + // Spoof up an error code that will cause any future c-ares operations on + // this fd to abort. + wsa_connect_error_ = WSA_OPERATION_ABORTED; + } + if (pending_continue_register_for_on_readable_locked_ != nullptr) { + GRPC_CLOSURE_SCHED(pending_continue_register_for_on_readable_locked_, + GRPC_ERROR_NONE); + } + if (pending_continue_register_for_on_writeable_locked_ != nullptr) { + GRPC_CLOSURE_SCHED(pending_continue_register_for_on_writeable_locked_, + GRPC_ERROR_NONE); + } + } + + int Connect(WSAErrorContext* wsa_error_ctx, const struct sockaddr* target, + ares_socklen_t target_len) { + switch (socket_type_) { + case SOCK_DGRAM: + return ConnectUDP(wsa_error_ctx, target, target_len); + case SOCK_STREAM: + return ConnectTCP(wsa_error_ctx, target, target_len); + default: + abort(); + } + } + + int ConnectUDP(WSAErrorContext* wsa_error_ctx, const struct sockaddr* target, + ares_socklen_t target_len) { + GRPC_CARES_TRACE_LOG("fd:%s ConnectUDP", GetName()); + GPR_ASSERT(!connect_done_); + GPR_ASSERT(wsa_connect_error_ == 0); SOCKET s = grpc_winsocket_wrapped_socket(winsocket_); - GRPC_CARES_TRACE_LOG("Connect: fd:|%s|", GetName()); int out = WSAConnect(s, target, target_len, nullptr, nullptr, nullptr, nullptr); - if (out != 0) { + wsa_connect_error_ = WSAGetLastError(); + wsa_error_ctx->SetWSAError(wsa_connect_error_); + connect_done_ = true; + char* msg = gpr_format_message(wsa_connect_error_); + GRPC_CARES_TRACE_LOG("fd:%s WSAConnect error code:|%d| msg:|%s|", GetName(), + wsa_connect_error_, msg); + gpr_free(msg); + // c-ares expects a posix-style connect API + return out == 0 ? 0 : -1; + } + + int ConnectTCP(WSAErrorContext* wsa_error_ctx, const struct sockaddr* target, + ares_socklen_t target_len) { + GRPC_CARES_TRACE_LOG("fd:%s ConnectTCP", GetName()); + LPFN_CONNECTEX ConnectEx; + GUID guid = WSAID_CONNECTEX; + DWORD ioctl_num_bytes; + SOCKET s = grpc_winsocket_wrapped_socket(winsocket_); + if (WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, &guid, sizeof(guid), + &ConnectEx, sizeof(ConnectEx), &ioctl_num_bytes, nullptr, + nullptr) != 0) { int wsa_last_error = WSAGetLastError(); + wsa_error_ctx->SetWSAError(wsa_last_error); char* msg = gpr_format_message(wsa_last_error); - GRPC_CARES_TRACE_LOG("Connect error code:|%d|, msg:|%s|. fd:|%s|", - wsa_last_error, msg, GetName()); + GRPC_CARES_TRACE_LOG( + "fd:%s WSAIoctl(SIO_GET_EXTENSION_FUNCTION_POINTER) error code:%d " + "msg:|%s|", + GetName(), wsa_last_error, msg); gpr_free(msg); - // c-ares expects a posix-style connect API - out = -1; + connect_done_ = true; + wsa_connect_error_ = wsa_last_error; + return -1; } + grpc_resolved_address wildcard4_addr; + grpc_resolved_address wildcard6_addr; + grpc_sockaddr_make_wildcards(0, &wildcard4_addr, &wildcard6_addr); + grpc_resolved_address* local_address = nullptr; + if (address_family_ == AF_INET) { + local_address = &wildcard4_addr; + } else { + local_address = &wildcard6_addr; + } + if (bind(s, (struct sockaddr*)local_address->addr, + (int)local_address->len) != 0) { + int wsa_last_error = WSAGetLastError(); + wsa_error_ctx->SetWSAError(wsa_last_error); + char* msg = gpr_format_message(wsa_last_error); + GRPC_CARES_TRACE_LOG("fd:%s bind error code:%d msg:|%s|", GetName(), + wsa_last_error, msg); + gpr_free(msg); + connect_done_ = true; + wsa_connect_error_ = wsa_last_error; + return -1; + } + int out = 0; + if (ConnectEx(s, target, target_len, nullptr, 0, nullptr, + &winsocket_->write_info.overlapped) == 0) { + out = -1; + int wsa_last_error = WSAGetLastError(); + wsa_error_ctx->SetWSAError(wsa_last_error); + char* msg = gpr_format_message(wsa_last_error); + GRPC_CARES_TRACE_LOG("fd:%s ConnectEx error code:%d msg:|%s|", GetName(), + wsa_last_error, msg); + gpr_free(msg); + if (wsa_last_error == WSA_IO_PENDING) { + // c-ares only understands WSAEINPROGRESS and EWOULDBLOCK error codes on + // connect, but an async connect on IOCP socket will give + // WSA_IO_PENDING, so we need to convert. + wsa_error_ctx->SetWSAError(WSAEWOULDBLOCK); + } else { + // By returning a non-retryable error to c-ares at this point, + // we're aborting the possibility of any future operations on this fd. + connect_done_ = true; + wsa_connect_error_ = wsa_last_error; + return -1; + } + } + grpc_socket_notify_on_write(winsocket_, &on_tcp_connect_locked_); return out; } @@ -319,12 +609,13 @@ class GrpcPolledFdWindows : public GrpcPolledFd { * in subsequent c-ares reads. */ if (winsocket_->read_info.wsa_error != WSAEMSGSIZE) { GRPC_ERROR_UNREF(error); - char* msg = gpr_format_message(winsocket_->read_info.wsa_error); + error = GRPC_WSA_ERROR(winsocket_->read_info.wsa_error, + "OnIocpReadableInner"); GRPC_CARES_TRACE_LOG( - "OnIocpReadableInner. winsocket error:|%s|. fd:|%s|", msg, - GetName()); - error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg); - gpr_free(msg); + "fd:|%s| OnIocpReadableInner winsocket_->read_info.wsa_error " + "code:|%d| msg:|%s|", + GetName(), winsocket_->read_info.wsa_error, + grpc_error_string(error)); } } } @@ -337,8 +628,8 @@ class GrpcPolledFdWindows : public GrpcPolledFd { read_buf_ = grpc_empty_slice(); } GRPC_CARES_TRACE_LOG( - "OnIocpReadable finishing. read buf length now:|%d|. :fd:|%s|", - GRPC_SLICE_LENGTH(read_buf_), GetName()); + "fd:|%s| OnIocpReadable finishing. read buf length now:|%d|", GetName(), + GRPC_SLICE_LENGTH(read_buf_)); ScheduleAndNullReadClosure(error); } @@ -349,22 +640,26 @@ class GrpcPolledFdWindows : public GrpcPolledFd { void OnIocpWriteableInner(grpc_error* error) { GRPC_CARES_TRACE_LOG("OnIocpWriteableInner. fd:|%s|", GetName()); + GPR_ASSERT(socket_type_ == SOCK_STREAM); if (error == GRPC_ERROR_NONE) { if (winsocket_->write_info.wsa_error != 0) { - char* msg = gpr_format_message(winsocket_->write_info.wsa_error); - GRPC_CARES_TRACE_LOG( - "OnIocpWriteableInner. winsocket error:|%s|. fd:|%s|", msg, - GetName()); GRPC_ERROR_UNREF(error); - error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg); - gpr_free(msg); + error = GRPC_WSA_ERROR(winsocket_->write_info.wsa_error, + "OnIocpWriteableInner"); + GRPC_CARES_TRACE_LOG( + "fd:|%s| OnIocpWriteableInner. winsocket_->write_info.wsa_error " + "code:|%d| msg:|%s|", + GetName(), winsocket_->write_info.wsa_error, + grpc_error_string(error)); } } - GPR_ASSERT(write_state_ == WRITE_PENDING); + GPR_ASSERT(tcp_write_state_ == WRITE_PENDING); if (error == GRPC_ERROR_NONE) { - write_state_ = WRITE_WAITING_FOR_VERIFICATION_UPON_RETRY; + tcp_write_state_ = WRITE_WAITING_FOR_VERIFICATION_UPON_RETRY; write_buf_ = grpc_slice_sub_no_ref( write_buf_, 0, winsocket_->write_info.bytes_transfered); + GRPC_CARES_TRACE_LOG("fd:|%s| OnIocpWriteableInner. bytes transferred:%d", + GetName(), winsocket_->write_info.bytes_transfered); } else { grpc_slice_unref_internal(write_buf_); write_buf_ = grpc_empty_slice(); @@ -386,9 +681,22 @@ class GrpcPolledFdWindows : public GrpcPolledFd { grpc_closure outer_read_closure_; grpc_closure outer_write_closure_; grpc_winsocket* winsocket_; - WriteState write_state_; + // tcp_write_state_ is only used on TCP GrpcPolledFds + WriteState tcp_write_state_; char* name_ = nullptr; bool gotten_into_driver_list_; + int address_family_; + int socket_type_; + grpc_closure on_tcp_connect_locked_; + bool connect_done_ = false; + int wsa_connect_error_ = 0; + // We don't run register_for_{readable,writeable} logic until + // a socket is connected. In the interim, we queue readable/writeable + // registrations with the following state. + grpc_closure continue_register_for_on_readable_locked_; + grpc_closure continue_register_for_on_writeable_locked_; + grpc_closure* pending_continue_register_for_on_readable_locked_ = nullptr; + grpc_closure* pending_continue_register_for_on_writeable_locked_ = nullptr; }; struct SockToPolledFdEntry { @@ -454,39 +762,53 @@ class SockToPolledFdMap { * objects. */ static ares_socket_t Socket(int af, int type, int protocol, void* user_data) { + if (type != SOCK_DGRAM && type != SOCK_STREAM) { + GRPC_CARES_TRACE_LOG("Socket called with invalid socket type:%d", type); + return INVALID_SOCKET; + } SockToPolledFdMap* map = static_cast(user_data); SOCKET s = WSASocket(af, type, protocol, nullptr, 0, grpc_get_default_wsa_socket_flags()); if (s == INVALID_SOCKET) { + GRPC_CARES_TRACE_LOG( + "WSASocket failed with params af:%d type:%d protocol:%d", af, type, + protocol); return s; } grpc_tcp_set_non_block(s); GrpcPolledFdWindows* polled_fd = - New(s, map->combiner_); + New(s, map->combiner_, af, type); + GRPC_CARES_TRACE_LOG( + "fd:|%s| created with params af:%d type:%d protocol:%d", + polled_fd->GetName(), af, type, protocol); map->AddNewSocket(s, polled_fd); return s; } static int Connect(ares_socket_t as, const struct sockaddr* target, ares_socklen_t target_len, void* user_data) { + WSAErrorContext wsa_error_ctx; SockToPolledFdMap* map = static_cast(user_data); GrpcPolledFdWindows* polled_fd = map->LookupPolledFd(as); - return polled_fd->Connect(target, target_len); + return polled_fd->Connect(&wsa_error_ctx, target, target_len); } static ares_ssize_t SendV(ares_socket_t as, const struct iovec* iov, int iovec_count, void* user_data) { + WSAErrorContext wsa_error_ctx; SockToPolledFdMap* map = static_cast(user_data); GrpcPolledFdWindows* polled_fd = map->LookupPolledFd(as); - return polled_fd->SendV(iov, iovec_count); + return polled_fd->SendV(&wsa_error_ctx, iov, iovec_count); } static ares_ssize_t RecvFrom(ares_socket_t as, void* data, size_t data_len, int flags, struct sockaddr* from, ares_socklen_t* from_len, void* user_data) { + WSAErrorContext wsa_error_ctx; SockToPolledFdMap* map = static_cast(user_data); GrpcPolledFdWindows* polled_fd = map->LookupPolledFd(as); - return polled_fd->RecvFrom(data, data_len, flags, from, from_len); + return polled_fd->RecvFrom(&wsa_error_ctx, data, data_len, flags, from, + from_len); } static int CloseSocket(SOCKET s, void* user_data) { From 8a11a8120ac4f7a97a3b58676580f805c7430129 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 19 Jun 2019 14:48:50 -0700 Subject: [PATCH 0592/1555] More run_tests.py script fix --- src/objective-c/tests/run_one_test.sh | 0 tools/run_tests/run_tests.py | 153 ++++++++++++++------------ 2 files changed, 81 insertions(+), 72 deletions(-) mode change 100644 => 100755 src/objective-c/tests/run_one_test.sh diff --git a/src/objective-c/tests/run_one_test.sh b/src/objective-c/tests/run_one_test.sh old mode 100644 new mode 100755 diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index f251c06d371..0addc093d73 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1058,78 +1058,87 @@ class ObjCLanguage(object): def test_specs(self): out = [] - out += self.config.job_spec( - ['src/objective-c/tests/build_one_example.sh'], - timeout_seconds=10 * 60, - shortname='ios-buildtest-example-sample', - cpu_cost=1e6, - environ={ - 'SCHEME': 'Sample', - 'EXAMPLE_PATH': 'src/objective-c/examples/Sample' - }) - out += job_spec( - ['src/objective-c/tests/build_one_example.sh'], - timeout_seconds=10 * 60, - shortname='ios-buildtest-example-sample-frameworks', - cpu_cost=1e6, - environ={ - 'SCHEME': 'Sample', - 'EXAMPLE_PATH': 'src/objective-c/examples/Sample', - 'FRAMEWORKS': 'YES' - }) - out += self.config.job_spec( - ['src/objective-c/tests/build_one_example.sh'], - timeout_seconds=10 * 60, - shortname='ios-buildtest-example-switftsample', - cpu_cost=1e6, - environ={ - 'SCHEME': 'SwiftSample', - 'EXAMPLE_PATH': 'src/objective-c/examples/SwiftSample' - }) - out += self.config.job_spec( - ['src/objective-c/tests/run_plugin_tests.sh'], - timeout_seconds=60 * 60, - shortname='ios-test-plugintest', - cpu_cost=1e6, - environ=_FORCE_ENVIRON_FOR_WRAPPERS) - out += self.config.job_spec( - ['test/core/iomgr/ios/CFStreamTests/run_tests.sh'], - timeout_seconds=20 * 60, - shortname='ios-test-cfstream-tests', - cpu_cost=1e6, - environ=_FORCE_ENVIRON_FOR_WRAPPERS) - out += self.config.job_spec( - ['src/objective-c/tests/run_one_test.sh'], - timeout_seconds=60 * 60, - shortname='ios-test-unittests', - cpu_cost=1e6, - environ={ - SCHEME: 'UnitTests' - }) - out += self.config.job_spec( - ['src/objective-c/tests/run_one_test.sh'], - timeout_seconds=60 * 60, - shortname='ios-test-interoptests', - cpu_cost=1e6, - environ={ - SCHEME: 'InteropTests' - }) - out += self.config.job_spec( - ['src/objective-c/tests/run_one_test.sh'], - timeout_seconds=60 * 60, - shortname='ios-test-cronettests', - cpu_cost=1e6, - environ={ - SCHEME: 'CronetTests' - }) - out += self.config.job_spec( - ['src/objective-c/tests/run_one_test.sh'], - timeout_seconds=60 * 60, - shortname='mac-test-basictests', - cpu_cost=1e6, - environ={ - SCHEME: 'MacTests' - }) + out.append( + self.config.job_spec( + ['src/objective-c/tests/build_one_example.sh'], + timeout_seconds=10 * 60, + shortname='ios-buildtest-example-sample', + cpu_cost=1e6, + environ={ + 'SCHEME': 'Sample', + 'EXAMPLE_PATH': 'src/objective-c/examples/Sample' + })) + out.append( + self.config.job_spec( + ['src/objective-c/tests/build_one_example.sh'], + timeout_seconds=10 * 60, + shortname='ios-buildtest-example-sample-frameworks', + cpu_cost=1e6, + environ={ + 'SCHEME': 'Sample', + 'EXAMPLE_PATH': 'src/objective-c/examples/Sample', + 'FRAMEWORKS': 'YES' + })) + out.append( + self.config.job_spec( + ['src/objective-c/tests/build_one_example.sh'], + timeout_seconds=10 * 60, + shortname='ios-buildtest-example-switftsample', + cpu_cost=1e6, + environ={ + 'SCHEME': 'SwiftSample', + 'EXAMPLE_PATH': 'src/objective-c/examples/SwiftSample' + })) + out.append( + self.config.job_spec( + ['src/objective-c/tests/run_plugin_tests.sh'], + timeout_seconds=60 * 60, + shortname='ios-test-plugintest', + cpu_cost=1e6, + environ=_FORCE_ENVIRON_FOR_WRAPPERS)) + out.append( + self.config.job_spec( + ['test/core/iomgr/ios/CFStreamTests/run_tests.sh'], + timeout_seconds=20 * 60, + shortname='ios-test-cfstream-tests', + cpu_cost=1e6, + environ=_FORCE_ENVIRON_FOR_WRAPPERS)) + out.append( + self.config.job_spec( + ['src/objective-c/tests/run_one_test.sh'], + timeout_seconds=60 * 60, + shortname='ios-test-unittests', + cpu_cost=1e6, + environ={ + 'SCHEME': 'UnitTests' + })) + out.append( + self.config.job_spec( + ['src/objective-c/tests/run_one_test.sh'], + timeout_seconds=60 * 60, + shortname='ios-test-interoptests', + cpu_cost=1e6, + environ={ + 'SCHEME': 'InteropTests' + })) + out.append( + self.config.job_spec( + ['src/objective-c/tests/run_one_test.sh'], + timeout_seconds=60 * 60, + shortname='ios-test-cronettests', + cpu_cost=1e6, + environ={ + 'SCHEME': 'CronetTests' + })) + out.append( + self.config.job_spec( + ['src/objective-c/tests/run_one_test.sh'], + timeout_seconds=60 * 60, + shortname='mac-test-basictests', + cpu_cost=1e6, + environ={ + 'SCHEME': 'MacTests' + })) return sorted(out) From 3e843d68d09ac49600b2bcbd4bf42941119cbb10 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Wed, 19 Jun 2019 14:59:26 -0700 Subject: [PATCH 0593/1555] Skip all ruby distrib tests that use ruby 2.2 --- tools/run_tests/artifacts/distribtest_targets.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/run_tests/artifacts/distribtest_targets.py b/tools/run_tests/artifacts/distribtest_targets.py index fd68a4dc747..1e861029faa 100644 --- a/tools/run_tests/artifacts/distribtest_targets.py +++ b/tools/run_tests/artifacts/distribtest_targets.py @@ -336,17 +336,18 @@ def targets(): PythonDistribTest('linux', 'x64', 'ubuntu1404', source=True), PythonDistribTest('linux', 'x64', 'ubuntu1604', source=True), RubyDistribTest('linux', 'x64', 'wheezy'), - RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_2'), RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_3'), RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_4'), RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_5'), RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_6'), - RubyDistribTest('linux', 'x64', 'centos6'), - RubyDistribTest('linux', 'x64', 'centos7'), - RubyDistribTest('linux', 'x64', 'fedora20'), - RubyDistribTest('linux', 'x64', 'fedora21'), - RubyDistribTest('linux', 'x64', 'fedora22'), - RubyDistribTest('linux', 'x64', 'fedora23'), + # TODO(apolcyn): unskip these after upgrading the ruby versions + # of these dockerfiles to >= 2.3. + # RubyDistribTest('linux', 'x64', 'centos6'), + # RubyDistribTest('linux', 'x64', 'centos7'), + # RubyDistribTest('linux', 'x64', 'fedora20'), + # RubyDistribTest('linux', 'x64', 'fedora21'), + # RubyDistribTest('linux', 'x64', 'fedora22'), + # RubyDistribTest('linux', 'x64', 'fedora23'), RubyDistribTest('linux', 'x64', 'opensuse'), RubyDistribTest('linux', 'x64', 'ubuntu1204'), RubyDistribTest('linux', 'x64', 'ubuntu1404'), From 621707370aa5d546e1325a61de7eab8e1db36b18 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Wed, 19 Jun 2019 14:59:26 -0700 Subject: [PATCH 0594/1555] Skip all ruby distrib tests that use ruby 2.2 --- tools/run_tests/artifacts/distribtest_targets.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/run_tests/artifacts/distribtest_targets.py b/tools/run_tests/artifacts/distribtest_targets.py index fd68a4dc747..1e861029faa 100644 --- a/tools/run_tests/artifacts/distribtest_targets.py +++ b/tools/run_tests/artifacts/distribtest_targets.py @@ -336,17 +336,18 @@ def targets(): PythonDistribTest('linux', 'x64', 'ubuntu1404', source=True), PythonDistribTest('linux', 'x64', 'ubuntu1604', source=True), RubyDistribTest('linux', 'x64', 'wheezy'), - RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_2'), RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_3'), RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_4'), RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_5'), RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_6'), - RubyDistribTest('linux', 'x64', 'centos6'), - RubyDistribTest('linux', 'x64', 'centos7'), - RubyDistribTest('linux', 'x64', 'fedora20'), - RubyDistribTest('linux', 'x64', 'fedora21'), - RubyDistribTest('linux', 'x64', 'fedora22'), - RubyDistribTest('linux', 'x64', 'fedora23'), + # TODO(apolcyn): unskip these after upgrading the ruby versions + # of these dockerfiles to >= 2.3. + # RubyDistribTest('linux', 'x64', 'centos6'), + # RubyDistribTest('linux', 'x64', 'centos7'), + # RubyDistribTest('linux', 'x64', 'fedora20'), + # RubyDistribTest('linux', 'x64', 'fedora21'), + # RubyDistribTest('linux', 'x64', 'fedora22'), + # RubyDistribTest('linux', 'x64', 'fedora23'), RubyDistribTest('linux', 'x64', 'opensuse'), RubyDistribTest('linux', 'x64', 'ubuntu1204'), RubyDistribTest('linux', 'x64', 'ubuntu1404'), From 5255b49fbc3b810bd56df31a2f9ea98cf5ff9c8c Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 19 Jun 2019 15:40:22 -0700 Subject: [PATCH 0595/1555] fix run_one_test --- src/objective-c/tests/run_one_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/tests/run_one_test.sh b/src/objective-c/tests/run_one_test.sh index 04cba0e321a..342d5a5b38d 100755 --- a/src/objective-c/tests/run_one_test.sh +++ b/src/objective-c/tests/run_one_test.sh @@ -47,7 +47,7 @@ XCODEBUILD_FILTER='(^CompileC |^Ld |^ *[^ ]*clang |^ *cd |^ *export |^Libtool |^ xcodebuild \ -workspace Tests.xcworkspace \ - -scheme SCHEME \ + -scheme $SCHEME \ -destination name="iPhone 8" \ HOST_PORT_LOCALSSL=localhost:$TLS_PORT \ HOST_PORT_LOCAL=localhost:$PLAIN_PORT \ From ad22f9d7bffc00aed71ef00d97b4639bb3795e60 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Wed, 19 Jun 2019 16:24:59 -0700 Subject: [PATCH 0596/1555] Add delete operator overload --- BUILD | 4 ++-- BUILD.gn | 6 +++--- CMakeLists.txt | 12 ++++++------ Makefile | 12 ++++++------ build.yaml | 4 ++-- config.m4 | 4 ++-- config.w32 | 4 ++-- gRPC-C++.podspec | 4 ++-- gRPC-Core.podspec | 6 +++--- grpc.gemspec | 4 ++-- grpc.gyp | 8 ++++---- package.xml | 4 ++-- .../iomgr/{threadpool => executor}/mpmcqueue.cc | 2 +- .../iomgr/{threadpool => executor}/mpmcqueue.h | 17 +++++++++++++---- src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/iomgr/mpmcqueue_test.cc | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- tools/doxygen/Doxyfile.core.internal | 4 ++-- .../generated/sources_and_headers.json | 6 +++--- 19 files changed, 58 insertions(+), 49 deletions(-) rename src/core/lib/iomgr/{threadpool => executor}/mpmcqueue.cc (98%) rename src/core/lib/iomgr/{threadpool => executor}/mpmcqueue.h (92%) diff --git a/BUILD b/BUILD index 9abcf7ece9a..a3d1ab01ae2 100644 --- a/BUILD +++ b/BUILD @@ -837,7 +837,7 @@ grpc_cc_library( "src/core/lib/iomgr/tcp_server_windows.cc", "src/core/lib/iomgr/tcp_uv.cc", "src/core/lib/iomgr/tcp_windows.cc", - "src/core/lib/iomgr/threadpool/mpmcqueue.cc", + "src/core/lib/iomgr/executor/mpmcqueue.cc", "src/core/lib/iomgr/time_averaged_stats.cc", "src/core/lib/iomgr/timer.cc", "src/core/lib/iomgr/timer_custom.cc", @@ -983,7 +983,7 @@ grpc_cc_library( "src/core/lib/iomgr/tcp_server.h", "src/core/lib/iomgr/tcp_server_utils_posix.h", "src/core/lib/iomgr/tcp_windows.h", - "src/core/lib/iomgr/threadpool/mpmcqueue.h", + "src/core/lib/iomgr/executor/mpmcqueue.h", "src/core/lib/iomgr/time_averaged_stats.h", "src/core/lib/iomgr/timer.h", "src/core/lib/iomgr/timer_custom.h", diff --git a/BUILD.gn b/BUILD.gn index 2ec4609c06d..dfb6e781fec 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -524,6 +524,8 @@ config("grpc_config") { "src/core/lib/iomgr/exec_ctx.h", "src/core/lib/iomgr/executor.cc", "src/core/lib/iomgr/executor.h", + "src/core/lib/iomgr/executor/mpmcqueue.cc", + "src/core/lib/iomgr/executor/mpmcqueue.h", "src/core/lib/iomgr/fork_posix.cc", "src/core/lib/iomgr/fork_windows.cc", "src/core/lib/iomgr/gethostname.h", @@ -622,8 +624,6 @@ config("grpc_config") { "src/core/lib/iomgr/tcp_uv.cc", "src/core/lib/iomgr/tcp_windows.cc", "src/core/lib/iomgr/tcp_windows.h", - "src/core/lib/iomgr/threadpool/mpmcqueue.cc", - "src/core/lib/iomgr/threadpool/mpmcqueue.h", "src/core/lib/iomgr/time_averaged_stats.cc", "src/core/lib/iomgr/time_averaged_stats.h", "src/core/lib/iomgr/timer.cc", @@ -1228,6 +1228,7 @@ config("grpc_config") { "src/core/lib/iomgr/ev_posix.h", "src/core/lib/iomgr/exec_ctx.h", "src/core/lib/iomgr/executor.h", + "src/core/lib/iomgr/executor/mpmcqueue.h", "src/core/lib/iomgr/gethostname.h", "src/core/lib/iomgr/grpc_if_nametoindex.h", "src/core/lib/iomgr/internal_errqueue.h", @@ -1269,7 +1270,6 @@ config("grpc_config") { "src/core/lib/iomgr/tcp_server.h", "src/core/lib/iomgr/tcp_server_utils_posix.h", "src/core/lib/iomgr/tcp_windows.h", - "src/core/lib/iomgr/threadpool/mpmcqueue.h", "src/core/lib/iomgr/time_averaged_stats.h", "src/core/lib/iomgr/timer.h", "src/core/lib/iomgr/timer_custom.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 7438eaf37cc..625513dce77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1027,6 +1027,7 @@ add_library(grpc src/core/lib/iomgr/ev_windows.cc src/core/lib/iomgr/exec_ctx.cc src/core/lib/iomgr/executor.cc + src/core/lib/iomgr/executor/mpmcqueue.cc src/core/lib/iomgr/fork_posix.cc src/core/lib/iomgr/fork_windows.cc src/core/lib/iomgr/gethostname_fallback.cc @@ -1084,7 +1085,6 @@ add_library(grpc src/core/lib/iomgr/tcp_server_windows.cc src/core/lib/iomgr/tcp_uv.cc src/core/lib/iomgr/tcp_windows.cc - src/core/lib/iomgr/threadpool/mpmcqueue.cc src/core/lib/iomgr/time_averaged_stats.cc src/core/lib/iomgr/timer.cc src/core/lib/iomgr/timer_custom.cc @@ -1463,6 +1463,7 @@ add_library(grpc_cronet src/core/lib/iomgr/ev_windows.cc src/core/lib/iomgr/exec_ctx.cc src/core/lib/iomgr/executor.cc + src/core/lib/iomgr/executor/mpmcqueue.cc src/core/lib/iomgr/fork_posix.cc src/core/lib/iomgr/fork_windows.cc src/core/lib/iomgr/gethostname_fallback.cc @@ -1520,7 +1521,6 @@ add_library(grpc_cronet src/core/lib/iomgr/tcp_server_windows.cc src/core/lib/iomgr/tcp_uv.cc src/core/lib/iomgr/tcp_windows.cc - src/core/lib/iomgr/threadpool/mpmcqueue.cc src/core/lib/iomgr/time_averaged_stats.cc src/core/lib/iomgr/timer.cc src/core/lib/iomgr/timer_custom.cc @@ -1881,6 +1881,7 @@ add_library(grpc_test_util src/core/lib/iomgr/ev_windows.cc src/core/lib/iomgr/exec_ctx.cc src/core/lib/iomgr/executor.cc + src/core/lib/iomgr/executor/mpmcqueue.cc src/core/lib/iomgr/fork_posix.cc src/core/lib/iomgr/fork_windows.cc src/core/lib/iomgr/gethostname_fallback.cc @@ -1938,7 +1939,6 @@ add_library(grpc_test_util src/core/lib/iomgr/tcp_server_windows.cc src/core/lib/iomgr/tcp_uv.cc src/core/lib/iomgr/tcp_windows.cc - src/core/lib/iomgr/threadpool/mpmcqueue.cc src/core/lib/iomgr/time_averaged_stats.cc src/core/lib/iomgr/timer.cc src/core/lib/iomgr/timer_custom.cc @@ -2212,6 +2212,7 @@ add_library(grpc_test_util_unsecure src/core/lib/iomgr/ev_windows.cc src/core/lib/iomgr/exec_ctx.cc src/core/lib/iomgr/executor.cc + src/core/lib/iomgr/executor/mpmcqueue.cc src/core/lib/iomgr/fork_posix.cc src/core/lib/iomgr/fork_windows.cc src/core/lib/iomgr/gethostname_fallback.cc @@ -2269,7 +2270,6 @@ add_library(grpc_test_util_unsecure src/core/lib/iomgr/tcp_server_windows.cc src/core/lib/iomgr/tcp_uv.cc src/core/lib/iomgr/tcp_windows.cc - src/core/lib/iomgr/threadpool/mpmcqueue.cc src/core/lib/iomgr/time_averaged_stats.cc src/core/lib/iomgr/timer.cc src/core/lib/iomgr/timer_custom.cc @@ -2519,6 +2519,7 @@ add_library(grpc_unsecure src/core/lib/iomgr/ev_windows.cc src/core/lib/iomgr/exec_ctx.cc src/core/lib/iomgr/executor.cc + src/core/lib/iomgr/executor/mpmcqueue.cc src/core/lib/iomgr/fork_posix.cc src/core/lib/iomgr/fork_windows.cc src/core/lib/iomgr/gethostname_fallback.cc @@ -2576,7 +2577,6 @@ add_library(grpc_unsecure src/core/lib/iomgr/tcp_server_windows.cc src/core/lib/iomgr/tcp_uv.cc src/core/lib/iomgr/tcp_windows.cc - src/core/lib/iomgr/threadpool/mpmcqueue.cc src/core/lib/iomgr/time_averaged_stats.cc src/core/lib/iomgr/timer.cc src/core/lib/iomgr/timer_custom.cc @@ -3546,6 +3546,7 @@ add_library(grpc++_cronet src/core/lib/iomgr/ev_windows.cc src/core/lib/iomgr/exec_ctx.cc src/core/lib/iomgr/executor.cc + src/core/lib/iomgr/executor/mpmcqueue.cc src/core/lib/iomgr/fork_posix.cc src/core/lib/iomgr/fork_windows.cc src/core/lib/iomgr/gethostname_fallback.cc @@ -3603,7 +3604,6 @@ add_library(grpc++_cronet src/core/lib/iomgr/tcp_server_windows.cc src/core/lib/iomgr/tcp_uv.cc src/core/lib/iomgr/tcp_windows.cc - src/core/lib/iomgr/threadpool/mpmcqueue.cc src/core/lib/iomgr/time_averaged_stats.cc src/core/lib/iomgr/timer.cc src/core/lib/iomgr/timer_custom.cc diff --git a/Makefile b/Makefile index 717402673b4..3668555e49f 100644 --- a/Makefile +++ b/Makefile @@ -3520,6 +3520,7 @@ LIBGRPC_SRC = \ src/core/lib/iomgr/ev_windows.cc \ src/core/lib/iomgr/exec_ctx.cc \ src/core/lib/iomgr/executor.cc \ + src/core/lib/iomgr/executor/mpmcqueue.cc \ src/core/lib/iomgr/fork_posix.cc \ src/core/lib/iomgr/fork_windows.cc \ src/core/lib/iomgr/gethostname_fallback.cc \ @@ -3577,7 +3578,6 @@ LIBGRPC_SRC = \ src/core/lib/iomgr/tcp_server_windows.cc \ src/core/lib/iomgr/tcp_uv.cc \ src/core/lib/iomgr/tcp_windows.cc \ - src/core/lib/iomgr/threadpool/mpmcqueue.cc \ src/core/lib/iomgr/time_averaged_stats.cc \ src/core/lib/iomgr/timer.cc \ src/core/lib/iomgr/timer_custom.cc \ @@ -3950,6 +3950,7 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/iomgr/ev_windows.cc \ src/core/lib/iomgr/exec_ctx.cc \ src/core/lib/iomgr/executor.cc \ + src/core/lib/iomgr/executor/mpmcqueue.cc \ src/core/lib/iomgr/fork_posix.cc \ src/core/lib/iomgr/fork_windows.cc \ src/core/lib/iomgr/gethostname_fallback.cc \ @@ -4007,7 +4008,6 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/iomgr/tcp_server_windows.cc \ src/core/lib/iomgr/tcp_uv.cc \ src/core/lib/iomgr/tcp_windows.cc \ - src/core/lib/iomgr/threadpool/mpmcqueue.cc \ src/core/lib/iomgr/time_averaged_stats.cc \ src/core/lib/iomgr/timer.cc \ src/core/lib/iomgr/timer_custom.cc \ @@ -4361,6 +4361,7 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/iomgr/ev_windows.cc \ src/core/lib/iomgr/exec_ctx.cc \ src/core/lib/iomgr/executor.cc \ + src/core/lib/iomgr/executor/mpmcqueue.cc \ src/core/lib/iomgr/fork_posix.cc \ src/core/lib/iomgr/fork_windows.cc \ src/core/lib/iomgr/gethostname_fallback.cc \ @@ -4418,7 +4419,6 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/iomgr/tcp_server_windows.cc \ src/core/lib/iomgr/tcp_uv.cc \ src/core/lib/iomgr/tcp_windows.cc \ - src/core/lib/iomgr/threadpool/mpmcqueue.cc \ src/core/lib/iomgr/time_averaged_stats.cc \ src/core/lib/iomgr/timer.cc \ src/core/lib/iomgr/timer_custom.cc \ @@ -4679,6 +4679,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/lib/iomgr/ev_windows.cc \ src/core/lib/iomgr/exec_ctx.cc \ src/core/lib/iomgr/executor.cc \ + src/core/lib/iomgr/executor/mpmcqueue.cc \ src/core/lib/iomgr/fork_posix.cc \ src/core/lib/iomgr/fork_windows.cc \ src/core/lib/iomgr/gethostname_fallback.cc \ @@ -4736,7 +4737,6 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/lib/iomgr/tcp_server_windows.cc \ src/core/lib/iomgr/tcp_uv.cc \ src/core/lib/iomgr/tcp_windows.cc \ - src/core/lib/iomgr/threadpool/mpmcqueue.cc \ src/core/lib/iomgr/time_averaged_stats.cc \ src/core/lib/iomgr/timer.cc \ src/core/lib/iomgr/timer_custom.cc \ @@ -4960,6 +4960,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/iomgr/ev_windows.cc \ src/core/lib/iomgr/exec_ctx.cc \ src/core/lib/iomgr/executor.cc \ + src/core/lib/iomgr/executor/mpmcqueue.cc \ src/core/lib/iomgr/fork_posix.cc \ src/core/lib/iomgr/fork_windows.cc \ src/core/lib/iomgr/gethostname_fallback.cc \ @@ -5017,7 +5018,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/iomgr/tcp_server_windows.cc \ src/core/lib/iomgr/tcp_uv.cc \ src/core/lib/iomgr/tcp_windows.cc \ - src/core/lib/iomgr/threadpool/mpmcqueue.cc \ src/core/lib/iomgr/time_averaged_stats.cc \ src/core/lib/iomgr/timer.cc \ src/core/lib/iomgr/timer_custom.cc \ @@ -5960,6 +5960,7 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/iomgr/ev_windows.cc \ src/core/lib/iomgr/exec_ctx.cc \ src/core/lib/iomgr/executor.cc \ + src/core/lib/iomgr/executor/mpmcqueue.cc \ src/core/lib/iomgr/fork_posix.cc \ src/core/lib/iomgr/fork_windows.cc \ src/core/lib/iomgr/gethostname_fallback.cc \ @@ -6017,7 +6018,6 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/iomgr/tcp_server_windows.cc \ src/core/lib/iomgr/tcp_uv.cc \ src/core/lib/iomgr/tcp_windows.cc \ - src/core/lib/iomgr/threadpool/mpmcqueue.cc \ src/core/lib/iomgr/time_averaged_stats.cc \ src/core/lib/iomgr/timer.cc \ src/core/lib/iomgr/timer_custom.cc \ diff --git a/build.yaml b/build.yaml index a02d7f01fcb..876e3a54440 100644 --- a/build.yaml +++ b/build.yaml @@ -280,6 +280,7 @@ filegroups: - src/core/lib/iomgr/ev_windows.cc - src/core/lib/iomgr/exec_ctx.cc - src/core/lib/iomgr/executor.cc + - src/core/lib/iomgr/executor/mpmcqueue.cc - src/core/lib/iomgr/fork_posix.cc - src/core/lib/iomgr/fork_windows.cc - src/core/lib/iomgr/gethostname_fallback.cc @@ -337,7 +338,6 @@ filegroups: - src/core/lib/iomgr/tcp_server_windows.cc - src/core/lib/iomgr/tcp_uv.cc - src/core/lib/iomgr/tcp_windows.cc - - src/core/lib/iomgr/threadpool/mpmcqueue.cc - src/core/lib/iomgr/time_averaged_stats.cc - src/core/lib/iomgr/timer.cc - src/core/lib/iomgr/timer_custom.cc @@ -467,6 +467,7 @@ filegroups: - src/core/lib/iomgr/ev_posix.h - src/core/lib/iomgr/exec_ctx.h - src/core/lib/iomgr/executor.h + - src/core/lib/iomgr/executor/mpmcqueue.h - src/core/lib/iomgr/gethostname.h - src/core/lib/iomgr/grpc_if_nametoindex.h - src/core/lib/iomgr/internal_errqueue.h @@ -508,7 +509,6 @@ filegroups: - src/core/lib/iomgr/tcp_server.h - src/core/lib/iomgr/tcp_server_utils_posix.h - src/core/lib/iomgr/tcp_windows.h - - src/core/lib/iomgr/threadpool/mpmcqueue.h - src/core/lib/iomgr/time_averaged_stats.h - src/core/lib/iomgr/timer.h - src/core/lib/iomgr/timer_custom.h diff --git a/config.m4 b/config.m4 index 6782f94a2b2..da088819b86 100644 --- a/config.m4 +++ b/config.m4 @@ -127,6 +127,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/iomgr/ev_windows.cc \ src/core/lib/iomgr/exec_ctx.cc \ src/core/lib/iomgr/executor.cc \ + src/core/lib/iomgr/executor/mpmcqueue.cc \ src/core/lib/iomgr/fork_posix.cc \ src/core/lib/iomgr/fork_windows.cc \ src/core/lib/iomgr/gethostname_fallback.cc \ @@ -184,7 +185,6 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/iomgr/tcp_server_windows.cc \ src/core/lib/iomgr/tcp_uv.cc \ src/core/lib/iomgr/tcp_windows.cc \ - src/core/lib/iomgr/threadpool/mpmcqueue.cc \ src/core/lib/iomgr/time_averaged_stats.cc \ src/core/lib/iomgr/timer.cc \ src/core/lib/iomgr/timer_custom.cc \ @@ -727,7 +727,7 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/gprpp) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/http) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/iomgr) - PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/iomgr/threadpool) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/iomgr/executor) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/json) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/profiling) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/security/context) diff --git a/config.w32 b/config.w32 index 8bff737f51f..fe62ac3f75b 100644 --- a/config.w32 +++ b/config.w32 @@ -102,6 +102,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\iomgr\\ev_windows.cc " + "src\\core\\lib\\iomgr\\exec_ctx.cc " + "src\\core\\lib\\iomgr\\executor.cc " + + "src\\core\\lib\\iomgr\\executor\\mpmcqueue.cc " + "src\\core\\lib\\iomgr\\fork_posix.cc " + "src\\core\\lib\\iomgr\\fork_windows.cc " + "src\\core\\lib\\iomgr\\gethostname_fallback.cc " + @@ -159,7 +160,6 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\iomgr\\tcp_server_windows.cc " + "src\\core\\lib\\iomgr\\tcp_uv.cc " + "src\\core\\lib\\iomgr\\tcp_windows.cc " + - "src\\core\\lib\\iomgr\\threadpool\\mpmcqueue.cc " + "src\\core\\lib\\iomgr\\time_averaged_stats.cc " + "src\\core\\lib\\iomgr\\timer.cc " + "src\\core\\lib\\iomgr\\timer_custom.cc " + @@ -740,7 +740,7 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\gprpp"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\http"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\iomgr"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\iomgr\\threadpool"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\iomgr\\executor"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\json"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\profiling"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\security"); diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 55e7e9340a1..2c2bed861c4 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -466,6 +466,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/ev_posix.h', 'src/core/lib/iomgr/exec_ctx.h', 'src/core/lib/iomgr/executor.h', + 'src/core/lib/iomgr/executor/mpmcqueue.h', 'src/core/lib/iomgr/gethostname.h', 'src/core/lib/iomgr/grpc_if_nametoindex.h', 'src/core/lib/iomgr/internal_errqueue.h', @@ -507,7 +508,6 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/tcp_server.h', 'src/core/lib/iomgr/tcp_server_utils_posix.h', 'src/core/lib/iomgr/tcp_windows.h', - 'src/core/lib/iomgr/threadpool/mpmcqueue.h', 'src/core/lib/iomgr/time_averaged_stats.h', 'src/core/lib/iomgr/timer.h', 'src/core/lib/iomgr/timer_custom.h', @@ -671,6 +671,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/ev_posix.h', 'src/core/lib/iomgr/exec_ctx.h', 'src/core/lib/iomgr/executor.h', + 'src/core/lib/iomgr/executor/mpmcqueue.h', 'src/core/lib/iomgr/gethostname.h', 'src/core/lib/iomgr/grpc_if_nametoindex.h', 'src/core/lib/iomgr/internal_errqueue.h', @@ -712,7 +713,6 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/tcp_server.h', 'src/core/lib/iomgr/tcp_server_utils_posix.h', 'src/core/lib/iomgr/tcp_windows.h', - 'src/core/lib/iomgr/threadpool/mpmcqueue.h', 'src/core/lib/iomgr/time_averaged_stats.h', 'src/core/lib/iomgr/timer.h', 'src/core/lib/iomgr/timer_custom.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 56b3d5b0955..ba96b5e86f2 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -436,6 +436,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/ev_posix.h', 'src/core/lib/iomgr/exec_ctx.h', 'src/core/lib/iomgr/executor.h', + 'src/core/lib/iomgr/executor/mpmcqueue.h', 'src/core/lib/iomgr/gethostname.h', 'src/core/lib/iomgr/grpc_if_nametoindex.h', 'src/core/lib/iomgr/internal_errqueue.h', @@ -477,7 +478,6 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/tcp_server.h', 'src/core/lib/iomgr/tcp_server_utils_posix.h', 'src/core/lib/iomgr/tcp_windows.h', - 'src/core/lib/iomgr/threadpool/mpmcqueue.h', 'src/core/lib/iomgr/time_averaged_stats.h', 'src/core/lib/iomgr/timer.h', 'src/core/lib/iomgr/timer_custom.h', @@ -590,6 +590,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/ev_windows.cc', 'src/core/lib/iomgr/exec_ctx.cc', 'src/core/lib/iomgr/executor.cc', + 'src/core/lib/iomgr/executor/mpmcqueue.cc', 'src/core/lib/iomgr/fork_posix.cc', 'src/core/lib/iomgr/fork_windows.cc', 'src/core/lib/iomgr/gethostname_fallback.cc', @@ -647,7 +648,6 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/tcp_server_windows.cc', 'src/core/lib/iomgr/tcp_uv.cc', 'src/core/lib/iomgr/tcp_windows.cc', - 'src/core/lib/iomgr/threadpool/mpmcqueue.cc', 'src/core/lib/iomgr/time_averaged_stats.cc', 'src/core/lib/iomgr/timer.cc', 'src/core/lib/iomgr/timer_custom.cc', @@ -1091,6 +1091,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/ev_posix.h', 'src/core/lib/iomgr/exec_ctx.h', 'src/core/lib/iomgr/executor.h', + 'src/core/lib/iomgr/executor/mpmcqueue.h', 'src/core/lib/iomgr/gethostname.h', 'src/core/lib/iomgr/grpc_if_nametoindex.h', 'src/core/lib/iomgr/internal_errqueue.h', @@ -1132,7 +1133,6 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/tcp_server.h', 'src/core/lib/iomgr/tcp_server_utils_posix.h', 'src/core/lib/iomgr/tcp_windows.h', - 'src/core/lib/iomgr/threadpool/mpmcqueue.h', 'src/core/lib/iomgr/time_averaged_stats.h', 'src/core/lib/iomgr/timer.h', 'src/core/lib/iomgr/timer_custom.h', diff --git a/grpc.gemspec b/grpc.gemspec index 3703533b6d7..65cc9a54f2c 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -370,6 +370,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/iomgr/ev_posix.h ) s.files += %w( src/core/lib/iomgr/exec_ctx.h ) s.files += %w( src/core/lib/iomgr/executor.h ) + s.files += %w( src/core/lib/iomgr/executor/mpmcqueue.h ) s.files += %w( src/core/lib/iomgr/gethostname.h ) s.files += %w( src/core/lib/iomgr/grpc_if_nametoindex.h ) s.files += %w( src/core/lib/iomgr/internal_errqueue.h ) @@ -411,7 +412,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/iomgr/tcp_server.h ) s.files += %w( src/core/lib/iomgr/tcp_server_utils_posix.h ) s.files += %w( src/core/lib/iomgr/tcp_windows.h ) - s.files += %w( src/core/lib/iomgr/threadpool/mpmcqueue.h ) s.files += %w( src/core/lib/iomgr/time_averaged_stats.h ) s.files += %w( src/core/lib/iomgr/timer.h ) s.files += %w( src/core/lib/iomgr/timer_custom.h ) @@ -524,6 +524,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/iomgr/ev_windows.cc ) s.files += %w( src/core/lib/iomgr/exec_ctx.cc ) s.files += %w( src/core/lib/iomgr/executor.cc ) + s.files += %w( src/core/lib/iomgr/executor/mpmcqueue.cc ) s.files += %w( src/core/lib/iomgr/fork_posix.cc ) s.files += %w( src/core/lib/iomgr/fork_windows.cc ) s.files += %w( src/core/lib/iomgr/gethostname_fallback.cc ) @@ -581,7 +582,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/iomgr/tcp_server_windows.cc ) s.files += %w( src/core/lib/iomgr/tcp_uv.cc ) s.files += %w( src/core/lib/iomgr/tcp_windows.cc ) - s.files += %w( src/core/lib/iomgr/threadpool/mpmcqueue.cc ) s.files += %w( src/core/lib/iomgr/time_averaged_stats.cc ) s.files += %w( src/core/lib/iomgr/timer.cc ) s.files += %w( src/core/lib/iomgr/timer_custom.cc ) diff --git a/grpc.gyp b/grpc.gyp index f64c80c2008..92d34f1557a 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -309,6 +309,7 @@ 'src/core/lib/iomgr/ev_windows.cc', 'src/core/lib/iomgr/exec_ctx.cc', 'src/core/lib/iomgr/executor.cc', + 'src/core/lib/iomgr/executor/mpmcqueue.cc', 'src/core/lib/iomgr/fork_posix.cc', 'src/core/lib/iomgr/fork_windows.cc', 'src/core/lib/iomgr/gethostname_fallback.cc', @@ -366,7 +367,6 @@ 'src/core/lib/iomgr/tcp_server_windows.cc', 'src/core/lib/iomgr/tcp_uv.cc', 'src/core/lib/iomgr/tcp_windows.cc', - 'src/core/lib/iomgr/threadpool/mpmcqueue.cc', 'src/core/lib/iomgr/time_averaged_stats.cc', 'src/core/lib/iomgr/timer.cc', 'src/core/lib/iomgr/timer_custom.cc', @@ -686,6 +686,7 @@ 'src/core/lib/iomgr/ev_windows.cc', 'src/core/lib/iomgr/exec_ctx.cc', 'src/core/lib/iomgr/executor.cc', + 'src/core/lib/iomgr/executor/mpmcqueue.cc', 'src/core/lib/iomgr/fork_posix.cc', 'src/core/lib/iomgr/fork_windows.cc', 'src/core/lib/iomgr/gethostname_fallback.cc', @@ -743,7 +744,6 @@ 'src/core/lib/iomgr/tcp_server_windows.cc', 'src/core/lib/iomgr/tcp_uv.cc', 'src/core/lib/iomgr/tcp_windows.cc', - 'src/core/lib/iomgr/threadpool/mpmcqueue.cc', 'src/core/lib/iomgr/time_averaged_stats.cc', 'src/core/lib/iomgr/timer.cc', 'src/core/lib/iomgr/timer_custom.cc', @@ -937,6 +937,7 @@ 'src/core/lib/iomgr/ev_windows.cc', 'src/core/lib/iomgr/exec_ctx.cc', 'src/core/lib/iomgr/executor.cc', + 'src/core/lib/iomgr/executor/mpmcqueue.cc', 'src/core/lib/iomgr/fork_posix.cc', 'src/core/lib/iomgr/fork_windows.cc', 'src/core/lib/iomgr/gethostname_fallback.cc', @@ -994,7 +995,6 @@ 'src/core/lib/iomgr/tcp_server_windows.cc', 'src/core/lib/iomgr/tcp_uv.cc', 'src/core/lib/iomgr/tcp_windows.cc', - 'src/core/lib/iomgr/threadpool/mpmcqueue.cc', 'src/core/lib/iomgr/time_averaged_stats.cc', 'src/core/lib/iomgr/timer.cc', 'src/core/lib/iomgr/timer_custom.cc', @@ -1164,6 +1164,7 @@ 'src/core/lib/iomgr/ev_windows.cc', 'src/core/lib/iomgr/exec_ctx.cc', 'src/core/lib/iomgr/executor.cc', + 'src/core/lib/iomgr/executor/mpmcqueue.cc', 'src/core/lib/iomgr/fork_posix.cc', 'src/core/lib/iomgr/fork_windows.cc', 'src/core/lib/iomgr/gethostname_fallback.cc', @@ -1221,7 +1222,6 @@ 'src/core/lib/iomgr/tcp_server_windows.cc', 'src/core/lib/iomgr/tcp_uv.cc', 'src/core/lib/iomgr/tcp_windows.cc', - 'src/core/lib/iomgr/threadpool/mpmcqueue.cc', 'src/core/lib/iomgr/time_averaged_stats.cc', 'src/core/lib/iomgr/timer.cc', 'src/core/lib/iomgr/timer_custom.cc', diff --git a/package.xml b/package.xml index 77162f3d366..5c982926a8c 100644 --- a/package.xml +++ b/package.xml @@ -375,6 +375,7 @@ + @@ -416,7 +417,6 @@ - @@ -529,6 +529,7 @@ + @@ -586,7 +587,6 @@ - diff --git a/src/core/lib/iomgr/threadpool/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc similarity index 98% rename from src/core/lib/iomgr/threadpool/mpmcqueue.cc rename to src/core/lib/iomgr/executor/mpmcqueue.cc index f39abe572c0..ea29fe9e7e6 100644 --- a/src/core/lib/iomgr/threadpool/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -18,7 +18,7 @@ #include -#include "src/core/lib/iomgr/threadpool/mpmcqueue.h" +#include "src/core/lib/iomgr/executor/mpmcqueue.h" #include #include diff --git a/src/core/lib/iomgr/threadpool/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h similarity index 92% rename from src/core/lib/iomgr/threadpool/mpmcqueue.h rename to src/core/lib/iomgr/executor/mpmcqueue.h index 2d77a281c5b..33240eaf6f6 100644 --- a/src/core/lib/iomgr/threadpool/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -16,8 +16,8 @@ * */ -#ifndef GRPC_CORE_LIB_IOMGR_THREADPOOL_MPMCQUEUE_H -#define GRPC_CORE_LIB_IOMGR_THREADPOOL_MPMCQUEUE_H +#ifndef GRPC_CORE_LIB_IOMGR_EXECUTOR_MPMCQUEUE_H +#define GRPC_CORE_LIB_IOMGR_EXECUTOR_MPMCQUEUE_H #include @@ -53,7 +53,7 @@ class MPMCQueue : public MPMCQueueInterface { public: // Create a new Multiple-Producer-Multiple-Consumer Queue. The queue created // will have infinite length. - explicit MPMCQueue(); + MPMCQueue(); // Release all resources hold by the queue. The queue must be empty, and no // one waiting on conditional variables. @@ -72,6 +72,15 @@ class MPMCQueue : public MPMCQueueInterface { // quickly. int count() const { return count_.Load(MemoryOrder::RELAXED); } + void* operator new(size_t n) { + void* p = gpr_malloc(n); + return p; + } + + void operator delete(void* p) { + gpr_free(p); + } + private: void* PopFront(); @@ -122,4 +131,4 @@ class MPMCQueue : public MPMCQueueInterface { } // namespace grpc_core -#endif /* GRPC_CORE_LIB_IOMGR_THREADPOOL_MPMCQUEUE_H */ +#endif /* GRPC_CORE_LIB_IOMGR_EXECUTOR_MPMCQUEUE_H */ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index fc9979f418e..5e04cc564fb 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -101,6 +101,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/iomgr/ev_windows.cc', 'src/core/lib/iomgr/exec_ctx.cc', 'src/core/lib/iomgr/executor.cc', + 'src/core/lib/iomgr/executor/mpmcqueue.cc', 'src/core/lib/iomgr/fork_posix.cc', 'src/core/lib/iomgr/fork_windows.cc', 'src/core/lib/iomgr/gethostname_fallback.cc', @@ -158,7 +159,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/iomgr/tcp_server_windows.cc', 'src/core/lib/iomgr/tcp_uv.cc', 'src/core/lib/iomgr/tcp_windows.cc', - 'src/core/lib/iomgr/threadpool/mpmcqueue.cc', 'src/core/lib/iomgr/time_averaged_stats.cc', 'src/core/lib/iomgr/timer.cc', 'src/core/lib/iomgr/timer_custom.cc', diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index e40a350c18c..9fa09153708 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -16,7 +16,7 @@ * */ -#include "src/core/lib/iomgr/threadpool/mpmcqueue.h" +#include "src/core/lib/iomgr/executor/mpmcqueue.h" #include #include diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index e5e78ffbb4b..68db69546b8 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1131,6 +1131,7 @@ src/core/lib/iomgr/ev_poll_posix.h \ src/core/lib/iomgr/ev_posix.h \ src/core/lib/iomgr/exec_ctx.h \ src/core/lib/iomgr/executor.h \ +src/core/lib/iomgr/executor/mpmcqueue.h \ src/core/lib/iomgr/gethostname.h \ src/core/lib/iomgr/grpc_if_nametoindex.h \ src/core/lib/iomgr/internal_errqueue.h \ @@ -1172,7 +1173,6 @@ src/core/lib/iomgr/tcp_posix.h \ src/core/lib/iomgr/tcp_server.h \ src/core/lib/iomgr/tcp_server_utils_posix.h \ src/core/lib/iomgr/tcp_windows.h \ -src/core/lib/iomgr/threadpool/mpmcqueue.h \ src/core/lib/iomgr/time_averaged_stats.h \ src/core/lib/iomgr/timer.h \ src/core/lib/iomgr/timer_custom.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 83a9315d5af..a79b213d49f 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1233,6 +1233,8 @@ src/core/lib/iomgr/exec_ctx.cc \ src/core/lib/iomgr/exec_ctx.h \ src/core/lib/iomgr/executor.cc \ src/core/lib/iomgr/executor.h \ +src/core/lib/iomgr/executor/mpmcqueue.cc \ +src/core/lib/iomgr/executor/mpmcqueue.h \ src/core/lib/iomgr/fork_posix.cc \ src/core/lib/iomgr/fork_windows.cc \ src/core/lib/iomgr/gethostname.h \ @@ -1331,8 +1333,6 @@ src/core/lib/iomgr/tcp_server_windows.cc \ src/core/lib/iomgr/tcp_uv.cc \ src/core/lib/iomgr/tcp_windows.cc \ src/core/lib/iomgr/tcp_windows.h \ -src/core/lib/iomgr/threadpool/mpmcqueue.cc \ -src/core/lib/iomgr/threadpool/mpmcqueue.h \ src/core/lib/iomgr/time_averaged_stats.cc \ src/core/lib/iomgr/time_averaged_stats.h \ src/core/lib/iomgr/timer.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 3fad15ca046..6a420677811 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -8442,6 +8442,7 @@ "src/core/lib/iomgr/ev_windows.cc", "src/core/lib/iomgr/exec_ctx.cc", "src/core/lib/iomgr/executor.cc", + "src/core/lib/iomgr/executor/mpmcqueue.cc", "src/core/lib/iomgr/fork_posix.cc", "src/core/lib/iomgr/fork_windows.cc", "src/core/lib/iomgr/gethostname_fallback.cc", @@ -8499,7 +8500,6 @@ "src/core/lib/iomgr/tcp_server_windows.cc", "src/core/lib/iomgr/tcp_uv.cc", "src/core/lib/iomgr/tcp_windows.cc", - "src/core/lib/iomgr/threadpool/mpmcqueue.cc", "src/core/lib/iomgr/time_averaged_stats.cc", "src/core/lib/iomgr/timer.cc", "src/core/lib/iomgr/timer_custom.cc", @@ -8630,6 +8630,7 @@ "src/core/lib/iomgr/ev_posix.h", "src/core/lib/iomgr/exec_ctx.h", "src/core/lib/iomgr/executor.h", + "src/core/lib/iomgr/executor/mpmcqueue.h", "src/core/lib/iomgr/gethostname.h", "src/core/lib/iomgr/grpc_if_nametoindex.h", "src/core/lib/iomgr/internal_errqueue.h", @@ -8671,7 +8672,6 @@ "src/core/lib/iomgr/tcp_server.h", "src/core/lib/iomgr/tcp_server_utils_posix.h", "src/core/lib/iomgr/tcp_windows.h", - "src/core/lib/iomgr/threadpool/mpmcqueue.h", "src/core/lib/iomgr/time_averaged_stats.h", "src/core/lib/iomgr/timer.h", "src/core/lib/iomgr/timer_custom.h", @@ -8788,6 +8788,7 @@ "src/core/lib/iomgr/ev_posix.h", "src/core/lib/iomgr/exec_ctx.h", "src/core/lib/iomgr/executor.h", + "src/core/lib/iomgr/executor/mpmcqueue.h", "src/core/lib/iomgr/gethostname.h", "src/core/lib/iomgr/grpc_if_nametoindex.h", "src/core/lib/iomgr/internal_errqueue.h", @@ -8829,7 +8830,6 @@ "src/core/lib/iomgr/tcp_server.h", "src/core/lib/iomgr/tcp_server_utils_posix.h", "src/core/lib/iomgr/tcp_windows.h", - "src/core/lib/iomgr/threadpool/mpmcqueue.h", "src/core/lib/iomgr/time_averaged_stats.h", "src/core/lib/iomgr/timer.h", "src/core/lib/iomgr/timer_custom.h", From 01ffaf8bac76359058c0f040a2c68efd0b0ee59c Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Wed, 19 Jun 2019 16:34:40 -0700 Subject: [PATCH 0597/1555] Add GRPC Abstract Macro --- src/core/lib/iomgr/executor/mpmcqueue.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index 33240eaf6f6..c710600fddf 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -24,8 +24,9 @@ #include #include -#include "src/core/lib/debug/stats.h" +#include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/atomic.h" +#include "src/core/lib/debug/stats.h" #include "src/core/lib/gprpp/sync.h" namespace grpc_core { @@ -39,14 +40,14 @@ class MPMCQueueInterface { // Put elem into queue immediately at the end of queue. // This might cause to block on full queue depending on implementation. - virtual void Put(void* elem) = 0; + virtual void Put(void* elem) GRPC_ABSTRACT; // Remove the oldest element from the queue and return it. // This might cause to block on empty queue depending on implementation. - virtual void* Get() = 0; + virtual void* Get() GRPC_ABSTRACT; // Return number of elements in the queue currently - virtual int count() const = 0; + virtual int count() const GRPC_ABSTRACT; }; class MPMCQueue : public MPMCQueueInterface { @@ -72,14 +73,7 @@ class MPMCQueue : public MPMCQueueInterface { // quickly. int count() const { return count_.Load(MemoryOrder::RELAXED); } - void* operator new(size_t n) { - void* p = gpr_malloc(n); - return p; - } - - void operator delete(void* p) { - gpr_free(p); - } + GRPC_ABSTRACT_BASE_CLASS private: void* PopFront(); From 1c6e8a07258102affe790deb9e1d9a737eaac69a Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Wed, 19 Jun 2019 16:41:41 -0700 Subject: [PATCH 0598/1555] Change getpagesize for portability --- src/core/lib/gprpp/thd_posix.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/gprpp/thd_posix.cc b/src/core/lib/gprpp/thd_posix.cc index 965a3ba229a..e26ee507a3d 100644 --- a/src/core/lib/gprpp/thd_posix.cc +++ b/src/core/lib/gprpp/thd_posix.cc @@ -50,7 +50,7 @@ struct thd_arg { }; size_t RoundUpToPageSize(size_t size) { - size_t page_size = static_cast(getpagesize()); + size_t page_size = static_cast(sysconf(_SC_PAGESIZE)); return (size + page_size - 1) & ~(page_size - 1); } From 58e36f10344051ba98fa07b069df96742f8a97d7 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Wed, 19 Jun 2019 16:55:06 -0700 Subject: [PATCH 0599/1555] Add base class abstract macro to all classes --- src/core/lib/iomgr/executor/mpmcqueue.h | 2 ++ test/core/iomgr/mpmcqueue_test.cc | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index c710600fddf..0fdd1d2d5a0 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -48,6 +48,8 @@ class MPMCQueueInterface { // Return number of elements in the queue currently virtual int count() const GRPC_ABSTRACT; + + GRPC_ABSTRACT_BASE_CLASS }; class MPMCQueue : public MPMCQueueInterface { diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index 9fa09153708..10a934ed149 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -141,6 +141,8 @@ class WorkThread { void Start() { thd_.Start(); } void Join() { thd_.Join(); } + GRPC_ABSTRACT_BASE_CLASS + private: void Run() { items_ = new WorkItem*[num_items_]; From 54c05c48956b6282c58b21b97d57fcfa89e04b28 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Wed, 19 Jun 2019 16:59:39 -0700 Subject: [PATCH 0600/1555] Remove extra status print --- src/core/lib/iomgr/executor/mpmcqueue.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index ea29fe9e7e6..286267fce43 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -81,9 +81,6 @@ MPMCQueue::~MPMCQueue() { GPR_ASSERT(count_.Load(MemoryOrder::RELAXED) == 0); MutexLock l(&mu_); GPR_ASSERT(num_waiters_ == 0); - if (GRPC_TRACE_FLAG_ENABLED(thread_pool_trace)) { - PrintStats(); - } } void MPMCQueue::Put(void* elem) { From 2fbd77aee45c60cfda583f5373e33c3cc86ef506 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Wed, 19 Jun 2019 17:16:23 -0700 Subject: [PATCH 0601/1555] Fix Node compile error on operator overload --- src/core/lib/iomgr/executor/mpmcqueue.h | 1 + test/core/iomgr/mpmcqueue_test.cc | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index 0fdd1d2d5a0..e19b66241fb 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -92,6 +92,7 @@ class MPMCQueue : public MPMCQueueInterface { next = nullptr; insert_time = gpr_now(GPR_CLOCK_PRECISE); } + GRPC_ABSTRACT_BASE_CLASS }; struct Stats { // Stats of queue diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index 10a934ed149..9fa09153708 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -141,8 +141,6 @@ class WorkThread { void Start() { thd_.Start(); } void Join() { thd_.Join(); } - GRPC_ABSTRACT_BASE_CLASS - private: void Run() { items_ = new WorkItem*[num_items_]; From a3a5685d298c7f57f6ba61b03848c8a88a8e52aa Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Wed, 19 Jun 2019 17:40:56 -0700 Subject: [PATCH 0602/1555] Modify Node allocate/deallocate --- src/core/lib/iomgr/executor/mpmcqueue.cc | 7 +++++-- src/core/lib/iomgr/executor/mpmcqueue.h | 5 +---- test/core/iomgr/mpmcqueue_test.cc | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index 286267fce43..d7266b433a3 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -45,7 +45,7 @@ inline void* MPMCQueue::PopFront() { gpr_timespec wait_time = gpr_time_sub(gpr_now(GPR_CLOCK_PRECISE), head_to_remove->insert_time); - delete head_to_remove; + gpr_free(head_to_remove); // Update Stats info stats_.num_completed++; @@ -86,7 +86,10 @@ MPMCQueue::~MPMCQueue() { void MPMCQueue::Put(void* elem) { MutexLock l(&mu_); - Node* new_node = static_cast(new Node(elem)); + Node* new_node = static_cast(gpr_malloc(sizeof(Node))); + new_node->next = nullptr; + new_node->content = elem; + new_node->insert_time = gpr_now(GPR_CLOCK_PRECISE); if (count_.Load(MemoryOrder::RELAXED) == 0) { busy_time = gpr_now(GPR_CLOCK_PRECISE); queue_head_ = queue_tail_ = new_node; diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index e19b66241fb..2f27ab3b9c9 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -47,9 +47,7 @@ class MPMCQueueInterface { virtual void* Get() GRPC_ABSTRACT; // Return number of elements in the queue currently - virtual int count() const GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS + virtual int count() const GRPC_ABSTRACT; }; class MPMCQueue : public MPMCQueueInterface { @@ -92,7 +90,6 @@ class MPMCQueue : public MPMCQueueInterface { next = nullptr; insert_time = gpr_now(GPR_CLOCK_PRECISE); } - GRPC_ABSTRACT_BASE_CLASS }; struct Stats { // Stats of queue diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index 9fa09153708..12799d7895e 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -58,6 +58,7 @@ static void test_small_queue(void) { GPR_ASSERT(i == item->index); delete item; } + gpr_log(GPR_DEBUG, "Done."); } static void test_get_thd(void* args) { From 53eef664d3d8b2245ea98d6299127348919c20e5 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Wed, 19 Jun 2019 18:00:49 -0700 Subject: [PATCH 0603/1555] clang-format --- src/core/lib/iomgr/executor/mpmcqueue.cc | 5 ++--- src/core/lib/iomgr/executor/mpmcqueue.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index d7266b433a3..7dc7be87e79 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -20,14 +20,13 @@ #include "src/core/lib/iomgr/executor/mpmcqueue.h" -#include -#include - #include #include #include #include #include +#include +#include #include "src/core/lib/debug/stats.h" #include "src/core/lib/gprpp/sync.h" diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index 2f27ab3b9c9..39396eeaad0 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -24,9 +24,9 @@ #include #include +#include "src/core/lib/debug/stats.h" #include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/atomic.h" -#include "src/core/lib/debug/stats.h" #include "src/core/lib/gprpp/sync.h" namespace grpc_core { From a75acbb6ae31cf242b0a080791fead613ac2d470 Mon Sep 17 00:00:00 2001 From: Qiancheng Zhao Date: Wed, 19 Jun 2019 19:25:44 -0700 Subject: [PATCH 0604/1555] Unref unselected subchannels in Pick First. --- .../lb_policy/pick_first/pick_first.cc | 117 +++++++++--------- 1 file changed, 59 insertions(+), 58 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index 00036d8be64..e0deed27442 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -128,6 +128,10 @@ class PickFirst : public LoadBalancingPolicy { void ShutdownLocked() override; + void AttemptToConnectUsingLatestUpdateArgsLocked(); + + // Lateset update args. + UpdateArgs latest_update_args_; // All our subchannels. OrphanablePtr subchannel_list_; // Latest pending subchannel list. @@ -167,18 +171,7 @@ void PickFirst::ExitIdleLocked() { if (shutdown_) return; if (idle_) { idle_ = false; - if (subchannel_list_ == nullptr || - subchannel_list_->num_subchannels() == 0) { - grpc_error* error = grpc_error_set_int( - GRPC_ERROR_CREATE_FROM_STATIC_STRING("No addresses to connect to"), - GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE); - channel_control_helper()->UpdateState( - GRPC_CHANNEL_TRANSIENT_FAILURE, - UniquePtr(New(error))); - } else { - subchannel_list_->subchannel(0) - ->CheckConnectivityStateAndStartWatchingLocked(); - } + AttemptToConnectUsingLatestUpdateArgsLocked(); } } @@ -189,36 +182,26 @@ void PickFirst::ResetBackoffLocked() { } } -void PickFirst::UpdateLocked(UpdateArgs args) { - if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_pick_first_trace)) { - gpr_log(GPR_INFO, - "Pick First %p received update with %" PRIuPTR " addresses", this, - args.addresses.size()); - } - grpc_arg new_arg = grpc_channel_arg_integer_create( - const_cast(GRPC_ARG_INHIBIT_HEALTH_CHECKING), 1); - grpc_channel_args* new_args = - grpc_channel_args_copy_and_add(args.args, &new_arg, 1); +void PickFirst::AttemptToConnectUsingLatestUpdateArgsLocked() { + // Create a subchannel list from the latest_update_args_. auto subchannel_list = MakeOrphanable( - this, &grpc_lb_pick_first_trace, args.addresses, combiner(), *new_args); - grpc_channel_args_destroy(new_args); + this, &grpc_lb_pick_first_trace, latest_update_args_.addresses, + combiner(), *latest_update_args_.args); + // Empty update or no valid subchannels. if (subchannel_list->num_subchannels() == 0) { - // Empty update or no valid subchannels. Unsubscribe from all current - // subchannels. + // Unsubscribe from all current subchannels. subchannel_list_ = std::move(subchannel_list); // Empty list. selected_ = nullptr; // If not idle, put the channel in TRANSIENT_FAILURE. // (If we are idle, then this will happen in ExitIdleLocked() if we // haven't gotten a non-empty update by the time the application tries // to start a new call.) - if (!idle_) { - grpc_error* error = grpc_error_set_int( - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty update"), - GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE); - channel_control_helper()->UpdateState( - GRPC_CHANNEL_TRANSIENT_FAILURE, - UniquePtr(New(error))); - } + grpc_error* error = + grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty update"), + GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE); + channel_control_helper()->UpdateState( + GRPC_CHANNEL_TRANSIENT_FAILURE, + UniquePtr(New(error))); return; } // If one of the subchannels in the new list is already in state @@ -226,8 +209,6 @@ void PickFirst::UpdateLocked(UpdateArgs args) { // currently selected subchannel is also present in the update. It // can also happen if one of the subchannels in the update is already // in the global subchannel pool because it's in use by another channel. - // TODO(roth): If we're in IDLE state, we should probably defer this - // check and instead do it in ExitIdleLocked(). for (size_t i = 0; i < subchannel_list->num_subchannels(); ++i) { PickFirstSubchannelData* sd = subchannel_list->subchannel(i); grpc_connectivity_state state = sd->CheckConnectivityStateLocked(); @@ -239,10 +220,6 @@ void PickFirst::UpdateLocked(UpdateArgs args) { // not have contained the currently selected subchannel), drop // it, so that it doesn't override what we've done here. latest_pending_subchannel_list_.reset(); - // Make sure that subsequent calls to ExitIdleLocked() don't cause - // us to start watching a subchannel other than the one we've - // selected. - idle_ = false; return; } } @@ -252,13 +229,11 @@ void PickFirst::UpdateLocked(UpdateArgs args) { subchannel_list_ = std::move(subchannel_list); // If we're not in IDLE state, start trying to connect to the first // subchannel in the new list. - if (!idle_) { - // Note: No need to use CheckConnectivityStateAndStartWatchingLocked() - // here, since we've already checked the initial connectivity - // state of all subchannels above. - subchannel_list_->subchannel(0)->StartConnectivityWatchLocked(); - subchannel_list_->subchannel(0)->subchannel()->AttemptToConnect(); - } + // Note: No need to use CheckConnectivityStateAndStartWatchingLocked() + // here, since we've already checked the initial connectivity + // state of all subchannels above. + subchannel_list_->subchannel(0)->StartConnectivityWatchLocked(); + subchannel_list_->subchannel(0)->subchannel()->AttemptToConnect(); } else { // We do have a selected subchannel (which means it's READY), so keep // using it until one of the subchannels in the new list reports READY. @@ -274,16 +249,35 @@ void PickFirst::UpdateLocked(UpdateArgs args) { latest_pending_subchannel_list_ = std::move(subchannel_list); // If we're not in IDLE state, start trying to connect to the first // subchannel in the new list. - if (!idle_) { - // Note: No need to use CheckConnectivityStateAndStartWatchingLocked() - // here, since we've already checked the initial connectivity - // state of all subchannels above. - latest_pending_subchannel_list_->subchannel(0) - ->StartConnectivityWatchLocked(); - latest_pending_subchannel_list_->subchannel(0) - ->subchannel() - ->AttemptToConnect(); - } + // Note: No need to use CheckConnectivityStateAndStartWatchingLocked() + // here, since we've already checked the initial connectivity + // state of all subchannels above. + latest_pending_subchannel_list_->subchannel(0) + ->StartConnectivityWatchLocked(); + latest_pending_subchannel_list_->subchannel(0) + ->subchannel() + ->AttemptToConnect(); + } +} + +void PickFirst::UpdateLocked(UpdateArgs args) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_pick_first_trace)) { + gpr_log(GPR_INFO, + "Pick First %p received update with %" PRIuPTR " addresses", this, + args.addresses.size()); + } + // Update the latest_update_args_ + grpc_arg new_arg = grpc_channel_arg_integer_create( + const_cast(GRPC_ARG_INHIBIT_HEALTH_CHECKING), 1); + const grpc_channel_args* new_args = + grpc_channel_args_copy_and_add(args.args, &new_arg, 1); + GPR_SWAP(const grpc_channel_args*, new_args, args.args); + grpc_channel_args_destroy(new_args); + latest_update_args_ = std::move(args); + // If we are not in idle, start connection attempt immediately. + // Otherwise, we defer the attempt into ExitIdleLocked(). + if (!idle_) { + AttemptToConnectUsingLatestUpdateArgsLocked(); } } @@ -338,10 +332,12 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( // also set the channel state to IDLE. The reason is that if the new // state is TRANSIENT_FAILURE due to a GOAWAY reception we don't want // to connect to the re-resolved backends until we leave IDLE state. + // TODO(qianchengz): We may want to request re-resolution in + // ExitIdleLocked(). p->idle_ = true; p->channel_control_helper()->RequestReresolution(); p->selected_ = nullptr; - CancelConnectivityWatchLocked("selected subchannel failed; going IDLE"); + p->subchannel_list_.reset(); p->channel_control_helper()->UpdateState( GRPC_CHANNEL_IDLE, UniquePtr(New( p->Ref(DEBUG_LOCATION, "QueuePicker")))); @@ -454,6 +450,11 @@ void PickFirst::PickFirstSubchannelData::ProcessUnselectedReadyLocked() { if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_pick_first_trace)) { gpr_log(GPR_INFO, "Pick First %p selected subchannel %p", p, subchannel()); } + for (size_t i = 0; i < subchannel_list()->num_subchannels(); ++i) { + if (i != Index()) { + subchannel_list()->subchannel(i)->ShutdownLocked(); + } + } } void PickFirst::PickFirstSubchannelData:: From 9aa48c6d1c02884ef27c2976d04596bd197eb5e5 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Sun, 9 Jun 2019 20:42:05 -0700 Subject: [PATCH 0605/1555] Drop support for ruby < 2.3; update and unskip distrib tests --- Rakefile | 4 +- grpc.gemspec | 2 +- templates/grpc.gemspec.template | 2 +- .../distribtest/ruby_centos6_x64/Dockerfile | 10 ++--- .../distribtest/ruby_centos7_x64/Dockerfile | 10 ++--- .../distribtest/ruby_fedora20_x64/Dockerfile | 10 ++--- .../distribtest/ruby_fedora21_x64/Dockerfile | 10 ++--- .../ruby_jessie_x64_ruby_2_2/Dockerfile | 40 ------------------- .../artifacts/distribtest_targets.py | 14 +++---- 9 files changed, 30 insertions(+), 72 deletions(-) delete mode 100644 tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_2/Dockerfile diff --git a/Rakefile b/Rakefile index d604f7935b1..8123dc541dc 100755 --- a/Rakefile +++ b/Rakefile @@ -124,10 +124,10 @@ task 'gem:native' do "invoked on macos with ruby #{RUBY_VERSION}. The ruby macos artifact " \ "build should be running on ruby 2.5." end - system "rake cross native gem RUBY_CC_VERSION=2.6.0:2.5.0:2.4.0:2.3.0:2.2.2 V=#{verbose} GRPC_CONFIG=#{grpc_config}" + system "rake cross native gem RUBY_CC_VERSION=2.6.0:2.5.0:2.4.0:2.3.0 V=#{verbose} GRPC_CONFIG=#{grpc_config}" else Rake::Task['dlls'].execute - docker_for_windows "gem update --system --no-document && bundle && rake cross native gem RUBY_CC_VERSION=2.6.0:2.5.0:2.4.0:2.3.0:2.2.2 V=#{verbose} GRPC_CONFIG=#{grpc_config}" + docker_for_windows "gem update --system --no-document && bundle && rake cross native gem RUBY_CC_VERSION=2.6.0:2.5.0:2.4.0:2.3.0 V=#{verbose} GRPC_CONFIG=#{grpc_config}" end end diff --git a/grpc.gemspec b/grpc.gemspec index fc90a350d64..11469a3ec5c 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |s| s.description = 'Send RPCs from Ruby using GRPC' s.license = 'Apache-2.0' - s.required_ruby_version = '>= 2.0.0' + s.required_ruby_version = '>= 2.3.0' s.files = %w( Makefile .yardopts ) s.files += %w( etc/roots.pem ) diff --git a/templates/grpc.gemspec.template b/templates/grpc.gemspec.template index f8dd0938936..12862c82b29 100644 --- a/templates/grpc.gemspec.template +++ b/templates/grpc.gemspec.template @@ -15,7 +15,7 @@ s.description = 'Send RPCs from Ruby using GRPC' s.license = 'Apache-2.0' - s.required_ruby_version = '>= 2.0.0' + s.required_ruby_version = '>= 2.3.0' s.files = %w( Makefile .yardopts ) s.files += %w( etc/roots.pem ) diff --git a/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile index b53ffc22d4f..f823d0f7706 100644 --- a/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile @@ -22,15 +22,15 @@ RUN yum install -y tar which RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB RUN curl -sSL https://get.rvm.io | bash -s stable -# Install Ruby 2.2 +# Install Ruby 2.3 # Running the installation twice to work around docker issue when using overlay. # https://github.com/docker/docker/issues/10180 -RUN (/bin/bash -l -c "rvm install ruby-2.2.10") || (/bin/bash -l -c "rvm install ruby-2.2.10") -RUN /bin/bash -l -c "rvm use --default ruby-2.2.10" +RUN (/bin/bash -l -c "rvm install ruby-2.3.8") || (/bin/bash -l -c "rvm install ruby-2.3.8") +RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" -RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.2.10' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" +RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" +RUN /bin/bash -l -c "gem install bundler --no-document" RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile index 72235bfba7f..c54f9565639 100644 --- a/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile @@ -20,13 +20,13 @@ RUN yum update && yum install -y curl tar which RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB RUN curl -sSL https://get.rvm.io | bash -s stable -# Install Ruby 2.2 -RUN /bin/bash -l -c "rvm install ruby-2.2.10" -RUN /bin/bash -l -c "rvm use --default ruby-2.2.10" +# Install Ruby 2.3 +RUN /bin/bash -l -c "rvm install ruby-2.3.8" +RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" -RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.2.10' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" +RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" +RUN /bin/bash -l -c "gem install bundler --no-document" RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile index 3d688a889f0..f8e383bf577 100644 --- a/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile @@ -21,15 +21,15 @@ RUN yum clean all && yum update -y && yum distro-sync -y && yum install -y opens RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB RUN curl -sSL https://get.rvm.io | bash -s stable -# Install Ruby 2.2 +# Install Ruby 2.3 # Running the installation twice to work around docker issue when using overlay. # https://github.com/docker/docker/issues/10180 -RUN (/bin/bash -l -c "rvm install ruby-2.2.10") || (/bin/bash -l -c "rvm install ruby-2.2.10") -RUN /bin/bash -l -c "rvm use --default ruby-2.2.10" +RUN (/bin/bash -l -c "rvm install ruby-2.3.8") || (/bin/bash -l -c "rvm install ruby-2.3.8") +RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" -RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.2.10' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" +RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" +RUN /bin/bash -l -c "gem install bundler --no-document" RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile index 8044adf15dc..58500c5b35d 100644 --- a/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile @@ -26,13 +26,13 @@ RUN yum clean all && yum update -y && yum distro-sync -y && yum install -y opens RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB RUN curl -sSL https://get.rvm.io | bash -s stable -# Install Ruby 2.2 -RUN /bin/bash -l -c "rvm install ruby-2.2.10" -RUN /bin/bash -l -c "rvm use --default ruby-2.2.10" +# Install Ruby 2.3 +RUN /bin/bash -l -c "rvm install ruby-2.3.8" +RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" -RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.2.10' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" +RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" +RUN /bin/bash -l -c "gem install bundler --no-document" RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_2/Dockerfile b/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_2/Dockerfile deleted file mode 100644 index 337fc3b5d8e..00000000000 --- a/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_2/Dockerfile +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2015 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FROM debian:jessie - -# Install Git and basic packages. -RUN apt-get update && apt-get install -y \ - curl \ - gcc && apt-get clean - -#================== -# Ruby dependencies - -# Install rvm -RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB -RUN \curl -sSL https://get.rvm.io | bash -s stable - -# Install Ruby 2.2 -RUN /bin/bash -l -c "rvm install ruby-2.2.10" -RUN /bin/bash -l -c "rvm use --default ruby-2.2.10" -RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" -RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" -RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.2.10' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" - -RUN mkdir /var/local/jenkins - -# Define the default command. -CMD ["bash"] diff --git a/tools/run_tests/artifacts/distribtest_targets.py b/tools/run_tests/artifacts/distribtest_targets.py index 1e861029faa..35a561ea928 100644 --- a/tools/run_tests/artifacts/distribtest_targets.py +++ b/tools/run_tests/artifacts/distribtest_targets.py @@ -340,14 +340,12 @@ def targets(): RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_4'), RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_5'), RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_6'), - # TODO(apolcyn): unskip these after upgrading the ruby versions - # of these dockerfiles to >= 2.3. - # RubyDistribTest('linux', 'x64', 'centos6'), - # RubyDistribTest('linux', 'x64', 'centos7'), - # RubyDistribTest('linux', 'x64', 'fedora20'), - # RubyDistribTest('linux', 'x64', 'fedora21'), - # RubyDistribTest('linux', 'x64', 'fedora22'), - # RubyDistribTest('linux', 'x64', 'fedora23'), + RubyDistribTest('linux', 'x64', 'centos6'), + RubyDistribTest('linux', 'x64', 'centos7'), + RubyDistribTest('linux', 'x64', 'fedora20'), + RubyDistribTest('linux', 'x64', 'fedora21'), + RubyDistribTest('linux', 'x64', 'fedora22'), + RubyDistribTest('linux', 'x64', 'fedora23'), RubyDistribTest('linux', 'x64', 'opensuse'), RubyDistribTest('linux', 'x64', 'ubuntu1204'), RubyDistribTest('linux', 'x64', 'ubuntu1404'), From 9e2bb81512af90d24c592e4c905f9f1a0aa0a5f3 Mon Sep 17 00:00:00 2001 From: Michael Thomsen Date: Thu, 20 Jun 2019 12:53:30 +0200 Subject: [PATCH 0606/1555] Roll Dart to 2.3 --- .../interoptest/grpc_interop_dart/Dockerfile.template | 2 +- tools/dockerfile/interoptest/grpc_interop_dart/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/tools/dockerfile/interoptest/grpc_interop_dart/Dockerfile.template b/templates/tools/dockerfile/interoptest/grpc_interop_dart/Dockerfile.template index 34ea645cfa0..dee59335280 100644 --- a/templates/tools/dockerfile/interoptest/grpc_interop_dart/Dockerfile.template +++ b/templates/tools/dockerfile/interoptest/grpc_interop_dart/Dockerfile.template @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. - FROM google/dart:2.0 + FROM google/dart:2.3 # Upgrade Dart to version 2. RUN apt-get update && apt-get upgrade -y dart diff --git a/tools/dockerfile/interoptest/grpc_interop_dart/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_dart/Dockerfile index 897354891c1..43d8a60daea 100644 --- a/tools/dockerfile/interoptest/grpc_interop_dart/Dockerfile +++ b/tools/dockerfile/interoptest/grpc_interop_dart/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM google/dart:2.0 +FROM google/dart:2.3 # Upgrade Dart to version 2. RUN apt-get update && apt-get upgrade -y dart From c5c3983c974e92930dbae384f2c2bcf8655545a8 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 20 Jun 2019 09:08:29 -0700 Subject: [PATCH 0607/1555] Fix hard written port --- src/objective-c/tests/UnitTests/GRPCClientTests.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/objective-c/tests/UnitTests/GRPCClientTests.m b/src/objective-c/tests/UnitTests/GRPCClientTests.m index 94164164c28..bcd87c17b78 100644 --- a/src/objective-c/tests/UnitTests/GRPCClientTests.m +++ b/src/objective-c/tests/UnitTests/GRPCClientTests.m @@ -37,10 +37,14 @@ #define TEST_TIMEOUT 16 -static NSString *const kHostAddress = @"localhost:5050"; +// The server address is derived from preprocessor macro, which is +// in turn derived from environment variable of the same name. +#define NSStringize_helper(x) #x +#define NSStringize(x) @NSStringize_helper(x) +static NSString *const kHostAddress = NSStringize(HOST_PORT_LOCAL); static NSString *const kPackage = @"grpc.testing"; static NSString *const kService = @"TestService"; -static NSString *const kRemoteSSLHost = @"grpc-test.sandbox.googleapis.com"; +static NSString *const kRemoteSSLHost = NSStringize(HOST_PORT_REMOTE); static GRPCProtoMethod *kInexistentMethod; static GRPCProtoMethod *kEmptyCallMethod; From 04d504f67f6f2410482eaedbfff8798465f3febc Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Thu, 20 Jun 2019 09:45:27 -0700 Subject: [PATCH 0608/1555] Fix delete operator undefined reference error for interface --- src/core/lib/iomgr/executor/mpmcqueue.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index 39396eeaad0..aec8dd33c60 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -48,6 +48,8 @@ class MPMCQueueInterface { // Return number of elements in the queue currently virtual int count() const GRPC_ABSTRACT; + + GRPC_ABSTRACT_BASE_CLASS }; class MPMCQueue : public MPMCQueueInterface { From 49f0fb9035120d0f5b5fa49846324c0b2d59c257 Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Thu, 20 Jun 2019 18:55:56 +0200 Subject: [PATCH 0609/1555] Migrate from dep.proto to dep[ProtoInfo] --- WORKSPACE | 2 +- bazel/generate_cc.bzl | 4 ++-- bazel/python_rules.bzl | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 2db3c5db2ff..60582d1a0f5 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -20,7 +20,7 @@ register_toolchains( git_repository( name = "io_bazel_rules_python", - commit = "8b5d0683a7d878b28fffe464779c8a53659fc645", + commit = "fdbb17a4118a1728d19e638a5291b4c4266ea5b8", remote = "https://github.com/bazelbuild/rules_python.git", ) diff --git a/bazel/generate_cc.bzl b/bazel/generate_cc.bzl index b7edcda702f..581165a190a 100644 --- a/bazel/generate_cc.bzl +++ b/bazel/generate_cc.bzl @@ -41,11 +41,11 @@ def _join_directories(directories): def generate_cc_impl(ctx): """Implementation of the generate_cc rule.""" - protos = [f for src in ctx.attr.srcs for f in src.proto.check_deps_sources.to_list()] + protos = [f for src in ctx.attr.srcs for f in src[ProtoInfo].check_deps_sources.to_list()] includes = [ f for src in ctx.attr.srcs - for f in src.proto.transitive_imports.to_list() + for f in src[ProtoInfo].transitive_imports.to_list() ] outs = [] proto_root = get_proto_root( diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index 17004f3474d..3df30f82628 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -28,12 +28,12 @@ def _get_staged_proto_file(context, source_file): def _generate_py_impl(context): protos = [] for src in context.attr.deps: - for file in src.proto.direct_sources: + for file in src[ProtoInfo].direct_sources: protos.append(_get_staged_proto_file(context, file)) includes = [ file for src in context.attr.deps - for file in src.proto.transitive_imports.to_list() + for file in src[ProtoInfo].transitive_imports.to_list() ] proto_root = get_proto_root(context.label.workspace_root) format_str = (_GENERATED_GRPC_PROTO_FORMAT if context.executable.plugin else _GENERATED_PROTO_FORMAT) From ecf04ccf4d8be9378166ec9e0ccf44081e211d11 Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Thu, 20 Jun 2019 18:57:33 +0200 Subject: [PATCH 0610/1555] Require ProtoInfo in attributes, not "proto" --- bazel/generate_cc.bzl | 2 +- bazel/python_rules.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bazel/generate_cc.bzl b/bazel/generate_cc.bzl index 581165a190a..87e8b9d3292 100644 --- a/bazel/generate_cc.bzl +++ b/bazel/generate_cc.bzl @@ -146,7 +146,7 @@ _generate_cc = rule( "srcs": attr.label_list( mandatory = True, allow_empty = False, - providers = ["proto"], + providers = [ProtoInfo], ), "plugin": attr.label( executable = True, diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index 3df30f82628..d4ff77094cc 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -99,7 +99,7 @@ __generate_py = rule( "deps": attr.label_list( mandatory = True, allow_empty = False, - providers = ["proto"], + providers = [ProtoInfo], ), "plugin": attr.label( executable = True, From 7eb8bac69612b1e5a73248eba64532ff38e8e758 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 20 Jun 2019 10:03:01 -0700 Subject: [PATCH 0611/1555] Resolve xcodebuild issue on Mac --- src/objective-c/tests/run_one_test.sh | 10 +++++++++- tools/run_tests/run_tests.py | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/objective-c/tests/run_one_test.sh b/src/objective-c/tests/run_one_test.sh index 342d5a5b38d..624ad4743eb 100755 --- a/src/objective-c/tests/run_one_test.sh +++ b/src/objective-c/tests/run_one_test.sh @@ -45,10 +45,18 @@ set -o pipefail XCODEBUILD_FILTER='(^CompileC |^Ld |^ *[^ ]*clang |^ *cd |^ *export |^Libtool |^ *[^ ]*libtool |^CpHeader |^ *builtin-copy )' +if [ $PLATFORM == ios ]; then +DESTINATION="name='iPhone 8'" +elif [ $PLATFORM == macos ]; then +DESTINATION='platform=macOS' +else +DESTINATION="name='iPhone 8'" +fi + xcodebuild \ -workspace Tests.xcworkspace \ -scheme $SCHEME \ - -destination name="iPhone 8" \ + -destination "$DESTINATION" \ HOST_PORT_LOCALSSL=localhost:$TLS_PORT \ HOST_PORT_LOCAL=localhost:$PLAIN_PORT \ HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 0addc093d73..f11927bd5d6 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1137,7 +1137,8 @@ class ObjCLanguage(object): shortname='mac-test-basictests', cpu_cost=1e6, environ={ - 'SCHEME': 'MacTests' + 'SCHEME': 'MacTests', + 'PLATFORM': 'macos' })) return sorted(out) From cc18abfa54e00a39fcc29763da508e12c5095ed5 Mon Sep 17 00:00:00 2001 From: Alex Polcyn Date: Thu, 20 Jun 2019 17:08:15 +0000 Subject: [PATCH 0612/1555] Pin bundler where needed --- tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile | 2 +- tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile | 2 +- tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile | 2 +- tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile index f823d0f7706..0812b860d7f 100644 --- a/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile @@ -30,7 +30,7 @@ RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler --no-document" +RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile index c54f9565639..fc4eabbbb15 100644 --- a/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile @@ -26,7 +26,7 @@ RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler --no-document" +RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile index f8e383bf577..73a4bd76c88 100644 --- a/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile @@ -29,7 +29,7 @@ RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler --no-document" +RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile index 58500c5b35d..43c0ae5d8d6 100644 --- a/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile @@ -32,7 +32,7 @@ RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler --no-document" +RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" RUN mkdir /var/local/jenkins From 07728ed01c170c1d4843357c1eca32e5d44323e4 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 20 Jun 2019 12:46:00 -0700 Subject: [PATCH 0613/1555] Fix ios simulator failure --- src/objective-c/tests/run_one_test.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/objective-c/tests/run_one_test.sh b/src/objective-c/tests/run_one_test.sh index 624ad4743eb..b74107e4a66 100755 --- a/src/objective-c/tests/run_one_test.sh +++ b/src/objective-c/tests/run_one_test.sh @@ -45,12 +45,12 @@ set -o pipefail XCODEBUILD_FILTER='(^CompileC |^Ld |^ *[^ ]*clang |^ *cd |^ *export |^Libtool |^ *[^ ]*libtool |^CpHeader |^ *builtin-copy )' -if [ $PLATFORM == ios ]; then -DESTINATION="name='iPhone 8'" +if [ -z $PLATFORM ]; then +DESTINATION='name=iPhone 8' +elif [ $PLATFORM == ios ]; then +DESTINATION='name=iPhone 8' elif [ $PLATFORM == macos ]; then DESTINATION='platform=macOS' -else -DESTINATION="name='iPhone 8'" fi xcodebuild \ From 9c5ed4550a3d1ed905cc61c2bab5cd9719d22647 Mon Sep 17 00:00:00 2001 From: Alex Polcyn Date: Thu, 20 Jun 2019 19:56:09 +0000 Subject: [PATCH 0614/1555] Also updated fedora 2.2 and 2.3 dockerfiles --- .../distribtest/ruby_fedora22_x64/Dockerfile | 24 +++++++++++++++++-- .../distribtest/ruby_fedora23_x64/Dockerfile | 24 +++++++++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/tools/dockerfile/distribtest/ruby_fedora22_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_fedora22_x64/Dockerfile index 848c5be789a..e077f68a38d 100644 --- a/tools/dockerfile/distribtest/ruby_fedora22_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_fedora22_x64/Dockerfile @@ -14,6 +14,26 @@ FROM fedora:22 -RUN yum clean all && yum update -y && yum install -y ruby findutils +# Make yum work properly under docker when using overlay storage driver. +# https://bugzilla.redhat.com/show_bug.cgi?id=1213602#c9 +# https://github.com/docker/docker/issues/10180 +RUN yum install -y yum-plugin-ovl -RUN gem install bundler +# distro-sync and install openssl, per https://github.com/fedora-cloud/docker-brew-fedora/issues/19 +RUN yum clean all && yum update -y && yum distro-sync -y && yum install -y openssl gnupg which findutils tar procps + +# Install rvm +RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB +RUN curl -sSL https://get.rvm.io | bash -s stable + +# Install Ruby 2.3 +RUN /bin/bash -l -c "rvm install ruby-2.3.8" +RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" +RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" +RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" +RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" +RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" + +RUN mkdir /var/local/jenkins + +RUN /bin/bash -l -c "echo '. /etc/profile.d/rvm.sh' >> ~/.bashrc" diff --git a/tools/dockerfile/distribtest/ruby_fedora23_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_fedora23_x64/Dockerfile index 47dd577e217..f586ae377a3 100644 --- a/tools/dockerfile/distribtest/ruby_fedora23_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_fedora23_x64/Dockerfile @@ -14,6 +14,26 @@ FROM fedora:23 -RUN yum clean all && yum update -y && yum install -y ruby findutils +# Make yum work properly under docker when using overlay storage driver. +# https://bugzilla.redhat.com/show_bug.cgi?id=1213602#c9 +# https://github.com/docker/docker/issues/10180 +RUN yum install -y yum-plugin-ovl -RUN gem install bundler +# distro-sync and install openssl, per https://github.com/fedora-cloud/docker-brew-fedora/issues/19 +RUN yum clean all && yum update -y && yum distro-sync -y && yum install -y openssl gnupg which findutils tar procps + +# Install rvm +RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB +RUN curl -sSL https://get.rvm.io | bash -s stable + +# Install Ruby 2.3 +RUN /bin/bash -l -c "rvm install ruby-2.3.8" +RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" +RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" +RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" +RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" +RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" + +RUN mkdir /var/local/jenkins + +RUN /bin/bash -l -c "echo '. /etc/profile.d/rvm.sh' >> ~/.bashrc" From cb8730c71dbf791331f46d5674be802b436b4e61 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Thu, 20 Jun 2019 14:00:05 -0700 Subject: [PATCH 0615/1555] Modify as static var --- src/core/lib/gprpp/thd_posix.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/gprpp/thd_posix.cc b/src/core/lib/gprpp/thd_posix.cc index e26ee507a3d..a26630a3dc3 100644 --- a/src/core/lib/gprpp/thd_posix.cc +++ b/src/core/lib/gprpp/thd_posix.cc @@ -50,7 +50,7 @@ struct thd_arg { }; size_t RoundUpToPageSize(size_t size) { - size_t page_size = static_cast(sysconf(_SC_PAGESIZE)); + static size_t page_size = static_cast(sysconf(_SC_PAGESIZE)); return (size + page_size - 1) & ~(page_size - 1); } From 30c700fd02a43c7540130370812e14ff0afab294 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Sun, 9 Jun 2019 20:42:05 -0700 Subject: [PATCH 0616/1555] Drop support for ruby < 2.3; update and unskip distrib tests --- Rakefile | 4 +- grpc.gemspec | 2 +- templates/grpc.gemspec.template | 2 +- .../distribtest/ruby_centos6_x64/Dockerfile | 10 ++--- .../distribtest/ruby_centos7_x64/Dockerfile | 10 ++--- .../distribtest/ruby_fedora20_x64/Dockerfile | 10 ++--- .../distribtest/ruby_fedora21_x64/Dockerfile | 10 ++--- .../ruby_jessie_x64_ruby_2_2/Dockerfile | 40 ------------------- .../artifacts/distribtest_targets.py | 14 +++---- 9 files changed, 30 insertions(+), 72 deletions(-) delete mode 100644 tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_2/Dockerfile diff --git a/Rakefile b/Rakefile index d604f7935b1..8123dc541dc 100755 --- a/Rakefile +++ b/Rakefile @@ -124,10 +124,10 @@ task 'gem:native' do "invoked on macos with ruby #{RUBY_VERSION}. The ruby macos artifact " \ "build should be running on ruby 2.5." end - system "rake cross native gem RUBY_CC_VERSION=2.6.0:2.5.0:2.4.0:2.3.0:2.2.2 V=#{verbose} GRPC_CONFIG=#{grpc_config}" + system "rake cross native gem RUBY_CC_VERSION=2.6.0:2.5.0:2.4.0:2.3.0 V=#{verbose} GRPC_CONFIG=#{grpc_config}" else Rake::Task['dlls'].execute - docker_for_windows "gem update --system --no-document && bundle && rake cross native gem RUBY_CC_VERSION=2.6.0:2.5.0:2.4.0:2.3.0:2.2.2 V=#{verbose} GRPC_CONFIG=#{grpc_config}" + docker_for_windows "gem update --system --no-document && bundle && rake cross native gem RUBY_CC_VERSION=2.6.0:2.5.0:2.4.0:2.3.0 V=#{verbose} GRPC_CONFIG=#{grpc_config}" end end diff --git a/grpc.gemspec b/grpc.gemspec index fc90a350d64..11469a3ec5c 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |s| s.description = 'Send RPCs from Ruby using GRPC' s.license = 'Apache-2.0' - s.required_ruby_version = '>= 2.0.0' + s.required_ruby_version = '>= 2.3.0' s.files = %w( Makefile .yardopts ) s.files += %w( etc/roots.pem ) diff --git a/templates/grpc.gemspec.template b/templates/grpc.gemspec.template index f8dd0938936..12862c82b29 100644 --- a/templates/grpc.gemspec.template +++ b/templates/grpc.gemspec.template @@ -15,7 +15,7 @@ s.description = 'Send RPCs from Ruby using GRPC' s.license = 'Apache-2.0' - s.required_ruby_version = '>= 2.0.0' + s.required_ruby_version = '>= 2.3.0' s.files = %w( Makefile .yardopts ) s.files += %w( etc/roots.pem ) diff --git a/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile index b53ffc22d4f..f823d0f7706 100644 --- a/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile @@ -22,15 +22,15 @@ RUN yum install -y tar which RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB RUN curl -sSL https://get.rvm.io | bash -s stable -# Install Ruby 2.2 +# Install Ruby 2.3 # Running the installation twice to work around docker issue when using overlay. # https://github.com/docker/docker/issues/10180 -RUN (/bin/bash -l -c "rvm install ruby-2.2.10") || (/bin/bash -l -c "rvm install ruby-2.2.10") -RUN /bin/bash -l -c "rvm use --default ruby-2.2.10" +RUN (/bin/bash -l -c "rvm install ruby-2.3.8") || (/bin/bash -l -c "rvm install ruby-2.3.8") +RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" -RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.2.10' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" +RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" +RUN /bin/bash -l -c "gem install bundler --no-document" RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile index 72235bfba7f..c54f9565639 100644 --- a/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile @@ -20,13 +20,13 @@ RUN yum update && yum install -y curl tar which RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB RUN curl -sSL https://get.rvm.io | bash -s stable -# Install Ruby 2.2 -RUN /bin/bash -l -c "rvm install ruby-2.2.10" -RUN /bin/bash -l -c "rvm use --default ruby-2.2.10" +# Install Ruby 2.3 +RUN /bin/bash -l -c "rvm install ruby-2.3.8" +RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" -RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.2.10' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" +RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" +RUN /bin/bash -l -c "gem install bundler --no-document" RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile index 3d688a889f0..f8e383bf577 100644 --- a/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile @@ -21,15 +21,15 @@ RUN yum clean all && yum update -y && yum distro-sync -y && yum install -y opens RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB RUN curl -sSL https://get.rvm.io | bash -s stable -# Install Ruby 2.2 +# Install Ruby 2.3 # Running the installation twice to work around docker issue when using overlay. # https://github.com/docker/docker/issues/10180 -RUN (/bin/bash -l -c "rvm install ruby-2.2.10") || (/bin/bash -l -c "rvm install ruby-2.2.10") -RUN /bin/bash -l -c "rvm use --default ruby-2.2.10" +RUN (/bin/bash -l -c "rvm install ruby-2.3.8") || (/bin/bash -l -c "rvm install ruby-2.3.8") +RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" -RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.2.10' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" +RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" +RUN /bin/bash -l -c "gem install bundler --no-document" RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile index 8044adf15dc..58500c5b35d 100644 --- a/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile @@ -26,13 +26,13 @@ RUN yum clean all && yum update -y && yum distro-sync -y && yum install -y opens RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB RUN curl -sSL https://get.rvm.io | bash -s stable -# Install Ruby 2.2 -RUN /bin/bash -l -c "rvm install ruby-2.2.10" -RUN /bin/bash -l -c "rvm use --default ruby-2.2.10" +# Install Ruby 2.3 +RUN /bin/bash -l -c "rvm install ruby-2.3.8" +RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" -RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.2.10' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" +RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" +RUN /bin/bash -l -c "gem install bundler --no-document" RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_2/Dockerfile b/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_2/Dockerfile deleted file mode 100644 index 337fc3b5d8e..00000000000 --- a/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_2/Dockerfile +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2015 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FROM debian:jessie - -# Install Git and basic packages. -RUN apt-get update && apt-get install -y \ - curl \ - gcc && apt-get clean - -#================== -# Ruby dependencies - -# Install rvm -RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB -RUN \curl -sSL https://get.rvm.io | bash -s stable - -# Install Ruby 2.2 -RUN /bin/bash -l -c "rvm install ruby-2.2.10" -RUN /bin/bash -l -c "rvm use --default ruby-2.2.10" -RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" -RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" -RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.2.10' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" - -RUN mkdir /var/local/jenkins - -# Define the default command. -CMD ["bash"] diff --git a/tools/run_tests/artifacts/distribtest_targets.py b/tools/run_tests/artifacts/distribtest_targets.py index 1e861029faa..35a561ea928 100644 --- a/tools/run_tests/artifacts/distribtest_targets.py +++ b/tools/run_tests/artifacts/distribtest_targets.py @@ -340,14 +340,12 @@ def targets(): RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_4'), RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_5'), RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_6'), - # TODO(apolcyn): unskip these after upgrading the ruby versions - # of these dockerfiles to >= 2.3. - # RubyDistribTest('linux', 'x64', 'centos6'), - # RubyDistribTest('linux', 'x64', 'centos7'), - # RubyDistribTest('linux', 'x64', 'fedora20'), - # RubyDistribTest('linux', 'x64', 'fedora21'), - # RubyDistribTest('linux', 'x64', 'fedora22'), - # RubyDistribTest('linux', 'x64', 'fedora23'), + RubyDistribTest('linux', 'x64', 'centos6'), + RubyDistribTest('linux', 'x64', 'centos7'), + RubyDistribTest('linux', 'x64', 'fedora20'), + RubyDistribTest('linux', 'x64', 'fedora21'), + RubyDistribTest('linux', 'x64', 'fedora22'), + RubyDistribTest('linux', 'x64', 'fedora23'), RubyDistribTest('linux', 'x64', 'opensuse'), RubyDistribTest('linux', 'x64', 'ubuntu1204'), RubyDistribTest('linux', 'x64', 'ubuntu1404'), From 7361c440c548e65238251cb0f5535d3e65104be1 Mon Sep 17 00:00:00 2001 From: Alex Polcyn Date: Thu, 20 Jun 2019 17:08:15 +0000 Subject: [PATCH 0617/1555] Pin bundler where needed --- tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile | 2 +- tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile | 2 +- tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile | 2 +- tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile index f823d0f7706..0812b860d7f 100644 --- a/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile @@ -30,7 +30,7 @@ RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler --no-document" +RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile index c54f9565639..fc4eabbbb15 100644 --- a/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile @@ -26,7 +26,7 @@ RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler --no-document" +RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile index f8e383bf577..73a4bd76c88 100644 --- a/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile @@ -29,7 +29,7 @@ RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler --no-document" +RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile index 58500c5b35d..43c0ae5d8d6 100644 --- a/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile @@ -32,7 +32,7 @@ RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler --no-document" +RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" RUN mkdir /var/local/jenkins From 1a0eb8bea6ec7939582c87c4ba0d7bae24ab4a52 Mon Sep 17 00:00:00 2001 From: Alex Polcyn Date: Thu, 20 Jun 2019 19:56:09 +0000 Subject: [PATCH 0618/1555] Also updated fedora 2.2 and 2.3 dockerfiles --- .../distribtest/ruby_fedora22_x64/Dockerfile | 24 +++++++++++++++++-- .../distribtest/ruby_fedora23_x64/Dockerfile | 24 +++++++++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/tools/dockerfile/distribtest/ruby_fedora22_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_fedora22_x64/Dockerfile index 848c5be789a..e077f68a38d 100644 --- a/tools/dockerfile/distribtest/ruby_fedora22_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_fedora22_x64/Dockerfile @@ -14,6 +14,26 @@ FROM fedora:22 -RUN yum clean all && yum update -y && yum install -y ruby findutils +# Make yum work properly under docker when using overlay storage driver. +# https://bugzilla.redhat.com/show_bug.cgi?id=1213602#c9 +# https://github.com/docker/docker/issues/10180 +RUN yum install -y yum-plugin-ovl -RUN gem install bundler +# distro-sync and install openssl, per https://github.com/fedora-cloud/docker-brew-fedora/issues/19 +RUN yum clean all && yum update -y && yum distro-sync -y && yum install -y openssl gnupg which findutils tar procps + +# Install rvm +RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB +RUN curl -sSL https://get.rvm.io | bash -s stable + +# Install Ruby 2.3 +RUN /bin/bash -l -c "rvm install ruby-2.3.8" +RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" +RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" +RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" +RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" +RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" + +RUN mkdir /var/local/jenkins + +RUN /bin/bash -l -c "echo '. /etc/profile.d/rvm.sh' >> ~/.bashrc" diff --git a/tools/dockerfile/distribtest/ruby_fedora23_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_fedora23_x64/Dockerfile index 47dd577e217..f586ae377a3 100644 --- a/tools/dockerfile/distribtest/ruby_fedora23_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_fedora23_x64/Dockerfile @@ -14,6 +14,26 @@ FROM fedora:23 -RUN yum clean all && yum update -y && yum install -y ruby findutils +# Make yum work properly under docker when using overlay storage driver. +# https://bugzilla.redhat.com/show_bug.cgi?id=1213602#c9 +# https://github.com/docker/docker/issues/10180 +RUN yum install -y yum-plugin-ovl -RUN gem install bundler +# distro-sync and install openssl, per https://github.com/fedora-cloud/docker-brew-fedora/issues/19 +RUN yum clean all && yum update -y && yum distro-sync -y && yum install -y openssl gnupg which findutils tar procps + +# Install rvm +RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB +RUN curl -sSL https://get.rvm.io | bash -s stable + +# Install Ruby 2.3 +RUN /bin/bash -l -c "rvm install ruby-2.3.8" +RUN /bin/bash -l -c "rvm use --default ruby-2.3.8" +RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" +RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" +RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc" +RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" + +RUN mkdir /var/local/jenkins + +RUN /bin/bash -l -c "echo '. /etc/profile.d/rvm.sh' >> ~/.bashrc" From 72fe202369e2910cee3fbe4995949c48378863e0 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 19 Jun 2019 09:48:45 -0700 Subject: [PATCH 0619/1555] Update Protobuf version --- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/!ProtoCompiler.podspec | 2 +- .../src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index e9b5645d012..939078def22 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -101,7 +101,7 @@ Pod::Spec.new do |s| s.preserve_paths = plugin # Restrict the protoc version to the one supported by this plugin. - s.dependency '!ProtoCompiler', '3.7.0' + s.dependency '!ProtoCompiler', '3.8.0' # For the Protobuf dependency not to complain: s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' diff --git a/src/objective-c/!ProtoCompiler.podspec b/src/objective-c/!ProtoCompiler.podspec index 58d74be4d4e..d8ce4d8e89d 100644 --- a/src/objective-c/!ProtoCompiler.podspec +++ b/src/objective-c/!ProtoCompiler.podspec @@ -36,7 +36,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler' - v = '3.7.0' + v = '3.8.0' s.version = v s.summary = 'The Protobuf Compiler (protoc) generates Objective-C files from .proto files' s.description = <<-DESC diff --git a/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template b/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template index 741f9b7e54d..b2335ac8a9e 100644 --- a/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template +++ b/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template @@ -103,7 +103,7 @@ s.preserve_paths = plugin # Restrict the protoc version to the one supported by this plugin. - s.dependency '!ProtoCompiler', '3.7.0' + s.dependency '!ProtoCompiler', '3.8.0' # For the Protobuf dependency not to complain: s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' From 233eee421fe2b1bea41e1e844ec1d1424d3c7c5b Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Thu, 20 Jun 2019 14:49:04 -0700 Subject: [PATCH 0620/1555] Modify static var to global var in file --- src/core/lib/gprpp/thd_posix.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/lib/gprpp/thd_posix.cc b/src/core/lib/gprpp/thd_posix.cc index a26630a3dc3..fb732b4d9f0 100644 --- a/src/core/lib/gprpp/thd_posix.cc +++ b/src/core/lib/gprpp/thd_posix.cc @@ -49,8 +49,9 @@ struct thd_arg { bool tracked; }; +size_t page_size = static_cast(sysconf(_SC_PAGESIZE)); + size_t RoundUpToPageSize(size_t size) { - static size_t page_size = static_cast(sysconf(_SC_PAGESIZE)); return (size + page_size - 1) & ~(page_size - 1); } From 1c8894d9c440340e6c1ed4169e70c677f782e44c Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Fri, 21 Jun 2019 00:33:06 +0200 Subject: [PATCH 0621/1555] Hail mary. --- tools/bazel.rc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/bazel.rc b/tools/bazel.rc index 6378b82017e..4bd3a5d7445 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -51,6 +51,10 @@ build:ubsan --copt=-DUNDEFINED_BEHAVIOR_SANITIZER # used by absl build:ubsan --copt=-fno-sanitize=function,vptr build:ubsan --linkopt=-fsanitize=undefined build:ubsan --action_env=UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1:suppressions=test/core/util/ubsan_suppressions.txt +# For some reasons, these two stopped being propagated, so, redeclaring them here. +# That's a hack that needs to be removed once we understand what's going on. +build:ubsan --copt=-DPB_FIELD_32BIT=1 +build:ubsan --copt=-DGRPC_PORT_ISOLATED_RUNTIME=1 build:basicprof --strip=never build:basicprof --copt=-DNDEBUG From 7c4c6e2e9a9882083ae1814b6b3040fa65c24113 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Thu, 20 Jun 2019 17:07:34 -0700 Subject: [PATCH 0622/1555] Modify page_size as const var --- src/core/lib/gprpp/thd_posix.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/gprpp/thd_posix.cc b/src/core/lib/gprpp/thd_posix.cc index fb732b4d9f0..dbb9c82cb06 100644 --- a/src/core/lib/gprpp/thd_posix.cc +++ b/src/core/lib/gprpp/thd_posix.cc @@ -49,7 +49,7 @@ struct thd_arg { bool tracked; }; -size_t page_size = static_cast(sysconf(_SC_PAGESIZE)); +const size_t page_size = static_cast(sysconf(_SC_PAGESIZE)); size_t RoundUpToPageSize(size_t size) { return (size + page_size - 1) & ~(page_size - 1); From fbfb93c88fead0bd62cc20d800bdcf45cf514caa Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Tue, 18 Jun 2019 17:50:28 -0700 Subject: [PATCH 0623/1555] Fix C++ tests to run on iOS - Define grpc_iomgr_run_in_background in iomgr_posix_cfstream.cc - Use *_IF_SUPPORTED() for death tests - Move global test init, teardown to SetUpTestCase, TearDownTestCase as GTMGoogleTestRun doesn't run main() --- src/core/lib/iomgr/iomgr_posix_cfstream.cc | 2 + test/cpp/codegen/proto_utils_test.cc | 49 +++++++++++++------ test/cpp/common/channel_arguments_test.cc | 6 ++- test/cpp/end2end/client_lb_end2end_test.cc | 9 ++-- test/cpp/end2end/filter_end2end_test.cc | 12 ++--- test/cpp/end2end/grpclb_end2end_test.cc | 16 +++--- .../end2end/service_config_end2end_test.cc | 9 ++-- test/cpp/end2end/xds_end2end_test.cc | 16 +++--- test/cpp/grpclb/grpclb_api_test.cc | 9 ++-- test/cpp/naming/cancel_ares_query_test.cc | 49 ++++++++++++------- test/cpp/server/server_builder_test.cc | 18 ++++--- ...server_builder_with_socket_mutator_test.cc | 11 +++-- test/cpp/util/byte_buffer_test.cc | 9 ++-- test/cpp/util/slice_test.cc | 6 ++- 14 files changed, 145 insertions(+), 76 deletions(-) diff --git a/src/core/lib/iomgr/iomgr_posix_cfstream.cc b/src/core/lib/iomgr/iomgr_posix_cfstream.cc index cf4d05318ea..c086ba52396 100644 --- a/src/core/lib/iomgr/iomgr_posix_cfstream.cc +++ b/src/core/lib/iomgr/iomgr_posix_cfstream.cc @@ -90,4 +90,6 @@ void grpc_set_default_iomgr_platform() { grpc_set_iomgr_platform_vtable(&vtable); } +bool grpc_iomgr_run_in_background() { return false; } + #endif /* GRPC_CFSTREAM_IOMGR */ diff --git a/test/cpp/codegen/proto_utils_test.cc b/test/cpp/codegen/proto_utils_test.cc index 801660eef67..e9dcea0fd9c 100644 --- a/test/cpp/codegen/proto_utils_test.cc +++ b/test/cpp/codegen/proto_utils_test.cc @@ -49,7 +49,18 @@ class GrpcByteBufferPeer { ByteBuffer* bb_; }; -class ProtoUtilsTest : public ::testing::Test {}; +class ProtoUtilsTest : public ::testing::Test { + protected: + static void SetUpTestCase() { + // Ensure the ProtoBufferWriter internals are initialized. + grpc::internal::GrpcLibraryInitializer init; + init.summon(); + grpc::GrpcLibraryCodegen lib; + grpc_init(); + } + + static void TearDownTestCase() { grpc_shutdown(); } +}; // Regression test for a memory corruption bug where a series of // ProtoBufferWriter Next()/Backup() invocations could result in a dangling @@ -136,36 +147,46 @@ void BufferWriterTest(int block_size, int total_size, int backup_size) { grpc_byte_buffer_reader_destroy(&reader); } -TEST(WriterTest, TinyBlockTinyBackup) { +class WriterTest : public ::testing::Test { + protected: + static void SetUpTestCase() { + grpc::internal::GrpcLibraryInitializer init; + init.summon(); + grpc::GrpcLibraryCodegen lib; + // Ensure the ProtoBufferWriter internals are initialized. + grpc_init(); + } + + static void TearDownTestCase() { grpc_shutdown(); } +}; + +TEST_F(WriterTest, TinyBlockTinyBackup) { for (int i = 2; i < static_cast GRPC_SLICE_INLINED_SIZE; i++) { BufferWriterTest(i, 256, 1); } } -TEST(WriterTest, SmallBlockTinyBackup) { BufferWriterTest(64, 256, 1); } +TEST_F(WriterTest, SmallBlockTinyBackup) { BufferWriterTest(64, 256, 1); } -TEST(WriterTest, SmallBlockNoBackup) { BufferWriterTest(64, 256, 0); } +TEST_F(WriterTest, SmallBlockNoBackup) { BufferWriterTest(64, 256, 0); } -TEST(WriterTest, SmallBlockFullBackup) { BufferWriterTest(64, 256, 64); } +TEST_F(WriterTest, SmallBlockFullBackup) { BufferWriterTest(64, 256, 64); } -TEST(WriterTest, LargeBlockTinyBackup) { BufferWriterTest(4096, 8192, 1); } +TEST_F(WriterTest, LargeBlockTinyBackup) { BufferWriterTest(4096, 8192, 1); } -TEST(WriterTest, LargeBlockNoBackup) { BufferWriterTest(4096, 8192, 0); } +TEST_F(WriterTest, LargeBlockNoBackup) { BufferWriterTest(4096, 8192, 0); } -TEST(WriterTest, LargeBlockFullBackup) { BufferWriterTest(4096, 8192, 4096); } +TEST_F(WriterTest, LargeBlockFullBackup) { BufferWriterTest(4096, 8192, 4096); } -TEST(WriterTest, LargeBlockLargeBackup) { BufferWriterTest(4096, 8192, 4095); } +TEST_F(WriterTest, LargeBlockLargeBackup) { + BufferWriterTest(4096, 8192, 4095); +} } // namespace } // namespace internal } // namespace grpc int main(int argc, char** argv) { - // Ensure the ProtoBufferWriter internals are initialized. - grpc::internal::GrpcLibraryInitializer init; - init.summon(); - grpc::GrpcLibraryCodegen lib; - ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/test/cpp/common/channel_arguments_test.cc b/test/cpp/common/channel_arguments_test.cc index 12fd9784f47..7fbed5ba3ea 100644 --- a/test/cpp/common/channel_arguments_test.cc +++ b/test/cpp/common/channel_arguments_test.cc @@ -84,6 +84,10 @@ class ChannelArgumentsTest : public ::testing::Test { channel_args.SetChannelArgs(args); } + static void SetUpTestCase() { grpc_init(); } + + static void TearDownTestCase() { grpc_shutdown(); } + grpc::string GetDefaultUserAgentPrefix() { std::ostringstream user_agent_prefix; user_agent_prefix << "grpc-c++/" << Version(); @@ -252,8 +256,6 @@ TEST_F(ChannelArgumentsTest, SetUserAgentPrefix) { int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); - grpc_init(); int ret = RUN_ALL_TESTS(); - grpc_shutdown(); return ret; } diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index f6d4a48b6f0..d499f136ef6 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -141,6 +141,12 @@ class ClientLbEnd2endTest : public ::testing::Test { creds_(new SecureChannelCredentials( grpc_fake_transport_security_credentials_create())) {} + static void SetUpTestCase() { + // Make the backup poller poll very frequently in order to pick up + // updates from all the subchannels's FDs. + GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + } + void SetUp() override { grpc_init(); response_generator_ = @@ -1481,9 +1487,6 @@ TEST_F(ClientLbInterceptTrailingMetadataTest, InterceptsRetriesEnabled) { } // namespace grpc int main(int argc, char** argv) { - // Make the backup poller poll very frequently in order to pick up - // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); ::testing::InitGoogleTest(&argc, argv); grpc::testing::TestEnvironment env(argc, argv); const auto result = RUN_ALL_TESTS(); diff --git a/test/cpp/end2end/filter_end2end_test.cc b/test/cpp/end2end/filter_end2end_test.cc index a4c981a3eb1..e96825c33eb 100644 --- a/test/cpp/end2end/filter_end2end_test.cc +++ b/test/cpp/end2end/filter_end2end_test.cc @@ -121,6 +121,12 @@ class FilterEnd2endTest : public ::testing::Test { protected: FilterEnd2endTest() : server_host_("localhost") {} + static void SetUpTestCase() { + gpr_log(GPR_ERROR, "In SetUpTestCase"); + grpc::RegisterChannelFilter( + "test-filter", GRPC_SERVER_CHANNEL, INT_MAX, nullptr); + } + void SetUp() override { int port = grpc_pick_unused_port_or_die(); server_address_ << server_host_ << ":" << port; @@ -321,11 +327,6 @@ TEST_F(FilterEnd2endTest, SimpleBidiStreaming) { EXPECT_EQ(1, GetConnectionCounterValue()); } -void RegisterFilter() { - grpc::RegisterChannelFilter( - "test-filter", GRPC_SERVER_CHANNEL, INT_MAX, nullptr); -} - } // namespace } // namespace testing } // namespace grpc @@ -333,6 +334,5 @@ void RegisterFilter() { int main(int argc, char** argv) { grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); - grpc::testing::RegisterFilter(); return RUN_ALL_TESTS(); } diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc index 70c443412aa..e3b79c810cd 100644 --- a/test/cpp/end2end/grpclb_end2end_test.cc +++ b/test/cpp/end2end/grpclb_end2end_test.cc @@ -374,6 +374,15 @@ class GrpclbEnd2endTest : public ::testing::Test { client_load_reporting_interval_seconds_( client_load_reporting_interval_seconds) {} + static void SetUpTestCase() { + // Make the backup poller poll very frequently in order to pick up + // updates from all the subchannels's FDs. + GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_init(); + } + + static void TearDownTestCase() { grpc_shutdown(); } + void SetUp() override { response_generator_ = grpc_core::MakeRefCounted(); @@ -1003,7 +1012,7 @@ TEST_F(SingleBalancerTest, SecureNamingDeathTest) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; // Make sure that we blow up (via abort() from the security connector) when // the name from the balancer doesn't match expectations. - ASSERT_DEATH( + ASSERT_DEATH_IF_SUPPORTED( { ResetStub(0, kApplicationTargetName_ + ";lb"); SetNextResolution({AddressData{balancers_[0]->port_, true, "woops"}}); @@ -1990,13 +1999,8 @@ TEST_F(SingleBalancerWithClientLoadReportingTest, Drop) { } // namespace grpc int main(int argc, char** argv) { - // Make the backup poller poll very frequently in order to pick up - // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); - grpc_init(); grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); const auto result = RUN_ALL_TESTS(); - grpc_shutdown(); return result; } diff --git a/test/cpp/end2end/service_config_end2end_test.cc b/test/cpp/end2end/service_config_end2end_test.cc index 8bf4a7c22ff..a00a45ecbb7 100644 --- a/test/cpp/end2end/service_config_end2end_test.cc +++ b/test/cpp/end2end/service_config_end2end_test.cc @@ -119,6 +119,12 @@ class ServiceConfigEnd2endTest : public ::testing::Test { creds_(new SecureChannelCredentials( grpc_fake_transport_security_credentials_create())) {} + static void SetUpTestCase() { + // Make the backup poller poll very frequently in order to pick up + // updates from all the subchannels's FDs. + GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + } + void SetUp() override { grpc_init(); response_generator_ = @@ -611,9 +617,6 @@ TEST_F(ServiceConfigEnd2endTest, } // namespace grpc int main(int argc, char** argv) { - // Make the backup poller poll very frequently in order to pick up - // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); ::testing::InitGoogleTest(&argc, argv); grpc::testing::TestEnvironment env(argc, argv); const auto result = RUN_ALL_TESTS(); diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index eac6f32a538..5e7717e4e06 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -370,6 +370,15 @@ class XdsEnd2endTest : public ::testing::Test { client_load_reporting_interval_seconds_( client_load_reporting_interval_seconds) {} + static void SetUpTestCase() { + // Make the backup poller poll very frequently in order to pick up + // updates from all the subchannels's FDs. + GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_init(); + } + + static void TearDownTestCase() { grpc_shutdown(); } + void SetUp() override { response_generator_ = grpc_core::MakeRefCounted(); @@ -788,7 +797,7 @@ TEST_F(SingleBalancerTest, SecureNamingDeathTest) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; // Make sure that we blow up (via abort() from the security connector) when // the name from the balancer doesn't match expectations. - ASSERT_DEATH( + ASSERT_DEATH_IF_SUPPORTED( { ResetStub(0, kApplicationTargetName_ + ";lb"); SetNextResolution({}, @@ -1401,13 +1410,8 @@ class SingleBalancerWithClientLoadReportingTest : public XdsEnd2endTest { } // namespace grpc int main(int argc, char** argv) { - // Make the backup poller poll very frequently in order to pick up - // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); - grpc_init(); grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); const auto result = RUN_ALL_TESTS(); - grpc_shutdown(); return result; } diff --git a/test/cpp/grpclb/grpclb_api_test.cc b/test/cpp/grpclb/grpclb_api_test.cc index ecba9f9ca3c..0ace512c278 100644 --- a/test/cpp/grpclb/grpclb_api_test.cc +++ b/test/cpp/grpclb/grpclb_api_test.cc @@ -31,7 +31,12 @@ namespace { using grpc::lb::v1::LoadBalanceRequest; using grpc::lb::v1::LoadBalanceResponse; -class GrpclbTest : public ::testing::Test {}; +class GrpclbTest : public ::testing::Test { + protected: + static void SetUpTestCase() { grpc_init(); } + + static void TearDownTestCase() { grpc_shutdown(); } +}; grpc::string Ip4ToPackedString(const char* ip_str) { struct in_addr ip4; @@ -128,8 +133,6 @@ TEST_F(GrpclbTest, ParseResponseServerList) { int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); - grpc_init(); int ret = RUN_ALL_TESTS(); - grpc_shutdown(); return ret; } diff --git a/test/cpp/naming/cancel_ares_query_test.cc b/test/cpp/naming/cancel_ares_query_test.cc index 667011ae291..9d4390f63d2 100644 --- a/test/cpp/naming/cancel_ares_query_test.cc +++ b/test/cpp/naming/cancel_ares_query_test.cc @@ -177,7 +177,32 @@ void TestCancelActiveDNSQuery(ArgsStruct* args) { ArgsFinish(args); } -TEST(CancelDuringAresQuery, TestCancelActiveDNSQuery) { +class CancelDuringAresQuery : public ::testing::Test { + protected: + static void SetUpTestCase() { + GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "ares"); + // Sanity check the time that it takes to run the test + // including the teardown time (the teardown + // part of the test involves cancelling the DNS query, + // which is the main point of interest for this test). + overall_deadline = grpc_timeout_seconds_to_deadline(4); + grpc_init(); + } + + static void TearDownTestCase() { + grpc_shutdown(); + if (gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), overall_deadline) > 0) { + gpr_log(GPR_ERROR, "Test took too long"); + abort(); + } + } + + private: + static gpr_timespec overall_deadline; +}; +gpr_timespec CancelDuringAresQuery::overall_deadline; + +TEST_F(CancelDuringAresQuery, TestCancelActiveDNSQuery) { grpc_core::ExecCtx exec_ctx; ArgsStruct args; ArgsInit(&args); @@ -216,7 +241,7 @@ void MaybePollArbitraryPollsetTwice() {} #endif -TEST(CancelDuringAresQuery, TestFdsAreDeletedFromPollsetSet) { +TEST_F(CancelDuringAresQuery, TestFdsAreDeletedFromPollsetSet) { grpc_core::ExecCtx exec_ctx; ArgsStruct args; ArgsInit(&args); @@ -352,18 +377,18 @@ void TestCancelDuringActiveQuery( EndTest(client, cq); } -TEST(CancelDuringAresQuery, - TestHitDeadlineAndDestroyChannelDuringAresResolutionIsGraceful) { +TEST_F(CancelDuringAresQuery, + TestHitDeadlineAndDestroyChannelDuringAresResolutionIsGraceful) { TestCancelDuringActiveQuery(NONE /* don't set query timeouts */); } -TEST( +TEST_F( CancelDuringAresQuery, TestHitDeadlineAndDestroyChannelDuringAresResolutionWithQueryTimeoutIsGraceful) { TestCancelDuringActiveQuery(SHORT /* set short query timeout */); } -TEST( +TEST_F( CancelDuringAresQuery, TestHitDeadlineAndDestroyChannelDuringAresResolutionWithZeroQueryTimeoutIsGraceful) { TestCancelDuringActiveQuery(ZERO /* disable query timeouts */); @@ -374,18 +399,6 @@ TEST( int main(int argc, char** argv) { grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); - GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "ares"); - // Sanity check the time that it takes to run the test - // including the teardown time (the teardown - // part of the test involves cancelling the DNS query, - // which is the main point of interest for this test). - gpr_timespec overall_deadline = grpc_timeout_seconds_to_deadline(4); - grpc_init(); auto result = RUN_ALL_TESTS(); - grpc_shutdown(); - if (gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), overall_deadline) > 0) { - gpr_log(GPR_ERROR, "Test took too long"); - abort(); - } return result; } diff --git a/test/cpp/server/server_builder_test.cc b/test/cpp/server/server_builder_test.cc index 5c22dda16f0..e07ae8dbc66 100644 --- a/test/cpp/server/server_builder_test.cc +++ b/test/cpp/server/server_builder_test.cc @@ -44,13 +44,19 @@ const grpc::string& GetPort() { return g_port; } -TEST(ServerBuilderTest, NoOp) { ServerBuilder b; } +class ServerBuilderTest : public ::testing::Test { + protected: + static void SetUpTestCase() { grpc_init(); } -TEST(ServerBuilderTest, CreateServerNoPorts) { + static void TearDownTestCase() { grpc_shutdown(); } +}; +TEST_F(ServerBuilderTest, NoOp) { ServerBuilder b; } + +TEST_F(ServerBuilderTest, CreateServerNoPorts) { ServerBuilder().RegisterService(&g_service).BuildAndStart()->Shutdown(); } -TEST(ServerBuilderTest, CreateServerOnePort) { +TEST_F(ServerBuilderTest, CreateServerOnePort) { ServerBuilder() .RegisterService(&g_service) .AddListeningPort(GetPort(), InsecureServerCredentials()) @@ -58,7 +64,7 @@ TEST(ServerBuilderTest, CreateServerOnePort) { ->Shutdown(); } -TEST(ServerBuilderTest, CreateServerRepeatedPort) { +TEST_F(ServerBuilderTest, CreateServerRepeatedPort) { ServerBuilder() .RegisterService(&g_service) .AddListeningPort(GetPort(), InsecureServerCredentials()) @@ -67,7 +73,7 @@ TEST(ServerBuilderTest, CreateServerRepeatedPort) { ->Shutdown(); } -TEST(ServerBuilderTest, CreateServerRepeatedPortWithDisallowedReusePort) { +TEST_F(ServerBuilderTest, CreateServerRepeatedPortWithDisallowedReusePort) { EXPECT_EQ(ServerBuilder() .RegisterService(&g_service) .AddListeningPort(GetPort(), InsecureServerCredentials()) @@ -82,8 +88,6 @@ TEST(ServerBuilderTest, CreateServerRepeatedPortWithDisallowedReusePort) { int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); - grpc_init(); int ret = RUN_ALL_TESTS(); - grpc_shutdown(); return ret; } diff --git a/test/cpp/server/server_builder_with_socket_mutator_test.cc b/test/cpp/server/server_builder_with_socket_mutator_test.cc index 5c7dd696c9f..15e5c073a04 100644 --- a/test/cpp/server/server_builder_with_socket_mutator_test.cc +++ b/test/cpp/server/server_builder_with_socket_mutator_test.cc @@ -86,7 +86,14 @@ class MockSocketMutatorServerBuilderOption : public grpc::ServerBuilderOption { MockSocketMutator* mock_socket_mutator_; }; -TEST(ServerBuilderWithSocketMutatorTest, CreateServerWithSocketMutator) { +class ServerBuilderWithSocketMutatorTest : public ::testing::Test { + protected: + static void SetUpTestCase() { grpc_init(); } + + static void TearDownTestCase() { grpc_shutdown(); } +}; + +TEST_F(ServerBuilderWithSocketMutatorTest, CreateServerWithSocketMutator) { auto address = "localhost:" + std::to_string(grpc_pick_unused_port_or_die()); auto mock_socket_mutator = new MockSocketMutator(); std::unique_ptr mock_socket_mutator_builder_option( @@ -109,8 +116,6 @@ TEST(ServerBuilderWithSocketMutatorTest, CreateServerWithSocketMutator) { int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); - grpc_init(); int ret = RUN_ALL_TESTS(); - grpc_shutdown(); return ret; } diff --git a/test/cpp/util/byte_buffer_test.cc b/test/cpp/util/byte_buffer_test.cc index 9bffbf7ac1c..fdae56a90c2 100644 --- a/test/cpp/util/byte_buffer_test.cc +++ b/test/cpp/util/byte_buffer_test.cc @@ -36,7 +36,12 @@ namespace { const char* kContent1 = "hello xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; const char* kContent2 = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy world"; -class ByteBufferTest : public ::testing::Test {}; +class ByteBufferTest : public ::testing::Test { + protected: + static void SetUpTestCase() { grpc_init(); } + + static void TearDownTestCase() { grpc_shutdown(); } +}; TEST_F(ByteBufferTest, CopyCtor) { ByteBuffer buffer1; @@ -121,8 +126,6 @@ TEST_F(ByteBufferTest, SerializationMakesCopy) { int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); - grpc_init(); int ret = RUN_ALL_TESTS(); - grpc_shutdown(); return ret; } diff --git a/test/cpp/util/slice_test.cc b/test/cpp/util/slice_test.cc index dc1910038f0..f8561c48a14 100644 --- a/test/cpp/util/slice_test.cc +++ b/test/cpp/util/slice_test.cc @@ -33,6 +33,10 @@ const char* kContent = "hello xxxxxxxxxxxxxxxxxxxx world"; class SliceTest : public ::testing::Test { protected: + static void SetUpTestCase() { grpc_init(); } + + static void TearDownTestCase() { grpc_shutdown(); } + void CheckSliceSize(const Slice& s, const grpc::string& content) { EXPECT_EQ(content.size(), s.size()); } @@ -132,8 +136,6 @@ TEST_F(SliceTest, Cslice) { int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); - grpc_init(); int ret = RUN_ALL_TESTS(); - grpc_shutdown(); return ret; } From 43628b286ff94de01aaee70f6578302db45d32ec Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Wed, 19 Jun 2019 14:14:02 -0700 Subject: [PATCH 0624/1555] Update googletest version to v1.8.1 Bazel builds of test/cpp/end2end:end2end_test were failing on Mac OS with v1.8.0 due to missing gtest symbols. The issue is not seen in v1.8.1. A WORKSPACE file was added to gtest repo in 1.8.1, so gtest.BUILD can be removed. --- bazel/grpc_deps.bzl | 12 ++---- test/cpp/end2end/BUILD | 6 --- test/cpp/ext/filters/census/BUILD | 1 - test/cpp/naming/BUILD | 2 +- .../generate_resolver_component_tests.bzl | 4 +- test/cpp/server/load_reporter/BUILD | 1 - third_party/googletest | 2 +- third_party/gtest.BUILD | 42 ------------------- tools/run_tests/sanity/check_submodules.sh | 2 +- 9 files changed, 8 insertions(+), 64 deletions(-) delete mode 100644 third_party/gtest.BUILD diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 151825c6839..9512c25dfbe 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -66,11 +66,6 @@ def grpc_deps(): actual = "@com_github_google_googletest//:gtest", ) - native.bind( - name = "gmock", - actual = "@com_github_google_googletest//:gmock", - ) - native.bind( name = "benchmark", actual = "@com_github_google_benchmark//:benchmark", @@ -144,10 +139,9 @@ def grpc_deps(): if "com_github_google_googletest" not in native.existing_rules(): http_archive( name = "com_github_google_googletest", - build_file = "@com_github_grpc_grpc//third_party:gtest.BUILD", - sha256 = "175a22300b3450e27e5f2e6f95cc9abca74617cbc21a1e0ed19bdfbd22ea0305", - strip_prefix = "googletest-ec44c6c1675c25b9827aacd08c02433cccde7780", - url = "https://github.com/google/googletest/archive/ec44c6c1675c25b9827aacd08c02433cccde7780.tar.gz", + sha256 = "d0d447b4feeedca837a0d46a289d4223089b32ac2f84545fa4982755cc8919be", + strip_prefix = "googletest-2fe3bd994b3189899d93f1d5a881e725e046fdc2", + url = "https://github.com/google/googletest/archive/2fe3bd994b3189899d93f1d5a881e725e046fdc2.tar.gz", ) if "com_github_gflags_gflags" not in native.existing_rules(): diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD index d229cc33034..ab0ef0c46ba 100644 --- a/test/cpp/end2end/BUILD +++ b/test/cpp/end2end/BUILD @@ -369,7 +369,6 @@ grpc_cc_test( name = "mock_test", srcs = ["mock_test.cc"], external_deps = [ - "gmock", "gtest", ], deps = [ @@ -406,7 +405,6 @@ grpc_cc_test( name = "client_lb_end2end_test", srcs = ["client_lb_end2end_test.cc"], external_deps = [ - "gmock", "gtest", ], deps = [ @@ -427,7 +425,6 @@ grpc_cc_test( name = "service_config_end2end_test", srcs = ["service_config_end2end_test.cc"], external_deps = [ - "gmock", "gtest", ], deps = [ @@ -447,7 +444,6 @@ grpc_cc_test( name = "grpclb_end2end_test", srcs = ["grpclb_end2end_test.cc"], external_deps = [ - "gmock", "gtest", ], deps = [ @@ -469,7 +465,6 @@ grpc_cc_test( name = "xds_end2end_test", srcs = ["xds_end2end_test.cc"], external_deps = [ - "gmock", "gtest", ], deps = [ @@ -594,7 +589,6 @@ grpc_cc_test( srcs = ["server_load_reporting_end2end_test.cc"], external_deps = [ "gtest", - "gmock", ], deps = [ "//:grpcpp_server_load_reporting", diff --git a/test/cpp/ext/filters/census/BUILD b/test/cpp/ext/filters/census/BUILD index 78b27e2063c..452a84b2a7a 100644 --- a/test/cpp/ext/filters/census/BUILD +++ b/test/cpp/ext/filters/census/BUILD @@ -26,7 +26,6 @@ grpc_cc_test( ], external_deps = [ "gtest", - "gmock", "opencensus-stats-test", ], language = "C++", diff --git a/test/cpp/naming/BUILD b/test/cpp/naming/BUILD index 7db435a3fd4..b91c0b83c9b 100644 --- a/test/cpp/naming/BUILD +++ b/test/cpp/naming/BUILD @@ -37,7 +37,7 @@ grpc_py_binary( grpc_cc_test( name = "cancel_ares_query_test", srcs = ["cancel_ares_query_test.cc"], - external_deps = ["gmock"], + external_deps = ["gtest"], deps = [ ":dns_test_util", "//:gpr", diff --git a/test/cpp/naming/generate_resolver_component_tests.bzl b/test/cpp/naming/generate_resolver_component_tests.bzl index bcc62f62871..2ce61d05446 100755 --- a/test/cpp/naming/generate_resolver_component_tests.bzl +++ b/test/cpp/naming/generate_resolver_component_tests.bzl @@ -23,7 +23,7 @@ def generate_resolver_component_tests(): "address_sorting_test.cc", ], external_deps = [ - "gmock", + "gtest", ], deps = [ "//test/cpp/util:test_util%s" % unsecure_build_config_suffix, @@ -43,7 +43,7 @@ def generate_resolver_component_tests(): "resolver_component_test.cc", ], external_deps = [ - "gmock", + "gtest", ], deps = [ ":dns_test_util", diff --git a/test/cpp/server/load_reporter/BUILD b/test/cpp/server/load_reporter/BUILD index db5c93263ad..633b6d8c0d9 100644 --- a/test/cpp/server/load_reporter/BUILD +++ b/test/cpp/server/load_reporter/BUILD @@ -35,7 +35,6 @@ grpc_cc_test( srcs = ["load_reporter_test.cc"], external_deps = [ "gtest", - "gmock", "opencensus-stats-test", ], deps = [ diff --git a/third_party/googletest b/third_party/googletest index ec44c6c1675..2fe3bd994b3 160000 --- a/third_party/googletest +++ b/third_party/googletest @@ -1 +1 @@ -Subproject commit ec44c6c1675c25b9827aacd08c02433cccde7780 +Subproject commit 2fe3bd994b3189899d93f1d5a881e725e046fdc2 diff --git a/third_party/gtest.BUILD b/third_party/gtest.BUILD deleted file mode 100644 index f38bfd8d457..00000000000 --- a/third_party/gtest.BUILD +++ /dev/null @@ -1,42 +0,0 @@ -cc_library( - name = "gtest", - srcs = [ - "googletest/src/gtest-all.cc", - ], - hdrs = glob([ - "googletest/include/**/*.h", - "googletest/src/*.cc", - "googletest/src/*.h", - ]), - includes = [ - "googletest", - "googletest/include", - ], - linkstatic = 1, - visibility = [ - "//visibility:public", - ], -) - -cc_library( - name = "gmock", - srcs = [ - "googlemock/src/gmock-all.cc" - ], - hdrs = glob([ - "googlemock/include/**/*.h", - "googlemock/src/*.cc", - "googlemock/src/*.h" - ]), - includes = [ - "googlemock", - "googlemock/include", - ], - deps = [ - ":gtest", - ], - linkstatic = 1, - visibility = [ - "//visibility:public", - ], -) diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index 487479ba3da..7b11d49655c 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -35,7 +35,7 @@ cat << EOF | awk '{ print $1 }' | sort > "$want_submodules" 911001cdca003337bdb93fab32740cde61bafee3 third_party/data-plane-api (heads/master) 28f50e0fed19872e0fd50dd23ce2ee8cd759338e third_party/gflags (v2.2.0-5-g30dbc81) 80ed4d0bbf65d57cc267dfc63bd2584557f11f9b third_party/googleapis (common-protos-1_3_1-915-g80ed4d0bb) - ec44c6c1675c25b9827aacd08c02433cccde7780 third_party/googletest (release-1.8.0) + 2fe3bd994b3189899d93f1d5a881e725e046fdc2 third_party/googletest (release-1.8.1) 6599cac0965be8e5a835ab7a5684bbef033d5ad0 third_party/libcxx (heads/release_60) 9245d481eb3e890f708ff2d7dadf2a10c04748ba third_party/libcxxabi (heads/release_60) 09745575a923640154bcf307fba8aedff47f240a third_party/protobuf (v3.7.0-rc.2-247-g09745575) From fdd856312a7a4e987629de816eaabcfad17623da Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Thu, 20 Jun 2019 18:23:17 -0700 Subject: [PATCH 0625/1555] Modify class name and other small changes --- src/core/lib/iomgr/executor/mpmcqueue.cc | 93 +++++++++--------- src/core/lib/iomgr/executor/mpmcqueue.h | 45 ++++----- test/core/iomgr/mpmcqueue_test.cc | 114 ++++++++--------------- 3 files changed, 105 insertions(+), 147 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index 7dc7be87e79..6deba05a421 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -29,40 +29,48 @@ #include #include "src/core/lib/debug/stats.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/sync.h" namespace grpc_core { -DebugOnlyTraceFlag thread_pool_trace(false, "thread_pool_trace"); +DebugOnlyTraceFlag thread_pool(false, "thread_pool_trace"); -inline void* MPMCQueue::PopFront() { +inline void* InfLenFIFOQueue::PopFront() { void* result = queue_head_->content; Node* head_to_remove = queue_head_; queue_head_ = queue_head_->next; - count_.Store(count_.Load(MemoryOrder::RELAXED) - 1, MemoryOrder::RELAXED); - gpr_timespec wait_time = + count_.FetchSub(1, MemoryOrder::RELAXED); + + if (GRPC_TRACE_FLAG_ENABLED(thread_pool)) { + gpr_timespec wait_time = gpr_time_sub(gpr_now(GPR_CLOCK_PRECISE), head_to_remove->insert_time); - gpr_free(head_to_remove); + // Updates Stats info + stats_.num_completed++; + stats_.total_queue_cycles = + gpr_time_add(stats_.total_queue_cycles, wait_time); + stats_.max_queue_cycles = gpr_time_max( + gpr_convert_clock_type(stats_.max_queue_cycles, GPR_TIMESPAN), + wait_time); - // Update Stats info - stats_.num_completed++; - stats_.total_queue_cycles = - gpr_time_add(stats_.total_queue_cycles, wait_time); - stats_.max_queue_cycles = gpr_time_max( - gpr_convert_clock_type(stats_.max_queue_cycles, GPR_TIMESPAN), wait_time); + if (count_.Load(MemoryOrder::RELAXED) == 0) { + stats_.busy_time_cycles = + gpr_time_add(stats_.busy_time_cycles, + gpr_time_sub(gpr_now(GPR_CLOCK_PRECISE), busy_time)); + } - if (count_.Load(MemoryOrder::RELAXED) == 0) { - stats_.busy_time_cycles = - gpr_time_add(stats_.busy_time_cycles, - gpr_time_sub(gpr_now(GPR_CLOCK_PRECISE), busy_time)); - } - - if (GRPC_TRACE_FLAG_ENABLED(thread_pool_trace)) { - PrintStats(); + gpr_log(GPR_INFO, + "[InfLenFIFOQueue Get] num_completed: %" PRIu64 + " total_queue_cycles: %" PRId32 " max_queue_cycles: %" PRId32 + " busy_time_cycles: %" PRId32, + stats_.num_completed, gpr_time_to_millis(stats_.total_queue_cycles), + gpr_time_to_millis(stats_.max_queue_cycles), + gpr_time_to_millis(stats_.busy_time_cycles)); } + Delete(head_to_remove); // Singal waiting thread if (count_.Load(MemoryOrder::RELAXED) > 0 && num_waiters_ > 0) { wait_nonempty_.Signal(); @@ -71,37 +79,34 @@ inline void* MPMCQueue::PopFront() { return result; } -MPMCQueue::MPMCQueue() - : num_waiters_(0), queue_head_(nullptr), queue_tail_(nullptr) { - count_.Store(0, MemoryOrder::RELAXED); -} +InfLenFIFOQueue::InfLenFIFOQueue() + : num_waiters_(0), queue_head_(nullptr), queue_tail_(nullptr) {} -MPMCQueue::~MPMCQueue() { +InfLenFIFOQueue::~InfLenFIFOQueue() { GPR_ASSERT(count_.Load(MemoryOrder::RELAXED) == 0); - MutexLock l(&mu_); GPR_ASSERT(num_waiters_ == 0); } -void MPMCQueue::Put(void* elem) { +void InfLenFIFOQueue::Put(void* elem) { MutexLock l(&mu_); - Node* new_node = static_cast(gpr_malloc(sizeof(Node))); - new_node->next = nullptr; - new_node->content = elem; - new_node->insert_time = gpr_now(GPR_CLOCK_PRECISE); + Node* new_node = New(elem); if (count_.Load(MemoryOrder::RELAXED) == 0) { - busy_time = gpr_now(GPR_CLOCK_PRECISE); + if (GRPC_TRACE_FLAG_ENABLED(thread_pool)) { + busy_time = gpr_now(GPR_CLOCK_PRECISE); + } queue_head_ = queue_tail_ = new_node; } else { queue_tail_->next = new_node; queue_tail_ = queue_tail_->next; } - count_.Store(count_.Load(MemoryOrder::RELAXED) + 1, MemoryOrder::RELAXED); + count_.FetchAdd(1, MemoryOrder::RELAXED); - // Update Stats info - stats_.num_started++; - if (GRPC_TRACE_FLAG_ENABLED(thread_pool_trace)) { - PrintStats(); + // Updates Stats info + if (GRPC_TRACE_FLAG_ENABLED(thread_pool)) { + stats_.num_started++; + gpr_log(GPR_INFO, "[InfLenFIFOQueue Put] num_started: %" PRIu64, + stats_.num_started); } if (num_waiters_ > 0) { @@ -109,7 +114,7 @@ void MPMCQueue::Put(void* elem) { } } -void* MPMCQueue::Get() { +void* InfLenFIFOQueue::Get() { MutexLock l(&mu_); if (count_.Load(MemoryOrder::RELAXED) == 0) { num_waiters_++; @@ -118,20 +123,8 @@ void* MPMCQueue::Get() { } while (count_.Load(MemoryOrder::RELAXED) == 0); num_waiters_--; } - GPR_ASSERT(count_.Load(MemoryOrder::RELAXED) > 0); + GPR_DEBUG_ASSERT(count_.Load(MemoryOrder::RELAXED) > 0); return PopFront(); } -void MPMCQueue::PrintStats() { - gpr_log(GPR_INFO, "STATS INFO:"); - gpr_log(GPR_INFO, "num_started: %" PRIu64, stats_.num_started); - gpr_log(GPR_INFO, "num_completed: %" PRIu64, stats_.num_completed); - gpr_log(GPR_INFO, "total_queue_cycles: %" PRId32, - gpr_time_to_millis(stats_.total_queue_cycles)); - gpr_log(GPR_INFO, "max_queue_cycles: %" PRId32, - gpr_time_to_millis(stats_.max_queue_cycles)); - gpr_log(GPR_INFO, "busy_time_cycles: %" PRId32, - gpr_time_to_millis(stats_.busy_time_cycles)); -} - } // namespace grpc_core diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index aec8dd33c60..8b59b053bf9 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -16,8 +16,8 @@ * */ -#ifndef GRPC_CORE_LIB_IOMGR_EXECUTOR_MPMCQUEUE_H -#define GRPC_CORE_LIB_IOMGR_EXECUTOR_MPMCQUEUE_H +#ifndef GRPC_CORE_LIB_IOMGR_EXECUTOR_INFLENFIFOQUEUE_H +#define GRPC_CORE_LIB_IOMGR_EXECUTOR_INFLENFIFOQUEUE_H #include @@ -31,46 +31,47 @@ namespace grpc_core { -extern DebugOnlyTraceFlag thread_pool_trace; +extern DebugOnlyTraceFlag thread_pool; -// Abstract base class of a MPMC queue interface +// Abstract base class of a Multiple-Producer-Multiple-Consumer(MPMC) queue +// interface class MPMCQueueInterface { public: virtual ~MPMCQueueInterface() {} - // Put elem into queue immediately at the end of queue. + // Puts elem into queue immediately at the end of queue. // This might cause to block on full queue depending on implementation. virtual void Put(void* elem) GRPC_ABSTRACT; - // Remove the oldest element from the queue and return it. + // Removes the oldest element from the queue and return it. // This might cause to block on empty queue depending on implementation. virtual void* Get() GRPC_ABSTRACT; - // Return number of elements in the queue currently + // Returns number of elements in the queue currently virtual int count() const GRPC_ABSTRACT; GRPC_ABSTRACT_BASE_CLASS }; -class MPMCQueue : public MPMCQueueInterface { +class InfLenFIFOQueue : public MPMCQueueInterface { public: - // Create a new Multiple-Producer-Multiple-Consumer Queue. The queue created + // Creates a new MPMC Queue. The queue created // will have infinite length. - MPMCQueue(); + InfLenFIFOQueue(); - // Release all resources hold by the queue. The queue must be empty, and no + // Releases all resources hold by the queue. The queue must be empty, and no // one waiting on conditional variables. - ~MPMCQueue(); + ~InfLenFIFOQueue(); - // Put elem into queue immediately at the end of queue. Since the queue has + // Puts elem into queue immediately at the end of queue. Since the queue has // infinite length, this routine will never block and should never fail. void Put(void* elem); - // Remove the oldest element from the queue and return it. + // Removes the oldest element from the queue and returns it. // This routine will cause the thread to block if queue is currently empty. void* Get(); - // Return number of elements in queue currently. + // Returns number of elements in queue currently. // There might be concurrently add/remove on queue, so count might change // quickly. int count() const { return count_.Load(MemoryOrder::RELAXED); } @@ -78,11 +79,11 @@ class MPMCQueue : public MPMCQueueInterface { GRPC_ABSTRACT_BASE_CLASS private: + // For Internal Use Only. + // Removes the oldest element from the queue and returns it. This routine + // will NOT check whether queue is empty, and it will NOT acquire mutex. void* PopFront(); - // Print out Stats. Time measurement are printed in millisecond. - void PrintStats(); - struct Node { Node* next; // Linking void* content; // Points to actual element @@ -94,7 +95,9 @@ class MPMCQueue : public MPMCQueueInterface { } }; - struct Stats { // Stats of queue + // Stats of queue. This will only be collect when debug trace mode is on. + // All printed stats info will have time measurement in millisecond. + struct Stats { uint64_t num_started; // Number of elements have been added to queue uint64_t num_completed; // Number of elements have been removed from // the queue @@ -120,11 +123,11 @@ class MPMCQueue : public MPMCQueueInterface { Node* queue_head_; // Head of the queue, remove position Node* queue_tail_; // End of queue, insert position - Atomic count_; // Number of elements in queue + Atomic count_{0}; // Number of elements in queue Stats stats_; // Stats info gpr_timespec busy_time; // Start time of busy queue }; } // namespace grpc_core -#endif /* GRPC_CORE_LIB_IOMGR_EXECUTOR_MPMCQUEUE_H */ +#endif /* GRPC_CORE_LIB_IOMGR_EXECUTOR_INFLENFIFOQUEUE_H */ diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index 12799d7895e..ebbf060961f 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -29,14 +29,6 @@ #define THREAD_SMALL_ITERATION 100 #define THREAD_LARGE_ITERATION 10000 -static void test_no_op(void) { - gpr_log(GPR_DEBUG, "test_no_op"); - grpc_core::MPMCQueue mpmcqueue; - gpr_log(GPR_DEBUG, "Checking count..."); - GPR_ASSERT(mpmcqueue.count() == 0); - gpr_log(GPR_DEBUG, "Done."); -} - // Testing items for queue struct WorkItem { int index; @@ -45,59 +37,44 @@ struct WorkItem { WorkItem(int i) : index(i) { done = false; } }; -static void test_small_queue(void) { - gpr_log(GPR_DEBUG, "test_small_queue"); - grpc_core::MPMCQueue small_queue; - for (int i = 0; i < THREAD_SMALL_ITERATION; ++i) { - small_queue.Put(static_cast(new WorkItem(i))); - } - GPR_ASSERT(small_queue.count() == THREAD_SMALL_ITERATION); - // Get items out in FIFO order - for (int i = 0; i < THREAD_SMALL_ITERATION; ++i) { - WorkItem* item = static_cast(small_queue.Get()); - GPR_ASSERT(i == item->index); - delete item; - } - gpr_log(GPR_DEBUG, "Done."); -} - -static void test_get_thd(void* args) { - grpc_core::MPMCQueue* mpmcqueue = static_cast(args); +static void ConsumerThread(void* args) { + grpc_core::InfLenFIFOQueue* queue = + static_cast(args); // count number of Get() called in this thread int count = 0; - int last_index = -1; + WorkItem* item; - while ((item = static_cast(mpmcqueue->Get())) != nullptr) { + while ((item = static_cast(queue->Get())) != nullptr) { count++; - GPR_ASSERT(item->index > last_index); - last_index = item->index; GPR_ASSERT(!item->done); - delete item; + item->done = true; } - gpr_log(GPR_DEBUG, "test_get_thd: %d times of Get() called.", count); + gpr_log(GPR_DEBUG, "ConsumerThread: %d times of Get() called.", count); } static void test_get_empty(void) { - gpr_log(GPR_DEBUG, "test_get_empty"); - grpc_core::MPMCQueue mpmcqueue; + gpr_log(GPR_INFO, "test_get_empty"); + grpc_core::InfLenFIFOQueue queue; + GPR_ASSERT(queue.count() == 0); const int num_threads = 10; grpc_core::Thread thds[num_threads]; // Fork threads. Threads should block at the beginning since queue is empty. for (int i = 0; i < num_threads; ++i) { - thds[i] = grpc_core::Thread("mpmcq_test_ge_thd", test_get_thd, &mpmcqueue); + thds[i] = + grpc_core::Thread("mpmcq_test_ge_thd", ConsumerThread, &queue); thds[i].Start(); } for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { - mpmcqueue.Put(static_cast(new WorkItem(i))); + queue.Put(static_cast(new WorkItem(i))); } gpr_log(GPR_DEBUG, "Terminating threads..."); for (int i = 0; i < num_threads; ++i) { - mpmcqueue.Put(nullptr); + queue.Put(nullptr); } for (int i = 0; i < num_threads; ++i) { thds[i].Join(); @@ -105,9 +82,9 @@ static void test_get_empty(void) { gpr_log(GPR_DEBUG, "Done."); } -static void test_large_queue(void) { - gpr_log(GPR_DEBUG, "test_large_queue"); - grpc_core::MPMCQueue large_queue; +static void test_FIFO(void) { + gpr_log(GPR_INFO, "test_large_queue"); + grpc_core::InfLenFIFOQueue large_queue; for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { large_queue.Put(static_cast(new WorkItem(i))); } @@ -120,18 +97,19 @@ static void test_large_queue(void) { } // Thread for put items into queue -class WorkThread { +class ProducerThread { public: - WorkThread(grpc_core::MPMCQueue* mpmcqueue, int start_index, int num_items) + ProducerThread(grpc_core::InfLenFIFOQueue* queue, int start_index, + int num_items) : start_index_(start_index), num_items_(num_items), - mpmcqueue_(mpmcqueue) { + queue_(queue) { items_ = nullptr; thd_ = grpc_core::Thread( "mpmcq_test_mt_put_thd", - [](void* th) { static_cast(th)->Run(); }, this); + [](void* th) { static_cast(th)->Run(); }, this); } - ~WorkThread() { + ~ProducerThread() { for (int i = 0; i < num_items_; ++i) { GPR_ASSERT(items_[i]->done); delete items_[i]; @@ -147,63 +125,49 @@ class WorkThread { items_ = new WorkItem*[num_items_]; for (int i = 0; i < num_items_; ++i) { items_[i] = new WorkItem(start_index_ + i); - mpmcqueue_->Put(items_[i]); + queue_->Put(items_[i]); } } int start_index_; int num_items_; - grpc_core::MPMCQueue* mpmcqueue_; + grpc_core::InfLenFIFOQueue* queue_; grpc_core::Thread thd_; WorkItem** items_; }; -static void test_many_get_thd(void* args) { - grpc_core::MPMCQueue* mpmcqueue = static_cast(args); - // count number of Get() called in this thread - int count = 0; - - WorkItem* item; - while ((item = static_cast(mpmcqueue->Get())) != nullptr) { - count++; - GPR_ASSERT(!item->done); - item->done = true; - } - - gpr_log(GPR_DEBUG, "test_many_get_thd: %d times of Get() called.", count); -} static void test_many_thread(void) { - gpr_log(GPR_DEBUG, "test_many_thread"); + gpr_log(GPR_INFO, "test_many_thread"); const int num_work_thd = 10; const int num_get_thd = 20; - grpc_core::MPMCQueue mpmcqueue; - WorkThread** work_thds = new WorkThread*[num_work_thd]; + grpc_core::InfLenFIFOQueue queue; + ProducerThread** work_thds = new ProducerThread*[num_work_thd]; grpc_core::Thread get_thds[num_get_thd]; - gpr_log(GPR_DEBUG, "Fork WorkThread..."); + gpr_log(GPR_DEBUG, "Fork ProducerThread..."); for (int i = 0; i < num_work_thd; ++i) { - work_thds[i] = new WorkThread(&mpmcqueue, i * THREAD_LARGE_ITERATION, + work_thds[i] = new ProducerThread(&queue, i * THREAD_LARGE_ITERATION, THREAD_LARGE_ITERATION); work_thds[i]->Start(); } - gpr_log(GPR_DEBUG, "WorkThread Started."); - gpr_log(GPR_DEBUG, "For Getter Thread..."); + gpr_log(GPR_DEBUG, "ProducerThread Started."); + gpr_log(GPR_DEBUG, "Fork Getter Thread..."); for (int i = 0; i < num_get_thd; ++i) { - get_thds[i] = grpc_core::Thread("mpmcq_test_mt_get_thd", test_many_get_thd, - &mpmcqueue); + get_thds[i] = grpc_core::Thread("mpmcq_test_mt_get_thd", ConsumerThread, + &queue); get_thds[i].Start(); } gpr_log(GPR_DEBUG, "Getter Thread Started."); - gpr_log(GPR_DEBUG, "Waiting WorkThread to finish..."); + gpr_log(GPR_DEBUG, "Waiting ProducerThread to finish..."); for (int i = 0; i < num_work_thd; ++i) { work_thds[i]->Join(); } - gpr_log(GPR_DEBUG, "All WorkThread Terminated."); + gpr_log(GPR_DEBUG, "All ProducerThread Terminated."); gpr_log(GPR_DEBUG, "Terminating Getter Thread..."); for (int i = 0; i < num_get_thd; ++i) { - mpmcqueue.Put(nullptr); + queue.Put(nullptr); } for (int i = 0; i < num_get_thd; ++i) { get_thds[i].Join(); @@ -221,10 +185,8 @@ int main(int argc, char** argv) { grpc::testing::TestEnvironment env(argc, argv); grpc_init(); gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG); - test_no_op(); - test_small_queue(); test_get_empty(); - test_large_queue(); + test_FIFO(); test_many_thread(); grpc_shutdown(); return 0; From cb6924d48fe4f6187da66ae1ad3d12b26ce745b7 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Thu, 20 Jun 2019 19:15:46 -0700 Subject: [PATCH 0626/1555] Fix header --- src/core/lib/iomgr/executor/mpmcqueue.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index 8b59b053bf9..2dee79737ca 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -16,8 +16,8 @@ * */ -#ifndef GRPC_CORE_LIB_IOMGR_EXECUTOR_INFLENFIFOQUEUE_H -#define GRPC_CORE_LIB_IOMGR_EXECUTOR_INFLENFIFOQUEUE_H +#ifndef GRPC_CORE_LIB_IOMGR_EXECUTOR_MPMCQUEUE_H +#define GRPC_CORE_LIB_IOMGR_EXECUTOR_MPMCQUEUE_H #include @@ -130,4 +130,4 @@ class InfLenFIFOQueue : public MPMCQueueInterface { } // namespace grpc_core -#endif /* GRPC_CORE_LIB_IOMGR_EXECUTOR_INFLENFIFOQUEUE_H */ +#endif /* GRPC_CORE_LIB_IOMGR_EXECUTOR_MPMCQUEUE_H */ From befd236fa3dcb3560b3fd15e8e57ca97c577f492 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Thu, 20 Jun 2019 19:18:48 -0700 Subject: [PATCH 0627/1555] Remove extra --- src/core/lib/iomgr/executor/mpmcqueue.h | 2 - test/core/iomgr/mpmcqueue_test.cc | 83 ++++++++++++------------- 2 files changed, 41 insertions(+), 44 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index 2dee79737ca..a46e5ea28fd 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -49,8 +49,6 @@ class MPMCQueueInterface { // Returns number of elements in the queue currently virtual int count() const GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS }; class InfLenFIFOQueue : public MPMCQueueInterface { diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index ebbf060961f..8f89b5c08bf 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -37,6 +37,47 @@ struct WorkItem { WorkItem(int i) : index(i) { done = false; } }; +// Thread for put items into queue +class ProducerThread { + public: + ProducerThread(grpc_core::InfLenFIFOQueue* queue, int start_index, + int num_items) + : start_index_(start_index), + num_items_(num_items), + queue_(queue) { + items_ = nullptr; + thd_ = grpc_core::Thread( + "mpmcq_test_mt_put_thd", + [](void* th) { static_cast(th)->Run(); }, this); + } + ~ProducerThread() { + for (int i = 0; i < num_items_; ++i) { + GPR_ASSERT(items_[i]->done); + delete items_[i]; + } + delete[] items_; + } + + void Start() { thd_.Start(); } + void Join() { thd_.Join(); } + + private: + void Run() { + items_ = new WorkItem*[num_items_]; + for (int i = 0; i < num_items_; ++i) { + items_[i] = new WorkItem(start_index_ + i); + queue_->Put(items_[i]); + } + } + + int start_index_; + int num_items_; + grpc_core::InfLenFIFOQueue* queue_; + grpc_core::Thread thd_; + WorkItem** items_; +}; + + static void ConsumerThread(void* args) { grpc_core::InfLenFIFOQueue* queue = static_cast(args); @@ -96,48 +137,6 @@ static void test_FIFO(void) { } } -// Thread for put items into queue -class ProducerThread { - public: - ProducerThread(grpc_core::InfLenFIFOQueue* queue, int start_index, - int num_items) - : start_index_(start_index), - num_items_(num_items), - queue_(queue) { - items_ = nullptr; - thd_ = grpc_core::Thread( - "mpmcq_test_mt_put_thd", - [](void* th) { static_cast(th)->Run(); }, this); - } - ~ProducerThread() { - for (int i = 0; i < num_items_; ++i) { - GPR_ASSERT(items_[i]->done); - delete items_[i]; - } - delete[] items_; - } - - void Start() { thd_.Start(); } - void Join() { thd_.Join(); } - - private: - void Run() { - items_ = new WorkItem*[num_items_]; - for (int i = 0; i < num_items_; ++i) { - items_[i] = new WorkItem(start_index_ + i); - queue_->Put(items_[i]); - } - } - - int start_index_; - int num_items_; - grpc_core::InfLenFIFOQueue* queue_; - grpc_core::Thread thd_; - WorkItem** items_; -}; - - - static void test_many_thread(void) { gpr_log(GPR_INFO, "test_many_thread"); const int num_work_thd = 10; From 87bd0a080aa5bc60f343d559fbb6051bea0e89a7 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Thu, 20 Jun 2019 19:21:59 -0700 Subject: [PATCH 0628/1555] Fix pos of base macro --- src/core/lib/iomgr/executor/mpmcqueue.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index a46e5ea28fd..ae9a3b2826f 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -49,6 +49,8 @@ class MPMCQueueInterface { // Returns number of elements in the queue currently virtual int count() const GRPC_ABSTRACT; + + GRPC_ABSTRACT_BASE_CLASS }; class InfLenFIFOQueue : public MPMCQueueInterface { @@ -74,8 +76,6 @@ class InfLenFIFOQueue : public MPMCQueueInterface { // quickly. int count() const { return count_.Load(MemoryOrder::RELAXED); } - GRPC_ABSTRACT_BASE_CLASS - private: // For Internal Use Only. // Removes the oldest element from the queue and returns it. This routine From ef0f9bf7ec0ffec47554fd1eb9790835c2183728 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Thu, 20 Jun 2019 23:19:34 -0400 Subject: [PATCH 0629/1555] Introduce string_view and use it for gpr_split_host_port. --- BUILD | 8 +- BUILD.gn | 8 +- CMakeLists.txt | 44 ++++- Makefile | 54 +++++- build.yaml | 20 ++- config.m4 | 2 +- config.w32 | 2 +- gRPC-C++.podspec | 6 +- gRPC-Core.podspec | 8 +- grpc.gemspec | 5 +- grpc.gyp | 2 +- package.xml | 5 +- .../ext/filters/client_channel/http_proxy.cc | 19 +- .../client_channel/lb_policy/grpclb/grpclb.cc | 1 - .../client_channel/lb_policy/xds/xds.cc | 1 - .../filters/client_channel/parse_address.cc | 55 +++--- .../resolver/dns/c_ares/dns_resolver_ares.cc | 1 - .../resolver/dns/c_ares/grpc_ares_wrapper.cc | 95 +++++----- .../dns/c_ares/grpc_ares_wrapper_libuv.cc | 1 - .../dns/c_ares/grpc_ares_wrapper_windows.cc | 1 - .../resolver/dns/native/dns_resolver.cc | 1 - .../resolver/fake/fake_resolver.cc | 1 - .../resolver/sockaddr/sockaddr_resolver.cc | 1 - .../transport/chttp2/server/chttp2_server.cc | 1 - .../transport/chttp2/transport/frame_data.cc | 8 +- .../cronet/transport/cronet_transport.cc | 1 - src/core/lib/channel/channelz.cc | 15 +- src/core/lib/gpr/host_port.cc | 98 ----------- src/core/lib/gpr/string.cc | 9 +- src/core/lib/gpr/string.h | 1 + src/core/lib/gprpp/host_port.cc | 97 +++++++++++ src/core/lib/{gpr => gprpp}/host_port.h | 38 ++-- src/core/lib/gprpp/string_view.h | 143 +++++++++++++++ .../lib/http/httpcli_security_connector.cc | 4 +- src/core/lib/iomgr/resolve_address_custom.cc | 35 ++-- src/core/lib/iomgr/resolve_address_posix.cc | 18 +- src/core/lib/iomgr/resolve_address_windows.cc | 14 +- src/core/lib/iomgr/sockaddr_utils.cc | 8 +- .../lib/iomgr/socket_utils_common_posix.cc | 1 - src/core/lib/iomgr/tcp_client_cfstream.cc | 13 +- .../alts/alts_security_connector.cc | 5 +- .../fake/fake_security_connector.cc | 46 +++-- .../local/local_security_connector.cc | 5 +- .../security_connector/security_connector.cc | 2 +- .../security_connector/security_connector.h | 2 +- .../ssl/ssl_security_connector.cc | 38 ++-- .../security/security_connector/ssl_utils.cc | 57 +++--- .../security/security_connector/ssl_utils.h | 19 +- .../tls/spiffe_security_connector.cc | 36 ++-- .../tls/spiffe_security_connector.h | 7 +- .../security/transport/client_auth_filter.cc | 3 +- .../alts/handshaker/alts_tsi_handshaker.cc | 1 - src/core/tsi/ssl_transport_security.cc | 78 ++++----- src/core/tsi/ssl_transport_security.h | 3 +- .../CronetTests/CoreCronetEnd2EndTests.mm | 16 +- .../tests/CronetTests/CronetUnitTests.mm | 14 +- src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/bad_ssl/bad_ssl_test.cc | 8 +- .../parse_address_with_named_scope_id_test.cc | 17 +- test/core/end2end/bad_server_response_test.cc | 11 +- test/core/end2end/connection_refused_test.cc | 12 +- test/core/end2end/dualstack_socket_test.cc | 25 ++- test/core/end2end/fixtures/h2_census.cc | 22 ++- test/core/end2end/fixtures/h2_compress.cc | 33 ++-- test/core/end2end/fixtures/h2_fakesec.cc | 23 ++- test/core/end2end/fixtures/h2_full+pipe.cc | 21 ++- test/core/end2end/fixtures/h2_full+trace.cc | 21 ++- .../end2end/fixtures/h2_full+workarounds.cc | 24 ++- test/core/end2end/fixtures/h2_full.cc | 21 ++- test/core/end2end/fixtures/h2_http_proxy.cc | 27 ++- test/core/end2end/fixtures/h2_local_ipv4.cc | 4 +- test/core/end2end/fixtures/h2_local_ipv6.cc | 4 +- test/core/end2end/fixtures/h2_local_uds.cc | 8 +- test/core/end2end/fixtures/h2_oauth2.cc | 25 ++- test/core/end2end/fixtures/h2_proxy.cc | 1 - test/core/end2end/fixtures/h2_spiffe.cc | 25 +-- test/core/end2end/fixtures/h2_ssl.cc | 22 ++- .../end2end/fixtures/h2_ssl_cred_reload.cc | 24 ++- test/core/end2end/fixtures/h2_ssl_proxy.cc | 1 - test/core/end2end/fixtures/h2_uds.cc | 1 - .../end2end/fixtures/http_proxy_fixture.cc | 14 +- test/core/end2end/fixtures/inproc.cc | 1 - test/core/end2end/fixtures/local_util.cc | 15 +- test/core/end2end/fixtures/local_util.h | 6 +- test/core/end2end/fixtures/proxy.cc | 29 ++-- test/core/end2end/h2_ssl_cert_test.cc | 22 ++- .../core/end2end/h2_ssl_session_reuse_test.cc | 15 +- .../end2end/invalid_call_argument_test.cc | 15 +- test/core/fling/fling_stream_test.cc | 11 +- test/core/fling/fling_test.cc | 12 +- test/core/fling/server.cc | 12 +- test/core/gpr/BUILD | 10 -- test/core/gprpp/BUILD | 23 +++ test/core/{gpr => gprpp}/host_port_test.cc | 11 +- test/core/gprpp/string_view_test.cc | 163 ++++++++++++++++++ test/core/memory_usage/memory_usage_test.cc | 11 +- test/core/memory_usage/server.cc | 12 +- ...num_external_connectivity_watchers_test.cc | 21 +-- .../surface/sequential_connectivity_test.cc | 11 +- test/core/surface/server_chttp2_test.cc | 12 +- test/core/surface/server_test.cc | 14 +- test/core/util/reconnect_server.cc | 1 - test/core/util/test_tcp_server.cc | 1 - test/cpp/interop/interop_test.cc | 1 - test/cpp/naming/address_sorting_test.cc | 18 +- test/cpp/naming/cancel_ares_query_test.cc | 1 - test/cpp/naming/resolver_component_test.cc | 16 +- test/cpp/qps/client_sync.cc | 1 - test/cpp/qps/driver.cc | 22 +-- test/cpp/qps/qps_worker.cc | 9 +- test/cpp/qps/server_async.cc | 9 +- test/cpp/qps/server_callback.cc | 9 +- test/cpp/qps/server_sync.cc | 9 +- tools/doxygen/Doxyfile.c++.internal | 3 +- tools/doxygen/Doxyfile.core.internal | 5 +- .../generated/sources_and_headers.json | 28 ++- tools/run_tests/generated/tests.json | 24 +++ 117 files changed, 1277 insertions(+), 879 deletions(-) delete mode 100644 src/core/lib/gpr/host_port.cc create mode 100644 src/core/lib/gprpp/host_port.cc rename src/core/lib/{gpr => gprpp}/host_port.h (51%) create mode 100644 src/core/lib/gprpp/string_view.h rename test/core/{gpr => gprpp}/host_port_test.cc (86%) create mode 100644 test/core/gprpp/string_view_test.cc diff --git a/BUILD b/BUILD index 8fd52808400..821c3824948 100644 --- a/BUILD +++ b/BUILD @@ -558,7 +558,6 @@ grpc_cc_library( "src/core/lib/gpr/env_linux.cc", "src/core/lib/gpr/env_posix.cc", "src/core/lib/gpr/env_windows.cc", - "src/core/lib/gpr/host_port.cc", "src/core/lib/gpr/log.cc", "src/core/lib/gpr/log_android.cc", "src/core/lib/gpr/log_linux.cc", @@ -585,6 +584,7 @@ grpc_cc_library( "src/core/lib/gprpp/arena.cc", "src/core/lib/gprpp/fork.cc", "src/core/lib/gprpp/global_config_env.cc", + "src/core/lib/gprpp/host_port.cc", "src/core/lib/gprpp/thd_posix.cc", "src/core/lib/gprpp/thd_windows.cc", "src/core/lib/profiling/basic_timers.cc", @@ -594,7 +594,6 @@ grpc_cc_library( "src/core/lib/gpr/alloc.h", "src/core/lib/gpr/arena.h", "src/core/lib/gpr/env.h", - "src/core/lib/gpr/host_port.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", "src/core/lib/gpr/spinlock.h", @@ -611,14 +610,16 @@ grpc_cc_library( "src/core/lib/gprpp/arena.h", "src/core/lib/gprpp/atomic.h", "src/core/lib/gprpp/fork.h", + "src/core/lib/gprpp/global_config.h", "src/core/lib/gprpp/global_config_custom.h", "src/core/lib/gprpp/global_config_env.h", "src/core/lib/gprpp/global_config_generic.h", - "src/core/lib/gprpp/global_config.h", + "src/core/lib/gprpp/host_port.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", "src/core/lib/gprpp/pair.h", + "src/core/lib/gprpp/string_view.h", "src/core/lib/gprpp/sync.h", "src/core/lib/gprpp/thd.h", "src/core/lib/profiling/timers.h", @@ -627,6 +628,7 @@ grpc_cc_library( public_hdrs = GPR_PUBLIC_HDRS, deps = [ "gpr_codegen", + "grpc_codegen", ], ) diff --git a/BUILD.gn b/BUILD.gn index e5396f51426..9ae5b1ed22b 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -141,8 +141,6 @@ config("grpc_config") { "src/core/lib/gpr/env_linux.cc", "src/core/lib/gpr/env_posix.cc", "src/core/lib/gpr/env_windows.cc", - "src/core/lib/gpr/host_port.cc", - "src/core/lib/gpr/host_port.h", "src/core/lib/gpr/log.cc", "src/core/lib/gpr/log_android.cc", "src/core/lib/gpr/log_linux.cc", @@ -189,6 +187,8 @@ config("grpc_config") { "src/core/lib/gprpp/global_config_env.cc", "src/core/lib/gprpp/global_config_env.h", "src/core/lib/gprpp/global_config_generic.h", + "src/core/lib/gprpp/host_port.cc", + "src/core/lib/gprpp/host_port.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", @@ -480,6 +480,7 @@ config("grpc_config") { "src/core/lib/gprpp/orphanable.h", "src/core/lib/gprpp/ref_counted.h", "src/core/lib/gprpp/ref_counted_ptr.h", + "src/core/lib/gprpp/string_view.h", "src/core/lib/http/format_request.cc", "src/core/lib/http/format_request.h", "src/core/lib/http/httpcli.cc", @@ -1171,7 +1172,6 @@ config("grpc_config") { "src/core/lib/gpr/alloc.h", "src/core/lib/gpr/arena.h", "src/core/lib/gpr/env.h", - "src/core/lib/gpr/host_port.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", "src/core/lib/gpr/spinlock.h", @@ -1193,6 +1193,7 @@ config("grpc_config") { "src/core/lib/gprpp/global_config_custom.h", "src/core/lib/gprpp/global_config_env.h", "src/core/lib/gprpp/global_config_generic.h", + "src/core/lib/gprpp/host_port.h", "src/core/lib/gprpp/inlined_vector.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", @@ -1202,6 +1203,7 @@ config("grpc_config") { "src/core/lib/gprpp/pair.h", "src/core/lib/gprpp/ref_counted.h", "src/core/lib/gprpp/ref_counted_ptr.h", + "src/core/lib/gprpp/string_view.h", "src/core/lib/gprpp/sync.h", "src/core/lib/gprpp/thd.h", "src/core/lib/http/format_request.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 77a50d5ba46..0d33bca0a90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -713,6 +713,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx streaming_throughput_test) endif() add_dependencies(buildtests_cxx stress_test) +add_dependencies(buildtests_cxx string_view_test) add_dependencies(buildtests_cxx thread_manager_test) add_dependencies(buildtests_cxx thread_stress_test) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) @@ -860,7 +861,6 @@ add_library(gpr src/core/lib/gpr/env_linux.cc src/core/lib/gpr/env_posix.cc src/core/lib/gpr/env_windows.cc - src/core/lib/gpr/host_port.cc src/core/lib/gpr/log.cc src/core/lib/gpr/log_android.cc src/core/lib/gpr/log_linux.cc @@ -887,6 +887,7 @@ add_library(gpr src/core/lib/gprpp/arena.cc src/core/lib/gprpp/fork.cc src/core/lib/gprpp/global_config_env.cc + src/core/lib/gprpp/host_port.cc src/core/lib/gprpp/thd_posix.cc src/core/lib/gprpp/thd_windows.cc src/core/lib/profiling/basic_timers.cc @@ -7505,7 +7506,7 @@ endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(gpr_host_port_test - test/core/gpr/host_port_test.cc + test/core/gprpp/host_port_test.cc ) @@ -16638,6 +16639,45 @@ target_link_libraries(stress_test ) +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + +add_executable(string_view_test + test/core/gprpp/string_view_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(string_view_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(string_view_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + grpc++ + grpc + gpr + ${_gRPC_GFLAGS_LIBRARIES} +) + + endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index 0251d0f4f8e..02c57243cac 100644 --- a/Makefile +++ b/Makefile @@ -1278,6 +1278,7 @@ status_metadata_test: $(BINDIR)/$(CONFIG)/status_metadata_test status_util_test: $(BINDIR)/$(CONFIG)/status_util_test streaming_throughput_test: $(BINDIR)/$(CONFIG)/streaming_throughput_test stress_test: $(BINDIR)/$(CONFIG)/stress_test +string_view_test: $(BINDIR)/$(CONFIG)/string_view_test thread_manager_test: $(BINDIR)/$(CONFIG)/thread_manager_test thread_stress_test: $(BINDIR)/$(CONFIG)/thread_stress_test time_change_test: $(BINDIR)/$(CONFIG)/time_change_test @@ -1743,6 +1744,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/status_util_test \ $(BINDIR)/$(CONFIG)/streaming_throughput_test \ $(BINDIR)/$(CONFIG)/stress_test \ + $(BINDIR)/$(CONFIG)/string_view_test \ $(BINDIR)/$(CONFIG)/thread_manager_test \ $(BINDIR)/$(CONFIG)/thread_stress_test \ $(BINDIR)/$(CONFIG)/time_change_test \ @@ -1905,6 +1907,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/status_util_test \ $(BINDIR)/$(CONFIG)/streaming_throughput_test \ $(BINDIR)/$(CONFIG)/stress_test \ + $(BINDIR)/$(CONFIG)/string_view_test \ $(BINDIR)/$(CONFIG)/thread_manager_test \ $(BINDIR)/$(CONFIG)/thread_stress_test \ $(BINDIR)/$(CONFIG)/time_change_test \ @@ -2430,6 +2433,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/status_util_test || ( echo test status_util_test failed ; exit 1 ) $(E) "[RUN] Testing streaming_throughput_test" $(Q) $(BINDIR)/$(CONFIG)/streaming_throughput_test || ( echo test streaming_throughput_test failed ; exit 1 ) + $(E) "[RUN] Testing string_view_test" + $(Q) $(BINDIR)/$(CONFIG)/string_view_test || ( echo test string_view_test failed ; exit 1 ) $(E) "[RUN] Testing thread_manager_test" $(Q) $(BINDIR)/$(CONFIG)/thread_manager_test || ( echo test thread_manager_test failed ; exit 1 ) $(E) "[RUN] Testing thread_stress_test" @@ -3374,7 +3379,6 @@ LIBGPR_SRC = \ src/core/lib/gpr/env_linux.cc \ src/core/lib/gpr/env_posix.cc \ src/core/lib/gpr/env_windows.cc \ - src/core/lib/gpr/host_port.cc \ src/core/lib/gpr/log.cc \ src/core/lib/gpr/log_android.cc \ src/core/lib/gpr/log_linux.cc \ @@ -3401,6 +3405,7 @@ LIBGPR_SRC = \ src/core/lib/gprpp/arena.cc \ src/core/lib/gprpp/fork.cc \ src/core/lib/gprpp/global_config_env.cc \ + src/core/lib/gprpp/host_port.cc \ src/core/lib/gprpp/thd_posix.cc \ src/core/lib/gprpp/thd_windows.cc \ src/core/lib/profiling/basic_timers.cc \ @@ -10213,7 +10218,7 @@ endif GPR_HOST_PORT_TEST_SRC = \ - test/core/gpr/host_port_test.cc \ + test/core/gprpp/host_port_test.cc \ GPR_HOST_PORT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_HOST_PORT_TEST_SRC)))) ifeq ($(NO_SECURE),true) @@ -10233,7 +10238,7 @@ $(BINDIR)/$(CONFIG)/gpr_host_port_test: $(GPR_HOST_PORT_TEST_OBJS) $(LIBDIR)/$(C endif -$(OBJDIR)/$(CONFIG)/test/core/gpr/host_port_test.o: $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a +$(OBJDIR)/$(CONFIG)/test/core/gprpp/host_port_test.o: $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a deps_gpr_host_port_test: $(GPR_HOST_PORT_TEST_OBJS:.o=.dep) @@ -19661,6 +19666,49 @@ $(OBJDIR)/$(CONFIG)/test/cpp/interop/stress_test.o: $(GENDIR)/src/proto/grpc/tes $(OBJDIR)/$(CONFIG)/test/cpp/util/metrics_server.o: $(GENDIR)/src/proto/grpc/testing/empty.pb.cc $(GENDIR)/src/proto/grpc/testing/empty.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/metrics.pb.cc $(GENDIR)/src/proto/grpc/testing/metrics.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/test.pb.cc $(GENDIR)/src/proto/grpc/testing/test.grpc.pb.cc +STRING_VIEW_TEST_SRC = \ + test/core/gprpp/string_view_test.cc \ + +STRING_VIEW_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(STRING_VIEW_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/string_view_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/string_view_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/string_view_test: $(PROTOBUF_DEP) $(STRING_VIEW_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(STRING_VIEW_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/string_view_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/core/gprpp/string_view_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_string_view_test: $(STRING_VIEW_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(STRING_VIEW_TEST_OBJS:.o=.dep) +endif +endif + + THREAD_MANAGER_TEST_SRC = \ test/cpp/thread_manager/thread_manager_test.cc \ diff --git a/build.yaml b/build.yaml index dad2146bd1c..41c32396a42 100644 --- a/build.yaml +++ b/build.yaml @@ -122,7 +122,6 @@ filegroups: - src/core/lib/gpr/env_linux.cc - src/core/lib/gpr/env_posix.cc - src/core/lib/gpr/env_windows.cc - - src/core/lib/gpr/host_port.cc - src/core/lib/gpr/log.cc - src/core/lib/gpr/log_android.cc - src/core/lib/gpr/log_linux.cc @@ -149,6 +148,7 @@ filegroups: - src/core/lib/gprpp/arena.cc - src/core/lib/gprpp/fork.cc - src/core/lib/gprpp/global_config_env.cc + - src/core/lib/gprpp/host_port.cc - src/core/lib/gprpp/thd_posix.cc - src/core/lib/gprpp/thd_windows.cc - src/core/lib/profiling/basic_timers.cc @@ -178,7 +178,6 @@ filegroups: - src/core/lib/gpr/alloc.h - src/core/lib/gpr/arena.h - src/core/lib/gpr/env.h - - src/core/lib/gpr/host_port.h - src/core/lib/gpr/mpscq.h - src/core/lib/gpr/murmur_hash.h - src/core/lib/gpr/spinlock.h @@ -199,6 +198,7 @@ filegroups: - src/core/lib/gprpp/global_config_custom.h - src/core/lib/gprpp/global_config_env.h - src/core/lib/gprpp/global_config_generic.h + - src/core/lib/gprpp/host_port.h - src/core/lib/gprpp/manual_constructor.h - src/core/lib/gprpp/map.h - src/core/lib/gprpp/memory.h @@ -444,6 +444,7 @@ filegroups: - src/core/lib/gprpp/orphanable.h - src/core/lib/gprpp/ref_counted.h - src/core/lib/gprpp/ref_counted_ptr.h + - src/core/lib/gprpp/string_view.h - src/core/lib/http/format_request.h - src/core/lib/http/httpcli.h - src/core/lib/http/parser.h @@ -2625,7 +2626,7 @@ targets: build: test language: c src: - - test/core/gpr/host_port_test.cc + - test/core/gprpp/host_port_test.cc deps: - gpr - grpc_test_util_unsecure @@ -5760,6 +5761,19 @@ targets: - grpc - gpr - grpc++_test_config +- name: string_view_test + gtest: true + build: test + language: c++ + src: + - test/core/gprpp/string_view_test.cc + deps: + - grpc_test_util + - grpc++ + - grpc + - gpr + uses: + - grpc++_test - name: thread_manager_test build: test language: c++ diff --git a/config.m4 b/config.m4 index bb30be56910..99d49d391b4 100644 --- a/config.m4 +++ b/config.m4 @@ -53,7 +53,6 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/gpr/env_linux.cc \ src/core/lib/gpr/env_posix.cc \ src/core/lib/gpr/env_windows.cc \ - src/core/lib/gpr/host_port.cc \ src/core/lib/gpr/log.cc \ src/core/lib/gpr/log_android.cc \ src/core/lib/gpr/log_linux.cc \ @@ -80,6 +79,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/gprpp/arena.cc \ src/core/lib/gprpp/fork.cc \ src/core/lib/gprpp/global_config_env.cc \ + src/core/lib/gprpp/host_port.cc \ src/core/lib/gprpp/thd_posix.cc \ src/core/lib/gprpp/thd_windows.cc \ src/core/lib/profiling/basic_timers.cc \ diff --git a/config.w32 b/config.w32 index c9faa8d9ac8..f6c6b4fde10 100644 --- a/config.w32 +++ b/config.w32 @@ -28,7 +28,6 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\gpr\\env_linux.cc " + "src\\core\\lib\\gpr\\env_posix.cc " + "src\\core\\lib\\gpr\\env_windows.cc " + - "src\\core\\lib\\gpr\\host_port.cc " + "src\\core\\lib\\gpr\\log.cc " + "src\\core\\lib\\gpr\\log_android.cc " + "src\\core\\lib\\gpr\\log_linux.cc " + @@ -55,6 +54,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\gprpp\\arena.cc " + "src\\core\\lib\\gprpp\\fork.cc " + "src\\core\\lib\\gprpp\\global_config_env.cc " + + "src\\core\\lib\\gprpp\\host_port.cc " + "src\\core\\lib\\gprpp\\thd_posix.cc " + "src\\core\\lib\\gprpp\\thd_windows.cc " + "src\\core\\lib\\profiling\\basic_timers.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index f0a4418b20c..17b44738cc2 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -261,7 +261,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/alloc.h', 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', - 'src/core/lib/gpr/host_port.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', 'src/core/lib/gpr/spinlock.h', @@ -282,6 +281,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/global_config_custom.h', 'src/core/lib/gprpp/global_config_env.h', 'src/core/lib/gprpp/global_config_generic.h', + 'src/core/lib/gprpp/host_port.h', 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', @@ -444,6 +444,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/orphanable.h', 'src/core/lib/gprpp/ref_counted.h', 'src/core/lib/gprpp/ref_counted_ptr.h', + 'src/core/lib/gprpp/string_view.h', 'src/core/lib/http/format_request.h', 'src/core/lib/http/httpcli.h', 'src/core/lib/http/parser.h', @@ -591,7 +592,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/alloc.h', 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', - 'src/core/lib/gpr/host_port.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', 'src/core/lib/gpr/spinlock.h', @@ -612,6 +612,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/global_config_custom.h', 'src/core/lib/gprpp/global_config_env.h', 'src/core/lib/gprpp/global_config_generic.h', + 'src/core/lib/gprpp/host_port.h', 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', @@ -648,6 +649,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/orphanable.h', 'src/core/lib/gprpp/ref_counted.h', 'src/core/lib/gprpp/ref_counted_ptr.h', + 'src/core/lib/gprpp/string_view.h', 'src/core/lib/http/format_request.h', 'src/core/lib/http/httpcli.h', 'src/core/lib/http/parser.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 2e34e8d7573..6255fdfd0ce 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -191,7 +191,6 @@ Pod::Spec.new do |s| ss.source_files = 'src/core/lib/gpr/alloc.h', 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', - 'src/core/lib/gpr/host_port.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', 'src/core/lib/gpr/spinlock.h', @@ -212,6 +211,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/global_config_custom.h', 'src/core/lib/gprpp/global_config_env.h', 'src/core/lib/gprpp/global_config_generic.h', + 'src/core/lib/gprpp/host_port.h', 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', @@ -228,7 +228,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/env_linux.cc', 'src/core/lib/gpr/env_posix.cc', 'src/core/lib/gpr/env_windows.cc', - 'src/core/lib/gpr/host_port.cc', 'src/core/lib/gpr/log.cc', 'src/core/lib/gpr/log_android.cc', 'src/core/lib/gpr/log_linux.cc', @@ -255,6 +254,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/arena.cc', 'src/core/lib/gprpp/fork.cc', 'src/core/lib/gprpp/global_config_env.cc', + 'src/core/lib/gprpp/host_port.cc', 'src/core/lib/gprpp/thd_posix.cc', 'src/core/lib/gprpp/thd_windows.cc', 'src/core/lib/profiling/basic_timers.cc', @@ -414,6 +414,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/orphanable.h', 'src/core/lib/gprpp/ref_counted.h', 'src/core/lib/gprpp/ref_counted_ptr.h', + 'src/core/lib/gprpp/string_view.h', 'src/core/lib/http/format_request.h', 'src/core/lib/http/httpcli.h', 'src/core/lib/http/parser.h', @@ -884,7 +885,6 @@ Pod::Spec.new do |s| ss.private_header_files = 'src/core/lib/gpr/alloc.h', 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', - 'src/core/lib/gpr/host_port.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', 'src/core/lib/gpr/spinlock.h', @@ -905,6 +905,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/global_config_custom.h', 'src/core/lib/gprpp/global_config_env.h', 'src/core/lib/gprpp/global_config_generic.h', + 'src/core/lib/gprpp/host_port.h', 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', @@ -1067,6 +1068,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/orphanable.h', 'src/core/lib/gprpp/ref_counted.h', 'src/core/lib/gprpp/ref_counted_ptr.h', + 'src/core/lib/gprpp/string_view.h', 'src/core/lib/http/format_request.h', 'src/core/lib/http/httpcli.h', 'src/core/lib/http/parser.h', diff --git a/grpc.gemspec b/grpc.gemspec index 11469a3ec5c..a1051fd4685 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -85,7 +85,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/alloc.h ) s.files += %w( src/core/lib/gpr/arena.h ) s.files += %w( src/core/lib/gpr/env.h ) - s.files += %w( src/core/lib/gpr/host_port.h ) s.files += %w( src/core/lib/gpr/mpscq.h ) s.files += %w( src/core/lib/gpr/murmur_hash.h ) s.files += %w( src/core/lib/gpr/spinlock.h ) @@ -106,6 +105,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gprpp/global_config_custom.h ) s.files += %w( src/core/lib/gprpp/global_config_env.h ) s.files += %w( src/core/lib/gprpp/global_config_generic.h ) + s.files += %w( src/core/lib/gprpp/host_port.h ) s.files += %w( src/core/lib/gprpp/manual_constructor.h ) s.files += %w( src/core/lib/gprpp/map.h ) s.files += %w( src/core/lib/gprpp/memory.h ) @@ -122,7 +122,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/env_linux.cc ) s.files += %w( src/core/lib/gpr/env_posix.cc ) s.files += %w( src/core/lib/gpr/env_windows.cc ) - s.files += %w( src/core/lib/gpr/host_port.cc ) s.files += %w( src/core/lib/gpr/log.cc ) s.files += %w( src/core/lib/gpr/log_android.cc ) s.files += %w( src/core/lib/gpr/log_linux.cc ) @@ -149,6 +148,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gprpp/arena.cc ) s.files += %w( src/core/lib/gprpp/fork.cc ) s.files += %w( src/core/lib/gprpp/global_config_env.cc ) + s.files += %w( src/core/lib/gprpp/host_port.cc ) s.files += %w( src/core/lib/gprpp/thd_posix.cc ) s.files += %w( src/core/lib/gprpp/thd_windows.cc ) s.files += %w( src/core/lib/profiling/basic_timers.cc ) @@ -348,6 +348,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gprpp/orphanable.h ) s.files += %w( src/core/lib/gprpp/ref_counted.h ) s.files += %w( src/core/lib/gprpp/ref_counted_ptr.h ) + s.files += %w( src/core/lib/gprpp/string_view.h ) s.files += %w( src/core/lib/http/format_request.h ) s.files += %w( src/core/lib/http/httpcli.h ) s.files += %w( src/core/lib/http/parser.h ) diff --git a/grpc.gyp b/grpc.gyp index 6268bed7bb0..784279301d3 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -226,7 +226,6 @@ 'src/core/lib/gpr/env_linux.cc', 'src/core/lib/gpr/env_posix.cc', 'src/core/lib/gpr/env_windows.cc', - 'src/core/lib/gpr/host_port.cc', 'src/core/lib/gpr/log.cc', 'src/core/lib/gpr/log_android.cc', 'src/core/lib/gpr/log_linux.cc', @@ -253,6 +252,7 @@ 'src/core/lib/gprpp/arena.cc', 'src/core/lib/gprpp/fork.cc', 'src/core/lib/gprpp/global_config_env.cc', + 'src/core/lib/gprpp/host_port.cc', 'src/core/lib/gprpp/thd_posix.cc', 'src/core/lib/gprpp/thd_windows.cc', 'src/core/lib/profiling/basic_timers.cc', diff --git a/package.xml b/package.xml index 616e1ece20e..388e8d8620a 100644 --- a/package.xml +++ b/package.xml @@ -90,7 +90,6 @@ - @@ -111,6 +110,7 @@ + @@ -127,7 +127,6 @@ - @@ -154,6 +153,7 @@ + @@ -353,6 +353,7 @@ + diff --git a/src/core/ext/filters/client_channel/http_proxy.cc b/src/core/ext/filters/client_channel/http_proxy.cc index 8951a2920c4..9e60a553ceb 100644 --- a/src/core/ext/filters/client_channel/http_proxy.cc +++ b/src/core/ext/filters/client_channel/http_proxy.cc @@ -31,8 +31,8 @@ #include "src/core/ext/filters/client_channel/proxy_mapper_registry.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/env.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/slice/b64.h" #include "src/core/lib/uri/uri_parser.h" @@ -126,17 +126,18 @@ static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper, if (no_proxy_str != nullptr) { static const char* NO_PROXY_SEPARATOR = ","; bool use_proxy = true; - char* server_host; - char* server_port; - if (!gpr_split_host_port(uri->path[0] == '/' ? uri->path + 1 : uri->path, - &server_host, &server_port)) { + grpc_core::UniquePtr server_host; + grpc_core::UniquePtr server_port; + if (!grpc_core::SplitHostPort( + uri->path[0] == '/' ? uri->path + 1 : uri->path, &server_host, + &server_port)) { gpr_log(GPR_INFO, "unable to split host and port, not checking no_proxy list for " "host '%s'", server_uri); gpr_free(no_proxy_str); } else { - size_t uri_len = strlen(server_host); + size_t uri_len = strlen(server_host.get()); char** no_proxy_hosts; size_t num_no_proxy_hosts; gpr_string_split(no_proxy_str, NO_PROXY_SEPARATOR, &no_proxy_hosts, @@ -145,8 +146,8 @@ static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper, char* no_proxy_entry = no_proxy_hosts[i]; size_t no_proxy_len = strlen(no_proxy_entry); if (no_proxy_len <= uri_len && - gpr_stricmp(no_proxy_entry, &server_host[uri_len - no_proxy_len]) == - 0) { + gpr_stricmp(no_proxy_entry, + &(server_host.get()[uri_len - no_proxy_len])) == 0) { gpr_log(GPR_INFO, "not using proxy for host in no_proxy list '%s'", server_uri); use_proxy = false; @@ -157,8 +158,6 @@ static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper, gpr_free(no_proxy_hosts[i]); } gpr_free(no_proxy_hosts); - gpr_free(server_host); - gpr_free(server_port); gpr_free(no_proxy_str); if (!use_proxy) goto no_use_proxy; } diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 2f3516066da..71e8e248770 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -84,7 +84,6 @@ #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/gprpp/memory.h" diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index e5c27fe67a4..ca9ea9e31cc 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -84,7 +84,6 @@ #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/gprpp/map.h" diff --git a/src/core/ext/filters/client_channel/parse_address.cc b/src/core/ext/filters/client_channel/parse_address.cc index c5e1ed811bc..fbfbb4445f3 100644 --- a/src/core/ext/filters/client_channel/parse_address.cc +++ b/src/core/ext/filters/client_channel/parse_address.cc @@ -33,8 +33,8 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #ifdef GRPC_POSIX_SOCKET #include @@ -73,9 +73,9 @@ bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr, bool log_errors) { bool success = false; // Split host and port. - char* host; - char* port; - if (!gpr_split_host_port(hostport, &host, &port)) { + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; + if (!grpc_core::SplitHostPort(hostport, &host, &port)) { if (log_errors) { gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)", hostport); } @@ -86,8 +86,10 @@ bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr, addr->len = static_cast(sizeof(grpc_sockaddr_in)); grpc_sockaddr_in* in = reinterpret_cast(addr->addr); in->sin_family = GRPC_AF_INET; - if (grpc_inet_pton(GRPC_AF_INET, host, &in->sin_addr) == 0) { - if (log_errors) gpr_log(GPR_ERROR, "invalid ipv4 address: '%s'", host); + if (grpc_inet_pton(GRPC_AF_INET, host.get(), &in->sin_addr) == 0) { + if (log_errors) { + gpr_log(GPR_ERROR, "invalid ipv4 address: '%s'", host.get()); + } goto done; } // Parse port. @@ -96,15 +98,14 @@ bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr, goto done; } int port_num; - if (sscanf(port, "%d", &port_num) != 1 || port_num < 0 || port_num > 65535) { - if (log_errors) gpr_log(GPR_ERROR, "invalid ipv4 port: '%s'", port); + if (sscanf(port.get(), "%d", &port_num) != 1 || port_num < 0 || + port_num > 65535) { + if (log_errors) gpr_log(GPR_ERROR, "invalid ipv4 port: '%s'", port.get()); goto done; } in->sin_port = grpc_htons(static_cast(port_num)); success = true; done: - gpr_free(host); - gpr_free(port); return success; } @@ -124,9 +125,9 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, bool log_errors) { bool success = false; // Split host and port. - char* host; - char* port; - if (!gpr_split_host_port(hostport, &host, &port)) { + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; + if (!grpc_core::SplitHostPort(hostport, &host, &port)) { if (log_errors) { gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)", hostport); } @@ -138,11 +139,12 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, grpc_sockaddr_in6* in6 = reinterpret_cast(addr->addr); in6->sin6_family = GRPC_AF_INET6; // Handle the RFC6874 syntax for IPv6 zone identifiers. - char* host_end = static_cast(gpr_memrchr(host, '%', strlen(host))); + char* host_end = + static_cast(gpr_memrchr(host.get(), '%', strlen(host.get()))); if (host_end != nullptr) { - GPR_ASSERT(host_end >= host); + GPR_ASSERT(host_end >= host.get()); char host_without_scope[GRPC_INET6_ADDRSTRLEN + 1]; - size_t host_without_scope_len = static_cast(host_end - host); + size_t host_without_scope_len = static_cast(host_end - host.get()); uint32_t sin6_scope_id = 0; if (host_without_scope_len > GRPC_INET6_ADDRSTRLEN) { if (log_errors) { @@ -154,7 +156,7 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, } goto done; } - strncpy(host_without_scope, host, host_without_scope_len); + strncpy(host_without_scope, host.get(), host_without_scope_len); host_without_scope[host_without_scope_len] = '\0'; if (grpc_inet_pton(GRPC_AF_INET6, host_without_scope, &in6->sin6_addr) == 0) { @@ -163,9 +165,9 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, } goto done; } - if (gpr_parse_bytes_to_uint32(host_end + 1, - strlen(host) - host_without_scope_len - 1, - &sin6_scope_id) == 0) { + if (gpr_parse_bytes_to_uint32( + host_end + 1, strlen(host.get()) - host_without_scope_len - 1, + &sin6_scope_id) == 0) { if ((sin6_scope_id = grpc_if_nametoindex(host_end + 1)) == 0) { gpr_log(GPR_ERROR, "Invalid interface name: '%s'. " @@ -177,8 +179,10 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, // Handle "sin6_scope_id" being type "u_long". See grpc issue #10027. in6->sin6_scope_id = sin6_scope_id; } else { - if (grpc_inet_pton(GRPC_AF_INET6, host, &in6->sin6_addr) == 0) { - if (log_errors) gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host); + if (grpc_inet_pton(GRPC_AF_INET6, host.get(), &in6->sin6_addr) == 0) { + if (log_errors) { + gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host.get()); + } goto done; } } @@ -188,15 +192,14 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, goto done; } int port_num; - if (sscanf(port, "%d", &port_num) != 1 || port_num < 0 || port_num > 65535) { - if (log_errors) gpr_log(GPR_ERROR, "invalid ipv6 port: '%s'", port); + if (sscanf(port.get(), "%d", &port_num) != 1 || port_num < 0 || + port_num > 65535) { + if (log_errors) gpr_log(GPR_ERROR, "invalid ipv6 port: '%s'", port.get()); goto done; } in6->sin6_port = grpc_htons(static_cast(port_num)); success = true; done: - gpr_free(host); - gpr_free(port); return success; } diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index 32a339af359..ff15704d692 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -38,7 +38,6 @@ #include "src/core/ext/filters/client_channel/service_config.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/combiner.h" diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc index ad0f1460121..0c1a8ba828f 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc @@ -35,8 +35,8 @@ #include #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/executor.h" @@ -355,9 +355,9 @@ void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked( grpc_ares_hostbyname_request* hr = nullptr; ares_channel* channel = nullptr; /* parse name, splitting it into host and port parts */ - char* host; - char* port; - gpr_split_host_port(name, &host, &port); + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; + grpc_core::SplitHostPort(name, &host, &port); if (host == nullptr) { error = grpc_error_set_str( GRPC_ERROR_CREATE_FROM_STATIC_STRING("unparseable host:port"), @@ -370,7 +370,7 @@ void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked( GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(name)); goto error_cleanup; } - port = gpr_strdup(default_port); + port.reset(gpr_strdup(default_port)); } error = grpc_ares_ev_driver_create_locked(&r->ev_driver, interested_parties, query_timeout_ms, combiner, r); @@ -414,20 +414,22 @@ void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked( } r->pending_queries = 1; if (grpc_ares_query_ipv6()) { - hr = create_hostbyname_request_locked(r, host, grpc_strhtons(port), - false /* is_balancer */); + hr = create_hostbyname_request_locked(r, host.get(), + grpc_strhtons(port.get()), + /*is_balancer=*/false); ares_gethostbyname(*channel, hr->host, AF_INET6, on_hostbyname_done_locked, hr); } - hr = create_hostbyname_request_locked(r, host, grpc_strhtons(port), - false /* is_balancer */); + hr = + create_hostbyname_request_locked(r, host.get(), grpc_strhtons(port.get()), + /*is_balancer=*/false); ares_gethostbyname(*channel, hr->host, AF_INET, on_hostbyname_done_locked, hr); if (check_grpclb) { /* Query the SRV record */ grpc_ares_request_ref_locked(r); char* service_name; - gpr_asprintf(&service_name, "_grpclb._tcp.%s", host); + gpr_asprintf(&service_name, "_grpclb._tcp.%s", host.get()); ares_query(*channel, service_name, ns_c_in, ns_t_srv, on_srv_query_done_locked, r); gpr_free(service_name); @@ -435,28 +437,25 @@ void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked( if (r->service_config_json_out != nullptr) { grpc_ares_request_ref_locked(r); char* config_name; - gpr_asprintf(&config_name, "_grpc_config.%s", host); + gpr_asprintf(&config_name, "_grpc_config.%s", host.get()); ares_search(*channel, config_name, ns_c_in, ns_t_txt, on_txt_done_locked, r); gpr_free(config_name); } grpc_ares_ev_driver_start_locked(r->ev_driver); grpc_ares_request_unref_locked(r); - gpr_free(host); - gpr_free(port); return; error_cleanup: GRPC_CLOSURE_SCHED(r->on_done, error); - gpr_free(host); - gpr_free(port); } static bool inner_resolve_as_ip_literal_locked( const char* name, const char* default_port, - grpc_core::UniquePtr* addrs, char** host, - char** port, char** hostport) { - gpr_split_host_port(name, host, port); + grpc_core::UniquePtr* addrs, + grpc_core::UniquePtr* host, grpc_core::UniquePtr* port, + grpc_core::UniquePtr* hostport) { + grpc_core::SplitHostPort(name, host, port); if (*host == nullptr) { gpr_log(GPR_ERROR, "Failed to parse %s to host:port while attempting to resolve as ip " @@ -472,12 +471,14 @@ static bool inner_resolve_as_ip_literal_locked( name); return false; } - *port = gpr_strdup(default_port); + port->reset(gpr_strdup(default_port)); } grpc_resolved_address addr; - GPR_ASSERT(gpr_join_host_port(hostport, *host, atoi(*port))); - if (grpc_parse_ipv4_hostport(*hostport, &addr, false /* log errors */) || - grpc_parse_ipv6_hostport(*hostport, &addr, false /* log errors */)) { + GPR_ASSERT(grpc_core::JoinHostPort(hostport, host->get(), atoi(port->get()))); + if (grpc_parse_ipv4_hostport(hostport->get(), &addr, + false /* log errors */) || + grpc_parse_ipv6_hostport(hostport->get(), &addr, + false /* log errors */)) { GPR_ASSERT(*addrs == nullptr); *addrs = grpc_core::MakeUnique(); (*addrs)->emplace_back(addr.addr, addr.len, nullptr /* args */); @@ -489,24 +490,22 @@ static bool inner_resolve_as_ip_literal_locked( static bool resolve_as_ip_literal_locked( const char* name, const char* default_port, grpc_core::UniquePtr* addrs) { - char* host = nullptr; - char* port = nullptr; - char* hostport = nullptr; + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; + grpc_core::UniquePtr hostport; bool out = inner_resolve_as_ip_literal_locked(name, default_port, addrs, &host, &port, &hostport); - gpr_free(host); - gpr_free(port); - gpr_free(hostport); return out; } -static bool target_matches_localhost_inner(const char* name, char** host, - char** port) { - if (!gpr_split_host_port(name, host, port)) { +static bool target_matches_localhost_inner(const char* name, + grpc_core::UniquePtr* host, + grpc_core::UniquePtr* port) { + if (!grpc_core::SplitHostPort(name, host, port)) { gpr_log(GPR_ERROR, "Unable to split host and port for name: %s", name); return false; } - if (gpr_stricmp(*host, "localhost") == 0) { + if (gpr_stricmp(host->get(), "localhost") == 0) { return true; } else { return false; @@ -514,20 +513,17 @@ static bool target_matches_localhost_inner(const char* name, char** host, } static bool target_matches_localhost(const char* name) { - char* host = nullptr; - char* port = nullptr; - bool out = target_matches_localhost_inner(name, &host, &port); - gpr_free(host); - gpr_free(port); - return out; + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; + return target_matches_localhost_inner(name, &host, &port); } #ifdef GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY static bool inner_maybe_resolve_localhost_manually_locked( const char* name, const char* default_port, - grpc_core::UniquePtr* addrs, char** host, - char** port) { - gpr_split_host_port(name, host, port); + grpc_core::UniquePtr* addrs, + grpc_core::UniquePtr* host, grpc_core::UniquePtr* port) { + grpc_core::SplitHostPort(name, host, port); if (*host == nullptr) { gpr_log(GPR_ERROR, "Failed to parse %s into host:port during manual localhost " @@ -543,12 +539,12 @@ static bool inner_maybe_resolve_localhost_manually_locked( name); return false; } - *port = gpr_strdup(default_port); + port->reset(gpr_strdup(default_port)); } - if (gpr_stricmp(*host, "localhost") == 0) { + if (gpr_stricmp(host->get(), "localhost") == 0) { GPR_ASSERT(*addrs == nullptr); *addrs = grpc_core::MakeUnique(); - uint16_t numeric_port = grpc_strhtons(*port); + uint16_t numeric_port = grpc_strhtons(port->get()); // Append the ipv6 loopback address. struct sockaddr_in6 ipv6_loopback_addr; memset(&ipv6_loopback_addr, 0, sizeof(ipv6_loopback_addr)); @@ -576,13 +572,10 @@ static bool inner_maybe_resolve_localhost_manually_locked( static bool grpc_ares_maybe_resolve_localhost_manually_locked( const char* name, const char* default_port, grpc_core::UniquePtr* addrs) { - char* host = nullptr; - char* port = nullptr; - bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port, - addrs, &host, &port); - gpr_free(host); - gpr_free(port); - return out; + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; + return inner_maybe_resolve_localhost_manually_locked(name, default_port, + addrs, &host, &port); } #else /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ static bool grpc_ares_maybe_resolve_localhost_manually_locked( diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc index f85feb674dd..d9e3293deb6 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc @@ -26,7 +26,6 @@ #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/ext/filters/client_channel/server_address.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" bool grpc_ares_query_ipv6() { diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc index 06cd5722ce3..1749cf77201 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc @@ -26,7 +26,6 @@ #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/ext/filters/client_channel/server_address.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/socket_windows.h" diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc index 5ab75d02793..b8434a1cae4 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc @@ -31,7 +31,6 @@ #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/combiner.h" diff --git a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc index 7f613ee21bc..ff728a3dc43 100644 --- a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc @@ -32,7 +32,6 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/closure.h" diff --git a/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc b/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc index 1465b0c644e..517b9297af4 100644 --- a/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc @@ -30,7 +30,6 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/resolve_address.h" diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc index 8285ee76445..dc60ec2487b 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -37,7 +37,6 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker.h" #include "src/core/lib/channel/handshaker_registry.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/resource_quota.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_data.cc b/src/core/ext/transport/chttp2/transport/frame_data.cc index 74c305b820f..c50d7e48d41 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.cc +++ b/src/core/ext/transport/chttp2/transport/frame_data.cc @@ -137,10 +137,10 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( p->error = grpc_error_set_int(p->error, GRPC_ERROR_INT_STREAM_ID, static_cast(s->id)); gpr_free(msg); - p->error = - grpc_error_set_str(p->error, GRPC_ERROR_STR_RAW_BYTES, - grpc_dump_slice_to_slice( - *slice, GPR_DUMP_HEX | GPR_DUMP_ASCII)); + p->error = grpc_error_set_str( + p->error, GRPC_ERROR_STR_RAW_BYTES, + grpc_slice_from_moved_string(grpc_core::UniquePtr( + grpc_dump_slice(*slice, GPR_DUMP_HEX | GPR_DUMP_ASCII)))); p->error = grpc_error_set_int(p->error, GRPC_ERROR_INT_OFFSET, cur - beg); p->state = GRPC_CHTTP2_DATA_ERROR; diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc index 3ddda268cfb..a5f6571c510 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.cc +++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc @@ -30,7 +30,6 @@ #include "src/core/ext/transport/chttp2/transport/incoming_metadata.h" #include "src/core/ext/transport/cronet/transport/cronet_transport.h" #include "src/core/lib/debug/trace.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/endpoint.h" diff --git a/src/core/lib/channel/channelz.cc b/src/core/lib/channel/channelz.cc index 4b130372e46..184ba17889d 100644 --- a/src/core/lib/channel/channelz.cc +++ b/src/core/lib/channel/channelz.cc @@ -30,9 +30,9 @@ #include "src/core/lib/channel/channelz_registry.h" #include "src/core/lib/channel/status_util.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -406,14 +406,15 @@ void PopulateSocketAddressJson(grpc_json* json, const char* name, (strcmp(uri->scheme, "ipv6") == 0))) { const char* host_port = uri->path; if (*host_port == '/') ++host_port; - char* host = nullptr; - char* port = nullptr; - GPR_ASSERT(gpr_split_host_port(host_port, &host, &port)); + UniquePtr host; + UniquePtr port; + GPR_ASSERT(SplitHostPort(host_port, &host, &port)); int port_num = -1; if (port != nullptr) { - port_num = atoi(port); + port_num = atoi(port.get()); } - char* b64_host = grpc_base64_encode(host, strlen(host), false, false); + char* b64_host = + grpc_base64_encode(host.get(), strlen(host.get()), false, false); json_iterator = grpc_json_create_child(json_iterator, json, "tcpip_address", nullptr, GRPC_JSON_OBJECT, false); json = json_iterator; @@ -422,8 +423,6 @@ void PopulateSocketAddressJson(grpc_json* json, const char* name, "port", port_num); json_iterator = grpc_json_create_child(json_iterator, json, "ip_address", b64_host, GRPC_JSON_STRING, true); - gpr_free(host); - gpr_free(port); } else if (uri != nullptr && strcmp(uri->scheme, "unix") == 0) { json_iterator = grpc_json_create_child(json_iterator, json, "uds_address", nullptr, GRPC_JSON_OBJECT, false); diff --git a/src/core/lib/gpr/host_port.cc b/src/core/lib/gpr/host_port.cc deleted file mode 100644 index a34e01cb516..00000000000 --- a/src/core/lib/gpr/host_port.cc +++ /dev/null @@ -1,98 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/lib/gpr/host_port.h" - -#include - -#include -#include -#include - -#include "src/core/lib/gpr/string.h" - -int gpr_join_host_port(char** out, const char* host, int port) { - if (host[0] != '[' && strchr(host, ':') != nullptr) { - /* IPv6 literals must be enclosed in brackets. */ - return gpr_asprintf(out, "[%s]:%d", host, port); - } else { - /* Ordinary non-bracketed host:port. */ - return gpr_asprintf(out, "%s:%d", host, port); - } -} - -int gpr_split_host_port(const char* name, char** host, char** port) { - const char* host_start; - size_t host_len; - const char* port_start; - - *host = nullptr; - *port = nullptr; - - if (name[0] == '[') { - /* Parse a bracketed host, typically an IPv6 literal. */ - const char* rbracket = strchr(name, ']'); - if (rbracket == nullptr) { - /* Unmatched [ */ - return 0; - } - if (rbracket[1] == '\0') { - /* ] */ - port_start = nullptr; - } else if (rbracket[1] == ':') { - /* ]: */ - port_start = rbracket + 2; - } else { - /* ] */ - return 0; - } - host_start = name + 1; - host_len = static_cast(rbracket - host_start); - if (memchr(host_start, ':', host_len) == nullptr) { - /* Require all bracketed hosts to contain a colon, because a hostname or - IPv4 address should never use brackets. */ - return 0; - } - } else { - const char* colon = strchr(name, ':'); - if (colon != nullptr && strchr(colon + 1, ':') == nullptr) { - /* Exactly 1 colon. Split into host:port. */ - host_start = name; - host_len = static_cast(colon - name); - port_start = colon + 1; - } else { - /* 0 or 2+ colons. Bare hostname or IPv6 litearal. */ - host_start = name; - host_len = strlen(name); - port_start = nullptr; - } - } - - /* Allocate return values. */ - *host = static_cast(gpr_malloc(host_len + 1)); - memcpy(*host, host_start, host_len); - (*host)[host_len] = '\0'; - - if (port_start != nullptr) { - *port = gpr_strdup(port_start); - } - - return 1; -} diff --git a/src/core/lib/gpr/string.cc b/src/core/lib/gpr/string.cc index a39f56ef926..14436ec1bf9 100644 --- a/src/core/lib/gpr/string.cc +++ b/src/core/lib/gpr/string.cc @@ -289,17 +289,22 @@ char* gpr_strvec_flatten(gpr_strvec* sv, size_t* final_length) { return gpr_strjoin((const char**)sv->strs, sv->count, final_length); } -int gpr_stricmp(const char* a, const char* b) { +int gpr_strincmp(const char* a, const char* b, size_t n) { int ca, cb; do { ca = tolower(*a); cb = tolower(*b); ++a; ++b; - } while (ca == cb && ca && cb); + --n; + } while (ca == cb && ca != 0 && cb != 0 && n != 0); return ca - cb; } +int gpr_stricmp(const char* a, const char* b) { + return gpr_strincmp(a, b, SIZE_MAX); +} + static void add_string_to_split(const char* beg, const char* end, char*** strs, size_t* nstrs, size_t* capstrs) { char* out = diff --git a/src/core/lib/gpr/string.h b/src/core/lib/gpr/string.h index bf59db7abfe..fcccf5e6764 100644 --- a/src/core/lib/gpr/string.h +++ b/src/core/lib/gpr/string.h @@ -115,6 +115,7 @@ char* gpr_strvec_flatten(gpr_strvec* strs, size_t* total_length); /** Case insensitive string comparison... return <0 if lower(a)0 if lower(a)>lower(b) */ int gpr_stricmp(const char* a, const char* b); +int gpr_strincmp(const char* a, const char* b, size_t n); void* gpr_memrchr(const void* s, int c, size_t n); diff --git a/src/core/lib/gprpp/host_port.cc b/src/core/lib/gprpp/host_port.cc new file mode 100644 index 00000000000..f3f8a73602a --- /dev/null +++ b/src/core/lib/gprpp/host_port.cc @@ -0,0 +1,97 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/gprpp/host_port.h" + +#include + +#include +#include +#include + +#include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/string_view.h" + +namespace grpc_core { +int JoinHostPort(UniquePtr* out, const char* host, int port) { + char* tmp; + int ret; + if (host[0] != '[' && strchr(host, ':') != nullptr) { + /* IPv6 literals must be enclosed in brackets. */ + ret = gpr_asprintf(&tmp, "[%s]:%d", host, port); + } else { + /* Ordinary non-bracketed host:port. */ + ret = gpr_asprintf(&tmp, "%s:%d", host, port); + } + out->reset(tmp); + return ret; +} + +bool SplitHostPort(StringView name, StringView* host, StringView* port) { + if (name[0] == '[') { + /* Parse a bracketed host, typically an IPv6 literal. */ + const size_t rbracket = name.find(']', 1); + if (rbracket == grpc_core::StringView::npos) { + /* Unmatched [ */ + return false; + } + if (rbracket == name.size() - 1) { + /* ] */ + port->clear(); + } else if (name[rbracket + 1] == ':') { + /* ]: */ + *port = name.substr(rbracket + 2, name.size() - rbracket - 2); + } else { + /* ] */ + return false; + } + *host = name.substr(1, rbracket - 1); + if (host->find(':') == grpc_core::StringView::npos) { + /* Require all bracketed hosts to contain a colon, because a hostname or + IPv4 address should never use brackets. */ + host->clear(); + return false; + } + } else { + size_t colon = name.find(':'); + if (colon != grpc_core::StringView::npos && + name.find(':', colon + 1) == grpc_core::StringView::npos) { + /* Exactly 1 colon. Split into host:port. */ + *host = name.substr(0, colon); + *port = name.substr(colon + 1, name.size() - colon - 1); + } else { + /* 0 or 2+ colons. Bare hostname or IPv6 litearal. */ + *host = name; + port->clear(); + } + } + return true; +} + +bool SplitHostPort(StringView name, UniquePtr* host, + UniquePtr* port) { + StringView host_view; + StringView port_view; + const bool ret = SplitHostPort(name, &host_view, &port_view); + host->reset(host_view.empty() ? nullptr : host_view.dup().release()); + port->reset(port_view.empty() ? nullptr : port_view.dup().release()); + return ret; +} +} // namespace grpc_core diff --git a/src/core/lib/gpr/host_port.h b/src/core/lib/gprpp/host_port.h similarity index 51% rename from src/core/lib/gpr/host_port.h rename to src/core/lib/gprpp/host_port.h index 0bf0960f824..16f1c807580 100644 --- a/src/core/lib/gpr/host_port.h +++ b/src/core/lib/gprpp/host_port.h @@ -16,28 +16,44 @@ * */ -#ifndef GRPC_CORE_LIB_GPR_HOST_PORT_H -#define GRPC_CORE_LIB_GPR_HOST_PORT_H +#ifndef GRPC_CORE_LIB_GPRPP_HOST_PORT_H +#define GRPC_CORE_LIB_GPRPP_HOST_PORT_H #include +#include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/gprpp/string_view.h" + +namespace grpc_core { + /** Given a host and port, creates a newly-allocated string of the form "host:port" or "[ho:st]:port", depending on whether the host contains colons like an IPv6 literal. If the host is already bracketed, then additional brackets will not be added. Usage is similar to gpr_asprintf: returns the number of bytes written - (excluding the final '\0'), and *out points to a string which must later be - destroyed using gpr_free(). + (excluding the final '\0'), and *out points to a string. In the unlikely event of an error, returns -1 and sets *out to NULL. */ -int gpr_join_host_port(char** out, const char* host, int port); +int JoinHostPort(UniquePtr* out, const char* host, int port); /** Given a name in the form "host:port" or "[ho:st]:port", split into hostname - and port number, into newly allocated strings, which must later be - destroyed using gpr_free(). - Return 1 on success, 0 on failure. Guarantees *host and *port == NULL on - failure. */ -int gpr_split_host_port(const char* name, char** host, char** port); + and port number. -#endif /* GRPC_CORE_LIB_GPR_HOST_PORT_H */ + There are two variants of this method: + 1) StringView ouptut: port and host are returned as views on name. + 2) char* output: port and host are copied into newly allocated strings. + + Prefer variant (1) over (2), because no allocation or copy is performed in + variant (1). Use (2) only when interacting with C API that mandate + null-terminated strings. + + Return true on success, false on failure. Guarantees *host and *port are + cleared on failure. */ +bool SplitHostPort(StringView name, StringView* host, StringView* port); +bool SplitHostPort(StringView name, UniquePtr* host, + UniquePtr* port); + +} // namespace grpc_core + +#endif /* GRPC_CORE_LIB_GPRPP_HOST_PORT_H */ diff --git a/src/core/lib/gprpp/string_view.h b/src/core/lib/gprpp/string_view.h new file mode 100644 index 00000000000..05a81066d48 --- /dev/null +++ b/src/core/lib/gprpp/string_view.h @@ -0,0 +1,143 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GRPC_CORE_LIB_GPRPP_STRING_VIEW_H +#define GRPC_CORE_LIB_GPRPP_STRING_VIEW_H + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/memory.h" + +namespace grpc_core { + +// Provides a light-weight view over a char array or a slice, similar but not +// identical to absl::string_view. +// +// Any method that has the same name as absl::string_view MUST HAVE identical +// semantics to what absl::string_view provides. +// +// Methods that are not part of absl::string_view API, must be clearly +// annotated. +// +// StringView does not own the buffers that back the view. Callers must ensure +// the buffer stays around while the StringView is accessible. +// +// Pass StringView by value in functions, since it is exactly two pointers in +// size. +// +// The interface used here is not identical to absl::string_view. Notably, we +// need to support slices while we cannot support std::string, and gpr string +// style functions such as strdup() and cmp(). Once we switch to +// absl::string_view this class will inherit from absl::string_view and add the +// gRPC-specific APIs. +class StringView final { + public: + static constexpr size_t npos = std::numeric_limits::max(); + + constexpr StringView(const char* ptr, size_t size) : ptr_(ptr), size_(size) {} + constexpr StringView(const char* ptr) + : StringView(ptr, ptr == nullptr ? 0 : strlen(ptr)) {} + // Not part of absl::string_view API. + StringView(const grpc_slice& slice) + : StringView(reinterpret_cast(GRPC_SLICE_START_PTR(slice)), + GRPC_SLICE_LENGTH(slice)) {} + constexpr StringView() : StringView(nullptr, 0) {} + + constexpr const char* data() const { return ptr_; } + constexpr size_t size() const { return size_; } + constexpr bool empty() const { return size_ == 0; } + + StringView substr(size_t start, size_t size = npos) { + GPR_DEBUG_ASSERT(start + size <= size_); + return StringView(ptr_ + start, std::min(size, size_ - start)); + } + + constexpr const char& operator[](size_t i) const { return ptr_[i]; } + + const char& front() const { return ptr_[0]; } + const char& back() const { return ptr_[size_ - 1]; } + + void remove_prefix(size_t n) { + GPR_DEBUG_ASSERT(n <= size_); + ptr_ += n; + size_ -= n; + } + + void remove_suffix(size_t n) { + GPR_DEBUG_ASSERT(n <= size_); + size_ -= n; + } + + size_t find(char c, size_t pos = 0) const { + if (empty() || pos >= size_) return npos; + const char* result = + static_cast(memchr(ptr_ + pos, c, size_ - pos)); + return result != nullptr ? result - ptr_ : npos; + } + + void clear() { + ptr_ = nullptr; + size_ = 0; + } + + // Creates a dup of the string viewed by this class. + // Return value is null-terminated and never nullptr. + // + // Not part of absl::string_view API. + grpc_core::UniquePtr dup() const { + char* str = static_cast(gpr_malloc(size_ + 1)); + if (size_ > 0) memcpy(str, ptr_, size_); + str[size_] = '\0'; + return grpc_core::UniquePtr(str); + } + + // Not part of absl::string_view API. + int cmp(StringView other) const { + const size_t len = GPR_MIN(size(), other.size()); + const int ret = strncmp(data(), other.data(), len); + if (ret != 0) return ret; + if (size() == other.size()) return 0; + if (size() < other.size()) return -1; + return 1; + } + + private: + const char* ptr_; + size_t size_; +}; + +inline bool operator==(StringView lhs, StringView rhs) { + return lhs.size() == rhs.size() && + strncmp(lhs.data(), rhs.data(), lhs.size()) == 0; +} + +inline bool operator!=(StringView lhs, StringView rhs) { return !(lhs == rhs); } + +} // namespace grpc_core + +#endif /* GRPC_CORE_LIB_GPRPP_STRING_VIEW_H */ diff --git a/src/core/lib/http/httpcli_security_connector.cc b/src/core/lib/http/httpcli_security_connector.cc index 762cbe41bcf..8196019f098 100644 --- a/src/core/lib/http/httpcli_security_connector.cc +++ b/src/core/lib/http/httpcli_security_connector.cc @@ -30,6 +30,7 @@ #include "src/core/lib/channel/handshaker_registry.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" +#include "src/core/lib/gprpp/string_view.h" #include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" @@ -108,7 +109,8 @@ class grpc_httpcli_ssl_channel_security_connector final return strcmp(secure_peer_name_, other->secure_peer_name_); } - bool check_call_host(const char* host, grpc_auth_context* auth_context, + bool check_call_host(grpc_core::StringView host, + grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) override { *error = GRPC_ERROR_NONE; diff --git a/src/core/lib/iomgr/resolve_address_custom.cc b/src/core/lib/iomgr/resolve_address_custom.cc index 9cf7817f66e..64c33cdc0d4 100644 --- a/src/core/lib/iomgr/resolve_address_custom.cc +++ b/src/core/lib/iomgr/resolve_address_custom.cc @@ -24,9 +24,9 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/iomgr_custom.h" #include "src/core/lib/iomgr/resolve_address_custom.h" @@ -86,11 +86,12 @@ void grpc_custom_resolve_callback(grpc_custom_resolver* r, } static grpc_error* try_split_host_port(const char* name, - const char* default_port, char** host, - char** port) { + const char* default_port, + grpc_core::UniquePtr* host, + grpc_core::UniquePtr* port) { /* parse name, splitting it into host and port parts */ grpc_error* error; - gpr_split_host_port(name, host, port); + SplitHostPort(name, host, port); if (*host == nullptr) { char* msg; gpr_asprintf(&msg, "unparseable host:port: '%s'", name); @@ -107,7 +108,7 @@ static grpc_error* try_split_host_port(const char* name, gpr_free(msg); return error; } - *port = gpr_strdup(default_port); + port->reset(gpr_strdup(default_port)); } return GRPC_ERROR_NONE; } @@ -115,28 +116,26 @@ static grpc_error* try_split_host_port(const char* name, static grpc_error* blocking_resolve_address_impl( const char* name, const char* default_port, grpc_resolved_addresses** addresses) { - char* host; - char* port; + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; grpc_error* err; GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD(); err = try_split_host_port(name, default_port, &host, &port); if (err != GRPC_ERROR_NONE) { - gpr_free(host); - gpr_free(port); return err; } /* Call getaddrinfo */ grpc_custom_resolver resolver; - resolver.host = host; - resolver.port = port; + resolver.host = host.get(); + resolver.port = port.get(); grpc_resolved_addresses* addrs; grpc_core::ExecCtx* curr = grpc_core::ExecCtx::Get(); grpc_core::ExecCtx::Set(nullptr); - err = resolve_address_vtable->resolve(host, port, &addrs); + err = resolve_address_vtable->resolve(host.get(), port.get(), &addrs); if (err != GRPC_ERROR_NONE) { if (retry_named_port_failure(&resolver, &addrs)) { GRPC_ERROR_UNREF(err); @@ -147,8 +146,6 @@ static grpc_error* blocking_resolve_address_impl( if (err == GRPC_ERROR_NONE) { *addresses = addrs; } - gpr_free(resolver.host); - gpr_free(resolver.port); return err; } @@ -157,22 +154,20 @@ static void resolve_address_impl(const char* name, const char* default_port, grpc_closure* on_done, grpc_resolved_addresses** addrs) { grpc_custom_resolver* r = nullptr; - char* host = nullptr; - char* port = nullptr; + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; grpc_error* err; GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD(); err = try_split_host_port(name, default_port, &host, &port); if (err != GRPC_ERROR_NONE) { GRPC_CLOSURE_SCHED(on_done, err); - gpr_free(host); - gpr_free(port); return; } r = (grpc_custom_resolver*)gpr_malloc(sizeof(grpc_custom_resolver)); r->on_done = on_done; r->addresses = addrs; - r->host = host; - r->port = port; + r->host = host.release(); + r->port = port.release(); /* Call getaddrinfo */ resolve_address_vtable->resolve_async(r, r->host, r->port); diff --git a/src/core/lib/iomgr/resolve_address_posix.cc b/src/core/lib/iomgr/resolve_address_posix.cc index e6dd8f1ceab..e02dc19bb27 100644 --- a/src/core/lib/iomgr/resolve_address_posix.cc +++ b/src/core/lib/iomgr/resolve_address_posix.cc @@ -33,9 +33,9 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/executor.h" @@ -48,8 +48,6 @@ static grpc_error* posix_blocking_resolve_address( grpc_core::ExecCtx exec_ctx; struct addrinfo hints; struct addrinfo *result = nullptr, *resp; - char* host; - char* port; int s; size_t i; grpc_error* err; @@ -59,8 +57,10 @@ static grpc_error* posix_blocking_resolve_address( return grpc_resolve_unix_domain_address(name + 5, addresses); } + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; /* parse name, splitting it into host and port parts */ - gpr_split_host_port(name, &host, &port); + grpc_core::SplitHostPort(name, &host, &port); if (host == nullptr) { err = grpc_error_set_str( GRPC_ERROR_CREATE_FROM_STATIC_STRING("unparseable host:port"), @@ -74,7 +74,7 @@ static grpc_error* posix_blocking_resolve_address( GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(name)); goto done; } - port = gpr_strdup(default_port); + port.reset(gpr_strdup(default_port)); } /* Call getaddrinfo */ @@ -84,16 +84,16 @@ static grpc_error* posix_blocking_resolve_address( hints.ai_flags = AI_PASSIVE; /* for wildcard IP address */ GRPC_SCHEDULING_START_BLOCKING_REGION; - s = getaddrinfo(host, port, &hints, &result); + s = getaddrinfo(host.get(), port.get(), &hints, &result); GRPC_SCHEDULING_END_BLOCKING_REGION; if (s != 0) { /* Retry if well-known service name is recognized */ const char* svc[][2] = {{"http", "80"}, {"https", "443"}}; for (i = 0; i < GPR_ARRAY_SIZE(svc); i++) { - if (strcmp(port, svc[i][0]) == 0) { + if (strcmp(port.get(), svc[i][0]) == 0) { GRPC_SCHEDULING_START_BLOCKING_REGION; - s = getaddrinfo(host, svc[i][1], &hints, &result); + s = getaddrinfo(host.get(), svc[i][1], &hints, &result); GRPC_SCHEDULING_END_BLOCKING_REGION; break; } @@ -133,8 +133,6 @@ static grpc_error* posix_blocking_resolve_address( err = GRPC_ERROR_NONE; done: - gpr_free(host); - gpr_free(port); if (result) { freeaddrinfo(result); } diff --git a/src/core/lib/iomgr/resolve_address_windows.cc b/src/core/lib/iomgr/resolve_address_windows.cc index 64351c38a8f..a06d5cefbcb 100644 --- a/src/core/lib/iomgr/resolve_address_windows.cc +++ b/src/core/lib/iomgr/resolve_address_windows.cc @@ -35,8 +35,8 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/executor.h" @@ -57,14 +57,14 @@ static grpc_error* windows_blocking_resolve_address( grpc_core::ExecCtx exec_ctx; struct addrinfo hints; struct addrinfo *result = NULL, *resp; - char* host; - char* port; int s; size_t i; grpc_error* error = GRPC_ERROR_NONE; /* parse name, splitting it into host and port parts */ - gpr_split_host_port(name, &host, &port); + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; + grpc_core::SplitHostPort(name, &host, &port); if (host == NULL) { char* msg; gpr_asprintf(&msg, "unparseable host:port: '%s'", name); @@ -80,7 +80,7 @@ static grpc_error* windows_blocking_resolve_address( gpr_free(msg); goto done; } - port = gpr_strdup(default_port); + port.reset(gpr_strdup(default_port)); } /* Call getaddrinfo */ @@ -90,7 +90,7 @@ static grpc_error* windows_blocking_resolve_address( hints.ai_flags = AI_PASSIVE; /* for wildcard IP address */ GRPC_SCHEDULING_START_BLOCKING_REGION; - s = getaddrinfo(host, port, &hints, &result); + s = getaddrinfo(host.get(), port.get(), &hints, &result); GRPC_SCHEDULING_END_BLOCKING_REGION; if (s != 0) { error = GRPC_WSA_ERROR(WSAGetLastError(), "getaddrinfo"); @@ -122,8 +122,6 @@ static grpc_error* windows_blocking_resolve_address( } done: - gpr_free(host); - gpr_free(port); if (result) { freeaddrinfo(result); } diff --git a/src/core/lib/iomgr/sockaddr_utils.cc b/src/core/lib/iomgr/sockaddr_utils.cc index 0839bdfef2d..baadf1da99e 100644 --- a/src/core/lib/iomgr/sockaddr_utils.cc +++ b/src/core/lib/iomgr/sockaddr_utils.cc @@ -28,8 +28,8 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/socket_utils.h" #include "src/core/lib/iomgr/unix_sockets_posix.h" @@ -181,15 +181,17 @@ int grpc_sockaddr_to_string(char** out, } if (ip != nullptr && grpc_inet_ntop(addr->sa_family, ip, ntop_buf, sizeof(ntop_buf)) != nullptr) { + grpc_core::UniquePtr tmp_out; if (sin6_scope_id != 0) { char* host_with_scope; /* Enclose sin6_scope_id with the format defined in RFC 6784 section 2. */ gpr_asprintf(&host_with_scope, "%s%%25%" PRIu32, ntop_buf, sin6_scope_id); - ret = gpr_join_host_port(out, host_with_scope, port); + ret = grpc_core::JoinHostPort(&tmp_out, host_with_scope, port); gpr_free(host_with_scope); } else { - ret = gpr_join_host_port(out, ntop_buf, port); + ret = grpc_core::JoinHostPort(&tmp_out, ntop_buf, port); } + *out = tmp_out.release(); } else { ret = gpr_asprintf(out, "(sockaddr family=%d)", addr->sa_family); } diff --git a/src/core/lib/iomgr/socket_utils_common_posix.cc b/src/core/lib/iomgr/socket_utils_common_posix.cc index 2101651b33f..47d9f51b095 100644 --- a/src/core/lib/iomgr/socket_utils_common_posix.cc +++ b/src/core/lib/iomgr/socket_utils_common_posix.cc @@ -46,7 +46,6 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/sockaddr_utils.h" diff --git a/src/core/lib/iomgr/tcp_client_cfstream.cc b/src/core/lib/iomgr/tcp_client_cfstream.cc index 4b21322d746..fcad5edd222 100644 --- a/src/core/lib/iomgr/tcp_client_cfstream.cc +++ b/src/core/lib/iomgr/tcp_client_cfstream.cc @@ -34,7 +34,7 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/cfstream_handle.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/endpoint_cfstream.h" @@ -143,12 +143,13 @@ static void OnOpen(void* arg, grpc_error* error) { static void ParseResolvedAddress(const grpc_resolved_address* addr, CFStringRef* host, int* port) { - char *host_port, *host_string, *port_string; + char* host_port; grpc_sockaddr_to_string(&host_port, addr, 1); - gpr_split_host_port(host_port, &host_string, &port_string); - *host = CFStringCreateWithCString(NULL, host_string, kCFStringEncodingUTF8); - gpr_free(host_string); - gpr_free(port_string); + grpc_core::UniquePtr host_string; + grpc_core::UniquePtr port_string; + grpc_core::SplitHostPort(host_port, &host_string, &port_string); + *host = + CFStringCreateWithCString(NULL, host_string.get(), kCFStringEncodingUTF8); gpr_free(host_port); *port = grpc_sockaddr_get_port(addr); } diff --git a/src/core/lib/security/security_connector/alts/alts_security_connector.cc b/src/core/lib/security/security_connector/alts/alts_security_connector.cc index 38b1f856d52..79908601130 100644 --- a/src/core/lib/security/security_connector/alts/alts_security_connector.cc +++ b/src/core/lib/security/security_connector/alts/alts_security_connector.cc @@ -108,10 +108,11 @@ class grpc_alts_channel_security_connector final return strcmp(target_name_, other->target_name_); } - bool check_call_host(const char* host, grpc_auth_context* auth_context, + bool check_call_host(grpc_core::StringView host, + grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) override { - if (host == nullptr || strcmp(host, target_name_) != 0) { + if (host.empty() || host != target_name_) { *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "ALTS call host does not match target name"); } diff --git a/src/core/lib/security/security_connector/fake/fake_security_connector.cc b/src/core/lib/security/security_connector/fake/fake_security_connector.cc index c55fd34d0e2..940c2ac5ee5 100644 --- a/src/core/lib/security/security_connector/fake/fake_security_connector.cc +++ b/src/core/lib/security/security_connector/fake/fake_security_connector.cc @@ -31,8 +31,8 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/security/context/security_context.h" #include "src/core/lib/security/credentials/credentials.h" @@ -102,39 +102,35 @@ class grpc_fake_channel_security_connector final tsi_create_fake_handshaker(/*is_client=*/true), this)); } - bool check_call_host(const char* host, grpc_auth_context* auth_context, + bool check_call_host(grpc_core::StringView host, + grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) override { - char* authority_hostname = nullptr; - char* authority_ignored_port = nullptr; - char* target_hostname = nullptr; - char* target_ignored_port = nullptr; - gpr_split_host_port(host, &authority_hostname, &authority_ignored_port); - gpr_split_host_port(target_, &target_hostname, &target_ignored_port); + grpc_core::StringView authority_hostname; + grpc_core::StringView authority_ignored_port; + grpc_core::StringView target_hostname; + grpc_core::StringView target_ignored_port; + grpc_core::SplitHostPort(host, &authority_hostname, + &authority_ignored_port); + grpc_core::SplitHostPort(target_, &target_hostname, &target_ignored_port); if (target_name_override_ != nullptr) { - char* fake_security_target_name_override_hostname = nullptr; - char* fake_security_target_name_override_ignored_port = nullptr; - gpr_split_host_port(target_name_override_, - &fake_security_target_name_override_hostname, - &fake_security_target_name_override_ignored_port); - if (strcmp(authority_hostname, - fake_security_target_name_override_hostname) != 0) { + grpc_core::StringView fake_security_target_name_override_hostname; + grpc_core::StringView fake_security_target_name_override_ignored_port; + grpc_core::SplitHostPort( + target_name_override_, &fake_security_target_name_override_hostname, + &fake_security_target_name_override_ignored_port); + if (authority_hostname != fake_security_target_name_override_hostname) { gpr_log(GPR_ERROR, "Authority (host) '%s' != Fake Security Target override '%s'", - host, fake_security_target_name_override_hostname); + host.data(), + fake_security_target_name_override_hostname.data()); abort(); } - gpr_free(fake_security_target_name_override_hostname); - gpr_free(fake_security_target_name_override_ignored_port); - } else if (strcmp(authority_hostname, target_hostname) != 0) { - gpr_log(GPR_ERROR, "Authority (host) '%s' != Target '%s'", - authority_hostname, target_hostname); + } else if (authority_hostname != target_hostname) { + gpr_log(GPR_ERROR, "Authority (host) '%s' != Target '%s'", host.data(), + target_); abort(); } - gpr_free(authority_hostname); - gpr_free(authority_ignored_port); - gpr_free(target_hostname); - gpr_free(target_ignored_port); return true; } diff --git a/src/core/lib/security/security_connector/local/local_security_connector.cc b/src/core/lib/security/security_connector/local/local_security_connector.cc index c1a101d4ab8..5b777009d34 100644 --- a/src/core/lib/security/security_connector/local/local_security_connector.cc +++ b/src/core/lib/security/security_connector/local/local_security_connector.cc @@ -156,10 +156,11 @@ class grpc_local_channel_security_connector final creds->connect_type()); } - bool check_call_host(const char* host, grpc_auth_context* auth_context, + bool check_call_host(grpc_core::StringView host, + grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) override { - if (host == nullptr || strcmp(host, target_name_) != 0) { + if (host.empty() || host != target_name_) { *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "local call host does not match target name"); } diff --git a/src/core/lib/security/security_connector/security_connector.cc b/src/core/lib/security/security_connector/security_connector.cc index 47c0ad5aa3d..2c7c982e719 100644 --- a/src/core/lib/security/security_connector/security_connector.cc +++ b/src/core/lib/security/security_connector/security_connector.cc @@ -28,8 +28,8 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/context/security_context.h" #include "src/core/lib/security/credentials/credentials.h" diff --git a/src/core/lib/security/security_connector/security_connector.h b/src/core/lib/security/security_connector/security_connector.h index f71ee54402d..e5ced44638b 100644 --- a/src/core/lib/security/security_connector/security_connector.h +++ b/src/core/lib/security/security_connector/security_connector.h @@ -98,7 +98,7 @@ class grpc_channel_security_connector : public grpc_security_connector { /// Returns true if completed synchronously, in which case \a error will /// be set to indicate the result. Otherwise, \a on_call_host_checked /// will be invoked when complete. - virtual bool check_call_host(const char* host, + virtual bool check_call_host(grpc_core::StringView host, grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) GRPC_ABSTRACT; diff --git a/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc b/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc index f920dc6046d..97c04cafce4 100644 --- a/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +++ b/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc @@ -28,8 +28,8 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/handshaker.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/security/context/security_context.h" #include "src/core/lib/security/credentials/credentials.h" @@ -75,15 +75,14 @@ class grpc_ssl_channel_security_connector final ? nullptr : gpr_strdup(overridden_target_name)), verify_options_(&config->verify_options) { - char* port; - gpr_split_host_port(target_name, &target_name_, &port); - gpr_free(port); + grpc_core::StringView host; + grpc_core::StringView port; + grpc_core::SplitHostPort(target_name, &host, &port); + target_name_ = host.dup(); } ~grpc_ssl_channel_security_connector() override { tsi_ssl_client_handshaker_factory_unref(client_handshaker_factory_); - if (target_name_ != nullptr) gpr_free(target_name_); - if (overridden_target_name_ != nullptr) gpr_free(overridden_target_name_); } grpc_security_status InitializeHandshakerFactory( @@ -123,8 +122,8 @@ class grpc_ssl_channel_security_connector final tsi_handshaker* tsi_hs = nullptr; tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker( client_handshaker_factory_, - overridden_target_name_ != nullptr ? overridden_target_name_ - : target_name_, + overridden_target_name_ != nullptr ? overridden_target_name_.get() + : target_name_.get(), &tsi_hs); if (result != TSI_OK) { gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.", @@ -139,8 +138,8 @@ class grpc_ssl_channel_security_connector final grpc_core::RefCountedPtr* auth_context, grpc_closure* on_peer_checked) override { const char* target_name = overridden_target_name_ != nullptr - ? overridden_target_name_ - : target_name_; + ? overridden_target_name_.get() + : target_name_.get(); grpc_error* error = ssl_check_peer(target_name, &peer, auth_context); if (error == GRPC_ERROR_NONE && verify_options_->verify_peer_callback != nullptr) { @@ -175,17 +174,18 @@ class grpc_ssl_channel_security_connector final reinterpret_cast(other_sc); int c = channel_security_connector_cmp(other); if (c != 0) return c; - c = strcmp(target_name_, other->target_name_); + c = strcmp(target_name_.get(), other->target_name_.get()); if (c != 0) return c; return (overridden_target_name_ == nullptr || other->overridden_target_name_ == nullptr) - ? GPR_ICMP(overridden_target_name_, - other->overridden_target_name_) - : strcmp(overridden_target_name_, - other->overridden_target_name_); + ? GPR_ICMP(overridden_target_name_.get(), + other->overridden_target_name_.get()) + : strcmp(overridden_target_name_.get(), + other->overridden_target_name_.get()); } - bool check_call_host(const char* host, grpc_auth_context* auth_context, + bool check_call_host(grpc_core::StringView host, + grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) override { grpc_security_status status = GRPC_SECURITY_ERROR; @@ -194,7 +194,7 @@ class grpc_ssl_channel_security_connector final /* If the target name was overridden, then the original target_name was 'checked' transitively during the previous peer check at the end of the handshake. */ - if (overridden_target_name_ != nullptr && strcmp(host, target_name_) == 0) { + if (overridden_target_name_ != nullptr && host == target_name_.get()) { status = GRPC_SECURITY_OK; } if (status != GRPC_SECURITY_OK) { @@ -212,8 +212,8 @@ class grpc_ssl_channel_security_connector final private: tsi_ssl_client_handshaker_factory* client_handshaker_factory_; - char* target_name_; - char* overridden_target_name_; + grpc_core::UniquePtr target_name_; + grpc_core::UniquePtr overridden_target_name_; const verify_peer_options* verify_options_; }; diff --git a/src/core/lib/security/security_connector/ssl_utils.cc b/src/core/lib/security/security_connector/ssl_utils.cc index cb0d5437988..ebb4a3f9ee8 100644 --- a/src/core/lib/security/security_connector/ssl_utils.cc +++ b/src/core/lib/security/security_connector/ssl_utils.cc @@ -27,9 +27,9 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/global_config.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/context/security_context.h" @@ -136,12 +136,13 @@ grpc_error* grpc_ssl_check_alpn(const tsi_peer* peer) { return GRPC_ERROR_NONE; } -grpc_error* grpc_ssl_check_peer_name(const char* peer_name, +grpc_error* grpc_ssl_check_peer_name(grpc_core::StringView peer_name, const tsi_peer* peer) { /* Check the peer name if specified. */ - if (peer_name != nullptr && !grpc_ssl_host_matches_name(peer, peer_name)) { + if (!peer_name.empty() && !grpc_ssl_host_matches_name(peer, peer_name)) { char* msg; - gpr_asprintf(&msg, "Peer name %s is not in peer certificate", peer_name); + gpr_asprintf(&msg, "Peer name %s is not in peer certificate", + peer_name.data()); grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg); gpr_free(msg); return error; @@ -149,15 +150,16 @@ grpc_error* grpc_ssl_check_peer_name(const char* peer_name, return GRPC_ERROR_NONE; } -bool grpc_ssl_check_call_host(const char* host, const char* target_name, - const char* overridden_target_name, +bool grpc_ssl_check_call_host(grpc_core::StringView host, + grpc_core::StringView target_name, + grpc_core::StringView overridden_target_name, grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) { grpc_security_status status = GRPC_SECURITY_ERROR; tsi_peer peer = grpc_shallow_peer_from_ssl_auth_context(auth_context); if (grpc_ssl_host_matches_name(&peer, host)) status = GRPC_SECURITY_OK; - if (overridden_target_name != nullptr && strcmp(host, target_name) == 0) { + if (!overridden_target_name.empty() && host == target_name) { status = GRPC_SECURITY_OK; } if (status != GRPC_SECURITY_OK) { @@ -179,35 +181,28 @@ const char** grpc_fill_alpn_protocol_strings(size_t* num_alpn_protocols) { return alpn_protocol_strings; } -int grpc_ssl_host_matches_name(const tsi_peer* peer, const char* peer_name) { - char* allocated_name = nullptr; - int r; - - char* ignored_port; - gpr_split_host_port(peer_name, &allocated_name, &ignored_port); - gpr_free(ignored_port); - peer_name = allocated_name; - if (!peer_name) return 0; +int grpc_ssl_host_matches_name(const tsi_peer* peer, + grpc_core::StringView peer_name) { + grpc_core::StringView allocated_name; + grpc_core::StringView ignored_port; + grpc_core::SplitHostPort(peer_name, &allocated_name, &ignored_port); + if (allocated_name.empty()) return 0; // IPv6 zone-id should not be included in comparisons. - char* const zone_id = strchr(allocated_name, '%'); - if (zone_id != nullptr) *zone_id = '\0'; - - r = tsi_ssl_peer_matches_name(peer, peer_name); - gpr_free(allocated_name); - return r; + const size_t zone_id = allocated_name.find('%'); + if (zone_id != grpc_core::StringView::npos) { + allocated_name.remove_suffix(allocated_name.size() - zone_id); + } + return tsi_ssl_peer_matches_name(peer, allocated_name); } -bool grpc_ssl_cmp_target_name(const char* target_name, - const char* other_target_name, - const char* overridden_target_name, - const char* other_overridden_target_name) { - int c = strcmp(target_name, other_target_name); +int grpc_ssl_cmp_target_name( + grpc_core::StringView target_name, grpc_core::StringView other_target_name, + grpc_core::StringView overridden_target_name, + grpc_core::StringView other_overridden_target_name) { + int c = target_name.cmp(other_target_name); if (c != 0) return c; - return (overridden_target_name == nullptr || - other_overridden_target_name == nullptr) - ? GPR_ICMP(overridden_target_name, other_overridden_target_name) - : strcmp(overridden_target_name, other_overridden_target_name); + return overridden_target_name.cmp(other_overridden_target_name); } grpc_core::RefCountedPtr grpc_ssl_peer_to_auth_context( diff --git a/src/core/lib/security/security_connector/ssl_utils.h b/src/core/lib/security/security_connector/ssl_utils.h index 1765a344c2a..bf8c1de3aae 100644 --- a/src/core/lib/security/security_connector/ssl_utils.h +++ b/src/core/lib/security/security_connector/ssl_utils.h @@ -28,6 +28,7 @@ #include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" +#include "src/core/lib/gprpp/string_view.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/security/security_connector/security_connector.h" #include "src/core/tsi/ssl_transport_security.h" @@ -46,16 +47,17 @@ GPR_GLOBAL_CONFIG_DECLARE_BOOL(grpc_not_use_system_ssl_roots); grpc_error* grpc_ssl_check_alpn(const tsi_peer* peer); /* Check peer name information returned from SSL handshakes. */ -grpc_error* grpc_ssl_check_peer_name(const char* peer_name, +grpc_error* grpc_ssl_check_peer_name(grpc_core::StringView peer_name, const tsi_peer* peer); /* Compare targer_name information extracted from SSL security connectors. */ -bool grpc_ssl_cmp_target_name(const char* target_name, - const char* other_target_name, - const char* overridden_target_name, - const char* other_overridden_target_name); +int grpc_ssl_cmp_target_name( + grpc_core::StringView target_name, grpc_core::StringView other_target_name, + grpc_core::StringView overridden_target_name, + grpc_core::StringView other_overridden_target_name); /* Check the host that will be set for a call is acceptable.*/ -bool grpc_ssl_check_call_host(const char* host, const char* target_name, - const char* overridden_target_name, +bool grpc_ssl_check_call_host(grpc_core::StringView host, + grpc_core::StringView target_name, + grpc_core::StringView overridden_target_name, grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error); @@ -89,7 +91,8 @@ grpc_core::RefCountedPtr grpc_ssl_peer_to_auth_context( tsi_peer grpc_shallow_peer_from_ssl_auth_context( const grpc_auth_context* auth_context); void grpc_shallow_peer_destruct(tsi_peer* peer); -int grpc_ssl_host_matches_name(const tsi_peer* peer, const char* peer_name); +int grpc_ssl_host_matches_name(const tsi_peer* peer, + grpc_core::StringView peer_name); /* --- Default SSL Root Store. --- */ namespace grpc_core { diff --git a/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc b/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc index ebf9c905079..5853de4fc13 100644 --- a/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +++ b/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc @@ -28,7 +28,7 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/ssl/ssl_credentials.h" #include "src/core/lib/security/credentials/tls/spiffe_credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" @@ -105,18 +105,13 @@ SpiffeChannelSecurityConnector::SpiffeChannelSecurityConnector( ? nullptr : gpr_strdup(overridden_target_name)) { check_arg_ = ServerAuthorizationCheckArgCreate(this); - char* port; - gpr_split_host_port(target_name, &target_name_, &port); - gpr_free(port); + grpc_core::StringView host; + grpc_core::StringView port; + grpc_core::SplitHostPort(target_name, &host, &port); + target_name_ = host.dup(); } SpiffeChannelSecurityConnector::~SpiffeChannelSecurityConnector() { - if (target_name_ != nullptr) { - gpr_free(target_name_); - } - if (overridden_target_name_ != nullptr) { - gpr_free(overridden_target_name_); - } if (client_handshaker_factory_ != nullptr) { tsi_ssl_client_handshaker_factory_unref(client_handshaker_factory_); } @@ -130,8 +125,8 @@ void SpiffeChannelSecurityConnector::add_handshakers( tsi_handshaker* tsi_hs = nullptr; tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker( client_handshaker_factory_, - overridden_target_name_ != nullptr ? overridden_target_name_ - : target_name_, + overridden_target_name_ != nullptr ? overridden_target_name_.get() + : target_name_.get(), &tsi_hs); if (result != TSI_OK) { gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.", @@ -147,8 +142,8 @@ void SpiffeChannelSecurityConnector::check_peer( grpc_core::RefCountedPtr* auth_context, grpc_closure* on_peer_checked) { const char* target_name = overridden_target_name_ != nullptr - ? overridden_target_name_ - : target_name_; + ? overridden_target_name_.get() + : target_name_.get(); grpc_error* error = grpc_ssl_check_alpn(&peer); if (error != GRPC_ERROR_NONE) { GRPC_CLOSURE_SCHED(on_peer_checked, error); @@ -203,16 +198,17 @@ int SpiffeChannelSecurityConnector::cmp( if (c != 0) { return c; } - return grpc_ssl_cmp_target_name(target_name_, other->target_name_, - overridden_target_name_, - other->overridden_target_name_); + return grpc_ssl_cmp_target_name(target_name_.get(), other->target_name_.get(), + overridden_target_name_.get(), + other->overridden_target_name_.get()); } bool SpiffeChannelSecurityConnector::check_call_host( - const char* host, grpc_auth_context* auth_context, + grpc_core::StringView host, grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) { - return grpc_ssl_check_call_host(host, target_name_, overridden_target_name_, - auth_context, on_call_host_checked, error); + return grpc_ssl_check_call_host(host, target_name_.get(), + overridden_target_name_.get(), auth_context, + on_call_host_checked, error); } void SpiffeChannelSecurityConnector::cancel_check_call_host( diff --git a/src/core/lib/security/security_connector/tls/spiffe_security_connector.h b/src/core/lib/security/security_connector/tls/spiffe_security_connector.h index 56972153e07..5ea00ee85b6 100644 --- a/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +++ b/src/core/lib/security/security_connector/tls/spiffe_security_connector.h @@ -53,7 +53,8 @@ class SpiffeChannelSecurityConnector final int cmp(const grpc_security_connector* other_sc) const override; - bool check_call_host(const char* host, grpc_auth_context* auth_context, + bool check_call_host(grpc_core::StringView host, + grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) override; @@ -83,8 +84,8 @@ class SpiffeChannelSecurityConnector final grpc_tls_server_authorization_check_arg* arg); grpc_closure* on_peer_checked_; - char* target_name_; - char* overridden_target_name_; + grpc_core::UniquePtr target_name_; + grpc_core::UniquePtr overridden_target_name_; tsi_ssl_client_handshaker_factory* client_handshaker_factory_ = nullptr; grpc_tls_server_authorization_check_arg* check_arg_; }; diff --git a/src/core/lib/security/transport/client_auth_filter.cc b/src/core/lib/security/transport/client_auth_filter.cc index 1062fc2f4fa..33343d276eb 100644 --- a/src/core/lib/security/transport/client_auth_filter.cc +++ b/src/core/lib/security/transport/client_auth_filter.cc @@ -346,7 +346,7 @@ static void auth_start_transport_stream_op_batch( GRPC_CALL_STACK_REF(calld->owning_call, "check_call_host"); GRPC_CLOSURE_INIT(&calld->async_result_closure, on_host_checked, batch, grpc_schedule_on_exec_ctx); - char* call_host = grpc_slice_to_c_string(calld->host); + grpc_core::StringView call_host(calld->host); grpc_error* error = GRPC_ERROR_NONE; if (chand->security_connector->check_call_host( call_host, chand->auth_context.get(), @@ -360,7 +360,6 @@ static void auth_start_transport_stream_op_batch( &calld->check_call_host_cancel_closure, cancel_check_call_host, elem, grpc_schedule_on_exec_ctx)); } - gpr_free(call_host); return; /* early exit */ } } diff --git a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc index 1b7e58d3ce0..0d28303e7dd 100644 --- a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +++ b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc @@ -30,7 +30,6 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/slice/slice_internal.h" diff --git a/src/core/tsi/ssl_transport_security.cc b/src/core/tsi/ssl_transport_security.cc index 25ae2cee285..d3c8982c847 100644 --- a/src/core/tsi/ssl_transport_security.cc +++ b/src/core/tsi/ssl_transport_security.cc @@ -233,11 +233,10 @@ static void ssl_info_callback(const SSL* ssl, int where, int ret) { /* Returns 1 if name looks like an IP address, 0 otherwise. This is a very rough heuristic, and only handles IPv6 in hexadecimal form. */ -static int looks_like_ip_address(const char* name) { - size_t i; +static int looks_like_ip_address(grpc_core::StringView name) { size_t dot_count = 0; size_t num_size = 0; - for (i = 0; i < strlen(name); i++) { + for (size_t i = 0; i < name.size(); ++i) { if (name[i] == ':') { /* IPv6 Address in hexadecimal form, : is not allowed in DNS names. */ return 1; @@ -1506,52 +1505,46 @@ static void tsi_ssl_server_handshaker_factory_destroy( gpr_free(self); } -static int does_entry_match_name(const char* entry, size_t entry_length, - const char* name) { - const char* dot; - const char* name_subdomain = nullptr; - size_t name_length = strlen(name); - size_t name_subdomain_length; - if (entry_length == 0) return 0; +static int does_entry_match_name(grpc_core::StringView entry, + grpc_core::StringView name) { + if (entry.empty()) return 0; /* Take care of '.' terminations. */ - if (name[name_length - 1] == '.') { - name_length--; + if (name.back() == '.') { + name.remove_suffix(1); } - if (entry[entry_length - 1] == '.') { - entry_length--; - if (entry_length == 0) return 0; + if (entry.back() == '.') { + entry.remove_suffix(1); + if (entry.empty()) return 0; } - if ((name_length == entry_length) && - strncmp(name, entry, entry_length) == 0) { + if (name == entry) { return 1; /* Perfect match. */ } - if (entry[0] != '*') return 0; + if (entry.front() != '*') return 0; /* Wildchar subdomain matching. */ - if (entry_length < 3 || entry[1] != '.') { /* At least *.x */ + if (entry.size() < 3 || entry[1] != '.') { /* At least *.x */ gpr_log(GPR_ERROR, "Invalid wildchar entry."); return 0; } - name_subdomain = strchr(name, '.'); - if (name_subdomain == nullptr) return 0; - name_subdomain_length = strlen(name_subdomain); - if (name_subdomain_length < 2) return 0; - name_subdomain++; /* Starts after the dot. */ - name_subdomain_length--; - entry += 2; /* Remove *. */ - entry_length -= 2; - dot = strchr(name_subdomain, '.'); - if ((dot == nullptr) || (dot == &name_subdomain[name_subdomain_length - 1])) { - gpr_log(GPR_ERROR, "Invalid toplevel subdomain: %s", name_subdomain); + size_t name_subdomain_pos = name.find('.'); + if (name_subdomain_pos == grpc_core::StringView::npos) return 0; + if (name_subdomain_pos >= name.size() - 2) return 0; + grpc_core::StringView name_subdomain = + name.substr(name_subdomain_pos + 1); /* Starts after the dot. */ + entry.remove_prefix(2); /* Remove *. */ + size_t dot = name_subdomain.find('.'); + if (dot == grpc_core::StringView::npos || dot == name_subdomain.size() - 1) { + grpc_core::UniquePtr name_subdomain_cstr(name_subdomain.dup()); + gpr_log(GPR_ERROR, "Invalid toplevel subdomain: %s", + name_subdomain_cstr.get()); return 0; } - if (name_subdomain[name_subdomain_length - 1] == '.') { - name_subdomain_length--; + if (name_subdomain.back() == '.') { + name_subdomain.remove_suffix(1); } - return ((entry_length > 0) && (name_subdomain_length == entry_length) && - strncmp(entry, name_subdomain, entry_length) == 0); + return !entry.empty() && name_subdomain == entry; } static int ssl_server_handshaker_factory_servername_callback(SSL* ssl, int* ap, @@ -1919,7 +1912,8 @@ tsi_result tsi_create_ssl_server_handshaker_factory_with_options( /* --- tsi_ssl utils. --- */ -int tsi_ssl_peer_matches_name(const tsi_peer* peer, const char* name) { +int tsi_ssl_peer_matches_name(const tsi_peer* peer, + grpc_core::StringView name) { size_t i = 0; size_t san_count = 0; const tsi_peer_property* cn_property = nullptr; @@ -1933,13 +1927,10 @@ int tsi_ssl_peer_matches_name(const tsi_peer* peer, const char* name) { TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY) == 0) { san_count++; - if (!like_ip && does_entry_match_name(property->value.data, - property->value.length, name)) { + grpc_core::StringView entry(property->value.data, property->value.length); + if (!like_ip && does_entry_match_name(entry, name)) { return 1; - } else if (like_ip && - strncmp(name, property->value.data, property->value.length) == - 0 && - strlen(name) == property->value.length) { + } else if (like_ip && name == entry) { /* IP Addresses are exact matches only. */ return 1; } @@ -1951,8 +1942,9 @@ int tsi_ssl_peer_matches_name(const tsi_peer* peer, const char* name) { /* If there's no SAN, try the CN, but only if its not like an IP Address */ if (san_count == 0 && cn_property != nullptr && !like_ip) { - if (does_entry_match_name(cn_property->value.data, - cn_property->value.length, name)) { + if (does_entry_match_name(grpc_core::StringView(cn_property->value.data, + cn_property->value.length), + name)) { return 1; } } diff --git a/src/core/tsi/ssl_transport_security.h b/src/core/tsi/ssl_transport_security.h index 769949e4aad..0203141e56e 100644 --- a/src/core/tsi/ssl_transport_security.h +++ b/src/core/tsi/ssl_transport_security.h @@ -21,6 +21,7 @@ #include +#include "src/core/lib/gprpp/string_view.h" #include "src/core/tsi/transport_security_interface.h" /* Value for the TSI_CERTIFICATE_TYPE_PEER_PROPERTY property for X509 certs. */ @@ -306,7 +307,7 @@ void tsi_ssl_server_handshaker_factory_unref( - handle mixed case. - handle %encoded chars. - handle public suffix wildchar more strictly (e.g. *.co.uk) */ -int tsi_ssl_peer_matches_name(const tsi_peer* peer, const char* name); +int tsi_ssl_peer_matches_name(const tsi_peer* peer, grpc_core::StringView name); /* --- Testing support. --- diff --git a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm index a24734024dc..fbcd4f888d4 100644 --- a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm +++ b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm @@ -37,9 +37,9 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" @@ -51,19 +51,18 @@ #import "../ConfigureCronet.h" -typedef struct fullstack_secure_fixture_data { - char *localaddr; -} fullstack_secure_fixture_data; +struct fullstack_secure_fixture_data { + grpc_core::UniquePtr localaddr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args *client_args, grpc_channel_args *server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_secure_fixture_data *ffd = - (fullstack_secure_fixture_data *)gpr_malloc(sizeof(fullstack_secure_fixture_data)); + fullstack_secure_fixture_data *ffd = grpc_core::New(); memset(&f, 0, sizeof(f)); - gpr_join_host_port(&ffd->localaddr, "127.0.0.1", port); + grpc_core::JoinHostPort(&ffd->localaddr, "127.0.0.1", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(NULL); @@ -103,8 +102,7 @@ static void chttp2_init_server_secure_fullstack(grpc_end2end_test_fixture *f, static void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { fullstack_secure_fixture_data *ffd = (fullstack_secure_fixture_data *)f->fixture_data; - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } static void cronet_init_client_simple_ssl_secure_fullstack(grpc_end2end_test_fixture *f, diff --git a/src/objective-c/tests/CronetTests/CronetUnitTests.mm b/src/objective-c/tests/CronetTests/CronetUnitTests.mm index 2473cf612be..4e2e70f1512 100644 --- a/src/objective-c/tests/CronetTests/CronetUnitTests.mm +++ b/src/objective-c/tests/CronetTests/CronetUnitTests.mm @@ -33,9 +33,9 @@ #import "src/core/lib/channel/channel_args.h" #import "src/core/lib/gpr/env.h" -#import "src/core/lib/gpr/host_port.h" #import "src/core/lib/gpr/string.h" #import "src/core/lib/gpr/tmpfile.h" +#import "src/core/lib/gprpp/host_port.h" #import "test/core/end2end/data/ssl_test_data.h" #import "test/core/util/test_config.h" @@ -133,11 +133,11 @@ unsigned int parse_h2_length(const char *field) { {{NULL, NULL, NULL, NULL}}}}; int port = grpc_pick_unused_port_or_die(); - char *addr; - gpr_join_host_port(&addr, "127.0.0.1", port); + grpc_core::UniquePtr addr; + grpc_core::JoinHostPort(&addr, "127.0.0.1", port); grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); stream_engine *cronetEngine = [Cronet getGlobalEngine]; - grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr, NULL, NULL); + grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr.get(), NULL, NULL); cq_verifier *cqv = cq_verifier_create(cq); grpc_op ops[6]; @@ -264,11 +264,11 @@ unsigned int parse_h2_length(const char *field) { {{NULL, NULL, NULL, NULL}}}}; int port = grpc_pick_unused_port_or_die(); - char *addr; - gpr_join_host_port(&addr, "127.0.0.1", port); + grpc_core::UniquePtr addr; + grpc_core::JoinHostPort(&addr, "127.0.0.1", port); grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); stream_engine *cronetEngine = [Cronet getGlobalEngine]; - grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr, args, NULL); + grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr.get(), args, NULL); cq_verifier *cqv = cq_verifier_create(cq); grpc_op ops[6]; diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 2619ccf9740..c7caee551ce 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -27,7 +27,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/gpr/env_linux.cc', 'src/core/lib/gpr/env_posix.cc', 'src/core/lib/gpr/env_windows.cc', - 'src/core/lib/gpr/host_port.cc', 'src/core/lib/gpr/log.cc', 'src/core/lib/gpr/log_android.cc', 'src/core/lib/gpr/log_linux.cc', @@ -54,6 +53,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/gprpp/arena.cc', 'src/core/lib/gprpp/fork.cc', 'src/core/lib/gprpp/global_config_env.cc', + 'src/core/lib/gprpp/host_port.cc', 'src/core/lib/gprpp/thd_posix.cc', 'src/core/lib/gprpp/thd_windows.cc', 'src/core/lib/profiling/basic_timers.cc', diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc index 8dd55f64944..deae9072613 100644 --- a/test/core/bad_ssl/bad_ssl_test.cc +++ b/test/core/bad_ssl/bad_ssl_test.cc @@ -25,8 +25,9 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" @@ -144,7 +145,9 @@ int main(int argc, char** argv) { gpr_asprintf(&args[0], "%s/bad_ssl_%s_server%s", root, test, gpr_subprocess_binary_extension()); args[1] = const_cast("--bind"); - gpr_join_host_port(&args[2], "::", port); + grpc_core::UniquePtr joined; + grpc_core::JoinHostPort(&joined, "::", port); + args[2] = joined.get(); svr = gpr_subprocess_create(4, (const char**)args); gpr_free(args[0]); @@ -153,7 +156,6 @@ int main(int argc, char** argv) { run_test(args[2], i); grpc_shutdown(); } - gpr_free(args[2]); gpr_subprocess_interrupt(svr); status = gpr_subprocess_join(svr); diff --git a/test/core/client_channel/parse_address_with_named_scope_id_test.cc b/test/core/client_channel/parse_address_with_named_scope_id_test.cc index bfafa745178..071fb88b734 100644 --- a/test/core/client_channel/parse_address_with_named_scope_id_test.cc +++ b/test/core/client_channel/parse_address_with_named_scope_id_test.cc @@ -30,7 +30,8 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/socket_utils.h" #include "test/core/util/test_config.h" @@ -60,20 +61,20 @@ static void test_grpc_parse_ipv6_parity_with_getaddrinfo( struct sockaddr_in6 resolve_with_gettaddrinfo(const char* uri_text) { grpc_uri* uri = grpc_uri_parse(uri_text, 0); - char* host = nullptr; - char* port = nullptr; - gpr_split_host_port(uri->path, &host, &port); + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; + grpc_core::SplitHostPort(uri->path, &host, &port); struct addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET6; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_NUMERICHOST; struct addrinfo* result; - int res = getaddrinfo(host, port, &hints, &result); + int res = getaddrinfo(host.get(), port.get(), &hints, &result); if (res != 0) { gpr_log(GPR_ERROR, - "getaddrinfo failed to resolve host:%s port:%s. Error: %d.", host, - port, res); + "getaddrinfo failed to resolve host:%s port:%s. Error: %d.", + host.get(), port.get(), res); abort(); } size_t num_addrs_from_getaddrinfo = 0; @@ -86,8 +87,6 @@ struct sockaddr_in6 resolve_with_gettaddrinfo(const char* uri_text) { *reinterpret_cast(result->ai_addr); // Cleanup freeaddrinfo(result); - gpr_free(host); - gpr_free(port); grpc_uri_destroy(uri); return out; } diff --git a/test/core/end2end/bad_server_response_test.cc b/test/core/end2end/bad_server_response_test.cc index 2d74b6b77b3..db480463b68 100644 --- a/test/core/end2end/bad_server_response_test.cc +++ b/test/core/end2end/bad_server_response_test.cc @@ -29,8 +29,8 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/sockaddr.h" @@ -71,7 +71,7 @@ #define SERVER_INCOMING_DATA_LENGTH_LOWER_THRESHOLD (size_t)200 struct rpc_state { - char* target; + grpc_core::UniquePtr target; grpc_completion_queue* cq; grpc_channel* channel; grpc_call* call; @@ -165,8 +165,9 @@ static void start_rpc(int target_port, grpc_status_code expected_status, state.cq = grpc_completion_queue_create_for_next(nullptr); cqv = cq_verifier_create(state.cq); - gpr_join_host_port(&state.target, "127.0.0.1", target_port); - state.channel = grpc_insecure_channel_create(state.target, nullptr, nullptr); + grpc_core::JoinHostPort(&state.target, "127.0.0.1", target_port); + state.channel = + grpc_insecure_channel_create(state.target.get(), nullptr, nullptr); grpc_slice host = grpc_slice_from_static_string("localhost"); state.call = grpc_channel_create_call( state.channel, nullptr, GRPC_PROPAGATE_DEFAULTS, state.cq, @@ -230,7 +231,7 @@ static void cleanup_rpc() { } while (ev.type != GRPC_QUEUE_SHUTDOWN); grpc_completion_queue_destroy(state.cq); grpc_channel_destroy(state.channel); - gpr_free(state.target); + state.target.reset(); } typedef struct { diff --git a/test/core/end2end/connection_refused_test.cc b/test/core/end2end/connection_refused_test.cc index 446e7b045a1..3bb6d2e23b6 100644 --- a/test/core/end2end/connection_refused_test.cc +++ b/test/core/end2end/connection_refused_test.cc @@ -24,7 +24,7 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata.h" @@ -77,10 +77,10 @@ static void run_test(bool wait_for_ready, bool use_service_config) { /* create a call, channel to a port which will refuse connection */ int port = grpc_pick_unused_port_or_die(); - char* addr; - gpr_join_host_port(&addr, "127.0.0.1", port); - gpr_log(GPR_INFO, "server: %s", addr); - chan = grpc_insecure_channel_create(addr, args, nullptr); + grpc_core::UniquePtr addr; + grpc_core::JoinHostPort(&addr, "127.0.0.1", port); + gpr_log(GPR_INFO, "server: %s", addr.get()); + chan = grpc_insecure_channel_create(addr.get(), args, nullptr); grpc_slice host = grpc_slice_from_static_string("nonexistant"); gpr_timespec deadline = grpc_timeout_seconds_to_deadline(2); call = @@ -88,8 +88,6 @@ static void run_test(bool wait_for_ready, bool use_service_config) { grpc_slice_from_static_string("/service/method"), &host, deadline, nullptr); - gpr_free(addr); - memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; diff --git a/test/core/end2end/dualstack_socket_test.cc b/test/core/end2end/dualstack_socket_test.cc index 330af8fce07..cb49e0030b4 100644 --- a/test/core/end2end/dualstack_socket_test.cc +++ b/test/core/end2end/dualstack_socket_test.cc @@ -28,8 +28,8 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/sockaddr_utils.h" @@ -70,8 +70,6 @@ static void log_resolved_addrs(const char* label, const char* hostname) { void test_connect(const char* server_host, const char* client_host, int port, int expect_ok) { - char* client_hostport; - char* server_hostport; grpc_channel* client; grpc_server* server; grpc_completion_queue* cq; @@ -99,7 +97,8 @@ void test_connect(const char* server_host, const char* client_host, int port, picked_port = 1; } - gpr_join_host_port(&server_hostport, server_host, port); + grpc_core::UniquePtr server_hostport; + grpc_core::JoinHostPort(&server_hostport, server_host, port); grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); @@ -111,7 +110,7 @@ void test_connect(const char* server_host, const char* client_host, int port, server = grpc_server_create(nullptr, nullptr); grpc_server_register_completion_queue(server, cq, nullptr); GPR_ASSERT((got_port = grpc_server_add_insecure_http2_port( - server, server_hostport)) > 0); + server, server_hostport.get())) > 0); if (port == 0) { port = got_port; } else { @@ -121,6 +120,7 @@ void test_connect(const char* server_host, const char* client_host, int port, cqv = cq_verifier_create(cq); /* Create client. */ + grpc_core::UniquePtr client_hostport; if (client_host[0] == 'i') { /* for ipv4:/ipv6: addresses, concatenate the port to each of the parts */ size_t i; @@ -139,8 +139,8 @@ void test_connect(const char* server_host, const char* client_host, int port, gpr_asprintf(&hosts_with_port[i], "%s:%d", uri_part_str, port); gpr_free(uri_part_str); } - client_hostport = gpr_strjoin_sep((const char**)hosts_with_port, - uri_parts.count, ",", nullptr); + client_hostport.reset(gpr_strjoin_sep((const char**)hosts_with_port, + uri_parts.count, ",", nullptr)); for (i = 0; i < uri_parts.count; i++) { gpr_free(hosts_with_port[i]); } @@ -148,18 +148,17 @@ void test_connect(const char* server_host, const char* client_host, int port, grpc_slice_buffer_destroy(&uri_parts); grpc_slice_unref(uri_slice); } else { - gpr_join_host_port(&client_hostport, client_host, port); + grpc_core::JoinHostPort(&client_hostport, client_host, port); } - client = grpc_insecure_channel_create(client_hostport, nullptr, nullptr); + client = + grpc_insecure_channel_create(client_hostport.get(), nullptr, nullptr); gpr_log(GPR_INFO, "Testing with server=%s client=%s (expecting %s)", - server_hostport, client_hostport, expect_ok ? "success" : "failure"); + server_hostport.get(), client_hostport.get(), + expect_ok ? "success" : "failure"); log_resolved_addrs("server resolved addr", server_host); log_resolved_addrs("client resolved addr", client_host); - gpr_free(client_hostport); - gpr_free(server_hostport); - if (expect_ok) { /* Normal deadline, shouldn't be reached. */ deadline = grpc_timeout_milliseconds_to_deadline(60000); diff --git a/test/core/end2end/fixtures/h2_census.cc b/test/core/end2end/fixtures/h2_census.cc index 60442ddcc77..72cb96138e1 100644 --- a/test/core/end2end/fixtures/h2_census.cc +++ b/test/core/end2end/fixtures/h2_census.cc @@ -29,25 +29,23 @@ #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_fixture_data { - char* localaddr; -} fullstack_fixture_data; +struct fullstack_fixture_data { + grpc_core::UniquePtr localaddr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = static_cast( - gpr_malloc(sizeof(fullstack_fixture_data))); + fullstack_fixture_data* ffd = grpc_core::New(); memset(&f, 0, sizeof(f)); - - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -71,7 +69,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, grpc_arg arg = make_census_enable_arg(); client_args = grpc_channel_args_copy_and_add(client_args, &arg, 1); f->client = - grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr); + grpc_insecure_channel_create(ffd->localaddr.get(), client_args, nullptr); GPR_ASSERT(f->client); { grpc_core::ExecCtx exec_ctx; @@ -94,15 +92,15 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, grpc_channel_args_destroy(server_args); } grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); + GPR_ASSERT( + grpc_server_add_insecure_http2_port(f->server, ffd->localaddr.get())); grpc_server_start(f->server); } void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_compress.cc b/test/core/end2end/fixtures/h2_compress.cc index 01e5ae1b7b5..dd0c1fe0201 100644 --- a/test/core/end2end/fixtures/h2_compress.cc +++ b/test/core/end2end/fixtures/h2_compress.cc @@ -30,28 +30,29 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/compression/compression_args.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_compression_fixture_data { - char* localaddr; - grpc_channel_args* client_args_compression; - grpc_channel_args* server_args_compression; -} fullstack_compression_fixture_data; +struct fullstack_compression_fixture_data { + ~fullstack_compression_fixture_data() { + grpc_channel_args_destroy(client_args_compression); + grpc_channel_args_destroy(server_args_compression); + } + grpc_core::UniquePtr localaddr; + grpc_channel_args* client_args_compression = nullptr; + grpc_channel_args* server_args_compression = nullptr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_compression( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_compression_fixture_data* ffd = - static_cast( - gpr_malloc(sizeof(fullstack_compression_fixture_data))); - memset(ffd, 0, sizeof(fullstack_compression_fixture_data)); - - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::New(); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); memset(&f, 0, sizeof(f)); f.fixture_data = ffd; @@ -73,7 +74,7 @@ void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture* f, grpc_channel_args_set_channel_default_compression_algorithm( client_args, GRPC_COMPRESS_GZIP); f->client = grpc_insecure_channel_create( - ffd->localaddr, ffd->client_args_compression, nullptr); + ffd->localaddr.get(), ffd->client_args_compression, nullptr); } void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture* f, @@ -92,7 +93,8 @@ void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture* f, } f->server = grpc_server_create(ffd->server_args_compression, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); + GPR_ASSERT( + grpc_server_add_insecure_http2_port(f->server, ffd->localaddr.get())); grpc_server_start(f->server); } @@ -100,10 +102,7 @@ void chttp2_tear_down_fullstack_compression(grpc_end2end_test_fixture* f) { grpc_core::ExecCtx exec_ctx; fullstack_compression_fixture_data* ffd = static_cast(f->fixture_data); - grpc_channel_args_destroy(ffd->client_args_compression); - grpc_channel_args_destroy(ffd->server_args_compression); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_fakesec.cc b/test/core/end2end/fixtures/h2_fakesec.cc index ad83aab39f4..1375549ed6c 100644 --- a/test/core/end2end/fixtures/h2_fakesec.cc +++ b/test/core/end2end/fixtures/h2_fakesec.cc @@ -25,26 +25,24 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_secure_fixture_data { - char* localaddr; -} fullstack_secure_fixture_data; +struct fullstack_secure_fixture_data { + grpc_core::UniquePtr localaddr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = - static_cast( - gpr_malloc(sizeof(fullstack_secure_fixture_data))); - + grpc_core::New(); memset(&f, 0, sizeof(f)); - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -66,8 +64,8 @@ static void chttp2_init_client_secure_fullstack( grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - f->client = - grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); + f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), + client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -82,7 +80,7 @@ static void chttp2_init_server_secure_fullstack( } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); @@ -91,8 +89,7 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } static void chttp2_init_client_fake_secure_fullstack( diff --git a/test/core/end2end/fixtures/h2_full+pipe.cc b/test/core/end2end/fixtures/h2_full+pipe.cc index 6d559c4e516..ac4913674f0 100644 --- a/test/core/end2end/fixtures/h2_full+pipe.cc +++ b/test/core/end2end/fixtures/h2_full+pipe.cc @@ -33,26 +33,25 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_fixture_data { - char* localaddr; -} fullstack_fixture_data; +struct fullstack_fixture_data { + grpc_core::UniquePtr localaddr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = static_cast( - gpr_malloc(sizeof(fullstack_fixture_data))); + fullstack_fixture_data* ffd = grpc_core::New(); memset(&f, 0, sizeof(f)); - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -66,7 +65,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, fullstack_fixture_data* ffd = static_cast(f->fixture_data); f->client = - grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr); + grpc_insecure_channel_create(ffd->localaddr.get(), client_args, nullptr); GPR_ASSERT(f->client); } @@ -79,15 +78,15 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); + GPR_ASSERT( + grpc_server_add_insecure_http2_port(f->server, ffd->localaddr.get())); grpc_server_start(f->server); } void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_full+trace.cc b/test/core/end2end/fixtures/h2_full+trace.cc index b8dbe261183..04de2a20182 100644 --- a/test/core/end2end/fixtures/h2_full+trace.cc +++ b/test/core/end2end/fixtures/h2_full+trace.cc @@ -34,25 +34,24 @@ #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/debug/trace.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_fixture_data { - char* localaddr; -} fullstack_fixture_data; +struct fullstack_fixture_data { + grpc_core::UniquePtr localaddr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = static_cast( - gpr_malloc(sizeof(fullstack_fixture_data))); + fullstack_fixture_data* ffd = grpc_core::New(); memset(&f, 0, sizeof(f)); - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -66,7 +65,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, fullstack_fixture_data* ffd = static_cast(f->fixture_data); f->client = - grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr); + grpc_insecure_channel_create(ffd->localaddr.get(), client_args, nullptr); GPR_ASSERT(f->client); } @@ -79,15 +78,15 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); + GPR_ASSERT( + grpc_server_add_insecure_http2_port(f->server, ffd->localaddr.get())); grpc_server_start(f->server); } void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_full+workarounds.cc b/test/core/end2end/fixtures/h2_full+workarounds.cc index cb0f7d275b3..8cfba4587e0 100644 --- a/test/core/end2end/fixtures/h2_full+workarounds.cc +++ b/test/core/end2end/fixtures/h2_full+workarounds.cc @@ -30,7 +30,7 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" @@ -39,24 +39,20 @@ static char* workarounds_arg[GRPC_MAX_WORKAROUND_ID] = { const_cast(GRPC_ARG_WORKAROUND_CRONET_COMPRESSION)}; -typedef struct fullstack_fixture_data { - char* localaddr; -} fullstack_fixture_data; +struct fullstack_fixture_data { + grpc_core::UniquePtr localaddr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = static_cast( - gpr_malloc(sizeof(fullstack_fixture_data))); + fullstack_fixture_data* ffd = grpc_core::New(); memset(&f, 0, sizeof(f)); - - gpr_join_host_port(&ffd->localaddr, "localhost", port); - + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr); - return f; } @@ -65,7 +61,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, fullstack_fixture_data* ffd = static_cast(f->fixture_data); f->client = - grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr); + grpc_insecure_channel_create(ffd->localaddr.get(), client_args, nullptr); GPR_ASSERT(f->client); } @@ -88,7 +84,8 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, } f->server = grpc_server_create(server_args_new, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); + GPR_ASSERT( + grpc_server_add_insecure_http2_port(f->server, ffd->localaddr.get())); grpc_server_start(f->server); grpc_channel_args_destroy(server_args_new); } @@ -96,8 +93,7 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_full.cc b/test/core/end2end/fixtures/h2_full.cc index c0d21288c7e..a3f2f25db5f 100644 --- a/test/core/end2end/fixtures/h2_full.cc +++ b/test/core/end2end/fixtures/h2_full.cc @@ -28,25 +28,24 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_fixture_data { - char* localaddr; -} fullstack_fixture_data; +struct fullstack_fixture_data { + grpc_core::UniquePtr localaddr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = static_cast( - gpr_malloc(sizeof(fullstack_fixture_data))); + fullstack_fixture_data* ffd = grpc_core::New(); memset(&f, 0, sizeof(f)); - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -60,7 +59,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, fullstack_fixture_data* ffd = static_cast(f->fixture_data); f->client = - grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr); + grpc_insecure_channel_create(ffd->localaddr.get(), client_args, nullptr); GPR_ASSERT(f->client); } @@ -73,15 +72,15 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); + GPR_ASSERT( + grpc_server_add_insecure_http2_port(f->server, ffd->localaddr.get())); grpc_server_start(f->server); } void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_http_proxy.cc b/test/core/end2end/fixtures/h2_http_proxy.cc index 9b6a81494e1..18ba0e7f847 100644 --- a/test/core/end2end/fixtures/h2_http_proxy.cc +++ b/test/core/end2end/fixtures/h2_http_proxy.cc @@ -30,26 +30,26 @@ #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/gpr/env.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/end2end/fixtures/http_proxy_fixture.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_fixture_data { - char* server_addr; - grpc_end2end_http_proxy* proxy; -} fullstack_fixture_data; +struct fullstack_fixture_data { + ~fullstack_fixture_data() { grpc_end2end_http_proxy_destroy(proxy); } + grpc_core::UniquePtr server_addr; + grpc_end2end_http_proxy* proxy = nullptr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); - fullstack_fixture_data* ffd = static_cast( - gpr_malloc(sizeof(fullstack_fixture_data))); + fullstack_fixture_data* ffd = grpc_core::New(); const int server_port = grpc_pick_unused_port_or_die(); - gpr_join_host_port(&ffd->server_addr, "localhost", server_port); + grpc_core::JoinHostPort(&ffd->server_addr, "localhost", server_port); /* Passing client_args to proxy_create for the case of checking for proxy auth */ @@ -81,8 +81,8 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, } gpr_setenv("http_proxy", proxy_uri); gpr_free(proxy_uri); - f->client = - grpc_insecure_channel_create(ffd->server_addr, client_args, nullptr); + f->client = grpc_insecure_channel_create(ffd->server_addr.get(), client_args, + nullptr); GPR_ASSERT(f->client); } @@ -95,16 +95,15 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->server_addr)); + GPR_ASSERT( + grpc_server_add_insecure_http2_port(f->server, ffd->server_addr.get())); grpc_server_start(f->server); } void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->server_addr); - grpc_end2end_http_proxy_destroy(ffd->proxy); - gpr_free(ffd); + grpc_core::Delete(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_local_ipv4.cc b/test/core/end2end/fixtures/h2_local_ipv4.cc index f6996bf6be3..e27844be2df 100644 --- a/test/core/end2end/fixtures/h2_local_ipv4.cc +++ b/test/core/end2end/fixtures/h2_local_ipv4.cc @@ -20,7 +20,7 @@ #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "test/core/end2end/end2end_tests.h" #include "test/core/end2end/fixtures/local_util.h" #include "test/core/util/port.h" @@ -31,7 +31,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_ipv4( grpc_end2end_test_fixture f = grpc_end2end_local_chttp2_create_fixture_fullstack(); int port = grpc_pick_unused_port_or_die(); - gpr_join_host_port( + grpc_core::JoinHostPort( &static_cast(f.fixture_data) ->localaddr, "127.0.0.1", port); diff --git a/test/core/end2end/fixtures/h2_local_ipv6.cc b/test/core/end2end/fixtures/h2_local_ipv6.cc index e360727ca82..91acaa347f6 100644 --- a/test/core/end2end/fixtures/h2_local_ipv6.cc +++ b/test/core/end2end/fixtures/h2_local_ipv6.cc @@ -20,7 +20,7 @@ #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "test/core/end2end/end2end_tests.h" #include "test/core/end2end/fixtures/local_util.h" #include "test/core/util/port.h" @@ -31,7 +31,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_ipv6( grpc_end2end_test_fixture f = grpc_end2end_local_chttp2_create_fixture_fullstack(); int port = grpc_pick_unused_port_or_die(); - gpr_join_host_port( + grpc_core::JoinHostPort( &static_cast(f.fixture_data) ->localaddr, "[::1]", port); diff --git a/test/core/end2end/fixtures/h2_local_uds.cc b/test/core/end2end/fixtures/h2_local_uds.cc index f1bce213dc2..6c748896760 100644 --- a/test/core/end2end/fixtures/h2_local_uds.cc +++ b/test/core/end2end/fixtures/h2_local_uds.cc @@ -30,10 +30,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_uds( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f = grpc_end2end_local_chttp2_create_fixture_fullstack(); - gpr_asprintf( - &static_cast(f.fixture_data) - ->localaddr, - "unix:/tmp/grpc_fullstack_test.%d.%d", getpid(), unique++); + char* out = nullptr; + gpr_asprintf(&out, "unix:/tmp/grpc_fullstack_test.%d.%d", getpid(), unique++); + static_cast(f.fixture_data) + ->localaddr.reset(out); return f; } diff --git a/test/core/end2end/fixtures/h2_oauth2.cc b/test/core/end2end/fixtures/h2_oauth2.cc index 113a6b11732..513fded4b62 100644 --- a/test/core/end2end/fixtures/h2_oauth2.cc +++ b/test/core/end2end/fixtures/h2_oauth2.cc @@ -25,7 +25,7 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/security/credentials/credentials.h" #include "test/core/end2end/data/ssl_test_data.h" @@ -36,9 +36,9 @@ static const char oauth2_md[] = "Bearer aaslkfjs424535asdf"; static const char* client_identity_property_name = "smurf_name"; static const char* client_identity = "Brainy Smurf"; -typedef struct fullstack_secure_fixture_data { - char* localaddr; -} fullstack_secure_fixture_data; +struct fullstack_secure_fixture_data { + grpc_core::UniquePtr localaddr; +}; static const grpc_metadata* find_metadata(const grpc_metadata* md, size_t md_count, const char* key, @@ -95,16 +95,12 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = - static_cast( - gpr_malloc(sizeof(fullstack_secure_fixture_data))); + grpc_core::New(); memset(&f, 0, sizeof(f)); - - gpr_join_host_port(&ffd->localaddr, "localhost", port); - + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr); - return f; } @@ -113,8 +109,8 @@ static void chttp2_init_client_secure_fullstack( grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - f->client = - grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); + f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), + client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -129,7 +125,7 @@ static void chttp2_init_server_secure_fullstack( } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); @@ -138,8 +134,7 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack( diff --git a/test/core/end2end/fixtures/h2_proxy.cc b/test/core/end2end/fixtures/h2_proxy.cc index e334396ea7c..f0ada89d14d 100644 --- a/test/core/end2end/fixtures/h2_proxy.cc +++ b/test/core/end2end/fixtures/h2_proxy.cc @@ -28,7 +28,6 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/end2end/fixtures/proxy.h" diff --git a/test/core/end2end/fixtures/h2_spiffe.cc b/test/core/end2end/fixtures/h2_spiffe.cc index cdf091bac10..4352ef640cd 100644 --- a/test/core/end2end/fixtures/h2_spiffe.cc +++ b/test/core/end2end/fixtures/h2_spiffe.cc @@ -28,9 +28,9 @@ #include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/env.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/security/credentials/credentials.h" @@ -42,10 +42,15 @@ typedef grpc_core::InlinedVector ThreadList; -typedef struct fullstack_secure_fixture_data { - char* localaddr; +struct fullstack_secure_fixture_data { + ~fullstack_secure_fixture_data() { + for (size_t ind = 0; ind < thd_list.size(); ind++) { + thd_list[ind].Join(); + } + } + grpc_core::UniquePtr localaddr; ThreadList thd_list; -} fullstack_secure_fixture_data; +}; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { @@ -54,7 +59,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( fullstack_secure_fixture_data* ffd = grpc_core::New(); memset(&f, 0, sizeof(f)); - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr); @@ -74,8 +79,8 @@ static void chttp2_init_client_secure_fullstack( grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - f->client = - grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); + f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), + client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -90,7 +95,7 @@ static void chttp2_init_server_secure_fullstack( } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); @@ -99,10 +104,6 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - for (size_t ind = 0; ind < ffd->thd_list.size(); ind++) { - ffd->thd_list[ind].Join(); - } - gpr_free(ffd->localaddr); grpc_core::Delete(ffd); } diff --git a/test/core/end2end/fixtures/h2_ssl.cc b/test/core/end2end/fixtures/h2_ssl.cc index 3fc9bc7f329..cb55bb72061 100644 --- a/test/core/end2end/fixtures/h2_ssl.cc +++ b/test/core/end2end/fixtures/h2_ssl.cc @@ -25,29 +25,28 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_secure_fixture_data { - char* localaddr; -} fullstack_secure_fixture_data; +struct fullstack_secure_fixture_data { + grpc_core::UniquePtr localaddr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = - static_cast( - gpr_malloc(sizeof(fullstack_secure_fixture_data))); + grpc_core::New(); memset(&f, 0, sizeof(f)); - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -69,8 +68,8 @@ static void chttp2_init_client_secure_fullstack( grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - f->client = - grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); + f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), + client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -85,7 +84,7 @@ static void chttp2_init_server_secure_fullstack( } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); @@ -94,8 +93,7 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } static void chttp2_init_client_simple_ssl_secure_fullstack( diff --git a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc index 1d54a431364..2a9591845b9 100644 --- a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc +++ b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc @@ -25,19 +25,19 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_secure_fixture_data { - char* localaddr; - bool server_credential_reloaded; -} fullstack_secure_fixture_data; +struct fullstack_secure_fixture_data { + grpc_core::UniquePtr localaddr; + bool server_credential_reloaded = false; +}; static grpc_ssl_certificate_config_reload_status ssl_server_certificate_config_callback( @@ -64,10 +64,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = - static_cast( - gpr_malloc(sizeof(fullstack_secure_fixture_data))); + grpc_core::New(); memset(&f, 0, sizeof(f)); - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -89,8 +88,8 @@ static void chttp2_init_client_secure_fullstack( grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - f->client = - grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); + f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), + client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -106,7 +105,7 @@ static void chttp2_init_server_secure_fullstack( ffd->server_credential_reloaded = false; f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); @@ -115,8 +114,7 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } static void chttp2_init_client_simple_ssl_secure_fullstack( diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.cc b/test/core/end2end/fixtures/h2_ssl_proxy.cc index d5f695b1575..b16ffa1b8b8 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.cc +++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc @@ -25,7 +25,6 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" diff --git a/test/core/end2end/fixtures/h2_uds.cc b/test/core/end2end/fixtures/h2_uds.cc index f251bbd28c5..2b6c73d39c7 100644 --- a/test/core/end2end/fixtures/h2_uds.cc +++ b/test/core/end2end/fixtures/h2_uds.cc @@ -31,7 +31,6 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc index 6b5513f160e..da2381aa0a0 100644 --- a/test/core/end2end/fixtures/http_proxy_fixture.cc +++ b/test/core/end2end/fixtures/http_proxy_fixture.cc @@ -31,8 +31,8 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/http/parser.h" #include "src/core/lib/iomgr/closure.h" @@ -53,8 +53,7 @@ struct grpc_end2end_http_proxy { grpc_end2end_http_proxy() - : proxy_name(nullptr), - server(nullptr), + : server(nullptr), channel_args(nullptr), mu(nullptr), pollset(nullptr), @@ -62,7 +61,7 @@ struct grpc_end2end_http_proxy { gpr_ref_init(&users, 1); combiner = grpc_combiner_create(); } - char* proxy_name; + grpc_core::UniquePtr proxy_name; grpc_core::Thread thd; grpc_tcp_server* server; grpc_channel_args* channel_args; @@ -532,8 +531,8 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create( grpc_end2end_http_proxy* proxy = grpc_core::New(); // Construct proxy address. const int proxy_port = grpc_pick_unused_port_or_die(); - gpr_join_host_port(&proxy->proxy_name, "localhost", proxy_port); - gpr_log(GPR_INFO, "Proxy address: %s", proxy->proxy_name); + grpc_core::JoinHostPort(&proxy->proxy_name, "localhost", proxy_port); + gpr_log(GPR_INFO, "Proxy address: %s", proxy->proxy_name.get()); // Create TCP server. proxy->channel_args = grpc_channel_args_copy(args); grpc_error* error = @@ -573,7 +572,6 @@ void grpc_end2end_http_proxy_destroy(grpc_end2end_http_proxy* proxy) { proxy->thd.Join(); grpc_tcp_server_shutdown_listeners(proxy->server); grpc_tcp_server_unref(proxy->server); - gpr_free(proxy->proxy_name); grpc_channel_args_destroy(proxy->channel_args); grpc_pollset_shutdown(proxy->pollset, GRPC_CLOSURE_CREATE(destroy_pollset, proxy->pollset, @@ -584,5 +582,5 @@ void grpc_end2end_http_proxy_destroy(grpc_end2end_http_proxy* proxy) { const char* grpc_end2end_http_proxy_get_proxy_name( grpc_end2end_http_proxy* proxy) { - return proxy->proxy_name; + return proxy->proxy_name.get(); } diff --git a/test/core/end2end/fixtures/inproc.cc b/test/core/end2end/fixtures/inproc.cc index dadf3ef455d..70cc6b05479 100644 --- a/test/core/end2end/fixtures/inproc.cc +++ b/test/core/end2end/fixtures/inproc.cc @@ -28,7 +28,6 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/inproc/inproc_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/local_util.cc b/test/core/end2end/fixtures/local_util.cc index 5f0b0300ac0..767f3a28ef8 100644 --- a/test/core/end2end/fixtures/local_util.cc +++ b/test/core/end2end/fixtures/local_util.cc @@ -27,7 +27,6 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/surface/server.h" @@ -37,8 +36,7 @@ grpc_end2end_test_fixture grpc_end2end_local_chttp2_create_fixture_fullstack() { grpc_end2end_test_fixture f; grpc_end2end_local_fullstack_fixture_data* ffd = - static_cast( - gpr_malloc(sizeof(grpc_end2end_local_fullstack_fixture_data))); + grpc_core::New(); memset(&f, 0, sizeof(f)); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -52,8 +50,8 @@ void grpc_end2end_local_chttp2_init_client_fullstack( grpc_channel_credentials* creds = grpc_local_credentials_create(type); grpc_end2end_local_fullstack_fixture_data* ffd = static_cast(f->fixture_data); - f->client = - grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); + f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), + client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -99,8 +97,8 @@ void grpc_end2end_local_chttp2_init_server_fullstack( nullptr}; grpc_server_credentials_set_auth_metadata_processor(creds, processor); } - GPR_ASSERT( - grpc_server_add_secure_http2_port(f->server, ffd->localaddr, creds)); + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), + creds)); grpc_server_credentials_release(creds); grpc_server_start(f->server); } @@ -109,6 +107,5 @@ void grpc_end2end_local_chttp2_tear_down_fullstack( grpc_end2end_test_fixture* f) { grpc_end2end_local_fullstack_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } diff --git a/test/core/end2end/fixtures/local_util.h b/test/core/end2end/fixtures/local_util.h index f133b4d977e..df204d2fab2 100644 --- a/test/core/end2end/fixtures/local_util.h +++ b/test/core/end2end/fixtures/local_util.h @@ -22,9 +22,9 @@ #include "src/core/lib/surface/channel.h" -typedef struct grpc_end2end_local_fullstack_fixture_data { - char* localaddr; -} grpc_end2end_local_fullstack_fixture_data; +struct grpc_end2end_local_fullstack_fixture_data { + grpc_core::UniquePtr localaddr; +}; /* Utility functions shared by h2_local tests. */ grpc_end2end_test_fixture grpc_end2end_local_chttp2_create_fixture_fullstack(); diff --git a/test/core/end2end/fixtures/proxy.cc b/test/core/end2end/fixtures/proxy.cc index 869b6e846d3..4ae7450b0df 100644 --- a/test/core/end2end/fixtures/proxy.cc +++ b/test/core/end2end/fixtures/proxy.cc @@ -24,16 +24,15 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/thd.h" #include "test/core/util/port.h" struct grpc_end2end_proxy { grpc_end2end_proxy() - : proxy_port(nullptr), - server_port(nullptr), - cq(nullptr), + : cq(nullptr), server(nullptr), client(nullptr), shutdown(false), @@ -42,8 +41,8 @@ struct grpc_end2end_proxy { memset(&new_call_metadata, 0, sizeof(new_call_metadata)); } grpc_core::Thread thd; - char* proxy_port; - char* server_port; + grpc_core::UniquePtr proxy_port; + grpc_core::UniquePtr server_port; grpc_completion_queue* cq; grpc_server* server; grpc_channel* client; @@ -92,15 +91,15 @@ grpc_end2end_proxy* grpc_end2end_proxy_create(const grpc_end2end_proxy_def* def, grpc_end2end_proxy* proxy = grpc_core::New(); - gpr_join_host_port(&proxy->proxy_port, "localhost", proxy_port); - gpr_join_host_port(&proxy->server_port, "localhost", server_port); + grpc_core::JoinHostPort(&proxy->proxy_port, "localhost", proxy_port); + grpc_core::JoinHostPort(&proxy->server_port, "localhost", server_port); - gpr_log(GPR_DEBUG, "PROXY ADDR:%s BACKEND:%s", proxy->proxy_port, - proxy->server_port); + gpr_log(GPR_DEBUG, "PROXY ADDR:%s BACKEND:%s", proxy->proxy_port.get(), + proxy->server_port.get()); proxy->cq = grpc_completion_queue_create_for_next(nullptr); - proxy->server = def->create_server(proxy->proxy_port, server_args); - proxy->client = def->create_client(proxy->server_port, client_args); + proxy->server = def->create_server(proxy->proxy_port.get(), server_args); + proxy->client = def->create_client(proxy->server_port.get(), client_args); grpc_server_register_completion_queue(proxy->server, proxy->cq, nullptr); grpc_server_start(proxy->server); @@ -131,8 +130,6 @@ void grpc_end2end_proxy_destroy(grpc_end2end_proxy* proxy) { grpc_server_shutdown_and_notify(proxy->server, proxy->cq, new_closure(shutdown_complete, proxy)); proxy->thd.Join(); - gpr_free(proxy->proxy_port); - gpr_free(proxy->server_port); grpc_server_destroy(proxy->server); grpc_channel_destroy(proxy->client); grpc_completion_queue_destroy(proxy->cq); @@ -441,9 +438,9 @@ static void thread_main(void* arg) { } const char* grpc_end2end_proxy_get_client_target(grpc_end2end_proxy* proxy) { - return proxy->proxy_port; + return proxy->proxy_port.get(); } const char* grpc_end2end_proxy_get_server_port(grpc_end2end_proxy* proxy) { - return proxy->server_port; + return proxy->server_port.get(); } diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc index e9285778a2d..34a9ef760b5 100644 --- a/test/core/end2end/h2_ssl_cert_test.cc +++ b/test/core/end2end/h2_ssl_cert_test.cc @@ -25,9 +25,9 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/cq_verifier.h" @@ -40,20 +40,19 @@ namespace grpc { namespace testing { -typedef struct fullstack_secure_fixture_data { - char* localaddr; -} fullstack_secure_fixture_data; +struct fullstack_secure_fixture_data { + grpc_core::UniquePtr localaddr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = - static_cast( - gpr_malloc(sizeof(fullstack_secure_fixture_data))); + grpc_core::New(); memset(&f, 0, sizeof(f)); - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -73,8 +72,8 @@ static void chttp2_init_client_secure_fullstack( grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - f->client = - grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); + f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), + client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -89,7 +88,7 @@ static void chttp2_init_server_secure_fullstack( } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); @@ -98,8 +97,7 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } static int fail_server_auth_check(grpc_channel_args* server_args) { diff --git a/test/core/end2end/h2_ssl_session_reuse_test.cc b/test/core/end2end/h2_ssl_session_reuse_test.cc index b2d0a5e1133..6ffc138820e 100644 --- a/test/core/end2end/h2_ssl_session_reuse_test.cc +++ b/test/core/end2end/h2_ssl_session_reuse_test.cc @@ -25,9 +25,9 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/cq_verifier.h" @@ -215,19 +215,18 @@ void drain_cq(grpc_completion_queue* cq) { TEST(H2SessionReuseTest, SingleReuse) { int port = grpc_pick_unused_port_or_die(); - char* server_addr; - gpr_join_host_port(&server_addr, "localhost", port); + grpc_core::UniquePtr server_addr; + grpc_core::JoinHostPort(&server_addr, "localhost", port); grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); grpc_ssl_session_cache* cache = grpc_ssl_session_cache_create_lru(16); - grpc_server* server = server_create(cq, server_addr); + grpc_server* server = server_create(cq, server_addr.get()); - do_round_trip(cq, server, server_addr, cache, false); - do_round_trip(cq, server, server_addr, cache, true); - do_round_trip(cq, server, server_addr, cache, true); + do_round_trip(cq, server, server_addr.get(), cache, false); + do_round_trip(cq, server, server_addr.get(), cache, true); + do_round_trip(cq, server, server_addr.get(), cache, true); - gpr_free(server_addr); grpc_ssl_session_cache_destroy(cache); GPR_ASSERT(grpc_completion_queue_next( diff --git a/test/core/end2end/invalid_call_argument_test.cc b/test/core/end2end/invalid_call_argument_test.cc index bd28d192984..5f920fad638 100644 --- a/test/core/end2end/invalid_call_argument_test.cc +++ b/test/core/end2end/invalid_call_argument_test.cc @@ -25,7 +25,8 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gprpp/memory.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -54,7 +55,6 @@ static struct test_state g_state; static void prepare_test(int is_client) { int port = grpc_pick_unused_port_or_die(); - char* server_hostport; grpc_op* op; g_state.is_client = is_client; grpc_metadata_array_init(&g_state.initial_metadata_recv); @@ -77,14 +77,13 @@ static void prepare_test(int is_client) { } else { g_state.server = grpc_server_create(nullptr, nullptr); grpc_server_register_completion_queue(g_state.server, g_state.cq, nullptr); - gpr_join_host_port(&server_hostport, "0.0.0.0", port); - grpc_server_add_insecure_http2_port(g_state.server, server_hostport); + grpc_core::UniquePtr server_hostport; + grpc_core::JoinHostPort(&server_hostport, "0.0.0.0", port); + grpc_server_add_insecure_http2_port(g_state.server, server_hostport.get()); grpc_server_start(g_state.server); - gpr_free(server_hostport); - gpr_join_host_port(&server_hostport, "localhost", port); + grpc_core::JoinHostPort(&server_hostport, "localhost", port); g_state.chan = - grpc_insecure_channel_create(server_hostport, nullptr, nullptr); - gpr_free(server_hostport); + grpc_insecure_channel_create(server_hostport.get(), nullptr, nullptr); grpc_slice host = grpc_slice_from_static_string("bar"); g_state.call = grpc_channel_create_call( g_state.chan, nullptr, GRPC_PROPAGATE_DEFAULTS, g_state.cq, diff --git a/test/core/fling/fling_stream_test.cc b/test/core/fling/fling_stream_test.cc index 32bc9896414..474b4fbbc3b 100644 --- a/test/core/fling/fling_stream_test.cc +++ b/test/core/fling/fling_stream_test.cc @@ -22,8 +22,8 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" @@ -46,23 +46,24 @@ int main(int argc, char** argv) { gpr_asprintf(&args[0], "%s/fling_server%s", root, gpr_subprocess_binary_extension()); args[1] = const_cast("--bind"); - gpr_join_host_port(&args[2], "::", port); + grpc_core::UniquePtr joined; + grpc_core::JoinHostPort(&joined, "::", port); + args[2] = joined.get(); args[3] = const_cast("--no-secure"); svr = gpr_subprocess_create(4, (const char**)args); gpr_free(args[0]); - gpr_free(args[2]); /* start the client */ gpr_asprintf(&args[0], "%s/fling_client%s", root, gpr_subprocess_binary_extension()); args[1] = const_cast("--target"); - gpr_join_host_port(&args[2], "127.0.0.1", port); + grpc_core::JoinHostPort(&joined, "127.0.0.1", port); + args[2] = joined.get(); args[3] = const_cast("--scenario=ping-pong-stream"); args[4] = const_cast("--no-secure"); args[5] = nullptr; cli = gpr_subprocess_create(6, (const char**)args); gpr_free(args[0]); - gpr_free(args[2]); /* wait for completion */ printf("waiting for client\n"); diff --git a/test/core/fling/fling_test.cc b/test/core/fling/fling_test.cc index 3587a4acaae..3667d48f010 100644 --- a/test/core/fling/fling_test.cc +++ b/test/core/fling/fling_test.cc @@ -22,8 +22,9 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gprpp/memory.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" @@ -46,23 +47,24 @@ int main(int argc, const char** argv) { gpr_asprintf(&args[0], "%s/fling_server%s", root, gpr_subprocess_binary_extension()); args[1] = const_cast("--bind"); - gpr_join_host_port(&args[2], "::", port); + grpc_core::UniquePtr joined; + grpc_core::JoinHostPort(&joined, "::", port); + args[2] = joined.get(); args[3] = const_cast("--no-secure"); svr = gpr_subprocess_create(4, (const char**)args); gpr_free(args[0]); - gpr_free(args[2]); /* start the client */ gpr_asprintf(&args[0], "%s/fling_client%s", root, gpr_subprocess_binary_extension()); args[1] = const_cast("--target"); - gpr_join_host_port(&args[2], "127.0.0.1", port); + grpc_core::JoinHostPort(&joined, "127.0.0.1", port); + args[2] = joined.get(); args[3] = const_cast("--scenario=ping-pong-request"); args[4] = const_cast("--no-secure"); args[5] = nullptr; cli = gpr_subprocess_create(6, (const char**)args); gpr_free(args[0]); - gpr_free(args[2]); /* wait for completion */ printf("waiting for client\n"); diff --git a/test/core/fling/server.cc b/test/core/fling/server.cc index cf7e2465d9e..241ac71bc7d 100644 --- a/test/core/fling/server.cc +++ b/test/core/fling/server.cc @@ -33,7 +33,7 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/profiling/timers.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/cmdline.h" @@ -172,7 +172,7 @@ static void sigint_handler(int x) { _exit(0); } int main(int argc, char** argv) { grpc_event ev; call_state* s; - char* addr_buf = nullptr; + grpc_core::UniquePtr addr_buf; gpr_cmdline* cl; grpc_completion_queue* shutdown_cq; int shutdown_started = 0; @@ -199,8 +199,8 @@ int main(int argc, char** argv) { gpr_cmdline_destroy(cl); if (addr == nullptr) { - gpr_join_host_port(&addr_buf, "::", grpc_pick_unused_port_or_die()); - addr = addr_buf; + grpc_core::JoinHostPort(&addr_buf, "::", grpc_pick_unused_port_or_die()); + addr = addr_buf.get(); } gpr_log(GPR_INFO, "creating server on: %s", addr); @@ -220,8 +220,8 @@ int main(int argc, char** argv) { grpc_server_register_completion_queue(server, cq, nullptr); grpc_server_start(server); - gpr_free(addr_buf); - addr = addr_buf = nullptr; + addr = nullptr; + addr_buf.reset(); grpc_call_details_init(&call_details); diff --git a/test/core/gpr/BUILD b/test/core/gpr/BUILD index 434d55e0451..c2b2576ff03 100644 --- a/test/core/gpr/BUILD +++ b/test/core/gpr/BUILD @@ -58,16 +58,6 @@ grpc_cc_test( ], ) -grpc_cc_test( - name = "host_port_test", - srcs = ["host_port_test.cc"], - language = "C++", - deps = [ - "//:gpr", - "//test/core/util:grpc_test_util", - ], -) - grpc_cc_test( name = "log_test", srcs = ["log_test.cc"], diff --git a/test/core/gprpp/BUILD b/test/core/gprpp/BUILD index cd3232addfd..5cee96a3ad2 100644 --- a/test/core/gprpp/BUILD +++ b/test/core/gprpp/BUILD @@ -64,6 +64,16 @@ grpc_cc_test( ], ) +grpc_cc_test( + name = "host_port_test", + srcs = ["host_port_test.cc"], + language = "C++", + deps = [ + "//:gpr", + "//test/core/util:grpc_test_util", + ], +) + grpc_cc_test( name = "grpc_core_map_test", srcs = ["map_test.cc"], @@ -156,6 +166,19 @@ grpc_cc_test( ], ) +grpc_cc_test( + name = "string_view_test", + srcs = ["string_view_test.cc"], + external_deps = [ + "gtest", + ], + language = "C++", + deps = [ + "//:gpr_base", + "//test/core/util:grpc_test_util", + ], +) + grpc_cc_test( name = "thd_test", srcs = ["thd_test.cc"], diff --git a/test/core/gpr/host_port_test.cc b/test/core/gprpp/host_port_test.cc similarity index 86% rename from test/core/gpr/host_port_test.cc rename to test/core/gprpp/host_port_test.cc index b01bbf4b695..3474e6dc494 100644 --- a/test/core/gpr/host_port_test.cc +++ b/test/core/gprpp/host_port_test.cc @@ -21,18 +21,17 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "test/core/util/test_config.h" static void join_host_port_expect(const char* host, int port, const char* expected) { - char* buf; + grpc_core::UniquePtr buf; int len; - len = gpr_join_host_port(&buf, host, port); + len = grpc_core::JoinHostPort(&buf, host, port); GPR_ASSERT(len >= 0); - GPR_ASSERT(strlen(expected) == (size_t)len); - GPR_ASSERT(strcmp(expected, buf) == 0); - gpr_free(buf); + GPR_ASSERT(strlen(expected) == static_cast(len)); + GPR_ASSERT(strcmp(expected, buf.get()) == 0); } static void test_join_host_port(void) { diff --git a/test/core/gprpp/string_view_test.cc b/test/core/gprpp/string_view_test.cc new file mode 100644 index 00000000000..1c8adb1db14 --- /dev/null +++ b/test/core/gprpp/string_view_test.cc @@ -0,0 +1,163 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/gprpp/string_view.h" + +#include +#include "src/core/lib/gprpp/memory.h" +#include "test/core/util/test_config.h" + +namespace grpc_core { +namespace testing { + +TEST(StringViewTest, Empty) { + grpc_core::StringView empty; + EXPECT_TRUE(empty.empty()); + EXPECT_EQ(empty.size(), 0lu); + + grpc_core::StringView empty_buf(""); + EXPECT_TRUE(empty_buf.empty()); + EXPECT_EQ(empty_buf.size(), 0lu); + + grpc_core::StringView empty_trimmed("foo", 0); + EXPECT_TRUE(empty_trimmed.empty()); + EXPECT_EQ(empty_trimmed.size(), 0lu); + + grpc_core::StringView empty_slice(grpc_empty_slice()); + EXPECT_TRUE(empty_slice.empty()); + EXPECT_EQ(empty_slice.size(), 0lu); +} + +TEST(StringViewTest, Size) { + constexpr char kStr[] = "foo"; + grpc_core::StringView str1(kStr); + EXPECT_EQ(str1.size(), strlen(kStr)); + grpc_core::StringView str2(kStr, 2); + EXPECT_EQ(str2.size(), 2lu); +} + +TEST(StringViewTest, Data) { + constexpr char kStr[] = "foo-bar"; + grpc_core::StringView str(kStr); + EXPECT_EQ(str.size(), strlen(kStr)); + for (size_t i = 0; i < strlen(kStr); ++i) { + EXPECT_EQ(str[i], kStr[i]); + } +} + +TEST(StringViewTest, Slice) { + constexpr char kStr[] = "foo"; + grpc_core::StringView slice(grpc_slice_from_static_string(kStr)); + EXPECT_EQ(slice.size(), strlen(kStr)); +} + +TEST(StringViewTest, Dup) { + constexpr char kStr[] = "foo"; + grpc_core::StringView slice(grpc_slice_from_static_string(kStr)); + grpc_core::UniquePtr dup = slice.dup(); + EXPECT_EQ(0, strcmp(kStr, dup.get())); + EXPECT_EQ(slice.size(), strlen(kStr)); +} + +TEST(StringViewTest, Eq) { + constexpr char kStr1[] = "foo"; + constexpr char kStr2[] = "bar"; + grpc_core::StringView str1(kStr1); + EXPECT_EQ(kStr1, str1); + EXPECT_EQ(str1, kStr1); + grpc_core::StringView slice1(grpc_slice_from_static_string(kStr1)); + EXPECT_EQ(slice1, str1); + EXPECT_EQ(str1, slice1); + EXPECT_NE(slice1, kStr2); + EXPECT_NE(kStr2, slice1); + grpc_core::StringView slice2(grpc_slice_from_static_string(kStr2)); + EXPECT_NE(slice2, str1); + EXPECT_NE(str1, slice2); +} + +TEST(StringViewTest, Cmp) { + constexpr char kStr1[] = "abc"; + constexpr char kStr2[] = "abd"; + constexpr char kStr3[] = "abcd"; + grpc_core::StringView str1(kStr1); + grpc_core::StringView str2(kStr2); + grpc_core::StringView str3(kStr3); + EXPECT_EQ(str1.cmp(str1), 0); + EXPECT_LT(str1.cmp(str2), 0); + EXPECT_LT(str1.cmp(str3), 0); + EXPECT_EQ(str2.cmp(str2), 0); + EXPECT_GT(str2.cmp(str1), 0); + EXPECT_GT(str2.cmp(str3), 0); + EXPECT_EQ(str3.cmp(str3), 0); + EXPECT_GT(str3.cmp(str1), 0); + EXPECT_LT(str3.cmp(str2), 0); +} + +TEST(StringViewTest, RemovePrefix) { + constexpr char kStr[] = "abcd"; + grpc_core::StringView str(kStr); + str.remove_prefix(1); + EXPECT_EQ("bcd", str); + str.remove_prefix(2); + EXPECT_EQ("d", str); + str.remove_prefix(1); + EXPECT_EQ("", str); +} + +TEST(StringViewTest, RemoveSuffix) { + constexpr char kStr[] = "abcd"; + grpc_core::StringView str(kStr); + str.remove_suffix(1); + EXPECT_EQ("abc", str); + str.remove_suffix(2); + EXPECT_EQ("a", str); + str.remove_suffix(1); + EXPECT_EQ("", str); +} + +TEST(StringViewTest, Substring) { + constexpr char kStr[] = "abcd"; + grpc_core::StringView str(kStr); + EXPECT_EQ("bcd", str.substr(1)); + EXPECT_EQ("bc", str.substr(1, 2)); +} + +TEST(StringViewTest, Find) { + // Passing StringView::npos directly to GTEST macros result in link errors. + // Store the value in a local variable and use it in the test. + const size_t npos = grpc_core::StringView::npos; + constexpr char kStr[] = "abacad"; + grpc_core::StringView str(kStr); + EXPECT_EQ(0ul, str.find('a')); + EXPECT_EQ(2ul, str.find('a', 1)); + EXPECT_EQ(4ul, str.find('a', 3)); + EXPECT_EQ(1ul, str.find('b')); + EXPECT_EQ(npos, str.find('b', 2)); + EXPECT_EQ(npos, str.find('z')); +} + +} // namespace testing +} // namespace grpc_core + +int main(int argc, char** argv) { + grpc::testing::TestEnvironment env(argc, argv); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/core/memory_usage/memory_usage_test.cc b/test/core/memory_usage/memory_usage_test.cc index 5c35b4e1d36..5df8af5658b 100644 --- a/test/core/memory_usage/memory_usage_test.cc +++ b/test/core/memory_usage/memory_usage_test.cc @@ -22,8 +22,8 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" @@ -46,22 +46,23 @@ int main(int argc, char** argv) { gpr_asprintf(&args[0], "%s/memory_usage_server%s", root, gpr_subprocess_binary_extension()); args[1] = const_cast("--bind"); - gpr_join_host_port(&args[2], "::", port); + grpc_core::UniquePtr joined; + grpc_core::JoinHostPort(&joined, "::", port); + args[2] = joined.get(); args[3] = const_cast("--no-secure"); svr = gpr_subprocess_create(4, (const char**)args); gpr_free(args[0]); - gpr_free(args[2]); /* start the client */ gpr_asprintf(&args[0], "%s/memory_usage_client%s", root, gpr_subprocess_binary_extension()); args[1] = const_cast("--target"); - gpr_join_host_port(&args[2], "127.0.0.1", port); + grpc_core::JoinHostPort(&joined, "127.0.0.1", port); + args[2] = joined.get(); args[3] = const_cast("--warmup=1000"); args[4] = const_cast("--benchmark=9000"); cli = gpr_subprocess_create(5, (const char**)args); gpr_free(args[0]); - gpr_free(args[2]); /* wait for completion */ printf("waiting for client\n"); diff --git a/test/core/memory_usage/server.cc b/test/core/memory_usage/server.cc index 6fb14fa31a0..ecdf17925ec 100644 --- a/test/core/memory_usage/server.cc +++ b/test/core/memory_usage/server.cc @@ -33,7 +33,7 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/cmdline.h" #include "test/core/util/memory_counters.h" @@ -149,7 +149,7 @@ static void sigint_handler(int x) { _exit(0); } int main(int argc, char** argv) { grpc_memory_counters_init(); grpc_event ev; - char* addr_buf = nullptr; + grpc_core::UniquePtr addr_buf; gpr_cmdline* cl; grpc_completion_queue* shutdown_cq; int shutdown_started = 0; @@ -174,8 +174,8 @@ int main(int argc, char** argv) { gpr_cmdline_destroy(cl); if (addr == nullptr) { - gpr_join_host_port(&addr_buf, "::", grpc_pick_unused_port_or_die()); - addr = addr_buf; + grpc_core::JoinHostPort(&addr_buf, "::", grpc_pick_unused_port_or_die()); + addr = addr_buf.get(); } gpr_log(GPR_INFO, "creating server on: %s", addr); @@ -202,8 +202,8 @@ int main(int argc, char** argv) { struct grpc_memory_counters after_server_create = grpc_memory_counters_snapshot(); - gpr_free(addr_buf); - addr = addr_buf = nullptr; + addr = nullptr; + addr_buf.reset(); // initialize call instances for (int i = 0; i < static_cast(sizeof(calls) / sizeof(fling_call)); diff --git a/test/core/surface/num_external_connectivity_watchers_test.cc b/test/core/surface/num_external_connectivity_watchers_test.cc index 454cbd5747e..2c9b0d9aaed 100644 --- a/test/core/surface/num_external_connectivity_watchers_test.cc +++ b/test/core/surface/num_external_connectivity_watchers_test.cc @@ -22,7 +22,8 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/end2end/data/ssl_test_data.h" @@ -66,13 +67,11 @@ static void channel_idle_poll_for_timeout(grpc_channel* channel, static void run_timeouts_test(const test_fixture* fixture) { gpr_log(GPR_INFO, "TEST: %s", fixture->name); - char* addr; - + grpc_core::UniquePtr addr; grpc_init(); + grpc_core::JoinHostPort(&addr, "localhost", grpc_pick_unused_port_or_die()); - gpr_join_host_port(&addr, "localhost", grpc_pick_unused_port_or_die()); - - grpc_channel* channel = fixture->create_channel(addr); + grpc_channel* channel = fixture->create_channel(addr.get()); grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); /* start 1 watcher and then let it time out */ @@ -111,7 +110,6 @@ static void run_timeouts_test(const test_fixture* fixture) { grpc_completion_queue_destroy(cq); grpc_shutdown(); - gpr_free(addr); } /* An edge scenario; sets channel state to explicitly, and outside @@ -120,13 +118,11 @@ static void run_channel_shutdown_before_timeout_test( const test_fixture* fixture) { gpr_log(GPR_INFO, "TEST: %s", fixture->name); - char* addr; - + grpc_core::UniquePtr addr; grpc_init(); + grpc_core::JoinHostPort(&addr, "localhost", grpc_pick_unused_port_or_die()); - gpr_join_host_port(&addr, "localhost", grpc_pick_unused_port_or_die()); - - grpc_channel* channel = fixture->create_channel(addr); + grpc_channel* channel = fixture->create_channel(addr.get()); grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); /* start 1 watcher and then shut down the channel before the timer goes off */ @@ -154,7 +150,6 @@ static void run_channel_shutdown_before_timeout_test( grpc_completion_queue_destroy(cq); grpc_shutdown(); - gpr_free(addr); } static grpc_channel* insecure_test_create_channel(const char* addr) { diff --git a/test/core/surface/sequential_connectivity_test.cc b/test/core/surface/sequential_connectivity_test.cc index 3f9a7baf98b..46c4a24f5ed 100644 --- a/test/core/surface/sequential_connectivity_test.cc +++ b/test/core/surface/sequential_connectivity_test.cc @@ -22,7 +22,7 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/end2end/data/ssl_test_data.h" @@ -56,11 +56,11 @@ static void run_test(const test_fixture* fixture) { grpc_init(); - char* addr; - gpr_join_host_port(&addr, "localhost", grpc_pick_unused_port_or_die()); + grpc_core::UniquePtr addr; + grpc_core::JoinHostPort(&addr, "localhost", grpc_pick_unused_port_or_die()); grpc_server* server = grpc_server_create(nullptr, nullptr); - fixture->add_server_port(server, addr); + fixture->add_server_port(server, addr.get()); grpc_completion_queue* server_cq = grpc_completion_queue_create_for_next(nullptr); grpc_server_register_completion_queue(server, server_cq, nullptr); @@ -73,7 +73,7 @@ static void run_test(const test_fixture* fixture) { grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); grpc_channel* channels[NUM_CONNECTIONS]; for (size_t i = 0; i < NUM_CONNECTIONS; i++) { - channels[i] = fixture->create_channel(addr); + channels[i] = fixture->create_channel(addr.get()); gpr_timespec connect_deadline = grpc_timeout_seconds_to_deadline(30); grpc_connectivity_state state; @@ -116,7 +116,6 @@ static void run_test(const test_fixture* fixture) { grpc_completion_queue_destroy(cq); grpc_shutdown(); - gpr_free(addr); } static void insecure_test_add_port(grpc_server* server, const char* addr) { diff --git a/test/core/surface/server_chttp2_test.cc b/test/core/surface/server_chttp2_test.cc index ffb7f14f987..a88362e13b0 100644 --- a/test/core/surface/server_chttp2_test.cc +++ b/test/core/surface/server_chttp2_test.cc @@ -22,7 +22,7 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "src/core/tsi/fake_transport_security.h" @@ -47,17 +47,17 @@ void test_add_same_port_twice() { grpc_channel_args args = {1, &a}; int port = grpc_pick_unused_port_or_die(); - char* addr = nullptr; + grpc_core::UniquePtr addr; grpc_completion_queue* cq = grpc_completion_queue_create_for_pluck(nullptr); grpc_server* server = grpc_server_create(&args, nullptr); grpc_server_credentials* fake_creds = grpc_fake_transport_security_server_credentials_create(); - gpr_join_host_port(&addr, "localhost", port); - GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, fake_creds)); - GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, fake_creds) == 0); + grpc_core::JoinHostPort(&addr, "localhost", port); + GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr.get(), fake_creds)); + GPR_ASSERT( + grpc_server_add_secure_http2_port(server, addr.get(), fake_creds) == 0); grpc_server_credentials_release(fake_creds); - gpr_free(addr); grpc_server_shutdown_and_notify(server, cq, nullptr); grpc_completion_queue_pluck(cq, nullptr, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr); diff --git a/test/core/surface/server_test.cc b/test/core/surface/server_test.cc index 2fc166546b0..185a6757743 100644 --- a/test/core/surface/server_test.cc +++ b/test/core/surface/server_test.cc @@ -22,7 +22,7 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "test/core/util/port.h" @@ -106,18 +106,19 @@ void test_bind_server_twice(void) { void test_bind_server_to_addr(const char* host, bool secure) { int port = grpc_pick_unused_port_or_die(); - char* addr; - gpr_join_host_port(&addr, host, port); - gpr_log(GPR_INFO, "Test bind to %s", addr); + grpc_core::UniquePtr addr; + grpc_core::JoinHostPort(&addr, host, port); + gpr_log(GPR_INFO, "Test bind to %s", addr.get()); grpc_server* server = grpc_server_create(nullptr, nullptr); if (secure) { grpc_server_credentials* fake_creds = grpc_fake_transport_security_server_credentials_create(); - GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, fake_creds)); + GPR_ASSERT( + grpc_server_add_secure_http2_port(server, addr.get(), fake_creds)); grpc_server_credentials_release(fake_creds); } else { - GPR_ASSERT(grpc_server_add_insecure_http2_port(server, addr)); + GPR_ASSERT(grpc_server_add_insecure_http2_port(server, addr.get())); } grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); grpc_server_register_completion_queue(server, cq, nullptr); @@ -126,7 +127,6 @@ void test_bind_server_to_addr(const char* host, bool secure) { grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr); grpc_server_destroy(server); grpc_completion_queue_destroy(cq); - gpr_free(addr); } static int external_dns_works(const char* host) { diff --git a/test/core/util/reconnect_server.cc b/test/core/util/reconnect_server.cc index 144ad64f095..03c088db772 100644 --- a/test/core/util/reconnect_server.cc +++ b/test/core/util/reconnect_server.cc @@ -25,7 +25,6 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/tcp_server.h" diff --git a/test/core/util/test_tcp_server.cc b/test/core/util/test_tcp_server.cc index 170584df2b9..d7803e53555 100644 --- a/test/core/util/test_tcp_server.cc +++ b/test/core/util/test_tcp_server.cc @@ -28,7 +28,6 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/tcp_server.h" diff --git a/test/cpp/interop/interop_test.cc b/test/cpp/interop/interop_test.cc index 8e45b877212..e0bacb3cfd6 100644 --- a/test/cpp/interop/interop_test.cc +++ b/test/cpp/interop/interop_test.cc @@ -32,7 +32,6 @@ #include "test/core/util/port.h" #include "test/cpp/util/test_config.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/socket_utils_posix.h" diff --git a/test/cpp/naming/address_sorting_test.cc b/test/cpp/naming/address_sorting_test.cc index affc75bc634..a3d9936606d 100644 --- a/test/cpp/naming/address_sorting_test.cc +++ b/test/cpp/naming/address_sorting_test.cc @@ -40,8 +40,8 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr.h" @@ -64,30 +64,28 @@ struct TestAddress { }; grpc_resolved_address TestAddressToGrpcResolvedAddress(TestAddress test_addr) { - char* host; - char* port; + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; grpc_resolved_address resolved_addr; - gpr_split_host_port(test_addr.dest_addr.c_str(), &host, &port); + grpc_core::SplitHostPort(test_addr.dest_addr.c_str(), &host, &port); if (test_addr.family == AF_INET) { sockaddr_in in_dest; memset(&in_dest, 0, sizeof(sockaddr_in)); - in_dest.sin_port = htons(atoi(port)); + in_dest.sin_port = htons(atoi(port.get())); in_dest.sin_family = AF_INET; - GPR_ASSERT(inet_pton(AF_INET, host, &in_dest.sin_addr) == 1); + GPR_ASSERT(inet_pton(AF_INET, host.get(), &in_dest.sin_addr) == 1); memcpy(&resolved_addr.addr, &in_dest, sizeof(sockaddr_in)); resolved_addr.len = sizeof(sockaddr_in); } else { GPR_ASSERT(test_addr.family == AF_INET6); sockaddr_in6 in6_dest; memset(&in6_dest, 0, sizeof(sockaddr_in6)); - in6_dest.sin6_port = htons(atoi(port)); + in6_dest.sin6_port = htons(atoi(port.get())); in6_dest.sin6_family = AF_INET6; - GPR_ASSERT(inet_pton(AF_INET6, host, &in6_dest.sin6_addr) == 1); + GPR_ASSERT(inet_pton(AF_INET6, host.get(), &in6_dest.sin6_addr) == 1); memcpy(&resolved_addr.addr, &in6_dest, sizeof(sockaddr_in6)); resolved_addr.len = sizeof(sockaddr_in6); } - gpr_free(host); - gpr_free(port); return resolved_addr; } diff --git a/test/cpp/naming/cancel_ares_query_test.cc b/test/cpp/naming/cancel_ares_query_test.cc index 667011ae291..2d1a13d25a6 100644 --- a/test/cpp/naming/cancel_ares_query_test.cc +++ b/test/cpp/naming/cancel_ares_query_test.cc @@ -33,7 +33,6 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/stats.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/thd.h" diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index 6cea8143907..67ed307d2d7 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -46,8 +46,8 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/executor.h" @@ -506,10 +506,10 @@ int g_fake_non_responsive_dns_server_port = -1; void InjectBrokenNameServerList(ares_channel channel) { struct ares_addr_port_node dns_server_addrs[2]; memset(dns_server_addrs, 0, sizeof(dns_server_addrs)); - char* unused_host; - char* local_dns_server_port; - GPR_ASSERT(gpr_split_host_port(FLAGS_local_dns_server_address.c_str(), - &unused_host, &local_dns_server_port)); + grpc_core::UniquePtr unused_host; + grpc_core::UniquePtr local_dns_server_port; + GPR_ASSERT(grpc_core::SplitHostPort(FLAGS_local_dns_server_address.c_str(), + &unused_host, &local_dns_server_port)); gpr_log(GPR_DEBUG, "Injecting broken nameserver list. Bad server address:|[::1]:%d|. " "Good server address:%s", @@ -528,12 +528,10 @@ void InjectBrokenNameServerList(ares_channel channel) { dns_server_addrs[1].family = AF_INET; ((char*)&dns_server_addrs[1].addr.addr4)[0] = 0x7f; ((char*)&dns_server_addrs[1].addr.addr4)[3] = 0x1; - dns_server_addrs[1].tcp_port = atoi(local_dns_server_port); - dns_server_addrs[1].udp_port = atoi(local_dns_server_port); + dns_server_addrs[1].tcp_port = atoi(local_dns_server_port.get()); + dns_server_addrs[1].udp_port = atoi(local_dns_server_port.get()); dns_server_addrs[1].next = nullptr; GPR_ASSERT(ares_set_servers_ports(channel, dns_server_addrs) == ARES_SUCCESS); - gpr_free(local_dns_server_port); - gpr_free(unused_host); } void StartResolvingLocked(void* arg, grpc_error* unused) { diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc index 668d9abf5ca..5fc14ddbabd 100644 --- a/test/cpp/qps/client_sync.cc +++ b/test/cpp/qps/client_sync.cc @@ -33,7 +33,6 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/profiling/timers.h" #include "src/proto/grpc/testing/benchmark_service.grpc.pb.h" #include "test/cpp/qps/client.h" diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 7d4d5d99446..cfc3c8e9a06 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -31,7 +31,7 @@ #include #include "src/core/lib/gpr/env.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/profiling/timers.h" #include "src/proto/grpc/testing/worker_service.grpc.pb.h" #include "test/core/util/port.h" @@ -52,15 +52,10 @@ using std::vector; namespace grpc { namespace testing { static std::string get_host(const std::string& worker) { - char* host; - char* port; - - gpr_split_host_port(worker.c_str(), &host, &port); - const string s(host); - - gpr_free(host); - gpr_free(port); - return s; + grpc_core::StringView host; + grpc_core::StringView port; + grpc_core::SplitHostPort(worker.c_str(), &host, &port); + return std::string(host.data(), host.size()); } static deque get_workers(const string& env_name) { @@ -324,11 +319,10 @@ std::unique_ptr RunScenario( client_config.add_server_targets(cli_target); } else { std::string host; - char* cli_target; + grpc_core::UniquePtr cli_target; host = get_host(workers[i]); - gpr_join_host_port(&cli_target, host.c_str(), init_status.port()); - client_config.add_server_targets(cli_target); - gpr_free(cli_target); + grpc_core::JoinHostPort(&cli_target, host.c_str(), init_status.port()); + client_config.add_server_targets(cli_target.get()); } } diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc index 23fe72316a1..bdf94d86c10 100644 --- a/test/cpp/qps/qps_worker.cc +++ b/test/cpp/qps/qps_worker.cc @@ -34,7 +34,7 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/proto/grpc/testing/worker_service.grpc.pb.h" #include "test/core/util/grpc_profiler.h" #include "test/core/util/histogram.h" @@ -279,12 +279,11 @@ QpsWorker::QpsWorker(int driver_port, int server_port, std::unique_ptr builder = CreateQpsServerBuilder(); if (driver_port >= 0) { - char* server_address = nullptr; - gpr_join_host_port(&server_address, "::", driver_port); + grpc_core::UniquePtr server_address; + grpc_core::JoinHostPort(&server_address, "::", driver_port); builder->AddListeningPort( - server_address, + server_address.get(), GetCredentialsProvider()->GetServerCredentials(credential_type)); - gpr_free(server_address); } builder->RegisterService(impl_.get()); diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index a5f8347c269..e9978212f95 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -34,7 +34,7 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/surface/completion_queue.h" #include "src/proto/grpc/testing/benchmark_service.grpc.pb.h" #include "test/core/util/test_config.h" @@ -80,11 +80,10 @@ class AsyncQpsServerTest final : public grpc::testing::Server { auto port_num = port(); // Negative port number means inproc server, so no listen port needed if (port_num >= 0) { - char* server_address = nullptr; - gpr_join_host_port(&server_address, "::", port_num); - builder->AddListeningPort(server_address, + grpc_core::UniquePtr server_address; + grpc_core::JoinHostPort(&server_address, "::", port_num); + builder->AddListeningPort(server_address.get(), Server::CreateServerCredentials(config)); - gpr_free(server_address); } register_service(builder.get(), &async_service_); diff --git a/test/cpp/qps/server_callback.cc b/test/cpp/qps/server_callback.cc index 4a346dd0178..1829905cb49 100644 --- a/test/cpp/qps/server_callback.cc +++ b/test/cpp/qps/server_callback.cc @@ -21,7 +21,7 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/proto/grpc/testing/benchmark_service.grpc.pb.h" #include "test/cpp/qps/qps_server_builder.h" #include "test/cpp/qps/server.h" @@ -103,11 +103,10 @@ class CallbackServer final : public grpc::testing::Server { auto port_num = port(); // Negative port number means inproc server, so no listen port needed if (port_num >= 0) { - char* server_address = nullptr; - gpr_join_host_port(&server_address, "::", port_num); - builder->AddListeningPort(server_address, + grpc_core::UniquePtr server_address; + grpc_core::JoinHostPort(&server_address, "::", port_num); + builder->AddListeningPort(server_address.get(), Server::CreateServerCredentials(config)); - gpr_free(server_address); } ApplyConfigToBuilder(config, builder.get()); diff --git a/test/cpp/qps/server_sync.cc b/test/cpp/qps/server_sync.cc index 2e63f5ec867..7b76e9c206a 100644 --- a/test/cpp/qps/server_sync.cc +++ b/test/cpp/qps/server_sync.cc @@ -25,7 +25,7 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/proto/grpc/testing/benchmark_service.grpc.pb.h" #include "test/cpp/qps/qps_server_builder.h" #include "test/cpp/qps/server.h" @@ -160,11 +160,10 @@ class SynchronousServer final : public grpc::testing::Server { auto port_num = port(); // Negative port number means inproc server, so no listen port needed if (port_num >= 0) { - char* server_address = nullptr; - gpr_join_host_port(&server_address, "::", port_num); - builder->AddListeningPort(server_address, + grpc_core::UniquePtr server_address; + grpc_core::JoinHostPort(&server_address, "::", port_num); + builder->AddListeningPort(server_address.get(), Server::CreateServerCredentials(config)); - gpr_free(server_address); } ApplyConfigToBuilder(config, builder.get()); diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index e2d753e02eb..d783dae496c 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1076,7 +1076,6 @@ src/core/lib/debug/trace.h \ src/core/lib/gpr/alloc.h \ src/core/lib/gpr/arena.h \ src/core/lib/gpr/env.h \ -src/core/lib/gpr/host_port.h \ src/core/lib/gpr/mpscq.h \ src/core/lib/gpr/murmur_hash.h \ src/core/lib/gpr/spinlock.h \ @@ -1098,6 +1097,7 @@ src/core/lib/gprpp/global_config.h \ src/core/lib/gprpp/global_config_custom.h \ src/core/lib/gprpp/global_config_env.h \ src/core/lib/gprpp/global_config_generic.h \ +src/core/lib/gprpp/host_port.h \ src/core/lib/gprpp/inlined_vector.h \ src/core/lib/gprpp/manual_constructor.h \ src/core/lib/gprpp/map.h \ @@ -1107,6 +1107,7 @@ src/core/lib/gprpp/orphanable.h \ src/core/lib/gprpp/pair.h \ src/core/lib/gprpp/ref_counted.h \ src/core/lib/gprpp/ref_counted_ptr.h \ +src/core/lib/gprpp/string_view.h \ src/core/lib/gprpp/sync.h \ src/core/lib/gprpp/thd.h \ src/core/lib/http/format_request.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 7768bca30f5..1dae91d2eaf 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1125,8 +1125,6 @@ src/core/lib/gpr/env.h \ src/core/lib/gpr/env_linux.cc \ src/core/lib/gpr/env_posix.cc \ src/core/lib/gpr/env_windows.cc \ -src/core/lib/gpr/host_port.cc \ -src/core/lib/gpr/host_port.h \ src/core/lib/gpr/log.cc \ src/core/lib/gpr/log_android.cc \ src/core/lib/gpr/log_linux.cc \ @@ -1175,6 +1173,8 @@ src/core/lib/gprpp/global_config_custom.h \ src/core/lib/gprpp/global_config_env.cc \ src/core/lib/gprpp/global_config_env.h \ src/core/lib/gprpp/global_config_generic.h \ +src/core/lib/gprpp/host_port.cc \ +src/core/lib/gprpp/host_port.h \ src/core/lib/gprpp/inlined_vector.h \ src/core/lib/gprpp/manual_constructor.h \ src/core/lib/gprpp/map.h \ @@ -1184,6 +1184,7 @@ src/core/lib/gprpp/orphanable.h \ src/core/lib/gprpp/pair.h \ src/core/lib/gprpp/ref_counted.h \ src/core/lib/gprpp/ref_counted_ptr.h \ +src/core/lib/gprpp/string_view.h \ src/core/lib/gprpp/sync.h \ src/core/lib/gprpp/thd.h \ src/core/lib/gprpp/thd_posix.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 43fc3cc05ec..e894da1a9cb 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -683,7 +683,7 @@ "language": "c", "name": "gpr_host_port_test", "src": [ - "test/core/gpr/host_port_test.cc" + "test/core/gprpp/host_port_test.cc" ], "third_party": false, "type": "target" @@ -5058,6 +5058,24 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "grpc", + "grpc++", + "grpc++_test", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "string_view_test", + "src": [ + "test/core/gprpp/string_view_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", @@ -8172,7 +8190,6 @@ "src/core/lib/gpr/env_linux.cc", "src/core/lib/gpr/env_posix.cc", "src/core/lib/gpr/env_windows.cc", - "src/core/lib/gpr/host_port.cc", "src/core/lib/gpr/log.cc", "src/core/lib/gpr/log_android.cc", "src/core/lib/gpr/log_linux.cc", @@ -8199,6 +8216,7 @@ "src/core/lib/gprpp/arena.cc", "src/core/lib/gprpp/fork.cc", "src/core/lib/gprpp/global_config_env.cc", + "src/core/lib/gprpp/host_port.cc", "src/core/lib/gprpp/thd_posix.cc", "src/core/lib/gprpp/thd_windows.cc", "src/core/lib/profiling/basic_timers.cc", @@ -8232,7 +8250,6 @@ "src/core/lib/gpr/alloc.h", "src/core/lib/gpr/arena.h", "src/core/lib/gpr/env.h", - "src/core/lib/gpr/host_port.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", "src/core/lib/gpr/spinlock.h", @@ -8253,6 +8270,7 @@ "src/core/lib/gprpp/global_config_custom.h", "src/core/lib/gprpp/global_config_env.h", "src/core/lib/gprpp/global_config_generic.h", + "src/core/lib/gprpp/host_port.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", @@ -8285,7 +8303,6 @@ "src/core/lib/gpr/alloc.h", "src/core/lib/gpr/arena.h", "src/core/lib/gpr/env.h", - "src/core/lib/gpr/host_port.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", "src/core/lib/gpr/spinlock.h", @@ -8306,6 +8323,7 @@ "src/core/lib/gprpp/global_config_custom.h", "src/core/lib/gprpp/global_config_env.h", "src/core/lib/gprpp/global_config_generic.h", + "src/core/lib/gprpp/host_port.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", @@ -8606,6 +8624,7 @@ "src/core/lib/gprpp/orphanable.h", "src/core/lib/gprpp/ref_counted.h", "src/core/lib/gprpp/ref_counted_ptr.h", + "src/core/lib/gprpp/string_view.h", "src/core/lib/http/format_request.h", "src/core/lib/http/httpcli.h", "src/core/lib/http/parser.h", @@ -8763,6 +8782,7 @@ "src/core/lib/gprpp/orphanable.h", "src/core/lib/gprpp/ref_counted.h", "src/core/lib/gprpp/ref_counted_ptr.h", + "src/core/lib/gprpp/string_view.h", "src/core/lib/http/format_request.h", "src/core/lib/http/httpcli.h", "src/core/lib/http/parser.h", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 5c24ec4fa15..77a751de162 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -5730,6 +5730,30 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "string_view_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": true + }, { "args": [], "benchmark": false, From ddde5f65beb4921344b64e958b7720b8c2c3ea29 Mon Sep 17 00:00:00 2001 From: yunjiaw26 <50971092+yunjiaw26@users.noreply.github.com> Date: Thu, 20 Jun 2019 21:21:04 -0700 Subject: [PATCH 0630/1555] Fix format error --- src/core/lib/iomgr/executor/mpmcqueue.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index 6deba05a421..7290c68db94 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -45,7 +45,7 @@ inline void* InfLenFIFOQueue::PopFront() { if (GRPC_TRACE_FLAG_ENABLED(thread_pool)) { gpr_timespec wait_time = - gpr_time_sub(gpr_now(GPR_CLOCK_PRECISE), head_to_remove->insert_time); + gpr_time_sub(gpr_now(GPR_CLOCK_PRECISE), head_to_remove->insert_time); // Updates Stats info stats_.num_completed++; From 48cee18b2fc1475dc3ddd9ccb92d8bf9fcee58c5 Mon Sep 17 00:00:00 2001 From: yunjiaw26 <50971092+yunjiaw26@users.noreply.github.com> Date: Thu, 20 Jun 2019 21:21:48 -0700 Subject: [PATCH 0631/1555] Fix format error --- src/core/lib/iomgr/executor/mpmcqueue.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index ae9a3b2826f..5970dba0c1d 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -119,11 +119,11 @@ class InfLenFIFOQueue : public MPMCQueueInterface { CondVar wait_nonempty_; // Wait on empty queue on get int num_waiters_; // Number of waiters - Node* queue_head_; // Head of the queue, remove position - Node* queue_tail_; // End of queue, insert position - Atomic count_{0}; // Number of elements in queue - Stats stats_; // Stats info - gpr_timespec busy_time; // Start time of busy queue + Node* queue_head_; // Head of the queue, remove position + Node* queue_tail_; // End of queue, insert position + Atomic count_{0}; // Number of elements in queue + Stats stats_; // Stats info + gpr_timespec busy_time; // Start time of busy queue }; } // namespace grpc_core From 857d8d14b0f8b3beed6e605026da528af4077781 Mon Sep 17 00:00:00 2001 From: yunjiaw26 <50971092+yunjiaw26@users.noreply.github.com> Date: Thu, 20 Jun 2019 21:22:56 -0700 Subject: [PATCH 0632/1555] Fix format error and memory leak --- test/core/iomgr/mpmcqueue_test.cc | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index 8f89b5c08bf..ad47c657def 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -42,9 +42,7 @@ class ProducerThread { public: ProducerThread(grpc_core::InfLenFIFOQueue* queue, int start_index, int num_items) - : start_index_(start_index), - num_items_(num_items), - queue_(queue) { + : start_index_(start_index), num_items_(num_items), queue_(queue) { items_ = nullptr; thd_ = grpc_core::Thread( "mpmcq_test_mt_put_thd", @@ -77,7 +75,6 @@ class ProducerThread { WorkItem** items_; }; - static void ConsumerThread(void* args) { grpc_core::InfLenFIFOQueue* queue = static_cast(args); @@ -104,13 +101,14 @@ static void test_get_empty(void) { // Fork threads. Threads should block at the beginning since queue is empty. for (int i = 0; i < num_threads; ++i) { - thds[i] = - grpc_core::Thread("mpmcq_test_ge_thd", ConsumerThread, &queue); + thds[i] = grpc_core::Thread("mpmcq_test_ge_thd", ConsumerThread, &queue); thds[i].Start(); } + WorkItem** items = new WorkItem*[THREAD_LARGE_ITERATION]; for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { - queue.Put(static_cast(new WorkItem(i))); + items[i] = new WorkItem(i); + queue.Put(static_cast(items[i])); } gpr_log(GPR_DEBUG, "Terminating threads..."); @@ -120,6 +118,12 @@ static void test_get_empty(void) { for (int i = 0; i < num_threads; ++i) { thds[i].Join(); } + gpr_log(GPR_DEBUG, "Checking and Cleaning Up..."); + for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { + GPR_ASSERT(items[i]->done); + delete items[i]; + } + delete[] items; gpr_log(GPR_DEBUG, "Done."); } @@ -148,14 +152,14 @@ static void test_many_thread(void) { gpr_log(GPR_DEBUG, "Fork ProducerThread..."); for (int i = 0; i < num_work_thd; ++i) { work_thds[i] = new ProducerThread(&queue, i * THREAD_LARGE_ITERATION, - THREAD_LARGE_ITERATION); + THREAD_LARGE_ITERATION); work_thds[i]->Start(); } gpr_log(GPR_DEBUG, "ProducerThread Started."); gpr_log(GPR_DEBUG, "Fork Getter Thread..."); for (int i = 0; i < num_get_thd; ++i) { - get_thds[i] = grpc_core::Thread("mpmcq_test_mt_get_thd", ConsumerThread, - &queue); + get_thds[i] = + grpc_core::Thread("mpmcq_test_mt_get_thd", ConsumerThread, &queue); get_thds[i].Start(); } gpr_log(GPR_DEBUG, "Getter Thread Started."); From a16e89401225141ab118b304749b24790ba27c21 Mon Sep 17 00:00:00 2001 From: yunjiaw26 <50971092+yunjiaw26@users.noreply.github.com> Date: Thu, 20 Jun 2019 21:48:21 -0700 Subject: [PATCH 0633/1555] Fix format error :) --- src/core/lib/iomgr/executor/mpmcqueue.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index 5970dba0c1d..e5d2b6423ed 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -119,11 +119,11 @@ class InfLenFIFOQueue : public MPMCQueueInterface { CondVar wait_nonempty_; // Wait on empty queue on get int num_waiters_; // Number of waiters - Node* queue_head_; // Head of the queue, remove position - Node* queue_tail_; // End of queue, insert position - Atomic count_{0}; // Number of elements in queue - Stats stats_; // Stats info - gpr_timespec busy_time; // Start time of busy queue + Node* queue_head_; // Head of the queue, remove position + Node* queue_tail_; // End of queue, insert position + Atomic count_{0}; // Number of elements in queue + Stats stats_; // Stats info + gpr_timespec busy_time; // Start time of busy queue }; } // namespace grpc_core From 5435ac05ce7f7da170ad6ebb228b912b141e2730 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Fri, 21 Jun 2019 10:59:08 -0400 Subject: [PATCH 0634/1555] Fix obj-c tests. --- src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm index fbcd4f888d4..ad426014a5b 100644 --- a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm +++ b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm @@ -82,7 +82,8 @@ static void cronet_init_client_secure_fullstack(grpc_end2end_test_fixture *f, grpc_channel_args *client_args, stream_engine *cronetEngine) { fullstack_secure_fixture_data *ffd = (fullstack_secure_fixture_data *)f->fixture_data; - f->client = grpc_cronet_secure_channel_create(cronetEngine, ffd->localaddr, client_args, NULL); + f->client = + grpc_cronet_secure_channel_create(cronetEngine, ffd->localaddr.get(), client_args, NULL); GPR_ASSERT(f->client != NULL); } @@ -95,7 +96,7 @@ static void chttp2_init_server_secure_fullstack(grpc_end2end_test_fixture *f, } f->server = grpc_server_create(server_args, NULL); grpc_server_register_completion_queue(f->server, f->cq, NULL); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, server_creds)); + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); } From 152108e90791b5a1c5759bf21594463ce92a9ac1 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 21 Jun 2019 09:25:01 -0700 Subject: [PATCH 0635/1555] Modify var type to match interface --- src/core/lib/iomgr/executor/mpmcqueue.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index e5d2b6423ed..7022cf492f2 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -119,11 +119,11 @@ class InfLenFIFOQueue : public MPMCQueueInterface { CondVar wait_nonempty_; // Wait on empty queue on get int num_waiters_; // Number of waiters - Node* queue_head_; // Head of the queue, remove position - Node* queue_tail_; // End of queue, insert position - Atomic count_{0}; // Number of elements in queue - Stats stats_; // Stats info - gpr_timespec busy_time; // Start time of busy queue + Node* queue_head_; // Head of the queue, remove position + Node* queue_tail_; // End of queue, insert position + Atomic count_{0}; // Number of elements in queue + Stats stats_; // Stats info + gpr_timespec busy_time; // Start time of busy queue }; } // namespace grpc_core From 2bf9234f147eeaf48b8c7e1b0a68c3d1556d1717 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 21 Jun 2019 13:36:06 -0400 Subject: [PATCH 0636/1555] building upb as part of cmake build is not necessary --- CMakeLists.txt | 52 ------------------------------- templates/CMakeLists.txt.template | 2 +- 2 files changed, 1 insertion(+), 53 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 76f19024f0b..b449e353a9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5766,58 +5766,6 @@ endif() endif (gRPC_BUILD_CSHARP_EXT) if (gRPC_BUILD_TESTS) -add_library(upb - third_party/upb/google/protobuf/descriptor.upb.c - third_party/upb/upb/decode.c - third_party/upb/upb/def.c - third_party/upb/upb/encode.c - third_party/upb/upb/handlers.c - third_party/upb/upb/msg.c - third_party/upb/upb/msgfactory.c - third_party/upb/upb/sink.c - third_party/upb/upb/table.c - third_party/upb/upb/upb.c -) - -if(WIN32 AND MSVC) - set_target_properties(upb PROPERTIES COMPILE_PDB_NAME "upb" - COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" - ) - if (gRPC_INSTALL) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/upb.pdb - DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL - ) - endif() -endif() - - -target_include_directories(upb - PUBLIC $ $ - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} -) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(upb PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(upb PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() -target_link_libraries(upb - ${_gRPC_SSL_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} -) - - -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) - add_library(bad_client_test test/core/bad_client/bad_client.cc ) diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index 43bc063aee5..d42d2c6d0c8 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -325,7 +325,7 @@ % for lib in libs: % if lib.build in ["all", "protoc", "tool", "test", "private"] and not lib.boringssl: % if not lib.get('build_system', []) or 'cmake' in lib.get('build_system', []): - % if not lib.name in ['ares', 'benchmark', 'z']: # we build these using CMake instead + % if not lib.name in ['ares', 'benchmark', 'upb', 'z']: # we build these using CMake instead % if lib.build in ["test", "private"]: if (gRPC_BUILD_TESTS) ${cc_library(lib)} From 3ce20819cfd0919ccabdff08166bdb182fdadd41 Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Fri, 21 Jun 2019 10:51:57 -0700 Subject: [PATCH 0637/1555] Modify codegen to use grpc_impl namespace and other cleanups --- .../impl/codegen/async_generic_service.h | 4 +- include/grpcpp/impl/codegen/async_stream.h | 32 +++++------ .../grpcpp/impl/codegen/async_unary_call.h | 16 +++--- include/grpcpp/impl/codegen/call_op_set.h | 8 +-- include/grpcpp/impl/codegen/client_callback.h | 36 ++++++------- .../grpcpp/impl/codegen/intercepted_channel.h | 2 +- .../grpcpp/impl/codegen/method_handler_impl.h | 33 ++++++------ .../grpcpp/impl/codegen/server_interface.h | 2 +- include/grpcpp/impl/codegen/sync_stream.h | 53 ++++++++++--------- include/grpcpp/impl/server_builder_plugin.h | 4 +- include/grpcpp/security/credentials.h | 1 + include/grpcpp/security/credentials_impl.h | 28 +++++----- include/grpcpp/server_impl.h | 28 +++++----- src/compiler/cpp_generator.cc | 5 +- src/cpp/client/create_channel_internal.h | 1 + src/cpp/client/insecure_credentials.cc | 10 ++-- src/cpp/client/secure_credentials.cc | 10 ++-- src/cpp/client/secure_credentials.h | 8 +-- test/cpp/qps/server.h | 1 + test/cpp/util/create_test_channel.h | 22 ++++---- 20 files changed, 157 insertions(+), 147 deletions(-) diff --git a/include/grpcpp/impl/codegen/async_generic_service.h b/include/grpcpp/impl/codegen/async_generic_service.h index 46d09121a7b..d8e6f49b2f3 100644 --- a/include/grpcpp/impl/codegen/async_generic_service.h +++ b/include/grpcpp/impl/codegen/async_generic_service.h @@ -33,7 +33,7 @@ typedef ServerAsyncResponseWriter GenericServerAsyncResponseWriter; typedef ServerAsyncReader GenericServerAsyncReader; typedef ServerAsyncWriter GenericServerAsyncWriter; -class GenericServerContext final : public ServerContext { +class GenericServerContext final : public ::grpc_impl::ServerContext { public: const grpc::string& method() const { return method_; } const grpc::string& host() const { return host_; } @@ -99,7 +99,7 @@ class ServerGenericBidiReactor virtual void OnStarted(GenericServerContext* context) {} private: - void OnStarted(ServerContext* ctx) final { + void OnStarted(::grpc_impl::ServerContext* ctx) final { OnStarted(static_cast(ctx)); } }; diff --git a/include/grpcpp/impl/codegen/async_stream.h b/include/grpcpp/impl/codegen/async_stream.h index f95772650a2..f762833b3b1 100644 --- a/include/grpcpp/impl/codegen/async_stream.h +++ b/include/grpcpp/impl/codegen/async_stream.h @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -181,7 +181,7 @@ class ClientAsyncReaderFactory { static ClientAsyncReader* Create(ChannelInterface* channel, CompletionQueue* cq, const ::grpc::internal::RpcMethod& method, - ClientContext* context, const W& request, + ::grpc_impl::ClientContext* context, const W& request, bool start, void* tag) { ::grpc::internal::Call call = channel->CreateCall(method, context, cq); return new (g_core_codegen_interface->grpc_call_arena_alloc( @@ -260,7 +260,7 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface { private: friend class internal::ClientAsyncReaderFactory; template - ClientAsyncReader(::grpc::internal::Call call, ClientContext* context, + ClientAsyncReader(::grpc::internal::Call call, ::grpc_impl::ClientContext* context, const W& request, bool start, void* tag) : context_(context), call_(call), started_(start) { // TODO(ctiller): don't assert @@ -280,7 +280,7 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface { call_.PerformOps(&init_ops_); } - ClientContext* context_; + ::grpc_impl::ClientContext* context_; ::grpc::internal::Call call_; bool started_; ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, @@ -329,7 +329,7 @@ class ClientAsyncWriterFactory { static ClientAsyncWriter* Create(ChannelInterface* channel, CompletionQueue* cq, const ::grpc::internal::RpcMethod& method, - ClientContext* context, R* response, + ::grpc_impl::ClientContext* context, R* response, bool start, void* tag) { ::grpc::internal::Call call = channel->CreateCall(method, context, cq); return new (g_core_codegen_interface->grpc_call_arena_alloc( @@ -426,7 +426,7 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface { private: friend class internal::ClientAsyncWriterFactory; template - ClientAsyncWriter(::grpc::internal::Call call, ClientContext* context, + ClientAsyncWriter(::grpc::internal::Call call, ::grpc_impl::ClientContext* context, R* response, bool start, void* tag) : context_(context), call_(call), started_(start) { finish_ops_.RecvMessage(response); @@ -449,7 +449,7 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface { } } - ClientContext* context_; + ::grpc_impl::ClientContext* context_; ::grpc::internal::Call call_; bool started_; ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> @@ -493,7 +493,7 @@ class ClientAsyncReaderWriterFactory { /// used to send to the server when starting the call. static ClientAsyncReaderWriter* Create( ChannelInterface* channel, CompletionQueue* cq, - const ::grpc::internal::RpcMethod& method, ClientContext* context, + const ::grpc::internal::RpcMethod& method, ::grpc_impl::ClientContext* context, bool start, void* tag) { ::grpc::internal::Call call = channel->CreateCall(method, context, cq); @@ -599,7 +599,7 @@ class ClientAsyncReaderWriter final private: friend class internal::ClientAsyncReaderWriterFactory; - ClientAsyncReaderWriter(::grpc::internal::Call call, ClientContext* context, + ClientAsyncReaderWriter(::grpc::internal::Call call, ::grpc_impl::ClientContext* context, bool start, void* tag) : context_(context), call_(call), started_(start) { if (start) { @@ -620,7 +620,7 @@ class ClientAsyncReaderWriter final } } - ClientContext* context_; + ::grpc_impl::ClientContext* context_; ::grpc::internal::Call call_; bool started_; ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> @@ -696,7 +696,7 @@ class ServerAsyncReaderInterface template class ServerAsyncReader final : public ServerAsyncReaderInterface { public: - explicit ServerAsyncReader(ServerContext* ctx) + explicit ServerAsyncReader(::grpc_impl::ServerContext* ctx) : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. @@ -782,7 +782,7 @@ class ServerAsyncReader final : public ServerAsyncReaderInterface { void BindCall(::grpc::internal::Call* call) override { call_ = *call; } ::grpc::internal::Call call_; - ServerContext* ctx_; + ::grpc_impl::ServerContext* ctx_; ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> meta_ops_; ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage> read_ops_; @@ -843,7 +843,7 @@ class ServerAsyncWriterInterface template class ServerAsyncWriter final : public ServerAsyncWriterInterface { public: - explicit ServerAsyncWriter(ServerContext* ctx) + explicit ServerAsyncWriter(::grpc_impl::ServerContext* ctx) : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. @@ -940,7 +940,7 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface { } ::grpc::internal::Call call_; - ServerContext* ctx_; + ::grpc_impl::ServerContext* ctx_; ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> meta_ops_; ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, @@ -1009,7 +1009,7 @@ template class ServerAsyncReaderWriter final : public ServerAsyncReaderWriterInterface { public: - explicit ServerAsyncReaderWriter(ServerContext* ctx) + explicit ServerAsyncReaderWriter(::grpc_impl::ServerContext* ctx) : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. @@ -1114,7 +1114,7 @@ class ServerAsyncReaderWriter final } ::grpc::internal::Call call_; - ServerContext* ctx_; + ::grpc_impl::ServerContext* ctx_; ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> meta_ops_; ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage> read_ops_; diff --git a/include/grpcpp/impl/codegen/async_unary_call.h b/include/grpcpp/impl/codegen/async_unary_call.h index 4b97cf29018..4c0f4339c8f 100644 --- a/include/grpcpp/impl/codegen/async_unary_call.h +++ b/include/grpcpp/impl/codegen/async_unary_call.h @@ -22,8 +22,8 @@ #include #include #include -#include -#include +#include +#include #include #include @@ -80,8 +80,8 @@ class ClientAsyncResponseReaderFactory { /// used to send to the server when starting the call. template static ClientAsyncResponseReader* Create( - ChannelInterface* channel, CompletionQueue* cq, - const ::grpc::internal::RpcMethod& method, ClientContext* context, + ChannelInterface* channel, ::grpc_impl::CompletionQueue* cq, + const ::grpc::internal::RpcMethod& method, ::grpc_impl::ClientContext* context, const W& request, bool start) { ::grpc::internal::Call call = channel->CreateCall(method, context, cq); return new (g_core_codegen_interface->grpc_call_arena_alloc( @@ -156,13 +156,13 @@ class ClientAsyncResponseReader final private: friend class internal::ClientAsyncResponseReaderFactory; - ClientContext* const context_; + ::grpc_impl::ClientContext* const context_; ::grpc::internal::Call call_; bool started_; bool initial_metadata_read_ = false; template - ClientAsyncResponseReader(::grpc::internal::Call call, ClientContext* context, + ClientAsyncResponseReader(::grpc::internal::Call call, ::grpc_impl::ClientContext* context, const W& request, bool start) : context_(context), call_(call), started_(start) { // Bind the metadata at time of StartCallInternal but set up the rest here @@ -199,7 +199,7 @@ template class ServerAsyncResponseWriter final : public internal::ServerAsyncStreamingInterface { public: - explicit ServerAsyncResponseWriter(ServerContext* ctx) + explicit ServerAsyncResponseWriter(::grpc_impl::ServerContext* ctx) : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. @@ -289,7 +289,7 @@ class ServerAsyncResponseWriter final void BindCall(::grpc::internal::Call* call) override { call_ = *call; } ::grpc::internal::Call call_; - ServerContext* ctx_; + ::grpc_impl::ServerContext* ctx_; ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> meta_buf_; ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, diff --git a/include/grpcpp/impl/codegen/call_op_set.h b/include/grpcpp/impl/codegen/call_op_set.h index c3ae6c4e3d2..d0958bbb251 100644 --- a/include/grpcpp/impl/codegen/call_op_set.h +++ b/include/grpcpp/impl/codegen/call_op_set.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include @@ -697,7 +697,7 @@ class CallOpRecvInitialMetadata { public: CallOpRecvInitialMetadata() : metadata_map_(nullptr) {} - void RecvInitialMetadata(ClientContext* context) { + void RecvInitialMetadata(::grpc_impl::ClientContext* context) { context->initial_metadata_received_ = true; metadata_map_ = &context->recv_initial_metadata_; } @@ -746,7 +746,7 @@ class CallOpClientRecvStatus { CallOpClientRecvStatus() : recv_status_(nullptr), debug_error_string_(nullptr) {} - void ClientRecvStatus(ClientContext* context, Status* status) { + void ClientRecvStatus(::grpc_impl::ClientContext* context, Status* status) { client_context_ = context; metadata_map_ = &client_context_->trailing_metadata_; recv_status_ = status; @@ -807,7 +807,7 @@ class CallOpClientRecvStatus { private: bool hijacked_ = false; - ClientContext* client_context_; + ::grpc_impl::ClientContext* client_context_; MetadataMap* metadata_map_; Status* recv_status_; const char* debug_error_string_; diff --git a/include/grpcpp/impl/codegen/client_callback.h b/include/grpcpp/impl/codegen/client_callback.h index 86d06b72c91..9441a48b051 100644 --- a/include/grpcpp/impl/codegen/client_callback.h +++ b/include/grpcpp/impl/codegen/client_callback.h @@ -44,8 +44,8 @@ class RpcMethod; /// TODO(vjpai): Combine as much as possible with the blocking unary call code template void CallbackUnaryCall(ChannelInterface* channel, const RpcMethod& method, - ClientContext* context, const InputMessage* request, - OutputMessage* result, + ::grpc_impl::ClientContext* context, + const InputMessage* request, OutputMessage* result, std::function on_completion) { CallbackUnaryCallImpl x( channel, method, context, request, result, on_completion); @@ -55,8 +55,8 @@ template class CallbackUnaryCallImpl { public: CallbackUnaryCallImpl(ChannelInterface* channel, const RpcMethod& method, - ClientContext* context, const InputMessage* request, - OutputMessage* result, + ::grpc_impl::ClientContext* context, + const InputMessage* request, OutputMessage* result, std::function on_completion) { CompletionQueue* cq = channel->CallbackCQ(); GPR_CODEGEN_ASSERT(cq != nullptr); @@ -550,7 +550,7 @@ class ClientCallbackReaderWriterImpl friend class ClientCallbackReaderWriterFactory; ClientCallbackReaderWriterImpl( - Call call, ClientContext* context, + Call call, ::grpc_impl::ClientContext* context, ::grpc::experimental::ClientBidiReactor* reactor) : context_(context), call_(call), @@ -559,7 +559,7 @@ class ClientCallbackReaderWriterImpl this->BindReactor(reactor); } - ClientContext* const context_; + ::grpc_impl::ClientContext* const context_; Call call_; ::grpc::experimental::ClientBidiReactor* const reactor_; @@ -594,7 +594,7 @@ class ClientCallbackReaderWriterFactory { public: static void Create( ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, - ClientContext* context, + ::grpc_impl::ClientContext* context, ::grpc::experimental::ClientBidiReactor* reactor) { Call call = channel->CreateCall(method, context, channel->CallbackCQ()); @@ -692,7 +692,7 @@ class ClientCallbackReaderImpl template ClientCallbackReaderImpl( - Call call, ClientContext* context, Request* request, + Call call, ::grpc_impl::ClientContext* context, Request* request, ::grpc::experimental::ClientReadReactor* reactor) : context_(context), call_(call), reactor_(reactor) { this->BindReactor(reactor); @@ -701,7 +701,7 @@ class ClientCallbackReaderImpl start_ops_.ClientSendClose(); } - ClientContext* const context_; + ::grpc_impl::ClientContext* const context_; Call call_; ::grpc::experimental::ClientReadReactor* const reactor_; @@ -729,7 +729,7 @@ class ClientCallbackReaderFactory { template static void Create( ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, - ClientContext* context, const Request* request, + ::grpc_impl::ClientContext* context, const Request* request, ::grpc::experimental::ClientReadReactor* reactor) { Call call = channel->CreateCall(method, context, channel->CallbackCQ()); @@ -866,7 +866,7 @@ class ClientCallbackWriterImpl template ClientCallbackWriterImpl( - Call call, ClientContext* context, Response* response, + Call call, ::grpc_impl::ClientContext* context, Response* response, ::grpc::experimental::ClientWriteReactor* reactor) : context_(context), call_(call), @@ -877,7 +877,7 @@ class ClientCallbackWriterImpl finish_ops_.AllowNoMessage(); } - ClientContext* const context_; + ::grpc_impl::ClientContext* const context_; Call call_; ::grpc::experimental::ClientWriteReactor* const reactor_; @@ -909,7 +909,7 @@ class ClientCallbackWriterFactory { template static void Create( ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, - ClientContext* context, Response* response, + ::grpc_impl::ClientContext* context, Response* response, ::grpc::experimental::ClientWriteReactor* reactor) { Call call = channel->CreateCall(method, context, channel->CallbackCQ()); @@ -976,8 +976,8 @@ class ClientCallbackUnaryImpl final friend class ClientCallbackUnaryFactory; template - ClientCallbackUnaryImpl(Call call, ClientContext* context, Request* request, - Response* response, + ClientCallbackUnaryImpl(Call call, ::grpc_impl::ClientContext* context, + Request* request, Response* response, ::grpc::experimental::ClientUnaryReactor* reactor) : context_(context), call_(call), reactor_(reactor) { this->BindReactor(reactor); @@ -988,7 +988,7 @@ class ClientCallbackUnaryImpl final finish_ops_.AllowNoMessage(); } - ClientContext* const context_; + ::grpc_impl::ClientContext* const context_; Call call_; ::grpc::experimental::ClientUnaryReactor* const reactor_; @@ -1011,8 +1011,8 @@ class ClientCallbackUnaryFactory { template static void Create(ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, - ClientContext* context, const Request* request, - Response* response, + ::grpc_impl::ClientContext* context, + const Request* request, Response* response, ::grpc::experimental::ClientUnaryReactor* reactor) { Call call = channel->CreateCall(method, context, channel->CallbackCQ()); diff --git a/include/grpcpp/impl/codegen/intercepted_channel.h b/include/grpcpp/impl/codegen/intercepted_channel.h index cd0fcc06753..bcdd89db741 100644 --- a/include/grpcpp/impl/codegen/intercepted_channel.h +++ b/include/grpcpp/impl/codegen/intercepted_channel.h @@ -49,7 +49,7 @@ class InterceptedChannel : public ChannelInterface { InterceptedChannel(ChannelInterface* channel, size_t pos) : channel_(channel), interceptor_pos_(pos) {} - Call CreateCall(const RpcMethod& method, ClientContext* context, + Call CreateCall(const RpcMethod& method, ::grpc_impl::ClientContext* context, ::grpc_impl::CompletionQueue* cq) override { return channel_->CreateCallInternal(method, context, cq, interceptor_pos_); } diff --git a/include/grpcpp/impl/codegen/method_handler_impl.h b/include/grpcpp/impl/codegen/method_handler_impl.h index dee1cb56ad1..95b804c50e8 100644 --- a/include/grpcpp/impl/codegen/method_handler_impl.h +++ b/include/grpcpp/impl/codegen/method_handler_impl.h @@ -52,7 +52,8 @@ Status CatchingFunctionHandler(Callable&& handler) { template class RpcMethodHandler : public MethodHandler { public: - RpcMethodHandler(std::function func, ServiceType* service) @@ -103,8 +104,8 @@ class RpcMethodHandler : public MethodHandler { private: /// Application provided rpc handler function. - std::function + std::function func_; // The class the above handler function lives in. ServiceType* service_; @@ -115,7 +116,7 @@ template class ClientStreamingHandler : public MethodHandler { public: ClientStreamingHandler( - std::function*, ResponseType*)> func, ServiceType* service) @@ -147,8 +148,8 @@ class ClientStreamingHandler : public MethodHandler { } private: - std::function*, - ResponseType*)> + std::function*, ResponseType*)> func_; ServiceType* service_; }; @@ -158,8 +159,8 @@ template class ServerStreamingHandler : public MethodHandler { public: ServerStreamingHandler( - std::function*)> + std::function*)> func, ServiceType* service) : func_(func), service_(service) {} @@ -207,8 +208,8 @@ class ServerStreamingHandler : public MethodHandler { } private: - std::function*)> + std::function*)> func_; ServiceType* service_; }; @@ -224,7 +225,7 @@ template class TemplatedBidiStreamingHandler : public MethodHandler { public: TemplatedBidiStreamingHandler( - std::function func) + std::function func) : func_(func), write_needed_(WriteNeeded) {} void RunHandler(const HandlerParameter& param) final { @@ -256,7 +257,7 @@ class TemplatedBidiStreamingHandler : public MethodHandler { } private: - std::function func_; + std::function func_; const bool write_needed_; }; @@ -266,7 +267,7 @@ class BidiStreamingHandler ServerReaderWriter, false> { public: BidiStreamingHandler( - std::function*)> func, ServiceType* service) @@ -281,7 +282,7 @@ class StreamedUnaryHandler ServerUnaryStreamer, true> { public: explicit StreamedUnaryHandler( - std::function*)> func) : TemplatedBidiStreamingHandler< @@ -294,7 +295,7 @@ class SplitServerStreamingHandler ServerSplitStreamer, false> { public: explicit SplitServerStreamingHandler( - std::function*)> func) : TemplatedBidiStreamingHandler< @@ -307,7 +308,7 @@ template class ErrorMethodHandler : public MethodHandler { public: template - static void FillOps(ServerContext* context, T* ops) { + static void FillOps(::grpc_impl::ServerContext* context, T* ops) { Status status(code, ""); if (!context->sent_initial_metadata_) { ops->SendInitialMetadata(&context->initial_metadata_, diff --git a/include/grpcpp/impl/codegen/server_interface.h b/include/grpcpp/impl/codegen/server_interface.h index 9600e5f053d..6239b4c2d4d 100644 --- a/include/grpcpp/impl/codegen/server_interface.h +++ b/include/grpcpp/impl/codegen/server_interface.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include namespace grpc_impl { diff --git a/include/grpcpp/impl/codegen/sync_stream.h b/include/grpcpp/impl/codegen/sync_stream.h index 0d3fdfcb8dc..cdff2f487dc 100644 --- a/include/grpcpp/impl/codegen/sync_stream.h +++ b/include/grpcpp/impl/codegen/sync_stream.h @@ -21,10 +21,10 @@ #include #include -#include +#include #include #include -#include +#include #include #include @@ -120,7 +120,7 @@ class WriterInterface { /// /// \param msg The message to be written to the stream. /// - /// \return \a true on success, \a false when the stream has been closed. + /// \return \a true on success, \a false when the stream has been closed.access/marconi/common/grpc/async_grpc_container.h inline bool Write(const W& msg) { return Write(msg, WriteOptions()); } /// Write \a msg and coalesce it with the writing of trailing metadata, using @@ -142,7 +142,7 @@ class WriterInterface { } }; -} // namespace internal +} // namespace internalaccess/marconi/common/grpc/async_grpc_container.h /// Client-side interface for streaming reads of message of type \a R. template @@ -163,7 +163,8 @@ class ClientReaderFactory { template static ClientReader* Create(ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, - ClientContext* context, const W& request) { + ::grpc_impl::ClientContext* context, + const W& request) { return new ClientReader(channel, method, context, request); } }; @@ -230,8 +231,8 @@ class ClientReader final : public ClientReaderInterface { private: friend class internal::ClientReaderFactory; - ClientContext* context_; - CompletionQueue cq_; + ::grpc_impl::ClientContext* context_; + ::grpc_impl::CompletionQueue cq_; ::grpc::internal::Call call_; /// Block to create a stream and write the initial metadata and \a request @@ -240,7 +241,7 @@ class ClientReader final : public ClientReaderInterface { template ClientReader(::grpc::ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, - ClientContext* context, const W& request) + ::grpc_impl::ClientContext* context, const W& request) : context_(context), cq_(grpc_completion_queue_attributes{ GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, @@ -281,7 +282,8 @@ class ClientWriterFactory { template static ClientWriter* Create(::grpc::ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, - ClientContext* context, R* response) { + ::grpc_impl::ClientContext* context, + R* response) { return new ClientWriter(channel, method, context, response); } }; @@ -374,7 +376,7 @@ class ClientWriter : public ClientWriterInterface { template ClientWriter(ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, - ClientContext* context, R* response) + ::grpc_impl::ClientContext* context, R* response) : context_(context), cq_(grpc_completion_queue_attributes{ GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, @@ -393,12 +395,12 @@ class ClientWriter : public ClientWriterInterface { } } - ClientContext* context_; + ::grpc_impl::ClientContext* context_; ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, ::grpc::internal::CallOpGenericRecvMessage, ::grpc::internal::CallOpClientRecvStatus> finish_ops_; - CompletionQueue cq_; + ::grpc_impl::CompletionQueue cq_; ::grpc::internal::Call call_; }; @@ -431,7 +433,8 @@ class ClientReaderWriterFactory { public: static ClientReaderWriter* Create( ::grpc::ChannelInterface* channel, - const ::grpc::internal::RpcMethod& method, ClientContext* context) { + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context) { return new ClientReaderWriter(channel, method, context); } }; @@ -539,8 +542,8 @@ class ClientReaderWriter final : public ClientReaderWriterInterface { private: friend class internal::ClientReaderWriterFactory; - ClientContext* context_; - CompletionQueue cq_; + ::grpc_impl::ClientContext* context_; + ::grpc_impl::CompletionQueue cq_; ::grpc::internal::Call call_; /// Block to create a stream and write the initial metadata and \a request @@ -548,7 +551,7 @@ class ClientReaderWriter final : public ClientReaderWriterInterface { /// used to send to the server when starting the call. ClientReaderWriter(::grpc::ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, - ClientContext* context) + ::grpc_impl::ClientContext* context) : context_(context), cq_(grpc_completion_queue_attributes{ GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, @@ -607,12 +610,12 @@ class ServerReader final : public ServerReaderInterface { private: internal::Call* const call_; - ServerContext* const ctx_; + ::grpc_impl::ServerContext* const ctx_; template friend class internal::ClientStreamingHandler; - ServerReader(internal::Call* call, ServerContext* ctx) + ServerReader(internal::Call* call, ::grpc_impl::ServerContext* ctx) : call_(call), ctx_(ctx) {} }; @@ -681,12 +684,12 @@ class ServerWriter final : public ServerWriterInterface { private: internal::Call* const call_; - ServerContext* const ctx_; + ::grpc_impl::ServerContext* const ctx_; template friend class internal::ServerStreamingHandler; - ServerWriter(internal::Call* call, ServerContext* ctx) + ServerWriter(internal::Call* call, ::grpc_impl::ServerContext* ctx) : call_(call), ctx_(ctx) {} }; @@ -701,7 +704,7 @@ namespace internal { template class ServerReaderWriterBody final { public: - ServerReaderWriterBody(Call* call, ServerContext* ctx) + ServerReaderWriterBody(Call* call, ::grpc_impl::ServerContext* ctx) : call_(call), ctx_(ctx) {} void SendInitialMetadata() { @@ -759,7 +762,7 @@ class ServerReaderWriterBody final { private: Call* const call_; - ServerContext* const ctx_; + ::grpc_impl::ServerContext* const ctx_; }; } // namespace internal @@ -797,7 +800,7 @@ class ServerReaderWriter final : public ServerReaderWriterInterface { friend class internal::TemplatedBidiStreamingHandler, false>; - ServerReaderWriter(internal::Call* call, ServerContext* ctx) + ServerReaderWriter(internal::Call* call, ::grpc_impl::ServerContext* ctx) : body_(call, ctx) {} }; @@ -865,7 +868,7 @@ class ServerUnaryStreamer final friend class internal::TemplatedBidiStreamingHandler< ServerUnaryStreamer, true>; - ServerUnaryStreamer(internal::Call* call, ServerContext* ctx) + ServerUnaryStreamer(internal::Call* call, ::grpc_impl::ServerContext* ctx) : body_(call, ctx), read_done_(false), write_done_(false) {} }; @@ -925,7 +928,7 @@ class ServerSplitStreamer final friend class internal::TemplatedBidiStreamingHandler< ServerSplitStreamer, false>; - ServerSplitStreamer(internal::Call* call, ServerContext* ctx) + ServerSplitStreamer(internal::Call* call, ::grpc_impl::ServerContext* ctx) : body_(call, ctx), read_done_(false) {} }; diff --git a/include/grpcpp/impl/server_builder_plugin.h b/include/grpcpp/impl/server_builder_plugin.h index 84a88f2dd7b..349995c8c1c 100644 --- a/include/grpcpp/impl/server_builder_plugin.h +++ b/include/grpcpp/impl/server_builder_plugin.h @@ -21,11 +21,11 @@ #include +#include #include namespace grpc_impl { -class ChannelArguments; class ServerBuilder; class ServerInitializer; } // namespace grpc_impl @@ -57,7 +57,7 @@ class ServerBuilderPlugin { /// UpdateChannelArguments will be called in ServerBuilder::BuildAndStart(), /// before the Server instance is created. - virtual void UpdateChannelArguments(grpc_impl::ChannelArguments* args) {} + virtual void UpdateChannelArguments(ChannelArguments* args) {} virtual bool has_sync_methods() const { return false; } virtual bool has_async_methods() const { return false; } diff --git a/include/grpcpp/security/credentials.h b/include/grpcpp/security/credentials.h index e924275d592..b124d3d37be 100644 --- a/include/grpcpp/security/credentials.h +++ b/include/grpcpp/security/credentials.h @@ -28,6 +28,7 @@ typedef ::grpc_impl::CallCredentials CallCredentials; typedef ::grpc_impl::SslCredentialsOptions SslCredentialsOptions; typedef ::grpc_impl::SecureCallCredentials SecureCallCredentials; typedef ::grpc_impl::SecureChannelCredentials SecureChannelCredentials; +typedef ::grpc_impl::MetadataCredentialsPlugin MetadataCredentialsPlugin; static inline std::shared_ptr GoogleDefaultCredentials() { diff --git a/include/grpcpp/security/credentials_impl.h b/include/grpcpp/security/credentials_impl.h index 29ba2075c29..34920a55bbe 100644 --- a/include/grpcpp/security/credentials_impl.h +++ b/include/grpcpp/security/credentials_impl.h @@ -24,11 +24,11 @@ #include #include -#include +#include #include #include #include -#include +#include #include #include @@ -41,16 +41,16 @@ class CallCredentials; class SecureCallCredentials; class SecureChannelCredentials; -std::shared_ptr<::grpc::Channel> CreateCustomChannelImpl( +std::shared_ptr CreateCustomChannelImpl( const grpc::string& target, const std::shared_ptr& creds, - const grpc::ChannelArguments& args); + const ChannelArguments& args); namespace experimental { -std::shared_ptr<::grpc::Channel> CreateCustomChannelWithInterceptors( +std::shared_ptr CreateCustomChannelWithInterceptors( const grpc::string& target, const std::shared_ptr& creds, - const grpc::ChannelArguments& args, + const ChannelArguments& args, std::vector< std::unique_ptr> interceptor_creators); @@ -75,27 +75,27 @@ class ChannelCredentials : private grpc::GrpcLibraryCodegen { virtual SecureChannelCredentials* AsSecureCredentials() = 0; private: - friend std::shared_ptr<::grpc::Channel> CreateCustomChannelImpl( + friend std::shared_ptr CreateCustomChannelImpl( const grpc::string& target, const std::shared_ptr& creds, - const grpc::ChannelArguments& args); + const ChannelArguments& args); - friend std::shared_ptr<::grpc::Channel> + friend std::shared_ptr grpc_impl::experimental::CreateCustomChannelWithInterceptors( const grpc::string& target, const std::shared_ptr& creds, - const grpc::ChannelArguments& args, + const ChannelArguments& args, std::vector> interceptor_creators); - virtual std::shared_ptr<::grpc::Channel> CreateChannelImpl( - const grpc::string& target, const grpc::ChannelArguments& args) = 0; + virtual std::shared_ptr CreateChannelImpl( + const grpc::string& target, const ChannelArguments& args) = 0; // This function should have been a pure virtual function, but it is // implemented as a virtual function so that it does not break API. - virtual std::shared_ptr<::grpc::Channel> CreateChannelWithInterceptors( - const grpc::string& target, const grpc::ChannelArguments& args, + virtual std::shared_ptr CreateChannelWithInterceptors( + const grpc::string& target, const ChannelArguments& args, std::vector> interceptor_creators) { diff --git a/include/grpcpp/server_impl.h b/include/grpcpp/server_impl.h index b75012e5da8..a5c8670913e 100644 --- a/include/grpcpp/server_impl.h +++ b/include/grpcpp/server_impl.h @@ -27,16 +27,16 @@ #include #include -#include -#include +#include #include #include #include +#include #include #include #include #include -#include +#include #include #include @@ -80,7 +80,7 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { public: virtual ~GlobalCallbacks() {} /// Called before server is created. - virtual void UpdateArguments(grpc::ChannelArguments* args) {} + virtual void UpdateArguments(ChannelArguments* args) {} /// Called before application callback for each synchronous server request virtual void PreSynchronousRequest(grpc_impl::ServerContext* context) = 0; /// Called after application callback for each synchronous server request @@ -108,8 +108,7 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { } /// Establish a channel for in-process communication - std::shared_ptr<::grpc::Channel> InProcessChannel( - const grpc::ChannelArguments& args); + std::shared_ptr InProcessChannel(const ChannelArguments& args); /// NOTE: class experimental_type is not part of the public API of this class. /// TODO(yashykt): Integrate into public API when this is no longer @@ -120,8 +119,8 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { /// Establish a channel for in-process communication with client /// interceptors - std::shared_ptr<::grpc::Channel> InProcessChannelWithInterceptors( - const grpc::ChannelArguments& args, + std::shared_ptr InProcessChannelWithInterceptors( + const ChannelArguments& args, std::vector> interceptor_creators); @@ -182,9 +181,8 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { /// /// \param sync_cq_timeout_msec The timeout to use when calling AsyncNext() on /// server completion queues passed via sync_server_cqs param. - Server( - int max_message_size, grpc::ChannelArguments* args, - std::shared_ptr>> + Server(int max_message_size, ChannelArguments* args, + std::shared_ptr>> sync_server_cqs, int min_pollers, int max_pollers, int sync_cq_timeout_msec, std::vector< @@ -202,7 +200,7 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { /// caller is required to keep all completion queues live until the server is /// destroyed. /// \param num_cqs How many completion queues does \a cqs hold. - void Start(grpc::ServerCompletionQueue** cqs, size_t num_cqs) override; + void Start(ServerCompletionQueue** cqs, size_t num_cqs) override; grpc_server* server() override { return server_; } @@ -283,7 +281,7 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { return max_receive_message_size_; } - grpc::CompletionQueue* CallbackCQ() override; + CompletionQueue* CallbackCQ() override; grpc_impl::ServerInitializer* initializer(); @@ -304,7 +302,7 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { /// The following completion queues are ONLY used in case of Sync API /// i.e. if the server has any services with sync methods. The server uses /// these completion queues to poll for new RPCs - std::shared_ptr>> + std::shared_ptr>> sync_server_cqs_; /// List of \a ThreadManager instances (one for each cq in @@ -374,7 +372,7 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { // It is _not owned_ by the server; ownership belongs with its internal // shutdown callback tag (invoked when the CQ is fully shutdown). // It is protected by mu_ - grpc::CompletionQueue* callback_cq_ = nullptr; + CompletionQueue* callback_cq_ = nullptr; }; } // namespace grpc_impl diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index 23e3bd50eff..358efe9fd79 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -142,14 +142,17 @@ grpc::string GetHeaderIncludes(grpc_generator::File* file, "grpcpp/impl/codegen/async_stream.h", "grpcpp/impl/codegen/async_unary_call.h", "grpcpp/impl/codegen/client_callback.h", + "grpcpp/impl/codegen/client_context.h", "grpcpp/impl/codegen/method_handler_impl.h", "grpcpp/impl/codegen/proto_utils.h", "grpcpp/impl/codegen/rpc_method.h", "grpcpp/impl/codegen/server_callback.h", + "grpcpp/impl/codegen/server_context.h", "grpcpp/impl/codegen/service_type.h", "grpcpp/impl/codegen/status.h", "grpcpp/impl/codegen/stub_options.h", - "grpcpp/impl/codegen/sync_stream.h"}; + "grpcpp/impl/codegen/sync_stream.h", + }; std::vector headers(headers_strs, array_end(headers_strs)); PrintIncludes(printer.get(), headers, params.use_system_headers, params.grpc_search_path); diff --git a/src/cpp/client/create_channel_internal.h b/src/cpp/client/create_channel_internal.h index 3b201afb5a7..4abd4c3dda9 100644 --- a/src/cpp/client/create_channel_internal.h +++ b/src/cpp/client/create_channel_internal.h @@ -21,6 +21,7 @@ #include +#include #include #include diff --git a/src/cpp/client/insecure_credentials.cc b/src/cpp/client/insecure_credentials.cc index dcbb56dccda..0d4ac9978f2 100644 --- a/src/cpp/client/insecure_credentials.cc +++ b/src/cpp/client/insecure_credentials.cc @@ -16,8 +16,6 @@ * */ -#include - #include #include #include @@ -31,16 +29,16 @@ namespace grpc_impl { namespace { class InsecureChannelCredentialsImpl final : public ChannelCredentials { public: - std::shared_ptr<::grpc::Channel> CreateChannelImpl( - const grpc::string& target, const grpc::ChannelArguments& args) override { + std::shared_ptr CreateChannelImpl( + const grpc::string& target, const ChannelArguments& args) override { return CreateChannelWithInterceptors( target, args, std::vector>()); } - std::shared_ptr<::grpc::Channel> CreateChannelWithInterceptors( - const grpc::string& target, const grpc::ChannelArguments& args, + std::shared_ptr CreateChannelWithInterceptors( + const grpc::string& target, const ChannelArguments& args, std::vector> interceptor_creators) override { diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index 197112d4bb7..d73b3e035c8 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -36,17 +36,17 @@ SecureChannelCredentials::SecureChannelCredentials( g_gli_initializer.summon(); } -std::shared_ptr SecureChannelCredentials::CreateChannelImpl( - const grpc::string& target, const grpc::ChannelArguments& args) { +std::shared_ptr SecureChannelCredentials::CreateChannelImpl( + const grpc::string& target, const ChannelArguments& args) { return CreateChannelWithInterceptors( target, args, std::vector>()); } -std::shared_ptr +std::shared_ptr SecureChannelCredentials::CreateChannelWithInterceptors( - const grpc::string& target, const grpc::ChannelArguments& args, + const grpc::string& target, const ChannelArguments& args, std::vector< std::unique_ptr> interceptor_creators) { @@ -209,7 +209,7 @@ std::shared_ptr CompositeCallCredentials( return nullptr; } -std::shared_ptr MetadataCredentialsFromPlugin( +std::shared_ptr MetadataCredentialsFromPlugin( std::unique_ptr plugin) { grpc::GrpcLibraryCodegen init; // To call grpc_init(). const char* type = plugin->GetType(); diff --git a/src/cpp/client/secure_credentials.h b/src/cpp/client/secure_credentials.h index c4eef6c746d..dd379ca657d 100644 --- a/src/cpp/client/secure_credentials.h +++ b/src/cpp/client/secure_credentials.h @@ -39,14 +39,14 @@ class SecureChannelCredentials final : public ChannelCredentials { } grpc_channel_credentials* GetRawCreds() { return c_creds_; } - std::shared_ptr<::grpc::Channel> CreateChannelImpl( - const grpc::string& target, const grpc::ChannelArguments& args) override; + std::shared_ptr CreateChannelImpl( + const grpc::string& target, const ChannelArguments& args) override; SecureChannelCredentials* AsSecureCredentials() override { return this; } private: - std::shared_ptr<::grpc::Channel> CreateChannelWithInterceptors( - const grpc::string& target, const grpc::ChannelArguments& args, + std::shared_ptr CreateChannelWithInterceptors( + const grpc::string& target, const ChannelArguments& args, std::vector> interceptor_creators) override; diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h index 89b0e3af4b2..6c2f36451bc 100644 --- a/test/cpp/qps/server.h +++ b/test/cpp/qps/server.h @@ -19,6 +19,7 @@ #ifndef TEST_QPS_SERVER_H #define TEST_QPS_SERVER_H +#include #include #include #include diff --git a/test/cpp/util/create_test_channel.h b/test/cpp/util/create_test_channel.h index 42564a31ec8..131e8264114 100644 --- a/test/cpp/util/create_test_channel.h +++ b/test/cpp/util/create_test_channel.h @@ -21,8 +21,11 @@ #include +#include #include #include +#include + namespace grpc_impl { @@ -32,36 +35,35 @@ class Channel; namespace grpc { namespace testing { - typedef enum { INSECURE = 0, TLS, ALTS } transport_security; } // namespace testing -std::shared_ptr<::grpc_impl::Channel> CreateTestChannel( +std::shared_ptr CreateTestChannel( const grpc::string& server, testing::transport_security security_type); -std::shared_ptr<::grpc_impl::Channel> CreateTestChannel( +std::shared_ptr CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, testing::transport_security security_type, bool use_prod_roots); -std::shared_ptr<::grpc_impl::Channel> CreateTestChannel( +std::shared_ptr CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, testing::transport_security security_type, bool use_prod_roots, const std::shared_ptr& creds); -std::shared_ptr<::grpc_impl::Channel> CreateTestChannel( +std::shared_ptr CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, testing::transport_security security_type, bool use_prod_roots, const std::shared_ptr& creds, const ChannelArguments& args); -std::shared_ptr<::grpc_impl::Channel> CreateTestChannel( +std::shared_ptr CreateTestChannel( const grpc::string& server, const grpc::string& cred_type, const grpc::string& override_hostname, bool use_prod_roots, const std::shared_ptr& creds, const ChannelArguments& args); -std::shared_ptr<::grpc_impl::Channel> CreateTestChannel( +std::shared_ptr CreateTestChannel( const grpc::string& server, const grpc::string& credential_type, const std::shared_ptr& creds); @@ -76,7 +78,8 @@ std::shared_ptr CreateTestChannel( std::shared_ptr CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, testing::transport_security security_type, bool use_prod_roots, - const std::shared_ptr& creds, const ChannelArguments& args, + const std::shared_ptr& creds, + const ChannelArguments& args, std::vector< std::unique_ptr> interceptor_creators); @@ -84,7 +87,8 @@ std::shared_ptr CreateTestChannel( std::shared_ptr CreateTestChannel( const grpc::string& server, const grpc::string& cred_type, const grpc::string& override_hostname, bool use_prod_roots, - const std::shared_ptr& creds, const ChannelArguments& args, + const std::shared_ptr& creds, + const ChannelArguments& args, std::vector< std::unique_ptr> interceptor_creators); From 3ddff567b7cae91d1b313d3ea7f6defb865c75a1 Mon Sep 17 00:00:00 2001 From: Guantao Liu Date: Fri, 21 Jun 2019 10:55:26 -0700 Subject: [PATCH 0638/1555] Fix the missing traces of metadata unref. --- src/core/lib/transport/metadata.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h index 3cef031031d..4b9685066e5 100644 --- a/src/core/lib/transport/metadata.h +++ b/src/core/lib/transport/metadata.h @@ -348,10 +348,11 @@ inline void grpc_mdelem_unref(grpc_mdelem gmd) { free an interned md at any time: it's unsafe from this point on to access it so we read the hash now. */ uint32_t hash = md->hash(); - if (GPR_UNLIKELY(md->Unref())) { #ifndef NDEBUG + if (GPR_UNLIKELY(md->Unref(file, line))) { grpc_mdelem_on_final_unref(storage, md, hash, file, line); #else + if (GPR_UNLIKELY(md->Unref())) { grpc_mdelem_on_final_unref(storage, md, hash); #endif } From 63083d44725546e2f020e783ae5bdb26fd6d8afc Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Fri, 21 Jun 2019 11:19:34 -0700 Subject: [PATCH 0639/1555] Code cleanup --- include/grpcpp/generic/generic_stub_impl.h | 1 + src/cpp/client/insecure_credentials.cc | 2 +- test/cpp/util/create_test_channel.h | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/grpcpp/generic/generic_stub_impl.h b/include/grpcpp/generic/generic_stub_impl.h index 90414611cbd..fdbc0d0a272 100644 --- a/include/grpcpp/generic/generic_stub_impl.h +++ b/include/grpcpp/generic/generic_stub_impl.h @@ -21,6 +21,7 @@ #include +#include #include #include #include diff --git a/src/cpp/client/insecure_credentials.cc b/src/cpp/client/insecure_credentials.cc index 0d4ac9978f2..0556fa0e50f 100644 --- a/src/cpp/client/insecure_credentials.cc +++ b/src/cpp/client/insecure_credentials.cc @@ -15,11 +15,11 @@ * limitations under the License. * */ +#include #include #include #include -#include #include #include #include "src/cpp/client/create_channel_internal.h" diff --git a/test/cpp/util/create_test_channel.h b/test/cpp/util/create_test_channel.h index 131e8264114..ab5c7f39ebb 100644 --- a/test/cpp/util/create_test_channel.h +++ b/test/cpp/util/create_test_channel.h @@ -35,6 +35,7 @@ class Channel; namespace grpc { namespace testing { + typedef enum { INSECURE = 0, TLS, ALTS } transport_security; } // namespace testing From 491d4a8d935115dbd4e3073776ee7f665ebca4f4 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 21 Jun 2019 11:31:46 -0700 Subject: [PATCH 0640/1555] test name matching --- test/core/iomgr/mpmcqueue_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index ad47c657def..fdcc2d6019f 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -128,7 +128,7 @@ static void test_get_empty(void) { } static void test_FIFO(void) { - gpr_log(GPR_INFO, "test_large_queue"); + gpr_log(GPR_INFO, "test_FIFO"); grpc_core::InfLenFIFOQueue large_queue; for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { large_queue.Put(static_cast(new WorkItem(i))); From 684328b313455196e5af364f993e1de9f5ca2723 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Fri, 21 Jun 2019 21:21:45 +0200 Subject: [PATCH 0641/1555] Regenerating upb files. --- .../envoy/api/v2/auth/cert.upb.c | 8 +- .../envoy/api/v2/auth/cert.upb.h | 93 ++-- .../ext/upb-generated/envoy/api/v2/cds.upb.c | 150 +++--- .../ext/upb-generated/envoy/api/v2/cds.upb.h | 449 +++++++++++------- .../api/v2/cluster/circuit_breaker.upb.c | 16 +- .../api/v2/cluster/circuit_breaker.upb.h | 51 +- .../api/v2/cluster/outlier_detection.upb.h | 12 +- .../envoy/api/v2/core/address.upb.h | 50 +- .../envoy/api/v2/core/base.upb.c | 24 + .../envoy/api/v2/core/base.upb.h | 139 ++++-- .../envoy/api/v2/core/config_source.upb.c | 14 +- .../envoy/api/v2/core/config_source.upb.h | 70 +-- .../envoy/api/v2/core/grpc_service.upb.h | 82 ++-- .../envoy/api/v2/core/health_check.upb.c | 54 ++- .../envoy/api/v2/core/health_check.upb.h | 172 ++++--- .../envoy/api/v2/core/protocol.upb.c | 5 +- .../envoy/api/v2/core/protocol.upb.h | 40 +- .../envoy/api/v2/discovery.upb.c | 55 ++- .../envoy/api/v2/discovery.upb.h | 262 +++++----- .../ext/upb-generated/envoy/api/v2/eds.upb.c | 40 +- .../ext/upb-generated/envoy/api/v2/eds.upb.h | 97 +++- .../envoy/api/v2/endpoint/endpoint.upb.c | 20 +- .../envoy/api/v2/endpoint/endpoint.upb.h | 76 ++- .../envoy/api/v2/endpoint/load_report.upb.c | 38 +- .../envoy/api/v2/endpoint/load_report.upb.h | 119 +++-- .../envoy/service/discovery/v2/ads.upb.h | 12 +- .../envoy/service/load_stats/v2/lrs.upb.h | 18 +- .../upb-generated/envoy/type/percent.upb.h | 18 +- .../ext/upb-generated/envoy/type/range.upb.h | 18 +- .../ext/upb-generated/gogoproto/gogo.upb.h | 7 +- .../google/api/annotations.upb.h | 7 +- .../ext/upb-generated/google/api/http.upb.h | 28 +- .../upb-generated/google/protobuf/any.upb.h | 12 +- .../google/protobuf/descriptor.upb.h | 168 ++++--- .../google/protobuf/duration.upb.h | 12 +- .../upb-generated/google/protobuf/empty.upb.h | 12 +- .../google/protobuf/struct.upb.h | 34 +- .../google/protobuf/timestamp.upb.h | 12 +- .../google/protobuf/wrappers.upb.h | 60 ++- .../ext/upb-generated/google/rpc/status.upb.h | 12 +- .../ext/upb-generated/validate/validate.upb.h | 156 +++--- 41 files changed, 1572 insertions(+), 1150 deletions(-) diff --git a/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c b/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c index e8a2fb32bab..844ad3d147f 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +++ b/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c @@ -124,20 +124,22 @@ const upb_msglayout envoy_api_v2_auth_CommonTlsContext_CombinedCertificateValida UPB_SIZE(8, 16), 2, false, }; -static const upb_msglayout *const envoy_api_v2_auth_UpstreamTlsContext_submsgs[1] = { +static const upb_msglayout *const envoy_api_v2_auth_UpstreamTlsContext_submsgs[2] = { &envoy_api_v2_auth_CommonTlsContext_msginit, + &google_protobuf_UInt32Value_msginit, }; -static const upb_msglayout_field envoy_api_v2_auth_UpstreamTlsContext__fields[3] = { +static const upb_msglayout_field envoy_api_v2_auth_UpstreamTlsContext__fields[4] = { {1, UPB_SIZE(12, 24), 0, 0, 11, 1}, {2, UPB_SIZE(4, 8), 0, 0, 9, 1}, {3, UPB_SIZE(0, 0), 0, 0, 8, 1}, + {4, UPB_SIZE(16, 32), 0, 1, 11, 1}, }; const upb_msglayout envoy_api_v2_auth_UpstreamTlsContext_msginit = { &envoy_api_v2_auth_UpstreamTlsContext_submsgs[0], &envoy_api_v2_auth_UpstreamTlsContext__fields[0], - UPB_SIZE(16, 32), 3, false, + UPB_SIZE(24, 48), 4, false, }; static const upb_msglayout *const envoy_api_v2_auth_DownstreamTlsContext_submsgs[5] = { diff --git a/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h b/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h index 22379341331..89aeaee2fd7 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h @@ -10,12 +10,12 @@ #define ENVOY_API_V2_AUTH_CERT_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -53,11 +53,11 @@ extern const upb_msglayout envoy_api_v2_auth_Secret_msginit; struct envoy_api_v2_core_ConfigSource; struct envoy_api_v2_core_DataSource; struct google_protobuf_BoolValue; +struct google_protobuf_UInt32Value; extern const upb_msglayout envoy_api_v2_core_ConfigSource_msginit; extern const upb_msglayout envoy_api_v2_core_DataSource_msginit; extern const upb_msglayout google_protobuf_BoolValue_msginit; - -/* Enums */ +extern const upb_msglayout google_protobuf_UInt32Value_msginit; typedef enum { envoy_api_v2_auth_TlsParameters_TLS_AUTO = 0, @@ -73,9 +73,10 @@ typedef enum { UPB_INLINE envoy_api_v2_auth_TlsParameters *envoy_api_v2_auth_TlsParameters_new(upb_arena *arena) { return (envoy_api_v2_auth_TlsParameters *)upb_msg_new(&envoy_api_v2_auth_TlsParameters_msginit, arena); } -UPB_INLINE envoy_api_v2_auth_TlsParameters *envoy_api_v2_auth_TlsParameters_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_auth_TlsParameters *envoy_api_v2_auth_TlsParameters_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_auth_TlsParameters *ret = envoy_api_v2_auth_TlsParameters_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_auth_TlsParameters_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_auth_TlsParameters_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_auth_TlsParameters_serialize(const envoy_api_v2_auth_TlsParameters *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_auth_TlsParameters_msginit, arena, len); @@ -113,15 +114,15 @@ UPB_INLINE bool envoy_api_v2_auth_TlsParameters_add_ecdh_curves(envoy_api_v2_aut msg, UPB_SIZE(20, 24), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); } - /* envoy.api.v2.auth.TlsCertificate */ UPB_INLINE envoy_api_v2_auth_TlsCertificate *envoy_api_v2_auth_TlsCertificate_new(upb_arena *arena) { return (envoy_api_v2_auth_TlsCertificate *)upb_msg_new(&envoy_api_v2_auth_TlsCertificate_msginit, arena); } -UPB_INLINE envoy_api_v2_auth_TlsCertificate *envoy_api_v2_auth_TlsCertificate_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_auth_TlsCertificate *envoy_api_v2_auth_TlsCertificate_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_auth_TlsCertificate *ret = envoy_api_v2_auth_TlsCertificate_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_auth_TlsCertificate_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_auth_TlsCertificate_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_auth_TlsCertificate_serialize(const envoy_api_v2_auth_TlsCertificate *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_auth_TlsCertificate_msginit, arena, len); @@ -195,15 +196,15 @@ UPB_INLINE struct envoy_api_v2_core_DataSource* envoy_api_v2_auth_TlsCertificate return sub; } - /* envoy.api.v2.auth.TlsSessionTicketKeys */ UPB_INLINE envoy_api_v2_auth_TlsSessionTicketKeys *envoy_api_v2_auth_TlsSessionTicketKeys_new(upb_arena *arena) { return (envoy_api_v2_auth_TlsSessionTicketKeys *)upb_msg_new(&envoy_api_v2_auth_TlsSessionTicketKeys_msginit, arena); } -UPB_INLINE envoy_api_v2_auth_TlsSessionTicketKeys *envoy_api_v2_auth_TlsSessionTicketKeys_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_auth_TlsSessionTicketKeys *envoy_api_v2_auth_TlsSessionTicketKeys_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_auth_TlsSessionTicketKeys *ret = envoy_api_v2_auth_TlsSessionTicketKeys_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_auth_TlsSessionTicketKeys_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_auth_TlsSessionTicketKeys_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_auth_TlsSessionTicketKeys_serialize(const envoy_api_v2_auth_TlsSessionTicketKeys *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_auth_TlsSessionTicketKeys_msginit, arena, len); @@ -225,15 +226,15 @@ UPB_INLINE struct envoy_api_v2_core_DataSource* envoy_api_v2_auth_TlsSessionTick return sub; } - /* envoy.api.v2.auth.CertificateValidationContext */ UPB_INLINE envoy_api_v2_auth_CertificateValidationContext *envoy_api_v2_auth_CertificateValidationContext_new(upb_arena *arena) { return (envoy_api_v2_auth_CertificateValidationContext *)upb_msg_new(&envoy_api_v2_auth_CertificateValidationContext_msginit, arena); } -UPB_INLINE envoy_api_v2_auth_CertificateValidationContext *envoy_api_v2_auth_CertificateValidationContext_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_auth_CertificateValidationContext *envoy_api_v2_auth_CertificateValidationContext_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_auth_CertificateValidationContext *ret = envoy_api_v2_auth_CertificateValidationContext_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_auth_CertificateValidationContext_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_auth_CertificateValidationContext_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_auth_CertificateValidationContext_serialize(const envoy_api_v2_auth_CertificateValidationContext *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_auth_CertificateValidationContext_msginit, arena, len); @@ -330,15 +331,15 @@ UPB_INLINE void envoy_api_v2_auth_CertificateValidationContext_set_allow_expired UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)) = value; } - /* envoy.api.v2.auth.CommonTlsContext */ UPB_INLINE envoy_api_v2_auth_CommonTlsContext *envoy_api_v2_auth_CommonTlsContext_new(upb_arena *arena) { return (envoy_api_v2_auth_CommonTlsContext *)upb_msg_new(&envoy_api_v2_auth_CommonTlsContext_msginit, arena); } -UPB_INLINE envoy_api_v2_auth_CommonTlsContext *envoy_api_v2_auth_CommonTlsContext_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_auth_CommonTlsContext *envoy_api_v2_auth_CommonTlsContext_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_auth_CommonTlsContext *ret = envoy_api_v2_auth_CommonTlsContext_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_auth_CommonTlsContext_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_auth_CommonTlsContext_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_auth_CommonTlsContext_serialize(const envoy_api_v2_auth_CommonTlsContext *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_auth_CommonTlsContext_msginit, arena, len); @@ -348,9 +349,9 @@ typedef enum { envoy_api_v2_auth_CommonTlsContext_validation_context_type_validation_context = 3, envoy_api_v2_auth_CommonTlsContext_validation_context_type_validation_context_sds_secret_config = 7, envoy_api_v2_auth_CommonTlsContext_validation_context_type_combined_validation_context = 8, - envoy_api_v2_auth_CommonTlsContext_validation_context_type_NOT_SET = 0, + envoy_api_v2_auth_CommonTlsContext_validation_context_type_NOT_SET = 0 } envoy_api_v2_auth_CommonTlsContext_validation_context_type_oneofcases; -UPB_INLINE envoy_api_v2_auth_CommonTlsContext_validation_context_type_oneofcases envoy_api_v2_auth_CommonTlsContext_validation_context_type_case(const envoy_api_v2_auth_CommonTlsContext* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(20, 40)); } +UPB_INLINE envoy_api_v2_auth_CommonTlsContext_validation_context_type_oneofcases envoy_api_v2_auth_CommonTlsContext_validation_context_type_case(const envoy_api_v2_auth_CommonTlsContext* msg) { return (envoy_api_v2_auth_CommonTlsContext_validation_context_type_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(20, 40)); } UPB_INLINE const envoy_api_v2_auth_TlsParameters* envoy_api_v2_auth_CommonTlsContext_tls_params(const envoy_api_v2_auth_CommonTlsContext *msg) { return UPB_FIELD_AT(msg, const envoy_api_v2_auth_TlsParameters*, UPB_SIZE(0, 0)); } UPB_INLINE const envoy_api_v2_auth_TlsCertificate* const* envoy_api_v2_auth_CommonTlsContext_tls_certificates(const envoy_api_v2_auth_CommonTlsContext *msg, size_t *len) { return (const envoy_api_v2_auth_TlsCertificate* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); } @@ -448,15 +449,15 @@ UPB_INLINE struct envoy_api_v2_auth_CommonTlsContext_CombinedCertificateValidati return sub; } - /* envoy.api.v2.auth.CommonTlsContext.CombinedCertificateValidationContext */ UPB_INLINE envoy_api_v2_auth_CommonTlsContext_CombinedCertificateValidationContext *envoy_api_v2_auth_CommonTlsContext_CombinedCertificateValidationContext_new(upb_arena *arena) { return (envoy_api_v2_auth_CommonTlsContext_CombinedCertificateValidationContext *)upb_msg_new(&envoy_api_v2_auth_CommonTlsContext_CombinedCertificateValidationContext_msginit, arena); } -UPB_INLINE envoy_api_v2_auth_CommonTlsContext_CombinedCertificateValidationContext *envoy_api_v2_auth_CommonTlsContext_CombinedCertificateValidationContext_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_auth_CommonTlsContext_CombinedCertificateValidationContext *envoy_api_v2_auth_CommonTlsContext_CombinedCertificateValidationContext_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_auth_CommonTlsContext_CombinedCertificateValidationContext *ret = envoy_api_v2_auth_CommonTlsContext_CombinedCertificateValidationContext_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_auth_CommonTlsContext_CombinedCertificateValidationContext_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_auth_CommonTlsContext_CombinedCertificateValidationContext_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_auth_CommonTlsContext_CombinedCertificateValidationContext_serialize(const envoy_api_v2_auth_CommonTlsContext_CombinedCertificateValidationContext *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_auth_CommonTlsContext_CombinedCertificateValidationContext_msginit, arena, len); @@ -490,15 +491,15 @@ UPB_INLINE struct envoy_api_v2_auth_SdsSecretConfig* envoy_api_v2_auth_CommonTls return sub; } - /* envoy.api.v2.auth.UpstreamTlsContext */ UPB_INLINE envoy_api_v2_auth_UpstreamTlsContext *envoy_api_v2_auth_UpstreamTlsContext_new(upb_arena *arena) { return (envoy_api_v2_auth_UpstreamTlsContext *)upb_msg_new(&envoy_api_v2_auth_UpstreamTlsContext_msginit, arena); } -UPB_INLINE envoy_api_v2_auth_UpstreamTlsContext *envoy_api_v2_auth_UpstreamTlsContext_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_auth_UpstreamTlsContext *envoy_api_v2_auth_UpstreamTlsContext_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_auth_UpstreamTlsContext *ret = envoy_api_v2_auth_UpstreamTlsContext_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_auth_UpstreamTlsContext_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_auth_UpstreamTlsContext_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_auth_UpstreamTlsContext_serialize(const envoy_api_v2_auth_UpstreamTlsContext *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_auth_UpstreamTlsContext_msginit, arena, len); @@ -507,6 +508,7 @@ UPB_INLINE char *envoy_api_v2_auth_UpstreamTlsContext_serialize(const envoy_api_ UPB_INLINE const envoy_api_v2_auth_CommonTlsContext* envoy_api_v2_auth_UpstreamTlsContext_common_tls_context(const envoy_api_v2_auth_UpstreamTlsContext *msg) { return UPB_FIELD_AT(msg, const envoy_api_v2_auth_CommonTlsContext*, UPB_SIZE(12, 24)); } UPB_INLINE upb_strview envoy_api_v2_auth_UpstreamTlsContext_sni(const envoy_api_v2_auth_UpstreamTlsContext *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } UPB_INLINE bool envoy_api_v2_auth_UpstreamTlsContext_allow_renegotiation(const envoy_api_v2_auth_UpstreamTlsContext *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_auth_UpstreamTlsContext_max_session_keys(const envoy_api_v2_auth_UpstreamTlsContext *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(16, 32)); } UPB_INLINE void envoy_api_v2_auth_UpstreamTlsContext_set_common_tls_context(envoy_api_v2_auth_UpstreamTlsContext *msg, envoy_api_v2_auth_CommonTlsContext* value) { UPB_FIELD_AT(msg, envoy_api_v2_auth_CommonTlsContext*, UPB_SIZE(12, 24)) = value; @@ -526,16 +528,28 @@ UPB_INLINE void envoy_api_v2_auth_UpstreamTlsContext_set_sni(envoy_api_v2_auth_U UPB_INLINE void envoy_api_v2_auth_UpstreamTlsContext_set_allow_renegotiation(envoy_api_v2_auth_UpstreamTlsContext *msg, bool value) { UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)) = value; } - +UPB_INLINE void envoy_api_v2_auth_UpstreamTlsContext_set_max_session_keys(envoy_api_v2_auth_UpstreamTlsContext *msg, struct google_protobuf_UInt32Value* value) { + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(16, 32)) = value; +} +UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_auth_UpstreamTlsContext_mutable_max_session_keys(envoy_api_v2_auth_UpstreamTlsContext *msg, upb_arena *arena) { + struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_auth_UpstreamTlsContext_max_session_keys(msg); + if (sub == NULL) { + sub = (struct google_protobuf_UInt32Value*)upb_msg_new(&google_protobuf_UInt32Value_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_auth_UpstreamTlsContext_set_max_session_keys(msg, sub); + } + return sub; +} /* envoy.api.v2.auth.DownstreamTlsContext */ UPB_INLINE envoy_api_v2_auth_DownstreamTlsContext *envoy_api_v2_auth_DownstreamTlsContext_new(upb_arena *arena) { return (envoy_api_v2_auth_DownstreamTlsContext *)upb_msg_new(&envoy_api_v2_auth_DownstreamTlsContext_msginit, arena); } -UPB_INLINE envoy_api_v2_auth_DownstreamTlsContext *envoy_api_v2_auth_DownstreamTlsContext_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_auth_DownstreamTlsContext *envoy_api_v2_auth_DownstreamTlsContext_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_auth_DownstreamTlsContext *ret = envoy_api_v2_auth_DownstreamTlsContext_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_auth_DownstreamTlsContext_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_auth_DownstreamTlsContext_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_auth_DownstreamTlsContext_serialize(const envoy_api_v2_auth_DownstreamTlsContext *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_auth_DownstreamTlsContext_msginit, arena, len); @@ -544,9 +558,9 @@ UPB_INLINE char *envoy_api_v2_auth_DownstreamTlsContext_serialize(const envoy_ap typedef enum { envoy_api_v2_auth_DownstreamTlsContext_session_ticket_keys_type_session_ticket_keys = 4, envoy_api_v2_auth_DownstreamTlsContext_session_ticket_keys_type_session_ticket_keys_sds_secret_config = 5, - envoy_api_v2_auth_DownstreamTlsContext_session_ticket_keys_type_NOT_SET = 0, + envoy_api_v2_auth_DownstreamTlsContext_session_ticket_keys_type_NOT_SET = 0 } envoy_api_v2_auth_DownstreamTlsContext_session_ticket_keys_type_oneofcases; -UPB_INLINE envoy_api_v2_auth_DownstreamTlsContext_session_ticket_keys_type_oneofcases envoy_api_v2_auth_DownstreamTlsContext_session_ticket_keys_type_case(const envoy_api_v2_auth_DownstreamTlsContext* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(16, 32)); } +UPB_INLINE envoy_api_v2_auth_DownstreamTlsContext_session_ticket_keys_type_oneofcases envoy_api_v2_auth_DownstreamTlsContext_session_ticket_keys_type_case(const envoy_api_v2_auth_DownstreamTlsContext* msg) { return (envoy_api_v2_auth_DownstreamTlsContext_session_ticket_keys_type_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 32)); } UPB_INLINE const envoy_api_v2_auth_CommonTlsContext* envoy_api_v2_auth_DownstreamTlsContext_common_tls_context(const envoy_api_v2_auth_DownstreamTlsContext *msg) { return UPB_FIELD_AT(msg, const envoy_api_v2_auth_CommonTlsContext*, UPB_SIZE(0, 0)); } UPB_INLINE const struct google_protobuf_BoolValue* envoy_api_v2_auth_DownstreamTlsContext_require_client_certificate(const envoy_api_v2_auth_DownstreamTlsContext *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_BoolValue*, UPB_SIZE(4, 8)); } @@ -617,15 +631,15 @@ UPB_INLINE struct envoy_api_v2_auth_SdsSecretConfig* envoy_api_v2_auth_Downstrea return sub; } - /* envoy.api.v2.auth.SdsSecretConfig */ UPB_INLINE envoy_api_v2_auth_SdsSecretConfig *envoy_api_v2_auth_SdsSecretConfig_new(upb_arena *arena) { return (envoy_api_v2_auth_SdsSecretConfig *)upb_msg_new(&envoy_api_v2_auth_SdsSecretConfig_msginit, arena); } -UPB_INLINE envoy_api_v2_auth_SdsSecretConfig *envoy_api_v2_auth_SdsSecretConfig_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_auth_SdsSecretConfig *envoy_api_v2_auth_SdsSecretConfig_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_auth_SdsSecretConfig *ret = envoy_api_v2_auth_SdsSecretConfig_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_auth_SdsSecretConfig_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_auth_SdsSecretConfig_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_auth_SdsSecretConfig_serialize(const envoy_api_v2_auth_SdsSecretConfig *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_auth_SdsSecretConfig_msginit, arena, len); @@ -650,15 +664,15 @@ UPB_INLINE struct envoy_api_v2_core_ConfigSource* envoy_api_v2_auth_SdsSecretCon return sub; } - /* envoy.api.v2.auth.Secret */ UPB_INLINE envoy_api_v2_auth_Secret *envoy_api_v2_auth_Secret_new(upb_arena *arena) { return (envoy_api_v2_auth_Secret *)upb_msg_new(&envoy_api_v2_auth_Secret_msginit, arena); } -UPB_INLINE envoy_api_v2_auth_Secret *envoy_api_v2_auth_Secret_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_auth_Secret *envoy_api_v2_auth_Secret_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_auth_Secret *ret = envoy_api_v2_auth_Secret_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_auth_Secret_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_auth_Secret_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_auth_Secret_serialize(const envoy_api_v2_auth_Secret *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_auth_Secret_msginit, arena, len); @@ -668,9 +682,9 @@ typedef enum { envoy_api_v2_auth_Secret_type_tls_certificate = 2, envoy_api_v2_auth_Secret_type_session_ticket_keys = 3, envoy_api_v2_auth_Secret_type_validation_context = 4, - envoy_api_v2_auth_Secret_type_NOT_SET = 0, + envoy_api_v2_auth_Secret_type_NOT_SET = 0 } envoy_api_v2_auth_Secret_type_oneofcases; -UPB_INLINE envoy_api_v2_auth_Secret_type_oneofcases envoy_api_v2_auth_Secret_type_case(const envoy_api_v2_auth_Secret* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(12, 24)); } +UPB_INLINE envoy_api_v2_auth_Secret_type_oneofcases envoy_api_v2_auth_Secret_type_case(const envoy_api_v2_auth_Secret* msg) { return (envoy_api_v2_auth_Secret_type_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(12, 24)); } UPB_INLINE upb_strview envoy_api_v2_auth_Secret_name(const envoy_api_v2_auth_Secret *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } UPB_INLINE bool envoy_api_v2_auth_Secret_has_tls_certificate(const envoy_api_v2_auth_Secret *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(12, 24), 2); } @@ -720,7 +734,6 @@ UPB_INLINE struct envoy_api_v2_auth_CertificateValidationContext* envoy_api_v2_a return sub; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c b/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c index 91a25cd220b..f5a7b9195e1 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c +++ b/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c @@ -30,11 +30,13 @@ #include "upb/port_def.inc" -static const upb_msglayout *const envoy_api_v2_Cluster_submsgs[26] = { +static const upb_msglayout *const envoy_api_v2_Cluster_submsgs[28] = { &envoy_api_v2_Cluster_CommonLbConfig_msginit, + &envoy_api_v2_Cluster_CustomClusterType_msginit, &envoy_api_v2_Cluster_EdsClusterConfig_msginit, &envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry_msginit, &envoy_api_v2_Cluster_LbSubsetConfig_msginit, + &envoy_api_v2_Cluster_LeastRequestLbConfig_msginit, &envoy_api_v2_Cluster_OriginalDstLbConfig_msginit, &envoy_api_v2_Cluster_RingHashLbConfig_msginit, &envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry_msginit, @@ -55,47 +57,64 @@ static const upb_msglayout *const envoy_api_v2_Cluster_submsgs[26] = { &google_protobuf_UInt32Value_msginit, }; -static const upb_msglayout_field envoy_api_v2_Cluster__fields[34] = { - {1, UPB_SIZE(36, 40), 0, 0, 9, 1}, - {2, UPB_SIZE(0, 0), 0, 0, 14, 1}, - {3, UPB_SIZE(52, 72), 0, 1, 11, 1}, - {4, UPB_SIZE(56, 80), 0, 20, 11, 1}, - {5, UPB_SIZE(60, 88), 0, 21, 11, 1}, - {6, UPB_SIZE(8, 8), 0, 0, 14, 1}, - {7, UPB_SIZE(128, 224), 0, 12, 11, 3}, - {8, UPB_SIZE(132, 232), 0, 14, 11, 3}, - {9, UPB_SIZE(64, 96), 0, 21, 11, 1}, - {10, UPB_SIZE(68, 104), 0, 10, 11, 1}, - {11, UPB_SIZE(72, 112), 0, 9, 11, 1}, - {13, UPB_SIZE(76, 120), 0, 15, 11, 1}, - {14, UPB_SIZE(80, 128), 0, 16, 11, 1}, - {16, UPB_SIZE(84, 136), 0, 20, 11, 1}, - {17, UPB_SIZE(16, 16), 0, 0, 14, 1}, - {18, UPB_SIZE(136, 240), 0, 12, 11, 3}, - {19, UPB_SIZE(88, 144), 0, 11, 11, 1}, - {20, UPB_SIZE(92, 152), 0, 20, 11, 1}, - {21, UPB_SIZE(96, 160), 0, 13, 11, 1}, - {22, UPB_SIZE(100, 168), 0, 3, 11, 1}, - {23, UPB_SIZE(148, 264), UPB_SIZE(-153, -273), 5, 11, 1}, - {24, UPB_SIZE(104, 176), 0, 19, 11, 1}, - {25, UPB_SIZE(108, 184), 0, 18, 11, 1}, - {26, UPB_SIZE(24, 24), 0, 0, 14, 1}, - {27, UPB_SIZE(112, 192), 0, 0, 11, 1}, - {28, UPB_SIZE(44, 56), 0, 0, 9, 1}, - {29, UPB_SIZE(116, 200), 0, 17, 11, 1}, - {30, UPB_SIZE(120, 208), 0, 8, 11, 1}, - {31, UPB_SIZE(32, 32), 0, 0, 8, 1}, - {32, UPB_SIZE(33, 33), 0, 0, 8, 1}, - {33, UPB_SIZE(124, 216), 0, 7, 11, 1}, - {34, UPB_SIZE(148, 264), UPB_SIZE(-153, -273), 4, 11, 1}, - {35, UPB_SIZE(140, 248), 0, 2, 11, 3}, - {36, UPB_SIZE(144, 256), 0, 6, 11, 3}, +static const upb_msglayout_field envoy_api_v2_Cluster__fields[36] = { + {1, UPB_SIZE(28, 32), 0, 0, 9, 1}, + {2, UPB_SIZE(144, 256), UPB_SIZE(-153, -265), 0, 14, 1}, + {3, UPB_SIZE(44, 64), 0, 2, 11, 1}, + {4, UPB_SIZE(48, 72), 0, 22, 11, 1}, + {5, UPB_SIZE(52, 80), 0, 23, 11, 1}, + {6, UPB_SIZE(0, 0), 0, 0, 14, 1}, + {7, UPB_SIZE(120, 216), 0, 14, 11, 3}, + {8, UPB_SIZE(124, 224), 0, 16, 11, 3}, + {9, UPB_SIZE(56, 88), 0, 23, 11, 1}, + {10, UPB_SIZE(60, 96), 0, 12, 11, 1}, + {11, UPB_SIZE(64, 104), 0, 11, 11, 1}, + {13, UPB_SIZE(68, 112), 0, 17, 11, 1}, + {14, UPB_SIZE(72, 120), 0, 18, 11, 1}, + {16, UPB_SIZE(76, 128), 0, 22, 11, 1}, + {17, UPB_SIZE(8, 8), 0, 0, 14, 1}, + {18, UPB_SIZE(128, 232), 0, 14, 11, 3}, + {19, UPB_SIZE(80, 136), 0, 13, 11, 1}, + {20, UPB_SIZE(84, 144), 0, 22, 11, 1}, + {21, UPB_SIZE(88, 152), 0, 15, 11, 1}, + {22, UPB_SIZE(92, 160), 0, 4, 11, 1}, + {23, UPB_SIZE(156, 272), UPB_SIZE(-161, -281), 7, 11, 1}, + {24, UPB_SIZE(96, 168), 0, 21, 11, 1}, + {25, UPB_SIZE(100, 176), 0, 20, 11, 1}, + {26, UPB_SIZE(16, 16), 0, 0, 14, 1}, + {27, UPB_SIZE(104, 184), 0, 0, 11, 1}, + {28, UPB_SIZE(36, 48), 0, 0, 9, 1}, + {29, UPB_SIZE(108, 192), 0, 19, 11, 1}, + {30, UPB_SIZE(112, 200), 0, 10, 11, 1}, + {31, UPB_SIZE(24, 24), 0, 0, 8, 1}, + {32, UPB_SIZE(25, 25), 0, 0, 8, 1}, + {33, UPB_SIZE(116, 208), 0, 9, 11, 1}, + {34, UPB_SIZE(156, 272), UPB_SIZE(-161, -281), 6, 11, 1}, + {35, UPB_SIZE(132, 240), 0, 3, 11, 3}, + {36, UPB_SIZE(136, 248), 0, 8, 11, 3}, + {37, UPB_SIZE(156, 272), UPB_SIZE(-161, -281), 5, 11, 1}, + {38, UPB_SIZE(144, 256), UPB_SIZE(-153, -265), 1, 11, 1}, }; const upb_msglayout envoy_api_v2_Cluster_msginit = { &envoy_api_v2_Cluster_submsgs[0], &envoy_api_v2_Cluster__fields[0], - UPB_SIZE(160, 288), 34, false, + UPB_SIZE(168, 288), 36, false, +}; + +static const upb_msglayout *const envoy_api_v2_Cluster_CustomClusterType_submsgs[1] = { + &google_protobuf_Any_msginit, +}; + +static const upb_msglayout_field envoy_api_v2_Cluster_CustomClusterType__fields[2] = { + {1, UPB_SIZE(0, 0), 0, 0, 9, 1}, + {2, UPB_SIZE(8, 16), 0, 0, 11, 1}, +}; + +const upb_msglayout envoy_api_v2_Cluster_CustomClusterType_msginit = { + &envoy_api_v2_Cluster_CustomClusterType_submsgs[0], + &envoy_api_v2_Cluster_CustomClusterType__fields[0], + UPB_SIZE(16, 32), 2, false, }; static const upb_msglayout *const envoy_api_v2_Cluster_EdsClusterConfig_submsgs[1] = { @@ -148,17 +167,19 @@ static const upb_msglayout *const envoy_api_v2_Cluster_LbSubsetConfig_submsgs[2] &google_protobuf_Struct_msginit, }; -static const upb_msglayout_field envoy_api_v2_Cluster_LbSubsetConfig__fields[4] = { +static const upb_msglayout_field envoy_api_v2_Cluster_LbSubsetConfig__fields[6] = { {1, UPB_SIZE(0, 0), 0, 0, 14, 1}, {2, UPB_SIZE(12, 16), 0, 1, 11, 1}, {3, UPB_SIZE(16, 24), 0, 0, 11, 3}, {4, UPB_SIZE(8, 8), 0, 0, 8, 1}, + {5, UPB_SIZE(9, 9), 0, 0, 8, 1}, + {6, UPB_SIZE(10, 10), 0, 0, 8, 1}, }; const upb_msglayout envoy_api_v2_Cluster_LbSubsetConfig_msginit = { &envoy_api_v2_Cluster_LbSubsetConfig_submsgs[0], &envoy_api_v2_Cluster_LbSubsetConfig__fields[0], - UPB_SIZE(24, 32), 4, false, + UPB_SIZE(24, 32), 6, false, }; static const upb_msglayout_field envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector__fields[1] = { @@ -171,34 +192,34 @@ const upb_msglayout envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_msginit UPB_SIZE(4, 8), 1, false, }; +static const upb_msglayout *const envoy_api_v2_Cluster_LeastRequestLbConfig_submsgs[1] = { + &google_protobuf_UInt32Value_msginit, +}; + +static const upb_msglayout_field envoy_api_v2_Cluster_LeastRequestLbConfig__fields[1] = { + {1, UPB_SIZE(0, 0), 0, 0, 11, 1}, +}; + +const upb_msglayout envoy_api_v2_Cluster_LeastRequestLbConfig_msginit = { + &envoy_api_v2_Cluster_LeastRequestLbConfig_submsgs[0], + &envoy_api_v2_Cluster_LeastRequestLbConfig__fields[0], + UPB_SIZE(4, 8), 1, false, +}; + static const upb_msglayout *const envoy_api_v2_Cluster_RingHashLbConfig_submsgs[2] = { - &envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1_msginit, &google_protobuf_UInt64Value_msginit, }; -static const upb_msglayout_field envoy_api_v2_Cluster_RingHashLbConfig__fields[2] = { - {1, UPB_SIZE(0, 0), 0, 1, 11, 1}, - {2, UPB_SIZE(4, 8), 0, 0, 11, 1}, +static const upb_msglayout_field envoy_api_v2_Cluster_RingHashLbConfig__fields[3] = { + {1, UPB_SIZE(8, 8), 0, 0, 11, 1}, + {3, UPB_SIZE(0, 0), 0, 0, 14, 1}, + {4, UPB_SIZE(12, 16), 0, 0, 11, 1}, }; const upb_msglayout envoy_api_v2_Cluster_RingHashLbConfig_msginit = { &envoy_api_v2_Cluster_RingHashLbConfig_submsgs[0], &envoy_api_v2_Cluster_RingHashLbConfig__fields[0], - UPB_SIZE(8, 16), 2, false, -}; - -static const upb_msglayout *const envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1_submsgs[1] = { - &google_protobuf_BoolValue_msginit, -}; - -static const upb_msglayout_field envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1__fields[1] = { - {1, UPB_SIZE(0, 0), 0, 0, 11, 1}, -}; - -const upb_msglayout envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1_msginit = { - &envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1_submsgs[0], - &envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1__fields[0], - UPB_SIZE(4, 8), 1, false, + UPB_SIZE(16, 24), 3, false, }; static const upb_msglayout_field envoy_api_v2_Cluster_OriginalDstLbConfig__fields[1] = { @@ -218,17 +239,18 @@ static const upb_msglayout *const envoy_api_v2_Cluster_CommonLbConfig_submsgs[4] &google_protobuf_Duration_msginit, }; -static const upb_msglayout_field envoy_api_v2_Cluster_CommonLbConfig__fields[4] = { - {1, UPB_SIZE(0, 0), 0, 2, 11, 1}, - {2, UPB_SIZE(8, 16), UPB_SIZE(-13, -25), 1, 11, 1}, - {3, UPB_SIZE(8, 16), UPB_SIZE(-13, -25), 0, 11, 1}, - {4, UPB_SIZE(4, 8), 0, 3, 11, 1}, +static const upb_msglayout_field envoy_api_v2_Cluster_CommonLbConfig__fields[5] = { + {1, UPB_SIZE(4, 8), 0, 2, 11, 1}, + {2, UPB_SIZE(12, 24), UPB_SIZE(-17, -33), 1, 11, 1}, + {3, UPB_SIZE(12, 24), UPB_SIZE(-17, -33), 0, 11, 1}, + {4, UPB_SIZE(8, 16), 0, 3, 11, 1}, + {5, UPB_SIZE(0, 0), 0, 0, 8, 1}, }; const upb_msglayout envoy_api_v2_Cluster_CommonLbConfig_msginit = { &envoy_api_v2_Cluster_CommonLbConfig_submsgs[0], &envoy_api_v2_Cluster_CommonLbConfig__fields[0], - UPB_SIZE(16, 32), 4, false, + UPB_SIZE(20, 40), 5, false, }; static const upb_msglayout *const envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig_submsgs[2] = { diff --git a/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h b/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h index e960b82506e..2fecf727bcb 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h @@ -10,24 +10,25 @@ #define ENVOY_API_V2_CDS_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif struct envoy_api_v2_Cluster; +struct envoy_api_v2_Cluster_CustomClusterType; struct envoy_api_v2_Cluster_EdsClusterConfig; struct envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry; struct envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry; struct envoy_api_v2_Cluster_LbSubsetConfig; struct envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector; +struct envoy_api_v2_Cluster_LeastRequestLbConfig; struct envoy_api_v2_Cluster_RingHashLbConfig; -struct envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1; struct envoy_api_v2_Cluster_OriginalDstLbConfig; struct envoy_api_v2_Cluster_CommonLbConfig; struct envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig; @@ -35,13 +36,14 @@ struct envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig; struct envoy_api_v2_UpstreamBindConfig; struct envoy_api_v2_UpstreamConnectionOptions; typedef struct envoy_api_v2_Cluster envoy_api_v2_Cluster; +typedef struct envoy_api_v2_Cluster_CustomClusterType envoy_api_v2_Cluster_CustomClusterType; typedef struct envoy_api_v2_Cluster_EdsClusterConfig envoy_api_v2_Cluster_EdsClusterConfig; typedef struct envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry; typedef struct envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry; typedef struct envoy_api_v2_Cluster_LbSubsetConfig envoy_api_v2_Cluster_LbSubsetConfig; typedef struct envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector; +typedef struct envoy_api_v2_Cluster_LeastRequestLbConfig envoy_api_v2_Cluster_LeastRequestLbConfig; typedef struct envoy_api_v2_Cluster_RingHashLbConfig envoy_api_v2_Cluster_RingHashLbConfig; -typedef struct envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1 envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1; typedef struct envoy_api_v2_Cluster_OriginalDstLbConfig envoy_api_v2_Cluster_OriginalDstLbConfig; typedef struct envoy_api_v2_Cluster_CommonLbConfig envoy_api_v2_Cluster_CommonLbConfig; typedef struct envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig; @@ -49,13 +51,14 @@ typedef struct envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig envo typedef struct envoy_api_v2_UpstreamBindConfig envoy_api_v2_UpstreamBindConfig; typedef struct envoy_api_v2_UpstreamConnectionOptions envoy_api_v2_UpstreamConnectionOptions; extern const upb_msglayout envoy_api_v2_Cluster_msginit; +extern const upb_msglayout envoy_api_v2_Cluster_CustomClusterType_msginit; extern const upb_msglayout envoy_api_v2_Cluster_EdsClusterConfig_msginit; extern const upb_msglayout envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry_msginit; extern const upb_msglayout envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry_msginit; extern const upb_msglayout envoy_api_v2_Cluster_LbSubsetConfig_msginit; extern const upb_msglayout envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_msginit; +extern const upb_msglayout envoy_api_v2_Cluster_LeastRequestLbConfig_msginit; extern const upb_msglayout envoy_api_v2_Cluster_RingHashLbConfig_msginit; -extern const upb_msglayout envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1_msginit; extern const upb_msglayout envoy_api_v2_Cluster_OriginalDstLbConfig_msginit; extern const upb_msglayout envoy_api_v2_Cluster_CommonLbConfig_msginit; extern const upb_msglayout envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig_msginit; @@ -78,7 +81,6 @@ struct envoy_api_v2_core_TcpKeepalive; struct envoy_api_v2_core_TransportSocket; struct envoy_type_Percent; struct google_protobuf_Any; -struct google_protobuf_BoolValue; struct google_protobuf_Duration; struct google_protobuf_Struct; struct google_protobuf_UInt32Value; @@ -99,14 +101,11 @@ extern const upb_msglayout envoy_api_v2_core_TcpKeepalive_msginit; extern const upb_msglayout envoy_api_v2_core_TransportSocket_msginit; extern const upb_msglayout envoy_type_Percent_msginit; extern const upb_msglayout google_protobuf_Any_msginit; -extern const upb_msglayout google_protobuf_BoolValue_msginit; extern const upb_msglayout google_protobuf_Duration_msginit; extern const upb_msglayout google_protobuf_Struct_msginit; extern const upb_msglayout google_protobuf_UInt32Value_msginit; extern const upb_msglayout google_protobuf_UInt64Value_msginit; -/* Enums */ - typedef enum { envoy_api_v2_Cluster_USE_CONFIGURED_PROTOCOL = 0, envoy_api_v2_Cluster_USE_DOWNSTREAM_PROTOCOL = 1 @@ -132,7 +131,8 @@ typedef enum { envoy_api_v2_Cluster_RING_HASH = 2, envoy_api_v2_Cluster_RANDOM = 3, envoy_api_v2_Cluster_ORIGINAL_DST_LB = 4, - envoy_api_v2_Cluster_MAGLEV = 5 + envoy_api_v2_Cluster_MAGLEV = 5, + envoy_api_v2_Cluster_CLUSTER_PROVIDED = 6 } envoy_api_v2_Cluster_LbPolicy; typedef enum { @@ -141,72 +141,91 @@ typedef enum { envoy_api_v2_Cluster_LbSubsetConfig_DEFAULT_SUBSET = 2 } envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetFallbackPolicy; +typedef enum { + envoy_api_v2_Cluster_RingHashLbConfig_XX_HASH = 0, + envoy_api_v2_Cluster_RingHashLbConfig_MURMUR_HASH_2 = 1 +} envoy_api_v2_Cluster_RingHashLbConfig_HashFunction; + /* envoy.api.v2.Cluster */ UPB_INLINE envoy_api_v2_Cluster *envoy_api_v2_Cluster_new(upb_arena *arena) { return (envoy_api_v2_Cluster *)upb_msg_new(&envoy_api_v2_Cluster_msginit, arena); } -UPB_INLINE envoy_api_v2_Cluster *envoy_api_v2_Cluster_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_Cluster *envoy_api_v2_Cluster_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_Cluster *ret = envoy_api_v2_Cluster_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_Cluster_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_Cluster_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_Cluster_serialize(const envoy_api_v2_Cluster *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_Cluster_msginit, arena, len); } +typedef enum { + envoy_api_v2_Cluster_cluster_discovery_type_type = 2, + envoy_api_v2_Cluster_cluster_discovery_type_cluster_type = 38, + envoy_api_v2_Cluster_cluster_discovery_type_NOT_SET = 0 +} envoy_api_v2_Cluster_cluster_discovery_type_oneofcases; +UPB_INLINE envoy_api_v2_Cluster_cluster_discovery_type_oneofcases envoy_api_v2_Cluster_cluster_discovery_type_case(const envoy_api_v2_Cluster* msg) { return (envoy_api_v2_Cluster_cluster_discovery_type_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(152, 264)); } + typedef enum { envoy_api_v2_Cluster_lb_config_ring_hash_lb_config = 23, envoy_api_v2_Cluster_lb_config_original_dst_lb_config = 34, - envoy_api_v2_Cluster_lb_config_NOT_SET = 0, + envoy_api_v2_Cluster_lb_config_least_request_lb_config = 37, + envoy_api_v2_Cluster_lb_config_NOT_SET = 0 } envoy_api_v2_Cluster_lb_config_oneofcases; -UPB_INLINE envoy_api_v2_Cluster_lb_config_oneofcases envoy_api_v2_Cluster_lb_config_case(const envoy_api_v2_Cluster* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(152, 272)); } +UPB_INLINE envoy_api_v2_Cluster_lb_config_oneofcases envoy_api_v2_Cluster_lb_config_case(const envoy_api_v2_Cluster* msg) { return (envoy_api_v2_Cluster_lb_config_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(160, 280)); } -UPB_INLINE upb_strview envoy_api_v2_Cluster_name(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(36, 40)); } -UPB_INLINE int32_t envoy_api_v2_Cluster_type(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)); } -UPB_INLINE const envoy_api_v2_Cluster_EdsClusterConfig* envoy_api_v2_Cluster_eds_cluster_config(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const envoy_api_v2_Cluster_EdsClusterConfig*, UPB_SIZE(52, 72)); } -UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_Cluster_connect_timeout(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(56, 80)); } -UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_Cluster_per_connection_buffer_limit_bytes(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(60, 88)); } -UPB_INLINE int32_t envoy_api_v2_Cluster_lb_policy(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); } -UPB_INLINE const struct envoy_api_v2_core_Address* const* envoy_api_v2_Cluster_hosts(const envoy_api_v2_Cluster *msg, size_t *len) { return (const struct envoy_api_v2_core_Address* const*)_upb_array_accessor(msg, UPB_SIZE(128, 224), len); } -UPB_INLINE const struct envoy_api_v2_core_HealthCheck* const* envoy_api_v2_Cluster_health_checks(const envoy_api_v2_Cluster *msg, size_t *len) { return (const struct envoy_api_v2_core_HealthCheck* const*)_upb_array_accessor(msg, UPB_SIZE(132, 232), len); } -UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_Cluster_max_requests_per_connection(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(64, 96)); } -UPB_INLINE const struct envoy_api_v2_cluster_CircuitBreakers* envoy_api_v2_Cluster_circuit_breakers(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_cluster_CircuitBreakers*, UPB_SIZE(68, 104)); } -UPB_INLINE const struct envoy_api_v2_auth_UpstreamTlsContext* envoy_api_v2_Cluster_tls_context(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_auth_UpstreamTlsContext*, UPB_SIZE(72, 112)); } -UPB_INLINE const struct envoy_api_v2_core_Http1ProtocolOptions* envoy_api_v2_Cluster_http_protocol_options(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Http1ProtocolOptions*, UPB_SIZE(76, 120)); } -UPB_INLINE const struct envoy_api_v2_core_Http2ProtocolOptions* envoy_api_v2_Cluster_http2_protocol_options(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Http2ProtocolOptions*, UPB_SIZE(80, 128)); } -UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_Cluster_dns_refresh_rate(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(84, 136)); } -UPB_INLINE int32_t envoy_api_v2_Cluster_dns_lookup_family(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 16)); } -UPB_INLINE const struct envoy_api_v2_core_Address* const* envoy_api_v2_Cluster_dns_resolvers(const envoy_api_v2_Cluster *msg, size_t *len) { return (const struct envoy_api_v2_core_Address* const*)_upb_array_accessor(msg, UPB_SIZE(136, 240), len); } -UPB_INLINE const struct envoy_api_v2_cluster_OutlierDetection* envoy_api_v2_Cluster_outlier_detection(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_cluster_OutlierDetection*, UPB_SIZE(88, 144)); } -UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_Cluster_cleanup_interval(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(92, 152)); } -UPB_INLINE const struct envoy_api_v2_core_BindConfig* envoy_api_v2_Cluster_upstream_bind_config(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_BindConfig*, UPB_SIZE(96, 160)); } -UPB_INLINE const envoy_api_v2_Cluster_LbSubsetConfig* envoy_api_v2_Cluster_lb_subset_config(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const envoy_api_v2_Cluster_LbSubsetConfig*, UPB_SIZE(100, 168)); } -UPB_INLINE bool envoy_api_v2_Cluster_has_ring_hash_lb_config(const envoy_api_v2_Cluster *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(152, 272), 23); } -UPB_INLINE const envoy_api_v2_Cluster_RingHashLbConfig* envoy_api_v2_Cluster_ring_hash_lb_config(const envoy_api_v2_Cluster *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_Cluster_RingHashLbConfig*, UPB_SIZE(148, 264), UPB_SIZE(152, 272), 23, NULL); } -UPB_INLINE const struct envoy_api_v2_core_TransportSocket* envoy_api_v2_Cluster_transport_socket(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_TransportSocket*, UPB_SIZE(104, 176)); } -UPB_INLINE const struct envoy_api_v2_core_Metadata* envoy_api_v2_Cluster_metadata(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Metadata*, UPB_SIZE(108, 184)); } -UPB_INLINE int32_t envoy_api_v2_Cluster_protocol_selection(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(24, 24)); } -UPB_INLINE const envoy_api_v2_Cluster_CommonLbConfig* envoy_api_v2_Cluster_common_lb_config(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const envoy_api_v2_Cluster_CommonLbConfig*, UPB_SIZE(112, 192)); } -UPB_INLINE upb_strview envoy_api_v2_Cluster_alt_stat_name(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(44, 56)); } -UPB_INLINE const struct envoy_api_v2_core_HttpProtocolOptions* envoy_api_v2_Cluster_common_http_protocol_options(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_HttpProtocolOptions*, UPB_SIZE(116, 200)); } -UPB_INLINE const envoy_api_v2_UpstreamConnectionOptions* envoy_api_v2_Cluster_upstream_connection_options(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const envoy_api_v2_UpstreamConnectionOptions*, UPB_SIZE(120, 208)); } -UPB_INLINE bool envoy_api_v2_Cluster_close_connections_on_host_health_failure(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(32, 32)); } -UPB_INLINE bool envoy_api_v2_Cluster_drain_connections_on_host_removal(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(33, 33)); } -UPB_INLINE const struct envoy_api_v2_ClusterLoadAssignment* envoy_api_v2_Cluster_load_assignment(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_ClusterLoadAssignment*, UPB_SIZE(124, 216)); } -UPB_INLINE bool envoy_api_v2_Cluster_has_original_dst_lb_config(const envoy_api_v2_Cluster *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(152, 272), 34); } -UPB_INLINE const envoy_api_v2_Cluster_OriginalDstLbConfig* envoy_api_v2_Cluster_original_dst_lb_config(const envoy_api_v2_Cluster *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_Cluster_OriginalDstLbConfig*, UPB_SIZE(148, 264), UPB_SIZE(152, 272), 34, NULL); } -UPB_INLINE const envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry* const* envoy_api_v2_Cluster_extension_protocol_options(const envoy_api_v2_Cluster *msg, size_t *len) { return (const envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry* const*)_upb_array_accessor(msg, UPB_SIZE(140, 248), len); } -UPB_INLINE const envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry* const* envoy_api_v2_Cluster_typed_extension_protocol_options(const envoy_api_v2_Cluster *msg, size_t *len) { return (const envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry* const*)_upb_array_accessor(msg, UPB_SIZE(144, 256), len); } +UPB_INLINE upb_strview envoy_api_v2_Cluster_name(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(28, 32)); } +UPB_INLINE bool envoy_api_v2_Cluster_has_type(const envoy_api_v2_Cluster *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(152, 264), 2); } +UPB_INLINE int32_t envoy_api_v2_Cluster_type(const envoy_api_v2_Cluster *msg) { return UPB_READ_ONEOF(msg, int32_t, UPB_SIZE(144, 256), UPB_SIZE(152, 264), 2, envoy_api_v2_Cluster_STATIC); } +UPB_INLINE const envoy_api_v2_Cluster_EdsClusterConfig* envoy_api_v2_Cluster_eds_cluster_config(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const envoy_api_v2_Cluster_EdsClusterConfig*, UPB_SIZE(44, 64)); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_Cluster_connect_timeout(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(48, 72)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_Cluster_per_connection_buffer_limit_bytes(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(52, 80)); } +UPB_INLINE int32_t envoy_api_v2_Cluster_lb_policy(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)); } +UPB_INLINE const struct envoy_api_v2_core_Address* const* envoy_api_v2_Cluster_hosts(const envoy_api_v2_Cluster *msg, size_t *len) { return (const struct envoy_api_v2_core_Address* const*)_upb_array_accessor(msg, UPB_SIZE(120, 216), len); } +UPB_INLINE const struct envoy_api_v2_core_HealthCheck* const* envoy_api_v2_Cluster_health_checks(const envoy_api_v2_Cluster *msg, size_t *len) { return (const struct envoy_api_v2_core_HealthCheck* const*)_upb_array_accessor(msg, UPB_SIZE(124, 224), len); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_Cluster_max_requests_per_connection(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(56, 88)); } +UPB_INLINE const struct envoy_api_v2_cluster_CircuitBreakers* envoy_api_v2_Cluster_circuit_breakers(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_cluster_CircuitBreakers*, UPB_SIZE(60, 96)); } +UPB_INLINE const struct envoy_api_v2_auth_UpstreamTlsContext* envoy_api_v2_Cluster_tls_context(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_auth_UpstreamTlsContext*, UPB_SIZE(64, 104)); } +UPB_INLINE const struct envoy_api_v2_core_Http1ProtocolOptions* envoy_api_v2_Cluster_http_protocol_options(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Http1ProtocolOptions*, UPB_SIZE(68, 112)); } +UPB_INLINE const struct envoy_api_v2_core_Http2ProtocolOptions* envoy_api_v2_Cluster_http2_protocol_options(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Http2ProtocolOptions*, UPB_SIZE(72, 120)); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_Cluster_dns_refresh_rate(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(76, 128)); } +UPB_INLINE int32_t envoy_api_v2_Cluster_dns_lookup_family(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); } +UPB_INLINE const struct envoy_api_v2_core_Address* const* envoy_api_v2_Cluster_dns_resolvers(const envoy_api_v2_Cluster *msg, size_t *len) { return (const struct envoy_api_v2_core_Address* const*)_upb_array_accessor(msg, UPB_SIZE(128, 232), len); } +UPB_INLINE const struct envoy_api_v2_cluster_OutlierDetection* envoy_api_v2_Cluster_outlier_detection(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_cluster_OutlierDetection*, UPB_SIZE(80, 136)); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_Cluster_cleanup_interval(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(84, 144)); } +UPB_INLINE const struct envoy_api_v2_core_BindConfig* envoy_api_v2_Cluster_upstream_bind_config(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_BindConfig*, UPB_SIZE(88, 152)); } +UPB_INLINE const envoy_api_v2_Cluster_LbSubsetConfig* envoy_api_v2_Cluster_lb_subset_config(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const envoy_api_v2_Cluster_LbSubsetConfig*, UPB_SIZE(92, 160)); } +UPB_INLINE bool envoy_api_v2_Cluster_has_ring_hash_lb_config(const envoy_api_v2_Cluster *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(160, 280), 23); } +UPB_INLINE const envoy_api_v2_Cluster_RingHashLbConfig* envoy_api_v2_Cluster_ring_hash_lb_config(const envoy_api_v2_Cluster *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_Cluster_RingHashLbConfig*, UPB_SIZE(156, 272), UPB_SIZE(160, 280), 23, NULL); } +UPB_INLINE const struct envoy_api_v2_core_TransportSocket* envoy_api_v2_Cluster_transport_socket(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_TransportSocket*, UPB_SIZE(96, 168)); } +UPB_INLINE const struct envoy_api_v2_core_Metadata* envoy_api_v2_Cluster_metadata(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Metadata*, UPB_SIZE(100, 176)); } +UPB_INLINE int32_t envoy_api_v2_Cluster_protocol_selection(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 16)); } +UPB_INLINE const envoy_api_v2_Cluster_CommonLbConfig* envoy_api_v2_Cluster_common_lb_config(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const envoy_api_v2_Cluster_CommonLbConfig*, UPB_SIZE(104, 184)); } +UPB_INLINE upb_strview envoy_api_v2_Cluster_alt_stat_name(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(36, 48)); } +UPB_INLINE const struct envoy_api_v2_core_HttpProtocolOptions* envoy_api_v2_Cluster_common_http_protocol_options(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_HttpProtocolOptions*, UPB_SIZE(108, 192)); } +UPB_INLINE const envoy_api_v2_UpstreamConnectionOptions* envoy_api_v2_Cluster_upstream_connection_options(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const envoy_api_v2_UpstreamConnectionOptions*, UPB_SIZE(112, 200)); } +UPB_INLINE bool envoy_api_v2_Cluster_close_connections_on_host_health_failure(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(24, 24)); } +UPB_INLINE bool envoy_api_v2_Cluster_drain_connections_on_host_removal(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(25, 25)); } +UPB_INLINE const struct envoy_api_v2_ClusterLoadAssignment* envoy_api_v2_Cluster_load_assignment(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_ClusterLoadAssignment*, UPB_SIZE(116, 208)); } +UPB_INLINE bool envoy_api_v2_Cluster_has_original_dst_lb_config(const envoy_api_v2_Cluster *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(160, 280), 34); } +UPB_INLINE const envoy_api_v2_Cluster_OriginalDstLbConfig* envoy_api_v2_Cluster_original_dst_lb_config(const envoy_api_v2_Cluster *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_Cluster_OriginalDstLbConfig*, UPB_SIZE(156, 272), UPB_SIZE(160, 280), 34, NULL); } +UPB_INLINE const envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry* const* envoy_api_v2_Cluster_extension_protocol_options(const envoy_api_v2_Cluster *msg, size_t *len) { return (const envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry* const*)_upb_array_accessor(msg, UPB_SIZE(132, 240), len); } +UPB_INLINE const envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry* const* envoy_api_v2_Cluster_typed_extension_protocol_options(const envoy_api_v2_Cluster *msg, size_t *len) { return (const envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry* const*)_upb_array_accessor(msg, UPB_SIZE(136, 248), len); } +UPB_INLINE bool envoy_api_v2_Cluster_has_least_request_lb_config(const envoy_api_v2_Cluster *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(160, 280), 37); } +UPB_INLINE const envoy_api_v2_Cluster_LeastRequestLbConfig* envoy_api_v2_Cluster_least_request_lb_config(const envoy_api_v2_Cluster *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_Cluster_LeastRequestLbConfig*, UPB_SIZE(156, 272), UPB_SIZE(160, 280), 37, NULL); } +UPB_INLINE bool envoy_api_v2_Cluster_has_cluster_type(const envoy_api_v2_Cluster *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(152, 264), 38); } +UPB_INLINE const envoy_api_v2_Cluster_CustomClusterType* envoy_api_v2_Cluster_cluster_type(const envoy_api_v2_Cluster *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_Cluster_CustomClusterType*, UPB_SIZE(144, 256), UPB_SIZE(152, 264), 38, NULL); } UPB_INLINE void envoy_api_v2_Cluster_set_name(envoy_api_v2_Cluster *msg, upb_strview value) { - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(36, 40)) = value; + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(28, 32)) = value; } UPB_INLINE void envoy_api_v2_Cluster_set_type(envoy_api_v2_Cluster *msg, int32_t value) { - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)) = value; + UPB_WRITE_ONEOF(msg, int32_t, UPB_SIZE(144, 256), value, UPB_SIZE(152, 264), 2); } UPB_INLINE void envoy_api_v2_Cluster_set_eds_cluster_config(envoy_api_v2_Cluster *msg, envoy_api_v2_Cluster_EdsClusterConfig* value) { - UPB_FIELD_AT(msg, envoy_api_v2_Cluster_EdsClusterConfig*, UPB_SIZE(52, 72)) = value; + UPB_FIELD_AT(msg, envoy_api_v2_Cluster_EdsClusterConfig*, UPB_SIZE(44, 64)) = value; } UPB_INLINE struct envoy_api_v2_Cluster_EdsClusterConfig* envoy_api_v2_Cluster_mutable_eds_cluster_config(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_Cluster_EdsClusterConfig* sub = (struct envoy_api_v2_Cluster_EdsClusterConfig*)envoy_api_v2_Cluster_eds_cluster_config(msg); @@ -218,7 +237,7 @@ UPB_INLINE struct envoy_api_v2_Cluster_EdsClusterConfig* envoy_api_v2_Cluster_mu return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_connect_timeout(envoy_api_v2_Cluster *msg, struct google_protobuf_Duration* value) { - UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(56, 80)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(48, 72)) = value; } UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_Cluster_mutable_connect_timeout(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_Cluster_connect_timeout(msg); @@ -230,7 +249,7 @@ UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_Cluster_mutable_connect return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_per_connection_buffer_limit_bytes(envoy_api_v2_Cluster *msg, struct google_protobuf_UInt32Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(60, 88)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(52, 80)) = value; } UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_Cluster_mutable_per_connection_buffer_limit_bytes(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_Cluster_per_connection_buffer_limit_bytes(msg); @@ -242,36 +261,36 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_Cluster_mutable_per_ return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_lb_policy(envoy_api_v2_Cluster *msg, int32_t value) { - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)) = value; } UPB_INLINE struct envoy_api_v2_core_Address** envoy_api_v2_Cluster_mutable_hosts(envoy_api_v2_Cluster *msg, size_t *len) { - return (struct envoy_api_v2_core_Address**)_upb_array_mutable_accessor(msg, UPB_SIZE(128, 224), len); + return (struct envoy_api_v2_core_Address**)_upb_array_mutable_accessor(msg, UPB_SIZE(120, 216), len); } UPB_INLINE struct envoy_api_v2_core_Address** envoy_api_v2_Cluster_resize_hosts(envoy_api_v2_Cluster *msg, size_t len, upb_arena *arena) { - return (struct envoy_api_v2_core_Address**)_upb_array_resize_accessor(msg, UPB_SIZE(128, 224), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); + return (struct envoy_api_v2_core_Address**)_upb_array_resize_accessor(msg, UPB_SIZE(120, 216), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); } UPB_INLINE struct envoy_api_v2_core_Address* envoy_api_v2_Cluster_add_hosts(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_core_Address* sub = (struct envoy_api_v2_core_Address*)upb_msg_new(&envoy_api_v2_core_Address_msginit, arena); bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(128, 224), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + msg, UPB_SIZE(120, 216), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); if (!ok) return NULL; return sub; } UPB_INLINE struct envoy_api_v2_core_HealthCheck** envoy_api_v2_Cluster_mutable_health_checks(envoy_api_v2_Cluster *msg, size_t *len) { - return (struct envoy_api_v2_core_HealthCheck**)_upb_array_mutable_accessor(msg, UPB_SIZE(132, 232), len); + return (struct envoy_api_v2_core_HealthCheck**)_upb_array_mutable_accessor(msg, UPB_SIZE(124, 224), len); } UPB_INLINE struct envoy_api_v2_core_HealthCheck** envoy_api_v2_Cluster_resize_health_checks(envoy_api_v2_Cluster *msg, size_t len, upb_arena *arena) { - return (struct envoy_api_v2_core_HealthCheck**)_upb_array_resize_accessor(msg, UPB_SIZE(132, 232), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); + return (struct envoy_api_v2_core_HealthCheck**)_upb_array_resize_accessor(msg, UPB_SIZE(124, 224), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); } UPB_INLINE struct envoy_api_v2_core_HealthCheck* envoy_api_v2_Cluster_add_health_checks(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_core_HealthCheck* sub = (struct envoy_api_v2_core_HealthCheck*)upb_msg_new(&envoy_api_v2_core_HealthCheck_msginit, arena); bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(132, 232), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + msg, UPB_SIZE(124, 224), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); if (!ok) return NULL; return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_max_requests_per_connection(envoy_api_v2_Cluster *msg, struct google_protobuf_UInt32Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(64, 96)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(56, 88)) = value; } UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_Cluster_mutable_max_requests_per_connection(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_Cluster_max_requests_per_connection(msg); @@ -283,7 +302,7 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_Cluster_mutable_max_ return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_circuit_breakers(envoy_api_v2_Cluster *msg, struct envoy_api_v2_cluster_CircuitBreakers* value) { - UPB_FIELD_AT(msg, struct envoy_api_v2_cluster_CircuitBreakers*, UPB_SIZE(68, 104)) = value; + UPB_FIELD_AT(msg, struct envoy_api_v2_cluster_CircuitBreakers*, UPB_SIZE(60, 96)) = value; } UPB_INLINE struct envoy_api_v2_cluster_CircuitBreakers* envoy_api_v2_Cluster_mutable_circuit_breakers(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_cluster_CircuitBreakers* sub = (struct envoy_api_v2_cluster_CircuitBreakers*)envoy_api_v2_Cluster_circuit_breakers(msg); @@ -295,7 +314,7 @@ UPB_INLINE struct envoy_api_v2_cluster_CircuitBreakers* envoy_api_v2_Cluster_mut return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_tls_context(envoy_api_v2_Cluster *msg, struct envoy_api_v2_auth_UpstreamTlsContext* value) { - UPB_FIELD_AT(msg, struct envoy_api_v2_auth_UpstreamTlsContext*, UPB_SIZE(72, 112)) = value; + UPB_FIELD_AT(msg, struct envoy_api_v2_auth_UpstreamTlsContext*, UPB_SIZE(64, 104)) = value; } UPB_INLINE struct envoy_api_v2_auth_UpstreamTlsContext* envoy_api_v2_Cluster_mutable_tls_context(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_auth_UpstreamTlsContext* sub = (struct envoy_api_v2_auth_UpstreamTlsContext*)envoy_api_v2_Cluster_tls_context(msg); @@ -307,7 +326,7 @@ UPB_INLINE struct envoy_api_v2_auth_UpstreamTlsContext* envoy_api_v2_Cluster_mut return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_http_protocol_options(envoy_api_v2_Cluster *msg, struct envoy_api_v2_core_Http1ProtocolOptions* value) { - UPB_FIELD_AT(msg, struct envoy_api_v2_core_Http1ProtocolOptions*, UPB_SIZE(76, 120)) = value; + UPB_FIELD_AT(msg, struct envoy_api_v2_core_Http1ProtocolOptions*, UPB_SIZE(68, 112)) = value; } UPB_INLINE struct envoy_api_v2_core_Http1ProtocolOptions* envoy_api_v2_Cluster_mutable_http_protocol_options(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_core_Http1ProtocolOptions* sub = (struct envoy_api_v2_core_Http1ProtocolOptions*)envoy_api_v2_Cluster_http_protocol_options(msg); @@ -319,7 +338,7 @@ UPB_INLINE struct envoy_api_v2_core_Http1ProtocolOptions* envoy_api_v2_Cluster_m return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_http2_protocol_options(envoy_api_v2_Cluster *msg, struct envoy_api_v2_core_Http2ProtocolOptions* value) { - UPB_FIELD_AT(msg, struct envoy_api_v2_core_Http2ProtocolOptions*, UPB_SIZE(80, 128)) = value; + UPB_FIELD_AT(msg, struct envoy_api_v2_core_Http2ProtocolOptions*, UPB_SIZE(72, 120)) = value; } UPB_INLINE struct envoy_api_v2_core_Http2ProtocolOptions* envoy_api_v2_Cluster_mutable_http2_protocol_options(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_core_Http2ProtocolOptions* sub = (struct envoy_api_v2_core_Http2ProtocolOptions*)envoy_api_v2_Cluster_http2_protocol_options(msg); @@ -331,7 +350,7 @@ UPB_INLINE struct envoy_api_v2_core_Http2ProtocolOptions* envoy_api_v2_Cluster_m return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_dns_refresh_rate(envoy_api_v2_Cluster *msg, struct google_protobuf_Duration* value) { - UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(84, 136)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(76, 128)) = value; } UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_Cluster_mutable_dns_refresh_rate(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_Cluster_dns_refresh_rate(msg); @@ -343,23 +362,23 @@ UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_Cluster_mutable_dns_ref return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_dns_lookup_family(envoy_api_v2_Cluster *msg, int32_t value) { - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 16)) = value; + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; } UPB_INLINE struct envoy_api_v2_core_Address** envoy_api_v2_Cluster_mutable_dns_resolvers(envoy_api_v2_Cluster *msg, size_t *len) { - return (struct envoy_api_v2_core_Address**)_upb_array_mutable_accessor(msg, UPB_SIZE(136, 240), len); + return (struct envoy_api_v2_core_Address**)_upb_array_mutable_accessor(msg, UPB_SIZE(128, 232), len); } UPB_INLINE struct envoy_api_v2_core_Address** envoy_api_v2_Cluster_resize_dns_resolvers(envoy_api_v2_Cluster *msg, size_t len, upb_arena *arena) { - return (struct envoy_api_v2_core_Address**)_upb_array_resize_accessor(msg, UPB_SIZE(136, 240), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); + return (struct envoy_api_v2_core_Address**)_upb_array_resize_accessor(msg, UPB_SIZE(128, 232), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); } UPB_INLINE struct envoy_api_v2_core_Address* envoy_api_v2_Cluster_add_dns_resolvers(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_core_Address* sub = (struct envoy_api_v2_core_Address*)upb_msg_new(&envoy_api_v2_core_Address_msginit, arena); bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(136, 240), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + msg, UPB_SIZE(128, 232), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); if (!ok) return NULL; return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_outlier_detection(envoy_api_v2_Cluster *msg, struct envoy_api_v2_cluster_OutlierDetection* value) { - UPB_FIELD_AT(msg, struct envoy_api_v2_cluster_OutlierDetection*, UPB_SIZE(88, 144)) = value; + UPB_FIELD_AT(msg, struct envoy_api_v2_cluster_OutlierDetection*, UPB_SIZE(80, 136)) = value; } UPB_INLINE struct envoy_api_v2_cluster_OutlierDetection* envoy_api_v2_Cluster_mutable_outlier_detection(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_cluster_OutlierDetection* sub = (struct envoy_api_v2_cluster_OutlierDetection*)envoy_api_v2_Cluster_outlier_detection(msg); @@ -371,7 +390,7 @@ UPB_INLINE struct envoy_api_v2_cluster_OutlierDetection* envoy_api_v2_Cluster_mu return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_cleanup_interval(envoy_api_v2_Cluster *msg, struct google_protobuf_Duration* value) { - UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(92, 152)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(84, 144)) = value; } UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_Cluster_mutable_cleanup_interval(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_Cluster_cleanup_interval(msg); @@ -383,7 +402,7 @@ UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_Cluster_mutable_cleanup return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_upstream_bind_config(envoy_api_v2_Cluster *msg, struct envoy_api_v2_core_BindConfig* value) { - UPB_FIELD_AT(msg, struct envoy_api_v2_core_BindConfig*, UPB_SIZE(96, 160)) = value; + UPB_FIELD_AT(msg, struct envoy_api_v2_core_BindConfig*, UPB_SIZE(88, 152)) = value; } UPB_INLINE struct envoy_api_v2_core_BindConfig* envoy_api_v2_Cluster_mutable_upstream_bind_config(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_core_BindConfig* sub = (struct envoy_api_v2_core_BindConfig*)envoy_api_v2_Cluster_upstream_bind_config(msg); @@ -395,7 +414,7 @@ UPB_INLINE struct envoy_api_v2_core_BindConfig* envoy_api_v2_Cluster_mutable_ups return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_lb_subset_config(envoy_api_v2_Cluster *msg, envoy_api_v2_Cluster_LbSubsetConfig* value) { - UPB_FIELD_AT(msg, envoy_api_v2_Cluster_LbSubsetConfig*, UPB_SIZE(100, 168)) = value; + UPB_FIELD_AT(msg, envoy_api_v2_Cluster_LbSubsetConfig*, UPB_SIZE(92, 160)) = value; } UPB_INLINE struct envoy_api_v2_Cluster_LbSubsetConfig* envoy_api_v2_Cluster_mutable_lb_subset_config(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_Cluster_LbSubsetConfig* sub = (struct envoy_api_v2_Cluster_LbSubsetConfig*)envoy_api_v2_Cluster_lb_subset_config(msg); @@ -407,7 +426,7 @@ UPB_INLINE struct envoy_api_v2_Cluster_LbSubsetConfig* envoy_api_v2_Cluster_muta return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_ring_hash_lb_config(envoy_api_v2_Cluster *msg, envoy_api_v2_Cluster_RingHashLbConfig* value) { - UPB_WRITE_ONEOF(msg, envoy_api_v2_Cluster_RingHashLbConfig*, UPB_SIZE(148, 264), value, UPB_SIZE(152, 272), 23); + UPB_WRITE_ONEOF(msg, envoy_api_v2_Cluster_RingHashLbConfig*, UPB_SIZE(156, 272), value, UPB_SIZE(160, 280), 23); } UPB_INLINE struct envoy_api_v2_Cluster_RingHashLbConfig* envoy_api_v2_Cluster_mutable_ring_hash_lb_config(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_Cluster_RingHashLbConfig* sub = (struct envoy_api_v2_Cluster_RingHashLbConfig*)envoy_api_v2_Cluster_ring_hash_lb_config(msg); @@ -419,7 +438,7 @@ UPB_INLINE struct envoy_api_v2_Cluster_RingHashLbConfig* envoy_api_v2_Cluster_mu return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_transport_socket(envoy_api_v2_Cluster *msg, struct envoy_api_v2_core_TransportSocket* value) { - UPB_FIELD_AT(msg, struct envoy_api_v2_core_TransportSocket*, UPB_SIZE(104, 176)) = value; + UPB_FIELD_AT(msg, struct envoy_api_v2_core_TransportSocket*, UPB_SIZE(96, 168)) = value; } UPB_INLINE struct envoy_api_v2_core_TransportSocket* envoy_api_v2_Cluster_mutable_transport_socket(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_core_TransportSocket* sub = (struct envoy_api_v2_core_TransportSocket*)envoy_api_v2_Cluster_transport_socket(msg); @@ -431,7 +450,7 @@ UPB_INLINE struct envoy_api_v2_core_TransportSocket* envoy_api_v2_Cluster_mutabl return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_metadata(envoy_api_v2_Cluster *msg, struct envoy_api_v2_core_Metadata* value) { - UPB_FIELD_AT(msg, struct envoy_api_v2_core_Metadata*, UPB_SIZE(108, 184)) = value; + UPB_FIELD_AT(msg, struct envoy_api_v2_core_Metadata*, UPB_SIZE(100, 176)) = value; } UPB_INLINE struct envoy_api_v2_core_Metadata* envoy_api_v2_Cluster_mutable_metadata(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_core_Metadata* sub = (struct envoy_api_v2_core_Metadata*)envoy_api_v2_Cluster_metadata(msg); @@ -443,10 +462,10 @@ UPB_INLINE struct envoy_api_v2_core_Metadata* envoy_api_v2_Cluster_mutable_metad return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_protocol_selection(envoy_api_v2_Cluster *msg, int32_t value) { - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(24, 24)) = value; + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 16)) = value; } UPB_INLINE void envoy_api_v2_Cluster_set_common_lb_config(envoy_api_v2_Cluster *msg, envoy_api_v2_Cluster_CommonLbConfig* value) { - UPB_FIELD_AT(msg, envoy_api_v2_Cluster_CommonLbConfig*, UPB_SIZE(112, 192)) = value; + UPB_FIELD_AT(msg, envoy_api_v2_Cluster_CommonLbConfig*, UPB_SIZE(104, 184)) = value; } UPB_INLINE struct envoy_api_v2_Cluster_CommonLbConfig* envoy_api_v2_Cluster_mutable_common_lb_config(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_Cluster_CommonLbConfig* sub = (struct envoy_api_v2_Cluster_CommonLbConfig*)envoy_api_v2_Cluster_common_lb_config(msg); @@ -458,10 +477,10 @@ UPB_INLINE struct envoy_api_v2_Cluster_CommonLbConfig* envoy_api_v2_Cluster_muta return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_alt_stat_name(envoy_api_v2_Cluster *msg, upb_strview value) { - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(44, 56)) = value; + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(36, 48)) = value; } UPB_INLINE void envoy_api_v2_Cluster_set_common_http_protocol_options(envoy_api_v2_Cluster *msg, struct envoy_api_v2_core_HttpProtocolOptions* value) { - UPB_FIELD_AT(msg, struct envoy_api_v2_core_HttpProtocolOptions*, UPB_SIZE(116, 200)) = value; + UPB_FIELD_AT(msg, struct envoy_api_v2_core_HttpProtocolOptions*, UPB_SIZE(108, 192)) = value; } UPB_INLINE struct envoy_api_v2_core_HttpProtocolOptions* envoy_api_v2_Cluster_mutable_common_http_protocol_options(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_core_HttpProtocolOptions* sub = (struct envoy_api_v2_core_HttpProtocolOptions*)envoy_api_v2_Cluster_common_http_protocol_options(msg); @@ -473,7 +492,7 @@ UPB_INLINE struct envoy_api_v2_core_HttpProtocolOptions* envoy_api_v2_Cluster_mu return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_upstream_connection_options(envoy_api_v2_Cluster *msg, envoy_api_v2_UpstreamConnectionOptions* value) { - UPB_FIELD_AT(msg, envoy_api_v2_UpstreamConnectionOptions*, UPB_SIZE(120, 208)) = value; + UPB_FIELD_AT(msg, envoy_api_v2_UpstreamConnectionOptions*, UPB_SIZE(112, 200)) = value; } UPB_INLINE struct envoy_api_v2_UpstreamConnectionOptions* envoy_api_v2_Cluster_mutable_upstream_connection_options(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_UpstreamConnectionOptions* sub = (struct envoy_api_v2_UpstreamConnectionOptions*)envoy_api_v2_Cluster_upstream_connection_options(msg); @@ -485,13 +504,13 @@ UPB_INLINE struct envoy_api_v2_UpstreamConnectionOptions* envoy_api_v2_Cluster_m return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_close_connections_on_host_health_failure(envoy_api_v2_Cluster *msg, bool value) { - UPB_FIELD_AT(msg, bool, UPB_SIZE(32, 32)) = value; + UPB_FIELD_AT(msg, bool, UPB_SIZE(24, 24)) = value; } UPB_INLINE void envoy_api_v2_Cluster_set_drain_connections_on_host_removal(envoy_api_v2_Cluster *msg, bool value) { - UPB_FIELD_AT(msg, bool, UPB_SIZE(33, 33)) = value; + UPB_FIELD_AT(msg, bool, UPB_SIZE(25, 25)) = value; } UPB_INLINE void envoy_api_v2_Cluster_set_load_assignment(envoy_api_v2_Cluster *msg, struct envoy_api_v2_ClusterLoadAssignment* value) { - UPB_FIELD_AT(msg, struct envoy_api_v2_ClusterLoadAssignment*, UPB_SIZE(124, 216)) = value; + UPB_FIELD_AT(msg, struct envoy_api_v2_ClusterLoadAssignment*, UPB_SIZE(116, 208)) = value; } UPB_INLINE struct envoy_api_v2_ClusterLoadAssignment* envoy_api_v2_Cluster_mutable_load_assignment(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_ClusterLoadAssignment* sub = (struct envoy_api_v2_ClusterLoadAssignment*)envoy_api_v2_Cluster_load_assignment(msg); @@ -503,7 +522,7 @@ UPB_INLINE struct envoy_api_v2_ClusterLoadAssignment* envoy_api_v2_Cluster_mutab return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_original_dst_lb_config(envoy_api_v2_Cluster *msg, envoy_api_v2_Cluster_OriginalDstLbConfig* value) { - UPB_WRITE_ONEOF(msg, envoy_api_v2_Cluster_OriginalDstLbConfig*, UPB_SIZE(148, 264), value, UPB_SIZE(152, 272), 34); + UPB_WRITE_ONEOF(msg, envoy_api_v2_Cluster_OriginalDstLbConfig*, UPB_SIZE(156, 272), value, UPB_SIZE(160, 280), 34); } UPB_INLINE struct envoy_api_v2_Cluster_OriginalDstLbConfig* envoy_api_v2_Cluster_mutable_original_dst_lb_config(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_Cluster_OriginalDstLbConfig* sub = (struct envoy_api_v2_Cluster_OriginalDstLbConfig*)envoy_api_v2_Cluster_original_dst_lb_config(msg); @@ -515,41 +534,98 @@ UPB_INLINE struct envoy_api_v2_Cluster_OriginalDstLbConfig* envoy_api_v2_Cluster return sub; } UPB_INLINE envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry** envoy_api_v2_Cluster_mutable_extension_protocol_options(envoy_api_v2_Cluster *msg, size_t *len) { - return (envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry**)_upb_array_mutable_accessor(msg, UPB_SIZE(140, 248), len); + return (envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry**)_upb_array_mutable_accessor(msg, UPB_SIZE(132, 240), len); } UPB_INLINE envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry** envoy_api_v2_Cluster_resize_extension_protocol_options(envoy_api_v2_Cluster *msg, size_t len, upb_arena *arena) { - return (envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry**)_upb_array_resize_accessor(msg, UPB_SIZE(140, 248), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); + return (envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry**)_upb_array_resize_accessor(msg, UPB_SIZE(132, 240), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); } UPB_INLINE struct envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry* envoy_api_v2_Cluster_add_extension_protocol_options(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry* sub = (struct envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry*)upb_msg_new(&envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry_msginit, arena); bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(140, 248), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + msg, UPB_SIZE(132, 240), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); if (!ok) return NULL; return sub; } UPB_INLINE envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry** envoy_api_v2_Cluster_mutable_typed_extension_protocol_options(envoy_api_v2_Cluster *msg, size_t *len) { - return (envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry**)_upb_array_mutable_accessor(msg, UPB_SIZE(144, 256), len); + return (envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry**)_upb_array_mutable_accessor(msg, UPB_SIZE(136, 248), len); } UPB_INLINE envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry** envoy_api_v2_Cluster_resize_typed_extension_protocol_options(envoy_api_v2_Cluster *msg, size_t len, upb_arena *arena) { - return (envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry**)_upb_array_resize_accessor(msg, UPB_SIZE(144, 256), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); + return (envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry**)_upb_array_resize_accessor(msg, UPB_SIZE(136, 248), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); } UPB_INLINE struct envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry* envoy_api_v2_Cluster_add_typed_extension_protocol_options(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry* sub = (struct envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry*)upb_msg_new(&envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry_msginit, arena); bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(144, 256), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + msg, UPB_SIZE(136, 248), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); if (!ok) return NULL; return sub; } +UPB_INLINE void envoy_api_v2_Cluster_set_least_request_lb_config(envoy_api_v2_Cluster *msg, envoy_api_v2_Cluster_LeastRequestLbConfig* value) { + UPB_WRITE_ONEOF(msg, envoy_api_v2_Cluster_LeastRequestLbConfig*, UPB_SIZE(156, 272), value, UPB_SIZE(160, 280), 37); +} +UPB_INLINE struct envoy_api_v2_Cluster_LeastRequestLbConfig* envoy_api_v2_Cluster_mutable_least_request_lb_config(envoy_api_v2_Cluster *msg, upb_arena *arena) { + struct envoy_api_v2_Cluster_LeastRequestLbConfig* sub = (struct envoy_api_v2_Cluster_LeastRequestLbConfig*)envoy_api_v2_Cluster_least_request_lb_config(msg); + if (sub == NULL) { + sub = (struct envoy_api_v2_Cluster_LeastRequestLbConfig*)upb_msg_new(&envoy_api_v2_Cluster_LeastRequestLbConfig_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_Cluster_set_least_request_lb_config(msg, sub); + } + return sub; +} +UPB_INLINE void envoy_api_v2_Cluster_set_cluster_type(envoy_api_v2_Cluster *msg, envoy_api_v2_Cluster_CustomClusterType* value) { + UPB_WRITE_ONEOF(msg, envoy_api_v2_Cluster_CustomClusterType*, UPB_SIZE(144, 256), value, UPB_SIZE(152, 264), 38); +} +UPB_INLINE struct envoy_api_v2_Cluster_CustomClusterType* envoy_api_v2_Cluster_mutable_cluster_type(envoy_api_v2_Cluster *msg, upb_arena *arena) { + struct envoy_api_v2_Cluster_CustomClusterType* sub = (struct envoy_api_v2_Cluster_CustomClusterType*)envoy_api_v2_Cluster_cluster_type(msg); + if (sub == NULL) { + sub = (struct envoy_api_v2_Cluster_CustomClusterType*)upb_msg_new(&envoy_api_v2_Cluster_CustomClusterType_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_Cluster_set_cluster_type(msg, sub); + } + return sub; +} +/* envoy.api.v2.Cluster.CustomClusterType */ + +UPB_INLINE envoy_api_v2_Cluster_CustomClusterType *envoy_api_v2_Cluster_CustomClusterType_new(upb_arena *arena) { + return (envoy_api_v2_Cluster_CustomClusterType *)upb_msg_new(&envoy_api_v2_Cluster_CustomClusterType_msginit, arena); +} +UPB_INLINE envoy_api_v2_Cluster_CustomClusterType *envoy_api_v2_Cluster_CustomClusterType_parse(const char *buf, size_t size, + upb_arena *arena) { + envoy_api_v2_Cluster_CustomClusterType *ret = envoy_api_v2_Cluster_CustomClusterType_new(arena); + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_Cluster_CustomClusterType_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *envoy_api_v2_Cluster_CustomClusterType_serialize(const envoy_api_v2_Cluster_CustomClusterType *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &envoy_api_v2_Cluster_CustomClusterType_msginit, arena, len); +} + +UPB_INLINE upb_strview envoy_api_v2_Cluster_CustomClusterType_name(const envoy_api_v2_Cluster_CustomClusterType *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } +UPB_INLINE const struct google_protobuf_Any* envoy_api_v2_Cluster_CustomClusterType_typed_config(const envoy_api_v2_Cluster_CustomClusterType *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Any*, UPB_SIZE(8, 16)); } + +UPB_INLINE void envoy_api_v2_Cluster_CustomClusterType_set_name(envoy_api_v2_Cluster_CustomClusterType *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE void envoy_api_v2_Cluster_CustomClusterType_set_typed_config(envoy_api_v2_Cluster_CustomClusterType *msg, struct google_protobuf_Any* value) { + UPB_FIELD_AT(msg, struct google_protobuf_Any*, UPB_SIZE(8, 16)) = value; +} +UPB_INLINE struct google_protobuf_Any* envoy_api_v2_Cluster_CustomClusterType_mutable_typed_config(envoy_api_v2_Cluster_CustomClusterType *msg, upb_arena *arena) { + struct google_protobuf_Any* sub = (struct google_protobuf_Any*)envoy_api_v2_Cluster_CustomClusterType_typed_config(msg); + if (sub == NULL) { + sub = (struct google_protobuf_Any*)upb_msg_new(&google_protobuf_Any_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_Cluster_CustomClusterType_set_typed_config(msg, sub); + } + return sub; +} /* envoy.api.v2.Cluster.EdsClusterConfig */ UPB_INLINE envoy_api_v2_Cluster_EdsClusterConfig *envoy_api_v2_Cluster_EdsClusterConfig_new(upb_arena *arena) { return (envoy_api_v2_Cluster_EdsClusterConfig *)upb_msg_new(&envoy_api_v2_Cluster_EdsClusterConfig_msginit, arena); } -UPB_INLINE envoy_api_v2_Cluster_EdsClusterConfig *envoy_api_v2_Cluster_EdsClusterConfig_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_Cluster_EdsClusterConfig *envoy_api_v2_Cluster_EdsClusterConfig_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_Cluster_EdsClusterConfig *ret = envoy_api_v2_Cluster_EdsClusterConfig_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_Cluster_EdsClusterConfig_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_Cluster_EdsClusterConfig_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_Cluster_EdsClusterConfig_serialize(const envoy_api_v2_Cluster_EdsClusterConfig *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_Cluster_EdsClusterConfig_msginit, arena, len); @@ -574,15 +650,15 @@ UPB_INLINE void envoy_api_v2_Cluster_EdsClusterConfig_set_service_name(envoy_api UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; } - /* envoy.api.v2.Cluster.ExtensionProtocolOptionsEntry */ UPB_INLINE envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry *envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry_new(upb_arena *arena) { return (envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry *)upb_msg_new(&envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry_msginit, arena); } -UPB_INLINE envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry *envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry *envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry *ret = envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry_serialize(const envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry_msginit, arena, len); @@ -607,15 +683,15 @@ UPB_INLINE struct google_protobuf_Struct* envoy_api_v2_Cluster_ExtensionProtocol return sub; } - /* envoy.api.v2.Cluster.TypedExtensionProtocolOptionsEntry */ UPB_INLINE envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry *envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry_new(upb_arena *arena) { return (envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry *)upb_msg_new(&envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry_msginit, arena); } -UPB_INLINE envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry *envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry *envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry *ret = envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry_serialize(const envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry_msginit, arena, len); @@ -640,15 +716,15 @@ UPB_INLINE struct google_protobuf_Any* envoy_api_v2_Cluster_TypedExtensionProtoc return sub; } - /* envoy.api.v2.Cluster.LbSubsetConfig */ UPB_INLINE envoy_api_v2_Cluster_LbSubsetConfig *envoy_api_v2_Cluster_LbSubsetConfig_new(upb_arena *arena) { return (envoy_api_v2_Cluster_LbSubsetConfig *)upb_msg_new(&envoy_api_v2_Cluster_LbSubsetConfig_msginit, arena); } -UPB_INLINE envoy_api_v2_Cluster_LbSubsetConfig *envoy_api_v2_Cluster_LbSubsetConfig_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_Cluster_LbSubsetConfig *envoy_api_v2_Cluster_LbSubsetConfig_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_Cluster_LbSubsetConfig *ret = envoy_api_v2_Cluster_LbSubsetConfig_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_Cluster_LbSubsetConfig_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_Cluster_LbSubsetConfig_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_Cluster_LbSubsetConfig_serialize(const envoy_api_v2_Cluster_LbSubsetConfig *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_Cluster_LbSubsetConfig_msginit, arena, len); @@ -658,6 +734,8 @@ UPB_INLINE int32_t envoy_api_v2_Cluster_LbSubsetConfig_fallback_policy(const env UPB_INLINE const struct google_protobuf_Struct* envoy_api_v2_Cluster_LbSubsetConfig_default_subset(const envoy_api_v2_Cluster_LbSubsetConfig *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Struct*, UPB_SIZE(12, 16)); } UPB_INLINE const envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector* const* envoy_api_v2_Cluster_LbSubsetConfig_subset_selectors(const envoy_api_v2_Cluster_LbSubsetConfig *msg, size_t *len) { return (const envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector* const*)_upb_array_accessor(msg, UPB_SIZE(16, 24), len); } UPB_INLINE bool envoy_api_v2_Cluster_LbSubsetConfig_locality_weight_aware(const envoy_api_v2_Cluster_LbSubsetConfig *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(8, 8)); } +UPB_INLINE bool envoy_api_v2_Cluster_LbSubsetConfig_scale_locality_weight(const envoy_api_v2_Cluster_LbSubsetConfig *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(9, 9)); } +UPB_INLINE bool envoy_api_v2_Cluster_LbSubsetConfig_panic_mode_any(const envoy_api_v2_Cluster_LbSubsetConfig *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(10, 10)); } UPB_INLINE void envoy_api_v2_Cluster_LbSubsetConfig_set_fallback_policy(envoy_api_v2_Cluster_LbSubsetConfig *msg, int32_t value) { UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)) = value; @@ -690,16 +768,22 @@ UPB_INLINE struct envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector* envoy_ap UPB_INLINE void envoy_api_v2_Cluster_LbSubsetConfig_set_locality_weight_aware(envoy_api_v2_Cluster_LbSubsetConfig *msg, bool value) { UPB_FIELD_AT(msg, bool, UPB_SIZE(8, 8)) = value; } - +UPB_INLINE void envoy_api_v2_Cluster_LbSubsetConfig_set_scale_locality_weight(envoy_api_v2_Cluster_LbSubsetConfig *msg, bool value) { + UPB_FIELD_AT(msg, bool, UPB_SIZE(9, 9)) = value; +} +UPB_INLINE void envoy_api_v2_Cluster_LbSubsetConfig_set_panic_mode_any(envoy_api_v2_Cluster_LbSubsetConfig *msg, bool value) { + UPB_FIELD_AT(msg, bool, UPB_SIZE(10, 10)) = value; +} /* envoy.api.v2.Cluster.LbSubsetConfig.LbSubsetSelector */ UPB_INLINE envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector *envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_new(upb_arena *arena) { return (envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector *)upb_msg_new(&envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_msginit, arena); } -UPB_INLINE envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector *envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector *envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector *ret = envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_serialize(const envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_msginit, arena, len); @@ -718,25 +802,55 @@ UPB_INLINE bool envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_add_keys(en msg, UPB_SIZE(0, 0), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); } +/* envoy.api.v2.Cluster.LeastRequestLbConfig */ + +UPB_INLINE envoy_api_v2_Cluster_LeastRequestLbConfig *envoy_api_v2_Cluster_LeastRequestLbConfig_new(upb_arena *arena) { + return (envoy_api_v2_Cluster_LeastRequestLbConfig *)upb_msg_new(&envoy_api_v2_Cluster_LeastRequestLbConfig_msginit, arena); +} +UPB_INLINE envoy_api_v2_Cluster_LeastRequestLbConfig *envoy_api_v2_Cluster_LeastRequestLbConfig_parse(const char *buf, size_t size, + upb_arena *arena) { + envoy_api_v2_Cluster_LeastRequestLbConfig *ret = envoy_api_v2_Cluster_LeastRequestLbConfig_new(arena); + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_Cluster_LeastRequestLbConfig_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *envoy_api_v2_Cluster_LeastRequestLbConfig_serialize(const envoy_api_v2_Cluster_LeastRequestLbConfig *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &envoy_api_v2_Cluster_LeastRequestLbConfig_msginit, arena, len); +} + +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_Cluster_LeastRequestLbConfig_choice_count(const envoy_api_v2_Cluster_LeastRequestLbConfig *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(0, 0)); } + +UPB_INLINE void envoy_api_v2_Cluster_LeastRequestLbConfig_set_choice_count(envoy_api_v2_Cluster_LeastRequestLbConfig *msg, struct google_protobuf_UInt32Value* value) { + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_Cluster_LeastRequestLbConfig_mutable_choice_count(envoy_api_v2_Cluster_LeastRequestLbConfig *msg, upb_arena *arena) { + struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_Cluster_LeastRequestLbConfig_choice_count(msg); + if (sub == NULL) { + sub = (struct google_protobuf_UInt32Value*)upb_msg_new(&google_protobuf_UInt32Value_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_Cluster_LeastRequestLbConfig_set_choice_count(msg, sub); + } + return sub; +} /* envoy.api.v2.Cluster.RingHashLbConfig */ UPB_INLINE envoy_api_v2_Cluster_RingHashLbConfig *envoy_api_v2_Cluster_RingHashLbConfig_new(upb_arena *arena) { return (envoy_api_v2_Cluster_RingHashLbConfig *)upb_msg_new(&envoy_api_v2_Cluster_RingHashLbConfig_msginit, arena); } -UPB_INLINE envoy_api_v2_Cluster_RingHashLbConfig *envoy_api_v2_Cluster_RingHashLbConfig_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_Cluster_RingHashLbConfig *envoy_api_v2_Cluster_RingHashLbConfig_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_Cluster_RingHashLbConfig *ret = envoy_api_v2_Cluster_RingHashLbConfig_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_Cluster_RingHashLbConfig_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_Cluster_RingHashLbConfig_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_Cluster_RingHashLbConfig_serialize(const envoy_api_v2_Cluster_RingHashLbConfig *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_Cluster_RingHashLbConfig_msginit, arena, len); } -UPB_INLINE const struct google_protobuf_UInt64Value* envoy_api_v2_Cluster_RingHashLbConfig_minimum_ring_size(const envoy_api_v2_Cluster_RingHashLbConfig *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt64Value*, UPB_SIZE(0, 0)); } -UPB_INLINE const envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1* envoy_api_v2_Cluster_RingHashLbConfig_deprecated_v1(const envoy_api_v2_Cluster_RingHashLbConfig *msg) { return UPB_FIELD_AT(msg, const envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1*, UPB_SIZE(4, 8)); } +UPB_INLINE const struct google_protobuf_UInt64Value* envoy_api_v2_Cluster_RingHashLbConfig_minimum_ring_size(const envoy_api_v2_Cluster_RingHashLbConfig *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt64Value*, UPB_SIZE(8, 8)); } +UPB_INLINE int32_t envoy_api_v2_Cluster_RingHashLbConfig_hash_function(const envoy_api_v2_Cluster_RingHashLbConfig *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)); } +UPB_INLINE const struct google_protobuf_UInt64Value* envoy_api_v2_Cluster_RingHashLbConfig_maximum_ring_size(const envoy_api_v2_Cluster_RingHashLbConfig *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt64Value*, UPB_SIZE(12, 16)); } UPB_INLINE void envoy_api_v2_Cluster_RingHashLbConfig_set_minimum_ring_size(envoy_api_v2_Cluster_RingHashLbConfig *msg, struct google_protobuf_UInt64Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt64Value*, UPB_SIZE(0, 0)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt64Value*, UPB_SIZE(8, 8)) = value; } UPB_INLINE struct google_protobuf_UInt64Value* envoy_api_v2_Cluster_RingHashLbConfig_mutable_minimum_ring_size(envoy_api_v2_Cluster_RingHashLbConfig *msg, upb_arena *arena) { struct google_protobuf_UInt64Value* sub = (struct google_protobuf_UInt64Value*)envoy_api_v2_Cluster_RingHashLbConfig_minimum_ring_size(msg); @@ -747,57 +861,31 @@ UPB_INLINE struct google_protobuf_UInt64Value* envoy_api_v2_Cluster_RingHashLbCo } return sub; } -UPB_INLINE void envoy_api_v2_Cluster_RingHashLbConfig_set_deprecated_v1(envoy_api_v2_Cluster_RingHashLbConfig *msg, envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1* value) { - UPB_FIELD_AT(msg, envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1*, UPB_SIZE(4, 8)) = value; +UPB_INLINE void envoy_api_v2_Cluster_RingHashLbConfig_set_hash_function(envoy_api_v2_Cluster_RingHashLbConfig *msg, int32_t value) { + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)) = value; } -UPB_INLINE struct envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1* envoy_api_v2_Cluster_RingHashLbConfig_mutable_deprecated_v1(envoy_api_v2_Cluster_RingHashLbConfig *msg, upb_arena *arena) { - struct envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1* sub = (struct envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1*)envoy_api_v2_Cluster_RingHashLbConfig_deprecated_v1(msg); +UPB_INLINE void envoy_api_v2_Cluster_RingHashLbConfig_set_maximum_ring_size(envoy_api_v2_Cluster_RingHashLbConfig *msg, struct google_protobuf_UInt64Value* value) { + UPB_FIELD_AT(msg, struct google_protobuf_UInt64Value*, UPB_SIZE(12, 16)) = value; +} +UPB_INLINE struct google_protobuf_UInt64Value* envoy_api_v2_Cluster_RingHashLbConfig_mutable_maximum_ring_size(envoy_api_v2_Cluster_RingHashLbConfig *msg, upb_arena *arena) { + struct google_protobuf_UInt64Value* sub = (struct google_protobuf_UInt64Value*)envoy_api_v2_Cluster_RingHashLbConfig_maximum_ring_size(msg); if (sub == NULL) { - sub = (struct envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1*)upb_msg_new(&envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1_msginit, arena); + sub = (struct google_protobuf_UInt64Value*)upb_msg_new(&google_protobuf_UInt64Value_msginit, arena); if (!sub) return NULL; - envoy_api_v2_Cluster_RingHashLbConfig_set_deprecated_v1(msg, sub); + envoy_api_v2_Cluster_RingHashLbConfig_set_maximum_ring_size(msg, sub); } return sub; } - -/* envoy.api.v2.Cluster.RingHashLbConfig.DeprecatedV1 */ - -UPB_INLINE envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1 *envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1_new(upb_arena *arena) { - return (envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1 *)upb_msg_new(&envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1_msginit, arena); -} -UPB_INLINE envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1 *envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1_parsenew(upb_strview buf, upb_arena *arena) { - envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1 *ret = envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1_msginit)) ? ret : NULL; -} -UPB_INLINE char *envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1_serialize(const envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1 *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1_msginit, arena, len); -} - -UPB_INLINE const struct google_protobuf_BoolValue* envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1_use_std_hash(const envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1 *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_BoolValue*, UPB_SIZE(0, 0)); } - -UPB_INLINE void envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1_set_use_std_hash(envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1 *msg, struct google_protobuf_BoolValue* value) { - UPB_FIELD_AT(msg, struct google_protobuf_BoolValue*, UPB_SIZE(0, 0)) = value; -} -UPB_INLINE struct google_protobuf_BoolValue* envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1_mutable_use_std_hash(envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1 *msg, upb_arena *arena) { - struct google_protobuf_BoolValue* sub = (struct google_protobuf_BoolValue*)envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1_use_std_hash(msg); - if (sub == NULL) { - sub = (struct google_protobuf_BoolValue*)upb_msg_new(&google_protobuf_BoolValue_msginit, arena); - if (!sub) return NULL; - envoy_api_v2_Cluster_RingHashLbConfig_DeprecatedV1_set_use_std_hash(msg, sub); - } - return sub; -} - - /* envoy.api.v2.Cluster.OriginalDstLbConfig */ UPB_INLINE envoy_api_v2_Cluster_OriginalDstLbConfig *envoy_api_v2_Cluster_OriginalDstLbConfig_new(upb_arena *arena) { return (envoy_api_v2_Cluster_OriginalDstLbConfig *)upb_msg_new(&envoy_api_v2_Cluster_OriginalDstLbConfig_msginit, arena); } -UPB_INLINE envoy_api_v2_Cluster_OriginalDstLbConfig *envoy_api_v2_Cluster_OriginalDstLbConfig_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_Cluster_OriginalDstLbConfig *envoy_api_v2_Cluster_OriginalDstLbConfig_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_Cluster_OriginalDstLbConfig *ret = envoy_api_v2_Cluster_OriginalDstLbConfig_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_Cluster_OriginalDstLbConfig_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_Cluster_OriginalDstLbConfig_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_Cluster_OriginalDstLbConfig_serialize(const envoy_api_v2_Cluster_OriginalDstLbConfig *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_Cluster_OriginalDstLbConfig_msginit, arena, len); @@ -809,15 +897,15 @@ UPB_INLINE void envoy_api_v2_Cluster_OriginalDstLbConfig_set_use_http_header(env UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)) = value; } - /* envoy.api.v2.Cluster.CommonLbConfig */ UPB_INLINE envoy_api_v2_Cluster_CommonLbConfig *envoy_api_v2_Cluster_CommonLbConfig_new(upb_arena *arena) { return (envoy_api_v2_Cluster_CommonLbConfig *)upb_msg_new(&envoy_api_v2_Cluster_CommonLbConfig_msginit, arena); } -UPB_INLINE envoy_api_v2_Cluster_CommonLbConfig *envoy_api_v2_Cluster_CommonLbConfig_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_Cluster_CommonLbConfig *envoy_api_v2_Cluster_CommonLbConfig_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_Cluster_CommonLbConfig *ret = envoy_api_v2_Cluster_CommonLbConfig_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_Cluster_CommonLbConfig_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_Cluster_CommonLbConfig_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_Cluster_CommonLbConfig_serialize(const envoy_api_v2_Cluster_CommonLbConfig *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_Cluster_CommonLbConfig_msginit, arena, len); @@ -826,19 +914,20 @@ UPB_INLINE char *envoy_api_v2_Cluster_CommonLbConfig_serialize(const envoy_api_v typedef enum { envoy_api_v2_Cluster_CommonLbConfig_locality_config_specifier_zone_aware_lb_config = 2, envoy_api_v2_Cluster_CommonLbConfig_locality_config_specifier_locality_weighted_lb_config = 3, - envoy_api_v2_Cluster_CommonLbConfig_locality_config_specifier_NOT_SET = 0, + envoy_api_v2_Cluster_CommonLbConfig_locality_config_specifier_NOT_SET = 0 } envoy_api_v2_Cluster_CommonLbConfig_locality_config_specifier_oneofcases; -UPB_INLINE envoy_api_v2_Cluster_CommonLbConfig_locality_config_specifier_oneofcases envoy_api_v2_Cluster_CommonLbConfig_locality_config_specifier_case(const envoy_api_v2_Cluster_CommonLbConfig* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(12, 24)); } +UPB_INLINE envoy_api_v2_Cluster_CommonLbConfig_locality_config_specifier_oneofcases envoy_api_v2_Cluster_CommonLbConfig_locality_config_specifier_case(const envoy_api_v2_Cluster_CommonLbConfig* msg) { return (envoy_api_v2_Cluster_CommonLbConfig_locality_config_specifier_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 32)); } -UPB_INLINE const struct envoy_type_Percent* envoy_api_v2_Cluster_CommonLbConfig_healthy_panic_threshold(const envoy_api_v2_Cluster_CommonLbConfig *msg) { return UPB_FIELD_AT(msg, const struct envoy_type_Percent*, UPB_SIZE(0, 0)); } -UPB_INLINE bool envoy_api_v2_Cluster_CommonLbConfig_has_zone_aware_lb_config(const envoy_api_v2_Cluster_CommonLbConfig *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(12, 24), 2); } -UPB_INLINE const envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig* envoy_api_v2_Cluster_CommonLbConfig_zone_aware_lb_config(const envoy_api_v2_Cluster_CommonLbConfig *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig*, UPB_SIZE(8, 16), UPB_SIZE(12, 24), 2, NULL); } -UPB_INLINE bool envoy_api_v2_Cluster_CommonLbConfig_has_locality_weighted_lb_config(const envoy_api_v2_Cluster_CommonLbConfig *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(12, 24), 3); } -UPB_INLINE const envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig* envoy_api_v2_Cluster_CommonLbConfig_locality_weighted_lb_config(const envoy_api_v2_Cluster_CommonLbConfig *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig*, UPB_SIZE(8, 16), UPB_SIZE(12, 24), 3, NULL); } -UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_Cluster_CommonLbConfig_update_merge_window(const envoy_api_v2_Cluster_CommonLbConfig *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(4, 8)); } +UPB_INLINE const struct envoy_type_Percent* envoy_api_v2_Cluster_CommonLbConfig_healthy_panic_threshold(const envoy_api_v2_Cluster_CommonLbConfig *msg) { return UPB_FIELD_AT(msg, const struct envoy_type_Percent*, UPB_SIZE(4, 8)); } +UPB_INLINE bool envoy_api_v2_Cluster_CommonLbConfig_has_zone_aware_lb_config(const envoy_api_v2_Cluster_CommonLbConfig *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(16, 32), 2); } +UPB_INLINE const envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig* envoy_api_v2_Cluster_CommonLbConfig_zone_aware_lb_config(const envoy_api_v2_Cluster_CommonLbConfig *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig*, UPB_SIZE(12, 24), UPB_SIZE(16, 32), 2, NULL); } +UPB_INLINE bool envoy_api_v2_Cluster_CommonLbConfig_has_locality_weighted_lb_config(const envoy_api_v2_Cluster_CommonLbConfig *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(16, 32), 3); } +UPB_INLINE const envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig* envoy_api_v2_Cluster_CommonLbConfig_locality_weighted_lb_config(const envoy_api_v2_Cluster_CommonLbConfig *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig*, UPB_SIZE(12, 24), UPB_SIZE(16, 32), 3, NULL); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_Cluster_CommonLbConfig_update_merge_window(const envoy_api_v2_Cluster_CommonLbConfig *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(8, 16)); } +UPB_INLINE bool envoy_api_v2_Cluster_CommonLbConfig_ignore_new_hosts_until_first_hc(const envoy_api_v2_Cluster_CommonLbConfig *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)); } UPB_INLINE void envoy_api_v2_Cluster_CommonLbConfig_set_healthy_panic_threshold(envoy_api_v2_Cluster_CommonLbConfig *msg, struct envoy_type_Percent* value) { - UPB_FIELD_AT(msg, struct envoy_type_Percent*, UPB_SIZE(0, 0)) = value; + UPB_FIELD_AT(msg, struct envoy_type_Percent*, UPB_SIZE(4, 8)) = value; } UPB_INLINE struct envoy_type_Percent* envoy_api_v2_Cluster_CommonLbConfig_mutable_healthy_panic_threshold(envoy_api_v2_Cluster_CommonLbConfig *msg, upb_arena *arena) { struct envoy_type_Percent* sub = (struct envoy_type_Percent*)envoy_api_v2_Cluster_CommonLbConfig_healthy_panic_threshold(msg); @@ -850,7 +939,7 @@ UPB_INLINE struct envoy_type_Percent* envoy_api_v2_Cluster_CommonLbConfig_mutabl return sub; } UPB_INLINE void envoy_api_v2_Cluster_CommonLbConfig_set_zone_aware_lb_config(envoy_api_v2_Cluster_CommonLbConfig *msg, envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig* value) { - UPB_WRITE_ONEOF(msg, envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig*, UPB_SIZE(8, 16), value, UPB_SIZE(12, 24), 2); + UPB_WRITE_ONEOF(msg, envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig*, UPB_SIZE(12, 24), value, UPB_SIZE(16, 32), 2); } UPB_INLINE struct envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig* envoy_api_v2_Cluster_CommonLbConfig_mutable_zone_aware_lb_config(envoy_api_v2_Cluster_CommonLbConfig *msg, upb_arena *arena) { struct envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig* sub = (struct envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig*)envoy_api_v2_Cluster_CommonLbConfig_zone_aware_lb_config(msg); @@ -862,7 +951,7 @@ UPB_INLINE struct envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig* envoy_a return sub; } UPB_INLINE void envoy_api_v2_Cluster_CommonLbConfig_set_locality_weighted_lb_config(envoy_api_v2_Cluster_CommonLbConfig *msg, envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig* value) { - UPB_WRITE_ONEOF(msg, envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig*, UPB_SIZE(8, 16), value, UPB_SIZE(12, 24), 3); + UPB_WRITE_ONEOF(msg, envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig*, UPB_SIZE(12, 24), value, UPB_SIZE(16, 32), 3); } UPB_INLINE struct envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig* envoy_api_v2_Cluster_CommonLbConfig_mutable_locality_weighted_lb_config(envoy_api_v2_Cluster_CommonLbConfig *msg, upb_arena *arena) { struct envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig* sub = (struct envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig*)envoy_api_v2_Cluster_CommonLbConfig_locality_weighted_lb_config(msg); @@ -874,7 +963,7 @@ UPB_INLINE struct envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig* return sub; } UPB_INLINE void envoy_api_v2_Cluster_CommonLbConfig_set_update_merge_window(envoy_api_v2_Cluster_CommonLbConfig *msg, struct google_protobuf_Duration* value) { - UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(4, 8)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(8, 16)) = value; } UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_Cluster_CommonLbConfig_mutable_update_merge_window(envoy_api_v2_Cluster_CommonLbConfig *msg, upb_arena *arena) { struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_Cluster_CommonLbConfig_update_merge_window(msg); @@ -885,16 +974,19 @@ UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_Cluster_CommonLbConfig_ } return sub; } - +UPB_INLINE void envoy_api_v2_Cluster_CommonLbConfig_set_ignore_new_hosts_until_first_hc(envoy_api_v2_Cluster_CommonLbConfig *msg, bool value) { + UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)) = value; +} /* envoy.api.v2.Cluster.CommonLbConfig.ZoneAwareLbConfig */ UPB_INLINE envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig *envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig_new(upb_arena *arena) { return (envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig *)upb_msg_new(&envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig_msginit, arena); } -UPB_INLINE envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig *envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig *envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig *ret = envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig_serialize(const envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig_msginit, arena, len); @@ -928,15 +1020,15 @@ UPB_INLINE struct google_protobuf_UInt64Value* envoy_api_v2_Cluster_CommonLbConf return sub; } - /* envoy.api.v2.Cluster.CommonLbConfig.LocalityWeightedLbConfig */ UPB_INLINE envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig *envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig_new(upb_arena *arena) { return (envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig *)upb_msg_new(&envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig_msginit, arena); } -UPB_INLINE envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig *envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig *envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig *ret = envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig_serialize(const envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig_msginit, arena, len); @@ -944,15 +1036,15 @@ UPB_INLINE char *envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig_se - /* envoy.api.v2.UpstreamBindConfig */ UPB_INLINE envoy_api_v2_UpstreamBindConfig *envoy_api_v2_UpstreamBindConfig_new(upb_arena *arena) { return (envoy_api_v2_UpstreamBindConfig *)upb_msg_new(&envoy_api_v2_UpstreamBindConfig_msginit, arena); } -UPB_INLINE envoy_api_v2_UpstreamBindConfig *envoy_api_v2_UpstreamBindConfig_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_UpstreamBindConfig *envoy_api_v2_UpstreamBindConfig_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_UpstreamBindConfig *ret = envoy_api_v2_UpstreamBindConfig_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_UpstreamBindConfig_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_UpstreamBindConfig_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_UpstreamBindConfig_serialize(const envoy_api_v2_UpstreamBindConfig *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_UpstreamBindConfig_msginit, arena, len); @@ -973,15 +1065,15 @@ UPB_INLINE struct envoy_api_v2_core_Address* envoy_api_v2_UpstreamBindConfig_mut return sub; } - /* envoy.api.v2.UpstreamConnectionOptions */ UPB_INLINE envoy_api_v2_UpstreamConnectionOptions *envoy_api_v2_UpstreamConnectionOptions_new(upb_arena *arena) { return (envoy_api_v2_UpstreamConnectionOptions *)upb_msg_new(&envoy_api_v2_UpstreamConnectionOptions_msginit, arena); } -UPB_INLINE envoy_api_v2_UpstreamConnectionOptions *envoy_api_v2_UpstreamConnectionOptions_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_UpstreamConnectionOptions *envoy_api_v2_UpstreamConnectionOptions_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_UpstreamConnectionOptions *ret = envoy_api_v2_UpstreamConnectionOptions_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_UpstreamConnectionOptions_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_UpstreamConnectionOptions_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_UpstreamConnectionOptions_serialize(const envoy_api_v2_UpstreamConnectionOptions *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_UpstreamConnectionOptions_msginit, arena, len); @@ -1002,7 +1094,6 @@ UPB_INLINE struct envoy_api_v2_core_TcpKeepalive* envoy_api_v2_UpstreamConnectio return sub; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c b/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c index d16f2ce2afb..12d8cf5ec3f 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +++ b/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c @@ -29,22 +29,24 @@ const upb_msglayout envoy_api_v2_cluster_CircuitBreakers_msginit = { UPB_SIZE(4, 8), 1, false, }; -static const upb_msglayout *const envoy_api_v2_cluster_CircuitBreakers_Thresholds_submsgs[4] = { +static const upb_msglayout *const envoy_api_v2_cluster_CircuitBreakers_Thresholds_submsgs[5] = { &google_protobuf_UInt32Value_msginit, }; -static const upb_msglayout_field envoy_api_v2_cluster_CircuitBreakers_Thresholds__fields[5] = { +static const upb_msglayout_field envoy_api_v2_cluster_CircuitBreakers_Thresholds__fields[7] = { {1, UPB_SIZE(0, 0), 0, 0, 14, 1}, - {2, UPB_SIZE(8, 8), 0, 0, 11, 1}, - {3, UPB_SIZE(12, 16), 0, 0, 11, 1}, - {4, UPB_SIZE(16, 24), 0, 0, 11, 1}, - {5, UPB_SIZE(20, 32), 0, 0, 11, 1}, + {2, UPB_SIZE(12, 16), 0, 0, 11, 1}, + {3, UPB_SIZE(16, 24), 0, 0, 11, 1}, + {4, UPB_SIZE(20, 32), 0, 0, 11, 1}, + {5, UPB_SIZE(24, 40), 0, 0, 11, 1}, + {6, UPB_SIZE(8, 8), 0, 0, 8, 1}, + {7, UPB_SIZE(28, 48), 0, 0, 11, 1}, }; const upb_msglayout envoy_api_v2_cluster_CircuitBreakers_Thresholds_msginit = { &envoy_api_v2_cluster_CircuitBreakers_Thresholds_submsgs[0], &envoy_api_v2_cluster_CircuitBreakers_Thresholds__fields[0], - UPB_SIZE(24, 40), 5, false, + UPB_SIZE(32, 56), 7, false, }; #include "upb/port_undef.inc" diff --git a/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h b/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h index 45fd07230b0..9a1fa088f05 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h @@ -10,12 +10,12 @@ #define ENVOY_API_V2_CLUSTER_CIRCUIT_BREAKER_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -29,17 +29,16 @@ extern const upb_msglayout envoy_api_v2_cluster_CircuitBreakers_Thresholds_msgin struct google_protobuf_UInt32Value; extern const upb_msglayout google_protobuf_UInt32Value_msginit; -/* Enums */ - /* envoy.api.v2.cluster.CircuitBreakers */ UPB_INLINE envoy_api_v2_cluster_CircuitBreakers *envoy_api_v2_cluster_CircuitBreakers_new(upb_arena *arena) { return (envoy_api_v2_cluster_CircuitBreakers *)upb_msg_new(&envoy_api_v2_cluster_CircuitBreakers_msginit, arena); } -UPB_INLINE envoy_api_v2_cluster_CircuitBreakers *envoy_api_v2_cluster_CircuitBreakers_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_cluster_CircuitBreakers *envoy_api_v2_cluster_CircuitBreakers_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_cluster_CircuitBreakers *ret = envoy_api_v2_cluster_CircuitBreakers_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_cluster_CircuitBreakers_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_cluster_CircuitBreakers_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_cluster_CircuitBreakers_serialize(const envoy_api_v2_cluster_CircuitBreakers *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_cluster_CircuitBreakers_msginit, arena, len); @@ -61,31 +60,33 @@ UPB_INLINE struct envoy_api_v2_cluster_CircuitBreakers_Thresholds* envoy_api_v2_ return sub; } - /* envoy.api.v2.cluster.CircuitBreakers.Thresholds */ UPB_INLINE envoy_api_v2_cluster_CircuitBreakers_Thresholds *envoy_api_v2_cluster_CircuitBreakers_Thresholds_new(upb_arena *arena) { return (envoy_api_v2_cluster_CircuitBreakers_Thresholds *)upb_msg_new(&envoy_api_v2_cluster_CircuitBreakers_Thresholds_msginit, arena); } -UPB_INLINE envoy_api_v2_cluster_CircuitBreakers_Thresholds *envoy_api_v2_cluster_CircuitBreakers_Thresholds_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_cluster_CircuitBreakers_Thresholds *envoy_api_v2_cluster_CircuitBreakers_Thresholds_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_cluster_CircuitBreakers_Thresholds *ret = envoy_api_v2_cluster_CircuitBreakers_Thresholds_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_cluster_CircuitBreakers_Thresholds_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_cluster_CircuitBreakers_Thresholds_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_cluster_CircuitBreakers_Thresholds_serialize(const envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_cluster_CircuitBreakers_Thresholds_msginit, arena, len); } UPB_INLINE int32_t envoy_api_v2_cluster_CircuitBreakers_Thresholds_priority(const envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)); } -UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_CircuitBreakers_Thresholds_max_connections(const envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(8, 8)); } -UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_CircuitBreakers_Thresholds_max_pending_requests(const envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(12, 16)); } -UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_CircuitBreakers_Thresholds_max_requests(const envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(16, 24)); } -UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_CircuitBreakers_Thresholds_max_retries(const envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(20, 32)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_CircuitBreakers_Thresholds_max_connections(const envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(12, 16)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_CircuitBreakers_Thresholds_max_pending_requests(const envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(16, 24)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_CircuitBreakers_Thresholds_max_requests(const envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(20, 32)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_CircuitBreakers_Thresholds_max_retries(const envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(24, 40)); } +UPB_INLINE bool envoy_api_v2_cluster_CircuitBreakers_Thresholds_track_remaining(const envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(8, 8)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_CircuitBreakers_Thresholds_max_connection_pools(const envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(28, 48)); } UPB_INLINE void envoy_api_v2_cluster_CircuitBreakers_Thresholds_set_priority(envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg, int32_t value) { UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)) = value; } UPB_INLINE void envoy_api_v2_cluster_CircuitBreakers_Thresholds_set_max_connections(envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg, struct google_protobuf_UInt32Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(8, 8)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(12, 16)) = value; } UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_CircuitBreakers_Thresholds_mutable_max_connections(envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg, upb_arena *arena) { struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_cluster_CircuitBreakers_Thresholds_max_connections(msg); @@ -97,7 +98,7 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_CircuitBreak return sub; } UPB_INLINE void envoy_api_v2_cluster_CircuitBreakers_Thresholds_set_max_pending_requests(envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg, struct google_protobuf_UInt32Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(12, 16)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(16, 24)) = value; } UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_CircuitBreakers_Thresholds_mutable_max_pending_requests(envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg, upb_arena *arena) { struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_cluster_CircuitBreakers_Thresholds_max_pending_requests(msg); @@ -109,7 +110,7 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_CircuitBreak return sub; } UPB_INLINE void envoy_api_v2_cluster_CircuitBreakers_Thresholds_set_max_requests(envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg, struct google_protobuf_UInt32Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(16, 24)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(20, 32)) = value; } UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_CircuitBreakers_Thresholds_mutable_max_requests(envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg, upb_arena *arena) { struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_cluster_CircuitBreakers_Thresholds_max_requests(msg); @@ -121,7 +122,7 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_CircuitBreak return sub; } UPB_INLINE void envoy_api_v2_cluster_CircuitBreakers_Thresholds_set_max_retries(envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg, struct google_protobuf_UInt32Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(20, 32)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(24, 40)) = value; } UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_CircuitBreakers_Thresholds_mutable_max_retries(envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg, upb_arena *arena) { struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_cluster_CircuitBreakers_Thresholds_max_retries(msg); @@ -132,7 +133,21 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_CircuitBreak } return sub; } - +UPB_INLINE void envoy_api_v2_cluster_CircuitBreakers_Thresholds_set_track_remaining(envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg, bool value) { + UPB_FIELD_AT(msg, bool, UPB_SIZE(8, 8)) = value; +} +UPB_INLINE void envoy_api_v2_cluster_CircuitBreakers_Thresholds_set_max_connection_pools(envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg, struct google_protobuf_UInt32Value* value) { + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(28, 48)) = value; +} +UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_CircuitBreakers_Thresholds_mutable_max_connection_pools(envoy_api_v2_cluster_CircuitBreakers_Thresholds *msg, upb_arena *arena) { + struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_cluster_CircuitBreakers_Thresholds_max_connection_pools(msg); + if (sub == NULL) { + sub = (struct google_protobuf_UInt32Value*)upb_msg_new(&google_protobuf_UInt32Value_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_cluster_CircuitBreakers_Thresholds_set_max_connection_pools(msg, sub); + } + return sub; +} #ifdef __cplusplus } /* extern "C" */ diff --git a/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h b/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h index 06fa49f6fd7..cb290de1c0e 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h @@ -10,12 +10,12 @@ #define ENVOY_API_V2_CLUSTER_OUTLIER_DETECTION_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -28,17 +28,16 @@ struct google_protobuf_UInt32Value; extern const upb_msglayout google_protobuf_Duration_msginit; extern const upb_msglayout google_protobuf_UInt32Value_msginit; -/* Enums */ - /* envoy.api.v2.cluster.OutlierDetection */ UPB_INLINE envoy_api_v2_cluster_OutlierDetection *envoy_api_v2_cluster_OutlierDetection_new(upb_arena *arena) { return (envoy_api_v2_cluster_OutlierDetection *)upb_msg_new(&envoy_api_v2_cluster_OutlierDetection_msginit, arena); } -UPB_INLINE envoy_api_v2_cluster_OutlierDetection *envoy_api_v2_cluster_OutlierDetection_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_cluster_OutlierDetection *envoy_api_v2_cluster_OutlierDetection_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_cluster_OutlierDetection *ret = envoy_api_v2_cluster_OutlierDetection_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_cluster_OutlierDetection_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_cluster_OutlierDetection_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_cluster_OutlierDetection_serialize(const envoy_api_v2_cluster_OutlierDetection *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_cluster_OutlierDetection_msginit, arena, len); @@ -189,7 +188,6 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetec return sub; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h b/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h index 8e0f8a28656..ebf172a036a 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h @@ -10,12 +10,12 @@ #define ENVOY_API_V2_CORE_ADDRESS_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -45,8 +45,6 @@ extern const upb_msglayout envoy_api_v2_core_SocketOption_msginit; extern const upb_msglayout google_protobuf_BoolValue_msginit; extern const upb_msglayout google_protobuf_UInt32Value_msginit; -/* Enums */ - typedef enum { envoy_api_v2_core_SocketAddress_TCP = 0, envoy_api_v2_core_SocketAddress_UDP = 1 @@ -58,9 +56,10 @@ typedef enum { UPB_INLINE envoy_api_v2_core_Pipe *envoy_api_v2_core_Pipe_new(upb_arena *arena) { return (envoy_api_v2_core_Pipe *)upb_msg_new(&envoy_api_v2_core_Pipe_msginit, arena); } -UPB_INLINE envoy_api_v2_core_Pipe *envoy_api_v2_core_Pipe_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_Pipe *envoy_api_v2_core_Pipe_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_Pipe *ret = envoy_api_v2_core_Pipe_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_Pipe_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_Pipe_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_Pipe_serialize(const envoy_api_v2_core_Pipe *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_Pipe_msginit, arena, len); @@ -72,15 +71,15 @@ UPB_INLINE void envoy_api_v2_core_Pipe_set_path(envoy_api_v2_core_Pipe *msg, upb UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; } - /* envoy.api.v2.core.SocketAddress */ UPB_INLINE envoy_api_v2_core_SocketAddress *envoy_api_v2_core_SocketAddress_new(upb_arena *arena) { return (envoy_api_v2_core_SocketAddress *)upb_msg_new(&envoy_api_v2_core_SocketAddress_msginit, arena); } -UPB_INLINE envoy_api_v2_core_SocketAddress *envoy_api_v2_core_SocketAddress_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_SocketAddress *envoy_api_v2_core_SocketAddress_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_SocketAddress *ret = envoy_api_v2_core_SocketAddress_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_SocketAddress_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_SocketAddress_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_SocketAddress_serialize(const envoy_api_v2_core_SocketAddress *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_SocketAddress_msginit, arena, len); @@ -89,9 +88,9 @@ UPB_INLINE char *envoy_api_v2_core_SocketAddress_serialize(const envoy_api_v2_co typedef enum { envoy_api_v2_core_SocketAddress_port_specifier_port_value = 3, envoy_api_v2_core_SocketAddress_port_specifier_named_port = 4, - envoy_api_v2_core_SocketAddress_port_specifier_NOT_SET = 0, + envoy_api_v2_core_SocketAddress_port_specifier_NOT_SET = 0 } envoy_api_v2_core_SocketAddress_port_specifier_oneofcases; -UPB_INLINE envoy_api_v2_core_SocketAddress_port_specifier_oneofcases envoy_api_v2_core_SocketAddress_port_specifier_case(const envoy_api_v2_core_SocketAddress* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(36, 64)); } +UPB_INLINE envoy_api_v2_core_SocketAddress_port_specifier_oneofcases envoy_api_v2_core_SocketAddress_port_specifier_case(const envoy_api_v2_core_SocketAddress* msg) { return (envoy_api_v2_core_SocketAddress_port_specifier_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(36, 64)); } UPB_INLINE int32_t envoy_api_v2_core_SocketAddress_protocol(const envoy_api_v2_core_SocketAddress *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)); } UPB_INLINE upb_strview envoy_api_v2_core_SocketAddress_address(const envoy_api_v2_core_SocketAddress *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 16)); } @@ -121,15 +120,15 @@ UPB_INLINE void envoy_api_v2_core_SocketAddress_set_ipv4_compat(envoy_api_v2_cor UPB_FIELD_AT(msg, bool, UPB_SIZE(8, 8)) = value; } - /* envoy.api.v2.core.TcpKeepalive */ UPB_INLINE envoy_api_v2_core_TcpKeepalive *envoy_api_v2_core_TcpKeepalive_new(upb_arena *arena) { return (envoy_api_v2_core_TcpKeepalive *)upb_msg_new(&envoy_api_v2_core_TcpKeepalive_msginit, arena); } -UPB_INLINE envoy_api_v2_core_TcpKeepalive *envoy_api_v2_core_TcpKeepalive_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_TcpKeepalive *envoy_api_v2_core_TcpKeepalive_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_TcpKeepalive *ret = envoy_api_v2_core_TcpKeepalive_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_TcpKeepalive_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_TcpKeepalive_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_TcpKeepalive_serialize(const envoy_api_v2_core_TcpKeepalive *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_TcpKeepalive_msginit, arena, len); @@ -176,15 +175,15 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_core_TcpKeepalive_mu return sub; } - /* envoy.api.v2.core.BindConfig */ UPB_INLINE envoy_api_v2_core_BindConfig *envoy_api_v2_core_BindConfig_new(upb_arena *arena) { return (envoy_api_v2_core_BindConfig *)upb_msg_new(&envoy_api_v2_core_BindConfig_msginit, arena); } -UPB_INLINE envoy_api_v2_core_BindConfig *envoy_api_v2_core_BindConfig_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_BindConfig *envoy_api_v2_core_BindConfig_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_BindConfig *ret = envoy_api_v2_core_BindConfig_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_BindConfig_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_BindConfig_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_BindConfig_serialize(const envoy_api_v2_core_BindConfig *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_BindConfig_msginit, arena, len); @@ -232,15 +231,15 @@ UPB_INLINE struct envoy_api_v2_core_SocketOption* envoy_api_v2_core_BindConfig_a return sub; } - /* envoy.api.v2.core.Address */ UPB_INLINE envoy_api_v2_core_Address *envoy_api_v2_core_Address_new(upb_arena *arena) { return (envoy_api_v2_core_Address *)upb_msg_new(&envoy_api_v2_core_Address_msginit, arena); } -UPB_INLINE envoy_api_v2_core_Address *envoy_api_v2_core_Address_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_Address *envoy_api_v2_core_Address_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_Address *ret = envoy_api_v2_core_Address_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_Address_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_Address_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_Address_serialize(const envoy_api_v2_core_Address *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_Address_msginit, arena, len); @@ -249,9 +248,9 @@ UPB_INLINE char *envoy_api_v2_core_Address_serialize(const envoy_api_v2_core_Add typedef enum { envoy_api_v2_core_Address_address_socket_address = 1, envoy_api_v2_core_Address_address_pipe = 2, - envoy_api_v2_core_Address_address_NOT_SET = 0, + envoy_api_v2_core_Address_address_NOT_SET = 0 } envoy_api_v2_core_Address_address_oneofcases; -UPB_INLINE envoy_api_v2_core_Address_address_oneofcases envoy_api_v2_core_Address_address_case(const envoy_api_v2_core_Address* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(4, 8)); } +UPB_INLINE envoy_api_v2_core_Address_address_oneofcases envoy_api_v2_core_Address_address_case(const envoy_api_v2_core_Address* msg) { return (envoy_api_v2_core_Address_address_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 8)); } UPB_INLINE bool envoy_api_v2_core_Address_has_socket_address(const envoy_api_v2_core_Address *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(4, 8), 1); } UPB_INLINE const envoy_api_v2_core_SocketAddress* envoy_api_v2_core_Address_socket_address(const envoy_api_v2_core_Address *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_core_SocketAddress*, UPB_SIZE(0, 0), UPB_SIZE(4, 8), 1, NULL); } @@ -283,15 +282,15 @@ UPB_INLINE struct envoy_api_v2_core_Pipe* envoy_api_v2_core_Address_mutable_pipe return sub; } - /* envoy.api.v2.core.CidrRange */ UPB_INLINE envoy_api_v2_core_CidrRange *envoy_api_v2_core_CidrRange_new(upb_arena *arena) { return (envoy_api_v2_core_CidrRange *)upb_msg_new(&envoy_api_v2_core_CidrRange_msginit, arena); } -UPB_INLINE envoy_api_v2_core_CidrRange *envoy_api_v2_core_CidrRange_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_CidrRange *envoy_api_v2_core_CidrRange_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_CidrRange *ret = envoy_api_v2_core_CidrRange_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_CidrRange_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_CidrRange_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_CidrRange_serialize(const envoy_api_v2_core_CidrRange *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_CidrRange_msginit, arena, len); @@ -316,7 +315,6 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_core_CidrRange_mutab return sub; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c b/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c index 1e5c9190381..725b17d7e31 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +++ b/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c @@ -116,6 +116,20 @@ const upb_msglayout envoy_api_v2_core_HeaderValueOption_msginit = { UPB_SIZE(8, 16), 2, false, }; +static const upb_msglayout *const envoy_api_v2_core_HeaderMap_submsgs[1] = { + &envoy_api_v2_core_HeaderValue_msginit, +}; + +static const upb_msglayout_field envoy_api_v2_core_HeaderMap__fields[1] = { + {1, UPB_SIZE(0, 0), 0, 0, 11, 3}, +}; + +const upb_msglayout envoy_api_v2_core_HeaderMap_msginit = { + &envoy_api_v2_core_HeaderMap_submsgs[0], + &envoy_api_v2_core_HeaderMap__fields[0], + UPB_SIZE(4, 8), 1, false, +}; + static const upb_msglayout_field envoy_api_v2_core_DataSource__fields[3] = { {1, UPB_SIZE(0, 0), UPB_SIZE(-9, -17), 0, 9, 1}, {2, UPB_SIZE(0, 0), UPB_SIZE(-9, -17), 0, 12, 1}, @@ -175,5 +189,15 @@ const upb_msglayout envoy_api_v2_core_RuntimeFractionalPercent_msginit = { UPB_SIZE(16, 32), 2, false, }; +static const upb_msglayout_field envoy_api_v2_core_ControlPlane__fields[1] = { + {1, UPB_SIZE(0, 0), 0, 0, 9, 1}, +}; + +const upb_msglayout envoy_api_v2_core_ControlPlane_msginit = { + NULL, + &envoy_api_v2_core_ControlPlane__fields[0], + UPB_SIZE(8, 16), 1, false, +}; + #include "upb/port_undef.inc" diff --git a/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h b/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h index 41d0dd096ac..58e6e5e3f7b 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h @@ -10,12 +10,12 @@ #define ENVOY_API_V2_CORE_BASE_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -27,10 +27,12 @@ struct envoy_api_v2_core_Metadata_FilterMetadataEntry; struct envoy_api_v2_core_RuntimeUInt32; struct envoy_api_v2_core_HeaderValue; struct envoy_api_v2_core_HeaderValueOption; +struct envoy_api_v2_core_HeaderMap; struct envoy_api_v2_core_DataSource; struct envoy_api_v2_core_TransportSocket; struct envoy_api_v2_core_SocketOption; struct envoy_api_v2_core_RuntimeFractionalPercent; +struct envoy_api_v2_core_ControlPlane; typedef struct envoy_api_v2_core_Locality envoy_api_v2_core_Locality; typedef struct envoy_api_v2_core_Node envoy_api_v2_core_Node; typedef struct envoy_api_v2_core_Metadata envoy_api_v2_core_Metadata; @@ -38,10 +40,12 @@ typedef struct envoy_api_v2_core_Metadata_FilterMetadataEntry envoy_api_v2_core_ typedef struct envoy_api_v2_core_RuntimeUInt32 envoy_api_v2_core_RuntimeUInt32; typedef struct envoy_api_v2_core_HeaderValue envoy_api_v2_core_HeaderValue; typedef struct envoy_api_v2_core_HeaderValueOption envoy_api_v2_core_HeaderValueOption; +typedef struct envoy_api_v2_core_HeaderMap envoy_api_v2_core_HeaderMap; typedef struct envoy_api_v2_core_DataSource envoy_api_v2_core_DataSource; typedef struct envoy_api_v2_core_TransportSocket envoy_api_v2_core_TransportSocket; typedef struct envoy_api_v2_core_SocketOption envoy_api_v2_core_SocketOption; typedef struct envoy_api_v2_core_RuntimeFractionalPercent envoy_api_v2_core_RuntimeFractionalPercent; +typedef struct envoy_api_v2_core_ControlPlane envoy_api_v2_core_ControlPlane; extern const upb_msglayout envoy_api_v2_core_Locality_msginit; extern const upb_msglayout envoy_api_v2_core_Node_msginit; extern const upb_msglayout envoy_api_v2_core_Metadata_msginit; @@ -49,10 +53,12 @@ extern const upb_msglayout envoy_api_v2_core_Metadata_FilterMetadataEntry_msgini extern const upb_msglayout envoy_api_v2_core_RuntimeUInt32_msginit; extern const upb_msglayout envoy_api_v2_core_HeaderValue_msginit; extern const upb_msglayout envoy_api_v2_core_HeaderValueOption_msginit; +extern const upb_msglayout envoy_api_v2_core_HeaderMap_msginit; extern const upb_msglayout envoy_api_v2_core_DataSource_msginit; extern const upb_msglayout envoy_api_v2_core_TransportSocket_msginit; extern const upb_msglayout envoy_api_v2_core_SocketOption_msginit; extern const upb_msglayout envoy_api_v2_core_RuntimeFractionalPercent_msginit; +extern const upb_msglayout envoy_api_v2_core_ControlPlane_msginit; struct envoy_type_FractionalPercent; struct google_protobuf_Any; struct google_protobuf_BoolValue; @@ -62,8 +68,6 @@ extern const upb_msglayout google_protobuf_Any_msginit; extern const upb_msglayout google_protobuf_BoolValue_msginit; extern const upb_msglayout google_protobuf_Struct_msginit; -/* Enums */ - typedef enum { envoy_api_v2_core_METHOD_UNSPECIFIED = 0, envoy_api_v2_core_GET = 1, @@ -73,7 +77,8 @@ typedef enum { envoy_api_v2_core_DELETE = 5, envoy_api_v2_core_CONNECT = 6, envoy_api_v2_core_OPTIONS = 7, - envoy_api_v2_core_TRACE = 8 + envoy_api_v2_core_TRACE = 8, + envoy_api_v2_core_PATCH = 9 } envoy_api_v2_core_RequestMethod; typedef enum { @@ -93,9 +98,10 @@ typedef enum { UPB_INLINE envoy_api_v2_core_Locality *envoy_api_v2_core_Locality_new(upb_arena *arena) { return (envoy_api_v2_core_Locality *)upb_msg_new(&envoy_api_v2_core_Locality_msginit, arena); } -UPB_INLINE envoy_api_v2_core_Locality *envoy_api_v2_core_Locality_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_Locality *envoy_api_v2_core_Locality_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_Locality *ret = envoy_api_v2_core_Locality_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_Locality_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_Locality_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_Locality_serialize(const envoy_api_v2_core_Locality *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_Locality_msginit, arena, len); @@ -115,15 +121,15 @@ UPB_INLINE void envoy_api_v2_core_Locality_set_sub_zone(envoy_api_v2_core_Locali UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(16, 32)) = value; } - /* envoy.api.v2.core.Node */ UPB_INLINE envoy_api_v2_core_Node *envoy_api_v2_core_Node_new(upb_arena *arena) { return (envoy_api_v2_core_Node *)upb_msg_new(&envoy_api_v2_core_Node_msginit, arena); } -UPB_INLINE envoy_api_v2_core_Node *envoy_api_v2_core_Node_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_Node *envoy_api_v2_core_Node_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_Node *ret = envoy_api_v2_core_Node_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_Node_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_Node_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_Node_serialize(const envoy_api_v2_core_Node *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_Node_msginit, arena, len); @@ -169,15 +175,15 @@ UPB_INLINE void envoy_api_v2_core_Node_set_build_version(envoy_api_v2_core_Node UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(16, 32)) = value; } - /* envoy.api.v2.core.Metadata */ UPB_INLINE envoy_api_v2_core_Metadata *envoy_api_v2_core_Metadata_new(upb_arena *arena) { return (envoy_api_v2_core_Metadata *)upb_msg_new(&envoy_api_v2_core_Metadata_msginit, arena); } -UPB_INLINE envoy_api_v2_core_Metadata *envoy_api_v2_core_Metadata_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_Metadata *envoy_api_v2_core_Metadata_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_Metadata *ret = envoy_api_v2_core_Metadata_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_Metadata_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_Metadata_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_Metadata_serialize(const envoy_api_v2_core_Metadata *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_Metadata_msginit, arena, len); @@ -199,15 +205,15 @@ UPB_INLINE struct envoy_api_v2_core_Metadata_FilterMetadataEntry* envoy_api_v2_c return sub; } - /* envoy.api.v2.core.Metadata.FilterMetadataEntry */ UPB_INLINE envoy_api_v2_core_Metadata_FilterMetadataEntry *envoy_api_v2_core_Metadata_FilterMetadataEntry_new(upb_arena *arena) { return (envoy_api_v2_core_Metadata_FilterMetadataEntry *)upb_msg_new(&envoy_api_v2_core_Metadata_FilterMetadataEntry_msginit, arena); } -UPB_INLINE envoy_api_v2_core_Metadata_FilterMetadataEntry *envoy_api_v2_core_Metadata_FilterMetadataEntry_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_Metadata_FilterMetadataEntry *envoy_api_v2_core_Metadata_FilterMetadataEntry_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_Metadata_FilterMetadataEntry *ret = envoy_api_v2_core_Metadata_FilterMetadataEntry_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_Metadata_FilterMetadataEntry_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_Metadata_FilterMetadataEntry_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_Metadata_FilterMetadataEntry_serialize(const envoy_api_v2_core_Metadata_FilterMetadataEntry *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_Metadata_FilterMetadataEntry_msginit, arena, len); @@ -232,15 +238,15 @@ UPB_INLINE struct google_protobuf_Struct* envoy_api_v2_core_Metadata_FilterMetad return sub; } - /* envoy.api.v2.core.RuntimeUInt32 */ UPB_INLINE envoy_api_v2_core_RuntimeUInt32 *envoy_api_v2_core_RuntimeUInt32_new(upb_arena *arena) { return (envoy_api_v2_core_RuntimeUInt32 *)upb_msg_new(&envoy_api_v2_core_RuntimeUInt32_msginit, arena); } -UPB_INLINE envoy_api_v2_core_RuntimeUInt32 *envoy_api_v2_core_RuntimeUInt32_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_RuntimeUInt32 *envoy_api_v2_core_RuntimeUInt32_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_RuntimeUInt32 *ret = envoy_api_v2_core_RuntimeUInt32_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_RuntimeUInt32_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_RuntimeUInt32_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_RuntimeUInt32_serialize(const envoy_api_v2_core_RuntimeUInt32 *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_RuntimeUInt32_msginit, arena, len); @@ -256,15 +262,15 @@ UPB_INLINE void envoy_api_v2_core_RuntimeUInt32_set_runtime_key(envoy_api_v2_cor UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; } - /* envoy.api.v2.core.HeaderValue */ UPB_INLINE envoy_api_v2_core_HeaderValue *envoy_api_v2_core_HeaderValue_new(upb_arena *arena) { return (envoy_api_v2_core_HeaderValue *)upb_msg_new(&envoy_api_v2_core_HeaderValue_msginit, arena); } -UPB_INLINE envoy_api_v2_core_HeaderValue *envoy_api_v2_core_HeaderValue_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_HeaderValue *envoy_api_v2_core_HeaderValue_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_HeaderValue *ret = envoy_api_v2_core_HeaderValue_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_HeaderValue_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_HeaderValue_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_HeaderValue_serialize(const envoy_api_v2_core_HeaderValue *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_HeaderValue_msginit, arena, len); @@ -280,15 +286,15 @@ UPB_INLINE void envoy_api_v2_core_HeaderValue_set_value(envoy_api_v2_core_Header UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)) = value; } - /* envoy.api.v2.core.HeaderValueOption */ UPB_INLINE envoy_api_v2_core_HeaderValueOption *envoy_api_v2_core_HeaderValueOption_new(upb_arena *arena) { return (envoy_api_v2_core_HeaderValueOption *)upb_msg_new(&envoy_api_v2_core_HeaderValueOption_msginit, arena); } -UPB_INLINE envoy_api_v2_core_HeaderValueOption *envoy_api_v2_core_HeaderValueOption_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_HeaderValueOption *envoy_api_v2_core_HeaderValueOption_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_HeaderValueOption *ret = envoy_api_v2_core_HeaderValueOption_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_HeaderValueOption_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_HeaderValueOption_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_HeaderValueOption_serialize(const envoy_api_v2_core_HeaderValueOption *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_HeaderValueOption_msginit, arena, len); @@ -322,15 +328,45 @@ UPB_INLINE struct google_protobuf_BoolValue* envoy_api_v2_core_HeaderValueOption return sub; } +/* envoy.api.v2.core.HeaderMap */ + +UPB_INLINE envoy_api_v2_core_HeaderMap *envoy_api_v2_core_HeaderMap_new(upb_arena *arena) { + return (envoy_api_v2_core_HeaderMap *)upb_msg_new(&envoy_api_v2_core_HeaderMap_msginit, arena); +} +UPB_INLINE envoy_api_v2_core_HeaderMap *envoy_api_v2_core_HeaderMap_parse(const char *buf, size_t size, + upb_arena *arena) { + envoy_api_v2_core_HeaderMap *ret = envoy_api_v2_core_HeaderMap_new(arena); + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_HeaderMap_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *envoy_api_v2_core_HeaderMap_serialize(const envoy_api_v2_core_HeaderMap *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &envoy_api_v2_core_HeaderMap_msginit, arena, len); +} + +UPB_INLINE const envoy_api_v2_core_HeaderValue* const* envoy_api_v2_core_HeaderMap_headers(const envoy_api_v2_core_HeaderMap *msg, size_t *len) { return (const envoy_api_v2_core_HeaderValue* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); } + +UPB_INLINE envoy_api_v2_core_HeaderValue** envoy_api_v2_core_HeaderMap_mutable_headers(envoy_api_v2_core_HeaderMap *msg, size_t *len) { + return (envoy_api_v2_core_HeaderValue**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len); +} +UPB_INLINE envoy_api_v2_core_HeaderValue** envoy_api_v2_core_HeaderMap_resize_headers(envoy_api_v2_core_HeaderMap *msg, size_t len, upb_arena *arena) { + return (envoy_api_v2_core_HeaderValue**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct envoy_api_v2_core_HeaderValue* envoy_api_v2_core_HeaderMap_add_headers(envoy_api_v2_core_HeaderMap *msg, upb_arena *arena) { + struct envoy_api_v2_core_HeaderValue* sub = (struct envoy_api_v2_core_HeaderValue*)upb_msg_new(&envoy_api_v2_core_HeaderValue_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} /* envoy.api.v2.core.DataSource */ UPB_INLINE envoy_api_v2_core_DataSource *envoy_api_v2_core_DataSource_new(upb_arena *arena) { return (envoy_api_v2_core_DataSource *)upb_msg_new(&envoy_api_v2_core_DataSource_msginit, arena); } -UPB_INLINE envoy_api_v2_core_DataSource *envoy_api_v2_core_DataSource_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_DataSource *envoy_api_v2_core_DataSource_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_DataSource *ret = envoy_api_v2_core_DataSource_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_DataSource_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_DataSource_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_DataSource_serialize(const envoy_api_v2_core_DataSource *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_DataSource_msginit, arena, len); @@ -340,9 +376,9 @@ typedef enum { envoy_api_v2_core_DataSource_specifier_filename = 1, envoy_api_v2_core_DataSource_specifier_inline_bytes = 2, envoy_api_v2_core_DataSource_specifier_inline_string = 3, - envoy_api_v2_core_DataSource_specifier_NOT_SET = 0, + envoy_api_v2_core_DataSource_specifier_NOT_SET = 0 } envoy_api_v2_core_DataSource_specifier_oneofcases; -UPB_INLINE envoy_api_v2_core_DataSource_specifier_oneofcases envoy_api_v2_core_DataSource_specifier_case(const envoy_api_v2_core_DataSource* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(8, 16)); } +UPB_INLINE envoy_api_v2_core_DataSource_specifier_oneofcases envoy_api_v2_core_DataSource_specifier_case(const envoy_api_v2_core_DataSource* msg) { return (envoy_api_v2_core_DataSource_specifier_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 16)); } UPB_INLINE bool envoy_api_v2_core_DataSource_has_filename(const envoy_api_v2_core_DataSource *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(8, 16), 1); } UPB_INLINE upb_strview envoy_api_v2_core_DataSource_filename(const envoy_api_v2_core_DataSource *msg) { return UPB_READ_ONEOF(msg, upb_strview, UPB_SIZE(0, 0), UPB_SIZE(8, 16), 1, upb_strview_make("", strlen(""))); } @@ -361,15 +397,15 @@ UPB_INLINE void envoy_api_v2_core_DataSource_set_inline_string(envoy_api_v2_core UPB_WRITE_ONEOF(msg, upb_strview, UPB_SIZE(0, 0), value, UPB_SIZE(8, 16), 3); } - /* envoy.api.v2.core.TransportSocket */ UPB_INLINE envoy_api_v2_core_TransportSocket *envoy_api_v2_core_TransportSocket_new(upb_arena *arena) { return (envoy_api_v2_core_TransportSocket *)upb_msg_new(&envoy_api_v2_core_TransportSocket_msginit, arena); } -UPB_INLINE envoy_api_v2_core_TransportSocket *envoy_api_v2_core_TransportSocket_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_TransportSocket *envoy_api_v2_core_TransportSocket_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_TransportSocket *ret = envoy_api_v2_core_TransportSocket_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_TransportSocket_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_TransportSocket_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_TransportSocket_serialize(const envoy_api_v2_core_TransportSocket *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_TransportSocket_msginit, arena, len); @@ -378,9 +414,9 @@ UPB_INLINE char *envoy_api_v2_core_TransportSocket_serialize(const envoy_api_v2_ typedef enum { envoy_api_v2_core_TransportSocket_config_type_config = 2, envoy_api_v2_core_TransportSocket_config_type_typed_config = 3, - envoy_api_v2_core_TransportSocket_config_type_NOT_SET = 0, + envoy_api_v2_core_TransportSocket_config_type_NOT_SET = 0 } envoy_api_v2_core_TransportSocket_config_type_oneofcases; -UPB_INLINE envoy_api_v2_core_TransportSocket_config_type_oneofcases envoy_api_v2_core_TransportSocket_config_type_case(const envoy_api_v2_core_TransportSocket* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(12, 24)); } +UPB_INLINE envoy_api_v2_core_TransportSocket_config_type_oneofcases envoy_api_v2_core_TransportSocket_config_type_case(const envoy_api_v2_core_TransportSocket* msg) { return (envoy_api_v2_core_TransportSocket_config_type_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(12, 24)); } UPB_INLINE upb_strview envoy_api_v2_core_TransportSocket_name(const envoy_api_v2_core_TransportSocket *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } UPB_INLINE bool envoy_api_v2_core_TransportSocket_has_config(const envoy_api_v2_core_TransportSocket *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(12, 24), 2); } @@ -416,15 +452,15 @@ UPB_INLINE struct google_protobuf_Any* envoy_api_v2_core_TransportSocket_mutable return sub; } - /* envoy.api.v2.core.SocketOption */ UPB_INLINE envoy_api_v2_core_SocketOption *envoy_api_v2_core_SocketOption_new(upb_arena *arena) { return (envoy_api_v2_core_SocketOption *)upb_msg_new(&envoy_api_v2_core_SocketOption_msginit, arena); } -UPB_INLINE envoy_api_v2_core_SocketOption *envoy_api_v2_core_SocketOption_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_SocketOption *envoy_api_v2_core_SocketOption_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_SocketOption *ret = envoy_api_v2_core_SocketOption_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_SocketOption_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_SocketOption_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_SocketOption_serialize(const envoy_api_v2_core_SocketOption *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_SocketOption_msginit, arena, len); @@ -433,9 +469,9 @@ UPB_INLINE char *envoy_api_v2_core_SocketOption_serialize(const envoy_api_v2_cor typedef enum { envoy_api_v2_core_SocketOption_value_int_value = 4, envoy_api_v2_core_SocketOption_value_buf_value = 5, - envoy_api_v2_core_SocketOption_value_NOT_SET = 0, + envoy_api_v2_core_SocketOption_value_NOT_SET = 0 } envoy_api_v2_core_SocketOption_value_oneofcases; -UPB_INLINE envoy_api_v2_core_SocketOption_value_oneofcases envoy_api_v2_core_SocketOption_value_case(const envoy_api_v2_core_SocketOption* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(40, 56)); } +UPB_INLINE envoy_api_v2_core_SocketOption_value_oneofcases envoy_api_v2_core_SocketOption_value_case(const envoy_api_v2_core_SocketOption* msg) { return (envoy_api_v2_core_SocketOption_value_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(40, 56)); } UPB_INLINE upb_strview envoy_api_v2_core_SocketOption_description(const envoy_api_v2_core_SocketOption *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(24, 24)); } UPB_INLINE int64_t envoy_api_v2_core_SocketOption_level(const envoy_api_v2_core_SocketOption *msg) { return UPB_FIELD_AT(msg, int64_t, UPB_SIZE(0, 0)); } @@ -465,15 +501,15 @@ UPB_INLINE void envoy_api_v2_core_SocketOption_set_state(envoy_api_v2_core_Socke UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 16)) = value; } - /* envoy.api.v2.core.RuntimeFractionalPercent */ UPB_INLINE envoy_api_v2_core_RuntimeFractionalPercent *envoy_api_v2_core_RuntimeFractionalPercent_new(upb_arena *arena) { return (envoy_api_v2_core_RuntimeFractionalPercent *)upb_msg_new(&envoy_api_v2_core_RuntimeFractionalPercent_msginit, arena); } -UPB_INLINE envoy_api_v2_core_RuntimeFractionalPercent *envoy_api_v2_core_RuntimeFractionalPercent_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_RuntimeFractionalPercent *envoy_api_v2_core_RuntimeFractionalPercent_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_RuntimeFractionalPercent *ret = envoy_api_v2_core_RuntimeFractionalPercent_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_RuntimeFractionalPercent_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_RuntimeFractionalPercent_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_RuntimeFractionalPercent_serialize(const envoy_api_v2_core_RuntimeFractionalPercent *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_RuntimeFractionalPercent_msginit, arena, len); @@ -498,6 +534,25 @@ UPB_INLINE void envoy_api_v2_core_RuntimeFractionalPercent_set_runtime_key(envoy UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; } +/* envoy.api.v2.core.ControlPlane */ + +UPB_INLINE envoy_api_v2_core_ControlPlane *envoy_api_v2_core_ControlPlane_new(upb_arena *arena) { + return (envoy_api_v2_core_ControlPlane *)upb_msg_new(&envoy_api_v2_core_ControlPlane_msginit, arena); +} +UPB_INLINE envoy_api_v2_core_ControlPlane *envoy_api_v2_core_ControlPlane_parse(const char *buf, size_t size, + upb_arena *arena) { + envoy_api_v2_core_ControlPlane *ret = envoy_api_v2_core_ControlPlane_new(arena); + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_ControlPlane_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *envoy_api_v2_core_ControlPlane_serialize(const envoy_api_v2_core_ControlPlane *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &envoy_api_v2_core_ControlPlane_msginit, arena, len); +} + +UPB_INLINE upb_strview envoy_api_v2_core_ControlPlane_identifier(const envoy_api_v2_core_ControlPlane *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } + +UPB_INLINE void envoy_api_v2_core_ControlPlane_set_identifier(envoy_api_v2_core_ControlPlane *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; +} #ifdef __cplusplus } /* extern "C" */ diff --git a/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c b/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c index b36d02aeb81..5fe2a189ce0 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +++ b/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c @@ -60,21 +60,23 @@ const upb_msglayout envoy_api_v2_core_RateLimitSettings_msginit = { UPB_SIZE(8, 16), 2, false, }; -static const upb_msglayout *const envoy_api_v2_core_ConfigSource_submsgs[2] = { +static const upb_msglayout *const envoy_api_v2_core_ConfigSource_submsgs[3] = { &envoy_api_v2_core_AggregatedConfigSource_msginit, &envoy_api_v2_core_ApiConfigSource_msginit, + &google_protobuf_Duration_msginit, }; -static const upb_msglayout_field envoy_api_v2_core_ConfigSource__fields[3] = { - {1, UPB_SIZE(0, 0), UPB_SIZE(-9, -17), 0, 9, 1}, - {2, UPB_SIZE(0, 0), UPB_SIZE(-9, -17), 1, 11, 1}, - {3, UPB_SIZE(0, 0), UPB_SIZE(-9, -17), 0, 11, 1}, +static const upb_msglayout_field envoy_api_v2_core_ConfigSource__fields[4] = { + {1, UPB_SIZE(4, 8), UPB_SIZE(-13, -25), 0, 9, 1}, + {2, UPB_SIZE(4, 8), UPB_SIZE(-13, -25), 1, 11, 1}, + {3, UPB_SIZE(4, 8), UPB_SIZE(-13, -25), 0, 11, 1}, + {4, UPB_SIZE(0, 0), 0, 2, 11, 1}, }; const upb_msglayout envoy_api_v2_core_ConfigSource_msginit = { &envoy_api_v2_core_ConfigSource_submsgs[0], &envoy_api_v2_core_ConfigSource__fields[0], - UPB_SIZE(16, 32), 3, false, + UPB_SIZE(16, 32), 4, false, }; #include "upb/port_undef.inc" diff --git a/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h b/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h index 2b03b134c8e..27f4779c17f 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h @@ -10,12 +10,12 @@ #define ENVOY_API_V2_CORE_CONFIG_SOURCE_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -41,12 +41,11 @@ extern const upb_msglayout google_protobuf_DoubleValue_msginit; extern const upb_msglayout google_protobuf_Duration_msginit; extern const upb_msglayout google_protobuf_UInt32Value_msginit; -/* Enums */ - typedef enum { - envoy_api_v2_core_ApiConfigSource_REST_LEGACY = 0, + envoy_api_v2_core_ApiConfigSource_UNSUPPORTED_REST_LEGACY = 0, envoy_api_v2_core_ApiConfigSource_REST = 1, - envoy_api_v2_core_ApiConfigSource_GRPC = 2 + envoy_api_v2_core_ApiConfigSource_GRPC = 2, + envoy_api_v2_core_ApiConfigSource_DELTA_GRPC = 3 } envoy_api_v2_core_ApiConfigSource_ApiType; @@ -55,9 +54,10 @@ typedef enum { UPB_INLINE envoy_api_v2_core_ApiConfigSource *envoy_api_v2_core_ApiConfigSource_new(upb_arena *arena) { return (envoy_api_v2_core_ApiConfigSource *)upb_msg_new(&envoy_api_v2_core_ApiConfigSource_msginit, arena); } -UPB_INLINE envoy_api_v2_core_ApiConfigSource *envoy_api_v2_core_ApiConfigSource_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_ApiConfigSource *envoy_api_v2_core_ApiConfigSource_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_ApiConfigSource *ret = envoy_api_v2_core_ApiConfigSource_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_ApiConfigSource_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_ApiConfigSource_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_ApiConfigSource_serialize(const envoy_api_v2_core_ApiConfigSource *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_ApiConfigSource_msginit, arena, len); @@ -133,15 +133,15 @@ UPB_INLINE struct envoy_api_v2_core_RateLimitSettings* envoy_api_v2_core_ApiConf return sub; } - /* envoy.api.v2.core.AggregatedConfigSource */ UPB_INLINE envoy_api_v2_core_AggregatedConfigSource *envoy_api_v2_core_AggregatedConfigSource_new(upb_arena *arena) { return (envoy_api_v2_core_AggregatedConfigSource *)upb_msg_new(&envoy_api_v2_core_AggregatedConfigSource_msginit, arena); } -UPB_INLINE envoy_api_v2_core_AggregatedConfigSource *envoy_api_v2_core_AggregatedConfigSource_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_AggregatedConfigSource *envoy_api_v2_core_AggregatedConfigSource_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_AggregatedConfigSource *ret = envoy_api_v2_core_AggregatedConfigSource_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_AggregatedConfigSource_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_AggregatedConfigSource_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_AggregatedConfigSource_serialize(const envoy_api_v2_core_AggregatedConfigSource *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_AggregatedConfigSource_msginit, arena, len); @@ -149,15 +149,15 @@ UPB_INLINE char *envoy_api_v2_core_AggregatedConfigSource_serialize(const envoy_ - /* envoy.api.v2.core.RateLimitSettings */ UPB_INLINE envoy_api_v2_core_RateLimitSettings *envoy_api_v2_core_RateLimitSettings_new(upb_arena *arena) { return (envoy_api_v2_core_RateLimitSettings *)upb_msg_new(&envoy_api_v2_core_RateLimitSettings_msginit, arena); } -UPB_INLINE envoy_api_v2_core_RateLimitSettings *envoy_api_v2_core_RateLimitSettings_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_RateLimitSettings *envoy_api_v2_core_RateLimitSettings_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_RateLimitSettings *ret = envoy_api_v2_core_RateLimitSettings_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_RateLimitSettings_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_RateLimitSettings_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_RateLimitSettings_serialize(const envoy_api_v2_core_RateLimitSettings *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_RateLimitSettings_msginit, arena, len); @@ -191,15 +191,15 @@ UPB_INLINE struct google_protobuf_DoubleValue* envoy_api_v2_core_RateLimitSettin return sub; } - /* envoy.api.v2.core.ConfigSource */ UPB_INLINE envoy_api_v2_core_ConfigSource *envoy_api_v2_core_ConfigSource_new(upb_arena *arena) { return (envoy_api_v2_core_ConfigSource *)upb_msg_new(&envoy_api_v2_core_ConfigSource_msginit, arena); } -UPB_INLINE envoy_api_v2_core_ConfigSource *envoy_api_v2_core_ConfigSource_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_ConfigSource *envoy_api_v2_core_ConfigSource_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_ConfigSource *ret = envoy_api_v2_core_ConfigSource_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_ConfigSource_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_ConfigSource_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_ConfigSource_serialize(const envoy_api_v2_core_ConfigSource *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_ConfigSource_msginit, arena, len); @@ -209,22 +209,23 @@ typedef enum { envoy_api_v2_core_ConfigSource_config_source_specifier_path = 1, envoy_api_v2_core_ConfigSource_config_source_specifier_api_config_source = 2, envoy_api_v2_core_ConfigSource_config_source_specifier_ads = 3, - envoy_api_v2_core_ConfigSource_config_source_specifier_NOT_SET = 0, + envoy_api_v2_core_ConfigSource_config_source_specifier_NOT_SET = 0 } envoy_api_v2_core_ConfigSource_config_source_specifier_oneofcases; -UPB_INLINE envoy_api_v2_core_ConfigSource_config_source_specifier_oneofcases envoy_api_v2_core_ConfigSource_config_source_specifier_case(const envoy_api_v2_core_ConfigSource* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(8, 16)); } +UPB_INLINE envoy_api_v2_core_ConfigSource_config_source_specifier_oneofcases envoy_api_v2_core_ConfigSource_config_source_specifier_case(const envoy_api_v2_core_ConfigSource* msg) { return (envoy_api_v2_core_ConfigSource_config_source_specifier_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(12, 24)); } -UPB_INLINE bool envoy_api_v2_core_ConfigSource_has_path(const envoy_api_v2_core_ConfigSource *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(8, 16), 1); } -UPB_INLINE upb_strview envoy_api_v2_core_ConfigSource_path(const envoy_api_v2_core_ConfigSource *msg) { return UPB_READ_ONEOF(msg, upb_strview, UPB_SIZE(0, 0), UPB_SIZE(8, 16), 1, upb_strview_make("", strlen(""))); } -UPB_INLINE bool envoy_api_v2_core_ConfigSource_has_api_config_source(const envoy_api_v2_core_ConfigSource *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(8, 16), 2); } -UPB_INLINE const envoy_api_v2_core_ApiConfigSource* envoy_api_v2_core_ConfigSource_api_config_source(const envoy_api_v2_core_ConfigSource *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_core_ApiConfigSource*, UPB_SIZE(0, 0), UPB_SIZE(8, 16), 2, NULL); } -UPB_INLINE bool envoy_api_v2_core_ConfigSource_has_ads(const envoy_api_v2_core_ConfigSource *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(8, 16), 3); } -UPB_INLINE const envoy_api_v2_core_AggregatedConfigSource* envoy_api_v2_core_ConfigSource_ads(const envoy_api_v2_core_ConfigSource *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_core_AggregatedConfigSource*, UPB_SIZE(0, 0), UPB_SIZE(8, 16), 3, NULL); } +UPB_INLINE bool envoy_api_v2_core_ConfigSource_has_path(const envoy_api_v2_core_ConfigSource *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(12, 24), 1); } +UPB_INLINE upb_strview envoy_api_v2_core_ConfigSource_path(const envoy_api_v2_core_ConfigSource *msg) { return UPB_READ_ONEOF(msg, upb_strview, UPB_SIZE(4, 8), UPB_SIZE(12, 24), 1, upb_strview_make("", strlen(""))); } +UPB_INLINE bool envoy_api_v2_core_ConfigSource_has_api_config_source(const envoy_api_v2_core_ConfigSource *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(12, 24), 2); } +UPB_INLINE const envoy_api_v2_core_ApiConfigSource* envoy_api_v2_core_ConfigSource_api_config_source(const envoy_api_v2_core_ConfigSource *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_core_ApiConfigSource*, UPB_SIZE(4, 8), UPB_SIZE(12, 24), 2, NULL); } +UPB_INLINE bool envoy_api_v2_core_ConfigSource_has_ads(const envoy_api_v2_core_ConfigSource *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(12, 24), 3); } +UPB_INLINE const envoy_api_v2_core_AggregatedConfigSource* envoy_api_v2_core_ConfigSource_ads(const envoy_api_v2_core_ConfigSource *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_core_AggregatedConfigSource*, UPB_SIZE(4, 8), UPB_SIZE(12, 24), 3, NULL); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_ConfigSource_initial_fetch_timeout(const envoy_api_v2_core_ConfigSource *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(0, 0)); } UPB_INLINE void envoy_api_v2_core_ConfigSource_set_path(envoy_api_v2_core_ConfigSource *msg, upb_strview value) { - UPB_WRITE_ONEOF(msg, upb_strview, UPB_SIZE(0, 0), value, UPB_SIZE(8, 16), 1); + UPB_WRITE_ONEOF(msg, upb_strview, UPB_SIZE(4, 8), value, UPB_SIZE(12, 24), 1); } UPB_INLINE void envoy_api_v2_core_ConfigSource_set_api_config_source(envoy_api_v2_core_ConfigSource *msg, envoy_api_v2_core_ApiConfigSource* value) { - UPB_WRITE_ONEOF(msg, envoy_api_v2_core_ApiConfigSource*, UPB_SIZE(0, 0), value, UPB_SIZE(8, 16), 2); + UPB_WRITE_ONEOF(msg, envoy_api_v2_core_ApiConfigSource*, UPB_SIZE(4, 8), value, UPB_SIZE(12, 24), 2); } UPB_INLINE struct envoy_api_v2_core_ApiConfigSource* envoy_api_v2_core_ConfigSource_mutable_api_config_source(envoy_api_v2_core_ConfigSource *msg, upb_arena *arena) { struct envoy_api_v2_core_ApiConfigSource* sub = (struct envoy_api_v2_core_ApiConfigSource*)envoy_api_v2_core_ConfigSource_api_config_source(msg); @@ -236,7 +237,7 @@ UPB_INLINE struct envoy_api_v2_core_ApiConfigSource* envoy_api_v2_core_ConfigSou return sub; } UPB_INLINE void envoy_api_v2_core_ConfigSource_set_ads(envoy_api_v2_core_ConfigSource *msg, envoy_api_v2_core_AggregatedConfigSource* value) { - UPB_WRITE_ONEOF(msg, envoy_api_v2_core_AggregatedConfigSource*, UPB_SIZE(0, 0), value, UPB_SIZE(8, 16), 3); + UPB_WRITE_ONEOF(msg, envoy_api_v2_core_AggregatedConfigSource*, UPB_SIZE(4, 8), value, UPB_SIZE(12, 24), 3); } UPB_INLINE struct envoy_api_v2_core_AggregatedConfigSource* envoy_api_v2_core_ConfigSource_mutable_ads(envoy_api_v2_core_ConfigSource *msg, upb_arena *arena) { struct envoy_api_v2_core_AggregatedConfigSource* sub = (struct envoy_api_v2_core_AggregatedConfigSource*)envoy_api_v2_core_ConfigSource_ads(msg); @@ -247,7 +248,18 @@ UPB_INLINE struct envoy_api_v2_core_AggregatedConfigSource* envoy_api_v2_core_Co } return sub; } - +UPB_INLINE void envoy_api_v2_core_ConfigSource_set_initial_fetch_timeout(envoy_api_v2_core_ConfigSource *msg, struct google_protobuf_Duration* value) { + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_ConfigSource_mutable_initial_fetch_timeout(envoy_api_v2_core_ConfigSource *msg, upb_arena *arena) { + struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_core_ConfigSource_initial_fetch_timeout(msg); + if (sub == NULL) { + sub = (struct google_protobuf_Duration*)upb_msg_new(&google_protobuf_Duration_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_core_ConfigSource_set_initial_fetch_timeout(msg, sub); + } + return sub; +} #ifdef __cplusplus } /* extern "C" */ diff --git a/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h b/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h index 8369c026dc7..bff3c3c0e81 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h @@ -10,12 +10,12 @@ #define ENVOY_API_V2_CORE_GRPC_SERVICE_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -63,17 +63,16 @@ extern const upb_msglayout google_protobuf_Duration_msginit; extern const upb_msglayout google_protobuf_Empty_msginit; extern const upb_msglayout google_protobuf_Struct_msginit; -/* Enums */ - /* envoy.api.v2.core.GrpcService */ UPB_INLINE envoy_api_v2_core_GrpcService *envoy_api_v2_core_GrpcService_new(upb_arena *arena) { return (envoy_api_v2_core_GrpcService *)upb_msg_new(&envoy_api_v2_core_GrpcService_msginit, arena); } -UPB_INLINE envoy_api_v2_core_GrpcService *envoy_api_v2_core_GrpcService_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_GrpcService *envoy_api_v2_core_GrpcService_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_GrpcService *ret = envoy_api_v2_core_GrpcService_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_GrpcService_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_GrpcService_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_GrpcService_serialize(const envoy_api_v2_core_GrpcService *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_GrpcService_msginit, arena, len); @@ -82,9 +81,9 @@ UPB_INLINE char *envoy_api_v2_core_GrpcService_serialize(const envoy_api_v2_core typedef enum { envoy_api_v2_core_GrpcService_target_specifier_envoy_grpc = 1, envoy_api_v2_core_GrpcService_target_specifier_google_grpc = 2, - envoy_api_v2_core_GrpcService_target_specifier_NOT_SET = 0, + envoy_api_v2_core_GrpcService_target_specifier_NOT_SET = 0 } envoy_api_v2_core_GrpcService_target_specifier_oneofcases; -UPB_INLINE envoy_api_v2_core_GrpcService_target_specifier_oneofcases envoy_api_v2_core_GrpcService_target_specifier_case(const envoy_api_v2_core_GrpcService* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(12, 24)); } +UPB_INLINE envoy_api_v2_core_GrpcService_target_specifier_oneofcases envoy_api_v2_core_GrpcService_target_specifier_case(const envoy_api_v2_core_GrpcService* msg) { return (envoy_api_v2_core_GrpcService_target_specifier_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(12, 24)); } UPB_INLINE bool envoy_api_v2_core_GrpcService_has_envoy_grpc(const envoy_api_v2_core_GrpcService *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(12, 24), 1); } UPB_INLINE const envoy_api_v2_core_GrpcService_EnvoyGrpc* envoy_api_v2_core_GrpcService_envoy_grpc(const envoy_api_v2_core_GrpcService *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_core_GrpcService_EnvoyGrpc*, UPB_SIZE(8, 16), UPB_SIZE(12, 24), 1, NULL); } @@ -143,15 +142,15 @@ UPB_INLINE struct envoy_api_v2_core_HeaderValue* envoy_api_v2_core_GrpcService_a return sub; } - /* envoy.api.v2.core.GrpcService.EnvoyGrpc */ UPB_INLINE envoy_api_v2_core_GrpcService_EnvoyGrpc *envoy_api_v2_core_GrpcService_EnvoyGrpc_new(upb_arena *arena) { return (envoy_api_v2_core_GrpcService_EnvoyGrpc *)upb_msg_new(&envoy_api_v2_core_GrpcService_EnvoyGrpc_msginit, arena); } -UPB_INLINE envoy_api_v2_core_GrpcService_EnvoyGrpc *envoy_api_v2_core_GrpcService_EnvoyGrpc_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_GrpcService_EnvoyGrpc *envoy_api_v2_core_GrpcService_EnvoyGrpc_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_GrpcService_EnvoyGrpc *ret = envoy_api_v2_core_GrpcService_EnvoyGrpc_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_GrpcService_EnvoyGrpc_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_GrpcService_EnvoyGrpc_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_GrpcService_EnvoyGrpc_serialize(const envoy_api_v2_core_GrpcService_EnvoyGrpc *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_GrpcService_EnvoyGrpc_msginit, arena, len); @@ -163,15 +162,15 @@ UPB_INLINE void envoy_api_v2_core_GrpcService_EnvoyGrpc_set_cluster_name(envoy_a UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; } - /* envoy.api.v2.core.GrpcService.GoogleGrpc */ UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc *envoy_api_v2_core_GrpcService_GoogleGrpc_new(upb_arena *arena) { return (envoy_api_v2_core_GrpcService_GoogleGrpc *)upb_msg_new(&envoy_api_v2_core_GrpcService_GoogleGrpc_msginit, arena); } -UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc *envoy_api_v2_core_GrpcService_GoogleGrpc_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc *envoy_api_v2_core_GrpcService_GoogleGrpc_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_GrpcService_GoogleGrpc *ret = envoy_api_v2_core_GrpcService_GoogleGrpc_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_GrpcService_GoogleGrpc_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_GrpcService_GoogleGrpc_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_GrpcService_GoogleGrpc_serialize(const envoy_api_v2_core_GrpcService_GoogleGrpc *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_GrpcService_GoogleGrpc_msginit, arena, len); @@ -231,15 +230,15 @@ UPB_INLINE struct google_protobuf_Struct* envoy_api_v2_core_GrpcService_GoogleGr return sub; } - /* envoy.api.v2.core.GrpcService.GoogleGrpc.SslCredentials */ UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_SslCredentials *envoy_api_v2_core_GrpcService_GoogleGrpc_SslCredentials_new(upb_arena *arena) { return (envoy_api_v2_core_GrpcService_GoogleGrpc_SslCredentials *)upb_msg_new(&envoy_api_v2_core_GrpcService_GoogleGrpc_SslCredentials_msginit, arena); } -UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_SslCredentials *envoy_api_v2_core_GrpcService_GoogleGrpc_SslCredentials_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_SslCredentials *envoy_api_v2_core_GrpcService_GoogleGrpc_SslCredentials_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_GrpcService_GoogleGrpc_SslCredentials *ret = envoy_api_v2_core_GrpcService_GoogleGrpc_SslCredentials_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_GrpcService_GoogleGrpc_SslCredentials_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_GrpcService_GoogleGrpc_SslCredentials_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_GrpcService_GoogleGrpc_SslCredentials_serialize(const envoy_api_v2_core_GrpcService_GoogleGrpc_SslCredentials *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_GrpcService_GoogleGrpc_SslCredentials_msginit, arena, len); @@ -286,15 +285,15 @@ UPB_INLINE struct envoy_api_v2_core_DataSource* envoy_api_v2_core_GrpcService_Go return sub; } - /* envoy.api.v2.core.GrpcService.GoogleGrpc.GoogleLocalCredentials */ UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_GoogleLocalCredentials *envoy_api_v2_core_GrpcService_GoogleGrpc_GoogleLocalCredentials_new(upb_arena *arena) { return (envoy_api_v2_core_GrpcService_GoogleGrpc_GoogleLocalCredentials *)upb_msg_new(&envoy_api_v2_core_GrpcService_GoogleGrpc_GoogleLocalCredentials_msginit, arena); } -UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_GoogleLocalCredentials *envoy_api_v2_core_GrpcService_GoogleGrpc_GoogleLocalCredentials_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_GoogleLocalCredentials *envoy_api_v2_core_GrpcService_GoogleGrpc_GoogleLocalCredentials_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_GrpcService_GoogleGrpc_GoogleLocalCredentials *ret = envoy_api_v2_core_GrpcService_GoogleGrpc_GoogleLocalCredentials_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_GrpcService_GoogleGrpc_GoogleLocalCredentials_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_GrpcService_GoogleGrpc_GoogleLocalCredentials_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_GrpcService_GoogleGrpc_GoogleLocalCredentials_serialize(const envoy_api_v2_core_GrpcService_GoogleGrpc_GoogleLocalCredentials *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_GrpcService_GoogleGrpc_GoogleLocalCredentials_msginit, arena, len); @@ -302,15 +301,15 @@ UPB_INLINE char *envoy_api_v2_core_GrpcService_GoogleGrpc_GoogleLocalCredentials - /* envoy.api.v2.core.GrpcService.GoogleGrpc.ChannelCredentials */ UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials *envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_new(upb_arena *arena) { return (envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials *)upb_msg_new(&envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_msginit, arena); } -UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials *envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials *envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials *ret = envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_serialize(const envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_msginit, arena, len); @@ -320,9 +319,9 @@ typedef enum { envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_credential_specifier_ssl_credentials = 1, envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_credential_specifier_google_default = 2, envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_credential_specifier_local_credentials = 3, - envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_credential_specifier_NOT_SET = 0, + envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_credential_specifier_NOT_SET = 0 } envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_credential_specifier_oneofcases; -UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_credential_specifier_oneofcases envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_credential_specifier_case(const envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(4, 8)); } +UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_credential_specifier_oneofcases envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_credential_specifier_case(const envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials* msg) { return (envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_credential_specifier_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 8)); } UPB_INLINE bool envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_has_ssl_credentials(const envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(4, 8), 1); } UPB_INLINE const envoy_api_v2_core_GrpcService_GoogleGrpc_SslCredentials* envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials_ssl_credentials(const envoy_api_v2_core_GrpcService_GoogleGrpc_ChannelCredentials *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_core_GrpcService_GoogleGrpc_SslCredentials*, UPB_SIZE(0, 0), UPB_SIZE(4, 8), 1, NULL); } @@ -368,15 +367,15 @@ UPB_INLINE struct envoy_api_v2_core_GrpcService_GoogleGrpc_GoogleLocalCredential return sub; } - /* envoy.api.v2.core.GrpcService.GoogleGrpc.CallCredentials */ UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials *envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_new(upb_arena *arena) { return (envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials *)upb_msg_new(&envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_msginit, arena); } -UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials *envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials *envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials *ret = envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_serialize(const envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_msginit, arena, len); @@ -389,9 +388,9 @@ typedef enum { envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_credential_specifier_service_account_jwt_access = 4, envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_credential_specifier_google_iam = 5, envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_credential_specifier_from_plugin = 6, - envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_credential_specifier_NOT_SET = 0, + envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_credential_specifier_NOT_SET = 0 } envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_credential_specifier_oneofcases; -UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_credential_specifier_oneofcases envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_credential_specifier_case(const envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(8, 16)); } +UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_credential_specifier_oneofcases envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_credential_specifier_case(const envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials* msg) { return (envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_credential_specifier_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 16)); } UPB_INLINE bool envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_has_access_token(const envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(8, 16), 1); } UPB_INLINE upb_strview envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_access_token(const envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials *msg) { return UPB_READ_ONEOF(msg, upb_strview, UPB_SIZE(0, 0), UPB_SIZE(8, 16), 1, upb_strview_make("", strlen(""))); } @@ -461,15 +460,15 @@ UPB_INLINE struct envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_Metad return sub; } - /* envoy.api.v2.core.GrpcService.GoogleGrpc.CallCredentials.ServiceAccountJWTAccessCredentials */ UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_ServiceAccountJWTAccessCredentials *envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_ServiceAccountJWTAccessCredentials_new(upb_arena *arena) { return (envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_ServiceAccountJWTAccessCredentials *)upb_msg_new(&envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_ServiceAccountJWTAccessCredentials_msginit, arena); } -UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_ServiceAccountJWTAccessCredentials *envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_ServiceAccountJWTAccessCredentials_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_ServiceAccountJWTAccessCredentials *envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_ServiceAccountJWTAccessCredentials_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_ServiceAccountJWTAccessCredentials *ret = envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_ServiceAccountJWTAccessCredentials_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_ServiceAccountJWTAccessCredentials_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_ServiceAccountJWTAccessCredentials_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_ServiceAccountJWTAccessCredentials_serialize(const envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_ServiceAccountJWTAccessCredentials *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_ServiceAccountJWTAccessCredentials_msginit, arena, len); @@ -485,15 +484,15 @@ UPB_INLINE void envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_Service UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)) = value; } - /* envoy.api.v2.core.GrpcService.GoogleGrpc.CallCredentials.GoogleIAMCredentials */ UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_GoogleIAMCredentials *envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_GoogleIAMCredentials_new(upb_arena *arena) { return (envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_GoogleIAMCredentials *)upb_msg_new(&envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_GoogleIAMCredentials_msginit, arena); } -UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_GoogleIAMCredentials *envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_GoogleIAMCredentials_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_GoogleIAMCredentials *envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_GoogleIAMCredentials_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_GoogleIAMCredentials *ret = envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_GoogleIAMCredentials_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_GoogleIAMCredentials_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_GoogleIAMCredentials_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_GoogleIAMCredentials_serialize(const envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_GoogleIAMCredentials *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_GoogleIAMCredentials_msginit, arena, len); @@ -509,15 +508,15 @@ UPB_INLINE void envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_GoogleI UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)) = value; } - /* envoy.api.v2.core.GrpcService.GoogleGrpc.CallCredentials.MetadataCredentialsFromPlugin */ UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin *envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_new(upb_arena *arena) { return (envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin *)upb_msg_new(&envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_msginit, arena); } -UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin *envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin *envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin *ret = envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_serialize(const envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_msginit, arena, len); @@ -526,9 +525,9 @@ UPB_INLINE char *envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_Metada typedef enum { envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_config_type_config = 2, envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_config_type_typed_config = 3, - envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_config_type_NOT_SET = 0, + envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_config_type_NOT_SET = 0 } envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_config_type_oneofcases; -UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_config_type_oneofcases envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_config_type_case(const envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(12, 24)); } +UPB_INLINE envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_config_type_oneofcases envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_config_type_case(const envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin* msg) { return (envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_config_type_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(12, 24)); } UPB_INLINE upb_strview envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_name(const envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } UPB_INLINE bool envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_has_config(const envoy_api_v2_core_GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(12, 24), 2); } @@ -564,7 +563,6 @@ UPB_INLINE struct google_protobuf_Any* envoy_api_v2_core_GrpcService_GoogleGrpc_ return sub; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c b/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c index a6dcd52d45b..9b804abcadc 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +++ b/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c @@ -10,6 +10,7 @@ #include "upb/msg.h" #include "envoy/api/v2/core/health_check.upb.h" #include "envoy/api/v2/core/base.upb.h" +#include "envoy/type/range.upb.h" #include "google/protobuf/any.upb.h" #include "google/protobuf/duration.upb.h" #include "google/protobuf/struct.upb.h" @@ -19,7 +20,7 @@ #include "upb/port_def.inc" -static const upb_msglayout *const envoy_api_v2_core_HealthCheck_submsgs[15] = { +static const upb_msglayout *const envoy_api_v2_core_HealthCheck_submsgs[16] = { &envoy_api_v2_core_HealthCheck_CustomHealthCheck_msginit, &envoy_api_v2_core_HealthCheck_GrpcHealthCheck_msginit, &envoy_api_v2_core_HealthCheck_HttpHealthCheck_msginit, @@ -29,30 +30,32 @@ static const upb_msglayout *const envoy_api_v2_core_HealthCheck_submsgs[15] = { &google_protobuf_UInt32Value_msginit, }; -static const upb_msglayout_field envoy_api_v2_core_HealthCheck__fields[17] = { - {1, UPB_SIZE(12, 24), 0, 5, 11, 1}, - {2, UPB_SIZE(16, 32), 0, 5, 11, 1}, - {3, UPB_SIZE(20, 40), 0, 5, 11, 1}, - {4, UPB_SIZE(24, 48), 0, 6, 11, 1}, - {5, UPB_SIZE(28, 56), 0, 6, 11, 1}, - {6, UPB_SIZE(32, 64), 0, 6, 11, 1}, - {7, UPB_SIZE(36, 72), 0, 4, 11, 1}, - {8, UPB_SIZE(56, 112), UPB_SIZE(-61, -121), 2, 11, 1}, - {9, UPB_SIZE(56, 112), UPB_SIZE(-61, -121), 3, 11, 1}, - {11, UPB_SIZE(56, 112), UPB_SIZE(-61, -121), 1, 11, 1}, - {12, UPB_SIZE(40, 80), 0, 5, 11, 1}, - {13, UPB_SIZE(56, 112), UPB_SIZE(-61, -121), 0, 11, 1}, - {14, UPB_SIZE(44, 88), 0, 5, 11, 1}, - {15, UPB_SIZE(48, 96), 0, 5, 11, 1}, - {16, UPB_SIZE(52, 104), 0, 5, 11, 1}, - {17, UPB_SIZE(4, 8), 0, 0, 9, 1}, +static const upb_msglayout_field envoy_api_v2_core_HealthCheck__fields[19] = { + {1, UPB_SIZE(16, 24), 0, 5, 11, 1}, + {2, UPB_SIZE(20, 32), 0, 5, 11, 1}, + {3, UPB_SIZE(24, 40), 0, 5, 11, 1}, + {4, UPB_SIZE(28, 48), 0, 6, 11, 1}, + {5, UPB_SIZE(32, 56), 0, 6, 11, 1}, + {6, UPB_SIZE(36, 64), 0, 6, 11, 1}, + {7, UPB_SIZE(40, 72), 0, 4, 11, 1}, + {8, UPB_SIZE(64, 120), UPB_SIZE(-69, -129), 2, 11, 1}, + {9, UPB_SIZE(64, 120), UPB_SIZE(-69, -129), 3, 11, 1}, + {11, UPB_SIZE(64, 120), UPB_SIZE(-69, -129), 1, 11, 1}, + {12, UPB_SIZE(44, 80), 0, 5, 11, 1}, + {13, UPB_SIZE(64, 120), UPB_SIZE(-69, -129), 0, 11, 1}, + {14, UPB_SIZE(48, 88), 0, 5, 11, 1}, + {15, UPB_SIZE(52, 96), 0, 5, 11, 1}, + {16, UPB_SIZE(56, 104), 0, 5, 11, 1}, + {17, UPB_SIZE(8, 8), 0, 0, 9, 1}, {18, UPB_SIZE(0, 0), 0, 0, 13, 1}, + {19, UPB_SIZE(4, 4), 0, 0, 8, 1}, + {20, UPB_SIZE(60, 112), 0, 5, 11, 1}, }; const upb_msglayout envoy_api_v2_core_HealthCheck_msginit = { &envoy_api_v2_core_HealthCheck_submsgs[0], &envoy_api_v2_core_HealthCheck__fields[0], - UPB_SIZE(64, 128), 17, false, + UPB_SIZE(72, 144), 19, false, }; static const upb_msglayout_field envoy_api_v2_core_HealthCheck_Payload__fields[2] = { @@ -66,12 +69,13 @@ const upb_msglayout envoy_api_v2_core_HealthCheck_Payload_msginit = { UPB_SIZE(16, 32), 2, false, }; -static const upb_msglayout *const envoy_api_v2_core_HealthCheck_HttpHealthCheck_submsgs[3] = { +static const upb_msglayout *const envoy_api_v2_core_HealthCheck_HttpHealthCheck_submsgs[4] = { &envoy_api_v2_core_HeaderValueOption_msginit, &envoy_api_v2_core_HealthCheck_Payload_msginit, + &envoy_type_Int64Range_msginit, }; -static const upb_msglayout_field envoy_api_v2_core_HealthCheck_HttpHealthCheck__fields[8] = { +static const upb_msglayout_field envoy_api_v2_core_HealthCheck_HttpHealthCheck__fields[9] = { {1, UPB_SIZE(4, 8), 0, 0, 9, 1}, {2, UPB_SIZE(12, 24), 0, 0, 9, 1}, {3, UPB_SIZE(28, 56), 0, 1, 11, 1}, @@ -80,12 +84,13 @@ static const upb_msglayout_field envoy_api_v2_core_HealthCheck_HttpHealthCheck__ {6, UPB_SIZE(36, 72), 0, 0, 11, 3}, {7, UPB_SIZE(0, 0), 0, 0, 8, 1}, {8, UPB_SIZE(40, 80), 0, 0, 9, 3}, + {9, UPB_SIZE(44, 88), 0, 2, 11, 3}, }; const upb_msglayout envoy_api_v2_core_HealthCheck_HttpHealthCheck_msginit = { &envoy_api_v2_core_HealthCheck_HttpHealthCheck_submsgs[0], &envoy_api_v2_core_HealthCheck_HttpHealthCheck__fields[0], - UPB_SIZE(48, 96), 8, false, + UPB_SIZE(48, 96), 9, false, }; static const upb_msglayout *const envoy_api_v2_core_HealthCheck_TcpHealthCheck_submsgs[2] = { @@ -113,14 +118,15 @@ const upb_msglayout envoy_api_v2_core_HealthCheck_RedisHealthCheck_msginit = { UPB_SIZE(8, 16), 1, false, }; -static const upb_msglayout_field envoy_api_v2_core_HealthCheck_GrpcHealthCheck__fields[1] = { +static const upb_msglayout_field envoy_api_v2_core_HealthCheck_GrpcHealthCheck__fields[2] = { {1, UPB_SIZE(0, 0), 0, 0, 9, 1}, + {2, UPB_SIZE(8, 16), 0, 0, 9, 1}, }; const upb_msglayout envoy_api_v2_core_HealthCheck_GrpcHealthCheck_msginit = { NULL, &envoy_api_v2_core_HealthCheck_GrpcHealthCheck__fields[0], - UPB_SIZE(8, 16), 1, false, + UPB_SIZE(16, 32), 2, false, }; static const upb_msglayout *const envoy_api_v2_core_HealthCheck_CustomHealthCheck_submsgs[2] = { diff --git a/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h b/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h index 7db04bf3e73..6e7b25866db 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h @@ -10,12 +10,12 @@ #define ENVOY_API_V2_CORE_HEALTH_CHECK_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -42,26 +42,27 @@ extern const upb_msglayout envoy_api_v2_core_HealthCheck_RedisHealthCheck_msgini extern const upb_msglayout envoy_api_v2_core_HealthCheck_GrpcHealthCheck_msginit; extern const upb_msglayout envoy_api_v2_core_HealthCheck_CustomHealthCheck_msginit; struct envoy_api_v2_core_HeaderValueOption; +struct envoy_type_Int64Range; struct google_protobuf_Any; struct google_protobuf_BoolValue; struct google_protobuf_Duration; struct google_protobuf_Struct; struct google_protobuf_UInt32Value; extern const upb_msglayout envoy_api_v2_core_HeaderValueOption_msginit; +extern const upb_msglayout envoy_type_Int64Range_msginit; extern const upb_msglayout google_protobuf_Any_msginit; extern const upb_msglayout google_protobuf_BoolValue_msginit; extern const upb_msglayout google_protobuf_Duration_msginit; extern const upb_msglayout google_protobuf_Struct_msginit; extern const upb_msglayout google_protobuf_UInt32Value_msginit; -/* Enums */ - typedef enum { envoy_api_v2_core_UNKNOWN = 0, envoy_api_v2_core_HEALTHY = 1, envoy_api_v2_core_UNHEALTHY = 2, envoy_api_v2_core_DRAINING = 3, - envoy_api_v2_core_TIMEOUT = 4 + envoy_api_v2_core_TIMEOUT = 4, + envoy_api_v2_core_DEGRADED = 5 } envoy_api_v2_core_HealthStatus; @@ -70,9 +71,10 @@ typedef enum { UPB_INLINE envoy_api_v2_core_HealthCheck *envoy_api_v2_core_HealthCheck_new(upb_arena *arena) { return (envoy_api_v2_core_HealthCheck *)upb_msg_new(&envoy_api_v2_core_HealthCheck_msginit, arena); } -UPB_INLINE envoy_api_v2_core_HealthCheck *envoy_api_v2_core_HealthCheck_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_HealthCheck *envoy_api_v2_core_HealthCheck_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_HealthCheck *ret = envoy_api_v2_core_HealthCheck_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_HealthCheck_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_HealthCheck_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_HealthCheck_serialize(const envoy_api_v2_core_HealthCheck *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_HealthCheck_msginit, arena, len); @@ -83,34 +85,36 @@ typedef enum { envoy_api_v2_core_HealthCheck_health_checker_tcp_health_check = 9, envoy_api_v2_core_HealthCheck_health_checker_grpc_health_check = 11, envoy_api_v2_core_HealthCheck_health_checker_custom_health_check = 13, - envoy_api_v2_core_HealthCheck_health_checker_NOT_SET = 0, + envoy_api_v2_core_HealthCheck_health_checker_NOT_SET = 0 } envoy_api_v2_core_HealthCheck_health_checker_oneofcases; -UPB_INLINE envoy_api_v2_core_HealthCheck_health_checker_oneofcases envoy_api_v2_core_HealthCheck_health_checker_case(const envoy_api_v2_core_HealthCheck* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(60, 120)); } +UPB_INLINE envoy_api_v2_core_HealthCheck_health_checker_oneofcases envoy_api_v2_core_HealthCheck_health_checker_case(const envoy_api_v2_core_HealthCheck* msg) { return (envoy_api_v2_core_HealthCheck_health_checker_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(68, 128)); } -UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_timeout(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(12, 24)); } -UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_interval(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(16, 32)); } -UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_interval_jitter(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(20, 40)); } -UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_core_HealthCheck_unhealthy_threshold(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(24, 48)); } -UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_core_HealthCheck_healthy_threshold(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(28, 56)); } -UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_core_HealthCheck_alt_port(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(32, 64)); } -UPB_INLINE const struct google_protobuf_BoolValue* envoy_api_v2_core_HealthCheck_reuse_connection(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_BoolValue*, UPB_SIZE(36, 72)); } -UPB_INLINE bool envoy_api_v2_core_HealthCheck_has_http_health_check(const envoy_api_v2_core_HealthCheck *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(60, 120), 8); } -UPB_INLINE const envoy_api_v2_core_HealthCheck_HttpHealthCheck* envoy_api_v2_core_HealthCheck_http_health_check(const envoy_api_v2_core_HealthCheck *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_core_HealthCheck_HttpHealthCheck*, UPB_SIZE(56, 112), UPB_SIZE(60, 120), 8, NULL); } -UPB_INLINE bool envoy_api_v2_core_HealthCheck_has_tcp_health_check(const envoy_api_v2_core_HealthCheck *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(60, 120), 9); } -UPB_INLINE const envoy_api_v2_core_HealthCheck_TcpHealthCheck* envoy_api_v2_core_HealthCheck_tcp_health_check(const envoy_api_v2_core_HealthCheck *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_core_HealthCheck_TcpHealthCheck*, UPB_SIZE(56, 112), UPB_SIZE(60, 120), 9, NULL); } -UPB_INLINE bool envoy_api_v2_core_HealthCheck_has_grpc_health_check(const envoy_api_v2_core_HealthCheck *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(60, 120), 11); } -UPB_INLINE const envoy_api_v2_core_HealthCheck_GrpcHealthCheck* envoy_api_v2_core_HealthCheck_grpc_health_check(const envoy_api_v2_core_HealthCheck *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_core_HealthCheck_GrpcHealthCheck*, UPB_SIZE(56, 112), UPB_SIZE(60, 120), 11, NULL); } -UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_no_traffic_interval(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(40, 80)); } -UPB_INLINE bool envoy_api_v2_core_HealthCheck_has_custom_health_check(const envoy_api_v2_core_HealthCheck *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(60, 120), 13); } -UPB_INLINE const envoy_api_v2_core_HealthCheck_CustomHealthCheck* envoy_api_v2_core_HealthCheck_custom_health_check(const envoy_api_v2_core_HealthCheck *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_core_HealthCheck_CustomHealthCheck*, UPB_SIZE(56, 112), UPB_SIZE(60, 120), 13, NULL); } -UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_unhealthy_interval(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(44, 88)); } -UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_unhealthy_edge_interval(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(48, 96)); } -UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_healthy_edge_interval(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(52, 104)); } -UPB_INLINE upb_strview envoy_api_v2_core_HealthCheck_event_log_path(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_timeout(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(16, 24)); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_interval(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(20, 32)); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_interval_jitter(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(24, 40)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_core_HealthCheck_unhealthy_threshold(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(28, 48)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_core_HealthCheck_healthy_threshold(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(32, 56)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_core_HealthCheck_alt_port(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(36, 64)); } +UPB_INLINE const struct google_protobuf_BoolValue* envoy_api_v2_core_HealthCheck_reuse_connection(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_BoolValue*, UPB_SIZE(40, 72)); } +UPB_INLINE bool envoy_api_v2_core_HealthCheck_has_http_health_check(const envoy_api_v2_core_HealthCheck *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(68, 128), 8); } +UPB_INLINE const envoy_api_v2_core_HealthCheck_HttpHealthCheck* envoy_api_v2_core_HealthCheck_http_health_check(const envoy_api_v2_core_HealthCheck *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_core_HealthCheck_HttpHealthCheck*, UPB_SIZE(64, 120), UPB_SIZE(68, 128), 8, NULL); } +UPB_INLINE bool envoy_api_v2_core_HealthCheck_has_tcp_health_check(const envoy_api_v2_core_HealthCheck *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(68, 128), 9); } +UPB_INLINE const envoy_api_v2_core_HealthCheck_TcpHealthCheck* envoy_api_v2_core_HealthCheck_tcp_health_check(const envoy_api_v2_core_HealthCheck *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_core_HealthCheck_TcpHealthCheck*, UPB_SIZE(64, 120), UPB_SIZE(68, 128), 9, NULL); } +UPB_INLINE bool envoy_api_v2_core_HealthCheck_has_grpc_health_check(const envoy_api_v2_core_HealthCheck *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(68, 128), 11); } +UPB_INLINE const envoy_api_v2_core_HealthCheck_GrpcHealthCheck* envoy_api_v2_core_HealthCheck_grpc_health_check(const envoy_api_v2_core_HealthCheck *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_core_HealthCheck_GrpcHealthCheck*, UPB_SIZE(64, 120), UPB_SIZE(68, 128), 11, NULL); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_no_traffic_interval(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(44, 80)); } +UPB_INLINE bool envoy_api_v2_core_HealthCheck_has_custom_health_check(const envoy_api_v2_core_HealthCheck *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(68, 128), 13); } +UPB_INLINE const envoy_api_v2_core_HealthCheck_CustomHealthCheck* envoy_api_v2_core_HealthCheck_custom_health_check(const envoy_api_v2_core_HealthCheck *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_core_HealthCheck_CustomHealthCheck*, UPB_SIZE(64, 120), UPB_SIZE(68, 128), 13, NULL); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_unhealthy_interval(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(48, 88)); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_unhealthy_edge_interval(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(52, 96)); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_healthy_edge_interval(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(56, 104)); } +UPB_INLINE upb_strview envoy_api_v2_core_HealthCheck_event_log_path(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)); } UPB_INLINE uint32_t envoy_api_v2_core_HealthCheck_interval_jitter_percent(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(0, 0)); } +UPB_INLINE bool envoy_api_v2_core_HealthCheck_always_log_health_check_failures(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(4, 4)); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_initial_jitter(const envoy_api_v2_core_HealthCheck *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(60, 112)); } UPB_INLINE void envoy_api_v2_core_HealthCheck_set_timeout(envoy_api_v2_core_HealthCheck *msg, struct google_protobuf_Duration* value) { - UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(12, 24)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(16, 24)) = value; } UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_mutable_timeout(envoy_api_v2_core_HealthCheck *msg, upb_arena *arena) { struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_core_HealthCheck_timeout(msg); @@ -122,7 +126,7 @@ UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_mutabl return sub; } UPB_INLINE void envoy_api_v2_core_HealthCheck_set_interval(envoy_api_v2_core_HealthCheck *msg, struct google_protobuf_Duration* value) { - UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(16, 32)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(20, 32)) = value; } UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_mutable_interval(envoy_api_v2_core_HealthCheck *msg, upb_arena *arena) { struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_core_HealthCheck_interval(msg); @@ -134,7 +138,7 @@ UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_mutabl return sub; } UPB_INLINE void envoy_api_v2_core_HealthCheck_set_interval_jitter(envoy_api_v2_core_HealthCheck *msg, struct google_protobuf_Duration* value) { - UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(20, 40)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(24, 40)) = value; } UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_mutable_interval_jitter(envoy_api_v2_core_HealthCheck *msg, upb_arena *arena) { struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_core_HealthCheck_interval_jitter(msg); @@ -146,7 +150,7 @@ UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_mutabl return sub; } UPB_INLINE void envoy_api_v2_core_HealthCheck_set_unhealthy_threshold(envoy_api_v2_core_HealthCheck *msg, struct google_protobuf_UInt32Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(24, 48)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(28, 48)) = value; } UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_core_HealthCheck_mutable_unhealthy_threshold(envoy_api_v2_core_HealthCheck *msg, upb_arena *arena) { struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_core_HealthCheck_unhealthy_threshold(msg); @@ -158,7 +162,7 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_core_HealthCheck_mut return sub; } UPB_INLINE void envoy_api_v2_core_HealthCheck_set_healthy_threshold(envoy_api_v2_core_HealthCheck *msg, struct google_protobuf_UInt32Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(28, 56)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(32, 56)) = value; } UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_core_HealthCheck_mutable_healthy_threshold(envoy_api_v2_core_HealthCheck *msg, upb_arena *arena) { struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_core_HealthCheck_healthy_threshold(msg); @@ -170,7 +174,7 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_core_HealthCheck_mut return sub; } UPB_INLINE void envoy_api_v2_core_HealthCheck_set_alt_port(envoy_api_v2_core_HealthCheck *msg, struct google_protobuf_UInt32Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(32, 64)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(36, 64)) = value; } UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_core_HealthCheck_mutable_alt_port(envoy_api_v2_core_HealthCheck *msg, upb_arena *arena) { struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_core_HealthCheck_alt_port(msg); @@ -182,7 +186,7 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_core_HealthCheck_mut return sub; } UPB_INLINE void envoy_api_v2_core_HealthCheck_set_reuse_connection(envoy_api_v2_core_HealthCheck *msg, struct google_protobuf_BoolValue* value) { - UPB_FIELD_AT(msg, struct google_protobuf_BoolValue*, UPB_SIZE(36, 72)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_BoolValue*, UPB_SIZE(40, 72)) = value; } UPB_INLINE struct google_protobuf_BoolValue* envoy_api_v2_core_HealthCheck_mutable_reuse_connection(envoy_api_v2_core_HealthCheck *msg, upb_arena *arena) { struct google_protobuf_BoolValue* sub = (struct google_protobuf_BoolValue*)envoy_api_v2_core_HealthCheck_reuse_connection(msg); @@ -194,7 +198,7 @@ UPB_INLINE struct google_protobuf_BoolValue* envoy_api_v2_core_HealthCheck_mutab return sub; } UPB_INLINE void envoy_api_v2_core_HealthCheck_set_http_health_check(envoy_api_v2_core_HealthCheck *msg, envoy_api_v2_core_HealthCheck_HttpHealthCheck* value) { - UPB_WRITE_ONEOF(msg, envoy_api_v2_core_HealthCheck_HttpHealthCheck*, UPB_SIZE(56, 112), value, UPB_SIZE(60, 120), 8); + UPB_WRITE_ONEOF(msg, envoy_api_v2_core_HealthCheck_HttpHealthCheck*, UPB_SIZE(64, 120), value, UPB_SIZE(68, 128), 8); } UPB_INLINE struct envoy_api_v2_core_HealthCheck_HttpHealthCheck* envoy_api_v2_core_HealthCheck_mutable_http_health_check(envoy_api_v2_core_HealthCheck *msg, upb_arena *arena) { struct envoy_api_v2_core_HealthCheck_HttpHealthCheck* sub = (struct envoy_api_v2_core_HealthCheck_HttpHealthCheck*)envoy_api_v2_core_HealthCheck_http_health_check(msg); @@ -206,7 +210,7 @@ UPB_INLINE struct envoy_api_v2_core_HealthCheck_HttpHealthCheck* envoy_api_v2_co return sub; } UPB_INLINE void envoy_api_v2_core_HealthCheck_set_tcp_health_check(envoy_api_v2_core_HealthCheck *msg, envoy_api_v2_core_HealthCheck_TcpHealthCheck* value) { - UPB_WRITE_ONEOF(msg, envoy_api_v2_core_HealthCheck_TcpHealthCheck*, UPB_SIZE(56, 112), value, UPB_SIZE(60, 120), 9); + UPB_WRITE_ONEOF(msg, envoy_api_v2_core_HealthCheck_TcpHealthCheck*, UPB_SIZE(64, 120), value, UPB_SIZE(68, 128), 9); } UPB_INLINE struct envoy_api_v2_core_HealthCheck_TcpHealthCheck* envoy_api_v2_core_HealthCheck_mutable_tcp_health_check(envoy_api_v2_core_HealthCheck *msg, upb_arena *arena) { struct envoy_api_v2_core_HealthCheck_TcpHealthCheck* sub = (struct envoy_api_v2_core_HealthCheck_TcpHealthCheck*)envoy_api_v2_core_HealthCheck_tcp_health_check(msg); @@ -218,7 +222,7 @@ UPB_INLINE struct envoy_api_v2_core_HealthCheck_TcpHealthCheck* envoy_api_v2_cor return sub; } UPB_INLINE void envoy_api_v2_core_HealthCheck_set_grpc_health_check(envoy_api_v2_core_HealthCheck *msg, envoy_api_v2_core_HealthCheck_GrpcHealthCheck* value) { - UPB_WRITE_ONEOF(msg, envoy_api_v2_core_HealthCheck_GrpcHealthCheck*, UPB_SIZE(56, 112), value, UPB_SIZE(60, 120), 11); + UPB_WRITE_ONEOF(msg, envoy_api_v2_core_HealthCheck_GrpcHealthCheck*, UPB_SIZE(64, 120), value, UPB_SIZE(68, 128), 11); } UPB_INLINE struct envoy_api_v2_core_HealthCheck_GrpcHealthCheck* envoy_api_v2_core_HealthCheck_mutable_grpc_health_check(envoy_api_v2_core_HealthCheck *msg, upb_arena *arena) { struct envoy_api_v2_core_HealthCheck_GrpcHealthCheck* sub = (struct envoy_api_v2_core_HealthCheck_GrpcHealthCheck*)envoy_api_v2_core_HealthCheck_grpc_health_check(msg); @@ -230,7 +234,7 @@ UPB_INLINE struct envoy_api_v2_core_HealthCheck_GrpcHealthCheck* envoy_api_v2_co return sub; } UPB_INLINE void envoy_api_v2_core_HealthCheck_set_no_traffic_interval(envoy_api_v2_core_HealthCheck *msg, struct google_protobuf_Duration* value) { - UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(40, 80)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(44, 80)) = value; } UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_mutable_no_traffic_interval(envoy_api_v2_core_HealthCheck *msg, upb_arena *arena) { struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_core_HealthCheck_no_traffic_interval(msg); @@ -242,7 +246,7 @@ UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_mutabl return sub; } UPB_INLINE void envoy_api_v2_core_HealthCheck_set_custom_health_check(envoy_api_v2_core_HealthCheck *msg, envoy_api_v2_core_HealthCheck_CustomHealthCheck* value) { - UPB_WRITE_ONEOF(msg, envoy_api_v2_core_HealthCheck_CustomHealthCheck*, UPB_SIZE(56, 112), value, UPB_SIZE(60, 120), 13); + UPB_WRITE_ONEOF(msg, envoy_api_v2_core_HealthCheck_CustomHealthCheck*, UPB_SIZE(64, 120), value, UPB_SIZE(68, 128), 13); } UPB_INLINE struct envoy_api_v2_core_HealthCheck_CustomHealthCheck* envoy_api_v2_core_HealthCheck_mutable_custom_health_check(envoy_api_v2_core_HealthCheck *msg, upb_arena *arena) { struct envoy_api_v2_core_HealthCheck_CustomHealthCheck* sub = (struct envoy_api_v2_core_HealthCheck_CustomHealthCheck*)envoy_api_v2_core_HealthCheck_custom_health_check(msg); @@ -254,7 +258,7 @@ UPB_INLINE struct envoy_api_v2_core_HealthCheck_CustomHealthCheck* envoy_api_v2_ return sub; } UPB_INLINE void envoy_api_v2_core_HealthCheck_set_unhealthy_interval(envoy_api_v2_core_HealthCheck *msg, struct google_protobuf_Duration* value) { - UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(44, 88)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(48, 88)) = value; } UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_mutable_unhealthy_interval(envoy_api_v2_core_HealthCheck *msg, upb_arena *arena) { struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_core_HealthCheck_unhealthy_interval(msg); @@ -266,7 +270,7 @@ UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_mutabl return sub; } UPB_INLINE void envoy_api_v2_core_HealthCheck_set_unhealthy_edge_interval(envoy_api_v2_core_HealthCheck *msg, struct google_protobuf_Duration* value) { - UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(48, 96)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(52, 96)) = value; } UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_mutable_unhealthy_edge_interval(envoy_api_v2_core_HealthCheck *msg, upb_arena *arena) { struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_core_HealthCheck_unhealthy_edge_interval(msg); @@ -278,7 +282,7 @@ UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_mutabl return sub; } UPB_INLINE void envoy_api_v2_core_HealthCheck_set_healthy_edge_interval(envoy_api_v2_core_HealthCheck *msg, struct google_protobuf_Duration* value) { - UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(52, 104)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(56, 104)) = value; } UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_mutable_healthy_edge_interval(envoy_api_v2_core_HealthCheck *msg, upb_arena *arena) { struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_core_HealthCheck_healthy_edge_interval(msg); @@ -290,21 +294,36 @@ UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_mutabl return sub; } UPB_INLINE void envoy_api_v2_core_HealthCheck_set_event_log_path(envoy_api_v2_core_HealthCheck *msg, upb_strview value) { - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)) = value; } UPB_INLINE void envoy_api_v2_core_HealthCheck_set_interval_jitter_percent(envoy_api_v2_core_HealthCheck *msg, uint32_t value) { UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(0, 0)) = value; } - +UPB_INLINE void envoy_api_v2_core_HealthCheck_set_always_log_health_check_failures(envoy_api_v2_core_HealthCheck *msg, bool value) { + UPB_FIELD_AT(msg, bool, UPB_SIZE(4, 4)) = value; +} +UPB_INLINE void envoy_api_v2_core_HealthCheck_set_initial_jitter(envoy_api_v2_core_HealthCheck *msg, struct google_protobuf_Duration* value) { + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(60, 112)) = value; +} +UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_HealthCheck_mutable_initial_jitter(envoy_api_v2_core_HealthCheck *msg, upb_arena *arena) { + struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_core_HealthCheck_initial_jitter(msg); + if (sub == NULL) { + sub = (struct google_protobuf_Duration*)upb_msg_new(&google_protobuf_Duration_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_core_HealthCheck_set_initial_jitter(msg, sub); + } + return sub; +} /* envoy.api.v2.core.HealthCheck.Payload */ UPB_INLINE envoy_api_v2_core_HealthCheck_Payload *envoy_api_v2_core_HealthCheck_Payload_new(upb_arena *arena) { return (envoy_api_v2_core_HealthCheck_Payload *)upb_msg_new(&envoy_api_v2_core_HealthCheck_Payload_msginit, arena); } -UPB_INLINE envoy_api_v2_core_HealthCheck_Payload *envoy_api_v2_core_HealthCheck_Payload_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_HealthCheck_Payload *envoy_api_v2_core_HealthCheck_Payload_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_HealthCheck_Payload *ret = envoy_api_v2_core_HealthCheck_Payload_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_HealthCheck_Payload_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_HealthCheck_Payload_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_HealthCheck_Payload_serialize(const envoy_api_v2_core_HealthCheck_Payload *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_HealthCheck_Payload_msginit, arena, len); @@ -313,9 +332,9 @@ UPB_INLINE char *envoy_api_v2_core_HealthCheck_Payload_serialize(const envoy_api typedef enum { envoy_api_v2_core_HealthCheck_Payload_payload_text = 1, envoy_api_v2_core_HealthCheck_Payload_payload_binary = 2, - envoy_api_v2_core_HealthCheck_Payload_payload_NOT_SET = 0, + envoy_api_v2_core_HealthCheck_Payload_payload_NOT_SET = 0 } envoy_api_v2_core_HealthCheck_Payload_payload_oneofcases; -UPB_INLINE envoy_api_v2_core_HealthCheck_Payload_payload_oneofcases envoy_api_v2_core_HealthCheck_Payload_payload_case(const envoy_api_v2_core_HealthCheck_Payload* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(8, 16)); } +UPB_INLINE envoy_api_v2_core_HealthCheck_Payload_payload_oneofcases envoy_api_v2_core_HealthCheck_Payload_payload_case(const envoy_api_v2_core_HealthCheck_Payload* msg) { return (envoy_api_v2_core_HealthCheck_Payload_payload_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 16)); } UPB_INLINE bool envoy_api_v2_core_HealthCheck_Payload_has_text(const envoy_api_v2_core_HealthCheck_Payload *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(8, 16), 1); } UPB_INLINE upb_strview envoy_api_v2_core_HealthCheck_Payload_text(const envoy_api_v2_core_HealthCheck_Payload *msg) { return UPB_READ_ONEOF(msg, upb_strview, UPB_SIZE(0, 0), UPB_SIZE(8, 16), 1, upb_strview_make("", strlen(""))); } @@ -329,15 +348,15 @@ UPB_INLINE void envoy_api_v2_core_HealthCheck_Payload_set_binary(envoy_api_v2_co UPB_WRITE_ONEOF(msg, upb_strview, UPB_SIZE(0, 0), value, UPB_SIZE(8, 16), 2); } - /* envoy.api.v2.core.HealthCheck.HttpHealthCheck */ UPB_INLINE envoy_api_v2_core_HealthCheck_HttpHealthCheck *envoy_api_v2_core_HealthCheck_HttpHealthCheck_new(upb_arena *arena) { return (envoy_api_v2_core_HealthCheck_HttpHealthCheck *)upb_msg_new(&envoy_api_v2_core_HealthCheck_HttpHealthCheck_msginit, arena); } -UPB_INLINE envoy_api_v2_core_HealthCheck_HttpHealthCheck *envoy_api_v2_core_HealthCheck_HttpHealthCheck_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_HealthCheck_HttpHealthCheck *envoy_api_v2_core_HealthCheck_HttpHealthCheck_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_HealthCheck_HttpHealthCheck *ret = envoy_api_v2_core_HealthCheck_HttpHealthCheck_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_HealthCheck_HttpHealthCheck_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_HealthCheck_HttpHealthCheck_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_HealthCheck_HttpHealthCheck_serialize(const envoy_api_v2_core_HealthCheck_HttpHealthCheck *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_HealthCheck_HttpHealthCheck_msginit, arena, len); @@ -351,6 +370,7 @@ UPB_INLINE upb_strview envoy_api_v2_core_HealthCheck_HttpHealthCheck_service_nam UPB_INLINE const struct envoy_api_v2_core_HeaderValueOption* const* envoy_api_v2_core_HealthCheck_HttpHealthCheck_request_headers_to_add(const envoy_api_v2_core_HealthCheck_HttpHealthCheck *msg, size_t *len) { return (const struct envoy_api_v2_core_HeaderValueOption* const*)_upb_array_accessor(msg, UPB_SIZE(36, 72), len); } UPB_INLINE bool envoy_api_v2_core_HealthCheck_HttpHealthCheck_use_http2(const envoy_api_v2_core_HealthCheck_HttpHealthCheck *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)); } UPB_INLINE upb_strview const* envoy_api_v2_core_HealthCheck_HttpHealthCheck_request_headers_to_remove(const envoy_api_v2_core_HealthCheck_HttpHealthCheck *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(40, 80), len); } +UPB_INLINE const struct envoy_type_Int64Range* const* envoy_api_v2_core_HealthCheck_HttpHealthCheck_expected_statuses(const envoy_api_v2_core_HealthCheck_HttpHealthCheck *msg, size_t *len) { return (const struct envoy_type_Int64Range* const*)_upb_array_accessor(msg, UPB_SIZE(44, 88), len); } UPB_INLINE void envoy_api_v2_core_HealthCheck_HttpHealthCheck_set_host(envoy_api_v2_core_HealthCheck_HttpHealthCheck *msg, upb_strview value) { UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; @@ -411,16 +431,29 @@ UPB_INLINE bool envoy_api_v2_core_HealthCheck_HttpHealthCheck_add_request_header return _upb_array_append_accessor( msg, UPB_SIZE(40, 80), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); } - +UPB_INLINE struct envoy_type_Int64Range** envoy_api_v2_core_HealthCheck_HttpHealthCheck_mutable_expected_statuses(envoy_api_v2_core_HealthCheck_HttpHealthCheck *msg, size_t *len) { + return (struct envoy_type_Int64Range**)_upb_array_mutable_accessor(msg, UPB_SIZE(44, 88), len); +} +UPB_INLINE struct envoy_type_Int64Range** envoy_api_v2_core_HealthCheck_HttpHealthCheck_resize_expected_statuses(envoy_api_v2_core_HealthCheck_HttpHealthCheck *msg, size_t len, upb_arena *arena) { + return (struct envoy_type_Int64Range**)_upb_array_resize_accessor(msg, UPB_SIZE(44, 88), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct envoy_type_Int64Range* envoy_api_v2_core_HealthCheck_HttpHealthCheck_add_expected_statuses(envoy_api_v2_core_HealthCheck_HttpHealthCheck *msg, upb_arena *arena) { + struct envoy_type_Int64Range* sub = (struct envoy_type_Int64Range*)upb_msg_new(&envoy_type_Int64Range_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(44, 88), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} /* envoy.api.v2.core.HealthCheck.TcpHealthCheck */ UPB_INLINE envoy_api_v2_core_HealthCheck_TcpHealthCheck *envoy_api_v2_core_HealthCheck_TcpHealthCheck_new(upb_arena *arena) { return (envoy_api_v2_core_HealthCheck_TcpHealthCheck *)upb_msg_new(&envoy_api_v2_core_HealthCheck_TcpHealthCheck_msginit, arena); } -UPB_INLINE envoy_api_v2_core_HealthCheck_TcpHealthCheck *envoy_api_v2_core_HealthCheck_TcpHealthCheck_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_HealthCheck_TcpHealthCheck *envoy_api_v2_core_HealthCheck_TcpHealthCheck_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_HealthCheck_TcpHealthCheck *ret = envoy_api_v2_core_HealthCheck_TcpHealthCheck_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_HealthCheck_TcpHealthCheck_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_HealthCheck_TcpHealthCheck_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_HealthCheck_TcpHealthCheck_serialize(const envoy_api_v2_core_HealthCheck_TcpHealthCheck *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_HealthCheck_TcpHealthCheck_msginit, arena, len); @@ -455,15 +488,15 @@ UPB_INLINE struct envoy_api_v2_core_HealthCheck_Payload* envoy_api_v2_core_Healt return sub; } - /* envoy.api.v2.core.HealthCheck.RedisHealthCheck */ UPB_INLINE envoy_api_v2_core_HealthCheck_RedisHealthCheck *envoy_api_v2_core_HealthCheck_RedisHealthCheck_new(upb_arena *arena) { return (envoy_api_v2_core_HealthCheck_RedisHealthCheck *)upb_msg_new(&envoy_api_v2_core_HealthCheck_RedisHealthCheck_msginit, arena); } -UPB_INLINE envoy_api_v2_core_HealthCheck_RedisHealthCheck *envoy_api_v2_core_HealthCheck_RedisHealthCheck_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_HealthCheck_RedisHealthCheck *envoy_api_v2_core_HealthCheck_RedisHealthCheck_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_HealthCheck_RedisHealthCheck *ret = envoy_api_v2_core_HealthCheck_RedisHealthCheck_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_HealthCheck_RedisHealthCheck_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_HealthCheck_RedisHealthCheck_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_HealthCheck_RedisHealthCheck_serialize(const envoy_api_v2_core_HealthCheck_RedisHealthCheck *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_HealthCheck_RedisHealthCheck_msginit, arena, len); @@ -475,35 +508,39 @@ UPB_INLINE void envoy_api_v2_core_HealthCheck_RedisHealthCheck_set_key(envoy_api UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; } - /* envoy.api.v2.core.HealthCheck.GrpcHealthCheck */ UPB_INLINE envoy_api_v2_core_HealthCheck_GrpcHealthCheck *envoy_api_v2_core_HealthCheck_GrpcHealthCheck_new(upb_arena *arena) { return (envoy_api_v2_core_HealthCheck_GrpcHealthCheck *)upb_msg_new(&envoy_api_v2_core_HealthCheck_GrpcHealthCheck_msginit, arena); } -UPB_INLINE envoy_api_v2_core_HealthCheck_GrpcHealthCheck *envoy_api_v2_core_HealthCheck_GrpcHealthCheck_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_HealthCheck_GrpcHealthCheck *envoy_api_v2_core_HealthCheck_GrpcHealthCheck_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_HealthCheck_GrpcHealthCheck *ret = envoy_api_v2_core_HealthCheck_GrpcHealthCheck_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_HealthCheck_GrpcHealthCheck_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_HealthCheck_GrpcHealthCheck_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_HealthCheck_GrpcHealthCheck_serialize(const envoy_api_v2_core_HealthCheck_GrpcHealthCheck *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_HealthCheck_GrpcHealthCheck_msginit, arena, len); } UPB_INLINE upb_strview envoy_api_v2_core_HealthCheck_GrpcHealthCheck_service_name(const envoy_api_v2_core_HealthCheck_GrpcHealthCheck *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } +UPB_INLINE upb_strview envoy_api_v2_core_HealthCheck_GrpcHealthCheck_authority(const envoy_api_v2_core_HealthCheck_GrpcHealthCheck *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)); } UPB_INLINE void envoy_api_v2_core_HealthCheck_GrpcHealthCheck_set_service_name(envoy_api_v2_core_HealthCheck_GrpcHealthCheck *msg, upb_strview value) { UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; } - +UPB_INLINE void envoy_api_v2_core_HealthCheck_GrpcHealthCheck_set_authority(envoy_api_v2_core_HealthCheck_GrpcHealthCheck *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)) = value; +} /* envoy.api.v2.core.HealthCheck.CustomHealthCheck */ UPB_INLINE envoy_api_v2_core_HealthCheck_CustomHealthCheck *envoy_api_v2_core_HealthCheck_CustomHealthCheck_new(upb_arena *arena) { return (envoy_api_v2_core_HealthCheck_CustomHealthCheck *)upb_msg_new(&envoy_api_v2_core_HealthCheck_CustomHealthCheck_msginit, arena); } -UPB_INLINE envoy_api_v2_core_HealthCheck_CustomHealthCheck *envoy_api_v2_core_HealthCheck_CustomHealthCheck_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_HealthCheck_CustomHealthCheck *envoy_api_v2_core_HealthCheck_CustomHealthCheck_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_HealthCheck_CustomHealthCheck *ret = envoy_api_v2_core_HealthCheck_CustomHealthCheck_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_HealthCheck_CustomHealthCheck_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_HealthCheck_CustomHealthCheck_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_HealthCheck_CustomHealthCheck_serialize(const envoy_api_v2_core_HealthCheck_CustomHealthCheck *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_HealthCheck_CustomHealthCheck_msginit, arena, len); @@ -512,9 +549,9 @@ UPB_INLINE char *envoy_api_v2_core_HealthCheck_CustomHealthCheck_serialize(const typedef enum { envoy_api_v2_core_HealthCheck_CustomHealthCheck_config_type_config = 2, envoy_api_v2_core_HealthCheck_CustomHealthCheck_config_type_typed_config = 3, - envoy_api_v2_core_HealthCheck_CustomHealthCheck_config_type_NOT_SET = 0, + envoy_api_v2_core_HealthCheck_CustomHealthCheck_config_type_NOT_SET = 0 } envoy_api_v2_core_HealthCheck_CustomHealthCheck_config_type_oneofcases; -UPB_INLINE envoy_api_v2_core_HealthCheck_CustomHealthCheck_config_type_oneofcases envoy_api_v2_core_HealthCheck_CustomHealthCheck_config_type_case(const envoy_api_v2_core_HealthCheck_CustomHealthCheck* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(12, 24)); } +UPB_INLINE envoy_api_v2_core_HealthCheck_CustomHealthCheck_config_type_oneofcases envoy_api_v2_core_HealthCheck_CustomHealthCheck_config_type_case(const envoy_api_v2_core_HealthCheck_CustomHealthCheck* msg) { return (envoy_api_v2_core_HealthCheck_CustomHealthCheck_config_type_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(12, 24)); } UPB_INLINE upb_strview envoy_api_v2_core_HealthCheck_CustomHealthCheck_name(const envoy_api_v2_core_HealthCheck_CustomHealthCheck *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } UPB_INLINE bool envoy_api_v2_core_HealthCheck_CustomHealthCheck_has_config(const envoy_api_v2_core_HealthCheck_CustomHealthCheck *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(12, 24), 2); } @@ -550,7 +587,6 @@ UPB_INLINE struct google_protobuf_Any* envoy_api_v2_core_HealthCheck_CustomHealt return sub; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c b/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c index fa8855d20b9..896cfe25638 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +++ b/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c @@ -56,18 +56,19 @@ static const upb_msglayout *const envoy_api_v2_core_Http2ProtocolOptions_submsgs &google_protobuf_UInt32Value_msginit, }; -static const upb_msglayout_field envoy_api_v2_core_Http2ProtocolOptions__fields[5] = { +static const upb_msglayout_field envoy_api_v2_core_Http2ProtocolOptions__fields[6] = { {1, UPB_SIZE(4, 8), 0, 0, 11, 1}, {2, UPB_SIZE(8, 16), 0, 0, 11, 1}, {3, UPB_SIZE(12, 24), 0, 0, 11, 1}, {4, UPB_SIZE(16, 32), 0, 0, 11, 1}, {5, UPB_SIZE(0, 0), 0, 0, 8, 1}, + {6, UPB_SIZE(1, 1), 0, 0, 8, 1}, }; const upb_msglayout envoy_api_v2_core_Http2ProtocolOptions_msginit = { &envoy_api_v2_core_Http2ProtocolOptions_submsgs[0], &envoy_api_v2_core_Http2ProtocolOptions__fields[0], - UPB_SIZE(20, 40), 5, false, + UPB_SIZE(20, 40), 6, false, }; static const upb_msglayout *const envoy_api_v2_core_GrpcProtocolOptions_submsgs[1] = { diff --git a/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h b/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h index db352e43d87..039b221ef2a 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h @@ -10,12 +10,12 @@ #define ENVOY_API_V2_CORE_PROTOCOL_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -42,17 +42,16 @@ extern const upb_msglayout google_protobuf_BoolValue_msginit; extern const upb_msglayout google_protobuf_Duration_msginit; extern const upb_msglayout google_protobuf_UInt32Value_msginit; -/* Enums */ - /* envoy.api.v2.core.TcpProtocolOptions */ UPB_INLINE envoy_api_v2_core_TcpProtocolOptions *envoy_api_v2_core_TcpProtocolOptions_new(upb_arena *arena) { return (envoy_api_v2_core_TcpProtocolOptions *)upb_msg_new(&envoy_api_v2_core_TcpProtocolOptions_msginit, arena); } -UPB_INLINE envoy_api_v2_core_TcpProtocolOptions *envoy_api_v2_core_TcpProtocolOptions_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_TcpProtocolOptions *envoy_api_v2_core_TcpProtocolOptions_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_TcpProtocolOptions *ret = envoy_api_v2_core_TcpProtocolOptions_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_TcpProtocolOptions_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_TcpProtocolOptions_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_TcpProtocolOptions_serialize(const envoy_api_v2_core_TcpProtocolOptions *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_TcpProtocolOptions_msginit, arena, len); @@ -60,15 +59,15 @@ UPB_INLINE char *envoy_api_v2_core_TcpProtocolOptions_serialize(const envoy_api_ - /* envoy.api.v2.core.HttpProtocolOptions */ UPB_INLINE envoy_api_v2_core_HttpProtocolOptions *envoy_api_v2_core_HttpProtocolOptions_new(upb_arena *arena) { return (envoy_api_v2_core_HttpProtocolOptions *)upb_msg_new(&envoy_api_v2_core_HttpProtocolOptions_msginit, arena); } -UPB_INLINE envoy_api_v2_core_HttpProtocolOptions *envoy_api_v2_core_HttpProtocolOptions_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_HttpProtocolOptions *envoy_api_v2_core_HttpProtocolOptions_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_HttpProtocolOptions *ret = envoy_api_v2_core_HttpProtocolOptions_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_HttpProtocolOptions_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_HttpProtocolOptions_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_HttpProtocolOptions_serialize(const envoy_api_v2_core_HttpProtocolOptions *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_HttpProtocolOptions_msginit, arena, len); @@ -89,15 +88,15 @@ UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_HttpProtocolOption return sub; } - /* envoy.api.v2.core.Http1ProtocolOptions */ UPB_INLINE envoy_api_v2_core_Http1ProtocolOptions *envoy_api_v2_core_Http1ProtocolOptions_new(upb_arena *arena) { return (envoy_api_v2_core_Http1ProtocolOptions *)upb_msg_new(&envoy_api_v2_core_Http1ProtocolOptions_msginit, arena); } -UPB_INLINE envoy_api_v2_core_Http1ProtocolOptions *envoy_api_v2_core_Http1ProtocolOptions_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_Http1ProtocolOptions *envoy_api_v2_core_Http1ProtocolOptions_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_Http1ProtocolOptions *ret = envoy_api_v2_core_Http1ProtocolOptions_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_Http1ProtocolOptions_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_Http1ProtocolOptions_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_Http1ProtocolOptions_serialize(const envoy_api_v2_core_Http1ProtocolOptions *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_Http1ProtocolOptions_msginit, arena, len); @@ -126,15 +125,15 @@ UPB_INLINE void envoy_api_v2_core_Http1ProtocolOptions_set_default_host_for_http UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; } - /* envoy.api.v2.core.Http2ProtocolOptions */ UPB_INLINE envoy_api_v2_core_Http2ProtocolOptions *envoy_api_v2_core_Http2ProtocolOptions_new(upb_arena *arena) { return (envoy_api_v2_core_Http2ProtocolOptions *)upb_msg_new(&envoy_api_v2_core_Http2ProtocolOptions_msginit, arena); } -UPB_INLINE envoy_api_v2_core_Http2ProtocolOptions *envoy_api_v2_core_Http2ProtocolOptions_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_Http2ProtocolOptions *envoy_api_v2_core_Http2ProtocolOptions_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_Http2ProtocolOptions *ret = envoy_api_v2_core_Http2ProtocolOptions_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_Http2ProtocolOptions_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_Http2ProtocolOptions_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_Http2ProtocolOptions_serialize(const envoy_api_v2_core_Http2ProtocolOptions *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_Http2ProtocolOptions_msginit, arena, len); @@ -145,6 +144,7 @@ UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_core_Http2Prot UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_core_Http2ProtocolOptions_initial_stream_window_size(const envoy_api_v2_core_Http2ProtocolOptions *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(12, 24)); } UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_core_Http2ProtocolOptions_initial_connection_window_size(const envoy_api_v2_core_Http2ProtocolOptions *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(16, 32)); } UPB_INLINE bool envoy_api_v2_core_Http2ProtocolOptions_allow_connect(const envoy_api_v2_core_Http2ProtocolOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)); } +UPB_INLINE bool envoy_api_v2_core_Http2ProtocolOptions_allow_metadata(const envoy_api_v2_core_Http2ProtocolOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); } UPB_INLINE void envoy_api_v2_core_Http2ProtocolOptions_set_hpack_table_size(envoy_api_v2_core_Http2ProtocolOptions *msg, struct google_protobuf_UInt32Value* value) { UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(4, 8)) = value; @@ -197,16 +197,19 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_core_Http2ProtocolOp UPB_INLINE void envoy_api_v2_core_Http2ProtocolOptions_set_allow_connect(envoy_api_v2_core_Http2ProtocolOptions *msg, bool value) { UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)) = value; } - +UPB_INLINE void envoy_api_v2_core_Http2ProtocolOptions_set_allow_metadata(envoy_api_v2_core_Http2ProtocolOptions *msg, bool value) { + UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value; +} /* envoy.api.v2.core.GrpcProtocolOptions */ UPB_INLINE envoy_api_v2_core_GrpcProtocolOptions *envoy_api_v2_core_GrpcProtocolOptions_new(upb_arena *arena) { return (envoy_api_v2_core_GrpcProtocolOptions *)upb_msg_new(&envoy_api_v2_core_GrpcProtocolOptions_msginit, arena); } -UPB_INLINE envoy_api_v2_core_GrpcProtocolOptions *envoy_api_v2_core_GrpcProtocolOptions_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_core_GrpcProtocolOptions *envoy_api_v2_core_GrpcProtocolOptions_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_core_GrpcProtocolOptions *ret = envoy_api_v2_core_GrpcProtocolOptions_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_core_GrpcProtocolOptions_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_GrpcProtocolOptions_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_core_GrpcProtocolOptions_serialize(const envoy_api_v2_core_GrpcProtocolOptions *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_core_GrpcProtocolOptions_msginit, arena, len); @@ -227,7 +230,6 @@ UPB_INLINE struct envoy_api_v2_core_Http2ProtocolOptions* envoy_api_v2_core_Grpc return sub; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c b/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c index 2f67f55a8a3..c51a38e7c1c 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +++ b/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c @@ -36,31 +36,33 @@ const upb_msglayout envoy_api_v2_DiscoveryRequest_msginit = { UPB_SIZE(40, 80), 6, false, }; -static const upb_msglayout *const envoy_api_v2_DiscoveryResponse_submsgs[1] = { +static const upb_msglayout *const envoy_api_v2_DiscoveryResponse_submsgs[2] = { + &envoy_api_v2_core_ControlPlane_msginit, &google_protobuf_Any_msginit, }; -static const upb_msglayout_field envoy_api_v2_DiscoveryResponse__fields[5] = { +static const upb_msglayout_field envoy_api_v2_DiscoveryResponse__fields[6] = { {1, UPB_SIZE(4, 8), 0, 0, 9, 1}, - {2, UPB_SIZE(28, 56), 0, 0, 11, 3}, + {2, UPB_SIZE(32, 64), 0, 1, 11, 3}, {3, UPB_SIZE(0, 0), 0, 0, 8, 1}, {4, UPB_SIZE(12, 24), 0, 0, 9, 1}, {5, UPB_SIZE(20, 40), 0, 0, 9, 1}, + {6, UPB_SIZE(28, 56), 0, 0, 11, 1}, }; const upb_msglayout envoy_api_v2_DiscoveryResponse_msginit = { &envoy_api_v2_DiscoveryResponse_submsgs[0], &envoy_api_v2_DiscoveryResponse__fields[0], - UPB_SIZE(32, 64), 5, false, + UPB_SIZE(40, 80), 6, false, }; -static const upb_msglayout *const envoy_api_v2_IncrementalDiscoveryRequest_submsgs[3] = { - &envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry_msginit, +static const upb_msglayout *const envoy_api_v2_DeltaDiscoveryRequest_submsgs[3] = { + &envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry_msginit, &envoy_api_v2_core_Node_msginit, &google_rpc_Status_msginit, }; -static const upb_msglayout_field envoy_api_v2_IncrementalDiscoveryRequest__fields[7] = { +static const upb_msglayout_field envoy_api_v2_DeltaDiscoveryRequest__fields[7] = { {1, UPB_SIZE(16, 32), 0, 1, 11, 1}, {2, UPB_SIZE(0, 0), 0, 0, 9, 1}, {3, UPB_SIZE(24, 48), 0, 0, 9, 3}, @@ -70,53 +72,56 @@ static const upb_msglayout_field envoy_api_v2_IncrementalDiscoveryRequest__field {7, UPB_SIZE(20, 40), 0, 2, 11, 1}, }; -const upb_msglayout envoy_api_v2_IncrementalDiscoveryRequest_msginit = { - &envoy_api_v2_IncrementalDiscoveryRequest_submsgs[0], - &envoy_api_v2_IncrementalDiscoveryRequest__fields[0], +const upb_msglayout envoy_api_v2_DeltaDiscoveryRequest_msginit = { + &envoy_api_v2_DeltaDiscoveryRequest_submsgs[0], + &envoy_api_v2_DeltaDiscoveryRequest__fields[0], UPB_SIZE(40, 80), 7, false, }; -static const upb_msglayout_field envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry__fields[2] = { +static const upb_msglayout_field envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry__fields[2] = { {1, UPB_SIZE(0, 0), 0, 0, 9, 1}, {2, UPB_SIZE(8, 16), 0, 0, 9, 1}, }; -const upb_msglayout envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry_msginit = { +const upb_msglayout envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry_msginit = { NULL, - &envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry__fields[0], + &envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry__fields[0], UPB_SIZE(16, 32), 2, false, }; -static const upb_msglayout *const envoy_api_v2_IncrementalDiscoveryResponse_submsgs[1] = { +static const upb_msglayout *const envoy_api_v2_DeltaDiscoveryResponse_submsgs[1] = { &envoy_api_v2_Resource_msginit, }; -static const upb_msglayout_field envoy_api_v2_IncrementalDiscoveryResponse__fields[4] = { +static const upb_msglayout_field envoy_api_v2_DeltaDiscoveryResponse__fields[5] = { {1, UPB_SIZE(0, 0), 0, 0, 9, 1}, - {2, UPB_SIZE(16, 32), 0, 0, 11, 3}, - {5, UPB_SIZE(8, 16), 0, 0, 9, 1}, - {6, UPB_SIZE(20, 40), 0, 0, 9, 3}, + {2, UPB_SIZE(24, 48), 0, 0, 11, 3}, + {4, UPB_SIZE(8, 16), 0, 0, 9, 1}, + {5, UPB_SIZE(16, 32), 0, 0, 9, 1}, + {6, UPB_SIZE(28, 56), 0, 0, 9, 3}, }; -const upb_msglayout envoy_api_v2_IncrementalDiscoveryResponse_msginit = { - &envoy_api_v2_IncrementalDiscoveryResponse_submsgs[0], - &envoy_api_v2_IncrementalDiscoveryResponse__fields[0], - UPB_SIZE(24, 48), 4, false, +const upb_msglayout envoy_api_v2_DeltaDiscoveryResponse_msginit = { + &envoy_api_v2_DeltaDiscoveryResponse_submsgs[0], + &envoy_api_v2_DeltaDiscoveryResponse__fields[0], + UPB_SIZE(32, 64), 5, false, }; static const upb_msglayout *const envoy_api_v2_Resource_submsgs[1] = { &google_protobuf_Any_msginit, }; -static const upb_msglayout_field envoy_api_v2_Resource__fields[2] = { +static const upb_msglayout_field envoy_api_v2_Resource__fields[4] = { {1, UPB_SIZE(0, 0), 0, 0, 9, 1}, - {2, UPB_SIZE(8, 16), 0, 0, 11, 1}, + {2, UPB_SIZE(16, 32), 0, 0, 11, 1}, + {3, UPB_SIZE(8, 16), 0, 0, 9, 1}, + {4, UPB_SIZE(20, 40), 0, 0, 9, 3}, }; const upb_msglayout envoy_api_v2_Resource_msginit = { &envoy_api_v2_Resource_submsgs[0], &envoy_api_v2_Resource__fields[0], - UPB_SIZE(16, 32), 2, false, + UPB_SIZE(24, 48), 4, false, }; #include "upb/port_undef.inc" diff --git a/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h b/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h index 7044ea956bf..b2475bee1b6 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h @@ -10,52 +10,53 @@ #define ENVOY_API_V2_DISCOVERY_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif struct envoy_api_v2_DiscoveryRequest; struct envoy_api_v2_DiscoveryResponse; -struct envoy_api_v2_IncrementalDiscoveryRequest; -struct envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry; -struct envoy_api_v2_IncrementalDiscoveryResponse; +struct envoy_api_v2_DeltaDiscoveryRequest; +struct envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry; +struct envoy_api_v2_DeltaDiscoveryResponse; struct envoy_api_v2_Resource; typedef struct envoy_api_v2_DiscoveryRequest envoy_api_v2_DiscoveryRequest; typedef struct envoy_api_v2_DiscoveryResponse envoy_api_v2_DiscoveryResponse; -typedef struct envoy_api_v2_IncrementalDiscoveryRequest envoy_api_v2_IncrementalDiscoveryRequest; -typedef struct envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry; -typedef struct envoy_api_v2_IncrementalDiscoveryResponse envoy_api_v2_IncrementalDiscoveryResponse; +typedef struct envoy_api_v2_DeltaDiscoveryRequest envoy_api_v2_DeltaDiscoveryRequest; +typedef struct envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry; +typedef struct envoy_api_v2_DeltaDiscoveryResponse envoy_api_v2_DeltaDiscoveryResponse; typedef struct envoy_api_v2_Resource envoy_api_v2_Resource; extern const upb_msglayout envoy_api_v2_DiscoveryRequest_msginit; extern const upb_msglayout envoy_api_v2_DiscoveryResponse_msginit; -extern const upb_msglayout envoy_api_v2_IncrementalDiscoveryRequest_msginit; -extern const upb_msglayout envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry_msginit; -extern const upb_msglayout envoy_api_v2_IncrementalDiscoveryResponse_msginit; +extern const upb_msglayout envoy_api_v2_DeltaDiscoveryRequest_msginit; +extern const upb_msglayout envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry_msginit; +extern const upb_msglayout envoy_api_v2_DeltaDiscoveryResponse_msginit; extern const upb_msglayout envoy_api_v2_Resource_msginit; +struct envoy_api_v2_core_ControlPlane; struct envoy_api_v2_core_Node; struct google_protobuf_Any; struct google_rpc_Status; +extern const upb_msglayout envoy_api_v2_core_ControlPlane_msginit; extern const upb_msglayout envoy_api_v2_core_Node_msginit; extern const upb_msglayout google_protobuf_Any_msginit; extern const upb_msglayout google_rpc_Status_msginit; -/* Enums */ - /* envoy.api.v2.DiscoveryRequest */ UPB_INLINE envoy_api_v2_DiscoveryRequest *envoy_api_v2_DiscoveryRequest_new(upb_arena *arena) { return (envoy_api_v2_DiscoveryRequest *)upb_msg_new(&envoy_api_v2_DiscoveryRequest_msginit, arena); } -UPB_INLINE envoy_api_v2_DiscoveryRequest *envoy_api_v2_DiscoveryRequest_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_DiscoveryRequest *envoy_api_v2_DiscoveryRequest_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_DiscoveryRequest *ret = envoy_api_v2_DiscoveryRequest_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_DiscoveryRequest_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_DiscoveryRequest_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_DiscoveryRequest_serialize(const envoy_api_v2_DiscoveryRequest *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_DiscoveryRequest_msginit, arena, len); @@ -112,39 +113,40 @@ UPB_INLINE struct google_rpc_Status* envoy_api_v2_DiscoveryRequest_mutable_error return sub; } - /* envoy.api.v2.DiscoveryResponse */ UPB_INLINE envoy_api_v2_DiscoveryResponse *envoy_api_v2_DiscoveryResponse_new(upb_arena *arena) { return (envoy_api_v2_DiscoveryResponse *)upb_msg_new(&envoy_api_v2_DiscoveryResponse_msginit, arena); } -UPB_INLINE envoy_api_v2_DiscoveryResponse *envoy_api_v2_DiscoveryResponse_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_DiscoveryResponse *envoy_api_v2_DiscoveryResponse_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_DiscoveryResponse *ret = envoy_api_v2_DiscoveryResponse_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_DiscoveryResponse_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_DiscoveryResponse_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_DiscoveryResponse_serialize(const envoy_api_v2_DiscoveryResponse *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_DiscoveryResponse_msginit, arena, len); } UPB_INLINE upb_strview envoy_api_v2_DiscoveryResponse_version_info(const envoy_api_v2_DiscoveryResponse *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } -UPB_INLINE const struct google_protobuf_Any* const* envoy_api_v2_DiscoveryResponse_resources(const envoy_api_v2_DiscoveryResponse *msg, size_t *len) { return (const struct google_protobuf_Any* const*)_upb_array_accessor(msg, UPB_SIZE(28, 56), len); } +UPB_INLINE const struct google_protobuf_Any* const* envoy_api_v2_DiscoveryResponse_resources(const envoy_api_v2_DiscoveryResponse *msg, size_t *len) { return (const struct google_protobuf_Any* const*)_upb_array_accessor(msg, UPB_SIZE(32, 64), len); } UPB_INLINE bool envoy_api_v2_DiscoveryResponse_canary(const envoy_api_v2_DiscoveryResponse *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)); } UPB_INLINE upb_strview envoy_api_v2_DiscoveryResponse_type_url(const envoy_api_v2_DiscoveryResponse *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)); } UPB_INLINE upb_strview envoy_api_v2_DiscoveryResponse_nonce(const envoy_api_v2_DiscoveryResponse *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(20, 40)); } +UPB_INLINE const struct envoy_api_v2_core_ControlPlane* envoy_api_v2_DiscoveryResponse_control_plane(const envoy_api_v2_DiscoveryResponse *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_ControlPlane*, UPB_SIZE(28, 56)); } UPB_INLINE void envoy_api_v2_DiscoveryResponse_set_version_info(envoy_api_v2_DiscoveryResponse *msg, upb_strview value) { UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; } UPB_INLINE struct google_protobuf_Any** envoy_api_v2_DiscoveryResponse_mutable_resources(envoy_api_v2_DiscoveryResponse *msg, size_t *len) { - return (struct google_protobuf_Any**)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 56), len); + return (struct google_protobuf_Any**)_upb_array_mutable_accessor(msg, UPB_SIZE(32, 64), len); } UPB_INLINE struct google_protobuf_Any** envoy_api_v2_DiscoveryResponse_resize_resources(envoy_api_v2_DiscoveryResponse *msg, size_t len, upb_arena *arena) { - return (struct google_protobuf_Any**)_upb_array_resize_accessor(msg, UPB_SIZE(28, 56), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); + return (struct google_protobuf_Any**)_upb_array_resize_accessor(msg, UPB_SIZE(32, 64), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); } UPB_INLINE struct google_protobuf_Any* envoy_api_v2_DiscoveryResponse_add_resources(envoy_api_v2_DiscoveryResponse *msg, upb_arena *arena) { struct google_protobuf_Any* sub = (struct google_protobuf_Any*)upb_msg_new(&google_protobuf_Any_msginit, arena); bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(28, 56), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + msg, UPB_SIZE(32, 64), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); if (!ok) return NULL; return sub; } @@ -157,188 +159,206 @@ UPB_INLINE void envoy_api_v2_DiscoveryResponse_set_type_url(envoy_api_v2_Discove UPB_INLINE void envoy_api_v2_DiscoveryResponse_set_nonce(envoy_api_v2_DiscoveryResponse *msg, upb_strview value) { UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(20, 40)) = value; } - - -/* envoy.api.v2.IncrementalDiscoveryRequest */ - -UPB_INLINE envoy_api_v2_IncrementalDiscoveryRequest *envoy_api_v2_IncrementalDiscoveryRequest_new(upb_arena *arena) { - return (envoy_api_v2_IncrementalDiscoveryRequest *)upb_msg_new(&envoy_api_v2_IncrementalDiscoveryRequest_msginit, arena); +UPB_INLINE void envoy_api_v2_DiscoveryResponse_set_control_plane(envoy_api_v2_DiscoveryResponse *msg, struct envoy_api_v2_core_ControlPlane* value) { + UPB_FIELD_AT(msg, struct envoy_api_v2_core_ControlPlane*, UPB_SIZE(28, 56)) = value; } -UPB_INLINE envoy_api_v2_IncrementalDiscoveryRequest *envoy_api_v2_IncrementalDiscoveryRequest_parsenew(upb_strview buf, upb_arena *arena) { - envoy_api_v2_IncrementalDiscoveryRequest *ret = envoy_api_v2_IncrementalDiscoveryRequest_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_IncrementalDiscoveryRequest_msginit)) ? ret : NULL; -} -UPB_INLINE char *envoy_api_v2_IncrementalDiscoveryRequest_serialize(const envoy_api_v2_IncrementalDiscoveryRequest *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &envoy_api_v2_IncrementalDiscoveryRequest_msginit, arena, len); -} - -UPB_INLINE const struct envoy_api_v2_core_Node* envoy_api_v2_IncrementalDiscoveryRequest_node(const envoy_api_v2_IncrementalDiscoveryRequest *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Node*, UPB_SIZE(16, 32)); } -UPB_INLINE upb_strview envoy_api_v2_IncrementalDiscoveryRequest_type_url(const envoy_api_v2_IncrementalDiscoveryRequest *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } -UPB_INLINE upb_strview const* envoy_api_v2_IncrementalDiscoveryRequest_resource_names_subscribe(const envoy_api_v2_IncrementalDiscoveryRequest *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len); } -UPB_INLINE upb_strview const* envoy_api_v2_IncrementalDiscoveryRequest_resource_names_unsubscribe(const envoy_api_v2_IncrementalDiscoveryRequest *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(28, 56), len); } -UPB_INLINE const envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry* const* envoy_api_v2_IncrementalDiscoveryRequest_initial_resource_versions(const envoy_api_v2_IncrementalDiscoveryRequest *msg, size_t *len) { return (const envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry* const*)_upb_array_accessor(msg, UPB_SIZE(32, 64), len); } -UPB_INLINE upb_strview envoy_api_v2_IncrementalDiscoveryRequest_response_nonce(const envoy_api_v2_IncrementalDiscoveryRequest *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)); } -UPB_INLINE const struct google_rpc_Status* envoy_api_v2_IncrementalDiscoveryRequest_error_detail(const envoy_api_v2_IncrementalDiscoveryRequest *msg) { return UPB_FIELD_AT(msg, const struct google_rpc_Status*, UPB_SIZE(20, 40)); } - -UPB_INLINE void envoy_api_v2_IncrementalDiscoveryRequest_set_node(envoy_api_v2_IncrementalDiscoveryRequest *msg, struct envoy_api_v2_core_Node* value) { - UPB_FIELD_AT(msg, struct envoy_api_v2_core_Node*, UPB_SIZE(16, 32)) = value; -} -UPB_INLINE struct envoy_api_v2_core_Node* envoy_api_v2_IncrementalDiscoveryRequest_mutable_node(envoy_api_v2_IncrementalDiscoveryRequest *msg, upb_arena *arena) { - struct envoy_api_v2_core_Node* sub = (struct envoy_api_v2_core_Node*)envoy_api_v2_IncrementalDiscoveryRequest_node(msg); +UPB_INLINE struct envoy_api_v2_core_ControlPlane* envoy_api_v2_DiscoveryResponse_mutable_control_plane(envoy_api_v2_DiscoveryResponse *msg, upb_arena *arena) { + struct envoy_api_v2_core_ControlPlane* sub = (struct envoy_api_v2_core_ControlPlane*)envoy_api_v2_DiscoveryResponse_control_plane(msg); if (sub == NULL) { - sub = (struct envoy_api_v2_core_Node*)upb_msg_new(&envoy_api_v2_core_Node_msginit, arena); + sub = (struct envoy_api_v2_core_ControlPlane*)upb_msg_new(&envoy_api_v2_core_ControlPlane_msginit, arena); if (!sub) return NULL; - envoy_api_v2_IncrementalDiscoveryRequest_set_node(msg, sub); + envoy_api_v2_DiscoveryResponse_set_control_plane(msg, sub); } return sub; } -UPB_INLINE void envoy_api_v2_IncrementalDiscoveryRequest_set_type_url(envoy_api_v2_IncrementalDiscoveryRequest *msg, upb_strview value) { + +/* envoy.api.v2.DeltaDiscoveryRequest */ + +UPB_INLINE envoy_api_v2_DeltaDiscoveryRequest *envoy_api_v2_DeltaDiscoveryRequest_new(upb_arena *arena) { + return (envoy_api_v2_DeltaDiscoveryRequest *)upb_msg_new(&envoy_api_v2_DeltaDiscoveryRequest_msginit, arena); +} +UPB_INLINE envoy_api_v2_DeltaDiscoveryRequest *envoy_api_v2_DeltaDiscoveryRequest_parse(const char *buf, size_t size, + upb_arena *arena) { + envoy_api_v2_DeltaDiscoveryRequest *ret = envoy_api_v2_DeltaDiscoveryRequest_new(arena); + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_DeltaDiscoveryRequest_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *envoy_api_v2_DeltaDiscoveryRequest_serialize(const envoy_api_v2_DeltaDiscoveryRequest *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &envoy_api_v2_DeltaDiscoveryRequest_msginit, arena, len); +} + +UPB_INLINE const struct envoy_api_v2_core_Node* envoy_api_v2_DeltaDiscoveryRequest_node(const envoy_api_v2_DeltaDiscoveryRequest *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Node*, UPB_SIZE(16, 32)); } +UPB_INLINE upb_strview envoy_api_v2_DeltaDiscoveryRequest_type_url(const envoy_api_v2_DeltaDiscoveryRequest *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } +UPB_INLINE upb_strview const* envoy_api_v2_DeltaDiscoveryRequest_resource_names_subscribe(const envoy_api_v2_DeltaDiscoveryRequest *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len); } +UPB_INLINE upb_strview const* envoy_api_v2_DeltaDiscoveryRequest_resource_names_unsubscribe(const envoy_api_v2_DeltaDiscoveryRequest *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(28, 56), len); } +UPB_INLINE const envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry* const* envoy_api_v2_DeltaDiscoveryRequest_initial_resource_versions(const envoy_api_v2_DeltaDiscoveryRequest *msg, size_t *len) { return (const envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry* const*)_upb_array_accessor(msg, UPB_SIZE(32, 64), len); } +UPB_INLINE upb_strview envoy_api_v2_DeltaDiscoveryRequest_response_nonce(const envoy_api_v2_DeltaDiscoveryRequest *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)); } +UPB_INLINE const struct google_rpc_Status* envoy_api_v2_DeltaDiscoveryRequest_error_detail(const envoy_api_v2_DeltaDiscoveryRequest *msg) { return UPB_FIELD_AT(msg, const struct google_rpc_Status*, UPB_SIZE(20, 40)); } + +UPB_INLINE void envoy_api_v2_DeltaDiscoveryRequest_set_node(envoy_api_v2_DeltaDiscoveryRequest *msg, struct envoy_api_v2_core_Node* value) { + UPB_FIELD_AT(msg, struct envoy_api_v2_core_Node*, UPB_SIZE(16, 32)) = value; +} +UPB_INLINE struct envoy_api_v2_core_Node* envoy_api_v2_DeltaDiscoveryRequest_mutable_node(envoy_api_v2_DeltaDiscoveryRequest *msg, upb_arena *arena) { + struct envoy_api_v2_core_Node* sub = (struct envoy_api_v2_core_Node*)envoy_api_v2_DeltaDiscoveryRequest_node(msg); + if (sub == NULL) { + sub = (struct envoy_api_v2_core_Node*)upb_msg_new(&envoy_api_v2_core_Node_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_DeltaDiscoveryRequest_set_node(msg, sub); + } + return sub; +} +UPB_INLINE void envoy_api_v2_DeltaDiscoveryRequest_set_type_url(envoy_api_v2_DeltaDiscoveryRequest *msg, upb_strview value) { UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; } -UPB_INLINE upb_strview* envoy_api_v2_IncrementalDiscoveryRequest_mutable_resource_names_subscribe(envoy_api_v2_IncrementalDiscoveryRequest *msg, size_t *len) { +UPB_INLINE upb_strview* envoy_api_v2_DeltaDiscoveryRequest_mutable_resource_names_subscribe(envoy_api_v2_DeltaDiscoveryRequest *msg, size_t *len) { return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 48), len); } -UPB_INLINE upb_strview* envoy_api_v2_IncrementalDiscoveryRequest_resize_resource_names_subscribe(envoy_api_v2_IncrementalDiscoveryRequest *msg, size_t len, upb_arena *arena) { +UPB_INLINE upb_strview* envoy_api_v2_DeltaDiscoveryRequest_resize_resource_names_subscribe(envoy_api_v2_DeltaDiscoveryRequest *msg, size_t len, upb_arena *arena) { return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(24, 48), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); } -UPB_INLINE bool envoy_api_v2_IncrementalDiscoveryRequest_add_resource_names_subscribe(envoy_api_v2_IncrementalDiscoveryRequest *msg, upb_strview val, upb_arena *arena) { +UPB_INLINE bool envoy_api_v2_DeltaDiscoveryRequest_add_resource_names_subscribe(envoy_api_v2_DeltaDiscoveryRequest *msg, upb_strview val, upb_arena *arena) { return _upb_array_append_accessor( msg, UPB_SIZE(24, 48), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); } -UPB_INLINE upb_strview* envoy_api_v2_IncrementalDiscoveryRequest_mutable_resource_names_unsubscribe(envoy_api_v2_IncrementalDiscoveryRequest *msg, size_t *len) { +UPB_INLINE upb_strview* envoy_api_v2_DeltaDiscoveryRequest_mutable_resource_names_unsubscribe(envoy_api_v2_DeltaDiscoveryRequest *msg, size_t *len) { return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 56), len); } -UPB_INLINE upb_strview* envoy_api_v2_IncrementalDiscoveryRequest_resize_resource_names_unsubscribe(envoy_api_v2_IncrementalDiscoveryRequest *msg, size_t len, upb_arena *arena) { +UPB_INLINE upb_strview* envoy_api_v2_DeltaDiscoveryRequest_resize_resource_names_unsubscribe(envoy_api_v2_DeltaDiscoveryRequest *msg, size_t len, upb_arena *arena) { return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(28, 56), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); } -UPB_INLINE bool envoy_api_v2_IncrementalDiscoveryRequest_add_resource_names_unsubscribe(envoy_api_v2_IncrementalDiscoveryRequest *msg, upb_strview val, upb_arena *arena) { +UPB_INLINE bool envoy_api_v2_DeltaDiscoveryRequest_add_resource_names_unsubscribe(envoy_api_v2_DeltaDiscoveryRequest *msg, upb_strview val, upb_arena *arena) { return _upb_array_append_accessor( msg, UPB_SIZE(28, 56), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); } -UPB_INLINE envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry** envoy_api_v2_IncrementalDiscoveryRequest_mutable_initial_resource_versions(envoy_api_v2_IncrementalDiscoveryRequest *msg, size_t *len) { - return (envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry**)_upb_array_mutable_accessor(msg, UPB_SIZE(32, 64), len); +UPB_INLINE envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry** envoy_api_v2_DeltaDiscoveryRequest_mutable_initial_resource_versions(envoy_api_v2_DeltaDiscoveryRequest *msg, size_t *len) { + return (envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry**)_upb_array_mutable_accessor(msg, UPB_SIZE(32, 64), len); } -UPB_INLINE envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry** envoy_api_v2_IncrementalDiscoveryRequest_resize_initial_resource_versions(envoy_api_v2_IncrementalDiscoveryRequest *msg, size_t len, upb_arena *arena) { - return (envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry**)_upb_array_resize_accessor(msg, UPB_SIZE(32, 64), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +UPB_INLINE envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry** envoy_api_v2_DeltaDiscoveryRequest_resize_initial_resource_versions(envoy_api_v2_DeltaDiscoveryRequest *msg, size_t len, upb_arena *arena) { + return (envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry**)_upb_array_resize_accessor(msg, UPB_SIZE(32, 64), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); } -UPB_INLINE struct envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry* envoy_api_v2_IncrementalDiscoveryRequest_add_initial_resource_versions(envoy_api_v2_IncrementalDiscoveryRequest *msg, upb_arena *arena) { - struct envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry* sub = (struct envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry*)upb_msg_new(&envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry_msginit, arena); +UPB_INLINE struct envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry* envoy_api_v2_DeltaDiscoveryRequest_add_initial_resource_versions(envoy_api_v2_DeltaDiscoveryRequest *msg, upb_arena *arena) { + struct envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry* sub = (struct envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry*)upb_msg_new(&envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry_msginit, arena); bool ok = _upb_array_append_accessor( msg, UPB_SIZE(32, 64), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); if (!ok) return NULL; return sub; } -UPB_INLINE void envoy_api_v2_IncrementalDiscoveryRequest_set_response_nonce(envoy_api_v2_IncrementalDiscoveryRequest *msg, upb_strview value) { +UPB_INLINE void envoy_api_v2_DeltaDiscoveryRequest_set_response_nonce(envoy_api_v2_DeltaDiscoveryRequest *msg, upb_strview value) { UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)) = value; } -UPB_INLINE void envoy_api_v2_IncrementalDiscoveryRequest_set_error_detail(envoy_api_v2_IncrementalDiscoveryRequest *msg, struct google_rpc_Status* value) { +UPB_INLINE void envoy_api_v2_DeltaDiscoveryRequest_set_error_detail(envoy_api_v2_DeltaDiscoveryRequest *msg, struct google_rpc_Status* value) { UPB_FIELD_AT(msg, struct google_rpc_Status*, UPB_SIZE(20, 40)) = value; } -UPB_INLINE struct google_rpc_Status* envoy_api_v2_IncrementalDiscoveryRequest_mutable_error_detail(envoy_api_v2_IncrementalDiscoveryRequest *msg, upb_arena *arena) { - struct google_rpc_Status* sub = (struct google_rpc_Status*)envoy_api_v2_IncrementalDiscoveryRequest_error_detail(msg); +UPB_INLINE struct google_rpc_Status* envoy_api_v2_DeltaDiscoveryRequest_mutable_error_detail(envoy_api_v2_DeltaDiscoveryRequest *msg, upb_arena *arena) { + struct google_rpc_Status* sub = (struct google_rpc_Status*)envoy_api_v2_DeltaDiscoveryRequest_error_detail(msg); if (sub == NULL) { sub = (struct google_rpc_Status*)upb_msg_new(&google_rpc_Status_msginit, arena); if (!sub) return NULL; - envoy_api_v2_IncrementalDiscoveryRequest_set_error_detail(msg, sub); + envoy_api_v2_DeltaDiscoveryRequest_set_error_detail(msg, sub); } return sub; } +/* envoy.api.v2.DeltaDiscoveryRequest.InitialResourceVersionsEntry */ -/* envoy.api.v2.IncrementalDiscoveryRequest.InitialResourceVersionsEntry */ - -UPB_INLINE envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry *envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry_new(upb_arena *arena) { - return (envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry *)upb_msg_new(&envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry_msginit, arena); +UPB_INLINE envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry *envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry_new(upb_arena *arena) { + return (envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry *)upb_msg_new(&envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry_msginit, arena); } -UPB_INLINE envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry *envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry_parsenew(upb_strview buf, upb_arena *arena) { - envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry *ret = envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry_msginit)) ? ret : NULL; +UPB_INLINE envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry *envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry_parse(const char *buf, size_t size, + upb_arena *arena) { + envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry *ret = envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry_new(arena); + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry_msginit, arena)) ? ret : NULL; } -UPB_INLINE char *envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry_serialize(const envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry_msginit, arena, len); +UPB_INLINE char *envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry_serialize(const envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry_msginit, arena, len); } -UPB_INLINE upb_strview envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry_key(const envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } -UPB_INLINE upb_strview envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry_value(const envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)); } +UPB_INLINE upb_strview envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry_key(const envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } +UPB_INLINE upb_strview envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry_value(const envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)); } -UPB_INLINE void envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry_set_key(envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry *msg, upb_strview value) { +UPB_INLINE void envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry_set_key(envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry *msg, upb_strview value) { UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; } -UPB_INLINE void envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry_set_value(envoy_api_v2_IncrementalDiscoveryRequest_InitialResourceVersionsEntry *msg, upb_strview value) { +UPB_INLINE void envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry_set_value(envoy_api_v2_DeltaDiscoveryRequest_InitialResourceVersionsEntry *msg, upb_strview value) { UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)) = value; } +/* envoy.api.v2.DeltaDiscoveryResponse */ -/* envoy.api.v2.IncrementalDiscoveryResponse */ - -UPB_INLINE envoy_api_v2_IncrementalDiscoveryResponse *envoy_api_v2_IncrementalDiscoveryResponse_new(upb_arena *arena) { - return (envoy_api_v2_IncrementalDiscoveryResponse *)upb_msg_new(&envoy_api_v2_IncrementalDiscoveryResponse_msginit, arena); +UPB_INLINE envoy_api_v2_DeltaDiscoveryResponse *envoy_api_v2_DeltaDiscoveryResponse_new(upb_arena *arena) { + return (envoy_api_v2_DeltaDiscoveryResponse *)upb_msg_new(&envoy_api_v2_DeltaDiscoveryResponse_msginit, arena); } -UPB_INLINE envoy_api_v2_IncrementalDiscoveryResponse *envoy_api_v2_IncrementalDiscoveryResponse_parsenew(upb_strview buf, upb_arena *arena) { - envoy_api_v2_IncrementalDiscoveryResponse *ret = envoy_api_v2_IncrementalDiscoveryResponse_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_IncrementalDiscoveryResponse_msginit)) ? ret : NULL; +UPB_INLINE envoy_api_v2_DeltaDiscoveryResponse *envoy_api_v2_DeltaDiscoveryResponse_parse(const char *buf, size_t size, + upb_arena *arena) { + envoy_api_v2_DeltaDiscoveryResponse *ret = envoy_api_v2_DeltaDiscoveryResponse_new(arena); + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_DeltaDiscoveryResponse_msginit, arena)) ? ret : NULL; } -UPB_INLINE char *envoy_api_v2_IncrementalDiscoveryResponse_serialize(const envoy_api_v2_IncrementalDiscoveryResponse *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &envoy_api_v2_IncrementalDiscoveryResponse_msginit, arena, len); +UPB_INLINE char *envoy_api_v2_DeltaDiscoveryResponse_serialize(const envoy_api_v2_DeltaDiscoveryResponse *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &envoy_api_v2_DeltaDiscoveryResponse_msginit, arena, len); } -UPB_INLINE upb_strview envoy_api_v2_IncrementalDiscoveryResponse_system_version_info(const envoy_api_v2_IncrementalDiscoveryResponse *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } -UPB_INLINE const envoy_api_v2_Resource* const* envoy_api_v2_IncrementalDiscoveryResponse_resources(const envoy_api_v2_IncrementalDiscoveryResponse *msg, size_t *len) { return (const envoy_api_v2_Resource* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len); } -UPB_INLINE upb_strview envoy_api_v2_IncrementalDiscoveryResponse_nonce(const envoy_api_v2_IncrementalDiscoveryResponse *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)); } -UPB_INLINE upb_strview const* envoy_api_v2_IncrementalDiscoveryResponse_removed_resources(const envoy_api_v2_IncrementalDiscoveryResponse *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len); } +UPB_INLINE upb_strview envoy_api_v2_DeltaDiscoveryResponse_system_version_info(const envoy_api_v2_DeltaDiscoveryResponse *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } +UPB_INLINE const envoy_api_v2_Resource* const* envoy_api_v2_DeltaDiscoveryResponse_resources(const envoy_api_v2_DeltaDiscoveryResponse *msg, size_t *len) { return (const envoy_api_v2_Resource* const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len); } +UPB_INLINE upb_strview envoy_api_v2_DeltaDiscoveryResponse_type_url(const envoy_api_v2_DeltaDiscoveryResponse *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)); } +UPB_INLINE upb_strview envoy_api_v2_DeltaDiscoveryResponse_nonce(const envoy_api_v2_DeltaDiscoveryResponse *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(16, 32)); } +UPB_INLINE upb_strview const* envoy_api_v2_DeltaDiscoveryResponse_removed_resources(const envoy_api_v2_DeltaDiscoveryResponse *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(28, 56), len); } -UPB_INLINE void envoy_api_v2_IncrementalDiscoveryResponse_set_system_version_info(envoy_api_v2_IncrementalDiscoveryResponse *msg, upb_strview value) { +UPB_INLINE void envoy_api_v2_DeltaDiscoveryResponse_set_system_version_info(envoy_api_v2_DeltaDiscoveryResponse *msg, upb_strview value) { UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; } -UPB_INLINE envoy_api_v2_Resource** envoy_api_v2_IncrementalDiscoveryResponse_mutable_resources(envoy_api_v2_IncrementalDiscoveryResponse *msg, size_t *len) { - return (envoy_api_v2_Resource**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len); +UPB_INLINE envoy_api_v2_Resource** envoy_api_v2_DeltaDiscoveryResponse_mutable_resources(envoy_api_v2_DeltaDiscoveryResponse *msg, size_t *len) { + return (envoy_api_v2_Resource**)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 48), len); } -UPB_INLINE envoy_api_v2_Resource** envoy_api_v2_IncrementalDiscoveryResponse_resize_resources(envoy_api_v2_IncrementalDiscoveryResponse *msg, size_t len, upb_arena *arena) { - return (envoy_api_v2_Resource**)_upb_array_resize_accessor(msg, UPB_SIZE(16, 32), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +UPB_INLINE envoy_api_v2_Resource** envoy_api_v2_DeltaDiscoveryResponse_resize_resources(envoy_api_v2_DeltaDiscoveryResponse *msg, size_t len, upb_arena *arena) { + return (envoy_api_v2_Resource**)_upb_array_resize_accessor(msg, UPB_SIZE(24, 48), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); } -UPB_INLINE struct envoy_api_v2_Resource* envoy_api_v2_IncrementalDiscoveryResponse_add_resources(envoy_api_v2_IncrementalDiscoveryResponse *msg, upb_arena *arena) { +UPB_INLINE struct envoy_api_v2_Resource* envoy_api_v2_DeltaDiscoveryResponse_add_resources(envoy_api_v2_DeltaDiscoveryResponse *msg, upb_arena *arena) { struct envoy_api_v2_Resource* sub = (struct envoy_api_v2_Resource*)upb_msg_new(&envoy_api_v2_Resource_msginit, arena); bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(16, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + msg, UPB_SIZE(24, 48), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); if (!ok) return NULL; return sub; } -UPB_INLINE void envoy_api_v2_IncrementalDiscoveryResponse_set_nonce(envoy_api_v2_IncrementalDiscoveryResponse *msg, upb_strview value) { +UPB_INLINE void envoy_api_v2_DeltaDiscoveryResponse_set_type_url(envoy_api_v2_DeltaDiscoveryResponse *msg, upb_strview value) { UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)) = value; } -UPB_INLINE upb_strview* envoy_api_v2_IncrementalDiscoveryResponse_mutable_removed_resources(envoy_api_v2_IncrementalDiscoveryResponse *msg, size_t *len) { - return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 40), len); +UPB_INLINE void envoy_api_v2_DeltaDiscoveryResponse_set_nonce(envoy_api_v2_DeltaDiscoveryResponse *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(16, 32)) = value; } -UPB_INLINE upb_strview* envoy_api_v2_IncrementalDiscoveryResponse_resize_removed_resources(envoy_api_v2_IncrementalDiscoveryResponse *msg, size_t len, upb_arena *arena) { - return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(20, 40), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); +UPB_INLINE upb_strview* envoy_api_v2_DeltaDiscoveryResponse_mutable_removed_resources(envoy_api_v2_DeltaDiscoveryResponse *msg, size_t *len) { + return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 56), len); } -UPB_INLINE bool envoy_api_v2_IncrementalDiscoveryResponse_add_removed_resources(envoy_api_v2_IncrementalDiscoveryResponse *msg, upb_strview val, upb_arena *arena) { +UPB_INLINE upb_strview* envoy_api_v2_DeltaDiscoveryResponse_resize_removed_resources(envoy_api_v2_DeltaDiscoveryResponse *msg, size_t len, upb_arena *arena) { + return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(28, 56), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); +} +UPB_INLINE bool envoy_api_v2_DeltaDiscoveryResponse_add_removed_resources(envoy_api_v2_DeltaDiscoveryResponse *msg, upb_strview val, upb_arena *arena) { return _upb_array_append_accessor( - msg, UPB_SIZE(20, 40), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); + msg, UPB_SIZE(28, 56), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); } - /* envoy.api.v2.Resource */ UPB_INLINE envoy_api_v2_Resource *envoy_api_v2_Resource_new(upb_arena *arena) { return (envoy_api_v2_Resource *)upb_msg_new(&envoy_api_v2_Resource_msginit, arena); } -UPB_INLINE envoy_api_v2_Resource *envoy_api_v2_Resource_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_Resource *envoy_api_v2_Resource_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_Resource *ret = envoy_api_v2_Resource_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_Resource_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_Resource_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_Resource_serialize(const envoy_api_v2_Resource *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_Resource_msginit, arena, len); } UPB_INLINE upb_strview envoy_api_v2_Resource_version(const envoy_api_v2_Resource *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } -UPB_INLINE const struct google_protobuf_Any* envoy_api_v2_Resource_resource(const envoy_api_v2_Resource *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Any*, UPB_SIZE(8, 16)); } +UPB_INLINE const struct google_protobuf_Any* envoy_api_v2_Resource_resource(const envoy_api_v2_Resource *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Any*, UPB_SIZE(16, 32)); } +UPB_INLINE upb_strview envoy_api_v2_Resource_name(const envoy_api_v2_Resource *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)); } +UPB_INLINE upb_strview const* envoy_api_v2_Resource_aliases(const envoy_api_v2_Resource *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len); } UPB_INLINE void envoy_api_v2_Resource_set_version(envoy_api_v2_Resource *msg, upb_strview value) { UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; } UPB_INLINE void envoy_api_v2_Resource_set_resource(envoy_api_v2_Resource *msg, struct google_protobuf_Any* value) { - UPB_FIELD_AT(msg, struct google_protobuf_Any*, UPB_SIZE(8, 16)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_Any*, UPB_SIZE(16, 32)) = value; } UPB_INLINE struct google_protobuf_Any* envoy_api_v2_Resource_mutable_resource(envoy_api_v2_Resource *msg, upb_arena *arena) { struct google_protobuf_Any* sub = (struct google_protobuf_Any*)envoy_api_v2_Resource_resource(msg); @@ -349,7 +369,19 @@ UPB_INLINE struct google_protobuf_Any* envoy_api_v2_Resource_mutable_resource(en } return sub; } - +UPB_INLINE void envoy_api_v2_Resource_set_name(envoy_api_v2_Resource *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)) = value; +} +UPB_INLINE upb_strview* envoy_api_v2_Resource_mutable_aliases(envoy_api_v2_Resource *msg, size_t *len) { + return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 40), len); +} +UPB_INLINE upb_strview* envoy_api_v2_Resource_resize_aliases(envoy_api_v2_Resource *msg, size_t len, upb_arena *arena) { + return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(20, 40), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); +} +UPB_INLINE bool envoy_api_v2_Resource_add_aliases(envoy_api_v2_Resource *msg, upb_strview val, upb_arena *arena) { + return _upb_array_append_accessor( + msg, UPB_SIZE(20, 40), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); +} #ifdef __cplusplus } /* extern "C" */ diff --git a/src/core/ext/upb-generated/envoy/api/v2/eds.upb.c b/src/core/ext/upb-generated/envoy/api/v2/eds.upb.c index d6f074b0879..b8f5b57c140 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/eds.upb.c +++ b/src/core/ext/upb-generated/envoy/api/v2/eds.upb.c @@ -16,40 +16,60 @@ #include "validate/validate.upb.h" #include "gogoproto/gogo.upb.h" #include "google/protobuf/wrappers.upb.h" +#include "google/protobuf/duration.upb.h" #include "upb/port_def.inc" -static const upb_msglayout *const envoy_api_v2_ClusterLoadAssignment_submsgs[2] = { +static const upb_msglayout *const envoy_api_v2_ClusterLoadAssignment_submsgs[3] = { + &envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_msginit, &envoy_api_v2_ClusterLoadAssignment_Policy_msginit, &envoy_api_v2_endpoint_LocalityLbEndpoints_msginit, }; -static const upb_msglayout_field envoy_api_v2_ClusterLoadAssignment__fields[3] = { +static const upb_msglayout_field envoy_api_v2_ClusterLoadAssignment__fields[4] = { {1, UPB_SIZE(0, 0), 0, 0, 9, 1}, - {2, UPB_SIZE(12, 24), 0, 1, 11, 3}, - {4, UPB_SIZE(8, 16), 0, 0, 11, 1}, + {2, UPB_SIZE(12, 24), 0, 2, 11, 3}, + {4, UPB_SIZE(8, 16), 0, 1, 11, 1}, + {5, UPB_SIZE(16, 32), 0, 0, 11, 3}, }; const upb_msglayout envoy_api_v2_ClusterLoadAssignment_msginit = { &envoy_api_v2_ClusterLoadAssignment_submsgs[0], &envoy_api_v2_ClusterLoadAssignment__fields[0], - UPB_SIZE(16, 32), 3, false, + UPB_SIZE(24, 48), 4, false, }; -static const upb_msglayout *const envoy_api_v2_ClusterLoadAssignment_Policy_submsgs[2] = { +static const upb_msglayout *const envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_submsgs[1] = { + &envoy_api_v2_endpoint_Endpoint_msginit, +}; + +static const upb_msglayout_field envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry__fields[2] = { + {1, UPB_SIZE(0, 0), 0, 0, 9, 1}, + {2, UPB_SIZE(8, 16), 0, 0, 11, 1}, +}; + +const upb_msglayout envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_msginit = { + &envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_submsgs[0], + &envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry__fields[0], + UPB_SIZE(16, 32), 2, false, +}; + +static const upb_msglayout *const envoy_api_v2_ClusterLoadAssignment_Policy_submsgs[3] = { &envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_msginit, + &google_protobuf_Duration_msginit, &google_protobuf_UInt32Value_msginit, }; -static const upb_msglayout_field envoy_api_v2_ClusterLoadAssignment_Policy__fields[2] = { - {2, UPB_SIZE(4, 8), 0, 0, 11, 3}, - {3, UPB_SIZE(0, 0), 0, 1, 11, 1}, +static const upb_msglayout_field envoy_api_v2_ClusterLoadAssignment_Policy__fields[3] = { + {2, UPB_SIZE(8, 16), 0, 0, 11, 3}, + {3, UPB_SIZE(0, 0), 0, 2, 11, 1}, + {4, UPB_SIZE(4, 8), 0, 1, 11, 1}, }; const upb_msglayout envoy_api_v2_ClusterLoadAssignment_Policy_msginit = { &envoy_api_v2_ClusterLoadAssignment_Policy_submsgs[0], &envoy_api_v2_ClusterLoadAssignment_Policy__fields[0], - UPB_SIZE(8, 16), 2, false, + UPB_SIZE(12, 24), 3, false, }; static const upb_msglayout *const envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_submsgs[1] = { diff --git a/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h b/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h index a9b6f5f9c3d..334147090d4 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h @@ -10,43 +10,49 @@ #define ENVOY_API_V2_EDS_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif struct envoy_api_v2_ClusterLoadAssignment; +struct envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry; struct envoy_api_v2_ClusterLoadAssignment_Policy; struct envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload; typedef struct envoy_api_v2_ClusterLoadAssignment envoy_api_v2_ClusterLoadAssignment; +typedef struct envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry; typedef struct envoy_api_v2_ClusterLoadAssignment_Policy envoy_api_v2_ClusterLoadAssignment_Policy; typedef struct envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload; extern const upb_msglayout envoy_api_v2_ClusterLoadAssignment_msginit; +extern const upb_msglayout envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_msginit; extern const upb_msglayout envoy_api_v2_ClusterLoadAssignment_Policy_msginit; extern const upb_msglayout envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_msginit; +struct envoy_api_v2_endpoint_Endpoint; struct envoy_api_v2_endpoint_LocalityLbEndpoints; struct envoy_type_FractionalPercent; +struct google_protobuf_Duration; struct google_protobuf_UInt32Value; +extern const upb_msglayout envoy_api_v2_endpoint_Endpoint_msginit; extern const upb_msglayout envoy_api_v2_endpoint_LocalityLbEndpoints_msginit; extern const upb_msglayout envoy_type_FractionalPercent_msginit; +extern const upb_msglayout google_protobuf_Duration_msginit; extern const upb_msglayout google_protobuf_UInt32Value_msginit; -/* Enums */ - /* envoy.api.v2.ClusterLoadAssignment */ UPB_INLINE envoy_api_v2_ClusterLoadAssignment *envoy_api_v2_ClusterLoadAssignment_new(upb_arena *arena) { return (envoy_api_v2_ClusterLoadAssignment *)upb_msg_new(&envoy_api_v2_ClusterLoadAssignment_msginit, arena); } -UPB_INLINE envoy_api_v2_ClusterLoadAssignment *envoy_api_v2_ClusterLoadAssignment_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_ClusterLoadAssignment *envoy_api_v2_ClusterLoadAssignment_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_ClusterLoadAssignment *ret = envoy_api_v2_ClusterLoadAssignment_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_ClusterLoadAssignment_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_ClusterLoadAssignment_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_ClusterLoadAssignment_serialize(const envoy_api_v2_ClusterLoadAssignment *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_ClusterLoadAssignment_msginit, arena, len); @@ -55,6 +61,7 @@ UPB_INLINE char *envoy_api_v2_ClusterLoadAssignment_serialize(const envoy_api_v2 UPB_INLINE upb_strview envoy_api_v2_ClusterLoadAssignment_cluster_name(const envoy_api_v2_ClusterLoadAssignment *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } UPB_INLINE const struct envoy_api_v2_endpoint_LocalityLbEndpoints* const* envoy_api_v2_ClusterLoadAssignment_endpoints(const envoy_api_v2_ClusterLoadAssignment *msg, size_t *len) { return (const struct envoy_api_v2_endpoint_LocalityLbEndpoints* const*)_upb_array_accessor(msg, UPB_SIZE(12, 24), len); } UPB_INLINE const envoy_api_v2_ClusterLoadAssignment_Policy* envoy_api_v2_ClusterLoadAssignment_policy(const envoy_api_v2_ClusterLoadAssignment *msg) { return UPB_FIELD_AT(msg, const envoy_api_v2_ClusterLoadAssignment_Policy*, UPB_SIZE(8, 16)); } +UPB_INLINE const envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry* const* envoy_api_v2_ClusterLoadAssignment_named_endpoints(const envoy_api_v2_ClusterLoadAssignment *msg, size_t *len) { return (const envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len); } UPB_INLINE void envoy_api_v2_ClusterLoadAssignment_set_cluster_name(envoy_api_v2_ClusterLoadAssignment *msg, upb_strview value) { UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; @@ -84,34 +91,81 @@ UPB_INLINE struct envoy_api_v2_ClusterLoadAssignment_Policy* envoy_api_v2_Cluste } return sub; } +UPB_INLINE envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry** envoy_api_v2_ClusterLoadAssignment_mutable_named_endpoints(envoy_api_v2_ClusterLoadAssignment *msg, size_t *len) { + return (envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len); +} +UPB_INLINE envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry** envoy_api_v2_ClusterLoadAssignment_resize_named_endpoints(envoy_api_v2_ClusterLoadAssignment *msg, size_t len, upb_arena *arena) { + return (envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry**)_upb_array_resize_accessor(msg, UPB_SIZE(16, 32), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry* envoy_api_v2_ClusterLoadAssignment_add_named_endpoints(envoy_api_v2_ClusterLoadAssignment *msg, upb_arena *arena) { + struct envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry* sub = (struct envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry*)upb_msg_new(&envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(16, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} +/* envoy.api.v2.ClusterLoadAssignment.NamedEndpointsEntry */ + +UPB_INLINE envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry *envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_new(upb_arena *arena) { + return (envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry *)upb_msg_new(&envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_msginit, arena); +} +UPB_INLINE envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry *envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_parse(const char *buf, size_t size, + upb_arena *arena) { + envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry *ret = envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_new(arena); + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_serialize(const envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_msginit, arena, len); +} + +UPB_INLINE upb_strview envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_key(const envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } +UPB_INLINE const struct envoy_api_v2_endpoint_Endpoint* envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_value(const envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_endpoint_Endpoint*, UPB_SIZE(8, 16)); } + +UPB_INLINE void envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_set_key(envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE void envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_set_value(envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry *msg, struct envoy_api_v2_endpoint_Endpoint* value) { + UPB_FIELD_AT(msg, struct envoy_api_v2_endpoint_Endpoint*, UPB_SIZE(8, 16)) = value; +} +UPB_INLINE struct envoy_api_v2_endpoint_Endpoint* envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_mutable_value(envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry *msg, upb_arena *arena) { + struct envoy_api_v2_endpoint_Endpoint* sub = (struct envoy_api_v2_endpoint_Endpoint*)envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_value(msg); + if (sub == NULL) { + sub = (struct envoy_api_v2_endpoint_Endpoint*)upb_msg_new(&envoy_api_v2_endpoint_Endpoint_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_ClusterLoadAssignment_NamedEndpointsEntry_set_value(msg, sub); + } + return sub; +} /* envoy.api.v2.ClusterLoadAssignment.Policy */ UPB_INLINE envoy_api_v2_ClusterLoadAssignment_Policy *envoy_api_v2_ClusterLoadAssignment_Policy_new(upb_arena *arena) { return (envoy_api_v2_ClusterLoadAssignment_Policy *)upb_msg_new(&envoy_api_v2_ClusterLoadAssignment_Policy_msginit, arena); } -UPB_INLINE envoy_api_v2_ClusterLoadAssignment_Policy *envoy_api_v2_ClusterLoadAssignment_Policy_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_ClusterLoadAssignment_Policy *envoy_api_v2_ClusterLoadAssignment_Policy_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_ClusterLoadAssignment_Policy *ret = envoy_api_v2_ClusterLoadAssignment_Policy_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_ClusterLoadAssignment_Policy_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_ClusterLoadAssignment_Policy_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_ClusterLoadAssignment_Policy_serialize(const envoy_api_v2_ClusterLoadAssignment_Policy *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_ClusterLoadAssignment_Policy_msginit, arena, len); } -UPB_INLINE const envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload* const* envoy_api_v2_ClusterLoadAssignment_Policy_drop_overloads(const envoy_api_v2_ClusterLoadAssignment_Policy *msg, size_t *len) { return (const envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); } +UPB_INLINE const envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload* const* envoy_api_v2_ClusterLoadAssignment_Policy_drop_overloads(const envoy_api_v2_ClusterLoadAssignment_Policy *msg, size_t *len) { return (const envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload* const*)_upb_array_accessor(msg, UPB_SIZE(8, 16), len); } UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_ClusterLoadAssignment_Policy_overprovisioning_factor(const envoy_api_v2_ClusterLoadAssignment_Policy *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(0, 0)); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_ClusterLoadAssignment_Policy_endpoint_stale_after(const envoy_api_v2_ClusterLoadAssignment_Policy *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(4, 8)); } UPB_INLINE envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload** envoy_api_v2_ClusterLoadAssignment_Policy_mutable_drop_overloads(envoy_api_v2_ClusterLoadAssignment_Policy *msg, size_t *len) { - return (envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload**)_upb_array_mutable_accessor(msg, UPB_SIZE(4, 8), len); + return (envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload**)_upb_array_mutable_accessor(msg, UPB_SIZE(8, 16), len); } UPB_INLINE envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload** envoy_api_v2_ClusterLoadAssignment_Policy_resize_drop_overloads(envoy_api_v2_ClusterLoadAssignment_Policy *msg, size_t len, upb_arena *arena) { - return (envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload**)_upb_array_resize_accessor(msg, UPB_SIZE(4, 8), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); + return (envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload**)_upb_array_resize_accessor(msg, UPB_SIZE(8, 16), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); } UPB_INLINE struct envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload* envoy_api_v2_ClusterLoadAssignment_Policy_add_drop_overloads(envoy_api_v2_ClusterLoadAssignment_Policy *msg, upb_arena *arena) { struct envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload* sub = (struct envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload*)upb_msg_new(&envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_msginit, arena); bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(4, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + msg, UPB_SIZE(8, 16), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); if (!ok) return NULL; return sub; } @@ -127,16 +181,28 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_ClusterLoadAssignmen } return sub; } - +UPB_INLINE void envoy_api_v2_ClusterLoadAssignment_Policy_set_endpoint_stale_after(envoy_api_v2_ClusterLoadAssignment_Policy *msg, struct google_protobuf_Duration* value) { + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(4, 8)) = value; +} +UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_ClusterLoadAssignment_Policy_mutable_endpoint_stale_after(envoy_api_v2_ClusterLoadAssignment_Policy *msg, upb_arena *arena) { + struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_ClusterLoadAssignment_Policy_endpoint_stale_after(msg); + if (sub == NULL) { + sub = (struct google_protobuf_Duration*)upb_msg_new(&google_protobuf_Duration_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_ClusterLoadAssignment_Policy_set_endpoint_stale_after(msg, sub); + } + return sub; +} /* envoy.api.v2.ClusterLoadAssignment.Policy.DropOverload */ UPB_INLINE envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload *envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_new(upb_arena *arena) { return (envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload *)upb_msg_new(&envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_msginit, arena); } -UPB_INLINE envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload *envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload *envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload *ret = envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_serialize(const envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_msginit, arena, len); @@ -161,7 +227,6 @@ UPB_INLINE struct envoy_type_FractionalPercent* envoy_api_v2_ClusterLoadAssignme return sub; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c b/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c index 4cc9d7dd445..527096be8c9 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +++ b/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c @@ -50,36 +50,38 @@ static const upb_msglayout *const envoy_api_v2_endpoint_LbEndpoint_submsgs[3] = &google_protobuf_UInt32Value_msginit, }; -static const upb_msglayout_field envoy_api_v2_endpoint_LbEndpoint__fields[4] = { - {1, UPB_SIZE(8, 8), 0, 1, 11, 1}, +static const upb_msglayout_field envoy_api_v2_endpoint_LbEndpoint__fields[5] = { + {1, UPB_SIZE(16, 24), UPB_SIZE(-25, -41), 1, 11, 1}, {2, UPB_SIZE(0, 0), 0, 0, 14, 1}, - {3, UPB_SIZE(12, 16), 0, 0, 11, 1}, - {4, UPB_SIZE(16, 24), 0, 2, 11, 1}, + {3, UPB_SIZE(8, 8), 0, 0, 11, 1}, + {4, UPB_SIZE(12, 16), 0, 2, 11, 1}, + {5, UPB_SIZE(16, 24), UPB_SIZE(-25, -41), 0, 9, 1}, }; const upb_msglayout envoy_api_v2_endpoint_LbEndpoint_msginit = { &envoy_api_v2_endpoint_LbEndpoint_submsgs[0], &envoy_api_v2_endpoint_LbEndpoint__fields[0], - UPB_SIZE(24, 32), 4, false, + UPB_SIZE(32, 48), 5, false, }; -static const upb_msglayout *const envoy_api_v2_endpoint_LocalityLbEndpoints_submsgs[3] = { +static const upb_msglayout *const envoy_api_v2_endpoint_LocalityLbEndpoints_submsgs[4] = { &envoy_api_v2_core_Locality_msginit, &envoy_api_v2_endpoint_LbEndpoint_msginit, &google_protobuf_UInt32Value_msginit, }; -static const upb_msglayout_field envoy_api_v2_endpoint_LocalityLbEndpoints__fields[4] = { +static const upb_msglayout_field envoy_api_v2_endpoint_LocalityLbEndpoints__fields[5] = { {1, UPB_SIZE(4, 8), 0, 0, 11, 1}, - {2, UPB_SIZE(12, 24), 0, 1, 11, 3}, + {2, UPB_SIZE(16, 32), 0, 1, 11, 3}, {3, UPB_SIZE(8, 16), 0, 2, 11, 1}, {5, UPB_SIZE(0, 0), 0, 0, 13, 1}, + {6, UPB_SIZE(12, 24), 0, 2, 11, 1}, }; const upb_msglayout envoy_api_v2_endpoint_LocalityLbEndpoints_msginit = { &envoy_api_v2_endpoint_LocalityLbEndpoints_submsgs[0], &envoy_api_v2_endpoint_LocalityLbEndpoints__fields[0], - UPB_SIZE(16, 32), 4, false, + UPB_SIZE(20, 40), 5, false, }; #include "upb/port_undef.inc" diff --git a/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h b/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h index 4fd6341d3c4..2b3a9166c55 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h @@ -10,12 +10,12 @@ #define ENVOY_API_V2_ENDPOINT_ENDPOINT_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -41,17 +41,16 @@ extern const upb_msglayout envoy_api_v2_core_Locality_msginit; extern const upb_msglayout envoy_api_v2_core_Metadata_msginit; extern const upb_msglayout google_protobuf_UInt32Value_msginit; -/* Enums */ - /* envoy.api.v2.endpoint.Endpoint */ UPB_INLINE envoy_api_v2_endpoint_Endpoint *envoy_api_v2_endpoint_Endpoint_new(upb_arena *arena) { return (envoy_api_v2_endpoint_Endpoint *)upb_msg_new(&envoy_api_v2_endpoint_Endpoint_msginit, arena); } -UPB_INLINE envoy_api_v2_endpoint_Endpoint *envoy_api_v2_endpoint_Endpoint_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_endpoint_Endpoint *envoy_api_v2_endpoint_Endpoint_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_endpoint_Endpoint *ret = envoy_api_v2_endpoint_Endpoint_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_endpoint_Endpoint_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_endpoint_Endpoint_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_endpoint_Endpoint_serialize(const envoy_api_v2_endpoint_Endpoint *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_endpoint_Endpoint_msginit, arena, len); @@ -85,15 +84,15 @@ UPB_INLINE struct envoy_api_v2_endpoint_Endpoint_HealthCheckConfig* envoy_api_v2 return sub; } - /* envoy.api.v2.endpoint.Endpoint.HealthCheckConfig */ UPB_INLINE envoy_api_v2_endpoint_Endpoint_HealthCheckConfig *envoy_api_v2_endpoint_Endpoint_HealthCheckConfig_new(upb_arena *arena) { return (envoy_api_v2_endpoint_Endpoint_HealthCheckConfig *)upb_msg_new(&envoy_api_v2_endpoint_Endpoint_HealthCheckConfig_msginit, arena); } -UPB_INLINE envoy_api_v2_endpoint_Endpoint_HealthCheckConfig *envoy_api_v2_endpoint_Endpoint_HealthCheckConfig_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_endpoint_Endpoint_HealthCheckConfig *envoy_api_v2_endpoint_Endpoint_HealthCheckConfig_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_endpoint_Endpoint_HealthCheckConfig *ret = envoy_api_v2_endpoint_Endpoint_HealthCheckConfig_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_endpoint_Endpoint_HealthCheckConfig_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_endpoint_Endpoint_HealthCheckConfig_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_endpoint_Endpoint_HealthCheckConfig_serialize(const envoy_api_v2_endpoint_Endpoint_HealthCheckConfig *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_endpoint_Endpoint_HealthCheckConfig_msginit, arena, len); @@ -105,27 +104,37 @@ UPB_INLINE void envoy_api_v2_endpoint_Endpoint_HealthCheckConfig_set_port_value( UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(0, 0)) = value; } - /* envoy.api.v2.endpoint.LbEndpoint */ UPB_INLINE envoy_api_v2_endpoint_LbEndpoint *envoy_api_v2_endpoint_LbEndpoint_new(upb_arena *arena) { return (envoy_api_v2_endpoint_LbEndpoint *)upb_msg_new(&envoy_api_v2_endpoint_LbEndpoint_msginit, arena); } -UPB_INLINE envoy_api_v2_endpoint_LbEndpoint *envoy_api_v2_endpoint_LbEndpoint_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_endpoint_LbEndpoint *envoy_api_v2_endpoint_LbEndpoint_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_endpoint_LbEndpoint *ret = envoy_api_v2_endpoint_LbEndpoint_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_endpoint_LbEndpoint_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_endpoint_LbEndpoint_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_endpoint_LbEndpoint_serialize(const envoy_api_v2_endpoint_LbEndpoint *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_endpoint_LbEndpoint_msginit, arena, len); } -UPB_INLINE const envoy_api_v2_endpoint_Endpoint* envoy_api_v2_endpoint_LbEndpoint_endpoint(const envoy_api_v2_endpoint_LbEndpoint *msg) { return UPB_FIELD_AT(msg, const envoy_api_v2_endpoint_Endpoint*, UPB_SIZE(8, 8)); } +typedef enum { + envoy_api_v2_endpoint_LbEndpoint_host_identifier_endpoint = 1, + envoy_api_v2_endpoint_LbEndpoint_host_identifier_endpoint_name = 5, + envoy_api_v2_endpoint_LbEndpoint_host_identifier_NOT_SET = 0 +} envoy_api_v2_endpoint_LbEndpoint_host_identifier_oneofcases; +UPB_INLINE envoy_api_v2_endpoint_LbEndpoint_host_identifier_oneofcases envoy_api_v2_endpoint_LbEndpoint_host_identifier_case(const envoy_api_v2_endpoint_LbEndpoint* msg) { return (envoy_api_v2_endpoint_LbEndpoint_host_identifier_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(24, 40)); } + +UPB_INLINE bool envoy_api_v2_endpoint_LbEndpoint_has_endpoint(const envoy_api_v2_endpoint_LbEndpoint *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(24, 40), 1); } +UPB_INLINE const envoy_api_v2_endpoint_Endpoint* envoy_api_v2_endpoint_LbEndpoint_endpoint(const envoy_api_v2_endpoint_LbEndpoint *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_endpoint_Endpoint*, UPB_SIZE(16, 24), UPB_SIZE(24, 40), 1, NULL); } UPB_INLINE int32_t envoy_api_v2_endpoint_LbEndpoint_health_status(const envoy_api_v2_endpoint_LbEndpoint *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)); } -UPB_INLINE const struct envoy_api_v2_core_Metadata* envoy_api_v2_endpoint_LbEndpoint_metadata(const envoy_api_v2_endpoint_LbEndpoint *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Metadata*, UPB_SIZE(12, 16)); } -UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_endpoint_LbEndpoint_load_balancing_weight(const envoy_api_v2_endpoint_LbEndpoint *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(16, 24)); } +UPB_INLINE const struct envoy_api_v2_core_Metadata* envoy_api_v2_endpoint_LbEndpoint_metadata(const envoy_api_v2_endpoint_LbEndpoint *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Metadata*, UPB_SIZE(8, 8)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_endpoint_LbEndpoint_load_balancing_weight(const envoy_api_v2_endpoint_LbEndpoint *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(12, 16)); } +UPB_INLINE bool envoy_api_v2_endpoint_LbEndpoint_has_endpoint_name(const envoy_api_v2_endpoint_LbEndpoint *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(24, 40), 5); } +UPB_INLINE upb_strview envoy_api_v2_endpoint_LbEndpoint_endpoint_name(const envoy_api_v2_endpoint_LbEndpoint *msg) { return UPB_READ_ONEOF(msg, upb_strview, UPB_SIZE(16, 24), UPB_SIZE(24, 40), 5, upb_strview_make("", strlen(""))); } UPB_INLINE void envoy_api_v2_endpoint_LbEndpoint_set_endpoint(envoy_api_v2_endpoint_LbEndpoint *msg, envoy_api_v2_endpoint_Endpoint* value) { - UPB_FIELD_AT(msg, envoy_api_v2_endpoint_Endpoint*, UPB_SIZE(8, 8)) = value; + UPB_WRITE_ONEOF(msg, envoy_api_v2_endpoint_Endpoint*, UPB_SIZE(16, 24), value, UPB_SIZE(24, 40), 1); } UPB_INLINE struct envoy_api_v2_endpoint_Endpoint* envoy_api_v2_endpoint_LbEndpoint_mutable_endpoint(envoy_api_v2_endpoint_LbEndpoint *msg, upb_arena *arena) { struct envoy_api_v2_endpoint_Endpoint* sub = (struct envoy_api_v2_endpoint_Endpoint*)envoy_api_v2_endpoint_LbEndpoint_endpoint(msg); @@ -140,7 +149,7 @@ UPB_INLINE void envoy_api_v2_endpoint_LbEndpoint_set_health_status(envoy_api_v2_ UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)) = value; } UPB_INLINE void envoy_api_v2_endpoint_LbEndpoint_set_metadata(envoy_api_v2_endpoint_LbEndpoint *msg, struct envoy_api_v2_core_Metadata* value) { - UPB_FIELD_AT(msg, struct envoy_api_v2_core_Metadata*, UPB_SIZE(12, 16)) = value; + UPB_FIELD_AT(msg, struct envoy_api_v2_core_Metadata*, UPB_SIZE(8, 8)) = value; } UPB_INLINE struct envoy_api_v2_core_Metadata* envoy_api_v2_endpoint_LbEndpoint_mutable_metadata(envoy_api_v2_endpoint_LbEndpoint *msg, upb_arena *arena) { struct envoy_api_v2_core_Metadata* sub = (struct envoy_api_v2_core_Metadata*)envoy_api_v2_endpoint_LbEndpoint_metadata(msg); @@ -152,7 +161,7 @@ UPB_INLINE struct envoy_api_v2_core_Metadata* envoy_api_v2_endpoint_LbEndpoint_m return sub; } UPB_INLINE void envoy_api_v2_endpoint_LbEndpoint_set_load_balancing_weight(envoy_api_v2_endpoint_LbEndpoint *msg, struct google_protobuf_UInt32Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(16, 24)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(12, 16)) = value; } UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_endpoint_LbEndpoint_mutable_load_balancing_weight(envoy_api_v2_endpoint_LbEndpoint *msg, upb_arena *arena) { struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_endpoint_LbEndpoint_load_balancing_weight(msg); @@ -163,25 +172,29 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_endpoint_LbEndpoint_ } return sub; } - +UPB_INLINE void envoy_api_v2_endpoint_LbEndpoint_set_endpoint_name(envoy_api_v2_endpoint_LbEndpoint *msg, upb_strview value) { + UPB_WRITE_ONEOF(msg, upb_strview, UPB_SIZE(16, 24), value, UPB_SIZE(24, 40), 5); +} /* envoy.api.v2.endpoint.LocalityLbEndpoints */ UPB_INLINE envoy_api_v2_endpoint_LocalityLbEndpoints *envoy_api_v2_endpoint_LocalityLbEndpoints_new(upb_arena *arena) { return (envoy_api_v2_endpoint_LocalityLbEndpoints *)upb_msg_new(&envoy_api_v2_endpoint_LocalityLbEndpoints_msginit, arena); } -UPB_INLINE envoy_api_v2_endpoint_LocalityLbEndpoints *envoy_api_v2_endpoint_LocalityLbEndpoints_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_endpoint_LocalityLbEndpoints *envoy_api_v2_endpoint_LocalityLbEndpoints_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_endpoint_LocalityLbEndpoints *ret = envoy_api_v2_endpoint_LocalityLbEndpoints_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_endpoint_LocalityLbEndpoints_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_endpoint_LocalityLbEndpoints_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_endpoint_LocalityLbEndpoints_serialize(const envoy_api_v2_endpoint_LocalityLbEndpoints *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_endpoint_LocalityLbEndpoints_msginit, arena, len); } UPB_INLINE const struct envoy_api_v2_core_Locality* envoy_api_v2_endpoint_LocalityLbEndpoints_locality(const envoy_api_v2_endpoint_LocalityLbEndpoints *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Locality*, UPB_SIZE(4, 8)); } -UPB_INLINE const envoy_api_v2_endpoint_LbEndpoint* const* envoy_api_v2_endpoint_LocalityLbEndpoints_lb_endpoints(const envoy_api_v2_endpoint_LocalityLbEndpoints *msg, size_t *len) { return (const envoy_api_v2_endpoint_LbEndpoint* const*)_upb_array_accessor(msg, UPB_SIZE(12, 24), len); } +UPB_INLINE const envoy_api_v2_endpoint_LbEndpoint* const* envoy_api_v2_endpoint_LocalityLbEndpoints_lb_endpoints(const envoy_api_v2_endpoint_LocalityLbEndpoints *msg, size_t *len) { return (const envoy_api_v2_endpoint_LbEndpoint* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len); } UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_endpoint_LocalityLbEndpoints_load_balancing_weight(const envoy_api_v2_endpoint_LocalityLbEndpoints *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(8, 16)); } UPB_INLINE uint32_t envoy_api_v2_endpoint_LocalityLbEndpoints_priority(const envoy_api_v2_endpoint_LocalityLbEndpoints *msg) { return UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(0, 0)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_endpoint_LocalityLbEndpoints_proximity(const envoy_api_v2_endpoint_LocalityLbEndpoints *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(12, 24)); } UPB_INLINE void envoy_api_v2_endpoint_LocalityLbEndpoints_set_locality(envoy_api_v2_endpoint_LocalityLbEndpoints *msg, struct envoy_api_v2_core_Locality* value) { UPB_FIELD_AT(msg, struct envoy_api_v2_core_Locality*, UPB_SIZE(4, 8)) = value; @@ -196,15 +209,15 @@ UPB_INLINE struct envoy_api_v2_core_Locality* envoy_api_v2_endpoint_LocalityLbEn return sub; } UPB_INLINE envoy_api_v2_endpoint_LbEndpoint** envoy_api_v2_endpoint_LocalityLbEndpoints_mutable_lb_endpoints(envoy_api_v2_endpoint_LocalityLbEndpoints *msg, size_t *len) { - return (envoy_api_v2_endpoint_LbEndpoint**)_upb_array_mutable_accessor(msg, UPB_SIZE(12, 24), len); + return (envoy_api_v2_endpoint_LbEndpoint**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len); } UPB_INLINE envoy_api_v2_endpoint_LbEndpoint** envoy_api_v2_endpoint_LocalityLbEndpoints_resize_lb_endpoints(envoy_api_v2_endpoint_LocalityLbEndpoints *msg, size_t len, upb_arena *arena) { - return (envoy_api_v2_endpoint_LbEndpoint**)_upb_array_resize_accessor(msg, UPB_SIZE(12, 24), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); + return (envoy_api_v2_endpoint_LbEndpoint**)_upb_array_resize_accessor(msg, UPB_SIZE(16, 32), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); } UPB_INLINE struct envoy_api_v2_endpoint_LbEndpoint* envoy_api_v2_endpoint_LocalityLbEndpoints_add_lb_endpoints(envoy_api_v2_endpoint_LocalityLbEndpoints *msg, upb_arena *arena) { struct envoy_api_v2_endpoint_LbEndpoint* sub = (struct envoy_api_v2_endpoint_LbEndpoint*)upb_msg_new(&envoy_api_v2_endpoint_LbEndpoint_msginit, arena); bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(12, 24), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + msg, UPB_SIZE(16, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); if (!ok) return NULL; return sub; } @@ -223,7 +236,18 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_endpoint_LocalityLbE UPB_INLINE void envoy_api_v2_endpoint_LocalityLbEndpoints_set_priority(envoy_api_v2_endpoint_LocalityLbEndpoints *msg, uint32_t value) { UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(0, 0)) = value; } - +UPB_INLINE void envoy_api_v2_endpoint_LocalityLbEndpoints_set_proximity(envoy_api_v2_endpoint_LocalityLbEndpoints *msg, struct google_protobuf_UInt32Value* value) { + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(12, 24)) = value; +} +UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_endpoint_LocalityLbEndpoints_mutable_proximity(envoy_api_v2_endpoint_LocalityLbEndpoints *msg, upb_arena *arena) { + struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_endpoint_LocalityLbEndpoints_proximity(msg); + if (sub == NULL) { + sub = (struct google_protobuf_UInt32Value*)upb_msg_new(&google_protobuf_UInt32Value_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_endpoint_LocalityLbEndpoints_set_proximity(msg, sub); + } + return sub; +} #ifdef __cplusplus } /* extern "C" */ diff --git a/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c b/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c index 2af77c59efb..ad7c93f24ae 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +++ b/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c @@ -12,6 +12,7 @@ #include "envoy/api/v2/core/address.upb.h" #include "envoy/api/v2/core/base.upb.h" #include "google/protobuf/duration.upb.h" +#include "google/protobuf/struct.upb.h" #include "validate/validate.upb.h" #include "gogoproto/gogo.upb.h" @@ -23,39 +24,43 @@ static const upb_msglayout *const envoy_api_v2_endpoint_UpstreamLocalityStats_su &envoy_api_v2_endpoint_UpstreamEndpointStats_msginit, }; -static const upb_msglayout_field envoy_api_v2_endpoint_UpstreamLocalityStats__fields[7] = { - {1, UPB_SIZE(28, 32), 0, 0, 11, 1}, +static const upb_msglayout_field envoy_api_v2_endpoint_UpstreamLocalityStats__fields[8] = { + {1, UPB_SIZE(36, 40), 0, 0, 11, 1}, {2, UPB_SIZE(0, 0), 0, 0, 4, 1}, {3, UPB_SIZE(8, 8), 0, 0, 4, 1}, {4, UPB_SIZE(16, 16), 0, 0, 4, 1}, - {5, UPB_SIZE(32, 40), 0, 1, 11, 3}, - {6, UPB_SIZE(24, 24), 0, 0, 13, 1}, - {7, UPB_SIZE(36, 48), 0, 2, 11, 3}, + {5, UPB_SIZE(40, 48), 0, 1, 11, 3}, + {6, UPB_SIZE(32, 32), 0, 0, 13, 1}, + {7, UPB_SIZE(44, 56), 0, 2, 11, 3}, + {8, UPB_SIZE(24, 24), 0, 0, 4, 1}, }; const upb_msglayout envoy_api_v2_endpoint_UpstreamLocalityStats_msginit = { &envoy_api_v2_endpoint_UpstreamLocalityStats_submsgs[0], &envoy_api_v2_endpoint_UpstreamLocalityStats__fields[0], - UPB_SIZE(40, 56), 7, false, + UPB_SIZE(48, 64), 8, false, }; -static const upb_msglayout *const envoy_api_v2_endpoint_UpstreamEndpointStats_submsgs[2] = { +static const upb_msglayout *const envoy_api_v2_endpoint_UpstreamEndpointStats_submsgs[3] = { &envoy_api_v2_core_Address_msginit, &envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit, + &google_protobuf_Struct_msginit, }; -static const upb_msglayout_field envoy_api_v2_endpoint_UpstreamEndpointStats__fields[5] = { - {1, UPB_SIZE(24, 24), 0, 0, 11, 1}, +static const upb_msglayout_field envoy_api_v2_endpoint_UpstreamEndpointStats__fields[7] = { + {1, UPB_SIZE(32, 32), 0, 0, 11, 1}, {2, UPB_SIZE(0, 0), 0, 0, 4, 1}, {3, UPB_SIZE(8, 8), 0, 0, 4, 1}, {4, UPB_SIZE(16, 16), 0, 0, 4, 1}, - {5, UPB_SIZE(28, 32), 0, 1, 11, 3}, + {5, UPB_SIZE(40, 48), 0, 1, 11, 3}, + {6, UPB_SIZE(36, 40), 0, 2, 11, 1}, + {7, UPB_SIZE(24, 24), 0, 0, 4, 1}, }; const upb_msglayout envoy_api_v2_endpoint_UpstreamEndpointStats_msginit = { &envoy_api_v2_endpoint_UpstreamEndpointStats_submsgs[0], &envoy_api_v2_endpoint_UpstreamEndpointStats__fields[0], - UPB_SIZE(32, 40), 5, false, + UPB_SIZE(48, 56), 7, false, }; static const upb_msglayout_field envoy_api_v2_endpoint_EndpointLoadMetricStats__fields[3] = { @@ -76,18 +81,19 @@ static const upb_msglayout *const envoy_api_v2_endpoint_ClusterStats_submsgs[3] &google_protobuf_Duration_msginit, }; -static const upb_msglayout_field envoy_api_v2_endpoint_ClusterStats__fields[5] = { +static const upb_msglayout_field envoy_api_v2_endpoint_ClusterStats__fields[6] = { {1, UPB_SIZE(8, 8), 0, 0, 9, 1}, - {2, UPB_SIZE(20, 32), 0, 1, 11, 3}, + {2, UPB_SIZE(28, 48), 0, 1, 11, 3}, {3, UPB_SIZE(0, 0), 0, 0, 4, 1}, - {4, UPB_SIZE(16, 24), 0, 2, 11, 1}, - {5, UPB_SIZE(24, 40), 0, 0, 11, 3}, + {4, UPB_SIZE(24, 40), 0, 2, 11, 1}, + {5, UPB_SIZE(32, 56), 0, 0, 11, 3}, + {6, UPB_SIZE(16, 24), 0, 0, 9, 1}, }; const upb_msglayout envoy_api_v2_endpoint_ClusterStats_msginit = { &envoy_api_v2_endpoint_ClusterStats_submsgs[0], &envoy_api_v2_endpoint_ClusterStats__fields[0], - UPB_SIZE(32, 48), 5, false, + UPB_SIZE(40, 64), 6, false, }; static const upb_msglayout_field envoy_api_v2_endpoint_ClusterStats_DroppedRequests__fields[2] = { diff --git a/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h b/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h index 7ee2129f436..d37045d874e 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h @@ -10,12 +10,12 @@ #define ENVOY_API_V2_ENDPOINT_LOAD_REPORT_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -38,11 +38,11 @@ extern const upb_msglayout envoy_api_v2_endpoint_ClusterStats_DroppedRequests_ms struct envoy_api_v2_core_Address; struct envoy_api_v2_core_Locality; struct google_protobuf_Duration; +struct google_protobuf_Struct; extern const upb_msglayout envoy_api_v2_core_Address_msginit; extern const upb_msglayout envoy_api_v2_core_Locality_msginit; extern const upb_msglayout google_protobuf_Duration_msginit; - -/* Enums */ +extern const upb_msglayout google_protobuf_Struct_msginit; /* envoy.api.v2.endpoint.UpstreamLocalityStats */ @@ -50,24 +50,26 @@ extern const upb_msglayout google_protobuf_Duration_msginit; UPB_INLINE envoy_api_v2_endpoint_UpstreamLocalityStats *envoy_api_v2_endpoint_UpstreamLocalityStats_new(upb_arena *arena) { return (envoy_api_v2_endpoint_UpstreamLocalityStats *)upb_msg_new(&envoy_api_v2_endpoint_UpstreamLocalityStats_msginit, arena); } -UPB_INLINE envoy_api_v2_endpoint_UpstreamLocalityStats *envoy_api_v2_endpoint_UpstreamLocalityStats_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_endpoint_UpstreamLocalityStats *envoy_api_v2_endpoint_UpstreamLocalityStats_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_endpoint_UpstreamLocalityStats *ret = envoy_api_v2_endpoint_UpstreamLocalityStats_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_endpoint_UpstreamLocalityStats_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_endpoint_UpstreamLocalityStats_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_endpoint_UpstreamLocalityStats_serialize(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_endpoint_UpstreamLocalityStats_msginit, arena, len); } -UPB_INLINE const struct envoy_api_v2_core_Locality* envoy_api_v2_endpoint_UpstreamLocalityStats_locality(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Locality*, UPB_SIZE(28, 32)); } +UPB_INLINE const struct envoy_api_v2_core_Locality* envoy_api_v2_endpoint_UpstreamLocalityStats_locality(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Locality*, UPB_SIZE(36, 40)); } UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamLocalityStats_total_successful_requests(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)); } UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamLocalityStats_total_requests_in_progress(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(8, 8)); } UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamLocalityStats_total_error_requests(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(16, 16)); } -UPB_INLINE const envoy_api_v2_endpoint_EndpointLoadMetricStats* const* envoy_api_v2_endpoint_UpstreamLocalityStats_load_metric_stats(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_EndpointLoadMetricStats* const*)_upb_array_accessor(msg, UPB_SIZE(32, 40), len); } -UPB_INLINE uint32_t envoy_api_v2_endpoint_UpstreamLocalityStats_priority(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg) { return UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(24, 24)); } -UPB_INLINE const envoy_api_v2_endpoint_UpstreamEndpointStats* const* envoy_api_v2_endpoint_UpstreamLocalityStats_upstream_endpoint_stats(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_UpstreamEndpointStats* const*)_upb_array_accessor(msg, UPB_SIZE(36, 48), len); } +UPB_INLINE const envoy_api_v2_endpoint_EndpointLoadMetricStats* const* envoy_api_v2_endpoint_UpstreamLocalityStats_load_metric_stats(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_EndpointLoadMetricStats* const*)_upb_array_accessor(msg, UPB_SIZE(40, 48), len); } +UPB_INLINE uint32_t envoy_api_v2_endpoint_UpstreamLocalityStats_priority(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg) { return UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(32, 32)); } +UPB_INLINE const envoy_api_v2_endpoint_UpstreamEndpointStats* const* envoy_api_v2_endpoint_UpstreamLocalityStats_upstream_endpoint_stats(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_UpstreamEndpointStats* const*)_upb_array_accessor(msg, UPB_SIZE(44, 56), len); } +UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamLocalityStats_total_issued_requests(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(24, 24)); } UPB_INLINE void envoy_api_v2_endpoint_UpstreamLocalityStats_set_locality(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, struct envoy_api_v2_core_Locality* value) { - UPB_FIELD_AT(msg, struct envoy_api_v2_core_Locality*, UPB_SIZE(28, 32)) = value; + UPB_FIELD_AT(msg, struct envoy_api_v2_core_Locality*, UPB_SIZE(36, 40)) = value; } UPB_INLINE struct envoy_api_v2_core_Locality* envoy_api_v2_endpoint_UpstreamLocalityStats_mutable_locality(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, upb_arena *arena) { struct envoy_api_v2_core_Locality* sub = (struct envoy_api_v2_core_Locality*)envoy_api_v2_endpoint_UpstreamLocalityStats_locality(msg); @@ -88,57 +90,62 @@ UPB_INLINE void envoy_api_v2_endpoint_UpstreamLocalityStats_set_total_error_requ UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(16, 16)) = value; } UPB_INLINE envoy_api_v2_endpoint_EndpointLoadMetricStats** envoy_api_v2_endpoint_UpstreamLocalityStats_mutable_load_metric_stats(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t *len) { - return (envoy_api_v2_endpoint_EndpointLoadMetricStats**)_upb_array_mutable_accessor(msg, UPB_SIZE(32, 40), len); + return (envoy_api_v2_endpoint_EndpointLoadMetricStats**)_upb_array_mutable_accessor(msg, UPB_SIZE(40, 48), len); } UPB_INLINE envoy_api_v2_endpoint_EndpointLoadMetricStats** envoy_api_v2_endpoint_UpstreamLocalityStats_resize_load_metric_stats(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t len, upb_arena *arena) { - return (envoy_api_v2_endpoint_EndpointLoadMetricStats**)_upb_array_resize_accessor(msg, UPB_SIZE(32, 40), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); + return (envoy_api_v2_endpoint_EndpointLoadMetricStats**)_upb_array_resize_accessor(msg, UPB_SIZE(40, 48), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); } UPB_INLINE struct envoy_api_v2_endpoint_EndpointLoadMetricStats* envoy_api_v2_endpoint_UpstreamLocalityStats_add_load_metric_stats(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, upb_arena *arena) { struct envoy_api_v2_endpoint_EndpointLoadMetricStats* sub = (struct envoy_api_v2_endpoint_EndpointLoadMetricStats*)upb_msg_new(&envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit, arena); bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(32, 40), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + msg, UPB_SIZE(40, 48), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); if (!ok) return NULL; return sub; } UPB_INLINE void envoy_api_v2_endpoint_UpstreamLocalityStats_set_priority(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, uint32_t value) { - UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(24, 24)) = value; + UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(32, 32)) = value; } UPB_INLINE envoy_api_v2_endpoint_UpstreamEndpointStats** envoy_api_v2_endpoint_UpstreamLocalityStats_mutable_upstream_endpoint_stats(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t *len) { - return (envoy_api_v2_endpoint_UpstreamEndpointStats**)_upb_array_mutable_accessor(msg, UPB_SIZE(36, 48), len); + return (envoy_api_v2_endpoint_UpstreamEndpointStats**)_upb_array_mutable_accessor(msg, UPB_SIZE(44, 56), len); } UPB_INLINE envoy_api_v2_endpoint_UpstreamEndpointStats** envoy_api_v2_endpoint_UpstreamLocalityStats_resize_upstream_endpoint_stats(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t len, upb_arena *arena) { - return (envoy_api_v2_endpoint_UpstreamEndpointStats**)_upb_array_resize_accessor(msg, UPB_SIZE(36, 48), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); + return (envoy_api_v2_endpoint_UpstreamEndpointStats**)_upb_array_resize_accessor(msg, UPB_SIZE(44, 56), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); } UPB_INLINE struct envoy_api_v2_endpoint_UpstreamEndpointStats* envoy_api_v2_endpoint_UpstreamLocalityStats_add_upstream_endpoint_stats(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, upb_arena *arena) { struct envoy_api_v2_endpoint_UpstreamEndpointStats* sub = (struct envoy_api_v2_endpoint_UpstreamEndpointStats*)upb_msg_new(&envoy_api_v2_endpoint_UpstreamEndpointStats_msginit, arena); bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(36, 48), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + msg, UPB_SIZE(44, 56), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); if (!ok) return NULL; return sub; } - +UPB_INLINE void envoy_api_v2_endpoint_UpstreamLocalityStats_set_total_issued_requests(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, uint64_t value) { + UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(24, 24)) = value; +} /* envoy.api.v2.endpoint.UpstreamEndpointStats */ UPB_INLINE envoy_api_v2_endpoint_UpstreamEndpointStats *envoy_api_v2_endpoint_UpstreamEndpointStats_new(upb_arena *arena) { return (envoy_api_v2_endpoint_UpstreamEndpointStats *)upb_msg_new(&envoy_api_v2_endpoint_UpstreamEndpointStats_msginit, arena); } -UPB_INLINE envoy_api_v2_endpoint_UpstreamEndpointStats *envoy_api_v2_endpoint_UpstreamEndpointStats_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_endpoint_UpstreamEndpointStats *envoy_api_v2_endpoint_UpstreamEndpointStats_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_endpoint_UpstreamEndpointStats *ret = envoy_api_v2_endpoint_UpstreamEndpointStats_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_endpoint_UpstreamEndpointStats_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_endpoint_UpstreamEndpointStats_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_endpoint_UpstreamEndpointStats_serialize(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_endpoint_UpstreamEndpointStats_msginit, arena, len); } -UPB_INLINE const struct envoy_api_v2_core_Address* envoy_api_v2_endpoint_UpstreamEndpointStats_address(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Address*, UPB_SIZE(24, 24)); } +UPB_INLINE const struct envoy_api_v2_core_Address* envoy_api_v2_endpoint_UpstreamEndpointStats_address(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Address*, UPB_SIZE(32, 32)); } UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamEndpointStats_total_successful_requests(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)); } UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamEndpointStats_total_requests_in_progress(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(8, 8)); } UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamEndpointStats_total_error_requests(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(16, 16)); } -UPB_INLINE const envoy_api_v2_endpoint_EndpointLoadMetricStats* const* envoy_api_v2_endpoint_UpstreamEndpointStats_load_metric_stats(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_EndpointLoadMetricStats* const*)_upb_array_accessor(msg, UPB_SIZE(28, 32), len); } +UPB_INLINE const envoy_api_v2_endpoint_EndpointLoadMetricStats* const* envoy_api_v2_endpoint_UpstreamEndpointStats_load_metric_stats(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_EndpointLoadMetricStats* const*)_upb_array_accessor(msg, UPB_SIZE(40, 48), len); } +UPB_INLINE const struct google_protobuf_Struct* envoy_api_v2_endpoint_UpstreamEndpointStats_metadata(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Struct*, UPB_SIZE(36, 40)); } +UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamEndpointStats_total_issued_requests(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(24, 24)); } UPB_INLINE void envoy_api_v2_endpoint_UpstreamEndpointStats_set_address(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, struct envoy_api_v2_core_Address* value) { - UPB_FIELD_AT(msg, struct envoy_api_v2_core_Address*, UPB_SIZE(24, 24)) = value; + UPB_FIELD_AT(msg, struct envoy_api_v2_core_Address*, UPB_SIZE(32, 32)) = value; } UPB_INLINE struct envoy_api_v2_core_Address* envoy_api_v2_endpoint_UpstreamEndpointStats_mutable_address(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, upb_arena *arena) { struct envoy_api_v2_core_Address* sub = (struct envoy_api_v2_core_Address*)envoy_api_v2_endpoint_UpstreamEndpointStats_address(msg); @@ -159,28 +166,43 @@ UPB_INLINE void envoy_api_v2_endpoint_UpstreamEndpointStats_set_total_error_requ UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(16, 16)) = value; } UPB_INLINE envoy_api_v2_endpoint_EndpointLoadMetricStats** envoy_api_v2_endpoint_UpstreamEndpointStats_mutable_load_metric_stats(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, size_t *len) { - return (envoy_api_v2_endpoint_EndpointLoadMetricStats**)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 32), len); + return (envoy_api_v2_endpoint_EndpointLoadMetricStats**)_upb_array_mutable_accessor(msg, UPB_SIZE(40, 48), len); } UPB_INLINE envoy_api_v2_endpoint_EndpointLoadMetricStats** envoy_api_v2_endpoint_UpstreamEndpointStats_resize_load_metric_stats(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, size_t len, upb_arena *arena) { - return (envoy_api_v2_endpoint_EndpointLoadMetricStats**)_upb_array_resize_accessor(msg, UPB_SIZE(28, 32), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); + return (envoy_api_v2_endpoint_EndpointLoadMetricStats**)_upb_array_resize_accessor(msg, UPB_SIZE(40, 48), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); } UPB_INLINE struct envoy_api_v2_endpoint_EndpointLoadMetricStats* envoy_api_v2_endpoint_UpstreamEndpointStats_add_load_metric_stats(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, upb_arena *arena) { struct envoy_api_v2_endpoint_EndpointLoadMetricStats* sub = (struct envoy_api_v2_endpoint_EndpointLoadMetricStats*)upb_msg_new(&envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit, arena); bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(28, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + msg, UPB_SIZE(40, 48), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); if (!ok) return NULL; return sub; } - +UPB_INLINE void envoy_api_v2_endpoint_UpstreamEndpointStats_set_metadata(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, struct google_protobuf_Struct* value) { + UPB_FIELD_AT(msg, struct google_protobuf_Struct*, UPB_SIZE(36, 40)) = value; +} +UPB_INLINE struct google_protobuf_Struct* envoy_api_v2_endpoint_UpstreamEndpointStats_mutable_metadata(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, upb_arena *arena) { + struct google_protobuf_Struct* sub = (struct google_protobuf_Struct*)envoy_api_v2_endpoint_UpstreamEndpointStats_metadata(msg); + if (sub == NULL) { + sub = (struct google_protobuf_Struct*)upb_msg_new(&google_protobuf_Struct_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_endpoint_UpstreamEndpointStats_set_metadata(msg, sub); + } + return sub; +} +UPB_INLINE void envoy_api_v2_endpoint_UpstreamEndpointStats_set_total_issued_requests(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, uint64_t value) { + UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(24, 24)) = value; +} /* envoy.api.v2.endpoint.EndpointLoadMetricStats */ UPB_INLINE envoy_api_v2_endpoint_EndpointLoadMetricStats *envoy_api_v2_endpoint_EndpointLoadMetricStats_new(upb_arena *arena) { return (envoy_api_v2_endpoint_EndpointLoadMetricStats *)upb_msg_new(&envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit, arena); } -UPB_INLINE envoy_api_v2_endpoint_EndpointLoadMetricStats *envoy_api_v2_endpoint_EndpointLoadMetricStats_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_endpoint_EndpointLoadMetricStats *envoy_api_v2_endpoint_EndpointLoadMetricStats_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_endpoint_EndpointLoadMetricStats *ret = envoy_api_v2_endpoint_EndpointLoadMetricStats_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_endpoint_EndpointLoadMetricStats_serialize(const envoy_api_v2_endpoint_EndpointLoadMetricStats *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit, arena, len); @@ -200,39 +222,40 @@ UPB_INLINE void envoy_api_v2_endpoint_EndpointLoadMetricStats_set_total_metric_v UPB_FIELD_AT(msg, double, UPB_SIZE(8, 8)) = value; } - /* envoy.api.v2.endpoint.ClusterStats */ UPB_INLINE envoy_api_v2_endpoint_ClusterStats *envoy_api_v2_endpoint_ClusterStats_new(upb_arena *arena) { return (envoy_api_v2_endpoint_ClusterStats *)upb_msg_new(&envoy_api_v2_endpoint_ClusterStats_msginit, arena); } -UPB_INLINE envoy_api_v2_endpoint_ClusterStats *envoy_api_v2_endpoint_ClusterStats_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_endpoint_ClusterStats *envoy_api_v2_endpoint_ClusterStats_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_endpoint_ClusterStats *ret = envoy_api_v2_endpoint_ClusterStats_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_endpoint_ClusterStats_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_endpoint_ClusterStats_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_endpoint_ClusterStats_serialize(const envoy_api_v2_endpoint_ClusterStats *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_endpoint_ClusterStats_msginit, arena, len); } UPB_INLINE upb_strview envoy_api_v2_endpoint_ClusterStats_cluster_name(const envoy_api_v2_endpoint_ClusterStats *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)); } -UPB_INLINE const envoy_api_v2_endpoint_UpstreamLocalityStats* const* envoy_api_v2_endpoint_ClusterStats_upstream_locality_stats(const envoy_api_v2_endpoint_ClusterStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_UpstreamLocalityStats* const*)_upb_array_accessor(msg, UPB_SIZE(20, 32), len); } +UPB_INLINE const envoy_api_v2_endpoint_UpstreamLocalityStats* const* envoy_api_v2_endpoint_ClusterStats_upstream_locality_stats(const envoy_api_v2_endpoint_ClusterStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_UpstreamLocalityStats* const*)_upb_array_accessor(msg, UPB_SIZE(28, 48), len); } UPB_INLINE uint64_t envoy_api_v2_endpoint_ClusterStats_total_dropped_requests(const envoy_api_v2_endpoint_ClusterStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)); } -UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_endpoint_ClusterStats_load_report_interval(const envoy_api_v2_endpoint_ClusterStats *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(16, 24)); } -UPB_INLINE const envoy_api_v2_endpoint_ClusterStats_DroppedRequests* const* envoy_api_v2_endpoint_ClusterStats_dropped_requests(const envoy_api_v2_endpoint_ClusterStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_ClusterStats_DroppedRequests* const*)_upb_array_accessor(msg, UPB_SIZE(24, 40), len); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_endpoint_ClusterStats_load_report_interval(const envoy_api_v2_endpoint_ClusterStats *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(24, 40)); } +UPB_INLINE const envoy_api_v2_endpoint_ClusterStats_DroppedRequests* const* envoy_api_v2_endpoint_ClusterStats_dropped_requests(const envoy_api_v2_endpoint_ClusterStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_ClusterStats_DroppedRequests* const*)_upb_array_accessor(msg, UPB_SIZE(32, 56), len); } +UPB_INLINE upb_strview envoy_api_v2_endpoint_ClusterStats_cluster_service_name(const envoy_api_v2_endpoint_ClusterStats *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(16, 24)); } UPB_INLINE void envoy_api_v2_endpoint_ClusterStats_set_cluster_name(envoy_api_v2_endpoint_ClusterStats *msg, upb_strview value) { UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)) = value; } UPB_INLINE envoy_api_v2_endpoint_UpstreamLocalityStats** envoy_api_v2_endpoint_ClusterStats_mutable_upstream_locality_stats(envoy_api_v2_endpoint_ClusterStats *msg, size_t *len) { - return (envoy_api_v2_endpoint_UpstreamLocalityStats**)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 32), len); + return (envoy_api_v2_endpoint_UpstreamLocalityStats**)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 48), len); } UPB_INLINE envoy_api_v2_endpoint_UpstreamLocalityStats** envoy_api_v2_endpoint_ClusterStats_resize_upstream_locality_stats(envoy_api_v2_endpoint_ClusterStats *msg, size_t len, upb_arena *arena) { - return (envoy_api_v2_endpoint_UpstreamLocalityStats**)_upb_array_resize_accessor(msg, UPB_SIZE(20, 32), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); + return (envoy_api_v2_endpoint_UpstreamLocalityStats**)_upb_array_resize_accessor(msg, UPB_SIZE(28, 48), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); } UPB_INLINE struct envoy_api_v2_endpoint_UpstreamLocalityStats* envoy_api_v2_endpoint_ClusterStats_add_upstream_locality_stats(envoy_api_v2_endpoint_ClusterStats *msg, upb_arena *arena) { struct envoy_api_v2_endpoint_UpstreamLocalityStats* sub = (struct envoy_api_v2_endpoint_UpstreamLocalityStats*)upb_msg_new(&envoy_api_v2_endpoint_UpstreamLocalityStats_msginit, arena); bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(20, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + msg, UPB_SIZE(28, 48), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); if (!ok) return NULL; return sub; } @@ -240,7 +263,7 @@ UPB_INLINE void envoy_api_v2_endpoint_ClusterStats_set_total_dropped_requests(en UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)) = value; } UPB_INLINE void envoy_api_v2_endpoint_ClusterStats_set_load_report_interval(envoy_api_v2_endpoint_ClusterStats *msg, struct google_protobuf_Duration* value) { - UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(16, 24)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(24, 40)) = value; } UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_endpoint_ClusterStats_mutable_load_report_interval(envoy_api_v2_endpoint_ClusterStats *msg, upb_arena *arena) { struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_endpoint_ClusterStats_load_report_interval(msg); @@ -252,28 +275,31 @@ UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_endpoint_ClusterStats_m return sub; } UPB_INLINE envoy_api_v2_endpoint_ClusterStats_DroppedRequests** envoy_api_v2_endpoint_ClusterStats_mutable_dropped_requests(envoy_api_v2_endpoint_ClusterStats *msg, size_t *len) { - return (envoy_api_v2_endpoint_ClusterStats_DroppedRequests**)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 40), len); + return (envoy_api_v2_endpoint_ClusterStats_DroppedRequests**)_upb_array_mutable_accessor(msg, UPB_SIZE(32, 56), len); } UPB_INLINE envoy_api_v2_endpoint_ClusterStats_DroppedRequests** envoy_api_v2_endpoint_ClusterStats_resize_dropped_requests(envoy_api_v2_endpoint_ClusterStats *msg, size_t len, upb_arena *arena) { - return (envoy_api_v2_endpoint_ClusterStats_DroppedRequests**)_upb_array_resize_accessor(msg, UPB_SIZE(24, 40), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); + return (envoy_api_v2_endpoint_ClusterStats_DroppedRequests**)_upb_array_resize_accessor(msg, UPB_SIZE(32, 56), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); } UPB_INLINE struct envoy_api_v2_endpoint_ClusterStats_DroppedRequests* envoy_api_v2_endpoint_ClusterStats_add_dropped_requests(envoy_api_v2_endpoint_ClusterStats *msg, upb_arena *arena) { struct envoy_api_v2_endpoint_ClusterStats_DroppedRequests* sub = (struct envoy_api_v2_endpoint_ClusterStats_DroppedRequests*)upb_msg_new(&envoy_api_v2_endpoint_ClusterStats_DroppedRequests_msginit, arena); bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(24, 40), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + msg, UPB_SIZE(32, 56), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); if (!ok) return NULL; return sub; } - +UPB_INLINE void envoy_api_v2_endpoint_ClusterStats_set_cluster_service_name(envoy_api_v2_endpoint_ClusterStats *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(16, 24)) = value; +} /* envoy.api.v2.endpoint.ClusterStats.DroppedRequests */ UPB_INLINE envoy_api_v2_endpoint_ClusterStats_DroppedRequests *envoy_api_v2_endpoint_ClusterStats_DroppedRequests_new(upb_arena *arena) { return (envoy_api_v2_endpoint_ClusterStats_DroppedRequests *)upb_msg_new(&envoy_api_v2_endpoint_ClusterStats_DroppedRequests_msginit, arena); } -UPB_INLINE envoy_api_v2_endpoint_ClusterStats_DroppedRequests *envoy_api_v2_endpoint_ClusterStats_DroppedRequests_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_api_v2_endpoint_ClusterStats_DroppedRequests *envoy_api_v2_endpoint_ClusterStats_DroppedRequests_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_api_v2_endpoint_ClusterStats_DroppedRequests *ret = envoy_api_v2_endpoint_ClusterStats_DroppedRequests_new(arena); - return (ret && upb_decode(buf, ret, &envoy_api_v2_endpoint_ClusterStats_DroppedRequests_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_endpoint_ClusterStats_DroppedRequests_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_api_v2_endpoint_ClusterStats_DroppedRequests_serialize(const envoy_api_v2_endpoint_ClusterStats_DroppedRequests *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_api_v2_endpoint_ClusterStats_DroppedRequests_msginit, arena, len); @@ -289,7 +315,6 @@ UPB_INLINE void envoy_api_v2_endpoint_ClusterStats_DroppedRequests_set_dropped_c UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)) = value; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h b/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h index d5f1b90a032..05fc7302e73 100644 --- a/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h +++ b/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h @@ -10,12 +10,12 @@ #define ENVOY_SERVICE_DISCOVERY_V2_ADS_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -24,17 +24,16 @@ struct envoy_service_discovery_v2_AdsDummy; typedef struct envoy_service_discovery_v2_AdsDummy envoy_service_discovery_v2_AdsDummy; extern const upb_msglayout envoy_service_discovery_v2_AdsDummy_msginit; -/* Enums */ - /* envoy.service.discovery.v2.AdsDummy */ UPB_INLINE envoy_service_discovery_v2_AdsDummy *envoy_service_discovery_v2_AdsDummy_new(upb_arena *arena) { return (envoy_service_discovery_v2_AdsDummy *)upb_msg_new(&envoy_service_discovery_v2_AdsDummy_msginit, arena); } -UPB_INLINE envoy_service_discovery_v2_AdsDummy *envoy_service_discovery_v2_AdsDummy_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_service_discovery_v2_AdsDummy *envoy_service_discovery_v2_AdsDummy_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_service_discovery_v2_AdsDummy *ret = envoy_service_discovery_v2_AdsDummy_new(arena); - return (ret && upb_decode(buf, ret, &envoy_service_discovery_v2_AdsDummy_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_service_discovery_v2_AdsDummy_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_service_discovery_v2_AdsDummy_serialize(const envoy_service_discovery_v2_AdsDummy *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_service_discovery_v2_AdsDummy_msginit, arena, len); @@ -42,7 +41,6 @@ UPB_INLINE char *envoy_service_discovery_v2_AdsDummy_serialize(const envoy_servi - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h b/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h index 99db767a8a1..457deafdd9d 100644 --- a/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h +++ b/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h @@ -10,12 +10,12 @@ #define ENVOY_SERVICE_LOAD_STATS_V2_LRS_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -33,17 +33,16 @@ extern const upb_msglayout envoy_api_v2_core_Node_msginit; extern const upb_msglayout envoy_api_v2_endpoint_ClusterStats_msginit; extern const upb_msglayout google_protobuf_Duration_msginit; -/* Enums */ - /* envoy.service.load_stats.v2.LoadStatsRequest */ UPB_INLINE envoy_service_load_stats_v2_LoadStatsRequest *envoy_service_load_stats_v2_LoadStatsRequest_new(upb_arena *arena) { return (envoy_service_load_stats_v2_LoadStatsRequest *)upb_msg_new(&envoy_service_load_stats_v2_LoadStatsRequest_msginit, arena); } -UPB_INLINE envoy_service_load_stats_v2_LoadStatsRequest *envoy_service_load_stats_v2_LoadStatsRequest_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_service_load_stats_v2_LoadStatsRequest *envoy_service_load_stats_v2_LoadStatsRequest_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_service_load_stats_v2_LoadStatsRequest *ret = envoy_service_load_stats_v2_LoadStatsRequest_new(arena); - return (ret && upb_decode(buf, ret, &envoy_service_load_stats_v2_LoadStatsRequest_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_service_load_stats_v2_LoadStatsRequest_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_service_load_stats_v2_LoadStatsRequest_serialize(const envoy_service_load_stats_v2_LoadStatsRequest *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_service_load_stats_v2_LoadStatsRequest_msginit, arena, len); @@ -78,15 +77,15 @@ UPB_INLINE struct envoy_api_v2_endpoint_ClusterStats* envoy_service_load_stats_v return sub; } - /* envoy.service.load_stats.v2.LoadStatsResponse */ UPB_INLINE envoy_service_load_stats_v2_LoadStatsResponse *envoy_service_load_stats_v2_LoadStatsResponse_new(upb_arena *arena) { return (envoy_service_load_stats_v2_LoadStatsResponse *)upb_msg_new(&envoy_service_load_stats_v2_LoadStatsResponse_msginit, arena); } -UPB_INLINE envoy_service_load_stats_v2_LoadStatsResponse *envoy_service_load_stats_v2_LoadStatsResponse_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_service_load_stats_v2_LoadStatsResponse *envoy_service_load_stats_v2_LoadStatsResponse_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_service_load_stats_v2_LoadStatsResponse *ret = envoy_service_load_stats_v2_LoadStatsResponse_new(arena); - return (ret && upb_decode(buf, ret, &envoy_service_load_stats_v2_LoadStatsResponse_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_service_load_stats_v2_LoadStatsResponse_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_service_load_stats_v2_LoadStatsResponse_serialize(const envoy_service_load_stats_v2_LoadStatsResponse *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_service_load_stats_v2_LoadStatsResponse_msginit, arena, len); @@ -122,7 +121,6 @@ UPB_INLINE void envoy_service_load_stats_v2_LoadStatsResponse_set_report_endpoin UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)) = value; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/envoy/type/percent.upb.h b/src/core/ext/upb-generated/envoy/type/percent.upb.h index 13df96a610c..e9aa889957a 100644 --- a/src/core/ext/upb-generated/envoy/type/percent.upb.h +++ b/src/core/ext/upb-generated/envoy/type/percent.upb.h @@ -10,12 +10,12 @@ #define ENVOY_TYPE_PERCENT_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -27,8 +27,6 @@ typedef struct envoy_type_FractionalPercent envoy_type_FractionalPercent; extern const upb_msglayout envoy_type_Percent_msginit; extern const upb_msglayout envoy_type_FractionalPercent_msginit; -/* Enums */ - typedef enum { envoy_type_FractionalPercent_HUNDRED = 0, envoy_type_FractionalPercent_TEN_THOUSAND = 1, @@ -41,9 +39,10 @@ typedef enum { UPB_INLINE envoy_type_Percent *envoy_type_Percent_new(upb_arena *arena) { return (envoy_type_Percent *)upb_msg_new(&envoy_type_Percent_msginit, arena); } -UPB_INLINE envoy_type_Percent *envoy_type_Percent_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_type_Percent *envoy_type_Percent_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_type_Percent *ret = envoy_type_Percent_new(arena); - return (ret && upb_decode(buf, ret, &envoy_type_Percent_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_type_Percent_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_type_Percent_serialize(const envoy_type_Percent *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_type_Percent_msginit, arena, len); @@ -55,15 +54,15 @@ UPB_INLINE void envoy_type_Percent_set_value(envoy_type_Percent *msg, double val UPB_FIELD_AT(msg, double, UPB_SIZE(0, 0)) = value; } - /* envoy.type.FractionalPercent */ UPB_INLINE envoy_type_FractionalPercent *envoy_type_FractionalPercent_new(upb_arena *arena) { return (envoy_type_FractionalPercent *)upb_msg_new(&envoy_type_FractionalPercent_msginit, arena); } -UPB_INLINE envoy_type_FractionalPercent *envoy_type_FractionalPercent_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_type_FractionalPercent *envoy_type_FractionalPercent_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_type_FractionalPercent *ret = envoy_type_FractionalPercent_new(arena); - return (ret && upb_decode(buf, ret, &envoy_type_FractionalPercent_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_type_FractionalPercent_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_type_FractionalPercent_serialize(const envoy_type_FractionalPercent *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_type_FractionalPercent_msginit, arena, len); @@ -79,7 +78,6 @@ UPB_INLINE void envoy_type_FractionalPercent_set_denominator(envoy_type_Fraction UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)) = value; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/envoy/type/range.upb.h b/src/core/ext/upb-generated/envoy/type/range.upb.h index de1846a1300..3e607745151 100644 --- a/src/core/ext/upb-generated/envoy/type/range.upb.h +++ b/src/core/ext/upb-generated/envoy/type/range.upb.h @@ -10,12 +10,12 @@ #define ENVOY_TYPE_RANGE_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -27,17 +27,16 @@ typedef struct envoy_type_DoubleRange envoy_type_DoubleRange; extern const upb_msglayout envoy_type_Int64Range_msginit; extern const upb_msglayout envoy_type_DoubleRange_msginit; -/* Enums */ - /* envoy.type.Int64Range */ UPB_INLINE envoy_type_Int64Range *envoy_type_Int64Range_new(upb_arena *arena) { return (envoy_type_Int64Range *)upb_msg_new(&envoy_type_Int64Range_msginit, arena); } -UPB_INLINE envoy_type_Int64Range *envoy_type_Int64Range_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_type_Int64Range *envoy_type_Int64Range_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_type_Int64Range *ret = envoy_type_Int64Range_new(arena); - return (ret && upb_decode(buf, ret, &envoy_type_Int64Range_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_type_Int64Range_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_type_Int64Range_serialize(const envoy_type_Int64Range *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_type_Int64Range_msginit, arena, len); @@ -53,15 +52,15 @@ UPB_INLINE void envoy_type_Int64Range_set_end(envoy_type_Int64Range *msg, int64_ UPB_FIELD_AT(msg, int64_t, UPB_SIZE(8, 8)) = value; } - /* envoy.type.DoubleRange */ UPB_INLINE envoy_type_DoubleRange *envoy_type_DoubleRange_new(upb_arena *arena) { return (envoy_type_DoubleRange *)upb_msg_new(&envoy_type_DoubleRange_msginit, arena); } -UPB_INLINE envoy_type_DoubleRange *envoy_type_DoubleRange_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE envoy_type_DoubleRange *envoy_type_DoubleRange_parse(const char *buf, size_t size, + upb_arena *arena) { envoy_type_DoubleRange *ret = envoy_type_DoubleRange_new(arena); - return (ret && upb_decode(buf, ret, &envoy_type_DoubleRange_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &envoy_type_DoubleRange_msginit, arena)) ? ret : NULL; } UPB_INLINE char *envoy_type_DoubleRange_serialize(const envoy_type_DoubleRange *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &envoy_type_DoubleRange_msginit, arena, len); @@ -77,7 +76,6 @@ UPB_INLINE void envoy_type_DoubleRange_set_end(envoy_type_DoubleRange *msg, doub UPB_FIELD_AT(msg, double, UPB_SIZE(8, 8)) = value; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/gogoproto/gogo.upb.h b/src/core/ext/upb-generated/gogoproto/gogo.upb.h index 6b3dda647ee..530adbf32db 100644 --- a/src/core/ext/upb-generated/gogoproto/gogo.upb.h +++ b/src/core/ext/upb-generated/gogoproto/gogo.upb.h @@ -10,20 +10,17 @@ #define GOGOPROTO_GOGO_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif -/* Enums */ - - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/google/api/annotations.upb.h b/src/core/ext/upb-generated/google/api/annotations.upb.h index 5a49fffdd22..d81cd3d4446 100644 --- a/src/core/ext/upb-generated/google/api/annotations.upb.h +++ b/src/core/ext/upb-generated/google/api/annotations.upb.h @@ -10,20 +10,17 @@ #define GOOGLE_API_ANNOTATIONS_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif -/* Enums */ - - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/google/api/http.upb.h b/src/core/ext/upb-generated/google/api/http.upb.h index d8bda895b86..5e8bffea178 100644 --- a/src/core/ext/upb-generated/google/api/http.upb.h +++ b/src/core/ext/upb-generated/google/api/http.upb.h @@ -10,12 +10,12 @@ #define GOOGLE_API_HTTP_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -30,17 +30,16 @@ extern const upb_msglayout google_api_Http_msginit; extern const upb_msglayout google_api_HttpRule_msginit; extern const upb_msglayout google_api_CustomHttpPattern_msginit; -/* Enums */ - /* google.api.Http */ UPB_INLINE google_api_Http *google_api_Http_new(upb_arena *arena) { return (google_api_Http *)upb_msg_new(&google_api_Http_msginit, arena); } -UPB_INLINE google_api_Http *google_api_Http_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_api_Http *google_api_Http_parse(const char *buf, size_t size, + upb_arena *arena) { google_api_Http *ret = google_api_Http_new(arena); - return (ret && upb_decode(buf, ret, &google_api_Http_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_api_Http_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_api_Http_serialize(const google_api_Http *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_api_Http_msginit, arena, len); @@ -66,15 +65,15 @@ UPB_INLINE void google_api_Http_set_fully_decode_reserved_expansion(google_api_H UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)) = value; } - /* google.api.HttpRule */ UPB_INLINE google_api_HttpRule *google_api_HttpRule_new(upb_arena *arena) { return (google_api_HttpRule *)upb_msg_new(&google_api_HttpRule_msginit, arena); } -UPB_INLINE google_api_HttpRule *google_api_HttpRule_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_api_HttpRule *google_api_HttpRule_parse(const char *buf, size_t size, + upb_arena *arena) { google_api_HttpRule *ret = google_api_HttpRule_new(arena); - return (ret && upb_decode(buf, ret, &google_api_HttpRule_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_api_HttpRule_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_api_HttpRule_serialize(const google_api_HttpRule *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_api_HttpRule_msginit, arena, len); @@ -87,9 +86,9 @@ typedef enum { google_api_HttpRule_pattern_delete = 5, google_api_HttpRule_pattern_patch = 6, google_api_HttpRule_pattern_custom = 8, - google_api_HttpRule_pattern_NOT_SET = 0, + google_api_HttpRule_pattern_NOT_SET = 0 } google_api_HttpRule_pattern_oneofcases; -UPB_INLINE google_api_HttpRule_pattern_oneofcases google_api_HttpRule_pattern_case(const google_api_HttpRule* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(36, 72)); } +UPB_INLINE google_api_HttpRule_pattern_oneofcases google_api_HttpRule_pattern_case(const google_api_HttpRule* msg) { return (google_api_HttpRule_pattern_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(36, 72)); } UPB_INLINE upb_strview google_api_HttpRule_selector(const google_api_HttpRule *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } UPB_INLINE bool google_api_HttpRule_has_get(const google_api_HttpRule *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(36, 72), 2); } @@ -158,15 +157,15 @@ UPB_INLINE void google_api_HttpRule_set_response_body(google_api_HttpRule *msg, UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(16, 32)) = value; } - /* google.api.CustomHttpPattern */ UPB_INLINE google_api_CustomHttpPattern *google_api_CustomHttpPattern_new(upb_arena *arena) { return (google_api_CustomHttpPattern *)upb_msg_new(&google_api_CustomHttpPattern_msginit, arena); } -UPB_INLINE google_api_CustomHttpPattern *google_api_CustomHttpPattern_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_api_CustomHttpPattern *google_api_CustomHttpPattern_parse(const char *buf, size_t size, + upb_arena *arena) { google_api_CustomHttpPattern *ret = google_api_CustomHttpPattern_new(arena); - return (ret && upb_decode(buf, ret, &google_api_CustomHttpPattern_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_api_CustomHttpPattern_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_api_CustomHttpPattern_serialize(const google_api_CustomHttpPattern *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_api_CustomHttpPattern_msginit, arena, len); @@ -182,7 +181,6 @@ UPB_INLINE void google_api_CustomHttpPattern_set_path(google_api_CustomHttpPatte UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)) = value; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/google/protobuf/any.upb.h b/src/core/ext/upb-generated/google/protobuf/any.upb.h index 877e5bd606d..a591ba85d44 100644 --- a/src/core/ext/upb-generated/google/protobuf/any.upb.h +++ b/src/core/ext/upb-generated/google/protobuf/any.upb.h @@ -10,12 +10,12 @@ #define GOOGLE_PROTOBUF_ANY_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -24,17 +24,16 @@ struct google_protobuf_Any; typedef struct google_protobuf_Any google_protobuf_Any; extern const upb_msglayout google_protobuf_Any_msginit; -/* Enums */ - /* google.protobuf.Any */ UPB_INLINE google_protobuf_Any *google_protobuf_Any_new(upb_arena *arena) { return (google_protobuf_Any *)upb_msg_new(&google_protobuf_Any_msginit, arena); } -UPB_INLINE google_protobuf_Any *google_protobuf_Any_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_Any *google_protobuf_Any_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_Any *ret = google_protobuf_Any_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_Any_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_Any_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_Any_serialize(const google_protobuf_Any *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_Any_msginit, arena, len); @@ -50,7 +49,6 @@ UPB_INLINE void google_protobuf_Any_set_value(google_protobuf_Any *msg, upb_strv UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)) = value; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h b/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h index 11868b28f1f..681614910e0 100644 --- a/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +++ b/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h @@ -10,12 +10,12 @@ #define GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -102,8 +102,6 @@ extern const upb_msglayout google_protobuf_SourceCodeInfo_Location_msginit; extern const upb_msglayout google_protobuf_GeneratedCodeInfo_msginit; extern const upb_msglayout google_protobuf_GeneratedCodeInfo_Annotation_msginit; -/* Enums */ - typedef enum { google_protobuf_FieldDescriptorProto_LABEL_OPTIONAL = 1, google_protobuf_FieldDescriptorProto_LABEL_REQUIRED = 2, @@ -161,9 +159,10 @@ typedef enum { UPB_INLINE google_protobuf_FileDescriptorSet *google_protobuf_FileDescriptorSet_new(upb_arena *arena) { return (google_protobuf_FileDescriptorSet *)upb_msg_new(&google_protobuf_FileDescriptorSet_msginit, arena); } -UPB_INLINE google_protobuf_FileDescriptorSet *google_protobuf_FileDescriptorSet_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_FileDescriptorSet *google_protobuf_FileDescriptorSet_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_FileDescriptorSet *ret = google_protobuf_FileDescriptorSet_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_FileDescriptorSet_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_FileDescriptorSet_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_FileDescriptorSet_serialize(const google_protobuf_FileDescriptorSet *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_FileDescriptorSet_msginit, arena, len); @@ -185,15 +184,15 @@ UPB_INLINE struct google_protobuf_FileDescriptorProto* google_protobuf_FileDescr return sub; } - /* google.protobuf.FileDescriptorProto */ UPB_INLINE google_protobuf_FileDescriptorProto *google_protobuf_FileDescriptorProto_new(upb_arena *arena) { return (google_protobuf_FileDescriptorProto *)upb_msg_new(&google_protobuf_FileDescriptorProto_msginit, arena); } -UPB_INLINE google_protobuf_FileDescriptorProto *google_protobuf_FileDescriptorProto_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_FileDescriptorProto *google_protobuf_FileDescriptorProto_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_FileDescriptorProto *ret = google_protobuf_FileDescriptorProto_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_FileDescriptorProto_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_FileDescriptorProto_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_FileDescriptorProto_serialize(const google_protobuf_FileDescriptorProto *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_FileDescriptorProto_msginit, arena, len); @@ -338,15 +337,15 @@ UPB_INLINE void google_protobuf_FileDescriptorProto_set_syntax(google_protobuf_F UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(20, 40)) = value; } - /* google.protobuf.DescriptorProto */ UPB_INLINE google_protobuf_DescriptorProto *google_protobuf_DescriptorProto_new(upb_arena *arena) { return (google_protobuf_DescriptorProto *)upb_msg_new(&google_protobuf_DescriptorProto_msginit, arena); } -UPB_INLINE google_protobuf_DescriptorProto *google_protobuf_DescriptorProto_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_DescriptorProto *google_protobuf_DescriptorProto_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_DescriptorProto *ret = google_protobuf_DescriptorProto_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_DescriptorProto_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_DescriptorProto_serialize(const google_protobuf_DescriptorProto *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_DescriptorProto_msginit, arena, len); @@ -484,15 +483,15 @@ UPB_INLINE bool google_protobuf_DescriptorProto_add_reserved_name(google_protobu msg, UPB_SIZE(44, 88), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); } - /* google.protobuf.DescriptorProto.ExtensionRange */ UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange *google_protobuf_DescriptorProto_ExtensionRange_new(upb_arena *arena) { return (google_protobuf_DescriptorProto_ExtensionRange *)upb_msg_new(&google_protobuf_DescriptorProto_ExtensionRange_msginit, arena); } -UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange *google_protobuf_DescriptorProto_ExtensionRange_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange *google_protobuf_DescriptorProto_ExtensionRange_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_DescriptorProto_ExtensionRange *ret = google_protobuf_DescriptorProto_ExtensionRange_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_DescriptorProto_ExtensionRange_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ExtensionRange_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_DescriptorProto_ExtensionRange_serialize(const google_protobuf_DescriptorProto_ExtensionRange *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_DescriptorProto_ExtensionRange_msginit, arena, len); @@ -527,15 +526,15 @@ UPB_INLINE struct google_protobuf_ExtensionRangeOptions* google_protobuf_Descrip return sub; } - /* google.protobuf.DescriptorProto.ReservedRange */ UPB_INLINE google_protobuf_DescriptorProto_ReservedRange *google_protobuf_DescriptorProto_ReservedRange_new(upb_arena *arena) { return (google_protobuf_DescriptorProto_ReservedRange *)upb_msg_new(&google_protobuf_DescriptorProto_ReservedRange_msginit, arena); } -UPB_INLINE google_protobuf_DescriptorProto_ReservedRange *google_protobuf_DescriptorProto_ReservedRange_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_DescriptorProto_ReservedRange *google_protobuf_DescriptorProto_ReservedRange_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_DescriptorProto_ReservedRange *ret = google_protobuf_DescriptorProto_ReservedRange_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_DescriptorProto_ReservedRange_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ReservedRange_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_DescriptorProto_ReservedRange_serialize(const google_protobuf_DescriptorProto_ReservedRange *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_DescriptorProto_ReservedRange_msginit, arena, len); @@ -555,15 +554,15 @@ UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_set_end(google_pro UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; } - /* google.protobuf.ExtensionRangeOptions */ UPB_INLINE google_protobuf_ExtensionRangeOptions *google_protobuf_ExtensionRangeOptions_new(upb_arena *arena) { return (google_protobuf_ExtensionRangeOptions *)upb_msg_new(&google_protobuf_ExtensionRangeOptions_msginit, arena); } -UPB_INLINE google_protobuf_ExtensionRangeOptions *google_protobuf_ExtensionRangeOptions_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_ExtensionRangeOptions *google_protobuf_ExtensionRangeOptions_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_ExtensionRangeOptions *ret = google_protobuf_ExtensionRangeOptions_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_ExtensionRangeOptions_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_ExtensionRangeOptions_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_ExtensionRangeOptions_serialize(const google_protobuf_ExtensionRangeOptions *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_ExtensionRangeOptions_msginit, arena, len); @@ -585,15 +584,15 @@ UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_Extension return sub; } - /* google.protobuf.FieldDescriptorProto */ UPB_INLINE google_protobuf_FieldDescriptorProto *google_protobuf_FieldDescriptorProto_new(upb_arena *arena) { return (google_protobuf_FieldDescriptorProto *)upb_msg_new(&google_protobuf_FieldDescriptorProto_msginit, arena); } -UPB_INLINE google_protobuf_FieldDescriptorProto *google_protobuf_FieldDescriptorProto_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_FieldDescriptorProto *google_protobuf_FieldDescriptorProto_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_FieldDescriptorProto *ret = google_protobuf_FieldDescriptorProto_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_FieldDescriptorProto_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_FieldDescriptorProto_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_FieldDescriptorProto_serialize(const google_protobuf_FieldDescriptorProto *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_FieldDescriptorProto_msginit, arena, len); @@ -670,15 +669,15 @@ UPB_INLINE void google_protobuf_FieldDescriptorProto_set_json_name(google_protob UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(64, 96)) = value; } - /* google.protobuf.OneofDescriptorProto */ UPB_INLINE google_protobuf_OneofDescriptorProto *google_protobuf_OneofDescriptorProto_new(upb_arena *arena) { return (google_protobuf_OneofDescriptorProto *)upb_msg_new(&google_protobuf_OneofDescriptorProto_msginit, arena); } -UPB_INLINE google_protobuf_OneofDescriptorProto *google_protobuf_OneofDescriptorProto_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_OneofDescriptorProto *google_protobuf_OneofDescriptorProto_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_OneofDescriptorProto *ret = google_protobuf_OneofDescriptorProto_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_OneofDescriptorProto_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_OneofDescriptorProto_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_OneofDescriptorProto_serialize(const google_protobuf_OneofDescriptorProto *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_OneofDescriptorProto_msginit, arena, len); @@ -707,15 +706,15 @@ UPB_INLINE struct google_protobuf_OneofOptions* google_protobuf_OneofDescriptorP return sub; } - /* google.protobuf.EnumDescriptorProto */ UPB_INLINE google_protobuf_EnumDescriptorProto *google_protobuf_EnumDescriptorProto_new(upb_arena *arena) { return (google_protobuf_EnumDescriptorProto *)upb_msg_new(&google_protobuf_EnumDescriptorProto_msginit, arena); } -UPB_INLINE google_protobuf_EnumDescriptorProto *google_protobuf_EnumDescriptorProto_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_EnumDescriptorProto *google_protobuf_EnumDescriptorProto_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_EnumDescriptorProto *ret = google_protobuf_EnumDescriptorProto_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_EnumDescriptorProto_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_EnumDescriptorProto_serialize(const google_protobuf_EnumDescriptorProto *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_EnumDescriptorProto_msginit, arena, len); @@ -783,15 +782,15 @@ UPB_INLINE bool google_protobuf_EnumDescriptorProto_add_reserved_name(google_pro msg, UPB_SIZE(24, 48), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); } - /* google.protobuf.EnumDescriptorProto.EnumReservedRange */ UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange *google_protobuf_EnumDescriptorProto_EnumReservedRange_new(upb_arena *arena) { return (google_protobuf_EnumDescriptorProto_EnumReservedRange *)upb_msg_new(&google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena); } -UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange *google_protobuf_EnumDescriptorProto_EnumReservedRange_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange *google_protobuf_EnumDescriptorProto_EnumReservedRange_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_EnumDescriptorProto_EnumReservedRange *ret = google_protobuf_EnumDescriptorProto_EnumReservedRange_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_EnumDescriptorProto_EnumReservedRange_serialize(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena, len); @@ -811,15 +810,15 @@ UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_set_end(go UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; } - /* google.protobuf.EnumValueDescriptorProto */ UPB_INLINE google_protobuf_EnumValueDescriptorProto *google_protobuf_EnumValueDescriptorProto_new(upb_arena *arena) { return (google_protobuf_EnumValueDescriptorProto *)upb_msg_new(&google_protobuf_EnumValueDescriptorProto_msginit, arena); } -UPB_INLINE google_protobuf_EnumValueDescriptorProto *google_protobuf_EnumValueDescriptorProto_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_EnumValueDescriptorProto *google_protobuf_EnumValueDescriptorProto_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_EnumValueDescriptorProto *ret = google_protobuf_EnumValueDescriptorProto_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_EnumValueDescriptorProto_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumValueDescriptorProto_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_EnumValueDescriptorProto_serialize(const google_protobuf_EnumValueDescriptorProto *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_EnumValueDescriptorProto_msginit, arena, len); @@ -854,15 +853,15 @@ UPB_INLINE struct google_protobuf_EnumValueOptions* google_protobuf_EnumValueDes return sub; } - /* google.protobuf.ServiceDescriptorProto */ UPB_INLINE google_protobuf_ServiceDescriptorProto *google_protobuf_ServiceDescriptorProto_new(upb_arena *arena) { return (google_protobuf_ServiceDescriptorProto *)upb_msg_new(&google_protobuf_ServiceDescriptorProto_msginit, arena); } -UPB_INLINE google_protobuf_ServiceDescriptorProto *google_protobuf_ServiceDescriptorProto_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_ServiceDescriptorProto *google_protobuf_ServiceDescriptorProto_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_ServiceDescriptorProto *ret = google_protobuf_ServiceDescriptorProto_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_ServiceDescriptorProto_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_ServiceDescriptorProto_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_ServiceDescriptorProto_serialize(const google_protobuf_ServiceDescriptorProto *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_ServiceDescriptorProto_msginit, arena, len); @@ -905,15 +904,15 @@ UPB_INLINE struct google_protobuf_ServiceOptions* google_protobuf_ServiceDescrip return sub; } - /* google.protobuf.MethodDescriptorProto */ UPB_INLINE google_protobuf_MethodDescriptorProto *google_protobuf_MethodDescriptorProto_new(upb_arena *arena) { return (google_protobuf_MethodDescriptorProto *)upb_msg_new(&google_protobuf_MethodDescriptorProto_msginit, arena); } -UPB_INLINE google_protobuf_MethodDescriptorProto *google_protobuf_MethodDescriptorProto_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_MethodDescriptorProto *google_protobuf_MethodDescriptorProto_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_MethodDescriptorProto *ret = google_protobuf_MethodDescriptorProto_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_MethodDescriptorProto_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_MethodDescriptorProto_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_MethodDescriptorProto_serialize(const google_protobuf_MethodDescriptorProto *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_MethodDescriptorProto_msginit, arena, len); @@ -966,15 +965,15 @@ UPB_INLINE void google_protobuf_MethodDescriptorProto_set_server_streaming(googl UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)) = value; } - /* google.protobuf.FileOptions */ UPB_INLINE google_protobuf_FileOptions *google_protobuf_FileOptions_new(upb_arena *arena) { return (google_protobuf_FileOptions *)upb_msg_new(&google_protobuf_FileOptions_msginit, arena); } -UPB_INLINE google_protobuf_FileOptions *google_protobuf_FileOptions_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_FileOptions *google_protobuf_FileOptions_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_FileOptions *ret = google_protobuf_FileOptions_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_FileOptions_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_FileOptions_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_FileOptions_serialize(const google_protobuf_FileOptions *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_FileOptions_msginit, arena, len); @@ -1116,15 +1115,15 @@ UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_FileOptio return sub; } - /* google.protobuf.MessageOptions */ UPB_INLINE google_protobuf_MessageOptions *google_protobuf_MessageOptions_new(upb_arena *arena) { return (google_protobuf_MessageOptions *)upb_msg_new(&google_protobuf_MessageOptions_msginit, arena); } -UPB_INLINE google_protobuf_MessageOptions *google_protobuf_MessageOptions_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_MessageOptions *google_protobuf_MessageOptions_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_MessageOptions *ret = google_protobuf_MessageOptions_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_MessageOptions_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_MessageOptions_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_MessageOptions_serialize(const google_protobuf_MessageOptions *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_MessageOptions_msginit, arena, len); @@ -1170,15 +1169,15 @@ UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_MessageOp return sub; } - /* google.protobuf.FieldOptions */ UPB_INLINE google_protobuf_FieldOptions *google_protobuf_FieldOptions_new(upb_arena *arena) { return (google_protobuf_FieldOptions *)upb_msg_new(&google_protobuf_FieldOptions_msginit, arena); } -UPB_INLINE google_protobuf_FieldOptions *google_protobuf_FieldOptions_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_FieldOptions *google_protobuf_FieldOptions_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_FieldOptions *ret = google_protobuf_FieldOptions_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_FieldOptions_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_FieldOptions_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_FieldOptions_serialize(const google_protobuf_FieldOptions *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_FieldOptions_msginit, arena, len); @@ -1236,15 +1235,15 @@ UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_FieldOpti return sub; } - /* google.protobuf.OneofOptions */ UPB_INLINE google_protobuf_OneofOptions *google_protobuf_OneofOptions_new(upb_arena *arena) { return (google_protobuf_OneofOptions *)upb_msg_new(&google_protobuf_OneofOptions_msginit, arena); } -UPB_INLINE google_protobuf_OneofOptions *google_protobuf_OneofOptions_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_OneofOptions *google_protobuf_OneofOptions_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_OneofOptions *ret = google_protobuf_OneofOptions_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_OneofOptions_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_OneofOptions_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_OneofOptions_serialize(const google_protobuf_OneofOptions *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_OneofOptions_msginit, arena, len); @@ -1266,15 +1265,15 @@ UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_OneofOpti return sub; } - /* google.protobuf.EnumOptions */ UPB_INLINE google_protobuf_EnumOptions *google_protobuf_EnumOptions_new(upb_arena *arena) { return (google_protobuf_EnumOptions *)upb_msg_new(&google_protobuf_EnumOptions_msginit, arena); } -UPB_INLINE google_protobuf_EnumOptions *google_protobuf_EnumOptions_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_EnumOptions *google_protobuf_EnumOptions_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_EnumOptions *ret = google_protobuf_EnumOptions_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_EnumOptions_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumOptions_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_EnumOptions_serialize(const google_protobuf_EnumOptions *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_EnumOptions_msginit, arena, len); @@ -1308,15 +1307,15 @@ UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_EnumOptio return sub; } - /* google.protobuf.EnumValueOptions */ UPB_INLINE google_protobuf_EnumValueOptions *google_protobuf_EnumValueOptions_new(upb_arena *arena) { return (google_protobuf_EnumValueOptions *)upb_msg_new(&google_protobuf_EnumValueOptions_msginit, arena); } -UPB_INLINE google_protobuf_EnumValueOptions *google_protobuf_EnumValueOptions_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_EnumValueOptions *google_protobuf_EnumValueOptions_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_EnumValueOptions *ret = google_protobuf_EnumValueOptions_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_EnumValueOptions_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumValueOptions_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_EnumValueOptions_serialize(const google_protobuf_EnumValueOptions *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_EnumValueOptions_msginit, arena, len); @@ -1344,15 +1343,15 @@ UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_EnumValue return sub; } - /* google.protobuf.ServiceOptions */ UPB_INLINE google_protobuf_ServiceOptions *google_protobuf_ServiceOptions_new(upb_arena *arena) { return (google_protobuf_ServiceOptions *)upb_msg_new(&google_protobuf_ServiceOptions_msginit, arena); } -UPB_INLINE google_protobuf_ServiceOptions *google_protobuf_ServiceOptions_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_ServiceOptions *google_protobuf_ServiceOptions_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_ServiceOptions *ret = google_protobuf_ServiceOptions_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_ServiceOptions_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_ServiceOptions_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_ServiceOptions_serialize(const google_protobuf_ServiceOptions *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_ServiceOptions_msginit, arena, len); @@ -1380,15 +1379,15 @@ UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_ServiceOp return sub; } - /* google.protobuf.MethodOptions */ UPB_INLINE google_protobuf_MethodOptions *google_protobuf_MethodOptions_new(upb_arena *arena) { return (google_protobuf_MethodOptions *)upb_msg_new(&google_protobuf_MethodOptions_msginit, arena); } -UPB_INLINE google_protobuf_MethodOptions *google_protobuf_MethodOptions_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_MethodOptions *google_protobuf_MethodOptions_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_MethodOptions *ret = google_protobuf_MethodOptions_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_MethodOptions_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_MethodOptions_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_MethodOptions_serialize(const google_protobuf_MethodOptions *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_MethodOptions_msginit, arena, len); @@ -1422,15 +1421,15 @@ UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_MethodOpt return sub; } - /* google.protobuf.UninterpretedOption */ UPB_INLINE google_protobuf_UninterpretedOption *google_protobuf_UninterpretedOption_new(upb_arena *arena) { return (google_protobuf_UninterpretedOption *)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); } -UPB_INLINE google_protobuf_UninterpretedOption *google_protobuf_UninterpretedOption_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_UninterpretedOption *google_protobuf_UninterpretedOption_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_UninterpretedOption *ret = google_protobuf_UninterpretedOption_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_UninterpretedOption_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_UninterpretedOption_serialize(const google_protobuf_UninterpretedOption *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_UninterpretedOption_msginit, arena, len); @@ -1488,15 +1487,15 @@ UPB_INLINE void google_protobuf_UninterpretedOption_set_aggregate_value(google_p UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(48, 64)) = value; } - /* google.protobuf.UninterpretedOption.NamePart */ UPB_INLINE google_protobuf_UninterpretedOption_NamePart *google_protobuf_UninterpretedOption_NamePart_new(upb_arena *arena) { return (google_protobuf_UninterpretedOption_NamePart *)upb_msg_new(&google_protobuf_UninterpretedOption_NamePart_msginit, arena); } -UPB_INLINE google_protobuf_UninterpretedOption_NamePart *google_protobuf_UninterpretedOption_NamePart_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_UninterpretedOption_NamePart *google_protobuf_UninterpretedOption_NamePart_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_UninterpretedOption_NamePart *ret = google_protobuf_UninterpretedOption_NamePart_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_UninterpretedOption_NamePart_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_NamePart_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_UninterpretedOption_NamePart_serialize(const google_protobuf_UninterpretedOption_NamePart *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_UninterpretedOption_NamePart_msginit, arena, len); @@ -1516,15 +1515,15 @@ UPB_INLINE void google_protobuf_UninterpretedOption_NamePart_set_is_extension(go UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value; } - /* google.protobuf.SourceCodeInfo */ UPB_INLINE google_protobuf_SourceCodeInfo *google_protobuf_SourceCodeInfo_new(upb_arena *arena) { return (google_protobuf_SourceCodeInfo *)upb_msg_new(&google_protobuf_SourceCodeInfo_msginit, arena); } -UPB_INLINE google_protobuf_SourceCodeInfo *google_protobuf_SourceCodeInfo_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_SourceCodeInfo *google_protobuf_SourceCodeInfo_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_SourceCodeInfo *ret = google_protobuf_SourceCodeInfo_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_SourceCodeInfo_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_SourceCodeInfo_serialize(const google_protobuf_SourceCodeInfo *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_SourceCodeInfo_msginit, arena, len); @@ -1546,15 +1545,15 @@ UPB_INLINE struct google_protobuf_SourceCodeInfo_Location* google_protobuf_Sourc return sub; } - /* google.protobuf.SourceCodeInfo.Location */ UPB_INLINE google_protobuf_SourceCodeInfo_Location *google_protobuf_SourceCodeInfo_Location_new(upb_arena *arena) { return (google_protobuf_SourceCodeInfo_Location *)upb_msg_new(&google_protobuf_SourceCodeInfo_Location_msginit, arena); } -UPB_INLINE google_protobuf_SourceCodeInfo_Location *google_protobuf_SourceCodeInfo_Location_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_SourceCodeInfo_Location *google_protobuf_SourceCodeInfo_Location_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_SourceCodeInfo_Location *ret = google_protobuf_SourceCodeInfo_Location_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_SourceCodeInfo_Location_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_Location_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_SourceCodeInfo_Location_serialize(const google_protobuf_SourceCodeInfo_Location *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_SourceCodeInfo_Location_msginit, arena, len); @@ -1607,15 +1606,15 @@ UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_leading_detached_com msg, UPB_SIZE(28, 56), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); } - /* google.protobuf.GeneratedCodeInfo */ UPB_INLINE google_protobuf_GeneratedCodeInfo *google_protobuf_GeneratedCodeInfo_new(upb_arena *arena) { return (google_protobuf_GeneratedCodeInfo *)upb_msg_new(&google_protobuf_GeneratedCodeInfo_msginit, arena); } -UPB_INLINE google_protobuf_GeneratedCodeInfo *google_protobuf_GeneratedCodeInfo_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_GeneratedCodeInfo *google_protobuf_GeneratedCodeInfo_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_GeneratedCodeInfo *ret = google_protobuf_GeneratedCodeInfo_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_GeneratedCodeInfo_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_GeneratedCodeInfo_serialize(const google_protobuf_GeneratedCodeInfo *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_GeneratedCodeInfo_msginit, arena, len); @@ -1637,15 +1636,15 @@ UPB_INLINE struct google_protobuf_GeneratedCodeInfo_Annotation* google_protobuf_ return sub; } - /* google.protobuf.GeneratedCodeInfo.Annotation */ UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation *google_protobuf_GeneratedCodeInfo_Annotation_new(upb_arena *arena) { return (google_protobuf_GeneratedCodeInfo_Annotation *)upb_msg_new(&google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena); } -UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation *google_protobuf_GeneratedCodeInfo_Annotation_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation *google_protobuf_GeneratedCodeInfo_Annotation_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_GeneratedCodeInfo_Annotation *ret = google_protobuf_GeneratedCodeInfo_Annotation_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_GeneratedCodeInfo_Annotation_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_GeneratedCodeInfo_Annotation_serialize(const google_protobuf_GeneratedCodeInfo_Annotation *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena, len); @@ -1682,7 +1681,6 @@ UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_end(google_prot UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/google/protobuf/duration.upb.h b/src/core/ext/upb-generated/google/protobuf/duration.upb.h index bb116dcc89a..f4b35811daf 100644 --- a/src/core/ext/upb-generated/google/protobuf/duration.upb.h +++ b/src/core/ext/upb-generated/google/protobuf/duration.upb.h @@ -10,12 +10,12 @@ #define GOOGLE_PROTOBUF_DURATION_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -24,17 +24,16 @@ struct google_protobuf_Duration; typedef struct google_protobuf_Duration google_protobuf_Duration; extern const upb_msglayout google_protobuf_Duration_msginit; -/* Enums */ - /* google.protobuf.Duration */ UPB_INLINE google_protobuf_Duration *google_protobuf_Duration_new(upb_arena *arena) { return (google_protobuf_Duration *)upb_msg_new(&google_protobuf_Duration_msginit, arena); } -UPB_INLINE google_protobuf_Duration *google_protobuf_Duration_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_Duration *google_protobuf_Duration_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_Duration *ret = google_protobuf_Duration_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_Duration_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_Duration_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_Duration_serialize(const google_protobuf_Duration *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_Duration_msginit, arena, len); @@ -50,7 +49,6 @@ UPB_INLINE void google_protobuf_Duration_set_nanos(google_protobuf_Duration *msg UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/google/protobuf/empty.upb.h b/src/core/ext/upb-generated/google/protobuf/empty.upb.h index 43b2edd8cc0..6232ecf6374 100644 --- a/src/core/ext/upb-generated/google/protobuf/empty.upb.h +++ b/src/core/ext/upb-generated/google/protobuf/empty.upb.h @@ -10,12 +10,12 @@ #define GOOGLE_PROTOBUF_EMPTY_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -24,17 +24,16 @@ struct google_protobuf_Empty; typedef struct google_protobuf_Empty google_protobuf_Empty; extern const upb_msglayout google_protobuf_Empty_msginit; -/* Enums */ - /* google.protobuf.Empty */ UPB_INLINE google_protobuf_Empty *google_protobuf_Empty_new(upb_arena *arena) { return (google_protobuf_Empty *)upb_msg_new(&google_protobuf_Empty_msginit, arena); } -UPB_INLINE google_protobuf_Empty *google_protobuf_Empty_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_Empty *google_protobuf_Empty_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_Empty *ret = google_protobuf_Empty_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_Empty_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_Empty_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_Empty_serialize(const google_protobuf_Empty *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_Empty_msginit, arena, len); @@ -42,7 +41,6 @@ UPB_INLINE char *google_protobuf_Empty_serialize(const google_protobuf_Empty *ms - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/google/protobuf/struct.upb.h b/src/core/ext/upb-generated/google/protobuf/struct.upb.h index da5da203457..8d036b57663 100644 --- a/src/core/ext/upb-generated/google/protobuf/struct.upb.h +++ b/src/core/ext/upb-generated/google/protobuf/struct.upb.h @@ -10,12 +10,12 @@ #define GOOGLE_PROTOBUF_STRUCT_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -33,8 +33,6 @@ extern const upb_msglayout google_protobuf_Struct_FieldsEntry_msginit; extern const upb_msglayout google_protobuf_Value_msginit; extern const upb_msglayout google_protobuf_ListValue_msginit; -/* Enums */ - typedef enum { google_protobuf_NULL_VALUE = 0 } google_protobuf_NullValue; @@ -45,9 +43,10 @@ typedef enum { UPB_INLINE google_protobuf_Struct *google_protobuf_Struct_new(upb_arena *arena) { return (google_protobuf_Struct *)upb_msg_new(&google_protobuf_Struct_msginit, arena); } -UPB_INLINE google_protobuf_Struct *google_protobuf_Struct_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_Struct *google_protobuf_Struct_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_Struct *ret = google_protobuf_Struct_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_Struct_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_Struct_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_Struct_serialize(const google_protobuf_Struct *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_Struct_msginit, arena, len); @@ -69,15 +68,15 @@ UPB_INLINE struct google_protobuf_Struct_FieldsEntry* google_protobuf_Struct_add return sub; } - /* google.protobuf.Struct.FieldsEntry */ UPB_INLINE google_protobuf_Struct_FieldsEntry *google_protobuf_Struct_FieldsEntry_new(upb_arena *arena) { return (google_protobuf_Struct_FieldsEntry *)upb_msg_new(&google_protobuf_Struct_FieldsEntry_msginit, arena); } -UPB_INLINE google_protobuf_Struct_FieldsEntry *google_protobuf_Struct_FieldsEntry_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_Struct_FieldsEntry *google_protobuf_Struct_FieldsEntry_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_Struct_FieldsEntry *ret = google_protobuf_Struct_FieldsEntry_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_Struct_FieldsEntry_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_Struct_FieldsEntry_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_Struct_FieldsEntry_serialize(const google_protobuf_Struct_FieldsEntry *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_Struct_FieldsEntry_msginit, arena, len); @@ -102,15 +101,15 @@ UPB_INLINE struct google_protobuf_Value* google_protobuf_Struct_FieldsEntry_muta return sub; } - /* google.protobuf.Value */ UPB_INLINE google_protobuf_Value *google_protobuf_Value_new(upb_arena *arena) { return (google_protobuf_Value *)upb_msg_new(&google_protobuf_Value_msginit, arena); } -UPB_INLINE google_protobuf_Value *google_protobuf_Value_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_Value *google_protobuf_Value_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_Value *ret = google_protobuf_Value_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_Value_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_Value_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_Value_serialize(const google_protobuf_Value *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_Value_msginit, arena, len); @@ -123,9 +122,9 @@ typedef enum { google_protobuf_Value_kind_bool_value = 4, google_protobuf_Value_kind_struct_value = 5, google_protobuf_Value_kind_list_value = 6, - google_protobuf_Value_kind_NOT_SET = 0, + google_protobuf_Value_kind_NOT_SET = 0 } google_protobuf_Value_kind_oneofcases; -UPB_INLINE google_protobuf_Value_kind_oneofcases google_protobuf_Value_kind_case(const google_protobuf_Value* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(8, 16)); } +UPB_INLINE google_protobuf_Value_kind_oneofcases google_protobuf_Value_kind_case(const google_protobuf_Value* msg) { return (google_protobuf_Value_kind_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 16)); } UPB_INLINE bool google_protobuf_Value_has_null_value(const google_protobuf_Value *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(8, 16), 1); } UPB_INLINE int32_t google_protobuf_Value_null_value(const google_protobuf_Value *msg) { return UPB_READ_ONEOF(msg, int32_t, UPB_SIZE(0, 0), UPB_SIZE(8, 16), 1, google_protobuf_NULL_VALUE); } @@ -177,15 +176,15 @@ UPB_INLINE struct google_protobuf_ListValue* google_protobuf_Value_mutable_list_ return sub; } - /* google.protobuf.ListValue */ UPB_INLINE google_protobuf_ListValue *google_protobuf_ListValue_new(upb_arena *arena) { return (google_protobuf_ListValue *)upb_msg_new(&google_protobuf_ListValue_msginit, arena); } -UPB_INLINE google_protobuf_ListValue *google_protobuf_ListValue_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_ListValue *google_protobuf_ListValue_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_ListValue *ret = google_protobuf_ListValue_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_ListValue_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_ListValue_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_ListValue_serialize(const google_protobuf_ListValue *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_ListValue_msginit, arena, len); @@ -207,7 +206,6 @@ UPB_INLINE struct google_protobuf_Value* google_protobuf_ListValue_add_values(go return sub; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h b/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h index 23d39e55f9d..ec4dfe9444a 100644 --- a/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +++ b/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h @@ -10,12 +10,12 @@ #define GOOGLE_PROTOBUF_TIMESTAMP_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -24,17 +24,16 @@ struct google_protobuf_Timestamp; typedef struct google_protobuf_Timestamp google_protobuf_Timestamp; extern const upb_msglayout google_protobuf_Timestamp_msginit; -/* Enums */ - /* google.protobuf.Timestamp */ UPB_INLINE google_protobuf_Timestamp *google_protobuf_Timestamp_new(upb_arena *arena) { return (google_protobuf_Timestamp *)upb_msg_new(&google_protobuf_Timestamp_msginit, arena); } -UPB_INLINE google_protobuf_Timestamp *google_protobuf_Timestamp_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_Timestamp *google_protobuf_Timestamp_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_Timestamp *ret = google_protobuf_Timestamp_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_Timestamp_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_Timestamp_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_Timestamp_serialize(const google_protobuf_Timestamp *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_Timestamp_msginit, arena, len); @@ -50,7 +49,6 @@ UPB_INLINE void google_protobuf_Timestamp_set_nanos(google_protobuf_Timestamp *m UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h b/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h index b9897ecceb2..589c21355bf 100644 --- a/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +++ b/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h @@ -10,12 +10,12 @@ #define GOOGLE_PROTOBUF_WRAPPERS_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -48,17 +48,16 @@ extern const upb_msglayout google_protobuf_BoolValue_msginit; extern const upb_msglayout google_protobuf_StringValue_msginit; extern const upb_msglayout google_protobuf_BytesValue_msginit; -/* Enums */ - /* google.protobuf.DoubleValue */ UPB_INLINE google_protobuf_DoubleValue *google_protobuf_DoubleValue_new(upb_arena *arena) { return (google_protobuf_DoubleValue *)upb_msg_new(&google_protobuf_DoubleValue_msginit, arena); } -UPB_INLINE google_protobuf_DoubleValue *google_protobuf_DoubleValue_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_DoubleValue *google_protobuf_DoubleValue_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_DoubleValue *ret = google_protobuf_DoubleValue_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_DoubleValue_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_DoubleValue_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_DoubleValue_serialize(const google_protobuf_DoubleValue *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_DoubleValue_msginit, arena, len); @@ -70,15 +69,15 @@ UPB_INLINE void google_protobuf_DoubleValue_set_value(google_protobuf_DoubleValu UPB_FIELD_AT(msg, double, UPB_SIZE(0, 0)) = value; } - /* google.protobuf.FloatValue */ UPB_INLINE google_protobuf_FloatValue *google_protobuf_FloatValue_new(upb_arena *arena) { return (google_protobuf_FloatValue *)upb_msg_new(&google_protobuf_FloatValue_msginit, arena); } -UPB_INLINE google_protobuf_FloatValue *google_protobuf_FloatValue_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_FloatValue *google_protobuf_FloatValue_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_FloatValue *ret = google_protobuf_FloatValue_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_FloatValue_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_FloatValue_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_FloatValue_serialize(const google_protobuf_FloatValue *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_FloatValue_msginit, arena, len); @@ -90,15 +89,15 @@ UPB_INLINE void google_protobuf_FloatValue_set_value(google_protobuf_FloatValue UPB_FIELD_AT(msg, float, UPB_SIZE(0, 0)) = value; } - /* google.protobuf.Int64Value */ UPB_INLINE google_protobuf_Int64Value *google_protobuf_Int64Value_new(upb_arena *arena) { return (google_protobuf_Int64Value *)upb_msg_new(&google_protobuf_Int64Value_msginit, arena); } -UPB_INLINE google_protobuf_Int64Value *google_protobuf_Int64Value_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_Int64Value *google_protobuf_Int64Value_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_Int64Value *ret = google_protobuf_Int64Value_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_Int64Value_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_Int64Value_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_Int64Value_serialize(const google_protobuf_Int64Value *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_Int64Value_msginit, arena, len); @@ -110,15 +109,15 @@ UPB_INLINE void google_protobuf_Int64Value_set_value(google_protobuf_Int64Value UPB_FIELD_AT(msg, int64_t, UPB_SIZE(0, 0)) = value; } - /* google.protobuf.UInt64Value */ UPB_INLINE google_protobuf_UInt64Value *google_protobuf_UInt64Value_new(upb_arena *arena) { return (google_protobuf_UInt64Value *)upb_msg_new(&google_protobuf_UInt64Value_msginit, arena); } -UPB_INLINE google_protobuf_UInt64Value *google_protobuf_UInt64Value_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_UInt64Value *google_protobuf_UInt64Value_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_UInt64Value *ret = google_protobuf_UInt64Value_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_UInt64Value_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_UInt64Value_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_UInt64Value_serialize(const google_protobuf_UInt64Value *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_UInt64Value_msginit, arena, len); @@ -130,15 +129,15 @@ UPB_INLINE void google_protobuf_UInt64Value_set_value(google_protobuf_UInt64Valu UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)) = value; } - /* google.protobuf.Int32Value */ UPB_INLINE google_protobuf_Int32Value *google_protobuf_Int32Value_new(upb_arena *arena) { return (google_protobuf_Int32Value *)upb_msg_new(&google_protobuf_Int32Value_msginit, arena); } -UPB_INLINE google_protobuf_Int32Value *google_protobuf_Int32Value_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_Int32Value *google_protobuf_Int32Value_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_Int32Value *ret = google_protobuf_Int32Value_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_Int32Value_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_Int32Value_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_Int32Value_serialize(const google_protobuf_Int32Value *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_Int32Value_msginit, arena, len); @@ -150,15 +149,15 @@ UPB_INLINE void google_protobuf_Int32Value_set_value(google_protobuf_Int32Value UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)) = value; } - /* google.protobuf.UInt32Value */ UPB_INLINE google_protobuf_UInt32Value *google_protobuf_UInt32Value_new(upb_arena *arena) { return (google_protobuf_UInt32Value *)upb_msg_new(&google_protobuf_UInt32Value_msginit, arena); } -UPB_INLINE google_protobuf_UInt32Value *google_protobuf_UInt32Value_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_UInt32Value *google_protobuf_UInt32Value_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_UInt32Value *ret = google_protobuf_UInt32Value_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_UInt32Value_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_UInt32Value_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_UInt32Value_serialize(const google_protobuf_UInt32Value *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_UInt32Value_msginit, arena, len); @@ -170,15 +169,15 @@ UPB_INLINE void google_protobuf_UInt32Value_set_value(google_protobuf_UInt32Valu UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(0, 0)) = value; } - /* google.protobuf.BoolValue */ UPB_INLINE google_protobuf_BoolValue *google_protobuf_BoolValue_new(upb_arena *arena) { return (google_protobuf_BoolValue *)upb_msg_new(&google_protobuf_BoolValue_msginit, arena); } -UPB_INLINE google_protobuf_BoolValue *google_protobuf_BoolValue_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_BoolValue *google_protobuf_BoolValue_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_BoolValue *ret = google_protobuf_BoolValue_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_BoolValue_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_BoolValue_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_BoolValue_serialize(const google_protobuf_BoolValue *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_BoolValue_msginit, arena, len); @@ -190,15 +189,15 @@ UPB_INLINE void google_protobuf_BoolValue_set_value(google_protobuf_BoolValue *m UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)) = value; } - /* google.protobuf.StringValue */ UPB_INLINE google_protobuf_StringValue *google_protobuf_StringValue_new(upb_arena *arena) { return (google_protobuf_StringValue *)upb_msg_new(&google_protobuf_StringValue_msginit, arena); } -UPB_INLINE google_protobuf_StringValue *google_protobuf_StringValue_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_StringValue *google_protobuf_StringValue_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_StringValue *ret = google_protobuf_StringValue_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_StringValue_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_StringValue_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_StringValue_serialize(const google_protobuf_StringValue *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_StringValue_msginit, arena, len); @@ -210,15 +209,15 @@ UPB_INLINE void google_protobuf_StringValue_set_value(google_protobuf_StringValu UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; } - /* google.protobuf.BytesValue */ UPB_INLINE google_protobuf_BytesValue *google_protobuf_BytesValue_new(upb_arena *arena) { return (google_protobuf_BytesValue *)upb_msg_new(&google_protobuf_BytesValue_msginit, arena); } -UPB_INLINE google_protobuf_BytesValue *google_protobuf_BytesValue_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_protobuf_BytesValue *google_protobuf_BytesValue_parse(const char *buf, size_t size, + upb_arena *arena) { google_protobuf_BytesValue *ret = google_protobuf_BytesValue_new(arena); - return (ret && upb_decode(buf, ret, &google_protobuf_BytesValue_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_protobuf_BytesValue_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_protobuf_BytesValue_serialize(const google_protobuf_BytesValue *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_protobuf_BytesValue_msginit, arena, len); @@ -230,7 +229,6 @@ UPB_INLINE void google_protobuf_BytesValue_set_value(google_protobuf_BytesValue UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/google/rpc/status.upb.h b/src/core/ext/upb-generated/google/rpc/status.upb.h index ccdac652130..6c35d83dc1d 100644 --- a/src/core/ext/upb-generated/google/rpc/status.upb.h +++ b/src/core/ext/upb-generated/google/rpc/status.upb.h @@ -10,12 +10,12 @@ #define GOOGLE_RPC_STATUS_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -26,17 +26,16 @@ extern const upb_msglayout google_rpc_Status_msginit; struct google_protobuf_Any; extern const upb_msglayout google_protobuf_Any_msginit; -/* Enums */ - /* google.rpc.Status */ UPB_INLINE google_rpc_Status *google_rpc_Status_new(upb_arena *arena) { return (google_rpc_Status *)upb_msg_new(&google_rpc_Status_msginit, arena); } -UPB_INLINE google_rpc_Status *google_rpc_Status_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE google_rpc_Status *google_rpc_Status_parse(const char *buf, size_t size, + upb_arena *arena) { google_rpc_Status *ret = google_rpc_Status_new(arena); - return (ret && upb_decode(buf, ret, &google_rpc_Status_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &google_rpc_Status_msginit, arena)) ? ret : NULL; } UPB_INLINE char *google_rpc_Status_serialize(const google_rpc_Status *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &google_rpc_Status_msginit, arena, len); @@ -66,7 +65,6 @@ UPB_INLINE struct google_protobuf_Any* google_rpc_Status_add_details(google_rpc_ return sub; } - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/ext/upb-generated/validate/validate.upb.h b/src/core/ext/upb-generated/validate/validate.upb.h index c28ac41881d..cac68a3441f 100644 --- a/src/core/ext/upb-generated/validate/validate.upb.h +++ b/src/core/ext/upb-generated/validate/validate.upb.h @@ -10,12 +10,12 @@ #define VALIDATE_VALIDATE_PROTO_UPB_H_ #include "upb/generated_util.h" - #include "upb/msg.h" - #include "upb/decode.h" #include "upb/encode.h" + #include "upb/port_def.inc" + #ifdef __cplusplus extern "C" { #endif @@ -94,17 +94,16 @@ struct google_protobuf_Timestamp; extern const upb_msglayout google_protobuf_Duration_msginit; extern const upb_msglayout google_protobuf_Timestamp_msginit; -/* Enums */ - /* validate.FieldRules */ UPB_INLINE validate_FieldRules *validate_FieldRules_new(upb_arena *arena) { return (validate_FieldRules *)upb_msg_new(&validate_FieldRules_msginit, arena); } -UPB_INLINE validate_FieldRules *validate_FieldRules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_FieldRules *validate_FieldRules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_FieldRules *ret = validate_FieldRules_new(arena); - return (ret && upb_decode(buf, ret, &validate_FieldRules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_FieldRules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_FieldRules_serialize(const validate_FieldRules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_FieldRules_msginit, arena, len); @@ -133,9 +132,9 @@ typedef enum { validate_FieldRules_type_any = 20, validate_FieldRules_type_duration = 21, validate_FieldRules_type_timestamp = 22, - validate_FieldRules_type_NOT_SET = 0, + validate_FieldRules_type_NOT_SET = 0 } validate_FieldRules_type_oneofcases; -UPB_INLINE validate_FieldRules_type_oneofcases validate_FieldRules_type_case(const validate_FieldRules* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(4, 8)); } +UPB_INLINE validate_FieldRules_type_oneofcases validate_FieldRules_type_case(const validate_FieldRules* msg) { return (validate_FieldRules_type_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 8)); } UPB_INLINE bool validate_FieldRules_has_float(const validate_FieldRules *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(4, 8), 1); } UPB_INLINE const validate_FloatRules* validate_FieldRules_float(const validate_FieldRules *msg) { return UPB_READ_ONEOF(msg, const validate_FloatRules*, UPB_SIZE(0, 0), UPB_SIZE(4, 8), 1, NULL); } @@ -447,15 +446,15 @@ UPB_INLINE struct validate_TimestampRules* validate_FieldRules_mutable_timestamp return sub; } - /* validate.FloatRules */ UPB_INLINE validate_FloatRules *validate_FloatRules_new(upb_arena *arena) { return (validate_FloatRules *)upb_msg_new(&validate_FloatRules_msginit, arena); } -UPB_INLINE validate_FloatRules *validate_FloatRules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_FloatRules *validate_FloatRules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_FloatRules *ret = validate_FloatRules_new(arena); - return (ret && upb_decode(buf, ret, &validate_FloatRules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_FloatRules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_FloatRules_serialize(const validate_FloatRules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_FloatRules_msginit, arena, len); @@ -515,15 +514,15 @@ UPB_INLINE bool validate_FloatRules_add_not_in(validate_FloatRules *msg, float v msg, UPB_SIZE(28, 32), UPB_SIZE(4, 4), UPB_TYPE_FLOAT, &val, arena); } - /* validate.DoubleRules */ UPB_INLINE validate_DoubleRules *validate_DoubleRules_new(upb_arena *arena) { return (validate_DoubleRules *)upb_msg_new(&validate_DoubleRules_msginit, arena); } -UPB_INLINE validate_DoubleRules *validate_DoubleRules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_DoubleRules *validate_DoubleRules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_DoubleRules *ret = validate_DoubleRules_new(arena); - return (ret && upb_decode(buf, ret, &validate_DoubleRules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_DoubleRules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_DoubleRules_serialize(const validate_DoubleRules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_DoubleRules_msginit, arena, len); @@ -583,15 +582,15 @@ UPB_INLINE bool validate_DoubleRules_add_not_in(validate_DoubleRules *msg, doubl msg, UPB_SIZE(52, 56), UPB_SIZE(8, 8), UPB_TYPE_DOUBLE, &val, arena); } - /* validate.Int32Rules */ UPB_INLINE validate_Int32Rules *validate_Int32Rules_new(upb_arena *arena) { return (validate_Int32Rules *)upb_msg_new(&validate_Int32Rules_msginit, arena); } -UPB_INLINE validate_Int32Rules *validate_Int32Rules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_Int32Rules *validate_Int32Rules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_Int32Rules *ret = validate_Int32Rules_new(arena); - return (ret && upb_decode(buf, ret, &validate_Int32Rules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_Int32Rules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_Int32Rules_serialize(const validate_Int32Rules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_Int32Rules_msginit, arena, len); @@ -651,15 +650,15 @@ UPB_INLINE bool validate_Int32Rules_add_not_in(validate_Int32Rules *msg, int32_t msg, UPB_SIZE(28, 32), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val, arena); } - /* validate.Int64Rules */ UPB_INLINE validate_Int64Rules *validate_Int64Rules_new(upb_arena *arena) { return (validate_Int64Rules *)upb_msg_new(&validate_Int64Rules_msginit, arena); } -UPB_INLINE validate_Int64Rules *validate_Int64Rules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_Int64Rules *validate_Int64Rules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_Int64Rules *ret = validate_Int64Rules_new(arena); - return (ret && upb_decode(buf, ret, &validate_Int64Rules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_Int64Rules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_Int64Rules_serialize(const validate_Int64Rules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_Int64Rules_msginit, arena, len); @@ -719,15 +718,15 @@ UPB_INLINE bool validate_Int64Rules_add_not_in(validate_Int64Rules *msg, int64_t msg, UPB_SIZE(52, 56), UPB_SIZE(8, 8), UPB_TYPE_INT64, &val, arena); } - /* validate.UInt32Rules */ UPB_INLINE validate_UInt32Rules *validate_UInt32Rules_new(upb_arena *arena) { return (validate_UInt32Rules *)upb_msg_new(&validate_UInt32Rules_msginit, arena); } -UPB_INLINE validate_UInt32Rules *validate_UInt32Rules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_UInt32Rules *validate_UInt32Rules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_UInt32Rules *ret = validate_UInt32Rules_new(arena); - return (ret && upb_decode(buf, ret, &validate_UInt32Rules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_UInt32Rules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_UInt32Rules_serialize(const validate_UInt32Rules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_UInt32Rules_msginit, arena, len); @@ -787,15 +786,15 @@ UPB_INLINE bool validate_UInt32Rules_add_not_in(validate_UInt32Rules *msg, uint3 msg, UPB_SIZE(28, 32), UPB_SIZE(4, 4), UPB_TYPE_UINT32, &val, arena); } - /* validate.UInt64Rules */ UPB_INLINE validate_UInt64Rules *validate_UInt64Rules_new(upb_arena *arena) { return (validate_UInt64Rules *)upb_msg_new(&validate_UInt64Rules_msginit, arena); } -UPB_INLINE validate_UInt64Rules *validate_UInt64Rules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_UInt64Rules *validate_UInt64Rules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_UInt64Rules *ret = validate_UInt64Rules_new(arena); - return (ret && upb_decode(buf, ret, &validate_UInt64Rules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_UInt64Rules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_UInt64Rules_serialize(const validate_UInt64Rules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_UInt64Rules_msginit, arena, len); @@ -855,15 +854,15 @@ UPB_INLINE bool validate_UInt64Rules_add_not_in(validate_UInt64Rules *msg, uint6 msg, UPB_SIZE(52, 56), UPB_SIZE(8, 8), UPB_TYPE_UINT64, &val, arena); } - /* validate.SInt32Rules */ UPB_INLINE validate_SInt32Rules *validate_SInt32Rules_new(upb_arena *arena) { return (validate_SInt32Rules *)upb_msg_new(&validate_SInt32Rules_msginit, arena); } -UPB_INLINE validate_SInt32Rules *validate_SInt32Rules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_SInt32Rules *validate_SInt32Rules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_SInt32Rules *ret = validate_SInt32Rules_new(arena); - return (ret && upb_decode(buf, ret, &validate_SInt32Rules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_SInt32Rules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_SInt32Rules_serialize(const validate_SInt32Rules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_SInt32Rules_msginit, arena, len); @@ -923,15 +922,15 @@ UPB_INLINE bool validate_SInt32Rules_add_not_in(validate_SInt32Rules *msg, int32 msg, UPB_SIZE(28, 32), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val, arena); } - /* validate.SInt64Rules */ UPB_INLINE validate_SInt64Rules *validate_SInt64Rules_new(upb_arena *arena) { return (validate_SInt64Rules *)upb_msg_new(&validate_SInt64Rules_msginit, arena); } -UPB_INLINE validate_SInt64Rules *validate_SInt64Rules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_SInt64Rules *validate_SInt64Rules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_SInt64Rules *ret = validate_SInt64Rules_new(arena); - return (ret && upb_decode(buf, ret, &validate_SInt64Rules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_SInt64Rules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_SInt64Rules_serialize(const validate_SInt64Rules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_SInt64Rules_msginit, arena, len); @@ -991,15 +990,15 @@ UPB_INLINE bool validate_SInt64Rules_add_not_in(validate_SInt64Rules *msg, int64 msg, UPB_SIZE(52, 56), UPB_SIZE(8, 8), UPB_TYPE_INT64, &val, arena); } - /* validate.Fixed32Rules */ UPB_INLINE validate_Fixed32Rules *validate_Fixed32Rules_new(upb_arena *arena) { return (validate_Fixed32Rules *)upb_msg_new(&validate_Fixed32Rules_msginit, arena); } -UPB_INLINE validate_Fixed32Rules *validate_Fixed32Rules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_Fixed32Rules *validate_Fixed32Rules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_Fixed32Rules *ret = validate_Fixed32Rules_new(arena); - return (ret && upb_decode(buf, ret, &validate_Fixed32Rules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_Fixed32Rules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_Fixed32Rules_serialize(const validate_Fixed32Rules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_Fixed32Rules_msginit, arena, len); @@ -1059,15 +1058,15 @@ UPB_INLINE bool validate_Fixed32Rules_add_not_in(validate_Fixed32Rules *msg, uin msg, UPB_SIZE(28, 32), UPB_SIZE(4, 4), UPB_TYPE_UINT32, &val, arena); } - /* validate.Fixed64Rules */ UPB_INLINE validate_Fixed64Rules *validate_Fixed64Rules_new(upb_arena *arena) { return (validate_Fixed64Rules *)upb_msg_new(&validate_Fixed64Rules_msginit, arena); } -UPB_INLINE validate_Fixed64Rules *validate_Fixed64Rules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_Fixed64Rules *validate_Fixed64Rules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_Fixed64Rules *ret = validate_Fixed64Rules_new(arena); - return (ret && upb_decode(buf, ret, &validate_Fixed64Rules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_Fixed64Rules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_Fixed64Rules_serialize(const validate_Fixed64Rules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_Fixed64Rules_msginit, arena, len); @@ -1127,15 +1126,15 @@ UPB_INLINE bool validate_Fixed64Rules_add_not_in(validate_Fixed64Rules *msg, uin msg, UPB_SIZE(52, 56), UPB_SIZE(8, 8), UPB_TYPE_UINT64, &val, arena); } - /* validate.SFixed32Rules */ UPB_INLINE validate_SFixed32Rules *validate_SFixed32Rules_new(upb_arena *arena) { return (validate_SFixed32Rules *)upb_msg_new(&validate_SFixed32Rules_msginit, arena); } -UPB_INLINE validate_SFixed32Rules *validate_SFixed32Rules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_SFixed32Rules *validate_SFixed32Rules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_SFixed32Rules *ret = validate_SFixed32Rules_new(arena); - return (ret && upb_decode(buf, ret, &validate_SFixed32Rules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_SFixed32Rules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_SFixed32Rules_serialize(const validate_SFixed32Rules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_SFixed32Rules_msginit, arena, len); @@ -1195,15 +1194,15 @@ UPB_INLINE bool validate_SFixed32Rules_add_not_in(validate_SFixed32Rules *msg, i msg, UPB_SIZE(28, 32), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val, arena); } - /* validate.SFixed64Rules */ UPB_INLINE validate_SFixed64Rules *validate_SFixed64Rules_new(upb_arena *arena) { return (validate_SFixed64Rules *)upb_msg_new(&validate_SFixed64Rules_msginit, arena); } -UPB_INLINE validate_SFixed64Rules *validate_SFixed64Rules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_SFixed64Rules *validate_SFixed64Rules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_SFixed64Rules *ret = validate_SFixed64Rules_new(arena); - return (ret && upb_decode(buf, ret, &validate_SFixed64Rules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_SFixed64Rules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_SFixed64Rules_serialize(const validate_SFixed64Rules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_SFixed64Rules_msginit, arena, len); @@ -1263,15 +1262,15 @@ UPB_INLINE bool validate_SFixed64Rules_add_not_in(validate_SFixed64Rules *msg, i msg, UPB_SIZE(52, 56), UPB_SIZE(8, 8), UPB_TYPE_INT64, &val, arena); } - /* validate.BoolRules */ UPB_INLINE validate_BoolRules *validate_BoolRules_new(upb_arena *arena) { return (validate_BoolRules *)upb_msg_new(&validate_BoolRules_msginit, arena); } -UPB_INLINE validate_BoolRules *validate_BoolRules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_BoolRules *validate_BoolRules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_BoolRules *ret = validate_BoolRules_new(arena); - return (ret && upb_decode(buf, ret, &validate_BoolRules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_BoolRules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_BoolRules_serialize(const validate_BoolRules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_BoolRules_msginit, arena, len); @@ -1285,15 +1284,15 @@ UPB_INLINE void validate_BoolRules_set_const(validate_BoolRules *msg, bool value UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value; } - /* validate.StringRules */ UPB_INLINE validate_StringRules *validate_StringRules_new(upb_arena *arena) { return (validate_StringRules *)upb_msg_new(&validate_StringRules_msginit, arena); } -UPB_INLINE validate_StringRules *validate_StringRules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_StringRules *validate_StringRules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_StringRules *ret = validate_StringRules_new(arena); - return (ret && upb_decode(buf, ret, &validate_StringRules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_StringRules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_StringRules_serialize(const validate_StringRules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_StringRules_msginit, arena, len); @@ -1307,9 +1306,9 @@ typedef enum { validate_StringRules_well_known_ipv6 = 16, validate_StringRules_well_known_uri = 17, validate_StringRules_well_known_uri_ref = 18, - validate_StringRules_well_known_NOT_SET = 0, + validate_StringRules_well_known_NOT_SET = 0 } validate_StringRules_well_known_oneofcases; -UPB_INLINE validate_StringRules_well_known_oneofcases validate_StringRules_well_known_case(const validate_StringRules* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(108, 156)); } +UPB_INLINE validate_StringRules_well_known_oneofcases validate_StringRules_well_known_case(const validate_StringRules* msg) { return (validate_StringRules_well_known_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(108, 156)); } UPB_INLINE bool validate_StringRules_has_const(const validate_StringRules *msg) { return _upb_has_field(msg, 7); } UPB_INLINE upb_strview validate_StringRules_const(const validate_StringRules *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(56, 56)); } @@ -1436,15 +1435,15 @@ UPB_INLINE void validate_StringRules_set_len_bytes(validate_StringRules *msg, ui UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(48, 48)) = value; } - /* validate.BytesRules */ UPB_INLINE validate_BytesRules *validate_BytesRules_new(upb_arena *arena) { return (validate_BytesRules *)upb_msg_new(&validate_BytesRules_msginit, arena); } -UPB_INLINE validate_BytesRules *validate_BytesRules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_BytesRules *validate_BytesRules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_BytesRules *ret = validate_BytesRules_new(arena); - return (ret && upb_decode(buf, ret, &validate_BytesRules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_BytesRules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_BytesRules_serialize(const validate_BytesRules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_BytesRules_msginit, arena, len); @@ -1454,9 +1453,9 @@ typedef enum { validate_BytesRules_well_known_ip = 10, validate_BytesRules_well_known_ipv4 = 11, validate_BytesRules_well_known_ipv6 = 12, - validate_BytesRules_well_known_NOT_SET = 0, + validate_BytesRules_well_known_NOT_SET = 0 } validate_BytesRules_well_known_oneofcases; -UPB_INLINE validate_BytesRules_well_known_oneofcases validate_BytesRules_well_known_case(const validate_BytesRules* msg) { return UPB_FIELD_AT(msg, int, UPB_SIZE(84, 132)); } +UPB_INLINE validate_BytesRules_well_known_oneofcases validate_BytesRules_well_known_case(const validate_BytesRules* msg) { return (validate_BytesRules_well_known_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(84, 132)); } UPB_INLINE bool validate_BytesRules_has_const(const validate_BytesRules *msg) { return _upb_has_field(msg, 4); } UPB_INLINE upb_strview validate_BytesRules_const(const validate_BytesRules *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(32, 32)); } @@ -1545,15 +1544,15 @@ UPB_INLINE void validate_BytesRules_set_len(validate_BytesRules *msg, uint64_t v UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(24, 24)) = value; } - /* validate.EnumRules */ UPB_INLINE validate_EnumRules *validate_EnumRules_new(upb_arena *arena) { return (validate_EnumRules *)upb_msg_new(&validate_EnumRules_msginit, arena); } -UPB_INLINE validate_EnumRules *validate_EnumRules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_EnumRules *validate_EnumRules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_EnumRules *ret = validate_EnumRules_new(arena); - return (ret && upb_decode(buf, ret, &validate_EnumRules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_EnumRules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_EnumRules_serialize(const validate_EnumRules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_EnumRules_msginit, arena, len); @@ -1595,15 +1594,15 @@ UPB_INLINE bool validate_EnumRules_add_not_in(validate_EnumRules *msg, int32_t v msg, UPB_SIZE(16, 24), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val, arena); } - /* validate.MessageRules */ UPB_INLINE validate_MessageRules *validate_MessageRules_new(upb_arena *arena) { return (validate_MessageRules *)upb_msg_new(&validate_MessageRules_msginit, arena); } -UPB_INLINE validate_MessageRules *validate_MessageRules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_MessageRules *validate_MessageRules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_MessageRules *ret = validate_MessageRules_new(arena); - return (ret && upb_decode(buf, ret, &validate_MessageRules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_MessageRules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_MessageRules_serialize(const validate_MessageRules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_MessageRules_msginit, arena, len); @@ -1623,15 +1622,15 @@ UPB_INLINE void validate_MessageRules_set_required(validate_MessageRules *msg, b UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)) = value; } - /* validate.RepeatedRules */ UPB_INLINE validate_RepeatedRules *validate_RepeatedRules_new(upb_arena *arena) { return (validate_RepeatedRules *)upb_msg_new(&validate_RepeatedRules_msginit, arena); } -UPB_INLINE validate_RepeatedRules *validate_RepeatedRules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_RepeatedRules *validate_RepeatedRules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_RepeatedRules *ret = validate_RepeatedRules_new(arena); - return (ret && upb_decode(buf, ret, &validate_RepeatedRules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_RepeatedRules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_RepeatedRules_serialize(const validate_RepeatedRules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_RepeatedRules_msginit, arena, len); @@ -1672,15 +1671,15 @@ UPB_INLINE struct validate_FieldRules* validate_RepeatedRules_mutable_items(vali return sub; } - /* validate.MapRules */ UPB_INLINE validate_MapRules *validate_MapRules_new(upb_arena *arena) { return (validate_MapRules *)upb_msg_new(&validate_MapRules_msginit, arena); } -UPB_INLINE validate_MapRules *validate_MapRules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_MapRules *validate_MapRules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_MapRules *ret = validate_MapRules_new(arena); - return (ret && upb_decode(buf, ret, &validate_MapRules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_MapRules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_MapRules_serialize(const validate_MapRules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_MapRules_msginit, arena, len); @@ -1736,15 +1735,15 @@ UPB_INLINE struct validate_FieldRules* validate_MapRules_mutable_values(validate return sub; } - /* validate.AnyRules */ UPB_INLINE validate_AnyRules *validate_AnyRules_new(upb_arena *arena) { return (validate_AnyRules *)upb_msg_new(&validate_AnyRules_msginit, arena); } -UPB_INLINE validate_AnyRules *validate_AnyRules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_AnyRules *validate_AnyRules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_AnyRules *ret = validate_AnyRules_new(arena); - return (ret && upb_decode(buf, ret, &validate_AnyRules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_AnyRules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_AnyRules_serialize(const validate_AnyRules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_AnyRules_msginit, arena, len); @@ -1780,15 +1779,15 @@ UPB_INLINE bool validate_AnyRules_add_not_in(validate_AnyRules *msg, upb_strview msg, UPB_SIZE(8, 16), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); } - /* validate.DurationRules */ UPB_INLINE validate_DurationRules *validate_DurationRules_new(upb_arena *arena) { return (validate_DurationRules *)upb_msg_new(&validate_DurationRules_msginit, arena); } -UPB_INLINE validate_DurationRules *validate_DurationRules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_DurationRules *validate_DurationRules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_DurationRules *ret = validate_DurationRules_new(arena); - return (ret && upb_decode(buf, ret, &validate_DurationRules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_DurationRules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_DurationRules_serialize(const validate_DurationRules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_DurationRules_msginit, arena, len); @@ -1905,15 +1904,15 @@ UPB_INLINE struct google_protobuf_Duration* validate_DurationRules_add_not_in(va return sub; } - /* validate.TimestampRules */ UPB_INLINE validate_TimestampRules *validate_TimestampRules_new(upb_arena *arena) { return (validate_TimestampRules *)upb_msg_new(&validate_TimestampRules_msginit, arena); } -UPB_INLINE validate_TimestampRules *validate_TimestampRules_parsenew(upb_strview buf, upb_arena *arena) { +UPB_INLINE validate_TimestampRules *validate_TimestampRules_parse(const char *buf, size_t size, + upb_arena *arena) { validate_TimestampRules *ret = validate_TimestampRules_new(arena); - return (ret && upb_decode(buf, ret, &validate_TimestampRules_msginit)) ? ret : NULL; + return (ret && upb_decode(buf, size, ret, &validate_TimestampRules_msginit, arena)) ? ret : NULL; } UPB_INLINE char *validate_TimestampRules_serialize(const validate_TimestampRules *msg, upb_arena *arena, size_t *len) { return upb_encode(msg, &validate_TimestampRules_msginit, arena, len); @@ -2029,7 +2028,6 @@ UPB_INLINE struct google_protobuf_Duration* validate_TimestampRules_mutable_with return sub; } - #ifdef __cplusplus } /* extern "C" */ #endif From fbd5957ee83c1dcc3c59b0c8707cc2b8061efbbe Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Fri, 21 Jun 2019 12:28:55 -0700 Subject: [PATCH 0642/1555] Sanity and build fixes --- include/grpcpp/impl/codegen/async_stream.h | 27 ++++++++++--------- .../grpcpp/impl/codegen/async_unary_call.h | 7 ++--- .../grpcpp/impl/codegen/method_handler_impl.h | 6 ++--- include/grpcpp/impl/codegen/sync_stream.h | 4 +-- include/grpcpp/server_impl.h | 20 +++++++------- test/cpp/codegen/compiler_test_golden | 2 ++ test/cpp/qps/server.h | 2 +- test/cpp/util/create_test_channel.h | 7 ++--- 8 files changed, 39 insertions(+), 36 deletions(-) diff --git a/include/grpcpp/impl/codegen/async_stream.h b/include/grpcpp/impl/codegen/async_stream.h index f762833b3b1..417dceb587f 100644 --- a/include/grpcpp/impl/codegen/async_stream.h +++ b/include/grpcpp/impl/codegen/async_stream.h @@ -181,8 +181,8 @@ class ClientAsyncReaderFactory { static ClientAsyncReader* Create(ChannelInterface* channel, CompletionQueue* cq, const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, const W& request, - bool start, void* tag) { + ::grpc_impl::ClientContext* context, + const W& request, bool start, void* tag) { ::grpc::internal::Call call = channel->CreateCall(method, context, cq); return new (g_core_codegen_interface->grpc_call_arena_alloc( call.call(), sizeof(ClientAsyncReader))) @@ -260,8 +260,9 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface { private: friend class internal::ClientAsyncReaderFactory; template - ClientAsyncReader(::grpc::internal::Call call, ::grpc_impl::ClientContext* context, - const W& request, bool start, void* tag) + ClientAsyncReader(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, const W& request, + bool start, void* tag) : context_(context), call_(call), started_(start) { // TODO(ctiller): don't assert GPR_CODEGEN_ASSERT(init_ops_.SendMessage(request).ok()); @@ -329,8 +330,8 @@ class ClientAsyncWriterFactory { static ClientAsyncWriter* Create(ChannelInterface* channel, CompletionQueue* cq, const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, R* response, - bool start, void* tag) { + ::grpc_impl::ClientContext* context, + R* response, bool start, void* tag) { ::grpc::internal::Call call = channel->CreateCall(method, context, cq); return new (g_core_codegen_interface->grpc_call_arena_alloc( call.call(), sizeof(ClientAsyncWriter))) @@ -426,8 +427,9 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface { private: friend class internal::ClientAsyncWriterFactory; template - ClientAsyncWriter(::grpc::internal::Call call, ::grpc_impl::ClientContext* context, - R* response, bool start, void* tag) + ClientAsyncWriter(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, R* response, + bool start, void* tag) : context_(context), call_(call), started_(start) { finish_ops_.RecvMessage(response); finish_ops_.AllowNoMessage(); @@ -493,8 +495,8 @@ class ClientAsyncReaderWriterFactory { /// used to send to the server when starting the call. static ClientAsyncReaderWriter* Create( ChannelInterface* channel, CompletionQueue* cq, - const ::grpc::internal::RpcMethod& method, ::grpc_impl::ClientContext* context, - bool start, void* tag) { + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, bool start, void* tag) { ::grpc::internal::Call call = channel->CreateCall(method, context, cq); return new (g_core_codegen_interface->grpc_call_arena_alloc( @@ -599,8 +601,9 @@ class ClientAsyncReaderWriter final private: friend class internal::ClientAsyncReaderWriterFactory; - ClientAsyncReaderWriter(::grpc::internal::Call call, ::grpc_impl::ClientContext* context, - bool start, void* tag) + ClientAsyncReaderWriter(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, bool start, + void* tag) : context_(context), call_(call), started_(start) { if (start) { StartCallInternal(tag); diff --git a/include/grpcpp/impl/codegen/async_unary_call.h b/include/grpcpp/impl/codegen/async_unary_call.h index 4c0f4339c8f..5da6a649f14 100644 --- a/include/grpcpp/impl/codegen/async_unary_call.h +++ b/include/grpcpp/impl/codegen/async_unary_call.h @@ -81,8 +81,8 @@ class ClientAsyncResponseReaderFactory { template static ClientAsyncResponseReader* Create( ChannelInterface* channel, ::grpc_impl::CompletionQueue* cq, - const ::grpc::internal::RpcMethod& method, ::grpc_impl::ClientContext* context, - const W& request, bool start) { + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, const W& request, bool start) { ::grpc::internal::Call call = channel->CreateCall(method, context, cq); return new (g_core_codegen_interface->grpc_call_arena_alloc( call.call(), sizeof(ClientAsyncResponseReader))) @@ -162,7 +162,8 @@ class ClientAsyncResponseReader final bool initial_metadata_read_ = false; template - ClientAsyncResponseReader(::grpc::internal::Call call, ::grpc_impl::ClientContext* context, + ClientAsyncResponseReader(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, const W& request, bool start) : context_(context), call_(call), started_(start) { // Bind the metadata at time of StartCallInternal but set up the rest here diff --git a/include/grpcpp/impl/codegen/method_handler_impl.h b/include/grpcpp/impl/codegen/method_handler_impl.h index 95b804c50e8..1903f898ba8 100644 --- a/include/grpcpp/impl/codegen/method_handler_impl.h +++ b/include/grpcpp/impl/codegen/method_handler_impl.h @@ -54,9 +54,9 @@ class RpcMethodHandler : public MethodHandler { public: RpcMethodHandler( std::function - func, - ServiceType* service) + const RequestType*, ResponseType*)> + func, + ServiceType* service) : func_(func), service_(service) {} void RunHandler(const HandlerParameter& param) final { diff --git a/include/grpcpp/impl/codegen/sync_stream.h b/include/grpcpp/impl/codegen/sync_stream.h index cdff2f487dc..9d030a13a71 100644 --- a/include/grpcpp/impl/codegen/sync_stream.h +++ b/include/grpcpp/impl/codegen/sync_stream.h @@ -120,7 +120,7 @@ class WriterInterface { /// /// \param msg The message to be written to the stream. /// - /// \return \a true on success, \a false when the stream has been closed.access/marconi/common/grpc/async_grpc_container.h + /// \return \a true on success, \a false when the stream has been closed. inline bool Write(const W& msg) { return Write(msg, WriteOptions()); } /// Write \a msg and coalesce it with the writing of trailing metadata, using @@ -142,7 +142,7 @@ class WriterInterface { } }; -} // namespace internalaccess/marconi/common/grpc/async_grpc_container.h +} // namespace internal /// Client-side interface for streaming reads of message of type \a R. template diff --git a/include/grpcpp/server_impl.h b/include/grpcpp/server_impl.h index a5c8670913e..056f5f0c5ab 100644 --- a/include/grpcpp/server_impl.h +++ b/include/grpcpp/server_impl.h @@ -183,16 +183,16 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { /// server completion queues passed via sync_server_cqs param. Server(int max_message_size, ChannelArguments* args, std::shared_ptr>> - sync_server_cqs, - int min_pollers, int max_pollers, int sync_cq_timeout_msec, - std::vector< - std::shared_ptr> - acceptors, - grpc_resource_quota* server_rq = nullptr, - std::vector> - interceptor_creators = std::vector>()); + sync_server_cqs, + int min_pollers, int max_pollers, int sync_cq_timeout_msec, + std::vector< + std::shared_ptr> + acceptors, + grpc_resource_quota* server_rq = nullptr, + std::vector> + interceptor_creators = std::vector>()); /// Start the server. /// diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index 64ab123123b..035955023b8 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -31,10 +31,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h index 6c2f36451bc..2b82abce202 100644 --- a/test/cpp/qps/server.h +++ b/test/cpp/qps/server.h @@ -19,9 +19,9 @@ #ifndef TEST_QPS_SERVER_H #define TEST_QPS_SERVER_H -#include #include #include +#include #include #include #include diff --git a/test/cpp/util/create_test_channel.h b/test/cpp/util/create_test_channel.h index ab5c7f39ebb..2aacbc9bdf3 100644 --- a/test/cpp/util/create_test_channel.h +++ b/test/cpp/util/create_test_channel.h @@ -26,7 +26,6 @@ #include #include - namespace grpc_impl { class Channel; @@ -79,8 +78,7 @@ std::shared_ptr CreateTestChannel( std::shared_ptr CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, testing::transport_security security_type, bool use_prod_roots, - const std::shared_ptr& creds, - const ChannelArguments& args, + const std::shared_ptr& creds, const ChannelArguments& args, std::vector< std::unique_ptr> interceptor_creators); @@ -88,8 +86,7 @@ std::shared_ptr CreateTestChannel( std::shared_ptr CreateTestChannel( const grpc::string& server, const grpc::string& cred_type, const grpc::string& override_hostname, bool use_prod_roots, - const std::shared_ptr& creds, - const ChannelArguments& args, + const std::shared_ptr& creds, const ChannelArguments& args, std::vector< std::unique_ptr> interceptor_creators); From 889224227c0724dbff8bcfa79ce02c235e56612d Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Fri, 21 Jun 2019 15:48:17 -0400 Subject: [PATCH 0643/1555] Fix a typo. --- src/core/lib/gprpp/host_port.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/gprpp/host_port.h b/src/core/lib/gprpp/host_port.h index 16f1c807580..9a0b492b98f 100644 --- a/src/core/lib/gprpp/host_port.h +++ b/src/core/lib/gprpp/host_port.h @@ -41,7 +41,7 @@ int JoinHostPort(UniquePtr* out, const char* host, int port); and port number. There are two variants of this method: - 1) StringView ouptut: port and host are returned as views on name. + 1) StringView output: port and host are returned as views on name. 2) char* output: port and host are copied into newly allocated strings. Prefer variant (1) over (2), because no allocation or copy is performed in From 624839b7043e8ac3463765152e1d9326d474c691 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Thu, 20 Jun 2019 10:32:54 -0700 Subject: [PATCH 0644/1555] Add example Python server using compression. --- examples/python/compression/BUILD.bazel | 44 +++++++ examples/python/compression/README.md | 58 ++++++++++ examples/python/compression/client.py | 76 ++++++++++++ examples/python/compression/server.py | 109 ++++++++++++++++++ .../test/compression_example_test.py | 62 ++++++++++ 5 files changed, 349 insertions(+) create mode 100644 examples/python/compression/BUILD.bazel create mode 100644 examples/python/compression/README.md create mode 100644 examples/python/compression/client.py create mode 100644 examples/python/compression/server.py create mode 100644 examples/python/compression/test/compression_example_test.py diff --git a/examples/python/compression/BUILD.bazel b/examples/python/compression/BUILD.bazel new file mode 100644 index 00000000000..b95d7cccc77 --- /dev/null +++ b/examples/python/compression/BUILD.bazel @@ -0,0 +1,44 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +py_binary( + name = "server", + srcs = ["server.py"], + deps = [ + "//src/python/grpcio/grpc:grpcio", + "//examples:py_helloworld", + ], + srcs_version = "PY2AND3", +) + +py_binary( + name = "client", + srcs = ["client.py"], + deps = [ + "//src/python/grpcio/grpc:grpcio", + "//examples:py_helloworld", + ], + srcs_version = "PY2AND3", +) + +py_test( + name = "test/compression_example_test", + srcs = ["test/compression_example_test.py"], + srcs_version = "PY2AND3", + data = [ + ":client", + ":server", + ], + size = "small", +) diff --git a/examples/python/compression/README.md b/examples/python/compression/README.md new file mode 100644 index 00000000000..c719bba07f8 --- /dev/null +++ b/examples/python/compression/README.md @@ -0,0 +1,58 @@ +## Compression with gRPC Python + +gRPC offers lossless compression options in order to decrease the number of bits +transferred over the wire. Three levels of compression are available: + + - `grpc.Compression.NoCompression` - No compression is applied to the payload. (default) + - `grpc.Compression.Deflate` - The "Deflate" algorithm is applied to the payload. + - `grpc.Compression.Gzip` - The Gzip algorithm is applied to the payload. + +The default option on both clients and servers is `grpc.Compression.NoCompression`. + +See [the gRPC Compression Spec](https://github.com/grpc/grpc/blob/master/doc/compression.md) +for more information. + +### Client Side Compression + +Compression may be set at two levels on the client side. + +#### At the channel level + +```python +with grpc.insecure_channel('foo.bar:1234', compression=grpc.Compression.Gzip) as channel: + use_channel(channel) +``` + +#### At the call level + +Setting the compression method at the call level will override any settings on +the channel level. + +```python +stub = helloworld_pb2_grpc.GreeterStub(channel) +response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'), + compression=grpc.Compression.Deflate) +``` + + +### Server Side Compression + +Additionally, compression may be set at two levels on the server side. + +#### On the entire server + +```python +server = grpc.server(futures.ThreadPoolExecutor(), + compression=grpc.Compression.Gzip) +``` + +#### For an individual RPC + +```python +def SayHello(self, request, context): + context.set_response_compression(grpc.Compression.NoCompression) + return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name) +``` + +Setting the compression method for an individual RPC will override any setting +supplied at server creation time. diff --git a/examples/python/compression/client.py b/examples/python/compression/client.py new file mode 100644 index 00000000000..444f14c1f68 --- /dev/null +++ b/examples/python/compression/client.py @@ -0,0 +1,76 @@ +# Copyright 2019 the gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""An example of compression on the client side with gRPC.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import argparse +import logging +import grpc + +from examples import helloworld_pb2 +from examples import helloworld_pb2_grpc + +_DESCRIPTION = 'A client capable of compression.' +_COMPRESSION_OPTIONS = { + "none": grpc.Compression.NoCompression, + "deflate": grpc.Compression.Deflate, + "gzip": grpc.Compression.Gzip, +} + +_LOGGER = logging.getLogger(__name__) + + +def run_client(channel_compression, call_compression, target): + with grpc.insecure_channel( + target, compression=channel_compression) as channel: + stub = helloworld_pb2_grpc.GreeterStub(channel) + response = stub.SayHello( + helloworld_pb2.HelloRequest(name='you'), + compression=call_compression, + wait_for_ready=True) + print("Response: {}".format(response)) + + +def main(): + parser = argparse.ArgumentParser(description=_DESCRIPTION) + parser.add_argument( + '--channel_compression', + default='none', + nargs='?', + choices=_COMPRESSION_OPTIONS.keys(), + help='The compression method to use for the channel.') + parser.add_argument( + '--call_compression', + default='none', + nargs='?', + choices=_COMPRESSION_OPTIONS.keys(), + help='The compression method to use for an individual call.') + parser.add_argument( + '--server', + default='localhost:50051', + type=str, + nargs='?', + help='The host-port pair at which to reach the server.') + args = parser.parse_args() + channel_compression = _COMPRESSION_OPTIONS[args.channel_compression] + call_compression = _COMPRESSION_OPTIONS[args.call_compression] + run_client(channel_compression, call_compression, args.server) + + +if __name__ == "__main__": + logging.basicConfig() + main() diff --git a/examples/python/compression/server.py b/examples/python/compression/server.py new file mode 100644 index 00000000000..bc13e60cb5b --- /dev/null +++ b/examples/python/compression/server.py @@ -0,0 +1,109 @@ +# Copyright 2019 the gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""An example of compression on the server side with gRPC.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +from concurrent import futures +import argparse +import logging +import threading +import time +import grpc + +from examples import helloworld_pb2 +from examples import helloworld_pb2_grpc + +_DESCRIPTION = 'A server capable of compression.' +_COMPRESSION_OPTIONS = { + "none": grpc.Compression.NoCompression, + "deflate": grpc.Compression.Deflate, + "gzip": grpc.Compression.Gzip, +} +_LOGGER = logging.getLogger(__name__) + +_SERVER_HOST = 'localhost' +_ONE_DAY_IN_SECONDS = 60 * 60 * 24 + + +class Greeter(helloworld_pb2_grpc.GreeterServicer): + + def __init__(self, no_compress_every_n): + super(Greeter, self).__init__() + self._no_compress_every_n = 0 + self._request_counter = 0 + self._counter_lock = threading.RLock() + + def _should_suppress_compression(self): + suppress_compression = False + with self._counter_lock: + if self._no_compress_every_n and self._request_counter % self._no_compress_every_n == 0: + suppress_compression = True + self._request_counter += 1 + return suppress_compression + + def SayHello(self, request, context): + if self._should_suppress_compression(): + context.set_response_compression(grpc.Compression.NoCompression) + return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name) + + +def run_server(server_compression, no_compress_every_n, port): + server = grpc.server( + futures.ThreadPoolExecutor(), + compression=server_compression, + options=(('grpc.so_reuseport', 1),)) + helloworld_pb2_grpc.add_GreeterServicer_to_server( + Greeter(no_compress_every_n), server) + address = '{}:{}'.format(_SERVER_HOST, port) + server.add_insecure_port(address) + server.start() + print("Server listening at '{}'".format(address)) + try: + while True: + time.sleep(_ONE_DAY_IN_SECONDS) + except KeyboardInterrupt: + server.stop(None) + + +def main(): + parser = argparse.ArgumentParser(description=_DESCRIPTION) + parser.add_argument( + '--server_compression', + default='none', + nargs='?', + choices=_COMPRESSION_OPTIONS.keys(), + help='The default compression method for the server.') + parser.add_argument( + '--no_compress_every_n', + type=int, + default=0, + nargs='?', + help='If set, every nth reply will be uncompressed.') + parser.add_argument( + '--port', + type=int, + default=50051, + nargs='?', + help='The port on which the server will listen.') + args = parser.parse_args() + run_server(_COMPRESSION_OPTIONS[args.server_compression], + args.no_compress_every_n, args.port) + + +if __name__ == "__main__": + logging.basicConfig() + main() diff --git a/examples/python/compression/test/compression_example_test.py b/examples/python/compression/test/compression_example_test.py new file mode 100644 index 00000000000..7d25379683f --- /dev/null +++ b/examples/python/compression/test/compression_example_test.py @@ -0,0 +1,62 @@ +# Copyright 2019 the gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Test for compression example.""" + +import contextlib +import os +import socket +import subprocess +import unittest + +_BINARY_DIR = os.path.realpath( + os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')) +_SERVER_PATH = os.path.join(_BINARY_DIR, 'server') +_CLIENT_PATH = os.path.join(_BINARY_DIR, 'client') + + +@contextlib.contextmanager +def _get_port(): + sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) + sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) + if sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT) == 0: + raise RuntimeError("Failed to set SO_REUSEPORT.") + sock.bind(('', 0)) + try: + yield sock.getsockname()[1] + finally: + sock.close() + + +class CompressionExampleTest(unittest.TestCase): + + def test_compression_example(self): + with _get_port() as test_port: + server_process = subprocess.Popen((_SERVER_PATH, '--port', + str(test_port), + '--server_compression', 'gzip')) + try: + server_target = 'localhost:{}'.format(test_port) + client_process = subprocess.Popen( + (_CLIENT_PATH, '--server', server_target, + '--channel_compression', 'gzip')) + client_return_code = client_process.wait() + self.assertEqual(0, client_return_code) + self.assertIsNone(server_process.poll()) + finally: + server_process.kill() + server_process.wait() + + +if __name__ == '__main__': + unittest.main(verbosity=2) From 8fb51946bf1a14039f5aab9abeb4144008dfb1e9 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Fri, 21 Jun 2019 14:01:27 -0700 Subject: [PATCH 0645/1555] Fix multiprocessing example for MacOS. A closer reading of the API for getsockopt revealed that we were depending on an implementation detail of getsockopt on Linux. This assumption breaks down on MacOS. getsockopt merely guarantees that it will return on 0 in case of failure and a value greater than 0 in case of success. There is no guarantee as to *which* non-zero value you will receive. On Linux, it seems to be 1, the value which was explicitly set. On MacOS, it seems to be the value of the FLAG which was set, i.e. 512 for SO_REUSEPORT. This commit ensures the check we use does not rely on either of these implementation details. --- examples/python/multiprocessing/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/python/multiprocessing/server.py b/examples/python/multiprocessing/server.py index a05eb9edda0..b1e5951a8b0 100644 --- a/examples/python/multiprocessing/server.py +++ b/examples/python/multiprocessing/server.py @@ -87,7 +87,7 @@ def _reserve_port(): """Find and reserve a port for all subprocesses to use.""" sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) - if sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT) != 1: + if sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT) == 0: raise RuntimeError("Failed to set SO_REUSEPORT.") sock.bind(('', 0)) try: From bff4dd1b2d6af9e467243b4424999a3c307c0c0c Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Mon, 3 Jun 2019 13:45:20 -0700 Subject: [PATCH 0646/1555] Fast-path for no-error case for grpc_error_get_status. For each client side call, we execute grpc_error_get_status; in the common case that there is no error, we save roughly 30 instructions and a call to strlen. --- .../filters/http/client/http_client_filter.cc | 2 +- .../filters/http/client_authority_filter.cc | 4 +- .../chttp2/transport/hpack_parser.cc | 10 ++-- .../transport/chttp2/transport/hpack_table.cc | 6 ++- .../ext/transport/inproc/inproc_transport.cc | 2 +- src/core/lib/iomgr/error.cc | 24 ++++++--- src/core/lib/slice/slice.cc | 49 +++++++++---------- src/core/lib/slice/slice_internal.h | 15 ++++++ src/core/lib/transport/error_utils.cc | 11 ++++- .../run_tests/sanity/core_banned_functions.py | 1 + 10 files changed, 78 insertions(+), 46 deletions(-) diff --git a/src/core/ext/filters/http/client/http_client_filter.cc b/src/core/ext/filters/http/client/http_client_filter.cc index 4ef6c1f610e..d014460b34e 100644 --- a/src/core/ext/filters/http/client/http_client_filter.cc +++ b/src/core/ext/filters/http/client/http_client_filter.cc @@ -558,7 +558,7 @@ static grpc_slice user_agent_from_args(const grpc_channel_args* args, tmp = gpr_strvec_flatten(&v, nullptr); gpr_strvec_destroy(&v); - result = grpc_slice_intern(grpc_slice_from_static_string(tmp)); + result = grpc_slice_intern(grpc_slice_from_static_string_internal(tmp)); gpr_free(tmp); return result; diff --git a/src/core/ext/filters/http/client_authority_filter.cc b/src/core/ext/filters/http/client_authority_filter.cc index 85b30bc13ca..4bd666ecfee 100644 --- a/src/core/ext/filters/http/client_authority_filter.cc +++ b/src/core/ext/filters/http/client_authority_filter.cc @@ -101,8 +101,8 @@ grpc_error* init_channel_elem(grpc_channel_element* elem, return GRPC_ERROR_CREATE_FROM_STATIC_STRING( "GRPC_ARG_DEFAULT_AUTHORITY channel arg. must be a string"); } - chand->default_authority = - grpc_slice_intern(grpc_slice_from_static_string(default_authority_str)); + chand->default_authority = grpc_slice_intern( + grpc_slice_from_static_string_internal(default_authority_str)); chand->default_authority_mdelem = grpc_mdelem_create( GRPC_MDSTR_AUTHORITY, chand->default_authority, nullptr); GPR_ASSERT(!args->is_last); diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index 7d5c39e5144..8db0c96cc52 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -670,7 +670,7 @@ static grpc_slice take_string(grpc_chttp2_hpack_parser* p, str->copied = true; str->data.referenced = grpc_empty_slice(); } else if (intern) { - s = grpc_slice_intern(grpc_slice_from_static_buffer( + s = grpc_slice_intern(grpc_slice_from_static_buffer_internal( str->data.copied.str, str->data.copied.length)); } else { s = grpc_slice_from_copied_buffer(str->data.copied.str, @@ -1496,14 +1496,14 @@ static grpc_error* parse_key_string(grpc_chttp2_hpack_parser* p, static bool is_binary_literal_header(grpc_chttp2_hpack_parser* p) { /* We know that either argument here is a reference counter slice. - * 1. If a result of grpc_slice_from_static_buffer, the refcount is set to - * NoopRefcount. + * 1. If a result of grpc_slice_from_static_buffer_internal, the refcount is + * set to kNoopRefcount. * 2. If it's p->key.data.referenced, then p->key.copied was set to false, * which occurs in begin_parse_string() - where the refcount is set to * p->current_slice_refcount, which is not null. */ return grpc_is_refcounted_slice_binary_header( - p->key.copied ? grpc_slice_from_static_buffer(p->key.data.copied.str, - p->key.data.copied.length) + p->key.copied ? grpc_slice_from_static_buffer_internal( + p->key.data.copied.str, p->key.data.copied.length) : p->key.data.referenced); } diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.cc b/src/core/ext/transport/chttp2/transport/hpack_table.cc index f9e97cc5566..9d1ac4b370f 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_table.cc @@ -29,6 +29,7 @@ #include "src/core/lib/debug/trace.h" #include "src/core/lib/gpr/murmur_hash.h" +#include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/validate_metadata.h" #include "src/core/lib/transport/static_metadata.h" @@ -182,9 +183,10 @@ void grpc_chttp2_hptbl_init(grpc_chttp2_hptbl* tbl) { memset(tbl->ents, 0, sizeof(*tbl->ents) * tbl->cap_entries); for (i = 1; i <= GRPC_CHTTP2_LAST_STATIC_ENTRY; i++) { tbl->static_ents[i - 1] = grpc_mdelem_from_slices( - grpc_slice_intern(grpc_slice_from_static_string(static_table[i].key)), grpc_slice_intern( - grpc_slice_from_static_string(static_table[i].value))); + grpc_slice_from_static_string_internal(static_table[i].key)), + grpc_slice_intern( + grpc_slice_from_static_string_internal(static_table[i].value))); } } diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc index 8da89851a69..8cb9ac4a2fd 100644 --- a/src/core/ext/transport/inproc/inproc_transport.cc +++ b/src/core/ext/transport/inproc/inproc_transport.cc @@ -1203,7 +1203,7 @@ void inproc_transports_create(grpc_transport** server_transport, */ void grpc_inproc_transport_init(void) { grpc_core::ExecCtx exec_ctx; - g_empty_slice = grpc_slice_from_static_buffer(nullptr, 0); + g_empty_slice = grpc_slice_from_static_buffer_internal(nullptr, 0); grpc_slice key_tmp = grpc_slice_from_static_string(":path"); g_fake_path_key = grpc_slice_intern(key_tmp); diff --git a/src/core/lib/iomgr/error.cc b/src/core/lib/iomgr/error.cc index ebec9dc704a..eb44c9a2c90 100644 --- a/src/core/lib/iomgr/error.cc +++ b/src/core/lib/iomgr/error.cc @@ -447,13 +447,17 @@ grpc_error* grpc_error_set_int(grpc_error* src, grpc_error_ints which, typedef struct { grpc_status_code code; const char* msg; + size_t len; } special_error_status_map; -static const special_error_status_map error_status_map[] = { - {GRPC_STATUS_OK, ""}, // GRPC_ERROR_NONE - {GRPC_STATUS_INVALID_ARGUMENT, ""}, // GRPC_ERROR_RESERVED_1 - {GRPC_STATUS_RESOURCE_EXHAUSTED, "Out of memory"}, // GRPC_ERROR_OOM - {GRPC_STATUS_INVALID_ARGUMENT, ""}, // GRPC_ERROR_RESERVED_2 - {GRPC_STATUS_CANCELLED, "Cancelled"}, // GRPC_ERROR_CANCELLED + +const special_error_status_map error_status_map[] = { + {GRPC_STATUS_OK, "", 0}, // GRPC_ERROR_NONE + {GRPC_STATUS_INVALID_ARGUMENT, "", 0}, // GRPC_ERROR_RESERVED_1 + {GRPC_STATUS_RESOURCE_EXHAUSTED, "Out of memory", + strlen("Out of memory")}, // GRPC_ERROR_OOM + {GRPC_STATUS_INVALID_ARGUMENT, "", 0}, // GRPC_ERROR_RESERVED_2 + {GRPC_STATUS_CANCELLED, "Cancelled", + strlen("Cancelled")}, // GRPC_ERROR_CANCELLED }; bool grpc_error_get_int(grpc_error* err, grpc_error_ints which, intptr_t* p) { @@ -483,8 +487,12 @@ bool grpc_error_get_str(grpc_error* err, grpc_error_strs which, grpc_slice* str) { if (grpc_error_is_special(err)) { if (which != GRPC_ERROR_STR_GRPC_MESSAGE) return false; - *str = grpc_slice_from_static_string( - error_status_map[reinterpret_cast(err)].msg); + const special_error_status_map& msg = + error_status_map[reinterpret_cast(err)]; + str->refcount = &grpc_core::kNoopRefcount; + str->data.refcounted.bytes = + reinterpret_cast(const_cast(msg.msg)); + str->data.refcounted.length = msg.len; return true; } uint8_t slot = err->strs[which]; diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc index eebf66bb882..57862518feb 100644 --- a/src/core/lib/slice/slice.cc +++ b/src/core/lib/slice/slice.cc @@ -66,32 +66,13 @@ void grpc_slice_unref(grpc_slice slice) { } } +namespace grpc_core { + /* grpc_slice_from_static_string support structure - a refcount that does nothing */ -static grpc_slice_refcount NoopRefcount = - grpc_slice_refcount(grpc_slice_refcount::Type::NOP); - -size_t grpc_slice_memory_usage(grpc_slice s) { - if (s.refcount == nullptr || s.refcount == &NoopRefcount) { - return 0; - } else { - return s.data.refcounted.length; - } -} - -grpc_slice grpc_slice_from_static_buffer(const void* s, size_t len) { - grpc_slice slice; - slice.refcount = &NoopRefcount; - slice.data.refcounted.bytes = (uint8_t*)s; - slice.data.refcounted.length = len; - return slice; -} - -grpc_slice grpc_slice_from_static_string(const char* s) { - return grpc_slice_from_static_buffer(s, strlen(s)); -} - -namespace grpc_core { +grpc_slice_refcount kNoopRefcount(grpc_slice_refcount::Type::NOP); +static_assert(std::is_trivially_destructible::value, + "kNoopRefcount must be trivially destructible."); /* grpc_slice_new support structures - we create a refcount object extended with the user provided data pointer & destroy function */ @@ -122,6 +103,22 @@ class NewSliceRefcount { } // namespace grpc_core +size_t grpc_slice_memory_usage(grpc_slice s) { + if (s.refcount == nullptr || s.refcount == &grpc_core::kNoopRefcount) { + return 0; + } else { + return s.data.refcounted.length; + } +} + +grpc_slice grpc_slice_from_static_buffer(const void* s, size_t len) { + return grpc_slice_from_static_buffer_internal(s, len); +} + +grpc_slice grpc_slice_from_static_string(const char* s) { + return grpc_slice_from_static_buffer_internal(s, strlen(s)); +} + grpc_slice grpc_slice_new_with_user_data(void* p, size_t len, void (*destroy)(void*), void* user_data) { @@ -375,10 +372,10 @@ grpc_slice grpc_slice_split_tail_maybe_ref(grpc_slice* source, size_t split, switch (ref_whom) { case GRPC_SLICE_REF_TAIL: tail.refcount = source->refcount->sub_refcount(); - source->refcount = &NoopRefcount; + source->refcount = &grpc_core::kNoopRefcount; break; case GRPC_SLICE_REF_HEAD: - tail.refcount = &NoopRefcount; + tail.refcount = &grpc_core::kNoopRefcount; source->refcount = source->refcount->sub_refcount(); break; case GRPC_SLICE_REF_BOTH: diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index c6943fe6563..54badeb9ab9 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -171,6 +171,8 @@ struct grpc_slice_refcount { namespace grpc_core { +extern grpc_slice_refcount kNoopRefcount; + struct InternedSliceRefcount { static void Destroy(void* arg) { auto* rc = static_cast(arg); @@ -312,4 +314,17 @@ grpc_slice grpc_slice_from_moved_string(grpc_core::UniquePtr p); // 0. All other slices will return the size of the allocated chars. size_t grpc_slice_memory_usage(grpc_slice s); +inline grpc_slice grpc_slice_from_static_buffer_internal(const void* s, + size_t len) { + grpc_slice slice; + slice.refcount = &grpc_core::kNoopRefcount; + slice.data.refcounted.bytes = (uint8_t*)s; + slice.data.refcounted.length = len; + return slice; +} + +inline grpc_slice grpc_slice_from_static_string_internal(const char* s) { + return grpc_slice_from_static_buffer_internal(s, strlen(s)); +} + #endif /* GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H */ diff --git a/src/core/lib/transport/error_utils.cc b/src/core/lib/transport/error_utils.cc index eb4e8c3a282..5be98c9f04f 100644 --- a/src/core/lib/transport/error_utils.cc +++ b/src/core/lib/transport/error_utils.cc @@ -22,6 +22,7 @@ #include #include "src/core/lib/iomgr/error_internal.h" +#include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/status_conversion.h" static grpc_error* recursively_find_error_with_field(grpc_error* error, @@ -52,7 +53,15 @@ void grpc_error_get_status(grpc_error* error, grpc_millis deadline, if (GPR_LIKELY(error == GRPC_ERROR_NONE)) { if (code != nullptr) *code = GRPC_STATUS_OK; if (slice != nullptr) { - grpc_error_get_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, slice); + // Normally, we call grpc_error_get_str( + // error, GRPC_ERROR_STR_GRPC_MESSAGE, slice). + // We can fastpath since we know that: + // 1) Error is null + // 2) which == GRPC_ERROR_STR_GRPC_MESSAGE + // 3) The resulting slice is statically known. + // 4) Said resulting slice is of length 0 (""). + // This means 3 movs, instead of 10s of instructions and a strlen. + *slice = grpc_slice_from_static_string_internal(""); } if (http_error != nullptr) { *http_error = GRPC_HTTP2_NO_ERROR; diff --git a/tools/run_tests/sanity/core_banned_functions.py b/tools/run_tests/sanity/core_banned_functions.py index ce9ff0dae21..a9c986b3ac2 100755 --- a/tools/run_tests/sanity/core_banned_functions.py +++ b/tools/run_tests/sanity/core_banned_functions.py @@ -23,6 +23,7 @@ os.chdir(os.path.join(os.path.dirname(sys.argv[0]), '../../..')) # map of banned function signature to whitelist BANNED_EXCEPT = { + 'grpc_slice_from_static_buffer(': ['src/core/lib/slice/slice.cc'], 'grpc_resource_quota_ref(': ['src/core/lib/iomgr/resource_quota.cc'], 'grpc_resource_quota_unref(': ['src/core/lib/iomgr/resource_quota.cc', 'src/core/lib/surface/server.cc'], From d73abc7b56d317058b507ab4752a3a0abe65777d Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 21 Jun 2019 16:23:16 -0700 Subject: [PATCH 0647/1555] Modify comments style --- src/core/lib/gprpp/thd.h | 5 ++--- src/core/lib/gprpp/thd_posix.cc | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/core/lib/gprpp/thd.h b/src/core/lib/gprpp/thd.h index 6f29f82427f..0af33faa119 100644 --- a/src/core/lib/gprpp/thd.h +++ b/src/core/lib/gprpp/thd.h @@ -64,9 +64,8 @@ class Thread { } bool tracked() const { return tracked_; } - /// Set thread stack size (in bytes). Set to 0 will reset stack size to - /// default value, which is 64KB for Windows threads and 2MB for Posix(x86) - /// threads. + /// Sets thread stack size (in bytes). Sets to 0 will use the default stack + /// size which is 64KB for Windows threads and 2MB for Posix(x86) threads. Options& set_stack_size(size_t bytes) { stack_size_ = bytes; return *this; diff --git a/src/core/lib/gprpp/thd_posix.cc b/src/core/lib/gprpp/thd_posix.cc index dbb9c82cb06..7415231e97f 100644 --- a/src/core/lib/gprpp/thd_posix.cc +++ b/src/core/lib/gprpp/thd_posix.cc @@ -55,7 +55,7 @@ size_t RoundUpToPageSize(size_t size) { return (size + page_size - 1) & ~(page_size - 1); } -// Return the minimum valid stack size that can be passed to +// Returns the minimum valid stack size that can be passed to // pthread_attr_setstacksize. size_t MinValidStackSize(size_t request_size) { if (request_size < _SC_THREAD_STACK_MIN) { From a68e7bc4618da2d768582a382ae89bf5d3d76052 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 21 Jun 2019 17:16:29 -0700 Subject: [PATCH 0648/1555] Remove extra header file, change to c test, change new/delete --- BUILD | 4 +- CMakeLists.txt | 76 ++++++++--------- Makefile | 84 ++++++++----------- build.yaml | 21 +++-- src/core/lib/iomgr/executor/mpmcqueue.cc | 12 --- src/core/lib/iomgr/executor/mpmcqueue.h | 4 +- test/core/iomgr/mpmcqueue_test.cc | 35 ++++---- .../generated/sources_and_headers.json | 34 ++++---- tools/run_tests/generated/tests.json | 48 +++++------ 9 files changed, 141 insertions(+), 177 deletions(-) diff --git a/BUILD b/BUILD index 10933cb24f1..ef485ac4277 100644 --- a/BUILD +++ b/BUILD @@ -782,6 +782,7 @@ grpc_cc_library( "src/core/lib/iomgr/ev_windows.cc", "src/core/lib/iomgr/exec_ctx.cc", "src/core/lib/iomgr/executor.cc", + "src/core/lib/iomgr/executor/mpmcqueue.cc", "src/core/lib/iomgr/fork_posix.cc", "src/core/lib/iomgr/fork_windows.cc", "src/core/lib/iomgr/gethostname_fallback.cc", @@ -837,7 +838,6 @@ grpc_cc_library( "src/core/lib/iomgr/tcp_server_windows.cc", "src/core/lib/iomgr/tcp_uv.cc", "src/core/lib/iomgr/tcp_windows.cc", - "src/core/lib/iomgr/executor/mpmcqueue.cc", "src/core/lib/iomgr/time_averaged_stats.cc", "src/core/lib/iomgr/timer.cc", "src/core/lib/iomgr/timer_custom.cc", @@ -940,6 +940,7 @@ grpc_cc_library( "src/core/lib/iomgr/ev_posix.h", "src/core/lib/iomgr/exec_ctx.h", "src/core/lib/iomgr/executor.h", + "src/core/lib/iomgr/executor/mpmcqueue.h", "src/core/lib/iomgr/gethostname.h", "src/core/lib/iomgr/gevent_util.h", "src/core/lib/iomgr/grpc_if_nametoindex.h", @@ -983,7 +984,6 @@ grpc_cc_library( "src/core/lib/iomgr/tcp_server.h", "src/core/lib/iomgr/tcp_server_utils_posix.h", "src/core/lib/iomgr/tcp_windows.h", - "src/core/lib/iomgr/executor/mpmcqueue.h", "src/core/lib/iomgr/time_averaged_stats.h", "src/core/lib/iomgr/timer.h", "src/core/lib/iomgr/timer_custom.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 47d8b3c6d0f..8dc4605297a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -378,6 +378,7 @@ add_dependencies(buildtests_c memory_usage_test) endif() add_dependencies(buildtests_c message_compress_test) add_dependencies(buildtests_c minimal_stack_is_minimal_test) +add_dependencies(buildtests_c mpmcqueue_test) add_dependencies(buildtests_c multiple_server_queues_test) add_dependencies(buildtests_c murmur_hash_test) add_dependencies(buildtests_c no_server_test) @@ -663,7 +664,6 @@ add_dependencies(buildtests_cxx memory_test) add_dependencies(buildtests_cxx message_allocator_end2end_test) add_dependencies(buildtests_cxx metrics_client) add_dependencies(buildtests_cxx mock_test) -add_dependencies(buildtests_cxx mpmcqueue_test) add_dependencies(buildtests_cxx nonblocking_test) add_dependencies(buildtests_cxx noop-benchmark) add_dependencies(buildtests_cxx optional_test) @@ -9364,6 +9364,40 @@ target_link_libraries(minimal_stack_is_minimal_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) +add_executable(mpmcqueue_test + test/core/iomgr/mpmcqueue_test.cc +) + + +target_include_directories(mpmcqueue_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} +) + +target_link_libraries(mpmcqueue_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + grpc + gpr +) + + # avoid dependency on libstdc++ + if (_gRPC_CORE_NOSTDCXX_FLAGS) + set_target_properties(mpmcqueue_test PROPERTIES LINKER_LANGUAGE C) + target_compile_options(mpmcqueue_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) + endif() + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + add_executable(multiple_server_queues_test test/core/end2end/multiple_server_queues_test.cc ) @@ -15003,46 +15037,6 @@ target_link_libraries(mock_test ) -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) - -add_executable(mpmcqueue_test - test/core/iomgr/mpmcqueue_test.cc - third_party/googletest/googletest/src/gtest-all.cc - third_party/googletest/googlemock/src/gmock-all.cc -) - - -target_include_directories(mpmcqueue_test - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} - PRIVATE third_party/googletest/googletest/include - PRIVATE third_party/googletest/googletest - PRIVATE third_party/googletest/googlemock/include - PRIVATE third_party/googletest/googlemock - PRIVATE ${_gRPC_PROTO_GENS_DIR} -) - -target_link_libraries(mpmcqueue_test - ${_gRPC_PROTOBUF_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc++_test_util - grpc_test_util - grpc++ - grpc - gpr - ${_gRPC_GFLAGS_LIBRARIES} -) - - endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index 6bcf8472d3e..7562a129995 100644 --- a/Makefile +++ b/Makefile @@ -1092,6 +1092,7 @@ memory_usage_server: $(BINDIR)/$(CONFIG)/memory_usage_server memory_usage_test: $(BINDIR)/$(CONFIG)/memory_usage_test message_compress_test: $(BINDIR)/$(CONFIG)/message_compress_test minimal_stack_is_minimal_test: $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test +mpmcqueue_test: $(BINDIR)/$(CONFIG)/mpmcqueue_test multiple_server_queues_test: $(BINDIR)/$(CONFIG)/multiple_server_queues_test murmur_hash_test: $(BINDIR)/$(CONFIG)/murmur_hash_test nanopb_fuzzer_response_test: $(BINDIR)/$(CONFIG)/nanopb_fuzzer_response_test @@ -1240,7 +1241,6 @@ memory_test: $(BINDIR)/$(CONFIG)/memory_test message_allocator_end2end_test: $(BINDIR)/$(CONFIG)/message_allocator_end2end_test metrics_client: $(BINDIR)/$(CONFIG)/metrics_client mock_test: $(BINDIR)/$(CONFIG)/mock_test -mpmcqueue_test: $(BINDIR)/$(CONFIG)/mpmcqueue_test nonblocking_test: $(BINDIR)/$(CONFIG)/nonblocking_test noop-benchmark: $(BINDIR)/$(CONFIG)/noop-benchmark optional_test: $(BINDIR)/$(CONFIG)/optional_test @@ -1516,6 +1516,7 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/memory_usage_test \ $(BINDIR)/$(CONFIG)/message_compress_test \ $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test \ + $(BINDIR)/$(CONFIG)/mpmcqueue_test \ $(BINDIR)/$(CONFIG)/multiple_server_queues_test \ $(BINDIR)/$(CONFIG)/murmur_hash_test \ $(BINDIR)/$(CONFIG)/no_server_test \ @@ -1707,7 +1708,6 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/message_allocator_end2end_test \ $(BINDIR)/$(CONFIG)/metrics_client \ $(BINDIR)/$(CONFIG)/mock_test \ - $(BINDIR)/$(CONFIG)/mpmcqueue_test \ $(BINDIR)/$(CONFIG)/nonblocking_test \ $(BINDIR)/$(CONFIG)/noop-benchmark \ $(BINDIR)/$(CONFIG)/optional_test \ @@ -1871,7 +1871,6 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/message_allocator_end2end_test \ $(BINDIR)/$(CONFIG)/metrics_client \ $(BINDIR)/$(CONFIG)/mock_test \ - $(BINDIR)/$(CONFIG)/mpmcqueue_test \ $(BINDIR)/$(CONFIG)/nonblocking_test \ $(BINDIR)/$(CONFIG)/noop-benchmark \ $(BINDIR)/$(CONFIG)/optional_test \ @@ -2112,6 +2111,8 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/message_compress_test || ( echo test message_compress_test failed ; exit 1 ) $(E) "[RUN] Testing minimal_stack_is_minimal_test" $(Q) $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test || ( echo test minimal_stack_is_minimal_test failed ; exit 1 ) + $(E) "[RUN] Testing mpmcqueue_test" + $(Q) $(BINDIR)/$(CONFIG)/mpmcqueue_test || ( echo test mpmcqueue_test failed ; exit 1 ) $(E) "[RUN] Testing multiple_server_queues_test" $(Q) $(BINDIR)/$(CONFIG)/multiple_server_queues_test || ( echo test multiple_server_queues_test failed ; exit 1 ) $(E) "[RUN] Testing murmur_hash_test" @@ -2374,8 +2375,6 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/message_allocator_end2end_test || ( echo test message_allocator_end2end_test failed ; exit 1 ) $(E) "[RUN] Testing mock_test" $(Q) $(BINDIR)/$(CONFIG)/mock_test || ( echo test mock_test failed ; exit 1 ) - $(E) "[RUN] Testing mpmcqueue_test" - $(Q) $(BINDIR)/$(CONFIG)/mpmcqueue_test || ( echo test mpmcqueue_test failed ; exit 1 ) $(E) "[RUN] Testing nonblocking_test" $(Q) $(BINDIR)/$(CONFIG)/nonblocking_test || ( echo test nonblocking_test failed ; exit 1 ) $(E) "[RUN] Testing noop-benchmark" @@ -12131,6 +12130,38 @@ endif endif +MPMCQUEUE_TEST_SRC = \ + test/core/iomgr/mpmcqueue_test.cc \ + +MPMCQUEUE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(MPMCQUEUE_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/mpmcqueue_test: openssl_dep_error + +else + + + +$(BINDIR)/$(CONFIG)/mpmcqueue_test: $(MPMCQUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LD) $(LDFLAGS) $(MPMCQUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/mpmcqueue_test + +endif + +$(OBJDIR)/$(CONFIG)/test/core/iomgr/mpmcqueue_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_mpmcqueue_test: $(MPMCQUEUE_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(MPMCQUEUE_TEST_OBJS:.o=.dep) +endif +endif + + MULTIPLE_SERVER_QUEUES_TEST_SRC = \ test/core/end2end/multiple_server_queues_test.cc \ @@ -17973,49 +18004,6 @@ endif endif -MPMCQUEUE_TEST_SRC = \ - test/core/iomgr/mpmcqueue_test.cc \ - -MPMCQUEUE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(MPMCQUEUE_TEST_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/mpmcqueue_test: openssl_dep_error - -else - - - - -ifeq ($(NO_PROTOBUF),true) - -# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. - -$(BINDIR)/$(CONFIG)/mpmcqueue_test: protobuf_dep_error - -else - -$(BINDIR)/$(CONFIG)/mpmcqueue_test: $(PROTOBUF_DEP) $(MPMCQUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(MPMCQUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/mpmcqueue_test - -endif - -endif - -$(OBJDIR)/$(CONFIG)/test/core/iomgr/mpmcqueue_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a - -deps_mpmcqueue_test: $(MPMCQUEUE_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(MPMCQUEUE_TEST_OBJS:.o=.dep) -endif -endif - - NONBLOCKING_TEST_SRC = \ test/cpp/end2end/nonblocking_test.cc \ diff --git a/build.yaml b/build.yaml index 76447a1bebd..53f40398668 100644 --- a/build.yaml +++ b/build.yaml @@ -3268,6 +3268,16 @@ targets: - grpc - gpr uses_polling: false +- name: mpmcqueue_test + build: test + language: c + src: + - test/core/iomgr/mpmcqueue_test.cc + deps: + - grpc_test_util + - grpc + - gpr + uses_polling: false - name: multiple_server_queues_test build: test language: c @@ -5230,17 +5240,6 @@ targets: - grpc++ - grpc - gpr -- name: mpmcqueue_test - build: test - language: c++ - src: - - test/core/iomgr/mpmcqueue_test.cc - deps: - - grpc++_test_util - - grpc_test_util - - grpc++ - - grpc - - gpr - name: nonblocking_test gtest: true build: test diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index 7290c68db94..fff078035c8 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -20,18 +20,6 @@ #include "src/core/lib/iomgr/executor/mpmcqueue.h" -#include -#include -#include -#include -#include -#include -#include - -#include "src/core/lib/debug/stats.h" -#include "src/core/lib/gprpp/memory.h" -#include "src/core/lib/gprpp/sync.h" - namespace grpc_core { DebugOnlyTraceFlag thread_pool(false, "thread_pool_trace"); diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index 7022cf492f2..6b071a2fd68 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -21,9 +21,6 @@ #include -#include -#include - #include "src/core/lib/debug/stats.h" #include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/atomic.h" @@ -80,6 +77,7 @@ class InfLenFIFOQueue : public MPMCQueueInterface { // For Internal Use Only. // Removes the oldest element from the queue and returns it. This routine // will NOT check whether queue is empty, and it will NOT acquire mutex. + // Caller should do the check and acquire mutex before callling. void* PopFront(); struct Node { diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index fdcc2d6019f..f89fed24bc2 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -19,10 +19,7 @@ #include "src/core/lib/iomgr/executor/mpmcqueue.h" #include -#include -#include -#include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/thd.h" #include "test/core/util/test_config.h" @@ -51,9 +48,9 @@ class ProducerThread { ~ProducerThread() { for (int i = 0; i < num_items_; ++i) { GPR_ASSERT(items_[i]->done); - delete items_[i]; + grpc_core::Delete(items_[i]); } - delete[] items_; + gpr_free(items_); } void Start() { thd_.Start(); } @@ -61,9 +58,9 @@ class ProducerThread { private: void Run() { - items_ = new WorkItem*[num_items_]; + items_ = static_cast(gpr_zalloc(num_items_)); for (int i = 0; i < num_items_; ++i) { - items_[i] = new WorkItem(start_index_ + i); + items_[i] = grpc_core::New(start_index_ + i); queue_->Put(items_[i]); } } @@ -105,9 +102,10 @@ static void test_get_empty(void) { thds[i].Start(); } - WorkItem** items = new WorkItem*[THREAD_LARGE_ITERATION]; + WorkItem** items = + static_cast(gpr_zalloc(THREAD_SMALL_ITERATION)); for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { - items[i] = new WorkItem(i); + items[i] = grpc_core::New(i); queue.Put(static_cast(items[i])); } @@ -121,9 +119,9 @@ static void test_get_empty(void) { gpr_log(GPR_DEBUG, "Checking and Cleaning Up..."); for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { GPR_ASSERT(items[i]->done); - delete items[i]; + grpc_core::Delete(items[i]); } - delete[] items; + gpr_free(items); gpr_log(GPR_DEBUG, "Done."); } @@ -131,13 +129,13 @@ static void test_FIFO(void) { gpr_log(GPR_INFO, "test_FIFO"); grpc_core::InfLenFIFOQueue large_queue; for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { - large_queue.Put(static_cast(new WorkItem(i))); + large_queue.Put(static_cast(grpc_core::New(i))); } GPR_ASSERT(large_queue.count() == THREAD_LARGE_ITERATION); for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { WorkItem* item = static_cast(large_queue.Get()); GPR_ASSERT(i == item->index); - delete item; + grpc_core::Delete(item); } } @@ -146,13 +144,14 @@ static void test_many_thread(void) { const int num_work_thd = 10; const int num_get_thd = 20; grpc_core::InfLenFIFOQueue queue; - ProducerThread** work_thds = new ProducerThread*[num_work_thd]; + ProducerThread** work_thds = + static_cast(gpr_zalloc(num_work_thd)); grpc_core::Thread get_thds[num_get_thd]; gpr_log(GPR_DEBUG, "Fork ProducerThread..."); for (int i = 0; i < num_work_thd; ++i) { - work_thds[i] = new ProducerThread(&queue, i * THREAD_LARGE_ITERATION, - THREAD_LARGE_ITERATION); + work_thds[i] = grpc_core::New( + &queue, i * THREAD_LARGE_ITERATION, THREAD_LARGE_ITERATION); work_thds[i]->Start(); } gpr_log(GPR_DEBUG, "ProducerThread Started."); @@ -178,9 +177,9 @@ static void test_many_thread(void) { gpr_log(GPR_DEBUG, "All Getter Thread Terminated."); gpr_log(GPR_DEBUG, "Checking WorkItems and Cleaning Up..."); for (int i = 0; i < num_work_thd; ++i) { - delete work_thds[i]; + grpc_core::Delete(work_thds[i]); } - delete[] work_thds; + gpr_free(work_thds); gpr_log(GPR_DEBUG, "Done."); } diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 9bb1ddba930..4e5d5bece82 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -1626,6 +1626,22 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "grpc", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c", + "name": "mpmcqueue_test", + "src": [ + "test/core/iomgr/mpmcqueue_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", @@ -4295,24 +4311,6 @@ "third_party": false, "type": "target" }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "mpmcqueue_test", - "src": [ - "test/core/iomgr/mpmcqueue_test.cc" - ], - "third_party": false, - "type": "target" - }, { "deps": [ "gpr", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 29657db49f9..7d1a09dbea8 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -1959,6 +1959,30 @@ ], "uses_polling": false }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": false, + "language": "c", + "name": "mpmcqueue_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": false + }, { "args": [], "benchmark": false, @@ -4997,30 +5021,6 @@ ], "uses_polling": true }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": false, - "language": "c++", - "name": "mpmcqueue_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "uses_polling": true - }, { "args": [], "benchmark": false, From 241d77bd80a78594e474d60718bd0f86e4e0f9f4 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 21 Jun 2019 17:18:41 -0700 Subject: [PATCH 0649/1555] remove extra constant --- test/core/iomgr/mpmcqueue_test.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index f89fed24bc2..38c899e7098 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -23,7 +23,6 @@ #include "src/core/lib/gprpp/thd.h" #include "test/core/util/test_config.h" -#define THREAD_SMALL_ITERATION 100 #define THREAD_LARGE_ITERATION 10000 // Testing items for queue @@ -103,7 +102,7 @@ static void test_get_empty(void) { } WorkItem** items = - static_cast(gpr_zalloc(THREAD_SMALL_ITERATION)); + static_cast(gpr_zalloc(THREAD_LARGE_ITERATION)); for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { items[i] = grpc_core::New(i); queue.Put(static_cast(items[i])); From 9427d1c9ce2f7bfa1802a43b176184ee1894032f Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 21 Jun 2019 17:24:05 -0700 Subject: [PATCH 0650/1555] Revert "Surface exceptions in gevent IO manager" --- .../grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi | 44 +++++++++---------- .../grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi | 42 +++++++++--------- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi index 59b3891d9fa..30fdf6a7600 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi @@ -44,12 +44,12 @@ cdef extern from "src/core/lib/iomgr/resolve_address_custom.h": pass struct grpc_custom_resolver_vtable: - grpc_error* (*resolve)(char* host, char* port, grpc_resolved_addresses** res) except * - void (*resolve_async)(grpc_custom_resolver* resolver, char* host, char* port) except * + grpc_error* (*resolve)(char* host, char* port, grpc_resolved_addresses** res); + void (*resolve_async)(grpc_custom_resolver* resolver, char* host, char* port); void grpc_custom_resolve_callback(grpc_custom_resolver* resolver, grpc_resolved_addresses* result, - grpc_error* error) + grpc_error* error); cdef extern from "src/core/lib/iomgr/tcp_custom.h": struct grpc_custom_socket: @@ -67,25 +67,25 @@ cdef extern from "src/core/lib/iomgr/tcp_custom.h": ctypedef void (*grpc_custom_close_callback)(grpc_custom_socket* socket) struct grpc_socket_vtable: - grpc_error* (*init)(grpc_custom_socket* socket, int domain) except * + grpc_error* (*init)(grpc_custom_socket* socket, int domain); void (*connect)(grpc_custom_socket* socket, const grpc_sockaddr* addr, - size_t len, grpc_custom_connect_callback cb) except * - void (*destroy)(grpc_custom_socket* socket) except * - void (*shutdown)(grpc_custom_socket* socket) except * - void (*close)(grpc_custom_socket* socket, grpc_custom_close_callback cb) except * + size_t len, grpc_custom_connect_callback cb); + void (*destroy)(grpc_custom_socket* socket); + void (*shutdown)(grpc_custom_socket* socket); + void (*close)(grpc_custom_socket* socket, grpc_custom_close_callback cb); void (*write)(grpc_custom_socket* socket, grpc_slice_buffer* slices, - grpc_custom_write_callback cb) except * + grpc_custom_write_callback cb); void (*read)(grpc_custom_socket* socket, char* buffer, size_t length, - grpc_custom_read_callback cb) except * + grpc_custom_read_callback cb); grpc_error* (*getpeername)(grpc_custom_socket* socket, - const grpc_sockaddr* addr, int* len) except * + const grpc_sockaddr* addr, int* len); grpc_error* (*getsockname)(grpc_custom_socket* socket, - const grpc_sockaddr* addr, int* len) except * + const grpc_sockaddr* addr, int* len); grpc_error* (*bind)(grpc_custom_socket* socket, const grpc_sockaddr* addr, - size_t len, int flags) except * - grpc_error* (*listen)(grpc_custom_socket* socket) except * + size_t len, int flags); + grpc_error* (*listen)(grpc_custom_socket* socket); void (*accept)(grpc_custom_socket* socket, grpc_custom_socket* client, - grpc_custom_accept_callback cb) except * + grpc_custom_accept_callback cb); cdef extern from "src/core/lib/iomgr/timer_custom.h": struct grpc_custom_timer: @@ -94,17 +94,17 @@ cdef extern from "src/core/lib/iomgr/timer_custom.h": # We don't care about the rest of the fields struct grpc_custom_timer_vtable: - void (*start)(grpc_custom_timer* t) except * - void (*stop)(grpc_custom_timer* t) except * + void (*start)(grpc_custom_timer* t); + void (*stop)(grpc_custom_timer* t); - void grpc_custom_timer_callback(grpc_custom_timer* t, grpc_error* error) + void grpc_custom_timer_callback(grpc_custom_timer* t, grpc_error* error); cdef extern from "src/core/lib/iomgr/pollset_custom.h": struct grpc_custom_poller_vtable: - void (*init)() except * - void (*poll)(size_t timeout_ms) except * - void (*kick)() except * - void (*shutdown)() except * + void (*init)() + void (*poll)(size_t timeout_ms) + void (*kick)() + void (*shutdown)() cdef extern from "src/core/lib/iomgr/iomgr_custom.h": void grpc_custom_iomgr_init(grpc_socket_vtable* socket, diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi index f82fca2cce7..a1618d04d0e 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi @@ -56,7 +56,7 @@ cdef sockaddr_is_ipv4(const grpc_sockaddr* address, size_t length): c_addr.len = length return grpc_sockaddr_get_uri_scheme(&c_addr) == b'ipv4' -cdef grpc_resolved_addresses* tuples_to_resolvaddr(tups) except *: +cdef grpc_resolved_addresses* tuples_to_resolvaddr(tups): cdef grpc_resolved_addresses* addresses tups_set = set((tup[4][0], tup[4][1]) for tup in tups) addresses = malloc(sizeof(grpc_resolved_addresses)) @@ -84,7 +84,7 @@ cdef class SocketWrapper: self.c_buffer = NULL self.len = 0 -cdef grpc_error* socket_init(grpc_custom_socket* socket, int domain) except * with gil: +cdef grpc_error* socket_init(grpc_custom_socket* socket, int domain) with gil: sw = SocketWrapper() sw.c_socket = socket sw.sockopts = [] @@ -112,7 +112,7 @@ def socket_connect_async(socket_wrapper, addr_tuple): cdef void socket_connect(grpc_custom_socket* socket, const grpc_sockaddr* addr, size_t addr_len, - grpc_custom_connect_callback cb) except * with gil: + grpc_custom_connect_callback cb) with gil: py_socket = None socket_wrapper = socket.impl socket_wrapper.connect_cb = cb @@ -125,10 +125,10 @@ cdef void socket_connect(grpc_custom_socket* socket, const grpc_sockaddr* addr, socket_wrapper.socket = py_socket _spawn_greenlet(socket_connect_async, socket_wrapper, addr_tuple) -cdef void socket_destroy(grpc_custom_socket* socket) except * with gil: +cdef void socket_destroy(grpc_custom_socket* socket) with gil: cpython.Py_DECREF(socket.impl) -cdef void socket_shutdown(grpc_custom_socket* socket) except * with gil: +cdef void socket_shutdown(grpc_custom_socket* socket) with gil: try: (socket.impl).socket.shutdown(gevent_socket.SHUT_RDWR) except IOError as io_error: @@ -136,7 +136,7 @@ cdef void socket_shutdown(grpc_custom_socket* socket) except * with gil: raise io_error cdef void socket_close(grpc_custom_socket* socket, - grpc_custom_close_callback cb) except * with gil: + grpc_custom_close_callback cb) with gil: socket_wrapper = (socket.impl) if socket_wrapper.socket is not None: socket_wrapper.socket.close() @@ -176,7 +176,7 @@ def socket_write_async(socket_wrapper, write_bytes): socket_write_async_cython(socket_wrapper, write_bytes) cdef void socket_write(grpc_custom_socket* socket, grpc_slice_buffer* buffer, - grpc_custom_write_callback cb) except * with gil: + grpc_custom_write_callback cb) with gil: cdef char* start sw = socket.impl sw.write_cb = cb @@ -204,7 +204,7 @@ def socket_read_async(socket_wrapper): socket_read_async_cython(socket_wrapper) cdef void socket_read(grpc_custom_socket* socket, char* buffer, - size_t length, grpc_custom_read_callback cb) except * with gil: + size_t length, grpc_custom_read_callback cb) with gil: sw = socket.impl sw.read_cb = cb sw.c_buffer = buffer @@ -213,7 +213,7 @@ cdef void socket_read(grpc_custom_socket* socket, char* buffer, cdef grpc_error* socket_getpeername(grpc_custom_socket* socket, const grpc_sockaddr* addr, - int* length) except * with gil: + int* length) with gil: cdef char* src_buf peer = (socket.impl).socket.getpeername() @@ -226,7 +226,7 @@ cdef grpc_error* socket_getpeername(grpc_custom_socket* socket, cdef grpc_error* socket_getsockname(grpc_custom_socket* socket, const grpc_sockaddr* addr, - int* length) except * with gil: + int* length) with gil: cdef char* src_buf cdef grpc_resolved_address c_addr if (socket.impl).socket is None: @@ -245,7 +245,7 @@ def applysockopts(s): cdef grpc_error* socket_bind(grpc_custom_socket* socket, const grpc_sockaddr* addr, - size_t len, int flags) except * with gil: + size_t len, int flags) with gil: addr_tuple = sockaddr_to_tuple(addr, len) try: try: @@ -262,7 +262,7 @@ cdef grpc_error* socket_bind(grpc_custom_socket* socket, else: return grpc_error_none() -cdef grpc_error* socket_listen(grpc_custom_socket* socket) except * with gil: +cdef grpc_error* socket_listen(grpc_custom_socket* socket) with gil: (socket.impl).socket.listen(50) return grpc_error_none() @@ -292,7 +292,7 @@ def socket_accept_async(s): accept_callback_cython(s) cdef void socket_accept(grpc_custom_socket* socket, grpc_custom_socket* client, - grpc_custom_accept_callback cb) except * with gil: + grpc_custom_accept_callback cb) with gil: sw = socket.impl sw.accepting_socket = client sw.accept_cb = cb @@ -322,7 +322,7 @@ cdef socket_resolve_async_cython(ResolveWrapper resolve_wrapper): def socket_resolve_async_python(resolve_wrapper): socket_resolve_async_cython(resolve_wrapper) -cdef void socket_resolve_async(grpc_custom_resolver* r, char* host, char* port) except * with gil: +cdef void socket_resolve_async(grpc_custom_resolver* r, char* host, char* port) with gil: rw = ResolveWrapper() rw.c_resolver = r rw.c_host = host @@ -330,7 +330,7 @@ cdef void socket_resolve_async(grpc_custom_resolver* r, char* host, char* port) _spawn_greenlet(socket_resolve_async_python, rw) cdef grpc_error* socket_resolve(char* host, char* port, - grpc_resolved_addresses** res) except * with gil: + grpc_resolved_addresses** res) with gil: try: result = gevent_socket.getaddrinfo(host, port) res[0] = tuples_to_resolvaddr(result) @@ -360,13 +360,13 @@ cdef class TimerWrapper: self.event.set() self.timer.stop() -cdef void timer_start(grpc_custom_timer* t) except * with gil: +cdef void timer_start(grpc_custom_timer* t) with gil: timer = TimerWrapper(t.timeout_ms / 1000.0) timer.c_timer = t t.timer = timer timer.start() -cdef void timer_stop(grpc_custom_timer* t) except * with gil: +cdef void timer_stop(grpc_custom_timer* t) with gil: time_wrapper = t.timer time_wrapper.stop() @@ -374,16 +374,16 @@ cdef void timer_stop(grpc_custom_timer* t) except * with gil: ### pollset implementation ### ############################### -cdef void init_loop() except * with gil: +cdef void init_loop() with gil: pass -cdef void destroy_loop() except * with gil: +cdef void destroy_loop() with gil: g_pool.join() -cdef void kick_loop() except * with gil: +cdef void kick_loop() with gil: g_event.set() -cdef void run_loop(size_t timeout_ms) except * with gil: +cdef void run_loop(size_t timeout_ms) with gil: timeout = timeout_ms / 1000.0 if timeout_ms > 0: g_event.wait(timeout) From 7a957698be3efdcc9bedf73972f9fd204e6b4cb0 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 21 Jun 2019 17:32:40 -0700 Subject: [PATCH 0651/1555] Modify clock type and time measurement --- src/core/lib/iomgr/executor/mpmcqueue.cc | 32 +++++++++++++----------- src/core/lib/iomgr/executor/mpmcqueue.h | 23 ++++++++--------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index fff078035c8..78a3aa1306f 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -25,6 +25,8 @@ namespace grpc_core { DebugOnlyTraceFlag thread_pool(false, "thread_pool_trace"); inline void* InfLenFIFOQueue::PopFront() { + // Caller should already checked queue is not empty and has already hold the + // mutex. This function will only do the job of removal. void* result = queue_head_->content; Node* head_to_remove = queue_head_; queue_head_ = queue_head_->next; @@ -33,29 +35,29 @@ inline void* InfLenFIFOQueue::PopFront() { if (GRPC_TRACE_FLAG_ENABLED(thread_pool)) { gpr_timespec wait_time = - gpr_time_sub(gpr_now(GPR_CLOCK_PRECISE), head_to_remove->insert_time); + gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), head_to_remove->insert_time); // Updates Stats info stats_.num_completed++; - stats_.total_queue_cycles = - gpr_time_add(stats_.total_queue_cycles, wait_time); - stats_.max_queue_cycles = gpr_time_max( - gpr_convert_clock_type(stats_.max_queue_cycles, GPR_TIMESPAN), + stats_.total_queue_time = + gpr_time_add(stats_.total_queue_time, wait_time); + stats_.max_queue_time = gpr_time_max( + gpr_convert_clock_type(stats_.max_queue_time, GPR_TIMESPAN), wait_time); if (count_.Load(MemoryOrder::RELAXED) == 0) { - stats_.busy_time_cycles = - gpr_time_add(stats_.busy_time_cycles, - gpr_time_sub(gpr_now(GPR_CLOCK_PRECISE), busy_time)); + stats_.busy_queue_time = + gpr_time_add(stats_.busy_queue_time, + gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), busy_time)); } gpr_log(GPR_INFO, - "[InfLenFIFOQueue Get] num_completed: %" PRIu64 - " total_queue_cycles: %" PRId32 " max_queue_cycles: %" PRId32 - " busy_time_cycles: %" PRId32, - stats_.num_completed, gpr_time_to_millis(stats_.total_queue_cycles), - gpr_time_to_millis(stats_.max_queue_cycles), - gpr_time_to_millis(stats_.busy_time_cycles)); + "[InfLenFIFOQueue PopFront] num_completed: %" PRIu64 + " total_queue_time: %f max_queue_time: %f busy_queue_time: %f", + stats_.num_completed, + gpr_timespec_to_micros(stats_.total_queue_time), + gpr_timespec_to_micros(stats_.max_queue_time), + gpr_timespec_to_micros(stats_.busy_queue_time)); } Delete(head_to_remove); @@ -81,7 +83,7 @@ void InfLenFIFOQueue::Put(void* elem) { Node* new_node = New(elem); if (count_.Load(MemoryOrder::RELAXED) == 0) { if (GRPC_TRACE_FLAG_ENABLED(thread_pool)) { - busy_time = gpr_now(GPR_CLOCK_PRECISE); + busy_time = gpr_now(GPR_CLOCK_MONOTONIC); } queue_head_ = queue_tail_ = new_node; } else { diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index 6b071a2fd68..208038498c9 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -52,8 +52,7 @@ class MPMCQueueInterface { class InfLenFIFOQueue : public MPMCQueueInterface { public: - // Creates a new MPMC Queue. The queue created - // will have infinite length. + // Creates a new MPMC Queue. The queue created will have infinite length. InfLenFIFOQueue(); // Releases all resources hold by the queue. The queue must be empty, and no @@ -92,24 +91,24 @@ class InfLenFIFOQueue : public MPMCQueueInterface { }; // Stats of queue. This will only be collect when debug trace mode is on. - // All printed stats info will have time measurement in millisecond. + // All printed stats info will have time measurement in microsecond. struct Stats { uint64_t num_started; // Number of elements have been added to queue uint64_t num_completed; // Number of elements have been removed from // the queue - gpr_timespec total_queue_cycles; // Total waiting time that all the - // removed elements have spent in queue - gpr_timespec max_queue_cycles; // Max waiting time among all removed - // elements - gpr_timespec busy_time_cycles; // Accumulated amount of time that queue - // was not empty + gpr_timespec total_queue_time; // Total waiting time that all the + // removed elements have spent in queue + gpr_timespec max_queue_time; // Max waiting time among all removed + // elements + gpr_timespec busy_queue_time; // Accumulated amount of time that queue + // was not empty Stats() { num_started = 0; num_completed = 0; - total_queue_cycles = gpr_time_0(GPR_TIMESPAN); - max_queue_cycles = gpr_time_0(GPR_TIMESPAN); - busy_time_cycles = gpr_time_0(GPR_TIMESPAN); + total_queue_time = gpr_time_0(GPR_TIMESPAN); + max_queue_time = gpr_time_0(GPR_TIMESPAN); + busy_queue_time = gpr_time_0(GPR_TIMESPAN); } }; From 723d6580bd381aa46fcaac029fa9246ff48f9319 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 21 Jun 2019 17:46:16 -0700 Subject: [PATCH 0652/1555] Change to malloc --- test/core/iomgr/mpmcqueue_test.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index 38c899e7098..42852b8b583 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -41,7 +41,7 @@ class ProducerThread { : start_index_(start_index), num_items_(num_items), queue_(queue) { items_ = nullptr; thd_ = grpc_core::Thread( - "mpmcq_test_mt_put_thd", + "mpmcq_test_put_thd", [](void* th) { static_cast(th)->Run(); }, this); } ~ProducerThread() { @@ -57,7 +57,8 @@ class ProducerThread { private: void Run() { - items_ = static_cast(gpr_zalloc(num_items_)); + items_ = + static_cast(gpr_malloc(num_items_ * sizeof(WorkItem*))); for (int i = 0; i < num_items_; ++i) { items_[i] = grpc_core::New(start_index_ + i); queue_->Put(items_[i]); @@ -101,8 +102,8 @@ static void test_get_empty(void) { thds[i].Start(); } - WorkItem** items = - static_cast(gpr_zalloc(THREAD_LARGE_ITERATION)); + WorkItem** items = static_cast( + gpr_malloc(THREAD_LARGE_ITERATION * sizeof(WorkItem*))); for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { items[i] = grpc_core::New(i); queue.Put(static_cast(items[i])); @@ -143,8 +144,8 @@ static void test_many_thread(void) { const int num_work_thd = 10; const int num_get_thd = 20; grpc_core::InfLenFIFOQueue queue; - ProducerThread** work_thds = - static_cast(gpr_zalloc(num_work_thd)); + ProducerThread** work_thds = static_cast( + gpr_malloc(num_work_thd * sizeof(ProducerThread*))); grpc_core::Thread get_thds[num_get_thd]; gpr_log(GPR_DEBUG, "Fork ProducerThread..."); From 2a7e593ac4ed4a4eefb1c764d3b1e54879fe38fc Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 21 Jun 2019 18:03:29 -0700 Subject: [PATCH 0653/1555] Change consumer thread to class --- test/core/iomgr/mpmcqueue_test.cc | 74 ++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index 42852b8b583..792d9b602c2 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -58,7 +58,7 @@ class ProducerThread { private: void Run() { items_ = - static_cast(gpr_malloc(num_items_ * sizeof(WorkItem*))); + static_cast(gpr_zalloc(num_items_ * sizeof(WorkItem*))); for (int i = 0; i < num_items_; ++i) { items_[i] = grpc_core::New(start_index_ + i); queue_->Put(items_[i]); @@ -72,38 +72,52 @@ class ProducerThread { WorkItem** items_; }; -static void ConsumerThread(void* args) { - grpc_core::InfLenFIFOQueue* queue = - static_cast(args); - - // count number of Get() called in this thread - int count = 0; - - WorkItem* item; - while ((item = static_cast(queue->Get())) != nullptr) { - count++; - GPR_ASSERT(!item->done); - item->done = true; +class ConsumerThread { + public: + ConsumerThread(grpc_core::InfLenFIFOQueue* queue) : queue_(queue) { + thd_ = grpc_core::Thread( + "mpmcq_test_get_thd", + [](void* th) { static_cast(th)->Run(); }, this); } + ~ConsumerThread() {} - gpr_log(GPR_DEBUG, "ConsumerThread: %d times of Get() called.", count); -} + void Start() { thd_.Start(); } + void Join() { thd_.Join(); } + + private: + void Run() { + // count number of Get() called in this thread + int count = 0; + + WorkItem* item; + while ((item = static_cast(queue_->Get())) != nullptr) { + count++; + GPR_ASSERT(!item->done); + item->done = true; + } + + gpr_log(GPR_DEBUG, "ConsumerThread: %d times of Get() called.", count); + } + grpc_core::InfLenFIFOQueue* queue_; + grpc_core::Thread thd_; +}; static void test_get_empty(void) { gpr_log(GPR_INFO, "test_get_empty"); grpc_core::InfLenFIFOQueue queue; GPR_ASSERT(queue.count() == 0); const int num_threads = 10; - grpc_core::Thread thds[num_threads]; + ConsumerThread** consumer_thds = static_cast( + gpr_zalloc(num_threads * sizeof(ConsumerThread*))); // Fork threads. Threads should block at the beginning since queue is empty. for (int i = 0; i < num_threads; ++i) { - thds[i] = grpc_core::Thread("mpmcq_test_ge_thd", ConsumerThread, &queue); - thds[i].Start(); + consumer_thds[i] = grpc_core::New(&queue); + consumer_thds[i]->Start(); } WorkItem** items = static_cast( - gpr_malloc(THREAD_LARGE_ITERATION * sizeof(WorkItem*))); + gpr_zalloc(THREAD_LARGE_ITERATION * sizeof(WorkItem*))); for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { items[i] = grpc_core::New(i); queue.Put(static_cast(items[i])); @@ -114,7 +128,7 @@ static void test_get_empty(void) { queue.Put(nullptr); } for (int i = 0; i < num_threads; ++i) { - thds[i].Join(); + consumer_thds[i]->Join(); } gpr_log(GPR_DEBUG, "Checking and Cleaning Up..."); for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { @@ -122,6 +136,10 @@ static void test_get_empty(void) { grpc_core::Delete(items[i]); } gpr_free(items); + for (int i = 0; i < num_threads; ++i) { + grpc_core::Delete(consumer_thds[i]); + } + gpr_free(consumer_thds); gpr_log(GPR_DEBUG, "Done."); } @@ -145,8 +163,9 @@ static void test_many_thread(void) { const int num_get_thd = 20; grpc_core::InfLenFIFOQueue queue; ProducerThread** work_thds = static_cast( - gpr_malloc(num_work_thd * sizeof(ProducerThread*))); - grpc_core::Thread get_thds[num_get_thd]; + gpr_zalloc(num_work_thd * sizeof(ProducerThread*))); + ConsumerThread** consumer_thds = static_cast( + gpr_zalloc(num_get_thd * sizeof(ConsumerThread*))); gpr_log(GPR_DEBUG, "Fork ProducerThread..."); for (int i = 0; i < num_work_thd; ++i) { @@ -157,9 +176,8 @@ static void test_many_thread(void) { gpr_log(GPR_DEBUG, "ProducerThread Started."); gpr_log(GPR_DEBUG, "Fork Getter Thread..."); for (int i = 0; i < num_get_thd; ++i) { - get_thds[i] = - grpc_core::Thread("mpmcq_test_mt_get_thd", ConsumerThread, &queue); - get_thds[i].Start(); + consumer_thds[i] = grpc_core::New(&queue); + consumer_thds[i]->Start(); } gpr_log(GPR_DEBUG, "Getter Thread Started."); gpr_log(GPR_DEBUG, "Waiting ProducerThread to finish..."); @@ -172,7 +190,7 @@ static void test_many_thread(void) { queue.Put(nullptr); } for (int i = 0; i < num_get_thd; ++i) { - get_thds[i].Join(); + consumer_thds[i]->Join(); } gpr_log(GPR_DEBUG, "All Getter Thread Terminated."); gpr_log(GPR_DEBUG, "Checking WorkItems and Cleaning Up..."); @@ -180,6 +198,10 @@ static void test_many_thread(void) { grpc_core::Delete(work_thds[i]); } gpr_free(work_thds); + for (int i = 0; i < num_get_thd; ++i) { + grpc_core::Delete(consumer_thds[i]); + } + gpr_free(consumer_thds); gpr_log(GPR_DEBUG, "Done."); } From 5c95bcbd83db1b8d0d379ab608c445d93a98532b Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 21 Jun 2019 18:06:11 -0700 Subject: [PATCH 0654/1555] Default value in class --- src/core/lib/iomgr/executor/mpmcqueue.cc | 3 +-- src/core/lib/iomgr/executor/mpmcqueue.h | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index 78a3aa1306f..df8dd13e3e2 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -69,8 +69,7 @@ inline void* InfLenFIFOQueue::PopFront() { return result; } -InfLenFIFOQueue::InfLenFIFOQueue() - : num_waiters_(0), queue_head_(nullptr), queue_tail_(nullptr) {} +InfLenFIFOQueue::InfLenFIFOQueue() {} InfLenFIFOQueue::~InfLenFIFOQueue() { GPR_ASSERT(count_.Load(MemoryOrder::RELAXED) == 0); diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index 208038498c9..964ac6a8b41 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -114,13 +114,13 @@ class InfLenFIFOQueue : public MPMCQueueInterface { Mutex mu_; // Protecting lock CondVar wait_nonempty_; // Wait on empty queue on get - int num_waiters_; // Number of waiters + int num_waiters_ = 0; // Number of waiters - Node* queue_head_; // Head of the queue, remove position - Node* queue_tail_; // End of queue, insert position - Atomic count_{0}; // Number of elements in queue - Stats stats_; // Stats info - gpr_timespec busy_time; // Start time of busy queue + Node* queue_head_ = nullptr; // Head of the queue, remove position + Node* queue_tail_ = nullptr; // End of queue, insert position + Atomic count_{0}; // Number of elements in queue + Stats stats_; // Stats info + gpr_timespec busy_time; // Start time of busy queue }; } // namespace grpc_core From 1bda5ce33865ca6227ee980a848b5e2069a3b11d Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 21 Jun 2019 18:08:30 -0700 Subject: [PATCH 0655/1555] clang_format --- src/core/lib/iomgr/executor/mpmcqueue.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index df8dd13e3e2..cf8ade721d3 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -39,11 +39,9 @@ inline void* InfLenFIFOQueue::PopFront() { // Updates Stats info stats_.num_completed++; - stats_.total_queue_time = - gpr_time_add(stats_.total_queue_time, wait_time); + stats_.total_queue_time = gpr_time_add(stats_.total_queue_time, wait_time); stats_.max_queue_time = gpr_time_max( - gpr_convert_clock_type(stats_.max_queue_time, GPR_TIMESPAN), - wait_time); + gpr_convert_clock_type(stats_.max_queue_time, GPR_TIMESPAN), wait_time); if (count_.Load(MemoryOrder::RELAXED) == 0) { stats_.busy_queue_time = From 8b91dc5fd2683424efbb32ed02cf6acdce95fecd Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Sat, 22 Jun 2019 17:09:34 -0700 Subject: [PATCH 0656/1555] Move more of usage to grpc_impl 1) Create server_context_impl and completion_queue_impl headers. 2) Move more of usage of ClientContext, ServerContext to grpc_impl --- BUILD | 3 ++ BUILD.gn | 2 ++ CMakeLists.txt | 6 ++++ Makefile | 6 ++++ build.yaml | 2 ++ gRPC-C++.podspec | 2 ++ include/grpcpp/completion_queue_impl.h | 24 +++++++++++++ .../impl/codegen/async_generic_service.h | 4 +-- include/grpcpp/impl/codegen/async_stream.h | 35 +++++++++--------- include/grpcpp/impl/codegen/call_op_set.h | 8 ++--- include/grpcpp/impl/codegen/client_callback.h | 36 +++++++++---------- .../grpcpp/impl/codegen/intercepted_channel.h | 2 +- .../grpcpp/impl/codegen/server_interface.h | 3 +- include/grpcpp/server_context_impl.h | 24 +++++++++++++ include/grpcpp/server_impl.h | 2 +- tools/doxygen/Doxyfile.c++ | 2 ++ tools/doxygen/Doxyfile.c++.internal | 2 ++ .../generated/sources_and_headers.json | 4 +++ 18 files changed, 123 insertions(+), 44 deletions(-) create mode 100644 include/grpcpp/completion_queue_impl.h create mode 100644 include/grpcpp/server_context_impl.h diff --git a/BUILD b/BUILD index 8fd52808400..35e10a8b2ff 100644 --- a/BUILD +++ b/BUILD @@ -222,6 +222,7 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/channel_impl.h", "include/grpcpp/client_context.h", "include/grpcpp/completion_queue.h", + "include/grpcpp/completion_queue_impl.h", "include/grpcpp/create_channel.h", "include/grpcpp/create_channel_impl.h", "include/grpcpp/create_channel_posix.h", @@ -264,6 +265,7 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/server_builder.h", "include/grpcpp/server_builder_impl.h", "include/grpcpp/server_context.h", + "include/grpcpp/server_context_impl.h", "include/grpcpp/server_posix.h", "include/grpcpp/server_posix_impl.h", "include/grpcpp/support/async_stream.h", @@ -2187,6 +2189,7 @@ grpc_cc_library( "include/grpcpp/impl/codegen/server_callback.h", "include/grpcpp/impl/codegen/server_context.h", "include/grpcpp/impl/codegen/server_context_impl.h", + "include/grpcpp/impl/codegen/server_context_impl.h", "include/grpcpp/impl/codegen/server_interceptor.h", "include/grpcpp/impl/codegen/server_interface.h", "include/grpcpp/impl/codegen/service_type.h", diff --git a/BUILD.gn b/BUILD.gn index e5396f51426..534c88bd67f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1028,6 +1028,7 @@ config("grpc_config") { "include/grpcpp/channel_impl.h", "include/grpcpp/client_context.h", "include/grpcpp/completion_queue.h", + "include/grpcpp/completion_queue_impl.h", "include/grpcpp/create_channel.h", "include/grpcpp/create_channel_impl.h", "include/grpcpp/create_channel_posix.h", @@ -1118,6 +1119,7 @@ config("grpc_config") { "include/grpcpp/server_builder.h", "include/grpcpp/server_builder_impl.h", "include/grpcpp/server_context.h", + "include/grpcpp/server_context_impl.h", "include/grpcpp/server_impl.h", "include/grpcpp/server_posix.h", "include/grpcpp/server_posix_impl.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index a34f9265256..46bd48cccdb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3160,6 +3160,7 @@ foreach(_hdr include/grpcpp/channel_impl.h include/grpcpp/client_context.h include/grpcpp/completion_queue.h + include/grpcpp/completion_queue_impl.h include/grpcpp/create_channel.h include/grpcpp/create_channel_impl.h include/grpcpp/create_channel_posix.h @@ -3199,6 +3200,7 @@ foreach(_hdr include/grpcpp/server_builder.h include/grpcpp/server_builder_impl.h include/grpcpp/server_context.h + include/grpcpp/server_context_impl.h include/grpcpp/server_impl.h include/grpcpp/server_posix.h include/grpcpp/server_posix_impl.h @@ -3781,6 +3783,7 @@ foreach(_hdr include/grpcpp/channel_impl.h include/grpcpp/client_context.h include/grpcpp/completion_queue.h + include/grpcpp/completion_queue_impl.h include/grpcpp/create_channel.h include/grpcpp/create_channel_impl.h include/grpcpp/create_channel_posix.h @@ -3820,6 +3823,7 @@ foreach(_hdr include/grpcpp/server_builder.h include/grpcpp/server_builder_impl.h include/grpcpp/server_context.h + include/grpcpp/server_context_impl.h include/grpcpp/server_impl.h include/grpcpp/server_posix.h include/grpcpp/server_posix_impl.h @@ -4780,6 +4784,7 @@ foreach(_hdr include/grpcpp/channel_impl.h include/grpcpp/client_context.h include/grpcpp/completion_queue.h + include/grpcpp/completion_queue_impl.h include/grpcpp/create_channel.h include/grpcpp/create_channel_impl.h include/grpcpp/create_channel_posix.h @@ -4819,6 +4824,7 @@ foreach(_hdr include/grpcpp/server_builder.h include/grpcpp/server_builder_impl.h include/grpcpp/server_context.h + include/grpcpp/server_context_impl.h include/grpcpp/server_impl.h include/grpcpp/server_posix.h include/grpcpp/server_posix_impl.h diff --git a/Makefile b/Makefile index 9930fc35a25..702c571f585 100644 --- a/Makefile +++ b/Makefile @@ -5534,6 +5534,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/channel_impl.h \ include/grpcpp/client_context.h \ include/grpcpp/completion_queue.h \ + include/grpcpp/completion_queue_impl.h \ include/grpcpp/create_channel.h \ include/grpcpp/create_channel_impl.h \ include/grpcpp/create_channel_posix.h \ @@ -5573,6 +5574,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/server_builder.h \ include/grpcpp/server_builder_impl.h \ include/grpcpp/server_context.h \ + include/grpcpp/server_context_impl.h \ include/grpcpp/server_impl.h \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ @@ -6163,6 +6165,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/channel_impl.h \ include/grpcpp/client_context.h \ include/grpcpp/completion_queue.h \ + include/grpcpp/completion_queue_impl.h \ include/grpcpp/create_channel.h \ include/grpcpp/create_channel_impl.h \ include/grpcpp/create_channel_posix.h \ @@ -6202,6 +6205,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/server_builder.h \ include/grpcpp/server_builder_impl.h \ include/grpcpp/server_context.h \ + include/grpcpp/server_context_impl.h \ include/grpcpp/server_impl.h \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ @@ -7111,6 +7115,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/channel_impl.h \ include/grpcpp/client_context.h \ include/grpcpp/completion_queue.h \ + include/grpcpp/completion_queue_impl.h \ include/grpcpp/create_channel.h \ include/grpcpp/create_channel_impl.h \ include/grpcpp/create_channel_posix.h \ @@ -7150,6 +7155,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/server_builder.h \ include/grpcpp/server_builder_impl.h \ include/grpcpp/server_context.h \ + include/grpcpp/server_context_impl.h \ include/grpcpp/server_impl.h \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ diff --git a/build.yaml b/build.yaml index dad2146bd1c..d63284e1267 100644 --- a/build.yaml +++ b/build.yaml @@ -1366,6 +1366,7 @@ filegroups: - include/grpcpp/channel_impl.h - include/grpcpp/client_context.h - include/grpcpp/completion_queue.h + - include/grpcpp/completion_queue_impl.h - include/grpcpp/create_channel.h - include/grpcpp/create_channel_impl.h - include/grpcpp/create_channel_posix.h @@ -1405,6 +1406,7 @@ filegroups: - include/grpcpp/server_builder.h - include/grpcpp/server_builder_impl.h - include/grpcpp/server_context.h + - include/grpcpp/server_context_impl.h - include/grpcpp/server_impl.h - include/grpcpp/server_posix.h - include/grpcpp/server_posix_impl.h diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index f0a4418b20c..981fb345eee 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -85,6 +85,7 @@ Pod::Spec.new do |s| 'include/grpcpp/channel_impl.h', 'include/grpcpp/client_context.h', 'include/grpcpp/completion_queue.h', + 'include/grpcpp/completion_queue_impl.h', 'include/grpcpp/create_channel.h', 'include/grpcpp/create_channel_impl.h', 'include/grpcpp/create_channel_posix.h', @@ -124,6 +125,7 @@ Pod::Spec.new do |s| 'include/grpcpp/server_builder.h', 'include/grpcpp/server_builder_impl.h', 'include/grpcpp/server_context.h', + 'include/grpcpp/server_context_impl.h', 'include/grpcpp/server_impl.h', 'include/grpcpp/server_posix.h', 'include/grpcpp/server_posix_impl.h', diff --git a/include/grpcpp/completion_queue_impl.h b/include/grpcpp/completion_queue_impl.h new file mode 100644 index 00000000000..d5bb07d5763 --- /dev/null +++ b/include/grpcpp/completion_queue_impl.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_COMPLETION_QUEUE_H +#define GRPCPP_COMPLETION_QUEUE_H + +#include + +#endif // GRPCPP_COMPLETION_QUEUE_H diff --git a/include/grpcpp/impl/codegen/async_generic_service.h b/include/grpcpp/impl/codegen/async_generic_service.h index 46d09121a7b..95c0f3dd969 100644 --- a/include/grpcpp/impl/codegen/async_generic_service.h +++ b/include/grpcpp/impl/codegen/async_generic_service.h @@ -33,7 +33,7 @@ typedef ServerAsyncResponseWriter GenericServerAsyncResponseWriter; typedef ServerAsyncReader GenericServerAsyncReader; typedef ServerAsyncWriter GenericServerAsyncWriter; -class GenericServerContext final : public ServerContext { +class GenericServerContext final : public grpc_impl::ServerContext { public: const grpc::string& method() const { return method_; } const grpc::string& host() const { return host_; } @@ -99,7 +99,7 @@ class ServerGenericBidiReactor virtual void OnStarted(GenericServerContext* context) {} private: - void OnStarted(ServerContext* ctx) final { + void OnStarted(grpc_impl::ServerContext* ctx) final { OnStarted(static_cast(ctx)); } }; diff --git a/include/grpcpp/impl/codegen/async_stream.h b/include/grpcpp/impl/codegen/async_stream.h index f95772650a2..5e608df5c4e 100644 --- a/include/grpcpp/impl/codegen/async_stream.h +++ b/include/grpcpp/impl/codegen/async_stream.h @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -181,8 +181,8 @@ class ClientAsyncReaderFactory { static ClientAsyncReader* Create(ChannelInterface* channel, CompletionQueue* cq, const ::grpc::internal::RpcMethod& method, - ClientContext* context, const W& request, - bool start, void* tag) { + ::grpc_impl::ClientContext* context, + const W& request, bool start, void* tag) { ::grpc::internal::Call call = channel->CreateCall(method, context, cq); return new (g_core_codegen_interface->grpc_call_arena_alloc( call.call(), sizeof(ClientAsyncReader))) @@ -260,8 +260,9 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface { private: friend class internal::ClientAsyncReaderFactory; template - ClientAsyncReader(::grpc::internal::Call call, ClientContext* context, - const W& request, bool start, void* tag) + ClientAsyncReader(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, const W& request, + bool start, void* tag) : context_(context), call_(call), started_(start) { // TODO(ctiller): don't assert GPR_CODEGEN_ASSERT(init_ops_.SendMessage(request).ok()); @@ -280,7 +281,7 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface { call_.PerformOps(&init_ops_); } - ClientContext* context_; + ::grpc_impl::ClientContext* context_; ::grpc::internal::Call call_; bool started_; ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, @@ -329,8 +330,8 @@ class ClientAsyncWriterFactory { static ClientAsyncWriter* Create(ChannelInterface* channel, CompletionQueue* cq, const ::grpc::internal::RpcMethod& method, - ClientContext* context, R* response, - bool start, void* tag) { + ::grpc_impl::ClientContext* context, + R* response, bool start, void* tag) { ::grpc::internal::Call call = channel->CreateCall(method, context, cq); return new (g_core_codegen_interface->grpc_call_arena_alloc( call.call(), sizeof(ClientAsyncWriter))) @@ -426,8 +427,9 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface { private: friend class internal::ClientAsyncWriterFactory; template - ClientAsyncWriter(::grpc::internal::Call call, ClientContext* context, - R* response, bool start, void* tag) + ClientAsyncWriter(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, R* response, + bool start, void* tag) : context_(context), call_(call), started_(start) { finish_ops_.RecvMessage(response); finish_ops_.AllowNoMessage(); @@ -449,7 +451,7 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface { } } - ClientContext* context_; + ::grpc_impl::ClientContext* context_; ::grpc::internal::Call call_; bool started_; ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> @@ -493,8 +495,8 @@ class ClientAsyncReaderWriterFactory { /// used to send to the server when starting the call. static ClientAsyncReaderWriter* Create( ChannelInterface* channel, CompletionQueue* cq, - const ::grpc::internal::RpcMethod& method, ClientContext* context, - bool start, void* tag) { + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, bool start, void* tag) { ::grpc::internal::Call call = channel->CreateCall(method, context, cq); return new (g_core_codegen_interface->grpc_call_arena_alloc( @@ -599,8 +601,9 @@ class ClientAsyncReaderWriter final private: friend class internal::ClientAsyncReaderWriterFactory; - ClientAsyncReaderWriter(::grpc::internal::Call call, ClientContext* context, - bool start, void* tag) + ClientAsyncReaderWriter(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, bool start, + void* tag) : context_(context), call_(call), started_(start) { if (start) { StartCallInternal(tag); @@ -620,7 +623,7 @@ class ClientAsyncReaderWriter final } } - ClientContext* context_; + ::grpc_impl::ClientContext* context_; ::grpc::internal::Call call_; bool started_; ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> diff --git a/include/grpcpp/impl/codegen/call_op_set.h b/include/grpcpp/impl/codegen/call_op_set.h index c3ae6c4e3d2..d0958bbb251 100644 --- a/include/grpcpp/impl/codegen/call_op_set.h +++ b/include/grpcpp/impl/codegen/call_op_set.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include @@ -697,7 +697,7 @@ class CallOpRecvInitialMetadata { public: CallOpRecvInitialMetadata() : metadata_map_(nullptr) {} - void RecvInitialMetadata(ClientContext* context) { + void RecvInitialMetadata(::grpc_impl::ClientContext* context) { context->initial_metadata_received_ = true; metadata_map_ = &context->recv_initial_metadata_; } @@ -746,7 +746,7 @@ class CallOpClientRecvStatus { CallOpClientRecvStatus() : recv_status_(nullptr), debug_error_string_(nullptr) {} - void ClientRecvStatus(ClientContext* context, Status* status) { + void ClientRecvStatus(::grpc_impl::ClientContext* context, Status* status) { client_context_ = context; metadata_map_ = &client_context_->trailing_metadata_; recv_status_ = status; @@ -807,7 +807,7 @@ class CallOpClientRecvStatus { private: bool hijacked_ = false; - ClientContext* client_context_; + ::grpc_impl::ClientContext* client_context_; MetadataMap* metadata_map_; Status* recv_status_; const char* debug_error_string_; diff --git a/include/grpcpp/impl/codegen/client_callback.h b/include/grpcpp/impl/codegen/client_callback.h index 86d06b72c91..9441a48b051 100644 --- a/include/grpcpp/impl/codegen/client_callback.h +++ b/include/grpcpp/impl/codegen/client_callback.h @@ -44,8 +44,8 @@ class RpcMethod; /// TODO(vjpai): Combine as much as possible with the blocking unary call code template void CallbackUnaryCall(ChannelInterface* channel, const RpcMethod& method, - ClientContext* context, const InputMessage* request, - OutputMessage* result, + ::grpc_impl::ClientContext* context, + const InputMessage* request, OutputMessage* result, std::function on_completion) { CallbackUnaryCallImpl x( channel, method, context, request, result, on_completion); @@ -55,8 +55,8 @@ template class CallbackUnaryCallImpl { public: CallbackUnaryCallImpl(ChannelInterface* channel, const RpcMethod& method, - ClientContext* context, const InputMessage* request, - OutputMessage* result, + ::grpc_impl::ClientContext* context, + const InputMessage* request, OutputMessage* result, std::function on_completion) { CompletionQueue* cq = channel->CallbackCQ(); GPR_CODEGEN_ASSERT(cq != nullptr); @@ -550,7 +550,7 @@ class ClientCallbackReaderWriterImpl friend class ClientCallbackReaderWriterFactory; ClientCallbackReaderWriterImpl( - Call call, ClientContext* context, + Call call, ::grpc_impl::ClientContext* context, ::grpc::experimental::ClientBidiReactor* reactor) : context_(context), call_(call), @@ -559,7 +559,7 @@ class ClientCallbackReaderWriterImpl this->BindReactor(reactor); } - ClientContext* const context_; + ::grpc_impl::ClientContext* const context_; Call call_; ::grpc::experimental::ClientBidiReactor* const reactor_; @@ -594,7 +594,7 @@ class ClientCallbackReaderWriterFactory { public: static void Create( ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, - ClientContext* context, + ::grpc_impl::ClientContext* context, ::grpc::experimental::ClientBidiReactor* reactor) { Call call = channel->CreateCall(method, context, channel->CallbackCQ()); @@ -692,7 +692,7 @@ class ClientCallbackReaderImpl template ClientCallbackReaderImpl( - Call call, ClientContext* context, Request* request, + Call call, ::grpc_impl::ClientContext* context, Request* request, ::grpc::experimental::ClientReadReactor* reactor) : context_(context), call_(call), reactor_(reactor) { this->BindReactor(reactor); @@ -701,7 +701,7 @@ class ClientCallbackReaderImpl start_ops_.ClientSendClose(); } - ClientContext* const context_; + ::grpc_impl::ClientContext* const context_; Call call_; ::grpc::experimental::ClientReadReactor* const reactor_; @@ -729,7 +729,7 @@ class ClientCallbackReaderFactory { template static void Create( ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, - ClientContext* context, const Request* request, + ::grpc_impl::ClientContext* context, const Request* request, ::grpc::experimental::ClientReadReactor* reactor) { Call call = channel->CreateCall(method, context, channel->CallbackCQ()); @@ -866,7 +866,7 @@ class ClientCallbackWriterImpl template ClientCallbackWriterImpl( - Call call, ClientContext* context, Response* response, + Call call, ::grpc_impl::ClientContext* context, Response* response, ::grpc::experimental::ClientWriteReactor* reactor) : context_(context), call_(call), @@ -877,7 +877,7 @@ class ClientCallbackWriterImpl finish_ops_.AllowNoMessage(); } - ClientContext* const context_; + ::grpc_impl::ClientContext* const context_; Call call_; ::grpc::experimental::ClientWriteReactor* const reactor_; @@ -909,7 +909,7 @@ class ClientCallbackWriterFactory { template static void Create( ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, - ClientContext* context, Response* response, + ::grpc_impl::ClientContext* context, Response* response, ::grpc::experimental::ClientWriteReactor* reactor) { Call call = channel->CreateCall(method, context, channel->CallbackCQ()); @@ -976,8 +976,8 @@ class ClientCallbackUnaryImpl final friend class ClientCallbackUnaryFactory; template - ClientCallbackUnaryImpl(Call call, ClientContext* context, Request* request, - Response* response, + ClientCallbackUnaryImpl(Call call, ::grpc_impl::ClientContext* context, + Request* request, Response* response, ::grpc::experimental::ClientUnaryReactor* reactor) : context_(context), call_(call), reactor_(reactor) { this->BindReactor(reactor); @@ -988,7 +988,7 @@ class ClientCallbackUnaryImpl final finish_ops_.AllowNoMessage(); } - ClientContext* const context_; + ::grpc_impl::ClientContext* const context_; Call call_; ::grpc::experimental::ClientUnaryReactor* const reactor_; @@ -1011,8 +1011,8 @@ class ClientCallbackUnaryFactory { template static void Create(ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, - ClientContext* context, const Request* request, - Response* response, + ::grpc_impl::ClientContext* context, + const Request* request, Response* response, ::grpc::experimental::ClientUnaryReactor* reactor) { Call call = channel->CreateCall(method, context, channel->CallbackCQ()); diff --git a/include/grpcpp/impl/codegen/intercepted_channel.h b/include/grpcpp/impl/codegen/intercepted_channel.h index cd0fcc06753..bcdd89db741 100644 --- a/include/grpcpp/impl/codegen/intercepted_channel.h +++ b/include/grpcpp/impl/codegen/intercepted_channel.h @@ -49,7 +49,7 @@ class InterceptedChannel : public ChannelInterface { InterceptedChannel(ChannelInterface* channel, size_t pos) : channel_(channel), interceptor_pos_(pos) {} - Call CreateCall(const RpcMethod& method, ClientContext* context, + Call CreateCall(const RpcMethod& method, ::grpc_impl::ClientContext* context, ::grpc_impl::CompletionQueue* cq) override { return channel_->CreateCallInternal(method, context, cq, interceptor_pos_); } diff --git a/include/grpcpp/impl/codegen/server_interface.h b/include/grpcpp/impl/codegen/server_interface.h index 9600e5f053d..a375d3c0b4c 100644 --- a/include/grpcpp/impl/codegen/server_interface.h +++ b/include/grpcpp/impl/codegen/server_interface.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include namespace grpc_impl { @@ -34,7 +34,6 @@ class Channel; class CompletionQueue; class ServerCompletionQueue; class ServerCredentials; -class ServerContext; } // namespace grpc_impl namespace grpc { diff --git a/include/grpcpp/server_context_impl.h b/include/grpcpp/server_context_impl.h new file mode 100644 index 00000000000..3a944f3da8f --- /dev/null +++ b/include/grpcpp/server_context_impl.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SERVER_CONTEXT_IMPL_H +#define GRPCPP_SERVER_CONTEXT_IMPL_H + +#include + +#endif // GRPCPP_SERVER_CONTEXT_IMPL_H diff --git a/include/grpcpp/server_impl.h b/include/grpcpp/server_impl.h index b75012e5da8..f92c80ef97d 100644 --- a/include/grpcpp/server_impl.h +++ b/include/grpcpp/server_impl.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 183ab0dff53..fe242437921 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -930,6 +930,7 @@ include/grpcpp/channel.h \ include/grpcpp/channel_impl.h \ include/grpcpp/client_context.h \ include/grpcpp/completion_queue.h \ +include/grpcpp/completion_queue_impl.h \ include/grpcpp/create_channel.h \ include/grpcpp/create_channel_impl.h \ include/grpcpp/create_channel_posix.h \ @@ -1019,6 +1020,7 @@ include/grpcpp/server.h \ include/grpcpp/server_builder.h \ include/grpcpp/server_builder_impl.h \ include/grpcpp/server_context.h \ +include/grpcpp/server_context_impl.h \ include/grpcpp/server_impl.h \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index e2d753e02eb..e500b317af8 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -931,6 +931,7 @@ include/grpcpp/channel.h \ include/grpcpp/channel_impl.h \ include/grpcpp/client_context.h \ include/grpcpp/completion_queue.h \ +include/grpcpp/completion_queue_impl.h \ include/grpcpp/create_channel.h \ include/grpcpp/create_channel_impl.h \ include/grpcpp/create_channel_posix.h \ @@ -1021,6 +1022,7 @@ include/grpcpp/server.h \ include/grpcpp/server_builder.h \ include/grpcpp/server_builder_impl.h \ include/grpcpp/server_context.h \ +include/grpcpp/server_context_impl.h \ include/grpcpp/server_impl.h \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 8765f216dab..98b9bdc4261 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -10381,6 +10381,7 @@ "include/grpcpp/channel_impl.h", "include/grpcpp/client_context.h", "include/grpcpp/completion_queue.h", + "include/grpcpp/completion_queue_impl.h", "include/grpcpp/create_channel.h", "include/grpcpp/create_channel_impl.h", "include/grpcpp/create_channel_posix.h", @@ -10420,6 +10421,7 @@ "include/grpcpp/server_builder.h", "include/grpcpp/server_builder_impl.h", "include/grpcpp/server_context.h", + "include/grpcpp/server_context_impl.h", "include/grpcpp/server_impl.h", "include/grpcpp/server_posix.h", "include/grpcpp/server_posix_impl.h", @@ -10508,6 +10510,7 @@ "include/grpcpp/channel_impl.h", "include/grpcpp/client_context.h", "include/grpcpp/completion_queue.h", + "include/grpcpp/completion_queue_impl.h", "include/grpcpp/create_channel.h", "include/grpcpp/create_channel_impl.h", "include/grpcpp/create_channel_posix.h", @@ -10547,6 +10550,7 @@ "include/grpcpp/server_builder.h", "include/grpcpp/server_builder_impl.h", "include/grpcpp/server_context.h", + "include/grpcpp/server_context_impl.h", "include/grpcpp/server_impl.h", "include/grpcpp/server_posix.h", "include/grpcpp/server_posix_impl.h", From 650c0216c31c9e8430472891f1b2ce2beaeea32f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 24 Jun 2019 18:30:56 +0200 Subject: [PATCH 0657/1555] Make sure Grpc metapackage includes Grpc.Core.targets --- src/csharp/Grpc/Grpc.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/csharp/Grpc/Grpc.csproj b/src/csharp/Grpc/Grpc.csproj index b71cd93ff9a..ff6f0d84ef7 100644 --- a/src/csharp/Grpc/Grpc.csproj +++ b/src/csharp/Grpc/Grpc.csproj @@ -21,6 +21,7 @@ - + + From 1ce6d98fb4586e3110f5f3039cca16127c9aa030 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 24 Jun 2019 18:33:18 +0200 Subject: [PATCH 0658/1555] formatting --- src/csharp/Grpc/Grpc.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/csharp/Grpc/Grpc.csproj b/src/csharp/Grpc/Grpc.csproj index ff6f0d84ef7..4cf52cc39f7 100644 --- a/src/csharp/Grpc/Grpc.csproj +++ b/src/csharp/Grpc/Grpc.csproj @@ -21,7 +21,7 @@ - + From bb7829b87b31fcb428e92abc07230870bbed5b68 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 24 Jun 2019 12:53:40 -0700 Subject: [PATCH 0659/1555] Relocate cpu_cost to correct test case --- tools/run_tests/sanity/sanity_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/sanity/sanity_tests.yaml b/tools/run_tests/sanity/sanity_tests.yaml index 065be90108c..1c5dc5d4312 100644 --- a/tools/run_tests/sanity/sanity_tests.yaml +++ b/tools/run_tests/sanity/sanity_tests.yaml @@ -23,6 +23,6 @@ - script: tools/distrib/pylint_code.sh - script: tools/distrib/yapf_code.sh - script: tools/distrib/python/check_grpcio_tools.py + cpu_cost: 1000 - script: tools/distrib/check_shadow_boringssl_symbol_list.sh - script: tools/distrib/check_protobuf_pod_version.sh - cpu_cost: 1000 From 32944fdeb2ad7d4a480d347f5b08c07a7f7797f3 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 24 Jun 2019 13:56:56 -0700 Subject: [PATCH 0660/1555] Lay out bones of example --- examples/python/cancellation/BUILD.bazel | 64 ++++++++++ examples/python/cancellation/README.md | 0 examples/python/cancellation/client.py | 41 ++++++ examples/python/cancellation/hash_name.proto | 32 +++++ examples/python/cancellation/server.py | 117 ++++++++++++++++++ .../test/_cancellation_example_test.py | 0 6 files changed, 254 insertions(+) create mode 100644 examples/python/cancellation/BUILD.bazel create mode 100644 examples/python/cancellation/README.md create mode 100644 examples/python/cancellation/client.py create mode 100644 examples/python/cancellation/hash_name.proto create mode 100644 examples/python/cancellation/server.py create mode 100644 examples/python/cancellation/test/_cancellation_example_test.py diff --git a/examples/python/cancellation/BUILD.bazel b/examples/python/cancellation/BUILD.bazel new file mode 100644 index 00000000000..30bede22f22 --- /dev/null +++ b/examples/python/cancellation/BUILD.bazel @@ -0,0 +1,64 @@ +# gRPC Bazel BUILD file. +# +# Copyright 2019 The gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@grpc_python_dependencies//:requirements.bzl", "requirement") +load("//bazel:python_rules.bzl", "py_proto_library") + +proto_library( + name = "hash_name_proto", + srcs = ["hash_name.proto"] +) + +py_proto_library( + name = "hash_name_proto_pb2", + deps = [":hash_name_proto"], + well_known_protos = False, +) + +py_binary( + name = "client", + testonly = 1, + srcs = ["client.py"], + deps = [ + "//src/python/grpcio/grpc:grpcio", + ":hash_name_proto_pb2", + ], + srcs_version = "PY2AND3", +) + +py_binary( + name = "server", + testonly = 1, + srcs = ["server.py"], + deps = [ + "//src/python/grpcio/grpc:grpcio", + ":hash_name_proto_pb2" + ] + select({ + "//conditions:default": [requirement("futures")], + "//:python3": [], + }), + srcs_version = "PY2AND3", +) + +py_test( + name = "test/_cancellation_example_test", + srcs = ["test/_cancellation_example_test.py"], + data = [ + ":client", + ":server" + ], + size = "small", +) diff --git a/examples/python/cancellation/README.md b/examples/python/cancellation/README.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/python/cancellation/client.py b/examples/python/cancellation/client.py new file mode 100644 index 00000000000..b76ad0eabb5 --- /dev/null +++ b/examples/python/cancellation/client.py @@ -0,0 +1,41 @@ +# Copyright the 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""An example of cancelling requests in gRPC.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +from concurrent import futures +import logging +import time + +import grpc + +from examples.python.cancellation import hash_name_pb2 +from examples.python.cancellation import hash_name_pb2_grpc + +_LOGGER = logging.getLogger(__name__) + +def main(): + # TODO(rbellevi): Fix the connaissance of target. + with grpc.insecure_channel('localhost:50051') as channel: + stub = hash_name_pb2_grpc.HashFinderStub(channel) + response = stub.Find(hash_name_pb2.HashNameRequest(desired_name="doctor", + maximum_hamming_distance=0)) + print(response) + +if __name__ == "__main__": + logging.basicConfig() + main() diff --git a/examples/python/cancellation/hash_name.proto b/examples/python/cancellation/hash_name.proto new file mode 100644 index 00000000000..b56d0f27a1e --- /dev/null +++ b/examples/python/cancellation/hash_name.proto @@ -0,0 +1,32 @@ +// Copyright 2019 the gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package hash_name; + +message HashNameRequest { + string desired_name = 1; + int32 maximum_hamming_distance = 2; +} + +message HashNameResponse { + string secret = 1; + string hashed_name = 2; + int32 hamming_distance = 3; +} + +service HashFinder { + rpc Find (HashNameRequest) returns (HashNameResponse) {} +} diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py new file mode 100644 index 00000000000..6aa3be4d3f2 --- /dev/null +++ b/examples/python/cancellation/server.py @@ -0,0 +1,117 @@ +# Copyright the 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""An example of cancelling requests in gRPC.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +from concurrent import futures +from collections import deque +import base64 +import logging +import hashlib +import struct +import time + +import grpc + +from examples.python.cancellation import hash_name_pb2 +from examples.python.cancellation import hash_name_pb2_grpc + + +_LOGGER = logging.getLogger(__name__) +_SERVER_HOST = 'localhost' +_ONE_DAY_IN_SECONDS = 60 * 60 * 24 + + +def _get_hamming_distance(a, b): + """Calculates hamming distance between strings of equal length.""" + assert len(a) == len(b), "'{}', '{}'".format(a, b) + distance = 0 + for char_a, char_b in zip(a, b): + if char_a.lower() != char_b.lower(): + distance += 1 + return distance + + +def _get_substring_hamming_distance(candidate, target): + """Calculates the minimum hamming distance between between the target + and any substring of the candidate. + + Args: + candidate: The string whose substrings will be tested. + target: The target string. + + Returns: + The minimum Hamming distance between candidate and target. + """ + assert len(target) <= len(candidate) + assert len(candidate) != 0 + min_distance = None + for i in range(len(candidate) - len(target) + 1): + distance = _get_hamming_distance(candidate[i:i+len(target)], target) + if min_distance is None or distance < min_distance: + min_distance = distance + return min_distance + + +def _get_hash(secret): + hasher = hashlib.sha256() + hasher.update(secret) + return base64.b64encode(hasher.digest()) + + +class HashFinder(hash_name_pb2_grpc.HashFinderServicer): + + # TODO(rbellevi): Make this use less memory. + def Find(self, request, context): + to_check = deque((i,) for i in range(256)) + count = 0 + while True: + if count % 1000 == 0: + logging.info("Checked {} hashes.".format(count)) + current = to_check.popleft() + for i in range(256): + to_check.append(current + (i,)) + secret = b''.join(struct.pack('B', i) for i in current) + hash = _get_hash(secret) + distance = _get_substring_hamming_distance(hash, request.desired_name) + if distance <= request.maximum_hamming_distance: + return hash_name_pb2.HashNameResponse(secret=base64.b64encode(secret), + hashed_name=hash, + hamming_distance=distance) + count += 1 + + + +def main(): + port = 50051 + server = grpc.server(futures.ThreadPoolExecutor()) + hash_name_pb2_grpc.add_HashFinderServicer_to_server( + HashFinder(), server) + address = '{}:{}'.format(_SERVER_HOST, port) + server.add_insecure_port(address) + server.start() + print("Server listening at '{}'".format(address)) + try: + while True: + time.sleep(_ONE_DAY_IN_SECONDS) + except KeyboardInterrupt: + server.stop(None) + pass + +if __name__ == "__main__": + logging.basicConfig() + main() diff --git a/examples/python/cancellation/test/_cancellation_example_test.py b/examples/python/cancellation/test/_cancellation_example_test.py new file mode 100644 index 00000000000..e69de29bb2d From d61e37111d914eda867b455c94ebedf21b9e7612 Mon Sep 17 00:00:00 2001 From: Guantao Liu Date: Mon, 24 Jun 2019 14:58:30 -0700 Subject: [PATCH 0661/1555] Disable the backup poller in the client channel when using the background poller. Also, add the missing implementations of grpc_iomgr_run_in_background() for cfstream and libuv. --- src/core/ext/filters/client_channel/backup_poller.cc | 9 +++++---- src/core/lib/iomgr/iomgr_posix_cfstream.cc | 4 ++++ src/core/lib/iomgr/iomgr_uv.cc | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/core/ext/filters/client_channel/backup_poller.cc b/src/core/ext/filters/client_channel/backup_poller.cc index 9e51a83415e..06a241aa8c6 100644 --- a/src/core/ext/filters/client_channel/backup_poller.cc +++ b/src/core/ext/filters/client_channel/backup_poller.cc @@ -16,18 +16,19 @@ * */ -#include - #include "src/core/ext/filters/client_channel/backup_poller.h" #include #include #include +#include #include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/iomgr/error.h" +#include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/surface/channel.h" @@ -153,7 +154,7 @@ static void g_poller_init_locked() { void grpc_client_channel_start_backup_polling( grpc_pollset_set* interested_parties) { - if (g_poll_interval_ms == 0) { + if (g_poll_interval_ms == 0 || grpc_iomgr_run_in_background()) { return; } gpr_mu_lock(&g_poller_mu); @@ -171,7 +172,7 @@ void grpc_client_channel_start_backup_polling( void grpc_client_channel_stop_backup_polling( grpc_pollset_set* interested_parties) { - if (g_poll_interval_ms == 0) { + if (g_poll_interval_ms == 0 || grpc_iomgr_run_in_background()) { return; } grpc_pollset_set_del_pollset(interested_parties, g_poller->pollset); diff --git a/src/core/lib/iomgr/iomgr_posix_cfstream.cc b/src/core/lib/iomgr/iomgr_posix_cfstream.cc index cf4d05318ea..ac9a4497f77 100644 --- a/src/core/lib/iomgr/iomgr_posix_cfstream.cc +++ b/src/core/lib/iomgr/iomgr_posix_cfstream.cc @@ -90,4 +90,8 @@ void grpc_set_default_iomgr_platform() { grpc_set_iomgr_platform_vtable(&vtable); } +bool grpc_iomgr_run_in_background() { + return grpc_event_engine_run_in_background(); +} + #endif /* GRPC_CFSTREAM_IOMGR */ diff --git a/src/core/lib/iomgr/iomgr_uv.cc b/src/core/lib/iomgr/iomgr_uv.cc index 4a984446dba..d00bfa4d46e 100644 --- a/src/core/lib/iomgr/iomgr_uv.cc +++ b/src/core/lib/iomgr/iomgr_uv.cc @@ -37,4 +37,6 @@ void grpc_set_default_iomgr_platform() { grpc_custom_iomgr_init(&grpc_uv_socket_vtable, &uv_resolver_vtable, &uv_timer_vtable, &uv_pollset_vtable); } + +bool grpc_iomgr_run_in_background() { return false; } #endif From 335e655a7865f347efa92ed747363723c70dd299 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 24 Jun 2019 15:51:16 -0700 Subject: [PATCH 0662/1555] Free up server thread upon cancellation --- examples/python/cancellation/README.md | 9 +++ examples/python/cancellation/client.py | 27 +++++++- examples/python/cancellation/server.py | 87 +++++++++++++++++++------- 3 files changed, 97 insertions(+), 26 deletions(-) diff --git a/examples/python/cancellation/README.md b/examples/python/cancellation/README.md index e69de29bb2d..af0c8592625 100644 --- a/examples/python/cancellation/README.md +++ b/examples/python/cancellation/README.md @@ -0,0 +1,9 @@ +### Cancelling RPCs + +RPCs may be cancelled by both the client and the server. + +#### Cancellation on the Client Side + + + +#### Cancellation on the Server Side diff --git a/examples/python/cancellation/client.py b/examples/python/cancellation/client.py index b76ad0eabb5..599a774fefe 100644 --- a/examples/python/cancellation/client.py +++ b/examples/python/cancellation/client.py @@ -18,6 +18,7 @@ from __future__ import division from __future__ import print_function from concurrent import futures +import datetime import logging import time @@ -28,13 +29,33 @@ from examples.python.cancellation import hash_name_pb2_grpc _LOGGER = logging.getLogger(__name__) +# Interface: +# Cancel after we have n matches or we have an exact match. + + +# Test whether cancelling cancels a long-running unary RPC (I doubt it). +# Start the server with a single thread. +# Start a request and cancel it soon after. +# Start another request. If it succesfully cancelled, this will block forever. +# Add a bunch of logging so we know what's happening. + def main(): # TODO(rbellevi): Fix the connaissance of target. with grpc.insecure_channel('localhost:50051') as channel: stub = hash_name_pb2_grpc.HashFinderStub(channel) - response = stub.Find(hash_name_pb2.HashNameRequest(desired_name="doctor", - maximum_hamming_distance=0)) - print(response) + while True: + print("Sending request") + future = stub.Find.future(hash_name_pb2.HashNameRequest(desired_name="doctor", + maximum_hamming_distance=0)) + # TODO(rbellevi): Do not leave in a cancellation based on timeout. + # That's best handled by, well.. timeout. + try: + result = future.result(timeout=2.0) + print("Got response: \n{}".format(response)) + except grpc.FutureTimeoutError: + print("Cancelling request") + future.cancel() + if __name__ == "__main__": logging.basicConfig() diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index 6aa3be4d3f2..badf5698b4a 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -19,11 +19,13 @@ from __future__ import print_function from concurrent import futures from collections import deque +import argparse import base64 import logging import hashlib import struct import time +import threading import grpc @@ -31,10 +33,14 @@ from examples.python.cancellation import hash_name_pb2 from examples.python.cancellation import hash_name_pb2_grpc +_BYTE_MAX = 255 + _LOGGER = logging.getLogger(__name__) _SERVER_HOST = 'localhost' _ONE_DAY_IN_SECONDS = 60 * 60 * 24 +_DESCRIPTION = "A server for finding hashes similar to names." + def _get_hamming_distance(a, b): """Calculates hamming distance between strings of equal length.""" @@ -68,37 +74,61 @@ def _get_substring_hamming_distance(candidate, target): def _get_hash(secret): - hasher = hashlib.sha256() + hasher = hashlib.sha1() hasher.update(secret) return base64.b64encode(hasher.digest()) +def _find_secret_of_length(target, maximum_distance, length, stop_event): + digits = [0] * length + while True: + if stop_event.is_set(): + return hash_name_pb2.HashNameResponse() + secret = b''.join(struct.pack('B', i) for i in digits) + hash = _get_hash(secret) + distance = _get_substring_hamming_distance(hash, target) + if distance <= maximum_distance: + return hash_name_pb2.HashNameResponse(secret=base64.b64encode(secret), + hashed_name=hash, + hamming_distance=distance) + digits[-1] += 1 + i = length - 1 + while digits[i] == _BYTE_MAX + 1: + digits[i] = 0 + i -= 1 + if i == -1: + return None + else: + digits[i] += 1 + + +def _find_secret(target, maximum_distance, stop_event): + length = 1 + while True: + print("Checking strings of length {}.".format(length)) + match = _find_secret_of_length(target, maximum_distance, length, stop_event) + if match is not None: + return match + if stop_event.is_set(): + return hash_name_pb2.HashNameResponse() + length += 1 + + class HashFinder(hash_name_pb2_grpc.HashFinderServicer): - # TODO(rbellevi): Make this use less memory. def Find(self, request, context): - to_check = deque((i,) for i in range(256)) - count = 0 - while True: - if count % 1000 == 0: - logging.info("Checked {} hashes.".format(count)) - current = to_check.popleft() - for i in range(256): - to_check.append(current + (i,)) - secret = b''.join(struct.pack('B', i) for i in current) - hash = _get_hash(secret) - distance = _get_substring_hamming_distance(hash, request.desired_name) - if distance <= request.maximum_hamming_distance: - return hash_name_pb2.HashNameResponse(secret=base64.b64encode(secret), - hashed_name=hash, - hamming_distance=distance) - count += 1 + stop_event = threading.Event() + def on_rpc_done(): + stop_event.set() + context.add_callback(on_rpc_done) + print("Received request:\n{}".format(request)) + result = _find_secret(request.desired_name, request.maximum_hamming_distance, stop_event) + print("Returning result:\n{}".format(result)) + return result - -def main(): - port = 50051 - server = grpc.server(futures.ThreadPoolExecutor()) +def _run_server(port): + server = grpc.server(futures.ThreadPoolExecutor(max_workers=1)) hash_name_pb2_grpc.add_HashFinderServicer_to_server( HashFinder(), server) address = '{}:{}'.format(_SERVER_HOST, port) @@ -110,7 +140,18 @@ def main(): time.sleep(_ONE_DAY_IN_SECONDS) except KeyboardInterrupt: server.stop(None) - pass + + +def main(): + parser = argparse.ArgumentParser(description=_DESCRIPTION) + parser.add_argument( + '--port', + type=int, + default=50051, + nargs='?', + help='The port on which the server will listen.') + args = parser.parse_args() + _run_server(args.port) if __name__ == "__main__": logging.basicConfig() From 7dccc07c2ac7e54cd44ed1e81cdd2b6daf944f62 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 24 Jun 2019 16:02:34 -0700 Subject: [PATCH 0663/1555] Start writing README --- examples/python/cancellation/README.md | 31 +++++++++++++++++++++++++- examples/python/cancellation/client.py | 6 ----- examples/python/cancellation/server.py | 2 -- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/examples/python/cancellation/README.md b/examples/python/cancellation/README.md index af0c8592625..8d3e4767b9c 100644 --- a/examples/python/cancellation/README.md +++ b/examples/python/cancellation/README.md @@ -4,6 +4,35 @@ RPCs may be cancelled by both the client and the server. #### Cancellation on the Client Side - +A client may cancel an RPC for several reasons. Perhaps the data it requested +has been made irrelevant. Perhaps you, as the client, want to be a good citizen +of the server and are conserving compute resources. #### Cancellation on the Server Side + +A server is reponsible for cancellation in two ways. It must respond in some way +when a client initiates a cancellation, otherwise long-running computations +could continue indefinitely. + +It may also decide to cancel the RPC for its own reasons. In our example, the +server can be configured to cancel an RPC after a certain number of hashes has +been computed in order to conserve compute resources. + +##### Responding to Cancellations from a Servicer Thread + +It's important to remember that a gRPC Python server is backed by a thread pool +with a fixed size. When an RPC is cancelled, the library does *not* terminate +your servicer thread. It is your responsibility as the application author to +ensure that your servicer thread terminates soon after the RPC has been +cancelled. + +In this example, we use the `ServicerContext.add_callback` method to set a +`threading.Event` object when the RPC is terminated. We pass this `Event` object +down through our hashing algorithm and ensure to check that the RPC is still +ongoing before each iteration. + + +##### Initiating a Cancellation from a Servicer + +Initiating a cancellation from the server side is simpler. Just call +`ServicerContext.cancel()`. diff --git a/examples/python/cancellation/client.py b/examples/python/cancellation/client.py index 599a774fefe..93673ad8cc9 100644 --- a/examples/python/cancellation/client.py +++ b/examples/python/cancellation/client.py @@ -33,12 +33,6 @@ _LOGGER = logging.getLogger(__name__) # Cancel after we have n matches or we have an exact match. -# Test whether cancelling cancels a long-running unary RPC (I doubt it). -# Start the server with a single thread. -# Start a request and cancel it soon after. -# Start another request. If it succesfully cancelled, this will block forever. -# Add a bunch of logging so we know what's happening. - def main(): # TODO(rbellevi): Fix the connaissance of target. with grpc.insecure_channel('localhost:50051') as channel: diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index badf5698b4a..6af36809348 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -121,9 +121,7 @@ class HashFinder(hash_name_pb2_grpc.HashFinderServicer): def on_rpc_done(): stop_event.set() context.add_callback(on_rpc_done) - print("Received request:\n{}".format(request)) result = _find_secret(request.desired_name, request.maximum_hamming_distance, stop_event) - print("Returning result:\n{}".format(result)) return result From 12c296b3dcf46548dbf3e4d3b4251ee08c9e538e Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Mon, 24 Jun 2019 16:39:51 -0700 Subject: [PATCH 0664/1555] [Python] Add authentication extension example --- examples/python/auth/BUILD.bazel | 65 ++++++++++ examples/python/auth/README.md | 48 ++++++++ examples/python/auth/_credentials.py | 31 +++++ .../python/auth/credentials/localhost.crt | 19 +++ .../python/auth/credentials/localhost.key | 27 ++++ examples/python/auth/credentials/root.crt | 20 +++ examples/python/auth/customize_auth_client.py | 111 +++++++++++++++++ examples/python/auth/customize_auth_server.py | 115 ++++++++++++++++++ .../python/auth/test/_auth_example_test.py | 55 +++++++++ 9 files changed, 491 insertions(+) create mode 100644 examples/python/auth/BUILD.bazel create mode 100644 examples/python/auth/README.md create mode 100644 examples/python/auth/_credentials.py create mode 100644 examples/python/auth/credentials/localhost.crt create mode 100644 examples/python/auth/credentials/localhost.key create mode 100644 examples/python/auth/credentials/root.crt create mode 100644 examples/python/auth/customize_auth_client.py create mode 100644 examples/python/auth/customize_auth_server.py create mode 100644 examples/python/auth/test/_auth_example_test.py diff --git a/examples/python/auth/BUILD.bazel b/examples/python/auth/BUILD.bazel new file mode 100644 index 00000000000..6e748d55abe --- /dev/null +++ b/examples/python/auth/BUILD.bazel @@ -0,0 +1,65 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filegroup( + name = "_credentails_files", + testonly = 1, + srcs = [ + "credentials/localhost.key", + "credentials/localhost.crt", + "credentials/root.crt", + ], +) + +py_library( + name = "_credentials", + testonly = 1, + srcs = ["_credentials.py"], + data = [":_credentails_files"], +) + +py_binary( + name = "customize_auth_client", + testonly = 1, + srcs = ["customize_auth_client.py"], + deps = [ + ":_credentials", + "//src/python/grpcio/grpc:grpcio", + "//examples:py_helloworld", + ], +) + +py_binary( + name = "customize_auth_server", + testonly = 1, + srcs = ["customize_auth_server.py"], + deps = [ + ":_credentials", + "//src/python/grpcio/grpc:grpcio", + "//examples:py_helloworld", + + ], +) + +py_test( + name = "_auth_example_test", + srcs = ["test/_auth_example_test.py"], + deps = [ + "//src/python/grpcio/grpc:grpcio", + "//examples:py_helloworld", + ":customize_auth_client", + ":customize_auth_server", + ":_credentials", + ], +) diff --git a/examples/python/auth/README.md b/examples/python/auth/README.md new file mode 100644 index 00000000000..a13f829b68a --- /dev/null +++ b/examples/python/auth/README.md @@ -0,0 +1,48 @@ +# Authentication Extension Example in gRPC Python + +## Check Our Guide First + +For most common usage of authentication in gRPC Python, please see our [Authentication](https://grpc.io/docs/guides/auth/) guide's Python section, it includes: + +1. Server SSL credential setup +2. Client SSL credential setup +3. Authenticate with Google using a JWT +4. Authenticate with Google using an Oauth2 token + +Also, the guide talks about gRPC specific credential types. + +### Channel credentials + +Channel credentials are attached to a `Channel` object, the most common use case are SSL credentials. + +### Call credentials + +Call credentials are attached to a `Call` object (corresponding to an RPC). Under the hood, the call credentials is a function that takes in information of the RPC and modify metadata through callback. + +## About This Example + +This example focuses on extending gRPC authentication mechanism: +1) Customize authentication plugin; +2) Composite client side credentials; +3) Validation through interceptor on server side. + +## AuthMetadataPlugin: Manipulate metadata for each call + +Unlike TLS/SSL based authentication, the authentication extension in gRPC Python lives in a much higher level of abstraction. It relies on the transmit of metadata (HTTP Header) between client and server. gRPC Python provides a way to intercept an RPC and append authentication related metadata through [`AuthMetadataPlugin`](https://grpc.github.io/grpc/python/grpc.html#grpc.AuthMetadataPlugin). + +```Python +class AuthMetadataPlugin: + """A specification for custom authentication.""" + + def __call__(self, context, callback): + """Implements authentication by passing metadata to a callback. + + Implementations of this method must not block. + + Args: + context: An AuthMetadataContext providing information on the RPC that + the plugin is being called to authenticate. + callback: An AuthMetadataPluginCallback to be invoked either + synchronously or asynchronously. + """ +``` diff --git a/examples/python/auth/_credentials.py b/examples/python/auth/_credentials.py new file mode 100644 index 00000000000..45b19959bdd --- /dev/null +++ b/examples/python/auth/_credentials.py @@ -0,0 +1,31 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Loading SSL credentials for gRPC Python authentication example.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import os + + +def _load_credential_from_file(filepath): + real_path = os.path.join(os.path.dirname(__file__), filepath) + with open(real_path, 'r') as f: + return f.read() + + +SERVER_CERTIFICATE = _load_credential_from_file('credentials/localhost.crt') +SERVER_CERTIFICATE_KEY = _load_credential_from_file('credentials/localhost.key') +ROOT_CERTIFICATE = _load_credential_from_file('credentials/root.crt') diff --git a/examples/python/auth/credentials/localhost.crt b/examples/python/auth/credentials/localhost.crt new file mode 100644 index 00000000000..fc54fd492e1 --- /dev/null +++ b/examples/python/auth/credentials/localhost.crt @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDFjCCAf4CCQCzrLIhrWa55zANBgkqhkiG9w0BAQsFADBCMQswCQYDVQQGEwJV +UzETMBEGA1UECAwKQ2FsaWZvcm5pYTEPMA0GA1UECgwGR29vZ2xlMQ0wCwYDVQQL +DARnUlBDMCAXDTE5MDYyNDIyMjIzM1oYDzIxMTkwNTMxMjIyMjMzWjBWMQswCQYD +VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEPMA0GA1UECgwGR29vZ2xlMQ0w +CwYDVQQLDARnUlBDMRIwEAYDVQQDDAlsb2NhbGhvc3QwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQCtCW0TjugnIUu8BEVIYvdMP+/2GENQDjZhZ8eKR5C6 +toDGbgjsDtt/GxISAg4cg70fIvy0XolnGPZodvfHDM4lJ7yHBOdZD8TXQoE6okR7 +HZuLUJ20M0pXgWqtRewKRUjuYsSDXBnzLiZw1dcv9nGpo+Bqa8NonpiGRRpEkshF +D6T9KU9Ts/x+wMQBIra2Gj0UMh79jPhUuxcYAQA0JQGivnOtdwuPiumpnUT8j8h6 +tWg5l01EsCZWJecCF85KnGpJEVYPyPqBqGsy0nGS9plGotOWF87+jyUQt+KD63xA +aBmTro86mKDDKEK4JvzjVeMGz2UbVcLPiiZnErTFaiXJAgMBAAEwDQYJKoZIhvcN +AQELBQADggEBAKsDgOPCWp5WCy17vJbRlgfgk05sVNIHZtzrmdswjBmvSg8MUpep +XqcPNUpsljAXsf9UM5IFEMRdilUsFGWvHjBEtNAW8WUK9UV18WRuU//0w1Mp5HAN +xUEKb4BoyZr65vlCnTR+AR5c9FfPvLibhr5qHs2RA8Y3GyLOcGqBWed87jhdQLCc +P1bxB+96le5JeXq0tw215lxonI2/3ZYVK4/ok9gwXrQoWm8YieJqitk/ZQ4S17/4 +pynHtDfdxLn23EXeGx+UTxJGfpRmhEZdJ+MN7QGYoomzx5qS5XoYKxRNrDlirJpr +OqXIn8E1it+6d5gOZfuHawcNGhRLplE/pfA= +-----END CERTIFICATE----- diff --git a/examples/python/auth/credentials/localhost.key b/examples/python/auth/credentials/localhost.key new file mode 100644 index 00000000000..72e24632828 --- /dev/null +++ b/examples/python/auth/credentials/localhost.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEogIBAAKCAQEArQltE47oJyFLvARFSGL3TD/v9hhDUA42YWfHikeQuraAxm4I +7A7bfxsSEgIOHIO9HyL8tF6JZxj2aHb3xwzOJSe8hwTnWQ/E10KBOqJEex2bi1Cd +tDNKV4FqrUXsCkVI7mLEg1wZ8y4mcNXXL/ZxqaPgamvDaJ6YhkUaRJLIRQ+k/SlP +U7P8fsDEASK2tho9FDIe/Yz4VLsXGAEANCUBor5zrXcLj4rpqZ1E/I/IerVoOZdN +RLAmViXnAhfOSpxqSRFWD8j6gahrMtJxkvaZRqLTlhfO/o8lELfig+t8QGgZk66P +OpigwyhCuCb841XjBs9lG1XCz4omZxK0xWolyQIDAQABAoIBADeq/Kh6JT3RfGf0 +h8WN8TlaqHxnueAbcmtL0+oss+cdp7gu1jf7X6o4r0uT1a5ew40s2Fe+wj2kzkE1 +ZOlouTlC22gkr7j7Vbxa7PBMG/Pvxoa/XL0IczZLsGImSJXVTG1E4SvRiZeulTdf +1GbdxhtpWV1jZe5Wd4Na3+SHxF5S7m3PrHiZlYdz1ND+8XZs1NlL9+ej72qSFul9 +t/QjMWJ9pky/Wad5abnRLRyOsg+BsgnXbkUy2rD89ZxFMLda9pzXo3TPyAlBHonr +mkEsE4eRMWMpjBM79JbeyDdHn/cs/LjAZrzeDf7ugXr2CHQpKaM5O0PsNHezJII9 +L5kCfzECgYEA4M/rz1UP1/BJoSqigUlSs0tPAg8a5UlkVsh6Osuq72IPNo8qg/Fw +oV/IiIS+q+obRcFj1Od3PGdTpCJwW5dzd2fXBQGmGdj0HucnCrs13RtBh91JiF5i +y/YYI9KfgOG2ZT9gG68T0gTs6jRrS3Qd83npqjrkJqMOd7s00MK9tUcCgYEAxQq7 +T541oCYHSBRIIb0IrR25krZy9caxzCqPDwOcuuhaCqCiaq+ATvOWlSfgecm4eH0K +PCH0xlWxG0auPEwm4pA8+/WR/XJwscPZMuoht1EoKy1his4eKx/s7hHNeO6KOF0V +Y/zqIiuZnEwUoKbn7EqqNFSTT65PJKyGsICJFG8CgYAfaw9yl1myfQNdQb8aQGwN +YJ33FLNWje427qeeZe5KrDKiFloDvI9YDjHRWnPnRL1w/zj7fSm9yFb5HlMDieP6 +MQnsyjEzdY2QcA+VwVoiv3dmDHgFVeOKy6bOAtaFxYWfGr9MvygO9t9BT/gawGyb +JVORlc9i0vDnrMMR1dV7awKBgBpTWLtGc/u1mPt0Wj7HtsUKV6TWY32a0l5owTxM +S0BdksogtBJ06DukJ9Y9wawD23WdnyRxlPZ6tHLkeprrwbY7dypioOKvy4a0l+xJ +g7+uRCOgqIuXBkjUtx8HmeAyXp0xMo5tWArAsIFFWOwt4IadYygitJvMuh44PraO +NcJZAoGADEiV0dheXUCVr8DrtSom8DQMj92/G/FIYjXL8OUhh0+F+YlYP0+F8PEU +yYIWEqL/S5tVKYshimUXQa537JcRKsTVJBG/ZKD2kuqgOc72zQy3oplimXeJDCXY +h2eAQ0u8GN6tN9C4t8Kp4a3y6FGsxgu+UTxdnL3YQ+yHAVhtCzo= +-----END RSA PRIVATE KEY----- diff --git a/examples/python/auth/credentials/root.crt b/examples/python/auth/credentials/root.crt new file mode 100644 index 00000000000..0fa644d3e59 --- /dev/null +++ b/examples/python/auth/credentials/root.crt @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDWTCCAkGgAwIBAgIJAPOConZMwykwMA0GCSqGSIb3DQEBCwUAMEIxCzAJBgNV +BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMQ8wDQYDVQQKDAZHb29nbGUxDTAL +BgNVBAsMBGdSUEMwIBcNMTkwNjI0MjIyMDA3WhgPMjExOTA1MzEyMjIwMDdaMEIx +CzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMQ8wDQYDVQQKDAZHb29n +bGUxDTALBgNVBAsMBGdSUEMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB +AQCwqei3TfyLidnQNDJ2lierMYo229K92DuORni7nSjJQ59Jc3dNMsmqGQJjCD8o +6mTlKM/oCbs27Wpx+OxcOLvT95j2kiDGca1fCvaMdguIod09SWiyMpv/hp0trLv7 +NJIKHznath6rHYX2Ii3fZ1yCPzyQbEPSAA+GNpoNm1v1ZWmWKke9v7vLlS3inNlW +Mt9jepK7DrtbNZnVDjeItnppBSbVYRMxIyNHkepFbqXx5TpkCvl4M4XQZw9bfSxQ +i3WZ3q+T1Tw//OUdPNc+OfMhu0MA0QoMwikskP0NaIC3dbJZ5Ogx0RcnaB4E+9C6 +O/znUEh3WuKVl5HXBF+UwWoFAgMBAAGjUDBOMB0GA1UdDgQWBBRm3JIgzgK4G97J +fbMGatWMZc7V3jAfBgNVHSMEGDAWgBRm3JIgzgK4G97JfbMGatWMZc7V3jAMBgNV +HRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCNiV8x41if094ry2srS0YucpiN +3rTPk08FOLsENTMYai524TGXJti1P6ofGr5KXCL0uxTByHE3fEiMMud2TIY5iHQo +Y4mzDTTcb+Q7yKHwYZMlcp6nO8W+NeY5t+S0JPHhb8deKWepcN2UpXBUYQLw7AiE +l96T9Gi+vC9h/XE5IVwHFQXTxf5UYzXtW1nfapvrOONg/ms41dgmrRKIi+knWfiJ +FdHpHX2sfDAoJtnpEISX+nxRGNVTLY64utXWm4yxaZJshvy2s8zWJgRg7rtwAhTT +Np9E9MnihXLEmDI4Co9XlLPJyZFmqImsbmVuKFeQOCiLAoPJaMI2lbi7fiTo +-----END CERTIFICATE----- diff --git a/examples/python/auth/customize_auth_client.py b/examples/python/auth/customize_auth_client.py new file mode 100644 index 00000000000..324f629caf1 --- /dev/null +++ b/examples/python/auth/customize_auth_client.py @@ -0,0 +1,111 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Client of the Python example of customizing authentication mechanism.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import argparse +import contextlib +import logging +import os + +import grpc +from examples import helloworld_pb2, helloworld_pb2_grpc +from examples.python.auth import _credentials + +_LOGGER = logging.getLogger(__name__) +_LOGGER.setLevel(logging.INFO) + +_ONE_DAY_IN_SECONDS = 60 * 60 * 24 + +_SERVER_ADDR_TEMPLATE = 'localhost:%d' +_SIGNATURE_HEADER_KEY = 'x-signautre' + + +class AuthGateway(grpc.AuthMetadataPlugin): + + def __call__(self, context, callback): + """Implements authentication by passing metadata to a callback. + + Implementations of this method must not block. + + Args: + context: An AuthMetadataContext providing information on the RPC that + the plugin is being called to authenticate. + callback: An AuthMetadataPluginCallback to be invoked either + synchronously or asynchronously. + """ + # Example AuthMetadataContext object: + # AuthMetadataContext( + # service_url=u'https://localhost:50051/helloworld.Greeter', + # method_name=u'SayHello') + signature = context.method_name[::-1] + callback(((_SIGNATURE_HEADER_KEY, signature),), None) + + +def _load_credential_from_file(filepath): + real_path = os.path.join(os.path.dirname(__file__), filepath) + with open(real_path, 'r') as f: + return f.read() + + +@contextlib.contextmanager +def create_client_channel(addr): + # Call credential object will be invoked for every single RPC + call_credentials = grpc.metadata_call_credentials( + AuthGateway(), name='auth gateway') + # Channel credential will be valid for the entire channel + channel_credential = grpc.ssl_channel_credentials( + _credentials.ROOT_CERTIFICATE) + # Combining channel credentials and call credentials together + composite_credentials = grpc.composite_channel_credentials( + channel_credential, + call_credentials, + ) + channel = grpc.secure_channel(addr, composite_credentials) + yield channel + + +def send_rpc(channel): + stub = helloworld_pb2_grpc.GreeterStub(channel) + request = helloworld_pb2.HelloRequest(name='you') + try: + response = stub.SayHello(request) + except grpc.RpcError as rpc_error: + _LOGGER.error('Received error: %s', rpc_error) + return rpc_error + else: + _LOGGER.info('Received message: %s', response) + return response + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument( + '--port', + nargs=1, + type=int, + default=50051, + help='the address of server') + args = parser.parse_args() + + with create_client_channel(_SERVER_ADDR_TEMPLATE % args.port) as channel: + send_rpc(channel) + + +if __name__ == '__main__': + logging.basicConfig(level=logging.INFO) + main() diff --git a/examples/python/auth/customize_auth_server.py b/examples/python/auth/customize_auth_server.py new file mode 100644 index 00000000000..23805ae7c3e --- /dev/null +++ b/examples/python/auth/customize_auth_server.py @@ -0,0 +1,115 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Server of the Python example of customizing authentication mechanism.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import argparse +import contextlib +import logging +import os +import time +from concurrent import futures + +import grpc +from examples import helloworld_pb2, helloworld_pb2_grpc +from examples.python.auth import _credentials + +_LOGGER = logging.getLogger(__name__) +_LOGGER.setLevel(logging.INFO) + +_ONE_DAY_IN_SECONDS = 60 * 60 * 24 + +_LISTEN_ADDRESS_TEMPLATE = 'localhost:%d' +_SIGNATURE_HEADER_KEY = 'x-signautre' + + +class SignatureValidationInterceptor(grpc.ServerInterceptor): + + def __init__(self): + + def abort(ignored_request, context): + context.abort(grpc.StatusCode.UNAUTHENTICATED, 'Invalid signature') + + self._abortion = grpc.unary_unary_rpc_method_handler(abort) + + def intercept_service(self, continuation, handler_call_details): + # Example HandlerCallDetails object: + # _HandlerCallDetails( + # method=u'/helloworld.Greeter/SayHello', + # invocation_metadata=...) + method_name = handler_call_details.method.split('/')[-1] + expected_metadata = (_SIGNATURE_HEADER_KEY, method_name[::-1]) + if expected_metadata in handler_call_details.invocation_metadata: + return continuation(handler_call_details) + else: + return self._abortion + + +class SimpleGreeter(helloworld_pb2_grpc.GreeterServicer): + + @staticmethod + def SayHello(request, unused_context): + return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name) + + +def _load_credential_from_file(filepath): + real_path = os.path.join(os.path.dirname(__file__), filepath) + with open(real_path, 'r') as f: + return f.read() + + +@contextlib.contextmanager +def run_server(port): + # Bind interceptor to server + server = grpc.server( + futures.ThreadPoolExecutor(), + interceptors=(SignatureValidationInterceptor(),)) + helloworld_pb2_grpc.add_GreeterServicer_to_server(SimpleGreeter(), server) + + # Loading credentials + server_credentials = grpc.ssl_server_credentials((( + _credentials.SERVER_CERTIFICATE_KEY, + _credentials.SERVER_CERTIFICATE, + ),)) + + # Pass down credentails + port = server.add_secure_port(_LISTEN_ADDRESS_TEMPLATE % port, + server_credentials) + + server.start() + yield port + server.stop(0) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument( + '--port', nargs=1, type=int, default=50051, help='the listening port') + args = parser.parse_args() + + with run_server(args.port) as port: + logging.info('Server is listening at port :%d', port) + try: + while True: + time.sleep(_ONE_DAY_IN_SECONDS) + except KeyboardInterrupt: + pass + + +if __name__ == '__main__': + logging.basicConfig(level=logging.INFO) + main() diff --git a/examples/python/auth/test/_auth_example_test.py b/examples/python/auth/test/_auth_example_test.py new file mode 100644 index 00000000000..5659a1bf887 --- /dev/null +++ b/examples/python/auth/test/_auth_example_test.py @@ -0,0 +1,55 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Test for gRPC Python authentication example.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import unittest + +import grpc +from examples.python.auth import (_credentials, customize_auth_client, + customize_auth_server) + +_SERVER_ADDR_TEMPLATE = 'localhost:%d' + + +class AuthExampleTest(unittest.TestCase): + + def test_successful_call(self): + with customize_auth_server.run_server(0) as port: + with customize_auth_client.create_client_channel( + _SERVER_ADDR_TEMPLATE % port) as channel: + customize_auth_client.send_rpc(channel) + # No unhandled exception raised, test passed! + + def test_no_channel_credential(self): + with customize_auth_server.run_server(0) as port: + with grpc.insecure_channel(_SERVER_ADDR_TEMPLATE % port) as channel: + resp = customize_auth_client.send_rpc(channel) + self.assertEqual(resp.code(), grpc.StatusCode.UNAVAILABLE) + + def test_no_call_credential(self): + with customize_auth_server.run_server(0) as port: + channel_credential = grpc.ssl_channel_credentials( + _credentials.ROOT_CERTIFICATE) + with grpc.secure_channel(_SERVER_ADDR_TEMPLATE % port, + channel_credential) as channel: + resp = customize_auth_client.send_rpc(channel) + self.assertEqual(resp.code(), grpc.StatusCode.UNAUTHENTICATED) + + +if __name__ == '__main__': + unittest.main(verbosity=2) From b31431aea3e0caac3b3741d077e7b4bd692f05c9 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 24 Jun 2019 16:49:35 -0700 Subject: [PATCH 0665/1555] Switch over to a generator --- examples/python/cancellation/client.py | 6 +- examples/python/cancellation/hash_name.proto | 4 +- examples/python/cancellation/server.py | 61 +++++++++++++++----- 3 files changed, 54 insertions(+), 17 deletions(-) diff --git a/examples/python/cancellation/client.py b/examples/python/cancellation/client.py index 93673ad8cc9..bd5296a544f 100644 --- a/examples/python/cancellation/client.py +++ b/examples/python/cancellation/client.py @@ -40,12 +40,12 @@ def main(): while True: print("Sending request") future = stub.Find.future(hash_name_pb2.HashNameRequest(desired_name="doctor", - maximum_hamming_distance=0)) + ideal_hamming_distance=1)) # TODO(rbellevi): Do not leave in a cancellation based on timeout. # That's best handled by, well.. timeout. try: - result = future.result(timeout=2.0) - print("Got response: \n{}".format(response)) + result = future.result(timeout=20.0) + print("Got response: \n{}".format(result)) except grpc.FutureTimeoutError: print("Cancelling request") future.cancel() diff --git a/examples/python/cancellation/hash_name.proto b/examples/python/cancellation/hash_name.proto index b56d0f27a1e..e0a5c8357be 100644 --- a/examples/python/cancellation/hash_name.proto +++ b/examples/python/cancellation/hash_name.proto @@ -18,7 +18,8 @@ package hash_name; message HashNameRequest { string desired_name = 1; - int32 maximum_hamming_distance = 2; + int32 ideal_hamming_distance = 2; + int32 interesting_hamming_distance = 3; } message HashNameResponse { @@ -29,4 +30,5 @@ message HashNameResponse { service HashFinder { rpc Find (HashNameRequest) returns (HashNameResponse) {} + rpc FindRange (HashNameRequest) returns (stream HashNameResponse) {} } diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index 6af36809348..334a3770247 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -79,25 +79,39 @@ def _get_hash(secret): return base64.b64encode(hasher.digest()) -def _find_secret_of_length(target, maximum_distance, length, stop_event): +def _find_secret_of_length(target, ideal_distance, length, stop_event, interesting_hamming_distance=None): digits = [0] * length while True: if stop_event.is_set(): - return hash_name_pb2.HashNameResponse() + # Yield a sentinel and stop the generator if the RPC has been + # cancelled. + yield None + raise StopIteration() secret = b''.join(struct.pack('B', i) for i in digits) hash = _get_hash(secret) distance = _get_substring_hamming_distance(hash, target) - if distance <= maximum_distance: - return hash_name_pb2.HashNameResponse(secret=base64.b64encode(secret), + if interesting_hamming_distance is not None and distance <= interesting_hamming_distance: + # Surface interesting candidates, but don't stop. + yield hash_name_pb2.HashNameResponse(secret=base64.b64encode(secret), hashed_name=hash, hamming_distance=distance) + elif distance <= ideal_distance: + # Yield the ideal candidate followed by a sentinel to signal the end + # of the stream. + yield hash_name_pb2.HashNameResponse(secret=base64.b64encode(secret), + hashed_name=hash, + hamming_distance=distance) + yield None + raise StopIteration() digits[-1] += 1 i = length - 1 while digits[i] == _BYTE_MAX + 1: digits[i] = 0 i -= 1 if i == -1: - return None + # Terminate the generator since we've run out of strings of + # `length` bytes. + raise StopIteration() else: digits[i] += 1 @@ -106,11 +120,15 @@ def _find_secret(target, maximum_distance, stop_event): length = 1 while True: print("Checking strings of length {}.".format(length)) - match = _find_secret_of_length(target, maximum_distance, length, stop_event) - if match is not None: - return match - if stop_event.is_set(): - return hash_name_pb2.HashNameResponse() + for candidate in _find_secret_of_length(target, maximum_distance, length, stop_event): + if candidate is not None: + yield candidate + else: + raise StopIteration() + if stop_event.is_set(): + # Terminate the generator if the RPC has been cancelled. + raise StopIteration() + print("Incrementing length") length += 1 @@ -121,12 +139,28 @@ class HashFinder(hash_name_pb2_grpc.HashFinderServicer): def on_rpc_done(): stop_event.set() context.add_callback(on_rpc_done) - result = _find_secret(request.desired_name, request.maximum_hamming_distance, stop_event) - return result + candidates = list(_find_secret(request.desired_name, request.ideal_hamming_distance, stop_event)) + if not candidates: + return hash_name_pb2.HashNameResponse() + return candidates[-1] + + + def FindRange(self, request, context): + stop_event = threading.Event() + def on_rpc_done(): + stop_event.set() + context.add_callback(on_rpc_done) + secret_generator = _find_secret(request.desired_name, + request.ideal_hamming_distance, + stop_event, + interesting_hamming_distance=request.interesting_hamming_distance) + for candidate in secret_generator: + yield candidate def _run_server(port): - server = grpc.server(futures.ThreadPoolExecutor(max_workers=1)) + server = grpc.server(futures.ThreadPoolExecutor(max_workers=1), + maximum_concurrent_rpcs=1) hash_name_pb2_grpc.add_HashFinderServicer_to_server( HashFinder(), server) address = '{}:{}'.format(_SERVER_HOST, port) @@ -151,6 +185,7 @@ def main(): args = parser.parse_args() _run_server(args.port) + if __name__ == "__main__": logging.basicConfig() main() From 5f98b1e8efa76fe7670d7cd3cb5b1b86772578cf Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Mon, 24 Jun 2019 17:13:42 -0700 Subject: [PATCH 0666/1555] Fix 2/3 str/bytes compatibility issue --- examples/python/auth/_credentials.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/python/auth/_credentials.py b/examples/python/auth/_credentials.py index 45b19959bdd..39939f6284b 100644 --- a/examples/python/auth/_credentials.py +++ b/examples/python/auth/_credentials.py @@ -23,7 +23,7 @@ import os def _load_credential_from_file(filepath): real_path = os.path.join(os.path.dirname(__file__), filepath) with open(real_path, 'r') as f: - return f.read() + return bytes(f.read()) SERVER_CERTIFICATE = _load_credential_from_file('credentials/localhost.crt') From aa567e5364958862561a3815eaa41a2655aba8b4 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Mon, 24 Jun 2019 17:58:11 -0700 Subject: [PATCH 0667/1555] Adopt reviewer's advices --- examples/python/auth/BUILD.bazel | 16 ++--- examples/python/auth/README.md | 72 +++++++++++++++++-- ...th_client.py => customized_auth_client.py} | 4 +- ...th_server.py => customized_auth_server.py} | 15 ++-- 4 files changed, 86 insertions(+), 21 deletions(-) rename examples/python/auth/{customize_auth_client.py => customized_auth_client.py} (98%) rename examples/python/auth/{customize_auth_server.py => customized_auth_server.py} (92%) diff --git a/examples/python/auth/BUILD.bazel b/examples/python/auth/BUILD.bazel index 6e748d55abe..7bb4203f93f 100644 --- a/examples/python/auth/BUILD.bazel +++ b/examples/python/auth/BUILD.bazel @@ -13,7 +13,7 @@ # limitations under the License. filegroup( - name = "_credentails_files", + name = "_credentials_files", testonly = 1, srcs = [ "credentials/localhost.key", @@ -26,13 +26,13 @@ py_library( name = "_credentials", testonly = 1, srcs = ["_credentials.py"], - data = [":_credentails_files"], + data = [":_credentials_files"], ) py_binary( - name = "customize_auth_client", + name = "customized_auth_client", testonly = 1, - srcs = ["customize_auth_client.py"], + srcs = ["customized_auth_client.py"], deps = [ ":_credentials", "//src/python/grpcio/grpc:grpcio", @@ -41,9 +41,9 @@ py_binary( ) py_binary( - name = "customize_auth_server", + name = "customized_auth_server", testonly = 1, - srcs = ["customize_auth_server.py"], + srcs = ["customized_auth_server.py"], deps = [ ":_credentials", "//src/python/grpcio/grpc:grpcio", @@ -58,8 +58,8 @@ py_test( deps = [ "//src/python/grpcio/grpc:grpcio", "//examples:py_helloworld", - ":customize_auth_client", - ":customize_auth_server", + ":customized_auth_client", + ":customized_auth_server", ":_credentials", ], ) diff --git a/examples/python/auth/README.md b/examples/python/auth/README.md index a13f829b68a..2fd044b8a30 100644 --- a/examples/python/auth/README.md +++ b/examples/python/auth/README.md @@ -2,7 +2,9 @@ ## Check Our Guide First -For most common usage of authentication in gRPC Python, please see our [Authentication](https://grpc.io/docs/guides/auth/) guide's Python section, it includes: +For most common usage of authentication in gRPC Python, please see our +[Authentication](https://grpc.io/docs/guides/auth/) guide's Python section. The +Guide includes following scenarios: 1. Server SSL credential setup 2. Client SSL credential setup @@ -13,11 +15,14 @@ Also, the guide talks about gRPC specific credential types. ### Channel credentials -Channel credentials are attached to a `Channel` object, the most common use case are SSL credentials. +Channel credentials are attached to a `Channel` object, the most common use case +are SSL credentials. ### Call credentials -Call credentials are attached to a `Call` object (corresponding to an RPC). Under the hood, the call credentials is a function that takes in information of the RPC and modify metadata through callback. +Call credentials are attached to a `Call` object (corresponding to an RPC). +Under the hood, the call credentials is a function that takes in information of +the RPC and modify metadata through callback. ## About This Example @@ -28,7 +33,16 @@ This example focuses on extending gRPC authentication mechanism: ## AuthMetadataPlugin: Manipulate metadata for each call -Unlike TLS/SSL based authentication, the authentication extension in gRPC Python lives in a much higher level of abstraction. It relies on the transmit of metadata (HTTP Header) between client and server. gRPC Python provides a way to intercept an RPC and append authentication related metadata through [`AuthMetadataPlugin`](https://grpc.github.io/grpc/python/grpc.html#grpc.AuthMetadataPlugin). +Unlike TLS/SSL based authentication, the authentication extension in gRPC Python +lives at a much higher level of networking. It relies on the transmission of +metadata (HTTP Header) between client and server, instead of alternating the +transport protocol. + +gRPC Python provides a way to intercept an RPC and append authentication related +metadata through +[`AuthMetadataPlugin`](https://grpc.github.io/grpc/python/grpc.html#grpc.AuthMetadataPlugin). +Those in need of a custom authentication method may simply provide a concrete +implementation of the following interface: ```Python class AuthMetadataPlugin: @@ -46,3 +60,53 @@ class AuthMetadataPlugin: synchronously or asynchronously. """ ``` + +Then pass the instance of the concrete implementation to +`grpc.metadata_call_credentials` function to be converted into a +`CallCredentials` object. Please NOTE that it is possible to pass a Python +function object directly, but we recommend to inherit from the base class to +ensure implementation correctness. + + +```Python +def metadata_call_credentials(metadata_plugin, name=None): + """Construct CallCredentials from an AuthMetadataPlugin. + + Args: + metadata_plugin: An AuthMetadataPlugin to use for authentication. + name: An optional name for the plugin. + + Returns: + A CallCredentials. + """ +``` + +The `CallCredentials` object can be passed directly into an RPC like: + +```Python +call_credentials = grpc.metadata_call_credentials(my_foo_plugin) +stub.FooRpc(request, credentials=call_credentials) +``` + +Or you can use `ChannelCredentials` and `CallCredentials` at the same time by +combining them: + +```Python +channel_credentials = ... +call_credentials = ... +composite_credentials = grpc.composite_channel_credentials( + channel_credential, + call_credentials) +channel = grpc.secure_channel(server_address, composite_credentials) +``` + +It is also possible to apply multiple `CallCredentials` to a single RPC: + +```Python +call_credentials_foo = ... +call_credentials_bar = ... +call_credentials = grpc.composite_call_credentials( + call_credentials_foo, + call_credentials_bar) +stub.FooRpc(request, credentials=call_credentials) +``` diff --git a/examples/python/auth/customize_auth_client.py b/examples/python/auth/customized_auth_client.py similarity index 98% rename from examples/python/auth/customize_auth_client.py rename to examples/python/auth/customized_auth_client.py index 324f629caf1..c9ba7c70074 100644 --- a/examples/python/auth/customize_auth_client.py +++ b/examples/python/auth/customized_auth_client.py @@ -32,7 +32,7 @@ _LOGGER.setLevel(logging.INFO) _ONE_DAY_IN_SECONDS = 60 * 60 * 24 _SERVER_ADDR_TEMPLATE = 'localhost:%d' -_SIGNATURE_HEADER_KEY = 'x-signautre' +_SIGNATURE_HEADER_KEY = 'x-signature' class AuthGateway(grpc.AuthMetadataPlugin): @@ -96,7 +96,7 @@ def main(): parser = argparse.ArgumentParser() parser.add_argument( '--port', - nargs=1, + nargs='?', type=int, default=50051, help='the address of server') diff --git a/examples/python/auth/customize_auth_server.py b/examples/python/auth/customized_auth_server.py similarity index 92% rename from examples/python/auth/customize_auth_server.py rename to examples/python/auth/customized_auth_server.py index 23805ae7c3e..915c74a7510 100644 --- a/examples/python/auth/customize_auth_server.py +++ b/examples/python/auth/customized_auth_server.py @@ -34,7 +34,7 @@ _LOGGER.setLevel(logging.INFO) _ONE_DAY_IN_SECONDS = 60 * 60 * 24 _LISTEN_ADDRESS_TEMPLATE = 'localhost:%d' -_SIGNATURE_HEADER_KEY = 'x-signautre' +_SIGNATURE_HEADER_KEY = 'x-signature' class SignatureValidationInterceptor(grpc.ServerInterceptor): @@ -61,8 +61,7 @@ class SignatureValidationInterceptor(grpc.ServerInterceptor): class SimpleGreeter(helloworld_pb2_grpc.GreeterServicer): - @staticmethod - def SayHello(request, unused_context): + def SayHello(self, request, unused_context): return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name) @@ -86,19 +85,21 @@ def run_server(port): _credentials.SERVER_CERTIFICATE, ),)) - # Pass down credentails + # Pass down credentials port = server.add_secure_port(_LISTEN_ADDRESS_TEMPLATE % port, server_credentials) server.start() - yield port - server.stop(0) + try: + yield port + finally: + server.stop(0) def main(): parser = argparse.ArgumentParser() parser.add_argument( - '--port', nargs=1, type=int, default=50051, help='the listening port') + '--port', nargs='?', type=int, default=50051, help='the listening port') args = parser.parse_args() with run_server(args.port) as port: From 8f30132877c97ec79aa0f087ad4aece9c37ef35e Mon Sep 17 00:00:00 2001 From: Guantao Liu Date: Mon, 24 Jun 2019 21:15:01 -0700 Subject: [PATCH 0668/1555] Revert the previous clang-format changes to pass the clang format check on github. --- src/core/ext/filters/client_channel/backup_poller.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/ext/filters/client_channel/backup_poller.cc b/src/core/ext/filters/client_channel/backup_poller.cc index 06a241aa8c6..2e2d8d607de 100644 --- a/src/core/ext/filters/client_channel/backup_poller.cc +++ b/src/core/ext/filters/client_channel/backup_poller.cc @@ -16,12 +16,13 @@ * */ +#include + #include "src/core/ext/filters/client_channel/backup_poller.h" #include #include #include -#include #include #include "src/core/ext/filters/client_channel/client_channel.h" From 244279cb3651999a52e8b33f365e2d81819ce77b Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 25 Jun 2019 09:07:46 -0700 Subject: [PATCH 0669/1555] Add client CLI --- examples/python/cancellation/client.py | 43 +++++++++++++++++++++----- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/examples/python/cancellation/client.py b/examples/python/cancellation/client.py index bd5296a544f..63891d05842 100644 --- a/examples/python/cancellation/client.py +++ b/examples/python/cancellation/client.py @@ -18,6 +18,7 @@ from __future__ import division from __future__ import print_function from concurrent import futures +import argparse import datetime import logging import time @@ -27,20 +28,20 @@ import grpc from examples.python.cancellation import hash_name_pb2 from examples.python.cancellation import hash_name_pb2_grpc +_DESCRIPTION = "A client for finding hashes similar to names." _LOGGER = logging.getLogger(__name__) # Interface: -# Cancel after we have n matches or we have an exact match. +# Cancel on ctrl+c or an ideal candidate. - -def main(): - # TODO(rbellevi): Fix the connaissance of target. - with grpc.insecure_channel('localhost:50051') as channel: +def run_unary_client(server_target, name, ideal_distance): + # TODO(rbellevi): Cancel on ctrl+c + with grpc.insecure_channel(server_target) as channel: stub = hash_name_pb2_grpc.HashFinderStub(channel) while True: print("Sending request") - future = stub.Find.future(hash_name_pb2.HashNameRequest(desired_name="doctor", - ideal_hamming_distance=1)) + future = stub.Find.future(hash_name_pb2.HashNameRequest(desired_name=name, + ideal_hamming_distance=ideal_distance)) # TODO(rbellevi): Do not leave in a cancellation based on timeout. # That's best handled by, well.. timeout. try: @@ -51,6 +52,34 @@ def main(): future.cancel() +def run_streaming_client(target, name, ideal_distance, interesting_distance): + pass + + +def main(): + parser = argparse.ArgumentParser(description=_DESCRIPTION) + parser.add_argument("name", type=str, help='The desired name.') + parser.add_argument("--ideal-distance", default=0, nargs='?', + type=int, help="The desired Hamming distance.") + parser.add_argument( + '--server', + default='localhost:50051', + type=str, + nargs='?', + help='The host-port pair at which to reach the server.') + parser.add_argument( + '--show-inferior', + default=None, + type=int, + nargs='?', + help='Also show candidates with a Hamming distance less than this value.') + + args = parser.parse_args() + if args.show_inferior is not None: + run_streaming_client(args.server, args.name, args.ideal_distance, args.interesting_distance) + else: + run_unary_client(args.server, args.name, args.ideal_distance) + if __name__ == "__main__": logging.basicConfig() main() From b6a5e94f71917046ae3b0c29825ec986e11876ca Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 25 Jun 2019 09:36:49 -0700 Subject: [PATCH 0670/1555] Respond to ctrl+c on client side --- examples/python/cancellation/client.py | 27 ++++++++++++++------------ examples/python/cancellation/server.py | 2 ++ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/examples/python/cancellation/client.py b/examples/python/cancellation/client.py index 63891d05842..f86a32af175 100644 --- a/examples/python/cancellation/client.py +++ b/examples/python/cancellation/client.py @@ -22,6 +22,7 @@ import argparse import datetime import logging import time +import signal import grpc @@ -31,25 +32,27 @@ from examples.python.cancellation import hash_name_pb2_grpc _DESCRIPTION = "A client for finding hashes similar to names." _LOGGER = logging.getLogger(__name__) -# Interface: -# Cancel on ctrl+c or an ideal candidate. +_TIMEOUT_SECONDS = 0.05 def run_unary_client(server_target, name, ideal_distance): - # TODO(rbellevi): Cancel on ctrl+c with grpc.insecure_channel(server_target) as channel: stub = hash_name_pb2_grpc.HashFinderStub(channel) + print("Sending request") + future = stub.Find.future(hash_name_pb2.HashNameRequest(desired_name=name, + ideal_hamming_distance=ideal_distance)) + def cancel_request(unused_signum, unused_frame): + print("Cancelling request.") + future.cancel() + signal.signal(signal.SIGINT, cancel_request) while True: - print("Sending request") - future = stub.Find.future(hash_name_pb2.HashNameRequest(desired_name=name, - ideal_hamming_distance=ideal_distance)) - # TODO(rbellevi): Do not leave in a cancellation based on timeout. - # That's best handled by, well.. timeout. try: - result = future.result(timeout=20.0) - print("Got response: \n{}".format(result)) + result = future.result(timeout=_TIMEOUT_SECONDS) except grpc.FutureTimeoutError: - print("Cancelling request") - future.cancel() + continue + except grpc.FutureCancelledError: + break + print("Got response: \n{}".format(result)) + break def run_streaming_client(target, name, ideal_distance, interesting_distance): diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index 334a3770247..575c2fc8e74 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -137,9 +137,11 @@ class HashFinder(hash_name_pb2_grpc.HashFinderServicer): def Find(self, request, context): stop_event = threading.Event() def on_rpc_done(): + print("Attempting to regain servicer thread.") stop_event.set() context.add_callback(on_rpc_done) candidates = list(_find_secret(request.desired_name, request.ideal_hamming_distance, stop_event)) + print("Servicer thread returning.") if not candidates: return hash_name_pb2.HashNameResponse() return candidates[-1] From 7b8292406656e4a53b073153a50283bdeb5b1c5e Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Mon, 24 Jun 2019 19:53:41 -0700 Subject: [PATCH 0671/1555] Update module import according to name changes --- .../python/auth/customized_auth_client.py | 3 ++- .../python/auth/customized_auth_server.py | 3 ++- .../python/auth/test/_auth_example_test.py | 19 ++++++++++--------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/examples/python/auth/customized_auth_client.py b/examples/python/auth/customized_auth_client.py index c9ba7c70074..4ec0c2d3806 100644 --- a/examples/python/auth/customized_auth_client.py +++ b/examples/python/auth/customized_auth_client.py @@ -23,7 +23,8 @@ import logging import os import grpc -from examples import helloworld_pb2, helloworld_pb2_grpc +from examples import helloworld_pb2 +from examples import helloworld_pb2_grpc from examples.python.auth import _credentials _LOGGER = logging.getLogger(__name__) diff --git a/examples/python/auth/customized_auth_server.py b/examples/python/auth/customized_auth_server.py index 915c74a7510..f79c2639d90 100644 --- a/examples/python/auth/customized_auth_server.py +++ b/examples/python/auth/customized_auth_server.py @@ -25,7 +25,8 @@ import time from concurrent import futures import grpc -from examples import helloworld_pb2, helloworld_pb2_grpc +from examples import helloworld_pb2 +from examples import helloworld_pb2_grpc from examples.python.auth import _credentials _LOGGER = logging.getLogger(__name__) diff --git a/examples/python/auth/test/_auth_example_test.py b/examples/python/auth/test/_auth_example_test.py index 5659a1bf887..e2214267212 100644 --- a/examples/python/auth/test/_auth_example_test.py +++ b/examples/python/auth/test/_auth_example_test.py @@ -20,8 +20,9 @@ from __future__ import print_function import unittest import grpc -from examples.python.auth import (_credentials, customize_auth_client, - customize_auth_server) +from examples.python.auth import _credentials +from examples.python.auth import customized_auth_client +from examples.python.auth import customized_auth_server _SERVER_ADDR_TEMPLATE = 'localhost:%d' @@ -29,25 +30,25 @@ _SERVER_ADDR_TEMPLATE = 'localhost:%d' class AuthExampleTest(unittest.TestCase): def test_successful_call(self): - with customize_auth_server.run_server(0) as port: - with customize_auth_client.create_client_channel( + with customized_auth_server.run_server(0) as port: + with customized_auth_client.create_client_channel( _SERVER_ADDR_TEMPLATE % port) as channel: - customize_auth_client.send_rpc(channel) + customized_auth_client.send_rpc(channel) # No unhandled exception raised, test passed! def test_no_channel_credential(self): - with customize_auth_server.run_server(0) as port: + with customized_auth_server.run_server(0) as port: with grpc.insecure_channel(_SERVER_ADDR_TEMPLATE % port) as channel: - resp = customize_auth_client.send_rpc(channel) + resp = customized_auth_client.send_rpc(channel) self.assertEqual(resp.code(), grpc.StatusCode.UNAVAILABLE) def test_no_call_credential(self): - with customize_auth_server.run_server(0) as port: + with customized_auth_server.run_server(0) as port: channel_credential = grpc.ssl_channel_credentials( _credentials.ROOT_CERTIFICATE) with grpc.secure_channel(_SERVER_ADDR_TEMPLATE % port, channel_credential) as channel: - resp = customize_auth_client.send_rpc(channel) + resp = customized_auth_client.send_rpc(channel) self.assertEqual(resp.code(), grpc.StatusCode.UNAUTHENTICATED) From 9f0d0e030faa67dbd482a5a9a1879b33333b4656 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 25 Jun 2019 19:31:53 +0200 Subject: [PATCH 0672/1555] Syncing all the data-plane-api references. --- third_party/data-plane-api | 2 +- tools/run_tests/sanity/check_submodules.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/data-plane-api b/third_party/data-plane-api index ed9db8d1c82..a83394157ad 160000 --- a/third_party/data-plane-api +++ b/third_party/data-plane-api @@ -1 +1 @@ -Subproject commit ed9db8d1c8201ccdba2cb50a066f5956d6d91069 +Subproject commit a83394157ad97f4dadbc8ed81f56ad5b3a72e542 diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index 68741700d4e..0a70cf17dee 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -32,7 +32,7 @@ cat << EOF | awk '{ print $1 }' | sort > "$want_submodules" b29b21a81b32ec273f118f589f46d56ad3332420 third_party/boringssl (remotes/origin/chromium-stable) afc30d43eef92979b05776ec0963c9cede5fb80f third_party/boringssl-with-bazel (fips-20180716-116-gafc30d43e) e982924acee7f7313b4baa4ee5ec000c5e373c30 third_party/cares/cares (cares-1_15_0) - 911001cdca003337bdb93fab32740cde61bafee3 third_party/data-plane-api (heads/master) + a83394157ad97f4dadbc8ed81f56ad5b3a72e542 third_party/data-plane-api (heads/master) 28f50e0fed19872e0fd50dd23ce2ee8cd759338e third_party/gflags (v2.2.0-5-g30dbc81) 80ed4d0bbf65d57cc267dfc63bd2584557f11f9b third_party/googleapis (common-protos-1_3_1-915-g80ed4d0bb) ec44c6c1675c25b9827aacd08c02433cccde7780 third_party/googletest (release-1.8.0) From c9e83db6bcaf08024f8e00184990a1e72cfe2b82 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 25 Jun 2019 10:34:48 -0700 Subject: [PATCH 0673/1555] Implement streaming on the client side --- examples/python/cancellation/README.md | 28 +++++++++++++++ examples/python/cancellation/client.py | 50 ++++++++++++++++++++++++-- examples/python/cancellation/server.py | 8 +++-- 3 files changed, 81 insertions(+), 5 deletions(-) diff --git a/examples/python/cancellation/README.md b/examples/python/cancellation/README.md index 8d3e4767b9c..64ffa3cf1c7 100644 --- a/examples/python/cancellation/README.md +++ b/examples/python/cancellation/README.md @@ -8,6 +8,34 @@ A client may cancel an RPC for several reasons. Perhaps the data it requested has been made irrelevant. Perhaps you, as the client, want to be a good citizen of the server and are conserving compute resources. +##### Cancelling a Client-Side Unary RPC + +The default RPC methods on a stub will simply return the result of an RPC. + +```python +>>> stub = hash_name_pb2_grpc.HashFinderStub(channel) +>>> stub.Find(hash_name_pb2.HashNameRequest(desired_name=name)) + +``` + +But you may use the `future()` method to receive an instance of `grpc.Future`. +This interface allows you to wait on a response with a timeout, add a callback +to be executed when the RPC completes, or to cancel the RPC before it has +completed. + +In the example, we use this interface to cancel our in-progress RPC when the +user interrupts the process with ctrl-c. + +```python +stub = hash_name_pb2_grpc.HashFinderStub(channel) +future = stub.Find.future(hash_name_pb2.HashNameRequest(desired_name=name)) +def cancel_request(unused_signum, unused_frame): + future.cancel() +signal.signal(signal.SIGINT, cancel_request) +``` + +##### Cancelling a Client-Side Streaming RPC + #### Cancellation on the Server Side A server is reponsible for cancellation in two ways. It must respond in some way diff --git a/examples/python/cancellation/client.py b/examples/python/cancellation/client.py index f86a32af175..f57867a9ae6 100644 --- a/examples/python/cancellation/client.py +++ b/examples/python/cancellation/client.py @@ -23,6 +23,14 @@ import datetime import logging import time import signal +import threading + +try: + from queue import Queue + from queue import Empty as QueueEmpty +except ImportError: + from Queue import Queue + from Queue import Empty as QueueEmpty import grpc @@ -34,6 +42,8 @@ _LOGGER = logging.getLogger(__name__) _TIMEOUT_SECONDS = 0.05 +# TODO(rbellevi): Actually use the logger. + def run_unary_client(server_target, name, ideal_distance): with grpc.insecure_channel(server_target) as channel: stub = hash_name_pb2_grpc.HashFinderStub(channel) @@ -55,9 +65,43 @@ def run_unary_client(server_target, name, ideal_distance): break -def run_streaming_client(target, name, ideal_distance, interesting_distance): - pass +def run_streaming_client(server_target, name, ideal_distance, interesting_distance): + with grpc.insecure_channel(server_target) as channel: + stub = hash_name_pb2_grpc.HashFinderStub(channel) + print("Initiating RPC") + result_generator = stub.FindRange(hash_name_pb2.HashNameRequest(desired_name=name, + ideal_hamming_distance=ideal_distance, + interesting_hamming_distance=interesting_distance)) + def cancel_request(unused_signum, unused_frame): + print("Cancelling request.") + result_generator.cancel() + signal.signal(signal.SIGINT, cancel_request) + result_queue = Queue() + def iterate_responses(result_generator, result_queue): + try: + for result in result_generator: + print("Result: {}".format(result)) + result_queue.put(result) + except grpc.RpcError as rpc_error: + if rpc_error.code() != grpc.StatusCode.CANCELLED: + result_queue.put(None) + raise rpc_error + # Enqueue a sentinel to signal the end of the stream. + result_queue.put(None) + print("RPC complete") + response_thread = threading.Thread(target=iterate_responses, args=(result_generator, result_queue)) + response_thread.daemon = True + response_thread.start() + + while result_generator.running(): + try: + result = result_queue.get(timeout=_TIMEOUT_SECONDS) + except QueueEmpty: + continue + if result is None: + break + print("Got result: {}".format(result)) def main(): parser = argparse.ArgumentParser(description=_DESCRIPTION) @@ -79,7 +123,7 @@ def main(): args = parser.parse_args() if args.show_inferior is not None: - run_streaming_client(args.server, args.name, args.ideal_distance, args.interesting_distance) + run_streaming_client(args.server, args.name, args.ideal_distance, args.show_inferior) else: run_unary_client(args.server, args.name, args.ideal_distance) diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index 575c2fc8e74..12dbc5653ff 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -32,6 +32,8 @@ import grpc from examples.python.cancellation import hash_name_pb2 from examples.python.cancellation import hash_name_pb2_grpc +# TODO(rbellevi): Actually use the logger. +# TODO(rbellevi): Enforce per-user quotas with cancellation _BYTE_MAX = 255 @@ -116,11 +118,11 @@ def _find_secret_of_length(target, ideal_distance, length, stop_event, interesti digits[i] += 1 -def _find_secret(target, maximum_distance, stop_event): +def _find_secret(target, maximum_distance, stop_event, interesting_hamming_distance=None): length = 1 while True: print("Checking strings of length {}.".format(length)) - for candidate in _find_secret_of_length(target, maximum_distance, length, stop_event): + for candidate in _find_secret_of_length(target, maximum_distance, length, stop_event, interesting_hamming_distance=interesting_hamming_distance): if candidate is not None: yield candidate else: @@ -150,6 +152,7 @@ class HashFinder(hash_name_pb2_grpc.HashFinderServicer): def FindRange(self, request, context): stop_event = threading.Event() def on_rpc_done(): + print("Attempting to regain servicer thread.") stop_event.set() context.add_callback(on_rpc_done) secret_generator = _find_secret(request.desired_name, @@ -158,6 +161,7 @@ class HashFinder(hash_name_pb2_grpc.HashFinderServicer): interesting_hamming_distance=request.interesting_hamming_distance) for candidate in secret_generator: yield candidate + print("Regained servicer thread.") def _run_server(port): From 4ee154dd53c7ce6ad8bb2e7831af40abac4f545d Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 25 Jun 2019 10:50:04 -0700 Subject: [PATCH 0674/1555] Elaborate on unary cancellation --- examples/python/cancellation/README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/examples/python/cancellation/README.md b/examples/python/cancellation/README.md index 64ffa3cf1c7..08aea49e2c9 100644 --- a/examples/python/cancellation/README.md +++ b/examples/python/cancellation/README.md @@ -34,6 +34,29 @@ def cancel_request(unused_signum, unused_frame): signal.signal(signal.SIGINT, cancel_request) ``` +It's also important that you not block indefinitely on the RPC. Otherwise, the +signal handler will never have a chance to run. + +```python +while True: + try: + result = future.result(timeout=_TIMEOUT_SECONDS) + except grpc.FutureTimeoutError: + continue + except grpc.FutureCancelledError: + break + print("Got response: \n{}".format(result)) + break +``` + +Here, we repeatedly block on a result for up to `_TIMEOUT_SECONDS`. Doing so +gives us a chance for the signal handlers to run. In the case that out timeout +was reached, we simply continue on in the loop. In the case that the RPC was +cancelled (by our user's ctrl+c), we break out of the loop cleanly. Finally, if +we received the result of the RPC, we print it out for the user and exit the +loop. + + ##### Cancelling a Client-Side Streaming RPC #### Cancellation on the Server Side From 82aa4068c79ebb3ba37341199b078c9b6f910f8c Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 25 Jun 2019 11:02:10 -0700 Subject: [PATCH 0675/1555] Elaborate on cancelling streaming RPCs --- examples/python/cancellation/README.md | 64 ++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/examples/python/cancellation/README.md b/examples/python/cancellation/README.md index 08aea49e2c9..e7f6b42106e 100644 --- a/examples/python/cancellation/README.md +++ b/examples/python/cancellation/README.md @@ -8,7 +8,7 @@ A client may cancel an RPC for several reasons. Perhaps the data it requested has been made irrelevant. Perhaps you, as the client, want to be a good citizen of the server and are conserving compute resources. -##### Cancelling a Client-Side Unary RPC +##### Cancelling a Server-Side Unary RPC from the Client The default RPC methods on a stub will simply return the result of an RPC. @@ -50,14 +50,72 @@ while True: ``` Here, we repeatedly block on a result for up to `_TIMEOUT_SECONDS`. Doing so -gives us a chance for the signal handlers to run. In the case that out timeout +gives the signal handlers a chance to run. In the case that our timeout was reached, we simply continue on in the loop. In the case that the RPC was cancelled (by our user's ctrl+c), we break out of the loop cleanly. Finally, if we received the result of the RPC, we print it out for the user and exit the loop. -##### Cancelling a Client-Side Streaming RPC +##### Cancelling a Server-Side Streaming RPC from the Client + +Cancelling a Server-side streaming RPC is even simpler from the perspective of +the gRPC API. The default stub method is already an instance of `grpc.Future`, +so the methods outlined above still apply. It is also a generator, so we may +iterate over it to yield the results of our RPC. + +```python +stub = hash_name_pb2_grpc.HashFinderStub(channel) +result_generator = stub.FindRange(hash_name_pb2.HashNameRequest(desired_name=name)) +def cancel_request(unused_signum, unused_frame): + result_generator.cancel() +signal.signal(signal.SIGINT, cancel_request) +``` + +However, the streaming case is complicated by the fact that there is no way to +propagate a timeout to Python generators. As a result, simply iterating over the +results of the RPC can block indefinitely and the signal handler may never run. +Instead, we iterate over the generator on another thread and retrieve the +results on the main thread with a synchronized `Queue`. + +```python +result_queue = Queue() +def iterate_responses(result_generator, result_queue): + try: + for result in result_generator: + result_queue.put(result) + except grpc.RpcError as rpc_error: + if rpc_error.code() != grpc.StatusCode.CANCELLED: + result_queue.put(None) + raise rpc_error + result_queue.put(None) + print("RPC complete") +response_thread = threading.Thread(target=iterate_responses, args=(result_generator, result_queue)) +response_thread.daemon = True +response_thread.start() +``` + +While this thread iterating over the results may block indefinitely, we can +structure the code running on our main thread in such a way that signal handlers +are guaranteed to be run at least every `_TIMEOUT_SECONDS` seconds. + +```python +while result_generator.running(): + try: + result = result_queue.get(timeout=_TIMEOUT_SECONDS) + except QueueEmpty: + continue + if result is None: + break + print("Got result: {}".format(result)) +``` + +Similarly to the unary example above, we continue in a loop waiting for results, +taking care to block for intervals of `_TIMEOUT_SECONDS` at the longest. +Finally, we use `None` as a sentinel value to signal the end of the stream. + +Using this scheme, our process responds nicely to `SIGINT`s while also +explicitly cancelling its RPCs. #### Cancellation on the Server Side From cdae8ca6ad87c6fb94c7dc5dec7ba49f282b06aa Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 25 Jun 2019 11:11:03 -0700 Subject: [PATCH 0676/1555] Add intro about algorithm --- examples/python/cancellation/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/examples/python/cancellation/README.md b/examples/python/cancellation/README.md index e7f6b42106e..c50cc3b34df 100644 --- a/examples/python/cancellation/README.md +++ b/examples/python/cancellation/README.md @@ -2,6 +2,19 @@ RPCs may be cancelled by both the client and the server. +#### The Example + +In the example, we implement a silly algorithm. We search for bytestrings whose +hashes are similar to a given search string. For example, say we're looking for +the string "doctor". Our algorithm may `JrqhZVkTDoctYrUlXDbL6pfYQHU=` or +`RC9/7mlM3ldy4TdoctOc6WzYbO4=`. This is a brute force algorithm, so the server +performing the search must be conscious the resources it allows to each client +and each client must be conscientious of the resources demanded of the server. + +In particular, we ensure that client processes cancel the stream explicitly +before terminating and we ensure the server cancels RPCs that have gone on longer +than a certain number of iterations. + #### Cancellation on the Client Side A client may cancel an RPC for several reasons. Perhaps the data it requested From b9cc2c210f85f6b6a672b3f0be853e26fcfa9ae3 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 25 Jun 2019 11:15:43 -0700 Subject: [PATCH 0677/1555] Explain how we take care of servicer threads --- examples/python/cancellation/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/python/cancellation/README.md b/examples/python/cancellation/README.md index c50cc3b34df..7329ed834e8 100644 --- a/examples/python/cancellation/README.md +++ b/examples/python/cancellation/README.md @@ -153,6 +153,14 @@ In this example, we use the `ServicerContext.add_callback` method to set a down through our hashing algorithm and ensure to check that the RPC is still ongoing before each iteration. +```python +stop_event = threading.Event() +def on_rpc_done(): + # Regain servicer thread. + stop_event.set() +context.add_callback(on_rpc_done) +secret = _find_secret(stop_event) +``` ##### Initiating a Cancellation from a Servicer From 27030f58aaaca4910d427903d440a236bdd3709a Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 25 Jun 2019 21:06:21 +0200 Subject: [PATCH 0678/1555] Renaming data-plane-api to envoy-api. --- .gitmodules | 4 ++-- third_party/{data-plane-api => envoy-api} | 0 tools/codegen/core/gen_upb_api.sh | 2 +- tools/run_tests/sanity/check_submodules.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename third_party/{data-plane-api => envoy-api} (100%) diff --git a/.gitmodules b/.gitmodules index f4690a2687f..da360131e43 100644 --- a/.gitmodules +++ b/.gitmodules @@ -42,8 +42,8 @@ path = third_party/libcxx url = https://github.com/llvm-mirror/libcxx.git branch = release_60 -[submodule "third_party/data-plane-api"] - path = third_party/data-plane-api +[submodule "third_party/envoy-api"] + path = third_party/envoy-api url = https://github.com/envoyproxy/data-plane-api.git [submodule "third_party/googleapis"] path = third_party/googleapis diff --git a/third_party/data-plane-api b/third_party/envoy-api similarity index 100% rename from third_party/data-plane-api rename to third_party/envoy-api diff --git a/tools/codegen/core/gen_upb_api.sh b/tools/codegen/core/gen_upb_api.sh index ff21c49362c..4dbc4bbec3e 100755 --- a/tools/codegen/core/gen_upb_api.sh +++ b/tools/codegen/core/gen_upb_api.sh @@ -58,5 +58,5 @@ proto_files=( \ for i in "${proto_files[@]}" do - protoc -I=$PWD/third_party/data-plane-api -I=$PWD/third_party/googleapis -I=$PWD/third_party/protobuf -I=$PWD/third_party/protoc-gen-validate $i --upb_out=./src/core/ext/upb-generated --plugin=protoc-gen-upb=third_party/upb/bazel-bin/protoc-gen-upb + protoc -I=$PWD/third_party/envoy-api -I=$PWD/third_party/googleapis -I=$PWD/third_party/protobuf -I=$PWD/third_party/protoc-gen-validate $i --upb_out=./src/core/ext/upb-generated --plugin=protoc-gen-upb=third_party/upb/bazel-bin/protoc-gen-upb done diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index 0a70cf17dee..593db878173 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -32,7 +32,7 @@ cat << EOF | awk '{ print $1 }' | sort > "$want_submodules" b29b21a81b32ec273f118f589f46d56ad3332420 third_party/boringssl (remotes/origin/chromium-stable) afc30d43eef92979b05776ec0963c9cede5fb80f third_party/boringssl-with-bazel (fips-20180716-116-gafc30d43e) e982924acee7f7313b4baa4ee5ec000c5e373c30 third_party/cares/cares (cares-1_15_0) - a83394157ad97f4dadbc8ed81f56ad5b3a72e542 third_party/data-plane-api (heads/master) + a83394157ad97f4dadbc8ed81f56ad5b3a72e542 third_party/envoy-api (heads/master) 28f50e0fed19872e0fd50dd23ce2ee8cd759338e third_party/gflags (v2.2.0-5-g30dbc81) 80ed4d0bbf65d57cc267dfc63bd2584557f11f9b third_party/googleapis (common-protos-1_3_1-915-g80ed4d0bb) ec44c6c1675c25b9827aacd08c02433cccde7780 third_party/googletest (release-1.8.0) From 47871c274ed13b9cad8fe0e61c0a5fee860ed1fd Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Tue, 25 Jun 2019 12:47:27 -0700 Subject: [PATCH 0679/1555] Change channelz SubchannelNode to no longer take a ref to the Subchannel --- .../client_channel/client_channel_channelz.cc | 22 ++++++++++++------- .../client_channel/client_channel_channelz.h | 20 +++++++++++++++-- .../ext/filters/client_channel/subchannel.cc | 9 +++++++- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel_channelz.cc b/src/core/ext/filters/client_channel/client_channel_channelz.cc index e068d11dc41..fb7d1cbbc16 100644 --- a/src/core/ext/filters/client_channel/client_channel_channelz.cc +++ b/src/core/ext/filters/client_channel/client_channel_channelz.cc @@ -30,23 +30,29 @@ namespace grpc_core { namespace channelz { -SubchannelNode::SubchannelNode(Subchannel* subchannel, +SubchannelNode::SubchannelNode(const char* target_address, size_t channel_tracer_max_nodes) : BaseNode(EntityType::kSubchannel), - subchannel_(subchannel), - target_(UniquePtr(gpr_strdup(subchannel_->GetTargetAddress()))), + subchannel_destroyed_(false), + target_(UniquePtr(gpr_strdup(target_address))), trace_(channel_tracer_max_nodes) {} SubchannelNode::~SubchannelNode() {} +void SubchannelNode::UpdateConnectivityState(grpc_connectivity_state state) { + connectivity_state_.Store(state, MemoryOrder::RELAXED); +} + +void SubchannelNode::SetChildSocketUuid(intptr_t uuid) { + child_socket_uuid_.Store(uuid, MemoryOrder::RELAXED); +} + void SubchannelNode::PopulateConnectivityState(grpc_json* json) { grpc_connectivity_state state; - if (subchannel_ == nullptr) { + if (subchannel_destroyed_) { state = GRPC_CHANNEL_SHUTDOWN; } else { - state = subchannel_->CheckConnectivityState( - nullptr /* health_check_service_name */, - nullptr /* connected_subchannel */); + state = connectivity_state_.Load(MemoryOrder::RELAXED); } json = grpc_json_create_child(nullptr, json, "state", nullptr, GRPC_JSON_OBJECT, false); @@ -87,7 +93,7 @@ grpc_json* SubchannelNode::RenderJson() { call_counter_.PopulateCallCounts(json); json = top_level_json; // populate the child socket. - intptr_t socket_uuid = subchannel_->GetChildSocketUuid(); + intptr_t socket_uuid = child_socket_uuid_.Load(MemoryOrder::RELAXED); if (socket_uuid != 0) { grpc_json* array_parent = grpc_json_create_child( nullptr, json, "socketRef", nullptr, GRPC_JSON_ARRAY, false); diff --git a/src/core/ext/filters/client_channel/client_channel_channelz.h b/src/core/ext/filters/client_channel/client_channel_channelz.h index 9f11e928998..ef50f45f73a 100644 --- a/src/core/ext/filters/client_channel/client_channel_channelz.h +++ b/src/core/ext/filters/client_channel/client_channel_channelz.h @@ -34,9 +34,23 @@ namespace channelz { class SubchannelNode : public BaseNode { public: - SubchannelNode(Subchannel* subchannel, size_t channel_tracer_max_nodes); + SubchannelNode(const char* target_address, size_t channel_tracer_max_nodes); ~SubchannelNode() override; + void MarkSubchannelDestroyed() { + GPR_ASSERT(!subchannel_destroyed_); + subchannel_destroyed_ = true; + } + + // Used when the subchannel's transport connectivity state changes. + void UpdateConnectivityState(grpc_connectivity_state state); + + // Used when the subchannel's child socket uuid changes. This should be set + // when the subchannel's transport is created and set to 0 when the subchannel + // unrefs the transport. A uuid of 0 indicates that the child socket is no + // longer associated with this subchannel. + void SetChildSocketUuid(intptr_t uuid); + void MarkSubchannelDestroyed() { GPR_ASSERT(subchannel_ != nullptr); subchannel_ = nullptr; @@ -61,7 +75,9 @@ class SubchannelNode : public BaseNode { private: void PopulateConnectivityState(grpc_json* json); - Subchannel* subchannel_; + bool subchannel_destroyed_; + Atomic connectivity_state_{GRPC_CHANNEL_IDLE}; + Atomic child_socket_uuid_{0}; UniquePtr target_; CallCountingHelper call_counter_; ChannelTrace trace_; diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index dd16eded826..069a58bf605 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -344,6 +344,9 @@ class Subchannel::ConnectedSubchannelStateWatcher { self->pending_connectivity_state_)); } c->connected_subchannel_.reset(); + if (c->channelz_node() != nullptr) { + c->channelz_node()->SetChildSocketUuid(0); + } c->SetConnectivityStateLocked(GRPC_CHANNEL_TRANSIENT_FAILURE); c->backoff_begun_ = false; c->backoff_.Reset(); @@ -676,7 +679,7 @@ Subchannel::Subchannel(SubchannelKey* key, grpc_connector* connector, (size_t)grpc_channel_arg_get_integer(arg, options); if (channelz_enabled) { channelz_node_ = MakeRefCounted( - this, channel_tracer_max_memory); + this->GetTargetAddress(), channel_tracer_max_memory); channelz_node_->AddTraceEvent( channelz::ChannelTrace::Severity::Info, grpc_slice_from_static_string("subchannel created")); @@ -930,6 +933,7 @@ const char* SubchannelConnectivityStateChangeString( void Subchannel::SetConnectivityStateLocked(grpc_connectivity_state state) { state_ = state; if (channelz_node_ != nullptr) { + channelz_node()->UpdateConnectivityState(state); channelz_node_->AddTraceEvent( channelz::ChannelTrace::Severity::Info, grpc_slice_from_static_string( @@ -1081,6 +1085,9 @@ bool Subchannel::PublishTransportLocked() { New(stk, args_, channelz_node_, socket_uuid)); gpr_log(GPR_INFO, "New connected subchannel at %p for subchannel %p", connected_subchannel_.get(), this); + if (channelz_node() != nullptr) { + channelz_node()->SetChildSocketUuid(socket_uuid); + } // Instantiate state watcher. Will clean itself up. New(this); // Report initial state. From 4c852bf25f30b618e412c0a1e9dfb2f33cc75478 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 25 Jun 2019 12:50:10 -0700 Subject: [PATCH 0680/1555] Cancel RPCs after a hash limit has been reached --- examples/python/cancellation/README.md | 2 +- examples/python/cancellation/server.py | 61 ++++++++++++++++++++------ 2 files changed, 49 insertions(+), 14 deletions(-) diff --git a/examples/python/cancellation/README.md b/examples/python/cancellation/README.md index 7329ed834e8..b085c9bc016 100644 --- a/examples/python/cancellation/README.md +++ b/examples/python/cancellation/README.md @@ -162,7 +162,7 @@ context.add_callback(on_rpc_done) secret = _find_secret(stop_event) ``` -##### Initiating a Cancellation from a Servicer +##### Initiating a Cancellation on the Server Side Initiating a cancellation from the server side is simpler. Just call `ServicerContext.cancel()`. diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index 12dbc5653ff..3eb5f0bd45b 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -81,13 +81,22 @@ def _get_hash(secret): return base64.b64encode(hasher.digest()) -def _find_secret_of_length(target, ideal_distance, length, stop_event, interesting_hamming_distance=None): +class ResourceLimitExceededError(Exception): + """Signifies the request has exceeded configured limits.""" + +# TODO(rbellevi): Docstring all the things. +# TODO(rbellevi): File issue about indefinite blocking for server-side +# streaming. + + +def _find_secret_of_length(target, ideal_distance, length, stop_event, maximum_hashes, interesting_hamming_distance=None): digits = [0] * length + hashes_computed = 0 while True: if stop_event.is_set(): # Yield a sentinel and stop the generator if the RPC has been # cancelled. - yield None + yield None, hashes_computed raise StopIteration() secret = b''.join(struct.pack('B', i) for i in digits) hash = _get_hash(secret) @@ -96,14 +105,14 @@ def _find_secret_of_length(target, ideal_distance, length, stop_event, interesti # Surface interesting candidates, but don't stop. yield hash_name_pb2.HashNameResponse(secret=base64.b64encode(secret), hashed_name=hash, - hamming_distance=distance) + hamming_distance=distance), hashes_computed elif distance <= ideal_distance: # Yield the ideal candidate followed by a sentinel to signal the end # of the stream. yield hash_name_pb2.HashNameResponse(secret=base64.b64encode(secret), hashed_name=hash, - hamming_distance=distance) - yield None + hamming_distance=distance), hashes_computed + yield None, hashes_computed raise StopIteration() digits[-1] += 1 i = length - 1 @@ -116,13 +125,19 @@ def _find_secret_of_length(target, ideal_distance, length, stop_event, interesti raise StopIteration() else: digits[i] += 1 + hashes_computed += 1 + if hashes_computed == maximum_hashes: + raise ResourceLimitExceededError() -def _find_secret(target, maximum_distance, stop_event, interesting_hamming_distance=None): +def _find_secret(target, maximum_distance, stop_event, maximum_hashes, interesting_hamming_distance=None): length = 1 + total_hashes = 0 while True: print("Checking strings of length {}.".format(length)) - for candidate in _find_secret_of_length(target, maximum_distance, length, stop_event, interesting_hamming_distance=interesting_hamming_distance): + last_hashes_computed = 0 + for candidate, hashes_computed in _find_secret_of_length(target, maximum_distance, length, stop_event, maximum_hashes - total_hashes, interesting_hamming_distance=interesting_hamming_distance): + last_hashes_computed = hashes_computed if candidate is not None: yield candidate else: @@ -130,19 +145,28 @@ def _find_secret(target, maximum_distance, stop_event, interesting_hamming_dista if stop_event.is_set(): # Terminate the generator if the RPC has been cancelled. raise StopIteration() + total_hashes += last_hashes_computed print("Incrementing length") length += 1 class HashFinder(hash_name_pb2_grpc.HashFinderServicer): + def __init__(self, maximum_hashes): + super(HashFinder, self).__init__() + self._maximum_hashes = maximum_hashes + def Find(self, request, context): stop_event = threading.Event() def on_rpc_done(): print("Attempting to regain servicer thread.") stop_event.set() context.add_callback(on_rpc_done) - candidates = list(_find_secret(request.desired_name, request.ideal_hamming_distance, stop_event)) + try: + candidates = list(_find_secret(request.desired_name, request.ideal_hamming_distance, stop_event, self._maximum_hashes)) + except ResourceLimitExceededError: + print("Cancelling RPC due to exhausted resources.") + context.cancel() print("Servicer thread returning.") if not candidates: return hash_name_pb2.HashNameResponse() @@ -158,17 +182,22 @@ class HashFinder(hash_name_pb2_grpc.HashFinderServicer): secret_generator = _find_secret(request.desired_name, request.ideal_hamming_distance, stop_event, + self._maximum_hashes, interesting_hamming_distance=request.interesting_hamming_distance) - for candidate in secret_generator: - yield candidate + try: + for candidate in secret_generator: + yield candidate + except ResourceLimitExceededError: + print("Cancelling RPC due to exhausted resources.") + context.cancel print("Regained servicer thread.") -def _run_server(port): +def _run_server(port, maximum_hashes): server = grpc.server(futures.ThreadPoolExecutor(max_workers=1), maximum_concurrent_rpcs=1) hash_name_pb2_grpc.add_HashFinderServicer_to_server( - HashFinder(), server) + HashFinder(maximum_hashes), server) address = '{}:{}'.format(_SERVER_HOST, port) server.add_insecure_port(address) server.start() @@ -188,8 +217,14 @@ def main(): default=50051, nargs='?', help='The port on which the server will listen.') + parser.add_argument( + '--maximum-hashes', + type=int, + default=10000, + nargs='?', + help='The maximum number of hashes to search before cancelling.') args = parser.parse_args() - _run_server(args.port) + _run_server(args.port, args.maximum_hashes) if __name__ == "__main__": From b7dc50942984cf04eccccf663c839a217100e69d Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Tue, 25 Jun 2019 12:53:12 -0700 Subject: [PATCH 0681/1555] Minor fix --- src/core/ext/filters/client_channel/subchannel.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 069a58bf605..68353b897e2 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -933,7 +933,7 @@ const char* SubchannelConnectivityStateChangeString( void Subchannel::SetConnectivityStateLocked(grpc_connectivity_state state) { state_ = state; if (channelz_node_ != nullptr) { - channelz_node()->UpdateConnectivityState(state); + channelz_node_->UpdateConnectivityState(state); channelz_node_->AddTraceEvent( channelz::ChannelTrace::Severity::Info, grpc_slice_from_static_string( @@ -1085,8 +1085,8 @@ bool Subchannel::PublishTransportLocked() { New(stk, args_, channelz_node_, socket_uuid)); gpr_log(GPR_INFO, "New connected subchannel at %p for subchannel %p", connected_subchannel_.get(), this); - if (channelz_node() != nullptr) { - channelz_node()->SetChildSocketUuid(socket_uuid); + if (channelz_node_ != nullptr) { + channelz_node_->SetChildSocketUuid(socket_uuid); } // Instantiate state watcher. Will clean itself up. New(this); From d137ee8a85a9389cb4dca5154939fed60622886a Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Tue, 25 Jun 2019 12:59:41 -0700 Subject: [PATCH 0682/1555] Fix format --- src/core/ext/filters/client_channel/subchannel.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 68353b897e2..28fe6d87c6d 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -344,7 +344,7 @@ class Subchannel::ConnectedSubchannelStateWatcher { self->pending_connectivity_state_)); } c->connected_subchannel_.reset(); - if (c->channelz_node() != nullptr) { + if (c->channelz_node() != nullptr) { c->channelz_node()->SetChildSocketUuid(0); } c->SetConnectivityStateLocked(GRPC_CHANNEL_TRANSIENT_FAILURE); From b12299701df6614c1fd5df86d9c46a5bda3d2d66 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 25 Jun 2019 13:00:09 -0700 Subject: [PATCH 0683/1555] Clean up logging --- examples/python/cancellation/README.md | 15 +++++++++++++++ examples/python/cancellation/client.py | 10 ++-------- examples/python/cancellation/server.py | 19 +++++++------------ 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/examples/python/cancellation/README.md b/examples/python/cancellation/README.md index b085c9bc016..d5f9a844fcc 100644 --- a/examples/python/cancellation/README.md +++ b/examples/python/cancellation/README.md @@ -166,3 +166,18 @@ secret = _find_secret(stop_event) Initiating a cancellation from the server side is simpler. Just call `ServicerContext.cancel()`. + +In our example, we ensure that no single client is monopolizing the server by +cancelling after a configurable number of hashes have been checked. + +```python +try: + for candidate in secret_generator: + yield candidate +except ResourceLimitExceededError: + print("Cancelling RPC due to exhausted resources.") + context.cancel() +``` + +In this type of situation, you may also consider returning a more specific error +using the [`grpcio-status`](https://pypi.org/project/grpcio-status/) package. diff --git a/examples/python/cancellation/client.py b/examples/python/cancellation/client.py index f57867a9ae6..f97a8c05e50 100644 --- a/examples/python/cancellation/client.py +++ b/examples/python/cancellation/client.py @@ -47,11 +47,9 @@ _TIMEOUT_SECONDS = 0.05 def run_unary_client(server_target, name, ideal_distance): with grpc.insecure_channel(server_target) as channel: stub = hash_name_pb2_grpc.HashFinderStub(channel) - print("Sending request") future = stub.Find.future(hash_name_pb2.HashNameRequest(desired_name=name, ideal_hamming_distance=ideal_distance)) def cancel_request(unused_signum, unused_frame): - print("Cancelling request.") future.cancel() signal.signal(signal.SIGINT, cancel_request) while True: @@ -61,19 +59,17 @@ def run_unary_client(server_target, name, ideal_distance): continue except grpc.FutureCancelledError: break - print("Got response: \n{}".format(result)) + print(result) break def run_streaming_client(server_target, name, ideal_distance, interesting_distance): with grpc.insecure_channel(server_target) as channel: stub = hash_name_pb2_grpc.HashFinderStub(channel) - print("Initiating RPC") result_generator = stub.FindRange(hash_name_pb2.HashNameRequest(desired_name=name, ideal_hamming_distance=ideal_distance, interesting_hamming_distance=interesting_distance)) def cancel_request(unused_signum, unused_frame): - print("Cancelling request.") result_generator.cancel() signal.signal(signal.SIGINT, cancel_request) result_queue = Queue() @@ -81,7 +77,6 @@ def run_streaming_client(server_target, name, ideal_distance, interesting_distan def iterate_responses(result_generator, result_queue): try: for result in result_generator: - print("Result: {}".format(result)) result_queue.put(result) except grpc.RpcError as rpc_error: if rpc_error.code() != grpc.StatusCode.CANCELLED: @@ -89,7 +84,6 @@ def run_streaming_client(server_target, name, ideal_distance, interesting_distan raise rpc_error # Enqueue a sentinel to signal the end of the stream. result_queue.put(None) - print("RPC complete") response_thread = threading.Thread(target=iterate_responses, args=(result_generator, result_queue)) response_thread.daemon = True response_thread.start() @@ -101,7 +95,7 @@ def run_streaming_client(server_target, name, ideal_distance, interesting_distan continue if result is None: break - print("Got result: {}".format(result)) + print(result) def main(): parser = argparse.ArgumentParser(description=_DESCRIPTION) diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index 3eb5f0bd45b..a2e8e947746 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -32,9 +32,6 @@ import grpc from examples.python.cancellation import hash_name_pb2 from examples.python.cancellation import hash_name_pb2_grpc -# TODO(rbellevi): Actually use the logger. -# TODO(rbellevi): Enforce per-user quotas with cancellation - _BYTE_MAX = 255 _LOGGER = logging.getLogger(__name__) @@ -134,7 +131,6 @@ def _find_secret(target, maximum_distance, stop_event, maximum_hashes, interesti length = 1 total_hashes = 0 while True: - print("Checking strings of length {}.".format(length)) last_hashes_computed = 0 for candidate, hashes_computed in _find_secret_of_length(target, maximum_distance, length, stop_event, maximum_hashes - total_hashes, interesting_hamming_distance=interesting_hamming_distance): last_hashes_computed = hashes_computed @@ -146,7 +142,6 @@ def _find_secret(target, maximum_distance, stop_event, maximum_hashes, interesti # Terminate the generator if the RPC has been cancelled. raise StopIteration() total_hashes += last_hashes_computed - print("Incrementing length") length += 1 @@ -159,15 +154,15 @@ class HashFinder(hash_name_pb2_grpc.HashFinderServicer): def Find(self, request, context): stop_event = threading.Event() def on_rpc_done(): - print("Attempting to regain servicer thread.") + _LOGGER.debug("Attempting to regain servicer thread.") stop_event.set() context.add_callback(on_rpc_done) try: candidates = list(_find_secret(request.desired_name, request.ideal_hamming_distance, stop_event, self._maximum_hashes)) except ResourceLimitExceededError: - print("Cancelling RPC due to exhausted resources.") + _LOGGER.info("Cancelling RPC due to exhausted resources.") context.cancel() - print("Servicer thread returning.") + _LOGGER.debug("Servicer thread returning.") if not candidates: return hash_name_pb2.HashNameResponse() return candidates[-1] @@ -176,7 +171,7 @@ class HashFinder(hash_name_pb2_grpc.HashFinderServicer): def FindRange(self, request, context): stop_event = threading.Event() def on_rpc_done(): - print("Attempting to regain servicer thread.") + _LOGGER.debug("Attempting to regain servicer thread.") stop_event.set() context.add_callback(on_rpc_done) secret_generator = _find_secret(request.desired_name, @@ -188,9 +183,9 @@ class HashFinder(hash_name_pb2_grpc.HashFinderServicer): for candidate in secret_generator: yield candidate except ResourceLimitExceededError: - print("Cancelling RPC due to exhausted resources.") - context.cancel - print("Regained servicer thread.") + _LOGGER.info("Cancelling RPC due to exhausted resources.") + context.cancel() + _LOGGER.debug("Regained servicer thread.") def _run_server(port, maximum_hashes): From 8f1bfdab55f08cebdf60d5847634ba894904e62e Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 25 Jun 2019 13:01:22 -0700 Subject: [PATCH 0684/1555] Yapf --- examples/python/cancellation/client.py | 41 +++++++++++----- examples/python/cancellation/server.py | 65 ++++++++++++++++++-------- 2 files changed, 75 insertions(+), 31 deletions(-) diff --git a/examples/python/cancellation/client.py b/examples/python/cancellation/client.py index f97a8c05e50..288f93d057e 100644 --- a/examples/python/cancellation/client.py +++ b/examples/python/cancellation/client.py @@ -44,13 +44,17 @@ _TIMEOUT_SECONDS = 0.05 # TODO(rbellevi): Actually use the logger. + def run_unary_client(server_target, name, ideal_distance): with grpc.insecure_channel(server_target) as channel: stub = hash_name_pb2_grpc.HashFinderStub(channel) - future = stub.Find.future(hash_name_pb2.HashNameRequest(desired_name=name, - ideal_hamming_distance=ideal_distance)) + future = stub.Find.future( + hash_name_pb2.HashNameRequest( + desired_name=name, ideal_hamming_distance=ideal_distance)) + def cancel_request(unused_signum, unused_frame): future.cancel() + signal.signal(signal.SIGINT, cancel_request) while True: try: @@ -63,14 +67,19 @@ def run_unary_client(server_target, name, ideal_distance): break -def run_streaming_client(server_target, name, ideal_distance, interesting_distance): +def run_streaming_client(server_target, name, ideal_distance, + interesting_distance): with grpc.insecure_channel(server_target) as channel: stub = hash_name_pb2_grpc.HashFinderStub(channel) - result_generator = stub.FindRange(hash_name_pb2.HashNameRequest(desired_name=name, - ideal_hamming_distance=ideal_distance, - interesting_hamming_distance=interesting_distance)) + result_generator = stub.FindRange( + hash_name_pb2.HashNameRequest( + desired_name=name, + ideal_hamming_distance=ideal_distance, + interesting_hamming_distance=interesting_distance)) + def cancel_request(unused_signum, unused_frame): result_generator.cancel() + signal.signal(signal.SIGINT, cancel_request) result_queue = Queue() @@ -84,7 +93,9 @@ def run_streaming_client(server_target, name, ideal_distance, interesting_distan raise rpc_error # Enqueue a sentinel to signal the end of the stream. result_queue.put(None) - response_thread = threading.Thread(target=iterate_responses, args=(result_generator, result_queue)) + + response_thread = threading.Thread( + target=iterate_responses, args=(result_generator, result_queue)) response_thread.daemon = True response_thread.start() @@ -97,11 +108,16 @@ def run_streaming_client(server_target, name, ideal_distance, interesting_distan break print(result) + def main(): parser = argparse.ArgumentParser(description=_DESCRIPTION) parser.add_argument("name", type=str, help='The desired name.') - parser.add_argument("--ideal-distance", default=0, nargs='?', - type=int, help="The desired Hamming distance.") + parser.add_argument( + "--ideal-distance", + default=0, + nargs='?', + type=int, + help="The desired Hamming distance.") parser.add_argument( '--server', default='localhost:50051', @@ -113,14 +129,17 @@ def main(): default=None, type=int, nargs='?', - help='Also show candidates with a Hamming distance less than this value.') + help='Also show candidates with a Hamming distance less than this value.' + ) args = parser.parse_args() if args.show_inferior is not None: - run_streaming_client(args.server, args.name, args.ideal_distance, args.show_inferior) + run_streaming_client(args.server, args.name, args.ideal_distance, + args.show_inferior) else: run_unary_client(args.server, args.name, args.ideal_distance) + if __name__ == "__main__": logging.basicConfig() main() diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index a2e8e947746..1af07e4a1e4 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -66,7 +66,7 @@ def _get_substring_hamming_distance(candidate, target): assert len(candidate) != 0 min_distance = None for i in range(len(candidate) - len(target) + 1): - distance = _get_hamming_distance(candidate[i:i+len(target)], target) + distance = _get_hamming_distance(candidate[i:i + len(target)], target) if min_distance is None or distance < min_distance: min_distance = distance return min_distance @@ -81,12 +81,18 @@ def _get_hash(secret): class ResourceLimitExceededError(Exception): """Signifies the request has exceeded configured limits.""" + # TODO(rbellevi): Docstring all the things. # TODO(rbellevi): File issue about indefinite blocking for server-side # streaming. -def _find_secret_of_length(target, ideal_distance, length, stop_event, maximum_hashes, interesting_hamming_distance=None): +def _find_secret_of_length(target, + ideal_distance, + length, + stop_event, + maximum_hashes, + interesting_hamming_distance=None): digits = [0] * length hashes_computed = 0 while True: @@ -100,15 +106,17 @@ def _find_secret_of_length(target, ideal_distance, length, stop_event, maximum_h distance = _get_substring_hamming_distance(hash, target) if interesting_hamming_distance is not None and distance <= interesting_hamming_distance: # Surface interesting candidates, but don't stop. - yield hash_name_pb2.HashNameResponse(secret=base64.b64encode(secret), - hashed_name=hash, - hamming_distance=distance), hashes_computed + yield hash_name_pb2.HashNameResponse( + secret=base64.b64encode(secret), + hashed_name=hash, + hamming_distance=distance), hashes_computed elif distance <= ideal_distance: # Yield the ideal candidate followed by a sentinel to signal the end # of the stream. - yield hash_name_pb2.HashNameResponse(secret=base64.b64encode(secret), - hashed_name=hash, - hamming_distance=distance), hashes_computed + yield hash_name_pb2.HashNameResponse( + secret=base64.b64encode(secret), + hashed_name=hash, + hamming_distance=distance), hashes_computed yield None, hashes_computed raise StopIteration() digits[-1] += 1 @@ -127,12 +135,22 @@ def _find_secret_of_length(target, ideal_distance, length, stop_event, maximum_h raise ResourceLimitExceededError() -def _find_secret(target, maximum_distance, stop_event, maximum_hashes, interesting_hamming_distance=None): +def _find_secret(target, + maximum_distance, + stop_event, + maximum_hashes, + interesting_hamming_distance=None): length = 1 total_hashes = 0 while True: last_hashes_computed = 0 - for candidate, hashes_computed in _find_secret_of_length(target, maximum_distance, length, stop_event, maximum_hashes - total_hashes, interesting_hamming_distance=interesting_hamming_distance): + for candidate, hashes_computed in _find_secret_of_length( + target, + maximum_distance, + length, + stop_event, + maximum_hashes - total_hashes, + interesting_hamming_distance=interesting_hamming_distance): last_hashes_computed = hashes_computed if candidate is not None: yield candidate @@ -153,12 +171,17 @@ class HashFinder(hash_name_pb2_grpc.HashFinderServicer): def Find(self, request, context): stop_event = threading.Event() + def on_rpc_done(): _LOGGER.debug("Attempting to regain servicer thread.") stop_event.set() + context.add_callback(on_rpc_done) try: - candidates = list(_find_secret(request.desired_name, request.ideal_hamming_distance, stop_event, self._maximum_hashes)) + candidates = list( + _find_secret(request.desired_name, + request.ideal_hamming_distance, stop_event, + self._maximum_hashes)) except ResourceLimitExceededError: _LOGGER.info("Cancelling RPC due to exhausted resources.") context.cancel() @@ -167,18 +190,20 @@ class HashFinder(hash_name_pb2_grpc.HashFinderServicer): return hash_name_pb2.HashNameResponse() return candidates[-1] - def FindRange(self, request, context): stop_event = threading.Event() + def on_rpc_done(): _LOGGER.debug("Attempting to regain servicer thread.") stop_event.set() + context.add_callback(on_rpc_done) - secret_generator = _find_secret(request.desired_name, - request.ideal_hamming_distance, - stop_event, - self._maximum_hashes, - interesting_hamming_distance=request.interesting_hamming_distance) + secret_generator = _find_secret( + request.desired_name, + request.ideal_hamming_distance, + stop_event, + self._maximum_hashes, + interesting_hamming_distance=request.interesting_hamming_distance) try: for candidate in secret_generator: yield candidate @@ -189,10 +214,10 @@ class HashFinder(hash_name_pb2_grpc.HashFinderServicer): def _run_server(port, maximum_hashes): - server = grpc.server(futures.ThreadPoolExecutor(max_workers=1), - maximum_concurrent_rpcs=1) + server = grpc.server( + futures.ThreadPoolExecutor(max_workers=1), maximum_concurrent_rpcs=1) hash_name_pb2_grpc.add_HashFinderServicer_to_server( - HashFinder(maximum_hashes), server) + HashFinder(maximum_hashes), server) address = '{}:{}'.format(_SERVER_HOST, port) server.add_insecure_port(address) server.start() From dc8dba8afeb527f8118d9aca11ad27a5493f1966 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 25 Jun 2019 13:19:02 -0700 Subject: [PATCH 0685/1555] Add docstrings --- examples/python/cancellation/client.py | 2 - examples/python/cancellation/server.py | 61 +++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/examples/python/cancellation/client.py b/examples/python/cancellation/client.py index 288f93d057e..c3bc226be2c 100644 --- a/examples/python/cancellation/client.py +++ b/examples/python/cancellation/client.py @@ -42,8 +42,6 @@ _LOGGER = logging.getLogger(__name__) _TIMEOUT_SECONDS = 0.05 -# TODO(rbellevi): Actually use the logger. - def run_unary_client(server_target, name, ideal_distance): with grpc.insecure_channel(server_target) as channel: diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index 1af07e4a1e4..44b8ee26139 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -21,6 +21,7 @@ from concurrent import futures from collections import deque import argparse import base64 +import contextlib import logging import hashlib import struct @@ -82,7 +83,6 @@ class ResourceLimitExceededError(Exception): """Signifies the request has exceeded configured limits.""" -# TODO(rbellevi): Docstring all the things. # TODO(rbellevi): File issue about indefinite blocking for server-side # streaming. @@ -93,6 +93,28 @@ def _find_secret_of_length(target, stop_event, maximum_hashes, interesting_hamming_distance=None): + """Find a candidate with the given length. + + Args: + target: The search string. + ideal_distance: The desired Hamming distance. + length: The length of secret string to search for. + stop_event: An event indicating whether the RPC should terminate. + maximum_hashes: The maximum number of hashes to check before stopping. + interesting_hamming_distance: If specified, strings with a Hamming + distance from the target below this value will be yielded. + + Yields: + A stream of tuples of type Tuple[Optional[HashNameResponse], int]. The + element of the tuple, if specified, signifies an ideal or interesting + candidate. If this element is None, it signifies that the stream has + ended because an ideal candidate has been found. The second element is + the number of hashes computed up this point. + + Raises: + ResourceLimitExceededError: If the computation exceeds `maximum_hashes` + iterations. + """ digits = [0] * length hashes_computed = 0 while True: @@ -140,6 +162,29 @@ def _find_secret(target, stop_event, maximum_hashes, interesting_hamming_distance=None): + """Find candidate strings. + + Search through the space of all bytestrings, in order of increasing length, + indefinitely, until a hash with a Hamming distance of `maximum_distance` or + less has been found. + + Args: + target: The search string. + maximum_distance: The desired Hamming distance. + stop_event: An event indicating whether the RPC should terminate. + maximum_hashes: The maximum number of hashes to check before stopping. + interesting_hamming_distance: If specified, strings with a Hamming + distance from the target below this value will be yielded. + + Yields: + Instances of HashNameResponse. The final entry in the stream will be of + `maximum_distance` Hamming distance or less from the target string, + while all others will be of less than `interesting_hamming_distance`. + + Raises: + ResourceLimitExceededError: If the computation exceeds `maximum_hashes` + iterations. + """ length = 1 total_hashes = 0 while True: @@ -213,19 +258,21 @@ class HashFinder(hash_name_pb2_grpc.HashFinderServicer): _LOGGER.debug("Regained servicer thread.") -def _run_server(port, maximum_hashes): +@contextlib.contextmanager +def _running_server(port, maximum_hashes): server = grpc.server( futures.ThreadPoolExecutor(max_workers=1), maximum_concurrent_rpcs=1) hash_name_pb2_grpc.add_HashFinderServicer_to_server( HashFinder(maximum_hashes), server) address = '{}:{}'.format(_SERVER_HOST, port) - server.add_insecure_port(address) + actual_port = server.add_insecure_port(address) server.start() print("Server listening at '{}'".format(address)) try: - while True: - time.sleep(_ONE_DAY_IN_SECONDS) + yield actual_port except KeyboardInterrupt: + pass + finally: server.stop(None) @@ -244,7 +291,9 @@ def main(): nargs='?', help='The maximum number of hashes to search before cancelling.') args = parser.parse_args() - _run_server(args.port, args.maximum_hashes) + with _running_server(args.port, args.maximum_hashes): + while True: + time.sleep(_ONE_DAY_IN_SECONDS) if __name__ == "__main__": From 93d6344ac60ccb5bb6aec5f12be42c0ba581dcfc Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 25 Jun 2019 13:25:54 -0700 Subject: [PATCH 0686/1555] Add todo --- examples/python/cancellation/client.py | 2 ++ examples/python/cancellation/server.py | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/python/cancellation/client.py b/examples/python/cancellation/client.py index c3bc226be2c..20b76784622 100644 --- a/examples/python/cancellation/client.py +++ b/examples/python/cancellation/client.py @@ -92,6 +92,8 @@ def run_streaming_client(server_target, name, ideal_distance, # Enqueue a sentinel to signal the end of the stream. result_queue.put(None) + # TODO(https://github.com/grpc/grpc/issues/19464): Do everything on the + # main thread. response_thread = threading.Thread( target=iterate_responses, args=(result_generator, result_queue)) response_thread.daemon = True diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index 44b8ee26139..a316a7c2c60 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -83,10 +83,6 @@ class ResourceLimitExceededError(Exception): """Signifies the request has exceeded configured limits.""" -# TODO(rbellevi): File issue about indefinite blocking for server-side -# streaming. - - def _find_secret_of_length(target, ideal_distance, length, From a240860008889df2365664a0adb5f3f4eb1acc10 Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Tue, 25 Jun 2019 14:12:28 -0700 Subject: [PATCH 0687/1555] Minor fix --- .../ext/filters/client_channel/client_channel_channelz.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel_channelz.h b/src/core/ext/filters/client_channel/client_channel_channelz.h index ef50f45f73a..34b8e269a2e 100644 --- a/src/core/ext/filters/client_channel/client_channel_channelz.h +++ b/src/core/ext/filters/client_channel/client_channel_channelz.h @@ -51,11 +51,6 @@ class SubchannelNode : public BaseNode { // longer associated with this subchannel. void SetChildSocketUuid(intptr_t uuid); - void MarkSubchannelDestroyed() { - GPR_ASSERT(subchannel_ != nullptr); - subchannel_ = nullptr; - } - grpc_json* RenderJson() override; // proxy methods to composed classes. From 786a3acab0f37ce539f4ed5000f3dc388c35b0a5 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 25 Jun 2019 14:20:07 -0700 Subject: [PATCH 0688/1555] Add test --- examples/python/cancellation/client.py | 10 ++- examples/python/cancellation/server.py | 1 + .../test/_cancellation_example_test.py | 87 +++++++++++++++++++ 3 files changed, 96 insertions(+), 2 deletions(-) diff --git a/examples/python/cancellation/client.py b/examples/python/cancellation/client.py index 20b76784622..0621a05d643 100644 --- a/examples/python/cancellation/client.py +++ b/examples/python/cancellation/client.py @@ -48,7 +48,8 @@ def run_unary_client(server_target, name, ideal_distance): stub = hash_name_pb2_grpc.HashFinderStub(channel) future = stub.Find.future( hash_name_pb2.HashNameRequest( - desired_name=name, ideal_hamming_distance=ideal_distance)) + desired_name=name, ideal_hamming_distance=ideal_distance), + wait_for_ready=True) def cancel_request(unused_signum, unused_frame): future.cancel() @@ -61,6 +62,10 @@ def run_unary_client(server_target, name, ideal_distance): continue except grpc.FutureCancelledError: break + except grpc.RpcError as rpc_error: + if rpc_error.code() == grpc.StatusCode.CANCELLED: + break + raise rpc_error print(result) break @@ -73,7 +78,8 @@ def run_streaming_client(server_target, name, ideal_distance, hash_name_pb2.HashNameRequest( desired_name=name, ideal_hamming_distance=ideal_distance, - interesting_hamming_distance=interesting_distance)) + interesting_hamming_distance=interesting_distance), + wait_for_ready=True) def cancel_request(unused_signum, unused_frame): result_generator.cancel() diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index a316a7c2c60..98634727aaa 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -218,6 +218,7 @@ class HashFinder(hash_name_pb2_grpc.HashFinderServicer): stop_event.set() context.add_callback(on_rpc_done) + candidates = [] try: candidates = list( _find_secret(request.desired_name, diff --git a/examples/python/cancellation/test/_cancellation_example_test.py b/examples/python/cancellation/test/_cancellation_example_test.py index e69de29bb2d..45b0ccb400a 100644 --- a/examples/python/cancellation/test/_cancellation_example_test.py +++ b/examples/python/cancellation/test/_cancellation_example_test.py @@ -0,0 +1,87 @@ +# Copyright 2019 the gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Test for cancellation example.""" + +import contextlib +import os +import signal +import socket +import subprocess +import unittest + +_BINARY_DIR = os.path.realpath( + os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')) +_SERVER_PATH = os.path.join(_BINARY_DIR, 'server') +_CLIENT_PATH = os.path.join(_BINARY_DIR, 'client') + + +@contextlib.contextmanager +def _get_port(): + sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) + sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) + if sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT) == 0: + raise RuntimeError("Failed to set SO_REUSEPORT.") + sock.bind(('', 0)) + try: + yield sock.getsockname()[1] + finally: + sock.close() + + +def _start_client(server_port, + desired_string, + ideal_distance, + interesting_distance=None): + interesting_distance_args = () if interesting_distance is None else ( + '--show-inferior', interesting_distance) + return subprocess.Popen((_CLIENT_PATH, desired_string, '--server', + 'localhost:{}'.format(server_port), + '--ideal-distance', + str(ideal_distance)) + interesting_distance_args) + + +class CancellationExampleTest(unittest.TestCase): + + def test_successful_run(self): + with _get_port() as test_port: + server_process = subprocess.Popen((_SERVER_PATH, '--port', + str(test_port))) + try: + client_process = _start_client(test_port, 'aa', 0) + client_return_code = client_process.wait() + self.assertEqual(0, client_return_code) + self.assertIsNone(server_process.poll()) + finally: + server_process.kill() + server_process.wait() + + def test_graceful_sigint(self): + with _get_port() as test_port: + server_process = subprocess.Popen((_SERVER_PATH, '--port', + str(test_port))) + try: + client_process1 = _start_client(test_port, 'aaaaaaaaaa', 0) + client_process1.send_signal(signal.SIGINT) + client_process1.wait() + client_process2 = _start_client(test_port, 'aaaaaaaaaa', 0) + client_return_code = client_process2.wait() + self.assertEqual(0, client_return_code) + self.assertIsNone(server_process.poll()) + finally: + server_process.kill() + server_process.wait() + + +if __name__ == '__main__': + unittest.main(verbosity=2) From 3c72a939fce12756a88511e88c092b983ac9649e Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Tue, 25 Jun 2019 15:39:16 -0700 Subject: [PATCH 0689/1555] Remove subchannel_destroyed_ --- .../ext/filters/client_channel/client_channel_channelz.cc | 7 +------ .../ext/filters/client_channel/client_channel_channelz.h | 6 ------ src/core/ext/filters/client_channel/subchannel.cc | 2 +- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel_channelz.cc b/src/core/ext/filters/client_channel/client_channel_channelz.cc index fb7d1cbbc16..f21d45d8c0f 100644 --- a/src/core/ext/filters/client_channel/client_channel_channelz.cc +++ b/src/core/ext/filters/client_channel/client_channel_channelz.cc @@ -33,7 +33,6 @@ namespace channelz { SubchannelNode::SubchannelNode(const char* target_address, size_t channel_tracer_max_nodes) : BaseNode(EntityType::kSubchannel), - subchannel_destroyed_(false), target_(UniquePtr(gpr_strdup(target_address))), trace_(channel_tracer_max_nodes) {} @@ -49,11 +48,7 @@ void SubchannelNode::SetChildSocketUuid(intptr_t uuid) { void SubchannelNode::PopulateConnectivityState(grpc_json* json) { grpc_connectivity_state state; - if (subchannel_destroyed_) { - state = GRPC_CHANNEL_SHUTDOWN; - } else { - state = connectivity_state_.Load(MemoryOrder::RELAXED); - } + state = connectivity_state_.Load(MemoryOrder::RELAXED); json = grpc_json_create_child(nullptr, json, "state", nullptr, GRPC_JSON_OBJECT, false); grpc_json_create_child(nullptr, json, "state", diff --git a/src/core/ext/filters/client_channel/client_channel_channelz.h b/src/core/ext/filters/client_channel/client_channel_channelz.h index 34b8e269a2e..b9eaec7e0c5 100644 --- a/src/core/ext/filters/client_channel/client_channel_channelz.h +++ b/src/core/ext/filters/client_channel/client_channel_channelz.h @@ -37,11 +37,6 @@ class SubchannelNode : public BaseNode { SubchannelNode(const char* target_address, size_t channel_tracer_max_nodes); ~SubchannelNode() override; - void MarkSubchannelDestroyed() { - GPR_ASSERT(!subchannel_destroyed_); - subchannel_destroyed_ = true; - } - // Used when the subchannel's transport connectivity state changes. void UpdateConnectivityState(grpc_connectivity_state state); @@ -70,7 +65,6 @@ class SubchannelNode : public BaseNode { private: void PopulateConnectivityState(grpc_json* json); - bool subchannel_destroyed_; Atomic connectivity_state_{GRPC_CHANNEL_IDLE}; Atomic child_socket_uuid_{0}; UniquePtr target_; diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 28fe6d87c6d..9a6655e45d6 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -691,7 +691,7 @@ Subchannel::~Subchannel() { channelz_node_->AddTraceEvent( channelz::ChannelTrace::Severity::Info, grpc_slice_from_static_string("Subchannel destroyed")); - channelz_node_->MarkSubchannelDestroyed(); + channelz_node_->UpdateConnectivityState(GRPC_CHANNEL_SHUTDOWN); } grpc_channel_args_destroy(args_); grpc_connector_unref(connector_); From 44160d2b65e82d82be5a99ffb20583d9c4b12fb8 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 25 Jun 2019 15:43:06 -0700 Subject: [PATCH 0690/1555] Add unit test to check the re-entrancy of callbacks --- .../end2end/client_callback_end2end_test.cc | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/test/cpp/end2end/client_callback_end2end_test.cc b/test/cpp/end2end/client_callback_end2end_test.cc index 8cf6def1073..52797672fc0 100644 --- a/test/cpp/end2end/client_callback_end2end_test.cc +++ b/test/cpp/end2end/client_callback_end2end_test.cc @@ -374,6 +374,79 @@ TEST_P(ClientCallbackEnd2endTest, SimpleRpc) { SendRpcs(1, false); } +TEST_P(ClientCallbackEnd2endTest, SimpleRpcUnderLockNested) { + MAYBE_SKIP_TEST; + ResetStub(); + std::mutex mu1, mu2, mu3; + std::condition_variable cv1, cv2, cv3; + bool done1 = false; + EchoRequest request1, request2, request3; + request1.set_message("Hello locked world1."); + EchoResponse response1; + ClientContext cli_ctx1; + { + std::unique_lock l(mu1); + stub_->experimental_async()->Echo( + &cli_ctx1, &request1, &response1, + [&mu1, this, &cv1, &done1, &request1, &response1](Status s1) { + std::unique_lock l1(mu1); + EXPECT_TRUE(s1.ok()); + EXPECT_EQ(request1.message(), response1.message()); + // start the second level of nesting + std::mutex mu2; + bool done2 = false; + std::condition_variable cv2; + EchoRequest request2; + request2.set_message("Hello locked world2."); + EchoResponse response2; + ClientContext cli_ctx2; + std::unique_lock l2(mu2); + stub_->experimental_async()->Echo( + &cli_ctx2, &request2, &response2, + [&mu2, this, &cv2, &done2, &request2, &response2](Status s2) { + std::unique_lock l2(mu2); + EXPECT_TRUE(s2.ok()); + EXPECT_EQ(request2.message(), response2.message()); + // start the third level of nesting + std::mutex mu3; + bool done3 = false; + std::condition_variable cv3; + EchoRequest request3; + request3.set_message("Hello locked world2."); + EchoResponse response3; + ClientContext cli_ctx3; + std::unique_lock l3(mu3); + stub_->experimental_async()->Echo( + &cli_ctx3, &request3, &response3, + [&mu3, &cv3, &done3, &request3, &response3](Status s3) { + std::lock_guard l(mu3); + EXPECT_TRUE(s3.ok()); + EXPECT_EQ(request3.message(), response3.message()); + done3 = true; + cv3.notify_all(); + }); + done2 = true; + cv2.notify_all(); + // Wait for inner most rpc to return. + while (!done3) { + cv3.wait(l3); + } + }); + // Wait for second rpc to return. + while (!done2) { + cv2.wait(l2); + } + done1 = true; + cv1.notify_all(); + }); + } + + std::unique_lock l1(mu1); + while (!done1) { + cv1.wait(l1); + } +} + TEST_P(ClientCallbackEnd2endTest, SimpleRpcUnderLock) { MAYBE_SKIP_TEST; ResetStub(); From edbddf25ab99c86f70c961d78e4f85a40aebc5a2 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 25 Jun 2019 15:49:31 -0700 Subject: [PATCH 0691/1555] Typos --- examples/python/cancellation/README.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/examples/python/cancellation/README.md b/examples/python/cancellation/README.md index d5f9a844fcc..57ea1a30850 100644 --- a/examples/python/cancellation/README.md +++ b/examples/python/cancellation/README.md @@ -1,18 +1,14 @@ -### Cancelling RPCs - -RPCs may be cancelled by both the client and the server. - #### The Example In the example, we implement a silly algorithm. We search for bytestrings whose hashes are similar to a given search string. For example, say we're looking for -the string "doctor". Our algorithm may `JrqhZVkTDoctYrUlXDbL6pfYQHU=` or +the string "doctor". Our algorithm may return `JrqhZVkTDoctYrUlXDbL6pfYQHU=` or `RC9/7mlM3ldy4TdoctOc6WzYbO4=`. This is a brute force algorithm, so the server -performing the search must be conscious the resources it allows to each client -and each client must be conscientious of the resources demanded of the server. +performing the search must be conscious of the resources it allows to each client +and each client must be conscientious of the resources it demands of the server. In particular, we ensure that client processes cancel the stream explicitly -before terminating and we ensure the server cancels RPCs that have gone on longer +before terminating and we ensure that server processes cancel RPCs that have gone on longer than a certain number of iterations. #### Cancellation on the Client Side From a019017840bed8798390fc09758348f1c79b1ae3 Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Tue, 25 Jun 2019 15:50:10 -0700 Subject: [PATCH 0692/1555] Address minor comments --- src/core/ext/filters/client_channel/client_channel_channelz.h | 2 +- src/core/ext/filters/client_channel/subchannel.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel_channelz.h b/src/core/ext/filters/client_channel/client_channel_channelz.h index b9eaec7e0c5..d5aa20ca9a1 100644 --- a/src/core/ext/filters/client_channel/client_channel_channelz.h +++ b/src/core/ext/filters/client_channel/client_channel_channelz.h @@ -37,7 +37,7 @@ class SubchannelNode : public BaseNode { SubchannelNode(const char* target_address, size_t channel_tracer_max_nodes); ~SubchannelNode() override; - // Used when the subchannel's transport connectivity state changes. + // Used when the subchannel's connectivity state changes. void UpdateConnectivityState(grpc_connectivity_state state); // Used when the subchannel's child socket uuid changes. This should be set diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 9a6655e45d6..8ed821e236e 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -679,7 +679,7 @@ Subchannel::Subchannel(SubchannelKey* key, grpc_connector* connector, (size_t)grpc_channel_arg_get_integer(arg, options); if (channelz_enabled) { channelz_node_ = MakeRefCounted( - this->GetTargetAddress(), channel_tracer_max_memory); + GetTargetAddress(), channel_tracer_max_memory); channelz_node_->AddTraceEvent( channelz::ChannelTrace::Severity::Info, grpc_slice_from_static_string("subchannel created")); From fabad6e687306d15092c066963834ee3665aae29 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 25 Jun 2019 23:45:45 +0200 Subject: [PATCH 0693/1555] Fixing check bazel workspace script. --- tools/run_tests/sanity/check_bazel_workspace.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/run_tests/sanity/check_bazel_workspace.py b/tools/run_tests/sanity/check_bazel_workspace.py index 65aa72183d0..10fb0ccf6a8 100755 --- a/tools/run_tests/sanity/check_bazel_workspace.py +++ b/tools/run_tests/sanity/check_bazel_workspace.py @@ -54,6 +54,7 @@ _GRPC_DEP_NAMES = [ 'com_github_cares_cares', 'com_google_absl', 'io_opencensus_cpp', + 'envoy_api', _BAZEL_SKYLIB_DEP_NAME, _BAZEL_TOOLCHAINS_DEP_NAME, _TWISTED_TWISTED_DEP_NAME, @@ -61,9 +62,12 @@ _GRPC_DEP_NAMES = [ _TWISTED_INCREMENTAL_DEP_NAME, _ZOPEFOUNDATION_ZOPE_INTERFACE_DEP_NAME, _TWISTED_CONSTANTLY_DEP_NAME, + 'io_bazel_rules_go', ] _GRPC_BAZEL_ONLY_DEPS = [ + 'com_google_absl', + 'io_opencensus_cpp', _BAZEL_SKYLIB_DEP_NAME, _BAZEL_TOOLCHAINS_DEP_NAME, _TWISTED_TWISTED_DEP_NAME, @@ -71,6 +75,7 @@ _GRPC_BAZEL_ONLY_DEPS = [ _TWISTED_INCREMENTAL_DEP_NAME, _ZOPEFOUNDATION_ZOPE_INTERFACE_DEP_NAME, _TWISTED_CONSTANTLY_DEP_NAME, + 'io_bazel_rules_go', ] From 81f42031c638cec53f72a78d17e3524ced4b9ee9 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 25 Jun 2019 15:58:06 -0700 Subject: [PATCH 0694/1555] Pylint --- examples/python/cancellation/client.py | 3 --- examples/python/cancellation/server.py | 21 ++++++++++----------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/examples/python/cancellation/client.py b/examples/python/cancellation/client.py index 0621a05d643..9223e7c6ff4 100644 --- a/examples/python/cancellation/client.py +++ b/examples/python/cancellation/client.py @@ -17,11 +17,8 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -from concurrent import futures import argparse -import datetime import logging -import time import signal import threading diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index 98634727aaa..46e7b88ce51 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -18,7 +18,6 @@ from __future__ import division from __future__ import print_function from concurrent import futures -from collections import deque import argparse import base64 import contextlib @@ -64,7 +63,7 @@ def _get_substring_hamming_distance(candidate, target): The minimum Hamming distance between candidate and target. """ assert len(target) <= len(candidate) - assert len(candidate) != 0 + assert candidate min_distance = None for i in range(len(candidate) - len(target) + 1): distance = _get_hamming_distance(candidate[i:i + len(target)], target) @@ -118,25 +117,25 @@ def _find_secret_of_length(target, # Yield a sentinel and stop the generator if the RPC has been # cancelled. yield None, hashes_computed - raise StopIteration() + raise StopIteration() # pylint: disable=stop-iteration-return secret = b''.join(struct.pack('B', i) for i in digits) - hash = _get_hash(secret) - distance = _get_substring_hamming_distance(hash, target) + candidate_hash = _get_hash(secret) + distance = _get_substring_hamming_distance(candidate_hash, target) if interesting_hamming_distance is not None and distance <= interesting_hamming_distance: # Surface interesting candidates, but don't stop. yield hash_name_pb2.HashNameResponse( secret=base64.b64encode(secret), - hashed_name=hash, + hashed_name=candidate_hash, hamming_distance=distance), hashes_computed elif distance <= ideal_distance: # Yield the ideal candidate followed by a sentinel to signal the end # of the stream. yield hash_name_pb2.HashNameResponse( secret=base64.b64encode(secret), - hashed_name=hash, + hashed_name=candidate_hash, hamming_distance=distance), hashes_computed yield None, hashes_computed - raise StopIteration() + raise StopIteration() # pylint: disable=stop-iteration-return digits[-1] += 1 i = length - 1 while digits[i] == _BYTE_MAX + 1: @@ -145,7 +144,7 @@ def _find_secret_of_length(target, if i == -1: # Terminate the generator since we've run out of strings of # `length` bytes. - raise StopIteration() + raise StopIteration() # pylint: disable=stop-iteration-return else: digits[i] += 1 hashes_computed += 1 @@ -196,10 +195,10 @@ def _find_secret(target, if candidate is not None: yield candidate else: - raise StopIteration() + raise StopIteration() # pylint: disable=stop-iteration-return if stop_event.is_set(): # Terminate the generator if the RPC has been cancelled. - raise StopIteration() + raise StopIteration() # pylint: disable=stop-iteration-return total_hashes += last_hashes_computed length += 1 From fed1c629e06f15ed063a44edcb4ce7717bdec569 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 25 Jun 2019 16:07:49 -0700 Subject: [PATCH 0695/1555] Make compatible with Python 3 --- examples/python/cancellation/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index 46e7b88ce51..767337ea3ea 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -75,7 +75,7 @@ def _get_substring_hamming_distance(candidate, target): def _get_hash(secret): hasher = hashlib.sha1() hasher.update(secret) - return base64.b64encode(hasher.digest()) + return base64.b64encode(hasher.digest()).decode('ascii') class ResourceLimitExceededError(Exception): From 81da76ca3eb189b5169356826ac90b623c70f700 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Wed, 26 Jun 2019 01:13:28 +0200 Subject: [PATCH 0696/1555] Updating build files with changing upb directories. --- CMakeLists.txt | 2 +- Makefile | 2 +- grpc.gyp | 2 +- src/upb/gen_build_yaml.py | 4 ++-- tools/run_tests/generated/sources_and_headers.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a34f9265256..bacaac86953 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5769,7 +5769,7 @@ endif (gRPC_BUILD_CSHARP_EXT) if (gRPC_BUILD_TESTS) add_library(upb - third_party/upb/google/protobuf/descriptor.upb.c + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c third_party/upb/upb/decode.c third_party/upb/upb/def.c third_party/upb/upb/encode.c diff --git a/Makefile b/Makefile index 9930fc35a25..898acc29007 100644 --- a/Makefile +++ b/Makefile @@ -8407,7 +8407,7 @@ endif LIBUPB_SRC = \ - third_party/upb/google/protobuf/descriptor.upb.c \ + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ third_party/upb/upb/decode.c \ third_party/upb/upb/def.c \ third_party/upb/upb/encode.c \ diff --git a/grpc.gyp b/grpc.gyp index 6268bed7bb0..0dc1c662f7a 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -2150,7 +2150,7 @@ 'dependencies': [ ], 'sources': [ - 'third_party/upb/google/protobuf/descriptor.upb.c', + 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', 'third_party/upb/upb/decode.c', 'third_party/upb/upb/def.c', 'third_party/upb/upb/encode.c', diff --git a/src/upb/gen_build_yaml.py b/src/upb/gen_build_yaml.py index 8b726d374a3..181d026fbd2 100755 --- a/src/upb/gen_build_yaml.py +++ b/src/upb/gen_build_yaml.py @@ -22,7 +22,7 @@ import sys import yaml srcs = [ - "third_party/upb/google/protobuf/descriptor.upb.c", + "third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c", "third_party/upb/upb/decode.c", "third_party/upb/upb/def.c", "third_party/upb/upb/encode.c", @@ -35,7 +35,7 @@ srcs = [ ] hdrs = [ - "third_party/upb/google/protobuf/descriptor.upb.h", + "third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.h", "third_party/upb/upb/decode.h", "third_party/upb/upb/def.h", "third_party/upb/upb/encode.h", diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 8765f216dab..2a8ed7367f4 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7687,7 +7687,7 @@ { "deps": [], "headers": [ - "third_party/upb/google/protobuf/descriptor.upb.h", + "third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.h", "third_party/upb/upb/decode.h", "third_party/upb/upb/def.h", "third_party/upb/upb/encode.h", From 5955baf3d916a85ea9ee219ea245dadbd265cbcd Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Tue, 25 Jun 2019 19:37:02 -0700 Subject: [PATCH 0697/1555] Change comment words --- src/core/lib/iomgr/executor/mpmcqueue.cc | 8 +++----- src/core/lib/iomgr/executor/mpmcqueue.h | 10 +++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index cf8ade721d3..2bc3ffbc392 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -22,10 +22,10 @@ namespace grpc_core { -DebugOnlyTraceFlag thread_pool(false, "thread_pool_trace"); +DebugOnlyTraceFlag grpc_thread_pool_trace(false, "thread_pool_trace"); inline void* InfLenFIFOQueue::PopFront() { - // Caller should already checked queue is not empty and has already hold the + // Caller should already check queue is not empty and has already held the // mutex. This function will only do the job of removal. void* result = queue_head_->content; Node* head_to_remove = queue_head_; @@ -33,7 +33,7 @@ inline void* InfLenFIFOQueue::PopFront() { count_.FetchSub(1, MemoryOrder::RELAXED); - if (GRPC_TRACE_FLAG_ENABLED(thread_pool)) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_thread_pool_trace)) { gpr_timespec wait_time = gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), head_to_remove->insert_time); @@ -67,8 +67,6 @@ inline void* InfLenFIFOQueue::PopFront() { return result; } -InfLenFIFOQueue::InfLenFIFOQueue() {} - InfLenFIFOQueue::~InfLenFIFOQueue() { GPR_ASSERT(count_.Load(MemoryOrder::RELAXED) == 0); GPR_ASSERT(num_waiters_ == 0); diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index 964ac6a8b41..8ece95699c7 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -28,7 +28,7 @@ namespace grpc_core { -extern DebugOnlyTraceFlag thread_pool; +extern DebugOnlyTraceFlag grpc_thread_pool_trace; // Abstract base class of a Multiple-Producer-Multiple-Consumer(MPMC) queue // interface @@ -53,10 +53,10 @@ class MPMCQueueInterface { class InfLenFIFOQueue : public MPMCQueueInterface { public: // Creates a new MPMC Queue. The queue created will have infinite length. - InfLenFIFOQueue(); + InfLenFIFOQueue() {} - // Releases all resources hold by the queue. The queue must be empty, and no - // one waiting on conditional variables. + // Releases all resources held by the queue. The queue must be empty, and no + // one waits on conditional variables. ~InfLenFIFOQueue(); // Puts elem into queue immediately at the end of queue. Since the queue has @@ -86,7 +86,7 @@ class InfLenFIFOQueue : public MPMCQueueInterface { Node(void* c) : content(c) { next = nullptr; - insert_time = gpr_now(GPR_CLOCK_PRECISE); + insert_time = gpr_now(GPR_CLOCK_MONOTONIC); } }; From 23028dd12d774a5fefa1c9f597b7942a2b6dae2d Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Tue, 25 Jun 2019 19:45:04 -0700 Subject: [PATCH 0698/1555] Change trace flag var name --- src/core/lib/iomgr/executor/mpmcqueue.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index 2bc3ffbc392..93b1d195f46 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -76,8 +76,8 @@ void InfLenFIFOQueue::Put(void* elem) { MutexLock l(&mu_); Node* new_node = New(elem); - if (count_.Load(MemoryOrder::RELAXED) == 0) { - if (GRPC_TRACE_FLAG_ENABLED(thread_pool)) { + if (count_.FetchAdd(1, MemoryOrder::RELAXED) == 0) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_thread_pool_trace)) { busy_time = gpr_now(GPR_CLOCK_MONOTONIC); } queue_head_ = queue_tail_ = new_node; @@ -85,10 +85,10 @@ void InfLenFIFOQueue::Put(void* elem) { queue_tail_->next = new_node; queue_tail_ = queue_tail_->next; } - count_.FetchAdd(1, MemoryOrder::RELAXED); + // Updates Stats info - if (GRPC_TRACE_FLAG_ENABLED(thread_pool)) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_thread_pool_trace)) { stats_.num_started++; gpr_log(GPR_INFO, "[InfLenFIFOQueue Put] num_started: %" PRIu64, stats_.num_started); From c041acb7a7371d3b5bdb1d5ecfdcfd201eb90e2c Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 25 Jun 2019 20:09:06 -0700 Subject: [PATCH 0699/1555] Fix the unit tests to exercise nesting correctly. --- .../end2end/client_callback_end2end_test.cc | 45 +++++-------------- 1 file changed, 10 insertions(+), 35 deletions(-) diff --git a/test/cpp/end2end/client_callback_end2end_test.cc b/test/cpp/end2end/client_callback_end2end_test.cc index 52797672fc0..b80f612b3a2 100644 --- a/test/cpp/end2end/client_callback_end2end_test.cc +++ b/test/cpp/end2end/client_callback_end2end_test.cc @@ -382,62 +382,37 @@ TEST_P(ClientCallbackEnd2endTest, SimpleRpcUnderLockNested) { bool done1 = false; EchoRequest request1, request2, request3; request1.set_message("Hello locked world1."); - EchoResponse response1; - ClientContext cli_ctx1; + request2.set_message("Hello locked world2."); + request3.set_message("Hello locked world3."); + EchoResponse response1, response2, response3; + ClientContext cli_ctx1, cli_ctx2, cli_ctx3; { std::unique_lock l(mu1); stub_->experimental_async()->Echo( &cli_ctx1, &request1, &response1, - [&mu1, this, &cv1, &done1, &request1, &response1](Status s1) { + [this, &mu1, &mu2, &mu3, &cv1, &done1, &request1, &request2, &request3, &response1, &response2, &response3, &cli_ctx1, &cli_ctx2, &cli_ctx3](Status s1) { std::unique_lock l1(mu1); EXPECT_TRUE(s1.ok()); EXPECT_EQ(request1.message(), response1.message()); // start the second level of nesting - std::mutex mu2; - bool done2 = false; - std::condition_variable cv2; - EchoRequest request2; - request2.set_message("Hello locked world2."); - EchoResponse response2; - ClientContext cli_ctx2; std::unique_lock l2(mu2); - stub_->experimental_async()->Echo( - &cli_ctx2, &request2, &response2, - [&mu2, this, &cv2, &done2, &request2, &response2](Status s2) { + this->stub_->experimental_async()->Echo(&cli_ctx2, &request2, &response2, + [this, &mu2, &mu3, &cv1, &done1, &request2, &request3, &response2, &response3, &cli_ctx3](Status s2) { std::unique_lock l2(mu2); EXPECT_TRUE(s2.ok()); EXPECT_EQ(request2.message(), response2.message()); // start the third level of nesting - std::mutex mu3; - bool done3 = false; - std::condition_variable cv3; - EchoRequest request3; - request3.set_message("Hello locked world2."); - EchoResponse response3; - ClientContext cli_ctx3; std::unique_lock l3(mu3); stub_->experimental_async()->Echo( &cli_ctx3, &request3, &response3, - [&mu3, &cv3, &done3, &request3, &response3](Status s3) { + [&mu3, &cv1, &done1, &request3, &response3](Status s3) { std::lock_guard l(mu3); EXPECT_TRUE(s3.ok()); EXPECT_EQ(request3.message(), response3.message()); - done3 = true; - cv3.notify_all(); + done1 = true; + cv1.notify_all(); }); - done2 = true; - cv2.notify_all(); - // Wait for inner most rpc to return. - while (!done3) { - cv3.wait(l3); - } }); - // Wait for second rpc to return. - while (!done2) { - cv2.wait(l2); - } - done1 = true; - cv1.notify_all(); }); } From 3467f2dfdc302896a3fc0132a63983aeecb42b8e Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Tue, 25 Jun 2019 20:10:43 -0700 Subject: [PATCH 0700/1555] Fix log typo --- .../resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc index df40ba1c4bd..d24c111448c 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc @@ -353,7 +353,7 @@ class GrpcPolledFdWindows : public GrpcPolledFd { ares_ssize_t SendV(WSAErrorContext* wsa_error_ctx, const struct iovec* iov, int iov_count) { GRPC_CARES_TRACE_LOG( - "fd:|%s| SendV called connect_done_:%d was_connect_error_:%d", + "fd:|%s| SendV called connect_done_:%d wsa_connect_error_:%d", GetName(), connect_done_, wsa_connect_error_); if (!connect_done_) { wsa_error_ctx->SetWSAError(WSAEWOULDBLOCK); From 514413de70d2992e23d2ca6eac3adcca73c9d5f4 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 25 Jun 2019 20:14:15 -0700 Subject: [PATCH 0701/1555] Clang formatting errors --- test/cpp/end2end/client_callback_end2end_test.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/cpp/end2end/client_callback_end2end_test.cc b/test/cpp/end2end/client_callback_end2end_test.cc index b80f612b3a2..8c33dc85cfc 100644 --- a/test/cpp/end2end/client_callback_end2end_test.cc +++ b/test/cpp/end2end/client_callback_end2end_test.cc @@ -390,14 +390,18 @@ TEST_P(ClientCallbackEnd2endTest, SimpleRpcUnderLockNested) { std::unique_lock l(mu1); stub_->experimental_async()->Echo( &cli_ctx1, &request1, &response1, - [this, &mu1, &mu2, &mu3, &cv1, &done1, &request1, &request2, &request3, &response1, &response2, &response3, &cli_ctx1, &cli_ctx2, &cli_ctx3](Status s1) { + [this, &mu1, &mu2, &mu3, &cv1, &done1, &request1, &request2, &request3, + &response1, &response2, &response3, &cli_ctx1, &cli_ctx2, + &cli_ctx3](Status s1) { std::unique_lock l1(mu1); EXPECT_TRUE(s1.ok()); EXPECT_EQ(request1.message(), response1.message()); // start the second level of nesting std::unique_lock l2(mu2); - this->stub_->experimental_async()->Echo(&cli_ctx2, &request2, &response2, - [this, &mu2, &mu3, &cv1, &done1, &request2, &request3, &response2, &response3, &cli_ctx3](Status s2) { + this->stub_->experimental_async()->Echo( + &cli_ctx2, &request2, &response2, + [this, &mu2, &mu3, &cv1, &done1, &request2, &request3, &response2, + &response3, &cli_ctx3](Status s2) { std::unique_lock l2(mu2); EXPECT_TRUE(s2.ok()); EXPECT_EQ(request2.message(), response2.message()); From a827504ffb70cbb8e25e976958853752f1cf5399 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 5 Jun 2019 11:22:48 +0200 Subject: [PATCH 0702/1555] get rid of workaround to build net45 targets on linux and mac --- src/csharp/Grpc.Core/Common.csproj.include | 10 ++++------ .../Grpc.Tools.Tests/Grpc.Tools.Tests.csproj | 15 ++++----------- src/csharp/Grpc.Tools/Grpc.Tools.csproj | 15 ++++----------- 3 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/csharp/Grpc.Core/Common.csproj.include b/src/csharp/Grpc.Core/Common.csproj.include index 3b1bec2d55f..19e7240f443 100755 --- a/src/csharp/Grpc.Core/Common.csproj.include +++ b/src/csharp/Grpc.Core/Common.csproj.include @@ -19,10 +19,8 @@ true - - - /usr/lib/mono/4.5-api - /usr/local/lib/mono/4.5-api - /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5-api - + + + + diff --git a/src/csharp/Grpc.Tools.Tests/Grpc.Tools.Tests.csproj b/src/csharp/Grpc.Tools.Tests/Grpc.Tools.Tests.csproj index 7ad2ce21694..6df929cb2c0 100644 --- a/src/csharp/Grpc.Tools.Tests/Grpc.Tools.Tests.csproj +++ b/src/csharp/Grpc.Tools.Tests/Grpc.Tools.Tests.csproj @@ -7,17 +7,10 @@ - - - - /usr/lib/mono/4.5-api - /usr/local/lib/mono/4.5-api - /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5-api - + + + + diff --git a/src/csharp/Grpc.Tools/Grpc.Tools.csproj b/src/csharp/Grpc.Tools/Grpc.Tools.csproj index d09d97d1397..40034e9b20a 100644 --- a/src/csharp/Grpc.Tools/Grpc.Tools.csproj +++ b/src/csharp/Grpc.Tools/Grpc.Tools.csproj @@ -7,17 +7,10 @@ net45;netstandard1.3 - - - - /usr/lib/mono/4.5-api - /usr/local/lib/mono/4.5-api - /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5-api - + + + + From 8bfb713c8052d8af27a9f12eb2922623b3ec7fe2 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 26 Jun 2019 04:38:44 -0400 Subject: [PATCH 0703/1555] fix Grpc.Tools build --- src/csharp/Grpc.Tools.Tests/Grpc.Tools.Tests.csproj | 12 ++++++++---- src/csharp/Grpc.Tools/Grpc.Tools.csproj | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/csharp/Grpc.Tools.Tests/Grpc.Tools.Tests.csproj b/src/csharp/Grpc.Tools.Tests/Grpc.Tools.Tests.csproj index 6df929cb2c0..bc32e375860 100644 --- a/src/csharp/Grpc.Tools.Tests/Grpc.Tools.Tests.csproj +++ b/src/csharp/Grpc.Tools.Tests/Grpc.Tools.Tests.csproj @@ -7,10 +7,14 @@ - - - - + + + /usr/lib/mono/4.5-api + /usr/local/lib/mono/4.5-api + /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5-api + diff --git a/src/csharp/Grpc.Tools/Grpc.Tools.csproj b/src/csharp/Grpc.Tools/Grpc.Tools.csproj index 40034e9b20a..e73f7b7deae 100644 --- a/src/csharp/Grpc.Tools/Grpc.Tools.csproj +++ b/src/csharp/Grpc.Tools/Grpc.Tools.csproj @@ -7,10 +7,14 @@ net45;netstandard1.3 - - - - + + + /usr/lib/mono/4.5-api + /usr/local/lib/mono/4.5-api + /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5-api + From 03b063568d9b8ce416134952e57198ce2a1c4a8f Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Wed, 26 Jun 2019 08:56:52 -0700 Subject: [PATCH 0704/1555] Minor fixes --- src/core/ext/filters/client_channel/client_channel_channelz.cc | 3 +-- src/core/ext/filters/client_channel/client_channel_channelz.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel_channelz.cc b/src/core/ext/filters/client_channel/client_channel_channelz.cc index f21d45d8c0f..3076c1c1420 100644 --- a/src/core/ext/filters/client_channel/client_channel_channelz.cc +++ b/src/core/ext/filters/client_channel/client_channel_channelz.cc @@ -47,8 +47,7 @@ void SubchannelNode::SetChildSocketUuid(intptr_t uuid) { } void SubchannelNode::PopulateConnectivityState(grpc_json* json) { - grpc_connectivity_state state; - state = connectivity_state_.Load(MemoryOrder::RELAXED); + grpc_connectivity_state state = connectivity_state_.Load(MemoryOrder::RELAXED); json = grpc_json_create_child(nullptr, json, "state", nullptr, GRPC_JSON_OBJECT, false); grpc_json_create_child(nullptr, json, "state", diff --git a/src/core/ext/filters/client_channel/client_channel_channelz.h b/src/core/ext/filters/client_channel/client_channel_channelz.h index d5aa20ca9a1..80a6fd230c8 100644 --- a/src/core/ext/filters/client_channel/client_channel_channelz.h +++ b/src/core/ext/filters/client_channel/client_channel_channelz.h @@ -37,7 +37,7 @@ class SubchannelNode : public BaseNode { SubchannelNode(const char* target_address, size_t channel_tracer_max_nodes); ~SubchannelNode() override; - // Used when the subchannel's connectivity state changes. + // Sets the subchannel's connectivity state without health checking. void UpdateConnectivityState(grpc_connectivity_state state); // Used when the subchannel's child socket uuid changes. This should be set From 2bf4d502c1943abb93e4349d36035fb1d574157c Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 26 Jun 2019 09:06:07 -0700 Subject: [PATCH 0705/1555] Factor out simpler generator --- examples/python/cancellation/server.py | 41 +++++++++++++++++--------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index 767337ea3ea..cb69e249d12 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -82,6 +82,32 @@ class ResourceLimitExceededError(Exception): """Signifies the request has exceeded configured limits.""" +def _bytestrings_of_length(length): + """Generates a stream containing all bytestrings of a given length. + + Args: + length: A non-negative integer length. + + Yields: + All bytestrings of length `length`. + """ + digits = [0] * length + hashes_computed = 0 + while True: + yield b''.join(struct.pack('B', i) for i in digits) + digits[-1] += 1 + i = length - 1 + while digits[i] == _BYTE_MAX + 1: + digits[i] = 0 + i -= 1 + if i == -1: + # Terminate the generator since we've run out of strings of + # `length` bytes. + raise StopIteration() # pylint: disable=stop-iteration-return + else: + digits[i] += 1 + + def _find_secret_of_length(target, ideal_distance, length, @@ -110,15 +136,13 @@ def _find_secret_of_length(target, ResourceLimitExceededError: If the computation exceeds `maximum_hashes` iterations. """ - digits = [0] * length hashes_computed = 0 - while True: + for secret in _bytestrings_of_length(length): if stop_event.is_set(): # Yield a sentinel and stop the generator if the RPC has been # cancelled. yield None, hashes_computed raise StopIteration() # pylint: disable=stop-iteration-return - secret = b''.join(struct.pack('B', i) for i in digits) candidate_hash = _get_hash(secret) distance = _get_substring_hamming_distance(candidate_hash, target) if interesting_hamming_distance is not None and distance <= interesting_hamming_distance: @@ -136,17 +160,6 @@ def _find_secret_of_length(target, hamming_distance=distance), hashes_computed yield None, hashes_computed raise StopIteration() # pylint: disable=stop-iteration-return - digits[-1] += 1 - i = length - 1 - while digits[i] == _BYTE_MAX + 1: - digits[i] = 0 - i -= 1 - if i == -1: - # Terminate the generator since we've run out of strings of - # `length` bytes. - raise StopIteration() # pylint: disable=stop-iteration-return - else: - digits[i] += 1 hashes_computed += 1 if hashes_computed == maximum_hashes: raise ResourceLimitExceededError() From 42b2fe154a4f2320c38206705ba9a7e90739ddab Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 26 Jun 2019 09:21:29 -0700 Subject: [PATCH 0706/1555] Simplify search implementation --- examples/python/cancellation/server.py | 110 ++++++++----------------- 1 file changed, 34 insertions(+), 76 deletions(-) diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index cb69e249d12..5d72b003dc6 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -86,13 +86,12 @@ def _bytestrings_of_length(length): """Generates a stream containing all bytestrings of a given length. Args: - length: A non-negative integer length. + length: A positive integer length. Yields: All bytestrings of length `length`. """ digits = [0] * length - hashes_computed = 0 while True: yield b''.join(struct.pack('B', i) for i in digits) digits[-1] += 1 @@ -108,65 +107,23 @@ def _bytestrings_of_length(length): digits[i] += 1 -def _find_secret_of_length(target, - ideal_distance, - length, - stop_event, - maximum_hashes, - interesting_hamming_distance=None): - """Find a candidate with the given length. +def _all_bytestrings(): + """Generates a stream containing all possible bytestrings. - Args: - target: The search string. - ideal_distance: The desired Hamming distance. - length: The length of secret string to search for. - stop_event: An event indicating whether the RPC should terminate. - maximum_hashes: The maximum number of hashes to check before stopping. - interesting_hamming_distance: If specified, strings with a Hamming - distance from the target below this value will be yielded. + This generator does not terminate. Yields: - A stream of tuples of type Tuple[Optional[HashNameResponse], int]. The - element of the tuple, if specified, signifies an ideal or interesting - candidate. If this element is None, it signifies that the stream has - ended because an ideal candidate has been found. The second element is - the number of hashes computed up this point. - - Raises: - ResourceLimitExceededError: If the computation exceeds `maximum_hashes` - iterations. + All bytestrings in ascending order of length. """ - hashes_computed = 0 - for secret in _bytestrings_of_length(length): - if stop_event.is_set(): - # Yield a sentinel and stop the generator if the RPC has been - # cancelled. - yield None, hashes_computed - raise StopIteration() # pylint: disable=stop-iteration-return - candidate_hash = _get_hash(secret) - distance = _get_substring_hamming_distance(candidate_hash, target) - if interesting_hamming_distance is not None and distance <= interesting_hamming_distance: - # Surface interesting candidates, but don't stop. - yield hash_name_pb2.HashNameResponse( - secret=base64.b64encode(secret), - hashed_name=candidate_hash, - hamming_distance=distance), hashes_computed - elif distance <= ideal_distance: - # Yield the ideal candidate followed by a sentinel to signal the end - # of the stream. - yield hash_name_pb2.HashNameResponse( - secret=base64.b64encode(secret), - hashed_name=candidate_hash, - hamming_distance=distance), hashes_computed - yield None, hashes_computed - raise StopIteration() # pylint: disable=stop-iteration-return - hashes_computed += 1 - if hashes_computed == maximum_hashes: - raise ResourceLimitExceededError() + length = 1 + while True: + for bytestring in _bytestrings_of_length(length): + yield bytestring + length += 1 def _find_secret(target, - maximum_distance, + ideal_distance, stop_event, maximum_hashes, interesting_hamming_distance=None): @@ -178,7 +135,7 @@ def _find_secret(target, Args: target: The search string. - maximum_distance: The desired Hamming distance. + ideal_distance: The desired Hamming distance. stop_event: An event indicating whether the RPC should terminate. maximum_hashes: The maximum number of hashes to check before stopping. interesting_hamming_distance: If specified, strings with a Hamming @@ -193,27 +150,28 @@ def _find_secret(target, ResourceLimitExceededError: If the computation exceeds `maximum_hashes` iterations. """ - length = 1 - total_hashes = 0 - while True: - last_hashes_computed = 0 - for candidate, hashes_computed in _find_secret_of_length( - target, - maximum_distance, - length, - stop_event, - maximum_hashes - total_hashes, - interesting_hamming_distance=interesting_hamming_distance): - last_hashes_computed = hashes_computed - if candidate is not None: - yield candidate - else: - raise StopIteration() # pylint: disable=stop-iteration-return - if stop_event.is_set(): - # Terminate the generator if the RPC has been cancelled. - raise StopIteration() # pylint: disable=stop-iteration-return - total_hashes += last_hashes_computed - length += 1 + hashes_computed = 0 + for secret in _all_bytestrings(): + if stop_event.is_set(): + raise StopIteration() # pylint: disable=stop-iteration-return + candidate_hash = _get_hash(secret) + distance = _get_substring_hamming_distance(candidate_hash, target) + if interesting_hamming_distance is not None and distance <= interesting_hamming_distance: + # Surface interesting candidates, but don't stop. + yield hash_name_pb2.HashNameResponse( + secret=base64.b64encode(secret), + hashed_name=candidate_hash, + hamming_distance=distance) + elif distance <= ideal_distance: + # Yield ideal candidate and end the stream. + yield hash_name_pb2.HashNameResponse( + secret=base64.b64encode(secret), + hashed_name=candidate_hash, + hamming_distance=distance) + raise StopIteration() # pylint: disable=stop-iteration-return + hashes_computed += 1 + if hashes_computed == maximum_hashes: + raise ResourceLimitExceededError() class HashFinder(hash_name_pb2_grpc.HashFinderServicer): From 7f666a25ff54a72ef90a2b8126119430a78c05aa Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Wed, 26 Jun 2019 09:21:42 -0700 Subject: [PATCH 0707/1555] Remove GetC/hildSocketUuid and stop storing uuid inside ConnectedSubchannel --- .../ext/filters/client_channel/subchannel.cc | 16 +++------------- src/core/ext/filters/client_channel/subchannel.h | 8 +------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 8ed821e236e..b6ab47fb09d 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -84,13 +84,11 @@ DebugOnlyTraceFlag grpc_trace_subchannel_refcount(false, "subchannel_refcount"); ConnectedSubchannel::ConnectedSubchannel( grpc_channel_stack* channel_stack, const grpc_channel_args* args, - RefCountedPtr channelz_subchannel, - intptr_t socket_uuid) + RefCountedPtr channelz_subchannel) : ConnectedSubchannelInterface(&grpc_trace_subchannel_refcount), channel_stack_(channel_stack), args_(grpc_channel_args_copy(args)), - channelz_subchannel_(std::move(channelz_subchannel)), - socket_uuid_(socket_uuid) {} + channelz_subchannel_(std::move(channelz_subchannel)) {} ConnectedSubchannel::~ConnectedSubchannel() { grpc_channel_args_destroy(args_); @@ -781,14 +779,6 @@ Subchannel* Subchannel::RefFromWeakRef(GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { } } -intptr_t Subchannel::GetChildSocketUuid() { - if (connected_subchannel_ != nullptr) { - return connected_subchannel_->socket_uuid(); - } else { - return 0; - } -} - const char* Subchannel::GetTargetAddress() { const grpc_arg* addr_arg = grpc_channel_args_find(args_, GRPC_ARG_SUBCHANNEL_ADDRESS); @@ -1082,7 +1072,7 @@ bool Subchannel::PublishTransportLocked() { } // Publish. connected_subchannel_.reset( - New(stk, args_, channelz_node_, socket_uuid)); + New(stk, args_, channelz_node_)); gpr_log(GPR_INFO, "New connected subchannel at %p for subchannel %p", connected_subchannel_.get(), this); if (channelz_node_ != nullptr) { diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h index 2f05792b872..64d679af6c5 100644 --- a/src/core/ext/filters/client_channel/subchannel.h +++ b/src/core/ext/filters/client_channel/subchannel.h @@ -85,8 +85,7 @@ class ConnectedSubchannel : public ConnectedSubchannelInterface { ConnectedSubchannel( grpc_channel_stack* channel_stack, const grpc_channel_args* args, - RefCountedPtr channelz_subchannel, - intptr_t socket_uuid); + RefCountedPtr channelz_subchannel); ~ConnectedSubchannel(); void NotifyOnStateChange(grpc_pollset_set* interested_parties, @@ -101,7 +100,6 @@ class ConnectedSubchannel : public ConnectedSubchannelInterface { channelz::SubchannelNode* channelz_subchannel() const { return channelz_subchannel_.get(); } - intptr_t socket_uuid() const { return socket_uuid_; } size_t GetInitialCallSizeEstimate(size_t parent_data_size) const; @@ -111,8 +109,6 @@ class ConnectedSubchannel : public ConnectedSubchannelInterface { // ref counted pointer to the channelz node in this connected subchannel's // owning subchannel. RefCountedPtr channelz_subchannel_; - // uuid of this subchannel's socket. 0 if this subchannel is not connected. - const intptr_t socket_uuid_; }; // Implements the interface of RefCounted<>. @@ -200,8 +196,6 @@ class Subchannel { // returns null. Subchannel* RefFromWeakRef(GRPC_SUBCHANNEL_REF_EXTRA_ARGS); - intptr_t GetChildSocketUuid(); - // Gets the string representing the subchannel address. // Caller doesn't take ownership. const char* GetTargetAddress(); From 7fa7f932e3debe33d38ecc25be7ae9f1dbf4fe98 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 26 Jun 2019 09:32:58 -0700 Subject: [PATCH 0708/1555] Pull search algorithm out into another module --- examples/python/cancellation/BUILD.bazel | 17 ++- examples/python/cancellation/search.py | 158 +++++++++++++++++++++++ examples/python/cancellation/server.py | 151 +--------------------- 3 files changed, 180 insertions(+), 146 deletions(-) create mode 100644 examples/python/cancellation/search.py diff --git a/examples/python/cancellation/BUILD.bazel b/examples/python/cancellation/BUILD.bazel index 30bede22f22..31bba1548fa 100644 --- a/examples/python/cancellation/BUILD.bazel +++ b/examples/python/cancellation/BUILD.bazel @@ -19,12 +19,14 @@ load("//bazel:python_rules.bzl", "py_proto_library") proto_library( name = "hash_name_proto", - srcs = ["hash_name.proto"] + srcs = ["hash_name.proto"], + testonly = 1, ) py_proto_library( name = "hash_name_proto_pb2", deps = [":hash_name_proto"], + testonly = 1, well_known_protos = False, ) @@ -39,13 +41,24 @@ py_binary( srcs_version = "PY2AND3", ) +py_library( + name = "search", + srcs = ["search.py"], + srcs_version = "PY2AND3", + deps = [ + ":hash_name_proto_pb2", + ], + testonly = 1, +) + py_binary( name = "server", testonly = 1, srcs = ["server.py"], deps = [ "//src/python/grpcio/grpc:grpcio", - ":hash_name_proto_pb2" + ":hash_name_proto_pb2", + ":search", ] + select({ "//conditions:default": [requirement("futures")], "//:python3": [], diff --git a/examples/python/cancellation/search.py b/examples/python/cancellation/search.py new file mode 100644 index 00000000000..95e479deffa --- /dev/null +++ b/examples/python/cancellation/search.py @@ -0,0 +1,158 @@ +# Copyright the 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""A search algorithm over the space of all bytestrings.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import base64 +import hashlib +import logging +import struct + +from examples.python.cancellation import hash_name_pb2 + +_LOGGER = logging.getLogger(__name__) +_BYTE_MAX = 255 + + +def _get_hamming_distance(a, b): + """Calculates hamming distance between strings of equal length.""" + distance = 0 + for char_a, char_b in zip(a, b): + if char_a.lower() != char_b.lower(): + distance += 1 + return distance + + +def _get_substring_hamming_distance(candidate, target): + """Calculates the minimum hamming distance between between the target + and any substring of the candidate. + + Args: + candidate: The string whose substrings will be tested. + target: The target string. + + Returns: + The minimum Hamming distance between candidate and target. + """ + min_distance = None + for i in range(len(candidate) - len(target) + 1): + distance = _get_hamming_distance(candidate[i:i + len(target)], target) + if min_distance is None or distance < min_distance: + min_distance = distance + return min_distance + + +def _get_hash(secret): + hasher = hashlib.sha1() + hasher.update(secret) + return base64.b64encode(hasher.digest()).decode('ascii') + + +class ResourceLimitExceededError(Exception): + """Signifies the request has exceeded configured limits.""" + + +def _bytestrings_of_length(length): + """Generates a stream containing all bytestrings of a given length. + + Args: + length: A positive integer length. + + Yields: + All bytestrings of length `length`. + """ + digits = [0] * length + while True: + yield b''.join(struct.pack('B', i) for i in digits) + digits[-1] += 1 + i = length - 1 + while digits[i] == _BYTE_MAX + 1: + digits[i] = 0 + i -= 1 + if i == -1: + # Terminate the generator since we've run out of strings of + # `length` bytes. + raise StopIteration() # pylint: disable=stop-iteration-return + else: + digits[i] += 1 + + +def _all_bytestrings(): + """Generates a stream containing all possible bytestrings. + + This generator does not terminate. + + Yields: + All bytestrings in ascending order of length. + """ + length = 1 + while True: + for bytestring in _bytestrings_of_length(length): + yield bytestring + length += 1 + + +def search(target, + ideal_distance, + stop_event, + maximum_hashes, + interesting_hamming_distance=None): + """Find candidate strings. + + Search through the space of all bytestrings, in order of increasing length, + indefinitely, until a hash with a Hamming distance of `maximum_distance` or + less has been found. + + Args: + target: The search string. + ideal_distance: The desired Hamming distance. + stop_event: An event indicating whether the RPC should terminate. + maximum_hashes: The maximum number of hashes to check before stopping. + interesting_hamming_distance: If specified, strings with a Hamming + distance from the target below this value will be yielded. + + Yields: + Instances of HashNameResponse. The final entry in the stream will be of + `maximum_distance` Hamming distance or less from the target string, + while all others will be of less than `interesting_hamming_distance`. + + Raises: + ResourceLimitExceededError: If the computation exceeds `maximum_hashes` + iterations. + """ + hashes_computed = 0 + for secret in _all_bytestrings(): + if stop_event.is_set(): + raise StopIteration() # pylint: disable=stop-iteration-return + candidate_hash = _get_hash(secret) + distance = _get_substring_hamming_distance(candidate_hash, target) + if interesting_hamming_distance is not None and distance <= interesting_hamming_distance: + # Surface interesting candidates, but don't stop. + yield hash_name_pb2.HashNameResponse( + secret=base64.b64encode(secret), + hashed_name=candidate_hash, + hamming_distance=distance) + elif distance <= ideal_distance: + # Yield ideal candidate and end the stream. + yield hash_name_pb2.HashNameResponse( + secret=base64.b64encode(secret), + hashed_name=candidate_hash, + hamming_distance=distance) + raise StopIteration() # pylint: disable=stop-iteration-return + hashes_computed += 1 + if hashes_computed == maximum_hashes: + raise ResourceLimitExceededError() diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index 5d72b003dc6..2c715565031 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -19,21 +19,17 @@ from __future__ import print_function from concurrent import futures import argparse -import base64 import contextlib import logging -import hashlib -import struct import time import threading import grpc +import search from examples.python.cancellation import hash_name_pb2 from examples.python.cancellation import hash_name_pb2_grpc -_BYTE_MAX = 255 - _LOGGER = logging.getLogger(__name__) _SERVER_HOST = 'localhost' _ONE_DAY_IN_SECONDS = 60 * 60 * 24 @@ -41,139 +37,6 @@ _ONE_DAY_IN_SECONDS = 60 * 60 * 24 _DESCRIPTION = "A server for finding hashes similar to names." -def _get_hamming_distance(a, b): - """Calculates hamming distance between strings of equal length.""" - assert len(a) == len(b), "'{}', '{}'".format(a, b) - distance = 0 - for char_a, char_b in zip(a, b): - if char_a.lower() != char_b.lower(): - distance += 1 - return distance - - -def _get_substring_hamming_distance(candidate, target): - """Calculates the minimum hamming distance between between the target - and any substring of the candidate. - - Args: - candidate: The string whose substrings will be tested. - target: The target string. - - Returns: - The minimum Hamming distance between candidate and target. - """ - assert len(target) <= len(candidate) - assert candidate - min_distance = None - for i in range(len(candidate) - len(target) + 1): - distance = _get_hamming_distance(candidate[i:i + len(target)], target) - if min_distance is None or distance < min_distance: - min_distance = distance - return min_distance - - -def _get_hash(secret): - hasher = hashlib.sha1() - hasher.update(secret) - return base64.b64encode(hasher.digest()).decode('ascii') - - -class ResourceLimitExceededError(Exception): - """Signifies the request has exceeded configured limits.""" - - -def _bytestrings_of_length(length): - """Generates a stream containing all bytestrings of a given length. - - Args: - length: A positive integer length. - - Yields: - All bytestrings of length `length`. - """ - digits = [0] * length - while True: - yield b''.join(struct.pack('B', i) for i in digits) - digits[-1] += 1 - i = length - 1 - while digits[i] == _BYTE_MAX + 1: - digits[i] = 0 - i -= 1 - if i == -1: - # Terminate the generator since we've run out of strings of - # `length` bytes. - raise StopIteration() # pylint: disable=stop-iteration-return - else: - digits[i] += 1 - - -def _all_bytestrings(): - """Generates a stream containing all possible bytestrings. - - This generator does not terminate. - - Yields: - All bytestrings in ascending order of length. - """ - length = 1 - while True: - for bytestring in _bytestrings_of_length(length): - yield bytestring - length += 1 - - -def _find_secret(target, - ideal_distance, - stop_event, - maximum_hashes, - interesting_hamming_distance=None): - """Find candidate strings. - - Search through the space of all bytestrings, in order of increasing length, - indefinitely, until a hash with a Hamming distance of `maximum_distance` or - less has been found. - - Args: - target: The search string. - ideal_distance: The desired Hamming distance. - stop_event: An event indicating whether the RPC should terminate. - maximum_hashes: The maximum number of hashes to check before stopping. - interesting_hamming_distance: If specified, strings with a Hamming - distance from the target below this value will be yielded. - - Yields: - Instances of HashNameResponse. The final entry in the stream will be of - `maximum_distance` Hamming distance or less from the target string, - while all others will be of less than `interesting_hamming_distance`. - - Raises: - ResourceLimitExceededError: If the computation exceeds `maximum_hashes` - iterations. - """ - hashes_computed = 0 - for secret in _all_bytestrings(): - if stop_event.is_set(): - raise StopIteration() # pylint: disable=stop-iteration-return - candidate_hash = _get_hash(secret) - distance = _get_substring_hamming_distance(candidate_hash, target) - if interesting_hamming_distance is not None and distance <= interesting_hamming_distance: - # Surface interesting candidates, but don't stop. - yield hash_name_pb2.HashNameResponse( - secret=base64.b64encode(secret), - hashed_name=candidate_hash, - hamming_distance=distance) - elif distance <= ideal_distance: - # Yield ideal candidate and end the stream. - yield hash_name_pb2.HashNameResponse( - secret=base64.b64encode(secret), - hashed_name=candidate_hash, - hamming_distance=distance) - raise StopIteration() # pylint: disable=stop-iteration-return - hashes_computed += 1 - if hashes_computed == maximum_hashes: - raise ResourceLimitExceededError() - - class HashFinder(hash_name_pb2_grpc.HashFinderServicer): def __init__(self, maximum_hashes): @@ -191,10 +54,10 @@ class HashFinder(hash_name_pb2_grpc.HashFinderServicer): candidates = [] try: candidates = list( - _find_secret(request.desired_name, - request.ideal_hamming_distance, stop_event, - self._maximum_hashes)) - except ResourceLimitExceededError: + search.search(request.desired_name, + request.ideal_hamming_distance, stop_event, + self._maximum_hashes)) + except search.ResourceLimitExceededError: _LOGGER.info("Cancelling RPC due to exhausted resources.") context.cancel() _LOGGER.debug("Servicer thread returning.") @@ -210,7 +73,7 @@ class HashFinder(hash_name_pb2_grpc.HashFinderServicer): stop_event.set() context.add_callback(on_rpc_done) - secret_generator = _find_secret( + secret_generator = search.search( request.desired_name, request.ideal_hamming_distance, stop_event, @@ -219,7 +82,7 @@ class HashFinder(hash_name_pb2_grpc.HashFinderServicer): try: for candidate in secret_generator: yield candidate - except ResourceLimitExceededError: + except search.ResourceLimitExceededError: _LOGGER.info("Cancelling RPC due to exhausted resources.") context.cancel() _LOGGER.debug("Regained servicer thread.") From 51626535cdf80076eb9b543540dccac54066e8b4 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 26 Jun 2019 09:33:58 -0700 Subject: [PATCH 0709/1555] Fix BUILD file --- BUILD | 1 - 1 file changed, 1 deletion(-) diff --git a/BUILD b/BUILD index 35e10a8b2ff..172a90e151e 100644 --- a/BUILD +++ b/BUILD @@ -2189,7 +2189,6 @@ grpc_cc_library( "include/grpcpp/impl/codegen/server_callback.h", "include/grpcpp/impl/codegen/server_context.h", "include/grpcpp/impl/codegen/server_context_impl.h", - "include/grpcpp/impl/codegen/server_context_impl.h", "include/grpcpp/impl/codegen/server_interceptor.h", "include/grpcpp/impl/codegen/server_interface.h", "include/grpcpp/impl/codegen/service_type.h", From c48eac2dd47db64003008b57e6dcc98f0876c309 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Wed, 26 Jun 2019 09:35:59 -0700 Subject: [PATCH 0710/1555] Modify variable name for consistency, remove extra test --- src/core/lib/iomgr/executor/mpmcqueue.cc | 1 - test/core/iomgr/mpmcqueue_test.cc | 119 ++++++++--------------- 2 files changed, 38 insertions(+), 82 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index 93b1d195f46..c6c2b7d0cc1 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -86,7 +86,6 @@ void InfLenFIFOQueue::Put(void* elem) { queue_tail_ = queue_tail_->next; } - // Updates Stats info if (GRPC_TRACE_FLAG_ENABLED(grpc_thread_pool_trace)) { stats_.num_started++; diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index 792d9b602c2..cd29362e557 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -23,7 +23,7 @@ #include "src/core/lib/gprpp/thd.h" #include "test/core/util/test_config.h" -#define THREAD_LARGE_ITERATION 10000 +#define TEST_NUM_ITEMS 10000 // Testing items for queue struct WorkItem { @@ -41,7 +41,7 @@ class ProducerThread { : start_index_(start_index), num_items_(num_items), queue_(queue) { items_ = nullptr; thd_ = grpc_core::Thread( - "mpmcq_test_put_thd", + "mpmcq_test_producer_thd", [](void* th) { static_cast(th)->Run(); }, this); } ~ProducerThread() { @@ -76,7 +76,7 @@ class ConsumerThread { public: ConsumerThread(grpc_core::InfLenFIFOQueue* queue) : queue_(queue) { thd_ = grpc_core::Thread( - "mpmcq_test_get_thd", + "mpmcq_test_consumer_thd", [](void* th) { static_cast(th)->Run(); }, this); } ~ConsumerThread() {} @@ -102,55 +102,14 @@ class ConsumerThread { grpc_core::Thread thd_; }; -static void test_get_empty(void) { - gpr_log(GPR_INFO, "test_get_empty"); - grpc_core::InfLenFIFOQueue queue; - GPR_ASSERT(queue.count() == 0); - const int num_threads = 10; - ConsumerThread** consumer_thds = static_cast( - gpr_zalloc(num_threads * sizeof(ConsumerThread*))); - - // Fork threads. Threads should block at the beginning since queue is empty. - for (int i = 0; i < num_threads; ++i) { - consumer_thds[i] = grpc_core::New(&queue); - consumer_thds[i]->Start(); - } - - WorkItem** items = static_cast( - gpr_zalloc(THREAD_LARGE_ITERATION * sizeof(WorkItem*))); - for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { - items[i] = grpc_core::New(i); - queue.Put(static_cast(items[i])); - } - - gpr_log(GPR_DEBUG, "Terminating threads..."); - for (int i = 0; i < num_threads; ++i) { - queue.Put(nullptr); - } - for (int i = 0; i < num_threads; ++i) { - consumer_thds[i]->Join(); - } - gpr_log(GPR_DEBUG, "Checking and Cleaning Up..."); - for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { - GPR_ASSERT(items[i]->done); - grpc_core::Delete(items[i]); - } - gpr_free(items); - for (int i = 0; i < num_threads; ++i) { - grpc_core::Delete(consumer_thds[i]); - } - gpr_free(consumer_thds); - gpr_log(GPR_DEBUG, "Done."); -} - static void test_FIFO(void) { gpr_log(GPR_INFO, "test_FIFO"); grpc_core::InfLenFIFOQueue large_queue; - for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { + for (int i = 0; i < TEST_NUM_ITEMS; ++i) { large_queue.Put(static_cast(grpc_core::New(i))); } - GPR_ASSERT(large_queue.count() == THREAD_LARGE_ITERATION); - for (int i = 0; i < THREAD_LARGE_ITERATION; ++i) { + GPR_ASSERT(large_queue.count() == TEST_NUM_ITEMS); + for (int i = 0; i < TEST_NUM_ITEMS; ++i) { WorkItem* item = static_cast(large_queue.Get()); GPR_ASSERT(i == item->index); grpc_core::Delete(item); @@ -159,57 +118,55 @@ static void test_FIFO(void) { static void test_many_thread(void) { gpr_log(GPR_INFO, "test_many_thread"); - const int num_work_thd = 10; - const int num_get_thd = 20; + const int num_producer_threads = 10; + const int num_consumer_threads = 20; grpc_core::InfLenFIFOQueue queue; - ProducerThread** work_thds = static_cast( - gpr_zalloc(num_work_thd * sizeof(ProducerThread*))); - ConsumerThread** consumer_thds = static_cast( - gpr_zalloc(num_get_thd * sizeof(ConsumerThread*))); + ProducerThread** producer_threads = static_cast( + gpr_zalloc(num_producer_threads * sizeof(ProducerThread*))); + ConsumerThread** consumer_threads = static_cast( + gpr_zalloc(num_consumer_threads * sizeof(ConsumerThread*))); - gpr_log(GPR_DEBUG, "Fork ProducerThread..."); - for (int i = 0; i < num_work_thd; ++i) { - work_thds[i] = grpc_core::New( - &queue, i * THREAD_LARGE_ITERATION, THREAD_LARGE_ITERATION); - work_thds[i]->Start(); + gpr_log(GPR_DEBUG, "Fork ProducerThreads..."); + for (int i = 0; i < num_producer_threads; ++i) { + producer_threads[i] = grpc_core::New( + &queue, i * TEST_NUM_ITEMS, TEST_NUM_ITEMS); + producer_threads[i]->Start(); } - gpr_log(GPR_DEBUG, "ProducerThread Started."); - gpr_log(GPR_DEBUG, "Fork Getter Thread..."); - for (int i = 0; i < num_get_thd; ++i) { - consumer_thds[i] = grpc_core::New(&queue); - consumer_thds[i]->Start(); + gpr_log(GPR_DEBUG, "ProducerThreads Started."); + gpr_log(GPR_DEBUG, "Fork ConsumerThreads..."); + for (int i = 0; i < num_consumer_threads; ++i) { + consumer_threads[i] = grpc_core::New(&queue); + consumer_threads[i]->Start(); } - gpr_log(GPR_DEBUG, "Getter Thread Started."); - gpr_log(GPR_DEBUG, "Waiting ProducerThread to finish..."); - for (int i = 0; i < num_work_thd; ++i) { - work_thds[i]->Join(); + gpr_log(GPR_DEBUG, "ConsumerThreads Started."); + gpr_log(GPR_DEBUG, "Waiting ProducerThreads to finish..."); + for (int i = 0; i < num_producer_threads; ++i) { + producer_threads[i]->Join(); } - gpr_log(GPR_DEBUG, "All ProducerThread Terminated."); - gpr_log(GPR_DEBUG, "Terminating Getter Thread..."); - for (int i = 0; i < num_get_thd; ++i) { + gpr_log(GPR_DEBUG, "All ProducerThreads Terminated."); + gpr_log(GPR_DEBUG, "Terminating ConsumerThreads..."); + for (int i = 0; i < num_consumer_threads; ++i) { queue.Put(nullptr); } - for (int i = 0; i < num_get_thd; ++i) { - consumer_thds[i]->Join(); + for (int i = 0; i < num_consumer_threads; ++i) { + consumer_threads[i]->Join(); } - gpr_log(GPR_DEBUG, "All Getter Thread Terminated."); + gpr_log(GPR_DEBUG, "All ConsumerThreads Terminated."); gpr_log(GPR_DEBUG, "Checking WorkItems and Cleaning Up..."); - for (int i = 0; i < num_work_thd; ++i) { - grpc_core::Delete(work_thds[i]); + for (int i = 0; i < num_producer_threads; ++i) { + grpc_core::Delete(producer_threads[i]); } - gpr_free(work_thds); - for (int i = 0; i < num_get_thd; ++i) { - grpc_core::Delete(consumer_thds[i]); + gpr_free(producer_threads); + for (int i = 0; i < num_consumer_threads; ++i) { + grpc_core::Delete(consumer_threads[i]); } - gpr_free(consumer_thds); + gpr_free(consumer_threads); gpr_log(GPR_DEBUG, "Done."); } int main(int argc, char** argv) { grpc::testing::TestEnvironment env(argc, argv); grpc_init(); - gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG); - test_get_empty(); test_FIFO(); test_many_thread(); grpc_shutdown(); From 4100084c78cec4b5d7b5fe3e1b4b517523b45cb2 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 26 Jun 2019 09:37:33 -0700 Subject: [PATCH 0711/1555] Use six for compatibility in client --- examples/python/cancellation/BUILD.bazel | 1 + examples/python/cancellation/client.py | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/python/cancellation/BUILD.bazel b/examples/python/cancellation/BUILD.bazel index 31bba1548fa..62bc7b2fa46 100644 --- a/examples/python/cancellation/BUILD.bazel +++ b/examples/python/cancellation/BUILD.bazel @@ -37,6 +37,7 @@ py_binary( deps = [ "//src/python/grpcio/grpc:grpcio", ":hash_name_proto_pb2", + requirement("six"), ], srcs_version = "PY2AND3", ) diff --git a/examples/python/cancellation/client.py b/examples/python/cancellation/client.py index 9223e7c6ff4..2661efc196f 100644 --- a/examples/python/cancellation/client.py +++ b/examples/python/cancellation/client.py @@ -20,14 +20,11 @@ from __future__ import print_function import argparse import logging import signal +import six import threading -try: - from queue import Queue - from queue import Empty as QueueEmpty -except ImportError: - from Queue import Queue - from Queue import Empty as QueueEmpty +from six.moves.queue import Queue +from six.moves.queue import Empty as QueueEmpty import grpc From 7486026eb97671f55a6320012d55222cfe3ffcf0 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 26 Jun 2019 09:42:55 -0700 Subject: [PATCH 0712/1555] Annotate the proto file --- examples/python/cancellation/hash_name.proto | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/examples/python/cancellation/hash_name.proto b/examples/python/cancellation/hash_name.proto index e0a5c8357be..7b4e47e056f 100644 --- a/examples/python/cancellation/hash_name.proto +++ b/examples/python/cancellation/hash_name.proto @@ -16,19 +16,41 @@ syntax = "proto3"; package hash_name; +// A request for a single secret whose hash is similar to a desired name. message HashNameRequest { + // The string that is desired in the secret's hash. string desired_name = 1; + + // The ideal Hamming distance betwen desired_name and the secret that will + // be searched for. int32 ideal_hamming_distance = 2; + + // A Hamming distance greater than the ideal Hamming distance. Search results + // with a Hamming distance less than this value but greater than the ideal + // distance will be returned back to the client but will not terminate the + // search. int32 interesting_hamming_distance = 3; } message HashNameResponse { + // The search result. string secret = 1; + + // The hash of the search result. A substring of this is of + // ideal_hamming_distance Hamming distance or less from desired_name. string hashed_name = 2; + + // The Hamming distance between hashed_name and desired_name. int32 hamming_distance = 3; } service HashFinder { + + // Search for a single string whose hash is similar to the specified + // desired_name. interesting_hamming_distance is ignored. rpc Find (HashNameRequest) returns (HashNameResponse) {} + + // Search for a string whose hash is similar to the specified desired_name, + // but also stream back less-than-ideal candidates. rpc FindRange (HashNameRequest) returns (stream HashNameResponse) {} } From 25f3439c910e0168b4dbe776b77526eed84f5213 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 26 Jun 2019 09:45:47 -0700 Subject: [PATCH 0713/1555] Make whole package testonly --- examples/python/cancellation/BUILD.bazel | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/examples/python/cancellation/BUILD.bazel b/examples/python/cancellation/BUILD.bazel index 62bc7b2fa46..81cd3a881b8 100644 --- a/examples/python/cancellation/BUILD.bazel +++ b/examples/python/cancellation/BUILD.bazel @@ -17,22 +17,21 @@ load("@grpc_python_dependencies//:requirements.bzl", "requirement") load("//bazel:python_rules.bzl", "py_proto_library") +package(default_testonly = 1) + proto_library( name = "hash_name_proto", srcs = ["hash_name.proto"], - testonly = 1, ) py_proto_library( name = "hash_name_proto_pb2", deps = [":hash_name_proto"], - testonly = 1, well_known_protos = False, ) py_binary( name = "client", - testonly = 1, srcs = ["client.py"], deps = [ "//src/python/grpcio/grpc:grpcio", @@ -49,12 +48,10 @@ py_library( deps = [ ":hash_name_proto_pb2", ], - testonly = 1, ) py_binary( name = "server", - testonly = 1, srcs = ["server.py"], deps = [ "//src/python/grpcio/grpc:grpcio", From ce41cde908a61468de83623453ff1984bf18ea7f Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Tue, 25 Jun 2019 14:08:41 -0700 Subject: [PATCH 0714/1555] Fix string/bytes problem && lint --- examples/python/auth/_credentials.py | 4 ++-- examples/python/auth/customized_auth_client.py | 7 ------- examples/python/auth/customized_auth_server.py | 7 ------- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/examples/python/auth/_credentials.py b/examples/python/auth/_credentials.py index 39939f6284b..732587b7c5b 100644 --- a/examples/python/auth/_credentials.py +++ b/examples/python/auth/_credentials.py @@ -22,8 +22,8 @@ import os def _load_credential_from_file(filepath): real_path = os.path.join(os.path.dirname(__file__), filepath) - with open(real_path, 'r') as f: - return bytes(f.read()) + with open(real_path, 'rb') as f: + return f.read() SERVER_CERTIFICATE = _load_credential_from_file('credentials/localhost.crt') diff --git a/examples/python/auth/customized_auth_client.py b/examples/python/auth/customized_auth_client.py index 4ec0c2d3806..0236c07adb1 100644 --- a/examples/python/auth/customized_auth_client.py +++ b/examples/python/auth/customized_auth_client.py @@ -20,7 +20,6 @@ from __future__ import print_function import argparse import contextlib import logging -import os import grpc from examples import helloworld_pb2 @@ -57,12 +56,6 @@ class AuthGateway(grpc.AuthMetadataPlugin): callback(((_SIGNATURE_HEADER_KEY, signature),), None) -def _load_credential_from_file(filepath): - real_path = os.path.join(os.path.dirname(__file__), filepath) - with open(real_path, 'r') as f: - return f.read() - - @contextlib.contextmanager def create_client_channel(addr): # Call credential object will be invoked for every single RPC diff --git a/examples/python/auth/customized_auth_server.py b/examples/python/auth/customized_auth_server.py index f79c2639d90..1debc6c3c5f 100644 --- a/examples/python/auth/customized_auth_server.py +++ b/examples/python/auth/customized_auth_server.py @@ -20,7 +20,6 @@ from __future__ import print_function import argparse import contextlib import logging -import os import time from concurrent import futures @@ -66,12 +65,6 @@ class SimpleGreeter(helloworld_pb2_grpc.GreeterServicer): return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name) -def _load_credential_from_file(filepath): - real_path = os.path.join(os.path.dirname(__file__), filepath) - with open(real_path, 'r') as f: - return f.read() - - @contextlib.contextmanager def run_server(port): # Bind interceptor to server From 1db141acccf91be59e46b584a0d1b883bf686ab9 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 26 Jun 2019 09:51:44 -0700 Subject: [PATCH 0715/1555] Change section title --- examples/python/cancellation/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/python/cancellation/README.md b/examples/python/cancellation/README.md index 57ea1a30850..ed85fbe53cb 100644 --- a/examples/python/cancellation/README.md +++ b/examples/python/cancellation/README.md @@ -1,4 +1,4 @@ -#### The Example +### Cancellation In the example, we implement a silly algorithm. We search for bytestrings whose hashes are similar to a given search string. For example, say we're looking for From 833bd5c118c4f09af42b9366fe47de31a42f9ac7 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Wed, 26 Jun 2019 10:12:50 -0700 Subject: [PATCH 0716/1555] Change trace flag name, add some comment in test --- src/core/lib/iomgr/executor/mpmcqueue.cc | 2 +- test/core/iomgr/mpmcqueue_test.cc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index c6c2b7d0cc1..97429ec30c7 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -22,7 +22,7 @@ namespace grpc_core { -DebugOnlyTraceFlag grpc_thread_pool_trace(false, "thread_pool_trace"); +DebugOnlyTraceFlag grpc_thread_pool_trace(false, "thread_pool"); inline void* InfLenFIFOQueue::PopFront() { // Caller should already check queue is not empty and has already held the diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index cd29362e557..12107e85327 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -154,6 +154,7 @@ static void test_many_thread(void) { gpr_log(GPR_DEBUG, "All ConsumerThreads Terminated."); gpr_log(GPR_DEBUG, "Checking WorkItems and Cleaning Up..."); for (int i = 0; i < num_producer_threads; ++i) { + // Destructor of ProducerThread will do the check of WorkItems grpc_core::Delete(producer_threads[i]); } gpr_free(producer_threads); From 5a05ea0530e6c9dde26c631e12e129f882c7a750 Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Wed, 26 Jun 2019 10:21:06 -0700 Subject: [PATCH 0717/1555] Format --- src/core/ext/filters/client_channel/client_channel_channelz.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/ext/filters/client_channel/client_channel_channelz.cc b/src/core/ext/filters/client_channel/client_channel_channelz.cc index 3076c1c1420..a489685df40 100644 --- a/src/core/ext/filters/client_channel/client_channel_channelz.cc +++ b/src/core/ext/filters/client_channel/client_channel_channelz.cc @@ -47,7 +47,8 @@ void SubchannelNode::SetChildSocketUuid(intptr_t uuid) { } void SubchannelNode::PopulateConnectivityState(grpc_json* json) { - grpc_connectivity_state state = connectivity_state_.Load(MemoryOrder::RELAXED); + grpc_connectivity_state state = + connectivity_state_.Load(MemoryOrder::RELAXED); json = grpc_json_create_child(nullptr, json, "state", nullptr, GRPC_JSON_OBJECT, false); grpc_json_create_child(nullptr, json, "state", From efeb0e7012724842a35372d352db2a4670c80ff1 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Wed, 26 Jun 2019 19:55:55 +0200 Subject: [PATCH 0718/1555] Fixing up include paths for upb. --- Makefile | 4 ++-- build.yaml | 2 +- templates/Makefile.template | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 898acc29007..48afd395f0e 100644 --- a/Makefile +++ b/Makefile @@ -369,7 +369,7 @@ CPPFLAGS += -fPIC LDFLAGS += -fPIC endif -INCLUDES = . include $(GENDIR) +INCLUDES = . include $(GENDIR) third_party/upb third_party/upb/generated_for_cmake LDFLAGS += -Llibs/$(CONFIG) ifeq ($(SYSTEM),Darwin) @@ -8422,7 +8422,7 @@ PUBLIC_HEADERS_C += \ LIBUPB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBUPB_SRC)))) -$(LIBUPB_OBJS): CFLAGS += -Ithird_party/upb -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers +$(LIBUPB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers $(LIBDIR)/$(CONFIG)/libupb.a: $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBUPB_OBJS) $(E) "[AR] Creating $@" diff --git a/build.yaml b/build.yaml index dad2146bd1c..ebd484fbcd9 100644 --- a/build.yaml +++ b/build.yaml @@ -6051,7 +6051,7 @@ defaults: CXXFLAGS: -Wnon-virtual-dtor LDFLAGS: -g upb: - CFLAGS: -Ithird_party/upb -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough + CFLAGS: -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers zlib: CFLAGS: -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration diff --git a/templates/Makefile.template b/templates/Makefile.template index 24bea5c2423..fb0dd1d87b3 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -239,7 +239,7 @@ LDFLAGS += -fPIC endif - INCLUDES = . include $(GENDIR) + INCLUDES = . include $(GENDIR) third_party/upb third_party/upb/generated_for_cmake LDFLAGS += -Llibs/$(CONFIG) ifeq ($(SYSTEM),Darwin) From ef4388b862aebacac70231b9040ef7a668e87e7b Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 26 Jun 2019 11:31:24 -0700 Subject: [PATCH 0719/1555] Explain order of callback execution in executor comments --- src/core/lib/iomgr/executor.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/executor.cc b/src/core/lib/iomgr/executor.cc index 8adc0902bd1..721542544cd 100644 --- a/src/core/lib/iomgr/executor.cc +++ b/src/core/lib/iomgr/executor.cc @@ -120,7 +120,10 @@ size_t Executor::RunClosures(const char* executor_name, // thread itself, but this is the point where we could start seeing // application-level callbacks. No need to create a new ExecCtx, though, // since there already is one and it is flushed (but not destructed) in this - // function itself. + // function itself. The ApplicationCallbackExecCtx will have its callbacks + // invoked on its destruction, which will be after completing any closures in + // the executor's closure list (which were explicitly scheduled onto the + // executor). grpc_core::ApplicationCallbackExecCtx callback_exec_ctx( GRPC_APP_CALLBACK_EXEC_CTX_FLAG_IS_INTERNAL_THREAD); From 4ad6d6d4dfefd1e7892d808ce29adfa3a8b49d82 Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Wed, 26 Jun 2019 10:33:06 -0700 Subject: [PATCH 0720/1555] Enable CFStream by default on iOS for all wrapped languages --- CMakeLists.txt | 18 ++++++++++++++++++ Makefile | 1 + src/core/lib/iomgr/iomgr_posix_cfstream.cc | 10 ++++++++++ src/objective-c/GRPCClient/GRPCCall.m | 5 +---- src/objective-c/manual_tests/main.m | 2 -- templates/CMakeLists.txt.template | 7 +++++++ templates/Makefile.template | 1 + 7 files changed, 38 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 19c8d44b05d..40757101a7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1364,6 +1364,9 @@ target_link_libraries(grpc ${_gRPC_ALLTARGETS_LIBRARIES} gpr ) +if (_gRPC_PLATFORM_IOS OR _gRPC_PLATFORM_MAC) + target_link_libraries(grpc "-framework CoreFoundation") +endif() foreach(_hdr include/grpc/impl/codegen/byte_buffer.h @@ -1762,6 +1765,9 @@ target_link_libraries(grpc_cronet ${_gRPC_ALLTARGETS_LIBRARIES} gpr ) +if (_gRPC_PLATFORM_IOS OR _gRPC_PLATFORM_MAC) + target_link_libraries(grpc_cronet "-framework CoreFoundation") +endif() foreach(_hdr include/grpc/impl/codegen/byte_buffer.h @@ -2091,6 +2097,9 @@ target_link_libraries(grpc_test_util gpr grpc ) +if (_gRPC_PLATFORM_IOS OR _gRPC_PLATFORM_MAC) + target_link_libraries(grpc_test_util "-framework CoreFoundation") +endif() foreach(_hdr include/grpc/support/alloc.h @@ -2421,6 +2430,9 @@ target_link_libraries(grpc_test_util_unsecure gpr grpc_unsecure ) +if (_gRPC_PLATFORM_IOS OR _gRPC_PLATFORM_MAC) + target_link_libraries(grpc_test_util_unsecure "-framework CoreFoundation") +endif() foreach(_hdr include/grpc/support/alloc.h @@ -2774,6 +2786,9 @@ target_link_libraries(grpc_unsecure ${_gRPC_ALLTARGETS_LIBRARIES} gpr ) +if (_gRPC_PLATFORM_IOS OR _gRPC_PLATFORM_MAC) + target_link_libraries(grpc_unsecure "-framework CoreFoundation") +endif() foreach(_hdr include/grpc/impl/codegen/byte_buffer.h @@ -3729,6 +3744,9 @@ target_link_libraries(grpc++_cronet grpc_cronet grpc ) +if (_gRPC_PLATFORM_IOS OR _gRPC_PLATFORM_MAC) + target_link_libraries(grpc++_cronet "-framework CoreFoundation") +endif() foreach(_hdr include/grpc++/alarm.h diff --git a/Makefile b/Makefile index 2d28e7b5656..e3ce968cfdc 100644 --- a/Makefile +++ b/Makefile @@ -351,6 +351,7 @@ CFLAGS += -std=c99 -Wsign-conversion -Wconversion $(W_SHADOW) $(W_EXTRA_SEMI) CXXFLAGS += -std=c++11 ifeq ($(SYSTEM),Darwin) CXXFLAGS += -stdlib=libc++ +LDFLAGS += -framework CoreFoundation endif CXXFLAGS += -Wnon-virtual-dtor CPPFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter -DOSATOMIC_USE_INLINED=1 -Wno-deprecated-declarations -Ithird_party/nanopb -DPB_FIELD_32BIT diff --git a/src/core/lib/iomgr/iomgr_posix_cfstream.cc b/src/core/lib/iomgr/iomgr_posix_cfstream.cc index cf4d05318ea..6e1bbae032e 100644 --- a/src/core/lib/iomgr/iomgr_posix_cfstream.cc +++ b/src/core/lib/iomgr/iomgr_posix_cfstream.cc @@ -78,9 +78,19 @@ static grpc_iomgr_platform_vtable vtable = { void grpc_set_default_iomgr_platform() { char* enable_cfstream = getenv(grpc_cfstream_env_var); grpc_tcp_client_vtable* client_vtable = &grpc_posix_tcp_client_vtable; + // CFStream is enabled by default on iOS, and disabled by default on other + // platforms. Defaults can be overriden by setting the grpc_cfstream + // environment variable. +#if TARGET_OS_IPHONE + if (enable_cfstream == nullptr || enable_cfstream[0] == '1') { + client_vtable = &grpc_cfstream_client_vtable; + } +#else if (enable_cfstream != nullptr && enable_cfstream[0] == '1') { client_vtable = &grpc_cfstream_client_vtable; } +#endif + grpc_set_tcp_client_impl(client_vtable); grpc_set_tcp_server_impl(&grpc_posix_tcp_server_vtable); grpc_set_timer_impl(&grpc_generic_timer_vtable); diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index e97ed6e3a9e..b5dfade0c39 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -322,9 +322,6 @@ const char *kCFStreamVarName = "grpc_cfstream"; // Guarantees the code in {} block is invoked only once. See ref at: // https://developer.apple.com/documentation/objectivec/nsobject/1418639-initialize?language=objc if (self == [GRPCCall self]) { - // Enable CFStream by default by do not overwrite if the user explicitly disables CFStream with - // environment variable "grpc_cfstream=0" - setenv(kCFStreamVarName, "1", 0); grpc_init(); callFlags = [NSMutableDictionary dictionary]; } @@ -780,7 +777,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; // Connectivity monitor is not required for CFStream char *enableCFStream = getenv(kCFStreamVarName); - if (enableCFStream == nil || enableCFStream[0] != '1') { + if (enableCFStream != nil && enableCFStream[0] != '1') { [GRPCConnectivityMonitor registerObserver:self selector:@selector(connectivityChanged:)]; } } diff --git a/src/objective-c/manual_tests/main.m b/src/objective-c/manual_tests/main.m index 451b50cc0e2..2797c6f17f2 100644 --- a/src/objective-c/manual_tests/main.m +++ b/src/objective-c/manual_tests/main.m @@ -21,8 +21,6 @@ int main(int argc, char* argv[]) { @autoreleasepool { - // enable CFStream API - setenv("grpc_cfstream", "1", 1); return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index 43bc063aee5..abf1282fe51 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -467,6 +467,13 @@ ) endif (_gRPC_PLATFORM_ANDROID) % endif + % if lib.name in ["grpc", "grpc_cronet", "grpc_test_util", \ + "grpc_test_util_unsecure", "grpc_unsecure", \ + "grpc++_cronet"]: + if (_gRPC_PLATFORM_IOS OR _gRPC_PLATFORM_MAC) + target_link_libraries(${lib.name} "-framework CoreFoundation") + endif() + %endif % if len(lib.get('public_headers', [])) > 0: foreach(_hdr diff --git a/templates/Makefile.template b/templates/Makefile.template index 24bea5c2423..18132b0db13 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -220,6 +220,7 @@ CXXFLAGS += -std=c++11 ifeq ($(SYSTEM),Darwin) CXXFLAGS += -stdlib=libc++ + LDFLAGS += -framework CoreFoundation endif % for arg in ['CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'COREFLAGS', 'LDFLAGS', 'DEFINES']: % if defaults.get('global', []).get(arg, None) is not None: From 2602bdd3e404849421a0be78c7f023057b4b9872 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 26 Jun 2019 11:37:54 -0700 Subject: [PATCH 0721/1555] Address review comments --- src/core/lib/surface/completion_queue.cc | 4 +-- .../end2end/client_callback_end2end_test.cc | 28 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index 55bfb6fcc30..82f87e769bf 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -864,7 +864,7 @@ static void cq_end_op_for_callback( return; } - // Schedule the shutdown callback on a closure if not internal or triggered + // Schedule the callback on a closure if not internal or triggered // from a background poller thread. GRPC_CLOSURE_SCHED( GRPC_CLOSURE_CREATE( @@ -1360,7 +1360,7 @@ static void cq_finish_shutdown_callback(grpc_completion_queue* cq) { return; } - // Schedule the shutdown callback on a closure if not internal or triggered + // Schedule the callback on a closure if not internal or triggered // from a background poller thread. GRPC_CLOSURE_SCHED( GRPC_CLOSURE_CREATE( diff --git a/test/cpp/end2end/client_callback_end2end_test.cc b/test/cpp/end2end/client_callback_end2end_test.cc index 8c33dc85cfc..ea94ac77726 100644 --- a/test/cpp/end2end/client_callback_end2end_test.cc +++ b/test/cpp/end2end/client_callback_end2end_test.cc @@ -378,8 +378,8 @@ TEST_P(ClientCallbackEnd2endTest, SimpleRpcUnderLockNested) { MAYBE_SKIP_TEST; ResetStub(); std::mutex mu1, mu2, mu3; - std::condition_variable cv1, cv2, cv3; - bool done1 = false; + std::condition_variable cv; + bool done = false; EchoRequest request1, request2, request3; request1.set_message("Hello locked world1."); request2.set_message("Hello locked world2."); @@ -387,42 +387,42 @@ TEST_P(ClientCallbackEnd2endTest, SimpleRpcUnderLockNested) { EchoResponse response1, response2, response3; ClientContext cli_ctx1, cli_ctx2, cli_ctx3; { - std::unique_lock l(mu1); + std::lock_guard l(mu1); stub_->experimental_async()->Echo( &cli_ctx1, &request1, &response1, - [this, &mu1, &mu2, &mu3, &cv1, &done1, &request1, &request2, &request3, + [this, &mu1, &mu2, &mu3, &cv, &done, &request1, &request2, &request3, &response1, &response2, &response3, &cli_ctx1, &cli_ctx2, &cli_ctx3](Status s1) { - std::unique_lock l1(mu1); + std::lock_guard l1(mu1); EXPECT_TRUE(s1.ok()); EXPECT_EQ(request1.message(), response1.message()); // start the second level of nesting std::unique_lock l2(mu2); this->stub_->experimental_async()->Echo( &cli_ctx2, &request2, &response2, - [this, &mu2, &mu3, &cv1, &done1, &request2, &request3, &response2, + [this, &mu2, &mu3, &cv, &done, &request2, &request3, &response2, &response3, &cli_ctx3](Status s2) { - std::unique_lock l2(mu2); + std::lock_guard l2(mu2); EXPECT_TRUE(s2.ok()); EXPECT_EQ(request2.message(), response2.message()); // start the third level of nesting - std::unique_lock l3(mu3); + std::lock_guard l3(mu3); stub_->experimental_async()->Echo( &cli_ctx3, &request3, &response3, - [&mu3, &cv1, &done1, &request3, &response3](Status s3) { + [&mu3, &cv, &done, &request3, &response3](Status s3) { std::lock_guard l(mu3); EXPECT_TRUE(s3.ok()); EXPECT_EQ(request3.message(), response3.message()); - done1 = true; - cv1.notify_all(); + done = true; + cv.notify_all(); }); }); }); } - std::unique_lock l1(mu1); - while (!done1) { - cv1.wait(l1); + std::unique_lock l(mu3); + while (!done) { + cv.wait(l); } } From 748b932d0233ffdbc2faa2038d96e3b384219be1 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 26 Jun 2019 12:32:31 -0700 Subject: [PATCH 0722/1555] Fix header guards --- include/grpcpp/completion_queue_impl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/grpcpp/completion_queue_impl.h b/include/grpcpp/completion_queue_impl.h index d5bb07d5763..b6fb2b4f990 100644 --- a/include/grpcpp/completion_queue_impl.h +++ b/include/grpcpp/completion_queue_impl.h @@ -16,9 +16,9 @@ * */ -#ifndef GRPCPP_COMPLETION_QUEUE_H -#define GRPCPP_COMPLETION_QUEUE_H +#ifndef GRPCPP_COMPLETION_QUEUE_IMPL_H +#define GRPCPP_COMPLETION_QUEUE_IMPL_H #include -#endif // GRPCPP_COMPLETION_QUEUE_H +#endif // GRPCPP_COMPLETION_QUEUE_IMPL_H From 189c2c8c306f92586e33a355f90bd600d0cd2488 Mon Sep 17 00:00:00 2001 From: Julien Boeuf Date: Tue, 14 May 2019 23:06:53 -0700 Subject: [PATCH 0723/1555] Adding support for STS Token Exchange Creds in core: - IETF specification is available here: https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16 --- grpc.def | 1 + include/grpc/grpc_security.h | 25 ++ .../security/credentials/jwt/json_token.cc | 8 +- .../credentials/oauth2/oauth2_credentials.cc | 258 +++++++++++++-- .../credentials/oauth2/oauth2_credentials.h | 16 + src/core/lib/security/util/json_util.cc | 24 +- src/core/lib/security/util/json_util.h | 4 +- src/ruby/ext/grpc/rb_grpc_imports.generated.c | 2 + src/ruby/ext/grpc/rb_grpc_imports.generated.h | 3 + test/core/security/credentials_test.cc | 305 +++++++++++++++++- test/core/security/fetch_oauth2.cc | 82 ++++- test/core/security/oauth2_utils.cc | 15 +- .../core/surface/public_headers_must_be_c89.c | 1 + 13 files changed, 692 insertions(+), 52 deletions(-) diff --git a/grpc.def b/grpc.def index 32289dffeb7..f451775dba6 100644 --- a/grpc.def +++ b/grpc.def @@ -111,6 +111,7 @@ EXPORTS grpc_google_refresh_token_credentials_create grpc_access_token_credentials_create grpc_google_iam_credentials_create + grpc_sts_credentials_create grpc_metadata_credentials_create_from_plugin grpc_secure_channel_create grpc_server_credentials_release diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h index 139c0c37a1f..8e4f26a2854 100644 --- a/include/grpc/grpc_security.h +++ b/include/grpc/grpc_security.h @@ -328,6 +328,31 @@ GRPCAPI grpc_call_credentials* grpc_google_iam_credentials_create( const char* authorization_token, const char* authority_selector, void* reserved); +/** Options for creating STS Oauth Token Exchange credentials following the IETF + draft https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16. + Optional fields may be set to NULL. It is the responsibility of the caller to + ensure that the subject and actor tokens are refreshed on disk at the + specified paths. This API is used for experimental purposes for now and may + change in the future. */ +typedef struct { + const char* sts_endpoint_url; /* Required. */ + const char* resource; /* Optional. */ + const char* audience; /* Optional. */ + const char* scope; /* Optional. */ + const char* requested_token_type; /* Optional. */ + const char* subject_token_path; /* Required. */ + const char* subject_token_type; /* Required. */ + const char* actor_token_path; /* Optional. */ + const char* actor_token_type; /* Optional. */ +} grpc_sts_credentials_options; + +/** Creates an STS credentials following the STS Token Exchanged specifed in the + IETF draft https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16. + This API is used for experimental purposes for now and may change in the + future. */ +GRPCAPI grpc_call_credentials* grpc_sts_credentials_create( + const grpc_sts_credentials_options* options, void* reserved); + /** Callback function to be called by the metadata credentials plugin implementation when the metadata is ready. - user_data is the opaque pointer that was passed in the get_metadata method diff --git a/src/core/lib/security/credentials/jwt/json_token.cc b/src/core/lib/security/credentials/jwt/json_token.cc index 113e2b83754..12b7c5368da 100644 --- a/src/core/lib/security/credentials/jwt/json_token.cc +++ b/src/core/lib/security/credentials/jwt/json_token.cc @@ -18,6 +18,7 @@ #include +#include "src/core/lib/iomgr/error.h" #include "src/core/lib/security/credentials/jwt/json_token.h" #include @@ -69,6 +70,7 @@ grpc_auth_json_key grpc_auth_json_key_create_from_json(const grpc_json* json) { BIO* bio = nullptr; const char* prop_value; int success = 0; + grpc_error* error = GRPC_ERROR_NONE; memset(&result, 0, sizeof(grpc_auth_json_key)); result.type = GRPC_AUTH_JSON_TYPE_INVALID; @@ -77,7 +79,8 @@ grpc_auth_json_key grpc_auth_json_key_create_from_json(const grpc_json* json) { goto end; } - prop_value = grpc_json_get_string_property(json, "type"); + prop_value = grpc_json_get_string_property(json, "type", &error); + GRPC_LOG_IF_ERROR("JSON key parsing", error); if (prop_value == nullptr || strcmp(prop_value, GRPC_AUTH_JSON_TYPE_SERVICE_ACCOUNT)) { goto end; @@ -92,7 +95,8 @@ grpc_auth_json_key grpc_auth_json_key_create_from_json(const grpc_json* json) { goto end; } - prop_value = grpc_json_get_string_property(json, "private_key"); + prop_value = grpc_json_get_string_property(json, "private_key", &error); + GRPC_LOG_IF_ERROR("JSON key parsing", error); if (prop_value == nullptr) { goto end; } diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc index b001868b3d3..3d63ec12b49 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc @@ -22,14 +22,23 @@ #include -#include "src/core/lib/gprpp/ref_counted_ptr.h" -#include "src/core/lib/security/util/json_util.h" -#include "src/core/lib/surface/api_trace.h" - +#include +#include +#include #include #include #include +#include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/inlined_vector.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" +#include "src/core/lib/iomgr/error.h" +#include "src/core/lib/iomgr/load_file.h" +#include "src/core/lib/security/util/json_util.h" +#include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/surface/api_trace.h" +#include "src/core/lib/uri/uri_parser.h" + // // Auth Refresh Token. // @@ -45,6 +54,7 @@ grpc_auth_refresh_token grpc_auth_refresh_token_create_from_json( grpc_auth_refresh_token result; const char* prop_value; int success = 0; + grpc_error* error = GRPC_ERROR_NONE; memset(&result, 0, sizeof(grpc_auth_refresh_token)); result.type = GRPC_AUTH_JSON_TYPE_INVALID; @@ -53,7 +63,8 @@ grpc_auth_refresh_token grpc_auth_refresh_token_create_from_json( goto end; } - prop_value = grpc_json_get_string_property(json, "type"); + prop_value = grpc_json_get_string_property(json, "type", &error); + GRPC_LOG_IF_ERROR("Parsing refresh token", error); if (prop_value == nullptr || strcmp(prop_value, GRPC_AUTH_JSON_TYPE_AUTHORIZED_USER)) { goto end; @@ -218,8 +229,10 @@ void grpc_oauth2_token_fetcher_credentials::on_http_response( grpc_mdelem access_token_md = GRPC_MDNULL; grpc_millis token_lifetime; grpc_credentials_status status = - grpc_oauth2_token_fetcher_credentials_parse_server_response( - &r->response, &access_token_md, &token_lifetime); + error == GRPC_ERROR_NONE + ? grpc_oauth2_token_fetcher_credentials_parse_server_response( + &r->response, &access_token_md, &token_lifetime) + : GRPC_CREDENTIALS_ERROR; // Update cache and grab list of pending requests. gpr_mu_lock(&mu_); token_fetch_pending_ = false; @@ -234,14 +247,15 @@ void grpc_oauth2_token_fetcher_credentials::on_http_response( gpr_mu_unlock(&mu_); // Invoke callbacks for all pending requests. while (pending_request != nullptr) { + grpc_error* new_error = GRPC_ERROR_NONE; if (status == GRPC_CREDENTIALS_OK) { grpc_credentials_mdelem_array_add(pending_request->md_array, access_token_md); } else { - error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( + new_error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( "Error occurred when fetching oauth2 token.", &error, 1); } - GRPC_CLOSURE_SCHED(pending_request->on_request_metadata, error); + GRPC_CLOSURE_SCHED(pending_request->on_request_metadata, new_error); grpc_polling_entity_del_from_pollset_set( pending_request->pollent, grpc_polling_entity_pollset_set(&pollent_)); grpc_oauth2_pending_get_request_metadata* prev = pending_request; @@ -356,7 +370,8 @@ class grpc_compute_engine_token_fetcher_credentials grpc_polling_entity* pollent, grpc_iomgr_cb_func response_cb, grpc_millis deadline) override { - grpc_http_header header = {(char*)"Metadata-Flavor", (char*)"Google"}; + grpc_http_header header = {const_cast("Metadata-Flavor"), + const_cast("Google")}; grpc_httpcli_request request; memset(&request, 0, sizeof(grpc_httpcli_request)); request.host = (char*)GRPC_COMPUTE_ENGINE_METADATA_HOST; @@ -369,11 +384,14 @@ class grpc_compute_engine_token_fetcher_credentials grpc_resource_quota* resource_quota = grpc_resource_quota_create("oauth2_credentials"); grpc_httpcli_get(http_context, pollent, resource_quota, &request, deadline, - GRPC_CLOSURE_CREATE(response_cb, metadata_req, - grpc_schedule_on_exec_ctx), + GRPC_CLOSURE_INIT(&http_get_cb_closure_, response_cb, + metadata_req, grpc_schedule_on_exec_ctx), &metadata_req->response); grpc_resource_quota_unref_internal(resource_quota); } + + private: + grpc_closure http_get_cb_closure_; }; } // namespace @@ -401,8 +419,9 @@ void grpc_google_refresh_token_credentials::fetch_oauth2( grpc_credentials_metadata_request* metadata_req, grpc_httpcli_context* httpcli_context, grpc_polling_entity* pollent, grpc_iomgr_cb_func response_cb, grpc_millis deadline) { - grpc_http_header header = {(char*)"Content-Type", - (char*)"application/x-www-form-urlencoded"}; + grpc_http_header header = { + const_cast("Content-Type"), + const_cast("application/x-www-form-urlencoded")}; grpc_httpcli_request request; char* body = nullptr; gpr_asprintf(&body, GRPC_REFRESH_TOKEN_POST_BODY_FORMAT_STRING, @@ -419,11 +438,11 @@ void grpc_google_refresh_token_credentials::fetch_oauth2( extreme memory pressure. */ grpc_resource_quota* resource_quota = grpc_resource_quota_create("oauth2_credentials_refresh"); - grpc_httpcli_post( - httpcli_context, pollent, resource_quota, &request, body, strlen(body), - deadline, - GRPC_CLOSURE_CREATE(response_cb, metadata_req, grpc_schedule_on_exec_ctx), - &metadata_req->response); + grpc_httpcli_post(httpcli_context, pollent, resource_quota, &request, body, + strlen(body), deadline, + GRPC_CLOSURE_INIT(&http_post_cb_closure_, response_cb, + metadata_req, grpc_schedule_on_exec_ctx), + &metadata_req->response); grpc_resource_quota_unref_internal(resource_quota); gpr_free(body); } @@ -472,6 +491,207 @@ grpc_call_credentials* grpc_google_refresh_token_credentials_create( .release(); } +// +// STS credentials. +// + +namespace grpc_core { + +namespace { + +void MaybeAddToBody(gpr_strvec* body_strvec, const char* field_name, + const char* field) { + if (field == nullptr || strlen(field) == 0) return; + char* new_query; + gpr_asprintf(&new_query, "&%s=%s", field_name, field); + gpr_strvec_add(body_strvec, new_query); +} + +grpc_error* LoadTokenFile(const char* path, gpr_slice* token) { + grpc_error* err = grpc_load_file(path, 1, token); + if (err != GRPC_ERROR_NONE) return err; + if (GRPC_SLICE_LENGTH(*token) == 0) { + gpr_log(GPR_ERROR, "Token file %s is empty", path); + err = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Token file is empty."); + } + return err; +} + +class StsTokenFetcherCredentials + : public grpc_oauth2_token_fetcher_credentials { + public: + StsTokenFetcherCredentials(grpc_uri* sts_url, // Ownership transfered. + const grpc_sts_credentials_options* options) + : sts_url_(sts_url), + resource_(gpr_strdup(options->resource)), + audience_(gpr_strdup(options->audience)), + scope_(gpr_strdup(options->scope)), + requested_token_type_(gpr_strdup(options->requested_token_type)), + subject_token_path_(gpr_strdup(options->subject_token_path)), + subject_token_type_(gpr_strdup(options->subject_token_type)), + actor_token_path_(gpr_strdup(options->actor_token_path)), + actor_token_type_(gpr_strdup(options->actor_token_type)) {} + + ~StsTokenFetcherCredentials() override { grpc_uri_destroy(sts_url_); } + + private: + void fetch_oauth2(grpc_credentials_metadata_request* metadata_req, + grpc_httpcli_context* http_context, + grpc_polling_entity* pollent, + grpc_iomgr_cb_func response_cb, + grpc_millis deadline) override { + char* body = nullptr; + size_t body_length = 0; + grpc_error* err = FillBody(&body, &body_length); + if (err != GRPC_ERROR_NONE) { + response_cb(metadata_req, err); + GRPC_ERROR_UNREF(err); + return; + } + grpc_http_header header = { + const_cast("Content-Type"), + const_cast("application/x-www-form-urlencoded")}; + grpc_httpcli_request request; + memset(&request, 0, sizeof(grpc_httpcli_request)); + request.host = (char*)sts_url_->authority; + request.http.path = (char*)sts_url_->path; + request.http.hdr_count = 1; + request.http.hdrs = &header; + request.handshaker = (strcmp(sts_url_->scheme, "https") == 0) + ? &grpc_httpcli_ssl + : &grpc_httpcli_plaintext; + /* TODO(ctiller): Carry the resource_quota in ctx and share it with the host + channel. This would allow us to cancel an authentication query when under + extreme memory pressure. */ + grpc_resource_quota* resource_quota = + grpc_resource_quota_create("oauth2_credentials_refresh"); + grpc_httpcli_post( + http_context, pollent, resource_quota, &request, body, body_length, + deadline, + GRPC_CLOSURE_INIT(&http_post_cb_closure_, response_cb, metadata_req, + grpc_schedule_on_exec_ctx), + &metadata_req->response); + grpc_resource_quota_unref_internal(resource_quota); + gpr_free(body); + } + + grpc_error* FillBody(char** body, size_t* body_length) { + *body = nullptr; + gpr_strvec body_strvec; + gpr_strvec_init(&body_strvec); + grpc_slice subject_token = grpc_empty_slice(); + grpc_slice actor_token = grpc_empty_slice(); + grpc_error* err = GRPC_ERROR_NONE; + + auto cleanup = [&body, &body_length, &body_strvec, &subject_token, + &actor_token, &err]() { + if (err == GRPC_ERROR_NONE) { + *body = gpr_strvec_flatten(&body_strvec, body_length); + } else { + gpr_free(*body); + } + gpr_strvec_destroy(&body_strvec); + grpc_slice_unref_internal(subject_token); + grpc_slice_unref_internal(actor_token); + return err; + }; + + err = LoadTokenFile(subject_token_path_.get(), &subject_token); + if (err != GRPC_ERROR_NONE) return cleanup(); + gpr_asprintf( + body, GRPC_STS_POST_MINIMAL_BODY_FORMAT_STRING, + reinterpret_cast(GRPC_SLICE_START_PTR(subject_token)), + subject_token_type_.get()); + gpr_strvec_add(&body_strvec, *body); + MaybeAddToBody(&body_strvec, "resource", resource_.get()); + MaybeAddToBody(&body_strvec, "audience", audience_.get()); + MaybeAddToBody(&body_strvec, "scope", scope_.get()); + MaybeAddToBody(&body_strvec, "requested_token_type", + requested_token_type_.get()); + if (actor_token_path_ != nullptr) { + err = LoadTokenFile(actor_token_path_.get(), &actor_token); + if (err != GRPC_ERROR_NONE) return cleanup(); + MaybeAddToBody( + &body_strvec, "actor_token", + reinterpret_cast(GRPC_SLICE_START_PTR(subject_token))); + MaybeAddToBody(&body_strvec, "actor_token_type", actor_token_type_.get()); + } + return cleanup(); + } + + grpc_uri* sts_url_; + grpc_closure http_post_cb_closure_; + grpc_core::UniquePtr resource_; + grpc_core::UniquePtr audience_; + grpc_core::UniquePtr scope_; + grpc_core::UniquePtr requested_token_type_; + grpc_core::UniquePtr subject_token_path_; + grpc_core::UniquePtr subject_token_type_; + grpc_core::UniquePtr actor_token_path_; + grpc_core::UniquePtr actor_token_type_; +}; + +} // namespace + +grpc_error* ValidateStsCredentialsOptions( + const grpc_sts_credentials_options* options, grpc_uri** sts_url_out) { + struct GrpcUriDeleter { + void operator()(grpc_uri* uri) { grpc_uri_destroy(uri); } + }; + *sts_url_out = nullptr; + InlinedVector error_list; + UniquePtr sts_url( + options->sts_endpoint_url != nullptr + ? grpc_uri_parse(options->sts_endpoint_url, false) + : nullptr); + if (sts_url == nullptr) { + error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "Invalid or missing STS endpoint URL")); + } else { + if (strcmp(sts_url->scheme, "https") != 0 && + strcmp(sts_url->scheme, "http") != 0) { + error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "Invalid URI scheme, must be https to http.")); + } + } + if (options->subject_token_path == nullptr || + strlen(options->subject_token_path) == 0) { + error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "subject_token needs to be specified")); + } + if (options->subject_token_type == nullptr || + strlen(options->subject_token_type) == 0) { + error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "subject_token_type needs to be specified")); + } + if (error_list.empty()) { + *sts_url_out = sts_url.release(); + return GRPC_ERROR_NONE; + } else { + return GRPC_ERROR_CREATE_FROM_VECTOR("Invalid STS Credentials Options", + &error_list); + } +} + +} // namespace grpc_core + +grpc_call_credentials* grpc_sts_credentials_create( + const grpc_sts_credentials_options* options, void* reserved) { + GPR_ASSERT(reserved == nullptr); + grpc_uri* sts_url; + grpc_error* error = + grpc_core::ValidateStsCredentialsOptions(options, &sts_url); + if (error != GRPC_ERROR_NONE) { + gpr_log(GPR_ERROR, "STS Credentials creation failed. Error: %s.", + grpc_error_string(error)); + GRPC_ERROR_UNREF(error); + return nullptr; + } + return grpc_core::MakeRefCounted( + sts_url, options) + .release(); +} + // // Oauth2 Access Token credentials. // diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h index 510a78b484a..c9b2d1decac 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h @@ -21,8 +21,15 @@ #include +#include #include "src/core/lib/json/json.h" #include "src/core/lib/security/credentials/credentials.h" +#include "src/core/lib/uri/uri_parser.h" + +// Constants. +#define GRPC_STS_POST_MINIMAL_BODY_FORMAT_STRING \ + "grant_type=urn:ietf:params:oauth:grant-type:token-exchange&subject_token=%" \ + "s&subject_token_type=%s" // auth_refresh_token parsing. typedef struct { @@ -115,6 +122,7 @@ class grpc_google_refresh_token_credentials final private: grpc_auth_refresh_token refresh_token_; + grpc_closure http_post_cb_closure_; }; // Access token credentials. @@ -148,4 +156,12 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response( const struct grpc_http_response* response, grpc_mdelem* token_md, grpc_millis* token_lifetime); +namespace grpc_core { +// Exposed for testing only. This function validates the options, ensuring that +// the required fields are set, and outputs the parsed URL of the STS token +// exchanged service. +grpc_error* ValidateStsCredentialsOptions( + const grpc_sts_credentials_options* options, grpc_uri** sts_url); +} // namespace grpc_core + #endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_OAUTH2_OAUTH2_CREDENTIALS_H */ diff --git a/src/core/lib/security/util/json_util.cc b/src/core/lib/security/util/json_util.cc index fe9f5fe3d35..8a1db636139 100644 --- a/src/core/lib/security/util/json_util.cc +++ b/src/core/lib/security/util/json_util.cc @@ -18,6 +18,7 @@ #include +#include "src/core/lib/iomgr/error.h" #include "src/core/lib/security/util/json_util.h" #include @@ -26,17 +27,27 @@ #include const char* grpc_json_get_string_property(const grpc_json* json, - const char* prop_name) { - grpc_json* child; + const char* prop_name, + grpc_error** error) { + grpc_json* child = nullptr; + if (error != nullptr) *error = GRPC_ERROR_NONE; for (child = json->child; child != nullptr; child = child->next) { if (child->key == nullptr) { - gpr_log(GPR_ERROR, "Invalid (null) JSON key encountered"); + if (error != nullptr) { + *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "Invalid (null) JSON key encountered"); + } return nullptr; } if (strcmp(child->key, prop_name) == 0) break; } if (child == nullptr || child->type != GRPC_JSON_STRING) { - gpr_log(GPR_ERROR, "Invalid or missing %s property.", prop_name); + if (error != nullptr) { + char* error_msg; + gpr_asprintf(&error_msg, "Invalid or missing %s property.", prop_name); + *error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg); + gpr_free(error_msg); + } return nullptr; } return child->value; @@ -45,7 +56,10 @@ const char* grpc_json_get_string_property(const grpc_json* json, bool grpc_copy_json_string_property(const grpc_json* json, const char* prop_name, char** copied_value) { - const char* prop_value = grpc_json_get_string_property(json, prop_name); + grpc_error* error = GRPC_ERROR_NONE; + const char* prop_value = + grpc_json_get_string_property(json, prop_name, &error); + GRPC_LOG_IF_ERROR("Could not copy JSON property", error); if (prop_value == nullptr) return false; *copied_value = gpr_strdup(prop_value); return true; diff --git a/src/core/lib/security/util/json_util.h b/src/core/lib/security/util/json_util.h index 89deffcc081..44d9eccd545 100644 --- a/src/core/lib/security/util/json_util.h +++ b/src/core/lib/security/util/json_util.h @@ -23,6 +23,7 @@ #include +#include "src/core/lib/iomgr/error.h" #include "src/core/lib/json/json.h" // Constants. @@ -32,7 +33,8 @@ // Gets a child property from a json node. const char* grpc_json_get_string_property(const grpc_json* json, - const char* prop_name); + const char* prop_name, + grpc_error** error); // Copies the value of the json child property specified by prop_name. // Returns false if the property was not found. diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index b1165a6d6eb..fa275c75419 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -134,6 +134,7 @@ grpc_service_account_jwt_access_credentials_create_type grpc_service_account_jwt grpc_google_refresh_token_credentials_create_type grpc_google_refresh_token_credentials_create_import; grpc_access_token_credentials_create_type grpc_access_token_credentials_create_import; grpc_google_iam_credentials_create_type grpc_google_iam_credentials_create_import; +grpc_sts_credentials_create_type grpc_sts_credentials_create_import; grpc_metadata_credentials_create_from_plugin_type grpc_metadata_credentials_create_from_plugin_import; grpc_secure_channel_create_type grpc_secure_channel_create_import; grpc_server_credentials_release_type grpc_server_credentials_release_import; @@ -404,6 +405,7 @@ void grpc_rb_load_imports(HMODULE library) { grpc_google_refresh_token_credentials_create_import = (grpc_google_refresh_token_credentials_create_type) GetProcAddress(library, "grpc_google_refresh_token_credentials_create"); grpc_access_token_credentials_create_import = (grpc_access_token_credentials_create_type) GetProcAddress(library, "grpc_access_token_credentials_create"); grpc_google_iam_credentials_create_import = (grpc_google_iam_credentials_create_type) GetProcAddress(library, "grpc_google_iam_credentials_create"); + grpc_sts_credentials_create_import = (grpc_sts_credentials_create_type) GetProcAddress(library, "grpc_sts_credentials_create"); grpc_metadata_credentials_create_from_plugin_import = (grpc_metadata_credentials_create_from_plugin_type) GetProcAddress(library, "grpc_metadata_credentials_create_from_plugin"); grpc_secure_channel_create_import = (grpc_secure_channel_create_type) GetProcAddress(library, "grpc_secure_channel_create"); grpc_server_credentials_release_import = (grpc_server_credentials_release_type) GetProcAddress(library, "grpc_server_credentials_release"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index 5809194f1ae..1389c301728 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -377,6 +377,9 @@ extern grpc_access_token_credentials_create_type grpc_access_token_credentials_c typedef grpc_call_credentials*(*grpc_google_iam_credentials_create_type)(const char* authorization_token, const char* authority_selector, void* reserved); extern grpc_google_iam_credentials_create_type grpc_google_iam_credentials_create_import; #define grpc_google_iam_credentials_create grpc_google_iam_credentials_create_import +typedef grpc_call_credentials*(*grpc_sts_credentials_create_type)(const grpc_sts_credentials_options* options, void* reserved); +extern grpc_sts_credentials_create_type grpc_sts_credentials_create_import; +#define grpc_sts_credentials_create grpc_sts_credentials_create_import typedef grpc_call_credentials*(*grpc_metadata_credentials_create_from_plugin_type)(grpc_metadata_credentials_plugin plugin, void* reserved); extern grpc_metadata_credentials_create_from_plugin_type grpc_metadata_credentials_create_from_plugin_import; #define grpc_metadata_credentials_create_from_plugin grpc_metadata_credentials_create_from_plugin_import diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc index 141346bca94..cbce595c354 100644 --- a/test/core/security/credentials_test.cc +++ b/test/core/security/credentials_test.cc @@ -24,8 +24,8 @@ #include #include +#include #include - #include #include #include @@ -34,13 +34,16 @@ #include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/http/httpcli.h" +#include "src/core/lib/iomgr/error.h" #include "src/core/lib/security/credentials/composite/composite_credentials.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "src/core/lib/security/credentials/google_default/google_default_credentials.h" #include "src/core/lib/security/credentials/jwt/jwt_credentials.h" #include "src/core/lib/security/credentials/oauth2/oauth2_credentials.h" #include "src/core/lib/security/transport/auth_filters.h" +#include "src/core/lib/uri/uri_parser.h" #include "test/core/util/test_config.h" using grpc_core::internal::grpc_flush_cached_google_default_credentials; @@ -99,15 +102,27 @@ static const char valid_oauth2_json_response[] = " \"expires_in\":3599, " " \"token_type\":\"Bearer\"}"; +static const char valid_sts_json_response[] = + "{\"access_token\":\"ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_\"," + " \"expires_in\":3599, " + " \"issued_token_type\":\"urn:ietf:params:oauth:token-type:access_token\", " + " \"token_type\":\"Bearer\"}"; + static const char test_scope[] = "perm1 perm2"; static const char test_signed_jwt[] = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImY0OTRkN2M1YWU2MGRmOTcyNmM4YW" "U0MDcyZTViYTdmZDkwODg2YzcifQ"; +static const char test_signed_jwt_token_type[] = + "urn:ietf:params:oauth:token-type:id_token"; +static const char test_signed_jwt_path_prefix[] = "test_sign_jwt"; static const char test_service_url[] = "https://foo.com/foo.v1"; static const char other_test_service_url[] = "https://bar.com/bar.v1"; +static const char test_sts_endpoint_url[] = + "https://foo.com:5555/v1/token-exchange"; + static const char test_method[] = "ThisIsNotAMethod"; /* -- Global state flags. -- */ @@ -657,11 +672,11 @@ static int refresh_token_httpcli_post_success( return 1; } -static int refresh_token_httpcli_post_failure( - const grpc_httpcli_request* request, const char* body, size_t body_size, - grpc_millis deadline, grpc_closure* on_done, - grpc_httpcli_response* response) { - validate_refresh_token_http_request(request, body, body_size); +static int token_httpcli_post_failure(const grpc_httpcli_request* request, + const char* body, size_t body_size, + grpc_millis deadline, + grpc_closure* on_done, + grpc_httpcli_response* response) { *response = http_response(403, "Not Authorized."); GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE); return 1; @@ -676,7 +691,7 @@ static void test_refresh_token_creds_success(void) { grpc_call_credentials* creds = grpc_google_refresh_token_credentials_create( test_refresh_token_str, nullptr); - /* First request: http get should be called. */ + /* First request: http put should be called. */ request_metadata_state* state = make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd)); grpc_httpcli_set_override(httpcli_get_should_not_be_called, @@ -707,12 +722,281 @@ static void test_refresh_token_creds_failure(void) { grpc_call_credentials* creds = grpc_google_refresh_token_credentials_create( test_refresh_token_str, nullptr); grpc_httpcli_set_override(httpcli_get_should_not_be_called, - refresh_token_httpcli_post_failure); + token_httpcli_post_failure); run_request_metadata_test(creds, auth_md_ctx, state); creds->Unref(); grpc_httpcli_set_override(nullptr, nullptr); } +static void test_valid_sts_creds_options(void) { + grpc_sts_credentials_options valid_options = { + test_sts_endpoint_url, // sts_endpoint_url + nullptr, // resource + nullptr, // audience + nullptr, // scope + nullptr, // requested_token_type + test_signed_jwt_path_prefix, // subject_token_path + test_signed_jwt_token_type, // subject_token_type + nullptr, // actor_token_path + nullptr // actor_token_type + }; + grpc_uri* sts_url; + grpc_error* error = + grpc_core::ValidateStsCredentialsOptions(&valid_options, &sts_url); + GPR_ASSERT(error == GRPC_ERROR_NONE); + GPR_ASSERT(sts_url != nullptr); + grpc_core::StringView host; + grpc_core::StringView port; + GPR_ASSERT(grpc_core::SplitHostPort(sts_url->authority, &host, &port)); + GPR_ASSERT(host.cmp("foo.com") == 0); + GPR_ASSERT(port.cmp("5555") == 0); + grpc_uri_destroy(sts_url); +} + +static void test_invalid_sts_creds_options(void) { + grpc_sts_credentials_options invalid_options = { + test_sts_endpoint_url, // sts_endpoint_url + nullptr, // resource + nullptr, // audience + nullptr, // scope + nullptr, // requested_token_type + nullptr, // subject_token_path (Required) + test_signed_jwt_token_type, // subject_token_type + nullptr, // actor_token_path + nullptr // actor_token_type + }; + grpc_uri* url_should_be_null; + grpc_error* error = grpc_core::ValidateStsCredentialsOptions( + &invalid_options, &url_should_be_null); + GPR_ASSERT(error != GRPC_ERROR_NONE); + GRPC_ERROR_UNREF(error); + GPR_ASSERT(url_should_be_null == nullptr); + + invalid_options = { + test_sts_endpoint_url, // sts_endpoint_url + nullptr, // resource + nullptr, // audience + nullptr, // scope + nullptr, // requested_token_type + test_signed_jwt_path_prefix, // subject_token_path + nullptr, // subject_token_type (Required) + nullptr, // actor_token_path + nullptr // actor_token_type + }; + error = grpc_core::ValidateStsCredentialsOptions(&invalid_options, + &url_should_be_null); + GPR_ASSERT(error != GRPC_ERROR_NONE); + GRPC_ERROR_UNREF(error); + GPR_ASSERT(url_should_be_null == nullptr); + + invalid_options = { + nullptr, // sts_endpoint_url (Required) + nullptr, // resource + nullptr, // audience + nullptr, // scope + nullptr, // requested_token_type + test_signed_jwt_path_prefix, // subject_token_path + test_signed_jwt_token_type, // subject_token_type (Required) + nullptr, // actor_token_path + nullptr // actor_token_type + }; + error = grpc_core::ValidateStsCredentialsOptions(&invalid_options, + &url_should_be_null); + GPR_ASSERT(error != GRPC_ERROR_NONE); + GRPC_ERROR_UNREF(error); + GPR_ASSERT(url_should_be_null == nullptr); + + invalid_options = { + "not_a_valid_uri", // sts_endpoint_url + nullptr, // resource + nullptr, // audience + nullptr, // scope + nullptr, // requested_token_type + test_signed_jwt_path_prefix, // subject_token_path + test_signed_jwt_token_type, // subject_token_type (Required) + nullptr, // actor_token_path + nullptr // actor_token_type + }; + error = grpc_core::ValidateStsCredentialsOptions(&invalid_options, + &url_should_be_null); + GPR_ASSERT(error != GRPC_ERROR_NONE); + GRPC_ERROR_UNREF(error); + GPR_ASSERT(url_should_be_null == nullptr); + + invalid_options = { + "ftp://ftp.is.not.a.valid.scheme/bar", // sts_endpoint_url + nullptr, // resource + nullptr, // audience + nullptr, // scope + nullptr, // requested_token_type + test_signed_jwt_path_prefix, // subject_token_path + test_signed_jwt_token_type, // subject_token_type (Required) + nullptr, // actor_token_path + nullptr // actor_token_type + }; + error = grpc_core::ValidateStsCredentialsOptions(&invalid_options, + &url_should_be_null); + GPR_ASSERT(error != GRPC_ERROR_NONE); + GRPC_ERROR_UNREF(error); + GPR_ASSERT(url_should_be_null == nullptr); +} + +static void validate_sts_token_http_request(const grpc_httpcli_request* request, + const char* body, + size_t body_size) { + // Check that the body is constructed properly. + GPR_ASSERT(body != nullptr); + GPR_ASSERT(body_size != 0); + GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl); + char* get_url_equivalent; + gpr_asprintf(&get_url_equivalent, "%s?%s", test_sts_endpoint_url, body); + grpc_uri* url = grpc_uri_parse(get_url_equivalent, false); + GPR_ASSERT(strcmp(grpc_uri_get_query_arg(url, "resource"), "resource") == 0); + GPR_ASSERT(strcmp(grpc_uri_get_query_arg(url, "audience"), "audience") == 0); + GPR_ASSERT(strcmp(grpc_uri_get_query_arg(url, "scope"), "scope") == 0); + GPR_ASSERT(strcmp(grpc_uri_get_query_arg(url, "requested_token_type"), + "requested_token_type") == 0); + GPR_ASSERT(strcmp(grpc_uri_get_query_arg(url, "subject_token"), + test_signed_jwt) == 0); + GPR_ASSERT(strcmp(grpc_uri_get_query_arg(url, "subject_token_type"), + test_signed_jwt_token_type) == 0); + GPR_ASSERT(grpc_uri_get_query_arg(url, "actor_token") == nullptr); + GPR_ASSERT(grpc_uri_get_query_arg(url, "actor_token_type") == nullptr); + grpc_uri_destroy(url); + gpr_free(get_url_equivalent); + + // Check the rest of the request. + GPR_ASSERT(strcmp(request->host, "foo.com:5555") == 0); + GPR_ASSERT(strcmp(request->http.path, "/v1/token-exchange") == 0); + GPR_ASSERT(request->http.hdr_count == 1); + GPR_ASSERT(strcmp(request->http.hdrs[0].key, "Content-Type") == 0); + GPR_ASSERT(strcmp(request->http.hdrs[0].value, + "application/x-www-form-urlencoded") == 0); +} + +static int sts_token_httpcli_post_success(const grpc_httpcli_request* request, + const char* body, size_t body_size, + grpc_millis deadline, + grpc_closure* on_done, + grpc_httpcli_response* response) { + validate_sts_token_http_request(request, body, body_size); + *response = http_response(200, valid_sts_json_response); + GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE); + return 1; +} + +static char* write_tmp_jwt_file(void) { + char* path; + FILE* tmp = gpr_tmpfile(test_signed_jwt_path_prefix, &path); + GPR_ASSERT(path != nullptr); + GPR_ASSERT(tmp != nullptr); + size_t jwt_length = strlen(test_signed_jwt); + GPR_ASSERT(fwrite(test_signed_jwt, 1, jwt_length, tmp) == jwt_length); + fclose(tmp); + return path; +} + +static void test_sts_creds_success(void) { + grpc_core::ExecCtx exec_ctx; + expected_md emd[] = { + {"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}}; + grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, + nullptr, nullptr}; + char* test_signed_jwt_path = write_tmp_jwt_file(); + grpc_sts_credentials_options valid_options = { + test_sts_endpoint_url, // sts_endpoint_url + "resource", // resource + "audience", // audience + "scope", // scope + "requested_token_type", // requested_token_type + test_signed_jwt_path, // subject_token_path + test_signed_jwt_token_type, // subject_token_type + nullptr, // actor_token_path + nullptr // actor_token_type + }; + grpc_call_credentials* creds = + grpc_sts_credentials_create(&valid_options, nullptr); + + /* First request: http put should be called. */ + request_metadata_state* state = + make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd)); + grpc_httpcli_set_override(httpcli_get_should_not_be_called, + sts_token_httpcli_post_success); + run_request_metadata_test(creds, auth_md_ctx, state); + grpc_core::ExecCtx::Get()->Flush(); + + /* Second request: the cached token should be served directly. */ + state = + make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd)); + grpc_httpcli_set_override(httpcli_get_should_not_be_called, + httpcli_post_should_not_be_called); + run_request_metadata_test(creds, auth_md_ctx, state); + grpc_core::ExecCtx::Get()->Flush(); + + creds->Unref(); + grpc_httpcli_set_override(nullptr, nullptr); + gpr_free(test_signed_jwt_path); +} + +static void test_sts_creds_load_token_failure(void) { + grpc_core::ExecCtx exec_ctx; + request_metadata_state* state = make_request_metadata_state( + GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "Error occurred when fetching oauth2 token."), + nullptr, 0); + grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, + nullptr, nullptr}; + char* test_signed_jwt_path = write_tmp_jwt_file(); + grpc_sts_credentials_options options = { + test_sts_endpoint_url, // sts_endpoint_url + "resource", // resource + "audience", // audience + "scope", // scope + "requested_token_type", // requested_token_type + "invalid_path", // subject_token_path + test_signed_jwt_token_type, // subject_token_type + nullptr, // actor_token_path + nullptr // actor_token_type + }; + grpc_call_credentials* creds = grpc_sts_credentials_create(&options, nullptr); + grpc_httpcli_set_override(httpcli_get_should_not_be_called, + httpcli_post_should_not_be_called); + run_request_metadata_test(creds, auth_md_ctx, state); + creds->Unref(); + grpc_httpcli_set_override(nullptr, nullptr); + gpr_free(test_signed_jwt_path); +} + +static void test_sts_creds_http_failure(void) { + grpc_core::ExecCtx exec_ctx; + request_metadata_state* state = make_request_metadata_state( + GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "Error occurred when fetching oauth2 token."), + nullptr, 0); + grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, + nullptr, nullptr}; + char* test_signed_jwt_path = write_tmp_jwt_file(); + grpc_sts_credentials_options valid_options = { + test_sts_endpoint_url, // sts_endpoint_url + "resource", // resource + "audience", // audience + "scope", // scope + "requested_token_type", // requested_token_type + test_signed_jwt_path, // subject_token_path + test_signed_jwt_token_type, // subject_token_type + nullptr, // actor_token_path + nullptr // actor_token_type + }; + grpc_call_credentials* creds = + grpc_sts_credentials_create(&valid_options, nullptr); + grpc_httpcli_set_override(httpcli_get_should_not_be_called, + token_httpcli_post_failure); + run_request_metadata_test(creds, auth_md_ctx, state); + creds->Unref(); + grpc_httpcli_set_override(nullptr, nullptr); + gpr_free(test_signed_jwt_path); +} + static void validate_jwt_encode_and_sign_params( const grpc_auth_json_key* json_key, const char* scope, gpr_timespec token_lifetime) { @@ -1288,6 +1572,11 @@ int main(int argc, char** argv) { test_compute_engine_creds_failure(); test_refresh_token_creds_success(); test_refresh_token_creds_failure(); + test_valid_sts_creds_options(); + test_invalid_sts_creds_options(); + test_sts_creds_success(); + test_sts_creds_load_token_failure(); + test_sts_creds_http_failure(); test_jwt_creds_lifetime(); test_jwt_creds_success(); test_jwt_creds_signing_failure(); diff --git a/test/core/security/fetch_oauth2.cc b/test/core/security/fetch_oauth2.cc index 82efe682be0..d404368b8b9 100644 --- a/test/core/security/fetch_oauth2.cc +++ b/test/core/security/fetch_oauth2.cc @@ -26,33 +26,82 @@ #include #include +#include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/credentials/credentials.h" +#include "src/core/lib/security/util/json_util.h" #include "test/core/security/oauth2_utils.h" #include "test/core/util/cmdline.h" +static grpc_sts_credentials_options sts_options_from_json(grpc_json* json) { + grpc_sts_credentials_options options; + memset(&options, 0, sizeof(options)); + grpc_error* error = GRPC_ERROR_NONE; + options.sts_endpoint_url = + grpc_json_get_string_property(json, "sts_endpoint_url", &error); + GRPC_LOG_IF_ERROR("STS credentials parsing", error); + options.resource = grpc_json_get_string_property(json, "resource", nullptr); + options.audience = grpc_json_get_string_property(json, "audience", nullptr); + options.scope = grpc_json_get_string_property(json, "scope", nullptr); + options.requested_token_type = + grpc_json_get_string_property(json, "requested_token_type", nullptr); + options.subject_token_path = + grpc_json_get_string_property(json, "subject_token_path", &error); + GRPC_LOG_IF_ERROR("STS credentials parsing", error); + options.subject_token_type = + grpc_json_get_string_property(json, "subject_token_type", &error); + GRPC_LOG_IF_ERROR("STS credentials parsing", error); + options.actor_token_path = + grpc_json_get_string_property(json, "actor_token_path", nullptr); + options.actor_token_type = + grpc_json_get_string_property(json, "actor_token_type", nullptr); + return options; +} + +static grpc_call_credentials* create_sts_creds(const char* json_file_path) { + grpc_slice sts_options_slice; + GPR_ASSERT(GRPC_LOG_IF_ERROR( + "load_file", grpc_load_file(json_file_path, 1, &sts_options_slice))); + grpc_json* json = grpc_json_parse_string( + reinterpret_cast(GRPC_SLICE_START_PTR(sts_options_slice))); + if (json == nullptr) { + gpr_log(GPR_ERROR, "Invalid json"); + return nullptr; + } + grpc_sts_credentials_options options = sts_options_from_json(json); + grpc_call_credentials* result = + grpc_sts_credentials_create(&options, nullptr); + grpc_json_destroy(json); + gpr_slice_unref(sts_options_slice); + return result; +} + static grpc_call_credentials* create_refresh_token_creds( const char* json_refresh_token_file_path) { grpc_slice refresh_token; GPR_ASSERT(GRPC_LOG_IF_ERROR( "load_file", grpc_load_file(json_refresh_token_file_path, 1, &refresh_token))); - return grpc_google_refresh_token_credentials_create( + grpc_call_credentials* result = grpc_google_refresh_token_credentials_create( reinterpret_cast GRPC_SLICE_START_PTR(refresh_token), nullptr); + gpr_slice_unref(refresh_token); + return result; } int main(int argc, char** argv) { grpc_call_credentials* creds = nullptr; - char* json_key_file_path = nullptr; + const char* json_sts_options_file_path = nullptr; const char* json_refresh_token_file_path = nullptr; char* token = nullptr; int use_gce = 0; - char* scope = nullptr; gpr_cmdline* cl = gpr_cmdline_create("fetch_oauth2"); gpr_cmdline_add_string(cl, "json_refresh_token", "File path of the json refresh token.", &json_refresh_token_file_path); + gpr_cmdline_add_string(cl, "json_sts_options", + "File path of the json sts options.", + &json_sts_options_file_path); gpr_cmdline_add_flag( cl, "gce", "Get a token from the GCE metadata server (only works in GCE).", @@ -61,18 +110,20 @@ int main(int argc, char** argv) { grpc_init(); - if (json_key_file_path != nullptr && + if (json_sts_options_file_path != nullptr && json_refresh_token_file_path != nullptr) { - gpr_log(GPR_ERROR, - "--json_key and --json_refresh_token are mutually exclusive."); + gpr_log( + GPR_ERROR, + "--json_sts_options and --json_refresh_token are mutually exclusive."); exit(1); } if (use_gce) { - if (json_key_file_path != nullptr || scope != nullptr) { + if (json_sts_options_file_path != nullptr || + json_refresh_token_file_path != nullptr) { gpr_log(GPR_INFO, - "Ignoring json key and scope to get a token from the GCE " - "metadata server."); + "Ignoring json refresh token or sts options to get a token from " + "the GCE metadata server."); } creds = grpc_google_compute_engine_credentials_create(nullptr); if (creds == nullptr) { @@ -88,8 +139,19 @@ int main(int argc, char** argv) { json_refresh_token_file_path); exit(1); } + } else if (json_sts_options_file_path != nullptr) { + creds = create_sts_creds(json_sts_options_file_path); + if (creds == nullptr) { + gpr_log(GPR_ERROR, + "Could not create sts creds. %s does probably not contain a " + "valid json for sts options.", + json_sts_options_file_path); + exit(1); + } } else { - gpr_log(GPR_ERROR, "Missing --gce or --json_refresh_token option."); + gpr_log( + GPR_ERROR, + "Missing --gce, --json_sts_options, or --json_refresh_token option."); exit(1); } GPR_ASSERT(creds != nullptr); diff --git a/test/core/security/oauth2_utils.cc b/test/core/security/oauth2_utils.cc index c9e205ab743..b24e7c180e1 100644 --- a/test/core/security/oauth2_utils.cc +++ b/test/core/security/oauth2_utils.cc @@ -63,14 +63,17 @@ static void on_oauth2_response(void* arg, grpc_error* error) { gpr_mu_unlock(request->mu); } -static void do_nothing(void* unused, grpc_error* error) {} +static void destroy_after_shutdown(void* pollset, grpc_error* error) { + grpc_pollset_destroy(reinterpret_cast(pollset)); + gpr_free(pollset); +} char* grpc_test_fetch_oauth2_token_with_credentials( grpc_call_credentials* creds) { oauth2_request request; memset(&request, 0, sizeof(request)); grpc_core::ExecCtx exec_ctx; - grpc_closure do_nothing_closure; + grpc_closure destroy_after_shutdown_closure; grpc_auth_metadata_context null_ctx = {"", "", nullptr, nullptr}; grpc_pollset* pollset = @@ -79,8 +82,8 @@ char* grpc_test_fetch_oauth2_token_with_credentials( request.pops = grpc_polling_entity_create_from_pollset(pollset); request.is_done = false; - GRPC_CLOSURE_INIT(&do_nothing_closure, do_nothing, nullptr, - grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_INIT(&destroy_after_shutdown_closure, destroy_after_shutdown, + pollset, grpc_schedule_on_exec_ctx); GRPC_CLOSURE_INIT(&request.closure, on_oauth2_response, &request, grpc_schedule_on_exec_ctx); @@ -107,8 +110,6 @@ char* grpc_test_fetch_oauth2_token_with_credentials( gpr_mu_unlock(request.mu); grpc_pollset_shutdown(grpc_polling_entity_pollset(&request.pops), - &do_nothing_closure); - - gpr_free(grpc_polling_entity_pollset(&request.pops)); + &destroy_after_shutdown_closure); return request.token; } diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c index 3aaa1e709ee..e537e482936 100644 --- a/test/core/surface/public_headers_must_be_c89.c +++ b/test/core/surface/public_headers_must_be_c89.c @@ -171,6 +171,7 @@ int main(int argc, char **argv) { printf("%lx", (unsigned long) grpc_google_refresh_token_credentials_create); printf("%lx", (unsigned long) grpc_access_token_credentials_create); printf("%lx", (unsigned long) grpc_google_iam_credentials_create); + printf("%lx", (unsigned long) grpc_sts_credentials_create); printf("%lx", (unsigned long) grpc_metadata_credentials_create_from_plugin); printf("%lx", (unsigned long) grpc_secure_channel_create); printf("%lx", (unsigned long) grpc_server_credentials_release); From 915e97b115cf5d339af2f6a1b5255f61de1b89c3 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 26 Jun 2019 13:16:02 -0700 Subject: [PATCH 0724/1555] Fix main thread starvation issues --- examples/python/cancellation/README.md | 76 +++---------------- examples/python/cancellation/client.py | 49 ++---------- examples/python/cancellation/server.py | 2 +- .../test/_cancellation_example_test.py | 2 +- 4 files changed, 21 insertions(+), 108 deletions(-) diff --git a/examples/python/cancellation/README.md b/examples/python/cancellation/README.md index ed85fbe53cb..26ef61c329f 100644 --- a/examples/python/cancellation/README.md +++ b/examples/python/cancellation/README.md @@ -40,30 +40,16 @@ stub = hash_name_pb2_grpc.HashFinderStub(channel) future = stub.Find.future(hash_name_pb2.HashNameRequest(desired_name=name)) def cancel_request(unused_signum, unused_frame): future.cancel() + sys.exit(0) signal.signal(signal.SIGINT, cancel_request) + +result = future.result() +print(result) ``` -It's also important that you not block indefinitely on the RPC. Otherwise, the -signal handler will never have a chance to run. - -```python -while True: - try: - result = future.result(timeout=_TIMEOUT_SECONDS) - except grpc.FutureTimeoutError: - continue - except grpc.FutureCancelledError: - break - print("Got response: \n{}".format(result)) - break -``` - -Here, we repeatedly block on a result for up to `_TIMEOUT_SECONDS`. Doing so -gives the signal handlers a chance to run. In the case that our timeout -was reached, we simply continue on in the loop. In the case that the RPC was -cancelled (by our user's ctrl+c), we break out of the loop cleanly. Finally, if -we received the result of the RPC, we print it out for the user and exit the -loop. +We also call `sys.exit(0)` to terminate the process. If we do not do this, then +`future.result()` with throw an `RpcError`. Alternatively, you may catch this +exception. ##### Cancelling a Server-Side Streaming RPC from the Client @@ -78,53 +64,15 @@ stub = hash_name_pb2_grpc.HashFinderStub(channel) result_generator = stub.FindRange(hash_name_pb2.HashNameRequest(desired_name=name)) def cancel_request(unused_signum, unused_frame): result_generator.cancel() + sys.exit(0) signal.signal(signal.SIGINT, cancel_request) +for result in result_generator: + print(result) ``` -However, the streaming case is complicated by the fact that there is no way to -propagate a timeout to Python generators. As a result, simply iterating over the -results of the RPC can block indefinitely and the signal handler may never run. -Instead, we iterate over the generator on another thread and retrieve the -results on the main thread with a synchronized `Queue`. +We also call `sys.exit(0)` here to terminate the process. Alternatively, you may +catch the `RpcError` raised by the for loop upon cancellation. -```python -result_queue = Queue() -def iterate_responses(result_generator, result_queue): - try: - for result in result_generator: - result_queue.put(result) - except grpc.RpcError as rpc_error: - if rpc_error.code() != grpc.StatusCode.CANCELLED: - result_queue.put(None) - raise rpc_error - result_queue.put(None) - print("RPC complete") -response_thread = threading.Thread(target=iterate_responses, args=(result_generator, result_queue)) -response_thread.daemon = True -response_thread.start() -``` - -While this thread iterating over the results may block indefinitely, we can -structure the code running on our main thread in such a way that signal handlers -are guaranteed to be run at least every `_TIMEOUT_SECONDS` seconds. - -```python -while result_generator.running(): - try: - result = result_queue.get(timeout=_TIMEOUT_SECONDS) - except QueueEmpty: - continue - if result is None: - break - print("Got result: {}".format(result)) -``` - -Similarly to the unary example above, we continue in a loop waiting for results, -taking care to block for intervals of `_TIMEOUT_SECONDS` at the longest. -Finally, we use `None` as a sentinel value to signal the end of the stream. - -Using this scheme, our process responds nicely to `SIGINT`s while also -explicitly cancelling its RPCs. #### Cancellation on the Server Side diff --git a/examples/python/cancellation/client.py b/examples/python/cancellation/client.py index 2661efc196f..491dffa170b 100644 --- a/examples/python/cancellation/client.py +++ b/examples/python/cancellation/client.py @@ -27,6 +27,8 @@ from six.moves.queue import Queue from six.moves.queue import Empty as QueueEmpty import grpc +import os +import sys from examples.python.cancellation import hash_name_pb2 from examples.python.cancellation import hash_name_pb2_grpc @@ -34,8 +36,6 @@ from examples.python.cancellation import hash_name_pb2_grpc _DESCRIPTION = "A client for finding hashes similar to names." _LOGGER = logging.getLogger(__name__) -_TIMEOUT_SECONDS = 0.05 - def run_unary_client(server_target, name, ideal_distance): with grpc.insecure_channel(server_target) as channel: @@ -47,21 +47,11 @@ def run_unary_client(server_target, name, ideal_distance): def cancel_request(unused_signum, unused_frame): future.cancel() + sys.exit(0) signal.signal(signal.SIGINT, cancel_request) - while True: - try: - result = future.result(timeout=_TIMEOUT_SECONDS) - except grpc.FutureTimeoutError: - continue - except grpc.FutureCancelledError: - break - except grpc.RpcError as rpc_error: - if rpc_error.code() == grpc.StatusCode.CANCELLED: - break - raise rpc_error - print(result) - break + result = future.result() + print(result) def run_streaming_client(server_target, name, ideal_distance, @@ -77,35 +67,10 @@ def run_streaming_client(server_target, name, ideal_distance, def cancel_request(unused_signum, unused_frame): result_generator.cancel() + sys.exit(0) signal.signal(signal.SIGINT, cancel_request) - result_queue = Queue() - - def iterate_responses(result_generator, result_queue): - try: - for result in result_generator: - result_queue.put(result) - except grpc.RpcError as rpc_error: - if rpc_error.code() != grpc.StatusCode.CANCELLED: - result_queue.put(None) - raise rpc_error - # Enqueue a sentinel to signal the end of the stream. - result_queue.put(None) - - # TODO(https://github.com/grpc/grpc/issues/19464): Do everything on the - # main thread. - response_thread = threading.Thread( - target=iterate_responses, args=(result_generator, result_queue)) - response_thread.daemon = True - response_thread.start() - - while result_generator.running(): - try: - result = result_queue.get(timeout=_TIMEOUT_SECONDS) - except QueueEmpty: - continue - if result is None: - break + for result in result_generator: print(result) diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index 2c715565031..25ce494ee39 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -117,7 +117,7 @@ def main(): parser.add_argument( '--maximum-hashes', type=int, - default=10000, + default=1000000, nargs='?', help='The maximum number of hashes to search before cancelling.') args = parser.parse_args() diff --git a/examples/python/cancellation/test/_cancellation_example_test.py b/examples/python/cancellation/test/_cancellation_example_test.py index 45b0ccb400a..2301cc63c67 100644 --- a/examples/python/cancellation/test/_cancellation_example_test.py +++ b/examples/python/cancellation/test/_cancellation_example_test.py @@ -74,7 +74,7 @@ class CancellationExampleTest(unittest.TestCase): client_process1 = _start_client(test_port, 'aaaaaaaaaa', 0) client_process1.send_signal(signal.SIGINT) client_process1.wait() - client_process2 = _start_client(test_port, 'aaaaaaaaaa', 0) + client_process2 = _start_client(test_port, 'aa', 0) client_return_code = client_process2.wait() self.assertEqual(0, client_return_code) self.assertIsNone(server_process.poll()) From 80c177d4c40ef85eb8ec37f9d4bfa030361958e1 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Wed, 26 Jun 2019 16:22:13 -0400 Subject: [PATCH 0725/1555] Revert "Introduce string_view and use it for gpr_split_host_port." --- BUILD | 8 +- BUILD.gn | 8 +- CMakeLists.txt | 44 +---- Makefile | 54 +----- build.yaml | 20 +-- config.m4 | 2 +- config.w32 | 2 +- gRPC-C++.podspec | 6 +- gRPC-Core.podspec | 8 +- grpc.gemspec | 5 +- grpc.gyp | 2 +- package.xml | 5 +- .../ext/filters/client_channel/http_proxy.cc | 19 +- .../client_channel/lb_policy/grpclb/grpclb.cc | 1 + .../client_channel/lb_policy/xds/xds.cc | 1 + .../filters/client_channel/parse_address.cc | 55 +++--- .../resolver/dns/c_ares/dns_resolver_ares.cc | 1 + .../resolver/dns/c_ares/grpc_ares_wrapper.cc | 95 +++++----- .../dns/c_ares/grpc_ares_wrapper_libuv.cc | 1 + .../dns/c_ares/grpc_ares_wrapper_windows.cc | 1 + .../resolver/dns/native/dns_resolver.cc | 1 + .../resolver/fake/fake_resolver.cc | 1 + .../resolver/sockaddr/sockaddr_resolver.cc | 1 + .../transport/chttp2/server/chttp2_server.cc | 1 + .../transport/chttp2/transport/frame_data.cc | 8 +- .../cronet/transport/cronet_transport.cc | 1 + src/core/lib/channel/channelz.cc | 15 +- src/core/lib/gpr/host_port.cc | 98 +++++++++++ src/core/lib/{gprpp => gpr}/host_port.h | 38 ++-- src/core/lib/gpr/string.cc | 9 +- src/core/lib/gpr/string.h | 1 - src/core/lib/gprpp/host_port.cc | 97 ----------- src/core/lib/gprpp/string_view.h | 143 --------------- .../lib/http/httpcli_security_connector.cc | 4 +- src/core/lib/iomgr/resolve_address_custom.cc | 35 ++-- src/core/lib/iomgr/resolve_address_posix.cc | 18 +- src/core/lib/iomgr/resolve_address_windows.cc | 14 +- src/core/lib/iomgr/sockaddr_utils.cc | 8 +- .../lib/iomgr/socket_utils_common_posix.cc | 1 + src/core/lib/iomgr/tcp_client_cfstream.cc | 13 +- .../alts/alts_security_connector.cc | 5 +- .../fake/fake_security_connector.cc | 46 ++--- .../local/local_security_connector.cc | 5 +- .../security_connector/security_connector.cc | 2 +- .../security_connector/security_connector.h | 2 +- .../ssl/ssl_security_connector.cc | 38 ++-- .../security/security_connector/ssl_utils.cc | 57 +++--- .../security/security_connector/ssl_utils.h | 19 +- .../tls/spiffe_security_connector.cc | 36 ++-- .../tls/spiffe_security_connector.h | 7 +- .../security/transport/client_auth_filter.cc | 3 +- .../alts/handshaker/alts_tsi_handshaker.cc | 1 + src/core/tsi/ssl_transport_security.cc | 78 +++++---- src/core/tsi/ssl_transport_security.h | 3 +- .../CronetTests/CoreCronetEnd2EndTests.mm | 21 +-- .../tests/CronetTests/CronetUnitTests.mm | 14 +- src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/bad_ssl/bad_ssl_test.cc | 8 +- .../parse_address_with_named_scope_id_test.cc | 17 +- test/core/end2end/bad_server_response_test.cc | 11 +- test/core/end2end/connection_refused_test.cc | 12 +- test/core/end2end/dualstack_socket_test.cc | 25 +-- test/core/end2end/fixtures/h2_census.cc | 22 +-- test/core/end2end/fixtures/h2_compress.cc | 33 ++-- test/core/end2end/fixtures/h2_fakesec.cc | 23 +-- test/core/end2end/fixtures/h2_full+pipe.cc | 21 +-- test/core/end2end/fixtures/h2_full+trace.cc | 21 +-- .../end2end/fixtures/h2_full+workarounds.cc | 24 +-- test/core/end2end/fixtures/h2_full.cc | 21 +-- test/core/end2end/fixtures/h2_http_proxy.cc | 27 +-- test/core/end2end/fixtures/h2_local_ipv4.cc | 4 +- test/core/end2end/fixtures/h2_local_ipv6.cc | 4 +- test/core/end2end/fixtures/h2_local_uds.cc | 8 +- test/core/end2end/fixtures/h2_oauth2.cc | 25 +-- test/core/end2end/fixtures/h2_proxy.cc | 1 + test/core/end2end/fixtures/h2_spiffe.cc | 25 ++- test/core/end2end/fixtures/h2_ssl.cc | 22 +-- .../end2end/fixtures/h2_ssl_cred_reload.cc | 24 +-- test/core/end2end/fixtures/h2_ssl_proxy.cc | 1 + test/core/end2end/fixtures/h2_uds.cc | 1 + .../end2end/fixtures/http_proxy_fixture.cc | 14 +- test/core/end2end/fixtures/inproc.cc | 1 + test/core/end2end/fixtures/local_util.cc | 15 +- test/core/end2end/fixtures/local_util.h | 6 +- test/core/end2end/fixtures/proxy.cc | 29 ++-- test/core/end2end/h2_ssl_cert_test.cc | 22 +-- .../core/end2end/h2_ssl_session_reuse_test.cc | 15 +- .../end2end/invalid_call_argument_test.cc | 15 +- test/core/fling/fling_stream_test.cc | 11 +- test/core/fling/fling_test.cc | 12 +- test/core/fling/server.cc | 12 +- test/core/gpr/BUILD | 10 ++ test/core/{gprpp => gpr}/host_port_test.cc | 11 +- test/core/gprpp/BUILD | 23 --- test/core/gprpp/string_view_test.cc | 163 ------------------ test/core/memory_usage/memory_usage_test.cc | 11 +- test/core/memory_usage/server.cc | 12 +- ...num_external_connectivity_watchers_test.cc | 25 +-- .../surface/sequential_connectivity_test.cc | 11 +- test/core/surface/server_chttp2_test.cc | 12 +- test/core/surface/server_test.cc | 14 +- test/core/util/reconnect_server.cc | 1 + test/core/util/test_tcp_server.cc | 1 + test/cpp/interop/interop_test.cc | 1 + test/cpp/naming/address_sorting_test.cc | 18 +- test/cpp/naming/cancel_ares_query_test.cc | 1 + test/cpp/naming/resolver_component_test.cc | 16 +- test/cpp/qps/client_sync.cc | 1 + test/cpp/qps/driver.cc | 22 ++- test/cpp/qps/qps_worker.cc | 9 +- test/cpp/qps/server_async.cc | 9 +- test/cpp/qps/server_callback.cc | 9 +- test/cpp/qps/server_sync.cc | 9 +- tools/doxygen/Doxyfile.c++.internal | 3 +- tools/doxygen/Doxyfile.core.internal | 5 +- .../generated/sources_and_headers.json | 28 +-- tools/run_tests/generated/tests.json | 24 --- 117 files changed, 883 insertions(+), 1282 deletions(-) create mode 100644 src/core/lib/gpr/host_port.cc rename src/core/lib/{gprpp => gpr}/host_port.h (51%) delete mode 100644 src/core/lib/gprpp/host_port.cc delete mode 100644 src/core/lib/gprpp/string_view.h rename test/core/{gprpp => gpr}/host_port_test.cc (86%) delete mode 100644 test/core/gprpp/string_view_test.cc diff --git a/BUILD b/BUILD index 821c3824948..8fd52808400 100644 --- a/BUILD +++ b/BUILD @@ -558,6 +558,7 @@ grpc_cc_library( "src/core/lib/gpr/env_linux.cc", "src/core/lib/gpr/env_posix.cc", "src/core/lib/gpr/env_windows.cc", + "src/core/lib/gpr/host_port.cc", "src/core/lib/gpr/log.cc", "src/core/lib/gpr/log_android.cc", "src/core/lib/gpr/log_linux.cc", @@ -584,7 +585,6 @@ grpc_cc_library( "src/core/lib/gprpp/arena.cc", "src/core/lib/gprpp/fork.cc", "src/core/lib/gprpp/global_config_env.cc", - "src/core/lib/gprpp/host_port.cc", "src/core/lib/gprpp/thd_posix.cc", "src/core/lib/gprpp/thd_windows.cc", "src/core/lib/profiling/basic_timers.cc", @@ -594,6 +594,7 @@ grpc_cc_library( "src/core/lib/gpr/alloc.h", "src/core/lib/gpr/arena.h", "src/core/lib/gpr/env.h", + "src/core/lib/gpr/host_port.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", "src/core/lib/gpr/spinlock.h", @@ -610,16 +611,14 @@ grpc_cc_library( "src/core/lib/gprpp/arena.h", "src/core/lib/gprpp/atomic.h", "src/core/lib/gprpp/fork.h", - "src/core/lib/gprpp/global_config.h", "src/core/lib/gprpp/global_config_custom.h", "src/core/lib/gprpp/global_config_env.h", "src/core/lib/gprpp/global_config_generic.h", - "src/core/lib/gprpp/host_port.h", + "src/core/lib/gprpp/global_config.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", "src/core/lib/gprpp/pair.h", - "src/core/lib/gprpp/string_view.h", "src/core/lib/gprpp/sync.h", "src/core/lib/gprpp/thd.h", "src/core/lib/profiling/timers.h", @@ -628,7 +627,6 @@ grpc_cc_library( public_hdrs = GPR_PUBLIC_HDRS, deps = [ "gpr_codegen", - "grpc_codegen", ], ) diff --git a/BUILD.gn b/BUILD.gn index 9ae5b1ed22b..e5396f51426 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -141,6 +141,8 @@ config("grpc_config") { "src/core/lib/gpr/env_linux.cc", "src/core/lib/gpr/env_posix.cc", "src/core/lib/gpr/env_windows.cc", + "src/core/lib/gpr/host_port.cc", + "src/core/lib/gpr/host_port.h", "src/core/lib/gpr/log.cc", "src/core/lib/gpr/log_android.cc", "src/core/lib/gpr/log_linux.cc", @@ -187,8 +189,6 @@ config("grpc_config") { "src/core/lib/gprpp/global_config_env.cc", "src/core/lib/gprpp/global_config_env.h", "src/core/lib/gprpp/global_config_generic.h", - "src/core/lib/gprpp/host_port.cc", - "src/core/lib/gprpp/host_port.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", @@ -480,7 +480,6 @@ config("grpc_config") { "src/core/lib/gprpp/orphanable.h", "src/core/lib/gprpp/ref_counted.h", "src/core/lib/gprpp/ref_counted_ptr.h", - "src/core/lib/gprpp/string_view.h", "src/core/lib/http/format_request.cc", "src/core/lib/http/format_request.h", "src/core/lib/http/httpcli.cc", @@ -1172,6 +1171,7 @@ config("grpc_config") { "src/core/lib/gpr/alloc.h", "src/core/lib/gpr/arena.h", "src/core/lib/gpr/env.h", + "src/core/lib/gpr/host_port.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", "src/core/lib/gpr/spinlock.h", @@ -1193,7 +1193,6 @@ config("grpc_config") { "src/core/lib/gprpp/global_config_custom.h", "src/core/lib/gprpp/global_config_env.h", "src/core/lib/gprpp/global_config_generic.h", - "src/core/lib/gprpp/host_port.h", "src/core/lib/gprpp/inlined_vector.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", @@ -1203,7 +1202,6 @@ config("grpc_config") { "src/core/lib/gprpp/pair.h", "src/core/lib/gprpp/ref_counted.h", "src/core/lib/gprpp/ref_counted_ptr.h", - "src/core/lib/gprpp/string_view.h", "src/core/lib/gprpp/sync.h", "src/core/lib/gprpp/thd.h", "src/core/lib/http/format_request.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 19c8d44b05d..a34f9265256 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -713,7 +713,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx streaming_throughput_test) endif() add_dependencies(buildtests_cxx stress_test) -add_dependencies(buildtests_cxx string_view_test) add_dependencies(buildtests_cxx thread_manager_test) add_dependencies(buildtests_cxx thread_stress_test) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) @@ -862,6 +861,7 @@ add_library(gpr src/core/lib/gpr/env_linux.cc src/core/lib/gpr/env_posix.cc src/core/lib/gpr/env_windows.cc + src/core/lib/gpr/host_port.cc src/core/lib/gpr/log.cc src/core/lib/gpr/log_android.cc src/core/lib/gpr/log_linux.cc @@ -888,7 +888,6 @@ add_library(gpr src/core/lib/gprpp/arena.cc src/core/lib/gprpp/fork.cc src/core/lib/gprpp/global_config_env.cc - src/core/lib/gprpp/host_port.cc src/core/lib/gprpp/thd_posix.cc src/core/lib/gprpp/thd_windows.cc src/core/lib/profiling/basic_timers.cc @@ -7507,7 +7506,7 @@ endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(gpr_host_port_test - test/core/gprpp/host_port_test.cc + test/core/gpr/host_port_test.cc ) @@ -16640,45 +16639,6 @@ target_link_libraries(stress_test ) -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) - -add_executable(string_view_test - test/core/gprpp/string_view_test.cc - third_party/googletest/googletest/src/gtest-all.cc - third_party/googletest/googlemock/src/gmock-all.cc -) - - -target_include_directories(string_view_test - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} - PRIVATE third_party/googletest/googletest/include - PRIVATE third_party/googletest/googletest - PRIVATE third_party/googletest/googlemock/include - PRIVATE third_party/googletest/googlemock - PRIVATE ${_gRPC_PROTO_GENS_DIR} -) - -target_link_libraries(string_view_test - ${_gRPC_PROTOBUF_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - grpc++ - grpc - gpr - ${_gRPC_GFLAGS_LIBRARIES} -) - - endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index 2d28e7b5656..9930fc35a25 100644 --- a/Makefile +++ b/Makefile @@ -1278,7 +1278,6 @@ status_metadata_test: $(BINDIR)/$(CONFIG)/status_metadata_test status_util_test: $(BINDIR)/$(CONFIG)/status_util_test streaming_throughput_test: $(BINDIR)/$(CONFIG)/streaming_throughput_test stress_test: $(BINDIR)/$(CONFIG)/stress_test -string_view_test: $(BINDIR)/$(CONFIG)/string_view_test thread_manager_test: $(BINDIR)/$(CONFIG)/thread_manager_test thread_stress_test: $(BINDIR)/$(CONFIG)/thread_stress_test time_change_test: $(BINDIR)/$(CONFIG)/time_change_test @@ -1745,7 +1744,6 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/status_util_test \ $(BINDIR)/$(CONFIG)/streaming_throughput_test \ $(BINDIR)/$(CONFIG)/stress_test \ - $(BINDIR)/$(CONFIG)/string_view_test \ $(BINDIR)/$(CONFIG)/thread_manager_test \ $(BINDIR)/$(CONFIG)/thread_stress_test \ $(BINDIR)/$(CONFIG)/time_change_test \ @@ -1909,7 +1907,6 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/status_util_test \ $(BINDIR)/$(CONFIG)/streaming_throughput_test \ $(BINDIR)/$(CONFIG)/stress_test \ - $(BINDIR)/$(CONFIG)/string_view_test \ $(BINDIR)/$(CONFIG)/thread_manager_test \ $(BINDIR)/$(CONFIG)/thread_stress_test \ $(BINDIR)/$(CONFIG)/time_change_test \ @@ -2436,8 +2433,6 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/status_util_test || ( echo test status_util_test failed ; exit 1 ) $(E) "[RUN] Testing streaming_throughput_test" $(Q) $(BINDIR)/$(CONFIG)/streaming_throughput_test || ( echo test streaming_throughput_test failed ; exit 1 ) - $(E) "[RUN] Testing string_view_test" - $(Q) $(BINDIR)/$(CONFIG)/string_view_test || ( echo test string_view_test failed ; exit 1 ) $(E) "[RUN] Testing thread_manager_test" $(Q) $(BINDIR)/$(CONFIG)/thread_manager_test || ( echo test thread_manager_test failed ; exit 1 ) $(E) "[RUN] Testing thread_stress_test" @@ -3384,6 +3379,7 @@ LIBGPR_SRC = \ src/core/lib/gpr/env_linux.cc \ src/core/lib/gpr/env_posix.cc \ src/core/lib/gpr/env_windows.cc \ + src/core/lib/gpr/host_port.cc \ src/core/lib/gpr/log.cc \ src/core/lib/gpr/log_android.cc \ src/core/lib/gpr/log_linux.cc \ @@ -3410,7 +3406,6 @@ LIBGPR_SRC = \ src/core/lib/gprpp/arena.cc \ src/core/lib/gprpp/fork.cc \ src/core/lib/gprpp/global_config_env.cc \ - src/core/lib/gprpp/host_port.cc \ src/core/lib/gprpp/thd_posix.cc \ src/core/lib/gprpp/thd_windows.cc \ src/core/lib/profiling/basic_timers.cc \ @@ -10223,7 +10218,7 @@ endif GPR_HOST_PORT_TEST_SRC = \ - test/core/gprpp/host_port_test.cc \ + test/core/gpr/host_port_test.cc \ GPR_HOST_PORT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_HOST_PORT_TEST_SRC)))) ifeq ($(NO_SECURE),true) @@ -10243,7 +10238,7 @@ $(BINDIR)/$(CONFIG)/gpr_host_port_test: $(GPR_HOST_PORT_TEST_OBJS) $(LIBDIR)/$(C endif -$(OBJDIR)/$(CONFIG)/test/core/gprpp/host_port_test.o: $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a +$(OBJDIR)/$(CONFIG)/test/core/gpr/host_port_test.o: $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a deps_gpr_host_port_test: $(GPR_HOST_PORT_TEST_OBJS:.o=.dep) @@ -19671,49 +19666,6 @@ $(OBJDIR)/$(CONFIG)/test/cpp/interop/stress_test.o: $(GENDIR)/src/proto/grpc/tes $(OBJDIR)/$(CONFIG)/test/cpp/util/metrics_server.o: $(GENDIR)/src/proto/grpc/testing/empty.pb.cc $(GENDIR)/src/proto/grpc/testing/empty.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/metrics.pb.cc $(GENDIR)/src/proto/grpc/testing/metrics.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/test.pb.cc $(GENDIR)/src/proto/grpc/testing/test.grpc.pb.cc -STRING_VIEW_TEST_SRC = \ - test/core/gprpp/string_view_test.cc \ - -STRING_VIEW_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(STRING_VIEW_TEST_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/string_view_test: openssl_dep_error - -else - - - - -ifeq ($(NO_PROTOBUF),true) - -# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. - -$(BINDIR)/$(CONFIG)/string_view_test: protobuf_dep_error - -else - -$(BINDIR)/$(CONFIG)/string_view_test: $(PROTOBUF_DEP) $(STRING_VIEW_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(STRING_VIEW_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/string_view_test - -endif - -endif - -$(OBJDIR)/$(CONFIG)/test/core/gprpp/string_view_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a - -deps_string_view_test: $(STRING_VIEW_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(STRING_VIEW_TEST_OBJS:.o=.dep) -endif -endif - - THREAD_MANAGER_TEST_SRC = \ test/cpp/thread_manager/thread_manager_test.cc \ diff --git a/build.yaml b/build.yaml index 41c32396a42..dad2146bd1c 100644 --- a/build.yaml +++ b/build.yaml @@ -122,6 +122,7 @@ filegroups: - src/core/lib/gpr/env_linux.cc - src/core/lib/gpr/env_posix.cc - src/core/lib/gpr/env_windows.cc + - src/core/lib/gpr/host_port.cc - src/core/lib/gpr/log.cc - src/core/lib/gpr/log_android.cc - src/core/lib/gpr/log_linux.cc @@ -148,7 +149,6 @@ filegroups: - src/core/lib/gprpp/arena.cc - src/core/lib/gprpp/fork.cc - src/core/lib/gprpp/global_config_env.cc - - src/core/lib/gprpp/host_port.cc - src/core/lib/gprpp/thd_posix.cc - src/core/lib/gprpp/thd_windows.cc - src/core/lib/profiling/basic_timers.cc @@ -178,6 +178,7 @@ filegroups: - src/core/lib/gpr/alloc.h - src/core/lib/gpr/arena.h - src/core/lib/gpr/env.h + - src/core/lib/gpr/host_port.h - src/core/lib/gpr/mpscq.h - src/core/lib/gpr/murmur_hash.h - src/core/lib/gpr/spinlock.h @@ -198,7 +199,6 @@ filegroups: - src/core/lib/gprpp/global_config_custom.h - src/core/lib/gprpp/global_config_env.h - src/core/lib/gprpp/global_config_generic.h - - src/core/lib/gprpp/host_port.h - src/core/lib/gprpp/manual_constructor.h - src/core/lib/gprpp/map.h - src/core/lib/gprpp/memory.h @@ -444,7 +444,6 @@ filegroups: - src/core/lib/gprpp/orphanable.h - src/core/lib/gprpp/ref_counted.h - src/core/lib/gprpp/ref_counted_ptr.h - - src/core/lib/gprpp/string_view.h - src/core/lib/http/format_request.h - src/core/lib/http/httpcli.h - src/core/lib/http/parser.h @@ -2626,7 +2625,7 @@ targets: build: test language: c src: - - test/core/gprpp/host_port_test.cc + - test/core/gpr/host_port_test.cc deps: - gpr - grpc_test_util_unsecure @@ -5761,19 +5760,6 @@ targets: - grpc - gpr - grpc++_test_config -- name: string_view_test - gtest: true - build: test - language: c++ - src: - - test/core/gprpp/string_view_test.cc - deps: - - grpc_test_util - - grpc++ - - grpc - - gpr - uses: - - grpc++_test - name: thread_manager_test build: test language: c++ diff --git a/config.m4 b/config.m4 index 99d49d391b4..bb30be56910 100644 --- a/config.m4 +++ b/config.m4 @@ -53,6 +53,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/gpr/env_linux.cc \ src/core/lib/gpr/env_posix.cc \ src/core/lib/gpr/env_windows.cc \ + src/core/lib/gpr/host_port.cc \ src/core/lib/gpr/log.cc \ src/core/lib/gpr/log_android.cc \ src/core/lib/gpr/log_linux.cc \ @@ -79,7 +80,6 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/gprpp/arena.cc \ src/core/lib/gprpp/fork.cc \ src/core/lib/gprpp/global_config_env.cc \ - src/core/lib/gprpp/host_port.cc \ src/core/lib/gprpp/thd_posix.cc \ src/core/lib/gprpp/thd_windows.cc \ src/core/lib/profiling/basic_timers.cc \ diff --git a/config.w32 b/config.w32 index f6c6b4fde10..c9faa8d9ac8 100644 --- a/config.w32 +++ b/config.w32 @@ -28,6 +28,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\gpr\\env_linux.cc " + "src\\core\\lib\\gpr\\env_posix.cc " + "src\\core\\lib\\gpr\\env_windows.cc " + + "src\\core\\lib\\gpr\\host_port.cc " + "src\\core\\lib\\gpr\\log.cc " + "src\\core\\lib\\gpr\\log_android.cc " + "src\\core\\lib\\gpr\\log_linux.cc " + @@ -54,7 +55,6 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\gprpp\\arena.cc " + "src\\core\\lib\\gprpp\\fork.cc " + "src\\core\\lib\\gprpp\\global_config_env.cc " + - "src\\core\\lib\\gprpp\\host_port.cc " + "src\\core\\lib\\gprpp\\thd_posix.cc " + "src\\core\\lib\\gprpp\\thd_windows.cc " + "src\\core\\lib\\profiling\\basic_timers.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 17b44738cc2..f0a4418b20c 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -261,6 +261,7 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/alloc.h', 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', + 'src/core/lib/gpr/host_port.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', 'src/core/lib/gpr/spinlock.h', @@ -281,7 +282,6 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/global_config_custom.h', 'src/core/lib/gprpp/global_config_env.h', 'src/core/lib/gprpp/global_config_generic.h', - 'src/core/lib/gprpp/host_port.h', 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', @@ -444,7 +444,6 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/orphanable.h', 'src/core/lib/gprpp/ref_counted.h', 'src/core/lib/gprpp/ref_counted_ptr.h', - 'src/core/lib/gprpp/string_view.h', 'src/core/lib/http/format_request.h', 'src/core/lib/http/httpcli.h', 'src/core/lib/http/parser.h', @@ -592,6 +591,7 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/alloc.h', 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', + 'src/core/lib/gpr/host_port.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', 'src/core/lib/gpr/spinlock.h', @@ -612,7 +612,6 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/global_config_custom.h', 'src/core/lib/gprpp/global_config_env.h', 'src/core/lib/gprpp/global_config_generic.h', - 'src/core/lib/gprpp/host_port.h', 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', @@ -649,7 +648,6 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/orphanable.h', 'src/core/lib/gprpp/ref_counted.h', 'src/core/lib/gprpp/ref_counted_ptr.h', - 'src/core/lib/gprpp/string_view.h', 'src/core/lib/http/format_request.h', 'src/core/lib/http/httpcli.h', 'src/core/lib/http/parser.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 6255fdfd0ce..2e34e8d7573 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -191,6 +191,7 @@ Pod::Spec.new do |s| ss.source_files = 'src/core/lib/gpr/alloc.h', 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', + 'src/core/lib/gpr/host_port.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', 'src/core/lib/gpr/spinlock.h', @@ -211,7 +212,6 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/global_config_custom.h', 'src/core/lib/gprpp/global_config_env.h', 'src/core/lib/gprpp/global_config_generic.h', - 'src/core/lib/gprpp/host_port.h', 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', @@ -228,6 +228,7 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/env_linux.cc', 'src/core/lib/gpr/env_posix.cc', 'src/core/lib/gpr/env_windows.cc', + 'src/core/lib/gpr/host_port.cc', 'src/core/lib/gpr/log.cc', 'src/core/lib/gpr/log_android.cc', 'src/core/lib/gpr/log_linux.cc', @@ -254,7 +255,6 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/arena.cc', 'src/core/lib/gprpp/fork.cc', 'src/core/lib/gprpp/global_config_env.cc', - 'src/core/lib/gprpp/host_port.cc', 'src/core/lib/gprpp/thd_posix.cc', 'src/core/lib/gprpp/thd_windows.cc', 'src/core/lib/profiling/basic_timers.cc', @@ -414,7 +414,6 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/orphanable.h', 'src/core/lib/gprpp/ref_counted.h', 'src/core/lib/gprpp/ref_counted_ptr.h', - 'src/core/lib/gprpp/string_view.h', 'src/core/lib/http/format_request.h', 'src/core/lib/http/httpcli.h', 'src/core/lib/http/parser.h', @@ -885,6 +884,7 @@ Pod::Spec.new do |s| ss.private_header_files = 'src/core/lib/gpr/alloc.h', 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', + 'src/core/lib/gpr/host_port.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', 'src/core/lib/gpr/spinlock.h', @@ -905,7 +905,6 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/global_config_custom.h', 'src/core/lib/gprpp/global_config_env.h', 'src/core/lib/gprpp/global_config_generic.h', - 'src/core/lib/gprpp/host_port.h', 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', @@ -1068,7 +1067,6 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/orphanable.h', 'src/core/lib/gprpp/ref_counted.h', 'src/core/lib/gprpp/ref_counted_ptr.h', - 'src/core/lib/gprpp/string_view.h', 'src/core/lib/http/format_request.h', 'src/core/lib/http/httpcli.h', 'src/core/lib/http/parser.h', diff --git a/grpc.gemspec b/grpc.gemspec index a1051fd4685..11469a3ec5c 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -85,6 +85,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/alloc.h ) s.files += %w( src/core/lib/gpr/arena.h ) s.files += %w( src/core/lib/gpr/env.h ) + s.files += %w( src/core/lib/gpr/host_port.h ) s.files += %w( src/core/lib/gpr/mpscq.h ) s.files += %w( src/core/lib/gpr/murmur_hash.h ) s.files += %w( src/core/lib/gpr/spinlock.h ) @@ -105,7 +106,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gprpp/global_config_custom.h ) s.files += %w( src/core/lib/gprpp/global_config_env.h ) s.files += %w( src/core/lib/gprpp/global_config_generic.h ) - s.files += %w( src/core/lib/gprpp/host_port.h ) s.files += %w( src/core/lib/gprpp/manual_constructor.h ) s.files += %w( src/core/lib/gprpp/map.h ) s.files += %w( src/core/lib/gprpp/memory.h ) @@ -122,6 +122,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/env_linux.cc ) s.files += %w( src/core/lib/gpr/env_posix.cc ) s.files += %w( src/core/lib/gpr/env_windows.cc ) + s.files += %w( src/core/lib/gpr/host_port.cc ) s.files += %w( src/core/lib/gpr/log.cc ) s.files += %w( src/core/lib/gpr/log_android.cc ) s.files += %w( src/core/lib/gpr/log_linux.cc ) @@ -148,7 +149,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gprpp/arena.cc ) s.files += %w( src/core/lib/gprpp/fork.cc ) s.files += %w( src/core/lib/gprpp/global_config_env.cc ) - s.files += %w( src/core/lib/gprpp/host_port.cc ) s.files += %w( src/core/lib/gprpp/thd_posix.cc ) s.files += %w( src/core/lib/gprpp/thd_windows.cc ) s.files += %w( src/core/lib/profiling/basic_timers.cc ) @@ -348,7 +348,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gprpp/orphanable.h ) s.files += %w( src/core/lib/gprpp/ref_counted.h ) s.files += %w( src/core/lib/gprpp/ref_counted_ptr.h ) - s.files += %w( src/core/lib/gprpp/string_view.h ) s.files += %w( src/core/lib/http/format_request.h ) s.files += %w( src/core/lib/http/httpcli.h ) s.files += %w( src/core/lib/http/parser.h ) diff --git a/grpc.gyp b/grpc.gyp index 784279301d3..6268bed7bb0 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -226,6 +226,7 @@ 'src/core/lib/gpr/env_linux.cc', 'src/core/lib/gpr/env_posix.cc', 'src/core/lib/gpr/env_windows.cc', + 'src/core/lib/gpr/host_port.cc', 'src/core/lib/gpr/log.cc', 'src/core/lib/gpr/log_android.cc', 'src/core/lib/gpr/log_linux.cc', @@ -252,7 +253,6 @@ 'src/core/lib/gprpp/arena.cc', 'src/core/lib/gprpp/fork.cc', 'src/core/lib/gprpp/global_config_env.cc', - 'src/core/lib/gprpp/host_port.cc', 'src/core/lib/gprpp/thd_posix.cc', 'src/core/lib/gprpp/thd_windows.cc', 'src/core/lib/profiling/basic_timers.cc', diff --git a/package.xml b/package.xml index 388e8d8620a..616e1ece20e 100644 --- a/package.xml +++ b/package.xml @@ -90,6 +90,7 @@ + @@ -110,7 +111,6 @@ - @@ -127,6 +127,7 @@ + @@ -153,7 +154,6 @@ - @@ -353,7 +353,6 @@ - diff --git a/src/core/ext/filters/client_channel/http_proxy.cc b/src/core/ext/filters/client_channel/http_proxy.cc index 9e60a553ceb..8951a2920c4 100644 --- a/src/core/ext/filters/client_channel/http_proxy.cc +++ b/src/core/ext/filters/client_channel/http_proxy.cc @@ -31,8 +31,8 @@ #include "src/core/ext/filters/client_channel/proxy_mapper_registry.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/slice/b64.h" #include "src/core/lib/uri/uri_parser.h" @@ -126,18 +126,17 @@ static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper, if (no_proxy_str != nullptr) { static const char* NO_PROXY_SEPARATOR = ","; bool use_proxy = true; - grpc_core::UniquePtr server_host; - grpc_core::UniquePtr server_port; - if (!grpc_core::SplitHostPort( - uri->path[0] == '/' ? uri->path + 1 : uri->path, &server_host, - &server_port)) { + char* server_host; + char* server_port; + if (!gpr_split_host_port(uri->path[0] == '/' ? uri->path + 1 : uri->path, + &server_host, &server_port)) { gpr_log(GPR_INFO, "unable to split host and port, not checking no_proxy list for " "host '%s'", server_uri); gpr_free(no_proxy_str); } else { - size_t uri_len = strlen(server_host.get()); + size_t uri_len = strlen(server_host); char** no_proxy_hosts; size_t num_no_proxy_hosts; gpr_string_split(no_proxy_str, NO_PROXY_SEPARATOR, &no_proxy_hosts, @@ -146,8 +145,8 @@ static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper, char* no_proxy_entry = no_proxy_hosts[i]; size_t no_proxy_len = strlen(no_proxy_entry); if (no_proxy_len <= uri_len && - gpr_stricmp(no_proxy_entry, - &(server_host.get()[uri_len - no_proxy_len])) == 0) { + gpr_stricmp(no_proxy_entry, &server_host[uri_len - no_proxy_len]) == + 0) { gpr_log(GPR_INFO, "not using proxy for host in no_proxy list '%s'", server_uri); use_proxy = false; @@ -158,6 +157,8 @@ static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper, gpr_free(no_proxy_hosts[i]); } gpr_free(no_proxy_hosts); + gpr_free(server_host); + gpr_free(server_port); gpr_free(no_proxy_str); if (!use_proxy) goto no_use_proxy; } diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 71e8e248770..2f3516066da 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -84,6 +84,7 @@ #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/gprpp/memory.h" diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index ca9ea9e31cc..e5c27fe67a4 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -84,6 +84,7 @@ #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/gprpp/map.h" diff --git a/src/core/ext/filters/client_channel/parse_address.cc b/src/core/ext/filters/client_channel/parse_address.cc index fbfbb4445f3..c5e1ed811bc 100644 --- a/src/core/ext/filters/client_channel/parse_address.cc +++ b/src/core/ext/filters/client_channel/parse_address.cc @@ -33,8 +33,8 @@ #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/host_port.h" #ifdef GRPC_POSIX_SOCKET #include @@ -73,9 +73,9 @@ bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr, bool log_errors) { bool success = false; // Split host and port. - grpc_core::UniquePtr host; - grpc_core::UniquePtr port; - if (!grpc_core::SplitHostPort(hostport, &host, &port)) { + char* host; + char* port; + if (!gpr_split_host_port(hostport, &host, &port)) { if (log_errors) { gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)", hostport); } @@ -86,10 +86,8 @@ bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr, addr->len = static_cast(sizeof(grpc_sockaddr_in)); grpc_sockaddr_in* in = reinterpret_cast(addr->addr); in->sin_family = GRPC_AF_INET; - if (grpc_inet_pton(GRPC_AF_INET, host.get(), &in->sin_addr) == 0) { - if (log_errors) { - gpr_log(GPR_ERROR, "invalid ipv4 address: '%s'", host.get()); - } + if (grpc_inet_pton(GRPC_AF_INET, host, &in->sin_addr) == 0) { + if (log_errors) gpr_log(GPR_ERROR, "invalid ipv4 address: '%s'", host); goto done; } // Parse port. @@ -98,14 +96,15 @@ bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr, goto done; } int port_num; - if (sscanf(port.get(), "%d", &port_num) != 1 || port_num < 0 || - port_num > 65535) { - if (log_errors) gpr_log(GPR_ERROR, "invalid ipv4 port: '%s'", port.get()); + if (sscanf(port, "%d", &port_num) != 1 || port_num < 0 || port_num > 65535) { + if (log_errors) gpr_log(GPR_ERROR, "invalid ipv4 port: '%s'", port); goto done; } in->sin_port = grpc_htons(static_cast(port_num)); success = true; done: + gpr_free(host); + gpr_free(port); return success; } @@ -125,9 +124,9 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, bool log_errors) { bool success = false; // Split host and port. - grpc_core::UniquePtr host; - grpc_core::UniquePtr port; - if (!grpc_core::SplitHostPort(hostport, &host, &port)) { + char* host; + char* port; + if (!gpr_split_host_port(hostport, &host, &port)) { if (log_errors) { gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)", hostport); } @@ -139,12 +138,11 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, grpc_sockaddr_in6* in6 = reinterpret_cast(addr->addr); in6->sin6_family = GRPC_AF_INET6; // Handle the RFC6874 syntax for IPv6 zone identifiers. - char* host_end = - static_cast(gpr_memrchr(host.get(), '%', strlen(host.get()))); + char* host_end = static_cast(gpr_memrchr(host, '%', strlen(host))); if (host_end != nullptr) { - GPR_ASSERT(host_end >= host.get()); + GPR_ASSERT(host_end >= host); char host_without_scope[GRPC_INET6_ADDRSTRLEN + 1]; - size_t host_without_scope_len = static_cast(host_end - host.get()); + size_t host_without_scope_len = static_cast(host_end - host); uint32_t sin6_scope_id = 0; if (host_without_scope_len > GRPC_INET6_ADDRSTRLEN) { if (log_errors) { @@ -156,7 +154,7 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, } goto done; } - strncpy(host_without_scope, host.get(), host_without_scope_len); + strncpy(host_without_scope, host, host_without_scope_len); host_without_scope[host_without_scope_len] = '\0'; if (grpc_inet_pton(GRPC_AF_INET6, host_without_scope, &in6->sin6_addr) == 0) { @@ -165,9 +163,9 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, } goto done; } - if (gpr_parse_bytes_to_uint32( - host_end + 1, strlen(host.get()) - host_without_scope_len - 1, - &sin6_scope_id) == 0) { + if (gpr_parse_bytes_to_uint32(host_end + 1, + strlen(host) - host_without_scope_len - 1, + &sin6_scope_id) == 0) { if ((sin6_scope_id = grpc_if_nametoindex(host_end + 1)) == 0) { gpr_log(GPR_ERROR, "Invalid interface name: '%s'. " @@ -179,10 +177,8 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, // Handle "sin6_scope_id" being type "u_long". See grpc issue #10027. in6->sin6_scope_id = sin6_scope_id; } else { - if (grpc_inet_pton(GRPC_AF_INET6, host.get(), &in6->sin6_addr) == 0) { - if (log_errors) { - gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host.get()); - } + if (grpc_inet_pton(GRPC_AF_INET6, host, &in6->sin6_addr) == 0) { + if (log_errors) gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host); goto done; } } @@ -192,14 +188,15 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, goto done; } int port_num; - if (sscanf(port.get(), "%d", &port_num) != 1 || port_num < 0 || - port_num > 65535) { - if (log_errors) gpr_log(GPR_ERROR, "invalid ipv6 port: '%s'", port.get()); + if (sscanf(port, "%d", &port_num) != 1 || port_num < 0 || port_num > 65535) { + if (log_errors) gpr_log(GPR_ERROR, "invalid ipv6 port: '%s'", port); goto done; } in6->sin6_port = grpc_htons(static_cast(port_num)); success = true; done: + gpr_free(host); + gpr_free(port); return success; } diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index ff15704d692..32a339af359 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -38,6 +38,7 @@ #include "src/core/ext/filters/client_channel/service_config.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/combiner.h" diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc index 0c1a8ba828f..ad0f1460121 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc @@ -35,8 +35,8 @@ #include #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/executor.h" @@ -355,9 +355,9 @@ void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked( grpc_ares_hostbyname_request* hr = nullptr; ares_channel* channel = nullptr; /* parse name, splitting it into host and port parts */ - grpc_core::UniquePtr host; - grpc_core::UniquePtr port; - grpc_core::SplitHostPort(name, &host, &port); + char* host; + char* port; + gpr_split_host_port(name, &host, &port); if (host == nullptr) { error = grpc_error_set_str( GRPC_ERROR_CREATE_FROM_STATIC_STRING("unparseable host:port"), @@ -370,7 +370,7 @@ void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked( GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(name)); goto error_cleanup; } - port.reset(gpr_strdup(default_port)); + port = gpr_strdup(default_port); } error = grpc_ares_ev_driver_create_locked(&r->ev_driver, interested_parties, query_timeout_ms, combiner, r); @@ -414,22 +414,20 @@ void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked( } r->pending_queries = 1; if (grpc_ares_query_ipv6()) { - hr = create_hostbyname_request_locked(r, host.get(), - grpc_strhtons(port.get()), - /*is_balancer=*/false); + hr = create_hostbyname_request_locked(r, host, grpc_strhtons(port), + false /* is_balancer */); ares_gethostbyname(*channel, hr->host, AF_INET6, on_hostbyname_done_locked, hr); } - hr = - create_hostbyname_request_locked(r, host.get(), grpc_strhtons(port.get()), - /*is_balancer=*/false); + hr = create_hostbyname_request_locked(r, host, grpc_strhtons(port), + false /* is_balancer */); ares_gethostbyname(*channel, hr->host, AF_INET, on_hostbyname_done_locked, hr); if (check_grpclb) { /* Query the SRV record */ grpc_ares_request_ref_locked(r); char* service_name; - gpr_asprintf(&service_name, "_grpclb._tcp.%s", host.get()); + gpr_asprintf(&service_name, "_grpclb._tcp.%s", host); ares_query(*channel, service_name, ns_c_in, ns_t_srv, on_srv_query_done_locked, r); gpr_free(service_name); @@ -437,25 +435,28 @@ void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked( if (r->service_config_json_out != nullptr) { grpc_ares_request_ref_locked(r); char* config_name; - gpr_asprintf(&config_name, "_grpc_config.%s", host.get()); + gpr_asprintf(&config_name, "_grpc_config.%s", host); ares_search(*channel, config_name, ns_c_in, ns_t_txt, on_txt_done_locked, r); gpr_free(config_name); } grpc_ares_ev_driver_start_locked(r->ev_driver); grpc_ares_request_unref_locked(r); + gpr_free(host); + gpr_free(port); return; error_cleanup: GRPC_CLOSURE_SCHED(r->on_done, error); + gpr_free(host); + gpr_free(port); } static bool inner_resolve_as_ip_literal_locked( const char* name, const char* default_port, - grpc_core::UniquePtr* addrs, - grpc_core::UniquePtr* host, grpc_core::UniquePtr* port, - grpc_core::UniquePtr* hostport) { - grpc_core::SplitHostPort(name, host, port); + grpc_core::UniquePtr* addrs, char** host, + char** port, char** hostport) { + gpr_split_host_port(name, host, port); if (*host == nullptr) { gpr_log(GPR_ERROR, "Failed to parse %s to host:port while attempting to resolve as ip " @@ -471,14 +472,12 @@ static bool inner_resolve_as_ip_literal_locked( name); return false; } - port->reset(gpr_strdup(default_port)); + *port = gpr_strdup(default_port); } grpc_resolved_address addr; - GPR_ASSERT(grpc_core::JoinHostPort(hostport, host->get(), atoi(port->get()))); - if (grpc_parse_ipv4_hostport(hostport->get(), &addr, - false /* log errors */) || - grpc_parse_ipv6_hostport(hostport->get(), &addr, - false /* log errors */)) { + GPR_ASSERT(gpr_join_host_port(hostport, *host, atoi(*port))); + if (grpc_parse_ipv4_hostport(*hostport, &addr, false /* log errors */) || + grpc_parse_ipv6_hostport(*hostport, &addr, false /* log errors */)) { GPR_ASSERT(*addrs == nullptr); *addrs = grpc_core::MakeUnique(); (*addrs)->emplace_back(addr.addr, addr.len, nullptr /* args */); @@ -490,22 +489,24 @@ static bool inner_resolve_as_ip_literal_locked( static bool resolve_as_ip_literal_locked( const char* name, const char* default_port, grpc_core::UniquePtr* addrs) { - grpc_core::UniquePtr host; - grpc_core::UniquePtr port; - grpc_core::UniquePtr hostport; + char* host = nullptr; + char* port = nullptr; + char* hostport = nullptr; bool out = inner_resolve_as_ip_literal_locked(name, default_port, addrs, &host, &port, &hostport); + gpr_free(host); + gpr_free(port); + gpr_free(hostport); return out; } -static bool target_matches_localhost_inner(const char* name, - grpc_core::UniquePtr* host, - grpc_core::UniquePtr* port) { - if (!grpc_core::SplitHostPort(name, host, port)) { +static bool target_matches_localhost_inner(const char* name, char** host, + char** port) { + if (!gpr_split_host_port(name, host, port)) { gpr_log(GPR_ERROR, "Unable to split host and port for name: %s", name); return false; } - if (gpr_stricmp(host->get(), "localhost") == 0) { + if (gpr_stricmp(*host, "localhost") == 0) { return true; } else { return false; @@ -513,17 +514,20 @@ static bool target_matches_localhost_inner(const char* name, } static bool target_matches_localhost(const char* name) { - grpc_core::UniquePtr host; - grpc_core::UniquePtr port; - return target_matches_localhost_inner(name, &host, &port); + char* host = nullptr; + char* port = nullptr; + bool out = target_matches_localhost_inner(name, &host, &port); + gpr_free(host); + gpr_free(port); + return out; } #ifdef GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY static bool inner_maybe_resolve_localhost_manually_locked( const char* name, const char* default_port, - grpc_core::UniquePtr* addrs, - grpc_core::UniquePtr* host, grpc_core::UniquePtr* port) { - grpc_core::SplitHostPort(name, host, port); + grpc_core::UniquePtr* addrs, char** host, + char** port) { + gpr_split_host_port(name, host, port); if (*host == nullptr) { gpr_log(GPR_ERROR, "Failed to parse %s into host:port during manual localhost " @@ -539,12 +543,12 @@ static bool inner_maybe_resolve_localhost_manually_locked( name); return false; } - port->reset(gpr_strdup(default_port)); + *port = gpr_strdup(default_port); } - if (gpr_stricmp(host->get(), "localhost") == 0) { + if (gpr_stricmp(*host, "localhost") == 0) { GPR_ASSERT(*addrs == nullptr); *addrs = grpc_core::MakeUnique(); - uint16_t numeric_port = grpc_strhtons(port->get()); + uint16_t numeric_port = grpc_strhtons(*port); // Append the ipv6 loopback address. struct sockaddr_in6 ipv6_loopback_addr; memset(&ipv6_loopback_addr, 0, sizeof(ipv6_loopback_addr)); @@ -572,10 +576,13 @@ static bool inner_maybe_resolve_localhost_manually_locked( static bool grpc_ares_maybe_resolve_localhost_manually_locked( const char* name, const char* default_port, grpc_core::UniquePtr* addrs) { - grpc_core::UniquePtr host; - grpc_core::UniquePtr port; - return inner_maybe_resolve_localhost_manually_locked(name, default_port, - addrs, &host, &port); + char* host = nullptr; + char* port = nullptr; + bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port, + addrs, &host, &port); + gpr_free(host); + gpr_free(port); + return out; } #else /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ static bool grpc_ares_maybe_resolve_localhost_manually_locked( diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc index d9e3293deb6..f85feb674dd 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc @@ -26,6 +26,7 @@ #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/ext/filters/client_channel/server_address.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" bool grpc_ares_query_ipv6() { diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc index 1749cf77201..06cd5722ce3 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc @@ -26,6 +26,7 @@ #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/ext/filters/client_channel/server_address.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/socket_windows.h" diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc index b8434a1cae4..5ab75d02793 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc @@ -31,6 +31,7 @@ #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/combiner.h" diff --git a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc index ff728a3dc43..7f613ee21bc 100644 --- a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc @@ -32,6 +32,7 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/closure.h" diff --git a/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc b/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc index 517b9297af4..1465b0c644e 100644 --- a/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc @@ -30,6 +30,7 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/resolve_address.h" diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc index dc60ec2487b..8285ee76445 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -37,6 +37,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker.h" #include "src/core/lib/channel/handshaker_registry.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/resource_quota.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_data.cc b/src/core/ext/transport/chttp2/transport/frame_data.cc index c50d7e48d41..74c305b820f 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.cc +++ b/src/core/ext/transport/chttp2/transport/frame_data.cc @@ -137,10 +137,10 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( p->error = grpc_error_set_int(p->error, GRPC_ERROR_INT_STREAM_ID, static_cast(s->id)); gpr_free(msg); - p->error = grpc_error_set_str( - p->error, GRPC_ERROR_STR_RAW_BYTES, - grpc_slice_from_moved_string(grpc_core::UniquePtr( - grpc_dump_slice(*slice, GPR_DUMP_HEX | GPR_DUMP_ASCII)))); + p->error = + grpc_error_set_str(p->error, GRPC_ERROR_STR_RAW_BYTES, + grpc_dump_slice_to_slice( + *slice, GPR_DUMP_HEX | GPR_DUMP_ASCII)); p->error = grpc_error_set_int(p->error, GRPC_ERROR_INT_OFFSET, cur - beg); p->state = GRPC_CHTTP2_DATA_ERROR; diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc index a5f6571c510..3ddda268cfb 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.cc +++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc @@ -30,6 +30,7 @@ #include "src/core/ext/transport/chttp2/transport/incoming_metadata.h" #include "src/core/ext/transport/cronet/transport/cronet_transport.h" #include "src/core/lib/debug/trace.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/endpoint.h" diff --git a/src/core/lib/channel/channelz.cc b/src/core/lib/channel/channelz.cc index 184ba17889d..4b130372e46 100644 --- a/src/core/lib/channel/channelz.cc +++ b/src/core/lib/channel/channelz.cc @@ -30,9 +30,9 @@ #include "src/core/lib/channel/channelz_registry.h" #include "src/core/lib/channel/status_util.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -406,15 +406,14 @@ void PopulateSocketAddressJson(grpc_json* json, const char* name, (strcmp(uri->scheme, "ipv6") == 0))) { const char* host_port = uri->path; if (*host_port == '/') ++host_port; - UniquePtr host; - UniquePtr port; - GPR_ASSERT(SplitHostPort(host_port, &host, &port)); + char* host = nullptr; + char* port = nullptr; + GPR_ASSERT(gpr_split_host_port(host_port, &host, &port)); int port_num = -1; if (port != nullptr) { - port_num = atoi(port.get()); + port_num = atoi(port); } - char* b64_host = - grpc_base64_encode(host.get(), strlen(host.get()), false, false); + char* b64_host = grpc_base64_encode(host, strlen(host), false, false); json_iterator = grpc_json_create_child(json_iterator, json, "tcpip_address", nullptr, GRPC_JSON_OBJECT, false); json = json_iterator; @@ -423,6 +422,8 @@ void PopulateSocketAddressJson(grpc_json* json, const char* name, "port", port_num); json_iterator = grpc_json_create_child(json_iterator, json, "ip_address", b64_host, GRPC_JSON_STRING, true); + gpr_free(host); + gpr_free(port); } else if (uri != nullptr && strcmp(uri->scheme, "unix") == 0) { json_iterator = grpc_json_create_child(json_iterator, json, "uds_address", nullptr, GRPC_JSON_OBJECT, false); diff --git a/src/core/lib/gpr/host_port.cc b/src/core/lib/gpr/host_port.cc new file mode 100644 index 00000000000..a34e01cb516 --- /dev/null +++ b/src/core/lib/gpr/host_port.cc @@ -0,0 +1,98 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/gpr/host_port.h" + +#include + +#include +#include +#include + +#include "src/core/lib/gpr/string.h" + +int gpr_join_host_port(char** out, const char* host, int port) { + if (host[0] != '[' && strchr(host, ':') != nullptr) { + /* IPv6 literals must be enclosed in brackets. */ + return gpr_asprintf(out, "[%s]:%d", host, port); + } else { + /* Ordinary non-bracketed host:port. */ + return gpr_asprintf(out, "%s:%d", host, port); + } +} + +int gpr_split_host_port(const char* name, char** host, char** port) { + const char* host_start; + size_t host_len; + const char* port_start; + + *host = nullptr; + *port = nullptr; + + if (name[0] == '[') { + /* Parse a bracketed host, typically an IPv6 literal. */ + const char* rbracket = strchr(name, ']'); + if (rbracket == nullptr) { + /* Unmatched [ */ + return 0; + } + if (rbracket[1] == '\0') { + /* ] */ + port_start = nullptr; + } else if (rbracket[1] == ':') { + /* ]: */ + port_start = rbracket + 2; + } else { + /* ] */ + return 0; + } + host_start = name + 1; + host_len = static_cast(rbracket - host_start); + if (memchr(host_start, ':', host_len) == nullptr) { + /* Require all bracketed hosts to contain a colon, because a hostname or + IPv4 address should never use brackets. */ + return 0; + } + } else { + const char* colon = strchr(name, ':'); + if (colon != nullptr && strchr(colon + 1, ':') == nullptr) { + /* Exactly 1 colon. Split into host:port. */ + host_start = name; + host_len = static_cast(colon - name); + port_start = colon + 1; + } else { + /* 0 or 2+ colons. Bare hostname or IPv6 litearal. */ + host_start = name; + host_len = strlen(name); + port_start = nullptr; + } + } + + /* Allocate return values. */ + *host = static_cast(gpr_malloc(host_len + 1)); + memcpy(*host, host_start, host_len); + (*host)[host_len] = '\0'; + + if (port_start != nullptr) { + *port = gpr_strdup(port_start); + } + + return 1; +} diff --git a/src/core/lib/gprpp/host_port.h b/src/core/lib/gpr/host_port.h similarity index 51% rename from src/core/lib/gprpp/host_port.h rename to src/core/lib/gpr/host_port.h index 9a0b492b98f..0bf0960f824 100644 --- a/src/core/lib/gprpp/host_port.h +++ b/src/core/lib/gpr/host_port.h @@ -16,44 +16,28 @@ * */ -#ifndef GRPC_CORE_LIB_GPRPP_HOST_PORT_H -#define GRPC_CORE_LIB_GPRPP_HOST_PORT_H +#ifndef GRPC_CORE_LIB_GPR_HOST_PORT_H +#define GRPC_CORE_LIB_GPR_HOST_PORT_H #include -#include "src/core/lib/gprpp/memory.h" -#include "src/core/lib/gprpp/string_view.h" - -namespace grpc_core { - /** Given a host and port, creates a newly-allocated string of the form "host:port" or "[ho:st]:port", depending on whether the host contains colons like an IPv6 literal. If the host is already bracketed, then additional brackets will not be added. Usage is similar to gpr_asprintf: returns the number of bytes written - (excluding the final '\0'), and *out points to a string. + (excluding the final '\0'), and *out points to a string which must later be + destroyed using gpr_free(). In the unlikely event of an error, returns -1 and sets *out to NULL. */ -int JoinHostPort(UniquePtr* out, const char* host, int port); +int gpr_join_host_port(char** out, const char* host, int port); /** Given a name in the form "host:port" or "[ho:st]:port", split into hostname - and port number. + and port number, into newly allocated strings, which must later be + destroyed using gpr_free(). + Return 1 on success, 0 on failure. Guarantees *host and *port == NULL on + failure. */ +int gpr_split_host_port(const char* name, char** host, char** port); - There are two variants of this method: - 1) StringView output: port and host are returned as views on name. - 2) char* output: port and host are copied into newly allocated strings. - - Prefer variant (1) over (2), because no allocation or copy is performed in - variant (1). Use (2) only when interacting with C API that mandate - null-terminated strings. - - Return true on success, false on failure. Guarantees *host and *port are - cleared on failure. */ -bool SplitHostPort(StringView name, StringView* host, StringView* port); -bool SplitHostPort(StringView name, UniquePtr* host, - UniquePtr* port); - -} // namespace grpc_core - -#endif /* GRPC_CORE_LIB_GPRPP_HOST_PORT_H */ +#endif /* GRPC_CORE_LIB_GPR_HOST_PORT_H */ diff --git a/src/core/lib/gpr/string.cc b/src/core/lib/gpr/string.cc index 14436ec1bf9..a39f56ef926 100644 --- a/src/core/lib/gpr/string.cc +++ b/src/core/lib/gpr/string.cc @@ -289,22 +289,17 @@ char* gpr_strvec_flatten(gpr_strvec* sv, size_t* final_length) { return gpr_strjoin((const char**)sv->strs, sv->count, final_length); } -int gpr_strincmp(const char* a, const char* b, size_t n) { +int gpr_stricmp(const char* a, const char* b) { int ca, cb; do { ca = tolower(*a); cb = tolower(*b); ++a; ++b; - --n; - } while (ca == cb && ca != 0 && cb != 0 && n != 0); + } while (ca == cb && ca && cb); return ca - cb; } -int gpr_stricmp(const char* a, const char* b) { - return gpr_strincmp(a, b, SIZE_MAX); -} - static void add_string_to_split(const char* beg, const char* end, char*** strs, size_t* nstrs, size_t* capstrs) { char* out = diff --git a/src/core/lib/gpr/string.h b/src/core/lib/gpr/string.h index fcccf5e6764..bf59db7abfe 100644 --- a/src/core/lib/gpr/string.h +++ b/src/core/lib/gpr/string.h @@ -115,7 +115,6 @@ char* gpr_strvec_flatten(gpr_strvec* strs, size_t* total_length); /** Case insensitive string comparison... return <0 if lower(a)0 if lower(a)>lower(b) */ int gpr_stricmp(const char* a, const char* b); -int gpr_strincmp(const char* a, const char* b, size_t n); void* gpr_memrchr(const void* s, int c, size_t n); diff --git a/src/core/lib/gprpp/host_port.cc b/src/core/lib/gprpp/host_port.cc deleted file mode 100644 index f3f8a73602a..00000000000 --- a/src/core/lib/gprpp/host_port.cc +++ /dev/null @@ -1,97 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/lib/gprpp/host_port.h" - -#include - -#include -#include -#include - -#include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/string_view.h" - -namespace grpc_core { -int JoinHostPort(UniquePtr* out, const char* host, int port) { - char* tmp; - int ret; - if (host[0] != '[' && strchr(host, ':') != nullptr) { - /* IPv6 literals must be enclosed in brackets. */ - ret = gpr_asprintf(&tmp, "[%s]:%d", host, port); - } else { - /* Ordinary non-bracketed host:port. */ - ret = gpr_asprintf(&tmp, "%s:%d", host, port); - } - out->reset(tmp); - return ret; -} - -bool SplitHostPort(StringView name, StringView* host, StringView* port) { - if (name[0] == '[') { - /* Parse a bracketed host, typically an IPv6 literal. */ - const size_t rbracket = name.find(']', 1); - if (rbracket == grpc_core::StringView::npos) { - /* Unmatched [ */ - return false; - } - if (rbracket == name.size() - 1) { - /* ] */ - port->clear(); - } else if (name[rbracket + 1] == ':') { - /* ]: */ - *port = name.substr(rbracket + 2, name.size() - rbracket - 2); - } else { - /* ] */ - return false; - } - *host = name.substr(1, rbracket - 1); - if (host->find(':') == grpc_core::StringView::npos) { - /* Require all bracketed hosts to contain a colon, because a hostname or - IPv4 address should never use brackets. */ - host->clear(); - return false; - } - } else { - size_t colon = name.find(':'); - if (colon != grpc_core::StringView::npos && - name.find(':', colon + 1) == grpc_core::StringView::npos) { - /* Exactly 1 colon. Split into host:port. */ - *host = name.substr(0, colon); - *port = name.substr(colon + 1, name.size() - colon - 1); - } else { - /* 0 or 2+ colons. Bare hostname or IPv6 litearal. */ - *host = name; - port->clear(); - } - } - return true; -} - -bool SplitHostPort(StringView name, UniquePtr* host, - UniquePtr* port) { - StringView host_view; - StringView port_view; - const bool ret = SplitHostPort(name, &host_view, &port_view); - host->reset(host_view.empty() ? nullptr : host_view.dup().release()); - port->reset(port_view.empty() ? nullptr : port_view.dup().release()); - return ret; -} -} // namespace grpc_core diff --git a/src/core/lib/gprpp/string_view.h b/src/core/lib/gprpp/string_view.h deleted file mode 100644 index 05a81066d48..00000000000 --- a/src/core/lib/gprpp/string_view.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef GRPC_CORE_LIB_GPRPP_STRING_VIEW_H -#define GRPC_CORE_LIB_GPRPP_STRING_VIEW_H - -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include "src/core/lib/gpr/string.h" -#include "src/core/lib/gpr/useful.h" -#include "src/core/lib/gprpp/memory.h" - -namespace grpc_core { - -// Provides a light-weight view over a char array or a slice, similar but not -// identical to absl::string_view. -// -// Any method that has the same name as absl::string_view MUST HAVE identical -// semantics to what absl::string_view provides. -// -// Methods that are not part of absl::string_view API, must be clearly -// annotated. -// -// StringView does not own the buffers that back the view. Callers must ensure -// the buffer stays around while the StringView is accessible. -// -// Pass StringView by value in functions, since it is exactly two pointers in -// size. -// -// The interface used here is not identical to absl::string_view. Notably, we -// need to support slices while we cannot support std::string, and gpr string -// style functions such as strdup() and cmp(). Once we switch to -// absl::string_view this class will inherit from absl::string_view and add the -// gRPC-specific APIs. -class StringView final { - public: - static constexpr size_t npos = std::numeric_limits::max(); - - constexpr StringView(const char* ptr, size_t size) : ptr_(ptr), size_(size) {} - constexpr StringView(const char* ptr) - : StringView(ptr, ptr == nullptr ? 0 : strlen(ptr)) {} - // Not part of absl::string_view API. - StringView(const grpc_slice& slice) - : StringView(reinterpret_cast(GRPC_SLICE_START_PTR(slice)), - GRPC_SLICE_LENGTH(slice)) {} - constexpr StringView() : StringView(nullptr, 0) {} - - constexpr const char* data() const { return ptr_; } - constexpr size_t size() const { return size_; } - constexpr bool empty() const { return size_ == 0; } - - StringView substr(size_t start, size_t size = npos) { - GPR_DEBUG_ASSERT(start + size <= size_); - return StringView(ptr_ + start, std::min(size, size_ - start)); - } - - constexpr const char& operator[](size_t i) const { return ptr_[i]; } - - const char& front() const { return ptr_[0]; } - const char& back() const { return ptr_[size_ - 1]; } - - void remove_prefix(size_t n) { - GPR_DEBUG_ASSERT(n <= size_); - ptr_ += n; - size_ -= n; - } - - void remove_suffix(size_t n) { - GPR_DEBUG_ASSERT(n <= size_); - size_ -= n; - } - - size_t find(char c, size_t pos = 0) const { - if (empty() || pos >= size_) return npos; - const char* result = - static_cast(memchr(ptr_ + pos, c, size_ - pos)); - return result != nullptr ? result - ptr_ : npos; - } - - void clear() { - ptr_ = nullptr; - size_ = 0; - } - - // Creates a dup of the string viewed by this class. - // Return value is null-terminated and never nullptr. - // - // Not part of absl::string_view API. - grpc_core::UniquePtr dup() const { - char* str = static_cast(gpr_malloc(size_ + 1)); - if (size_ > 0) memcpy(str, ptr_, size_); - str[size_] = '\0'; - return grpc_core::UniquePtr(str); - } - - // Not part of absl::string_view API. - int cmp(StringView other) const { - const size_t len = GPR_MIN(size(), other.size()); - const int ret = strncmp(data(), other.data(), len); - if (ret != 0) return ret; - if (size() == other.size()) return 0; - if (size() < other.size()) return -1; - return 1; - } - - private: - const char* ptr_; - size_t size_; -}; - -inline bool operator==(StringView lhs, StringView rhs) { - return lhs.size() == rhs.size() && - strncmp(lhs.data(), rhs.data(), lhs.size()) == 0; -} - -inline bool operator!=(StringView lhs, StringView rhs) { return !(lhs == rhs); } - -} // namespace grpc_core - -#endif /* GRPC_CORE_LIB_GPRPP_STRING_VIEW_H */ diff --git a/src/core/lib/http/httpcli_security_connector.cc b/src/core/lib/http/httpcli_security_connector.cc index 8196019f098..762cbe41bcf 100644 --- a/src/core/lib/http/httpcli_security_connector.cc +++ b/src/core/lib/http/httpcli_security_connector.cc @@ -30,7 +30,6 @@ #include "src/core/lib/channel/handshaker_registry.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" -#include "src/core/lib/gprpp/string_view.h" #include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" @@ -109,8 +108,7 @@ class grpc_httpcli_ssl_channel_security_connector final return strcmp(secure_peer_name_, other->secure_peer_name_); } - bool check_call_host(grpc_core::StringView host, - grpc_auth_context* auth_context, + bool check_call_host(const char* host, grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) override { *error = GRPC_ERROR_NONE; diff --git a/src/core/lib/iomgr/resolve_address_custom.cc b/src/core/lib/iomgr/resolve_address_custom.cc index 64c33cdc0d4..9cf7817f66e 100644 --- a/src/core/lib/iomgr/resolve_address_custom.cc +++ b/src/core/lib/iomgr/resolve_address_custom.cc @@ -24,9 +24,9 @@ #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/iomgr_custom.h" #include "src/core/lib/iomgr/resolve_address_custom.h" @@ -86,12 +86,11 @@ void grpc_custom_resolve_callback(grpc_custom_resolver* r, } static grpc_error* try_split_host_port(const char* name, - const char* default_port, - grpc_core::UniquePtr* host, - grpc_core::UniquePtr* port) { + const char* default_port, char** host, + char** port) { /* parse name, splitting it into host and port parts */ grpc_error* error; - SplitHostPort(name, host, port); + gpr_split_host_port(name, host, port); if (*host == nullptr) { char* msg; gpr_asprintf(&msg, "unparseable host:port: '%s'", name); @@ -108,7 +107,7 @@ static grpc_error* try_split_host_port(const char* name, gpr_free(msg); return error; } - port->reset(gpr_strdup(default_port)); + *port = gpr_strdup(default_port); } return GRPC_ERROR_NONE; } @@ -116,26 +115,28 @@ static grpc_error* try_split_host_port(const char* name, static grpc_error* blocking_resolve_address_impl( const char* name, const char* default_port, grpc_resolved_addresses** addresses) { - grpc_core::UniquePtr host; - grpc_core::UniquePtr port; + char* host; + char* port; grpc_error* err; GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD(); err = try_split_host_port(name, default_port, &host, &port); if (err != GRPC_ERROR_NONE) { + gpr_free(host); + gpr_free(port); return err; } /* Call getaddrinfo */ grpc_custom_resolver resolver; - resolver.host = host.get(); - resolver.port = port.get(); + resolver.host = host; + resolver.port = port; grpc_resolved_addresses* addrs; grpc_core::ExecCtx* curr = grpc_core::ExecCtx::Get(); grpc_core::ExecCtx::Set(nullptr); - err = resolve_address_vtable->resolve(host.get(), port.get(), &addrs); + err = resolve_address_vtable->resolve(host, port, &addrs); if (err != GRPC_ERROR_NONE) { if (retry_named_port_failure(&resolver, &addrs)) { GRPC_ERROR_UNREF(err); @@ -146,6 +147,8 @@ static grpc_error* blocking_resolve_address_impl( if (err == GRPC_ERROR_NONE) { *addresses = addrs; } + gpr_free(resolver.host); + gpr_free(resolver.port); return err; } @@ -154,20 +157,22 @@ static void resolve_address_impl(const char* name, const char* default_port, grpc_closure* on_done, grpc_resolved_addresses** addrs) { grpc_custom_resolver* r = nullptr; - grpc_core::UniquePtr host; - grpc_core::UniquePtr port; + char* host = nullptr; + char* port = nullptr; grpc_error* err; GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD(); err = try_split_host_port(name, default_port, &host, &port); if (err != GRPC_ERROR_NONE) { GRPC_CLOSURE_SCHED(on_done, err); + gpr_free(host); + gpr_free(port); return; } r = (grpc_custom_resolver*)gpr_malloc(sizeof(grpc_custom_resolver)); r->on_done = on_done; r->addresses = addrs; - r->host = host.release(); - r->port = port.release(); + r->host = host; + r->port = port; /* Call getaddrinfo */ resolve_address_vtable->resolve_async(r, r->host, r->port); diff --git a/src/core/lib/iomgr/resolve_address_posix.cc b/src/core/lib/iomgr/resolve_address_posix.cc index e02dc19bb27..e6dd8f1ceab 100644 --- a/src/core/lib/iomgr/resolve_address_posix.cc +++ b/src/core/lib/iomgr/resolve_address_posix.cc @@ -33,9 +33,9 @@ #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/executor.h" @@ -48,6 +48,8 @@ static grpc_error* posix_blocking_resolve_address( grpc_core::ExecCtx exec_ctx; struct addrinfo hints; struct addrinfo *result = nullptr, *resp; + char* host; + char* port; int s; size_t i; grpc_error* err; @@ -57,10 +59,8 @@ static grpc_error* posix_blocking_resolve_address( return grpc_resolve_unix_domain_address(name + 5, addresses); } - grpc_core::UniquePtr host; - grpc_core::UniquePtr port; /* parse name, splitting it into host and port parts */ - grpc_core::SplitHostPort(name, &host, &port); + gpr_split_host_port(name, &host, &port); if (host == nullptr) { err = grpc_error_set_str( GRPC_ERROR_CREATE_FROM_STATIC_STRING("unparseable host:port"), @@ -74,7 +74,7 @@ static grpc_error* posix_blocking_resolve_address( GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(name)); goto done; } - port.reset(gpr_strdup(default_port)); + port = gpr_strdup(default_port); } /* Call getaddrinfo */ @@ -84,16 +84,16 @@ static grpc_error* posix_blocking_resolve_address( hints.ai_flags = AI_PASSIVE; /* for wildcard IP address */ GRPC_SCHEDULING_START_BLOCKING_REGION; - s = getaddrinfo(host.get(), port.get(), &hints, &result); + s = getaddrinfo(host, port, &hints, &result); GRPC_SCHEDULING_END_BLOCKING_REGION; if (s != 0) { /* Retry if well-known service name is recognized */ const char* svc[][2] = {{"http", "80"}, {"https", "443"}}; for (i = 0; i < GPR_ARRAY_SIZE(svc); i++) { - if (strcmp(port.get(), svc[i][0]) == 0) { + if (strcmp(port, svc[i][0]) == 0) { GRPC_SCHEDULING_START_BLOCKING_REGION; - s = getaddrinfo(host.get(), svc[i][1], &hints, &result); + s = getaddrinfo(host, svc[i][1], &hints, &result); GRPC_SCHEDULING_END_BLOCKING_REGION; break; } @@ -133,6 +133,8 @@ static grpc_error* posix_blocking_resolve_address( err = GRPC_ERROR_NONE; done: + gpr_free(host); + gpr_free(port); if (result) { freeaddrinfo(result); } diff --git a/src/core/lib/iomgr/resolve_address_windows.cc b/src/core/lib/iomgr/resolve_address_windows.cc index a06d5cefbcb..64351c38a8f 100644 --- a/src/core/lib/iomgr/resolve_address_windows.cc +++ b/src/core/lib/iomgr/resolve_address_windows.cc @@ -35,8 +35,8 @@ #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/executor.h" @@ -57,14 +57,14 @@ static grpc_error* windows_blocking_resolve_address( grpc_core::ExecCtx exec_ctx; struct addrinfo hints; struct addrinfo *result = NULL, *resp; + char* host; + char* port; int s; size_t i; grpc_error* error = GRPC_ERROR_NONE; /* parse name, splitting it into host and port parts */ - grpc_core::UniquePtr host; - grpc_core::UniquePtr port; - grpc_core::SplitHostPort(name, &host, &port); + gpr_split_host_port(name, &host, &port); if (host == NULL) { char* msg; gpr_asprintf(&msg, "unparseable host:port: '%s'", name); @@ -80,7 +80,7 @@ static grpc_error* windows_blocking_resolve_address( gpr_free(msg); goto done; } - port.reset(gpr_strdup(default_port)); + port = gpr_strdup(default_port); } /* Call getaddrinfo */ @@ -90,7 +90,7 @@ static grpc_error* windows_blocking_resolve_address( hints.ai_flags = AI_PASSIVE; /* for wildcard IP address */ GRPC_SCHEDULING_START_BLOCKING_REGION; - s = getaddrinfo(host.get(), port.get(), &hints, &result); + s = getaddrinfo(host, port, &hints, &result); GRPC_SCHEDULING_END_BLOCKING_REGION; if (s != 0) { error = GRPC_WSA_ERROR(WSAGetLastError(), "getaddrinfo"); @@ -122,6 +122,8 @@ static grpc_error* windows_blocking_resolve_address( } done: + gpr_free(host); + gpr_free(port); if (result) { freeaddrinfo(result); } diff --git a/src/core/lib/iomgr/sockaddr_utils.cc b/src/core/lib/iomgr/sockaddr_utils.cc index baadf1da99e..0839bdfef2d 100644 --- a/src/core/lib/iomgr/sockaddr_utils.cc +++ b/src/core/lib/iomgr/sockaddr_utils.cc @@ -28,8 +28,8 @@ #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/socket_utils.h" #include "src/core/lib/iomgr/unix_sockets_posix.h" @@ -181,17 +181,15 @@ int grpc_sockaddr_to_string(char** out, } if (ip != nullptr && grpc_inet_ntop(addr->sa_family, ip, ntop_buf, sizeof(ntop_buf)) != nullptr) { - grpc_core::UniquePtr tmp_out; if (sin6_scope_id != 0) { char* host_with_scope; /* Enclose sin6_scope_id with the format defined in RFC 6784 section 2. */ gpr_asprintf(&host_with_scope, "%s%%25%" PRIu32, ntop_buf, sin6_scope_id); - ret = grpc_core::JoinHostPort(&tmp_out, host_with_scope, port); + ret = gpr_join_host_port(out, host_with_scope, port); gpr_free(host_with_scope); } else { - ret = grpc_core::JoinHostPort(&tmp_out, ntop_buf, port); + ret = gpr_join_host_port(out, ntop_buf, port); } - *out = tmp_out.release(); } else { ret = gpr_asprintf(out, "(sockaddr family=%d)", addr->sa_family); } diff --git a/src/core/lib/iomgr/socket_utils_common_posix.cc b/src/core/lib/iomgr/socket_utils_common_posix.cc index 47d9f51b095..2101651b33f 100644 --- a/src/core/lib/iomgr/socket_utils_common_posix.cc +++ b/src/core/lib/iomgr/socket_utils_common_posix.cc @@ -46,6 +46,7 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/sockaddr_utils.h" diff --git a/src/core/lib/iomgr/tcp_client_cfstream.cc b/src/core/lib/iomgr/tcp_client_cfstream.cc index fcad5edd222..4b21322d746 100644 --- a/src/core/lib/iomgr/tcp_client_cfstream.cc +++ b/src/core/lib/iomgr/tcp_client_cfstream.cc @@ -34,7 +34,7 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/cfstream_handle.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/endpoint_cfstream.h" @@ -143,13 +143,12 @@ static void OnOpen(void* arg, grpc_error* error) { static void ParseResolvedAddress(const grpc_resolved_address* addr, CFStringRef* host, int* port) { - char* host_port; + char *host_port, *host_string, *port_string; grpc_sockaddr_to_string(&host_port, addr, 1); - grpc_core::UniquePtr host_string; - grpc_core::UniquePtr port_string; - grpc_core::SplitHostPort(host_port, &host_string, &port_string); - *host = - CFStringCreateWithCString(NULL, host_string.get(), kCFStringEncodingUTF8); + gpr_split_host_port(host_port, &host_string, &port_string); + *host = CFStringCreateWithCString(NULL, host_string, kCFStringEncodingUTF8); + gpr_free(host_string); + gpr_free(port_string); gpr_free(host_port); *port = grpc_sockaddr_get_port(addr); } diff --git a/src/core/lib/security/security_connector/alts/alts_security_connector.cc b/src/core/lib/security/security_connector/alts/alts_security_connector.cc index 79908601130..38b1f856d52 100644 --- a/src/core/lib/security/security_connector/alts/alts_security_connector.cc +++ b/src/core/lib/security/security_connector/alts/alts_security_connector.cc @@ -108,11 +108,10 @@ class grpc_alts_channel_security_connector final return strcmp(target_name_, other->target_name_); } - bool check_call_host(grpc_core::StringView host, - grpc_auth_context* auth_context, + bool check_call_host(const char* host, grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) override { - if (host.empty() || host != target_name_) { + if (host == nullptr || strcmp(host, target_name_) != 0) { *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "ALTS call host does not match target name"); } diff --git a/src/core/lib/security/security_connector/fake/fake_security_connector.cc b/src/core/lib/security/security_connector/fake/fake_security_connector.cc index 940c2ac5ee5..c55fd34d0e2 100644 --- a/src/core/lib/security/security_connector/fake/fake_security_connector.cc +++ b/src/core/lib/security/security_connector/fake/fake_security_connector.cc @@ -31,8 +31,8 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/security/context/security_context.h" #include "src/core/lib/security/credentials/credentials.h" @@ -102,35 +102,39 @@ class grpc_fake_channel_security_connector final tsi_create_fake_handshaker(/*is_client=*/true), this)); } - bool check_call_host(grpc_core::StringView host, - grpc_auth_context* auth_context, + bool check_call_host(const char* host, grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) override { - grpc_core::StringView authority_hostname; - grpc_core::StringView authority_ignored_port; - grpc_core::StringView target_hostname; - grpc_core::StringView target_ignored_port; - grpc_core::SplitHostPort(host, &authority_hostname, - &authority_ignored_port); - grpc_core::SplitHostPort(target_, &target_hostname, &target_ignored_port); + char* authority_hostname = nullptr; + char* authority_ignored_port = nullptr; + char* target_hostname = nullptr; + char* target_ignored_port = nullptr; + gpr_split_host_port(host, &authority_hostname, &authority_ignored_port); + gpr_split_host_port(target_, &target_hostname, &target_ignored_port); if (target_name_override_ != nullptr) { - grpc_core::StringView fake_security_target_name_override_hostname; - grpc_core::StringView fake_security_target_name_override_ignored_port; - grpc_core::SplitHostPort( - target_name_override_, &fake_security_target_name_override_hostname, - &fake_security_target_name_override_ignored_port); - if (authority_hostname != fake_security_target_name_override_hostname) { + char* fake_security_target_name_override_hostname = nullptr; + char* fake_security_target_name_override_ignored_port = nullptr; + gpr_split_host_port(target_name_override_, + &fake_security_target_name_override_hostname, + &fake_security_target_name_override_ignored_port); + if (strcmp(authority_hostname, + fake_security_target_name_override_hostname) != 0) { gpr_log(GPR_ERROR, "Authority (host) '%s' != Fake Security Target override '%s'", - host.data(), - fake_security_target_name_override_hostname.data()); + host, fake_security_target_name_override_hostname); abort(); } - } else if (authority_hostname != target_hostname) { - gpr_log(GPR_ERROR, "Authority (host) '%s' != Target '%s'", host.data(), - target_); + gpr_free(fake_security_target_name_override_hostname); + gpr_free(fake_security_target_name_override_ignored_port); + } else if (strcmp(authority_hostname, target_hostname) != 0) { + gpr_log(GPR_ERROR, "Authority (host) '%s' != Target '%s'", + authority_hostname, target_hostname); abort(); } + gpr_free(authority_hostname); + gpr_free(authority_ignored_port); + gpr_free(target_hostname); + gpr_free(target_ignored_port); return true; } diff --git a/src/core/lib/security/security_connector/local/local_security_connector.cc b/src/core/lib/security/security_connector/local/local_security_connector.cc index 5b777009d34..c1a101d4ab8 100644 --- a/src/core/lib/security/security_connector/local/local_security_connector.cc +++ b/src/core/lib/security/security_connector/local/local_security_connector.cc @@ -156,11 +156,10 @@ class grpc_local_channel_security_connector final creds->connect_type()); } - bool check_call_host(grpc_core::StringView host, - grpc_auth_context* auth_context, + bool check_call_host(const char* host, grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) override { - if (host.empty() || host != target_name_) { + if (host == nullptr || strcmp(host, target_name_) != 0) { *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "local call host does not match target name"); } diff --git a/src/core/lib/security/security_connector/security_connector.cc b/src/core/lib/security/security_connector/security_connector.cc index 2c7c982e719..47c0ad5aa3d 100644 --- a/src/core/lib/security/security_connector/security_connector.cc +++ b/src/core/lib/security/security_connector/security_connector.cc @@ -28,8 +28,8 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/context/security_context.h" #include "src/core/lib/security/credentials/credentials.h" diff --git a/src/core/lib/security/security_connector/security_connector.h b/src/core/lib/security/security_connector/security_connector.h index e5ced44638b..f71ee54402d 100644 --- a/src/core/lib/security/security_connector/security_connector.h +++ b/src/core/lib/security/security_connector/security_connector.h @@ -98,7 +98,7 @@ class grpc_channel_security_connector : public grpc_security_connector { /// Returns true if completed synchronously, in which case \a error will /// be set to indicate the result. Otherwise, \a on_call_host_checked /// will be invoked when complete. - virtual bool check_call_host(grpc_core::StringView host, + virtual bool check_call_host(const char* host, grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) GRPC_ABSTRACT; diff --git a/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc b/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc index 97c04cafce4..f920dc6046d 100644 --- a/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +++ b/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc @@ -28,8 +28,8 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/handshaker.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/security/context/security_context.h" #include "src/core/lib/security/credentials/credentials.h" @@ -75,14 +75,15 @@ class grpc_ssl_channel_security_connector final ? nullptr : gpr_strdup(overridden_target_name)), verify_options_(&config->verify_options) { - grpc_core::StringView host; - grpc_core::StringView port; - grpc_core::SplitHostPort(target_name, &host, &port); - target_name_ = host.dup(); + char* port; + gpr_split_host_port(target_name, &target_name_, &port); + gpr_free(port); } ~grpc_ssl_channel_security_connector() override { tsi_ssl_client_handshaker_factory_unref(client_handshaker_factory_); + if (target_name_ != nullptr) gpr_free(target_name_); + if (overridden_target_name_ != nullptr) gpr_free(overridden_target_name_); } grpc_security_status InitializeHandshakerFactory( @@ -122,8 +123,8 @@ class grpc_ssl_channel_security_connector final tsi_handshaker* tsi_hs = nullptr; tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker( client_handshaker_factory_, - overridden_target_name_ != nullptr ? overridden_target_name_.get() - : target_name_.get(), + overridden_target_name_ != nullptr ? overridden_target_name_ + : target_name_, &tsi_hs); if (result != TSI_OK) { gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.", @@ -138,8 +139,8 @@ class grpc_ssl_channel_security_connector final grpc_core::RefCountedPtr* auth_context, grpc_closure* on_peer_checked) override { const char* target_name = overridden_target_name_ != nullptr - ? overridden_target_name_.get() - : target_name_.get(); + ? overridden_target_name_ + : target_name_; grpc_error* error = ssl_check_peer(target_name, &peer, auth_context); if (error == GRPC_ERROR_NONE && verify_options_->verify_peer_callback != nullptr) { @@ -174,18 +175,17 @@ class grpc_ssl_channel_security_connector final reinterpret_cast(other_sc); int c = channel_security_connector_cmp(other); if (c != 0) return c; - c = strcmp(target_name_.get(), other->target_name_.get()); + c = strcmp(target_name_, other->target_name_); if (c != 0) return c; return (overridden_target_name_ == nullptr || other->overridden_target_name_ == nullptr) - ? GPR_ICMP(overridden_target_name_.get(), - other->overridden_target_name_.get()) - : strcmp(overridden_target_name_.get(), - other->overridden_target_name_.get()); + ? GPR_ICMP(overridden_target_name_, + other->overridden_target_name_) + : strcmp(overridden_target_name_, + other->overridden_target_name_); } - bool check_call_host(grpc_core::StringView host, - grpc_auth_context* auth_context, + bool check_call_host(const char* host, grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) override { grpc_security_status status = GRPC_SECURITY_ERROR; @@ -194,7 +194,7 @@ class grpc_ssl_channel_security_connector final /* If the target name was overridden, then the original target_name was 'checked' transitively during the previous peer check at the end of the handshake. */ - if (overridden_target_name_ != nullptr && host == target_name_.get()) { + if (overridden_target_name_ != nullptr && strcmp(host, target_name_) == 0) { status = GRPC_SECURITY_OK; } if (status != GRPC_SECURITY_OK) { @@ -212,8 +212,8 @@ class grpc_ssl_channel_security_connector final private: tsi_ssl_client_handshaker_factory* client_handshaker_factory_; - grpc_core::UniquePtr target_name_; - grpc_core::UniquePtr overridden_target_name_; + char* target_name_; + char* overridden_target_name_; const verify_peer_options* verify_options_; }; diff --git a/src/core/lib/security/security_connector/ssl_utils.cc b/src/core/lib/security/security_connector/ssl_utils.cc index ebb4a3f9ee8..cb0d5437988 100644 --- a/src/core/lib/security/security_connector/ssl_utils.cc +++ b/src/core/lib/security/security_connector/ssl_utils.cc @@ -27,9 +27,9 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/global_config.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/context/security_context.h" @@ -136,13 +136,12 @@ grpc_error* grpc_ssl_check_alpn(const tsi_peer* peer) { return GRPC_ERROR_NONE; } -grpc_error* grpc_ssl_check_peer_name(grpc_core::StringView peer_name, +grpc_error* grpc_ssl_check_peer_name(const char* peer_name, const tsi_peer* peer) { /* Check the peer name if specified. */ - if (!peer_name.empty() && !grpc_ssl_host_matches_name(peer, peer_name)) { + if (peer_name != nullptr && !grpc_ssl_host_matches_name(peer, peer_name)) { char* msg; - gpr_asprintf(&msg, "Peer name %s is not in peer certificate", - peer_name.data()); + gpr_asprintf(&msg, "Peer name %s is not in peer certificate", peer_name); grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg); gpr_free(msg); return error; @@ -150,16 +149,15 @@ grpc_error* grpc_ssl_check_peer_name(grpc_core::StringView peer_name, return GRPC_ERROR_NONE; } -bool grpc_ssl_check_call_host(grpc_core::StringView host, - grpc_core::StringView target_name, - grpc_core::StringView overridden_target_name, +bool grpc_ssl_check_call_host(const char* host, const char* target_name, + const char* overridden_target_name, grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) { grpc_security_status status = GRPC_SECURITY_ERROR; tsi_peer peer = grpc_shallow_peer_from_ssl_auth_context(auth_context); if (grpc_ssl_host_matches_name(&peer, host)) status = GRPC_SECURITY_OK; - if (!overridden_target_name.empty() && host == target_name) { + if (overridden_target_name != nullptr && strcmp(host, target_name) == 0) { status = GRPC_SECURITY_OK; } if (status != GRPC_SECURITY_OK) { @@ -181,28 +179,35 @@ const char** grpc_fill_alpn_protocol_strings(size_t* num_alpn_protocols) { return alpn_protocol_strings; } -int grpc_ssl_host_matches_name(const tsi_peer* peer, - grpc_core::StringView peer_name) { - grpc_core::StringView allocated_name; - grpc_core::StringView ignored_port; - grpc_core::SplitHostPort(peer_name, &allocated_name, &ignored_port); - if (allocated_name.empty()) return 0; +int grpc_ssl_host_matches_name(const tsi_peer* peer, const char* peer_name) { + char* allocated_name = nullptr; + int r; + + char* ignored_port; + gpr_split_host_port(peer_name, &allocated_name, &ignored_port); + gpr_free(ignored_port); + peer_name = allocated_name; + if (!peer_name) return 0; // IPv6 zone-id should not be included in comparisons. - const size_t zone_id = allocated_name.find('%'); - if (zone_id != grpc_core::StringView::npos) { - allocated_name.remove_suffix(allocated_name.size() - zone_id); - } - return tsi_ssl_peer_matches_name(peer, allocated_name); + char* const zone_id = strchr(allocated_name, '%'); + if (zone_id != nullptr) *zone_id = '\0'; + + r = tsi_ssl_peer_matches_name(peer, peer_name); + gpr_free(allocated_name); + return r; } -int grpc_ssl_cmp_target_name( - grpc_core::StringView target_name, grpc_core::StringView other_target_name, - grpc_core::StringView overridden_target_name, - grpc_core::StringView other_overridden_target_name) { - int c = target_name.cmp(other_target_name); +bool grpc_ssl_cmp_target_name(const char* target_name, + const char* other_target_name, + const char* overridden_target_name, + const char* other_overridden_target_name) { + int c = strcmp(target_name, other_target_name); if (c != 0) return c; - return overridden_target_name.cmp(other_overridden_target_name); + return (overridden_target_name == nullptr || + other_overridden_target_name == nullptr) + ? GPR_ICMP(overridden_target_name, other_overridden_target_name) + : strcmp(overridden_target_name, other_overridden_target_name); } grpc_core::RefCountedPtr grpc_ssl_peer_to_auth_context( diff --git a/src/core/lib/security/security_connector/ssl_utils.h b/src/core/lib/security/security_connector/ssl_utils.h index bf8c1de3aae..1765a344c2a 100644 --- a/src/core/lib/security/security_connector/ssl_utils.h +++ b/src/core/lib/security/security_connector/ssl_utils.h @@ -28,7 +28,6 @@ #include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" -#include "src/core/lib/gprpp/string_view.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/security/security_connector/security_connector.h" #include "src/core/tsi/ssl_transport_security.h" @@ -47,17 +46,16 @@ GPR_GLOBAL_CONFIG_DECLARE_BOOL(grpc_not_use_system_ssl_roots); grpc_error* grpc_ssl_check_alpn(const tsi_peer* peer); /* Check peer name information returned from SSL handshakes. */ -grpc_error* grpc_ssl_check_peer_name(grpc_core::StringView peer_name, +grpc_error* grpc_ssl_check_peer_name(const char* peer_name, const tsi_peer* peer); /* Compare targer_name information extracted from SSL security connectors. */ -int grpc_ssl_cmp_target_name( - grpc_core::StringView target_name, grpc_core::StringView other_target_name, - grpc_core::StringView overridden_target_name, - grpc_core::StringView other_overridden_target_name); +bool grpc_ssl_cmp_target_name(const char* target_name, + const char* other_target_name, + const char* overridden_target_name, + const char* other_overridden_target_name); /* Check the host that will be set for a call is acceptable.*/ -bool grpc_ssl_check_call_host(grpc_core::StringView host, - grpc_core::StringView target_name, - grpc_core::StringView overridden_target_name, +bool grpc_ssl_check_call_host(const char* host, const char* target_name, + const char* overridden_target_name, grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error); @@ -91,8 +89,7 @@ grpc_core::RefCountedPtr grpc_ssl_peer_to_auth_context( tsi_peer grpc_shallow_peer_from_ssl_auth_context( const grpc_auth_context* auth_context); void grpc_shallow_peer_destruct(tsi_peer* peer); -int grpc_ssl_host_matches_name(const tsi_peer* peer, - grpc_core::StringView peer_name); +int grpc_ssl_host_matches_name(const tsi_peer* peer, const char* peer_name); /* --- Default SSL Root Store. --- */ namespace grpc_core { diff --git a/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc b/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc index 5853de4fc13..ebf9c905079 100644 --- a/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +++ b/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc @@ -28,7 +28,7 @@ #include #include -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/security/credentials/ssl/ssl_credentials.h" #include "src/core/lib/security/credentials/tls/spiffe_credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" @@ -105,13 +105,18 @@ SpiffeChannelSecurityConnector::SpiffeChannelSecurityConnector( ? nullptr : gpr_strdup(overridden_target_name)) { check_arg_ = ServerAuthorizationCheckArgCreate(this); - grpc_core::StringView host; - grpc_core::StringView port; - grpc_core::SplitHostPort(target_name, &host, &port); - target_name_ = host.dup(); + char* port; + gpr_split_host_port(target_name, &target_name_, &port); + gpr_free(port); } SpiffeChannelSecurityConnector::~SpiffeChannelSecurityConnector() { + if (target_name_ != nullptr) { + gpr_free(target_name_); + } + if (overridden_target_name_ != nullptr) { + gpr_free(overridden_target_name_); + } if (client_handshaker_factory_ != nullptr) { tsi_ssl_client_handshaker_factory_unref(client_handshaker_factory_); } @@ -125,8 +130,8 @@ void SpiffeChannelSecurityConnector::add_handshakers( tsi_handshaker* tsi_hs = nullptr; tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker( client_handshaker_factory_, - overridden_target_name_ != nullptr ? overridden_target_name_.get() - : target_name_.get(), + overridden_target_name_ != nullptr ? overridden_target_name_ + : target_name_, &tsi_hs); if (result != TSI_OK) { gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.", @@ -142,8 +147,8 @@ void SpiffeChannelSecurityConnector::check_peer( grpc_core::RefCountedPtr* auth_context, grpc_closure* on_peer_checked) { const char* target_name = overridden_target_name_ != nullptr - ? overridden_target_name_.get() - : target_name_.get(); + ? overridden_target_name_ + : target_name_; grpc_error* error = grpc_ssl_check_alpn(&peer); if (error != GRPC_ERROR_NONE) { GRPC_CLOSURE_SCHED(on_peer_checked, error); @@ -198,17 +203,16 @@ int SpiffeChannelSecurityConnector::cmp( if (c != 0) { return c; } - return grpc_ssl_cmp_target_name(target_name_.get(), other->target_name_.get(), - overridden_target_name_.get(), - other->overridden_target_name_.get()); + return grpc_ssl_cmp_target_name(target_name_, other->target_name_, + overridden_target_name_, + other->overridden_target_name_); } bool SpiffeChannelSecurityConnector::check_call_host( - grpc_core::StringView host, grpc_auth_context* auth_context, + const char* host, grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) { - return grpc_ssl_check_call_host(host, target_name_.get(), - overridden_target_name_.get(), auth_context, - on_call_host_checked, error); + return grpc_ssl_check_call_host(host, target_name_, overridden_target_name_, + auth_context, on_call_host_checked, error); } void SpiffeChannelSecurityConnector::cancel_check_call_host( diff --git a/src/core/lib/security/security_connector/tls/spiffe_security_connector.h b/src/core/lib/security/security_connector/tls/spiffe_security_connector.h index 5ea00ee85b6..56972153e07 100644 --- a/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +++ b/src/core/lib/security/security_connector/tls/spiffe_security_connector.h @@ -53,8 +53,7 @@ class SpiffeChannelSecurityConnector final int cmp(const grpc_security_connector* other_sc) const override; - bool check_call_host(grpc_core::StringView host, - grpc_auth_context* auth_context, + bool check_call_host(const char* host, grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) override; @@ -84,8 +83,8 @@ class SpiffeChannelSecurityConnector final grpc_tls_server_authorization_check_arg* arg); grpc_closure* on_peer_checked_; - grpc_core::UniquePtr target_name_; - grpc_core::UniquePtr overridden_target_name_; + char* target_name_; + char* overridden_target_name_; tsi_ssl_client_handshaker_factory* client_handshaker_factory_ = nullptr; grpc_tls_server_authorization_check_arg* check_arg_; }; diff --git a/src/core/lib/security/transport/client_auth_filter.cc b/src/core/lib/security/transport/client_auth_filter.cc index 33343d276eb..1062fc2f4fa 100644 --- a/src/core/lib/security/transport/client_auth_filter.cc +++ b/src/core/lib/security/transport/client_auth_filter.cc @@ -346,7 +346,7 @@ static void auth_start_transport_stream_op_batch( GRPC_CALL_STACK_REF(calld->owning_call, "check_call_host"); GRPC_CLOSURE_INIT(&calld->async_result_closure, on_host_checked, batch, grpc_schedule_on_exec_ctx); - grpc_core::StringView call_host(calld->host); + char* call_host = grpc_slice_to_c_string(calld->host); grpc_error* error = GRPC_ERROR_NONE; if (chand->security_connector->check_call_host( call_host, chand->auth_context.get(), @@ -360,6 +360,7 @@ static void auth_start_transport_stream_op_batch( &calld->check_call_host_cancel_closure, cancel_check_call_host, elem, grpc_schedule_on_exec_ctx)); } + gpr_free(call_host); return; /* early exit */ } } diff --git a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc index 0d28303e7dd..1b7e58d3ce0 100644 --- a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +++ b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc @@ -30,6 +30,7 @@ #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/slice/slice_internal.h" diff --git a/src/core/tsi/ssl_transport_security.cc b/src/core/tsi/ssl_transport_security.cc index d3c8982c847..25ae2cee285 100644 --- a/src/core/tsi/ssl_transport_security.cc +++ b/src/core/tsi/ssl_transport_security.cc @@ -233,10 +233,11 @@ static void ssl_info_callback(const SSL* ssl, int where, int ret) { /* Returns 1 if name looks like an IP address, 0 otherwise. This is a very rough heuristic, and only handles IPv6 in hexadecimal form. */ -static int looks_like_ip_address(grpc_core::StringView name) { +static int looks_like_ip_address(const char* name) { + size_t i; size_t dot_count = 0; size_t num_size = 0; - for (size_t i = 0; i < name.size(); ++i) { + for (i = 0; i < strlen(name); i++) { if (name[i] == ':') { /* IPv6 Address in hexadecimal form, : is not allowed in DNS names. */ return 1; @@ -1505,46 +1506,52 @@ static void tsi_ssl_server_handshaker_factory_destroy( gpr_free(self); } -static int does_entry_match_name(grpc_core::StringView entry, - grpc_core::StringView name) { - if (entry.empty()) return 0; +static int does_entry_match_name(const char* entry, size_t entry_length, + const char* name) { + const char* dot; + const char* name_subdomain = nullptr; + size_t name_length = strlen(name); + size_t name_subdomain_length; + if (entry_length == 0) return 0; /* Take care of '.' terminations. */ - if (name.back() == '.') { - name.remove_suffix(1); + if (name[name_length - 1] == '.') { + name_length--; } - if (entry.back() == '.') { - entry.remove_suffix(1); - if (entry.empty()) return 0; + if (entry[entry_length - 1] == '.') { + entry_length--; + if (entry_length == 0) return 0; } - if (name == entry) { + if ((name_length == entry_length) && + strncmp(name, entry, entry_length) == 0) { return 1; /* Perfect match. */ } - if (entry.front() != '*') return 0; + if (entry[0] != '*') return 0; /* Wildchar subdomain matching. */ - if (entry.size() < 3 || entry[1] != '.') { /* At least *.x */ + if (entry_length < 3 || entry[1] != '.') { /* At least *.x */ gpr_log(GPR_ERROR, "Invalid wildchar entry."); return 0; } - size_t name_subdomain_pos = name.find('.'); - if (name_subdomain_pos == grpc_core::StringView::npos) return 0; - if (name_subdomain_pos >= name.size() - 2) return 0; - grpc_core::StringView name_subdomain = - name.substr(name_subdomain_pos + 1); /* Starts after the dot. */ - entry.remove_prefix(2); /* Remove *. */ - size_t dot = name_subdomain.find('.'); - if (dot == grpc_core::StringView::npos || dot == name_subdomain.size() - 1) { - grpc_core::UniquePtr name_subdomain_cstr(name_subdomain.dup()); - gpr_log(GPR_ERROR, "Invalid toplevel subdomain: %s", - name_subdomain_cstr.get()); + name_subdomain = strchr(name, '.'); + if (name_subdomain == nullptr) return 0; + name_subdomain_length = strlen(name_subdomain); + if (name_subdomain_length < 2) return 0; + name_subdomain++; /* Starts after the dot. */ + name_subdomain_length--; + entry += 2; /* Remove *. */ + entry_length -= 2; + dot = strchr(name_subdomain, '.'); + if ((dot == nullptr) || (dot == &name_subdomain[name_subdomain_length - 1])) { + gpr_log(GPR_ERROR, "Invalid toplevel subdomain: %s", name_subdomain); return 0; } - if (name_subdomain.back() == '.') { - name_subdomain.remove_suffix(1); + if (name_subdomain[name_subdomain_length - 1] == '.') { + name_subdomain_length--; } - return !entry.empty() && name_subdomain == entry; + return ((entry_length > 0) && (name_subdomain_length == entry_length) && + strncmp(entry, name_subdomain, entry_length) == 0); } static int ssl_server_handshaker_factory_servername_callback(SSL* ssl, int* ap, @@ -1912,8 +1919,7 @@ tsi_result tsi_create_ssl_server_handshaker_factory_with_options( /* --- tsi_ssl utils. --- */ -int tsi_ssl_peer_matches_name(const tsi_peer* peer, - grpc_core::StringView name) { +int tsi_ssl_peer_matches_name(const tsi_peer* peer, const char* name) { size_t i = 0; size_t san_count = 0; const tsi_peer_property* cn_property = nullptr; @@ -1927,10 +1933,13 @@ int tsi_ssl_peer_matches_name(const tsi_peer* peer, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY) == 0) { san_count++; - grpc_core::StringView entry(property->value.data, property->value.length); - if (!like_ip && does_entry_match_name(entry, name)) { + if (!like_ip && does_entry_match_name(property->value.data, + property->value.length, name)) { return 1; - } else if (like_ip && name == entry) { + } else if (like_ip && + strncmp(name, property->value.data, property->value.length) == + 0 && + strlen(name) == property->value.length) { /* IP Addresses are exact matches only. */ return 1; } @@ -1942,9 +1951,8 @@ int tsi_ssl_peer_matches_name(const tsi_peer* peer, /* If there's no SAN, try the CN, but only if its not like an IP Address */ if (san_count == 0 && cn_property != nullptr && !like_ip) { - if (does_entry_match_name(grpc_core::StringView(cn_property->value.data, - cn_property->value.length), - name)) { + if (does_entry_match_name(cn_property->value.data, + cn_property->value.length, name)) { return 1; } } diff --git a/src/core/tsi/ssl_transport_security.h b/src/core/tsi/ssl_transport_security.h index 0203141e56e..769949e4aad 100644 --- a/src/core/tsi/ssl_transport_security.h +++ b/src/core/tsi/ssl_transport_security.h @@ -21,7 +21,6 @@ #include -#include "src/core/lib/gprpp/string_view.h" #include "src/core/tsi/transport_security_interface.h" /* Value for the TSI_CERTIFICATE_TYPE_PEER_PROPERTY property for X509 certs. */ @@ -307,7 +306,7 @@ void tsi_ssl_server_handshaker_factory_unref( - handle mixed case. - handle %encoded chars. - handle public suffix wildchar more strictly (e.g. *.co.uk) */ -int tsi_ssl_peer_matches_name(const tsi_peer* peer, grpc_core::StringView name); +int tsi_ssl_peer_matches_name(const tsi_peer* peer, const char* name); /* --- Testing support. --- diff --git a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm index ad426014a5b..a24734024dc 100644 --- a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm +++ b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm @@ -37,9 +37,9 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" @@ -51,18 +51,19 @@ #import "../ConfigureCronet.h" -struct fullstack_secure_fixture_data { - grpc_core::UniquePtr localaddr; -}; +typedef struct fullstack_secure_fixture_data { + char *localaddr; +} fullstack_secure_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args *client_args, grpc_channel_args *server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_secure_fixture_data *ffd = grpc_core::New(); + fullstack_secure_fixture_data *ffd = + (fullstack_secure_fixture_data *)gpr_malloc(sizeof(fullstack_secure_fixture_data)); memset(&f, 0, sizeof(f)); - grpc_core::JoinHostPort(&ffd->localaddr, "127.0.0.1", port); + gpr_join_host_port(&ffd->localaddr, "127.0.0.1", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(NULL); @@ -82,8 +83,7 @@ static void cronet_init_client_secure_fullstack(grpc_end2end_test_fixture *f, grpc_channel_args *client_args, stream_engine *cronetEngine) { fullstack_secure_fixture_data *ffd = (fullstack_secure_fixture_data *)f->fixture_data; - f->client = - grpc_cronet_secure_channel_create(cronetEngine, ffd->localaddr.get(), client_args, NULL); + f->client = grpc_cronet_secure_channel_create(cronetEngine, ffd->localaddr, client_args, NULL); GPR_ASSERT(f->client != NULL); } @@ -96,14 +96,15 @@ static void chttp2_init_server_secure_fullstack(grpc_end2end_test_fixture *f, } f->server = grpc_server_create(server_args, NULL); grpc_server_register_completion_queue(f->server, f->cq, NULL); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), server_creds)); + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); } static void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { fullstack_secure_fixture_data *ffd = (fullstack_secure_fixture_data *)f->fixture_data; - grpc_core::Delete(ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } static void cronet_init_client_simple_ssl_secure_fullstack(grpc_end2end_test_fixture *f, diff --git a/src/objective-c/tests/CronetTests/CronetUnitTests.mm b/src/objective-c/tests/CronetTests/CronetUnitTests.mm index 4e2e70f1512..2473cf612be 100644 --- a/src/objective-c/tests/CronetTests/CronetUnitTests.mm +++ b/src/objective-c/tests/CronetTests/CronetUnitTests.mm @@ -33,9 +33,9 @@ #import "src/core/lib/channel/channel_args.h" #import "src/core/lib/gpr/env.h" +#import "src/core/lib/gpr/host_port.h" #import "src/core/lib/gpr/string.h" #import "src/core/lib/gpr/tmpfile.h" -#import "src/core/lib/gprpp/host_port.h" #import "test/core/end2end/data/ssl_test_data.h" #import "test/core/util/test_config.h" @@ -133,11 +133,11 @@ unsigned int parse_h2_length(const char *field) { {{NULL, NULL, NULL, NULL}}}}; int port = grpc_pick_unused_port_or_die(); - grpc_core::UniquePtr addr; - grpc_core::JoinHostPort(&addr, "127.0.0.1", port); + char *addr; + gpr_join_host_port(&addr, "127.0.0.1", port); grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); stream_engine *cronetEngine = [Cronet getGlobalEngine]; - grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr.get(), NULL, NULL); + grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr, NULL, NULL); cq_verifier *cqv = cq_verifier_create(cq); grpc_op ops[6]; @@ -264,11 +264,11 @@ unsigned int parse_h2_length(const char *field) { {{NULL, NULL, NULL, NULL}}}}; int port = grpc_pick_unused_port_or_die(); - grpc_core::UniquePtr addr; - grpc_core::JoinHostPort(&addr, "127.0.0.1", port); + char *addr; + gpr_join_host_port(&addr, "127.0.0.1", port); grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); stream_engine *cronetEngine = [Cronet getGlobalEngine]; - grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr.get(), args, NULL); + grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr, args, NULL); cq_verifier *cqv = cq_verifier_create(cq); grpc_op ops[6]; diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index c7caee551ce..2619ccf9740 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -27,6 +27,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/gpr/env_linux.cc', 'src/core/lib/gpr/env_posix.cc', 'src/core/lib/gpr/env_windows.cc', + 'src/core/lib/gpr/host_port.cc', 'src/core/lib/gpr/log.cc', 'src/core/lib/gpr/log_android.cc', 'src/core/lib/gpr/log_linux.cc', @@ -53,7 +54,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/gprpp/arena.cc', 'src/core/lib/gprpp/fork.cc', 'src/core/lib/gprpp/global_config_env.cc', - 'src/core/lib/gprpp/host_port.cc', 'src/core/lib/gprpp/thd_posix.cc', 'src/core/lib/gprpp/thd_windows.cc', 'src/core/lib/profiling/basic_timers.cc', diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc index deae9072613..8dd55f64944 100644 --- a/test/core/bad_ssl/bad_ssl_test.cc +++ b/test/core/bad_ssl/bad_ssl_test.cc @@ -25,9 +25,8 @@ #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/host_port.h" -#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" @@ -145,9 +144,7 @@ int main(int argc, char** argv) { gpr_asprintf(&args[0], "%s/bad_ssl_%s_server%s", root, test, gpr_subprocess_binary_extension()); args[1] = const_cast("--bind"); - grpc_core::UniquePtr joined; - grpc_core::JoinHostPort(&joined, "::", port); - args[2] = joined.get(); + gpr_join_host_port(&args[2], "::", port); svr = gpr_subprocess_create(4, (const char**)args); gpr_free(args[0]); @@ -156,6 +153,7 @@ int main(int argc, char** argv) { run_test(args[2], i); grpc_shutdown(); } + gpr_free(args[2]); gpr_subprocess_interrupt(svr); status = gpr_subprocess_join(svr); diff --git a/test/core/client_channel/parse_address_with_named_scope_id_test.cc b/test/core/client_channel/parse_address_with_named_scope_id_test.cc index 071fb88b734..bfafa745178 100644 --- a/test/core/client_channel/parse_address_with_named_scope_id_test.cc +++ b/test/core/client_channel/parse_address_with_named_scope_id_test.cc @@ -30,8 +30,7 @@ #include #include -#include "src/core/lib/gprpp/host_port.h" -#include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/socket_utils.h" #include "test/core/util/test_config.h" @@ -61,20 +60,20 @@ static void test_grpc_parse_ipv6_parity_with_getaddrinfo( struct sockaddr_in6 resolve_with_gettaddrinfo(const char* uri_text) { grpc_uri* uri = grpc_uri_parse(uri_text, 0); - grpc_core::UniquePtr host; - grpc_core::UniquePtr port; - grpc_core::SplitHostPort(uri->path, &host, &port); + char* host = nullptr; + char* port = nullptr; + gpr_split_host_port(uri->path, &host, &port); struct addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET6; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_NUMERICHOST; struct addrinfo* result; - int res = getaddrinfo(host.get(), port.get(), &hints, &result); + int res = getaddrinfo(host, port, &hints, &result); if (res != 0) { gpr_log(GPR_ERROR, - "getaddrinfo failed to resolve host:%s port:%s. Error: %d.", - host.get(), port.get(), res); + "getaddrinfo failed to resolve host:%s port:%s. Error: %d.", host, + port, res); abort(); } size_t num_addrs_from_getaddrinfo = 0; @@ -87,6 +86,8 @@ struct sockaddr_in6 resolve_with_gettaddrinfo(const char* uri_text) { *reinterpret_cast(result->ai_addr); // Cleanup freeaddrinfo(result); + gpr_free(host); + gpr_free(port); grpc_uri_destroy(uri); return out; } diff --git a/test/core/end2end/bad_server_response_test.cc b/test/core/end2end/bad_server_response_test.cc index db480463b68..2d74b6b77b3 100644 --- a/test/core/end2end/bad_server_response_test.cc +++ b/test/core/end2end/bad_server_response_test.cc @@ -29,8 +29,8 @@ #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/sockaddr.h" @@ -71,7 +71,7 @@ #define SERVER_INCOMING_DATA_LENGTH_LOWER_THRESHOLD (size_t)200 struct rpc_state { - grpc_core::UniquePtr target; + char* target; grpc_completion_queue* cq; grpc_channel* channel; grpc_call* call; @@ -165,9 +165,8 @@ static void start_rpc(int target_port, grpc_status_code expected_status, state.cq = grpc_completion_queue_create_for_next(nullptr); cqv = cq_verifier_create(state.cq); - grpc_core::JoinHostPort(&state.target, "127.0.0.1", target_port); - state.channel = - grpc_insecure_channel_create(state.target.get(), nullptr, nullptr); + gpr_join_host_port(&state.target, "127.0.0.1", target_port); + state.channel = grpc_insecure_channel_create(state.target, nullptr, nullptr); grpc_slice host = grpc_slice_from_static_string("localhost"); state.call = grpc_channel_create_call( state.channel, nullptr, GRPC_PROPAGATE_DEFAULTS, state.cq, @@ -231,7 +230,7 @@ static void cleanup_rpc() { } while (ev.type != GRPC_QUEUE_SHUTDOWN); grpc_completion_queue_destroy(state.cq); grpc_channel_destroy(state.channel); - state.target.reset(); + gpr_free(state.target); } typedef struct { diff --git a/test/core/end2end/connection_refused_test.cc b/test/core/end2end/connection_refused_test.cc index 3bb6d2e23b6..446e7b045a1 100644 --- a/test/core/end2end/connection_refused_test.cc +++ b/test/core/end2end/connection_refused_test.cc @@ -24,7 +24,7 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata.h" @@ -77,10 +77,10 @@ static void run_test(bool wait_for_ready, bool use_service_config) { /* create a call, channel to a port which will refuse connection */ int port = grpc_pick_unused_port_or_die(); - grpc_core::UniquePtr addr; - grpc_core::JoinHostPort(&addr, "127.0.0.1", port); - gpr_log(GPR_INFO, "server: %s", addr.get()); - chan = grpc_insecure_channel_create(addr.get(), args, nullptr); + char* addr; + gpr_join_host_port(&addr, "127.0.0.1", port); + gpr_log(GPR_INFO, "server: %s", addr); + chan = grpc_insecure_channel_create(addr, args, nullptr); grpc_slice host = grpc_slice_from_static_string("nonexistant"); gpr_timespec deadline = grpc_timeout_seconds_to_deadline(2); call = @@ -88,6 +88,8 @@ static void run_test(bool wait_for_ready, bool use_service_config) { grpc_slice_from_static_string("/service/method"), &host, deadline, nullptr); + gpr_free(addr); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; diff --git a/test/core/end2end/dualstack_socket_test.cc b/test/core/end2end/dualstack_socket_test.cc index cb49e0030b4..330af8fce07 100644 --- a/test/core/end2end/dualstack_socket_test.cc +++ b/test/core/end2end/dualstack_socket_test.cc @@ -28,8 +28,8 @@ #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/sockaddr_utils.h" @@ -70,6 +70,8 @@ static void log_resolved_addrs(const char* label, const char* hostname) { void test_connect(const char* server_host, const char* client_host, int port, int expect_ok) { + char* client_hostport; + char* server_hostport; grpc_channel* client; grpc_server* server; grpc_completion_queue* cq; @@ -97,8 +99,7 @@ void test_connect(const char* server_host, const char* client_host, int port, picked_port = 1; } - grpc_core::UniquePtr server_hostport; - grpc_core::JoinHostPort(&server_hostport, server_host, port); + gpr_join_host_port(&server_hostport, server_host, port); grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); @@ -110,7 +111,7 @@ void test_connect(const char* server_host, const char* client_host, int port, server = grpc_server_create(nullptr, nullptr); grpc_server_register_completion_queue(server, cq, nullptr); GPR_ASSERT((got_port = grpc_server_add_insecure_http2_port( - server, server_hostport.get())) > 0); + server, server_hostport)) > 0); if (port == 0) { port = got_port; } else { @@ -120,7 +121,6 @@ void test_connect(const char* server_host, const char* client_host, int port, cqv = cq_verifier_create(cq); /* Create client. */ - grpc_core::UniquePtr client_hostport; if (client_host[0] == 'i') { /* for ipv4:/ipv6: addresses, concatenate the port to each of the parts */ size_t i; @@ -139,8 +139,8 @@ void test_connect(const char* server_host, const char* client_host, int port, gpr_asprintf(&hosts_with_port[i], "%s:%d", uri_part_str, port); gpr_free(uri_part_str); } - client_hostport.reset(gpr_strjoin_sep((const char**)hosts_with_port, - uri_parts.count, ",", nullptr)); + client_hostport = gpr_strjoin_sep((const char**)hosts_with_port, + uri_parts.count, ",", nullptr); for (i = 0; i < uri_parts.count; i++) { gpr_free(hosts_with_port[i]); } @@ -148,17 +148,18 @@ void test_connect(const char* server_host, const char* client_host, int port, grpc_slice_buffer_destroy(&uri_parts); grpc_slice_unref(uri_slice); } else { - grpc_core::JoinHostPort(&client_hostport, client_host, port); + gpr_join_host_port(&client_hostport, client_host, port); } - client = - grpc_insecure_channel_create(client_hostport.get(), nullptr, nullptr); + client = grpc_insecure_channel_create(client_hostport, nullptr, nullptr); gpr_log(GPR_INFO, "Testing with server=%s client=%s (expecting %s)", - server_hostport.get(), client_hostport.get(), - expect_ok ? "success" : "failure"); + server_hostport, client_hostport, expect_ok ? "success" : "failure"); log_resolved_addrs("server resolved addr", server_host); log_resolved_addrs("client resolved addr", client_host); + gpr_free(client_hostport); + gpr_free(server_hostport); + if (expect_ok) { /* Normal deadline, shouldn't be reached. */ deadline = grpc_timeout_milliseconds_to_deadline(60000); diff --git a/test/core/end2end/fixtures/h2_census.cc b/test/core/end2end/fixtures/h2_census.cc index 72cb96138e1..60442ddcc77 100644 --- a/test/core/end2end/fixtures/h2_census.cc +++ b/test/core/end2end/fixtures/h2_census.cc @@ -29,23 +29,25 @@ #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -struct fullstack_fixture_data { - grpc_core::UniquePtr localaddr; -}; +typedef struct fullstack_fixture_data { + char* localaddr; +} fullstack_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = grpc_core::New(); + fullstack_fixture_data* ffd = static_cast( + gpr_malloc(sizeof(fullstack_fixture_data))); memset(&f, 0, sizeof(f)); - grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); + + gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -69,7 +71,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, grpc_arg arg = make_census_enable_arg(); client_args = grpc_channel_args_copy_and_add(client_args, &arg, 1); f->client = - grpc_insecure_channel_create(ffd->localaddr.get(), client_args, nullptr); + grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr); GPR_ASSERT(f->client); { grpc_core::ExecCtx exec_ctx; @@ -92,15 +94,15 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, grpc_channel_args_destroy(server_args); } grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT( - grpc_server_add_insecure_http2_port(f->server, ffd->localaddr.get())); + GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); grpc_server_start(f->server); } void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_compress.cc b/test/core/end2end/fixtures/h2_compress.cc index dd0c1fe0201..01e5ae1b7b5 100644 --- a/test/core/end2end/fixtures/h2_compress.cc +++ b/test/core/end2end/fixtures/h2_compress.cc @@ -30,29 +30,28 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/compression/compression_args.h" -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -struct fullstack_compression_fixture_data { - ~fullstack_compression_fixture_data() { - grpc_channel_args_destroy(client_args_compression); - grpc_channel_args_destroy(server_args_compression); - } - grpc_core::UniquePtr localaddr; - grpc_channel_args* client_args_compression = nullptr; - grpc_channel_args* server_args_compression = nullptr; -}; +typedef struct fullstack_compression_fixture_data { + char* localaddr; + grpc_channel_args* client_args_compression; + grpc_channel_args* server_args_compression; +} fullstack_compression_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_compression( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_compression_fixture_data* ffd = - grpc_core::New(); - grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); + static_cast( + gpr_malloc(sizeof(fullstack_compression_fixture_data))); + memset(ffd, 0, sizeof(fullstack_compression_fixture_data)); + + gpr_join_host_port(&ffd->localaddr, "localhost", port); memset(&f, 0, sizeof(f)); f.fixture_data = ffd; @@ -74,7 +73,7 @@ void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture* f, grpc_channel_args_set_channel_default_compression_algorithm( client_args, GRPC_COMPRESS_GZIP); f->client = grpc_insecure_channel_create( - ffd->localaddr.get(), ffd->client_args_compression, nullptr); + ffd->localaddr, ffd->client_args_compression, nullptr); } void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture* f, @@ -93,8 +92,7 @@ void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture* f, } f->server = grpc_server_create(ffd->server_args_compression, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT( - grpc_server_add_insecure_http2_port(f->server, ffd->localaddr.get())); + GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); grpc_server_start(f->server); } @@ -102,7 +100,10 @@ void chttp2_tear_down_fullstack_compression(grpc_end2end_test_fixture* f) { grpc_core::ExecCtx exec_ctx; fullstack_compression_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + grpc_channel_args_destroy(ffd->client_args_compression); + grpc_channel_args_destroy(ffd->server_args_compression); + gpr_free(ffd->localaddr); + gpr_free(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_fakesec.cc b/test/core/end2end/fixtures/h2_fakesec.cc index 1375549ed6c..ad83aab39f4 100644 --- a/test/core/end2end/fixtures/h2_fakesec.cc +++ b/test/core/end2end/fixtures/h2_fakesec.cc @@ -25,24 +25,26 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -struct fullstack_secure_fixture_data { - grpc_core::UniquePtr localaddr; -}; +typedef struct fullstack_secure_fixture_data { + char* localaddr; +} fullstack_secure_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = - grpc_core::New(); + static_cast( + gpr_malloc(sizeof(fullstack_secure_fixture_data))); + memset(&f, 0, sizeof(f)); - grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); + gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -64,8 +66,8 @@ static void chttp2_init_client_secure_fullstack( grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), - client_args, nullptr); + f->client = + grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -80,7 +82,7 @@ static void chttp2_init_server_secure_fullstack( } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); @@ -89,7 +91,8 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } static void chttp2_init_client_fake_secure_fullstack( diff --git a/test/core/end2end/fixtures/h2_full+pipe.cc b/test/core/end2end/fixtures/h2_full+pipe.cc index ac4913674f0..6d559c4e516 100644 --- a/test/core/end2end/fixtures/h2_full+pipe.cc +++ b/test/core/end2end/fixtures/h2_full+pipe.cc @@ -33,25 +33,26 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -struct fullstack_fixture_data { - grpc_core::UniquePtr localaddr; -}; +typedef struct fullstack_fixture_data { + char* localaddr; +} fullstack_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = grpc_core::New(); + fullstack_fixture_data* ffd = static_cast( + gpr_malloc(sizeof(fullstack_fixture_data))); memset(&f, 0, sizeof(f)); - grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); + gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -65,7 +66,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, fullstack_fixture_data* ffd = static_cast(f->fixture_data); f->client = - grpc_insecure_channel_create(ffd->localaddr.get(), client_args, nullptr); + grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr); GPR_ASSERT(f->client); } @@ -78,15 +79,15 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT( - grpc_server_add_insecure_http2_port(f->server, ffd->localaddr.get())); + GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); grpc_server_start(f->server); } void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_full+trace.cc b/test/core/end2end/fixtures/h2_full+trace.cc index 04de2a20182..b8dbe261183 100644 --- a/test/core/end2end/fixtures/h2_full+trace.cc +++ b/test/core/end2end/fixtures/h2_full+trace.cc @@ -34,24 +34,25 @@ #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/debug/trace.h" -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -struct fullstack_fixture_data { - grpc_core::UniquePtr localaddr; -}; +typedef struct fullstack_fixture_data { + char* localaddr; +} fullstack_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = grpc_core::New(); + fullstack_fixture_data* ffd = static_cast( + gpr_malloc(sizeof(fullstack_fixture_data))); memset(&f, 0, sizeof(f)); - grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); + gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -65,7 +66,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, fullstack_fixture_data* ffd = static_cast(f->fixture_data); f->client = - grpc_insecure_channel_create(ffd->localaddr.get(), client_args, nullptr); + grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr); GPR_ASSERT(f->client); } @@ -78,15 +79,15 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT( - grpc_server_add_insecure_http2_port(f->server, ffd->localaddr.get())); + GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); grpc_server_start(f->server); } void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_full+workarounds.cc b/test/core/end2end/fixtures/h2_full+workarounds.cc index 8cfba4587e0..cb0f7d275b3 100644 --- a/test/core/end2end/fixtures/h2_full+workarounds.cc +++ b/test/core/end2end/fixtures/h2_full+workarounds.cc @@ -30,7 +30,7 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" @@ -39,20 +39,24 @@ static char* workarounds_arg[GRPC_MAX_WORKAROUND_ID] = { const_cast(GRPC_ARG_WORKAROUND_CRONET_COMPRESSION)}; -struct fullstack_fixture_data { - grpc_core::UniquePtr localaddr; -}; +typedef struct fullstack_fixture_data { + char* localaddr; +} fullstack_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = grpc_core::New(); + fullstack_fixture_data* ffd = static_cast( + gpr_malloc(sizeof(fullstack_fixture_data))); memset(&f, 0, sizeof(f)); - grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); + + gpr_join_host_port(&ffd->localaddr, "localhost", port); + f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr); + return f; } @@ -61,7 +65,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, fullstack_fixture_data* ffd = static_cast(f->fixture_data); f->client = - grpc_insecure_channel_create(ffd->localaddr.get(), client_args, nullptr); + grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr); GPR_ASSERT(f->client); } @@ -84,8 +88,7 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, } f->server = grpc_server_create(server_args_new, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT( - grpc_server_add_insecure_http2_port(f->server, ffd->localaddr.get())); + GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); grpc_server_start(f->server); grpc_channel_args_destroy(server_args_new); } @@ -93,7 +96,8 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_full.cc b/test/core/end2end/fixtures/h2_full.cc index a3f2f25db5f..c0d21288c7e 100644 --- a/test/core/end2end/fixtures/h2_full.cc +++ b/test/core/end2end/fixtures/h2_full.cc @@ -28,24 +28,25 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -struct fullstack_fixture_data { - grpc_core::UniquePtr localaddr; -}; +typedef struct fullstack_fixture_data { + char* localaddr; +} fullstack_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = grpc_core::New(); + fullstack_fixture_data* ffd = static_cast( + gpr_malloc(sizeof(fullstack_fixture_data))); memset(&f, 0, sizeof(f)); - grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); + gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -59,7 +60,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, fullstack_fixture_data* ffd = static_cast(f->fixture_data); f->client = - grpc_insecure_channel_create(ffd->localaddr.get(), client_args, nullptr); + grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr); GPR_ASSERT(f->client); } @@ -72,15 +73,15 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT( - grpc_server_add_insecure_http2_port(f->server, ffd->localaddr.get())); + GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); grpc_server_start(f->server); } void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_http_proxy.cc b/test/core/end2end/fixtures/h2_http_proxy.cc index 18ba0e7f847..9b6a81494e1 100644 --- a/test/core/end2end/fixtures/h2_http_proxy.cc +++ b/test/core/end2end/fixtures/h2_http_proxy.cc @@ -30,26 +30,26 @@ #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/gpr/env.h" -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/end2end/fixtures/http_proxy_fixture.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -struct fullstack_fixture_data { - ~fullstack_fixture_data() { grpc_end2end_http_proxy_destroy(proxy); } - grpc_core::UniquePtr server_addr; - grpc_end2end_http_proxy* proxy = nullptr; -}; +typedef struct fullstack_fixture_data { + char* server_addr; + grpc_end2end_http_proxy* proxy; +} fullstack_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); - fullstack_fixture_data* ffd = grpc_core::New(); + fullstack_fixture_data* ffd = static_cast( + gpr_malloc(sizeof(fullstack_fixture_data))); const int server_port = grpc_pick_unused_port_or_die(); - grpc_core::JoinHostPort(&ffd->server_addr, "localhost", server_port); + gpr_join_host_port(&ffd->server_addr, "localhost", server_port); /* Passing client_args to proxy_create for the case of checking for proxy auth */ @@ -81,8 +81,8 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, } gpr_setenv("http_proxy", proxy_uri); gpr_free(proxy_uri); - f->client = grpc_insecure_channel_create(ffd->server_addr.get(), client_args, - nullptr); + f->client = + grpc_insecure_channel_create(ffd->server_addr, client_args, nullptr); GPR_ASSERT(f->client); } @@ -95,15 +95,16 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT( - grpc_server_add_insecure_http2_port(f->server, ffd->server_addr.get())); + GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->server_addr)); grpc_server_start(f->server); } void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + gpr_free(ffd->server_addr); + grpc_end2end_http_proxy_destroy(ffd->proxy); + gpr_free(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_local_ipv4.cc b/test/core/end2end/fixtures/h2_local_ipv4.cc index e27844be2df..f6996bf6be3 100644 --- a/test/core/end2end/fixtures/h2_local_ipv4.cc +++ b/test/core/end2end/fixtures/h2_local_ipv4.cc @@ -20,7 +20,7 @@ #include -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "test/core/end2end/end2end_tests.h" #include "test/core/end2end/fixtures/local_util.h" #include "test/core/util/port.h" @@ -31,7 +31,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_ipv4( grpc_end2end_test_fixture f = grpc_end2end_local_chttp2_create_fixture_fullstack(); int port = grpc_pick_unused_port_or_die(); - grpc_core::JoinHostPort( + gpr_join_host_port( &static_cast(f.fixture_data) ->localaddr, "127.0.0.1", port); diff --git a/test/core/end2end/fixtures/h2_local_ipv6.cc b/test/core/end2end/fixtures/h2_local_ipv6.cc index 91acaa347f6..e360727ca82 100644 --- a/test/core/end2end/fixtures/h2_local_ipv6.cc +++ b/test/core/end2end/fixtures/h2_local_ipv6.cc @@ -20,7 +20,7 @@ #include -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "test/core/end2end/end2end_tests.h" #include "test/core/end2end/fixtures/local_util.h" #include "test/core/util/port.h" @@ -31,7 +31,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_ipv6( grpc_end2end_test_fixture f = grpc_end2end_local_chttp2_create_fixture_fullstack(); int port = grpc_pick_unused_port_or_die(); - grpc_core::JoinHostPort( + gpr_join_host_port( &static_cast(f.fixture_data) ->localaddr, "[::1]", port); diff --git a/test/core/end2end/fixtures/h2_local_uds.cc b/test/core/end2end/fixtures/h2_local_uds.cc index 6c748896760..f1bce213dc2 100644 --- a/test/core/end2end/fixtures/h2_local_uds.cc +++ b/test/core/end2end/fixtures/h2_local_uds.cc @@ -30,10 +30,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_uds( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f = grpc_end2end_local_chttp2_create_fixture_fullstack(); - char* out = nullptr; - gpr_asprintf(&out, "unix:/tmp/grpc_fullstack_test.%d.%d", getpid(), unique++); - static_cast(f.fixture_data) - ->localaddr.reset(out); + gpr_asprintf( + &static_cast(f.fixture_data) + ->localaddr, + "unix:/tmp/grpc_fullstack_test.%d.%d", getpid(), unique++); return f; } diff --git a/test/core/end2end/fixtures/h2_oauth2.cc b/test/core/end2end/fixtures/h2_oauth2.cc index 513fded4b62..113a6b11732 100644 --- a/test/core/end2end/fixtures/h2_oauth2.cc +++ b/test/core/end2end/fixtures/h2_oauth2.cc @@ -25,7 +25,7 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/security/credentials/credentials.h" #include "test/core/end2end/data/ssl_test_data.h" @@ -36,9 +36,9 @@ static const char oauth2_md[] = "Bearer aaslkfjs424535asdf"; static const char* client_identity_property_name = "smurf_name"; static const char* client_identity = "Brainy Smurf"; -struct fullstack_secure_fixture_data { - grpc_core::UniquePtr localaddr; -}; +typedef struct fullstack_secure_fixture_data { + char* localaddr; +} fullstack_secure_fixture_data; static const grpc_metadata* find_metadata(const grpc_metadata* md, size_t md_count, const char* key, @@ -95,12 +95,16 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = - grpc_core::New(); + static_cast( + gpr_malloc(sizeof(fullstack_secure_fixture_data))); memset(&f, 0, sizeof(f)); - grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); + + gpr_join_host_port(&ffd->localaddr, "localhost", port); + f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr); + return f; } @@ -109,8 +113,8 @@ static void chttp2_init_client_secure_fullstack( grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), - client_args, nullptr); + f->client = + grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -125,7 +129,7 @@ static void chttp2_init_server_secure_fullstack( } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); @@ -134,7 +138,8 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack( diff --git a/test/core/end2end/fixtures/h2_proxy.cc b/test/core/end2end/fixtures/h2_proxy.cc index f0ada89d14d..e334396ea7c 100644 --- a/test/core/end2end/fixtures/h2_proxy.cc +++ b/test/core/end2end/fixtures/h2_proxy.cc @@ -28,6 +28,7 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/end2end/fixtures/proxy.h" diff --git a/test/core/end2end/fixtures/h2_spiffe.cc b/test/core/end2end/fixtures/h2_spiffe.cc index 4352ef640cd..cdf091bac10 100644 --- a/test/core/end2end/fixtures/h2_spiffe.cc +++ b/test/core/end2end/fixtures/h2_spiffe.cc @@ -28,9 +28,9 @@ #include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/security/credentials/credentials.h" @@ -42,15 +42,10 @@ typedef grpc_core::InlinedVector ThreadList; -struct fullstack_secure_fixture_data { - ~fullstack_secure_fixture_data() { - for (size_t ind = 0; ind < thd_list.size(); ind++) { - thd_list[ind].Join(); - } - } - grpc_core::UniquePtr localaddr; +typedef struct fullstack_secure_fixture_data { + char* localaddr; ThreadList thd_list; -}; +} fullstack_secure_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { @@ -59,7 +54,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( fullstack_secure_fixture_data* ffd = grpc_core::New(); memset(&f, 0, sizeof(f)); - grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); + gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr); @@ -79,8 +74,8 @@ static void chttp2_init_client_secure_fullstack( grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), - client_args, nullptr); + f->client = + grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -95,7 +90,7 @@ static void chttp2_init_server_secure_fullstack( } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); @@ -104,6 +99,10 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); + for (size_t ind = 0; ind < ffd->thd_list.size(); ind++) { + ffd->thd_list[ind].Join(); + } + gpr_free(ffd->localaddr); grpc_core::Delete(ffd); } diff --git a/test/core/end2end/fixtures/h2_ssl.cc b/test/core/end2end/fixtures/h2_ssl.cc index cb55bb72061..3fc9bc7f329 100644 --- a/test/core/end2end/fixtures/h2_ssl.cc +++ b/test/core/end2end/fixtures/h2_ssl.cc @@ -25,28 +25,29 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -struct fullstack_secure_fixture_data { - grpc_core::UniquePtr localaddr; -}; +typedef struct fullstack_secure_fixture_data { + char* localaddr; +} fullstack_secure_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = - grpc_core::New(); + static_cast( + gpr_malloc(sizeof(fullstack_secure_fixture_data))); memset(&f, 0, sizeof(f)); - grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); + gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -68,8 +69,8 @@ static void chttp2_init_client_secure_fullstack( grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), - client_args, nullptr); + f->client = + grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -84,7 +85,7 @@ static void chttp2_init_server_secure_fullstack( } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); @@ -93,7 +94,8 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } static void chttp2_init_client_simple_ssl_secure_fullstack( diff --git a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc index 2a9591845b9..1d54a431364 100644 --- a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc +++ b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc @@ -25,19 +25,19 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -struct fullstack_secure_fixture_data { - grpc_core::UniquePtr localaddr; - bool server_credential_reloaded = false; -}; +typedef struct fullstack_secure_fixture_data { + char* localaddr; + bool server_credential_reloaded; +} fullstack_secure_fixture_data; static grpc_ssl_certificate_config_reload_status ssl_server_certificate_config_callback( @@ -64,9 +64,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = - grpc_core::New(); + static_cast( + gpr_malloc(sizeof(fullstack_secure_fixture_data))); memset(&f, 0, sizeof(f)); - grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); + gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -88,8 +89,8 @@ static void chttp2_init_client_secure_fullstack( grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), - client_args, nullptr); + f->client = + grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -105,7 +106,7 @@ static void chttp2_init_server_secure_fullstack( ffd->server_credential_reloaded = false; f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); @@ -114,7 +115,8 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } static void chttp2_init_client_simple_ssl_secure_fullstack( diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.cc b/test/core/end2end/fixtures/h2_ssl_proxy.cc index b16ffa1b8b8..d5f695b1575 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.cc +++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc @@ -25,6 +25,7 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" diff --git a/test/core/end2end/fixtures/h2_uds.cc b/test/core/end2end/fixtures/h2_uds.cc index 2b6c73d39c7..f251bbd28c5 100644 --- a/test/core/end2end/fixtures/h2_uds.cc +++ b/test/core/end2end/fixtures/h2_uds.cc @@ -31,6 +31,7 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc index da2381aa0a0..6b5513f160e 100644 --- a/test/core/end2end/fixtures/http_proxy_fixture.cc +++ b/test/core/end2end/fixtures/http_proxy_fixture.cc @@ -31,8 +31,8 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/http/parser.h" #include "src/core/lib/iomgr/closure.h" @@ -53,7 +53,8 @@ struct grpc_end2end_http_proxy { grpc_end2end_http_proxy() - : server(nullptr), + : proxy_name(nullptr), + server(nullptr), channel_args(nullptr), mu(nullptr), pollset(nullptr), @@ -61,7 +62,7 @@ struct grpc_end2end_http_proxy { gpr_ref_init(&users, 1); combiner = grpc_combiner_create(); } - grpc_core::UniquePtr proxy_name; + char* proxy_name; grpc_core::Thread thd; grpc_tcp_server* server; grpc_channel_args* channel_args; @@ -531,8 +532,8 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create( grpc_end2end_http_proxy* proxy = grpc_core::New(); // Construct proxy address. const int proxy_port = grpc_pick_unused_port_or_die(); - grpc_core::JoinHostPort(&proxy->proxy_name, "localhost", proxy_port); - gpr_log(GPR_INFO, "Proxy address: %s", proxy->proxy_name.get()); + gpr_join_host_port(&proxy->proxy_name, "localhost", proxy_port); + gpr_log(GPR_INFO, "Proxy address: %s", proxy->proxy_name); // Create TCP server. proxy->channel_args = grpc_channel_args_copy(args); grpc_error* error = @@ -572,6 +573,7 @@ void grpc_end2end_http_proxy_destroy(grpc_end2end_http_proxy* proxy) { proxy->thd.Join(); grpc_tcp_server_shutdown_listeners(proxy->server); grpc_tcp_server_unref(proxy->server); + gpr_free(proxy->proxy_name); grpc_channel_args_destroy(proxy->channel_args); grpc_pollset_shutdown(proxy->pollset, GRPC_CLOSURE_CREATE(destroy_pollset, proxy->pollset, @@ -582,5 +584,5 @@ void grpc_end2end_http_proxy_destroy(grpc_end2end_http_proxy* proxy) { const char* grpc_end2end_http_proxy_get_proxy_name( grpc_end2end_http_proxy* proxy) { - return proxy->proxy_name.get(); + return proxy->proxy_name; } diff --git a/test/core/end2end/fixtures/inproc.cc b/test/core/end2end/fixtures/inproc.cc index 70cc6b05479..dadf3ef455d 100644 --- a/test/core/end2end/fixtures/inproc.cc +++ b/test/core/end2end/fixtures/inproc.cc @@ -28,6 +28,7 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/inproc/inproc_transport.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/local_util.cc b/test/core/end2end/fixtures/local_util.cc index 767f3a28ef8..5f0b0300ac0 100644 --- a/test/core/end2end/fixtures/local_util.cc +++ b/test/core/end2end/fixtures/local_util.cc @@ -27,6 +27,7 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/surface/server.h" @@ -36,7 +37,8 @@ grpc_end2end_test_fixture grpc_end2end_local_chttp2_create_fixture_fullstack() { grpc_end2end_test_fixture f; grpc_end2end_local_fullstack_fixture_data* ffd = - grpc_core::New(); + static_cast( + gpr_malloc(sizeof(grpc_end2end_local_fullstack_fixture_data))); memset(&f, 0, sizeof(f)); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -50,8 +52,8 @@ void grpc_end2end_local_chttp2_init_client_fullstack( grpc_channel_credentials* creds = grpc_local_credentials_create(type); grpc_end2end_local_fullstack_fixture_data* ffd = static_cast(f->fixture_data); - f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), - client_args, nullptr); + f->client = + grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -97,8 +99,8 @@ void grpc_end2end_local_chttp2_init_server_fullstack( nullptr}; grpc_server_credentials_set_auth_metadata_processor(creds, processor); } - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), - creds)); + GPR_ASSERT( + grpc_server_add_secure_http2_port(f->server, ffd->localaddr, creds)); grpc_server_credentials_release(creds); grpc_server_start(f->server); } @@ -107,5 +109,6 @@ void grpc_end2end_local_chttp2_tear_down_fullstack( grpc_end2end_test_fixture* f) { grpc_end2end_local_fullstack_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } diff --git a/test/core/end2end/fixtures/local_util.h b/test/core/end2end/fixtures/local_util.h index df204d2fab2..f133b4d977e 100644 --- a/test/core/end2end/fixtures/local_util.h +++ b/test/core/end2end/fixtures/local_util.h @@ -22,9 +22,9 @@ #include "src/core/lib/surface/channel.h" -struct grpc_end2end_local_fullstack_fixture_data { - grpc_core::UniquePtr localaddr; -}; +typedef struct grpc_end2end_local_fullstack_fixture_data { + char* localaddr; +} grpc_end2end_local_fullstack_fixture_data; /* Utility functions shared by h2_local tests. */ grpc_end2end_test_fixture grpc_end2end_local_chttp2_create_fixture_fullstack(); diff --git a/test/core/end2end/fixtures/proxy.cc b/test/core/end2end/fixtures/proxy.cc index 4ae7450b0df..869b6e846d3 100644 --- a/test/core/end2end/fixtures/proxy.cc +++ b/test/core/end2end/fixtures/proxy.cc @@ -24,15 +24,16 @@ #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/useful.h" -#include "src/core/lib/gprpp/host_port.h" -#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/thd.h" #include "test/core/util/port.h" struct grpc_end2end_proxy { grpc_end2end_proxy() - : cq(nullptr), + : proxy_port(nullptr), + server_port(nullptr), + cq(nullptr), server(nullptr), client(nullptr), shutdown(false), @@ -41,8 +42,8 @@ struct grpc_end2end_proxy { memset(&new_call_metadata, 0, sizeof(new_call_metadata)); } grpc_core::Thread thd; - grpc_core::UniquePtr proxy_port; - grpc_core::UniquePtr server_port; + char* proxy_port; + char* server_port; grpc_completion_queue* cq; grpc_server* server; grpc_channel* client; @@ -91,15 +92,15 @@ grpc_end2end_proxy* grpc_end2end_proxy_create(const grpc_end2end_proxy_def* def, grpc_end2end_proxy* proxy = grpc_core::New(); - grpc_core::JoinHostPort(&proxy->proxy_port, "localhost", proxy_port); - grpc_core::JoinHostPort(&proxy->server_port, "localhost", server_port); + gpr_join_host_port(&proxy->proxy_port, "localhost", proxy_port); + gpr_join_host_port(&proxy->server_port, "localhost", server_port); - gpr_log(GPR_DEBUG, "PROXY ADDR:%s BACKEND:%s", proxy->proxy_port.get(), - proxy->server_port.get()); + gpr_log(GPR_DEBUG, "PROXY ADDR:%s BACKEND:%s", proxy->proxy_port, + proxy->server_port); proxy->cq = grpc_completion_queue_create_for_next(nullptr); - proxy->server = def->create_server(proxy->proxy_port.get(), server_args); - proxy->client = def->create_client(proxy->server_port.get(), client_args); + proxy->server = def->create_server(proxy->proxy_port, server_args); + proxy->client = def->create_client(proxy->server_port, client_args); grpc_server_register_completion_queue(proxy->server, proxy->cq, nullptr); grpc_server_start(proxy->server); @@ -130,6 +131,8 @@ void grpc_end2end_proxy_destroy(grpc_end2end_proxy* proxy) { grpc_server_shutdown_and_notify(proxy->server, proxy->cq, new_closure(shutdown_complete, proxy)); proxy->thd.Join(); + gpr_free(proxy->proxy_port); + gpr_free(proxy->server_port); grpc_server_destroy(proxy->server); grpc_channel_destroy(proxy->client); grpc_completion_queue_destroy(proxy->cq); @@ -438,9 +441,9 @@ static void thread_main(void* arg) { } const char* grpc_end2end_proxy_get_client_target(grpc_end2end_proxy* proxy) { - return proxy->proxy_port.get(); + return proxy->proxy_port; } const char* grpc_end2end_proxy_get_server_port(grpc_end2end_proxy* proxy) { - return proxy->server_port.get(); + return proxy->server_port; } diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc index 34a9ef760b5..e9285778a2d 100644 --- a/test/core/end2end/h2_ssl_cert_test.cc +++ b/test/core/end2end/h2_ssl_cert_test.cc @@ -25,9 +25,9 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/cq_verifier.h" @@ -40,19 +40,20 @@ namespace grpc { namespace testing { -struct fullstack_secure_fixture_data { - grpc_core::UniquePtr localaddr; -}; +typedef struct fullstack_secure_fixture_data { + char* localaddr; +} fullstack_secure_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = - grpc_core::New(); + static_cast( + gpr_malloc(sizeof(fullstack_secure_fixture_data))); memset(&f, 0, sizeof(f)); - grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); + gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -72,8 +73,8 @@ static void chttp2_init_client_secure_fullstack( grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), - client_args, nullptr); + f->client = + grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -88,7 +89,7 @@ static void chttp2_init_server_secure_fullstack( } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); @@ -97,7 +98,8 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } static int fail_server_auth_check(grpc_channel_args* server_args) { diff --git a/test/core/end2end/h2_ssl_session_reuse_test.cc b/test/core/end2end/h2_ssl_session_reuse_test.cc index 6ffc138820e..b2d0a5e1133 100644 --- a/test/core/end2end/h2_ssl_session_reuse_test.cc +++ b/test/core/end2end/h2_ssl_session_reuse_test.cc @@ -25,9 +25,9 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/cq_verifier.h" @@ -215,18 +215,19 @@ void drain_cq(grpc_completion_queue* cq) { TEST(H2SessionReuseTest, SingleReuse) { int port = grpc_pick_unused_port_or_die(); - grpc_core::UniquePtr server_addr; - grpc_core::JoinHostPort(&server_addr, "localhost", port); + char* server_addr; + gpr_join_host_port(&server_addr, "localhost", port); grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); grpc_ssl_session_cache* cache = grpc_ssl_session_cache_create_lru(16); - grpc_server* server = server_create(cq, server_addr.get()); + grpc_server* server = server_create(cq, server_addr); - do_round_trip(cq, server, server_addr.get(), cache, false); - do_round_trip(cq, server, server_addr.get(), cache, true); - do_round_trip(cq, server, server_addr.get(), cache, true); + do_round_trip(cq, server, server_addr, cache, false); + do_round_trip(cq, server, server_addr, cache, true); + do_round_trip(cq, server, server_addr, cache, true); + gpr_free(server_addr); grpc_ssl_session_cache_destroy(cache); GPR_ASSERT(grpc_completion_queue_next( diff --git a/test/core/end2end/invalid_call_argument_test.cc b/test/core/end2end/invalid_call_argument_test.cc index 5f920fad638..bd28d192984 100644 --- a/test/core/end2end/invalid_call_argument_test.cc +++ b/test/core/end2end/invalid_call_argument_test.cc @@ -25,8 +25,7 @@ #include #include -#include "src/core/lib/gprpp/host_port.h" -#include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/gpr/host_port.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -55,6 +54,7 @@ static struct test_state g_state; static void prepare_test(int is_client) { int port = grpc_pick_unused_port_or_die(); + char* server_hostport; grpc_op* op; g_state.is_client = is_client; grpc_metadata_array_init(&g_state.initial_metadata_recv); @@ -77,13 +77,14 @@ static void prepare_test(int is_client) { } else { g_state.server = grpc_server_create(nullptr, nullptr); grpc_server_register_completion_queue(g_state.server, g_state.cq, nullptr); - grpc_core::UniquePtr server_hostport; - grpc_core::JoinHostPort(&server_hostport, "0.0.0.0", port); - grpc_server_add_insecure_http2_port(g_state.server, server_hostport.get()); + gpr_join_host_port(&server_hostport, "0.0.0.0", port); + grpc_server_add_insecure_http2_port(g_state.server, server_hostport); grpc_server_start(g_state.server); - grpc_core::JoinHostPort(&server_hostport, "localhost", port); + gpr_free(server_hostport); + gpr_join_host_port(&server_hostport, "localhost", port); g_state.chan = - grpc_insecure_channel_create(server_hostport.get(), nullptr, nullptr); + grpc_insecure_channel_create(server_hostport, nullptr, nullptr); + gpr_free(server_hostport); grpc_slice host = grpc_slice_from_static_string("bar"); g_state.call = grpc_channel_create_call( g_state.chan, nullptr, GRPC_PROPAGATE_DEFAULTS, g_state.cq, diff --git a/test/core/fling/fling_stream_test.cc b/test/core/fling/fling_stream_test.cc index 474b4fbbc3b..32bc9896414 100644 --- a/test/core/fling/fling_stream_test.cc +++ b/test/core/fling/fling_stream_test.cc @@ -22,8 +22,8 @@ #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/host_port.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" @@ -46,24 +46,23 @@ int main(int argc, char** argv) { gpr_asprintf(&args[0], "%s/fling_server%s", root, gpr_subprocess_binary_extension()); args[1] = const_cast("--bind"); - grpc_core::UniquePtr joined; - grpc_core::JoinHostPort(&joined, "::", port); - args[2] = joined.get(); + gpr_join_host_port(&args[2], "::", port); args[3] = const_cast("--no-secure"); svr = gpr_subprocess_create(4, (const char**)args); gpr_free(args[0]); + gpr_free(args[2]); /* start the client */ gpr_asprintf(&args[0], "%s/fling_client%s", root, gpr_subprocess_binary_extension()); args[1] = const_cast("--target"); - grpc_core::JoinHostPort(&joined, "127.0.0.1", port); - args[2] = joined.get(); + gpr_join_host_port(&args[2], "127.0.0.1", port); args[3] = const_cast("--scenario=ping-pong-stream"); args[4] = const_cast("--no-secure"); args[5] = nullptr; cli = gpr_subprocess_create(6, (const char**)args); gpr_free(args[0]); + gpr_free(args[2]); /* wait for completion */ printf("waiting for client\n"); diff --git a/test/core/fling/fling_test.cc b/test/core/fling/fling_test.cc index 3667d48f010..3587a4acaae 100644 --- a/test/core/fling/fling_test.cc +++ b/test/core/fling/fling_test.cc @@ -22,9 +22,8 @@ #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/host_port.h" -#include "src/core/lib/gprpp/memory.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" @@ -47,24 +46,23 @@ int main(int argc, const char** argv) { gpr_asprintf(&args[0], "%s/fling_server%s", root, gpr_subprocess_binary_extension()); args[1] = const_cast("--bind"); - grpc_core::UniquePtr joined; - grpc_core::JoinHostPort(&joined, "::", port); - args[2] = joined.get(); + gpr_join_host_port(&args[2], "::", port); args[3] = const_cast("--no-secure"); svr = gpr_subprocess_create(4, (const char**)args); gpr_free(args[0]); + gpr_free(args[2]); /* start the client */ gpr_asprintf(&args[0], "%s/fling_client%s", root, gpr_subprocess_binary_extension()); args[1] = const_cast("--target"); - grpc_core::JoinHostPort(&joined, "127.0.0.1", port); - args[2] = joined.get(); + gpr_join_host_port(&args[2], "127.0.0.1", port); args[3] = const_cast("--scenario=ping-pong-request"); args[4] = const_cast("--no-secure"); args[5] = nullptr; cli = gpr_subprocess_create(6, (const char**)args); gpr_free(args[0]); + gpr_free(args[2]); /* wait for completion */ printf("waiting for client\n"); diff --git a/test/core/fling/server.cc b/test/core/fling/server.cc index 241ac71bc7d..cf7e2465d9e 100644 --- a/test/core/fling/server.cc +++ b/test/core/fling/server.cc @@ -33,7 +33,7 @@ #include #include -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/profiling/timers.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/cmdline.h" @@ -172,7 +172,7 @@ static void sigint_handler(int x) { _exit(0); } int main(int argc, char** argv) { grpc_event ev; call_state* s; - grpc_core::UniquePtr addr_buf; + char* addr_buf = nullptr; gpr_cmdline* cl; grpc_completion_queue* shutdown_cq; int shutdown_started = 0; @@ -199,8 +199,8 @@ int main(int argc, char** argv) { gpr_cmdline_destroy(cl); if (addr == nullptr) { - grpc_core::JoinHostPort(&addr_buf, "::", grpc_pick_unused_port_or_die()); - addr = addr_buf.get(); + gpr_join_host_port(&addr_buf, "::", grpc_pick_unused_port_or_die()); + addr = addr_buf; } gpr_log(GPR_INFO, "creating server on: %s", addr); @@ -220,8 +220,8 @@ int main(int argc, char** argv) { grpc_server_register_completion_queue(server, cq, nullptr); grpc_server_start(server); - addr = nullptr; - addr_buf.reset(); + gpr_free(addr_buf); + addr = addr_buf = nullptr; grpc_call_details_init(&call_details); diff --git a/test/core/gpr/BUILD b/test/core/gpr/BUILD index c2b2576ff03..434d55e0451 100644 --- a/test/core/gpr/BUILD +++ b/test/core/gpr/BUILD @@ -58,6 +58,16 @@ grpc_cc_test( ], ) +grpc_cc_test( + name = "host_port_test", + srcs = ["host_port_test.cc"], + language = "C++", + deps = [ + "//:gpr", + "//test/core/util:grpc_test_util", + ], +) + grpc_cc_test( name = "log_test", srcs = ["log_test.cc"], diff --git a/test/core/gprpp/host_port_test.cc b/test/core/gpr/host_port_test.cc similarity index 86% rename from test/core/gprpp/host_port_test.cc rename to test/core/gpr/host_port_test.cc index 3474e6dc494..b01bbf4b695 100644 --- a/test/core/gprpp/host_port_test.cc +++ b/test/core/gpr/host_port_test.cc @@ -21,17 +21,18 @@ #include #include -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "test/core/util/test_config.h" static void join_host_port_expect(const char* host, int port, const char* expected) { - grpc_core::UniquePtr buf; + char* buf; int len; - len = grpc_core::JoinHostPort(&buf, host, port); + len = gpr_join_host_port(&buf, host, port); GPR_ASSERT(len >= 0); - GPR_ASSERT(strlen(expected) == static_cast(len)); - GPR_ASSERT(strcmp(expected, buf.get()) == 0); + GPR_ASSERT(strlen(expected) == (size_t)len); + GPR_ASSERT(strcmp(expected, buf) == 0); + gpr_free(buf); } static void test_join_host_port(void) { diff --git a/test/core/gprpp/BUILD b/test/core/gprpp/BUILD index 5cee96a3ad2..cd3232addfd 100644 --- a/test/core/gprpp/BUILD +++ b/test/core/gprpp/BUILD @@ -64,16 +64,6 @@ grpc_cc_test( ], ) -grpc_cc_test( - name = "host_port_test", - srcs = ["host_port_test.cc"], - language = "C++", - deps = [ - "//:gpr", - "//test/core/util:grpc_test_util", - ], -) - grpc_cc_test( name = "grpc_core_map_test", srcs = ["map_test.cc"], @@ -166,19 +156,6 @@ grpc_cc_test( ], ) -grpc_cc_test( - name = "string_view_test", - srcs = ["string_view_test.cc"], - external_deps = [ - "gtest", - ], - language = "C++", - deps = [ - "//:gpr_base", - "//test/core/util:grpc_test_util", - ], -) - grpc_cc_test( name = "thd_test", srcs = ["thd_test.cc"], diff --git a/test/core/gprpp/string_view_test.cc b/test/core/gprpp/string_view_test.cc deleted file mode 100644 index 1c8adb1db14..00000000000 --- a/test/core/gprpp/string_view_test.cc +++ /dev/null @@ -1,163 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/lib/gprpp/string_view.h" - -#include -#include "src/core/lib/gprpp/memory.h" -#include "test/core/util/test_config.h" - -namespace grpc_core { -namespace testing { - -TEST(StringViewTest, Empty) { - grpc_core::StringView empty; - EXPECT_TRUE(empty.empty()); - EXPECT_EQ(empty.size(), 0lu); - - grpc_core::StringView empty_buf(""); - EXPECT_TRUE(empty_buf.empty()); - EXPECT_EQ(empty_buf.size(), 0lu); - - grpc_core::StringView empty_trimmed("foo", 0); - EXPECT_TRUE(empty_trimmed.empty()); - EXPECT_EQ(empty_trimmed.size(), 0lu); - - grpc_core::StringView empty_slice(grpc_empty_slice()); - EXPECT_TRUE(empty_slice.empty()); - EXPECT_EQ(empty_slice.size(), 0lu); -} - -TEST(StringViewTest, Size) { - constexpr char kStr[] = "foo"; - grpc_core::StringView str1(kStr); - EXPECT_EQ(str1.size(), strlen(kStr)); - grpc_core::StringView str2(kStr, 2); - EXPECT_EQ(str2.size(), 2lu); -} - -TEST(StringViewTest, Data) { - constexpr char kStr[] = "foo-bar"; - grpc_core::StringView str(kStr); - EXPECT_EQ(str.size(), strlen(kStr)); - for (size_t i = 0; i < strlen(kStr); ++i) { - EXPECT_EQ(str[i], kStr[i]); - } -} - -TEST(StringViewTest, Slice) { - constexpr char kStr[] = "foo"; - grpc_core::StringView slice(grpc_slice_from_static_string(kStr)); - EXPECT_EQ(slice.size(), strlen(kStr)); -} - -TEST(StringViewTest, Dup) { - constexpr char kStr[] = "foo"; - grpc_core::StringView slice(grpc_slice_from_static_string(kStr)); - grpc_core::UniquePtr dup = slice.dup(); - EXPECT_EQ(0, strcmp(kStr, dup.get())); - EXPECT_EQ(slice.size(), strlen(kStr)); -} - -TEST(StringViewTest, Eq) { - constexpr char kStr1[] = "foo"; - constexpr char kStr2[] = "bar"; - grpc_core::StringView str1(kStr1); - EXPECT_EQ(kStr1, str1); - EXPECT_EQ(str1, kStr1); - grpc_core::StringView slice1(grpc_slice_from_static_string(kStr1)); - EXPECT_EQ(slice1, str1); - EXPECT_EQ(str1, slice1); - EXPECT_NE(slice1, kStr2); - EXPECT_NE(kStr2, slice1); - grpc_core::StringView slice2(grpc_slice_from_static_string(kStr2)); - EXPECT_NE(slice2, str1); - EXPECT_NE(str1, slice2); -} - -TEST(StringViewTest, Cmp) { - constexpr char kStr1[] = "abc"; - constexpr char kStr2[] = "abd"; - constexpr char kStr3[] = "abcd"; - grpc_core::StringView str1(kStr1); - grpc_core::StringView str2(kStr2); - grpc_core::StringView str3(kStr3); - EXPECT_EQ(str1.cmp(str1), 0); - EXPECT_LT(str1.cmp(str2), 0); - EXPECT_LT(str1.cmp(str3), 0); - EXPECT_EQ(str2.cmp(str2), 0); - EXPECT_GT(str2.cmp(str1), 0); - EXPECT_GT(str2.cmp(str3), 0); - EXPECT_EQ(str3.cmp(str3), 0); - EXPECT_GT(str3.cmp(str1), 0); - EXPECT_LT(str3.cmp(str2), 0); -} - -TEST(StringViewTest, RemovePrefix) { - constexpr char kStr[] = "abcd"; - grpc_core::StringView str(kStr); - str.remove_prefix(1); - EXPECT_EQ("bcd", str); - str.remove_prefix(2); - EXPECT_EQ("d", str); - str.remove_prefix(1); - EXPECT_EQ("", str); -} - -TEST(StringViewTest, RemoveSuffix) { - constexpr char kStr[] = "abcd"; - grpc_core::StringView str(kStr); - str.remove_suffix(1); - EXPECT_EQ("abc", str); - str.remove_suffix(2); - EXPECT_EQ("a", str); - str.remove_suffix(1); - EXPECT_EQ("", str); -} - -TEST(StringViewTest, Substring) { - constexpr char kStr[] = "abcd"; - grpc_core::StringView str(kStr); - EXPECT_EQ("bcd", str.substr(1)); - EXPECT_EQ("bc", str.substr(1, 2)); -} - -TEST(StringViewTest, Find) { - // Passing StringView::npos directly to GTEST macros result in link errors. - // Store the value in a local variable and use it in the test. - const size_t npos = grpc_core::StringView::npos; - constexpr char kStr[] = "abacad"; - grpc_core::StringView str(kStr); - EXPECT_EQ(0ul, str.find('a')); - EXPECT_EQ(2ul, str.find('a', 1)); - EXPECT_EQ(4ul, str.find('a', 3)); - EXPECT_EQ(1ul, str.find('b')); - EXPECT_EQ(npos, str.find('b', 2)); - EXPECT_EQ(npos, str.find('z')); -} - -} // namespace testing -} // namespace grpc_core - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/test/core/memory_usage/memory_usage_test.cc b/test/core/memory_usage/memory_usage_test.cc index 5df8af5658b..5c35b4e1d36 100644 --- a/test/core/memory_usage/memory_usage_test.cc +++ b/test/core/memory_usage/memory_usage_test.cc @@ -22,8 +22,8 @@ #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/host_port.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" @@ -46,23 +46,22 @@ int main(int argc, char** argv) { gpr_asprintf(&args[0], "%s/memory_usage_server%s", root, gpr_subprocess_binary_extension()); args[1] = const_cast("--bind"); - grpc_core::UniquePtr joined; - grpc_core::JoinHostPort(&joined, "::", port); - args[2] = joined.get(); + gpr_join_host_port(&args[2], "::", port); args[3] = const_cast("--no-secure"); svr = gpr_subprocess_create(4, (const char**)args); gpr_free(args[0]); + gpr_free(args[2]); /* start the client */ gpr_asprintf(&args[0], "%s/memory_usage_client%s", root, gpr_subprocess_binary_extension()); args[1] = const_cast("--target"); - grpc_core::JoinHostPort(&joined, "127.0.0.1", port); - args[2] = joined.get(); + gpr_join_host_port(&args[2], "127.0.0.1", port); args[3] = const_cast("--warmup=1000"); args[4] = const_cast("--benchmark=9000"); cli = gpr_subprocess_create(5, (const char**)args); gpr_free(args[0]); + gpr_free(args[2]); /* wait for completion */ printf("waiting for client\n"); diff --git a/test/core/memory_usage/server.cc b/test/core/memory_usage/server.cc index ecdf17925ec..6fb14fa31a0 100644 --- a/test/core/memory_usage/server.cc +++ b/test/core/memory_usage/server.cc @@ -33,7 +33,7 @@ #include #include -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/cmdline.h" #include "test/core/util/memory_counters.h" @@ -149,7 +149,7 @@ static void sigint_handler(int x) { _exit(0); } int main(int argc, char** argv) { grpc_memory_counters_init(); grpc_event ev; - grpc_core::UniquePtr addr_buf; + char* addr_buf = nullptr; gpr_cmdline* cl; grpc_completion_queue* shutdown_cq; int shutdown_started = 0; @@ -174,8 +174,8 @@ int main(int argc, char** argv) { gpr_cmdline_destroy(cl); if (addr == nullptr) { - grpc_core::JoinHostPort(&addr_buf, "::", grpc_pick_unused_port_or_die()); - addr = addr_buf.get(); + gpr_join_host_port(&addr_buf, "::", grpc_pick_unused_port_or_die()); + addr = addr_buf; } gpr_log(GPR_INFO, "creating server on: %s", addr); @@ -202,8 +202,8 @@ int main(int argc, char** argv) { struct grpc_memory_counters after_server_create = grpc_memory_counters_snapshot(); - addr = nullptr; - addr_buf.reset(); + gpr_free(addr_buf); + addr = addr_buf = nullptr; // initialize call instances for (int i = 0; i < static_cast(sizeof(calls) / sizeof(fling_call)); diff --git a/test/core/surface/num_external_connectivity_watchers_test.cc b/test/core/surface/num_external_connectivity_watchers_test.cc index 2c9b0d9aaed..454cbd5747e 100644 --- a/test/core/surface/num_external_connectivity_watchers_test.cc +++ b/test/core/surface/num_external_connectivity_watchers_test.cc @@ -22,8 +22,7 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gprpp/host_port.h" -#include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/end2end/data/ssl_test_data.h" @@ -67,11 +66,13 @@ static void channel_idle_poll_for_timeout(grpc_channel* channel, static void run_timeouts_test(const test_fixture* fixture) { gpr_log(GPR_INFO, "TEST: %s", fixture->name); - grpc_core::UniquePtr addr; - grpc_init(); - grpc_core::JoinHostPort(&addr, "localhost", grpc_pick_unused_port_or_die()); + char* addr; - grpc_channel* channel = fixture->create_channel(addr.get()); + grpc_init(); + + gpr_join_host_port(&addr, "localhost", grpc_pick_unused_port_or_die()); + + grpc_channel* channel = fixture->create_channel(addr); grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); /* start 1 watcher and then let it time out */ @@ -110,6 +111,7 @@ static void run_timeouts_test(const test_fixture* fixture) { grpc_completion_queue_destroy(cq); grpc_shutdown(); + gpr_free(addr); } /* An edge scenario; sets channel state to explicitly, and outside @@ -118,11 +120,13 @@ static void run_channel_shutdown_before_timeout_test( const test_fixture* fixture) { gpr_log(GPR_INFO, "TEST: %s", fixture->name); - grpc_core::UniquePtr addr; - grpc_init(); - grpc_core::JoinHostPort(&addr, "localhost", grpc_pick_unused_port_or_die()); + char* addr; - grpc_channel* channel = fixture->create_channel(addr.get()); + grpc_init(); + + gpr_join_host_port(&addr, "localhost", grpc_pick_unused_port_or_die()); + + grpc_channel* channel = fixture->create_channel(addr); grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); /* start 1 watcher and then shut down the channel before the timer goes off */ @@ -150,6 +154,7 @@ static void run_channel_shutdown_before_timeout_test( grpc_completion_queue_destroy(cq); grpc_shutdown(); + gpr_free(addr); } static grpc_channel* insecure_test_create_channel(const char* addr) { diff --git a/test/core/surface/sequential_connectivity_test.cc b/test/core/surface/sequential_connectivity_test.cc index 46c4a24f5ed..3f9a7baf98b 100644 --- a/test/core/surface/sequential_connectivity_test.cc +++ b/test/core/surface/sequential_connectivity_test.cc @@ -22,7 +22,7 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/end2end/data/ssl_test_data.h" @@ -56,11 +56,11 @@ static void run_test(const test_fixture* fixture) { grpc_init(); - grpc_core::UniquePtr addr; - grpc_core::JoinHostPort(&addr, "localhost", grpc_pick_unused_port_or_die()); + char* addr; + gpr_join_host_port(&addr, "localhost", grpc_pick_unused_port_or_die()); grpc_server* server = grpc_server_create(nullptr, nullptr); - fixture->add_server_port(server, addr.get()); + fixture->add_server_port(server, addr); grpc_completion_queue* server_cq = grpc_completion_queue_create_for_next(nullptr); grpc_server_register_completion_queue(server, server_cq, nullptr); @@ -73,7 +73,7 @@ static void run_test(const test_fixture* fixture) { grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); grpc_channel* channels[NUM_CONNECTIONS]; for (size_t i = 0; i < NUM_CONNECTIONS; i++) { - channels[i] = fixture->create_channel(addr.get()); + channels[i] = fixture->create_channel(addr); gpr_timespec connect_deadline = grpc_timeout_seconds_to_deadline(30); grpc_connectivity_state state; @@ -116,6 +116,7 @@ static void run_test(const test_fixture* fixture) { grpc_completion_queue_destroy(cq); grpc_shutdown(); + gpr_free(addr); } static void insecure_test_add_port(grpc_server* server, const char* addr) { diff --git a/test/core/surface/server_chttp2_test.cc b/test/core/surface/server_chttp2_test.cc index a88362e13b0..ffb7f14f987 100644 --- a/test/core/surface/server_chttp2_test.cc +++ b/test/core/surface/server_chttp2_test.cc @@ -22,7 +22,7 @@ #include #include -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "src/core/tsi/fake_transport_security.h" @@ -47,17 +47,17 @@ void test_add_same_port_twice() { grpc_channel_args args = {1, &a}; int port = grpc_pick_unused_port_or_die(); - grpc_core::UniquePtr addr; + char* addr = nullptr; grpc_completion_queue* cq = grpc_completion_queue_create_for_pluck(nullptr); grpc_server* server = grpc_server_create(&args, nullptr); grpc_server_credentials* fake_creds = grpc_fake_transport_security_server_credentials_create(); - grpc_core::JoinHostPort(&addr, "localhost", port); - GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr.get(), fake_creds)); - GPR_ASSERT( - grpc_server_add_secure_http2_port(server, addr.get(), fake_creds) == 0); + gpr_join_host_port(&addr, "localhost", port); + GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, fake_creds)); + GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, fake_creds) == 0); grpc_server_credentials_release(fake_creds); + gpr_free(addr); grpc_server_shutdown_and_notify(server, cq, nullptr); grpc_completion_queue_pluck(cq, nullptr, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr); diff --git a/test/core/surface/server_test.cc b/test/core/surface/server_test.cc index 185a6757743..2fc166546b0 100644 --- a/test/core/surface/server_test.cc +++ b/test/core/surface/server_test.cc @@ -22,7 +22,7 @@ #include #include -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "test/core/util/port.h" @@ -106,19 +106,18 @@ void test_bind_server_twice(void) { void test_bind_server_to_addr(const char* host, bool secure) { int port = grpc_pick_unused_port_or_die(); - grpc_core::UniquePtr addr; - grpc_core::JoinHostPort(&addr, host, port); - gpr_log(GPR_INFO, "Test bind to %s", addr.get()); + char* addr; + gpr_join_host_port(&addr, host, port); + gpr_log(GPR_INFO, "Test bind to %s", addr); grpc_server* server = grpc_server_create(nullptr, nullptr); if (secure) { grpc_server_credentials* fake_creds = grpc_fake_transport_security_server_credentials_create(); - GPR_ASSERT( - grpc_server_add_secure_http2_port(server, addr.get(), fake_creds)); + GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, fake_creds)); grpc_server_credentials_release(fake_creds); } else { - GPR_ASSERT(grpc_server_add_insecure_http2_port(server, addr.get())); + GPR_ASSERT(grpc_server_add_insecure_http2_port(server, addr)); } grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); grpc_server_register_completion_queue(server, cq, nullptr); @@ -127,6 +126,7 @@ void test_bind_server_to_addr(const char* host, bool secure) { grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr); grpc_server_destroy(server); grpc_completion_queue_destroy(cq); + gpr_free(addr); } static int external_dns_works(const char* host) { diff --git a/test/core/util/reconnect_server.cc b/test/core/util/reconnect_server.cc index 03c088db772..144ad64f095 100644 --- a/test/core/util/reconnect_server.cc +++ b/test/core/util/reconnect_server.cc @@ -25,6 +25,7 @@ #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/tcp_server.h" diff --git a/test/core/util/test_tcp_server.cc b/test/core/util/test_tcp_server.cc index d7803e53555..170584df2b9 100644 --- a/test/core/util/test_tcp_server.cc +++ b/test/core/util/test_tcp_server.cc @@ -28,6 +28,7 @@ #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/tcp_server.h" diff --git a/test/cpp/interop/interop_test.cc b/test/cpp/interop/interop_test.cc index e0bacb3cfd6..8e45b877212 100644 --- a/test/cpp/interop/interop_test.cc +++ b/test/cpp/interop/interop_test.cc @@ -32,6 +32,7 @@ #include "test/core/util/port.h" #include "test/cpp/util/test_config.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/socket_utils_posix.h" diff --git a/test/cpp/naming/address_sorting_test.cc b/test/cpp/naming/address_sorting_test.cc index a3d9936606d..affc75bc634 100644 --- a/test/cpp/naming/address_sorting_test.cc +++ b/test/cpp/naming/address_sorting_test.cc @@ -40,8 +40,8 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr.h" @@ -64,28 +64,30 @@ struct TestAddress { }; grpc_resolved_address TestAddressToGrpcResolvedAddress(TestAddress test_addr) { - grpc_core::UniquePtr host; - grpc_core::UniquePtr port; + char* host; + char* port; grpc_resolved_address resolved_addr; - grpc_core::SplitHostPort(test_addr.dest_addr.c_str(), &host, &port); + gpr_split_host_port(test_addr.dest_addr.c_str(), &host, &port); if (test_addr.family == AF_INET) { sockaddr_in in_dest; memset(&in_dest, 0, sizeof(sockaddr_in)); - in_dest.sin_port = htons(atoi(port.get())); + in_dest.sin_port = htons(atoi(port)); in_dest.sin_family = AF_INET; - GPR_ASSERT(inet_pton(AF_INET, host.get(), &in_dest.sin_addr) == 1); + GPR_ASSERT(inet_pton(AF_INET, host, &in_dest.sin_addr) == 1); memcpy(&resolved_addr.addr, &in_dest, sizeof(sockaddr_in)); resolved_addr.len = sizeof(sockaddr_in); } else { GPR_ASSERT(test_addr.family == AF_INET6); sockaddr_in6 in6_dest; memset(&in6_dest, 0, sizeof(sockaddr_in6)); - in6_dest.sin6_port = htons(atoi(port.get())); + in6_dest.sin6_port = htons(atoi(port)); in6_dest.sin6_family = AF_INET6; - GPR_ASSERT(inet_pton(AF_INET6, host.get(), &in6_dest.sin6_addr) == 1); + GPR_ASSERT(inet_pton(AF_INET6, host, &in6_dest.sin6_addr) == 1); memcpy(&resolved_addr.addr, &in6_dest, sizeof(sockaddr_in6)); resolved_addr.len = sizeof(sockaddr_in6); } + gpr_free(host); + gpr_free(port); return resolved_addr; } diff --git a/test/cpp/naming/cancel_ares_query_test.cc b/test/cpp/naming/cancel_ares_query_test.cc index 2d1a13d25a6..667011ae291 100644 --- a/test/cpp/naming/cancel_ares_query_test.cc +++ b/test/cpp/naming/cancel_ares_query_test.cc @@ -33,6 +33,7 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/stats.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/thd.h" diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index 67ed307d2d7..6cea8143907 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -46,8 +46,8 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/executor.h" @@ -506,10 +506,10 @@ int g_fake_non_responsive_dns_server_port = -1; void InjectBrokenNameServerList(ares_channel channel) { struct ares_addr_port_node dns_server_addrs[2]; memset(dns_server_addrs, 0, sizeof(dns_server_addrs)); - grpc_core::UniquePtr unused_host; - grpc_core::UniquePtr local_dns_server_port; - GPR_ASSERT(grpc_core::SplitHostPort(FLAGS_local_dns_server_address.c_str(), - &unused_host, &local_dns_server_port)); + char* unused_host; + char* local_dns_server_port; + GPR_ASSERT(gpr_split_host_port(FLAGS_local_dns_server_address.c_str(), + &unused_host, &local_dns_server_port)); gpr_log(GPR_DEBUG, "Injecting broken nameserver list. Bad server address:|[::1]:%d|. " "Good server address:%s", @@ -528,10 +528,12 @@ void InjectBrokenNameServerList(ares_channel channel) { dns_server_addrs[1].family = AF_INET; ((char*)&dns_server_addrs[1].addr.addr4)[0] = 0x7f; ((char*)&dns_server_addrs[1].addr.addr4)[3] = 0x1; - dns_server_addrs[1].tcp_port = atoi(local_dns_server_port.get()); - dns_server_addrs[1].udp_port = atoi(local_dns_server_port.get()); + dns_server_addrs[1].tcp_port = atoi(local_dns_server_port); + dns_server_addrs[1].udp_port = atoi(local_dns_server_port); dns_server_addrs[1].next = nullptr; GPR_ASSERT(ares_set_servers_ports(channel, dns_server_addrs) == ARES_SUCCESS); + gpr_free(local_dns_server_port); + gpr_free(unused_host); } void StartResolvingLocked(void* arg, grpc_error* unused) { diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc index 5fc14ddbabd..668d9abf5ca 100644 --- a/test/cpp/qps/client_sync.cc +++ b/test/cpp/qps/client_sync.cc @@ -33,6 +33,7 @@ #include #include +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/profiling/timers.h" #include "src/proto/grpc/testing/benchmark_service.grpc.pb.h" #include "test/cpp/qps/client.h" diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index cfc3c8e9a06..7d4d5d99446 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -31,7 +31,7 @@ #include #include "src/core/lib/gpr/env.h" -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/profiling/timers.h" #include "src/proto/grpc/testing/worker_service.grpc.pb.h" #include "test/core/util/port.h" @@ -52,10 +52,15 @@ using std::vector; namespace grpc { namespace testing { static std::string get_host(const std::string& worker) { - grpc_core::StringView host; - grpc_core::StringView port; - grpc_core::SplitHostPort(worker.c_str(), &host, &port); - return std::string(host.data(), host.size()); + char* host; + char* port; + + gpr_split_host_port(worker.c_str(), &host, &port); + const string s(host); + + gpr_free(host); + gpr_free(port); + return s; } static deque get_workers(const string& env_name) { @@ -319,10 +324,11 @@ std::unique_ptr RunScenario( client_config.add_server_targets(cli_target); } else { std::string host; - grpc_core::UniquePtr cli_target; + char* cli_target; host = get_host(workers[i]); - grpc_core::JoinHostPort(&cli_target, host.c_str(), init_status.port()); - client_config.add_server_targets(cli_target.get()); + gpr_join_host_port(&cli_target, host.c_str(), init_status.port()); + client_config.add_server_targets(cli_target); + gpr_free(cli_target); } } diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc index bdf94d86c10..23fe72316a1 100644 --- a/test/cpp/qps/qps_worker.cc +++ b/test/cpp/qps/qps_worker.cc @@ -34,7 +34,7 @@ #include #include -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/proto/grpc/testing/worker_service.grpc.pb.h" #include "test/core/util/grpc_profiler.h" #include "test/core/util/histogram.h" @@ -279,11 +279,12 @@ QpsWorker::QpsWorker(int driver_port, int server_port, std::unique_ptr builder = CreateQpsServerBuilder(); if (driver_port >= 0) { - grpc_core::UniquePtr server_address; - grpc_core::JoinHostPort(&server_address, "::", driver_port); + char* server_address = nullptr; + gpr_join_host_port(&server_address, "::", driver_port); builder->AddListeningPort( - server_address.get(), + server_address, GetCredentialsProvider()->GetServerCredentials(credential_type)); + gpr_free(server_address); } builder->RegisterService(impl_.get()); diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index e9978212f95..a5f8347c269 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -34,7 +34,7 @@ #include #include -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/completion_queue.h" #include "src/proto/grpc/testing/benchmark_service.grpc.pb.h" #include "test/core/util/test_config.h" @@ -80,10 +80,11 @@ class AsyncQpsServerTest final : public grpc::testing::Server { auto port_num = port(); // Negative port number means inproc server, so no listen port needed if (port_num >= 0) { - grpc_core::UniquePtr server_address; - grpc_core::JoinHostPort(&server_address, "::", port_num); - builder->AddListeningPort(server_address.get(), + char* server_address = nullptr; + gpr_join_host_port(&server_address, "::", port_num); + builder->AddListeningPort(server_address, Server::CreateServerCredentials(config)); + gpr_free(server_address); } register_service(builder.get(), &async_service_); diff --git a/test/cpp/qps/server_callback.cc b/test/cpp/qps/server_callback.cc index 1829905cb49..4a346dd0178 100644 --- a/test/cpp/qps/server_callback.cc +++ b/test/cpp/qps/server_callback.cc @@ -21,7 +21,7 @@ #include #include -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/proto/grpc/testing/benchmark_service.grpc.pb.h" #include "test/cpp/qps/qps_server_builder.h" #include "test/cpp/qps/server.h" @@ -103,10 +103,11 @@ class CallbackServer final : public grpc::testing::Server { auto port_num = port(); // Negative port number means inproc server, so no listen port needed if (port_num >= 0) { - grpc_core::UniquePtr server_address; - grpc_core::JoinHostPort(&server_address, "::", port_num); - builder->AddListeningPort(server_address.get(), + char* server_address = nullptr; + gpr_join_host_port(&server_address, "::", port_num); + builder->AddListeningPort(server_address, Server::CreateServerCredentials(config)); + gpr_free(server_address); } ApplyConfigToBuilder(config, builder.get()); diff --git a/test/cpp/qps/server_sync.cc b/test/cpp/qps/server_sync.cc index 7b76e9c206a..2e63f5ec867 100644 --- a/test/cpp/qps/server_sync.cc +++ b/test/cpp/qps/server_sync.cc @@ -25,7 +25,7 @@ #include #include -#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gpr/host_port.h" #include "src/proto/grpc/testing/benchmark_service.grpc.pb.h" #include "test/cpp/qps/qps_server_builder.h" #include "test/cpp/qps/server.h" @@ -160,10 +160,11 @@ class SynchronousServer final : public grpc::testing::Server { auto port_num = port(); // Negative port number means inproc server, so no listen port needed if (port_num >= 0) { - grpc_core::UniquePtr server_address; - grpc_core::JoinHostPort(&server_address, "::", port_num); - builder->AddListeningPort(server_address.get(), + char* server_address = nullptr; + gpr_join_host_port(&server_address, "::", port_num); + builder->AddListeningPort(server_address, Server::CreateServerCredentials(config)); + gpr_free(server_address); } ApplyConfigToBuilder(config, builder.get()); diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index d783dae496c..e2d753e02eb 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1076,6 +1076,7 @@ src/core/lib/debug/trace.h \ src/core/lib/gpr/alloc.h \ src/core/lib/gpr/arena.h \ src/core/lib/gpr/env.h \ +src/core/lib/gpr/host_port.h \ src/core/lib/gpr/mpscq.h \ src/core/lib/gpr/murmur_hash.h \ src/core/lib/gpr/spinlock.h \ @@ -1097,7 +1098,6 @@ src/core/lib/gprpp/global_config.h \ src/core/lib/gprpp/global_config_custom.h \ src/core/lib/gprpp/global_config_env.h \ src/core/lib/gprpp/global_config_generic.h \ -src/core/lib/gprpp/host_port.h \ src/core/lib/gprpp/inlined_vector.h \ src/core/lib/gprpp/manual_constructor.h \ src/core/lib/gprpp/map.h \ @@ -1107,7 +1107,6 @@ src/core/lib/gprpp/orphanable.h \ src/core/lib/gprpp/pair.h \ src/core/lib/gprpp/ref_counted.h \ src/core/lib/gprpp/ref_counted_ptr.h \ -src/core/lib/gprpp/string_view.h \ src/core/lib/gprpp/sync.h \ src/core/lib/gprpp/thd.h \ src/core/lib/http/format_request.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 1dae91d2eaf..7768bca30f5 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1125,6 +1125,8 @@ src/core/lib/gpr/env.h \ src/core/lib/gpr/env_linux.cc \ src/core/lib/gpr/env_posix.cc \ src/core/lib/gpr/env_windows.cc \ +src/core/lib/gpr/host_port.cc \ +src/core/lib/gpr/host_port.h \ src/core/lib/gpr/log.cc \ src/core/lib/gpr/log_android.cc \ src/core/lib/gpr/log_linux.cc \ @@ -1173,8 +1175,6 @@ src/core/lib/gprpp/global_config_custom.h \ src/core/lib/gprpp/global_config_env.cc \ src/core/lib/gprpp/global_config_env.h \ src/core/lib/gprpp/global_config_generic.h \ -src/core/lib/gprpp/host_port.cc \ -src/core/lib/gprpp/host_port.h \ src/core/lib/gprpp/inlined_vector.h \ src/core/lib/gprpp/manual_constructor.h \ src/core/lib/gprpp/map.h \ @@ -1184,7 +1184,6 @@ src/core/lib/gprpp/orphanable.h \ src/core/lib/gprpp/pair.h \ src/core/lib/gprpp/ref_counted.h \ src/core/lib/gprpp/ref_counted_ptr.h \ -src/core/lib/gprpp/string_view.h \ src/core/lib/gprpp/sync.h \ src/core/lib/gprpp/thd.h \ src/core/lib/gprpp/thd_posix.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index dc2b0531e71..8765f216dab 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -683,7 +683,7 @@ "language": "c", "name": "gpr_host_port_test", "src": [ - "test/core/gprpp/host_port_test.cc" + "test/core/gpr/host_port_test.cc" ], "third_party": false, "type": "target" @@ -5058,24 +5058,6 @@ "third_party": false, "type": "target" }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "string_view_test", - "src": [ - "test/core/gprpp/string_view_test.cc" - ], - "third_party": false, - "type": "target" - }, { "deps": [ "gpr", @@ -8207,6 +8189,7 @@ "src/core/lib/gpr/env_linux.cc", "src/core/lib/gpr/env_posix.cc", "src/core/lib/gpr/env_windows.cc", + "src/core/lib/gpr/host_port.cc", "src/core/lib/gpr/log.cc", "src/core/lib/gpr/log_android.cc", "src/core/lib/gpr/log_linux.cc", @@ -8233,7 +8216,6 @@ "src/core/lib/gprpp/arena.cc", "src/core/lib/gprpp/fork.cc", "src/core/lib/gprpp/global_config_env.cc", - "src/core/lib/gprpp/host_port.cc", "src/core/lib/gprpp/thd_posix.cc", "src/core/lib/gprpp/thd_windows.cc", "src/core/lib/profiling/basic_timers.cc", @@ -8267,6 +8249,7 @@ "src/core/lib/gpr/alloc.h", "src/core/lib/gpr/arena.h", "src/core/lib/gpr/env.h", + "src/core/lib/gpr/host_port.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", "src/core/lib/gpr/spinlock.h", @@ -8287,7 +8270,6 @@ "src/core/lib/gprpp/global_config_custom.h", "src/core/lib/gprpp/global_config_env.h", "src/core/lib/gprpp/global_config_generic.h", - "src/core/lib/gprpp/host_port.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", @@ -8320,6 +8302,7 @@ "src/core/lib/gpr/alloc.h", "src/core/lib/gpr/arena.h", "src/core/lib/gpr/env.h", + "src/core/lib/gpr/host_port.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", "src/core/lib/gpr/spinlock.h", @@ -8340,7 +8323,6 @@ "src/core/lib/gprpp/global_config_custom.h", "src/core/lib/gprpp/global_config_env.h", "src/core/lib/gprpp/global_config_generic.h", - "src/core/lib/gprpp/host_port.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", @@ -8641,7 +8623,6 @@ "src/core/lib/gprpp/orphanable.h", "src/core/lib/gprpp/ref_counted.h", "src/core/lib/gprpp/ref_counted_ptr.h", - "src/core/lib/gprpp/string_view.h", "src/core/lib/http/format_request.h", "src/core/lib/http/httpcli.h", "src/core/lib/http/parser.h", @@ -8799,7 +8780,6 @@ "src/core/lib/gprpp/orphanable.h", "src/core/lib/gprpp/ref_counted.h", "src/core/lib/gprpp/ref_counted_ptr.h", - "src/core/lib/gprpp/string_view.h", "src/core/lib/http/format_request.h", "src/core/lib/http/httpcli.h", "src/core/lib/http/parser.h", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 9e835c22bb6..625d3bd295f 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -5730,30 +5730,6 @@ ], "uses_polling": true }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": true, - "language": "c++", - "name": "string_view_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "uses_polling": true - }, { "args": [], "benchmark": false, From 0e85762b67cca0e049c668a96b759217b1a1f383 Mon Sep 17 00:00:00 2001 From: Qixuan Li Date: Tue, 25 Jun 2019 11:24:17 -0700 Subject: [PATCH 0726/1555] add pick_first_unary --- src/proto/grpc/testing/messages.proto | 7 +++++++ test/cpp/interop/client.cc | 2 ++ test/cpp/interop/client_helper.cc | 7 +++++++ test/cpp/interop/interop_client.cc | 23 +++++++++++++++++++++++ test/cpp/interop/interop_client.h | 2 ++ 5 files changed, 41 insertions(+) diff --git a/src/proto/grpc/testing/messages.proto b/src/proto/grpc/testing/messages.proto index 7b1b7286dce..3b966ae1b25 100644 --- a/src/proto/grpc/testing/messages.proto +++ b/src/proto/grpc/testing/messages.proto @@ -77,6 +77,9 @@ message SimpleRequest { // Whether the server should expect this request to be compressed. BoolValue expect_compressed = 8; + + // Whether SimpleResponse should include server_id. + bool fill_server_id = 9; } // Unary response, as configured by the request. @@ -88,6 +91,10 @@ message SimpleResponse { string username = 2; // OAuth scope. string oauth_scope = 3; + + // Server ID. This must be unique among different server instances, + // but the same across all RPC's made to a particular server instance. + string server_id = 4; } // Client-streaming request. diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index ccfd2bb0c45..47653b25ef9 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -222,6 +222,8 @@ int main(int argc, char** argv) { &grpc::testing::InteropClient::DoTimeoutOnSleepingServer, &client); actions["empty_stream"] = std::bind(&grpc::testing::InteropClient::DoEmptyStream, &client); + actions["pick_first_unary"] = + std::bind(&grpc::testing::InteropClient::DoPickFirstUnary, &client); if (FLAGS_use_tls) { actions["compute_engine_creds"] = std::bind(&grpc::testing::InteropClient::DoComputeEngineCreds, &client, diff --git a/test/cpp/interop/client_helper.cc b/test/cpp/interop/client_helper.cc index 92f07387d75..2f312542b9b 100644 --- a/test/cpp/interop/client_helper.cc +++ b/test/cpp/interop/client_helper.cc @@ -105,6 +105,13 @@ std::shared_ptr CreateChannelForTestCase( creds = FLAGS_custom_credentials_type == "google_default_credentials" ? nullptr : AccessTokenCredentials(GetOauth2AccessToken()); + } else if (test_case == "pick_first_unary") { + ChannelArguments channel_args; + // force using pick first policy + channel_args.SetInt(GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION, 0); + return CreateTestChannel(host_port, FLAGS_custom_credentials_type, + FLAGS_server_host_override, !FLAGS_use_test_ca, + creds, channel_args); } if (FLAGS_custom_credentials_type.empty()) { transport_security security_type = diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index 649abf8a938..7c9a702a726 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -948,6 +948,29 @@ bool InteropClient::DoCacheableUnary() { return true; } +bool InteropClient::DoPickFirstUnary() { + const int rpcCount = 100; + SimpleRequest request; + SimpleResponse response; + std::string first_server_id; + request.set_fill_server_id(true); + for (int i = 0; i < rpcCount; i++) { + ClientContext context; + Status s = serviceStub_.Get()->UnaryCall(&context, request, &response); + if (!AssertStatusOk(s, context.debug_error_string())) { + return false; + } + if (i == 0) { + first_server_id = response.server_id(); + gpr_log(GPR_DEBUG, "first_user_id is %s", first_server_id.c_str()); + continue; + } + GPR_ASSERT(response.server_id() == first_server_id); + } + gpr_log(GPR_DEBUG, "pick first unary successfully finished"); + return true; +} + bool InteropClient::DoCustomMetadata() { const grpc::string kEchoInitialMetadataKey("x-grpc-test-echo-initial"); const grpc::string kInitialMetadataValue("test_initial_metadata_value"); diff --git a/test/cpp/interop/interop_client.h b/test/cpp/interop/interop_client.h index 22df688468b..483d9becac2 100644 --- a/test/cpp/interop/interop_client.h +++ b/test/cpp/interop/interop_client.h @@ -69,6 +69,8 @@ class InteropClient { bool DoUnimplementedMethod(); bool DoUnimplementedService(); bool DoCacheableUnary(); + // all requests are sent to one server despite multiple servers are resolved + bool DoPickFirstUnary(); // The following interop test are not yet part of the interop spec, and are // not implemented cross-language. They are considered experimental for now, From e92622eb5be9b8e53dec5a48a3c6dc7ddbf963c4 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Fri, 7 Jun 2019 15:13:47 -0700 Subject: [PATCH 0727/1555] Add PHP back to client_matrix.py --- tools/interop_matrix/client_matrix.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index 05c495f5633..7bcfa075559 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -284,9 +284,9 @@ LANG_RELEASE_MATRIX = { ('v1.16.0', ReleaseInfo(testcases_file='php__v1.0.1')), ('v1.17.1', ReleaseInfo(testcases_file='php__v1.0.1')), ('v1.18.0', ReleaseInfo()), + # v1.19 and v1.20 were deliberately ommitted here because of an issue. + # See https://github.com/grpc/grpc/issues/18264 ('v1.21.4', ReleaseInfo()), - # TODO:https://github.com/grpc/grpc/issues/18264 - # Error in above issues needs to be resolved. ]), 'csharp': OrderedDict([ From 18fb10cdd6544ae2ec69367591a4ba2e40209b05 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Wed, 26 Jun 2019 13:59:23 -0700 Subject: [PATCH 0728/1555] Add some comment --- test/core/iomgr/mpmcqueue_test.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index 12107e85327..a301832f608 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -33,7 +33,9 @@ struct WorkItem { WorkItem(int i) : index(i) { done = false; } }; -// Thread for put items into queue +// Thread to "produce" items and put items into queue +// It will also check that all items has been marked done and clean up all +// produced items on destructing. class ProducerThread { public: ProducerThread(grpc_core::InfLenFIFOQueue* queue, int start_index, @@ -72,6 +74,7 @@ class ProducerThread { WorkItem** items_; }; +// Thread to pull out items from queue class ConsumerThread { public: ConsumerThread(grpc_core::InfLenFIFOQueue* queue) : queue_(queue) { From bddcb6c906757c4741168817d27606e496074495 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 26 Jun 2019 14:28:34 -0700 Subject: [PATCH 0729/1555] Don't move ServerContext to impl --- BUILD | 1 - BUILD.gn | 1 - CMakeLists.txt | 3 --- Makefile | 3 --- build.yaml | 1 - gRPC-C++.podspec | 1 - include/grpcpp/server_context_impl.h | 24 ------------------- tools/doxygen/Doxyfile.c++ | 1 - tools/doxygen/Doxyfile.c++.internal | 1 - .../generated/sources_and_headers.json | 2 -- 10 files changed, 38 deletions(-) delete mode 100644 include/grpcpp/server_context_impl.h diff --git a/BUILD b/BUILD index 172a90e151e..87d3b978358 100644 --- a/BUILD +++ b/BUILD @@ -265,7 +265,6 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/server_builder.h", "include/grpcpp/server_builder_impl.h", "include/grpcpp/server_context.h", - "include/grpcpp/server_context_impl.h", "include/grpcpp/server_posix.h", "include/grpcpp/server_posix_impl.h", "include/grpcpp/support/async_stream.h", diff --git a/BUILD.gn b/BUILD.gn index 534c88bd67f..fc9fa8dc3d0 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1119,7 +1119,6 @@ config("grpc_config") { "include/grpcpp/server_builder.h", "include/grpcpp/server_builder_impl.h", "include/grpcpp/server_context.h", - "include/grpcpp/server_context_impl.h", "include/grpcpp/server_impl.h", "include/grpcpp/server_posix.h", "include/grpcpp/server_posix_impl.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 46bd48cccdb..ce16506ab62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3200,7 +3200,6 @@ foreach(_hdr include/grpcpp/server_builder.h include/grpcpp/server_builder_impl.h include/grpcpp/server_context.h - include/grpcpp/server_context_impl.h include/grpcpp/server_impl.h include/grpcpp/server_posix.h include/grpcpp/server_posix_impl.h @@ -3823,7 +3822,6 @@ foreach(_hdr include/grpcpp/server_builder.h include/grpcpp/server_builder_impl.h include/grpcpp/server_context.h - include/grpcpp/server_context_impl.h include/grpcpp/server_impl.h include/grpcpp/server_posix.h include/grpcpp/server_posix_impl.h @@ -4824,7 +4822,6 @@ foreach(_hdr include/grpcpp/server_builder.h include/grpcpp/server_builder_impl.h include/grpcpp/server_context.h - include/grpcpp/server_context_impl.h include/grpcpp/server_impl.h include/grpcpp/server_posix.h include/grpcpp/server_posix_impl.h diff --git a/Makefile b/Makefile index 702c571f585..e2e8aa60488 100644 --- a/Makefile +++ b/Makefile @@ -5574,7 +5574,6 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/server_builder.h \ include/grpcpp/server_builder_impl.h \ include/grpcpp/server_context.h \ - include/grpcpp/server_context_impl.h \ include/grpcpp/server_impl.h \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ @@ -6205,7 +6204,6 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/server_builder.h \ include/grpcpp/server_builder_impl.h \ include/grpcpp/server_context.h \ - include/grpcpp/server_context_impl.h \ include/grpcpp/server_impl.h \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ @@ -7155,7 +7153,6 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/server_builder.h \ include/grpcpp/server_builder_impl.h \ include/grpcpp/server_context.h \ - include/grpcpp/server_context_impl.h \ include/grpcpp/server_impl.h \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ diff --git a/build.yaml b/build.yaml index d63284e1267..5b9a8c1594e 100644 --- a/build.yaml +++ b/build.yaml @@ -1406,7 +1406,6 @@ filegroups: - include/grpcpp/server_builder.h - include/grpcpp/server_builder_impl.h - include/grpcpp/server_context.h - - include/grpcpp/server_context_impl.h - include/grpcpp/server_impl.h - include/grpcpp/server_posix.h - include/grpcpp/server_posix_impl.h diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 981fb345eee..6fc97c6135e 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -125,7 +125,6 @@ Pod::Spec.new do |s| 'include/grpcpp/server_builder.h', 'include/grpcpp/server_builder_impl.h', 'include/grpcpp/server_context.h', - 'include/grpcpp/server_context_impl.h', 'include/grpcpp/server_impl.h', 'include/grpcpp/server_posix.h', 'include/grpcpp/server_posix_impl.h', diff --git a/include/grpcpp/server_context_impl.h b/include/grpcpp/server_context_impl.h deleted file mode 100644 index 3a944f3da8f..00000000000 --- a/include/grpcpp/server_context_impl.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_SERVER_CONTEXT_IMPL_H -#define GRPCPP_SERVER_CONTEXT_IMPL_H - -#include - -#endif // GRPCPP_SERVER_CONTEXT_IMPL_H diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index fe242437921..501be844410 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -1020,7 +1020,6 @@ include/grpcpp/server.h \ include/grpcpp/server_builder.h \ include/grpcpp/server_builder_impl.h \ include/grpcpp/server_context.h \ -include/grpcpp/server_context_impl.h \ include/grpcpp/server_impl.h \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index e500b317af8..f1dd2e54e1d 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1022,7 +1022,6 @@ include/grpcpp/server.h \ include/grpcpp/server_builder.h \ include/grpcpp/server_builder_impl.h \ include/grpcpp/server_context.h \ -include/grpcpp/server_context_impl.h \ include/grpcpp/server_impl.h \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 98b9bdc4261..b157439a3f4 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -10421,7 +10421,6 @@ "include/grpcpp/server_builder.h", "include/grpcpp/server_builder_impl.h", "include/grpcpp/server_context.h", - "include/grpcpp/server_context_impl.h", "include/grpcpp/server_impl.h", "include/grpcpp/server_posix.h", "include/grpcpp/server_posix_impl.h", @@ -10550,7 +10549,6 @@ "include/grpcpp/server_builder.h", "include/grpcpp/server_builder_impl.h", "include/grpcpp/server_context.h", - "include/grpcpp/server_context_impl.h", "include/grpcpp/server_impl.h", "include/grpcpp/server_posix.h", "include/grpcpp/server_posix_impl.h", From 7a4b6b7e302ebc970ee4225bf13e0190472b2356 Mon Sep 17 00:00:00 2001 From: yang-g Date: Wed, 26 Jun 2019 15:00:26 -0700 Subject: [PATCH 0730/1555] Update oauth2 token endpoints --- src/core/lib/security/credentials/credentials.h | 4 ++-- src/core/lib/security/credentials/jwt/json_token.h | 2 +- test/core/security/jwt_verifier_test.cc | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h index a9d581280d1..907cf2b02f6 100644 --- a/src/core/lib/security/credentials/credentials.h +++ b/src/core/lib/security/credentials/credentials.h @@ -64,8 +64,8 @@ typedef enum { #define GRPC_COMPUTE_ENGINE_METADATA_TOKEN_PATH \ "/computeMetadata/v1/instance/service-accounts/default/token" -#define GRPC_GOOGLE_OAUTH2_SERVICE_HOST "www.googleapis.com" -#define GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH "/oauth2/v3/token" +#define GRPC_GOOGLE_OAUTH2_SERVICE_HOST "oauth2.googleapis.com" +#define GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH "/token" #define GRPC_SERVICE_ACCOUNT_POST_BODY_PREFIX \ "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&" \ diff --git a/src/core/lib/security/credentials/jwt/json_token.h b/src/core/lib/security/credentials/jwt/json_token.h index 3ed990140d3..20390f3096a 100644 --- a/src/core/lib/security/credentials/jwt/json_token.h +++ b/src/core/lib/security/credentials/jwt/json_token.h @@ -30,7 +30,7 @@ /* --- Constants. --- */ -#define GRPC_JWT_OAUTH2_AUDIENCE "https://www.googleapis.com/oauth2/v3/token" +#define GRPC_JWT_OAUTH2_AUDIENCE "https://oauth2.googleapis.com/token" /* --- auth_json_key parsing. --- */ diff --git a/test/core/security/jwt_verifier_test.cc b/test/core/security/jwt_verifier_test.cc index 70155cdd065..21a7aa47b9d 100644 --- a/test/core/security/jwt_verifier_test.cc +++ b/test/core/security/jwt_verifier_test.cc @@ -128,9 +128,9 @@ static const char good_openid_config[] = " \"issuer\": \"https://accounts.google.com\"," " \"authorization_endpoint\": " "\"https://accounts.google.com/o/oauth2/v2/auth\"," - " \"token_endpoint\": \"https://www.googleapis.com/oauth2/v4/token\"," + " \"token_endpoint\": \"https://oauth2.googleapis.com/token\"," " \"userinfo_endpoint\": \"https://www.googleapis.com/oauth2/v3/userinfo\"," - " \"revocation_endpoint\": \"https://accounts.google.com/o/oauth2/revoke\"," + " \"revocation_endpoint\": \"https://oauth2.googleapis.com/revoke\"," " \"jwks_uri\": \"https://www.googleapis.com/oauth2/v3/certs\"" "}"; From 0fc57d04142e87812884fb5f9b1b03f36b701034 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Wed, 26 Jun 2019 15:15:07 -0700 Subject: [PATCH 0731/1555] Slightly better codegen for hpack_encoder. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hpack_encoder::ensure_space checks to see if we need to allocate to start a frame or not. The common case is that we don't need to, so we mark that code branch as the more likely one to occur. This causes the common case to jump around less. BM_HpackEncoderEncodeDeadline 152ns ± 0% 149ns ± 0% -1.99% (p=0.000 n=19+17) BM_HpackEncoderEncodeHeader/0/16384 35.0ns ± 2% 34.6ns ± 0% -1.10% (p=0.000 n=20+17) BM_HpackEncoderEncodeHeader/1/16384 34.9ns ± 1% 34.7ns ± 1% -0.81% (p=0.007 n=20+19) BM_HpackEncoderEncodeHeader/0/16384 50.6ns ± 0% 49.1ns ± 1% -3.06% (p=0.000 n=17+19) BM_HpackEncoderEncodeHeader/0/16384 84.9ns ± 1% 82.4ns ± 1% -2.90% (p=0.000 n=20+19) BM_HpackEncoderEncodeHeader/0/16384 50.5ns ± 0% 49.2ns ± 1% -2.54% (p=0.000 n=15+19) BM_HpackEncoderEncodeHeader>/0/16384 50.8ns ± 2% 49.6ns ± 1% -2.46% (p=0.000 n=17+19) BM_HpackEncoderEncodeHeader>/0/16384 50.9ns ± 2% 49.5ns ± 1% -2.78% (p=0.000 n=20+19) BM_HpackEncoderEncodeHeader>/0/16384 50.4ns ± 1% 49.2ns ± 1% -2.32% (p=0.000 n=18+19) BM_HpackEncoderEncodeHeader>/0/16384 50.3ns ± 0% 49.2ns ± 1% -2.16% (p=0.000 n=18+19) BM_HpackEncoderEncodeHeader>/0/16384 50.4ns ± 1% 49.2ns ± 1% -2.35% (p=0.000 n=19+19) BM_HpackEncoderEncodeHeader>/0/16384 50.9ns ± 2% 49.4ns ± 1% -2.81% (p=0.000 n=20+19) BM_HpackEncoderEncodeHeader>/0/16384 50.9ns ± 2% 49.4ns ± 1% -2.91% (p=0.000 n=20+19) BM_HpackEncoderEncodeHeader>/0/16384 50.2ns ± 0% 49.2ns ± 0% -2.04% (p=0.000 n=17+19) BM_HpackEncoderEncodeHeader>/0/16384 50.4ns ± 1% 49.2ns ± 1% -2.38% (p=0.000 n=19+19) BM_HpackEncoderEncodeHeader>/0/16384 50.3ns ± 0% 49.2ns ± 0% -2.06% (p=0.000 n=19+19) BM_HpackEncoderEncodeHeader/0/16384 91.7ns ± 1% 85.6ns ± 1% -6.64% (p=0.000 n=19+19) BM_HpackEncoderEncodeHeader>/0/16384 116ns ± 1% 112ns ± 1% -3.95% (p=0.000 n=19+18) BM_HpackEncoderEncodeHeader>/0/16384 122ns ± 0% 117ns ± 1% -3.63% (p=0.000 n=18+17) BM_HpackEncoderEncodeHeader>/0/16384 145ns ± 1% 140ns ± 0% -2.89% (p=0.000 n=18+18) BM_HpackEncoderEncodeHeader>/0/16384 233ns ± 1% 231ns ± 1% -1.14% (p=0.000 n=20+19) BM_HpackEncoderEncodeHeader>/0/16384 472ns ± 1% 469ns ± 1% -0.64% (p=0.000 n=20+19) BM_HpackEncoderEncodeHeader>/0/16384 93.2ns ± 1% 87.3ns ± 1% -6.41% (p=0.000 n=20+17) BM_HpackEncoderEncodeHeader>/0/16384 94.2ns ± 1% 88.0ns ± 1% -6.59% (p=0.000 n=20+17) BM_HpackEncoderEncodeHeader>/0/16384 94.1ns ± 2% 87.5ns ± 1% -6.98% (p=0.000 n=20+17) BM_HpackEncoderEncodeHeader>/0/16384 107ns ± 2% 102ns ± 4% -4.30% (p=0.000 n=19+19) BM_HpackEncoderEncodeHeader>/0/16384 106ns ± 1% 100ns ± 1% -5.64% (p=0.000 n=20+17) BM_HpackEncoderEncodeHeader/0/1 356ns ± 1% 355ns ± 1% -0.47% (p=0.001 n=20+18) BM_HpackEncoderEncodeHeader/0/16384 140ns ± 1% 128ns ± 1% -7.99% (p=0.000 n=20+19) BM_HpackEncoderEncodeHeader/0/16384 237ns ± 1% 218ns ± 1% -7.93% (p=0.000 n=19+19) BM_HpackEncoderEncodeHeader/0/16384 73.7ns ± 1% 69.7ns ± 1% -5.47% (p=0.000 n=20+19) BM_HpackEncoderEncodeHeader/1/16384 50.7ns ± 0% 49.0ns ± 2% -3.19% (p=0.000 n=18+19) --- src/core/ext/transport/chttp2/transport/hpack_encoder.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc index 359ad275bbb..3325c3ec24d 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc @@ -130,8 +130,9 @@ static void begin_frame(framer_state* st) { space to add at least about_to_add bytes -- finishes the current frame if needed */ static void ensure_space(framer_state* st, size_t need_bytes) { - if (st->output->length - st->output_length_at_start_of_frame + need_bytes <= - st->max_frame_size) { + if (GPR_LIKELY(st->output->length - st->output_length_at_start_of_frame + + need_bytes <= + st->max_frame_size)) { return; } finish_frame(st, 0, 0); From 913acf456b3f768880b017c15acbdec7489118bb Mon Sep 17 00:00:00 2001 From: Qixuan Li Date: Wed, 26 Jun 2019 22:32:33 +0000 Subject: [PATCH 0732/1555] fix minor nits --- test/cpp/interop/client_helper.cc | 2 +- test/cpp/interop/interop_client.cc | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/test/cpp/interop/client_helper.cc b/test/cpp/interop/client_helper.cc index 2f312542b9b..a7279eb0092 100644 --- a/test/cpp/interop/client_helper.cc +++ b/test/cpp/interop/client_helper.cc @@ -107,7 +107,7 @@ std::shared_ptr CreateChannelForTestCase( : AccessTokenCredentials(GetOauth2AccessToken()); } else if (test_case == "pick_first_unary") { ChannelArguments channel_args; - // force using pick first policy + // allow the LB policy to be configured with service config channel_args.SetInt(GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION, 0); return CreateTestChannel(host_port, FLAGS_custom_credentials_type, FLAGS_server_host_override, !FLAGS_use_test_ca, diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index 7c9a702a726..f474903331f 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -952,7 +952,7 @@ bool InteropClient::DoPickFirstUnary() { const int rpcCount = 100; SimpleRequest request; SimpleResponse response; - std::string first_server_id; + std::string server_id; request.set_fill_server_id(true); for (int i = 0; i < rpcCount; i++) { ClientContext context; @@ -961,11 +961,14 @@ bool InteropClient::DoPickFirstUnary() { return false; } if (i == 0) { - first_server_id = response.server_id(); - gpr_log(GPR_DEBUG, "first_user_id is %s", first_server_id.c_str()); + server_id = response.server_id(); continue; } - GPR_ASSERT(response.server_id() == first_server_id); + if (response.server_id() != server_id) { + gpr_log(GPR_ERROR, "#%d rpc hits server_id %s, expect server_id %s", i, + response.server_id().c_str(), server_id.c_str()); + return false; + } } gpr_log(GPR_DEBUG, "pick first unary successfully finished"); return true; From 7610817bc860d9f25fc76277684b6d6a90d9784e Mon Sep 17 00:00:00 2001 From: Guantao Liu Date: Wed, 26 Jun 2019 17:38:17 -0700 Subject: [PATCH 0733/1555] Also add the missing implementation of grpc_iomgr_run_in_background() for gevent. --- src/core/lib/iomgr/iomgr_custom.cc | 2 ++ src/core/lib/iomgr/iomgr_uv.cc | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/iomgr_custom.cc b/src/core/lib/iomgr/iomgr_custom.cc index f5ac8a0670a..262417cf0d2 100644 --- a/src/core/lib/iomgr/iomgr_custom.cc +++ b/src/core/lib/iomgr/iomgr_custom.cc @@ -72,6 +72,8 @@ void grpc_custom_iomgr_init(grpc_socket_vtable* socket, grpc_set_iomgr_platform_vtable(&vtable); } +bool grpc_iomgr_run_in_background() { return false; } + #ifdef GRPC_CUSTOM_SOCKET grpc_iomgr_platform_vtable* grpc_default_iomgr_platform_vtable() { return &vtable; diff --git a/src/core/lib/iomgr/iomgr_uv.cc b/src/core/lib/iomgr/iomgr_uv.cc index d00bfa4d46e..4a984446dba 100644 --- a/src/core/lib/iomgr/iomgr_uv.cc +++ b/src/core/lib/iomgr/iomgr_uv.cc @@ -37,6 +37,4 @@ void grpc_set_default_iomgr_platform() { grpc_custom_iomgr_init(&grpc_uv_socket_vtable, &uv_resolver_vtable, &uv_timer_vtable, &uv_pollset_vtable); } - -bool grpc_iomgr_run_in_background() { return false; } #endif From b95bb89d13e8abd51c783a5dc8be82dc85653cf2 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Thu, 27 Jun 2019 09:55:03 -0700 Subject: [PATCH 0734/1555] Add TODO comment --- src/core/lib/gprpp/thd_posix.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/lib/gprpp/thd_posix.cc b/src/core/lib/gprpp/thd_posix.cc index 7415231e97f..99197cbbfa9 100644 --- a/src/core/lib/gprpp/thd_posix.cc +++ b/src/core/lib/gprpp/thd_posix.cc @@ -49,6 +49,8 @@ struct thd_arg { bool tracked; }; +// TODO(yunjiaw): move this to a function-level static, or remove the use of a +// non-constexpr initializer when possible const size_t page_size = static_cast(sysconf(_SC_PAGESIZE)); size_t RoundUpToPageSize(size_t size) { From 424328b8e7c4c8a9b1b6b9d9ea607eab9787ae58 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 27 Jun 2019 10:49:28 -0700 Subject: [PATCH 0735/1555] Resolve uninitialized warning --- src/core/lib/security/credentials/oauth2/oauth2_credentials.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc index 3d63ec12b49..5e0b9416e16 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc @@ -227,7 +227,7 @@ static void on_oauth2_token_fetcher_http_response(void* user_data, void grpc_oauth2_token_fetcher_credentials::on_http_response( grpc_credentials_metadata_request* r, grpc_error* error) { grpc_mdelem access_token_md = GRPC_MDNULL; - grpc_millis token_lifetime; + grpc_millis token_lifetime = 0; grpc_credentials_status status = error == GRPC_ERROR_NONE ? grpc_oauth2_token_fetcher_credentials_parse_server_response( From dc858eea2578f856394f9fd2cd7f4ef2725266d9 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Thu, 27 Jun 2019 14:19:15 -0400 Subject: [PATCH 0736/1555] Fix build failure in credential_test.cc --- test/core/security/credentials_test.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc index cbce595c354..50340311fba 100644 --- a/test/core/security/credentials_test.cc +++ b/test/core/security/credentials_test.cc @@ -32,9 +32,9 @@ #include #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" -#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/http/httpcli.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/security/credentials/composite/composite_credentials.h" @@ -745,11 +745,11 @@ static void test_valid_sts_creds_options(void) { grpc_core::ValidateStsCredentialsOptions(&valid_options, &sts_url); GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(sts_url != nullptr); - grpc_core::StringView host; - grpc_core::StringView port; - GPR_ASSERT(grpc_core::SplitHostPort(sts_url->authority, &host, &port)); - GPR_ASSERT(host.cmp("foo.com") == 0); - GPR_ASSERT(port.cmp("5555") == 0); + char* host; + char* port; + GPR_ASSERT(gpr_split_host_port(sts_url->authority, &host, &port)); + GPR_ASSERT(strcmp(host, "foo.com") == 0); + GPR_ASSERT(strcmp(port, "5555") == 0); grpc_uri_destroy(sts_url); } From 0d2c622f9ee747e7a21447c257e5f88825006216 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 27 Jun 2019 00:42:41 -0700 Subject: [PATCH 0737/1555] Fix DNS resolver cooldown --- CMakeLists.txt | 47 +++++++++++++-- Makefile | 58 +++++++++++++++---- build.yaml | 15 ++++- .../resolver/dns/c_ares/dns_resolver_ares.cc | 3 +- .../resolver/dns/native/dns_resolver.cc | 3 +- test/core/client_channel/resolvers/BUILD | 19 +++++- .../resolvers/dns_resolver_cooldown_test.cc | 48 +++++++++++---- .../generated/sources_and_headers.json | 18 +++++- tools/run_tests/generated/tests.json | 32 +++++++++- 9 files changed, 209 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a34f9265256..6c1f8f24c57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,7 +275,8 @@ add_dependencies(buildtests_c compression_test) add_dependencies(buildtests_c concurrent_connectivity_test) add_dependencies(buildtests_c connection_refused_test) add_dependencies(buildtests_c dns_resolver_connectivity_test) -add_dependencies(buildtests_c dns_resolver_cooldown_test) +add_dependencies(buildtests_c dns_resolver_cooldown_using_ares_resolver_test) +add_dependencies(buildtests_c dns_resolver_cooldown_using_native_resolver_test) add_dependencies(buildtests_c dns_resolver_test) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_c dualstack_socket_test) @@ -6874,12 +6875,12 @@ target_link_libraries(dns_resolver_connectivity_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) -add_executable(dns_resolver_cooldown_test +add_executable(dns_resolver_cooldown_using_ares_resolver_test test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc ) -target_include_directories(dns_resolver_cooldown_test +target_include_directories(dns_resolver_cooldown_using_ares_resolver_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${_gRPC_SSL_INCLUDE_DIR} @@ -6892,7 +6893,7 @@ target_include_directories(dns_resolver_cooldown_test PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} ) -target_link_libraries(dns_resolver_cooldown_test +target_link_libraries(dns_resolver_cooldown_using_ares_resolver_test ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util grpc @@ -6901,8 +6902,42 @@ target_link_libraries(dns_resolver_cooldown_test # avoid dependency on libstdc++ if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(dns_resolver_cooldown_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(dns_resolver_cooldown_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) + set_target_properties(dns_resolver_cooldown_using_ares_resolver_test PROPERTIES LINKER_LANGUAGE C) + target_compile_options(dns_resolver_cooldown_using_ares_resolver_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) + endif() + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + +add_executable(dns_resolver_cooldown_using_native_resolver_test + test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc +) + + +target_include_directories(dns_resolver_cooldown_using_native_resolver_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} +) + +target_link_libraries(dns_resolver_cooldown_using_native_resolver_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + grpc + gpr +) + + # avoid dependency on libstdc++ + if (_gRPC_CORE_NOSTDCXX_FLAGS) + set_target_properties(dns_resolver_cooldown_using_native_resolver_test PROPERTIES LINKER_LANGUAGE C) + target_compile_options(dns_resolver_cooldown_using_native_resolver_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) endif() endif (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index 9930fc35a25..52c175dab48 100644 --- a/Makefile +++ b/Makefile @@ -1015,7 +1015,8 @@ compression_test: $(BINDIR)/$(CONFIG)/compression_test concurrent_connectivity_test: $(BINDIR)/$(CONFIG)/concurrent_connectivity_test connection_refused_test: $(BINDIR)/$(CONFIG)/connection_refused_test dns_resolver_connectivity_test: $(BINDIR)/$(CONFIG)/dns_resolver_connectivity_test -dns_resolver_cooldown_test: $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_test +dns_resolver_cooldown_using_ares_resolver_test: $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_ares_resolver_test +dns_resolver_cooldown_using_native_resolver_test: $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_native_resolver_test dns_resolver_test: $(BINDIR)/$(CONFIG)/dns_resolver_test dualstack_socket_test: $(BINDIR)/$(CONFIG)/dualstack_socket_test endpoint_pair_test: $(BINDIR)/$(CONFIG)/endpoint_pair_test @@ -1446,7 +1447,8 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/concurrent_connectivity_test \ $(BINDIR)/$(CONFIG)/connection_refused_test \ $(BINDIR)/$(CONFIG)/dns_resolver_connectivity_test \ - $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_test \ + $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_ares_resolver_test \ + $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_native_resolver_test \ $(BINDIR)/$(CONFIG)/dns_resolver_test \ $(BINDIR)/$(CONFIG)/dualstack_socket_test \ $(BINDIR)/$(CONFIG)/endpoint_pair_test \ @@ -1983,8 +1985,10 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/connection_refused_test || ( echo test connection_refused_test failed ; exit 1 ) $(E) "[RUN] Testing dns_resolver_connectivity_test" $(Q) $(BINDIR)/$(CONFIG)/dns_resolver_connectivity_test || ( echo test dns_resolver_connectivity_test failed ; exit 1 ) - $(E) "[RUN] Testing dns_resolver_cooldown_test" - $(Q) $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_test || ( echo test dns_resolver_cooldown_test failed ; exit 1 ) + $(E) "[RUN] Testing dns_resolver_cooldown_using_ares_resolver_test" + $(Q) $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_ares_resolver_test || ( echo test dns_resolver_cooldown_using_ares_resolver_test failed ; exit 1 ) + $(E) "[RUN] Testing dns_resolver_cooldown_using_native_resolver_test" + $(Q) $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_native_resolver_test || ( echo test dns_resolver_cooldown_using_native_resolver_test failed ; exit 1 ) $(E) "[RUN] Testing dns_resolver_test" $(Q) $(BINDIR)/$(CONFIG)/dns_resolver_test || ( echo test dns_resolver_test failed ; exit 1 ) $(E) "[RUN] Testing dualstack_socket_test" @@ -9638,34 +9642,66 @@ endif endif -DNS_RESOLVER_COOLDOWN_TEST_SRC = \ +DNS_RESOLVER_COOLDOWN_USING_ARES_RESOLVER_TEST_SRC = \ test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc \ -DNS_RESOLVER_COOLDOWN_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(DNS_RESOLVER_COOLDOWN_TEST_SRC)))) +DNS_RESOLVER_COOLDOWN_USING_ARES_RESOLVER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(DNS_RESOLVER_COOLDOWN_USING_ARES_RESOLVER_TEST_SRC)))) ifeq ($(NO_SECURE),true) # You can't build secure targets if you don't have OpenSSL. -$(BINDIR)/$(CONFIG)/dns_resolver_cooldown_test: openssl_dep_error +$(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_ares_resolver_test: openssl_dep_error else -$(BINDIR)/$(CONFIG)/dns_resolver_cooldown_test: $(DNS_RESOLVER_COOLDOWN_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_ares_resolver_test: $(DNS_RESOLVER_COOLDOWN_USING_ARES_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(DNS_RESOLVER_COOLDOWN_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_test + $(Q) $(LD) $(LDFLAGS) $(DNS_RESOLVER_COOLDOWN_USING_ARES_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_ares_resolver_test endif $(OBJDIR)/$(CONFIG)/test/core/client_channel/resolvers/dns_resolver_cooldown_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a -deps_dns_resolver_cooldown_test: $(DNS_RESOLVER_COOLDOWN_TEST_OBJS:.o=.dep) +deps_dns_resolver_cooldown_using_ares_resolver_test: $(DNS_RESOLVER_COOLDOWN_USING_ARES_RESOLVER_TEST_OBJS:.o=.dep) ifneq ($(NO_SECURE),true) ifneq ($(NO_DEPS),true) --include $(DNS_RESOLVER_COOLDOWN_TEST_OBJS:.o=.dep) +-include $(DNS_RESOLVER_COOLDOWN_USING_ARES_RESOLVER_TEST_OBJS:.o=.dep) +endif +endif + + +DNS_RESOLVER_COOLDOWN_USING_NATIVE_RESOLVER_TEST_SRC = \ + test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc \ + +DNS_RESOLVER_COOLDOWN_USING_NATIVE_RESOLVER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(DNS_RESOLVER_COOLDOWN_USING_NATIVE_RESOLVER_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_native_resolver_test: openssl_dep_error + +else + + + +$(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_native_resolver_test: $(DNS_RESOLVER_COOLDOWN_USING_NATIVE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LD) $(LDFLAGS) $(DNS_RESOLVER_COOLDOWN_USING_NATIVE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_native_resolver_test + +endif + +$(OBJDIR)/$(CONFIG)/test/core/client_channel/resolvers/dns_resolver_cooldown_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_dns_resolver_cooldown_using_native_resolver_test: $(DNS_RESOLVER_COOLDOWN_USING_NATIVE_RESOLVER_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(DNS_RESOLVER_COOLDOWN_USING_NATIVE_RESOLVER_TEST_OBJS:.o=.dep) endif endif diff --git a/build.yaml b/build.yaml index dad2146bd1c..a5b271ebad2 100644 --- a/build.yaml +++ b/build.yaml @@ -2399,7 +2399,7 @@ targets: - gpr exclude_iomgrs: - uv -- name: dns_resolver_cooldown_test +- name: dns_resolver_cooldown_using_ares_resolver_test build: test language: c src: @@ -2408,6 +2408,19 @@ targets: - grpc_test_util - grpc - gpr + args: + - --resolver=ares +- name: dns_resolver_cooldown_using_native_resolver_test + build: test + language: c + src: + - test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc + deps: + - grpc_test_util + - grpc + - gpr + args: + - --resolver=native - name: dns_resolver_test build: test language: c diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index 32a339af359..24b6537b7ca 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -401,7 +401,8 @@ void AresDnsResolver::MaybeStartResolvingLocked() { // new closure API is done, find a way to track this ref with the timer // callback as part of the type system. Ref(DEBUG_LOCATION, "next_resolution_timer_cooldown").release(); - grpc_timer_init(&next_resolution_timer_, ms_until_next_resolution, + grpc_timer_init(&next_resolution_timer_, + ExecCtx::Get()->Now() + ms_until_next_resolution, &on_next_resolution_); return; } diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc index 5ab75d02793..6a2439a5d35 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc @@ -230,7 +230,8 @@ void NativeDnsResolver::MaybeStartResolvingLocked() { // new closure API is done, find a way to track this ref with the timer // callback as part of the type system. Ref(DEBUG_LOCATION, "next_resolution_timer_cooldown").release(); - grpc_timer_init(&next_resolution_timer_, ms_until_next_resolution, + grpc_timer_init(&next_resolution_timer_, + ExecCtx::Get()->Now() + ms_until_next_resolution, &on_next_resolution_); return; } diff --git a/test/core/client_channel/resolvers/BUILD b/test/core/client_channel/resolvers/BUILD index 3dbee5c9e6d..e5882069cd4 100644 --- a/test/core/client_channel/resolvers/BUILD +++ b/test/core/client_channel/resolvers/BUILD @@ -19,9 +19,26 @@ grpc_package(name = "test/core/client_channel_resolvers") licenses(["notice"]) # Apache v2 grpc_cc_test( - name = "dns_resolver_connectivity_test", + name = "dns_resolver_connectivity_using_ares_resolver_test", srcs = ["dns_resolver_connectivity_test.cc"], language = "C++", + args = [ + "--resolver=ares", + ], + deps = [ + "//:gpr", + "//:grpc", + "//test/core/util:grpc_test_util", + ], +) + +grpc_cc_test( + name = "dns_resolver_connectivity_using_native_resolver_test", + srcs = ["dns_resolver_connectivity_test.cc"], + language = "C++", + args = [ + "--resolver=native", + ], deps = [ "//:gpr", "//:grpc", diff --git a/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc b/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc index 7b3a4589f5b..683d02079c3 100644 --- a/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc @@ -101,12 +101,16 @@ static grpc_ares_request* test_dns_lookup_ares_locked( addresses, check_grpclb, service_config_json, query_timeout_ms, combiner); ++g_resolution_count; static grpc_millis last_resolution_time = 0; + grpc_millis now = + grpc_timespec_to_millis_round_up(gpr_now(GPR_CLOCK_MONOTONIC)); + gpr_log(GPR_DEBUG, + "last_resolution_time:%" PRId64 " now:%" PRId64 + " min_time_between:%d", + last_resolution_time, now, kMinResolutionPeriodForCheckMs); if (last_resolution_time == 0) { last_resolution_time = grpc_timespec_to_millis_round_up(gpr_now(GPR_CLOCK_MONOTONIC)); } else { - grpc_millis now = - grpc_timespec_to_millis_round_up(gpr_now(GPR_CLOCK_MONOTONIC)); GPR_ASSERT(now - last_resolution_time >= kMinResolutionPeriodForCheckMs); last_resolution_time = now; } @@ -212,11 +216,14 @@ struct OnResolutionCallbackArg { // Set to true by the last callback in the resolution chain. static bool g_all_callbacks_invoked; -static void on_second_resolution(OnResolutionCallbackArg* cb_arg) { - gpr_log(GPR_INFO, "2nd: g_resolution_count: %d", g_resolution_count); - // The resolution callback was not invoked until new data was - // available, which was delayed until after the cooldown period. - GPR_ASSERT(g_resolution_count == 2); +// It's interesting to run a few rounds of this test because as +// we run more rounds, the base starting time +// (i.e. ExecCtx g_start_time) gets further and further away +// from "Now()". Thus the more rounds ran, the more highlighted the +// difference is between absolute and relative times values. +static void on_fourth_resolution(OnResolutionCallbackArg* cb_arg) { + gpr_log(GPR_INFO, "4th: g_resolution_count: %d", g_resolution_count); + GPR_ASSERT(g_resolution_count == 4); cb_arg->resolver.reset(); gpr_atm_rel_store(&g_iomgr_args.done_atm, 1); gpr_mu_lock(g_iomgr_args.mu); @@ -227,6 +234,30 @@ static void on_second_resolution(OnResolutionCallbackArg* cb_arg) { g_all_callbacks_invoked = true; } +static void on_third_resolution(OnResolutionCallbackArg* cb_arg) { + gpr_log(GPR_INFO, "3rd: g_resolution_count: %d", g_resolution_count); + GPR_ASSERT(g_resolution_count == 3); + cb_arg->result_handler->SetCallback(on_fourth_resolution, cb_arg); + cb_arg->resolver->RequestReresolutionLocked(); + gpr_mu_lock(g_iomgr_args.mu); + GRPC_LOG_IF_ERROR("pollset_kick", + grpc_pollset_kick(g_iomgr_args.pollset, nullptr)); + gpr_mu_unlock(g_iomgr_args.mu); +} + +static void on_second_resolution(OnResolutionCallbackArg* cb_arg) { + gpr_log(GPR_INFO, "2nd: g_resolution_count: %d", g_resolution_count); + // The resolution callback was not invoked until new data was + // available, which was delayed until after the cooldown period. + GPR_ASSERT(g_resolution_count == 2); + cb_arg->result_handler->SetCallback(on_third_resolution, cb_arg); + cb_arg->resolver->RequestReresolutionLocked(); + gpr_mu_lock(g_iomgr_args.mu); + GRPC_LOG_IF_ERROR("pollset_kick", + grpc_pollset_kick(g_iomgr_args.pollset, nullptr)); + gpr_mu_unlock(g_iomgr_args.mu); +} + static void on_first_resolution(OnResolutionCallbackArg* cb_arg) { gpr_log(GPR_INFO, "1st: g_resolution_count: %d", g_resolution_count); // There's one initial system-level resolution and one invocation of a @@ -243,9 +274,7 @@ static void on_first_resolution(OnResolutionCallbackArg* cb_arg) { static void start_test_under_combiner(void* arg, grpc_error* error) { OnResolutionCallbackArg* res_cb_arg = static_cast(arg); - res_cb_arg->result_handler = grpc_core::New(); - grpc_core::ResolverFactory* factory = grpc_core::ResolverRegistry::LookupResolverFactory("dns"); grpc_uri* uri = grpc_uri_parse(res_cb_arg->uri_str, 0); @@ -300,7 +329,6 @@ int main(int argc, char** argv) { grpc_set_resolver_impl(&test_resolver); test_cooldown(); - { grpc_core::ExecCtx exec_ctx; GRPC_COMBINER_UNREF(g_combiner, "test"); diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 8765f216dab..f99c64e19a1 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -392,7 +392,23 @@ "headers": [], "is_filegroup": false, "language": "c", - "name": "dns_resolver_cooldown_test", + "name": "dns_resolver_cooldown_using_ares_resolver_test", + "src": [ + "test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc" + ], + "third_party": false, + "type": "target" + }, + { + "deps": [ + "gpr", + "grpc", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c", + "name": "dns_resolver_cooldown_using_native_resolver_test", "src": [ "test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc" ], diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 625d3bd295f..89d68a64628 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -484,7 +484,9 @@ "uses_polling": true }, { - "args": [], + "args": [ + "--resolver=ares" + ], "benchmark": false, "ci_platforms": [ "linux", @@ -498,7 +500,33 @@ "flaky": false, "gtest": false, "language": "c", - "name": "dns_resolver_cooldown_test", + "name": "dns_resolver_cooldown_using_ares_resolver_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": true + }, + { + "args": [ + "--resolver=native" + ], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": false, + "language": "c", + "name": "dns_resolver_cooldown_using_native_resolver_test", "platforms": [ "linux", "mac", From 36339f4032f7a2a2800c5c650b79a1f18e351e2e Mon Sep 17 00:00:00 2001 From: nanahpang <31627465+nanahpang@users.noreply.github.com> Date: Thu, 27 Jun 2019 16:25:27 -0700 Subject: [PATCH 0738/1555] fix typo "transfered" to "transferred" find the typo during import and create this pr to sync up --- src/core/lib/security/credentials/oauth2/oauth2_credentials.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc index 5e0b9416e16..06fa8bbdb4b 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc @@ -520,7 +520,7 @@ grpc_error* LoadTokenFile(const char* path, gpr_slice* token) { class StsTokenFetcherCredentials : public grpc_oauth2_token_fetcher_credentials { public: - StsTokenFetcherCredentials(grpc_uri* sts_url, // Ownership transfered. + StsTokenFetcherCredentials(grpc_uri* sts_url, // Ownership transferred. const grpc_sts_credentials_options* options) : sts_url_(sts_url), resource_(gpr_strdup(options->resource)), From 80d1aec0218b3dc72acb23c838deaa0d7a10cb1a Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Thu, 27 Jun 2019 14:54:51 -0700 Subject: [PATCH 0739/1555] Codegen optimizations for hpack_parser on_hdr. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, the log statements for on_hdr clobber some registers even if it is disabled by default. Additionally, the no-error path is doing some unnecessary jumps. This PR separates out and un-inlines the logging code, and marks the no-error case as likely to occur. This results in slightly faster hpack_parsing, e.g.: BM_HpackParserParseHeader 23.8ns ± 0% 19.8ns ± 0% -16.81% (p=0.000 n=17+17) BM_HpackParserParseHeader 160ns ± 0% 154ns ± 0% -3.18% (p=0.000 n=19+20) BM_HpackParserParseHeader 216ns ± 1% 214ns ± 2% -0.70% (p=0.004 n=18+18) BM_HpackParserParseHeader 35.4ns ± 0% 34.4ns ± 0% -2.93% (p=0.000 n=16+16) BM_HpackParserParseHeader 140ns ± 0% 130ns ± 0% -7.06% (p=0.000 n=17+18) BM_HpackParserParseHeader 644ns ± 1% 636ns ± 2% -1.29% (p=0.003 n=17+20) BM_HpackParserParseHeader 49.1ns ± 0% 38.7ns ± 0% -21.13% (p=0.000 n=19+18) BM_HpackParserParseHeader 47.1ns ± 0% 43.2ns ± 0% -8.17% (p=0.000 n=20+19) BM_HpackParserParseHeader 452ns ± 1% 417ns ± 1% -7.86% (p=0.000 n=20+20) BM_HpackParserParseHeader 1.06µs ± 1% 1.02µs ± 2% -3.42% (p=0.000 n=19+20) BM_HpackParserParseHeader 156ns ± 0% 142ns ± 1% -9.08% (p=0.000 n=17+19) BM_HpackParserParseHeader 117ns ± 0% 113ns ± 1% -3.98% (p=0.000 n=20+20) --- .../chttp2/transport/hpack_parser.cc | 96 +++++++++---------- 1 file changed, 44 insertions(+), 52 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index 8db0c96cc52..efbd997e994 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -622,33 +622,37 @@ static const uint8_t inverse_base64[256] = { 255, }; +static void GPR_ATTRIBUTE_NOINLINE on_hdr_log(grpc_mdelem md) { + char* k = grpc_slice_to_c_string(GRPC_MDKEY(md)); + char* v = nullptr; + if (grpc_is_binary_header_internal(GRPC_MDKEY(md))) { + v = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX); + } else { + v = grpc_slice_to_c_string(GRPC_MDVALUE(md)); + } + gpr_log( + GPR_INFO, + "Decode: '%s: %s', elem_interned=%d [%d], k_interned=%d, v_interned=%d", + k, v, GRPC_MDELEM_IS_INTERNED(md), GRPC_MDELEM_STORAGE(md), + grpc_slice_is_interned(GRPC_MDKEY(md)), + grpc_slice_is_interned(GRPC_MDVALUE(md))); + gpr_free(k); + gpr_free(v); +} + /* emission helpers */ -static grpc_error* on_hdr(grpc_chttp2_hpack_parser* p, grpc_mdelem md, - int add_to_table) { +template +static grpc_error* on_hdr(grpc_chttp2_hpack_parser* p, grpc_mdelem md) { if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { - char* k = grpc_slice_to_c_string(GRPC_MDKEY(md)); - char* v = nullptr; - if (grpc_is_binary_header_internal(GRPC_MDKEY(md))) { - v = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX); - } else { - v = grpc_slice_to_c_string(GRPC_MDVALUE(md)); - } - gpr_log( - GPR_INFO, - "Decode: '%s: %s', elem_interned=%d [%d], k_interned=%d, v_interned=%d", - k, v, GRPC_MDELEM_IS_INTERNED(md), GRPC_MDELEM_STORAGE(md), - grpc_slice_is_interned(GRPC_MDKEY(md)), - grpc_slice_is_interned(GRPC_MDVALUE(md))); - gpr_free(k); - gpr_free(v); + on_hdr_log(md); } - if (add_to_table) { - GPR_ASSERT(GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_INTERNED || - GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_STATIC); + if (do_add) { + GPR_DEBUG_ASSERT(GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_INTERNED || + GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_STATIC); grpc_error* err = grpc_chttp2_hptbl_add(&p->table, md); - if (err != GRPC_ERROR_NONE) return err; + if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) return err; } - if (p->on_header == nullptr) { + if (GPR_UNLIKELY(p->on_header == nullptr)) { GRPC_MDELEM_UNREF(md); return GRPC_ERROR_CREATE_FROM_STATIC_STRING("on_header callback not set"); } @@ -765,7 +769,7 @@ static grpc_error* finish_indexed_field(grpc_chttp2_hpack_parser* p, } GRPC_MDELEM_REF(md); GRPC_STATS_INC_HPACK_RECV_INDEXED(); - grpc_error* err = on_hdr(p, md, 0); + grpc_error* err = on_hdr(p, md); if (err != GRPC_ERROR_NONE) return err; return parse_begin(p, cur, end); } @@ -798,11 +802,9 @@ static grpc_error* finish_lithdr_incidx(grpc_chttp2_hpack_parser* p, grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index); GPR_ASSERT(!GRPC_MDISNULL(md)); /* handled in string parsing */ GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX(); - grpc_error* err = - on_hdr(p, - grpc_mdelem_from_slices(grpc_slice_ref_internal(GRPC_MDKEY(md)), - take_string(p, &p->value, true)), - 1); + grpc_error* err = on_hdr( + p, grpc_mdelem_from_slices(grpc_slice_ref_internal(GRPC_MDKEY(md)), + take_string(p, &p->value, true))); if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err); return parse_begin(p, cur, end); } @@ -813,10 +815,8 @@ static grpc_error* finish_lithdr_incidx_v(grpc_chttp2_hpack_parser* p, const uint8_t* end) { GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX_V(); grpc_error* err = - on_hdr(p, - grpc_mdelem_from_slices(take_string(p, &p->key, true), - take_string(p, &p->value, true)), - 1); + on_hdr(p, grpc_mdelem_from_slices(take_string(p, &p->key, true), + take_string(p, &p->value, true))); if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err); return parse_begin(p, cur, end); } @@ -865,11 +865,9 @@ static grpc_error* finish_lithdr_notidx(grpc_chttp2_hpack_parser* p, grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index); GPR_ASSERT(!GRPC_MDISNULL(md)); /* handled in string parsing */ GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX(); - grpc_error* err = - on_hdr(p, - grpc_mdelem_from_slices(grpc_slice_ref_internal(GRPC_MDKEY(md)), - take_string(p, &p->value, false)), - 0); + grpc_error* err = on_hdr( + p, grpc_mdelem_from_slices(grpc_slice_ref_internal(GRPC_MDKEY(md)), + take_string(p, &p->value, false))); if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err); return parse_begin(p, cur, end); } @@ -879,11 +877,9 @@ static grpc_error* finish_lithdr_notidx_v(grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end) { GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX_V(); - grpc_error* err = - on_hdr(p, - grpc_mdelem_from_slices(take_string(p, &p->key, true), - take_string(p, &p->value, false)), - 0); + grpc_error* err = on_hdr( + p, grpc_mdelem_from_slices(take_string(p, &p->key, true), + take_string(p, &p->value, false))); if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err); return parse_begin(p, cur, end); } @@ -932,11 +928,9 @@ static grpc_error* finish_lithdr_nvridx(grpc_chttp2_hpack_parser* p, grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index); GPR_ASSERT(!GRPC_MDISNULL(md)); /* handled in string parsing */ GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX(); - grpc_error* err = - on_hdr(p, - grpc_mdelem_from_slices(grpc_slice_ref_internal(GRPC_MDKEY(md)), - take_string(p, &p->value, false)), - 0); + grpc_error* err = on_hdr( + p, grpc_mdelem_from_slices(grpc_slice_ref_internal(GRPC_MDKEY(md)), + take_string(p, &p->value, false))); if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err); return parse_begin(p, cur, end); } @@ -946,11 +940,9 @@ static grpc_error* finish_lithdr_nvridx_v(grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end) { GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX_V(); - grpc_error* err = - on_hdr(p, - grpc_mdelem_from_slices(take_string(p, &p->key, true), - take_string(p, &p->value, false)), - 0); + grpc_error* err = on_hdr( + p, grpc_mdelem_from_slices(take_string(p, &p->key, true), + take_string(p, &p->value, false))); if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err); return parse_begin(p, cur, end); } From dbf88dd66f0c45f2f3ce3d5209d9cd4ef180367d Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Thu, 27 Jun 2019 11:15:31 -0400 Subject: [PATCH 0740/1555] Revert "Revert "Introduce string_view and use it for gpr_split_host_port."" This reverts commit 80c177d4c40ef85eb8ec37f9d4bfa030361958e1. --- BUILD | 8 +- BUILD.gn | 8 +- CMakeLists.txt | 44 ++++- Makefile | 54 +++++- build.yaml | 20 ++- config.m4 | 2 +- config.w32 | 2 +- gRPC-C++.podspec | 6 +- gRPC-Core.podspec | 8 +- grpc.gemspec | 5 +- grpc.gyp | 2 +- package.xml | 5 +- .../ext/filters/client_channel/http_proxy.cc | 19 +- .../client_channel/lb_policy/grpclb/grpclb.cc | 1 - .../client_channel/lb_policy/xds/xds.cc | 1 - .../filters/client_channel/parse_address.cc | 55 +++--- .../resolver/dns/c_ares/dns_resolver_ares.cc | 1 - .../resolver/dns/c_ares/grpc_ares_wrapper.cc | 95 +++++----- .../dns/c_ares/grpc_ares_wrapper_libuv.cc | 1 - .../dns/c_ares/grpc_ares_wrapper_windows.cc | 1 - .../resolver/dns/native/dns_resolver.cc | 1 - .../resolver/fake/fake_resolver.cc | 1 - .../resolver/sockaddr/sockaddr_resolver.cc | 1 - .../transport/chttp2/server/chttp2_server.cc | 1 - .../transport/chttp2/transport/frame_data.cc | 8 +- .../cronet/transport/cronet_transport.cc | 1 - src/core/lib/channel/channelz.cc | 15 +- src/core/lib/gpr/host_port.cc | 98 ----------- src/core/lib/gpr/string.cc | 9 +- src/core/lib/gpr/string.h | 1 + src/core/lib/gprpp/host_port.cc | 97 +++++++++++ src/core/lib/{gpr => gprpp}/host_port.h | 38 ++-- src/core/lib/gprpp/string_view.h | 143 +++++++++++++++ .../lib/http/httpcli_security_connector.cc | 4 +- src/core/lib/iomgr/resolve_address_custom.cc | 35 ++-- src/core/lib/iomgr/resolve_address_posix.cc | 18 +- src/core/lib/iomgr/resolve_address_windows.cc | 14 +- src/core/lib/iomgr/sockaddr_utils.cc | 8 +- .../lib/iomgr/socket_utils_common_posix.cc | 1 - src/core/lib/iomgr/tcp_client_cfstream.cc | 13 +- .../alts/alts_security_connector.cc | 5 +- .../fake/fake_security_connector.cc | 46 +++-- .../local/local_security_connector.cc | 5 +- .../security_connector/security_connector.cc | 2 +- .../security_connector/security_connector.h | 2 +- .../ssl/ssl_security_connector.cc | 38 ++-- .../security/security_connector/ssl_utils.cc | 57 +++--- .../security/security_connector/ssl_utils.h | 19 +- .../tls/spiffe_security_connector.cc | 36 ++-- .../tls/spiffe_security_connector.h | 7 +- .../security/transport/client_auth_filter.cc | 3 +- .../alts/handshaker/alts_tsi_handshaker.cc | 1 - src/core/tsi/ssl_transport_security.cc | 78 ++++----- src/core/tsi/ssl_transport_security.h | 3 +- .../CronetTests/CoreCronetEnd2EndTests.mm | 21 ++- .../tests/CronetTests/CronetUnitTests.mm | 14 +- src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/bad_ssl/bad_ssl_test.cc | 8 +- .../parse_address_with_named_scope_id_test.cc | 17 +- test/core/end2end/bad_server_response_test.cc | 11 +- test/core/end2end/connection_refused_test.cc | 12 +- test/core/end2end/dualstack_socket_test.cc | 25 ++- test/core/end2end/fixtures/h2_census.cc | 22 ++- test/core/end2end/fixtures/h2_compress.cc | 33 ++-- test/core/end2end/fixtures/h2_fakesec.cc | 23 ++- test/core/end2end/fixtures/h2_full+pipe.cc | 21 ++- test/core/end2end/fixtures/h2_full+trace.cc | 21 ++- .../end2end/fixtures/h2_full+workarounds.cc | 24 ++- test/core/end2end/fixtures/h2_full.cc | 21 ++- test/core/end2end/fixtures/h2_http_proxy.cc | 27 ++- test/core/end2end/fixtures/h2_local_ipv4.cc | 4 +- test/core/end2end/fixtures/h2_local_ipv6.cc | 4 +- test/core/end2end/fixtures/h2_local_uds.cc | 8 +- test/core/end2end/fixtures/h2_oauth2.cc | 25 ++- test/core/end2end/fixtures/h2_proxy.cc | 1 - test/core/end2end/fixtures/h2_spiffe.cc | 25 +-- test/core/end2end/fixtures/h2_ssl.cc | 22 ++- .../end2end/fixtures/h2_ssl_cred_reload.cc | 24 ++- test/core/end2end/fixtures/h2_ssl_proxy.cc | 1 - test/core/end2end/fixtures/h2_uds.cc | 1 - .../end2end/fixtures/http_proxy_fixture.cc | 14 +- test/core/end2end/fixtures/inproc.cc | 1 - test/core/end2end/fixtures/local_util.cc | 15 +- test/core/end2end/fixtures/local_util.h | 6 +- test/core/end2end/fixtures/proxy.cc | 29 ++-- test/core/end2end/h2_ssl_cert_test.cc | 22 ++- .../core/end2end/h2_ssl_session_reuse_test.cc | 15 +- .../end2end/invalid_call_argument_test.cc | 15 +- test/core/fling/fling_stream_test.cc | 11 +- test/core/fling/fling_test.cc | 12 +- test/core/fling/server.cc | 12 +- test/core/gpr/BUILD | 10 -- test/core/gprpp/BUILD | 23 +++ test/core/{gpr => gprpp}/host_port_test.cc | 11 +- test/core/gprpp/string_view_test.cc | 163 ++++++++++++++++++ test/core/memory_usage/memory_usage_test.cc | 11 +- test/core/memory_usage/server.cc | 12 +- ...num_external_connectivity_watchers_test.cc | 21 +-- .../surface/sequential_connectivity_test.cc | 11 +- test/core/surface/server_chttp2_test.cc | 12 +- test/core/surface/server_test.cc | 14 +- test/core/util/reconnect_server.cc | 1 - test/core/util/test_tcp_server.cc | 1 - test/cpp/interop/interop_test.cc | 1 - test/cpp/naming/address_sorting_test.cc | 18 +- test/cpp/naming/cancel_ares_query_test.cc | 1 - test/cpp/naming/resolver_component_test.cc | 16 +- test/cpp/qps/client_sync.cc | 1 - test/cpp/qps/driver.cc | 22 +-- test/cpp/qps/qps_worker.cc | 9 +- test/cpp/qps/server_async.cc | 9 +- test/cpp/qps/server_callback.cc | 9 +- test/cpp/qps/server_sync.cc | 9 +- tools/doxygen/Doxyfile.c++.internal | 3 +- tools/doxygen/Doxyfile.core.internal | 5 +- .../generated/sources_and_headers.json | 28 ++- tools/run_tests/generated/tests.json | 24 +++ 117 files changed, 1280 insertions(+), 881 deletions(-) delete mode 100644 src/core/lib/gpr/host_port.cc create mode 100644 src/core/lib/gprpp/host_port.cc rename src/core/lib/{gpr => gprpp}/host_port.h (51%) create mode 100644 src/core/lib/gprpp/string_view.h rename test/core/{gpr => gprpp}/host_port_test.cc (86%) create mode 100644 test/core/gprpp/string_view_test.cc diff --git a/BUILD b/BUILD index 87d3b978358..f7c97beaaaf 100644 --- a/BUILD +++ b/BUILD @@ -559,7 +559,6 @@ grpc_cc_library( "src/core/lib/gpr/env_linux.cc", "src/core/lib/gpr/env_posix.cc", "src/core/lib/gpr/env_windows.cc", - "src/core/lib/gpr/host_port.cc", "src/core/lib/gpr/log.cc", "src/core/lib/gpr/log_android.cc", "src/core/lib/gpr/log_linux.cc", @@ -586,6 +585,7 @@ grpc_cc_library( "src/core/lib/gprpp/arena.cc", "src/core/lib/gprpp/fork.cc", "src/core/lib/gprpp/global_config_env.cc", + "src/core/lib/gprpp/host_port.cc", "src/core/lib/gprpp/thd_posix.cc", "src/core/lib/gprpp/thd_windows.cc", "src/core/lib/profiling/basic_timers.cc", @@ -595,7 +595,6 @@ grpc_cc_library( "src/core/lib/gpr/alloc.h", "src/core/lib/gpr/arena.h", "src/core/lib/gpr/env.h", - "src/core/lib/gpr/host_port.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", "src/core/lib/gpr/spinlock.h", @@ -612,14 +611,16 @@ grpc_cc_library( "src/core/lib/gprpp/arena.h", "src/core/lib/gprpp/atomic.h", "src/core/lib/gprpp/fork.h", + "src/core/lib/gprpp/global_config.h", "src/core/lib/gprpp/global_config_custom.h", "src/core/lib/gprpp/global_config_env.h", "src/core/lib/gprpp/global_config_generic.h", - "src/core/lib/gprpp/global_config.h", + "src/core/lib/gprpp/host_port.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", "src/core/lib/gprpp/pair.h", + "src/core/lib/gprpp/string_view.h", "src/core/lib/gprpp/sync.h", "src/core/lib/gprpp/thd.h", "src/core/lib/profiling/timers.h", @@ -628,6 +629,7 @@ grpc_cc_library( public_hdrs = GPR_PUBLIC_HDRS, deps = [ "gpr_codegen", + "grpc_codegen", ], ) diff --git a/BUILD.gn b/BUILD.gn index fc9fa8dc3d0..08625e9bd12 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -141,8 +141,6 @@ config("grpc_config") { "src/core/lib/gpr/env_linux.cc", "src/core/lib/gpr/env_posix.cc", "src/core/lib/gpr/env_windows.cc", - "src/core/lib/gpr/host_port.cc", - "src/core/lib/gpr/host_port.h", "src/core/lib/gpr/log.cc", "src/core/lib/gpr/log_android.cc", "src/core/lib/gpr/log_linux.cc", @@ -189,6 +187,8 @@ config("grpc_config") { "src/core/lib/gprpp/global_config_env.cc", "src/core/lib/gprpp/global_config_env.h", "src/core/lib/gprpp/global_config_generic.h", + "src/core/lib/gprpp/host_port.cc", + "src/core/lib/gprpp/host_port.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", @@ -480,6 +480,7 @@ config("grpc_config") { "src/core/lib/gprpp/orphanable.h", "src/core/lib/gprpp/ref_counted.h", "src/core/lib/gprpp/ref_counted_ptr.h", + "src/core/lib/gprpp/string_view.h", "src/core/lib/http/format_request.cc", "src/core/lib/http/format_request.h", "src/core/lib/http/httpcli.cc", @@ -1172,7 +1173,6 @@ config("grpc_config") { "src/core/lib/gpr/alloc.h", "src/core/lib/gpr/arena.h", "src/core/lib/gpr/env.h", - "src/core/lib/gpr/host_port.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", "src/core/lib/gpr/spinlock.h", @@ -1194,6 +1194,7 @@ config("grpc_config") { "src/core/lib/gprpp/global_config_custom.h", "src/core/lib/gprpp/global_config_env.h", "src/core/lib/gprpp/global_config_generic.h", + "src/core/lib/gprpp/host_port.h", "src/core/lib/gprpp/inlined_vector.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", @@ -1203,6 +1204,7 @@ config("grpc_config") { "src/core/lib/gprpp/pair.h", "src/core/lib/gprpp/ref_counted.h", "src/core/lib/gprpp/ref_counted_ptr.h", + "src/core/lib/gprpp/string_view.h", "src/core/lib/gprpp/sync.h", "src/core/lib/gprpp/thd.h", "src/core/lib/http/format_request.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index ce16506ab62..261a561918f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -713,6 +713,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx streaming_throughput_test) endif() add_dependencies(buildtests_cxx stress_test) +add_dependencies(buildtests_cxx string_view_test) add_dependencies(buildtests_cxx thread_manager_test) add_dependencies(buildtests_cxx thread_stress_test) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) @@ -861,7 +862,6 @@ add_library(gpr src/core/lib/gpr/env_linux.cc src/core/lib/gpr/env_posix.cc src/core/lib/gpr/env_windows.cc - src/core/lib/gpr/host_port.cc src/core/lib/gpr/log.cc src/core/lib/gpr/log_android.cc src/core/lib/gpr/log_linux.cc @@ -888,6 +888,7 @@ add_library(gpr src/core/lib/gprpp/arena.cc src/core/lib/gprpp/fork.cc src/core/lib/gprpp/global_config_env.cc + src/core/lib/gprpp/host_port.cc src/core/lib/gprpp/thd_posix.cc src/core/lib/gprpp/thd_windows.cc src/core/lib/profiling/basic_timers.cc @@ -7509,7 +7510,7 @@ endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(gpr_host_port_test - test/core/gpr/host_port_test.cc + test/core/gprpp/host_port_test.cc ) @@ -16642,6 +16643,45 @@ target_link_libraries(stress_test ) +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + +add_executable(string_view_test + test/core/gprpp/string_view_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(string_view_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(string_view_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + grpc++ + grpc + gpr + ${_gRPC_GFLAGS_LIBRARIES} +) + + endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index e2e8aa60488..d19adcabec9 100644 --- a/Makefile +++ b/Makefile @@ -1278,6 +1278,7 @@ status_metadata_test: $(BINDIR)/$(CONFIG)/status_metadata_test status_util_test: $(BINDIR)/$(CONFIG)/status_util_test streaming_throughput_test: $(BINDIR)/$(CONFIG)/streaming_throughput_test stress_test: $(BINDIR)/$(CONFIG)/stress_test +string_view_test: $(BINDIR)/$(CONFIG)/string_view_test thread_manager_test: $(BINDIR)/$(CONFIG)/thread_manager_test thread_stress_test: $(BINDIR)/$(CONFIG)/thread_stress_test time_change_test: $(BINDIR)/$(CONFIG)/time_change_test @@ -1744,6 +1745,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/status_util_test \ $(BINDIR)/$(CONFIG)/streaming_throughput_test \ $(BINDIR)/$(CONFIG)/stress_test \ + $(BINDIR)/$(CONFIG)/string_view_test \ $(BINDIR)/$(CONFIG)/thread_manager_test \ $(BINDIR)/$(CONFIG)/thread_stress_test \ $(BINDIR)/$(CONFIG)/time_change_test \ @@ -1907,6 +1909,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/status_util_test \ $(BINDIR)/$(CONFIG)/streaming_throughput_test \ $(BINDIR)/$(CONFIG)/stress_test \ + $(BINDIR)/$(CONFIG)/string_view_test \ $(BINDIR)/$(CONFIG)/thread_manager_test \ $(BINDIR)/$(CONFIG)/thread_stress_test \ $(BINDIR)/$(CONFIG)/time_change_test \ @@ -2433,6 +2436,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/status_util_test || ( echo test status_util_test failed ; exit 1 ) $(E) "[RUN] Testing streaming_throughput_test" $(Q) $(BINDIR)/$(CONFIG)/streaming_throughput_test || ( echo test streaming_throughput_test failed ; exit 1 ) + $(E) "[RUN] Testing string_view_test" + $(Q) $(BINDIR)/$(CONFIG)/string_view_test || ( echo test string_view_test failed ; exit 1 ) $(E) "[RUN] Testing thread_manager_test" $(Q) $(BINDIR)/$(CONFIG)/thread_manager_test || ( echo test thread_manager_test failed ; exit 1 ) $(E) "[RUN] Testing thread_stress_test" @@ -3379,7 +3384,6 @@ LIBGPR_SRC = \ src/core/lib/gpr/env_linux.cc \ src/core/lib/gpr/env_posix.cc \ src/core/lib/gpr/env_windows.cc \ - src/core/lib/gpr/host_port.cc \ src/core/lib/gpr/log.cc \ src/core/lib/gpr/log_android.cc \ src/core/lib/gpr/log_linux.cc \ @@ -3406,6 +3410,7 @@ LIBGPR_SRC = \ src/core/lib/gprpp/arena.cc \ src/core/lib/gprpp/fork.cc \ src/core/lib/gprpp/global_config_env.cc \ + src/core/lib/gprpp/host_port.cc \ src/core/lib/gprpp/thd_posix.cc \ src/core/lib/gprpp/thd_windows.cc \ src/core/lib/profiling/basic_timers.cc \ @@ -10221,7 +10226,7 @@ endif GPR_HOST_PORT_TEST_SRC = \ - test/core/gpr/host_port_test.cc \ + test/core/gprpp/host_port_test.cc \ GPR_HOST_PORT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_HOST_PORT_TEST_SRC)))) ifeq ($(NO_SECURE),true) @@ -10241,7 +10246,7 @@ $(BINDIR)/$(CONFIG)/gpr_host_port_test: $(GPR_HOST_PORT_TEST_OBJS) $(LIBDIR)/$(C endif -$(OBJDIR)/$(CONFIG)/test/core/gpr/host_port_test.o: $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a +$(OBJDIR)/$(CONFIG)/test/core/gprpp/host_port_test.o: $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a deps_gpr_host_port_test: $(GPR_HOST_PORT_TEST_OBJS:.o=.dep) @@ -19669,6 +19674,49 @@ $(OBJDIR)/$(CONFIG)/test/cpp/interop/stress_test.o: $(GENDIR)/src/proto/grpc/tes $(OBJDIR)/$(CONFIG)/test/cpp/util/metrics_server.o: $(GENDIR)/src/proto/grpc/testing/empty.pb.cc $(GENDIR)/src/proto/grpc/testing/empty.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/metrics.pb.cc $(GENDIR)/src/proto/grpc/testing/metrics.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/test.pb.cc $(GENDIR)/src/proto/grpc/testing/test.grpc.pb.cc +STRING_VIEW_TEST_SRC = \ + test/core/gprpp/string_view_test.cc \ + +STRING_VIEW_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(STRING_VIEW_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/string_view_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/string_view_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/string_view_test: $(PROTOBUF_DEP) $(STRING_VIEW_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(STRING_VIEW_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/string_view_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/core/gprpp/string_view_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_string_view_test: $(STRING_VIEW_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(STRING_VIEW_TEST_OBJS:.o=.dep) +endif +endif + + THREAD_MANAGER_TEST_SRC = \ test/cpp/thread_manager/thread_manager_test.cc \ diff --git a/build.yaml b/build.yaml index 5b9a8c1594e..ff27f1fb31f 100644 --- a/build.yaml +++ b/build.yaml @@ -122,7 +122,6 @@ filegroups: - src/core/lib/gpr/env_linux.cc - src/core/lib/gpr/env_posix.cc - src/core/lib/gpr/env_windows.cc - - src/core/lib/gpr/host_port.cc - src/core/lib/gpr/log.cc - src/core/lib/gpr/log_android.cc - src/core/lib/gpr/log_linux.cc @@ -149,6 +148,7 @@ filegroups: - src/core/lib/gprpp/arena.cc - src/core/lib/gprpp/fork.cc - src/core/lib/gprpp/global_config_env.cc + - src/core/lib/gprpp/host_port.cc - src/core/lib/gprpp/thd_posix.cc - src/core/lib/gprpp/thd_windows.cc - src/core/lib/profiling/basic_timers.cc @@ -178,7 +178,6 @@ filegroups: - src/core/lib/gpr/alloc.h - src/core/lib/gpr/arena.h - src/core/lib/gpr/env.h - - src/core/lib/gpr/host_port.h - src/core/lib/gpr/mpscq.h - src/core/lib/gpr/murmur_hash.h - src/core/lib/gpr/spinlock.h @@ -199,6 +198,7 @@ filegroups: - src/core/lib/gprpp/global_config_custom.h - src/core/lib/gprpp/global_config_env.h - src/core/lib/gprpp/global_config_generic.h + - src/core/lib/gprpp/host_port.h - src/core/lib/gprpp/manual_constructor.h - src/core/lib/gprpp/map.h - src/core/lib/gprpp/memory.h @@ -444,6 +444,7 @@ filegroups: - src/core/lib/gprpp/orphanable.h - src/core/lib/gprpp/ref_counted.h - src/core/lib/gprpp/ref_counted_ptr.h + - src/core/lib/gprpp/string_view.h - src/core/lib/http/format_request.h - src/core/lib/http/httpcli.h - src/core/lib/http/parser.h @@ -2626,7 +2627,7 @@ targets: build: test language: c src: - - test/core/gpr/host_port_test.cc + - test/core/gprpp/host_port_test.cc deps: - gpr - grpc_test_util_unsecure @@ -5761,6 +5762,19 @@ targets: - grpc - gpr - grpc++_test_config +- name: string_view_test + gtest: true + build: test + language: c++ + src: + - test/core/gprpp/string_view_test.cc + deps: + - grpc_test_util + - grpc++ + - grpc + - gpr + uses: + - grpc++_test - name: thread_manager_test build: test language: c++ diff --git a/config.m4 b/config.m4 index bb30be56910..99d49d391b4 100644 --- a/config.m4 +++ b/config.m4 @@ -53,7 +53,6 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/gpr/env_linux.cc \ src/core/lib/gpr/env_posix.cc \ src/core/lib/gpr/env_windows.cc \ - src/core/lib/gpr/host_port.cc \ src/core/lib/gpr/log.cc \ src/core/lib/gpr/log_android.cc \ src/core/lib/gpr/log_linux.cc \ @@ -80,6 +79,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/gprpp/arena.cc \ src/core/lib/gprpp/fork.cc \ src/core/lib/gprpp/global_config_env.cc \ + src/core/lib/gprpp/host_port.cc \ src/core/lib/gprpp/thd_posix.cc \ src/core/lib/gprpp/thd_windows.cc \ src/core/lib/profiling/basic_timers.cc \ diff --git a/config.w32 b/config.w32 index c9faa8d9ac8..f6c6b4fde10 100644 --- a/config.w32 +++ b/config.w32 @@ -28,7 +28,6 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\gpr\\env_linux.cc " + "src\\core\\lib\\gpr\\env_posix.cc " + "src\\core\\lib\\gpr\\env_windows.cc " + - "src\\core\\lib\\gpr\\host_port.cc " + "src\\core\\lib\\gpr\\log.cc " + "src\\core\\lib\\gpr\\log_android.cc " + "src\\core\\lib\\gpr\\log_linux.cc " + @@ -55,6 +54,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\gprpp\\arena.cc " + "src\\core\\lib\\gprpp\\fork.cc " + "src\\core\\lib\\gprpp\\global_config_env.cc " + + "src\\core\\lib\\gprpp\\host_port.cc " + "src\\core\\lib\\gprpp\\thd_posix.cc " + "src\\core\\lib\\gprpp\\thd_windows.cc " + "src\\core\\lib\\profiling\\basic_timers.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 6fc97c6135e..a09173dc8f0 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -262,7 +262,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/alloc.h', 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', - 'src/core/lib/gpr/host_port.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', 'src/core/lib/gpr/spinlock.h', @@ -283,6 +282,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/global_config_custom.h', 'src/core/lib/gprpp/global_config_env.h', 'src/core/lib/gprpp/global_config_generic.h', + 'src/core/lib/gprpp/host_port.h', 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', @@ -445,6 +445,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/orphanable.h', 'src/core/lib/gprpp/ref_counted.h', 'src/core/lib/gprpp/ref_counted_ptr.h', + 'src/core/lib/gprpp/string_view.h', 'src/core/lib/http/format_request.h', 'src/core/lib/http/httpcli.h', 'src/core/lib/http/parser.h', @@ -592,7 +593,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/alloc.h', 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', - 'src/core/lib/gpr/host_port.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', 'src/core/lib/gpr/spinlock.h', @@ -613,6 +613,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/global_config_custom.h', 'src/core/lib/gprpp/global_config_env.h', 'src/core/lib/gprpp/global_config_generic.h', + 'src/core/lib/gprpp/host_port.h', 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', @@ -649,6 +650,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/orphanable.h', 'src/core/lib/gprpp/ref_counted.h', 'src/core/lib/gprpp/ref_counted_ptr.h', + 'src/core/lib/gprpp/string_view.h', 'src/core/lib/http/format_request.h', 'src/core/lib/http/httpcli.h', 'src/core/lib/http/parser.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 2e34e8d7573..6255fdfd0ce 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -191,7 +191,6 @@ Pod::Spec.new do |s| ss.source_files = 'src/core/lib/gpr/alloc.h', 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', - 'src/core/lib/gpr/host_port.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', 'src/core/lib/gpr/spinlock.h', @@ -212,6 +211,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/global_config_custom.h', 'src/core/lib/gprpp/global_config_env.h', 'src/core/lib/gprpp/global_config_generic.h', + 'src/core/lib/gprpp/host_port.h', 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', @@ -228,7 +228,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/env_linux.cc', 'src/core/lib/gpr/env_posix.cc', 'src/core/lib/gpr/env_windows.cc', - 'src/core/lib/gpr/host_port.cc', 'src/core/lib/gpr/log.cc', 'src/core/lib/gpr/log_android.cc', 'src/core/lib/gpr/log_linux.cc', @@ -255,6 +254,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/arena.cc', 'src/core/lib/gprpp/fork.cc', 'src/core/lib/gprpp/global_config_env.cc', + 'src/core/lib/gprpp/host_port.cc', 'src/core/lib/gprpp/thd_posix.cc', 'src/core/lib/gprpp/thd_windows.cc', 'src/core/lib/profiling/basic_timers.cc', @@ -414,6 +414,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/orphanable.h', 'src/core/lib/gprpp/ref_counted.h', 'src/core/lib/gprpp/ref_counted_ptr.h', + 'src/core/lib/gprpp/string_view.h', 'src/core/lib/http/format_request.h', 'src/core/lib/http/httpcli.h', 'src/core/lib/http/parser.h', @@ -884,7 +885,6 @@ Pod::Spec.new do |s| ss.private_header_files = 'src/core/lib/gpr/alloc.h', 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', - 'src/core/lib/gpr/host_port.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', 'src/core/lib/gpr/spinlock.h', @@ -905,6 +905,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/global_config_custom.h', 'src/core/lib/gprpp/global_config_env.h', 'src/core/lib/gprpp/global_config_generic.h', + 'src/core/lib/gprpp/host_port.h', 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', @@ -1067,6 +1068,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/orphanable.h', 'src/core/lib/gprpp/ref_counted.h', 'src/core/lib/gprpp/ref_counted_ptr.h', + 'src/core/lib/gprpp/string_view.h', 'src/core/lib/http/format_request.h', 'src/core/lib/http/httpcli.h', 'src/core/lib/http/parser.h', diff --git a/grpc.gemspec b/grpc.gemspec index 11469a3ec5c..a1051fd4685 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -85,7 +85,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/alloc.h ) s.files += %w( src/core/lib/gpr/arena.h ) s.files += %w( src/core/lib/gpr/env.h ) - s.files += %w( src/core/lib/gpr/host_port.h ) s.files += %w( src/core/lib/gpr/mpscq.h ) s.files += %w( src/core/lib/gpr/murmur_hash.h ) s.files += %w( src/core/lib/gpr/spinlock.h ) @@ -106,6 +105,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gprpp/global_config_custom.h ) s.files += %w( src/core/lib/gprpp/global_config_env.h ) s.files += %w( src/core/lib/gprpp/global_config_generic.h ) + s.files += %w( src/core/lib/gprpp/host_port.h ) s.files += %w( src/core/lib/gprpp/manual_constructor.h ) s.files += %w( src/core/lib/gprpp/map.h ) s.files += %w( src/core/lib/gprpp/memory.h ) @@ -122,7 +122,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/env_linux.cc ) s.files += %w( src/core/lib/gpr/env_posix.cc ) s.files += %w( src/core/lib/gpr/env_windows.cc ) - s.files += %w( src/core/lib/gpr/host_port.cc ) s.files += %w( src/core/lib/gpr/log.cc ) s.files += %w( src/core/lib/gpr/log_android.cc ) s.files += %w( src/core/lib/gpr/log_linux.cc ) @@ -149,6 +148,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gprpp/arena.cc ) s.files += %w( src/core/lib/gprpp/fork.cc ) s.files += %w( src/core/lib/gprpp/global_config_env.cc ) + s.files += %w( src/core/lib/gprpp/host_port.cc ) s.files += %w( src/core/lib/gprpp/thd_posix.cc ) s.files += %w( src/core/lib/gprpp/thd_windows.cc ) s.files += %w( src/core/lib/profiling/basic_timers.cc ) @@ -348,6 +348,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gprpp/orphanable.h ) s.files += %w( src/core/lib/gprpp/ref_counted.h ) s.files += %w( src/core/lib/gprpp/ref_counted_ptr.h ) + s.files += %w( src/core/lib/gprpp/string_view.h ) s.files += %w( src/core/lib/http/format_request.h ) s.files += %w( src/core/lib/http/httpcli.h ) s.files += %w( src/core/lib/http/parser.h ) diff --git a/grpc.gyp b/grpc.gyp index 6268bed7bb0..784279301d3 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -226,7 +226,6 @@ 'src/core/lib/gpr/env_linux.cc', 'src/core/lib/gpr/env_posix.cc', 'src/core/lib/gpr/env_windows.cc', - 'src/core/lib/gpr/host_port.cc', 'src/core/lib/gpr/log.cc', 'src/core/lib/gpr/log_android.cc', 'src/core/lib/gpr/log_linux.cc', @@ -253,6 +252,7 @@ 'src/core/lib/gprpp/arena.cc', 'src/core/lib/gprpp/fork.cc', 'src/core/lib/gprpp/global_config_env.cc', + 'src/core/lib/gprpp/host_port.cc', 'src/core/lib/gprpp/thd_posix.cc', 'src/core/lib/gprpp/thd_windows.cc', 'src/core/lib/profiling/basic_timers.cc', diff --git a/package.xml b/package.xml index 616e1ece20e..388e8d8620a 100644 --- a/package.xml +++ b/package.xml @@ -90,7 +90,6 @@ - @@ -111,6 +110,7 @@ + @@ -127,7 +127,6 @@ - @@ -154,6 +153,7 @@ + @@ -353,6 +353,7 @@ + diff --git a/src/core/ext/filters/client_channel/http_proxy.cc b/src/core/ext/filters/client_channel/http_proxy.cc index 8951a2920c4..9e60a553ceb 100644 --- a/src/core/ext/filters/client_channel/http_proxy.cc +++ b/src/core/ext/filters/client_channel/http_proxy.cc @@ -31,8 +31,8 @@ #include "src/core/ext/filters/client_channel/proxy_mapper_registry.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/env.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/slice/b64.h" #include "src/core/lib/uri/uri_parser.h" @@ -126,17 +126,18 @@ static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper, if (no_proxy_str != nullptr) { static const char* NO_PROXY_SEPARATOR = ","; bool use_proxy = true; - char* server_host; - char* server_port; - if (!gpr_split_host_port(uri->path[0] == '/' ? uri->path + 1 : uri->path, - &server_host, &server_port)) { + grpc_core::UniquePtr server_host; + grpc_core::UniquePtr server_port; + if (!grpc_core::SplitHostPort( + uri->path[0] == '/' ? uri->path + 1 : uri->path, &server_host, + &server_port)) { gpr_log(GPR_INFO, "unable to split host and port, not checking no_proxy list for " "host '%s'", server_uri); gpr_free(no_proxy_str); } else { - size_t uri_len = strlen(server_host); + size_t uri_len = strlen(server_host.get()); char** no_proxy_hosts; size_t num_no_proxy_hosts; gpr_string_split(no_proxy_str, NO_PROXY_SEPARATOR, &no_proxy_hosts, @@ -145,8 +146,8 @@ static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper, char* no_proxy_entry = no_proxy_hosts[i]; size_t no_proxy_len = strlen(no_proxy_entry); if (no_proxy_len <= uri_len && - gpr_stricmp(no_proxy_entry, &server_host[uri_len - no_proxy_len]) == - 0) { + gpr_stricmp(no_proxy_entry, + &(server_host.get()[uri_len - no_proxy_len])) == 0) { gpr_log(GPR_INFO, "not using proxy for host in no_proxy list '%s'", server_uri); use_proxy = false; @@ -157,8 +158,6 @@ static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper, gpr_free(no_proxy_hosts[i]); } gpr_free(no_proxy_hosts); - gpr_free(server_host); - gpr_free(server_port); gpr_free(no_proxy_str); if (!use_proxy) goto no_use_proxy; } diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 2f3516066da..71e8e248770 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -84,7 +84,6 @@ #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/gprpp/memory.h" diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index e5c27fe67a4..ca9ea9e31cc 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -84,7 +84,6 @@ #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/gprpp/map.h" diff --git a/src/core/ext/filters/client_channel/parse_address.cc b/src/core/ext/filters/client_channel/parse_address.cc index c5e1ed811bc..fbfbb4445f3 100644 --- a/src/core/ext/filters/client_channel/parse_address.cc +++ b/src/core/ext/filters/client_channel/parse_address.cc @@ -33,8 +33,8 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #ifdef GRPC_POSIX_SOCKET #include @@ -73,9 +73,9 @@ bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr, bool log_errors) { bool success = false; // Split host and port. - char* host; - char* port; - if (!gpr_split_host_port(hostport, &host, &port)) { + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; + if (!grpc_core::SplitHostPort(hostport, &host, &port)) { if (log_errors) { gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)", hostport); } @@ -86,8 +86,10 @@ bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr, addr->len = static_cast(sizeof(grpc_sockaddr_in)); grpc_sockaddr_in* in = reinterpret_cast(addr->addr); in->sin_family = GRPC_AF_INET; - if (grpc_inet_pton(GRPC_AF_INET, host, &in->sin_addr) == 0) { - if (log_errors) gpr_log(GPR_ERROR, "invalid ipv4 address: '%s'", host); + if (grpc_inet_pton(GRPC_AF_INET, host.get(), &in->sin_addr) == 0) { + if (log_errors) { + gpr_log(GPR_ERROR, "invalid ipv4 address: '%s'", host.get()); + } goto done; } // Parse port. @@ -96,15 +98,14 @@ bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr, goto done; } int port_num; - if (sscanf(port, "%d", &port_num) != 1 || port_num < 0 || port_num > 65535) { - if (log_errors) gpr_log(GPR_ERROR, "invalid ipv4 port: '%s'", port); + if (sscanf(port.get(), "%d", &port_num) != 1 || port_num < 0 || + port_num > 65535) { + if (log_errors) gpr_log(GPR_ERROR, "invalid ipv4 port: '%s'", port.get()); goto done; } in->sin_port = grpc_htons(static_cast(port_num)); success = true; done: - gpr_free(host); - gpr_free(port); return success; } @@ -124,9 +125,9 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, bool log_errors) { bool success = false; // Split host and port. - char* host; - char* port; - if (!gpr_split_host_port(hostport, &host, &port)) { + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; + if (!grpc_core::SplitHostPort(hostport, &host, &port)) { if (log_errors) { gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)", hostport); } @@ -138,11 +139,12 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, grpc_sockaddr_in6* in6 = reinterpret_cast(addr->addr); in6->sin6_family = GRPC_AF_INET6; // Handle the RFC6874 syntax for IPv6 zone identifiers. - char* host_end = static_cast(gpr_memrchr(host, '%', strlen(host))); + char* host_end = + static_cast(gpr_memrchr(host.get(), '%', strlen(host.get()))); if (host_end != nullptr) { - GPR_ASSERT(host_end >= host); + GPR_ASSERT(host_end >= host.get()); char host_without_scope[GRPC_INET6_ADDRSTRLEN + 1]; - size_t host_without_scope_len = static_cast(host_end - host); + size_t host_without_scope_len = static_cast(host_end - host.get()); uint32_t sin6_scope_id = 0; if (host_without_scope_len > GRPC_INET6_ADDRSTRLEN) { if (log_errors) { @@ -154,7 +156,7 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, } goto done; } - strncpy(host_without_scope, host, host_without_scope_len); + strncpy(host_without_scope, host.get(), host_without_scope_len); host_without_scope[host_without_scope_len] = '\0'; if (grpc_inet_pton(GRPC_AF_INET6, host_without_scope, &in6->sin6_addr) == 0) { @@ -163,9 +165,9 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, } goto done; } - if (gpr_parse_bytes_to_uint32(host_end + 1, - strlen(host) - host_without_scope_len - 1, - &sin6_scope_id) == 0) { + if (gpr_parse_bytes_to_uint32( + host_end + 1, strlen(host.get()) - host_without_scope_len - 1, + &sin6_scope_id) == 0) { if ((sin6_scope_id = grpc_if_nametoindex(host_end + 1)) == 0) { gpr_log(GPR_ERROR, "Invalid interface name: '%s'. " @@ -177,8 +179,10 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, // Handle "sin6_scope_id" being type "u_long". See grpc issue #10027. in6->sin6_scope_id = sin6_scope_id; } else { - if (grpc_inet_pton(GRPC_AF_INET6, host, &in6->sin6_addr) == 0) { - if (log_errors) gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host); + if (grpc_inet_pton(GRPC_AF_INET6, host.get(), &in6->sin6_addr) == 0) { + if (log_errors) { + gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host.get()); + } goto done; } } @@ -188,15 +192,14 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, goto done; } int port_num; - if (sscanf(port, "%d", &port_num) != 1 || port_num < 0 || port_num > 65535) { - if (log_errors) gpr_log(GPR_ERROR, "invalid ipv6 port: '%s'", port); + if (sscanf(port.get(), "%d", &port_num) != 1 || port_num < 0 || + port_num > 65535) { + if (log_errors) gpr_log(GPR_ERROR, "invalid ipv6 port: '%s'", port.get()); goto done; } in6->sin6_port = grpc_htons(static_cast(port_num)); success = true; done: - gpr_free(host); - gpr_free(port); return success; } diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index 32a339af359..ff15704d692 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -38,7 +38,6 @@ #include "src/core/ext/filters/client_channel/service_config.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/combiner.h" diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc index ad0f1460121..0c1a8ba828f 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc @@ -35,8 +35,8 @@ #include #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/executor.h" @@ -355,9 +355,9 @@ void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked( grpc_ares_hostbyname_request* hr = nullptr; ares_channel* channel = nullptr; /* parse name, splitting it into host and port parts */ - char* host; - char* port; - gpr_split_host_port(name, &host, &port); + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; + grpc_core::SplitHostPort(name, &host, &port); if (host == nullptr) { error = grpc_error_set_str( GRPC_ERROR_CREATE_FROM_STATIC_STRING("unparseable host:port"), @@ -370,7 +370,7 @@ void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked( GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(name)); goto error_cleanup; } - port = gpr_strdup(default_port); + port.reset(gpr_strdup(default_port)); } error = grpc_ares_ev_driver_create_locked(&r->ev_driver, interested_parties, query_timeout_ms, combiner, r); @@ -414,20 +414,22 @@ void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked( } r->pending_queries = 1; if (grpc_ares_query_ipv6()) { - hr = create_hostbyname_request_locked(r, host, grpc_strhtons(port), - false /* is_balancer */); + hr = create_hostbyname_request_locked(r, host.get(), + grpc_strhtons(port.get()), + /*is_balancer=*/false); ares_gethostbyname(*channel, hr->host, AF_INET6, on_hostbyname_done_locked, hr); } - hr = create_hostbyname_request_locked(r, host, grpc_strhtons(port), - false /* is_balancer */); + hr = + create_hostbyname_request_locked(r, host.get(), grpc_strhtons(port.get()), + /*is_balancer=*/false); ares_gethostbyname(*channel, hr->host, AF_INET, on_hostbyname_done_locked, hr); if (check_grpclb) { /* Query the SRV record */ grpc_ares_request_ref_locked(r); char* service_name; - gpr_asprintf(&service_name, "_grpclb._tcp.%s", host); + gpr_asprintf(&service_name, "_grpclb._tcp.%s", host.get()); ares_query(*channel, service_name, ns_c_in, ns_t_srv, on_srv_query_done_locked, r); gpr_free(service_name); @@ -435,28 +437,25 @@ void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked( if (r->service_config_json_out != nullptr) { grpc_ares_request_ref_locked(r); char* config_name; - gpr_asprintf(&config_name, "_grpc_config.%s", host); + gpr_asprintf(&config_name, "_grpc_config.%s", host.get()); ares_search(*channel, config_name, ns_c_in, ns_t_txt, on_txt_done_locked, r); gpr_free(config_name); } grpc_ares_ev_driver_start_locked(r->ev_driver); grpc_ares_request_unref_locked(r); - gpr_free(host); - gpr_free(port); return; error_cleanup: GRPC_CLOSURE_SCHED(r->on_done, error); - gpr_free(host); - gpr_free(port); } static bool inner_resolve_as_ip_literal_locked( const char* name, const char* default_port, - grpc_core::UniquePtr* addrs, char** host, - char** port, char** hostport) { - gpr_split_host_port(name, host, port); + grpc_core::UniquePtr* addrs, + grpc_core::UniquePtr* host, grpc_core::UniquePtr* port, + grpc_core::UniquePtr* hostport) { + grpc_core::SplitHostPort(name, host, port); if (*host == nullptr) { gpr_log(GPR_ERROR, "Failed to parse %s to host:port while attempting to resolve as ip " @@ -472,12 +471,14 @@ static bool inner_resolve_as_ip_literal_locked( name); return false; } - *port = gpr_strdup(default_port); + port->reset(gpr_strdup(default_port)); } grpc_resolved_address addr; - GPR_ASSERT(gpr_join_host_port(hostport, *host, atoi(*port))); - if (grpc_parse_ipv4_hostport(*hostport, &addr, false /* log errors */) || - grpc_parse_ipv6_hostport(*hostport, &addr, false /* log errors */)) { + GPR_ASSERT(grpc_core::JoinHostPort(hostport, host->get(), atoi(port->get()))); + if (grpc_parse_ipv4_hostport(hostport->get(), &addr, + false /* log errors */) || + grpc_parse_ipv6_hostport(hostport->get(), &addr, + false /* log errors */)) { GPR_ASSERT(*addrs == nullptr); *addrs = grpc_core::MakeUnique(); (*addrs)->emplace_back(addr.addr, addr.len, nullptr /* args */); @@ -489,24 +490,22 @@ static bool inner_resolve_as_ip_literal_locked( static bool resolve_as_ip_literal_locked( const char* name, const char* default_port, grpc_core::UniquePtr* addrs) { - char* host = nullptr; - char* port = nullptr; - char* hostport = nullptr; + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; + grpc_core::UniquePtr hostport; bool out = inner_resolve_as_ip_literal_locked(name, default_port, addrs, &host, &port, &hostport); - gpr_free(host); - gpr_free(port); - gpr_free(hostport); return out; } -static bool target_matches_localhost_inner(const char* name, char** host, - char** port) { - if (!gpr_split_host_port(name, host, port)) { +static bool target_matches_localhost_inner(const char* name, + grpc_core::UniquePtr* host, + grpc_core::UniquePtr* port) { + if (!grpc_core::SplitHostPort(name, host, port)) { gpr_log(GPR_ERROR, "Unable to split host and port for name: %s", name); return false; } - if (gpr_stricmp(*host, "localhost") == 0) { + if (gpr_stricmp(host->get(), "localhost") == 0) { return true; } else { return false; @@ -514,20 +513,17 @@ static bool target_matches_localhost_inner(const char* name, char** host, } static bool target_matches_localhost(const char* name) { - char* host = nullptr; - char* port = nullptr; - bool out = target_matches_localhost_inner(name, &host, &port); - gpr_free(host); - gpr_free(port); - return out; + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; + return target_matches_localhost_inner(name, &host, &port); } #ifdef GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY static bool inner_maybe_resolve_localhost_manually_locked( const char* name, const char* default_port, - grpc_core::UniquePtr* addrs, char** host, - char** port) { - gpr_split_host_port(name, host, port); + grpc_core::UniquePtr* addrs, + grpc_core::UniquePtr* host, grpc_core::UniquePtr* port) { + grpc_core::SplitHostPort(name, host, port); if (*host == nullptr) { gpr_log(GPR_ERROR, "Failed to parse %s into host:port during manual localhost " @@ -543,12 +539,12 @@ static bool inner_maybe_resolve_localhost_manually_locked( name); return false; } - *port = gpr_strdup(default_port); + port->reset(gpr_strdup(default_port)); } - if (gpr_stricmp(*host, "localhost") == 0) { + if (gpr_stricmp(host->get(), "localhost") == 0) { GPR_ASSERT(*addrs == nullptr); *addrs = grpc_core::MakeUnique(); - uint16_t numeric_port = grpc_strhtons(*port); + uint16_t numeric_port = grpc_strhtons(port->get()); // Append the ipv6 loopback address. struct sockaddr_in6 ipv6_loopback_addr; memset(&ipv6_loopback_addr, 0, sizeof(ipv6_loopback_addr)); @@ -576,13 +572,10 @@ static bool inner_maybe_resolve_localhost_manually_locked( static bool grpc_ares_maybe_resolve_localhost_manually_locked( const char* name, const char* default_port, grpc_core::UniquePtr* addrs) { - char* host = nullptr; - char* port = nullptr; - bool out = inner_maybe_resolve_localhost_manually_locked(name, default_port, - addrs, &host, &port); - gpr_free(host); - gpr_free(port); - return out; + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; + return inner_maybe_resolve_localhost_manually_locked(name, default_port, + addrs, &host, &port); } #else /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ static bool grpc_ares_maybe_resolve_localhost_manually_locked( diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc index f85feb674dd..d9e3293deb6 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc @@ -26,7 +26,6 @@ #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/ext/filters/client_channel/server_address.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" bool grpc_ares_query_ipv6() { diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc index 06cd5722ce3..1749cf77201 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc @@ -26,7 +26,6 @@ #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/ext/filters/client_channel/server_address.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/socket_windows.h" diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc index 5ab75d02793..b8434a1cae4 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc @@ -31,7 +31,6 @@ #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/combiner.h" diff --git a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc index 7f613ee21bc..ff728a3dc43 100644 --- a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc @@ -32,7 +32,6 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/closure.h" diff --git a/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc b/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc index 1465b0c644e..517b9297af4 100644 --- a/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc @@ -30,7 +30,6 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/resolve_address.h" diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc index 8285ee76445..dc60ec2487b 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -37,7 +37,6 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker.h" #include "src/core/lib/channel/handshaker_registry.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/resource_quota.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_data.cc b/src/core/ext/transport/chttp2/transport/frame_data.cc index 74c305b820f..c50d7e48d41 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.cc +++ b/src/core/ext/transport/chttp2/transport/frame_data.cc @@ -137,10 +137,10 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( p->error = grpc_error_set_int(p->error, GRPC_ERROR_INT_STREAM_ID, static_cast(s->id)); gpr_free(msg); - p->error = - grpc_error_set_str(p->error, GRPC_ERROR_STR_RAW_BYTES, - grpc_dump_slice_to_slice( - *slice, GPR_DUMP_HEX | GPR_DUMP_ASCII)); + p->error = grpc_error_set_str( + p->error, GRPC_ERROR_STR_RAW_BYTES, + grpc_slice_from_moved_string(grpc_core::UniquePtr( + grpc_dump_slice(*slice, GPR_DUMP_HEX | GPR_DUMP_ASCII)))); p->error = grpc_error_set_int(p->error, GRPC_ERROR_INT_OFFSET, cur - beg); p->state = GRPC_CHTTP2_DATA_ERROR; diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc index 3ddda268cfb..a5f6571c510 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.cc +++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc @@ -30,7 +30,6 @@ #include "src/core/ext/transport/chttp2/transport/incoming_metadata.h" #include "src/core/ext/transport/cronet/transport/cronet_transport.h" #include "src/core/lib/debug/trace.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/endpoint.h" diff --git a/src/core/lib/channel/channelz.cc b/src/core/lib/channel/channelz.cc index 4b130372e46..184ba17889d 100644 --- a/src/core/lib/channel/channelz.cc +++ b/src/core/lib/channel/channelz.cc @@ -30,9 +30,9 @@ #include "src/core/lib/channel/channelz_registry.h" #include "src/core/lib/channel/status_util.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -406,14 +406,15 @@ void PopulateSocketAddressJson(grpc_json* json, const char* name, (strcmp(uri->scheme, "ipv6") == 0))) { const char* host_port = uri->path; if (*host_port == '/') ++host_port; - char* host = nullptr; - char* port = nullptr; - GPR_ASSERT(gpr_split_host_port(host_port, &host, &port)); + UniquePtr host; + UniquePtr port; + GPR_ASSERT(SplitHostPort(host_port, &host, &port)); int port_num = -1; if (port != nullptr) { - port_num = atoi(port); + port_num = atoi(port.get()); } - char* b64_host = grpc_base64_encode(host, strlen(host), false, false); + char* b64_host = + grpc_base64_encode(host.get(), strlen(host.get()), false, false); json_iterator = grpc_json_create_child(json_iterator, json, "tcpip_address", nullptr, GRPC_JSON_OBJECT, false); json = json_iterator; @@ -422,8 +423,6 @@ void PopulateSocketAddressJson(grpc_json* json, const char* name, "port", port_num); json_iterator = grpc_json_create_child(json_iterator, json, "ip_address", b64_host, GRPC_JSON_STRING, true); - gpr_free(host); - gpr_free(port); } else if (uri != nullptr && strcmp(uri->scheme, "unix") == 0) { json_iterator = grpc_json_create_child(json_iterator, json, "uds_address", nullptr, GRPC_JSON_OBJECT, false); diff --git a/src/core/lib/gpr/host_port.cc b/src/core/lib/gpr/host_port.cc deleted file mode 100644 index a34e01cb516..00000000000 --- a/src/core/lib/gpr/host_port.cc +++ /dev/null @@ -1,98 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/lib/gpr/host_port.h" - -#include - -#include -#include -#include - -#include "src/core/lib/gpr/string.h" - -int gpr_join_host_port(char** out, const char* host, int port) { - if (host[0] != '[' && strchr(host, ':') != nullptr) { - /* IPv6 literals must be enclosed in brackets. */ - return gpr_asprintf(out, "[%s]:%d", host, port); - } else { - /* Ordinary non-bracketed host:port. */ - return gpr_asprintf(out, "%s:%d", host, port); - } -} - -int gpr_split_host_port(const char* name, char** host, char** port) { - const char* host_start; - size_t host_len; - const char* port_start; - - *host = nullptr; - *port = nullptr; - - if (name[0] == '[') { - /* Parse a bracketed host, typically an IPv6 literal. */ - const char* rbracket = strchr(name, ']'); - if (rbracket == nullptr) { - /* Unmatched [ */ - return 0; - } - if (rbracket[1] == '\0') { - /* ] */ - port_start = nullptr; - } else if (rbracket[1] == ':') { - /* ]: */ - port_start = rbracket + 2; - } else { - /* ] */ - return 0; - } - host_start = name + 1; - host_len = static_cast(rbracket - host_start); - if (memchr(host_start, ':', host_len) == nullptr) { - /* Require all bracketed hosts to contain a colon, because a hostname or - IPv4 address should never use brackets. */ - return 0; - } - } else { - const char* colon = strchr(name, ':'); - if (colon != nullptr && strchr(colon + 1, ':') == nullptr) { - /* Exactly 1 colon. Split into host:port. */ - host_start = name; - host_len = static_cast(colon - name); - port_start = colon + 1; - } else { - /* 0 or 2+ colons. Bare hostname or IPv6 litearal. */ - host_start = name; - host_len = strlen(name); - port_start = nullptr; - } - } - - /* Allocate return values. */ - *host = static_cast(gpr_malloc(host_len + 1)); - memcpy(*host, host_start, host_len); - (*host)[host_len] = '\0'; - - if (port_start != nullptr) { - *port = gpr_strdup(port_start); - } - - return 1; -} diff --git a/src/core/lib/gpr/string.cc b/src/core/lib/gpr/string.cc index a39f56ef926..14436ec1bf9 100644 --- a/src/core/lib/gpr/string.cc +++ b/src/core/lib/gpr/string.cc @@ -289,17 +289,22 @@ char* gpr_strvec_flatten(gpr_strvec* sv, size_t* final_length) { return gpr_strjoin((const char**)sv->strs, sv->count, final_length); } -int gpr_stricmp(const char* a, const char* b) { +int gpr_strincmp(const char* a, const char* b, size_t n) { int ca, cb; do { ca = tolower(*a); cb = tolower(*b); ++a; ++b; - } while (ca == cb && ca && cb); + --n; + } while (ca == cb && ca != 0 && cb != 0 && n != 0); return ca - cb; } +int gpr_stricmp(const char* a, const char* b) { + return gpr_strincmp(a, b, SIZE_MAX); +} + static void add_string_to_split(const char* beg, const char* end, char*** strs, size_t* nstrs, size_t* capstrs) { char* out = diff --git a/src/core/lib/gpr/string.h b/src/core/lib/gpr/string.h index bf59db7abfe..fcccf5e6764 100644 --- a/src/core/lib/gpr/string.h +++ b/src/core/lib/gpr/string.h @@ -115,6 +115,7 @@ char* gpr_strvec_flatten(gpr_strvec* strs, size_t* total_length); /** Case insensitive string comparison... return <0 if lower(a)0 if lower(a)>lower(b) */ int gpr_stricmp(const char* a, const char* b); +int gpr_strincmp(const char* a, const char* b, size_t n); void* gpr_memrchr(const void* s, int c, size_t n); diff --git a/src/core/lib/gprpp/host_port.cc b/src/core/lib/gprpp/host_port.cc new file mode 100644 index 00000000000..f3f8a73602a --- /dev/null +++ b/src/core/lib/gprpp/host_port.cc @@ -0,0 +1,97 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/gprpp/host_port.h" + +#include + +#include +#include +#include + +#include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/string_view.h" + +namespace grpc_core { +int JoinHostPort(UniquePtr* out, const char* host, int port) { + char* tmp; + int ret; + if (host[0] != '[' && strchr(host, ':') != nullptr) { + /* IPv6 literals must be enclosed in brackets. */ + ret = gpr_asprintf(&tmp, "[%s]:%d", host, port); + } else { + /* Ordinary non-bracketed host:port. */ + ret = gpr_asprintf(&tmp, "%s:%d", host, port); + } + out->reset(tmp); + return ret; +} + +bool SplitHostPort(StringView name, StringView* host, StringView* port) { + if (name[0] == '[') { + /* Parse a bracketed host, typically an IPv6 literal. */ + const size_t rbracket = name.find(']', 1); + if (rbracket == grpc_core::StringView::npos) { + /* Unmatched [ */ + return false; + } + if (rbracket == name.size() - 1) { + /* ] */ + port->clear(); + } else if (name[rbracket + 1] == ':') { + /* ]: */ + *port = name.substr(rbracket + 2, name.size() - rbracket - 2); + } else { + /* ] */ + return false; + } + *host = name.substr(1, rbracket - 1); + if (host->find(':') == grpc_core::StringView::npos) { + /* Require all bracketed hosts to contain a colon, because a hostname or + IPv4 address should never use brackets. */ + host->clear(); + return false; + } + } else { + size_t colon = name.find(':'); + if (colon != grpc_core::StringView::npos && + name.find(':', colon + 1) == grpc_core::StringView::npos) { + /* Exactly 1 colon. Split into host:port. */ + *host = name.substr(0, colon); + *port = name.substr(colon + 1, name.size() - colon - 1); + } else { + /* 0 or 2+ colons. Bare hostname or IPv6 litearal. */ + *host = name; + port->clear(); + } + } + return true; +} + +bool SplitHostPort(StringView name, UniquePtr* host, + UniquePtr* port) { + StringView host_view; + StringView port_view; + const bool ret = SplitHostPort(name, &host_view, &port_view); + host->reset(host_view.empty() ? nullptr : host_view.dup().release()); + port->reset(port_view.empty() ? nullptr : port_view.dup().release()); + return ret; +} +} // namespace grpc_core diff --git a/src/core/lib/gpr/host_port.h b/src/core/lib/gprpp/host_port.h similarity index 51% rename from src/core/lib/gpr/host_port.h rename to src/core/lib/gprpp/host_port.h index 0bf0960f824..9a0b492b98f 100644 --- a/src/core/lib/gpr/host_port.h +++ b/src/core/lib/gprpp/host_port.h @@ -16,28 +16,44 @@ * */ -#ifndef GRPC_CORE_LIB_GPR_HOST_PORT_H -#define GRPC_CORE_LIB_GPR_HOST_PORT_H +#ifndef GRPC_CORE_LIB_GPRPP_HOST_PORT_H +#define GRPC_CORE_LIB_GPRPP_HOST_PORT_H #include +#include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/gprpp/string_view.h" + +namespace grpc_core { + /** Given a host and port, creates a newly-allocated string of the form "host:port" or "[ho:st]:port", depending on whether the host contains colons like an IPv6 literal. If the host is already bracketed, then additional brackets will not be added. Usage is similar to gpr_asprintf: returns the number of bytes written - (excluding the final '\0'), and *out points to a string which must later be - destroyed using gpr_free(). + (excluding the final '\0'), and *out points to a string. In the unlikely event of an error, returns -1 and sets *out to NULL. */ -int gpr_join_host_port(char** out, const char* host, int port); +int JoinHostPort(UniquePtr* out, const char* host, int port); /** Given a name in the form "host:port" or "[ho:st]:port", split into hostname - and port number, into newly allocated strings, which must later be - destroyed using gpr_free(). - Return 1 on success, 0 on failure. Guarantees *host and *port == NULL on - failure. */ -int gpr_split_host_port(const char* name, char** host, char** port); + and port number. -#endif /* GRPC_CORE_LIB_GPR_HOST_PORT_H */ + There are two variants of this method: + 1) StringView output: port and host are returned as views on name. + 2) char* output: port and host are copied into newly allocated strings. + + Prefer variant (1) over (2), because no allocation or copy is performed in + variant (1). Use (2) only when interacting with C API that mandate + null-terminated strings. + + Return true on success, false on failure. Guarantees *host and *port are + cleared on failure. */ +bool SplitHostPort(StringView name, StringView* host, StringView* port); +bool SplitHostPort(StringView name, UniquePtr* host, + UniquePtr* port); + +} // namespace grpc_core + +#endif /* GRPC_CORE_LIB_GPRPP_HOST_PORT_H */ diff --git a/src/core/lib/gprpp/string_view.h b/src/core/lib/gprpp/string_view.h new file mode 100644 index 00000000000..05a81066d48 --- /dev/null +++ b/src/core/lib/gprpp/string_view.h @@ -0,0 +1,143 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GRPC_CORE_LIB_GPRPP_STRING_VIEW_H +#define GRPC_CORE_LIB_GPRPP_STRING_VIEW_H + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/memory.h" + +namespace grpc_core { + +// Provides a light-weight view over a char array or a slice, similar but not +// identical to absl::string_view. +// +// Any method that has the same name as absl::string_view MUST HAVE identical +// semantics to what absl::string_view provides. +// +// Methods that are not part of absl::string_view API, must be clearly +// annotated. +// +// StringView does not own the buffers that back the view. Callers must ensure +// the buffer stays around while the StringView is accessible. +// +// Pass StringView by value in functions, since it is exactly two pointers in +// size. +// +// The interface used here is not identical to absl::string_view. Notably, we +// need to support slices while we cannot support std::string, and gpr string +// style functions such as strdup() and cmp(). Once we switch to +// absl::string_view this class will inherit from absl::string_view and add the +// gRPC-specific APIs. +class StringView final { + public: + static constexpr size_t npos = std::numeric_limits::max(); + + constexpr StringView(const char* ptr, size_t size) : ptr_(ptr), size_(size) {} + constexpr StringView(const char* ptr) + : StringView(ptr, ptr == nullptr ? 0 : strlen(ptr)) {} + // Not part of absl::string_view API. + StringView(const grpc_slice& slice) + : StringView(reinterpret_cast(GRPC_SLICE_START_PTR(slice)), + GRPC_SLICE_LENGTH(slice)) {} + constexpr StringView() : StringView(nullptr, 0) {} + + constexpr const char* data() const { return ptr_; } + constexpr size_t size() const { return size_; } + constexpr bool empty() const { return size_ == 0; } + + StringView substr(size_t start, size_t size = npos) { + GPR_DEBUG_ASSERT(start + size <= size_); + return StringView(ptr_ + start, std::min(size, size_ - start)); + } + + constexpr const char& operator[](size_t i) const { return ptr_[i]; } + + const char& front() const { return ptr_[0]; } + const char& back() const { return ptr_[size_ - 1]; } + + void remove_prefix(size_t n) { + GPR_DEBUG_ASSERT(n <= size_); + ptr_ += n; + size_ -= n; + } + + void remove_suffix(size_t n) { + GPR_DEBUG_ASSERT(n <= size_); + size_ -= n; + } + + size_t find(char c, size_t pos = 0) const { + if (empty() || pos >= size_) return npos; + const char* result = + static_cast(memchr(ptr_ + pos, c, size_ - pos)); + return result != nullptr ? result - ptr_ : npos; + } + + void clear() { + ptr_ = nullptr; + size_ = 0; + } + + // Creates a dup of the string viewed by this class. + // Return value is null-terminated and never nullptr. + // + // Not part of absl::string_view API. + grpc_core::UniquePtr dup() const { + char* str = static_cast(gpr_malloc(size_ + 1)); + if (size_ > 0) memcpy(str, ptr_, size_); + str[size_] = '\0'; + return grpc_core::UniquePtr(str); + } + + // Not part of absl::string_view API. + int cmp(StringView other) const { + const size_t len = GPR_MIN(size(), other.size()); + const int ret = strncmp(data(), other.data(), len); + if (ret != 0) return ret; + if (size() == other.size()) return 0; + if (size() < other.size()) return -1; + return 1; + } + + private: + const char* ptr_; + size_t size_; +}; + +inline bool operator==(StringView lhs, StringView rhs) { + return lhs.size() == rhs.size() && + strncmp(lhs.data(), rhs.data(), lhs.size()) == 0; +} + +inline bool operator!=(StringView lhs, StringView rhs) { return !(lhs == rhs); } + +} // namespace grpc_core + +#endif /* GRPC_CORE_LIB_GPRPP_STRING_VIEW_H */ diff --git a/src/core/lib/http/httpcli_security_connector.cc b/src/core/lib/http/httpcli_security_connector.cc index 762cbe41bcf..8196019f098 100644 --- a/src/core/lib/http/httpcli_security_connector.cc +++ b/src/core/lib/http/httpcli_security_connector.cc @@ -30,6 +30,7 @@ #include "src/core/lib/channel/handshaker_registry.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" +#include "src/core/lib/gprpp/string_view.h" #include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" @@ -108,7 +109,8 @@ class grpc_httpcli_ssl_channel_security_connector final return strcmp(secure_peer_name_, other->secure_peer_name_); } - bool check_call_host(const char* host, grpc_auth_context* auth_context, + bool check_call_host(grpc_core::StringView host, + grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) override { *error = GRPC_ERROR_NONE; diff --git a/src/core/lib/iomgr/resolve_address_custom.cc b/src/core/lib/iomgr/resolve_address_custom.cc index 9cf7817f66e..64c33cdc0d4 100644 --- a/src/core/lib/iomgr/resolve_address_custom.cc +++ b/src/core/lib/iomgr/resolve_address_custom.cc @@ -24,9 +24,9 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/iomgr_custom.h" #include "src/core/lib/iomgr/resolve_address_custom.h" @@ -86,11 +86,12 @@ void grpc_custom_resolve_callback(grpc_custom_resolver* r, } static grpc_error* try_split_host_port(const char* name, - const char* default_port, char** host, - char** port) { + const char* default_port, + grpc_core::UniquePtr* host, + grpc_core::UniquePtr* port) { /* parse name, splitting it into host and port parts */ grpc_error* error; - gpr_split_host_port(name, host, port); + SplitHostPort(name, host, port); if (*host == nullptr) { char* msg; gpr_asprintf(&msg, "unparseable host:port: '%s'", name); @@ -107,7 +108,7 @@ static grpc_error* try_split_host_port(const char* name, gpr_free(msg); return error; } - *port = gpr_strdup(default_port); + port->reset(gpr_strdup(default_port)); } return GRPC_ERROR_NONE; } @@ -115,28 +116,26 @@ static grpc_error* try_split_host_port(const char* name, static grpc_error* blocking_resolve_address_impl( const char* name, const char* default_port, grpc_resolved_addresses** addresses) { - char* host; - char* port; + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; grpc_error* err; GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD(); err = try_split_host_port(name, default_port, &host, &port); if (err != GRPC_ERROR_NONE) { - gpr_free(host); - gpr_free(port); return err; } /* Call getaddrinfo */ grpc_custom_resolver resolver; - resolver.host = host; - resolver.port = port; + resolver.host = host.get(); + resolver.port = port.get(); grpc_resolved_addresses* addrs; grpc_core::ExecCtx* curr = grpc_core::ExecCtx::Get(); grpc_core::ExecCtx::Set(nullptr); - err = resolve_address_vtable->resolve(host, port, &addrs); + err = resolve_address_vtable->resolve(host.get(), port.get(), &addrs); if (err != GRPC_ERROR_NONE) { if (retry_named_port_failure(&resolver, &addrs)) { GRPC_ERROR_UNREF(err); @@ -147,8 +146,6 @@ static grpc_error* blocking_resolve_address_impl( if (err == GRPC_ERROR_NONE) { *addresses = addrs; } - gpr_free(resolver.host); - gpr_free(resolver.port); return err; } @@ -157,22 +154,20 @@ static void resolve_address_impl(const char* name, const char* default_port, grpc_closure* on_done, grpc_resolved_addresses** addrs) { grpc_custom_resolver* r = nullptr; - char* host = nullptr; - char* port = nullptr; + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; grpc_error* err; GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD(); err = try_split_host_port(name, default_port, &host, &port); if (err != GRPC_ERROR_NONE) { GRPC_CLOSURE_SCHED(on_done, err); - gpr_free(host); - gpr_free(port); return; } r = (grpc_custom_resolver*)gpr_malloc(sizeof(grpc_custom_resolver)); r->on_done = on_done; r->addresses = addrs; - r->host = host; - r->port = port; + r->host = host.release(); + r->port = port.release(); /* Call getaddrinfo */ resolve_address_vtable->resolve_async(r, r->host, r->port); diff --git a/src/core/lib/iomgr/resolve_address_posix.cc b/src/core/lib/iomgr/resolve_address_posix.cc index e6dd8f1ceab..e02dc19bb27 100644 --- a/src/core/lib/iomgr/resolve_address_posix.cc +++ b/src/core/lib/iomgr/resolve_address_posix.cc @@ -33,9 +33,9 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/executor.h" @@ -48,8 +48,6 @@ static grpc_error* posix_blocking_resolve_address( grpc_core::ExecCtx exec_ctx; struct addrinfo hints; struct addrinfo *result = nullptr, *resp; - char* host; - char* port; int s; size_t i; grpc_error* err; @@ -59,8 +57,10 @@ static grpc_error* posix_blocking_resolve_address( return grpc_resolve_unix_domain_address(name + 5, addresses); } + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; /* parse name, splitting it into host and port parts */ - gpr_split_host_port(name, &host, &port); + grpc_core::SplitHostPort(name, &host, &port); if (host == nullptr) { err = grpc_error_set_str( GRPC_ERROR_CREATE_FROM_STATIC_STRING("unparseable host:port"), @@ -74,7 +74,7 @@ static grpc_error* posix_blocking_resolve_address( GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(name)); goto done; } - port = gpr_strdup(default_port); + port.reset(gpr_strdup(default_port)); } /* Call getaddrinfo */ @@ -84,16 +84,16 @@ static grpc_error* posix_blocking_resolve_address( hints.ai_flags = AI_PASSIVE; /* for wildcard IP address */ GRPC_SCHEDULING_START_BLOCKING_REGION; - s = getaddrinfo(host, port, &hints, &result); + s = getaddrinfo(host.get(), port.get(), &hints, &result); GRPC_SCHEDULING_END_BLOCKING_REGION; if (s != 0) { /* Retry if well-known service name is recognized */ const char* svc[][2] = {{"http", "80"}, {"https", "443"}}; for (i = 0; i < GPR_ARRAY_SIZE(svc); i++) { - if (strcmp(port, svc[i][0]) == 0) { + if (strcmp(port.get(), svc[i][0]) == 0) { GRPC_SCHEDULING_START_BLOCKING_REGION; - s = getaddrinfo(host, svc[i][1], &hints, &result); + s = getaddrinfo(host.get(), svc[i][1], &hints, &result); GRPC_SCHEDULING_END_BLOCKING_REGION; break; } @@ -133,8 +133,6 @@ static grpc_error* posix_blocking_resolve_address( err = GRPC_ERROR_NONE; done: - gpr_free(host); - gpr_free(port); if (result) { freeaddrinfo(result); } diff --git a/src/core/lib/iomgr/resolve_address_windows.cc b/src/core/lib/iomgr/resolve_address_windows.cc index 64351c38a8f..a06d5cefbcb 100644 --- a/src/core/lib/iomgr/resolve_address_windows.cc +++ b/src/core/lib/iomgr/resolve_address_windows.cc @@ -35,8 +35,8 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/executor.h" @@ -57,14 +57,14 @@ static grpc_error* windows_blocking_resolve_address( grpc_core::ExecCtx exec_ctx; struct addrinfo hints; struct addrinfo *result = NULL, *resp; - char* host; - char* port; int s; size_t i; grpc_error* error = GRPC_ERROR_NONE; /* parse name, splitting it into host and port parts */ - gpr_split_host_port(name, &host, &port); + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; + grpc_core::SplitHostPort(name, &host, &port); if (host == NULL) { char* msg; gpr_asprintf(&msg, "unparseable host:port: '%s'", name); @@ -80,7 +80,7 @@ static grpc_error* windows_blocking_resolve_address( gpr_free(msg); goto done; } - port = gpr_strdup(default_port); + port.reset(gpr_strdup(default_port)); } /* Call getaddrinfo */ @@ -90,7 +90,7 @@ static grpc_error* windows_blocking_resolve_address( hints.ai_flags = AI_PASSIVE; /* for wildcard IP address */ GRPC_SCHEDULING_START_BLOCKING_REGION; - s = getaddrinfo(host, port, &hints, &result); + s = getaddrinfo(host.get(), port.get(), &hints, &result); GRPC_SCHEDULING_END_BLOCKING_REGION; if (s != 0) { error = GRPC_WSA_ERROR(WSAGetLastError(), "getaddrinfo"); @@ -122,8 +122,6 @@ static grpc_error* windows_blocking_resolve_address( } done: - gpr_free(host); - gpr_free(port); if (result) { freeaddrinfo(result); } diff --git a/src/core/lib/iomgr/sockaddr_utils.cc b/src/core/lib/iomgr/sockaddr_utils.cc index 0839bdfef2d..baadf1da99e 100644 --- a/src/core/lib/iomgr/sockaddr_utils.cc +++ b/src/core/lib/iomgr/sockaddr_utils.cc @@ -28,8 +28,8 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/socket_utils.h" #include "src/core/lib/iomgr/unix_sockets_posix.h" @@ -181,15 +181,17 @@ int grpc_sockaddr_to_string(char** out, } if (ip != nullptr && grpc_inet_ntop(addr->sa_family, ip, ntop_buf, sizeof(ntop_buf)) != nullptr) { + grpc_core::UniquePtr tmp_out; if (sin6_scope_id != 0) { char* host_with_scope; /* Enclose sin6_scope_id with the format defined in RFC 6784 section 2. */ gpr_asprintf(&host_with_scope, "%s%%25%" PRIu32, ntop_buf, sin6_scope_id); - ret = gpr_join_host_port(out, host_with_scope, port); + ret = grpc_core::JoinHostPort(&tmp_out, host_with_scope, port); gpr_free(host_with_scope); } else { - ret = gpr_join_host_port(out, ntop_buf, port); + ret = grpc_core::JoinHostPort(&tmp_out, ntop_buf, port); } + *out = tmp_out.release(); } else { ret = gpr_asprintf(out, "(sockaddr family=%d)", addr->sa_family); } diff --git a/src/core/lib/iomgr/socket_utils_common_posix.cc b/src/core/lib/iomgr/socket_utils_common_posix.cc index 2101651b33f..47d9f51b095 100644 --- a/src/core/lib/iomgr/socket_utils_common_posix.cc +++ b/src/core/lib/iomgr/socket_utils_common_posix.cc @@ -46,7 +46,6 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/sockaddr_utils.h" diff --git a/src/core/lib/iomgr/tcp_client_cfstream.cc b/src/core/lib/iomgr/tcp_client_cfstream.cc index 4b21322d746..fcad5edd222 100644 --- a/src/core/lib/iomgr/tcp_client_cfstream.cc +++ b/src/core/lib/iomgr/tcp_client_cfstream.cc @@ -34,7 +34,7 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/cfstream_handle.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/endpoint_cfstream.h" @@ -143,12 +143,13 @@ static void OnOpen(void* arg, grpc_error* error) { static void ParseResolvedAddress(const grpc_resolved_address* addr, CFStringRef* host, int* port) { - char *host_port, *host_string, *port_string; + char* host_port; grpc_sockaddr_to_string(&host_port, addr, 1); - gpr_split_host_port(host_port, &host_string, &port_string); - *host = CFStringCreateWithCString(NULL, host_string, kCFStringEncodingUTF8); - gpr_free(host_string); - gpr_free(port_string); + grpc_core::UniquePtr host_string; + grpc_core::UniquePtr port_string; + grpc_core::SplitHostPort(host_port, &host_string, &port_string); + *host = + CFStringCreateWithCString(NULL, host_string.get(), kCFStringEncodingUTF8); gpr_free(host_port); *port = grpc_sockaddr_get_port(addr); } diff --git a/src/core/lib/security/security_connector/alts/alts_security_connector.cc b/src/core/lib/security/security_connector/alts/alts_security_connector.cc index 38b1f856d52..79908601130 100644 --- a/src/core/lib/security/security_connector/alts/alts_security_connector.cc +++ b/src/core/lib/security/security_connector/alts/alts_security_connector.cc @@ -108,10 +108,11 @@ class grpc_alts_channel_security_connector final return strcmp(target_name_, other->target_name_); } - bool check_call_host(const char* host, grpc_auth_context* auth_context, + bool check_call_host(grpc_core::StringView host, + grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) override { - if (host == nullptr || strcmp(host, target_name_) != 0) { + if (host.empty() || host != target_name_) { *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "ALTS call host does not match target name"); } diff --git a/src/core/lib/security/security_connector/fake/fake_security_connector.cc b/src/core/lib/security/security_connector/fake/fake_security_connector.cc index c55fd34d0e2..940c2ac5ee5 100644 --- a/src/core/lib/security/security_connector/fake/fake_security_connector.cc +++ b/src/core/lib/security/security_connector/fake/fake_security_connector.cc @@ -31,8 +31,8 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/security/context/security_context.h" #include "src/core/lib/security/credentials/credentials.h" @@ -102,39 +102,35 @@ class grpc_fake_channel_security_connector final tsi_create_fake_handshaker(/*is_client=*/true), this)); } - bool check_call_host(const char* host, grpc_auth_context* auth_context, + bool check_call_host(grpc_core::StringView host, + grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) override { - char* authority_hostname = nullptr; - char* authority_ignored_port = nullptr; - char* target_hostname = nullptr; - char* target_ignored_port = nullptr; - gpr_split_host_port(host, &authority_hostname, &authority_ignored_port); - gpr_split_host_port(target_, &target_hostname, &target_ignored_port); + grpc_core::StringView authority_hostname; + grpc_core::StringView authority_ignored_port; + grpc_core::StringView target_hostname; + grpc_core::StringView target_ignored_port; + grpc_core::SplitHostPort(host, &authority_hostname, + &authority_ignored_port); + grpc_core::SplitHostPort(target_, &target_hostname, &target_ignored_port); if (target_name_override_ != nullptr) { - char* fake_security_target_name_override_hostname = nullptr; - char* fake_security_target_name_override_ignored_port = nullptr; - gpr_split_host_port(target_name_override_, - &fake_security_target_name_override_hostname, - &fake_security_target_name_override_ignored_port); - if (strcmp(authority_hostname, - fake_security_target_name_override_hostname) != 0) { + grpc_core::StringView fake_security_target_name_override_hostname; + grpc_core::StringView fake_security_target_name_override_ignored_port; + grpc_core::SplitHostPort( + target_name_override_, &fake_security_target_name_override_hostname, + &fake_security_target_name_override_ignored_port); + if (authority_hostname != fake_security_target_name_override_hostname) { gpr_log(GPR_ERROR, "Authority (host) '%s' != Fake Security Target override '%s'", - host, fake_security_target_name_override_hostname); + host.data(), + fake_security_target_name_override_hostname.data()); abort(); } - gpr_free(fake_security_target_name_override_hostname); - gpr_free(fake_security_target_name_override_ignored_port); - } else if (strcmp(authority_hostname, target_hostname) != 0) { - gpr_log(GPR_ERROR, "Authority (host) '%s' != Target '%s'", - authority_hostname, target_hostname); + } else if (authority_hostname != target_hostname) { + gpr_log(GPR_ERROR, "Authority (host) '%s' != Target '%s'", host.data(), + target_); abort(); } - gpr_free(authority_hostname); - gpr_free(authority_ignored_port); - gpr_free(target_hostname); - gpr_free(target_ignored_port); return true; } diff --git a/src/core/lib/security/security_connector/local/local_security_connector.cc b/src/core/lib/security/security_connector/local/local_security_connector.cc index c1a101d4ab8..5b777009d34 100644 --- a/src/core/lib/security/security_connector/local/local_security_connector.cc +++ b/src/core/lib/security/security_connector/local/local_security_connector.cc @@ -156,10 +156,11 @@ class grpc_local_channel_security_connector final creds->connect_type()); } - bool check_call_host(const char* host, grpc_auth_context* auth_context, + bool check_call_host(grpc_core::StringView host, + grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) override { - if (host == nullptr || strcmp(host, target_name_) != 0) { + if (host.empty() || host != target_name_) { *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "local call host does not match target name"); } diff --git a/src/core/lib/security/security_connector/security_connector.cc b/src/core/lib/security/security_connector/security_connector.cc index 47c0ad5aa3d..2c7c982e719 100644 --- a/src/core/lib/security/security_connector/security_connector.cc +++ b/src/core/lib/security/security_connector/security_connector.cc @@ -28,8 +28,8 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/context/security_context.h" #include "src/core/lib/security/credentials/credentials.h" diff --git a/src/core/lib/security/security_connector/security_connector.h b/src/core/lib/security/security_connector/security_connector.h index f71ee54402d..e5ced44638b 100644 --- a/src/core/lib/security/security_connector/security_connector.h +++ b/src/core/lib/security/security_connector/security_connector.h @@ -98,7 +98,7 @@ class grpc_channel_security_connector : public grpc_security_connector { /// Returns true if completed synchronously, in which case \a error will /// be set to indicate the result. Otherwise, \a on_call_host_checked /// will be invoked when complete. - virtual bool check_call_host(const char* host, + virtual bool check_call_host(grpc_core::StringView host, grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) GRPC_ABSTRACT; diff --git a/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc b/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc index f920dc6046d..97c04cafce4 100644 --- a/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +++ b/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc @@ -28,8 +28,8 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/handshaker.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/security/context/security_context.h" #include "src/core/lib/security/credentials/credentials.h" @@ -75,15 +75,14 @@ class grpc_ssl_channel_security_connector final ? nullptr : gpr_strdup(overridden_target_name)), verify_options_(&config->verify_options) { - char* port; - gpr_split_host_port(target_name, &target_name_, &port); - gpr_free(port); + grpc_core::StringView host; + grpc_core::StringView port; + grpc_core::SplitHostPort(target_name, &host, &port); + target_name_ = host.dup(); } ~grpc_ssl_channel_security_connector() override { tsi_ssl_client_handshaker_factory_unref(client_handshaker_factory_); - if (target_name_ != nullptr) gpr_free(target_name_); - if (overridden_target_name_ != nullptr) gpr_free(overridden_target_name_); } grpc_security_status InitializeHandshakerFactory( @@ -123,8 +122,8 @@ class grpc_ssl_channel_security_connector final tsi_handshaker* tsi_hs = nullptr; tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker( client_handshaker_factory_, - overridden_target_name_ != nullptr ? overridden_target_name_ - : target_name_, + overridden_target_name_ != nullptr ? overridden_target_name_.get() + : target_name_.get(), &tsi_hs); if (result != TSI_OK) { gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.", @@ -139,8 +138,8 @@ class grpc_ssl_channel_security_connector final grpc_core::RefCountedPtr* auth_context, grpc_closure* on_peer_checked) override { const char* target_name = overridden_target_name_ != nullptr - ? overridden_target_name_ - : target_name_; + ? overridden_target_name_.get() + : target_name_.get(); grpc_error* error = ssl_check_peer(target_name, &peer, auth_context); if (error == GRPC_ERROR_NONE && verify_options_->verify_peer_callback != nullptr) { @@ -175,17 +174,18 @@ class grpc_ssl_channel_security_connector final reinterpret_cast(other_sc); int c = channel_security_connector_cmp(other); if (c != 0) return c; - c = strcmp(target_name_, other->target_name_); + c = strcmp(target_name_.get(), other->target_name_.get()); if (c != 0) return c; return (overridden_target_name_ == nullptr || other->overridden_target_name_ == nullptr) - ? GPR_ICMP(overridden_target_name_, - other->overridden_target_name_) - : strcmp(overridden_target_name_, - other->overridden_target_name_); + ? GPR_ICMP(overridden_target_name_.get(), + other->overridden_target_name_.get()) + : strcmp(overridden_target_name_.get(), + other->overridden_target_name_.get()); } - bool check_call_host(const char* host, grpc_auth_context* auth_context, + bool check_call_host(grpc_core::StringView host, + grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) override { grpc_security_status status = GRPC_SECURITY_ERROR; @@ -194,7 +194,7 @@ class grpc_ssl_channel_security_connector final /* If the target name was overridden, then the original target_name was 'checked' transitively during the previous peer check at the end of the handshake. */ - if (overridden_target_name_ != nullptr && strcmp(host, target_name_) == 0) { + if (overridden_target_name_ != nullptr && host == target_name_.get()) { status = GRPC_SECURITY_OK; } if (status != GRPC_SECURITY_OK) { @@ -212,8 +212,8 @@ class grpc_ssl_channel_security_connector final private: tsi_ssl_client_handshaker_factory* client_handshaker_factory_; - char* target_name_; - char* overridden_target_name_; + grpc_core::UniquePtr target_name_; + grpc_core::UniquePtr overridden_target_name_; const verify_peer_options* verify_options_; }; diff --git a/src/core/lib/security/security_connector/ssl_utils.cc b/src/core/lib/security/security_connector/ssl_utils.cc index cb0d5437988..ebb4a3f9ee8 100644 --- a/src/core/lib/security/security_connector/ssl_utils.cc +++ b/src/core/lib/security/security_connector/ssl_utils.cc @@ -27,9 +27,9 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/global_config.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/context/security_context.h" @@ -136,12 +136,13 @@ grpc_error* grpc_ssl_check_alpn(const tsi_peer* peer) { return GRPC_ERROR_NONE; } -grpc_error* grpc_ssl_check_peer_name(const char* peer_name, +grpc_error* grpc_ssl_check_peer_name(grpc_core::StringView peer_name, const tsi_peer* peer) { /* Check the peer name if specified. */ - if (peer_name != nullptr && !grpc_ssl_host_matches_name(peer, peer_name)) { + if (!peer_name.empty() && !grpc_ssl_host_matches_name(peer, peer_name)) { char* msg; - gpr_asprintf(&msg, "Peer name %s is not in peer certificate", peer_name); + gpr_asprintf(&msg, "Peer name %s is not in peer certificate", + peer_name.data()); grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg); gpr_free(msg); return error; @@ -149,15 +150,16 @@ grpc_error* grpc_ssl_check_peer_name(const char* peer_name, return GRPC_ERROR_NONE; } -bool grpc_ssl_check_call_host(const char* host, const char* target_name, - const char* overridden_target_name, +bool grpc_ssl_check_call_host(grpc_core::StringView host, + grpc_core::StringView target_name, + grpc_core::StringView overridden_target_name, grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) { grpc_security_status status = GRPC_SECURITY_ERROR; tsi_peer peer = grpc_shallow_peer_from_ssl_auth_context(auth_context); if (grpc_ssl_host_matches_name(&peer, host)) status = GRPC_SECURITY_OK; - if (overridden_target_name != nullptr && strcmp(host, target_name) == 0) { + if (!overridden_target_name.empty() && host == target_name) { status = GRPC_SECURITY_OK; } if (status != GRPC_SECURITY_OK) { @@ -179,35 +181,28 @@ const char** grpc_fill_alpn_protocol_strings(size_t* num_alpn_protocols) { return alpn_protocol_strings; } -int grpc_ssl_host_matches_name(const tsi_peer* peer, const char* peer_name) { - char* allocated_name = nullptr; - int r; - - char* ignored_port; - gpr_split_host_port(peer_name, &allocated_name, &ignored_port); - gpr_free(ignored_port); - peer_name = allocated_name; - if (!peer_name) return 0; +int grpc_ssl_host_matches_name(const tsi_peer* peer, + grpc_core::StringView peer_name) { + grpc_core::StringView allocated_name; + grpc_core::StringView ignored_port; + grpc_core::SplitHostPort(peer_name, &allocated_name, &ignored_port); + if (allocated_name.empty()) return 0; // IPv6 zone-id should not be included in comparisons. - char* const zone_id = strchr(allocated_name, '%'); - if (zone_id != nullptr) *zone_id = '\0'; - - r = tsi_ssl_peer_matches_name(peer, peer_name); - gpr_free(allocated_name); - return r; + const size_t zone_id = allocated_name.find('%'); + if (zone_id != grpc_core::StringView::npos) { + allocated_name.remove_suffix(allocated_name.size() - zone_id); + } + return tsi_ssl_peer_matches_name(peer, allocated_name); } -bool grpc_ssl_cmp_target_name(const char* target_name, - const char* other_target_name, - const char* overridden_target_name, - const char* other_overridden_target_name) { - int c = strcmp(target_name, other_target_name); +int grpc_ssl_cmp_target_name( + grpc_core::StringView target_name, grpc_core::StringView other_target_name, + grpc_core::StringView overridden_target_name, + grpc_core::StringView other_overridden_target_name) { + int c = target_name.cmp(other_target_name); if (c != 0) return c; - return (overridden_target_name == nullptr || - other_overridden_target_name == nullptr) - ? GPR_ICMP(overridden_target_name, other_overridden_target_name) - : strcmp(overridden_target_name, other_overridden_target_name); + return overridden_target_name.cmp(other_overridden_target_name); } grpc_core::RefCountedPtr grpc_ssl_peer_to_auth_context( diff --git a/src/core/lib/security/security_connector/ssl_utils.h b/src/core/lib/security/security_connector/ssl_utils.h index 1765a344c2a..bf8c1de3aae 100644 --- a/src/core/lib/security/security_connector/ssl_utils.h +++ b/src/core/lib/security/security_connector/ssl_utils.h @@ -28,6 +28,7 @@ #include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" +#include "src/core/lib/gprpp/string_view.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/security/security_connector/security_connector.h" #include "src/core/tsi/ssl_transport_security.h" @@ -46,16 +47,17 @@ GPR_GLOBAL_CONFIG_DECLARE_BOOL(grpc_not_use_system_ssl_roots); grpc_error* grpc_ssl_check_alpn(const tsi_peer* peer); /* Check peer name information returned from SSL handshakes. */ -grpc_error* grpc_ssl_check_peer_name(const char* peer_name, +grpc_error* grpc_ssl_check_peer_name(grpc_core::StringView peer_name, const tsi_peer* peer); /* Compare targer_name information extracted from SSL security connectors. */ -bool grpc_ssl_cmp_target_name(const char* target_name, - const char* other_target_name, - const char* overridden_target_name, - const char* other_overridden_target_name); +int grpc_ssl_cmp_target_name( + grpc_core::StringView target_name, grpc_core::StringView other_target_name, + grpc_core::StringView overridden_target_name, + grpc_core::StringView other_overridden_target_name); /* Check the host that will be set for a call is acceptable.*/ -bool grpc_ssl_check_call_host(const char* host, const char* target_name, - const char* overridden_target_name, +bool grpc_ssl_check_call_host(grpc_core::StringView host, + grpc_core::StringView target_name, + grpc_core::StringView overridden_target_name, grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error); @@ -89,7 +91,8 @@ grpc_core::RefCountedPtr grpc_ssl_peer_to_auth_context( tsi_peer grpc_shallow_peer_from_ssl_auth_context( const grpc_auth_context* auth_context); void grpc_shallow_peer_destruct(tsi_peer* peer); -int grpc_ssl_host_matches_name(const tsi_peer* peer, const char* peer_name); +int grpc_ssl_host_matches_name(const tsi_peer* peer, + grpc_core::StringView peer_name); /* --- Default SSL Root Store. --- */ namespace grpc_core { diff --git a/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc b/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc index ebf9c905079..5853de4fc13 100644 --- a/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +++ b/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc @@ -28,7 +28,7 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/ssl/ssl_credentials.h" #include "src/core/lib/security/credentials/tls/spiffe_credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" @@ -105,18 +105,13 @@ SpiffeChannelSecurityConnector::SpiffeChannelSecurityConnector( ? nullptr : gpr_strdup(overridden_target_name)) { check_arg_ = ServerAuthorizationCheckArgCreate(this); - char* port; - gpr_split_host_port(target_name, &target_name_, &port); - gpr_free(port); + grpc_core::StringView host; + grpc_core::StringView port; + grpc_core::SplitHostPort(target_name, &host, &port); + target_name_ = host.dup(); } SpiffeChannelSecurityConnector::~SpiffeChannelSecurityConnector() { - if (target_name_ != nullptr) { - gpr_free(target_name_); - } - if (overridden_target_name_ != nullptr) { - gpr_free(overridden_target_name_); - } if (client_handshaker_factory_ != nullptr) { tsi_ssl_client_handshaker_factory_unref(client_handshaker_factory_); } @@ -130,8 +125,8 @@ void SpiffeChannelSecurityConnector::add_handshakers( tsi_handshaker* tsi_hs = nullptr; tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker( client_handshaker_factory_, - overridden_target_name_ != nullptr ? overridden_target_name_ - : target_name_, + overridden_target_name_ != nullptr ? overridden_target_name_.get() + : target_name_.get(), &tsi_hs); if (result != TSI_OK) { gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.", @@ -147,8 +142,8 @@ void SpiffeChannelSecurityConnector::check_peer( grpc_core::RefCountedPtr* auth_context, grpc_closure* on_peer_checked) { const char* target_name = overridden_target_name_ != nullptr - ? overridden_target_name_ - : target_name_; + ? overridden_target_name_.get() + : target_name_.get(); grpc_error* error = grpc_ssl_check_alpn(&peer); if (error != GRPC_ERROR_NONE) { GRPC_CLOSURE_SCHED(on_peer_checked, error); @@ -203,16 +198,17 @@ int SpiffeChannelSecurityConnector::cmp( if (c != 0) { return c; } - return grpc_ssl_cmp_target_name(target_name_, other->target_name_, - overridden_target_name_, - other->overridden_target_name_); + return grpc_ssl_cmp_target_name(target_name_.get(), other->target_name_.get(), + overridden_target_name_.get(), + other->overridden_target_name_.get()); } bool SpiffeChannelSecurityConnector::check_call_host( - const char* host, grpc_auth_context* auth_context, + grpc_core::StringView host, grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) { - return grpc_ssl_check_call_host(host, target_name_, overridden_target_name_, - auth_context, on_call_host_checked, error); + return grpc_ssl_check_call_host(host, target_name_.get(), + overridden_target_name_.get(), auth_context, + on_call_host_checked, error); } void SpiffeChannelSecurityConnector::cancel_check_call_host( diff --git a/src/core/lib/security/security_connector/tls/spiffe_security_connector.h b/src/core/lib/security/security_connector/tls/spiffe_security_connector.h index 56972153e07..5ea00ee85b6 100644 --- a/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +++ b/src/core/lib/security/security_connector/tls/spiffe_security_connector.h @@ -53,7 +53,8 @@ class SpiffeChannelSecurityConnector final int cmp(const grpc_security_connector* other_sc) const override; - bool check_call_host(const char* host, grpc_auth_context* auth_context, + bool check_call_host(grpc_core::StringView host, + grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, grpc_error** error) override; @@ -83,8 +84,8 @@ class SpiffeChannelSecurityConnector final grpc_tls_server_authorization_check_arg* arg); grpc_closure* on_peer_checked_; - char* target_name_; - char* overridden_target_name_; + grpc_core::UniquePtr target_name_; + grpc_core::UniquePtr overridden_target_name_; tsi_ssl_client_handshaker_factory* client_handshaker_factory_ = nullptr; grpc_tls_server_authorization_check_arg* check_arg_; }; diff --git a/src/core/lib/security/transport/client_auth_filter.cc b/src/core/lib/security/transport/client_auth_filter.cc index 1062fc2f4fa..33343d276eb 100644 --- a/src/core/lib/security/transport/client_auth_filter.cc +++ b/src/core/lib/security/transport/client_auth_filter.cc @@ -346,7 +346,7 @@ static void auth_start_transport_stream_op_batch( GRPC_CALL_STACK_REF(calld->owning_call, "check_call_host"); GRPC_CLOSURE_INIT(&calld->async_result_closure, on_host_checked, batch, grpc_schedule_on_exec_ctx); - char* call_host = grpc_slice_to_c_string(calld->host); + grpc_core::StringView call_host(calld->host); grpc_error* error = GRPC_ERROR_NONE; if (chand->security_connector->check_call_host( call_host, chand->auth_context.get(), @@ -360,7 +360,6 @@ static void auth_start_transport_stream_op_batch( &calld->check_call_host_cancel_closure, cancel_check_call_host, elem, grpc_schedule_on_exec_ctx)); } - gpr_free(call_host); return; /* early exit */ } } diff --git a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc index 1b7e58d3ce0..0d28303e7dd 100644 --- a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +++ b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc @@ -30,7 +30,6 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/slice/slice_internal.h" diff --git a/src/core/tsi/ssl_transport_security.cc b/src/core/tsi/ssl_transport_security.cc index 25ae2cee285..d3c8982c847 100644 --- a/src/core/tsi/ssl_transport_security.cc +++ b/src/core/tsi/ssl_transport_security.cc @@ -233,11 +233,10 @@ static void ssl_info_callback(const SSL* ssl, int where, int ret) { /* Returns 1 if name looks like an IP address, 0 otherwise. This is a very rough heuristic, and only handles IPv6 in hexadecimal form. */ -static int looks_like_ip_address(const char* name) { - size_t i; +static int looks_like_ip_address(grpc_core::StringView name) { size_t dot_count = 0; size_t num_size = 0; - for (i = 0; i < strlen(name); i++) { + for (size_t i = 0; i < name.size(); ++i) { if (name[i] == ':') { /* IPv6 Address in hexadecimal form, : is not allowed in DNS names. */ return 1; @@ -1506,52 +1505,46 @@ static void tsi_ssl_server_handshaker_factory_destroy( gpr_free(self); } -static int does_entry_match_name(const char* entry, size_t entry_length, - const char* name) { - const char* dot; - const char* name_subdomain = nullptr; - size_t name_length = strlen(name); - size_t name_subdomain_length; - if (entry_length == 0) return 0; +static int does_entry_match_name(grpc_core::StringView entry, + grpc_core::StringView name) { + if (entry.empty()) return 0; /* Take care of '.' terminations. */ - if (name[name_length - 1] == '.') { - name_length--; + if (name.back() == '.') { + name.remove_suffix(1); } - if (entry[entry_length - 1] == '.') { - entry_length--; - if (entry_length == 0) return 0; + if (entry.back() == '.') { + entry.remove_suffix(1); + if (entry.empty()) return 0; } - if ((name_length == entry_length) && - strncmp(name, entry, entry_length) == 0) { + if (name == entry) { return 1; /* Perfect match. */ } - if (entry[0] != '*') return 0; + if (entry.front() != '*') return 0; /* Wildchar subdomain matching. */ - if (entry_length < 3 || entry[1] != '.') { /* At least *.x */ + if (entry.size() < 3 || entry[1] != '.') { /* At least *.x */ gpr_log(GPR_ERROR, "Invalid wildchar entry."); return 0; } - name_subdomain = strchr(name, '.'); - if (name_subdomain == nullptr) return 0; - name_subdomain_length = strlen(name_subdomain); - if (name_subdomain_length < 2) return 0; - name_subdomain++; /* Starts after the dot. */ - name_subdomain_length--; - entry += 2; /* Remove *. */ - entry_length -= 2; - dot = strchr(name_subdomain, '.'); - if ((dot == nullptr) || (dot == &name_subdomain[name_subdomain_length - 1])) { - gpr_log(GPR_ERROR, "Invalid toplevel subdomain: %s", name_subdomain); + size_t name_subdomain_pos = name.find('.'); + if (name_subdomain_pos == grpc_core::StringView::npos) return 0; + if (name_subdomain_pos >= name.size() - 2) return 0; + grpc_core::StringView name_subdomain = + name.substr(name_subdomain_pos + 1); /* Starts after the dot. */ + entry.remove_prefix(2); /* Remove *. */ + size_t dot = name_subdomain.find('.'); + if (dot == grpc_core::StringView::npos || dot == name_subdomain.size() - 1) { + grpc_core::UniquePtr name_subdomain_cstr(name_subdomain.dup()); + gpr_log(GPR_ERROR, "Invalid toplevel subdomain: %s", + name_subdomain_cstr.get()); return 0; } - if (name_subdomain[name_subdomain_length - 1] == '.') { - name_subdomain_length--; + if (name_subdomain.back() == '.') { + name_subdomain.remove_suffix(1); } - return ((entry_length > 0) && (name_subdomain_length == entry_length) && - strncmp(entry, name_subdomain, entry_length) == 0); + return !entry.empty() && name_subdomain == entry; } static int ssl_server_handshaker_factory_servername_callback(SSL* ssl, int* ap, @@ -1919,7 +1912,8 @@ tsi_result tsi_create_ssl_server_handshaker_factory_with_options( /* --- tsi_ssl utils. --- */ -int tsi_ssl_peer_matches_name(const tsi_peer* peer, const char* name) { +int tsi_ssl_peer_matches_name(const tsi_peer* peer, + grpc_core::StringView name) { size_t i = 0; size_t san_count = 0; const tsi_peer_property* cn_property = nullptr; @@ -1933,13 +1927,10 @@ int tsi_ssl_peer_matches_name(const tsi_peer* peer, const char* name) { TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY) == 0) { san_count++; - if (!like_ip && does_entry_match_name(property->value.data, - property->value.length, name)) { + grpc_core::StringView entry(property->value.data, property->value.length); + if (!like_ip && does_entry_match_name(entry, name)) { return 1; - } else if (like_ip && - strncmp(name, property->value.data, property->value.length) == - 0 && - strlen(name) == property->value.length) { + } else if (like_ip && name == entry) { /* IP Addresses are exact matches only. */ return 1; } @@ -1951,8 +1942,9 @@ int tsi_ssl_peer_matches_name(const tsi_peer* peer, const char* name) { /* If there's no SAN, try the CN, but only if its not like an IP Address */ if (san_count == 0 && cn_property != nullptr && !like_ip) { - if (does_entry_match_name(cn_property->value.data, - cn_property->value.length, name)) { + if (does_entry_match_name(grpc_core::StringView(cn_property->value.data, + cn_property->value.length), + name)) { return 1; } } diff --git a/src/core/tsi/ssl_transport_security.h b/src/core/tsi/ssl_transport_security.h index 769949e4aad..0203141e56e 100644 --- a/src/core/tsi/ssl_transport_security.h +++ b/src/core/tsi/ssl_transport_security.h @@ -21,6 +21,7 @@ #include +#include "src/core/lib/gprpp/string_view.h" #include "src/core/tsi/transport_security_interface.h" /* Value for the TSI_CERTIFICATE_TYPE_PEER_PROPERTY property for X509 certs. */ @@ -306,7 +307,7 @@ void tsi_ssl_server_handshaker_factory_unref( - handle mixed case. - handle %encoded chars. - handle public suffix wildchar more strictly (e.g. *.co.uk) */ -int tsi_ssl_peer_matches_name(const tsi_peer* peer, const char* name); +int tsi_ssl_peer_matches_name(const tsi_peer* peer, grpc_core::StringView name); /* --- Testing support. --- diff --git a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm index a24734024dc..ad426014a5b 100644 --- a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm +++ b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm @@ -37,9 +37,9 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" @@ -51,19 +51,18 @@ #import "../ConfigureCronet.h" -typedef struct fullstack_secure_fixture_data { - char *localaddr; -} fullstack_secure_fixture_data; +struct fullstack_secure_fixture_data { + grpc_core::UniquePtr localaddr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args *client_args, grpc_channel_args *server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_secure_fixture_data *ffd = - (fullstack_secure_fixture_data *)gpr_malloc(sizeof(fullstack_secure_fixture_data)); + fullstack_secure_fixture_data *ffd = grpc_core::New(); memset(&f, 0, sizeof(f)); - gpr_join_host_port(&ffd->localaddr, "127.0.0.1", port); + grpc_core::JoinHostPort(&ffd->localaddr, "127.0.0.1", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(NULL); @@ -83,7 +82,8 @@ static void cronet_init_client_secure_fullstack(grpc_end2end_test_fixture *f, grpc_channel_args *client_args, stream_engine *cronetEngine) { fullstack_secure_fixture_data *ffd = (fullstack_secure_fixture_data *)f->fixture_data; - f->client = grpc_cronet_secure_channel_create(cronetEngine, ffd->localaddr, client_args, NULL); + f->client = + grpc_cronet_secure_channel_create(cronetEngine, ffd->localaddr.get(), client_args, NULL); GPR_ASSERT(f->client != NULL); } @@ -96,15 +96,14 @@ static void chttp2_init_server_secure_fullstack(grpc_end2end_test_fixture *f, } f->server = grpc_server_create(server_args, NULL); grpc_server_register_completion_queue(f->server, f->cq, NULL); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, server_creds)); + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); } static void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { fullstack_secure_fixture_data *ffd = (fullstack_secure_fixture_data *)f->fixture_data; - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } static void cronet_init_client_simple_ssl_secure_fullstack(grpc_end2end_test_fixture *f, diff --git a/src/objective-c/tests/CronetTests/CronetUnitTests.mm b/src/objective-c/tests/CronetTests/CronetUnitTests.mm index 2473cf612be..4e2e70f1512 100644 --- a/src/objective-c/tests/CronetTests/CronetUnitTests.mm +++ b/src/objective-c/tests/CronetTests/CronetUnitTests.mm @@ -33,9 +33,9 @@ #import "src/core/lib/channel/channel_args.h" #import "src/core/lib/gpr/env.h" -#import "src/core/lib/gpr/host_port.h" #import "src/core/lib/gpr/string.h" #import "src/core/lib/gpr/tmpfile.h" +#import "src/core/lib/gprpp/host_port.h" #import "test/core/end2end/data/ssl_test_data.h" #import "test/core/util/test_config.h" @@ -133,11 +133,11 @@ unsigned int parse_h2_length(const char *field) { {{NULL, NULL, NULL, NULL}}}}; int port = grpc_pick_unused_port_or_die(); - char *addr; - gpr_join_host_port(&addr, "127.0.0.1", port); + grpc_core::UniquePtr addr; + grpc_core::JoinHostPort(&addr, "127.0.0.1", port); grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); stream_engine *cronetEngine = [Cronet getGlobalEngine]; - grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr, NULL, NULL); + grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr.get(), NULL, NULL); cq_verifier *cqv = cq_verifier_create(cq); grpc_op ops[6]; @@ -264,11 +264,11 @@ unsigned int parse_h2_length(const char *field) { {{NULL, NULL, NULL, NULL}}}}; int port = grpc_pick_unused_port_or_die(); - char *addr; - gpr_join_host_port(&addr, "127.0.0.1", port); + grpc_core::UniquePtr addr; + grpc_core::JoinHostPort(&addr, "127.0.0.1", port); grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); stream_engine *cronetEngine = [Cronet getGlobalEngine]; - grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr, args, NULL); + grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr.get(), args, NULL); cq_verifier *cqv = cq_verifier_create(cq); grpc_op ops[6]; diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 2619ccf9740..c7caee551ce 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -27,7 +27,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/gpr/env_linux.cc', 'src/core/lib/gpr/env_posix.cc', 'src/core/lib/gpr/env_windows.cc', - 'src/core/lib/gpr/host_port.cc', 'src/core/lib/gpr/log.cc', 'src/core/lib/gpr/log_android.cc', 'src/core/lib/gpr/log_linux.cc', @@ -54,6 +53,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/gprpp/arena.cc', 'src/core/lib/gprpp/fork.cc', 'src/core/lib/gprpp/global_config_env.cc', + 'src/core/lib/gprpp/host_port.cc', 'src/core/lib/gprpp/thd_posix.cc', 'src/core/lib/gprpp/thd_windows.cc', 'src/core/lib/profiling/basic_timers.cc', diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc index 8dd55f64944..deae9072613 100644 --- a/test/core/bad_ssl/bad_ssl_test.cc +++ b/test/core/bad_ssl/bad_ssl_test.cc @@ -25,8 +25,9 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" @@ -144,7 +145,9 @@ int main(int argc, char** argv) { gpr_asprintf(&args[0], "%s/bad_ssl_%s_server%s", root, test, gpr_subprocess_binary_extension()); args[1] = const_cast("--bind"); - gpr_join_host_port(&args[2], "::", port); + grpc_core::UniquePtr joined; + grpc_core::JoinHostPort(&joined, "::", port); + args[2] = joined.get(); svr = gpr_subprocess_create(4, (const char**)args); gpr_free(args[0]); @@ -153,7 +156,6 @@ int main(int argc, char** argv) { run_test(args[2], i); grpc_shutdown(); } - gpr_free(args[2]); gpr_subprocess_interrupt(svr); status = gpr_subprocess_join(svr); diff --git a/test/core/client_channel/parse_address_with_named_scope_id_test.cc b/test/core/client_channel/parse_address_with_named_scope_id_test.cc index bfafa745178..071fb88b734 100644 --- a/test/core/client_channel/parse_address_with_named_scope_id_test.cc +++ b/test/core/client_channel/parse_address_with_named_scope_id_test.cc @@ -30,7 +30,8 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/socket_utils.h" #include "test/core/util/test_config.h" @@ -60,20 +61,20 @@ static void test_grpc_parse_ipv6_parity_with_getaddrinfo( struct sockaddr_in6 resolve_with_gettaddrinfo(const char* uri_text) { grpc_uri* uri = grpc_uri_parse(uri_text, 0); - char* host = nullptr; - char* port = nullptr; - gpr_split_host_port(uri->path, &host, &port); + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; + grpc_core::SplitHostPort(uri->path, &host, &port); struct addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET6; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_NUMERICHOST; struct addrinfo* result; - int res = getaddrinfo(host, port, &hints, &result); + int res = getaddrinfo(host.get(), port.get(), &hints, &result); if (res != 0) { gpr_log(GPR_ERROR, - "getaddrinfo failed to resolve host:%s port:%s. Error: %d.", host, - port, res); + "getaddrinfo failed to resolve host:%s port:%s. Error: %d.", + host.get(), port.get(), res); abort(); } size_t num_addrs_from_getaddrinfo = 0; @@ -86,8 +87,6 @@ struct sockaddr_in6 resolve_with_gettaddrinfo(const char* uri_text) { *reinterpret_cast(result->ai_addr); // Cleanup freeaddrinfo(result); - gpr_free(host); - gpr_free(port); grpc_uri_destroy(uri); return out; } diff --git a/test/core/end2end/bad_server_response_test.cc b/test/core/end2end/bad_server_response_test.cc index 2d74b6b77b3..db480463b68 100644 --- a/test/core/end2end/bad_server_response_test.cc +++ b/test/core/end2end/bad_server_response_test.cc @@ -29,8 +29,8 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/sockaddr.h" @@ -71,7 +71,7 @@ #define SERVER_INCOMING_DATA_LENGTH_LOWER_THRESHOLD (size_t)200 struct rpc_state { - char* target; + grpc_core::UniquePtr target; grpc_completion_queue* cq; grpc_channel* channel; grpc_call* call; @@ -165,8 +165,9 @@ static void start_rpc(int target_port, grpc_status_code expected_status, state.cq = grpc_completion_queue_create_for_next(nullptr); cqv = cq_verifier_create(state.cq); - gpr_join_host_port(&state.target, "127.0.0.1", target_port); - state.channel = grpc_insecure_channel_create(state.target, nullptr, nullptr); + grpc_core::JoinHostPort(&state.target, "127.0.0.1", target_port); + state.channel = + grpc_insecure_channel_create(state.target.get(), nullptr, nullptr); grpc_slice host = grpc_slice_from_static_string("localhost"); state.call = grpc_channel_create_call( state.channel, nullptr, GRPC_PROPAGATE_DEFAULTS, state.cq, @@ -230,7 +231,7 @@ static void cleanup_rpc() { } while (ev.type != GRPC_QUEUE_SHUTDOWN); grpc_completion_queue_destroy(state.cq); grpc_channel_destroy(state.channel); - gpr_free(state.target); + state.target.reset(); } typedef struct { diff --git a/test/core/end2end/connection_refused_test.cc b/test/core/end2end/connection_refused_test.cc index 446e7b045a1..3bb6d2e23b6 100644 --- a/test/core/end2end/connection_refused_test.cc +++ b/test/core/end2end/connection_refused_test.cc @@ -24,7 +24,7 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata.h" @@ -77,10 +77,10 @@ static void run_test(bool wait_for_ready, bool use_service_config) { /* create a call, channel to a port which will refuse connection */ int port = grpc_pick_unused_port_or_die(); - char* addr; - gpr_join_host_port(&addr, "127.0.0.1", port); - gpr_log(GPR_INFO, "server: %s", addr); - chan = grpc_insecure_channel_create(addr, args, nullptr); + grpc_core::UniquePtr addr; + grpc_core::JoinHostPort(&addr, "127.0.0.1", port); + gpr_log(GPR_INFO, "server: %s", addr.get()); + chan = grpc_insecure_channel_create(addr.get(), args, nullptr); grpc_slice host = grpc_slice_from_static_string("nonexistant"); gpr_timespec deadline = grpc_timeout_seconds_to_deadline(2); call = @@ -88,8 +88,6 @@ static void run_test(bool wait_for_ready, bool use_service_config) { grpc_slice_from_static_string("/service/method"), &host, deadline, nullptr); - gpr_free(addr); - memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; diff --git a/test/core/end2end/dualstack_socket_test.cc b/test/core/end2end/dualstack_socket_test.cc index 330af8fce07..cb49e0030b4 100644 --- a/test/core/end2end/dualstack_socket_test.cc +++ b/test/core/end2end/dualstack_socket_test.cc @@ -28,8 +28,8 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/sockaddr_utils.h" @@ -70,8 +70,6 @@ static void log_resolved_addrs(const char* label, const char* hostname) { void test_connect(const char* server_host, const char* client_host, int port, int expect_ok) { - char* client_hostport; - char* server_hostport; grpc_channel* client; grpc_server* server; grpc_completion_queue* cq; @@ -99,7 +97,8 @@ void test_connect(const char* server_host, const char* client_host, int port, picked_port = 1; } - gpr_join_host_port(&server_hostport, server_host, port); + grpc_core::UniquePtr server_hostport; + grpc_core::JoinHostPort(&server_hostport, server_host, port); grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); @@ -111,7 +110,7 @@ void test_connect(const char* server_host, const char* client_host, int port, server = grpc_server_create(nullptr, nullptr); grpc_server_register_completion_queue(server, cq, nullptr); GPR_ASSERT((got_port = grpc_server_add_insecure_http2_port( - server, server_hostport)) > 0); + server, server_hostport.get())) > 0); if (port == 0) { port = got_port; } else { @@ -121,6 +120,7 @@ void test_connect(const char* server_host, const char* client_host, int port, cqv = cq_verifier_create(cq); /* Create client. */ + grpc_core::UniquePtr client_hostport; if (client_host[0] == 'i') { /* for ipv4:/ipv6: addresses, concatenate the port to each of the parts */ size_t i; @@ -139,8 +139,8 @@ void test_connect(const char* server_host, const char* client_host, int port, gpr_asprintf(&hosts_with_port[i], "%s:%d", uri_part_str, port); gpr_free(uri_part_str); } - client_hostport = gpr_strjoin_sep((const char**)hosts_with_port, - uri_parts.count, ",", nullptr); + client_hostport.reset(gpr_strjoin_sep((const char**)hosts_with_port, + uri_parts.count, ",", nullptr)); for (i = 0; i < uri_parts.count; i++) { gpr_free(hosts_with_port[i]); } @@ -148,18 +148,17 @@ void test_connect(const char* server_host, const char* client_host, int port, grpc_slice_buffer_destroy(&uri_parts); grpc_slice_unref(uri_slice); } else { - gpr_join_host_port(&client_hostport, client_host, port); + grpc_core::JoinHostPort(&client_hostport, client_host, port); } - client = grpc_insecure_channel_create(client_hostport, nullptr, nullptr); + client = + grpc_insecure_channel_create(client_hostport.get(), nullptr, nullptr); gpr_log(GPR_INFO, "Testing with server=%s client=%s (expecting %s)", - server_hostport, client_hostport, expect_ok ? "success" : "failure"); + server_hostport.get(), client_hostport.get(), + expect_ok ? "success" : "failure"); log_resolved_addrs("server resolved addr", server_host); log_resolved_addrs("client resolved addr", client_host); - gpr_free(client_hostport); - gpr_free(server_hostport); - if (expect_ok) { /* Normal deadline, shouldn't be reached. */ deadline = grpc_timeout_milliseconds_to_deadline(60000); diff --git a/test/core/end2end/fixtures/h2_census.cc b/test/core/end2end/fixtures/h2_census.cc index 60442ddcc77..72cb96138e1 100644 --- a/test/core/end2end/fixtures/h2_census.cc +++ b/test/core/end2end/fixtures/h2_census.cc @@ -29,25 +29,23 @@ #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_fixture_data { - char* localaddr; -} fullstack_fixture_data; +struct fullstack_fixture_data { + grpc_core::UniquePtr localaddr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = static_cast( - gpr_malloc(sizeof(fullstack_fixture_data))); + fullstack_fixture_data* ffd = grpc_core::New(); memset(&f, 0, sizeof(f)); - - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -71,7 +69,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, grpc_arg arg = make_census_enable_arg(); client_args = grpc_channel_args_copy_and_add(client_args, &arg, 1); f->client = - grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr); + grpc_insecure_channel_create(ffd->localaddr.get(), client_args, nullptr); GPR_ASSERT(f->client); { grpc_core::ExecCtx exec_ctx; @@ -94,15 +92,15 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, grpc_channel_args_destroy(server_args); } grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); + GPR_ASSERT( + grpc_server_add_insecure_http2_port(f->server, ffd->localaddr.get())); grpc_server_start(f->server); } void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_compress.cc b/test/core/end2end/fixtures/h2_compress.cc index 01e5ae1b7b5..dd0c1fe0201 100644 --- a/test/core/end2end/fixtures/h2_compress.cc +++ b/test/core/end2end/fixtures/h2_compress.cc @@ -30,28 +30,29 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/compression/compression_args.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_compression_fixture_data { - char* localaddr; - grpc_channel_args* client_args_compression; - grpc_channel_args* server_args_compression; -} fullstack_compression_fixture_data; +struct fullstack_compression_fixture_data { + ~fullstack_compression_fixture_data() { + grpc_channel_args_destroy(client_args_compression); + grpc_channel_args_destroy(server_args_compression); + } + grpc_core::UniquePtr localaddr; + grpc_channel_args* client_args_compression = nullptr; + grpc_channel_args* server_args_compression = nullptr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_compression( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_compression_fixture_data* ffd = - static_cast( - gpr_malloc(sizeof(fullstack_compression_fixture_data))); - memset(ffd, 0, sizeof(fullstack_compression_fixture_data)); - - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::New(); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); memset(&f, 0, sizeof(f)); f.fixture_data = ffd; @@ -73,7 +74,7 @@ void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture* f, grpc_channel_args_set_channel_default_compression_algorithm( client_args, GRPC_COMPRESS_GZIP); f->client = grpc_insecure_channel_create( - ffd->localaddr, ffd->client_args_compression, nullptr); + ffd->localaddr.get(), ffd->client_args_compression, nullptr); } void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture* f, @@ -92,7 +93,8 @@ void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture* f, } f->server = grpc_server_create(ffd->server_args_compression, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); + GPR_ASSERT( + grpc_server_add_insecure_http2_port(f->server, ffd->localaddr.get())); grpc_server_start(f->server); } @@ -100,10 +102,7 @@ void chttp2_tear_down_fullstack_compression(grpc_end2end_test_fixture* f) { grpc_core::ExecCtx exec_ctx; fullstack_compression_fixture_data* ffd = static_cast(f->fixture_data); - grpc_channel_args_destroy(ffd->client_args_compression); - grpc_channel_args_destroy(ffd->server_args_compression); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_fakesec.cc b/test/core/end2end/fixtures/h2_fakesec.cc index ad83aab39f4..1375549ed6c 100644 --- a/test/core/end2end/fixtures/h2_fakesec.cc +++ b/test/core/end2end/fixtures/h2_fakesec.cc @@ -25,26 +25,24 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_secure_fixture_data { - char* localaddr; -} fullstack_secure_fixture_data; +struct fullstack_secure_fixture_data { + grpc_core::UniquePtr localaddr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = - static_cast( - gpr_malloc(sizeof(fullstack_secure_fixture_data))); - + grpc_core::New(); memset(&f, 0, sizeof(f)); - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -66,8 +64,8 @@ static void chttp2_init_client_secure_fullstack( grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - f->client = - grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); + f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), + client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -82,7 +80,7 @@ static void chttp2_init_server_secure_fullstack( } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); @@ -91,8 +89,7 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } static void chttp2_init_client_fake_secure_fullstack( diff --git a/test/core/end2end/fixtures/h2_full+pipe.cc b/test/core/end2end/fixtures/h2_full+pipe.cc index 6d559c4e516..ac4913674f0 100644 --- a/test/core/end2end/fixtures/h2_full+pipe.cc +++ b/test/core/end2end/fixtures/h2_full+pipe.cc @@ -33,26 +33,25 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_fixture_data { - char* localaddr; -} fullstack_fixture_data; +struct fullstack_fixture_data { + grpc_core::UniquePtr localaddr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = static_cast( - gpr_malloc(sizeof(fullstack_fixture_data))); + fullstack_fixture_data* ffd = grpc_core::New(); memset(&f, 0, sizeof(f)); - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -66,7 +65,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, fullstack_fixture_data* ffd = static_cast(f->fixture_data); f->client = - grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr); + grpc_insecure_channel_create(ffd->localaddr.get(), client_args, nullptr); GPR_ASSERT(f->client); } @@ -79,15 +78,15 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); + GPR_ASSERT( + grpc_server_add_insecure_http2_port(f->server, ffd->localaddr.get())); grpc_server_start(f->server); } void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_full+trace.cc b/test/core/end2end/fixtures/h2_full+trace.cc index b8dbe261183..04de2a20182 100644 --- a/test/core/end2end/fixtures/h2_full+trace.cc +++ b/test/core/end2end/fixtures/h2_full+trace.cc @@ -34,25 +34,24 @@ #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/debug/trace.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_fixture_data { - char* localaddr; -} fullstack_fixture_data; +struct fullstack_fixture_data { + grpc_core::UniquePtr localaddr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = static_cast( - gpr_malloc(sizeof(fullstack_fixture_data))); + fullstack_fixture_data* ffd = grpc_core::New(); memset(&f, 0, sizeof(f)); - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -66,7 +65,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, fullstack_fixture_data* ffd = static_cast(f->fixture_data); f->client = - grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr); + grpc_insecure_channel_create(ffd->localaddr.get(), client_args, nullptr); GPR_ASSERT(f->client); } @@ -79,15 +78,15 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); + GPR_ASSERT( + grpc_server_add_insecure_http2_port(f->server, ffd->localaddr.get())); grpc_server_start(f->server); } void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_full+workarounds.cc b/test/core/end2end/fixtures/h2_full+workarounds.cc index cb0f7d275b3..8cfba4587e0 100644 --- a/test/core/end2end/fixtures/h2_full+workarounds.cc +++ b/test/core/end2end/fixtures/h2_full+workarounds.cc @@ -30,7 +30,7 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" @@ -39,24 +39,20 @@ static char* workarounds_arg[GRPC_MAX_WORKAROUND_ID] = { const_cast(GRPC_ARG_WORKAROUND_CRONET_COMPRESSION)}; -typedef struct fullstack_fixture_data { - char* localaddr; -} fullstack_fixture_data; +struct fullstack_fixture_data { + grpc_core::UniquePtr localaddr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = static_cast( - gpr_malloc(sizeof(fullstack_fixture_data))); + fullstack_fixture_data* ffd = grpc_core::New(); memset(&f, 0, sizeof(f)); - - gpr_join_host_port(&ffd->localaddr, "localhost", port); - + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr); - return f; } @@ -65,7 +61,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, fullstack_fixture_data* ffd = static_cast(f->fixture_data); f->client = - grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr); + grpc_insecure_channel_create(ffd->localaddr.get(), client_args, nullptr); GPR_ASSERT(f->client); } @@ -88,7 +84,8 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, } f->server = grpc_server_create(server_args_new, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); + GPR_ASSERT( + grpc_server_add_insecure_http2_port(f->server, ffd->localaddr.get())); grpc_server_start(f->server); grpc_channel_args_destroy(server_args_new); } @@ -96,8 +93,7 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_full.cc b/test/core/end2end/fixtures/h2_full.cc index c0d21288c7e..a3f2f25db5f 100644 --- a/test/core/end2end/fixtures/h2_full.cc +++ b/test/core/end2end/fixtures/h2_full.cc @@ -28,25 +28,24 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_fixture_data { - char* localaddr; -} fullstack_fixture_data; +struct fullstack_fixture_data { + grpc_core::UniquePtr localaddr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = static_cast( - gpr_malloc(sizeof(fullstack_fixture_data))); + fullstack_fixture_data* ffd = grpc_core::New(); memset(&f, 0, sizeof(f)); - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -60,7 +59,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, fullstack_fixture_data* ffd = static_cast(f->fixture_data); f->client = - grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr); + grpc_insecure_channel_create(ffd->localaddr.get(), client_args, nullptr); GPR_ASSERT(f->client); } @@ -73,15 +72,15 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); + GPR_ASSERT( + grpc_server_add_insecure_http2_port(f->server, ffd->localaddr.get())); grpc_server_start(f->server); } void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_http_proxy.cc b/test/core/end2end/fixtures/h2_http_proxy.cc index 9b6a81494e1..18ba0e7f847 100644 --- a/test/core/end2end/fixtures/h2_http_proxy.cc +++ b/test/core/end2end/fixtures/h2_http_proxy.cc @@ -30,26 +30,26 @@ #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/gpr/env.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/end2end/fixtures/http_proxy_fixture.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_fixture_data { - char* server_addr; - grpc_end2end_http_proxy* proxy; -} fullstack_fixture_data; +struct fullstack_fixture_data { + ~fullstack_fixture_data() { grpc_end2end_http_proxy_destroy(proxy); } + grpc_core::UniquePtr server_addr; + grpc_end2end_http_proxy* proxy = nullptr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); - fullstack_fixture_data* ffd = static_cast( - gpr_malloc(sizeof(fullstack_fixture_data))); + fullstack_fixture_data* ffd = grpc_core::New(); const int server_port = grpc_pick_unused_port_or_die(); - gpr_join_host_port(&ffd->server_addr, "localhost", server_port); + grpc_core::JoinHostPort(&ffd->server_addr, "localhost", server_port); /* Passing client_args to proxy_create for the case of checking for proxy auth */ @@ -81,8 +81,8 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, } gpr_setenv("http_proxy", proxy_uri); gpr_free(proxy_uri); - f->client = - grpc_insecure_channel_create(ffd->server_addr, client_args, nullptr); + f->client = grpc_insecure_channel_create(ffd->server_addr.get(), client_args, + nullptr); GPR_ASSERT(f->client); } @@ -95,16 +95,15 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->server_addr)); + GPR_ASSERT( + grpc_server_add_insecure_http2_port(f->server, ffd->server_addr.get())); grpc_server_start(f->server); } void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->server_addr); - grpc_end2end_http_proxy_destroy(ffd->proxy); - gpr_free(ffd); + grpc_core::Delete(ffd); } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_local_ipv4.cc b/test/core/end2end/fixtures/h2_local_ipv4.cc index f6996bf6be3..e27844be2df 100644 --- a/test/core/end2end/fixtures/h2_local_ipv4.cc +++ b/test/core/end2end/fixtures/h2_local_ipv4.cc @@ -20,7 +20,7 @@ #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "test/core/end2end/end2end_tests.h" #include "test/core/end2end/fixtures/local_util.h" #include "test/core/util/port.h" @@ -31,7 +31,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_ipv4( grpc_end2end_test_fixture f = grpc_end2end_local_chttp2_create_fixture_fullstack(); int port = grpc_pick_unused_port_or_die(); - gpr_join_host_port( + grpc_core::JoinHostPort( &static_cast(f.fixture_data) ->localaddr, "127.0.0.1", port); diff --git a/test/core/end2end/fixtures/h2_local_ipv6.cc b/test/core/end2end/fixtures/h2_local_ipv6.cc index e360727ca82..91acaa347f6 100644 --- a/test/core/end2end/fixtures/h2_local_ipv6.cc +++ b/test/core/end2end/fixtures/h2_local_ipv6.cc @@ -20,7 +20,7 @@ #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "test/core/end2end/end2end_tests.h" #include "test/core/end2end/fixtures/local_util.h" #include "test/core/util/port.h" @@ -31,7 +31,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_ipv6( grpc_end2end_test_fixture f = grpc_end2end_local_chttp2_create_fixture_fullstack(); int port = grpc_pick_unused_port_or_die(); - gpr_join_host_port( + grpc_core::JoinHostPort( &static_cast(f.fixture_data) ->localaddr, "[::1]", port); diff --git a/test/core/end2end/fixtures/h2_local_uds.cc b/test/core/end2end/fixtures/h2_local_uds.cc index f1bce213dc2..6c748896760 100644 --- a/test/core/end2end/fixtures/h2_local_uds.cc +++ b/test/core/end2end/fixtures/h2_local_uds.cc @@ -30,10 +30,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_uds( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f = grpc_end2end_local_chttp2_create_fixture_fullstack(); - gpr_asprintf( - &static_cast(f.fixture_data) - ->localaddr, - "unix:/tmp/grpc_fullstack_test.%d.%d", getpid(), unique++); + char* out = nullptr; + gpr_asprintf(&out, "unix:/tmp/grpc_fullstack_test.%d.%d", getpid(), unique++); + static_cast(f.fixture_data) + ->localaddr.reset(out); return f; } diff --git a/test/core/end2end/fixtures/h2_oauth2.cc b/test/core/end2end/fixtures/h2_oauth2.cc index 113a6b11732..513fded4b62 100644 --- a/test/core/end2end/fixtures/h2_oauth2.cc +++ b/test/core/end2end/fixtures/h2_oauth2.cc @@ -25,7 +25,7 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/security/credentials/credentials.h" #include "test/core/end2end/data/ssl_test_data.h" @@ -36,9 +36,9 @@ static const char oauth2_md[] = "Bearer aaslkfjs424535asdf"; static const char* client_identity_property_name = "smurf_name"; static const char* client_identity = "Brainy Smurf"; -typedef struct fullstack_secure_fixture_data { - char* localaddr; -} fullstack_secure_fixture_data; +struct fullstack_secure_fixture_data { + grpc_core::UniquePtr localaddr; +}; static const grpc_metadata* find_metadata(const grpc_metadata* md, size_t md_count, const char* key, @@ -95,16 +95,12 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = - static_cast( - gpr_malloc(sizeof(fullstack_secure_fixture_data))); + grpc_core::New(); memset(&f, 0, sizeof(f)); - - gpr_join_host_port(&ffd->localaddr, "localhost", port); - + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr); - return f; } @@ -113,8 +109,8 @@ static void chttp2_init_client_secure_fullstack( grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - f->client = - grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); + f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), + client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -129,7 +125,7 @@ static void chttp2_init_server_secure_fullstack( } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); @@ -138,8 +134,7 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack( diff --git a/test/core/end2end/fixtures/h2_proxy.cc b/test/core/end2end/fixtures/h2_proxy.cc index e334396ea7c..f0ada89d14d 100644 --- a/test/core/end2end/fixtures/h2_proxy.cc +++ b/test/core/end2end/fixtures/h2_proxy.cc @@ -28,7 +28,6 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/end2end/fixtures/proxy.h" diff --git a/test/core/end2end/fixtures/h2_spiffe.cc b/test/core/end2end/fixtures/h2_spiffe.cc index cdf091bac10..4352ef640cd 100644 --- a/test/core/end2end/fixtures/h2_spiffe.cc +++ b/test/core/end2end/fixtures/h2_spiffe.cc @@ -28,9 +28,9 @@ #include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/env.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/security/credentials/credentials.h" @@ -42,10 +42,15 @@ typedef grpc_core::InlinedVector ThreadList; -typedef struct fullstack_secure_fixture_data { - char* localaddr; +struct fullstack_secure_fixture_data { + ~fullstack_secure_fixture_data() { + for (size_t ind = 0; ind < thd_list.size(); ind++) { + thd_list[ind].Join(); + } + } + grpc_core::UniquePtr localaddr; ThreadList thd_list; -} fullstack_secure_fixture_data; +}; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { @@ -54,7 +59,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( fullstack_secure_fixture_data* ffd = grpc_core::New(); memset(&f, 0, sizeof(f)); - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr); @@ -74,8 +79,8 @@ static void chttp2_init_client_secure_fullstack( grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - f->client = - grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); + f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), + client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -90,7 +95,7 @@ static void chttp2_init_server_secure_fullstack( } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); @@ -99,10 +104,6 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - for (size_t ind = 0; ind < ffd->thd_list.size(); ind++) { - ffd->thd_list[ind].Join(); - } - gpr_free(ffd->localaddr); grpc_core::Delete(ffd); } diff --git a/test/core/end2end/fixtures/h2_ssl.cc b/test/core/end2end/fixtures/h2_ssl.cc index 3fc9bc7f329..cb55bb72061 100644 --- a/test/core/end2end/fixtures/h2_ssl.cc +++ b/test/core/end2end/fixtures/h2_ssl.cc @@ -25,29 +25,28 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_secure_fixture_data { - char* localaddr; -} fullstack_secure_fixture_data; +struct fullstack_secure_fixture_data { + grpc_core::UniquePtr localaddr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = - static_cast( - gpr_malloc(sizeof(fullstack_secure_fixture_data))); + grpc_core::New(); memset(&f, 0, sizeof(f)); - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -69,8 +68,8 @@ static void chttp2_init_client_secure_fullstack( grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - f->client = - grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); + f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), + client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -85,7 +84,7 @@ static void chttp2_init_server_secure_fullstack( } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); @@ -94,8 +93,7 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } static void chttp2_init_client_simple_ssl_secure_fullstack( diff --git a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc index 1d54a431364..2a9591845b9 100644 --- a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc +++ b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc @@ -25,19 +25,19 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_secure_fixture_data { - char* localaddr; - bool server_credential_reloaded; -} fullstack_secure_fixture_data; +struct fullstack_secure_fixture_data { + grpc_core::UniquePtr localaddr; + bool server_credential_reloaded = false; +}; static grpc_ssl_certificate_config_reload_status ssl_server_certificate_config_callback( @@ -64,10 +64,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = - static_cast( - gpr_malloc(sizeof(fullstack_secure_fixture_data))); + grpc_core::New(); memset(&f, 0, sizeof(f)); - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -89,8 +88,8 @@ static void chttp2_init_client_secure_fullstack( grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - f->client = - grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); + f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), + client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -106,7 +105,7 @@ static void chttp2_init_server_secure_fullstack( ffd->server_credential_reloaded = false; f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); @@ -115,8 +114,7 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } static void chttp2_init_client_simple_ssl_secure_fullstack( diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.cc b/test/core/end2end/fixtures/h2_ssl_proxy.cc index d5f695b1575..b16ffa1b8b8 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.cc +++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc @@ -25,7 +25,6 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" diff --git a/test/core/end2end/fixtures/h2_uds.cc b/test/core/end2end/fixtures/h2_uds.cc index f251bbd28c5..2b6c73d39c7 100644 --- a/test/core/end2end/fixtures/h2_uds.cc +++ b/test/core/end2end/fixtures/h2_uds.cc @@ -31,7 +31,6 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc index 6b5513f160e..da2381aa0a0 100644 --- a/test/core/end2end/fixtures/http_proxy_fixture.cc +++ b/test/core/end2end/fixtures/http_proxy_fixture.cc @@ -31,8 +31,8 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/http/parser.h" #include "src/core/lib/iomgr/closure.h" @@ -53,8 +53,7 @@ struct grpc_end2end_http_proxy { grpc_end2end_http_proxy() - : proxy_name(nullptr), - server(nullptr), + : server(nullptr), channel_args(nullptr), mu(nullptr), pollset(nullptr), @@ -62,7 +61,7 @@ struct grpc_end2end_http_proxy { gpr_ref_init(&users, 1); combiner = grpc_combiner_create(); } - char* proxy_name; + grpc_core::UniquePtr proxy_name; grpc_core::Thread thd; grpc_tcp_server* server; grpc_channel_args* channel_args; @@ -532,8 +531,8 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create( grpc_end2end_http_proxy* proxy = grpc_core::New(); // Construct proxy address. const int proxy_port = grpc_pick_unused_port_or_die(); - gpr_join_host_port(&proxy->proxy_name, "localhost", proxy_port); - gpr_log(GPR_INFO, "Proxy address: %s", proxy->proxy_name); + grpc_core::JoinHostPort(&proxy->proxy_name, "localhost", proxy_port); + gpr_log(GPR_INFO, "Proxy address: %s", proxy->proxy_name.get()); // Create TCP server. proxy->channel_args = grpc_channel_args_copy(args); grpc_error* error = @@ -573,7 +572,6 @@ void grpc_end2end_http_proxy_destroy(grpc_end2end_http_proxy* proxy) { proxy->thd.Join(); grpc_tcp_server_shutdown_listeners(proxy->server); grpc_tcp_server_unref(proxy->server); - gpr_free(proxy->proxy_name); grpc_channel_args_destroy(proxy->channel_args); grpc_pollset_shutdown(proxy->pollset, GRPC_CLOSURE_CREATE(destroy_pollset, proxy->pollset, @@ -584,5 +582,5 @@ void grpc_end2end_http_proxy_destroy(grpc_end2end_http_proxy* proxy) { const char* grpc_end2end_http_proxy_get_proxy_name( grpc_end2end_http_proxy* proxy) { - return proxy->proxy_name; + return proxy->proxy_name.get(); } diff --git a/test/core/end2end/fixtures/inproc.cc b/test/core/end2end/fixtures/inproc.cc index dadf3ef455d..70cc6b05479 100644 --- a/test/core/end2end/fixtures/inproc.cc +++ b/test/core/end2end/fixtures/inproc.cc @@ -28,7 +28,6 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/inproc/inproc_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/local_util.cc b/test/core/end2end/fixtures/local_util.cc index 5f0b0300ac0..767f3a28ef8 100644 --- a/test/core/end2end/fixtures/local_util.cc +++ b/test/core/end2end/fixtures/local_util.cc @@ -27,7 +27,6 @@ #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/surface/server.h" @@ -37,8 +36,7 @@ grpc_end2end_test_fixture grpc_end2end_local_chttp2_create_fixture_fullstack() { grpc_end2end_test_fixture f; grpc_end2end_local_fullstack_fixture_data* ffd = - static_cast( - gpr_malloc(sizeof(grpc_end2end_local_fullstack_fixture_data))); + grpc_core::New(); memset(&f, 0, sizeof(f)); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -52,8 +50,8 @@ void grpc_end2end_local_chttp2_init_client_fullstack( grpc_channel_credentials* creds = grpc_local_credentials_create(type); grpc_end2end_local_fullstack_fixture_data* ffd = static_cast(f->fixture_data); - f->client = - grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); + f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), + client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -99,8 +97,8 @@ void grpc_end2end_local_chttp2_init_server_fullstack( nullptr}; grpc_server_credentials_set_auth_metadata_processor(creds, processor); } - GPR_ASSERT( - grpc_server_add_secure_http2_port(f->server, ffd->localaddr, creds)); + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), + creds)); grpc_server_credentials_release(creds); grpc_server_start(f->server); } @@ -109,6 +107,5 @@ void grpc_end2end_local_chttp2_tear_down_fullstack( grpc_end2end_test_fixture* f) { grpc_end2end_local_fullstack_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } diff --git a/test/core/end2end/fixtures/local_util.h b/test/core/end2end/fixtures/local_util.h index f133b4d977e..df204d2fab2 100644 --- a/test/core/end2end/fixtures/local_util.h +++ b/test/core/end2end/fixtures/local_util.h @@ -22,9 +22,9 @@ #include "src/core/lib/surface/channel.h" -typedef struct grpc_end2end_local_fullstack_fixture_data { - char* localaddr; -} grpc_end2end_local_fullstack_fixture_data; +struct grpc_end2end_local_fullstack_fixture_data { + grpc_core::UniquePtr localaddr; +}; /* Utility functions shared by h2_local tests. */ grpc_end2end_test_fixture grpc_end2end_local_chttp2_create_fixture_fullstack(); diff --git a/test/core/end2end/fixtures/proxy.cc b/test/core/end2end/fixtures/proxy.cc index 869b6e846d3..4ae7450b0df 100644 --- a/test/core/end2end/fixtures/proxy.cc +++ b/test/core/end2end/fixtures/proxy.cc @@ -24,16 +24,15 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/thd.h" #include "test/core/util/port.h" struct grpc_end2end_proxy { grpc_end2end_proxy() - : proxy_port(nullptr), - server_port(nullptr), - cq(nullptr), + : cq(nullptr), server(nullptr), client(nullptr), shutdown(false), @@ -42,8 +41,8 @@ struct grpc_end2end_proxy { memset(&new_call_metadata, 0, sizeof(new_call_metadata)); } grpc_core::Thread thd; - char* proxy_port; - char* server_port; + grpc_core::UniquePtr proxy_port; + grpc_core::UniquePtr server_port; grpc_completion_queue* cq; grpc_server* server; grpc_channel* client; @@ -92,15 +91,15 @@ grpc_end2end_proxy* grpc_end2end_proxy_create(const grpc_end2end_proxy_def* def, grpc_end2end_proxy* proxy = grpc_core::New(); - gpr_join_host_port(&proxy->proxy_port, "localhost", proxy_port); - gpr_join_host_port(&proxy->server_port, "localhost", server_port); + grpc_core::JoinHostPort(&proxy->proxy_port, "localhost", proxy_port); + grpc_core::JoinHostPort(&proxy->server_port, "localhost", server_port); - gpr_log(GPR_DEBUG, "PROXY ADDR:%s BACKEND:%s", proxy->proxy_port, - proxy->server_port); + gpr_log(GPR_DEBUG, "PROXY ADDR:%s BACKEND:%s", proxy->proxy_port.get(), + proxy->server_port.get()); proxy->cq = grpc_completion_queue_create_for_next(nullptr); - proxy->server = def->create_server(proxy->proxy_port, server_args); - proxy->client = def->create_client(proxy->server_port, client_args); + proxy->server = def->create_server(proxy->proxy_port.get(), server_args); + proxy->client = def->create_client(proxy->server_port.get(), client_args); grpc_server_register_completion_queue(proxy->server, proxy->cq, nullptr); grpc_server_start(proxy->server); @@ -131,8 +130,6 @@ void grpc_end2end_proxy_destroy(grpc_end2end_proxy* proxy) { grpc_server_shutdown_and_notify(proxy->server, proxy->cq, new_closure(shutdown_complete, proxy)); proxy->thd.Join(); - gpr_free(proxy->proxy_port); - gpr_free(proxy->server_port); grpc_server_destroy(proxy->server); grpc_channel_destroy(proxy->client); grpc_completion_queue_destroy(proxy->cq); @@ -441,9 +438,9 @@ static void thread_main(void* arg) { } const char* grpc_end2end_proxy_get_client_target(grpc_end2end_proxy* proxy) { - return proxy->proxy_port; + return proxy->proxy_port.get(); } const char* grpc_end2end_proxy_get_server_port(grpc_end2end_proxy* proxy) { - return proxy->server_port; + return proxy->server_port.get(); } diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc index e9285778a2d..34a9ef760b5 100644 --- a/test/core/end2end/h2_ssl_cert_test.cc +++ b/test/core/end2end/h2_ssl_cert_test.cc @@ -25,9 +25,9 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/cq_verifier.h" @@ -40,20 +40,19 @@ namespace grpc { namespace testing { -typedef struct fullstack_secure_fixture_data { - char* localaddr; -} fullstack_secure_fixture_data; +struct fullstack_secure_fixture_data { + grpc_core::UniquePtr localaddr; +}; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = - static_cast( - gpr_malloc(sizeof(fullstack_secure_fixture_data))); + grpc_core::New(); memset(&f, 0, sizeof(f)); - gpr_join_host_port(&ffd->localaddr, "localhost", port); + grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -73,8 +72,8 @@ static void chttp2_init_client_secure_fullstack( grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - f->client = - grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr); + f->client = grpc_secure_channel_create(creds, ffd->localaddr.get(), + client_args, nullptr); GPR_ASSERT(f->client != nullptr); grpc_channel_credentials_release(creds); } @@ -89,7 +88,7 @@ static void chttp2_init_server_secure_fullstack( } f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); - GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr.get(), server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); @@ -98,8 +97,7 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - gpr_free(ffd->localaddr); - gpr_free(ffd); + grpc_core::Delete(ffd); } static int fail_server_auth_check(grpc_channel_args* server_args) { diff --git a/test/core/end2end/h2_ssl_session_reuse_test.cc b/test/core/end2end/h2_ssl_session_reuse_test.cc index b2d0a5e1133..6ffc138820e 100644 --- a/test/core/end2end/h2_ssl_session_reuse_test.cc +++ b/test/core/end2end/h2_ssl_session_reuse_test.cc @@ -25,9 +25,9 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/security_connector/ssl_utils.h" #include "test/core/end2end/cq_verifier.h" @@ -215,19 +215,18 @@ void drain_cq(grpc_completion_queue* cq) { TEST(H2SessionReuseTest, SingleReuse) { int port = grpc_pick_unused_port_or_die(); - char* server_addr; - gpr_join_host_port(&server_addr, "localhost", port); + grpc_core::UniquePtr server_addr; + grpc_core::JoinHostPort(&server_addr, "localhost", port); grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); grpc_ssl_session_cache* cache = grpc_ssl_session_cache_create_lru(16); - grpc_server* server = server_create(cq, server_addr); + grpc_server* server = server_create(cq, server_addr.get()); - do_round_trip(cq, server, server_addr, cache, false); - do_round_trip(cq, server, server_addr, cache, true); - do_round_trip(cq, server, server_addr, cache, true); + do_round_trip(cq, server, server_addr.get(), cache, false); + do_round_trip(cq, server, server_addr.get(), cache, true); + do_round_trip(cq, server, server_addr.get(), cache, true); - gpr_free(server_addr); grpc_ssl_session_cache_destroy(cache); GPR_ASSERT(grpc_completion_queue_next( diff --git a/test/core/end2end/invalid_call_argument_test.cc b/test/core/end2end/invalid_call_argument_test.cc index bd28d192984..5f920fad638 100644 --- a/test/core/end2end/invalid_call_argument_test.cc +++ b/test/core/end2end/invalid_call_argument_test.cc @@ -25,7 +25,8 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gprpp/memory.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -54,7 +55,6 @@ static struct test_state g_state; static void prepare_test(int is_client) { int port = grpc_pick_unused_port_or_die(); - char* server_hostport; grpc_op* op; g_state.is_client = is_client; grpc_metadata_array_init(&g_state.initial_metadata_recv); @@ -77,14 +77,13 @@ static void prepare_test(int is_client) { } else { g_state.server = grpc_server_create(nullptr, nullptr); grpc_server_register_completion_queue(g_state.server, g_state.cq, nullptr); - gpr_join_host_port(&server_hostport, "0.0.0.0", port); - grpc_server_add_insecure_http2_port(g_state.server, server_hostport); + grpc_core::UniquePtr server_hostport; + grpc_core::JoinHostPort(&server_hostport, "0.0.0.0", port); + grpc_server_add_insecure_http2_port(g_state.server, server_hostport.get()); grpc_server_start(g_state.server); - gpr_free(server_hostport); - gpr_join_host_port(&server_hostport, "localhost", port); + grpc_core::JoinHostPort(&server_hostport, "localhost", port); g_state.chan = - grpc_insecure_channel_create(server_hostport, nullptr, nullptr); - gpr_free(server_hostport); + grpc_insecure_channel_create(server_hostport.get(), nullptr, nullptr); grpc_slice host = grpc_slice_from_static_string("bar"); g_state.call = grpc_channel_create_call( g_state.chan, nullptr, GRPC_PROPAGATE_DEFAULTS, g_state.cq, diff --git a/test/core/fling/fling_stream_test.cc b/test/core/fling/fling_stream_test.cc index 32bc9896414..474b4fbbc3b 100644 --- a/test/core/fling/fling_stream_test.cc +++ b/test/core/fling/fling_stream_test.cc @@ -22,8 +22,8 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" @@ -46,23 +46,24 @@ int main(int argc, char** argv) { gpr_asprintf(&args[0], "%s/fling_server%s", root, gpr_subprocess_binary_extension()); args[1] = const_cast("--bind"); - gpr_join_host_port(&args[2], "::", port); + grpc_core::UniquePtr joined; + grpc_core::JoinHostPort(&joined, "::", port); + args[2] = joined.get(); args[3] = const_cast("--no-secure"); svr = gpr_subprocess_create(4, (const char**)args); gpr_free(args[0]); - gpr_free(args[2]); /* start the client */ gpr_asprintf(&args[0], "%s/fling_client%s", root, gpr_subprocess_binary_extension()); args[1] = const_cast("--target"); - gpr_join_host_port(&args[2], "127.0.0.1", port); + grpc_core::JoinHostPort(&joined, "127.0.0.1", port); + args[2] = joined.get(); args[3] = const_cast("--scenario=ping-pong-stream"); args[4] = const_cast("--no-secure"); args[5] = nullptr; cli = gpr_subprocess_create(6, (const char**)args); gpr_free(args[0]); - gpr_free(args[2]); /* wait for completion */ printf("waiting for client\n"); diff --git a/test/core/fling/fling_test.cc b/test/core/fling/fling_test.cc index 3587a4acaae..3667d48f010 100644 --- a/test/core/fling/fling_test.cc +++ b/test/core/fling/fling_test.cc @@ -22,8 +22,9 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gprpp/memory.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" @@ -46,23 +47,24 @@ int main(int argc, const char** argv) { gpr_asprintf(&args[0], "%s/fling_server%s", root, gpr_subprocess_binary_extension()); args[1] = const_cast("--bind"); - gpr_join_host_port(&args[2], "::", port); + grpc_core::UniquePtr joined; + grpc_core::JoinHostPort(&joined, "::", port); + args[2] = joined.get(); args[3] = const_cast("--no-secure"); svr = gpr_subprocess_create(4, (const char**)args); gpr_free(args[0]); - gpr_free(args[2]); /* start the client */ gpr_asprintf(&args[0], "%s/fling_client%s", root, gpr_subprocess_binary_extension()); args[1] = const_cast("--target"); - gpr_join_host_port(&args[2], "127.0.0.1", port); + grpc_core::JoinHostPort(&joined, "127.0.0.1", port); + args[2] = joined.get(); args[3] = const_cast("--scenario=ping-pong-request"); args[4] = const_cast("--no-secure"); args[5] = nullptr; cli = gpr_subprocess_create(6, (const char**)args); gpr_free(args[0]); - gpr_free(args[2]); /* wait for completion */ printf("waiting for client\n"); diff --git a/test/core/fling/server.cc b/test/core/fling/server.cc index cf7e2465d9e..241ac71bc7d 100644 --- a/test/core/fling/server.cc +++ b/test/core/fling/server.cc @@ -33,7 +33,7 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/profiling/timers.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/cmdline.h" @@ -172,7 +172,7 @@ static void sigint_handler(int x) { _exit(0); } int main(int argc, char** argv) { grpc_event ev; call_state* s; - char* addr_buf = nullptr; + grpc_core::UniquePtr addr_buf; gpr_cmdline* cl; grpc_completion_queue* shutdown_cq; int shutdown_started = 0; @@ -199,8 +199,8 @@ int main(int argc, char** argv) { gpr_cmdline_destroy(cl); if (addr == nullptr) { - gpr_join_host_port(&addr_buf, "::", grpc_pick_unused_port_or_die()); - addr = addr_buf; + grpc_core::JoinHostPort(&addr_buf, "::", grpc_pick_unused_port_or_die()); + addr = addr_buf.get(); } gpr_log(GPR_INFO, "creating server on: %s", addr); @@ -220,8 +220,8 @@ int main(int argc, char** argv) { grpc_server_register_completion_queue(server, cq, nullptr); grpc_server_start(server); - gpr_free(addr_buf); - addr = addr_buf = nullptr; + addr = nullptr; + addr_buf.reset(); grpc_call_details_init(&call_details); diff --git a/test/core/gpr/BUILD b/test/core/gpr/BUILD index 434d55e0451..c2b2576ff03 100644 --- a/test/core/gpr/BUILD +++ b/test/core/gpr/BUILD @@ -58,16 +58,6 @@ grpc_cc_test( ], ) -grpc_cc_test( - name = "host_port_test", - srcs = ["host_port_test.cc"], - language = "C++", - deps = [ - "//:gpr", - "//test/core/util:grpc_test_util", - ], -) - grpc_cc_test( name = "log_test", srcs = ["log_test.cc"], diff --git a/test/core/gprpp/BUILD b/test/core/gprpp/BUILD index cd3232addfd..5cee96a3ad2 100644 --- a/test/core/gprpp/BUILD +++ b/test/core/gprpp/BUILD @@ -64,6 +64,16 @@ grpc_cc_test( ], ) +grpc_cc_test( + name = "host_port_test", + srcs = ["host_port_test.cc"], + language = "C++", + deps = [ + "//:gpr", + "//test/core/util:grpc_test_util", + ], +) + grpc_cc_test( name = "grpc_core_map_test", srcs = ["map_test.cc"], @@ -156,6 +166,19 @@ grpc_cc_test( ], ) +grpc_cc_test( + name = "string_view_test", + srcs = ["string_view_test.cc"], + external_deps = [ + "gtest", + ], + language = "C++", + deps = [ + "//:gpr_base", + "//test/core/util:grpc_test_util", + ], +) + grpc_cc_test( name = "thd_test", srcs = ["thd_test.cc"], diff --git a/test/core/gpr/host_port_test.cc b/test/core/gprpp/host_port_test.cc similarity index 86% rename from test/core/gpr/host_port_test.cc rename to test/core/gprpp/host_port_test.cc index b01bbf4b695..3474e6dc494 100644 --- a/test/core/gpr/host_port_test.cc +++ b/test/core/gprpp/host_port_test.cc @@ -21,18 +21,17 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "test/core/util/test_config.h" static void join_host_port_expect(const char* host, int port, const char* expected) { - char* buf; + grpc_core::UniquePtr buf; int len; - len = gpr_join_host_port(&buf, host, port); + len = grpc_core::JoinHostPort(&buf, host, port); GPR_ASSERT(len >= 0); - GPR_ASSERT(strlen(expected) == (size_t)len); - GPR_ASSERT(strcmp(expected, buf) == 0); - gpr_free(buf); + GPR_ASSERT(strlen(expected) == static_cast(len)); + GPR_ASSERT(strcmp(expected, buf.get()) == 0); } static void test_join_host_port(void) { diff --git a/test/core/gprpp/string_view_test.cc b/test/core/gprpp/string_view_test.cc new file mode 100644 index 00000000000..1c8adb1db14 --- /dev/null +++ b/test/core/gprpp/string_view_test.cc @@ -0,0 +1,163 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/gprpp/string_view.h" + +#include +#include "src/core/lib/gprpp/memory.h" +#include "test/core/util/test_config.h" + +namespace grpc_core { +namespace testing { + +TEST(StringViewTest, Empty) { + grpc_core::StringView empty; + EXPECT_TRUE(empty.empty()); + EXPECT_EQ(empty.size(), 0lu); + + grpc_core::StringView empty_buf(""); + EXPECT_TRUE(empty_buf.empty()); + EXPECT_EQ(empty_buf.size(), 0lu); + + grpc_core::StringView empty_trimmed("foo", 0); + EXPECT_TRUE(empty_trimmed.empty()); + EXPECT_EQ(empty_trimmed.size(), 0lu); + + grpc_core::StringView empty_slice(grpc_empty_slice()); + EXPECT_TRUE(empty_slice.empty()); + EXPECT_EQ(empty_slice.size(), 0lu); +} + +TEST(StringViewTest, Size) { + constexpr char kStr[] = "foo"; + grpc_core::StringView str1(kStr); + EXPECT_EQ(str1.size(), strlen(kStr)); + grpc_core::StringView str2(kStr, 2); + EXPECT_EQ(str2.size(), 2lu); +} + +TEST(StringViewTest, Data) { + constexpr char kStr[] = "foo-bar"; + grpc_core::StringView str(kStr); + EXPECT_EQ(str.size(), strlen(kStr)); + for (size_t i = 0; i < strlen(kStr); ++i) { + EXPECT_EQ(str[i], kStr[i]); + } +} + +TEST(StringViewTest, Slice) { + constexpr char kStr[] = "foo"; + grpc_core::StringView slice(grpc_slice_from_static_string(kStr)); + EXPECT_EQ(slice.size(), strlen(kStr)); +} + +TEST(StringViewTest, Dup) { + constexpr char kStr[] = "foo"; + grpc_core::StringView slice(grpc_slice_from_static_string(kStr)); + grpc_core::UniquePtr dup = slice.dup(); + EXPECT_EQ(0, strcmp(kStr, dup.get())); + EXPECT_EQ(slice.size(), strlen(kStr)); +} + +TEST(StringViewTest, Eq) { + constexpr char kStr1[] = "foo"; + constexpr char kStr2[] = "bar"; + grpc_core::StringView str1(kStr1); + EXPECT_EQ(kStr1, str1); + EXPECT_EQ(str1, kStr1); + grpc_core::StringView slice1(grpc_slice_from_static_string(kStr1)); + EXPECT_EQ(slice1, str1); + EXPECT_EQ(str1, slice1); + EXPECT_NE(slice1, kStr2); + EXPECT_NE(kStr2, slice1); + grpc_core::StringView slice2(grpc_slice_from_static_string(kStr2)); + EXPECT_NE(slice2, str1); + EXPECT_NE(str1, slice2); +} + +TEST(StringViewTest, Cmp) { + constexpr char kStr1[] = "abc"; + constexpr char kStr2[] = "abd"; + constexpr char kStr3[] = "abcd"; + grpc_core::StringView str1(kStr1); + grpc_core::StringView str2(kStr2); + grpc_core::StringView str3(kStr3); + EXPECT_EQ(str1.cmp(str1), 0); + EXPECT_LT(str1.cmp(str2), 0); + EXPECT_LT(str1.cmp(str3), 0); + EXPECT_EQ(str2.cmp(str2), 0); + EXPECT_GT(str2.cmp(str1), 0); + EXPECT_GT(str2.cmp(str3), 0); + EXPECT_EQ(str3.cmp(str3), 0); + EXPECT_GT(str3.cmp(str1), 0); + EXPECT_LT(str3.cmp(str2), 0); +} + +TEST(StringViewTest, RemovePrefix) { + constexpr char kStr[] = "abcd"; + grpc_core::StringView str(kStr); + str.remove_prefix(1); + EXPECT_EQ("bcd", str); + str.remove_prefix(2); + EXPECT_EQ("d", str); + str.remove_prefix(1); + EXPECT_EQ("", str); +} + +TEST(StringViewTest, RemoveSuffix) { + constexpr char kStr[] = "abcd"; + grpc_core::StringView str(kStr); + str.remove_suffix(1); + EXPECT_EQ("abc", str); + str.remove_suffix(2); + EXPECT_EQ("a", str); + str.remove_suffix(1); + EXPECT_EQ("", str); +} + +TEST(StringViewTest, Substring) { + constexpr char kStr[] = "abcd"; + grpc_core::StringView str(kStr); + EXPECT_EQ("bcd", str.substr(1)); + EXPECT_EQ("bc", str.substr(1, 2)); +} + +TEST(StringViewTest, Find) { + // Passing StringView::npos directly to GTEST macros result in link errors. + // Store the value in a local variable and use it in the test. + const size_t npos = grpc_core::StringView::npos; + constexpr char kStr[] = "abacad"; + grpc_core::StringView str(kStr); + EXPECT_EQ(0ul, str.find('a')); + EXPECT_EQ(2ul, str.find('a', 1)); + EXPECT_EQ(4ul, str.find('a', 3)); + EXPECT_EQ(1ul, str.find('b')); + EXPECT_EQ(npos, str.find('b', 2)); + EXPECT_EQ(npos, str.find('z')); +} + +} // namespace testing +} // namespace grpc_core + +int main(int argc, char** argv) { + grpc::testing::TestEnvironment env(argc, argv); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/core/memory_usage/memory_usage_test.cc b/test/core/memory_usage/memory_usage_test.cc index 5c35b4e1d36..5df8af5658b 100644 --- a/test/core/memory_usage/memory_usage_test.cc +++ b/test/core/memory_usage/memory_usage_test.cc @@ -22,8 +22,8 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" @@ -46,22 +46,23 @@ int main(int argc, char** argv) { gpr_asprintf(&args[0], "%s/memory_usage_server%s", root, gpr_subprocess_binary_extension()); args[1] = const_cast("--bind"); - gpr_join_host_port(&args[2], "::", port); + grpc_core::UniquePtr joined; + grpc_core::JoinHostPort(&joined, "::", port); + args[2] = joined.get(); args[3] = const_cast("--no-secure"); svr = gpr_subprocess_create(4, (const char**)args); gpr_free(args[0]); - gpr_free(args[2]); /* start the client */ gpr_asprintf(&args[0], "%s/memory_usage_client%s", root, gpr_subprocess_binary_extension()); args[1] = const_cast("--target"); - gpr_join_host_port(&args[2], "127.0.0.1", port); + grpc_core::JoinHostPort(&joined, "127.0.0.1", port); + args[2] = joined.get(); args[3] = const_cast("--warmup=1000"); args[4] = const_cast("--benchmark=9000"); cli = gpr_subprocess_create(5, (const char**)args); gpr_free(args[0]); - gpr_free(args[2]); /* wait for completion */ printf("waiting for client\n"); diff --git a/test/core/memory_usage/server.cc b/test/core/memory_usage/server.cc index 6fb14fa31a0..ecdf17925ec 100644 --- a/test/core/memory_usage/server.cc +++ b/test/core/memory_usage/server.cc @@ -33,7 +33,7 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/cmdline.h" #include "test/core/util/memory_counters.h" @@ -149,7 +149,7 @@ static void sigint_handler(int x) { _exit(0); } int main(int argc, char** argv) { grpc_memory_counters_init(); grpc_event ev; - char* addr_buf = nullptr; + grpc_core::UniquePtr addr_buf; gpr_cmdline* cl; grpc_completion_queue* shutdown_cq; int shutdown_started = 0; @@ -174,8 +174,8 @@ int main(int argc, char** argv) { gpr_cmdline_destroy(cl); if (addr == nullptr) { - gpr_join_host_port(&addr_buf, "::", grpc_pick_unused_port_or_die()); - addr = addr_buf; + grpc_core::JoinHostPort(&addr_buf, "::", grpc_pick_unused_port_or_die()); + addr = addr_buf.get(); } gpr_log(GPR_INFO, "creating server on: %s", addr); @@ -202,8 +202,8 @@ int main(int argc, char** argv) { struct grpc_memory_counters after_server_create = grpc_memory_counters_snapshot(); - gpr_free(addr_buf); - addr = addr_buf = nullptr; + addr = nullptr; + addr_buf.reset(); // initialize call instances for (int i = 0; i < static_cast(sizeof(calls) / sizeof(fling_call)); diff --git a/test/core/surface/num_external_connectivity_watchers_test.cc b/test/core/surface/num_external_connectivity_watchers_test.cc index 454cbd5747e..2c9b0d9aaed 100644 --- a/test/core/surface/num_external_connectivity_watchers_test.cc +++ b/test/core/surface/num_external_connectivity_watchers_test.cc @@ -22,7 +22,8 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/end2end/data/ssl_test_data.h" @@ -66,13 +67,11 @@ static void channel_idle_poll_for_timeout(grpc_channel* channel, static void run_timeouts_test(const test_fixture* fixture) { gpr_log(GPR_INFO, "TEST: %s", fixture->name); - char* addr; - + grpc_core::UniquePtr addr; grpc_init(); + grpc_core::JoinHostPort(&addr, "localhost", grpc_pick_unused_port_or_die()); - gpr_join_host_port(&addr, "localhost", grpc_pick_unused_port_or_die()); - - grpc_channel* channel = fixture->create_channel(addr); + grpc_channel* channel = fixture->create_channel(addr.get()); grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); /* start 1 watcher and then let it time out */ @@ -111,7 +110,6 @@ static void run_timeouts_test(const test_fixture* fixture) { grpc_completion_queue_destroy(cq); grpc_shutdown(); - gpr_free(addr); } /* An edge scenario; sets channel state to explicitly, and outside @@ -120,13 +118,11 @@ static void run_channel_shutdown_before_timeout_test( const test_fixture* fixture) { gpr_log(GPR_INFO, "TEST: %s", fixture->name); - char* addr; - + grpc_core::UniquePtr addr; grpc_init(); + grpc_core::JoinHostPort(&addr, "localhost", grpc_pick_unused_port_or_die()); - gpr_join_host_port(&addr, "localhost", grpc_pick_unused_port_or_die()); - - grpc_channel* channel = fixture->create_channel(addr); + grpc_channel* channel = fixture->create_channel(addr.get()); grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); /* start 1 watcher and then shut down the channel before the timer goes off */ @@ -154,7 +150,6 @@ static void run_channel_shutdown_before_timeout_test( grpc_completion_queue_destroy(cq); grpc_shutdown(); - gpr_free(addr); } static grpc_channel* insecure_test_create_channel(const char* addr) { diff --git a/test/core/surface/sequential_connectivity_test.cc b/test/core/surface/sequential_connectivity_test.cc index 3f9a7baf98b..46c4a24f5ed 100644 --- a/test/core/surface/sequential_connectivity_test.cc +++ b/test/core/surface/sequential_connectivity_test.cc @@ -22,7 +22,7 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/end2end/data/ssl_test_data.h" @@ -56,11 +56,11 @@ static void run_test(const test_fixture* fixture) { grpc_init(); - char* addr; - gpr_join_host_port(&addr, "localhost", grpc_pick_unused_port_or_die()); + grpc_core::UniquePtr addr; + grpc_core::JoinHostPort(&addr, "localhost", grpc_pick_unused_port_or_die()); grpc_server* server = grpc_server_create(nullptr, nullptr); - fixture->add_server_port(server, addr); + fixture->add_server_port(server, addr.get()); grpc_completion_queue* server_cq = grpc_completion_queue_create_for_next(nullptr); grpc_server_register_completion_queue(server, server_cq, nullptr); @@ -73,7 +73,7 @@ static void run_test(const test_fixture* fixture) { grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); grpc_channel* channels[NUM_CONNECTIONS]; for (size_t i = 0; i < NUM_CONNECTIONS; i++) { - channels[i] = fixture->create_channel(addr); + channels[i] = fixture->create_channel(addr.get()); gpr_timespec connect_deadline = grpc_timeout_seconds_to_deadline(30); grpc_connectivity_state state; @@ -116,7 +116,6 @@ static void run_test(const test_fixture* fixture) { grpc_completion_queue_destroy(cq); grpc_shutdown(); - gpr_free(addr); } static void insecure_test_add_port(grpc_server* server, const char* addr) { diff --git a/test/core/surface/server_chttp2_test.cc b/test/core/surface/server_chttp2_test.cc index ffb7f14f987..a88362e13b0 100644 --- a/test/core/surface/server_chttp2_test.cc +++ b/test/core/surface/server_chttp2_test.cc @@ -22,7 +22,7 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "src/core/tsi/fake_transport_security.h" @@ -47,17 +47,17 @@ void test_add_same_port_twice() { grpc_channel_args args = {1, &a}; int port = grpc_pick_unused_port_or_die(); - char* addr = nullptr; + grpc_core::UniquePtr addr; grpc_completion_queue* cq = grpc_completion_queue_create_for_pluck(nullptr); grpc_server* server = grpc_server_create(&args, nullptr); grpc_server_credentials* fake_creds = grpc_fake_transport_security_server_credentials_create(); - gpr_join_host_port(&addr, "localhost", port); - GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, fake_creds)); - GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, fake_creds) == 0); + grpc_core::JoinHostPort(&addr, "localhost", port); + GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr.get(), fake_creds)); + GPR_ASSERT( + grpc_server_add_secure_http2_port(server, addr.get(), fake_creds) == 0); grpc_server_credentials_release(fake_creds); - gpr_free(addr); grpc_server_shutdown_and_notify(server, cq, nullptr); grpc_completion_queue_pluck(cq, nullptr, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr); diff --git a/test/core/surface/server_test.cc b/test/core/surface/server_test.cc index 2fc166546b0..185a6757743 100644 --- a/test/core/surface/server_test.cc +++ b/test/core/surface/server_test.cc @@ -22,7 +22,7 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "test/core/util/port.h" @@ -106,18 +106,19 @@ void test_bind_server_twice(void) { void test_bind_server_to_addr(const char* host, bool secure) { int port = grpc_pick_unused_port_or_die(); - char* addr; - gpr_join_host_port(&addr, host, port); - gpr_log(GPR_INFO, "Test bind to %s", addr); + grpc_core::UniquePtr addr; + grpc_core::JoinHostPort(&addr, host, port); + gpr_log(GPR_INFO, "Test bind to %s", addr.get()); grpc_server* server = grpc_server_create(nullptr, nullptr); if (secure) { grpc_server_credentials* fake_creds = grpc_fake_transport_security_server_credentials_create(); - GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, fake_creds)); + GPR_ASSERT( + grpc_server_add_secure_http2_port(server, addr.get(), fake_creds)); grpc_server_credentials_release(fake_creds); } else { - GPR_ASSERT(grpc_server_add_insecure_http2_port(server, addr)); + GPR_ASSERT(grpc_server_add_insecure_http2_port(server, addr.get())); } grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); grpc_server_register_completion_queue(server, cq, nullptr); @@ -126,7 +127,6 @@ void test_bind_server_to_addr(const char* host, bool secure) { grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr); grpc_server_destroy(server); grpc_completion_queue_destroy(cq); - gpr_free(addr); } static int external_dns_works(const char* host) { diff --git a/test/core/util/reconnect_server.cc b/test/core/util/reconnect_server.cc index 144ad64f095..03c088db772 100644 --- a/test/core/util/reconnect_server.cc +++ b/test/core/util/reconnect_server.cc @@ -25,7 +25,6 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/tcp_server.h" diff --git a/test/core/util/test_tcp_server.cc b/test/core/util/test_tcp_server.cc index 170584df2b9..d7803e53555 100644 --- a/test/core/util/test_tcp_server.cc +++ b/test/core/util/test_tcp_server.cc @@ -28,7 +28,6 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/tcp_server.h" diff --git a/test/cpp/interop/interop_test.cc b/test/cpp/interop/interop_test.cc index 8e45b877212..e0bacb3cfd6 100644 --- a/test/cpp/interop/interop_test.cc +++ b/test/cpp/interop/interop_test.cc @@ -32,7 +32,6 @@ #include "test/core/util/port.h" #include "test/cpp/util/test_config.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/socket_utils_posix.h" diff --git a/test/cpp/naming/address_sorting_test.cc b/test/cpp/naming/address_sorting_test.cc index affc75bc634..a3d9936606d 100644 --- a/test/cpp/naming/address_sorting_test.cc +++ b/test/cpp/naming/address_sorting_test.cc @@ -40,8 +40,8 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr.h" @@ -64,30 +64,28 @@ struct TestAddress { }; grpc_resolved_address TestAddressToGrpcResolvedAddress(TestAddress test_addr) { - char* host; - char* port; + grpc_core::UniquePtr host; + grpc_core::UniquePtr port; grpc_resolved_address resolved_addr; - gpr_split_host_port(test_addr.dest_addr.c_str(), &host, &port); + grpc_core::SplitHostPort(test_addr.dest_addr.c_str(), &host, &port); if (test_addr.family == AF_INET) { sockaddr_in in_dest; memset(&in_dest, 0, sizeof(sockaddr_in)); - in_dest.sin_port = htons(atoi(port)); + in_dest.sin_port = htons(atoi(port.get())); in_dest.sin_family = AF_INET; - GPR_ASSERT(inet_pton(AF_INET, host, &in_dest.sin_addr) == 1); + GPR_ASSERT(inet_pton(AF_INET, host.get(), &in_dest.sin_addr) == 1); memcpy(&resolved_addr.addr, &in_dest, sizeof(sockaddr_in)); resolved_addr.len = sizeof(sockaddr_in); } else { GPR_ASSERT(test_addr.family == AF_INET6); sockaddr_in6 in6_dest; memset(&in6_dest, 0, sizeof(sockaddr_in6)); - in6_dest.sin6_port = htons(atoi(port)); + in6_dest.sin6_port = htons(atoi(port.get())); in6_dest.sin6_family = AF_INET6; - GPR_ASSERT(inet_pton(AF_INET6, host, &in6_dest.sin6_addr) == 1); + GPR_ASSERT(inet_pton(AF_INET6, host.get(), &in6_dest.sin6_addr) == 1); memcpy(&resolved_addr.addr, &in6_dest, sizeof(sockaddr_in6)); resolved_addr.len = sizeof(sockaddr_in6); } - gpr_free(host); - gpr_free(port); return resolved_addr; } diff --git a/test/cpp/naming/cancel_ares_query_test.cc b/test/cpp/naming/cancel_ares_query_test.cc index 667011ae291..2d1a13d25a6 100644 --- a/test/cpp/naming/cancel_ares_query_test.cc +++ b/test/cpp/naming/cancel_ares_query_test.cc @@ -33,7 +33,6 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/stats.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/thd.h" diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index 6cea8143907..67ed307d2d7 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -46,8 +46,8 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/executor.h" @@ -506,10 +506,10 @@ int g_fake_non_responsive_dns_server_port = -1; void InjectBrokenNameServerList(ares_channel channel) { struct ares_addr_port_node dns_server_addrs[2]; memset(dns_server_addrs, 0, sizeof(dns_server_addrs)); - char* unused_host; - char* local_dns_server_port; - GPR_ASSERT(gpr_split_host_port(FLAGS_local_dns_server_address.c_str(), - &unused_host, &local_dns_server_port)); + grpc_core::UniquePtr unused_host; + grpc_core::UniquePtr local_dns_server_port; + GPR_ASSERT(grpc_core::SplitHostPort(FLAGS_local_dns_server_address.c_str(), + &unused_host, &local_dns_server_port)); gpr_log(GPR_DEBUG, "Injecting broken nameserver list. Bad server address:|[::1]:%d|. " "Good server address:%s", @@ -528,12 +528,10 @@ void InjectBrokenNameServerList(ares_channel channel) { dns_server_addrs[1].family = AF_INET; ((char*)&dns_server_addrs[1].addr.addr4)[0] = 0x7f; ((char*)&dns_server_addrs[1].addr.addr4)[3] = 0x1; - dns_server_addrs[1].tcp_port = atoi(local_dns_server_port); - dns_server_addrs[1].udp_port = atoi(local_dns_server_port); + dns_server_addrs[1].tcp_port = atoi(local_dns_server_port.get()); + dns_server_addrs[1].udp_port = atoi(local_dns_server_port.get()); dns_server_addrs[1].next = nullptr; GPR_ASSERT(ares_set_servers_ports(channel, dns_server_addrs) == ARES_SUCCESS); - gpr_free(local_dns_server_port); - gpr_free(unused_host); } void StartResolvingLocked(void* arg, grpc_error* unused) { diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc index 668d9abf5ca..5fc14ddbabd 100644 --- a/test/cpp/qps/client_sync.cc +++ b/test/cpp/qps/client_sync.cc @@ -33,7 +33,6 @@ #include #include -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/profiling/timers.h" #include "src/proto/grpc/testing/benchmark_service.grpc.pb.h" #include "test/cpp/qps/client.h" diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 7d4d5d99446..cfc3c8e9a06 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -31,7 +31,7 @@ #include #include "src/core/lib/gpr/env.h" -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/profiling/timers.h" #include "src/proto/grpc/testing/worker_service.grpc.pb.h" #include "test/core/util/port.h" @@ -52,15 +52,10 @@ using std::vector; namespace grpc { namespace testing { static std::string get_host(const std::string& worker) { - char* host; - char* port; - - gpr_split_host_port(worker.c_str(), &host, &port); - const string s(host); - - gpr_free(host); - gpr_free(port); - return s; + grpc_core::StringView host; + grpc_core::StringView port; + grpc_core::SplitHostPort(worker.c_str(), &host, &port); + return std::string(host.data(), host.size()); } static deque get_workers(const string& env_name) { @@ -324,11 +319,10 @@ std::unique_ptr RunScenario( client_config.add_server_targets(cli_target); } else { std::string host; - char* cli_target; + grpc_core::UniquePtr cli_target; host = get_host(workers[i]); - gpr_join_host_port(&cli_target, host.c_str(), init_status.port()); - client_config.add_server_targets(cli_target); - gpr_free(cli_target); + grpc_core::JoinHostPort(&cli_target, host.c_str(), init_status.port()); + client_config.add_server_targets(cli_target.get()); } } diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc index 23fe72316a1..bdf94d86c10 100644 --- a/test/cpp/qps/qps_worker.cc +++ b/test/cpp/qps/qps_worker.cc @@ -34,7 +34,7 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/proto/grpc/testing/worker_service.grpc.pb.h" #include "test/core/util/grpc_profiler.h" #include "test/core/util/histogram.h" @@ -279,12 +279,11 @@ QpsWorker::QpsWorker(int driver_port, int server_port, std::unique_ptr builder = CreateQpsServerBuilder(); if (driver_port >= 0) { - char* server_address = nullptr; - gpr_join_host_port(&server_address, "::", driver_port); + grpc_core::UniquePtr server_address; + grpc_core::JoinHostPort(&server_address, "::", driver_port); builder->AddListeningPort( - server_address, + server_address.get(), GetCredentialsProvider()->GetServerCredentials(credential_type)); - gpr_free(server_address); } builder->RegisterService(impl_.get()); diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index a5f8347c269..e9978212f95 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -34,7 +34,7 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/surface/completion_queue.h" #include "src/proto/grpc/testing/benchmark_service.grpc.pb.h" #include "test/core/util/test_config.h" @@ -80,11 +80,10 @@ class AsyncQpsServerTest final : public grpc::testing::Server { auto port_num = port(); // Negative port number means inproc server, so no listen port needed if (port_num >= 0) { - char* server_address = nullptr; - gpr_join_host_port(&server_address, "::", port_num); - builder->AddListeningPort(server_address, + grpc_core::UniquePtr server_address; + grpc_core::JoinHostPort(&server_address, "::", port_num); + builder->AddListeningPort(server_address.get(), Server::CreateServerCredentials(config)); - gpr_free(server_address); } register_service(builder.get(), &async_service_); diff --git a/test/cpp/qps/server_callback.cc b/test/cpp/qps/server_callback.cc index 4a346dd0178..1829905cb49 100644 --- a/test/cpp/qps/server_callback.cc +++ b/test/cpp/qps/server_callback.cc @@ -21,7 +21,7 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/proto/grpc/testing/benchmark_service.grpc.pb.h" #include "test/cpp/qps/qps_server_builder.h" #include "test/cpp/qps/server.h" @@ -103,11 +103,10 @@ class CallbackServer final : public grpc::testing::Server { auto port_num = port(); // Negative port number means inproc server, so no listen port needed if (port_num >= 0) { - char* server_address = nullptr; - gpr_join_host_port(&server_address, "::", port_num); - builder->AddListeningPort(server_address, + grpc_core::UniquePtr server_address; + grpc_core::JoinHostPort(&server_address, "::", port_num); + builder->AddListeningPort(server_address.get(), Server::CreateServerCredentials(config)); - gpr_free(server_address); } ApplyConfigToBuilder(config, builder.get()); diff --git a/test/cpp/qps/server_sync.cc b/test/cpp/qps/server_sync.cc index 2e63f5ec867..7b76e9c206a 100644 --- a/test/cpp/qps/server_sync.cc +++ b/test/cpp/qps/server_sync.cc @@ -25,7 +25,7 @@ #include #include -#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/proto/grpc/testing/benchmark_service.grpc.pb.h" #include "test/cpp/qps/qps_server_builder.h" #include "test/cpp/qps/server.h" @@ -160,11 +160,10 @@ class SynchronousServer final : public grpc::testing::Server { auto port_num = port(); // Negative port number means inproc server, so no listen port needed if (port_num >= 0) { - char* server_address = nullptr; - gpr_join_host_port(&server_address, "::", port_num); - builder->AddListeningPort(server_address, + grpc_core::UniquePtr server_address; + grpc_core::JoinHostPort(&server_address, "::", port_num); + builder->AddListeningPort(server_address.get(), Server::CreateServerCredentials(config)); - gpr_free(server_address); } ApplyConfigToBuilder(config, builder.get()); diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index f1dd2e54e1d..69ff7eb6098 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1077,7 +1077,6 @@ src/core/lib/debug/trace.h \ src/core/lib/gpr/alloc.h \ src/core/lib/gpr/arena.h \ src/core/lib/gpr/env.h \ -src/core/lib/gpr/host_port.h \ src/core/lib/gpr/mpscq.h \ src/core/lib/gpr/murmur_hash.h \ src/core/lib/gpr/spinlock.h \ @@ -1099,6 +1098,7 @@ src/core/lib/gprpp/global_config.h \ src/core/lib/gprpp/global_config_custom.h \ src/core/lib/gprpp/global_config_env.h \ src/core/lib/gprpp/global_config_generic.h \ +src/core/lib/gprpp/host_port.h \ src/core/lib/gprpp/inlined_vector.h \ src/core/lib/gprpp/manual_constructor.h \ src/core/lib/gprpp/map.h \ @@ -1108,6 +1108,7 @@ src/core/lib/gprpp/orphanable.h \ src/core/lib/gprpp/pair.h \ src/core/lib/gprpp/ref_counted.h \ src/core/lib/gprpp/ref_counted_ptr.h \ +src/core/lib/gprpp/string_view.h \ src/core/lib/gprpp/sync.h \ src/core/lib/gprpp/thd.h \ src/core/lib/http/format_request.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 7768bca30f5..1dae91d2eaf 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1125,8 +1125,6 @@ src/core/lib/gpr/env.h \ src/core/lib/gpr/env_linux.cc \ src/core/lib/gpr/env_posix.cc \ src/core/lib/gpr/env_windows.cc \ -src/core/lib/gpr/host_port.cc \ -src/core/lib/gpr/host_port.h \ src/core/lib/gpr/log.cc \ src/core/lib/gpr/log_android.cc \ src/core/lib/gpr/log_linux.cc \ @@ -1175,6 +1173,8 @@ src/core/lib/gprpp/global_config_custom.h \ src/core/lib/gprpp/global_config_env.cc \ src/core/lib/gprpp/global_config_env.h \ src/core/lib/gprpp/global_config_generic.h \ +src/core/lib/gprpp/host_port.cc \ +src/core/lib/gprpp/host_port.h \ src/core/lib/gprpp/inlined_vector.h \ src/core/lib/gprpp/manual_constructor.h \ src/core/lib/gprpp/map.h \ @@ -1184,6 +1184,7 @@ src/core/lib/gprpp/orphanable.h \ src/core/lib/gprpp/pair.h \ src/core/lib/gprpp/ref_counted.h \ src/core/lib/gprpp/ref_counted_ptr.h \ +src/core/lib/gprpp/string_view.h \ src/core/lib/gprpp/sync.h \ src/core/lib/gprpp/thd.h \ src/core/lib/gprpp/thd_posix.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index b157439a3f4..6b746decca9 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -683,7 +683,7 @@ "language": "c", "name": "gpr_host_port_test", "src": [ - "test/core/gpr/host_port_test.cc" + "test/core/gprpp/host_port_test.cc" ], "third_party": false, "type": "target" @@ -5058,6 +5058,24 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "grpc", + "grpc++", + "grpc++_test", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "string_view_test", + "src": [ + "test/core/gprpp/string_view_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", @@ -8189,7 +8207,6 @@ "src/core/lib/gpr/env_linux.cc", "src/core/lib/gpr/env_posix.cc", "src/core/lib/gpr/env_windows.cc", - "src/core/lib/gpr/host_port.cc", "src/core/lib/gpr/log.cc", "src/core/lib/gpr/log_android.cc", "src/core/lib/gpr/log_linux.cc", @@ -8216,6 +8233,7 @@ "src/core/lib/gprpp/arena.cc", "src/core/lib/gprpp/fork.cc", "src/core/lib/gprpp/global_config_env.cc", + "src/core/lib/gprpp/host_port.cc", "src/core/lib/gprpp/thd_posix.cc", "src/core/lib/gprpp/thd_windows.cc", "src/core/lib/profiling/basic_timers.cc", @@ -8249,7 +8267,6 @@ "src/core/lib/gpr/alloc.h", "src/core/lib/gpr/arena.h", "src/core/lib/gpr/env.h", - "src/core/lib/gpr/host_port.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", "src/core/lib/gpr/spinlock.h", @@ -8270,6 +8287,7 @@ "src/core/lib/gprpp/global_config_custom.h", "src/core/lib/gprpp/global_config_env.h", "src/core/lib/gprpp/global_config_generic.h", + "src/core/lib/gprpp/host_port.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", @@ -8302,7 +8320,6 @@ "src/core/lib/gpr/alloc.h", "src/core/lib/gpr/arena.h", "src/core/lib/gpr/env.h", - "src/core/lib/gpr/host_port.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", "src/core/lib/gpr/spinlock.h", @@ -8323,6 +8340,7 @@ "src/core/lib/gprpp/global_config_custom.h", "src/core/lib/gprpp/global_config_env.h", "src/core/lib/gprpp/global_config_generic.h", + "src/core/lib/gprpp/host_port.h", "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", @@ -8623,6 +8641,7 @@ "src/core/lib/gprpp/orphanable.h", "src/core/lib/gprpp/ref_counted.h", "src/core/lib/gprpp/ref_counted_ptr.h", + "src/core/lib/gprpp/string_view.h", "src/core/lib/http/format_request.h", "src/core/lib/http/httpcli.h", "src/core/lib/http/parser.h", @@ -8780,6 +8799,7 @@ "src/core/lib/gprpp/orphanable.h", "src/core/lib/gprpp/ref_counted.h", "src/core/lib/gprpp/ref_counted_ptr.h", + "src/core/lib/gprpp/string_view.h", "src/core/lib/http/format_request.h", "src/core/lib/http/httpcli.h", "src/core/lib/http/parser.h", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 625d3bd295f..9e835c22bb6 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -5730,6 +5730,30 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "string_view_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": true + }, { "args": [], "benchmark": false, From c9ec1a64edd64b9a56b991d1d43544c0829fe746 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Thu, 27 Jun 2019 11:20:30 -0400 Subject: [PATCH 0741/1555] Fix SplitHostPort for empty strings. Add unittests to catch such errors in the future. --- src/core/lib/gprpp/host_port.cc | 8 +++++-- test/core/gprpp/host_port_test.cc | 36 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/core/lib/gprpp/host_port.cc b/src/core/lib/gprpp/host_port.cc index f3f8a73602a..82a3ab1add0 100644 --- a/src/core/lib/gprpp/host_port.cc +++ b/src/core/lib/gprpp/host_port.cc @@ -87,11 +87,15 @@ bool SplitHostPort(StringView name, StringView* host, StringView* port) { bool SplitHostPort(StringView name, UniquePtr* host, UniquePtr* port) { + GPR_DEBUG_ASSERT(host != nullptr && *host == nullptr); + GPR_DEBUG_ASSERT(port != nullptr && *port == nullptr); StringView host_view; StringView port_view; const bool ret = SplitHostPort(name, &host_view, &port_view); - host->reset(host_view.empty() ? nullptr : host_view.dup().release()); - port->reset(port_view.empty() ? nullptr : port_view.dup().release()); + if (ret) { + *host = host_view.dup(); + *port = port_view.dup(); + } return ret; } } // namespace grpc_core diff --git a/test/core/gprpp/host_port_test.cc b/test/core/gprpp/host_port_test.cc index 3474e6dc494..33ea4781491 100644 --- a/test/core/gprpp/host_port_test.cc +++ b/test/core/gprpp/host_port_test.cc @@ -48,11 +48,47 @@ static void test_join_host_port_garbage(void) { join_host_port_expect("::]", 107, "[::]]:107"); } +static void split_host_port_expect(const char* name, const char* host, + const char* port, bool ret) { + grpc_core::UniquePtr actual_host; + grpc_core::UniquePtr actual_port; + const bool actual_ret = + grpc_core::SplitHostPort(name, &actual_host, &actual_port); + GPR_ASSERT(actual_ret == ret); + if (host == nullptr) { + GPR_ASSERT(actual_host == nullptr); + } else { + GPR_ASSERT(strcmp(host, actual_host.get()) == 0); + } + if (port == nullptr) { + GPR_ASSERT(actual_port == nullptr); + } else { + GPR_ASSERT(strcmp(port, actual_port.get()) == 0); + } +} + +static void test_split_host_port() { + split_host_port_expect("", "", "", true); + split_host_port_expect("[a:b]", "a:b", "", true); + split_host_port_expect("1.2.3.4", "1.2.3.4", "", true); + split_host_port_expect("a:b:c::", "a:b:c::", "", true); + split_host_port_expect("[a:b]:30", "a:b", "30", true); + split_host_port_expect("1.2.3.4:30", "1.2.3.4", "30", true); + split_host_port_expect(":30", "", "30", true); +} + +static void test_split_host_port_invalid() { + split_host_port_expect("[a:b", nullptr, nullptr, false); + split_host_port_expect("[a:b]30", nullptr, nullptr, false); +} + int main(int argc, char** argv) { grpc::testing::TestEnvironment env(argc, argv); test_join_host_port(); test_join_host_port_garbage(); + test_split_host_port(); + test_split_host_port_invalid(); return 0; } From fedf7e373e172b07c32dcb303a628c0a572c8dd7 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Thu, 27 Jun 2019 12:36:21 -0400 Subject: [PATCH 0742/1555] Fix a backward compatibility bug. To remain backward compatible, we only set port if it's a non-emptry string. But, we always store host. --- src/core/lib/gprpp/host_port.cc | 6 +++++- test/core/gprpp/host_port_test.cc | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/core/lib/gprpp/host_port.cc b/src/core/lib/gprpp/host_port.cc index 82a3ab1add0..13b63eb902b 100644 --- a/src/core/lib/gprpp/host_port.cc +++ b/src/core/lib/gprpp/host_port.cc @@ -93,8 +93,12 @@ bool SplitHostPort(StringView name, UniquePtr* host, StringView port_view; const bool ret = SplitHostPort(name, &host_view, &port_view); if (ret) { + // We always set the host, but port is set only when it's non-empty, + // to remain backward compatible with the old split_host_port API. *host = host_view.dup(); - *port = port_view.dup(); + if (!port_view.empty()) { + *port = port_view.dup(); + } } return ret; } diff --git a/test/core/gprpp/host_port_test.cc b/test/core/gprpp/host_port_test.cc index 33ea4781491..3b392da66e8 100644 --- a/test/core/gprpp/host_port_test.cc +++ b/test/core/gprpp/host_port_test.cc @@ -68,10 +68,10 @@ static void split_host_port_expect(const char* name, const char* host, } static void test_split_host_port() { - split_host_port_expect("", "", "", true); - split_host_port_expect("[a:b]", "a:b", "", true); - split_host_port_expect("1.2.3.4", "1.2.3.4", "", true); - split_host_port_expect("a:b:c::", "a:b:c::", "", true); + split_host_port_expect("", "", nullptr, true); + split_host_port_expect("[a:b]", "a:b", nullptr, true); + split_host_port_expect("1.2.3.4", "1.2.3.4", nullptr, true); + split_host_port_expect("a:b:c::", "a:b:c::", nullptr, true); split_host_port_expect("[a:b]:30", "a:b", "30", true); split_host_port_expect("1.2.3.4:30", "1.2.3.4", "30", true); split_host_port_expect(":30", "", "30", true); From ea63c00d38b144f8d488165021e328c27db8ffa5 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Thu, 27 Jun 2019 17:40:12 -0400 Subject: [PATCH 0743/1555] Revert "Fix build failure in credential_test.cc" This reverts commit dc858eea2578f856394f9fd2cd7f4ef2725266d9. --- test/core/security/credentials_test.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc index 50340311fba..cbce595c354 100644 --- a/test/core/security/credentials_test.cc +++ b/test/core/security/credentials_test.cc @@ -32,9 +32,9 @@ #include #include "src/core/lib/gpr/env.h" -#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" +#include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/http/httpcli.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/security/credentials/composite/composite_credentials.h" @@ -745,11 +745,11 @@ static void test_valid_sts_creds_options(void) { grpc_core::ValidateStsCredentialsOptions(&valid_options, &sts_url); GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(sts_url != nullptr); - char* host; - char* port; - GPR_ASSERT(gpr_split_host_port(sts_url->authority, &host, &port)); - GPR_ASSERT(strcmp(host, "foo.com") == 0); - GPR_ASSERT(strcmp(port, "5555") == 0); + grpc_core::StringView host; + grpc_core::StringView port; + GPR_ASSERT(grpc_core::SplitHostPort(sts_url->authority, &host, &port)); + GPR_ASSERT(host.cmp("foo.com") == 0); + GPR_ASSERT(port.cmp("5555") == 0); grpc_uri_destroy(sts_url); } From 9f59029aee2d613002b650420ef7dc0129991ad7 Mon Sep 17 00:00:00 2001 From: Guantao Liu Date: Thu, 27 Jun 2019 20:54:51 -0700 Subject: [PATCH 0744/1555] Revert the implementation of grpc_iomgr_run_in_background() for gevent, which causes duplicate definitions. --- src/core/lib/iomgr/iomgr_custom.cc | 2 -- src/core/lib/iomgr/iomgr_uv.cc | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/iomgr_custom.cc b/src/core/lib/iomgr/iomgr_custom.cc index 262417cf0d2..f5ac8a0670a 100644 --- a/src/core/lib/iomgr/iomgr_custom.cc +++ b/src/core/lib/iomgr/iomgr_custom.cc @@ -72,8 +72,6 @@ void grpc_custom_iomgr_init(grpc_socket_vtable* socket, grpc_set_iomgr_platform_vtable(&vtable); } -bool grpc_iomgr_run_in_background() { return false; } - #ifdef GRPC_CUSTOM_SOCKET grpc_iomgr_platform_vtable* grpc_default_iomgr_platform_vtable() { return &vtable; diff --git a/src/core/lib/iomgr/iomgr_uv.cc b/src/core/lib/iomgr/iomgr_uv.cc index 4a984446dba..d00bfa4d46e 100644 --- a/src/core/lib/iomgr/iomgr_uv.cc +++ b/src/core/lib/iomgr/iomgr_uv.cc @@ -37,4 +37,6 @@ void grpc_set_default_iomgr_platform() { grpc_custom_iomgr_init(&grpc_uv_socket_vtable, &uv_resolver_vtable, &uv_timer_vtable, &uv_pollset_vtable); } + +bool grpc_iomgr_run_in_background() { return false; } #endif From 743be2ba94f37366f48f2465e69e8d7a4c14b864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=A2=E3=83=8F=E3=83=A1=E3=83=89?= <12945919+iamrare@users.noreply.github.com> Date: Fri, 28 Jun 2019 15:54:03 +0900 Subject: [PATCH 0745/1555] fix link --- doc/statuscodes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/statuscodes.md b/doc/statuscodes.md index 61e0d820b48..a5c395d0ceb 100644 --- a/doc/statuscodes.md +++ b/doc/statuscodes.md @@ -71,4 +71,4 @@ The following status codes are never generated by the library: - OUT_OF_RANGE - DATA_LOSS -Applications that may wish to [retry](https:github.com/grpc/proposal/blob/master/A6-client-retries.md) failed RPCs must decide which status codes on which to retry. As shown in the table above, the gRPC library can generate the same status code for different cases. Server applications can also return those same status codes. Therefore, there is no fixed list of status codes on which it is appropriate to retry in all applications. As a result, individual applications must make their own determination as to which status codes should cause an RPC to be retried. +Applications that may wish to [retry](https://github.com/grpc/proposal/blob/master/A6-client-retries.md) failed RPCs must decide which status codes on which to retry. As shown in the table above, the gRPC library can generate the same status code for different cases. Server applications can also return those same status codes. Therefore, there is no fixed list of status codes on which it is appropriate to retry in all applications. As a result, individual applications must make their own determination as to which status codes should cause an RPC to be retried. From 4c96998eb1cd263396d0f3b1c4af43bfbbc859c3 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Wed, 26 Jun 2019 16:07:03 -0700 Subject: [PATCH 0746/1555] Fix typo --- .../dns/c_ares/grpc_ares_ev_driver_windows.cc | 19 ++++++++++--------- src/core/lib/iomgr/iocp_windows.cc | 4 ++-- src/core/lib/iomgr/socket_windows.h | 2 +- src/core/lib/iomgr/tcp_windows.cc | 14 +++++++------- tools/interop_matrix/client_matrix.py | 2 +- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc index d24c111448c..addae23dc3e 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc @@ -459,12 +459,13 @@ class GrpcPolledFdWindows : public GrpcPolledFd { connect_done_ = true; GPR_ASSERT(wsa_connect_error_ == 0); if (error == GRPC_ERROR_NONE) { - DWORD transfered_bytes = 0; + DWORD transferred_bytes = 0; DWORD flags; - BOOL wsa_success = WSAGetOverlappedResult( - grpc_winsocket_wrapped_socket(winsocket_), - &winsocket_->write_info.overlapped, &transfered_bytes, FALSE, &flags); - GPR_ASSERT(transfered_bytes == 0); + BOOL wsa_success = + WSAGetOverlappedResult(grpc_winsocket_wrapped_socket(winsocket_), + &winsocket_->write_info.overlapped, + &transferred_bytes, FALSE, &flags); + GPR_ASSERT(transferred_bytes == 0); if (!wsa_success) { wsa_connect_error_ = WSAGetLastError(); char* msg = gpr_format_message(wsa_connect_error_); @@ -620,8 +621,8 @@ class GrpcPolledFdWindows : public GrpcPolledFd { } } if (error == GRPC_ERROR_NONE) { - read_buf_ = grpc_slice_sub_no_ref(read_buf_, 0, - winsocket_->read_info.bytes_transfered); + read_buf_ = grpc_slice_sub_no_ref( + read_buf_, 0, winsocket_->read_info.bytes_transferred); read_buf_has_data_ = true; } else { grpc_slice_unref_internal(read_buf_); @@ -657,9 +658,9 @@ class GrpcPolledFdWindows : public GrpcPolledFd { if (error == GRPC_ERROR_NONE) { tcp_write_state_ = WRITE_WAITING_FOR_VERIFICATION_UPON_RETRY; write_buf_ = grpc_slice_sub_no_ref( - write_buf_, 0, winsocket_->write_info.bytes_transfered); + write_buf_, 0, winsocket_->write_info.bytes_transferred); GRPC_CARES_TRACE_LOG("fd:|%s| OnIocpWriteableInner. bytes transferred:%d", - GetName(), winsocket_->write_info.bytes_transfered); + GetName(), winsocket_->write_info.bytes_transferred); } else { grpc_slice_unref_internal(write_buf_); write_buf_ = grpc_empty_slice(); diff --git a/src/core/lib/iomgr/iocp_windows.cc b/src/core/lib/iomgr/iocp_windows.cc index ad325fe2156..29a05ee3099 100644 --- a/src/core/lib/iomgr/iocp_windows.cc +++ b/src/core/lib/iomgr/iocp_windows.cc @@ -90,12 +90,12 @@ grpc_iocp_work_status grpc_iocp_work(grpc_millis deadline) { abort(); } if (socket->shutdown_called) { - info->bytes_transfered = 0; + info->bytes_transferred = 0; info->wsa_error = WSA_OPERATION_ABORTED; } else { success = WSAGetOverlappedResult(socket->socket, &info->overlapped, &bytes, FALSE, &flags); - info->bytes_transfered = bytes; + info->bytes_transferred = bytes; info->wsa_error = success ? 0 : WSAGetLastError(); } GPR_ASSERT(overlapped == &info->overlapped); diff --git a/src/core/lib/iomgr/socket_windows.h b/src/core/lib/iomgr/socket_windows.h index 5fed6909e6f..78f79453c6c 100644 --- a/src/core/lib/iomgr/socket_windows.h +++ b/src/core/lib/iomgr/socket_windows.h @@ -59,7 +59,7 @@ typedef struct grpc_winsocket_callback_info { to hold a mutex for a long amount of time. */ int has_pending_iocp; /* The results of the overlapped operation. */ - DWORD bytes_transfered; + DWORD bytes_transferred; int wsa_error; } grpc_winsocket_callback_info; diff --git a/src/core/lib/iomgr/tcp_windows.cc b/src/core/lib/iomgr/tcp_windows.cc index ae6b2b68e62..32d0bb36ea7 100644 --- a/src/core/lib/iomgr/tcp_windows.cc +++ b/src/core/lib/iomgr/tcp_windows.cc @@ -196,17 +196,17 @@ static void on_read(void* tcpp, grpc_error* error) { gpr_free(utf8_message); grpc_slice_buffer_reset_and_unref_internal(tcp->read_slices); } else { - if (info->bytes_transfered != 0 && !tcp->shutting_down) { - GPR_ASSERT((size_t)info->bytes_transfered <= tcp->read_slices->length); - if (static_cast(info->bytes_transfered) != + if (info->bytes_transferred != 0 && !tcp->shutting_down) { + GPR_ASSERT((size_t)info->bytes_transferred <= tcp->read_slices->length); + if (static_cast(info->bytes_transferred) != tcp->read_slices->length) { grpc_slice_buffer_trim_end( tcp->read_slices, tcp->read_slices->length - - static_cast(info->bytes_transfered), + static_cast(info->bytes_transferred), &tcp->last_read_buffer); } - GPR_ASSERT((size_t)info->bytes_transfered == tcp->read_slices->length); + GPR_ASSERT((size_t)info->bytes_transferred == tcp->read_slices->length); if (grpc_tcp_trace.enabled()) { size_t i; @@ -288,7 +288,7 @@ static void win_read(grpc_endpoint* ep, grpc_slice_buffer* read_slices, /* Did we get data immediately ? Yay. */ if (info->wsa_error != WSAEWOULDBLOCK) { - info->bytes_transfered = bytes_read; + info->bytes_transferred = bytes_read; GRPC_CLOSURE_SCHED(&tcp->on_read, GRPC_ERROR_NONE); return; } @@ -333,7 +333,7 @@ static void on_write(void* tcpp, grpc_error* error) { if (info->wsa_error != 0) { error = GRPC_WSA_ERROR(info->wsa_error, "WSASend"); } else { - GPR_ASSERT(info->bytes_transfered == tcp->write_slices->length); + GPR_ASSERT(info->bytes_transferred == tcp->write_slices->length); } } diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index 7bcfa075559..d6d0612b4e4 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -284,7 +284,7 @@ LANG_RELEASE_MATRIX = { ('v1.16.0', ReleaseInfo(testcases_file='php__v1.0.1')), ('v1.17.1', ReleaseInfo(testcases_file='php__v1.0.1')), ('v1.18.0', ReleaseInfo()), - # v1.19 and v1.20 were deliberately ommitted here because of an issue. + # v1.19 and v1.20 were deliberately omitted here because of an issue. # See https://github.com/grpc/grpc/issues/18264 ('v1.21.4', ReleaseInfo()), ]), From d527c1fbda718e7e274de4c5ec300c0345dea7b6 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Wed, 26 Jun 2019 17:41:39 -0700 Subject: [PATCH 0747/1555] Pre-compute static metadata index for hpack_encoder. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Originally, hpack_encoder would check if a metadata was static or not by comparing its pointer to the known static metadata global table and checking if it was within bounds. This check was performed regardless of if the metadata was static or not, and is somewhat costly. Instead, we now pre-compute the static metadata index during code generation time, and store it with static metadata objects. We read that value only if we are dealing with a static metadata flag (which we know from the storage type of the grpc_mdelem). This yields slightly faster metadata encoding: BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:0 ] 34.9ns ± 2% 34.2ns ± 1% -2.04% (p=0.000 n=20+20) BM_HpackEncoderEncodeHeader/1/16384 [framing_bytes/iter:9 header_bytes/iter:0 ] 34.9ns ± 2% 34.2ns ± 1% -2.01% (p=0.000 n=20+19) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 50.6ns ± 0% 49.2ns ± 2% -2.74% (p=0.000 n=18+20) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:6 ] 84.7ns ± 1% 83.5ns ± 1% -1.43% (p=0.000 n=20+20) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 50.4ns ± 0% 47.9ns ± 0% -4.83% (p=0.000 n=18+17) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 51.1ns ± 2% 48.9ns ± 1% -4.32% (p=0.000 n=20+20) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 50.8ns ± 2% 48.8ns ± 2% -3.88% (p=0.000 n=19+20) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 50.2ns ± 1% 47.9ns ± 0% -4.47% (p=0.000 n=19+16) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 50.2ns ± 0% 47.9ns ± 0% -4.46% (p=0.000 n=18+16) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 50.2ns ± 0% 47.9ns ± 0% -4.40% (p=0.000 n=19+17) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 50.7ns ± 2% 48.8ns ± 2% -3.81% (p=0.000 n=20+20) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 50.9ns ± 2% 48.8ns ± 2% -4.05% (p=0.000 n=20+20) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 50.1ns ± 0% 48.0ns ± 1% -4.27% (p=0.000 n=17+17) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 50.1ns ± 0% 48.0ns ± 1% -4.28% (p=0.000 n=18+17) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 50.1ns ± 0% 48.0ns ± 0% -4.33% (p=0.000 n=18+17) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:9 ] 91.4ns ± 1% 90.7ns ± 1% -0.79% (p=0.000 n=18+20) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:12 ] 116ns ± 1% 116ns ± 1% -0.46% (p=0.002 n=20+20) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:14 ] 122ns ± 0% 121ns ± 0% -0.69% (p=0.000 n=20+20) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:23 ] 144ns ± 1% 144ns ± 0% -0.23% (p=0.009 n=20+20) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:46 ] 232ns ± 0% 232ns ± 1% -0.26% (p=0.021 n=18+19) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:12 ] 92.9ns ± 1% 92.0ns ± 1% -0.97% (p=0.000 n=19+19) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:14 ] 94.0ns ± 1% 92.6ns ± 1% -1.45% (p=0.000 n=20+19) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:21 ] 93.9ns ± 2% 92.8ns ± 1% -1.17% (p=0.001 n=20+19) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:111 ] 106ns ± 0% 105ns ± 3% -1.15% (p=0.000 n=18+20) BM_HpackEncoderEncodeHeader/0/1 [framing_bytes/iter:81 header_bytes/iter:9 ] 355ns ± 1% 354ns ± 0% -0.35% (p=0.015 n=19+20) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:8.00002 ] 139ns ± 1% 133ns ± 1% -4.46% (p=0.000 n=19+20) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:16 ] 236ns ± 1% 231ns ± 1% -2.24% (p=0.000 n=20+20) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:3 ] 73.6ns ± 1% 70.5ns ± 1% -4.14% (p=0.000 n=20+20) BM_HpackEncoderEncodeHeader/1/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 50.5ns ± 0% 49.2ns ± 2% -2.60% (p=0.000 n=16+20) --- .../chttp2/transport/hpack_encoder.cc | 22 ++- src/core/lib/transport/metadata.h | 6 +- src/core/lib/transport/static_metadata.cc | 172 +++++++++--------- tools/codegen/core/gen_static_metadata.py | 6 +- 4 files changed, 109 insertions(+), 97 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc index 359ad275bbb..9e5f0f5e4a1 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc @@ -711,18 +711,28 @@ void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor* c, } for (size_t i = 0; i < extra_headers_size; ++i) { grpc_mdelem md = *extra_headers[i]; - uintptr_t static_index = grpc_chttp2_get_static_hpack_table_index(md); - if (static_index) { - emit_indexed(c, static_cast(static_index), &st); + const bool is_static = + GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_STATIC; + uintptr_t static_index; + if (is_static && + (static_index = + reinterpret_cast(GRPC_MDELEM_DATA(md)) + ->StaticIndex()) < GRPC_CHTTP2_LAST_STATIC_ENTRY) { + emit_indexed(c, static_cast(static_index + 1), &st); } else { hpack_enc(c, md, &st); } } grpc_metadata_batch_assert_ok(metadata); for (grpc_linked_mdelem* l = metadata->list.head; l; l = l->next) { - uintptr_t static_index = grpc_chttp2_get_static_hpack_table_index(l->md); - if (static_index) { - emit_indexed(c, static_cast(static_index), &st); + const bool is_static = + GRPC_MDELEM_STORAGE(l->md) == GRPC_MDELEM_STORAGE_STATIC; + uintptr_t static_index; + if (is_static && + (static_index = reinterpret_cast( + GRPC_MDELEM_DATA(l->md)) + ->StaticIndex()) < GRPC_CHTTP2_LAST_STATIC_ENTRY) { + emit_indexed(c, static_cast(static_index + 1), &st); } else { hpack_enc(c, l->md, &st); } diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h index 4b9685066e5..4621433bf01 100644 --- a/src/core/lib/transport/metadata.h +++ b/src/core/lib/transport/metadata.h @@ -186,19 +186,21 @@ struct UserData { class StaticMetadata { public: - StaticMetadata(const grpc_slice& key, const grpc_slice& value) - : kv_({key, value}), hash_(0) {} + StaticMetadata(const grpc_slice& key, const grpc_slice& value, uintptr_t idx) + : kv_({key, value}), hash_(0), static_idx_(idx) {} const grpc_mdelem_data& data() const { return kv_; } void HashInit(); uint32_t hash() { return hash_; } + uintptr_t StaticIndex() { return static_idx_; } private: grpc_mdelem_data kv_; /* private only data */ uint32_t hash_; + uintptr_t static_idx_; }; class RefcountedMdBase { diff --git a/src/core/lib/transport/static_metadata.cc b/src/core/lib/transport/static_metadata.cc index bbf1736b595..5887e3515fb 100644 --- a/src/core/lib/transport/static_metadata.cc +++ b/src/core/lib/transport/static_metadata.cc @@ -398,262 +398,262 @@ grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b) { grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[3], {{10, g_bytes + 19}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 0), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, - {&grpc_static_metadata_refcounts[40], {{3, g_bytes + 612}}}), + {&grpc_static_metadata_refcounts[40], {{3, g_bytes + 612}}}, 1), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, - {&grpc_static_metadata_refcounts[41], {{4, g_bytes + 615}}}), + {&grpc_static_metadata_refcounts[41], {{4, g_bytes + 615}}}, 2), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[0], {{5, g_bytes + 0}}}, - {&grpc_static_metadata_refcounts[42], {{1, g_bytes + 619}}}), + {&grpc_static_metadata_refcounts[42], {{1, g_bytes + 619}}}, 3), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[0], {{5, g_bytes + 0}}}, - {&grpc_static_metadata_refcounts[43], {{11, g_bytes + 620}}}), + {&grpc_static_metadata_refcounts[43], {{11, g_bytes + 620}}}, 4), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, - {&grpc_static_metadata_refcounts[44], {{4, g_bytes + 631}}}), + {&grpc_static_metadata_refcounts[44], {{4, g_bytes + 631}}}, 5), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, - {&grpc_static_metadata_refcounts[45], {{5, g_bytes + 635}}}), + {&grpc_static_metadata_refcounts[45], {{5, g_bytes + 635}}}, 6), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[46], {{3, g_bytes + 640}}}), + {&grpc_static_metadata_refcounts[46], {{3, g_bytes + 640}}}, 7), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[47], {{3, g_bytes + 643}}}), + {&grpc_static_metadata_refcounts[47], {{3, g_bytes + 643}}}, 8), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[48], {{3, g_bytes + 646}}}), + {&grpc_static_metadata_refcounts[48], {{3, g_bytes + 646}}}, 9), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[49], {{3, g_bytes + 649}}}), + {&grpc_static_metadata_refcounts[49], {{3, g_bytes + 649}}}, 10), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[50], {{3, g_bytes + 652}}}), + {&grpc_static_metadata_refcounts[50], {{3, g_bytes + 652}}}, 11), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[51], {{3, g_bytes + 655}}}), + {&grpc_static_metadata_refcounts[51], {{3, g_bytes + 655}}}, 12), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[52], {{3, g_bytes + 658}}}), + {&grpc_static_metadata_refcounts[52], {{3, g_bytes + 658}}}, 13), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[53], {{14, g_bytes + 661}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 14), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[54], {{13, g_bytes + 675}}}), + {&grpc_static_metadata_refcounts[54], {{13, g_bytes + 675}}}, 15), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[55], {{15, g_bytes + 688}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 16), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[56], {{13, g_bytes + 703}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 17), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[57], {{6, g_bytes + 716}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 18), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[58], {{27, g_bytes + 722}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 19), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[59], {{3, g_bytes + 749}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 20), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[60], {{5, g_bytes + 752}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 21), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[61], {{13, g_bytes + 757}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 22), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[62], {{13, g_bytes + 770}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 23), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[63], {{19, g_bytes + 783}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 24), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 25), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[64], {{16, g_bytes + 802}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 26), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[65], {{14, g_bytes + 818}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 27), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[66], {{16, g_bytes + 832}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 28), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[67], {{13, g_bytes + 848}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 29), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[14], {{12, g_bytes + 158}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 30), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[68], {{6, g_bytes + 861}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 31), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[69], {{4, g_bytes + 867}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 32), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[70], {{4, g_bytes + 871}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 33), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[71], {{6, g_bytes + 875}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 34), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[72], {{7, g_bytes + 881}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 35), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[73], {{4, g_bytes + 888}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 36), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[20], {{4, g_bytes + 278}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 37), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[74], {{8, g_bytes + 892}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 38), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[75], {{17, g_bytes + 900}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 39), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[76], {{13, g_bytes + 917}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 40), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[77], {{8, g_bytes + 930}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 41), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[78], {{19, g_bytes + 938}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 42), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[79], {{13, g_bytes + 957}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 43), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[80], {{4, g_bytes + 970}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 44), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[81], {{8, g_bytes + 974}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 45), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[82], {{12, g_bytes + 982}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 46), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[83], {{18, g_bytes + 994}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 47), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[84], {{19, g_bytes + 1012}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 48), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[85], {{5, g_bytes + 1031}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 49), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[86], {{7, g_bytes + 1036}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 50), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[87], {{7, g_bytes + 1043}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 51), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[88], {{11, g_bytes + 1050}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 52), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[89], {{6, g_bytes + 1061}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 53), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[90], {{10, g_bytes + 1067}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 54), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[91], {{25, g_bytes + 1077}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 55), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[92], {{17, g_bytes + 1102}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 56), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[19], {{10, g_bytes + 268}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 57), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[93], {{4, g_bytes + 1119}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 58), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[94], {{3, g_bytes + 1123}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 59), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[95], {{16, g_bytes + 1126}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 60), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, - {&grpc_static_metadata_refcounts[96], {{1, g_bytes + 1142}}}), + {&grpc_static_metadata_refcounts[96], {{1, g_bytes + 1142}}}, 61), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, - {&grpc_static_metadata_refcounts[25], {{1, g_bytes + 350}}}), + {&grpc_static_metadata_refcounts[25], {{1, g_bytes + 350}}}, 62), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, - {&grpc_static_metadata_refcounts[26], {{1, g_bytes + 351}}}), + {&grpc_static_metadata_refcounts[26], {{1, g_bytes + 351}}}, 63), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, - {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}), + {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}, 64), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, - {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}), + {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}, 65), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, - {&grpc_static_metadata_refcounts[37], {{7, g_bytes + 590}}}), + {&grpc_static_metadata_refcounts[37], {{7, g_bytes + 590}}}, 66), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[5], {{2, g_bytes + 36}}}, - {&grpc_static_metadata_refcounts[98], {{8, g_bytes + 1151}}}), + {&grpc_static_metadata_refcounts[98], {{8, g_bytes + 1151}}}, 67), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[14], {{12, g_bytes + 158}}}, - {&grpc_static_metadata_refcounts[99], {{16, g_bytes + 1159}}}), + {&grpc_static_metadata_refcounts[99], {{16, g_bytes + 1159}}}, 68), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, - {&grpc_static_metadata_refcounts[100], {{4, g_bytes + 1175}}}), + {&grpc_static_metadata_refcounts[100], {{4, g_bytes + 1175}}}, 69), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, - {&grpc_static_metadata_refcounts[101], {{3, g_bytes + 1179}}}), + {&grpc_static_metadata_refcounts[101], {{3, g_bytes + 1179}}}, 70), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 71), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, - {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}), + {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}, 72), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, - {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}), + {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}, 73), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[21], {{8, g_bytes + 282}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 74), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[102], {{11, g_bytes + 1182}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}), + {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 75), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}), + {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}, 76), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[37], {{7, g_bytes + 590}}}), + {&grpc_static_metadata_refcounts[37], {{7, g_bytes + 590}}}, 77), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[103], {{16, g_bytes + 1193}}}), + {&grpc_static_metadata_refcounts[103], {{16, g_bytes + 1193}}}, 78), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}), + {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}, 79), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[104], {{13, g_bytes + 1209}}}), + {&grpc_static_metadata_refcounts[104], {{13, g_bytes + 1209}}}, 80), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[105], {{12, g_bytes + 1222}}}), + {&grpc_static_metadata_refcounts[105], {{12, g_bytes + 1222}}}, 81), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[106], {{21, g_bytes + 1234}}}), + {&grpc_static_metadata_refcounts[106], {{21, g_bytes + 1234}}}, 82), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}), + {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}, 83), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}), + {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}, 84), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[104], {{13, g_bytes + 1209}}}), + {&grpc_static_metadata_refcounts[104], {{13, g_bytes + 1209}}}, 85), }; const uint8_t grpc_static_accept_encoding_metadata[8] = {0, 76, 77, 78, 79, 80, 81, 82}; diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py index b534d8dab7e..a149e001d75 100755 --- a/tools/codegen/core/gen_static_metadata.py +++ b/tools/codegen/core/gen_static_metadata.py @@ -550,9 +550,9 @@ print >> C, '}' print >> C print >> C, 'grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = {' -for a, b in all_elems: - print >> C, 'grpc_core::StaticMetadata(%s,%s),' % (slice_def(str_idx(a)), - slice_def(str_idx(b))) +for idx, (a, b) in enumerate(all_elems): + print >> C, 'grpc_core::StaticMetadata(%s,%s, %d),' % ( + slice_def(str_idx(a)), slice_def(str_idx(b)), idx) print >> C, '};' print >> H, 'typedef enum {' From a40dd958be9ae762828a7862b59a7ef63691c7d5 Mon Sep 17 00:00:00 2001 From: Pau Freixes Date: Sat, 29 Jun 2019 16:56:44 +0200 Subject: [PATCH 0748/1555] Fix watcher connectivity dead lock Call the `grpc_cq_end_op` once the watcher connectivity mutex has been released, otherwise when using a completion queue of callback type a dead lock will occur. --- .../client_channel/channel_connectivity.cc | 18 ++++- test/core/end2end/tests/connectivity.cc | 75 +++++++++++++++++++ 2 files changed, 91 insertions(+), 2 deletions(-) diff --git a/src/core/ext/filters/client_channel/channel_connectivity.cc b/src/core/ext/filters/client_channel/channel_connectivity.cc index 232183d61ff..58170e66f96 100644 --- a/src/core/ext/filters/client_channel/channel_connectivity.cc +++ b/src/core/ext/filters/client_channel/channel_connectivity.cc @@ -111,6 +111,12 @@ static void finished_completion(void* pw, grpc_cq_completion* ignored) { static void partly_done(state_watcher* w, bool due_to_completion, grpc_error* error) { + bool end_op = false; + void* end_op_tag = nullptr; + grpc_error* end_op_error = nullptr; + grpc_completion_queue* end_op_cq = nullptr; + grpc_cq_completion* end_op_completion_storage = nullptr; + if (due_to_completion) { grpc_timer_cancel(&w->alarm); } else { @@ -152,8 +158,11 @@ static void partly_done(state_watcher* w, bool due_to_completion, w->error = error; } w->phase = CALLING_BACK_AND_FINISHED; - grpc_cq_end_op(w->cq, w->tag, w->error, finished_completion, w, - &w->completion_storage); + end_op = true; + end_op_cq = w->cq; + end_op_tag = w->tag; + end_op_error = w->error; + end_op_completion_storage = &w->completion_storage; break; case CALLING_BACK_AND_FINISHED: GPR_UNREACHABLE_CODE(return ); @@ -161,6 +170,11 @@ static void partly_done(state_watcher* w, bool due_to_completion, } gpr_mu_unlock(&w->mu); + if (end_op) { + grpc_cq_end_op(end_op_cq, end_op_tag, end_op_error, finished_completion, w, + end_op_completion_storage); + } + GRPC_ERROR_UNREF(error); } diff --git a/test/core/end2end/tests/connectivity.cc b/test/core/end2end/tests/connectivity.cc index caa4265aa2c..5511e55ccc7 100644 --- a/test/core/end2end/tests/connectivity.cc +++ b/test/core/end2end/tests/connectivity.cc @@ -33,6 +33,16 @@ typedef struct { grpc_completion_queue* cq; } child_events; +struct CallbackContext { + grpc_experimental_completion_queue_functor functor; + gpr_event finished; + explicit CallbackContext(void (*cb)( + grpc_experimental_completion_queue_functor* functor, int success)) { + functor.functor_run = cb; + gpr_event_init(&finished); + } +}; + static void child_thread(void* arg) { child_events* ce = static_cast(arg); grpc_event ev; @@ -163,9 +173,74 @@ static void test_connectivity(grpc_end2end_test_config config) { cq_verifier_destroy(cqv); } +static void cb_watch_connectivity( + grpc_experimental_completion_queue_functor* functor, int success) { + CallbackContext* cb_ctx = (CallbackContext*)functor; + + gpr_log(GPR_DEBUG, "cb_watch_connectivity called, verifying"); + + /* callback must not have errors */ + GPR_ASSERT(success != 0); + + gpr_event_set(&cb_ctx->finished, (void*)1); +} + +static void cb_shutdown(grpc_experimental_completion_queue_functor* functor, + int success) { + CallbackContext* cb_ctx = (CallbackContext*)functor; + + gpr_log(GPR_DEBUG, "cb_shutdown called, nothing to do"); + gpr_event_set(&cb_ctx->finished, (void*)1); +} + +static void test_watch_connectivity_cq_callback( + grpc_end2end_test_config config) { + CallbackContext cb_ctx(cb_watch_connectivity); + CallbackContext cb_shutdown_ctx(cb_shutdown); + grpc_completion_queue* cq; + grpc_end2end_test_fixture f = config.create_fixture(nullptr, nullptr); + + config.init_client(&f, nullptr); + + /* start connecting */ + grpc_channel_check_connectivity_state(f.client, 1); + + /* create the cq callback */ + cq = grpc_completion_queue_create_for_callback(&cb_shutdown_ctx.functor, + nullptr); + + /* start watching for any change, cb is immediately called + * and no dead lock should be raised */ + grpc_channel_watch_connectivity_state(f.client, GRPC_CHANNEL_IDLE, + grpc_timeout_seconds_to_deadline(3), cq, + &cb_ctx.functor); + + /* we just check that the callback was executed once notifying a connection + * transition */ + GPR_ASSERT(gpr_event_wait(&cb_ctx.finished, + gpr_inf_future(GPR_CLOCK_MONOTONIC)) != nullptr); + + /* shutdown, since shutdown cb might be executed in a background thread + * we actively wait till is executed. */ + grpc_completion_queue_shutdown(cq); + gpr_event_wait(&cb_shutdown_ctx.finished, + gpr_inf_future(GPR_CLOCK_MONOTONIC)); + + /* cleanup */ + grpc_channel_destroy(f.client); + grpc_completion_queue_destroy(cq); + + /* shutdown_cq and cq are not used in this test */ + grpc_completion_queue_destroy(f.cq); + grpc_completion_queue_destroy(f.shutdown_cq); + + config.tear_down_data(&f); +} + void connectivity(grpc_end2end_test_config config) { GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION); test_connectivity(config); + test_watch_connectivity_cq_callback(config); } void connectivity_pre_init(void) {} From 74be06c80f5bd9562041b1f3c6359a7ebf3620d0 Mon Sep 17 00:00:00 2001 From: Marc Gravell Date: Sun, 30 Jun 2019 09:42:21 +0100 Subject: [PATCH 0749/1555] remove UTF8 byte[] allocations: decode directly into a string; encode using stack or array-pool --- .../Grpc.Core/Internal/CallSafeHandle.cs | 37 +++++++++++++++++-- src/csharp/Grpc.Core/Internal/MarshalUtils.cs | 33 +++++++++++------ .../Internal/NativeMethods.Generated.cs | 16 +++++--- 3 files changed, 65 insertions(+), 21 deletions(-) diff --git a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs index 858d2a69605..67efb031629 100644 --- a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs @@ -21,6 +21,7 @@ using System.Text; using Grpc.Core; using Grpc.Core.Utils; using Grpc.Core.Profiling; +using System.Buffers; namespace Grpc.Core.Internal { @@ -127,16 +128,44 @@ namespace Grpc.Core.Internal } } - public void StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, + public unsafe void StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, byte[] optionalPayload, WriteFlags writeFlags) { using (completionQueue.NewScope()) { var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_ISendStatusFromServerCompletionCallback, callback); var optionalPayloadLength = optionalPayload != null ? new UIntPtr((ulong)optionalPayload.Length) : UIntPtr.Zero; - var statusDetailBytes = MarshalUtils.GetBytesUTF8(status.Detail); - Native.grpcsharp_call_send_status_from_server(this, ctx, status.StatusCode, statusDetailBytes, new UIntPtr((ulong)statusDetailBytes.Length), metadataArray, sendEmptyInitialMetadata ? 1 : 0, - optionalPayload, optionalPayloadLength, writeFlags).CheckOk(); + int maxBytes = MarshalUtils.GetMaxBytesUTF8(status.Detail); + const int MaxStackAllocBytes = 256; + + if (maxBytes <= MaxStackAllocBytes) + { // for small status, we can encode on the stack without touching arrays + // note: if init-locals is disabled, it would be more efficient + // to just stackalloc[MaxStackAllocBytes]; but by default, since we + // expect this to be small and it needs to wipe, just use maxBytes + byte* ptr = stackalloc byte[maxBytes]; + int statusBytes = MarshalUtils.GetBytesUTF8(status.Detail, ptr, maxBytes); + Native.grpcsharp_call_send_status_from_server(this, ctx, status.StatusCode, ptr, new UIntPtr((ulong)statusBytes), metadataArray, sendEmptyInitialMetadata ? 1 : 0, + optionalPayload, optionalPayloadLength, writeFlags).CheckOk(); + } + else + { // for larger status (rare), rent a buffer from the pool and + // use that for encoding + var statusBuffer = ArrayPool.Shared.Rent(maxBytes); + try + { + fixed (byte* ptr = statusBuffer) + { + int statusBytes = MarshalUtils.GetBytesUTF8(status.Detail, ptr, maxBytes); + Native.grpcsharp_call_send_status_from_server(this, ctx, status.StatusCode, ptr, new UIntPtr((ulong)statusBytes), metadataArray, sendEmptyInitialMetadata ? 1 : 0, + optionalPayload, optionalPayloadLength, writeFlags).CheckOk(); + } + } + finally + { + ArrayPool.Shared.Return(statusBuffer); + } + } } } diff --git a/src/csharp/Grpc.Core/Internal/MarshalUtils.cs b/src/csharp/Grpc.Core/Internal/MarshalUtils.cs index e3e41617955..ec3ce9ca72d 100644 --- a/src/csharp/Grpc.Core/Internal/MarshalUtils.cs +++ b/src/csharp/Grpc.Core/Internal/MarshalUtils.cs @@ -32,34 +32,43 @@ namespace Grpc.Core.Internal /// /// Converts IntPtr pointing to a UTF-8 encoded byte array to string. /// - public static string PtrToStringUTF8(IntPtr ptr, int len) + public static unsafe string PtrToStringUTF8(IntPtr ptr, int len) { if (len == 0) { return ""; } - // TODO(jtattermusch): once Span dependency is added, - // use Span-based API to decode the string without copying the buffer. - var bytes = new byte[len]; - Marshal.Copy(ptr, bytes, 0, len); - return EncodingUTF8.GetString(bytes); + // allocate a right-sized string and decode into it + byte* source = (byte*)ptr.ToPointer(); + int charCount = EncodingUTF8.GetCharCount(source, len); + string s = new string('\0', charCount); + fixed(char* cPtr = s) + { + EncodingUTF8.GetChars(source, len, cPtr, charCount); + } + return s; } /// - /// Returns byte array containing UTF-8 encoding of given string. + /// UTF-8 encodes the given string into a buffer of sufficient size /// - public static byte[] GetBytesUTF8(string str) + public static unsafe int GetBytesUTF8(string str, byte* destination, int destinationLength) { - return EncodingUTF8.GetBytes(str); + int charCount = str.Length; + if (charCount == 0) return 0; + fixed (char* source = str) + { + return EncodingUTF8.GetBytes(source, charCount, destination, destinationLength); + } } /// - /// Get string from a UTF8 encoded byte array. + /// Returns the maximum number of bytes required to encode a given string. /// - public static string GetStringUTF8(byte[] bytes) + public static int GetMaxBytesUTF8(string str) { - return EncodingUTF8.GetString(bytes); + return EncodingUTF8.GetMaxByteCount(str.Length); } } } diff --git a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs index b8a60b31c40..e67263edbda 100644 --- a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs +++ b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs @@ -266,7 +266,10 @@ namespace Grpc.Core.Internal this.grpcsharp_call_start_duplex_streaming = DllImportsFromStaticLib.grpcsharp_call_start_duplex_streaming; this.grpcsharp_call_send_message = DllImportsFromStaticLib.grpcsharp_call_send_message; this.grpcsharp_call_send_close_from_client = DllImportsFromStaticLib.grpcsharp_call_send_close_from_client; - this.grpcsharp_call_send_status_from_server = DllImportsFromStaticLib.grpcsharp_call_send_status_from_server; + unsafe + { + this.grpcsharp_call_send_status_from_server = DllImportsFromStaticLib.grpcsharp_call_send_status_from_server; + } this.grpcsharp_call_recv_message = DllImportsFromStaticLib.grpcsharp_call_recv_message; this.grpcsharp_call_recv_initial_metadata = DllImportsFromStaticLib.grpcsharp_call_recv_initial_metadata; this.grpcsharp_call_start_serverside = DllImportsFromStaticLib.grpcsharp_call_start_serverside; @@ -366,7 +369,10 @@ namespace Grpc.Core.Internal this.grpcsharp_call_start_duplex_streaming = DllImportsFromSharedLib.grpcsharp_call_start_duplex_streaming; this.grpcsharp_call_send_message = DllImportsFromSharedLib.grpcsharp_call_send_message; this.grpcsharp_call_send_close_from_client = DllImportsFromSharedLib.grpcsharp_call_send_close_from_client; - this.grpcsharp_call_send_status_from_server = DllImportsFromSharedLib.grpcsharp_call_send_status_from_server; + unsafe + { + this.grpcsharp_call_send_status_from_server = DllImportsFromSharedLib.grpcsharp_call_send_status_from_server; + } this.grpcsharp_call_recv_message = DllImportsFromSharedLib.grpcsharp_call_recv_message; this.grpcsharp_call_recv_initial_metadata = DllImportsFromSharedLib.grpcsharp_call_recv_initial_metadata; this.grpcsharp_call_start_serverside = DllImportsFromSharedLib.grpcsharp_call_start_serverside; @@ -469,7 +475,7 @@ namespace Grpc.Core.Internal public delegate CallError grpcsharp_call_start_duplex_streaming_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); public delegate CallError grpcsharp_call_send_message_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, int sendEmptyInitialMetadata); public delegate CallError grpcsharp_call_send_close_from_client_delegate(CallSafeHandle call, BatchContextSafeHandle ctx); - public delegate CallError grpcsharp_call_send_status_from_server_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, byte[] statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); + public unsafe delegate CallError grpcsharp_call_send_status_from_server_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, byte* statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); public delegate CallError grpcsharp_call_recv_message_delegate(CallSafeHandle call, BatchContextSafeHandle ctx); public delegate CallError grpcsharp_call_recv_initial_metadata_delegate(CallSafeHandle call, BatchContextSafeHandle ctx); public delegate CallError grpcsharp_call_start_serverside_delegate(CallSafeHandle call, BatchContextSafeHandle ctx); @@ -637,7 +643,7 @@ namespace Grpc.Core.Internal public static extern CallError grpcsharp_call_send_close_from_client(CallSafeHandle call, BatchContextSafeHandle ctx); [DllImport(ImportName)] - public static extern CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, byte[] statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); + public static unsafe extern CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, byte* statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); [DllImport(ImportName)] public static extern CallError grpcsharp_call_recv_message(CallSafeHandle call, BatchContextSafeHandle ctx); @@ -933,7 +939,7 @@ namespace Grpc.Core.Internal public static extern CallError grpcsharp_call_send_close_from_client(CallSafeHandle call, BatchContextSafeHandle ctx); [DllImport(ImportName)] - public static extern CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, byte[] statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); + public static unsafe extern CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, byte* statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); [DllImport(ImportName)] public static extern CallError grpcsharp_call_recv_message(CallSafeHandle call, BatchContextSafeHandle ctx); From cb813e1ffce4498a51fe87487554669dfdcb3903 Mon Sep 17 00:00:00 2001 From: Marc Gravell Date: Sun, 30 Jun 2019 09:59:46 +0100 Subject: [PATCH 0750/1555] check the *actual* length to allow more stack usage *and* allow smaller pool rentals --- src/csharp/Grpc.Core/Grpc.Core.csproj | 2 ++ src/csharp/Grpc.Core/Internal/CallSafeHandle.cs | 10 +++++++++- src/csharp/Grpc.Core/Internal/MarshalUtils.cs | 10 +++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/csharp/Grpc.Core/Grpc.Core.csproj b/src/csharp/Grpc.Core/Grpc.Core.csproj index afd60e73a21..1844ce335bc 100755 --- a/src/csharp/Grpc.Core/Grpc.Core.csproj +++ b/src/csharp/Grpc.Core/Grpc.Core.csproj @@ -100,6 +100,8 @@ + + diff --git a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs index 67efb031629..c62297b0972 100644 --- a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs @@ -135,8 +135,16 @@ namespace Grpc.Core.Internal { var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_ISendStatusFromServerCompletionCallback, callback); var optionalPayloadLength = optionalPayload != null ? new UIntPtr((ulong)optionalPayload.Length) : UIntPtr.Zero; - int maxBytes = MarshalUtils.GetMaxBytesUTF8(status.Detail); + const int MaxStackAllocBytes = 256; + int maxBytes = MarshalUtils.GetMaxByteCountUTF8(status.Detail); + if (maxBytes > MaxStackAllocBytes) + { + // pay the extra to get the *actual* size; this could mean that + // it ends up fitting on the stack after all, but even if not + // it will mean that we ask for a *much* smaller buffer + maxBytes = MarshalUtils.GetByteCountUTF8(status.Detail); + } if (maxBytes <= MaxStackAllocBytes) { // for small status, we can encode on the stack without touching arrays diff --git a/src/csharp/Grpc.Core/Internal/MarshalUtils.cs b/src/csharp/Grpc.Core/Internal/MarshalUtils.cs index ec3ce9ca72d..54b4370935d 100644 --- a/src/csharp/Grpc.Core/Internal/MarshalUtils.cs +++ b/src/csharp/Grpc.Core/Internal/MarshalUtils.cs @@ -66,9 +66,17 @@ namespace Grpc.Core.Internal /// /// Returns the maximum number of bytes required to encode a given string. /// - public static int GetMaxBytesUTF8(string str) + public static int GetMaxByteCountUTF8(string str) { return EncodingUTF8.GetMaxByteCount(str.Length); } + + /// + /// Returns the actual number of bytes required to encode a given string. + /// + public static int GetByteCountUTF8(string str) + { + return EncodingUTF8.GetByteCount(str); + } } } From 05a0dd20e4be4f0715be74ee092040fd6b05f173 Mon Sep 17 00:00:00 2001 From: mgravell Date: Mon, 1 Jul 2019 14:58:11 +0100 Subject: [PATCH 0751/1555] convert micro-benchmarks to benchmarkdotnet --- .gitignore | 3 + .../CommonThreadedBase.cs | 67 ++++++++++++++ .../CompletionRegistryBenchmark.cs | 56 ++++-------- src/csharp/Grpc.Microbenchmarks/GCStats.cs | 69 -------------- .../Grpc.Microbenchmarks.csproj | 7 +- .../PInvokeByteArrayBenchmark.cs | 42 ++++----- src/csharp/Grpc.Microbenchmarks/Program.cs | 89 ++----------------- .../SendMessageBenchmark.cs | 41 ++++----- .../Grpc.Microbenchmarks/ThreadedBenchmark.cs | 65 -------------- 9 files changed, 126 insertions(+), 313 deletions(-) create mode 100644 src/csharp/Grpc.Microbenchmarks/CommonThreadedBase.cs delete mode 100644 src/csharp/Grpc.Microbenchmarks/GCStats.cs delete mode 100644 src/csharp/Grpc.Microbenchmarks/ThreadedBenchmark.cs diff --git a/.gitignore b/.gitignore index a8c58277c34..4a400b4e3b4 100644 --- a/.gitignore +++ b/.gitignore @@ -146,3 +146,6 @@ bm_*.json # Clion artifacts cmake-build-debug/ + +# Benchmark outputs +BenchmarkDotNet.Artifacts/ \ No newline at end of file diff --git a/src/csharp/Grpc.Microbenchmarks/CommonThreadedBase.cs b/src/csharp/Grpc.Microbenchmarks/CommonThreadedBase.cs new file mode 100644 index 00000000000..d8724f1eaad --- /dev/null +++ b/src/csharp/Grpc.Microbenchmarks/CommonThreadedBase.cs @@ -0,0 +1,67 @@ +#region Copyright notice and license + +// Copyright 2015 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using System.Threading; +using System.Threading.Tasks; +using BenchmarkDotNet.Attributes; +using Grpc.Core; + +namespace Grpc.Microbenchmarks +{ + + // common base-type for tests that need to run with some level of concurrency; + // note there's nothing *special* about this type - it is just to save some + // boilerplate + + [ClrJob, CoreJob] // test .NET Core and .NET Framework + [MemoryDiagnoser] // allocations + [ShortRunJob] // don't take too long + public abstract class CommonThreadedBase + { + protected virtual bool NeedsEnvironment => true; + + [Params(1, 1, 2, 4, 8, 12)] + public int ThreadCount { get; set; } + + protected GrpcEnvironment Environment { get; private set; } + + [GlobalSetup] + public virtual void Setup() + { + ThreadPool.GetMinThreads(out var workers, out var iocp); + if (workers <= ThreadCount) ThreadPool.SetMinThreads(ThreadCount + 1, iocp); + if (NeedsEnvironment) Environment = GrpcEnvironment.AddRef(); + } + + [GlobalCleanup] + public virtual void Cleanup() + { + if (Environment != null) + { + Environment = null; + GrpcEnvironment.ReleaseAsync().Wait(); + } + } + + protected void RunConcurrent(Action operation) + { + Parallel.For(0, ThreadCount, _ => operation()); + } + } +} diff --git a/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs index bb57a6968fa..58ba29927cc 100644 --- a/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2015 gRPC authors. // @@ -17,62 +17,38 @@ #endregion using System; -using System.Runtime.InteropServices; -using System.Threading; -using Grpc.Core; +using BenchmarkDotNet.Attributes; using Grpc.Core.Internal; -using System.Collections.Generic; -using System.Diagnostics; namespace Grpc.Microbenchmarks { - public class CompletionRegistryBenchmark + public class CompletionRegistryBenchmarks : CommonThreadedBase { - GrpcEnvironment environment; + [Params(false, true)] + public bool UseSharedRegistry { get; set; } - public void Init() + const int Iterations = 1000; + [Benchmark(OperationsPerInvoke = Iterations)] + public void Run() { - environment = GrpcEnvironment.AddRef(); + RunConcurrent(() => { + CompletionRegistry sharedRegistry = UseSharedRegistry ? new CompletionRegistry(Environment, () => BatchContextSafeHandle.Create(), () => RequestCallContextSafeHandle.Create()) : null; + RunBody(sharedRegistry); + }); } - public void Cleanup() + private void RunBody(CompletionRegistry optionalSharedRegistry) { - GrpcEnvironment.ReleaseAsync().Wait(); - } - - public void Run(int threadCount, int iterations, bool useSharedRegistry) - { - Console.WriteLine(string.Format("CompletionRegistryBenchmark: threads={0}, iterations={1}, useSharedRegistry={2}", threadCount, iterations, useSharedRegistry)); - CompletionRegistry sharedRegistry = useSharedRegistry ? new CompletionRegistry(environment, () => BatchContextSafeHandle.Create(), () => RequestCallContextSafeHandle.Create()) : null; - var threadedBenchmark = new ThreadedBenchmark(threadCount, () => ThreadBody(iterations, sharedRegistry)); - threadedBenchmark.Run(); - // TODO: parametrize by number of pending completions - } - - private void ThreadBody(int iterations, CompletionRegistry optionalSharedRegistry) - { - var completionRegistry = optionalSharedRegistry ?? new CompletionRegistry(environment, () => throw new NotImplementedException(), () => throw new NotImplementedException()); + var completionRegistry = optionalSharedRegistry ?? new CompletionRegistry(Environment, () => throw new NotImplementedException(), () => throw new NotImplementedException()); var ctx = BatchContextSafeHandle.Create(); - - var stopwatch = Stopwatch.StartNew(); - for (int i = 0; i < iterations; i++) + + for (int i = 0; i < Iterations; i++) { completionRegistry.Register(ctx.Handle, ctx); var callback = completionRegistry.Extract(ctx.Handle); // NOTE: we are not calling the callback to avoid disposing ctx. } - stopwatch.Stop(); - Console.WriteLine("Elapsed millis: " + stopwatch.ElapsedMilliseconds); - ctx.Recycle(); } - - private class NopCompletionCallback : IOpCompletionCallback - { - public void OnComplete(bool success) - { - - } - } } } diff --git a/src/csharp/Grpc.Microbenchmarks/GCStats.cs b/src/csharp/Grpc.Microbenchmarks/GCStats.cs deleted file mode 100644 index ca7051ec4e5..00000000000 --- a/src/csharp/Grpc.Microbenchmarks/GCStats.cs +++ /dev/null @@ -1,69 +0,0 @@ -#region Copyright notice and license - -// Copyright 2015 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#endregion - -using System; -using Grpc.Core; -using Grpc.Core.Internal; - -namespace Grpc.Microbenchmarks -{ - internal class GCStats - { - readonly object myLock = new object(); - GCStatsSnapshot lastSnapshot; - - public GCStats() - { - lastSnapshot = new GCStatsSnapshot(GC.CollectionCount(0), GC.CollectionCount(1), GC.CollectionCount(2)); - } - - public GCStatsSnapshot GetSnapshot(bool reset = false) - { - lock (myLock) - { - var newSnapshot = new GCStatsSnapshot(GC.CollectionCount(0) - lastSnapshot.Gen0, - GC.CollectionCount(1) - lastSnapshot.Gen1, - GC.CollectionCount(2) - lastSnapshot.Gen2); - if (reset) - { - lastSnapshot = newSnapshot; - } - return newSnapshot; - } - } - } - - public class GCStatsSnapshot - { - public GCStatsSnapshot(int gen0, int gen1, int gen2) - { - this.Gen0 = gen0; - this.Gen1 = gen1; - this.Gen2 = gen2; - } - - public int Gen0 { get; } - public int Gen1 { get; } - public int Gen2 { get; } - - public override string ToString() - { - return string.Format("[GCCollectionCount: gen0 {0}, gen1 {1}, gen2 {2}]", Gen0, Gen1, Gen2); - } - } -} diff --git a/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj b/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj index e0fcdecd9ac..899e41ce532 100644 --- a/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj +++ b/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj @@ -3,7 +3,7 @@ - net45;netcoreapp2.1 + net461;netcoreapp2.1 Exe true @@ -13,10 +13,10 @@ - + - + @@ -24,5 +24,4 @@ - diff --git a/src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs index 787b5508fba..412f9ad1cb4 100644 --- a/src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2015 gRPC authors. // @@ -16,49 +16,39 @@ #endregion -using System; using System.Runtime.InteropServices; -using System.Threading; -using Grpc.Core; +using BenchmarkDotNet.Attributes; using Grpc.Core.Internal; -using System.Collections.Generic; -using System.Diagnostics; namespace Grpc.Microbenchmarks { - public class PInvokeByteArrayBenchmark + public class PInvokeByteArrayBenchmark : CommonThreadedBase { static readonly NativeMethods Native = NativeMethods.Get(); - public void Init() + protected override bool NeedsEnvironment => false; + + + [Params(0)] + public int PayloadSize { get; set; } + + const int Iterations = 1000; + [Benchmark(OperationsPerInvoke = Iterations)] + public void Run() { + RunConcurrent(RunBody); } - public void Cleanup() + private void RunBody() { - } - - public void Run(int threadCount, int iterations, int payloadSize) - { - Console.WriteLine(string.Format("PInvokeByteArrayBenchmark: threads={0}, iterations={1}, payloadSize={2}", threadCount, iterations, payloadSize)); - var threadedBenchmark = new ThreadedBenchmark(threadCount, () => ThreadBody(iterations, payloadSize)); - threadedBenchmark.Run(); - } - - private void ThreadBody(int iterations, int payloadSize) - { - var payload = new byte[payloadSize]; - - var stopwatch = Stopwatch.StartNew(); - for (int i = 0; i < iterations; i++) + var payload = new byte[PayloadSize]; + for (int i = 0; i < Iterations; i++) { var gcHandle = GCHandle.Alloc(payload, GCHandleType.Pinned); var payloadPtr = gcHandle.AddrOfPinnedObject(); Native.grpcsharp_test_nop(payloadPtr); gcHandle.Free(); } - stopwatch.Stop(); - Console.WriteLine("Elapsed millis: " + stopwatch.ElapsedMilliseconds); } } } diff --git a/src/csharp/Grpc.Microbenchmarks/Program.cs b/src/csharp/Grpc.Microbenchmarks/Program.cs index a64c2979abe..71e549f76ff 100644 --- a/src/csharp/Grpc.Microbenchmarks/Program.cs +++ b/src/csharp/Grpc.Microbenchmarks/Program.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2015 gRPC authors. // @@ -16,95 +16,18 @@ #endregion -using System; -using Grpc.Core; -using Grpc.Core.Internal; -using Grpc.Core.Logging; -using CommandLine; -using CommandLine.Text; +using BenchmarkDotNet.Running; namespace Grpc.Microbenchmarks { class Program { - public enum MicrobenchmarkType - { - CompletionRegistry, - PInvokeByteArray, - SendMessage - } - - private class BenchmarkOptions - { - [Option("benchmark", Required = true, HelpText = "Benchmark to run")] - public MicrobenchmarkType Benchmark { get; set; } - } - + // typical usage: dotnet run -c Release -f netcoreapp2.1 + // (this will profile both .net core and .net framework; for some reason + // if you start from "-f net461", it goes horribly wrong) public static void Main(string[] args) { - GrpcEnvironment.SetLogger(new ConsoleLogger()); - var parserResult = Parser.Default.ParseArguments(args) - .WithNotParsed(errors => { - Console.WriteLine("Supported benchmarks:"); - foreach (var enumValue in Enum.GetValues(typeof(MicrobenchmarkType))) - { - Console.WriteLine(" " + enumValue); - } - Environment.Exit(1); - }) - .WithParsed(options => - { - switch (options.Benchmark) - { - case MicrobenchmarkType.CompletionRegistry: - RunCompletionRegistryBenchmark(); - break; - case MicrobenchmarkType.PInvokeByteArray: - RunPInvokeByteArrayBenchmark(); - break; - case MicrobenchmarkType.SendMessage: - RunSendMessageBenchmark(); - break; - default: - throw new ArgumentException("Unsupported benchmark."); - } - }); - } - - static void RunCompletionRegistryBenchmark() - { - var benchmark = new CompletionRegistryBenchmark(); - benchmark.Init(); - foreach (int threadCount in new int[] {1, 1, 2, 4, 8, 12}) - { - foreach (bool useSharedRegistry in new bool[] {false, true}) - { - benchmark.Run(threadCount, 4 * 1000 * 1000, useSharedRegistry); - } - } - benchmark.Cleanup(); - } - - static void RunPInvokeByteArrayBenchmark() - { - var benchmark = new PInvokeByteArrayBenchmark(); - benchmark.Init(); - foreach (int threadCount in new int[] {1, 1, 2, 4, 8, 12}) - { - benchmark.Run(threadCount, 4 * 1000 * 1000, 0); - } - benchmark.Cleanup(); - } - - static void RunSendMessageBenchmark() - { - var benchmark = new SendMessageBenchmark(); - benchmark.Init(); - foreach (int threadCount in new int[] {1, 1, 2, 4, 8, 12}) - { - benchmark.Run(threadCount, 4 * 1000 * 1000, 0); - } - benchmark.Cleanup(); + BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); } } } diff --git a/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs index 390c062298d..fa06e7a8230 100644 --- a/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs @@ -17,59 +17,48 @@ #endregion using System; -using System.Threading; +using BenchmarkDotNet.Attributes; using Grpc.Core; using Grpc.Core.Internal; -using System.Collections.Generic; -using System.Diagnostics; namespace Grpc.Microbenchmarks { - public class SendMessageBenchmark + public class SendMessageBenchmark : CommonThreadedBase { static readonly NativeMethods Native = NativeMethods.Get(); - GrpcEnvironment environment; - - public void Init() + public override void Setup() { Native.grpcsharp_test_override_method("grpcsharp_call_start_batch", "nop"); - environment = GrpcEnvironment.AddRef(); + base.Setup(); } - public void Cleanup() + [Params(0)] + public int PayloadSize { get; set; } + + const int Iterations = 1000; + [Benchmark(OperationsPerInvoke = Iterations)] + public void Run() { - GrpcEnvironment.ReleaseAsync().Wait(); - // TODO(jtattermusch): track GC stats + RunConcurrent(RunBody); } - public void Run(int threadCount, int iterations, int payloadSize) + private void RunBody() { - Console.WriteLine(string.Format("SendMessageBenchmark: threads={0}, iterations={1}, payloadSize={2}", threadCount, iterations, payloadSize)); - var threadedBenchmark = new ThreadedBenchmark(threadCount, () => ThreadBody(iterations, payloadSize)); - threadedBenchmark.Run(); - } - - private void ThreadBody(int iterations, int payloadSize) - { - var completionRegistry = new CompletionRegistry(environment, () => environment.BatchContextPool.Lease(), () => throw new NotImplementedException()); + var completionRegistry = new CompletionRegistry(Environment, () => Environment.BatchContextPool.Lease(), () => throw new NotImplementedException()); var cq = CompletionQueueSafeHandle.CreateAsync(completionRegistry); var call = CreateFakeCall(cq); var sendCompletionCallback = new NopSendCompletionCallback(); - var payload = new byte[payloadSize]; + var payload = new byte[PayloadSize]; var writeFlags = default(WriteFlags); - var stopwatch = Stopwatch.StartNew(); - for (int i = 0; i < iterations; i++) + for (int i = 0; i < Iterations; i++) { call.StartSendMessage(sendCompletionCallback, payload, writeFlags, false); var callback = completionRegistry.Extract(completionRegistry.LastRegisteredKey); callback.OnComplete(true); } - stopwatch.Stop(); - Console.WriteLine("Elapsed millis: " + stopwatch.ElapsedMilliseconds); - cq.Dispose(); } diff --git a/src/csharp/Grpc.Microbenchmarks/ThreadedBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/ThreadedBenchmark.cs deleted file mode 100644 index 95b9aaaf3f9..00000000000 --- a/src/csharp/Grpc.Microbenchmarks/ThreadedBenchmark.cs +++ /dev/null @@ -1,65 +0,0 @@ -#region Copyright notice and license - -// Copyright 2015 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#endregion - -using System; -using System.Threading; -using Grpc.Core; -using Grpc.Core.Internal; -using System.Collections.Generic; -using System.Diagnostics; - -namespace Grpc.Microbenchmarks -{ - public class ThreadedBenchmark - { - List runners; - - public ThreadedBenchmark(IEnumerable runners) - { - this.runners = new List(runners); - } - - public ThreadedBenchmark(int threadCount, Action threadBody) - { - this.runners = new List(); - for (int i = 0; i < threadCount; i++) - { - this.runners.Add(new ThreadStart(() => threadBody())); - } - } - - public void Run() - { - Console.WriteLine("Running threads."); - var gcStats = new GCStats(); - var threads = new List(); - for (int i = 0; i < runners.Count; i++) - { - var thread = new Thread(runners[i]); - thread.Start(); - threads.Add(thread); - } - - foreach (var thread in threads) - { - thread.Join(); - } - Console.WriteLine("All threads finished (GC Stats Delta: " + gcStats.GetSnapshot() + ")"); - } - } -} From 52de8a0a17ebcfe414cbb777c3861cb3142577ec Mon Sep 17 00:00:00 2001 From: mgravell Date: Mon, 1 Jul 2019 15:25:22 +0100 Subject: [PATCH 0752/1555] ShortRunJob *added* a test! --- src/csharp/Grpc.Microbenchmarks/CommonThreadedBase.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/csharp/Grpc.Microbenchmarks/CommonThreadedBase.cs b/src/csharp/Grpc.Microbenchmarks/CommonThreadedBase.cs index d8724f1eaad..4b6174eeef8 100644 --- a/src/csharp/Grpc.Microbenchmarks/CommonThreadedBase.cs +++ b/src/csharp/Grpc.Microbenchmarks/CommonThreadedBase.cs @@ -31,7 +31,6 @@ namespace Grpc.Microbenchmarks [ClrJob, CoreJob] // test .NET Core and .NET Framework [MemoryDiagnoser] // allocations - [ShortRunJob] // don't take too long public abstract class CommonThreadedBase { protected virtual bool NeedsEnvironment => true; From f5091b2622d57fb34fc30fec1f609fe7b8d74800 Mon Sep 17 00:00:00 2001 From: mgravell Date: Mon, 1 Jul 2019 16:16:00 +0100 Subject: [PATCH 0753/1555] add UTF8-decode benchmark | Method | Job | Runtime | PayloadSize | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated | |------- |----- |-------- |------------ |-------------:|-----------:|-----------:|-------:|------:|------:|----------:| | Run | Clr | Clr | 0 | 1.736 ns | 0.0101 ns | 0.0094 ns | - | - | - | - | | Run | Core | Core | 0 | 1.306 ns | 0.0108 ns | 0.0095 ns | - | - | - | - | | Run | Clr | Clr | 1 | 35.384 ns | 0.2282 ns | 0.2135 ns | 0.0101 | - | - | 64 B | | Run | Core | Core | 1 | 32.388 ns | 0.3333 ns | 0.2955 ns | 0.0101 | - | - | 64 B | | Run | Clr | Clr | 4 | 57.736 ns | 0.3889 ns | 0.3448 ns | 0.0114 | - | - | 72 B | | Run | Core | Core | 4 | 52.878 ns | 0.2802 ns | 0.2621 ns | 0.0114 | - | - | 72 B | | Run | Clr | Clr | 128 | 554.819 ns | 4.4341 ns | 4.1477 ns | 0.0830 | - | - | 530 B | | Run | Core | Core | 128 | 336.356 ns | 1.6148 ns | 1.4315 ns | 0.0835 | - | - | 528 B | | Run | Clr | Clr | 1024 | 4,050.850 ns | 28.9245 ns | 25.6408 ns | 0.6016 | - | - | 3820 B | | Run | Core | Core | 1024 | 2,272.534 ns | 33.8963 ns | 31.7066 ns | 0.6016 | - | - | 3808 B | --- .../Grpc.Microbenchmarks.csproj | 1 + src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs | 50 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs diff --git a/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj b/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj index 899e41ce532..f775e4c85fb 100644 --- a/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj +++ b/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj @@ -6,6 +6,7 @@ net461;netcoreapp2.1 Exe true + true diff --git a/src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs b/src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs new file mode 100644 index 00000000000..1c3f4d261ee --- /dev/null +++ b/src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Text; +using BenchmarkDotNet.Attributes; +using Grpc.Core.Internal; + +namespace Grpc.Microbenchmarks +{ + [ClrJob, CoreJob] // test .NET Core and .NET Framework + [MemoryDiagnoser] // allocations + public class Utf8Decode + { + [Params(0, 1, 4, 128, 1024)] + public int PayloadSize { get; set; } + + static readonly Dictionary Payloads = new Dictionary { + { 0, Invent(0) }, + { 1, Invent(1) }, + { 4, Invent(4) }, + { 128, Invent(128) }, + { 1024, Invent(1024) }, + }; + + static byte[] Invent(int length) + { + var rand = new Random(Seed: length); + var chars = new char[length]; + for(int i = 0; i < chars.Length; i++) + { + chars[i] = (char)rand.Next(32, 300); + } + return Encoding.UTF8.GetBytes(chars); + } + + const int Iterations = 1000; + [Benchmark(OperationsPerInvoke = Iterations)] + public unsafe void Run() + { + byte[] payload = Payloads[PayloadSize]; + fixed (byte* ptr = payload) + { + var iPtr = new IntPtr(ptr); + for (int i = 0; i < Iterations; i++) + { + MarshalUtils.PtrToStringUTF8(iPtr, payload.Length); + } + } + } + } +} From dbef6c9c70898451dbc1eadfb7e1bab0a9d18a42 Mon Sep 17 00:00:00 2001 From: mgravell Date: Mon, 1 Jul 2019 16:36:46 +0100 Subject: [PATCH 0754/1555] add utf-8 encode benchmark --- .../Properties/AssemblyInfo.cs | 6 ++ .../Grpc.Microbenchmarks.csproj | 1 + src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs | 72 +++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs diff --git a/src/csharp/Grpc.Core.Tests/Properties/AssemblyInfo.cs b/src/csharp/Grpc.Core.Tests/Properties/AssemblyInfo.cs index af264c9be5d..e19010f0509 100644 --- a/src/csharp/Grpc.Core.Tests/Properties/AssemblyInfo.cs +++ b/src/csharp/Grpc.Core.Tests/Properties/AssemblyInfo.cs @@ -27,3 +27,9 @@ using System.Runtime.CompilerServices; [assembly: AssemblyCopyright("Google Inc. All rights reserved.")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] + +[assembly: InternalsVisibleTo("Grpc.Microbenchmarks,PublicKey=" + + "00240000048000009400000006020000002400005253413100040000010001002f5797a92c6fcde81bd4098f43" + + "0442bb8e12768722de0b0cb1b15e955b32a11352740ee59f2c94c48edc8e177d1052536b8ac651bce11ce5da3a" + + "27fc95aff3dc604a6971417453f9483c7b5e836756d5b271bf8f2403fe186e31956148c03d804487cf642f8cc0" + + "71394ee9672dfe5b55ea0f95dfd5a7f77d22c962ccf51320d3")] diff --git a/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj b/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj index f775e4c85fb..89597e139ec 100644 --- a/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj +++ b/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj @@ -11,6 +11,7 @@ + diff --git a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs new file mode 100644 index 00000000000..cbb4091122b --- /dev/null +++ b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Text; +using BenchmarkDotNet.Attributes; +using Grpc.Core; +using Grpc.Core.Internal; +using Grpc.Core.Internal.Tests; + +namespace Grpc.Microbenchmarks +{ + [ClrJob, CoreJob] // test .NET Core and .NET Framework + [MemoryDiagnoser] // allocations + public class Utf8Encode : ISendStatusFromServerCompletionCallback + { + static readonly NativeMethods Native = NativeMethods.Get(); + + [Params(0, 1, 4, 128, 1024)] + public int PayloadSize { get; set; } + + static readonly Dictionary Payloads = new Dictionary { + { 0, Invent(0) }, + { 1, Invent(1) }, + { 4, Invent(4) }, + { 128, Invent(128) }, + { 1024, Invent(1024) }, + }; + + static string Invent(int length) + { + var rand = new Random(Seed: length); + var chars = new char[length]; + for(int i = 0; i < chars.Length; i++) + { + chars[i] = (char)rand.Next(32, 300); + } + return new string(chars); + } + + [GlobalSetup] + public void Setup() + { + Native.grpcsharp_test_override_method("grpcsharp_call_start_batch", "nop"); + metadata = MetadataArraySafeHandle.Create(Metadata.Empty); + call = new FakeNativeCall(); + } + + public void Cleanup() + { + metadata.Dispose(); + metadata = null; + call.Dispose(); + call = null; + } + private INativeCall call; + private MetadataArraySafeHandle metadata; + + const int Iterations = 1000; + [Benchmark(OperationsPerInvoke = Iterations)] + public unsafe void Run() + { + string payload = Payloads[PayloadSize]; + var status = new Status(StatusCode.OK, payload); + for (int i = 0; i < Iterations; i++) + { + call.StartSendStatusFromServer(this, status, + metadata, false, null, WriteFlags.NoCompress); + } + } + + void ISendStatusFromServerCompletionCallback.OnSendStatusFromServerCompletion(bool success) { } + } +} From f53d844da9c6d070b52b8e05192fbcb11cea94db Mon Sep 17 00:00:00 2001 From: mgravell Date: Mon, 1 Jul 2019 17:07:15 +0100 Subject: [PATCH 0755/1555] attempt to fix the utf-8 encode benchmark; not currently working --- plugins.vcxproj.filters | 17 +++++++ .../Properties/AssemblyInfo.cs | 6 --- .../Grpc.Microbenchmarks.csproj | 1 - src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs | 47 ++++++++++++++----- 4 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 plugins.vcxproj.filters diff --git a/plugins.vcxproj.filters b/plugins.vcxproj.filters new file mode 100644 index 00000000000..5ce08010501 --- /dev/null +++ b/plugins.vcxproj.filters @@ -0,0 +1,17 @@ + + + + + CMake Rules + + + + + + + + + {870DBD13-69C5-3F27-A253-623E8947E2E7} + + + diff --git a/src/csharp/Grpc.Core.Tests/Properties/AssemblyInfo.cs b/src/csharp/Grpc.Core.Tests/Properties/AssemblyInfo.cs index e19010f0509..af264c9be5d 100644 --- a/src/csharp/Grpc.Core.Tests/Properties/AssemblyInfo.cs +++ b/src/csharp/Grpc.Core.Tests/Properties/AssemblyInfo.cs @@ -27,9 +27,3 @@ using System.Runtime.CompilerServices; [assembly: AssemblyCopyright("Google Inc. All rights reserved.")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] - -[assembly: InternalsVisibleTo("Grpc.Microbenchmarks,PublicKey=" + - "00240000048000009400000006020000002400005253413100040000010001002f5797a92c6fcde81bd4098f43" + - "0442bb8e12768722de0b0cb1b15e955b32a11352740ee59f2c94c48edc8e177d1052536b8ac651bce11ce5da3a" + - "27fc95aff3dc604a6971417453f9483c7b5e836756d5b271bf8f2403fe186e31956148c03d804487cf642f8cc0" + - "71394ee9672dfe5b55ea0f95dfd5a7f77d22c962ccf51320d3")] diff --git a/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj b/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj index 89597e139ec..f775e4c85fb 100644 --- a/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj +++ b/src/csharp/Grpc.Microbenchmarks/Grpc.Microbenchmarks.csproj @@ -11,7 +11,6 @@ - diff --git a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs index cbb4091122b..4061a1a0f02 100644 --- a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs +++ b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs @@ -1,10 +1,8 @@ using System; using System.Collections.Generic; -using System.Text; using BenchmarkDotNet.Attributes; using Grpc.Core; using Grpc.Core.Internal; -using Grpc.Core.Internal.Tests; namespace Grpc.Microbenchmarks { @@ -12,9 +10,7 @@ namespace Grpc.Microbenchmarks [MemoryDiagnoser] // allocations public class Utf8Encode : ISendStatusFromServerCompletionCallback { - static readonly NativeMethods Native = NativeMethods.Get(); - - [Params(0, 1, 4, 128, 1024)] + [Params(0)] //, 1, 4, 128, 1024)] public int PayloadSize { get; set; } static readonly Dictionary Payloads = new Dictionary { @@ -36,22 +32,50 @@ namespace Grpc.Microbenchmarks return new string(chars); } + private GrpcEnvironment environment; + [GlobalSetup] public void Setup() { - Native.grpcsharp_test_override_method("grpcsharp_call_start_batch", "nop"); + var native = NativeMethods.Get(); + + // ??? throws ??? + native.grpcsharp_test_override_method(nameof(NativeMethods.grpcsharp_call_send_status_from_server), "nop"); + + environment = GrpcEnvironment.AddRef(); metadata = MetadataArraySafeHandle.Create(Metadata.Empty); - call = new FakeNativeCall(); + var completionRegistry = new CompletionRegistry(environment, () => environment.BatchContextPool.Lease(), () => throw new NotImplementedException()); + var cq = CompletionQueueSafeHandle.CreateAsync(completionRegistry); + call = CreateFakeCall(cq); } + private static CallSafeHandle CreateFakeCall(CompletionQueueSafeHandle cq) + { + var call = CallSafeHandle.CreateFake(new IntPtr(0xdead), cq); + bool success = false; + while (!success) + { + // avoid calling destroy on a nonexistent grpc_call pointer + call.DangerousAddRef(ref success); + } + return call; + } + + [GlobalCleanup] public void Cleanup() { - metadata.Dispose(); + metadata?.Dispose(); metadata = null; - call.Dispose(); + call?.Dispose(); call = null; + + if (environment != null) + { + environment = null; + GrpcEnvironment.ReleaseAsync().Wait(); + } } - private INativeCall call; + private CallSafeHandle call; private MetadataArraySafeHandle metadata; const int Iterations = 1000; @@ -62,8 +86,7 @@ namespace Grpc.Microbenchmarks var status = new Status(StatusCode.OK, payload); for (int i = 0; i < Iterations; i++) { - call.StartSendStatusFromServer(this, status, - metadata, false, null, WriteFlags.NoCompress); + call.StartSendStatusFromServer(this, status, metadata, false, null, WriteFlags.NoCompress); } } From e4411e03e65a7f69acc48b22403f6453c37e207e Mon Sep 17 00:00:00 2001 From: mgravell Date: Mon, 1 Jul 2019 17:11:26 +0100 Subject: [PATCH 0756/1555] added by mistake --- plugins.vcxproj.filters | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 plugins.vcxproj.filters diff --git a/plugins.vcxproj.filters b/plugins.vcxproj.filters deleted file mode 100644 index 5ce08010501..00000000000 --- a/plugins.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - CMake Rules - - - - - - - - - {870DBD13-69C5-3F27-A253-623E8947E2E7} - - - From 0a1147b58c17de641082bbb58859a3b21fcbd34d Mon Sep 17 00:00:00 2001 From: mgravell Date: Mon, 1 Jul 2019 17:28:47 +0100 Subject: [PATCH 0757/1555] found another way to nop the native-call --- src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs index 4061a1a0f02..0c9370679a4 100644 --- a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs +++ b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs @@ -39,8 +39,9 @@ namespace Grpc.Microbenchmarks { var native = NativeMethods.Get(); - // ??? throws ??? - native.grpcsharp_test_override_method(nameof(NativeMethods.grpcsharp_call_send_status_from_server), "nop"); + // nop the native-call via reflection + NativeMethods.Delegates.grpcsharp_call_send_status_from_server_delegate nop = (CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, byte[] statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags) => CallError.OK; + native.GetType().GetField(nameof(native.grpcsharp_call_send_status_from_server)).SetValue(native, nop); environment = GrpcEnvironment.AddRef(); metadata = MetadataArraySafeHandle.Create(Metadata.Empty); From 464f558a456f8dd43609df066722cc5f0a0257bc Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 1 Jul 2019 10:12:23 -0700 Subject: [PATCH 0758/1555] Increase the control message size --- src/core/lib/iomgr/tcp_posix.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index 889272f6299..0a2ef767598 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -435,7 +435,9 @@ static void tcp_do_read(grpc_tcp* tcp) { GPR_TIMER_SCOPE("tcp_do_read", 0); struct msghdr msg; struct iovec iov[MAX_READ_IOVEC]; - char cmsgbuf[24 /*CMSG_SPACE(sizeof(int))*/]; + char cmsgbuf + [128 /*CMSG_SPACE(sizeof(grpc_core::scm_timestamping)) + CMSG_SPACE(sizeof(int))*/ + ]; ssize_t read_bytes; size_t total_read_bytes = 0; From 1c354e7c1f35c969a96bbdf420b6cc2884b712ba Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Mon, 1 Jul 2019 10:38:23 -0700 Subject: [PATCH 0759/1555] Move grpc async, callback and sync implementation to grpc_impl namespace --- BUILD | 10 + BUILD.gn | 10 + CMakeLists.txt | 40 + Makefile | 40 + build.yaml | 10 + gRPC-C++.podspec | 10 + include/grpcpp/channel_impl.h | 13 +- include/grpcpp/generic/generic_stub_impl.h | 41 +- .../impl/codegen/async_generic_service.h | 28 +- include/grpcpp/impl/codegen/async_stream.h | 1114 +--------------- .../grpcpp/impl/codegen/async_stream_impl.h | 1134 ++++++++++++++++ .../grpcpp/impl/codegen/async_unary_call.h | 291 +--- .../impl/codegen/async_unary_call_impl.h | 315 +++++ include/grpcpp/impl/codegen/byte_buffer.h | 19 +- include/grpcpp/impl/codegen/call_op_set.h | 2 +- .../grpcpp/impl/codegen/channel_interface.h | 47 +- include/grpcpp/impl/codegen/client_callback.h | 1003 +------------- .../impl/codegen/client_callback_impl.h | 1067 +++++++++++++++ .../grpcpp/impl/codegen/client_context_impl.h | 52 +- .../grpcpp/impl/codegen/client_unary_call.h | 4 +- .../impl/codegen/completion_queue_impl.h | 17 +- include/grpcpp/impl/codegen/server_callback.h | 1133 +--------------- .../impl/codegen/server_callback_impl.h | 1186 +++++++++++++++++ .../grpcpp/impl/codegen/server_context_impl.h | 54 +- include/grpcpp/impl/codegen/service_type.h | 20 +- include/grpcpp/impl/codegen/sync_stream.h | 922 +------------ .../grpcpp/impl/codegen/sync_stream_impl.h | 944 +++++++++++++ include/grpcpp/support/async_stream_impl.h | 24 + .../grpcpp/support/async_unary_call_impl.h | 24 + include/grpcpp/support/client_callback_impl.h | 24 + include/grpcpp/support/server_callback_impl.h | 24 + include/grpcpp/support/sync_stream_impl.h | 24 + src/compiler/cpp_generator.cc | 121 +- src/cpp/client/generic_stub.cc | 30 +- src/cpp/server/async_generic_service.cc | 4 +- .../health/default_health_check_service.h | 1 + src/cpp/server/server_builder.cc | 15 +- src/cpp/server/server_context.cc | 11 +- test/cpp/codegen/compiler_test_golden | 37 +- tools/doxygen/Doxyfile.c++ | 10 + tools/doxygen/Doxyfile.c++.internal | 10 + .../generated/sources_and_headers.json | 20 + 42 files changed, 5268 insertions(+), 4637 deletions(-) create mode 100644 include/grpcpp/impl/codegen/async_stream_impl.h create mode 100644 include/grpcpp/impl/codegen/async_unary_call_impl.h create mode 100644 include/grpcpp/impl/codegen/client_callback_impl.h create mode 100644 include/grpcpp/impl/codegen/server_callback_impl.h create mode 100644 include/grpcpp/impl/codegen/sync_stream_impl.h create mode 100644 include/grpcpp/support/async_stream_impl.h create mode 100644 include/grpcpp/support/async_unary_call_impl.h create mode 100644 include/grpcpp/support/client_callback_impl.h create mode 100644 include/grpcpp/support/server_callback_impl.h create mode 100644 include/grpcpp/support/sync_stream_impl.h diff --git a/BUILD b/BUILD index 87d3b978358..b9a47e6e776 100644 --- a/BUILD +++ b/BUILD @@ -268,11 +268,14 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/server_posix.h", "include/grpcpp/server_posix_impl.h", "include/grpcpp/support/async_stream.h", + "include/grpcpp/support/async_stream_impl.h", "include/grpcpp/support/async_unary_call.h", + "include/grpcpp/support/async_unary_call_impl.h", "include/grpcpp/support/byte_buffer.h", "include/grpcpp/support/channel_arguments.h", "include/grpcpp/support/channel_arguments_impl.h", "include/grpcpp/support/client_callback.h", + "include/grpcpp/support/client_callback_impl.h", "include/grpcpp/support/client_interceptor.h", "include/grpcpp/support/config.h", "include/grpcpp/support/interceptor.h", @@ -280,6 +283,7 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/support/proto_buffer_reader.h", "include/grpcpp/support/proto_buffer_writer.h", "include/grpcpp/support/server_callback.h", + "include/grpcpp/support/server_callback_impl.h", "include/grpcpp/support/server_interceptor.h", "include/grpcpp/support/slice.h", "include/grpcpp/support/status.h", @@ -287,6 +291,7 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/support/string_ref.h", "include/grpcpp/support/stub_options.h", "include/grpcpp/support/sync_stream.h", + "include/grpcpp/support/sync_stream_impl.h", "include/grpcpp/support/time.h", "include/grpcpp/support/validate_service_config.h", ] @@ -2155,7 +2160,9 @@ grpc_cc_library( "include/grpc++/impl/codegen/time.h", "include/grpcpp/impl/codegen/async_generic_service.h", "include/grpcpp/impl/codegen/async_stream.h", + "include/grpcpp/impl/codegen/async_stream_impl.h", "include/grpcpp/impl/codegen/async_unary_call.h", + "include/grpcpp/impl/codegen/async_unary_call_impl.h", "include/grpcpp/impl/codegen/byte_buffer.h", "include/grpcpp/impl/codegen/call.h", "include/grpcpp/impl/codegen/call_hook.h", @@ -2164,6 +2171,7 @@ grpc_cc_library( "include/grpcpp/impl/codegen/callback_common.h", "include/grpcpp/impl/codegen/channel_interface.h", "include/grpcpp/impl/codegen/client_callback.h", + "include/grpcpp/impl/codegen/client_callback_impl.h", "include/grpcpp/impl/codegen/client_context.h", "include/grpcpp/impl/codegen/client_context_impl.h", "include/grpcpp/impl/codegen/client_interceptor.h", @@ -2186,6 +2194,7 @@ grpc_cc_library( "include/grpcpp/impl/codegen/security/auth_context.h", "include/grpcpp/impl/codegen/serialization_traits.h", "include/grpcpp/impl/codegen/server_callback.h", + "include/grpcpp/impl/codegen/server_callback_impl.h", "include/grpcpp/impl/codegen/server_context.h", "include/grpcpp/impl/codegen/server_context_impl.h", "include/grpcpp/impl/codegen/server_interceptor.h", @@ -2197,6 +2206,7 @@ grpc_cc_library( "include/grpcpp/impl/codegen/string_ref.h", "include/grpcpp/impl/codegen/stub_options.h", "include/grpcpp/impl/codegen/sync_stream.h", + "include/grpcpp/impl/codegen/sync_stream_impl.h", "include/grpcpp/impl/codegen/time.h", ], deps = [ diff --git a/BUILD.gn b/BUILD.gn index fc9fa8dc3d0..05e4da5561f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1045,7 +1045,9 @@ config("grpc_config") { "include/grpcpp/impl/client_unary_call.h", "include/grpcpp/impl/codegen/async_generic_service.h", "include/grpcpp/impl/codegen/async_stream.h", + "include/grpcpp/impl/codegen/async_stream_impl.h", "include/grpcpp/impl/codegen/async_unary_call.h", + "include/grpcpp/impl/codegen/async_unary_call_impl.h", "include/grpcpp/impl/codegen/byte_buffer.h", "include/grpcpp/impl/codegen/call.h", "include/grpcpp/impl/codegen/call_hook.h", @@ -1054,6 +1056,7 @@ config("grpc_config") { "include/grpcpp/impl/codegen/callback_common.h", "include/grpcpp/impl/codegen/channel_interface.h", "include/grpcpp/impl/codegen/client_callback.h", + "include/grpcpp/impl/codegen/client_callback_impl.h", "include/grpcpp/impl/codegen/client_context.h", "include/grpcpp/impl/codegen/client_context_impl.h", "include/grpcpp/impl/codegen/client_interceptor.h", @@ -1082,6 +1085,7 @@ config("grpc_config") { "include/grpcpp/impl/codegen/security/auth_context.h", "include/grpcpp/impl/codegen/serialization_traits.h", "include/grpcpp/impl/codegen/server_callback.h", + "include/grpcpp/impl/codegen/server_callback_impl.h", "include/grpcpp/impl/codegen/server_context.h", "include/grpcpp/impl/codegen/server_context_impl.h", "include/grpcpp/impl/codegen/server_interceptor.h", @@ -1094,6 +1098,7 @@ config("grpc_config") { "include/grpcpp/impl/codegen/stub_options.h", "include/grpcpp/impl/codegen/sync.h", "include/grpcpp/impl/codegen/sync_stream.h", + "include/grpcpp/impl/codegen/sync_stream_impl.h", "include/grpcpp/impl/codegen/time.h", "include/grpcpp/impl/grpc_library.h", "include/grpcpp/impl/method_handler_impl.h", @@ -1123,11 +1128,14 @@ config("grpc_config") { "include/grpcpp/server_posix.h", "include/grpcpp/server_posix_impl.h", "include/grpcpp/support/async_stream.h", + "include/grpcpp/support/async_stream_impl.h", "include/grpcpp/support/async_unary_call.h", + "include/grpcpp/support/async_unary_call_impl.h", "include/grpcpp/support/byte_buffer.h", "include/grpcpp/support/channel_arguments.h", "include/grpcpp/support/channel_arguments_impl.h", "include/grpcpp/support/client_callback.h", + "include/grpcpp/support/client_callback_impl.h", "include/grpcpp/support/client_interceptor.h", "include/grpcpp/support/config.h", "include/grpcpp/support/interceptor.h", @@ -1135,6 +1143,7 @@ config("grpc_config") { "include/grpcpp/support/proto_buffer_reader.h", "include/grpcpp/support/proto_buffer_writer.h", "include/grpcpp/support/server_callback.h", + "include/grpcpp/support/server_callback_impl.h", "include/grpcpp/support/server_interceptor.h", "include/grpcpp/support/slice.h", "include/grpcpp/support/status.h", @@ -1142,6 +1151,7 @@ config("grpc_config") { "include/grpcpp/support/string_ref.h", "include/grpcpp/support/stub_options.h", "include/grpcpp/support/sync_stream.h", + "include/grpcpp/support/sync_stream_impl.h", "include/grpcpp/support/time.h", "include/grpcpp/support/validate_service_config.h", "src/core/ext/transport/inproc/inproc_transport.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 713fc16028f..c47684addac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3205,11 +3205,14 @@ foreach(_hdr include/grpcpp/server_posix.h include/grpcpp/server_posix_impl.h include/grpcpp/support/async_stream.h + include/grpcpp/support/async_stream_impl.h include/grpcpp/support/async_unary_call.h + include/grpcpp/support/async_unary_call_impl.h include/grpcpp/support/byte_buffer.h include/grpcpp/support/channel_arguments.h include/grpcpp/support/channel_arguments_impl.h include/grpcpp/support/client_callback.h + include/grpcpp/support/client_callback_impl.h include/grpcpp/support/client_interceptor.h include/grpcpp/support/config.h include/grpcpp/support/interceptor.h @@ -3217,6 +3220,7 @@ foreach(_hdr include/grpcpp/support/proto_buffer_reader.h include/grpcpp/support/proto_buffer_writer.h include/grpcpp/support/server_callback.h + include/grpcpp/support/server_callback_impl.h include/grpcpp/support/server_interceptor.h include/grpcpp/support/slice.h include/grpcpp/support/status.h @@ -3224,6 +3228,7 @@ foreach(_hdr include/grpcpp/support/string_ref.h include/grpcpp/support/stub_options.h include/grpcpp/support/sync_stream.h + include/grpcpp/support/sync_stream_impl.h include/grpcpp/support/time.h include/grpcpp/support/validate_service_config.h include/grpc/support/alloc.h @@ -3309,7 +3314,9 @@ foreach(_hdr include/grpc++/impl/codegen/time.h include/grpcpp/impl/codegen/async_generic_service.h include/grpcpp/impl/codegen/async_stream.h + include/grpcpp/impl/codegen/async_stream_impl.h include/grpcpp/impl/codegen/async_unary_call.h + include/grpcpp/impl/codegen/async_unary_call_impl.h include/grpcpp/impl/codegen/byte_buffer.h include/grpcpp/impl/codegen/call.h include/grpcpp/impl/codegen/call_hook.h @@ -3318,6 +3325,7 @@ foreach(_hdr include/grpcpp/impl/codegen/callback_common.h include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/client_callback.h + include/grpcpp/impl/codegen/client_callback_impl.h include/grpcpp/impl/codegen/client_context.h include/grpcpp/impl/codegen/client_context_impl.h include/grpcpp/impl/codegen/client_interceptor.h @@ -3340,6 +3348,7 @@ foreach(_hdr include/grpcpp/impl/codegen/security/auth_context.h include/grpcpp/impl/codegen/serialization_traits.h include/grpcpp/impl/codegen/server_callback.h + include/grpcpp/impl/codegen/server_callback_impl.h include/grpcpp/impl/codegen/server_context.h include/grpcpp/impl/codegen/server_context_impl.h include/grpcpp/impl/codegen/server_interceptor.h @@ -3351,6 +3360,7 @@ foreach(_hdr include/grpcpp/impl/codegen/string_ref.h include/grpcpp/impl/codegen/stub_options.h include/grpcpp/impl/codegen/sync_stream.h + include/grpcpp/impl/codegen/sync_stream_impl.h include/grpcpp/impl/codegen/time.h include/grpcpp/impl/codegen/sync.h include/grpc++/impl/codegen/proto_utils.h @@ -3827,11 +3837,14 @@ foreach(_hdr include/grpcpp/server_posix.h include/grpcpp/server_posix_impl.h include/grpcpp/support/async_stream.h + include/grpcpp/support/async_stream_impl.h include/grpcpp/support/async_unary_call.h + include/grpcpp/support/async_unary_call_impl.h include/grpcpp/support/byte_buffer.h include/grpcpp/support/channel_arguments.h include/grpcpp/support/channel_arguments_impl.h include/grpcpp/support/client_callback.h + include/grpcpp/support/client_callback_impl.h include/grpcpp/support/client_interceptor.h include/grpcpp/support/config.h include/grpcpp/support/interceptor.h @@ -3839,6 +3852,7 @@ foreach(_hdr include/grpcpp/support/proto_buffer_reader.h include/grpcpp/support/proto_buffer_writer.h include/grpcpp/support/server_callback.h + include/grpcpp/support/server_callback_impl.h include/grpcpp/support/server_interceptor.h include/grpcpp/support/slice.h include/grpcpp/support/status.h @@ -3846,6 +3860,7 @@ foreach(_hdr include/grpcpp/support/string_ref.h include/grpcpp/support/stub_options.h include/grpcpp/support/sync_stream.h + include/grpcpp/support/sync_stream_impl.h include/grpcpp/support/time.h include/grpcpp/support/validate_service_config.h include/grpc/support/alloc.h @@ -3931,7 +3946,9 @@ foreach(_hdr include/grpc++/impl/codegen/time.h include/grpcpp/impl/codegen/async_generic_service.h include/grpcpp/impl/codegen/async_stream.h + include/grpcpp/impl/codegen/async_stream_impl.h include/grpcpp/impl/codegen/async_unary_call.h + include/grpcpp/impl/codegen/async_unary_call_impl.h include/grpcpp/impl/codegen/byte_buffer.h include/grpcpp/impl/codegen/call.h include/grpcpp/impl/codegen/call_hook.h @@ -3940,6 +3957,7 @@ foreach(_hdr include/grpcpp/impl/codegen/callback_common.h include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/client_callback.h + include/grpcpp/impl/codegen/client_callback_impl.h include/grpcpp/impl/codegen/client_context.h include/grpcpp/impl/codegen/client_context_impl.h include/grpcpp/impl/codegen/client_interceptor.h @@ -3962,6 +3980,7 @@ foreach(_hdr include/grpcpp/impl/codegen/security/auth_context.h include/grpcpp/impl/codegen/serialization_traits.h include/grpcpp/impl/codegen/server_callback.h + include/grpcpp/impl/codegen/server_callback_impl.h include/grpcpp/impl/codegen/server_context.h include/grpcpp/impl/codegen/server_context_impl.h include/grpcpp/impl/codegen/server_interceptor.h @@ -3973,6 +3992,7 @@ foreach(_hdr include/grpcpp/impl/codegen/string_ref.h include/grpcpp/impl/codegen/stub_options.h include/grpcpp/impl/codegen/sync_stream.h + include/grpcpp/impl/codegen/sync_stream_impl.h include/grpcpp/impl/codegen/time.h include/grpcpp/impl/codegen/sync.h include/grpc/census.h @@ -4368,7 +4388,9 @@ foreach(_hdr include/grpc++/impl/codegen/time.h include/grpcpp/impl/codegen/async_generic_service.h include/grpcpp/impl/codegen/async_stream.h + include/grpcpp/impl/codegen/async_stream_impl.h include/grpcpp/impl/codegen/async_unary_call.h + include/grpcpp/impl/codegen/async_unary_call_impl.h include/grpcpp/impl/codegen/byte_buffer.h include/grpcpp/impl/codegen/call.h include/grpcpp/impl/codegen/call_hook.h @@ -4377,6 +4399,7 @@ foreach(_hdr include/grpcpp/impl/codegen/callback_common.h include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/client_callback.h + include/grpcpp/impl/codegen/client_callback_impl.h include/grpcpp/impl/codegen/client_context.h include/grpcpp/impl/codegen/client_context_impl.h include/grpcpp/impl/codegen/client_interceptor.h @@ -4399,6 +4422,7 @@ foreach(_hdr include/grpcpp/impl/codegen/security/auth_context.h include/grpcpp/impl/codegen/serialization_traits.h include/grpcpp/impl/codegen/server_callback.h + include/grpcpp/impl/codegen/server_callback_impl.h include/grpcpp/impl/codegen/server_context.h include/grpcpp/impl/codegen/server_context_impl.h include/grpcpp/impl/codegen/server_interceptor.h @@ -4410,6 +4434,7 @@ foreach(_hdr include/grpcpp/impl/codegen/string_ref.h include/grpcpp/impl/codegen/stub_options.h include/grpcpp/impl/codegen/sync_stream.h + include/grpcpp/impl/codegen/sync_stream_impl.h include/grpcpp/impl/codegen/time.h include/grpc/impl/codegen/byte_buffer.h include/grpc/impl/codegen/byte_buffer_reader.h @@ -4569,7 +4594,9 @@ foreach(_hdr include/grpc++/impl/codegen/time.h include/grpcpp/impl/codegen/async_generic_service.h include/grpcpp/impl/codegen/async_stream.h + include/grpcpp/impl/codegen/async_stream_impl.h include/grpcpp/impl/codegen/async_unary_call.h + include/grpcpp/impl/codegen/async_unary_call_impl.h include/grpcpp/impl/codegen/byte_buffer.h include/grpcpp/impl/codegen/call.h include/grpcpp/impl/codegen/call_hook.h @@ -4578,6 +4605,7 @@ foreach(_hdr include/grpcpp/impl/codegen/callback_common.h include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/client_callback.h + include/grpcpp/impl/codegen/client_callback_impl.h include/grpcpp/impl/codegen/client_context.h include/grpcpp/impl/codegen/client_context_impl.h include/grpcpp/impl/codegen/client_interceptor.h @@ -4600,6 +4628,7 @@ foreach(_hdr include/grpcpp/impl/codegen/security/auth_context.h include/grpcpp/impl/codegen/serialization_traits.h include/grpcpp/impl/codegen/server_callback.h + include/grpcpp/impl/codegen/server_callback_impl.h include/grpcpp/impl/codegen/server_context.h include/grpcpp/impl/codegen/server_context_impl.h include/grpcpp/impl/codegen/server_interceptor.h @@ -4611,6 +4640,7 @@ foreach(_hdr include/grpcpp/impl/codegen/string_ref.h include/grpcpp/impl/codegen/stub_options.h include/grpcpp/impl/codegen/sync_stream.h + include/grpcpp/impl/codegen/sync_stream_impl.h include/grpcpp/impl/codegen/time.h include/grpc/impl/codegen/byte_buffer.h include/grpc/impl/codegen/byte_buffer_reader.h @@ -4827,11 +4857,14 @@ foreach(_hdr include/grpcpp/server_posix.h include/grpcpp/server_posix_impl.h include/grpcpp/support/async_stream.h + include/grpcpp/support/async_stream_impl.h include/grpcpp/support/async_unary_call.h + include/grpcpp/support/async_unary_call_impl.h include/grpcpp/support/byte_buffer.h include/grpcpp/support/channel_arguments.h include/grpcpp/support/channel_arguments_impl.h include/grpcpp/support/client_callback.h + include/grpcpp/support/client_callback_impl.h include/grpcpp/support/client_interceptor.h include/grpcpp/support/config.h include/grpcpp/support/interceptor.h @@ -4839,6 +4872,7 @@ foreach(_hdr include/grpcpp/support/proto_buffer_reader.h include/grpcpp/support/proto_buffer_writer.h include/grpcpp/support/server_callback.h + include/grpcpp/support/server_callback_impl.h include/grpcpp/support/server_interceptor.h include/grpcpp/support/slice.h include/grpcpp/support/status.h @@ -4846,6 +4880,7 @@ foreach(_hdr include/grpcpp/support/string_ref.h include/grpcpp/support/stub_options.h include/grpcpp/support/sync_stream.h + include/grpcpp/support/sync_stream_impl.h include/grpcpp/support/time.h include/grpcpp/support/validate_service_config.h include/grpc/support/alloc.h @@ -4931,7 +4966,9 @@ foreach(_hdr include/grpc++/impl/codegen/time.h include/grpcpp/impl/codegen/async_generic_service.h include/grpcpp/impl/codegen/async_stream.h + include/grpcpp/impl/codegen/async_stream_impl.h include/grpcpp/impl/codegen/async_unary_call.h + include/grpcpp/impl/codegen/async_unary_call_impl.h include/grpcpp/impl/codegen/byte_buffer.h include/grpcpp/impl/codegen/call.h include/grpcpp/impl/codegen/call_hook.h @@ -4940,6 +4977,7 @@ foreach(_hdr include/grpcpp/impl/codegen/callback_common.h include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/client_callback.h + include/grpcpp/impl/codegen/client_callback_impl.h include/grpcpp/impl/codegen/client_context.h include/grpcpp/impl/codegen/client_context_impl.h include/grpcpp/impl/codegen/client_interceptor.h @@ -4962,6 +5000,7 @@ foreach(_hdr include/grpcpp/impl/codegen/security/auth_context.h include/grpcpp/impl/codegen/serialization_traits.h include/grpcpp/impl/codegen/server_callback.h + include/grpcpp/impl/codegen/server_callback_impl.h include/grpcpp/impl/codegen/server_context.h include/grpcpp/impl/codegen/server_context_impl.h include/grpcpp/impl/codegen/server_interceptor.h @@ -4973,6 +5012,7 @@ foreach(_hdr include/grpcpp/impl/codegen/string_ref.h include/grpcpp/impl/codegen/stub_options.h include/grpcpp/impl/codegen/sync_stream.h + include/grpcpp/impl/codegen/sync_stream_impl.h include/grpcpp/impl/codegen/time.h include/grpcpp/impl/codegen/sync.h ) diff --git a/Makefile b/Makefile index 15d4ede0670..44c428afdb1 100644 --- a/Makefile +++ b/Makefile @@ -5582,11 +5582,14 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ include/grpcpp/support/async_stream.h \ + include/grpcpp/support/async_stream_impl.h \ include/grpcpp/support/async_unary_call.h \ + include/grpcpp/support/async_unary_call_impl.h \ include/grpcpp/support/byte_buffer.h \ include/grpcpp/support/channel_arguments.h \ include/grpcpp/support/channel_arguments_impl.h \ include/grpcpp/support/client_callback.h \ + include/grpcpp/support/client_callback_impl.h \ include/grpcpp/support/client_interceptor.h \ include/grpcpp/support/config.h \ include/grpcpp/support/interceptor.h \ @@ -5594,6 +5597,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/support/proto_buffer_reader.h \ include/grpcpp/support/proto_buffer_writer.h \ include/grpcpp/support/server_callback.h \ + include/grpcpp/support/server_callback_impl.h \ include/grpcpp/support/server_interceptor.h \ include/grpcpp/support/slice.h \ include/grpcpp/support/status.h \ @@ -5601,6 +5605,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/support/string_ref.h \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ + include/grpcpp/support/sync_stream_impl.h \ include/grpcpp/support/time.h \ include/grpcpp/support/validate_service_config.h \ include/grpc/support/alloc.h \ @@ -5686,7 +5691,9 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/time.h \ include/grpcpp/impl/codegen/async_generic_service.h \ include/grpcpp/impl/codegen/async_stream.h \ + include/grpcpp/impl/codegen/async_stream_impl.h \ include/grpcpp/impl/codegen/async_unary_call.h \ + include/grpcpp/impl/codegen/async_unary_call_impl.h \ include/grpcpp/impl/codegen/byte_buffer.h \ include/grpcpp/impl/codegen/call.h \ include/grpcpp/impl/codegen/call_hook.h \ @@ -5695,6 +5702,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/callback_common.h \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ + include/grpcpp/impl/codegen/client_callback_impl.h \ include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ @@ -5717,6 +5725,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/security/auth_context.h \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ + include/grpcpp/impl/codegen/server_callback_impl.h \ include/grpcpp/impl/codegen/server_context.h \ include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ @@ -5728,6 +5737,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/string_ref.h \ include/grpcpp/impl/codegen/stub_options.h \ include/grpcpp/impl/codegen/sync_stream.h \ + include/grpcpp/impl/codegen/sync_stream_impl.h \ include/grpcpp/impl/codegen/time.h \ include/grpcpp/impl/codegen/sync.h \ include/grpc++/impl/codegen/proto_utils.h \ @@ -6212,11 +6222,14 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ include/grpcpp/support/async_stream.h \ + include/grpcpp/support/async_stream_impl.h \ include/grpcpp/support/async_unary_call.h \ + include/grpcpp/support/async_unary_call_impl.h \ include/grpcpp/support/byte_buffer.h \ include/grpcpp/support/channel_arguments.h \ include/grpcpp/support/channel_arguments_impl.h \ include/grpcpp/support/client_callback.h \ + include/grpcpp/support/client_callback_impl.h \ include/grpcpp/support/client_interceptor.h \ include/grpcpp/support/config.h \ include/grpcpp/support/interceptor.h \ @@ -6224,6 +6237,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/support/proto_buffer_reader.h \ include/grpcpp/support/proto_buffer_writer.h \ include/grpcpp/support/server_callback.h \ + include/grpcpp/support/server_callback_impl.h \ include/grpcpp/support/server_interceptor.h \ include/grpcpp/support/slice.h \ include/grpcpp/support/status.h \ @@ -6231,6 +6245,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/support/string_ref.h \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ + include/grpcpp/support/sync_stream_impl.h \ include/grpcpp/support/time.h \ include/grpcpp/support/validate_service_config.h \ include/grpc/support/alloc.h \ @@ -6316,7 +6331,9 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/time.h \ include/grpcpp/impl/codegen/async_generic_service.h \ include/grpcpp/impl/codegen/async_stream.h \ + include/grpcpp/impl/codegen/async_stream_impl.h \ include/grpcpp/impl/codegen/async_unary_call.h \ + include/grpcpp/impl/codegen/async_unary_call_impl.h \ include/grpcpp/impl/codegen/byte_buffer.h \ include/grpcpp/impl/codegen/call.h \ include/grpcpp/impl/codegen/call_hook.h \ @@ -6325,6 +6342,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/callback_common.h \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ + include/grpcpp/impl/codegen/client_callback_impl.h \ include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ @@ -6347,6 +6365,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/security/auth_context.h \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ + include/grpcpp/impl/codegen/server_callback_impl.h \ include/grpcpp/impl/codegen/server_context.h \ include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ @@ -6358,6 +6377,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/string_ref.h \ include/grpcpp/impl/codegen/stub_options.h \ include/grpcpp/impl/codegen/sync_stream.h \ + include/grpcpp/impl/codegen/sync_stream_impl.h \ include/grpcpp/impl/codegen/time.h \ include/grpcpp/impl/codegen/sync.h \ include/grpc/census.h \ @@ -6725,7 +6745,9 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/time.h \ include/grpcpp/impl/codegen/async_generic_service.h \ include/grpcpp/impl/codegen/async_stream.h \ + include/grpcpp/impl/codegen/async_stream_impl.h \ include/grpcpp/impl/codegen/async_unary_call.h \ + include/grpcpp/impl/codegen/async_unary_call_impl.h \ include/grpcpp/impl/codegen/byte_buffer.h \ include/grpcpp/impl/codegen/call.h \ include/grpcpp/impl/codegen/call_hook.h \ @@ -6734,6 +6756,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/callback_common.h \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ + include/grpcpp/impl/codegen/client_callback_impl.h \ include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ @@ -6756,6 +6779,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/security/auth_context.h \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ + include/grpcpp/impl/codegen/server_callback_impl.h \ include/grpcpp/impl/codegen/server_context.h \ include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ @@ -6767,6 +6791,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/string_ref.h \ include/grpcpp/impl/codegen/stub_options.h \ include/grpcpp/impl/codegen/sync_stream.h \ + include/grpcpp/impl/codegen/sync_stream_impl.h \ include/grpcpp/impl/codegen/time.h \ include/grpc/impl/codegen/byte_buffer.h \ include/grpc/impl/codegen/byte_buffer_reader.h \ @@ -6897,7 +6922,9 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/time.h \ include/grpcpp/impl/codegen/async_generic_service.h \ include/grpcpp/impl/codegen/async_stream.h \ + include/grpcpp/impl/codegen/async_stream_impl.h \ include/grpcpp/impl/codegen/async_unary_call.h \ + include/grpcpp/impl/codegen/async_unary_call_impl.h \ include/grpcpp/impl/codegen/byte_buffer.h \ include/grpcpp/impl/codegen/call.h \ include/grpcpp/impl/codegen/call_hook.h \ @@ -6906,6 +6933,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/callback_common.h \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ + include/grpcpp/impl/codegen/client_callback_impl.h \ include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ @@ -6928,6 +6956,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/security/auth_context.h \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ + include/grpcpp/impl/codegen/server_callback_impl.h \ include/grpcpp/impl/codegen/server_context.h \ include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ @@ -6939,6 +6968,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/string_ref.h \ include/grpcpp/impl/codegen/stub_options.h \ include/grpcpp/impl/codegen/sync_stream.h \ + include/grpcpp/impl/codegen/sync_stream_impl.h \ include/grpcpp/impl/codegen/time.h \ include/grpc/impl/codegen/byte_buffer.h \ include/grpc/impl/codegen/byte_buffer_reader.h \ @@ -7161,11 +7191,14 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ include/grpcpp/support/async_stream.h \ + include/grpcpp/support/async_stream_impl.h \ include/grpcpp/support/async_unary_call.h \ + include/grpcpp/support/async_unary_call_impl.h \ include/grpcpp/support/byte_buffer.h \ include/grpcpp/support/channel_arguments.h \ include/grpcpp/support/channel_arguments_impl.h \ include/grpcpp/support/client_callback.h \ + include/grpcpp/support/client_callback_impl.h \ include/grpcpp/support/client_interceptor.h \ include/grpcpp/support/config.h \ include/grpcpp/support/interceptor.h \ @@ -7173,6 +7206,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/support/proto_buffer_reader.h \ include/grpcpp/support/proto_buffer_writer.h \ include/grpcpp/support/server_callback.h \ + include/grpcpp/support/server_callback_impl.h \ include/grpcpp/support/server_interceptor.h \ include/grpcpp/support/slice.h \ include/grpcpp/support/status.h \ @@ -7180,6 +7214,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/support/string_ref.h \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ + include/grpcpp/support/sync_stream_impl.h \ include/grpcpp/support/time.h \ include/grpcpp/support/validate_service_config.h \ include/grpc/support/alloc.h \ @@ -7265,7 +7300,9 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/time.h \ include/grpcpp/impl/codegen/async_generic_service.h \ include/grpcpp/impl/codegen/async_stream.h \ + include/grpcpp/impl/codegen/async_stream_impl.h \ include/grpcpp/impl/codegen/async_unary_call.h \ + include/grpcpp/impl/codegen/async_unary_call_impl.h \ include/grpcpp/impl/codegen/byte_buffer.h \ include/grpcpp/impl/codegen/call.h \ include/grpcpp/impl/codegen/call_hook.h \ @@ -7274,6 +7311,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/callback_common.h \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ + include/grpcpp/impl/codegen/client_callback_impl.h \ include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ @@ -7296,6 +7334,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/security/auth_context.h \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ + include/grpcpp/impl/codegen/server_callback_impl.h \ include/grpcpp/impl/codegen/server_context.h \ include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ @@ -7307,6 +7346,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/string_ref.h \ include/grpcpp/impl/codegen/stub_options.h \ include/grpcpp/impl/codegen/sync_stream.h \ + include/grpcpp/impl/codegen/sync_stream_impl.h \ include/grpcpp/impl/codegen/time.h \ include/grpcpp/impl/codegen/sync.h \ diff --git a/build.yaml b/build.yaml index d342e88d24c..8e769ed9923 100644 --- a/build.yaml +++ b/build.yaml @@ -1250,7 +1250,9 @@ filegroups: - include/grpc++/impl/codegen/time.h - include/grpcpp/impl/codegen/async_generic_service.h - include/grpcpp/impl/codegen/async_stream.h + - include/grpcpp/impl/codegen/async_stream_impl.h - include/grpcpp/impl/codegen/async_unary_call.h + - include/grpcpp/impl/codegen/async_unary_call_impl.h - include/grpcpp/impl/codegen/byte_buffer.h - include/grpcpp/impl/codegen/call.h - include/grpcpp/impl/codegen/call_hook.h @@ -1259,6 +1261,7 @@ filegroups: - include/grpcpp/impl/codegen/callback_common.h - include/grpcpp/impl/codegen/channel_interface.h - include/grpcpp/impl/codegen/client_callback.h + - include/grpcpp/impl/codegen/client_callback_impl.h - include/grpcpp/impl/codegen/client_context.h - include/grpcpp/impl/codegen/client_context_impl.h - include/grpcpp/impl/codegen/client_interceptor.h @@ -1281,6 +1284,7 @@ filegroups: - include/grpcpp/impl/codegen/security/auth_context.h - include/grpcpp/impl/codegen/serialization_traits.h - include/grpcpp/impl/codegen/server_callback.h + - include/grpcpp/impl/codegen/server_callback_impl.h - include/grpcpp/impl/codegen/server_context.h - include/grpcpp/impl/codegen/server_context_impl.h - include/grpcpp/impl/codegen/server_interceptor.h @@ -1292,6 +1296,7 @@ filegroups: - include/grpcpp/impl/codegen/string_ref.h - include/grpcpp/impl/codegen/stub_options.h - include/grpcpp/impl/codegen/sync_stream.h + - include/grpcpp/impl/codegen/sync_stream_impl.h - include/grpcpp/impl/codegen/time.h uses: - grpc_codegen @@ -1410,11 +1415,14 @@ filegroups: - include/grpcpp/server_posix.h - include/grpcpp/server_posix_impl.h - include/grpcpp/support/async_stream.h + - include/grpcpp/support/async_stream_impl.h - include/grpcpp/support/async_unary_call.h + - include/grpcpp/support/async_unary_call_impl.h - include/grpcpp/support/byte_buffer.h - include/grpcpp/support/channel_arguments.h - include/grpcpp/support/channel_arguments_impl.h - include/grpcpp/support/client_callback.h + - include/grpcpp/support/client_callback_impl.h - include/grpcpp/support/client_interceptor.h - include/grpcpp/support/config.h - include/grpcpp/support/interceptor.h @@ -1422,6 +1430,7 @@ filegroups: - include/grpcpp/support/proto_buffer_reader.h - include/grpcpp/support/proto_buffer_writer.h - include/grpcpp/support/server_callback.h + - include/grpcpp/support/server_callback_impl.h - include/grpcpp/support/server_interceptor.h - include/grpcpp/support/slice.h - include/grpcpp/support/status.h @@ -1429,6 +1438,7 @@ filegroups: - include/grpcpp/support/string_ref.h - include/grpcpp/support/stub_options.h - include/grpcpp/support/sync_stream.h + - include/grpcpp/support/sync_stream_impl.h - include/grpcpp/support/time.h - include/grpcpp/support/validate_service_config.h headers: diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 6fc97c6135e..ad396396843 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -129,11 +129,14 @@ Pod::Spec.new do |s| 'include/grpcpp/server_posix.h', 'include/grpcpp/server_posix_impl.h', 'include/grpcpp/support/async_stream.h', + 'include/grpcpp/support/async_stream_impl.h', 'include/grpcpp/support/async_unary_call.h', + 'include/grpcpp/support/async_unary_call_impl.h', 'include/grpcpp/support/byte_buffer.h', 'include/grpcpp/support/channel_arguments.h', 'include/grpcpp/support/channel_arguments_impl.h', 'include/grpcpp/support/client_callback.h', + 'include/grpcpp/support/client_callback_impl.h', 'include/grpcpp/support/client_interceptor.h', 'include/grpcpp/support/config.h', 'include/grpcpp/support/interceptor.h', @@ -141,6 +144,7 @@ Pod::Spec.new do |s| 'include/grpcpp/support/proto_buffer_reader.h', 'include/grpcpp/support/proto_buffer_writer.h', 'include/grpcpp/support/server_callback.h', + 'include/grpcpp/support/server_callback_impl.h', 'include/grpcpp/support/server_interceptor.h', 'include/grpcpp/support/slice.h', 'include/grpcpp/support/status.h', @@ -148,11 +152,14 @@ Pod::Spec.new do |s| 'include/grpcpp/support/string_ref.h', 'include/grpcpp/support/stub_options.h', 'include/grpcpp/support/sync_stream.h', + 'include/grpcpp/support/sync_stream_impl.h', 'include/grpcpp/support/time.h', 'include/grpcpp/support/validate_service_config.h', 'include/grpcpp/impl/codegen/async_generic_service.h', 'include/grpcpp/impl/codegen/async_stream.h', + 'include/grpcpp/impl/codegen/async_stream_impl.h', 'include/grpcpp/impl/codegen/async_unary_call.h', + 'include/grpcpp/impl/codegen/async_unary_call_impl.h', 'include/grpcpp/impl/codegen/byte_buffer.h', 'include/grpcpp/impl/codegen/call.h', 'include/grpcpp/impl/codegen/call_hook.h', @@ -161,6 +168,7 @@ Pod::Spec.new do |s| 'include/grpcpp/impl/codegen/callback_common.h', 'include/grpcpp/impl/codegen/channel_interface.h', 'include/grpcpp/impl/codegen/client_callback.h', + 'include/grpcpp/impl/codegen/client_callback_impl.h', 'include/grpcpp/impl/codegen/client_context.h', 'include/grpcpp/impl/codegen/client_context_impl.h', 'include/grpcpp/impl/codegen/client_interceptor.h', @@ -183,6 +191,7 @@ Pod::Spec.new do |s| 'include/grpcpp/impl/codegen/security/auth_context.h', 'include/grpcpp/impl/codegen/serialization_traits.h', 'include/grpcpp/impl/codegen/server_callback.h', + 'include/grpcpp/impl/codegen/server_callback_impl.h', 'include/grpcpp/impl/codegen/server_context.h', 'include/grpcpp/impl/codegen/server_context_impl.h', 'include/grpcpp/impl/codegen/server_interceptor.h', @@ -194,6 +203,7 @@ Pod::Spec.new do |s| 'include/grpcpp/impl/codegen/string_ref.h', 'include/grpcpp/impl/codegen/stub_options.h', 'include/grpcpp/impl/codegen/sync_stream.h', + 'include/grpcpp/impl/codegen/sync_stream_impl.h', 'include/grpcpp/impl/codegen/time.h', 'include/grpcpp/impl/codegen/sync.h' end diff --git a/include/grpcpp/channel_impl.h b/include/grpcpp/channel_impl.h index a7eee2b8981..9ff3118645f 100644 --- a/include/grpcpp/channel_impl.h +++ b/include/grpcpp/channel_impl.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -86,22 +86,23 @@ class Channel final : public ::grpc::ChannelInterface, ::grpc::internal::Call CreateCall(const ::grpc::internal::RpcMethod& method, ::grpc_impl::ClientContext* context, - ::grpc::CompletionQueue* cq) override; + ::grpc_impl::CompletionQueue* cq) override; void PerformOpsOnCall(::grpc::internal::CallOpSetInterface* ops, ::grpc::internal::Call* call) override; void* RegisterMethod(const char* method) override; void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline, - ::grpc::CompletionQueue* cq, void* tag) override; + ::grpc_impl::CompletionQueue* cq, + void* tag) override; bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline) override; - ::grpc::CompletionQueue* CallbackCQ() override; + ::grpc_impl::CompletionQueue* CallbackCQ() override; ::grpc::internal::Call CreateCallInternal( const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, ::grpc::CompletionQueue* cq, + ::grpc_impl::ClientContext* context, ::grpc_impl::CompletionQueue* cq, size_t interceptor_pos) override; const grpc::string host_; @@ -114,7 +115,7 @@ class Channel final : public ::grpc::ChannelInterface, // with this channel (if any). It is set on the first call to CallbackCQ(). // It is _not owned_ by the channel; ownership belongs with its internal // shutdown callback tag (invoked when the CQ is fully shutdown). - ::grpc::CompletionQueue* callback_cq_ = nullptr; + ::grpc_impl::CompletionQueue* callback_cq_ = nullptr; std::vector< std::unique_ptr<::grpc::experimental::ClientInterceptorFactoryInterface>> diff --git a/include/grpcpp/generic/generic_stub_impl.h b/include/grpcpp/generic/generic_stub_impl.h index fdbc0d0a272..e670fcaa654 100644 --- a/include/grpcpp/generic/generic_stub_impl.h +++ b/include/grpcpp/generic/generic_stub_impl.h @@ -22,17 +22,20 @@ #include #include -#include -#include +#include +#include #include -#include +#include #include +#include + namespace grpc { -typedef ClientAsyncReaderWriter +typedef ::grpc_impl::ClientAsyncReaderWriter GenericClientAsyncReaderWriter; -typedef ClientAsyncResponseReader GenericClientAsyncResponseReader; +typedef ::grpc_impl::ClientAsyncResponseReader + GenericClientAsyncResponseReader; } // namespace grpc namespace grpc_impl { class CompletionQueue; @@ -50,15 +53,15 @@ class GenericStub final { /// succeeded (i.e. the call won't proceed if the return value is nullptr). std::unique_ptr PrepareCall( grpc::ClientContext* context, const grpc::string& method, - grpc::CompletionQueue* cq); + CompletionQueue* cq); /// Setup a unary call to a named method \a method using \a context, and don't /// start it. Let it be started explicitly with StartCall. /// The return value only indicates whether or not registration of the call /// succeeded (i.e. the call won't proceed if the return value is nullptr). std::unique_ptr PrepareUnaryCall( - grpc::ClientContext* context, const grpc::string& method, - const grpc::ByteBuffer& request, grpc::CompletionQueue* cq); + grpc_impl::ClientContext* context, const grpc::string& method, + const grpc::ByteBuffer& request, CompletionQueue* cq); /// DEPRECATED for multi-threaded use /// Begin a call to a named method \a method using \a context. @@ -67,8 +70,8 @@ class GenericStub final { /// The return value only indicates whether or not registration of the call /// succeeded (i.e. the call won't proceed if the return value is nullptr). std::unique_ptr Call( - grpc::ClientContext* context, const grpc::string& method, - grpc::CompletionQueue* cq, void* tag); + grpc_impl::ClientContext* context, const grpc::string& method, + CompletionQueue* cq, void* tag); /// NOTE: class experimental_type is not part of the public API of this class /// TODO(vjpai): Move these contents to the public API of GenericStub when @@ -79,23 +82,25 @@ class GenericStub final { /// Setup and start a unary call to a named method \a method using /// \a context and specifying the \a request and \a response buffers. - void UnaryCall(grpc::ClientContext* context, const grpc::string& method, - const grpc::ByteBuffer* request, grpc::ByteBuffer* response, + void UnaryCall(grpc_impl::ClientContext* context, + const grpc::string& method, const grpc::ByteBuffer* request, + grpc::ByteBuffer* response, std::function on_completion); /// Setup and start a unary call to a named method \a method using /// \a context and specifying the \a request and \a response buffers. - void UnaryCall(grpc::ClientContext* context, const grpc::string& method, - const grpc::ByteBuffer* request, grpc::ByteBuffer* response, - grpc::experimental::ClientUnaryReactor* reactor); + void UnaryCall(grpc_impl::ClientContext* context, + const grpc::string& method, const grpc::ByteBuffer* request, + grpc::ByteBuffer* response, + grpc_impl::experimental::ClientUnaryReactor* reactor); /// Setup a call to a named method \a method using \a context and tied to /// \a reactor . Like any other bidi streaming RPC, it will not be activated /// until StartCall is invoked on its reactor. void PrepareBidiStreamingCall( - grpc::ClientContext* context, const grpc::string& method, - grpc::experimental::ClientBidiReactor* reactor); + grpc_impl::ClientContext* context, const grpc::string& method, + grpc_impl::experimental::ClientBidiReactor* reactor); private: GenericStub* stub_; diff --git a/include/grpcpp/impl/codegen/async_generic_service.h b/include/grpcpp/impl/codegen/async_generic_service.h index d8e6f49b2f3..7c720ce3c23 100644 --- a/include/grpcpp/impl/codegen/async_generic_service.h +++ b/include/grpcpp/impl/codegen/async_generic_service.h @@ -19,19 +19,21 @@ #ifndef GRPCPP_IMPL_CODEGEN_ASYNC_GENERIC_SERVICE_H #define GRPCPP_IMPL_CODEGEN_ASYNC_GENERIC_SERVICE_H -#include +#include #include -#include +#include struct grpc_server; namespace grpc { -typedef ServerAsyncReaderWriter +typedef ::grpc_impl::ServerAsyncReaderWriter GenericServerAsyncReaderWriter; -typedef ServerAsyncResponseWriter GenericServerAsyncResponseWriter; -typedef ServerAsyncReader GenericServerAsyncReader; -typedef ServerAsyncWriter GenericServerAsyncWriter; +typedef ::grpc_impl::ServerAsyncResponseWriter + GenericServerAsyncResponseWriter; +typedef ::grpc_impl::ServerAsyncReader + GenericServerAsyncReader; +typedef ::grpc_impl::ServerAsyncWriter GenericServerAsyncWriter; class GenericServerContext final : public ::grpc_impl::ServerContext { public: @@ -75,8 +77,9 @@ class AsyncGenericService final { void RequestCall(GenericServerContext* ctx, GenericServerAsyncReaderWriter* reader_writer, - CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag); + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag); private: friend class grpc_impl::Server; @@ -91,7 +94,8 @@ namespace experimental { /// GenericServerContext rather than a ServerContext. All other reaction and /// operation initiation APIs are the same as ServerBidiReactor. class ServerGenericBidiReactor - : public ServerBidiReactor { + : public ::grpc_impl::experimental::ServerBidiReactor { public: /// Similar to ServerBidiReactor::OnStarted except for argument type. /// @@ -137,8 +141,10 @@ class CallbackGenericService { private: friend class ::grpc_impl::Server; - internal::CallbackBidiHandler* Handler() { - return new internal::CallbackBidiHandler( + ::grpc_impl::internal::CallbackBidiHandler* + Handler() { + return new ::grpc_impl::internal::CallbackBidiHandler( [this] { return CreateReactor(); }); } diff --git a/include/grpcpp/impl/codegen/async_stream.h b/include/grpcpp/impl/codegen/async_stream.h index 417dceb587f..14dfe67962e 100644 --- a/include/grpcpp/impl/codegen/async_stream.h +++ b/include/grpcpp/impl/codegen/async_stream.h @@ -19,1117 +19,47 @@ #ifndef GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H #define GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H -#include -#include -#include -#include -#include -#include +#include namespace grpc { - -namespace internal { -/// Common interface for all client side asynchronous streaming. -class ClientAsyncStreamingInterface { - public: - virtual ~ClientAsyncStreamingInterface() {} - - /// Start the call that was set up by the constructor, but only if the - /// constructor was invoked through the "Prepare" API which doesn't actually - /// start the call - virtual void StartCall(void* tag) = 0; - - /// Request notification of the reading of the initial metadata. Completion - /// will be notified by \a tag on the associated completion queue. - /// This call is optional, but if it is used, it cannot be used concurrently - /// with or after the \a AsyncReaderInterface::Read method. - /// - /// \param[in] tag Tag identifying this request. - virtual void ReadInitialMetadata(void* tag) = 0; - - /// Indicate that the stream is to be finished and request notification for - /// when the call has been ended. - /// Should not be used concurrently with other operations. - /// - /// It is appropriate to call this method when both: - /// * the client side has no more message to send - /// (this can be declared implicitly by calling this method, or - /// explicitly through an earlier call to the WritesDone method - /// of the class in use, e.g. \a ClientAsyncWriterInterface::WritesDone or - /// \a ClientAsyncReaderWriterInterface::WritesDone). - /// * there are no more messages to be received from the server (this can - /// be known implicitly by the calling code, or explicitly from an - /// earlier call to \a AsyncReaderInterface::Read that yielded a failed - /// result, e.g. cq->Next(&read_tag, &ok) filled in 'ok' with 'false'). - /// - /// The tag will be returned when either: - /// - all incoming messages have been read and the server has returned - /// a status. - /// - the server has returned a non-OK status. - /// - the call failed for some reason and the library generated a - /// status. - /// - /// Note that implementations of this method attempt to receive initial - /// metadata from the server if initial metadata hasn't yet been received. - /// - /// \param[in] tag Tag identifying this request. - /// \param[out] status To be updated with the operation status. - virtual void Finish(Status* status, void* tag) = 0; -}; - -/// An interface that yields a sequence of messages of type \a R. template -class AsyncReaderInterface { - public: - virtual ~AsyncReaderInterface() {} - - /// Read a message of type \a R into \a msg. Completion will be notified by \a - /// tag on the associated completion queue. - /// This is thread-safe with respect to \a Write or \a WritesDone methods. It - /// should not be called concurrently with other streaming APIs - /// on the same stream. It is not meaningful to call it concurrently - /// with another \a AsyncReaderInterface::Read on the same stream since reads - /// on the same stream are delivered in order. - /// - /// \param[out] msg Where to eventually store the read message. - /// \param[in] tag The tag identifying the operation. - /// - /// Side effect: note that this method attempt to receive initial metadata for - /// a stream if it hasn't yet been received. - virtual void Read(R* msg, void* tag) = 0; -}; - -/// An interface that can be fed a sequence of messages of type \a W. -template -class AsyncWriterInterface { - public: - virtual ~AsyncWriterInterface() {} - - /// Request the writing of \a msg with identifying tag \a tag. - /// - /// Only one write may be outstanding at any given time. This means that - /// after calling Write, one must wait to receive \a tag from the completion - /// queue BEFORE calling Write again. - /// This is thread-safe with respect to \a AsyncReaderInterface::Read - /// - /// gRPC doesn't take ownership or a reference to \a msg, so it is safe to - /// to deallocate once Write returns. - /// - /// \param[in] msg The message to be written. - /// \param[in] tag The tag identifying the operation. - virtual void Write(const W& msg, void* tag) = 0; - - /// Request the writing of \a msg using WriteOptions \a options with - /// identifying tag \a tag. - /// - /// Only one write may be outstanding at any given time. This means that - /// after calling Write, one must wait to receive \a tag from the completion - /// queue BEFORE calling Write again. - /// WriteOptions \a options is used to set the write options of this message. - /// This is thread-safe with respect to \a AsyncReaderInterface::Read - /// - /// gRPC doesn't take ownership or a reference to \a msg, so it is safe to - /// to deallocate once Write returns. - /// - /// \param[in] msg The message to be written. - /// \param[in] options The WriteOptions to be used to write this message. - /// \param[in] tag The tag identifying the operation. - virtual void Write(const W& msg, WriteOptions options, void* tag) = 0; - - /// Request the writing of \a msg and coalesce it with the writing - /// of trailing metadata, using WriteOptions \a options with - /// identifying tag \a tag. - /// - /// For client, WriteLast is equivalent of performing Write and - /// WritesDone in a single step. - /// For server, WriteLast buffers the \a msg. The writing of \a msg is held - /// until Finish is called, where \a msg and trailing metadata are coalesced - /// and write is initiated. Note that WriteLast can only buffer \a msg up to - /// the flow control window size. If \a msg size is larger than the window - /// size, it will be sent on wire without buffering. - /// - /// gRPC doesn't take ownership or a reference to \a msg, so it is safe to - /// to deallocate once Write returns. - /// - /// \param[in] msg The message to be written. - /// \param[in] options The WriteOptions to be used to write this message. - /// \param[in] tag The tag identifying the operation. - void WriteLast(const W& msg, WriteOptions options, void* tag) { - Write(msg, options.set_last_message(), tag); - } -}; - -} // namespace internal +using ClientAsyncReaderInterface = ::grpc_impl::ClientAsyncReaderInterface; template -class ClientAsyncReaderInterface - : public internal::ClientAsyncStreamingInterface, - public internal::AsyncReaderInterface {}; - -namespace internal { -template -class ClientAsyncReaderFactory { - public: - /// Create a stream object. - /// Write the first request out if \a start is set. - /// \a tag will be notified on \a cq when the call has been started and - /// \a request has been written out. If \a start is not set, \a tag must be - /// nullptr and the actual call must be initiated by StartCall - /// Note that \a context will be used to fill in custom initial metadata - /// used to send to the server when starting the call. - template - static ClientAsyncReader* Create(ChannelInterface* channel, - CompletionQueue* cq, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, - const W& request, bool start, void* tag) { - ::grpc::internal::Call call = channel->CreateCall(method, context, cq); - return new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(ClientAsyncReader))) - ClientAsyncReader(call, context, request, start, tag); - } -}; -} // namespace internal - -/// Async client-side API for doing server-streaming RPCs, -/// where the incoming message stream coming from the server has -/// messages of type \a R. -template -class ClientAsyncReader final : public ClientAsyncReaderInterface { - public: - // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { - assert(size == sizeof(ClientAsyncReader)); - } - - // This operator should never be called as the memory should be freed as part - // of the arena destruction. It only exists to provide a matching operator - // delete to the operator new so that some compilers will not complain (see - // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this - // there are no tests catching the compiler warning. - static void operator delete(void*, void*) { assert(0); } - - void StartCall(void* tag) override { - assert(!started_); - started_ = true; - StartCallInternal(tag); - } - - /// See the \a ClientAsyncStreamingInterface.ReadInitialMetadata - /// method for semantics. - /// - /// Side effect: - /// - upon receiving initial metadata from the server, - /// the \a ClientContext associated with this call is updated, and the - /// calling code can access the received metadata through the - /// \a ClientContext. - void ReadInitialMetadata(void* tag) override { - assert(started_); - GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); - - meta_ops_.set_output_tag(tag); - meta_ops_.RecvInitialMetadata(context_); - call_.PerformOps(&meta_ops_); - } - - void Read(R* msg, void* tag) override { - assert(started_); - read_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - read_ops_.RecvInitialMetadata(context_); - } - read_ops_.RecvMessage(msg); - call_.PerformOps(&read_ops_); - } - - /// See the \a ClientAsyncStreamingInterface.Finish method for semantics. - /// - /// Side effect: - /// - the \a ClientContext associated with this call is updated with - /// possible initial and trailing metadata received from the server. - void Finish(Status* status, void* tag) override { - assert(started_); - finish_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - finish_ops_.RecvInitialMetadata(context_); - } - finish_ops_.ClientRecvStatus(context_, status); - call_.PerformOps(&finish_ops_); - } - - private: - friend class internal::ClientAsyncReaderFactory; - template - ClientAsyncReader(::grpc::internal::Call call, - ::grpc_impl::ClientContext* context, const W& request, - bool start, void* tag) - : context_(context), call_(call), started_(start) { - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(init_ops_.SendMessage(request).ok()); - init_ops_.ClientSendClose(); - if (start) { - StartCallInternal(tag); - } else { - assert(tag == nullptr); - } - } - - void StartCallInternal(void* tag) { - init_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - init_ops_.set_output_tag(tag); - call_.PerformOps(&init_ops_); - } - - ::grpc_impl::ClientContext* context_; - ::grpc::internal::Call call_; - bool started_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpClientSendClose> - init_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> - meta_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpRecvMessage> - read_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpClientRecvStatus> - finish_ops_; -}; - -/// Common interface for client side asynchronous writing. -template -class ClientAsyncWriterInterface - : public internal::ClientAsyncStreamingInterface, - public internal::AsyncWriterInterface { - public: - /// Signal the client is done with the writes (half-close the client stream). - /// Thread-safe with respect to \a AsyncReaderInterface::Read - /// - /// \param[in] tag The tag identifying the operation. - virtual void WritesDone(void* tag) = 0; -}; - -namespace internal { -template -class ClientAsyncWriterFactory { - public: - /// Create a stream object. - /// Start the RPC if \a start is set - /// \a tag will be notified on \a cq when the call has been started (i.e. - /// intitial metadata sent) and \a request has been written out. - /// If \a start is not set, \a tag must be nullptr and the actual call - /// must be initiated by StartCall - /// Note that \a context will be used to fill in custom initial metadata - /// used to send to the server when starting the call. - /// \a response will be filled in with the single expected response - /// message from the server upon a successful call to the \a Finish - /// method of this instance. - template - static ClientAsyncWriter* Create(ChannelInterface* channel, - CompletionQueue* cq, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, - R* response, bool start, void* tag) { - ::grpc::internal::Call call = channel->CreateCall(method, context, cq); - return new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(ClientAsyncWriter))) - ClientAsyncWriter(call, context, response, start, tag); - } -}; -} // namespace internal - -/// Async API on the client side for doing client-streaming RPCs, -/// where the outgoing message stream going to the server contains -/// messages of type \a W. -template -class ClientAsyncWriter final : public ClientAsyncWriterInterface { - public: - // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { - assert(size == sizeof(ClientAsyncWriter)); - } - - // This operator should never be called as the memory should be freed as part - // of the arena destruction. It only exists to provide a matching operator - // delete to the operator new so that some compilers will not complain (see - // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this - // there are no tests catching the compiler warning. - static void operator delete(void*, void*) { assert(0); } - - void StartCall(void* tag) override { - assert(!started_); - started_ = true; - StartCallInternal(tag); - } - - /// See the \a ClientAsyncStreamingInterface.ReadInitialMetadata method for - /// semantics. - /// - /// Side effect: - /// - upon receiving initial metadata from the server, the \a ClientContext - /// associated with this call is updated, and the calling code can access - /// the received metadata through the \a ClientContext. - void ReadInitialMetadata(void* tag) override { - assert(started_); - GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); - - meta_ops_.set_output_tag(tag); - meta_ops_.RecvInitialMetadata(context_); - call_.PerformOps(&meta_ops_); - } - - void Write(const W& msg, void* tag) override { - assert(started_); - write_ops_.set_output_tag(tag); - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); - call_.PerformOps(&write_ops_); - } - - void Write(const W& msg, WriteOptions options, void* tag) override { - assert(started_); - write_ops_.set_output_tag(tag); - if (options.is_last_message()) { - options.set_buffer_hint(); - write_ops_.ClientSendClose(); - } - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); - call_.PerformOps(&write_ops_); - } - - void WritesDone(void* tag) override { - assert(started_); - write_ops_.set_output_tag(tag); - write_ops_.ClientSendClose(); - call_.PerformOps(&write_ops_); - } - - /// See the \a ClientAsyncStreamingInterface.Finish method for semantics. - /// - /// Side effect: - /// - the \a ClientContext associated with this call is updated with - /// possible initial and trailing metadata received from the server. - /// - attempts to fill in the \a response parameter passed to this class's - /// constructor with the server's response message. - void Finish(Status* status, void* tag) override { - assert(started_); - finish_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - finish_ops_.RecvInitialMetadata(context_); - } - finish_ops_.ClientRecvStatus(context_, status); - call_.PerformOps(&finish_ops_); - } - - private: - friend class internal::ClientAsyncWriterFactory; - template - ClientAsyncWriter(::grpc::internal::Call call, - ::grpc_impl::ClientContext* context, R* response, - bool start, void* tag) - : context_(context), call_(call), started_(start) { - finish_ops_.RecvMessage(response); - finish_ops_.AllowNoMessage(); - if (start) { - StartCallInternal(tag); - } else { - assert(tag == nullptr); - } - } - - void StartCallInternal(void* tag) { - write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - // if corked bit is set in context, we just keep the initial metadata - // buffered up to coalesce with later message send. No op is performed. - if (!context_->initial_metadata_corked_) { - write_ops_.set_output_tag(tag); - call_.PerformOps(&write_ops_); - } - } - - ::grpc_impl::ClientContext* context_; - ::grpc::internal::Call call_; - bool started_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> - meta_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpClientSendClose> - write_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpGenericRecvMessage, - ::grpc::internal::CallOpClientRecvStatus> - finish_ops_; -}; - -/// Async client-side interface for bi-directional streaming, -/// where the client-to-server message stream has messages of type \a W, -/// and the server-to-client message stream has messages of type \a R. -template -class ClientAsyncReaderWriterInterface - : public internal::ClientAsyncStreamingInterface, - public internal::AsyncWriterInterface, - public internal::AsyncReaderInterface { - public: - /// Signal the client is done with the writes (half-close the client stream). - /// Thread-safe with respect to \a AsyncReaderInterface::Read - /// - /// \param[in] tag The tag identifying the operation. - virtual void WritesDone(void* tag) = 0; -}; - -namespace internal { -template -class ClientAsyncReaderWriterFactory { - public: - /// Create a stream object. - /// Start the RPC request if \a start is set. - /// \a tag will be notified on \a cq when the call has been started (i.e. - /// intitial metadata sent). If \a start is not set, \a tag must be - /// nullptr and the actual call must be initiated by StartCall - /// Note that \a context will be used to fill in custom initial metadata - /// used to send to the server when starting the call. - static ClientAsyncReaderWriter* Create( - ChannelInterface* channel, CompletionQueue* cq, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, bool start, void* tag) { - ::grpc::internal::Call call = channel->CreateCall(method, context, cq); - - return new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(ClientAsyncReaderWriter))) - ClientAsyncReaderWriter(call, context, start, tag); - } -}; -} // namespace internal - -/// Async client-side interface for bi-directional streaming, -/// where the outgoing message stream going to the server -/// has messages of type \a W, and the incoming message stream coming -/// from the server has messages of type \a R. -template -class ClientAsyncReaderWriter final - : public ClientAsyncReaderWriterInterface { - public: - // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { - assert(size == sizeof(ClientAsyncReaderWriter)); - } - - // This operator should never be called as the memory should be freed as part - // of the arena destruction. It only exists to provide a matching operator - // delete to the operator new so that some compilers will not complain (see - // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this - // there are no tests catching the compiler warning. - static void operator delete(void*, void*) { assert(0); } - - void StartCall(void* tag) override { - assert(!started_); - started_ = true; - StartCallInternal(tag); - } - - /// See the \a ClientAsyncStreamingInterface.ReadInitialMetadata method - /// for semantics of this method. - /// - /// Side effect: - /// - upon receiving initial metadata from the server, the \a ClientContext - /// is updated with it, and then the receiving initial metadata can - /// be accessed through this \a ClientContext. - void ReadInitialMetadata(void* tag) override { - assert(started_); - GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); - - meta_ops_.set_output_tag(tag); - meta_ops_.RecvInitialMetadata(context_); - call_.PerformOps(&meta_ops_); - } - - void Read(R* msg, void* tag) override { - assert(started_); - read_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - read_ops_.RecvInitialMetadata(context_); - } - read_ops_.RecvMessage(msg); - call_.PerformOps(&read_ops_); - } - - void Write(const W& msg, void* tag) override { - assert(started_); - write_ops_.set_output_tag(tag); - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); - call_.PerformOps(&write_ops_); - } - - void Write(const W& msg, WriteOptions options, void* tag) override { - assert(started_); - write_ops_.set_output_tag(tag); - if (options.is_last_message()) { - options.set_buffer_hint(); - write_ops_.ClientSendClose(); - } - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); - call_.PerformOps(&write_ops_); - } - - void WritesDone(void* tag) override { - assert(started_); - write_ops_.set_output_tag(tag); - write_ops_.ClientSendClose(); - call_.PerformOps(&write_ops_); - } - - /// See the \a ClientAsyncStreamingInterface.Finish method for semantics. - /// Side effect - /// - the \a ClientContext associated with this call is updated with - /// possible initial and trailing metadata sent from the server. - void Finish(Status* status, void* tag) override { - assert(started_); - finish_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - finish_ops_.RecvInitialMetadata(context_); - } - finish_ops_.ClientRecvStatus(context_, status); - call_.PerformOps(&finish_ops_); - } - - private: - friend class internal::ClientAsyncReaderWriterFactory; - ClientAsyncReaderWriter(::grpc::internal::Call call, - ::grpc_impl::ClientContext* context, bool start, - void* tag) - : context_(context), call_(call), started_(start) { - if (start) { - StartCallInternal(tag); - } else { - assert(tag == nullptr); - } - } - - void StartCallInternal(void* tag) { - write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - // if corked bit is set in context, we just keep the initial metadata - // buffered up to coalesce with later message send. No op is performed. - if (!context_->initial_metadata_corked_) { - write_ops_.set_output_tag(tag); - call_.PerformOps(&write_ops_); - } - } - - ::grpc_impl::ClientContext* context_; - ::grpc::internal::Call call_; - bool started_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> - meta_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpRecvMessage> - read_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpClientSendClose> - write_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpClientRecvStatus> - finish_ops_; -}; - -template -class ServerAsyncReaderInterface - : public internal::ServerAsyncStreamingInterface, - public internal::AsyncReaderInterface { - public: - /// Indicate that the stream is to be finished with a certain status code - /// and also send out \a msg response to the client. - /// Request notification for when the server has sent the response and the - /// appropriate signals to the client to end the call. - /// Should not be used concurrently with other operations. - /// - /// It is appropriate to call this method when: - /// * all messages from the client have been received (either known - /// implictly, or explicitly because a previous - /// \a AsyncReaderInterface::Read operation with a non-ok result, - /// e.g., cq->Next(&read_tag, &ok) filled in 'ok' with 'false'). - /// - /// This operation will end when the server has finished sending out initial - /// metadata (if not sent already), response message, and status, or if - /// some failure occurred when trying to do so. - /// - /// gRPC doesn't take ownership or a reference to \a msg or \a status, so it - /// is safe to deallocate once Finish returns. - /// - /// \param[in] tag Tag identifying this request. - /// \param[in] status To be sent to the client as the result of this call. - /// \param[in] msg To be sent to the client as the response for this call. - virtual void Finish(const W& msg, const Status& status, void* tag) = 0; - - /// Indicate that the stream is to be finished with a certain - /// non-OK status code. - /// Request notification for when the server has sent the appropriate - /// signals to the client to end the call. - /// Should not be used concurrently with other operations. - /// - /// This call is meant to end the call with some error, and can be called at - /// any point that the server would like to "fail" the call (though note - /// this shouldn't be called concurrently with any other "sending" call, like - /// \a AsyncWriterInterface::Write). - /// - /// This operation will end when the server has finished sending out initial - /// metadata (if not sent already), and status, or if some failure occurred - /// when trying to do so. - /// - /// gRPC doesn't take ownership or a reference to \a status, so it is safe to - /// to deallocate once FinishWithError returns. - /// - /// \param[in] tag Tag identifying this request. - /// \param[in] status To be sent to the client as the result of this call. - /// - Note: \a status must have a non-OK code. - virtual void FinishWithError(const Status& status, void* tag) = 0; -}; - -/// Async server-side API for doing client-streaming RPCs, -/// where the incoming message stream from the client has messages of type \a R, -/// and the single response message sent from the server is type \a W. -template -class ServerAsyncReader final : public ServerAsyncReaderInterface { - public: - explicit ServerAsyncReader(::grpc_impl::ServerContext* ctx) - : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} - - /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. - /// - /// Implicit input parameter: - /// - The initial metadata that will be sent to the client from this op will - /// be taken from the \a ServerContext associated with the call. - void SendInitialMetadata(void* tag) override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - - meta_ops_.set_output_tag(tag); - meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - call_.PerformOps(&meta_ops_); - } - - void Read(R* msg, void* tag) override { - read_ops_.set_output_tag(tag); - read_ops_.RecvMessage(msg); - call_.PerformOps(&read_ops_); - } - - /// See the \a ServerAsyncReaderInterface.Read method for semantics - /// - /// Side effect: - /// - also sends initial metadata if not alreay sent. - /// - uses the \a ServerContext associated with this call to send possible - /// initial and trailing metadata. - /// - /// Note: \a msg is not sent if \a status has a non-OK code. - /// - /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it - /// is safe to deallocate once Finish returns. - void Finish(const W& msg, const Status& status, void* tag) override { - finish_ops_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - // The response is dropped if the status is not OK. - if (status.ok()) { - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, - finish_ops_.SendMessage(msg)); - } else { - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); - } - call_.PerformOps(&finish_ops_); - } - - /// See the \a ServerAsyncReaderInterface.Read method for semantics - /// - /// Side effect: - /// - also sends initial metadata if not alreay sent. - /// - uses the \a ServerContext associated with this call to send possible - /// initial and trailing metadata. - /// - /// gRPC doesn't take ownership or a reference to \a status, so it is safe to - /// to deallocate once FinishWithError returns. - void FinishWithError(const Status& status, void* tag) override { - GPR_CODEGEN_ASSERT(!status.ok()); - finish_ops_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); - call_.PerformOps(&finish_ops_); - } - - private: - void BindCall(::grpc::internal::Call* call) override { call_ = *call; } - - ::grpc::internal::Call call_; - ::grpc_impl::ServerContext* ctx_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> - meta_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage> read_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpServerSendStatus> - finish_ops_; -}; +using ClientAsyncReader = ::grpc_impl::ClientAsyncReader; template -class ServerAsyncWriterInterface - : public internal::ServerAsyncStreamingInterface, - public internal::AsyncWriterInterface { - public: - /// Indicate that the stream is to be finished with a certain status code. - /// Request notification for when the server has sent the appropriate - /// signals to the client to end the call. - /// Should not be used concurrently with other operations. - /// - /// It is appropriate to call this method when either: - /// * all messages from the client have been received (either known - /// implictly, or explicitly because a previous \a - /// AsyncReaderInterface::Read operation with a non-ok - /// result (e.g., cq->Next(&read_tag, &ok) filled in 'ok' with 'false'. - /// * it is desired to end the call early with some non-OK status code. - /// - /// This operation will end when the server has finished sending out initial - /// metadata (if not sent already), response message, and status, or if - /// some failure occurred when trying to do so. - /// - /// gRPC doesn't take ownership or a reference to \a status, so it is safe to - /// to deallocate once Finish returns. - /// - /// \param[in] tag Tag identifying this request. - /// \param[in] status To be sent to the client as the result of this call. - virtual void Finish(const Status& status, void* tag) = 0; +using ClientAsyncWriterInterface = ::grpc_impl::ClientAsyncWriterInterface; - /// Request the writing of \a msg and coalesce it with trailing metadata which - /// contains \a status, using WriteOptions options with - /// identifying tag \a tag. - /// - /// WriteAndFinish is equivalent of performing WriteLast and Finish - /// in a single step. - /// - /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it - /// is safe to deallocate once WriteAndFinish returns. - /// - /// \param[in] msg The message to be written. - /// \param[in] options The WriteOptions to be used to write this message. - /// \param[in] status The Status that server returns to client. - /// \param[in] tag The tag identifying the operation. - virtual void WriteAndFinish(const W& msg, WriteOptions options, - const Status& status, void* tag) = 0; -}; - -/// Async server-side API for doing server streaming RPCs, -/// where the outgoing message stream from the server has messages of type \a W. template -class ServerAsyncWriter final : public ServerAsyncWriterInterface { - public: - explicit ServerAsyncWriter(::grpc_impl::ServerContext* ctx) - : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} +using ClientAsyncWriter = ::grpc_impl::ClientAsyncWriter; - /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. - /// - /// Implicit input parameter: - /// - The initial metadata that will be sent to the client from this op will - /// be taken from the \a ServerContext associated with the call. - /// - /// \param[in] tag Tag identifying this request. - void SendInitialMetadata(void* tag) override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - - meta_ops_.set_output_tag(tag); - meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - call_.PerformOps(&meta_ops_); - } - - void Write(const W& msg, void* tag) override { - write_ops_.set_output_tag(tag); - EnsureInitialMetadataSent(&write_ops_); - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); - call_.PerformOps(&write_ops_); - } - - void Write(const W& msg, WriteOptions options, void* tag) override { - write_ops_.set_output_tag(tag); - if (options.is_last_message()) { - options.set_buffer_hint(); - } - - EnsureInitialMetadataSent(&write_ops_); - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); - call_.PerformOps(&write_ops_); - } - - /// See the \a ServerAsyncWriterInterface.WriteAndFinish method for semantics. - /// - /// Implicit input parameter: - /// - the \a ServerContext associated with this call is used - /// for sending trailing (and initial) metadata to the client. - /// - /// Note: \a status must have an OK code. - /// - /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it - /// is safe to deallocate once WriteAndFinish returns. - void WriteAndFinish(const W& msg, WriteOptions options, const Status& status, - void* tag) override { - write_ops_.set_output_tag(tag); - EnsureInitialMetadataSent(&write_ops_); - options.set_buffer_hint(); - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); - write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); - call_.PerformOps(&write_ops_); - } - - /// See the \a ServerAsyncWriterInterface.Finish method for semantics. - /// - /// Implicit input parameter: - /// - the \a ServerContext associated with this call is used for sending - /// trailing (and initial if not already sent) metadata to the client. - /// - /// Note: there are no restrictions are the code of - /// \a status,it may be non-OK - /// - /// gRPC doesn't take ownership or a reference to \a status, so it is safe to - /// to deallocate once Finish returns. - void Finish(const Status& status, void* tag) override { - finish_ops_.set_output_tag(tag); - EnsureInitialMetadataSent(&finish_ops_); - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); - call_.PerformOps(&finish_ops_); - } - - private: - void BindCall(::grpc::internal::Call* call) override { call_ = *call; } - - template - void EnsureInitialMetadataSent(T* ops) { - if (!ctx_->sent_initial_metadata_) { - ops->SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - ops->set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - } - - ::grpc::internal::Call call_; - ::grpc_impl::ServerContext* ctx_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> - meta_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpServerSendStatus> - write_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpServerSendStatus> - finish_ops_; -}; - -/// Server-side interface for asynchronous bi-directional streaming. template -class ServerAsyncReaderWriterInterface - : public internal::ServerAsyncStreamingInterface, - public internal::AsyncWriterInterface, - public internal::AsyncReaderInterface { - public: - /// Indicate that the stream is to be finished with a certain status code. - /// Request notification for when the server has sent the appropriate - /// signals to the client to end the call. - /// Should not be used concurrently with other operations. - /// - /// It is appropriate to call this method when either: - /// * all messages from the client have been received (either known - /// implictly, or explicitly because a previous \a - /// AsyncReaderInterface::Read operation - /// with a non-ok result (e.g., cq->Next(&read_tag, &ok) filled in 'ok' - /// with 'false'. - /// * it is desired to end the call early with some non-OK status code. - /// - /// This operation will end when the server has finished sending out initial - /// metadata (if not sent already), response message, and status, or if some - /// failure occurred when trying to do so. - /// - /// gRPC doesn't take ownership or a reference to \a status, so it is safe to - /// to deallocate once Finish returns. - /// - /// \param[in] tag Tag identifying this request. - /// \param[in] status To be sent to the client as the result of this call. - virtual void Finish(const Status& status, void* tag) = 0; +using ClientAsyncReaderWriterInterface = + ::grpc_impl::ClientAsyncReaderWriterInterface; - /// Request the writing of \a msg and coalesce it with trailing metadata which - /// contains \a status, using WriteOptions options with - /// identifying tag \a tag. - /// - /// WriteAndFinish is equivalent of performing WriteLast and Finish in a - /// single step. - /// - /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it - /// is safe to deallocate once WriteAndFinish returns. - /// - /// \param[in] msg The message to be written. - /// \param[in] options The WriteOptions to be used to write this message. - /// \param[in] status The Status that server returns to client. - /// \param[in] tag The tag identifying the operation. - virtual void WriteAndFinish(const W& msg, WriteOptions options, - const Status& status, void* tag) = 0; -}; - -/// Async server-side API for doing bidirectional streaming RPCs, -/// where the incoming message stream coming from the client has messages of -/// type \a R, and the outgoing message stream coming from the server has -/// messages of type \a W. template -class ServerAsyncReaderWriter final - : public ServerAsyncReaderWriterInterface { - public: - explicit ServerAsyncReaderWriter(::grpc_impl::ServerContext* ctx) - : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} +using ClientAsyncReaderWriter = ::grpc_impl::ClientAsyncReaderWriter; - /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. - /// - /// Implicit input parameter: - /// - The initial metadata that will be sent to the client from this op will - /// be taken from the \a ServerContext associated with the call. - /// - /// \param[in] tag Tag identifying this request. - void SendInitialMetadata(void* tag) override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); +template +using ServerAsyncReaderInterface = + ::grpc_impl::ServerAsyncReaderInterface; - meta_ops_.set_output_tag(tag); - meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - call_.PerformOps(&meta_ops_); - } +template +using ServerAsyncReader = ::grpc_impl::ServerAsyncReader; - void Read(R* msg, void* tag) override { - read_ops_.set_output_tag(tag); - read_ops_.RecvMessage(msg); - call_.PerformOps(&read_ops_); - } +template +using ServerAsyncWriterInterface = ::grpc_impl::ServerAsyncWriterInterface; - void Write(const W& msg, void* tag) override { - write_ops_.set_output_tag(tag); - EnsureInitialMetadataSent(&write_ops_); - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); - call_.PerformOps(&write_ops_); - } +template +using ServerAsyncWriter = ::grpc_impl::ServerAsyncWriter; - void Write(const W& msg, WriteOptions options, void* tag) override { - write_ops_.set_output_tag(tag); - if (options.is_last_message()) { - options.set_buffer_hint(); - } - EnsureInitialMetadataSent(&write_ops_); - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); - call_.PerformOps(&write_ops_); - } - - /// See the \a ServerAsyncReaderWriterInterface.WriteAndFinish - /// method for semantics. - /// - /// Implicit input parameter: - /// - the \a ServerContext associated with this call is used - /// for sending trailing (and initial) metadata to the client. - /// - /// Note: \a status must have an OK code. - // - /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it - /// is safe to deallocate once WriteAndFinish returns. - void WriteAndFinish(const W& msg, WriteOptions options, const Status& status, - void* tag) override { - write_ops_.set_output_tag(tag); - EnsureInitialMetadataSent(&write_ops_); - options.set_buffer_hint(); - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); - write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); - call_.PerformOps(&write_ops_); - } - - /// See the \a ServerAsyncReaderWriterInterface.Finish method for semantics. - /// - /// Implicit input parameter: - /// - the \a ServerContext associated with this call is used for sending - /// trailing (and initial if not already sent) metadata to the client. - /// - /// Note: there are no restrictions are the code of \a status, - /// it may be non-OK - // - /// gRPC doesn't take ownership or a reference to \a status, so it is safe to - /// to deallocate once Finish returns. - void Finish(const Status& status, void* tag) override { - finish_ops_.set_output_tag(tag); - EnsureInitialMetadataSent(&finish_ops_); - - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); - call_.PerformOps(&finish_ops_); - } - - private: - friend class ::grpc_impl::Server; - - void BindCall(::grpc::internal::Call* call) override { call_ = *call; } - - template - void EnsureInitialMetadataSent(T* ops) { - if (!ctx_->sent_initial_metadata_) { - ops->SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - ops->set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - } - - ::grpc::internal::Call call_; - ::grpc_impl::ServerContext* ctx_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> - meta_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage> read_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpServerSendStatus> - write_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpServerSendStatus> - finish_ops_; -}; +template +using ServerAsyncReaderWriterInterface = + ::grpc_impl::ServerAsyncReaderWriterInterface; +template +using ServerAsyncReaderWriter = ::grpc_impl::ServerAsyncReaderWriter; } // namespace grpc #endif // GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H diff --git a/include/grpcpp/impl/codegen/async_stream_impl.h b/include/grpcpp/impl/codegen/async_stream_impl.h new file mode 100644 index 00000000000..633a3d5dd00 --- /dev/null +++ b/include/grpcpp/impl/codegen/async_stream_impl.h @@ -0,0 +1,1134 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_IMPL_H +#define GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_IMPL_H + +#include +#include +#include +#include +#include +#include + +namespace grpc_impl { + +namespace internal { +/// Common interface for all client side asynchronous streaming. +class ClientAsyncStreamingInterface { + public: + virtual ~ClientAsyncStreamingInterface() {} + + /// Start the call that was set up by the constructor, but only if the + /// constructor was invoked through the "Prepare" API which doesn't actually + /// start the call + virtual void StartCall(void* tag) = 0; + + /// Request notification of the reading of the initial metadata. Completion + /// will be notified by \a tag on the associated completion queue. + /// This call is optional, but if it is used, it cannot be used concurrently + /// with or after the \a AsyncReaderInterface::Read method. + /// + /// \param[in] tag Tag identifying this request. + virtual void ReadInitialMetadata(void* tag) = 0; + + /// Indicate that the stream is to be finished and request notification for + /// when the call has been ended. + /// Should not be used concurrently with other operations. + /// + /// It is appropriate to call this method when both: + /// * the client side has no more message to send + /// (this can be declared implicitly by calling this method, or + /// explicitly through an earlier call to the WritesDone method + /// of the class in use, e.g. \a ClientAsyncWriterInterface::WritesDone or + /// \a ClientAsyncReaderWriterInterface::WritesDone). + /// * there are no more messages to be received from the server (this can + /// be known implicitly by the calling code, or explicitly from an + /// earlier call to \a AsyncReaderInterface::Read that yielded a failed + /// result, e.g. cq->Next(&read_tag, &ok) filled in 'ok' with 'false'). + /// + /// The tag will be returned when either: + /// - all incoming messages have been read and the server has returned + /// a status. + /// - the server has returned a non-OK status. + /// - the call failed for some reason and the library generated a + /// status. + /// + /// Note that implementations of this method attempt to receive initial + /// metadata from the server if initial metadata hasn't yet been received. + /// + /// \param[in] tag Tag identifying this request. + /// \param[out] status To be updated with the operation status. + virtual void Finish(::grpc::Status* status, void* tag) = 0; +}; + +/// An interface that yields a sequence of messages of type \a R. +template +class AsyncReaderInterface { + public: + virtual ~AsyncReaderInterface() {} + + /// Read a message of type \a R into \a msg. Completion will be notified by \a + /// tag on the associated completion queue. + /// This is thread-safe with respect to \a Write or \a WritesDone methods. It + /// should not be called concurrently with other streaming APIs + /// on the same stream. It is not meaningful to call it concurrently + /// with another \a AsyncReaderInterface::Read on the same stream since reads + /// on the same stream are delivered in order. + /// + /// \param[out] msg Where to eventually store the read message. + /// \param[in] tag The tag identifying the operation. + /// + /// Side effect: note that this method attempt to receive initial metadata for + /// a stream if it hasn't yet been received. + virtual void Read(R* msg, void* tag) = 0; +}; + +/// An interface that can be fed a sequence of messages of type \a W. +template +class AsyncWriterInterface { + public: + virtual ~AsyncWriterInterface() {} + + /// Request the writing of \a msg with identifying tag \a tag. + /// + /// Only one write may be outstanding at any given time. This means that + /// after calling Write, one must wait to receive \a tag from the completion + /// queue BEFORE calling Write again. + /// This is thread-safe with respect to \a AsyncReaderInterface::Read + /// + /// gRPC doesn't take ownership or a reference to \a msg, so it is safe to + /// to deallocate once Write returns. + /// + /// \param[in] msg The message to be written. + /// \param[in] tag The tag identifying the operation. + virtual void Write(const W& msg, void* tag) = 0; + + /// Request the writing of \a msg using WriteOptions \a options with + /// identifying tag \a tag. + /// + /// Only one write may be outstanding at any given time. This means that + /// after calling Write, one must wait to receive \a tag from the completion + /// queue BEFORE calling Write again. + /// WriteOptions \a options is used to set the write options of this message. + /// This is thread-safe with respect to \a AsyncReaderInterface::Read + /// + /// gRPC doesn't take ownership or a reference to \a msg, so it is safe to + /// to deallocate once Write returns. + /// + /// \param[in] msg The message to be written. + /// \param[in] options The WriteOptions to be used to write this message. + /// \param[in] tag The tag identifying the operation. + virtual void Write(const W& msg, ::grpc::WriteOptions options, void* tag) = 0; + + /// Request the writing of \a msg and coalesce it with the writing + /// of trailing metadata, using WriteOptions \a options with + /// identifying tag \a tag. + /// + /// For client, WriteLast is equivalent of performing Write and + /// WritesDone in a single step. + /// For server, WriteLast buffers the \a msg. The writing of \a msg is held + /// until Finish is called, where \a msg and trailing metadata are coalesced + /// and write is initiated. Note that WriteLast can only buffer \a msg up to + /// the flow control window size. If \a msg size is larger than the window + /// size, it will be sent on wire without buffering. + /// + /// gRPC doesn't take ownership or a reference to \a msg, so it is safe to + /// to deallocate once Write returns. + /// + /// \param[in] msg The message to be written. + /// \param[in] options The WriteOptions to be used to write this message. + /// \param[in] tag The tag identifying the operation. + void WriteLast(const W& msg, ::grpc::WriteOptions options, void* tag) { + Write(msg, options.set_last_message(), tag); + } +}; + +} // namespace internal + +template +class ClientAsyncReaderInterface + : public internal::ClientAsyncStreamingInterface, + public internal::AsyncReaderInterface {}; + +namespace internal { +template +class ClientAsyncReaderFactory { + public: + /// Create a stream object. + /// Write the first request out if \a start is set. + /// \a tag will be notified on \a cq when the call has been started and + /// \a request has been written out. If \a start is not set, \a tag must be + /// nullptr and the actual call must be initiated by StartCall + /// Note that \a context will be used to fill in custom initial metadata + /// used to send to the server when starting the call. + template + static ClientAsyncReader* Create(::grpc::ChannelInterface* channel, + ::grpc_impl::CompletionQueue* cq, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + const W& request, bool start, void* tag) { + ::grpc::internal::Call call = channel->CreateCall(method, context, cq); + return new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientAsyncReader))) + ClientAsyncReader(call, context, request, start, tag); + } +}; +} // namespace internal + +/// Async client-side API for doing server-streaming RPCs, +/// where the incoming message stream coming from the server has +/// messages of type \a R. +template +class ClientAsyncReader final : public ClientAsyncReaderInterface { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* ptr, std::size_t size) { + assert(size == sizeof(ClientAsyncReader)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { assert(0); } + + void StartCall(void* tag) override { + assert(!started_); + started_ = true; + StartCallInternal(tag); + } + + /// See the \a ClientAsyncStreamingInterface.ReadInitialMetadata + /// method for semantics. + /// + /// Side effect: + /// - upon receiving initial metadata from the server, + /// the \a ClientContext associated with this call is updated, and the + /// calling code can access the received metadata through the + /// \a ClientContext. + void ReadInitialMetadata(void* tag) override { + assert(started_); + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + meta_ops_.set_output_tag(tag); + meta_ops_.RecvInitialMetadata(context_); + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) override { + assert(started_); + read_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + read_ops_.RecvInitialMetadata(context_); + } + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + /// See the \a ClientAsyncStreamingInterface.Finish method for semantics. + /// + /// Side effect: + /// - the \a ClientContext associated with this call is updated with + /// possible initial and trailing metadata received from the server. + void Finish(::grpc::Status* status, void* tag) override { + assert(started_); + finish_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + finish_ops_.RecvInitialMetadata(context_); + } + finish_ops_.ClientRecvStatus(context_, status); + call_.PerformOps(&finish_ops_); + } + + private: + friend class internal::ClientAsyncReaderFactory; + template + ClientAsyncReader(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, const W& request, + bool start, void* tag) + : context_(context), call_(call), started_(start) { + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(init_ops_.SendMessage(request).ok()); + init_ops_.ClientSendClose(); + if (start) { + StartCallInternal(tag); + } else { + assert(tag == nullptr); + } + } + + void StartCallInternal(void* tag) { + init_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + init_ops_.set_output_tag(tag); + call_.PerformOps(&init_ops_); + } + + ::grpc_impl::ClientContext* context_; + ::grpc::internal::Call call_; + bool started_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose> + init_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> + meta_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpRecvMessage> + read_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpClientRecvStatus> + finish_ops_; +}; + +/// Common interface for client side asynchronous writing. +template +class ClientAsyncWriterInterface + : public internal::ClientAsyncStreamingInterface, + public internal::AsyncWriterInterface { + public: + /// Signal the client is done with the writes (half-close the client stream). + /// Thread-safe with respect to \a AsyncReaderInterface::Read + /// + /// \param[in] tag The tag identifying the operation. + virtual void WritesDone(void* tag) = 0; +}; + +namespace internal { +template +class ClientAsyncWriterFactory { + public: + /// Create a stream object. + /// Start the RPC if \a start is set + /// \a tag will be notified on \a cq when the call has been started (i.e. + /// intitial metadata sent) and \a request has been written out. + /// If \a start is not set, \a tag must be nullptr and the actual call + /// must be initiated by StartCall + /// Note that \a context will be used to fill in custom initial metadata + /// used to send to the server when starting the call. + /// \a response will be filled in with the single expected response + /// message from the server upon a successful call to the \a Finish + /// method of this instance. + template + static ClientAsyncWriter* Create(::grpc::ChannelInterface* channel, + ::grpc_impl::CompletionQueue* cq, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + R* response, bool start, void* tag) { + ::grpc::internal::Call call = channel->CreateCall(method, context, cq); + return new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientAsyncWriter))) + ClientAsyncWriter(call, context, response, start, tag); + } +}; +} // namespace internal + +/// Async API on the client side for doing client-streaming RPCs, +/// where the outgoing message stream going to the server contains +/// messages of type \a W. +template +class ClientAsyncWriter final : public ClientAsyncWriterInterface { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* ptr, std::size_t size) { + assert(size == sizeof(ClientAsyncWriter)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { assert(0); } + + void StartCall(void* tag) override { + assert(!started_); + started_ = true; + StartCallInternal(tag); + } + + /// See the \a ClientAsyncStreamingInterface.ReadInitialMetadata method for + /// semantics. + /// + /// Side effect: + /// - upon receiving initial metadata from the server, the \a ClientContext + /// associated with this call is updated, and the calling code can access + /// the received metadata through the \a ClientContext. + void ReadInitialMetadata(void* tag) override { + assert(started_); + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + meta_ops_.set_output_tag(tag); + meta_ops_.RecvInitialMetadata(context_); + call_.PerformOps(&meta_ops_); + } + + void Write(const W& msg, void* tag) override { + assert(started_); + write_ops_.set_output_tag(tag); + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override { + assert(started_); + write_ops_.set_output_tag(tag); + if (options.is_last_message()) { + options.set_buffer_hint(); + write_ops_.ClientSendClose(); + } + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); + call_.PerformOps(&write_ops_); + } + + void WritesDone(void* tag) override { + assert(started_); + write_ops_.set_output_tag(tag); + write_ops_.ClientSendClose(); + call_.PerformOps(&write_ops_); + } + + /// See the \a ClientAsyncStreamingInterface.Finish method for semantics. + /// + /// Side effect: + /// - the \a ClientContext associated with this call is updated with + /// possible initial and trailing metadata received from the server. + /// - attempts to fill in the \a response parameter passed to this class's + /// constructor with the server's response message. + void Finish(::grpc::Status* status, void* tag) override { + assert(started_); + finish_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + finish_ops_.RecvInitialMetadata(context_); + } + finish_ops_.ClientRecvStatus(context_, status); + call_.PerformOps(&finish_ops_); + } + + private: + friend class internal::ClientAsyncWriterFactory; + template + ClientAsyncWriter(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, R* response, + bool start, void* tag) + : context_(context), call_(call), started_(start) { + finish_ops_.RecvMessage(response); + finish_ops_.AllowNoMessage(); + if (start) { + StartCallInternal(tag); + } else { + assert(tag == nullptr); + } + } + + void StartCallInternal(void* tag) { + write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + // if corked bit is set in context, we just keep the initial metadata + // buffered up to coalesce with later message send. No op is performed. + if (!context_->initial_metadata_corked_) { + write_ops_.set_output_tag(tag); + call_.PerformOps(&write_ops_); + } + } + + ::grpc_impl::ClientContext* context_; + ::grpc::internal::Call call_; + bool started_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> + meta_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose> + write_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpGenericRecvMessage, + ::grpc::internal::CallOpClientRecvStatus> + finish_ops_; +}; + +/// Async client-side interface for bi-directional streaming, +/// where the client-to-server message stream has messages of type \a W, +/// and the server-to-client message stream has messages of type \a R. +template +class ClientAsyncReaderWriterInterface + : public internal::ClientAsyncStreamingInterface, + public internal::AsyncWriterInterface, + public internal::AsyncReaderInterface { + public: + /// Signal the client is done with the writes (half-close the client stream). + /// Thread-safe with respect to \a AsyncReaderInterface::Read + /// + /// \param[in] tag The tag identifying the operation. + virtual void WritesDone(void* tag) = 0; +}; + +namespace internal { +template +class ClientAsyncReaderWriterFactory { + public: + /// Create a stream object. + /// Start the RPC request if \a start is set. + /// \a tag will be notified on \a cq when the call has been started (i.e. + /// intitial metadata sent). If \a start is not set, \a tag must be + /// nullptr and the actual call must be initiated by StartCall + /// Note that \a context will be used to fill in custom initial metadata + /// used to send to the server when starting the call. + static ClientAsyncReaderWriter* Create( + ::grpc::ChannelInterface* channel, ::grpc_impl::CompletionQueue* cq, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, bool start, void* tag) { + ::grpc::internal::Call call = channel->CreateCall(method, context, cq); + + return new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientAsyncReaderWriter))) + ClientAsyncReaderWriter(call, context, start, tag); + } +}; +} // namespace internal + +/// Async client-side interface for bi-directional streaming, +/// where the outgoing message stream going to the server +/// has messages of type \a W, and the incoming message stream coming +/// from the server has messages of type \a R. +template +class ClientAsyncReaderWriter final + : public ClientAsyncReaderWriterInterface { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* ptr, std::size_t size) { + assert(size == sizeof(ClientAsyncReaderWriter)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { assert(0); } + + void StartCall(void* tag) override { + assert(!started_); + started_ = true; + StartCallInternal(tag); + } + + /// See the \a ClientAsyncStreamingInterface.ReadInitialMetadata method + /// for semantics of this method. + /// + /// Side effect: + /// - upon receiving initial metadata from the server, the \a ClientContext + /// is updated with it, and then the receiving initial metadata can + /// be accessed through this \a ClientContext. + void ReadInitialMetadata(void* tag) override { + assert(started_); + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + meta_ops_.set_output_tag(tag); + meta_ops_.RecvInitialMetadata(context_); + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) override { + assert(started_); + read_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + read_ops_.RecvInitialMetadata(context_); + } + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + void Write(const W& msg, void* tag) override { + assert(started_); + write_ops_.set_output_tag(tag); + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override { + assert(started_); + write_ops_.set_output_tag(tag); + if (options.is_last_message()) { + options.set_buffer_hint(); + write_ops_.ClientSendClose(); + } + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); + call_.PerformOps(&write_ops_); + } + + void WritesDone(void* tag) override { + assert(started_); + write_ops_.set_output_tag(tag); + write_ops_.ClientSendClose(); + call_.PerformOps(&write_ops_); + } + + /// See the \a ClientAsyncStreamingInterface.Finish method for semantics. + /// Side effect + /// - the \a ClientContext associated with this call is updated with + /// possible initial and trailing metadata sent from the server. + void Finish(::grpc::Status* status, void* tag) override { + assert(started_); + finish_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + finish_ops_.RecvInitialMetadata(context_); + } + finish_ops_.ClientRecvStatus(context_, status); + call_.PerformOps(&finish_ops_); + } + + private: + friend class internal::ClientAsyncReaderWriterFactory; + ClientAsyncReaderWriter(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, bool start, + void* tag) + : context_(context), call_(call), started_(start) { + if (start) { + StartCallInternal(tag); + } else { + assert(tag == nullptr); + } + } + + void StartCallInternal(void* tag) { + write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + // if corked bit is set in context, we just keep the initial metadata + // buffered up to coalesce with later message send. No op is performed. + if (!context_->initial_metadata_corked_) { + write_ops_.set_output_tag(tag); + call_.PerformOps(&write_ops_); + } + } + + ::grpc_impl::ClientContext* context_; + ::grpc::internal::Call call_; + bool started_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> + meta_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpRecvMessage> + read_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose> + write_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpClientRecvStatus> + finish_ops_; +}; + +template +class ServerAsyncReaderInterface + : public ::grpc::internal::ServerAsyncStreamingInterface, + public internal::AsyncReaderInterface { + public: + /// Indicate that the stream is to be finished with a certain status code + /// and also send out \a msg response to the client. + /// Request notification for when the server has sent the response and the + /// appropriate signals to the client to end the call. + /// Should not be used concurrently with other operations. + /// + /// It is appropriate to call this method when: + /// * all messages from the client have been received (either known + /// implictly, or explicitly because a previous + /// \a AsyncReaderInterface::Read operation with a non-ok result, + /// e.g., cq->Next(&read_tag, &ok) filled in 'ok' with 'false'). + /// + /// This operation will end when the server has finished sending out initial + /// metadata (if not sent already), response message, and status, or if + /// some failure occurred when trying to do so. + /// + /// gRPC doesn't take ownership or a reference to \a msg or \a status, so it + /// is safe to deallocate once Finish returns. + /// + /// \param[in] tag Tag identifying this request. + /// \param[in] status To be sent to the client as the result of this call. + /// \param[in] msg To be sent to the client as the response for this call. + virtual void Finish(const W& msg, const ::grpc::Status& status, + void* tag) = 0; + + /// Indicate that the stream is to be finished with a certain + /// non-OK status code. + /// Request notification for when the server has sent the appropriate + /// signals to the client to end the call. + /// Should not be used concurrently with other operations. + /// + /// This call is meant to end the call with some error, and can be called at + /// any point that the server would like to "fail" the call (though note + /// this shouldn't be called concurrently with any other "sending" call, like + /// \a AsyncWriterInterface::Write). + /// + /// This operation will end when the server has finished sending out initial + /// metadata (if not sent already), and status, or if some failure occurred + /// when trying to do so. + /// + /// gRPC doesn't take ownership or a reference to \a status, so it is safe to + /// to deallocate once FinishWithError returns. + /// + /// \param[in] tag Tag identifying this request. + /// \param[in] status To be sent to the client as the result of this call. + /// - Note: \a status must have a non-OK code. + virtual void FinishWithError(const ::grpc::Status& status, void* tag) = 0; +}; + +/// Async server-side API for doing client-streaming RPCs, +/// where the incoming message stream from the client has messages of type \a R, +/// and the single response message sent from the server is type \a W. +template +class ServerAsyncReader final : public ServerAsyncReaderInterface { + public: + explicit ServerAsyncReader(::grpc_impl::ServerContext* ctx) + : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} + + /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. + /// + /// Implicit input parameter: + /// - The initial metadata that will be sent to the client from this op will + /// be taken from the \a ServerContext associated with the call. + void SendInitialMetadata(void* tag) override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + meta_ops_.set_output_tag(tag); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) override { + read_ops_.set_output_tag(tag); + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + /// See the \a ServerAsyncReaderInterface.Read method for semantics + /// + /// Side effect: + /// - also sends initial metadata if not alreay sent. + /// - uses the \a ServerContext associated with this call to send possible + /// initial and trailing metadata. + /// + /// Note: \a msg is not sent if \a status has a non-OK code. + /// + /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it + /// is safe to deallocate once Finish returns. + void Finish(const W& msg, const ::grpc::Status& status, void* tag) override { + finish_ops_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // The response is dropped if the status is not OK. + if (status.ok()) { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, + finish_ops_.SendMessage(msg)); + } else { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); + } + call_.PerformOps(&finish_ops_); + } + + /// See the \a ServerAsyncReaderInterface.Read method for semantics + /// + /// Side effect: + /// - also sends initial metadata if not alreay sent. + /// - uses the \a ServerContext associated with this call to send possible + /// initial and trailing metadata. + /// + /// gRPC doesn't take ownership or a reference to \a status, so it is safe to + /// to deallocate once FinishWithError returns. + void FinishWithError(const ::grpc::Status& status, void* tag) override { + GPR_CODEGEN_ASSERT(!status.ok()); + finish_ops_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); + call_.PerformOps(&finish_ops_); + } + + private: + void BindCall(::grpc::internal::Call* call) override { call_ = *call; } + + ::grpc::internal::Call call_; + ::grpc_impl::ServerContext* ctx_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage> read_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + finish_ops_; +}; + +template +class ServerAsyncWriterInterface + : public ::grpc::internal::ServerAsyncStreamingInterface, + public internal::AsyncWriterInterface { + public: + /// Indicate that the stream is to be finished with a certain status code. + /// Request notification for when the server has sent the appropriate + /// signals to the client to end the call. + /// Should not be used concurrently with other operations. + /// + /// It is appropriate to call this method when either: + /// * all messages from the client have been received (either known + /// implictly, or explicitly because a previous \a + /// AsyncReaderInterface::Read operation with a non-ok + /// result (e.g., cq->Next(&read_tag, &ok) filled in 'ok' with 'false'. + /// * it is desired to end the call early with some non-OK status code. + /// + /// This operation will end when the server has finished sending out initial + /// metadata (if not sent already), response message, and status, or if + /// some failure occurred when trying to do so. + /// + /// gRPC doesn't take ownership or a reference to \a status, so it is safe to + /// to deallocate once Finish returns. + /// + /// \param[in] tag Tag identifying this request. + /// \param[in] status To be sent to the client as the result of this call. + virtual void Finish(const ::grpc::Status& status, void* tag) = 0; + + /// Request the writing of \a msg and coalesce it with trailing metadata which + /// contains \a status, using WriteOptions options with + /// identifying tag \a tag. + /// + /// WriteAndFinish is equivalent of performing WriteLast and Finish + /// in a single step. + /// + /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it + /// is safe to deallocate once WriteAndFinish returns. + /// + /// \param[in] msg The message to be written. + /// \param[in] options The WriteOptions to be used to write this message. + /// \param[in] status The Status that server returns to client. + /// \param[in] tag The tag identifying the operation. + virtual void WriteAndFinish(const W& msg, ::grpc::WriteOptions options, + const ::grpc::Status& status, void* tag) = 0; +}; + +/// Async server-side API for doing server streaming RPCs, +/// where the outgoing message stream from the server has messages of type \a W. +template +class ServerAsyncWriter final : public ServerAsyncWriterInterface { + public: + explicit ServerAsyncWriter(::grpc_impl::ServerContext* ctx) + : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} + + /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. + /// + /// Implicit input parameter: + /// - The initial metadata that will be sent to the client from this op will + /// be taken from the \a ServerContext associated with the call. + /// + /// \param[in] tag Tag identifying this request. + void SendInitialMetadata(void* tag) override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + meta_ops_.set_output_tag(tag); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_.PerformOps(&meta_ops_); + } + + void Write(const W& msg, void* tag) override { + write_ops_.set_output_tag(tag); + EnsureInitialMetadataSent(&write_ops_); + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override { + write_ops_.set_output_tag(tag); + if (options.is_last_message()) { + options.set_buffer_hint(); + } + + EnsureInitialMetadataSent(&write_ops_); + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); + call_.PerformOps(&write_ops_); + } + + /// See the \a ServerAsyncWriterInterface.WriteAndFinish method for semantics. + /// + /// Implicit input parameter: + /// - the \a ServerContext associated with this call is used + /// for sending trailing (and initial) metadata to the client. + /// + /// Note: \a status must have an OK code. + /// + /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it + /// is safe to deallocate once WriteAndFinish returns. + void WriteAndFinish(const W& msg, ::grpc::WriteOptions options, + const ::grpc::Status& status, void* tag) override { + write_ops_.set_output_tag(tag); + EnsureInitialMetadataSent(&write_ops_); + options.set_buffer_hint(); + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); + write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); + call_.PerformOps(&write_ops_); + } + + /// See the \a ServerAsyncWriterInterface.Finish method for semantics. + /// + /// Implicit input parameter: + /// - the \a ServerContext associated with this call is used for sending + /// trailing (and initial if not already sent) metadata to the client. + /// + /// Note: there are no restrictions are the code of + /// \a status,it may be non-OK + /// + /// gRPC doesn't take ownership or a reference to \a status, so it is safe to + /// to deallocate once Finish returns. + void Finish(const ::grpc::Status& status, void* tag) override { + finish_ops_.set_output_tag(tag); + EnsureInitialMetadataSent(&finish_ops_); + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); + call_.PerformOps(&finish_ops_); + } + + private: + void BindCall(::grpc::internal::Call* call) override { call_ = *call; } + + template + void EnsureInitialMetadataSent(T* ops) { + if (!ctx_->sent_initial_metadata_) { + ops->SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ops->set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + } + + ::grpc::internal::Call call_; + ::grpc_impl::ServerContext* ctx_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + write_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpServerSendStatus> + finish_ops_; +}; + +/// Server-side interface for asynchronous bi-directional streaming. +template +class ServerAsyncReaderWriterInterface + : public ::grpc::internal::ServerAsyncStreamingInterface, + public internal::AsyncWriterInterface, + public internal::AsyncReaderInterface { + public: + /// Indicate that the stream is to be finished with a certain status code. + /// Request notification for when the server has sent the appropriate + /// signals to the client to end the call. + /// Should not be used concurrently with other operations. + /// + /// It is appropriate to call this method when either: + /// * all messages from the client have been received (either known + /// implictly, or explicitly because a previous \a + /// AsyncReaderInterface::Read operation + /// with a non-ok result (e.g., cq->Next(&read_tag, &ok) filled in 'ok' + /// with 'false'. + /// * it is desired to end the call early with some non-OK status code. + /// + /// This operation will end when the server has finished sending out initial + /// metadata (if not sent already), response message, and status, or if some + /// failure occurred when trying to do so. + /// + /// gRPC doesn't take ownership or a reference to \a status, so it is safe to + /// to deallocate once Finish returns. + /// + /// \param[in] tag Tag identifying this request. + /// \param[in] status To be sent to the client as the result of this call. + virtual void Finish(const ::grpc::Status& status, void* tag) = 0; + + /// Request the writing of \a msg and coalesce it with trailing metadata which + /// contains \a status, using WriteOptions options with + /// identifying tag \a tag. + /// + /// WriteAndFinish is equivalent of performing WriteLast and Finish in a + /// single step. + /// + /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it + /// is safe to deallocate once WriteAndFinish returns. + /// + /// \param[in] msg The message to be written. + /// \param[in] options The WriteOptions to be used to write this message. + /// \param[in] status The Status that server returns to client. + /// \param[in] tag The tag identifying the operation. + virtual void WriteAndFinish(const W& msg, ::grpc::WriteOptions options, + const ::grpc::Status& status, void* tag) = 0; +}; + +/// Async server-side API for doing bidirectional streaming RPCs, +/// where the incoming message stream coming from the client has messages of +/// type \a R, and the outgoing message stream coming from the server has +/// messages of type \a W. +template +class ServerAsyncReaderWriter final + : public ServerAsyncReaderWriterInterface { + public: + explicit ServerAsyncReaderWriter(::grpc_impl::ServerContext* ctx) + : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} + + /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. + /// + /// Implicit input parameter: + /// - The initial metadata that will be sent to the client from this op will + /// be taken from the \a ServerContext associated with the call. + /// + /// \param[in] tag Tag identifying this request. + void SendInitialMetadata(void* tag) override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + meta_ops_.set_output_tag(tag); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) override { + read_ops_.set_output_tag(tag); + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + void Write(const W& msg, void* tag) override { + write_ops_.set_output_tag(tag); + EnsureInitialMetadataSent(&write_ops_); + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override { + write_ops_.set_output_tag(tag); + if (options.is_last_message()) { + options.set_buffer_hint(); + } + EnsureInitialMetadataSent(&write_ops_); + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); + call_.PerformOps(&write_ops_); + } + + /// See the \a ServerAsyncReaderWriterInterface.WriteAndFinish + /// method for semantics. + /// + /// Implicit input parameter: + /// - the \a ServerContext associated with this call is used + /// for sending trailing (and initial) metadata to the client. + /// + /// Note: \a status must have an OK code. + // + /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it + /// is safe to deallocate once WriteAndFinish returns. + void WriteAndFinish(const W& msg, ::grpc::WriteOptions options, + const ::grpc::Status& status, void* tag) override { + write_ops_.set_output_tag(tag); + EnsureInitialMetadataSent(&write_ops_); + options.set_buffer_hint(); + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); + write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); + call_.PerformOps(&write_ops_); + } + + /// See the \a ServerAsyncReaderWriterInterface.Finish method for semantics. + /// + /// Implicit input parameter: + /// - the \a ServerContext associated with this call is used for sending + /// trailing (and initial if not already sent) metadata to the client. + /// + /// Note: there are no restrictions are the code of \a status, + /// it may be non-OK + // + /// gRPC doesn't take ownership or a reference to \a status, so it is safe to + /// to deallocate once Finish returns. + void Finish(const ::grpc::Status& status, void* tag) override { + finish_ops_.set_output_tag(tag); + EnsureInitialMetadataSent(&finish_ops_); + + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); + call_.PerformOps(&finish_ops_); + } + + private: + friend class ::grpc_impl::Server; + + void BindCall(::grpc::internal::Call* call) override { call_ = *call; } + + template + void EnsureInitialMetadataSent(T* ops) { + if (!ctx_->sent_initial_metadata_) { + ops->SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ops->set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + } + + ::grpc::internal::Call call_; + ::grpc_impl::ServerContext* ctx_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage> read_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + write_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpServerSendStatus> + finish_ops_; +}; + +} // namespace grpc_impl +#endif // GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_IMPL_H diff --git a/include/grpcpp/impl/codegen/async_unary_call.h b/include/grpcpp/impl/codegen/async_unary_call.h index 5da6a649f14..64ee17dec0d 100644 --- a/include/grpcpp/impl/codegen/async_unary_call.h +++ b/include/grpcpp/impl/codegen/async_unary_call.h @@ -19,299 +19,18 @@ #ifndef GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_H #define GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_H -#include -#include -#include -#include -#include -#include -#include +#include namespace grpc { - -extern CoreCodegenInterface* g_core_codegen_interface; - -/// An interface relevant for async client side unary RPCs (which send -/// one request message to a server and receive one response message). template -class ClientAsyncResponseReaderInterface { - public: - virtual ~ClientAsyncResponseReaderInterface() {} - - /// Start the call that was set up by the constructor, but only if the - /// constructor was invoked through the "Prepare" API which doesn't actually - /// start the call - virtual void StartCall() = 0; - - /// Request notification of the reading of initial metadata. Completion - /// will be notified by \a tag on the associated completion queue. - /// This call is optional, but if it is used, it cannot be used concurrently - /// with or after the \a Finish method. - /// - /// \param[in] tag Tag identifying this request. - virtual void ReadInitialMetadata(void* tag) = 0; - - /// Request to receive the server's response \a msg and final \a status for - /// the call, and to notify \a tag on this call's completion queue when - /// finished. - /// - /// This function will return when either: - /// - when the server's response message and status have been received. - /// - when the server has returned a non-OK status (no message expected in - /// this case). - /// - when the call failed for some reason and the library generated a - /// non-OK status. - /// - /// \param[in] tag Tag identifying this request. - /// \param[out] status To be updated with the operation status. - /// \param[out] msg To be filled in with the server's response message. - virtual void Finish(R* msg, Status* status, void* tag) = 0; -}; - -namespace internal { +using ClientAsyncResponseReaderInterface = + grpc_impl::ClientAsyncResponseReaderInterface; template -class ClientAsyncResponseReaderFactory { - public: - /// Start a call and write the request out if \a start is set. - /// \a tag will be notified on \a cq when the call has been started (i.e. - /// intitial metadata sent) and \a request has been written out. - /// If \a start is not set, the actual call must be initiated by StartCall - /// Note that \a context will be used to fill in custom initial metadata - /// used to send to the server when starting the call. - template - static ClientAsyncResponseReader* Create( - ChannelInterface* channel, ::grpc_impl::CompletionQueue* cq, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, const W& request, bool start) { - ::grpc::internal::Call call = channel->CreateCall(method, context, cq); - return new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(ClientAsyncResponseReader))) - ClientAsyncResponseReader(call, context, request, start); - } -}; -} // namespace internal +using ClientAsyncResponseReader = grpc_impl::ClientAsyncResponseReader; -/// Async API for client-side unary RPCs, where the message response -/// received from the server is of type \a R. -template -class ClientAsyncResponseReader final - : public ClientAsyncResponseReaderInterface { - public: - // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { - assert(size == sizeof(ClientAsyncResponseReader)); - } - - // This operator should never be called as the memory should be freed as part - // of the arena destruction. It only exists to provide a matching operator - // delete to the operator new so that some compilers will not complain (see - // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this - // there are no tests catching the compiler warning. - static void operator delete(void*, void*) { assert(0); } - - void StartCall() override { - assert(!started_); - started_ = true; - StartCallInternal(); - } - - /// See \a ClientAsyncResponseReaderInterface::ReadInitialMetadata for - /// semantics. - /// - /// Side effect: - /// - the \a ClientContext associated with this call is updated with - /// possible initial and trailing metadata sent from the server. - void ReadInitialMetadata(void* tag) override { - assert(started_); - GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); - - single_buf.set_output_tag(tag); - single_buf.RecvInitialMetadata(context_); - call_.PerformOps(&single_buf); - initial_metadata_read_ = true; - } - - /// See \a ClientAysncResponseReaderInterface::Finish for semantics. - /// - /// Side effect: - /// - the \a ClientContext associated with this call is updated with - /// possible initial and trailing metadata sent from the server. - void Finish(R* msg, Status* status, void* tag) override { - assert(started_); - if (initial_metadata_read_) { - finish_buf.set_output_tag(tag); - finish_buf.RecvMessage(msg); - finish_buf.AllowNoMessage(); - finish_buf.ClientRecvStatus(context_, status); - call_.PerformOps(&finish_buf); - } else { - single_buf.set_output_tag(tag); - single_buf.RecvInitialMetadata(context_); - single_buf.RecvMessage(msg); - single_buf.AllowNoMessage(); - single_buf.ClientRecvStatus(context_, status); - call_.PerformOps(&single_buf); - } - } - - private: - friend class internal::ClientAsyncResponseReaderFactory; - ::grpc_impl::ClientContext* const context_; - ::grpc::internal::Call call_; - bool started_; - bool initial_metadata_read_ = false; - - template - ClientAsyncResponseReader(::grpc::internal::Call call, - ::grpc_impl::ClientContext* context, - const W& request, bool start) - : context_(context), call_(call), started_(start) { - // Bind the metadata at time of StartCallInternal but set up the rest here - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(single_buf.SendMessage(request).ok()); - single_buf.ClientSendClose(); - if (start) StartCallInternal(); - } - - void StartCallInternal() { - single_buf.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - } - - // disable operator new - static void* operator new(std::size_t size); - static void* operator new(std::size_t size, void* p) { return p; } - - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpClientSendClose, - ::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpRecvMessage, - ::grpc::internal::CallOpClientRecvStatus> - single_buf; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage, - ::grpc::internal::CallOpClientRecvStatus> - finish_buf; -}; - -/// Async server-side API for handling unary calls, where the single -/// response message sent to the client is of type \a W. template -class ServerAsyncResponseWriter final - : public internal::ServerAsyncStreamingInterface { - public: - explicit ServerAsyncResponseWriter(::grpc_impl::ServerContext* ctx) - : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} - - /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. - /// - /// Side effect: - /// The initial metadata that will be sent to the client from this op will - /// be taken from the \a ServerContext associated with the call. - /// - /// \param[in] tag Tag identifying this request. - void SendInitialMetadata(void* tag) override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - - meta_buf_.set_output_tag(tag); - meta_buf_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_buf_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - call_.PerformOps(&meta_buf_); - } - - /// Indicate that the stream is to be finished and request notification - /// when the server has sent the appropriate signals to the client to - /// end the call. Should not be used concurrently with other operations. - /// - /// \param[in] tag Tag identifying this request. - /// \param[in] status To be sent to the client as the result of the call. - /// \param[in] msg Message to be sent to the client. - /// - /// Side effect: - /// - also sends initial metadata if not already sent (using the - /// \a ServerContext associated with this call). - /// - /// Note: if \a status has a non-OK code, then \a msg will not be sent, - /// and the client will receive only the status with possible trailing - /// metadata. - void Finish(const W& msg, const Status& status, void* tag) { - finish_buf_.set_output_tag(tag); - finish_buf_.set_core_cq_tag(&finish_buf_); - if (!ctx_->sent_initial_metadata_) { - finish_buf_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_buf_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - // The response is dropped if the status is not OK. - if (status.ok()) { - finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_, - finish_buf_.SendMessage(msg)); - } else { - finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_, status); - } - call_.PerformOps(&finish_buf_); - } - - /// Indicate that the stream is to be finished with a non-OK status, - /// and request notification for when the server has finished sending the - /// appropriate signals to the client to end the call. - /// Should not be used concurrently with other operations. - /// - /// \param[in] tag Tag identifying this request. - /// \param[in] status To be sent to the client as the result of the call. - /// - Note: \a status must have a non-OK code. - /// - /// Side effect: - /// - also sends initial metadata if not already sent (using the - /// \a ServerContext associated with this call). - void FinishWithError(const Status& status, void* tag) { - GPR_CODEGEN_ASSERT(!status.ok()); - finish_buf_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - finish_buf_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_buf_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_, status); - call_.PerformOps(&finish_buf_); - } - - private: - void BindCall(::grpc::internal::Call* call) override { call_ = *call; } - - ::grpc::internal::Call call_; - ::grpc_impl::ServerContext* ctx_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> - meta_buf_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpServerSendStatus> - finish_buf_; -}; +using ServerAsyncResponseWriter = ::grpc_impl::ServerAsyncResponseWriter; } // namespace grpc -namespace std { -template -class default_delete> { - public: - void operator()(void* p) {} -}; -template -class default_delete> { - public: - void operator()(void* p) {} -}; -} // namespace std - #endif // GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_H diff --git a/include/grpcpp/impl/codegen/async_unary_call_impl.h b/include/grpcpp/impl/codegen/async_unary_call_impl.h new file mode 100644 index 00000000000..ff8bf15602b --- /dev/null +++ b/include/grpcpp/impl/codegen/async_unary_call_impl.h @@ -0,0 +1,315 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_IMPL_H +#define GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_IMPL_H + +#include +#include +#include +#include +#include +#include +#include + +namespace grpc_impl { + +/// An interface relevant for async client side unary RPCs (which send +/// one request message to a server and receive one response message). +template +class ClientAsyncResponseReaderInterface { + public: + virtual ~ClientAsyncResponseReaderInterface() {} + + /// Start the call that was set up by the constructor, but only if the + /// constructor was invoked through the "Prepare" API which doesn't actually + /// start the call + virtual void StartCall() = 0; + + /// Request notification of the reading of initial metadata. Completion + /// will be notified by \a tag on the associated completion queue. + /// This call is optional, but if it is used, it cannot be used concurrently + /// with or after the \a Finish method. + /// + /// \param[in] tag Tag identifying this request. + virtual void ReadInitialMetadata(void* tag) = 0; + + /// Request to receive the server's response \a msg and final \a status for + /// the call, and to notify \a tag on this call's completion queue when + /// finished. + /// + /// This function will return when either: + /// - when the server's response message and status have been received. + /// - when the server has returned a non-OK status (no message expected in + /// this case). + /// - when the call failed for some reason and the library generated a + /// non-OK status. + /// + /// \param[in] tag Tag identifying this request. + /// \param[out] status To be updated with the operation status. + /// \param[out] msg To be filled in with the server's response message. + virtual void Finish(R* msg, ::grpc::Status* status, void* tag) = 0; +}; + +namespace internal { +template +class ClientAsyncResponseReaderFactory { + public: + /// Start a call and write the request out if \a start is set. + /// \a tag will be notified on \a cq when the call has been started (i.e. + /// intitial metadata sent) and \a request has been written out. + /// If \a start is not set, the actual call must be initiated by StartCall + /// Note that \a context will be used to fill in custom initial metadata + /// used to send to the server when starting the call. + template + static ClientAsyncResponseReader* Create( + ::grpc::ChannelInterface* channel, ::grpc_impl::CompletionQueue* cq, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, const W& request, bool start) { + ::grpc::internal::Call call = channel->CreateCall(method, context, cq); + return new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientAsyncResponseReader))) + ClientAsyncResponseReader(call, context, request, start); + } +}; +} // namespace internal + +/// Async API for client-side unary RPCs, where the message response +/// received from the server is of type \a R. +template +class ClientAsyncResponseReader final + : public ClientAsyncResponseReaderInterface { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* ptr, std::size_t size) { + assert(size == sizeof(ClientAsyncResponseReader)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { assert(0); } + + void StartCall() override { + assert(!started_); + started_ = true; + StartCallInternal(); + } + + /// See \a ClientAsyncResponseReaderInterface::ReadInitialMetadata for + /// semantics. + /// + /// Side effect: + /// - the \a ClientContext associated with this call is updated with + /// possible initial and trailing metadata sent from the server. + void ReadInitialMetadata(void* tag) override { + assert(started_); + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + single_buf.set_output_tag(tag); + single_buf.RecvInitialMetadata(context_); + call_.PerformOps(&single_buf); + initial_metadata_read_ = true; + } + + /// See \a ClientAysncResponseReaderInterface::Finish for semantics. + /// + /// Side effect: + /// - the \a ClientContext associated with this call is updated with + /// possible initial and trailing metadata sent from the server. + void Finish(R* msg, ::grpc::Status* status, void* tag) override { + assert(started_); + if (initial_metadata_read_) { + finish_buf.set_output_tag(tag); + finish_buf.RecvMessage(msg); + finish_buf.AllowNoMessage(); + finish_buf.ClientRecvStatus(context_, status); + call_.PerformOps(&finish_buf); + } else { + single_buf.set_output_tag(tag); + single_buf.RecvInitialMetadata(context_); + single_buf.RecvMessage(msg); + single_buf.AllowNoMessage(); + single_buf.ClientRecvStatus(context_, status); + call_.PerformOps(&single_buf); + } + } + + private: + friend class internal::ClientAsyncResponseReaderFactory; + ::grpc_impl::ClientContext* const context_; + ::grpc::internal::Call call_; + bool started_; + bool initial_metadata_read_ = false; + + template + ClientAsyncResponseReader(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, + const W& request, bool start) + : context_(context), call_(call), started_(start) { + // Bind the metadata at time of StartCallInternal but set up the rest here + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(single_buf.SendMessage(request).ok()); + single_buf.ClientSendClose(); + if (start) StartCallInternal(); + } + + void StartCallInternal() { + single_buf.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + } + + // disable operator new + static void* operator new(std::size_t size); + static void* operator new(std::size_t size, void* p) { return p; } + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose, + ::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpRecvMessage, + ::grpc::internal::CallOpClientRecvStatus> + single_buf; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage, + ::grpc::internal::CallOpClientRecvStatus> + finish_buf; +}; + +/// Async server-side API for handling unary calls, where the single +/// response message sent to the client is of type \a W. +template +class ServerAsyncResponseWriter final + : public ::grpc::internal::ServerAsyncStreamingInterface { + public: + explicit ServerAsyncResponseWriter(::grpc_impl::ServerContext* ctx) + : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} + + /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. + /// + /// Side effect: + /// The initial metadata that will be sent to the client from this op will + /// be taken from the \a ServerContext associated with the call. + /// + /// \param[in] tag Tag identifying this request. + void SendInitialMetadata(void* tag) override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + meta_buf_.set_output_tag(tag); + meta_buf_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_buf_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_.PerformOps(&meta_buf_); + } + + /// Indicate that the stream is to be finished and request notification + /// when the server has sent the appropriate signals to the client to + /// end the call. Should not be used concurrently with other operations. + /// + /// \param[in] tag Tag identifying this request. + /// \param[in] status To be sent to the client as the result of the call. + /// \param[in] msg Message to be sent to the client. + /// + /// Side effect: + /// - also sends initial metadata if not already sent (using the + /// \a ServerContext associated with this call). + /// + /// Note: if \a status has a non-OK code, then \a msg will not be sent, + /// and the client will receive only the status with possible trailing + /// metadata. + void Finish(const W& msg, const ::grpc::Status& status, void* tag) { + finish_buf_.set_output_tag(tag); + finish_buf_.set_core_cq_tag(&finish_buf_); + if (!ctx_->sent_initial_metadata_) { + finish_buf_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_buf_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // The response is dropped if the status is not OK. + if (status.ok()) { + finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_, + finish_buf_.SendMessage(msg)); + } else { + finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_, status); + } + call_.PerformOps(&finish_buf_); + } + + /// Indicate that the stream is to be finished with a non-OK status, + /// and request notification for when the server has finished sending the + /// appropriate signals to the client to end the call. + /// Should not be used concurrently with other operations. + /// + /// \param[in] tag Tag identifying this request. + /// \param[in] status To be sent to the client as the result of the call. + /// - Note: \a status must have a non-OK code. + /// + /// Side effect: + /// - also sends initial metadata if not already sent (using the + /// \a ServerContext associated with this call). + void FinishWithError(const ::grpc::Status& status, void* tag) { + GPR_CODEGEN_ASSERT(!status.ok()); + finish_buf_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + finish_buf_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_buf_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_, status); + call_.PerformOps(&finish_buf_); + } + + private: + void BindCall(::grpc::internal::Call* call) override { call_ = *call; } + + ::grpc::internal::Call call_; + ::grpc_impl::ServerContext* ctx_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_buf_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + finish_buf_; +}; + +} // namespace grpc_impl + +namespace std { +template +class default_delete<::grpc_impl::ClientAsyncResponseReader> { + public: + void operator()(void* p) {} +}; +template +class default_delete<::grpc_impl::ClientAsyncResponseReaderInterface> { + public: + void operator()(void* p) {} +}; +} // namespace std + +#endif // GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_IMPL_H diff --git a/include/grpcpp/impl/codegen/byte_buffer.h b/include/grpcpp/impl/codegen/byte_buffer.h index e2ba9344bcb..0b7be6fc753 100644 --- a/include/grpcpp/impl/codegen/byte_buffer.h +++ b/include/grpcpp/impl/codegen/byte_buffer.h @@ -29,6 +29,17 @@ #include +namespace grpc_impl { +namespace internal { + +template +class CallbackUnaryHandler; +template +class CallbackServerStreamingHandler; + +} // namespace internal +} // namespace grpc_impl + namespace grpc { class ServerInterface; @@ -45,10 +56,6 @@ template class RpcMethodHandler; template class ServerStreamingHandler; -template -class CallbackUnaryHandler; -template -class CallbackServerStreamingHandler; template class ErrorMethodHandler; class ExternalConnectionAcceptorImpl; @@ -176,9 +183,9 @@ class ByteBuffer final { template friend class internal::ServerStreamingHandler; template - friend class internal::CallbackUnaryHandler; + friend class ::grpc_impl::internal::CallbackUnaryHandler; template - friend class ::grpc::internal::CallbackServerStreamingHandler; + friend class ::grpc_impl::internal::CallbackServerStreamingHandler; template friend class internal::ErrorMethodHandler; template diff --git a/include/grpcpp/impl/codegen/call_op_set.h b/include/grpcpp/impl/codegen/call_op_set.h index d0958bbb251..84d1407cbe2 100644 --- a/include/grpcpp/impl/codegen/call_op_set.h +++ b/include/grpcpp/impl/codegen/call_op_set.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/grpcpp/impl/codegen/channel_interface.h b/include/grpcpp/impl/codegen/channel_interface.h index 836c287e509..dd2fe8d687a 100644 --- a/include/grpcpp/impl/codegen/channel_interface.h +++ b/include/grpcpp/impl/codegen/channel_interface.h @@ -27,24 +27,13 @@ namespace grpc_impl { class ClientContext; class CompletionQueue; -} // namespace grpc_impl - -namespace grpc { -class ChannelInterface; - template class ClientReader; template class ClientWriter; template class ClientReaderWriter; - namespace internal { -class Call; -class CallOpSetInterface; -class RpcMethod; -template -class BlockingUnaryCallImpl; template class CallbackUnaryCallImpl; template @@ -62,7 +51,19 @@ class ClientCallbackReaderFactory; template class ClientCallbackWriterFactory; class ClientCallbackUnaryFactory; +} // namespace internal +} // namespace grpc_impl + +namespace grpc { +class ChannelInterface; + +namespace internal { +class Call; +class CallOpSetInterface; +class RpcMethod; class InterceptedChannel; +template +class BlockingUnaryCallImpl; } // namespace internal /// Codegen interface for \a grpc::Channel. @@ -102,30 +103,30 @@ class ChannelInterface { private: template - friend class ::grpc::ClientReader; + friend class ::grpc_impl::ClientReader; template - friend class ::grpc::ClientWriter; + friend class ::grpc_impl::ClientWriter; template - friend class ::grpc::ClientReaderWriter; + friend class ::grpc_impl::ClientReaderWriter; template - friend class ::grpc::internal::ClientAsyncReaderFactory; + friend class ::grpc_impl::internal::ClientAsyncReaderFactory; template - friend class ::grpc::internal::ClientAsyncWriterFactory; + friend class ::grpc_impl::internal::ClientAsyncWriterFactory; template - friend class ::grpc::internal::ClientAsyncReaderWriterFactory; + friend class ::grpc_impl::internal::ClientAsyncReaderWriterFactory; template - friend class ::grpc::internal::ClientAsyncResponseReaderFactory; + friend class ::grpc_impl::internal::ClientAsyncResponseReaderFactory; template - friend class ::grpc::internal::ClientCallbackReaderWriterFactory; + friend class ::grpc_impl::internal::ClientCallbackReaderWriterFactory; template - friend class ::grpc::internal::ClientCallbackReaderFactory; + friend class ::grpc_impl::internal::ClientCallbackReaderFactory; template - friend class ::grpc::internal::ClientCallbackWriterFactory; - friend class ::grpc::internal::ClientCallbackUnaryFactory; + friend class ::grpc_impl::internal::ClientCallbackWriterFactory; + friend class ::grpc_impl::internal::ClientCallbackUnaryFactory; template friend class ::grpc::internal::BlockingUnaryCallImpl; template - friend class ::grpc::internal::CallbackUnaryCallImpl; + friend class ::grpc_impl::internal::CallbackUnaryCallImpl; friend class ::grpc::internal::RpcMethod; friend class ::grpc::internal::InterceptedChannel; virtual internal::Call CreateCall(const internal::RpcMethod& method, diff --git a/include/grpcpp/impl/codegen/client_callback.h b/include/grpcpp/impl/codegen/client_callback.h index 9441a48b051..4f60741624a 100644 --- a/include/grpcpp/impl/codegen/client_callback.h +++ b/include/grpcpp/impl/codegen/client_callback.h @@ -19,1012 +19,25 @@ #ifndef GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_H #define GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_H -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace grpc_impl { -class Channel; -class ClientContext; -} // namespace grpc_impl +#include namespace grpc { - -namespace internal { -class RpcMethod; - -/// Perform a callback-based unary call -/// TODO(vjpai): Combine as much as possible with the blocking unary call code -template -void CallbackUnaryCall(ChannelInterface* channel, const RpcMethod& method, - ::grpc_impl::ClientContext* context, - const InputMessage* request, OutputMessage* result, - std::function on_completion) { - CallbackUnaryCallImpl x( - channel, method, context, request, result, on_completion); -} - -template -class CallbackUnaryCallImpl { - public: - CallbackUnaryCallImpl(ChannelInterface* channel, const RpcMethod& method, - ::grpc_impl::ClientContext* context, - const InputMessage* request, OutputMessage* result, - std::function on_completion) { - CompletionQueue* cq = channel->CallbackCQ(); - GPR_CODEGEN_ASSERT(cq != nullptr); - Call call(channel->CreateCall(method, context, cq)); - - using FullCallOpSet = - CallOpSet, - CallOpClientSendClose, CallOpClientRecvStatus>; - - auto* ops = new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(FullCallOpSet))) FullCallOpSet; - - auto* tag = new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(CallbackWithStatusTag))) - CallbackWithStatusTag(call.call(), on_completion, ops); - - // TODO(vjpai): Unify code with sync API as much as possible - Status s = ops->SendMessagePtr(request); - if (!s.ok()) { - tag->force_run(s); - return; - } - ops->SendInitialMetadata(&context->send_initial_metadata_, - context->initial_metadata_flags()); - ops->RecvInitialMetadata(context); - ops->RecvMessage(result); - ops->AllowNoMessage(); - ops->ClientSendClose(); - ops->ClientRecvStatus(context, tag->status_ptr()); - ops->set_core_cq_tag(tag); - call.PerformOps(ops); - } -}; -} // namespace internal - namespace experimental { -// Forward declarations -template -class ClientBidiReactor; template -class ClientReadReactor; -template -class ClientWriteReactor; -class ClientUnaryReactor; - -// NOTE: The streaming objects are not actually implemented in the public API. -// These interfaces are provided for mocking only. Typical applications -// will interact exclusively with the reactors that they define. -template -class ClientCallbackReaderWriter { - public: - virtual ~ClientCallbackReaderWriter() {} - virtual void StartCall() = 0; - virtual void Write(const Request* req, WriteOptions options) = 0; - virtual void WritesDone() = 0; - virtual void Read(Response* resp) = 0; - virtual void AddHold(int holds) = 0; - virtual void RemoveHold() = 0; - - protected: - void BindReactor(ClientBidiReactor* reactor) { - reactor->BindStream(this); - } -}; - -template -class ClientCallbackReader { - public: - virtual ~ClientCallbackReader() {} - virtual void StartCall() = 0; - virtual void Read(Response* resp) = 0; - virtual void AddHold(int holds) = 0; - virtual void RemoveHold() = 0; - - protected: - void BindReactor(ClientReadReactor* reactor) { - reactor->BindReader(this); - } -}; +using ClientReadReactor = + ::grpc_impl::experimental::ClientReadReactor; template -class ClientCallbackWriter { - public: - virtual ~ClientCallbackWriter() {} - virtual void StartCall() = 0; - void Write(const Request* req) { Write(req, WriteOptions()); } - virtual void Write(const Request* req, WriteOptions options) = 0; - void WriteLast(const Request* req, WriteOptions options) { - Write(req, options.set_last_message()); - } - virtual void WritesDone() = 0; +using ClientWriteReactor = + ::grpc_impl::experimental::ClientWriteReactor; - virtual void AddHold(int holds) = 0; - virtual void RemoveHold() = 0; - - protected: - void BindReactor(ClientWriteReactor* reactor) { - reactor->BindWriter(this); - } -}; - -class ClientCallbackUnary { - public: - virtual ~ClientCallbackUnary() {} - virtual void StartCall() = 0; - - protected: - void BindReactor(ClientUnaryReactor* reactor); -}; - -// The following classes are the reactor interfaces that are to be implemented -// by the user. They are passed in to the library as an argument to a call on a -// stub (either a codegen-ed call or a generic call). The streaming RPC is -// activated by calling StartCall, possibly after initiating StartRead, -// StartWrite, or AddHold operations on the streaming object. Note that none of -// the classes are pure; all reactions have a default empty reaction so that the -// user class only needs to override those classes that it cares about. -// The reactor must be passed to the stub invocation before any of the below -// operations can be called. - -/// \a ClientBidiReactor is the interface for a bidirectional streaming RPC. template -class ClientBidiReactor { - public: - virtual ~ClientBidiReactor() {} - - /// Activate the RPC and initiate any reads or writes that have been Start'ed - /// before this call. All streaming RPCs issued by the client MUST have - /// StartCall invoked on them (even if they are canceled) as this call is the - /// activation of their lifecycle. - void StartCall() { stream_->StartCall(); } - - /// Initiate a read operation (or post it for later initiation if StartCall - /// has not yet been invoked). - /// - /// \param[out] resp Where to eventually store the read message. Valid when - /// the library calls OnReadDone - void StartRead(Response* resp) { stream_->Read(resp); } - - /// Initiate a write operation (or post it for later initiation if StartCall - /// has not yet been invoked). - /// - /// \param[in] req The message to be written. The library takes temporary - /// ownership until OnWriteDone, at which point the application - /// regains ownership of msg. - void StartWrite(const Request* req) { StartWrite(req, WriteOptions()); } - - /// Initiate/post a write operation with specified options. - /// - /// \param[in] req The message to be written. The library takes temporary - /// ownership until OnWriteDone, at which point the application - /// regains ownership of msg. - /// \param[in] options The WriteOptions to use for writing this message - void StartWrite(const Request* req, WriteOptions options) { - stream_->Write(req, std::move(options)); - } - - /// Initiate/post a write operation with specified options and an indication - /// that this is the last write (like StartWrite and StartWritesDone, merged). - /// Note that calling this means that no more calls to StartWrite, - /// StartWriteLast, or StartWritesDone are allowed. - /// - /// \param[in] req The message to be written. The library takes temporary - /// ownership until OnWriteDone, at which point the application - /// regains ownership of msg. - /// \param[in] options The WriteOptions to use for writing this message - void StartWriteLast(const Request* req, WriteOptions options) { - StartWrite(req, std::move(options.set_last_message())); - } - - /// Indicate that the RPC will have no more write operations. This can only be - /// issued once for a given RPC. This is not required or allowed if - /// StartWriteLast is used since that already has the same implication. - /// Note that calling this means that no more calls to StartWrite, - /// StartWriteLast, or StartWritesDone are allowed. - void StartWritesDone() { stream_->WritesDone(); } - - /// Holds are needed if (and only if) this stream has operations that take - /// place on it after StartCall but from outside one of the reactions - /// (OnReadDone, etc). This is _not_ a common use of the streaming API. - /// - /// Holds must be added before calling StartCall. If a stream still has a hold - /// in place, its resources will not be destroyed even if the status has - /// already come in from the wire and there are currently no active callbacks - /// outstanding. Similarly, the stream will not call OnDone if there are still - /// holds on it. - /// - /// For example, if a StartRead or StartWrite operation is going to be - /// initiated from elsewhere in the application, the application should call - /// AddHold or AddMultipleHolds before StartCall. If there is going to be, - /// for example, a read-flow and a write-flow taking place outside the - /// reactions, then call AddMultipleHolds(2) before StartCall. When the - /// application knows that it won't issue any more read operations (such as - /// when a read comes back as not ok), it should issue a RemoveHold(). It - /// should also call RemoveHold() again after it does StartWriteLast or - /// StartWritesDone that indicates that there will be no more write ops. - /// The number of RemoveHold calls must match the total number of AddHold - /// calls plus the number of holds added by AddMultipleHolds. - void AddHold() { AddMultipleHolds(1); } - void AddMultipleHolds(int holds) { stream_->AddHold(holds); } - void RemoveHold() { stream_->RemoveHold(); } - - /// Notifies the application that all operations associated with this RPC - /// have completed and provides the RPC status outcome. - /// - /// \param[in] s The status outcome of this RPC - virtual void OnDone(const Status& s) {} - - /// Notifies the application that a read of initial metadata from the - /// server is done. If the application chooses not to implement this method, - /// it can assume that the initial metadata has been read before the first - /// call of OnReadDone or OnDone. - /// - /// \param[in] ok Was the initial metadata read successfully? If false, no - /// further read-side operation will succeed. - virtual void OnReadInitialMetadataDone(bool ok) {} - - /// Notifies the application that a StartRead operation completed. - /// - /// \param[in] ok Was it successful? If false, no further read-side operation - /// will succeed. - virtual void OnReadDone(bool ok) {} - - /// Notifies the application that a StartWrite operation completed. - /// - /// \param[in] ok Was it successful? If false, no further write-side operation - /// will succeed. - virtual void OnWriteDone(bool ok) {} - - /// Notifies the application that a StartWritesDone operation completed. Note - /// that this is only used on explicit StartWritesDone operations and not for - /// those that are implicitly invoked as part of a StartWriteLast. - /// - /// \param[in] ok Was it successful? If false, the application will later see - /// the failure reflected as a bad status in OnDone. - virtual void OnWritesDoneDone(bool ok) {} - - private: - friend class ClientCallbackReaderWriter; - void BindStream(ClientCallbackReaderWriter* stream) { - stream_ = stream; - } - ClientCallbackReaderWriter* stream_; -}; - -/// \a ClientReadReactor is the interface for a server-streaming RPC. -/// All public methods behave as in ClientBidiReactor. -template -class ClientReadReactor { - public: - virtual ~ClientReadReactor() {} - - void StartCall() { reader_->StartCall(); } - void StartRead(Response* resp) { reader_->Read(resp); } - - void AddHold() { AddMultipleHolds(1); } - void AddMultipleHolds(int holds) { reader_->AddHold(holds); } - void RemoveHold() { reader_->RemoveHold(); } - - virtual void OnDone(const Status& s) {} - virtual void OnReadInitialMetadataDone(bool ok) {} - virtual void OnReadDone(bool ok) {} - - private: - friend class ClientCallbackReader; - void BindReader(ClientCallbackReader* reader) { reader_ = reader; } - ClientCallbackReader* reader_; -}; - -/// \a ClientWriteReactor is the interface for a client-streaming RPC. -/// All public methods behave as in ClientBidiReactor. -template -class ClientWriteReactor { - public: - virtual ~ClientWriteReactor() {} - - void StartCall() { writer_->StartCall(); } - void StartWrite(const Request* req) { StartWrite(req, WriteOptions()); } - void StartWrite(const Request* req, WriteOptions options) { - writer_->Write(req, std::move(options)); - } - void StartWriteLast(const Request* req, WriteOptions options) { - StartWrite(req, std::move(options.set_last_message())); - } - void StartWritesDone() { writer_->WritesDone(); } - - void AddHold() { AddMultipleHolds(1); } - void AddMultipleHolds(int holds) { writer_->AddHold(holds); } - void RemoveHold() { writer_->RemoveHold(); } - - virtual void OnDone(const Status& s) {} - virtual void OnReadInitialMetadataDone(bool ok) {} - virtual void OnWriteDone(bool ok) {} - virtual void OnWritesDoneDone(bool ok) {} - - private: - friend class ClientCallbackWriter; - void BindWriter(ClientCallbackWriter* writer) { writer_ = writer; } - ClientCallbackWriter* writer_; -}; - -/// \a ClientUnaryReactor is a reactor-style interface for a unary RPC. -/// This is _not_ a common way of invoking a unary RPC. In practice, this -/// option should be used only if the unary RPC wants to receive initial -/// metadata without waiting for the response to complete. Most deployments of -/// RPC systems do not use this option, but it is needed for generality. -/// All public methods behave as in ClientBidiReactor. -/// StartCall is included for consistency with the other reactor flavors: even -/// though there are no StartRead or StartWrite operations to queue before the -/// call (that is part of the unary call itself) and there is no reactor object -/// being created as a result of this call, we keep a consistent 2-phase -/// initiation API among all the reactor flavors. -class ClientUnaryReactor { - public: - virtual ~ClientUnaryReactor() {} - - void StartCall() { call_->StartCall(); } - virtual void OnDone(const Status& s) {} - virtual void OnReadInitialMetadataDone(bool ok) {} - - private: - friend class ClientCallbackUnary; - void BindCall(ClientCallbackUnary* call) { call_ = call; } - ClientCallbackUnary* call_; -}; - -// Define function out-of-line from class to avoid forward declaration issue -inline void ClientCallbackUnary::BindReactor(ClientUnaryReactor* reactor) { - reactor->BindCall(this); -} +using ClientBidiReactor = + ::grpc_impl::experimental::ClientBidiReactor; +typedef ::grpc_impl::experimental::ClientUnaryReactor ClientUnaryReactor; } // namespace experimental - -namespace internal { - -// Forward declare factory classes for friendship -template -class ClientCallbackReaderWriterFactory; -template -class ClientCallbackReaderFactory; -template -class ClientCallbackWriterFactory; - -template -class ClientCallbackReaderWriterImpl - : public ::grpc::experimental::ClientCallbackReaderWriter { - public: - // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { - assert(size == sizeof(ClientCallbackReaderWriterImpl)); - } - - // This operator should never be called as the memory should be freed as part - // of the arena destruction. It only exists to provide a matching operator - // delete to the operator new so that some compilers will not complain (see - // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this - // there are no tests catching the compiler warning. - static void operator delete(void*, void*) { assert(0); } - - void MaybeFinish() { - if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( - 1, std::memory_order_acq_rel) == 1)) { - Status s = std::move(finish_status_); - auto* reactor = reactor_; - auto* call = call_.call(); - this->~ClientCallbackReaderWriterImpl(); - g_core_codegen_interface->grpc_call_unref(call); - reactor->OnDone(s); - } - } - - void StartCall() override { - // This call initiates two batches, plus any backlog, each with a callback - // 1. Send initial metadata (unless corked) + recv initial metadata - // 2. Any read backlog - // 3. Any write backlog - // 4. Recv trailing metadata, on_completion callback - started_ = true; - - start_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadInitialMetadataDone(ok); - MaybeFinish(); - }, - &start_ops_); - if (!start_corked_) { - start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - } - start_ops_.RecvInitialMetadata(context_); - start_ops_.set_core_cq_tag(&start_tag_); - call_.PerformOps(&start_ops_); - - // Also set up the read and write tags so that they don't have to be set up - // each time - write_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnWriteDone(ok); - MaybeFinish(); - }, - &write_ops_); - write_ops_.set_core_cq_tag(&write_tag_); - - read_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadDone(ok); - MaybeFinish(); - }, - &read_ops_); - read_ops_.set_core_cq_tag(&read_tag_); - if (read_ops_at_start_) { - call_.PerformOps(&read_ops_); - } - - if (write_ops_at_start_) { - call_.PerformOps(&write_ops_); - } - - if (writes_done_ops_at_start_) { - call_.PerformOps(&writes_done_ops_); - } - - finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, - &finish_ops_); - finish_ops_.ClientRecvStatus(context_, &finish_status_); - finish_ops_.set_core_cq_tag(&finish_tag_); - call_.PerformOps(&finish_ops_); - } - - void Read(Response* msg) override { - read_ops_.RecvMessage(msg); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - if (started_) { - call_.PerformOps(&read_ops_); - } else { - read_ops_at_start_ = true; - } - } - - void Write(const Request* msg, WriteOptions options) override { - if (start_corked_) { - write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - start_corked_ = false; - } - - if (options.is_last_message()) { - options.set_buffer_hint(); - write_ops_.ClientSendClose(); - } - // TODO(vjpai): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(msg, options).ok()); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - if (started_) { - call_.PerformOps(&write_ops_); - } else { - write_ops_at_start_ = true; - } - } - void WritesDone() override { - if (start_corked_) { - writes_done_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - start_corked_ = false; - } - writes_done_ops_.ClientSendClose(); - writes_done_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnWritesDoneDone(ok); - MaybeFinish(); - }, - &writes_done_ops_); - writes_done_ops_.set_core_cq_tag(&writes_done_tag_); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - if (started_) { - call_.PerformOps(&writes_done_ops_); - } else { - writes_done_ops_at_start_ = true; - } - } - - void AddHold(int holds) override { - callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed); - } - void RemoveHold() override { MaybeFinish(); } - - private: - friend class ClientCallbackReaderWriterFactory; - - ClientCallbackReaderWriterImpl( - Call call, ::grpc_impl::ClientContext* context, - ::grpc::experimental::ClientBidiReactor* reactor) - : context_(context), - call_(call), - reactor_(reactor), - start_corked_(context_->initial_metadata_corked_) { - this->BindReactor(reactor); - } - - ::grpc_impl::ClientContext* const context_; - Call call_; - ::grpc::experimental::ClientBidiReactor* const reactor_; - - CallOpSet start_ops_; - CallbackWithSuccessTag start_tag_; - bool start_corked_; - - CallOpSet finish_ops_; - CallbackWithSuccessTag finish_tag_; - Status finish_status_; - - CallOpSet - write_ops_; - CallbackWithSuccessTag write_tag_; - bool write_ops_at_start_{false}; - - CallOpSet writes_done_ops_; - CallbackWithSuccessTag writes_done_tag_; - bool writes_done_ops_at_start_{false}; - - CallOpSet> read_ops_; - CallbackWithSuccessTag read_tag_; - bool read_ops_at_start_{false}; - - // Minimum of 2 callbacks to pre-register for start and finish - std::atomic callbacks_outstanding_{2}; - bool started_{false}; -}; - -template -class ClientCallbackReaderWriterFactory { - public: - static void Create( - ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, - ::grpc::experimental::ClientBidiReactor* reactor) { - Call call = channel->CreateCall(method, context, channel->CallbackCQ()); - - g_core_codegen_interface->grpc_call_ref(call.call()); - new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(ClientCallbackReaderWriterImpl))) - ClientCallbackReaderWriterImpl(call, context, - reactor); - } -}; - -template -class ClientCallbackReaderImpl - : public ::grpc::experimental::ClientCallbackReader { - public: - // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { - assert(size == sizeof(ClientCallbackReaderImpl)); - } - - // This operator should never be called as the memory should be freed as part - // of the arena destruction. It only exists to provide a matching operator - // delete to the operator new so that some compilers will not complain (see - // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this - // there are no tests catching the compiler warning. - static void operator delete(void*, void*) { assert(0); } - - void MaybeFinish() { - if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( - 1, std::memory_order_acq_rel) == 1)) { - Status s = std::move(finish_status_); - auto* reactor = reactor_; - auto* call = call_.call(); - this->~ClientCallbackReaderImpl(); - g_core_codegen_interface->grpc_call_unref(call); - reactor->OnDone(s); - } - } - - void StartCall() override { - // This call initiates two batches, plus any backlog, each with a callback - // 1. Send initial metadata (unless corked) + recv initial metadata - // 2. Any backlog - // 3. Recv trailing metadata, on_completion callback - started_ = true; - - start_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadInitialMetadataDone(ok); - MaybeFinish(); - }, - &start_ops_); - start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - start_ops_.RecvInitialMetadata(context_); - start_ops_.set_core_cq_tag(&start_tag_); - call_.PerformOps(&start_ops_); - - // Also set up the read tag so it doesn't have to be set up each time - read_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadDone(ok); - MaybeFinish(); - }, - &read_ops_); - read_ops_.set_core_cq_tag(&read_tag_); - if (read_ops_at_start_) { - call_.PerformOps(&read_ops_); - } - - finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, - &finish_ops_); - finish_ops_.ClientRecvStatus(context_, &finish_status_); - finish_ops_.set_core_cq_tag(&finish_tag_); - call_.PerformOps(&finish_ops_); - } - - void Read(Response* msg) override { - read_ops_.RecvMessage(msg); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - if (started_) { - call_.PerformOps(&read_ops_); - } else { - read_ops_at_start_ = true; - } - } - - void AddHold(int holds) override { - callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed); - } - void RemoveHold() override { MaybeFinish(); } - - private: - friend class ClientCallbackReaderFactory; - - template - ClientCallbackReaderImpl( - Call call, ::grpc_impl::ClientContext* context, Request* request, - ::grpc::experimental::ClientReadReactor* reactor) - : context_(context), call_(call), reactor_(reactor) { - this->BindReactor(reactor); - // TODO(vjpai): don't assert - GPR_CODEGEN_ASSERT(start_ops_.SendMessagePtr(request).ok()); - start_ops_.ClientSendClose(); - } - - ::grpc_impl::ClientContext* const context_; - Call call_; - ::grpc::experimental::ClientReadReactor* const reactor_; - - CallOpSet - start_ops_; - CallbackWithSuccessTag start_tag_; - - CallOpSet finish_ops_; - CallbackWithSuccessTag finish_tag_; - Status finish_status_; - - CallOpSet> read_ops_; - CallbackWithSuccessTag read_tag_; - bool read_ops_at_start_{false}; - - // Minimum of 2 callbacks to pre-register for start and finish - std::atomic callbacks_outstanding_{2}; - bool started_{false}; -}; - -template -class ClientCallbackReaderFactory { - public: - template - static void Create( - ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, const Request* request, - ::grpc::experimental::ClientReadReactor* reactor) { - Call call = channel->CreateCall(method, context, channel->CallbackCQ()); - - g_core_codegen_interface->grpc_call_ref(call.call()); - new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(ClientCallbackReaderImpl))) - ClientCallbackReaderImpl(call, context, request, reactor); - } -}; - -template -class ClientCallbackWriterImpl - : public ::grpc::experimental::ClientCallbackWriter { - public: - // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { - assert(size == sizeof(ClientCallbackWriterImpl)); - } - - // This operator should never be called as the memory should be freed as part - // of the arena destruction. It only exists to provide a matching operator - // delete to the operator new so that some compilers will not complain (see - // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this - // there are no tests catching the compiler warning. - static void operator delete(void*, void*) { assert(0); } - - void MaybeFinish() { - if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( - 1, std::memory_order_acq_rel) == 1)) { - Status s = std::move(finish_status_); - auto* reactor = reactor_; - auto* call = call_.call(); - this->~ClientCallbackWriterImpl(); - g_core_codegen_interface->grpc_call_unref(call); - reactor->OnDone(s); - } - } - - void StartCall() override { - // This call initiates two batches, plus any backlog, each with a callback - // 1. Send initial metadata (unless corked) + recv initial metadata - // 2. Any backlog - // 3. Recv trailing metadata, on_completion callback - started_ = true; - - start_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadInitialMetadataDone(ok); - MaybeFinish(); - }, - &start_ops_); - if (!start_corked_) { - start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - } - start_ops_.RecvInitialMetadata(context_); - start_ops_.set_core_cq_tag(&start_tag_); - call_.PerformOps(&start_ops_); - - // Also set up the read and write tags so that they don't have to be set up - // each time - write_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnWriteDone(ok); - MaybeFinish(); - }, - &write_ops_); - write_ops_.set_core_cq_tag(&write_tag_); - - if (write_ops_at_start_) { - call_.PerformOps(&write_ops_); - } - - if (writes_done_ops_at_start_) { - call_.PerformOps(&writes_done_ops_); - } - - finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, - &finish_ops_); - finish_ops_.ClientRecvStatus(context_, &finish_status_); - finish_ops_.set_core_cq_tag(&finish_tag_); - call_.PerformOps(&finish_ops_); - } - - void Write(const Request* msg, WriteOptions options) override { - if (start_corked_) { - write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - start_corked_ = false; - } - - if (options.is_last_message()) { - options.set_buffer_hint(); - write_ops_.ClientSendClose(); - } - // TODO(vjpai): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(msg, options).ok()); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - if (started_) { - call_.PerformOps(&write_ops_); - } else { - write_ops_at_start_ = true; - } - } - void WritesDone() override { - if (start_corked_) { - writes_done_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - start_corked_ = false; - } - writes_done_ops_.ClientSendClose(); - writes_done_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnWritesDoneDone(ok); - MaybeFinish(); - }, - &writes_done_ops_); - writes_done_ops_.set_core_cq_tag(&writes_done_tag_); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - if (started_) { - call_.PerformOps(&writes_done_ops_); - } else { - writes_done_ops_at_start_ = true; - } - } - - void AddHold(int holds) override { - callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed); - } - void RemoveHold() override { MaybeFinish(); } - - private: - friend class ClientCallbackWriterFactory; - - template - ClientCallbackWriterImpl( - Call call, ::grpc_impl::ClientContext* context, Response* response, - ::grpc::experimental::ClientWriteReactor* reactor) - : context_(context), - call_(call), - reactor_(reactor), - start_corked_(context_->initial_metadata_corked_) { - this->BindReactor(reactor); - finish_ops_.RecvMessage(response); - finish_ops_.AllowNoMessage(); - } - - ::grpc_impl::ClientContext* const context_; - Call call_; - ::grpc::experimental::ClientWriteReactor* const reactor_; - - CallOpSet start_ops_; - CallbackWithSuccessTag start_tag_; - bool start_corked_; - - CallOpSet finish_ops_; - CallbackWithSuccessTag finish_tag_; - Status finish_status_; - - CallOpSet - write_ops_; - CallbackWithSuccessTag write_tag_; - bool write_ops_at_start_{false}; - - CallOpSet writes_done_ops_; - CallbackWithSuccessTag writes_done_tag_; - bool writes_done_ops_at_start_{false}; - - // Minimum of 2 callbacks to pre-register for start and finish - std::atomic callbacks_outstanding_{2}; - bool started_{false}; -}; - -template -class ClientCallbackWriterFactory { - public: - template - static void Create( - ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, Response* response, - ::grpc::experimental::ClientWriteReactor* reactor) { - Call call = channel->CreateCall(method, context, channel->CallbackCQ()); - - g_core_codegen_interface->grpc_call_ref(call.call()); - new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(ClientCallbackWriterImpl))) - ClientCallbackWriterImpl(call, context, response, reactor); - } -}; - -class ClientCallbackUnaryImpl final - : public ::grpc::experimental::ClientCallbackUnary { - public: - // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { - assert(size == sizeof(ClientCallbackUnaryImpl)); - } - - // This operator should never be called as the memory should be freed as part - // of the arena destruction. It only exists to provide a matching operator - // delete to the operator new so that some compilers will not complain (see - // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this - // there are no tests catching the compiler warning. - static void operator delete(void*, void*) { assert(0); } - - void StartCall() override { - // This call initiates two batches, each with a callback - // 1. Send initial metadata + write + writes done + recv initial metadata - // 2. Read message, recv trailing metadata - started_ = true; - - start_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadInitialMetadataDone(ok); - MaybeFinish(); - }, - &start_ops_); - start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - start_ops_.RecvInitialMetadata(context_); - start_ops_.set_core_cq_tag(&start_tag_); - call_.PerformOps(&start_ops_); - - finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, - &finish_ops_); - finish_ops_.ClientRecvStatus(context_, &finish_status_); - finish_ops_.set_core_cq_tag(&finish_tag_); - call_.PerformOps(&finish_ops_); - } - - void MaybeFinish() { - if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( - 1, std::memory_order_acq_rel) == 1)) { - Status s = std::move(finish_status_); - auto* reactor = reactor_; - auto* call = call_.call(); - this->~ClientCallbackUnaryImpl(); - g_core_codegen_interface->grpc_call_unref(call); - reactor->OnDone(s); - } - } - - private: - friend class ClientCallbackUnaryFactory; - - template - ClientCallbackUnaryImpl(Call call, ::grpc_impl::ClientContext* context, - Request* request, Response* response, - ::grpc::experimental::ClientUnaryReactor* reactor) - : context_(context), call_(call), reactor_(reactor) { - this->BindReactor(reactor); - // TODO(vjpai): don't assert - GPR_CODEGEN_ASSERT(start_ops_.SendMessagePtr(request).ok()); - start_ops_.ClientSendClose(); - finish_ops_.RecvMessage(response); - finish_ops_.AllowNoMessage(); - } - - ::grpc_impl::ClientContext* const context_; - Call call_; - ::grpc::experimental::ClientUnaryReactor* const reactor_; - - CallOpSet - start_ops_; - CallbackWithSuccessTag start_tag_; - - CallOpSet finish_ops_; - CallbackWithSuccessTag finish_tag_; - Status finish_status_; - - // This call will have 2 callbacks: start and finish - std::atomic callbacks_outstanding_{2}; - bool started_{false}; -}; - -class ClientCallbackUnaryFactory { - public: - template - static void Create(ChannelInterface* channel, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, - const Request* request, Response* response, - ::grpc::experimental::ClientUnaryReactor* reactor) { - Call call = channel->CreateCall(method, context, channel->CallbackCQ()); - - g_core_codegen_interface->grpc_call_ref(call.call()); - - new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(ClientCallbackUnaryImpl))) - ClientCallbackUnaryImpl(call, context, request, response, reactor); - } -}; - -} // namespace internal } // namespace grpc #endif // GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_H diff --git a/include/grpcpp/impl/codegen/client_callback_impl.h b/include/grpcpp/impl/codegen/client_callback_impl.h new file mode 100644 index 00000000000..81847bc9e04 --- /dev/null +++ b/include/grpcpp/impl/codegen/client_callback_impl.h @@ -0,0 +1,1067 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_IMPL_H +#define GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_IMPL_H +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace grpc { +namespace internal { +class RpcMethod; +} // namespace internal +} // namespace grpc + +namespace grpc_impl { +class Channel; +class ClientContext; + +namespace internal { + +/// Perform a callback-based unary call +/// TODO(vjpai): Combine as much as possible with the blocking unary call code +template +void CallbackUnaryCall(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + const InputMessage* request, OutputMessage* result, + std::function on_completion) { + CallbackUnaryCallImpl x( + channel, method, context, request, result, on_completion); +} + +template +class CallbackUnaryCallImpl { + public: + CallbackUnaryCallImpl(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + const InputMessage* request, OutputMessage* result, + std::function on_completion) { + ::grpc_impl::CompletionQueue* cq = channel->CallbackCQ(); + GPR_CODEGEN_ASSERT(cq != nullptr); + grpc::internal::Call call(channel->CreateCall(method, context, cq)); + + using FullCallOpSet = grpc::internal::CallOpSet< + ::grpc::internal::CallOpSendInitialMetadata, + grpc::internal::CallOpSendMessage, + grpc::internal::CallOpRecvInitialMetadata, + grpc::internal::CallOpRecvMessage, + grpc::internal::CallOpClientSendClose, + grpc::internal::CallOpClientRecvStatus>; + + auto* ops = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(FullCallOpSet))) FullCallOpSet; + + auto* tag = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(grpc::internal::CallbackWithStatusTag))) + grpc::internal::CallbackWithStatusTag(call.call(), on_completion, ops); + + // TODO(vjpai): Unify code with sync API as much as possible + ::grpc::Status s = ops->SendMessagePtr(request); + if (!s.ok()) { + tag->force_run(s); + return; + } + ops->SendInitialMetadata(&context->send_initial_metadata_, + context->initial_metadata_flags()); + ops->RecvInitialMetadata(context); + ops->RecvMessage(result); + ops->AllowNoMessage(); + ops->ClientSendClose(); + ops->ClientRecvStatus(context, tag->status_ptr()); + ops->set_core_cq_tag(tag); + call.PerformOps(ops); + } +}; +} // namespace internal + +namespace experimental { + +// Forward declarations +template +class ClientBidiReactor; +template +class ClientReadReactor; +template +class ClientWriteReactor; +class ClientUnaryReactor; + +// NOTE: The streaming objects are not actually implemented in the public API. +// These interfaces are provided for mocking only. Typical applications +// will interact exclusively with the reactors that they define. +template +class ClientCallbackReaderWriter { + public: + virtual ~ClientCallbackReaderWriter() {} + virtual void StartCall() = 0; + virtual void Write(const Request* req, ::grpc::WriteOptions options) = 0; + virtual void WritesDone() = 0; + virtual void Read(Response* resp) = 0; + virtual void AddHold(int holds) = 0; + virtual void RemoveHold() = 0; + + protected: + void BindReactor(ClientBidiReactor* reactor) { + reactor->BindStream(this); + } +}; + +template +class ClientCallbackReader { + public: + virtual ~ClientCallbackReader() {} + virtual void StartCall() = 0; + virtual void Read(Response* resp) = 0; + virtual void AddHold(int holds) = 0; + virtual void RemoveHold() = 0; + + protected: + void BindReactor(ClientReadReactor* reactor) { + reactor->BindReader(this); + } +}; + +template +class ClientCallbackWriter { + public: + virtual ~ClientCallbackWriter() {} + virtual void StartCall() = 0; + void Write(const Request* req) { Write(req, ::grpc::WriteOptions()); } + virtual void Write(const Request* req, ::grpc::WriteOptions options) = 0; + void WriteLast(const Request* req, ::grpc::WriteOptions options) { + Write(req, options.set_last_message()); + } + virtual void WritesDone() = 0; + + virtual void AddHold(int holds) = 0; + virtual void RemoveHold() = 0; + + protected: + void BindReactor(ClientWriteReactor* reactor) { + reactor->BindWriter(this); + } +}; + +class ClientCallbackUnary { + public: + virtual ~ClientCallbackUnary() {} + virtual void StartCall() = 0; + + protected: + void BindReactor(ClientUnaryReactor* reactor); +}; + +// The following classes are the reactor interfaces that are to be implemented +// by the user. They are passed in to the library as an argument to a call on a +// stub (either a codegen-ed call or a generic call). The streaming RPC is +// activated by calling StartCall, possibly after initiating StartRead, +// StartWrite, or AddHold operations on the streaming object. Note that none of +// the classes are pure; all reactions have a default empty reaction so that the +// user class only needs to override those classes that it cares about. +// The reactor must be passed to the stub invocation before any of the below +// operations can be called. + +/// \a ClientBidiReactor is the interface for a bidirectional streaming RPC. +template +class ClientBidiReactor { + public: + virtual ~ClientBidiReactor() {} + + /// Activate the RPC and initiate any reads or writes that have been Start'ed + /// before this call. All streaming RPCs issued by the client MUST have + /// StartCall invoked on them (even if they are canceled) as this call is the + /// activation of their lifecycle. + void StartCall() { stream_->StartCall(); } + + /// Initiate a read operation (or post it for later initiation if StartCall + /// has not yet been invoked). + /// + /// \param[out] resp Where to eventually store the read message. Valid when + /// the library calls OnReadDone + void StartRead(Response* resp) { stream_->Read(resp); } + + /// Initiate a write operation (or post it for later initiation if StartCall + /// has not yet been invoked). + /// + /// \param[in] req The message to be written. The library takes temporary + /// ownership until OnWriteDone, at which point the application + /// regains ownership of msg. + void StartWrite(const Request* req) { + StartWrite(req, ::grpc::WriteOptions()); + } + + /// Initiate/post a write operation with specified options. + /// + /// \param[in] req The message to be written. The library takes temporary + /// ownership until OnWriteDone, at which point the application + /// regains ownership of msg. + /// \param[in] options The WriteOptions to use for writing this message + void StartWrite(const Request* req, ::grpc::WriteOptions options) { + stream_->Write(req, std::move(options)); + } + + /// Initiate/post a write operation with specified options and an indication + /// that this is the last write (like StartWrite and StartWritesDone, merged). + /// Note that calling this means that no more calls to StartWrite, + /// StartWriteLast, or StartWritesDone are allowed. + /// + /// \param[in] req The message to be written. The library takes temporary + /// ownership until OnWriteDone, at which point the application + /// regains ownership of msg. + /// \param[in] options The WriteOptions to use for writing this message + void StartWriteLast(const Request* req, ::grpc::WriteOptions options) { + StartWrite(req, std::move(options.set_last_message())); + } + + /// Indicate that the RPC will have no more write operations. This can only be + /// issued once for a given RPC. This is not required or allowed if + /// StartWriteLast is used since that already has the same implication. + /// Note that calling this means that no more calls to StartWrite, + /// StartWriteLast, or StartWritesDone are allowed. + void StartWritesDone() { stream_->WritesDone(); } + + /// Holds are needed if (and only if) this stream has operations that take + /// place on it after StartCall but from outside one of the reactions + /// (OnReadDone, etc). This is _not_ a common use of the streaming API. + /// + /// Holds must be added before calling StartCall. If a stream still has a hold + /// in place, its resources will not be destroyed even if the status has + /// already come in from the wire and there are currently no active callbacks + /// outstanding. Similarly, the stream will not call OnDone if there are still + /// holds on it. + /// + /// For example, if a StartRead or StartWrite operation is going to be + /// initiated from elsewhere in the application, the application should call + /// AddHold or AddMultipleHolds before StartCall. If there is going to be, + /// for example, a read-flow and a write-flow taking place outside the + /// reactions, then call AddMultipleHolds(2) before StartCall. When the + /// application knows that it won't issue any more read operations (such as + /// when a read comes back as not ok), it should issue a RemoveHold(). It + /// should also call RemoveHold() again after it does StartWriteLast or + /// StartWritesDone that indicates that there will be no more write ops. + /// The number of RemoveHold calls must match the total number of AddHold + /// calls plus the number of holds added by AddMultipleHolds. + void AddHold() { AddMultipleHolds(1); } + void AddMultipleHolds(int holds) { stream_->AddHold(holds); } + void RemoveHold() { stream_->RemoveHold(); } + + /// Notifies the application that all operations associated with this RPC + /// have completed and provides the RPC status outcome. + /// + /// \param[in] s The status outcome of this RPC + virtual void OnDone(const ::grpc::Status& s) {} + + /// Notifies the application that a read of initial metadata from the + /// server is done. If the application chooses not to implement this method, + /// it can assume that the initial metadata has been read before the first + /// call of OnReadDone or OnDone. + /// + /// \param[in] ok Was the initial metadata read successfully? If false, no + /// further read-side operation will succeed. + virtual void OnReadInitialMetadataDone(bool ok) {} + + /// Notifies the application that a StartRead operation completed. + /// + /// \param[in] ok Was it successful? If false, no further read-side operation + /// will succeed. + virtual void OnReadDone(bool ok) {} + + /// Notifies the application that a StartWrite operation completed. + /// + /// \param[in] ok Was it successful? If false, no further write-side operation + /// will succeed. + virtual void OnWriteDone(bool ok) {} + + /// Notifies the application that a StartWritesDone operation completed. Note + /// that this is only used on explicit StartWritesDone operations and not for + /// those that are implicitly invoked as part of a StartWriteLast. + /// + /// \param[in] ok Was it successful? If false, the application will later see + /// the failure reflected as a bad status in OnDone. + virtual void OnWritesDoneDone(bool ok) {} + + private: + friend class ClientCallbackReaderWriter; + void BindStream(ClientCallbackReaderWriter* stream) { + stream_ = stream; + } + ClientCallbackReaderWriter* stream_; +}; + +/// \a ClientReadReactor is the interface for a server-streaming RPC. +/// All public methods behave as in ClientBidiReactor. +template +class ClientReadReactor { + public: + virtual ~ClientReadReactor() {} + + void StartCall() { reader_->StartCall(); } + void StartRead(Response* resp) { reader_->Read(resp); } + + void AddHold() { AddMultipleHolds(1); } + void AddMultipleHolds(int holds) { reader_->AddHold(holds); } + void RemoveHold() { reader_->RemoveHold(); } + + virtual void OnDone(const ::grpc::Status& s) {} + virtual void OnReadInitialMetadataDone(bool ok) {} + virtual void OnReadDone(bool ok) {} + + private: + friend class ClientCallbackReader; + void BindReader(ClientCallbackReader* reader) { reader_ = reader; } + ClientCallbackReader* reader_; +}; + +/// \a ClientWriteReactor is the interface for a client-streaming RPC. +/// All public methods behave as in ClientBidiReactor. +template +class ClientWriteReactor { + public: + virtual ~ClientWriteReactor() {} + + void StartCall() { writer_->StartCall(); } + void StartWrite(const Request* req) { + StartWrite(req, ::grpc::WriteOptions()); + } + void StartWrite(const Request* req, ::grpc::WriteOptions options) { + writer_->Write(req, std::move(options)); + } + void StartWriteLast(const Request* req, ::grpc::WriteOptions options) { + StartWrite(req, std::move(options.set_last_message())); + } + void StartWritesDone() { writer_->WritesDone(); } + + void AddHold() { AddMultipleHolds(1); } + void AddMultipleHolds(int holds) { writer_->AddHold(holds); } + void RemoveHold() { writer_->RemoveHold(); } + + virtual void OnDone(const ::grpc::Status& s) {} + virtual void OnReadInitialMetadataDone(bool ok) {} + virtual void OnWriteDone(bool ok) {} + virtual void OnWritesDoneDone(bool ok) {} + + private: + friend class ClientCallbackWriter; + void BindWriter(ClientCallbackWriter* writer) { writer_ = writer; } + ClientCallbackWriter* writer_; +}; + +/// \a ClientUnaryReactor is a reactor-style interface for a unary RPC. +/// This is _not_ a common way of invoking a unary RPC. In practice, this +/// option should be used only if the unary RPC wants to receive initial +/// metadata without waiting for the response to complete. Most deployments of +/// RPC systems do not use this option, but it is needed for generality. +/// All public methods behave as in ClientBidiReactor. +/// StartCall is included for consistency with the other reactor flavors: even +/// though there are no StartRead or StartWrite operations to queue before the +/// call (that is part of the unary call itself) and there is no reactor object +/// being created as a result of this call, we keep a consistent 2-phase +/// initiation API among all the reactor flavors. +class ClientUnaryReactor { + public: + virtual ~ClientUnaryReactor() {} + + void StartCall() { call_->StartCall(); } + virtual void OnDone(const ::grpc::Status& s) {} + virtual void OnReadInitialMetadataDone(bool ok) {} + + private: + friend class ClientCallbackUnary; + void BindCall(ClientCallbackUnary* call) { call_ = call; } + ClientCallbackUnary* call_; +}; + +// Define function out-of-line from class to avoid forward declaration issue +inline void ClientCallbackUnary::BindReactor(ClientUnaryReactor* reactor) { + reactor->BindCall(this); +} + +} // namespace experimental + +namespace internal { + +// Forward declare factory classes for friendship +template +class ClientCallbackReaderWriterFactory; +template +class ClientCallbackReaderFactory; +template +class ClientCallbackWriterFactory; + +template +class ClientCallbackReaderWriterImpl + : public experimental::ClientCallbackReaderWriter { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* ptr, std::size_t size) { + assert(size == sizeof(ClientCallbackReaderWriterImpl)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { assert(0); } + + void MaybeFinish() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + ::grpc::Status s = std::move(finish_status_); + auto* reactor = reactor_; + auto* call = call_.call(); + this->~ClientCallbackReaderWriterImpl(); + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + reactor->OnDone(s); + } + } + + void StartCall() override { + // This call initiates two batches, plus any backlog, each with a callback + // 1. Send initial metadata (unless corked) + recv initial metadata + // 2. Any read backlog + // 3. Any write backlog + // 4. Recv trailing metadata, on_completion callback + started_ = true; + + start_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadInitialMetadataDone(ok); + MaybeFinish(); + }, + &start_ops_); + if (!start_corked_) { + start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + } + start_ops_.RecvInitialMetadata(context_); + start_ops_.set_core_cq_tag(&start_tag_); + call_.PerformOps(&start_ops_); + + // Also set up the read and write tags so that they don't have to be set up + // each time + write_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnWriteDone(ok); + MaybeFinish(); + }, + &write_ops_); + write_ops_.set_core_cq_tag(&write_tag_); + + read_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadDone(ok); + MaybeFinish(); + }, + &read_ops_); + read_ops_.set_core_cq_tag(&read_tag_); + if (read_ops_at_start_) { + call_.PerformOps(&read_ops_); + } + + if (write_ops_at_start_) { + call_.PerformOps(&write_ops_); + } + + if (writes_done_ops_at_start_) { + call_.PerformOps(&writes_done_ops_); + } + + finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, + &finish_ops_); + finish_ops_.ClientRecvStatus(context_, &finish_status_); + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void Read(Response* msg) override { + read_ops_.RecvMessage(msg); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (started_) { + call_.PerformOps(&read_ops_); + } else { + read_ops_at_start_ = true; + } + } + + void Write(const Request* msg, ::grpc::WriteOptions options) override { + if (start_corked_) { + write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + start_corked_ = false; + } + + if (options.is_last_message()) { + options.set_buffer_hint(); + write_ops_.ClientSendClose(); + } + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(msg, options).ok()); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (started_) { + call_.PerformOps(&write_ops_); + } else { + write_ops_at_start_ = true; + } + } + void WritesDone() override { + if (start_corked_) { + writes_done_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + start_corked_ = false; + } + writes_done_ops_.ClientSendClose(); + writes_done_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnWritesDoneDone(ok); + MaybeFinish(); + }, + &writes_done_ops_); + writes_done_ops_.set_core_cq_tag(&writes_done_tag_); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (started_) { + call_.PerformOps(&writes_done_ops_); + } else { + writes_done_ops_at_start_ = true; + } + } + + void AddHold(int holds) override { + callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed); + } + void RemoveHold() override { MaybeFinish(); } + + private: + friend class ClientCallbackReaderWriterFactory; + + ClientCallbackReaderWriterImpl( + grpc::internal::Call call, ::grpc_impl::ClientContext* context, + experimental::ClientBidiReactor* reactor) + : context_(context), + call_(call), + reactor_(reactor), + start_corked_(context_->initial_metadata_corked_) { + this->BindReactor(reactor); + } + + ::grpc_impl::ClientContext* const context_; + grpc::internal::Call call_; + experimental::ClientBidiReactor* const reactor_; + + grpc::internal::CallOpSet + start_ops_; + grpc::internal::CallbackWithSuccessTag start_tag_; + bool start_corked_; + + grpc::internal::CallOpSet finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + ::grpc::Status finish_status_; + + grpc::internal::CallOpSet + write_ops_; + grpc::internal::CallbackWithSuccessTag write_tag_; + bool write_ops_at_start_{false}; + + grpc::internal::CallOpSet + writes_done_ops_; + grpc::internal::CallbackWithSuccessTag writes_done_tag_; + bool writes_done_ops_at_start_{false}; + + grpc::internal::CallOpSet> + read_ops_; + grpc::internal::CallbackWithSuccessTag read_tag_; + bool read_ops_at_start_{false}; + + // Minimum of 2 callbacks to pre-register for start and finish + std::atomic callbacks_outstanding_{2}; + bool started_{false}; +}; + +template +class ClientCallbackReaderWriterFactory { + public: + static void Create( + ::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + experimental::ClientBidiReactor* reactor) { + grpc::internal::Call call = + channel->CreateCall(method, context, channel->CallbackCQ()); + + ::grpc::g_core_codegen_interface->grpc_call_ref(call.call()); + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientCallbackReaderWriterImpl))) + ClientCallbackReaderWriterImpl(call, context, + reactor); + } +}; + +template +class ClientCallbackReaderImpl + : public experimental::ClientCallbackReader { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* ptr, std::size_t size) { + assert(size == sizeof(ClientCallbackReaderImpl)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { assert(0); } + + void MaybeFinish() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + ::grpc::Status s = std::move(finish_status_); + auto* reactor = reactor_; + auto* call = call_.call(); + this->~ClientCallbackReaderImpl(); + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + reactor->OnDone(s); + } + } + + void StartCall() override { + // This call initiates two batches, plus any backlog, each with a callback + // 1. Send initial metadata (unless corked) + recv initial metadata + // 2. Any backlog + // 3. Recv trailing metadata, on_completion callback + started_ = true; + + start_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadInitialMetadataDone(ok); + MaybeFinish(); + }, + &start_ops_); + start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + start_ops_.RecvInitialMetadata(context_); + start_ops_.set_core_cq_tag(&start_tag_); + call_.PerformOps(&start_ops_); + + // Also set up the read tag so it doesn't have to be set up each time + read_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadDone(ok); + MaybeFinish(); + }, + &read_ops_); + read_ops_.set_core_cq_tag(&read_tag_); + if (read_ops_at_start_) { + call_.PerformOps(&read_ops_); + } + + finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, + &finish_ops_); + finish_ops_.ClientRecvStatus(context_, &finish_status_); + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void Read(Response* msg) override { + read_ops_.RecvMessage(msg); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (started_) { + call_.PerformOps(&read_ops_); + } else { + read_ops_at_start_ = true; + } + } + + void AddHold(int holds) override { + callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed); + } + void RemoveHold() override { MaybeFinish(); } + + private: + friend class ClientCallbackReaderFactory; + + template + ClientCallbackReaderImpl(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, + Request* request, + experimental::ClientReadReactor* reactor) + : context_(context), call_(call), reactor_(reactor) { + this->BindReactor(reactor); + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(start_ops_.SendMessagePtr(request).ok()); + start_ops_.ClientSendClose(); + } + + ::grpc_impl::ClientContext* const context_; + grpc::internal::Call call_; + experimental::ClientReadReactor* const reactor_; + + grpc::internal::CallOpSet + start_ops_; + grpc::internal::CallbackWithSuccessTag start_tag_; + + grpc::internal::CallOpSet finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + ::grpc::Status finish_status_; + + grpc::internal::CallOpSet> + read_ops_; + grpc::internal::CallbackWithSuccessTag read_tag_; + bool read_ops_at_start_{false}; + + // Minimum of 2 callbacks to pre-register for start and finish + std::atomic callbacks_outstanding_{2}; + bool started_{false}; +}; + +template +class ClientCallbackReaderFactory { + public: + template + static void Create(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + const Request* request, + experimental::ClientReadReactor* reactor) { + grpc::internal::Call call = + channel->CreateCall(method, context, channel->CallbackCQ()); + + ::grpc::g_core_codegen_interface->grpc_call_ref(call.call()); + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientCallbackReaderImpl))) + ClientCallbackReaderImpl(call, context, request, reactor); + } +}; + +template +class ClientCallbackWriterImpl + : public experimental::ClientCallbackWriter { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* ptr, std::size_t size) { + assert(size == sizeof(ClientCallbackWriterImpl)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { assert(0); } + + void MaybeFinish() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + ::grpc::Status s = std::move(finish_status_); + auto* reactor = reactor_; + auto* call = call_.call(); + this->~ClientCallbackWriterImpl(); + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + reactor->OnDone(s); + } + } + + void StartCall() override { + // This call initiates two batches, plus any backlog, each with a callback + // 1. Send initial metadata (unless corked) + recv initial metadata + // 2. Any backlog + // 3. Recv trailing metadata, on_completion callback + started_ = true; + + start_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadInitialMetadataDone(ok); + MaybeFinish(); + }, + &start_ops_); + if (!start_corked_) { + start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + } + start_ops_.RecvInitialMetadata(context_); + start_ops_.set_core_cq_tag(&start_tag_); + call_.PerformOps(&start_ops_); + + // Also set up the read and write tags so that they don't have to be set up + // each time + write_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnWriteDone(ok); + MaybeFinish(); + }, + &write_ops_); + write_ops_.set_core_cq_tag(&write_tag_); + + if (write_ops_at_start_) { + call_.PerformOps(&write_ops_); + } + + if (writes_done_ops_at_start_) { + call_.PerformOps(&writes_done_ops_); + } + + finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, + &finish_ops_); + finish_ops_.ClientRecvStatus(context_, &finish_status_); + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void Write(const Request* msg, ::grpc::WriteOptions options) override { + if (start_corked_) { + write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + start_corked_ = false; + } + + if (options.is_last_message()) { + options.set_buffer_hint(); + write_ops_.ClientSendClose(); + } + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(msg, options).ok()); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (started_) { + call_.PerformOps(&write_ops_); + } else { + write_ops_at_start_ = true; + } + } + void WritesDone() override { + if (start_corked_) { + writes_done_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + start_corked_ = false; + } + writes_done_ops_.ClientSendClose(); + writes_done_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnWritesDoneDone(ok); + MaybeFinish(); + }, + &writes_done_ops_); + writes_done_ops_.set_core_cq_tag(&writes_done_tag_); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (started_) { + call_.PerformOps(&writes_done_ops_); + } else { + writes_done_ops_at_start_ = true; + } + } + + void AddHold(int holds) override { + callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed); + } + void RemoveHold() override { MaybeFinish(); } + + private: + friend class ClientCallbackWriterFactory; + + template + ClientCallbackWriterImpl(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, + Response* response, + experimental::ClientWriteReactor* reactor) + : context_(context), + call_(call), + reactor_(reactor), + start_corked_(context_->initial_metadata_corked_) { + this->BindReactor(reactor); + finish_ops_.RecvMessage(response); + finish_ops_.AllowNoMessage(); + } + + ::grpc_impl::ClientContext* const context_; + grpc::internal::Call call_; + experimental::ClientWriteReactor* const reactor_; + + grpc::internal::CallOpSet + start_ops_; + grpc::internal::CallbackWithSuccessTag start_tag_; + bool start_corked_; + + grpc::internal::CallOpSet + finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + ::grpc::Status finish_status_; + + grpc::internal::CallOpSet + write_ops_; + grpc::internal::CallbackWithSuccessTag write_tag_; + bool write_ops_at_start_{false}; + + grpc::internal::CallOpSet + writes_done_ops_; + grpc::internal::CallbackWithSuccessTag writes_done_tag_; + bool writes_done_ops_at_start_{false}; + + // Minimum of 2 callbacks to pre-register for start and finish + std::atomic callbacks_outstanding_{2}; + bool started_{false}; +}; + +template +class ClientCallbackWriterFactory { + public: + template + static void Create(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, Response* response, + experimental::ClientWriteReactor* reactor) { + grpc::internal::Call call = + channel->CreateCall(method, context, channel->CallbackCQ()); + + ::grpc::g_core_codegen_interface->grpc_call_ref(call.call()); + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientCallbackWriterImpl))) + ClientCallbackWriterImpl(call, context, response, reactor); + } +}; + +class ClientCallbackUnaryImpl final : public experimental::ClientCallbackUnary { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* ptr, std::size_t size) { + assert(size == sizeof(ClientCallbackUnaryImpl)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { assert(0); } + + void StartCall() override { + // This call initiates two batches, each with a callback + // 1. Send initial metadata + write + writes done + recv initial metadata + // 2. Read message, recv trailing metadata + started_ = true; + + start_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadInitialMetadataDone(ok); + MaybeFinish(); + }, + &start_ops_); + start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + start_ops_.RecvInitialMetadata(context_); + start_ops_.set_core_cq_tag(&start_tag_); + call_.PerformOps(&start_ops_); + + finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, + &finish_ops_); + finish_ops_.ClientRecvStatus(context_, &finish_status_); + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void MaybeFinish() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + ::grpc::Status s = std::move(finish_status_); + auto* reactor = reactor_; + auto* call = call_.call(); + this->~ClientCallbackUnaryImpl(); + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + reactor->OnDone(s); + } + } + + private: + friend class ClientCallbackUnaryFactory; + + template + ClientCallbackUnaryImpl(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, Request* request, + Response* response, + experimental::ClientUnaryReactor* reactor) + : context_(context), call_(call), reactor_(reactor) { + this->BindReactor(reactor); + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(start_ops_.SendMessagePtr(request).ok()); + start_ops_.ClientSendClose(); + finish_ops_.RecvMessage(response); + finish_ops_.AllowNoMessage(); + } + + ::grpc_impl::ClientContext* const context_; + grpc::internal::Call call_; + experimental::ClientUnaryReactor* const reactor_; + + grpc::internal::CallOpSet + start_ops_; + grpc::internal::CallbackWithSuccessTag start_tag_; + + grpc::internal::CallOpSet + finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + ::grpc::Status finish_status_; + + // This call will have 2 callbacks: start and finish + std::atomic callbacks_outstanding_{2}; + bool started_{false}; +}; + +class ClientCallbackUnaryFactory { + public: + template + static void Create(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + const Request* request, Response* response, + experimental::ClientUnaryReactor* reactor) { + grpc::internal::Call call = + channel->CreateCall(method, context, channel->CallbackCQ()); + + ::grpc::g_core_codegen_interface->grpc_call_ref(call.call()); + + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientCallbackUnaryImpl))) + ClientCallbackUnaryImpl(call, context, request, response, reactor); + } +}; + +} // namespace internal +} // namespace grpc_impl +#endif // GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_IMPL_H diff --git a/include/grpcpp/impl/codegen/client_context_impl.h b/include/grpcpp/impl/codegen/client_context_impl.h index 8491215cf0e..638ea641bed 100644 --- a/include/grpcpp/impl/codegen/client_context_impl.h +++ b/include/grpcpp/impl/codegen/client_context_impl.h @@ -63,10 +63,19 @@ class ChannelInterface; namespace internal { class RpcMethod; -class CallOpClientRecvStatus; -class CallOpRecvInitialMetadata; template class BlockingUnaryCallImpl; +class CallOpClientRecvStatus; +class CallOpRecvInitialMetadata; +} // namespace internal + +namespace testing { +class InteropClientContextInspector; +} // namespace testing +} // namespace grpc +namespace grpc_impl { + +namespace internal { template class CallbackUnaryCallImpl; template @@ -78,6 +87,10 @@ class ClientCallbackWriterImpl; class ClientCallbackUnaryImpl; } // namespace internal +class CallCredentials; +class Channel; +class CompletionQueue; +class ServerContext; template class ClientReader; template @@ -93,17 +106,6 @@ class ClientAsyncReaderWriter; template class ClientAsyncResponseReader; -namespace testing { -class InteropClientContextInspector; -} // namespace testing -} // namespace grpc -namespace grpc_impl { - -class CallCredentials; -class Channel; -class CompletionQueue; -class ServerContext; - /// Options for \a ClientContext::FromServerContext specifying which traits from /// the \a ServerContext to propagate (copy) from it into a new \a /// ClientContext. @@ -398,30 +400,30 @@ class ClientContext { friend class ::grpc::internal::CallOpRecvInitialMetadata; friend class ::grpc_impl::Channel; template - friend class ::grpc::ClientReader; + friend class ::grpc_impl::ClientReader; template - friend class ::grpc::ClientWriter; + friend class ::grpc_impl::ClientWriter; template - friend class ::grpc::ClientReaderWriter; + friend class ::grpc_impl::ClientReaderWriter; template - friend class ::grpc::ClientAsyncReader; + friend class ::grpc_impl::ClientAsyncReader; template - friend class ::grpc::ClientAsyncWriter; + friend class ::grpc_impl::ClientAsyncWriter; template - friend class ::grpc::ClientAsyncReaderWriter; + friend class ::grpc_impl::ClientAsyncReaderWriter; template - friend class ::grpc::ClientAsyncResponseReader; + friend class ::grpc_impl::ClientAsyncResponseReader; template friend class ::grpc::internal::BlockingUnaryCallImpl; template - friend class ::grpc::internal::CallbackUnaryCallImpl; + friend class ::grpc_impl::internal::CallbackUnaryCallImpl; template - friend class ::grpc::internal::ClientCallbackReaderWriterImpl; + friend class ::grpc_impl::internal::ClientCallbackReaderWriterImpl; template - friend class ::grpc::internal::ClientCallbackReaderImpl; + friend class ::grpc_impl::internal::ClientCallbackReaderImpl; template - friend class ::grpc::internal::ClientCallbackWriterImpl; - friend class ::grpc::internal::ClientCallbackUnaryImpl; + friend class ::grpc_impl::internal::ClientCallbackWriterImpl; + friend class ::grpc_impl::internal::ClientCallbackUnaryImpl; // Used by friend class CallOpClientRecvStatus void set_debug_error_string(const grpc::string& debug_error_string) { diff --git a/include/grpcpp/impl/codegen/client_unary_call.h b/include/grpcpp/impl/codegen/client_unary_call.h index 599dd1ecac9..7f80e571c07 100644 --- a/include/grpcpp/impl/codegen/client_unary_call.h +++ b/include/grpcpp/impl/codegen/client_unary_call.h @@ -49,10 +49,10 @@ class BlockingUnaryCallImpl { BlockingUnaryCallImpl(ChannelInterface* channel, const RpcMethod& method, grpc_impl::ClientContext* context, const InputMessage& request, OutputMessage* result) { - CompletionQueue cq(grpc_completion_queue_attributes{ + ::grpc_impl::CompletionQueue cq(grpc_completion_queue_attributes{ GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, nullptr}); // Pluckable completion queue - Call call(channel->CreateCall(method, context, &cq)); + ::grpc::internal::Call call(channel->CreateCall(method, context, &cq)); CallOpSet, CallOpClientSendClose, CallOpClientRecvStatus> diff --git a/include/grpcpp/impl/codegen/completion_queue_impl.h b/include/grpcpp/impl/codegen/completion_queue_impl.h index 0a6b0b0977b..7716a57e84a 100644 --- a/include/grpcpp/impl/codegen/completion_queue_impl.h +++ b/include/grpcpp/impl/codegen/completion_queue_impl.h @@ -47,9 +47,6 @@ class Channel; class Server; class ServerBuilder; class ServerContext; -} // namespace grpc_impl -namespace grpc { - template class ClientReader; template @@ -64,6 +61,8 @@ namespace internal { template class ServerReaderWriterBody; } // namespace internal +} // namespace grpc_impl +namespace grpc { class ChannelInterface; class ServerInterface; @@ -255,17 +254,17 @@ class CompletionQueue : private ::grpc::GrpcLibraryCodegen { // Friend synchronous wrappers so that they can access Pluck(), which is // a semi-private API geared towards the synchronous implementation. template - friend class ::grpc::ClientReader; + friend class ::grpc_impl::ClientReader; template - friend class ::grpc::ClientWriter; + friend class ::grpc_impl::ClientWriter; template - friend class ::grpc::ClientReaderWriter; + friend class ::grpc_impl::ClientReaderWriter; template - friend class ::grpc::ServerReader; + friend class ::grpc_impl::ServerReader; template - friend class ::grpc::ServerWriter; + friend class ::grpc_impl::ServerWriter; template - friend class ::grpc::internal::ServerReaderWriterBody; + friend class ::grpc_impl::internal::ServerReaderWriterBody; template friend class ::grpc::internal::RpcMethodHandler; template diff --git a/include/grpcpp/impl/codegen/server_callback.h b/include/grpcpp/impl/codegen/server_callback.h index 36ae19c5bec..cb771a662b9 100644 --- a/include/grpcpp/impl/codegen/server_callback.h +++ b/include/grpcpp/impl/codegen/server_callback.h @@ -19,1141 +19,26 @@ #ifndef GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_H #define GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_H -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include namespace grpc { - -// Declare base class of all reactors as internal -namespace internal { - -// Forward declarations -template -class CallbackClientStreamingHandler; -template -class CallbackServerStreamingHandler; -template -class CallbackBidiHandler; - -class ServerReactor { - public: - virtual ~ServerReactor() = default; - virtual void OnDone() = 0; - virtual void OnCancel() = 0; - - private: - friend class ::grpc_impl::ServerContext; - template - friend class CallbackClientStreamingHandler; - template - friend class CallbackServerStreamingHandler; - template - friend class CallbackBidiHandler; - - // The ServerReactor is responsible for tracking when it is safe to call - // OnCancel. This function should not be called until after OnStarted is done - // and the RPC has completed with a cancellation. This is tracked by counting - // how many of these conditions have been met and calling OnCancel when none - // remain unmet. - - void MaybeCallOnCancel() { - if (GPR_UNLIKELY(on_cancel_conditions_remaining_.fetch_sub( - 1, std::memory_order_acq_rel) == 1)) { - OnCancel(); - } - } - - std::atomic on_cancel_conditions_remaining_{2}; -}; - -template -class DefaultMessageHolder - : public experimental::MessageHolder { - public: - DefaultMessageHolder() { - this->set_request(&request_obj_); - this->set_response(&response_obj_); - } - void Release() override { - // the object is allocated in the call arena. - this->~DefaultMessageHolder(); - } - - private: - Request request_obj_; - Response response_obj_; -}; - -} // namespace internal - namespace experimental { - -// Forward declarations template -class ServerReadReactor; -template -class ServerWriteReactor; -template -class ServerBidiReactor; - -// For unary RPCs, the exposed controller class is only an interface -// and the actual implementation is an internal class. -class ServerCallbackRpcController { - public: - virtual ~ServerCallbackRpcController() = default; - - // The method handler must call this function when it is done so that - // the library knows to free its resources - virtual void Finish(Status s) = 0; - - // Allow the method handler to push out the initial metadata before - // the response and status are ready - virtual void SendInitialMetadata(std::function) = 0; - - /// SetCancelCallback passes in a callback to be called when the RPC is - /// canceled for whatever reason (streaming calls have OnCancel instead). This - /// is an advanced and uncommon use with several important restrictions. This - /// function may not be called more than once on the same RPC. - /// - /// If code calls SetCancelCallback on an RPC, it must also call - /// ClearCancelCallback before calling Finish on the RPC controller. That - /// method makes sure that no cancellation callback is executed for this RPC - /// beyond the point of its return. ClearCancelCallback may be called even if - /// SetCancelCallback was not called for this RPC, and it may be called - /// multiple times. It _must_ be called if SetCancelCallback was called for - /// this RPC. - /// - /// The callback should generally be lightweight and nonblocking and primarily - /// concerned with clearing application state related to the RPC or causing - /// operations (such as cancellations) to happen on dependent RPCs. - /// - /// If the RPC is already canceled at the time that SetCancelCallback is - /// called, the callback is invoked immediately. - /// - /// The cancellation callback may be executed concurrently with the method - /// handler that invokes it but will certainly not issue or execute after the - /// return of ClearCancelCallback. If ClearCancelCallback is invoked while the - /// callback is already executing, the callback will complete its execution - /// before ClearCancelCallback takes effect. - /// - /// To preserve the orderings described above, the callback may be called - /// under a lock that is also used for ClearCancelCallback and - /// ServerContext::IsCancelled, so the callback CANNOT call either of those - /// operations on this RPC or any other function that causes those operations - /// to be called before the callback completes. - virtual void SetCancelCallback(std::function callback) = 0; - virtual void ClearCancelCallback() = 0; - - // NOTE: This is an API for advanced users who need custom allocators. - // Get and maybe mutate the allocator state associated with the current RPC. - virtual RpcAllocatorState* GetRpcAllocatorState() = 0; -}; - -// NOTE: The actual streaming object classes are provided -// as API only to support mocking. There are no implementations of -// these class interfaces in the API. -template -class ServerCallbackReader { - public: - virtual ~ServerCallbackReader() {} - virtual void Finish(Status s) = 0; - virtual void SendInitialMetadata() = 0; - virtual void Read(Request* msg) = 0; - - protected: - template - void BindReactor(ServerReadReactor* reactor) { - reactor->InternalBindReader(this); - } -}; - -template -class ServerCallbackWriter { - public: - virtual ~ServerCallbackWriter() {} - - virtual void Finish(Status s) = 0; - virtual void SendInitialMetadata() = 0; - virtual void Write(const Response* msg, WriteOptions options) = 0; - virtual void WriteAndFinish(const Response* msg, WriteOptions options, - Status s) { - // Default implementation that can/should be overridden - Write(msg, std::move(options)); - Finish(std::move(s)); - } - - protected: - template - void BindReactor(ServerWriteReactor* reactor) { - reactor->InternalBindWriter(this); - } -}; +using ServerReadReactor = + ::grpc_impl::experimental::ServerReadReactor; template -class ServerCallbackReaderWriter { - public: - virtual ~ServerCallbackReaderWriter() {} +using ServerWriteReactor = + ::grpc_impl::experimental::ServerWriteReactor; - virtual void Finish(Status s) = 0; - virtual void SendInitialMetadata() = 0; - virtual void Read(Request* msg) = 0; - virtual void Write(const Response* msg, WriteOptions options) = 0; - virtual void WriteAndFinish(const Response* msg, WriteOptions options, - Status s) { - // Default implementation that can/should be overridden - Write(msg, std::move(options)); - Finish(std::move(s)); - } - - protected: - void BindReactor(ServerBidiReactor* reactor) { - reactor->InternalBindStream(this); - } -}; - -// The following classes are the reactor interfaces that are to be implemented -// by the user, returned as the result of the method handler for a callback -// method, and activated by the call to OnStarted. The library guarantees that -// OnStarted will be called for any reactor that has been created using a -// method handler registered on a service. No operation initiation method may be -// called until after the call to OnStarted. -// Note that none of the classes are pure; all reactions have a default empty -// reaction so that the user class only needs to override those classes that it -// cares about. - -/// \a ServerBidiReactor is the interface for a bidirectional streaming RPC. template -class ServerBidiReactor : public internal::ServerReactor { - public: - ~ServerBidiReactor() = default; +using ServerBidiReactor = + ::grpc_impl::experimental::ServerBidiReactor; - /// Do NOT call any operation initiation method (names that start with Start) - /// until after the library has called OnStarted on this object. - - /// Send any initial metadata stored in the RPC context. If not invoked, - /// any initial metadata will be passed along with the first Write or the - /// Finish (if there are no writes). - void StartSendInitialMetadata() { stream_->SendInitialMetadata(); } - - /// Initiate a read operation. - /// - /// \param[out] req Where to eventually store the read message. Valid when - /// the library calls OnReadDone - void StartRead(Request* req) { stream_->Read(req); } - - /// Initiate a write operation. - /// - /// \param[in] resp The message to be written. The library takes temporary - /// ownership until OnWriteDone, at which point the - /// application regains ownership of resp. - void StartWrite(const Response* resp) { StartWrite(resp, WriteOptions()); } - - /// Initiate a write operation with specified options. - /// - /// \param[in] resp The message to be written. The library takes temporary - /// ownership until OnWriteDone, at which point the - /// application regains ownership of resp. - /// \param[in] options The WriteOptions to use for writing this message - void StartWrite(const Response* resp, WriteOptions options) { - stream_->Write(resp, std::move(options)); - } - - /// Initiate a write operation with specified options and final RPC Status, - /// which also causes any trailing metadata for this RPC to be sent out. - /// StartWriteAndFinish is like merging StartWriteLast and Finish into a - /// single step. A key difference, though, is that this operation doesn't have - /// an OnWriteDone reaction - it is considered complete only when OnDone is - /// available. An RPC can either have StartWriteAndFinish or Finish, but not - /// both. - /// - /// \param[in] resp The message to be written. The library takes temporary - /// ownership until Onone, at which point the application - /// regains ownership of resp. - /// \param[in] options The WriteOptions to use for writing this message - /// \param[in] s The status outcome of this RPC - void StartWriteAndFinish(const Response* resp, WriteOptions options, - Status s) { - stream_->WriteAndFinish(resp, std::move(options), std::move(s)); - } - - /// Inform system of a planned write operation with specified options, but - /// allow the library to schedule the actual write coalesced with the writing - /// of trailing metadata (which takes place on a Finish call). - /// - /// \param[in] resp The message to be written. The library takes temporary - /// ownership until OnWriteDone, at which point the - /// application regains ownership of resp. - /// \param[in] options The WriteOptions to use for writing this message - void StartWriteLast(const Response* resp, WriteOptions options) { - StartWrite(resp, std::move(options.set_last_message())); - } - - /// Indicate that the stream is to be finished and the trailing metadata and - /// RPC status are to be sent. Every RPC MUST be finished using either Finish - /// or StartWriteAndFinish (but not both), even if the RPC is already - /// cancelled. - /// - /// \param[in] s The status outcome of this RPC - void Finish(Status s) { stream_->Finish(std::move(s)); } - - /// Notify the application that a streaming RPC has started and that it is now - /// ok to call any operation initiation method. An RPC is considered started - /// after the server has received all initial metadata from the client, which - /// is a result of the client calling StartCall(). - /// - /// \param[in] context The context object now associated with this RPC - virtual void OnStarted(::grpc_impl::ServerContext* context) {} - - /// Notifies the application that an explicit StartSendInitialMetadata - /// operation completed. Not used when the sending of initial metadata - /// piggybacks onto the first write. - /// - /// \param[in] ok Was it successful? If false, no further write-side operation - /// will succeed. - virtual void OnSendInitialMetadataDone(bool ok) {} - - /// Notifies the application that a StartRead operation completed. - /// - /// \param[in] ok Was it successful? If false, no further read-side operation - /// will succeed. - virtual void OnReadDone(bool ok) {} - - /// Notifies the application that a StartWrite (or StartWriteLast) operation - /// completed. - /// - /// \param[in] ok Was it successful? If false, no further write-side operation - /// will succeed. - virtual void OnWriteDone(bool ok) {} - - /// Notifies the application that all operations associated with this RPC - /// have completed. This is an override (from the internal base class) but not - /// final, so derived classes should override it if they want to take action. - void OnDone() override {} - - /// Notifies the application that this RPC has been cancelled. This is an - /// override (from the internal base class) but not final, so derived classes - /// should override it if they want to take action. - void OnCancel() override {} - - private: - friend class ServerCallbackReaderWriter; - // May be overridden by internal implementation details. This is not a public - // customization point. - virtual void InternalBindStream( - ServerCallbackReaderWriter* stream) { - stream_ = stream; - } - - ServerCallbackReaderWriter* stream_; -}; - -/// \a ServerReadReactor is the interface for a client-streaming RPC. -template -class ServerReadReactor : public internal::ServerReactor { - public: - ~ServerReadReactor() = default; - - /// The following operation initiations are exactly like ServerBidiReactor. - void StartSendInitialMetadata() { reader_->SendInitialMetadata(); } - void StartRead(Request* req) { reader_->Read(req); } - void Finish(Status s) { reader_->Finish(std::move(s)); } - - /// Similar to ServerBidiReactor::OnStarted, except that this also provides - /// the response object that the stream fills in before calling Finish. - /// (It must be filled in if status is OK, but it may be filled in otherwise.) - /// - /// \param[in] context The context object now associated with this RPC - /// \param[in] resp The response object to be used by this RPC - virtual void OnStarted(::grpc_impl::ServerContext* context, Response* resp) {} - - /// The following notifications are exactly like ServerBidiReactor. - virtual void OnSendInitialMetadataDone(bool ok) {} - virtual void OnReadDone(bool ok) {} - void OnDone() override {} - void OnCancel() override {} - - private: - friend class ServerCallbackReader; - // May be overridden by internal implementation details. This is not a public - // customization point. - virtual void InternalBindReader(ServerCallbackReader* reader) { - reader_ = reader; - } - - ServerCallbackReader* reader_; -}; - -/// \a ServerWriteReactor is the interface for a server-streaming RPC. -template -class ServerWriteReactor : public internal::ServerReactor { - public: - ~ServerWriteReactor() = default; - - /// The following operation initiations are exactly like ServerBidiReactor. - void StartSendInitialMetadata() { writer_->SendInitialMetadata(); } - void StartWrite(const Response* resp) { StartWrite(resp, WriteOptions()); } - void StartWrite(const Response* resp, WriteOptions options) { - writer_->Write(resp, std::move(options)); - } - void StartWriteAndFinish(const Response* resp, WriteOptions options, - Status s) { - writer_->WriteAndFinish(resp, std::move(options), std::move(s)); - } - void StartWriteLast(const Response* resp, WriteOptions options) { - StartWrite(resp, std::move(options.set_last_message())); - } - void Finish(Status s) { writer_->Finish(std::move(s)); } - - /// Similar to ServerBidiReactor::OnStarted, except that this also provides - /// the request object sent by the client. - /// - /// \param[in] context The context object now associated with this RPC - /// \param[in] req The request object sent by the client - virtual void OnStarted(::grpc_impl::ServerContext* context, - const Request* req) {} - - /// The following notifications are exactly like ServerBidiReactor. - virtual void OnSendInitialMetadataDone(bool ok) {} - virtual void OnWriteDone(bool ok) {} - void OnDone() override {} - void OnCancel() override {} - - private: - friend class ServerCallbackWriter; - // May be overridden by internal implementation details. This is not a public - // customization point. - virtual void InternalBindWriter(ServerCallbackWriter* writer) { - writer_ = writer; - } - - ServerCallbackWriter* writer_; -}; +typedef ::grpc_impl::experimental::ServerCallbackRpcController + ServerCallbackRpcController; } // namespace experimental - -namespace internal { - -template -class UnimplementedReadReactor - : public experimental::ServerReadReactor { - public: - void OnDone() override { delete this; } - void OnStarted(::grpc_impl::ServerContext*, Response*) override { - this->Finish(Status(StatusCode::UNIMPLEMENTED, "")); - } -}; - -template -class UnimplementedWriteReactor - : public experimental::ServerWriteReactor { - public: - void OnDone() override { delete this; } - void OnStarted(::grpc_impl::ServerContext*, const Request*) override { - this->Finish(Status(StatusCode::UNIMPLEMENTED, "")); - } -}; - -template -class UnimplementedBidiReactor - : public experimental::ServerBidiReactor { - public: - void OnDone() override { delete this; } - void OnStarted(::grpc_impl::ServerContext*) override { - this->Finish(Status(StatusCode::UNIMPLEMENTED, "")); - } -}; - -template -class CallbackUnaryHandler : public MethodHandler { - public: - CallbackUnaryHandler( - std::function - func) - : func_(func) {} - - void SetMessageAllocator( - experimental::MessageAllocator* allocator) { - allocator_ = allocator; - } - - void RunHandler(const HandlerParameter& param) final { - // Arena allocate a controller structure (that includes request/response) - g_core_codegen_interface->grpc_call_ref(param.call->call()); - auto* allocator_state = - static_cast*>( - param.internal_data); - auto* controller = new (g_core_codegen_interface->grpc_call_arena_alloc( - param.call->call(), sizeof(ServerCallbackRpcControllerImpl))) - ServerCallbackRpcControllerImpl(param.server_context, param.call, - allocator_state, - std::move(param.call_requester)); - Status status = param.status; - if (status.ok()) { - // Call the actual function handler and expect the user to call finish - CatchingCallback(func_, param.server_context, controller->request(), - controller->response(), controller); - } else { - // if deserialization failed, we need to fail the call - controller->Finish(status); - } - } - - void* Deserialize(grpc_call* call, grpc_byte_buffer* req, Status* status, - void** handler_data) final { - ByteBuffer buf; - buf.set_buffer(req); - RequestType* request = nullptr; - experimental::MessageHolder* allocator_state = - nullptr; - if (allocator_ != nullptr) { - allocator_state = allocator_->AllocateMessages(); - } else { - allocator_state = new (g_core_codegen_interface->grpc_call_arena_alloc( - call, sizeof(DefaultMessageHolder))) - DefaultMessageHolder(); - } - *handler_data = allocator_state; - request = allocator_state->request(); - *status = SerializationTraits::Deserialize(&buf, request); - buf.Release(); - if (status->ok()) { - return request; - } - // Clean up on deserialization failure. - allocator_state->Release(); - return nullptr; - } - - private: - std::function - func_; - experimental::MessageAllocator* allocator_ = - nullptr; - - // The implementation class of ServerCallbackRpcController is a private member - // of CallbackUnaryHandler since it is never exposed anywhere, and this allows - // it to take advantage of CallbackUnaryHandler's friendships. - class ServerCallbackRpcControllerImpl - : public experimental::ServerCallbackRpcController { - public: - void Finish(Status s) override { - finish_tag_.Set(call_.call(), [this](bool) { MaybeDone(); }, - &finish_ops_); - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - // The response is dropped if the status is not OK. - if (s.ok()) { - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, - finish_ops_.SendMessagePtr(response())); - } else { - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); - } - finish_ops_.set_core_cq_tag(&finish_tag_); - call_.PerformOps(&finish_ops_); - } - - void SendInitialMetadata(std::function f) override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - // TODO(vjpai): Consider taking f as a move-capture if we adopt C++14 - // and if performance of this operation matters - meta_tag_.Set(call_.call(), - [this, f](bool ok) { - f(ok); - MaybeDone(); - }, - &meta_ops_); - meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - meta_ops_.set_core_cq_tag(&meta_tag_); - call_.PerformOps(&meta_ops_); - } - - // Neither SetCancelCallback nor ClearCancelCallback should affect the - // callbacks_outstanding_ count since they are paired and both must precede - // the invocation of Finish (if they are used at all) - void SetCancelCallback(std::function callback) override { - ctx_->SetCancelCallback(std::move(callback)); - } - - void ClearCancelCallback() override { ctx_->ClearCancelCallback(); } - - experimental::RpcAllocatorState* GetRpcAllocatorState() override { - return allocator_state_; - } - - private: - friend class CallbackUnaryHandler; - - ServerCallbackRpcControllerImpl( - ::grpc_impl::ServerContext* ctx, Call* call, - experimental::MessageHolder* allocator_state, - std::function call_requester) - : ctx_(ctx), - call_(*call), - allocator_state_(allocator_state), - call_requester_(std::move(call_requester)) { - ctx_->BeginCompletionOp(call, [this](bool) { MaybeDone(); }, nullptr); - } - - const RequestType* request() { return allocator_state_->request(); } - ResponseType* response() { return allocator_state_->response(); } - - void MaybeDone() { - if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( - 1, std::memory_order_acq_rel) == 1)) { - grpc_call* call = call_.call(); - auto call_requester = std::move(call_requester_); - allocator_state_->Release(); - this->~ServerCallbackRpcControllerImpl(); // explicitly call destructor - g_core_codegen_interface->grpc_call_unref(call); - call_requester(); - } - } - - CallOpSet meta_ops_; - CallbackWithSuccessTag meta_tag_; - CallOpSet - finish_ops_; - CallbackWithSuccessTag finish_tag_; - - ::grpc_impl::ServerContext* ctx_; - Call call_; - experimental::MessageHolder* const - allocator_state_; - std::function call_requester_; - std::atomic callbacks_outstanding_{ - 2}; // reserve for Finish and CompletionOp - }; -}; - -template -class CallbackClientStreamingHandler : public MethodHandler { - public: - CallbackClientStreamingHandler( - std::function< - experimental::ServerReadReactor*()> - func) - : func_(std::move(func)) {} - void RunHandler(const HandlerParameter& param) final { - // Arena allocate a reader structure (that includes response) - g_core_codegen_interface->grpc_call_ref(param.call->call()); - - experimental::ServerReadReactor* reactor = - param.status.ok() - ? CatchingReactorCreator< - experimental::ServerReadReactor>( - func_) - : nullptr; - - if (reactor == nullptr) { - // if deserialization or reactor creator failed, we need to fail the call - reactor = new UnimplementedReadReactor; - } - - auto* reader = new (g_core_codegen_interface->grpc_call_arena_alloc( - param.call->call(), sizeof(ServerCallbackReaderImpl))) - ServerCallbackReaderImpl(param.server_context, param.call, - std::move(param.call_requester), reactor); - - reader->BindReactor(reactor); - reactor->OnStarted(param.server_context, reader->response()); - // The earliest that OnCancel can be called is after OnStarted is done. - reactor->MaybeCallOnCancel(); - reader->MaybeDone(); - } - - private: - std::function*()> - func_; - - class ServerCallbackReaderImpl - : public experimental::ServerCallbackReader { - public: - void Finish(Status s) override { - finish_tag_.Set(call_.call(), [this](bool) { MaybeDone(); }, - &finish_ops_); - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - // The response is dropped if the status is not OK. - if (s.ok()) { - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, - finish_ops_.SendMessagePtr(&resp_)); - } else { - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); - } - finish_ops_.set_core_cq_tag(&finish_tag_); - call_.PerformOps(&finish_ops_); - } - - void SendInitialMetadata() override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - meta_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnSendInitialMetadataDone(ok); - MaybeDone(); - }, - &meta_ops_); - meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - meta_ops_.set_core_cq_tag(&meta_tag_); - call_.PerformOps(&meta_ops_); - } - - void Read(RequestType* req) override { - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - read_ops_.RecvMessage(req); - call_.PerformOps(&read_ops_); - } - - private: - friend class CallbackClientStreamingHandler; - - ServerCallbackReaderImpl( - ::grpc_impl::ServerContext* ctx, Call* call, - std::function call_requester, - experimental::ServerReadReactor* reactor) - : ctx_(ctx), - call_(*call), - call_requester_(std::move(call_requester)), - reactor_(reactor) { - ctx_->BeginCompletionOp(call, [this](bool) { MaybeDone(); }, reactor); - read_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadDone(ok); - MaybeDone(); - }, - &read_ops_); - read_ops_.set_core_cq_tag(&read_tag_); - } - - ~ServerCallbackReaderImpl() {} - - ResponseType* response() { return &resp_; } - - void MaybeDone() { - if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( - 1, std::memory_order_acq_rel) == 1)) { - reactor_->OnDone(); - grpc_call* call = call_.call(); - auto call_requester = std::move(call_requester_); - this->~ServerCallbackReaderImpl(); // explicitly call destructor - g_core_codegen_interface->grpc_call_unref(call); - call_requester(); - } - } - - CallOpSet meta_ops_; - CallbackWithSuccessTag meta_tag_; - CallOpSet - finish_ops_; - CallbackWithSuccessTag finish_tag_; - CallOpSet> read_ops_; - CallbackWithSuccessTag read_tag_; - - ::grpc_impl::ServerContext* ctx_; - Call call_; - ResponseType resp_; - std::function call_requester_; - experimental::ServerReadReactor* reactor_; - std::atomic callbacks_outstanding_{ - 3}; // reserve for OnStarted, Finish, and CompletionOp - }; -}; - -template -class CallbackServerStreamingHandler : public MethodHandler { - public: - CallbackServerStreamingHandler( - std::function< - experimental::ServerWriteReactor*()> - func) - : func_(std::move(func)) {} - void RunHandler(const HandlerParameter& param) final { - // Arena allocate a writer structure - g_core_codegen_interface->grpc_call_ref(param.call->call()); - - experimental::ServerWriteReactor* reactor = - param.status.ok() - ? CatchingReactorCreator< - experimental::ServerWriteReactor>( - func_) - : nullptr; - - if (reactor == nullptr) { - // if deserialization or reactor creator failed, we need to fail the call - reactor = new UnimplementedWriteReactor; - } - - auto* writer = new (g_core_codegen_interface->grpc_call_arena_alloc( - param.call->call(), sizeof(ServerCallbackWriterImpl))) - ServerCallbackWriterImpl(param.server_context, param.call, - static_cast(param.request), - std::move(param.call_requester), reactor); - writer->BindReactor(reactor); - reactor->OnStarted(param.server_context, writer->request()); - // The earliest that OnCancel can be called is after OnStarted is done. - reactor->MaybeCallOnCancel(); - writer->MaybeDone(); - } - - void* Deserialize(grpc_call* call, grpc_byte_buffer* req, Status* status, - void** handler_data) final { - ByteBuffer buf; - buf.set_buffer(req); - auto* request = new (g_core_codegen_interface->grpc_call_arena_alloc( - call, sizeof(RequestType))) RequestType(); - *status = SerializationTraits::Deserialize(&buf, request); - buf.Release(); - if (status->ok()) { - return request; - } - request->~RequestType(); - return nullptr; - } - - private: - std::function*()> - func_; - - class ServerCallbackWriterImpl - : public experimental::ServerCallbackWriter { - public: - void Finish(Status s) override { - finish_tag_.Set(call_.call(), [this](bool) { MaybeDone(); }, - &finish_ops_); - finish_ops_.set_core_cq_tag(&finish_tag_); - - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); - call_.PerformOps(&finish_ops_); - } - - void SendInitialMetadata() override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - meta_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnSendInitialMetadataDone(ok); - MaybeDone(); - }, - &meta_ops_); - meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - meta_ops_.set_core_cq_tag(&meta_tag_); - call_.PerformOps(&meta_ops_); - } - - void Write(const ResponseType* resp, WriteOptions options) override { - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - if (options.is_last_message()) { - options.set_buffer_hint(); - } - if (!ctx_->sent_initial_metadata_) { - write_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - write_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - // TODO(vjpai): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(resp, options).ok()); - call_.PerformOps(&write_ops_); - } - - void WriteAndFinish(const ResponseType* resp, WriteOptions options, - Status s) override { - // This combines the write into the finish callback - // Don't send any message if the status is bad - if (s.ok()) { - // TODO(vjpai): don't assert - GPR_CODEGEN_ASSERT(finish_ops_.SendMessagePtr(resp, options).ok()); - } - Finish(std::move(s)); - } - - private: - friend class CallbackServerStreamingHandler; - - ServerCallbackWriterImpl( - ::grpc_impl::ServerContext* ctx, Call* call, const RequestType* req, - std::function call_requester, - experimental::ServerWriteReactor* reactor) - : ctx_(ctx), - call_(*call), - req_(req), - call_requester_(std::move(call_requester)), - reactor_(reactor) { - ctx_->BeginCompletionOp(call, [this](bool) { MaybeDone(); }, reactor); - write_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnWriteDone(ok); - MaybeDone(); - }, - &write_ops_); - write_ops_.set_core_cq_tag(&write_tag_); - } - ~ServerCallbackWriterImpl() { req_->~RequestType(); } - - const RequestType* request() { return req_; } - - void MaybeDone() { - if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( - 1, std::memory_order_acq_rel) == 1)) { - reactor_->OnDone(); - grpc_call* call = call_.call(); - auto call_requester = std::move(call_requester_); - this->~ServerCallbackWriterImpl(); // explicitly call destructor - g_core_codegen_interface->grpc_call_unref(call); - call_requester(); - } - } - - CallOpSet meta_ops_; - CallbackWithSuccessTag meta_tag_; - CallOpSet - finish_ops_; - CallbackWithSuccessTag finish_tag_; - CallOpSet write_ops_; - CallbackWithSuccessTag write_tag_; - - ::grpc_impl::ServerContext* ctx_; - Call call_; - const RequestType* req_; - std::function call_requester_; - experimental::ServerWriteReactor* reactor_; - std::atomic callbacks_outstanding_{ - 3}; // reserve for OnStarted, Finish, and CompletionOp - }; -}; - -template -class CallbackBidiHandler : public MethodHandler { - public: - CallbackBidiHandler( - std::function< - experimental::ServerBidiReactor*()> - func) - : func_(std::move(func)) {} - void RunHandler(const HandlerParameter& param) final { - g_core_codegen_interface->grpc_call_ref(param.call->call()); - - experimental::ServerBidiReactor* reactor = - param.status.ok() - ? CatchingReactorCreator< - experimental::ServerBidiReactor>( - func_) - : nullptr; - - if (reactor == nullptr) { - // if deserialization or reactor creator failed, we need to fail the call - reactor = new UnimplementedBidiReactor; - } - - auto* stream = new (g_core_codegen_interface->grpc_call_arena_alloc( - param.call->call(), sizeof(ServerCallbackReaderWriterImpl))) - ServerCallbackReaderWriterImpl(param.server_context, param.call, - std::move(param.call_requester), - reactor); - - stream->BindReactor(reactor); - reactor->OnStarted(param.server_context); - // The earliest that OnCancel can be called is after OnStarted is done. - reactor->MaybeCallOnCancel(); - stream->MaybeDone(); - } - - private: - std::function*()> - func_; - - class ServerCallbackReaderWriterImpl - : public experimental::ServerCallbackReaderWriter { - public: - void Finish(Status s) override { - finish_tag_.Set(call_.call(), [this](bool) { MaybeDone(); }, - &finish_ops_); - finish_ops_.set_core_cq_tag(&finish_tag_); - - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); - call_.PerformOps(&finish_ops_); - } - - void SendInitialMetadata() override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - meta_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnSendInitialMetadataDone(ok); - MaybeDone(); - }, - &meta_ops_); - meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - meta_ops_.set_core_cq_tag(&meta_tag_); - call_.PerformOps(&meta_ops_); - } - - void Write(const ResponseType* resp, WriteOptions options) override { - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - if (options.is_last_message()) { - options.set_buffer_hint(); - } - if (!ctx_->sent_initial_metadata_) { - write_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - write_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - // TODO(vjpai): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(resp, options).ok()); - call_.PerformOps(&write_ops_); - } - - void WriteAndFinish(const ResponseType* resp, WriteOptions options, - Status s) override { - // Don't send any message if the status is bad - if (s.ok()) { - // TODO(vjpai): don't assert - GPR_CODEGEN_ASSERT(finish_ops_.SendMessagePtr(resp, options).ok()); - } - Finish(std::move(s)); - } - - void Read(RequestType* req) override { - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - read_ops_.RecvMessage(req); - call_.PerformOps(&read_ops_); - } - - private: - friend class CallbackBidiHandler; - - ServerCallbackReaderWriterImpl( - ::grpc_impl::ServerContext* ctx, Call* call, - std::function call_requester, - experimental::ServerBidiReactor* reactor) - : ctx_(ctx), - call_(*call), - call_requester_(std::move(call_requester)), - reactor_(reactor) { - ctx_->BeginCompletionOp(call, [this](bool) { MaybeDone(); }, reactor); - write_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnWriteDone(ok); - MaybeDone(); - }, - &write_ops_); - write_ops_.set_core_cq_tag(&write_tag_); - read_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadDone(ok); - MaybeDone(); - }, - &read_ops_); - read_ops_.set_core_cq_tag(&read_tag_); - } - ~ServerCallbackReaderWriterImpl() {} - - void MaybeDone() { - if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( - 1, std::memory_order_acq_rel) == 1)) { - reactor_->OnDone(); - grpc_call* call = call_.call(); - auto call_requester = std::move(call_requester_); - this->~ServerCallbackReaderWriterImpl(); // explicitly call destructor - g_core_codegen_interface->grpc_call_unref(call); - call_requester(); - } - } - - CallOpSet meta_ops_; - CallbackWithSuccessTag meta_tag_; - CallOpSet - finish_ops_; - CallbackWithSuccessTag finish_tag_; - CallOpSet write_ops_; - CallbackWithSuccessTag write_tag_; - CallOpSet> read_ops_; - CallbackWithSuccessTag read_tag_; - - ::grpc_impl::ServerContext* ctx_; - Call call_; - std::function call_requester_; - experimental::ServerBidiReactor* reactor_; - std::atomic callbacks_outstanding_{ - 3}; // reserve for OnStarted, Finish, and CompletionOp - }; -}; - -} // namespace internal - } // namespace grpc #endif // GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_H diff --git a/include/grpcpp/impl/codegen/server_callback_impl.h b/include/grpcpp/impl/codegen/server_callback_impl.h new file mode 100644 index 00000000000..08ecdfd6497 --- /dev/null +++ b/include/grpcpp/impl/codegen/server_callback_impl.h @@ -0,0 +1,1186 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_IMPL_H +#define GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_IMPL_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace grpc_impl { + +// Declare base class of all reactors as internal +namespace internal { + +// Forward declarations +template +class CallbackClientStreamingHandler; +template +class CallbackServerStreamingHandler; +template +class CallbackBidiHandler; + +class ServerReactor { + public: + virtual ~ServerReactor() = default; + virtual void OnDone() = 0; + virtual void OnCancel() = 0; + + private: + friend class ::grpc_impl::ServerContext; + template + friend class CallbackClientStreamingHandler; + template + friend class CallbackServerStreamingHandler; + template + friend class CallbackBidiHandler; + + // The ServerReactor is responsible for tracking when it is safe to call + // OnCancel. This function should not be called until after OnStarted is done + // and the RPC has completed with a cancellation. This is tracked by counting + // how many of these conditions have been met and calling OnCancel when none + // remain unmet. + + void MaybeCallOnCancel() { + if (GPR_UNLIKELY(on_cancel_conditions_remaining_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + OnCancel(); + } + } + + std::atomic on_cancel_conditions_remaining_{2}; +}; + +template +class DefaultMessageHolder + : public ::grpc::experimental::MessageHolder { + public: + DefaultMessageHolder() { + this->set_request(&request_obj_); + this->set_response(&response_obj_); + } + void Release() override { + // the object is allocated in the call arena. + this->~DefaultMessageHolder(); + } + + private: + Request request_obj_; + Response response_obj_; +}; + +} // namespace internal + +namespace experimental { + +// Forward declarations +template +class ServerReadReactor; +template +class ServerWriteReactor; +template +class ServerBidiReactor; + +// For unary RPCs, the exposed controller class is only an interface +// and the actual implementation is an internal class. +class ServerCallbackRpcController { + public: + virtual ~ServerCallbackRpcController() = default; + + // The method handler must call this function when it is done so that + // the library knows to free its resources + virtual void Finish(::grpc::Status s) = 0; + + // Allow the method handler to push out the initial metadata before + // the response and status are ready + virtual void SendInitialMetadata(std::function) = 0; + + /// SetCancelCallback passes in a callback to be called when the RPC is + /// canceled for whatever reason (streaming calls have OnCancel instead). This + /// is an advanced and uncommon use with several important restrictions. This + /// function may not be called more than once on the same RPC. + /// + /// If code calls SetCancelCallback on an RPC, it must also call + /// ClearCancelCallback before calling Finish on the RPC controller. That + /// method makes sure that no cancellation callback is executed for this RPC + /// beyond the point of its return. ClearCancelCallback may be called even if + /// SetCancelCallback was not called for this RPC, and it may be called + /// multiple times. It _must_ be called if SetCancelCallback was called for + /// this RPC. + /// + /// The callback should generally be lightweight and nonblocking and primarily + /// concerned with clearing application state related to the RPC or causing + /// operations (such as cancellations) to happen on dependent RPCs. + /// + /// If the RPC is already canceled at the time that SetCancelCallback is + /// called, the callback is invoked immediately. + /// + /// The cancellation callback may be executed concurrently with the method + /// handler that invokes it but will certainly not issue or execute after the + /// return of ClearCancelCallback. If ClearCancelCallback is invoked while the + /// callback is already executing, the callback will complete its execution + /// before ClearCancelCallback takes effect. + /// + /// To preserve the orderings described above, the callback may be called + /// under a lock that is also used for ClearCancelCallback and + /// ServerContext::IsCancelled, so the callback CANNOT call either of those + /// operations on this RPC or any other function that causes those operations + /// to be called before the callback completes. + virtual void SetCancelCallback(std::function callback) = 0; + virtual void ClearCancelCallback() = 0; + + // NOTE: This is an API for advanced users who need custom allocators. + // Get and maybe mutate the allocator state associated with the current RPC. + virtual grpc::experimental::RpcAllocatorState* GetRpcAllocatorState() = 0; +}; + +// NOTE: The actual streaming object classes are provided +// as API only to support mocking. There are no implementations of +// these class interfaces in the API. +template +class ServerCallbackReader { + public: + virtual ~ServerCallbackReader() {} + virtual void Finish(::grpc::Status s) = 0; + virtual void SendInitialMetadata() = 0; + virtual void Read(Request* msg) = 0; + + protected: + template + void BindReactor(ServerReadReactor* reactor) { + reactor->InternalBindReader(this); + } +}; + +template +class ServerCallbackWriter { + public: + virtual ~ServerCallbackWriter() {} + + virtual void Finish(::grpc::Status s) = 0; + virtual void SendInitialMetadata() = 0; + virtual void Write(const Response* msg, ::grpc::WriteOptions options) = 0; + virtual void WriteAndFinish(const Response* msg, ::grpc::WriteOptions options, + ::grpc::Status s) { + // Default implementation that can/should be overridden + Write(msg, std::move(options)); + Finish(std::move(s)); + } + + protected: + template + void BindReactor(ServerWriteReactor* reactor) { + reactor->InternalBindWriter(this); + } +}; + +template +class ServerCallbackReaderWriter { + public: + virtual ~ServerCallbackReaderWriter() {} + + virtual void Finish(::grpc::Status s) = 0; + virtual void SendInitialMetadata() = 0; + virtual void Read(Request* msg) = 0; + virtual void Write(const Response* msg, ::grpc::WriteOptions options) = 0; + virtual void WriteAndFinish(const Response* msg, ::grpc::WriteOptions options, + ::grpc::Status s) { + // Default implementation that can/should be overridden + Write(msg, std::move(options)); + Finish(std::move(s)); + } + + protected: + void BindReactor(ServerBidiReactor* reactor) { + reactor->InternalBindStream(this); + } +}; + +// The following classes are the reactor interfaces that are to be implemented +// by the user, returned as the result of the method handler for a callback +// method, and activated by the call to OnStarted. The library guarantees that +// OnStarted will be called for any reactor that has been created using a +// method handler registered on a service. No operation initiation method may be +// called until after the call to OnStarted. +// Note that none of the classes are pure; all reactions have a default empty +// reaction so that the user class only needs to override those classes that it +// cares about. + +/// \a ServerBidiReactor is the interface for a bidirectional streaming RPC. +template +class ServerBidiReactor : public internal::ServerReactor { + public: + ~ServerBidiReactor() = default; + + /// Do NOT call any operation initiation method (names that start with Start) + /// until after the library has called OnStarted on this object. + + /// Send any initial metadata stored in the RPC context. If not invoked, + /// any initial metadata will be passed along with the first Write or the + /// Finish (if there are no writes). + void StartSendInitialMetadata() { stream_->SendInitialMetadata(); } + + /// Initiate a read operation. + /// + /// \param[out] req Where to eventually store the read message. Valid when + /// the library calls OnReadDone + void StartRead(Request* req) { stream_->Read(req); } + + /// Initiate a write operation. + /// + /// \param[in] resp The message to be written. The library takes temporary + /// ownership until OnWriteDone, at which point the + /// application regains ownership of resp. + void StartWrite(const Response* resp) { + StartWrite(resp, ::grpc::WriteOptions()); + } + + /// Initiate a write operation with specified options. + /// + /// \param[in] resp The message to be written. The library takes temporary + /// ownership until OnWriteDone, at which point the + /// application regains ownership of resp. + /// \param[in] options The WriteOptions to use for writing this message + void StartWrite(const Response* resp, ::grpc::WriteOptions options) { + stream_->Write(resp, std::move(options)); + } + + /// Initiate a write operation with specified options and final RPC Status, + /// which also causes any trailing metadata for this RPC to be sent out. + /// StartWriteAndFinish is like merging StartWriteLast and Finish into a + /// single step. A key difference, though, is that this operation doesn't have + /// an OnWriteDone reaction - it is considered complete only when OnDone is + /// available. An RPC can either have StartWriteAndFinish or Finish, but not + /// both. + /// + /// \param[in] resp The message to be written. The library takes temporary + /// ownership until Onone, at which point the application + /// regains ownership of resp. + /// \param[in] options The WriteOptions to use for writing this message + /// \param[in] s The status outcome of this RPC + void StartWriteAndFinish(const Response* resp, ::grpc::WriteOptions options, + ::grpc::Status s) { + stream_->WriteAndFinish(resp, std::move(options), std::move(s)); + } + + /// Inform system of a planned write operation with specified options, but + /// allow the library to schedule the actual write coalesced with the writing + /// of trailing metadata (which takes place on a Finish call). + /// + /// \param[in] resp The message to be written. The library takes temporary + /// ownership until OnWriteDone, at which point the + /// application regains ownership of resp. + /// \param[in] options The WriteOptions to use for writing this message + void StartWriteLast(const Response* resp, ::grpc::WriteOptions options) { + StartWrite(resp, std::move(options.set_last_message())); + } + + /// Indicate that the stream is to be finished and the trailing metadata and + /// RPC status are to be sent. Every RPC MUST be finished using either Finish + /// or StartWriteAndFinish (but not both), even if the RPC is already + /// cancelled. + /// + /// \param[in] s The status outcome of this RPC + void Finish(::grpc::Status s) { stream_->Finish(std::move(s)); } + + /// Notify the application that a streaming RPC has started and that it is now + /// ok to call any operation initiation method. An RPC is considered started + /// after the server has received all initial metadata from the client, which + /// is a result of the client calling StartCall(). + /// + /// \param[in] context The context object now associated with this RPC + virtual void OnStarted(::grpc_impl::ServerContext* context) {} + + /// Notifies the application that an explicit StartSendInitialMetadata + /// operation completed. Not used when the sending of initial metadata + /// piggybacks onto the first write. + /// + /// \param[in] ok Was it successful? If false, no further write-side operation + /// will succeed. + virtual void OnSendInitialMetadataDone(bool ok) {} + + /// Notifies the application that a StartRead operation completed. + /// + /// \param[in] ok Was it successful? If false, no further read-side operation + /// will succeed. + virtual void OnReadDone(bool ok) {} + + /// Notifies the application that a StartWrite (or StartWriteLast) operation + /// completed. + /// + /// \param[in] ok Was it successful? If false, no further write-side operation + /// will succeed. + virtual void OnWriteDone(bool ok) {} + + /// Notifies the application that all operations associated with this RPC + /// have completed. This is an override (from the internal base class) but not + /// final, so derived classes should override it if they want to take action. + void OnDone() override {} + + /// Notifies the application that this RPC has been cancelled. This is an + /// override (from the internal base class) but not final, so derived classes + /// should override it if they want to take action. + void OnCancel() override {} + + private: + friend class ServerCallbackReaderWriter; + // May be overridden by internal implementation details. This is not a public + // customization point. + virtual void InternalBindStream( + ServerCallbackReaderWriter* stream) { + stream_ = stream; + } + + ServerCallbackReaderWriter* stream_; +}; + +/// \a ServerReadReactor is the interface for a client-streaming RPC. +template +class ServerReadReactor : public internal::ServerReactor { + public: + ~ServerReadReactor() = default; + + /// The following operation initiations are exactly like ServerBidiReactor. + void StartSendInitialMetadata() { reader_->SendInitialMetadata(); } + void StartRead(Request* req) { reader_->Read(req); } + void Finish(::grpc::Status s) { reader_->Finish(std::move(s)); } + + /// Similar to ServerBidiReactor::OnStarted, except that this also provides + /// the response object that the stream fills in before calling Finish. + /// (It must be filled in if status is OK, but it may be filled in otherwise.) + /// + /// \param[in] context The context object now associated with this RPC + /// \param[in] resp The response object to be used by this RPC + virtual void OnStarted(::grpc_impl::ServerContext* context, Response* resp) {} + + /// The following notifications are exactly like ServerBidiReactor. + virtual void OnSendInitialMetadataDone(bool ok) {} + virtual void OnReadDone(bool ok) {} + void OnDone() override {} + void OnCancel() override {} + + private: + friend class ServerCallbackReader; + // May be overridden by internal implementation details. This is not a public + // customization point. + virtual void InternalBindReader(ServerCallbackReader* reader) { + reader_ = reader; + } + + ServerCallbackReader* reader_; +}; + +/// \a ServerWriteReactor is the interface for a server-streaming RPC. +template +class ServerWriteReactor : public internal::ServerReactor { + public: + ~ServerWriteReactor() = default; + + /// The following operation initiations are exactly like ServerBidiReactor. + void StartSendInitialMetadata() { writer_->SendInitialMetadata(); } + void StartWrite(const Response* resp) { + StartWrite(resp, ::grpc::WriteOptions()); + } + void StartWrite(const Response* resp, ::grpc::WriteOptions options) { + writer_->Write(resp, std::move(options)); + } + void StartWriteAndFinish(const Response* resp, ::grpc::WriteOptions options, + ::grpc::Status s) { + writer_->WriteAndFinish(resp, std::move(options), std::move(s)); + } + void StartWriteLast(const Response* resp, ::grpc::WriteOptions options) { + StartWrite(resp, std::move(options.set_last_message())); + } + void Finish(::grpc::Status s) { writer_->Finish(std::move(s)); } + + /// Similar to ServerBidiReactor::OnStarted, except that this also provides + /// the request object sent by the client. + /// + /// \param[in] context The context object now associated with this RPC + /// \param[in] req The request object sent by the client + virtual void OnStarted(::grpc_impl::ServerContext* context, + const Request* req) {} + + /// The following notifications are exactly like ServerBidiReactor. + virtual void OnSendInitialMetadataDone(bool ok) {} + virtual void OnWriteDone(bool ok) {} + void OnDone() override {} + void OnCancel() override {} + + private: + friend class ServerCallbackWriter; + // May be overridden by internal implementation details. This is not a public + // customization point. + virtual void InternalBindWriter(ServerCallbackWriter* writer) { + writer_ = writer; + } + + ServerCallbackWriter* writer_; +}; + +} // namespace experimental + +namespace internal { + +template +class UnimplementedReadReactor + : public experimental::ServerReadReactor { + public: + void OnDone() override { delete this; } + void OnStarted(::grpc_impl::ServerContext*, Response*) override { + this->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); + } +}; + +template +class UnimplementedWriteReactor + : public experimental::ServerWriteReactor { + public: + void OnDone() override { delete this; } + void OnStarted(::grpc_impl::ServerContext*, const Request*) override { + this->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); + } +}; + +template +class UnimplementedBidiReactor + : public experimental::ServerBidiReactor { + public: + void OnDone() override { delete this; } + void OnStarted(::grpc_impl::ServerContext*) override { + this->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); + } +}; + +template +class CallbackUnaryHandler : public grpc::internal::MethodHandler { + public: + CallbackUnaryHandler( + std::function + func) + : func_(func) {} + + void SetMessageAllocator( + ::grpc::experimental::MessageAllocator* + allocator) { + allocator_ = allocator; + } + + void RunHandler(const HandlerParameter& param) final { + // Arena allocate a controller structure (that includes request/response) + ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); + auto* allocator_state = static_cast< + grpc::experimental::MessageHolder*>( + param.internal_data); + auto* controller = + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(ServerCallbackRpcControllerImpl))) + ServerCallbackRpcControllerImpl(param.server_context, param.call, + allocator_state, + std::move(param.call_requester)); + ::grpc::Status status = param.status; + if (status.ok()) { + // Call the actual function handler and expect the user to call finish + grpc::internal::CatchingCallback(func_, param.server_context, + controller->request(), + controller->response(), controller); + } else { + // if deserialization failed, we need to fail the call + controller->Finish(status); + } + } + + void* Deserialize(grpc_call* call, grpc_byte_buffer* req, + ::grpc::Status* status, void** handler_data) final { + grpc::ByteBuffer buf; + buf.set_buffer(req); + RequestType* request = nullptr; + ::grpc::experimental::MessageHolder* + allocator_state = nullptr; + if (allocator_ != nullptr) { + allocator_state = allocator_->AllocateMessages(); + } else { + allocator_state = + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call, sizeof(DefaultMessageHolder))) + DefaultMessageHolder(); + } + *handler_data = allocator_state; + request = allocator_state->request(); + *status = + ::grpc::SerializationTraits::Deserialize(&buf, request); + buf.Release(); + if (status->ok()) { + return request; + } + // Clean up on deserialization failure. + allocator_state->Release(); + return nullptr; + } + + private: + std::function + func_; + grpc::experimental::MessageAllocator* allocator_ = + nullptr; + + // The implementation class of ServerCallbackRpcController is a private member + // of CallbackUnaryHandler since it is never exposed anywhere, and this allows + // it to take advantage of CallbackUnaryHandler's friendships. + class ServerCallbackRpcControllerImpl + : public experimental::ServerCallbackRpcController { + public: + void Finish(::grpc::Status s) override { + finish_tag_.Set(call_.call(), [this](bool) { MaybeDone(); }, + &finish_ops_); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // The response is dropped if the status is not OK. + if (s.ok()) { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, + finish_ops_.SendMessagePtr(response())); + } else { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); + } + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void SendInitialMetadata(std::function f) override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + // TODO(vjpai): Consider taking f as a move-capture if we adopt C++14 + // and if performance of this operation matters + meta_tag_.Set(call_.call(), + [this, f](bool ok) { + f(ok); + MaybeDone(); + }, + &meta_ops_); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + meta_ops_.set_core_cq_tag(&meta_tag_); + call_.PerformOps(&meta_ops_); + } + + // Neither SetCancelCallback nor ClearCancelCallback should affect the + // callbacks_outstanding_ count since they are paired and both must precede + // the invocation of Finish (if they are used at all) + void SetCancelCallback(std::function callback) override { + ctx_->SetCancelCallback(std::move(callback)); + } + + void ClearCancelCallback() override { ctx_->ClearCancelCallback(); } + + grpc::experimental::RpcAllocatorState* GetRpcAllocatorState() override { + return allocator_state_; + } + + private: + friend class CallbackUnaryHandler; + + ServerCallbackRpcControllerImpl( + ServerContext* ctx, ::grpc::internal::Call* call, + ::grpc::experimental::MessageHolder* + allocator_state, + std::function call_requester) + : ctx_(ctx), + call_(*call), + allocator_state_(allocator_state), + call_requester_(std::move(call_requester)) { + ctx_->BeginCompletionOp(call, [this](bool) { MaybeDone(); }, nullptr); + } + + const RequestType* request() { return allocator_state_->request(); } + ResponseType* response() { return allocator_state_->response(); } + + void MaybeDone() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + grpc_call* call = call_.call(); + auto call_requester = std::move(call_requester_); + allocator_state_->Release(); + this->~ServerCallbackRpcControllerImpl(); // explicitly call destructor + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + call_requester(); + } + } + + grpc::internal::CallOpSet + meta_ops_; + grpc::internal::CallbackWithSuccessTag meta_tag_; + grpc::internal::CallOpSet + finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + + ::grpc_impl::ServerContext* ctx_; + grpc::internal::Call call_; + grpc::experimental::MessageHolder* const + allocator_state_; + std::function call_requester_; + std::atomic callbacks_outstanding_{ + 2}; // reserve for Finish and CompletionOp + }; +}; + +template +class CallbackClientStreamingHandler : public grpc::internal::MethodHandler { + public: + CallbackClientStreamingHandler( + std::function< + experimental::ServerReadReactor*()> + func) + : func_(std::move(func)) {} + void RunHandler(const HandlerParameter& param) final { + // Arena allocate a reader structure (that includes response) + ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); + + experimental::ServerReadReactor* reactor = + param.status.ok() + ? ::grpc::internal::CatchingReactorCreator< + experimental::ServerReadReactor>( + func_) + : nullptr; + + if (reactor == nullptr) { + // if deserialization or reactor creator failed, we need to fail the call + reactor = new UnimplementedReadReactor; + } + + auto* reader = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(ServerCallbackReaderImpl))) + ServerCallbackReaderImpl(param.server_context, param.call, + std::move(param.call_requester), reactor); + + reader->BindReactor(reactor); + reactor->OnStarted(param.server_context, reader->response()); + // The earliest that OnCancel can be called is after OnStarted is done. + reactor->MaybeCallOnCancel(); + reader->MaybeDone(); + } + + private: + std::function*()> + func_; + + class ServerCallbackReaderImpl + : public experimental::ServerCallbackReader { + public: + void Finish(::grpc::Status s) override { + finish_tag_.Set(call_.call(), [this](bool) { MaybeDone(); }, + &finish_ops_); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // The response is dropped if the status is not OK. + if (s.ok()) { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, + finish_ops_.SendMessagePtr(&resp_)); + } else { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); + } + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + meta_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnSendInitialMetadataDone(ok); + MaybeDone(); + }, + &meta_ops_); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + meta_ops_.set_core_cq_tag(&meta_tag_); + call_.PerformOps(&meta_ops_); + } + + void Read(RequestType* req) override { + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + read_ops_.RecvMessage(req); + call_.PerformOps(&read_ops_); + } + + private: + friend class CallbackClientStreamingHandler; + + ServerCallbackReaderImpl( + ::grpc_impl::ServerContext* ctx, grpc::internal::Call* call, + std::function call_requester, + experimental::ServerReadReactor* reactor) + : ctx_(ctx), + call_(*call), + call_requester_(std::move(call_requester)), + reactor_(reactor) { + ctx_->BeginCompletionOp(call, [this](bool) { MaybeDone(); }, reactor); + read_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadDone(ok); + MaybeDone(); + }, + &read_ops_); + read_ops_.set_core_cq_tag(&read_tag_); + } + + ~ServerCallbackReaderImpl() {} + + ResponseType* response() { return &resp_; } + + void MaybeDone() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + reactor_->OnDone(); + grpc_call* call = call_.call(); + auto call_requester = std::move(call_requester_); + this->~ServerCallbackReaderImpl(); // explicitly call destructor + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + call_requester(); + } + } + + grpc::internal::CallOpSet + meta_ops_; + grpc::internal::CallbackWithSuccessTag meta_tag_; + grpc::internal::CallOpSet + finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + grpc::internal::CallOpSet> + read_ops_; + grpc::internal::CallbackWithSuccessTag read_tag_; + + ::grpc_impl::ServerContext* ctx_; + grpc::internal::Call call_; + ResponseType resp_; + std::function call_requester_; + experimental::ServerReadReactor* reactor_; + std::atomic callbacks_outstanding_{ + 3}; // reserve for OnStarted, Finish, and CompletionOp + }; +}; + +template +class CallbackServerStreamingHandler : public grpc::internal::MethodHandler { + public: + CallbackServerStreamingHandler( + std::function< + experimental::ServerWriteReactor*()> + func) + : func_(std::move(func)) {} + void RunHandler(const HandlerParameter& param) final { + // Arena allocate a writer structure + ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); + + experimental::ServerWriteReactor* reactor = + param.status.ok() + ? ::grpc::internal::CatchingReactorCreator< + experimental::ServerWriteReactor>( + func_) + : nullptr; + + if (reactor == nullptr) { + // if deserialization or reactor creator failed, we need to fail the call + reactor = new UnimplementedWriteReactor; + } + + auto* writer = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(ServerCallbackWriterImpl))) + ServerCallbackWriterImpl(param.server_context, param.call, + static_cast(param.request), + std::move(param.call_requester), reactor); + writer->BindReactor(reactor); + reactor->OnStarted(param.server_context, writer->request()); + // The earliest that OnCancel can be called is after OnStarted is done. + reactor->MaybeCallOnCancel(); + writer->MaybeDone(); + } + + void* Deserialize(grpc_call* call, grpc_byte_buffer* req, + ::grpc::Status* status, void** handler_data) final { + ::grpc::ByteBuffer buf; + buf.set_buffer(req); + auto* request = + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call, sizeof(RequestType))) RequestType(); + *status = + ::grpc::SerializationTraits::Deserialize(&buf, request); + buf.Release(); + if (status->ok()) { + return request; + } + request->~RequestType(); + return nullptr; + } + + private: + std::function*()> + func_; + + class ServerCallbackWriterImpl + : public experimental::ServerCallbackWriter { + public: + void Finish(::grpc::Status s) override { + finish_tag_.Set(call_.call(), [this](bool) { MaybeDone(); }, + &finish_ops_); + finish_ops_.set_core_cq_tag(&finish_tag_); + + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); + call_.PerformOps(&finish_ops_); + } + + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + meta_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnSendInitialMetadataDone(ok); + MaybeDone(); + }, + &meta_ops_); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + meta_ops_.set_core_cq_tag(&meta_tag_); + call_.PerformOps(&meta_ops_); + } + + void Write(const ResponseType* resp, + ::grpc::WriteOptions options) override { + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (options.is_last_message()) { + options.set_buffer_hint(); + } + if (!ctx_->sent_initial_metadata_) { + write_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + write_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(resp, options).ok()); + call_.PerformOps(&write_ops_); + } + + void WriteAndFinish(const ResponseType* resp, ::grpc::WriteOptions options, + ::grpc::Status s) override { + // This combines the write into the finish callback + // Don't send any message if the status is bad + if (s.ok()) { + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(finish_ops_.SendMessagePtr(resp, options).ok()); + } + Finish(std::move(s)); + } + + private: + friend class CallbackServerStreamingHandler; + + ServerCallbackWriterImpl( + ::grpc_impl::ServerContext* ctx, grpc::internal::Call* call, + const RequestType* req, std::function call_requester, + experimental::ServerWriteReactor* reactor) + : ctx_(ctx), + call_(*call), + req_(req), + call_requester_(std::move(call_requester)), + reactor_(reactor) { + ctx_->BeginCompletionOp(call, [this](bool) { MaybeDone(); }, reactor); + write_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnWriteDone(ok); + MaybeDone(); + }, + &write_ops_); + write_ops_.set_core_cq_tag(&write_tag_); + } + ~ServerCallbackWriterImpl() { req_->~RequestType(); } + + const RequestType* request() { return req_; } + + void MaybeDone() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + reactor_->OnDone(); + grpc_call* call = call_.call(); + auto call_requester = std::move(call_requester_); + this->~ServerCallbackWriterImpl(); // explicitly call destructor + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + call_requester(); + } + } + + grpc::internal::CallOpSet + meta_ops_; + grpc::internal::CallbackWithSuccessTag meta_tag_; + grpc::internal::CallOpSet + finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + grpc::internal::CallOpSet + write_ops_; + grpc::internal::CallbackWithSuccessTag write_tag_; + + ::grpc_impl::ServerContext* ctx_; + grpc::internal::Call call_; + const RequestType* req_; + std::function call_requester_; + experimental::ServerWriteReactor* reactor_; + std::atomic callbacks_outstanding_{ + 3}; // reserve for OnStarted, Finish, and CompletionOp + }; +}; + +template +class CallbackBidiHandler : public grpc::internal::MethodHandler { + public: + CallbackBidiHandler( + std::function< + experimental::ServerBidiReactor*()> + func) + : func_(std::move(func)) {} + void RunHandler(const HandlerParameter& param) final { + ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); + + experimental::ServerBidiReactor* reactor = + param.status.ok() + ? ::grpc::internal::CatchingReactorCreator< + experimental::ServerBidiReactor>( + func_) + : nullptr; + + if (reactor == nullptr) { + // if deserialization or reactor creator failed, we need to fail the call + reactor = new UnimplementedBidiReactor; + } + + auto* stream = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(ServerCallbackReaderWriterImpl))) + ServerCallbackReaderWriterImpl(param.server_context, param.call, + std::move(param.call_requester), + reactor); + + stream->BindReactor(reactor); + reactor->OnStarted(param.server_context); + // The earliest that OnCancel can be called is after OnStarted is done. + reactor->MaybeCallOnCancel(); + stream->MaybeDone(); + } + + private: + std::function*()> + func_; + + class ServerCallbackReaderWriterImpl + : public experimental::ServerCallbackReaderWriter { + public: + void Finish(::grpc::Status s) override { + finish_tag_.Set(call_.call(), [this](bool) { MaybeDone(); }, + &finish_ops_); + finish_ops_.set_core_cq_tag(&finish_tag_); + + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); + call_.PerformOps(&finish_ops_); + } + + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + meta_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnSendInitialMetadataDone(ok); + MaybeDone(); + }, + &meta_ops_); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + meta_ops_.set_core_cq_tag(&meta_tag_); + call_.PerformOps(&meta_ops_); + } + + void Write(const ResponseType* resp, + ::grpc::WriteOptions options) override { + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (options.is_last_message()) { + options.set_buffer_hint(); + } + if (!ctx_->sent_initial_metadata_) { + write_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + write_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(resp, options).ok()); + call_.PerformOps(&write_ops_); + } + + void WriteAndFinish(const ResponseType* resp, ::grpc::WriteOptions options, + ::grpc::Status s) override { + // Don't send any message if the status is bad + if (s.ok()) { + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(finish_ops_.SendMessagePtr(resp, options).ok()); + } + Finish(std::move(s)); + } + + void Read(RequestType* req) override { + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + read_ops_.RecvMessage(req); + call_.PerformOps(&read_ops_); + } + + private: + friend class CallbackBidiHandler; + + ServerCallbackReaderWriterImpl( + ::grpc_impl::ServerContext* ctx, grpc::internal::Call* call, + std::function call_requester, + experimental::ServerBidiReactor* reactor) + : ctx_(ctx), + call_(*call), + call_requester_(std::move(call_requester)), + reactor_(reactor) { + ctx_->BeginCompletionOp(call, [this](bool) { MaybeDone(); }, reactor); + write_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnWriteDone(ok); + MaybeDone(); + }, + &write_ops_); + write_ops_.set_core_cq_tag(&write_tag_); + read_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadDone(ok); + MaybeDone(); + }, + &read_ops_); + read_ops_.set_core_cq_tag(&read_tag_); + } + ~ServerCallbackReaderWriterImpl() {} + + void MaybeDone() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + reactor_->OnDone(); + grpc_call* call = call_.call(); + auto call_requester = std::move(call_requester_); + this->~ServerCallbackReaderWriterImpl(); // explicitly call destructor + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + call_requester(); + } + } + + grpc::internal::CallOpSet + meta_ops_; + grpc::internal::CallbackWithSuccessTag meta_tag_; + grpc::internal::CallOpSet + finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + grpc::internal::CallOpSet + write_ops_; + grpc::internal::CallbackWithSuccessTag write_tag_; + grpc::internal::CallOpSet> + read_ops_; + grpc::internal::CallbackWithSuccessTag read_tag_; + + ::grpc_impl::ServerContext* ctx_; + grpc::internal::Call call_; + std::function call_requester_; + experimental::ServerBidiReactor* reactor_; + std::atomic callbacks_outstanding_{ + 3}; // reserve for OnStarted, Finish, and CompletionOp + }; +}; + +} // namespace internal + +} // namespace grpc_impl + +#endif // GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_IMPL_H diff --git a/include/grpcpp/impl/codegen/server_context_impl.h b/include/grpcpp/impl/codegen/server_context_impl.h index 9497735eacc..72137f153b1 100644 --- a/include/grpcpp/impl/codegen/server_context_impl.h +++ b/include/grpcpp/impl/codegen/server_context_impl.h @@ -44,10 +44,6 @@ namespace grpc_impl { class ClientContext; class CompletionQueue; class Server; -} // namespace grpc_impl -namespace grpc { -class GenericServerContext; -class ServerInterface; template class ServerAsyncReader; template @@ -62,14 +58,6 @@ template class ServerWriter; namespace internal { -template -class ServerReaderWriterBody; -template -class RpcMethodHandler; -template -class ClientStreamingHandler; -template -class ServerStreamingHandler; template class BidiStreamingHandler; template @@ -80,12 +68,28 @@ template class CallbackServerStreamingHandler; template class CallbackBidiHandler; +template +class ServerReaderWriterBody; +class ServerReactor; +} // namespace internal + +} // namespace grpc_impl +namespace grpc { +class GenericServerContext; +class ServerInterface; + +namespace internal { +template +class ClientStreamingHandler; +template +class ServerStreamingHandler; +template +class RpcMethodHandler; template class TemplatedBidiStreamingHandler; template class ErrorMethodHandler; class Call; -class ServerReactor; } // namespace internal class ServerInterface; @@ -275,19 +279,19 @@ class ServerContext { friend class ::grpc::ServerInterface; friend class ::grpc_impl::Server; template - friend class ::grpc::ServerAsyncReader; + friend class ::grpc_impl::ServerAsyncReader; template - friend class ::grpc::ServerAsyncWriter; + friend class ::grpc_impl::ServerAsyncWriter; template - friend class ::grpc::ServerAsyncResponseWriter; + friend class ::grpc_impl::ServerAsyncResponseWriter; template - friend class ::grpc::ServerAsyncReaderWriter; + friend class ::grpc_impl::ServerAsyncReaderWriter; template - friend class ::grpc::ServerReader; + friend class ::grpc_impl::ServerReader; template - friend class ::grpc::ServerWriter; + friend class ::grpc_impl::ServerWriter; template - friend class ::grpc::internal::ServerReaderWriterBody; + friend class ::grpc_impl::internal::ServerReaderWriterBody; template friend class ::grpc::internal::RpcMethodHandler; template @@ -297,13 +301,13 @@ class ServerContext { template friend class ::grpc::internal::TemplatedBidiStreamingHandler; template - friend class ::grpc::internal::CallbackUnaryHandler; + friend class ::grpc_impl::internal::CallbackUnaryHandler; template - friend class ::grpc::internal::CallbackClientStreamingHandler; + friend class ::grpc_impl::internal::CallbackClientStreamingHandler; template - friend class ::grpc::internal::CallbackServerStreamingHandler; + friend class ::grpc_impl::internal::CallbackServerStreamingHandler; template - friend class ::grpc::internal::CallbackBidiHandler; + friend class ::grpc_impl::internal::CallbackBidiHandler; template <::grpc::StatusCode code> friend class ::grpc::internal::ErrorMethodHandler; friend class ::grpc_impl::ClientContext; @@ -317,7 +321,7 @@ class ServerContext { void BeginCompletionOp(::grpc::internal::Call* call, std::function callback, - ::grpc::internal::ServerReactor* reactor); + ::grpc_impl::internal::ServerReactor* reactor); /// Return the tag queued by BeginCompletionOp() ::grpc::internal::CompletionQueueTag* GetCompletionOpTag(); diff --git a/include/grpcpp/impl/codegen/service_type.h b/include/grpcpp/impl/codegen/service_type.h index 4109ee1b504..f13dfb99fa0 100644 --- a/include/grpcpp/impl/codegen/service_type.h +++ b/include/grpcpp/impl/codegen/service_type.h @@ -149,8 +149,9 @@ class Service { void RequestAsyncUnary(int index, ::grpc_impl::ServerContext* context, Message* request, internal::ServerAsyncStreamingInterface* stream, - CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag) { + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag) { // Typecast the index to size_t for indexing into a vector // while preserving the API that existed before a compiler // warning was first seen (grpc/grpc#11664) @@ -160,8 +161,9 @@ class Service { } void RequestAsyncClientStreaming( int index, ::grpc_impl::ServerContext* context, - internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag) { + internal::ServerAsyncStreamingInterface* stream, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, void* tag) { size_t idx = static_cast(index); server_->RequestAsyncCall(methods_[idx].get(), context, stream, call_cq, notification_cq, tag); @@ -169,16 +171,18 @@ class Service { template void RequestAsyncServerStreaming( int index, ::grpc_impl::ServerContext* context, Message* request, - internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag) { + internal::ServerAsyncStreamingInterface* stream, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, void* tag) { size_t idx = static_cast(index); server_->RequestAsyncCall(methods_[idx].get(), context, stream, call_cq, notification_cq, tag, request); } void RequestAsyncBidiStreaming( int index, ::grpc_impl::ServerContext* context, - internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag) { + internal::ServerAsyncStreamingInterface* stream, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, void* tag) { size_t idx = static_cast(index); server_->RequestAsyncCall(methods_[idx].get(), context, stream, call_cq, notification_cq, tag); diff --git a/include/grpcpp/impl/codegen/sync_stream.h b/include/grpcpp/impl/codegen/sync_stream.h index 9d030a13a71..cd447d7c5a5 100644 --- a/include/grpcpp/impl/codegen/sync_stream.h +++ b/include/grpcpp/impl/codegen/sync_stream.h @@ -19,918 +19,42 @@ #ifndef GRPCPP_IMPL_CODEGEN_SYNC_STREAM_H #define GRPCPP_IMPL_CODEGEN_SYNC_STREAM_H -#include -#include -#include -#include -#include -#include -#include -#include +#include namespace grpc { - -namespace internal { -/// Common interface for all synchronous client side streaming. -class ClientStreamingInterface { - public: - virtual ~ClientStreamingInterface() {} - - /// Block waiting until the stream finishes and a final status of the call is - /// available. - /// - /// It is appropriate to call this method when both: - /// * the calling code (client-side) has no more message to send - /// (this can be declared implicitly by calling this method, or - /// explicitly through an earlier call to WritesDone method of the - /// class in use, e.g. \a ClientWriterInterface::WritesDone or - /// \a ClientReaderWriterInterface::WritesDone). - /// * there are no more messages to be received from the server (which can - /// be known implicitly, or explicitly from an earlier call to \a - /// ReaderInterface::Read that returned "false"). - /// - /// This function will return either: - /// - when all incoming messages have been read and the server has - /// returned status. - /// - when the server has returned a non-OK status. - /// - OR when the call failed for some reason and the library generated a - /// status. - /// - /// Return values: - /// - \a Status contains the status code, message and details for the call - /// - the \a ClientContext associated with this call is updated with - /// possible trailing metadata sent from the server. - virtual Status Finish() = 0; -}; - -/// Common interface for all synchronous server side streaming. -class ServerStreamingInterface { - public: - virtual ~ServerStreamingInterface() {} - - /// Block to send initial metadata to client. - /// This call is optional, but if it is used, it cannot be used concurrently - /// with or after the \a Finish method. - /// - /// The initial metadata that will be sent to the client will be - /// taken from the \a ServerContext associated with the call. - virtual void SendInitialMetadata() = 0; -}; - -/// An interface that yields a sequence of messages of type \a R. template -class ReaderInterface { - public: - virtual ~ReaderInterface() {} +using ClientReaderInterface = ::grpc_impl::ClientReaderInterface; - /// Get an upper bound on the next message size available for reading on this - /// stream. - virtual bool NextMessageSize(uint32_t* sz) = 0; - - /// Block to read a message and parse to \a msg. Returns \a true on success. - /// This is thread-safe with respect to \a Write or \WritesDone methods on - /// the same stream. It should not be called concurrently with another \a - /// Read on the same stream as the order of delivery will not be defined. - /// - /// \param[out] msg The read message. - /// - /// \return \a false when there will be no more incoming messages, either - /// because the other side has called \a WritesDone() or the stream has failed - /// (or been cancelled). - virtual bool Read(R* msg) = 0; -}; - -/// An interface that can be fed a sequence of messages of type \a W. -template -class WriterInterface { - public: - virtual ~WriterInterface() {} - - /// Block to write \a msg to the stream with WriteOptions \a options. - /// This is thread-safe with respect to \a ReaderInterface::Read - /// - /// \param msg The message to be written to the stream. - /// \param options The WriteOptions affecting the write operation. - /// - /// \return \a true on success, \a false when the stream has been closed. - virtual bool Write(const W& msg, WriteOptions options) = 0; - - /// Block to write \a msg to the stream with default write options. - /// This is thread-safe with respect to \a ReaderInterface::Read - /// - /// \param msg The message to be written to the stream. - /// - /// \return \a true on success, \a false when the stream has been closed. - inline bool Write(const W& msg) { return Write(msg, WriteOptions()); } - - /// Write \a msg and coalesce it with the writing of trailing metadata, using - /// WriteOptions \a options. - /// - /// For client, WriteLast is equivalent of performing Write and WritesDone in - /// a single step. \a msg and trailing metadata are coalesced and sent on wire - /// by calling this function. For server, WriteLast buffers the \a msg. - /// The writing of \a msg is held until the service handler returns, - /// where \a msg and trailing metadata are coalesced and sent on wire. - /// Note that WriteLast can only buffer \a msg up to the flow control window - /// size. If \a msg size is larger than the window size, it will be sent on - /// wire without buffering. - /// - /// \param[in] msg The message to be written to the stream. - /// \param[in] options The WriteOptions to be used to write this message. - void WriteLast(const W& msg, WriteOptions options) { - Write(msg, options.set_last_message()); - } -}; - -} // namespace internal - -/// Client-side interface for streaming reads of message of type \a R. template -class ClientReaderInterface : public internal::ClientStreamingInterface, - public internal::ReaderInterface { - public: - /// Block to wait for initial metadata from server. The received metadata - /// can only be accessed after this call returns. Should only be called before - /// the first read. Calling this method is optional, and if it is not called - /// the metadata will be available in ClientContext after the first read. - virtual void WaitForInitialMetadata() = 0; -}; - -namespace internal { +using ClientReader = ::grpc_impl::ClientReader; +template +using ClientWriterInterface = ::grpc_impl::ClientWriterInterface; +template +using ClientWriter = ::grpc_impl::ClientWriter; +template +using ClientReaderWriterInterface = + ::grpc_impl::ClientReaderWriterInterface; +template +using ClientReaderWriter = ::grpc_impl::ClientReaderWriter; template -class ClientReaderFactory { - public: - template - static ClientReader* Create(ChannelInterface* channel, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, - const W& request) { - return new ClientReader(channel, method, context, request); - } -}; -} // namespace internal - -/// Synchronous (blocking) client-side API for doing server-streaming RPCs, -/// where the stream of messages coming from the server has messages -/// of type \a R. +using ServerReaderInterface = ::grpc_impl::ServerReaderInterface; template -class ClientReader final : public ClientReaderInterface { - public: - /// See the \a ClientStreamingInterface.WaitForInitialMetadata method for - /// semantics. - /// - // Side effect: - /// Once complete, the initial metadata read from - /// the server will be accessible through the \a ClientContext used to - /// construct this object. - void WaitForInitialMetadata() override { - GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); - - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> - ops; - ops.RecvInitialMetadata(context_); - call_.PerformOps(&ops); - cq_.Pluck(&ops); /// status ignored - } - - bool NextMessageSize(uint32_t* sz) override { - *sz = call_.max_receive_message_size(); - return true; - } - - /// See the \a ReaderInterface.Read method for semantics. - /// Side effect: - /// This also receives initial metadata from the server, if not - /// already received (if initial metadata is received, it can be then - /// accessed through the \a ClientContext associated with this call). - bool Read(R* msg) override { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpRecvMessage> - ops; - if (!context_->initial_metadata_received_) { - ops.RecvInitialMetadata(context_); - } - ops.RecvMessage(msg); - call_.PerformOps(&ops); - return cq_.Pluck(&ops) && ops.got_message; - } - - /// See the \a ClientStreamingInterface.Finish method for semantics. - /// - /// Side effect: - /// The \a ClientContext associated with this call is updated with - /// possible metadata received from the server. - Status Finish() override { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpClientRecvStatus> ops; - Status status; - ops.ClientRecvStatus(context_, &status); - call_.PerformOps(&ops); - GPR_CODEGEN_ASSERT(cq_.Pluck(&ops)); - return status; - } - - private: - friend class internal::ClientReaderFactory; - ::grpc_impl::ClientContext* context_; - ::grpc_impl::CompletionQueue cq_; - ::grpc::internal::Call call_; - - /// Block to create a stream and write the initial metadata and \a request - /// out. Note that \a context will be used to fill in custom initial - /// metadata used to send to the server when starting the call. - template - ClientReader(::grpc::ChannelInterface* channel, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, const W& request) - : context_(context), - cq_(grpc_completion_queue_attributes{ - GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, - nullptr}), // Pluckable cq - call_(channel->CreateCall(method, context, &cq_)) { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpClientSendClose> - ops; - ops.SendInitialMetadata(&context->send_initial_metadata_, - context->initial_metadata_flags()); - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(ops.SendMessagePtr(&request).ok()); - ops.ClientSendClose(); - call_.PerformOps(&ops); - cq_.Pluck(&ops); - } -}; - -/// Client-side interface for streaming writes of message type \a W. +using ServerReader = ::grpc_impl::ServerReader; template -class ClientWriterInterface : public internal::ClientStreamingInterface, - public internal::WriterInterface { - public: - /// Half close writing from the client. (signal that the stream of messages - /// coming from the client is complete). - /// Blocks until currently-pending writes are completed. - /// Thread safe with respect to \a ReaderInterface::Read operations only - /// - /// \return Whether the writes were successful. - virtual bool WritesDone() = 0; -}; - -namespace internal { +using ServerWriterInterface = ::grpc_impl::ServerWriterInterface; template -class ClientWriterFactory { - public: - template - static ClientWriter* Create(::grpc::ChannelInterface* channel, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, - R* response) { - return new ClientWriter(channel, method, context, response); - } -}; -} // namespace internal - -/// Synchronous (blocking) client-side API for doing client-streaming RPCs, -/// where the outgoing message stream coming from the client has messages of -/// type \a W. -template -class ClientWriter : public ClientWriterInterface { - public: - /// See the \a ClientStreamingInterface.WaitForInitialMetadata method for - /// semantics. - /// - // Side effect: - /// Once complete, the initial metadata read from the server will be - /// accessible through the \a ClientContext used to construct this object. - void WaitForInitialMetadata() { - GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); - - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> - ops; - ops.RecvInitialMetadata(context_); - call_.PerformOps(&ops); - cq_.Pluck(&ops); // status ignored - } - - /// See the WriterInterface.Write(const W& msg, WriteOptions options) method - /// for semantics. - /// - /// Side effect: - /// Also sends initial metadata if not already sent (using the - /// \a ClientContext associated with this call). - using ::grpc::internal::WriterInterface::Write; - bool Write(const W& msg, WriteOptions options) override { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpClientSendClose> - ops; - - if (options.is_last_message()) { - options.set_buffer_hint(); - ops.ClientSendClose(); - } - if (context_->initial_metadata_corked_) { - ops.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - context_->set_initial_metadata_corked(false); - } - if (!ops.SendMessagePtr(&msg, options).ok()) { - return false; - } - - call_.PerformOps(&ops); - return cq_.Pluck(&ops); - } - - bool WritesDone() override { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpClientSendClose> ops; - ops.ClientSendClose(); - call_.PerformOps(&ops); - return cq_.Pluck(&ops); - } - - /// See the ClientStreamingInterface.Finish method for semantics. - /// Side effects: - /// - Also receives initial metadata if not already received. - /// - Attempts to fill in the \a response parameter passed - /// to the constructor of this instance with the response - /// message from the server. - Status Finish() override { - Status status; - if (!context_->initial_metadata_received_) { - finish_ops_.RecvInitialMetadata(context_); - } - finish_ops_.ClientRecvStatus(context_, &status); - call_.PerformOps(&finish_ops_); - GPR_CODEGEN_ASSERT(cq_.Pluck(&finish_ops_)); - return status; - } - - private: - friend class internal::ClientWriterFactory; - - /// Block to create a stream (i.e. send request headers and other initial - /// metadata to the server). Note that \a context will be used to fill - /// in custom initial metadata. \a response will be filled in with the - /// single expected response message from the server upon a successful - /// call to the \a Finish method of this instance. - template - ClientWriter(ChannelInterface* channel, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, R* response) - : context_(context), - cq_(grpc_completion_queue_attributes{ - GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, - nullptr}), // Pluckable cq - call_(channel->CreateCall(method, context, &cq_)) { - finish_ops_.RecvMessage(response); - finish_ops_.AllowNoMessage(); - - if (!context_->initial_metadata_corked_) { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> - ops; - ops.SendInitialMetadata(&context->send_initial_metadata_, - context->initial_metadata_flags()); - call_.PerformOps(&ops); - cq_.Pluck(&ops); - } - } - - ::grpc_impl::ClientContext* context_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpGenericRecvMessage, - ::grpc::internal::CallOpClientRecvStatus> - finish_ops_; - ::grpc_impl::CompletionQueue cq_; - ::grpc::internal::Call call_; -}; - -/// Client-side interface for bi-directional streaming with -/// client-to-server stream messages of type \a W and -/// server-to-client stream messages of type \a R. +using ServerWriter = ::grpc_impl::ServerWriter; template -class ClientReaderWriterInterface : public internal::ClientStreamingInterface, - public internal::WriterInterface, - public internal::ReaderInterface { - public: - /// Block to wait for initial metadata from server. The received metadata - /// can only be accessed after this call returns. Should only be called before - /// the first read. Calling this method is optional, and if it is not called - /// the metadata will be available in ClientContext after the first read. - virtual void WaitForInitialMetadata() = 0; - - /// Half close writing from the client. (signal that the stream of messages - /// coming from the clinet is complete). - /// Blocks until currently-pending writes are completed. - /// Thread-safe with respect to \a ReaderInterface::Read - /// - /// \return Whether the writes were successful. - virtual bool WritesDone() = 0; -}; - -namespace internal { +using ServerReaderWriterInterface = + ::grpc_impl::ServerReaderWriterInterface; template -class ClientReaderWriterFactory { - public: - static ClientReaderWriter* Create( - ::grpc::ChannelInterface* channel, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context) { - return new ClientReaderWriter(channel, method, context); - } -}; -} // namespace internal - -/// Synchronous (blocking) client-side API for bi-directional streaming RPCs, -/// where the outgoing message stream coming from the client has messages of -/// type \a W, and the incoming messages stream coming from the server has -/// messages of type \a R. -template -class ClientReaderWriter final : public ClientReaderWriterInterface { - public: - /// Block waiting to read initial metadata from the server. - /// This call is optional, but if it is used, it cannot be used concurrently - /// with or after the \a Finish method. - /// - /// Once complete, the initial metadata read from the server will be - /// accessible through the \a ClientContext used to construct this object. - void WaitForInitialMetadata() override { - GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); - - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> - ops; - ops.RecvInitialMetadata(context_); - call_.PerformOps(&ops); - cq_.Pluck(&ops); // status ignored - } - - bool NextMessageSize(uint32_t* sz) override { - *sz = call_.max_receive_message_size(); - return true; - } - - /// See the \a ReaderInterface.Read method for semantics. - /// Side effect: - /// Also receives initial metadata if not already received (updates the \a - /// ClientContext associated with this call in that case). - bool Read(R* msg) override { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpRecvMessage> - ops; - if (!context_->initial_metadata_received_) { - ops.RecvInitialMetadata(context_); - } - ops.RecvMessage(msg); - call_.PerformOps(&ops); - return cq_.Pluck(&ops) && ops.got_message; - } - - /// See the \a WriterInterface.Write method for semantics. - /// - /// Side effect: - /// Also sends initial metadata if not already sent (using the - /// \a ClientContext associated with this call to fill in values). - using ::grpc::internal::WriterInterface::Write; - bool Write(const W& msg, WriteOptions options) override { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpClientSendClose> - ops; - - if (options.is_last_message()) { - options.set_buffer_hint(); - ops.ClientSendClose(); - } - if (context_->initial_metadata_corked_) { - ops.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - context_->set_initial_metadata_corked(false); - } - if (!ops.SendMessagePtr(&msg, options).ok()) { - return false; - } - - call_.PerformOps(&ops); - return cq_.Pluck(&ops); - } - - bool WritesDone() override { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpClientSendClose> ops; - ops.ClientSendClose(); - call_.PerformOps(&ops); - return cq_.Pluck(&ops); - } - - /// See the ClientStreamingInterface.Finish method for semantics. - /// - /// Side effect: - /// - the \a ClientContext associated with this call is updated with - /// possible trailing metadata sent from the server. - Status Finish() override { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpClientRecvStatus> - ops; - if (!context_->initial_metadata_received_) { - ops.RecvInitialMetadata(context_); - } - Status status; - ops.ClientRecvStatus(context_, &status); - call_.PerformOps(&ops); - GPR_CODEGEN_ASSERT(cq_.Pluck(&ops)); - return status; - } - - private: - friend class internal::ClientReaderWriterFactory; - - ::grpc_impl::ClientContext* context_; - ::grpc_impl::CompletionQueue cq_; - ::grpc::internal::Call call_; - - /// Block to create a stream and write the initial metadata and \a request - /// out. Note that \a context will be used to fill in custom initial metadata - /// used to send to the server when starting the call. - ClientReaderWriter(::grpc::ChannelInterface* channel, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context) - : context_(context), - cq_(grpc_completion_queue_attributes{ - GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, - nullptr}), // Pluckable cq - call_(channel->CreateCall(method, context, &cq_)) { - if (!context_->initial_metadata_corked_) { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> - ops; - ops.SendInitialMetadata(&context->send_initial_metadata_, - context->initial_metadata_flags()); - call_.PerformOps(&ops); - cq_.Pluck(&ops); - } - } -}; - -/// Server-side interface for streaming reads of message of type \a R. -template -class ServerReaderInterface : public internal::ServerStreamingInterface, - public internal::ReaderInterface {}; - -/// Synchronous (blocking) server-side API for doing client-streaming RPCs, -/// where the incoming message stream coming from the client has messages of -/// type \a R. -template -class ServerReader final : public ServerReaderInterface { - public: - /// See the \a ServerStreamingInterface.SendInitialMetadata method - /// for semantics. Note that initial metadata will be affected by the - /// \a ServerContext associated with this call. - void SendInitialMetadata() override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - - internal::CallOpSet ops; - ops.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - ops.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - call_->PerformOps(&ops); - call_->cq()->Pluck(&ops); - } - - bool NextMessageSize(uint32_t* sz) override { - *sz = call_->max_receive_message_size(); - return true; - } - - bool Read(R* msg) override { - internal::CallOpSet> ops; - ops.RecvMessage(msg); - call_->PerformOps(&ops); - return call_->cq()->Pluck(&ops) && ops.got_message; - } - - private: - internal::Call* const call_; - ::grpc_impl::ServerContext* const ctx_; - - template - friend class internal::ClientStreamingHandler; - - ServerReader(internal::Call* call, ::grpc_impl::ServerContext* ctx) - : call_(call), ctx_(ctx) {} -}; - -/// Server-side interface for streaming writes of message of type \a W. -template -class ServerWriterInterface : public internal::ServerStreamingInterface, - public internal::WriterInterface {}; - -/// Synchronous (blocking) server-side API for doing for doing a -/// server-streaming RPCs, where the outgoing message stream coming from the -/// server has messages of type \a W. -template -class ServerWriter final : public ServerWriterInterface { - public: - /// See the \a ServerStreamingInterface.SendInitialMetadata method - /// for semantics. - /// Note that initial metadata will be affected by the - /// \a ServerContext associated with this call. - void SendInitialMetadata() override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - - internal::CallOpSet ops; - ops.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - ops.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - call_->PerformOps(&ops); - call_->cq()->Pluck(&ops); - } - - /// See the \a WriterInterface.Write method for semantics. - /// - /// Side effect: - /// Also sends initial metadata if not already sent (using the - /// \a ClientContext associated with this call to fill in values). - using internal::WriterInterface::Write; - bool Write(const W& msg, WriteOptions options) override { - if (options.is_last_message()) { - options.set_buffer_hint(); - } - - if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) { - return false; - } - if (!ctx_->sent_initial_metadata_) { - ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - ctx_->pending_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - call_->PerformOps(&ctx_->pending_ops_); - // if this is the last message we defer the pluck until AFTER we start - // the trailing md op. This prevents hangs. See - // https://github.com/grpc/grpc/issues/11546 - if (options.is_last_message()) { - ctx_->has_pending_ops_ = true; - return true; - } - ctx_->has_pending_ops_ = false; - return call_->cq()->Pluck(&ctx_->pending_ops_); - } - - private: - internal::Call* const call_; - ::grpc_impl::ServerContext* const ctx_; - - template - friend class internal::ServerStreamingHandler; - - ServerWriter(internal::Call* call, ::grpc_impl::ServerContext* ctx) - : call_(call), ctx_(ctx) {} -}; - -/// Server-side interface for bi-directional streaming. -template -class ServerReaderWriterInterface : public internal::ServerStreamingInterface, - public internal::WriterInterface, - public internal::ReaderInterface {}; - -/// Actual implementation of bi-directional streaming -namespace internal { -template -class ServerReaderWriterBody final { - public: - ServerReaderWriterBody(Call* call, ::grpc_impl::ServerContext* ctx) - : call_(call), ctx_(ctx) {} - - void SendInitialMetadata() { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - - CallOpSet ops; - ops.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - ops.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - call_->PerformOps(&ops); - call_->cq()->Pluck(&ops); - } - - bool NextMessageSize(uint32_t* sz) { - *sz = call_->max_receive_message_size(); - return true; - } - - bool Read(R* msg) { - CallOpSet> ops; - ops.RecvMessage(msg); - call_->PerformOps(&ops); - return call_->cq()->Pluck(&ops) && ops.got_message; - } - - bool Write(const W& msg, WriteOptions options) { - if (options.is_last_message()) { - options.set_buffer_hint(); - } - if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) { - return false; - } - if (!ctx_->sent_initial_metadata_) { - ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - ctx_->pending_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - call_->PerformOps(&ctx_->pending_ops_); - // if this is the last message we defer the pluck until AFTER we start - // the trailing md op. This prevents hangs. See - // https://github.com/grpc/grpc/issues/11546 - if (options.is_last_message()) { - ctx_->has_pending_ops_ = true; - return true; - } - ctx_->has_pending_ops_ = false; - return call_->cq()->Pluck(&ctx_->pending_ops_); - } - - private: - Call* const call_; - ::grpc_impl::ServerContext* const ctx_; -}; - -} // namespace internal - -/// Synchronous (blocking) server-side API for a bidirectional -/// streaming call, where the incoming message stream coming from the client has -/// messages of type \a R, and the outgoing message streaming coming from -/// the server has messages of type \a W. -template -class ServerReaderWriter final : public ServerReaderWriterInterface { - public: - /// See the \a ServerStreamingInterface.SendInitialMetadata method - /// for semantics. Note that initial metadata will be affected by the - /// \a ServerContext associated with this call. - void SendInitialMetadata() override { body_.SendInitialMetadata(); } - - bool NextMessageSize(uint32_t* sz) override { - return body_.NextMessageSize(sz); - } - - bool Read(R* msg) override { return body_.Read(msg); } - - /// See the \a WriterInterface.Write(const W& msg, WriteOptions options) - /// method for semantics. - /// Side effect: - /// Also sends initial metadata if not already sent (using the \a - /// ServerContext associated with this call). - using internal::WriterInterface::Write; - bool Write(const W& msg, WriteOptions options) override { - return body_.Write(msg, options); - } - - private: - internal::ServerReaderWriterBody body_; - - friend class internal::TemplatedBidiStreamingHandler, - false>; - ServerReaderWriter(internal::Call* call, ::grpc_impl::ServerContext* ctx) - : body_(call, ctx) {} -}; - -/// A class to represent a flow-controlled unary call. This is something -/// of a hybrid between conventional unary and streaming. This is invoked -/// through a unary call on the client side, but the server responds to it -/// as though it were a single-ping-pong streaming call. The server can use -/// the \a NextMessageSize method to determine an upper-bound on the size of -/// the message. A key difference relative to streaming: ServerUnaryStreamer -/// must have exactly 1 Read and exactly 1 Write, in that order, to function -/// correctly. Otherwise, the RPC is in error. +using ServerReaderWriter = ::grpc_impl::ServerReaderWriter; template -class ServerUnaryStreamer final - : public ServerReaderWriterInterface { - public: - /// Block to send initial metadata to client. - /// Implicit input parameter: - /// - the \a ServerContext associated with this call will be used for - /// sending initial metadata. - void SendInitialMetadata() override { body_.SendInitialMetadata(); } - - /// Get an upper bound on the request message size from the client. - bool NextMessageSize(uint32_t* sz) override { - return body_.NextMessageSize(sz); - } - - /// Read a message of type \a R into \a msg. Completion will be notified by \a - /// tag on the associated completion queue. - /// This is thread-safe with respect to \a Write or \a WritesDone methods. It - /// should not be called concurrently with other streaming APIs - /// on the same stream. It is not meaningful to call it concurrently - /// with another \a ReaderInterface::Read on the same stream since reads on - /// the same stream are delivered in order. - /// - /// \param[out] msg Where to eventually store the read message. - /// \param[in] tag The tag identifying the operation. - bool Read(RequestType* request) override { - if (read_done_) { - return false; - } - read_done_ = true; - return body_.Read(request); - } - - /// Block to write \a msg to the stream with WriteOptions \a options. - /// This is thread-safe with respect to \a ReaderInterface::Read - /// - /// \param msg The message to be written to the stream. - /// \param options The WriteOptions affecting the write operation. - /// - /// \return \a true on success, \a false when the stream has been closed. - using internal::WriterInterface::Write; - bool Write(const ResponseType& response, WriteOptions options) override { - if (write_done_ || !read_done_) { - return false; - } - write_done_ = true; - return body_.Write(response, options); - } - - private: - internal::ServerReaderWriterBody body_; - bool read_done_; - bool write_done_; - - friend class internal::TemplatedBidiStreamingHandler< - ServerUnaryStreamer, true>; - ServerUnaryStreamer(internal::Call* call, ::grpc_impl::ServerContext* ctx) - : body_(call, ctx), read_done_(false), write_done_(false) {} -}; - -/// A class to represent a flow-controlled server-side streaming call. -/// This is something of a hybrid between server-side and bidi streaming. -/// This is invoked through a server-side streaming call on the client side, -/// but the server responds to it as though it were a bidi streaming call that -/// must first have exactly 1 Read and then any number of Writes. +using ServerUnaryStreamer = + ::grpc_impl::ServerUnaryStreamer; template -class ServerSplitStreamer final - : public ServerReaderWriterInterface { - public: - /// Block to send initial metadata to client. - /// Implicit input parameter: - /// - the \a ServerContext associated with this call will be used for - /// sending initial metadata. - void SendInitialMetadata() override { body_.SendInitialMetadata(); } - - /// Get an upper bound on the request message size from the client. - bool NextMessageSize(uint32_t* sz) override { - return body_.NextMessageSize(sz); - } - - /// Read a message of type \a R into \a msg. Completion will be notified by \a - /// tag on the associated completion queue. - /// This is thread-safe with respect to \a Write or \a WritesDone methods. It - /// should not be called concurrently with other streaming APIs - /// on the same stream. It is not meaningful to call it concurrently - /// with another \a ReaderInterface::Read on the same stream since reads on - /// the same stream are delivered in order. - /// - /// \param[out] msg Where to eventually store the read message. - /// \param[in] tag The tag identifying the operation. - bool Read(RequestType* request) override { - if (read_done_) { - return false; - } - read_done_ = true; - return body_.Read(request); - } - - /// Block to write \a msg to the stream with WriteOptions \a options. - /// This is thread-safe with respect to \a ReaderInterface::Read - /// - /// \param msg The message to be written to the stream. - /// \param options The WriteOptions affecting the write operation. - /// - /// \return \a true on success, \a false when the stream has been closed. - using internal::WriterInterface::Write; - bool Write(const ResponseType& response, WriteOptions options) override { - return read_done_ && body_.Write(response, options); - } - - private: - internal::ServerReaderWriterBody body_; - bool read_done_; - - friend class internal::TemplatedBidiStreamingHandler< - ServerSplitStreamer, false>; - ServerSplitStreamer(internal::Call* call, ::grpc_impl::ServerContext* ctx) - : body_(call, ctx), read_done_(false) {} -}; +using ServerSplitStreamer = + ::grpc_impl::ServerSplitStreamer; } // namespace grpc diff --git a/include/grpcpp/impl/codegen/sync_stream_impl.h b/include/grpcpp/impl/codegen/sync_stream_impl.h new file mode 100644 index 00000000000..dc764e0e27b --- /dev/null +++ b/include/grpcpp/impl/codegen/sync_stream_impl.h @@ -0,0 +1,944 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SYNC_STREAM_IMPL_H +#define GRPCPP_IMPL_CODEGEN_SYNC_STREAM_IMPL_H + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace grpc_impl { + +namespace internal { +/// Common interface for all synchronous client side streaming. +class ClientStreamingInterface { + public: + virtual ~ClientStreamingInterface() {} + + /// Block waiting until the stream finishes and a final status of the call is + /// available. + /// + /// It is appropriate to call this method when both: + /// * the calling code (client-side) has no more message to send + /// (this can be declared implicitly by calling this method, or + /// explicitly through an earlier call to WritesDone method of the + /// class in use, e.g. \a ClientWriterInterface::WritesDone or + /// \a ClientReaderWriterInterface::WritesDone). + /// * there are no more messages to be received from the server (which can + /// be known implicitly, or explicitly from an earlier call to \a + /// ReaderInterface::Read that returned "false"). + /// + /// This function will return either: + /// - when all incoming messages have been read and the server has + /// returned status. + /// - when the server has returned a non-OK status. + /// - OR when the call failed for some reason and the library generated a + /// status. + /// + /// Return values: + /// - \a Status contains the status code, message and details for the call + /// - the \a ClientContext associated with this call is updated with + /// possible trailing metadata sent from the server. + virtual ::grpc::Status Finish() = 0; +}; + +/// Common interface for all synchronous server side streaming. +class ServerStreamingInterface { + public: + virtual ~ServerStreamingInterface() {} + + /// Block to send initial metadata to client. + /// This call is optional, but if it is used, it cannot be used concurrently + /// with or after the \a Finish method. + /// + /// The initial metadata that will be sent to the client will be + /// taken from the \a ServerContext associated with the call. + virtual void SendInitialMetadata() = 0; +}; + +/// An interface that yields a sequence of messages of type \a R. +template +class ReaderInterface { + public: + virtual ~ReaderInterface() {} + + /// Get an upper bound on the next message size available for reading on this + /// stream. + virtual bool NextMessageSize(uint32_t* sz) = 0; + + /// Block to read a message and parse to \a msg. Returns \a true on success. + /// This is thread-safe with respect to \a Write or \WritesDone methods on + /// the same stream. It should not be called concurrently with another \a + /// Read on the same stream as the order of delivery will not be defined. + /// + /// \param[out] msg The read message. + /// + /// \return \a false when there will be no more incoming messages, either + /// because the other side has called \a WritesDone() or the stream has failed + /// (or been cancelled). + virtual bool Read(R* msg) = 0; +}; + +/// An interface that can be fed a sequence of messages of type \a W. +template +class WriterInterface { + public: + virtual ~WriterInterface() {} + + /// Block to write \a msg to the stream with WriteOptions \a options. + /// This is thread-safe with respect to \a ReaderInterface::Read + /// + /// \param msg The message to be written to the stream. + /// \param options The WriteOptions affecting the write operation. + /// + /// \return \a true on success, \a false when the stream has been closed. + virtual bool Write(const W& msg, ::grpc::WriteOptions options) = 0; + + /// Block to write \a msg to the stream with default write options. + /// This is thread-safe with respect to \a ReaderInterface::Read + /// + /// \param msg The message to be written to the stream. + /// + /// \return \a true on success, \a false when the stream has been closed. + inline bool Write(const W& msg) { return Write(msg, ::grpc::WriteOptions()); } + + /// Write \a msg and coalesce it with the writing of trailing metadata, using + /// WriteOptions \a options. + /// + /// For client, WriteLast is equivalent of performing Write and WritesDone in + /// a single step. \a msg and trailing metadata are coalesced and sent on wire + /// by calling this function. For server, WriteLast buffers the \a msg. + /// The writing of \a msg is held until the service handler returns, + /// where \a msg and trailing metadata are coalesced and sent on wire. + /// Note that WriteLast can only buffer \a msg up to the flow control window + /// size. If \a msg size is larger than the window size, it will be sent on + /// wire without buffering. + /// + /// \param[in] msg The message to be written to the stream. + /// \param[in] options The WriteOptions to be used to write this message. + void WriteLast(const W& msg, ::grpc::WriteOptions options) { + Write(msg, options.set_last_message()); + } +}; + +} // namespace internal + +/// Client-side interface for streaming reads of message of type \a R. +template +class ClientReaderInterface : public internal::ClientStreamingInterface, + public internal::ReaderInterface { + public: + /// Block to wait for initial metadata from server. The received metadata + /// can only be accessed after this call returns. Should only be called before + /// the first read. Calling this method is optional, and if it is not called + /// the metadata will be available in ClientContext after the first read. + virtual void WaitForInitialMetadata() = 0; +}; + +namespace internal { +template +class ClientReaderFactory { + public: + template + static ClientReader* Create(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + const W& request) { + return new ClientReader(channel, method, context, request); + } +}; +} // namespace internal + +/// Synchronous (blocking) client-side API for doing server-streaming RPCs, +/// where the stream of messages coming from the server has messages +/// of type \a R. +template +class ClientReader final : public ClientReaderInterface { + public: + /// See the \a ClientStreamingInterface.WaitForInitialMetadata method for + /// semantics. + /// + // Side effect: + /// Once complete, the initial metadata read from + /// the server will be accessible through the \a ClientContext used to + /// construct this object. + void WaitForInitialMetadata() override { + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> + ops; + ops.RecvInitialMetadata(context_); + call_.PerformOps(&ops); + cq_.Pluck(&ops); /// status ignored + } + + bool NextMessageSize(uint32_t* sz) override { + *sz = call_.max_receive_message_size(); + return true; + } + + /// See the \a ReaderInterface.Read method for semantics. + /// Side effect: + /// This also receives initial metadata from the server, if not + /// already received (if initial metadata is received, it can be then + /// accessed through the \a ClientContext associated with this call). + bool Read(R* msg) override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpRecvMessage> + ops; + if (!context_->initial_metadata_received_) { + ops.RecvInitialMetadata(context_); + } + ops.RecvMessage(msg); + call_.PerformOps(&ops); + return cq_.Pluck(&ops) && ops.got_message; + } + + /// See the \a ClientStreamingInterface.Finish method for semantics. + /// + /// Side effect: + /// The \a ClientContext associated with this call is updated with + /// possible metadata received from the server. + ::grpc::Status Finish() override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpClientRecvStatus> ops; + ::grpc::Status status; + ops.ClientRecvStatus(context_, &status); + call_.PerformOps(&ops); + GPR_CODEGEN_ASSERT(cq_.Pluck(&ops)); + return status; + } + + private: + friend class internal::ClientReaderFactory; + ::grpc_impl::ClientContext* context_; + ::grpc_impl::CompletionQueue cq_; + ::grpc::internal::Call call_; + + /// Block to create a stream and write the initial metadata and \a request + /// out. Note that \a context will be used to fill in custom initial + /// metadata used to send to the server when starting the call. + template + ClientReader(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, const W& request) + : context_(context), + cq_(grpc_completion_queue_attributes{ + GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, + nullptr}), // Pluckable cq + call_(channel->CreateCall(method, context, &cq_)) { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose> + ops; + ops.SendInitialMetadata(&context->send_initial_metadata_, + context->initial_metadata_flags()); + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(ops.SendMessagePtr(&request).ok()); + ops.ClientSendClose(); + call_.PerformOps(&ops); + cq_.Pluck(&ops); + } +}; + +/// Client-side interface for streaming writes of message type \a W. +template +class ClientWriterInterface : public internal::ClientStreamingInterface, + public internal::WriterInterface { + public: + /// Half close writing from the client. (signal that the stream of messages + /// coming from the client is complete). + /// Blocks until currently-pending writes are completed. + /// Thread safe with respect to \a ReaderInterface::Read operations only + /// + /// \return Whether the writes were successful. + virtual bool WritesDone() = 0; +}; + +namespace internal { +template +class ClientWriterFactory { + public: + template + static ClientWriter* Create(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + R* response) { + return new ClientWriter(channel, method, context, response); + } +}; +} // namespace internal + +/// Synchronous (blocking) client-side API for doing client-streaming RPCs, +/// where the outgoing message stream coming from the client has messages of +/// type \a W. +template +class ClientWriter : public ClientWriterInterface { + public: + /// See the \a ClientStreamingInterface.WaitForInitialMetadata method for + /// semantics. + /// + // Side effect: + /// Once complete, the initial metadata read from the server will be + /// accessible through the \a ClientContext used to construct this object. + void WaitForInitialMetadata() { + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> + ops; + ops.RecvInitialMetadata(context_); + call_.PerformOps(&ops); + cq_.Pluck(&ops); // status ignored + } + + /// See the WriterInterface.Write(const W& msg, WriteOptions options) method + /// for semantics. + /// + /// Side effect: + /// Also sends initial metadata if not already sent (using the + /// \a ClientContext associated with this call). + using internal::WriterInterface::Write; + bool Write(const W& msg, ::grpc::WriteOptions options) override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose> + ops; + + if (options.is_last_message()) { + options.set_buffer_hint(); + ops.ClientSendClose(); + } + if (context_->initial_metadata_corked_) { + ops.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + context_->set_initial_metadata_corked(false); + } + if (!ops.SendMessagePtr(&msg, options).ok()) { + return false; + } + + call_.PerformOps(&ops); + return cq_.Pluck(&ops); + } + + bool WritesDone() override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpClientSendClose> ops; + ops.ClientSendClose(); + call_.PerformOps(&ops); + return cq_.Pluck(&ops); + } + + /// See the ClientStreamingInterface.Finish method for semantics. + /// Side effects: + /// - Also receives initial metadata if not already received. + /// - Attempts to fill in the \a response parameter passed + /// to the constructor of this instance with the response + /// message from the server. + ::grpc::Status Finish() override { + ::grpc::Status status; + if (!context_->initial_metadata_received_) { + finish_ops_.RecvInitialMetadata(context_); + } + finish_ops_.ClientRecvStatus(context_, &status); + call_.PerformOps(&finish_ops_); + GPR_CODEGEN_ASSERT(cq_.Pluck(&finish_ops_)); + return status; + } + + private: + friend class internal::ClientWriterFactory; + + /// Block to create a stream (i.e. send request headers and other initial + /// metadata to the server). Note that \a context will be used to fill + /// in custom initial metadata. \a response will be filled in with the + /// single expected response message from the server upon a successful + /// call to the \a Finish method of this instance. + template + ClientWriter(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, R* response) + : context_(context), + cq_(grpc_completion_queue_attributes{ + GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, + nullptr}), // Pluckable cq + call_(channel->CreateCall(method, context, &cq_)) { + finish_ops_.RecvMessage(response); + finish_ops_.AllowNoMessage(); + + if (!context_->initial_metadata_corked_) { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + ops; + ops.SendInitialMetadata(&context->send_initial_metadata_, + context->initial_metadata_flags()); + call_.PerformOps(&ops); + cq_.Pluck(&ops); + } + } + + ::grpc_impl::ClientContext* context_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpGenericRecvMessage, + ::grpc::internal::CallOpClientRecvStatus> + finish_ops_; + ::grpc_impl::CompletionQueue cq_; + ::grpc::internal::Call call_; +}; + +/// Client-side interface for bi-directional streaming with +/// client-to-server stream messages of type \a W and +/// server-to-client stream messages of type \a R. +template +class ClientReaderWriterInterface : public internal::ClientStreamingInterface, + public internal::WriterInterface, + public internal::ReaderInterface { + public: + /// Block to wait for initial metadata from server. The received metadata + /// can only be accessed after this call returns. Should only be called before + /// the first read. Calling this method is optional, and if it is not called + /// the metadata will be available in ClientContext after the first read. + virtual void WaitForInitialMetadata() = 0; + + /// Half close writing from the client. (signal that the stream of messages + /// coming from the clinet is complete). + /// Blocks until currently-pending writes are completed. + /// Thread-safe with respect to \a ReaderInterface::Read + /// + /// \return Whether the writes were successful. + virtual bool WritesDone() = 0; +}; + +namespace internal { +template +class ClientReaderWriterFactory { + public: + static ClientReaderWriter* Create( + ::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context) { + return new ClientReaderWriter(channel, method, context); + } +}; +} // namespace internal + +/// Synchronous (blocking) client-side API for bi-directional streaming RPCs, +/// where the outgoing message stream coming from the client has messages of +/// type \a W, and the incoming messages stream coming from the server has +/// messages of type \a R. +template +class ClientReaderWriter final : public ClientReaderWriterInterface { + public: + /// Block waiting to read initial metadata from the server. + /// This call is optional, but if it is used, it cannot be used concurrently + /// with or after the \a Finish method. + /// + /// Once complete, the initial metadata read from the server will be + /// accessible through the \a ClientContext used to construct this object. + void WaitForInitialMetadata() override { + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> + ops; + ops.RecvInitialMetadata(context_); + call_.PerformOps(&ops); + cq_.Pluck(&ops); // status ignored + } + + bool NextMessageSize(uint32_t* sz) override { + *sz = call_.max_receive_message_size(); + return true; + } + + /// See the \a ReaderInterface.Read method for semantics. + /// Side effect: + /// Also receives initial metadata if not already received (updates the \a + /// ClientContext associated with this call in that case). + bool Read(R* msg) override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpRecvMessage> + ops; + if (!context_->initial_metadata_received_) { + ops.RecvInitialMetadata(context_); + } + ops.RecvMessage(msg); + call_.PerformOps(&ops); + return cq_.Pluck(&ops) && ops.got_message; + } + + /// See the \a WriterInterface.Write method for semantics. + /// + /// Side effect: + /// Also sends initial metadata if not already sent (using the + /// \a ClientContext associated with this call to fill in values). + using internal::WriterInterface::Write; + bool Write(const W& msg, ::grpc::WriteOptions options) override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose> + ops; + + if (options.is_last_message()) { + options.set_buffer_hint(); + ops.ClientSendClose(); + } + if (context_->initial_metadata_corked_) { + ops.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + context_->set_initial_metadata_corked(false); + } + if (!ops.SendMessagePtr(&msg, options).ok()) { + return false; + } + + call_.PerformOps(&ops); + return cq_.Pluck(&ops); + } + + bool WritesDone() override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpClientSendClose> ops; + ops.ClientSendClose(); + call_.PerformOps(&ops); + return cq_.Pluck(&ops); + } + + /// See the ClientStreamingInterface.Finish method for semantics. + /// + /// Side effect: + /// - the \a ClientContext associated with this call is updated with + /// possible trailing metadata sent from the server. + ::grpc::Status Finish() override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpClientRecvStatus> + ops; + if (!context_->initial_metadata_received_) { + ops.RecvInitialMetadata(context_); + } + ::grpc::Status status; + ops.ClientRecvStatus(context_, &status); + call_.PerformOps(&ops); + GPR_CODEGEN_ASSERT(cq_.Pluck(&ops)); + return status; + } + + private: + friend class internal::ClientReaderWriterFactory; + + ::grpc_impl::ClientContext* context_; + ::grpc_impl::CompletionQueue cq_; + ::grpc::internal::Call call_; + + /// Block to create a stream and write the initial metadata and \a request + /// out. Note that \a context will be used to fill in custom initial metadata + /// used to send to the server when starting the call. + ClientReaderWriter(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context) + : context_(context), + cq_(grpc_completion_queue_attributes{ + GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, + nullptr}), // Pluckable cq + call_(channel->CreateCall(method, context, &cq_)) { + if (!context_->initial_metadata_corked_) { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + ops; + ops.SendInitialMetadata(&context->send_initial_metadata_, + context->initial_metadata_flags()); + call_.PerformOps(&ops); + cq_.Pluck(&ops); + } + } +}; + +/// Server-side interface for streaming reads of message of type \a R. +template +class ServerReaderInterface : public internal::ServerStreamingInterface, + public internal::ReaderInterface {}; + +/// Synchronous (blocking) server-side API for doing client-streaming RPCs, +/// where the incoming message stream coming from the client has messages of +/// type \a R. +template +class ServerReader final : public ServerReaderInterface { + public: + /// See the \a ServerStreamingInterface.SendInitialMetadata method + /// for semantics. Note that initial metadata will be affected by the + /// \a ServerContext associated with this call. + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + ops; + ops.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ops.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_->PerformOps(&ops); + call_->cq()->Pluck(&ops); + } + + bool NextMessageSize(uint32_t* sz) override { + *sz = call_->max_receive_message_size(); + return true; + } + + bool Read(R* msg) override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage> ops; + ops.RecvMessage(msg); + call_->PerformOps(&ops); + return call_->cq()->Pluck(&ops) && ops.got_message; + } + + private: + ::grpc::internal::Call* const call_; + ServerContext* const ctx_; + + template + friend class ::grpc::internal::ClientStreamingHandler; + + ServerReader(::grpc::internal::Call* call, ::grpc_impl::ServerContext* ctx) + : call_(call), ctx_(ctx) {} +}; + +/// Server-side interface for streaming writes of message of type \a W. +template +class ServerWriterInterface : public internal::ServerStreamingInterface, + public internal::WriterInterface {}; + +/// Synchronous (blocking) server-side API for doing for doing a +/// server-streaming RPCs, where the outgoing message stream coming from the +/// server has messages of type \a W. +template +class ServerWriter final : public ServerWriterInterface { + public: + /// See the \a ServerStreamingInterface.SendInitialMetadata method + /// for semantics. + /// Note that initial metadata will be affected by the + /// \a ServerContext associated with this call. + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + ops; + ops.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ops.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_->PerformOps(&ops); + call_->cq()->Pluck(&ops); + } + + /// See the \a WriterInterface.Write method for semantics. + /// + /// Side effect: + /// Also sends initial metadata if not already sent (using the + /// \a ClientContext associated with this call to fill in values). + using internal::WriterInterface::Write; + bool Write(const W& msg, ::grpc::WriteOptions options) override { + if (options.is_last_message()) { + options.set_buffer_hint(); + } + + if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) { + return false; + } + if (!ctx_->sent_initial_metadata_) { + ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ctx_->pending_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + call_->PerformOps(&ctx_->pending_ops_); + // if this is the last message we defer the pluck until AFTER we start + // the trailing md op. This prevents hangs. See + // https://github.com/grpc/grpc/issues/11546 + if (options.is_last_message()) { + ctx_->has_pending_ops_ = true; + return true; + } + ctx_->has_pending_ops_ = false; + return call_->cq()->Pluck(&ctx_->pending_ops_); + } + + private: + ::grpc::internal::Call* const call_; + ::grpc_impl::ServerContext* const ctx_; + + template + friend class ::grpc::internal::ServerStreamingHandler; + + ServerWriter(::grpc::internal::Call* call, ::grpc_impl::ServerContext* ctx) + : call_(call), ctx_(ctx) {} +}; + +/// Server-side interface for bi-directional streaming. +template +class ServerReaderWriterInterface : public internal::ServerStreamingInterface, + public internal::WriterInterface, + public internal::ReaderInterface {}; + +/// Actual implementation of bi-directional streaming +namespace internal { +template +class ServerReaderWriterBody final { + public: + ServerReaderWriterBody(grpc::internal::Call* call, + ::grpc_impl::ServerContext* ctx) + : call_(call), ctx_(ctx) {} + + void SendInitialMetadata() { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + grpc::internal::CallOpSet ops; + ops.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ops.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_->PerformOps(&ops); + call_->cq()->Pluck(&ops); + } + + bool NextMessageSize(uint32_t* sz) { + *sz = call_->max_receive_message_size(); + return true; + } + + bool Read(R* msg) { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage> ops; + ops.RecvMessage(msg); + call_->PerformOps(&ops); + return call_->cq()->Pluck(&ops) && ops.got_message; + } + + bool Write(const W& msg, ::grpc::WriteOptions options) { + if (options.is_last_message()) { + options.set_buffer_hint(); + } + if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) { + return false; + } + if (!ctx_->sent_initial_metadata_) { + ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ctx_->pending_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + call_->PerformOps(&ctx_->pending_ops_); + // if this is the last message we defer the pluck until AFTER we start + // the trailing md op. This prevents hangs. See + // https://github.com/grpc/grpc/issues/11546 + if (options.is_last_message()) { + ctx_->has_pending_ops_ = true; + return true; + } + ctx_->has_pending_ops_ = false; + return call_->cq()->Pluck(&ctx_->pending_ops_); + } + + private: + grpc::internal::Call* const call_; + ::grpc_impl::ServerContext* const ctx_; +}; + +} // namespace internal + +/// Synchronous (blocking) server-side API for a bidirectional +/// streaming call, where the incoming message stream coming from the client has +/// messages of type \a R, and the outgoing message streaming coming from +/// the server has messages of type \a W. +template +class ServerReaderWriter final : public ServerReaderWriterInterface { + public: + /// See the \a ServerStreamingInterface.SendInitialMetadata method + /// for semantics. Note that initial metadata will be affected by the + /// \a ServerContext associated with this call. + void SendInitialMetadata() override { body_.SendInitialMetadata(); } + + bool NextMessageSize(uint32_t* sz) override { + return body_.NextMessageSize(sz); + } + + bool Read(R* msg) override { return body_.Read(msg); } + + /// See the \a WriterInterface.Write(const W& msg, WriteOptions options) + /// method for semantics. + /// Side effect: + /// Also sends initial metadata if not already sent (using the \a + /// ServerContext associated with this call). + using internal::WriterInterface::Write; + bool Write(const W& msg, ::grpc::WriteOptions options) override { + return body_.Write(msg, options); + } + + private: + internal::ServerReaderWriterBody body_; + + friend class ::grpc::internal::TemplatedBidiStreamingHandler< + ServerReaderWriter, false>; + ServerReaderWriter(::grpc::internal::Call* call, + ::grpc_impl::ServerContext* ctx) + : body_(call, ctx) {} +}; + +/// A class to represent a flow-controlled unary call. This is something +/// of a hybrid between conventional unary and streaming. This is invoked +/// through a unary call on the client side, but the server responds to it +/// as though it were a single-ping-pong streaming call. The server can use +/// the \a NextMessageSize method to determine an upper-bound on the size of +/// the message. A key difference relative to streaming: ServerUnaryStreamer +/// must have exactly 1 Read and exactly 1 Write, in that order, to function +/// correctly. Otherwise, the RPC is in error. +template +class ServerUnaryStreamer final + : public ServerReaderWriterInterface { + public: + /// Block to send initial metadata to client. + /// Implicit input parameter: + /// - the \a ServerContext associated with this call will be used for + /// sending initial metadata. + void SendInitialMetadata() override { body_.SendInitialMetadata(); } + + /// Get an upper bound on the request message size from the client. + bool NextMessageSize(uint32_t* sz) override { + return body_.NextMessageSize(sz); + } + + /// Read a message of type \a R into \a msg. Completion will be notified by \a + /// tag on the associated completion queue. + /// This is thread-safe with respect to \a Write or \a WritesDone methods. It + /// should not be called concurrently with other streaming APIs + /// on the same stream. It is not meaningful to call it concurrently + /// with another \a ReaderInterface::Read on the same stream since reads on + /// the same stream are delivered in order. + /// + /// \param[out] msg Where to eventually store the read message. + /// \param[in] tag The tag identifying the operation. + bool Read(RequestType* request) override { + if (read_done_) { + return false; + } + read_done_ = true; + return body_.Read(request); + } + + /// Block to write \a msg to the stream with WriteOptions \a options. + /// This is thread-safe with respect to \a ReaderInterface::Read + /// + /// \param msg The message to be written to the stream. + /// \param options The WriteOptions affecting the write operation. + /// + /// \return \a true on success, \a false when the stream has been closed. + using internal::WriterInterface::Write; + bool Write(const ResponseType& response, + ::grpc::WriteOptions options) override { + if (write_done_ || !read_done_) { + return false; + } + write_done_ = true; + return body_.Write(response, options); + } + + private: + internal::ServerReaderWriterBody body_; + bool read_done_; + bool write_done_; + + friend class ::grpc::internal::TemplatedBidiStreamingHandler< + ServerUnaryStreamer, true>; + ServerUnaryStreamer(::grpc::internal::Call* call, + ::grpc_impl::ServerContext* ctx) + : body_(call, ctx), read_done_(false), write_done_(false) {} +}; + +/// A class to represent a flow-controlled server-side streaming call. +/// This is something of a hybrid between server-side and bidi streaming. +/// This is invoked through a server-side streaming call on the client side, +/// but the server responds to it as though it were a bidi streaming call that +/// must first have exactly 1 Read and then any number of Writes. +template +class ServerSplitStreamer final + : public ServerReaderWriterInterface { + public: + /// Block to send initial metadata to client. + /// Implicit input parameter: + /// - the \a ServerContext associated with this call will be used for + /// sending initial metadata. + void SendInitialMetadata() override { body_.SendInitialMetadata(); } + + /// Get an upper bound on the request message size from the client. + bool NextMessageSize(uint32_t* sz) override { + return body_.NextMessageSize(sz); + } + + /// Read a message of type \a R into \a msg. Completion will be notified by \a + /// tag on the associated completion queue. + /// This is thread-safe with respect to \a Write or \a WritesDone methods. It + /// should not be called concurrently with other streaming APIs + /// on the same stream. It is not meaningful to call it concurrently + /// with another \a ReaderInterface::Read on the same stream since reads on + /// the same stream are delivered in order. + /// + /// \param[out] msg Where to eventually store the read message. + /// \param[in] tag The tag identifying the operation. + bool Read(RequestType* request) override { + if (read_done_) { + return false; + } + read_done_ = true; + return body_.Read(request); + } + + /// Block to write \a msg to the stream with WriteOptions \a options. + /// This is thread-safe with respect to \a ReaderInterface::Read + /// + /// \param msg The message to be written to the stream. + /// \param options The WriteOptions affecting the write operation. + /// + /// \return \a true on success, \a false when the stream has been closed. + using internal::WriterInterface::Write; + bool Write(const ResponseType& response, + ::grpc::WriteOptions options) override { + return read_done_ && body_.Write(response, options); + } + + private: + internal::ServerReaderWriterBody body_; + bool read_done_; + + friend class ::grpc::internal::TemplatedBidiStreamingHandler< + ServerSplitStreamer, false>; + ServerSplitStreamer(::grpc::internal::Call* call, + ::grpc_impl::ServerContext* ctx) + : body_(call, ctx), read_done_(false) {} +}; + +} // namespace grpc_impl + +#endif // GRPCPP_IMPL_CODEGEN_SYNC_STREAM_IMPL_H diff --git a/include/grpcpp/support/async_stream_impl.h b/include/grpcpp/support/async_stream_impl.h new file mode 100644 index 00000000000..cff700d3fa9 --- /dev/null +++ b/include/grpcpp/support/async_stream_impl.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_ASYNC_STREAM_IMPL_H +#define GRPCPP_SUPPORT_ASYNC_STREAM_IMPL_H + +#include + +#endif // GRPCPP_SUPPORT_ASYNC_STREAM_IMPL_H diff --git a/include/grpcpp/support/async_unary_call_impl.h b/include/grpcpp/support/async_unary_call_impl.h new file mode 100644 index 00000000000..488fe87515a --- /dev/null +++ b/include/grpcpp/support/async_unary_call_impl.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_ASYNC_UNARY_CALL_IMPL_H +#define GRPCPP_SUPPORT_ASYNC_UNARY_CALL_IMPL_H + +#include + +#endif // GRPCPP_SUPPORT_ASYNC_UNARY_CALL_IMPL_H diff --git a/include/grpcpp/support/client_callback_impl.h b/include/grpcpp/support/client_callback_impl.h new file mode 100644 index 00000000000..ed8df412496 --- /dev/null +++ b/include/grpcpp/support/client_callback_impl.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_CLIENT_CALLBACK_IMPL_H +#define GRPCPP_SUPPORT_CLIENT_CALLBACK_IMPL_H + +#include + +#endif // GRPCPP_SUPPORT_CLIENT_CALLBACK_IMPL_H diff --git a/include/grpcpp/support/server_callback_impl.h b/include/grpcpp/support/server_callback_impl.h new file mode 100644 index 00000000000..a91c8141dd8 --- /dev/null +++ b/include/grpcpp/support/server_callback_impl.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_SERVER_CALLBACK_IMPL_H +#define GRPCPP_SUPPORT_SERVER_CALLBACK_IMPL_H + +#include + +#endif // GRPCPP_SUPPORT_SERVER_CALLBACK_IMPL_H diff --git a/include/grpcpp/support/sync_stream_impl.h b/include/grpcpp/support/sync_stream_impl.h new file mode 100644 index 00000000000..a00e425acfc --- /dev/null +++ b/include/grpcpp/support/sync_stream_impl.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_SYNC_STREAM_IMPL_H +#define GRPCPP_SUPPORT_SYNC_STREAM_IMPL_H + +#include + +#endif // GRPCPP_SUPPORT_SYNC_STREAM_IMPL_H diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index 358efe9fd79..044647d9a81 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -143,6 +143,7 @@ grpc::string GetHeaderIncludes(grpc_generator::File* file, "grpcpp/impl/codegen/async_unary_call.h", "grpcpp/impl/codegen/client_callback.h", "grpcpp/impl/codegen/client_context.h", + "grpcpp/impl/codegen/completion_queue.h", "grpcpp/impl/codegen/method_handler_impl.h", "grpcpp/impl/codegen/proto_utils.h", "grpcpp/impl/codegen/rpc_method.h", @@ -946,11 +947,12 @@ void PrintHeaderServerCallbackMethodsHelper( " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); - printer->Print(*vars, - "virtual ::grpc::experimental::ServerReadReactor< " - "$RealRequest$, $RealResponse$>* $Method$() {\n" - " return new ::grpc::internal::UnimplementedReadReactor<\n" - " $RealRequest$, $RealResponse$>;}\n"); + printer->Print( + *vars, + "virtual ::grpc::experimental::ServerReadReactor< " + "$RealRequest$, $RealResponse$>* $Method$() {\n" + " return new ::grpc_impl::internal::UnimplementedReadReactor<\n" + " $RealRequest$, $RealResponse$>;}\n"); } else if (ServerOnlyStreaming(method)) { printer->Print( *vars, @@ -962,11 +964,12 @@ void PrintHeaderServerCallbackMethodsHelper( " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); - printer->Print(*vars, - "virtual ::grpc::experimental::ServerWriteReactor< " - "$RealRequest$, $RealResponse$>* $Method$() {\n" - " return new ::grpc::internal::UnimplementedWriteReactor<\n" - " $RealRequest$, $RealResponse$>;}\n"); + printer->Print( + *vars, + "virtual ::grpc::experimental::ServerWriteReactor< " + "$RealRequest$, $RealResponse$>* $Method$() {\n" + " return new ::grpc_impl::internal::UnimplementedWriteReactor<\n" + " $RealRequest$, $RealResponse$>;}\n"); } else if (method->BidiStreaming()) { printer->Print( *vars, @@ -978,11 +981,12 @@ void PrintHeaderServerCallbackMethodsHelper( " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); - printer->Print(*vars, - "virtual ::grpc::experimental::ServerBidiReactor< " - "$RealRequest$, $RealResponse$>* $Method$() {\n" - " return new ::grpc::internal::UnimplementedBidiReactor<\n" - " $RealRequest$, $RealResponse$>;}\n"); + printer->Print( + *vars, + "virtual ::grpc::experimental::ServerBidiReactor< " + "$RealRequest$, $RealResponse$>* $Method$() {\n" + " return new ::grpc_impl::internal::UnimplementedBidiReactor<\n" + " $RealRequest$, $RealResponse$>;}\n"); } } @@ -1010,7 +1014,7 @@ void PrintHeaderServerMethodCallback( printer->Print( *vars, " ::grpc::Service::experimental().MarkMethodCallback($Idx$,\n" - " new ::grpc::internal::CallbackUnaryHandler< " + " new ::grpc_impl::internal::CallbackUnaryHandler< " "$RealRequest$, $RealResponse$>(\n" " [this](::grpc::ServerContext* context,\n" " const $RealRequest$* request,\n" @@ -1024,7 +1028,7 @@ void PrintHeaderServerMethodCallback( "void SetMessageAllocatorFor_$Method$(\n" " ::grpc::experimental::MessageAllocator< " "$RealRequest$, $RealResponse$>* allocator) {\n" - " static_cast<::grpc::internal::CallbackUnaryHandler< " + " static_cast<::grpc_impl::internal::CallbackUnaryHandler< " "$RealRequest$, $RealResponse$>*>(\n" " ::grpc::Service::experimental().GetHandler($Idx$))\n" " ->SetMessageAllocator(allocator);\n"); @@ -1032,21 +1036,21 @@ void PrintHeaderServerMethodCallback( printer->Print( *vars, " ::grpc::Service::experimental().MarkMethodCallback($Idx$,\n" - " new ::grpc::internal::CallbackClientStreamingHandler< " + " new ::grpc_impl::internal::CallbackClientStreamingHandler< " "$RealRequest$, $RealResponse$>(\n" " [this] { return this->$Method$(); }));\n"); } else if (ServerOnlyStreaming(method)) { printer->Print( *vars, " ::grpc::Service::experimental().MarkMethodCallback($Idx$,\n" - " new ::grpc::internal::CallbackServerStreamingHandler< " + " new ::grpc_impl::internal::CallbackServerStreamingHandler< " "$RealRequest$, $RealResponse$>(\n" " [this] { return this->$Method$(); }));\n"); } else if (method->BidiStreaming()) { printer->Print( *vars, " ::grpc::Service::experimental().MarkMethodCallback($Idx$,\n" - " new ::grpc::internal::CallbackBidiHandler< " + " new ::grpc_impl::internal::CallbackBidiHandler< " "$RealRequest$, $RealResponse$>(\n" " [this] { return this->$Method$(); }));\n"); } @@ -1084,7 +1088,7 @@ void PrintHeaderServerMethodRawCallback( printer->Print( *vars, " ::grpc::Service::experimental().MarkMethodRawCallback($Idx$,\n" - " new ::grpc::internal::CallbackUnaryHandler< " + " new ::grpc_impl::internal::CallbackUnaryHandler< " "$RealRequest$, $RealResponse$>(\n" " [this](::grpc::ServerContext* context,\n" " const $RealRequest$* request,\n" @@ -1098,21 +1102,21 @@ void PrintHeaderServerMethodRawCallback( printer->Print( *vars, " ::grpc::Service::experimental().MarkMethodRawCallback($Idx$,\n" - " new ::grpc::internal::CallbackClientStreamingHandler< " + " new ::grpc_impl::internal::CallbackClientStreamingHandler< " "$RealRequest$, $RealResponse$>(\n" " [this] { return this->$Method$(); }));\n"); } else if (ServerOnlyStreaming(method)) { printer->Print( *vars, " ::grpc::Service::experimental().MarkMethodRawCallback($Idx$,\n" - " new ::grpc::internal::CallbackServerStreamingHandler< " + " new ::grpc_impl::internal::CallbackServerStreamingHandler< " "$RealRequest$, $RealResponse$>(\n" " [this] { return this->$Method$(); }));\n"); } else if (method->BidiStreaming()) { printer->Print( *vars, " ::grpc::Service::experimental().MarkMethodRawCallback($Idx$,\n" - " new ::grpc::internal::CallbackBidiHandler< " + " new ::grpc_impl::internal::CallbackBidiHandler< " "$RealRequest$, $RealResponse$>(\n" " [this] { return this->$Method$(); }));\n"); } @@ -1705,7 +1709,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "const $Request$* request, $Response$* response, " "std::function f) {\n"); printer->Print(*vars, - " ::grpc::internal::CallbackUnaryCall" + " ::grpc_impl::internal::CallbackUnaryCall" "(stub_->channel_.get(), stub_->rpcmethod_$Method$_, " "context, request, response, std::move(f));\n}\n\n"); @@ -1715,7 +1719,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "const ::grpc::ByteBuffer* request, $Response$* response, " "std::function f) {\n"); printer->Print(*vars, - " ::grpc::internal::CallbackUnaryCall" + " ::grpc_impl::internal::CallbackUnaryCall" "(stub_->channel_.get(), stub_->rpcmethod_$Method$_, " "context, request, response, std::move(f));\n}\n\n"); @@ -1725,7 +1729,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "const $Request$* request, $Response$* response, " "::grpc::experimental::ClientUnaryReactor* reactor) {\n"); printer->Print(*vars, - " ::grpc::internal::ClientCallbackUnaryFactory::Create" + " ::grpc_impl::internal::ClientCallbackUnaryFactory::Create" "(stub_->channel_.get(), stub_->rpcmethod_$Method$_, " "context, request, response, reactor);\n}\n\n"); @@ -1735,7 +1739,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "const ::grpc::ByteBuffer* request, $Response$* response, " "::grpc::experimental::ClientUnaryReactor* reactor) {\n"); printer->Print(*vars, - " ::grpc::internal::ClientCallbackUnaryFactory::Create" + " ::grpc_impl::internal::ClientCallbackUnaryFactory::Create" "(stub_->channel_.get(), stub_->rpcmethod_$Method$_, " "context, request, response, reactor);\n}\n\n"); @@ -1751,7 +1755,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, printer->Print( *vars, " return " - "::grpc::internal::ClientAsyncResponseReaderFactory< $Response$>" + "::grpc_impl::internal::ClientAsyncResponseReaderFactory< $Response$>" "::Create(channel_.get(), cq, " "rpcmethod_$Method$_, " "context, request, $AsyncStart$);\n" @@ -1762,13 +1766,13 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "::grpc::ClientWriter< $Request$>* " "$ns$$Service$::Stub::$Method$Raw(" "::grpc::ClientContext* context, $Response$* response) {\n"); - printer->Print( - *vars, - " return ::grpc::internal::ClientWriterFactory< $Request$>::Create(" - "channel_.get(), " - "rpcmethod_$Method$_, " - "context, response);\n" - "}\n\n"); + printer->Print(*vars, + " return ::grpc_impl::internal::ClientWriterFactory< " + "$Request$>::Create(" + "channel_.get(), " + "rpcmethod_$Method$_, " + "context, response);\n" + "}\n\n"); printer->Print( *vars, @@ -1777,7 +1781,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "$Response$* response, " "::grpc::experimental::ClientWriteReactor< $Request$>* reactor) {\n"); printer->Print(*vars, - " ::grpc::internal::ClientCallbackWriterFactory< " + " ::grpc_impl::internal::ClientCallbackWriterFactory< " "$Request$>::Create(" "stub_->channel_.get(), " "stub_->rpcmethod_$Method$_, " @@ -1796,7 +1800,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); printer->Print( *vars, - " return ::grpc::internal::ClientAsyncWriterFactory< $Request$>" + " return ::grpc_impl::internal::ClientAsyncWriterFactory< $Request$>" "::Create(channel_.get(), cq, " "rpcmethod_$Method$_, " "context, response, $AsyncStart$$AsyncCreateArgs$);\n" @@ -1808,13 +1812,13 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "::grpc::ClientReader< $Response$>* " "$ns$$Service$::Stub::$Method$Raw(" "::grpc::ClientContext* context, const $Request$& request) {\n"); - printer->Print( - *vars, - " return ::grpc::internal::ClientReaderFactory< $Response$>::Create(" - "channel_.get(), " - "rpcmethod_$Method$_, " - "context, request);\n" - "}\n\n"); + printer->Print(*vars, + " return ::grpc_impl::internal::ClientReaderFactory< " + "$Response$>::Create(" + "channel_.get(), " + "rpcmethod_$Method$_, " + "context, request);\n" + "}\n\n"); printer->Print( *vars, @@ -1823,7 +1827,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "$Request$* request, " "::grpc::experimental::ClientReadReactor< $Response$>* reactor) {\n"); printer->Print(*vars, - " ::grpc::internal::ClientCallbackReaderFactory< " + " ::grpc_impl::internal::ClientCallbackReaderFactory< " "$Response$>::Create(" "stub_->channel_.get(), " "stub_->rpcmethod_$Method$_, " @@ -1843,7 +1847,8 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); printer->Print( *vars, - " return ::grpc::internal::ClientAsyncReaderFactory< $Response$>" + " return ::grpc_impl::internal::ClientAsyncReaderFactory< " + "$Response$>" "::Create(channel_.get(), cq, " "rpcmethod_$Method$_, " "context, request, $AsyncStart$$AsyncCreateArgs$);\n" @@ -1855,7 +1860,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "::grpc::ClientReaderWriter< $Request$, $Response$>* " "$ns$$Service$::Stub::$Method$Raw(::grpc::ClientContext* context) {\n"); printer->Print(*vars, - " return ::grpc::internal::ClientReaderWriterFactory< " + " return ::grpc_impl::internal::ClientReaderWriterFactory< " "$Request$, $Response$>::Create(" "channel_.get(), " "rpcmethod_$Method$_, " @@ -1868,13 +1873,14 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "ClientContext* context, " "::grpc::experimental::ClientBidiReactor< $Request$,$Response$>* " "reactor) {\n"); - printer->Print(*vars, - " ::grpc::internal::ClientCallbackReaderWriterFactory< " - "$Request$,$Response$>::Create(" - "stub_->channel_.get(), " - "stub_->rpcmethod_$Method$_, " - "context, reactor);\n" - "}\n\n"); + printer->Print( + *vars, + " ::grpc_impl::internal::ClientCallbackReaderWriterFactory< " + "$Request$,$Response$>::Create(" + "stub_->channel_.get(), " + "stub_->rpcmethod_$Method$_, " + "context, reactor);\n" + "}\n\n"); for (auto async_prefix : async_prefixes) { (*vars)["AsyncPrefix"] = async_prefix.prefix; @@ -1888,7 +1894,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); printer->Print(*vars, " return " - "::grpc::internal::ClientAsyncReaderWriterFactory< " + "::grpc_impl::internal::ClientAsyncReaderWriterFactory< " "$Request$, $Response$>::Create(" "channel_.get(), cq, " "rpcmethod_$Method$_, " @@ -2279,7 +2285,8 @@ void PrintMockClientMethods(grpc_generator::Printer* printer, printer->Print( *vars, "MOCK_METHOD$MockArgs$($AsyncPrefix$$Method$Raw, " - "::grpc::ClientAsyncReaderWriterInterface<$Request$, $Response$>*" + "::grpc::ClientAsyncReaderWriterInterface<$Request$, " + "$Response$>*" "(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq" "$AsyncMethodParams$));\n"); } diff --git a/src/cpp/client/generic_stub.cc b/src/cpp/client/generic_stub.cc index 41631c794f2..e7d3df7a497 100644 --- a/src/cpp/client/generic_stub.cc +++ b/src/cpp/client/generic_stub.cc @@ -27,11 +27,10 @@ namespace grpc_impl { namespace { std::unique_ptr CallInternal( grpc::ChannelInterface* channel, grpc::ClientContext* context, - const grpc::string& method, grpc::CompletionQueue* cq, bool start, - void* tag) { + const grpc::string& method, CompletionQueue* cq, bool start, void* tag) { return std::unique_ptr( - grpc::internal::ClientAsyncReaderWriterFactory:: + internal::ClientAsyncReaderWriterFactory:: Create(channel, cq, grpc::internal::RpcMethod( method.c_str(), grpc::internal::RpcMethod::BIDI_STREAMING), @@ -43,14 +42,14 @@ std::unique_ptr CallInternal( // begin a call to a named method std::unique_ptr GenericStub::Call( grpc::ClientContext* context, const grpc::string& method, - grpc::CompletionQueue* cq, void* tag) { + CompletionQueue* cq, void* tag) { return CallInternal(channel_.get(), context, method, cq, true, tag); } // setup a call to a named method std::unique_ptr GenericStub::PrepareCall( grpc::ClientContext* context, const grpc::string& method, - grpc::CompletionQueue* cq) { + CompletionQueue* cq) { return CallInternal(channel_.get(), context, method, cq, false, nullptr); } @@ -59,21 +58,20 @@ std::unique_ptr GenericStub::PrepareUnaryCall(grpc::ClientContext* context, const grpc::string& method, const grpc::ByteBuffer& request, - grpc::CompletionQueue* cq) { + CompletionQueue* cq) { return std::unique_ptr( - grpc::internal::ClientAsyncResponseReaderFactory< - grpc::ByteBuffer>::Create(channel_.get(), cq, - grpc::internal::RpcMethod( - method.c_str(), - grpc::internal::RpcMethod::NORMAL_RPC), - context, request, false)); + internal::ClientAsyncResponseReaderFactory::Create( + channel_.get(), cq, + grpc::internal::RpcMethod(method.c_str(), + grpc::internal::RpcMethod::NORMAL_RPC), + context, request, false)); } void GenericStub::experimental_type::UnaryCall( grpc::ClientContext* context, const grpc::string& method, const grpc::ByteBuffer* request, grpc::ByteBuffer* response, std::function on_completion) { - grpc::internal::CallbackUnaryCall( + internal::CallbackUnaryCall( stub_->channel_.get(), grpc::internal::RpcMethod(method.c_str(), grpc::internal::RpcMethod::NORMAL_RPC), @@ -82,9 +80,9 @@ void GenericStub::experimental_type::UnaryCall( void GenericStub::experimental_type::PrepareBidiStreamingCall( grpc::ClientContext* context, const grpc::string& method, - grpc::experimental::ClientBidiReactor* + experimental::ClientBidiReactor* reactor) { - grpc::internal::ClientCallbackReaderWriterFactory< + internal::ClientCallbackReaderWriterFactory< grpc::ByteBuffer, grpc::ByteBuffer>::Create(stub_->channel_.get(), grpc::internal::RpcMethod( diff --git a/src/cpp/server/async_generic_service.cc b/src/cpp/server/async_generic_service.cc index 30613768295..556447a7f40 100644 --- a/src/cpp/server/async_generic_service.cc +++ b/src/cpp/server/async_generic_service.cc @@ -24,8 +24,8 @@ namespace grpc { void AsyncGenericService::RequestCall( GenericServerContext* ctx, GenericServerAsyncReaderWriter* reader_writer, - CompletionQueue* call_cq, ServerCompletionQueue* notification_cq, - void* tag) { + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, void* tag) { server_->RequestAsyncGenericCall(ctx, reader_writer, call_cq, notification_cq, tag); } diff --git a/src/cpp/server/health/default_health_check_service.h b/src/cpp/server/health/default_health_check_service.h index 4b926efdfe8..14a54d53ee0 100644 --- a/src/cpp/server/health/default_health_check_service.h +++ b/src/cpp/server/health/default_health_check_service.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index 1ba9ae1c9dc..1d68c2bdaea 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -69,14 +69,14 @@ ServerBuilder::~ServerBuilder() { } } -std::unique_ptr ServerBuilder::AddCompletionQueue( +std::unique_ptr ServerBuilder::AddCompletionQueue( bool is_frequently_polled) { - grpc::ServerCompletionQueue* cq = new grpc::ServerCompletionQueue( + ServerCompletionQueue* cq = new ServerCompletionQueue( GRPC_CQ_NEXT, is_frequently_polled ? GRPC_CQ_DEFAULT_POLLING : GRPC_CQ_NON_LISTENING, nullptr); cqs_.push_back(cq); - return std::unique_ptr(cq); + return std::unique_ptr(cq); } ServerBuilder& ServerBuilder::RegisterService(grpc::Service* service) { @@ -266,10 +266,9 @@ std::unique_ptr ServerBuilder::BuildAndStart() { // This is different from the completion queues added to the server via // ServerBuilder's AddCompletionQueue() method (those completion queues // are in 'cqs_' member variable of ServerBuilder object) - std::shared_ptr>> - sync_server_cqs( - std::make_shared< - std::vector>>()); + std::shared_ptr>> + sync_server_cqs(std::make_shared< + std::vector>>()); bool has_frequently_polled_cqs = false; for (auto it = cqs_.begin(); it != cqs_.end(); ++it) { @@ -298,7 +297,7 @@ std::unique_ptr ServerBuilder::BuildAndStart() { // Create completion queues to listen to incoming rpc requests for (int i = 0; i < sync_server_settings_.num_cqs; i++) { sync_server_cqs->emplace_back( - new grpc::ServerCompletionQueue(GRPC_CQ_NEXT, polling_type, nullptr)); + new ServerCompletionQueue(GRPC_CQ_NEXT, polling_type, nullptr)); } } diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc index ba834237ae9..1e27fad3988 100644 --- a/src/cpp/server/server_context.cc +++ b/src/cpp/server/server_context.cc @@ -45,8 +45,7 @@ class ServerContext::CompletionOp final public: // initial refs: one in the server context, one in the cq // must ref the call before calling constructor and after deleting this - CompletionOp(::grpc::internal::Call* call, - ::grpc::internal::ServerReactor* reactor) + CompletionOp(::grpc::internal::Call* call, internal::ServerReactor* reactor) : call_(*call), reactor_(reactor), has_tag_(false), @@ -152,7 +151,7 @@ class ServerContext::CompletionOp final } ::grpc::internal::Call call_; - ::grpc::internal::ServerReactor* const reactor_; + internal::ServerReactor* const reactor_; bool has_tag_; void* tag_; void* core_cq_tag_; @@ -294,9 +293,9 @@ void ServerContext::Clear() { } } -void ServerContext::BeginCompletionOp( - ::grpc::internal::Call* call, std::function callback, - ::grpc::internal::ServerReactor* reactor) { +void ServerContext::BeginCompletionOp(::grpc::internal::Call* call, + std::function callback, + internal::ServerReactor* reactor) { GPR_ASSERT(!completion_op_); if (rpc_info_) { rpc_info_->Ref(); diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index 035955023b8..34fb5bfb53f 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -336,7 +337,7 @@ class ServiceA final { public: ExperimentalWithCallbackMethod_MethodA1() { ::grpc::Service::experimental().MarkMethodCallback(0, - new ::grpc::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>( + new ::grpc_impl::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>( [this](::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, @@ -346,7 +347,7 @@ class ServiceA final { } void SetMessageAllocatorFor_MethodA1( ::grpc::experimental::MessageAllocator< ::grpc::testing::Request, ::grpc::testing::Response>* allocator) { - static_cast<::grpc::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>*>( + static_cast<::grpc_impl::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>*>( ::grpc::Service::experimental().GetHandler(0)) ->SetMessageAllocator(allocator); } @@ -367,7 +368,7 @@ class ServiceA final { public: ExperimentalWithCallbackMethod_MethodA2() { ::grpc::Service::experimental().MarkMethodCallback(1, - new ::grpc::internal::CallbackClientStreamingHandler< ::grpc::testing::Request, ::grpc::testing::Response>( + new ::grpc_impl::internal::CallbackClientStreamingHandler< ::grpc::testing::Request, ::grpc::testing::Response>( [this] { return this->MethodA2(); })); } ~ExperimentalWithCallbackMethod_MethodA2() override { @@ -379,7 +380,7 @@ class ServiceA final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } virtual ::grpc::experimental::ServerReadReactor< ::grpc::testing::Request, ::grpc::testing::Response>* MethodA2() { - return new ::grpc::internal::UnimplementedReadReactor< + return new ::grpc_impl::internal::UnimplementedReadReactor< ::grpc::testing::Request, ::grpc::testing::Response>;} }; template @@ -389,7 +390,7 @@ class ServiceA final { public: ExperimentalWithCallbackMethod_MethodA3() { ::grpc::Service::experimental().MarkMethodCallback(2, - new ::grpc::internal::CallbackServerStreamingHandler< ::grpc::testing::Request, ::grpc::testing::Response>( + new ::grpc_impl::internal::CallbackServerStreamingHandler< ::grpc::testing::Request, ::grpc::testing::Response>( [this] { return this->MethodA3(); })); } ~ExperimentalWithCallbackMethod_MethodA3() override { @@ -401,7 +402,7 @@ class ServiceA final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } virtual ::grpc::experimental::ServerWriteReactor< ::grpc::testing::Request, ::grpc::testing::Response>* MethodA3() { - return new ::grpc::internal::UnimplementedWriteReactor< + return new ::grpc_impl::internal::UnimplementedWriteReactor< ::grpc::testing::Request, ::grpc::testing::Response>;} }; template @@ -411,7 +412,7 @@ class ServiceA final { public: ExperimentalWithCallbackMethod_MethodA4() { ::grpc::Service::experimental().MarkMethodCallback(3, - new ::grpc::internal::CallbackBidiHandler< ::grpc::testing::Request, ::grpc::testing::Response>( + new ::grpc_impl::internal::CallbackBidiHandler< ::grpc::testing::Request, ::grpc::testing::Response>( [this] { return this->MethodA4(); })); } ~ExperimentalWithCallbackMethod_MethodA4() override { @@ -423,7 +424,7 @@ class ServiceA final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } virtual ::grpc::experimental::ServerBidiReactor< ::grpc::testing::Request, ::grpc::testing::Response>* MethodA4() { - return new ::grpc::internal::UnimplementedBidiReactor< + return new ::grpc_impl::internal::UnimplementedBidiReactor< ::grpc::testing::Request, ::grpc::testing::Response>;} }; typedef ExperimentalWithCallbackMethod_MethodA1 > > > ExperimentalCallbackService; @@ -582,7 +583,7 @@ class ServiceA final { public: ExperimentalWithRawCallbackMethod_MethodA1() { ::grpc::Service::experimental().MarkMethodRawCallback(0, - new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( + new ::grpc_impl::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this](::grpc::ServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response, @@ -607,7 +608,7 @@ class ServiceA final { public: ExperimentalWithRawCallbackMethod_MethodA2() { ::grpc::Service::experimental().MarkMethodRawCallback(1, - new ::grpc::internal::CallbackClientStreamingHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( + new ::grpc_impl::internal::CallbackClientStreamingHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this] { return this->MethodA2(); })); } ~ExperimentalWithRawCallbackMethod_MethodA2() override { @@ -619,7 +620,7 @@ class ServiceA final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } virtual ::grpc::experimental::ServerReadReactor< ::grpc::ByteBuffer, ::grpc::ByteBuffer>* MethodA2() { - return new ::grpc::internal::UnimplementedReadReactor< + return new ::grpc_impl::internal::UnimplementedReadReactor< ::grpc::ByteBuffer, ::grpc::ByteBuffer>;} }; template @@ -629,7 +630,7 @@ class ServiceA final { public: ExperimentalWithRawCallbackMethod_MethodA3() { ::grpc::Service::experimental().MarkMethodRawCallback(2, - new ::grpc::internal::CallbackServerStreamingHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( + new ::grpc_impl::internal::CallbackServerStreamingHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this] { return this->MethodA3(); })); } ~ExperimentalWithRawCallbackMethod_MethodA3() override { @@ -641,7 +642,7 @@ class ServiceA final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } virtual ::grpc::experimental::ServerWriteReactor< ::grpc::ByteBuffer, ::grpc::ByteBuffer>* MethodA3() { - return new ::grpc::internal::UnimplementedWriteReactor< + return new ::grpc_impl::internal::UnimplementedWriteReactor< ::grpc::ByteBuffer, ::grpc::ByteBuffer>;} }; template @@ -651,7 +652,7 @@ class ServiceA final { public: ExperimentalWithRawCallbackMethod_MethodA4() { ::grpc::Service::experimental().MarkMethodRawCallback(3, - new ::grpc::internal::CallbackBidiHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( + new ::grpc_impl::internal::CallbackBidiHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this] { return this->MethodA4(); })); } ~ExperimentalWithRawCallbackMethod_MethodA4() override { @@ -663,7 +664,7 @@ class ServiceA final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } virtual ::grpc::experimental::ServerBidiReactor< ::grpc::ByteBuffer, ::grpc::ByteBuffer>* MethodA4() { - return new ::grpc::internal::UnimplementedBidiReactor< + return new ::grpc_impl::internal::UnimplementedBidiReactor< ::grpc::ByteBuffer, ::grpc::ByteBuffer>;} }; template @@ -814,7 +815,7 @@ class ServiceB final { public: ExperimentalWithCallbackMethod_MethodB1() { ::grpc::Service::experimental().MarkMethodCallback(0, - new ::grpc::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>( + new ::grpc_impl::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>( [this](::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, @@ -824,7 +825,7 @@ class ServiceB final { } void SetMessageAllocatorFor_MethodB1( ::grpc::experimental::MessageAllocator< ::grpc::testing::Request, ::grpc::testing::Response>* allocator) { - static_cast<::grpc::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>*>( + static_cast<::grpc_impl::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>*>( ::grpc::Service::experimental().GetHandler(0)) ->SetMessageAllocator(allocator); } @@ -883,7 +884,7 @@ class ServiceB final { public: ExperimentalWithRawCallbackMethod_MethodB1() { ::grpc::Service::experimental().MarkMethodRawCallback(0, - new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( + new ::grpc_impl::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this](::grpc::ServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response, diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 501be844410..bdb36ae1a7b 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -947,7 +947,9 @@ include/grpcpp/impl/channel_argument_option.h \ include/grpcpp/impl/client_unary_call.h \ include/grpcpp/impl/codegen/async_generic_service.h \ include/grpcpp/impl/codegen/async_stream.h \ +include/grpcpp/impl/codegen/async_stream_impl.h \ include/grpcpp/impl/codegen/async_unary_call.h \ +include/grpcpp/impl/codegen/async_unary_call_impl.h \ include/grpcpp/impl/codegen/byte_buffer.h \ include/grpcpp/impl/codegen/call.h \ include/grpcpp/impl/codegen/call_hook.h \ @@ -956,6 +958,7 @@ include/grpcpp/impl/codegen/call_op_set_interface.h \ include/grpcpp/impl/codegen/callback_common.h \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ +include/grpcpp/impl/codegen/client_callback_impl.h \ include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ @@ -983,6 +986,7 @@ include/grpcpp/impl/codegen/rpc_service_method.h \ include/grpcpp/impl/codegen/security/auth_context.h \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ +include/grpcpp/impl/codegen/server_callback_impl.h \ include/grpcpp/impl/codegen/server_context.h \ include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ @@ -995,6 +999,7 @@ include/grpcpp/impl/codegen/string_ref.h \ include/grpcpp/impl/codegen/stub_options.h \ include/grpcpp/impl/codegen/sync.h \ include/grpcpp/impl/codegen/sync_stream.h \ +include/grpcpp/impl/codegen/sync_stream_impl.h \ include/grpcpp/impl/codegen/time.h \ include/grpcpp/impl/grpc_library.h \ include/grpcpp/impl/method_handler_impl.h \ @@ -1024,11 +1029,14 @@ include/grpcpp/server_impl.h \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ include/grpcpp/support/async_stream.h \ +include/grpcpp/support/async_stream_impl.h \ include/grpcpp/support/async_unary_call.h \ +include/grpcpp/support/async_unary_call_impl.h \ include/grpcpp/support/byte_buffer.h \ include/grpcpp/support/channel_arguments.h \ include/grpcpp/support/channel_arguments_impl.h \ include/grpcpp/support/client_callback.h \ +include/grpcpp/support/client_callback_impl.h \ include/grpcpp/support/client_interceptor.h \ include/grpcpp/support/config.h \ include/grpcpp/support/interceptor.h \ @@ -1036,6 +1044,7 @@ include/grpcpp/support/message_allocator.h \ include/grpcpp/support/proto_buffer_reader.h \ include/grpcpp/support/proto_buffer_writer.h \ include/grpcpp/support/server_callback.h \ +include/grpcpp/support/server_callback_impl.h \ include/grpcpp/support/server_interceptor.h \ include/grpcpp/support/slice.h \ include/grpcpp/support/status.h \ @@ -1043,6 +1052,7 @@ include/grpcpp/support/status_code_enum.h \ include/grpcpp/support/string_ref.h \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ +include/grpcpp/support/sync_stream_impl.h \ include/grpcpp/support/time.h \ include/grpcpp/support/validate_service_config.h diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index f1dd2e54e1d..1abe2523b3c 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -948,7 +948,9 @@ include/grpcpp/impl/channel_argument_option.h \ include/grpcpp/impl/client_unary_call.h \ include/grpcpp/impl/codegen/async_generic_service.h \ include/grpcpp/impl/codegen/async_stream.h \ +include/grpcpp/impl/codegen/async_stream_impl.h \ include/grpcpp/impl/codegen/async_unary_call.h \ +include/grpcpp/impl/codegen/async_unary_call_impl.h \ include/grpcpp/impl/codegen/byte_buffer.h \ include/grpcpp/impl/codegen/call.h \ include/grpcpp/impl/codegen/call_hook.h \ @@ -957,6 +959,7 @@ include/grpcpp/impl/codegen/call_op_set_interface.h \ include/grpcpp/impl/codegen/callback_common.h \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ +include/grpcpp/impl/codegen/client_callback_impl.h \ include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ @@ -985,6 +988,7 @@ include/grpcpp/impl/codegen/rpc_service_method.h \ include/grpcpp/impl/codegen/security/auth_context.h \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ +include/grpcpp/impl/codegen/server_callback_impl.h \ include/grpcpp/impl/codegen/server_context.h \ include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ @@ -997,6 +1001,7 @@ include/grpcpp/impl/codegen/string_ref.h \ include/grpcpp/impl/codegen/stub_options.h \ include/grpcpp/impl/codegen/sync.h \ include/grpcpp/impl/codegen/sync_stream.h \ +include/grpcpp/impl/codegen/sync_stream_impl.h \ include/grpcpp/impl/codegen/time.h \ include/grpcpp/impl/grpc_library.h \ include/grpcpp/impl/method_handler_impl.h \ @@ -1026,11 +1031,14 @@ include/grpcpp/server_impl.h \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ include/grpcpp/support/async_stream.h \ +include/grpcpp/support/async_stream_impl.h \ include/grpcpp/support/async_unary_call.h \ +include/grpcpp/support/async_unary_call_impl.h \ include/grpcpp/support/byte_buffer.h \ include/grpcpp/support/channel_arguments.h \ include/grpcpp/support/channel_arguments_impl.h \ include/grpcpp/support/client_callback.h \ +include/grpcpp/support/client_callback_impl.h \ include/grpcpp/support/client_interceptor.h \ include/grpcpp/support/config.h \ include/grpcpp/support/interceptor.h \ @@ -1038,6 +1046,7 @@ include/grpcpp/support/message_allocator.h \ include/grpcpp/support/proto_buffer_reader.h \ include/grpcpp/support/proto_buffer_writer.h \ include/grpcpp/support/server_callback.h \ +include/grpcpp/support/server_callback_impl.h \ include/grpcpp/support/server_interceptor.h \ include/grpcpp/support/slice.h \ include/grpcpp/support/status.h \ @@ -1045,6 +1054,7 @@ include/grpcpp/support/status_code_enum.h \ include/grpcpp/support/string_ref.h \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ +include/grpcpp/support/sync_stream_impl.h \ include/grpcpp/support/time.h \ include/grpcpp/support/validate_service_config.h \ src/core/ext/filters/client_channel/health/health.pb.c \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index d263e4fed22..51cb18b0932 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -10170,7 +10170,9 @@ "include/grpc++/impl/codegen/time.h", "include/grpcpp/impl/codegen/async_generic_service.h", "include/grpcpp/impl/codegen/async_stream.h", + "include/grpcpp/impl/codegen/async_stream_impl.h", "include/grpcpp/impl/codegen/async_unary_call.h", + "include/grpcpp/impl/codegen/async_unary_call_impl.h", "include/grpcpp/impl/codegen/byte_buffer.h", "include/grpcpp/impl/codegen/call.h", "include/grpcpp/impl/codegen/call_hook.h", @@ -10179,6 +10181,7 @@ "include/grpcpp/impl/codegen/callback_common.h", "include/grpcpp/impl/codegen/channel_interface.h", "include/grpcpp/impl/codegen/client_callback.h", + "include/grpcpp/impl/codegen/client_callback_impl.h", "include/grpcpp/impl/codegen/client_context.h", "include/grpcpp/impl/codegen/client_context_impl.h", "include/grpcpp/impl/codegen/client_interceptor.h", @@ -10201,6 +10204,7 @@ "include/grpcpp/impl/codegen/security/auth_context.h", "include/grpcpp/impl/codegen/serialization_traits.h", "include/grpcpp/impl/codegen/server_callback.h", + "include/grpcpp/impl/codegen/server_callback_impl.h", "include/grpcpp/impl/codegen/server_context.h", "include/grpcpp/impl/codegen/server_context_impl.h", "include/grpcpp/impl/codegen/server_interceptor.h", @@ -10212,6 +10216,7 @@ "include/grpcpp/impl/codegen/string_ref.h", "include/grpcpp/impl/codegen/stub_options.h", "include/grpcpp/impl/codegen/sync_stream.h", + "include/grpcpp/impl/codegen/sync_stream_impl.h", "include/grpcpp/impl/codegen/time.h" ], "is_filegroup": true, @@ -10250,7 +10255,9 @@ "include/grpc++/impl/codegen/time.h", "include/grpcpp/impl/codegen/async_generic_service.h", "include/grpcpp/impl/codegen/async_stream.h", + "include/grpcpp/impl/codegen/async_stream_impl.h", "include/grpcpp/impl/codegen/async_unary_call.h", + "include/grpcpp/impl/codegen/async_unary_call_impl.h", "include/grpcpp/impl/codegen/byte_buffer.h", "include/grpcpp/impl/codegen/call.h", "include/grpcpp/impl/codegen/call_hook.h", @@ -10259,6 +10266,7 @@ "include/grpcpp/impl/codegen/callback_common.h", "include/grpcpp/impl/codegen/channel_interface.h", "include/grpcpp/impl/codegen/client_callback.h", + "include/grpcpp/impl/codegen/client_callback_impl.h", "include/grpcpp/impl/codegen/client_context.h", "include/grpcpp/impl/codegen/client_context_impl.h", "include/grpcpp/impl/codegen/client_interceptor.h", @@ -10281,6 +10289,7 @@ "include/grpcpp/impl/codegen/security/auth_context.h", "include/grpcpp/impl/codegen/serialization_traits.h", "include/grpcpp/impl/codegen/server_callback.h", + "include/grpcpp/impl/codegen/server_callback_impl.h", "include/grpcpp/impl/codegen/server_context.h", "include/grpcpp/impl/codegen/server_context_impl.h", "include/grpcpp/impl/codegen/server_interceptor.h", @@ -10292,6 +10301,7 @@ "include/grpcpp/impl/codegen/string_ref.h", "include/grpcpp/impl/codegen/stub_options.h", "include/grpcpp/impl/codegen/sync_stream.h", + "include/grpcpp/impl/codegen/sync_stream_impl.h", "include/grpcpp/impl/codegen/time.h" ], "third_party": false, @@ -10441,11 +10451,14 @@ "include/grpcpp/server_posix.h", "include/grpcpp/server_posix_impl.h", "include/grpcpp/support/async_stream.h", + "include/grpcpp/support/async_stream_impl.h", "include/grpcpp/support/async_unary_call.h", + "include/grpcpp/support/async_unary_call_impl.h", "include/grpcpp/support/byte_buffer.h", "include/grpcpp/support/channel_arguments.h", "include/grpcpp/support/channel_arguments_impl.h", "include/grpcpp/support/client_callback.h", + "include/grpcpp/support/client_callback_impl.h", "include/grpcpp/support/client_interceptor.h", "include/grpcpp/support/config.h", "include/grpcpp/support/interceptor.h", @@ -10453,6 +10466,7 @@ "include/grpcpp/support/proto_buffer_reader.h", "include/grpcpp/support/proto_buffer_writer.h", "include/grpcpp/support/server_callback.h", + "include/grpcpp/support/server_callback_impl.h", "include/grpcpp/support/server_interceptor.h", "include/grpcpp/support/slice.h", "include/grpcpp/support/status.h", @@ -10460,6 +10474,7 @@ "include/grpcpp/support/string_ref.h", "include/grpcpp/support/stub_options.h", "include/grpcpp/support/sync_stream.h", + "include/grpcpp/support/sync_stream_impl.h", "include/grpcpp/support/time.h", "include/grpcpp/support/validate_service_config.h", "src/cpp/client/create_channel_internal.h", @@ -10569,11 +10584,14 @@ "include/grpcpp/server_posix.h", "include/grpcpp/server_posix_impl.h", "include/grpcpp/support/async_stream.h", + "include/grpcpp/support/async_stream_impl.h", "include/grpcpp/support/async_unary_call.h", + "include/grpcpp/support/async_unary_call_impl.h", "include/grpcpp/support/byte_buffer.h", "include/grpcpp/support/channel_arguments.h", "include/grpcpp/support/channel_arguments_impl.h", "include/grpcpp/support/client_callback.h", + "include/grpcpp/support/client_callback_impl.h", "include/grpcpp/support/client_interceptor.h", "include/grpcpp/support/config.h", "include/grpcpp/support/interceptor.h", @@ -10581,6 +10599,7 @@ "include/grpcpp/support/proto_buffer_reader.h", "include/grpcpp/support/proto_buffer_writer.h", "include/grpcpp/support/server_callback.h", + "include/grpcpp/support/server_callback_impl.h", "include/grpcpp/support/server_interceptor.h", "include/grpcpp/support/slice.h", "include/grpcpp/support/status.h", @@ -10588,6 +10607,7 @@ "include/grpcpp/support/string_ref.h", "include/grpcpp/support/stub_options.h", "include/grpcpp/support/sync_stream.h", + "include/grpcpp/support/sync_stream_impl.h", "include/grpcpp/support/time.h", "include/grpcpp/support/validate_service_config.h", "src/cpp/client/channel_cc.cc", From 420d5413c7d9816df16cf24018c1f8b8dc2e8d09 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 1 Jul 2019 10:50:47 -0700 Subject: [PATCH 0760/1555] Use the actual formula --- src/core/lib/iomgr/tcp_posix.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index 0a2ef767598..606e033a21e 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -435,9 +435,9 @@ static void tcp_do_read(grpc_tcp* tcp) { GPR_TIMER_SCOPE("tcp_do_read", 0); struct msghdr msg; struct iovec iov[MAX_READ_IOVEC]; - char cmsgbuf - [128 /*CMSG_SPACE(sizeof(grpc_core::scm_timestamping)) + CMSG_SPACE(sizeof(int))*/ - ]; + constexpr size_t cmsg_alloc_space = + CMSG_SPACE(sizeof(grpc_core::scm_timestamping)) + CMSG_SPACE(sizeof(int)); + char cmsgbuf[cmsg_alloc_space]; ssize_t read_bytes; size_t total_read_bytes = 0; From f44e0c07a709c81211fb32d5010906a8451f63ca Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 1 Jul 2019 10:55:11 -0700 Subject: [PATCH 0761/1555] Reviewer comments --- src/core/lib/iomgr/tcp_posix.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index 606e033a21e..031f681baa3 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -526,6 +526,7 @@ static void tcp_do_read(grpc_tcp* tcp) { if (cmsg->cmsg_level == SOL_TCP && cmsg->cmsg_type == TCP_CM_INQ && cmsg->cmsg_len == CMSG_LEN(sizeof(int))) { tcp->inq = *reinterpret_cast(CMSG_DATA(cmsg)); + break; } } } From 7cb861ce294edae5d40e8ea0c597687e989eec17 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 1 Jul 2019 11:00:55 -0700 Subject: [PATCH 0762/1555] Reviewer comments --- src/core/lib/iomgr/tcp_posix.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index 031f681baa3..79c56d5f3df 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -437,12 +437,12 @@ static void tcp_do_read(grpc_tcp* tcp) { struct iovec iov[MAX_READ_IOVEC]; constexpr size_t cmsg_alloc_space = CMSG_SPACE(sizeof(grpc_core::scm_timestamping)) + CMSG_SPACE(sizeof(int)); - char cmsgbuf[cmsg_alloc_space]; ssize_t read_bytes; size_t total_read_bytes = 0; - size_t iov_len = std::min(MAX_READ_IOVEC, tcp->incoming_buffer->count); + char cmsgbuf[cmsg_alloc_space]; + for (size_t i = 0; i < iov_len; i++) { iov[i].iov_base = GRPC_SLICE_START_PTR(tcp->incoming_buffer->slices[i]); iov[i].iov_len = GRPC_SLICE_LENGTH(tcp->incoming_buffer->slices[i]); From a94e00dccf732e19ec33e22ca184a99d44ace042 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 1 Jul 2019 11:15:40 -0700 Subject: [PATCH 0763/1555] Reviewer comments --- src/core/lib/iomgr/tcp_posix.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index 79c56d5f3df..94a9da2ee49 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -435,14 +435,13 @@ static void tcp_do_read(grpc_tcp* tcp) { GPR_TIMER_SCOPE("tcp_do_read", 0); struct msghdr msg; struct iovec iov[MAX_READ_IOVEC]; - constexpr size_t cmsg_alloc_space = - CMSG_SPACE(sizeof(grpc_core::scm_timestamping)) + CMSG_SPACE(sizeof(int)); ssize_t read_bytes; size_t total_read_bytes = 0; size_t iov_len = std::min(MAX_READ_IOVEC, tcp->incoming_buffer->count); + constexpr size_t cmsg_alloc_space = + CMSG_SPACE(sizeof(grpc_core::scm_timestamping)) + CMSG_SPACE(sizeof(int)); char cmsgbuf[cmsg_alloc_space]; - for (size_t i = 0; i < iov_len; i++) { iov[i].iov_base = GRPC_SLICE_START_PTR(tcp->incoming_buffer->slices[i]); iov[i].iov_len = GRPC_SLICE_LENGTH(tcp->incoming_buffer->slices[i]); From 02ff96bd31f33a0c193f0766d87bb57ba438b2ef Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 1 Jul 2019 11:46:52 -0700 Subject: [PATCH 0764/1555] No need to allocate space for receive timestamp if errqueue is not present --- src/core/lib/iomgr/tcp_posix.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index 94a9da2ee49..0e153679ad7 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -439,8 +439,12 @@ static void tcp_do_read(grpc_tcp* tcp) { size_t total_read_bytes = 0; size_t iov_len = std::min(MAX_READ_IOVEC, tcp->incoming_buffer->count); +#ifdef GRPC_LINUX_ERRQUEUE constexpr size_t cmsg_alloc_space = CMSG_SPACE(sizeof(grpc_core::scm_timestamping)) + CMSG_SPACE(sizeof(int)); +#else + constexpr size_t cmsg_alloc_space = CMSG_SPACE(sizeof(int)); +#endif /* GRPC_LINUX_ERRQUEUE */ char cmsgbuf[cmsg_alloc_space]; for (size_t i = 0; i < iov_len; i++) { iov[i].iov_base = GRPC_SLICE_START_PTR(tcp->incoming_buffer->slices[i]); From 416d9434a864f751ad9db67cbec6236a3bbc7b5a Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Mon, 1 Jul 2019 13:38:11 -0700 Subject: [PATCH 0765/1555] Modify BUILD for threadpool --- BUILD | 2 ++ 1 file changed, 2 insertions(+) diff --git a/BUILD b/BUILD index b2867e150b5..5faf39e7cde 100644 --- a/BUILD +++ b/BUILD @@ -785,6 +785,7 @@ grpc_cc_library( "src/core/lib/iomgr/exec_ctx.cc", "src/core/lib/iomgr/executor.cc", "src/core/lib/iomgr/executor/mpmcqueue.cc", + "src/core/lib/iomgr/executor/threadpool.cc", "src/core/lib/iomgr/fork_posix.cc", "src/core/lib/iomgr/fork_windows.cc", "src/core/lib/iomgr/gethostname_fallback.cc", @@ -943,6 +944,7 @@ grpc_cc_library( "src/core/lib/iomgr/exec_ctx.h", "src/core/lib/iomgr/executor.h", "src/core/lib/iomgr/executor/mpmcqueue.h", + "src/core/lib/iomgr/executor/threadpool.h", "src/core/lib/iomgr/gethostname.h", "src/core/lib/iomgr/gevent_util.h", "src/core/lib/iomgr/grpc_if_nametoindex.h", From 410451c126e970513a90827503775b3417a7939a Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Mon, 1 Jul 2019 14:02:58 -0700 Subject: [PATCH 0766/1555] Add threadpool implementation --- BUILD.gn | 3 + CMakeLists.txt | 41 ++++ Makefile | 42 +++++ build.yaml | 12 ++ config.m4 | 1 + config.w32 | 1 + gRPC-C++.podspec | 2 + gRPC-Core.podspec | 3 + grpc.gemspec | 2 + grpc.gyp | 4 + package.xml | 2 + src/core/lib/iomgr/executor/mpmcqueue.cc | 18 ++ src/core/lib/iomgr/executor/mpmcqueue.h | 5 + src/core/lib/iomgr/executor/threadpool.cc | 136 +++++++++++++ src/core/lib/iomgr/executor/threadpool.h | 153 +++++++++++++++ src/python/grpcio/grpc_core_dependencies.py | 1 + test/core/iomgr/BUILD | 11 ++ test/core/iomgr/threadpool_test.cc | 178 ++++++++++++++++++ tools/doxygen/Doxyfile.c++.internal | 1 + tools/doxygen/Doxyfile.core.internal | 2 + .../generated/sources_and_headers.json | 19 ++ tools/run_tests/generated/tests.json | 24 +++ 22 files changed, 661 insertions(+) create mode 100644 src/core/lib/iomgr/executor/threadpool.cc create mode 100644 src/core/lib/iomgr/executor/threadpool.h create mode 100644 test/core/iomgr/threadpool_test.cc diff --git a/BUILD.gn b/BUILD.gn index 6b6a0f5c392..9d9d53f7ba5 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -527,6 +527,8 @@ config("grpc_config") { "src/core/lib/iomgr/executor.h", "src/core/lib/iomgr/executor/mpmcqueue.cc", "src/core/lib/iomgr/executor/mpmcqueue.h", + "src/core/lib/iomgr/executor/threadpool.cc", + "src/core/lib/iomgr/executor/threadpool.h", "src/core/lib/iomgr/fork_posix.cc", "src/core/lib/iomgr/fork_windows.cc", "src/core/lib/iomgr/gethostname.h", @@ -1232,6 +1234,7 @@ config("grpc_config") { "src/core/lib/iomgr/exec_ctx.h", "src/core/lib/iomgr/executor.h", "src/core/lib/iomgr/executor/mpmcqueue.h", + "src/core/lib/iomgr/executor/threadpool.h", "src/core/lib/iomgr/gethostname.h", "src/core/lib/iomgr/grpc_if_nametoindex.h", "src/core/lib/iomgr/internal_errqueue.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a914be54b3..93d9fe3a163 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -428,6 +428,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_c tcp_server_posix_test) endif() add_dependencies(buildtests_c tcp_server_uv_test) +add_dependencies(buildtests_c threadpool_test) add_dependencies(buildtests_c time_averaged_stats_test) add_dependencies(buildtests_c timeout_encoding_test) add_dependencies(buildtests_c timer_heap_test) @@ -1032,6 +1033,7 @@ add_library(grpc src/core/lib/iomgr/exec_ctx.cc src/core/lib/iomgr/executor.cc src/core/lib/iomgr/executor/mpmcqueue.cc + src/core/lib/iomgr/executor/threadpool.cc src/core/lib/iomgr/fork_posix.cc src/core/lib/iomgr/fork_windows.cc src/core/lib/iomgr/gethostname_fallback.cc @@ -1471,6 +1473,7 @@ add_library(grpc_cronet src/core/lib/iomgr/exec_ctx.cc src/core/lib/iomgr/executor.cc src/core/lib/iomgr/executor/mpmcqueue.cc + src/core/lib/iomgr/executor/threadpool.cc src/core/lib/iomgr/fork_posix.cc src/core/lib/iomgr/fork_windows.cc src/core/lib/iomgr/gethostname_fallback.cc @@ -1892,6 +1895,7 @@ add_library(grpc_test_util src/core/lib/iomgr/exec_ctx.cc src/core/lib/iomgr/executor.cc src/core/lib/iomgr/executor/mpmcqueue.cc + src/core/lib/iomgr/executor/threadpool.cc src/core/lib/iomgr/fork_posix.cc src/core/lib/iomgr/fork_windows.cc src/core/lib/iomgr/gethostname_fallback.cc @@ -2226,6 +2230,7 @@ add_library(grpc_test_util_unsecure src/core/lib/iomgr/exec_ctx.cc src/core/lib/iomgr/executor.cc src/core/lib/iomgr/executor/mpmcqueue.cc + src/core/lib/iomgr/executor/threadpool.cc src/core/lib/iomgr/fork_posix.cc src/core/lib/iomgr/fork_windows.cc src/core/lib/iomgr/gethostname_fallback.cc @@ -2536,6 +2541,7 @@ add_library(grpc_unsecure src/core/lib/iomgr/exec_ctx.cc src/core/lib/iomgr/executor.cc src/core/lib/iomgr/executor/mpmcqueue.cc + src/core/lib/iomgr/executor/threadpool.cc src/core/lib/iomgr/fork_posix.cc src/core/lib/iomgr/fork_windows.cc src/core/lib/iomgr/gethostname_fallback.cc @@ -3567,6 +3573,7 @@ add_library(grpc++_cronet src/core/lib/iomgr/exec_ctx.cc src/core/lib/iomgr/executor.cc src/core/lib/iomgr/executor/mpmcqueue.cc + src/core/lib/iomgr/executor/threadpool.cc src/core/lib/iomgr/fork_posix.cc src/core/lib/iomgr/fork_windows.cc src/core/lib/iomgr/gethostname_fallback.cc @@ -10508,6 +10515,40 @@ target_link_libraries(tcp_server_uv_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) +add_executable(threadpool_test + test/core/iomgr/threadpool_test.cc +) + + +target_include_directories(threadpool_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} +) + +target_link_libraries(threadpool_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + grpc + gpr +) + + # avoid dependency on libstdc++ + if (_gRPC_CORE_NOSTDCXX_FLAGS) + set_target_properties(threadpool_test PROPERTIES LINKER_LANGUAGE C) + target_compile_options(threadpool_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) + endif() + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + add_executable(time_averaged_stats_test test/core/iomgr/time_averaged_stats_test.cc ) diff --git a/Makefile b/Makefile index fb43e7bb0b3..32b695c24ec 100644 --- a/Makefile +++ b/Makefile @@ -1133,6 +1133,7 @@ tcp_client_uv_test: $(BINDIR)/$(CONFIG)/tcp_client_uv_test tcp_posix_test: $(BINDIR)/$(CONFIG)/tcp_posix_test tcp_server_posix_test: $(BINDIR)/$(CONFIG)/tcp_server_posix_test tcp_server_uv_test: $(BINDIR)/$(CONFIG)/tcp_server_uv_test +threadpool_test: $(BINDIR)/$(CONFIG)/threadpool_test time_averaged_stats_test: $(BINDIR)/$(CONFIG)/time_averaged_stats_test timeout_encoding_test: $(BINDIR)/$(CONFIG)/timeout_encoding_test timer_heap_test: $(BINDIR)/$(CONFIG)/timer_heap_test @@ -1553,6 +1554,7 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/tcp_posix_test \ $(BINDIR)/$(CONFIG)/tcp_server_posix_test \ $(BINDIR)/$(CONFIG)/tcp_server_uv_test \ + $(BINDIR)/$(CONFIG)/threadpool_test \ $(BINDIR)/$(CONFIG)/time_averaged_stats_test \ $(BINDIR)/$(CONFIG)/timeout_encoding_test \ $(BINDIR)/$(CONFIG)/timer_heap_test \ @@ -2185,6 +2187,8 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/tcp_server_posix_test || ( echo test tcp_server_posix_test failed ; exit 1 ) $(E) "[RUN] Testing tcp_server_uv_test" $(Q) $(BINDIR)/$(CONFIG)/tcp_server_uv_test || ( echo test tcp_server_uv_test failed ; exit 1 ) + $(E) "[RUN] Testing threadpool_test" + $(Q) $(BINDIR)/$(CONFIG)/threadpool_test || ( echo test threadpool_test failed ; exit 1 ) $(E) "[RUN] Testing time_averaged_stats_test" $(Q) $(BINDIR)/$(CONFIG)/time_averaged_stats_test || ( echo test time_averaged_stats_test failed ; exit 1 ) $(E) "[RUN] Testing timeout_encoding_test" @@ -3540,6 +3544,7 @@ LIBGRPC_SRC = \ src/core/lib/iomgr/exec_ctx.cc \ src/core/lib/iomgr/executor.cc \ src/core/lib/iomgr/executor/mpmcqueue.cc \ + src/core/lib/iomgr/executor/threadpool.cc \ src/core/lib/iomgr/fork_posix.cc \ src/core/lib/iomgr/fork_windows.cc \ src/core/lib/iomgr/gethostname_fallback.cc \ @@ -3970,6 +3975,7 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/iomgr/exec_ctx.cc \ src/core/lib/iomgr/executor.cc \ src/core/lib/iomgr/executor/mpmcqueue.cc \ + src/core/lib/iomgr/executor/threadpool.cc \ src/core/lib/iomgr/fork_posix.cc \ src/core/lib/iomgr/fork_windows.cc \ src/core/lib/iomgr/gethostname_fallback.cc \ @@ -4381,6 +4387,7 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/iomgr/exec_ctx.cc \ src/core/lib/iomgr/executor.cc \ src/core/lib/iomgr/executor/mpmcqueue.cc \ + src/core/lib/iomgr/executor/threadpool.cc \ src/core/lib/iomgr/fork_posix.cc \ src/core/lib/iomgr/fork_windows.cc \ src/core/lib/iomgr/gethostname_fallback.cc \ @@ -4699,6 +4706,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/lib/iomgr/exec_ctx.cc \ src/core/lib/iomgr/executor.cc \ src/core/lib/iomgr/executor/mpmcqueue.cc \ + src/core/lib/iomgr/executor/threadpool.cc \ src/core/lib/iomgr/fork_posix.cc \ src/core/lib/iomgr/fork_windows.cc \ src/core/lib/iomgr/gethostname_fallback.cc \ @@ -4980,6 +4988,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/iomgr/exec_ctx.cc \ src/core/lib/iomgr/executor.cc \ src/core/lib/iomgr/executor/mpmcqueue.cc \ + src/core/lib/iomgr/executor/threadpool.cc \ src/core/lib/iomgr/fork_posix.cc \ src/core/lib/iomgr/fork_windows.cc \ src/core/lib/iomgr/gethostname_fallback.cc \ @@ -5981,6 +5990,7 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/iomgr/exec_ctx.cc \ src/core/lib/iomgr/executor.cc \ src/core/lib/iomgr/executor/mpmcqueue.cc \ + src/core/lib/iomgr/executor/threadpool.cc \ src/core/lib/iomgr/fork_posix.cc \ src/core/lib/iomgr/fork_windows.cc \ src/core/lib/iomgr/gethostname_fallback.cc \ @@ -13426,6 +13436,38 @@ endif endif +THREADPOOL_TEST_SRC = \ + test/core/iomgr/threadpool_test.cc \ + +THREADPOOL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(THREADPOOL_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/threadpool_test: openssl_dep_error + +else + + + +$(BINDIR)/$(CONFIG)/threadpool_test: $(THREADPOOL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LD) $(LDFLAGS) $(THREADPOOL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/threadpool_test + +endif + +$(OBJDIR)/$(CONFIG)/test/core/iomgr/threadpool_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_threadpool_test: $(THREADPOOL_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(THREADPOOL_TEST_OBJS:.o=.dep) +endif +endif + + TIME_AVERAGED_STATS_TEST_SRC = \ test/core/iomgr/time_averaged_stats_test.cc \ diff --git a/build.yaml b/build.yaml index 1b32902c6e7..4faddbc648a 100644 --- a/build.yaml +++ b/build.yaml @@ -281,6 +281,7 @@ filegroups: - src/core/lib/iomgr/exec_ctx.cc - src/core/lib/iomgr/executor.cc - src/core/lib/iomgr/executor/mpmcqueue.cc + - src/core/lib/iomgr/executor/threadpool.cc - src/core/lib/iomgr/fork_posix.cc - src/core/lib/iomgr/fork_windows.cc - src/core/lib/iomgr/gethostname_fallback.cc @@ -469,6 +470,7 @@ filegroups: - src/core/lib/iomgr/exec_ctx.h - src/core/lib/iomgr/executor.h - src/core/lib/iomgr/executor/mpmcqueue.h + - src/core/lib/iomgr/executor/threadpool.h - src/core/lib/iomgr/gethostname.h - src/core/lib/iomgr/grpc_if_nametoindex.h - src/core/lib/iomgr/internal_errqueue.h @@ -3733,6 +3735,16 @@ targets: - gpr exclude_iomgrs: - native +- name: threadpool_test + build: test + language: c + src: + - test/core/iomgr/threadpool_test.cc + deps: + - grpc_test_util + - grpc + - gpr + uses_polling: false - name: time_averaged_stats_test build: test language: c diff --git a/config.m4 b/config.m4 index 1791a3ca27b..50b789bb7bb 100644 --- a/config.m4 +++ b/config.m4 @@ -128,6 +128,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/iomgr/exec_ctx.cc \ src/core/lib/iomgr/executor.cc \ src/core/lib/iomgr/executor/mpmcqueue.cc \ + src/core/lib/iomgr/executor/threadpool.cc \ src/core/lib/iomgr/fork_posix.cc \ src/core/lib/iomgr/fork_windows.cc \ src/core/lib/iomgr/gethostname_fallback.cc \ diff --git a/config.w32 b/config.w32 index ddb5a39bc6c..7048f83facf 100644 --- a/config.w32 +++ b/config.w32 @@ -103,6 +103,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\iomgr\\exec_ctx.cc " + "src\\core\\lib\\iomgr\\executor.cc " + "src\\core\\lib\\iomgr\\executor\\mpmcqueue.cc " + + "src\\core\\lib\\iomgr\\executor\\threadpool.cc " + "src\\core\\lib\\iomgr\\fork_posix.cc " + "src\\core\\lib\\iomgr\\fork_windows.cc " + "src\\core\\lib\\iomgr\\gethostname_fallback.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 14492edd0e6..fc13e792240 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -469,6 +469,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/exec_ctx.h', 'src/core/lib/iomgr/executor.h', 'src/core/lib/iomgr/executor/mpmcqueue.h', + 'src/core/lib/iomgr/executor/threadpool.h', 'src/core/lib/iomgr/gethostname.h', 'src/core/lib/iomgr/grpc_if_nametoindex.h', 'src/core/lib/iomgr/internal_errqueue.h', @@ -675,6 +676,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/exec_ctx.h', 'src/core/lib/iomgr/executor.h', 'src/core/lib/iomgr/executor/mpmcqueue.h', + 'src/core/lib/iomgr/executor/threadpool.h', 'src/core/lib/iomgr/gethostname.h', 'src/core/lib/iomgr/grpc_if_nametoindex.h', 'src/core/lib/iomgr/internal_errqueue.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 340c7b4b66b..44f94171ed5 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -438,6 +438,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/exec_ctx.h', 'src/core/lib/iomgr/executor.h', 'src/core/lib/iomgr/executor/mpmcqueue.h', + 'src/core/lib/iomgr/executor/threadpool.h', 'src/core/lib/iomgr/gethostname.h', 'src/core/lib/iomgr/grpc_if_nametoindex.h', 'src/core/lib/iomgr/internal_errqueue.h', @@ -592,6 +593,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/exec_ctx.cc', 'src/core/lib/iomgr/executor.cc', 'src/core/lib/iomgr/executor/mpmcqueue.cc', + 'src/core/lib/iomgr/executor/threadpool.cc', 'src/core/lib/iomgr/fork_posix.cc', 'src/core/lib/iomgr/fork_windows.cc', 'src/core/lib/iomgr/gethostname_fallback.cc', @@ -1094,6 +1096,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/exec_ctx.h', 'src/core/lib/iomgr/executor.h', 'src/core/lib/iomgr/executor/mpmcqueue.h', + 'src/core/lib/iomgr/executor/threadpool.h', 'src/core/lib/iomgr/gethostname.h', 'src/core/lib/iomgr/grpc_if_nametoindex.h', 'src/core/lib/iomgr/internal_errqueue.h', diff --git a/grpc.gemspec b/grpc.gemspec index 0249e0a1fcd..1f4cf237ada 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -372,6 +372,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/iomgr/exec_ctx.h ) s.files += %w( src/core/lib/iomgr/executor.h ) s.files += %w( src/core/lib/iomgr/executor/mpmcqueue.h ) + s.files += %w( src/core/lib/iomgr/executor/threadpool.h ) s.files += %w( src/core/lib/iomgr/gethostname.h ) s.files += %w( src/core/lib/iomgr/grpc_if_nametoindex.h ) s.files += %w( src/core/lib/iomgr/internal_errqueue.h ) @@ -526,6 +527,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/iomgr/exec_ctx.cc ) s.files += %w( src/core/lib/iomgr/executor.cc ) s.files += %w( src/core/lib/iomgr/executor/mpmcqueue.cc ) + s.files += %w( src/core/lib/iomgr/executor/threadpool.cc ) s.files += %w( src/core/lib/iomgr/fork_posix.cc ) s.files += %w( src/core/lib/iomgr/fork_windows.cc ) s.files += %w( src/core/lib/iomgr/gethostname_fallback.cc ) diff --git a/grpc.gyp b/grpc.gyp index 0bd5be75f00..5eeab74d4c7 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -310,6 +310,7 @@ 'src/core/lib/iomgr/exec_ctx.cc', 'src/core/lib/iomgr/executor.cc', 'src/core/lib/iomgr/executor/mpmcqueue.cc', + 'src/core/lib/iomgr/executor/threadpool.cc', 'src/core/lib/iomgr/fork_posix.cc', 'src/core/lib/iomgr/fork_windows.cc', 'src/core/lib/iomgr/gethostname_fallback.cc', @@ -687,6 +688,7 @@ 'src/core/lib/iomgr/exec_ctx.cc', 'src/core/lib/iomgr/executor.cc', 'src/core/lib/iomgr/executor/mpmcqueue.cc', + 'src/core/lib/iomgr/executor/threadpool.cc', 'src/core/lib/iomgr/fork_posix.cc', 'src/core/lib/iomgr/fork_windows.cc', 'src/core/lib/iomgr/gethostname_fallback.cc', @@ -938,6 +940,7 @@ 'src/core/lib/iomgr/exec_ctx.cc', 'src/core/lib/iomgr/executor.cc', 'src/core/lib/iomgr/executor/mpmcqueue.cc', + 'src/core/lib/iomgr/executor/threadpool.cc', 'src/core/lib/iomgr/fork_posix.cc', 'src/core/lib/iomgr/fork_windows.cc', 'src/core/lib/iomgr/gethostname_fallback.cc', @@ -1165,6 +1168,7 @@ 'src/core/lib/iomgr/exec_ctx.cc', 'src/core/lib/iomgr/executor.cc', 'src/core/lib/iomgr/executor/mpmcqueue.cc', + 'src/core/lib/iomgr/executor/threadpool.cc', 'src/core/lib/iomgr/fork_posix.cc', 'src/core/lib/iomgr/fork_windows.cc', 'src/core/lib/iomgr/gethostname_fallback.cc', diff --git a/package.xml b/package.xml index 4467a11aae4..584c6510a60 100644 --- a/package.xml +++ b/package.xml @@ -377,6 +377,7 @@ + @@ -531,6 +532,7 @@ + diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index 97429ec30c7..b1d54bdcf88 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -111,4 +111,22 @@ void* InfLenFIFOQueue::Get() { return PopFront(); } +void* InfLenFIFOQueue::Get(gpr_timespec* wait_time) { + MutexLock l(&mu_); + + if (count_.Load(MemoryOrder::RELAXED) == 0) { + gpr_timespec start_time; + start_time = gpr_now(GPR_CLOCK_MONOTONIC); + + num_waiters_++; + do { + wait_nonempty_.Wait(&mu_); + } while (count_.Load(MemoryOrder::RELAXED) == 0); + num_waiters_--; + *wait_time = gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), start_time); + } + GPR_DEBUG_ASSERT(count_.Load(MemoryOrder::RELAXED) > 0); + return PopFront(); +} + } // namespace grpc_core diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index 8ece95699c7..fdb3de00e73 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -67,6 +67,11 @@ class InfLenFIFOQueue : public MPMCQueueInterface { // This routine will cause the thread to block if queue is currently empty. void* Get(); + // Same as Get(), but will record how long waited when getting. + // This routine should be only called when debug trace is on and wants to + // collect stats data. + void* Get(gpr_timespec* wait_time); + // Returns number of elements in queue currently. // There might be concurrently add/remove on queue, so count might change // quickly. diff --git a/src/core/lib/iomgr/executor/threadpool.cc b/src/core/lib/iomgr/executor/threadpool.cc new file mode 100644 index 00000000000..82b1724c23a --- /dev/null +++ b/src/core/lib/iomgr/executor/threadpool.cc @@ -0,0 +1,136 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/iomgr/executor/threadpool.h" + +namespace grpc_core { + +void ThreadPoolWorker::Run() { + while (true) { + void* elem; + + if (GRPC_TRACE_FLAG_ENABLED(grpc_thread_pool_trace)) { + // Updates stats and print + gpr_timespec wait_time = gpr_time_0(GPR_TIMESPAN); + elem = static_cast(queue_)->Get(&wait_time); + stats_.sleep_cycles = gpr_time_add(stats_.sleep_cycles, wait_time); + gpr_log(GPR_INFO, + "ThreadPool Worker [%s %d] Stats: sleep_cycles %f", + thd_name_, index_, gpr_timespec_to_micros(stats_.sleep_cycles)); + } else { + elem = static_cast(queue_)->Get(); + } + if (elem == nullptr) { + break; + } + // Runs closure + grpc_experimental_completion_queue_functor* closure = + static_cast(elem); + closure->functor_run(closure->internal_next, closure->internal_success); + } +} + +void ThreadPool::SharedThreadPoolConstructor() { + // All worker threads in thread pool must be joinable. + thread_options_.set_joinable(true); + + queue_ = New(); + threads_ = static_cast( + gpr_zalloc(num_threads_ * sizeof(ThreadPoolWorker*))); + for (int i = 0; i < num_threads_; ++i) { + threads_[i] = + New(thd_name_, this, queue_, thread_options_, i); + threads_[i]->Start(); + } +} + +size_t ThreadPool::DefaultStackSize() { +#if defined(__ANDROID__) || defined(__APPLE__) + return 1952 * 1024; +#else + return 64 * 1024; +#endif +} + +bool ThreadPool::HasBeenShutDown() { + return shut_down_.Load(MemoryOrder::ACQUIRE); +} + +ThreadPool::ThreadPool(int num_threads) : num_threads_(num_threads) { + thd_name_ = "ThreadPoolWorker"; + thread_options_ = Thread::Options(); + thread_options_.set_stack_size(DefaultStackSize()); + SharedThreadPoolConstructor(); +} + +ThreadPool::ThreadPool(int num_threads, const char* thd_name) + : num_threads_(num_threads), thd_name_(thd_name) { + thread_options_ = Thread::Options(); + thread_options_.set_stack_size(DefaultStackSize()); + SharedThreadPoolConstructor(); +} + +ThreadPool::ThreadPool(int num_threads, const char* thd_name, + const Thread::Options& thread_options) + : num_threads_(num_threads), + thd_name_(thd_name), + thread_options_(thread_options) { + if (thread_options_.stack_size() == 0) { + thread_options_.set_stack_size(DefaultStackSize()); + } + SharedThreadPoolConstructor(); +} + +ThreadPool::~ThreadPool() { + shut_down_.Store(false, MemoryOrder::RELEASE); + + for (int i = 0; i < num_threads_; ++i) { + queue_->Put(nullptr); + } + + for (int i = 0; i < num_threads_; ++i) { + threads_[i]->Join(); + } + + for (int i = 0; i < num_threads_; ++i) { + Delete(threads_[i]); + } + gpr_free(threads_); + Delete(queue_); +} + +void ThreadPool::Add(grpc_experimental_completion_queue_functor* closure) { + if (HasBeenShutDown()) { + gpr_log(GPR_ERROR, "ThreadPool Has Already Been Shut Down."); + } else { + queue_->Put(static_cast(closure)); + } +} + +int ThreadPool::num_pending_closures() const { return queue_->count(); } + +int ThreadPool::pool_capacity() const { return num_threads_; } + +const Thread::Options& ThreadPool::thread_options() const { + return thread_options_; +} + +const char* ThreadPool::thread_name() const { return thd_name_; } +} // namespace grpc_core diff --git a/src/core/lib/iomgr/executor/threadpool.h b/src/core/lib/iomgr/executor/threadpool.h new file mode 100644 index 00000000000..b14f1051feb --- /dev/null +++ b/src/core/lib/iomgr/executor/threadpool.h @@ -0,0 +1,153 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_EXECUTOR_THREADPOOL_H +#define GRPC_CORE_LIB_IOMGR_EXECUTOR_THREADPOOL_H + +#include + +#include + +#include "src/core/lib/gprpp/thd.h" +#include "src/core/lib/iomgr/executor/mpmcqueue.h" + +namespace grpc_core { + +// A base abstract base class for threadpool. +// Threadpool is an executor that maintains a pool of threads sitting around +// and waiting for closures. A threadpool also maintains a queue of pending +// closures, when closures appearing in the queue, the threads in pool will +// pull them out and execute them. +class ThreadPoolInterface { + public: + // Waits for all pending closures to complete, then shuts down thread pool. + virtual ~ThreadPoolInterface() {} + + // Schedules a given closure for execution later. + // Depending on specific subclass implementation, this routine might cause + // current thread to be blocked (in case of unable to schedule). + // Closure should contain a function pointer and arguments it will take, more + // details for closure struct at /grpc/include/grpc/impl/codegen/grpc_types.h + virtual void Add(grpc_experimental_completion_queue_functor* closure) + GRPC_ABSTRACT; + + // Returns the current number of pending closures + virtual int num_pending_closures() const GRPC_ABSTRACT; + + // Returns the capacity of pool (number of worker threads in pool) + virtual int pool_capacity() const GRPC_ABSTRACT; + + // Thread option accessor + virtual const Thread::Options& thread_options() const GRPC_ABSTRACT; + + // Returns the thread name for threads in this ThreadPool. + virtual const char* thread_name() const GRPC_ABSTRACT; + + GRPC_ABSTRACT_BASE_CLASS +}; + +// Worker thread for threadpool. Executes closures in the queue, until getting a +// NULL closure. +class ThreadPoolWorker { + public: + ThreadPoolWorker(const char* thd_name, ThreadPoolInterface* pool, + MPMCQueueInterface* queue, Thread::Options& options, + int index) + : queue_(queue), thd_name_(thd_name), index_(index) { + thd_ = Thread( + thd_name, [](void* th) { static_cast(th)->Run(); }, + this, nullptr, options); + } + + ~ThreadPoolWorker() {} + + void Start() { thd_.Start(); } + void Join() { thd_.Join(); } + + GRPC_ABSTRACT_BASE_CLASS + + private: + // struct for tracking stats of thread + struct Stats { + gpr_timespec sleep_cycles; + Stats() { sleep_cycles = gpr_time_0(GPR_TIMESPAN); } + }; + + void Run(); // Pulls closures from queue and executes them + + MPMCQueueInterface* queue_; // Queue in thread pool to pull closures from + Thread thd_; // Thread wrapped in + Stats stats_; // Stats to be collected in run time + const char* thd_name_; // Name of thread + int index_; // Index in thread pool +}; + +// A fixed size thread pool implementation of abstract thread pool interface. +// In this implementation, the number of threads in pool is fixed, but the +// capacity of closure queue is unlimited. +class ThreadPool : public ThreadPoolInterface { + public: + // Creates a thread pool with size of "num_threads", with default thread name + // "ThreadPoolWorker" and all thread options set to default. + ThreadPool(int num_threads); + + // Same as ThreadPool(int num_threads) constructor, except + // that it also sets "thd_name" as the name of all threads in the thread pool. + ThreadPool(int num_threads, const char* thd_name); + + // Same as ThreadPool(const char *thd_name, int num_threads) constructor, + // except that is also set thread_options for threads. + // Notes for stack size: + // If the stack size field of the passed in Thread::Options is set to default + // value 0, default ThreadPool stack size will be used. The current default + // stack size of this implementation is 1952K for mobile platform and 64K for + // all others. + ThreadPool(int num_threads, const char* thd_name, + const Thread::Options& thread_options); + + // Waits for all pending closures to complete, then shuts down thread pool. + ~ThreadPool() override; + + // Adds given closure into pending queue immediately. Since closure queue has + // infinite length, this routine will not block. + void Add(grpc_experimental_completion_queue_functor* closure) override; + + int num_pending_closures() const override; + int pool_capacity() const override; + const Thread::Options& thread_options() const override; + const char* thread_name() const override; + + private: + int num_threads_ = 0; + const char* thd_name_ = nullptr; + Thread::Options thread_options_; + ThreadPoolWorker** threads_ = nullptr; // Array of worker threads + MPMCQueueInterface* queue_ = nullptr; + + Atomic shut_down_{false}; // Destructor has been called if set to true + + void SharedThreadPoolConstructor(); + // For ThreadPool, default stack size for mobile platform is 1952K. for other + // platforms is 64K. + size_t DefaultStackSize(); + bool HasBeenShutDown(); +}; + +} // namespace grpc_core + +#endif /* GRPC_CORE_LIB_IOMGR_THREADPOOL_THREADPOOL_H */ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 72e19f02081..6a8b208b914 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -102,6 +102,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/iomgr/exec_ctx.cc', 'src/core/lib/iomgr/executor.cc', 'src/core/lib/iomgr/executor/mpmcqueue.cc', + 'src/core/lib/iomgr/executor/threadpool.cc', 'src/core/lib/iomgr/fork_posix.cc', 'src/core/lib/iomgr/fork_windows.cc', 'src/core/lib/iomgr/gethostname_fallback.cc', diff --git a/test/core/iomgr/BUILD b/test/core/iomgr/BUILD index af67d5de25e..808a635b80a 100644 --- a/test/core/iomgr/BUILD +++ b/test/core/iomgr/BUILD @@ -281,6 +281,17 @@ grpc_cc_test( tags = ["no_windows"], ) +grpc_cc_test( + name = "threadpool_test", + srcs = ["threadpool_test.cc"], + language = "C++", + deps = [ + "//:gpr", + "//:grpc", + "//test/core/util:grpc_test_util", + ], +) + grpc_cc_test( name = "time_averaged_stats_test", srcs = ["time_averaged_stats_test.cc"], diff --git a/test/core/iomgr/threadpool_test.cc b/test/core/iomgr/threadpool_test.cc new file mode 100644 index 00000000000..a56db5b647a --- /dev/null +++ b/test/core/iomgr/threadpool_test.cc @@ -0,0 +1,178 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "src/core/lib/iomgr/executor/threadpool.h" + +#include "test/core/util/test_config.h" + +#define SMALL_THREAD_POOL_SIZE 20 +#define LARGE_THREAD_POOL_SIZE 100 +#define THREAD_SMALL_ITERATION 100 +#define THREAD_LARGE_ITERATION 10000 + +grpc_core::Mutex mu; + +// Simple functor for testing. It will count how many times being called. +class SimpleFunctorForAdd : public grpc_experimental_completion_queue_functor { + public: + friend class SimpleFunctorCheckForAdd; + SimpleFunctorForAdd() : count_(0) { + functor_run = &SimpleFunctorForAdd::Run; + internal_next = this; + internal_success = 0; + } + ~SimpleFunctorForAdd() {} + static void Run(struct grpc_experimental_completion_queue_functor* cb, + int ok) { + auto* callback = static_cast(cb); + grpc_core::MutexLock l(&mu); + callback->count_++; + } + + int count() { + grpc_core::MutexLock l(&mu); + return count_; + } + + private: + int count_; +}; + +// Checks the given SimpleFunctorForAdd's count with a given number. +class SimpleFunctorCheckForAdd + : public grpc_experimental_completion_queue_functor { + public: + SimpleFunctorCheckForAdd( + struct grpc_experimental_completion_queue_functor* cb, int ok) { + functor_run = &SimpleFunctorCheckForAdd::Run; + internal_next = cb; + internal_success = ok; + } + ~SimpleFunctorCheckForAdd() {} + static void Run(struct grpc_experimental_completion_queue_functor* cb, + int ok) { + auto* callback = static_cast(cb); + GPR_ASSERT(callback->count_ == ok); + } +}; + +static void test_add(void) { + gpr_log(GPR_INFO, "test_add"); + grpc_core::ThreadPool* pool = + grpc_core::New(SMALL_THREAD_POOL_SIZE, "test_add"); + + SimpleFunctorForAdd* functor = grpc_core::New(); + for (int i = 0; i < THREAD_SMALL_ITERATION; ++i) { + pool->Add(functor); + } + grpc_core::Delete(pool); + GPR_ASSERT(functor->count() == THREAD_SMALL_ITERATION); + grpc_core::Delete(functor); + gpr_log(GPR_DEBUG, "Done."); +} + +// Thread that adds closures to pool +class WorkThread { + public: + WorkThread(grpc_core::ThreadPool* pool, SimpleFunctorForAdd* cb, int num_add) + : num_add_(num_add), cb_(cb), pool_(pool) { + thd_ = grpc_core::Thread( + "thread_pool_test_add_thd", + [](void* th) { static_cast(th)->Run(); }, this); + } + ~WorkThread() {} + + void Start() { thd_.Start(); } + void Join() { thd_.Join(); } + + private: + void Run() { + for (int i = 0; i < num_add_; ++i) { + pool_->Add(cb_); + } + } + + int num_add_; + SimpleFunctorForAdd* cb_; + grpc_core::ThreadPool* pool_; + grpc_core::Thread thd_; +}; + +static void test_multi_add(void) { + gpr_log(GPR_INFO, "test_multi_add"); + const int num_work_thds = 10; + grpc_core::ThreadPool* pool = grpc_core::New( + LARGE_THREAD_POOL_SIZE, "test_multi_add"); + SimpleFunctorForAdd* functor = grpc_core::New(); + WorkThread** work_thds = static_cast( + gpr_zalloc(sizeof(WorkThread*) * num_work_thds)); + gpr_log(GPR_DEBUG, "Fork threads for adding..."); + for (int i = 0; i < num_work_thds; ++i) { + work_thds[i] = + grpc_core::New(pool, functor, THREAD_LARGE_ITERATION); + work_thds[i]->Start(); + } + // Wait for all threads finish + gpr_log(GPR_DEBUG, "Waiting for all work threads finish..."); + for (int i = 0; i < num_work_thds; ++i) { + work_thds[i]->Join(); + grpc_core::Delete(work_thds[i]); + } + gpr_free(work_thds); + gpr_log(GPR_DEBUG, "Done."); + gpr_log(GPR_DEBUG, "Waiting for all closures finish..."); + // Destructor of thread pool will wait for all closures to finish + grpc_core::Delete(pool); + GPR_ASSERT(functor->count() == THREAD_LARGE_ITERATION * num_work_thds); + grpc_core::Delete(functor); + gpr_log(GPR_DEBUG, "Done."); +} + +static void test_one_thread_FIFO(void) { + gpr_log(GPR_INFO, "test_one_thread_FIFO"); + grpc_core::ThreadPool* pool = + grpc_core::New(1, "test_one_thread_FIFO"); + SimpleFunctorForAdd* functor = grpc_core::New(); + SimpleFunctorCheckForAdd** check_functors = + static_cast(gpr_zalloc( + sizeof(SimpleFunctorCheckForAdd*) * THREAD_SMALL_ITERATION)); + for (int i = 0; i < THREAD_SMALL_ITERATION; ++i) { + pool->Add(functor); + check_functors[i] = + grpc_core::New(functor, i + 1); + pool->Add(check_functors[i]); + } + // Destructor of pool will wait until all closures finished. + grpc_core::Delete(pool); + grpc_core::Delete(functor); + for (int i = 0; i < THREAD_SMALL_ITERATION; ++i) { + grpc_core::Delete(check_functors[i]); + } + gpr_free(check_functors); + gpr_log(GPR_DEBUG, "Done."); +} + +int main(int argc, char** argv) { + grpc::testing::TestEnvironment env(argc, argv); + grpc_init(); + test_add(); + test_multi_add(); + test_one_thread_FIFO(); + grpc_shutdown(); + return 0; +} diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 79cc89e13e8..8254c5b58b1 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1134,6 +1134,7 @@ src/core/lib/iomgr/ev_posix.h \ src/core/lib/iomgr/exec_ctx.h \ src/core/lib/iomgr/executor.h \ src/core/lib/iomgr/executor/mpmcqueue.h \ +src/core/lib/iomgr/executor/threadpool.h \ src/core/lib/iomgr/gethostname.h \ src/core/lib/iomgr/grpc_if_nametoindex.h \ src/core/lib/iomgr/internal_errqueue.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 273c56e0242..b9e26a3cb0f 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1236,6 +1236,8 @@ src/core/lib/iomgr/executor.cc \ src/core/lib/iomgr/executor.h \ src/core/lib/iomgr/executor/mpmcqueue.cc \ src/core/lib/iomgr/executor/mpmcqueue.h \ +src/core/lib/iomgr/executor/threadpool.cc \ +src/core/lib/iomgr/executor/threadpool.h \ src/core/lib/iomgr/fork_posix.cc \ src/core/lib/iomgr/fork_windows.cc \ src/core/lib/iomgr/gethostname.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index b8a79b387b6..b098db5f3a9 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -2267,6 +2267,22 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "grpc", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c", + "name": "threadpool_test", + "src": [ + "test/core/iomgr/threadpool_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", @@ -8509,6 +8525,7 @@ "src/core/lib/iomgr/exec_ctx.cc", "src/core/lib/iomgr/executor.cc", "src/core/lib/iomgr/executor/mpmcqueue.cc", + "src/core/lib/iomgr/executor/threadpool.cc", "src/core/lib/iomgr/fork_posix.cc", "src/core/lib/iomgr/fork_windows.cc", "src/core/lib/iomgr/gethostname_fallback.cc", @@ -8698,6 +8715,7 @@ "src/core/lib/iomgr/exec_ctx.h", "src/core/lib/iomgr/executor.h", "src/core/lib/iomgr/executor/mpmcqueue.h", + "src/core/lib/iomgr/executor/threadpool.h", "src/core/lib/iomgr/gethostname.h", "src/core/lib/iomgr/grpc_if_nametoindex.h", "src/core/lib/iomgr/internal_errqueue.h", @@ -8857,6 +8875,7 @@ "src/core/lib/iomgr/exec_ctx.h", "src/core/lib/iomgr/executor.h", "src/core/lib/iomgr/executor/mpmcqueue.h", + "src/core/lib/iomgr/executor/threadpool.h", "src/core/lib/iomgr/gethostname.h", "src/core/lib/iomgr/grpc_if_nametoindex.h", "src/core/lib/iomgr/internal_errqueue.h", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 2ac529238d5..c8d7ff50e1a 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -2793,6 +2793,30 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": false, + "language": "c", + "name": "threadpool_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": false + }, { "args": [], "benchmark": false, From bf994e48d90679f8571ba69781d9d5a31037f34b Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Mon, 1 Jul 2019 10:38:23 -0700 Subject: [PATCH 0767/1555] Move grpc async, callback and sync implementation to grpc_impl namespace --- BUILD | 10 + BUILD.gn | 10 + CMakeLists.txt | 40 + Makefile | 40 + build.yaml | 10 + gRPC-C++.podspec | 10 + include/grpcpp/channel_impl.h | 13 +- include/grpcpp/generic/generic_stub_impl.h | 41 +- .../impl/codegen/async_generic_service.h | 28 +- include/grpcpp/impl/codegen/async_stream.h | 1114 +--------------- .../grpcpp/impl/codegen/async_stream_impl.h | 1134 ++++++++++++++++ .../grpcpp/impl/codegen/async_unary_call.h | 291 +--- .../impl/codegen/async_unary_call_impl.h | 315 +++++ include/grpcpp/impl/codegen/byte_buffer.h | 19 +- include/grpcpp/impl/codegen/call_op_set.h | 2 +- .../grpcpp/impl/codegen/channel_interface.h | 47 +- include/grpcpp/impl/codegen/client_callback.h | 1003 +------------- .../impl/codegen/client_callback_impl.h | 1067 +++++++++++++++ .../grpcpp/impl/codegen/client_context_impl.h | 52 +- .../grpcpp/impl/codegen/client_unary_call.h | 4 +- .../impl/codegen/completion_queue_impl.h | 17 +- include/grpcpp/impl/codegen/server_callback.h | 1133 +--------------- .../impl/codegen/server_callback_impl.h | 1186 +++++++++++++++++ .../grpcpp/impl/codegen/server_context_impl.h | 54 +- include/grpcpp/impl/codegen/service_type.h | 20 +- include/grpcpp/impl/codegen/sync_stream.h | 922 +------------ .../grpcpp/impl/codegen/sync_stream_impl.h | 944 +++++++++++++ include/grpcpp/support/async_stream_impl.h | 24 + .../grpcpp/support/async_unary_call_impl.h | 24 + include/grpcpp/support/client_callback_impl.h | 24 + include/grpcpp/support/server_callback_impl.h | 24 + include/grpcpp/support/sync_stream_impl.h | 24 + src/compiler/cpp_generator.cc | 121 +- src/cpp/client/generic_stub.cc | 30 +- src/cpp/server/async_generic_service.cc | 4 +- .../health/default_health_check_service.h | 1 + src/cpp/server/server_builder.cc | 15 +- src/cpp/server/server_context.cc | 11 +- test/cpp/codegen/compiler_test_golden | 37 +- tools/doxygen/Doxyfile.c++ | 10 + tools/doxygen/Doxyfile.c++.internal | 10 + .../generated/sources_and_headers.json | 20 + 42 files changed, 5268 insertions(+), 4637 deletions(-) create mode 100644 include/grpcpp/impl/codegen/async_stream_impl.h create mode 100644 include/grpcpp/impl/codegen/async_unary_call_impl.h create mode 100644 include/grpcpp/impl/codegen/client_callback_impl.h create mode 100644 include/grpcpp/impl/codegen/server_callback_impl.h create mode 100644 include/grpcpp/impl/codegen/sync_stream_impl.h create mode 100644 include/grpcpp/support/async_stream_impl.h create mode 100644 include/grpcpp/support/async_unary_call_impl.h create mode 100644 include/grpcpp/support/client_callback_impl.h create mode 100644 include/grpcpp/support/server_callback_impl.h create mode 100644 include/grpcpp/support/sync_stream_impl.h diff --git a/BUILD b/BUILD index f7c97beaaaf..851e5011006 100644 --- a/BUILD +++ b/BUILD @@ -268,11 +268,14 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/server_posix.h", "include/grpcpp/server_posix_impl.h", "include/grpcpp/support/async_stream.h", + "include/grpcpp/support/async_stream_impl.h", "include/grpcpp/support/async_unary_call.h", + "include/grpcpp/support/async_unary_call_impl.h", "include/grpcpp/support/byte_buffer.h", "include/grpcpp/support/channel_arguments.h", "include/grpcpp/support/channel_arguments_impl.h", "include/grpcpp/support/client_callback.h", + "include/grpcpp/support/client_callback_impl.h", "include/grpcpp/support/client_interceptor.h", "include/grpcpp/support/config.h", "include/grpcpp/support/interceptor.h", @@ -280,6 +283,7 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/support/proto_buffer_reader.h", "include/grpcpp/support/proto_buffer_writer.h", "include/grpcpp/support/server_callback.h", + "include/grpcpp/support/server_callback_impl.h", "include/grpcpp/support/server_interceptor.h", "include/grpcpp/support/slice.h", "include/grpcpp/support/status.h", @@ -287,6 +291,7 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/support/string_ref.h", "include/grpcpp/support/stub_options.h", "include/grpcpp/support/sync_stream.h", + "include/grpcpp/support/sync_stream_impl.h", "include/grpcpp/support/time.h", "include/grpcpp/support/validate_service_config.h", ] @@ -2157,7 +2162,9 @@ grpc_cc_library( "include/grpc++/impl/codegen/time.h", "include/grpcpp/impl/codegen/async_generic_service.h", "include/grpcpp/impl/codegen/async_stream.h", + "include/grpcpp/impl/codegen/async_stream_impl.h", "include/grpcpp/impl/codegen/async_unary_call.h", + "include/grpcpp/impl/codegen/async_unary_call_impl.h", "include/grpcpp/impl/codegen/byte_buffer.h", "include/grpcpp/impl/codegen/call.h", "include/grpcpp/impl/codegen/call_hook.h", @@ -2166,6 +2173,7 @@ grpc_cc_library( "include/grpcpp/impl/codegen/callback_common.h", "include/grpcpp/impl/codegen/channel_interface.h", "include/grpcpp/impl/codegen/client_callback.h", + "include/grpcpp/impl/codegen/client_callback_impl.h", "include/grpcpp/impl/codegen/client_context.h", "include/grpcpp/impl/codegen/client_context_impl.h", "include/grpcpp/impl/codegen/client_interceptor.h", @@ -2188,6 +2196,7 @@ grpc_cc_library( "include/grpcpp/impl/codegen/security/auth_context.h", "include/grpcpp/impl/codegen/serialization_traits.h", "include/grpcpp/impl/codegen/server_callback.h", + "include/grpcpp/impl/codegen/server_callback_impl.h", "include/grpcpp/impl/codegen/server_context.h", "include/grpcpp/impl/codegen/server_context_impl.h", "include/grpcpp/impl/codegen/server_interceptor.h", @@ -2199,6 +2208,7 @@ grpc_cc_library( "include/grpcpp/impl/codegen/string_ref.h", "include/grpcpp/impl/codegen/stub_options.h", "include/grpcpp/impl/codegen/sync_stream.h", + "include/grpcpp/impl/codegen/sync_stream_impl.h", "include/grpcpp/impl/codegen/time.h", ], deps = [ diff --git a/BUILD.gn b/BUILD.gn index 08625e9bd12..940c9b25c72 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1046,7 +1046,9 @@ config("grpc_config") { "include/grpcpp/impl/client_unary_call.h", "include/grpcpp/impl/codegen/async_generic_service.h", "include/grpcpp/impl/codegen/async_stream.h", + "include/grpcpp/impl/codegen/async_stream_impl.h", "include/grpcpp/impl/codegen/async_unary_call.h", + "include/grpcpp/impl/codegen/async_unary_call_impl.h", "include/grpcpp/impl/codegen/byte_buffer.h", "include/grpcpp/impl/codegen/call.h", "include/grpcpp/impl/codegen/call_hook.h", @@ -1055,6 +1057,7 @@ config("grpc_config") { "include/grpcpp/impl/codegen/callback_common.h", "include/grpcpp/impl/codegen/channel_interface.h", "include/grpcpp/impl/codegen/client_callback.h", + "include/grpcpp/impl/codegen/client_callback_impl.h", "include/grpcpp/impl/codegen/client_context.h", "include/grpcpp/impl/codegen/client_context_impl.h", "include/grpcpp/impl/codegen/client_interceptor.h", @@ -1083,6 +1086,7 @@ config("grpc_config") { "include/grpcpp/impl/codegen/security/auth_context.h", "include/grpcpp/impl/codegen/serialization_traits.h", "include/grpcpp/impl/codegen/server_callback.h", + "include/grpcpp/impl/codegen/server_callback_impl.h", "include/grpcpp/impl/codegen/server_context.h", "include/grpcpp/impl/codegen/server_context_impl.h", "include/grpcpp/impl/codegen/server_interceptor.h", @@ -1095,6 +1099,7 @@ config("grpc_config") { "include/grpcpp/impl/codegen/stub_options.h", "include/grpcpp/impl/codegen/sync.h", "include/grpcpp/impl/codegen/sync_stream.h", + "include/grpcpp/impl/codegen/sync_stream_impl.h", "include/grpcpp/impl/codegen/time.h", "include/grpcpp/impl/grpc_library.h", "include/grpcpp/impl/method_handler_impl.h", @@ -1124,11 +1129,14 @@ config("grpc_config") { "include/grpcpp/server_posix.h", "include/grpcpp/server_posix_impl.h", "include/grpcpp/support/async_stream.h", + "include/grpcpp/support/async_stream_impl.h", "include/grpcpp/support/async_unary_call.h", + "include/grpcpp/support/async_unary_call_impl.h", "include/grpcpp/support/byte_buffer.h", "include/grpcpp/support/channel_arguments.h", "include/grpcpp/support/channel_arguments_impl.h", "include/grpcpp/support/client_callback.h", + "include/grpcpp/support/client_callback_impl.h", "include/grpcpp/support/client_interceptor.h", "include/grpcpp/support/config.h", "include/grpcpp/support/interceptor.h", @@ -1136,6 +1144,7 @@ config("grpc_config") { "include/grpcpp/support/proto_buffer_reader.h", "include/grpcpp/support/proto_buffer_writer.h", "include/grpcpp/support/server_callback.h", + "include/grpcpp/support/server_callback_impl.h", "include/grpcpp/support/server_interceptor.h", "include/grpcpp/support/slice.h", "include/grpcpp/support/status.h", @@ -1143,6 +1152,7 @@ config("grpc_config") { "include/grpcpp/support/string_ref.h", "include/grpcpp/support/stub_options.h", "include/grpcpp/support/sync_stream.h", + "include/grpcpp/support/sync_stream_impl.h", "include/grpcpp/support/time.h", "include/grpcpp/support/validate_service_config.h", "src/core/ext/transport/inproc/inproc_transport.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 90737ecfe29..4653b8f6013 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3221,11 +3221,14 @@ foreach(_hdr include/grpcpp/server_posix.h include/grpcpp/server_posix_impl.h include/grpcpp/support/async_stream.h + include/grpcpp/support/async_stream_impl.h include/grpcpp/support/async_unary_call.h + include/grpcpp/support/async_unary_call_impl.h include/grpcpp/support/byte_buffer.h include/grpcpp/support/channel_arguments.h include/grpcpp/support/channel_arguments_impl.h include/grpcpp/support/client_callback.h + include/grpcpp/support/client_callback_impl.h include/grpcpp/support/client_interceptor.h include/grpcpp/support/config.h include/grpcpp/support/interceptor.h @@ -3233,6 +3236,7 @@ foreach(_hdr include/grpcpp/support/proto_buffer_reader.h include/grpcpp/support/proto_buffer_writer.h include/grpcpp/support/server_callback.h + include/grpcpp/support/server_callback_impl.h include/grpcpp/support/server_interceptor.h include/grpcpp/support/slice.h include/grpcpp/support/status.h @@ -3240,6 +3244,7 @@ foreach(_hdr include/grpcpp/support/string_ref.h include/grpcpp/support/stub_options.h include/grpcpp/support/sync_stream.h + include/grpcpp/support/sync_stream_impl.h include/grpcpp/support/time.h include/grpcpp/support/validate_service_config.h include/grpc/support/alloc.h @@ -3325,7 +3330,9 @@ foreach(_hdr include/grpc++/impl/codegen/time.h include/grpcpp/impl/codegen/async_generic_service.h include/grpcpp/impl/codegen/async_stream.h + include/grpcpp/impl/codegen/async_stream_impl.h include/grpcpp/impl/codegen/async_unary_call.h + include/grpcpp/impl/codegen/async_unary_call_impl.h include/grpcpp/impl/codegen/byte_buffer.h include/grpcpp/impl/codegen/call.h include/grpcpp/impl/codegen/call_hook.h @@ -3334,6 +3341,7 @@ foreach(_hdr include/grpcpp/impl/codegen/callback_common.h include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/client_callback.h + include/grpcpp/impl/codegen/client_callback_impl.h include/grpcpp/impl/codegen/client_context.h include/grpcpp/impl/codegen/client_context_impl.h include/grpcpp/impl/codegen/client_interceptor.h @@ -3356,6 +3364,7 @@ foreach(_hdr include/grpcpp/impl/codegen/security/auth_context.h include/grpcpp/impl/codegen/serialization_traits.h include/grpcpp/impl/codegen/server_callback.h + include/grpcpp/impl/codegen/server_callback_impl.h include/grpcpp/impl/codegen/server_context.h include/grpcpp/impl/codegen/server_context_impl.h include/grpcpp/impl/codegen/server_interceptor.h @@ -3367,6 +3376,7 @@ foreach(_hdr include/grpcpp/impl/codegen/string_ref.h include/grpcpp/impl/codegen/stub_options.h include/grpcpp/impl/codegen/sync_stream.h + include/grpcpp/impl/codegen/sync_stream_impl.h include/grpcpp/impl/codegen/time.h include/grpcpp/impl/codegen/sync.h include/grpc++/impl/codegen/proto_utils.h @@ -3846,11 +3856,14 @@ foreach(_hdr include/grpcpp/server_posix.h include/grpcpp/server_posix_impl.h include/grpcpp/support/async_stream.h + include/grpcpp/support/async_stream_impl.h include/grpcpp/support/async_unary_call.h + include/grpcpp/support/async_unary_call_impl.h include/grpcpp/support/byte_buffer.h include/grpcpp/support/channel_arguments.h include/grpcpp/support/channel_arguments_impl.h include/grpcpp/support/client_callback.h + include/grpcpp/support/client_callback_impl.h include/grpcpp/support/client_interceptor.h include/grpcpp/support/config.h include/grpcpp/support/interceptor.h @@ -3858,6 +3871,7 @@ foreach(_hdr include/grpcpp/support/proto_buffer_reader.h include/grpcpp/support/proto_buffer_writer.h include/grpcpp/support/server_callback.h + include/grpcpp/support/server_callback_impl.h include/grpcpp/support/server_interceptor.h include/grpcpp/support/slice.h include/grpcpp/support/status.h @@ -3865,6 +3879,7 @@ foreach(_hdr include/grpcpp/support/string_ref.h include/grpcpp/support/stub_options.h include/grpcpp/support/sync_stream.h + include/grpcpp/support/sync_stream_impl.h include/grpcpp/support/time.h include/grpcpp/support/validate_service_config.h include/grpc/support/alloc.h @@ -3950,7 +3965,9 @@ foreach(_hdr include/grpc++/impl/codegen/time.h include/grpcpp/impl/codegen/async_generic_service.h include/grpcpp/impl/codegen/async_stream.h + include/grpcpp/impl/codegen/async_stream_impl.h include/grpcpp/impl/codegen/async_unary_call.h + include/grpcpp/impl/codegen/async_unary_call_impl.h include/grpcpp/impl/codegen/byte_buffer.h include/grpcpp/impl/codegen/call.h include/grpcpp/impl/codegen/call_hook.h @@ -3959,6 +3976,7 @@ foreach(_hdr include/grpcpp/impl/codegen/callback_common.h include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/client_callback.h + include/grpcpp/impl/codegen/client_callback_impl.h include/grpcpp/impl/codegen/client_context.h include/grpcpp/impl/codegen/client_context_impl.h include/grpcpp/impl/codegen/client_interceptor.h @@ -3981,6 +3999,7 @@ foreach(_hdr include/grpcpp/impl/codegen/security/auth_context.h include/grpcpp/impl/codegen/serialization_traits.h include/grpcpp/impl/codegen/server_callback.h + include/grpcpp/impl/codegen/server_callback_impl.h include/grpcpp/impl/codegen/server_context.h include/grpcpp/impl/codegen/server_context_impl.h include/grpcpp/impl/codegen/server_interceptor.h @@ -3992,6 +4011,7 @@ foreach(_hdr include/grpcpp/impl/codegen/string_ref.h include/grpcpp/impl/codegen/stub_options.h include/grpcpp/impl/codegen/sync_stream.h + include/grpcpp/impl/codegen/sync_stream_impl.h include/grpcpp/impl/codegen/time.h include/grpcpp/impl/codegen/sync.h include/grpc/census.h @@ -4387,7 +4407,9 @@ foreach(_hdr include/grpc++/impl/codegen/time.h include/grpcpp/impl/codegen/async_generic_service.h include/grpcpp/impl/codegen/async_stream.h + include/grpcpp/impl/codegen/async_stream_impl.h include/grpcpp/impl/codegen/async_unary_call.h + include/grpcpp/impl/codegen/async_unary_call_impl.h include/grpcpp/impl/codegen/byte_buffer.h include/grpcpp/impl/codegen/call.h include/grpcpp/impl/codegen/call_hook.h @@ -4396,6 +4418,7 @@ foreach(_hdr include/grpcpp/impl/codegen/callback_common.h include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/client_callback.h + include/grpcpp/impl/codegen/client_callback_impl.h include/grpcpp/impl/codegen/client_context.h include/grpcpp/impl/codegen/client_context_impl.h include/grpcpp/impl/codegen/client_interceptor.h @@ -4418,6 +4441,7 @@ foreach(_hdr include/grpcpp/impl/codegen/security/auth_context.h include/grpcpp/impl/codegen/serialization_traits.h include/grpcpp/impl/codegen/server_callback.h + include/grpcpp/impl/codegen/server_callback_impl.h include/grpcpp/impl/codegen/server_context.h include/grpcpp/impl/codegen/server_context_impl.h include/grpcpp/impl/codegen/server_interceptor.h @@ -4429,6 +4453,7 @@ foreach(_hdr include/grpcpp/impl/codegen/string_ref.h include/grpcpp/impl/codegen/stub_options.h include/grpcpp/impl/codegen/sync_stream.h + include/grpcpp/impl/codegen/sync_stream_impl.h include/grpcpp/impl/codegen/time.h include/grpc/impl/codegen/byte_buffer.h include/grpc/impl/codegen/byte_buffer_reader.h @@ -4588,7 +4613,9 @@ foreach(_hdr include/grpc++/impl/codegen/time.h include/grpcpp/impl/codegen/async_generic_service.h include/grpcpp/impl/codegen/async_stream.h + include/grpcpp/impl/codegen/async_stream_impl.h include/grpcpp/impl/codegen/async_unary_call.h + include/grpcpp/impl/codegen/async_unary_call_impl.h include/grpcpp/impl/codegen/byte_buffer.h include/grpcpp/impl/codegen/call.h include/grpcpp/impl/codegen/call_hook.h @@ -4597,6 +4624,7 @@ foreach(_hdr include/grpcpp/impl/codegen/callback_common.h include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/client_callback.h + include/grpcpp/impl/codegen/client_callback_impl.h include/grpcpp/impl/codegen/client_context.h include/grpcpp/impl/codegen/client_context_impl.h include/grpcpp/impl/codegen/client_interceptor.h @@ -4619,6 +4647,7 @@ foreach(_hdr include/grpcpp/impl/codegen/security/auth_context.h include/grpcpp/impl/codegen/serialization_traits.h include/grpcpp/impl/codegen/server_callback.h + include/grpcpp/impl/codegen/server_callback_impl.h include/grpcpp/impl/codegen/server_context.h include/grpcpp/impl/codegen/server_context_impl.h include/grpcpp/impl/codegen/server_interceptor.h @@ -4630,6 +4659,7 @@ foreach(_hdr include/grpcpp/impl/codegen/string_ref.h include/grpcpp/impl/codegen/stub_options.h include/grpcpp/impl/codegen/sync_stream.h + include/grpcpp/impl/codegen/sync_stream_impl.h include/grpcpp/impl/codegen/time.h include/grpc/impl/codegen/byte_buffer.h include/grpc/impl/codegen/byte_buffer_reader.h @@ -4846,11 +4876,14 @@ foreach(_hdr include/grpcpp/server_posix.h include/grpcpp/server_posix_impl.h include/grpcpp/support/async_stream.h + include/grpcpp/support/async_stream_impl.h include/grpcpp/support/async_unary_call.h + include/grpcpp/support/async_unary_call_impl.h include/grpcpp/support/byte_buffer.h include/grpcpp/support/channel_arguments.h include/grpcpp/support/channel_arguments_impl.h include/grpcpp/support/client_callback.h + include/grpcpp/support/client_callback_impl.h include/grpcpp/support/client_interceptor.h include/grpcpp/support/config.h include/grpcpp/support/interceptor.h @@ -4858,6 +4891,7 @@ foreach(_hdr include/grpcpp/support/proto_buffer_reader.h include/grpcpp/support/proto_buffer_writer.h include/grpcpp/support/server_callback.h + include/grpcpp/support/server_callback_impl.h include/grpcpp/support/server_interceptor.h include/grpcpp/support/slice.h include/grpcpp/support/status.h @@ -4865,6 +4899,7 @@ foreach(_hdr include/grpcpp/support/string_ref.h include/grpcpp/support/stub_options.h include/grpcpp/support/sync_stream.h + include/grpcpp/support/sync_stream_impl.h include/grpcpp/support/time.h include/grpcpp/support/validate_service_config.h include/grpc/support/alloc.h @@ -4950,7 +4985,9 @@ foreach(_hdr include/grpc++/impl/codegen/time.h include/grpcpp/impl/codegen/async_generic_service.h include/grpcpp/impl/codegen/async_stream.h + include/grpcpp/impl/codegen/async_stream_impl.h include/grpcpp/impl/codegen/async_unary_call.h + include/grpcpp/impl/codegen/async_unary_call_impl.h include/grpcpp/impl/codegen/byte_buffer.h include/grpcpp/impl/codegen/call.h include/grpcpp/impl/codegen/call_hook.h @@ -4959,6 +4996,7 @@ foreach(_hdr include/grpcpp/impl/codegen/callback_common.h include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/client_callback.h + include/grpcpp/impl/codegen/client_callback_impl.h include/grpcpp/impl/codegen/client_context.h include/grpcpp/impl/codegen/client_context_impl.h include/grpcpp/impl/codegen/client_interceptor.h @@ -4981,6 +5019,7 @@ foreach(_hdr include/grpcpp/impl/codegen/security/auth_context.h include/grpcpp/impl/codegen/serialization_traits.h include/grpcpp/impl/codegen/server_callback.h + include/grpcpp/impl/codegen/server_callback_impl.h include/grpcpp/impl/codegen/server_context.h include/grpcpp/impl/codegen/server_context_impl.h include/grpcpp/impl/codegen/server_interceptor.h @@ -4992,6 +5031,7 @@ foreach(_hdr include/grpcpp/impl/codegen/string_ref.h include/grpcpp/impl/codegen/stub_options.h include/grpcpp/impl/codegen/sync_stream.h + include/grpcpp/impl/codegen/sync_stream_impl.h include/grpcpp/impl/codegen/time.h include/grpcpp/impl/codegen/sync.h ) diff --git a/Makefile b/Makefile index d5b4f55d8d8..6369a52c49c 100644 --- a/Makefile +++ b/Makefile @@ -5588,11 +5588,14 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ include/grpcpp/support/async_stream.h \ + include/grpcpp/support/async_stream_impl.h \ include/grpcpp/support/async_unary_call.h \ + include/grpcpp/support/async_unary_call_impl.h \ include/grpcpp/support/byte_buffer.h \ include/grpcpp/support/channel_arguments.h \ include/grpcpp/support/channel_arguments_impl.h \ include/grpcpp/support/client_callback.h \ + include/grpcpp/support/client_callback_impl.h \ include/grpcpp/support/client_interceptor.h \ include/grpcpp/support/config.h \ include/grpcpp/support/interceptor.h \ @@ -5600,6 +5603,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/support/proto_buffer_reader.h \ include/grpcpp/support/proto_buffer_writer.h \ include/grpcpp/support/server_callback.h \ + include/grpcpp/support/server_callback_impl.h \ include/grpcpp/support/server_interceptor.h \ include/grpcpp/support/slice.h \ include/grpcpp/support/status.h \ @@ -5607,6 +5611,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/support/string_ref.h \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ + include/grpcpp/support/sync_stream_impl.h \ include/grpcpp/support/time.h \ include/grpcpp/support/validate_service_config.h \ include/grpc/support/alloc.h \ @@ -5692,7 +5697,9 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/time.h \ include/grpcpp/impl/codegen/async_generic_service.h \ include/grpcpp/impl/codegen/async_stream.h \ + include/grpcpp/impl/codegen/async_stream_impl.h \ include/grpcpp/impl/codegen/async_unary_call.h \ + include/grpcpp/impl/codegen/async_unary_call_impl.h \ include/grpcpp/impl/codegen/byte_buffer.h \ include/grpcpp/impl/codegen/call.h \ include/grpcpp/impl/codegen/call_hook.h \ @@ -5701,6 +5708,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/callback_common.h \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ + include/grpcpp/impl/codegen/client_callback_impl.h \ include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ @@ -5723,6 +5731,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/security/auth_context.h \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ + include/grpcpp/impl/codegen/server_callback_impl.h \ include/grpcpp/impl/codegen/server_context.h \ include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ @@ -5734,6 +5743,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/string_ref.h \ include/grpcpp/impl/codegen/stub_options.h \ include/grpcpp/impl/codegen/sync_stream.h \ + include/grpcpp/impl/codegen/sync_stream_impl.h \ include/grpcpp/impl/codegen/time.h \ include/grpcpp/impl/codegen/sync.h \ include/grpc++/impl/codegen/proto_utils.h \ @@ -6218,11 +6228,14 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ include/grpcpp/support/async_stream.h \ + include/grpcpp/support/async_stream_impl.h \ include/grpcpp/support/async_unary_call.h \ + include/grpcpp/support/async_unary_call_impl.h \ include/grpcpp/support/byte_buffer.h \ include/grpcpp/support/channel_arguments.h \ include/grpcpp/support/channel_arguments_impl.h \ include/grpcpp/support/client_callback.h \ + include/grpcpp/support/client_callback_impl.h \ include/grpcpp/support/client_interceptor.h \ include/grpcpp/support/config.h \ include/grpcpp/support/interceptor.h \ @@ -6230,6 +6243,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/support/proto_buffer_reader.h \ include/grpcpp/support/proto_buffer_writer.h \ include/grpcpp/support/server_callback.h \ + include/grpcpp/support/server_callback_impl.h \ include/grpcpp/support/server_interceptor.h \ include/grpcpp/support/slice.h \ include/grpcpp/support/status.h \ @@ -6237,6 +6251,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/support/string_ref.h \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ + include/grpcpp/support/sync_stream_impl.h \ include/grpcpp/support/time.h \ include/grpcpp/support/validate_service_config.h \ include/grpc/support/alloc.h \ @@ -6322,7 +6337,9 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/time.h \ include/grpcpp/impl/codegen/async_generic_service.h \ include/grpcpp/impl/codegen/async_stream.h \ + include/grpcpp/impl/codegen/async_stream_impl.h \ include/grpcpp/impl/codegen/async_unary_call.h \ + include/grpcpp/impl/codegen/async_unary_call_impl.h \ include/grpcpp/impl/codegen/byte_buffer.h \ include/grpcpp/impl/codegen/call.h \ include/grpcpp/impl/codegen/call_hook.h \ @@ -6331,6 +6348,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/callback_common.h \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ + include/grpcpp/impl/codegen/client_callback_impl.h \ include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ @@ -6353,6 +6371,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/security/auth_context.h \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ + include/grpcpp/impl/codegen/server_callback_impl.h \ include/grpcpp/impl/codegen/server_context.h \ include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ @@ -6364,6 +6383,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/string_ref.h \ include/grpcpp/impl/codegen/stub_options.h \ include/grpcpp/impl/codegen/sync_stream.h \ + include/grpcpp/impl/codegen/sync_stream_impl.h \ include/grpcpp/impl/codegen/time.h \ include/grpcpp/impl/codegen/sync.h \ include/grpc/census.h \ @@ -6731,7 +6751,9 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/time.h \ include/grpcpp/impl/codegen/async_generic_service.h \ include/grpcpp/impl/codegen/async_stream.h \ + include/grpcpp/impl/codegen/async_stream_impl.h \ include/grpcpp/impl/codegen/async_unary_call.h \ + include/grpcpp/impl/codegen/async_unary_call_impl.h \ include/grpcpp/impl/codegen/byte_buffer.h \ include/grpcpp/impl/codegen/call.h \ include/grpcpp/impl/codegen/call_hook.h \ @@ -6740,6 +6762,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/callback_common.h \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ + include/grpcpp/impl/codegen/client_callback_impl.h \ include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ @@ -6762,6 +6785,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/security/auth_context.h \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ + include/grpcpp/impl/codegen/server_callback_impl.h \ include/grpcpp/impl/codegen/server_context.h \ include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ @@ -6773,6 +6797,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/string_ref.h \ include/grpcpp/impl/codegen/stub_options.h \ include/grpcpp/impl/codegen/sync_stream.h \ + include/grpcpp/impl/codegen/sync_stream_impl.h \ include/grpcpp/impl/codegen/time.h \ include/grpc/impl/codegen/byte_buffer.h \ include/grpc/impl/codegen/byte_buffer_reader.h \ @@ -6903,7 +6928,9 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/time.h \ include/grpcpp/impl/codegen/async_generic_service.h \ include/grpcpp/impl/codegen/async_stream.h \ + include/grpcpp/impl/codegen/async_stream_impl.h \ include/grpcpp/impl/codegen/async_unary_call.h \ + include/grpcpp/impl/codegen/async_unary_call_impl.h \ include/grpcpp/impl/codegen/byte_buffer.h \ include/grpcpp/impl/codegen/call.h \ include/grpcpp/impl/codegen/call_hook.h \ @@ -6912,6 +6939,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/callback_common.h \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ + include/grpcpp/impl/codegen/client_callback_impl.h \ include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ @@ -6934,6 +6962,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/security/auth_context.h \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ + include/grpcpp/impl/codegen/server_callback_impl.h \ include/grpcpp/impl/codegen/server_context.h \ include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ @@ -6945,6 +6974,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/string_ref.h \ include/grpcpp/impl/codegen/stub_options.h \ include/grpcpp/impl/codegen/sync_stream.h \ + include/grpcpp/impl/codegen/sync_stream_impl.h \ include/grpcpp/impl/codegen/time.h \ include/grpc/impl/codegen/byte_buffer.h \ include/grpc/impl/codegen/byte_buffer_reader.h \ @@ -7167,11 +7197,14 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ include/grpcpp/support/async_stream.h \ + include/grpcpp/support/async_stream_impl.h \ include/grpcpp/support/async_unary_call.h \ + include/grpcpp/support/async_unary_call_impl.h \ include/grpcpp/support/byte_buffer.h \ include/grpcpp/support/channel_arguments.h \ include/grpcpp/support/channel_arguments_impl.h \ include/grpcpp/support/client_callback.h \ + include/grpcpp/support/client_callback_impl.h \ include/grpcpp/support/client_interceptor.h \ include/grpcpp/support/config.h \ include/grpcpp/support/interceptor.h \ @@ -7179,6 +7212,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/support/proto_buffer_reader.h \ include/grpcpp/support/proto_buffer_writer.h \ include/grpcpp/support/server_callback.h \ + include/grpcpp/support/server_callback_impl.h \ include/grpcpp/support/server_interceptor.h \ include/grpcpp/support/slice.h \ include/grpcpp/support/status.h \ @@ -7186,6 +7220,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/support/string_ref.h \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ + include/grpcpp/support/sync_stream_impl.h \ include/grpcpp/support/time.h \ include/grpcpp/support/validate_service_config.h \ include/grpc/support/alloc.h \ @@ -7271,7 +7306,9 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/time.h \ include/grpcpp/impl/codegen/async_generic_service.h \ include/grpcpp/impl/codegen/async_stream.h \ + include/grpcpp/impl/codegen/async_stream_impl.h \ include/grpcpp/impl/codegen/async_unary_call.h \ + include/grpcpp/impl/codegen/async_unary_call_impl.h \ include/grpcpp/impl/codegen/byte_buffer.h \ include/grpcpp/impl/codegen/call.h \ include/grpcpp/impl/codegen/call_hook.h \ @@ -7280,6 +7317,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/callback_common.h \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ + include/grpcpp/impl/codegen/client_callback_impl.h \ include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ @@ -7302,6 +7340,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/security/auth_context.h \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ + include/grpcpp/impl/codegen/server_callback_impl.h \ include/grpcpp/impl/codegen/server_context.h \ include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ @@ -7313,6 +7352,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/string_ref.h \ include/grpcpp/impl/codegen/stub_options.h \ include/grpcpp/impl/codegen/sync_stream.h \ + include/grpcpp/impl/codegen/sync_stream_impl.h \ include/grpcpp/impl/codegen/time.h \ include/grpcpp/impl/codegen/sync.h \ diff --git a/build.yaml b/build.yaml index 74482dab439..8d7445152f5 100644 --- a/build.yaml +++ b/build.yaml @@ -1251,7 +1251,9 @@ filegroups: - include/grpc++/impl/codegen/time.h - include/grpcpp/impl/codegen/async_generic_service.h - include/grpcpp/impl/codegen/async_stream.h + - include/grpcpp/impl/codegen/async_stream_impl.h - include/grpcpp/impl/codegen/async_unary_call.h + - include/grpcpp/impl/codegen/async_unary_call_impl.h - include/grpcpp/impl/codegen/byte_buffer.h - include/grpcpp/impl/codegen/call.h - include/grpcpp/impl/codegen/call_hook.h @@ -1260,6 +1262,7 @@ filegroups: - include/grpcpp/impl/codegen/callback_common.h - include/grpcpp/impl/codegen/channel_interface.h - include/grpcpp/impl/codegen/client_callback.h + - include/grpcpp/impl/codegen/client_callback_impl.h - include/grpcpp/impl/codegen/client_context.h - include/grpcpp/impl/codegen/client_context_impl.h - include/grpcpp/impl/codegen/client_interceptor.h @@ -1282,6 +1285,7 @@ filegroups: - include/grpcpp/impl/codegen/security/auth_context.h - include/grpcpp/impl/codegen/serialization_traits.h - include/grpcpp/impl/codegen/server_callback.h + - include/grpcpp/impl/codegen/server_callback_impl.h - include/grpcpp/impl/codegen/server_context.h - include/grpcpp/impl/codegen/server_context_impl.h - include/grpcpp/impl/codegen/server_interceptor.h @@ -1293,6 +1297,7 @@ filegroups: - include/grpcpp/impl/codegen/string_ref.h - include/grpcpp/impl/codegen/stub_options.h - include/grpcpp/impl/codegen/sync_stream.h + - include/grpcpp/impl/codegen/sync_stream_impl.h - include/grpcpp/impl/codegen/time.h uses: - grpc_codegen @@ -1411,11 +1416,14 @@ filegroups: - include/grpcpp/server_posix.h - include/grpcpp/server_posix_impl.h - include/grpcpp/support/async_stream.h + - include/grpcpp/support/async_stream_impl.h - include/grpcpp/support/async_unary_call.h + - include/grpcpp/support/async_unary_call_impl.h - include/grpcpp/support/byte_buffer.h - include/grpcpp/support/channel_arguments.h - include/grpcpp/support/channel_arguments_impl.h - include/grpcpp/support/client_callback.h + - include/grpcpp/support/client_callback_impl.h - include/grpcpp/support/client_interceptor.h - include/grpcpp/support/config.h - include/grpcpp/support/interceptor.h @@ -1423,6 +1431,7 @@ filegroups: - include/grpcpp/support/proto_buffer_reader.h - include/grpcpp/support/proto_buffer_writer.h - include/grpcpp/support/server_callback.h + - include/grpcpp/support/server_callback_impl.h - include/grpcpp/support/server_interceptor.h - include/grpcpp/support/slice.h - include/grpcpp/support/status.h @@ -1430,6 +1439,7 @@ filegroups: - include/grpcpp/support/string_ref.h - include/grpcpp/support/stub_options.h - include/grpcpp/support/sync_stream.h + - include/grpcpp/support/sync_stream_impl.h - include/grpcpp/support/time.h - include/grpcpp/support/validate_service_config.h headers: diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index a09173dc8f0..6933fd2c05b 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -129,11 +129,14 @@ Pod::Spec.new do |s| 'include/grpcpp/server_posix.h', 'include/grpcpp/server_posix_impl.h', 'include/grpcpp/support/async_stream.h', + 'include/grpcpp/support/async_stream_impl.h', 'include/grpcpp/support/async_unary_call.h', + 'include/grpcpp/support/async_unary_call_impl.h', 'include/grpcpp/support/byte_buffer.h', 'include/grpcpp/support/channel_arguments.h', 'include/grpcpp/support/channel_arguments_impl.h', 'include/grpcpp/support/client_callback.h', + 'include/grpcpp/support/client_callback_impl.h', 'include/grpcpp/support/client_interceptor.h', 'include/grpcpp/support/config.h', 'include/grpcpp/support/interceptor.h', @@ -141,6 +144,7 @@ Pod::Spec.new do |s| 'include/grpcpp/support/proto_buffer_reader.h', 'include/grpcpp/support/proto_buffer_writer.h', 'include/grpcpp/support/server_callback.h', + 'include/grpcpp/support/server_callback_impl.h', 'include/grpcpp/support/server_interceptor.h', 'include/grpcpp/support/slice.h', 'include/grpcpp/support/status.h', @@ -148,11 +152,14 @@ Pod::Spec.new do |s| 'include/grpcpp/support/string_ref.h', 'include/grpcpp/support/stub_options.h', 'include/grpcpp/support/sync_stream.h', + 'include/grpcpp/support/sync_stream_impl.h', 'include/grpcpp/support/time.h', 'include/grpcpp/support/validate_service_config.h', 'include/grpcpp/impl/codegen/async_generic_service.h', 'include/grpcpp/impl/codegen/async_stream.h', + 'include/grpcpp/impl/codegen/async_stream_impl.h', 'include/grpcpp/impl/codegen/async_unary_call.h', + 'include/grpcpp/impl/codegen/async_unary_call_impl.h', 'include/grpcpp/impl/codegen/byte_buffer.h', 'include/grpcpp/impl/codegen/call.h', 'include/grpcpp/impl/codegen/call_hook.h', @@ -161,6 +168,7 @@ Pod::Spec.new do |s| 'include/grpcpp/impl/codegen/callback_common.h', 'include/grpcpp/impl/codegen/channel_interface.h', 'include/grpcpp/impl/codegen/client_callback.h', + 'include/grpcpp/impl/codegen/client_callback_impl.h', 'include/grpcpp/impl/codegen/client_context.h', 'include/grpcpp/impl/codegen/client_context_impl.h', 'include/grpcpp/impl/codegen/client_interceptor.h', @@ -183,6 +191,7 @@ Pod::Spec.new do |s| 'include/grpcpp/impl/codegen/security/auth_context.h', 'include/grpcpp/impl/codegen/serialization_traits.h', 'include/grpcpp/impl/codegen/server_callback.h', + 'include/grpcpp/impl/codegen/server_callback_impl.h', 'include/grpcpp/impl/codegen/server_context.h', 'include/grpcpp/impl/codegen/server_context_impl.h', 'include/grpcpp/impl/codegen/server_interceptor.h', @@ -194,6 +203,7 @@ Pod::Spec.new do |s| 'include/grpcpp/impl/codegen/string_ref.h', 'include/grpcpp/impl/codegen/stub_options.h', 'include/grpcpp/impl/codegen/sync_stream.h', + 'include/grpcpp/impl/codegen/sync_stream_impl.h', 'include/grpcpp/impl/codegen/time.h', 'include/grpcpp/impl/codegen/sync.h' end diff --git a/include/grpcpp/channel_impl.h b/include/grpcpp/channel_impl.h index a7eee2b8981..9ff3118645f 100644 --- a/include/grpcpp/channel_impl.h +++ b/include/grpcpp/channel_impl.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -86,22 +86,23 @@ class Channel final : public ::grpc::ChannelInterface, ::grpc::internal::Call CreateCall(const ::grpc::internal::RpcMethod& method, ::grpc_impl::ClientContext* context, - ::grpc::CompletionQueue* cq) override; + ::grpc_impl::CompletionQueue* cq) override; void PerformOpsOnCall(::grpc::internal::CallOpSetInterface* ops, ::grpc::internal::Call* call) override; void* RegisterMethod(const char* method) override; void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline, - ::grpc::CompletionQueue* cq, void* tag) override; + ::grpc_impl::CompletionQueue* cq, + void* tag) override; bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline) override; - ::grpc::CompletionQueue* CallbackCQ() override; + ::grpc_impl::CompletionQueue* CallbackCQ() override; ::grpc::internal::Call CreateCallInternal( const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, ::grpc::CompletionQueue* cq, + ::grpc_impl::ClientContext* context, ::grpc_impl::CompletionQueue* cq, size_t interceptor_pos) override; const grpc::string host_; @@ -114,7 +115,7 @@ class Channel final : public ::grpc::ChannelInterface, // with this channel (if any). It is set on the first call to CallbackCQ(). // It is _not owned_ by the channel; ownership belongs with its internal // shutdown callback tag (invoked when the CQ is fully shutdown). - ::grpc::CompletionQueue* callback_cq_ = nullptr; + ::grpc_impl::CompletionQueue* callback_cq_ = nullptr; std::vector< std::unique_ptr<::grpc::experimental::ClientInterceptorFactoryInterface>> diff --git a/include/grpcpp/generic/generic_stub_impl.h b/include/grpcpp/generic/generic_stub_impl.h index fdbc0d0a272..e670fcaa654 100644 --- a/include/grpcpp/generic/generic_stub_impl.h +++ b/include/grpcpp/generic/generic_stub_impl.h @@ -22,17 +22,20 @@ #include #include -#include -#include +#include +#include #include -#include +#include #include +#include + namespace grpc { -typedef ClientAsyncReaderWriter +typedef ::grpc_impl::ClientAsyncReaderWriter GenericClientAsyncReaderWriter; -typedef ClientAsyncResponseReader GenericClientAsyncResponseReader; +typedef ::grpc_impl::ClientAsyncResponseReader + GenericClientAsyncResponseReader; } // namespace grpc namespace grpc_impl { class CompletionQueue; @@ -50,15 +53,15 @@ class GenericStub final { /// succeeded (i.e. the call won't proceed if the return value is nullptr). std::unique_ptr PrepareCall( grpc::ClientContext* context, const grpc::string& method, - grpc::CompletionQueue* cq); + CompletionQueue* cq); /// Setup a unary call to a named method \a method using \a context, and don't /// start it. Let it be started explicitly with StartCall. /// The return value only indicates whether or not registration of the call /// succeeded (i.e. the call won't proceed if the return value is nullptr). std::unique_ptr PrepareUnaryCall( - grpc::ClientContext* context, const grpc::string& method, - const grpc::ByteBuffer& request, grpc::CompletionQueue* cq); + grpc_impl::ClientContext* context, const grpc::string& method, + const grpc::ByteBuffer& request, CompletionQueue* cq); /// DEPRECATED for multi-threaded use /// Begin a call to a named method \a method using \a context. @@ -67,8 +70,8 @@ class GenericStub final { /// The return value only indicates whether or not registration of the call /// succeeded (i.e. the call won't proceed if the return value is nullptr). std::unique_ptr Call( - grpc::ClientContext* context, const grpc::string& method, - grpc::CompletionQueue* cq, void* tag); + grpc_impl::ClientContext* context, const grpc::string& method, + CompletionQueue* cq, void* tag); /// NOTE: class experimental_type is not part of the public API of this class /// TODO(vjpai): Move these contents to the public API of GenericStub when @@ -79,23 +82,25 @@ class GenericStub final { /// Setup and start a unary call to a named method \a method using /// \a context and specifying the \a request and \a response buffers. - void UnaryCall(grpc::ClientContext* context, const grpc::string& method, - const grpc::ByteBuffer* request, grpc::ByteBuffer* response, + void UnaryCall(grpc_impl::ClientContext* context, + const grpc::string& method, const grpc::ByteBuffer* request, + grpc::ByteBuffer* response, std::function on_completion); /// Setup and start a unary call to a named method \a method using /// \a context and specifying the \a request and \a response buffers. - void UnaryCall(grpc::ClientContext* context, const grpc::string& method, - const grpc::ByteBuffer* request, grpc::ByteBuffer* response, - grpc::experimental::ClientUnaryReactor* reactor); + void UnaryCall(grpc_impl::ClientContext* context, + const grpc::string& method, const grpc::ByteBuffer* request, + grpc::ByteBuffer* response, + grpc_impl::experimental::ClientUnaryReactor* reactor); /// Setup a call to a named method \a method using \a context and tied to /// \a reactor . Like any other bidi streaming RPC, it will not be activated /// until StartCall is invoked on its reactor. void PrepareBidiStreamingCall( - grpc::ClientContext* context, const grpc::string& method, - grpc::experimental::ClientBidiReactor* reactor); + grpc_impl::ClientContext* context, const grpc::string& method, + grpc_impl::experimental::ClientBidiReactor* reactor); private: GenericStub* stub_; diff --git a/include/grpcpp/impl/codegen/async_generic_service.h b/include/grpcpp/impl/codegen/async_generic_service.h index d8e6f49b2f3..7c720ce3c23 100644 --- a/include/grpcpp/impl/codegen/async_generic_service.h +++ b/include/grpcpp/impl/codegen/async_generic_service.h @@ -19,19 +19,21 @@ #ifndef GRPCPP_IMPL_CODEGEN_ASYNC_GENERIC_SERVICE_H #define GRPCPP_IMPL_CODEGEN_ASYNC_GENERIC_SERVICE_H -#include +#include #include -#include +#include struct grpc_server; namespace grpc { -typedef ServerAsyncReaderWriter +typedef ::grpc_impl::ServerAsyncReaderWriter GenericServerAsyncReaderWriter; -typedef ServerAsyncResponseWriter GenericServerAsyncResponseWriter; -typedef ServerAsyncReader GenericServerAsyncReader; -typedef ServerAsyncWriter GenericServerAsyncWriter; +typedef ::grpc_impl::ServerAsyncResponseWriter + GenericServerAsyncResponseWriter; +typedef ::grpc_impl::ServerAsyncReader + GenericServerAsyncReader; +typedef ::grpc_impl::ServerAsyncWriter GenericServerAsyncWriter; class GenericServerContext final : public ::grpc_impl::ServerContext { public: @@ -75,8 +77,9 @@ class AsyncGenericService final { void RequestCall(GenericServerContext* ctx, GenericServerAsyncReaderWriter* reader_writer, - CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag); + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag); private: friend class grpc_impl::Server; @@ -91,7 +94,8 @@ namespace experimental { /// GenericServerContext rather than a ServerContext. All other reaction and /// operation initiation APIs are the same as ServerBidiReactor. class ServerGenericBidiReactor - : public ServerBidiReactor { + : public ::grpc_impl::experimental::ServerBidiReactor { public: /// Similar to ServerBidiReactor::OnStarted except for argument type. /// @@ -137,8 +141,10 @@ class CallbackGenericService { private: friend class ::grpc_impl::Server; - internal::CallbackBidiHandler* Handler() { - return new internal::CallbackBidiHandler( + ::grpc_impl::internal::CallbackBidiHandler* + Handler() { + return new ::grpc_impl::internal::CallbackBidiHandler( [this] { return CreateReactor(); }); } diff --git a/include/grpcpp/impl/codegen/async_stream.h b/include/grpcpp/impl/codegen/async_stream.h index 417dceb587f..14dfe67962e 100644 --- a/include/grpcpp/impl/codegen/async_stream.h +++ b/include/grpcpp/impl/codegen/async_stream.h @@ -19,1117 +19,47 @@ #ifndef GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H #define GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H -#include -#include -#include -#include -#include -#include +#include namespace grpc { - -namespace internal { -/// Common interface for all client side asynchronous streaming. -class ClientAsyncStreamingInterface { - public: - virtual ~ClientAsyncStreamingInterface() {} - - /// Start the call that was set up by the constructor, but only if the - /// constructor was invoked through the "Prepare" API which doesn't actually - /// start the call - virtual void StartCall(void* tag) = 0; - - /// Request notification of the reading of the initial metadata. Completion - /// will be notified by \a tag on the associated completion queue. - /// This call is optional, but if it is used, it cannot be used concurrently - /// with or after the \a AsyncReaderInterface::Read method. - /// - /// \param[in] tag Tag identifying this request. - virtual void ReadInitialMetadata(void* tag) = 0; - - /// Indicate that the stream is to be finished and request notification for - /// when the call has been ended. - /// Should not be used concurrently with other operations. - /// - /// It is appropriate to call this method when both: - /// * the client side has no more message to send - /// (this can be declared implicitly by calling this method, or - /// explicitly through an earlier call to the WritesDone method - /// of the class in use, e.g. \a ClientAsyncWriterInterface::WritesDone or - /// \a ClientAsyncReaderWriterInterface::WritesDone). - /// * there are no more messages to be received from the server (this can - /// be known implicitly by the calling code, or explicitly from an - /// earlier call to \a AsyncReaderInterface::Read that yielded a failed - /// result, e.g. cq->Next(&read_tag, &ok) filled in 'ok' with 'false'). - /// - /// The tag will be returned when either: - /// - all incoming messages have been read and the server has returned - /// a status. - /// - the server has returned a non-OK status. - /// - the call failed for some reason and the library generated a - /// status. - /// - /// Note that implementations of this method attempt to receive initial - /// metadata from the server if initial metadata hasn't yet been received. - /// - /// \param[in] tag Tag identifying this request. - /// \param[out] status To be updated with the operation status. - virtual void Finish(Status* status, void* tag) = 0; -}; - -/// An interface that yields a sequence of messages of type \a R. template -class AsyncReaderInterface { - public: - virtual ~AsyncReaderInterface() {} - - /// Read a message of type \a R into \a msg. Completion will be notified by \a - /// tag on the associated completion queue. - /// This is thread-safe with respect to \a Write or \a WritesDone methods. It - /// should not be called concurrently with other streaming APIs - /// on the same stream. It is not meaningful to call it concurrently - /// with another \a AsyncReaderInterface::Read on the same stream since reads - /// on the same stream are delivered in order. - /// - /// \param[out] msg Where to eventually store the read message. - /// \param[in] tag The tag identifying the operation. - /// - /// Side effect: note that this method attempt to receive initial metadata for - /// a stream if it hasn't yet been received. - virtual void Read(R* msg, void* tag) = 0; -}; - -/// An interface that can be fed a sequence of messages of type \a W. -template -class AsyncWriterInterface { - public: - virtual ~AsyncWriterInterface() {} - - /// Request the writing of \a msg with identifying tag \a tag. - /// - /// Only one write may be outstanding at any given time. This means that - /// after calling Write, one must wait to receive \a tag from the completion - /// queue BEFORE calling Write again. - /// This is thread-safe with respect to \a AsyncReaderInterface::Read - /// - /// gRPC doesn't take ownership or a reference to \a msg, so it is safe to - /// to deallocate once Write returns. - /// - /// \param[in] msg The message to be written. - /// \param[in] tag The tag identifying the operation. - virtual void Write(const W& msg, void* tag) = 0; - - /// Request the writing of \a msg using WriteOptions \a options with - /// identifying tag \a tag. - /// - /// Only one write may be outstanding at any given time. This means that - /// after calling Write, one must wait to receive \a tag from the completion - /// queue BEFORE calling Write again. - /// WriteOptions \a options is used to set the write options of this message. - /// This is thread-safe with respect to \a AsyncReaderInterface::Read - /// - /// gRPC doesn't take ownership or a reference to \a msg, so it is safe to - /// to deallocate once Write returns. - /// - /// \param[in] msg The message to be written. - /// \param[in] options The WriteOptions to be used to write this message. - /// \param[in] tag The tag identifying the operation. - virtual void Write(const W& msg, WriteOptions options, void* tag) = 0; - - /// Request the writing of \a msg and coalesce it with the writing - /// of trailing metadata, using WriteOptions \a options with - /// identifying tag \a tag. - /// - /// For client, WriteLast is equivalent of performing Write and - /// WritesDone in a single step. - /// For server, WriteLast buffers the \a msg. The writing of \a msg is held - /// until Finish is called, where \a msg and trailing metadata are coalesced - /// and write is initiated. Note that WriteLast can only buffer \a msg up to - /// the flow control window size. If \a msg size is larger than the window - /// size, it will be sent on wire without buffering. - /// - /// gRPC doesn't take ownership or a reference to \a msg, so it is safe to - /// to deallocate once Write returns. - /// - /// \param[in] msg The message to be written. - /// \param[in] options The WriteOptions to be used to write this message. - /// \param[in] tag The tag identifying the operation. - void WriteLast(const W& msg, WriteOptions options, void* tag) { - Write(msg, options.set_last_message(), tag); - } -}; - -} // namespace internal +using ClientAsyncReaderInterface = ::grpc_impl::ClientAsyncReaderInterface; template -class ClientAsyncReaderInterface - : public internal::ClientAsyncStreamingInterface, - public internal::AsyncReaderInterface {}; - -namespace internal { -template -class ClientAsyncReaderFactory { - public: - /// Create a stream object. - /// Write the first request out if \a start is set. - /// \a tag will be notified on \a cq when the call has been started and - /// \a request has been written out. If \a start is not set, \a tag must be - /// nullptr and the actual call must be initiated by StartCall - /// Note that \a context will be used to fill in custom initial metadata - /// used to send to the server when starting the call. - template - static ClientAsyncReader* Create(ChannelInterface* channel, - CompletionQueue* cq, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, - const W& request, bool start, void* tag) { - ::grpc::internal::Call call = channel->CreateCall(method, context, cq); - return new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(ClientAsyncReader))) - ClientAsyncReader(call, context, request, start, tag); - } -}; -} // namespace internal - -/// Async client-side API for doing server-streaming RPCs, -/// where the incoming message stream coming from the server has -/// messages of type \a R. -template -class ClientAsyncReader final : public ClientAsyncReaderInterface { - public: - // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { - assert(size == sizeof(ClientAsyncReader)); - } - - // This operator should never be called as the memory should be freed as part - // of the arena destruction. It only exists to provide a matching operator - // delete to the operator new so that some compilers will not complain (see - // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this - // there are no tests catching the compiler warning. - static void operator delete(void*, void*) { assert(0); } - - void StartCall(void* tag) override { - assert(!started_); - started_ = true; - StartCallInternal(tag); - } - - /// See the \a ClientAsyncStreamingInterface.ReadInitialMetadata - /// method for semantics. - /// - /// Side effect: - /// - upon receiving initial metadata from the server, - /// the \a ClientContext associated with this call is updated, and the - /// calling code can access the received metadata through the - /// \a ClientContext. - void ReadInitialMetadata(void* tag) override { - assert(started_); - GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); - - meta_ops_.set_output_tag(tag); - meta_ops_.RecvInitialMetadata(context_); - call_.PerformOps(&meta_ops_); - } - - void Read(R* msg, void* tag) override { - assert(started_); - read_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - read_ops_.RecvInitialMetadata(context_); - } - read_ops_.RecvMessage(msg); - call_.PerformOps(&read_ops_); - } - - /// See the \a ClientAsyncStreamingInterface.Finish method for semantics. - /// - /// Side effect: - /// - the \a ClientContext associated with this call is updated with - /// possible initial and trailing metadata received from the server. - void Finish(Status* status, void* tag) override { - assert(started_); - finish_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - finish_ops_.RecvInitialMetadata(context_); - } - finish_ops_.ClientRecvStatus(context_, status); - call_.PerformOps(&finish_ops_); - } - - private: - friend class internal::ClientAsyncReaderFactory; - template - ClientAsyncReader(::grpc::internal::Call call, - ::grpc_impl::ClientContext* context, const W& request, - bool start, void* tag) - : context_(context), call_(call), started_(start) { - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(init_ops_.SendMessage(request).ok()); - init_ops_.ClientSendClose(); - if (start) { - StartCallInternal(tag); - } else { - assert(tag == nullptr); - } - } - - void StartCallInternal(void* tag) { - init_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - init_ops_.set_output_tag(tag); - call_.PerformOps(&init_ops_); - } - - ::grpc_impl::ClientContext* context_; - ::grpc::internal::Call call_; - bool started_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpClientSendClose> - init_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> - meta_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpRecvMessage> - read_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpClientRecvStatus> - finish_ops_; -}; - -/// Common interface for client side asynchronous writing. -template -class ClientAsyncWriterInterface - : public internal::ClientAsyncStreamingInterface, - public internal::AsyncWriterInterface { - public: - /// Signal the client is done with the writes (half-close the client stream). - /// Thread-safe with respect to \a AsyncReaderInterface::Read - /// - /// \param[in] tag The tag identifying the operation. - virtual void WritesDone(void* tag) = 0; -}; - -namespace internal { -template -class ClientAsyncWriterFactory { - public: - /// Create a stream object. - /// Start the RPC if \a start is set - /// \a tag will be notified on \a cq when the call has been started (i.e. - /// intitial metadata sent) and \a request has been written out. - /// If \a start is not set, \a tag must be nullptr and the actual call - /// must be initiated by StartCall - /// Note that \a context will be used to fill in custom initial metadata - /// used to send to the server when starting the call. - /// \a response will be filled in with the single expected response - /// message from the server upon a successful call to the \a Finish - /// method of this instance. - template - static ClientAsyncWriter* Create(ChannelInterface* channel, - CompletionQueue* cq, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, - R* response, bool start, void* tag) { - ::grpc::internal::Call call = channel->CreateCall(method, context, cq); - return new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(ClientAsyncWriter))) - ClientAsyncWriter(call, context, response, start, tag); - } -}; -} // namespace internal - -/// Async API on the client side for doing client-streaming RPCs, -/// where the outgoing message stream going to the server contains -/// messages of type \a W. -template -class ClientAsyncWriter final : public ClientAsyncWriterInterface { - public: - // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { - assert(size == sizeof(ClientAsyncWriter)); - } - - // This operator should never be called as the memory should be freed as part - // of the arena destruction. It only exists to provide a matching operator - // delete to the operator new so that some compilers will not complain (see - // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this - // there are no tests catching the compiler warning. - static void operator delete(void*, void*) { assert(0); } - - void StartCall(void* tag) override { - assert(!started_); - started_ = true; - StartCallInternal(tag); - } - - /// See the \a ClientAsyncStreamingInterface.ReadInitialMetadata method for - /// semantics. - /// - /// Side effect: - /// - upon receiving initial metadata from the server, the \a ClientContext - /// associated with this call is updated, and the calling code can access - /// the received metadata through the \a ClientContext. - void ReadInitialMetadata(void* tag) override { - assert(started_); - GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); - - meta_ops_.set_output_tag(tag); - meta_ops_.RecvInitialMetadata(context_); - call_.PerformOps(&meta_ops_); - } - - void Write(const W& msg, void* tag) override { - assert(started_); - write_ops_.set_output_tag(tag); - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); - call_.PerformOps(&write_ops_); - } - - void Write(const W& msg, WriteOptions options, void* tag) override { - assert(started_); - write_ops_.set_output_tag(tag); - if (options.is_last_message()) { - options.set_buffer_hint(); - write_ops_.ClientSendClose(); - } - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); - call_.PerformOps(&write_ops_); - } - - void WritesDone(void* tag) override { - assert(started_); - write_ops_.set_output_tag(tag); - write_ops_.ClientSendClose(); - call_.PerformOps(&write_ops_); - } - - /// See the \a ClientAsyncStreamingInterface.Finish method for semantics. - /// - /// Side effect: - /// - the \a ClientContext associated with this call is updated with - /// possible initial and trailing metadata received from the server. - /// - attempts to fill in the \a response parameter passed to this class's - /// constructor with the server's response message. - void Finish(Status* status, void* tag) override { - assert(started_); - finish_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - finish_ops_.RecvInitialMetadata(context_); - } - finish_ops_.ClientRecvStatus(context_, status); - call_.PerformOps(&finish_ops_); - } - - private: - friend class internal::ClientAsyncWriterFactory; - template - ClientAsyncWriter(::grpc::internal::Call call, - ::grpc_impl::ClientContext* context, R* response, - bool start, void* tag) - : context_(context), call_(call), started_(start) { - finish_ops_.RecvMessage(response); - finish_ops_.AllowNoMessage(); - if (start) { - StartCallInternal(tag); - } else { - assert(tag == nullptr); - } - } - - void StartCallInternal(void* tag) { - write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - // if corked bit is set in context, we just keep the initial metadata - // buffered up to coalesce with later message send. No op is performed. - if (!context_->initial_metadata_corked_) { - write_ops_.set_output_tag(tag); - call_.PerformOps(&write_ops_); - } - } - - ::grpc_impl::ClientContext* context_; - ::grpc::internal::Call call_; - bool started_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> - meta_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpClientSendClose> - write_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpGenericRecvMessage, - ::grpc::internal::CallOpClientRecvStatus> - finish_ops_; -}; - -/// Async client-side interface for bi-directional streaming, -/// where the client-to-server message stream has messages of type \a W, -/// and the server-to-client message stream has messages of type \a R. -template -class ClientAsyncReaderWriterInterface - : public internal::ClientAsyncStreamingInterface, - public internal::AsyncWriterInterface, - public internal::AsyncReaderInterface { - public: - /// Signal the client is done with the writes (half-close the client stream). - /// Thread-safe with respect to \a AsyncReaderInterface::Read - /// - /// \param[in] tag The tag identifying the operation. - virtual void WritesDone(void* tag) = 0; -}; - -namespace internal { -template -class ClientAsyncReaderWriterFactory { - public: - /// Create a stream object. - /// Start the RPC request if \a start is set. - /// \a tag will be notified on \a cq when the call has been started (i.e. - /// intitial metadata sent). If \a start is not set, \a tag must be - /// nullptr and the actual call must be initiated by StartCall - /// Note that \a context will be used to fill in custom initial metadata - /// used to send to the server when starting the call. - static ClientAsyncReaderWriter* Create( - ChannelInterface* channel, CompletionQueue* cq, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, bool start, void* tag) { - ::grpc::internal::Call call = channel->CreateCall(method, context, cq); - - return new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(ClientAsyncReaderWriter))) - ClientAsyncReaderWriter(call, context, start, tag); - } -}; -} // namespace internal - -/// Async client-side interface for bi-directional streaming, -/// where the outgoing message stream going to the server -/// has messages of type \a W, and the incoming message stream coming -/// from the server has messages of type \a R. -template -class ClientAsyncReaderWriter final - : public ClientAsyncReaderWriterInterface { - public: - // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { - assert(size == sizeof(ClientAsyncReaderWriter)); - } - - // This operator should never be called as the memory should be freed as part - // of the arena destruction. It only exists to provide a matching operator - // delete to the operator new so that some compilers will not complain (see - // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this - // there are no tests catching the compiler warning. - static void operator delete(void*, void*) { assert(0); } - - void StartCall(void* tag) override { - assert(!started_); - started_ = true; - StartCallInternal(tag); - } - - /// See the \a ClientAsyncStreamingInterface.ReadInitialMetadata method - /// for semantics of this method. - /// - /// Side effect: - /// - upon receiving initial metadata from the server, the \a ClientContext - /// is updated with it, and then the receiving initial metadata can - /// be accessed through this \a ClientContext. - void ReadInitialMetadata(void* tag) override { - assert(started_); - GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); - - meta_ops_.set_output_tag(tag); - meta_ops_.RecvInitialMetadata(context_); - call_.PerformOps(&meta_ops_); - } - - void Read(R* msg, void* tag) override { - assert(started_); - read_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - read_ops_.RecvInitialMetadata(context_); - } - read_ops_.RecvMessage(msg); - call_.PerformOps(&read_ops_); - } - - void Write(const W& msg, void* tag) override { - assert(started_); - write_ops_.set_output_tag(tag); - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); - call_.PerformOps(&write_ops_); - } - - void Write(const W& msg, WriteOptions options, void* tag) override { - assert(started_); - write_ops_.set_output_tag(tag); - if (options.is_last_message()) { - options.set_buffer_hint(); - write_ops_.ClientSendClose(); - } - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); - call_.PerformOps(&write_ops_); - } - - void WritesDone(void* tag) override { - assert(started_); - write_ops_.set_output_tag(tag); - write_ops_.ClientSendClose(); - call_.PerformOps(&write_ops_); - } - - /// See the \a ClientAsyncStreamingInterface.Finish method for semantics. - /// Side effect - /// - the \a ClientContext associated with this call is updated with - /// possible initial and trailing metadata sent from the server. - void Finish(Status* status, void* tag) override { - assert(started_); - finish_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - finish_ops_.RecvInitialMetadata(context_); - } - finish_ops_.ClientRecvStatus(context_, status); - call_.PerformOps(&finish_ops_); - } - - private: - friend class internal::ClientAsyncReaderWriterFactory; - ClientAsyncReaderWriter(::grpc::internal::Call call, - ::grpc_impl::ClientContext* context, bool start, - void* tag) - : context_(context), call_(call), started_(start) { - if (start) { - StartCallInternal(tag); - } else { - assert(tag == nullptr); - } - } - - void StartCallInternal(void* tag) { - write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - // if corked bit is set in context, we just keep the initial metadata - // buffered up to coalesce with later message send. No op is performed. - if (!context_->initial_metadata_corked_) { - write_ops_.set_output_tag(tag); - call_.PerformOps(&write_ops_); - } - } - - ::grpc_impl::ClientContext* context_; - ::grpc::internal::Call call_; - bool started_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> - meta_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpRecvMessage> - read_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpClientSendClose> - write_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpClientRecvStatus> - finish_ops_; -}; - -template -class ServerAsyncReaderInterface - : public internal::ServerAsyncStreamingInterface, - public internal::AsyncReaderInterface { - public: - /// Indicate that the stream is to be finished with a certain status code - /// and also send out \a msg response to the client. - /// Request notification for when the server has sent the response and the - /// appropriate signals to the client to end the call. - /// Should not be used concurrently with other operations. - /// - /// It is appropriate to call this method when: - /// * all messages from the client have been received (either known - /// implictly, or explicitly because a previous - /// \a AsyncReaderInterface::Read operation with a non-ok result, - /// e.g., cq->Next(&read_tag, &ok) filled in 'ok' with 'false'). - /// - /// This operation will end when the server has finished sending out initial - /// metadata (if not sent already), response message, and status, or if - /// some failure occurred when trying to do so. - /// - /// gRPC doesn't take ownership or a reference to \a msg or \a status, so it - /// is safe to deallocate once Finish returns. - /// - /// \param[in] tag Tag identifying this request. - /// \param[in] status To be sent to the client as the result of this call. - /// \param[in] msg To be sent to the client as the response for this call. - virtual void Finish(const W& msg, const Status& status, void* tag) = 0; - - /// Indicate that the stream is to be finished with a certain - /// non-OK status code. - /// Request notification for when the server has sent the appropriate - /// signals to the client to end the call. - /// Should not be used concurrently with other operations. - /// - /// This call is meant to end the call with some error, and can be called at - /// any point that the server would like to "fail" the call (though note - /// this shouldn't be called concurrently with any other "sending" call, like - /// \a AsyncWriterInterface::Write). - /// - /// This operation will end when the server has finished sending out initial - /// metadata (if not sent already), and status, or if some failure occurred - /// when trying to do so. - /// - /// gRPC doesn't take ownership or a reference to \a status, so it is safe to - /// to deallocate once FinishWithError returns. - /// - /// \param[in] tag Tag identifying this request. - /// \param[in] status To be sent to the client as the result of this call. - /// - Note: \a status must have a non-OK code. - virtual void FinishWithError(const Status& status, void* tag) = 0; -}; - -/// Async server-side API for doing client-streaming RPCs, -/// where the incoming message stream from the client has messages of type \a R, -/// and the single response message sent from the server is type \a W. -template -class ServerAsyncReader final : public ServerAsyncReaderInterface { - public: - explicit ServerAsyncReader(::grpc_impl::ServerContext* ctx) - : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} - - /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. - /// - /// Implicit input parameter: - /// - The initial metadata that will be sent to the client from this op will - /// be taken from the \a ServerContext associated with the call. - void SendInitialMetadata(void* tag) override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - - meta_ops_.set_output_tag(tag); - meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - call_.PerformOps(&meta_ops_); - } - - void Read(R* msg, void* tag) override { - read_ops_.set_output_tag(tag); - read_ops_.RecvMessage(msg); - call_.PerformOps(&read_ops_); - } - - /// See the \a ServerAsyncReaderInterface.Read method for semantics - /// - /// Side effect: - /// - also sends initial metadata if not alreay sent. - /// - uses the \a ServerContext associated with this call to send possible - /// initial and trailing metadata. - /// - /// Note: \a msg is not sent if \a status has a non-OK code. - /// - /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it - /// is safe to deallocate once Finish returns. - void Finish(const W& msg, const Status& status, void* tag) override { - finish_ops_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - // The response is dropped if the status is not OK. - if (status.ok()) { - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, - finish_ops_.SendMessage(msg)); - } else { - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); - } - call_.PerformOps(&finish_ops_); - } - - /// See the \a ServerAsyncReaderInterface.Read method for semantics - /// - /// Side effect: - /// - also sends initial metadata if not alreay sent. - /// - uses the \a ServerContext associated with this call to send possible - /// initial and trailing metadata. - /// - /// gRPC doesn't take ownership or a reference to \a status, so it is safe to - /// to deallocate once FinishWithError returns. - void FinishWithError(const Status& status, void* tag) override { - GPR_CODEGEN_ASSERT(!status.ok()); - finish_ops_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); - call_.PerformOps(&finish_ops_); - } - - private: - void BindCall(::grpc::internal::Call* call) override { call_ = *call; } - - ::grpc::internal::Call call_; - ::grpc_impl::ServerContext* ctx_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> - meta_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage> read_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpServerSendStatus> - finish_ops_; -}; +using ClientAsyncReader = ::grpc_impl::ClientAsyncReader; template -class ServerAsyncWriterInterface - : public internal::ServerAsyncStreamingInterface, - public internal::AsyncWriterInterface { - public: - /// Indicate that the stream is to be finished with a certain status code. - /// Request notification for when the server has sent the appropriate - /// signals to the client to end the call. - /// Should not be used concurrently with other operations. - /// - /// It is appropriate to call this method when either: - /// * all messages from the client have been received (either known - /// implictly, or explicitly because a previous \a - /// AsyncReaderInterface::Read operation with a non-ok - /// result (e.g., cq->Next(&read_tag, &ok) filled in 'ok' with 'false'. - /// * it is desired to end the call early with some non-OK status code. - /// - /// This operation will end when the server has finished sending out initial - /// metadata (if not sent already), response message, and status, or if - /// some failure occurred when trying to do so. - /// - /// gRPC doesn't take ownership or a reference to \a status, so it is safe to - /// to deallocate once Finish returns. - /// - /// \param[in] tag Tag identifying this request. - /// \param[in] status To be sent to the client as the result of this call. - virtual void Finish(const Status& status, void* tag) = 0; +using ClientAsyncWriterInterface = ::grpc_impl::ClientAsyncWriterInterface; - /// Request the writing of \a msg and coalesce it with trailing metadata which - /// contains \a status, using WriteOptions options with - /// identifying tag \a tag. - /// - /// WriteAndFinish is equivalent of performing WriteLast and Finish - /// in a single step. - /// - /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it - /// is safe to deallocate once WriteAndFinish returns. - /// - /// \param[in] msg The message to be written. - /// \param[in] options The WriteOptions to be used to write this message. - /// \param[in] status The Status that server returns to client. - /// \param[in] tag The tag identifying the operation. - virtual void WriteAndFinish(const W& msg, WriteOptions options, - const Status& status, void* tag) = 0; -}; - -/// Async server-side API for doing server streaming RPCs, -/// where the outgoing message stream from the server has messages of type \a W. template -class ServerAsyncWriter final : public ServerAsyncWriterInterface { - public: - explicit ServerAsyncWriter(::grpc_impl::ServerContext* ctx) - : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} +using ClientAsyncWriter = ::grpc_impl::ClientAsyncWriter; - /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. - /// - /// Implicit input parameter: - /// - The initial metadata that will be sent to the client from this op will - /// be taken from the \a ServerContext associated with the call. - /// - /// \param[in] tag Tag identifying this request. - void SendInitialMetadata(void* tag) override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - - meta_ops_.set_output_tag(tag); - meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - call_.PerformOps(&meta_ops_); - } - - void Write(const W& msg, void* tag) override { - write_ops_.set_output_tag(tag); - EnsureInitialMetadataSent(&write_ops_); - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); - call_.PerformOps(&write_ops_); - } - - void Write(const W& msg, WriteOptions options, void* tag) override { - write_ops_.set_output_tag(tag); - if (options.is_last_message()) { - options.set_buffer_hint(); - } - - EnsureInitialMetadataSent(&write_ops_); - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); - call_.PerformOps(&write_ops_); - } - - /// See the \a ServerAsyncWriterInterface.WriteAndFinish method for semantics. - /// - /// Implicit input parameter: - /// - the \a ServerContext associated with this call is used - /// for sending trailing (and initial) metadata to the client. - /// - /// Note: \a status must have an OK code. - /// - /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it - /// is safe to deallocate once WriteAndFinish returns. - void WriteAndFinish(const W& msg, WriteOptions options, const Status& status, - void* tag) override { - write_ops_.set_output_tag(tag); - EnsureInitialMetadataSent(&write_ops_); - options.set_buffer_hint(); - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); - write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); - call_.PerformOps(&write_ops_); - } - - /// See the \a ServerAsyncWriterInterface.Finish method for semantics. - /// - /// Implicit input parameter: - /// - the \a ServerContext associated with this call is used for sending - /// trailing (and initial if not already sent) metadata to the client. - /// - /// Note: there are no restrictions are the code of - /// \a status,it may be non-OK - /// - /// gRPC doesn't take ownership or a reference to \a status, so it is safe to - /// to deallocate once Finish returns. - void Finish(const Status& status, void* tag) override { - finish_ops_.set_output_tag(tag); - EnsureInitialMetadataSent(&finish_ops_); - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); - call_.PerformOps(&finish_ops_); - } - - private: - void BindCall(::grpc::internal::Call* call) override { call_ = *call; } - - template - void EnsureInitialMetadataSent(T* ops) { - if (!ctx_->sent_initial_metadata_) { - ops->SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - ops->set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - } - - ::grpc::internal::Call call_; - ::grpc_impl::ServerContext* ctx_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> - meta_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpServerSendStatus> - write_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpServerSendStatus> - finish_ops_; -}; - -/// Server-side interface for asynchronous bi-directional streaming. template -class ServerAsyncReaderWriterInterface - : public internal::ServerAsyncStreamingInterface, - public internal::AsyncWriterInterface, - public internal::AsyncReaderInterface { - public: - /// Indicate that the stream is to be finished with a certain status code. - /// Request notification for when the server has sent the appropriate - /// signals to the client to end the call. - /// Should not be used concurrently with other operations. - /// - /// It is appropriate to call this method when either: - /// * all messages from the client have been received (either known - /// implictly, or explicitly because a previous \a - /// AsyncReaderInterface::Read operation - /// with a non-ok result (e.g., cq->Next(&read_tag, &ok) filled in 'ok' - /// with 'false'. - /// * it is desired to end the call early with some non-OK status code. - /// - /// This operation will end when the server has finished sending out initial - /// metadata (if not sent already), response message, and status, or if some - /// failure occurred when trying to do so. - /// - /// gRPC doesn't take ownership or a reference to \a status, so it is safe to - /// to deallocate once Finish returns. - /// - /// \param[in] tag Tag identifying this request. - /// \param[in] status To be sent to the client as the result of this call. - virtual void Finish(const Status& status, void* tag) = 0; +using ClientAsyncReaderWriterInterface = + ::grpc_impl::ClientAsyncReaderWriterInterface; - /// Request the writing of \a msg and coalesce it with trailing metadata which - /// contains \a status, using WriteOptions options with - /// identifying tag \a tag. - /// - /// WriteAndFinish is equivalent of performing WriteLast and Finish in a - /// single step. - /// - /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it - /// is safe to deallocate once WriteAndFinish returns. - /// - /// \param[in] msg The message to be written. - /// \param[in] options The WriteOptions to be used to write this message. - /// \param[in] status The Status that server returns to client. - /// \param[in] tag The tag identifying the operation. - virtual void WriteAndFinish(const W& msg, WriteOptions options, - const Status& status, void* tag) = 0; -}; - -/// Async server-side API for doing bidirectional streaming RPCs, -/// where the incoming message stream coming from the client has messages of -/// type \a R, and the outgoing message stream coming from the server has -/// messages of type \a W. template -class ServerAsyncReaderWriter final - : public ServerAsyncReaderWriterInterface { - public: - explicit ServerAsyncReaderWriter(::grpc_impl::ServerContext* ctx) - : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} +using ClientAsyncReaderWriter = ::grpc_impl::ClientAsyncReaderWriter; - /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. - /// - /// Implicit input parameter: - /// - The initial metadata that will be sent to the client from this op will - /// be taken from the \a ServerContext associated with the call. - /// - /// \param[in] tag Tag identifying this request. - void SendInitialMetadata(void* tag) override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); +template +using ServerAsyncReaderInterface = + ::grpc_impl::ServerAsyncReaderInterface; - meta_ops_.set_output_tag(tag); - meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - call_.PerformOps(&meta_ops_); - } +template +using ServerAsyncReader = ::grpc_impl::ServerAsyncReader; - void Read(R* msg, void* tag) override { - read_ops_.set_output_tag(tag); - read_ops_.RecvMessage(msg); - call_.PerformOps(&read_ops_); - } +template +using ServerAsyncWriterInterface = ::grpc_impl::ServerAsyncWriterInterface; - void Write(const W& msg, void* tag) override { - write_ops_.set_output_tag(tag); - EnsureInitialMetadataSent(&write_ops_); - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); - call_.PerformOps(&write_ops_); - } +template +using ServerAsyncWriter = ::grpc_impl::ServerAsyncWriter; - void Write(const W& msg, WriteOptions options, void* tag) override { - write_ops_.set_output_tag(tag); - if (options.is_last_message()) { - options.set_buffer_hint(); - } - EnsureInitialMetadataSent(&write_ops_); - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); - call_.PerformOps(&write_ops_); - } - - /// See the \a ServerAsyncReaderWriterInterface.WriteAndFinish - /// method for semantics. - /// - /// Implicit input parameter: - /// - the \a ServerContext associated with this call is used - /// for sending trailing (and initial) metadata to the client. - /// - /// Note: \a status must have an OK code. - // - /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it - /// is safe to deallocate once WriteAndFinish returns. - void WriteAndFinish(const W& msg, WriteOptions options, const Status& status, - void* tag) override { - write_ops_.set_output_tag(tag); - EnsureInitialMetadataSent(&write_ops_); - options.set_buffer_hint(); - GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); - write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); - call_.PerformOps(&write_ops_); - } - - /// See the \a ServerAsyncReaderWriterInterface.Finish method for semantics. - /// - /// Implicit input parameter: - /// - the \a ServerContext associated with this call is used for sending - /// trailing (and initial if not already sent) metadata to the client. - /// - /// Note: there are no restrictions are the code of \a status, - /// it may be non-OK - // - /// gRPC doesn't take ownership or a reference to \a status, so it is safe to - /// to deallocate once Finish returns. - void Finish(const Status& status, void* tag) override { - finish_ops_.set_output_tag(tag); - EnsureInitialMetadataSent(&finish_ops_); - - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); - call_.PerformOps(&finish_ops_); - } - - private: - friend class ::grpc_impl::Server; - - void BindCall(::grpc::internal::Call* call) override { call_ = *call; } - - template - void EnsureInitialMetadataSent(T* ops) { - if (!ctx_->sent_initial_metadata_) { - ops->SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - ops->set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - } - - ::grpc::internal::Call call_; - ::grpc_impl::ServerContext* ctx_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> - meta_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage> read_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpServerSendStatus> - write_ops_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpServerSendStatus> - finish_ops_; -}; +template +using ServerAsyncReaderWriterInterface = + ::grpc_impl::ServerAsyncReaderWriterInterface; +template +using ServerAsyncReaderWriter = ::grpc_impl::ServerAsyncReaderWriter; } // namespace grpc #endif // GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H diff --git a/include/grpcpp/impl/codegen/async_stream_impl.h b/include/grpcpp/impl/codegen/async_stream_impl.h new file mode 100644 index 00000000000..633a3d5dd00 --- /dev/null +++ b/include/grpcpp/impl/codegen/async_stream_impl.h @@ -0,0 +1,1134 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_IMPL_H +#define GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_IMPL_H + +#include +#include +#include +#include +#include +#include + +namespace grpc_impl { + +namespace internal { +/// Common interface for all client side asynchronous streaming. +class ClientAsyncStreamingInterface { + public: + virtual ~ClientAsyncStreamingInterface() {} + + /// Start the call that was set up by the constructor, but only if the + /// constructor was invoked through the "Prepare" API which doesn't actually + /// start the call + virtual void StartCall(void* tag) = 0; + + /// Request notification of the reading of the initial metadata. Completion + /// will be notified by \a tag on the associated completion queue. + /// This call is optional, but if it is used, it cannot be used concurrently + /// with or after the \a AsyncReaderInterface::Read method. + /// + /// \param[in] tag Tag identifying this request. + virtual void ReadInitialMetadata(void* tag) = 0; + + /// Indicate that the stream is to be finished and request notification for + /// when the call has been ended. + /// Should not be used concurrently with other operations. + /// + /// It is appropriate to call this method when both: + /// * the client side has no more message to send + /// (this can be declared implicitly by calling this method, or + /// explicitly through an earlier call to the WritesDone method + /// of the class in use, e.g. \a ClientAsyncWriterInterface::WritesDone or + /// \a ClientAsyncReaderWriterInterface::WritesDone). + /// * there are no more messages to be received from the server (this can + /// be known implicitly by the calling code, or explicitly from an + /// earlier call to \a AsyncReaderInterface::Read that yielded a failed + /// result, e.g. cq->Next(&read_tag, &ok) filled in 'ok' with 'false'). + /// + /// The tag will be returned when either: + /// - all incoming messages have been read and the server has returned + /// a status. + /// - the server has returned a non-OK status. + /// - the call failed for some reason and the library generated a + /// status. + /// + /// Note that implementations of this method attempt to receive initial + /// metadata from the server if initial metadata hasn't yet been received. + /// + /// \param[in] tag Tag identifying this request. + /// \param[out] status To be updated with the operation status. + virtual void Finish(::grpc::Status* status, void* tag) = 0; +}; + +/// An interface that yields a sequence of messages of type \a R. +template +class AsyncReaderInterface { + public: + virtual ~AsyncReaderInterface() {} + + /// Read a message of type \a R into \a msg. Completion will be notified by \a + /// tag on the associated completion queue. + /// This is thread-safe with respect to \a Write or \a WritesDone methods. It + /// should not be called concurrently with other streaming APIs + /// on the same stream. It is not meaningful to call it concurrently + /// with another \a AsyncReaderInterface::Read on the same stream since reads + /// on the same stream are delivered in order. + /// + /// \param[out] msg Where to eventually store the read message. + /// \param[in] tag The tag identifying the operation. + /// + /// Side effect: note that this method attempt to receive initial metadata for + /// a stream if it hasn't yet been received. + virtual void Read(R* msg, void* tag) = 0; +}; + +/// An interface that can be fed a sequence of messages of type \a W. +template +class AsyncWriterInterface { + public: + virtual ~AsyncWriterInterface() {} + + /// Request the writing of \a msg with identifying tag \a tag. + /// + /// Only one write may be outstanding at any given time. This means that + /// after calling Write, one must wait to receive \a tag from the completion + /// queue BEFORE calling Write again. + /// This is thread-safe with respect to \a AsyncReaderInterface::Read + /// + /// gRPC doesn't take ownership or a reference to \a msg, so it is safe to + /// to deallocate once Write returns. + /// + /// \param[in] msg The message to be written. + /// \param[in] tag The tag identifying the operation. + virtual void Write(const W& msg, void* tag) = 0; + + /// Request the writing of \a msg using WriteOptions \a options with + /// identifying tag \a tag. + /// + /// Only one write may be outstanding at any given time. This means that + /// after calling Write, one must wait to receive \a tag from the completion + /// queue BEFORE calling Write again. + /// WriteOptions \a options is used to set the write options of this message. + /// This is thread-safe with respect to \a AsyncReaderInterface::Read + /// + /// gRPC doesn't take ownership or a reference to \a msg, so it is safe to + /// to deallocate once Write returns. + /// + /// \param[in] msg The message to be written. + /// \param[in] options The WriteOptions to be used to write this message. + /// \param[in] tag The tag identifying the operation. + virtual void Write(const W& msg, ::grpc::WriteOptions options, void* tag) = 0; + + /// Request the writing of \a msg and coalesce it with the writing + /// of trailing metadata, using WriteOptions \a options with + /// identifying tag \a tag. + /// + /// For client, WriteLast is equivalent of performing Write and + /// WritesDone in a single step. + /// For server, WriteLast buffers the \a msg. The writing of \a msg is held + /// until Finish is called, where \a msg and trailing metadata are coalesced + /// and write is initiated. Note that WriteLast can only buffer \a msg up to + /// the flow control window size. If \a msg size is larger than the window + /// size, it will be sent on wire without buffering. + /// + /// gRPC doesn't take ownership or a reference to \a msg, so it is safe to + /// to deallocate once Write returns. + /// + /// \param[in] msg The message to be written. + /// \param[in] options The WriteOptions to be used to write this message. + /// \param[in] tag The tag identifying the operation. + void WriteLast(const W& msg, ::grpc::WriteOptions options, void* tag) { + Write(msg, options.set_last_message(), tag); + } +}; + +} // namespace internal + +template +class ClientAsyncReaderInterface + : public internal::ClientAsyncStreamingInterface, + public internal::AsyncReaderInterface {}; + +namespace internal { +template +class ClientAsyncReaderFactory { + public: + /// Create a stream object. + /// Write the first request out if \a start is set. + /// \a tag will be notified on \a cq when the call has been started and + /// \a request has been written out. If \a start is not set, \a tag must be + /// nullptr and the actual call must be initiated by StartCall + /// Note that \a context will be used to fill in custom initial metadata + /// used to send to the server when starting the call. + template + static ClientAsyncReader* Create(::grpc::ChannelInterface* channel, + ::grpc_impl::CompletionQueue* cq, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + const W& request, bool start, void* tag) { + ::grpc::internal::Call call = channel->CreateCall(method, context, cq); + return new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientAsyncReader))) + ClientAsyncReader(call, context, request, start, tag); + } +}; +} // namespace internal + +/// Async client-side API for doing server-streaming RPCs, +/// where the incoming message stream coming from the server has +/// messages of type \a R. +template +class ClientAsyncReader final : public ClientAsyncReaderInterface { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* ptr, std::size_t size) { + assert(size == sizeof(ClientAsyncReader)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { assert(0); } + + void StartCall(void* tag) override { + assert(!started_); + started_ = true; + StartCallInternal(tag); + } + + /// See the \a ClientAsyncStreamingInterface.ReadInitialMetadata + /// method for semantics. + /// + /// Side effect: + /// - upon receiving initial metadata from the server, + /// the \a ClientContext associated with this call is updated, and the + /// calling code can access the received metadata through the + /// \a ClientContext. + void ReadInitialMetadata(void* tag) override { + assert(started_); + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + meta_ops_.set_output_tag(tag); + meta_ops_.RecvInitialMetadata(context_); + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) override { + assert(started_); + read_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + read_ops_.RecvInitialMetadata(context_); + } + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + /// See the \a ClientAsyncStreamingInterface.Finish method for semantics. + /// + /// Side effect: + /// - the \a ClientContext associated with this call is updated with + /// possible initial and trailing metadata received from the server. + void Finish(::grpc::Status* status, void* tag) override { + assert(started_); + finish_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + finish_ops_.RecvInitialMetadata(context_); + } + finish_ops_.ClientRecvStatus(context_, status); + call_.PerformOps(&finish_ops_); + } + + private: + friend class internal::ClientAsyncReaderFactory; + template + ClientAsyncReader(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, const W& request, + bool start, void* tag) + : context_(context), call_(call), started_(start) { + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(init_ops_.SendMessage(request).ok()); + init_ops_.ClientSendClose(); + if (start) { + StartCallInternal(tag); + } else { + assert(tag == nullptr); + } + } + + void StartCallInternal(void* tag) { + init_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + init_ops_.set_output_tag(tag); + call_.PerformOps(&init_ops_); + } + + ::grpc_impl::ClientContext* context_; + ::grpc::internal::Call call_; + bool started_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose> + init_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> + meta_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpRecvMessage> + read_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpClientRecvStatus> + finish_ops_; +}; + +/// Common interface for client side asynchronous writing. +template +class ClientAsyncWriterInterface + : public internal::ClientAsyncStreamingInterface, + public internal::AsyncWriterInterface { + public: + /// Signal the client is done with the writes (half-close the client stream). + /// Thread-safe with respect to \a AsyncReaderInterface::Read + /// + /// \param[in] tag The tag identifying the operation. + virtual void WritesDone(void* tag) = 0; +}; + +namespace internal { +template +class ClientAsyncWriterFactory { + public: + /// Create a stream object. + /// Start the RPC if \a start is set + /// \a tag will be notified on \a cq when the call has been started (i.e. + /// intitial metadata sent) and \a request has been written out. + /// If \a start is not set, \a tag must be nullptr and the actual call + /// must be initiated by StartCall + /// Note that \a context will be used to fill in custom initial metadata + /// used to send to the server when starting the call. + /// \a response will be filled in with the single expected response + /// message from the server upon a successful call to the \a Finish + /// method of this instance. + template + static ClientAsyncWriter* Create(::grpc::ChannelInterface* channel, + ::grpc_impl::CompletionQueue* cq, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + R* response, bool start, void* tag) { + ::grpc::internal::Call call = channel->CreateCall(method, context, cq); + return new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientAsyncWriter))) + ClientAsyncWriter(call, context, response, start, tag); + } +}; +} // namespace internal + +/// Async API on the client side for doing client-streaming RPCs, +/// where the outgoing message stream going to the server contains +/// messages of type \a W. +template +class ClientAsyncWriter final : public ClientAsyncWriterInterface { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* ptr, std::size_t size) { + assert(size == sizeof(ClientAsyncWriter)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { assert(0); } + + void StartCall(void* tag) override { + assert(!started_); + started_ = true; + StartCallInternal(tag); + } + + /// See the \a ClientAsyncStreamingInterface.ReadInitialMetadata method for + /// semantics. + /// + /// Side effect: + /// - upon receiving initial metadata from the server, the \a ClientContext + /// associated with this call is updated, and the calling code can access + /// the received metadata through the \a ClientContext. + void ReadInitialMetadata(void* tag) override { + assert(started_); + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + meta_ops_.set_output_tag(tag); + meta_ops_.RecvInitialMetadata(context_); + call_.PerformOps(&meta_ops_); + } + + void Write(const W& msg, void* tag) override { + assert(started_); + write_ops_.set_output_tag(tag); + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override { + assert(started_); + write_ops_.set_output_tag(tag); + if (options.is_last_message()) { + options.set_buffer_hint(); + write_ops_.ClientSendClose(); + } + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); + call_.PerformOps(&write_ops_); + } + + void WritesDone(void* tag) override { + assert(started_); + write_ops_.set_output_tag(tag); + write_ops_.ClientSendClose(); + call_.PerformOps(&write_ops_); + } + + /// See the \a ClientAsyncStreamingInterface.Finish method for semantics. + /// + /// Side effect: + /// - the \a ClientContext associated with this call is updated with + /// possible initial and trailing metadata received from the server. + /// - attempts to fill in the \a response parameter passed to this class's + /// constructor with the server's response message. + void Finish(::grpc::Status* status, void* tag) override { + assert(started_); + finish_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + finish_ops_.RecvInitialMetadata(context_); + } + finish_ops_.ClientRecvStatus(context_, status); + call_.PerformOps(&finish_ops_); + } + + private: + friend class internal::ClientAsyncWriterFactory; + template + ClientAsyncWriter(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, R* response, + bool start, void* tag) + : context_(context), call_(call), started_(start) { + finish_ops_.RecvMessage(response); + finish_ops_.AllowNoMessage(); + if (start) { + StartCallInternal(tag); + } else { + assert(tag == nullptr); + } + } + + void StartCallInternal(void* tag) { + write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + // if corked bit is set in context, we just keep the initial metadata + // buffered up to coalesce with later message send. No op is performed. + if (!context_->initial_metadata_corked_) { + write_ops_.set_output_tag(tag); + call_.PerformOps(&write_ops_); + } + } + + ::grpc_impl::ClientContext* context_; + ::grpc::internal::Call call_; + bool started_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> + meta_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose> + write_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpGenericRecvMessage, + ::grpc::internal::CallOpClientRecvStatus> + finish_ops_; +}; + +/// Async client-side interface for bi-directional streaming, +/// where the client-to-server message stream has messages of type \a W, +/// and the server-to-client message stream has messages of type \a R. +template +class ClientAsyncReaderWriterInterface + : public internal::ClientAsyncStreamingInterface, + public internal::AsyncWriterInterface, + public internal::AsyncReaderInterface { + public: + /// Signal the client is done with the writes (half-close the client stream). + /// Thread-safe with respect to \a AsyncReaderInterface::Read + /// + /// \param[in] tag The tag identifying the operation. + virtual void WritesDone(void* tag) = 0; +}; + +namespace internal { +template +class ClientAsyncReaderWriterFactory { + public: + /// Create a stream object. + /// Start the RPC request if \a start is set. + /// \a tag will be notified on \a cq when the call has been started (i.e. + /// intitial metadata sent). If \a start is not set, \a tag must be + /// nullptr and the actual call must be initiated by StartCall + /// Note that \a context will be used to fill in custom initial metadata + /// used to send to the server when starting the call. + static ClientAsyncReaderWriter* Create( + ::grpc::ChannelInterface* channel, ::grpc_impl::CompletionQueue* cq, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, bool start, void* tag) { + ::grpc::internal::Call call = channel->CreateCall(method, context, cq); + + return new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientAsyncReaderWriter))) + ClientAsyncReaderWriter(call, context, start, tag); + } +}; +} // namespace internal + +/// Async client-side interface for bi-directional streaming, +/// where the outgoing message stream going to the server +/// has messages of type \a W, and the incoming message stream coming +/// from the server has messages of type \a R. +template +class ClientAsyncReaderWriter final + : public ClientAsyncReaderWriterInterface { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* ptr, std::size_t size) { + assert(size == sizeof(ClientAsyncReaderWriter)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { assert(0); } + + void StartCall(void* tag) override { + assert(!started_); + started_ = true; + StartCallInternal(tag); + } + + /// See the \a ClientAsyncStreamingInterface.ReadInitialMetadata method + /// for semantics of this method. + /// + /// Side effect: + /// - upon receiving initial metadata from the server, the \a ClientContext + /// is updated with it, and then the receiving initial metadata can + /// be accessed through this \a ClientContext. + void ReadInitialMetadata(void* tag) override { + assert(started_); + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + meta_ops_.set_output_tag(tag); + meta_ops_.RecvInitialMetadata(context_); + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) override { + assert(started_); + read_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + read_ops_.RecvInitialMetadata(context_); + } + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + void Write(const W& msg, void* tag) override { + assert(started_); + write_ops_.set_output_tag(tag); + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override { + assert(started_); + write_ops_.set_output_tag(tag); + if (options.is_last_message()) { + options.set_buffer_hint(); + write_ops_.ClientSendClose(); + } + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); + call_.PerformOps(&write_ops_); + } + + void WritesDone(void* tag) override { + assert(started_); + write_ops_.set_output_tag(tag); + write_ops_.ClientSendClose(); + call_.PerformOps(&write_ops_); + } + + /// See the \a ClientAsyncStreamingInterface.Finish method for semantics. + /// Side effect + /// - the \a ClientContext associated with this call is updated with + /// possible initial and trailing metadata sent from the server. + void Finish(::grpc::Status* status, void* tag) override { + assert(started_); + finish_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + finish_ops_.RecvInitialMetadata(context_); + } + finish_ops_.ClientRecvStatus(context_, status); + call_.PerformOps(&finish_ops_); + } + + private: + friend class internal::ClientAsyncReaderWriterFactory; + ClientAsyncReaderWriter(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, bool start, + void* tag) + : context_(context), call_(call), started_(start) { + if (start) { + StartCallInternal(tag); + } else { + assert(tag == nullptr); + } + } + + void StartCallInternal(void* tag) { + write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + // if corked bit is set in context, we just keep the initial metadata + // buffered up to coalesce with later message send. No op is performed. + if (!context_->initial_metadata_corked_) { + write_ops_.set_output_tag(tag); + call_.PerformOps(&write_ops_); + } + } + + ::grpc_impl::ClientContext* context_; + ::grpc::internal::Call call_; + bool started_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> + meta_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpRecvMessage> + read_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose> + write_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpClientRecvStatus> + finish_ops_; +}; + +template +class ServerAsyncReaderInterface + : public ::grpc::internal::ServerAsyncStreamingInterface, + public internal::AsyncReaderInterface { + public: + /// Indicate that the stream is to be finished with a certain status code + /// and also send out \a msg response to the client. + /// Request notification for when the server has sent the response and the + /// appropriate signals to the client to end the call. + /// Should not be used concurrently with other operations. + /// + /// It is appropriate to call this method when: + /// * all messages from the client have been received (either known + /// implictly, or explicitly because a previous + /// \a AsyncReaderInterface::Read operation with a non-ok result, + /// e.g., cq->Next(&read_tag, &ok) filled in 'ok' with 'false'). + /// + /// This operation will end when the server has finished sending out initial + /// metadata (if not sent already), response message, and status, or if + /// some failure occurred when trying to do so. + /// + /// gRPC doesn't take ownership or a reference to \a msg or \a status, so it + /// is safe to deallocate once Finish returns. + /// + /// \param[in] tag Tag identifying this request. + /// \param[in] status To be sent to the client as the result of this call. + /// \param[in] msg To be sent to the client as the response for this call. + virtual void Finish(const W& msg, const ::grpc::Status& status, + void* tag) = 0; + + /// Indicate that the stream is to be finished with a certain + /// non-OK status code. + /// Request notification for when the server has sent the appropriate + /// signals to the client to end the call. + /// Should not be used concurrently with other operations. + /// + /// This call is meant to end the call with some error, and can be called at + /// any point that the server would like to "fail" the call (though note + /// this shouldn't be called concurrently with any other "sending" call, like + /// \a AsyncWriterInterface::Write). + /// + /// This operation will end when the server has finished sending out initial + /// metadata (if not sent already), and status, or if some failure occurred + /// when trying to do so. + /// + /// gRPC doesn't take ownership or a reference to \a status, so it is safe to + /// to deallocate once FinishWithError returns. + /// + /// \param[in] tag Tag identifying this request. + /// \param[in] status To be sent to the client as the result of this call. + /// - Note: \a status must have a non-OK code. + virtual void FinishWithError(const ::grpc::Status& status, void* tag) = 0; +}; + +/// Async server-side API for doing client-streaming RPCs, +/// where the incoming message stream from the client has messages of type \a R, +/// and the single response message sent from the server is type \a W. +template +class ServerAsyncReader final : public ServerAsyncReaderInterface { + public: + explicit ServerAsyncReader(::grpc_impl::ServerContext* ctx) + : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} + + /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. + /// + /// Implicit input parameter: + /// - The initial metadata that will be sent to the client from this op will + /// be taken from the \a ServerContext associated with the call. + void SendInitialMetadata(void* tag) override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + meta_ops_.set_output_tag(tag); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) override { + read_ops_.set_output_tag(tag); + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + /// See the \a ServerAsyncReaderInterface.Read method for semantics + /// + /// Side effect: + /// - also sends initial metadata if not alreay sent. + /// - uses the \a ServerContext associated with this call to send possible + /// initial and trailing metadata. + /// + /// Note: \a msg is not sent if \a status has a non-OK code. + /// + /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it + /// is safe to deallocate once Finish returns. + void Finish(const W& msg, const ::grpc::Status& status, void* tag) override { + finish_ops_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // The response is dropped if the status is not OK. + if (status.ok()) { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, + finish_ops_.SendMessage(msg)); + } else { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); + } + call_.PerformOps(&finish_ops_); + } + + /// See the \a ServerAsyncReaderInterface.Read method for semantics + /// + /// Side effect: + /// - also sends initial metadata if not alreay sent. + /// - uses the \a ServerContext associated with this call to send possible + /// initial and trailing metadata. + /// + /// gRPC doesn't take ownership or a reference to \a status, so it is safe to + /// to deallocate once FinishWithError returns. + void FinishWithError(const ::grpc::Status& status, void* tag) override { + GPR_CODEGEN_ASSERT(!status.ok()); + finish_ops_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); + call_.PerformOps(&finish_ops_); + } + + private: + void BindCall(::grpc::internal::Call* call) override { call_ = *call; } + + ::grpc::internal::Call call_; + ::grpc_impl::ServerContext* ctx_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage> read_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + finish_ops_; +}; + +template +class ServerAsyncWriterInterface + : public ::grpc::internal::ServerAsyncStreamingInterface, + public internal::AsyncWriterInterface { + public: + /// Indicate that the stream is to be finished with a certain status code. + /// Request notification for when the server has sent the appropriate + /// signals to the client to end the call. + /// Should not be used concurrently with other operations. + /// + /// It is appropriate to call this method when either: + /// * all messages from the client have been received (either known + /// implictly, or explicitly because a previous \a + /// AsyncReaderInterface::Read operation with a non-ok + /// result (e.g., cq->Next(&read_tag, &ok) filled in 'ok' with 'false'. + /// * it is desired to end the call early with some non-OK status code. + /// + /// This operation will end when the server has finished sending out initial + /// metadata (if not sent already), response message, and status, or if + /// some failure occurred when trying to do so. + /// + /// gRPC doesn't take ownership or a reference to \a status, so it is safe to + /// to deallocate once Finish returns. + /// + /// \param[in] tag Tag identifying this request. + /// \param[in] status To be sent to the client as the result of this call. + virtual void Finish(const ::grpc::Status& status, void* tag) = 0; + + /// Request the writing of \a msg and coalesce it with trailing metadata which + /// contains \a status, using WriteOptions options with + /// identifying tag \a tag. + /// + /// WriteAndFinish is equivalent of performing WriteLast and Finish + /// in a single step. + /// + /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it + /// is safe to deallocate once WriteAndFinish returns. + /// + /// \param[in] msg The message to be written. + /// \param[in] options The WriteOptions to be used to write this message. + /// \param[in] status The Status that server returns to client. + /// \param[in] tag The tag identifying the operation. + virtual void WriteAndFinish(const W& msg, ::grpc::WriteOptions options, + const ::grpc::Status& status, void* tag) = 0; +}; + +/// Async server-side API for doing server streaming RPCs, +/// where the outgoing message stream from the server has messages of type \a W. +template +class ServerAsyncWriter final : public ServerAsyncWriterInterface { + public: + explicit ServerAsyncWriter(::grpc_impl::ServerContext* ctx) + : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} + + /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. + /// + /// Implicit input parameter: + /// - The initial metadata that will be sent to the client from this op will + /// be taken from the \a ServerContext associated with the call. + /// + /// \param[in] tag Tag identifying this request. + void SendInitialMetadata(void* tag) override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + meta_ops_.set_output_tag(tag); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_.PerformOps(&meta_ops_); + } + + void Write(const W& msg, void* tag) override { + write_ops_.set_output_tag(tag); + EnsureInitialMetadataSent(&write_ops_); + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override { + write_ops_.set_output_tag(tag); + if (options.is_last_message()) { + options.set_buffer_hint(); + } + + EnsureInitialMetadataSent(&write_ops_); + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); + call_.PerformOps(&write_ops_); + } + + /// See the \a ServerAsyncWriterInterface.WriteAndFinish method for semantics. + /// + /// Implicit input parameter: + /// - the \a ServerContext associated with this call is used + /// for sending trailing (and initial) metadata to the client. + /// + /// Note: \a status must have an OK code. + /// + /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it + /// is safe to deallocate once WriteAndFinish returns. + void WriteAndFinish(const W& msg, ::grpc::WriteOptions options, + const ::grpc::Status& status, void* tag) override { + write_ops_.set_output_tag(tag); + EnsureInitialMetadataSent(&write_ops_); + options.set_buffer_hint(); + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); + write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); + call_.PerformOps(&write_ops_); + } + + /// See the \a ServerAsyncWriterInterface.Finish method for semantics. + /// + /// Implicit input parameter: + /// - the \a ServerContext associated with this call is used for sending + /// trailing (and initial if not already sent) metadata to the client. + /// + /// Note: there are no restrictions are the code of + /// \a status,it may be non-OK + /// + /// gRPC doesn't take ownership or a reference to \a status, so it is safe to + /// to deallocate once Finish returns. + void Finish(const ::grpc::Status& status, void* tag) override { + finish_ops_.set_output_tag(tag); + EnsureInitialMetadataSent(&finish_ops_); + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); + call_.PerformOps(&finish_ops_); + } + + private: + void BindCall(::grpc::internal::Call* call) override { call_ = *call; } + + template + void EnsureInitialMetadataSent(T* ops) { + if (!ctx_->sent_initial_metadata_) { + ops->SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ops->set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + } + + ::grpc::internal::Call call_; + ::grpc_impl::ServerContext* ctx_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + write_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpServerSendStatus> + finish_ops_; +}; + +/// Server-side interface for asynchronous bi-directional streaming. +template +class ServerAsyncReaderWriterInterface + : public ::grpc::internal::ServerAsyncStreamingInterface, + public internal::AsyncWriterInterface, + public internal::AsyncReaderInterface { + public: + /// Indicate that the stream is to be finished with a certain status code. + /// Request notification for when the server has sent the appropriate + /// signals to the client to end the call. + /// Should not be used concurrently with other operations. + /// + /// It is appropriate to call this method when either: + /// * all messages from the client have been received (either known + /// implictly, or explicitly because a previous \a + /// AsyncReaderInterface::Read operation + /// with a non-ok result (e.g., cq->Next(&read_tag, &ok) filled in 'ok' + /// with 'false'. + /// * it is desired to end the call early with some non-OK status code. + /// + /// This operation will end when the server has finished sending out initial + /// metadata (if not sent already), response message, and status, or if some + /// failure occurred when trying to do so. + /// + /// gRPC doesn't take ownership or a reference to \a status, so it is safe to + /// to deallocate once Finish returns. + /// + /// \param[in] tag Tag identifying this request. + /// \param[in] status To be sent to the client as the result of this call. + virtual void Finish(const ::grpc::Status& status, void* tag) = 0; + + /// Request the writing of \a msg and coalesce it with trailing metadata which + /// contains \a status, using WriteOptions options with + /// identifying tag \a tag. + /// + /// WriteAndFinish is equivalent of performing WriteLast and Finish in a + /// single step. + /// + /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it + /// is safe to deallocate once WriteAndFinish returns. + /// + /// \param[in] msg The message to be written. + /// \param[in] options The WriteOptions to be used to write this message. + /// \param[in] status The Status that server returns to client. + /// \param[in] tag The tag identifying the operation. + virtual void WriteAndFinish(const W& msg, ::grpc::WriteOptions options, + const ::grpc::Status& status, void* tag) = 0; +}; + +/// Async server-side API for doing bidirectional streaming RPCs, +/// where the incoming message stream coming from the client has messages of +/// type \a R, and the outgoing message stream coming from the server has +/// messages of type \a W. +template +class ServerAsyncReaderWriter final + : public ServerAsyncReaderWriterInterface { + public: + explicit ServerAsyncReaderWriter(::grpc_impl::ServerContext* ctx) + : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} + + /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. + /// + /// Implicit input parameter: + /// - The initial metadata that will be sent to the client from this op will + /// be taken from the \a ServerContext associated with the call. + /// + /// \param[in] tag Tag identifying this request. + void SendInitialMetadata(void* tag) override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + meta_ops_.set_output_tag(tag); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) override { + read_ops_.set_output_tag(tag); + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + void Write(const W& msg, void* tag) override { + write_ops_.set_output_tag(tag); + EnsureInitialMetadataSent(&write_ops_); + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override { + write_ops_.set_output_tag(tag); + if (options.is_last_message()) { + options.set_buffer_hint(); + } + EnsureInitialMetadataSent(&write_ops_); + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); + call_.PerformOps(&write_ops_); + } + + /// See the \a ServerAsyncReaderWriterInterface.WriteAndFinish + /// method for semantics. + /// + /// Implicit input parameter: + /// - the \a ServerContext associated with this call is used + /// for sending trailing (and initial) metadata to the client. + /// + /// Note: \a status must have an OK code. + // + /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it + /// is safe to deallocate once WriteAndFinish returns. + void WriteAndFinish(const W& msg, ::grpc::WriteOptions options, + const ::grpc::Status& status, void* tag) override { + write_ops_.set_output_tag(tag); + EnsureInitialMetadataSent(&write_ops_); + options.set_buffer_hint(); + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); + write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); + call_.PerformOps(&write_ops_); + } + + /// See the \a ServerAsyncReaderWriterInterface.Finish method for semantics. + /// + /// Implicit input parameter: + /// - the \a ServerContext associated with this call is used for sending + /// trailing (and initial if not already sent) metadata to the client. + /// + /// Note: there are no restrictions are the code of \a status, + /// it may be non-OK + // + /// gRPC doesn't take ownership or a reference to \a status, so it is safe to + /// to deallocate once Finish returns. + void Finish(const ::grpc::Status& status, void* tag) override { + finish_ops_.set_output_tag(tag); + EnsureInitialMetadataSent(&finish_ops_); + + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); + call_.PerformOps(&finish_ops_); + } + + private: + friend class ::grpc_impl::Server; + + void BindCall(::grpc::internal::Call* call) override { call_ = *call; } + + template + void EnsureInitialMetadataSent(T* ops) { + if (!ctx_->sent_initial_metadata_) { + ops->SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ops->set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + } + + ::grpc::internal::Call call_; + ::grpc_impl::ServerContext* ctx_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage> read_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + write_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpServerSendStatus> + finish_ops_; +}; + +} // namespace grpc_impl +#endif // GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_IMPL_H diff --git a/include/grpcpp/impl/codegen/async_unary_call.h b/include/grpcpp/impl/codegen/async_unary_call.h index 5da6a649f14..64ee17dec0d 100644 --- a/include/grpcpp/impl/codegen/async_unary_call.h +++ b/include/grpcpp/impl/codegen/async_unary_call.h @@ -19,299 +19,18 @@ #ifndef GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_H #define GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_H -#include -#include -#include -#include -#include -#include -#include +#include namespace grpc { - -extern CoreCodegenInterface* g_core_codegen_interface; - -/// An interface relevant for async client side unary RPCs (which send -/// one request message to a server and receive one response message). template -class ClientAsyncResponseReaderInterface { - public: - virtual ~ClientAsyncResponseReaderInterface() {} - - /// Start the call that was set up by the constructor, but only if the - /// constructor was invoked through the "Prepare" API which doesn't actually - /// start the call - virtual void StartCall() = 0; - - /// Request notification of the reading of initial metadata. Completion - /// will be notified by \a tag on the associated completion queue. - /// This call is optional, but if it is used, it cannot be used concurrently - /// with or after the \a Finish method. - /// - /// \param[in] tag Tag identifying this request. - virtual void ReadInitialMetadata(void* tag) = 0; - - /// Request to receive the server's response \a msg and final \a status for - /// the call, and to notify \a tag on this call's completion queue when - /// finished. - /// - /// This function will return when either: - /// - when the server's response message and status have been received. - /// - when the server has returned a non-OK status (no message expected in - /// this case). - /// - when the call failed for some reason and the library generated a - /// non-OK status. - /// - /// \param[in] tag Tag identifying this request. - /// \param[out] status To be updated with the operation status. - /// \param[out] msg To be filled in with the server's response message. - virtual void Finish(R* msg, Status* status, void* tag) = 0; -}; - -namespace internal { +using ClientAsyncResponseReaderInterface = + grpc_impl::ClientAsyncResponseReaderInterface; template -class ClientAsyncResponseReaderFactory { - public: - /// Start a call and write the request out if \a start is set. - /// \a tag will be notified on \a cq when the call has been started (i.e. - /// intitial metadata sent) and \a request has been written out. - /// If \a start is not set, the actual call must be initiated by StartCall - /// Note that \a context will be used to fill in custom initial metadata - /// used to send to the server when starting the call. - template - static ClientAsyncResponseReader* Create( - ChannelInterface* channel, ::grpc_impl::CompletionQueue* cq, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, const W& request, bool start) { - ::grpc::internal::Call call = channel->CreateCall(method, context, cq); - return new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(ClientAsyncResponseReader))) - ClientAsyncResponseReader(call, context, request, start); - } -}; -} // namespace internal +using ClientAsyncResponseReader = grpc_impl::ClientAsyncResponseReader; -/// Async API for client-side unary RPCs, where the message response -/// received from the server is of type \a R. -template -class ClientAsyncResponseReader final - : public ClientAsyncResponseReaderInterface { - public: - // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { - assert(size == sizeof(ClientAsyncResponseReader)); - } - - // This operator should never be called as the memory should be freed as part - // of the arena destruction. It only exists to provide a matching operator - // delete to the operator new so that some compilers will not complain (see - // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this - // there are no tests catching the compiler warning. - static void operator delete(void*, void*) { assert(0); } - - void StartCall() override { - assert(!started_); - started_ = true; - StartCallInternal(); - } - - /// See \a ClientAsyncResponseReaderInterface::ReadInitialMetadata for - /// semantics. - /// - /// Side effect: - /// - the \a ClientContext associated with this call is updated with - /// possible initial and trailing metadata sent from the server. - void ReadInitialMetadata(void* tag) override { - assert(started_); - GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); - - single_buf.set_output_tag(tag); - single_buf.RecvInitialMetadata(context_); - call_.PerformOps(&single_buf); - initial_metadata_read_ = true; - } - - /// See \a ClientAysncResponseReaderInterface::Finish for semantics. - /// - /// Side effect: - /// - the \a ClientContext associated with this call is updated with - /// possible initial and trailing metadata sent from the server. - void Finish(R* msg, Status* status, void* tag) override { - assert(started_); - if (initial_metadata_read_) { - finish_buf.set_output_tag(tag); - finish_buf.RecvMessage(msg); - finish_buf.AllowNoMessage(); - finish_buf.ClientRecvStatus(context_, status); - call_.PerformOps(&finish_buf); - } else { - single_buf.set_output_tag(tag); - single_buf.RecvInitialMetadata(context_); - single_buf.RecvMessage(msg); - single_buf.AllowNoMessage(); - single_buf.ClientRecvStatus(context_, status); - call_.PerformOps(&single_buf); - } - } - - private: - friend class internal::ClientAsyncResponseReaderFactory; - ::grpc_impl::ClientContext* const context_; - ::grpc::internal::Call call_; - bool started_; - bool initial_metadata_read_ = false; - - template - ClientAsyncResponseReader(::grpc::internal::Call call, - ::grpc_impl::ClientContext* context, - const W& request, bool start) - : context_(context), call_(call), started_(start) { - // Bind the metadata at time of StartCallInternal but set up the rest here - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(single_buf.SendMessage(request).ok()); - single_buf.ClientSendClose(); - if (start) StartCallInternal(); - } - - void StartCallInternal() { - single_buf.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - } - - // disable operator new - static void* operator new(std::size_t size); - static void* operator new(std::size_t size, void* p) { return p; } - - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpClientSendClose, - ::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpRecvMessage, - ::grpc::internal::CallOpClientRecvStatus> - single_buf; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage, - ::grpc::internal::CallOpClientRecvStatus> - finish_buf; -}; - -/// Async server-side API for handling unary calls, where the single -/// response message sent to the client is of type \a W. template -class ServerAsyncResponseWriter final - : public internal::ServerAsyncStreamingInterface { - public: - explicit ServerAsyncResponseWriter(::grpc_impl::ServerContext* ctx) - : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} - - /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. - /// - /// Side effect: - /// The initial metadata that will be sent to the client from this op will - /// be taken from the \a ServerContext associated with the call. - /// - /// \param[in] tag Tag identifying this request. - void SendInitialMetadata(void* tag) override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - - meta_buf_.set_output_tag(tag); - meta_buf_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_buf_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - call_.PerformOps(&meta_buf_); - } - - /// Indicate that the stream is to be finished and request notification - /// when the server has sent the appropriate signals to the client to - /// end the call. Should not be used concurrently with other operations. - /// - /// \param[in] tag Tag identifying this request. - /// \param[in] status To be sent to the client as the result of the call. - /// \param[in] msg Message to be sent to the client. - /// - /// Side effect: - /// - also sends initial metadata if not already sent (using the - /// \a ServerContext associated with this call). - /// - /// Note: if \a status has a non-OK code, then \a msg will not be sent, - /// and the client will receive only the status with possible trailing - /// metadata. - void Finish(const W& msg, const Status& status, void* tag) { - finish_buf_.set_output_tag(tag); - finish_buf_.set_core_cq_tag(&finish_buf_); - if (!ctx_->sent_initial_metadata_) { - finish_buf_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_buf_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - // The response is dropped if the status is not OK. - if (status.ok()) { - finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_, - finish_buf_.SendMessage(msg)); - } else { - finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_, status); - } - call_.PerformOps(&finish_buf_); - } - - /// Indicate that the stream is to be finished with a non-OK status, - /// and request notification for when the server has finished sending the - /// appropriate signals to the client to end the call. - /// Should not be used concurrently with other operations. - /// - /// \param[in] tag Tag identifying this request. - /// \param[in] status To be sent to the client as the result of the call. - /// - Note: \a status must have a non-OK code. - /// - /// Side effect: - /// - also sends initial metadata if not already sent (using the - /// \a ServerContext associated with this call). - void FinishWithError(const Status& status, void* tag) { - GPR_CODEGEN_ASSERT(!status.ok()); - finish_buf_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - finish_buf_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_buf_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_, status); - call_.PerformOps(&finish_buf_); - } - - private: - void BindCall(::grpc::internal::Call* call) override { call_ = *call; } - - ::grpc::internal::Call call_; - ::grpc_impl::ServerContext* ctx_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> - meta_buf_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpServerSendStatus> - finish_buf_; -}; +using ServerAsyncResponseWriter = ::grpc_impl::ServerAsyncResponseWriter; } // namespace grpc -namespace std { -template -class default_delete> { - public: - void operator()(void* p) {} -}; -template -class default_delete> { - public: - void operator()(void* p) {} -}; -} // namespace std - #endif // GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_H diff --git a/include/grpcpp/impl/codegen/async_unary_call_impl.h b/include/grpcpp/impl/codegen/async_unary_call_impl.h new file mode 100644 index 00000000000..ff8bf15602b --- /dev/null +++ b/include/grpcpp/impl/codegen/async_unary_call_impl.h @@ -0,0 +1,315 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_IMPL_H +#define GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_IMPL_H + +#include +#include +#include +#include +#include +#include +#include + +namespace grpc_impl { + +/// An interface relevant for async client side unary RPCs (which send +/// one request message to a server and receive one response message). +template +class ClientAsyncResponseReaderInterface { + public: + virtual ~ClientAsyncResponseReaderInterface() {} + + /// Start the call that was set up by the constructor, but only if the + /// constructor was invoked through the "Prepare" API which doesn't actually + /// start the call + virtual void StartCall() = 0; + + /// Request notification of the reading of initial metadata. Completion + /// will be notified by \a tag on the associated completion queue. + /// This call is optional, but if it is used, it cannot be used concurrently + /// with or after the \a Finish method. + /// + /// \param[in] tag Tag identifying this request. + virtual void ReadInitialMetadata(void* tag) = 0; + + /// Request to receive the server's response \a msg and final \a status for + /// the call, and to notify \a tag on this call's completion queue when + /// finished. + /// + /// This function will return when either: + /// - when the server's response message and status have been received. + /// - when the server has returned a non-OK status (no message expected in + /// this case). + /// - when the call failed for some reason and the library generated a + /// non-OK status. + /// + /// \param[in] tag Tag identifying this request. + /// \param[out] status To be updated with the operation status. + /// \param[out] msg To be filled in with the server's response message. + virtual void Finish(R* msg, ::grpc::Status* status, void* tag) = 0; +}; + +namespace internal { +template +class ClientAsyncResponseReaderFactory { + public: + /// Start a call and write the request out if \a start is set. + /// \a tag will be notified on \a cq when the call has been started (i.e. + /// intitial metadata sent) and \a request has been written out. + /// If \a start is not set, the actual call must be initiated by StartCall + /// Note that \a context will be used to fill in custom initial metadata + /// used to send to the server when starting the call. + template + static ClientAsyncResponseReader* Create( + ::grpc::ChannelInterface* channel, ::grpc_impl::CompletionQueue* cq, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, const W& request, bool start) { + ::grpc::internal::Call call = channel->CreateCall(method, context, cq); + return new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientAsyncResponseReader))) + ClientAsyncResponseReader(call, context, request, start); + } +}; +} // namespace internal + +/// Async API for client-side unary RPCs, where the message response +/// received from the server is of type \a R. +template +class ClientAsyncResponseReader final + : public ClientAsyncResponseReaderInterface { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* ptr, std::size_t size) { + assert(size == sizeof(ClientAsyncResponseReader)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { assert(0); } + + void StartCall() override { + assert(!started_); + started_ = true; + StartCallInternal(); + } + + /// See \a ClientAsyncResponseReaderInterface::ReadInitialMetadata for + /// semantics. + /// + /// Side effect: + /// - the \a ClientContext associated with this call is updated with + /// possible initial and trailing metadata sent from the server. + void ReadInitialMetadata(void* tag) override { + assert(started_); + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + single_buf.set_output_tag(tag); + single_buf.RecvInitialMetadata(context_); + call_.PerformOps(&single_buf); + initial_metadata_read_ = true; + } + + /// See \a ClientAysncResponseReaderInterface::Finish for semantics. + /// + /// Side effect: + /// - the \a ClientContext associated with this call is updated with + /// possible initial and trailing metadata sent from the server. + void Finish(R* msg, ::grpc::Status* status, void* tag) override { + assert(started_); + if (initial_metadata_read_) { + finish_buf.set_output_tag(tag); + finish_buf.RecvMessage(msg); + finish_buf.AllowNoMessage(); + finish_buf.ClientRecvStatus(context_, status); + call_.PerformOps(&finish_buf); + } else { + single_buf.set_output_tag(tag); + single_buf.RecvInitialMetadata(context_); + single_buf.RecvMessage(msg); + single_buf.AllowNoMessage(); + single_buf.ClientRecvStatus(context_, status); + call_.PerformOps(&single_buf); + } + } + + private: + friend class internal::ClientAsyncResponseReaderFactory; + ::grpc_impl::ClientContext* const context_; + ::grpc::internal::Call call_; + bool started_; + bool initial_metadata_read_ = false; + + template + ClientAsyncResponseReader(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, + const W& request, bool start) + : context_(context), call_(call), started_(start) { + // Bind the metadata at time of StartCallInternal but set up the rest here + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(single_buf.SendMessage(request).ok()); + single_buf.ClientSendClose(); + if (start) StartCallInternal(); + } + + void StartCallInternal() { + single_buf.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + } + + // disable operator new + static void* operator new(std::size_t size); + static void* operator new(std::size_t size, void* p) { return p; } + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose, + ::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpRecvMessage, + ::grpc::internal::CallOpClientRecvStatus> + single_buf; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage, + ::grpc::internal::CallOpClientRecvStatus> + finish_buf; +}; + +/// Async server-side API for handling unary calls, where the single +/// response message sent to the client is of type \a W. +template +class ServerAsyncResponseWriter final + : public ::grpc::internal::ServerAsyncStreamingInterface { + public: + explicit ServerAsyncResponseWriter(::grpc_impl::ServerContext* ctx) + : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} + + /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. + /// + /// Side effect: + /// The initial metadata that will be sent to the client from this op will + /// be taken from the \a ServerContext associated with the call. + /// + /// \param[in] tag Tag identifying this request. + void SendInitialMetadata(void* tag) override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + meta_buf_.set_output_tag(tag); + meta_buf_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_buf_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_.PerformOps(&meta_buf_); + } + + /// Indicate that the stream is to be finished and request notification + /// when the server has sent the appropriate signals to the client to + /// end the call. Should not be used concurrently with other operations. + /// + /// \param[in] tag Tag identifying this request. + /// \param[in] status To be sent to the client as the result of the call. + /// \param[in] msg Message to be sent to the client. + /// + /// Side effect: + /// - also sends initial metadata if not already sent (using the + /// \a ServerContext associated with this call). + /// + /// Note: if \a status has a non-OK code, then \a msg will not be sent, + /// and the client will receive only the status with possible trailing + /// metadata. + void Finish(const W& msg, const ::grpc::Status& status, void* tag) { + finish_buf_.set_output_tag(tag); + finish_buf_.set_core_cq_tag(&finish_buf_); + if (!ctx_->sent_initial_metadata_) { + finish_buf_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_buf_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // The response is dropped if the status is not OK. + if (status.ok()) { + finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_, + finish_buf_.SendMessage(msg)); + } else { + finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_, status); + } + call_.PerformOps(&finish_buf_); + } + + /// Indicate that the stream is to be finished with a non-OK status, + /// and request notification for when the server has finished sending the + /// appropriate signals to the client to end the call. + /// Should not be used concurrently with other operations. + /// + /// \param[in] tag Tag identifying this request. + /// \param[in] status To be sent to the client as the result of the call. + /// - Note: \a status must have a non-OK code. + /// + /// Side effect: + /// - also sends initial metadata if not already sent (using the + /// \a ServerContext associated with this call). + void FinishWithError(const ::grpc::Status& status, void* tag) { + GPR_CODEGEN_ASSERT(!status.ok()); + finish_buf_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + finish_buf_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_buf_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_, status); + call_.PerformOps(&finish_buf_); + } + + private: + void BindCall(::grpc::internal::Call* call) override { call_ = *call; } + + ::grpc::internal::Call call_; + ::grpc_impl::ServerContext* ctx_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_buf_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + finish_buf_; +}; + +} // namespace grpc_impl + +namespace std { +template +class default_delete<::grpc_impl::ClientAsyncResponseReader> { + public: + void operator()(void* p) {} +}; +template +class default_delete<::grpc_impl::ClientAsyncResponseReaderInterface> { + public: + void operator()(void* p) {} +}; +} // namespace std + +#endif // GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_IMPL_H diff --git a/include/grpcpp/impl/codegen/byte_buffer.h b/include/grpcpp/impl/codegen/byte_buffer.h index e2ba9344bcb..0b7be6fc753 100644 --- a/include/grpcpp/impl/codegen/byte_buffer.h +++ b/include/grpcpp/impl/codegen/byte_buffer.h @@ -29,6 +29,17 @@ #include +namespace grpc_impl { +namespace internal { + +template +class CallbackUnaryHandler; +template +class CallbackServerStreamingHandler; + +} // namespace internal +} // namespace grpc_impl + namespace grpc { class ServerInterface; @@ -45,10 +56,6 @@ template class RpcMethodHandler; template class ServerStreamingHandler; -template -class CallbackUnaryHandler; -template -class CallbackServerStreamingHandler; template class ErrorMethodHandler; class ExternalConnectionAcceptorImpl; @@ -176,9 +183,9 @@ class ByteBuffer final { template friend class internal::ServerStreamingHandler; template - friend class internal::CallbackUnaryHandler; + friend class ::grpc_impl::internal::CallbackUnaryHandler; template - friend class ::grpc::internal::CallbackServerStreamingHandler; + friend class ::grpc_impl::internal::CallbackServerStreamingHandler; template friend class internal::ErrorMethodHandler; template diff --git a/include/grpcpp/impl/codegen/call_op_set.h b/include/grpcpp/impl/codegen/call_op_set.h index d0958bbb251..84d1407cbe2 100644 --- a/include/grpcpp/impl/codegen/call_op_set.h +++ b/include/grpcpp/impl/codegen/call_op_set.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/grpcpp/impl/codegen/channel_interface.h b/include/grpcpp/impl/codegen/channel_interface.h index 836c287e509..dd2fe8d687a 100644 --- a/include/grpcpp/impl/codegen/channel_interface.h +++ b/include/grpcpp/impl/codegen/channel_interface.h @@ -27,24 +27,13 @@ namespace grpc_impl { class ClientContext; class CompletionQueue; -} // namespace grpc_impl - -namespace grpc { -class ChannelInterface; - template class ClientReader; template class ClientWriter; template class ClientReaderWriter; - namespace internal { -class Call; -class CallOpSetInterface; -class RpcMethod; -template -class BlockingUnaryCallImpl; template class CallbackUnaryCallImpl; template @@ -62,7 +51,19 @@ class ClientCallbackReaderFactory; template class ClientCallbackWriterFactory; class ClientCallbackUnaryFactory; +} // namespace internal +} // namespace grpc_impl + +namespace grpc { +class ChannelInterface; + +namespace internal { +class Call; +class CallOpSetInterface; +class RpcMethod; class InterceptedChannel; +template +class BlockingUnaryCallImpl; } // namespace internal /// Codegen interface for \a grpc::Channel. @@ -102,30 +103,30 @@ class ChannelInterface { private: template - friend class ::grpc::ClientReader; + friend class ::grpc_impl::ClientReader; template - friend class ::grpc::ClientWriter; + friend class ::grpc_impl::ClientWriter; template - friend class ::grpc::ClientReaderWriter; + friend class ::grpc_impl::ClientReaderWriter; template - friend class ::grpc::internal::ClientAsyncReaderFactory; + friend class ::grpc_impl::internal::ClientAsyncReaderFactory; template - friend class ::grpc::internal::ClientAsyncWriterFactory; + friend class ::grpc_impl::internal::ClientAsyncWriterFactory; template - friend class ::grpc::internal::ClientAsyncReaderWriterFactory; + friend class ::grpc_impl::internal::ClientAsyncReaderWriterFactory; template - friend class ::grpc::internal::ClientAsyncResponseReaderFactory; + friend class ::grpc_impl::internal::ClientAsyncResponseReaderFactory; template - friend class ::grpc::internal::ClientCallbackReaderWriterFactory; + friend class ::grpc_impl::internal::ClientCallbackReaderWriterFactory; template - friend class ::grpc::internal::ClientCallbackReaderFactory; + friend class ::grpc_impl::internal::ClientCallbackReaderFactory; template - friend class ::grpc::internal::ClientCallbackWriterFactory; - friend class ::grpc::internal::ClientCallbackUnaryFactory; + friend class ::grpc_impl::internal::ClientCallbackWriterFactory; + friend class ::grpc_impl::internal::ClientCallbackUnaryFactory; template friend class ::grpc::internal::BlockingUnaryCallImpl; template - friend class ::grpc::internal::CallbackUnaryCallImpl; + friend class ::grpc_impl::internal::CallbackUnaryCallImpl; friend class ::grpc::internal::RpcMethod; friend class ::grpc::internal::InterceptedChannel; virtual internal::Call CreateCall(const internal::RpcMethod& method, diff --git a/include/grpcpp/impl/codegen/client_callback.h b/include/grpcpp/impl/codegen/client_callback.h index 9441a48b051..4f60741624a 100644 --- a/include/grpcpp/impl/codegen/client_callback.h +++ b/include/grpcpp/impl/codegen/client_callback.h @@ -19,1012 +19,25 @@ #ifndef GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_H #define GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_H -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace grpc_impl { -class Channel; -class ClientContext; -} // namespace grpc_impl +#include namespace grpc { - -namespace internal { -class RpcMethod; - -/// Perform a callback-based unary call -/// TODO(vjpai): Combine as much as possible with the blocking unary call code -template -void CallbackUnaryCall(ChannelInterface* channel, const RpcMethod& method, - ::grpc_impl::ClientContext* context, - const InputMessage* request, OutputMessage* result, - std::function on_completion) { - CallbackUnaryCallImpl x( - channel, method, context, request, result, on_completion); -} - -template -class CallbackUnaryCallImpl { - public: - CallbackUnaryCallImpl(ChannelInterface* channel, const RpcMethod& method, - ::grpc_impl::ClientContext* context, - const InputMessage* request, OutputMessage* result, - std::function on_completion) { - CompletionQueue* cq = channel->CallbackCQ(); - GPR_CODEGEN_ASSERT(cq != nullptr); - Call call(channel->CreateCall(method, context, cq)); - - using FullCallOpSet = - CallOpSet, - CallOpClientSendClose, CallOpClientRecvStatus>; - - auto* ops = new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(FullCallOpSet))) FullCallOpSet; - - auto* tag = new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(CallbackWithStatusTag))) - CallbackWithStatusTag(call.call(), on_completion, ops); - - // TODO(vjpai): Unify code with sync API as much as possible - Status s = ops->SendMessagePtr(request); - if (!s.ok()) { - tag->force_run(s); - return; - } - ops->SendInitialMetadata(&context->send_initial_metadata_, - context->initial_metadata_flags()); - ops->RecvInitialMetadata(context); - ops->RecvMessage(result); - ops->AllowNoMessage(); - ops->ClientSendClose(); - ops->ClientRecvStatus(context, tag->status_ptr()); - ops->set_core_cq_tag(tag); - call.PerformOps(ops); - } -}; -} // namespace internal - namespace experimental { -// Forward declarations -template -class ClientBidiReactor; template -class ClientReadReactor; -template -class ClientWriteReactor; -class ClientUnaryReactor; - -// NOTE: The streaming objects are not actually implemented in the public API. -// These interfaces are provided for mocking only. Typical applications -// will interact exclusively with the reactors that they define. -template -class ClientCallbackReaderWriter { - public: - virtual ~ClientCallbackReaderWriter() {} - virtual void StartCall() = 0; - virtual void Write(const Request* req, WriteOptions options) = 0; - virtual void WritesDone() = 0; - virtual void Read(Response* resp) = 0; - virtual void AddHold(int holds) = 0; - virtual void RemoveHold() = 0; - - protected: - void BindReactor(ClientBidiReactor* reactor) { - reactor->BindStream(this); - } -}; - -template -class ClientCallbackReader { - public: - virtual ~ClientCallbackReader() {} - virtual void StartCall() = 0; - virtual void Read(Response* resp) = 0; - virtual void AddHold(int holds) = 0; - virtual void RemoveHold() = 0; - - protected: - void BindReactor(ClientReadReactor* reactor) { - reactor->BindReader(this); - } -}; +using ClientReadReactor = + ::grpc_impl::experimental::ClientReadReactor; template -class ClientCallbackWriter { - public: - virtual ~ClientCallbackWriter() {} - virtual void StartCall() = 0; - void Write(const Request* req) { Write(req, WriteOptions()); } - virtual void Write(const Request* req, WriteOptions options) = 0; - void WriteLast(const Request* req, WriteOptions options) { - Write(req, options.set_last_message()); - } - virtual void WritesDone() = 0; +using ClientWriteReactor = + ::grpc_impl::experimental::ClientWriteReactor; - virtual void AddHold(int holds) = 0; - virtual void RemoveHold() = 0; - - protected: - void BindReactor(ClientWriteReactor* reactor) { - reactor->BindWriter(this); - } -}; - -class ClientCallbackUnary { - public: - virtual ~ClientCallbackUnary() {} - virtual void StartCall() = 0; - - protected: - void BindReactor(ClientUnaryReactor* reactor); -}; - -// The following classes are the reactor interfaces that are to be implemented -// by the user. They are passed in to the library as an argument to a call on a -// stub (either a codegen-ed call or a generic call). The streaming RPC is -// activated by calling StartCall, possibly after initiating StartRead, -// StartWrite, or AddHold operations on the streaming object. Note that none of -// the classes are pure; all reactions have a default empty reaction so that the -// user class only needs to override those classes that it cares about. -// The reactor must be passed to the stub invocation before any of the below -// operations can be called. - -/// \a ClientBidiReactor is the interface for a bidirectional streaming RPC. template -class ClientBidiReactor { - public: - virtual ~ClientBidiReactor() {} - - /// Activate the RPC and initiate any reads or writes that have been Start'ed - /// before this call. All streaming RPCs issued by the client MUST have - /// StartCall invoked on them (even if they are canceled) as this call is the - /// activation of their lifecycle. - void StartCall() { stream_->StartCall(); } - - /// Initiate a read operation (or post it for later initiation if StartCall - /// has not yet been invoked). - /// - /// \param[out] resp Where to eventually store the read message. Valid when - /// the library calls OnReadDone - void StartRead(Response* resp) { stream_->Read(resp); } - - /// Initiate a write operation (or post it for later initiation if StartCall - /// has not yet been invoked). - /// - /// \param[in] req The message to be written. The library takes temporary - /// ownership until OnWriteDone, at which point the application - /// regains ownership of msg. - void StartWrite(const Request* req) { StartWrite(req, WriteOptions()); } - - /// Initiate/post a write operation with specified options. - /// - /// \param[in] req The message to be written. The library takes temporary - /// ownership until OnWriteDone, at which point the application - /// regains ownership of msg. - /// \param[in] options The WriteOptions to use for writing this message - void StartWrite(const Request* req, WriteOptions options) { - stream_->Write(req, std::move(options)); - } - - /// Initiate/post a write operation with specified options and an indication - /// that this is the last write (like StartWrite and StartWritesDone, merged). - /// Note that calling this means that no more calls to StartWrite, - /// StartWriteLast, or StartWritesDone are allowed. - /// - /// \param[in] req The message to be written. The library takes temporary - /// ownership until OnWriteDone, at which point the application - /// regains ownership of msg. - /// \param[in] options The WriteOptions to use for writing this message - void StartWriteLast(const Request* req, WriteOptions options) { - StartWrite(req, std::move(options.set_last_message())); - } - - /// Indicate that the RPC will have no more write operations. This can only be - /// issued once for a given RPC. This is not required or allowed if - /// StartWriteLast is used since that already has the same implication. - /// Note that calling this means that no more calls to StartWrite, - /// StartWriteLast, or StartWritesDone are allowed. - void StartWritesDone() { stream_->WritesDone(); } - - /// Holds are needed if (and only if) this stream has operations that take - /// place on it after StartCall but from outside one of the reactions - /// (OnReadDone, etc). This is _not_ a common use of the streaming API. - /// - /// Holds must be added before calling StartCall. If a stream still has a hold - /// in place, its resources will not be destroyed even if the status has - /// already come in from the wire and there are currently no active callbacks - /// outstanding. Similarly, the stream will not call OnDone if there are still - /// holds on it. - /// - /// For example, if a StartRead or StartWrite operation is going to be - /// initiated from elsewhere in the application, the application should call - /// AddHold or AddMultipleHolds before StartCall. If there is going to be, - /// for example, a read-flow and a write-flow taking place outside the - /// reactions, then call AddMultipleHolds(2) before StartCall. When the - /// application knows that it won't issue any more read operations (such as - /// when a read comes back as not ok), it should issue a RemoveHold(). It - /// should also call RemoveHold() again after it does StartWriteLast or - /// StartWritesDone that indicates that there will be no more write ops. - /// The number of RemoveHold calls must match the total number of AddHold - /// calls plus the number of holds added by AddMultipleHolds. - void AddHold() { AddMultipleHolds(1); } - void AddMultipleHolds(int holds) { stream_->AddHold(holds); } - void RemoveHold() { stream_->RemoveHold(); } - - /// Notifies the application that all operations associated with this RPC - /// have completed and provides the RPC status outcome. - /// - /// \param[in] s The status outcome of this RPC - virtual void OnDone(const Status& s) {} - - /// Notifies the application that a read of initial metadata from the - /// server is done. If the application chooses not to implement this method, - /// it can assume that the initial metadata has been read before the first - /// call of OnReadDone or OnDone. - /// - /// \param[in] ok Was the initial metadata read successfully? If false, no - /// further read-side operation will succeed. - virtual void OnReadInitialMetadataDone(bool ok) {} - - /// Notifies the application that a StartRead operation completed. - /// - /// \param[in] ok Was it successful? If false, no further read-side operation - /// will succeed. - virtual void OnReadDone(bool ok) {} - - /// Notifies the application that a StartWrite operation completed. - /// - /// \param[in] ok Was it successful? If false, no further write-side operation - /// will succeed. - virtual void OnWriteDone(bool ok) {} - - /// Notifies the application that a StartWritesDone operation completed. Note - /// that this is only used on explicit StartWritesDone operations and not for - /// those that are implicitly invoked as part of a StartWriteLast. - /// - /// \param[in] ok Was it successful? If false, the application will later see - /// the failure reflected as a bad status in OnDone. - virtual void OnWritesDoneDone(bool ok) {} - - private: - friend class ClientCallbackReaderWriter; - void BindStream(ClientCallbackReaderWriter* stream) { - stream_ = stream; - } - ClientCallbackReaderWriter* stream_; -}; - -/// \a ClientReadReactor is the interface for a server-streaming RPC. -/// All public methods behave as in ClientBidiReactor. -template -class ClientReadReactor { - public: - virtual ~ClientReadReactor() {} - - void StartCall() { reader_->StartCall(); } - void StartRead(Response* resp) { reader_->Read(resp); } - - void AddHold() { AddMultipleHolds(1); } - void AddMultipleHolds(int holds) { reader_->AddHold(holds); } - void RemoveHold() { reader_->RemoveHold(); } - - virtual void OnDone(const Status& s) {} - virtual void OnReadInitialMetadataDone(bool ok) {} - virtual void OnReadDone(bool ok) {} - - private: - friend class ClientCallbackReader; - void BindReader(ClientCallbackReader* reader) { reader_ = reader; } - ClientCallbackReader* reader_; -}; - -/// \a ClientWriteReactor is the interface for a client-streaming RPC. -/// All public methods behave as in ClientBidiReactor. -template -class ClientWriteReactor { - public: - virtual ~ClientWriteReactor() {} - - void StartCall() { writer_->StartCall(); } - void StartWrite(const Request* req) { StartWrite(req, WriteOptions()); } - void StartWrite(const Request* req, WriteOptions options) { - writer_->Write(req, std::move(options)); - } - void StartWriteLast(const Request* req, WriteOptions options) { - StartWrite(req, std::move(options.set_last_message())); - } - void StartWritesDone() { writer_->WritesDone(); } - - void AddHold() { AddMultipleHolds(1); } - void AddMultipleHolds(int holds) { writer_->AddHold(holds); } - void RemoveHold() { writer_->RemoveHold(); } - - virtual void OnDone(const Status& s) {} - virtual void OnReadInitialMetadataDone(bool ok) {} - virtual void OnWriteDone(bool ok) {} - virtual void OnWritesDoneDone(bool ok) {} - - private: - friend class ClientCallbackWriter; - void BindWriter(ClientCallbackWriter* writer) { writer_ = writer; } - ClientCallbackWriter* writer_; -}; - -/// \a ClientUnaryReactor is a reactor-style interface for a unary RPC. -/// This is _not_ a common way of invoking a unary RPC. In practice, this -/// option should be used only if the unary RPC wants to receive initial -/// metadata without waiting for the response to complete. Most deployments of -/// RPC systems do not use this option, but it is needed for generality. -/// All public methods behave as in ClientBidiReactor. -/// StartCall is included for consistency with the other reactor flavors: even -/// though there are no StartRead or StartWrite operations to queue before the -/// call (that is part of the unary call itself) and there is no reactor object -/// being created as a result of this call, we keep a consistent 2-phase -/// initiation API among all the reactor flavors. -class ClientUnaryReactor { - public: - virtual ~ClientUnaryReactor() {} - - void StartCall() { call_->StartCall(); } - virtual void OnDone(const Status& s) {} - virtual void OnReadInitialMetadataDone(bool ok) {} - - private: - friend class ClientCallbackUnary; - void BindCall(ClientCallbackUnary* call) { call_ = call; } - ClientCallbackUnary* call_; -}; - -// Define function out-of-line from class to avoid forward declaration issue -inline void ClientCallbackUnary::BindReactor(ClientUnaryReactor* reactor) { - reactor->BindCall(this); -} +using ClientBidiReactor = + ::grpc_impl::experimental::ClientBidiReactor; +typedef ::grpc_impl::experimental::ClientUnaryReactor ClientUnaryReactor; } // namespace experimental - -namespace internal { - -// Forward declare factory classes for friendship -template -class ClientCallbackReaderWriterFactory; -template -class ClientCallbackReaderFactory; -template -class ClientCallbackWriterFactory; - -template -class ClientCallbackReaderWriterImpl - : public ::grpc::experimental::ClientCallbackReaderWriter { - public: - // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { - assert(size == sizeof(ClientCallbackReaderWriterImpl)); - } - - // This operator should never be called as the memory should be freed as part - // of the arena destruction. It only exists to provide a matching operator - // delete to the operator new so that some compilers will not complain (see - // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this - // there are no tests catching the compiler warning. - static void operator delete(void*, void*) { assert(0); } - - void MaybeFinish() { - if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( - 1, std::memory_order_acq_rel) == 1)) { - Status s = std::move(finish_status_); - auto* reactor = reactor_; - auto* call = call_.call(); - this->~ClientCallbackReaderWriterImpl(); - g_core_codegen_interface->grpc_call_unref(call); - reactor->OnDone(s); - } - } - - void StartCall() override { - // This call initiates two batches, plus any backlog, each with a callback - // 1. Send initial metadata (unless corked) + recv initial metadata - // 2. Any read backlog - // 3. Any write backlog - // 4. Recv trailing metadata, on_completion callback - started_ = true; - - start_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadInitialMetadataDone(ok); - MaybeFinish(); - }, - &start_ops_); - if (!start_corked_) { - start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - } - start_ops_.RecvInitialMetadata(context_); - start_ops_.set_core_cq_tag(&start_tag_); - call_.PerformOps(&start_ops_); - - // Also set up the read and write tags so that they don't have to be set up - // each time - write_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnWriteDone(ok); - MaybeFinish(); - }, - &write_ops_); - write_ops_.set_core_cq_tag(&write_tag_); - - read_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadDone(ok); - MaybeFinish(); - }, - &read_ops_); - read_ops_.set_core_cq_tag(&read_tag_); - if (read_ops_at_start_) { - call_.PerformOps(&read_ops_); - } - - if (write_ops_at_start_) { - call_.PerformOps(&write_ops_); - } - - if (writes_done_ops_at_start_) { - call_.PerformOps(&writes_done_ops_); - } - - finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, - &finish_ops_); - finish_ops_.ClientRecvStatus(context_, &finish_status_); - finish_ops_.set_core_cq_tag(&finish_tag_); - call_.PerformOps(&finish_ops_); - } - - void Read(Response* msg) override { - read_ops_.RecvMessage(msg); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - if (started_) { - call_.PerformOps(&read_ops_); - } else { - read_ops_at_start_ = true; - } - } - - void Write(const Request* msg, WriteOptions options) override { - if (start_corked_) { - write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - start_corked_ = false; - } - - if (options.is_last_message()) { - options.set_buffer_hint(); - write_ops_.ClientSendClose(); - } - // TODO(vjpai): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(msg, options).ok()); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - if (started_) { - call_.PerformOps(&write_ops_); - } else { - write_ops_at_start_ = true; - } - } - void WritesDone() override { - if (start_corked_) { - writes_done_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - start_corked_ = false; - } - writes_done_ops_.ClientSendClose(); - writes_done_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnWritesDoneDone(ok); - MaybeFinish(); - }, - &writes_done_ops_); - writes_done_ops_.set_core_cq_tag(&writes_done_tag_); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - if (started_) { - call_.PerformOps(&writes_done_ops_); - } else { - writes_done_ops_at_start_ = true; - } - } - - void AddHold(int holds) override { - callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed); - } - void RemoveHold() override { MaybeFinish(); } - - private: - friend class ClientCallbackReaderWriterFactory; - - ClientCallbackReaderWriterImpl( - Call call, ::grpc_impl::ClientContext* context, - ::grpc::experimental::ClientBidiReactor* reactor) - : context_(context), - call_(call), - reactor_(reactor), - start_corked_(context_->initial_metadata_corked_) { - this->BindReactor(reactor); - } - - ::grpc_impl::ClientContext* const context_; - Call call_; - ::grpc::experimental::ClientBidiReactor* const reactor_; - - CallOpSet start_ops_; - CallbackWithSuccessTag start_tag_; - bool start_corked_; - - CallOpSet finish_ops_; - CallbackWithSuccessTag finish_tag_; - Status finish_status_; - - CallOpSet - write_ops_; - CallbackWithSuccessTag write_tag_; - bool write_ops_at_start_{false}; - - CallOpSet writes_done_ops_; - CallbackWithSuccessTag writes_done_tag_; - bool writes_done_ops_at_start_{false}; - - CallOpSet> read_ops_; - CallbackWithSuccessTag read_tag_; - bool read_ops_at_start_{false}; - - // Minimum of 2 callbacks to pre-register for start and finish - std::atomic callbacks_outstanding_{2}; - bool started_{false}; -}; - -template -class ClientCallbackReaderWriterFactory { - public: - static void Create( - ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, - ::grpc::experimental::ClientBidiReactor* reactor) { - Call call = channel->CreateCall(method, context, channel->CallbackCQ()); - - g_core_codegen_interface->grpc_call_ref(call.call()); - new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(ClientCallbackReaderWriterImpl))) - ClientCallbackReaderWriterImpl(call, context, - reactor); - } -}; - -template -class ClientCallbackReaderImpl - : public ::grpc::experimental::ClientCallbackReader { - public: - // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { - assert(size == sizeof(ClientCallbackReaderImpl)); - } - - // This operator should never be called as the memory should be freed as part - // of the arena destruction. It only exists to provide a matching operator - // delete to the operator new so that some compilers will not complain (see - // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this - // there are no tests catching the compiler warning. - static void operator delete(void*, void*) { assert(0); } - - void MaybeFinish() { - if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( - 1, std::memory_order_acq_rel) == 1)) { - Status s = std::move(finish_status_); - auto* reactor = reactor_; - auto* call = call_.call(); - this->~ClientCallbackReaderImpl(); - g_core_codegen_interface->grpc_call_unref(call); - reactor->OnDone(s); - } - } - - void StartCall() override { - // This call initiates two batches, plus any backlog, each with a callback - // 1. Send initial metadata (unless corked) + recv initial metadata - // 2. Any backlog - // 3. Recv trailing metadata, on_completion callback - started_ = true; - - start_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadInitialMetadataDone(ok); - MaybeFinish(); - }, - &start_ops_); - start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - start_ops_.RecvInitialMetadata(context_); - start_ops_.set_core_cq_tag(&start_tag_); - call_.PerformOps(&start_ops_); - - // Also set up the read tag so it doesn't have to be set up each time - read_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadDone(ok); - MaybeFinish(); - }, - &read_ops_); - read_ops_.set_core_cq_tag(&read_tag_); - if (read_ops_at_start_) { - call_.PerformOps(&read_ops_); - } - - finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, - &finish_ops_); - finish_ops_.ClientRecvStatus(context_, &finish_status_); - finish_ops_.set_core_cq_tag(&finish_tag_); - call_.PerformOps(&finish_ops_); - } - - void Read(Response* msg) override { - read_ops_.RecvMessage(msg); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - if (started_) { - call_.PerformOps(&read_ops_); - } else { - read_ops_at_start_ = true; - } - } - - void AddHold(int holds) override { - callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed); - } - void RemoveHold() override { MaybeFinish(); } - - private: - friend class ClientCallbackReaderFactory; - - template - ClientCallbackReaderImpl( - Call call, ::grpc_impl::ClientContext* context, Request* request, - ::grpc::experimental::ClientReadReactor* reactor) - : context_(context), call_(call), reactor_(reactor) { - this->BindReactor(reactor); - // TODO(vjpai): don't assert - GPR_CODEGEN_ASSERT(start_ops_.SendMessagePtr(request).ok()); - start_ops_.ClientSendClose(); - } - - ::grpc_impl::ClientContext* const context_; - Call call_; - ::grpc::experimental::ClientReadReactor* const reactor_; - - CallOpSet - start_ops_; - CallbackWithSuccessTag start_tag_; - - CallOpSet finish_ops_; - CallbackWithSuccessTag finish_tag_; - Status finish_status_; - - CallOpSet> read_ops_; - CallbackWithSuccessTag read_tag_; - bool read_ops_at_start_{false}; - - // Minimum of 2 callbacks to pre-register for start and finish - std::atomic callbacks_outstanding_{2}; - bool started_{false}; -}; - -template -class ClientCallbackReaderFactory { - public: - template - static void Create( - ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, const Request* request, - ::grpc::experimental::ClientReadReactor* reactor) { - Call call = channel->CreateCall(method, context, channel->CallbackCQ()); - - g_core_codegen_interface->grpc_call_ref(call.call()); - new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(ClientCallbackReaderImpl))) - ClientCallbackReaderImpl(call, context, request, reactor); - } -}; - -template -class ClientCallbackWriterImpl - : public ::grpc::experimental::ClientCallbackWriter { - public: - // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { - assert(size == sizeof(ClientCallbackWriterImpl)); - } - - // This operator should never be called as the memory should be freed as part - // of the arena destruction. It only exists to provide a matching operator - // delete to the operator new so that some compilers will not complain (see - // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this - // there are no tests catching the compiler warning. - static void operator delete(void*, void*) { assert(0); } - - void MaybeFinish() { - if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( - 1, std::memory_order_acq_rel) == 1)) { - Status s = std::move(finish_status_); - auto* reactor = reactor_; - auto* call = call_.call(); - this->~ClientCallbackWriterImpl(); - g_core_codegen_interface->grpc_call_unref(call); - reactor->OnDone(s); - } - } - - void StartCall() override { - // This call initiates two batches, plus any backlog, each with a callback - // 1. Send initial metadata (unless corked) + recv initial metadata - // 2. Any backlog - // 3. Recv trailing metadata, on_completion callback - started_ = true; - - start_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadInitialMetadataDone(ok); - MaybeFinish(); - }, - &start_ops_); - if (!start_corked_) { - start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - } - start_ops_.RecvInitialMetadata(context_); - start_ops_.set_core_cq_tag(&start_tag_); - call_.PerformOps(&start_ops_); - - // Also set up the read and write tags so that they don't have to be set up - // each time - write_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnWriteDone(ok); - MaybeFinish(); - }, - &write_ops_); - write_ops_.set_core_cq_tag(&write_tag_); - - if (write_ops_at_start_) { - call_.PerformOps(&write_ops_); - } - - if (writes_done_ops_at_start_) { - call_.PerformOps(&writes_done_ops_); - } - - finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, - &finish_ops_); - finish_ops_.ClientRecvStatus(context_, &finish_status_); - finish_ops_.set_core_cq_tag(&finish_tag_); - call_.PerformOps(&finish_ops_); - } - - void Write(const Request* msg, WriteOptions options) override { - if (start_corked_) { - write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - start_corked_ = false; - } - - if (options.is_last_message()) { - options.set_buffer_hint(); - write_ops_.ClientSendClose(); - } - // TODO(vjpai): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(msg, options).ok()); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - if (started_) { - call_.PerformOps(&write_ops_); - } else { - write_ops_at_start_ = true; - } - } - void WritesDone() override { - if (start_corked_) { - writes_done_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - start_corked_ = false; - } - writes_done_ops_.ClientSendClose(); - writes_done_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnWritesDoneDone(ok); - MaybeFinish(); - }, - &writes_done_ops_); - writes_done_ops_.set_core_cq_tag(&writes_done_tag_); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - if (started_) { - call_.PerformOps(&writes_done_ops_); - } else { - writes_done_ops_at_start_ = true; - } - } - - void AddHold(int holds) override { - callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed); - } - void RemoveHold() override { MaybeFinish(); } - - private: - friend class ClientCallbackWriterFactory; - - template - ClientCallbackWriterImpl( - Call call, ::grpc_impl::ClientContext* context, Response* response, - ::grpc::experimental::ClientWriteReactor* reactor) - : context_(context), - call_(call), - reactor_(reactor), - start_corked_(context_->initial_metadata_corked_) { - this->BindReactor(reactor); - finish_ops_.RecvMessage(response); - finish_ops_.AllowNoMessage(); - } - - ::grpc_impl::ClientContext* const context_; - Call call_; - ::grpc::experimental::ClientWriteReactor* const reactor_; - - CallOpSet start_ops_; - CallbackWithSuccessTag start_tag_; - bool start_corked_; - - CallOpSet finish_ops_; - CallbackWithSuccessTag finish_tag_; - Status finish_status_; - - CallOpSet - write_ops_; - CallbackWithSuccessTag write_tag_; - bool write_ops_at_start_{false}; - - CallOpSet writes_done_ops_; - CallbackWithSuccessTag writes_done_tag_; - bool writes_done_ops_at_start_{false}; - - // Minimum of 2 callbacks to pre-register for start and finish - std::atomic callbacks_outstanding_{2}; - bool started_{false}; -}; - -template -class ClientCallbackWriterFactory { - public: - template - static void Create( - ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, Response* response, - ::grpc::experimental::ClientWriteReactor* reactor) { - Call call = channel->CreateCall(method, context, channel->CallbackCQ()); - - g_core_codegen_interface->grpc_call_ref(call.call()); - new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(ClientCallbackWriterImpl))) - ClientCallbackWriterImpl(call, context, response, reactor); - } -}; - -class ClientCallbackUnaryImpl final - : public ::grpc::experimental::ClientCallbackUnary { - public: - // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { - assert(size == sizeof(ClientCallbackUnaryImpl)); - } - - // This operator should never be called as the memory should be freed as part - // of the arena destruction. It only exists to provide a matching operator - // delete to the operator new so that some compilers will not complain (see - // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this - // there are no tests catching the compiler warning. - static void operator delete(void*, void*) { assert(0); } - - void StartCall() override { - // This call initiates two batches, each with a callback - // 1. Send initial metadata + write + writes done + recv initial metadata - // 2. Read message, recv trailing metadata - started_ = true; - - start_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadInitialMetadataDone(ok); - MaybeFinish(); - }, - &start_ops_); - start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - start_ops_.RecvInitialMetadata(context_); - start_ops_.set_core_cq_tag(&start_tag_); - call_.PerformOps(&start_ops_); - - finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, - &finish_ops_); - finish_ops_.ClientRecvStatus(context_, &finish_status_); - finish_ops_.set_core_cq_tag(&finish_tag_); - call_.PerformOps(&finish_ops_); - } - - void MaybeFinish() { - if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( - 1, std::memory_order_acq_rel) == 1)) { - Status s = std::move(finish_status_); - auto* reactor = reactor_; - auto* call = call_.call(); - this->~ClientCallbackUnaryImpl(); - g_core_codegen_interface->grpc_call_unref(call); - reactor->OnDone(s); - } - } - - private: - friend class ClientCallbackUnaryFactory; - - template - ClientCallbackUnaryImpl(Call call, ::grpc_impl::ClientContext* context, - Request* request, Response* response, - ::grpc::experimental::ClientUnaryReactor* reactor) - : context_(context), call_(call), reactor_(reactor) { - this->BindReactor(reactor); - // TODO(vjpai): don't assert - GPR_CODEGEN_ASSERT(start_ops_.SendMessagePtr(request).ok()); - start_ops_.ClientSendClose(); - finish_ops_.RecvMessage(response); - finish_ops_.AllowNoMessage(); - } - - ::grpc_impl::ClientContext* const context_; - Call call_; - ::grpc::experimental::ClientUnaryReactor* const reactor_; - - CallOpSet - start_ops_; - CallbackWithSuccessTag start_tag_; - - CallOpSet finish_ops_; - CallbackWithSuccessTag finish_tag_; - Status finish_status_; - - // This call will have 2 callbacks: start and finish - std::atomic callbacks_outstanding_{2}; - bool started_{false}; -}; - -class ClientCallbackUnaryFactory { - public: - template - static void Create(ChannelInterface* channel, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, - const Request* request, Response* response, - ::grpc::experimental::ClientUnaryReactor* reactor) { - Call call = channel->CreateCall(method, context, channel->CallbackCQ()); - - g_core_codegen_interface->grpc_call_ref(call.call()); - - new (g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(ClientCallbackUnaryImpl))) - ClientCallbackUnaryImpl(call, context, request, response, reactor); - } -}; - -} // namespace internal } // namespace grpc #endif // GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_H diff --git a/include/grpcpp/impl/codegen/client_callback_impl.h b/include/grpcpp/impl/codegen/client_callback_impl.h new file mode 100644 index 00000000000..81847bc9e04 --- /dev/null +++ b/include/grpcpp/impl/codegen/client_callback_impl.h @@ -0,0 +1,1067 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_IMPL_H +#define GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_IMPL_H +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace grpc { +namespace internal { +class RpcMethod; +} // namespace internal +} // namespace grpc + +namespace grpc_impl { +class Channel; +class ClientContext; + +namespace internal { + +/// Perform a callback-based unary call +/// TODO(vjpai): Combine as much as possible with the blocking unary call code +template +void CallbackUnaryCall(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + const InputMessage* request, OutputMessage* result, + std::function on_completion) { + CallbackUnaryCallImpl x( + channel, method, context, request, result, on_completion); +} + +template +class CallbackUnaryCallImpl { + public: + CallbackUnaryCallImpl(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + const InputMessage* request, OutputMessage* result, + std::function on_completion) { + ::grpc_impl::CompletionQueue* cq = channel->CallbackCQ(); + GPR_CODEGEN_ASSERT(cq != nullptr); + grpc::internal::Call call(channel->CreateCall(method, context, cq)); + + using FullCallOpSet = grpc::internal::CallOpSet< + ::grpc::internal::CallOpSendInitialMetadata, + grpc::internal::CallOpSendMessage, + grpc::internal::CallOpRecvInitialMetadata, + grpc::internal::CallOpRecvMessage, + grpc::internal::CallOpClientSendClose, + grpc::internal::CallOpClientRecvStatus>; + + auto* ops = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(FullCallOpSet))) FullCallOpSet; + + auto* tag = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(grpc::internal::CallbackWithStatusTag))) + grpc::internal::CallbackWithStatusTag(call.call(), on_completion, ops); + + // TODO(vjpai): Unify code with sync API as much as possible + ::grpc::Status s = ops->SendMessagePtr(request); + if (!s.ok()) { + tag->force_run(s); + return; + } + ops->SendInitialMetadata(&context->send_initial_metadata_, + context->initial_metadata_flags()); + ops->RecvInitialMetadata(context); + ops->RecvMessage(result); + ops->AllowNoMessage(); + ops->ClientSendClose(); + ops->ClientRecvStatus(context, tag->status_ptr()); + ops->set_core_cq_tag(tag); + call.PerformOps(ops); + } +}; +} // namespace internal + +namespace experimental { + +// Forward declarations +template +class ClientBidiReactor; +template +class ClientReadReactor; +template +class ClientWriteReactor; +class ClientUnaryReactor; + +// NOTE: The streaming objects are not actually implemented in the public API. +// These interfaces are provided for mocking only. Typical applications +// will interact exclusively with the reactors that they define. +template +class ClientCallbackReaderWriter { + public: + virtual ~ClientCallbackReaderWriter() {} + virtual void StartCall() = 0; + virtual void Write(const Request* req, ::grpc::WriteOptions options) = 0; + virtual void WritesDone() = 0; + virtual void Read(Response* resp) = 0; + virtual void AddHold(int holds) = 0; + virtual void RemoveHold() = 0; + + protected: + void BindReactor(ClientBidiReactor* reactor) { + reactor->BindStream(this); + } +}; + +template +class ClientCallbackReader { + public: + virtual ~ClientCallbackReader() {} + virtual void StartCall() = 0; + virtual void Read(Response* resp) = 0; + virtual void AddHold(int holds) = 0; + virtual void RemoveHold() = 0; + + protected: + void BindReactor(ClientReadReactor* reactor) { + reactor->BindReader(this); + } +}; + +template +class ClientCallbackWriter { + public: + virtual ~ClientCallbackWriter() {} + virtual void StartCall() = 0; + void Write(const Request* req) { Write(req, ::grpc::WriteOptions()); } + virtual void Write(const Request* req, ::grpc::WriteOptions options) = 0; + void WriteLast(const Request* req, ::grpc::WriteOptions options) { + Write(req, options.set_last_message()); + } + virtual void WritesDone() = 0; + + virtual void AddHold(int holds) = 0; + virtual void RemoveHold() = 0; + + protected: + void BindReactor(ClientWriteReactor* reactor) { + reactor->BindWriter(this); + } +}; + +class ClientCallbackUnary { + public: + virtual ~ClientCallbackUnary() {} + virtual void StartCall() = 0; + + protected: + void BindReactor(ClientUnaryReactor* reactor); +}; + +// The following classes are the reactor interfaces that are to be implemented +// by the user. They are passed in to the library as an argument to a call on a +// stub (either a codegen-ed call or a generic call). The streaming RPC is +// activated by calling StartCall, possibly after initiating StartRead, +// StartWrite, or AddHold operations on the streaming object. Note that none of +// the classes are pure; all reactions have a default empty reaction so that the +// user class only needs to override those classes that it cares about. +// The reactor must be passed to the stub invocation before any of the below +// operations can be called. + +/// \a ClientBidiReactor is the interface for a bidirectional streaming RPC. +template +class ClientBidiReactor { + public: + virtual ~ClientBidiReactor() {} + + /// Activate the RPC and initiate any reads or writes that have been Start'ed + /// before this call. All streaming RPCs issued by the client MUST have + /// StartCall invoked on them (even if they are canceled) as this call is the + /// activation of their lifecycle. + void StartCall() { stream_->StartCall(); } + + /// Initiate a read operation (or post it for later initiation if StartCall + /// has not yet been invoked). + /// + /// \param[out] resp Where to eventually store the read message. Valid when + /// the library calls OnReadDone + void StartRead(Response* resp) { stream_->Read(resp); } + + /// Initiate a write operation (or post it for later initiation if StartCall + /// has not yet been invoked). + /// + /// \param[in] req The message to be written. The library takes temporary + /// ownership until OnWriteDone, at which point the application + /// regains ownership of msg. + void StartWrite(const Request* req) { + StartWrite(req, ::grpc::WriteOptions()); + } + + /// Initiate/post a write operation with specified options. + /// + /// \param[in] req The message to be written. The library takes temporary + /// ownership until OnWriteDone, at which point the application + /// regains ownership of msg. + /// \param[in] options The WriteOptions to use for writing this message + void StartWrite(const Request* req, ::grpc::WriteOptions options) { + stream_->Write(req, std::move(options)); + } + + /// Initiate/post a write operation with specified options and an indication + /// that this is the last write (like StartWrite and StartWritesDone, merged). + /// Note that calling this means that no more calls to StartWrite, + /// StartWriteLast, or StartWritesDone are allowed. + /// + /// \param[in] req The message to be written. The library takes temporary + /// ownership until OnWriteDone, at which point the application + /// regains ownership of msg. + /// \param[in] options The WriteOptions to use for writing this message + void StartWriteLast(const Request* req, ::grpc::WriteOptions options) { + StartWrite(req, std::move(options.set_last_message())); + } + + /// Indicate that the RPC will have no more write operations. This can only be + /// issued once for a given RPC. This is not required or allowed if + /// StartWriteLast is used since that already has the same implication. + /// Note that calling this means that no more calls to StartWrite, + /// StartWriteLast, or StartWritesDone are allowed. + void StartWritesDone() { stream_->WritesDone(); } + + /// Holds are needed if (and only if) this stream has operations that take + /// place on it after StartCall but from outside one of the reactions + /// (OnReadDone, etc). This is _not_ a common use of the streaming API. + /// + /// Holds must be added before calling StartCall. If a stream still has a hold + /// in place, its resources will not be destroyed even if the status has + /// already come in from the wire and there are currently no active callbacks + /// outstanding. Similarly, the stream will not call OnDone if there are still + /// holds on it. + /// + /// For example, if a StartRead or StartWrite operation is going to be + /// initiated from elsewhere in the application, the application should call + /// AddHold or AddMultipleHolds before StartCall. If there is going to be, + /// for example, a read-flow and a write-flow taking place outside the + /// reactions, then call AddMultipleHolds(2) before StartCall. When the + /// application knows that it won't issue any more read operations (such as + /// when a read comes back as not ok), it should issue a RemoveHold(). It + /// should also call RemoveHold() again after it does StartWriteLast or + /// StartWritesDone that indicates that there will be no more write ops. + /// The number of RemoveHold calls must match the total number of AddHold + /// calls plus the number of holds added by AddMultipleHolds. + void AddHold() { AddMultipleHolds(1); } + void AddMultipleHolds(int holds) { stream_->AddHold(holds); } + void RemoveHold() { stream_->RemoveHold(); } + + /// Notifies the application that all operations associated with this RPC + /// have completed and provides the RPC status outcome. + /// + /// \param[in] s The status outcome of this RPC + virtual void OnDone(const ::grpc::Status& s) {} + + /// Notifies the application that a read of initial metadata from the + /// server is done. If the application chooses not to implement this method, + /// it can assume that the initial metadata has been read before the first + /// call of OnReadDone or OnDone. + /// + /// \param[in] ok Was the initial metadata read successfully? If false, no + /// further read-side operation will succeed. + virtual void OnReadInitialMetadataDone(bool ok) {} + + /// Notifies the application that a StartRead operation completed. + /// + /// \param[in] ok Was it successful? If false, no further read-side operation + /// will succeed. + virtual void OnReadDone(bool ok) {} + + /// Notifies the application that a StartWrite operation completed. + /// + /// \param[in] ok Was it successful? If false, no further write-side operation + /// will succeed. + virtual void OnWriteDone(bool ok) {} + + /// Notifies the application that a StartWritesDone operation completed. Note + /// that this is only used on explicit StartWritesDone operations and not for + /// those that are implicitly invoked as part of a StartWriteLast. + /// + /// \param[in] ok Was it successful? If false, the application will later see + /// the failure reflected as a bad status in OnDone. + virtual void OnWritesDoneDone(bool ok) {} + + private: + friend class ClientCallbackReaderWriter; + void BindStream(ClientCallbackReaderWriter* stream) { + stream_ = stream; + } + ClientCallbackReaderWriter* stream_; +}; + +/// \a ClientReadReactor is the interface for a server-streaming RPC. +/// All public methods behave as in ClientBidiReactor. +template +class ClientReadReactor { + public: + virtual ~ClientReadReactor() {} + + void StartCall() { reader_->StartCall(); } + void StartRead(Response* resp) { reader_->Read(resp); } + + void AddHold() { AddMultipleHolds(1); } + void AddMultipleHolds(int holds) { reader_->AddHold(holds); } + void RemoveHold() { reader_->RemoveHold(); } + + virtual void OnDone(const ::grpc::Status& s) {} + virtual void OnReadInitialMetadataDone(bool ok) {} + virtual void OnReadDone(bool ok) {} + + private: + friend class ClientCallbackReader; + void BindReader(ClientCallbackReader* reader) { reader_ = reader; } + ClientCallbackReader* reader_; +}; + +/// \a ClientWriteReactor is the interface for a client-streaming RPC. +/// All public methods behave as in ClientBidiReactor. +template +class ClientWriteReactor { + public: + virtual ~ClientWriteReactor() {} + + void StartCall() { writer_->StartCall(); } + void StartWrite(const Request* req) { + StartWrite(req, ::grpc::WriteOptions()); + } + void StartWrite(const Request* req, ::grpc::WriteOptions options) { + writer_->Write(req, std::move(options)); + } + void StartWriteLast(const Request* req, ::grpc::WriteOptions options) { + StartWrite(req, std::move(options.set_last_message())); + } + void StartWritesDone() { writer_->WritesDone(); } + + void AddHold() { AddMultipleHolds(1); } + void AddMultipleHolds(int holds) { writer_->AddHold(holds); } + void RemoveHold() { writer_->RemoveHold(); } + + virtual void OnDone(const ::grpc::Status& s) {} + virtual void OnReadInitialMetadataDone(bool ok) {} + virtual void OnWriteDone(bool ok) {} + virtual void OnWritesDoneDone(bool ok) {} + + private: + friend class ClientCallbackWriter; + void BindWriter(ClientCallbackWriter* writer) { writer_ = writer; } + ClientCallbackWriter* writer_; +}; + +/// \a ClientUnaryReactor is a reactor-style interface for a unary RPC. +/// This is _not_ a common way of invoking a unary RPC. In practice, this +/// option should be used only if the unary RPC wants to receive initial +/// metadata without waiting for the response to complete. Most deployments of +/// RPC systems do not use this option, but it is needed for generality. +/// All public methods behave as in ClientBidiReactor. +/// StartCall is included for consistency with the other reactor flavors: even +/// though there are no StartRead or StartWrite operations to queue before the +/// call (that is part of the unary call itself) and there is no reactor object +/// being created as a result of this call, we keep a consistent 2-phase +/// initiation API among all the reactor flavors. +class ClientUnaryReactor { + public: + virtual ~ClientUnaryReactor() {} + + void StartCall() { call_->StartCall(); } + virtual void OnDone(const ::grpc::Status& s) {} + virtual void OnReadInitialMetadataDone(bool ok) {} + + private: + friend class ClientCallbackUnary; + void BindCall(ClientCallbackUnary* call) { call_ = call; } + ClientCallbackUnary* call_; +}; + +// Define function out-of-line from class to avoid forward declaration issue +inline void ClientCallbackUnary::BindReactor(ClientUnaryReactor* reactor) { + reactor->BindCall(this); +} + +} // namespace experimental + +namespace internal { + +// Forward declare factory classes for friendship +template +class ClientCallbackReaderWriterFactory; +template +class ClientCallbackReaderFactory; +template +class ClientCallbackWriterFactory; + +template +class ClientCallbackReaderWriterImpl + : public experimental::ClientCallbackReaderWriter { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* ptr, std::size_t size) { + assert(size == sizeof(ClientCallbackReaderWriterImpl)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { assert(0); } + + void MaybeFinish() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + ::grpc::Status s = std::move(finish_status_); + auto* reactor = reactor_; + auto* call = call_.call(); + this->~ClientCallbackReaderWriterImpl(); + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + reactor->OnDone(s); + } + } + + void StartCall() override { + // This call initiates two batches, plus any backlog, each with a callback + // 1. Send initial metadata (unless corked) + recv initial metadata + // 2. Any read backlog + // 3. Any write backlog + // 4. Recv trailing metadata, on_completion callback + started_ = true; + + start_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadInitialMetadataDone(ok); + MaybeFinish(); + }, + &start_ops_); + if (!start_corked_) { + start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + } + start_ops_.RecvInitialMetadata(context_); + start_ops_.set_core_cq_tag(&start_tag_); + call_.PerformOps(&start_ops_); + + // Also set up the read and write tags so that they don't have to be set up + // each time + write_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnWriteDone(ok); + MaybeFinish(); + }, + &write_ops_); + write_ops_.set_core_cq_tag(&write_tag_); + + read_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadDone(ok); + MaybeFinish(); + }, + &read_ops_); + read_ops_.set_core_cq_tag(&read_tag_); + if (read_ops_at_start_) { + call_.PerformOps(&read_ops_); + } + + if (write_ops_at_start_) { + call_.PerformOps(&write_ops_); + } + + if (writes_done_ops_at_start_) { + call_.PerformOps(&writes_done_ops_); + } + + finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, + &finish_ops_); + finish_ops_.ClientRecvStatus(context_, &finish_status_); + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void Read(Response* msg) override { + read_ops_.RecvMessage(msg); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (started_) { + call_.PerformOps(&read_ops_); + } else { + read_ops_at_start_ = true; + } + } + + void Write(const Request* msg, ::grpc::WriteOptions options) override { + if (start_corked_) { + write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + start_corked_ = false; + } + + if (options.is_last_message()) { + options.set_buffer_hint(); + write_ops_.ClientSendClose(); + } + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(msg, options).ok()); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (started_) { + call_.PerformOps(&write_ops_); + } else { + write_ops_at_start_ = true; + } + } + void WritesDone() override { + if (start_corked_) { + writes_done_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + start_corked_ = false; + } + writes_done_ops_.ClientSendClose(); + writes_done_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnWritesDoneDone(ok); + MaybeFinish(); + }, + &writes_done_ops_); + writes_done_ops_.set_core_cq_tag(&writes_done_tag_); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (started_) { + call_.PerformOps(&writes_done_ops_); + } else { + writes_done_ops_at_start_ = true; + } + } + + void AddHold(int holds) override { + callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed); + } + void RemoveHold() override { MaybeFinish(); } + + private: + friend class ClientCallbackReaderWriterFactory; + + ClientCallbackReaderWriterImpl( + grpc::internal::Call call, ::grpc_impl::ClientContext* context, + experimental::ClientBidiReactor* reactor) + : context_(context), + call_(call), + reactor_(reactor), + start_corked_(context_->initial_metadata_corked_) { + this->BindReactor(reactor); + } + + ::grpc_impl::ClientContext* const context_; + grpc::internal::Call call_; + experimental::ClientBidiReactor* const reactor_; + + grpc::internal::CallOpSet + start_ops_; + grpc::internal::CallbackWithSuccessTag start_tag_; + bool start_corked_; + + grpc::internal::CallOpSet finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + ::grpc::Status finish_status_; + + grpc::internal::CallOpSet + write_ops_; + grpc::internal::CallbackWithSuccessTag write_tag_; + bool write_ops_at_start_{false}; + + grpc::internal::CallOpSet + writes_done_ops_; + grpc::internal::CallbackWithSuccessTag writes_done_tag_; + bool writes_done_ops_at_start_{false}; + + grpc::internal::CallOpSet> + read_ops_; + grpc::internal::CallbackWithSuccessTag read_tag_; + bool read_ops_at_start_{false}; + + // Minimum of 2 callbacks to pre-register for start and finish + std::atomic callbacks_outstanding_{2}; + bool started_{false}; +}; + +template +class ClientCallbackReaderWriterFactory { + public: + static void Create( + ::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + experimental::ClientBidiReactor* reactor) { + grpc::internal::Call call = + channel->CreateCall(method, context, channel->CallbackCQ()); + + ::grpc::g_core_codegen_interface->grpc_call_ref(call.call()); + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientCallbackReaderWriterImpl))) + ClientCallbackReaderWriterImpl(call, context, + reactor); + } +}; + +template +class ClientCallbackReaderImpl + : public experimental::ClientCallbackReader { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* ptr, std::size_t size) { + assert(size == sizeof(ClientCallbackReaderImpl)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { assert(0); } + + void MaybeFinish() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + ::grpc::Status s = std::move(finish_status_); + auto* reactor = reactor_; + auto* call = call_.call(); + this->~ClientCallbackReaderImpl(); + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + reactor->OnDone(s); + } + } + + void StartCall() override { + // This call initiates two batches, plus any backlog, each with a callback + // 1. Send initial metadata (unless corked) + recv initial metadata + // 2. Any backlog + // 3. Recv trailing metadata, on_completion callback + started_ = true; + + start_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadInitialMetadataDone(ok); + MaybeFinish(); + }, + &start_ops_); + start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + start_ops_.RecvInitialMetadata(context_); + start_ops_.set_core_cq_tag(&start_tag_); + call_.PerformOps(&start_ops_); + + // Also set up the read tag so it doesn't have to be set up each time + read_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadDone(ok); + MaybeFinish(); + }, + &read_ops_); + read_ops_.set_core_cq_tag(&read_tag_); + if (read_ops_at_start_) { + call_.PerformOps(&read_ops_); + } + + finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, + &finish_ops_); + finish_ops_.ClientRecvStatus(context_, &finish_status_); + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void Read(Response* msg) override { + read_ops_.RecvMessage(msg); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (started_) { + call_.PerformOps(&read_ops_); + } else { + read_ops_at_start_ = true; + } + } + + void AddHold(int holds) override { + callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed); + } + void RemoveHold() override { MaybeFinish(); } + + private: + friend class ClientCallbackReaderFactory; + + template + ClientCallbackReaderImpl(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, + Request* request, + experimental::ClientReadReactor* reactor) + : context_(context), call_(call), reactor_(reactor) { + this->BindReactor(reactor); + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(start_ops_.SendMessagePtr(request).ok()); + start_ops_.ClientSendClose(); + } + + ::grpc_impl::ClientContext* const context_; + grpc::internal::Call call_; + experimental::ClientReadReactor* const reactor_; + + grpc::internal::CallOpSet + start_ops_; + grpc::internal::CallbackWithSuccessTag start_tag_; + + grpc::internal::CallOpSet finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + ::grpc::Status finish_status_; + + grpc::internal::CallOpSet> + read_ops_; + grpc::internal::CallbackWithSuccessTag read_tag_; + bool read_ops_at_start_{false}; + + // Minimum of 2 callbacks to pre-register for start and finish + std::atomic callbacks_outstanding_{2}; + bool started_{false}; +}; + +template +class ClientCallbackReaderFactory { + public: + template + static void Create(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + const Request* request, + experimental::ClientReadReactor* reactor) { + grpc::internal::Call call = + channel->CreateCall(method, context, channel->CallbackCQ()); + + ::grpc::g_core_codegen_interface->grpc_call_ref(call.call()); + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientCallbackReaderImpl))) + ClientCallbackReaderImpl(call, context, request, reactor); + } +}; + +template +class ClientCallbackWriterImpl + : public experimental::ClientCallbackWriter { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* ptr, std::size_t size) { + assert(size == sizeof(ClientCallbackWriterImpl)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { assert(0); } + + void MaybeFinish() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + ::grpc::Status s = std::move(finish_status_); + auto* reactor = reactor_; + auto* call = call_.call(); + this->~ClientCallbackWriterImpl(); + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + reactor->OnDone(s); + } + } + + void StartCall() override { + // This call initiates two batches, plus any backlog, each with a callback + // 1. Send initial metadata (unless corked) + recv initial metadata + // 2. Any backlog + // 3. Recv trailing metadata, on_completion callback + started_ = true; + + start_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadInitialMetadataDone(ok); + MaybeFinish(); + }, + &start_ops_); + if (!start_corked_) { + start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + } + start_ops_.RecvInitialMetadata(context_); + start_ops_.set_core_cq_tag(&start_tag_); + call_.PerformOps(&start_ops_); + + // Also set up the read and write tags so that they don't have to be set up + // each time + write_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnWriteDone(ok); + MaybeFinish(); + }, + &write_ops_); + write_ops_.set_core_cq_tag(&write_tag_); + + if (write_ops_at_start_) { + call_.PerformOps(&write_ops_); + } + + if (writes_done_ops_at_start_) { + call_.PerformOps(&writes_done_ops_); + } + + finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, + &finish_ops_); + finish_ops_.ClientRecvStatus(context_, &finish_status_); + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void Write(const Request* msg, ::grpc::WriteOptions options) override { + if (start_corked_) { + write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + start_corked_ = false; + } + + if (options.is_last_message()) { + options.set_buffer_hint(); + write_ops_.ClientSendClose(); + } + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(msg, options).ok()); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (started_) { + call_.PerformOps(&write_ops_); + } else { + write_ops_at_start_ = true; + } + } + void WritesDone() override { + if (start_corked_) { + writes_done_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + start_corked_ = false; + } + writes_done_ops_.ClientSendClose(); + writes_done_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnWritesDoneDone(ok); + MaybeFinish(); + }, + &writes_done_ops_); + writes_done_ops_.set_core_cq_tag(&writes_done_tag_); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (started_) { + call_.PerformOps(&writes_done_ops_); + } else { + writes_done_ops_at_start_ = true; + } + } + + void AddHold(int holds) override { + callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed); + } + void RemoveHold() override { MaybeFinish(); } + + private: + friend class ClientCallbackWriterFactory; + + template + ClientCallbackWriterImpl(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, + Response* response, + experimental::ClientWriteReactor* reactor) + : context_(context), + call_(call), + reactor_(reactor), + start_corked_(context_->initial_metadata_corked_) { + this->BindReactor(reactor); + finish_ops_.RecvMessage(response); + finish_ops_.AllowNoMessage(); + } + + ::grpc_impl::ClientContext* const context_; + grpc::internal::Call call_; + experimental::ClientWriteReactor* const reactor_; + + grpc::internal::CallOpSet + start_ops_; + grpc::internal::CallbackWithSuccessTag start_tag_; + bool start_corked_; + + grpc::internal::CallOpSet + finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + ::grpc::Status finish_status_; + + grpc::internal::CallOpSet + write_ops_; + grpc::internal::CallbackWithSuccessTag write_tag_; + bool write_ops_at_start_{false}; + + grpc::internal::CallOpSet + writes_done_ops_; + grpc::internal::CallbackWithSuccessTag writes_done_tag_; + bool writes_done_ops_at_start_{false}; + + // Minimum of 2 callbacks to pre-register for start and finish + std::atomic callbacks_outstanding_{2}; + bool started_{false}; +}; + +template +class ClientCallbackWriterFactory { + public: + template + static void Create(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, Response* response, + experimental::ClientWriteReactor* reactor) { + grpc::internal::Call call = + channel->CreateCall(method, context, channel->CallbackCQ()); + + ::grpc::g_core_codegen_interface->grpc_call_ref(call.call()); + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientCallbackWriterImpl))) + ClientCallbackWriterImpl(call, context, response, reactor); + } +}; + +class ClientCallbackUnaryImpl final : public experimental::ClientCallbackUnary { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* ptr, std::size_t size) { + assert(size == sizeof(ClientCallbackUnaryImpl)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { assert(0); } + + void StartCall() override { + // This call initiates two batches, each with a callback + // 1. Send initial metadata + write + writes done + recv initial metadata + // 2. Read message, recv trailing metadata + started_ = true; + + start_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadInitialMetadataDone(ok); + MaybeFinish(); + }, + &start_ops_); + start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + start_ops_.RecvInitialMetadata(context_); + start_ops_.set_core_cq_tag(&start_tag_); + call_.PerformOps(&start_ops_); + + finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, + &finish_ops_); + finish_ops_.ClientRecvStatus(context_, &finish_status_); + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void MaybeFinish() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + ::grpc::Status s = std::move(finish_status_); + auto* reactor = reactor_; + auto* call = call_.call(); + this->~ClientCallbackUnaryImpl(); + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + reactor->OnDone(s); + } + } + + private: + friend class ClientCallbackUnaryFactory; + + template + ClientCallbackUnaryImpl(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, Request* request, + Response* response, + experimental::ClientUnaryReactor* reactor) + : context_(context), call_(call), reactor_(reactor) { + this->BindReactor(reactor); + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(start_ops_.SendMessagePtr(request).ok()); + start_ops_.ClientSendClose(); + finish_ops_.RecvMessage(response); + finish_ops_.AllowNoMessage(); + } + + ::grpc_impl::ClientContext* const context_; + grpc::internal::Call call_; + experimental::ClientUnaryReactor* const reactor_; + + grpc::internal::CallOpSet + start_ops_; + grpc::internal::CallbackWithSuccessTag start_tag_; + + grpc::internal::CallOpSet + finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + ::grpc::Status finish_status_; + + // This call will have 2 callbacks: start and finish + std::atomic callbacks_outstanding_{2}; + bool started_{false}; +}; + +class ClientCallbackUnaryFactory { + public: + template + static void Create(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + const Request* request, Response* response, + experimental::ClientUnaryReactor* reactor) { + grpc::internal::Call call = + channel->CreateCall(method, context, channel->CallbackCQ()); + + ::grpc::g_core_codegen_interface->grpc_call_ref(call.call()); + + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientCallbackUnaryImpl))) + ClientCallbackUnaryImpl(call, context, request, response, reactor); + } +}; + +} // namespace internal +} // namespace grpc_impl +#endif // GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_IMPL_H diff --git a/include/grpcpp/impl/codegen/client_context_impl.h b/include/grpcpp/impl/codegen/client_context_impl.h index 8491215cf0e..638ea641bed 100644 --- a/include/grpcpp/impl/codegen/client_context_impl.h +++ b/include/grpcpp/impl/codegen/client_context_impl.h @@ -63,10 +63,19 @@ class ChannelInterface; namespace internal { class RpcMethod; -class CallOpClientRecvStatus; -class CallOpRecvInitialMetadata; template class BlockingUnaryCallImpl; +class CallOpClientRecvStatus; +class CallOpRecvInitialMetadata; +} // namespace internal + +namespace testing { +class InteropClientContextInspector; +} // namespace testing +} // namespace grpc +namespace grpc_impl { + +namespace internal { template class CallbackUnaryCallImpl; template @@ -78,6 +87,10 @@ class ClientCallbackWriterImpl; class ClientCallbackUnaryImpl; } // namespace internal +class CallCredentials; +class Channel; +class CompletionQueue; +class ServerContext; template class ClientReader; template @@ -93,17 +106,6 @@ class ClientAsyncReaderWriter; template class ClientAsyncResponseReader; -namespace testing { -class InteropClientContextInspector; -} // namespace testing -} // namespace grpc -namespace grpc_impl { - -class CallCredentials; -class Channel; -class CompletionQueue; -class ServerContext; - /// Options for \a ClientContext::FromServerContext specifying which traits from /// the \a ServerContext to propagate (copy) from it into a new \a /// ClientContext. @@ -398,30 +400,30 @@ class ClientContext { friend class ::grpc::internal::CallOpRecvInitialMetadata; friend class ::grpc_impl::Channel; template - friend class ::grpc::ClientReader; + friend class ::grpc_impl::ClientReader; template - friend class ::grpc::ClientWriter; + friend class ::grpc_impl::ClientWriter; template - friend class ::grpc::ClientReaderWriter; + friend class ::grpc_impl::ClientReaderWriter; template - friend class ::grpc::ClientAsyncReader; + friend class ::grpc_impl::ClientAsyncReader; template - friend class ::grpc::ClientAsyncWriter; + friend class ::grpc_impl::ClientAsyncWriter; template - friend class ::grpc::ClientAsyncReaderWriter; + friend class ::grpc_impl::ClientAsyncReaderWriter; template - friend class ::grpc::ClientAsyncResponseReader; + friend class ::grpc_impl::ClientAsyncResponseReader; template friend class ::grpc::internal::BlockingUnaryCallImpl; template - friend class ::grpc::internal::CallbackUnaryCallImpl; + friend class ::grpc_impl::internal::CallbackUnaryCallImpl; template - friend class ::grpc::internal::ClientCallbackReaderWriterImpl; + friend class ::grpc_impl::internal::ClientCallbackReaderWriterImpl; template - friend class ::grpc::internal::ClientCallbackReaderImpl; + friend class ::grpc_impl::internal::ClientCallbackReaderImpl; template - friend class ::grpc::internal::ClientCallbackWriterImpl; - friend class ::grpc::internal::ClientCallbackUnaryImpl; + friend class ::grpc_impl::internal::ClientCallbackWriterImpl; + friend class ::grpc_impl::internal::ClientCallbackUnaryImpl; // Used by friend class CallOpClientRecvStatus void set_debug_error_string(const grpc::string& debug_error_string) { diff --git a/include/grpcpp/impl/codegen/client_unary_call.h b/include/grpcpp/impl/codegen/client_unary_call.h index 599dd1ecac9..7f80e571c07 100644 --- a/include/grpcpp/impl/codegen/client_unary_call.h +++ b/include/grpcpp/impl/codegen/client_unary_call.h @@ -49,10 +49,10 @@ class BlockingUnaryCallImpl { BlockingUnaryCallImpl(ChannelInterface* channel, const RpcMethod& method, grpc_impl::ClientContext* context, const InputMessage& request, OutputMessage* result) { - CompletionQueue cq(grpc_completion_queue_attributes{ + ::grpc_impl::CompletionQueue cq(grpc_completion_queue_attributes{ GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, nullptr}); // Pluckable completion queue - Call call(channel->CreateCall(method, context, &cq)); + ::grpc::internal::Call call(channel->CreateCall(method, context, &cq)); CallOpSet, CallOpClientSendClose, CallOpClientRecvStatus> diff --git a/include/grpcpp/impl/codegen/completion_queue_impl.h b/include/grpcpp/impl/codegen/completion_queue_impl.h index 0a6b0b0977b..7716a57e84a 100644 --- a/include/grpcpp/impl/codegen/completion_queue_impl.h +++ b/include/grpcpp/impl/codegen/completion_queue_impl.h @@ -47,9 +47,6 @@ class Channel; class Server; class ServerBuilder; class ServerContext; -} // namespace grpc_impl -namespace grpc { - template class ClientReader; template @@ -64,6 +61,8 @@ namespace internal { template class ServerReaderWriterBody; } // namespace internal +} // namespace grpc_impl +namespace grpc { class ChannelInterface; class ServerInterface; @@ -255,17 +254,17 @@ class CompletionQueue : private ::grpc::GrpcLibraryCodegen { // Friend synchronous wrappers so that they can access Pluck(), which is // a semi-private API geared towards the synchronous implementation. template - friend class ::grpc::ClientReader; + friend class ::grpc_impl::ClientReader; template - friend class ::grpc::ClientWriter; + friend class ::grpc_impl::ClientWriter; template - friend class ::grpc::ClientReaderWriter; + friend class ::grpc_impl::ClientReaderWriter; template - friend class ::grpc::ServerReader; + friend class ::grpc_impl::ServerReader; template - friend class ::grpc::ServerWriter; + friend class ::grpc_impl::ServerWriter; template - friend class ::grpc::internal::ServerReaderWriterBody; + friend class ::grpc_impl::internal::ServerReaderWriterBody; template friend class ::grpc::internal::RpcMethodHandler; template diff --git a/include/grpcpp/impl/codegen/server_callback.h b/include/grpcpp/impl/codegen/server_callback.h index 36ae19c5bec..cb771a662b9 100644 --- a/include/grpcpp/impl/codegen/server_callback.h +++ b/include/grpcpp/impl/codegen/server_callback.h @@ -19,1141 +19,26 @@ #ifndef GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_H #define GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_H -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include namespace grpc { - -// Declare base class of all reactors as internal -namespace internal { - -// Forward declarations -template -class CallbackClientStreamingHandler; -template -class CallbackServerStreamingHandler; -template -class CallbackBidiHandler; - -class ServerReactor { - public: - virtual ~ServerReactor() = default; - virtual void OnDone() = 0; - virtual void OnCancel() = 0; - - private: - friend class ::grpc_impl::ServerContext; - template - friend class CallbackClientStreamingHandler; - template - friend class CallbackServerStreamingHandler; - template - friend class CallbackBidiHandler; - - // The ServerReactor is responsible for tracking when it is safe to call - // OnCancel. This function should not be called until after OnStarted is done - // and the RPC has completed with a cancellation. This is tracked by counting - // how many of these conditions have been met and calling OnCancel when none - // remain unmet. - - void MaybeCallOnCancel() { - if (GPR_UNLIKELY(on_cancel_conditions_remaining_.fetch_sub( - 1, std::memory_order_acq_rel) == 1)) { - OnCancel(); - } - } - - std::atomic on_cancel_conditions_remaining_{2}; -}; - -template -class DefaultMessageHolder - : public experimental::MessageHolder { - public: - DefaultMessageHolder() { - this->set_request(&request_obj_); - this->set_response(&response_obj_); - } - void Release() override { - // the object is allocated in the call arena. - this->~DefaultMessageHolder(); - } - - private: - Request request_obj_; - Response response_obj_; -}; - -} // namespace internal - namespace experimental { - -// Forward declarations template -class ServerReadReactor; -template -class ServerWriteReactor; -template -class ServerBidiReactor; - -// For unary RPCs, the exposed controller class is only an interface -// and the actual implementation is an internal class. -class ServerCallbackRpcController { - public: - virtual ~ServerCallbackRpcController() = default; - - // The method handler must call this function when it is done so that - // the library knows to free its resources - virtual void Finish(Status s) = 0; - - // Allow the method handler to push out the initial metadata before - // the response and status are ready - virtual void SendInitialMetadata(std::function) = 0; - - /// SetCancelCallback passes in a callback to be called when the RPC is - /// canceled for whatever reason (streaming calls have OnCancel instead). This - /// is an advanced and uncommon use with several important restrictions. This - /// function may not be called more than once on the same RPC. - /// - /// If code calls SetCancelCallback on an RPC, it must also call - /// ClearCancelCallback before calling Finish on the RPC controller. That - /// method makes sure that no cancellation callback is executed for this RPC - /// beyond the point of its return. ClearCancelCallback may be called even if - /// SetCancelCallback was not called for this RPC, and it may be called - /// multiple times. It _must_ be called if SetCancelCallback was called for - /// this RPC. - /// - /// The callback should generally be lightweight and nonblocking and primarily - /// concerned with clearing application state related to the RPC or causing - /// operations (such as cancellations) to happen on dependent RPCs. - /// - /// If the RPC is already canceled at the time that SetCancelCallback is - /// called, the callback is invoked immediately. - /// - /// The cancellation callback may be executed concurrently with the method - /// handler that invokes it but will certainly not issue or execute after the - /// return of ClearCancelCallback. If ClearCancelCallback is invoked while the - /// callback is already executing, the callback will complete its execution - /// before ClearCancelCallback takes effect. - /// - /// To preserve the orderings described above, the callback may be called - /// under a lock that is also used for ClearCancelCallback and - /// ServerContext::IsCancelled, so the callback CANNOT call either of those - /// operations on this RPC or any other function that causes those operations - /// to be called before the callback completes. - virtual void SetCancelCallback(std::function callback) = 0; - virtual void ClearCancelCallback() = 0; - - // NOTE: This is an API for advanced users who need custom allocators. - // Get and maybe mutate the allocator state associated with the current RPC. - virtual RpcAllocatorState* GetRpcAllocatorState() = 0; -}; - -// NOTE: The actual streaming object classes are provided -// as API only to support mocking. There are no implementations of -// these class interfaces in the API. -template -class ServerCallbackReader { - public: - virtual ~ServerCallbackReader() {} - virtual void Finish(Status s) = 0; - virtual void SendInitialMetadata() = 0; - virtual void Read(Request* msg) = 0; - - protected: - template - void BindReactor(ServerReadReactor* reactor) { - reactor->InternalBindReader(this); - } -}; - -template -class ServerCallbackWriter { - public: - virtual ~ServerCallbackWriter() {} - - virtual void Finish(Status s) = 0; - virtual void SendInitialMetadata() = 0; - virtual void Write(const Response* msg, WriteOptions options) = 0; - virtual void WriteAndFinish(const Response* msg, WriteOptions options, - Status s) { - // Default implementation that can/should be overridden - Write(msg, std::move(options)); - Finish(std::move(s)); - } - - protected: - template - void BindReactor(ServerWriteReactor* reactor) { - reactor->InternalBindWriter(this); - } -}; +using ServerReadReactor = + ::grpc_impl::experimental::ServerReadReactor; template -class ServerCallbackReaderWriter { - public: - virtual ~ServerCallbackReaderWriter() {} +using ServerWriteReactor = + ::grpc_impl::experimental::ServerWriteReactor; - virtual void Finish(Status s) = 0; - virtual void SendInitialMetadata() = 0; - virtual void Read(Request* msg) = 0; - virtual void Write(const Response* msg, WriteOptions options) = 0; - virtual void WriteAndFinish(const Response* msg, WriteOptions options, - Status s) { - // Default implementation that can/should be overridden - Write(msg, std::move(options)); - Finish(std::move(s)); - } - - protected: - void BindReactor(ServerBidiReactor* reactor) { - reactor->InternalBindStream(this); - } -}; - -// The following classes are the reactor interfaces that are to be implemented -// by the user, returned as the result of the method handler for a callback -// method, and activated by the call to OnStarted. The library guarantees that -// OnStarted will be called for any reactor that has been created using a -// method handler registered on a service. No operation initiation method may be -// called until after the call to OnStarted. -// Note that none of the classes are pure; all reactions have a default empty -// reaction so that the user class only needs to override those classes that it -// cares about. - -/// \a ServerBidiReactor is the interface for a bidirectional streaming RPC. template -class ServerBidiReactor : public internal::ServerReactor { - public: - ~ServerBidiReactor() = default; +using ServerBidiReactor = + ::grpc_impl::experimental::ServerBidiReactor; - /// Do NOT call any operation initiation method (names that start with Start) - /// until after the library has called OnStarted on this object. - - /// Send any initial metadata stored in the RPC context. If not invoked, - /// any initial metadata will be passed along with the first Write or the - /// Finish (if there are no writes). - void StartSendInitialMetadata() { stream_->SendInitialMetadata(); } - - /// Initiate a read operation. - /// - /// \param[out] req Where to eventually store the read message. Valid when - /// the library calls OnReadDone - void StartRead(Request* req) { stream_->Read(req); } - - /// Initiate a write operation. - /// - /// \param[in] resp The message to be written. The library takes temporary - /// ownership until OnWriteDone, at which point the - /// application regains ownership of resp. - void StartWrite(const Response* resp) { StartWrite(resp, WriteOptions()); } - - /// Initiate a write operation with specified options. - /// - /// \param[in] resp The message to be written. The library takes temporary - /// ownership until OnWriteDone, at which point the - /// application regains ownership of resp. - /// \param[in] options The WriteOptions to use for writing this message - void StartWrite(const Response* resp, WriteOptions options) { - stream_->Write(resp, std::move(options)); - } - - /// Initiate a write operation with specified options and final RPC Status, - /// which also causes any trailing metadata for this RPC to be sent out. - /// StartWriteAndFinish is like merging StartWriteLast and Finish into a - /// single step. A key difference, though, is that this operation doesn't have - /// an OnWriteDone reaction - it is considered complete only when OnDone is - /// available. An RPC can either have StartWriteAndFinish or Finish, but not - /// both. - /// - /// \param[in] resp The message to be written. The library takes temporary - /// ownership until Onone, at which point the application - /// regains ownership of resp. - /// \param[in] options The WriteOptions to use for writing this message - /// \param[in] s The status outcome of this RPC - void StartWriteAndFinish(const Response* resp, WriteOptions options, - Status s) { - stream_->WriteAndFinish(resp, std::move(options), std::move(s)); - } - - /// Inform system of a planned write operation with specified options, but - /// allow the library to schedule the actual write coalesced with the writing - /// of trailing metadata (which takes place on a Finish call). - /// - /// \param[in] resp The message to be written. The library takes temporary - /// ownership until OnWriteDone, at which point the - /// application regains ownership of resp. - /// \param[in] options The WriteOptions to use for writing this message - void StartWriteLast(const Response* resp, WriteOptions options) { - StartWrite(resp, std::move(options.set_last_message())); - } - - /// Indicate that the stream is to be finished and the trailing metadata and - /// RPC status are to be sent. Every RPC MUST be finished using either Finish - /// or StartWriteAndFinish (but not both), even if the RPC is already - /// cancelled. - /// - /// \param[in] s The status outcome of this RPC - void Finish(Status s) { stream_->Finish(std::move(s)); } - - /// Notify the application that a streaming RPC has started and that it is now - /// ok to call any operation initiation method. An RPC is considered started - /// after the server has received all initial metadata from the client, which - /// is a result of the client calling StartCall(). - /// - /// \param[in] context The context object now associated with this RPC - virtual void OnStarted(::grpc_impl::ServerContext* context) {} - - /// Notifies the application that an explicit StartSendInitialMetadata - /// operation completed. Not used when the sending of initial metadata - /// piggybacks onto the first write. - /// - /// \param[in] ok Was it successful? If false, no further write-side operation - /// will succeed. - virtual void OnSendInitialMetadataDone(bool ok) {} - - /// Notifies the application that a StartRead operation completed. - /// - /// \param[in] ok Was it successful? If false, no further read-side operation - /// will succeed. - virtual void OnReadDone(bool ok) {} - - /// Notifies the application that a StartWrite (or StartWriteLast) operation - /// completed. - /// - /// \param[in] ok Was it successful? If false, no further write-side operation - /// will succeed. - virtual void OnWriteDone(bool ok) {} - - /// Notifies the application that all operations associated with this RPC - /// have completed. This is an override (from the internal base class) but not - /// final, so derived classes should override it if they want to take action. - void OnDone() override {} - - /// Notifies the application that this RPC has been cancelled. This is an - /// override (from the internal base class) but not final, so derived classes - /// should override it if they want to take action. - void OnCancel() override {} - - private: - friend class ServerCallbackReaderWriter; - // May be overridden by internal implementation details. This is not a public - // customization point. - virtual void InternalBindStream( - ServerCallbackReaderWriter* stream) { - stream_ = stream; - } - - ServerCallbackReaderWriter* stream_; -}; - -/// \a ServerReadReactor is the interface for a client-streaming RPC. -template -class ServerReadReactor : public internal::ServerReactor { - public: - ~ServerReadReactor() = default; - - /// The following operation initiations are exactly like ServerBidiReactor. - void StartSendInitialMetadata() { reader_->SendInitialMetadata(); } - void StartRead(Request* req) { reader_->Read(req); } - void Finish(Status s) { reader_->Finish(std::move(s)); } - - /// Similar to ServerBidiReactor::OnStarted, except that this also provides - /// the response object that the stream fills in before calling Finish. - /// (It must be filled in if status is OK, but it may be filled in otherwise.) - /// - /// \param[in] context The context object now associated with this RPC - /// \param[in] resp The response object to be used by this RPC - virtual void OnStarted(::grpc_impl::ServerContext* context, Response* resp) {} - - /// The following notifications are exactly like ServerBidiReactor. - virtual void OnSendInitialMetadataDone(bool ok) {} - virtual void OnReadDone(bool ok) {} - void OnDone() override {} - void OnCancel() override {} - - private: - friend class ServerCallbackReader; - // May be overridden by internal implementation details. This is not a public - // customization point. - virtual void InternalBindReader(ServerCallbackReader* reader) { - reader_ = reader; - } - - ServerCallbackReader* reader_; -}; - -/// \a ServerWriteReactor is the interface for a server-streaming RPC. -template -class ServerWriteReactor : public internal::ServerReactor { - public: - ~ServerWriteReactor() = default; - - /// The following operation initiations are exactly like ServerBidiReactor. - void StartSendInitialMetadata() { writer_->SendInitialMetadata(); } - void StartWrite(const Response* resp) { StartWrite(resp, WriteOptions()); } - void StartWrite(const Response* resp, WriteOptions options) { - writer_->Write(resp, std::move(options)); - } - void StartWriteAndFinish(const Response* resp, WriteOptions options, - Status s) { - writer_->WriteAndFinish(resp, std::move(options), std::move(s)); - } - void StartWriteLast(const Response* resp, WriteOptions options) { - StartWrite(resp, std::move(options.set_last_message())); - } - void Finish(Status s) { writer_->Finish(std::move(s)); } - - /// Similar to ServerBidiReactor::OnStarted, except that this also provides - /// the request object sent by the client. - /// - /// \param[in] context The context object now associated with this RPC - /// \param[in] req The request object sent by the client - virtual void OnStarted(::grpc_impl::ServerContext* context, - const Request* req) {} - - /// The following notifications are exactly like ServerBidiReactor. - virtual void OnSendInitialMetadataDone(bool ok) {} - virtual void OnWriteDone(bool ok) {} - void OnDone() override {} - void OnCancel() override {} - - private: - friend class ServerCallbackWriter; - // May be overridden by internal implementation details. This is not a public - // customization point. - virtual void InternalBindWriter(ServerCallbackWriter* writer) { - writer_ = writer; - } - - ServerCallbackWriter* writer_; -}; +typedef ::grpc_impl::experimental::ServerCallbackRpcController + ServerCallbackRpcController; } // namespace experimental - -namespace internal { - -template -class UnimplementedReadReactor - : public experimental::ServerReadReactor { - public: - void OnDone() override { delete this; } - void OnStarted(::grpc_impl::ServerContext*, Response*) override { - this->Finish(Status(StatusCode::UNIMPLEMENTED, "")); - } -}; - -template -class UnimplementedWriteReactor - : public experimental::ServerWriteReactor { - public: - void OnDone() override { delete this; } - void OnStarted(::grpc_impl::ServerContext*, const Request*) override { - this->Finish(Status(StatusCode::UNIMPLEMENTED, "")); - } -}; - -template -class UnimplementedBidiReactor - : public experimental::ServerBidiReactor { - public: - void OnDone() override { delete this; } - void OnStarted(::grpc_impl::ServerContext*) override { - this->Finish(Status(StatusCode::UNIMPLEMENTED, "")); - } -}; - -template -class CallbackUnaryHandler : public MethodHandler { - public: - CallbackUnaryHandler( - std::function - func) - : func_(func) {} - - void SetMessageAllocator( - experimental::MessageAllocator* allocator) { - allocator_ = allocator; - } - - void RunHandler(const HandlerParameter& param) final { - // Arena allocate a controller structure (that includes request/response) - g_core_codegen_interface->grpc_call_ref(param.call->call()); - auto* allocator_state = - static_cast*>( - param.internal_data); - auto* controller = new (g_core_codegen_interface->grpc_call_arena_alloc( - param.call->call(), sizeof(ServerCallbackRpcControllerImpl))) - ServerCallbackRpcControllerImpl(param.server_context, param.call, - allocator_state, - std::move(param.call_requester)); - Status status = param.status; - if (status.ok()) { - // Call the actual function handler and expect the user to call finish - CatchingCallback(func_, param.server_context, controller->request(), - controller->response(), controller); - } else { - // if deserialization failed, we need to fail the call - controller->Finish(status); - } - } - - void* Deserialize(grpc_call* call, grpc_byte_buffer* req, Status* status, - void** handler_data) final { - ByteBuffer buf; - buf.set_buffer(req); - RequestType* request = nullptr; - experimental::MessageHolder* allocator_state = - nullptr; - if (allocator_ != nullptr) { - allocator_state = allocator_->AllocateMessages(); - } else { - allocator_state = new (g_core_codegen_interface->grpc_call_arena_alloc( - call, sizeof(DefaultMessageHolder))) - DefaultMessageHolder(); - } - *handler_data = allocator_state; - request = allocator_state->request(); - *status = SerializationTraits::Deserialize(&buf, request); - buf.Release(); - if (status->ok()) { - return request; - } - // Clean up on deserialization failure. - allocator_state->Release(); - return nullptr; - } - - private: - std::function - func_; - experimental::MessageAllocator* allocator_ = - nullptr; - - // The implementation class of ServerCallbackRpcController is a private member - // of CallbackUnaryHandler since it is never exposed anywhere, and this allows - // it to take advantage of CallbackUnaryHandler's friendships. - class ServerCallbackRpcControllerImpl - : public experimental::ServerCallbackRpcController { - public: - void Finish(Status s) override { - finish_tag_.Set(call_.call(), [this](bool) { MaybeDone(); }, - &finish_ops_); - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - // The response is dropped if the status is not OK. - if (s.ok()) { - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, - finish_ops_.SendMessagePtr(response())); - } else { - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); - } - finish_ops_.set_core_cq_tag(&finish_tag_); - call_.PerformOps(&finish_ops_); - } - - void SendInitialMetadata(std::function f) override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - // TODO(vjpai): Consider taking f as a move-capture if we adopt C++14 - // and if performance of this operation matters - meta_tag_.Set(call_.call(), - [this, f](bool ok) { - f(ok); - MaybeDone(); - }, - &meta_ops_); - meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - meta_ops_.set_core_cq_tag(&meta_tag_); - call_.PerformOps(&meta_ops_); - } - - // Neither SetCancelCallback nor ClearCancelCallback should affect the - // callbacks_outstanding_ count since they are paired and both must precede - // the invocation of Finish (if they are used at all) - void SetCancelCallback(std::function callback) override { - ctx_->SetCancelCallback(std::move(callback)); - } - - void ClearCancelCallback() override { ctx_->ClearCancelCallback(); } - - experimental::RpcAllocatorState* GetRpcAllocatorState() override { - return allocator_state_; - } - - private: - friend class CallbackUnaryHandler; - - ServerCallbackRpcControllerImpl( - ::grpc_impl::ServerContext* ctx, Call* call, - experimental::MessageHolder* allocator_state, - std::function call_requester) - : ctx_(ctx), - call_(*call), - allocator_state_(allocator_state), - call_requester_(std::move(call_requester)) { - ctx_->BeginCompletionOp(call, [this](bool) { MaybeDone(); }, nullptr); - } - - const RequestType* request() { return allocator_state_->request(); } - ResponseType* response() { return allocator_state_->response(); } - - void MaybeDone() { - if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( - 1, std::memory_order_acq_rel) == 1)) { - grpc_call* call = call_.call(); - auto call_requester = std::move(call_requester_); - allocator_state_->Release(); - this->~ServerCallbackRpcControllerImpl(); // explicitly call destructor - g_core_codegen_interface->grpc_call_unref(call); - call_requester(); - } - } - - CallOpSet meta_ops_; - CallbackWithSuccessTag meta_tag_; - CallOpSet - finish_ops_; - CallbackWithSuccessTag finish_tag_; - - ::grpc_impl::ServerContext* ctx_; - Call call_; - experimental::MessageHolder* const - allocator_state_; - std::function call_requester_; - std::atomic callbacks_outstanding_{ - 2}; // reserve for Finish and CompletionOp - }; -}; - -template -class CallbackClientStreamingHandler : public MethodHandler { - public: - CallbackClientStreamingHandler( - std::function< - experimental::ServerReadReactor*()> - func) - : func_(std::move(func)) {} - void RunHandler(const HandlerParameter& param) final { - // Arena allocate a reader structure (that includes response) - g_core_codegen_interface->grpc_call_ref(param.call->call()); - - experimental::ServerReadReactor* reactor = - param.status.ok() - ? CatchingReactorCreator< - experimental::ServerReadReactor>( - func_) - : nullptr; - - if (reactor == nullptr) { - // if deserialization or reactor creator failed, we need to fail the call - reactor = new UnimplementedReadReactor; - } - - auto* reader = new (g_core_codegen_interface->grpc_call_arena_alloc( - param.call->call(), sizeof(ServerCallbackReaderImpl))) - ServerCallbackReaderImpl(param.server_context, param.call, - std::move(param.call_requester), reactor); - - reader->BindReactor(reactor); - reactor->OnStarted(param.server_context, reader->response()); - // The earliest that OnCancel can be called is after OnStarted is done. - reactor->MaybeCallOnCancel(); - reader->MaybeDone(); - } - - private: - std::function*()> - func_; - - class ServerCallbackReaderImpl - : public experimental::ServerCallbackReader { - public: - void Finish(Status s) override { - finish_tag_.Set(call_.call(), [this](bool) { MaybeDone(); }, - &finish_ops_); - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - // The response is dropped if the status is not OK. - if (s.ok()) { - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, - finish_ops_.SendMessagePtr(&resp_)); - } else { - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); - } - finish_ops_.set_core_cq_tag(&finish_tag_); - call_.PerformOps(&finish_ops_); - } - - void SendInitialMetadata() override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - meta_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnSendInitialMetadataDone(ok); - MaybeDone(); - }, - &meta_ops_); - meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - meta_ops_.set_core_cq_tag(&meta_tag_); - call_.PerformOps(&meta_ops_); - } - - void Read(RequestType* req) override { - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - read_ops_.RecvMessage(req); - call_.PerformOps(&read_ops_); - } - - private: - friend class CallbackClientStreamingHandler; - - ServerCallbackReaderImpl( - ::grpc_impl::ServerContext* ctx, Call* call, - std::function call_requester, - experimental::ServerReadReactor* reactor) - : ctx_(ctx), - call_(*call), - call_requester_(std::move(call_requester)), - reactor_(reactor) { - ctx_->BeginCompletionOp(call, [this](bool) { MaybeDone(); }, reactor); - read_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadDone(ok); - MaybeDone(); - }, - &read_ops_); - read_ops_.set_core_cq_tag(&read_tag_); - } - - ~ServerCallbackReaderImpl() {} - - ResponseType* response() { return &resp_; } - - void MaybeDone() { - if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( - 1, std::memory_order_acq_rel) == 1)) { - reactor_->OnDone(); - grpc_call* call = call_.call(); - auto call_requester = std::move(call_requester_); - this->~ServerCallbackReaderImpl(); // explicitly call destructor - g_core_codegen_interface->grpc_call_unref(call); - call_requester(); - } - } - - CallOpSet meta_ops_; - CallbackWithSuccessTag meta_tag_; - CallOpSet - finish_ops_; - CallbackWithSuccessTag finish_tag_; - CallOpSet> read_ops_; - CallbackWithSuccessTag read_tag_; - - ::grpc_impl::ServerContext* ctx_; - Call call_; - ResponseType resp_; - std::function call_requester_; - experimental::ServerReadReactor* reactor_; - std::atomic callbacks_outstanding_{ - 3}; // reserve for OnStarted, Finish, and CompletionOp - }; -}; - -template -class CallbackServerStreamingHandler : public MethodHandler { - public: - CallbackServerStreamingHandler( - std::function< - experimental::ServerWriteReactor*()> - func) - : func_(std::move(func)) {} - void RunHandler(const HandlerParameter& param) final { - // Arena allocate a writer structure - g_core_codegen_interface->grpc_call_ref(param.call->call()); - - experimental::ServerWriteReactor* reactor = - param.status.ok() - ? CatchingReactorCreator< - experimental::ServerWriteReactor>( - func_) - : nullptr; - - if (reactor == nullptr) { - // if deserialization or reactor creator failed, we need to fail the call - reactor = new UnimplementedWriteReactor; - } - - auto* writer = new (g_core_codegen_interface->grpc_call_arena_alloc( - param.call->call(), sizeof(ServerCallbackWriterImpl))) - ServerCallbackWriterImpl(param.server_context, param.call, - static_cast(param.request), - std::move(param.call_requester), reactor); - writer->BindReactor(reactor); - reactor->OnStarted(param.server_context, writer->request()); - // The earliest that OnCancel can be called is after OnStarted is done. - reactor->MaybeCallOnCancel(); - writer->MaybeDone(); - } - - void* Deserialize(grpc_call* call, grpc_byte_buffer* req, Status* status, - void** handler_data) final { - ByteBuffer buf; - buf.set_buffer(req); - auto* request = new (g_core_codegen_interface->grpc_call_arena_alloc( - call, sizeof(RequestType))) RequestType(); - *status = SerializationTraits::Deserialize(&buf, request); - buf.Release(); - if (status->ok()) { - return request; - } - request->~RequestType(); - return nullptr; - } - - private: - std::function*()> - func_; - - class ServerCallbackWriterImpl - : public experimental::ServerCallbackWriter { - public: - void Finish(Status s) override { - finish_tag_.Set(call_.call(), [this](bool) { MaybeDone(); }, - &finish_ops_); - finish_ops_.set_core_cq_tag(&finish_tag_); - - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); - call_.PerformOps(&finish_ops_); - } - - void SendInitialMetadata() override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - meta_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnSendInitialMetadataDone(ok); - MaybeDone(); - }, - &meta_ops_); - meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - meta_ops_.set_core_cq_tag(&meta_tag_); - call_.PerformOps(&meta_ops_); - } - - void Write(const ResponseType* resp, WriteOptions options) override { - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - if (options.is_last_message()) { - options.set_buffer_hint(); - } - if (!ctx_->sent_initial_metadata_) { - write_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - write_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - // TODO(vjpai): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(resp, options).ok()); - call_.PerformOps(&write_ops_); - } - - void WriteAndFinish(const ResponseType* resp, WriteOptions options, - Status s) override { - // This combines the write into the finish callback - // Don't send any message if the status is bad - if (s.ok()) { - // TODO(vjpai): don't assert - GPR_CODEGEN_ASSERT(finish_ops_.SendMessagePtr(resp, options).ok()); - } - Finish(std::move(s)); - } - - private: - friend class CallbackServerStreamingHandler; - - ServerCallbackWriterImpl( - ::grpc_impl::ServerContext* ctx, Call* call, const RequestType* req, - std::function call_requester, - experimental::ServerWriteReactor* reactor) - : ctx_(ctx), - call_(*call), - req_(req), - call_requester_(std::move(call_requester)), - reactor_(reactor) { - ctx_->BeginCompletionOp(call, [this](bool) { MaybeDone(); }, reactor); - write_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnWriteDone(ok); - MaybeDone(); - }, - &write_ops_); - write_ops_.set_core_cq_tag(&write_tag_); - } - ~ServerCallbackWriterImpl() { req_->~RequestType(); } - - const RequestType* request() { return req_; } - - void MaybeDone() { - if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( - 1, std::memory_order_acq_rel) == 1)) { - reactor_->OnDone(); - grpc_call* call = call_.call(); - auto call_requester = std::move(call_requester_); - this->~ServerCallbackWriterImpl(); // explicitly call destructor - g_core_codegen_interface->grpc_call_unref(call); - call_requester(); - } - } - - CallOpSet meta_ops_; - CallbackWithSuccessTag meta_tag_; - CallOpSet - finish_ops_; - CallbackWithSuccessTag finish_tag_; - CallOpSet write_ops_; - CallbackWithSuccessTag write_tag_; - - ::grpc_impl::ServerContext* ctx_; - Call call_; - const RequestType* req_; - std::function call_requester_; - experimental::ServerWriteReactor* reactor_; - std::atomic callbacks_outstanding_{ - 3}; // reserve for OnStarted, Finish, and CompletionOp - }; -}; - -template -class CallbackBidiHandler : public MethodHandler { - public: - CallbackBidiHandler( - std::function< - experimental::ServerBidiReactor*()> - func) - : func_(std::move(func)) {} - void RunHandler(const HandlerParameter& param) final { - g_core_codegen_interface->grpc_call_ref(param.call->call()); - - experimental::ServerBidiReactor* reactor = - param.status.ok() - ? CatchingReactorCreator< - experimental::ServerBidiReactor>( - func_) - : nullptr; - - if (reactor == nullptr) { - // if deserialization or reactor creator failed, we need to fail the call - reactor = new UnimplementedBidiReactor; - } - - auto* stream = new (g_core_codegen_interface->grpc_call_arena_alloc( - param.call->call(), sizeof(ServerCallbackReaderWriterImpl))) - ServerCallbackReaderWriterImpl(param.server_context, param.call, - std::move(param.call_requester), - reactor); - - stream->BindReactor(reactor); - reactor->OnStarted(param.server_context); - // The earliest that OnCancel can be called is after OnStarted is done. - reactor->MaybeCallOnCancel(); - stream->MaybeDone(); - } - - private: - std::function*()> - func_; - - class ServerCallbackReaderWriterImpl - : public experimental::ServerCallbackReaderWriter { - public: - void Finish(Status s) override { - finish_tag_.Set(call_.call(), [this](bool) { MaybeDone(); }, - &finish_ops_); - finish_ops_.set_core_cq_tag(&finish_tag_); - - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); - call_.PerformOps(&finish_ops_); - } - - void SendInitialMetadata() override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - meta_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnSendInitialMetadataDone(ok); - MaybeDone(); - }, - &meta_ops_); - meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - meta_ops_.set_core_cq_tag(&meta_tag_); - call_.PerformOps(&meta_ops_); - } - - void Write(const ResponseType* resp, WriteOptions options) override { - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - if (options.is_last_message()) { - options.set_buffer_hint(); - } - if (!ctx_->sent_initial_metadata_) { - write_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - write_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - // TODO(vjpai): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(resp, options).ok()); - call_.PerformOps(&write_ops_); - } - - void WriteAndFinish(const ResponseType* resp, WriteOptions options, - Status s) override { - // Don't send any message if the status is bad - if (s.ok()) { - // TODO(vjpai): don't assert - GPR_CODEGEN_ASSERT(finish_ops_.SendMessagePtr(resp, options).ok()); - } - Finish(std::move(s)); - } - - void Read(RequestType* req) override { - callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); - read_ops_.RecvMessage(req); - call_.PerformOps(&read_ops_); - } - - private: - friend class CallbackBidiHandler; - - ServerCallbackReaderWriterImpl( - ::grpc_impl::ServerContext* ctx, Call* call, - std::function call_requester, - experimental::ServerBidiReactor* reactor) - : ctx_(ctx), - call_(*call), - call_requester_(std::move(call_requester)), - reactor_(reactor) { - ctx_->BeginCompletionOp(call, [this](bool) { MaybeDone(); }, reactor); - write_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnWriteDone(ok); - MaybeDone(); - }, - &write_ops_); - write_ops_.set_core_cq_tag(&write_tag_); - read_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadDone(ok); - MaybeDone(); - }, - &read_ops_); - read_ops_.set_core_cq_tag(&read_tag_); - } - ~ServerCallbackReaderWriterImpl() {} - - void MaybeDone() { - if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( - 1, std::memory_order_acq_rel) == 1)) { - reactor_->OnDone(); - grpc_call* call = call_.call(); - auto call_requester = std::move(call_requester_); - this->~ServerCallbackReaderWriterImpl(); // explicitly call destructor - g_core_codegen_interface->grpc_call_unref(call); - call_requester(); - } - } - - CallOpSet meta_ops_; - CallbackWithSuccessTag meta_tag_; - CallOpSet - finish_ops_; - CallbackWithSuccessTag finish_tag_; - CallOpSet write_ops_; - CallbackWithSuccessTag write_tag_; - CallOpSet> read_ops_; - CallbackWithSuccessTag read_tag_; - - ::grpc_impl::ServerContext* ctx_; - Call call_; - std::function call_requester_; - experimental::ServerBidiReactor* reactor_; - std::atomic callbacks_outstanding_{ - 3}; // reserve for OnStarted, Finish, and CompletionOp - }; -}; - -} // namespace internal - } // namespace grpc #endif // GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_H diff --git a/include/grpcpp/impl/codegen/server_callback_impl.h b/include/grpcpp/impl/codegen/server_callback_impl.h new file mode 100644 index 00000000000..08ecdfd6497 --- /dev/null +++ b/include/grpcpp/impl/codegen/server_callback_impl.h @@ -0,0 +1,1186 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_IMPL_H +#define GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_IMPL_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace grpc_impl { + +// Declare base class of all reactors as internal +namespace internal { + +// Forward declarations +template +class CallbackClientStreamingHandler; +template +class CallbackServerStreamingHandler; +template +class CallbackBidiHandler; + +class ServerReactor { + public: + virtual ~ServerReactor() = default; + virtual void OnDone() = 0; + virtual void OnCancel() = 0; + + private: + friend class ::grpc_impl::ServerContext; + template + friend class CallbackClientStreamingHandler; + template + friend class CallbackServerStreamingHandler; + template + friend class CallbackBidiHandler; + + // The ServerReactor is responsible for tracking when it is safe to call + // OnCancel. This function should not be called until after OnStarted is done + // and the RPC has completed with a cancellation. This is tracked by counting + // how many of these conditions have been met and calling OnCancel when none + // remain unmet. + + void MaybeCallOnCancel() { + if (GPR_UNLIKELY(on_cancel_conditions_remaining_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + OnCancel(); + } + } + + std::atomic on_cancel_conditions_remaining_{2}; +}; + +template +class DefaultMessageHolder + : public ::grpc::experimental::MessageHolder { + public: + DefaultMessageHolder() { + this->set_request(&request_obj_); + this->set_response(&response_obj_); + } + void Release() override { + // the object is allocated in the call arena. + this->~DefaultMessageHolder(); + } + + private: + Request request_obj_; + Response response_obj_; +}; + +} // namespace internal + +namespace experimental { + +// Forward declarations +template +class ServerReadReactor; +template +class ServerWriteReactor; +template +class ServerBidiReactor; + +// For unary RPCs, the exposed controller class is only an interface +// and the actual implementation is an internal class. +class ServerCallbackRpcController { + public: + virtual ~ServerCallbackRpcController() = default; + + // The method handler must call this function when it is done so that + // the library knows to free its resources + virtual void Finish(::grpc::Status s) = 0; + + // Allow the method handler to push out the initial metadata before + // the response and status are ready + virtual void SendInitialMetadata(std::function) = 0; + + /// SetCancelCallback passes in a callback to be called when the RPC is + /// canceled for whatever reason (streaming calls have OnCancel instead). This + /// is an advanced and uncommon use with several important restrictions. This + /// function may not be called more than once on the same RPC. + /// + /// If code calls SetCancelCallback on an RPC, it must also call + /// ClearCancelCallback before calling Finish on the RPC controller. That + /// method makes sure that no cancellation callback is executed for this RPC + /// beyond the point of its return. ClearCancelCallback may be called even if + /// SetCancelCallback was not called for this RPC, and it may be called + /// multiple times. It _must_ be called if SetCancelCallback was called for + /// this RPC. + /// + /// The callback should generally be lightweight and nonblocking and primarily + /// concerned with clearing application state related to the RPC or causing + /// operations (such as cancellations) to happen on dependent RPCs. + /// + /// If the RPC is already canceled at the time that SetCancelCallback is + /// called, the callback is invoked immediately. + /// + /// The cancellation callback may be executed concurrently with the method + /// handler that invokes it but will certainly not issue or execute after the + /// return of ClearCancelCallback. If ClearCancelCallback is invoked while the + /// callback is already executing, the callback will complete its execution + /// before ClearCancelCallback takes effect. + /// + /// To preserve the orderings described above, the callback may be called + /// under a lock that is also used for ClearCancelCallback and + /// ServerContext::IsCancelled, so the callback CANNOT call either of those + /// operations on this RPC or any other function that causes those operations + /// to be called before the callback completes. + virtual void SetCancelCallback(std::function callback) = 0; + virtual void ClearCancelCallback() = 0; + + // NOTE: This is an API for advanced users who need custom allocators. + // Get and maybe mutate the allocator state associated with the current RPC. + virtual grpc::experimental::RpcAllocatorState* GetRpcAllocatorState() = 0; +}; + +// NOTE: The actual streaming object classes are provided +// as API only to support mocking. There are no implementations of +// these class interfaces in the API. +template +class ServerCallbackReader { + public: + virtual ~ServerCallbackReader() {} + virtual void Finish(::grpc::Status s) = 0; + virtual void SendInitialMetadata() = 0; + virtual void Read(Request* msg) = 0; + + protected: + template + void BindReactor(ServerReadReactor* reactor) { + reactor->InternalBindReader(this); + } +}; + +template +class ServerCallbackWriter { + public: + virtual ~ServerCallbackWriter() {} + + virtual void Finish(::grpc::Status s) = 0; + virtual void SendInitialMetadata() = 0; + virtual void Write(const Response* msg, ::grpc::WriteOptions options) = 0; + virtual void WriteAndFinish(const Response* msg, ::grpc::WriteOptions options, + ::grpc::Status s) { + // Default implementation that can/should be overridden + Write(msg, std::move(options)); + Finish(std::move(s)); + } + + protected: + template + void BindReactor(ServerWriteReactor* reactor) { + reactor->InternalBindWriter(this); + } +}; + +template +class ServerCallbackReaderWriter { + public: + virtual ~ServerCallbackReaderWriter() {} + + virtual void Finish(::grpc::Status s) = 0; + virtual void SendInitialMetadata() = 0; + virtual void Read(Request* msg) = 0; + virtual void Write(const Response* msg, ::grpc::WriteOptions options) = 0; + virtual void WriteAndFinish(const Response* msg, ::grpc::WriteOptions options, + ::grpc::Status s) { + // Default implementation that can/should be overridden + Write(msg, std::move(options)); + Finish(std::move(s)); + } + + protected: + void BindReactor(ServerBidiReactor* reactor) { + reactor->InternalBindStream(this); + } +}; + +// The following classes are the reactor interfaces that are to be implemented +// by the user, returned as the result of the method handler for a callback +// method, and activated by the call to OnStarted. The library guarantees that +// OnStarted will be called for any reactor that has been created using a +// method handler registered on a service. No operation initiation method may be +// called until after the call to OnStarted. +// Note that none of the classes are pure; all reactions have a default empty +// reaction so that the user class only needs to override those classes that it +// cares about. + +/// \a ServerBidiReactor is the interface for a bidirectional streaming RPC. +template +class ServerBidiReactor : public internal::ServerReactor { + public: + ~ServerBidiReactor() = default; + + /// Do NOT call any operation initiation method (names that start with Start) + /// until after the library has called OnStarted on this object. + + /// Send any initial metadata stored in the RPC context. If not invoked, + /// any initial metadata will be passed along with the first Write or the + /// Finish (if there are no writes). + void StartSendInitialMetadata() { stream_->SendInitialMetadata(); } + + /// Initiate a read operation. + /// + /// \param[out] req Where to eventually store the read message. Valid when + /// the library calls OnReadDone + void StartRead(Request* req) { stream_->Read(req); } + + /// Initiate a write operation. + /// + /// \param[in] resp The message to be written. The library takes temporary + /// ownership until OnWriteDone, at which point the + /// application regains ownership of resp. + void StartWrite(const Response* resp) { + StartWrite(resp, ::grpc::WriteOptions()); + } + + /// Initiate a write operation with specified options. + /// + /// \param[in] resp The message to be written. The library takes temporary + /// ownership until OnWriteDone, at which point the + /// application regains ownership of resp. + /// \param[in] options The WriteOptions to use for writing this message + void StartWrite(const Response* resp, ::grpc::WriteOptions options) { + stream_->Write(resp, std::move(options)); + } + + /// Initiate a write operation with specified options and final RPC Status, + /// which also causes any trailing metadata for this RPC to be sent out. + /// StartWriteAndFinish is like merging StartWriteLast and Finish into a + /// single step. A key difference, though, is that this operation doesn't have + /// an OnWriteDone reaction - it is considered complete only when OnDone is + /// available. An RPC can either have StartWriteAndFinish or Finish, but not + /// both. + /// + /// \param[in] resp The message to be written. The library takes temporary + /// ownership until Onone, at which point the application + /// regains ownership of resp. + /// \param[in] options The WriteOptions to use for writing this message + /// \param[in] s The status outcome of this RPC + void StartWriteAndFinish(const Response* resp, ::grpc::WriteOptions options, + ::grpc::Status s) { + stream_->WriteAndFinish(resp, std::move(options), std::move(s)); + } + + /// Inform system of a planned write operation with specified options, but + /// allow the library to schedule the actual write coalesced with the writing + /// of trailing metadata (which takes place on a Finish call). + /// + /// \param[in] resp The message to be written. The library takes temporary + /// ownership until OnWriteDone, at which point the + /// application regains ownership of resp. + /// \param[in] options The WriteOptions to use for writing this message + void StartWriteLast(const Response* resp, ::grpc::WriteOptions options) { + StartWrite(resp, std::move(options.set_last_message())); + } + + /// Indicate that the stream is to be finished and the trailing metadata and + /// RPC status are to be sent. Every RPC MUST be finished using either Finish + /// or StartWriteAndFinish (but not both), even if the RPC is already + /// cancelled. + /// + /// \param[in] s The status outcome of this RPC + void Finish(::grpc::Status s) { stream_->Finish(std::move(s)); } + + /// Notify the application that a streaming RPC has started and that it is now + /// ok to call any operation initiation method. An RPC is considered started + /// after the server has received all initial metadata from the client, which + /// is a result of the client calling StartCall(). + /// + /// \param[in] context The context object now associated with this RPC + virtual void OnStarted(::grpc_impl::ServerContext* context) {} + + /// Notifies the application that an explicit StartSendInitialMetadata + /// operation completed. Not used when the sending of initial metadata + /// piggybacks onto the first write. + /// + /// \param[in] ok Was it successful? If false, no further write-side operation + /// will succeed. + virtual void OnSendInitialMetadataDone(bool ok) {} + + /// Notifies the application that a StartRead operation completed. + /// + /// \param[in] ok Was it successful? If false, no further read-side operation + /// will succeed. + virtual void OnReadDone(bool ok) {} + + /// Notifies the application that a StartWrite (or StartWriteLast) operation + /// completed. + /// + /// \param[in] ok Was it successful? If false, no further write-side operation + /// will succeed. + virtual void OnWriteDone(bool ok) {} + + /// Notifies the application that all operations associated with this RPC + /// have completed. This is an override (from the internal base class) but not + /// final, so derived classes should override it if they want to take action. + void OnDone() override {} + + /// Notifies the application that this RPC has been cancelled. This is an + /// override (from the internal base class) but not final, so derived classes + /// should override it if they want to take action. + void OnCancel() override {} + + private: + friend class ServerCallbackReaderWriter; + // May be overridden by internal implementation details. This is not a public + // customization point. + virtual void InternalBindStream( + ServerCallbackReaderWriter* stream) { + stream_ = stream; + } + + ServerCallbackReaderWriter* stream_; +}; + +/// \a ServerReadReactor is the interface for a client-streaming RPC. +template +class ServerReadReactor : public internal::ServerReactor { + public: + ~ServerReadReactor() = default; + + /// The following operation initiations are exactly like ServerBidiReactor. + void StartSendInitialMetadata() { reader_->SendInitialMetadata(); } + void StartRead(Request* req) { reader_->Read(req); } + void Finish(::grpc::Status s) { reader_->Finish(std::move(s)); } + + /// Similar to ServerBidiReactor::OnStarted, except that this also provides + /// the response object that the stream fills in before calling Finish. + /// (It must be filled in if status is OK, but it may be filled in otherwise.) + /// + /// \param[in] context The context object now associated with this RPC + /// \param[in] resp The response object to be used by this RPC + virtual void OnStarted(::grpc_impl::ServerContext* context, Response* resp) {} + + /// The following notifications are exactly like ServerBidiReactor. + virtual void OnSendInitialMetadataDone(bool ok) {} + virtual void OnReadDone(bool ok) {} + void OnDone() override {} + void OnCancel() override {} + + private: + friend class ServerCallbackReader; + // May be overridden by internal implementation details. This is not a public + // customization point. + virtual void InternalBindReader(ServerCallbackReader* reader) { + reader_ = reader; + } + + ServerCallbackReader* reader_; +}; + +/// \a ServerWriteReactor is the interface for a server-streaming RPC. +template +class ServerWriteReactor : public internal::ServerReactor { + public: + ~ServerWriteReactor() = default; + + /// The following operation initiations are exactly like ServerBidiReactor. + void StartSendInitialMetadata() { writer_->SendInitialMetadata(); } + void StartWrite(const Response* resp) { + StartWrite(resp, ::grpc::WriteOptions()); + } + void StartWrite(const Response* resp, ::grpc::WriteOptions options) { + writer_->Write(resp, std::move(options)); + } + void StartWriteAndFinish(const Response* resp, ::grpc::WriteOptions options, + ::grpc::Status s) { + writer_->WriteAndFinish(resp, std::move(options), std::move(s)); + } + void StartWriteLast(const Response* resp, ::grpc::WriteOptions options) { + StartWrite(resp, std::move(options.set_last_message())); + } + void Finish(::grpc::Status s) { writer_->Finish(std::move(s)); } + + /// Similar to ServerBidiReactor::OnStarted, except that this also provides + /// the request object sent by the client. + /// + /// \param[in] context The context object now associated with this RPC + /// \param[in] req The request object sent by the client + virtual void OnStarted(::grpc_impl::ServerContext* context, + const Request* req) {} + + /// The following notifications are exactly like ServerBidiReactor. + virtual void OnSendInitialMetadataDone(bool ok) {} + virtual void OnWriteDone(bool ok) {} + void OnDone() override {} + void OnCancel() override {} + + private: + friend class ServerCallbackWriter; + // May be overridden by internal implementation details. This is not a public + // customization point. + virtual void InternalBindWriter(ServerCallbackWriter* writer) { + writer_ = writer; + } + + ServerCallbackWriter* writer_; +}; + +} // namespace experimental + +namespace internal { + +template +class UnimplementedReadReactor + : public experimental::ServerReadReactor { + public: + void OnDone() override { delete this; } + void OnStarted(::grpc_impl::ServerContext*, Response*) override { + this->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); + } +}; + +template +class UnimplementedWriteReactor + : public experimental::ServerWriteReactor { + public: + void OnDone() override { delete this; } + void OnStarted(::grpc_impl::ServerContext*, const Request*) override { + this->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); + } +}; + +template +class UnimplementedBidiReactor + : public experimental::ServerBidiReactor { + public: + void OnDone() override { delete this; } + void OnStarted(::grpc_impl::ServerContext*) override { + this->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); + } +}; + +template +class CallbackUnaryHandler : public grpc::internal::MethodHandler { + public: + CallbackUnaryHandler( + std::function + func) + : func_(func) {} + + void SetMessageAllocator( + ::grpc::experimental::MessageAllocator* + allocator) { + allocator_ = allocator; + } + + void RunHandler(const HandlerParameter& param) final { + // Arena allocate a controller structure (that includes request/response) + ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); + auto* allocator_state = static_cast< + grpc::experimental::MessageHolder*>( + param.internal_data); + auto* controller = + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(ServerCallbackRpcControllerImpl))) + ServerCallbackRpcControllerImpl(param.server_context, param.call, + allocator_state, + std::move(param.call_requester)); + ::grpc::Status status = param.status; + if (status.ok()) { + // Call the actual function handler and expect the user to call finish + grpc::internal::CatchingCallback(func_, param.server_context, + controller->request(), + controller->response(), controller); + } else { + // if deserialization failed, we need to fail the call + controller->Finish(status); + } + } + + void* Deserialize(grpc_call* call, grpc_byte_buffer* req, + ::grpc::Status* status, void** handler_data) final { + grpc::ByteBuffer buf; + buf.set_buffer(req); + RequestType* request = nullptr; + ::grpc::experimental::MessageHolder* + allocator_state = nullptr; + if (allocator_ != nullptr) { + allocator_state = allocator_->AllocateMessages(); + } else { + allocator_state = + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call, sizeof(DefaultMessageHolder))) + DefaultMessageHolder(); + } + *handler_data = allocator_state; + request = allocator_state->request(); + *status = + ::grpc::SerializationTraits::Deserialize(&buf, request); + buf.Release(); + if (status->ok()) { + return request; + } + // Clean up on deserialization failure. + allocator_state->Release(); + return nullptr; + } + + private: + std::function + func_; + grpc::experimental::MessageAllocator* allocator_ = + nullptr; + + // The implementation class of ServerCallbackRpcController is a private member + // of CallbackUnaryHandler since it is never exposed anywhere, and this allows + // it to take advantage of CallbackUnaryHandler's friendships. + class ServerCallbackRpcControllerImpl + : public experimental::ServerCallbackRpcController { + public: + void Finish(::grpc::Status s) override { + finish_tag_.Set(call_.call(), [this](bool) { MaybeDone(); }, + &finish_ops_); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // The response is dropped if the status is not OK. + if (s.ok()) { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, + finish_ops_.SendMessagePtr(response())); + } else { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); + } + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void SendInitialMetadata(std::function f) override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + // TODO(vjpai): Consider taking f as a move-capture if we adopt C++14 + // and if performance of this operation matters + meta_tag_.Set(call_.call(), + [this, f](bool ok) { + f(ok); + MaybeDone(); + }, + &meta_ops_); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + meta_ops_.set_core_cq_tag(&meta_tag_); + call_.PerformOps(&meta_ops_); + } + + // Neither SetCancelCallback nor ClearCancelCallback should affect the + // callbacks_outstanding_ count since they are paired and both must precede + // the invocation of Finish (if they are used at all) + void SetCancelCallback(std::function callback) override { + ctx_->SetCancelCallback(std::move(callback)); + } + + void ClearCancelCallback() override { ctx_->ClearCancelCallback(); } + + grpc::experimental::RpcAllocatorState* GetRpcAllocatorState() override { + return allocator_state_; + } + + private: + friend class CallbackUnaryHandler; + + ServerCallbackRpcControllerImpl( + ServerContext* ctx, ::grpc::internal::Call* call, + ::grpc::experimental::MessageHolder* + allocator_state, + std::function call_requester) + : ctx_(ctx), + call_(*call), + allocator_state_(allocator_state), + call_requester_(std::move(call_requester)) { + ctx_->BeginCompletionOp(call, [this](bool) { MaybeDone(); }, nullptr); + } + + const RequestType* request() { return allocator_state_->request(); } + ResponseType* response() { return allocator_state_->response(); } + + void MaybeDone() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + grpc_call* call = call_.call(); + auto call_requester = std::move(call_requester_); + allocator_state_->Release(); + this->~ServerCallbackRpcControllerImpl(); // explicitly call destructor + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + call_requester(); + } + } + + grpc::internal::CallOpSet + meta_ops_; + grpc::internal::CallbackWithSuccessTag meta_tag_; + grpc::internal::CallOpSet + finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + + ::grpc_impl::ServerContext* ctx_; + grpc::internal::Call call_; + grpc::experimental::MessageHolder* const + allocator_state_; + std::function call_requester_; + std::atomic callbacks_outstanding_{ + 2}; // reserve for Finish and CompletionOp + }; +}; + +template +class CallbackClientStreamingHandler : public grpc::internal::MethodHandler { + public: + CallbackClientStreamingHandler( + std::function< + experimental::ServerReadReactor*()> + func) + : func_(std::move(func)) {} + void RunHandler(const HandlerParameter& param) final { + // Arena allocate a reader structure (that includes response) + ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); + + experimental::ServerReadReactor* reactor = + param.status.ok() + ? ::grpc::internal::CatchingReactorCreator< + experimental::ServerReadReactor>( + func_) + : nullptr; + + if (reactor == nullptr) { + // if deserialization or reactor creator failed, we need to fail the call + reactor = new UnimplementedReadReactor; + } + + auto* reader = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(ServerCallbackReaderImpl))) + ServerCallbackReaderImpl(param.server_context, param.call, + std::move(param.call_requester), reactor); + + reader->BindReactor(reactor); + reactor->OnStarted(param.server_context, reader->response()); + // The earliest that OnCancel can be called is after OnStarted is done. + reactor->MaybeCallOnCancel(); + reader->MaybeDone(); + } + + private: + std::function*()> + func_; + + class ServerCallbackReaderImpl + : public experimental::ServerCallbackReader { + public: + void Finish(::grpc::Status s) override { + finish_tag_.Set(call_.call(), [this](bool) { MaybeDone(); }, + &finish_ops_); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // The response is dropped if the status is not OK. + if (s.ok()) { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, + finish_ops_.SendMessagePtr(&resp_)); + } else { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); + } + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + meta_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnSendInitialMetadataDone(ok); + MaybeDone(); + }, + &meta_ops_); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + meta_ops_.set_core_cq_tag(&meta_tag_); + call_.PerformOps(&meta_ops_); + } + + void Read(RequestType* req) override { + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + read_ops_.RecvMessage(req); + call_.PerformOps(&read_ops_); + } + + private: + friend class CallbackClientStreamingHandler; + + ServerCallbackReaderImpl( + ::grpc_impl::ServerContext* ctx, grpc::internal::Call* call, + std::function call_requester, + experimental::ServerReadReactor* reactor) + : ctx_(ctx), + call_(*call), + call_requester_(std::move(call_requester)), + reactor_(reactor) { + ctx_->BeginCompletionOp(call, [this](bool) { MaybeDone(); }, reactor); + read_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadDone(ok); + MaybeDone(); + }, + &read_ops_); + read_ops_.set_core_cq_tag(&read_tag_); + } + + ~ServerCallbackReaderImpl() {} + + ResponseType* response() { return &resp_; } + + void MaybeDone() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + reactor_->OnDone(); + grpc_call* call = call_.call(); + auto call_requester = std::move(call_requester_); + this->~ServerCallbackReaderImpl(); // explicitly call destructor + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + call_requester(); + } + } + + grpc::internal::CallOpSet + meta_ops_; + grpc::internal::CallbackWithSuccessTag meta_tag_; + grpc::internal::CallOpSet + finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + grpc::internal::CallOpSet> + read_ops_; + grpc::internal::CallbackWithSuccessTag read_tag_; + + ::grpc_impl::ServerContext* ctx_; + grpc::internal::Call call_; + ResponseType resp_; + std::function call_requester_; + experimental::ServerReadReactor* reactor_; + std::atomic callbacks_outstanding_{ + 3}; // reserve for OnStarted, Finish, and CompletionOp + }; +}; + +template +class CallbackServerStreamingHandler : public grpc::internal::MethodHandler { + public: + CallbackServerStreamingHandler( + std::function< + experimental::ServerWriteReactor*()> + func) + : func_(std::move(func)) {} + void RunHandler(const HandlerParameter& param) final { + // Arena allocate a writer structure + ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); + + experimental::ServerWriteReactor* reactor = + param.status.ok() + ? ::grpc::internal::CatchingReactorCreator< + experimental::ServerWriteReactor>( + func_) + : nullptr; + + if (reactor == nullptr) { + // if deserialization or reactor creator failed, we need to fail the call + reactor = new UnimplementedWriteReactor; + } + + auto* writer = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(ServerCallbackWriterImpl))) + ServerCallbackWriterImpl(param.server_context, param.call, + static_cast(param.request), + std::move(param.call_requester), reactor); + writer->BindReactor(reactor); + reactor->OnStarted(param.server_context, writer->request()); + // The earliest that OnCancel can be called is after OnStarted is done. + reactor->MaybeCallOnCancel(); + writer->MaybeDone(); + } + + void* Deserialize(grpc_call* call, grpc_byte_buffer* req, + ::grpc::Status* status, void** handler_data) final { + ::grpc::ByteBuffer buf; + buf.set_buffer(req); + auto* request = + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call, sizeof(RequestType))) RequestType(); + *status = + ::grpc::SerializationTraits::Deserialize(&buf, request); + buf.Release(); + if (status->ok()) { + return request; + } + request->~RequestType(); + return nullptr; + } + + private: + std::function*()> + func_; + + class ServerCallbackWriterImpl + : public experimental::ServerCallbackWriter { + public: + void Finish(::grpc::Status s) override { + finish_tag_.Set(call_.call(), [this](bool) { MaybeDone(); }, + &finish_ops_); + finish_ops_.set_core_cq_tag(&finish_tag_); + + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); + call_.PerformOps(&finish_ops_); + } + + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + meta_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnSendInitialMetadataDone(ok); + MaybeDone(); + }, + &meta_ops_); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + meta_ops_.set_core_cq_tag(&meta_tag_); + call_.PerformOps(&meta_ops_); + } + + void Write(const ResponseType* resp, + ::grpc::WriteOptions options) override { + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (options.is_last_message()) { + options.set_buffer_hint(); + } + if (!ctx_->sent_initial_metadata_) { + write_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + write_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(resp, options).ok()); + call_.PerformOps(&write_ops_); + } + + void WriteAndFinish(const ResponseType* resp, ::grpc::WriteOptions options, + ::grpc::Status s) override { + // This combines the write into the finish callback + // Don't send any message if the status is bad + if (s.ok()) { + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(finish_ops_.SendMessagePtr(resp, options).ok()); + } + Finish(std::move(s)); + } + + private: + friend class CallbackServerStreamingHandler; + + ServerCallbackWriterImpl( + ::grpc_impl::ServerContext* ctx, grpc::internal::Call* call, + const RequestType* req, std::function call_requester, + experimental::ServerWriteReactor* reactor) + : ctx_(ctx), + call_(*call), + req_(req), + call_requester_(std::move(call_requester)), + reactor_(reactor) { + ctx_->BeginCompletionOp(call, [this](bool) { MaybeDone(); }, reactor); + write_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnWriteDone(ok); + MaybeDone(); + }, + &write_ops_); + write_ops_.set_core_cq_tag(&write_tag_); + } + ~ServerCallbackWriterImpl() { req_->~RequestType(); } + + const RequestType* request() { return req_; } + + void MaybeDone() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + reactor_->OnDone(); + grpc_call* call = call_.call(); + auto call_requester = std::move(call_requester_); + this->~ServerCallbackWriterImpl(); // explicitly call destructor + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + call_requester(); + } + } + + grpc::internal::CallOpSet + meta_ops_; + grpc::internal::CallbackWithSuccessTag meta_tag_; + grpc::internal::CallOpSet + finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + grpc::internal::CallOpSet + write_ops_; + grpc::internal::CallbackWithSuccessTag write_tag_; + + ::grpc_impl::ServerContext* ctx_; + grpc::internal::Call call_; + const RequestType* req_; + std::function call_requester_; + experimental::ServerWriteReactor* reactor_; + std::atomic callbacks_outstanding_{ + 3}; // reserve for OnStarted, Finish, and CompletionOp + }; +}; + +template +class CallbackBidiHandler : public grpc::internal::MethodHandler { + public: + CallbackBidiHandler( + std::function< + experimental::ServerBidiReactor*()> + func) + : func_(std::move(func)) {} + void RunHandler(const HandlerParameter& param) final { + ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); + + experimental::ServerBidiReactor* reactor = + param.status.ok() + ? ::grpc::internal::CatchingReactorCreator< + experimental::ServerBidiReactor>( + func_) + : nullptr; + + if (reactor == nullptr) { + // if deserialization or reactor creator failed, we need to fail the call + reactor = new UnimplementedBidiReactor; + } + + auto* stream = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(ServerCallbackReaderWriterImpl))) + ServerCallbackReaderWriterImpl(param.server_context, param.call, + std::move(param.call_requester), + reactor); + + stream->BindReactor(reactor); + reactor->OnStarted(param.server_context); + // The earliest that OnCancel can be called is after OnStarted is done. + reactor->MaybeCallOnCancel(); + stream->MaybeDone(); + } + + private: + std::function*()> + func_; + + class ServerCallbackReaderWriterImpl + : public experimental::ServerCallbackReaderWriter { + public: + void Finish(::grpc::Status s) override { + finish_tag_.Set(call_.call(), [this](bool) { MaybeDone(); }, + &finish_ops_); + finish_ops_.set_core_cq_tag(&finish_tag_); + + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); + call_.PerformOps(&finish_ops_); + } + + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + meta_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnSendInitialMetadataDone(ok); + MaybeDone(); + }, + &meta_ops_); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + meta_ops_.set_core_cq_tag(&meta_tag_); + call_.PerformOps(&meta_ops_); + } + + void Write(const ResponseType* resp, + ::grpc::WriteOptions options) override { + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (options.is_last_message()) { + options.set_buffer_hint(); + } + if (!ctx_->sent_initial_metadata_) { + write_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + write_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(resp, options).ok()); + call_.PerformOps(&write_ops_); + } + + void WriteAndFinish(const ResponseType* resp, ::grpc::WriteOptions options, + ::grpc::Status s) override { + // Don't send any message if the status is bad + if (s.ok()) { + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(finish_ops_.SendMessagePtr(resp, options).ok()); + } + Finish(std::move(s)); + } + + void Read(RequestType* req) override { + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + read_ops_.RecvMessage(req); + call_.PerformOps(&read_ops_); + } + + private: + friend class CallbackBidiHandler; + + ServerCallbackReaderWriterImpl( + ::grpc_impl::ServerContext* ctx, grpc::internal::Call* call, + std::function call_requester, + experimental::ServerBidiReactor* reactor) + : ctx_(ctx), + call_(*call), + call_requester_(std::move(call_requester)), + reactor_(reactor) { + ctx_->BeginCompletionOp(call, [this](bool) { MaybeDone(); }, reactor); + write_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnWriteDone(ok); + MaybeDone(); + }, + &write_ops_); + write_ops_.set_core_cq_tag(&write_tag_); + read_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadDone(ok); + MaybeDone(); + }, + &read_ops_); + read_ops_.set_core_cq_tag(&read_tag_); + } + ~ServerCallbackReaderWriterImpl() {} + + void MaybeDone() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + reactor_->OnDone(); + grpc_call* call = call_.call(); + auto call_requester = std::move(call_requester_); + this->~ServerCallbackReaderWriterImpl(); // explicitly call destructor + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + call_requester(); + } + } + + grpc::internal::CallOpSet + meta_ops_; + grpc::internal::CallbackWithSuccessTag meta_tag_; + grpc::internal::CallOpSet + finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + grpc::internal::CallOpSet + write_ops_; + grpc::internal::CallbackWithSuccessTag write_tag_; + grpc::internal::CallOpSet> + read_ops_; + grpc::internal::CallbackWithSuccessTag read_tag_; + + ::grpc_impl::ServerContext* ctx_; + grpc::internal::Call call_; + std::function call_requester_; + experimental::ServerBidiReactor* reactor_; + std::atomic callbacks_outstanding_{ + 3}; // reserve for OnStarted, Finish, and CompletionOp + }; +}; + +} // namespace internal + +} // namespace grpc_impl + +#endif // GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_IMPL_H diff --git a/include/grpcpp/impl/codegen/server_context_impl.h b/include/grpcpp/impl/codegen/server_context_impl.h index 9497735eacc..72137f153b1 100644 --- a/include/grpcpp/impl/codegen/server_context_impl.h +++ b/include/grpcpp/impl/codegen/server_context_impl.h @@ -44,10 +44,6 @@ namespace grpc_impl { class ClientContext; class CompletionQueue; class Server; -} // namespace grpc_impl -namespace grpc { -class GenericServerContext; -class ServerInterface; template class ServerAsyncReader; template @@ -62,14 +58,6 @@ template class ServerWriter; namespace internal { -template -class ServerReaderWriterBody; -template -class RpcMethodHandler; -template -class ClientStreamingHandler; -template -class ServerStreamingHandler; template class BidiStreamingHandler; template @@ -80,12 +68,28 @@ template class CallbackServerStreamingHandler; template class CallbackBidiHandler; +template +class ServerReaderWriterBody; +class ServerReactor; +} // namespace internal + +} // namespace grpc_impl +namespace grpc { +class GenericServerContext; +class ServerInterface; + +namespace internal { +template +class ClientStreamingHandler; +template +class ServerStreamingHandler; +template +class RpcMethodHandler; template class TemplatedBidiStreamingHandler; template class ErrorMethodHandler; class Call; -class ServerReactor; } // namespace internal class ServerInterface; @@ -275,19 +279,19 @@ class ServerContext { friend class ::grpc::ServerInterface; friend class ::grpc_impl::Server; template - friend class ::grpc::ServerAsyncReader; + friend class ::grpc_impl::ServerAsyncReader; template - friend class ::grpc::ServerAsyncWriter; + friend class ::grpc_impl::ServerAsyncWriter; template - friend class ::grpc::ServerAsyncResponseWriter; + friend class ::grpc_impl::ServerAsyncResponseWriter; template - friend class ::grpc::ServerAsyncReaderWriter; + friend class ::grpc_impl::ServerAsyncReaderWriter; template - friend class ::grpc::ServerReader; + friend class ::grpc_impl::ServerReader; template - friend class ::grpc::ServerWriter; + friend class ::grpc_impl::ServerWriter; template - friend class ::grpc::internal::ServerReaderWriterBody; + friend class ::grpc_impl::internal::ServerReaderWriterBody; template friend class ::grpc::internal::RpcMethodHandler; template @@ -297,13 +301,13 @@ class ServerContext { template friend class ::grpc::internal::TemplatedBidiStreamingHandler; template - friend class ::grpc::internal::CallbackUnaryHandler; + friend class ::grpc_impl::internal::CallbackUnaryHandler; template - friend class ::grpc::internal::CallbackClientStreamingHandler; + friend class ::grpc_impl::internal::CallbackClientStreamingHandler; template - friend class ::grpc::internal::CallbackServerStreamingHandler; + friend class ::grpc_impl::internal::CallbackServerStreamingHandler; template - friend class ::grpc::internal::CallbackBidiHandler; + friend class ::grpc_impl::internal::CallbackBidiHandler; template <::grpc::StatusCode code> friend class ::grpc::internal::ErrorMethodHandler; friend class ::grpc_impl::ClientContext; @@ -317,7 +321,7 @@ class ServerContext { void BeginCompletionOp(::grpc::internal::Call* call, std::function callback, - ::grpc::internal::ServerReactor* reactor); + ::grpc_impl::internal::ServerReactor* reactor); /// Return the tag queued by BeginCompletionOp() ::grpc::internal::CompletionQueueTag* GetCompletionOpTag(); diff --git a/include/grpcpp/impl/codegen/service_type.h b/include/grpcpp/impl/codegen/service_type.h index 4109ee1b504..f13dfb99fa0 100644 --- a/include/grpcpp/impl/codegen/service_type.h +++ b/include/grpcpp/impl/codegen/service_type.h @@ -149,8 +149,9 @@ class Service { void RequestAsyncUnary(int index, ::grpc_impl::ServerContext* context, Message* request, internal::ServerAsyncStreamingInterface* stream, - CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag) { + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag) { // Typecast the index to size_t for indexing into a vector // while preserving the API that existed before a compiler // warning was first seen (grpc/grpc#11664) @@ -160,8 +161,9 @@ class Service { } void RequestAsyncClientStreaming( int index, ::grpc_impl::ServerContext* context, - internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag) { + internal::ServerAsyncStreamingInterface* stream, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, void* tag) { size_t idx = static_cast(index); server_->RequestAsyncCall(methods_[idx].get(), context, stream, call_cq, notification_cq, tag); @@ -169,16 +171,18 @@ class Service { template void RequestAsyncServerStreaming( int index, ::grpc_impl::ServerContext* context, Message* request, - internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag) { + internal::ServerAsyncStreamingInterface* stream, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, void* tag) { size_t idx = static_cast(index); server_->RequestAsyncCall(methods_[idx].get(), context, stream, call_cq, notification_cq, tag, request); } void RequestAsyncBidiStreaming( int index, ::grpc_impl::ServerContext* context, - internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag) { + internal::ServerAsyncStreamingInterface* stream, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, void* tag) { size_t idx = static_cast(index); server_->RequestAsyncCall(methods_[idx].get(), context, stream, call_cq, notification_cq, tag); diff --git a/include/grpcpp/impl/codegen/sync_stream.h b/include/grpcpp/impl/codegen/sync_stream.h index 9d030a13a71..cd447d7c5a5 100644 --- a/include/grpcpp/impl/codegen/sync_stream.h +++ b/include/grpcpp/impl/codegen/sync_stream.h @@ -19,918 +19,42 @@ #ifndef GRPCPP_IMPL_CODEGEN_SYNC_STREAM_H #define GRPCPP_IMPL_CODEGEN_SYNC_STREAM_H -#include -#include -#include -#include -#include -#include -#include -#include +#include namespace grpc { - -namespace internal { -/// Common interface for all synchronous client side streaming. -class ClientStreamingInterface { - public: - virtual ~ClientStreamingInterface() {} - - /// Block waiting until the stream finishes and a final status of the call is - /// available. - /// - /// It is appropriate to call this method when both: - /// * the calling code (client-side) has no more message to send - /// (this can be declared implicitly by calling this method, or - /// explicitly through an earlier call to WritesDone method of the - /// class in use, e.g. \a ClientWriterInterface::WritesDone or - /// \a ClientReaderWriterInterface::WritesDone). - /// * there are no more messages to be received from the server (which can - /// be known implicitly, or explicitly from an earlier call to \a - /// ReaderInterface::Read that returned "false"). - /// - /// This function will return either: - /// - when all incoming messages have been read and the server has - /// returned status. - /// - when the server has returned a non-OK status. - /// - OR when the call failed for some reason and the library generated a - /// status. - /// - /// Return values: - /// - \a Status contains the status code, message and details for the call - /// - the \a ClientContext associated with this call is updated with - /// possible trailing metadata sent from the server. - virtual Status Finish() = 0; -}; - -/// Common interface for all synchronous server side streaming. -class ServerStreamingInterface { - public: - virtual ~ServerStreamingInterface() {} - - /// Block to send initial metadata to client. - /// This call is optional, but if it is used, it cannot be used concurrently - /// with or after the \a Finish method. - /// - /// The initial metadata that will be sent to the client will be - /// taken from the \a ServerContext associated with the call. - virtual void SendInitialMetadata() = 0; -}; - -/// An interface that yields a sequence of messages of type \a R. template -class ReaderInterface { - public: - virtual ~ReaderInterface() {} +using ClientReaderInterface = ::grpc_impl::ClientReaderInterface; - /// Get an upper bound on the next message size available for reading on this - /// stream. - virtual bool NextMessageSize(uint32_t* sz) = 0; - - /// Block to read a message and parse to \a msg. Returns \a true on success. - /// This is thread-safe with respect to \a Write or \WritesDone methods on - /// the same stream. It should not be called concurrently with another \a - /// Read on the same stream as the order of delivery will not be defined. - /// - /// \param[out] msg The read message. - /// - /// \return \a false when there will be no more incoming messages, either - /// because the other side has called \a WritesDone() or the stream has failed - /// (or been cancelled). - virtual bool Read(R* msg) = 0; -}; - -/// An interface that can be fed a sequence of messages of type \a W. -template -class WriterInterface { - public: - virtual ~WriterInterface() {} - - /// Block to write \a msg to the stream with WriteOptions \a options. - /// This is thread-safe with respect to \a ReaderInterface::Read - /// - /// \param msg The message to be written to the stream. - /// \param options The WriteOptions affecting the write operation. - /// - /// \return \a true on success, \a false when the stream has been closed. - virtual bool Write(const W& msg, WriteOptions options) = 0; - - /// Block to write \a msg to the stream with default write options. - /// This is thread-safe with respect to \a ReaderInterface::Read - /// - /// \param msg The message to be written to the stream. - /// - /// \return \a true on success, \a false when the stream has been closed. - inline bool Write(const W& msg) { return Write(msg, WriteOptions()); } - - /// Write \a msg and coalesce it with the writing of trailing metadata, using - /// WriteOptions \a options. - /// - /// For client, WriteLast is equivalent of performing Write and WritesDone in - /// a single step. \a msg and trailing metadata are coalesced and sent on wire - /// by calling this function. For server, WriteLast buffers the \a msg. - /// The writing of \a msg is held until the service handler returns, - /// where \a msg and trailing metadata are coalesced and sent on wire. - /// Note that WriteLast can only buffer \a msg up to the flow control window - /// size. If \a msg size is larger than the window size, it will be sent on - /// wire without buffering. - /// - /// \param[in] msg The message to be written to the stream. - /// \param[in] options The WriteOptions to be used to write this message. - void WriteLast(const W& msg, WriteOptions options) { - Write(msg, options.set_last_message()); - } -}; - -} // namespace internal - -/// Client-side interface for streaming reads of message of type \a R. template -class ClientReaderInterface : public internal::ClientStreamingInterface, - public internal::ReaderInterface { - public: - /// Block to wait for initial metadata from server. The received metadata - /// can only be accessed after this call returns. Should only be called before - /// the first read. Calling this method is optional, and if it is not called - /// the metadata will be available in ClientContext after the first read. - virtual void WaitForInitialMetadata() = 0; -}; - -namespace internal { +using ClientReader = ::grpc_impl::ClientReader; +template +using ClientWriterInterface = ::grpc_impl::ClientWriterInterface; +template +using ClientWriter = ::grpc_impl::ClientWriter; +template +using ClientReaderWriterInterface = + ::grpc_impl::ClientReaderWriterInterface; +template +using ClientReaderWriter = ::grpc_impl::ClientReaderWriter; template -class ClientReaderFactory { - public: - template - static ClientReader* Create(ChannelInterface* channel, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, - const W& request) { - return new ClientReader(channel, method, context, request); - } -}; -} // namespace internal - -/// Synchronous (blocking) client-side API for doing server-streaming RPCs, -/// where the stream of messages coming from the server has messages -/// of type \a R. +using ServerReaderInterface = ::grpc_impl::ServerReaderInterface; template -class ClientReader final : public ClientReaderInterface { - public: - /// See the \a ClientStreamingInterface.WaitForInitialMetadata method for - /// semantics. - /// - // Side effect: - /// Once complete, the initial metadata read from - /// the server will be accessible through the \a ClientContext used to - /// construct this object. - void WaitForInitialMetadata() override { - GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); - - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> - ops; - ops.RecvInitialMetadata(context_); - call_.PerformOps(&ops); - cq_.Pluck(&ops); /// status ignored - } - - bool NextMessageSize(uint32_t* sz) override { - *sz = call_.max_receive_message_size(); - return true; - } - - /// See the \a ReaderInterface.Read method for semantics. - /// Side effect: - /// This also receives initial metadata from the server, if not - /// already received (if initial metadata is received, it can be then - /// accessed through the \a ClientContext associated with this call). - bool Read(R* msg) override { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpRecvMessage> - ops; - if (!context_->initial_metadata_received_) { - ops.RecvInitialMetadata(context_); - } - ops.RecvMessage(msg); - call_.PerformOps(&ops); - return cq_.Pluck(&ops) && ops.got_message; - } - - /// See the \a ClientStreamingInterface.Finish method for semantics. - /// - /// Side effect: - /// The \a ClientContext associated with this call is updated with - /// possible metadata received from the server. - Status Finish() override { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpClientRecvStatus> ops; - Status status; - ops.ClientRecvStatus(context_, &status); - call_.PerformOps(&ops); - GPR_CODEGEN_ASSERT(cq_.Pluck(&ops)); - return status; - } - - private: - friend class internal::ClientReaderFactory; - ::grpc_impl::ClientContext* context_; - ::grpc_impl::CompletionQueue cq_; - ::grpc::internal::Call call_; - - /// Block to create a stream and write the initial metadata and \a request - /// out. Note that \a context will be used to fill in custom initial - /// metadata used to send to the server when starting the call. - template - ClientReader(::grpc::ChannelInterface* channel, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, const W& request) - : context_(context), - cq_(grpc_completion_queue_attributes{ - GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, - nullptr}), // Pluckable cq - call_(channel->CreateCall(method, context, &cq_)) { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpClientSendClose> - ops; - ops.SendInitialMetadata(&context->send_initial_metadata_, - context->initial_metadata_flags()); - // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(ops.SendMessagePtr(&request).ok()); - ops.ClientSendClose(); - call_.PerformOps(&ops); - cq_.Pluck(&ops); - } -}; - -/// Client-side interface for streaming writes of message type \a W. +using ServerReader = ::grpc_impl::ServerReader; template -class ClientWriterInterface : public internal::ClientStreamingInterface, - public internal::WriterInterface { - public: - /// Half close writing from the client. (signal that the stream of messages - /// coming from the client is complete). - /// Blocks until currently-pending writes are completed. - /// Thread safe with respect to \a ReaderInterface::Read operations only - /// - /// \return Whether the writes were successful. - virtual bool WritesDone() = 0; -}; - -namespace internal { +using ServerWriterInterface = ::grpc_impl::ServerWriterInterface; template -class ClientWriterFactory { - public: - template - static ClientWriter* Create(::grpc::ChannelInterface* channel, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, - R* response) { - return new ClientWriter(channel, method, context, response); - } -}; -} // namespace internal - -/// Synchronous (blocking) client-side API for doing client-streaming RPCs, -/// where the outgoing message stream coming from the client has messages of -/// type \a W. -template -class ClientWriter : public ClientWriterInterface { - public: - /// See the \a ClientStreamingInterface.WaitForInitialMetadata method for - /// semantics. - /// - // Side effect: - /// Once complete, the initial metadata read from the server will be - /// accessible through the \a ClientContext used to construct this object. - void WaitForInitialMetadata() { - GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); - - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> - ops; - ops.RecvInitialMetadata(context_); - call_.PerformOps(&ops); - cq_.Pluck(&ops); // status ignored - } - - /// See the WriterInterface.Write(const W& msg, WriteOptions options) method - /// for semantics. - /// - /// Side effect: - /// Also sends initial metadata if not already sent (using the - /// \a ClientContext associated with this call). - using ::grpc::internal::WriterInterface::Write; - bool Write(const W& msg, WriteOptions options) override { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpClientSendClose> - ops; - - if (options.is_last_message()) { - options.set_buffer_hint(); - ops.ClientSendClose(); - } - if (context_->initial_metadata_corked_) { - ops.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - context_->set_initial_metadata_corked(false); - } - if (!ops.SendMessagePtr(&msg, options).ok()) { - return false; - } - - call_.PerformOps(&ops); - return cq_.Pluck(&ops); - } - - bool WritesDone() override { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpClientSendClose> ops; - ops.ClientSendClose(); - call_.PerformOps(&ops); - return cq_.Pluck(&ops); - } - - /// See the ClientStreamingInterface.Finish method for semantics. - /// Side effects: - /// - Also receives initial metadata if not already received. - /// - Attempts to fill in the \a response parameter passed - /// to the constructor of this instance with the response - /// message from the server. - Status Finish() override { - Status status; - if (!context_->initial_metadata_received_) { - finish_ops_.RecvInitialMetadata(context_); - } - finish_ops_.ClientRecvStatus(context_, &status); - call_.PerformOps(&finish_ops_); - GPR_CODEGEN_ASSERT(cq_.Pluck(&finish_ops_)); - return status; - } - - private: - friend class internal::ClientWriterFactory; - - /// Block to create a stream (i.e. send request headers and other initial - /// metadata to the server). Note that \a context will be used to fill - /// in custom initial metadata. \a response will be filled in with the - /// single expected response message from the server upon a successful - /// call to the \a Finish method of this instance. - template - ClientWriter(ChannelInterface* channel, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, R* response) - : context_(context), - cq_(grpc_completion_queue_attributes{ - GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, - nullptr}), // Pluckable cq - call_(channel->CreateCall(method, context, &cq_)) { - finish_ops_.RecvMessage(response); - finish_ops_.AllowNoMessage(); - - if (!context_->initial_metadata_corked_) { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> - ops; - ops.SendInitialMetadata(&context->send_initial_metadata_, - context->initial_metadata_flags()); - call_.PerformOps(&ops); - cq_.Pluck(&ops); - } - } - - ::grpc_impl::ClientContext* context_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpGenericRecvMessage, - ::grpc::internal::CallOpClientRecvStatus> - finish_ops_; - ::grpc_impl::CompletionQueue cq_; - ::grpc::internal::Call call_; -}; - -/// Client-side interface for bi-directional streaming with -/// client-to-server stream messages of type \a W and -/// server-to-client stream messages of type \a R. +using ServerWriter = ::grpc_impl::ServerWriter; template -class ClientReaderWriterInterface : public internal::ClientStreamingInterface, - public internal::WriterInterface, - public internal::ReaderInterface { - public: - /// Block to wait for initial metadata from server. The received metadata - /// can only be accessed after this call returns. Should only be called before - /// the first read. Calling this method is optional, and if it is not called - /// the metadata will be available in ClientContext after the first read. - virtual void WaitForInitialMetadata() = 0; - - /// Half close writing from the client. (signal that the stream of messages - /// coming from the clinet is complete). - /// Blocks until currently-pending writes are completed. - /// Thread-safe with respect to \a ReaderInterface::Read - /// - /// \return Whether the writes were successful. - virtual bool WritesDone() = 0; -}; - -namespace internal { +using ServerReaderWriterInterface = + ::grpc_impl::ServerReaderWriterInterface; template -class ClientReaderWriterFactory { - public: - static ClientReaderWriter* Create( - ::grpc::ChannelInterface* channel, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context) { - return new ClientReaderWriter(channel, method, context); - } -}; -} // namespace internal - -/// Synchronous (blocking) client-side API for bi-directional streaming RPCs, -/// where the outgoing message stream coming from the client has messages of -/// type \a W, and the incoming messages stream coming from the server has -/// messages of type \a R. -template -class ClientReaderWriter final : public ClientReaderWriterInterface { - public: - /// Block waiting to read initial metadata from the server. - /// This call is optional, but if it is used, it cannot be used concurrently - /// with or after the \a Finish method. - /// - /// Once complete, the initial metadata read from the server will be - /// accessible through the \a ClientContext used to construct this object. - void WaitForInitialMetadata() override { - GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); - - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> - ops; - ops.RecvInitialMetadata(context_); - call_.PerformOps(&ops); - cq_.Pluck(&ops); // status ignored - } - - bool NextMessageSize(uint32_t* sz) override { - *sz = call_.max_receive_message_size(); - return true; - } - - /// See the \a ReaderInterface.Read method for semantics. - /// Side effect: - /// Also receives initial metadata if not already received (updates the \a - /// ClientContext associated with this call in that case). - bool Read(R* msg) override { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpRecvMessage> - ops; - if (!context_->initial_metadata_received_) { - ops.RecvInitialMetadata(context_); - } - ops.RecvMessage(msg); - call_.PerformOps(&ops); - return cq_.Pluck(&ops) && ops.got_message; - } - - /// See the \a WriterInterface.Write method for semantics. - /// - /// Side effect: - /// Also sends initial metadata if not already sent (using the - /// \a ClientContext associated with this call to fill in values). - using ::grpc::internal::WriterInterface::Write; - bool Write(const W& msg, WriteOptions options) override { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpClientSendClose> - ops; - - if (options.is_last_message()) { - options.set_buffer_hint(); - ops.ClientSendClose(); - } - if (context_->initial_metadata_corked_) { - ops.SendInitialMetadata(&context_->send_initial_metadata_, - context_->initial_metadata_flags()); - context_->set_initial_metadata_corked(false); - } - if (!ops.SendMessagePtr(&msg, options).ok()) { - return false; - } - - call_.PerformOps(&ops); - return cq_.Pluck(&ops); - } - - bool WritesDone() override { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpClientSendClose> ops; - ops.ClientSendClose(); - call_.PerformOps(&ops); - return cq_.Pluck(&ops); - } - - /// See the ClientStreamingInterface.Finish method for semantics. - /// - /// Side effect: - /// - the \a ClientContext associated with this call is updated with - /// possible trailing metadata sent from the server. - Status Finish() override { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, - ::grpc::internal::CallOpClientRecvStatus> - ops; - if (!context_->initial_metadata_received_) { - ops.RecvInitialMetadata(context_); - } - Status status; - ops.ClientRecvStatus(context_, &status); - call_.PerformOps(&ops); - GPR_CODEGEN_ASSERT(cq_.Pluck(&ops)); - return status; - } - - private: - friend class internal::ClientReaderWriterFactory; - - ::grpc_impl::ClientContext* context_; - ::grpc_impl::CompletionQueue cq_; - ::grpc::internal::Call call_; - - /// Block to create a stream and write the initial metadata and \a request - /// out. Note that \a context will be used to fill in custom initial metadata - /// used to send to the server when starting the call. - ClientReaderWriter(::grpc::ChannelInterface* channel, - const ::grpc::internal::RpcMethod& method, - ::grpc_impl::ClientContext* context) - : context_(context), - cq_(grpc_completion_queue_attributes{ - GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, - nullptr}), // Pluckable cq - call_(channel->CreateCall(method, context, &cq_)) { - if (!context_->initial_metadata_corked_) { - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> - ops; - ops.SendInitialMetadata(&context->send_initial_metadata_, - context->initial_metadata_flags()); - call_.PerformOps(&ops); - cq_.Pluck(&ops); - } - } -}; - -/// Server-side interface for streaming reads of message of type \a R. -template -class ServerReaderInterface : public internal::ServerStreamingInterface, - public internal::ReaderInterface {}; - -/// Synchronous (blocking) server-side API for doing client-streaming RPCs, -/// where the incoming message stream coming from the client has messages of -/// type \a R. -template -class ServerReader final : public ServerReaderInterface { - public: - /// See the \a ServerStreamingInterface.SendInitialMetadata method - /// for semantics. Note that initial metadata will be affected by the - /// \a ServerContext associated with this call. - void SendInitialMetadata() override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - - internal::CallOpSet ops; - ops.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - ops.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - call_->PerformOps(&ops); - call_->cq()->Pluck(&ops); - } - - bool NextMessageSize(uint32_t* sz) override { - *sz = call_->max_receive_message_size(); - return true; - } - - bool Read(R* msg) override { - internal::CallOpSet> ops; - ops.RecvMessage(msg); - call_->PerformOps(&ops); - return call_->cq()->Pluck(&ops) && ops.got_message; - } - - private: - internal::Call* const call_; - ::grpc_impl::ServerContext* const ctx_; - - template - friend class internal::ClientStreamingHandler; - - ServerReader(internal::Call* call, ::grpc_impl::ServerContext* ctx) - : call_(call), ctx_(ctx) {} -}; - -/// Server-side interface for streaming writes of message of type \a W. -template -class ServerWriterInterface : public internal::ServerStreamingInterface, - public internal::WriterInterface {}; - -/// Synchronous (blocking) server-side API for doing for doing a -/// server-streaming RPCs, where the outgoing message stream coming from the -/// server has messages of type \a W. -template -class ServerWriter final : public ServerWriterInterface { - public: - /// See the \a ServerStreamingInterface.SendInitialMetadata method - /// for semantics. - /// Note that initial metadata will be affected by the - /// \a ServerContext associated with this call. - void SendInitialMetadata() override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - - internal::CallOpSet ops; - ops.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - ops.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - call_->PerformOps(&ops); - call_->cq()->Pluck(&ops); - } - - /// See the \a WriterInterface.Write method for semantics. - /// - /// Side effect: - /// Also sends initial metadata if not already sent (using the - /// \a ClientContext associated with this call to fill in values). - using internal::WriterInterface::Write; - bool Write(const W& msg, WriteOptions options) override { - if (options.is_last_message()) { - options.set_buffer_hint(); - } - - if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) { - return false; - } - if (!ctx_->sent_initial_metadata_) { - ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - ctx_->pending_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - call_->PerformOps(&ctx_->pending_ops_); - // if this is the last message we defer the pluck until AFTER we start - // the trailing md op. This prevents hangs. See - // https://github.com/grpc/grpc/issues/11546 - if (options.is_last_message()) { - ctx_->has_pending_ops_ = true; - return true; - } - ctx_->has_pending_ops_ = false; - return call_->cq()->Pluck(&ctx_->pending_ops_); - } - - private: - internal::Call* const call_; - ::grpc_impl::ServerContext* const ctx_; - - template - friend class internal::ServerStreamingHandler; - - ServerWriter(internal::Call* call, ::grpc_impl::ServerContext* ctx) - : call_(call), ctx_(ctx) {} -}; - -/// Server-side interface for bi-directional streaming. -template -class ServerReaderWriterInterface : public internal::ServerStreamingInterface, - public internal::WriterInterface, - public internal::ReaderInterface {}; - -/// Actual implementation of bi-directional streaming -namespace internal { -template -class ServerReaderWriterBody final { - public: - ServerReaderWriterBody(Call* call, ::grpc_impl::ServerContext* ctx) - : call_(call), ctx_(ctx) {} - - void SendInitialMetadata() { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - - CallOpSet ops; - ops.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - ops.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - call_->PerformOps(&ops); - call_->cq()->Pluck(&ops); - } - - bool NextMessageSize(uint32_t* sz) { - *sz = call_->max_receive_message_size(); - return true; - } - - bool Read(R* msg) { - CallOpSet> ops; - ops.RecvMessage(msg); - call_->PerformOps(&ops); - return call_->cq()->Pluck(&ops) && ops.got_message; - } - - bool Write(const W& msg, WriteOptions options) { - if (options.is_last_message()) { - options.set_buffer_hint(); - } - if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) { - return false; - } - if (!ctx_->sent_initial_metadata_) { - ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - ctx_->pending_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - call_->PerformOps(&ctx_->pending_ops_); - // if this is the last message we defer the pluck until AFTER we start - // the trailing md op. This prevents hangs. See - // https://github.com/grpc/grpc/issues/11546 - if (options.is_last_message()) { - ctx_->has_pending_ops_ = true; - return true; - } - ctx_->has_pending_ops_ = false; - return call_->cq()->Pluck(&ctx_->pending_ops_); - } - - private: - Call* const call_; - ::grpc_impl::ServerContext* const ctx_; -}; - -} // namespace internal - -/// Synchronous (blocking) server-side API for a bidirectional -/// streaming call, where the incoming message stream coming from the client has -/// messages of type \a R, and the outgoing message streaming coming from -/// the server has messages of type \a W. -template -class ServerReaderWriter final : public ServerReaderWriterInterface { - public: - /// See the \a ServerStreamingInterface.SendInitialMetadata method - /// for semantics. Note that initial metadata will be affected by the - /// \a ServerContext associated with this call. - void SendInitialMetadata() override { body_.SendInitialMetadata(); } - - bool NextMessageSize(uint32_t* sz) override { - return body_.NextMessageSize(sz); - } - - bool Read(R* msg) override { return body_.Read(msg); } - - /// See the \a WriterInterface.Write(const W& msg, WriteOptions options) - /// method for semantics. - /// Side effect: - /// Also sends initial metadata if not already sent (using the \a - /// ServerContext associated with this call). - using internal::WriterInterface::Write; - bool Write(const W& msg, WriteOptions options) override { - return body_.Write(msg, options); - } - - private: - internal::ServerReaderWriterBody body_; - - friend class internal::TemplatedBidiStreamingHandler, - false>; - ServerReaderWriter(internal::Call* call, ::grpc_impl::ServerContext* ctx) - : body_(call, ctx) {} -}; - -/// A class to represent a flow-controlled unary call. This is something -/// of a hybrid between conventional unary and streaming. This is invoked -/// through a unary call on the client side, but the server responds to it -/// as though it were a single-ping-pong streaming call. The server can use -/// the \a NextMessageSize method to determine an upper-bound on the size of -/// the message. A key difference relative to streaming: ServerUnaryStreamer -/// must have exactly 1 Read and exactly 1 Write, in that order, to function -/// correctly. Otherwise, the RPC is in error. +using ServerReaderWriter = ::grpc_impl::ServerReaderWriter; template -class ServerUnaryStreamer final - : public ServerReaderWriterInterface { - public: - /// Block to send initial metadata to client. - /// Implicit input parameter: - /// - the \a ServerContext associated with this call will be used for - /// sending initial metadata. - void SendInitialMetadata() override { body_.SendInitialMetadata(); } - - /// Get an upper bound on the request message size from the client. - bool NextMessageSize(uint32_t* sz) override { - return body_.NextMessageSize(sz); - } - - /// Read a message of type \a R into \a msg. Completion will be notified by \a - /// tag on the associated completion queue. - /// This is thread-safe with respect to \a Write or \a WritesDone methods. It - /// should not be called concurrently with other streaming APIs - /// on the same stream. It is not meaningful to call it concurrently - /// with another \a ReaderInterface::Read on the same stream since reads on - /// the same stream are delivered in order. - /// - /// \param[out] msg Where to eventually store the read message. - /// \param[in] tag The tag identifying the operation. - bool Read(RequestType* request) override { - if (read_done_) { - return false; - } - read_done_ = true; - return body_.Read(request); - } - - /// Block to write \a msg to the stream with WriteOptions \a options. - /// This is thread-safe with respect to \a ReaderInterface::Read - /// - /// \param msg The message to be written to the stream. - /// \param options The WriteOptions affecting the write operation. - /// - /// \return \a true on success, \a false when the stream has been closed. - using internal::WriterInterface::Write; - bool Write(const ResponseType& response, WriteOptions options) override { - if (write_done_ || !read_done_) { - return false; - } - write_done_ = true; - return body_.Write(response, options); - } - - private: - internal::ServerReaderWriterBody body_; - bool read_done_; - bool write_done_; - - friend class internal::TemplatedBidiStreamingHandler< - ServerUnaryStreamer, true>; - ServerUnaryStreamer(internal::Call* call, ::grpc_impl::ServerContext* ctx) - : body_(call, ctx), read_done_(false), write_done_(false) {} -}; - -/// A class to represent a flow-controlled server-side streaming call. -/// This is something of a hybrid between server-side and bidi streaming. -/// This is invoked through a server-side streaming call on the client side, -/// but the server responds to it as though it were a bidi streaming call that -/// must first have exactly 1 Read and then any number of Writes. +using ServerUnaryStreamer = + ::grpc_impl::ServerUnaryStreamer; template -class ServerSplitStreamer final - : public ServerReaderWriterInterface { - public: - /// Block to send initial metadata to client. - /// Implicit input parameter: - /// - the \a ServerContext associated with this call will be used for - /// sending initial metadata. - void SendInitialMetadata() override { body_.SendInitialMetadata(); } - - /// Get an upper bound on the request message size from the client. - bool NextMessageSize(uint32_t* sz) override { - return body_.NextMessageSize(sz); - } - - /// Read a message of type \a R into \a msg. Completion will be notified by \a - /// tag on the associated completion queue. - /// This is thread-safe with respect to \a Write or \a WritesDone methods. It - /// should not be called concurrently with other streaming APIs - /// on the same stream. It is not meaningful to call it concurrently - /// with another \a ReaderInterface::Read on the same stream since reads on - /// the same stream are delivered in order. - /// - /// \param[out] msg Where to eventually store the read message. - /// \param[in] tag The tag identifying the operation. - bool Read(RequestType* request) override { - if (read_done_) { - return false; - } - read_done_ = true; - return body_.Read(request); - } - - /// Block to write \a msg to the stream with WriteOptions \a options. - /// This is thread-safe with respect to \a ReaderInterface::Read - /// - /// \param msg The message to be written to the stream. - /// \param options The WriteOptions affecting the write operation. - /// - /// \return \a true on success, \a false when the stream has been closed. - using internal::WriterInterface::Write; - bool Write(const ResponseType& response, WriteOptions options) override { - return read_done_ && body_.Write(response, options); - } - - private: - internal::ServerReaderWriterBody body_; - bool read_done_; - - friend class internal::TemplatedBidiStreamingHandler< - ServerSplitStreamer, false>; - ServerSplitStreamer(internal::Call* call, ::grpc_impl::ServerContext* ctx) - : body_(call, ctx), read_done_(false) {} -}; +using ServerSplitStreamer = + ::grpc_impl::ServerSplitStreamer; } // namespace grpc diff --git a/include/grpcpp/impl/codegen/sync_stream_impl.h b/include/grpcpp/impl/codegen/sync_stream_impl.h new file mode 100644 index 00000000000..dc764e0e27b --- /dev/null +++ b/include/grpcpp/impl/codegen/sync_stream_impl.h @@ -0,0 +1,944 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SYNC_STREAM_IMPL_H +#define GRPCPP_IMPL_CODEGEN_SYNC_STREAM_IMPL_H + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace grpc_impl { + +namespace internal { +/// Common interface for all synchronous client side streaming. +class ClientStreamingInterface { + public: + virtual ~ClientStreamingInterface() {} + + /// Block waiting until the stream finishes and a final status of the call is + /// available. + /// + /// It is appropriate to call this method when both: + /// * the calling code (client-side) has no more message to send + /// (this can be declared implicitly by calling this method, or + /// explicitly through an earlier call to WritesDone method of the + /// class in use, e.g. \a ClientWriterInterface::WritesDone or + /// \a ClientReaderWriterInterface::WritesDone). + /// * there are no more messages to be received from the server (which can + /// be known implicitly, or explicitly from an earlier call to \a + /// ReaderInterface::Read that returned "false"). + /// + /// This function will return either: + /// - when all incoming messages have been read and the server has + /// returned status. + /// - when the server has returned a non-OK status. + /// - OR when the call failed for some reason and the library generated a + /// status. + /// + /// Return values: + /// - \a Status contains the status code, message and details for the call + /// - the \a ClientContext associated with this call is updated with + /// possible trailing metadata sent from the server. + virtual ::grpc::Status Finish() = 0; +}; + +/// Common interface for all synchronous server side streaming. +class ServerStreamingInterface { + public: + virtual ~ServerStreamingInterface() {} + + /// Block to send initial metadata to client. + /// This call is optional, but if it is used, it cannot be used concurrently + /// with or after the \a Finish method. + /// + /// The initial metadata that will be sent to the client will be + /// taken from the \a ServerContext associated with the call. + virtual void SendInitialMetadata() = 0; +}; + +/// An interface that yields a sequence of messages of type \a R. +template +class ReaderInterface { + public: + virtual ~ReaderInterface() {} + + /// Get an upper bound on the next message size available for reading on this + /// stream. + virtual bool NextMessageSize(uint32_t* sz) = 0; + + /// Block to read a message and parse to \a msg. Returns \a true on success. + /// This is thread-safe with respect to \a Write or \WritesDone methods on + /// the same stream. It should not be called concurrently with another \a + /// Read on the same stream as the order of delivery will not be defined. + /// + /// \param[out] msg The read message. + /// + /// \return \a false when there will be no more incoming messages, either + /// because the other side has called \a WritesDone() or the stream has failed + /// (or been cancelled). + virtual bool Read(R* msg) = 0; +}; + +/// An interface that can be fed a sequence of messages of type \a W. +template +class WriterInterface { + public: + virtual ~WriterInterface() {} + + /// Block to write \a msg to the stream with WriteOptions \a options. + /// This is thread-safe with respect to \a ReaderInterface::Read + /// + /// \param msg The message to be written to the stream. + /// \param options The WriteOptions affecting the write operation. + /// + /// \return \a true on success, \a false when the stream has been closed. + virtual bool Write(const W& msg, ::grpc::WriteOptions options) = 0; + + /// Block to write \a msg to the stream with default write options. + /// This is thread-safe with respect to \a ReaderInterface::Read + /// + /// \param msg The message to be written to the stream. + /// + /// \return \a true on success, \a false when the stream has been closed. + inline bool Write(const W& msg) { return Write(msg, ::grpc::WriteOptions()); } + + /// Write \a msg and coalesce it with the writing of trailing metadata, using + /// WriteOptions \a options. + /// + /// For client, WriteLast is equivalent of performing Write and WritesDone in + /// a single step. \a msg and trailing metadata are coalesced and sent on wire + /// by calling this function. For server, WriteLast buffers the \a msg. + /// The writing of \a msg is held until the service handler returns, + /// where \a msg and trailing metadata are coalesced and sent on wire. + /// Note that WriteLast can only buffer \a msg up to the flow control window + /// size. If \a msg size is larger than the window size, it will be sent on + /// wire without buffering. + /// + /// \param[in] msg The message to be written to the stream. + /// \param[in] options The WriteOptions to be used to write this message. + void WriteLast(const W& msg, ::grpc::WriteOptions options) { + Write(msg, options.set_last_message()); + } +}; + +} // namespace internal + +/// Client-side interface for streaming reads of message of type \a R. +template +class ClientReaderInterface : public internal::ClientStreamingInterface, + public internal::ReaderInterface { + public: + /// Block to wait for initial metadata from server. The received metadata + /// can only be accessed after this call returns. Should only be called before + /// the first read. Calling this method is optional, and if it is not called + /// the metadata will be available in ClientContext after the first read. + virtual void WaitForInitialMetadata() = 0; +}; + +namespace internal { +template +class ClientReaderFactory { + public: + template + static ClientReader* Create(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + const W& request) { + return new ClientReader(channel, method, context, request); + } +}; +} // namespace internal + +/// Synchronous (blocking) client-side API for doing server-streaming RPCs, +/// where the stream of messages coming from the server has messages +/// of type \a R. +template +class ClientReader final : public ClientReaderInterface { + public: + /// See the \a ClientStreamingInterface.WaitForInitialMetadata method for + /// semantics. + /// + // Side effect: + /// Once complete, the initial metadata read from + /// the server will be accessible through the \a ClientContext used to + /// construct this object. + void WaitForInitialMetadata() override { + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> + ops; + ops.RecvInitialMetadata(context_); + call_.PerformOps(&ops); + cq_.Pluck(&ops); /// status ignored + } + + bool NextMessageSize(uint32_t* sz) override { + *sz = call_.max_receive_message_size(); + return true; + } + + /// See the \a ReaderInterface.Read method for semantics. + /// Side effect: + /// This also receives initial metadata from the server, if not + /// already received (if initial metadata is received, it can be then + /// accessed through the \a ClientContext associated with this call). + bool Read(R* msg) override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpRecvMessage> + ops; + if (!context_->initial_metadata_received_) { + ops.RecvInitialMetadata(context_); + } + ops.RecvMessage(msg); + call_.PerformOps(&ops); + return cq_.Pluck(&ops) && ops.got_message; + } + + /// See the \a ClientStreamingInterface.Finish method for semantics. + /// + /// Side effect: + /// The \a ClientContext associated with this call is updated with + /// possible metadata received from the server. + ::grpc::Status Finish() override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpClientRecvStatus> ops; + ::grpc::Status status; + ops.ClientRecvStatus(context_, &status); + call_.PerformOps(&ops); + GPR_CODEGEN_ASSERT(cq_.Pluck(&ops)); + return status; + } + + private: + friend class internal::ClientReaderFactory; + ::grpc_impl::ClientContext* context_; + ::grpc_impl::CompletionQueue cq_; + ::grpc::internal::Call call_; + + /// Block to create a stream and write the initial metadata and \a request + /// out. Note that \a context will be used to fill in custom initial + /// metadata used to send to the server when starting the call. + template + ClientReader(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, const W& request) + : context_(context), + cq_(grpc_completion_queue_attributes{ + GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, + nullptr}), // Pluckable cq + call_(channel->CreateCall(method, context, &cq_)) { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose> + ops; + ops.SendInitialMetadata(&context->send_initial_metadata_, + context->initial_metadata_flags()); + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(ops.SendMessagePtr(&request).ok()); + ops.ClientSendClose(); + call_.PerformOps(&ops); + cq_.Pluck(&ops); + } +}; + +/// Client-side interface for streaming writes of message type \a W. +template +class ClientWriterInterface : public internal::ClientStreamingInterface, + public internal::WriterInterface { + public: + /// Half close writing from the client. (signal that the stream of messages + /// coming from the client is complete). + /// Blocks until currently-pending writes are completed. + /// Thread safe with respect to \a ReaderInterface::Read operations only + /// + /// \return Whether the writes were successful. + virtual bool WritesDone() = 0; +}; + +namespace internal { +template +class ClientWriterFactory { + public: + template + static ClientWriter* Create(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + R* response) { + return new ClientWriter(channel, method, context, response); + } +}; +} // namespace internal + +/// Synchronous (blocking) client-side API for doing client-streaming RPCs, +/// where the outgoing message stream coming from the client has messages of +/// type \a W. +template +class ClientWriter : public ClientWriterInterface { + public: + /// See the \a ClientStreamingInterface.WaitForInitialMetadata method for + /// semantics. + /// + // Side effect: + /// Once complete, the initial metadata read from the server will be + /// accessible through the \a ClientContext used to construct this object. + void WaitForInitialMetadata() { + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> + ops; + ops.RecvInitialMetadata(context_); + call_.PerformOps(&ops); + cq_.Pluck(&ops); // status ignored + } + + /// See the WriterInterface.Write(const W& msg, WriteOptions options) method + /// for semantics. + /// + /// Side effect: + /// Also sends initial metadata if not already sent (using the + /// \a ClientContext associated with this call). + using internal::WriterInterface::Write; + bool Write(const W& msg, ::grpc::WriteOptions options) override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose> + ops; + + if (options.is_last_message()) { + options.set_buffer_hint(); + ops.ClientSendClose(); + } + if (context_->initial_metadata_corked_) { + ops.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + context_->set_initial_metadata_corked(false); + } + if (!ops.SendMessagePtr(&msg, options).ok()) { + return false; + } + + call_.PerformOps(&ops); + return cq_.Pluck(&ops); + } + + bool WritesDone() override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpClientSendClose> ops; + ops.ClientSendClose(); + call_.PerformOps(&ops); + return cq_.Pluck(&ops); + } + + /// See the ClientStreamingInterface.Finish method for semantics. + /// Side effects: + /// - Also receives initial metadata if not already received. + /// - Attempts to fill in the \a response parameter passed + /// to the constructor of this instance with the response + /// message from the server. + ::grpc::Status Finish() override { + ::grpc::Status status; + if (!context_->initial_metadata_received_) { + finish_ops_.RecvInitialMetadata(context_); + } + finish_ops_.ClientRecvStatus(context_, &status); + call_.PerformOps(&finish_ops_); + GPR_CODEGEN_ASSERT(cq_.Pluck(&finish_ops_)); + return status; + } + + private: + friend class internal::ClientWriterFactory; + + /// Block to create a stream (i.e. send request headers and other initial + /// metadata to the server). Note that \a context will be used to fill + /// in custom initial metadata. \a response will be filled in with the + /// single expected response message from the server upon a successful + /// call to the \a Finish method of this instance. + template + ClientWriter(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, R* response) + : context_(context), + cq_(grpc_completion_queue_attributes{ + GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, + nullptr}), // Pluckable cq + call_(channel->CreateCall(method, context, &cq_)) { + finish_ops_.RecvMessage(response); + finish_ops_.AllowNoMessage(); + + if (!context_->initial_metadata_corked_) { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + ops; + ops.SendInitialMetadata(&context->send_initial_metadata_, + context->initial_metadata_flags()); + call_.PerformOps(&ops); + cq_.Pluck(&ops); + } + } + + ::grpc_impl::ClientContext* context_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpGenericRecvMessage, + ::grpc::internal::CallOpClientRecvStatus> + finish_ops_; + ::grpc_impl::CompletionQueue cq_; + ::grpc::internal::Call call_; +}; + +/// Client-side interface for bi-directional streaming with +/// client-to-server stream messages of type \a W and +/// server-to-client stream messages of type \a R. +template +class ClientReaderWriterInterface : public internal::ClientStreamingInterface, + public internal::WriterInterface, + public internal::ReaderInterface { + public: + /// Block to wait for initial metadata from server. The received metadata + /// can only be accessed after this call returns. Should only be called before + /// the first read. Calling this method is optional, and if it is not called + /// the metadata will be available in ClientContext after the first read. + virtual void WaitForInitialMetadata() = 0; + + /// Half close writing from the client. (signal that the stream of messages + /// coming from the clinet is complete). + /// Blocks until currently-pending writes are completed. + /// Thread-safe with respect to \a ReaderInterface::Read + /// + /// \return Whether the writes were successful. + virtual bool WritesDone() = 0; +}; + +namespace internal { +template +class ClientReaderWriterFactory { + public: + static ClientReaderWriter* Create( + ::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context) { + return new ClientReaderWriter(channel, method, context); + } +}; +} // namespace internal + +/// Synchronous (blocking) client-side API for bi-directional streaming RPCs, +/// where the outgoing message stream coming from the client has messages of +/// type \a W, and the incoming messages stream coming from the server has +/// messages of type \a R. +template +class ClientReaderWriter final : public ClientReaderWriterInterface { + public: + /// Block waiting to read initial metadata from the server. + /// This call is optional, but if it is used, it cannot be used concurrently + /// with or after the \a Finish method. + /// + /// Once complete, the initial metadata read from the server will be + /// accessible through the \a ClientContext used to construct this object. + void WaitForInitialMetadata() override { + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> + ops; + ops.RecvInitialMetadata(context_); + call_.PerformOps(&ops); + cq_.Pluck(&ops); // status ignored + } + + bool NextMessageSize(uint32_t* sz) override { + *sz = call_.max_receive_message_size(); + return true; + } + + /// See the \a ReaderInterface.Read method for semantics. + /// Side effect: + /// Also receives initial metadata if not already received (updates the \a + /// ClientContext associated with this call in that case). + bool Read(R* msg) override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpRecvMessage> + ops; + if (!context_->initial_metadata_received_) { + ops.RecvInitialMetadata(context_); + } + ops.RecvMessage(msg); + call_.PerformOps(&ops); + return cq_.Pluck(&ops) && ops.got_message; + } + + /// See the \a WriterInterface.Write method for semantics. + /// + /// Side effect: + /// Also sends initial metadata if not already sent (using the + /// \a ClientContext associated with this call to fill in values). + using internal::WriterInterface::Write; + bool Write(const W& msg, ::grpc::WriteOptions options) override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose> + ops; + + if (options.is_last_message()) { + options.set_buffer_hint(); + ops.ClientSendClose(); + } + if (context_->initial_metadata_corked_) { + ops.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + context_->set_initial_metadata_corked(false); + } + if (!ops.SendMessagePtr(&msg, options).ok()) { + return false; + } + + call_.PerformOps(&ops); + return cq_.Pluck(&ops); + } + + bool WritesDone() override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpClientSendClose> ops; + ops.ClientSendClose(); + call_.PerformOps(&ops); + return cq_.Pluck(&ops); + } + + /// See the ClientStreamingInterface.Finish method for semantics. + /// + /// Side effect: + /// - the \a ClientContext associated with this call is updated with + /// possible trailing metadata sent from the server. + ::grpc::Status Finish() override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpClientRecvStatus> + ops; + if (!context_->initial_metadata_received_) { + ops.RecvInitialMetadata(context_); + } + ::grpc::Status status; + ops.ClientRecvStatus(context_, &status); + call_.PerformOps(&ops); + GPR_CODEGEN_ASSERT(cq_.Pluck(&ops)); + return status; + } + + private: + friend class internal::ClientReaderWriterFactory; + + ::grpc_impl::ClientContext* context_; + ::grpc_impl::CompletionQueue cq_; + ::grpc::internal::Call call_; + + /// Block to create a stream and write the initial metadata and \a request + /// out. Note that \a context will be used to fill in custom initial metadata + /// used to send to the server when starting the call. + ClientReaderWriter(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context) + : context_(context), + cq_(grpc_completion_queue_attributes{ + GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, + nullptr}), // Pluckable cq + call_(channel->CreateCall(method, context, &cq_)) { + if (!context_->initial_metadata_corked_) { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + ops; + ops.SendInitialMetadata(&context->send_initial_metadata_, + context->initial_metadata_flags()); + call_.PerformOps(&ops); + cq_.Pluck(&ops); + } + } +}; + +/// Server-side interface for streaming reads of message of type \a R. +template +class ServerReaderInterface : public internal::ServerStreamingInterface, + public internal::ReaderInterface {}; + +/// Synchronous (blocking) server-side API for doing client-streaming RPCs, +/// where the incoming message stream coming from the client has messages of +/// type \a R. +template +class ServerReader final : public ServerReaderInterface { + public: + /// See the \a ServerStreamingInterface.SendInitialMetadata method + /// for semantics. Note that initial metadata will be affected by the + /// \a ServerContext associated with this call. + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + ops; + ops.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ops.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_->PerformOps(&ops); + call_->cq()->Pluck(&ops); + } + + bool NextMessageSize(uint32_t* sz) override { + *sz = call_->max_receive_message_size(); + return true; + } + + bool Read(R* msg) override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage> ops; + ops.RecvMessage(msg); + call_->PerformOps(&ops); + return call_->cq()->Pluck(&ops) && ops.got_message; + } + + private: + ::grpc::internal::Call* const call_; + ServerContext* const ctx_; + + template + friend class ::grpc::internal::ClientStreamingHandler; + + ServerReader(::grpc::internal::Call* call, ::grpc_impl::ServerContext* ctx) + : call_(call), ctx_(ctx) {} +}; + +/// Server-side interface for streaming writes of message of type \a W. +template +class ServerWriterInterface : public internal::ServerStreamingInterface, + public internal::WriterInterface {}; + +/// Synchronous (blocking) server-side API for doing for doing a +/// server-streaming RPCs, where the outgoing message stream coming from the +/// server has messages of type \a W. +template +class ServerWriter final : public ServerWriterInterface { + public: + /// See the \a ServerStreamingInterface.SendInitialMetadata method + /// for semantics. + /// Note that initial metadata will be affected by the + /// \a ServerContext associated with this call. + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + ops; + ops.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ops.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_->PerformOps(&ops); + call_->cq()->Pluck(&ops); + } + + /// See the \a WriterInterface.Write method for semantics. + /// + /// Side effect: + /// Also sends initial metadata if not already sent (using the + /// \a ClientContext associated with this call to fill in values). + using internal::WriterInterface::Write; + bool Write(const W& msg, ::grpc::WriteOptions options) override { + if (options.is_last_message()) { + options.set_buffer_hint(); + } + + if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) { + return false; + } + if (!ctx_->sent_initial_metadata_) { + ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ctx_->pending_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + call_->PerformOps(&ctx_->pending_ops_); + // if this is the last message we defer the pluck until AFTER we start + // the trailing md op. This prevents hangs. See + // https://github.com/grpc/grpc/issues/11546 + if (options.is_last_message()) { + ctx_->has_pending_ops_ = true; + return true; + } + ctx_->has_pending_ops_ = false; + return call_->cq()->Pluck(&ctx_->pending_ops_); + } + + private: + ::grpc::internal::Call* const call_; + ::grpc_impl::ServerContext* const ctx_; + + template + friend class ::grpc::internal::ServerStreamingHandler; + + ServerWriter(::grpc::internal::Call* call, ::grpc_impl::ServerContext* ctx) + : call_(call), ctx_(ctx) {} +}; + +/// Server-side interface for bi-directional streaming. +template +class ServerReaderWriterInterface : public internal::ServerStreamingInterface, + public internal::WriterInterface, + public internal::ReaderInterface {}; + +/// Actual implementation of bi-directional streaming +namespace internal { +template +class ServerReaderWriterBody final { + public: + ServerReaderWriterBody(grpc::internal::Call* call, + ::grpc_impl::ServerContext* ctx) + : call_(call), ctx_(ctx) {} + + void SendInitialMetadata() { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + grpc::internal::CallOpSet ops; + ops.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ops.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_->PerformOps(&ops); + call_->cq()->Pluck(&ops); + } + + bool NextMessageSize(uint32_t* sz) { + *sz = call_->max_receive_message_size(); + return true; + } + + bool Read(R* msg) { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage> ops; + ops.RecvMessage(msg); + call_->PerformOps(&ops); + return call_->cq()->Pluck(&ops) && ops.got_message; + } + + bool Write(const W& msg, ::grpc::WriteOptions options) { + if (options.is_last_message()) { + options.set_buffer_hint(); + } + if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) { + return false; + } + if (!ctx_->sent_initial_metadata_) { + ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ctx_->pending_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + call_->PerformOps(&ctx_->pending_ops_); + // if this is the last message we defer the pluck until AFTER we start + // the trailing md op. This prevents hangs. See + // https://github.com/grpc/grpc/issues/11546 + if (options.is_last_message()) { + ctx_->has_pending_ops_ = true; + return true; + } + ctx_->has_pending_ops_ = false; + return call_->cq()->Pluck(&ctx_->pending_ops_); + } + + private: + grpc::internal::Call* const call_; + ::grpc_impl::ServerContext* const ctx_; +}; + +} // namespace internal + +/// Synchronous (blocking) server-side API for a bidirectional +/// streaming call, where the incoming message stream coming from the client has +/// messages of type \a R, and the outgoing message streaming coming from +/// the server has messages of type \a W. +template +class ServerReaderWriter final : public ServerReaderWriterInterface { + public: + /// See the \a ServerStreamingInterface.SendInitialMetadata method + /// for semantics. Note that initial metadata will be affected by the + /// \a ServerContext associated with this call. + void SendInitialMetadata() override { body_.SendInitialMetadata(); } + + bool NextMessageSize(uint32_t* sz) override { + return body_.NextMessageSize(sz); + } + + bool Read(R* msg) override { return body_.Read(msg); } + + /// See the \a WriterInterface.Write(const W& msg, WriteOptions options) + /// method for semantics. + /// Side effect: + /// Also sends initial metadata if not already sent (using the \a + /// ServerContext associated with this call). + using internal::WriterInterface::Write; + bool Write(const W& msg, ::grpc::WriteOptions options) override { + return body_.Write(msg, options); + } + + private: + internal::ServerReaderWriterBody body_; + + friend class ::grpc::internal::TemplatedBidiStreamingHandler< + ServerReaderWriter, false>; + ServerReaderWriter(::grpc::internal::Call* call, + ::grpc_impl::ServerContext* ctx) + : body_(call, ctx) {} +}; + +/// A class to represent a flow-controlled unary call. This is something +/// of a hybrid between conventional unary and streaming. This is invoked +/// through a unary call on the client side, but the server responds to it +/// as though it were a single-ping-pong streaming call. The server can use +/// the \a NextMessageSize method to determine an upper-bound on the size of +/// the message. A key difference relative to streaming: ServerUnaryStreamer +/// must have exactly 1 Read and exactly 1 Write, in that order, to function +/// correctly. Otherwise, the RPC is in error. +template +class ServerUnaryStreamer final + : public ServerReaderWriterInterface { + public: + /// Block to send initial metadata to client. + /// Implicit input parameter: + /// - the \a ServerContext associated with this call will be used for + /// sending initial metadata. + void SendInitialMetadata() override { body_.SendInitialMetadata(); } + + /// Get an upper bound on the request message size from the client. + bool NextMessageSize(uint32_t* sz) override { + return body_.NextMessageSize(sz); + } + + /// Read a message of type \a R into \a msg. Completion will be notified by \a + /// tag on the associated completion queue. + /// This is thread-safe with respect to \a Write or \a WritesDone methods. It + /// should not be called concurrently with other streaming APIs + /// on the same stream. It is not meaningful to call it concurrently + /// with another \a ReaderInterface::Read on the same stream since reads on + /// the same stream are delivered in order. + /// + /// \param[out] msg Where to eventually store the read message. + /// \param[in] tag The tag identifying the operation. + bool Read(RequestType* request) override { + if (read_done_) { + return false; + } + read_done_ = true; + return body_.Read(request); + } + + /// Block to write \a msg to the stream with WriteOptions \a options. + /// This is thread-safe with respect to \a ReaderInterface::Read + /// + /// \param msg The message to be written to the stream. + /// \param options The WriteOptions affecting the write operation. + /// + /// \return \a true on success, \a false when the stream has been closed. + using internal::WriterInterface::Write; + bool Write(const ResponseType& response, + ::grpc::WriteOptions options) override { + if (write_done_ || !read_done_) { + return false; + } + write_done_ = true; + return body_.Write(response, options); + } + + private: + internal::ServerReaderWriterBody body_; + bool read_done_; + bool write_done_; + + friend class ::grpc::internal::TemplatedBidiStreamingHandler< + ServerUnaryStreamer, true>; + ServerUnaryStreamer(::grpc::internal::Call* call, + ::grpc_impl::ServerContext* ctx) + : body_(call, ctx), read_done_(false), write_done_(false) {} +}; + +/// A class to represent a flow-controlled server-side streaming call. +/// This is something of a hybrid between server-side and bidi streaming. +/// This is invoked through a server-side streaming call on the client side, +/// but the server responds to it as though it were a bidi streaming call that +/// must first have exactly 1 Read and then any number of Writes. +template +class ServerSplitStreamer final + : public ServerReaderWriterInterface { + public: + /// Block to send initial metadata to client. + /// Implicit input parameter: + /// - the \a ServerContext associated with this call will be used for + /// sending initial metadata. + void SendInitialMetadata() override { body_.SendInitialMetadata(); } + + /// Get an upper bound on the request message size from the client. + bool NextMessageSize(uint32_t* sz) override { + return body_.NextMessageSize(sz); + } + + /// Read a message of type \a R into \a msg. Completion will be notified by \a + /// tag on the associated completion queue. + /// This is thread-safe with respect to \a Write or \a WritesDone methods. It + /// should not be called concurrently with other streaming APIs + /// on the same stream. It is not meaningful to call it concurrently + /// with another \a ReaderInterface::Read on the same stream since reads on + /// the same stream are delivered in order. + /// + /// \param[out] msg Where to eventually store the read message. + /// \param[in] tag The tag identifying the operation. + bool Read(RequestType* request) override { + if (read_done_) { + return false; + } + read_done_ = true; + return body_.Read(request); + } + + /// Block to write \a msg to the stream with WriteOptions \a options. + /// This is thread-safe with respect to \a ReaderInterface::Read + /// + /// \param msg The message to be written to the stream. + /// \param options The WriteOptions affecting the write operation. + /// + /// \return \a true on success, \a false when the stream has been closed. + using internal::WriterInterface::Write; + bool Write(const ResponseType& response, + ::grpc::WriteOptions options) override { + return read_done_ && body_.Write(response, options); + } + + private: + internal::ServerReaderWriterBody body_; + bool read_done_; + + friend class ::grpc::internal::TemplatedBidiStreamingHandler< + ServerSplitStreamer, false>; + ServerSplitStreamer(::grpc::internal::Call* call, + ::grpc_impl::ServerContext* ctx) + : body_(call, ctx), read_done_(false) {} +}; + +} // namespace grpc_impl + +#endif // GRPCPP_IMPL_CODEGEN_SYNC_STREAM_IMPL_H diff --git a/include/grpcpp/support/async_stream_impl.h b/include/grpcpp/support/async_stream_impl.h new file mode 100644 index 00000000000..cff700d3fa9 --- /dev/null +++ b/include/grpcpp/support/async_stream_impl.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_ASYNC_STREAM_IMPL_H +#define GRPCPP_SUPPORT_ASYNC_STREAM_IMPL_H + +#include + +#endif // GRPCPP_SUPPORT_ASYNC_STREAM_IMPL_H diff --git a/include/grpcpp/support/async_unary_call_impl.h b/include/grpcpp/support/async_unary_call_impl.h new file mode 100644 index 00000000000..488fe87515a --- /dev/null +++ b/include/grpcpp/support/async_unary_call_impl.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_ASYNC_UNARY_CALL_IMPL_H +#define GRPCPP_SUPPORT_ASYNC_UNARY_CALL_IMPL_H + +#include + +#endif // GRPCPP_SUPPORT_ASYNC_UNARY_CALL_IMPL_H diff --git a/include/grpcpp/support/client_callback_impl.h b/include/grpcpp/support/client_callback_impl.h new file mode 100644 index 00000000000..ed8df412496 --- /dev/null +++ b/include/grpcpp/support/client_callback_impl.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_CLIENT_CALLBACK_IMPL_H +#define GRPCPP_SUPPORT_CLIENT_CALLBACK_IMPL_H + +#include + +#endif // GRPCPP_SUPPORT_CLIENT_CALLBACK_IMPL_H diff --git a/include/grpcpp/support/server_callback_impl.h b/include/grpcpp/support/server_callback_impl.h new file mode 100644 index 00000000000..a91c8141dd8 --- /dev/null +++ b/include/grpcpp/support/server_callback_impl.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_SERVER_CALLBACK_IMPL_H +#define GRPCPP_SUPPORT_SERVER_CALLBACK_IMPL_H + +#include + +#endif // GRPCPP_SUPPORT_SERVER_CALLBACK_IMPL_H diff --git a/include/grpcpp/support/sync_stream_impl.h b/include/grpcpp/support/sync_stream_impl.h new file mode 100644 index 00000000000..a00e425acfc --- /dev/null +++ b/include/grpcpp/support/sync_stream_impl.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_SYNC_STREAM_IMPL_H +#define GRPCPP_SUPPORT_SYNC_STREAM_IMPL_H + +#include + +#endif // GRPCPP_SUPPORT_SYNC_STREAM_IMPL_H diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index 358efe9fd79..044647d9a81 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -143,6 +143,7 @@ grpc::string GetHeaderIncludes(grpc_generator::File* file, "grpcpp/impl/codegen/async_unary_call.h", "grpcpp/impl/codegen/client_callback.h", "grpcpp/impl/codegen/client_context.h", + "grpcpp/impl/codegen/completion_queue.h", "grpcpp/impl/codegen/method_handler_impl.h", "grpcpp/impl/codegen/proto_utils.h", "grpcpp/impl/codegen/rpc_method.h", @@ -946,11 +947,12 @@ void PrintHeaderServerCallbackMethodsHelper( " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); - printer->Print(*vars, - "virtual ::grpc::experimental::ServerReadReactor< " - "$RealRequest$, $RealResponse$>* $Method$() {\n" - " return new ::grpc::internal::UnimplementedReadReactor<\n" - " $RealRequest$, $RealResponse$>;}\n"); + printer->Print( + *vars, + "virtual ::grpc::experimental::ServerReadReactor< " + "$RealRequest$, $RealResponse$>* $Method$() {\n" + " return new ::grpc_impl::internal::UnimplementedReadReactor<\n" + " $RealRequest$, $RealResponse$>;}\n"); } else if (ServerOnlyStreaming(method)) { printer->Print( *vars, @@ -962,11 +964,12 @@ void PrintHeaderServerCallbackMethodsHelper( " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); - printer->Print(*vars, - "virtual ::grpc::experimental::ServerWriteReactor< " - "$RealRequest$, $RealResponse$>* $Method$() {\n" - " return new ::grpc::internal::UnimplementedWriteReactor<\n" - " $RealRequest$, $RealResponse$>;}\n"); + printer->Print( + *vars, + "virtual ::grpc::experimental::ServerWriteReactor< " + "$RealRequest$, $RealResponse$>* $Method$() {\n" + " return new ::grpc_impl::internal::UnimplementedWriteReactor<\n" + " $RealRequest$, $RealResponse$>;}\n"); } else if (method->BidiStreaming()) { printer->Print( *vars, @@ -978,11 +981,12 @@ void PrintHeaderServerCallbackMethodsHelper( " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); - printer->Print(*vars, - "virtual ::grpc::experimental::ServerBidiReactor< " - "$RealRequest$, $RealResponse$>* $Method$() {\n" - " return new ::grpc::internal::UnimplementedBidiReactor<\n" - " $RealRequest$, $RealResponse$>;}\n"); + printer->Print( + *vars, + "virtual ::grpc::experimental::ServerBidiReactor< " + "$RealRequest$, $RealResponse$>* $Method$() {\n" + " return new ::grpc_impl::internal::UnimplementedBidiReactor<\n" + " $RealRequest$, $RealResponse$>;}\n"); } } @@ -1010,7 +1014,7 @@ void PrintHeaderServerMethodCallback( printer->Print( *vars, " ::grpc::Service::experimental().MarkMethodCallback($Idx$,\n" - " new ::grpc::internal::CallbackUnaryHandler< " + " new ::grpc_impl::internal::CallbackUnaryHandler< " "$RealRequest$, $RealResponse$>(\n" " [this](::grpc::ServerContext* context,\n" " const $RealRequest$* request,\n" @@ -1024,7 +1028,7 @@ void PrintHeaderServerMethodCallback( "void SetMessageAllocatorFor_$Method$(\n" " ::grpc::experimental::MessageAllocator< " "$RealRequest$, $RealResponse$>* allocator) {\n" - " static_cast<::grpc::internal::CallbackUnaryHandler< " + " static_cast<::grpc_impl::internal::CallbackUnaryHandler< " "$RealRequest$, $RealResponse$>*>(\n" " ::grpc::Service::experimental().GetHandler($Idx$))\n" " ->SetMessageAllocator(allocator);\n"); @@ -1032,21 +1036,21 @@ void PrintHeaderServerMethodCallback( printer->Print( *vars, " ::grpc::Service::experimental().MarkMethodCallback($Idx$,\n" - " new ::grpc::internal::CallbackClientStreamingHandler< " + " new ::grpc_impl::internal::CallbackClientStreamingHandler< " "$RealRequest$, $RealResponse$>(\n" " [this] { return this->$Method$(); }));\n"); } else if (ServerOnlyStreaming(method)) { printer->Print( *vars, " ::grpc::Service::experimental().MarkMethodCallback($Idx$,\n" - " new ::grpc::internal::CallbackServerStreamingHandler< " + " new ::grpc_impl::internal::CallbackServerStreamingHandler< " "$RealRequest$, $RealResponse$>(\n" " [this] { return this->$Method$(); }));\n"); } else if (method->BidiStreaming()) { printer->Print( *vars, " ::grpc::Service::experimental().MarkMethodCallback($Idx$,\n" - " new ::grpc::internal::CallbackBidiHandler< " + " new ::grpc_impl::internal::CallbackBidiHandler< " "$RealRequest$, $RealResponse$>(\n" " [this] { return this->$Method$(); }));\n"); } @@ -1084,7 +1088,7 @@ void PrintHeaderServerMethodRawCallback( printer->Print( *vars, " ::grpc::Service::experimental().MarkMethodRawCallback($Idx$,\n" - " new ::grpc::internal::CallbackUnaryHandler< " + " new ::grpc_impl::internal::CallbackUnaryHandler< " "$RealRequest$, $RealResponse$>(\n" " [this](::grpc::ServerContext* context,\n" " const $RealRequest$* request,\n" @@ -1098,21 +1102,21 @@ void PrintHeaderServerMethodRawCallback( printer->Print( *vars, " ::grpc::Service::experimental().MarkMethodRawCallback($Idx$,\n" - " new ::grpc::internal::CallbackClientStreamingHandler< " + " new ::grpc_impl::internal::CallbackClientStreamingHandler< " "$RealRequest$, $RealResponse$>(\n" " [this] { return this->$Method$(); }));\n"); } else if (ServerOnlyStreaming(method)) { printer->Print( *vars, " ::grpc::Service::experimental().MarkMethodRawCallback($Idx$,\n" - " new ::grpc::internal::CallbackServerStreamingHandler< " + " new ::grpc_impl::internal::CallbackServerStreamingHandler< " "$RealRequest$, $RealResponse$>(\n" " [this] { return this->$Method$(); }));\n"); } else if (method->BidiStreaming()) { printer->Print( *vars, " ::grpc::Service::experimental().MarkMethodRawCallback($Idx$,\n" - " new ::grpc::internal::CallbackBidiHandler< " + " new ::grpc_impl::internal::CallbackBidiHandler< " "$RealRequest$, $RealResponse$>(\n" " [this] { return this->$Method$(); }));\n"); } @@ -1705,7 +1709,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "const $Request$* request, $Response$* response, " "std::function f) {\n"); printer->Print(*vars, - " ::grpc::internal::CallbackUnaryCall" + " ::grpc_impl::internal::CallbackUnaryCall" "(stub_->channel_.get(), stub_->rpcmethod_$Method$_, " "context, request, response, std::move(f));\n}\n\n"); @@ -1715,7 +1719,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "const ::grpc::ByteBuffer* request, $Response$* response, " "std::function f) {\n"); printer->Print(*vars, - " ::grpc::internal::CallbackUnaryCall" + " ::grpc_impl::internal::CallbackUnaryCall" "(stub_->channel_.get(), stub_->rpcmethod_$Method$_, " "context, request, response, std::move(f));\n}\n\n"); @@ -1725,7 +1729,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "const $Request$* request, $Response$* response, " "::grpc::experimental::ClientUnaryReactor* reactor) {\n"); printer->Print(*vars, - " ::grpc::internal::ClientCallbackUnaryFactory::Create" + " ::grpc_impl::internal::ClientCallbackUnaryFactory::Create" "(stub_->channel_.get(), stub_->rpcmethod_$Method$_, " "context, request, response, reactor);\n}\n\n"); @@ -1735,7 +1739,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "const ::grpc::ByteBuffer* request, $Response$* response, " "::grpc::experimental::ClientUnaryReactor* reactor) {\n"); printer->Print(*vars, - " ::grpc::internal::ClientCallbackUnaryFactory::Create" + " ::grpc_impl::internal::ClientCallbackUnaryFactory::Create" "(stub_->channel_.get(), stub_->rpcmethod_$Method$_, " "context, request, response, reactor);\n}\n\n"); @@ -1751,7 +1755,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, printer->Print( *vars, " return " - "::grpc::internal::ClientAsyncResponseReaderFactory< $Response$>" + "::grpc_impl::internal::ClientAsyncResponseReaderFactory< $Response$>" "::Create(channel_.get(), cq, " "rpcmethod_$Method$_, " "context, request, $AsyncStart$);\n" @@ -1762,13 +1766,13 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "::grpc::ClientWriter< $Request$>* " "$ns$$Service$::Stub::$Method$Raw(" "::grpc::ClientContext* context, $Response$* response) {\n"); - printer->Print( - *vars, - " return ::grpc::internal::ClientWriterFactory< $Request$>::Create(" - "channel_.get(), " - "rpcmethod_$Method$_, " - "context, response);\n" - "}\n\n"); + printer->Print(*vars, + " return ::grpc_impl::internal::ClientWriterFactory< " + "$Request$>::Create(" + "channel_.get(), " + "rpcmethod_$Method$_, " + "context, response);\n" + "}\n\n"); printer->Print( *vars, @@ -1777,7 +1781,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "$Response$* response, " "::grpc::experimental::ClientWriteReactor< $Request$>* reactor) {\n"); printer->Print(*vars, - " ::grpc::internal::ClientCallbackWriterFactory< " + " ::grpc_impl::internal::ClientCallbackWriterFactory< " "$Request$>::Create(" "stub_->channel_.get(), " "stub_->rpcmethod_$Method$_, " @@ -1796,7 +1800,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); printer->Print( *vars, - " return ::grpc::internal::ClientAsyncWriterFactory< $Request$>" + " return ::grpc_impl::internal::ClientAsyncWriterFactory< $Request$>" "::Create(channel_.get(), cq, " "rpcmethod_$Method$_, " "context, response, $AsyncStart$$AsyncCreateArgs$);\n" @@ -1808,13 +1812,13 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "::grpc::ClientReader< $Response$>* " "$ns$$Service$::Stub::$Method$Raw(" "::grpc::ClientContext* context, const $Request$& request) {\n"); - printer->Print( - *vars, - " return ::grpc::internal::ClientReaderFactory< $Response$>::Create(" - "channel_.get(), " - "rpcmethod_$Method$_, " - "context, request);\n" - "}\n\n"); + printer->Print(*vars, + " return ::grpc_impl::internal::ClientReaderFactory< " + "$Response$>::Create(" + "channel_.get(), " + "rpcmethod_$Method$_, " + "context, request);\n" + "}\n\n"); printer->Print( *vars, @@ -1823,7 +1827,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "$Request$* request, " "::grpc::experimental::ClientReadReactor< $Response$>* reactor) {\n"); printer->Print(*vars, - " ::grpc::internal::ClientCallbackReaderFactory< " + " ::grpc_impl::internal::ClientCallbackReaderFactory< " "$Response$>::Create(" "stub_->channel_.get(), " "stub_->rpcmethod_$Method$_, " @@ -1843,7 +1847,8 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); printer->Print( *vars, - " return ::grpc::internal::ClientAsyncReaderFactory< $Response$>" + " return ::grpc_impl::internal::ClientAsyncReaderFactory< " + "$Response$>" "::Create(channel_.get(), cq, " "rpcmethod_$Method$_, " "context, request, $AsyncStart$$AsyncCreateArgs$);\n" @@ -1855,7 +1860,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "::grpc::ClientReaderWriter< $Request$, $Response$>* " "$ns$$Service$::Stub::$Method$Raw(::grpc::ClientContext* context) {\n"); printer->Print(*vars, - " return ::grpc::internal::ClientReaderWriterFactory< " + " return ::grpc_impl::internal::ClientReaderWriterFactory< " "$Request$, $Response$>::Create(" "channel_.get(), " "rpcmethod_$Method$_, " @@ -1868,13 +1873,14 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "ClientContext* context, " "::grpc::experimental::ClientBidiReactor< $Request$,$Response$>* " "reactor) {\n"); - printer->Print(*vars, - " ::grpc::internal::ClientCallbackReaderWriterFactory< " - "$Request$,$Response$>::Create(" - "stub_->channel_.get(), " - "stub_->rpcmethod_$Method$_, " - "context, reactor);\n" - "}\n\n"); + printer->Print( + *vars, + " ::grpc_impl::internal::ClientCallbackReaderWriterFactory< " + "$Request$,$Response$>::Create(" + "stub_->channel_.get(), " + "stub_->rpcmethod_$Method$_, " + "context, reactor);\n" + "}\n\n"); for (auto async_prefix : async_prefixes) { (*vars)["AsyncPrefix"] = async_prefix.prefix; @@ -1888,7 +1894,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); printer->Print(*vars, " return " - "::grpc::internal::ClientAsyncReaderWriterFactory< " + "::grpc_impl::internal::ClientAsyncReaderWriterFactory< " "$Request$, $Response$>::Create(" "channel_.get(), cq, " "rpcmethod_$Method$_, " @@ -2279,7 +2285,8 @@ void PrintMockClientMethods(grpc_generator::Printer* printer, printer->Print( *vars, "MOCK_METHOD$MockArgs$($AsyncPrefix$$Method$Raw, " - "::grpc::ClientAsyncReaderWriterInterface<$Request$, $Response$>*" + "::grpc::ClientAsyncReaderWriterInterface<$Request$, " + "$Response$>*" "(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq" "$AsyncMethodParams$));\n"); } diff --git a/src/cpp/client/generic_stub.cc b/src/cpp/client/generic_stub.cc index 41631c794f2..e7d3df7a497 100644 --- a/src/cpp/client/generic_stub.cc +++ b/src/cpp/client/generic_stub.cc @@ -27,11 +27,10 @@ namespace grpc_impl { namespace { std::unique_ptr CallInternal( grpc::ChannelInterface* channel, grpc::ClientContext* context, - const grpc::string& method, grpc::CompletionQueue* cq, bool start, - void* tag) { + const grpc::string& method, CompletionQueue* cq, bool start, void* tag) { return std::unique_ptr( - grpc::internal::ClientAsyncReaderWriterFactory:: + internal::ClientAsyncReaderWriterFactory:: Create(channel, cq, grpc::internal::RpcMethod( method.c_str(), grpc::internal::RpcMethod::BIDI_STREAMING), @@ -43,14 +42,14 @@ std::unique_ptr CallInternal( // begin a call to a named method std::unique_ptr GenericStub::Call( grpc::ClientContext* context, const grpc::string& method, - grpc::CompletionQueue* cq, void* tag) { + CompletionQueue* cq, void* tag) { return CallInternal(channel_.get(), context, method, cq, true, tag); } // setup a call to a named method std::unique_ptr GenericStub::PrepareCall( grpc::ClientContext* context, const grpc::string& method, - grpc::CompletionQueue* cq) { + CompletionQueue* cq) { return CallInternal(channel_.get(), context, method, cq, false, nullptr); } @@ -59,21 +58,20 @@ std::unique_ptr GenericStub::PrepareUnaryCall(grpc::ClientContext* context, const grpc::string& method, const grpc::ByteBuffer& request, - grpc::CompletionQueue* cq) { + CompletionQueue* cq) { return std::unique_ptr( - grpc::internal::ClientAsyncResponseReaderFactory< - grpc::ByteBuffer>::Create(channel_.get(), cq, - grpc::internal::RpcMethod( - method.c_str(), - grpc::internal::RpcMethod::NORMAL_RPC), - context, request, false)); + internal::ClientAsyncResponseReaderFactory::Create( + channel_.get(), cq, + grpc::internal::RpcMethod(method.c_str(), + grpc::internal::RpcMethod::NORMAL_RPC), + context, request, false)); } void GenericStub::experimental_type::UnaryCall( grpc::ClientContext* context, const grpc::string& method, const grpc::ByteBuffer* request, grpc::ByteBuffer* response, std::function on_completion) { - grpc::internal::CallbackUnaryCall( + internal::CallbackUnaryCall( stub_->channel_.get(), grpc::internal::RpcMethod(method.c_str(), grpc::internal::RpcMethod::NORMAL_RPC), @@ -82,9 +80,9 @@ void GenericStub::experimental_type::UnaryCall( void GenericStub::experimental_type::PrepareBidiStreamingCall( grpc::ClientContext* context, const grpc::string& method, - grpc::experimental::ClientBidiReactor* + experimental::ClientBidiReactor* reactor) { - grpc::internal::ClientCallbackReaderWriterFactory< + internal::ClientCallbackReaderWriterFactory< grpc::ByteBuffer, grpc::ByteBuffer>::Create(stub_->channel_.get(), grpc::internal::RpcMethod( diff --git a/src/cpp/server/async_generic_service.cc b/src/cpp/server/async_generic_service.cc index 30613768295..556447a7f40 100644 --- a/src/cpp/server/async_generic_service.cc +++ b/src/cpp/server/async_generic_service.cc @@ -24,8 +24,8 @@ namespace grpc { void AsyncGenericService::RequestCall( GenericServerContext* ctx, GenericServerAsyncReaderWriter* reader_writer, - CompletionQueue* call_cq, ServerCompletionQueue* notification_cq, - void* tag) { + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, void* tag) { server_->RequestAsyncGenericCall(ctx, reader_writer, call_cq, notification_cq, tag); } diff --git a/src/cpp/server/health/default_health_check_service.h b/src/cpp/server/health/default_health_check_service.h index 4b926efdfe8..14a54d53ee0 100644 --- a/src/cpp/server/health/default_health_check_service.h +++ b/src/cpp/server/health/default_health_check_service.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index 1ba9ae1c9dc..1d68c2bdaea 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -69,14 +69,14 @@ ServerBuilder::~ServerBuilder() { } } -std::unique_ptr ServerBuilder::AddCompletionQueue( +std::unique_ptr ServerBuilder::AddCompletionQueue( bool is_frequently_polled) { - grpc::ServerCompletionQueue* cq = new grpc::ServerCompletionQueue( + ServerCompletionQueue* cq = new ServerCompletionQueue( GRPC_CQ_NEXT, is_frequently_polled ? GRPC_CQ_DEFAULT_POLLING : GRPC_CQ_NON_LISTENING, nullptr); cqs_.push_back(cq); - return std::unique_ptr(cq); + return std::unique_ptr(cq); } ServerBuilder& ServerBuilder::RegisterService(grpc::Service* service) { @@ -266,10 +266,9 @@ std::unique_ptr ServerBuilder::BuildAndStart() { // This is different from the completion queues added to the server via // ServerBuilder's AddCompletionQueue() method (those completion queues // are in 'cqs_' member variable of ServerBuilder object) - std::shared_ptr>> - sync_server_cqs( - std::make_shared< - std::vector>>()); + std::shared_ptr>> + sync_server_cqs(std::make_shared< + std::vector>>()); bool has_frequently_polled_cqs = false; for (auto it = cqs_.begin(); it != cqs_.end(); ++it) { @@ -298,7 +297,7 @@ std::unique_ptr ServerBuilder::BuildAndStart() { // Create completion queues to listen to incoming rpc requests for (int i = 0; i < sync_server_settings_.num_cqs; i++) { sync_server_cqs->emplace_back( - new grpc::ServerCompletionQueue(GRPC_CQ_NEXT, polling_type, nullptr)); + new ServerCompletionQueue(GRPC_CQ_NEXT, polling_type, nullptr)); } } diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc index ba834237ae9..1e27fad3988 100644 --- a/src/cpp/server/server_context.cc +++ b/src/cpp/server/server_context.cc @@ -45,8 +45,7 @@ class ServerContext::CompletionOp final public: // initial refs: one in the server context, one in the cq // must ref the call before calling constructor and after deleting this - CompletionOp(::grpc::internal::Call* call, - ::grpc::internal::ServerReactor* reactor) + CompletionOp(::grpc::internal::Call* call, internal::ServerReactor* reactor) : call_(*call), reactor_(reactor), has_tag_(false), @@ -152,7 +151,7 @@ class ServerContext::CompletionOp final } ::grpc::internal::Call call_; - ::grpc::internal::ServerReactor* const reactor_; + internal::ServerReactor* const reactor_; bool has_tag_; void* tag_; void* core_cq_tag_; @@ -294,9 +293,9 @@ void ServerContext::Clear() { } } -void ServerContext::BeginCompletionOp( - ::grpc::internal::Call* call, std::function callback, - ::grpc::internal::ServerReactor* reactor) { +void ServerContext::BeginCompletionOp(::grpc::internal::Call* call, + std::function callback, + internal::ServerReactor* reactor) { GPR_ASSERT(!completion_op_); if (rpc_info_) { rpc_info_->Ref(); diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index 035955023b8..34fb5bfb53f 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -336,7 +337,7 @@ class ServiceA final { public: ExperimentalWithCallbackMethod_MethodA1() { ::grpc::Service::experimental().MarkMethodCallback(0, - new ::grpc::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>( + new ::grpc_impl::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>( [this](::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, @@ -346,7 +347,7 @@ class ServiceA final { } void SetMessageAllocatorFor_MethodA1( ::grpc::experimental::MessageAllocator< ::grpc::testing::Request, ::grpc::testing::Response>* allocator) { - static_cast<::grpc::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>*>( + static_cast<::grpc_impl::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>*>( ::grpc::Service::experimental().GetHandler(0)) ->SetMessageAllocator(allocator); } @@ -367,7 +368,7 @@ class ServiceA final { public: ExperimentalWithCallbackMethod_MethodA2() { ::grpc::Service::experimental().MarkMethodCallback(1, - new ::grpc::internal::CallbackClientStreamingHandler< ::grpc::testing::Request, ::grpc::testing::Response>( + new ::grpc_impl::internal::CallbackClientStreamingHandler< ::grpc::testing::Request, ::grpc::testing::Response>( [this] { return this->MethodA2(); })); } ~ExperimentalWithCallbackMethod_MethodA2() override { @@ -379,7 +380,7 @@ class ServiceA final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } virtual ::grpc::experimental::ServerReadReactor< ::grpc::testing::Request, ::grpc::testing::Response>* MethodA2() { - return new ::grpc::internal::UnimplementedReadReactor< + return new ::grpc_impl::internal::UnimplementedReadReactor< ::grpc::testing::Request, ::grpc::testing::Response>;} }; template @@ -389,7 +390,7 @@ class ServiceA final { public: ExperimentalWithCallbackMethod_MethodA3() { ::grpc::Service::experimental().MarkMethodCallback(2, - new ::grpc::internal::CallbackServerStreamingHandler< ::grpc::testing::Request, ::grpc::testing::Response>( + new ::grpc_impl::internal::CallbackServerStreamingHandler< ::grpc::testing::Request, ::grpc::testing::Response>( [this] { return this->MethodA3(); })); } ~ExperimentalWithCallbackMethod_MethodA3() override { @@ -401,7 +402,7 @@ class ServiceA final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } virtual ::grpc::experimental::ServerWriteReactor< ::grpc::testing::Request, ::grpc::testing::Response>* MethodA3() { - return new ::grpc::internal::UnimplementedWriteReactor< + return new ::grpc_impl::internal::UnimplementedWriteReactor< ::grpc::testing::Request, ::grpc::testing::Response>;} }; template @@ -411,7 +412,7 @@ class ServiceA final { public: ExperimentalWithCallbackMethod_MethodA4() { ::grpc::Service::experimental().MarkMethodCallback(3, - new ::grpc::internal::CallbackBidiHandler< ::grpc::testing::Request, ::grpc::testing::Response>( + new ::grpc_impl::internal::CallbackBidiHandler< ::grpc::testing::Request, ::grpc::testing::Response>( [this] { return this->MethodA4(); })); } ~ExperimentalWithCallbackMethod_MethodA4() override { @@ -423,7 +424,7 @@ class ServiceA final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } virtual ::grpc::experimental::ServerBidiReactor< ::grpc::testing::Request, ::grpc::testing::Response>* MethodA4() { - return new ::grpc::internal::UnimplementedBidiReactor< + return new ::grpc_impl::internal::UnimplementedBidiReactor< ::grpc::testing::Request, ::grpc::testing::Response>;} }; typedef ExperimentalWithCallbackMethod_MethodA1 > > > ExperimentalCallbackService; @@ -582,7 +583,7 @@ class ServiceA final { public: ExperimentalWithRawCallbackMethod_MethodA1() { ::grpc::Service::experimental().MarkMethodRawCallback(0, - new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( + new ::grpc_impl::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this](::grpc::ServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response, @@ -607,7 +608,7 @@ class ServiceA final { public: ExperimentalWithRawCallbackMethod_MethodA2() { ::grpc::Service::experimental().MarkMethodRawCallback(1, - new ::grpc::internal::CallbackClientStreamingHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( + new ::grpc_impl::internal::CallbackClientStreamingHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this] { return this->MethodA2(); })); } ~ExperimentalWithRawCallbackMethod_MethodA2() override { @@ -619,7 +620,7 @@ class ServiceA final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } virtual ::grpc::experimental::ServerReadReactor< ::grpc::ByteBuffer, ::grpc::ByteBuffer>* MethodA2() { - return new ::grpc::internal::UnimplementedReadReactor< + return new ::grpc_impl::internal::UnimplementedReadReactor< ::grpc::ByteBuffer, ::grpc::ByteBuffer>;} }; template @@ -629,7 +630,7 @@ class ServiceA final { public: ExperimentalWithRawCallbackMethod_MethodA3() { ::grpc::Service::experimental().MarkMethodRawCallback(2, - new ::grpc::internal::CallbackServerStreamingHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( + new ::grpc_impl::internal::CallbackServerStreamingHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this] { return this->MethodA3(); })); } ~ExperimentalWithRawCallbackMethod_MethodA3() override { @@ -641,7 +642,7 @@ class ServiceA final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } virtual ::grpc::experimental::ServerWriteReactor< ::grpc::ByteBuffer, ::grpc::ByteBuffer>* MethodA3() { - return new ::grpc::internal::UnimplementedWriteReactor< + return new ::grpc_impl::internal::UnimplementedWriteReactor< ::grpc::ByteBuffer, ::grpc::ByteBuffer>;} }; template @@ -651,7 +652,7 @@ class ServiceA final { public: ExperimentalWithRawCallbackMethod_MethodA4() { ::grpc::Service::experimental().MarkMethodRawCallback(3, - new ::grpc::internal::CallbackBidiHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( + new ::grpc_impl::internal::CallbackBidiHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this] { return this->MethodA4(); })); } ~ExperimentalWithRawCallbackMethod_MethodA4() override { @@ -663,7 +664,7 @@ class ServiceA final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } virtual ::grpc::experimental::ServerBidiReactor< ::grpc::ByteBuffer, ::grpc::ByteBuffer>* MethodA4() { - return new ::grpc::internal::UnimplementedBidiReactor< + return new ::grpc_impl::internal::UnimplementedBidiReactor< ::grpc::ByteBuffer, ::grpc::ByteBuffer>;} }; template @@ -814,7 +815,7 @@ class ServiceB final { public: ExperimentalWithCallbackMethod_MethodB1() { ::grpc::Service::experimental().MarkMethodCallback(0, - new ::grpc::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>( + new ::grpc_impl::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>( [this](::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, @@ -824,7 +825,7 @@ class ServiceB final { } void SetMessageAllocatorFor_MethodB1( ::grpc::experimental::MessageAllocator< ::grpc::testing::Request, ::grpc::testing::Response>* allocator) { - static_cast<::grpc::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>*>( + static_cast<::grpc_impl::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>*>( ::grpc::Service::experimental().GetHandler(0)) ->SetMessageAllocator(allocator); } @@ -883,7 +884,7 @@ class ServiceB final { public: ExperimentalWithRawCallbackMethod_MethodB1() { ::grpc::Service::experimental().MarkMethodRawCallback(0, - new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( + new ::grpc_impl::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this](::grpc::ServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response, diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 501be844410..bdb36ae1a7b 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -947,7 +947,9 @@ include/grpcpp/impl/channel_argument_option.h \ include/grpcpp/impl/client_unary_call.h \ include/grpcpp/impl/codegen/async_generic_service.h \ include/grpcpp/impl/codegen/async_stream.h \ +include/grpcpp/impl/codegen/async_stream_impl.h \ include/grpcpp/impl/codegen/async_unary_call.h \ +include/grpcpp/impl/codegen/async_unary_call_impl.h \ include/grpcpp/impl/codegen/byte_buffer.h \ include/grpcpp/impl/codegen/call.h \ include/grpcpp/impl/codegen/call_hook.h \ @@ -956,6 +958,7 @@ include/grpcpp/impl/codegen/call_op_set_interface.h \ include/grpcpp/impl/codegen/callback_common.h \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ +include/grpcpp/impl/codegen/client_callback_impl.h \ include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ @@ -983,6 +986,7 @@ include/grpcpp/impl/codegen/rpc_service_method.h \ include/grpcpp/impl/codegen/security/auth_context.h \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ +include/grpcpp/impl/codegen/server_callback_impl.h \ include/grpcpp/impl/codegen/server_context.h \ include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ @@ -995,6 +999,7 @@ include/grpcpp/impl/codegen/string_ref.h \ include/grpcpp/impl/codegen/stub_options.h \ include/grpcpp/impl/codegen/sync.h \ include/grpcpp/impl/codegen/sync_stream.h \ +include/grpcpp/impl/codegen/sync_stream_impl.h \ include/grpcpp/impl/codegen/time.h \ include/grpcpp/impl/grpc_library.h \ include/grpcpp/impl/method_handler_impl.h \ @@ -1024,11 +1029,14 @@ include/grpcpp/server_impl.h \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ include/grpcpp/support/async_stream.h \ +include/grpcpp/support/async_stream_impl.h \ include/grpcpp/support/async_unary_call.h \ +include/grpcpp/support/async_unary_call_impl.h \ include/grpcpp/support/byte_buffer.h \ include/grpcpp/support/channel_arguments.h \ include/grpcpp/support/channel_arguments_impl.h \ include/grpcpp/support/client_callback.h \ +include/grpcpp/support/client_callback_impl.h \ include/grpcpp/support/client_interceptor.h \ include/grpcpp/support/config.h \ include/grpcpp/support/interceptor.h \ @@ -1036,6 +1044,7 @@ include/grpcpp/support/message_allocator.h \ include/grpcpp/support/proto_buffer_reader.h \ include/grpcpp/support/proto_buffer_writer.h \ include/grpcpp/support/server_callback.h \ +include/grpcpp/support/server_callback_impl.h \ include/grpcpp/support/server_interceptor.h \ include/grpcpp/support/slice.h \ include/grpcpp/support/status.h \ @@ -1043,6 +1052,7 @@ include/grpcpp/support/status_code_enum.h \ include/grpcpp/support/string_ref.h \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ +include/grpcpp/support/sync_stream_impl.h \ include/grpcpp/support/time.h \ include/grpcpp/support/validate_service_config.h diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 69ff7eb6098..57d6ca8b761 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -948,7 +948,9 @@ include/grpcpp/impl/channel_argument_option.h \ include/grpcpp/impl/client_unary_call.h \ include/grpcpp/impl/codegen/async_generic_service.h \ include/grpcpp/impl/codegen/async_stream.h \ +include/grpcpp/impl/codegen/async_stream_impl.h \ include/grpcpp/impl/codegen/async_unary_call.h \ +include/grpcpp/impl/codegen/async_unary_call_impl.h \ include/grpcpp/impl/codegen/byte_buffer.h \ include/grpcpp/impl/codegen/call.h \ include/grpcpp/impl/codegen/call_hook.h \ @@ -957,6 +959,7 @@ include/grpcpp/impl/codegen/call_op_set_interface.h \ include/grpcpp/impl/codegen/callback_common.h \ include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/client_callback.h \ +include/grpcpp/impl/codegen/client_callback_impl.h \ include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context_impl.h \ include/grpcpp/impl/codegen/client_interceptor.h \ @@ -985,6 +988,7 @@ include/grpcpp/impl/codegen/rpc_service_method.h \ include/grpcpp/impl/codegen/security/auth_context.h \ include/grpcpp/impl/codegen/serialization_traits.h \ include/grpcpp/impl/codegen/server_callback.h \ +include/grpcpp/impl/codegen/server_callback_impl.h \ include/grpcpp/impl/codegen/server_context.h \ include/grpcpp/impl/codegen/server_context_impl.h \ include/grpcpp/impl/codegen/server_interceptor.h \ @@ -997,6 +1001,7 @@ include/grpcpp/impl/codegen/string_ref.h \ include/grpcpp/impl/codegen/stub_options.h \ include/grpcpp/impl/codegen/sync.h \ include/grpcpp/impl/codegen/sync_stream.h \ +include/grpcpp/impl/codegen/sync_stream_impl.h \ include/grpcpp/impl/codegen/time.h \ include/grpcpp/impl/grpc_library.h \ include/grpcpp/impl/method_handler_impl.h \ @@ -1026,11 +1031,14 @@ include/grpcpp/server_impl.h \ include/grpcpp/server_posix.h \ include/grpcpp/server_posix_impl.h \ include/grpcpp/support/async_stream.h \ +include/grpcpp/support/async_stream_impl.h \ include/grpcpp/support/async_unary_call.h \ +include/grpcpp/support/async_unary_call_impl.h \ include/grpcpp/support/byte_buffer.h \ include/grpcpp/support/channel_arguments.h \ include/grpcpp/support/channel_arguments_impl.h \ include/grpcpp/support/client_callback.h \ +include/grpcpp/support/client_callback_impl.h \ include/grpcpp/support/client_interceptor.h \ include/grpcpp/support/config.h \ include/grpcpp/support/interceptor.h \ @@ -1038,6 +1046,7 @@ include/grpcpp/support/message_allocator.h \ include/grpcpp/support/proto_buffer_reader.h \ include/grpcpp/support/proto_buffer_writer.h \ include/grpcpp/support/server_callback.h \ +include/grpcpp/support/server_callback_impl.h \ include/grpcpp/support/server_interceptor.h \ include/grpcpp/support/slice.h \ include/grpcpp/support/status.h \ @@ -1045,6 +1054,7 @@ include/grpcpp/support/status_code_enum.h \ include/grpcpp/support/string_ref.h \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ +include/grpcpp/support/sync_stream_impl.h \ include/grpcpp/support/time.h \ include/grpcpp/support/validate_service_config.h \ src/core/ext/filters/client_channel/health/health.pb.c \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index e638e305af8..fd8037cf3a3 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -10190,7 +10190,9 @@ "include/grpc++/impl/codegen/time.h", "include/grpcpp/impl/codegen/async_generic_service.h", "include/grpcpp/impl/codegen/async_stream.h", + "include/grpcpp/impl/codegen/async_stream_impl.h", "include/grpcpp/impl/codegen/async_unary_call.h", + "include/grpcpp/impl/codegen/async_unary_call_impl.h", "include/grpcpp/impl/codegen/byte_buffer.h", "include/grpcpp/impl/codegen/call.h", "include/grpcpp/impl/codegen/call_hook.h", @@ -10199,6 +10201,7 @@ "include/grpcpp/impl/codegen/callback_common.h", "include/grpcpp/impl/codegen/channel_interface.h", "include/grpcpp/impl/codegen/client_callback.h", + "include/grpcpp/impl/codegen/client_callback_impl.h", "include/grpcpp/impl/codegen/client_context.h", "include/grpcpp/impl/codegen/client_context_impl.h", "include/grpcpp/impl/codegen/client_interceptor.h", @@ -10221,6 +10224,7 @@ "include/grpcpp/impl/codegen/security/auth_context.h", "include/grpcpp/impl/codegen/serialization_traits.h", "include/grpcpp/impl/codegen/server_callback.h", + "include/grpcpp/impl/codegen/server_callback_impl.h", "include/grpcpp/impl/codegen/server_context.h", "include/grpcpp/impl/codegen/server_context_impl.h", "include/grpcpp/impl/codegen/server_interceptor.h", @@ -10232,6 +10236,7 @@ "include/grpcpp/impl/codegen/string_ref.h", "include/grpcpp/impl/codegen/stub_options.h", "include/grpcpp/impl/codegen/sync_stream.h", + "include/grpcpp/impl/codegen/sync_stream_impl.h", "include/grpcpp/impl/codegen/time.h" ], "is_filegroup": true, @@ -10270,7 +10275,9 @@ "include/grpc++/impl/codegen/time.h", "include/grpcpp/impl/codegen/async_generic_service.h", "include/grpcpp/impl/codegen/async_stream.h", + "include/grpcpp/impl/codegen/async_stream_impl.h", "include/grpcpp/impl/codegen/async_unary_call.h", + "include/grpcpp/impl/codegen/async_unary_call_impl.h", "include/grpcpp/impl/codegen/byte_buffer.h", "include/grpcpp/impl/codegen/call.h", "include/grpcpp/impl/codegen/call_hook.h", @@ -10279,6 +10286,7 @@ "include/grpcpp/impl/codegen/callback_common.h", "include/grpcpp/impl/codegen/channel_interface.h", "include/grpcpp/impl/codegen/client_callback.h", + "include/grpcpp/impl/codegen/client_callback_impl.h", "include/grpcpp/impl/codegen/client_context.h", "include/grpcpp/impl/codegen/client_context_impl.h", "include/grpcpp/impl/codegen/client_interceptor.h", @@ -10301,6 +10309,7 @@ "include/grpcpp/impl/codegen/security/auth_context.h", "include/grpcpp/impl/codegen/serialization_traits.h", "include/grpcpp/impl/codegen/server_callback.h", + "include/grpcpp/impl/codegen/server_callback_impl.h", "include/grpcpp/impl/codegen/server_context.h", "include/grpcpp/impl/codegen/server_context_impl.h", "include/grpcpp/impl/codegen/server_interceptor.h", @@ -10312,6 +10321,7 @@ "include/grpcpp/impl/codegen/string_ref.h", "include/grpcpp/impl/codegen/stub_options.h", "include/grpcpp/impl/codegen/sync_stream.h", + "include/grpcpp/impl/codegen/sync_stream_impl.h", "include/grpcpp/impl/codegen/time.h" ], "third_party": false, @@ -10461,11 +10471,14 @@ "include/grpcpp/server_posix.h", "include/grpcpp/server_posix_impl.h", "include/grpcpp/support/async_stream.h", + "include/grpcpp/support/async_stream_impl.h", "include/grpcpp/support/async_unary_call.h", + "include/grpcpp/support/async_unary_call_impl.h", "include/grpcpp/support/byte_buffer.h", "include/grpcpp/support/channel_arguments.h", "include/grpcpp/support/channel_arguments_impl.h", "include/grpcpp/support/client_callback.h", + "include/grpcpp/support/client_callback_impl.h", "include/grpcpp/support/client_interceptor.h", "include/grpcpp/support/config.h", "include/grpcpp/support/interceptor.h", @@ -10473,6 +10486,7 @@ "include/grpcpp/support/proto_buffer_reader.h", "include/grpcpp/support/proto_buffer_writer.h", "include/grpcpp/support/server_callback.h", + "include/grpcpp/support/server_callback_impl.h", "include/grpcpp/support/server_interceptor.h", "include/grpcpp/support/slice.h", "include/grpcpp/support/status.h", @@ -10480,6 +10494,7 @@ "include/grpcpp/support/string_ref.h", "include/grpcpp/support/stub_options.h", "include/grpcpp/support/sync_stream.h", + "include/grpcpp/support/sync_stream_impl.h", "include/grpcpp/support/time.h", "include/grpcpp/support/validate_service_config.h", "src/cpp/client/create_channel_internal.h", @@ -10589,11 +10604,14 @@ "include/grpcpp/server_posix.h", "include/grpcpp/server_posix_impl.h", "include/grpcpp/support/async_stream.h", + "include/grpcpp/support/async_stream_impl.h", "include/grpcpp/support/async_unary_call.h", + "include/grpcpp/support/async_unary_call_impl.h", "include/grpcpp/support/byte_buffer.h", "include/grpcpp/support/channel_arguments.h", "include/grpcpp/support/channel_arguments_impl.h", "include/grpcpp/support/client_callback.h", + "include/grpcpp/support/client_callback_impl.h", "include/grpcpp/support/client_interceptor.h", "include/grpcpp/support/config.h", "include/grpcpp/support/interceptor.h", @@ -10601,6 +10619,7 @@ "include/grpcpp/support/proto_buffer_reader.h", "include/grpcpp/support/proto_buffer_writer.h", "include/grpcpp/support/server_callback.h", + "include/grpcpp/support/server_callback_impl.h", "include/grpcpp/support/server_interceptor.h", "include/grpcpp/support/slice.h", "include/grpcpp/support/status.h", @@ -10608,6 +10627,7 @@ "include/grpcpp/support/string_ref.h", "include/grpcpp/support/stub_options.h", "include/grpcpp/support/sync_stream.h", + "include/grpcpp/support/sync_stream_impl.h", "include/grpcpp/support/time.h", "include/grpcpp/support/validate_service_config.h", "src/cpp/client/channel_cc.cc", From 1487ac42cc992e5e9a9e8dfa0742a74c14593db6 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 1 Jul 2019 14:11:44 -0700 Subject: [PATCH 0768/1555] Remove CMSG_SPACE for macos --- src/core/lib/iomgr/tcp_posix.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index 0e153679ad7..819c5284256 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -443,7 +443,7 @@ static void tcp_do_read(grpc_tcp* tcp) { constexpr size_t cmsg_alloc_space = CMSG_SPACE(sizeof(grpc_core::scm_timestamping)) + CMSG_SPACE(sizeof(int)); #else - constexpr size_t cmsg_alloc_space = CMSG_SPACE(sizeof(int)); + constexpr size_t cmsg_alloc_space = 24 /* CMSG_SPACE(sizeof(int)) */; #endif /* GRPC_LINUX_ERRQUEUE */ char cmsgbuf[cmsg_alloc_space]; for (size_t i = 0; i < iov_len; i++) { From 01b82d3a39f2d4455025e9176dae7917a82babb2 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Mon, 1 Jul 2019 18:29:54 -0400 Subject: [PATCH 0769/1555] Return empty strings on optional ports for backward compatibility. gpr_split_host_port returns an empty string for the port when given "0.0.0.0:" as the input. Change the emptiness check to an explicit argument called has_port, to remain backward compatible. Added a test to cover both v4 and v6. --- src/core/lib/gprpp/host_port.cc | 18 +++++++++++++++--- test/core/gprpp/host_port_test.cc | 2 ++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/core/lib/gprpp/host_port.cc b/src/core/lib/gprpp/host_port.cc index 13b63eb902b..3fa4719f49a 100644 --- a/src/core/lib/gprpp/host_port.cc +++ b/src/core/lib/gprpp/host_port.cc @@ -44,7 +44,10 @@ int JoinHostPort(UniquePtr* out, const char* host, int port) { return ret; } -bool SplitHostPort(StringView name, StringView* host, StringView* port) { +namespace { +bool DoSplitHostPort(StringView name, StringView* host, StringView* port, + bool* has_port) { + *has_port = false; if (name[0] == '[') { /* Parse a bracketed host, typically an IPv6 literal. */ const size_t rbracket = name.find(']', 1); @@ -58,6 +61,7 @@ bool SplitHostPort(StringView name, StringView* host, StringView* port) { } else if (name[rbracket + 1] == ':') { /* ]: */ *port = name.substr(rbracket + 2, name.size() - rbracket - 2); + *has_port = true; } else { /* ] */ return false; @@ -76,6 +80,7 @@ bool SplitHostPort(StringView name, StringView* host, StringView* port) { /* Exactly 1 colon. Split into host:port. */ *host = name.substr(0, colon); *port = name.substr(colon + 1, name.size() - colon - 1); + *has_port = true; } else { /* 0 or 2+ colons. Bare hostname or IPv6 litearal. */ *host = name; @@ -84,6 +89,12 @@ bool SplitHostPort(StringView name, StringView* host, StringView* port) { } return true; } +} // namespace + +bool SplitHostPort(StringView name, StringView* host, StringView* port) { + bool unused; + return DoSplitHostPort(name, host, port, &unused); +} bool SplitHostPort(StringView name, UniquePtr* host, UniquePtr* port) { @@ -91,12 +102,13 @@ bool SplitHostPort(StringView name, UniquePtr* host, GPR_DEBUG_ASSERT(port != nullptr && *port == nullptr); StringView host_view; StringView port_view; - const bool ret = SplitHostPort(name, &host_view, &port_view); + bool has_port; + const bool ret = DoSplitHostPort(name, &host_view, &port_view, &has_port); if (ret) { // We always set the host, but port is set only when it's non-empty, // to remain backward compatible with the old split_host_port API. *host = host_view.dup(); - if (!port_view.empty()) { + if (has_port) { *port = port_view.dup(); } } diff --git a/test/core/gprpp/host_port_test.cc b/test/core/gprpp/host_port_test.cc index 3b392da66e8..cfe0eddb036 100644 --- a/test/core/gprpp/host_port_test.cc +++ b/test/core/gprpp/host_port_test.cc @@ -71,7 +71,9 @@ static void test_split_host_port() { split_host_port_expect("", "", nullptr, true); split_host_port_expect("[a:b]", "a:b", nullptr, true); split_host_port_expect("1.2.3.4", "1.2.3.4", nullptr, true); + split_host_port_expect("0.0.0.0:", "0.0.0.0", "", true); split_host_port_expect("a:b:c::", "a:b:c::", nullptr, true); + split_host_port_expect("[a:b:c::]:", "a:b:c::", "", true); split_host_port_expect("[a:b]:30", "a:b", "30", true); split_host_port_expect("1.2.3.4:30", "1.2.3.4", "30", true); split_host_port_expect(":30", "", "30", true); From cac8afa1593cd551e1ea122ba2d07e4166478ee4 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Mon, 1 Jul 2019 15:34:24 -0700 Subject: [PATCH 0770/1555] Add benchmark --- src/core/lib/iomgr/executor/threadpool.h | 13 +- test/cpp/microbenchmarks/BUILD | 8 + test/cpp/microbenchmarks/bm_threadpool.cc | 346 ++++++++++++++++++++++ 3 files changed, 361 insertions(+), 6 deletions(-) create mode 100644 test/cpp/microbenchmarks/bm_threadpool.cc diff --git a/src/core/lib/iomgr/executor/threadpool.h b/src/core/lib/iomgr/executor/threadpool.h index b14f1051feb..f362cea4a16 100644 --- a/src/core/lib/iomgr/executor/threadpool.h +++ b/src/core/lib/iomgr/executor/threadpool.h @@ -69,9 +69,9 @@ class ThreadPoolWorker { MPMCQueueInterface* queue, Thread::Options& options, int index) : queue_(queue), thd_name_(thd_name), index_(index) { - thd_ = Thread( - thd_name, [](void* th) { static_cast(th)->Run(); }, - this, nullptr, options); + thd_ = Thread(thd_name, + [](void* th) { static_cast(th)->Run(); }, + this, nullptr, options); } ~ThreadPoolWorker() {} @@ -100,7 +100,7 @@ class ThreadPoolWorker { // A fixed size thread pool implementation of abstract thread pool interface. // In this implementation, the number of threads in pool is fixed, but the // capacity of closure queue is unlimited. -class ThreadPool : public ThreadPoolInterface { +class ThreadPool : public ThreadPoolInterface { public: // Creates a thread pool with size of "num_threads", with default thread name // "ThreadPoolWorker" and all thread options set to default. @@ -108,7 +108,7 @@ class ThreadPool : public ThreadPoolInterface { // Same as ThreadPool(int num_threads) constructor, except // that it also sets "thd_name" as the name of all threads in the thread pool. - ThreadPool(int num_threads, const char* thd_name); + ThreadPool(int num_threads, const char *thd_name); // Same as ThreadPool(const char *thd_name, int num_threads) constructor, // except that is also set thread_options for threads. @@ -117,7 +117,7 @@ class ThreadPool : public ThreadPoolInterface { // value 0, default ThreadPool stack size will be used. The current default // stack size of this implementation is 1952K for mobile platform and 64K for // all others. - ThreadPool(int num_threads, const char* thd_name, + ThreadPool(int num_threads, const char *thd_name, const Thread::Options& thread_options); // Waits for all pending closures to complete, then shuts down thread pool. @@ -148,6 +148,7 @@ class ThreadPool : public ThreadPoolInterface { bool HasBeenShutDown(); }; + } // namespace grpc_core #endif /* GRPC_CORE_LIB_IOMGR_THREADPOOL_THREADPOOL_H */ diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD index d9424f24f16..576eab554a4 100644 --- a/test/cpp/microbenchmarks/BUILD +++ b/test/cpp/microbenchmarks/BUILD @@ -214,6 +214,14 @@ grpc_cc_binary( ], ) +grpc_cc_binary( + name = "bm_threadpool", + testonly = 1, + srcs = ["bm_threadpool.cc"], + tags = ["no_windows"], + deps = [":helpers"], +) + grpc_cc_binary( name = "bm_timer", testonly = 1, diff --git a/test/cpp/microbenchmarks/bm_threadpool.cc b/test/cpp/microbenchmarks/bm_threadpool.cc new file mode 100644 index 00000000000..9eef16a7026 --- /dev/null +++ b/test/cpp/microbenchmarks/bm_threadpool.cc @@ -0,0 +1,346 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "src/core/lib/iomgr/executor/threadpool.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include "test/cpp/microbenchmarks/helpers.h" +#include "test/cpp/util/test_config.h" + + + +namespace grpc { +namespace testing { + +// This helper class allows a thread to block for s pre-specified number of +// actions. BlockingCounter has a initial non-negative count on initialization +// Each call to DecrementCount will decrease the count by 1. When making a call +// to Wait, if the count is greater than 0, the thread will be block, until +// the count reaches 0, it will unblock. +class BlockingCounter { + public: + BlockingCounter(int count) : count_(count) {} + void DecrementCount() { + std::lock_guard l(mu_); + count_--; + cv_.notify_one(); + } + + void Wait() { + std::unique_lock l(mu_); + while (count_ > 0) { + cv_.wait(l); + } + } + private: + int count_; + std::mutex mu_; + std::condition_variable cv_; +}; + +// This is a functor/closure class for threadpool microbenchmark. +// This functor (closure) class will add another functor into pool if the +// number passed in (num_add) is greater than 0. Otherwise, it will decrement +// the counter to indicate that task is finished. This functor will suicide at +// the end, therefore, no need for caller to do clean-ups. +class AddAnotherFunctor : public grpc_experimental_completion_queue_functor { + public: + AddAnotherFunctor(grpc_core::ThreadPool* pool, BlockingCounter* counter, + int num_add) + : pool_(pool), counter_(counter), num_add_(num_add) { + functor_run = &AddAnotherFunctor::Run; + internal_next = this; + internal_success = 0; + } + ~AddAnotherFunctor() {} + // When the functor gets to run in thread pool, it will take internal_next + // as first argument and internal_success as second one. Therefore, the + // first argument here would be the closure itself. + static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { + auto* callback = static_cast(cb); + if (--callback->num_add_ > 0) { + callback->pool_->Add(new AddAnotherFunctor( + callback->pool_, callback->counter_, callback->num_add_)); + } else { + callback->counter_->DecrementCount(); + } + // Suicide + delete callback; + } + + private: + grpc_core::ThreadPool* pool_; + BlockingCounter* counter_; + int num_add_; +}; + +void ThreadPoolAddAnotherHelper(benchmark::State& state, + int concurrent_functor) { + const int num_threads = state.range(0); + const int num_iterations = state.range(1); + // number of adds done by each closure + const int num_add = num_iterations / concurrent_functor; + grpc_core::ThreadPool pool(num_threads); + while (state.KeepRunningBatch(num_iterations)) { + BlockingCounter* counter = new BlockingCounter(concurrent_functor); + for (int i = 0; i < concurrent_functor; ++i) { + pool.Add(new AddAnotherFunctor(&pool, counter, num_add)); + } + counter->Wait(); + delete counter; + } + state.SetItemsProcessed(state.iterations()); +} + +// This benchmark will let a closure add a new closure into pool. Concurrent +// closures range from 1 to 2048 +static void BM_ThreadPool1AddAnother(benchmark::State& state) { + ThreadPoolAddAnotherHelper(state, 1); +} +BENCHMARK(BM_ThreadPool1AddAnother) + ->UseRealTime() + // ->Iterations(1) + // First pair is range for number of threads in pool, second paris is range + // for number of iterations + ->Ranges({{1, 1024}, {524288, 524288}}); // range = 2M ~ 4M + +static void BM_ThreadPool4AddAnother(benchmark::State& state) { + ThreadPoolAddAnotherHelper(state, 4); +} +BENCHMARK(BM_ThreadPool4AddAnother) + ->UseRealTime() + // ->Iterations(1) + ->Ranges({{1, 1024}, {524288, 524288}}); // range = 256K ~ 512K + +static void BM_ThreadPool8AddAnother(benchmark::State& state) { + ThreadPoolAddAnotherHelper(state, 8); +} +BENCHMARK(BM_ThreadPool8AddAnother) + ->UseRealTime() + // ->Iterations(1) + ->Ranges({{1, 1024}, {524288, 524288}}); + + +static void BM_ThreadPool16AddAnother(benchmark::State& state) { + ThreadPoolAddAnotherHelper(state, 16); +} +BENCHMARK(BM_ThreadPool16AddAnother) + ->UseRealTime() + // ->Iterations(1) + ->Ranges({{1, 1024}, {524288, 524288}}); + + +static void BM_ThreadPool32AddAnother(benchmark::State& state) { + ThreadPoolAddAnotherHelper(state, 32); +} +BENCHMARK(BM_ThreadPool32AddAnother) + ->UseRealTime() + // ->Iterations(1) + ->Ranges({{1, 1024}, {524288, 524288}}); + +static void BM_ThreadPool64AddAnother(benchmark::State& state) { + ThreadPoolAddAnotherHelper(state, 64); +} +BENCHMARK(BM_ThreadPool64AddAnother) + ->UseRealTime() + // ->Iterations(1) + ->Ranges({{1, 1024}, {524288, 524288}}); + +static void BM_ThreadPool128AddAnother(benchmark::State& state) { + ThreadPoolAddAnotherHelper(state, 128); +} +BENCHMARK(BM_ThreadPool128AddAnother) + ->UseRealTime() + // ->Iterations(1) + ->Ranges({{1, 1024}, {524288, 524288}}); + +static void BM_ThreadPool512AddAnother(benchmark::State& state) { + ThreadPoolAddAnotherHelper(state, 512); +} +BENCHMARK(BM_ThreadPool512AddAnother) + ->UseRealTime() + // ->Iterations(1) + ->Ranges({{1, 1024}, {524288, 524288}}); + +static void BM_ThreadPool2048AddAnother(benchmark::State& state) { + ThreadPoolAddAnotherHelper(state, 2048); +} +BENCHMARK(BM_ThreadPool2048AddAnother) + ->UseRealTime() + // ->Iterations(1) + ->Ranges({{1, 1024}, {524288, 524288}}); + + +// A functor class that will delete self on end of running. +class SuicideFunctorForAdd + : public grpc_experimental_completion_queue_functor { + public: + SuicideFunctorForAdd() { + functor_run = &SuicideFunctorForAdd::Run; + internal_next = this; + internal_success = 0; + } + ~SuicideFunctorForAdd() {} + static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { + // On running, the first argument would be internal_next, which is itself. + delete cb; + } +}; + +// Performs the scenario of external thread(s) adding closures into pool. +static void BM_ThreadPoolExternalAdd(benchmark::State& state) { + const int num_threads = state.range(0); + static grpc_core::ThreadPool* pool = + new grpc_core::ThreadPool(num_threads); + for (auto _ : state) { + pool->Add(new SuicideFunctorForAdd()); + } + state.SetItemsProcessed(state.iterations()); +} +BENCHMARK(BM_ThreadPoolExternalAdd) + ->Range(1, 1024) + ->ThreadRange(1, 1024) // concurrent external thread(s) up to 1024 + ->UseRealTime(); + +// Functor (closure) that adds itself into pool repeatedly. By adding self, the +// overhead would be low and can measure the time of add more accurately. +class AddSelfFunctor : public grpc_experimental_completion_queue_functor { + public: + AddSelfFunctor(grpc_core::ThreadPool* pool, BlockingCounter* counter, + int num_add) + : pool_(pool), counter_(counter), num_add_(num_add) { + functor_run = &AddSelfFunctor::Run; + internal_next = this; + internal_success = 0; + } + ~AddSelfFunctor() {} + // When the functor gets to run in thread pool, it will take internal_next + // as first argument and internal_success as second one. Therefore, the + // first argument here would be the closure itself. + static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { + auto* callback = static_cast(cb); + if (--callback->num_add_ > 0) { + callback->pool_->Add(cb); + } else { + callback->counter_->DecrementCount(); + // Suicide + delete callback; + } + } + + private: + grpc_core::ThreadPool* pool_; + BlockingCounter* counter_; + int num_add_; +}; + +static void BM_ThreadPoolAddSelf(benchmark::State& state) { + const int num_threads = state.range(0); + const int kNumIteration = 524288; + int concurrent_functor = num_threads; + int num_add = kNumIteration / concurrent_functor; + grpc_core::ThreadPool pool(num_threads); + while (state.KeepRunningBatch(kNumIteration)) { + BlockingCounter* counter = new BlockingCounter(concurrent_functor); + for (int i = 0; i < concurrent_functor; ++i) { + pool.Add(new AddSelfFunctor(&pool, counter, num_add)); + } + counter->Wait(); + delete counter; + } + state.SetItemsProcessed(state.iterations()); +} + +BENCHMARK(BM_ThreadPoolAddSelf)->UseRealTime()->Range(1, 1024); + +// A functor (closure) that simulates closures with small but non-trivial amount +// of work. +class ShortWorkFunctorForAdd + : public grpc_experimental_completion_queue_functor { + public: + BlockingCounter* counter_; + + ShortWorkFunctorForAdd() { + functor_run = &ShortWorkFunctorForAdd::Run; + internal_next = this; + internal_success = 0; + val_ = 0; + } + ~ShortWorkFunctorForAdd() {} + static void Run(grpc_experimental_completion_queue_functor *cb, int ok) { + auto* callback = static_cast(cb); + for (int i = 0; i < 1000; ++i) { + callback->val_++; + } + callback->counter_->DecrementCount(); + } + private: + int val_; +}; + +// Simulates workloads where many short running callbacks are added to the +// threadpool. The callbacks are not enough to keep all the workers busy +// continuously so the number of workers running changes overtime. +// +// In effect this tests how well the threadpool avoids spurious wakeups. +static void BM_SpikyLoad(benchmark::State& state) { + const int num_threads = state.range(0); + + const int kNumSpikes = 1000; + const int batch_size = 3 * num_threads; + std::vector work_vector(batch_size); + while (state.KeepRunningBatch(kNumSpikes * batch_size)) { + grpc_core::ThreadPool pool(num_threads); + for (int i = 0; i != kNumSpikes; ++i) { + BlockingCounter counter(batch_size); + for (auto& w : work_vector) { + w.counter_ = &counter; + pool.Add(&w); + } + counter.Wait(); + } + } + state.SetItemsProcessed(state.iterations() * batch_size); +} +BENCHMARK(BM_SpikyLoad)->Arg(1)->Arg(2)->Arg(4)->Arg(8)->Arg(16); + +} // namespace testing +} // namespace grpc + +// Some distros have RunSpecifiedBenchmarks under the benchmark namespace, +// and others do not. This allows us to support both modes. +namespace benchmark { +void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } +} // namespace benchmark + +int main(int argc, char** argv) { + LibraryInitializer libInit; + ::benchmark::Initialize(&argc, argv); + // gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG); + ::grpc::testing::InitTest(&argc, &argv, false); + benchmark::RunTheBenchmarksNamespaced(); + return 0; +} From 9421a27a76bc9f0100e2ad30f3e299fb9d2c0225 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Mon, 1 Jul 2019 15:45:01 -0700 Subject: [PATCH 0771/1555] Remove extra headers --- test/cpp/microbenchmarks/bm_threadpool.cc | 44 +++++++---------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_threadpool.cc b/test/cpp/microbenchmarks/bm_threadpool.cc index 9eef16a7026..2e68a298b15 100644 --- a/test/cpp/microbenchmarks/bm_threadpool.cc +++ b/test/cpp/microbenchmarks/bm_threadpool.cc @@ -16,22 +16,14 @@ * */ -#include "src/core/lib/iomgr/executor/threadpool.h" - -#include - #include -#include -#include -#include + #include -#include -#include + +#include "src/core/lib/iomgr/executor/threadpool.h" #include "test/cpp/microbenchmarks/helpers.h" #include "test/cpp/util/test_config.h" - - namespace grpc { namespace testing { @@ -122,26 +114,23 @@ static void BM_ThreadPool1AddAnother(benchmark::State& state) { } BENCHMARK(BM_ThreadPool1AddAnother) ->UseRealTime() - // ->Iterations(1) - // First pair is range for number of threads in pool, second paris is range + // First pair is range for number of threads in pool, second pair is range // for number of iterations - ->Ranges({{1, 1024}, {524288, 524288}}); // range = 2M ~ 4M + ->Ranges({{1, 1024}, {524288, 2097152}}); // 512K ~ 2M static void BM_ThreadPool4AddAnother(benchmark::State& state) { ThreadPoolAddAnotherHelper(state, 4); } BENCHMARK(BM_ThreadPool4AddAnother) ->UseRealTime() - // ->Iterations(1) - ->Ranges({{1, 1024}, {524288, 524288}}); // range = 256K ~ 512K + ->Ranges({{1, 1024}, {524288, 2097152}}); static void BM_ThreadPool8AddAnother(benchmark::State& state) { ThreadPoolAddAnotherHelper(state, 8); } BENCHMARK(BM_ThreadPool8AddAnother) ->UseRealTime() - // ->Iterations(1) - ->Ranges({{1, 1024}, {524288, 524288}}); + ->Ranges({{1, 1024}, {524288, 1048576}}); // 512K ~ 1M static void BM_ThreadPool16AddAnother(benchmark::State& state) { @@ -149,8 +138,7 @@ static void BM_ThreadPool16AddAnother(benchmark::State& state) { } BENCHMARK(BM_ThreadPool16AddAnother) ->UseRealTime() - // ->Iterations(1) - ->Ranges({{1, 1024}, {524288, 524288}}); + ->Ranges({{1, 1024}, {524288, 1048576}}); static void BM_ThreadPool32AddAnother(benchmark::State& state) { @@ -158,40 +146,35 @@ static void BM_ThreadPool32AddAnother(benchmark::State& state) { } BENCHMARK(BM_ThreadPool32AddAnother) ->UseRealTime() - // ->Iterations(1) - ->Ranges({{1, 1024}, {524288, 524288}}); + ->Ranges({{1, 1024}, {524288, 1048576}}); static void BM_ThreadPool64AddAnother(benchmark::State& state) { ThreadPoolAddAnotherHelper(state, 64); } BENCHMARK(BM_ThreadPool64AddAnother) ->UseRealTime() - // ->Iterations(1) - ->Ranges({{1, 1024}, {524288, 524288}}); + ->Ranges({{1, 1024}, {524288, 1048576}}); static void BM_ThreadPool128AddAnother(benchmark::State& state) { ThreadPoolAddAnotherHelper(state, 128); } BENCHMARK(BM_ThreadPool128AddAnother) ->UseRealTime() - // ->Iterations(1) - ->Ranges({{1, 1024}, {524288, 524288}}); + ->Ranges({{1, 1024}, {524288, 1048576}}); static void BM_ThreadPool512AddAnother(benchmark::State& state) { ThreadPoolAddAnotherHelper(state, 512); } BENCHMARK(BM_ThreadPool512AddAnother) ->UseRealTime() - // ->Iterations(1) - ->Ranges({{1, 1024}, {524288, 524288}}); + ->Ranges({{1, 1024}, {524288, 1048576}}); static void BM_ThreadPool2048AddAnother(benchmark::State& state) { ThreadPoolAddAnotherHelper(state, 2048); } BENCHMARK(BM_ThreadPool2048AddAnother) ->UseRealTime() - // ->Iterations(1) - ->Ranges({{1, 1024}, {524288, 524288}}); + ->Ranges({{1, 1024}, {524288, 1048576}}); // A functor class that will delete self on end of running. @@ -339,7 +322,6 @@ void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } int main(int argc, char** argv) { LibraryInitializer libInit; ::benchmark::Initialize(&argc, argv); - // gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG); ::grpc::testing::InitTest(&argc, &argv, false); benchmark::RunTheBenchmarksNamespaced(); return 0; From bf9b4c257bdd5f5765fcd9b6c9402d170f75fea8 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Mon, 1 Jul 2019 19:13:26 -0400 Subject: [PATCH 0772/1555] Fix stale comment in split host port. --- src/core/lib/gprpp/host_port.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/lib/gprpp/host_port.cc b/src/core/lib/gprpp/host_port.cc index 3fa4719f49a..e7f0e4461e9 100644 --- a/src/core/lib/gprpp/host_port.cc +++ b/src/core/lib/gprpp/host_port.cc @@ -105,8 +105,9 @@ bool SplitHostPort(StringView name, UniquePtr* host, bool has_port; const bool ret = DoSplitHostPort(name, &host_view, &port_view, &has_port); if (ret) { - // We always set the host, but port is set only when it's non-empty, - // to remain backward compatible with the old split_host_port API. + // We always set the host, but port is set only when DoSplitHostPort find a + // port in the string, to remain backward compatible with the old + // gpr_split_host_port API. *host = host_view.dup(); if (has_port) { *port = port_view.dup(); From 093dd768bb52e7eaf37d7bd5e4d59c85c1912945 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Mon, 1 Jul 2019 16:48:26 -0700 Subject: [PATCH 0773/1555] reformat --- test/cpp/microbenchmarks/bm_threadpool.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/cpp/microbenchmarks/bm_threadpool.cc b/test/cpp/microbenchmarks/bm_threadpool.cc index 2e68a298b15..0ef34c2aecc 100644 --- a/test/cpp/microbenchmarks/bm_threadpool.cc +++ b/test/cpp/microbenchmarks/bm_threadpool.cc @@ -197,7 +197,7 @@ class SuicideFunctorForAdd static void BM_ThreadPoolExternalAdd(benchmark::State& state) { const int num_threads = state.range(0); static grpc_core::ThreadPool* pool = - new grpc_core::ThreadPool(num_threads); + grpc_core::New(num_threads); for (auto _ : state) { pool->Add(new SuicideFunctorForAdd()); } @@ -280,6 +280,7 @@ class ShortWorkFunctorForAdd } callback->counter_->DecrementCount(); } + private: int val_; }; From 651a8b0ec2ca8166665c33784c8e6b3230ffa11a Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Mon, 1 Jul 2019 17:07:57 -0700 Subject: [PATCH 0774/1555] Change FetchAdd/Sub to Load-Add/Sub-Store --- src/core/lib/iomgr/executor/mpmcqueue.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index 97429ec30c7..ea2a6868d2f 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -31,7 +31,7 @@ inline void* InfLenFIFOQueue::PopFront() { Node* head_to_remove = queue_head_; queue_head_ = queue_head_->next; - count_.FetchSub(1, MemoryOrder::RELAXED); + count_.Store(count_.Load(MemoryOrder::RELAXED) - 1, MemoryOrder::RELAXED); if (GRPC_TRACE_FLAG_ENABLED(grpc_thread_pool_trace)) { gpr_timespec wait_time = @@ -76,7 +76,7 @@ void InfLenFIFOQueue::Put(void* elem) { MutexLock l(&mu_); Node* new_node = New(elem); - if (count_.FetchAdd(1, MemoryOrder::RELAXED) == 0) { + if (count_.Load(MemoryOrder::RELAXED) == 0) { if (GRPC_TRACE_FLAG_ENABLED(grpc_thread_pool_trace)) { busy_time = gpr_now(GPR_CLOCK_MONOTONIC); } @@ -85,7 +85,7 @@ void InfLenFIFOQueue::Put(void* elem) { queue_tail_->next = new_node; queue_tail_ = queue_tail_->next; } - + count_.Store(count_.Load(MemoryOrder::RELAXED) + 1, MemoryOrder::RELAXED); // Updates Stats info if (GRPC_TRACE_FLAG_ENABLED(grpc_thread_pool_trace)) { stats_.num_started++; From 500cb1f99b495bcb081c2e6d913dd27493c97815 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Mon, 1 Jul 2019 17:58:54 -0700 Subject: [PATCH 0775/1555] Reformat --- src/core/lib/iomgr/executor/threadpool.h | 10 ++++------ test/cpp/microbenchmarks/bm_threadpool.cc | 11 ++++------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/core/lib/iomgr/executor/threadpool.h b/src/core/lib/iomgr/executor/threadpool.h index f362cea4a16..d0822fadc8b 100644 --- a/src/core/lib/iomgr/executor/threadpool.h +++ b/src/core/lib/iomgr/executor/threadpool.h @@ -19,9 +19,8 @@ #ifndef GRPC_CORE_LIB_IOMGR_EXECUTOR_THREADPOOL_H #define GRPC_CORE_LIB_IOMGR_EXECUTOR_THREADPOOL_H -#include - #include +#include #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/executor/mpmcqueue.h" @@ -100,7 +99,7 @@ class ThreadPoolWorker { // A fixed size thread pool implementation of abstract thread pool interface. // In this implementation, the number of threads in pool is fixed, but the // capacity of closure queue is unlimited. -class ThreadPool : public ThreadPoolInterface { +class ThreadPool : public ThreadPoolInterface { public: // Creates a thread pool with size of "num_threads", with default thread name // "ThreadPoolWorker" and all thread options set to default. @@ -108,7 +107,7 @@ class ThreadPool : public ThreadPoolInterface { // Same as ThreadPool(int num_threads) constructor, except // that it also sets "thd_name" as the name of all threads in the thread pool. - ThreadPool(int num_threads, const char *thd_name); + ThreadPool(int num_threads, const char* thd_name); // Same as ThreadPool(const char *thd_name, int num_threads) constructor, // except that is also set thread_options for threads. @@ -117,7 +116,7 @@ class ThreadPool : public ThreadPoolInterface { // value 0, default ThreadPool stack size will be used. The current default // stack size of this implementation is 1952K for mobile platform and 64K for // all others. - ThreadPool(int num_threads, const char *thd_name, + ThreadPool(int num_threads, const char* thd_name, const Thread::Options& thread_options); // Waits for all pending closures to complete, then shuts down thread pool. @@ -148,7 +147,6 @@ class ThreadPool : public ThreadPoolInterface { bool HasBeenShutDown(); }; - } // namespace grpc_core #endif /* GRPC_CORE_LIB_IOMGR_THREADPOOL_THREADPOOL_H */ diff --git a/test/cpp/microbenchmarks/bm_threadpool.cc b/test/cpp/microbenchmarks/bm_threadpool.cc index 0ef34c2aecc..b4ebcdaaf92 100644 --- a/test/cpp/microbenchmarks/bm_threadpool.cc +++ b/test/cpp/microbenchmarks/bm_threadpool.cc @@ -47,6 +47,7 @@ class BlockingCounter { cv_.wait(l); } } + private: int count_; std::mutex mu_; @@ -61,7 +62,7 @@ class BlockingCounter { class AddAnotherFunctor : public grpc_experimental_completion_queue_functor { public: AddAnotherFunctor(grpc_core::ThreadPool* pool, BlockingCounter* counter, - int num_add) + int num_add) : pool_(pool), counter_(counter), num_add_(num_add) { functor_run = &AddAnotherFunctor::Run; internal_next = this; @@ -132,7 +133,6 @@ BENCHMARK(BM_ThreadPool8AddAnother) ->UseRealTime() ->Ranges({{1, 1024}, {524288, 1048576}}); // 512K ~ 1M - static void BM_ThreadPool16AddAnother(benchmark::State& state) { ThreadPoolAddAnotherHelper(state, 16); } @@ -140,7 +140,6 @@ BENCHMARK(BM_ThreadPool16AddAnother) ->UseRealTime() ->Ranges({{1, 1024}, {524288, 1048576}}); - static void BM_ThreadPool32AddAnother(benchmark::State& state) { ThreadPoolAddAnotherHelper(state, 32); } @@ -176,10 +175,8 @@ BENCHMARK(BM_ThreadPool2048AddAnother) ->UseRealTime() ->Ranges({{1, 1024}, {524288, 1048576}}); - // A functor class that will delete self on end of running. -class SuicideFunctorForAdd - : public grpc_experimental_completion_queue_functor { +class SuicideFunctorForAdd : public grpc_experimental_completion_queue_functor { public: SuicideFunctorForAdd() { functor_run = &SuicideFunctorForAdd::Run; @@ -273,7 +270,7 @@ class ShortWorkFunctorForAdd val_ = 0; } ~ShortWorkFunctorForAdd() {} - static void Run(grpc_experimental_completion_queue_functor *cb, int ok) { + static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { auto* callback = static_cast(cb); for (int i = 0; i < 1000; ++i) { callback->val_++; From aa535356e8a95d686396f79370f500c3be8e6233 Mon Sep 17 00:00:00 2001 From: mgravell Date: Tue, 2 Jul 2019 08:28:44 +0100 Subject: [PATCH 0776/1555] fix encode benchmark (and simplify decode benchmark) --- src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs | 20 ++++--- src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs | 56 +++++++++++-------- 2 files changed, 45 insertions(+), 31 deletions(-) diff --git a/src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs b/src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs index 1c3f4d261ee..070f8ec03ce 100644 --- a/src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs +++ b/src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs @@ -11,15 +11,18 @@ namespace Grpc.Microbenchmarks public class Utf8Decode { [Params(0, 1, 4, 128, 1024)] - public int PayloadSize { get; set; } + public int PayloadSize + { + get { return payloadSize; } + set + { + payloadSize = value; + payload = Invent(value); + } + } - static readonly Dictionary Payloads = new Dictionary { - { 0, Invent(0) }, - { 1, Invent(1) }, - { 4, Invent(4) }, - { 128, Invent(128) }, - { 1024, Invent(1024) }, - }; + private int payloadSize; + private byte[] payload; static byte[] Invent(int length) { @@ -36,7 +39,6 @@ namespace Grpc.Microbenchmarks [Benchmark(OperationsPerInvoke = Iterations)] public unsafe void Run() { - byte[] payload = Payloads[PayloadSize]; fixed (byte* ptr = payload) { var iPtr = new IntPtr(ptr); diff --git a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs index 0c9370679a4..bf9fe68e467 100644 --- a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs +++ b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs @@ -10,16 +10,19 @@ namespace Grpc.Microbenchmarks [MemoryDiagnoser] // allocations public class Utf8Encode : ISendStatusFromServerCompletionCallback { - [Params(0)] //, 1, 4, 128, 1024)] - public int PayloadSize { get; set; } + [Params(0, 1, 4, 128, 1024)] + public int PayloadSize + { + get { return payloadSize; } + set + { + payloadSize = value; + status = new Status(StatusCode.OK, Invent(value)); + } + } - static readonly Dictionary Payloads = new Dictionary { - { 0, Invent(0) }, - { 1, Invent(1) }, - { 4, Invent(4) }, - { 128, Invent(128) }, - { 1024, Invent(1024) }, - }; + private int payloadSize; + private Status status; static string Invent(int length) { @@ -33,19 +36,22 @@ namespace Grpc.Microbenchmarks } private GrpcEnvironment environment; - + private CompletionRegistry completionRegistry; [GlobalSetup] public void Setup() { var native = NativeMethods.Get(); // nop the native-call via reflection - NativeMethods.Delegates.grpcsharp_call_send_status_from_server_delegate nop = (CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, byte[] statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags) => CallError.OK; + NativeMethods.Delegates.grpcsharp_call_send_status_from_server_delegate nop = (CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, byte[] statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags) => { + completionRegistry.Extract(ctx.Handle).OnComplete(true); // drain the dictionary as we go + return CallError.OK; + }; native.GetType().GetField(nameof(native.grpcsharp_call_send_status_from_server)).SetValue(native, nop); environment = GrpcEnvironment.AddRef(); metadata = MetadataArraySafeHandle.Create(Metadata.Empty); - var completionRegistry = new CompletionRegistry(environment, () => environment.BatchContextPool.Lease(), () => throw new NotImplementedException()); + completionRegistry = new CompletionRegistry(environment, () => environment.BatchContextPool.Lease(), () => throw new NotImplementedException()); var cq = CompletionQueueSafeHandle.CreateAsync(completionRegistry); call = CreateFakeCall(cq); } @@ -65,15 +71,23 @@ namespace Grpc.Microbenchmarks [GlobalCleanup] public void Cleanup() { - metadata?.Dispose(); - metadata = null; - call?.Dispose(); - call = null; - - if (environment != null) + try { - environment = null; - GrpcEnvironment.ReleaseAsync().Wait(); + metadata?.Dispose(); + metadata = null; + call?.Dispose(); + call = null; + + if (environment != null) + { + environment = null; + // cleanup seems... unreliable on CLR + // GrpcEnvironment.ReleaseAsync().Wait(1000); + } + } + catch (Exception ex) + { + Console.Error.WriteLine(ex.Message); } } private CallSafeHandle call; @@ -83,8 +97,6 @@ namespace Grpc.Microbenchmarks [Benchmark(OperationsPerInvoke = Iterations)] public unsafe void Run() { - string payload = Payloads[PayloadSize]; - var status = new Status(StatusCode.OK, payload); for (int i = 0; i < Iterations; i++) { call.StartSendStatusFromServer(this, status, metadata, false, null, WriteFlags.NoCompress); From 36c1a11d84771eec759a92670c071744c7541c96 Mon Sep 17 00:00:00 2001 From: mgravell Date: Tue, 2 Jul 2019 08:48:24 +0100 Subject: [PATCH 0777/1555] give useful names to benchmarks --- grpcpp_channelz.vcxproj.filters | 42 +++++++++++++++++++ .../CompletionRegistryBenchmark.cs | 2 +- .../PInvokeByteArrayBenchmark.cs | 2 +- .../SendMessageBenchmark.cs | 4 +- src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs | 2 +- src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs | 2 +- 6 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 grpcpp_channelz.vcxproj.filters diff --git a/grpcpp_channelz.vcxproj.filters b/grpcpp_channelz.vcxproj.filters new file mode 100644 index 00000000000..9f37e96eb69 --- /dev/null +++ b/grpcpp_channelz.vcxproj.filters @@ -0,0 +1,42 @@ + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + + + CMake Rules + + + + + + {870DBD13-69C5-3F27-A253-623E8947E2E7} + + + {67AA517E-A3B4-3BFF-B690-252465A3B876} + + + {B3AFD131-5BE8-3F8D-8C68-1BD558A25862} + + + diff --git a/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs index 58ba29927cc..ac252a95d89 100644 --- a/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs @@ -29,7 +29,7 @@ namespace Grpc.Microbenchmarks const int Iterations = 1000; [Benchmark(OperationsPerInvoke = Iterations)] - public void Run() + public void RegisterExtract() { RunConcurrent(() => { CompletionRegistry sharedRegistry = UseSharedRegistry ? new CompletionRegistry(Environment, () => BatchContextSafeHandle.Create(), () => RequestCallContextSafeHandle.Create()) : null; diff --git a/src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs index 412f9ad1cb4..b217aef2068 100644 --- a/src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs @@ -34,7 +34,7 @@ namespace Grpc.Microbenchmarks const int Iterations = 1000; [Benchmark(OperationsPerInvoke = Iterations)] - public void Run() + public void AllocFree() { RunConcurrent(RunBody); } diff --git a/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs index fa06e7a8230..56ae838a4f4 100644 --- a/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2015 gRPC authors. // @@ -38,7 +38,7 @@ namespace Grpc.Microbenchmarks const int Iterations = 1000; [Benchmark(OperationsPerInvoke = Iterations)] - public void Run() + public void SendMessage() { RunConcurrent(RunBody); } diff --git a/src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs b/src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs index 070f8ec03ce..5c5c927a260 100644 --- a/src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs +++ b/src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs @@ -37,7 +37,7 @@ namespace Grpc.Microbenchmarks const int Iterations = 1000; [Benchmark(OperationsPerInvoke = Iterations)] - public unsafe void Run() + public unsafe void Decode() { fixed (byte* ptr = payload) { diff --git a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs index bf9fe68e467..95e7ad45841 100644 --- a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs +++ b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs @@ -95,7 +95,7 @@ namespace Grpc.Microbenchmarks const int Iterations = 1000; [Benchmark(OperationsPerInvoke = Iterations)] - public unsafe void Run() + public unsafe void SendStatus() { for (int i = 0; i < Iterations; i++) { From dd5f19765ea382b6ae1b08b786c448c923597a5c Mon Sep 17 00:00:00 2001 From: mgravell Date: Tue, 2 Jul 2019 09:11:14 +0100 Subject: [PATCH 0778/1555] add framework overhead "PingBenchmark" --- .../Grpc.Microbenchmarks/PingBenchmark.cs | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/csharp/Grpc.Microbenchmarks/PingBenchmark.cs diff --git a/src/csharp/Grpc.Microbenchmarks/PingBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/PingBenchmark.cs new file mode 100644 index 00000000000..25996fb6868 --- /dev/null +++ b/src/csharp/Grpc.Microbenchmarks/PingBenchmark.cs @@ -0,0 +1,84 @@ +using System.Threading.Tasks; +using BenchmarkDotNet.Attributes; +using Grpc.Core; + +namespace Grpc.Microbenchmarks +{ + // this test creates a real server and client, measuring the inherent inbuilt + // platform overheads; the marshallers **DO NOT ALLOCATE**, so any allocations + // are from the framework, not the messages themselves + + // important: allocs are not reliable on .NET Core until .NET Core 3, since + // this test involves multiple threads + + [ClrJob, CoreJob] // test .NET Core and .NET Framework + [MemoryDiagnoser] // allocations + public class PingBenchmark + { + private static readonly Task CompletedString = Task.FromResult(""); + private static readonly byte[] EmptyBlob = new byte[0]; + private static readonly Marshaller EmptyMarshaller = new Marshaller(_ => EmptyBlob, _ => ""); + private static readonly Method PingMethod = new Method(MethodType.Unary, nameof(PingBenchmark), "Ping", EmptyMarshaller, EmptyMarshaller); + + + [Benchmark] + public async ValueTask PingAsync() + { + using (var result = client.PingAsync("")) + { + return await result.ResponseAsync; + } + } + + [Benchmark] + public string Ping() + { + return client.Ping(""); + } + + private Task ServerMethod(string request, ServerCallContext context) + { + return CompletedString; + } + + Server server; + Channel channel; + PingClient client; + + [GlobalSetup] + public async Task Setup() + { + // create server + server = new Server { + Ports = { new ServerPort("localhost", 10042, ServerCredentials.Insecure) }, + Services = { ServerServiceDefinition.CreateBuilder().AddMethod(PingMethod, ServerMethod).Build() }, + }; + server.Start(); + + // create client + channel = new Channel("localhost", 10042, ChannelCredentials.Insecure); + await channel.ConnectAsync(); + client = new PingClient(new DefaultCallInvoker(channel)); + } + + [GlobalCleanup] + public async Task Cleanup() + { + await channel.ShutdownAsync(); + await server.ShutdownAsync(); + } + + class PingClient : LiteClientBase + { + public PingClient(CallInvoker callInvoker) : base(callInvoker) { } + public AsyncUnaryCall PingAsync(string request, CallOptions options = default) + { + return CallInvoker.AsyncUnaryCall(PingMethod, null, options, request); + } + public string Ping(string request, CallOptions options = default) + { + return CallInvoker.BlockingUnaryCall(PingMethod, null, options, request); + } + } + } +} From ffac31b10830c763c2e04c71d7eaf038e405d318 Mon Sep 17 00:00:00 2001 From: mgravell Date: Tue, 2 Jul 2019 09:30:26 +0100 Subject: [PATCH 0779/1555] incorrectly added --- grpcpp_channelz.vcxproj.filters | 42 --------------------------------- 1 file changed, 42 deletions(-) delete mode 100644 grpcpp_channelz.vcxproj.filters diff --git a/grpcpp_channelz.vcxproj.filters b/grpcpp_channelz.vcxproj.filters deleted file mode 100644 index 9f37e96eb69..00000000000 --- a/grpcpp_channelz.vcxproj.filters +++ /dev/null @@ -1,42 +0,0 @@ - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - CMake Rules - - - - - - {870DBD13-69C5-3F27-A253-623E8947E2E7} - - - {67AA517E-A3B4-3BFF-B690-252465A3B876} - - - {B3AFD131-5BE8-3F8D-8C68-1BD558A25862} - - - From a56998bdffa4ed97615649d5f9e6ba908ced4260 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 2 Jul 2019 03:35:12 -0400 Subject: [PATCH 0780/1555] fix small nits --- src/csharp/Grpc.Microbenchmarks/CommonThreadedBase.cs | 2 +- src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/csharp/Grpc.Microbenchmarks/CommonThreadedBase.cs b/src/csharp/Grpc.Microbenchmarks/CommonThreadedBase.cs index 4b6174eeef8..c6bdf471b8a 100644 --- a/src/csharp/Grpc.Microbenchmarks/CommonThreadedBase.cs +++ b/src/csharp/Grpc.Microbenchmarks/CommonThreadedBase.cs @@ -35,7 +35,7 @@ namespace Grpc.Microbenchmarks { protected virtual bool NeedsEnvironment => true; - [Params(1, 1, 2, 4, 8, 12)] + [Params(1, 2, 4, 8, 12)] public int ThreadCount { get; set; } protected GrpcEnvironment Environment { get; private set; } diff --git a/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs index ac252a95d89..62665925f62 100644 --- a/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs @@ -22,7 +22,7 @@ using Grpc.Core.Internal; namespace Grpc.Microbenchmarks { - public class CompletionRegistryBenchmarks : CommonThreadedBase + public class CompletionRegistryBenchmark : CommonThreadedBase { [Params(false, true)] public bool UseSharedRegistry { get; set; } From 43240238d2eb0b5df40ee0ca5b8c570ad9e4faec Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 2 Jul 2019 07:17:05 -0400 Subject: [PATCH 0781/1555] tweak iteration counts for multithreaded benchmarks --- src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs | 2 +- src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs | 2 +- src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs index 62665925f62..e4cd7eeb1f6 100644 --- a/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs @@ -27,7 +27,7 @@ namespace Grpc.Microbenchmarks [Params(false, true)] public bool UseSharedRegistry { get; set; } - const int Iterations = 1000; + const int Iterations = 1000000; // High number to make the overhead of RunConcurrent negligible. [Benchmark(OperationsPerInvoke = Iterations)] public void RegisterExtract() { diff --git a/src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs index b217aef2068..de4e635580f 100644 --- a/src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs @@ -32,7 +32,7 @@ namespace Grpc.Microbenchmarks [Params(0)] public int PayloadSize { get; set; } - const int Iterations = 1000; + const int Iterations = 1000000; // High number to make the overhead of RunConcurrent negligible. [Benchmark(OperationsPerInvoke = Iterations)] public void AllocFree() { diff --git a/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs index 56ae838a4f4..d9554db00db 100644 --- a/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs @@ -36,7 +36,7 @@ namespace Grpc.Microbenchmarks [Params(0)] public int PayloadSize { get; set; } - const int Iterations = 1000; + const int Iterations = 1000000; // High number to make the overhead of RunConcurrent negligible. [Benchmark(OperationsPerInvoke = Iterations)] public void SendMessage() { From 3ba99a685ed548c236f9bcad3061b34dd6e905b5 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 2 Jul 2019 07:20:28 -0400 Subject: [PATCH 0782/1555] make pingbenchmark compile --- src/csharp/Grpc.Microbenchmarks/PingBenchmark.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/csharp/Grpc.Microbenchmarks/PingBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/PingBenchmark.cs index 25996fb6868..f22c52c8927 100644 --- a/src/csharp/Grpc.Microbenchmarks/PingBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/PingBenchmark.cs @@ -24,7 +24,7 @@ namespace Grpc.Microbenchmarks [Benchmark] public async ValueTask PingAsync() { - using (var result = client.PingAsync("")) + using (var result = client.PingAsync("", new CallOptions())) { return await result.ResponseAsync; } @@ -33,7 +33,7 @@ namespace Grpc.Microbenchmarks [Benchmark] public string Ping() { - return client.Ping(""); + return client.Ping("", new CallOptions()); } private Task ServerMethod(string request, ServerCallContext context) @@ -71,11 +71,11 @@ namespace Grpc.Microbenchmarks class PingClient : LiteClientBase { public PingClient(CallInvoker callInvoker) : base(callInvoker) { } - public AsyncUnaryCall PingAsync(string request, CallOptions options = default) + public AsyncUnaryCall PingAsync(string request, CallOptions options) { return CallInvoker.AsyncUnaryCall(PingMethod, null, options, request); } - public string Ping(string request, CallOptions options = default) + public string Ping(string request, CallOptions options) { return CallInvoker.BlockingUnaryCall(PingMethod, null, options, request); } From 47287e8ed7c3d458bbbf326a2434621c20526fdc Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 2 Jul 2019 08:02:23 -0400 Subject: [PATCH 0783/1555] add license headers --- .../Grpc.Microbenchmarks/PingBenchmark.cs | 18 ++++++++++++++++++ src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs | 18 ++++++++++++++++++ src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs | 18 ++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/src/csharp/Grpc.Microbenchmarks/PingBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/PingBenchmark.cs index f22c52c8927..3949040aac0 100644 --- a/src/csharp/Grpc.Microbenchmarks/PingBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/PingBenchmark.cs @@ -1,3 +1,21 @@ +#region Copyright notice and license + +// Copyright 2019 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + using System.Threading.Tasks; using BenchmarkDotNet.Attributes; using Grpc.Core; diff --git a/src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs b/src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs index 5c5c927a260..70bbae6f400 100644 --- a/src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs +++ b/src/csharp/Grpc.Microbenchmarks/Utf8Decode.cs @@ -1,3 +1,21 @@ +#region Copyright notice and license + +// Copyright 2019 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + using System; using System.Collections.Generic; using System.Text; diff --git a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs index 95e7ad45841..3eddb33788a 100644 --- a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs +++ b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs @@ -1,3 +1,21 @@ +#region Copyright notice and license + +// Copyright 2019 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + using System; using System.Collections.Generic; using BenchmarkDotNet.Attributes; From 6f315691da46b12d1b1728fd8643e36e2de97a78 Mon Sep 17 00:00:00 2001 From: mgravell Date: Tue, 2 Jul 2019 13:57:50 +0100 Subject: [PATCH 0784/1555] remove boxing of Timespec caused by Equals usage --- src/csharp/Grpc.Core/Internal/Timespec.cs | 44 ++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/csharp/Grpc.Core/Internal/Timespec.cs b/src/csharp/Grpc.Core/Internal/Timespec.cs index 71628d50642..ac7b2f720fe 100644 --- a/src/csharp/Grpc.Core/Internal/Timespec.cs +++ b/src/csharp/Grpc.Core/Internal/Timespec.cs @@ -25,8 +25,50 @@ namespace Grpc.Core.Internal /// gpr_timespec from grpc/support/time.h /// [StructLayout(LayoutKind.Sequential)] - internal struct Timespec + internal struct Timespec : IEquatable { + /// + /// Indicates whether this instance and a specified object are equal. + /// + public override bool Equals(object obj) + { + return obj is Timespec && Equals((Timespec)obj); + } + + /// + /// Returns the hash code for this instance. + /// + public override int GetHashCode() + { + unchecked + { + const int Prime = 373587911; + int i = (int)clock_type; + i = (i * Prime) ^ tv_nsec; + i = (i * Prime) ^ tv_nsec.GetHashCode(); + return i; + } + } + + /// + /// Returns the full type name of this instance. + /// + public override string ToString() + { + base.ToString(); + return typeof(Timespec).FullName; + } + + /// + /// Indicates whether this instance and a specified object are equal. + /// + public bool Equals(Timespec other) + { + return this.clock_type == other.clock_type + && this.tv_nsec == other.tv_nsec + && this.tv_sec == other.tv_sec; + } + const long NanosPerSecond = 1000 * 1000 * 1000; const long NanosPerTick = 100; const long TicksPerSecond = NanosPerSecond / NanosPerTick; From 746287111d207445289b6cd06a03ecf662dd3e16 Mon Sep 17 00:00:00 2001 From: mgravell Date: Tue, 2 Jul 2019 14:05:50 +0100 Subject: [PATCH 0785/1555] (left a base-call in that I'd used to get the intellisense comment) --- src/csharp/Grpc.Core/Internal/Timespec.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/csharp/Grpc.Core/Internal/Timespec.cs b/src/csharp/Grpc.Core/Internal/Timespec.cs index ac7b2f720fe..0edaffb9f49 100644 --- a/src/csharp/Grpc.Core/Internal/Timespec.cs +++ b/src/csharp/Grpc.Core/Internal/Timespec.cs @@ -55,7 +55,6 @@ namespace Grpc.Core.Internal /// public override string ToString() { - base.ToString(); return typeof(Timespec).FullName; } From 36ecd052f6e8a7fb07cf026d63ea462033033af8 Mon Sep 17 00:00:00 2001 From: mgravell Date: Tue, 2 Jul 2019 14:20:09 +0100 Subject: [PATCH 0786/1555] avoid capture-context in HandleNewServerRpc => HandleCallAsync --- src/csharp/Grpc.Core/Server.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/csharp/Grpc.Core/Server.cs b/src/csharp/Grpc.Core/Server.cs index 26d182ae53b..81b4b59528b 100644 --- a/src/csharp/Grpc.Core/Server.cs +++ b/src/csharp/Grpc.Core/Server.cs @@ -334,7 +334,7 @@ namespace Grpc.Core /// /// Selects corresponding handler for given call and handles the call. /// - private async Task HandleCallAsync(ServerRpcNew newRpc, CompletionQueueSafeHandle cq, Action continuation) + private async Task HandleCallAsync(ServerRpcNew newRpc, CompletionQueueSafeHandle cq, Action continuation) { try { @@ -351,7 +351,7 @@ namespace Grpc.Core } finally { - continuation(); + continuation(cq); } } @@ -374,7 +374,7 @@ namespace Grpc.Core // Don't await, the continuations will run on gRPC thread pool once triggered // by cq.Next(). #pragma warning disable 4014 - HandleCallAsync(newRpc, cq, () => AllowOneRpc(cq)); + HandleCallAsync(newRpc, cq, state => AllowOneRpc(state)); #pragma warning restore 4014 } } From 834a3d29a656b5f1e2313e1608bc6f60c2fd21cd Mon Sep 17 00:00:00 2001 From: mgravell Date: Tue, 2 Jul 2019 14:24:24 +0100 Subject: [PATCH 0787/1555] capture the server too --- src/csharp/Grpc.Core/Server.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/csharp/Grpc.Core/Server.cs b/src/csharp/Grpc.Core/Server.cs index 81b4b59528b..8705f52666f 100644 --- a/src/csharp/Grpc.Core/Server.cs +++ b/src/csharp/Grpc.Core/Server.cs @@ -334,7 +334,7 @@ namespace Grpc.Core /// /// Selects corresponding handler for given call and handles the call. /// - private async Task HandleCallAsync(ServerRpcNew newRpc, CompletionQueueSafeHandle cq, Action continuation) + private async Task HandleCallAsync(ServerRpcNew newRpc, CompletionQueueSafeHandle cq, Action continuation) { try { @@ -351,7 +351,7 @@ namespace Grpc.Core } finally { - continuation(cq); + continuation(this, cq); } } @@ -374,7 +374,7 @@ namespace Grpc.Core // Don't await, the continuations will run on gRPC thread pool once triggered // by cq.Next(). #pragma warning disable 4014 - HandleCallAsync(newRpc, cq, state => AllowOneRpc(state)); + HandleCallAsync(newRpc, cq, (server, state) => server.AllowOneRpc(state)); #pragma warning restore 4014 } } From 264fca1eb6f0bc5118986c38bf53d39bbe02bf7a Mon Sep 17 00:00:00 2001 From: mgravell Date: Tue, 2 Jul 2019 15:40:36 +0100 Subject: [PATCH 0788/1555] match delegate signature in benchmark --- src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs index 3eddb33788a..990f6fbb48e 100644 --- a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs +++ b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs @@ -61,11 +61,14 @@ namespace Grpc.Microbenchmarks var native = NativeMethods.Get(); // nop the native-call via reflection - NativeMethods.Delegates.grpcsharp_call_send_status_from_server_delegate nop = (CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, byte[] statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags) => { - completionRegistry.Extract(ctx.Handle).OnComplete(true); // drain the dictionary as we go - return CallError.OK; - }; - native.GetType().GetField(nameof(native.grpcsharp_call_send_status_from_server)).SetValue(native, nop); + unsafe + { + NativeMethods.Delegates.grpcsharp_call_send_status_from_server_delegate nop = (CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, byte* statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags) => { + completionRegistry.Extract(ctx.Handle).OnComplete(true); // drain the dictionary as we go + return CallError.OK; + }; + native.GetType().GetField(nameof(native.grpcsharp_call_send_status_from_server)).SetValue(native, nop); + } environment = GrpcEnvironment.AddRef(); metadata = MetadataArraySafeHandle.Create(Metadata.Empty); From e95f3297aa3b7b52912e95f6fbe713af1c8328ba Mon Sep 17 00:00:00 2001 From: mgravell Date: Tue, 2 Jul 2019 16:37:13 +0100 Subject: [PATCH 0789/1555] don't allocate/copy a buffer in ReadMetadataFromPtrUnsafe unless we actually need to (move that logic to CreateUnsafe); implement well-known strings check (just "user-agent" at the moment) --- src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj | 3 +- src/csharp/Grpc.Core.Api/Metadata.cs | 36 ++++++++++++-- .../Grpc.Core.Tests/Grpc.Core.Tests.csproj | 3 +- src/csharp/Grpc.Core.Tests/MetadataTest.cs | 30 +++++++----- .../Internal/MetadataArraySafeHandle.cs | 47 ++++++++++++++++--- 5 files changed, 95 insertions(+), 24 deletions(-) diff --git a/src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj b/src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj index 8a32bc757df..0a958299ec8 100755 --- a/src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj +++ b/src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj @@ -1,4 +1,4 @@ - + @@ -11,6 +11,7 @@ https://github.com/grpc/grpc gRPC RPC HTTP/2 $(GrpcCsharpVersion) + true diff --git a/src/csharp/Grpc.Core.Api/Metadata.cs b/src/csharp/Grpc.Core.Api/Metadata.cs index 27e72fbfa8b..7a04a2ee859 100644 --- a/src/csharp/Grpc.Core.Api/Metadata.cs +++ b/src/csharp/Grpc.Core.Api/Metadata.cs @@ -17,6 +17,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Text; using System.Text.RegularExpressions; @@ -345,15 +346,44 @@ namespace Grpc.Core /// Creates a binary value or ascii value metadata entry from data received from the native layer. /// We trust C core to give us well-formed data, so we don't perform any checks or defensive copying. /// - internal static Entry CreateUnsafe(string key, byte[] valueBytes) + internal static unsafe Entry CreateUnsafe(string key, byte* source, int length) { if (HasBinaryHeaderSuffix(key)) { - return new Entry(key, null, valueBytes); + byte[] arr; + if (length == 0) + { + arr = EmptyBlob; + } + else + { // create a local copy in a fresh array + arr = new byte[length]; + Marshal.Copy(new IntPtr(source), arr, 0, length); + } + return new Entry(key, null, arr); + } + else + { + string s; + if (length == 0) + { + s = ""; + } + else + { + int charCount = EncodingASCII.GetCharCount(source, length); + s = new string('\0', charCount); + fixed (char* cPtr = s) + { + EncodingASCII.GetChars(source, length, cPtr, charCount); + } + } + return new Entry(key, s, null); } - return new Entry(key, EncodingASCII.GetString(valueBytes), null); } + static readonly byte[] EmptyBlob = new byte[0]; + private static string NormalizeKey(string key) { GrpcPreconditions.CheckNotNull(key, "key"); diff --git a/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj b/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj index 7fef2c77091..693646bea1c 100755 --- a/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj +++ b/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj @@ -1,4 +1,4 @@ - + @@ -6,6 +6,7 @@ net45;netcoreapp2.1 Exe true + true diff --git a/src/csharp/Grpc.Core.Tests/MetadataTest.cs b/src/csharp/Grpc.Core.Tests/MetadataTest.cs index d85d7572a63..7286f9c9932 100644 --- a/src/csharp/Grpc.Core.Tests/MetadataTest.cs +++ b/src/csharp/Grpc.Core.Tests/MetadataTest.cs @@ -111,25 +111,31 @@ namespace Grpc.Core.Tests } [Test] - public void Entry_CreateUnsafe_Ascii() + public unsafe void Entry_CreateUnsafe_Ascii() { var bytes = new byte[] { (byte)'X', (byte)'y' }; - var entry = Metadata.Entry.CreateUnsafe("abc", bytes); - Assert.IsFalse(entry.IsBinary); - Assert.AreEqual("abc", entry.Key); - Assert.AreEqual("Xy", entry.Value); - CollectionAssert.AreEqual(bytes, entry.ValueBytes); + fixed (byte* ptr = bytes) + { + var entry = Metadata.Entry.CreateUnsafe("abc", ptr, bytes.Length); + Assert.IsFalse(entry.IsBinary); + Assert.AreEqual("abc", entry.Key); + Assert.AreEqual("Xy", entry.Value); + CollectionAssert.AreEqual(bytes, entry.ValueBytes); + } } [Test] - public void Entry_CreateUnsafe_Binary() + public unsafe void Entry_CreateUnsafe_Binary() { var bytes = new byte[] { 1, 2, 3 }; - var entry = Metadata.Entry.CreateUnsafe("abc-bin", bytes); - Assert.IsTrue(entry.IsBinary); - Assert.AreEqual("abc-bin", entry.Key); - Assert.Throws(typeof(InvalidOperationException), () => { var v = entry.Value; }); - CollectionAssert.AreEqual(bytes, entry.ValueBytes); + fixed (byte* ptr = bytes) + { + var entry = Metadata.Entry.CreateUnsafe("abc-bin", ptr, bytes.Length); + Assert.IsTrue(entry.IsBinary); + Assert.AreEqual("abc-bin", entry.Key); + Assert.Throws(typeof(InvalidOperationException), () => { var v = entry.Value; }); + CollectionAssert.AreEqual(bytes, entry.ValueBytes); + } } [Test] diff --git a/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs b/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs index 13fde68fe0f..1663a9d44ac 100644 --- a/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs @@ -15,8 +15,7 @@ #endregion using System; using System.Runtime.InteropServices; -using System.Threading.Tasks; -using Grpc.Core.Profiling; +using System.Text; namespace Grpc.Core.Internal { @@ -51,7 +50,7 @@ namespace Grpc.Core.Internal /// /// Reads metadata from pointer to grpc_metadata_array /// - public static Metadata ReadMetadataFromPtrUnsafe(IntPtr metadataArray) + public static unsafe Metadata ReadMetadataFromPtrUnsafe(IntPtr metadataArray) { if (metadataArray == IntPtr.Zero) { @@ -66,16 +65,50 @@ namespace Grpc.Core.Internal var index = new UIntPtr(i); UIntPtr keyLen; IntPtr keyPtr = Native.grpcsharp_metadata_array_get_key(metadataArray, index, out keyLen); - string key = Marshal.PtrToStringAnsi(keyPtr, (int)keyLen.ToUInt32()); + int keyLen32 = checked((int)keyLen.ToUInt32()); + string key = WellKnownStrings.TryIdentify((byte*)keyPtr.ToPointer(), keyLen32) + ?? Marshal.PtrToStringAnsi(keyPtr, keyLen32); UIntPtr valueLen; IntPtr valuePtr = Native.grpcsharp_metadata_array_get_value(metadataArray, index, out valueLen); - var bytes = new byte[valueLen.ToUInt64()]; - Marshal.Copy(valuePtr, bytes, 0, bytes.Length); - metadata.Add(Metadata.Entry.CreateUnsafe(key, bytes)); + int len32 = checked((int)valueLen.ToUInt64()); + metadata.Add(Metadata.Entry.CreateUnsafe(key, (byte*)valuePtr.ToPointer(), len32)); } return metadata; } + private static class WellKnownStrings + { + // turn a string of ASCII-length 8 into a ulong using the CPUs current + // endianness; this allows us to do the same thing in TryIdentify, + // testing string prefixes (of length >= 8) in a single load/compare + private static unsafe ulong Thunk8(string value) + { + int byteCount = Encoding.ASCII.GetByteCount(value); + if (byteCount != 8) throw new ArgumentException(nameof(value)); + ulong result = 0; + fixed (char* cPtr = value) + { + Encoding.ASCII.GetBytes(cPtr, value.Length, (byte*)&result, byteCount); + } + return result; + } + private static readonly ulong UserAgent = Thunk8("user-age"); + public static unsafe string TryIdentify(byte* source, int length) + { + switch (length) + { + case 10: + // test the first 8 bytes via evilness + ulong first8 = *(ulong*)source; + if (first8 == UserAgent & source[8] == (byte)'n' & source[9] == (byte)'t') + return "user-agent"; + + break; + } + return null; + } + } + internal IntPtr Handle { get From be186ac8d93385c725f0b5403f9bb703aed95480 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Tue, 2 Jul 2019 09:55:31 -0700 Subject: [PATCH 0790/1555] Fix guards name --- src/core/lib/iomgr/executor/threadpool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/executor/threadpool.h b/src/core/lib/iomgr/executor/threadpool.h index d0822fadc8b..b0dfa37383b 100644 --- a/src/core/lib/iomgr/executor/threadpool.h +++ b/src/core/lib/iomgr/executor/threadpool.h @@ -149,4 +149,4 @@ class ThreadPool : public ThreadPoolInterface { } // namespace grpc_core -#endif /* GRPC_CORE_LIB_IOMGR_THREADPOOL_THREADPOOL_H */ +#endif /* GRPC_CORE_LIB_IOMGR_EXECUTOR_THREADPOOL_H */ From 1e46a3ab627d9408a02efd5ce63e8e0a5e791977 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 2 Jul 2019 10:15:56 -0700 Subject: [PATCH 0791/1555] Bump version to v1.22.0 --- BUILD | 2 +- build.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index 0ca0d9b7fd8..f08703a2752 100644 --- a/BUILD +++ b/BUILD @@ -78,7 +78,7 @@ g_stands_for = "gale" core_version = "7.0.0" -version = "1.22.0-pre1" +version = "1.22.0" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index cce7d1bbe5c..d04ffcf3389 100644 --- a/build.yaml +++ b/build.yaml @@ -14,7 +14,7 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 7.0.0 g_stands_for: gale - version: 1.22.0-pre1 + version: 1.22.0 filegroups: - name: alts_proto headers: From 1399d06276a31a7275d52d082a8d25e045aca4db Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 2 Jul 2019 10:16:36 -0700 Subject: [PATCH 0792/1555] Regenerate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 6 +++--- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 8 ++++---- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 2 +- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 29 files changed, 35 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b449e353a9a..5b330d443c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.22.0-pre1") +set(PACKAGE_VERSION "1.22.0") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 0b1a9259d91..d80d72b7d9f 100644 --- a/Makefile +++ b/Makefile @@ -460,8 +460,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.22.0-pre1 -CSHARP_VERSION = 1.22.0-pre1 +CPP_VERSION = 1.22.0 +CSHARP_VERSION = 1.22.0 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 4cdf65fcc99..65c4ec5159b 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,15 +23,15 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.22.0-pre1' - version = '0.0.9-pre1' + # version = '1.22.0' + version = '0.0.9' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.22.0-pre1' + grpc_version = '1.22.0' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index a40c9511fd2..c7ffda130de 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.22.0-pre1' + version = '1.22.0' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 00609603438..2ebcf2d2fd3 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.22.0-pre1' + version = '1.22.0' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index b3423e97791..cc4d710a4dd 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.22.0-pre1' + version = '1.22.0' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index 7b13447ff3f..4f6e823b05a 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.22.0-pre1' + version = '1.22.0' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index 01ed99d0f91..0314e8982bc 100644 --- a/package.xml +++ b/package.xml @@ -13,12 +13,12 @@ 2018-01-19 - 1.22.0RC1 - 1.22.0RC1 + 1.22.0 + 1.22.0 - beta - beta + stable + stable Apache 2.0 diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index ebd4f7ef023..c04c12b1728 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.22.0-pre1"; } +grpc::string Version() { return "1.22.0"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index a9b73c24c27..40ad442402c 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -38,6 +38,6 @@ namespace Grpc.Core /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.22.0-pre1"; + public const string CurrentVersion = "1.22.0"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index 662ac407713..62b8685eecb 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 1.22.0-pre1 + 1.22.0 3.7.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index b2f855e10e7..8c58c2fff7c 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=1.22.0-pre1 +set VERSION=1.22.0 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 2769bb3e4e3..c4e9c23d20f 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.22.0-pre1' + v = '1.22.0' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 05829ac102c..a162f1b1292 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.22.0-pre1" +#define GRPC_OBJC_VERSION_STRING @"1.22.0" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 68ea0849659..37db5da9560 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.22.0-pre1" +#define GRPC_OBJC_VERSION_STRING @"1.22.0" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 4ebb30d2ff5..d4e0bbcc385 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.22.0RC1" +#define PHP_GRPC_VERSION "1.22.0" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index fa594107fec..b76cdd33908 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.22.0rc1""" +__version__ = """1.22.0""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index e878336b40c..7c5eca53ed9 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.22.0rc1' +VERSION = '1.22.0' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index edd2b36e5d3..29ee7f8aaa5 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.22.0rc1' +VERSION = '1.22.0' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index 44b59737fd9..8bae17b37fa 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.22.0rc1' +VERSION = '1.22.0' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 02fc7b80423..d1e46f67036 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.22.0rc1' +VERSION = '1.22.0' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index 0b70be2fd4b..583b2d9c920 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.22.0rc1' +VERSION = '1.22.0' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 21c75d294e8..c8ff0b0a77a 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.22.0rc1' +VERSION = '1.22.0' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index 2bb40b514a6..2edf51569f8 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.22.0rc1' +VERSION = '1.22.0' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 5e6d6de685a..c80fb62961a 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.22.0.pre1' + VERSION = '1.22.0' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index e86c6330a70..f6c3dfaa05d 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.22.0.pre1' + VERSION = '1.22.0' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 810493f00da..69c53da15cf 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.22.0rc1' +VERSION = '1.22.0' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 2de0dbb9af7..f43cff4de0b 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.22.0-pre1 +PROJECT_NUMBER = 1.22.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index ba8a287104a..29c7901c48c 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.22.0-pre1 +PROJECT_NUMBER = 1.22.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From a63cbfb61e393e077cca39101fb3490253f3ec90 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Tue, 2 Jul 2019 10:25:22 -0700 Subject: [PATCH 0793/1555] Fix headers order --- src/core/lib/iomgr/executor/threadpool.h | 3 ++- test/cpp/microbenchmarks/bm_threadpool.cc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/executor/threadpool.h b/src/core/lib/iomgr/executor/threadpool.h index b0dfa37383b..2ea1d5fcef4 100644 --- a/src/core/lib/iomgr/executor/threadpool.h +++ b/src/core/lib/iomgr/executor/threadpool.h @@ -19,9 +19,10 @@ #ifndef GRPC_CORE_LIB_IOMGR_EXECUTOR_THREADPOOL_H #define GRPC_CORE_LIB_IOMGR_EXECUTOR_THREADPOOL_H -#include #include +#include + #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/executor/mpmcqueue.h" diff --git a/test/cpp/microbenchmarks/bm_threadpool.cc b/test/cpp/microbenchmarks/bm_threadpool.cc index b4ebcdaaf92..601108aacab 100644 --- a/test/cpp/microbenchmarks/bm_threadpool.cc +++ b/test/cpp/microbenchmarks/bm_threadpool.cc @@ -16,11 +16,12 @@ * */ +#include "src/core/lib/iomgr/executor/threadpool.h" + #include #include -#include "src/core/lib/iomgr/executor/threadpool.h" #include "test/cpp/microbenchmarks/helpers.h" #include "test/cpp/util/test_config.h" From 64871bfea254b7694518438920c3376b97235754 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Tue, 2 Jul 2019 14:30:34 -0400 Subject: [PATCH 0794/1555] Revert "Fix stale comment in split host port." This reverts commit bf9b4c257bdd5f5765fcd9b6c9402d170f75fea8. --- src/core/lib/gprpp/host_port.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/lib/gprpp/host_port.cc b/src/core/lib/gprpp/host_port.cc index e7f0e4461e9..3fa4719f49a 100644 --- a/src/core/lib/gprpp/host_port.cc +++ b/src/core/lib/gprpp/host_port.cc @@ -105,9 +105,8 @@ bool SplitHostPort(StringView name, UniquePtr* host, bool has_port; const bool ret = DoSplitHostPort(name, &host_view, &port_view, &has_port); if (ret) { - // We always set the host, but port is set only when DoSplitHostPort find a - // port in the string, to remain backward compatible with the old - // gpr_split_host_port API. + // We always set the host, but port is set only when it's non-empty, + // to remain backward compatible with the old split_host_port API. *host = host_view.dup(); if (has_port) { *port = port_view.dup(); From 6376cc9b8f4c1b684ac6b551cb9a8ea1705acd5a Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Tue, 2 Jul 2019 14:30:41 -0400 Subject: [PATCH 0795/1555] Revert "Return empty strings on optional ports for backward compatibility." This reverts commit 01b82d3a39f2d4455025e9176dae7917a82babb2. --- src/core/lib/gprpp/host_port.cc | 18 +++--------------- test/core/gprpp/host_port_test.cc | 2 -- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/core/lib/gprpp/host_port.cc b/src/core/lib/gprpp/host_port.cc index 3fa4719f49a..13b63eb902b 100644 --- a/src/core/lib/gprpp/host_port.cc +++ b/src/core/lib/gprpp/host_port.cc @@ -44,10 +44,7 @@ int JoinHostPort(UniquePtr* out, const char* host, int port) { return ret; } -namespace { -bool DoSplitHostPort(StringView name, StringView* host, StringView* port, - bool* has_port) { - *has_port = false; +bool SplitHostPort(StringView name, StringView* host, StringView* port) { if (name[0] == '[') { /* Parse a bracketed host, typically an IPv6 literal. */ const size_t rbracket = name.find(']', 1); @@ -61,7 +58,6 @@ bool DoSplitHostPort(StringView name, StringView* host, StringView* port, } else if (name[rbracket + 1] == ':') { /* ]: */ *port = name.substr(rbracket + 2, name.size() - rbracket - 2); - *has_port = true; } else { /* ] */ return false; @@ -80,7 +76,6 @@ bool DoSplitHostPort(StringView name, StringView* host, StringView* port, /* Exactly 1 colon. Split into host:port. */ *host = name.substr(0, colon); *port = name.substr(colon + 1, name.size() - colon - 1); - *has_port = true; } else { /* 0 or 2+ colons. Bare hostname or IPv6 litearal. */ *host = name; @@ -89,12 +84,6 @@ bool DoSplitHostPort(StringView name, StringView* host, StringView* port, } return true; } -} // namespace - -bool SplitHostPort(StringView name, StringView* host, StringView* port) { - bool unused; - return DoSplitHostPort(name, host, port, &unused); -} bool SplitHostPort(StringView name, UniquePtr* host, UniquePtr* port) { @@ -102,13 +91,12 @@ bool SplitHostPort(StringView name, UniquePtr* host, GPR_DEBUG_ASSERT(port != nullptr && *port == nullptr); StringView host_view; StringView port_view; - bool has_port; - const bool ret = DoSplitHostPort(name, &host_view, &port_view, &has_port); + const bool ret = SplitHostPort(name, &host_view, &port_view); if (ret) { // We always set the host, but port is set only when it's non-empty, // to remain backward compatible with the old split_host_port API. *host = host_view.dup(); - if (has_port) { + if (!port_view.empty()) { *port = port_view.dup(); } } diff --git a/test/core/gprpp/host_port_test.cc b/test/core/gprpp/host_port_test.cc index cfe0eddb036..3b392da66e8 100644 --- a/test/core/gprpp/host_port_test.cc +++ b/test/core/gprpp/host_port_test.cc @@ -71,9 +71,7 @@ static void test_split_host_port() { split_host_port_expect("", "", nullptr, true); split_host_port_expect("[a:b]", "a:b", nullptr, true); split_host_port_expect("1.2.3.4", "1.2.3.4", nullptr, true); - split_host_port_expect("0.0.0.0:", "0.0.0.0", "", true); split_host_port_expect("a:b:c::", "a:b:c::", nullptr, true); - split_host_port_expect("[a:b:c::]:", "a:b:c::", "", true); split_host_port_expect("[a:b]:30", "a:b", "30", true); split_host_port_expect("1.2.3.4:30", "1.2.3.4", "30", true); split_host_port_expect(":30", "", "30", true); From def083b2c84f03d588bf0f9e75323f270c549676 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Tue, 2 Jul 2019 14:37:54 -0400 Subject: [PATCH 0796/1555] Clearly callout the behavior for listening ports. This is to clarify that the port number is a required part of the listening address. --- include/grpcpp/server_builder_impl.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/grpcpp/server_builder_impl.h b/include/grpcpp/server_builder_impl.h index 7f85e807d07..9c69adc9147 100644 --- a/include/grpcpp/server_builder_impl.h +++ b/include/grpcpp/server_builder_impl.h @@ -112,6 +112,10 @@ class ServerBuilder { /// /// It can be invoked multiple times. /// + /// If port is not provided in the \a addr (e.g., "1.2.3.4:" or "1.2.3.4"), + /// the default port (i.e., https) is used. To request an ephemeral port, + /// \a addr must include 0 as the port number (e.g., "1.2.3.4:0"). + /// /// \param addr_uri The address to try to bind to the server in URI form. If /// the scheme name is omitted, "dns:///" is assumed. To bind to any address, /// please use IPv6 any, i.e., [::]:, which also accepts IPv4 From f757028ea41b7d6ddb46de4da6e3030da0bdbceb Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 2 Jul 2019 11:54:57 -0700 Subject: [PATCH 0797/1555] Sched combiner closures instead of running to avoid data races --- .../transport/chttp2/transport/chttp2_transport.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 48c3d002bbd..b05a48a6a0c 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -1232,10 +1232,10 @@ static grpc_closure* add_closure_barrier(grpc_closure* closure) { return closure; } -static void null_then_run_closure(grpc_closure** closure, grpc_error* error) { +static void null_then_sched_closure(grpc_closure** closure, grpc_error* error) { grpc_closure* c = *closure; *closure = nullptr; - GRPC_CLOSURE_RUN(c, error); + GRPC_CLOSURE_SCHED(c, error); } void grpc_chttp2_complete_closure_step(grpc_chttp2_transport* t, @@ -1902,7 +1902,7 @@ void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_chttp2_transport* t, } grpc_chttp2_incoming_metadata_buffer_publish(&s->metadata_buffer[0], s->recv_initial_metadata); - null_then_run_closure(&s->recv_initial_metadata_ready, GRPC_ERROR_NONE); + null_then_sched_closure(&s->recv_initial_metadata_ready, GRPC_ERROR_NONE); } } @@ -1982,10 +1982,10 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_chttp2_transport* t, s->unprocessed_incoming_frames_buffer_cached_length = s->unprocessed_incoming_frames_buffer.length; if (error == GRPC_ERROR_NONE && *s->recv_message != nullptr) { - null_then_run_closure(&s->recv_message_ready, GRPC_ERROR_NONE); + null_then_sched_closure(&s->recv_message_ready, GRPC_ERROR_NONE); } else if (s->published_metadata[1] != GRPC_METADATA_NOT_PUBLISHED) { *s->recv_message = nullptr; - null_then_run_closure(&s->recv_message_ready, GRPC_ERROR_NONE); + null_then_sched_closure(&s->recv_message_ready, GRPC_ERROR_NONE); } GRPC_ERROR_UNREF(error); } @@ -2051,8 +2051,8 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_chttp2_transport* t, s->collecting_stats = nullptr; grpc_chttp2_incoming_metadata_buffer_publish(&s->metadata_buffer[1], s->recv_trailing_metadata); - null_then_run_closure(&s->recv_trailing_metadata_finished, - GRPC_ERROR_NONE); + null_then_sched_closure(&s->recv_trailing_metadata_finished, + GRPC_ERROR_NONE); } } } From d8c01823606f5ff1597b3316183c01ceef57c49a Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Tue, 2 Jul 2019 12:32:14 -0700 Subject: [PATCH 0798/1555] Expose some of the internal codegen interfaces --- include/grpcpp/impl/codegen/async_stream.h | 30 ++++++++++++++ .../grpcpp/impl/codegen/async_unary_call.h | 10 +++++ include/grpcpp/impl/codegen/client_callback.h | 12 ++++++ include/grpcpp/impl/codegen/sync_stream.h | 39 +++++++++++++++++++ third_party/googletest | 2 +- third_party/protobuf | 2 +- 6 files changed, 93 insertions(+), 2 deletions(-) diff --git a/include/grpcpp/impl/codegen/async_stream.h b/include/grpcpp/impl/codegen/async_stream.h index 14dfe67962e..d76a8982a4b 100644 --- a/include/grpcpp/impl/codegen/async_stream.h +++ b/include/grpcpp/impl/codegen/async_stream.h @@ -22,6 +22,20 @@ #include namespace grpc { + +namespace internal { + +typedef ::grpc_impl::internal::ClientAsyncStreamingInterface + ClientAsyncStreamingInterface; + +template +using AsyncReaderInterface = ::grpc_impl::internal::AsyncReaderInterface; + +template +using AsyncWriterInterface = ::grpc_impl::internal::AsyncWriterInterface; + +} // namespace internal + template using ClientAsyncReaderInterface = ::grpc_impl::ClientAsyncReaderInterface; @@ -60,6 +74,22 @@ using ServerAsyncReaderWriterInterface = template using ServerAsyncReaderWriter = ::grpc_impl::ServerAsyncReaderWriter; + +namespace internal { +template +using ClientAsyncReaderFactory = + ::grpc_impl::internal::ClientAsyncReaderFactory; + +template +using ClientAsyncWriterFactory = + ::grpc_impl::internal::ClientAsyncWriterFactory; + +template +using ClientAsyncReaderWriterFactory = + ::grpc_impl::internal::ClientAsyncReaderWriterFactory; + +} // namespace internal + } // namespace grpc #endif // GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H diff --git a/include/grpcpp/impl/codegen/async_unary_call.h b/include/grpcpp/impl/codegen/async_unary_call.h index 64ee17dec0d..cbbe70172c8 100644 --- a/include/grpcpp/impl/codegen/async_unary_call.h +++ b/include/grpcpp/impl/codegen/async_unary_call.h @@ -22,15 +22,25 @@ #include namespace grpc { + template using ClientAsyncResponseReaderInterface = grpc_impl::ClientAsyncResponseReaderInterface; + template using ClientAsyncResponseReader = grpc_impl::ClientAsyncResponseReader; template using ServerAsyncResponseWriter = ::grpc_impl::ServerAsyncResponseWriter; +namespace internal { + +template +using ClientAsyncResponseReaderFactory = + ::grpc_impl::internal::ClientAsyncResponseReaderFactory; + +} // namespace internal + } // namespace grpc #endif // GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_H diff --git a/include/grpcpp/impl/codegen/client_callback.h b/include/grpcpp/impl/codegen/client_callback.h index 4f60741624a..9d183725b57 100644 --- a/include/grpcpp/impl/codegen/client_callback.h +++ b/include/grpcpp/impl/codegen/client_callback.h @@ -24,6 +24,18 @@ namespace grpc { namespace experimental { +template +using ClientCallbackReader = + ::grpc_impl::experimental::ClientCallbackReader; + +template +using ClientCallbackWriter = + ::grpc_impl::experimental::ClientCallbackWriter; + +template +using ClientCallbackReaderWriter = + ::grpc_impl::experimental::ClientCallbackReaderWriter; + template using ClientReadReactor = ::grpc_impl::experimental::ClientReadReactor; diff --git a/include/grpcpp/impl/codegen/sync_stream.h b/include/grpcpp/impl/codegen/sync_stream.h index cd447d7c5a5..852fe6676bf 100644 --- a/include/grpcpp/impl/codegen/sync_stream.h +++ b/include/grpcpp/impl/codegen/sync_stream.h @@ -22,36 +22,75 @@ #include namespace grpc { + +namespace internal { + +typedef ::grpc_impl::internal::ClientStreamingInterface + ClientStreamingInterface; + +typedef ::grpc_impl::internal::ServerStreamingInterface + ServerStreamingInterface; + +template +using ReaderInterface = ::grpc_impl::internal::ReaderInterface; + +template +using WriterInterface = ::grpc_impl::internal::WriterInterface; + +template +using ClientReaderFactory = ::grpc_impl::internal::ClientReaderFactory; + +template +using ClientWriterFactory = ::grpc_impl::internal::ClientWriterFactory; + +template +using ClientReaderWriterFactory = + ::grpc_impl::internal::ClientReaderWriterFactory; + +} // namespace internal + template using ClientReaderInterface = ::grpc_impl::ClientReaderInterface; template using ClientReader = ::grpc_impl::ClientReader; + template using ClientWriterInterface = ::grpc_impl::ClientWriterInterface; + template using ClientWriter = ::grpc_impl::ClientWriter; + template using ClientReaderWriterInterface = ::grpc_impl::ClientReaderWriterInterface; + template using ClientReaderWriter = ::grpc_impl::ClientReaderWriter; + template using ServerReaderInterface = ::grpc_impl::ServerReaderInterface; + template using ServerReader = ::grpc_impl::ServerReader; + template using ServerWriterInterface = ::grpc_impl::ServerWriterInterface; + template using ServerWriter = ::grpc_impl::ServerWriter; + template using ServerReaderWriterInterface = ::grpc_impl::ServerReaderWriterInterface; + template using ServerReaderWriter = ::grpc_impl::ServerReaderWriter; + template using ServerUnaryStreamer = ::grpc_impl::ServerUnaryStreamer; + template using ServerSplitStreamer = ::grpc_impl::ServerSplitStreamer; diff --git a/third_party/googletest b/third_party/googletest index 2fe3bd994b3..ec44c6c1675 160000 --- a/third_party/googletest +++ b/third_party/googletest @@ -1 +1 @@ -Subproject commit 2fe3bd994b3189899d93f1d5a881e725e046fdc2 +Subproject commit ec44c6c1675c25b9827aacd08c02433cccde7780 diff --git a/third_party/protobuf b/third_party/protobuf index 09745575a92..582743bf40c 160000 --- a/third_party/protobuf +++ b/third_party/protobuf @@ -1 +1 @@ -Subproject commit 09745575a923640154bcf307fba8aedff47f240a +Subproject commit 582743bf40c5d3639a70f98f183914a2c0cd0680 From 5f55921b088b07af2348a894550874841a7a9b18 Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Tue, 2 Jul 2019 12:37:08 -0700 Subject: [PATCH 0799/1555] Remove third_party --- third_party/googletest | 2 +- third_party/protobuf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/googletest b/third_party/googletest index ec44c6c1675..2fe3bd994b3 160000 --- a/third_party/googletest +++ b/third_party/googletest @@ -1 +1 @@ -Subproject commit ec44c6c1675c25b9827aacd08c02433cccde7780 +Subproject commit 2fe3bd994b3189899d93f1d5a881e725e046fdc2 diff --git a/third_party/protobuf b/third_party/protobuf index 582743bf40c..09745575a92 160000 --- a/third_party/protobuf +++ b/third_party/protobuf @@ -1 +1 @@ -Subproject commit 582743bf40c5d3639a70f98f183914a2c0cd0680 +Subproject commit 09745575a923640154bcf307fba8aedff47f240a From b1914bd46cab8a6f14788e4fa5ddd1fe45cd1ab5 Mon Sep 17 00:00:00 2001 From: mgravell Date: Tue, 2 Jul 2019 21:24:23 +0100 Subject: [PATCH 0800/1555] remove lazy usage --- src/csharp/Grpc.Core.Api/AuthProperty.cs | 7 ++----- src/csharp/Grpc.Core/Internal/DefaultServerCallContext.cs | 6 ++---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/csharp/Grpc.Core.Api/AuthProperty.cs b/src/csharp/Grpc.Core.Api/AuthProperty.cs index 0907edba84d..c208cee0267 100644 --- a/src/csharp/Grpc.Core.Api/AuthProperty.cs +++ b/src/csharp/Grpc.Core.Api/AuthProperty.cs @@ -17,8 +17,6 @@ #endregion using System; -using System.Collections.Generic; -using System.Linq; using System.Text; using Grpc.Core.Utils; @@ -33,13 +31,12 @@ namespace Grpc.Core static readonly Encoding EncodingUTF8 = System.Text.Encoding.UTF8; string name; byte[] valueBytes; - Lazy value; + string lazyValue; private AuthProperty(string name, byte[] valueBytes) { this.name = GrpcPreconditions.CheckNotNull(name); this.valueBytes = GrpcPreconditions.CheckNotNull(valueBytes); - this.value = new Lazy(() => EncodingUTF8.GetString(this.valueBytes)); } /// @@ -60,7 +57,7 @@ namespace Grpc.Core { get { - return value.Value; + return lazyValue ?? (lazyValue = EncodingUTF8.GetString(this.valueBytes)); } } diff --git a/src/csharp/Grpc.Core/Internal/DefaultServerCallContext.cs b/src/csharp/Grpc.Core/Internal/DefaultServerCallContext.cs index b33cb631e26..77e4ccd356d 100644 --- a/src/csharp/Grpc.Core/Internal/DefaultServerCallContext.cs +++ b/src/csharp/Grpc.Core/Internal/DefaultServerCallContext.cs @@ -38,7 +38,7 @@ namespace Grpc.Core private readonly Metadata responseTrailers; private Status status; private readonly IServerResponseStream serverResponseStream; - private readonly Lazy authContext; + private AuthContext lazyAuthContext; /// /// Creates a new instance of ServerCallContext. @@ -57,8 +57,6 @@ namespace Grpc.Core this.responseTrailers = new Metadata(); this.status = Status.DefaultSuccess; this.serverResponseStream = serverResponseStream; - // TODO(jtattermusch): avoid unnecessary allocation of factory function and the lazy object - this.authContext = new Lazy(GetAuthContextEager); } protected override ContextPropagationToken CreatePropagationTokenCore(ContextPropagationOptions options) @@ -97,7 +95,7 @@ namespace Grpc.Core set => serverResponseStream.WriteOptions = value; } - protected override AuthContext AuthContextCore => authContext.Value; + protected override AuthContext AuthContextCore => lazyAuthContext ?? (lazyAuthContext = GetAuthContextEager()); private AuthContext GetAuthContextEager() { From c9ce403dc46e494e8ae546c4e99e044dbdda5400 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 2 Jul 2019 14:00:46 -0700 Subject: [PATCH 0801/1555] Ensure bazel_hack terminates when running test_gevent. --- .../grpcio_tests/tests/bazel_namespace_package_hack.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/python/grpcio_tests/tests/bazel_namespace_package_hack.py b/src/python/grpcio_tests/tests/bazel_namespace_package_hack.py index c6b72c327b1..0250dce0d61 100644 --- a/src/python/grpcio_tests/tests/bazel_namespace_package_hack.py +++ b/src/python/grpcio_tests/tests/bazel_namespace_package_hack.py @@ -24,9 +24,15 @@ import sys # Analysis in depth: https://github.com/bazelbuild/rules_python/issues/55 def sys_path_to_site_dir_hack(): """Add valid sys.path item to site directory to parse the .pth files.""" + print("Executing hack") + print("sys.path: {}".format(sys.path)) + items = [] for item in sys.path: + print("Checking {}".format(item)) if os.path.exists(item): # The only difference between sys.path and site-directory is # whether the .pth file will be parsed or not. A site-directory # will always exist in sys.path, but not another way around. - site.addsitedir(item) + items.append(item) + for item in items: + site.addsitedir(item) From 85b4e7948cecabb2b1ca5ebabb628ebc2a72a05e Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 2 Jul 2019 14:01:59 -0700 Subject: [PATCH 0802/1555] Remove debug prints --- src/python/grpcio_tests/tests/bazel_namespace_package_hack.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/python/grpcio_tests/tests/bazel_namespace_package_hack.py b/src/python/grpcio_tests/tests/bazel_namespace_package_hack.py index 0250dce0d61..006a3deecb4 100644 --- a/src/python/grpcio_tests/tests/bazel_namespace_package_hack.py +++ b/src/python/grpcio_tests/tests/bazel_namespace_package_hack.py @@ -24,11 +24,8 @@ import sys # Analysis in depth: https://github.com/bazelbuild/rules_python/issues/55 def sys_path_to_site_dir_hack(): """Add valid sys.path item to site directory to parse the .pth files.""" - print("Executing hack") - print("sys.path: {}".format(sys.path)) items = [] for item in sys.path: - print("Checking {}".format(item)) if os.path.exists(item): # The only difference between sys.path and site-directory is # whether the .pth file will be parsed or not. A site-directory From 1b7ff376d87e764d42006ac61acaa4942995b9ec Mon Sep 17 00:00:00 2001 From: Doug Fawley Date: Tue, 2 Jul 2019 14:18:58 -0700 Subject: [PATCH 0803/1555] Add v1.22.0 releases of grpc-go to interop matrix --- tools/interop_matrix/client_matrix.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index d6d0612b4e4..99734bb9f76 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -142,6 +142,7 @@ LANG_RELEASE_MATRIX = { ReleaseInfo(runtimes=['go1.11'], testcases_file='go__v1.0.5')), ('v1.20.0', ReleaseInfo(runtimes=['go1.11'])), ('v1.21.0', ReleaseInfo(runtimes=['go1.11'])), + ('v1.22.0', ReleaseInfo(runtimes=['go1.11'])), ]), 'java': OrderedDict([ From 3bce424458ed4a3fefd191349dda1e672d8df5d0 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 2 Jul 2019 15:00:32 -0700 Subject: [PATCH 0804/1555] Remove debug code --- src/core/lib/gpr/sync_posix.cc | 129 ---------------------------- src/core/lib/iomgr/timer_manager.cc | 44 ---------- 2 files changed, 173 deletions(-) diff --git a/src/core/lib/gpr/sync_posix.cc b/src/core/lib/gpr/sync_posix.cc index a30e36c11ac..fe2d5a9ca38 100644 --- a/src/core/lib/gpr/sync_posix.cc +++ b/src/core/lib/gpr/sync_posix.cc @@ -29,44 +29,6 @@ #include #include "src/core/lib/profiling/timers.h" -// For debug of the timer manager crash only. -// TODO (mxyan): remove after bug is fixed. -#ifdef GRPC_DEBUG_TIMER_MANAGER -#include -void (*g_grpc_debug_timer_manager_stats)( - int64_t timer_manager_init_count, int64_t timer_manager_shutdown_count, - int64_t fork_count, int64_t timer_wait_err, int64_t timer_cv_value, - int64_t timer_mu_value, int64_t abstime_sec_value, - int64_t abstime_nsec_value, int64_t abs_deadline_sec_value, - int64_t abs_deadline_nsec_value, int64_t now1_sec_value, - int64_t now1_nsec_value, int64_t now2_sec_value, int64_t now2_nsec_value, - int64_t add_result_sec_value, int64_t add_result_nsec_value, - int64_t sub_result_sec_value, int64_t sub_result_nsec_value, - int64_t next_value, int64_t start_time_sec, - int64_t start_time_nsec) = nullptr; -int64_t g_timer_manager_init_count = 0; -int64_t g_timer_manager_shutdown_count = 0; -int64_t g_fork_count = 0; -int64_t g_timer_wait_err = 0; -int64_t g_timer_cv_value = 0; -int64_t g_timer_mu_value = 0; -int64_t g_abstime_sec_value = -1; -int64_t g_abstime_nsec_value = -1; -int64_t g_abs_deadline_sec_value = -1; -int64_t g_abs_deadline_nsec_value = -1; -int64_t g_now1_sec_value = -1; -int64_t g_now1_nsec_value = -1; -int64_t g_now2_sec_value = -1; -int64_t g_now2_nsec_value = -1; -int64_t g_add_result_sec_value = -1; -int64_t g_add_result_nsec_value = -1; -int64_t g_sub_result_sec_value = -1; -int64_t g_sub_result_nsec_value = -1; -int64_t g_next_value = -1; -int64_t g_start_time_sec = -1; -int64_t g_start_time_nsec = -1; -#endif // GRPC_DEBUG_TIMER_MANAGER - #ifdef GPR_LOW_LEVEL_COUNTERS gpr_atm gpr_mu_locks = 0; gpr_atm gpr_counter_atm_cas = 0; @@ -152,63 +114,12 @@ void gpr_cv_destroy(gpr_cv* cv) { #endif } -// For debug of the timer manager crash only. -// TODO (mxyan): remove after bug is fixed. -#ifdef GRPC_DEBUG_TIMER_MANAGER -static gpr_timespec gpr_convert_clock_type_debug_timespec( - gpr_timespec t, gpr_clock_type clock_type, gpr_timespec& now1, - gpr_timespec& now2, gpr_timespec& add_result, gpr_timespec& sub_result) { - if (t.clock_type == clock_type) { - return t; - } - - if (t.tv_sec == INT64_MAX || t.tv_sec == INT64_MIN) { - t.clock_type = clock_type; - return t; - } - - if (clock_type == GPR_TIMESPAN) { - return gpr_time_sub(t, gpr_now(t.clock_type)); - } - - if (t.clock_type == GPR_TIMESPAN) { - return gpr_time_add(gpr_now(clock_type), t); - } - - now1 = gpr_now(t.clock_type); - sub_result = gpr_time_sub(t, now1); - now2 = gpr_now(clock_type); - add_result = gpr_time_add(now2, sub_result); - return add_result; -} - -#define gpr_convert_clock_type_debug(t, clock_type, now1, now2, add_result, \ - sub_result) \ - gpr_convert_clock_type_debug_timespec((t), (clock_type), (now1), (now2), \ - (add_result), (sub_result)) -#else #define gpr_convert_clock_type_debug(t, clock_type, now1, now2, add_result, \ sub_result) \ gpr_convert_clock_type((t), (clock_type)) -#endif int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) { int err = 0; -#ifdef GRPC_DEBUG_TIMER_MANAGER - // For debug of the timer manager crash only. - // TODO (mxyan): remove after bug is fixed. - gpr_timespec abs_deadline_copy; - abs_deadline_copy.tv_sec = abs_deadline.tv_sec; - abs_deadline_copy.tv_nsec = abs_deadline.tv_nsec; - gpr_timespec now1; - gpr_timespec now2; - gpr_timespec add_result; - gpr_timespec sub_result; - memset(&now1, 0, sizeof(now1)); - memset(&now2, 0, sizeof(now2)); - memset(&add_result, 0, sizeof(add_result)); - memset(&sub_result, 0, sizeof(sub_result)); -#endif if (gpr_time_cmp(abs_deadline, gpr_inf_future(abs_deadline.clock_type)) == 0) { #ifdef GRPC_ASAN_ENABLED @@ -232,47 +143,7 @@ int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) { #else err = pthread_cond_timedwait(cv, mu, &abs_deadline_ts); #endif - -#ifdef GRPC_DEBUG_TIMER_MANAGER - // For debug of the timer manager crash only. - // TODO (mxyan): remove after bug is fixed. - if (GPR_UNLIKELY(!(err == 0 || err == ETIMEDOUT || err == EAGAIN))) { - g_abstime_sec_value = abs_deadline_ts.tv_sec; - g_abstime_nsec_value = abs_deadline_ts.tv_nsec; - } -#endif } - -#ifdef GRPC_DEBUG_TIMER_MANAGER - // For debug of the timer manager crash only. - // TODO (mxyan): remove after bug is fixed. - if (GPR_UNLIKELY(!(err == 0 || err == ETIMEDOUT || err == EAGAIN))) { - if (g_grpc_debug_timer_manager_stats) { - g_timer_wait_err = err; - g_timer_cv_value = (int64_t)cv; - g_timer_mu_value = (int64_t)mu; - g_abs_deadline_sec_value = abs_deadline_copy.tv_sec; - g_abs_deadline_nsec_value = abs_deadline_copy.tv_nsec; - g_now1_sec_value = now1.tv_sec; - g_now1_nsec_value = now1.tv_nsec; - g_now2_sec_value = now2.tv_sec; - g_now2_nsec_value = now2.tv_nsec; - g_add_result_sec_value = add_result.tv_sec; - g_add_result_nsec_value = add_result.tv_nsec; - g_sub_result_sec_value = sub_result.tv_sec; - g_sub_result_nsec_value = sub_result.tv_nsec; - g_grpc_debug_timer_manager_stats( - g_timer_manager_init_count, g_timer_manager_shutdown_count, - g_fork_count, g_timer_wait_err, g_timer_cv_value, g_timer_mu_value, - g_abstime_sec_value, g_abstime_nsec_value, g_abs_deadline_sec_value, - g_abs_deadline_nsec_value, g_now1_sec_value, g_now1_nsec_value, - g_now2_sec_value, g_now2_nsec_value, g_add_result_sec_value, - g_add_result_nsec_value, g_sub_result_sec_value, - g_sub_result_nsec_value, g_next_value, g_start_time_sec, - g_start_time_nsec); - } - } -#endif GPR_ASSERT(err == 0 || err == ETIMEDOUT || err == EAGAIN); return err == ETIMEDOUT; } diff --git a/src/core/lib/iomgr/timer_manager.cc b/src/core/lib/iomgr/timer_manager.cc index bdf54909b4c..bb270af8129 100644 --- a/src/core/lib/iomgr/timer_manager.cc +++ b/src/core/lib/iomgr/timer_manager.cc @@ -61,30 +61,6 @@ static uint64_t g_timed_waiter_generation; static void timer_thread(void* completed_thread_ptr); -// For debug of the timer manager crash only. -// TODO (mxyan): remove after bug is fixed. -#ifdef GRPC_DEBUG_TIMER_MANAGER -extern int64_t g_timer_manager_init_count; -extern int64_t g_timer_manager_shutdown_count; -extern int64_t g_fork_count; -extern int64_t g_next_value; -#endif // GRPC_DEBUG_TIMER_MANAGER - -static void gc_completed_threads(void) { - if (g_completed_threads != nullptr) { - completed_thread* to_gc = g_completed_threads; - g_completed_threads = nullptr; - gpr_mu_unlock(&g_mu); - while (to_gc != nullptr) { - to_gc->thd.Join(); - completed_thread* next = to_gc->next; - gpr_free(to_gc); - to_gc = next; - } - gpr_mu_lock(&g_mu); - } -} - static void start_timer_thread_and_unlock(void) { GPR_ASSERT(g_threaded); ++g_waiter_count; @@ -203,11 +179,6 @@ static bool wait_until(grpc_millis next) { gpr_log(GPR_INFO, "sleep until kicked"); } - // For debug of the timer manager crash only. - // TODO (mxyan): remove after bug is fixed. -#ifdef GRPC_DEBUG_TIMER_MANAGER - g_next_value = next; -#endif gpr_cv_wait(&g_cv_wait, &g_mu, grpc_millis_to_timespec(next, GPR_CLOCK_MONOTONIC)); @@ -309,11 +280,6 @@ static void start_threads(void) { void grpc_timer_manager_init(void) { gpr_mu_init(&g_mu); gpr_cv_init(&g_cv_wait); -#ifdef GRPC_DEBUG_TIMER_MANAGER - // For debug of the timer manager crash only. - // TODO (mxyan): remove after bug is fixed. - g_timer_manager_init_count++; -#endif gpr_cv_init(&g_cv_shutdown); g_threaded = false; g_thread_count = 0; @@ -349,11 +315,6 @@ static void stop_threads(void) { } void grpc_timer_manager_shutdown(void) { -#ifdef GRPC_DEBUG_TIMER_MANAGER - // For debug of the timer manager crash only. - // TODO (mxyan): remove after bug is fixed. - g_timer_manager_shutdown_count++; -#endif stop_threads(); gpr_mu_destroy(&g_mu); @@ -362,11 +323,6 @@ void grpc_timer_manager_shutdown(void) { } void grpc_timer_manager_set_threading(bool threaded) { -#ifdef GRPC_DEBUG_TIMER_MANAGER - // For debug of the timer manager crash only. - // TODO (mxyan): remove after bug is fixed. - g_fork_count++; -#endif if (threaded) { start_threads(); } else { From 4be4df36247bd2ef540f235f930540e3c50a9530 Mon Sep 17 00:00:00 2001 From: Christopher Warrington Date: Tue, 25 Jun 2019 21:48:48 +0000 Subject: [PATCH 0805/1555] Bump min CMake to 3.5.1 to match Google benchmark The Google Benchmark CMake build needs CMake 3.5.1 or newer. CMake 3.5.1 was released May 24, 2016 and is available in Debian stable and Ubuntu 16.04 and 18.04. --- CMakeLists.txt | 2 +- examples/cpp/helloworld/CMakeLists.txt | 2 +- examples/cpp/helloworld/cmake_externalproject/CMakeLists.txt | 2 +- templates/CMakeLists.txt.template | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a34f9265256..5780c91470f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.5.1) set(PACKAGE_NAME "grpc") set(PACKAGE_VERSION "1.23.0-dev") diff --git a/examples/cpp/helloworld/CMakeLists.txt b/examples/cpp/helloworld/CMakeLists.txt index d0f705f6d99..146ee814261 100644 --- a/examples/cpp/helloworld/CMakeLists.txt +++ b/examples/cpp/helloworld/CMakeLists.txt @@ -17,7 +17,7 @@ # See cmake_externalproject/CMakeLists.txt for all-in-one cmake build # that automatically builds all the dependencies before building helloworld. -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.5.1) project(HelloWorld C CXX) diff --git a/examples/cpp/helloworld/cmake_externalproject/CMakeLists.txt b/examples/cpp/helloworld/cmake_externalproject/CMakeLists.txt index 9fbdf071a8d..0d8470a8d68 100644 --- a/examples/cpp/helloworld/cmake_externalproject/CMakeLists.txt +++ b/examples/cpp/helloworld/cmake_externalproject/CMakeLists.txt @@ -20,7 +20,7 @@ # including the "helloworld" project itself. # See https://blog.kitware.com/cmake-superbuilds-git-submodules/ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.5.1) # Project project(HelloWorld-SuperBuild C CXX) diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index 43bc063aee5..b9aa76fd6d6 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -69,7 +69,7 @@ return 'endif()\n' %> - cmake_minimum_required(VERSION 2.8) + cmake_minimum_required(VERSION 3.5.1) set(PACKAGE_NAME "grpc") set(PACKAGE_VERSION "${settings.cpp_version}") From 0a1f644da59a1f8598580d925e847c425e7a3786 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 2 Jul 2019 16:44:47 -0700 Subject: [PATCH 0806/1555] Revert undesired deletion --- src/core/lib/iomgr/timer_manager.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/core/lib/iomgr/timer_manager.cc b/src/core/lib/iomgr/timer_manager.cc index bb270af8129..04d4f881ecf 100644 --- a/src/core/lib/iomgr/timer_manager.cc +++ b/src/core/lib/iomgr/timer_manager.cc @@ -61,6 +61,21 @@ static uint64_t g_timed_waiter_generation; static void timer_thread(void* completed_thread_ptr); +static void gc_completed_threads(void) { + if (g_completed_threads != nullptr) { + completed_thread* to_gc = g_completed_threads; + g_completed_threads = nullptr; + gpr_mu_unlock(&g_mu); + while (to_gc != nullptr) { + to_gc->thd.Join(); + completed_thread* next = to_gc->next; + gpr_free(to_gc); + to_gc = next; + } + gpr_mu_lock(&g_mu); + } +} + static void start_timer_thread_and_unlock(void) { GPR_ASSERT(g_threaded); ++g_waiter_count; From 42b7374880521652596e61818aef1bf8e936bf0b Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Tue, 2 Jul 2019 19:29:04 -0700 Subject: [PATCH 0807/1555] Force run --- src/core/lib/iomgr/executor/threadpool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/executor/threadpool.h b/src/core/lib/iomgr/executor/threadpool.h index 2ea1d5fcef4..3bc79aa6c3c 100644 --- a/src/core/lib/iomgr/executor/threadpool.h +++ b/src/core/lib/iomgr/executor/threadpool.h @@ -137,7 +137,7 @@ class ThreadPool : public ThreadPoolInterface { const char* thd_name_ = nullptr; Thread::Options thread_options_; ThreadPoolWorker** threads_ = nullptr; // Array of worker threads - MPMCQueueInterface* queue_ = nullptr; + MPMCQueueInterface* queue_ = nullptr; // Closure queue Atomic shut_down_{false}; // Destructor has been called if set to true From aaf5cf4cb7604030b3e5c8d81ec62d9dff2606ed Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 3 Jul 2019 08:52:51 -0700 Subject: [PATCH 0808/1555] clang-format --- src/core/lib/iomgr/timer_manager.cc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/core/lib/iomgr/timer_manager.cc b/src/core/lib/iomgr/timer_manager.cc index 04d4f881ecf..17cae5cd4c3 100644 --- a/src/core/lib/iomgr/timer_manager.cc +++ b/src/core/lib/iomgr/timer_manager.cc @@ -61,20 +61,20 @@ static uint64_t g_timed_waiter_generation; static void timer_thread(void* completed_thread_ptr); -static void gc_completed_threads(void) { - if (g_completed_threads != nullptr) { - completed_thread* to_gc = g_completed_threads; - g_completed_threads = nullptr; - gpr_mu_unlock(&g_mu); - while (to_gc != nullptr) { - to_gc->thd.Join(); - completed_thread* next = to_gc->next; - gpr_free(to_gc); - to_gc = next; - } - gpr_mu_lock(&g_mu); - } -} +static void gc_completed_threads(void) { + if (g_completed_threads != nullptr) { + completed_thread* to_gc = g_completed_threads; + g_completed_threads = nullptr; + gpr_mu_unlock(&g_mu); + while (to_gc != nullptr) { + to_gc->thd.Join(); + completed_thread* next = to_gc->next; + gpr_free(to_gc); + to_gc = next; + } + gpr_mu_lock(&g_mu); + } +} static void start_timer_thread_and_unlock(void) { GPR_ASSERT(g_threaded); From ad3957a48b53bd69e9a871f3a1aa49b15877975b Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Wed, 3 Jul 2019 11:47:18 -0700 Subject: [PATCH 0809/1555] Fix typo --- src/core/lib/iomgr/executor/mpmcqueue.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index ea2a6868d2f..5eac7e29087 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -59,7 +59,7 @@ inline void* InfLenFIFOQueue::PopFront() { } Delete(head_to_remove); - // Singal waiting thread + // Signal waiting thread if (count_.Load(MemoryOrder::RELAXED) > 0 && num_waiters_ > 0) { wait_nonempty_.Signal(); } From af1b09f7e758d7aa61b3252151e0f9b20c564b09 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 26 Jun 2019 13:22:36 -0700 Subject: [PATCH 0810/1555] Enforce a Finite Time Gap Bound between Signal Receipt and Signal Handler Execution Previously, signal handlers were only given a chance to run upon receipt of an entry in the RPC stream. Since there is no time bound on how long that might take, there can be an arbitrarily long time gap between receipt of the signal and the execution of the application's signal handlers. Signal handlers are only run on the main thread. The cpython implementation takes great care to ensure that the main thread does not block for an arbitrarily long period between signal checks. Our indefinite blocking was due to wait() invocations on condition variables without a timeout. This changes all usages of wait() in the the channel implementation to use a wrapper that is responsive to signals even while waiting on an RPC. A test has been added to verify this. Tests are currently disabled under gevent due to https://github.com/grpc/grpc/issues/18980, but a fix for that has been found and should be merged shortly. --- src/python/grpcio/grpc/_channel.py | 151 ++++++++++------- src/python/grpcio/grpc/_common.py | 50 ++++++ src/python/grpcio_tests/commands.py | 2 + src/python/grpcio_tests/tests/tests.json | 1 + .../grpcio_tests/tests/unit/BUILD.bazel | 8 + .../grpcio_tests/tests/unit/_signal_client.py | 82 +++++++++ .../tests/unit/_signal_handling_test.py | 158 ++++++++++++++++++ 7 files changed, 393 insertions(+), 59 deletions(-) create mode 100644 src/python/grpcio_tests/tests/unit/_signal_client.py create mode 100644 src/python/grpcio_tests/tests/unit/_signal_handling_test.py diff --git a/src/python/grpcio/grpc/_channel.py b/src/python/grpcio/grpc/_channel.py index 24f928ef69f..0bf8e03b5ce 100644 --- a/src/python/grpcio/grpc/_channel.py +++ b/src/python/grpcio/grpc/_channel.py @@ -13,6 +13,7 @@ # limitations under the License. """Invocation-side implementation of gRPC Python.""" +import functools import logging import sys import threading @@ -81,17 +82,6 @@ def _unknown_code_details(unknown_cygrpc_code, details): unknown_cygrpc_code, details) -def _wait_once_until(condition, until): - if until is None: - condition.wait() - else: - remaining = until - time.time() - if remaining < 0: - raise grpc.FutureTimeoutError() - else: - condition.wait(timeout=remaining) - - class _RPCState(object): def __init__(self, due, initial_metadata, trailing_metadata, code, details): @@ -178,12 +168,11 @@ def _event_handler(state, response_deserializer): #pylint: disable=too-many-statements def _consume_request_iterator(request_iterator, state, call, request_serializer, event_handler): - if cygrpc.is_fork_support_enabled(): - condition_wait_timeout = 1.0 - else: - condition_wait_timeout = None + """Consume a request iterator supplied by the user.""" def consume_request_iterator(): # pylint: disable=too-many-branches + # Iterate over the request iterator until it is exhausted or an error + # condition is encountered. while True: return_from_user_request_generator_invoked = False try: @@ -224,14 +213,19 @@ def _consume_request_iterator(request_iterator, state, call, request_serializer, state.due.add(cygrpc.OperationType.send_message) else: return - while True: - state.condition.wait(condition_wait_timeout) - cygrpc.block_if_fork_in_progress(state) - if state.code is None: - if cygrpc.OperationType.send_message not in state.due: - break - else: - return + + def _done(): + return (state.code is not None or + cygrpc.OperationType.send_message not in + state.due) + + _common.wait( + state.condition.wait, + _done, + spin_cb=functools.partial( + cygrpc.block_if_fork_in_progress, state)) + if state.code is not None: + return else: return with state.condition: @@ -281,13 +275,21 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call): # pylint: disable=too with self._state.condition: return self._state.code is not None + def _is_complete(self): + return self._state.code is not None + def result(self, timeout=None): - until = None if timeout is None else time.time() + timeout + """Returns the result of the computation or raises its exception. + + See grpc.Future.result for the full API contract. + """ with self._state.condition: - while True: - if self._state.code is None: - _wait_once_until(self._state.condition, until) - elif self._state.code is grpc.StatusCode.OK: + timed_out = _common.wait( + self._state.condition.wait, self._is_complete, timeout=timeout) + if timed_out: + raise grpc.FutureTimeoutError() + else: + if self._state.code is grpc.StatusCode.OK: return self._state.response elif self._state.cancelled: raise grpc.FutureCancelledError() @@ -295,12 +297,17 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call): # pylint: disable=too raise self def exception(self, timeout=None): - until = None if timeout is None else time.time() + timeout + """Return the exception raised by the computation. + + See grpc.Future.exception for the full API contract. + """ with self._state.condition: - while True: - if self._state.code is None: - _wait_once_until(self._state.condition, until) - elif self._state.code is grpc.StatusCode.OK: + timed_out = _common.wait( + self._state.condition.wait, self._is_complete, timeout=timeout) + if timed_out: + raise grpc.FutureTimeoutError() + else: + if self._state.code is grpc.StatusCode.OK: return None elif self._state.cancelled: raise grpc.FutureCancelledError() @@ -308,12 +315,17 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call): # pylint: disable=too return self def traceback(self, timeout=None): - until = None if timeout is None else time.time() + timeout + """Access the traceback of the exception raised by the computation. + + See grpc.future.traceback for the full API contract. + """ with self._state.condition: - while True: - if self._state.code is None: - _wait_once_until(self._state.condition, until) - elif self._state.code is grpc.StatusCode.OK: + timed_out = _common.wait( + self._state.condition.wait, self._is_complete, timeout=timeout) + if timed_out: + raise grpc.FutureTimeoutError() + else: + if self._state.code is grpc.StatusCode.OK: return None elif self._state.cancelled: raise grpc.FutureCancelledError() @@ -345,17 +357,23 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call): # pylint: disable=too raise StopIteration() else: raise self - while True: - self._state.condition.wait() - if self._state.response is not None: - response = self._state.response - self._state.response = None - return response - elif cygrpc.OperationType.receive_message not in self._state.due: - if self._state.code is grpc.StatusCode.OK: - raise StopIteration() - elif self._state.code is not None: - raise self + + def _response_ready(): + return ( + self._state.response is not None or + (cygrpc.OperationType.receive_message not in self._state.due + and self._state.code is not None)) + + _common.wait(self._state.condition.wait, _response_ready) + if self._state.response is not None: + response = self._state.response + self._state.response = None + return response + elif cygrpc.OperationType.receive_message not in self._state.due: + if self._state.code is grpc.StatusCode.OK: + raise StopIteration() + elif self._state.code is not None: + raise self def __iter__(self): return self @@ -386,32 +404,47 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call): # pylint: disable=too def initial_metadata(self): with self._state.condition: - while self._state.initial_metadata is None: - self._state.condition.wait() + + def _done(): + return self._state.initial_metadata is not None + + _common.wait(self._state.condition.wait, _done) return self._state.initial_metadata def trailing_metadata(self): with self._state.condition: - while self._state.trailing_metadata is None: - self._state.condition.wait() + + def _done(): + return self._state.trailing_metadata is not None + + _common.wait(self._state.condition.wait, _done) return self._state.trailing_metadata def code(self): with self._state.condition: - while self._state.code is None: - self._state.condition.wait() + + def _done(): + return self._state.code is not None + + _common.wait(self._state.condition.wait, _done) return self._state.code def details(self): with self._state.condition: - while self._state.details is None: - self._state.condition.wait() + + def _done(): + return self._state.details is not None + + _common.wait(self._state.condition.wait, _done) return _common.decode(self._state.details) def debug_error_string(self): with self._state.condition: - while self._state.debug_error_string is None: - self._state.condition.wait() + + def _done(): + return self._state.debug_error_string is not None + + _common.wait(self._state.condition.wait, _done) return _common.decode(self._state.debug_error_string) def _repr(self): diff --git a/src/python/grpcio/grpc/_common.py b/src/python/grpcio/grpc/_common.py index f69127e38ef..b4b24738e8f 100644 --- a/src/python/grpcio/grpc/_common.py +++ b/src/python/grpcio/grpc/_common.py @@ -15,6 +15,7 @@ import logging +import time import six import grpc @@ -60,6 +61,8 @@ STATUS_CODE_TO_CYGRPC_STATUS_CODE = { CYGRPC_STATUS_CODE_TO_STATUS_CODE) } +MAXIMUM_WAIT_TIMEOUT = 0.1 + def encode(s): if isinstance(s, bytes): @@ -96,3 +99,50 @@ def deserialize(serialized_message, deserializer): def fully_qualified_method(group, method): return '/{}/{}'.format(group, method) + + +def _wait_once(wait_fn, timeout, spin_cb): + wait_fn(timeout=timeout) + if spin_cb is not None: + spin_cb() + + +def wait(wait_fn, wait_complete_fn, timeout=None, spin_cb=None): + """Blocks waiting for an event without blocking the thread indefinitely. + + See https://github.com/grpc/grpc/issues/19464 for full context. CPython's + `threading.Event.wait` and `threading.Condition.wait` methods, if invoked + without a timeout kwarg, may block the calling thread indefinitely. If the + call is made from the main thread, this means that signal handlers may not + run for an arbitrarily long period of time. + + This wrapper calls the supplied wait function with an arbitrary short + timeout to ensure that no signal handler has to wait longer than + MAXIMUM_WAIT_TIMEOUT before executing. + + Args: + wait_fn: A callable acceptable a single float-valued kwarg named + `timeout`. This function is expected to be one of `threading.Event.wait` + or `threading.Condition.wait`. + wait_complete_fn: A callable taking no arguments and returning a bool. + When this function returns true, it indicates that waiting should cease. + timeout: An optional float-valued number of seconds after which the wait + should cease. + spin_cb: An optional Callable taking no arguments and returning nothing. + This callback will be called on each iteration of the spin. This may be + used for, e.g. work related to forking. + + Returns: + True if a timeout was supplied and it was reached. False otherwise. + """ + if timeout is None: + while not wait_complete_fn(): + _wait_once(wait_fn, MAXIMUM_WAIT_TIMEOUT, spin_cb) + else: + end = time.time() + timeout + while not wait_complete_fn(): + remaining = min(end - time.time(), MAXIMUM_WAIT_TIMEOUT) + if remaining < 0: + return True + _wait_once(wait_fn, remaining, spin_cb) + return False diff --git a/src/python/grpcio_tests/commands.py b/src/python/grpcio_tests/commands.py index dc0795d4a12..166cea101a4 100644 --- a/src/python/grpcio_tests/commands.py +++ b/src/python/grpcio_tests/commands.py @@ -145,6 +145,8 @@ class TestGevent(setuptools.Command): 'unit._exit_test.ExitTest.test_in_flight_partial_unary_stream_call', 'unit._exit_test.ExitTest.test_in_flight_partial_stream_unary_call', 'unit._exit_test.ExitTest.test_in_flight_partial_stream_stream_call', + # TODO(https://github.com/grpc/grpc/issues/18980): Reenable. + 'unit._signal_handling_test.SignalHandlingTest', 'unit._metadata_flags_test', 'health_check._health_servicer_test.HealthServicerTest.test_cancelled_watch_removed_from_watch_list', # TODO(https://github.com/grpc/grpc/issues/17330) enable these three tests diff --git a/src/python/grpcio_tests/tests/tests.json b/src/python/grpcio_tests/tests/tests.json index cc08d56248a..16ba4847bc0 100644 --- a/src/python/grpcio_tests/tests/tests.json +++ b/src/python/grpcio_tests/tests/tests.json @@ -67,6 +67,7 @@ "unit._server_ssl_cert_config_test.ServerSSLCertReloadTestWithoutClientAuth", "unit._server_test.ServerTest", "unit._session_cache_test.SSLSessionCacheTest", + "unit._signal_handling_test.SignalHandlingTest", "unit._version_test.VersionTest", "unit.beta._beta_features_test.BetaFeaturesTest", "unit.beta._beta_features_test.ContextManagementAndLifecycleTest", diff --git a/src/python/grpcio_tests/tests/unit/BUILD.bazel b/src/python/grpcio_tests/tests/unit/BUILD.bazel index a161794f8be..d21f5a59ad1 100644 --- a/src/python/grpcio_tests/tests/unit/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/BUILD.bazel @@ -16,6 +16,7 @@ GRPCIO_TESTS_UNIT = [ "_credentials_test.py", "_dns_resolver_test.py", "_empty_message_test.py", + "_error_message_encoding_test.py", "_exit_test.py", "_interceptor_test.py", "_invalid_metadata_test.py", @@ -27,6 +28,7 @@ GRPCIO_TESTS_UNIT = [ # "_reconnect_test.py", "_resource_exhausted_test.py", "_rpc_test.py", + "_signal_handling_test.py", # TODO(ghostwriternr): To be added later. # "_server_ssl_cert_config_test.py", "_server_test.py", @@ -39,6 +41,11 @@ py_library( srcs = ["_tcp_proxy.py"], ) +py_library( + name = "_signal_client", + srcs = ["_signal_client.py"], +) + py_library( name = "resources", srcs = ["resources.py"], @@ -87,6 +94,7 @@ py_library( ":_server_shutdown_scenarios", ":_from_grpc_import_star", ":_tcp_proxy", + ":_signal_client", "//src/python/grpcio_tests/tests/unit/framework/common", "//src/python/grpcio_tests/tests/testing", requirement('six'), diff --git a/src/python/grpcio_tests/tests/unit/_signal_client.py b/src/python/grpcio_tests/tests/unit/_signal_client.py new file mode 100644 index 00000000000..da413db3b94 --- /dev/null +++ b/src/python/grpcio_tests/tests/unit/_signal_client.py @@ -0,0 +1,82 @@ +# Copyright 2019 the gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Client for testing responsiveness to signals.""" + +from __future__ import print_function + +import argparse +import functools +import logging +import signal +import sys + +import grpc + +SIGTERM_MESSAGE = "Handling sigterm!" + +UNARY_UNARY = "/test/Unary" +UNARY_STREAM = "/test/ServerStreaming" + +_MESSAGE = b'\x00\x00\x00' + +_ASSERTION_MESSAGE = "Control flow should never reach here." + +# NOTE(gnossen): We use a global variable here so that the signal handler can be +# installed before the RPC begins. If we do not do this, then we may receive the +# SIGINT before the signal handler is installed. I'm not happy with per-process +# global state, but the per-process global state that is signal handlers +# somewhat forces my hand. +per_process_rpc_future = None + + +def handle_sigint(unused_signum, unused_frame): + print(SIGTERM_MESSAGE) + if per_process_rpc_future is not None: + per_process_rpc_future.cancel() + sys.stderr.flush() + sys.exit(0) + + +def main_unary(server_target): + global per_process_rpc_future # pylint: disable=global-statement + with grpc.insecure_channel(server_target) as channel: + multicallable = channel.unary_unary(UNARY_UNARY) + signal.signal(signal.SIGINT, handle_sigint) + per_process_rpc_future = multicallable.future( + _MESSAGE, wait_for_ready=True) + result = per_process_rpc_future.result() + assert False, _ASSERTION_MESSAGE + + +def main_streaming(server_target): + global per_process_rpc_future # pylint: disable=global-statement + with grpc.insecure_channel(server_target) as channel: + signal.signal(signal.SIGINT, handle_sigint) + per_process_rpc_future = channel.unary_stream(UNARY_STREAM)( + _MESSAGE, wait_for_ready=True) + for result in per_process_rpc_future: + pass + assert False, _ASSERTION_MESSAGE + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Signal test client.') + parser.add_argument('server', help='Server target') + parser.add_argument( + 'arity', help='RPC arity', choices=('unary', 'streaming')) + args = parser.parse_args() + if args.arity == 'unary': + main_unary(args.server) + else: + main_streaming(args.server) diff --git a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py new file mode 100644 index 00000000000..9d0d64709af --- /dev/null +++ b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py @@ -0,0 +1,158 @@ +# Copyright 2019 the gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Test of responsiveness to signals.""" + +from __future__ import print_function + +import logging +import os +import signal +import subprocess +import tempfile +import threading +import unittest +import sys + +import grpc + +from tests.unit import test_common +from tests.unit import _signal_client + +_CLIENT_PATH = os.path.abspath(os.path.realpath(_signal_client.__file__)) +_HOST = 'localhost' + + +class _GenericHandler(grpc.GenericRpcHandler): + + def __init__(self): + self._connected_clients_lock = threading.RLock() + self._connected_clients_event = threading.Event() + self._connected_clients = 0 + + self._unary_unary_handler = grpc.unary_unary_rpc_method_handler( + self._handle_unary_unary) + self._unary_stream_handler = grpc.unary_stream_rpc_method_handler( + self._handle_unary_stream) + + def _on_client_connect(self): + with self._connected_clients_lock: + self._connected_clients += 1 + self._connected_clients_event.set() + + def _on_client_disconnect(self): + with self._connected_clients_lock: + self._connected_clients -= 1 + if self._connected_clients == 0: + self._connected_clients_event.clear() + + def await_connected_client(self): + """Blocks until a client connects to the server.""" + self._connected_clients_event.wait() + + def _handle_unary_unary(self, request, servicer_context): + """Handles a unary RPC. + + Blocks until the client disconnects and then echoes. + """ + stop_event = threading.Event() + + def on_rpc_end(): + self._on_client_disconnect() + stop_event.set() + + servicer_context.add_callback(on_rpc_end) + self._on_client_connect() + stop_event.wait() + return request + + def _handle_unary_stream(self, request, servicer_context): + """Handles a server streaming RPC. + + Blocks until the client disconnects and then echoes. + """ + stop_event = threading.Event() + + def on_rpc_end(): + self._on_client_disconnect() + stop_event.set() + + servicer_context.add_callback(on_rpc_end) + self._on_client_connect() + stop_event.wait() + yield request + + def service(self, handler_call_details): + if handler_call_details.method == _signal_client.UNARY_UNARY: + return self._unary_unary_handler + elif handler_call_details.method == _signal_client.UNARY_STREAM: + return self._unary_stream_handler + else: + return None + + +def _read_stream(stream): + stream.seek(0) + return stream.read() + + +class SignalHandlingTest(unittest.TestCase): + + def setUp(self): + self._server = test_common.test_server() + self._port = self._server.add_insecure_port('{}:0'.format(_HOST)) + self._handler = _GenericHandler() + self._server.add_generic_rpc_handlers((self._handler,)) + self._server.start() + + def tearDown(self): + self._server.stop(None) + + @unittest.skipIf(os.name == 'nt', 'SIGINT not supported on windows') + def testUnary(self): + """Tests that the server unary code path does not stall signal handlers.""" + server_target = '{}:{}'.format(_HOST, self._port) + with tempfile.TemporaryFile(mode='r') as client_stdout: + with tempfile.TemporaryFile(mode='r') as client_stderr: + client = subprocess.Popen( + (sys.executable, _CLIENT_PATH, server_target, 'unary'), + stdout=client_stdout, + stderr=client_stderr) + self._handler.await_connected_client() + client.send_signal(signal.SIGINT) + self.assertFalse(client.wait(), msg=_read_stream(client_stderr)) + client_stdout.seek(0) + self.assertIn(_signal_client.SIGTERM_MESSAGE, + client_stdout.read()) + + @unittest.skipIf(os.name == 'nt', 'SIGINT not supported on windows') + def testStreaming(self): + """Tests that the server streaming code path does not stall signal handlers.""" + server_target = '{}:{}'.format(_HOST, self._port) + with tempfile.TemporaryFile(mode='r') as client_stdout: + with tempfile.TemporaryFile(mode='r') as client_stderr: + client = subprocess.Popen( + (sys.executable, _CLIENT_PATH, server_target, 'streaming'), + stdout=client_stdout, + stderr=client_stderr) + self._handler.await_connected_client() + client.send_signal(signal.SIGINT) + self.assertFalse(client.wait(), msg=_read_stream(client_stderr)) + client_stdout.seek(0) + self.assertIn(_signal_client.SIGTERM_MESSAGE, + client_stdout.read()) + + +if __name__ == '__main__': + logging.basicConfig() + unittest.main(verbosity=2) From f7182fe4f2f3b4fe91885b20fd91ff9a4f3ecf3a Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 3 Jul 2019 14:32:01 -0700 Subject: [PATCH 0811/1555] Add explanation to _signal_client --- src/python/grpcio_tests/tests/unit/_signal_client.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/python/grpcio_tests/tests/unit/_signal_client.py b/src/python/grpcio_tests/tests/unit/_signal_client.py index da413db3b94..65ddd6d858e 100644 --- a/src/python/grpcio_tests/tests/unit/_signal_client.py +++ b/src/python/grpcio_tests/tests/unit/_signal_client.py @@ -49,6 +49,7 @@ def handle_sigint(unused_signum, unused_frame): def main_unary(server_target): + """Initiate a unary RPC to be interrupted by a SIGINT.""" global per_process_rpc_future # pylint: disable=global-statement with grpc.insecure_channel(server_target) as channel: multicallable = channel.unary_unary(UNARY_UNARY) @@ -60,6 +61,7 @@ def main_unary(server_target): def main_streaming(server_target): + """Initiate a streaming RPC to be interrupted by a SIGINT.""" global per_process_rpc_future # pylint: disable=global-statement with grpc.insecure_channel(server_target) as channel: signal.signal(signal.SIGINT, handle_sigint) From b41ded289e12e7fc96222fd1dbd7a508c164aac1 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 3 Jul 2019 12:35:12 -0700 Subject: [PATCH 0812/1555] WIP. Check for NULL --- src/core/lib/iomgr/fork_posix.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/fork_posix.cc b/src/core/lib/iomgr/fork_posix.cc index 629b08162fb..444d2574c7e 100644 --- a/src/core/lib/iomgr/fork_posix.cc +++ b/src/core/lib/iomgr/fork_posix.cc @@ -59,8 +59,9 @@ void grpc_prefork() { "environment variable GRPC_ENABLE_FORK_SUPPORT=1"); return; } - if (strcmp(grpc_get_poll_strategy_name(), "epoll1") != 0 && - strcmp(grpc_get_poll_strategy_name(), "poll") != 0) { + const char * poll_strategy_name = grpc_get_poll_strategy_name(); + if (poll_strategy_name == nullptr || strcmp(poll_strategy_name, "epoll1") != 0 && + strcmp(poll_strategy_name, "poll") != 0) { gpr_log(GPR_INFO, "Fork support is only compatible with the epoll1 and poll polling " "strategies"); From 5e35a367d94a2b37897a256737dd1bd73658eb2f Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Wed, 3 Jul 2019 18:52:29 -0400 Subject: [PATCH 0813/1555] Revert "Clearly callout the behavior for listening ports." --- include/grpcpp/server_builder_impl.h | 4 ---- src/core/lib/gprpp/host_port.cc | 23 ++++++++++++++++++----- test/core/gprpp/host_port_test.cc | 2 ++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/include/grpcpp/server_builder_impl.h b/include/grpcpp/server_builder_impl.h index 9c69adc9147..7f85e807d07 100644 --- a/include/grpcpp/server_builder_impl.h +++ b/include/grpcpp/server_builder_impl.h @@ -112,10 +112,6 @@ class ServerBuilder { /// /// It can be invoked multiple times. /// - /// If port is not provided in the \a addr (e.g., "1.2.3.4:" or "1.2.3.4"), - /// the default port (i.e., https) is used. To request an ephemeral port, - /// \a addr must include 0 as the port number (e.g., "1.2.3.4:0"). - /// /// \param addr_uri The address to try to bind to the server in URI form. If /// the scheme name is omitted, "dns:///" is assumed. To bind to any address, /// please use IPv6 any, i.e., [::]:, which also accepts IPv4 diff --git a/src/core/lib/gprpp/host_port.cc b/src/core/lib/gprpp/host_port.cc index 13b63eb902b..e7f0e4461e9 100644 --- a/src/core/lib/gprpp/host_port.cc +++ b/src/core/lib/gprpp/host_port.cc @@ -44,7 +44,10 @@ int JoinHostPort(UniquePtr* out, const char* host, int port) { return ret; } -bool SplitHostPort(StringView name, StringView* host, StringView* port) { +namespace { +bool DoSplitHostPort(StringView name, StringView* host, StringView* port, + bool* has_port) { + *has_port = false; if (name[0] == '[') { /* Parse a bracketed host, typically an IPv6 literal. */ const size_t rbracket = name.find(']', 1); @@ -58,6 +61,7 @@ bool SplitHostPort(StringView name, StringView* host, StringView* port) { } else if (name[rbracket + 1] == ':') { /* ]: */ *port = name.substr(rbracket + 2, name.size() - rbracket - 2); + *has_port = true; } else { /* ] */ return false; @@ -76,6 +80,7 @@ bool SplitHostPort(StringView name, StringView* host, StringView* port) { /* Exactly 1 colon. Split into host:port. */ *host = name.substr(0, colon); *port = name.substr(colon + 1, name.size() - colon - 1); + *has_port = true; } else { /* 0 or 2+ colons. Bare hostname or IPv6 litearal. */ *host = name; @@ -84,6 +89,12 @@ bool SplitHostPort(StringView name, StringView* host, StringView* port) { } return true; } +} // namespace + +bool SplitHostPort(StringView name, StringView* host, StringView* port) { + bool unused; + return DoSplitHostPort(name, host, port, &unused); +} bool SplitHostPort(StringView name, UniquePtr* host, UniquePtr* port) { @@ -91,12 +102,14 @@ bool SplitHostPort(StringView name, UniquePtr* host, GPR_DEBUG_ASSERT(port != nullptr && *port == nullptr); StringView host_view; StringView port_view; - const bool ret = SplitHostPort(name, &host_view, &port_view); + bool has_port; + const bool ret = DoSplitHostPort(name, &host_view, &port_view, &has_port); if (ret) { - // We always set the host, but port is set only when it's non-empty, - // to remain backward compatible with the old split_host_port API. + // We always set the host, but port is set only when DoSplitHostPort find a + // port in the string, to remain backward compatible with the old + // gpr_split_host_port API. *host = host_view.dup(); - if (!port_view.empty()) { + if (has_port) { *port = port_view.dup(); } } diff --git a/test/core/gprpp/host_port_test.cc b/test/core/gprpp/host_port_test.cc index 3b392da66e8..cfe0eddb036 100644 --- a/test/core/gprpp/host_port_test.cc +++ b/test/core/gprpp/host_port_test.cc @@ -71,7 +71,9 @@ static void test_split_host_port() { split_host_port_expect("", "", nullptr, true); split_host_port_expect("[a:b]", "a:b", nullptr, true); split_host_port_expect("1.2.3.4", "1.2.3.4", nullptr, true); + split_host_port_expect("0.0.0.0:", "0.0.0.0", "", true); split_host_port_expect("a:b:c::", "a:b:c::", nullptr, true); + split_host_port_expect("[a:b:c::]:", "a:b:c::", "", true); split_host_port_expect("[a:b]:30", "a:b", "30", true); split_host_port_expect("1.2.3.4:30", "1.2.3.4", "30", true); split_host_port_expect(":30", "", "30", true); From eab6f7a64b31226f73535bca97ca14c1c14b421c Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 3 Jul 2019 16:02:29 -0700 Subject: [PATCH 0814/1555] Clang format --- src/core/lib/iomgr/fork_posix.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/lib/iomgr/fork_posix.cc b/src/core/lib/iomgr/fork_posix.cc index 444d2574c7e..248e9ae5f54 100644 --- a/src/core/lib/iomgr/fork_posix.cc +++ b/src/core/lib/iomgr/fork_posix.cc @@ -59,9 +59,10 @@ void grpc_prefork() { "environment variable GRPC_ENABLE_FORK_SUPPORT=1"); return; } - const char * poll_strategy_name = grpc_get_poll_strategy_name(); - if (poll_strategy_name == nullptr || strcmp(poll_strategy_name, "epoll1") != 0 && - strcmp(poll_strategy_name, "poll") != 0) { + const char* poll_strategy_name = grpc_get_poll_strategy_name(); + if (poll_strategy_name == nullptr || + strcmp(poll_strategy_name, "epoll1") != 0 && + strcmp(poll_strategy_name, "poll") != 0) { gpr_log(GPR_INFO, "Fork support is only compatible with the epoll1 and poll polling " "strategies"); From dd22893c322dcd7c4425d5a2aba26789fa4fbc23 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 3 Jul 2019 16:03:23 -0700 Subject: [PATCH 0815/1555] Clarify API contract for grpc_get_poll_strategy_name --- src/core/lib/iomgr/ev_posix.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc index d78ac2dac2d..02e4da1c349 100644 --- a/src/core/lib/iomgr/ev_posix.cc +++ b/src/core/lib/iomgr/ev_posix.cc @@ -206,7 +206,8 @@ void grpc_register_event_engine_factory(const char* name, GPR_ASSERT(false); } -/* Call this only after calling grpc_event_engine_init() */ +/*If grpc_event_engine_init() has been called, returns the poll_strategy_name. + * Otherwise, returns nullptr. */ const char* grpc_get_poll_strategy_name() { return g_poll_strategy_name; } void grpc_event_engine_init(void) { From 5087ab48bf5377c2dc89fe7b28b5dbbefab5889c Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 3 Jul 2019 16:22:40 -0700 Subject: [PATCH 0816/1555] Reenable signal handling test --- src/python/grpcio_tests/commands.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/python/grpcio_tests/commands.py b/src/python/grpcio_tests/commands.py index 166cea101a4..dc0795d4a12 100644 --- a/src/python/grpcio_tests/commands.py +++ b/src/python/grpcio_tests/commands.py @@ -145,8 +145,6 @@ class TestGevent(setuptools.Command): 'unit._exit_test.ExitTest.test_in_flight_partial_unary_stream_call', 'unit._exit_test.ExitTest.test_in_flight_partial_stream_unary_call', 'unit._exit_test.ExitTest.test_in_flight_partial_stream_stream_call', - # TODO(https://github.com/grpc/grpc/issues/18980): Reenable. - 'unit._signal_handling_test.SignalHandlingTest', 'unit._metadata_flags_test', 'health_check._health_servicer_test.HealthServicerTest.test_cancelled_watch_removed_from_watch_list', # TODO(https://github.com/grpc/grpc/issues/17330) enable these three tests From 6bcd74e903ac2e5491026e550dfcc744be27a411 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 3 Jul 2019 16:58:38 -0700 Subject: [PATCH 0817/1555] Add parentheses --- src/core/lib/iomgr/fork_posix.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/fork_posix.cc b/src/core/lib/iomgr/fork_posix.cc index 248e9ae5f54..e678b4f5905 100644 --- a/src/core/lib/iomgr/fork_posix.cc +++ b/src/core/lib/iomgr/fork_posix.cc @@ -61,8 +61,8 @@ void grpc_prefork() { } const char* poll_strategy_name = grpc_get_poll_strategy_name(); if (poll_strategy_name == nullptr || - strcmp(poll_strategy_name, "epoll1") != 0 && - strcmp(poll_strategy_name, "poll") != 0) { + (strcmp(poll_strategy_name, "epoll1") != 0 && + strcmp(poll_strategy_name, "poll") != 0)) { gpr_log(GPR_INFO, "Fork support is only compatible with the epoll1 and poll polling " "strategies"); From b0b81792ee4d12a68a3382b8a008217706c55617 Mon Sep 17 00:00:00 2001 From: yunjiaw26 <50971092+yunjiaw26@users.noreply.github.com> Date: Wed, 3 Jul 2019 18:00:14 -0700 Subject: [PATCH 0818/1555] Delete bm_threadpool.cc --- test/cpp/microbenchmarks/bm_threadpool.cc | 327 ---------------------- 1 file changed, 327 deletions(-) delete mode 100644 test/cpp/microbenchmarks/bm_threadpool.cc diff --git a/test/cpp/microbenchmarks/bm_threadpool.cc b/test/cpp/microbenchmarks/bm_threadpool.cc deleted file mode 100644 index 601108aacab..00000000000 --- a/test/cpp/microbenchmarks/bm_threadpool.cc +++ /dev/null @@ -1,327 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "src/core/lib/iomgr/executor/threadpool.h" - -#include - -#include - -#include "test/cpp/microbenchmarks/helpers.h" -#include "test/cpp/util/test_config.h" - -namespace grpc { -namespace testing { - -// This helper class allows a thread to block for s pre-specified number of -// actions. BlockingCounter has a initial non-negative count on initialization -// Each call to DecrementCount will decrease the count by 1. When making a call -// to Wait, if the count is greater than 0, the thread will be block, until -// the count reaches 0, it will unblock. -class BlockingCounter { - public: - BlockingCounter(int count) : count_(count) {} - void DecrementCount() { - std::lock_guard l(mu_); - count_--; - cv_.notify_one(); - } - - void Wait() { - std::unique_lock l(mu_); - while (count_ > 0) { - cv_.wait(l); - } - } - - private: - int count_; - std::mutex mu_; - std::condition_variable cv_; -}; - -// This is a functor/closure class for threadpool microbenchmark. -// This functor (closure) class will add another functor into pool if the -// number passed in (num_add) is greater than 0. Otherwise, it will decrement -// the counter to indicate that task is finished. This functor will suicide at -// the end, therefore, no need for caller to do clean-ups. -class AddAnotherFunctor : public grpc_experimental_completion_queue_functor { - public: - AddAnotherFunctor(grpc_core::ThreadPool* pool, BlockingCounter* counter, - int num_add) - : pool_(pool), counter_(counter), num_add_(num_add) { - functor_run = &AddAnotherFunctor::Run; - internal_next = this; - internal_success = 0; - } - ~AddAnotherFunctor() {} - // When the functor gets to run in thread pool, it will take internal_next - // as first argument and internal_success as second one. Therefore, the - // first argument here would be the closure itself. - static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { - auto* callback = static_cast(cb); - if (--callback->num_add_ > 0) { - callback->pool_->Add(new AddAnotherFunctor( - callback->pool_, callback->counter_, callback->num_add_)); - } else { - callback->counter_->DecrementCount(); - } - // Suicide - delete callback; - } - - private: - grpc_core::ThreadPool* pool_; - BlockingCounter* counter_; - int num_add_; -}; - -void ThreadPoolAddAnotherHelper(benchmark::State& state, - int concurrent_functor) { - const int num_threads = state.range(0); - const int num_iterations = state.range(1); - // number of adds done by each closure - const int num_add = num_iterations / concurrent_functor; - grpc_core::ThreadPool pool(num_threads); - while (state.KeepRunningBatch(num_iterations)) { - BlockingCounter* counter = new BlockingCounter(concurrent_functor); - for (int i = 0; i < concurrent_functor; ++i) { - pool.Add(new AddAnotherFunctor(&pool, counter, num_add)); - } - counter->Wait(); - delete counter; - } - state.SetItemsProcessed(state.iterations()); -} - -// This benchmark will let a closure add a new closure into pool. Concurrent -// closures range from 1 to 2048 -static void BM_ThreadPool1AddAnother(benchmark::State& state) { - ThreadPoolAddAnotherHelper(state, 1); -} -BENCHMARK(BM_ThreadPool1AddAnother) - ->UseRealTime() - // First pair is range for number of threads in pool, second pair is range - // for number of iterations - ->Ranges({{1, 1024}, {524288, 2097152}}); // 512K ~ 2M - -static void BM_ThreadPool4AddAnother(benchmark::State& state) { - ThreadPoolAddAnotherHelper(state, 4); -} -BENCHMARK(BM_ThreadPool4AddAnother) - ->UseRealTime() - ->Ranges({{1, 1024}, {524288, 2097152}}); - -static void BM_ThreadPool8AddAnother(benchmark::State& state) { - ThreadPoolAddAnotherHelper(state, 8); -} -BENCHMARK(BM_ThreadPool8AddAnother) - ->UseRealTime() - ->Ranges({{1, 1024}, {524288, 1048576}}); // 512K ~ 1M - -static void BM_ThreadPool16AddAnother(benchmark::State& state) { - ThreadPoolAddAnotherHelper(state, 16); -} -BENCHMARK(BM_ThreadPool16AddAnother) - ->UseRealTime() - ->Ranges({{1, 1024}, {524288, 1048576}}); - -static void BM_ThreadPool32AddAnother(benchmark::State& state) { - ThreadPoolAddAnotherHelper(state, 32); -} -BENCHMARK(BM_ThreadPool32AddAnother) - ->UseRealTime() - ->Ranges({{1, 1024}, {524288, 1048576}}); - -static void BM_ThreadPool64AddAnother(benchmark::State& state) { - ThreadPoolAddAnotherHelper(state, 64); -} -BENCHMARK(BM_ThreadPool64AddAnother) - ->UseRealTime() - ->Ranges({{1, 1024}, {524288, 1048576}}); - -static void BM_ThreadPool128AddAnother(benchmark::State& state) { - ThreadPoolAddAnotherHelper(state, 128); -} -BENCHMARK(BM_ThreadPool128AddAnother) - ->UseRealTime() - ->Ranges({{1, 1024}, {524288, 1048576}}); - -static void BM_ThreadPool512AddAnother(benchmark::State& state) { - ThreadPoolAddAnotherHelper(state, 512); -} -BENCHMARK(BM_ThreadPool512AddAnother) - ->UseRealTime() - ->Ranges({{1, 1024}, {524288, 1048576}}); - -static void BM_ThreadPool2048AddAnother(benchmark::State& state) { - ThreadPoolAddAnotherHelper(state, 2048); -} -BENCHMARK(BM_ThreadPool2048AddAnother) - ->UseRealTime() - ->Ranges({{1, 1024}, {524288, 1048576}}); - -// A functor class that will delete self on end of running. -class SuicideFunctorForAdd : public grpc_experimental_completion_queue_functor { - public: - SuicideFunctorForAdd() { - functor_run = &SuicideFunctorForAdd::Run; - internal_next = this; - internal_success = 0; - } - ~SuicideFunctorForAdd() {} - static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { - // On running, the first argument would be internal_next, which is itself. - delete cb; - } -}; - -// Performs the scenario of external thread(s) adding closures into pool. -static void BM_ThreadPoolExternalAdd(benchmark::State& state) { - const int num_threads = state.range(0); - static grpc_core::ThreadPool* pool = - grpc_core::New(num_threads); - for (auto _ : state) { - pool->Add(new SuicideFunctorForAdd()); - } - state.SetItemsProcessed(state.iterations()); -} -BENCHMARK(BM_ThreadPoolExternalAdd) - ->Range(1, 1024) - ->ThreadRange(1, 1024) // concurrent external thread(s) up to 1024 - ->UseRealTime(); - -// Functor (closure) that adds itself into pool repeatedly. By adding self, the -// overhead would be low and can measure the time of add more accurately. -class AddSelfFunctor : public grpc_experimental_completion_queue_functor { - public: - AddSelfFunctor(grpc_core::ThreadPool* pool, BlockingCounter* counter, - int num_add) - : pool_(pool), counter_(counter), num_add_(num_add) { - functor_run = &AddSelfFunctor::Run; - internal_next = this; - internal_success = 0; - } - ~AddSelfFunctor() {} - // When the functor gets to run in thread pool, it will take internal_next - // as first argument and internal_success as second one. Therefore, the - // first argument here would be the closure itself. - static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { - auto* callback = static_cast(cb); - if (--callback->num_add_ > 0) { - callback->pool_->Add(cb); - } else { - callback->counter_->DecrementCount(); - // Suicide - delete callback; - } - } - - private: - grpc_core::ThreadPool* pool_; - BlockingCounter* counter_; - int num_add_; -}; - -static void BM_ThreadPoolAddSelf(benchmark::State& state) { - const int num_threads = state.range(0); - const int kNumIteration = 524288; - int concurrent_functor = num_threads; - int num_add = kNumIteration / concurrent_functor; - grpc_core::ThreadPool pool(num_threads); - while (state.KeepRunningBatch(kNumIteration)) { - BlockingCounter* counter = new BlockingCounter(concurrent_functor); - for (int i = 0; i < concurrent_functor; ++i) { - pool.Add(new AddSelfFunctor(&pool, counter, num_add)); - } - counter->Wait(); - delete counter; - } - state.SetItemsProcessed(state.iterations()); -} - -BENCHMARK(BM_ThreadPoolAddSelf)->UseRealTime()->Range(1, 1024); - -// A functor (closure) that simulates closures with small but non-trivial amount -// of work. -class ShortWorkFunctorForAdd - : public grpc_experimental_completion_queue_functor { - public: - BlockingCounter* counter_; - - ShortWorkFunctorForAdd() { - functor_run = &ShortWorkFunctorForAdd::Run; - internal_next = this; - internal_success = 0; - val_ = 0; - } - ~ShortWorkFunctorForAdd() {} - static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { - auto* callback = static_cast(cb); - for (int i = 0; i < 1000; ++i) { - callback->val_++; - } - callback->counter_->DecrementCount(); - } - - private: - int val_; -}; - -// Simulates workloads where many short running callbacks are added to the -// threadpool. The callbacks are not enough to keep all the workers busy -// continuously so the number of workers running changes overtime. -// -// In effect this tests how well the threadpool avoids spurious wakeups. -static void BM_SpikyLoad(benchmark::State& state) { - const int num_threads = state.range(0); - - const int kNumSpikes = 1000; - const int batch_size = 3 * num_threads; - std::vector work_vector(batch_size); - while (state.KeepRunningBatch(kNumSpikes * batch_size)) { - grpc_core::ThreadPool pool(num_threads); - for (int i = 0; i != kNumSpikes; ++i) { - BlockingCounter counter(batch_size); - for (auto& w : work_vector) { - w.counter_ = &counter; - pool.Add(&w); - } - counter.Wait(); - } - } - state.SetItemsProcessed(state.iterations() * batch_size); -} -BENCHMARK(BM_SpikyLoad)->Arg(1)->Arg(2)->Arg(4)->Arg(8)->Arg(16); - -} // namespace testing -} // namespace grpc - -// Some distros have RunSpecifiedBenchmarks under the benchmark namespace, -// and others do not. This allows us to support both modes. -namespace benchmark { -void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } -} // namespace benchmark - -int main(int argc, char** argv) { - LibraryInitializer libInit; - ::benchmark::Initialize(&argc, argv); - ::grpc::testing::InitTest(&argc, &argv, false); - benchmark::RunTheBenchmarksNamespaced(); - return 0; -} From fdc250d6189b636ecfda7b2314662e62a9bbe868 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Wed, 3 Jul 2019 18:23:12 -0700 Subject: [PATCH 0819/1555] remove bencharmk --- test/cpp/microbenchmarks/BUILD | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD index 576eab554a4..d9424f24f16 100644 --- a/test/cpp/microbenchmarks/BUILD +++ b/test/cpp/microbenchmarks/BUILD @@ -214,14 +214,6 @@ grpc_cc_binary( ], ) -grpc_cc_binary( - name = "bm_threadpool", - testonly = 1, - srcs = ["bm_threadpool.cc"], - tags = ["no_windows"], - deps = [":helpers"], -) - grpc_cc_binary( name = "bm_timer", testonly = 1, From b6e104f22f6baec437828014611a196f4cf72c4b Mon Sep 17 00:00:00 2001 From: mgravell Date: Thu, 4 Jul 2019 08:21:17 +0100 Subject: [PATCH 0820/1555] make use of Encoding.GetString(byte*, int) when available; poly-fill when not available (NET45); move related logic to extension class --- src/csharp/Grpc.Core.Api/Metadata.cs | 17 ++------- .../Grpc.Core.Api/Utils/EncodingExtensions.cs | 36 +++++++++++++++++++ src/csharp/Grpc.Core/Internal/MarshalUtils.cs | 23 ++++-------- 3 files changed, 45 insertions(+), 31 deletions(-) create mode 100644 src/csharp/Grpc.Core.Api/Utils/EncodingExtensions.cs diff --git a/src/csharp/Grpc.Core.Api/Metadata.cs b/src/csharp/Grpc.Core.Api/Metadata.cs index 7a04a2ee859..cd1ea3b4676 100644 --- a/src/csharp/Grpc.Core.Api/Metadata.cs +++ b/src/csharp/Grpc.Core.Api/Metadata.cs @@ -19,7 +19,7 @@ using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; -using System.Text.RegularExpressions; +using Grpc.Core.Api.Utils; using Grpc.Core.Utils; @@ -364,20 +364,7 @@ namespace Grpc.Core } else { - string s; - if (length == 0) - { - s = ""; - } - else - { - int charCount = EncodingASCII.GetCharCount(source, length); - s = new string('\0', charCount); - fixed (char* cPtr = s) - { - EncodingASCII.GetChars(source, length, cPtr, charCount); - } - } + string s = length == 0 ? "" : EncodingASCII.GetString(source, length); return new Entry(key, s, null); } } diff --git a/src/csharp/Grpc.Core.Api/Utils/EncodingExtensions.cs b/src/csharp/Grpc.Core.Api/Utils/EncodingExtensions.cs new file mode 100644 index 00000000000..ef38baf5cc4 --- /dev/null +++ b/src/csharp/Grpc.Core.Api/Utils/EncodingExtensions.cs @@ -0,0 +1,36 @@ +using System; +using System.Text; + +namespace Grpc.Core.Api.Utils +{ + + internal static class EncodingExtensions + { +#if NET45 // back-fill over a method missing in NET45 + /// + /// Converts byte* pointing to an encoded byte array to a string using the provided Encoding. + /// + public static unsafe string GetString(this Encoding encoding, byte* source, int byteCount) + { + if (byteCount == 0) return ""; // most callers will have already checked, but: make sure + + // allocate a right-sized string and decode into it + int charCount = encoding.GetCharCount(source, byteCount); + string s = new string('\0', charCount); + fixed (char* cPtr = s) + { + encoding.GetChars(source, byteCount, cPtr, charCount); + } + return s; + } +#endif + /// + /// Converts IntPtr pointing to a encoded byte array to a string using the provided Encoding. + /// + public static unsafe string GetString(this Encoding encoding, IntPtr ptr, int len) + { + return len == 0 ? "" : encoding.GetString((byte*)ptr.ToPointer(), len); + } + } + +} diff --git a/src/csharp/Grpc.Core/Internal/MarshalUtils.cs b/src/csharp/Grpc.Core/Internal/MarshalUtils.cs index 54b4370935d..313e2b5c9d7 100644 --- a/src/csharp/Grpc.Core/Internal/MarshalUtils.cs +++ b/src/csharp/Grpc.Core/Internal/MarshalUtils.cs @@ -17,8 +17,9 @@ #endregion using System; -using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using System.Text; +using Grpc.Core.Api.Utils; namespace Grpc.Core.Internal { @@ -32,22 +33,10 @@ namespace Grpc.Core.Internal /// /// Converts IntPtr pointing to a UTF-8 encoded byte array to string. /// - public static unsafe string PtrToStringUTF8(IntPtr ptr, int len) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static string PtrToStringUTF8(IntPtr ptr, int len) { - if (len == 0) - { - return ""; - } - - // allocate a right-sized string and decode into it - byte* source = (byte*)ptr.ToPointer(); - int charCount = EncodingUTF8.GetCharCount(source, len); - string s = new string('\0', charCount); - fixed(char* cPtr = s) - { - EncodingUTF8.GetChars(source, len, cPtr, charCount); - } - return s; + return EncodingUTF8.GetString(ptr, len); } /// @@ -66,6 +55,7 @@ namespace Grpc.Core.Internal /// /// Returns the maximum number of bytes required to encode a given string. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetMaxByteCountUTF8(string str) { return EncodingUTF8.GetMaxByteCount(str.Length); @@ -74,6 +64,7 @@ namespace Grpc.Core.Internal /// /// Returns the actual number of bytes required to encode a given string. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetByteCountUTF8(string str) { return EncodingUTF8.GetByteCount(str); From b3528734616b49055c9f6ae2d647cf8423462ac2 Mon Sep 17 00:00:00 2001 From: mgravell Date: Thu, 4 Jul 2019 08:30:51 +0100 Subject: [PATCH 0821/1555] UTF encode/native: use IntPtr, not byte*, in the native API (avoid "unsafe" declaration) --- .../Grpc.Core/Internal/CallSafeHandle.cs | 55 ++++++++++--------- .../Internal/NativeMethods.Generated.cs | 6 +- src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs | 13 ++--- .../Grpc.Core/Internal/native_methods.include | 4 +- 4 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs index c62297b0972..2e637c9704b 100644 --- a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs @@ -128,7 +128,7 @@ namespace Grpc.Core.Internal } } - public unsafe void StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, + public void StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, byte[] optionalPayload, WriteFlags writeFlags) { using (completionQueue.NewScope()) @@ -146,32 +146,35 @@ namespace Grpc.Core.Internal maxBytes = MarshalUtils.GetByteCountUTF8(status.Detail); } - if (maxBytes <= MaxStackAllocBytes) - { // for small status, we can encode on the stack without touching arrays - // note: if init-locals is disabled, it would be more efficient - // to just stackalloc[MaxStackAllocBytes]; but by default, since we - // expect this to be small and it needs to wipe, just use maxBytes - byte* ptr = stackalloc byte[maxBytes]; - int statusBytes = MarshalUtils.GetBytesUTF8(status.Detail, ptr, maxBytes); - Native.grpcsharp_call_send_status_from_server(this, ctx, status.StatusCode, ptr, new UIntPtr((ulong)statusBytes), metadataArray, sendEmptyInitialMetadata ? 1 : 0, - optionalPayload, optionalPayloadLength, writeFlags).CheckOk(); - } - else - { // for larger status (rare), rent a buffer from the pool and - // use that for encoding - var statusBuffer = ArrayPool.Shared.Rent(maxBytes); - try - { - fixed (byte* ptr = statusBuffer) - { - int statusBytes = MarshalUtils.GetBytesUTF8(status.Detail, ptr, maxBytes); - Native.grpcsharp_call_send_status_from_server(this, ctx, status.StatusCode, ptr, new UIntPtr((ulong)statusBytes), metadataArray, sendEmptyInitialMetadata ? 1 : 0, - optionalPayload, optionalPayloadLength, writeFlags).CheckOk(); - } + unsafe + { + if (maxBytes <= MaxStackAllocBytes) + { // for small status, we can encode on the stack without touching arrays + // note: if init-locals is disabled, it would be more efficient + // to just stackalloc[MaxStackAllocBytes]; but by default, since we + // expect this to be small and it needs to wipe, just use maxBytes + byte* ptr = stackalloc byte[maxBytes]; + int statusBytes = MarshalUtils.GetBytesUTF8(status.Detail, ptr, maxBytes); + Native.grpcsharp_call_send_status_from_server(this, ctx, status.StatusCode, new IntPtr(ptr), new UIntPtr((ulong)statusBytes), metadataArray, sendEmptyInitialMetadata ? 1 : 0, + optionalPayload, optionalPayloadLength, writeFlags).CheckOk(); } - finally - { - ArrayPool.Shared.Return(statusBuffer); + else + { // for larger status (rare), rent a buffer from the pool and + // use that for encoding + var statusBuffer = ArrayPool.Shared.Rent(maxBytes); + try + { + fixed (byte* ptr = statusBuffer) + { + int statusBytes = MarshalUtils.GetBytesUTF8(status.Detail, ptr, maxBytes); + Native.grpcsharp_call_send_status_from_server(this, ctx, status.StatusCode, new IntPtr(ptr), new UIntPtr((ulong)statusBytes), metadataArray, sendEmptyInitialMetadata ? 1 : 0, + optionalPayload, optionalPayloadLength, writeFlags).CheckOk(); + } + } + finally + { + ArrayPool.Shared.Return(statusBuffer); + } } } } diff --git a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs index e67263edbda..d98f0226e3f 100644 --- a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs +++ b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs @@ -475,7 +475,7 @@ namespace Grpc.Core.Internal public delegate CallError grpcsharp_call_start_duplex_streaming_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); public delegate CallError grpcsharp_call_send_message_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, int sendEmptyInitialMetadata); public delegate CallError grpcsharp_call_send_close_from_client_delegate(CallSafeHandle call, BatchContextSafeHandle ctx); - public unsafe delegate CallError grpcsharp_call_send_status_from_server_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, byte* statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); + public delegate CallError grpcsharp_call_send_status_from_server_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); public delegate CallError grpcsharp_call_recv_message_delegate(CallSafeHandle call, BatchContextSafeHandle ctx); public delegate CallError grpcsharp_call_recv_initial_metadata_delegate(CallSafeHandle call, BatchContextSafeHandle ctx); public delegate CallError grpcsharp_call_start_serverside_delegate(CallSafeHandle call, BatchContextSafeHandle ctx); @@ -643,7 +643,7 @@ namespace Grpc.Core.Internal public static extern CallError grpcsharp_call_send_close_from_client(CallSafeHandle call, BatchContextSafeHandle ctx); [DllImport(ImportName)] - public static unsafe extern CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, byte* statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); + public static extern CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); [DllImport(ImportName)] public static extern CallError grpcsharp_call_recv_message(CallSafeHandle call, BatchContextSafeHandle ctx); @@ -939,7 +939,7 @@ namespace Grpc.Core.Internal public static extern CallError grpcsharp_call_send_close_from_client(CallSafeHandle call, BatchContextSafeHandle ctx); [DllImport(ImportName)] - public static unsafe extern CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, byte* statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); + public static extern CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); [DllImport(ImportName)] public static extern CallError grpcsharp_call_recv_message(CallSafeHandle call, BatchContextSafeHandle ctx); diff --git a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs index 990f6fbb48e..a59afa19118 100644 --- a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs +++ b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs @@ -61,14 +61,11 @@ namespace Grpc.Microbenchmarks var native = NativeMethods.Get(); // nop the native-call via reflection - unsafe - { - NativeMethods.Delegates.grpcsharp_call_send_status_from_server_delegate nop = (CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, byte* statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags) => { - completionRegistry.Extract(ctx.Handle).OnComplete(true); // drain the dictionary as we go - return CallError.OK; - }; - native.GetType().GetField(nameof(native.grpcsharp_call_send_status_from_server)).SetValue(native, nop); - } + NativeMethods.Delegates.grpcsharp_call_send_status_from_server_delegate nop = (CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags) => { + completionRegistry.Extract(ctx.Handle).OnComplete(true); // drain the dictionary as we go + return CallError.OK; + }; + native.GetType().GetField(nameof(native.grpcsharp_call_send_status_from_server)).SetValue(native, nop); environment = GrpcEnvironment.AddRef(); metadata = MetadataArraySafeHandle.Create(Metadata.Empty); diff --git a/templates/src/csharp/Grpc.Core/Internal/native_methods.include b/templates/src/csharp/Grpc.Core/Internal/native_methods.include index 4a31171aa27..ffcaf16bca9 100644 --- a/templates/src/csharp/Grpc.Core/Internal/native_methods.include +++ b/templates/src/csharp/Grpc.Core/Internal/native_methods.include @@ -31,7 +31,7 @@ native_method_signatures = [ 'CallError grpcsharp_call_start_duplex_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', 'CallError grpcsharp_call_send_message(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, int sendEmptyInitialMetadata)', 'CallError grpcsharp_call_send_close_from_client(CallSafeHandle call, BatchContextSafeHandle ctx)', - 'CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, byte[] statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags)', + 'CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags)', 'CallError grpcsharp_call_recv_message(CallSafeHandle call, BatchContextSafeHandle ctx)', 'CallError grpcsharp_call_recv_initial_metadata(CallSafeHandle call, BatchContextSafeHandle ctx)', 'CallError grpcsharp_call_start_serverside(CallSafeHandle call, BatchContextSafeHandle ctx)', @@ -107,4 +107,4 @@ for signature in native_method_signatures: native_methods.append({'returntype': match.group(1), 'name': match.group(2), 'params': match.group(3), 'comment': match.group(4)}) return list(native_methods) -%> \ No newline at end of file +%> From 9967e42a7f31f390a91117b0b28812467036ece5 Mon Sep 17 00:00:00 2001 From: mgravell Date: Thu, 4 Jul 2019 08:32:10 +0100 Subject: [PATCH 0822/1555] review feedback; naming : Blob => ByteArray --- src/csharp/Grpc.Core.Api/Metadata.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/csharp/Grpc.Core.Api/Metadata.cs b/src/csharp/Grpc.Core.Api/Metadata.cs index cd1ea3b4676..0576cb35304 100644 --- a/src/csharp/Grpc.Core.Api/Metadata.cs +++ b/src/csharp/Grpc.Core.Api/Metadata.cs @@ -353,7 +353,7 @@ namespace Grpc.Core byte[] arr; if (length == 0) { - arr = EmptyBlob; + arr = EmptyByteArray; } else { // create a local copy in a fresh array @@ -369,7 +369,7 @@ namespace Grpc.Core } } - static readonly byte[] EmptyBlob = new byte[0]; + static readonly byte[] EmptyByteArray = new byte[0]; private static string NormalizeKey(string key) { From 3ab3f5e586cad0754c4d28d5722954f1edbdc0be Mon Sep 17 00:00:00 2001 From: mgravell Date: Thu, 4 Jul 2019 09:17:01 +0100 Subject: [PATCH 0823/1555] move WellKnownStrings to top-level file; add tests; refactor --- .../Internal/WellKnownStringsTest.cs | 46 +++++++++++++ .../Internal/MetadataArraySafeHandle.cs | 33 ---------- .../Grpc.Core/Internal/WellKnownStrings.cs | 66 +++++++++++++++++++ 3 files changed, 112 insertions(+), 33 deletions(-) create mode 100644 src/csharp/Grpc.Core.Tests/Internal/WellKnownStringsTest.cs create mode 100644 src/csharp/Grpc.Core/Internal/WellKnownStrings.cs diff --git a/src/csharp/Grpc.Core.Tests/Internal/WellKnownStringsTest.cs b/src/csharp/Grpc.Core.Tests/Internal/WellKnownStringsTest.cs new file mode 100644 index 00000000000..f5c8e01a141 --- /dev/null +++ b/src/csharp/Grpc.Core.Tests/Internal/WellKnownStringsTest.cs @@ -0,0 +1,46 @@ +using System.Text; +using Grpc.Core.Internal; +using NUnit.Framework; + +namespace Grpc.Core.Tests.Internal +{ + public class WellKnownStringsTest + { + [Test] + [TestCase("", true)] + [TestCase("u", false)] + [TestCase("us", false)] + [TestCase("use", false)] + [TestCase("user", false)] + [TestCase("user-", false)] + [TestCase("user-a", false)] + [TestCase("user-ag", false)] + [TestCase("user-age", false)] + [TestCase("user-agent", true)] + [TestCase("user-agent ", false)] + [TestCase("useragent ", false)] + [TestCase("User-Agent", false)] + [TestCase("sdlkfjlskjfdlkjs;lfdksflsdfkh skjdfh sdkfhskdhf skjfhk sdhjkjh", false)] + + // test for endianness snafus (reversed in segments) + [TestCase("ega-resutn", false)] + public unsafe void TestWellKnownStrings(string input, bool expected) + { + // create a copy of the data; no cheating! + byte[] bytes = Encoding.ASCII.GetBytes(input); + fixed(byte* ptr = bytes) + { + string result = WellKnownStrings.TryIdentify(ptr, bytes.Length); + if (expected) Assert.AreEqual(input, result); + else Assert.IsNull(result); + + if (expected) + { + // try again, and check we get the same instance + string again = WellKnownStrings.TryIdentify(ptr, bytes.Length); + Assert.AreSame(result, again); + } + } + } + } +} diff --git a/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs b/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs index 1663a9d44ac..cc306891119 100644 --- a/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs @@ -76,39 +76,6 @@ namespace Grpc.Core.Internal return metadata; } - private static class WellKnownStrings - { - // turn a string of ASCII-length 8 into a ulong using the CPUs current - // endianness; this allows us to do the same thing in TryIdentify, - // testing string prefixes (of length >= 8) in a single load/compare - private static unsafe ulong Thunk8(string value) - { - int byteCount = Encoding.ASCII.GetByteCount(value); - if (byteCount != 8) throw new ArgumentException(nameof(value)); - ulong result = 0; - fixed (char* cPtr = value) - { - Encoding.ASCII.GetBytes(cPtr, value.Length, (byte*)&result, byteCount); - } - return result; - } - private static readonly ulong UserAgent = Thunk8("user-age"); - public static unsafe string TryIdentify(byte* source, int length) - { - switch (length) - { - case 10: - // test the first 8 bytes via evilness - ulong first8 = *(ulong*)source; - if (first8 == UserAgent & source[8] == (byte)'n' & source[9] == (byte)'t') - return "user-agent"; - - break; - } - return null; - } - } - internal IntPtr Handle { get diff --git a/src/csharp/Grpc.Core/Internal/WellKnownStrings.cs b/src/csharp/Grpc.Core/Internal/WellKnownStrings.cs new file mode 100644 index 00000000000..1e78ffdab43 --- /dev/null +++ b/src/csharp/Grpc.Core/Internal/WellKnownStrings.cs @@ -0,0 +1,66 @@ +using System; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Grpc.Core.Internal +{ + /// + /// Utility type for identifying "well-known" strings (i.e. headers/keys etc that + /// we expect to see frequently, and don't want to allocate lots of copies of) + /// + internal static class WellKnownStrings + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static unsafe ulong Coerce64(byte* value) + { + return *(ulong*)value; + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static unsafe uint Coerce32(byte* value) + { + return *(uint*)value; + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static unsafe ushort Coerce16(byte* value) + { + return *(ushort*)value; + } + + /// + /// Test whether the provided byte sequence is recognized as a well-known string; if + /// so, return a shared instance of that string; otherwise, return null + /// + public static unsafe string TryIdentify(byte* source, int length) + { + // note: the logic here is hard-coded to constants for optimal processing; + // refer to an ASCII/hex converter (and remember to reverse **segments** for little-endian) + if (BitConverter.IsLittleEndian) // this is a JIT intrinsic; branch removal happens on modern runtimes + { + switch (length) + { + case 0: return ""; + case 10: + switch(Coerce64(source)) + { + case 0x6567612d72657375: return Coerce16(source + 8) == 0x746e ? "user-agent" : null; + } + break; + } + } + else + { + switch (length) + { + case 0: return ""; + case 10: + switch (Coerce64(source)) + { + case 0x757365722d616765: return Coerce16(source + 8) == 0x6e74 ? "user-agent" : null; + } + break; + } + } + return null; + } + } +} From 0628990feb79736d30949951f6e64fb34b157597 Mon Sep 17 00:00:00 2001 From: mgravell Date: Thu, 4 Jul 2019 09:24:15 +0100 Subject: [PATCH 0824/1555] UTF8 decode: remove "unsafe" from a bunch of places that don't need it any more --- src/csharp/Grpc.Core.Api/Metadata.cs | 6 +++--- src/csharp/Grpc.Core.Api/Utils/EncodingExtensions.cs | 2 ++ .../Grpc.Core/Internal/MetadataArraySafeHandle.cs | 6 +++--- src/csharp/Grpc.Core/Internal/WellKnownStrings.cs | 11 +++++++++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/csharp/Grpc.Core.Api/Metadata.cs b/src/csharp/Grpc.Core.Api/Metadata.cs index 0576cb35304..f7f0ae1c93a 100644 --- a/src/csharp/Grpc.Core.Api/Metadata.cs +++ b/src/csharp/Grpc.Core.Api/Metadata.cs @@ -346,7 +346,7 @@ namespace Grpc.Core /// Creates a binary value or ascii value metadata entry from data received from the native layer. /// We trust C core to give us well-formed data, so we don't perform any checks or defensive copying. /// - internal static unsafe Entry CreateUnsafe(string key, byte* source, int length) + internal static Entry CreateUnsafe(string key, IntPtr source, int length) { if (HasBinaryHeaderSuffix(key)) { @@ -358,13 +358,13 @@ namespace Grpc.Core else { // create a local copy in a fresh array arr = new byte[length]; - Marshal.Copy(new IntPtr(source), arr, 0, length); + Marshal.Copy(source, arr, 0, length); } return new Entry(key, null, arr); } else { - string s = length == 0 ? "" : EncodingASCII.GetString(source, length); + string s = EncodingASCII.GetString(source, length); return new Entry(key, s, null); } } diff --git a/src/csharp/Grpc.Core.Api/Utils/EncodingExtensions.cs b/src/csharp/Grpc.Core.Api/Utils/EncodingExtensions.cs index ef38baf5cc4..b516ae0993a 100644 --- a/src/csharp/Grpc.Core.Api/Utils/EncodingExtensions.cs +++ b/src/csharp/Grpc.Core.Api/Utils/EncodingExtensions.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.CompilerServices; using System.Text; namespace Grpc.Core.Api.Utils @@ -27,6 +28,7 @@ namespace Grpc.Core.Api.Utils /// /// Converts IntPtr pointing to a encoded byte array to a string using the provided Encoding. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe string GetString(this Encoding encoding, IntPtr ptr, int len) { return len == 0 ? "" : encoding.GetString((byte*)ptr.ToPointer(), len); diff --git a/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs b/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs index cc306891119..3edfbfa3bfd 100644 --- a/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs @@ -50,7 +50,7 @@ namespace Grpc.Core.Internal /// /// Reads metadata from pointer to grpc_metadata_array /// - public static unsafe Metadata ReadMetadataFromPtrUnsafe(IntPtr metadataArray) + public static Metadata ReadMetadataFromPtrUnsafe(IntPtr metadataArray) { if (metadataArray == IntPtr.Zero) { @@ -66,12 +66,12 @@ namespace Grpc.Core.Internal UIntPtr keyLen; IntPtr keyPtr = Native.grpcsharp_metadata_array_get_key(metadataArray, index, out keyLen); int keyLen32 = checked((int)keyLen.ToUInt32()); - string key = WellKnownStrings.TryIdentify((byte*)keyPtr.ToPointer(), keyLen32) + string key = WellKnownStrings.TryIdentify(keyPtr, keyLen32) ?? Marshal.PtrToStringAnsi(keyPtr, keyLen32); UIntPtr valueLen; IntPtr valuePtr = Native.grpcsharp_metadata_array_get_value(metadataArray, index, out valueLen); int len32 = checked((int)valueLen.ToUInt64()); - metadata.Add(Metadata.Entry.CreateUnsafe(key, (byte*)valuePtr.ToPointer(), len32)); + metadata.Add(Metadata.Entry.CreateUnsafe(key, valuePtr, len32)); } return metadata; } diff --git a/src/csharp/Grpc.Core/Internal/WellKnownStrings.cs b/src/csharp/Grpc.Core/Internal/WellKnownStrings.cs index 1e78ffdab43..bf35134c9be 100644 --- a/src/csharp/Grpc.Core/Internal/WellKnownStrings.cs +++ b/src/csharp/Grpc.Core/Internal/WellKnownStrings.cs @@ -26,6 +26,17 @@ namespace Grpc.Core.Internal return *(ushort*)value; } + + /// + /// Test whether the provided byte sequence is recognized as a well-known string; if + /// so, return a shared instance of that string; otherwise, return null + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static unsafe string TryIdentify(IntPtr source, int length) + { + return TryIdentify((byte*)source.ToPointer(), length); + } + /// /// Test whether the provided byte sequence is recognized as a well-known string; if /// so, return a shared instance of that string; otherwise, return null From 47913c20ab9f13fd8ad7f99283ad311983f1feac Mon Sep 17 00:00:00 2001 From: mgravell Date: Thu, 4 Jul 2019 09:27:18 +0100 Subject: [PATCH 0825/1555] utf8-encode; fix broken test --- src/csharp/Grpc.Core.Tests/MetadataTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/MetadataTest.cs b/src/csharp/Grpc.Core.Tests/MetadataTest.cs index 7286f9c9932..0b5f1c76e0c 100644 --- a/src/csharp/Grpc.Core.Tests/MetadataTest.cs +++ b/src/csharp/Grpc.Core.Tests/MetadataTest.cs @@ -116,7 +116,7 @@ namespace Grpc.Core.Tests var bytes = new byte[] { (byte)'X', (byte)'y' }; fixed (byte* ptr = bytes) { - var entry = Metadata.Entry.CreateUnsafe("abc", ptr, bytes.Length); + var entry = Metadata.Entry.CreateUnsafe("abc", new IntPtr(ptr), bytes.Length); Assert.IsFalse(entry.IsBinary); Assert.AreEqual("abc", entry.Key); Assert.AreEqual("Xy", entry.Value); @@ -130,7 +130,7 @@ namespace Grpc.Core.Tests var bytes = new byte[] { 1, 2, 3 }; fixed (byte* ptr = bytes) { - var entry = Metadata.Entry.CreateUnsafe("abc-bin", ptr, bytes.Length); + var entry = Metadata.Entry.CreateUnsafe("abc-bin", new IntPtr(ptr), bytes.Length); Assert.IsTrue(entry.IsBinary); Assert.AreEqual("abc-bin", entry.Key); Assert.Throws(typeof(InvalidOperationException), () => { var v = entry.Value; }); From ccbde1365bccfa2450011537b89ea8a8bcd86031 Mon Sep 17 00:00:00 2001 From: mgravell Date: Thu, 4 Jul 2019 09:56:45 +0100 Subject: [PATCH 0826/1555] add missing copyright --- .../Grpc.Core.Api/Utils/EncodingExtensions.cs | 16 ++++++++++++++++ .../Internal/WellKnownStringsTest.cs | 16 ++++++++++++++++ .../Grpc.Core/Internal/WellKnownStrings.cs | 17 ++++++++++++++++- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/csharp/Grpc.Core.Api/Utils/EncodingExtensions.cs b/src/csharp/Grpc.Core.Api/Utils/EncodingExtensions.cs index b516ae0993a..7d520d30eae 100644 --- a/src/csharp/Grpc.Core.Api/Utils/EncodingExtensions.cs +++ b/src/csharp/Grpc.Core.Api/Utils/EncodingExtensions.cs @@ -1,3 +1,19 @@ +#region Copyright notice and license +// Copyright 2015 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#endregion + using System; using System.Runtime.CompilerServices; using System.Text; diff --git a/src/csharp/Grpc.Core.Tests/Internal/WellKnownStringsTest.cs b/src/csharp/Grpc.Core.Tests/Internal/WellKnownStringsTest.cs index f5c8e01a141..285f7a12d0a 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/WellKnownStringsTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/WellKnownStringsTest.cs @@ -1,3 +1,19 @@ +#region Copyright notice and license +// Copyright 2015 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#endregion + using System.Text; using Grpc.Core.Internal; using NUnit.Framework; diff --git a/src/csharp/Grpc.Core/Internal/WellKnownStrings.cs b/src/csharp/Grpc.Core/Internal/WellKnownStrings.cs index bf35134c9be..4b95d1f368d 100644 --- a/src/csharp/Grpc.Core/Internal/WellKnownStrings.cs +++ b/src/csharp/Grpc.Core/Internal/WellKnownStrings.cs @@ -1,6 +1,21 @@ +#region Copyright notice and license +// Copyright 2015 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#endregion + using System; using System.Runtime.CompilerServices; -using System.Text; namespace Grpc.Core.Internal { From b98cc917a77dbec83fa09bc2ff5fc30be0447eea Mon Sep 17 00:00:00 2001 From: mgravell Date: Thu, 4 Jul 2019 09:58:06 +0100 Subject: [PATCH 0827/1555] remove changes to .Generated.cs --- .../Grpc.Core/Internal/NativeMethods.Generated.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs index d98f0226e3f..170fc5c5657 100644 --- a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs +++ b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs @@ -266,10 +266,7 @@ namespace Grpc.Core.Internal this.grpcsharp_call_start_duplex_streaming = DllImportsFromStaticLib.grpcsharp_call_start_duplex_streaming; this.grpcsharp_call_send_message = DllImportsFromStaticLib.grpcsharp_call_send_message; this.grpcsharp_call_send_close_from_client = DllImportsFromStaticLib.grpcsharp_call_send_close_from_client; - unsafe - { - this.grpcsharp_call_send_status_from_server = DllImportsFromStaticLib.grpcsharp_call_send_status_from_server; - } + this.grpcsharp_call_send_status_from_server = DllImportsFromStaticLib.grpcsharp_call_send_status_from_server; this.grpcsharp_call_recv_message = DllImportsFromStaticLib.grpcsharp_call_recv_message; this.grpcsharp_call_recv_initial_metadata = DllImportsFromStaticLib.grpcsharp_call_recv_initial_metadata; this.grpcsharp_call_start_serverside = DllImportsFromStaticLib.grpcsharp_call_start_serverside; @@ -369,10 +366,7 @@ namespace Grpc.Core.Internal this.grpcsharp_call_start_duplex_streaming = DllImportsFromSharedLib.grpcsharp_call_start_duplex_streaming; this.grpcsharp_call_send_message = DllImportsFromSharedLib.grpcsharp_call_send_message; this.grpcsharp_call_send_close_from_client = DllImportsFromSharedLib.grpcsharp_call_send_close_from_client; - unsafe - { - this.grpcsharp_call_send_status_from_server = DllImportsFromSharedLib.grpcsharp_call_send_status_from_server; - } + this.grpcsharp_call_send_status_from_server = DllImportsFromSharedLib.grpcsharp_call_send_status_from_server; this.grpcsharp_call_recv_message = DllImportsFromSharedLib.grpcsharp_call_recv_message; this.grpcsharp_call_recv_initial_metadata = DllImportsFromSharedLib.grpcsharp_call_recv_initial_metadata; this.grpcsharp_call_start_serverside = DllImportsFromSharedLib.grpcsharp_call_start_serverside; From 2ebbf220ab6d859831b0f77383eb1a9d01bb2255 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 4 Jul 2019 11:48:49 -0400 Subject: [PATCH 0828/1555] fix C# sanity and other nits --- src/csharp/Grpc.Core.Api/Utils/EncodingExtensions.cs | 2 +- src/csharp/Grpc.Core.Tests/Internal/WellKnownStringsTest.cs | 4 ++-- src/csharp/Grpc.Core/Internal/WellKnownStrings.cs | 2 +- src/csharp/tests.json | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/csharp/Grpc.Core.Api/Utils/EncodingExtensions.cs b/src/csharp/Grpc.Core.Api/Utils/EncodingExtensions.cs index 7d520d30eae..080fbcd5c12 100644 --- a/src/csharp/Grpc.Core.Api/Utils/EncodingExtensions.cs +++ b/src/csharp/Grpc.Core.Api/Utils/EncodingExtensions.cs @@ -1,5 +1,5 @@ #region Copyright notice and license -// Copyright 2015 gRPC authors. +// Copyright 2019 The gRPC Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/csharp/Grpc.Core.Tests/Internal/WellKnownStringsTest.cs b/src/csharp/Grpc.Core.Tests/Internal/WellKnownStringsTest.cs index 285f7a12d0a..4c89b993238 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/WellKnownStringsTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/WellKnownStringsTest.cs @@ -1,5 +1,5 @@ #region Copyright notice and license -// Copyright 2015 gRPC authors. +// Copyright 2019 The gRPC Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ using System.Text; using Grpc.Core.Internal; using NUnit.Framework; -namespace Grpc.Core.Tests.Internal +namespace Grpc.Core.Internal.Tests { public class WellKnownStringsTest { diff --git a/src/csharp/Grpc.Core/Internal/WellKnownStrings.cs b/src/csharp/Grpc.Core/Internal/WellKnownStrings.cs index 4b95d1f368d..fa33e9a1fe4 100644 --- a/src/csharp/Grpc.Core/Internal/WellKnownStrings.cs +++ b/src/csharp/Grpc.Core/Internal/WellKnownStrings.cs @@ -1,5 +1,5 @@ #region Copyright notice and license -// Copyright 2015 gRPC authors. +// Copyright 2019 The gRPC Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/csharp/tests.json b/src/csharp/tests.json index cacdb305d2e..2eb786e0983 100644 --- a/src/csharp/tests.json +++ b/src/csharp/tests.json @@ -14,6 +14,7 @@ "Grpc.Core.Internal.Tests.ReusableSliceBufferTest", "Grpc.Core.Internal.Tests.SliceTest", "Grpc.Core.Internal.Tests.TimespecTest", + "Grpc.Core.Internal.Tests.WellKnownStringsTest", "Grpc.Core.Tests.AppDomainUnloadTest", "Grpc.Core.Tests.AuthContextTest", "Grpc.Core.Tests.AuthPropertyTest", From fbd5a47181020a1c83141b5295ac055e44949a56 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 5 Jul 2019 08:20:38 -0400 Subject: [PATCH 0829/1555] use System.Memory and Span<> on all TFMs --- .../Grpc.Core.Api/DeserializationContext.cs | 4 +--- src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj | 9 +------ .../Grpc.Core.Tests/Grpc.Core.Tests.csproj | 4 ---- .../DefaultDeserializationContextTest.cs | 14 ++--------- .../Internal/FakeBufferReaderManagerTest.cs | 2 +- .../Internal/ReusableSliceBufferTest.cs | 17 +++---------- .../Grpc.Core.Tests/Internal/SliceTest.cs | 21 ++-------------- src/csharp/Grpc.Core/Grpc.Core.csproj | 6 ++--- .../Internal/DefaultDeserializationContext.cs | 24 ++----------------- .../Grpc.Core/Internal/ReusableSliceBuffer.cs | 3 --- src/csharp/Grpc.Core/Internal/Slice.cs | 9 ------- 11 files changed, 14 insertions(+), 99 deletions(-) diff --git a/src/csharp/Grpc.Core.Api/DeserializationContext.cs b/src/csharp/Grpc.Core.Api/DeserializationContext.cs index 966bcfa8c8e..eb00f67601e 100644 --- a/src/csharp/Grpc.Core.Api/DeserializationContext.cs +++ b/src/csharp/Grpc.Core.Api/DeserializationContext.cs @@ -48,13 +48,12 @@ namespace Grpc.Core throw new NotImplementedException(); } -#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY /// /// Gets the entire payload as a ReadOnlySequence. /// The ReadOnlySequence is only valid for the duration of the deserializer routine and the caller must not access it after the deserializer returns. /// Using the read only sequence is the most efficient way to access the message payload. Where possible it allows directly /// accessing the received payload without needing to perform any buffer copying or buffer allocations. - /// NOTE: This method is only available in the netstandard2.0 build of the library. + /// NOTE: In order to access the payload via this method, your compiler needs to support C# 7.2 (to be able to use the Span type). /// NOTE: Deserializers are expected not to call this method (or other payload accessor methods) more than once per received message /// (as there is no practical reason for doing so) and DeserializationContext implementations are free to assume so. /// @@ -63,6 +62,5 @@ namespace Grpc.Core { throw new NotImplementedException(); } -#endif } } diff --git a/src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj b/src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj index 0a958299ec8..a0d41a260da 100755 --- a/src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj +++ b/src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj @@ -20,18 +20,11 @@ true - - $(DefineConstants);GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY - - - - - - + diff --git a/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj b/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj index 693646bea1c..1aa314f4aec 100755 --- a/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj +++ b/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj @@ -9,10 +9,6 @@ true - - $(DefineConstants);GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY - - diff --git a/src/csharp/Grpc.Core.Tests/Internal/DefaultDeserializationContextTest.cs b/src/csharp/Grpc.Core.Tests/Internal/DefaultDeserializationContextTest.cs index 63baab31624..8b635f9288f 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/DefaultDeserializationContextTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/DefaultDeserializationContextTest.cs @@ -17,18 +17,14 @@ #endregion using System; +using System.Buffers; using System.Collections.Generic; +using System.Runtime.InteropServices; using Grpc.Core; using Grpc.Core.Internal; using Grpc.Core.Utils; using NUnit.Framework; -using System.Runtime.InteropServices; - -#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY -using System.Buffers; -#endif - namespace Grpc.Core.Internal.Tests { public class DefaultDeserializationContextTest @@ -47,7 +43,6 @@ namespace Grpc.Core.Internal.Tests fakeBufferReaderManager.Dispose(); } -#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY [TestCase] public void PayloadAsReadOnlySequence_ZeroSegmentPayload() { @@ -118,7 +113,6 @@ namespace Grpc.Core.Internal.Tests Assert.IsFalse(segmentEnumerator.MoveNext()); } -#endif [TestCase] public void NullPayloadNotAllowed() @@ -196,9 +190,7 @@ namespace Grpc.Core.Internal.Tests // Getting payload multiple times is illegal Assert.Throws(typeof(InvalidOperationException), () => context.PayloadAsNewBuffer()); -#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY Assert.Throws(typeof(InvalidOperationException), () => context.PayloadAsReadOnlySequence()); -#endif } [TestCase] @@ -215,9 +207,7 @@ namespace Grpc.Core.Internal.Tests Assert.AreEqual(0, context.PayloadLength); Assert.Throws(typeof(NullReferenceException), () => context.PayloadAsNewBuffer()); -#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY Assert.Throws(typeof(NullReferenceException), () => context.PayloadAsReadOnlySequence()); -#endif // Previously reset context can be initialized again var origBuffer2 = GetTestBuffer(50); diff --git a/src/csharp/Grpc.Core.Tests/Internal/FakeBufferReaderManagerTest.cs b/src/csharp/Grpc.Core.Tests/Internal/FakeBufferReaderManagerTest.cs index 7c4ff652bd3..8211b7fe00c 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/FakeBufferReaderManagerTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/FakeBufferReaderManagerTest.cs @@ -103,7 +103,7 @@ namespace Grpc.Core.Internal.Tests private void AssertSliceDataEqual(byte[] expected, Slice actual) { var actualSliceData = new byte[actual.Length]; - actual.CopyTo(new ArraySegment(actualSliceData)); + actual.ToSpanUnsafe().CopyTo(actualSliceData); CollectionAssert.AreEqual(expected, actualSliceData); } diff --git a/src/csharp/Grpc.Core.Tests/Internal/ReusableSliceBufferTest.cs b/src/csharp/Grpc.Core.Tests/Internal/ReusableSliceBufferTest.cs index 7630785aef4..bfe4f6451d0 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/ReusableSliceBufferTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/ReusableSliceBufferTest.cs @@ -17,19 +17,15 @@ #endregion using System; +using System.Buffers; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using Grpc.Core; using Grpc.Core.Internal; using Grpc.Core.Utils; using NUnit.Framework; -using System.Runtime.InteropServices; - -#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY -using System.Buffers; -#endif - namespace Grpc.Core.Internal.Tests { // Converts IBufferReader into instances of ReadOnlySequence @@ -50,7 +46,6 @@ namespace Grpc.Core.Internal.Tests fakeBufferReaderManager.Dispose(); } -#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY [TestCase] public void NullPayload() { @@ -131,13 +126,7 @@ namespace Grpc.Core.Internal.Tests } return result; } -#else - [TestCase] - public void OnlySupportedOnNetCore() - { - // Test case needs to exist to make C# sanity test happy. - } -#endif + private byte[] GetTestBuffer(int length) { var testBuffer = new byte[length]; diff --git a/src/csharp/Grpc.Core.Tests/Internal/SliceTest.cs b/src/csharp/Grpc.Core.Tests/Internal/SliceTest.cs index eb090bbfa50..ff4d74727b5 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/SliceTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/SliceTest.cs @@ -33,7 +33,7 @@ namespace Grpc.Core.Internal.Tests [TestCase(10)] [TestCase(100)] [TestCase(1000)] - public void SliceFromNativePtr_CopyToArraySegment(int bufferLength) + public void SliceFromNativePtr_Copy(int bufferLength) { var origBuffer = GetTestBuffer(bufferLength); var gcHandle = GCHandle.Alloc(origBuffer, GCHandleType.Pinned); @@ -43,7 +43,7 @@ namespace Grpc.Core.Internal.Tests Assert.AreEqual(bufferLength, slice.Length); var newBuffer = new byte[bufferLength]; - slice.CopyTo(new ArraySegment(newBuffer)); + slice.ToSpanUnsafe().CopyTo(newBuffer); CollectionAssert.AreEqual(origBuffer, newBuffer); } finally @@ -52,23 +52,6 @@ namespace Grpc.Core.Internal.Tests } } - [TestCase] - public void SliceFromNativePtr_CopyToArraySegmentTooSmall() - { - var origBuffer = GetTestBuffer(100); - var gcHandle = GCHandle.Alloc(origBuffer, GCHandleType.Pinned); - try - { - var slice = new Slice(gcHandle.AddrOfPinnedObject(), origBuffer.Length); - var tooSmall = new byte[origBuffer.Length - 1]; - Assert.Catch(typeof(ArgumentException), () => slice.CopyTo(new ArraySegment(tooSmall))); - } - finally - { - gcHandle.Free(); - } - } - // create a buffer of given size and fill it with some data private byte[] GetTestBuffer(int length) { diff --git a/src/csharp/Grpc.Core/Grpc.Core.csproj b/src/csharp/Grpc.Core/Grpc.Core.csproj index 1844ce335bc..b7c7851a34b 100755 --- a/src/csharp/Grpc.Core/Grpc.Core.csproj +++ b/src/csharp/Grpc.Core/Grpc.Core.csproj @@ -23,9 +23,8 @@ true - + 7.2 - $(DefineConstants);GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY @@ -100,8 +99,7 @@ - - + diff --git a/src/csharp/Grpc.Core/Internal/DefaultDeserializationContext.cs b/src/csharp/Grpc.Core/Internal/DefaultDeserializationContext.cs index 946c37de190..b668ea18841 100644 --- a/src/csharp/Grpc.Core/Internal/DefaultDeserializationContext.cs +++ b/src/csharp/Grpc.Core/Internal/DefaultDeserializationContext.cs @@ -16,13 +16,10 @@ #endregion -using Grpc.Core.Utils; using System; -using System.Threading; - -#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY using System.Buffers; -#endif +using System.Threading; +using Grpc.Core.Utils; namespace Grpc.Core.Internal { @@ -33,9 +30,7 @@ namespace Grpc.Core.Internal IBufferReader bufferReader; int payloadLength; -#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY ReusableSliceBuffer cachedSliceBuffer = new ReusableSliceBuffer(); -#endif public DefaultDeserializationContext() { @@ -51,14 +46,12 @@ namespace Grpc.Core.Internal return buffer; } -#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY public override ReadOnlySequence PayloadAsReadOnlySequence() { var sequence = cachedSliceBuffer.PopulateFrom(bufferReader); GrpcPreconditions.CheckState(sequence.Length == payloadLength); return sequence; } -#endif public void Initialize(IBufferReader bufferReader) { @@ -70,9 +63,7 @@ namespace Grpc.Core.Internal { this.bufferReader = null; this.payloadLength = 0; -#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY this.cachedSliceBuffer.Invalidate(); -#endif } public static DefaultDeserializationContext GetInitializedThreadLocal(IBufferReader bufferReader) @@ -84,18 +75,7 @@ namespace Grpc.Core.Internal private void FillContinguousBuffer(IBufferReader reader, byte[] destination) { -#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY PayloadAsReadOnlySequence().CopyTo(new Span(destination)); -#else - int offset = 0; - while (reader.TryGetNextSlice(out Slice slice)) - { - slice.CopyTo(new ArraySegment(destination, offset, (int)slice.Length)); - offset += (int)slice.Length; - } - // check that we filled the entire destination - GrpcPreconditions.CheckState(offset == payloadLength); -#endif } } } diff --git a/src/csharp/Grpc.Core/Internal/ReusableSliceBuffer.cs b/src/csharp/Grpc.Core/Internal/ReusableSliceBuffer.cs index 2d38509e511..078e59e9d1b 100644 --- a/src/csharp/Grpc.Core/Internal/ReusableSliceBuffer.cs +++ b/src/csharp/Grpc.Core/Internal/ReusableSliceBuffer.cs @@ -16,8 +16,6 @@ #endregion -#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY - using Grpc.Core.Utils; using System; using System.Threading; @@ -145,4 +143,3 @@ namespace Grpc.Core.Internal } } } -#endif diff --git a/src/csharp/Grpc.Core/Internal/Slice.cs b/src/csharp/Grpc.Core/Internal/Slice.cs index 22eb9537951..b6e07014808 100644 --- a/src/csharp/Grpc.Core/Internal/Slice.cs +++ b/src/csharp/Grpc.Core/Internal/Slice.cs @@ -40,14 +40,6 @@ namespace Grpc.Core.Internal public int Length => length; - // copies data of the slice to given span. - // there needs to be enough space in the destination buffer - public void CopyTo(ArraySegment destination) - { - Marshal.Copy(dataPtr, destination.Array, destination.Offset, length); - } - -#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY public Span ToSpanUnsafe() { unsafe @@ -55,7 +47,6 @@ namespace Grpc.Core.Internal return new Span((byte*) dataPtr, length); } } -#endif /// /// Returns a that represents the current . From 05772b699fe9496c41b516c221698e8610c45dd1 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 5 Jul 2019 08:23:12 -0400 Subject: [PATCH 0830/1555] a bit of cleanup --- .../Grpc.Core/Internal/DefaultDeserializationContext.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/csharp/Grpc.Core/Internal/DefaultDeserializationContext.cs b/src/csharp/Grpc.Core/Internal/DefaultDeserializationContext.cs index b668ea18841..7b5997b3fed 100644 --- a/src/csharp/Grpc.Core/Internal/DefaultDeserializationContext.cs +++ b/src/csharp/Grpc.Core/Internal/DefaultDeserializationContext.cs @@ -42,7 +42,7 @@ namespace Grpc.Core.Internal public override byte[] PayloadAsNewBuffer() { var buffer = new byte[payloadLength]; - FillContinguousBuffer(bufferReader, buffer); + PayloadAsReadOnlySequence().CopyTo(buffer); return buffer; } @@ -72,10 +72,5 @@ namespace Grpc.Core.Internal instance.Initialize(bufferReader); return instance; } - - private void FillContinguousBuffer(IBufferReader reader, byte[] destination) - { - PayloadAsReadOnlySequence().CopyTo(new Span(destination)); - } } } From af8c8a88e3e45073b0f439b0950da68b5a412b66 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 8 Jul 2019 16:24:16 +0200 Subject: [PATCH 0831/1555] Delete the exited container after running python bazel_deps.sh --- tools/distrib/python/bazel_deps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/distrib/python/bazel_deps.sh b/tools/distrib/python/bazel_deps.sh index 5f4ee1d6c4d..67896f10bd8 100755 --- a/tools/distrib/python/bazel_deps.sh +++ b/tools/distrib/python/bazel_deps.sh @@ -26,6 +26,7 @@ else docker build -t bazel_local_img tools/dockerfile/test/sanity docker run -v "$(realpath .):/src/grpc/:ro" \ -w /src/grpc/third_party/protobuf \ + --rm=true \ bazel_local_img \ bazel query 'deps('$1')' fi From 1bada10afb3b82663c7c6007fcd0ed989a745a7a Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 8 Jul 2019 12:00:37 -0400 Subject: [PATCH 0832/1555] add new dependencies to Unity package --- src/csharp/build_unitypackage.bat | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index 4211d70b235..06552e8464b 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -65,6 +65,9 @@ copy /Y nativelibs\csharp_ext_macos_ios\libgrpc.a unitypackage\unitypackage_skel @rem add gRPC dependencies @rem TODO(jtattermusch): also include XMLdoc copy /Y Grpc.Core\bin\Release\net45\System.Interactive.Async.dll unitypackage\unitypackage_skeleton\Plugins\System.Interactive.Async\lib\net45\System.Interactive.Async.dll || goto :error +copy /Y Grpc.Core\bin\Release\net45\System.Runtime.CompilerServices.Unsafe.dll unitypackage\unitypackage_skeleton\Plugins\System.Runtime.CompilerServices.Unsafe\lib\net45\System.Runtime.CompilerServices.Unsafe.dll || goto :error +copy /Y Grpc.Core\bin\Release\net45\System.Buffers.dll unitypackage\unitypackage_skeleton\Plugins\System.Buffers\lib\net45\System.Buffers.dll || goto :error +copy /Y Grpc.Core\bin\Release\net45\System.Memory.dll unitypackage\unitypackage_skeleton\Plugins\System.Memory\lib\net45\System.Memory.dll || goto :error @rem add Google.Protobuf @rem TODO(jtattermusch): also include XMLdoc From a933d3d00a7fd9d0a89e08977547778b8bb5ede0 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 8 Jul 2019 12:06:16 -0400 Subject: [PATCH 0833/1555] add unity package skeleton for newly added dependencies --- .../Plugins/System.Buffers/lib.meta | 10 ++++++ .../Plugins/System.Buffers/lib/net45.meta | 10 ++++++ .../lib/net45/System.Buffers.dll.meta | 32 +++++++++++++++++++ .../lib/net45/System.Buffers.xml.meta | 9 ++++++ .../Plugins/System.Memory/lib.meta | 10 ++++++ .../Plugins/System.Memory/lib/net45.meta | 10 ++++++ .../lib/net45/System.Memory.dll.meta | 32 +++++++++++++++++++ .../lib/net45/System.Memory.xml.meta | 9 ++++++ .../lib.meta | 10 ++++++ .../lib/net45.meta | 10 ++++++ ...m.Runtime.CompilerServices.Unsafe.dll.meta | 32 +++++++++++++++++++ ...m.Runtime.CompilerServices.Unsafe.xml.meta | 9 ++++++ 12 files changed, 183 insertions(+) create mode 100644 src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib.meta create mode 100644 src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45.meta create mode 100644 src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45/System.Buffers.dll.meta create mode 100644 src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45/System.Buffers.xml.meta create mode 100644 src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib.meta create mode 100644 src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45.meta create mode 100644 src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45/System.Memory.dll.meta create mode 100644 src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45/System.Memory.xml.meta create mode 100644 src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib.meta create mode 100644 src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45.meta create mode 100644 src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45/System.Runtime.CompilerServices.Unsafe.dll.meta create mode 100644 src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45/System.Runtime.CompilerServices.Unsafe.xml.meta diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib.meta new file mode 100644 index 00000000000..d7ae012a397 --- /dev/null +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: bd5ddd2522dc301488ffe002106fe0ab +folderAsset: yes +timeCreated: 1531219385 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45.meta new file mode 100644 index 00000000000..9b1748d3e76 --- /dev/null +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: a68443518bcd1d44ba88a871dcab0c83 +folderAsset: yes +timeCreated: 1531219385 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45/System.Buffers.dll.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45/System.Buffers.dll.meta new file mode 100644 index 00000000000..bb910fe9229 --- /dev/null +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45/System.Buffers.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 4c05e46cbf00c68408f5ddc1eef9ae3b +timeCreated: 1531219386 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45/System.Buffers.xml.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45/System.Buffers.xml.meta new file mode 100644 index 00000000000..53f91502bd6 --- /dev/null +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45/System.Buffers.xml.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6fc38864f2d3dde46b3833c62c91a008 +timeCreated: 1531219386 +licenseType: Free +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib.meta new file mode 100644 index 00000000000..d7ae012a397 --- /dev/null +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: bd5ddd2522dc301488ffe002106fe0ab +folderAsset: yes +timeCreated: 1531219385 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45.meta new file mode 100644 index 00000000000..9b1748d3e76 --- /dev/null +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: a68443518bcd1d44ba88a871dcab0c83 +folderAsset: yes +timeCreated: 1531219385 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45/System.Memory.dll.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45/System.Memory.dll.meta new file mode 100644 index 00000000000..bb910fe9229 --- /dev/null +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45/System.Memory.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 4c05e46cbf00c68408f5ddc1eef9ae3b +timeCreated: 1531219386 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45/System.Memory.xml.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45/System.Memory.xml.meta new file mode 100644 index 00000000000..53f91502bd6 --- /dev/null +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45/System.Memory.xml.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6fc38864f2d3dde46b3833c62c91a008 +timeCreated: 1531219386 +licenseType: Free +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib.meta new file mode 100644 index 00000000000..d7ae012a397 --- /dev/null +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: bd5ddd2522dc301488ffe002106fe0ab +folderAsset: yes +timeCreated: 1531219385 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45.meta new file mode 100644 index 00000000000..9b1748d3e76 --- /dev/null +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: a68443518bcd1d44ba88a871dcab0c83 +folderAsset: yes +timeCreated: 1531219385 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45/System.Runtime.CompilerServices.Unsafe.dll.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45/System.Runtime.CompilerServices.Unsafe.dll.meta new file mode 100644 index 00000000000..bb910fe9229 --- /dev/null +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45/System.Runtime.CompilerServices.Unsafe.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 4c05e46cbf00c68408f5ddc1eef9ae3b +timeCreated: 1531219386 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45/System.Runtime.CompilerServices.Unsafe.xml.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45/System.Runtime.CompilerServices.Unsafe.xml.meta new file mode 100644 index 00000000000..53f91502bd6 --- /dev/null +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45/System.Runtime.CompilerServices.Unsafe.xml.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6fc38864f2d3dde46b3833c62c91a008 +timeCreated: 1531219386 +licenseType: Free +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From ba39c9255c0b3cc4335d0377da5f53b297804a40 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 8 Jul 2019 10:00:36 -0700 Subject: [PATCH 0834/1555] Adopt reviewer's comments --- examples/python/cancellation/search.py | 30 +++++++++----------------- examples/python/cancellation/server.py | 3 +++ 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/examples/python/cancellation/search.py b/examples/python/cancellation/search.py index 95e479deffa..8c41baf651c 100644 --- a/examples/python/cancellation/search.py +++ b/examples/python/cancellation/search.py @@ -19,6 +19,7 @@ from __future__ import print_function import base64 import hashlib +import itertools import logging import struct @@ -32,7 +33,7 @@ def _get_hamming_distance(a, b): """Calculates hamming distance between strings of equal length.""" distance = 0 for char_a, char_b in zip(a, b): - if char_a.lower() != char_b.lower(): + if char_a != char_b: distance += 1 return distance @@ -49,8 +50,11 @@ def _get_substring_hamming_distance(candidate, target): The minimum Hamming distance between candidate and target. """ min_distance = None + if len(target) > len(candidate): + raise ValueError("Candidate must be at least as long as target.") for i in range(len(candidate) - len(target) + 1): - distance = _get_hamming_distance(candidate[i:i + len(target)], target) + distance = _get_hamming_distance(candidate[i:i + len(target)].lower(), + target.lower()) if min_distance is None or distance < min_distance: min_distance = distance return min_distance @@ -75,20 +79,8 @@ def _bytestrings_of_length(length): Yields: All bytestrings of length `length`. """ - digits = [0] * length - while True: + for digits in itertools.product(range(_BYTE_MAX), repeat=length): yield b''.join(struct.pack('B', i) for i in digits) - digits[-1] += 1 - i = length - 1 - while digits[i] == _BYTE_MAX + 1: - digits[i] = 0 - i -= 1 - if i == -1: - # Terminate the generator since we've run out of strings of - # `length` bytes. - raise StopIteration() # pylint: disable=stop-iteration-return - else: - digits[i] += 1 def _all_bytestrings(): @@ -99,11 +91,9 @@ def _all_bytestrings(): Yields: All bytestrings in ascending order of length. """ - length = 1 - while True: - for bytestring in _bytestrings_of_length(length): - yield bytestring - length += 1 + for bytestring in itertools.chain.from_iterable( + _bytestrings_of_length(length) for length in itertools.count()): + yield bytestring def search(target, diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index 25ce494ee39..22132d81fce 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -90,6 +90,9 @@ class HashFinder(hash_name_pb2_grpc.HashFinderServicer): @contextlib.contextmanager def _running_server(port, maximum_hashes): + # We use only a single servicer thread here to demonstrate that, if managed + # carefully, cancelled RPCs can need not continue occupying servicers + # threads. server = grpc.server( futures.ThreadPoolExecutor(max_workers=1), maximum_concurrent_rpcs=1) hash_name_pb2_grpc.add_HashFinderServicer_to_server( From de9c1e8f9c74f9c0da18d48b963afe66f29b7fa5 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Mon, 8 Jul 2019 19:29:27 +0200 Subject: [PATCH 0835/1555] Upgrading Bazel Windows RBE to 0.26 too. --- tools/internal_ci/windows/bazel_rbe.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat index 8abab687ed2..153b2d59687 100644 --- a/tools/internal_ci/windows/bazel_rbe.bat +++ b/tools/internal_ci/windows/bazel_rbe.bat @@ -14,7 +14,7 @@ @rem TODO(jtattermusch): make this generate less output @rem TODO(jtattermusch): use tools/bazel script to keep the versions in sync -choco install bazel -y --version 0.24.1 --limit-output +choco install bazel -y --version 0.26.0 --limit-output cd github/grpc set PATH=C:\tools\msys64\usr\bin;C:\Python27;%PATH% From 170beff6482ad3423cde427ed7d0b71cb10e5a8f Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Mon, 8 Jul 2019 19:44:14 +0200 Subject: [PATCH 0836/1555] Upgrading absl submodule, in the hope this will make Windows RBE work. --- bazel/grpc_deps.bzl | 6 +++--- third_party/abseil-cpp | 2 +- tools/run_tests/sanity/check_submodules.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 2507fd5f242..d3f5a2df593 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -172,9 +172,9 @@ def grpc_deps(): if "com_google_absl" not in native.existing_rules(): http_archive( name = "com_google_absl", - sha256 = "7ddf863ddced6fa5bf7304103f9c7aa619c20a2fcf84475512c8d3834b9d14fa", - strip_prefix = "abseil-cpp-61c9bf3e3e1c28a4aa6d7f1be4b37fd473bb5529", - url = "https://github.com/abseil/abseil-cpp/archive/61c9bf3e3e1c28a4aa6d7f1be4b37fd473bb5529.tar.gz", + sha256 = "fd4edc10767c28b23bf9f41114c6bcd9625c165a31baa0e6939f01058029a912", + strip_prefix = "abseil-cpp-74d91756c11bc22f9b0108b94da9326f7f9e376f", + url = "https://github.com/abseil/abseil-cpp/archive/74d91756c11bc22f9b0108b94da9326f7f9e376f.tar.gz", ) if "bazel_toolchains" not in native.existing_rules(): diff --git a/third_party/abseil-cpp b/third_party/abseil-cpp index cc4bed2d74f..74d91756c11 160000 --- a/third_party/abseil-cpp +++ b/third_party/abseil-cpp @@ -1 +1 @@ -Subproject commit cc4bed2d74f7c8717e31f9579214ab52a9c9c610 +Subproject commit 74d91756c11bc22f9b0108b94da9326f7f9e376f diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index 5ebd395835a..77fc34e3b10 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -26,7 +26,7 @@ want_submodules=$(mktemp /tmp/submXXXXXX) git submodule | awk '{ print $1 }' | sort > "$submodules" cat << EOF | awk '{ print $1 }' | sort > "$want_submodules" - cc4bed2d74f7c8717e31f9579214ab52a9c9c610 third_party/abseil-cpp (cc4bed2) + 74d91756c11bc22f9b0108b94da9326f7f9e376f third_party/abseil-cpp (74d9175) e776aa0275e293707b6a0901e0e8d8a8a3679508 third_party/benchmark (v1.2.0) 73594cde8c9a52a102c4341c244c833aa61b9c06 third_party/bloaty (remotes/origin/wide-14-g73594cd) b29b21a81b32ec273f118f589f46d56ad3332420 third_party/boringssl (remotes/origin/chromium-stable) From 79e78d16f703ad743fe1338f9f6abf0f9ff0e83a Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 8 Jul 2019 11:09:44 -0700 Subject: [PATCH 0837/1555] Pylint --- examples/python/cancellation/client.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/examples/python/cancellation/client.py b/examples/python/cancellation/client.py index 491dffa170b..f5a180c7e57 100644 --- a/examples/python/cancellation/client.py +++ b/examples/python/cancellation/client.py @@ -20,15 +20,9 @@ from __future__ import print_function import argparse import logging import signal -import six -import threading - -from six.moves.queue import Queue -from six.moves.queue import Empty as QueueEmpty +import sys import grpc -import os -import sys from examples.python.cancellation import hash_name_pb2 from examples.python.cancellation import hash_name_pb2_grpc From 06d8d07a9892d058c052339f9c8cb692312c32a6 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Mon, 8 Jul 2019 11:12:10 -0700 Subject: [PATCH 0838/1555] Remove the unused import --- src/python/grpcio_tests/tests/unit/_signal_handling_test.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py index 9d0d64709af..467b8df27f9 100644 --- a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py +++ b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py @@ -13,8 +13,6 @@ # limitations under the License. """Test of responsiveness to signals.""" -from __future__ import print_function - import logging import os import signal From 6a71664035fc0ac237bff396c58407901f0b7bd8 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 8 Jul 2019 14:41:44 -0400 Subject: [PATCH 0839/1555] fix sanity test --- templates/src/csharp/build_unitypackage.bat.template | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/src/csharp/build_unitypackage.bat.template b/templates/src/csharp/build_unitypackage.bat.template index d6f2e3c7f0d..07f19c2af3e 100755 --- a/templates/src/csharp/build_unitypackage.bat.template +++ b/templates/src/csharp/build_unitypackage.bat.template @@ -67,6 +67,9 @@ @rem add gRPC dependencies @rem TODO(jtattermusch): also include XMLdoc copy /Y Grpc.Core\bin\Release\net45\System.Interactive.Async.dll unitypackage\unitypackage_skeleton\Plugins\System.Interactive.Async\lib\net45\System.Interactive.Async.dll || goto :error + copy /Y Grpc.Core\bin\Release\net45\System.Runtime.CompilerServices.Unsafe.dll unitypackage\unitypackage_skeleton\Plugins\System.Runtime.CompilerServices.Unsafe\lib\net45\System.Runtime.CompilerServices.Unsafe.dll || goto :error + copy /Y Grpc.Core\bin\Release\net45\System.Buffers.dll unitypackage\unitypackage_skeleton\Plugins\System.Buffers\lib\net45\System.Buffers.dll || goto :error + copy /Y Grpc.Core\bin\Release\net45\System.Memory.dll unitypackage\unitypackage_skeleton\Plugins\System.Memory\lib\net45\System.Memory.dll || goto :error @rem add Google.Protobuf @rem TODO(jtattermusch): also include XMLdoc From 805afe647d72b68b9163d743e35e21867d4cdb70 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 8 Jul 2019 11:42:21 -0700 Subject: [PATCH 0840/1555] Copyright typo --- examples/python/cancellation/client.py | 2 +- examples/python/cancellation/search.py | 2 +- examples/python/cancellation/server.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/python/cancellation/client.py b/examples/python/cancellation/client.py index f5a180c7e57..f80f9668849 100644 --- a/examples/python/cancellation/client.py +++ b/examples/python/cancellation/client.py @@ -1,4 +1,4 @@ -# Copyright the 2019 gRPC authors. +# Copyright 2019 the gRPC authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/examples/python/cancellation/search.py b/examples/python/cancellation/search.py index 8c41baf651c..9d2331af1bb 100644 --- a/examples/python/cancellation/search.py +++ b/examples/python/cancellation/search.py @@ -1,4 +1,4 @@ -# Copyright the 2019 gRPC authors. +# Copyright 2019 the gRPC authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index 22132d81fce..9597e8941b4 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -1,4 +1,4 @@ -# Copyright the 2019 gRPC authors. +# Copyright 2019 the gRPC authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From af986fa3d50e080cc0630e16f64f469c69f5be31 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 8 Jul 2019 12:50:03 -0700 Subject: [PATCH 0841/1555] Revert "Merge pull request #19581 from lidizheng/rf-signal" This reverts commit 6d62eb1b703617ff9165773b6d1e7d28ab84856d, reversing changes made to 70dd0b9b3b70e0923149f6c187834eb81b274401. --- src/python/grpcio_tests/tests/unit/_signal_handling_test.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py index 467b8df27f9..9d0d64709af 100644 --- a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py +++ b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py @@ -13,6 +13,8 @@ # limitations under the License. """Test of responsiveness to signals.""" +from __future__ import print_function + import logging import os import signal From 2014a519fc082fa65614896ba219a31ae4b7c45f Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 8 Jul 2019 12:50:13 -0700 Subject: [PATCH 0842/1555] Revert "Merge pull request #19481 from gnossen/main_thread_starvation" This reverts commit 8f044f741f5a39411e04423de0dedd845459f770, reversing changes made to 5ae9afdc55b81a9046ef896cea0327faba56cf36. --- src/python/grpcio/grpc/_channel.py | 151 +++++++---------- src/python/grpcio/grpc/_common.py | 50 ------ src/python/grpcio_tests/commands.py | 2 - src/python/grpcio_tests/tests/tests.json | 1 - .../grpcio_tests/tests/unit/BUILD.bazel | 8 - .../grpcio_tests/tests/unit/_signal_client.py | 84 ---------- .../tests/unit/_signal_handling_test.py | 158 ------------------ 7 files changed, 59 insertions(+), 395 deletions(-) delete mode 100644 src/python/grpcio_tests/tests/unit/_signal_client.py delete mode 100644 src/python/grpcio_tests/tests/unit/_signal_handling_test.py diff --git a/src/python/grpcio/grpc/_channel.py b/src/python/grpcio/grpc/_channel.py index 0bf8e03b5ce..24f928ef69f 100644 --- a/src/python/grpcio/grpc/_channel.py +++ b/src/python/grpcio/grpc/_channel.py @@ -13,7 +13,6 @@ # limitations under the License. """Invocation-side implementation of gRPC Python.""" -import functools import logging import sys import threading @@ -82,6 +81,17 @@ def _unknown_code_details(unknown_cygrpc_code, details): unknown_cygrpc_code, details) +def _wait_once_until(condition, until): + if until is None: + condition.wait() + else: + remaining = until - time.time() + if remaining < 0: + raise grpc.FutureTimeoutError() + else: + condition.wait(timeout=remaining) + + class _RPCState(object): def __init__(self, due, initial_metadata, trailing_metadata, code, details): @@ -168,11 +178,12 @@ def _event_handler(state, response_deserializer): #pylint: disable=too-many-statements def _consume_request_iterator(request_iterator, state, call, request_serializer, event_handler): - """Consume a request iterator supplied by the user.""" + if cygrpc.is_fork_support_enabled(): + condition_wait_timeout = 1.0 + else: + condition_wait_timeout = None def consume_request_iterator(): # pylint: disable=too-many-branches - # Iterate over the request iterator until it is exhausted or an error - # condition is encountered. while True: return_from_user_request_generator_invoked = False try: @@ -213,19 +224,14 @@ def _consume_request_iterator(request_iterator, state, call, request_serializer, state.due.add(cygrpc.OperationType.send_message) else: return - - def _done(): - return (state.code is not None or - cygrpc.OperationType.send_message not in - state.due) - - _common.wait( - state.condition.wait, - _done, - spin_cb=functools.partial( - cygrpc.block_if_fork_in_progress, state)) - if state.code is not None: - return + while True: + state.condition.wait(condition_wait_timeout) + cygrpc.block_if_fork_in_progress(state) + if state.code is None: + if cygrpc.OperationType.send_message not in state.due: + break + else: + return else: return with state.condition: @@ -275,21 +281,13 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call): # pylint: disable=too with self._state.condition: return self._state.code is not None - def _is_complete(self): - return self._state.code is not None - def result(self, timeout=None): - """Returns the result of the computation or raises its exception. - - See grpc.Future.result for the full API contract. - """ + until = None if timeout is None else time.time() + timeout with self._state.condition: - timed_out = _common.wait( - self._state.condition.wait, self._is_complete, timeout=timeout) - if timed_out: - raise grpc.FutureTimeoutError() - else: - if self._state.code is grpc.StatusCode.OK: + while True: + if self._state.code is None: + _wait_once_until(self._state.condition, until) + elif self._state.code is grpc.StatusCode.OK: return self._state.response elif self._state.cancelled: raise grpc.FutureCancelledError() @@ -297,17 +295,12 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call): # pylint: disable=too raise self def exception(self, timeout=None): - """Return the exception raised by the computation. - - See grpc.Future.exception for the full API contract. - """ + until = None if timeout is None else time.time() + timeout with self._state.condition: - timed_out = _common.wait( - self._state.condition.wait, self._is_complete, timeout=timeout) - if timed_out: - raise grpc.FutureTimeoutError() - else: - if self._state.code is grpc.StatusCode.OK: + while True: + if self._state.code is None: + _wait_once_until(self._state.condition, until) + elif self._state.code is grpc.StatusCode.OK: return None elif self._state.cancelled: raise grpc.FutureCancelledError() @@ -315,17 +308,12 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call): # pylint: disable=too return self def traceback(self, timeout=None): - """Access the traceback of the exception raised by the computation. - - See grpc.future.traceback for the full API contract. - """ + until = None if timeout is None else time.time() + timeout with self._state.condition: - timed_out = _common.wait( - self._state.condition.wait, self._is_complete, timeout=timeout) - if timed_out: - raise grpc.FutureTimeoutError() - else: - if self._state.code is grpc.StatusCode.OK: + while True: + if self._state.code is None: + _wait_once_until(self._state.condition, until) + elif self._state.code is grpc.StatusCode.OK: return None elif self._state.cancelled: raise grpc.FutureCancelledError() @@ -357,23 +345,17 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call): # pylint: disable=too raise StopIteration() else: raise self - - def _response_ready(): - return ( - self._state.response is not None or - (cygrpc.OperationType.receive_message not in self._state.due - and self._state.code is not None)) - - _common.wait(self._state.condition.wait, _response_ready) - if self._state.response is not None: - response = self._state.response - self._state.response = None - return response - elif cygrpc.OperationType.receive_message not in self._state.due: - if self._state.code is grpc.StatusCode.OK: - raise StopIteration() - elif self._state.code is not None: - raise self + while True: + self._state.condition.wait() + if self._state.response is not None: + response = self._state.response + self._state.response = None + return response + elif cygrpc.OperationType.receive_message not in self._state.due: + if self._state.code is grpc.StatusCode.OK: + raise StopIteration() + elif self._state.code is not None: + raise self def __iter__(self): return self @@ -404,47 +386,32 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call): # pylint: disable=too def initial_metadata(self): with self._state.condition: - - def _done(): - return self._state.initial_metadata is not None - - _common.wait(self._state.condition.wait, _done) + while self._state.initial_metadata is None: + self._state.condition.wait() return self._state.initial_metadata def trailing_metadata(self): with self._state.condition: - - def _done(): - return self._state.trailing_metadata is not None - - _common.wait(self._state.condition.wait, _done) + while self._state.trailing_metadata is None: + self._state.condition.wait() return self._state.trailing_metadata def code(self): with self._state.condition: - - def _done(): - return self._state.code is not None - - _common.wait(self._state.condition.wait, _done) + while self._state.code is None: + self._state.condition.wait() return self._state.code def details(self): with self._state.condition: - - def _done(): - return self._state.details is not None - - _common.wait(self._state.condition.wait, _done) + while self._state.details is None: + self._state.condition.wait() return _common.decode(self._state.details) def debug_error_string(self): with self._state.condition: - - def _done(): - return self._state.debug_error_string is not None - - _common.wait(self._state.condition.wait, _done) + while self._state.debug_error_string is None: + self._state.condition.wait() return _common.decode(self._state.debug_error_string) def _repr(self): diff --git a/src/python/grpcio/grpc/_common.py b/src/python/grpcio/grpc/_common.py index b4b24738e8f..f69127e38ef 100644 --- a/src/python/grpcio/grpc/_common.py +++ b/src/python/grpcio/grpc/_common.py @@ -15,7 +15,6 @@ import logging -import time import six import grpc @@ -61,8 +60,6 @@ STATUS_CODE_TO_CYGRPC_STATUS_CODE = { CYGRPC_STATUS_CODE_TO_STATUS_CODE) } -MAXIMUM_WAIT_TIMEOUT = 0.1 - def encode(s): if isinstance(s, bytes): @@ -99,50 +96,3 @@ def deserialize(serialized_message, deserializer): def fully_qualified_method(group, method): return '/{}/{}'.format(group, method) - - -def _wait_once(wait_fn, timeout, spin_cb): - wait_fn(timeout=timeout) - if spin_cb is not None: - spin_cb() - - -def wait(wait_fn, wait_complete_fn, timeout=None, spin_cb=None): - """Blocks waiting for an event without blocking the thread indefinitely. - - See https://github.com/grpc/grpc/issues/19464 for full context. CPython's - `threading.Event.wait` and `threading.Condition.wait` methods, if invoked - without a timeout kwarg, may block the calling thread indefinitely. If the - call is made from the main thread, this means that signal handlers may not - run for an arbitrarily long period of time. - - This wrapper calls the supplied wait function with an arbitrary short - timeout to ensure that no signal handler has to wait longer than - MAXIMUM_WAIT_TIMEOUT before executing. - - Args: - wait_fn: A callable acceptable a single float-valued kwarg named - `timeout`. This function is expected to be one of `threading.Event.wait` - or `threading.Condition.wait`. - wait_complete_fn: A callable taking no arguments and returning a bool. - When this function returns true, it indicates that waiting should cease. - timeout: An optional float-valued number of seconds after which the wait - should cease. - spin_cb: An optional Callable taking no arguments and returning nothing. - This callback will be called on each iteration of the spin. This may be - used for, e.g. work related to forking. - - Returns: - True if a timeout was supplied and it was reached. False otherwise. - """ - if timeout is None: - while not wait_complete_fn(): - _wait_once(wait_fn, MAXIMUM_WAIT_TIMEOUT, spin_cb) - else: - end = time.time() + timeout - while not wait_complete_fn(): - remaining = min(end - time.time(), MAXIMUM_WAIT_TIMEOUT) - if remaining < 0: - return True - _wait_once(wait_fn, remaining, spin_cb) - return False diff --git a/src/python/grpcio_tests/commands.py b/src/python/grpcio_tests/commands.py index 166cea101a4..dc0795d4a12 100644 --- a/src/python/grpcio_tests/commands.py +++ b/src/python/grpcio_tests/commands.py @@ -145,8 +145,6 @@ class TestGevent(setuptools.Command): 'unit._exit_test.ExitTest.test_in_flight_partial_unary_stream_call', 'unit._exit_test.ExitTest.test_in_flight_partial_stream_unary_call', 'unit._exit_test.ExitTest.test_in_flight_partial_stream_stream_call', - # TODO(https://github.com/grpc/grpc/issues/18980): Reenable. - 'unit._signal_handling_test.SignalHandlingTest', 'unit._metadata_flags_test', 'health_check._health_servicer_test.HealthServicerTest.test_cancelled_watch_removed_from_watch_list', # TODO(https://github.com/grpc/grpc/issues/17330) enable these three tests diff --git a/src/python/grpcio_tests/tests/tests.json b/src/python/grpcio_tests/tests/tests.json index 16ba4847bc0..cc08d56248a 100644 --- a/src/python/grpcio_tests/tests/tests.json +++ b/src/python/grpcio_tests/tests/tests.json @@ -67,7 +67,6 @@ "unit._server_ssl_cert_config_test.ServerSSLCertReloadTestWithoutClientAuth", "unit._server_test.ServerTest", "unit._session_cache_test.SSLSessionCacheTest", - "unit._signal_handling_test.SignalHandlingTest", "unit._version_test.VersionTest", "unit.beta._beta_features_test.BetaFeaturesTest", "unit.beta._beta_features_test.ContextManagementAndLifecycleTest", diff --git a/src/python/grpcio_tests/tests/unit/BUILD.bazel b/src/python/grpcio_tests/tests/unit/BUILD.bazel index d21f5a59ad1..a161794f8be 100644 --- a/src/python/grpcio_tests/tests/unit/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/BUILD.bazel @@ -16,7 +16,6 @@ GRPCIO_TESTS_UNIT = [ "_credentials_test.py", "_dns_resolver_test.py", "_empty_message_test.py", - "_error_message_encoding_test.py", "_exit_test.py", "_interceptor_test.py", "_invalid_metadata_test.py", @@ -28,7 +27,6 @@ GRPCIO_TESTS_UNIT = [ # "_reconnect_test.py", "_resource_exhausted_test.py", "_rpc_test.py", - "_signal_handling_test.py", # TODO(ghostwriternr): To be added later. # "_server_ssl_cert_config_test.py", "_server_test.py", @@ -41,11 +39,6 @@ py_library( srcs = ["_tcp_proxy.py"], ) -py_library( - name = "_signal_client", - srcs = ["_signal_client.py"], -) - py_library( name = "resources", srcs = ["resources.py"], @@ -94,7 +87,6 @@ py_library( ":_server_shutdown_scenarios", ":_from_grpc_import_star", ":_tcp_proxy", - ":_signal_client", "//src/python/grpcio_tests/tests/unit/framework/common", "//src/python/grpcio_tests/tests/testing", requirement('six'), diff --git a/src/python/grpcio_tests/tests/unit/_signal_client.py b/src/python/grpcio_tests/tests/unit/_signal_client.py deleted file mode 100644 index 65ddd6d858e..00000000000 --- a/src/python/grpcio_tests/tests/unit/_signal_client.py +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright 2019 the gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Client for testing responsiveness to signals.""" - -from __future__ import print_function - -import argparse -import functools -import logging -import signal -import sys - -import grpc - -SIGTERM_MESSAGE = "Handling sigterm!" - -UNARY_UNARY = "/test/Unary" -UNARY_STREAM = "/test/ServerStreaming" - -_MESSAGE = b'\x00\x00\x00' - -_ASSERTION_MESSAGE = "Control flow should never reach here." - -# NOTE(gnossen): We use a global variable here so that the signal handler can be -# installed before the RPC begins. If we do not do this, then we may receive the -# SIGINT before the signal handler is installed. I'm not happy with per-process -# global state, but the per-process global state that is signal handlers -# somewhat forces my hand. -per_process_rpc_future = None - - -def handle_sigint(unused_signum, unused_frame): - print(SIGTERM_MESSAGE) - if per_process_rpc_future is not None: - per_process_rpc_future.cancel() - sys.stderr.flush() - sys.exit(0) - - -def main_unary(server_target): - """Initiate a unary RPC to be interrupted by a SIGINT.""" - global per_process_rpc_future # pylint: disable=global-statement - with grpc.insecure_channel(server_target) as channel: - multicallable = channel.unary_unary(UNARY_UNARY) - signal.signal(signal.SIGINT, handle_sigint) - per_process_rpc_future = multicallable.future( - _MESSAGE, wait_for_ready=True) - result = per_process_rpc_future.result() - assert False, _ASSERTION_MESSAGE - - -def main_streaming(server_target): - """Initiate a streaming RPC to be interrupted by a SIGINT.""" - global per_process_rpc_future # pylint: disable=global-statement - with grpc.insecure_channel(server_target) as channel: - signal.signal(signal.SIGINT, handle_sigint) - per_process_rpc_future = channel.unary_stream(UNARY_STREAM)( - _MESSAGE, wait_for_ready=True) - for result in per_process_rpc_future: - pass - assert False, _ASSERTION_MESSAGE - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Signal test client.') - parser.add_argument('server', help='Server target') - parser.add_argument( - 'arity', help='RPC arity', choices=('unary', 'streaming')) - args = parser.parse_args() - if args.arity == 'unary': - main_unary(args.server) - else: - main_streaming(args.server) diff --git a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py deleted file mode 100644 index 9d0d64709af..00000000000 --- a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py +++ /dev/null @@ -1,158 +0,0 @@ -# Copyright 2019 the gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Test of responsiveness to signals.""" - -from __future__ import print_function - -import logging -import os -import signal -import subprocess -import tempfile -import threading -import unittest -import sys - -import grpc - -from tests.unit import test_common -from tests.unit import _signal_client - -_CLIENT_PATH = os.path.abspath(os.path.realpath(_signal_client.__file__)) -_HOST = 'localhost' - - -class _GenericHandler(grpc.GenericRpcHandler): - - def __init__(self): - self._connected_clients_lock = threading.RLock() - self._connected_clients_event = threading.Event() - self._connected_clients = 0 - - self._unary_unary_handler = grpc.unary_unary_rpc_method_handler( - self._handle_unary_unary) - self._unary_stream_handler = grpc.unary_stream_rpc_method_handler( - self._handle_unary_stream) - - def _on_client_connect(self): - with self._connected_clients_lock: - self._connected_clients += 1 - self._connected_clients_event.set() - - def _on_client_disconnect(self): - with self._connected_clients_lock: - self._connected_clients -= 1 - if self._connected_clients == 0: - self._connected_clients_event.clear() - - def await_connected_client(self): - """Blocks until a client connects to the server.""" - self._connected_clients_event.wait() - - def _handle_unary_unary(self, request, servicer_context): - """Handles a unary RPC. - - Blocks until the client disconnects and then echoes. - """ - stop_event = threading.Event() - - def on_rpc_end(): - self._on_client_disconnect() - stop_event.set() - - servicer_context.add_callback(on_rpc_end) - self._on_client_connect() - stop_event.wait() - return request - - def _handle_unary_stream(self, request, servicer_context): - """Handles a server streaming RPC. - - Blocks until the client disconnects and then echoes. - """ - stop_event = threading.Event() - - def on_rpc_end(): - self._on_client_disconnect() - stop_event.set() - - servicer_context.add_callback(on_rpc_end) - self._on_client_connect() - stop_event.wait() - yield request - - def service(self, handler_call_details): - if handler_call_details.method == _signal_client.UNARY_UNARY: - return self._unary_unary_handler - elif handler_call_details.method == _signal_client.UNARY_STREAM: - return self._unary_stream_handler - else: - return None - - -def _read_stream(stream): - stream.seek(0) - return stream.read() - - -class SignalHandlingTest(unittest.TestCase): - - def setUp(self): - self._server = test_common.test_server() - self._port = self._server.add_insecure_port('{}:0'.format(_HOST)) - self._handler = _GenericHandler() - self._server.add_generic_rpc_handlers((self._handler,)) - self._server.start() - - def tearDown(self): - self._server.stop(None) - - @unittest.skipIf(os.name == 'nt', 'SIGINT not supported on windows') - def testUnary(self): - """Tests that the server unary code path does not stall signal handlers.""" - server_target = '{}:{}'.format(_HOST, self._port) - with tempfile.TemporaryFile(mode='r') as client_stdout: - with tempfile.TemporaryFile(mode='r') as client_stderr: - client = subprocess.Popen( - (sys.executable, _CLIENT_PATH, server_target, 'unary'), - stdout=client_stdout, - stderr=client_stderr) - self._handler.await_connected_client() - client.send_signal(signal.SIGINT) - self.assertFalse(client.wait(), msg=_read_stream(client_stderr)) - client_stdout.seek(0) - self.assertIn(_signal_client.SIGTERM_MESSAGE, - client_stdout.read()) - - @unittest.skipIf(os.name == 'nt', 'SIGINT not supported on windows') - def testStreaming(self): - """Tests that the server streaming code path does not stall signal handlers.""" - server_target = '{}:{}'.format(_HOST, self._port) - with tempfile.TemporaryFile(mode='r') as client_stdout: - with tempfile.TemporaryFile(mode='r') as client_stderr: - client = subprocess.Popen( - (sys.executable, _CLIENT_PATH, server_target, 'streaming'), - stdout=client_stdout, - stderr=client_stderr) - self._handler.await_connected_client() - client.send_signal(signal.SIGINT) - self.assertFalse(client.wait(), msg=_read_stream(client_stderr)) - client_stdout.seek(0) - self.assertIn(_signal_client.SIGTERM_MESSAGE, - client_stdout.read()) - - -if __name__ == '__main__': - logging.basicConfig() - unittest.main(verbosity=2) From 50cb169af06c9165c117e327d88713503f786c4b Mon Sep 17 00:00:00 2001 From: Qiancheng Zhao Date: Mon, 8 Jul 2019 13:44:55 -0700 Subject: [PATCH 0843/1555] add IsValidTarget api to ResolverRegistry --- .../resolver/dns/c_ares/dns_resolver_ares.cc | 2 + .../resolver/dns/native/dns_resolver.cc | 11 +++-- .../resolver/fake/fake_resolver.cc | 2 + .../resolver/sockaddr/sockaddr_resolver.cc | 44 +++++++++++++------ .../filters/client_channel/resolver_factory.h | 4 ++ .../client_channel/resolver_registry.cc | 11 +++++ .../client_channel/resolver_registry.h | 3 ++ 7 files changed, 61 insertions(+), 16 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index 43b28bc9650..4e7bb5ec482 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -433,6 +433,8 @@ void AresDnsResolver::StartResolvingLocked() { class AresDnsResolverFactory : public ResolverFactory { public: + bool IsValidUri(const grpc_uri* uri) const override { return true; } + OrphanablePtr CreateResolver(ResolverArgs args) const override { return OrphanablePtr(New(std::move(args))); } diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc index 1abe9ad3e44..bc6d73acac7 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc @@ -258,11 +258,16 @@ void NativeDnsResolver::StartResolvingLocked() { class NativeDnsResolverFactory : public ResolverFactory { public: - OrphanablePtr CreateResolver(ResolverArgs args) const override { - if (GPR_UNLIKELY(0 != strcmp(args.uri->authority, ""))) { + bool IsValidUri(const grpc_uri* uri) const override { + if (GPR_UNLIKELY(0 != strcmp(uri->authority, ""))) { gpr_log(GPR_ERROR, "authority based dns uri's not supported"); - return OrphanablePtr(nullptr); + return false; } + return true; + } + + OrphanablePtr CreateResolver(ResolverArgs args) const override { + if (!IsValidUri(args.uri)) return nullptr; return OrphanablePtr(New(std::move(args))); } diff --git a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc index ff728a3dc43..5ecdf4e8d16 100644 --- a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc @@ -315,6 +315,8 @@ namespace { class FakeResolverFactory : public ResolverFactory { public: + bool IsValidUri(const grpc_uri* uri) const override { return true; } + OrphanablePtr CreateResolver(ResolverArgs args) const override { return OrphanablePtr(New(std::move(args))); } diff --git a/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc b/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc index 517b9297af4..532fd6df9b7 100644 --- a/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc @@ -80,24 +80,23 @@ void SockaddrResolver::StartLocked() { void DoNothing(void* ignored) {} -OrphanablePtr CreateSockaddrResolver( - ResolverArgs args, - bool parse(const grpc_uri* uri, grpc_resolved_address* dst)) { - if (0 != strcmp(args.uri->authority, "")) { +bool ParseUri(const grpc_uri* uri, + bool parse(const grpc_uri* uri, grpc_resolved_address* dst), + ServerAddressList* addresses) { + if (0 != strcmp(uri->authority, "")) { gpr_log(GPR_ERROR, "authority-based URIs not supported by the %s scheme", - args.uri->scheme); - return nullptr; + uri->scheme); + return false; } // Construct addresses. grpc_slice path_slice = - grpc_slice_new(args.uri->path, strlen(args.uri->path), DoNothing); + grpc_slice_new(uri->path, strlen(uri->path), DoNothing); grpc_slice_buffer path_parts; grpc_slice_buffer_init(&path_parts); grpc_slice_split(path_slice, ",", &path_parts); - ServerAddressList addresses; bool errors_found = false; for (size_t i = 0; i < path_parts.count; i++) { - grpc_uri ith_uri = *args.uri; + grpc_uri ith_uri = *uri; UniquePtr part_str(grpc_slice_to_c_string(path_parts.slices[i])); ith_uri.path = part_str.get(); grpc_resolved_address addr; @@ -105,13 +104,20 @@ OrphanablePtr CreateSockaddrResolver( errors_found = true; break; } - addresses.emplace_back(addr, nullptr /* args */); + if (addresses != nullptr) { + addresses->emplace_back(addr, nullptr /* args */); + } } grpc_slice_buffer_destroy_internal(&path_parts); grpc_slice_unref_internal(path_slice); - if (errors_found) { - return OrphanablePtr(nullptr); - } + return !errors_found; +} + +OrphanablePtr CreateSockaddrResolver( + ResolverArgs args, + bool parse(const grpc_uri* uri, grpc_resolved_address* dst)) { + ServerAddressList addresses; + if (!ParseUri(args.uri, parse, &addresses)) return nullptr; // Instantiate resolver. return OrphanablePtr( New(std::move(addresses), std::move(args))); @@ -119,6 +125,10 @@ OrphanablePtr CreateSockaddrResolver( class IPv4ResolverFactory : public ResolverFactory { public: + bool IsValidUri(const grpc_uri* uri) const override { + return ParseUri(uri, grpc_parse_ipv4, nullptr); + } + OrphanablePtr CreateResolver(ResolverArgs args) const override { return CreateSockaddrResolver(std::move(args), grpc_parse_ipv4); } @@ -128,6 +138,10 @@ class IPv4ResolverFactory : public ResolverFactory { class IPv6ResolverFactory : public ResolverFactory { public: + bool IsValidUri(const grpc_uri* uri) const override { + return ParseUri(uri, grpc_parse_ipv6, nullptr); + } + OrphanablePtr CreateResolver(ResolverArgs args) const override { return CreateSockaddrResolver(std::move(args), grpc_parse_ipv6); } @@ -138,6 +152,10 @@ class IPv6ResolverFactory : public ResolverFactory { #ifdef GRPC_HAVE_UNIX_SOCKET class UnixResolverFactory : public ResolverFactory { public: + bool IsValidUri(const grpc_uri* uri) const override { + return ParseUri(uri, grpc_parse_unix, nullptr); + } + OrphanablePtr CreateResolver(ResolverArgs args) const override { return CreateSockaddrResolver(std::move(args), grpc_parse_unix); } diff --git a/src/core/ext/filters/client_channel/resolver_factory.h b/src/core/ext/filters/client_channel/resolver_factory.h index 273fd8d24f0..7fed48b9570 100644 --- a/src/core/ext/filters/client_channel/resolver_factory.h +++ b/src/core/ext/filters/client_channel/resolver_factory.h @@ -47,6 +47,10 @@ struct ResolverArgs { class ResolverFactory { public: + /// Returns a bool indicating whether the input uri is valid to create a + /// resolver. + virtual bool IsValidUri(const grpc_uri* uri) const GRPC_ABSTRACT; + /// Returns a new resolver instance. virtual OrphanablePtr CreateResolver(ResolverArgs args) const GRPC_ABSTRACT; diff --git a/src/core/ext/filters/client_channel/resolver_registry.cc b/src/core/ext/filters/client_channel/resolver_registry.cc index 5b00eab341e..509c4ef38fa 100644 --- a/src/core/ext/filters/client_channel/resolver_registry.cc +++ b/src/core/ext/filters/client_channel/resolver_registry.cc @@ -132,6 +132,17 @@ ResolverFactory* ResolverRegistry::LookupResolverFactory(const char* scheme) { return g_state->LookupResolverFactory(scheme); } +bool ResolverRegistry::IsValidTarget(const char* target) { + grpc_uri* uri = nullptr; + char* canonical_target = nullptr; + ResolverFactory* factory = + g_state->FindResolverFactory(target, &uri, &canonical_target); + bool result = factory == nullptr ? false : factory->IsValidUri(uri); + grpc_uri_destroy(uri); + gpr_free(canonical_target); + return result; +} + OrphanablePtr ResolverRegistry::CreateResolver( const char* target, const grpc_channel_args* args, grpc_pollset_set* pollset_set, grpc_combiner* combiner, diff --git a/src/core/ext/filters/client_channel/resolver_registry.h b/src/core/ext/filters/client_channel/resolver_registry.h index 0eec6782609..4248a065439 100644 --- a/src/core/ext/filters/client_channel/resolver_registry.h +++ b/src/core/ext/filters/client_channel/resolver_registry.h @@ -50,6 +50,9 @@ class ResolverRegistry { static void RegisterResolverFactory(UniquePtr factory); }; + /// Checks whether the user input \a target is valid to create a resolver. + static bool IsValidTarget(const char* target); + /// Creates a resolver given \a target. /// First tries to parse \a target as a URI. If this succeeds, tries /// to locate a registered resolver factory based on the URI scheme. From 957fc7bab7d427878d2dd0def19dfffa5cd111fd Mon Sep 17 00:00:00 2001 From: Michael Herold Date: Mon, 8 Jul 2019 16:15:27 -0500 Subject: [PATCH 0844/1555] Don't require_relative for an absolute path Ruby's `require_relative` method currently converts paths to absolute paths. This idiosyncrasy means that the implementation of the require for the distributed shared library works, however the semantics do not mesh with the semantics of `require_relative`. This is an issue when you redefine `require_relative` and follow the semantics of the method, as [derailed_benchmarks does][1]. This means that any project that uses `grpc` also cannot use that project (which I will also be patching). In the event that a new version of Ruby follows the semantics of the method (whether or not that is likely), this will break as well. By switching to `require` here instead of `require_relative`, we maintain the functionality but do not use a semantically incompatible method to do so. [1]: https://github.com/schneems/derailed_benchmarks/blob/1b0c425720fd6cc575edbb389b434f461cb65989/lib/derailed_benchmarks/core_ext/kernel_require.rb#L24-L27 --- src/ruby/lib/grpc/grpc.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ruby/lib/grpc/grpc.rb b/src/ruby/lib/grpc/grpc.rb index 0649dabd606..f52efe36764 100644 --- a/src/ruby/lib/grpc/grpc.rb +++ b/src/ruby/lib/grpc/grpc.rb @@ -17,7 +17,7 @@ begin distrib_lib_dir = File.expand_path(ruby_version_dirname, File.dirname(__FILE__)) if File.directory?(distrib_lib_dir) - require_relative "#{distrib_lib_dir}/grpc_c" + require "#{distrib_lib_dir}/grpc_c" else require 'grpc/grpc_c' end From e30dcefeab460ccec0f5583da329a0e9cb2428f5 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 8 Jul 2019 14:50:49 -0700 Subject: [PATCH 0845/1555] Revert "Merge pull request #19583 from gnossen/revert_signal_handling" This reverts commit 1e7ec75eff60ff74d0c192591a369af0308bca48, reversing changes made to 6d62eb1b703617ff9165773b6d1e7d28ab84856d. --- src/python/grpcio/grpc/_channel.py | 151 ++++++++++------- src/python/grpcio/grpc/_common.py | 50 ++++++ src/python/grpcio_tests/commands.py | 2 + src/python/grpcio_tests/tests/tests.json | 1 + .../grpcio_tests/tests/unit/BUILD.bazel | 8 + .../grpcio_tests/tests/unit/_signal_client.py | 84 ++++++++++ .../tests/unit/_signal_handling_test.py | 156 ++++++++++++++++++ 7 files changed, 393 insertions(+), 59 deletions(-) create mode 100644 src/python/grpcio_tests/tests/unit/_signal_client.py create mode 100644 src/python/grpcio_tests/tests/unit/_signal_handling_test.py diff --git a/src/python/grpcio/grpc/_channel.py b/src/python/grpcio/grpc/_channel.py index 24f928ef69f..0bf8e03b5ce 100644 --- a/src/python/grpcio/grpc/_channel.py +++ b/src/python/grpcio/grpc/_channel.py @@ -13,6 +13,7 @@ # limitations under the License. """Invocation-side implementation of gRPC Python.""" +import functools import logging import sys import threading @@ -81,17 +82,6 @@ def _unknown_code_details(unknown_cygrpc_code, details): unknown_cygrpc_code, details) -def _wait_once_until(condition, until): - if until is None: - condition.wait() - else: - remaining = until - time.time() - if remaining < 0: - raise grpc.FutureTimeoutError() - else: - condition.wait(timeout=remaining) - - class _RPCState(object): def __init__(self, due, initial_metadata, trailing_metadata, code, details): @@ -178,12 +168,11 @@ def _event_handler(state, response_deserializer): #pylint: disable=too-many-statements def _consume_request_iterator(request_iterator, state, call, request_serializer, event_handler): - if cygrpc.is_fork_support_enabled(): - condition_wait_timeout = 1.0 - else: - condition_wait_timeout = None + """Consume a request iterator supplied by the user.""" def consume_request_iterator(): # pylint: disable=too-many-branches + # Iterate over the request iterator until it is exhausted or an error + # condition is encountered. while True: return_from_user_request_generator_invoked = False try: @@ -224,14 +213,19 @@ def _consume_request_iterator(request_iterator, state, call, request_serializer, state.due.add(cygrpc.OperationType.send_message) else: return - while True: - state.condition.wait(condition_wait_timeout) - cygrpc.block_if_fork_in_progress(state) - if state.code is None: - if cygrpc.OperationType.send_message not in state.due: - break - else: - return + + def _done(): + return (state.code is not None or + cygrpc.OperationType.send_message not in + state.due) + + _common.wait( + state.condition.wait, + _done, + spin_cb=functools.partial( + cygrpc.block_if_fork_in_progress, state)) + if state.code is not None: + return else: return with state.condition: @@ -281,13 +275,21 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call): # pylint: disable=too with self._state.condition: return self._state.code is not None + def _is_complete(self): + return self._state.code is not None + def result(self, timeout=None): - until = None if timeout is None else time.time() + timeout + """Returns the result of the computation or raises its exception. + + See grpc.Future.result for the full API contract. + """ with self._state.condition: - while True: - if self._state.code is None: - _wait_once_until(self._state.condition, until) - elif self._state.code is grpc.StatusCode.OK: + timed_out = _common.wait( + self._state.condition.wait, self._is_complete, timeout=timeout) + if timed_out: + raise grpc.FutureTimeoutError() + else: + if self._state.code is grpc.StatusCode.OK: return self._state.response elif self._state.cancelled: raise grpc.FutureCancelledError() @@ -295,12 +297,17 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call): # pylint: disable=too raise self def exception(self, timeout=None): - until = None if timeout is None else time.time() + timeout + """Return the exception raised by the computation. + + See grpc.Future.exception for the full API contract. + """ with self._state.condition: - while True: - if self._state.code is None: - _wait_once_until(self._state.condition, until) - elif self._state.code is grpc.StatusCode.OK: + timed_out = _common.wait( + self._state.condition.wait, self._is_complete, timeout=timeout) + if timed_out: + raise grpc.FutureTimeoutError() + else: + if self._state.code is grpc.StatusCode.OK: return None elif self._state.cancelled: raise grpc.FutureCancelledError() @@ -308,12 +315,17 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call): # pylint: disable=too return self def traceback(self, timeout=None): - until = None if timeout is None else time.time() + timeout + """Access the traceback of the exception raised by the computation. + + See grpc.future.traceback for the full API contract. + """ with self._state.condition: - while True: - if self._state.code is None: - _wait_once_until(self._state.condition, until) - elif self._state.code is grpc.StatusCode.OK: + timed_out = _common.wait( + self._state.condition.wait, self._is_complete, timeout=timeout) + if timed_out: + raise grpc.FutureTimeoutError() + else: + if self._state.code is grpc.StatusCode.OK: return None elif self._state.cancelled: raise grpc.FutureCancelledError() @@ -345,17 +357,23 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call): # pylint: disable=too raise StopIteration() else: raise self - while True: - self._state.condition.wait() - if self._state.response is not None: - response = self._state.response - self._state.response = None - return response - elif cygrpc.OperationType.receive_message not in self._state.due: - if self._state.code is grpc.StatusCode.OK: - raise StopIteration() - elif self._state.code is not None: - raise self + + def _response_ready(): + return ( + self._state.response is not None or + (cygrpc.OperationType.receive_message not in self._state.due + and self._state.code is not None)) + + _common.wait(self._state.condition.wait, _response_ready) + if self._state.response is not None: + response = self._state.response + self._state.response = None + return response + elif cygrpc.OperationType.receive_message not in self._state.due: + if self._state.code is grpc.StatusCode.OK: + raise StopIteration() + elif self._state.code is not None: + raise self def __iter__(self): return self @@ -386,32 +404,47 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call): # pylint: disable=too def initial_metadata(self): with self._state.condition: - while self._state.initial_metadata is None: - self._state.condition.wait() + + def _done(): + return self._state.initial_metadata is not None + + _common.wait(self._state.condition.wait, _done) return self._state.initial_metadata def trailing_metadata(self): with self._state.condition: - while self._state.trailing_metadata is None: - self._state.condition.wait() + + def _done(): + return self._state.trailing_metadata is not None + + _common.wait(self._state.condition.wait, _done) return self._state.trailing_metadata def code(self): with self._state.condition: - while self._state.code is None: - self._state.condition.wait() + + def _done(): + return self._state.code is not None + + _common.wait(self._state.condition.wait, _done) return self._state.code def details(self): with self._state.condition: - while self._state.details is None: - self._state.condition.wait() + + def _done(): + return self._state.details is not None + + _common.wait(self._state.condition.wait, _done) return _common.decode(self._state.details) def debug_error_string(self): with self._state.condition: - while self._state.debug_error_string is None: - self._state.condition.wait() + + def _done(): + return self._state.debug_error_string is not None + + _common.wait(self._state.condition.wait, _done) return _common.decode(self._state.debug_error_string) def _repr(self): diff --git a/src/python/grpcio/grpc/_common.py b/src/python/grpcio/grpc/_common.py index f69127e38ef..b4b24738e8f 100644 --- a/src/python/grpcio/grpc/_common.py +++ b/src/python/grpcio/grpc/_common.py @@ -15,6 +15,7 @@ import logging +import time import six import grpc @@ -60,6 +61,8 @@ STATUS_CODE_TO_CYGRPC_STATUS_CODE = { CYGRPC_STATUS_CODE_TO_STATUS_CODE) } +MAXIMUM_WAIT_TIMEOUT = 0.1 + def encode(s): if isinstance(s, bytes): @@ -96,3 +99,50 @@ def deserialize(serialized_message, deserializer): def fully_qualified_method(group, method): return '/{}/{}'.format(group, method) + + +def _wait_once(wait_fn, timeout, spin_cb): + wait_fn(timeout=timeout) + if spin_cb is not None: + spin_cb() + + +def wait(wait_fn, wait_complete_fn, timeout=None, spin_cb=None): + """Blocks waiting for an event without blocking the thread indefinitely. + + See https://github.com/grpc/grpc/issues/19464 for full context. CPython's + `threading.Event.wait` and `threading.Condition.wait` methods, if invoked + without a timeout kwarg, may block the calling thread indefinitely. If the + call is made from the main thread, this means that signal handlers may not + run for an arbitrarily long period of time. + + This wrapper calls the supplied wait function with an arbitrary short + timeout to ensure that no signal handler has to wait longer than + MAXIMUM_WAIT_TIMEOUT before executing. + + Args: + wait_fn: A callable acceptable a single float-valued kwarg named + `timeout`. This function is expected to be one of `threading.Event.wait` + or `threading.Condition.wait`. + wait_complete_fn: A callable taking no arguments and returning a bool. + When this function returns true, it indicates that waiting should cease. + timeout: An optional float-valued number of seconds after which the wait + should cease. + spin_cb: An optional Callable taking no arguments and returning nothing. + This callback will be called on each iteration of the spin. This may be + used for, e.g. work related to forking. + + Returns: + True if a timeout was supplied and it was reached. False otherwise. + """ + if timeout is None: + while not wait_complete_fn(): + _wait_once(wait_fn, MAXIMUM_WAIT_TIMEOUT, spin_cb) + else: + end = time.time() + timeout + while not wait_complete_fn(): + remaining = min(end - time.time(), MAXIMUM_WAIT_TIMEOUT) + if remaining < 0: + return True + _wait_once(wait_fn, remaining, spin_cb) + return False diff --git a/src/python/grpcio_tests/commands.py b/src/python/grpcio_tests/commands.py index dc0795d4a12..166cea101a4 100644 --- a/src/python/grpcio_tests/commands.py +++ b/src/python/grpcio_tests/commands.py @@ -145,6 +145,8 @@ class TestGevent(setuptools.Command): 'unit._exit_test.ExitTest.test_in_flight_partial_unary_stream_call', 'unit._exit_test.ExitTest.test_in_flight_partial_stream_unary_call', 'unit._exit_test.ExitTest.test_in_flight_partial_stream_stream_call', + # TODO(https://github.com/grpc/grpc/issues/18980): Reenable. + 'unit._signal_handling_test.SignalHandlingTest', 'unit._metadata_flags_test', 'health_check._health_servicer_test.HealthServicerTest.test_cancelled_watch_removed_from_watch_list', # TODO(https://github.com/grpc/grpc/issues/17330) enable these three tests diff --git a/src/python/grpcio_tests/tests/tests.json b/src/python/grpcio_tests/tests/tests.json index cc08d56248a..16ba4847bc0 100644 --- a/src/python/grpcio_tests/tests/tests.json +++ b/src/python/grpcio_tests/tests/tests.json @@ -67,6 +67,7 @@ "unit._server_ssl_cert_config_test.ServerSSLCertReloadTestWithoutClientAuth", "unit._server_test.ServerTest", "unit._session_cache_test.SSLSessionCacheTest", + "unit._signal_handling_test.SignalHandlingTest", "unit._version_test.VersionTest", "unit.beta._beta_features_test.BetaFeaturesTest", "unit.beta._beta_features_test.ContextManagementAndLifecycleTest", diff --git a/src/python/grpcio_tests/tests/unit/BUILD.bazel b/src/python/grpcio_tests/tests/unit/BUILD.bazel index a161794f8be..d21f5a59ad1 100644 --- a/src/python/grpcio_tests/tests/unit/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/BUILD.bazel @@ -16,6 +16,7 @@ GRPCIO_TESTS_UNIT = [ "_credentials_test.py", "_dns_resolver_test.py", "_empty_message_test.py", + "_error_message_encoding_test.py", "_exit_test.py", "_interceptor_test.py", "_invalid_metadata_test.py", @@ -27,6 +28,7 @@ GRPCIO_TESTS_UNIT = [ # "_reconnect_test.py", "_resource_exhausted_test.py", "_rpc_test.py", + "_signal_handling_test.py", # TODO(ghostwriternr): To be added later. # "_server_ssl_cert_config_test.py", "_server_test.py", @@ -39,6 +41,11 @@ py_library( srcs = ["_tcp_proxy.py"], ) +py_library( + name = "_signal_client", + srcs = ["_signal_client.py"], +) + py_library( name = "resources", srcs = ["resources.py"], @@ -87,6 +94,7 @@ py_library( ":_server_shutdown_scenarios", ":_from_grpc_import_star", ":_tcp_proxy", + ":_signal_client", "//src/python/grpcio_tests/tests/unit/framework/common", "//src/python/grpcio_tests/tests/testing", requirement('six'), diff --git a/src/python/grpcio_tests/tests/unit/_signal_client.py b/src/python/grpcio_tests/tests/unit/_signal_client.py new file mode 100644 index 00000000000..65ddd6d858e --- /dev/null +++ b/src/python/grpcio_tests/tests/unit/_signal_client.py @@ -0,0 +1,84 @@ +# Copyright 2019 the gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Client for testing responsiveness to signals.""" + +from __future__ import print_function + +import argparse +import functools +import logging +import signal +import sys + +import grpc + +SIGTERM_MESSAGE = "Handling sigterm!" + +UNARY_UNARY = "/test/Unary" +UNARY_STREAM = "/test/ServerStreaming" + +_MESSAGE = b'\x00\x00\x00' + +_ASSERTION_MESSAGE = "Control flow should never reach here." + +# NOTE(gnossen): We use a global variable here so that the signal handler can be +# installed before the RPC begins. If we do not do this, then we may receive the +# SIGINT before the signal handler is installed. I'm not happy with per-process +# global state, but the per-process global state that is signal handlers +# somewhat forces my hand. +per_process_rpc_future = None + + +def handle_sigint(unused_signum, unused_frame): + print(SIGTERM_MESSAGE) + if per_process_rpc_future is not None: + per_process_rpc_future.cancel() + sys.stderr.flush() + sys.exit(0) + + +def main_unary(server_target): + """Initiate a unary RPC to be interrupted by a SIGINT.""" + global per_process_rpc_future # pylint: disable=global-statement + with grpc.insecure_channel(server_target) as channel: + multicallable = channel.unary_unary(UNARY_UNARY) + signal.signal(signal.SIGINT, handle_sigint) + per_process_rpc_future = multicallable.future( + _MESSAGE, wait_for_ready=True) + result = per_process_rpc_future.result() + assert False, _ASSERTION_MESSAGE + + +def main_streaming(server_target): + """Initiate a streaming RPC to be interrupted by a SIGINT.""" + global per_process_rpc_future # pylint: disable=global-statement + with grpc.insecure_channel(server_target) as channel: + signal.signal(signal.SIGINT, handle_sigint) + per_process_rpc_future = channel.unary_stream(UNARY_STREAM)( + _MESSAGE, wait_for_ready=True) + for result in per_process_rpc_future: + pass + assert False, _ASSERTION_MESSAGE + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Signal test client.') + parser.add_argument('server', help='Server target') + parser.add_argument( + 'arity', help='RPC arity', choices=('unary', 'streaming')) + args = parser.parse_args() + if args.arity == 'unary': + main_unary(args.server) + else: + main_streaming(args.server) diff --git a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py new file mode 100644 index 00000000000..467b8df27f9 --- /dev/null +++ b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py @@ -0,0 +1,156 @@ +# Copyright 2019 the gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Test of responsiveness to signals.""" + +import logging +import os +import signal +import subprocess +import tempfile +import threading +import unittest +import sys + +import grpc + +from tests.unit import test_common +from tests.unit import _signal_client + +_CLIENT_PATH = os.path.abspath(os.path.realpath(_signal_client.__file__)) +_HOST = 'localhost' + + +class _GenericHandler(grpc.GenericRpcHandler): + + def __init__(self): + self._connected_clients_lock = threading.RLock() + self._connected_clients_event = threading.Event() + self._connected_clients = 0 + + self._unary_unary_handler = grpc.unary_unary_rpc_method_handler( + self._handle_unary_unary) + self._unary_stream_handler = grpc.unary_stream_rpc_method_handler( + self._handle_unary_stream) + + def _on_client_connect(self): + with self._connected_clients_lock: + self._connected_clients += 1 + self._connected_clients_event.set() + + def _on_client_disconnect(self): + with self._connected_clients_lock: + self._connected_clients -= 1 + if self._connected_clients == 0: + self._connected_clients_event.clear() + + def await_connected_client(self): + """Blocks until a client connects to the server.""" + self._connected_clients_event.wait() + + def _handle_unary_unary(self, request, servicer_context): + """Handles a unary RPC. + + Blocks until the client disconnects and then echoes. + """ + stop_event = threading.Event() + + def on_rpc_end(): + self._on_client_disconnect() + stop_event.set() + + servicer_context.add_callback(on_rpc_end) + self._on_client_connect() + stop_event.wait() + return request + + def _handle_unary_stream(self, request, servicer_context): + """Handles a server streaming RPC. + + Blocks until the client disconnects and then echoes. + """ + stop_event = threading.Event() + + def on_rpc_end(): + self._on_client_disconnect() + stop_event.set() + + servicer_context.add_callback(on_rpc_end) + self._on_client_connect() + stop_event.wait() + yield request + + def service(self, handler_call_details): + if handler_call_details.method == _signal_client.UNARY_UNARY: + return self._unary_unary_handler + elif handler_call_details.method == _signal_client.UNARY_STREAM: + return self._unary_stream_handler + else: + return None + + +def _read_stream(stream): + stream.seek(0) + return stream.read() + + +class SignalHandlingTest(unittest.TestCase): + + def setUp(self): + self._server = test_common.test_server() + self._port = self._server.add_insecure_port('{}:0'.format(_HOST)) + self._handler = _GenericHandler() + self._server.add_generic_rpc_handlers((self._handler,)) + self._server.start() + + def tearDown(self): + self._server.stop(None) + + @unittest.skipIf(os.name == 'nt', 'SIGINT not supported on windows') + def testUnary(self): + """Tests that the server unary code path does not stall signal handlers.""" + server_target = '{}:{}'.format(_HOST, self._port) + with tempfile.TemporaryFile(mode='r') as client_stdout: + with tempfile.TemporaryFile(mode='r') as client_stderr: + client = subprocess.Popen( + (sys.executable, _CLIENT_PATH, server_target, 'unary'), + stdout=client_stdout, + stderr=client_stderr) + self._handler.await_connected_client() + client.send_signal(signal.SIGINT) + self.assertFalse(client.wait(), msg=_read_stream(client_stderr)) + client_stdout.seek(0) + self.assertIn(_signal_client.SIGTERM_MESSAGE, + client_stdout.read()) + + @unittest.skipIf(os.name == 'nt', 'SIGINT not supported on windows') + def testStreaming(self): + """Tests that the server streaming code path does not stall signal handlers.""" + server_target = '{}:{}'.format(_HOST, self._port) + with tempfile.TemporaryFile(mode='r') as client_stdout: + with tempfile.TemporaryFile(mode='r') as client_stderr: + client = subprocess.Popen( + (sys.executable, _CLIENT_PATH, server_target, 'streaming'), + stdout=client_stdout, + stderr=client_stderr) + self._handler.await_connected_client() + client.send_signal(signal.SIGINT) + self.assertFalse(client.wait(), msg=_read_stream(client_stderr)) + client_stdout.seek(0) + self.assertIn(_signal_client.SIGTERM_MESSAGE, + client_stdout.read()) + + +if __name__ == '__main__': + logging.basicConfig() + unittest.main(verbosity=2) From 6de222a6ad6ea72c0f8d8d95c4bd6dc2a11d10d8 Mon Sep 17 00:00:00 2001 From: Qiancheng Zhao Date: Mon, 8 Jul 2019 15:37:21 -0700 Subject: [PATCH 0846/1555] refactor response generator in client_lb_end2end_test --- .../resolver/fake/fake_resolver.cc | 8 +- test/cpp/end2end/client_lb_end2end_test.cc | 350 +++++++++++------- 2 files changed, 214 insertions(+), 144 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc index ff728a3dc43..c48f2321cf4 100644 --- a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc @@ -89,9 +89,15 @@ FakeResolver::FakeResolver(ResolverArgs args) : Resolver(args.combiner, std::move(args.result_handler)) { GRPC_CLOSURE_INIT(&reresolution_closure_, ReturnReresolutionResult, this, grpc_combiner_scheduler(combiner())); - channel_args_ = grpc_channel_args_copy(args.args); FakeResolverResponseGenerator* response_generator = FakeResolverResponseGenerator::GetFromArgs(args.args); + // Channels sharing the same subchannels may have different resolver response + // generators. If we don't remove this arg, subchannel pool will create new + // subchannels for the same address instead of reusing existing ones because + // of different values of this channel arg. + const char* args_to_remove[] = {GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR}; + channel_args_ = grpc_channel_args_copy_and_remove( + args.args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove)); if (response_generator != nullptr) { response_generator->resolver_ = this; if (response_generator->has_result_) { diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index d499f136ef6..8fc0eacc2fc 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -133,6 +133,59 @@ class MyTestServiceImpl : public TestServiceImpl { std::set clients_; }; +class FakeResolverResponseGeneratorWrapper { + public: + FakeResolverResponseGeneratorWrapper() + : response_generator_(grpc_core::MakeRefCounted< + grpc_core::FakeResolverResponseGenerator>()) {} + + FakeResolverResponseGeneratorWrapper( + FakeResolverResponseGeneratorWrapper&& other) { + response_generator_ = std::move(other.response_generator_); + } + + void SetNextResolution(const std::vector& ports) { + grpc_core::ExecCtx exec_ctx; + response_generator_->SetResponse(BuildFakeResults(ports)); + } + + void SetNextResolutionUponError(const std::vector& ports) { + grpc_core::ExecCtx exec_ctx; + response_generator_->SetReresolutionResponse(BuildFakeResults(ports)); + } + + void SetFailureOnReresolution() { + grpc_core::ExecCtx exec_ctx; + response_generator_->SetFailureOnReresolution(); + } + + grpc_core::FakeResolverResponseGenerator* Get() const { + return response_generator_.get(); + } + + private: + static grpc_core::Resolver::Result BuildFakeResults( + const std::vector& ports) { + grpc_core::Resolver::Result result; + for (const int& port : ports) { + char* lb_uri_str; + gpr_asprintf(&lb_uri_str, "ipv4:127.0.0.1:%d", port); + grpc_uri* lb_uri = grpc_uri_parse(lb_uri_str, true); + GPR_ASSERT(lb_uri != nullptr); + grpc_resolved_address address; + GPR_ASSERT(grpc_parse_uri(lb_uri, &address)); + result.addresses.emplace_back(address.addr, address.len, + nullptr /* args */); + grpc_uri_destroy(lb_uri); + gpr_free(lb_uri_str); + } + return result; + } + + grpc_core::RefCountedPtr + response_generator_; +}; + class ClientLbEnd2endTest : public ::testing::Test { protected: ClientLbEnd2endTest() @@ -147,11 +200,7 @@ class ClientLbEnd2endTest : public ::testing::Test { GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); } - void SetUp() override { - grpc_init(); - response_generator_ = - grpc_core::MakeRefCounted(); - } + void SetUp() override { grpc_init(); } void TearDown() override { for (size_t i = 0; i < servers_.size(); ++i) { @@ -186,38 +235,6 @@ class ClientLbEnd2endTest : public ::testing::Test { } } - grpc_core::Resolver::Result BuildFakeResults(const std::vector& ports) { - grpc_core::Resolver::Result result; - for (const int& port : ports) { - char* lb_uri_str; - gpr_asprintf(&lb_uri_str, "ipv4:127.0.0.1:%d", port); - grpc_uri* lb_uri = grpc_uri_parse(lb_uri_str, true); - GPR_ASSERT(lb_uri != nullptr); - grpc_resolved_address address; - GPR_ASSERT(grpc_parse_uri(lb_uri, &address)); - result.addresses.emplace_back(address.addr, address.len, - nullptr /* args */); - grpc_uri_destroy(lb_uri); - gpr_free(lb_uri_str); - } - return result; - } - - void SetNextResolution(const std::vector& ports) { - grpc_core::ExecCtx exec_ctx; - response_generator_->SetResponse(BuildFakeResults(ports)); - } - - void SetNextResolutionUponError(const std::vector& ports) { - grpc_core::ExecCtx exec_ctx; - response_generator_->SetReresolutionResponse(BuildFakeResults(ports)); - } - - void SetFailureOnReresolution() { - grpc_core::ExecCtx exec_ctx; - response_generator_->SetFailureOnReresolution(); - } - std::vector GetServersPorts(size_t start_index = 0) { std::vector ports; for (size_t i = start_index; i < servers_.size(); ++i) { @@ -226,6 +243,10 @@ class ClientLbEnd2endTest : public ::testing::Test { return ports; } + FakeResolverResponseGeneratorWrapper BuildResolverResponseGenerator() { + return FakeResolverResponseGeneratorWrapper(); + } + std::unique_ptr BuildStub( const std::shared_ptr& channel) { return grpc::testing::EchoTestService::NewStub(channel); @@ -233,12 +254,13 @@ class ClientLbEnd2endTest : public ::testing::Test { std::shared_ptr BuildChannel( const grpc::string& lb_policy_name, + const FakeResolverResponseGeneratorWrapper& response_generator, ChannelArguments args = ChannelArguments()) { if (lb_policy_name.size() > 0) { args.SetLoadBalancingPolicyName(lb_policy_name); } // else, default to pick first args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, - response_generator_.get()); + response_generator.Get()); return ::grpc::CreateCustomChannel("fake:///", creds_, args); } @@ -401,8 +423,6 @@ class ClientLbEnd2endTest : public ::testing::Test { const grpc::string server_host_; std::unique_ptr stub_; std::vector> servers_; - grpc_core::RefCountedPtr - response_generator_; const grpc::string kRequestMessage_; std::shared_ptr creds_; }; @@ -410,7 +430,8 @@ class ClientLbEnd2endTest : public ::testing::Test { TEST_F(ClientLbEnd2endTest, ChannelStateConnectingWhenResolving) { const int kNumServers = 3; StartServers(kNumServers); - auto channel = BuildChannel(""); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("", response_generator); auto stub = BuildStub(channel); // Initial state should be IDLE. EXPECT_EQ(channel->GetState(false /* try_to_connect */), GRPC_CHANNEL_IDLE); @@ -423,7 +444,7 @@ TEST_F(ClientLbEnd2endTest, ChannelStateConnectingWhenResolving) { EXPECT_EQ(channel->GetState(false /* try_to_connect */), GRPC_CHANNEL_CONNECTING); // Return a resolver result, which allows the connection attempt to proceed. - SetNextResolution(GetServersPorts()); + response_generator.SetNextResolution(GetServersPorts()); // We should eventually transition into state READY. EXPECT_TRUE(WaitForChannelReady(channel.get())); } @@ -432,9 +453,11 @@ TEST_F(ClientLbEnd2endTest, PickFirst) { // Start servers and send one RPC per server. const int kNumServers = 3; StartServers(kNumServers); - auto channel = BuildChannel(""); // test that pick first is the default. + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel( + "", response_generator); // test that pick first is the default. auto stub = BuildStub(channel); - SetNextResolution(GetServersPorts()); + response_generator.SetNextResolution(GetServersPorts()); for (size_t i = 0; i < servers_.size(); ++i) { CheckRpcSendOk(stub, DEBUG_LOCATION); } @@ -454,19 +477,22 @@ TEST_F(ClientLbEnd2endTest, PickFirst) { } TEST_F(ClientLbEnd2endTest, PickFirstProcessPending) { - StartServers(1); // Single server - auto channel = BuildChannel(""); // test that pick first is the default. + StartServers(1); // Single server + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel( + "", response_generator); // test that pick first is the default. auto stub = BuildStub(channel); - SetNextResolution({servers_[0]->port_}); + response_generator.SetNextResolution({servers_[0]->port_}); WaitForServer(stub, 0, DEBUG_LOCATION); // Create a new channel and its corresponding PF LB policy, which will pick // the subchannels in READY state from the previous RPC against the same // target (even if it happened over a different channel, because subchannels // are globally reused). Progress should happen without any transition from // this READY state. - auto second_channel = BuildChannel(""); + auto second_response_generator = BuildResolverResponseGenerator(); + auto second_channel = BuildChannel("", second_response_generator); auto second_stub = BuildStub(second_channel); - SetNextResolution({servers_[0]->port_}); + second_response_generator.SetNextResolution({servers_[0]->port_}); CheckRpcSendOk(second_stub, DEBUG_LOCATION); } @@ -479,16 +505,18 @@ TEST_F(ClientLbEnd2endTest, PickFirstSelectsReadyAtStartup) { grpc_pick_unused_port_or_die()}; CreateServers(2, ports); StartServer(1); - auto channel1 = BuildChannel("pick_first", args); + auto response_generator1 = BuildResolverResponseGenerator(); + auto channel1 = BuildChannel("pick_first", response_generator1, args); auto stub1 = BuildStub(channel1); - SetNextResolution(ports); + response_generator1.SetNextResolution(ports); // Wait for second server to be ready. WaitForServer(stub1, 1, DEBUG_LOCATION); // Create a second channel with the same addresses. Its PF instance // should immediately pick the second subchannel, since it's already // in READY state. - auto channel2 = BuildChannel("pick_first", args); - SetNextResolution(ports); + auto response_generator2 = BuildResolverResponseGenerator(); + auto channel2 = BuildChannel("pick_first", response_generator2, args); + response_generator2.SetNextResolution(ports); // Check that the channel reports READY without waiting for the // initial backoff. EXPECT_TRUE(WaitForChannelReady(channel2.get(), 1 /* timeout_seconds */)); @@ -500,9 +528,10 @@ TEST_F(ClientLbEnd2endTest, PickFirstBackOffInitialReconnect) { args.SetInt(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS, kInitialBackOffMs); const std::vector ports = {grpc_pick_unused_port_or_die()}; const gpr_timespec t0 = gpr_now(GPR_CLOCK_MONOTONIC); - auto channel = BuildChannel("pick_first", args); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("pick_first", response_generator, args); auto stub = BuildStub(channel); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); // The channel won't become connected (there's no server). ASSERT_FALSE(channel->WaitForConnected( grpc_timeout_milliseconds_to_deadline(kInitialBackOffMs * 2))); @@ -529,9 +558,10 @@ TEST_F(ClientLbEnd2endTest, PickFirstBackOffMinReconnect) { constexpr int kMinReconnectBackOffMs = 1000; args.SetInt(GRPC_ARG_MIN_RECONNECT_BACKOFF_MS, kMinReconnectBackOffMs); const std::vector ports = {grpc_pick_unused_port_or_die()}; - auto channel = BuildChannel("pick_first", args); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("pick_first", response_generator, args); auto stub = BuildStub(channel); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); // Make connection delay a 10% longer than it's willing to in order to make // sure we are hitting the codepath that waits for the min reconnect backoff. gpr_atm_rel_store(&g_connection_delay_ms, kMinReconnectBackOffMs * 1.10); @@ -554,9 +584,10 @@ TEST_F(ClientLbEnd2endTest, PickFirstResetConnectionBackoff) { constexpr int kInitialBackOffMs = 1000; args.SetInt(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS, kInitialBackOffMs); const std::vector ports = {grpc_pick_unused_port_or_die()}; - auto channel = BuildChannel("pick_first", args); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("pick_first", response_generator, args); auto stub = BuildStub(channel); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); // The channel won't become connected (there's no server). EXPECT_FALSE( channel->WaitForConnected(grpc_timeout_milliseconds_to_deadline(10))); @@ -585,9 +616,10 @@ TEST_F(ClientLbEnd2endTest, constexpr int kInitialBackOffMs = 1000; args.SetInt(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS, kInitialBackOffMs); const std::vector ports = {grpc_pick_unused_port_or_die()}; - auto channel = BuildChannel("pick_first", args); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("pick_first", response_generator, args); auto stub = BuildStub(channel); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); // Wait for connect, which should fail ~immediately, because the server // is not up. gpr_log(GPR_INFO, "=== INITIAL CONNECTION ATTEMPT"); @@ -628,21 +660,22 @@ TEST_F(ClientLbEnd2endTest, PickFirstUpdates) { // Start servers and send one RPC per server. const int kNumServers = 3; StartServers(kNumServers); - auto channel = BuildChannel("pick_first"); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("pick_first", response_generator); auto stub = BuildStub(channel); std::vector ports; // Perform one RPC against the first server. ports.emplace_back(servers_[0]->port_); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); gpr_log(GPR_INFO, "****** SET [0] *******"); CheckRpcSendOk(stub, DEBUG_LOCATION); EXPECT_EQ(servers_[0]->service_.request_count(), 1); // An empty update will result in the channel going into TRANSIENT_FAILURE. ports.clear(); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); gpr_log(GPR_INFO, "****** SET none *******"); grpc_connectivity_state channel_state; do { @@ -654,7 +687,7 @@ TEST_F(ClientLbEnd2endTest, PickFirstUpdates) { // Next update introduces servers_[1], making the channel recover. ports.clear(); ports.emplace_back(servers_[1]->port_); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); gpr_log(GPR_INFO, "****** SET [1] *******"); WaitForServer(stub, 1, DEBUG_LOCATION); EXPECT_EQ(servers_[0]->service_.request_count(), 0); @@ -662,7 +695,7 @@ TEST_F(ClientLbEnd2endTest, PickFirstUpdates) { // And again for servers_[2] ports.clear(); ports.emplace_back(servers_[2]->port_); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); gpr_log(GPR_INFO, "****** SET [2] *******"); WaitForServer(stub, 2, DEBUG_LOCATION); EXPECT_EQ(servers_[0]->service_.request_count(), 0); @@ -676,14 +709,15 @@ TEST_F(ClientLbEnd2endTest, PickFirstUpdateSuperset) { // Start servers and send one RPC per server. const int kNumServers = 3; StartServers(kNumServers); - auto channel = BuildChannel("pick_first"); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("pick_first", response_generator); auto stub = BuildStub(channel); std::vector ports; // Perform one RPC against the first server. ports.emplace_back(servers_[0]->port_); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); gpr_log(GPR_INFO, "****** SET [0] *******"); CheckRpcSendOk(stub, DEBUG_LOCATION); EXPECT_EQ(servers_[0]->service_.request_count(), 1); @@ -693,7 +727,7 @@ TEST_F(ClientLbEnd2endTest, PickFirstUpdateSuperset) { ports.clear(); ports.emplace_back(servers_[1]->port_); ports.emplace_back(servers_[0]->port_); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); gpr_log(GPR_INFO, "****** SET superset *******"); CheckRpcSendOk(stub, DEBUG_LOCATION); // We stick to the previously connected server. @@ -710,12 +744,14 @@ TEST_F(ClientLbEnd2endTest, PickFirstGlobalSubchannelPool) { StartServers(kNumServers); std::vector ports = GetServersPorts(); // Create two channels that (by default) use the global subchannel pool. - auto channel1 = BuildChannel("pick_first"); + auto response_generator1 = BuildResolverResponseGenerator(); + auto channel1 = BuildChannel("pick_first", response_generator1); auto stub1 = BuildStub(channel1); - SetNextResolution(ports); - auto channel2 = BuildChannel("pick_first"); + response_generator1.SetNextResolution(ports); + auto response_generator2 = BuildResolverResponseGenerator(); + auto channel2 = BuildChannel("pick_first", response_generator2); auto stub2 = BuildStub(channel2); - SetNextResolution(ports); + response_generator2.SetNextResolution(ports); WaitForServer(stub1, 0, DEBUG_LOCATION); // Send one RPC on each channel. CheckRpcSendOk(stub1, DEBUG_LOCATION); @@ -735,12 +771,14 @@ TEST_F(ClientLbEnd2endTest, PickFirstLocalSubchannelPool) { // Create two channels that use local subchannel pool. ChannelArguments args; args.SetInt(GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL, 1); - auto channel1 = BuildChannel("pick_first", args); + auto response_generator1 = BuildResolverResponseGenerator(); + auto channel1 = BuildChannel("pick_first", response_generator1, args); auto stub1 = BuildStub(channel1); - SetNextResolution(ports); - auto channel2 = BuildChannel("pick_first", args); + response_generator1.SetNextResolution(ports); + auto response_generator2 = BuildResolverResponseGenerator(); + auto channel2 = BuildChannel("pick_first", response_generator2, args); auto stub2 = BuildStub(channel2); - SetNextResolution(ports); + response_generator2.SetNextResolution(ports); WaitForServer(stub1, 0, DEBUG_LOCATION); // Send one RPC on each channel. CheckRpcSendOk(stub1, DEBUG_LOCATION); @@ -756,13 +794,14 @@ TEST_F(ClientLbEnd2endTest, PickFirstManyUpdates) { const int kNumUpdates = 1000; const int kNumServers = 3; StartServers(kNumServers); - auto channel = BuildChannel("pick_first"); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("pick_first", response_generator); auto stub = BuildStub(channel); std::vector ports = GetServersPorts(); for (size_t i = 0; i < kNumUpdates; ++i) { std::shuffle(ports.begin(), ports.end(), std::mt19937(std::random_device()())); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); // We should re-enter core at the end of the loop to give the resolution // setting closure a chance to run. if ((i + 1) % 10 == 0) CheckRpcSendOk(stub, DEBUG_LOCATION); @@ -784,16 +823,17 @@ TEST_F(ClientLbEnd2endTest, PickFirstReresolutionNoSelected) { dead_ports.emplace_back(grpc_pick_unused_port_or_die()); } } - auto channel = BuildChannel("pick_first"); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("pick_first", response_generator); auto stub = BuildStub(channel); // The initial resolution only contains dead ports. There won't be any // selected subchannel. Re-resolution will return the same result. - SetNextResolution(dead_ports); + response_generator.SetNextResolution(dead_ports); gpr_log(GPR_INFO, "****** INITIAL RESOLUTION SET *******"); for (size_t i = 0; i < 10; ++i) CheckRpcSendFailure(stub); // Set a re-resolution result that contains reachable ports, so that the // pick_first LB policy can recover soon. - SetNextResolutionUponError(alive_ports); + response_generator.SetNextResolutionUponError(alive_ports); gpr_log(GPR_INFO, "****** RE-RESOLUTION SET *******"); WaitForServer(stub, 0, DEBUG_LOCATION, true /* ignore_failure */); CheckRpcSendOk(stub, DEBUG_LOCATION); @@ -805,9 +845,10 @@ TEST_F(ClientLbEnd2endTest, PickFirstReresolutionNoSelected) { TEST_F(ClientLbEnd2endTest, PickFirstReconnectWithoutNewResolverResult) { std::vector ports = {grpc_pick_unused_port_or_die()}; StartServers(1, ports); - auto channel = BuildChannel("pick_first"); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("pick_first", response_generator); auto stub = BuildStub(channel); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); gpr_log(GPR_INFO, "****** INITIAL CONNECTION *******"); WaitForServer(stub, 0, DEBUG_LOCATION); gpr_log(GPR_INFO, "****** STOPPING SERVER ******"); @@ -824,9 +865,10 @@ TEST_F(ClientLbEnd2endTest, grpc_pick_unused_port_or_die()}; CreateServers(2, ports); StartServer(1); - auto channel = BuildChannel("pick_first"); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("pick_first", response_generator); auto stub = BuildStub(channel); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); gpr_log(GPR_INFO, "****** INITIAL CONNECTION *******"); WaitForServer(stub, 1, DEBUG_LOCATION); gpr_log(GPR_INFO, "****** STOPPING SERVER ******"); @@ -840,9 +882,10 @@ TEST_F(ClientLbEnd2endTest, TEST_F(ClientLbEnd2endTest, PickFirstCheckStateBeforeStartWatch) { std::vector ports = {grpc_pick_unused_port_or_die()}; StartServers(1, ports); - auto channel_1 = BuildChannel("pick_first"); + auto response_generator = BuildResolverResponseGenerator(); + auto channel_1 = BuildChannel("pick_first", response_generator); auto stub_1 = BuildStub(channel_1); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); gpr_log(GPR_INFO, "****** RESOLUTION SET FOR CHANNEL 1 *******"); WaitForServer(stub_1, 0, DEBUG_LOCATION); gpr_log(GPR_INFO, "****** CHANNEL 1 CONNECTED *******"); @@ -851,13 +894,10 @@ TEST_F(ClientLbEnd2endTest, PickFirstCheckStateBeforeStartWatch) { // create a new subchannel and hold a ref to it. StartServers(1, ports); gpr_log(GPR_INFO, "****** SERVER RESTARTED *******"); - auto channel_2 = BuildChannel("pick_first"); + auto response_generator_2 = BuildResolverResponseGenerator(); + auto channel_2 = BuildChannel("pick_first", response_generator_2); auto stub_2 = BuildStub(channel_2); - // TODO(juanlishen): This resolution result will only be visible to channel 2 - // since the response generator is only associated with channel 2 now. We - // should change the response generator to be able to deliver updates to - // multiple channels at once. - SetNextResolution(ports); + response_generator_2.SetNextResolution(ports); gpr_log(GPR_INFO, "****** RESOLUTION SET FOR CHANNEL 2 *******"); WaitForServer(stub_2, 0, DEBUG_LOCATION, true); gpr_log(GPR_INFO, "****** CHANNEL 2 CONNECTED *******"); @@ -883,13 +923,15 @@ TEST_F(ClientLbEnd2endTest, PickFirstIdleOnDisconnect) { // Start server, send RPC, and make sure channel is READY. const int kNumServers = 1; StartServers(kNumServers); - auto channel = BuildChannel(""); // pick_first is the default. + auto response_generator = BuildResolverResponseGenerator(); + auto channel = + BuildChannel("", response_generator); // pick_first is the default. auto stub = BuildStub(channel); - SetNextResolution(GetServersPorts()); + response_generator.SetNextResolution(GetServersPorts()); CheckRpcSendOk(stub, DEBUG_LOCATION); EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); // Stop server. Channel should go into state IDLE. - SetFailureOnReresolution(); + response_generator.SetFailureOnReresolution(); servers_[0]->Shutdown(); EXPECT_TRUE(WaitForChannelNotReady(channel.get())); EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_IDLE); @@ -897,14 +939,16 @@ TEST_F(ClientLbEnd2endTest, PickFirstIdleOnDisconnect) { } TEST_F(ClientLbEnd2endTest, PickFirstPendingUpdateAndSelectedSubchannelFails) { - auto channel = BuildChannel(""); // pick_first is the default. + auto response_generator = BuildResolverResponseGenerator(); + auto channel = + BuildChannel("", response_generator); // pick_first is the default. auto stub = BuildStub(channel); // Create a number of servers, but only start 1 of them. CreateServers(10); StartServer(0); // Initially resolve to first server and make sure it connects. gpr_log(GPR_INFO, "Phase 1: Connect to first server."); - SetNextResolution({servers_[0]->port_}); + response_generator.SetNextResolution({servers_[0]->port_}); CheckRpcSendOk(stub, DEBUG_LOCATION, true /* wait_for_ready */); EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); // Send a resolution update with the remaining servers, none of which are @@ -916,7 +960,7 @@ TEST_F(ClientLbEnd2endTest, PickFirstPendingUpdateAndSelectedSubchannelFails) { gpr_log(GPR_INFO, "Phase 2: Resolver update pointing to remaining " "(not started) servers."); - SetNextResolution(GetServersPorts(1 /* start_index */)); + response_generator.SetNextResolution(GetServersPorts(1 /* start_index */)); // RPCs will continue to be sent to the first server. CheckRpcSendOk(stub, DEBUG_LOCATION); // Now stop the first server, so that the current subchannel list @@ -947,9 +991,11 @@ TEST_F(ClientLbEnd2endTest, PickFirstStaysIdleUponEmptyUpdate) { // Start server, send RPC, and make sure channel is READY. const int kNumServers = 1; StartServers(kNumServers); - auto channel = BuildChannel(""); // pick_first is the default. + auto response_generator = BuildResolverResponseGenerator(); + auto channel = + BuildChannel("", response_generator); // pick_first is the default. auto stub = BuildStub(channel); - SetNextResolution(GetServersPorts()); + response_generator.SetNextResolution(GetServersPorts()); CheckRpcSendOk(stub, DEBUG_LOCATION); EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); // Stop server. Channel should go into state IDLE. @@ -958,13 +1004,13 @@ TEST_F(ClientLbEnd2endTest, PickFirstStaysIdleUponEmptyUpdate) { EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_IDLE); // Now send resolver update that includes no addresses. Channel // should stay in state IDLE. - SetNextResolution({}); + response_generator.SetNextResolution({}); EXPECT_FALSE(channel->WaitForStateChange( GRPC_CHANNEL_IDLE, grpc_timeout_seconds_to_deadline(3))); // Now bring the backend back up and send a non-empty resolver update, // and then try to send an RPC. Channel should go back into state READY. StartServer(0); - SetNextResolution(GetServersPorts()); + response_generator.SetNextResolution(GetServersPorts()); CheckRpcSendOk(stub, DEBUG_LOCATION); EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); } @@ -973,9 +1019,10 @@ TEST_F(ClientLbEnd2endTest, RoundRobin) { // Start servers and send one RPC per server. const int kNumServers = 3; StartServers(kNumServers); - auto channel = BuildChannel("round_robin"); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("round_robin", response_generator); auto stub = BuildStub(channel); - SetNextResolution(GetServersPorts()); + response_generator.SetNextResolution(GetServersPorts()); // Wait until all backends are ready. do { CheckRpcSendOk(stub, DEBUG_LOCATION); @@ -999,18 +1046,20 @@ TEST_F(ClientLbEnd2endTest, RoundRobin) { TEST_F(ClientLbEnd2endTest, RoundRobinProcessPending) { StartServers(1); // Single server - auto channel = BuildChannel("round_robin"); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("round_robin", response_generator); auto stub = BuildStub(channel); - SetNextResolution({servers_[0]->port_}); + response_generator.SetNextResolution({servers_[0]->port_}); WaitForServer(stub, 0, DEBUG_LOCATION); // Create a new channel and its corresponding RR LB policy, which will pick // the subchannels in READY state from the previous RPC against the same // target (even if it happened over a different channel, because subchannels // are globally reused). Progress should happen without any transition from // this READY state. - auto second_channel = BuildChannel("round_robin"); + auto second_response_generator = BuildResolverResponseGenerator(); + auto second_channel = BuildChannel("round_robin", second_response_generator); auto second_stub = BuildStub(second_channel); - SetNextResolution({servers_[0]->port_}); + second_response_generator.SetNextResolution({servers_[0]->port_}); CheckRpcSendOk(second_stub, DEBUG_LOCATION); } @@ -1018,13 +1067,14 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) { // Start servers and send one RPC per server. const int kNumServers = 3; StartServers(kNumServers); - auto channel = BuildChannel("round_robin"); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("round_robin", response_generator); auto stub = BuildStub(channel); std::vector ports; // Start with a single server. gpr_log(GPR_INFO, "*** FIRST BACKEND ***"); ports.emplace_back(servers_[0]->port_); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); WaitForServer(stub, 0, DEBUG_LOCATION); // Send RPCs. They should all go servers_[0] for (size_t i = 0; i < 10; ++i) CheckRpcSendOk(stub, DEBUG_LOCATION); @@ -1036,7 +1086,7 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) { gpr_log(GPR_INFO, "*** SECOND BACKEND ***"); ports.clear(); ports.emplace_back(servers_[1]->port_); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); // Wait until update has been processed, as signaled by the second backend // receiving a request. EXPECT_EQ(0, servers_[1]->service_.request_count()); @@ -1050,7 +1100,7 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) { gpr_log(GPR_INFO, "*** THIRD BACKEND ***"); ports.clear(); ports.emplace_back(servers_[2]->port_); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); WaitForServer(stub, 2, DEBUG_LOCATION); for (size_t i = 0; i < 10; ++i) CheckRpcSendOk(stub, DEBUG_LOCATION); EXPECT_EQ(0, servers_[0]->service_.request_count()); @@ -1063,7 +1113,7 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) { ports.emplace_back(servers_[0]->port_); ports.emplace_back(servers_[1]->port_); ports.emplace_back(servers_[2]->port_); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); WaitForServer(stub, 0, DEBUG_LOCATION); WaitForServer(stub, 1, DEBUG_LOCATION); WaitForServer(stub, 2, DEBUG_LOCATION); @@ -1075,7 +1125,7 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) { // An empty update will result in the channel going into TRANSIENT_FAILURE. gpr_log(GPR_INFO, "*** NO BACKENDS ***"); ports.clear(); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); grpc_connectivity_state channel_state; do { channel_state = channel->GetState(true /* try to connect */); @@ -1086,7 +1136,7 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) { gpr_log(GPR_INFO, "*** BACK TO SECOND BACKEND ***"); ports.clear(); ports.emplace_back(servers_[1]->port_); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); WaitForServer(stub, 1, DEBUG_LOCATION); channel_state = channel->GetState(false /* try to connect */); ASSERT_EQ(channel_state, GRPC_CHANNEL_READY); @@ -1097,13 +1147,14 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) { TEST_F(ClientLbEnd2endTest, RoundRobinUpdateInError) { const int kNumServers = 3; StartServers(kNumServers); - auto channel = BuildChannel("round_robin"); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("round_robin", response_generator); auto stub = BuildStub(channel); std::vector ports; // Start with a single server. ports.emplace_back(servers_[0]->port_); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); WaitForServer(stub, 0, DEBUG_LOCATION); // Send RPCs. They should all go to servers_[0] for (size_t i = 0; i < 10; ++i) SendRpc(stub); @@ -1116,7 +1167,7 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdateInError) { servers_[1]->Shutdown(); ports.emplace_back(servers_[1]->port_); ports.emplace_back(servers_[2]->port_); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); WaitForServer(stub, 0, DEBUG_LOCATION); WaitForServer(stub, 2, DEBUG_LOCATION); @@ -1130,13 +1181,14 @@ TEST_F(ClientLbEnd2endTest, RoundRobinManyUpdates) { // Start servers and send one RPC per server. const int kNumServers = 3; StartServers(kNumServers); - auto channel = BuildChannel("round_robin"); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("round_robin", response_generator); auto stub = BuildStub(channel); std::vector ports = GetServersPorts(); for (size_t i = 0; i < 1000; ++i) { std::shuffle(ports.begin(), ports.end(), std::mt19937(std::random_device()())); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); if (i % 10 == 0) CheckRpcSendOk(stub, DEBUG_LOCATION); } // Check LB policy name for the channel. @@ -1162,9 +1214,10 @@ TEST_F(ClientLbEnd2endTest, RoundRobinReresolve) { second_ports.push_back(grpc_pick_unused_port_or_die()); } StartServers(kNumServers, first_ports); - auto channel = BuildChannel("round_robin"); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("round_robin", response_generator); auto stub = BuildStub(channel); - SetNextResolution(first_ports); + response_generator.SetNextResolution(first_ports); // Send a number of RPCs, which succeed. for (size_t i = 0; i < 100; ++i) { CheckRpcSendOk(stub, DEBUG_LOCATION); @@ -1188,7 +1241,7 @@ TEST_F(ClientLbEnd2endTest, RoundRobinReresolve) { StartServers(kNumServers, second_ports); // Don't notify of the update. Wait for the LB policy's re-resolution to // "pull" the new ports. - SetNextResolutionUponError(second_ports); + response_generator.SetNextResolutionUponError(second_ports); gpr_log(GPR_INFO, "****** SERVERS RESTARTED *******"); gpr_log(GPR_INFO, "****** SENDING REQUEST TO SUCCEED *******"); // Client request should eventually (but still fairly soon) succeed. @@ -1205,9 +1258,10 @@ TEST_F(ClientLbEnd2endTest, RoundRobinSingleReconnect) { const int kNumServers = 3; StartServers(kNumServers); const auto ports = GetServersPorts(); - auto channel = BuildChannel("round_robin"); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("round_robin", response_generator); auto stub = BuildStub(channel); - SetNextResolution(ports); + response_generator.SetNextResolution(ports); for (size_t i = 0; i < kNumServers; ++i) { WaitForServer(stub, i, DEBUG_LOCATION); } @@ -1251,9 +1305,10 @@ TEST_F(ClientLbEnd2endTest, args.SetServiceConfigJSON( "{\"healthCheckConfig\": " "{\"serviceName\": \"health_check_service_name\"}}"); - auto channel = BuildChannel("round_robin", args); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("round_robin", response_generator, args); auto stub = BuildStub(channel); - SetNextResolution({servers_[0]->port_}); + response_generator.SetNextResolution({servers_[0]->port_}); EXPECT_TRUE(WaitForChannelReady(channel.get())); CheckRpcSendOk(stub, DEBUG_LOCATION); } @@ -1267,9 +1322,10 @@ TEST_F(ClientLbEnd2endTest, RoundRobinWithHealthChecking) { args.SetServiceConfigJSON( "{\"healthCheckConfig\": " "{\"serviceName\": \"health_check_service_name\"}}"); - auto channel = BuildChannel("round_robin", args); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("round_robin", response_generator, args); auto stub = BuildStub(channel); - SetNextResolution(GetServersPorts()); + response_generator.SetNextResolution(GetServersPorts()); // Channel should not become READY, because health checks should be failing. gpr_log(GPR_INFO, "*** initial state: unknown health check service name for " @@ -1341,15 +1397,17 @@ TEST_F(ClientLbEnd2endTest, RoundRobinWithHealthCheckingInhibitPerChannel) { args.SetServiceConfigJSON( "{\"healthCheckConfig\": " "{\"serviceName\": \"health_check_service_name\"}}"); - auto channel1 = BuildChannel("round_robin", args); + auto response_generator1 = BuildResolverResponseGenerator(); + auto channel1 = BuildChannel("round_robin", response_generator1, args); auto stub1 = BuildStub(channel1); std::vector ports = GetServersPorts(); - SetNextResolution(ports); + response_generator1.SetNextResolution(ports); // Create a channel with health checking enabled but inhibited. args.SetInt(GRPC_ARG_INHIBIT_HEALTH_CHECKING, 1); - auto channel2 = BuildChannel("round_robin", args); + auto response_generator2 = BuildResolverResponseGenerator(); + auto channel2 = BuildChannel("round_robin", response_generator2, args); auto stub2 = BuildStub(channel2); - SetNextResolution(ports); + response_generator2.SetNextResolution(ports); // First channel should not become READY, because health checks should be // failing. EXPECT_FALSE(WaitForChannelReady(channel1.get(), 1)); @@ -1376,19 +1434,21 @@ TEST_F(ClientLbEnd2endTest, RoundRobinWithHealthCheckingServiceNamePerChannel) { args.SetServiceConfigJSON( "{\"healthCheckConfig\": " "{\"serviceName\": \"health_check_service_name\"}}"); - auto channel1 = BuildChannel("round_robin", args); + auto response_generator1 = BuildResolverResponseGenerator(); + auto channel1 = BuildChannel("round_robin", response_generator1, args); auto stub1 = BuildStub(channel1); std::vector ports = GetServersPorts(); - SetNextResolution(ports); + response_generator1.SetNextResolution(ports); // Create a channel with health-checking enabled with a different // service name. ChannelArguments args2; args2.SetServiceConfigJSON( "{\"healthCheckConfig\": " "{\"serviceName\": \"health_check_service_name2\"}}"); - auto channel2 = BuildChannel("round_robin", args2); + auto response_generator2 = BuildResolverResponseGenerator(); + auto channel2 = BuildChannel("round_robin", response_generator2, args2); auto stub2 = BuildStub(channel2); - SetNextResolution(ports); + response_generator2.SetNextResolution(ports); // Allow health checks from channel 2 to succeed. servers_[0]->SetServingStatus("health_check_service_name2", true); // First channel should not become READY, because health checks should be @@ -1438,9 +1498,11 @@ TEST_F(ClientLbInterceptTrailingMetadataTest, InterceptsRetriesDisabled) { const int kNumServers = 1; const int kNumRpcs = 10; StartServers(kNumServers); - auto channel = BuildChannel("intercept_trailing_metadata_lb"); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = + BuildChannel("intercept_trailing_metadata_lb", response_generator); auto stub = BuildStub(channel); - SetNextResolution(GetServersPorts()); + response_generator.SetNextResolution(GetServersPorts()); for (size_t i = 0; i < kNumRpcs; ++i) { CheckRpcSendOk(stub, DEBUG_LOCATION); } @@ -1470,9 +1532,11 @@ TEST_F(ClientLbInterceptTrailingMetadataTest, InterceptsRetriesEnabled) { " }\n" " } ]\n" "}"); - auto channel = BuildChannel("intercept_trailing_metadata_lb", args); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = + BuildChannel("intercept_trailing_metadata_lb", response_generator, args); auto stub = BuildStub(channel); - SetNextResolution(GetServersPorts()); + response_generator.SetNextResolution(GetServersPorts()); for (size_t i = 0; i < kNumRpcs; ++i) { CheckRpcSendOk(stub, DEBUG_LOCATION); } From 648c5ff8a7685b9858ab498fc67a173c0dc22312 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Mon, 8 Jul 2019 12:35:11 -0700 Subject: [PATCH 0847/1555] Convert compile-time bool into template param in slicebuf --- src/core/lib/slice/slice_buffer.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc index 2b69f576a3c..7eedad3f379 100644 --- a/src/core/lib/slice/slice_buffer.cc +++ b/src/core/lib/slice/slice_buffer.cc @@ -262,9 +262,9 @@ void grpc_slice_buffer_move_into(grpc_slice_buffer* src, src->length = 0; } +template static void slice_buffer_move_first_maybe_ref(grpc_slice_buffer* src, size_t n, - grpc_slice_buffer* dst, - bool incref) { + grpc_slice_buffer* dst) { GPR_ASSERT(src->length >= n); if (src->length == n) { grpc_slice_buffer_move_into(src, dst); @@ -304,12 +304,12 @@ static void slice_buffer_move_first_maybe_ref(grpc_slice_buffer* src, size_t n, void grpc_slice_buffer_move_first(grpc_slice_buffer* src, size_t n, grpc_slice_buffer* dst) { - slice_buffer_move_first_maybe_ref(src, n, dst, true); + slice_buffer_move_first_maybe_ref(src, n, dst); } void grpc_slice_buffer_move_first_no_ref(grpc_slice_buffer* src, size_t n, grpc_slice_buffer* dst) { - slice_buffer_move_first_maybe_ref(src, n, dst, false); + slice_buffer_move_first_maybe_ref(src, n, dst); } void grpc_slice_buffer_move_first_into_buffer(grpc_slice_buffer* src, size_t n, From 6518c2c67d4395e3676f841bcad5c00cdaf35e84 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Tue, 9 Jul 2019 10:05:10 -0700 Subject: [PATCH 0848/1555] Remove ThreadPoolWorker GABC --- src/core/lib/iomgr/executor/threadpool.cc | 2 +- src/core/lib/iomgr/executor/threadpool.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/executor/threadpool.cc b/src/core/lib/iomgr/executor/threadpool.cc index 82b1724c23a..deeadc0f758 100644 --- a/src/core/lib/iomgr/executor/threadpool.cc +++ b/src/core/lib/iomgr/executor/threadpool.cc @@ -99,7 +99,7 @@ ThreadPool::ThreadPool(int num_threads, const char* thd_name, } ThreadPool::~ThreadPool() { - shut_down_.Store(false, MemoryOrder::RELEASE); + shut_down_.Store(true, MemoryOrder::RELEASE); for (int i = 0; i < num_threads_; ++i) { queue_->Put(nullptr); diff --git a/src/core/lib/iomgr/executor/threadpool.h b/src/core/lib/iomgr/executor/threadpool.h index 3bc79aa6c3c..f0c54104ef1 100644 --- a/src/core/lib/iomgr/executor/threadpool.h +++ b/src/core/lib/iomgr/executor/threadpool.h @@ -79,7 +79,7 @@ class ThreadPoolWorker { void Start() { thd_.Start(); } void Join() { thd_.Join(); } - GRPC_ABSTRACT_BASE_CLASS + // GRPC_ABSTRACT_BASE_CLASS private: // struct for tracking stats of thread From 53b75d8c921cc80431802fe45f74699fa72c4829 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Tue, 9 Jul 2019 11:54:41 -0700 Subject: [PATCH 0849/1555] Change Get() signature, modify shut_down assertion & memoryorder --- src/core/lib/iomgr/executor/mpmcqueue.cc | 23 +++++++------------ src/core/lib/iomgr/executor/mpmcqueue.h | 12 +++++----- src/core/lib/iomgr/executor/threadpool.cc | 27 +++++++++++------------ src/core/lib/iomgr/executor/threadpool.h | 5 +++-- test/core/iomgr/threadpool_test.cc | 15 +++++-------- 5 files changed, 35 insertions(+), 47 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index 581045245c4..7f916258b82 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -98,32 +98,25 @@ void InfLenFIFOQueue::Put(void* elem) { } } -void* InfLenFIFOQueue::Get() { - MutexLock l(&mu_); - if (count_.Load(MemoryOrder::RELAXED) == 0) { - num_waiters_++; - do { - wait_nonempty_.Wait(&mu_); - } while (count_.Load(MemoryOrder::RELAXED) == 0); - num_waiters_--; - } - GPR_DEBUG_ASSERT(count_.Load(MemoryOrder::RELAXED) > 0); - return PopFront(); -} - void* InfLenFIFOQueue::Get(gpr_timespec* wait_time) { MutexLock l(&mu_); if (count_.Load(MemoryOrder::RELAXED) == 0) { gpr_timespec start_time; - start_time = gpr_now(GPR_CLOCK_MONOTONIC); + if (GRPC_TRACE_FLAG_ENABLED(grpc_thread_pool_trace) && + wait_time != nullptr) { + start_time = gpr_now(GPR_CLOCK_MONOTONIC); + } num_waiters_++; do { wait_nonempty_.Wait(&mu_); } while (count_.Load(MemoryOrder::RELAXED) == 0); num_waiters_--; - *wait_time = gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), start_time); + if (GRPC_TRACE_FLAG_ENABLED(grpc_thread_pool_trace) && + wait_time != nullptr) { + *wait_time = gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), start_time); + } } GPR_DEBUG_ASSERT(count_.Load(MemoryOrder::RELAXED) > 0); return PopFront(); diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index fdb3de00e73..5c62221e9d4 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -42,7 +42,8 @@ class MPMCQueueInterface { // Removes the oldest element from the queue and return it. // This might cause to block on empty queue depending on implementation. - virtual void* Get() GRPC_ABSTRACT; + // Optional argument for collecting stats purpose. + virtual void* Get(gpr_timespec* wait_time = nullptr) GRPC_ABSTRACT; // Returns number of elements in the queue currently virtual int count() const GRPC_ABSTRACT; @@ -65,12 +66,9 @@ class InfLenFIFOQueue : public MPMCQueueInterface { // Removes the oldest element from the queue and returns it. // This routine will cause the thread to block if queue is currently empty. - void* Get(); - - // Same as Get(), but will record how long waited when getting. - // This routine should be only called when debug trace is on and wants to - // collect stats data. - void* Get(gpr_timespec* wait_time); + // Argument wait_time should be passed in when trace flag turning on (for + // collecting stats info purpose.) + void* Get(gpr_timespec* wait_time = nullptr); // Returns number of elements in queue currently. // There might be concurrently add/remove on queue, so count might change diff --git a/src/core/lib/iomgr/executor/threadpool.cc b/src/core/lib/iomgr/executor/threadpool.cc index deeadc0f758..166bf0a34a0 100644 --- a/src/core/lib/iomgr/executor/threadpool.cc +++ b/src/core/lib/iomgr/executor/threadpool.cc @@ -29,21 +29,21 @@ void ThreadPoolWorker::Run() { if (GRPC_TRACE_FLAG_ENABLED(grpc_thread_pool_trace)) { // Updates stats and print gpr_timespec wait_time = gpr_time_0(GPR_TIMESPAN); - elem = static_cast(queue_)->Get(&wait_time); - stats_.sleep_cycles = gpr_time_add(stats_.sleep_cycles, wait_time); + elem = queue_->Get(&wait_time); + stats_.sleep_time = gpr_time_add(stats_.sleep_time, wait_time); gpr_log(GPR_INFO, - "ThreadPool Worker [%s %d] Stats: sleep_cycles %f", - thd_name_, index_, gpr_timespec_to_micros(stats_.sleep_cycles)); + "ThreadPool Worker [%s %d] Stats: sleep_time %f", + thd_name_, index_, gpr_timespec_to_micros(stats_.sleep_time)); } else { - elem = static_cast(queue_)->Get(); + elem = queue_->Get(nullptr); } if (elem == nullptr) { break; } // Runs closure - grpc_experimental_completion_queue_functor* closure = + auto* closure = static_cast(elem); - closure->functor_run(closure->internal_next, closure->internal_success); + closure->functor_run(closure, closure->internal_success); } } @@ -70,7 +70,8 @@ size_t ThreadPool::DefaultStackSize() { } bool ThreadPool::HasBeenShutDown() { - return shut_down_.Load(MemoryOrder::ACQUIRE); + // For debug checking purpose, using RELAXED order is sufficient. + return shut_down_.Load(MemoryOrder::RELAXED); } ThreadPool::ThreadPool(int num_threads) : num_threads_(num_threads) { @@ -99,7 +100,8 @@ ThreadPool::ThreadPool(int num_threads, const char* thd_name, } ThreadPool::~ThreadPool() { - shut_down_.Store(true, MemoryOrder::RELEASE); + // For debug checking purpose, using RELAXED order is sufficient. + shut_down_.Store(true, MemoryOrder::RELAXED); for (int i = 0; i < num_threads_; ++i) { queue_->Put(nullptr); @@ -117,11 +119,8 @@ ThreadPool::~ThreadPool() { } void ThreadPool::Add(grpc_experimental_completion_queue_functor* closure) { - if (HasBeenShutDown()) { - gpr_log(GPR_ERROR, "ThreadPool Has Already Been Shut Down."); - } else { - queue_->Put(static_cast(closure)); - } + GPR_DEBUG_ASSERT(!HasBeenShutDown()); + queue_->Put(static_cast(closure)); } int ThreadPool::num_pending_closures() const { return queue_->count(); } diff --git a/src/core/lib/iomgr/executor/threadpool.h b/src/core/lib/iomgr/executor/threadpool.h index f0c54104ef1..d68cbbf7328 100644 --- a/src/core/lib/iomgr/executor/threadpool.h +++ b/src/core/lib/iomgr/executor/threadpool.h @@ -84,8 +84,8 @@ class ThreadPoolWorker { private: // struct for tracking stats of thread struct Stats { - gpr_timespec sleep_cycles; - Stats() { sleep_cycles = gpr_time_0(GPR_TIMESPAN); } + gpr_timespec sleep_time; + Stats() { sleep_time = gpr_time_0(GPR_TIMESPAN); } }; void Run(); // Pulls closures from queue and executes them @@ -145,6 +145,7 @@ class ThreadPool : public ThreadPoolInterface { // For ThreadPool, default stack size for mobile platform is 1952K. for other // platforms is 64K. size_t DefaultStackSize(); + // Internal Use Only for debug checking. bool HasBeenShutDown(); }; diff --git a/test/core/iomgr/threadpool_test.cc b/test/core/iomgr/threadpool_test.cc index a56db5b647a..c093c421b7b 100644 --- a/test/core/iomgr/threadpool_test.cc +++ b/test/core/iomgr/threadpool_test.cc @@ -25,8 +25,6 @@ #define THREAD_SMALL_ITERATION 100 #define THREAD_LARGE_ITERATION 10000 -grpc_core::Mutex mu; - // Simple functor for testing. It will count how many times being called. class SimpleFunctorForAdd : public grpc_experimental_completion_queue_functor { public: @@ -40,17 +38,15 @@ class SimpleFunctorForAdd : public grpc_experimental_completion_queue_functor { static void Run(struct grpc_experimental_completion_queue_functor* cb, int ok) { auto* callback = static_cast(cb); - grpc_core::MutexLock l(&mu); - callback->count_++; + callback->count_.FetchAdd(1, grpc_core::MemoryOrder::RELAXED); } int count() { - grpc_core::MutexLock l(&mu); - return count_; + return count_.Load(grpc_core::MemoryOrder::RELAXED); } private: - int count_; + grpc_core::Atomic count_{0}; }; // Checks the given SimpleFunctorForAdd's count with a given number. @@ -66,8 +62,9 @@ class SimpleFunctorCheckForAdd ~SimpleFunctorCheckForAdd() {} static void Run(struct grpc_experimental_completion_queue_functor* cb, int ok) { - auto* callback = static_cast(cb); - GPR_ASSERT(callback->count_ == ok); + auto* callback = static_cast(cb); + auto* cb_check = static_cast(callback->internal_next); + GPR_ASSERT(cb_check->count_.Load(grpc_core::MemoryOrder::RELAXED) == ok); } }; From 7bc9aba863250d15b00cd6aae4e4db231edb00ad Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Tue, 9 Jul 2019 12:13:33 -0700 Subject: [PATCH 0850/1555] Reformat --- test/core/iomgr/threadpool_test.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/core/iomgr/threadpool_test.cc b/test/core/iomgr/threadpool_test.cc index c093c421b7b..e0a9d73f48b 100644 --- a/test/core/iomgr/threadpool_test.cc +++ b/test/core/iomgr/threadpool_test.cc @@ -41,9 +41,7 @@ class SimpleFunctorForAdd : public grpc_experimental_completion_queue_functor { callback->count_.FetchAdd(1, grpc_core::MemoryOrder::RELAXED); } - int count() { - return count_.Load(grpc_core::MemoryOrder::RELAXED); - } + int count() { return count_.Load(grpc_core::MemoryOrder::RELAXED); } private: grpc_core::Atomic count_{0}; From 674de801232dcfd2e420246c62e52613d837a6fd Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 9 Jul 2019 14:12:27 -0700 Subject: [PATCH 0851/1555] Function in an internal environment --- .../tests/unit/_signal_handling_test.py | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py index 467b8df27f9..5e9dc676a7c 100644 --- a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py +++ b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py @@ -27,7 +27,18 @@ import grpc from tests.unit import test_common from tests.unit import _signal_client -_CLIENT_PATH = os.path.abspath(os.path.realpath(_signal_client.__file__)) +_CLIENT_PATH = None +if sys.executable is not None: + _CLIENT_PATH = os.path.abspath(os.path.realpath(_signal_client.__file__)) +else: + # Note(rbellevi): For compatibility with internal testing. + if len(sys.argv) != 2: + raise RuntimeError("Must supply path to executable client.") + client_name = sys.argv[1].split("/")[-1] + del sys.argv[1] # For compatibility with test runner. + _CLIENT_PATH = os.path.realpath( + os.path.join(os.path.dirname(os.path.abspath(__file__)), client_name)) + _HOST = 'localhost' @@ -104,6 +115,15 @@ def _read_stream(stream): return stream.read() +def _start_client(args, stdout, stderr): + invocation = None + if sys.executable is not None: + invocation = (sys.executable, _CLIENT_PATH) + tuple(args) + else: + invocation = (_CLIENT_PATH,) + tuple(args) + return subprocess.Popen(invocation, stdout=stdout, stderr=stderr) + + class SignalHandlingTest(unittest.TestCase): def setUp(self): @@ -122,10 +142,8 @@ class SignalHandlingTest(unittest.TestCase): server_target = '{}:{}'.format(_HOST, self._port) with tempfile.TemporaryFile(mode='r') as client_stdout: with tempfile.TemporaryFile(mode='r') as client_stderr: - client = subprocess.Popen( - (sys.executable, _CLIENT_PATH, server_target, 'unary'), - stdout=client_stdout, - stderr=client_stderr) + client = _start_client((server_target, 'unary'), client_stdout, + client_stderr) self._handler.await_connected_client() client.send_signal(signal.SIGINT) self.assertFalse(client.wait(), msg=_read_stream(client_stderr)) @@ -139,10 +157,8 @@ class SignalHandlingTest(unittest.TestCase): server_target = '{}:{}'.format(_HOST, self._port) with tempfile.TemporaryFile(mode='r') as client_stdout: with tempfile.TemporaryFile(mode='r') as client_stderr: - client = subprocess.Popen( - (sys.executable, _CLIENT_PATH, server_target, 'streaming'), - stdout=client_stdout, - stderr=client_stderr) + client = _start_client((server_target, 'streaming'), + client_stdout, client_stderr) self._handler.await_connected_client() client.send_signal(signal.SIGINT) self.assertFalse(client.wait(), msg=_read_stream(client_stderr)) From d6e3d04cf861ac62a4c235bfe49737f76f0a1c98 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 9 Jul 2019 15:57:19 -0700 Subject: [PATCH 0852/1555] Capitalize comment --- src/python/grpcio_tests/tests/unit/_signal_handling_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py index 5e9dc676a7c..8ef156c596d 100644 --- a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py +++ b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py @@ -31,7 +31,7 @@ _CLIENT_PATH = None if sys.executable is not None: _CLIENT_PATH = os.path.abspath(os.path.realpath(_signal_client.__file__)) else: - # Note(rbellevi): For compatibility with internal testing. + # NOTE(rbellevi): For compatibility with internal testing. if len(sys.argv) != 2: raise RuntimeError("Must supply path to executable client.") client_name = sys.argv[1].split("/")[-1] From 11e60b8f30ca0bc77f6cec284806c5be2a33087b Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Tue, 9 Jul 2019 16:50:53 -0700 Subject: [PATCH 0853/1555] Add documentation for compression enums --- src/python/grpcio/grpc/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index f0c198db66d..ac5192e0fed 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -1856,10 +1856,16 @@ def _create_servicer_context(rpc_event, state, request_deserializer): context._finalize_state() # pylint: disable=protected-access +@enum.unique class Compression(enum.IntEnum): """Indicates the compression method to be used for an RPC. This enumeration is part of an EXPERIMENTAL API. + + Attributes: + NoCompression: Do not use compression algorithm. + Deflate: Use "Deflate" compression algorithm. + Gzip: Use "Gzip" compression algorithm. """ NoCompression = _compression.NoCompression Deflate = _compression.Deflate From 51f80abb5a80f7b2666b88306740751ea90ca98e Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Thu, 13 Jun 2019 17:09:53 -0700 Subject: [PATCH 0854/1555] Coalesced some grpc_slice_buffer_tiny_add calls in hpack_enc --- .../chttp2/transport/hpack_encoder.cc | 28 +++++++++++-------- src/core/lib/slice/slice_buffer.cc | 3 +- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc index 666d28975a8..2b40b7b03ed 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc @@ -381,10 +381,11 @@ static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor* c, uint32_t len_val_len; GPR_ASSERT(len_val <= UINT32_MAX); len_val_len = GRPC_CHTTP2_VARINT_LENGTH((uint32_t)len_val, 1); - GRPC_CHTTP2_WRITE_VARINT(key_index, 2, 0x40, - add_tiny_header_data(st, len_pfx), len_pfx); + GPR_DEBUG_ASSERT(len_pfx + len_val_len < GRPC_SLICE_INLINED_SIZE); + uint8_t* data = add_tiny_header_data(st, len_pfx + len_val_len); + GRPC_CHTTP2_WRITE_VARINT(key_index, 2, 0x40, data, len_pfx); GRPC_CHTTP2_WRITE_VARINT((uint32_t)len_val, 1, value.huffman_prefix, - add_tiny_header_data(st, len_val_len), len_val_len); + &data[len_pfx], len_val_len); add_wire_value(st, value); } @@ -398,10 +399,11 @@ static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor* c, uint32_t len_val_len; GPR_ASSERT(len_val <= UINT32_MAX); len_val_len = GRPC_CHTTP2_VARINT_LENGTH((uint32_t)len_val, 1); - GRPC_CHTTP2_WRITE_VARINT(key_index, 4, 0x00, - add_tiny_header_data(st, len_pfx), len_pfx); + GPR_DEBUG_ASSERT(len_pfx + len_val_len < GRPC_SLICE_INLINED_SIZE); + uint8_t* data = add_tiny_header_data(st, len_pfx + len_val_len); + GRPC_CHTTP2_WRITE_VARINT(key_index, 4, 0x00, data, len_pfx); GRPC_CHTTP2_WRITE_VARINT((uint32_t)len_val, 1, value.huffman_prefix, - add_tiny_header_data(st, len_val_len), len_val_len); + &data[len_pfx], len_val_len); add_wire_value(st, value); } @@ -418,9 +420,10 @@ static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor* c, uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); GPR_ASSERT(len_key <= UINT32_MAX); GPR_ASSERT(wire_value_length(value) <= UINT32_MAX); - *add_tiny_header_data(st, 1) = 0x40; - GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, - add_tiny_header_data(st, len_key_len), len_key_len); + GPR_DEBUG_ASSERT(1 + len_key_len < GRPC_SLICE_INLINED_SIZE); + uint8_t* data = add_tiny_header_data(st, 1 + len_key_len); + data[0] = 0x40; + GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, &data[1], len_key_len); add_header_data(st, grpc_slice_ref_internal(GRPC_MDKEY(elem))); GRPC_CHTTP2_WRITE_VARINT(len_val, 1, value.huffman_prefix, add_tiny_header_data(st, len_val_len), len_val_len); @@ -440,9 +443,10 @@ static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor* c, uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); GPR_ASSERT(len_key <= UINT32_MAX); GPR_ASSERT(wire_value_length(value) <= UINT32_MAX); - *add_tiny_header_data(st, 1) = 0x00; - GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, - add_tiny_header_data(st, len_key_len), len_key_len); + /* Preconditions passed; emit header. */ + uint8_t* data = add_tiny_header_data(st, 1 + len_key_len); + data[0] = 0x00; + GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, &data[1], len_key_len); add_header_data(st, grpc_slice_ref_internal(GRPC_MDKEY(elem))); GRPC_CHTTP2_WRITE_VARINT(len_val, 1, value.huffman_prefix, add_tiny_header_data(st, len_val_len), len_val_len); diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc index 2b69f576a3c..dfa4b84fd0f 100644 --- a/src/core/lib/slice/slice_buffer.cc +++ b/src/core/lib/slice/slice_buffer.cc @@ -103,7 +103,7 @@ uint8_t* grpc_slice_buffer_tiny_add(grpc_slice_buffer* sb, size_t n) { sb->length += n; - if (sb->count == 0) goto add_new; + if (sb->count == 0) goto add_first; back = &sb->slices[sb->count - 1]; if (back->refcount) goto add_new; if ((back->data.inlined.length + n) > sizeof(back->data.inlined.bytes)) @@ -115,6 +115,7 @@ uint8_t* grpc_slice_buffer_tiny_add(grpc_slice_buffer* sb, size_t n) { add_new: maybe_embiggen(sb); +add_first: back = &sb->slices[sb->count]; sb->count++; back->refcount = nullptr; From 109edca9710ade3b67af6cf5a59cd48caf0da795 Mon Sep 17 00:00:00 2001 From: Julien Boeuf Date: Sun, 7 Jul 2019 22:44:33 -0700 Subject: [PATCH 0855/1555] Adding C++ API and implementation for STS credentials: - marked as experimental. - also changed the name of a field in the options struct. --- CMakeLists.txt | 75 +++++---- Makefile | 80 +++++---- build.yaml | 21 +-- include/grpc/grpc_security.h | 26 +-- include/grpcpp/security/credentials.h | 18 ++ include/grpcpp/security/credentials_impl.h | 64 +++++++ .../credentials/oauth2/oauth2_credentials.cc | 5 +- src/cpp/client/secure_credentials.cc | 148 +++++++++++++++++ src/cpp/client/secure_credentials.h | 11 ++ test/core/security/BUILD | 1 + test/core/security/fetch_oauth2.cc | 72 ++++---- test/cpp/client/credentials_test.cc | 157 ++++++++++++++++++ .../generated/sources_and_headers.json | 33 ++-- 13 files changed, 560 insertions(+), 151 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 22c926df537..8dfa4e8009a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -332,7 +332,6 @@ add_dependencies(buildtests_c grpc_channel_stack_test) add_dependencies(buildtests_c grpc_completion_queue_test) add_dependencies(buildtests_c grpc_completion_queue_threading_test) add_dependencies(buildtests_c grpc_credentials_test) -add_dependencies(buildtests_c grpc_fetch_oauth2) add_dependencies(buildtests_c grpc_ipv6_loopback_available_test) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_c grpc_json_token_test) @@ -634,6 +633,7 @@ add_dependencies(buildtests_cxx golden_file_test) add_dependencies(buildtests_cxx grpc_alts_credentials_options_test) add_dependencies(buildtests_cxx grpc_cli) add_dependencies(buildtests_cxx grpc_core_map_test) +add_dependencies(buildtests_cxx grpc_fetch_oauth2) add_dependencies(buildtests_cxx grpc_linux_system_roots_test) add_dependencies(buildtests_cxx grpc_tool_test) add_dependencies(buildtests_cxx grpclb_api_test) @@ -8270,40 +8270,6 @@ target_link_libraries(grpc_credentials_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) -add_executable(grpc_fetch_oauth2 - test/core/security/fetch_oauth2.cc -) - - -target_include_directories(grpc_fetch_oauth2 - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} -) - -target_link_libraries(grpc_fetch_oauth2 - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - grpc - gpr -) - - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_fetch_oauth2 PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_fetch_oauth2 PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() - -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) - add_executable(grpc_ipv6_loopback_available_test test/core/iomgr/grpc_ipv6_loopback_available_test.cc ) @@ -14080,6 +14046,45 @@ endif() endif (gRPC_BUILD_CODEGEN) if (gRPC_BUILD_TESTS) +add_executable(grpc_fetch_oauth2 + test/core/security/fetch_oauth2.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(grpc_fetch_oauth2 + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(grpc_fetch_oauth2 + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + grpc++ + grpc + gpr + ${_gRPC_GFLAGS_LIBRARIES} +) + + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + add_executable(grpc_linux_system_roots_test test/core/security/linux_system_roots_test.cc third_party/googletest/googletest/src/gtest-all.cc diff --git a/Makefile b/Makefile index c11462f419a..2a1bfad1f35 100644 --- a/Makefile +++ b/Makefile @@ -1056,7 +1056,6 @@ grpc_completion_queue_test: $(BINDIR)/$(CONFIG)/grpc_completion_queue_test grpc_completion_queue_threading_test: $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test grpc_create_jwt: $(BINDIR)/$(CONFIG)/grpc_create_jwt grpc_credentials_test: $(BINDIR)/$(CONFIG)/grpc_credentials_test -grpc_fetch_oauth2: $(BINDIR)/$(CONFIG)/grpc_fetch_oauth2 grpc_ipv6_loopback_available_test: $(BINDIR)/$(CONFIG)/grpc_ipv6_loopback_available_test grpc_json_token_test: $(BINDIR)/$(CONFIG)/grpc_json_token_test grpc_jwt_verifier_test: $(BINDIR)/$(CONFIG)/grpc_jwt_verifier_test @@ -1219,6 +1218,7 @@ grpc_cli: $(BINDIR)/$(CONFIG)/grpc_cli grpc_core_map_test: $(BINDIR)/$(CONFIG)/grpc_core_map_test grpc_cpp_plugin: $(BINDIR)/$(CONFIG)/grpc_cpp_plugin grpc_csharp_plugin: $(BINDIR)/$(CONFIG)/grpc_csharp_plugin +grpc_fetch_oauth2: $(BINDIR)/$(CONFIG)/grpc_fetch_oauth2 grpc_linux_system_roots_test: $(BINDIR)/$(CONFIG)/grpc_linux_system_roots_test grpc_node_plugin: $(BINDIR)/$(CONFIG)/grpc_node_plugin grpc_objective_c_plugin: $(BINDIR)/$(CONFIG)/grpc_objective_c_plugin @@ -1489,7 +1489,6 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/grpc_completion_queue_test \ $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test \ $(BINDIR)/$(CONFIG)/grpc_credentials_test \ - $(BINDIR)/$(CONFIG)/grpc_fetch_oauth2 \ $(BINDIR)/$(CONFIG)/grpc_ipv6_loopback_available_test \ $(BINDIR)/$(CONFIG)/grpc_json_token_test \ $(BINDIR)/$(CONFIG)/grpc_jwt_verifier_test \ @@ -1693,6 +1692,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test \ $(BINDIR)/$(CONFIG)/grpc_cli \ $(BINDIR)/$(CONFIG)/grpc_core_map_test \ + $(BINDIR)/$(CONFIG)/grpc_fetch_oauth2 \ $(BINDIR)/$(CONFIG)/grpc_linux_system_roots_test \ $(BINDIR)/$(CONFIG)/grpc_tool_test \ $(BINDIR)/$(CONFIG)/grpclb_api_test \ @@ -1857,6 +1857,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test \ $(BINDIR)/$(CONFIG)/grpc_cli \ $(BINDIR)/$(CONFIG)/grpc_core_map_test \ + $(BINDIR)/$(CONFIG)/grpc_fetch_oauth2 \ $(BINDIR)/$(CONFIG)/grpc_linux_system_roots_test \ $(BINDIR)/$(CONFIG)/grpc_tool_test \ $(BINDIR)/$(CONFIG)/grpclb_api_test \ @@ -10987,38 +10988,6 @@ endif endif -GRPC_FETCH_OAUTH2_SRC = \ - test/core/security/fetch_oauth2.cc \ - -GRPC_FETCH_OAUTH2_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_FETCH_OAUTH2_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/grpc_fetch_oauth2: openssl_dep_error - -else - - - -$(BINDIR)/$(CONFIG)/grpc_fetch_oauth2: $(GRPC_FETCH_OAUTH2_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_FETCH_OAUTH2_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_fetch_oauth2 - -endif - -$(OBJDIR)/$(CONFIG)/test/core/security/fetch_oauth2.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a - -deps_grpc_fetch_oauth2: $(GRPC_FETCH_OAUTH2_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(GRPC_FETCH_OAUTH2_OBJS:.o=.dep) -endif -endif - - GRPC_IPV6_LOOPBACK_AVAILABLE_TEST_SRC = \ test/core/iomgr/grpc_ipv6_loopback_available_test.cc \ @@ -17134,6 +17103,49 @@ ifneq ($(NO_DEPS),true) endif +GRPC_FETCH_OAUTH2_SRC = \ + test/core/security/fetch_oauth2.cc \ + +GRPC_FETCH_OAUTH2_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_FETCH_OAUTH2_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/grpc_fetch_oauth2: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/grpc_fetch_oauth2: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/grpc_fetch_oauth2: $(PROTOBUF_DEP) $(GRPC_FETCH_OAUTH2_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_FETCH_OAUTH2_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/grpc_fetch_oauth2 + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/core/security/fetch_oauth2.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_grpc_fetch_oauth2: $(GRPC_FETCH_OAUTH2_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(GRPC_FETCH_OAUTH2_OBJS:.o=.dep) +endif +endif + + GRPC_LINUX_SYSTEM_ROOTS_TEST_SRC = \ test/core/security/linux_system_roots_test.cc \ diff --git a/build.yaml b/build.yaml index 1c7be4e23ec..4134ecd8880 100644 --- a/build.yaml +++ b/build.yaml @@ -2863,16 +2863,6 @@ targets: - grpc_test_util - grpc - gpr -- name: grpc_fetch_oauth2 - build: test - run: false - language: c - src: - - test/core/security/fetch_oauth2.cc - deps: - - grpc_test_util - - grpc - - gpr - name: grpc_ipv6_loopback_available_test build: test language: c @@ -4945,6 +4935,17 @@ targets: deps: - grpc_plugin_support secure: false +- name: grpc_fetch_oauth2 + build: test + run: false + language: c++ + src: + - test/core/security/fetch_oauth2.cc + deps: + - grpc_test_util + - grpc++ + - grpc + - gpr - name: grpc_linux_system_roots_test gtest: true build: test diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h index 8e4f26a2854..777142f38c6 100644 --- a/include/grpc/grpc_security.h +++ b/include/grpc/grpc_security.h @@ -330,20 +330,20 @@ GRPCAPI grpc_call_credentials* grpc_google_iam_credentials_create( /** Options for creating STS Oauth Token Exchange credentials following the IETF draft https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16. - Optional fields may be set to NULL. It is the responsibility of the caller to - ensure that the subject and actor tokens are refreshed on disk at the - specified paths. This API is used for experimental purposes for now and may - change in the future. */ + Optional fields may be set to NULL or empty string. It is the responsibility + of the caller to ensure that the subject and actor tokens are refreshed on + disk at the specified paths. This API is used for experimental purposes for + now and may change in the future. */ typedef struct { - const char* sts_endpoint_url; /* Required. */ - const char* resource; /* Optional. */ - const char* audience; /* Optional. */ - const char* scope; /* Optional. */ - const char* requested_token_type; /* Optional. */ - const char* subject_token_path; /* Required. */ - const char* subject_token_type; /* Required. */ - const char* actor_token_path; /* Optional. */ - const char* actor_token_type; /* Optional. */ + const char* token_exchange_service_uri; /* Required. */ + const char* resource; /* Optional. */ + const char* audience; /* Optional. */ + const char* scope; /* Optional. */ + const char* requested_token_type; /* Optional. */ + const char* subject_token_path; /* Required. */ + const char* subject_token_type; /* Required. */ + const char* actor_token_path; /* Optional. */ + const char* actor_token_type; /* Optional. */ } grpc_sts_credentials_options; /** Creates an STS credentials following the STS Token Exchanged specifed in the diff --git a/include/grpcpp/security/credentials.h b/include/grpcpp/security/credentials.h index b124d3d37be..5190b1b3393 100644 --- a/include/grpcpp/security/credentials.h +++ b/include/grpcpp/security/credentials.h @@ -106,6 +106,24 @@ MetadataCredentialsFromPlugin( namespace experimental { +typedef ::grpc_impl::experimental::StsCredentialsOptions StsCredentialsOptions; + +static inline grpc::Status StsCredentialsOptionsFromJson( + const grpc::string& json_string, StsCredentialsOptions* options) { + return ::grpc_impl::experimental::StsCredentialsOptionsFromJson(json_string, + options); +} + +static inline grpc::Status StsCredentialsOptionsFromEnv( + StsCredentialsOptions* options) { + return grpc_impl::experimental::StsCredentialsOptionsFromEnv(options); +} + +static inline std::shared_ptr StsCredentials( + const StsCredentialsOptions& options) { + return grpc_impl::experimental::StsCredentials(options); +} + typedef ::grpc_impl::experimental::AltsCredentialsOptions AltsCredentialsOptions; diff --git a/include/grpcpp/security/credentials_impl.h b/include/grpcpp/security/credentials_impl.h index 34920a55bbe..e236512f43e 100644 --- a/include/grpcpp/security/credentials_impl.h +++ b/include/grpcpp/security/credentials_impl.h @@ -259,6 +259,70 @@ std::shared_ptr MetadataCredentialsFromPlugin( namespace experimental { +/// Options for creating STS Oauth Token Exchange credentials following the IETF +/// draft https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16. +/// Optional fields may be set to empty string. It is the responsibility of the +/// caller to ensure that the subject and actor tokens are refreshed on disk at +/// the specified paths. +struct StsCredentialsOptions { + grpc::string token_exchange_service_uri; // Required. + grpc::string resource; // Optional. + grpc::string audience; // Optional. + grpc::string scope; // Optional. + grpc::string requested_token_type; // Optional. + grpc::string subject_token_path; // Required. + grpc::string subject_token_type; // Required. + grpc::string actor_token_path; // Optional. + grpc::string actor_token_type; // Optional. +}; + +/// Creates STS Options from a JSON string. The JSON schema is as follows: +/// { +/// "title": "STS Credentials Config", +/// "type": "object", +/// "required": ["token_exchange_service_uri", "subject_token_path", +/// "subject_token_type"], +/// "properties": { +/// "token_exchange_service_uri": { +/// "type": "string" +/// }, +/// "resource": { +/// "type": "string" +/// }, +/// "audience": { +/// "type": "string" +/// }, +/// "scope": { +/// "type": "string" +/// }, +/// "requested_token_type": { +/// "type": "string" +/// }, +/// "subject_token_path": { +/// "type": "string" +/// }, +/// "subject_token_type": { +/// "type": "string" +/// }, +/// "actor_token_path" : { +/// "type": "string" +/// }, +/// "actor_token_type": { +/// "type": "string" +/// } +/// } +/// } +grpc::Status StsCredentialsOptionsFromJson(const grpc::string& json_string, + StsCredentialsOptions* options); + +/// Creates STS credentials options from the $STS_CREDENTIALS environment +/// variable. This environment variable points to the path of a JSON file +/// comforming to the schema described above. +grpc::Status StsCredentialsOptionsFromEnv(StsCredentialsOptions* options); + +std::shared_ptr StsCredentials( + const StsCredentialsOptions& options); + /// Options used to build AltsCredentials. struct AltsCredentialsOptions { /// service accounts of target endpoint that will be acceptable diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc index 06fa8bbdb4b..7a584835b96 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc @@ -18,6 +18,7 @@ #include +#include "src/core/lib/json/json.h" #include "src/core/lib/security/credentials/oauth2/oauth2_credentials.h" #include @@ -641,8 +642,8 @@ grpc_error* ValidateStsCredentialsOptions( *sts_url_out = nullptr; InlinedVector error_list; UniquePtr sts_url( - options->sts_endpoint_url != nullptr - ? grpc_uri_parse(options->sts_endpoint_url, false) + options->token_exchange_service_uri != nullptr + ? grpc_uri_parse(options->token_exchange_service_uri, false) : nullptr); if (sts_url == nullptr) { error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index d73b3e035c8..5de5a76194e 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -17,13 +17,23 @@ */ #include "src/cpp/client/secure_credentials.h" + +#include +#include #include #include #include +#include #include #include + +#include "src/core/lib/gpr/env.h" +#include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/executor.h" +#include "src/core/lib/iomgr/load_file.h" +#include "src/core/lib/json/json.h" #include "src/core/lib/security/transport/auth_filters.h" +#include "src/core/lib/security/util/json_util.h" #include "src/cpp/client/create_channel_internal.h" #include "src/cpp/common/secure_auth_context.h" @@ -105,6 +115,144 @@ std::shared_ptr SslCredentials( namespace experimental { +namespace { + +void ClearStsCredentialsOptions(StsCredentialsOptions* options) { + if (options == nullptr) return; + options->token_exchange_service_uri.clear(); + options->resource.clear(); + options->audience.clear(); + options->scope.clear(); + options->requested_token_type.clear(); + options->subject_token_path.clear(); + options->subject_token_type.clear(); + options->actor_token_path.clear(); + options->actor_token_type.clear(); +} + +} // namespace + +// Builds STS credentials options from JSON. +grpc::Status StsCredentialsOptionsFromJson(const grpc::string& json_string, + StsCredentialsOptions* options) { + struct GrpcJsonDeleter { + void operator()(grpc_json* json) { grpc_json_destroy(json); } + }; + if (options == nullptr) { + return grpc::Status(grpc::INVALID_ARGUMENT, "options cannot be nullptr."); + } + ClearStsCredentialsOptions(options); + std::vector scratchpad(json_string.c_str(), + json_string.c_str() + json_string.size() + 1); + std::unique_ptr json( + grpc_json_parse_string(&scratchpad[0])); + if (json == nullptr) { + return grpc::Status(grpc::INVALID_ARGUMENT, "Invalid json."); + } + + // Required fields. + const char* value = grpc_json_get_string_property( + json.get(), "token_exchange_service_uri", nullptr); + if (value == nullptr) { + ClearStsCredentialsOptions(options); + return grpc::Status(grpc::INVALID_ARGUMENT, + "token_exchange_service_uri must be specified."); + } + options->token_exchange_service_uri.assign(value); + value = + grpc_json_get_string_property(json.get(), "subject_token_path", nullptr); + if (value == nullptr) { + ClearStsCredentialsOptions(options); + return grpc::Status(grpc::INVALID_ARGUMENT, + "subject_token_path must be specified."); + } + options->subject_token_path.assign(value); + value = + grpc_json_get_string_property(json.get(), "subject_token_type", nullptr); + if (value == nullptr) { + ClearStsCredentialsOptions(options); + return grpc::Status(grpc::INVALID_ARGUMENT, + "subject_token_type must be specified."); + } + options->subject_token_type.assign(value); + + // Optional fields. + value = grpc_json_get_string_property(json.get(), "resource", nullptr); + if (value != nullptr) options->resource.assign(value); + value = grpc_json_get_string_property(json.get(), "audience", nullptr); + if (value != nullptr) options->audience.assign(value); + value = grpc_json_get_string_property(json.get(), "scope", nullptr); + if (value != nullptr) options->scope.assign(value); + value = grpc_json_get_string_property(json.get(), "requested_token_type", + nullptr); + if (value != nullptr) options->requested_token_type.assign(value); + value = + grpc_json_get_string_property(json.get(), "actor_token_path", nullptr); + if (value != nullptr) options->actor_token_path.assign(value); + value = + grpc_json_get_string_property(json.get(), "actor_token_type", nullptr); + if (value != nullptr) options->actor_token_type.assign(value); + + return grpc::Status(); +} + +// Builds STS credentials Options from the $STS_CREDENTIALS env var. +grpc::Status StsCredentialsOptionsFromEnv(StsCredentialsOptions* options) { + if (options == nullptr) { + return grpc::Status(grpc::INVALID_ARGUMENT, "options cannot be nullptr."); + } + ClearStsCredentialsOptions(options); + grpc_slice json_string = grpc_empty_slice(); + char* sts_creds_path = gpr_getenv("STS_CREDENTIALS"); + grpc_error* error = GRPC_ERROR_NONE; + grpc::Status status; + auto cleanup = [&json_string, &sts_creds_path, &error, &status]() { + grpc_slice_unref_internal(json_string); + gpr_free(sts_creds_path); + GRPC_ERROR_UNREF(error); + return status; + }; + + if (sts_creds_path == nullptr) { + status = grpc::Status(grpc::NOT_FOUND, + "STS_CREDENTIALS environment variable not set."); + return cleanup(); + } + error = grpc_load_file(sts_creds_path, 1, &json_string); + if (error != GRPC_ERROR_NONE) { + status = grpc::Status(grpc::NOT_FOUND, grpc_error_string(error)); + return cleanup(); + } + status = StsCredentialsOptionsFromJson( + reinterpret_cast(GRPC_SLICE_START_PTR(json_string)), + options); + return cleanup(); +} + +// C++ to Core STS Credentials options. +grpc_sts_credentials_options StsCredentialsCppToCoreOptions( + const StsCredentialsOptions& options) { + grpc_sts_credentials_options opts; + memset(&opts, 0, sizeof(opts)); + opts.token_exchange_service_uri = options.token_exchange_service_uri.c_str(); + opts.resource = options.resource.c_str(); + opts.audience = options.audience.c_str(); + opts.scope = options.scope.c_str(); + opts.requested_token_type = options.requested_token_type.c_str(); + opts.subject_token_path = options.subject_token_path.c_str(); + opts.subject_token_type = options.subject_token_type.c_str(); + opts.actor_token_path = options.actor_token_path.c_str(); + opts.actor_token_type = options.actor_token_type.c_str(); + return opts; +} + +// Builds STS credentials. +std::shared_ptr StsCredentials( + const StsCredentialsOptions& options) { + auto opts = StsCredentialsCppToCoreOptions(options); + return WrapCallCredentials(grpc_sts_credentials_create(&opts, nullptr)); +} + // Builds ALTS Credentials given ALTS specific options std::shared_ptr AltsCredentials( const AltsCredentialsOptions& options) { diff --git a/src/cpp/client/secure_credentials.h b/src/cpp/client/secure_credentials.h index dd379ca657d..ed14df4938e 100644 --- a/src/cpp/client/secure_credentials.h +++ b/src/cpp/client/secure_credentials.h @@ -22,6 +22,7 @@ #include #include +#include #include #include "src/core/lib/security/credentials/credentials.h" @@ -68,6 +69,16 @@ class SecureCallCredentials final : public CallCredentials { grpc_call_credentials* const c_creds_; }; +namespace experimental { + +// Transforms C++ STS Credentials options to core options. The pointers of the +// resulting core options point to the memory held by the C++ options so C++ +// options need to be kept alive until after the core credentials creation. +grpc_sts_credentials_options StsCredentialsCppToCoreOptions( + const StsCredentialsOptions& options); + +} // namespace experimental + } // namespace grpc_impl namespace grpc { diff --git a/test/core/security/BUILD b/test/core/security/BUILD index d8dcdc25231..835c0ad7b65 100644 --- a/test/core/security/BUILD +++ b/test/core/security/BUILD @@ -171,6 +171,7 @@ grpc_cc_binary( ":oauth2_utils", "//:gpr", "//:grpc", + "//:grpc++", "//test/core/util:grpc_test_util", ], ) diff --git a/test/core/security/fetch_oauth2.cc b/test/core/security/fetch_oauth2.cc index d404368b8b9..1aa999758b0 100644 --- a/test/core/security/fetch_oauth2.cc +++ b/test/core/security/fetch_oauth2.cc @@ -26,53 +26,40 @@ #include #include +#include "grpcpp/security/credentials_impl.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/util/json_util.h" +#include "src/cpp/client/secure_credentials.h" #include "test/core/security/oauth2_utils.h" #include "test/core/util/cmdline.h" -static grpc_sts_credentials_options sts_options_from_json(grpc_json* json) { - grpc_sts_credentials_options options; - memset(&options, 0, sizeof(options)); - grpc_error* error = GRPC_ERROR_NONE; - options.sts_endpoint_url = - grpc_json_get_string_property(json, "sts_endpoint_url", &error); - GRPC_LOG_IF_ERROR("STS credentials parsing", error); - options.resource = grpc_json_get_string_property(json, "resource", nullptr); - options.audience = grpc_json_get_string_property(json, "audience", nullptr); - options.scope = grpc_json_get_string_property(json, "scope", nullptr); - options.requested_token_type = - grpc_json_get_string_property(json, "requested_token_type", nullptr); - options.subject_token_path = - grpc_json_get_string_property(json, "subject_token_path", &error); - GRPC_LOG_IF_ERROR("STS credentials parsing", error); - options.subject_token_type = - grpc_json_get_string_property(json, "subject_token_type", &error); - GRPC_LOG_IF_ERROR("STS credentials parsing", error); - options.actor_token_path = - grpc_json_get_string_property(json, "actor_token_path", nullptr); - options.actor_token_type = - grpc_json_get_string_property(json, "actor_token_type", nullptr); - return options; -} - static grpc_call_credentials* create_sts_creds(const char* json_file_path) { - grpc_slice sts_options_slice; - GPR_ASSERT(GRPC_LOG_IF_ERROR( - "load_file", grpc_load_file(json_file_path, 1, &sts_options_slice))); - grpc_json* json = grpc_json_parse_string( - reinterpret_cast(GRPC_SLICE_START_PTR(sts_options_slice))); - if (json == nullptr) { - gpr_log(GPR_ERROR, "Invalid json"); - return nullptr; + grpc_impl::experimental::StsCredentialsOptions options; + if (strlen(json_file_path) == 0) { + auto status = + grpc_impl::experimental::StsCredentialsOptionsFromEnv(&options); + if (!status.ok()) { + gpr_log(GPR_ERROR, "%s", status.error_message().c_str()); + return nullptr; + } + } else { + grpc_slice sts_options_slice; + GPR_ASSERT(GRPC_LOG_IF_ERROR( + "load_file", grpc_load_file(json_file_path, 1, &sts_options_slice))); + auto status = grpc_impl::experimental::StsCredentialsOptionsFromJson( + reinterpret_cast(GRPC_SLICE_START_PTR(sts_options_slice)), + &options); + gpr_slice_unref(sts_options_slice); + if (!status.ok()) { + gpr_log(GPR_ERROR, "%s", status.error_message().c_str()); + return nullptr; + } } - grpc_sts_credentials_options options = sts_options_from_json(json); - grpc_call_credentials* result = - grpc_sts_credentials_create(&options, nullptr); - grpc_json_destroy(json); - gpr_slice_unref(sts_options_slice); + grpc_sts_credentials_options opts = + grpc_impl::experimental::StsCredentialsCppToCoreOptions(options); + grpc_call_credentials* result = grpc_sts_credentials_create(&opts, nullptr); return result; } @@ -99,9 +86,12 @@ int main(int argc, char** argv) { gpr_cmdline_add_string(cl, "json_refresh_token", "File path of the json refresh token.", &json_refresh_token_file_path); - gpr_cmdline_add_string(cl, "json_sts_options", - "File path of the json sts options.", - &json_sts_options_file_path); + gpr_cmdline_add_string( + cl, "json_sts_options", + "File path of the json sts options. If the path is empty, the program " + "will attempt to use the $STS_CREDENTIALS environment variable to access " + "a file containing the options.", + &json_sts_options_file_path); gpr_cmdline_add_flag( cl, "gce", "Get a token from the GCE metadata server (only works in GCE).", diff --git a/test/cpp/client/credentials_test.cc b/test/cpp/client/credentials_test.cc index e64e260a46c..d560fb6d8e8 100644 --- a/test/cpp/client/credentials_test.cc +++ b/test/cpp/client/credentials_test.cc @@ -20,9 +20,14 @@ #include +#include #include #include +#include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/tmpfile.h" +#include "src/cpp/client/secure_credentials.h" + namespace grpc { namespace testing { @@ -39,6 +44,158 @@ TEST_F(CredentialsTest, DefaultCredentials) { auto creds = GoogleDefaultCredentials(); } +TEST_F(CredentialsTest, StsCredentialsOptionsCppToCore) { + grpc::experimental::StsCredentialsOptions options; + options.token_exchange_service_uri = "https://foo.com/exchange"; + options.resource = "resource"; + options.audience = "audience"; + options.scope = "scope"; + // options.requested_token_type explicitly not set. + options.subject_token_path = "/foo/bar"; + options.subject_token_type = "nice_token_type"; + options.actor_token_path = "/foo/baz"; + options.actor_token_type = "even_nicer_token_type"; + grpc_sts_credentials_options core_opts = + grpc_impl::experimental::StsCredentialsCppToCoreOptions(options); + EXPECT_EQ(options.token_exchange_service_uri, + core_opts.token_exchange_service_uri); + EXPECT_EQ(options.resource, core_opts.resource); + EXPECT_EQ(options.audience, core_opts.audience); + EXPECT_EQ(options.scope, core_opts.scope); + EXPECT_EQ(options.requested_token_type, core_opts.requested_token_type); + EXPECT_EQ(options.subject_token_path, core_opts.subject_token_path); + EXPECT_EQ(options.subject_token_type, core_opts.subject_token_type); + EXPECT_EQ(options.actor_token_path, core_opts.actor_token_path); + EXPECT_EQ(options.actor_token_type, core_opts.actor_token_type); +} + +TEST_F(CredentialsTest, StsCredentialsOptionsJson) { + const char valid_json[] = R"( + { + "token_exchange_service_uri": "https://foo/exchange", + "resource": "resource", + "audience": "audience", + "scope": "scope", + "requested_token_type": "requested_token_type", + "subject_token_path": "subject_token_path", + "subject_token_type": "subject_token_type", + "actor_token_path": "actor_token_path", + "actor_token_type": "actor_token_type" + })"; + grpc::experimental::StsCredentialsOptions options; + EXPECT_TRUE( + grpc::experimental::StsCredentialsOptionsFromJson(valid_json, &options) + .ok()); + EXPECT_EQ(options.token_exchange_service_uri, "https://foo/exchange"); + EXPECT_EQ(options.resource, "resource"); + EXPECT_EQ(options.audience, "audience"); + EXPECT_EQ(options.scope, "scope"); + EXPECT_EQ(options.requested_token_type, "requested_token_type"); + EXPECT_EQ(options.subject_token_path, "subject_token_path"); + EXPECT_EQ(options.subject_token_type, "subject_token_type"); + EXPECT_EQ(options.actor_token_path, "actor_token_path"); + EXPECT_EQ(options.actor_token_type, "actor_token_type"); + + const char minimum_valid_json[] = R"( + { + "token_exchange_service_uri": "https://foo/exchange", + "subject_token_path": "subject_token_path", + "subject_token_type": "subject_token_type" + })"; + EXPECT_TRUE(grpc::experimental::StsCredentialsOptionsFromJson( + minimum_valid_json, &options) + .ok()); + EXPECT_EQ(options.token_exchange_service_uri, "https://foo/exchange"); + EXPECT_EQ(options.resource, ""); + EXPECT_EQ(options.audience, ""); + EXPECT_EQ(options.scope, ""); + EXPECT_EQ(options.requested_token_type, ""); + EXPECT_EQ(options.subject_token_path, "subject_token_path"); + EXPECT_EQ(options.subject_token_type, "subject_token_type"); + EXPECT_EQ(options.actor_token_path, ""); + EXPECT_EQ(options.actor_token_type, ""); + + const char invalid_json[] = R"( + I'm not a valid JSON. + )"; + EXPECT_EQ( + grpc::INVALID_ARGUMENT, + grpc::experimental::StsCredentialsOptionsFromJson(invalid_json, &options) + .error_code()); + + const char invalid_json_missing_subject_token_type[] = R"( + { + "token_exchange_service_uri": "https://foo/exchange", + "subject_token_path": "subject_token_path" + })"; + auto status = grpc::experimental::StsCredentialsOptionsFromJson( + invalid_json_missing_subject_token_type, &options); + EXPECT_EQ(grpc::INVALID_ARGUMENT, status.error_code()); + EXPECT_THAT(status.error_message(), + ::testing::HasSubstr("subject_token_type")); + + const char invalid_json_missing_subject_token_path[] = R"( + { + "token_exchange_service_uri": "https://foo/exchange", + "subject_token_type": "subject_token_type" + })"; + status = grpc::experimental::StsCredentialsOptionsFromJson( + invalid_json_missing_subject_token_path, &options); + EXPECT_EQ(grpc::INVALID_ARGUMENT, status.error_code()); + EXPECT_THAT(status.error_message(), + ::testing::HasSubstr("subject_token_path")); + + const char invalid_json_missing_token_exchange_uri[] = R"( + { + "subject_token_path": "subject_token_path", + "subject_token_type": "subject_token_type" + })"; + status = grpc::experimental::StsCredentialsOptionsFromJson( + invalid_json_missing_token_exchange_uri, &options); + EXPECT_EQ(grpc::INVALID_ARGUMENT, status.error_code()); + EXPECT_THAT(status.error_message(), + ::testing::HasSubstr("token_exchange_service_uri")); +} + +TEST_F(CredentialsTest, StsCredentialsOptionsFromEnv) { + // Unset env and check expected failure. + gpr_unsetenv("STS_CREDENTIALS"); + grpc::experimental::StsCredentialsOptions options; + auto status = grpc::experimental::StsCredentialsOptionsFromEnv(&options); + EXPECT_EQ(grpc::NOT_FOUND, status.error_code()); + + // Set env and check for success. + const char valid_json[] = R"( + { + "token_exchange_service_uri": "https://foo/exchange", + "subject_token_path": "subject_token_path", + "subject_token_type": "subject_token_type" + })"; + char* creds_file_name; + FILE* creds_file = gpr_tmpfile("sts_creds_options", &creds_file_name); + ASSERT_NE(creds_file_name, nullptr); + ASSERT_NE(creds_file, nullptr); + ASSERT_EQ(sizeof(valid_json), + fwrite(valid_json, 1, sizeof(valid_json), creds_file)); + fclose(creds_file); + gpr_setenv("STS_CREDENTIALS", creds_file_name); + gpr_free(creds_file_name); + status = grpc::experimental::StsCredentialsOptionsFromEnv(&options); + EXPECT_TRUE(status.ok()); + EXPECT_EQ(options.token_exchange_service_uri, "https://foo/exchange"); + EXPECT_EQ(options.resource, ""); + EXPECT_EQ(options.audience, ""); + EXPECT_EQ(options.scope, ""); + EXPECT_EQ(options.requested_token_type, ""); + EXPECT_EQ(options.subject_token_path, "subject_token_path"); + EXPECT_EQ(options.subject_token_type, "subject_token_type"); + EXPECT_EQ(options.actor_token_path, ""); + EXPECT_EQ(options.actor_token_type, ""); + + // Cleanup. + gpr_unsetenv("STS_CREDENTIALS"); +} + } // namespace testing } // namespace grpc diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 92b3757c65e..0f560fd1063 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -1024,22 +1024,6 @@ "third_party": false, "type": "target" }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_fetch_oauth2", - "src": [ - "test/core/security/fetch_oauth2.cc" - ], - "third_party": false, - "type": "target" - }, { "deps": [ "gpr", @@ -3878,6 +3862,23 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "grpc", + "grpc++", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "grpc_fetch_oauth2", + "src": [ + "test/core/security/fetch_oauth2.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", From ee7b5be39649cee0b5b02a2f81a97794388a2c14 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 10 Jul 2019 04:35:30 -0400 Subject: [PATCH 0856/1555] more accurate comment --- src/csharp/Grpc.Core.Api/DeserializationContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/csharp/Grpc.Core.Api/DeserializationContext.cs b/src/csharp/Grpc.Core.Api/DeserializationContext.cs index eb00f67601e..b0c3badbc24 100644 --- a/src/csharp/Grpc.Core.Api/DeserializationContext.cs +++ b/src/csharp/Grpc.Core.Api/DeserializationContext.cs @@ -53,7 +53,7 @@ namespace Grpc.Core /// The ReadOnlySequence is only valid for the duration of the deserializer routine and the caller must not access it after the deserializer returns. /// Using the read only sequence is the most efficient way to access the message payload. Where possible it allows directly /// accessing the received payload without needing to perform any buffer copying or buffer allocations. - /// NOTE: In order to access the payload via this method, your compiler needs to support C# 7.2 (to be able to use the Span type). + /// NOTE: When using this method, it is recommended to use C# 7.2 compiler to make it more useful (using Span type directly from your code requires C# 7.2)." /// NOTE: Deserializers are expected not to call this method (or other payload accessor methods) more than once per received message /// (as there is no practical reason for doing so) and DeserializationContext implementations are free to assume so. /// From 578f027e3c6363d2e0b5d9679a90e36a4bc50e55 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 10 Jul 2019 04:43:05 -0400 Subject: [PATCH 0857/1555] deduplicate GUIDs in unity package skeleton --- .../unitypackage_skeleton/Plugins/System.Buffers/lib.meta | 2 +- .../unitypackage_skeleton/Plugins/System.Buffers/lib/net45.meta | 2 +- .../Plugins/System.Buffers/lib/net45/System.Buffers.dll.meta | 2 +- .../Plugins/System.Buffers/lib/net45/System.Buffers.xml.meta | 2 +- .../unitypackage_skeleton/Plugins/System.Memory/lib.meta | 2 +- .../unitypackage_skeleton/Plugins/System.Memory/lib/net45.meta | 2 +- .../Plugins/System.Memory/lib/net45/System.Memory.dll.meta | 2 +- .../Plugins/System.Memory/lib/net45/System.Memory.xml.meta | 2 +- .../Plugins/System.Runtime.CompilerServices.Unsafe/lib.meta | 2 +- .../System.Runtime.CompilerServices.Unsafe/lib/net45.meta | 2 +- .../lib/net45/System.Runtime.CompilerServices.Unsafe.dll.meta | 2 +- .../lib/net45/System.Runtime.CompilerServices.Unsafe.xml.meta | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib.meta index d7ae012a397..754fcaee5f1 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib.meta +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: bd5ddd2522dc301488ffe002106fe0ab +guid: 0cb4be3dca2a49e6a920da037ea13d80 folderAsset: yes timeCreated: 1531219385 licenseType: Free diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45.meta index 9b1748d3e76..00368db2d4f 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45.meta +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a68443518bcd1d44ba88a871dcab0c83 +guid: 53b3f7a608814da5a3e3207d10c85b4e folderAsset: yes timeCreated: 1531219385 licenseType: Free diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45/System.Buffers.dll.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45/System.Buffers.dll.meta index bb910fe9229..6a9eae1c5b8 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45/System.Buffers.dll.meta +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45/System.Buffers.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4c05e46cbf00c68408f5ddc1eef9ae3b +guid: bb037a236f584460af82c59c5d5ad972 timeCreated: 1531219386 licenseType: Free PluginImporter: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45/System.Buffers.xml.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45/System.Buffers.xml.meta index 53f91502bd6..14b3b367a4a 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45/System.Buffers.xml.meta +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Buffers/lib/net45/System.Buffers.xml.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6fc38864f2d3dde46b3833c62c91a008 +guid: 4b9fff86d3b2471eb0003735b3ce3a51 timeCreated: 1531219386 licenseType: Free TextScriptImporter: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib.meta index d7ae012a397..eab9851920f 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib.meta +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: bd5ddd2522dc301488ffe002106fe0ab +guid: 3d6c20bf92b74c03b1ba691cbce610e4 folderAsset: yes timeCreated: 1531219385 licenseType: Free diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45.meta index 9b1748d3e76..2d33fd95298 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45.meta +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a68443518bcd1d44ba88a871dcab0c83 +guid: 7164a0a387b24d1a9d76f6d558fc44d2 folderAsset: yes timeCreated: 1531219385 licenseType: Free diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45/System.Memory.dll.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45/System.Memory.dll.meta index bb910fe9229..11af5eae04c 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45/System.Memory.dll.meta +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45/System.Memory.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4c05e46cbf00c68408f5ddc1eef9ae3b +guid: e774d51b8ba64a988dd37135e487105c timeCreated: 1531219386 licenseType: Free PluginImporter: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45/System.Memory.xml.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45/System.Memory.xml.meta index 53f91502bd6..4c04cedb0eb 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45/System.Memory.xml.meta +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Memory/lib/net45/System.Memory.xml.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6fc38864f2d3dde46b3833c62c91a008 +guid: 3d27c5afe3114f67b0f6e27e36b89d5c timeCreated: 1531219386 licenseType: Free TextScriptImporter: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib.meta index d7ae012a397..b3a382aed11 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib.meta +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: bd5ddd2522dc301488ffe002106fe0ab +guid: f51cc0f065424fb2928eee7c2804bfd8 folderAsset: yes timeCreated: 1531219385 licenseType: Free diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45.meta index 9b1748d3e76..4154241974e 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45.meta +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a68443518bcd1d44ba88a871dcab0c83 +guid: aad21c5c1f2f4c1391b1e4a475f163bb folderAsset: yes timeCreated: 1531219385 licenseType: Free diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45/System.Runtime.CompilerServices.Unsafe.dll.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45/System.Runtime.CompilerServices.Unsafe.dll.meta index bb910fe9229..c3988cadd4e 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45/System.Runtime.CompilerServices.Unsafe.dll.meta +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45/System.Runtime.CompilerServices.Unsafe.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4c05e46cbf00c68408f5ddc1eef9ae3b +guid: d378b9cd266a4a448f071c114e5f18cb timeCreated: 1531219386 licenseType: Free PluginImporter: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45/System.Runtime.CompilerServices.Unsafe.xml.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45/System.Runtime.CompilerServices.Unsafe.xml.meta index 53f91502bd6..e756ced26d0 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45/System.Runtime.CompilerServices.Unsafe.xml.meta +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Runtime.CompilerServices.Unsafe/lib/net45/System.Runtime.CompilerServices.Unsafe.xml.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6fc38864f2d3dde46b3833c62c91a008 +guid: cfa8e546fee54a5ea3b20cf9dcf90fdf timeCreated: 1531219386 licenseType: Free TextScriptImporter: From 6fbe9d916daae8e507e3797c4a6a9ad544ecc8c2 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 10 Jul 2019 20:56:38 +1200 Subject: [PATCH 0858/1555] Add ChannelBase, change client base argument --- src/csharp/Grpc.Core.Api/ChannelBase.cs | 52 +++++++++++++++++++++++++ src/csharp/Grpc.Core/Channel.cs | 24 ++++++------ src/csharp/Grpc.Core/ClientBase.cs | 4 +- 3 files changed, 65 insertions(+), 15 deletions(-) create mode 100644 src/csharp/Grpc.Core.Api/ChannelBase.cs diff --git a/src/csharp/Grpc.Core.Api/ChannelBase.cs b/src/csharp/Grpc.Core.Api/ChannelBase.cs new file mode 100644 index 00000000000..54546300e81 --- /dev/null +++ b/src/csharp/Grpc.Core.Api/ChannelBase.cs @@ -0,0 +1,52 @@ +#region Copyright notice and license + +// Copyright 2019 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using Grpc.Core.Utils; + +namespace Grpc.Core +{ + /// + /// Base class for gRPC channel. Channels are an abstraction of long-lived connections to remote servers. + /// + public abstract class ChannelBase + { + private readonly string target; + + /// + /// Initializes a new instance of class that connects to a specific host. + /// + /// Target of the channel. + protected ChannelBase(string target) + { + this.target = GrpcPreconditions.CheckNotNull(target, nameof(target)); + } + + /// The original target used to create the channel. + public string Target + { + get { return this.target; } + } + + /// + /// Create a new for the channel. + /// + /// A new . + public abstract CallInvoker CreateCallInvoker(); + } +} diff --git a/src/csharp/Grpc.Core/Channel.cs b/src/csharp/Grpc.Core/Channel.cs index 97f79b0fb4f..fb58c077c70 100644 --- a/src/csharp/Grpc.Core/Channel.cs +++ b/src/csharp/Grpc.Core/Channel.cs @@ -30,7 +30,7 @@ namespace Grpc.Core /// More client objects can reuse the same channel. Creating a channel is an expensive operation compared to invoking /// a remote call so in general you should reuse a single channel for as many calls as possible. /// - public class Channel + public class Channel : ChannelBase { static readonly ILogger Logger = GrpcEnvironment.Logger.ForType(); @@ -38,7 +38,6 @@ namespace Grpc.Core readonly AtomicCounter activeCallCounter = new AtomicCounter(); readonly CancellationTokenSource shutdownTokenSource = new CancellationTokenSource(); - readonly string target; readonly GrpcEnvironment environment; readonly CompletionQueueSafeHandle completionQueue; readonly ChannelSafeHandle handle; @@ -64,9 +63,8 @@ namespace Grpc.Core /// Target of the channel. /// Credentials to secure the channel. /// Channel options. - public Channel(string target, ChannelCredentials credentials, IEnumerable options) + public Channel(string target, ChannelCredentials credentials, IEnumerable options) : base(target) { - this.target = GrpcPreconditions.CheckNotNull(target, "target"); this.options = CreateOptionsDictionary(options); EnsureUserAgentChannelOption(this.options); this.environment = GrpcEnvironment.AddRef(); @@ -179,15 +177,6 @@ namespace Grpc.Core } } - /// The original target used to create the channel. - public string Target - { - get - { - return this.target; - } - } - /// /// Returns a token that gets cancelled once ShutdownAsync is invoked. /// @@ -257,6 +246,15 @@ namespace Grpc.Core await GrpcEnvironment.ReleaseAsync().ConfigureAwait(false); } + /// + /// Create a new for the channel. + /// + /// A new . + public override CallInvoker CreateCallInvoker() + { + return new DefaultCallInvoker(this); + } + internal ChannelSafeHandle Handle { get diff --git a/src/csharp/Grpc.Core/ClientBase.cs b/src/csharp/Grpc.Core/ClientBase.cs index 05edce7467d..243c35e20c1 100644 --- a/src/csharp/Grpc.Core/ClientBase.cs +++ b/src/csharp/Grpc.Core/ClientBase.cs @@ -51,7 +51,7 @@ namespace Grpc.Core /// Initializes a new instance of ClientBase class. /// /// The channel to use for remote call invocation. - public ClientBase(Channel channel) : base(channel) + public ClientBase(ChannelBase channel) : base(channel) { } @@ -113,7 +113,7 @@ namespace Grpc.Core /// Initializes a new instance of ClientBase class. /// /// The channel to use for remote call invocation. - public ClientBase(Channel channel) : this(new DefaultCallInvoker(channel)) + public ClientBase(ChannelBase channel) : this(channel.CreateCallInvoker()) { } From 5dee89b06e3171ec1fee76245055106372d59e5b Mon Sep 17 00:00:00 2001 From: Wensheng Tang Date: Sun, 7 Jul 2019 01:59:28 +0800 Subject: [PATCH 0859/1555] Use grpc_error defs instead of NULL NULL is not clear for a grpc_error. Not sure we should use other error codes here. --- src/core/lib/iomgr/tcp_server_windows.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/tcp_server_windows.cc b/src/core/lib/iomgr/tcp_server_windows.cc index abfa3be5708..0024f807ed3 100644 --- a/src/core/lib/iomgr/tcp_server_windows.cc +++ b/src/core/lib/iomgr/tcp_server_windows.cc @@ -409,7 +409,7 @@ static grpc_error* add_socket_to_server(grpc_tcp_server* s, SOCKET sock, gpr_log(GPR_ERROR, "on_connect error: %s", utf8_message); gpr_free(utf8_message); closesocket(sock); - return NULL; + return GRPC_ERROR_NONE; } error = prepare_socket(sock, addr, &port); From c01477360f148b67d7858b10ecb655aee2a24a31 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 3 Jul 2019 16:24:30 -0700 Subject: [PATCH 0860/1555] Add v1.22.0 to interop_matrix --- tools/interop_matrix/client_matrix.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index d6d0612b4e4..3f136b69bc2 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -98,6 +98,7 @@ LANG_RELEASE_MATRIX = { ('v1.19.0', ReleaseInfo(testcases_file='cxx__v1.0.1')), ('v1.20.0', ReleaseInfo()), ('v1.21.4', ReleaseInfo()), + ('v1.22.0', ReleaseInfo()), ]), 'go': OrderedDict( @@ -211,6 +212,7 @@ LANG_RELEASE_MATRIX = { ('v1.19.0', ReleaseInfo()), ('v1.20.0', ReleaseInfo()), ('v1.21.4', ReleaseInfo()), + ('v1.22.0', ReleaseInfo()), ]), 'node': OrderedDict([ @@ -260,6 +262,7 @@ LANG_RELEASE_MATRIX = { ('v1.19.0', ReleaseInfo()), ('v1.20.0', ReleaseInfo()), ('v1.21.4', ReleaseInfo()), + ('v1.22.0', ReleaseInfo()), # TODO: https://github.com/grpc/grpc/issues/18262. # If you are not encountering the error in above issue # go ahead and upload the docker image for new releases. @@ -287,6 +290,7 @@ LANG_RELEASE_MATRIX = { # v1.19 and v1.20 were deliberately omitted here because of an issue. # See https://github.com/grpc/grpc/issues/18264 ('v1.21.4', ReleaseInfo()), + ('v1.22.0', ReleaseInfo()), ]), 'csharp': OrderedDict([ @@ -317,5 +321,6 @@ LANG_RELEASE_MATRIX = { ('v1.19.0', ReleaseInfo(testcases_file='csharp__v1.18.0')), ('v1.20.0', ReleaseInfo()), ('v1.21.4', ReleaseInfo()), + ('v1.22.0', ReleaseInfo()), ]), } From bd5ed4fddd7e3aa9121a9eed92b820ef37e03b48 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Mon, 24 Jun 2019 16:37:08 -0700 Subject: [PATCH 0861/1555] Move compiler targets from /BUILD to /src/compiler/BUILD --- BUILD | 87 ------------- BUILD.gn | 1 + bazel/cc_grpc_library.bzl | 2 +- bazel/grpc_deps.bzl | 2 +- bazel/python_rules.bzl | 2 +- build.yaml | 1 + src/compiler/BUILD | 120 ++++++++++++++++++ src/compiler/config.h | 30 +---- src/compiler/config_protobuf.h | 52 ++++++++ .../generated/sources_and_headers.json | 2 + 10 files changed, 180 insertions(+), 119 deletions(-) create mode 100644 src/compiler/BUILD create mode 100644 src/compiler/config_protobuf.h diff --git a/BUILD b/BUILD index 95d8f753e39..b5d7761a9a1 100644 --- a/BUILD +++ b/BUILD @@ -30,7 +30,6 @@ load( "//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_generate_one_off_targets", - "grpc_proto_plugin", ) config_setting( @@ -429,92 +428,6 @@ grpc_cc_library( ], ) -grpc_cc_library( - name = "grpc_plugin_support", - srcs = [ - "src/compiler/cpp_generator.cc", - "src/compiler/csharp_generator.cc", - "src/compiler/node_generator.cc", - "src/compiler/objective_c_generator.cc", - "src/compiler/php_generator.cc", - "src/compiler/python_generator.cc", - "src/compiler/ruby_generator.cc", - ], - hdrs = [ - "src/compiler/config.h", - "src/compiler/cpp_generator.h", - "src/compiler/cpp_generator_helpers.h", - "src/compiler/cpp_plugin.h", - "src/compiler/csharp_generator.h", - "src/compiler/csharp_generator_helpers.h", - "src/compiler/generator_helpers.h", - "src/compiler/node_generator.h", - "src/compiler/node_generator_helpers.h", - "src/compiler/objective_c_generator.h", - "src/compiler/objective_c_generator_helpers.h", - "src/compiler/php_generator.h", - "src/compiler/php_generator_helpers.h", - "src/compiler/protobuf_plugin.h", - "src/compiler/python_generator.h", - "src/compiler/python_generator_helpers.h", - "src/compiler/python_private_generator.h", - "src/compiler/ruby_generator.h", - "src/compiler/ruby_generator_helpers-inl.h", - "src/compiler/ruby_generator_map-inl.h", - "src/compiler/ruby_generator_string-inl.h", - "src/compiler/schema_interface.h", - ], - external_deps = [ - "protobuf_clib", - ], - language = "c++", - deps = [ - "grpc++_config_proto", - ], -) - -grpc_proto_plugin( - name = "grpc_cpp_plugin", - srcs = ["src/compiler/cpp_plugin.cc"], - deps = [":grpc_plugin_support"], -) - -grpc_proto_plugin( - name = "grpc_csharp_plugin", - srcs = ["src/compiler/csharp_plugin.cc"], - deps = [":grpc_plugin_support"], -) - -grpc_proto_plugin( - name = "grpc_node_plugin", - srcs = ["src/compiler/node_plugin.cc"], - deps = [":grpc_plugin_support"], -) - -grpc_proto_plugin( - name = "grpc_objective_c_plugin", - srcs = ["src/compiler/objective_c_plugin.cc"], - deps = [":grpc_plugin_support"], -) - -grpc_proto_plugin( - name = "grpc_php_plugin", - srcs = ["src/compiler/php_plugin.cc"], - deps = [":grpc_plugin_support"], -) - -grpc_proto_plugin( - name = "grpc_python_plugin", - srcs = ["src/compiler/python_plugin.cc"], - deps = [":grpc_plugin_support"], -) - -grpc_proto_plugin( - name = "grpc_ruby_plugin", - srcs = ["src/compiler/ruby_plugin.cc"], - deps = [":grpc_plugin_support"], -) - grpc_cc_library( name = "grpc_csharp_ext", srcs = [ diff --git a/BUILD.gn b/BUILD.gn index 0868b2dae5a..177f4082adf 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1413,6 +1413,7 @@ config("grpc_config") { "include/grpc++/impl/codegen/config_protobuf.h", "include/grpcpp/impl/codegen/config_protobuf.h", "src/compiler/config.h", + "src/compiler/config_protobuf.h", "src/compiler/cpp_generator.cc", "src/compiler/cpp_generator.h", "src/compiler/cpp_generator_helpers.h", diff --git a/bazel/cc_grpc_library.bzl b/bazel/cc_grpc_library.bzl index 572af756176..dea493eaf20 100644 --- a/bazel/cc_grpc_library.bzl +++ b/bazel/cc_grpc_library.bzl @@ -88,7 +88,7 @@ def cc_grpc_library( generate_cc( name = codegen_grpc_target, srcs = proto_targets, - plugin = "@com_github_grpc_grpc//:grpc_cpp_plugin", + plugin = "@com_github_grpc_grpc//src/compiler:grpc_cpp_plugin", well_known_protos = well_known_protos, generate_mocks = generate_mocks, **kwargs diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index be58c52b2b9..49def4f82c1 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -78,7 +78,7 @@ def grpc_deps(): native.bind( name = "grpc_cpp_plugin", - actual = "@com_github_grpc_grpc//:grpc_cpp_plugin", + actual = "@com_github_grpc_grpc//src/compiler:grpc_cpp_plugin", ) native.bind( diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index d4ff77094cc..14550852a4a 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -163,7 +163,7 @@ def py_proto_library( _generate_py( name = codegen_grpc_target, deps = deps, - plugin = "//:grpc_python_plugin", + plugin = "//src/compiler:grpc_python_plugin", well_known_protos = well_known_protos, **kwargs ) diff --git a/build.yaml b/build.yaml index 4134ecd8880..5915b9ccd64 100644 --- a/build.yaml +++ b/build.yaml @@ -1969,6 +1969,7 @@ libs: language: c++ headers: - src/compiler/config.h + - src/compiler/config_protobuf.h - src/compiler/cpp_generator.h - src/compiler/cpp_generator_helpers.h - src/compiler/csharp_generator.h diff --git a/src/compiler/BUILD b/src/compiler/BUILD new file mode 100644 index 00000000000..9a38f942939 --- /dev/null +++ b/src/compiler/BUILD @@ -0,0 +1,120 @@ +# gRPC Bazel BUILD file. +# +# Copyright 2016 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +licenses(["notice"]) # Apache v2 + +exports_files(["LICENSE"]) + +package( + default_visibility = ["//visibility:public"], + features = [ + "-layering_check", + "-parse_headers", + ], +) + +load( + "//bazel:grpc_build_system.bzl", + "grpc_cc_library", + "grpc_proto_plugin", +) + +grpc_cc_library( + name = "grpc_plugin_support", + srcs = [ + "cpp_generator.cc", + "csharp_generator.cc", + "node_generator.cc", + "objective_c_generator.cc", + "php_generator.cc", + "python_generator.cc", + "ruby_generator.cc", + ], + hdrs = [ + "config_protobuf.h", + "config.h", + "cpp_generator.h", + "cpp_generator_helpers.h", + "cpp_plugin.h", + "csharp_generator.h", + "csharp_generator_helpers.h", + "generator_helpers.h", + "node_generator.h", + "node_generator_helpers.h", + "objective_c_generator.h", + "objective_c_generator_helpers.h", + "php_generator.h", + "php_generator_helpers.h", + "protobuf_plugin.h", + "python_generator.h", + "python_generator_helpers.h", + "python_private_generator.h", + "ruby_generator.h", + "ruby_generator_helpers-inl.h", + "ruby_generator_map-inl.h", + "ruby_generator_string-inl.h", + "schema_interface.h", + ], + external_deps = [ + "protobuf_clib", + ], + language = "c++", + deps = [ + "//:grpc++_config_proto", + ], +) + +grpc_proto_plugin( + name = "grpc_cpp_plugin", + srcs = ["cpp_plugin.cc"], + deps = [":grpc_plugin_support"], +) + +grpc_proto_plugin( + name = "grpc_csharp_plugin", + srcs = ["csharp_plugin.cc"], + deps = [":grpc_plugin_support"], +) + +grpc_proto_plugin( + name = "grpc_node_plugin", + srcs = ["node_plugin.cc"], + deps = [":grpc_plugin_support"], +) + +grpc_proto_plugin( + name = "grpc_objective_c_plugin", + srcs = ["objective_c_plugin.cc"], + deps = [":grpc_plugin_support"], +) + +grpc_proto_plugin( + name = "grpc_php_plugin", + srcs = ["php_plugin.cc"], + deps = [":grpc_plugin_support"], +) + +grpc_proto_plugin( + name = "grpc_python_plugin", + srcs = ["python_plugin.cc"], + deps = [":grpc_plugin_support"], +) + +grpc_proto_plugin( + name = "grpc_ruby_plugin", + srcs = ["ruby_plugin.cc"], + deps = [":grpc_plugin_support"], +) diff --git a/src/compiler/config.h b/src/compiler/config.h index cfdc3036247..60772f2be68 100644 --- a/src/compiler/config.h +++ b/src/compiler/config.h @@ -19,35 +19,7 @@ #ifndef SRC_COMPILER_CONFIG_H #define SRC_COMPILER_CONFIG_H -#include - -#ifndef GRPC_CUSTOM_CODEGENERATOR -#include -#define GRPC_CUSTOM_CODEGENERATOR ::google::protobuf::compiler::CodeGenerator -#define GRPC_CUSTOM_GENERATORCONTEXT \ - ::google::protobuf::compiler::GeneratorContext -#endif - -#ifndef GRPC_CUSTOM_PRINTER -#include -#include -#include -#define GRPC_CUSTOM_PRINTER ::google::protobuf::io::Printer -#define GRPC_CUSTOM_CODEDOUTPUTSTREAM ::google::protobuf::io::CodedOutputStream -#define GRPC_CUSTOM_STRINGOUTPUTSTREAM \ - ::google::protobuf::io::StringOutputStream -#endif - -#ifndef GRPC_CUSTOM_PLUGINMAIN -#include -#define GRPC_CUSTOM_PLUGINMAIN ::google::protobuf::compiler::PluginMain -#endif - -#ifndef GRPC_CUSTOM_PARSEGENERATORPARAMETER -#include -#define GRPC_CUSTOM_PARSEGENERATORPARAMETER \ - ::google::protobuf::compiler::ParseGeneratorParameter -#endif +#include "src/compiler/config_protobuf.h" #ifndef GRPC_CUSTOM_STRING #include diff --git a/src/compiler/config_protobuf.h b/src/compiler/config_protobuf.h new file mode 100644 index 00000000000..06d5073f433 --- /dev/null +++ b/src/compiler/config_protobuf.h @@ -0,0 +1,52 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef SRC_COMPILER_CONFIG_PROTOBUF_H +#define SRC_COMPILER_CONFIG_PROTOBUF_H + +#include + +#ifndef GRPC_CUSTOM_CODEGENERATOR +#include +#define GRPC_CUSTOM_CODEGENERATOR ::google::protobuf::compiler::CodeGenerator +#define GRPC_CUSTOM_GENERATORCONTEXT \ + ::google::protobuf::compiler::GeneratorContext +#endif + +#ifndef GRPC_CUSTOM_PRINTER +#include +#include +#include +#define GRPC_CUSTOM_PRINTER ::google::protobuf::io::Printer +#define GRPC_CUSTOM_CODEDOUTPUTSTREAM ::google::protobuf::io::CodedOutputStream +#define GRPC_CUSTOM_STRINGOUTPUTSTREAM \ + ::google::protobuf::io::StringOutputStream +#endif + +#ifndef GRPC_CUSTOM_PLUGINMAIN +#include +#define GRPC_CUSTOM_PLUGINMAIN ::google::protobuf::compiler::PluginMain +#endif + +#ifndef GRPC_CUSTOM_PARSEGENERATORPARAMETER +#include +#define GRPC_CUSTOM_PARSEGENERATORPARAMETER \ + ::google::protobuf::compiler::ParseGeneratorParameter +#endif + +#endif // SRC_COMPILER_CONFIG_PROTOBUF_H diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 0f560fd1063..7a1baae36cd 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7184,6 +7184,7 @@ ], "headers": [ "src/compiler/config.h", + "src/compiler/config_protobuf.h", "src/compiler/cpp_generator.h", "src/compiler/cpp_generator_helpers.h", "src/compiler/csharp_generator.h", @@ -7210,6 +7211,7 @@ "name": "grpc_plugin_support", "src": [ "src/compiler/config.h", + "src/compiler/config_protobuf.h", "src/compiler/cpp_generator.cc", "src/compiler/cpp_generator.h", "src/compiler/cpp_generator_helpers.h", From 5779dd935a22c699a1c33be35b32bee2053a3aba Mon Sep 17 00:00:00 2001 From: yang-g Date: Wed, 10 Jul 2019 13:52:31 -0700 Subject: [PATCH 0862/1555] Qualify the error code with StatusCode:: --- src/cpp/client/secure_credentials.cc | 21 ++++++++++++--------- test/cpp/client/credentials_test.cc | 10 +++++----- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index 5de5a76194e..ebff8af3e5a 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include @@ -139,7 +139,8 @@ grpc::Status StsCredentialsOptionsFromJson(const grpc::string& json_string, void operator()(grpc_json* json) { grpc_json_destroy(json); } }; if (options == nullptr) { - return grpc::Status(grpc::INVALID_ARGUMENT, "options cannot be nullptr."); + return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, + "options cannot be nullptr."); } ClearStsCredentialsOptions(options); std::vector scratchpad(json_string.c_str(), @@ -147,7 +148,7 @@ grpc::Status StsCredentialsOptionsFromJson(const grpc::string& json_string, std::unique_ptr json( grpc_json_parse_string(&scratchpad[0])); if (json == nullptr) { - return grpc::Status(grpc::INVALID_ARGUMENT, "Invalid json."); + return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid json."); } // Required fields. @@ -155,7 +156,7 @@ grpc::Status StsCredentialsOptionsFromJson(const grpc::string& json_string, json.get(), "token_exchange_service_uri", nullptr); if (value == nullptr) { ClearStsCredentialsOptions(options); - return grpc::Status(grpc::INVALID_ARGUMENT, + return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "token_exchange_service_uri must be specified."); } options->token_exchange_service_uri.assign(value); @@ -163,7 +164,7 @@ grpc::Status StsCredentialsOptionsFromJson(const grpc::string& json_string, grpc_json_get_string_property(json.get(), "subject_token_path", nullptr); if (value == nullptr) { ClearStsCredentialsOptions(options); - return grpc::Status(grpc::INVALID_ARGUMENT, + return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "subject_token_path must be specified."); } options->subject_token_path.assign(value); @@ -171,7 +172,7 @@ grpc::Status StsCredentialsOptionsFromJson(const grpc::string& json_string, grpc_json_get_string_property(json.get(), "subject_token_type", nullptr); if (value == nullptr) { ClearStsCredentialsOptions(options); - return grpc::Status(grpc::INVALID_ARGUMENT, + return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "subject_token_type must be specified."); } options->subject_token_type.assign(value); @@ -199,7 +200,8 @@ grpc::Status StsCredentialsOptionsFromJson(const grpc::string& json_string, // Builds STS credentials Options from the $STS_CREDENTIALS env var. grpc::Status StsCredentialsOptionsFromEnv(StsCredentialsOptions* options) { if (options == nullptr) { - return grpc::Status(grpc::INVALID_ARGUMENT, "options cannot be nullptr."); + return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, + "options cannot be nullptr."); } ClearStsCredentialsOptions(options); grpc_slice json_string = grpc_empty_slice(); @@ -214,13 +216,14 @@ grpc::Status StsCredentialsOptionsFromEnv(StsCredentialsOptions* options) { }; if (sts_creds_path == nullptr) { - status = grpc::Status(grpc::NOT_FOUND, + status = grpc::Status(grpc::StatusCode::NOT_FOUND, "STS_CREDENTIALS environment variable not set."); return cleanup(); } error = grpc_load_file(sts_creds_path, 1, &json_string); if (error != GRPC_ERROR_NONE) { - status = grpc::Status(grpc::NOT_FOUND, grpc_error_string(error)); + status = + grpc::Status(grpc::StatusCode::NOT_FOUND, grpc_error_string(error)); return cleanup(); } status = StsCredentialsOptionsFromJson( diff --git a/test/cpp/client/credentials_test.cc b/test/cpp/client/credentials_test.cc index d560fb6d8e8..ba004efe0d9 100644 --- a/test/cpp/client/credentials_test.cc +++ b/test/cpp/client/credentials_test.cc @@ -119,7 +119,7 @@ TEST_F(CredentialsTest, StsCredentialsOptionsJson) { I'm not a valid JSON. )"; EXPECT_EQ( - grpc::INVALID_ARGUMENT, + grpc::StatusCode::INVALID_ARGUMENT, grpc::experimental::StsCredentialsOptionsFromJson(invalid_json, &options) .error_code()); @@ -130,7 +130,7 @@ TEST_F(CredentialsTest, StsCredentialsOptionsJson) { })"; auto status = grpc::experimental::StsCredentialsOptionsFromJson( invalid_json_missing_subject_token_type, &options); - EXPECT_EQ(grpc::INVALID_ARGUMENT, status.error_code()); + EXPECT_EQ(grpc::StatusCode::INVALID_ARGUMENT, status.error_code()); EXPECT_THAT(status.error_message(), ::testing::HasSubstr("subject_token_type")); @@ -141,7 +141,7 @@ TEST_F(CredentialsTest, StsCredentialsOptionsJson) { })"; status = grpc::experimental::StsCredentialsOptionsFromJson( invalid_json_missing_subject_token_path, &options); - EXPECT_EQ(grpc::INVALID_ARGUMENT, status.error_code()); + EXPECT_EQ(grpc::StatusCode::INVALID_ARGUMENT, status.error_code()); EXPECT_THAT(status.error_message(), ::testing::HasSubstr("subject_token_path")); @@ -152,7 +152,7 @@ TEST_F(CredentialsTest, StsCredentialsOptionsJson) { })"; status = grpc::experimental::StsCredentialsOptionsFromJson( invalid_json_missing_token_exchange_uri, &options); - EXPECT_EQ(grpc::INVALID_ARGUMENT, status.error_code()); + EXPECT_EQ(grpc::StatusCode::INVALID_ARGUMENT, status.error_code()); EXPECT_THAT(status.error_message(), ::testing::HasSubstr("token_exchange_service_uri")); } @@ -162,7 +162,7 @@ TEST_F(CredentialsTest, StsCredentialsOptionsFromEnv) { gpr_unsetenv("STS_CREDENTIALS"); grpc::experimental::StsCredentialsOptions options; auto status = grpc::experimental::StsCredentialsOptionsFromEnv(&options); - EXPECT_EQ(grpc::NOT_FOUND, status.error_code()); + EXPECT_EQ(grpc::StatusCode::NOT_FOUND, status.error_code()); // Set env and check for success. const char valid_json[] = R"( From 4a9667721934f99c430e2e8f759d38992da635e8 Mon Sep 17 00:00:00 2001 From: Keith Moyer Date: Mon, 17 Jun 2019 17:38:59 -0700 Subject: [PATCH 0863/1555] Use struct-defined initialization when available The grpc_polling_entity and grpc_httpcli_response types have default member initializer values specified, to indicate what a cleared variable of those types should have as values. This file overrides that, however, by directly performing a memset to 0 over the structures. Instead, the initialization values defined by the type should be honored. Local types that include these types are also upgraded to specify default member initializer values to simplify clearing them. This fixes -Wclass-memaccess warnings in modern versions of GCC. --- test/core/util/port_server_client.cc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/core/util/port_server_client.cc b/test/core/util/port_server_client.cc index 9a4159944bf..8c48a5467c1 100644 --- a/test/core/util/port_server_client.cc +++ b/test/core/util/port_server_client.cc @@ -35,9 +35,9 @@ #include "src/core/lib/http/httpcli.h" typedef struct freereq { - gpr_mu* mu; - grpc_polling_entity pops; - int done; + gpr_mu* mu = nullptr; + grpc_polling_entity pops = {}; + int done = 0; } freereq; static void destroy_pops_and_shutdown(void* p, grpc_error* error) { @@ -68,9 +68,9 @@ void grpc_free_port_using_server(int port) { grpc_init(); - memset(&pr, 0, sizeof(pr)); + pr = {}; memset(&req, 0, sizeof(req)); - memset(&rsp, 0, sizeof(rsp)); + rsp = {}; grpc_pollset* pollset = static_cast(gpr_zalloc(grpc_pollset_size())); @@ -117,13 +117,13 @@ void grpc_free_port_using_server(int port) { } typedef struct portreq { - gpr_mu* mu; - grpc_polling_entity pops; - int port; - int retries; - char* server; - grpc_httpcli_context* ctx; - grpc_httpcli_response response; + gpr_mu* mu = nullptr; + grpc_polling_entity pops = {}; + int port = 0; + int retries = 0; + char* server = nullptr; + grpc_httpcli_context* ctx = nullptr; + grpc_httpcli_response response = {}; } portreq; static void got_port_from_server(void* arg, grpc_error* error) { @@ -167,7 +167,7 @@ static void got_port_from_server(void* arg, grpc_error* error) { req.host = pr->server; req.http.path = const_cast("/get"); grpc_http_response_destroy(&pr->response); - memset(&pr->response, 0, sizeof(pr->response)); + pr->response = {}; grpc_resource_quota* resource_quota = grpc_resource_quota_create("port_server_client/pick_retry"); grpc_httpcli_get(pr->ctx, &pr->pops, resource_quota, &req, @@ -202,7 +202,7 @@ int grpc_pick_port_using_server(void) { grpc_init(); { grpc_core::ExecCtx exec_ctx; - memset(&pr, 0, sizeof(pr)); + pr = {}; memset(&req, 0, sizeof(req)); grpc_pollset* pollset = static_cast(gpr_zalloc(grpc_pollset_size())); From a2eb267ccb7440212e21cbbd405e712fe9db78ea Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Wed, 10 Jul 2019 14:29:55 -0700 Subject: [PATCH 0864/1555] Clarify std:: usage --- doc/core/moving-to-c++.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/core/moving-to-c++.md b/doc/core/moving-to-c++.md index 4c745b38a90..717e2267b33 100644 --- a/doc/core/moving-to-c++.md +++ b/doc/core/moving-to-c++.md @@ -21,9 +21,13 @@ C++ compatible with ## Constraints -- No use of standard library +- No use of standard library if it requires link-time dependency - Standard library makes wrapping difficult/impossible and also reduces platform portability - This takes precedence over using C++ style guide +- Limited use of standard library if it does not require link-time dependency + - We can use things from `std::` as long as they are header-only implementations. + - Since the standard library API does not specify whether any given part of the API is implemented header-only, the only way to know is to try using something and see if our tests fail. + - Since there is no guarantee that some header-only implementation in the standard library will remain header-only in the future, we should define our own API in lib/gprpp that is an alias for the thing we want to use in `std::` and use the gprpp API in core. That way, if we later need to stop using the thing from `std::`, we can replace the alias with our own implementation. - But lambdas are ok - As are third-party libraries that meet our build requirements (such as many parts of abseil) - There will be some C++ features that don't work From 7e3a9b6b236174000e673771cfbae22a42d05621 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 10 Jul 2019 14:54:44 -0700 Subject: [PATCH 0865/1555] Remove error arg - reviewer comment --- .../transport/chttp2/transport/chttp2_transport.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index b05a48a6a0c..6254369ef69 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -1232,10 +1232,10 @@ static grpc_closure* add_closure_barrier(grpc_closure* closure) { return closure; } -static void null_then_sched_closure(grpc_closure** closure, grpc_error* error) { +static void null_then_sched_closure(grpc_closure** closure) { grpc_closure* c = *closure; *closure = nullptr; - GRPC_CLOSURE_SCHED(c, error); + GRPC_CLOSURE_SCHED(c, GRPC_ERROR_NONE); } void grpc_chttp2_complete_closure_step(grpc_chttp2_transport* t, @@ -1902,7 +1902,7 @@ void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_chttp2_transport* t, } grpc_chttp2_incoming_metadata_buffer_publish(&s->metadata_buffer[0], s->recv_initial_metadata); - null_then_sched_closure(&s->recv_initial_metadata_ready, GRPC_ERROR_NONE); + null_then_sched_closure(&s->recv_initial_metadata_ready); } } @@ -1982,10 +1982,10 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_chttp2_transport* t, s->unprocessed_incoming_frames_buffer_cached_length = s->unprocessed_incoming_frames_buffer.length; if (error == GRPC_ERROR_NONE && *s->recv_message != nullptr) { - null_then_sched_closure(&s->recv_message_ready, GRPC_ERROR_NONE); + null_then_sched_closure(&s->recv_message_ready); } else if (s->published_metadata[1] != GRPC_METADATA_NOT_PUBLISHED) { *s->recv_message = nullptr; - null_then_sched_closure(&s->recv_message_ready, GRPC_ERROR_NONE); + null_then_sched_closure(&s->recv_message_ready); } GRPC_ERROR_UNREF(error); } @@ -2051,8 +2051,7 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_chttp2_transport* t, s->collecting_stats = nullptr; grpc_chttp2_incoming_metadata_buffer_publish(&s->metadata_buffer[1], s->recv_trailing_metadata); - null_then_sched_closure(&s->recv_trailing_metadata_finished, - GRPC_ERROR_NONE); + null_then_sched_closure(&s->recv_trailing_metadata_finished); } } } From 444806583d7aace199b3aa83051d08315239fa7e Mon Sep 17 00:00:00 2001 From: Qiancheng Zhao Date: Wed, 10 Jul 2019 15:26:53 -0700 Subject: [PATCH 0866/1555] lazy resolving lb policy creation --- .../filters/client_channel/client_channel.cc | 102 ++++++++++-------- .../resolver/fake/fake_resolver.cc | 1 - .../client_channel/resolving_lb_policy.cc | 59 ++-------- .../client_channel/resolving_lb_policy.h | 15 +-- test/cpp/end2end/grpclb_end2end_test.cc | 4 + 5 files changed, 74 insertions(+), 107 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 0b612e67a33..39ca3e5abb2 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -210,6 +210,10 @@ class ChannelData { ChannelData(grpc_channel_element_args* args, grpc_error** error); ~ChannelData(); + void CreateResolvingLoadBalancingPolicyLocked(); + + void DestroyResolvingLoadBalancingPolicyLocked(); + static bool ProcessResolverResultLocked( void* arg, const Resolver::Result& result, const char** lb_policy_name, RefCountedPtr* lb_policy_config, @@ -235,8 +239,10 @@ class ChannelData { const size_t per_rpc_retry_buffer_size_; grpc_channel_stack* owning_stack_; ClientChannelFactory* client_channel_factory_; - UniquePtr server_name_; + const grpc_channel_args* channel_args_; RefCountedPtr default_service_config_; + UniquePtr server_name_; + UniquePtr target_uri_; channelz::ChannelNode* channelz_node_; // @@ -1226,51 +1232,25 @@ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error) grpc_channel_args* new_args = nullptr; grpc_proxy_mappers_map_name(server_uri, args->channel_args, &proxy_name, &new_args); - UniquePtr target_uri(proxy_name != nullptr ? proxy_name - : gpr_strdup(server_uri)); - // Instantiate resolving LB policy. - LoadBalancingPolicy::Args lb_args; - lb_args.combiner = combiner_; - lb_args.channel_control_helper = - UniquePtr( - New(this)); - lb_args.args = new_args != nullptr ? new_args : args->channel_args; - resolving_lb_policy_.reset(New( - std::move(lb_args), &grpc_client_channel_routing_trace, - std::move(target_uri), ProcessResolverResultLocked, this, error)); - grpc_channel_args_destroy(new_args); - if (*error != GRPC_ERROR_NONE) { - // Orphan the resolving LB policy and flush the exec_ctx to ensure - // that it finishes shutting down. This ensures that if we are - // failing, we destroy the ClientChannelControlHelper (and thus - // unref the channel stack) before we return. - // TODO(roth): This is not a complete solution, because it only - // catches the case where channel stack initialization fails in this - // particular filter. If there is a failure in a different filter, we - // will leave a dangling ref here, which can cause a crash. Fortunately, - // in practice, there are no other filters that can cause failures in - // channel stack initialization, so this works for now. - resolving_lb_policy_.reset(); - ExecCtx::Get()->Flush(); - } else { - grpc_pollset_set_add_pollset_set(resolving_lb_policy_->interested_parties(), - interested_parties_); - if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { - gpr_log(GPR_INFO, "chand=%p: created resolving_lb_policy=%p", this, - resolving_lb_policy_.get()); - } + target_uri_.reset(proxy_name != nullptr ? proxy_name + : gpr_strdup(server_uri)); + channel_args_ = new_args != nullptr + ? new_args + : grpc_channel_args_copy(args->channel_args); + if (!ResolverRegistry::IsValidTarget(target_uri_.get())) { + *error = + GRPC_ERROR_CREATE_FROM_STATIC_STRING("the target uri is not valid."); + return; } + *error = GRPC_ERROR_NONE; } ChannelData::~ChannelData() { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { gpr_log(GPR_INFO, "chand=%p: destroying channel", this); } - if (resolving_lb_policy_ != nullptr) { - grpc_pollset_set_del_pollset_set(resolving_lb_policy_->interested_parties(), - interested_parties_); - resolving_lb_policy_.reset(); - } + DestroyResolvingLoadBalancingPolicyLocked(); + grpc_channel_args_destroy(channel_args_); // Stop backup polling. grpc_client_channel_stop_backup_polling(interested_parties_); grpc_pollset_set_destroy(interested_parties_); @@ -1281,6 +1261,34 @@ ChannelData::~ChannelData() { gpr_mu_destroy(&info_mu_); } +void ChannelData::CreateResolvingLoadBalancingPolicyLocked() { + // Instantiate resolving LB policy. + LoadBalancingPolicy::Args lb_args; + lb_args.combiner = combiner_; + lb_args.channel_control_helper = + UniquePtr( + New(this)); + lb_args.args = channel_args_; + UniquePtr target_uri(strdup(target_uri_.get())); + resolving_lb_policy_.reset(New( + std::move(lb_args), &grpc_client_channel_routing_trace, + std::move(target_uri), ProcessResolverResultLocked, this)); + grpc_pollset_set_add_pollset_set(resolving_lb_policy_->interested_parties(), + interested_parties_); + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { + gpr_log(GPR_INFO, "chand=%p: created resolving_lb_policy=%p", this, + resolving_lb_policy_.get()); + } +} + +void ChannelData::DestroyResolvingLoadBalancingPolicyLocked() { + if (resolving_lb_policy_ != nullptr) { + grpc_pollset_set_del_pollset_set(resolving_lb_policy_->interested_parties(), + interested_parties_); + resolving_lb_policy_.reset(); + } +} + void ChannelData::ProcessLbPolicy( const Resolver::Result& resolver_result, const internal::ClientChannelGlobalParsedConfig* parsed_service_config, @@ -1500,10 +1508,7 @@ void ChannelData::StartTransportOpLocked(void* arg, grpc_error* ignored) { GPR_ASSERT(chand->disconnect_error_.CompareExchangeStrong( &error, op->disconnect_with_error, MemoryOrder::ACQ_REL, MemoryOrder::ACQUIRE)); - grpc_pollset_set_del_pollset_set( - chand->resolving_lb_policy_->interested_parties(), - chand->interested_parties_); - chand->resolving_lb_policy_.reset(); + chand->DestroyResolvingLoadBalancingPolicyLocked(); // Will delete itself. New( chand, GRPC_CHANNEL_SHUTDOWN, "shutdown from API", @@ -1574,6 +1579,8 @@ void ChannelData::TryToConnectLocked(void* arg, grpc_error* error_ignored) { auto* chand = static_cast(arg); if (chand->resolving_lb_policy_ != nullptr) { chand->resolving_lb_policy_->ExitIdleLocked(); + } else { + chand->CreateResolvingLoadBalancingPolicyLocked(); } GRPC_CHANNEL_STACK_UNREF(chand->owning_stack_, "TryToConnect"); } @@ -3463,6 +3470,15 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { ChannelData* chand = static_cast(elem->channel_data); GPR_ASSERT(calld->connected_subchannel_ == nullptr); GPR_ASSERT(calld->subchannel_call_ == nullptr); + // picker's being null means the channel is currently in IDLE state. The + // incoming call will make the channel exit IDLE and queue itself. + if (chand->picker() == nullptr) { + // We are currently in the data plane. + // Bounce into the control plane to exit IDLE. + chand->CheckConnectivityState(true); + calld->AddCallToQueuedPicksLocked(elem); + return; + } // Apply service config to call if needed. calld->MaybeApplyServiceConfigToCallLocked(elem); // If this is a retry, use the send_initial_metadata payload that diff --git a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc index c5a27f127b8..761b27292da 100644 --- a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc @@ -196,7 +196,6 @@ void FakeResolverResponseGenerator::SetResponse(Resolver::Result result) { grpc_combiner_scheduler(resolver_->combiner())), GRPC_ERROR_NONE); } else { - GPR_ASSERT(!has_result_); has_result_ = true; result_ = std::move(result); } diff --git a/src/core/ext/filters/client_channel/resolving_lb_policy.cc b/src/core/ext/filters/client_channel/resolving_lb_policy.cc index 180b0fcbbf4..4b61df09959 100644 --- a/src/core/ext/filters/client_channel/resolving_lb_policy.cc +++ b/src/core/ext/filters/client_channel/resolving_lb_policy.cc @@ -181,52 +181,29 @@ class ResolvingLoadBalancingPolicy::ResolvingControlHelper // ResolvingLoadBalancingPolicy // -ResolvingLoadBalancingPolicy::ResolvingLoadBalancingPolicy( - Args args, TraceFlag* tracer, UniquePtr target_uri, - UniquePtr child_policy_name, - RefCountedPtr child_lb_config, - grpc_error** error) - : LoadBalancingPolicy(std::move(args)), - tracer_(tracer), - target_uri_(std::move(target_uri)), - child_policy_name_(std::move(child_policy_name)), - child_lb_config_(std::move(child_lb_config)) { - GPR_ASSERT(child_policy_name_ != nullptr); - // Don't fetch service config, since this ctor is for use in nested LB - // policies, not at the top level, and we only fetch the service - // config at the top level. - grpc_arg arg = grpc_channel_arg_integer_create( - const_cast(GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION), 0); - grpc_channel_args* new_args = - grpc_channel_args_copy_and_add(args.args, &arg, 1); - *error = Init(*new_args); - grpc_channel_args_destroy(new_args); -} - ResolvingLoadBalancingPolicy::ResolvingLoadBalancingPolicy( Args args, TraceFlag* tracer, UniquePtr target_uri, ProcessResolverResultCallback process_resolver_result, - void* process_resolver_result_user_data, grpc_error** error) + void* process_resolver_result_user_data) : LoadBalancingPolicy(std::move(args)), tracer_(tracer), target_uri_(std::move(target_uri)), process_resolver_result_(process_resolver_result), process_resolver_result_user_data_(process_resolver_result_user_data) { GPR_ASSERT(process_resolver_result != nullptr); - *error = Init(*args.args); -} - -grpc_error* ResolvingLoadBalancingPolicy::Init(const grpc_channel_args& args) { resolver_ = ResolverRegistry::CreateResolver( - target_uri_.get(), &args, interested_parties(), combiner(), + target_uri_.get(), args.args, interested_parties(), combiner(), UniquePtr(New(Ref()))); - if (resolver_ == nullptr) { - return GRPC_ERROR_CREATE_FROM_STATIC_STRING("resolver creation failed"); + // Since the validity of args has been checked when create the channel, + // CreateResolver() must return a non-null result. + GPR_ASSERT(resolver_ != nullptr); + if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) { + gpr_log(GPR_INFO, "resolving_lb=%p: starting name resolution", this); } - // Return our picker to the channel. channel_control_helper()->UpdateState( - GRPC_CHANNEL_IDLE, UniquePtr(New(Ref()))); - return GRPC_ERROR_NONE; + GRPC_CHANNEL_CONNECTING, + UniquePtr(New(Ref()))); + resolver_->StartLocked(); } ResolvingLoadBalancingPolicy::~ResolvingLoadBalancingPolicy() { @@ -262,10 +239,6 @@ void ResolvingLoadBalancingPolicy::ExitIdleLocked() { if (lb_policy_ != nullptr) { lb_policy_->ExitIdleLocked(); if (pending_lb_policy_ != nullptr) pending_lb_policy_->ExitIdleLocked(); - } else { - if (!started_resolving_ && resolver_ != nullptr) { - StartResolvingLocked(); - } } } @@ -278,18 +251,6 @@ void ResolvingLoadBalancingPolicy::ResetBackoffLocked() { if (pending_lb_policy_ != nullptr) pending_lb_policy_->ResetBackoffLocked(); } -void ResolvingLoadBalancingPolicy::StartResolvingLocked() { - if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) { - gpr_log(GPR_INFO, "resolving_lb=%p: starting name resolution", this); - } - GPR_ASSERT(!started_resolving_); - started_resolving_ = true; - channel_control_helper()->UpdateState( - GRPC_CHANNEL_CONNECTING, - UniquePtr(New(Ref()))); - resolver_->StartLocked(); -} - void ResolvingLoadBalancingPolicy::OnResolverError(grpc_error* error) { if (resolver_ == nullptr) { GRPC_ERROR_UNREF(error); diff --git a/src/core/ext/filters/client_channel/resolving_lb_policy.h b/src/core/ext/filters/client_channel/resolving_lb_policy.h index e91ea832661..d8447c18cf5 100644 --- a/src/core/ext/filters/client_channel/resolving_lb_policy.h +++ b/src/core/ext/filters/client_channel/resolving_lb_policy.h @@ -51,16 +51,6 @@ namespace grpc_core { // child LB policy and config to use. class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy { public: - // If error is set when this returns, then construction failed, and - // the caller may not use the new object. - ResolvingLoadBalancingPolicy( - Args args, TraceFlag* tracer, UniquePtr target_uri, - UniquePtr child_policy_name, - RefCountedPtr child_lb_config, - grpc_error** error); - - // Private ctor, to be used by client_channel only! - // // Synchronous callback that takes the resolver result and sets // lb_policy_name and lb_policy_config to point to the right data. // Returns true if the service config has changed since the last result. @@ -77,7 +67,7 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy { ResolvingLoadBalancingPolicy( Args args, TraceFlag* tracer, UniquePtr target_uri, ProcessResolverResultCallback process_resolver_result, - void* process_resolver_result_user_data, grpc_error** error); + void* process_resolver_result_user_data); virtual const char* name() const override { return "resolving_lb"; } @@ -98,10 +88,8 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy { ~ResolvingLoadBalancingPolicy(); - grpc_error* Init(const grpc_channel_args& args); void ShutdownLocked() override; - void StartResolvingLocked(); void OnResolverError(grpc_error* error); void CreateOrUpdateLbPolicyLocked( const char* lb_policy_name, @@ -126,7 +114,6 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy { // Resolver and associated state. OrphanablePtr resolver_; - bool started_resolving_ = false; bool previous_resolution_contained_addresses_ = false; // Child LB policy. diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc index e3b79c810cd..d71dafc855f 100644 --- a/test/cpp/end2end/grpclb_end2end_test.cc +++ b/test/cpp/end2end/grpclb_end2end_test.cc @@ -1618,6 +1618,8 @@ TEST_F(UpdatesTest, ReresolveDeadBackend) { addresses.emplace_back(AddressData{balancers_[0]->port_, true, ""}); addresses.emplace_back(AddressData{backends_[0]->port_, false, ""}); SetNextResolution(addresses); + // Ask channel to connect to trigger resolver creation. + channel_->GetState(true); // The re-resolution result will contain the addresses of the same balancer // and a new fallback backend. addresses.clear(); @@ -1669,6 +1671,8 @@ class UpdatesWithClientLoadReportingTest : public GrpclbEnd2endTest { }; TEST_F(UpdatesWithClientLoadReportingTest, ReresolveDeadBalancer) { + // Ask channel to connect to trigger resolver creation. + channel_->GetState(true); std::vector addresses; addresses.emplace_back(AddressData{balancers_[0]->port_, true, ""}); SetNextResolution(addresses); From 39775cf30fe2b29693652184e01a480a8596a89c Mon Sep 17 00:00:00 2001 From: mgravell Date: Thu, 11 Jul 2019 13:07:50 +0100 Subject: [PATCH 0867/1555] remove delegate allocation and boxing from cancellation registrations --- src/csharp/Grpc.Core.Tests/CallCancellationTest.cs | 11 +++++++++++ src/csharp/Grpc.Core/Internal/AsyncCall.cs | 10 +++------- src/csharp/Grpc.Core/Internal/AsyncCallBase.cs | 8 ++++++++ src/csharp/Grpc.Core/Internal/ClientResponseStream.cs | 3 +-- src/csharp/Grpc.Core/Internal/ServerRequestStream.cs | 4 +--- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/CallCancellationTest.cs b/src/csharp/Grpc.Core.Tests/CallCancellationTest.cs index e040f52380a..753b8b227b1 100644 --- a/src/csharp/Grpc.Core.Tests/CallCancellationTest.cs +++ b/src/csharp/Grpc.Core.Tests/CallCancellationTest.cs @@ -178,5 +178,16 @@ namespace Grpc.Core.Tests Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode); } } + + [Test] + public void CanDisposeDefaultCancellationRegistration() + { + // prove that we're fine to dispose default CancellationTokenRegistration + // values without boxing them to IDisposable for a null-check + var obj = default(CancellationTokenRegistration); + obj.Dispose(); + + using (obj) {} + } } } diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs index a1c688140d1..ce3508d398e 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs @@ -38,7 +38,7 @@ namespace Grpc.Core.Internal bool registeredWithChannel; // Dispose of to de-register cancellation token registration - IDisposable cancellationTokenRegistration; + CancellationTokenRegistration cancellationTokenRegistration; // Completion of a pending unary response if not null. TaskCompletionSource unaryResponseTcs; @@ -409,7 +409,7 @@ namespace Grpc.Core.Internal // deadlock. // See https://github.com/grpc/grpc/issues/14777 // See https://github.com/dotnet/corefx/issues/14903 - cancellationTokenRegistration?.Dispose(); + cancellationTokenRegistration.Dispose(); } protected override bool IsClient @@ -509,11 +509,7 @@ namespace Grpc.Core.Internal // Make sure that once cancellationToken for this call is cancelled, Cancel() will be called. private void RegisterCancellationCallback() { - var token = details.Options.CancellationToken; - if (token.CanBeCanceled) - { - cancellationTokenRegistration = token.Register(() => this.Cancel()); - } + cancellationTokenRegistration = RegisterCancellationCallbackForToken(details.Options.CancellationToken); } /// diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs index 0b99aaf3e21..ac1f9066516 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs @@ -394,5 +394,13 @@ namespace Grpc.Core.Internal { HandleReadFinished(success, receivedMessageReader); } + + internal CancellationTokenRegistration RegisterCancellationCallbackForToken(CancellationToken cancellationToken) + { + if (cancellationToken.CanBeCanceled) return cancellationToken.Register(CancelCallFromToken, this); + return default(CancellationTokenRegistration); + } + + private static readonly Action CancelCallFromToken = state => ((AsyncCallBase)state).Cancel(); } } diff --git a/src/csharp/Grpc.Core/Internal/ClientResponseStream.cs b/src/csharp/Grpc.Core/Internal/ClientResponseStream.cs index ab649ee7662..ff73b26dff4 100644 --- a/src/csharp/Grpc.Core/Internal/ClientResponseStream.cs +++ b/src/csharp/Grpc.Core/Internal/ClientResponseStream.cs @@ -49,8 +49,7 @@ namespace Grpc.Core.Internal public async Task MoveNext(CancellationToken token) { - var cancellationTokenRegistration = token.CanBeCanceled ? token.Register(() => call.Cancel()) : (IDisposable) null; - using (cancellationTokenRegistration) + using (call.RegisterCancellationCallbackForToken(token)) { var result = await call.ReadMessageAsync().ConfigureAwait(false); this.current = result; diff --git a/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs b/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs index 058dddb7ebb..f3655139e47 100644 --- a/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs +++ b/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs @@ -49,9 +49,7 @@ namespace Grpc.Core.Internal public async Task MoveNext(CancellationToken token) { - - var cancellationTokenRegistration = token.CanBeCanceled ? token.Register(() => call.Cancel()) : (IDisposable) null; - using (cancellationTokenRegistration) + using (call.RegisterCancellationCallbackForToken(token)) { var result = await call.ReadMessageAsync().ConfigureAwait(false); this.current = result; From 8e4d14fe91053fb4202db948e62dc11bfad8d6e5 Mon Sep 17 00:00:00 2001 From: Wensheng Tang Date: Sun, 7 Jul 2019 02:47:20 +0800 Subject: [PATCH 0868/1555] Fix the assertion of grpc_udp_server_add_port grpc_udp_server_add_port() can return port = -1 when going fail. @nanahpang also recommands discarding port = 0 --- test/core/iomgr/udp_server_test.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/core/iomgr/udp_server_test.cc b/test/core/iomgr/udp_server_test.cc index f65783a0174..3c9e7108608 100644 --- a/test/core/iomgr/udp_server_test.cc +++ b/test/core/iomgr/udp_server_test.cc @@ -218,7 +218,7 @@ static void test_no_op_with_port(void) { addr->sin_family = AF_INET; GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, rcv_buf_size, snd_buf_size, &handler_factory, - g_num_listeners)); + g_num_listeners) > 0); grpc_udp_server_destroy(s, nullptr); @@ -250,7 +250,7 @@ static void test_no_op_with_port_and_socket_factory(void) { addr->sin_family = AF_INET; GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, rcv_buf_size, snd_buf_size, &handler_factory, - g_num_listeners)); + g_num_listeners) > 0); GPR_ASSERT(socket_factory->number_of_socket_calls == g_num_listeners); GPR_ASSERT(socket_factory->number_of_bind_calls == g_num_listeners); @@ -278,7 +278,7 @@ static void test_no_op_with_port_and_start(void) { addr->sin_family = AF_INET; GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, rcv_buf_size, snd_buf_size, &handler_factory, - g_num_listeners)); + g_num_listeners) > 0); grpc_udp_server_start(s, nullptr, 0, nullptr); GPR_ASSERT(g_number_of_starts == g_num_listeners); @@ -312,7 +312,7 @@ static void test_receive(int number_of_clients) { addr->ss_family = AF_INET; GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, rcv_buf_size, snd_buf_size, &handler_factory, - g_num_listeners)); + g_num_listeners) > 0); svrfd = grpc_udp_server_get_fd(s, 0); GPR_ASSERT(svrfd >= 0); From e8b9e95fa275361d1203217a97e01bbadcd211ee Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Thu, 11 Jul 2019 09:53:13 -0700 Subject: [PATCH 0869/1555] Use RefCountedPtr instead of raw pointer --- src/core/lib/channel/channelz.h | 2 +- src/core/lib/surface/server.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/channel/channelz.h b/src/core/lib/channel/channelz.h index f8acb531e8a..d26896262ec 100644 --- a/src/core/lib/channel/channelz.h +++ b/src/core/lib/channel/channelz.h @@ -64,7 +64,7 @@ intptr_t GetParentUuidFromArgs(const grpc_channel_args& args); typedef InlinedVector ChildRefsList; class SocketNode; -typedef InlinedVector ChildSocketsList; +typedef InlinedVector, 10> ChildSocketsList; namespace testing { class CallCountingHelperPeer; diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 8f6df482aa9..6cd86003f01 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -1248,7 +1248,7 @@ void grpc_server_populate_server_sockets( channel_data* c = nullptr; for (c = s->root_channel_data.next; c != &s->root_channel_data; c = c->next) { if (c->socket_node != nullptr && c->socket_node->uuid() >= start_idx) { - server_sockets->push_back(c->socket_node.get()); + server_sockets->push_back(c->socket_node); } } gpr_mu_unlock(&s->mu_global); From 54a3b642466faf6f71578c44615d31af861b92ef Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Wed, 10 Jul 2019 15:49:37 -0700 Subject: [PATCH 0870/1555] Pull() eats slice from sbuf wrapped byte buffer. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At present, a commonly used byte buffer wraps an underlying slice buffer. This is used by grpc_call; it passes a byte buffer for send stream ops through the filter stack and down to the transport. Pull() is a one-way operation; given a slice-buffer backed byte-buffer, it starts with a cursor at index=0 and increments it per pull. There is no way for a cursor to be rewinded. Originally Pull() would ref the slice and return a copy; the slice remains in the underlying buffer and is eventually cleaned up (unref'd). Thus, assuming a slice buffer of size N and assuming we pulled all N slices then we have a total of 2N ref/unref pairs. Since Pull() is essentially acting as a consume operation here, and since it is a one-way operation, we simply transfer the ref rather than create a new ref. This cuts down atomic ops. from 2N to N. This reduces streaming latency slightly for streaming fullstack microbenchmarks: BM_StreamingPingPong/0/1 [polls/iter:0 ] 8.87µs ± 1% 8.91µs ± 1% +0.45% (p=0.002 n=20+20) BM_StreamingPingPong/0/2 [polls/iter:0 ] 11.7µs ± 1% 11.7µs ± 1% +0.34% (p=0.002 n=19+19) BM_StreamingPingPong/8/1 [polls/iter:0 ] 9.11µs ± 1% 9.14µs ± 1% +0.29% (p=0.016 n=19+20) BM_StreamingPingPong/64/1 [polls/iter:0 ] 9.29µs ± 1% 9.27µs ± 1% -0.23% (p=0.029 n=18+19) BM_StreamingPingPong/512/2 [polls/iter:0 ] 13.0µs ± 1% 12.9µs ± 1% -0.52% (p=0.000 n=20+19) BM_StreamingPingPong/4096/1 [polls/iter:0 ] 11.8µs ± 1% 11.8µs ± 1% -0.41% (p=0.007 n=20+20) BM_StreamingPingPong/4096/2 [polls/iter:0 ] 17.4µs ± 1% 17.2µs ± 1% -0.73% (p=0.000 n=19+19) BM_StreamingPingPongMsgs/1 [polls/iter:0 ] 2.87µs ± 1% 2.84µs ± 1% -1.18% (p=0.000 n=19+18) BM_StreamingPingPongMsgs/8 [polls/iter:0 ] 2.85µs ± 1% 2.84µs ± 0% -0.38% (p=0.022 n=20+17) BM_StreamingPingPongMsgs/64 [polls/iter:0 ] 3.00µs ± 1% 2.95µs ± 1% -1.64% (p=0.000 n=19+19) BM_StreamingPingPongMsgs/512 [polls/iter:0 ] 3.32µs ± 1% 3.23µs ± 1% -2.62% (p=0.000 n=20+20) BM_StreamingPingPongMsgs/4096 [polls/iter:0 ] 5.38µs ± 2% 5.30µs ± 1% -1.42% (p=0.000 n=19+20) BM_StreamingPingPongMsgs/32768 [polls/iter:0 ] 24.1µs ± 1% 24.0µs ± 0% -0.47% (p=0.000 n=19+18) BM_StreamingPingPong/0/0 [polls/iter:0 ] 5.71µs ± 1% 5.69µs ± 1% -0.36% (p=0.010 n=19+19) BM_StreamingPingPong/0/1 [polls/iter:0 ] 8.64µs ± 1% 8.68µs ± 1% +0.38% (p=0.004 n=20+18) BM_StreamingPingPong/1/2 [polls/iter:0 ] 11.9µs ± 1% 11.8µs ± 1% -0.36% (p=0.003 n=20+18) BM_StreamingPingPong/64/1 [polls/iter:0 ] 9.09µs ± 1% 9.06µs ± 1% -0.32% (p=0.046 n=20+20) BM_StreamingPingPong/64/2 [polls/iter:0 ] 12.2µs ± 0% 12.1µs ± 1% -0.35% (p=0.001 n=19+20) BM_StreamingPingPong/512/2 [polls/iter:0 ] 12.8µs ± 1% 12.7µs ± 1% -0.46% (p=0.000 n=19+19) BM_StreamingPingPong/4096/1 [polls/iter:0 ] 11.7µs ± 2% 11.6µs ± 1% -0.58% (p=0.004 n=20+20) BM_StreamingPingPong/4096/2 [polls/iter:0 ] 17.1µs ± 1% 17.0µs ± 1% -0.55% (p=0.010 n=20+20) BM_StreamingPingPong/32768/1 [polls/iter:0 ] 30.5µs ± 1% 30.6µs ± 0% +0.27% (p=0.003 n=20+19) BM_StreamingPingPong/262144/2 [polls/iter:0 ] 363µs ± 1% 362µs ± 1% -0.22% (p=0.049 n=20+20) BM_StreamingPingPongMsgs/134217728 [polls/iter:4 writes/iter:8.5 ] 266ms ± 0% 263ms ± 1% -1.23% (p=0.029 n=4+4) BM_StreamingPingPongMsgs/64 [polls/iter:0 ] 2.95µs ± 1% 2.93µs ± 1% -0.97% (p=0.000 n=19+20) BM_StreamingPingPongMsgs/512 [polls/iter:0 ] 3.27µs ± 1% 3.19µs ± 1% -2.32% (p=0.000 n=20+20) BM_StreamingPingPongMsgs/4096 [polls/iter:0 ] 5.33µs ± 2% 5.26µs ± 1% -1.30% (p=0.000 n=20+20) BM_StreamingPingPongMsgs/32768 [polls/iter:0 ] 24.1µs ± 1% 24.0µs ± 0% -0.35% (p=0.001 n=19+20) BM_StreamingPingPongWithCoalescingApi/0/2/1 [polls/iter:0 ] 10.6µs ± 1% 10.6µs ± 1% +0.45% (p=0.014 n=20+20) BM_StreamingPingPongWithCoalescingApi/1/2/0 [polls/iter:0 ] 11.3µs ± 1% 11.3µs ± 1% -0.39% (p=0.046 n=20+20) BM_StreamingPingPongWithCoalescingApi/1/1/1 [polls/iter:0 ] 7.92µs ± 1% 7.88µs ± 1% -0.46% (p=0.012 n=19+18) BM_StreamingPingPongWithCoalescingApi/1/2/1 [polls/iter:0 ] 11.0µs ± 1% 10.9µs ± 1% -0.48% (p=0.001 n=18+20) BM_StreamingPingPongWithCoalescingApi/8/1/0 [polls/iter:0 ] 8.33µs ± 1% 8.30µs ± 1% -0.29% (p=0.025 n=19+19) BM_StreamingPingPongWithCoalescingApi/8/2/0 [polls/iter:0 ] 11.3µs ± 1% 11.3µs ± 1% -0.34% (p=0.011 n=19+19) BM_StreamingPingPongWithCoalescingApi/64/1/0 [polls/iter:0 ] 8.49µs ± 1% 8.41µs ± 1% -1.01% (p=0.000 n=20+20) BM_StreamingPingPongWithCoalescingApi/64/2/0 [polls/iter:0 ] 11.6µs ± 1% 11.5µs ± 1% -0.80% (p=0.000 n=19+19) BM_StreamingPingPongWithCoalescingApi/64/1/1 [polls/iter:0 ] 8.06µs ± 1% 8.02µs ± 1% -0.51% (p=0.016 n=20+19) BM_StreamingPingPongWithCoalescingApi/64/2/1 [polls/iter:0 ] 11.2µs ± 1% 11.1µs ± 1% -0.69% (p=0.000 n=19+18) BM_StreamingPingPongWithCoalescingApi/512/1/0 [polls/iter:0 ] 8.83µs ± 1% 8.71µs ± 1% -1.34% (p=0.000 n=20+19) BM_StreamingPingPongWithCoalescingApi/512/2/0 [polls/iter:0 ] 12.2µs ± 1% 12.1µs ± 1% -1.35% (p=0.000 n=19+17) BM_StreamingPingPongWithCoalescingApi/512/1/1 [polls/iter:0 ] 8.40µs ± 1% 8.32µs ± 1% -0.92% (p=0.000 n=20+20) BM_StreamingPingPongWithCoalescingApi/512/2/1 [polls/iter:0 ] 11.9µs ± 1% 11.7µs ± 1% -1.04% (p=0.000 n=19+20) BM_StreamingPingPongWithCoalescingApi/4096/1/0 [polls/iter:0 ] 11.1µs ± 1% 11.0µs ± 1% -0.53% (p=0.002 n=20+19) BM_StreamingPingPongWithCoalescingApi/4096/2/0 [polls/iter:0 ] 16.6µs ± 1% 16.5µs ± 2% -0.47% (p=0.023 n=20+20) BM_StreamingPingPongWithCoalescingApi/32768/1/1 [polls/iter:0 ] 29.6µs ± 1% 29.7µs ± 1% +0.36% (p=0.000 n=20+20) BM_StreamingPingPongWithCoalescingApi/2097152/1/0 [polls/iter:0 ] 1.59ms ± 9% 1.48ms ± 1% -7.02% (p=0.001 n=20+16) BM_StreamingPingPongWithCoalescingApi/2097152/2/0 [polls/iter:0 ] 3.17ms ± 9% 2.95ms ± 0% -6.86% (p=0.015 n=20+16) BM_StreamingPingPongWithCoalescingApi/2097152/1/1 [polls/iter:0 ] 1.59ms ± 9% 1.48ms ± 0% -7.01% (p=0.000 n=20+16) BM_StreamingPingPongWithCoalescingApi/2097152/2/1 [polls/iter:0 ] 3.17ms ± 9% 2.95ms ± 0% -6.91% (p=0.004 n=20+16) BM_StreamingPingPongWithCoalescingApi/134217728/2/1 [polls/iter:0 ] 512ms ± 2% 509ms ± 2% -0.74% (p=0.040 n=20+20) BM_StreamingPingPongWithCoalescingApi/0/1/0 [polls/iter:0 ] 8.07µs ± 1% 8.02µs ± 1% -0.62% (p=0.001 n=20+20) BM_StreamingPingPongWithCoalescingApi/0/2/0 [polls/iter:0 ] 10.9µs ± 1% 10.9µs ± 1% +0.30% (p=0.014 n=20+20) BM_StreamingPingPongWithCoalescingApi/1/1/0 [polls/iter:0 ] 8.27µs ± 1% 8.24µs ± 1% -0.40% (p=0.040 n=20+20) BM_StreamingPingPongWithCoalescingApi/1/1/1 [polls/iter:0 ] 7.86µs ± 1% 7.83µs ± 1% -0.36% (p=0.041 n=20+19) BM_StreamingPingPongWithCoalescingApi/1/2/1 [polls/iter:0 ] 11.0µs ± 1% 10.9µs ± 1% -0.50% (p=0.000 n=18+19) BM_StreamingPingPongWithCoalescingApi/8/2/1 [polls/iter:0 ] 10.9µs ± 1% 10.9µs ± 1% +0.28% (p=0.005 n=17+19) BM_StreamingPingPongWithCoalescingApi/64/1/0 [polls/iter:0 ] 8.43µs ± 1% 8.40µs ± 1% -0.40% (p=0.012 n=20+18) BM_StreamingPingPongWithCoalescingApi/64/2/1 [polls/iter:0 ] 11.2µs ± 1% 11.1µs ± 1% -0.42% (p=0.019 n=20+18) BM_StreamingPingPongWithCoalescingApi/512/1/0 [polls/iter:0 ] 8.77µs ± 1% 8.70µs ± 1% -0.91% (p=0.000 n=20+20) BM_StreamingPingPongWithCoalescingApi/512/2/0 [polls/iter:0 ] 12.2µs ± 1% 12.1µs ± 1% -0.71% (p=0.000 n=20+20) BM_StreamingPingPongWithCoalescingApi/512/2/1 [polls/iter:0 ] 11.8µs ± 1% 11.7µs ± 1% -0.78% (p=0.000 n=20+20) BM_StreamingPingPongWithCoalescingApi/4096/1/0 [polls/iter:0 ] 11.0µs ± 1% 11.0µs ± 1% -0.42% (p=0.030 n=20+20) BM_StreamingPingPongWithCoalescingApi/32768/1/1 [polls/iter:0 ] 29.4µs ± 1% 29.5µs ± 1% +0.35% (p=0.003 n=20+20) BM_StreamingPingPongWithCoalescingApi/2097152/1/0 [polls/iter:0 ] 1.60ms ± 8% 1.48ms ± 1% -7.63% (p=0.002 n=20+16) BM_StreamingPingPongWithCoalescingApi/2097152/2/0 [polls/iter:0 ] 3.20ms ± 8% 2.96ms ± 1% -7.49% (p=0.020 n=20+16) BM_StreamingPingPongWithCoalescingApi/2097152/1/1 [polls/iter:0 ] 1.60ms ± 8% 1.48ms ± 1% -7.68% (p=0.000 n=20+16) BM_StreamingPingPongWithCoalescingApi/2097152/2/1 [polls/iter:0 ] 3.20ms ± 9% 2.95ms ± 1% -7.76% (p=0.001 n=20+16) BM_StreamingPingPongWithCoalescingApi/134217728/1/0 [polls/iter:5.8 writes/iter:9.8 ] 255ms ± 2% 248ms ± 1% -2.59% (p=0.017 n=3+7) BM_StreamingPingPongWithCoalescingApi/134217728/2/1 [polls/iter:9.5 writes/iter:18.5 ] 523ms ± 1% 512ms ± 2% -2.09% (p=0.016 n=5+5) --- src/core/lib/transport/byte_stream.cc | 8 +++----- src/core/lib/transport/byte_stream.h | 3 +-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/core/lib/transport/byte_stream.cc b/src/core/lib/transport/byte_stream.cc index 16b85ca0db0..1dd234c3761 100644 --- a/src/core/lib/transport/byte_stream.cc +++ b/src/core/lib/transport/byte_stream.cc @@ -55,17 +55,15 @@ void SliceBufferByteStream::Orphan() { bool SliceBufferByteStream::Next(size_t max_size_hint, grpc_closure* on_complete) { - GPR_ASSERT(cursor_ < backing_buffer_.count); + GPR_DEBUG_ASSERT(backing_buffer_.count > 0); return true; } grpc_error* SliceBufferByteStream::Pull(grpc_slice* slice) { - if (shutdown_error_ != GRPC_ERROR_NONE) { + if (GPR_UNLIKELY(shutdown_error_ != GRPC_ERROR_NONE)) { return GRPC_ERROR_REF(shutdown_error_); } - GPR_ASSERT(cursor_ < backing_buffer_.count); - *slice = grpc_slice_ref_internal(backing_buffer_.slices[cursor_]); - ++cursor_; + *slice = grpc_slice_buffer_take_first(&backing_buffer_); return GRPC_ERROR_NONE; } diff --git a/src/core/lib/transport/byte_stream.h b/src/core/lib/transport/byte_stream.h index eff832515da..06503015d2c 100644 --- a/src/core/lib/transport/byte_stream.h +++ b/src/core/lib/transport/byte_stream.h @@ -99,9 +99,8 @@ class SliceBufferByteStream : public ByteStream { void Shutdown(grpc_error* error) override; private: - grpc_slice_buffer backing_buffer_; - size_t cursor_ = 0; grpc_error* shutdown_error_ = GRPC_ERROR_NONE; + grpc_slice_buffer backing_buffer_; }; // From c7793ddddeb2475ea274593dfe0f5436e2046ad6 Mon Sep 17 00:00:00 2001 From: yang-g Date: Thu, 11 Jul 2019 10:16:58 -0700 Subject: [PATCH 0871/1555] Log transport pointer and goaway last stream id when chttp tracing is enabled --- .../transport/chttp2/transport/chttp2_transport.cc | 12 +++++++++--- .../ext/transport/chttp2/transport/frame_goaway.cc | 2 +- src/core/ext/transport/chttp2/transport/internal.h | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 48c3d002bbd..1b1ec8d3c3a 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -1140,6 +1140,7 @@ static void queue_setting_update(grpc_chttp2_transport* t, void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t, uint32_t goaway_error, + uint32_t last_stream_id, const grpc_slice& goaway_text) { // Discard the error from a previous goaway frame (if any) if (t->goaway_error != GRPC_ERROR_NONE) { @@ -1153,6 +1154,9 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t, GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE), GRPC_ERROR_STR_RAW_BYTES, goaway_text); + GRPC_CHTTP2_IF_TRACING( + gpr_log(GPR_INFO, "transport %p got goaway with last stream id %d", t, + last_stream_id)); /* We want to log this irrespective of whether http tracing is enabled */ gpr_log(GPR_INFO, "%s: Got goaway [%d] err=%s", t->peer_string, goaway_error, grpc_error_string(t->goaway_error)); @@ -1191,8 +1195,9 @@ static void maybe_start_some_streams(grpc_chttp2_transport* t) { grpc_chttp2_list_pop_waiting_for_concurrency(t, &s)) { /* safe since we can't (legally) be parsing this stream yet */ GRPC_CHTTP2_IF_TRACING(gpr_log( - GPR_INFO, "HTTP:%s: Allocating new grpc_chttp2_stream %p to id %d", - t->is_client ? "CLI" : "SVR", s, t->next_stream_id)); + GPR_INFO, + "HTTP:%s: Transport %p allocating new grpc_chttp2_stream %p to id %d", + t->is_client ? "CLI" : "SVR", t, s, t->next_stream_id)); GPR_ASSERT(s->id == 0); s->id = t->next_stream_id; @@ -2825,7 +2830,8 @@ static void keepalive_watchdog_fired_locked(void* arg, grpc_error* error) { static void connectivity_state_set(grpc_chttp2_transport* t, grpc_connectivity_state state, const char* reason) { - GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_INFO, "set connectivity_state=%d", state)); + GRPC_CHTTP2_IF_TRACING( + gpr_log(GPR_INFO, "transport %p set connectivity_state=%d", t, state)); grpc_connectivity_state_set(&t->channel_callback.state_tracker, state, reason); } diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.cc b/src/core/ext/transport/chttp2/transport/frame_goaway.cc index e901a6bdc76..6dad3497ec6 100644 --- a/src/core/ext/transport/chttp2/transport/frame_goaway.cc +++ b/src/core/ext/transport/chttp2/transport/frame_goaway.cc @@ -139,7 +139,7 @@ grpc_error* grpc_chttp2_goaway_parser_parse(void* parser, p->state = GRPC_CHTTP2_GOAWAY_DEBUG; if (is_last) { grpc_chttp2_add_incoming_goaway( - t, p->error_code, + t, p->error_code, p->last_stream_id, grpc_slice_new(p->debug_data, p->debug_length, gpr_free)); p->debug_data = nullptr; } diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 4ab46f9808b..732bc38a0ac 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -752,6 +752,7 @@ grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_chttp2_transport* t, void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t, uint32_t goaway_error, + uint32_t last_stream_id, const grpc_slice& goaway_text); void grpc_chttp2_parsing_become_skip_parser(grpc_chttp2_transport* t); From aa3c2a903d556df2bef204ef579bfa0888751c4b Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Thu, 11 Jul 2019 16:04:44 -0700 Subject: [PATCH 0872/1555] Reworked hack --- gRPC-Core.podspec | 13 ++++++++++--- templates/gRPC-Core.podspec.template | 16 +++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 340c7b4b66b..f92b78f3fdf 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -1387,8 +1387,15 @@ Pod::Spec.new do |s| # TODO (mxyan): Instead of this hack, add include path "third_party" to C core's include path? s.prepare_command = <<-END_OF_COMMAND - find src/core/ -type f ! -path '*.grpc_back' -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(pb(_.*)?\\.h)";#include ;g' - find src/core/ -type f -path '*.grpc_back' -print0 | xargs -0 rm - find src/core/ -type f \\( -path '*.h' -or -path '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include \\ +#else\\ + #include "\\1"\\ +#endif;g' + find src/core/ -type f \\( -path '*.h' -or -path '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i '' 's;#include ;#if COCOAPODS\\ + #include \\ +#else\\ + #include \\ +#endif;g' END_OF_COMMAND end diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template index 89a1e9188ff..a22ce9c33e9 100644 --- a/templates/gRPC-Core.podspec.template +++ b/templates/gRPC-Core.podspec.template @@ -211,9 +211,15 @@ end # TODO (mxyan): Instead of this hack, add include path "third_party" to C core's include path? - s.prepare_command = <<-END_OF_COMMAND - find src/core/ -type f ! -path '*.grpc_back' -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(pb(_.*)?\\.h)";#include ;g' - find src/core/ -type f -path '*.grpc_back' -print0 | xargs -0 rm - find src/core/ -type f \\( -path '*.h' -or -path '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include \\ +#else\\ + #include "\\1"\\ +#endif;g' + find src/core/ -type f \\( -path '*.h' -or -path '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i '' 's;#include ;#if COCOAPODS\\ + #include \\ +#else\\ + #include \\ +#endif;g' end From 4999420c7d980189ecc11d5e58a9387ef7573400 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 11 Jul 2019 16:11:15 -0700 Subject: [PATCH 0873/1555] Add a test client for certain grpclb fallback scenarios --- CMakeLists.txt | 63 +++++ Makefile | 58 ++++ build.yaml | 15 ++ src/proto/grpc/testing/messages.proto | 20 ++ test/cpp/interop/BUILD | 16 ++ test/cpp/interop/grpclb_fallback_test.cc | 254 ++++++++++++++++++ .../generated/sources_and_headers.json | 29 ++ tools/run_tests/generated/tests.json | 24 ++ 8 files changed, 479 insertions(+) create mode 100644 test/cpp/interop/grpclb_fallback_test.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 8dfa4e8009a..fc67b4512ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -638,6 +638,7 @@ add_dependencies(buildtests_cxx grpc_linux_system_roots_test) add_dependencies(buildtests_cxx grpc_tool_test) add_dependencies(buildtests_cxx grpclb_api_test) add_dependencies(buildtests_cxx grpclb_end2end_test) +add_dependencies(buildtests_cxx grpclb_fallback_test) add_dependencies(buildtests_cxx h2_ssl_cert_test) add_dependencies(buildtests_cxx h2_ssl_session_reuse_test) add_dependencies(buildtests_cxx health_service_end2end_test) @@ -14465,6 +14466,68 @@ target_link_libraries(grpclb_end2end_test ) +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + +add_executable(grpclb_fallback_test + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/empty.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/empty.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/empty.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/empty.grpc.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/messages.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/messages.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/messages.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/messages.grpc.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/test.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/test.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/test.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/test.grpc.pb.h + test/cpp/interop/grpclb_fallback_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + +protobuf_generate_grpc_cpp( + src/proto/grpc/testing/empty.proto +) +protobuf_generate_grpc_cpp( + src/proto/grpc/testing/messages.proto +) +protobuf_generate_grpc_cpp( + src/proto/grpc/testing/test.proto +) + +target_include_directories(grpclb_fallback_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(grpclb_fallback_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc++_test_util + grpc_test_util + grpc++ + grpc + gpr + grpc++_test_config + ${_gRPC_GFLAGS_LIBRARIES} +) + + endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index 2a1bfad1f35..952b20155fd 100644 --- a/Makefile +++ b/Makefile @@ -1228,6 +1228,7 @@ grpc_ruby_plugin: $(BINDIR)/$(CONFIG)/grpc_ruby_plugin grpc_tool_test: $(BINDIR)/$(CONFIG)/grpc_tool_test grpclb_api_test: $(BINDIR)/$(CONFIG)/grpclb_api_test grpclb_end2end_test: $(BINDIR)/$(CONFIG)/grpclb_end2end_test +grpclb_fallback_test: $(BINDIR)/$(CONFIG)/grpclb_fallback_test h2_ssl_cert_test: $(BINDIR)/$(CONFIG)/h2_ssl_cert_test h2_ssl_session_reuse_test: $(BINDIR)/$(CONFIG)/h2_ssl_session_reuse_test health_service_end2end_test: $(BINDIR)/$(CONFIG)/health_service_end2end_test @@ -1697,6 +1698,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/grpc_tool_test \ $(BINDIR)/$(CONFIG)/grpclb_api_test \ $(BINDIR)/$(CONFIG)/grpclb_end2end_test \ + $(BINDIR)/$(CONFIG)/grpclb_fallback_test \ $(BINDIR)/$(CONFIG)/h2_ssl_cert_test \ $(BINDIR)/$(CONFIG)/h2_ssl_session_reuse_test \ $(BINDIR)/$(CONFIG)/health_service_end2end_test \ @@ -1862,6 +1864,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/grpc_tool_test \ $(BINDIR)/$(CONFIG)/grpclb_api_test \ $(BINDIR)/$(CONFIG)/grpclb_end2end_test \ + $(BINDIR)/$(CONFIG)/grpclb_fallback_test \ $(BINDIR)/$(CONFIG)/h2_ssl_cert_test \ $(BINDIR)/$(CONFIG)/h2_ssl_session_reuse_test \ $(BINDIR)/$(CONFIG)/health_service_end2end_test \ @@ -2366,6 +2369,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/grpclb_api_test || ( echo test grpclb_api_test failed ; exit 1 ) $(E) "[RUN] Testing grpclb_end2end_test" $(Q) $(BINDIR)/$(CONFIG)/grpclb_end2end_test || ( echo test grpclb_end2end_test failed ; exit 1 ) + $(E) "[RUN] Testing grpclb_fallback_test" + $(Q) $(BINDIR)/$(CONFIG)/grpclb_fallback_test || ( echo test grpclb_fallback_test failed ; exit 1 ) $(E) "[RUN] Testing h2_ssl_cert_test" $(Q) $(BINDIR)/$(CONFIG)/h2_ssl_cert_test || ( echo test h2_ssl_cert_test failed ; exit 1 ) $(E) "[RUN] Testing h2_ssl_session_reuse_test" @@ -17488,6 +17493,59 @@ endif $(OBJDIR)/$(CONFIG)/test/cpp/end2end/grpclb_end2end_test.o: $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc +GRPCLB_FALLBACK_TEST_SRC = \ + $(GENDIR)/src/proto/grpc/testing/empty.pb.cc $(GENDIR)/src/proto/grpc/testing/empty.grpc.pb.cc \ + $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc \ + $(GENDIR)/src/proto/grpc/testing/test.pb.cc $(GENDIR)/src/proto/grpc/testing/test.grpc.pb.cc \ + test/cpp/interop/grpclb_fallback_test.cc \ + +GRPCLB_FALLBACK_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPCLB_FALLBACK_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/grpclb_fallback_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/grpclb_fallback_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/grpclb_fallback_test: $(PROTOBUF_DEP) $(GRPCLB_FALLBACK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(GRPCLB_FALLBACK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/grpclb_fallback_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/src/proto/grpc/testing/empty.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a + +$(OBJDIR)/$(CONFIG)/src/proto/grpc/testing/messages.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a + +$(OBJDIR)/$(CONFIG)/src/proto/grpc/testing/test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a + +$(OBJDIR)/$(CONFIG)/test/cpp/interop/grpclb_fallback_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a + +deps_grpclb_fallback_test: $(GRPCLB_FALLBACK_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(GRPCLB_FALLBACK_TEST_OBJS:.o=.dep) +endif +endif +$(OBJDIR)/$(CONFIG)/test/cpp/interop/grpclb_fallback_test.o: $(GENDIR)/src/proto/grpc/testing/empty.pb.cc $(GENDIR)/src/proto/grpc/testing/empty.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/test.pb.cc $(GENDIR)/src/proto/grpc/testing/test.grpc.pb.cc + + H2_SSL_CERT_TEST_SRC = \ test/core/end2end/h2_ssl_cert_test.cc \ diff --git a/build.yaml b/build.yaml index 5915b9ccd64..f42efbb3b21 100644 --- a/build.yaml +++ b/build.yaml @@ -5041,6 +5041,21 @@ targets: - grpc++ - grpc - gpr +- name: grpclb_fallback_test + build: test + language: c++ + src: + - src/proto/grpc/testing/empty.proto + - src/proto/grpc/testing/messages.proto + - src/proto/grpc/testing/test.proto + - test/cpp/interop/grpclb_fallback_test.cc + deps: + - grpc++_test_util + - grpc_test_util + - grpc++ + - grpc + - gpr + - grpc++_test_config - name: h2_ssl_cert_test gtest: true build: test diff --git a/src/proto/grpc/testing/messages.proto b/src/proto/grpc/testing/messages.proto index 3b966ae1b25..4fed83fb389 100644 --- a/src/proto/grpc/testing/messages.proto +++ b/src/proto/grpc/testing/messages.proto @@ -48,6 +48,21 @@ message EchoStatus { string message = 2; } +// The type of route that a client took to reach a server w.r.t. gRPCLB. +// The server must fill in "fallback" if it detects that the RPC reached +// the server via the "gRPCLB fallback" path, and "backend" if it detects +// that the RPC reached the server via "gRPCLB backend" path (i.e. if it got +// the address of this server from the gRPCLB server BalanceLoad RPC). Exactly +// how this detection is done is context and server dependant. +enum GrpclbRouteType { + // Server didn't detect the route that a client took to reach it. + GRPCLB_ROUTE_TYPE_UNKNOWN = 0; + // Indicates that a client reached a server via gRPCLB fallback. + GRPCLB_ROUTE_TYPE_FALLBACK = 1; + // Indicates that a client reached a server as a gRPCLB-given backend. + GRPCLB_ROUTE_TYPE_BACKEND = 2; +} + // Unary request. message SimpleRequest { // Desired payload type in the response from the server. @@ -80,6 +95,9 @@ message SimpleRequest { // Whether SimpleResponse should include server_id. bool fill_server_id = 9; + + // Whether SimpleResponse should include grpclb_route_type. + bool fill_grpclb_route_type = 10; } // Unary response, as configured by the request. @@ -95,6 +113,8 @@ message SimpleResponse { // Server ID. This must be unique among different server instances, // but the same across all RPC's made to a particular server instance. string server_id = 4; + // gRPCLB Path. + GrpclbRouteType grpclb_route_type = 5; } // Client-streaming request. diff --git a/test/cpp/interop/BUILD b/test/cpp/interop/BUILD index 802302bc8bf..e575ef88c5d 100644 --- a/test/cpp/interop/BUILD +++ b/test/cpp/interop/BUILD @@ -38,6 +38,22 @@ grpc_cc_library( ], ) +grpc_cc_binary( + name = "grpclb_fallback_test", + srcs = [ + "grpclb_fallback_test.cc", + ], + language = "C++", + deps = [ + "//src/proto/grpc/testing:empty_proto", + "//src/proto/grpc/testing:messages_proto", + "//src/proto/grpc/testing:test_proto", + "//test/cpp/util:test_config", + "//test/cpp/util:test_util", + "//:grpc++", + ], +) + grpc_cc_binary( name = "interop_server", srcs = [ diff --git a/test/cpp/interop/grpclb_fallback_test.cc b/test/cpp/interop/grpclb_fallback_test.cc new file mode 100644 index 00000000000..ddfad7e01b1 --- /dev/null +++ b/test/cpp/interop/grpclb_fallback_test.cc @@ -0,0 +1,254 @@ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "src/core/lib/gpr/string.h" +#include "src/core/lib/iomgr/socket_mutator.h" +#include "src/proto/grpc/testing/empty.pb.h" +#include "src/proto/grpc/testing/messages.pb.h" +#include "src/proto/grpc/testing/test.grpc.pb.h" +#include "src/proto/grpc/testing/test.pb.h" + +#include "test/cpp/util/test_config.h" +#include "test/cpp/util/test_credentials_provider.h" + +DEFINE_string(custom_credentials_type, "", "User provided credentials type."); +DEFINE_string(server_uri, "localhost:1000", "Server URI target"); +DEFINE_string(unroute_lb_and_backend_addrs_cmd, "exit 1", + "Shell command used to make LB and backend addresses unroutable"); +DEFINE_string(blackhole_lb_and_backend_addrs_cmd, "exit 1", + "Shell command used to make LB and backend addresses blackholed"); +DEFINE_string( + test_case, "", + "Test case to run. Valid options are:\n\n" + "fast_fallback_before_startup : fallback before establishing connection to " + "LB;\n" + "fast_fallback_after_startup : fallback after startup due to LB/backend " + "addresses becoming unroutable;\n" + "slow_fallback_before_startup : fallback before startup due to LB address " + "being blackholed;\n" + "slow_fallback_after_startup : fallback after startup due to LB/backend " + "addresses becoming blackholed;\n"); + +using grpc::testing::GrpclbRouteType; +using grpc::testing::SimpleRequest; +using grpc::testing::SimpleResponse; +using grpc::testing::TestService; + +namespace { + +enum RpcMode { + FailFast, + WaitForReady, +}; + +GrpclbRouteType DoRPCAndGetPath(TestService::Stub* stub, int deadline_seconds, + RpcMode rpc_mode) { + gpr_log(GPR_INFO, "DoRPCAndGetPath deadline_seconds:%d rpc_mode:%d", + deadline_seconds, rpc_mode); + SimpleRequest request; + SimpleResponse response; + grpc::ClientContext context; + if (rpc_mode == WaitForReady) { + context.set_wait_for_ready(true); + } + request.set_fill_grpclb_route_type(true); + std::chrono::system_clock::time_point deadline = + std::chrono::system_clock::now() + std::chrono::seconds(deadline_seconds); + context.set_deadline(deadline); + grpc::Status s = stub->UnaryCall(&context, request, &response); + if (!s.ok()) { + gpr_log(GPR_INFO, "DoRPCAndGetPath failed. status-message: %s", + s.error_message().c_str()); + return GrpclbRouteType::GRPCLB_ROUTE_TYPE_UNKNOWN; + } + GPR_ASSERT(response.grpclb_route_type() == + GrpclbRouteType::GRPCLB_ROUTE_TYPE_BACKEND || + response.grpclb_route_type() == + GrpclbRouteType::GRPCLB_ROUTE_TYPE_FALLBACK); + gpr_log(GPR_INFO, "DoRPCAndGetPath done. grpclb_route_type:%d", + response.grpclb_route_type()); + return response.grpclb_route_type(); +} + +GrpclbRouteType DoRPCAndGetPath(TestService::Stub* stub, int deadline_seconds) { + return DoRPCAndGetPath(stub, deadline_seconds, FailFast); +} + +GrpclbRouteType DoWaitForReadyRPCAndGetPath(TestService::Stub* stub, + int deadline_seconds) { + return DoRPCAndGetPath(stub, deadline_seconds, WaitForReady); +} + +bool TcpUserTimeoutMutateFd(int fd, grpc_socket_mutator* mutator) { + int timeout = 20000; // 20 seconds + gpr_log(GPR_INFO, "Setting socket option TCP_USER_TIMEOUT on fd: %d", fd); + if (0 != setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &timeout, + sizeof(timeout))) { + gpr_log(GPR_ERROR, "Failed to set socket option TCP_USER_TIMEOUT"); + abort(); + } + int newval; + socklen_t len = sizeof(newval); + if (0 != getsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &newval, &len) || + newval != timeout) { + gpr_log(GPR_ERROR, "Failed to set socket option TCP_USER_TIMEOUT"); + abort(); + } + return true; +} + +int TcpUserTimeoutCompare(grpc_socket_mutator* a, grpc_socket_mutator* b) { + return 0; +} + +void TcpUserTimeoutDestroy(grpc_socket_mutator* mutator) { gpr_free(mutator); } + +const grpc_socket_mutator_vtable kTcpUserTimeoutMutatorVtable = + grpc_socket_mutator_vtable{ + .mutate_fd = TcpUserTimeoutMutateFd, + .compare = TcpUserTimeoutCompare, + .destroy = TcpUserTimeoutDestroy, + }; + +std::unique_ptr CreateFallbackTestStub() { + grpc::ChannelArguments channel_args; + grpc_socket_mutator* tcp_user_timeout_mutator = + static_cast( + gpr_malloc(sizeof(tcp_user_timeout_mutator))); + grpc_socket_mutator_init(tcp_user_timeout_mutator, + &kTcpUserTimeoutMutatorVtable); + channel_args.SetSocketMutator(tcp_user_timeout_mutator); + // Allow LB policy to be configured by service config + channel_args.SetInt(GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION, 0); + std::shared_ptr channel_creds = + grpc::testing::GetCredentialsProvider()->GetChannelCredentials( + FLAGS_custom_credentials_type, &channel_args); + return TestService::NewStub( + grpc::CreateCustomChannel(FLAGS_server_uri, channel_creds, channel_args)); +} + +void RunCommand(const std::string command) { + gpr_log(GPR_INFO, "RunCommand: |%s|", command.c_str()); + int out = std::system(command.c_str()); + if (WIFEXITED(out)) { + int code = WEXITSTATUS(out); + if (code != 0) { + gpr_log(GPR_ERROR, "RunCommand failed exit code:%d command:|%s|", code, + command.c_str()); + abort(); + } + } else { + gpr_log(GPR_ERROR, "RunCommand failed command:|%s|", command.c_str()); + abort(); + } +} + +void RunFallbackBeforeStartupTest( + const std::string break_lb_and_backend_conns_cmd, + int per_rpc_deadline_seconds) { + std::unique_ptr stub = CreateFallbackTestStub(); + RunCommand(break_lb_and_backend_conns_cmd); + for (size_t i = 0; i < 30; i++) { + GrpclbRouteType grpclb_route_type = + DoRPCAndGetPath(stub.get(), per_rpc_deadline_seconds); + if (grpclb_route_type != GrpclbRouteType::GRPCLB_ROUTE_TYPE_FALLBACK) { + gpr_log(GPR_ERROR, "Expected grpclb route type: FALLBACK. Got: %d", + grpclb_route_type); + abort(); + } + std::this_thread::sleep_for(std::chrono::seconds(1)); + } +} + +void DoFastFallbackBeforeStartup() { + RunFallbackBeforeStartupTest(FLAGS_unroute_lb_and_backend_addrs_cmd, 9); +} + +void DoSlowFallbackBeforeStartup() { + RunFallbackBeforeStartupTest(FLAGS_blackhole_lb_and_backend_addrs_cmd, 20); +} + +void RunFallbackAfterStartupTest( + const std::string break_lb_and_backend_conns_cmd) { + std::unique_ptr stub = CreateFallbackTestStub(); + GrpclbRouteType grpclb_route_type = DoRPCAndGetPath(stub.get(), 20); + if (grpclb_route_type != GrpclbRouteType::GRPCLB_ROUTE_TYPE_BACKEND) { + gpr_log(GPR_ERROR, "Expected grpclb route type: BACKEND. Got: %d", + grpclb_route_type); + abort(); + } + RunCommand(break_lb_and_backend_conns_cmd); + for (size_t i = 0; i < 40; i++) { + GrpclbRouteType grpclb_route_type = + DoWaitForReadyRPCAndGetPath(stub.get(), 1); + // Backends should be unreachable by now, otherwise the test is broken. + GPR_ASSERT(grpclb_route_type != GrpclbRouteType::GRPCLB_ROUTE_TYPE_BACKEND); + if (grpclb_route_type == GrpclbRouteType::GRPCLB_ROUTE_TYPE_FALLBACK) { + gpr_log(GPR_INFO, + "Made one successul RPC to a fallback. Now expect the same for " + "the rest."); + break; + } else { + gpr_log(GPR_ERROR, "Retryable RPC failure on iteration: %" PRIdPTR, i); + } + } + for (size_t i = 0; i < 30; i++) { + GrpclbRouteType grpclb_route_type = DoRPCAndGetPath(stub.get(), 20); + if (grpclb_route_type != GrpclbRouteType::GRPCLB_ROUTE_TYPE_FALLBACK) { + gpr_log(GPR_ERROR, "Expected grpclb route type: FALLBACK. Got: %d", + grpclb_route_type); + abort(); + } + std::this_thread::sleep_for(std::chrono::seconds(1)); + } +} + +void DoFastFallbackAfterStartup() { + RunFallbackAfterStartupTest(FLAGS_unroute_lb_and_backend_addrs_cmd); +} + +void DoSlowFallbackAfterStartup() { + RunFallbackAfterStartupTest(FLAGS_blackhole_lb_and_backend_addrs_cmd); +} +} // namespace + +int main(int argc, char** argv) { + grpc::testing::InitTest(&argc, &argv, true); + gpr_log(GPR_INFO, "Testing: %s", FLAGS_test_case.c_str()); + if (FLAGS_test_case == "fast_fallback_before_startup") { + DoFastFallbackBeforeStartup(); + gpr_log(GPR_INFO, "DoFastFallbackBeforeStartup done!"); + } else if (FLAGS_test_case == "slow_fallback_before_startup") { + DoSlowFallbackBeforeStartup(); + gpr_log(GPR_INFO, "DoSlowFallbackBeforeStartup done!"); + } else if (FLAGS_test_case == "fast_fallback_after_startup") { + DoFastFallbackAfterStartup(); + gpr_log(GPR_INFO, "DoFastFallbackAfterStartup done!"); + } else if (FLAGS_test_case == "slow_fallback_after_startup") { + DoSlowFallbackAfterStartup(); + gpr_log(GPR_INFO, "DoSlowFallbackAfterStartup done!"); + } else { + gpr_log(GPR_ERROR, "Invalid test case: %s", FLAGS_test_case.c_str()); + abort(); + } +} diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 7a1baae36cd..0b56c7b32df 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -4037,6 +4037,35 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "grpc", + "grpc++", + "grpc++_test_config", + "grpc++_test_util", + "grpc_test_util" + ], + "headers": [ + "src/proto/grpc/testing/empty.grpc.pb.h", + "src/proto/grpc/testing/empty.pb.h", + "src/proto/grpc/testing/empty_mock.grpc.pb.h", + "src/proto/grpc/testing/messages.grpc.pb.h", + "src/proto/grpc/testing/messages.pb.h", + "src/proto/grpc/testing/messages_mock.grpc.pb.h", + "src/proto/grpc/testing/test.grpc.pb.h", + "src/proto/grpc/testing/test.pb.h", + "src/proto/grpc/testing/test_mock.grpc.pb.h" + ], + "is_filegroup": false, + "language": "c++", + "name": "grpclb_fallback_test", + "src": [ + "test/cpp/interop/grpclb_fallback_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 2ac529238d5..fe10187fffb 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -4813,6 +4813,30 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": false, + "language": "c++", + "name": "grpclb_fallback_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": true + }, { "args": [], "benchmark": false, From 34a688050857ee29e413ec3baf833873d9c36bdf Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Thu, 11 Jul 2019 18:31:51 -0700 Subject: [PATCH 0874/1555] Fixing formatting issues --- gRPC-Core.podspec | 12 ++---------- templates/gRPC-Core.podspec.template | 15 ++++----------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index f92b78f3fdf..2dfcb311b5d 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -1387,15 +1387,7 @@ Pod::Spec.new do |s| # TODO (mxyan): Instead of this hack, add include path "third_party" to C core's include path? s.prepare_command = <<-END_OF_COMMAND - find src/core/ -type f -print0 | xargs -0 -L1 sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS\\ - #include \\ -#else\\ - #include "\\1"\\ -#endif;g' - find src/core/ -type f \\( -path '*.h' -or -path '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i '' 's;#include ;#if COCOAPODS\\ - #include \\ -#else\\ - #include \\ -#endif;g' + find src/core/ -type f -print0 | xargs -0 -L1 sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS\\\n #include \\\n#else\\\n #include "\\1"\\\n#endif;g' + find src/core/ -type f \\( -path '*.h' -or -path '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i '' 's;#include ;#if COCOAPODS\\\n #include \\\n#else\\\n #include \\\n#endif;g' END_OF_COMMAND end diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template index a22ce9c33e9..652c4ed43f0 100644 --- a/templates/gRPC-Core.podspec.template +++ b/templates/gRPC-Core.podspec.template @@ -211,15 +211,8 @@ end # TODO (mxyan): Instead of this hack, add include path "third_party" to C core's include path? - s.prepare_command = <<-END_OF_COMMAND - find src/core/ -type f -print0 | xargs -0 -L1 sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS\\ - #include \\ -#else\\ - #include "\\1"\\ -#endif;g' - find src/core/ -type f \\( -path '*.h' -or -path '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i '' 's;#include ;#if COCOAPODS\\ - #include \\ -#else\\ - #include \\ -#endif;g' + s.prepare_command = <<-END_OF_COMMAND + find src/core/ -type f -print0 | xargs -0 -L1 sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS\\\n #include \\\n#else\\\n #include "\\1"\\\n#endif;g' + find src/core/ -type f \\( -path '*.h' -or -path '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i '' 's;#include ;#if COCOAPODS\\\n #include \\\n#else\\\n #include \\\n#endif;g' + END_OF_COMMAND end From 3958a53bf7ba8a847154f55bf1eb50ca503fb220 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 11 Jul 2019 19:08:27 -0700 Subject: [PATCH 0875/1555] Address review comments; fix sanity --- CMakeLists.txt | 4 ++++ build.yaml | 2 ++ test/cpp/interop/grpclb_fallback_test.cc | 26 ++++++++++++++++++++---- tools/run_tests/generated/tests.json | 10 ++------- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc67b4512ea..a68f5caff81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -638,7 +638,9 @@ add_dependencies(buildtests_cxx grpc_linux_system_roots_test) add_dependencies(buildtests_cxx grpc_tool_test) add_dependencies(buildtests_cxx grpclb_api_test) add_dependencies(buildtests_cxx grpclb_end2end_test) +if(_gRPC_PLATFORM_LINUX) add_dependencies(buildtests_cxx grpclb_fallback_test) +endif() add_dependencies(buildtests_cxx h2_ssl_cert_test) add_dependencies(buildtests_cxx h2_ssl_session_reuse_test) add_dependencies(buildtests_cxx health_service_end2end_test) @@ -14468,6 +14470,7 @@ target_link_libraries(grpclb_end2end_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX) add_executable(grpclb_fallback_test ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/empty.pb.cc @@ -14528,6 +14531,7 @@ target_link_libraries(grpclb_fallback_test ) +endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) diff --git a/build.yaml b/build.yaml index f42efbb3b21..c36b3c72594 100644 --- a/build.yaml +++ b/build.yaml @@ -5056,6 +5056,8 @@ targets: - grpc - gpr - grpc++_test_config + platforms: + - linux - name: h2_ssl_cert_test gtest: true build: test diff --git a/test/cpp/interop/grpclb_fallback_test.cc b/test/cpp/interop/grpclb_fallback_test.cc index ddfad7e01b1..3622482b67d 100644 --- a/test/cpp/interop/grpclb_fallback_test.cc +++ b/test/cpp/interop/grpclb_fallback_test.cc @@ -1,3 +1,21 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + #include #include @@ -111,7 +129,7 @@ bool TcpUserTimeoutMutateFd(int fd, grpc_socket_mutator* mutator) { socklen_t len = sizeof(newval); if (0 != getsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &newval, &len) || newval != timeout) { - gpr_log(GPR_ERROR, "Failed to set socket option TCP_USER_TIMEOUT"); + gpr_log(GPR_ERROR, "Failed to get expected socket option TCP_USER_TIMEOUT"); abort(); } return true; @@ -147,7 +165,7 @@ std::unique_ptr CreateFallbackTestStub() { grpc::CreateCustomChannel(FLAGS_server_uri, channel_creds, channel_args)); } -void RunCommand(const std::string command) { +void RunCommand(const std::string& command) { gpr_log(GPR_INFO, "RunCommand: |%s|", command.c_str()); int out = std::system(command.c_str()); if (WIFEXITED(out)) { @@ -164,7 +182,7 @@ void RunCommand(const std::string command) { } void RunFallbackBeforeStartupTest( - const std::string break_lb_and_backend_conns_cmd, + const std::string& break_lb_and_backend_conns_cmd, int per_rpc_deadline_seconds) { std::unique_ptr stub = CreateFallbackTestStub(); RunCommand(break_lb_and_backend_conns_cmd); @@ -189,7 +207,7 @@ void DoSlowFallbackBeforeStartup() { } void RunFallbackAfterStartupTest( - const std::string break_lb_and_backend_conns_cmd) { + const std::string& break_lb_and_backend_conns_cmd) { std::unique_ptr stub = CreateFallbackTestStub(); GrpclbRouteType grpclb_route_type = DoRPCAndGetPath(stub.get(), 20); if (grpclb_route_type != GrpclbRouteType::GRPCLB_ROUTE_TYPE_BACKEND) { diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index fe10187fffb..f4757e5ef62 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -4817,10 +4817,7 @@ "args": [], "benchmark": false, "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" + "linux" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -4830,10 +4827,7 @@ "language": "c++", "name": "grpclb_fallback_test", "platforms": [ - "linux", - "mac", - "posix", - "windows" + "linux" ], "uses_polling": true }, From a0d9ec81a5503c5d71f317b66682748c5eb34852 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Fri, 12 Jul 2019 14:11:26 -0700 Subject: [PATCH 0876/1555] Add a sanity check for the Python release process. This fixes https://github.com/grpc/grpc/issues/19632. --- tools/release/verify_python_release.py | 116 +++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 tools/release/verify_python_release.py diff --git a/tools/release/verify_python_release.py b/tools/release/verify_python_release.py new file mode 100644 index 00000000000..af2892b61a5 --- /dev/null +++ b/tools/release/verify_python_release.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python3 + +#Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Verifies that all gRPC Python artifacts have been successfully published. + +This script is intended to be run from a directory containing the artifacts +that have been uploaded and only the artifacts that have been uploaded. We use +PyPI's JSON API to verify that the proper filenames and checksums are present. + +Note that PyPI may take several minutes to update its metadata. Don't have a +heart attack immediately. + +This sanity check is a good first step, but ideally, we would automate the +entire release process. +""" + +import argparse +import collections +import hashlib +import os +import requests +import sys + +_DEFAULT_PACKAGES = [ + "grpcio", + "grpcio-tools", + "grpcio-status", + "grpcio-health-checking", + "grpcio-reflection", + "grpcio-channelz", + "grpcio-testing", +] + +Artifact = collections.namedtuple("Artifact", ("filename", "checksum")) + + +def _get_md5_checksum(filename): + """Calculate the md5sum for a file.""" + hash_md5 = hashlib.md5() + with open(filename, 'rb') as f: + for chunk in iter(lambda: f.read(4096), b""): + hash_md5.update(chunk) + return hash_md5.hexdigest() + + +def _get_local_artifacts(): + """Get a set of artifacts representing all files in the cwd.""" + return set( + Artifact(f, _get_md5_checksum(f)) for f in os.listdir(os.getcwd())) + + +def _get_remote_artifacts_for_package(package, version): + """Get a list of artifacts based on PyPi's json metadata. + + Note that this data will not updated immediately after upload. In my + experience, it has taken a minute on average to be fresh. + """ + artifacts = set() + payload = requests.get("https://pypi.org/pypi/{}/{}/json".format( + package, version)).json() + for download_info in payload['releases'][version]: + artifacts.add( + Artifact(download_info['filename'], download_info['md5_digest'])) + return artifacts + + +def _get_remote_artifacts_for_packages(packages, version): + artifacts = set() + for package in packages: + artifacts |= _get_remote_artifacts_for_package(package, version) + return artifacts + + +def _verify_release(version, packages): + """Compare the local artifacts to the packages uploaded to PyPI.""" + local_artifacts = _get_local_artifacts() + remote_artifacts = _get_remote_artifacts_for_packages(packages, version) + if local_artifacts != remote_artifacts: + local_but_not_remote = local_artifacts - remote_artifacts + remote_but_not_local = remote_artifacts - local_artifacts + if local_but_not_remote: + print("The following artifacts exist locally but not remotely.") + for artifact in local_but_not_remote: + print(artifact) + if remote_but_not_local: + print("The following artifacts exist remotely but not locally.") + for artifact in remote_but_not_local: + print(artifact) + sys.exit(1) + print("Release verified successfully.") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + "Verify a release. Run this from a directory containing only the" + "artifacts to be uploaded. Note that PyPI may take several minutes" + "after the upload to reflect the proper metadata." + ) + parser.add_argument("version") + parser.add_argument( + "packages", nargs='*', type=str, default=_DEFAULT_PACKAGES) + args = parser.parse_args() + _verify_release(args.version, args.packages) From 994985be97e59e6379655988a1af56b977749d58 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 12 Jul 2019 10:27:47 -0700 Subject: [PATCH 0877/1555] Log refcount traces if tracer enabled, even if DEBUG_LOCATION is not used. --- src/core/lib/gprpp/debug_location.h | 5 +- src/core/lib/gprpp/ref_counted.h | 88 +++++++++++++++++++++-------- 2 files changed, 68 insertions(+), 25 deletions(-) diff --git a/src/core/lib/gprpp/debug_location.h b/src/core/lib/gprpp/debug_location.h index 287761beafb..d2384fde289 100644 --- a/src/core/lib/gprpp/debug_location.h +++ b/src/core/lib/gprpp/debug_location.h @@ -25,10 +25,12 @@ namespace grpc_core { // No-op for non-debug builds. // Callers can use the DEBUG_LOCATION macro in either case. #ifndef NDEBUG +// TODO(roth): See if there's a way to automatically populate this, +// similarly to how absl::SourceLocation::current() works, so that +// callers don't need to explicitly pass DEBUG_LOCATION anywhere. class DebugLocation { public: DebugLocation(const char* file, int line) : file_(file), line_(line) {} - bool Log() const { return true; } const char* file() const { return file_; } int line() const { return line_; } @@ -40,7 +42,6 @@ class DebugLocation { #else class DebugLocation { public: - bool Log() const { return false; } const char* file() const { return nullptr; } int line() const { return -1; } }; diff --git a/src/core/lib/gprpp/ref_counted.h b/src/core/lib/gprpp/ref_counted.h index cab1aaaaab1..5c7a5cf0735 100644 --- a/src/core/lib/gprpp/ref_counted.h +++ b/src/core/lib/gprpp/ref_counted.h @@ -89,72 +89,114 @@ class RefCount { } // Increases the ref-count by `n`. - void Ref(Value n = 1) { value_.FetchAdd(n, MemoryOrder::RELAXED); } + void Ref(Value n = 1) { +#ifndef NDEBUG + const Value prior = value_.FetchAdd(n, MemoryOrder::RELAXED); + if (trace_flag_ != nullptr && trace_flag_->enabled()) { + gpr_log(GPR_INFO, "%s:%p ref %" PRIdPTR " -> %" PRIdPTR, + trace_flag_->name(), this, prior, prior + n); + } +#else + value_.FetchAdd(n, MemoryOrder::RELAXED); +#endif + } void Ref(const DebugLocation& location, const char* reason, Value n = 1) { #ifndef NDEBUG - if (location.Log() && trace_flag_ != nullptr && trace_flag_->enabled()) { - const RefCount::Value old_refs = get(); + const Value prior = value_.FetchAdd(n, MemoryOrder::RELAXED); + if (trace_flag_ != nullptr && trace_flag_->enabled()) { gpr_log(GPR_INFO, "%s:%p %s:%d ref %" PRIdPTR " -> %" PRIdPTR " %s", trace_flag_->name(), this, location.file(), location.line(), - old_refs, old_refs + n, reason); + prior, prior + n, reason); } +#else + value_.FetchAdd(n, MemoryOrder::RELAXED); #endif - Ref(n); } // Similar to Ref() with an assert on the ref-count being non-zero. void RefNonZero() { #ifndef NDEBUG const Value prior = value_.FetchAdd(1, MemoryOrder::RELAXED); + if (trace_flag_ != nullptr && trace_flag_->enabled()) { + gpr_log(GPR_INFO, "%s:%p ref %" PRIdPTR " -> %" PRIdPTR, + trace_flag_->name(), this, prior, prior + 1); + } assert(prior > 0); #else - Ref(); + value_.FetchAdd(1, MemoryOrder::RELAXED); #endif } void RefNonZero(const DebugLocation& location, const char* reason) { #ifndef NDEBUG - if (location.Log() && trace_flag_ != nullptr && trace_flag_->enabled()) { - const RefCount::Value old_refs = get(); + const Value prior = value_.FetchAdd(1, MemoryOrder::RELAXED); + if (trace_flag_ != nullptr && trace_flag_->enabled()) { gpr_log(GPR_INFO, "%s:%p %s:%d ref %" PRIdPTR " -> %" PRIdPTR " %s", trace_flag_->name(), this, location.file(), location.line(), - old_refs, old_refs + 1, reason); + prior, prior + 1, reason); } -#endif + assert(prior > 0); +#else RefNonZero(); +#endif } - bool RefIfNonZero() { return value_.IncrementIfNonzero(); } - + bool RefIfNonZero() { +#ifndef NDEBUG + if (trace_flag_ != nullptr && trace_flag_->enabled()) { + const Value prior = get(); + gpr_log(GPR_INFO, "%s:%p ref_if_non_zero %" PRIdPTR " -> %" PRIdPTR, + trace_flag_->name(), this, prior, prior + 1); + } +#endif + return value_.IncrementIfNonzero(); + } bool RefIfNonZero(const DebugLocation& location, const char* reason) { #ifndef NDEBUG - if (location.Log() && trace_flag_ != nullptr && trace_flag_->enabled()) { - const RefCount::Value old_refs = get(); + if (trace_flag_ != nullptr && trace_flag_->enabled()) { + const Value prior = get(); gpr_log(GPR_INFO, "%s:%p %s:%d ref_if_non_zero " "%" PRIdPTR " -> %" PRIdPTR " %s", trace_flag_->name(), this, location.file(), location.line(), - old_refs, old_refs + 1, reason); + prior, prior + 1, reason); } #endif - return RefIfNonZero(); + return value_.IncrementIfNonzero(); } // Decrements the ref-count and returns true if the ref-count reaches 0. bool Unref() { +#ifndef NDEBUG + // Grab a copy of the trace flag before the atomic change, since we + // can't safely access it afterwards if we're going to be freed. + auto* trace_flag = trace_flag_; +#endif const Value prior = value_.FetchSub(1, MemoryOrder::ACQ_REL); +#ifndef NDEBUG + if (trace_flag != nullptr && trace_flag->enabled()) { + gpr_log(GPR_INFO, "%s:%p unref %" PRIdPTR " -> %" PRIdPTR, + trace_flag->name(), this, prior, prior - 1); + } GPR_DEBUG_ASSERT(prior > 0); +#endif return prior == 1; } bool Unref(const DebugLocation& location, const char* reason) { #ifndef NDEBUG - if (location.Log() && trace_flag_ != nullptr && trace_flag_->enabled()) { - const RefCount::Value old_refs = get(); - gpr_log(GPR_INFO, "%s:%p %s:%d unref %" PRIdPTR " -> %" PRIdPTR " %s", - trace_flag_->name(), this, location.file(), location.line(), - old_refs, old_refs - 1, reason); - } + // Grab a copy of the trace flag before the atomic change, since we + // can't safely access it afterwards if we're going to be freed. + auto* trace_flag = trace_flag_; #endif - return Unref(); + const Value prior = value_.FetchSub(1, MemoryOrder::ACQ_REL); +#ifndef NDEBUG + if (trace_flag != nullptr && trace_flag->enabled()) { + gpr_log(GPR_INFO, "%s:%p %s:%d unref %" PRIdPTR " -> %" PRIdPTR " %s", + trace_flag->name(), this, location.file(), location.line(), prior, + prior - 1, reason); + } + GPR_DEBUG_ASSERT(prior > 0); +#endif + return prior == 1; } private: From c15d246f6a241ffff1ad59abf4d76867949d1706 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 12 Jul 2019 14:56:07 -0700 Subject: [PATCH 0878/1555] Add constructor test case --- src/core/lib/iomgr/executor/mpmcqueue.h | 4 +- src/core/lib/iomgr/executor/threadpool.h | 2 - test/core/iomgr/threadpool_test.cc | 63 ++++++++++++++---------- 3 files changed, 40 insertions(+), 29 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index 5c62221e9d4..c6102b3add0 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -66,8 +66,8 @@ class InfLenFIFOQueue : public MPMCQueueInterface { // Removes the oldest element from the queue and returns it. // This routine will cause the thread to block if queue is currently empty. - // Argument wait_time should be passed in when trace flag turning on (for - // collecting stats info purpose.) + // Argument wait_time should be passed in when turning on the trace flag + // grpc_thread_pool_trace (for collecting stats info purpose.) void* Get(gpr_timespec* wait_time = nullptr); // Returns number of elements in queue currently. diff --git a/src/core/lib/iomgr/executor/threadpool.h b/src/core/lib/iomgr/executor/threadpool.h index d68cbbf7328..3f79bbe9d08 100644 --- a/src/core/lib/iomgr/executor/threadpool.h +++ b/src/core/lib/iomgr/executor/threadpool.h @@ -79,8 +79,6 @@ class ThreadPoolWorker { void Start() { thd_.Start(); } void Join() { thd_.Join(); } - // GRPC_ABSTRACT_BASE_CLASS - private: // struct for tracking stats of thread struct Stats { diff --git a/test/core/iomgr/threadpool_test.cc b/test/core/iomgr/threadpool_test.cc index e0a9d73f48b..4b36c3dc185 100644 --- a/test/core/iomgr/threadpool_test.cc +++ b/test/core/iomgr/threadpool_test.cc @@ -20,16 +20,16 @@ #include "test/core/util/test_config.h" -#define SMALL_THREAD_POOL_SIZE 20 -#define LARGE_THREAD_POOL_SIZE 100 -#define THREAD_SMALL_ITERATION 100 -#define THREAD_LARGE_ITERATION 10000 +const int kSmallThreadPoolSize = 20; +const int kLargeThreadPoolSize = 100; +const int kThreadSmallIter = 100; +const int kThreadLargeIter = 10000; // Simple functor for testing. It will count how many times being called. class SimpleFunctorForAdd : public grpc_experimental_completion_queue_functor { public: friend class SimpleFunctorCheckForAdd; - SimpleFunctorForAdd() : count_(0) { + SimpleFunctorForAdd() { functor_run = &SimpleFunctorForAdd::Run; internal_next = this; internal_success = 0; @@ -51,32 +51,32 @@ class SimpleFunctorForAdd : public grpc_experimental_completion_queue_functor { class SimpleFunctorCheckForAdd : public grpc_experimental_completion_queue_functor { public: - SimpleFunctorCheckForAdd( - struct grpc_experimental_completion_queue_functor* cb, int ok) { + SimpleFunctorCheckForAdd(int ok, int* count) : count_(count) { functor_run = &SimpleFunctorCheckForAdd::Run; - internal_next = cb; internal_success = ok; } ~SimpleFunctorCheckForAdd() {} static void Run(struct grpc_experimental_completion_queue_functor* cb, int ok) { auto* callback = static_cast(cb); - auto* cb_check = static_cast(callback->internal_next); - GPR_ASSERT(cb_check->count_.Load(grpc_core::MemoryOrder::RELAXED) == ok); + (*callback->count_)++; + GPR_ASSERT(*callback->count_ == callback->internal_success); } + private: + int* count_; }; static void test_add(void) { gpr_log(GPR_INFO, "test_add"); grpc_core::ThreadPool* pool = - grpc_core::New(SMALL_THREAD_POOL_SIZE, "test_add"); + grpc_core::New(kSmallThreadPoolSize, "test_add"); SimpleFunctorForAdd* functor = grpc_core::New(); - for (int i = 0; i < THREAD_SMALL_ITERATION; ++i) { + for (int i = 0; i < kThreadSmallIter; ++i) { pool->Add(functor); } grpc_core::Delete(pool); - GPR_ASSERT(functor->count() == THREAD_SMALL_ITERATION); + GPR_ASSERT(functor->count() == kThreadSmallIter); grpc_core::Delete(functor); gpr_log(GPR_DEBUG, "Done."); } @@ -108,18 +108,32 @@ class WorkThread { grpc_core::Thread thd_; }; +static void test_constructor(void) { + // Size is 0 case + grpc_core::ThreadPool* pool_size_zero = + grpc_core::New(0); + GPR_ASSERT(pool_size_zero->pool_capacity() == 0); + Delete(pool_size_zero); + // Tests options + grpc_core::Thread::Options options; + options.set_stack_size(192 * 1024); // Random non-default value + grpc_core::ThreadPool* pool = + grpc_core::New(0, "test_constructor", options); + GPR_ASSERT(pool->thread_options().stack_size() == options.stack_size()); + Delete(pool); +} + static void test_multi_add(void) { gpr_log(GPR_INFO, "test_multi_add"); const int num_work_thds = 10; grpc_core::ThreadPool* pool = grpc_core::New( - LARGE_THREAD_POOL_SIZE, "test_multi_add"); + kLargeThreadPoolSize, "test_multi_add"); SimpleFunctorForAdd* functor = grpc_core::New(); WorkThread** work_thds = static_cast( gpr_zalloc(sizeof(WorkThread*) * num_work_thds)); gpr_log(GPR_DEBUG, "Fork threads for adding..."); for (int i = 0; i < num_work_thds; ++i) { - work_thds[i] = - grpc_core::New(pool, functor, THREAD_LARGE_ITERATION); + work_thds[i] = grpc_core::New(pool, functor, kThreadLargeIter); work_thds[i]->Start(); } // Wait for all threads finish @@ -133,29 +147,27 @@ static void test_multi_add(void) { gpr_log(GPR_DEBUG, "Waiting for all closures finish..."); // Destructor of thread pool will wait for all closures to finish grpc_core::Delete(pool); - GPR_ASSERT(functor->count() == THREAD_LARGE_ITERATION * num_work_thds); + GPR_ASSERT(functor->count() == kThreadLargeIter * num_work_thds); grpc_core::Delete(functor); gpr_log(GPR_DEBUG, "Done."); } static void test_one_thread_FIFO(void) { gpr_log(GPR_INFO, "test_one_thread_FIFO"); + int counter = 0; grpc_core::ThreadPool* pool = grpc_core::New(1, "test_one_thread_FIFO"); - SimpleFunctorForAdd* functor = grpc_core::New(); SimpleFunctorCheckForAdd** check_functors = - static_cast(gpr_zalloc( - sizeof(SimpleFunctorCheckForAdd*) * THREAD_SMALL_ITERATION)); - for (int i = 0; i < THREAD_SMALL_ITERATION; ++i) { - pool->Add(functor); + static_cast( + gpr_zalloc(sizeof(SimpleFunctorCheckForAdd*) * kThreadSmallIter)); + for (int i = 0; i < kThreadSmallIter; ++i) { check_functors[i] = - grpc_core::New(functor, i + 1); + grpc_core::New(i + 1, &counter); pool->Add(check_functors[i]); } // Destructor of pool will wait until all closures finished. grpc_core::Delete(pool); - grpc_core::Delete(functor); - for (int i = 0; i < THREAD_SMALL_ITERATION; ++i) { + for (int i = 0; i < kThreadSmallIter; ++i) { grpc_core::Delete(check_functors[i]); } gpr_free(check_functors); @@ -165,6 +177,7 @@ static void test_one_thread_FIFO(void) { int main(int argc, char** argv) { grpc::testing::TestEnvironment env(argc, argv); grpc_init(); + test_constructor(); test_add(); test_multi_add(); test_one_thread_FIFO(); From ba761f77c55cd2046844f11259fc32bd42355248 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Fri, 12 Jul 2019 15:21:11 -0700 Subject: [PATCH 0879/1555] Yapf. Pylint. Long-form birth certificate. --- tools/release/verify_python_release.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/release/verify_python_release.py b/tools/release/verify_python_release.py index af2892b61a5..6cbc39982a9 100644 --- a/tools/release/verify_python_release.py +++ b/tools/release/verify_python_release.py @@ -13,7 +13,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - """Verifies that all gRPC Python artifacts have been successfully published. This script is intended to be run from a directory containing the artifacts @@ -107,8 +106,7 @@ if __name__ == "__main__": parser = argparse.ArgumentParser( "Verify a release. Run this from a directory containing only the" "artifacts to be uploaded. Note that PyPI may take several minutes" - "after the upload to reflect the proper metadata." - ) + "after the upload to reflect the proper metadata.") parser.add_argument("version") parser.add_argument( "packages", nargs='*', type=str, default=_DEFAULT_PACKAGES) From 3b380ccb58fc666c4b22515e9faa7416af0a5e11 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Fri, 12 Jul 2019 15:33:10 -0700 Subject: [PATCH 0880/1555] Added sample tvOS project and modified some podspec deployment targets --- .../RemoteTestClient/RemoteTest.podspec | 1 + src/objective-c/examples/tvOS-sample/Podfile | 31 ++ .../tvOS-sample.xcodeproj/project.pbxproj | 401 ++++++++++++++++++ .../tvOS-sample/tvOS-sample/AppDelegate.h | 17 + .../tvOS-sample/tvOS-sample/AppDelegate.m | 51 +++ .../Content.imageset/Contents.json | 11 + .../Back.imagestacklayer/Contents.json | 6 + .../Contents.json | 17 + .../Content.imageset/Contents.json | 11 + .../Front.imagestacklayer/Contents.json | 6 + .../Content.imageset/Contents.json | 11 + .../Middle.imagestacklayer/Contents.json | 6 + .../Content.imageset/Contents.json | 16 + .../Back.imagestacklayer/Contents.json | 6 + .../App Icon.imagestack/Contents.json | 17 + .../Content.imageset/Contents.json | 16 + .../Front.imagestacklayer/Contents.json | 6 + .../Content.imageset/Contents.json | 16 + .../Middle.imagestacklayer/Contents.json | 6 + .../Contents.json | 32 ++ .../Contents.json | 24 ++ .../Top Shelf Image.imageset/Contents.json | 24 ++ .../tvOS-sample/Assets.xcassets/Contents.json | 6 + .../Launch Image.launchimage/Contents.json | 22 + .../tvOS-sample/Base.lproj/Main.storyboard | 43 ++ .../tvOS-sample/tvOS-sample/Info.plist | 32 ++ .../tvOS-sample/tvOS-sample/ViewController.h | 15 + .../tvOS-sample/tvOS-sample/ViewController.m | 54 +++ .../examples/tvOS-sample/tvOS-sample/main.m | 16 + 29 files changed, 920 insertions(+) create mode 100644 src/objective-c/examples/tvOS-sample/Podfile create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.h create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Content.imageset/Contents.json create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Contents.json create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Contents.json create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Content.imageset/Contents.json create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Contents.json create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Contents.json create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Content.imageset/Contents.json create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Contents.json create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Contents.json create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Content.imageset/Contents.json create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Contents.json create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Contents.json create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/Contents.json create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/Launch Image.launchimage/Contents.json create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Base.lproj/Main.storyboard create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Info.plist create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.h create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/main.m diff --git a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec index cd9464c453e..97faa0d9236 100644 --- a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec +++ b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec @@ -9,6 +9,7 @@ Pod::Spec.new do |s| s.ios.deployment_target = '7.1' s.osx.deployment_target = '10.9' + s.tvos.deployment_target = '10.0' # Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients. s.dependency "!ProtoCompiler-gRPCPlugin" diff --git a/src/objective-c/examples/tvOS-sample/Podfile b/src/objective-c/examples/tvOS-sample/Podfile new file mode 100644 index 00000000000..20d20e27bdf --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/Podfile @@ -0,0 +1,31 @@ +platform :tvos, '10.0' + +install! 'cocoapods', :deterministic_uuids => false + +ROOT_DIR = '../../../..' + +target 'tvOS-sample' do + pod 'gRPC-ProtoRPC', :path => ROOT_DIR + pod 'gRPC', :path => ROOT_DIR + pod 'gRPC-Core', :path => ROOT_DIR + pod 'gRPC-RxLibrary', :path => ROOT_DIR + pod 'RemoteTest', :path => "../RemoteTestClient" + pod '!ProtoCompiler-gRPCPlugin', :path => "#{ROOT_DIR}/src/objective-c" +end + +pre_install do |installer| + grpc_core_spec = installer.pod_targets.find{|t| t.name.start_with?('gRPC-Core')}.root_spec + + src_root = "$(PODS_TARGET_SRCROOT)" + grpc_core_spec.pod_target_xcconfig = { + 'GRPC_SRC_ROOT' => src_root, + 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"', + 'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"', + # If we don't set these two settings, `include/grpc/support/time.h` and + # `src/core/lib/gpr/string.h` shadow the system `` and ``, breaking the + # build. + 'USE_HEADERMAP' => 'NO', + 'ALWAYS_SEARCH_USER_PATHS' => 'NO', + } +end + diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj b/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj new file mode 100644 index 00000000000..91ebf53215f --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj @@ -0,0 +1,401 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 565ABB2FA1065F0EC355A9AA /* libPods-tvOS-sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 968ABA42FAF2C82FA0BF740C /* libPods-tvOS-sample.a */; }; + ABB17D3A22D8FB8B00C26D6E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D3922D8FB8B00C26D6E /* AppDelegate.m */; }; + ABB17D3D22D8FB8B00C26D6E /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D3C22D8FB8B00C26D6E /* ViewController.m */; }; + ABB17D4022D8FB8B00C26D6E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D3E22D8FB8B00C26D6E /* Main.storyboard */; }; + ABB17D4222D8FB8D00C26D6E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D4122D8FB8D00C26D6E /* Assets.xcassets */; }; + ABB17D4522D8FB8D00C26D6E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D4422D8FB8D00C26D6E /* main.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 288D31799283F13AE615B2E7 /* Pods-tvOS-sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-tvOS-sample.debug.xcconfig"; path = "Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample.debug.xcconfig"; sourceTree = ""; }; + 68CC4CF97E776A55036CCBD2 /* Pods-tvOS-sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-tvOS-sample.release.xcconfig"; path = "Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample.release.xcconfig"; sourceTree = ""; }; + 968ABA42FAF2C82FA0BF740C /* libPods-tvOS-sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-tvOS-sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + ABB17D3522D8FB8B00C26D6E /* tvOS-sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "tvOS-sample.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + ABB17D3822D8FB8B00C26D6E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + ABB17D3922D8FB8B00C26D6E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + ABB17D3B22D8FB8B00C26D6E /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + ABB17D3C22D8FB8B00C26D6E /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + ABB17D3F22D8FB8B00C26D6E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + ABB17D4122D8FB8D00C26D6E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + ABB17D4322D8FB8D00C26D6E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + ABB17D4422D8FB8D00C26D6E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + ABB17D3222D8FB8B00C26D6E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 565ABB2FA1065F0EC355A9AA /* libPods-tvOS-sample.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 1D5885E1FE0BFAC7841076C2 /* Pods */ = { + isa = PBXGroup; + children = ( + 288D31799283F13AE615B2E7 /* Pods-tvOS-sample.debug.xcconfig */, + 68CC4CF97E776A55036CCBD2 /* Pods-tvOS-sample.release.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; + ABB17D2C22D8FB8B00C26D6E = { + isa = PBXGroup; + children = ( + ABB17D3722D8FB8B00C26D6E /* tvOS-sample */, + ABB17D3622D8FB8B00C26D6E /* Products */, + 1D5885E1FE0BFAC7841076C2 /* Pods */, + EC43163F87C0DE6118957F38 /* Frameworks */, + ); + sourceTree = ""; + }; + ABB17D3622D8FB8B00C26D6E /* Products */ = { + isa = PBXGroup; + children = ( + ABB17D3522D8FB8B00C26D6E /* tvOS-sample.app */, + ); + name = Products; + sourceTree = ""; + }; + ABB17D3722D8FB8B00C26D6E /* tvOS-sample */ = { + isa = PBXGroup; + children = ( + ABB17D3822D8FB8B00C26D6E /* AppDelegate.h */, + ABB17D3922D8FB8B00C26D6E /* AppDelegate.m */, + ABB17D3B22D8FB8B00C26D6E /* ViewController.h */, + ABB17D3C22D8FB8B00C26D6E /* ViewController.m */, + ABB17D3E22D8FB8B00C26D6E /* Main.storyboard */, + ABB17D4122D8FB8D00C26D6E /* Assets.xcassets */, + ABB17D4322D8FB8D00C26D6E /* Info.plist */, + ABB17D4422D8FB8D00C26D6E /* main.m */, + ); + path = "tvOS-sample"; + sourceTree = ""; + }; + EC43163F87C0DE6118957F38 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 968ABA42FAF2C82FA0BF740C /* libPods-tvOS-sample.a */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + ABB17D3422D8FB8B00C26D6E /* tvOS-sample */ = { + isa = PBXNativeTarget; + buildConfigurationList = ABB17D4822D8FB8D00C26D6E /* Build configuration list for PBXNativeTarget "tvOS-sample" */; + buildPhases = ( + 3963C36BEF44FBF8792B6A8A /* [CP] Check Pods Manifest.lock */, + ABB17D3122D8FB8B00C26D6E /* Sources */, + ABB17D3222D8FB8B00C26D6E /* Frameworks */, + ABB17D3322D8FB8B00C26D6E /* Resources */, + 3A325E5E27D64D1CC36130E2 /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "tvOS-sample"; + productName = "tvOS-sample"; + productReference = ABB17D3522D8FB8B00C26D6E /* tvOS-sample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + ABB17D2D22D8FB8B00C26D6E /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1010; + ORGANIZATIONNAME = "Tony Lu"; + TargetAttributes = { + ABB17D3422D8FB8B00C26D6E = { + CreatedOnToolsVersion = 10.1; + }; + }; + }; + buildConfigurationList = ABB17D3022D8FB8B00C26D6E /* Build configuration list for PBXProject "tvOS-sample" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = ABB17D2C22D8FB8B00C26D6E; + productRefGroup = ABB17D3622D8FB8B00C26D6E /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + ABB17D3422D8FB8B00C26D6E /* tvOS-sample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + ABB17D3322D8FB8B00C26D6E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ABB17D4222D8FB8D00C26D6E /* Assets.xcassets in Resources */, + ABB17D4022D8FB8B00C26D6E /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3963C36BEF44FBF8792B6A8A /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-tvOS-sample-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 3A325E5E27D64D1CC36130E2 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + ABB17D3122D8FB8B00C26D6E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ABB17D3D22D8FB8B00C26D6E /* ViewController.m in Sources */, + ABB17D4522D8FB8D00C26D6E /* main.m in Sources */, + ABB17D3A22D8FB8B00C26D6E /* AppDelegate.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + ABB17D3E22D8FB8B00C26D6E /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + ABB17D3F22D8FB8B00C26D6E /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + ABB17D4622D8FB8D00C26D6E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = appletvos; + TVOS_DEPLOYMENT_TARGET = 12.1; + }; + name = Debug; + }; + ABB17D4722D8FB8D00C26D6E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = appletvos; + TVOS_DEPLOYMENT_TARGET = 12.1; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + ABB17D4922D8FB8D00C26D6E /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 288D31799283F13AE615B2E7 /* Pods-tvOS-sample.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6T98ZJNPG5; + INFOPLIST_FILE = "tvOS-sample/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.google.tvOS-grpc-sample"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = 3; + }; + name = Debug; + }; + ABB17D4A22D8FB8D00C26D6E /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 68CC4CF97E776A55036CCBD2 /* Pods-tvOS-sample.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6T98ZJNPG5; + INFOPLIST_FILE = "tvOS-sample/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.google.tvOS-grpc-sample"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = 3; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + ABB17D3022D8FB8B00C26D6E /* Build configuration list for PBXProject "tvOS-sample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + ABB17D4622D8FB8D00C26D6E /* Debug */, + ABB17D4722D8FB8D00C26D6E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + ABB17D4822D8FB8D00C26D6E /* Build configuration list for PBXNativeTarget "tvOS-sample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + ABB17D4922D8FB8D00C26D6E /* Debug */, + ABB17D4A22D8FB8D00C26D6E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = ABB17D2D22D8FB8B00C26D6E /* Project object */; +} diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.h b/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.h new file mode 100644 index 00000000000..24f0d222e54 --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.h @@ -0,0 +1,17 @@ +// +// AppDelegate.h +// tvOS-sample +// +// Created by Tony Lu on 7/12/19. +// Copyright © 2019 Tony Lu. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m new file mode 100644 index 00000000000..e04dba4c4c1 --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m @@ -0,0 +1,51 @@ +// +// AppDelegate.m +// tvOS-sample +// +// Created by Tony Lu on 7/12/19. +// Copyright © 2019 Tony Lu. All rights reserved. +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + + +- (void)applicationWillResignActive:(UIApplication *)application { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +} + + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. +} + + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + + +@end diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Content.imageset/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Content.imageset/Contents.json new file mode 100644 index 00000000000..48ecb4fa43e --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Content.imageset/Contents.json @@ -0,0 +1,11 @@ +{ + "images" : [ + { + "idiom" : "tv" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Contents.json new file mode 100644 index 00000000000..da4a164c918 --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Contents.json new file mode 100644 index 00000000000..d29f024ed5c --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Contents.json @@ -0,0 +1,17 @@ +{ + "layers" : [ + { + "filename" : "Front.imagestacklayer" + }, + { + "filename" : "Middle.imagestacklayer" + }, + { + "filename" : "Back.imagestacklayer" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Content.imageset/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Content.imageset/Contents.json new file mode 100644 index 00000000000..48ecb4fa43e --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Content.imageset/Contents.json @@ -0,0 +1,11 @@ +{ + "images" : [ + { + "idiom" : "tv" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Contents.json new file mode 100644 index 00000000000..da4a164c918 --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json new file mode 100644 index 00000000000..48ecb4fa43e --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json @@ -0,0 +1,11 @@ +{ + "images" : [ + { + "idiom" : "tv" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Contents.json new file mode 100644 index 00000000000..da4a164c918 --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Content.imageset/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Content.imageset/Contents.json new file mode 100644 index 00000000000..16a370df014 --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Content.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "idiom" : "tv", + "scale" : "1x" + }, + { + "idiom" : "tv", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Contents.json new file mode 100644 index 00000000000..da4a164c918 --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Contents.json new file mode 100644 index 00000000000..d29f024ed5c --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Contents.json @@ -0,0 +1,17 @@ +{ + "layers" : [ + { + "filename" : "Front.imagestacklayer" + }, + { + "filename" : "Middle.imagestacklayer" + }, + { + "filename" : "Back.imagestacklayer" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Content.imageset/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Content.imageset/Contents.json new file mode 100644 index 00000000000..16a370df014 --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Content.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "idiom" : "tv", + "scale" : "1x" + }, + { + "idiom" : "tv", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Contents.json new file mode 100644 index 00000000000..da4a164c918 --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json new file mode 100644 index 00000000000..16a370df014 --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "idiom" : "tv", + "scale" : "1x" + }, + { + "idiom" : "tv", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Contents.json new file mode 100644 index 00000000000..da4a164c918 --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json new file mode 100644 index 00000000000..db288f368f1 --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json @@ -0,0 +1,32 @@ +{ + "assets" : [ + { + "size" : "1280x768", + "idiom" : "tv", + "filename" : "App Icon - App Store.imagestack", + "role" : "primary-app-icon" + }, + { + "size" : "400x240", + "idiom" : "tv", + "filename" : "App Icon.imagestack", + "role" : "primary-app-icon" + }, + { + "size" : "2320x720", + "idiom" : "tv", + "filename" : "Top Shelf Image Wide.imageset", + "role" : "top-shelf-image-wide" + }, + { + "size" : "1920x720", + "idiom" : "tv", + "filename" : "Top Shelf Image.imageset", + "role" : "top-shelf-image" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json new file mode 100644 index 00000000000..7dc95020229 --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json @@ -0,0 +1,24 @@ +{ + "images" : [ + { + "idiom" : "tv", + "scale" : "1x" + }, + { + "idiom" : "tv", + "scale" : "2x" + }, + { + "idiom" : "tv-marketing", + "scale" : "1x" + }, + { + "idiom" : "tv-marketing", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json new file mode 100644 index 00000000000..7dc95020229 --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json @@ -0,0 +1,24 @@ +{ + "images" : [ + { + "idiom" : "tv", + "scale" : "1x" + }, + { + "idiom" : "tv", + "scale" : "2x" + }, + { + "idiom" : "tv-marketing", + "scale" : "1x" + }, + { + "idiom" : "tv-marketing", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/Contents.json new file mode 100644 index 00000000000..da4a164c918 --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/Launch Image.launchimage/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/Launch Image.launchimage/Contents.json new file mode 100644 index 00000000000..d746a609003 --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/Launch Image.launchimage/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "orientation" : "landscape", + "idiom" : "tv", + "extent" : "full-screen", + "minimum-system-version" : "11.0", + "scale" : "2x" + }, + { + "orientation" : "landscape", + "idiom" : "tv", + "extent" : "full-screen", + "minimum-system-version" : "9.0", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Base.lproj/Main.storyboard b/src/objective-c/examples/tvOS-sample/tvOS-sample/Base.lproj/Main.storyboard new file mode 100644 index 00000000000..783cc4062b3 --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Base.lproj/Main.storyboard @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Info.plist b/src/objective-c/examples/tvOS-sample/tvOS-sample/Info.plist new file mode 100644 index 00000000000..02942a34f3e --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + arm64 + + UIUserInterfaceStyle + Automatic + + diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.h b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.h new file mode 100644 index 00000000000..703e8bdb36e --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.h @@ -0,0 +1,15 @@ +// +// ViewController.h +// tvOS-sample +// +// Created by Tony Lu on 7/12/19. +// Copyright © 2019 Tony Lu. All rights reserved. +// + +#import + +@interface ViewController : UIViewController + + +@end + diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m new file mode 100644 index 00000000000..1a733523f50 --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m @@ -0,0 +1,54 @@ +// +// ViewController.m +// tvOS-sample +// +// Created by Tony Lu on 7/12/19. +// Copyright © 2019 Tony Lu. All rights reserved. +// + +#import "ViewController.h" + +#import +#import + + +static NSString *const kPackage = @"grpc.testing"; +static NSString *const kService = @"TestService"; + +@interface ViewController () + +@end + +@implementation ViewController { + GRPCCallOptions *_options; + RMTTestService *_service; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + _options = options; + + _service = [[RMTTestService alloc] initWithHost:@"grpc-test.sandbox.googleapis.com" + callOptions:_options]; +} + +- (IBAction)makeCall:(id)sender { + RMTSimpleRequest *request = [RMTSimpleRequest message]; + request.responseSize = 100; + GRPCUnaryProtoCall *call = [_service unaryCallWithMessage:request + responseHandler:self + callOptions:nil]; + [call start]; +} + +- (void)didReceiveProtoMessage:(GPBMessage *)message { + NSLog(@"%@", [message data]); +} + +- (dispatch_queue_t)dispatchQueue { + return dispatch_get_main_queue(); +} + +@end diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/main.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/main.m new file mode 100644 index 00000000000..f18a9db860e --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/main.m @@ -0,0 +1,16 @@ +// +// main.m +// tvOS-sample +// +// Created by Tony Lu on 7/12/19. +// Copyright © 2019 Tony Lu. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} From a381dea062ab3fb62d0d0763ffc75dff30abad72 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 12 Jul 2019 17:08:16 -0700 Subject: [PATCH 0881/1555] reformat --- test/core/iomgr/threadpool_test.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/test/core/iomgr/threadpool_test.cc b/test/core/iomgr/threadpool_test.cc index 4b36c3dc185..9c678fa4304 100644 --- a/test/core/iomgr/threadpool_test.cc +++ b/test/core/iomgr/threadpool_test.cc @@ -62,6 +62,7 @@ class SimpleFunctorCheckForAdd (*callback->count_)++; GPR_ASSERT(*callback->count_ == callback->internal_success); } + private: int* count_; }; From 90dac25693c18888982de6408779cc92a21106f1 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Fri, 12 Jul 2019 17:21:35 -0700 Subject: [PATCH 0882/1555] Added watchOS sample --- gRPC-Core.podspec | 1 + gRPC-ProtoRPC.podspec | 1 + gRPC-RxLibrary.podspec | 1 + gRPC.podspec | 1 + .../!ProtoCompiler-gRPCPlugin.podspec | 1 + src/objective-c/!ProtoCompiler.podspec | 1 + src/objective-c/BoringSSL-GRPC.podspec | 1 + .../RemoteTestClient/RemoteTest.podspec | 1 + .../tvOS-sample.xcodeproj/project.pbxproj | 68 +- .../tvOS-sample/tvOS-sample/ViewController.m | 4 - .../examples/watchOS-sample/Podfile | 41 + .../AppIcon.appiconset/Contents.json | 81 ++ .../Assets.xcassets/Contents.json | 6 + .../Base.lproj/Interface.storyboard | 27 + .../watchOS-sample WatchKit App/Info.plist | 33 + .../Circular.imageset/Contents.json | 18 + .../Contents.json | 48 ++ .../Extra Large.imageset/Contents.json | 18 + .../Graphic Bezel.imageset/Contents.json | 18 + .../Graphic Circular.imageset/Contents.json | 18 + .../Graphic Corner.imageset/Contents.json | 18 + .../Contents.json | 18 + .../Modular.imageset/Contents.json | 18 + .../Utilitarian.imageset/Contents.json | 18 + .../Assets.xcassets/Contents.json | 6 + .../ExtensionDelegate.h | 13 + .../ExtensionDelegate.m | 61 ++ .../Info.plist | 36 + .../InterfaceController.h | 14 + .../InterfaceController.m | 68 ++ .../watchOS-sample.xcodeproj/project.pbxproj | 750 ++++++++++++++++++ .../watchOS-sample/AppDelegate.h | 17 + .../watchOS-sample/AppDelegate.m | 51 ++ .../AppIcon.appiconset/Contents.json | 98 +++ .../Assets.xcassets/Contents.json | 6 + .../Base.lproj/LaunchScreen.storyboard | 25 + .../watchOS-sample/Base.lproj/Main.storyboard | 24 + .../watchOS-sample/watchOS-sample/Info.plist | 45 ++ .../watchOS-sample/ViewController.h | 15 + .../watchOS-sample/ViewController.m | 25 + .../watchOS-sample/watchOS-sample/main.m | 16 + 41 files changed, 1692 insertions(+), 38 deletions(-) create mode 100644 src/objective-c/examples/watchOS-sample/Podfile create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Assets.xcassets/Contents.json create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Base.lproj/Interface.storyboard create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Info.plist create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Contents.json create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Contents.json create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.h create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.m create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Info.plist create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.h create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.m create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.h create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample/Assets.xcassets/Contents.json create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample/Base.lproj/LaunchScreen.storyboard create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample/Base.lproj/Main.storyboard create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample/Info.plist create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.h create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample/main.m diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 2dfcb311b5d..4dee494b6b5 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -41,6 +41,7 @@ Pod::Spec.new do |s| s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '4.0' s.requires_arc = false diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 2c0441ba95c..62bff003934 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -36,6 +36,7 @@ Pod::Spec.new do |s| s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '4.0' name = 'ProtoRPC' s.module_name = name diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 12a8728ac34..e9a19ac65df 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -36,6 +36,7 @@ Pod::Spec.new do |s| s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '4.0' name = 'RxLibrary' s.module_name = name diff --git a/gRPC.podspec b/gRPC.podspec index bbfd08f9774..0374e525b0d 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -35,6 +35,7 @@ Pod::Spec.new do |s| s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '4.0' name = 'GRPCClient' s.module_name = name diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 939078def22..ec88ee7a5af 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -106,6 +106,7 @@ Pod::Spec.new do |s| s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '4.0' # Restrict the gRPC runtime version to the one supported by this plugin. s.dependency 'gRPC-ProtoRPC', v diff --git a/src/objective-c/!ProtoCompiler.podspec b/src/objective-c/!ProtoCompiler.podspec index d8ce4d8e89d..b75d93a58be 100644 --- a/src/objective-c/!ProtoCompiler.podspec +++ b/src/objective-c/!ProtoCompiler.podspec @@ -113,6 +113,7 @@ Pod::Spec.new do |s| s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '4.0' # This is only for local development of protoc: If the Podfile brings this pod from a local # directory using `:path`, CocoaPods won't download the zip file and so the compiler won't be diff --git a/src/objective-c/BoringSSL-GRPC.podspec b/src/objective-c/BoringSSL-GRPC.podspec index 2ec146e7ebe..f0d9750d6d1 100644 --- a/src/objective-c/BoringSSL-GRPC.podspec +++ b/src/objective-c/BoringSSL-GRPC.podspec @@ -82,6 +82,7 @@ Pod::Spec.new do |s| s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.7' s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '4.0' name = 'openssl_grpc' diff --git a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec index 97faa0d9236..63c6ba4ad5c 100644 --- a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec +++ b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec @@ -10,6 +10,7 @@ Pod::Spec.new do |s| s.ios.deployment_target = '7.1' s.osx.deployment_target = '10.9' s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '4.0' # Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients. s.dependency "!ProtoCompiler-gRPCPlugin" diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj b/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj index 91ebf53215f..8840882b145 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj @@ -7,18 +7,17 @@ objects = { /* Begin PBXBuildFile section */ - 565ABB2FA1065F0EC355A9AA /* libPods-tvOS-sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 968ABA42FAF2C82FA0BF740C /* libPods-tvOS-sample.a */; }; ABB17D3A22D8FB8B00C26D6E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D3922D8FB8B00C26D6E /* AppDelegate.m */; }; ABB17D3D22D8FB8B00C26D6E /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D3C22D8FB8B00C26D6E /* ViewController.m */; }; ABB17D4022D8FB8B00C26D6E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D3E22D8FB8B00C26D6E /* Main.storyboard */; }; ABB17D4222D8FB8D00C26D6E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D4122D8FB8D00C26D6E /* Assets.xcassets */; }; ABB17D4522D8FB8D00C26D6E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D4422D8FB8D00C26D6E /* main.m */; }; + F9B775DB1DDCBD39DF92BFA8 /* libPods-tvOS-sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 40071025CBF9E79B9522398F /* libPods-tvOS-sample.a */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 288D31799283F13AE615B2E7 /* Pods-tvOS-sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-tvOS-sample.debug.xcconfig"; path = "Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample.debug.xcconfig"; sourceTree = ""; }; - 68CC4CF97E776A55036CCBD2 /* Pods-tvOS-sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-tvOS-sample.release.xcconfig"; path = "Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample.release.xcconfig"; sourceTree = ""; }; - 968ABA42FAF2C82FA0BF740C /* libPods-tvOS-sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-tvOS-sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 40071025CBF9E79B9522398F /* libPods-tvOS-sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-tvOS-sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 93F3CF0DB110860F8E180685 /* Pods-tvOS-sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-tvOS-sample.release.xcconfig"; path = "Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample.release.xcconfig"; sourceTree = ""; }; ABB17D3522D8FB8B00C26D6E /* tvOS-sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "tvOS-sample.app"; sourceTree = BUILT_PRODUCTS_DIR; }; ABB17D3822D8FB8B00C26D6E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; ABB17D3922D8FB8B00C26D6E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; @@ -28,6 +27,7 @@ ABB17D4122D8FB8D00C26D6E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; ABB17D4322D8FB8D00C26D6E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; ABB17D4422D8FB8D00C26D6E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + D2D1C60CE9BD00C1371BC913 /* Pods-tvOS-sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-tvOS-sample.debug.xcconfig"; path = "Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -35,18 +35,18 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 565ABB2FA1065F0EC355A9AA /* libPods-tvOS-sample.a in Frameworks */, + F9B775DB1DDCBD39DF92BFA8 /* libPods-tvOS-sample.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 1D5885E1FE0BFAC7841076C2 /* Pods */ = { + 28FD2EFD84992131D85ADAE6 /* Pods */ = { isa = PBXGroup; children = ( - 288D31799283F13AE615B2E7 /* Pods-tvOS-sample.debug.xcconfig */, - 68CC4CF97E776A55036CCBD2 /* Pods-tvOS-sample.release.xcconfig */, + D2D1C60CE9BD00C1371BC913 /* Pods-tvOS-sample.debug.xcconfig */, + 93F3CF0DB110860F8E180685 /* Pods-tvOS-sample.release.xcconfig */, ); name = Pods; path = Pods; @@ -57,8 +57,8 @@ children = ( ABB17D3722D8FB8B00C26D6E /* tvOS-sample */, ABB17D3622D8FB8B00C26D6E /* Products */, - 1D5885E1FE0BFAC7841076C2 /* Pods */, - EC43163F87C0DE6118957F38 /* Frameworks */, + 28FD2EFD84992131D85ADAE6 /* Pods */, + D280E557B55AAB044C083DB5 /* Frameworks */, ); sourceTree = ""; }; @@ -85,10 +85,10 @@ path = "tvOS-sample"; sourceTree = ""; }; - EC43163F87C0DE6118957F38 /* Frameworks */ = { + D280E557B55AAB044C083DB5 /* Frameworks */ = { isa = PBXGroup; children = ( - 968ABA42FAF2C82FA0BF740C /* libPods-tvOS-sample.a */, + 40071025CBF9E79B9522398F /* libPods-tvOS-sample.a */, ); name = Frameworks; sourceTree = ""; @@ -100,11 +100,11 @@ isa = PBXNativeTarget; buildConfigurationList = ABB17D4822D8FB8D00C26D6E /* Build configuration list for PBXNativeTarget "tvOS-sample" */; buildPhases = ( - 3963C36BEF44FBF8792B6A8A /* [CP] Check Pods Manifest.lock */, + BCFBD1317F97D9F34D9AFD4A /* [CP] Check Pods Manifest.lock */, ABB17D3122D8FB8B00C26D6E /* Sources */, ABB17D3222D8FB8B00C26D6E /* Frameworks */, ABB17D3322D8FB8B00C26D6E /* Resources */, - 3A325E5E27D64D1CC36130E2 /* [CP] Copy Pods Resources */, + 340B0470EBFB87C5242C058E /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -160,7 +160,24 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 3963C36BEF44FBF8792B6A8A /* [CP] Check Pods Manifest.lock */ = { + 340B0470EBFB87C5242C058E /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + BCFBD1317F97D9F34D9AFD4A /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -182,23 +199,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 3A325E5E27D64D1CC36130E2 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-resources-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-resources-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -338,7 +338,7 @@ }; ABB17D4922D8FB8D00C26D6E /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 288D31799283F13AE615B2E7 /* Pods-tvOS-sample.debug.xcconfig */; + baseConfigurationReference = D2D1C60CE9BD00C1371BC913 /* Pods-tvOS-sample.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; @@ -357,7 +357,7 @@ }; ABB17D4A22D8FB8D00C26D6E /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 68CC4CF97E776A55036CCBD2 /* Pods-tvOS-sample.release.xcconfig */; + baseConfigurationReference = 93F3CF0DB110860F8E180685 /* Pods-tvOS-sample.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m index 1a733523f50..69e1e0ce87b 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m @@ -11,10 +11,6 @@ #import #import - -static NSString *const kPackage = @"grpc.testing"; -static NSString *const kService = @"TestService"; - @interface ViewController () @end diff --git a/src/objective-c/examples/watchOS-sample/Podfile b/src/objective-c/examples/watchOS-sample/Podfile new file mode 100644 index 00000000000..60626ca493f --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/Podfile @@ -0,0 +1,41 @@ +install! 'cocoapods', :deterministic_uuids => false + +ROOT_DIR = '../../../..' + +def grpc_deps + pod 'gRPC-ProtoRPC', :path => ROOT_DIR + pod 'gRPC', :path => ROOT_DIR + pod 'gRPC-Core', :path => ROOT_DIR + pod 'gRPC-RxLibrary', :path => ROOT_DIR + pod 'RemoteTest', :path => "../RemoteTestClient" + pod '!ProtoCompiler-gRPCPlugin', :path => "#{ROOT_DIR}/src/objective-c" + pod 'BoringSSL-GRPC', :path => "#{ROOT_DIR}/third_party/boringssl" + pod '!ProtoCompiler', :path => "#{ROOT_DIR}/src/objective-c" +end + +target 'watchOS-sample' do +platform :ios, '8.0' + grpc_deps +end + +target 'watchOS-sample WatchKit Extension' do +platform :watchos, '4.0' + grpc_deps +end + +pre_install do |installer| + grpc_core_spec = installer.pod_targets.find{|t| t.name.start_with?('gRPC-Core')}.root_spec + + src_root = "$(PODS_TARGET_SRCROOT)" + grpc_core_spec.pod_target_xcconfig = { + 'GRPC_SRC_ROOT' => src_root, + 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"', + 'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"', + # If we don't set these two settings, `include/grpc/support/time.h` and + # `src/core/lib/gpr/string.h` shadow the system `` and ``, breaking the + # build. + 'USE_HEADERMAP' => 'NO', + 'ALWAYS_SEARCH_USER_PATHS' => 'NO', + } +end + diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Assets.xcassets/AppIcon.appiconset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000000..6c0f2b4204b --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,81 @@ +{ + "images" : [ + { + "size" : "24x24", + "idiom" : "watch", + "scale" : "2x", + "role" : "notificationCenter", + "subtype" : "38mm" + }, + { + "size" : "27.5x27.5", + "idiom" : "watch", + "scale" : "2x", + "role" : "notificationCenter", + "subtype" : "42mm" + }, + { + "size" : "29x29", + "idiom" : "watch", + "role" : "companionSettings", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "watch", + "role" : "companionSettings", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "watch", + "scale" : "2x", + "role" : "appLauncher", + "subtype" : "38mm" + }, + { + "size" : "44x44", + "idiom" : "watch", + "scale" : "2x", + "role" : "appLauncher", + "subtype" : "40mm" + }, + { + "size" : "50x50", + "idiom" : "watch", + "scale" : "2x", + "role" : "appLauncher", + "subtype" : "44mm" + }, + { + "size" : "86x86", + "idiom" : "watch", + "scale" : "2x", + "role" : "quickLook", + "subtype" : "38mm" + }, + { + "size" : "98x98", + "idiom" : "watch", + "scale" : "2x", + "role" : "quickLook", + "subtype" : "42mm" + }, + { + "size" : "108x108", + "idiom" : "watch", + "scale" : "2x", + "role" : "quickLook", + "subtype" : "44mm" + }, + { + "idiom" : "watch-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Assets.xcassets/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Assets.xcassets/Contents.json new file mode 100644 index 00000000000..da4a164c918 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Base.lproj/Interface.storyboard b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Base.lproj/Interface.storyboard new file mode 100644 index 00000000000..6c4d9248113 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Base.lproj/Interface.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Info.plist b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Info.plist new file mode 100644 index 00000000000..68081b1f6e0 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Info.plist @@ -0,0 +1,33 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + watchOS-sample WatchKit App + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + + WKCompanionAppBundleIdentifier + com.google.watchOS-grpc-sample + WKWatchKitApp + + + diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json new file mode 100644 index 00000000000..f84499ba516 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json @@ -0,0 +1,18 @@ +{ + "images" : [ + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : "<=145" + }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">145" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Contents.json new file mode 100644 index 00000000000..1571c7e531b --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Contents.json @@ -0,0 +1,48 @@ +{ + "assets" : [ + { + "idiom" : "watch", + "filename" : "Circular.imageset", + "role" : "circular" + }, + { + "idiom" : "watch", + "filename" : "Extra Large.imageset", + "role" : "extra-large" + }, + { + "idiom" : "watch", + "filename" : "Graphic Bezel.imageset", + "role" : "graphic-bezel" + }, + { + "idiom" : "watch", + "filename" : "Graphic Circular.imageset", + "role" : "graphic-circular" + }, + { + "idiom" : "watch", + "filename" : "Graphic Corner.imageset", + "role" : "graphic-corner" + }, + { + "idiom" : "watch", + "filename" : "Graphic Large Rectangular.imageset", + "role" : "graphic-large-rectangular" + }, + { + "idiom" : "watch", + "filename" : "Modular.imageset", + "role" : "modular" + }, + { + "idiom" : "watch", + "filename" : "Utilitarian.imageset", + "role" : "utilitarian" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json new file mode 100644 index 00000000000..f84499ba516 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json @@ -0,0 +1,18 @@ +{ + "images" : [ + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : "<=145" + }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">145" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json new file mode 100644 index 00000000000..f84499ba516 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json @@ -0,0 +1,18 @@ +{ + "images" : [ + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : "<=145" + }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">145" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json new file mode 100644 index 00000000000..f84499ba516 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json @@ -0,0 +1,18 @@ +{ + "images" : [ + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : "<=145" + }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">145" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json new file mode 100644 index 00000000000..f84499ba516 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json @@ -0,0 +1,18 @@ +{ + "images" : [ + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : "<=145" + }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">145" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json new file mode 100644 index 00000000000..f84499ba516 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json @@ -0,0 +1,18 @@ +{ + "images" : [ + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : "<=145" + }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">145" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json new file mode 100644 index 00000000000..f84499ba516 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json @@ -0,0 +1,18 @@ +{ + "images" : [ + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : "<=145" + }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">145" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json new file mode 100644 index 00000000000..f84499ba516 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json @@ -0,0 +1,18 @@ +{ + "images" : [ + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : "<=145" + }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">145" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Contents.json new file mode 100644 index 00000000000..da4a164c918 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.h b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.h new file mode 100644 index 00000000000..df2e8e156b6 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.h @@ -0,0 +1,13 @@ +// +// ExtensionDelegate.h +// watchOS-sample WatchKit Extension +// +// Created by Tony Lu on 7/12/19. +// Copyright © 2019 Tony Lu. All rights reserved. +// + +#import + +@interface ExtensionDelegate : NSObject + +@end diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.m b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.m new file mode 100644 index 00000000000..97d553aa855 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.m @@ -0,0 +1,61 @@ +// +// ExtensionDelegate.m +// watchOS-sample WatchKit Extension +// +// Created by Tony Lu on 7/12/19. +// Copyright © 2019 Tony Lu. All rights reserved. +// + +#import "ExtensionDelegate.h" + +@implementation ExtensionDelegate + +- (void)applicationDidFinishLaunching { + // Perform any final initialization of your application. +} + +- (void)applicationDidBecomeActive { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillResignActive { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, etc. +} + +- (void)handleBackgroundTasks:(NSSet *)backgroundTasks { + // Sent when the system needs to launch the application in the background to process tasks. Tasks arrive in a set, so loop through and process each one. + for (WKRefreshBackgroundTask * task in backgroundTasks) { + // Check the Class of each task to decide how to process it + if ([task isKindOfClass:[WKApplicationRefreshBackgroundTask class]]) { + // Be sure to complete the background task once you’re done. + WKApplicationRefreshBackgroundTask *backgroundTask = (WKApplicationRefreshBackgroundTask*)task; + [backgroundTask setTaskCompletedWithSnapshot:NO]; + } else if ([task isKindOfClass:[WKSnapshotRefreshBackgroundTask class]]) { + // Snapshot tasks have a unique completion call, make sure to set your expiration date + WKSnapshotRefreshBackgroundTask *snapshotTask = (WKSnapshotRefreshBackgroundTask*)task; + [snapshotTask setTaskCompletedWithDefaultStateRestored:YES estimatedSnapshotExpiration:[NSDate distantFuture] userInfo:nil]; + } else if ([task isKindOfClass:[WKWatchConnectivityRefreshBackgroundTask class]]) { + // Be sure to complete the background task once you’re done. + WKWatchConnectivityRefreshBackgroundTask *backgroundTask = (WKWatchConnectivityRefreshBackgroundTask*)task; + [backgroundTask setTaskCompletedWithSnapshot:NO]; + } else if ([task isKindOfClass:[WKURLSessionRefreshBackgroundTask class]]) { + // Be sure to complete the background task once you’re done. + WKURLSessionRefreshBackgroundTask *backgroundTask = (WKURLSessionRefreshBackgroundTask*)task; + [backgroundTask setTaskCompletedWithSnapshot:NO]; + } else if ([task isKindOfClass:[WKRelevantShortcutRefreshBackgroundTask class]]) { + // Be sure to complete the relevant-shortcut task once you’re done. + WKRelevantShortcutRefreshBackgroundTask *relevantShortcutTask = (WKRelevantShortcutRefreshBackgroundTask*)task; + [relevantShortcutTask setTaskCompletedWithSnapshot:NO]; + } else if ([task isKindOfClass:[WKIntentDidRunRefreshBackgroundTask class]]) { + // Be sure to complete the intent-did-run task once you’re done. + WKIntentDidRunRefreshBackgroundTask *intentDidRunTask = (WKIntentDidRunRefreshBackgroundTask*)task; + [intentDidRunTask setTaskCompletedWithSnapshot:NO]; + } else { + // make sure to complete unhandled task types + [task setTaskCompletedWithSnapshot:NO]; + } + } +} + +@end diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Info.plist b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Info.plist new file mode 100644 index 00000000000..457a48af2d8 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Info.plist @@ -0,0 +1,36 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + watchOS-sample WatchKit Extension + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + XPC! + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + NSExtension + + NSExtensionAttributes + + WKAppBundleIdentifier + com.google.watchOS-grpc-sample.watchkitapp + + NSExtensionPointIdentifier + com.apple.watchkit + + WKExtensionDelegateClassName + ExtensionDelegate + + diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.h b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.h new file mode 100644 index 00000000000..cd5752bcc5c --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.h @@ -0,0 +1,14 @@ +// +// InterfaceController.h +// watchOS-sample WatchKit Extension +// +// Created by Tony Lu on 7/12/19. +// Copyright © 2019 Tony Lu. All rights reserved. +// + +#import +#import + +@interface InterfaceController : WKInterfaceController + +@end diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.m b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.m new file mode 100644 index 00000000000..9722a80ca50 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.m @@ -0,0 +1,68 @@ +// +// InterfaceController.m +// watchOS-sample WatchKit Extension +// +// Created by Tony Lu on 7/12/19. +// Copyright © 2019 Tony Lu. All rights reserved. +// + +#import "InterfaceController.h" + +#import +#import + +@interface InterfaceController () + +@end + + +@implementation InterfaceController { + GRPCCallOptions *_options; + RMTTestService *_service; +} + +- (void)awakeWithContext:(id)context { + [super awakeWithContext:context]; + + // Configure interface objects here. + + + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + _options = options; + + _service = [[RMTTestService alloc] initWithHost:@"grpc-test.sandbox.googleapis.com" + callOptions:_options]; +} + +- (void)willActivate { + // This method is called when watch view controller is about to be visible to user + [super willActivate]; +} + +- (void)didDeactivate { + // This method is called when watch view controller is no longer visible + [super didDeactivate]; +} + +- (IBAction)makeCall { + + RMTSimpleRequest *request = [RMTSimpleRequest message]; + request.responseSize = 100; + GRPCUnaryProtoCall *call = [_service unaryCallWithMessage:request + responseHandler:self + callOptions:nil]; + [call start]; +} + +- (void)didReceiveProtoMessage:(GPBMessage *)message { + NSLog(@"%@", [message data]); +} + +- (dispatch_queue_t)dispatchQueue { + return dispatch_get_main_queue(); +} + +@end + + + diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj new file mode 100644 index 00000000000..12e7f29b7a0 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj @@ -0,0 +1,750 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 51; + objects = { + +/* Begin PBXBuildFile section */ + 8C710D86B987697CC3B243A8 /* libPods-watchOS-sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 56BDF7E8B01683A4EFDEC9CF /* libPods-watchOS-sample.a */; }; + 8F4EFFA8E14960D3C5BD0046 /* libPods-watchOS-sample WatchKit Extension.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 76AFD66D880975F945E377C9 /* libPods-watchOS-sample WatchKit Extension.a */; }; + ABB17D5922D93BAB00C26D6E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D5822D93BAB00C26D6E /* AppDelegate.m */; }; + ABB17D5C22D93BAB00C26D6E /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D5B22D93BAB00C26D6E /* ViewController.m */; }; + ABB17D5F22D93BAB00C26D6E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D5D22D93BAB00C26D6E /* Main.storyboard */; }; + ABB17D6122D93BAC00C26D6E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D6022D93BAC00C26D6E /* Assets.xcassets */; }; + ABB17D6422D93BAC00C26D6E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D6222D93BAC00C26D6E /* LaunchScreen.storyboard */; }; + ABB17D6722D93BAC00C26D6E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D6622D93BAC00C26D6E /* main.m */; }; + ABB17D6B22D93BAC00C26D6E /* watchOS-sample WatchKit App.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = ABB17D6A22D93BAC00C26D6E /* watchOS-sample WatchKit App.app */; }; + ABB17D7122D93BAC00C26D6E /* Interface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D6F22D93BAC00C26D6E /* Interface.storyboard */; }; + ABB17D7322D93BAC00C26D6E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D7222D93BAC00C26D6E /* Assets.xcassets */; }; + ABB17D7A22D93BAC00C26D6E /* watchOS-sample WatchKit Extension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = ABB17D7922D93BAC00C26D6E /* watchOS-sample WatchKit Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + ABB17D8022D93BAC00C26D6E /* InterfaceController.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D7F22D93BAC00C26D6E /* InterfaceController.m */; }; + ABB17D8322D93BAC00C26D6E /* ExtensionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D8222D93BAC00C26D6E /* ExtensionDelegate.m */; }; + ABB17D8522D93BAD00C26D6E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D8422D93BAD00C26D6E /* Assets.xcassets */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + ABB17D6C22D93BAC00C26D6E /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = ABB17D4C22D93BAB00C26D6E /* Project object */; + proxyType = 1; + remoteGlobalIDString = ABB17D6922D93BAC00C26D6E; + remoteInfo = "watchOS-sample WatchKit App"; + }; + ABB17D7B22D93BAC00C26D6E /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = ABB17D4C22D93BAB00C26D6E /* Project object */; + proxyType = 1; + remoteGlobalIDString = ABB17D7822D93BAC00C26D6E; + remoteInfo = "watchOS-sample WatchKit Extension"; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + ABB17D8C22D93BAD00C26D6E /* Embed App Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + ABB17D7A22D93BAC00C26D6E /* watchOS-sample WatchKit Extension.appex in Embed App Extensions */, + ); + name = "Embed App Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; + ABB17D9022D93BAD00C26D6E /* Embed Watch Content */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "$(CONTENTS_FOLDER_PATH)/Watch"; + dstSubfolderSpec = 16; + files = ( + ABB17D6B22D93BAC00C26D6E /* watchOS-sample WatchKit App.app in Embed Watch Content */, + ); + name = "Embed Watch Content"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 0D53169393FEB36944484D25 /* Pods-watchOS-sample WatchKit Extension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample WatchKit Extension.release.xcconfig"; path = "Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension.release.xcconfig"; sourceTree = ""; }; + 56BDF7E8B01683A4EFDEC9CF /* libPods-watchOS-sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-watchOS-sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 76AFD66D880975F945E377C9 /* libPods-watchOS-sample WatchKit Extension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-watchOS-sample WatchKit Extension.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 7DB8462D385A70A534800DAF /* Pods-watchOS-sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample.release.xcconfig"; path = "Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample.release.xcconfig"; sourceTree = ""; }; + 8C5540E3A034586596BEFE2B /* Pods-watchOS-sample WatchKit Extension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample WatchKit Extension.debug.xcconfig"; path = "Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension.debug.xcconfig"; sourceTree = ""; }; + ABB17D5422D93BAB00C26D6E /* watchOS-sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "watchOS-sample.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + ABB17D5722D93BAB00C26D6E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + ABB17D5822D93BAB00C26D6E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + ABB17D5A22D93BAB00C26D6E /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + ABB17D5B22D93BAB00C26D6E /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + ABB17D5E22D93BAB00C26D6E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + ABB17D6022D93BAC00C26D6E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + ABB17D6322D93BAC00C26D6E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + ABB17D6522D93BAC00C26D6E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + ABB17D6622D93BAC00C26D6E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + ABB17D6A22D93BAC00C26D6E /* watchOS-sample WatchKit App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "watchOS-sample WatchKit App.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + ABB17D7022D93BAC00C26D6E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Interface.storyboard; sourceTree = ""; }; + ABB17D7222D93BAC00C26D6E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + ABB17D7422D93BAC00C26D6E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + ABB17D7922D93BAC00C26D6E /* watchOS-sample WatchKit Extension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "watchOS-sample WatchKit Extension.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; + ABB17D7E22D93BAC00C26D6E /* InterfaceController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InterfaceController.h; sourceTree = ""; }; + ABB17D7F22D93BAC00C26D6E /* InterfaceController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InterfaceController.m; sourceTree = ""; }; + ABB17D8122D93BAC00C26D6E /* ExtensionDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExtensionDelegate.h; sourceTree = ""; }; + ABB17D8222D93BAC00C26D6E /* ExtensionDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ExtensionDelegate.m; sourceTree = ""; }; + ABB17D8422D93BAD00C26D6E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + ABB17D8622D93BAD00C26D6E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + CC865626944D2C3DD838F762 /* Pods-watchOS-sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample.debug.xcconfig"; path = "Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample.debug.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + ABB17D5122D93BAB00C26D6E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8C710D86B987697CC3B243A8 /* libPods-watchOS-sample.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + ABB17D7622D93BAC00C26D6E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8F4EFFA8E14960D3C5BD0046 /* libPods-watchOS-sample WatchKit Extension.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + F374C9EC9D24282B20A64719 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 2C4A0708747AAA7298F757DA /* Pods */ = { + isa = PBXGroup; + children = ( + CC865626944D2C3DD838F762 /* Pods-watchOS-sample.debug.xcconfig */, + 7DB8462D385A70A534800DAF /* Pods-watchOS-sample.release.xcconfig */, + 8C5540E3A034586596BEFE2B /* Pods-watchOS-sample WatchKit Extension.debug.xcconfig */, + 0D53169393FEB36944484D25 /* Pods-watchOS-sample WatchKit Extension.release.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; + 589283F4A582EEF2434E0220 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 56BDF7E8B01683A4EFDEC9CF /* libPods-watchOS-sample.a */, + 76AFD66D880975F945E377C9 /* libPods-watchOS-sample WatchKit Extension.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + ABB17D4B22D93BAB00C26D6E = { + isa = PBXGroup; + children = ( + ABB17D5622D93BAB00C26D6E /* watchOS-sample */, + ABB17D6E22D93BAC00C26D6E /* watchOS-sample WatchKit App */, + ABB17D7D22D93BAC00C26D6E /* watchOS-sample WatchKit Extension */, + ABB17D5522D93BAB00C26D6E /* Products */, + 2C4A0708747AAA7298F757DA /* Pods */, + 589283F4A582EEF2434E0220 /* Frameworks */, + ); + sourceTree = ""; + }; + ABB17D5522D93BAB00C26D6E /* Products */ = { + isa = PBXGroup; + children = ( + ABB17D5422D93BAB00C26D6E /* watchOS-sample.app */, + ABB17D6A22D93BAC00C26D6E /* watchOS-sample WatchKit App.app */, + ABB17D7922D93BAC00C26D6E /* watchOS-sample WatchKit Extension.appex */, + ); + name = Products; + sourceTree = ""; + }; + ABB17D5622D93BAB00C26D6E /* watchOS-sample */ = { + isa = PBXGroup; + children = ( + ABB17D5722D93BAB00C26D6E /* AppDelegate.h */, + ABB17D5822D93BAB00C26D6E /* AppDelegate.m */, + ABB17D5A22D93BAB00C26D6E /* ViewController.h */, + ABB17D5B22D93BAB00C26D6E /* ViewController.m */, + ABB17D5D22D93BAB00C26D6E /* Main.storyboard */, + ABB17D6022D93BAC00C26D6E /* Assets.xcassets */, + ABB17D6222D93BAC00C26D6E /* LaunchScreen.storyboard */, + ABB17D6522D93BAC00C26D6E /* Info.plist */, + ABB17D6622D93BAC00C26D6E /* main.m */, + ); + path = "watchOS-sample"; + sourceTree = ""; + }; + ABB17D6E22D93BAC00C26D6E /* watchOS-sample WatchKit App */ = { + isa = PBXGroup; + children = ( + ABB17D6F22D93BAC00C26D6E /* Interface.storyboard */, + ABB17D7222D93BAC00C26D6E /* Assets.xcassets */, + ABB17D7422D93BAC00C26D6E /* Info.plist */, + ); + path = "watchOS-sample WatchKit App"; + sourceTree = ""; + }; + ABB17D7D22D93BAC00C26D6E /* watchOS-sample WatchKit Extension */ = { + isa = PBXGroup; + children = ( + ABB17D7E22D93BAC00C26D6E /* InterfaceController.h */, + ABB17D7F22D93BAC00C26D6E /* InterfaceController.m */, + ABB17D8122D93BAC00C26D6E /* ExtensionDelegate.h */, + ABB17D8222D93BAC00C26D6E /* ExtensionDelegate.m */, + ABB17D8422D93BAD00C26D6E /* Assets.xcassets */, + ABB17D8622D93BAD00C26D6E /* Info.plist */, + ); + path = "watchOS-sample WatchKit Extension"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + ABB17D5322D93BAB00C26D6E /* watchOS-sample */ = { + isa = PBXNativeTarget; + buildConfigurationList = ABB17D9122D93BAD00C26D6E /* Build configuration list for PBXNativeTarget "watchOS-sample" */; + buildPhases = ( + 94316399D2F0BC04388E77B0 /* [CP] Check Pods Manifest.lock */, + ABB17D5022D93BAB00C26D6E /* Sources */, + ABB17D5122D93BAB00C26D6E /* Frameworks */, + ABB17D5222D93BAB00C26D6E /* Resources */, + ABB17D9022D93BAD00C26D6E /* Embed Watch Content */, + 1E38C9CB686CAEF71A5A25B7 /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ABB17D6D22D93BAC00C26D6E /* PBXTargetDependency */, + ); + name = "watchOS-sample"; + productName = "watchOS-sample"; + productReference = ABB17D5422D93BAB00C26D6E /* watchOS-sample.app */; + productType = "com.apple.product-type.application"; + }; + ABB17D6922D93BAC00C26D6E /* watchOS-sample WatchKit App */ = { + isa = PBXNativeTarget; + buildConfigurationList = ABB17D8D22D93BAD00C26D6E /* Build configuration list for PBXNativeTarget "watchOS-sample WatchKit App" */; + buildPhases = ( + ABB17D6822D93BAC00C26D6E /* Resources */, + ABB17D8C22D93BAD00C26D6E /* Embed App Extensions */, + F374C9EC9D24282B20A64719 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ABB17D7C22D93BAC00C26D6E /* PBXTargetDependency */, + ); + name = "watchOS-sample WatchKit App"; + productName = "watchOS-sample WatchKit App"; + productReference = ABB17D6A22D93BAC00C26D6E /* watchOS-sample WatchKit App.app */; + productType = "com.apple.product-type.application.watchapp2"; + }; + ABB17D7822D93BAC00C26D6E /* watchOS-sample WatchKit Extension */ = { + isa = PBXNativeTarget; + buildConfigurationList = ABB17D8922D93BAD00C26D6E /* Build configuration list for PBXNativeTarget "watchOS-sample WatchKit Extension" */; + buildPhases = ( + 097AA61E20DEB1DB1E771FC9 /* [CP] Check Pods Manifest.lock */, + ABB17D7522D93BAC00C26D6E /* Sources */, + ABB17D7622D93BAC00C26D6E /* Frameworks */, + ABB17D7722D93BAC00C26D6E /* Resources */, + 8F82497BD93485F0621F0F30 /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "watchOS-sample WatchKit Extension"; + productName = "watchOS-sample WatchKit Extension"; + productReference = ABB17D7922D93BAC00C26D6E /* watchOS-sample WatchKit Extension.appex */; + productType = "com.apple.product-type.watchkit2-extension"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + ABB17D4C22D93BAB00C26D6E /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1010; + ORGANIZATIONNAME = "Tony Lu"; + TargetAttributes = { + ABB17D5322D93BAB00C26D6E = { + CreatedOnToolsVersion = 10.1; + }; + ABB17D6922D93BAC00C26D6E = { + CreatedOnToolsVersion = 10.1; + }; + ABB17D7822D93BAC00C26D6E = { + CreatedOnToolsVersion = 10.1; + }; + }; + }; + buildConfigurationList = ABB17D4F22D93BAB00C26D6E /* Build configuration list for PBXProject "watchOS-sample" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = ABB17D4B22D93BAB00C26D6E; + productRefGroup = ABB17D5522D93BAB00C26D6E /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + ABB17D5322D93BAB00C26D6E /* watchOS-sample */, + ABB17D6922D93BAC00C26D6E /* watchOS-sample WatchKit App */, + ABB17D7822D93BAC00C26D6E /* watchOS-sample WatchKit Extension */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + ABB17D5222D93BAB00C26D6E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ABB17D6422D93BAC00C26D6E /* LaunchScreen.storyboard in Resources */, + ABB17D6122D93BAC00C26D6E /* Assets.xcassets in Resources */, + ABB17D5F22D93BAB00C26D6E /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + ABB17D6822D93BAC00C26D6E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ABB17D7322D93BAC00C26D6E /* Assets.xcassets in Resources */, + ABB17D7122D93BAC00C26D6E /* Interface.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + ABB17D7722D93BAC00C26D6E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ABB17D8522D93BAD00C26D6E /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 097AA61E20DEB1DB1E771FC9 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-watchOS-sample WatchKit Extension-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 1E38C9CB686CAEF71A5A25B7 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 8F82497BD93485F0621F0F30 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 94316399D2F0BC04388E77B0 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-watchOS-sample-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + ABB17D5022D93BAB00C26D6E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ABB17D5C22D93BAB00C26D6E /* ViewController.m in Sources */, + ABB17D6722D93BAC00C26D6E /* main.m in Sources */, + ABB17D5922D93BAB00C26D6E /* AppDelegate.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + ABB17D7522D93BAC00C26D6E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ABB17D8322D93BAC00C26D6E /* ExtensionDelegate.m in Sources */, + ABB17D8022D93BAC00C26D6E /* InterfaceController.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + ABB17D6D22D93BAC00C26D6E /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = ABB17D6922D93BAC00C26D6E /* watchOS-sample WatchKit App */; + targetProxy = ABB17D6C22D93BAC00C26D6E /* PBXContainerItemProxy */; + }; + ABB17D7C22D93BAC00C26D6E /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = ABB17D7822D93BAC00C26D6E /* watchOS-sample WatchKit Extension */; + targetProxy = ABB17D7B22D93BAC00C26D6E /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + ABB17D5D22D93BAB00C26D6E /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + ABB17D5E22D93BAB00C26D6E /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + ABB17D6222D93BAC00C26D6E /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + ABB17D6322D93BAC00C26D6E /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; + ABB17D6F22D93BAC00C26D6E /* Interface.storyboard */ = { + isa = PBXVariantGroup; + children = ( + ABB17D7022D93BAC00C26D6E /* Base */, + ); + name = Interface.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + ABB17D8722D93BAD00C26D6E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + ABB17D8822D93BAD00C26D6E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + ABB17D8A22D93BAD00C26D6E /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 8C5540E3A034586596BEFE2B /* Pods-watchOS-sample WatchKit Extension.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6T98ZJNPG5; + INFOPLIST_FILE = "watchOS-sample WatchKit Extension/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample.watchkitapp.watchkitextension"; + PRODUCT_NAME = "${TARGET_NAME}"; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 5.1; + }; + name = Debug; + }; + ABB17D8B22D93BAD00C26D6E /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 0D53169393FEB36944484D25 /* Pods-watchOS-sample WatchKit Extension.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6T98ZJNPG5; + INFOPLIST_FILE = "watchOS-sample WatchKit Extension/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample.watchkitapp.watchkitextension"; + PRODUCT_NAME = "${TARGET_NAME}"; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 5.1; + }; + name = Release; + }; + ABB17D8E22D93BAD00C26D6E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6T98ZJNPG5; + IBSC_MODULE = watchOS_sample_WatchKit_Extension; + INFOPLIST_FILE = "watchOS-sample WatchKit App/Info.plist"; + PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample.watchkitapp"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 5.1; + }; + name = Debug; + }; + ABB17D8F22D93BAD00C26D6E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6T98ZJNPG5; + IBSC_MODULE = watchOS_sample_WatchKit_Extension; + INFOPLIST_FILE = "watchOS-sample WatchKit App/Info.plist"; + PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample.watchkitapp"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 5.1; + }; + name = Release; + }; + ABB17D9222D93BAD00C26D6E /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = CC865626944D2C3DD838F762 /* Pods-watchOS-sample.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6T98ZJNPG5; + INFOPLIST_FILE = "watchOS-sample/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + ABB17D9322D93BAD00C26D6E /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7DB8462D385A70A534800DAF /* Pods-watchOS-sample.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6T98ZJNPG5; + INFOPLIST_FILE = "watchOS-sample/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + ABB17D4F22D93BAB00C26D6E /* Build configuration list for PBXProject "watchOS-sample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + ABB17D8722D93BAD00C26D6E /* Debug */, + ABB17D8822D93BAD00C26D6E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + ABB17D8922D93BAD00C26D6E /* Build configuration list for PBXNativeTarget "watchOS-sample WatchKit Extension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + ABB17D8A22D93BAD00C26D6E /* Debug */, + ABB17D8B22D93BAD00C26D6E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + ABB17D8D22D93BAD00C26D6E /* Build configuration list for PBXNativeTarget "watchOS-sample WatchKit App" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + ABB17D8E22D93BAD00C26D6E /* Debug */, + ABB17D8F22D93BAD00C26D6E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + ABB17D9122D93BAD00C26D6E /* Build configuration list for PBXNativeTarget "watchOS-sample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + ABB17D9222D93BAD00C26D6E /* Debug */, + ABB17D9322D93BAD00C26D6E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = ABB17D4C22D93BAB00C26D6E /* Project object */; +} diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.h b/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.h new file mode 100644 index 00000000000..762a16888a2 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.h @@ -0,0 +1,17 @@ +// +// AppDelegate.h +// watchOS-sample +// +// Created by Tony Lu on 7/12/19. +// Copyright © 2019 Tony Lu. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m b/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m new file mode 100644 index 00000000000..1f77c1fb15c --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m @@ -0,0 +1,51 @@ +// +// AppDelegate.m +// watchOS-sample +// +// Created by Tony Lu on 7/12/19. +// Copyright © 2019 Tony Lu. All rights reserved. +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + + +- (void)applicationWillResignActive:(UIApplication *)application { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. +} + + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. +} + + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + + +@end diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/Assets.xcassets/AppIcon.appiconset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000000..d8db8d65fd7 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/Assets.xcassets/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample/Assets.xcassets/Contents.json new file mode 100644 index 00000000000..da4a164c918 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/Base.lproj/LaunchScreen.storyboard b/src/objective-c/examples/watchOS-sample/watchOS-sample/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000000..bfa36129419 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/Base.lproj/Main.storyboard b/src/objective-c/examples/watchOS-sample/watchOS-sample/Base.lproj/Main.storyboard new file mode 100644 index 00000000000..123b8115aa4 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/Base.lproj/Main.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/Info.plist b/src/objective-c/examples/watchOS-sample/watchOS-sample/Info.plist new file mode 100644 index 00000000000..16be3b68112 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.h b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.h new file mode 100644 index 00000000000..336e0ee57f2 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.h @@ -0,0 +1,15 @@ +// +// ViewController.h +// watchOS-sample +// +// Created by Tony Lu on 7/12/19. +// Copyright © 2019 Tony Lu. All rights reserved. +// + +#import + +@interface ViewController : UIViewController + + +@end + diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m new file mode 100644 index 00000000000..bc2f24a168b --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m @@ -0,0 +1,25 @@ +// +// ViewController.m +// watchOS-sample +// +// Created by Tony Lu on 7/12/19. +// Copyright © 2019 Tony Lu. All rights reserved. +// + +#import "ViewController.h" + +#import + +@interface ViewController () + +@end + +@implementation ViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view, typically from a nib. +} + + +@end diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/main.m b/src/objective-c/examples/watchOS-sample/watchOS-sample/main.m new file mode 100644 index 00000000000..a57a3cac1a5 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/main.m @@ -0,0 +1,16 @@ +// +// main.m +// watchOS-sample +// +// Created by Tony Lu on 7/12/19. +// Copyright © 2019 Tony Lu. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} From fa4e0f040faa48ec31b97f4778d71f94b73427f8 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Fri, 12 Jul 2019 17:45:04 -0700 Subject: [PATCH 0883/1555] Fix segv in pick_first --- .../filters/client_channel/lb_policy/pick_first/pick_first.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index e0deed27442..411d528354a 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -176,7 +176,7 @@ void PickFirst::ExitIdleLocked() { } void PickFirst::ResetBackoffLocked() { - subchannel_list_->ResetBackoffLocked(); + if (subchannel_list_ != nullptr) subchannel_list_->ResetBackoffLocked(); if (latest_pending_subchannel_list_ != nullptr) { latest_pending_subchannel_list_->ResetBackoffLocked(); } From 46de95536a16472c517393934052119ab297b124 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Sun, 14 Jul 2019 09:03:37 +1200 Subject: [PATCH 0884/1555] Move ClientBase to Grpc.Core.Api, change client project references to Grpc.Core.Api, use ChannelBase in codegen --- src/compiler/csharp_generator.cc | 2 +- .../ClientBase.cs | 0 .../Internal/UnimplementedCallInvoker.cs | 60 +++++++++++++++++++ src/csharp/Grpc.Core.Api/LiteClientBase.cs | 36 +---------- .../Grpc.HealthCheck.Tests.csproj | 3 +- .../Grpc.HealthCheck/Grpc.HealthCheck.csproj | 4 +- src/csharp/Grpc.HealthCheck/HealthGrpc.cs | 2 +- .../Grpc.Reflection.Tests.csproj | 3 +- .../Grpc.Reflection/Grpc.Reflection.csproj | 2 +- src/csharp/Grpc.Reflection/ReflectionGrpc.cs | 2 +- 10 files changed, 71 insertions(+), 43 deletions(-) rename src/csharp/{Grpc.Core => Grpc.Core.Api}/ClientBase.cs (100%) create mode 100644 src/csharp/Grpc.Core.Api/Internal/UnimplementedCallInvoker.cs diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc index a45408a4cb8..386d1783b9f 100644 --- a/src/compiler/csharp_generator.cc +++ b/src/compiler/csharp_generator.cc @@ -437,7 +437,7 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor* service, "/// The channel to use to make remote " "calls.\n", "servicename", GetServiceClassName(service)); - out->Print("public $name$(grpc::Channel channel) : base(channel)\n", "name", + out->Print("public $name$(grpc::ChannelBase channel) : base(channel)\n", "name", GetClientClassName(service)); out->Print("{\n"); out->Print("}\n"); diff --git a/src/csharp/Grpc.Core/ClientBase.cs b/src/csharp/Grpc.Core.Api/ClientBase.cs similarity index 100% rename from src/csharp/Grpc.Core/ClientBase.cs rename to src/csharp/Grpc.Core.Api/ClientBase.cs diff --git a/src/csharp/Grpc.Core.Api/Internal/UnimplementedCallInvoker.cs b/src/csharp/Grpc.Core.Api/Internal/UnimplementedCallInvoker.cs new file mode 100644 index 00000000000..c7be74ecf30 --- /dev/null +++ b/src/csharp/Grpc.Core.Api/Internal/UnimplementedCallInvoker.cs @@ -0,0 +1,60 @@ +#region Copyright notice and license + +// Copyright 2015-2016 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using System.Threading.Tasks; +using Grpc.Core; +using Grpc.Core.Utils; + +namespace Grpc.Core.Internal +{ + /// + /// Call invoker that throws NotImplementedException for all requests. + /// + internal class UnimplementedCallInvoker : CallInvoker + { + public UnimplementedCallInvoker() + { + } + + public override TResponse BlockingUnaryCall(Method method, string host, CallOptions options, TRequest request) + { + throw new NotImplementedException(); + } + + public override AsyncUnaryCall AsyncUnaryCall(Method method, string host, CallOptions options, TRequest request) + { + throw new NotImplementedException(); + } + + public override AsyncServerStreamingCall AsyncServerStreamingCall(Method method, string host, CallOptions options, TRequest request) + { + throw new NotImplementedException(); + } + + public override AsyncClientStreamingCall AsyncClientStreamingCall(Method method, string host, CallOptions options) + { + throw new NotImplementedException(); + } + + public override AsyncDuplexStreamingCall AsyncDuplexStreamingCall(Method method, string host, CallOptions options) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/csharp/Grpc.Core.Api/LiteClientBase.cs b/src/csharp/Grpc.Core.Api/LiteClientBase.cs index c3215f016a0..132f10a912f 100644 --- a/src/csharp/Grpc.Core.Api/LiteClientBase.cs +++ b/src/csharp/Grpc.Core.Api/LiteClientBase.cs @@ -17,6 +17,7 @@ #endregion using System; +using Grpc.Core.Internal; using Grpc.Core.Utils; namespace Grpc.Core @@ -58,40 +59,5 @@ namespace Grpc.Core { get { return this.callInvoker; } } - - /// - /// Call invoker that throws NotImplementedException for all requests. - /// - private class UnimplementedCallInvoker : CallInvoker - { - public UnimplementedCallInvoker() - { - } - - public override TResponse BlockingUnaryCall(Method method, string host, CallOptions options, TRequest request) - { - throw new NotImplementedException(); - } - - public override AsyncUnaryCall AsyncUnaryCall(Method method, string host, CallOptions options, TRequest request) - { - throw new NotImplementedException(); - } - - public override AsyncServerStreamingCall AsyncServerStreamingCall(Method method, string host, CallOptions options, TRequest request) - { - throw new NotImplementedException(); - } - - public override AsyncClientStreamingCall AsyncClientStreamingCall(Method method, string host, CallOptions options) - { - throw new NotImplementedException(); - } - - public override AsyncDuplexStreamingCall AsyncDuplexStreamingCall(Method method, string host, CallOptions options) - { - throw new NotImplementedException(); - } - } } } diff --git a/src/csharp/Grpc.HealthCheck.Tests/Grpc.HealthCheck.Tests.csproj b/src/csharp/Grpc.HealthCheck.Tests/Grpc.HealthCheck.Tests.csproj index 223c9985ecd..05f7320ad57 100755 --- a/src/csharp/Grpc.HealthCheck.Tests/Grpc.HealthCheck.Tests.csproj +++ b/src/csharp/Grpc.HealthCheck.Tests/Grpc.HealthCheck.Tests.csproj @@ -1,4 +1,4 @@ - + @@ -10,6 +10,7 @@ + diff --git a/src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.csproj b/src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.csproj index 7e8a8a7de87..391aee81cbc 100755 --- a/src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.csproj +++ b/src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.csproj @@ -1,4 +1,4 @@ - + @@ -26,7 +26,7 @@ - + None diff --git a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs index 7137b907274..d5051f3b05a 100644 --- a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs +++ b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs @@ -102,7 +102,7 @@ namespace Grpc.Health.V1 { { /// Creates a new client for Health /// The channel to use to make remote calls. - public HealthClient(grpc::Channel channel) : base(channel) + public HealthClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for Health that uses a custom CallInvoker. diff --git a/src/csharp/Grpc.Reflection.Tests/Grpc.Reflection.Tests.csproj b/src/csharp/Grpc.Reflection.Tests/Grpc.Reflection.Tests.csproj index ef9d2a1c570..e19020808f7 100755 --- a/src/csharp/Grpc.Reflection.Tests/Grpc.Reflection.Tests.csproj +++ b/src/csharp/Grpc.Reflection.Tests/Grpc.Reflection.Tests.csproj @@ -1,4 +1,4 @@ - + @@ -10,6 +10,7 @@ + diff --git a/src/csharp/Grpc.Reflection/Grpc.Reflection.csproj b/src/csharp/Grpc.Reflection/Grpc.Reflection.csproj index cf08e58ed65..4dbc8d69390 100755 --- a/src/csharp/Grpc.Reflection/Grpc.Reflection.csproj +++ b/src/csharp/Grpc.Reflection/Grpc.Reflection.csproj @@ -26,7 +26,7 @@ - + None diff --git a/src/csharp/Grpc.Reflection/ReflectionGrpc.cs b/src/csharp/Grpc.Reflection/ReflectionGrpc.cs index f97b3143a69..fa482eba494 100644 --- a/src/csharp/Grpc.Reflection/ReflectionGrpc.cs +++ b/src/csharp/Grpc.Reflection/ReflectionGrpc.cs @@ -69,7 +69,7 @@ namespace Grpc.Reflection.V1Alpha { { /// Creates a new client for ServerReflection /// The channel to use to make remote calls. - public ServerReflectionClient(grpc::Channel channel) : base(channel) + public ServerReflectionClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for ServerReflection that uses a custom CallInvoker. From 8ca58d55fe6d50951f14714ad6bdef40b07b155c Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Sun, 14 Jul 2019 09:10:49 +1200 Subject: [PATCH 0885/1555] Add ClientBase type forward --- src/csharp/Grpc.Core/ForwardedTypes.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/csharp/Grpc.Core/ForwardedTypes.cs b/src/csharp/Grpc.Core/ForwardedTypes.cs index fb99cfc018d..ad30814eb70 100644 --- a/src/csharp/Grpc.Core/ForwardedTypes.cs +++ b/src/csharp/Grpc.Core/ForwardedTypes.cs @@ -38,6 +38,8 @@ using Grpc.Core.Utils; [assembly:TypeForwardedToAttribute(typeof(CallInvoker))] [assembly:TypeForwardedToAttribute(typeof(CallInvokerExtensions))] [assembly:TypeForwardedToAttribute(typeof(CallOptions))] +[assembly:TypeForwardedToAttribute(typeof(ClientBase))] +[assembly:TypeForwardedToAttribute(typeof(ClientBase<>))] [assembly:TypeForwardedToAttribute(typeof(ClientInterceptorContext<,>))] [assembly:TypeForwardedToAttribute(typeof(ContextPropagationOptions))] [assembly:TypeForwardedToAttribute(typeof(ContextPropagationToken))] From 9e65a8876290bdd782e197fe8b98c35530c90427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Sobala?= Date: Mon, 15 Jul 2019 16:11:35 +0200 Subject: [PATCH 0886/1555] Fixed "implicitly-declared operator=" error from gcc 9 --- include/grpcpp/impl/codegen/call_op_set.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/grpcpp/impl/codegen/call_op_set.h b/include/grpcpp/impl/codegen/call_op_set.h index 84d1407cbe2..814cf29f913 100644 --- a/include/grpcpp/impl/codegen/call_op_set.h +++ b/include/grpcpp/impl/codegen/call_op_set.h @@ -88,6 +88,9 @@ class WriteOptions { WriteOptions(const WriteOptions& other) : flags_(other.flags_), last_message_(other.last_message_) {} + /// Default assignment operator + WriteOptions& operator=(const WriteOptions& other) = default; + /// Clear all flags. inline void Clear() { flags_ = 0; } From c556a02024a0922a51edb4976343dd6814515f5d Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 15 Jul 2019 11:20:17 -0400 Subject: [PATCH 0887/1555] add per-rpc interop tests to managed grpc-dotnet client --- tools/run_tests/run_interop_tests.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py index e71d308dcbe..d35723c917e 100755 --- a/tools/run_tests/run_interop_tests.py +++ b/tools/run_tests/run_interop_tests.py @@ -208,7 +208,10 @@ class AspNetCoreLanguage: def unimplemented_test_cases(self): return _SKIP_COMPRESSION + \ - _AUTH_TEST_CASES + ['compute_engine_creds'] + \ + ['jwt_token_creds'] + \ + _SKIP_GOOGLE_DEFAULT_CREDS + \ + _SKIP_COMPUTE_ENGINE_CHANNEL_CREDS def unimplemented_test_cases_server(self): return _SKIP_COMPRESSION @@ -821,8 +824,8 @@ def auth_options(language, test_case, google_default_creds_use_key_file, if test_case in ['jwt_token_creds', 'per_rpc_creds', 'oauth2_auth_token']: if language in [ - 'csharp', 'csharpcoreclr', 'node', 'php', 'php7', 'python', - 'ruby', 'nodepurejs' + 'csharp', 'csharpcoreclr', 'aspnetcore', 'node', 'php', 'php7', + 'python', 'ruby', 'nodepurejs' ]: env['GOOGLE_APPLICATION_CREDENTIALS'] = service_account_key_file else: From bb04e070b3177d7bd8e69c4086dc420f662b8f28 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Mon, 15 Jul 2019 11:34:04 -0700 Subject: [PATCH 0888/1555] doc/statuscodes.md: Remove HTTP status codes The HTTP status codes are more for REST; they don't work with gRPC. We shouldn't be encouraging them and they are confusing when you compare them to doc/http-grpc-status-mapping.md . --- doc/statuscodes.md | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/doc/statuscodes.md b/doc/statuscodes.md index a5c395d0ceb..ac34da591fc 100644 --- a/doc/statuscodes.md +++ b/doc/statuscodes.md @@ -3,25 +3,25 @@ gRPC uses a set of well defined status codes as part of the RPC API. These statuses are defined as such: -| Code | Number | Description | Closest HTTP Mapping | -|------------------|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------| -| OK | 0 | Not an error; returned on success. | 200 OK | -| CANCELLED | 1 | The operation was cancelled, typically by the caller. | 499 Client Closed Request | -| UNKNOWN | 2 | Unknown error. For example, this error may be returned when a `Status` value received from another address space belongs to an error space that is not known in this address space. Also errors raised by APIs that do not return enough error information may be converted to this error. | 500 Internal Server Error | -| INVALID_ARGUMENT | 3 | The client specified an invalid argument. Note that this differs from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments that are problematic regardless of the state of the system (e.g., a malformed file name). | 400 Bad Request | -| DEADLINE_EXCEEDED | 4 | The deadline expired before the operation could complete. For operations that change the state of the system, this error may be returned even if the operation has completed successfully. For example, a successful response from a server could have been delayed long | 504 Gateway Timeout | -| NOT_FOUND | 5 | Some requested entity (e.g., file or directory) was not found. Note to server developers: if a request is denied for an entire class of users, such as gradual feature rollout or undocumented whitelist, `NOT_FOUND` may be used. If a request is denied for some users within a class of users, such as user-based access control, `PERMISSION_DENIED` must be used. | 404 Not Found | -| ALREADY_EXISTS | 6 | The entity that a client attempted to create (e.g., file or directory) already exists. | 409 Conflict | -| PERMISSION_DENIED | 7 | The caller does not have permission to execute the specified operation. `PERMISSION_DENIED` must not be used for rejections caused by exhausting some resource (use `RESOURCE_EXHAUSTED` instead for those errors). `PERMISSION_DENIED` must not be used if the caller can not be identified (use `UNAUTHENTICATED` instead for those errors). This error code does not imply the request is valid or the requested entity exists or satisfies other pre-conditions. | 403 Forbidden | -| UNAUTHENTICATED | 16 | The request does not have valid authentication credentials for the operation. | 401 Unauthorized | -| RESOURCE_EXHAUSTED | 8 | Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. | 429 Too Many Requests | -| FAILED_PRECONDITION | 9 | The operation was rejected because the system is not in a state required for the operation's execution. For example, the directory to be deleted is non-empty, an rmdir operation is applied to a non-directory, etc. Service implementors can use the following guidelines to decide between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`: (a) Use `UNAVAILABLE` if the client can retry just the failing call. (b) Use `ABORTED` if the client should retry at a higher level (e.g., when a client-specified test-and-set fails, indicating the client should restart a read-modify-write sequence). (c) Use `FAILED_PRECONDITION` if the client should not retry until the system state has been explicitly fixed. E.g., if an "rmdir" fails because the directory is non-empty, `FAILED_PRECONDITION` should be returned since the client should not retry unless the files are deleted from the directory. | 400 Bad Request | -| ABORTED | 10 | The operation was aborted, typically due to a concurrency issue such as a sequencer check failure or transaction abort. See the guidelines above for deciding between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`. | 409 Conflict | -| OUT_OF_RANGE | 11 | The operation was attempted past the valid range. E.g., seeking or reading past end-of-file. Unlike `INVALID_ARGUMENT`, this error indicates a problem that may be fixed if the system state changes. For example, a 32-bit file system will generate `INVALID_ARGUMENT` if asked to read at an offset that is not in the range [0,2^32-1], but it will generate `OUT_OF_RANGE` if asked to read from an offset past the current file size. There is a fair bit of overlap between `FAILED_PRECONDITION` and `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific error) when it applies so that callers who are iterating through a space can easily look for an `OUT_OF_RANGE` error to detect when they are done. | 400 Bad Request | -| UNIMPLEMENTED | 12 | The operation is not implemented or is not supported/enabled in this service. | 501 Not Implemented | -| INTERNAL | 13 | Internal errors. This means that some invariants expected by the underlying system have been broken. This error code is reserved for serious errors. | 500 Internal Server Error | -| UNAVAILABLE | 14 | The service is currently unavailable. This is most likely a transient condition, which can be corrected by retrying with a backoff. Note that it is not always safe to retry non-idempotent operations. | 503 Service Unavailable | -| DATA_LOSS | 15 | Unrecoverable data loss or corruption. | 500 Internal Server Error | +| Code | Number | Description | +|------------------|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| OK | 0 | Not an error; returned on success. | +| CANCELLED | 1 | The operation was cancelled, typically by the caller. | +| UNKNOWN | 2 | Unknown error. For example, this error may be returned when a `Status` value received from another address space belongs to an error space that is not known in this address space. Also errors raised by APIs that do not return enough error information may be converted to this error. | +| INVALID_ARGUMENT | 3 | The client specified an invalid argument. Note that this differs from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments that are problematic regardless of the state of the system (e.g., a malformed file name). | +| DEADLINE_EXCEEDED | 4 | The deadline expired before the operation could complete. For operations that change the state of the system, this error may be returned even if the operation has completed successfully. For example, a successful response from a server could have been delayed long | +| NOT_FOUND | 5 | Some requested entity (e.g., file or directory) was not found. Note to server developers: if a request is denied for an entire class of users, such as gradual feature rollout or undocumented whitelist, `NOT_FOUND` may be used. If a request is denied for some users within a class of users, such as user-based access control, `PERMISSION_DENIED` must be used. | +| ALREADY_EXISTS | 6 | The entity that a client attempted to create (e.g., file or directory) already exists. | +| PERMISSION_DENIED | 7 | The caller does not have permission to execute the specified operation. `PERMISSION_DENIED` must not be used for rejections caused by exhausting some resource (use `RESOURCE_EXHAUSTED` instead for those errors). `PERMISSION_DENIED` must not be used if the caller can not be identified (use `UNAUTHENTICATED` instead for those errors). This error code does not imply the request is valid or the requested entity exists or satisfies other pre-conditions. | +| UNAUTHENTICATED | 16 | The request does not have valid authentication credentials for the operation. | +| RESOURCE_EXHAUSTED | 8 | Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. | +| FAILED_PRECONDITION | 9 | The operation was rejected because the system is not in a state required for the operation's execution. For example, the directory to be deleted is non-empty, an rmdir operation is applied to a non-directory, etc. Service implementors can use the following guidelines to decide between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`: (a) Use `UNAVAILABLE` if the client can retry just the failing call. (b) Use `ABORTED` if the client should retry at a higher level (e.g., when a client-specified test-and-set fails, indicating the client should restart a read-modify-write sequence). (c) Use `FAILED_PRECONDITION` if the client should not retry until the system state has been explicitly fixed. E.g., if an "rmdir" fails because the directory is non-empty, `FAILED_PRECONDITION` should be returned since the client should not retry unless the files are deleted from the directory. | +| ABORTED | 10 | The operation was aborted, typically due to a concurrency issue such as a sequencer check failure or transaction abort. See the guidelines above for deciding between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`. | +| OUT_OF_RANGE | 11 | The operation was attempted past the valid range. E.g., seeking or reading past end-of-file. Unlike `INVALID_ARGUMENT`, this error indicates a problem that may be fixed if the system state changes. For example, a 32-bit file system will generate `INVALID_ARGUMENT` if asked to read at an offset that is not in the range [0,2^32-1], but it will generate `OUT_OF_RANGE` if asked to read from an offset past the current file size. There is a fair bit of overlap between `FAILED_PRECONDITION` and `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific error) when it applies so that callers who are iterating through a space can easily look for an `OUT_OF_RANGE` error to detect when they are done. | +| UNIMPLEMENTED | 12 | The operation is not implemented or is not supported/enabled in this service. | +| INTERNAL | 13 | Internal errors. This means that some invariants expected by the underlying system have been broken. This error code is reserved for serious errors. | +| UNAVAILABLE | 14 | The service is currently unavailable. This is most likely a transient condition, which can be corrected by retrying with a backoff. Note that it is not always safe to retry non-idempotent operations. | +| DATA_LOSS | 15 | Unrecoverable data loss or corruption. | All RPCs started at a client return a `status` object composed of an integer `code` and a string `message`. The server-side can choose the status it From 225a878e9f358de573c4e05f119bf106476ed19c Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Thu, 11 Jul 2019 18:51:17 -0700 Subject: [PATCH 0889/1555] Track channelz server sockets in the server node --- src/core/lib/channel/channelz.cc | 33 +++++++++++++++++++++----------- src/core/lib/channel/channelz.h | 11 ++++++++--- src/core/lib/surface/server.cc | 32 +++++++++++++++---------------- src/core/lib/surface/server.h | 8 ++------ 4 files changed, 47 insertions(+), 37 deletions(-) diff --git a/src/core/lib/channel/channelz.cc b/src/core/lib/channel/channelz.cc index 184ba17889d..b9f65870cfe 100644 --- a/src/core/lib/channel/channelz.cc +++ b/src/core/lib/channel/channelz.cc @@ -309,31 +309,42 @@ ServerNode::ServerNode(grpc_server* server, size_t channel_tracer_max_nodes) ServerNode::~ServerNode() {} +void ServerNode::AddChildSocket(RefCountedPtr node) { + MutexLock lock(&child_mu_); + child_sockets_.insert(MakePair(node->uuid(), std::move(node))); +} + +void ServerNode::RemoveChildSocket(intptr_t child_uuid) { + MutexLock lock(&child_mu_); + child_sockets_.erase(child_uuid); +} + char* ServerNode::RenderServerSockets(intptr_t start_socket_id, intptr_t max_results) { - // if user does not set max_results, we choose 500. + // If user does not set max_results, we choose 500. size_t pagination_limit = max_results == 0 ? 500 : max_results; grpc_json* top_level_json = grpc_json_create(GRPC_JSON_OBJECT); grpc_json* json = top_level_json; grpc_json* json_iterator = nullptr; - ChildSocketsList socket_refs; - grpc_server_populate_server_sockets(server_, &socket_refs, start_socket_id); - // declared early so it can be used outside of the loop. - size_t i = 0; - if (!socket_refs.empty()) { - // create list of socket refs + MutexLock lock(&child_mu_); + size_t sockets_rendered = 0; + if (!child_sockets_.empty()) { + // Create list of socket refs grpc_json* array_parent = grpc_json_create_child( nullptr, json, "socketRef", nullptr, GRPC_JSON_ARRAY, false); - for (i = 0; i < GPR_MIN(socket_refs.size(), pagination_limit); ++i) { + const size_t limit = GPR_MIN(child_sockets_.size(), pagination_limit); + for (auto it = child_sockets_.lower_bound(start_socket_id); + it != child_sockets_.end() && sockets_rendered < limit; + ++it, ++sockets_rendered) { grpc_json* socket_ref_json = grpc_json_create_child( nullptr, array_parent, nullptr, nullptr, GRPC_JSON_OBJECT, false); json_iterator = grpc_json_add_number_string_child( - socket_ref_json, nullptr, "socketId", socket_refs[i]->uuid()); + socket_ref_json, nullptr, "socketId", it->first); grpc_json_create_child(json_iterator, socket_ref_json, "name", - socket_refs[i]->remote(), GRPC_JSON_STRING, false); + it->second->remote(), GRPC_JSON_STRING, false); } } - if (i == socket_refs.size()) { + if (sockets_rendered == child_sockets_.size()) { json_iterator = grpc_json_create_child(nullptr, json, "end", nullptr, GRPC_JSON_TRUE, false); } diff --git a/src/core/lib/channel/channelz.h b/src/core/lib/channel/channelz.h index d26896262ec..a02cb82cc75 100644 --- a/src/core/lib/channel/channelz.h +++ b/src/core/lib/channel/channelz.h @@ -64,7 +64,6 @@ intptr_t GetParentUuidFromArgs(const grpc_channel_args& args); typedef InlinedVector ChildRefsList; class SocketNode; -typedef InlinedVector, 10> ChildSocketsList; namespace testing { class CallCountingHelperPeer; @@ -207,12 +206,16 @@ class ChannelNode : public BaseNode { class ServerNode : public BaseNode { public: ServerNode(grpc_server* server, size_t channel_tracer_max_nodes); + ~ServerNode() override; grpc_json* RenderJson() override; - char* RenderServerSockets(intptr_t start_socket_id, - intptr_t pagination_limit); + char* RenderServerSockets(intptr_t start_socket_id, intptr_t max_results); + + void AddChildSocket(RefCountedPtr); + + void RemoveChildSocket(intptr_t child_uuid); // proxy methods to composed classes. void AddTraceEvent(ChannelTrace::Severity severity, const grpc_slice& data) { @@ -232,6 +235,8 @@ class ServerNode : public BaseNode { grpc_server* server_; CallCountingHelper call_counter_; ChannelTrace trace_; + Mutex child_mu_; // Guards child map below. + Map> child_sockets_; }; // Handles channelz bookkeeping for sockets diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 6cd86003f01..a1c7d132ade 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -31,6 +31,7 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/channel/channelz.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/mpscq.h" @@ -111,7 +112,7 @@ struct channel_data { uint32_t registered_method_max_probes; grpc_closure finish_destroy_channel_closure; grpc_closure channel_connectivity_changed; - grpc_core::RefCountedPtr socket_node; + intptr_t channelz_socket_uuid; }; typedef struct shutdown_tag { @@ -941,7 +942,6 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem, static void destroy_channel_elem(grpc_channel_element* elem) { size_t i; channel_data* chand = static_cast(elem->channel_data); - chand->socket_node.reset(); if (chand->registered_methods) { for (i = 0; i < chand->registered_method_slots; i++) { grpc_slice_unref_internal(chand->registered_methods[i].method); @@ -952,6 +952,11 @@ static void destroy_channel_elem(grpc_channel_element* elem) { gpr_free(chand->registered_methods); } if (chand->server) { + if (chand->server->channelz_server != nullptr && + chand->channelz_socket_uuid != 0) { + chand->server->channelz_server->RemoveChildSocket( + chand->channelz_socket_uuid); + } gpr_mu_lock(&chand->server->mu_global); chand->next->prev = chand->prev; chand->prev->next = chand->next; @@ -1144,7 +1149,8 @@ void grpc_server_get_pollsets(grpc_server* server, grpc_pollset*** pollsets, void grpc_server_setup_transport( grpc_server* s, grpc_transport* transport, grpc_pollset* accepting_pollset, const grpc_channel_args* args, - grpc_core::RefCountedPtr socket_node, + const grpc_core::RefCountedPtr& + socket_node, grpc_resource_user* resource_user) { size_t num_registered_methods; size_t alloc; @@ -1166,7 +1172,12 @@ void grpc_server_setup_transport( chand->server = s; server_ref(s); chand->channel = channel; - chand->socket_node = std::move(socket_node); + if (socket_node != nullptr) { + chand->channelz_socket_uuid = socket_node->uuid(); + s->channelz_server->AddChildSocket(socket_node); + } else { + chand->channelz_socket_uuid = 0; + } size_t cq_idx; for (cq_idx = 0; cq_idx < s->cq_count; cq_idx++) { @@ -1241,19 +1252,6 @@ void grpc_server_setup_transport( grpc_transport_perform_op(transport, op); } -void grpc_server_populate_server_sockets( - grpc_server* s, grpc_core::channelz::ChildSocketsList* server_sockets, - intptr_t start_idx) { - gpr_mu_lock(&s->mu_global); - channel_data* c = nullptr; - for (c = s->root_channel_data.next; c != &s->root_channel_data; c = c->next) { - if (c->socket_node != nullptr && c->socket_node->uuid() >= start_idx) { - server_sockets->push_back(c->socket_node); - } - } - gpr_mu_unlock(&s->mu_global); -} - void grpc_server_populate_listen_sockets( grpc_server* server, grpc_core::channelz::ChildRefsList* listen_sockets) { gpr_mu_lock(&server->mu_global); diff --git a/src/core/lib/surface/server.h b/src/core/lib/surface/server.h index 393bb242148..926a5825006 100644 --- a/src/core/lib/surface/server.h +++ b/src/core/lib/surface/server.h @@ -47,14 +47,10 @@ void grpc_server_add_listener(grpc_server* server, void* listener, void grpc_server_setup_transport( grpc_server* server, grpc_transport* transport, grpc_pollset* accepting_pollset, const grpc_channel_args* args, - grpc_core::RefCountedPtr socket_node, + const grpc_core::RefCountedPtr& + socket_node, grpc_resource_user* resource_user = nullptr); -/* fills in the uuids of all sockets used for connections on this server */ -void grpc_server_populate_server_sockets( - grpc_server* server, grpc_core::channelz::ChildSocketsList* server_sockets, - intptr_t start_idx); - /* fills in the uuids of all listen sockets on this server */ void grpc_server_populate_listen_sockets( grpc_server* server, grpc_core::channelz::ChildRefsList* listen_sockets); From eaef598a90f990b999df72bfb2c136c2ab516974 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Mon, 15 Jul 2019 15:36:13 -0700 Subject: [PATCH 0890/1555] Changed to remote sources --- src/objective-c/examples/watchOS-sample/Podfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/examples/watchOS-sample/Podfile b/src/objective-c/examples/watchOS-sample/Podfile index 60626ca493f..a0f93bef730 100644 --- a/src/objective-c/examples/watchOS-sample/Podfile +++ b/src/objective-c/examples/watchOS-sample/Podfile @@ -9,7 +9,7 @@ def grpc_deps pod 'gRPC-RxLibrary', :path => ROOT_DIR pod 'RemoteTest', :path => "../RemoteTestClient" pod '!ProtoCompiler-gRPCPlugin', :path => "#{ROOT_DIR}/src/objective-c" - pod 'BoringSSL-GRPC', :path => "#{ROOT_DIR}/third_party/boringssl" + pod 'BoringSSL-GRPC', :podspec => "#{ROOT_DIR}/src/objective-c" pod '!ProtoCompiler', :path => "#{ROOT_DIR}/src/objective-c" end From b1d73a01f15ef7de1aa3da25c2a62be0b97f2087 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Mon, 24 Jun 2019 15:15:26 -0700 Subject: [PATCH 0891/1555] Removed duplicate static table from hpack table. Removed an or instruction for every usage of static grpc metadata. Inlined hpack table lookups for static metadata. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This leads to faster hpack parser creation: BM_HpackParserInitDestroy 5.32µs ± 1% 0.06µs ± 1% -98.91% (p=0.000 n=18+19) And slightly faster parsing: BM_HpackParserParseHeader 456ns ± 1% 435ns ± 1% -4.74% (p=0.000 n=18+19) BM_HpackParserParseHeader 1.06µs ± 2% 1.04µs ± 2% -1.82% (p=0.000 n=19+20) It also yields a slight (0.5 - 1.0 microsecond) reduction in CPU time for fullstack unary pingpong: BM_UnaryPingPong/0/512 [polls/iter:3.0001 ] 23.9µs ± 2% 23.0µs ± 1% -3.63% (p=0.002 n=6+6) BM_UnaryPingPong/0/32768 [polls/iter:3.00015 ] 35.1µs ± 1% 34.2µs ± 1% -2.57% (p=0.036 n=5+3) BM_UnaryPingPong/8/0 [polls/iter:3.00011 ] 21.7µs ± 3% 21.2µs ± 2% -2.44% (p=0.017 n=6+5) --- .../chttp2/transport/hpack_parser.cc | 1 - .../transport/chttp2/transport/hpack_table.cc | 173 +------ .../transport/chttp2/transport/hpack_table.h | 56 ++- src/core/lib/transport/static_metadata.cc | 441 ++++++++++++++++++ src/core/lib/transport/static_metadata.h | 353 ++++---------- .../transport/chttp2/hpack_parser_test.cc | 4 + .../core/transport/chttp2/hpack_table_test.cc | 4 - test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 7 + tools/codegen/core/gen_static_metadata.py | 32 +- 9 files changed, 627 insertions(+), 444 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index efbd997e994..616d6c56148 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -1559,7 +1559,6 @@ void grpc_chttp2_hpack_parser_init(grpc_chttp2_hpack_parser* p) { p->value.data.copied.length = 0; p->dynamic_table_update_allowed = 2; p->last_error = GRPC_ERROR_NONE; - grpc_chttp2_hptbl_init(&p->table); } void grpc_chttp2_hpack_parser_set_has_priority(grpc_chttp2_hpack_parser* p) { diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.cc b/src/core/ext/transport/chttp2/transport/hpack_table.cc index 9d1ac4b370f..f86332c6bc3 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_table.cc @@ -35,179 +35,18 @@ extern grpc_core::TraceFlag grpc_http_trace; -static struct { - const char* key; - const char* value; -} static_table[] = { - /* 0: */ - {nullptr, nullptr}, - /* 1: */ - {":authority", ""}, - /* 2: */ - {":method", "GET"}, - /* 3: */ - {":method", "POST"}, - /* 4: */ - {":path", "/"}, - /* 5: */ - {":path", "/index.html"}, - /* 6: */ - {":scheme", "http"}, - /* 7: */ - {":scheme", "https"}, - /* 8: */ - {":status", "200"}, - /* 9: */ - {":status", "204"}, - /* 10: */ - {":status", "206"}, - /* 11: */ - {":status", "304"}, - /* 12: */ - {":status", "400"}, - /* 13: */ - {":status", "404"}, - /* 14: */ - {":status", "500"}, - /* 15: */ - {"accept-charset", ""}, - /* 16: */ - {"accept-encoding", "gzip, deflate"}, - /* 17: */ - {"accept-language", ""}, - /* 18: */ - {"accept-ranges", ""}, - /* 19: */ - {"accept", ""}, - /* 20: */ - {"access-control-allow-origin", ""}, - /* 21: */ - {"age", ""}, - /* 22: */ - {"allow", ""}, - /* 23: */ - {"authorization", ""}, - /* 24: */ - {"cache-control", ""}, - /* 25: */ - {"content-disposition", ""}, - /* 26: */ - {"content-encoding", ""}, - /* 27: */ - {"content-language", ""}, - /* 28: */ - {"content-length", ""}, - /* 29: */ - {"content-location", ""}, - /* 30: */ - {"content-range", ""}, - /* 31: */ - {"content-type", ""}, - /* 32: */ - {"cookie", ""}, - /* 33: */ - {"date", ""}, - /* 34: */ - {"etag", ""}, - /* 35: */ - {"expect", ""}, - /* 36: */ - {"expires", ""}, - /* 37: */ - {"from", ""}, - /* 38: */ - {"host", ""}, - /* 39: */ - {"if-match", ""}, - /* 40: */ - {"if-modified-since", ""}, - /* 41: */ - {"if-none-match", ""}, - /* 42: */ - {"if-range", ""}, - /* 43: */ - {"if-unmodified-since", ""}, - /* 44: */ - {"last-modified", ""}, - /* 45: */ - {"link", ""}, - /* 46: */ - {"location", ""}, - /* 47: */ - {"max-forwards", ""}, - /* 48: */ - {"proxy-authenticate", ""}, - /* 49: */ - {"proxy-authorization", ""}, - /* 50: */ - {"range", ""}, - /* 51: */ - {"referer", ""}, - /* 52: */ - {"refresh", ""}, - /* 53: */ - {"retry-after", ""}, - /* 54: */ - {"server", ""}, - /* 55: */ - {"set-cookie", ""}, - /* 56: */ - {"strict-transport-security", ""}, - /* 57: */ - {"transfer-encoding", ""}, - /* 58: */ - {"user-agent", ""}, - /* 59: */ - {"vary", ""}, - /* 60: */ - {"via", ""}, - /* 61: */ - {"www-authenticate", ""}, -}; - -static uint32_t entries_for_bytes(uint32_t bytes) { - return (bytes + GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD - 1) / - GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD; -} - -void grpc_chttp2_hptbl_init(grpc_chttp2_hptbl* tbl) { - size_t i; - - memset(tbl, 0, sizeof(*tbl)); - tbl->current_table_bytes = tbl->max_bytes = - GRPC_CHTTP2_INITIAL_HPACK_TABLE_SIZE; - tbl->max_entries = tbl->cap_entries = - entries_for_bytes(tbl->current_table_bytes); - tbl->ents = static_cast( - gpr_malloc(sizeof(*tbl->ents) * tbl->cap_entries)); - memset(tbl->ents, 0, sizeof(*tbl->ents) * tbl->cap_entries); - for (i = 1; i <= GRPC_CHTTP2_LAST_STATIC_ENTRY; i++) { - tbl->static_ents[i - 1] = grpc_mdelem_from_slices( - grpc_slice_intern( - grpc_slice_from_static_string_internal(static_table[i].key)), - grpc_slice_intern( - grpc_slice_from_static_string_internal(static_table[i].value))); - } -} - void grpc_chttp2_hptbl_destroy(grpc_chttp2_hptbl* tbl) { size_t i; - for (i = 0; i < GRPC_CHTTP2_LAST_STATIC_ENTRY; i++) { - GRPC_MDELEM_UNREF(tbl->static_ents[i]); - } for (i = 0; i < tbl->num_ents; i++) { GRPC_MDELEM_UNREF(tbl->ents[(tbl->first_ent + i) % tbl->cap_entries]); } gpr_free(tbl->ents); + tbl->ents = nullptr; } -grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl* tbl, - uint32_t tbl_index) { - /* Static table comes first, just return an entry from it */ - if (tbl_index <= GRPC_CHTTP2_LAST_STATIC_ENTRY) { - return tbl->static_ents[tbl_index - 1]; - } - /* Otherwise, find the value in the list of valid entries */ +grpc_mdelem grpc_chttp2_hptbl_lookup_dynamic_index(const grpc_chttp2_hptbl* tbl, + uint32_t tbl_index) { + /* Not static - find the value in the list of valid entries */ tbl_index -= (GRPC_CHTTP2_LAST_STATIC_ENTRY + 1); if (tbl_index < tbl->num_ents) { uint32_t offset = @@ -280,7 +119,7 @@ grpc_error* grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl* tbl, evict1(tbl); } tbl->current_table_bytes = bytes; - tbl->max_entries = entries_for_bytes(bytes); + tbl->max_entries = grpc_chttp2_hptbl::entries_for_bytes(bytes); if (tbl->max_entries > tbl->cap_entries) { rebuild_ents(tbl, GPR_MAX(tbl->max_entries, 2 * tbl->cap_entries)); } else if (tbl->max_entries < tbl->cap_entries / 3) { @@ -350,7 +189,7 @@ grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find( /* See if the string is in the static table */ for (i = 0; i < GRPC_CHTTP2_LAST_STATIC_ENTRY; i++) { - grpc_mdelem ent = tbl->static_ents[i]; + grpc_mdelem ent = grpc_static_mdelem_manifested[i]; if (!grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDKEY(ent))) continue; r.index = i + 1u; r.has_value = grpc_slice_eq(GRPC_MDVALUE(md), GRPC_MDVALUE(ent)); diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.h b/src/core/ext/transport/chttp2/transport/hpack_table.h index 38f8bdda6ae..699b7eccaf2 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.h +++ b/src/core/ext/transport/chttp2/transport/hpack_table.h @@ -22,6 +22,7 @@ #include #include +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/static_metadata.h" @@ -46,32 +47,45 @@ #endif /* hpack decoder table */ -typedef struct { +struct grpc_chttp2_hptbl { + static uint32_t entries_for_bytes(uint32_t bytes) { + return (bytes + GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD - 1) / + GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD; + } + static constexpr uint32_t kInitialCapacity = + (GRPC_CHTTP2_INITIAL_HPACK_TABLE_SIZE + GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD - + 1) / + GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD; + + grpc_chttp2_hptbl() { + GPR_DEBUG_ASSERT(!ents); + constexpr uint32_t AllocSize = sizeof(*ents) * kInitialCapacity; + ents = static_cast(gpr_malloc(AllocSize)); + memset(ents, 0, AllocSize); + } + /* the first used entry in ents */ - uint32_t first_ent; + uint32_t first_ent = 0; /* how many entries are in the table */ - uint32_t num_ents; + uint32_t num_ents = 0; /* the amount of memory used by the table, according to the hpack algorithm */ - uint32_t mem_used; + uint32_t mem_used = 0; /* the max memory allowed to be used by the table, according to the hpack algorithm */ - uint32_t max_bytes; + uint32_t max_bytes = GRPC_CHTTP2_INITIAL_HPACK_TABLE_SIZE; /* the currently agreed size of the table, according to the hpack algorithm */ - uint32_t current_table_bytes; + uint32_t current_table_bytes = GRPC_CHTTP2_INITIAL_HPACK_TABLE_SIZE; /* Maximum number of entries we could possibly fit in the table, given defined overheads */ - uint32_t max_entries; + uint32_t max_entries = kInitialCapacity; /* Number of entries allocated in ents */ - uint32_t cap_entries; + uint32_t cap_entries = kInitialCapacity; /* a circular buffer of headers - this is stored in the opposite order to what hpack specifies, in order to simplify table management a little... meaning lookups need to SUBTRACT from the end position */ - grpc_mdelem* ents; - grpc_mdelem static_ents[GRPC_CHTTP2_LAST_STATIC_ENTRY]; -} grpc_chttp2_hptbl; + grpc_mdelem* ents = nullptr; +}; -/* initialize a hpack table */ -void grpc_chttp2_hptbl_init(grpc_chttp2_hptbl* tbl); void grpc_chttp2_hptbl_destroy(grpc_chttp2_hptbl* tbl); void grpc_chttp2_hptbl_set_max_bytes(grpc_chttp2_hptbl* tbl, uint32_t max_bytes); @@ -79,8 +93,20 @@ grpc_error* grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl* tbl, uint32_t bytes); /* lookup a table entry based on its hpack index */ -grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl* tbl, - uint32_t index); +grpc_mdelem grpc_chttp2_hptbl_lookup_dynamic_index(const grpc_chttp2_hptbl* tbl, + uint32_t tbl_index); +inline grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl* tbl, + uint32_t index) { + /* Static table comes first, just return an entry from it. + NB: This imposes the constraint that the first + GRPC_CHTTP2_LAST_STATIC_ENTRY entries in the core static metadata table + must follow the hpack standard. If that changes, we *must* not rely on + reading the core static metadata table here; at that point we'd need our + own singleton static metadata in the correct order. */ + return index <= GRPC_CHTTP2_LAST_STATIC_ENTRY + ? grpc_static_mdelem_manifested[index - 1] + : grpc_chttp2_hptbl_lookup_dynamic_index(tbl, index); +} /* add a table entry to the index */ grpc_error* grpc_chttp2_hptbl_add(grpc_chttp2_hptbl* tbl, grpc_mdelem md) GRPC_MUST_USE_RESULT; diff --git a/src/core/lib/transport/static_metadata.cc b/src/core/lib/transport/static_metadata.cc index 5887e3515fb..8b0a6f482d7 100644 --- a/src/core/lib/transport/static_metadata.cc +++ b/src/core/lib/transport/static_metadata.cc @@ -337,6 +337,447 @@ const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT] = { {&grpc_static_metadata_refcounts[106], {{21, g_bytes + 1234}}}, }; +/* Warning: the core static metadata currently operates under the soft +constraint that the first GRPC_CHTTP2_LAST_STATIC_ENTRY (61) entries must +contain metadata specified by the http2 hpack standard. The CHTTP2 transport +reads the core metadata with this assumption in mind. If the order of the core +static metadata is to be changed, then the CHTTP2 transport must be changed as +well to stop relying on the core metadata. */ + +grpc_mdelem grpc_static_mdelem_manifested[GRPC_STATIC_MDELEM_COUNT] = { + // clang-format off + /* GRPC_MDELEM_AUTHORITY_EMPTY: + ":authority": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[0].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_METHOD_GET: + ":method": "GET" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[1].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_METHOD_POST: + ":method": "POST" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[2].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_PATH_SLASH: + ":path": "/" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[3].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_PATH_SLASH_INDEX_DOT_HTML: + ":path": "/index.html" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[4].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_SCHEME_HTTP: + ":scheme": "http" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[5].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_SCHEME_HTTPS: + ":scheme": "https" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[6].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_STATUS_200: + ":status": "200" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[7].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_STATUS_204: + ":status": "204" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[8].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_STATUS_206: + ":status": "206" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[9].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_STATUS_304: + ":status": "304" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[10].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_STATUS_400: + ":status": "400" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[11].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_STATUS_404: + ":status": "404" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[12].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_STATUS_500: + ":status": "500" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[13].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_ACCEPT_CHARSET_EMPTY: + "accept-charset": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[14].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_ACCEPT_ENCODING_GZIP_COMMA_DEFLATE: + "accept-encoding": "gzip, deflate" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[15].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_ACCEPT_LANGUAGE_EMPTY: + "accept-language": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[16].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_ACCEPT_RANGES_EMPTY: + "accept-ranges": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[17].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_ACCEPT_EMPTY: + "accept": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[18].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_ACCESS_CONTROL_ALLOW_ORIGIN_EMPTY: + "access-control-allow-origin": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[19].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_AGE_EMPTY: + "age": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[20].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_ALLOW_EMPTY: + "allow": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[21].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_AUTHORIZATION_EMPTY: + "authorization": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[22].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_CACHE_CONTROL_EMPTY: + "cache-control": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[23].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_CONTENT_DISPOSITION_EMPTY: + "content-disposition": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[24].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_CONTENT_ENCODING_EMPTY: + "content-encoding": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[25].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_CONTENT_LANGUAGE_EMPTY: + "content-language": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[26].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_CONTENT_LENGTH_EMPTY: + "content-length": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[27].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_CONTENT_LOCATION_EMPTY: + "content-location": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[28].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_CONTENT_RANGE_EMPTY: + "content-range": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[29].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_CONTENT_TYPE_EMPTY: + "content-type": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[30].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_COOKIE_EMPTY: + "cookie": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[31].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_DATE_EMPTY: + "date": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[32].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_ETAG_EMPTY: + "etag": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[33].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_EXPECT_EMPTY: + "expect": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[34].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_EXPIRES_EMPTY: + "expires": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[35].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_FROM_EMPTY: + "from": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[36].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_HOST_EMPTY: + "host": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[37].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_IF_MATCH_EMPTY: + "if-match": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[38].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_IF_MODIFIED_SINCE_EMPTY: + "if-modified-since": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[39].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_IF_NONE_MATCH_EMPTY: + "if-none-match": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[40].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_IF_RANGE_EMPTY: + "if-range": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[41].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_IF_UNMODIFIED_SINCE_EMPTY: + "if-unmodified-since": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[42].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_LAST_MODIFIED_EMPTY: + "last-modified": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[43].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_LINK_EMPTY: + "link": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[44].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_LOCATION_EMPTY: + "location": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[45].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_MAX_FORWARDS_EMPTY: + "max-forwards": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[46].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_PROXY_AUTHENTICATE_EMPTY: + "proxy-authenticate": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[47].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_PROXY_AUTHORIZATION_EMPTY: + "proxy-authorization": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[48].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_RANGE_EMPTY: + "range": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[49].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_REFERER_EMPTY: + "referer": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[50].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_REFRESH_EMPTY: + "refresh": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[51].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_RETRY_AFTER_EMPTY: + "retry-after": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[52].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_SERVER_EMPTY: + "server": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[53].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_SET_COOKIE_EMPTY: + "set-cookie": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[54].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_STRICT_TRANSPORT_SECURITY_EMPTY: + "strict-transport-security": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[55].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_TRANSFER_ENCODING_EMPTY: + "transfer-encoding": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[56].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_USER_AGENT_EMPTY: + "user-agent": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[57].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_VARY_EMPTY: + "vary": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[58].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_VIA_EMPTY: + "via": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[59].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_WWW_AUTHENTICATE_EMPTY: + "www-authenticate": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[60].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_GRPC_STATUS_0: + "grpc-status": "0" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[61].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_GRPC_STATUS_1: + "grpc-status": "1" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[62].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_GRPC_STATUS_2: + "grpc-status": "2" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[63].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_GRPC_ENCODING_IDENTITY: + "grpc-encoding": "identity" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[64].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_GRPC_ENCODING_GZIP: + "grpc-encoding": "gzip" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[65].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_GRPC_ENCODING_DEFLATE: + "grpc-encoding": "deflate" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[66].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_TE_TRAILERS: + "te": "trailers" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[67].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC: + "content-type": "application/grpc" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[68].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_SCHEME_GRPC: + ":scheme": "grpc" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[69].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_METHOD_PUT: + ":method": "PUT" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[70].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_ACCEPT_ENCODING_EMPTY: + "accept-encoding": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[71].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_CONTENT_ENCODING_IDENTITY: + "content-encoding": "identity" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[72].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_CONTENT_ENCODING_GZIP: + "content-encoding": "gzip" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[73].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_LB_TOKEN_EMPTY: + "lb-token": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[74].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_LB_COST_BIN_EMPTY: + "lb-cost-bin": "" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[75].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY: + "grpc-accept-encoding": "identity" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[76].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE: + "grpc-accept-encoding": "deflate" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[77].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE: + "grpc-accept-encoding": "identity,deflate" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[78].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_GZIP: + "grpc-accept-encoding": "gzip" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[79].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP: + "grpc-accept-encoding": "identity,gzip" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[80].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE_COMMA_GZIP: + "grpc-accept-encoding": "deflate,gzip" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[81].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP: + "grpc-accept-encoding": "identity,deflate,gzip" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[82].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY: + "accept-encoding": "identity" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[83].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_ACCEPT_ENCODING_GZIP: + "accept-encoding": "gzip" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[84].data(), + GRPC_MDELEM_STORAGE_STATIC), + /* GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP: + "accept-encoding": "identity,gzip" */ + GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table[85].data(), + GRPC_MDELEM_STORAGE_STATIC) + // clang-format on +}; uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/src/core/lib/transport/static_metadata.h b/src/core/lib/transport/static_metadata.h index 800ee04d6f9..458e87d30a7 100644 --- a/src/core/lib/transport/static_metadata.h +++ b/src/core/lib/transport/static_metadata.h @@ -272,350 +272,195 @@ extern grpc_slice_refcount extern grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT]; extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT]; +extern grpc_mdelem grpc_static_mdelem_manifested[GRPC_STATIC_MDELEM_COUNT]; /* ":authority": "" */ -#define GRPC_MDELEM_AUTHORITY_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[0].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_AUTHORITY_EMPTY (grpc_static_mdelem_manifested[0]) /* ":method": "GET" */ -#define GRPC_MDELEM_METHOD_GET \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[1].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_METHOD_GET (grpc_static_mdelem_manifested[1]) /* ":method": "POST" */ -#define GRPC_MDELEM_METHOD_POST \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[2].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_METHOD_POST (grpc_static_mdelem_manifested[2]) /* ":path": "/" */ -#define GRPC_MDELEM_PATH_SLASH \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[3].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_PATH_SLASH (grpc_static_mdelem_manifested[3]) /* ":path": "/index.html" */ -#define GRPC_MDELEM_PATH_SLASH_INDEX_DOT_HTML \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[4].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_PATH_SLASH_INDEX_DOT_HTML (grpc_static_mdelem_manifested[4]) /* ":scheme": "http" */ -#define GRPC_MDELEM_SCHEME_HTTP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[5].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_SCHEME_HTTP (grpc_static_mdelem_manifested[5]) /* ":scheme": "https" */ -#define GRPC_MDELEM_SCHEME_HTTPS \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[6].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_SCHEME_HTTPS (grpc_static_mdelem_manifested[6]) /* ":status": "200" */ -#define GRPC_MDELEM_STATUS_200 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[7].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_200 (grpc_static_mdelem_manifested[7]) /* ":status": "204" */ -#define GRPC_MDELEM_STATUS_204 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[8].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_204 (grpc_static_mdelem_manifested[8]) /* ":status": "206" */ -#define GRPC_MDELEM_STATUS_206 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[9].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_206 (grpc_static_mdelem_manifested[9]) /* ":status": "304" */ -#define GRPC_MDELEM_STATUS_304 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[10].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_304 (grpc_static_mdelem_manifested[10]) /* ":status": "400" */ -#define GRPC_MDELEM_STATUS_400 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[11].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_400 (grpc_static_mdelem_manifested[11]) /* ":status": "404" */ -#define GRPC_MDELEM_STATUS_404 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[12].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_404 (grpc_static_mdelem_manifested[12]) /* ":status": "500" */ -#define GRPC_MDELEM_STATUS_500 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[13].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STATUS_500 (grpc_static_mdelem_manifested[13]) /* "accept-charset": "" */ -#define GRPC_MDELEM_ACCEPT_CHARSET_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[14].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_CHARSET_EMPTY (grpc_static_mdelem_manifested[14]) /* "accept-encoding": "gzip, deflate" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP_COMMA_DEFLATE \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[15].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP_COMMA_DEFLATE \ + (grpc_static_mdelem_manifested[15]) /* "accept-language": "" */ -#define GRPC_MDELEM_ACCEPT_LANGUAGE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[16].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_LANGUAGE_EMPTY (grpc_static_mdelem_manifested[16]) /* "accept-ranges": "" */ -#define GRPC_MDELEM_ACCEPT_RANGES_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[17].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_RANGES_EMPTY (grpc_static_mdelem_manifested[17]) /* "accept": "" */ -#define GRPC_MDELEM_ACCEPT_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[18].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_EMPTY (grpc_static_mdelem_manifested[18]) /* "access-control-allow-origin": "" */ -#define GRPC_MDELEM_ACCESS_CONTROL_ALLOW_ORIGIN_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[19].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCESS_CONTROL_ALLOW_ORIGIN_EMPTY \ + (grpc_static_mdelem_manifested[19]) /* "age": "" */ -#define GRPC_MDELEM_AGE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[20].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_AGE_EMPTY (grpc_static_mdelem_manifested[20]) /* "allow": "" */ -#define GRPC_MDELEM_ALLOW_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[21].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ALLOW_EMPTY (grpc_static_mdelem_manifested[21]) /* "authorization": "" */ -#define GRPC_MDELEM_AUTHORIZATION_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[22].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_AUTHORIZATION_EMPTY (grpc_static_mdelem_manifested[22]) /* "cache-control": "" */ -#define GRPC_MDELEM_CACHE_CONTROL_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[23].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CACHE_CONTROL_EMPTY (grpc_static_mdelem_manifested[23]) /* "content-disposition": "" */ -#define GRPC_MDELEM_CONTENT_DISPOSITION_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[24].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_DISPOSITION_EMPTY \ + (grpc_static_mdelem_manifested[24]) /* "content-encoding": "" */ -#define GRPC_MDELEM_CONTENT_ENCODING_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[25].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_ENCODING_EMPTY (grpc_static_mdelem_manifested[25]) /* "content-language": "" */ -#define GRPC_MDELEM_CONTENT_LANGUAGE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[26].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_LANGUAGE_EMPTY (grpc_static_mdelem_manifested[26]) /* "content-length": "" */ -#define GRPC_MDELEM_CONTENT_LENGTH_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[27].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_LENGTH_EMPTY (grpc_static_mdelem_manifested[27]) /* "content-location": "" */ -#define GRPC_MDELEM_CONTENT_LOCATION_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[28].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_LOCATION_EMPTY (grpc_static_mdelem_manifested[28]) /* "content-range": "" */ -#define GRPC_MDELEM_CONTENT_RANGE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[29].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_RANGE_EMPTY (grpc_static_mdelem_manifested[29]) /* "content-type": "" */ -#define GRPC_MDELEM_CONTENT_TYPE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[30].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_TYPE_EMPTY (grpc_static_mdelem_manifested[30]) /* "cookie": "" */ -#define GRPC_MDELEM_COOKIE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[31].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_COOKIE_EMPTY (grpc_static_mdelem_manifested[31]) /* "date": "" */ -#define GRPC_MDELEM_DATE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[32].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_DATE_EMPTY (grpc_static_mdelem_manifested[32]) /* "etag": "" */ -#define GRPC_MDELEM_ETAG_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[33].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ETAG_EMPTY (grpc_static_mdelem_manifested[33]) /* "expect": "" */ -#define GRPC_MDELEM_EXPECT_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[34].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_EXPECT_EMPTY (grpc_static_mdelem_manifested[34]) /* "expires": "" */ -#define GRPC_MDELEM_EXPIRES_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[35].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_EXPIRES_EMPTY (grpc_static_mdelem_manifested[35]) /* "from": "" */ -#define GRPC_MDELEM_FROM_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[36].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_FROM_EMPTY (grpc_static_mdelem_manifested[36]) /* "host": "" */ -#define GRPC_MDELEM_HOST_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[37].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_HOST_EMPTY (grpc_static_mdelem_manifested[37]) /* "if-match": "" */ -#define GRPC_MDELEM_IF_MATCH_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[38].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_IF_MATCH_EMPTY (grpc_static_mdelem_manifested[38]) /* "if-modified-since": "" */ -#define GRPC_MDELEM_IF_MODIFIED_SINCE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[39].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_IF_MODIFIED_SINCE_EMPTY (grpc_static_mdelem_manifested[39]) /* "if-none-match": "" */ -#define GRPC_MDELEM_IF_NONE_MATCH_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[40].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_IF_NONE_MATCH_EMPTY (grpc_static_mdelem_manifested[40]) /* "if-range": "" */ -#define GRPC_MDELEM_IF_RANGE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[41].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_IF_RANGE_EMPTY (grpc_static_mdelem_manifested[41]) /* "if-unmodified-since": "" */ -#define GRPC_MDELEM_IF_UNMODIFIED_SINCE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[42].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_IF_UNMODIFIED_SINCE_EMPTY \ + (grpc_static_mdelem_manifested[42]) /* "last-modified": "" */ -#define GRPC_MDELEM_LAST_MODIFIED_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[43].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_LAST_MODIFIED_EMPTY (grpc_static_mdelem_manifested[43]) /* "link": "" */ -#define GRPC_MDELEM_LINK_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[44].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_LINK_EMPTY (grpc_static_mdelem_manifested[44]) /* "location": "" */ -#define GRPC_MDELEM_LOCATION_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[45].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_LOCATION_EMPTY (grpc_static_mdelem_manifested[45]) /* "max-forwards": "" */ -#define GRPC_MDELEM_MAX_FORWARDS_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[46].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_MAX_FORWARDS_EMPTY (grpc_static_mdelem_manifested[46]) /* "proxy-authenticate": "" */ -#define GRPC_MDELEM_PROXY_AUTHENTICATE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[47].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_PROXY_AUTHENTICATE_EMPTY (grpc_static_mdelem_manifested[47]) /* "proxy-authorization": "" */ -#define GRPC_MDELEM_PROXY_AUTHORIZATION_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[48].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_PROXY_AUTHORIZATION_EMPTY \ + (grpc_static_mdelem_manifested[48]) /* "range": "" */ -#define GRPC_MDELEM_RANGE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[49].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_RANGE_EMPTY (grpc_static_mdelem_manifested[49]) /* "referer": "" */ -#define GRPC_MDELEM_REFERER_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[50].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_REFERER_EMPTY (grpc_static_mdelem_manifested[50]) /* "refresh": "" */ -#define GRPC_MDELEM_REFRESH_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[51].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_REFRESH_EMPTY (grpc_static_mdelem_manifested[51]) /* "retry-after": "" */ -#define GRPC_MDELEM_RETRY_AFTER_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[52].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_RETRY_AFTER_EMPTY (grpc_static_mdelem_manifested[52]) /* "server": "" */ -#define GRPC_MDELEM_SERVER_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[53].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_SERVER_EMPTY (grpc_static_mdelem_manifested[53]) /* "set-cookie": "" */ -#define GRPC_MDELEM_SET_COOKIE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[54].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_SET_COOKIE_EMPTY (grpc_static_mdelem_manifested[54]) /* "strict-transport-security": "" */ -#define GRPC_MDELEM_STRICT_TRANSPORT_SECURITY_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[55].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_STRICT_TRANSPORT_SECURITY_EMPTY \ + (grpc_static_mdelem_manifested[55]) /* "transfer-encoding": "" */ -#define GRPC_MDELEM_TRANSFER_ENCODING_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[56].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_TRANSFER_ENCODING_EMPTY (grpc_static_mdelem_manifested[56]) /* "user-agent": "" */ -#define GRPC_MDELEM_USER_AGENT_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[57].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_USER_AGENT_EMPTY (grpc_static_mdelem_manifested[57]) /* "vary": "" */ -#define GRPC_MDELEM_VARY_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[58].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_VARY_EMPTY (grpc_static_mdelem_manifested[58]) /* "via": "" */ -#define GRPC_MDELEM_VIA_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[59].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_VIA_EMPTY (grpc_static_mdelem_manifested[59]) /* "www-authenticate": "" */ -#define GRPC_MDELEM_WWW_AUTHENTICATE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[60].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_WWW_AUTHENTICATE_EMPTY (grpc_static_mdelem_manifested[60]) /* "grpc-status": "0" */ -#define GRPC_MDELEM_GRPC_STATUS_0 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[61].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_STATUS_0 (grpc_static_mdelem_manifested[61]) /* "grpc-status": "1" */ -#define GRPC_MDELEM_GRPC_STATUS_1 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[62].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_STATUS_1 (grpc_static_mdelem_manifested[62]) /* "grpc-status": "2" */ -#define GRPC_MDELEM_GRPC_STATUS_2 \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[63].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_STATUS_2 (grpc_static_mdelem_manifested[63]) /* "grpc-encoding": "identity" */ -#define GRPC_MDELEM_GRPC_ENCODING_IDENTITY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[64].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_ENCODING_IDENTITY (grpc_static_mdelem_manifested[64]) /* "grpc-encoding": "gzip" */ -#define GRPC_MDELEM_GRPC_ENCODING_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[65].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_ENCODING_GZIP (grpc_static_mdelem_manifested[65]) /* "grpc-encoding": "deflate" */ -#define GRPC_MDELEM_GRPC_ENCODING_DEFLATE \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[66].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_ENCODING_DEFLATE (grpc_static_mdelem_manifested[66]) /* "te": "trailers" */ -#define GRPC_MDELEM_TE_TRAILERS \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[67].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_TE_TRAILERS (grpc_static_mdelem_manifested[67]) /* "content-type": "application/grpc" */ -#define GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[68].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC \ + (grpc_static_mdelem_manifested[68]) /* ":scheme": "grpc" */ -#define GRPC_MDELEM_SCHEME_GRPC \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[69].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_SCHEME_GRPC (grpc_static_mdelem_manifested[69]) /* ":method": "PUT" */ -#define GRPC_MDELEM_METHOD_PUT \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[70].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_METHOD_PUT (grpc_static_mdelem_manifested[70]) /* "accept-encoding": "" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[71].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_ENCODING_EMPTY (grpc_static_mdelem_manifested[71]) /* "content-encoding": "identity" */ -#define GRPC_MDELEM_CONTENT_ENCODING_IDENTITY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[72].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_ENCODING_IDENTITY \ + (grpc_static_mdelem_manifested[72]) /* "content-encoding": "gzip" */ -#define GRPC_MDELEM_CONTENT_ENCODING_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[73].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_CONTENT_ENCODING_GZIP (grpc_static_mdelem_manifested[73]) /* "lb-token": "" */ -#define GRPC_MDELEM_LB_TOKEN_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[74].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_LB_TOKEN_EMPTY (grpc_static_mdelem_manifested[74]) /* "lb-cost-bin": "" */ -#define GRPC_MDELEM_LB_COST_BIN_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[75].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_LB_COST_BIN_EMPTY (grpc_static_mdelem_manifested[75]) /* "grpc-accept-encoding": "identity" */ -#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[76].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY \ + (grpc_static_mdelem_manifested[76]) /* "grpc-accept-encoding": "deflate" */ -#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[77].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE \ + (grpc_static_mdelem_manifested[77]) /* "grpc-accept-encoding": "identity,deflate" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[78].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) + (grpc_static_mdelem_manifested[78]) /* "grpc-accept-encoding": "gzip" */ -#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[79].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_GZIP \ + (grpc_static_mdelem_manifested[79]) /* "grpc-accept-encoding": "identity,gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[80].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) + (grpc_static_mdelem_manifested[80]) /* "grpc-accept-encoding": "deflate,gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE_COMMA_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[81].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) + (grpc_static_mdelem_manifested[81]) /* "grpc-accept-encoding": "identity,deflate,gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[82].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) + (grpc_static_mdelem_manifested[82]) /* "accept-encoding": "identity" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[83].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY (grpc_static_mdelem_manifested[83]) /* "accept-encoding": "gzip" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[84].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP (grpc_static_mdelem_manifested[84]) /* "accept-encoding": "identity,gzip" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[85].data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \ + (grpc_static_mdelem_manifested[85]) grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b); typedef enum { diff --git a/test/core/transport/chttp2/hpack_parser_test.cc b/test/core/transport/chttp2/hpack_parser_test.cc index 882ad726b5a..8be7dc17ed1 100644 --- a/test/core/transport/chttp2/hpack_parser_test.cc +++ b/test/core/transport/chttp2/hpack_parser_test.cc @@ -102,6 +102,7 @@ static void test_vectors(grpc_slice_split_mode mode) { grpc_chttp2_hpack_parser_destroy(&parser); grpc_chttp2_hpack_parser_init(&parser); + new (&parser.table) grpc_chttp2_hptbl(); /* D.3.1 */ test_vector(&parser, mode, "8286 8441 0f77 7777 2e65 7861 6d70 6c65" @@ -122,6 +123,7 @@ static void test_vectors(grpc_slice_split_mode mode) { grpc_chttp2_hpack_parser_destroy(&parser); grpc_chttp2_hpack_parser_init(&parser); + new (&parser.table) grpc_chttp2_hptbl(); /* D.4.1 */ test_vector(&parser, mode, "8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4" @@ -142,6 +144,7 @@ static void test_vectors(grpc_slice_split_mode mode) { grpc_chttp2_hpack_parser_destroy(&parser); grpc_chttp2_hpack_parser_init(&parser); + new (&parser.table) grpc_chttp2_hptbl(); grpc_chttp2_hptbl_set_max_bytes(&parser.table, 256); grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256); /* D.5.1 */ @@ -176,6 +179,7 @@ static void test_vectors(grpc_slice_split_mode mode) { grpc_chttp2_hpack_parser_destroy(&parser); grpc_chttp2_hpack_parser_init(&parser); + new (&parser.table) grpc_chttp2_hptbl(); grpc_chttp2_hptbl_set_max_bytes(&parser.table, 256); grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256); /* D.6.1 */ diff --git a/test/core/transport/chttp2/hpack_table_test.cc b/test/core/transport/chttp2/hpack_table_test.cc index c31975786f0..32b011b247b 100644 --- a/test/core/transport/chttp2/hpack_table_test.cc +++ b/test/core/transport/chttp2/hpack_table_test.cc @@ -48,8 +48,6 @@ static void test_static_lookup(void) { grpc_core::ExecCtx exec_ctx; grpc_chttp2_hptbl tbl; - grpc_chttp2_hptbl_init(&tbl); - LOG_TEST("test_static_lookup"); assert_index(&tbl, 1, ":authority", ""); assert_index(&tbl, 2, ":method", "GET"); @@ -125,7 +123,6 @@ static void test_many_additions(void) { LOG_TEST("test_many_additions"); grpc_core::ExecCtx exec_ctx; - grpc_chttp2_hptbl_init(&tbl); for (i = 0; i < 100000; i++) { grpc_mdelem elem; @@ -172,7 +169,6 @@ static void test_find(void) { LOG_TEST("test_find"); - grpc_chttp2_hptbl_init(&tbl); elem = grpc_mdelem_from_slices(grpc_slice_from_static_string("abc"), grpc_slice_from_static_string("xyz")); GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE); diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index d0ed1da7671..1d2ddf13f6a 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -433,8 +433,15 @@ static void BM_HpackParserInitDestroy(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; grpc_chttp2_hpack_parser p; + // Initial destruction so we don't leak memory in the loop. + grpc_chttp2_hptbl_destroy(&p.table); while (state.KeepRunning()) { grpc_chttp2_hpack_parser_init(&p); + // Note that grpc_chttp2_hpack_parser_destroy frees the table dynamic + // elements so we need to recreate it here. In actual operation, + // grpc_core::New allocates the table once + // and for all. + new (&p.table) grpc_chttp2_hptbl(); grpc_chttp2_hpack_parser_destroy(&p); grpc_core::ExecCtx::Get()->Flush(); } diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py index a149e001d75..95a545f5542 100755 --- a/tools/codegen/core/gen_static_metadata.py +++ b/tools/codegen/core/gen_static_metadata.py @@ -451,11 +451,37 @@ print >> H, ('extern grpc_core::StaticMetadata ' 'grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];') print >> H, ('extern uintptr_t ' 'grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT];') +print >> H, ('extern grpc_mdelem ' + 'grpc_static_mdelem_manifested[GRPC_STATIC_MDELEM_COUNT];') +print >> C, (''' +/* Warning: the core static metadata currently operates under the soft constraint +that the first GRPC_CHTTP2_LAST_STATIC_ENTRY (61) entries must contain +metadata specified by the http2 hpack standard. The CHTTP2 transport reads the +core metadata with this assumption in mind. If the order of the core static +metadata is to be changed, then the CHTTP2 transport must be changed as well to +stop relying on the core metadata. */ +''') +print >> C, ('grpc_mdelem ' + 'grpc_static_mdelem_manifested[GRPC_STATIC_MDELEM_COUNT] = {') +print >> C, '// clang-format off' +static_mds = [] for i, elem in enumerate(all_elems): + md_name = mangle(elem).upper() + md_human_readable = '"%s": "%s"' % elem + md_spec = ' /* %s: \n %s */\n' % (md_name, md_human_readable) + md_spec += ' GRPC_MAKE_MDELEM(\n' + md_spec += ((' &grpc_static_mdelem_table[%d].data(),\n' % i) + + ' GRPC_MDELEM_STORAGE_STATIC)') + static_mds.append(md_spec) +print >> C, ',\n'.join(static_mds) +print >> C, '// clang-format on' +print >> C, ('};') + +for i, elem in enumerate(all_elems): + md_name = mangle(elem).upper() print >> H, '/* "%s": "%s" */' % elem - print >> H, ( - '#define %s (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[%d].data(), ' - 'GRPC_MDELEM_STORAGE_STATIC))') % (mangle(elem).upper(), i) + print >> H, ('#define %s (grpc_static_mdelem_manifested[%d])' % (md_name, + i)) print >> H print >> C, ('uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] ' From 666d73e39cfaa7f40082c7234ca4f111a2178bce Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Wed, 3 Jul 2019 14:30:25 -0700 Subject: [PATCH 0892/1555] Cached metadata lookup for hpack_parser. --- .../chttp2/transport/hpack_parser.cc | 64 +++++++++++++++++-- .../transport/chttp2/transport/hpack_parser.h | 8 +++ 2 files changed, 66 insertions(+), 6 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index efbd997e994..f83f67ed195 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -779,6 +779,7 @@ static grpc_error* parse_indexed_field(grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end) { p->dynamic_table_update_allowed = 0; p->index = (*cur) & 0x7f; + p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */ return finish_indexed_field(p, cur + 1, end); } @@ -791,17 +792,32 @@ static grpc_error* parse_indexed_field_x(grpc_chttp2_hpack_parser* p, p->dynamic_table_update_allowed = 0; p->next_state = and_then; p->index = 0x7f; + p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */ p->parsing.value = &p->index; return parse_value0(p, cur + 1, end); } +/* When finishing with a header, get the cached md element for this index. + This is set in parse_value_string(). We ensure (in debug mode) that the + cached metadata corresponds with the index we are examining. */ +static grpc_mdelem get_precomputed_md_for_idx(grpc_chttp2_hpack_parser* p) { + GPR_DEBUG_ASSERT(p->md_for_index.payload != 0); + GPR_DEBUG_ASSERT(static_cast(p->index) == p->precomputed_md_index); + grpc_mdelem md = p->md_for_index; + GPR_DEBUG_ASSERT(!GRPC_MDISNULL(md)); /* handled in string parsing */ + p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */ +#ifndef NDEBUG + p->precomputed_md_index = -1; +#endif + return md; +} + /* finish a literal header with incremental indexing */ static grpc_error* finish_lithdr_incidx(grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end) { - grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index); - GPR_ASSERT(!GRPC_MDISNULL(md)); /* handled in string parsing */ GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX(); + grpc_mdelem md = get_precomputed_md_for_idx(p); grpc_error* err = on_hdr( p, grpc_mdelem_from_slices(grpc_slice_ref_internal(GRPC_MDKEY(md)), take_string(p, &p->value, true))); @@ -829,6 +845,7 @@ static grpc_error* parse_lithdr_incidx(grpc_chttp2_hpack_parser* p, p->dynamic_table_update_allowed = 0; p->next_state = and_then; p->index = (*cur) & 0x3f; + p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */ return parse_string_prefix(p, cur + 1, end); } @@ -842,6 +859,7 @@ static grpc_error* parse_lithdr_incidx_x(grpc_chttp2_hpack_parser* p, p->dynamic_table_update_allowed = 0; p->next_state = and_then; p->index = 0x3f; + p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */ p->parsing.value = &p->index; return parse_value0(p, cur + 1, end); } @@ -862,9 +880,8 @@ static grpc_error* parse_lithdr_incidx_v(grpc_chttp2_hpack_parser* p, static grpc_error* finish_lithdr_notidx(grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end) { - grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index); - GPR_ASSERT(!GRPC_MDISNULL(md)); /* handled in string parsing */ GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX(); + grpc_mdelem md = get_precomputed_md_for_idx(p); grpc_error* err = on_hdr( p, grpc_mdelem_from_slices(grpc_slice_ref_internal(GRPC_MDKEY(md)), take_string(p, &p->value, false))); @@ -892,6 +909,7 @@ static grpc_error* parse_lithdr_notidx(grpc_chttp2_hpack_parser* p, p->dynamic_table_update_allowed = 0; p->next_state = and_then; p->index = (*cur) & 0xf; + p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */ return parse_string_prefix(p, cur + 1, end); } @@ -905,6 +923,7 @@ static grpc_error* parse_lithdr_notidx_x(grpc_chttp2_hpack_parser* p, p->dynamic_table_update_allowed = 0; p->next_state = and_then; p->index = 0xf; + p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */ p->parsing.value = &p->index; return parse_value0(p, cur + 1, end); } @@ -925,9 +944,8 @@ static grpc_error* parse_lithdr_notidx_v(grpc_chttp2_hpack_parser* p, static grpc_error* finish_lithdr_nvridx(grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end) { - grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index); - GPR_ASSERT(!GRPC_MDISNULL(md)); /* handled in string parsing */ GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX(); + grpc_mdelem md = get_precomputed_md_for_idx(p); grpc_error* err = on_hdr( p, grpc_mdelem_from_slices(grpc_slice_ref_internal(GRPC_MDKEY(md)), take_string(p, &p->value, false))); @@ -955,6 +973,7 @@ static grpc_error* parse_lithdr_nvridx(grpc_chttp2_hpack_parser* p, p->dynamic_table_update_allowed = 0; p->next_state = and_then; p->index = (*cur) & 0xf; + p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */ return parse_string_prefix(p, cur + 1, end); } @@ -968,6 +987,7 @@ static grpc_error* parse_lithdr_nvridx_x(grpc_chttp2_hpack_parser* p, p->dynamic_table_update_allowed = 0; p->next_state = and_then; p->index = 0xf; + p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */ p->parsing.value = &p->index; return parse_value0(p, cur + 1, end); } @@ -1007,6 +1027,7 @@ static grpc_error* parse_max_tbl_size(grpc_chttp2_hpack_parser* p, } p->dynamic_table_update_allowed--; p->index = (*cur) & 0x1f; + p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */ return finish_max_tbl_size(p, cur + 1, end); } @@ -1025,6 +1046,7 @@ static grpc_error* parse_max_tbl_size_x(grpc_chttp2_hpack_parser* p, p->dynamic_table_update_allowed--; p->next_state = and_then; p->index = 0x1f; + p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */ p->parsing.value = &p->index; return parse_value0(p, cur + 1, end); } @@ -1499,6 +1521,23 @@ static bool is_binary_literal_header(grpc_chttp2_hpack_parser* p) { : p->key.data.referenced); } +/* Cache the metadata for the given index during initial parsing. This avoids a + pointless recomputation of the metadata when finishing a header. We read the + cached value in get_precomputed_md_for_idx(). */ +static void set_precomputed_md_idx(grpc_chttp2_hpack_parser* p, + grpc_mdelem md) { + GPR_DEBUG_ASSERT(p->md_for_index.payload == 0); + GPR_DEBUG_ASSERT(p->precomputed_md_index == -1); + p->md_for_index = md; +#ifndef NDEBUG + p->precomputed_md_index = p->index; +#endif +} + +/* Determines if a metadata element key associated with the current parser index + is a binary indexed header during string parsing. We'll need to revisit this + metadata when we're done parsing, so we cache the metadata for this index + here using set_precomputed_md_idx(). */ static grpc_error* is_binary_indexed_header(grpc_chttp2_hpack_parser* p, bool* is) { grpc_mdelem elem = grpc_chttp2_hptbl_lookup(&p->table, p->index); @@ -1519,6 +1558,7 @@ static grpc_error* is_binary_indexed_header(grpc_chttp2_hpack_parser* p, * interned. * 4. Both static and interned element slices have non-null refcounts. */ *is = grpc_is_refcounted_slice_binary_header(GRPC_MDKEY(elem)); + set_precomputed_md_idx(p, elem); return GRPC_ERROR_NONE; } @@ -1557,6 +1597,18 @@ void grpc_chttp2_hpack_parser_init(grpc_chttp2_hpack_parser* p) { p->value.data.copied.str = nullptr; p->value.data.copied.capacity = 0; p->value.data.copied.length = 0; + /* Cached metadata for the current index the parser is handling. This is set + to 0 initially, invalidated when the index changes, and invalidated when it + is read (by get_precomputed_md_for_idx()). It is set during string parsing, + by set_precomputed_md_idx() - which is called by parse_value_string(). + The goal here is to avoid recomputing the metadata for the index when + finishing with a header as well as the initial parse. */ + p->md_for_index.payload = 0; +#ifndef NDEBUG + /* In debug mode, this ensures that the cached metadata we're reading is in + * fact correct for the index we are examining. */ + p->precomputed_md_index = -1; +#endif p->dynamic_table_update_allowed = 2; p->last_error = GRPC_ERROR_NONE; grpc_chttp2_hptbl_init(&p->table); diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.h b/src/core/ext/transport/chttp2/transport/hpack_parser.h index 3dc8e13bea2..c5691244028 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.h +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.h @@ -69,6 +69,14 @@ struct grpc_chttp2_hpack_parser { grpc_chttp2_hpack_parser_string value; /* parsed index */ uint32_t index; + /* When we parse a value string, we determine the metadata element for a + specific index, which we need again when we're finishing up with that + header. To avoid calculating the metadata element for that index a second + time at that stage, we cache (and invalidate) the element here. */ + grpc_mdelem md_for_index; +#ifndef NDEBUG + int64_t precomputed_md_index; +#endif /* length of source bytes for the currently parsing string */ uint32_t strlen; /* number of source bytes read for the currently parsing string */ From c8a277add49f15cee5dfbea0bc2ec82a160c70eb Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Mon, 15 Jul 2019 16:54:17 -0700 Subject: [PATCH 0893/1555] Several documentation fixes --- src/python/grpcio/grpc/__init__.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index ac5192e0fed..a1df5fb161c 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -339,8 +339,7 @@ class RpcContext(six.with_metaclass(abc.ABCMeta)): callback: A no-parameter callable to be called on RPC termination. Returns: - bool: - True if the callback was added and will be called later; False if + True if the callback was added and will be called later; False if the callback was not added and will not be called (because the RPC already terminated or some other reason). """ @@ -1285,6 +1284,7 @@ class RpcMethodHandler(six.with_metaclass(abc.ABCMeta)): class HandlerCallDetails(six.with_metaclass(abc.ABCMeta)): """Describes an RPC that has just arrived for service. + Attributes: method: The method name of the RPC. invocation_metadata: The :term:`metadata` sent by the client. @@ -1381,12 +1381,10 @@ class Server(six.with_metaclass(abc.ABCMeta)): This method may only be called before starting the server. Args: - address: The address for which to open a port. - if the port is 0, or not specified in the address, then gRPC runtime - will choose a port. + address: The address for which to open a port. If the port is 0, + or not specified in the address, then gRPC runtime will choose a port. Returns: - integer: An integer port on which server will accept RPC requests. """ raise NotImplementedError() @@ -1404,7 +1402,6 @@ class Server(six.with_metaclass(abc.ABCMeta)): server_credentials: A ServerCredentials object. Returns: - integer: An integer port on which server will accept RPC requests. """ raise NotImplementedError() From 34c76f527d12d7f0fba739e41dcdb06d82d4910d Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Mon, 15 Jul 2019 17:58:51 -0700 Subject: [PATCH 0894/1555] Add default size 1 for thread pool --- src/core/lib/iomgr/executor/threadpool.cc | 3 ++ src/core/lib/iomgr/executor/threadpool.h | 3 +- test/core/iomgr/threadpool_test.cc | 45 +++++++++++++---------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/core/lib/iomgr/executor/threadpool.cc b/src/core/lib/iomgr/executor/threadpool.cc index 166bf0a34a0..9bb1fd1d1cd 100644 --- a/src/core/lib/iomgr/executor/threadpool.cc +++ b/src/core/lib/iomgr/executor/threadpool.cc @@ -51,6 +51,9 @@ void ThreadPool::SharedThreadPoolConstructor() { // All worker threads in thread pool must be joinable. thread_options_.set_joinable(true); + // Create at least 1 worker threads. + if (num_threads_ <= 0) num_threads_ = 1; + queue_ = New(); threads_ = static_cast( gpr_zalloc(num_threads_ * sizeof(ThreadPoolWorker*))); diff --git a/src/core/lib/iomgr/executor/threadpool.h b/src/core/lib/iomgr/executor/threadpool.h index 3f79bbe9d08..e37f5727ced 100644 --- a/src/core/lib/iomgr/executor/threadpool.h +++ b/src/core/lib/iomgr/executor/threadpool.h @@ -101,7 +101,8 @@ class ThreadPoolWorker { class ThreadPool : public ThreadPoolInterface { public: // Creates a thread pool with size of "num_threads", with default thread name - // "ThreadPoolWorker" and all thread options set to default. + // "ThreadPoolWorker" and all thread options set to default. If the given size + // is 0 or less, there will be 1 worker threads created inside pool. ThreadPool(int num_threads); // Same as ThreadPool(int num_threads) constructor, except diff --git a/test/core/iomgr/threadpool_test.cc b/test/core/iomgr/threadpool_test.cc index 9c678fa4304..1219d25f3b7 100644 --- a/test/core/iomgr/threadpool_test.cc +++ b/test/core/iomgr/threadpool_test.cc @@ -20,10 +20,29 @@ #include "test/core/util/test_config.h" -const int kSmallThreadPoolSize = 20; -const int kLargeThreadPoolSize = 100; -const int kThreadSmallIter = 100; -const int kThreadLargeIter = 10000; +static const int kSmallThreadPoolSize = 20; +static const int kLargeThreadPoolSize = 100; +static const int kThreadSmallIter = 100; +static const int kThreadLargeIter = 10000; + +static void test_size_zero(void) { + gpr_log(GPR_INFO, "test_size_zero"); + grpc_core::ThreadPool* pool_size_zero = + grpc_core::New(0); + GPR_ASSERT(pool_size_zero->pool_capacity() == 1); + Delete(pool_size_zero); +} + +static void test_constructor_option(void) { + gpr_log(GPR_INFO, "test_constructor_option"); + // Tests options + grpc_core::Thread::Options options; + options.set_stack_size(192 * 1024); // Random non-default value + grpc_core::ThreadPool* pool = grpc_core::New( + 0, "test_constructor_option", options); + GPR_ASSERT(pool->thread_options().stack_size() == options.stack_size()); + Delete(pool); +} // Simple functor for testing. It will count how many times being called. class SimpleFunctorForAdd : public grpc_experimental_completion_queue_functor { @@ -109,21 +128,6 @@ class WorkThread { grpc_core::Thread thd_; }; -static void test_constructor(void) { - // Size is 0 case - grpc_core::ThreadPool* pool_size_zero = - grpc_core::New(0); - GPR_ASSERT(pool_size_zero->pool_capacity() == 0); - Delete(pool_size_zero); - // Tests options - grpc_core::Thread::Options options; - options.set_stack_size(192 * 1024); // Random non-default value - grpc_core::ThreadPool* pool = - grpc_core::New(0, "test_constructor", options); - GPR_ASSERT(pool->thread_options().stack_size() == options.stack_size()); - Delete(pool); -} - static void test_multi_add(void) { gpr_log(GPR_INFO, "test_multi_add"); const int num_work_thds = 10; @@ -178,7 +182,8 @@ static void test_one_thread_FIFO(void) { int main(int argc, char** argv) { grpc::testing::TestEnvironment env(argc, argv); grpc_init(); - test_constructor(); + test_size_zero(); + test_constructor_option(); test_add(); test_multi_add(); test_one_thread_FIFO(); From eb72215622aaa69e74dad4eb12d3030ab57455f2 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Mon, 15 Jul 2019 18:16:54 -0700 Subject: [PATCH 0895/1555] Removed reference of GRPCConnectivityMonitor --- gRPC.podspec | 2 +- src/objective-c/GRPCClient/GRPCCall.m | 7 ------- src/objective-c/GRPCClient/private/GRPCChannelPool.m | 6 +----- src/objective-c/GRPCClient/private/GRPCHost.m | 1 - 4 files changed, 2 insertions(+), 14 deletions(-) diff --git a/gRPC.podspec b/gRPC.podspec index bbfd08f9774..7b253a2b2bb 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -58,8 +58,8 @@ Pod::Spec.new do |s| ss.header_mappings_dir = "#{src_dir}" ss.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}" - ss.exclude_files = "#{src_dir}/GRPCCall+GID.{h,m}" ss.private_header_files = "#{src_dir}/private/*.h", "#{src_dir}/internal/*.h" + ss.exclude_files = "#{src_dir}/GRPCCall+GID.{h,m}", "#{src_dir}/private/GRPCConnectivityMonitor.{h,m}" ss.dependency 'gRPC-Core', version end diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 45b03e4b684..c3b06d6c72d 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -33,7 +33,6 @@ #import "private/GRPCCallInternal.h" #import "private/GRPCChannelPool.h" #import "private/GRPCCompletionQueue.h" -#import "private/GRPCConnectivityMonitor.h" #import "private/GRPCHost.h" #import "private/GRPCRequestHeaders.h" #import "private/GRPCWrappedCall.h" @@ -288,7 +287,6 @@ const char *kCFStreamVarName = "grpc_cfstream"; GRPCCallSafety _callSafety; GRPCCallOptions *_callOptions; GRPCWrappedCall *_wrappedCall; - GRPCConnectivityMonitor *_connectivityMonitor; // The C gRPC library has less guarantees on the ordering of events than we // do. Particularly, in the face of errors, there's no ordering guarantee at @@ -494,8 +492,6 @@ const char *kCFStreamVarName = "grpc_cfstream"; } - (void)dealloc { - [GRPCConnectivityMonitor unregisterObserver:self]; - __block GRPCWrappedCall *wrappedCall = _wrappedCall; dispatch_async(_callQueue, ^{ wrappedCall = nil; @@ -797,9 +793,6 @@ const char *kCFStreamVarName = "grpc_cfstream"; // Connectivity monitor is not required for CFStream char *enableCFStream = getenv(kCFStreamVarName); - if (enableCFStream != nil && enableCFStream[0] != '1') { - [GRPCConnectivityMonitor registerObserver:self selector:@selector(connectivityChanged:)]; - } } // Now that the RPC has been initiated, request writes can start. diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.m b/src/objective-c/GRPCClient/private/GRPCChannelPool.m index 60a33eda824..e8b6944d4b9 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannelPool.m +++ b/src/objective-c/GRPCClient/private/GRPCChannelPool.m @@ -24,7 +24,6 @@ #import "GRPCChannelPool+Test.h" #import "GRPCChannelPool.h" #import "GRPCCompletionQueue.h" -#import "GRPCConnectivityMonitor.h" #import "GRPCCronetChannelFactory.h" #import "GRPCInsecureChannelFactory.h" #import "GRPCSecureChannelFactory.h" @@ -218,15 +217,12 @@ static const NSTimeInterval kDefaultChannelDestroyDelay = 30; // Connectivity monitor is not required for CFStream char *enableCFStream = getenv(kCFStreamVarName); - if (enableCFStream == nil || enableCFStream[0] != '1') { - [GRPCConnectivityMonitor registerObserver:self selector:@selector(connectivityChange:)]; - } } return self; } - (void)dealloc { - [GRPCConnectivityMonitor unregisterObserver:self]; + } - (GRPCPooledChannel *)channelWithHost:(NSString *)host callOptions:(GRPCCallOptions *)callOptions { diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m index 24348c3aed7..63ffc927411 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCHost.m @@ -28,7 +28,6 @@ #import "../internal/GRPCCallOptions+Internal.h" #import "GRPCChannelFactory.h" #import "GRPCCompletionQueue.h" -#import "GRPCConnectivityMonitor.h" #import "GRPCCronetChannelFactory.h" #import "GRPCSecureChannelFactory.h" #import "NSDictionary+GRPC.h" From 3afb0b263565125a3c2b2a1634ae869b4f055a6d Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Mon, 15 Jul 2019 18:39:57 -0700 Subject: [PATCH 0896/1555] Fix fallback test breaking on mac bazel --- test/cpp/interop/grpclb_fallback_test.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/cpp/interop/grpclb_fallback_test.cc b/test/cpp/interop/grpclb_fallback_test.cc index 3622482b67d..38474b29749 100644 --- a/test/cpp/interop/grpclb_fallback_test.cc +++ b/test/cpp/interop/grpclb_fallback_test.cc @@ -18,6 +18,8 @@ #include +#include "src/core/lib/iomgr/port.h" + #include #include #include @@ -67,6 +69,7 @@ DEFINE_string( "slow_fallback_after_startup : fallback after startup due to LB/backend " "addresses becoming blackholed;\n"); +#ifdef GRPC_HAVE_TCP_USER_TIMEOUT using grpc::testing::GrpclbRouteType; using grpc::testing::SimpleRequest; using grpc::testing::SimpleResponse; @@ -270,3 +273,11 @@ int main(int argc, char** argv) { abort(); } } +#else +int main(int argc, char** argv) { + grpc::testing::InitTest(&argc, &argv, true); + gpr_log(GPR_ERROR, + "This test requires TCP_USER_TIMEOUT, which isn't available"); + abort(); +} +#endif // GRPC_HAVE_TCP_USER_TIMEOUT From 881e0385296a1b99332eebaf2a4aa60f62d06ef9 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Mon, 15 Jul 2019 18:55:12 -0700 Subject: [PATCH 0897/1555] Fixing duplicating problem --- gRPC-Core.podspec | 4 ++-- templates/gRPC-Core.podspec.template | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 2dfcb311b5d..f309161fadb 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -1387,7 +1387,7 @@ Pod::Spec.new do |s| # TODO (mxyan): Instead of this hack, add include path "third_party" to C core's include path? s.prepare_command = <<-END_OF_COMMAND - find src/core/ -type f -print0 | xargs -0 -L1 sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS\\\n #include \\\n#else\\\n #include "\\1"\\\n#endif;g' - find src/core/ -type f \\( -path '*.h' -or -path '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i '' 's;#include ;#if COCOAPODS\\\n #include \\\n#else\\\n #include \\\n#endif;g' + sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS==1\\\n #include \\\n#else\\\n #include "\\1"\\\n#endif;g' $(find src/core -type f -print | xargs grep -H -c '#if COCOAPODS==1' | grep 0$ | cut -d':' -f1) + sed -E -i '' 's;#include ;#if COCOAPODS==1\\\n #include \\\n#else\\\n #include \\\n#endif;g' $(find src/core -type f \\( -path '*.h' -or -path '*.cc' \\) -print | xargs grep -H -c '#if COCOAPODS==1' | grep 0$ | cut -d':' -f1) END_OF_COMMAND end diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template index 652c4ed43f0..63baa01a27f 100644 --- a/templates/gRPC-Core.podspec.template +++ b/templates/gRPC-Core.podspec.template @@ -212,7 +212,7 @@ # TODO (mxyan): Instead of this hack, add include path "third_party" to C core's include path? s.prepare_command = <<-END_OF_COMMAND - find src/core/ -type f -print0 | xargs -0 -L1 sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS\\\n #include \\\n#else\\\n #include "\\1"\\\n#endif;g' - find src/core/ -type f \\( -path '*.h' -or -path '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i '' 's;#include ;#if COCOAPODS\\\n #include \\\n#else\\\n #include \\\n#endif;g' + sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS==1\\\n #include \\\n#else\\\n #include "\\1"\\\n#endif;g' $(find src/core -type f -print | xargs grep -H -c '#if COCOAPODS==1' | grep 0$ | cut -d':' -f1) + sed -E -i '' 's;#include ;#if COCOAPODS==1\\\n #include \\\n#else\\\n #include \\\n#endif;g' $(find src/core -type f \\( -path '*.h' -or -path '*.cc' \\) -print | xargs grep -H -c '#if COCOAPODS==1' | grep 0$ | cut -d':' -f1) END_OF_COMMAND end From dce5408b848bd7ceb8577bdbbccfb94019de372a Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 16 Jul 2019 08:13:42 -0400 Subject: [PATCH 0898/1555] clang format code --- src/compiler/csharp_generator.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc index 386d1783b9f..d7ba4f2636a 100644 --- a/src/compiler/csharp_generator.cc +++ b/src/compiler/csharp_generator.cc @@ -437,8 +437,8 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor* service, "/// The channel to use to make remote " "calls.\n", "servicename", GetServiceClassName(service)); - out->Print("public $name$(grpc::ChannelBase channel) : base(channel)\n", "name", - GetClientClassName(service)); + out->Print("public $name$(grpc::ChannelBase channel) : base(channel)\n", + "name", GetClientClassName(service)); out->Print("{\n"); out->Print("}\n"); } From fd3d125988862b13c452abb1f844e8961994946a Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 16 Jul 2019 08:31:44 -0400 Subject: [PATCH 0899/1555] regenerate C# protos with src/csharp/generate_proto_csharp.sh --- src/csharp/Grpc.Examples/MathGrpc.cs | 2 +- .../BenchmarkServiceGrpc.cs | 2 +- .../EmptyServiceGrpc.cs | 2 +- .../Grpc.IntegrationTesting/Messages.cs | 110 ++++++++++++++---- .../Grpc.IntegrationTesting/MetricsGrpc.cs | 2 +- .../ReportQpsScenarioServiceGrpc.cs | 2 +- .../Grpc.IntegrationTesting/TestGrpc.cs | 6 +- .../WorkerServiceGrpc.cs | 2 +- 8 files changed, 96 insertions(+), 32 deletions(-) diff --git a/src/csharp/Grpc.Examples/MathGrpc.cs b/src/csharp/Grpc.Examples/MathGrpc.cs index fab64354411..5186d2f6dae 100644 --- a/src/csharp/Grpc.Examples/MathGrpc.cs +++ b/src/csharp/Grpc.Examples/MathGrpc.cs @@ -130,7 +130,7 @@ namespace Math { { /// Creates a new client for Math /// The channel to use to make remote calls. - public MathClient(grpc::Channel channel) : base(channel) + public MathClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for Math that uses a custom CallInvoker. diff --git a/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceGrpc.cs b/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceGrpc.cs index 5b37b144f2a..4a608be318c 100644 --- a/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceGrpc.cs @@ -148,7 +148,7 @@ namespace Grpc.Testing { { /// Creates a new client for BenchmarkService /// The channel to use to make remote calls. - public BenchmarkServiceClient(grpc::Channel channel) : base(channel) + public BenchmarkServiceClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for BenchmarkService that uses a custom CallInvoker. diff --git a/src/csharp/Grpc.IntegrationTesting/EmptyServiceGrpc.cs b/src/csharp/Grpc.IntegrationTesting/EmptyServiceGrpc.cs index 50c6e159206..30fd6dec542 100644 --- a/src/csharp/Grpc.IntegrationTesting/EmptyServiceGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/EmptyServiceGrpc.cs @@ -49,7 +49,7 @@ namespace Grpc.Testing { { /// Creates a new client for EmptyService /// The channel to use to make remote calls. - public EmptyServiceClient(grpc::Channel channel) : base(channel) + public EmptyServiceClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for EmptyService that uses a custom CallInvoker. diff --git a/src/csharp/Grpc.IntegrationTesting/Messages.cs b/src/csharp/Grpc.IntegrationTesting/Messages.cs index 3b6c0010222..5c5042b75b6 100644 --- a/src/csharp/Grpc.IntegrationTesting/Messages.cs +++ b/src/csharp/Grpc.IntegrationTesting/Messages.cs @@ -28,41 +28,42 @@ namespace Grpc.Testing { "LnRlc3RpbmciGgoJQm9vbFZhbHVlEg0KBXZhbHVlGAEgASgIIkAKB1BheWxv", "YWQSJwoEdHlwZRgBIAEoDjIZLmdycGMudGVzdGluZy5QYXlsb2FkVHlwZRIM", "CgRib2R5GAIgASgMIisKCkVjaG9TdGF0dXMSDAoEY29kZRgBIAEoBRIPCgdt", - "ZXNzYWdlGAIgASgJIs4CCg1TaW1wbGVSZXF1ZXN0EjAKDXJlc3BvbnNlX3R5", + "ZXNzYWdlGAIgASgJIuYCCg1TaW1wbGVSZXF1ZXN0EjAKDXJlc3BvbnNlX3R5", "cGUYASABKA4yGS5ncnBjLnRlc3RpbmcuUGF5bG9hZFR5cGUSFQoNcmVzcG9u", "c2Vfc2l6ZRgCIAEoBRImCgdwYXlsb2FkGAMgASgLMhUuZ3JwYy50ZXN0aW5n", "LlBheWxvYWQSFQoNZmlsbF91c2VybmFtZRgEIAEoCBIYChBmaWxsX29hdXRo", "X3Njb3BlGAUgASgIEjQKE3Jlc3BvbnNlX2NvbXByZXNzZWQYBiABKAsyFy5n", "cnBjLnRlc3RpbmcuQm9vbFZhbHVlEjEKD3Jlc3BvbnNlX3N0YXR1cxgHIAEo", "CzIYLmdycGMudGVzdGluZy5FY2hvU3RhdHVzEjIKEWV4cGVjdF9jb21wcmVz", - "c2VkGAggASgLMhcuZ3JwYy50ZXN0aW5nLkJvb2xWYWx1ZSJfCg5TaW1wbGVS", - "ZXNwb25zZRImCgdwYXlsb2FkGAEgASgLMhUuZ3JwYy50ZXN0aW5nLlBheWxv", - "YWQSEAoIdXNlcm5hbWUYAiABKAkSEwoLb2F1dGhfc2NvcGUYAyABKAkidwoZ", - "U3RyZWFtaW5nSW5wdXRDYWxsUmVxdWVzdBImCgdwYXlsb2FkGAEgASgLMhUu", - "Z3JwYy50ZXN0aW5nLlBheWxvYWQSMgoRZXhwZWN0X2NvbXByZXNzZWQYAiAB", - "KAsyFy5ncnBjLnRlc3RpbmcuQm9vbFZhbHVlIj0KGlN0cmVhbWluZ0lucHV0", - "Q2FsbFJlc3BvbnNlEh8KF2FnZ3JlZ2F0ZWRfcGF5bG9hZF9zaXplGAEgASgF", - "ImQKElJlc3BvbnNlUGFyYW1ldGVycxIMCgRzaXplGAEgASgFEhMKC2ludGVy", - "dmFsX3VzGAIgASgFEisKCmNvbXByZXNzZWQYAyABKAsyFy5ncnBjLnRlc3Rp", - "bmcuQm9vbFZhbHVlIugBChpTdHJlYW1pbmdPdXRwdXRDYWxsUmVxdWVzdBIw", - "Cg1yZXNwb25zZV90eXBlGAEgASgOMhkuZ3JwYy50ZXN0aW5nLlBheWxvYWRU", - "eXBlEj0KE3Jlc3BvbnNlX3BhcmFtZXRlcnMYAiADKAsyIC5ncnBjLnRlc3Rp", - "bmcuUmVzcG9uc2VQYXJhbWV0ZXJzEiYKB3BheWxvYWQYAyABKAsyFS5ncnBj", - "LnRlc3RpbmcuUGF5bG9hZBIxCg9yZXNwb25zZV9zdGF0dXMYByABKAsyGC5n", - "cnBjLnRlc3RpbmcuRWNob1N0YXR1cyJFChtTdHJlYW1pbmdPdXRwdXRDYWxs", - "UmVzcG9uc2USJgoHcGF5bG9hZBgBIAEoCzIVLmdycGMudGVzdGluZy5QYXls", - "b2FkIjMKD1JlY29ubmVjdFBhcmFtcxIgChhtYXhfcmVjb25uZWN0X2JhY2tv", - "ZmZfbXMYASABKAUiMwoNUmVjb25uZWN0SW5mbxIOCgZwYXNzZWQYASABKAgS", - "EgoKYmFja29mZl9tcxgCIAMoBSofCgtQYXlsb2FkVHlwZRIQCgxDT01QUkVT", - "U0FCTEUQAGIGcHJvdG8z")); + "c2VkGAggASgLMhcuZ3JwYy50ZXN0aW5nLkJvb2xWYWx1ZRIWCg5maWxsX3Nl", + "cnZlcl9pZBgJIAEoCCJyCg5TaW1wbGVSZXNwb25zZRImCgdwYXlsb2FkGAEg", + "ASgLMhUuZ3JwYy50ZXN0aW5nLlBheWxvYWQSEAoIdXNlcm5hbWUYAiABKAkS", + "EwoLb2F1dGhfc2NvcGUYAyABKAkSEQoJc2VydmVyX2lkGAQgASgJIncKGVN0", + "cmVhbWluZ0lucHV0Q2FsbFJlcXVlc3QSJgoHcGF5bG9hZBgBIAEoCzIVLmdy", + "cGMudGVzdGluZy5QYXlsb2FkEjIKEWV4cGVjdF9jb21wcmVzc2VkGAIgASgL", + "MhcuZ3JwYy50ZXN0aW5nLkJvb2xWYWx1ZSI9ChpTdHJlYW1pbmdJbnB1dENh", + "bGxSZXNwb25zZRIfChdhZ2dyZWdhdGVkX3BheWxvYWRfc2l6ZRgBIAEoBSJk", + "ChJSZXNwb25zZVBhcmFtZXRlcnMSDAoEc2l6ZRgBIAEoBRITCgtpbnRlcnZh", + "bF91cxgCIAEoBRIrCgpjb21wcmVzc2VkGAMgASgLMhcuZ3JwYy50ZXN0aW5n", + "LkJvb2xWYWx1ZSLoAQoaU3RyZWFtaW5nT3V0cHV0Q2FsbFJlcXVlc3QSMAoN", + "cmVzcG9uc2VfdHlwZRgBIAEoDjIZLmdycGMudGVzdGluZy5QYXlsb2FkVHlw", + "ZRI9ChNyZXNwb25zZV9wYXJhbWV0ZXJzGAIgAygLMiAuZ3JwYy50ZXN0aW5n", + "LlJlc3BvbnNlUGFyYW1ldGVycxImCgdwYXlsb2FkGAMgASgLMhUuZ3JwYy50", + "ZXN0aW5nLlBheWxvYWQSMQoPcmVzcG9uc2Vfc3RhdHVzGAcgASgLMhguZ3Jw", + "Yy50ZXN0aW5nLkVjaG9TdGF0dXMiRQobU3RyZWFtaW5nT3V0cHV0Q2FsbFJl", + "c3BvbnNlEiYKB3BheWxvYWQYASABKAsyFS5ncnBjLnRlc3RpbmcuUGF5bG9h", + "ZCIzCg9SZWNvbm5lY3RQYXJhbXMSIAoYbWF4X3JlY29ubmVjdF9iYWNrb2Zm", + "X21zGAEgASgFIjMKDVJlY29ubmVjdEluZm8SDgoGcGFzc2VkGAEgASgIEhIK", + "CmJhY2tvZmZfbXMYAiADKAUqHwoLUGF5bG9hZFR5cGUSEAoMQ09NUFJFU1NB", + "QkxFEABiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Grpc.Testing.PayloadType), }, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.BoolValue), global::Grpc.Testing.BoolValue.Parser, new[]{ "Value" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.Payload), global::Grpc.Testing.Payload.Parser, new[]{ "Type", "Body" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.EchoStatus), global::Grpc.Testing.EchoStatus.Parser, new[]{ "Code", "Message" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.SimpleRequest), global::Grpc.Testing.SimpleRequest.Parser, new[]{ "ResponseType", "ResponseSize", "Payload", "FillUsername", "FillOauthScope", "ResponseCompressed", "ResponseStatus", "ExpectCompressed" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.SimpleResponse), global::Grpc.Testing.SimpleResponse.Parser, new[]{ "Payload", "Username", "OauthScope" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.SimpleRequest), global::Grpc.Testing.SimpleRequest.Parser, new[]{ "ResponseType", "ResponseSize", "Payload", "FillUsername", "FillOauthScope", "ResponseCompressed", "ResponseStatus", "ExpectCompressed", "FillServerId" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.SimpleResponse), global::Grpc.Testing.SimpleResponse.Parser, new[]{ "Payload", "Username", "OauthScope", "ServerId" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.StreamingInputCallRequest), global::Grpc.Testing.StreamingInputCallRequest.Parser, new[]{ "Payload", "ExpectCompressed" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.StreamingInputCallResponse), global::Grpc.Testing.StreamingInputCallResponse.Parser, new[]{ "AggregatedPayloadSize" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ResponseParameters), global::Grpc.Testing.ResponseParameters.Parser, new[]{ "Size", "IntervalUs", "Compressed" }, null, null, null), @@ -589,6 +590,7 @@ namespace Grpc.Testing { responseCompressed_ = other.responseCompressed_ != null ? other.responseCompressed_.Clone() : null; responseStatus_ = other.responseStatus_ != null ? other.responseStatus_.Clone() : null; expectCompressed_ = other.expectCompressed_ != null ? other.expectCompressed_.Clone() : null; + fillServerId_ = other.fillServerId_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -713,6 +715,20 @@ namespace Grpc.Testing { } } + /// Field number for the "fill_server_id" field. + public const int FillServerIdFieldNumber = 9; + private bool fillServerId_; + /// + /// Whether SimpleResponse should include server_id. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool FillServerId { + get { return fillServerId_; } + set { + fillServerId_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as SimpleRequest); @@ -734,6 +750,7 @@ namespace Grpc.Testing { if (!object.Equals(ResponseCompressed, other.ResponseCompressed)) return false; if (!object.Equals(ResponseStatus, other.ResponseStatus)) return false; if (!object.Equals(ExpectCompressed, other.ExpectCompressed)) return false; + if (FillServerId != other.FillServerId) return false; return Equals(_unknownFields, other._unknownFields); } @@ -748,6 +765,7 @@ namespace Grpc.Testing { if (responseCompressed_ != null) hash ^= ResponseCompressed.GetHashCode(); if (responseStatus_ != null) hash ^= ResponseStatus.GetHashCode(); if (expectCompressed_ != null) hash ^= ExpectCompressed.GetHashCode(); + if (FillServerId != false) hash ^= FillServerId.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } @@ -793,6 +811,10 @@ namespace Grpc.Testing { output.WriteRawTag(66); output.WriteMessage(ExpectCompressed); } + if (FillServerId != false) { + output.WriteRawTag(72); + output.WriteBool(FillServerId); + } if (_unknownFields != null) { _unknownFields.WriteTo(output); } @@ -825,6 +847,9 @@ namespace Grpc.Testing { if (expectCompressed_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(ExpectCompressed); } + if (FillServerId != false) { + size += 1 + 1; + } if (_unknownFields != null) { size += _unknownFields.CalculateSize(); } @@ -872,6 +897,9 @@ namespace Grpc.Testing { } ExpectCompressed.MergeFrom(other.ExpectCompressed); } + if (other.FillServerId != false) { + FillServerId = other.FillServerId; + } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } @@ -927,6 +955,10 @@ namespace Grpc.Testing { input.ReadMessage(ExpectCompressed); break; } + case 72: { + FillServerId = input.ReadBool(); + break; + } } } } @@ -964,6 +996,7 @@ namespace Grpc.Testing { payload_ = other.payload_ != null ? other.payload_.Clone() : null; username_ = other.username_; oauthScope_ = other.oauthScope_; + serverId_ = other.serverId_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -1015,6 +1048,21 @@ namespace Grpc.Testing { } } + /// Field number for the "server_id" field. + public const int ServerIdFieldNumber = 4; + private string serverId_ = ""; + /// + /// Server ID. This must be unique among different server instances, + /// but the same across all RPC's made to a particular server instance. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ServerId { + get { return serverId_; } + set { + serverId_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as SimpleResponse); @@ -1031,6 +1079,7 @@ namespace Grpc.Testing { if (!object.Equals(Payload, other.Payload)) return false; if (Username != other.Username) return false; if (OauthScope != other.OauthScope) return false; + if (ServerId != other.ServerId) return false; return Equals(_unknownFields, other._unknownFields); } @@ -1040,6 +1089,7 @@ namespace Grpc.Testing { if (payload_ != null) hash ^= Payload.GetHashCode(); if (Username.Length != 0) hash ^= Username.GetHashCode(); if (OauthScope.Length != 0) hash ^= OauthScope.GetHashCode(); + if (ServerId.Length != 0) hash ^= ServerId.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } @@ -1065,6 +1115,10 @@ namespace Grpc.Testing { output.WriteRawTag(26); output.WriteString(OauthScope); } + if (ServerId.Length != 0) { + output.WriteRawTag(34); + output.WriteString(ServerId); + } if (_unknownFields != null) { _unknownFields.WriteTo(output); } @@ -1082,6 +1136,9 @@ namespace Grpc.Testing { if (OauthScope.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(OauthScope); } + if (ServerId.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ServerId); + } if (_unknownFields != null) { size += _unknownFields.CalculateSize(); } @@ -1105,6 +1162,9 @@ namespace Grpc.Testing { if (other.OauthScope.Length != 0) { OauthScope = other.OauthScope; } + if (other.ServerId.Length != 0) { + ServerId = other.ServerId; + } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } @@ -1131,6 +1191,10 @@ namespace Grpc.Testing { OauthScope = input.ReadString(); break; } + case 34: { + ServerId = input.ReadString(); + break; + } } } } diff --git a/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs index 9b11e990d2d..fbc3690d2ac 100644 --- a/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs @@ -92,7 +92,7 @@ namespace Grpc.Testing { { /// Creates a new client for MetricsService /// The channel to use to make remote calls. - public MetricsServiceClient(grpc::Channel channel) : base(channel) + public MetricsServiceClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for MetricsService that uses a custom CallInvoker. diff --git a/src/csharp/Grpc.IntegrationTesting/ReportQpsScenarioServiceGrpc.cs b/src/csharp/Grpc.IntegrationTesting/ReportQpsScenarioServiceGrpc.cs index 1a505ebc764..e35c7c39fd5 100644 --- a/src/csharp/Grpc.IntegrationTesting/ReportQpsScenarioServiceGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/ReportQpsScenarioServiceGrpc.cs @@ -67,7 +67,7 @@ namespace Grpc.Testing { { /// Creates a new client for ReportQpsScenarioService /// The channel to use to make remote calls. - public ReportQpsScenarioServiceClient(grpc::Channel channel) : base(channel) + public ReportQpsScenarioServiceClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for ReportQpsScenarioService that uses a custom CallInvoker. diff --git a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs index e7b93094c65..f358a6d175c 100644 --- a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs @@ -216,7 +216,7 @@ namespace Grpc.Testing { { /// Creates a new client for TestService /// The channel to use to make remote calls. - public TestServiceClient(grpc::Channel channel) : base(channel) + public TestServiceClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for TestService that uses a custom CallInvoker. @@ -602,7 +602,7 @@ namespace Grpc.Testing { { /// Creates a new client for UnimplementedService /// The channel to use to make remote calls. - public UnimplementedServiceClient(grpc::Channel channel) : base(channel) + public UnimplementedServiceClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for UnimplementedService that uses a custom CallInvoker. @@ -741,7 +741,7 @@ namespace Grpc.Testing { { /// Creates a new client for ReconnectService /// The channel to use to make remote calls. - public ReconnectServiceClient(grpc::Channel channel) : base(channel) + public ReconnectServiceClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for ReconnectService that uses a custom CallInvoker. diff --git a/src/csharp/Grpc.IntegrationTesting/WorkerServiceGrpc.cs b/src/csharp/Grpc.IntegrationTesting/WorkerServiceGrpc.cs index 14c26f99a6b..66378081626 100644 --- a/src/csharp/Grpc.IntegrationTesting/WorkerServiceGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/WorkerServiceGrpc.cs @@ -138,7 +138,7 @@ namespace Grpc.Testing { { /// Creates a new client for WorkerService /// The channel to use to make remote calls. - public WorkerServiceClient(grpc::Channel channel) : base(channel) + public WorkerServiceClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for WorkerService that uses a custom CallInvoker. From f9e6144692bd92cffe5690d5e9dfac92458acc17 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 12 Jul 2019 15:08:36 -0700 Subject: [PATCH 0900/1555] Avoid unnecessary ref of connected subchannel when creating subchannel call. --- .../filters/client_channel/client_channel.cc | 10 +-- .../health/health_check_client.cc | 6 +- .../ext/filters/client_channel/subchannel.cc | 69 ++++++++++--------- .../ext/filters/client_channel/subchannel.h | 31 ++++----- 4 files changed, 59 insertions(+), 57 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 0b612e67a33..257616a124e 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -2157,9 +2157,8 @@ void CallData::DoRetry(grpc_call_element* elem, GPR_ASSERT(method_params_ != nullptr); const auto* retry_policy = method_params_->retry_policy(); GPR_ASSERT(retry_policy != nullptr); - // Reset subchannel call and connected subchannel. + // Reset subchannel call. subchannel_call_.reset(); - connected_subchannel_.reset(); // Compute backoff delay. grpc_millis next_attempt_time; if (server_pushback_ms >= 0) { @@ -3277,13 +3276,14 @@ void CallData::CreateSubchannelCall(grpc_call_element* elem) { ChannelData* chand = static_cast(elem->channel_data); const size_t parent_data_size = enable_retries_ ? sizeof(SubchannelCallRetryState) : 0; - const ConnectedSubchannel::CallArgs call_args = { - pollent_, path_, call_start_time_, deadline_, arena_, + SubchannelCall::Args call_args = { + std::move(connected_subchannel_), pollent_, path_, call_start_time_, + deadline_, arena_, // TODO(roth): When we implement hedging support, we will probably // need to use a separate call context for each subchannel call. call_context_, call_combiner_, parent_data_size}; grpc_error* error = GRPC_ERROR_NONE; - subchannel_call_ = connected_subchannel_->CreateCall(call_args, &error); + subchannel_call_ = SubchannelCall::Create(std::move(call_args), &error); if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { gpr_log(GPR_INFO, "chand=%p calld=%p: create subchannel_call=%p: error=%s", chand, this, subchannel_call_.get(), grpc_error_string(error)); diff --git a/src/core/ext/filters/client_channel/health/health_check_client.cc b/src/core/ext/filters/client_channel/health/health_check_client.cc index faa2ba5b3b1..a6b910b5dad 100644 --- a/src/core/ext/filters/client_channel/health/health_check_client.cc +++ b/src/core/ext/filters/client_channel/health/health_check_client.cc @@ -310,7 +310,8 @@ void HealthCheckClient::CallState::Orphan() { } void HealthCheckClient::CallState::StartCall() { - ConnectedSubchannel::CallArgs args = { + SubchannelCall::Args args = { + health_check_client_->connected_subchannel_, &pollent_, GRPC_MDSTR_SLASH_GRPC_DOT_HEALTH_DOT_V1_DOT_HEALTH_SLASH_WATCH, gpr_now(GPR_CLOCK_MONOTONIC), // start_time @@ -321,8 +322,7 @@ void HealthCheckClient::CallState::StartCall() { 0, // parent_data_size }; grpc_error* error = GRPC_ERROR_NONE; - call_ = health_check_client_->connected_subchannel_->CreateCall(args, &error) - .release(); + call_ = SubchannelCall::Create(std::move(args), &error).release(); // Register after-destruction callback. GRPC_CLOSURE_INIT(&after_call_stack_destruction_, AfterCallStackDestruction, this, grpc_schedule_on_exec_ctx); diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index b6ab47fb09d..c3521f46cee 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -117,38 +117,6 @@ void ConnectedSubchannel::Ping(grpc_closure* on_initiate, elem->filter->start_transport_op(elem, op); } -RefCountedPtr ConnectedSubchannel::CreateCall( - const CallArgs& args, grpc_error** error) { - const size_t allocation_size = - GetInitialCallSizeEstimate(args.parent_data_size); - RefCountedPtr call( - new (args.arena->Alloc(allocation_size)) - SubchannelCall(Ref(DEBUG_LOCATION, "subchannel_call"), args)); - grpc_call_stack* callstk = SUBCHANNEL_CALL_TO_CALL_STACK(call.get()); - const grpc_call_element_args call_args = { - callstk, /* call_stack */ - nullptr, /* server_transport_data */ - args.context, /* context */ - args.path, /* path */ - args.start_time, /* start_time */ - args.deadline, /* deadline */ - args.arena, /* arena */ - args.call_combiner /* call_combiner */ - }; - *error = grpc_call_stack_init(channel_stack_, 1, SubchannelCall::Destroy, - call.get(), &call_args); - if (GPR_UNLIKELY(*error != GRPC_ERROR_NONE)) { - const char* error_string = grpc_error_string(*error); - gpr_log(GPR_ERROR, "error: %s", error_string); - return call; - } - grpc_call_stack_set_pollset_or_pollset_set(callstk, args.pollent); - if (channelz_subchannel_ != nullptr) { - channelz_subchannel_->RecordCallStarted(); - } - return call; -} - size_t ConnectedSubchannel::GetInitialCallSizeEstimate( size_t parent_data_size) const { size_t allocation_size = @@ -167,6 +135,43 @@ size_t ConnectedSubchannel::GetInitialCallSizeEstimate( // SubchannelCall // +RefCountedPtr SubchannelCall::Create(Args args, + grpc_error** error) { + const size_t allocation_size = + args.connected_subchannel->GetInitialCallSizeEstimate( + args.parent_data_size); + return RefCountedPtr(new (args.arena->Alloc( + allocation_size)) SubchannelCall(std::move(args), error)); +} + +SubchannelCall::SubchannelCall(Args args, grpc_error** error) + : connected_subchannel_(std::move(args.connected_subchannel)), + deadline_(args.deadline) { + grpc_call_stack* callstk = SUBCHANNEL_CALL_TO_CALL_STACK(this); + const grpc_call_element_args call_args = { + callstk, /* call_stack */ + nullptr, /* server_transport_data */ + args.context, /* context */ + args.path, /* path */ + args.start_time, /* start_time */ + args.deadline, /* deadline */ + args.arena, /* arena */ + args.call_combiner /* call_combiner */ + }; + *error = grpc_call_stack_init(connected_subchannel_->channel_stack(), 1, + SubchannelCall::Destroy, this, &call_args); + if (GPR_UNLIKELY(*error != GRPC_ERROR_NONE)) { + const char* error_string = grpc_error_string(*error); + gpr_log(GPR_ERROR, "error: %s", error_string); + return; + } + grpc_call_stack_set_pollset_or_pollset_set(callstk, args.pollent); + auto* channelz_node = connected_subchannel_->channelz_subchannel(); + if (channelz_node != nullptr) { + channelz_node->RecordCallStarted(); + } +} + void SubchannelCall::StartTransportStreamOpBatch( grpc_transport_stream_op_batch* batch) { GPR_TIMER_SCOPE("subchannel_call_process_op", 0); diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h index 64d679af6c5..d1c4b7d1073 100644 --- a/src/core/ext/filters/client_channel/subchannel.h +++ b/src/core/ext/filters/client_channel/subchannel.h @@ -72,17 +72,6 @@ class SubchannelCall; class ConnectedSubchannel : public ConnectedSubchannelInterface { public: - struct CallArgs { - grpc_polling_entity* pollent; - grpc_slice path; - gpr_timespec start_time; - grpc_millis deadline; - Arena* arena; - grpc_call_context_element* context; - CallCombiner* call_combiner; - size_t parent_data_size; - }; - ConnectedSubchannel( grpc_channel_stack* channel_stack, const grpc_channel_args* args, RefCountedPtr channelz_subchannel); @@ -92,8 +81,6 @@ class ConnectedSubchannel : public ConnectedSubchannelInterface { grpc_connectivity_state* state, grpc_closure* closure); void Ping(grpc_closure* on_initiate, grpc_closure* on_ack); - RefCountedPtr CreateCall(const CallArgs& args, - grpc_error** error); grpc_channel_stack* channel_stack() const { return channel_stack_; } const grpc_channel_args* args() const override { return args_; } @@ -114,10 +101,18 @@ class ConnectedSubchannel : public ConnectedSubchannelInterface { // Implements the interface of RefCounted<>. class SubchannelCall { public: - SubchannelCall(RefCountedPtr connected_subchannel, - const ConnectedSubchannel::CallArgs& args) - : connected_subchannel_(std::move(connected_subchannel)), - deadline_(args.deadline) {} + struct Args { + RefCountedPtr connected_subchannel; + grpc_polling_entity* pollent; + grpc_slice path; + gpr_timespec start_time; + grpc_millis deadline; + Arena* arena; + grpc_call_context_element* context; + CallCombiner* call_combiner; + size_t parent_data_size; + }; + static RefCountedPtr Create(Args args, grpc_error** error); // Continues processing a transport stream op batch. void StartTransportStreamOpBatch(grpc_transport_stream_op_batch* batch); @@ -150,6 +145,8 @@ class SubchannelCall { template friend class RefCountedPtr; + SubchannelCall(Args args, grpc_error** error); + // If channelz is enabled, intercepts recv_trailing so that we may check the // status and associate it to a subchannel. void MaybeInterceptRecvTrailingMetadata( From b58d2e84ab7412f54f30a88b698a74a3db344cb4 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Tue, 16 Jul 2019 10:45:08 -0400 Subject: [PATCH 0901/1555] Make sure there is at least a header in the frame storge of H2. grpc_chttp2_maybe_complete_recv_trailing_metadata() moves at least GRPC_HEADER_SIZE_IN_BYTES from the frame storage, whenever the frame storage is non-empty. Instead ensure that we have at least GRPC_HEADER_SIZE_IN_BYTES in the frame storage. This results in bugs detected by clusterfuzz in chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=984534 https://bugs.chromium.org/p/chromium/issues/detail?id=984478#c2 --- .../ext/transport/chttp2/transport/chttp2_transport.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 3c9a8a2209f..43f2db1309f 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -2016,9 +2016,10 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_chttp2_transport* t, * maybe decompress the next 5 bytes in the stream. */ if (s->stream_decompression_method == GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS) { - grpc_slice_buffer_move_first(&s->frame_storage, - GRPC_HEADER_SIZE_IN_BYTES, - &s->unprocessed_incoming_frames_buffer); + grpc_slice_buffer_move_first( + &s->frame_storage, + GPR_MIN(s->frame_storage.length, GRPC_HEADER_SIZE_IN_BYTES), + &s->unprocessed_incoming_frames_buffer); if (s->unprocessed_incoming_frames_buffer.length > 0) { s->unprocessed_incoming_frames_decompressed = true; pending_data = true; From f43322dfcb188b903c91d60d9c0b358e9d0a7c3d Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 16 Jul 2019 18:54:36 +0200 Subject: [PATCH 0902/1555] Upgrading a few more places to bazel 0.26. --- .../toolchains/bazel_0.26.0_rbe_windows/BUILD | 188 ++ .../bazel_0.26.0_rbe_windows/Dockerfile | 96 + .../cc_toolchain_config.bzl | 1728 +++++++++++++++++ 3 files changed, 2012 insertions(+) create mode 100644 third_party/toolchains/bazel_0.26.0_rbe_windows/BUILD create mode 100644 third_party/toolchains/bazel_0.26.0_rbe_windows/Dockerfile create mode 100644 third_party/toolchains/bazel_0.26.0_rbe_windows/cc_toolchain_config.bzl diff --git a/third_party/toolchains/bazel_0.26.0_rbe_windows/BUILD b/third_party/toolchains/bazel_0.26.0_rbe_windows/BUILD new file mode 100644 index 00000000000..5a74a06ddbd --- /dev/null +++ b/third_party/toolchains/bazel_0.26.0_rbe_windows/BUILD @@ -0,0 +1,188 @@ +# Copyright 2018 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This becomes the BUILD file for @local_config_cc// under Windows. + +package(default_visibility = ["//visibility:public"]) + +load(":cc_toolchain_config.bzl", "cc_toolchain_config") + +cc_library( + name = "malloc", +) + +filegroup( + name = "empty", + srcs = [], +) + +# Hardcoded toolchain, legacy behaviour. +cc_toolchain_suite( + name = "toolchain", + toolchains = { + "armeabi-v7a|compiler": ":cc-compiler-armeabi-v7a", + "x64_windows|msvc-cl": ":cc-compiler-x64_windows", + "x64_windows|msys-gcc": ":cc-compiler-x64_windows_msys", + "x64_windows|mingw-gcc": ":cc-compiler-x64_windows_mingw", + "x64_windows_msys": ":cc-compiler-x64_windows_msys", + "x64_windows": ":cc-compiler-x64_windows", + "armeabi-v7a": ":cc-compiler-armeabi-v7a", + }, +) + +cc_toolchain( + name = "cc-compiler-x64_windows_msys", + toolchain_identifier = "msys_x64", + toolchain_config = ":msys_x64", + all_files = ":empty", + ar_files = ":empty", + as_files = ":empty", + compiler_files = ":empty", + dwp_files = ":empty", + linker_files = ":empty", + objcopy_files = ":empty", + strip_files = ":empty", + supports_param_files = 1, +) + +cc_toolchain_config( + name = "msys_x64", + cpu = "x64_windows", + compiler = "msys-gcc", +) + +toolchain( + name = "cc-toolchain-x64_windows_msys", + exec_compatible_with = [ + "@bazel_tools//platforms:x86_64", + "@bazel_tools//platforms:windows", + "@bazel_tools//tools/cpp:msys", + ], + target_compatible_with = [ + "@bazel_tools//platforms:x86_64", + "@bazel_tools//platforms:windows", + ], + toolchain = ":cc-compiler-x64_windows_msys", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) + +cc_toolchain( + name = "cc-compiler-x64_windows_mingw", + toolchain_identifier = "msys_x64_mingw", + toolchain_config = ":msys_x64_mingw", + all_files = ":empty", + ar_files = ":empty", + as_files = ":empty", + compiler_files = ":empty", + dwp_files = ":empty", + linker_files = ":empty", + objcopy_files = ":empty", + strip_files = ":empty", + supports_param_files = 0, +) + +cc_toolchain_config( + name = "msys_x64_mingw", + cpu = "x64_windows", + compiler = "mingw-gcc", +) + +toolchain( + name = "cc-toolchain-x64_windows_mingw", + exec_compatible_with = [ + "@bazel_tools//platforms:x86_64", + "@bazel_tools//platforms:windows", + "@bazel_tools//tools/cpp:mingw", + ], + target_compatible_with = [ + "@bazel_tools//platforms:x86_64", + "@bazel_tools//platforms:windows", + ], + toolchain = ":cc-compiler-x64_windows_mingw", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) + +cc_toolchain( + name = "cc-compiler-x64_windows", + toolchain_identifier = "msvc_x64", + toolchain_config = ":msvc_x64", + all_files = ":empty", + ar_files = ":empty", + as_files = ":empty", + compiler_files = ":empty", + dwp_files = ":empty", + linker_files = ":empty", + objcopy_files = ":empty", + strip_files = ":empty", + supports_param_files = 1, +) + +cc_toolchain_config( + name = "msvc_x64", + cpu = "x64_windows", + compiler = "msvc-cl", +) + +toolchain( + name = "cc-toolchain-x64_windows", + exec_compatible_with = [ + "@bazel_tools//platforms:x86_64", + "@bazel_tools//platforms:windows", + ], + target_compatible_with = [ + "@bazel_tools//platforms:x86_64", + "@bazel_tools//platforms:windows", + ], + toolchain = ":cc-compiler-x64_windows", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) + +cc_toolchain( + name = "cc-compiler-armeabi-v7a", + toolchain_identifier = "stub_armeabi-v7a", + toolchain_config = ":stub_armeabi-v7a", + all_files = ":empty", + ar_files = ":empty", + as_files = ":empty", + compiler_files = ":empty", + dwp_files = ":empty", + linker_files = ":empty", + objcopy_files = ":empty", + strip_files = ":empty", + supports_param_files = 1, +) + +cc_toolchain_config( + name = "stub_armeabi-v7a", + cpu = "armeabi-v7a", + compiler = "compiler", +) + +toolchain( + name = "cc-toolchain-armeabi-v7a", + exec_compatible_with = [ + ], + target_compatible_with = [ + "@bazel_tools//platforms:arm", + "@bazel_tools//platforms:android", + ], + toolchain = ":cc-compiler-armeabi-v7a", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) + +filegroup( + name = "link_dynamic_library", + srcs = ["link_dynamic_library.sh"], +) + diff --git a/third_party/toolchains/bazel_0.26.0_rbe_windows/Dockerfile b/third_party/toolchains/bazel_0.26.0_rbe_windows/Dockerfile new file mode 100644 index 00000000000..bbfce76436d --- /dev/null +++ b/third_party/toolchains/bazel_0.26.0_rbe_windows/Dockerfile @@ -0,0 +1,96 @@ +# This Dockerfile creates an image that: +# - Has the correct MTU setting for networking from inside the container to work. +# - Has Visual Studio 2015 Build Tools installed. +# - Has msys2 + git, curl, zip, unzip installed. +# - Has Python 2.7 installed. +# - Has Bazel installed. + +# TODO(jsharpe): Consider replacing "ADD $URI $DEST" with "Invoke-WebRequest -Method Get -Uri $URI -OutFile $DEST" + +# Use the latest Windows Server Core image. +# +# WARNING: What's the `:1803` about? There are two versions of Windows Server +# 2016: a "regular" one (corresponding to `microsoft/windowsservercore`) is on +# a slow release cadence, and a fast release cadence one (corresponding to +# `microsoft/windowsservercore:1803`). If you chose a different image than +# described above, probably omit the `:1803` or change it to a different +# number. +FROM microsoft/windowsservercore:1803 + +SHELL ["powershell.exe", "-ExecutionPolicy", "Bypass", "-Command", "$ErrorActionPreference='Stop'; $ProgressPreference='SilentlyContinue'; $VerbosePreference = 'Continue';"] + +# TODO(b/112379377): Workaround until bug is fixed. +RUN netsh interface ipv4 set subinterface \"vEthernet (Ethernet)\" mtu=1460 store=persistent + +# Install Visual Studio 2015 Build Tools. +RUN Invoke-WebRequest "https://download.microsoft.com/download/5/f/7/5f7acaeb-8363-451f-9425-68a90f98b238/visualcppbuildtools_full.exe" \ + -OutFile visualcppbuildtools_full.exe -UseBasicParsing ; \ + Start-Process -FilePath 'visualcppbuildtools_full.exe' -ArgumentList '/quiet', '/NoRestart' -Wait ; \ + Remove-Item .\visualcppbuildtools_full.exe; + +# TODO(jsharpe): Alternate install for msys2: https://github.com/StefanScherer/dockerfiles-windows/issues/30 + +# Install 7-Zip and add it to the path. +ADD https://www.7-zip.org/a/7z1801-x64.msi C:\\TEMP\\7z.msi +RUN Start-Process msiexec.exe -ArgumentList \"/i C:\\TEMP\\7z.msi /qn /norestart /log C:\\TEMP\\7z_install_log.txt\" -wait +RUN $oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path; \ + $newpath = \"$oldpath;C:\Program Files\7-Zip\"; \ + Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath + +# Install msys2, and add some extra tools. +ADD http://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-20161025.tar.xz C:\\TEMP\\msys2.tar.xz +RUN 7z x C:\TEMP\msys2.tar.xz -oC:\TEMP\msys2.tar +RUN 7z x C:\TEMP\msys2.tar -oC:\tools +RUN $oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path; \ + $newpath = \"$oldpath;C:\tools\msys64;C:\tools\msys64\usr\bin\"; \ + Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath +RUN Start-Process msys2 -ArgumentList 'pacman -noconfirm -Syuu git curl zip unzip' -Wait + +# Install Visual C++ Redistributable for Visual Studio 2015: +ADD https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x64.exe C:\\TEMP\\vc_redist.x64.exe +RUN C:\TEMP\vc_redist.x64.exe /quiet /install + +# Install Python 2.7. +ADD https://www.python.org/ftp/python/2.7.14/python-2.7.14.amd64.msi C:\\TEMP\\python.msi +RUN Start-Process msiexec.exe -ArgumentList \"/i C:\\TEMP\\python.msi /qn /norestart /log C:\\TEMP\\python_install_log.txt\" -wait +RUN $oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path; \ + $newpath = \"$oldpath;C:\Python27\"; \ + Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath + +# Install Bazel. +RUN Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name BAZEL_SH -Value \"C:\tools\msys64\usr\bin\bash.exe\" +RUN Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name BAZEL_VC -Value \"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\" +RUN [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; +ADD https://github.com/bazelbuild/bazel/releases/download/0.26.0/bazel-0.26.0-windows-x86_64.exe C:\\bin\\bazel.exe +RUN $oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path; \ + $newpath = \"$oldpath;C:\bin\"; \ + Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath + +# TODO(jsharpe): This requires entropy so may be problematic on a headless machine: https://wiki.archlinux.org/index.php/Pacman/Package_signing#Initializing_the_keyring +RUN Start-Process msys2 -ArgumentList 'pacman-key --init' -Wait +# TODO(jsharpe): If you don't run this then the next command can't succeed since it needs to prompt to remove catgets. +RUN pacman --noconfirm -R libcatgets catgets +# Bazel documentation says to use -Syuu but this doesn't work in Docker. See +# http://g/foundry-windows/PDMVXbGew7Y +RUN pacman --noconfirm -Syy git curl zip unzip + +RUN \ + Add-Type -AssemblyName \"System.IO.Compression.FileSystem\"; \ + $zulu_url = \"https://cdn.azul.com/zulu/bin/zulu8.28.0.1-jdk8.0.163-win_x64.zip\"; \ + $zulu_zip = \"c:\\temp\\zulu8.28.0.1-jdk8.0.163-win_x64.zip\"; \ + $zulu_extracted_path = \"c:\\temp\\\" + [IO.Path]::GetFileNameWithoutExtension($zulu_zip); \ + $zulu_root = \"c:\\openjdk\"; \ + (New-Object Net.WebClient).DownloadFile($zulu_url, $zulu_zip); \ + [System.IO.Compression.ZipFile]::ExtractToDirectory($zulu_zip, \"c:\\temp\"); \ + Move-Item $zulu_extracted_path -Destination $zulu_root; \ + Remove-Item $zulu_zip; \ + $env:PATH = [Environment]::GetEnvironmentVariable(\"PATH\", \"Machine\") + \";${zulu_root}\\bin\"; \ + [Environment]::SetEnvironmentVariable(\"PATH\", $env:PATH, \"Machine\"); \ + $env:JAVA_HOME = $zulu_root; \ + [Environment]::SetEnvironmentVariable(\"JAVA_HOME\", $env:JAVA_HOME, \"Machine\") + +# Restore default shell for Windows containers. +SHELL ["cmd.exe", "/s", "/c"] + +# Default to PowerShell if no other command specified. +CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"] diff --git a/third_party/toolchains/bazel_0.26.0_rbe_windows/cc_toolchain_config.bzl b/third_party/toolchains/bazel_0.26.0_rbe_windows/cc_toolchain_config.bzl new file mode 100644 index 00000000000..20b4316c591 --- /dev/null +++ b/third_party/toolchains/bazel_0.26.0_rbe_windows/cc_toolchain_config.bzl @@ -0,0 +1,1728 @@ +# Copyright 2019 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""A Starlark cc_toolchain configuration rule""" +load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", + "action_config", + "artifact_name_pattern", + "env_entry", + "env_set", + "feature", + "feature_set", + "flag_group", + "flag_set", + "make_variable", + "tool", + "tool_path", + "variable_with_value", + "with_feature_set", + ) +load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") + + +all_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.clif_match, + ACTION_NAMES.lto_backend, +] + +all_cpp_compile_actions = [ + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.clif_match, +] + +preprocessor_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.clif_match, +] + +codegen_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, +] + +all_link_actions = [ + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, +] + +def _windows_msvc_impl(ctx): + toolchain_identifier = "msvc_x64" + host_system_name = "local" + target_system_name = "local" + target_cpu = "x64_windows" + target_libc = "msvcrt" + compiler = "msvc-cl" + abi_version = "local" + abi_libc_version = "local" + cc_target_os = None + builtin_sysroot = None + + cxx_builtin_include_directories = [ + # This is a workaround for https://github.com/bazelbuild/bazel/issues/5087. + "C:\\botcode\\w", + "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\INCLUDE", + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\ucrt", + "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\shared", + "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um", + "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt" + ] + + cpp_link_nodeps_dynamic_library_action = action_config( + action_name = ACTION_NAMES.cpp_link_nodeps_dynamic_library, + implies = [ + "nologo", + "shared_flag", + "linkstamps", + "output_execpath_flags", + "input_param_flags", + "user_link_flags", + "default_link_flags", + "linker_subsystem_flag", + "linker_param_file", + "msvc_env", + "no_stripping", + "has_configured_linker_path", + "def_file", + ], + tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/link.exe")], + ) + + cpp_link_static_library_action = action_config( + action_name = ACTION_NAMES.cpp_link_static_library, + implies = [ + "nologo", + "archiver_flags", + "input_param_flags", + "linker_param_file", + "msvc_env", + ], + tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/lib.exe")], + ) + + assemble_action = action_config( + action_name = ACTION_NAMES.assemble, + implies = [ + "compiler_input_flags", + "compiler_output_flags", + "nologo", + "msvc_env", + "sysroot", + ], + tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/ml64.exe")], + ) + + preprocess_assemble_action = action_config( + action_name = ACTION_NAMES.preprocess_assemble, + implies = [ + "compiler_input_flags", + "compiler_output_flags", + "nologo", + "msvc_env", + "sysroot", + ], + tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/ml64.exe")], + ) + + c_compile_action = action_config( + action_name = ACTION_NAMES.c_compile, + implies = [ + "compiler_input_flags", + "compiler_output_flags", + "default_compile_flags", + "nologo", + "msvc_env", + "parse_showincludes", + "user_compile_flags", + "sysroot", + "unfiltered_compile_flags", + ], + tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe")], + ) + + cpp_compile_action = action_config( + action_name = ACTION_NAMES.cpp_compile, + implies = [ + "compiler_input_flags", + "compiler_output_flags", + "default_compile_flags", + "nologo", + "msvc_env", + "parse_showincludes", + "user_compile_flags", + "sysroot", + "unfiltered_compile_flags", + ], + tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe")], + ) + + cpp_link_executable_action = action_config( + action_name = ACTION_NAMES.cpp_link_executable, + implies = [ + "nologo", + "linkstamps", + "output_execpath_flags", + "input_param_flags", + "user_link_flags", + "default_link_flags", + "linker_subsystem_flag", + "linker_param_file", + "msvc_env", + "no_stripping", + ], + tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/link.exe")], + ) + + cpp_link_dynamic_library_action = action_config( + action_name = ACTION_NAMES.cpp_link_dynamic_library, + implies = [ + "nologo", + "shared_flag", + "linkstamps", + "output_execpath_flags", + "input_param_flags", + "user_link_flags", + "default_link_flags", + "linker_subsystem_flag", + "linker_param_file", + "msvc_env", + "no_stripping", + "has_configured_linker_path", + "def_file", + ], + tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/link.exe")], + ) + + action_configs = [ + assemble_action, + preprocess_assemble_action, + c_compile_action, + cpp_compile_action, + cpp_link_executable_action, + cpp_link_dynamic_library_action, + cpp_link_nodeps_dynamic_library_action, + cpp_link_static_library_action, + ] + + msvc_link_env_feature = feature( + name = "msvc_link_env", + env_sets = [ + env_set( + actions = all_link_actions + + [ACTION_NAMES.cpp_link_static_library], + env_entries = [env_entry(key = "LIB", value = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\LIB\\amd64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.10240.0\\ucrt\\x64;C:\\Program Files (x86)\\Windows Kits\\8.1\\lib\\winv6.3\\um\\x64;")], + ), + ], + ) + + shared_flag_feature = feature( + name = "shared_flag", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ], + flag_groups = [flag_group(flags = ["/DLL"])], + ), + ], + ) + + determinism_feature = feature( + name = "determinism", + enabled = True, + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [ + flag_group( + flags = [ + "/wd4117", + "-D__DATE__=\"redacted\"", + "-D__TIMESTAMP__=\"redacted\"", + "-D__TIME__=\"redacted\"", + ], + ), + ], + ), + ], + ) + + sysroot_feature = feature( + name = "sysroot", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ], + flag_groups = [ + flag_group( + flags = ["--sysroot=%{sysroot}"], + iterate_over = "sysroot", + expand_if_available = "sysroot", + ), + ], + ), + ], + ) + + unfiltered_compile_flags_feature = feature( + name = "unfiltered_compile_flags", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ], + flag_groups = [ + flag_group( + flags = ["%{unfiltered_compile_flags}"], + iterate_over = "unfiltered_compile_flags", + expand_if_available = "unfiltered_compile_flags", + ), + ], + ), + ], + ) + + compiler_param_file_feature = feature( + name = "compiler_param_file", + ) + + copy_dynamic_libraries_to_binary_feature = feature(name = "copy_dynamic_libraries_to_binary") + + input_param_flags_feature = feature( + name = "input_param_flags", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ], + flag_groups = [ + flag_group( + flags = ["/IMPLIB:%{interface_library_output_path}"], + expand_if_available = "interface_library_output_path", + ), + ], + ), + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = ["%{libopts}"], + iterate_over = "libopts", + expand_if_available = "libopts", + ), + ], + ), + flag_set( + actions = all_link_actions + + [ACTION_NAMES.cpp_link_static_library], + flag_groups = [ + flag_group( + iterate_over = "libraries_to_link", + flag_groups = [ + flag_group( + iterate_over = "libraries_to_link.object_files", + flag_groups = [flag_group(flags = ["%{libraries_to_link.object_files}"])], + expand_if_equal = variable_with_value( + name = "libraries_to_link.type", + value = "object_file_group", + ), + ), + flag_group( + flag_groups = [flag_group(flags = ["%{libraries_to_link.name}"])], + expand_if_equal = variable_with_value( + name = "libraries_to_link.type", + value = "object_file", + ), + ), + flag_group( + flag_groups = [flag_group(flags = ["%{libraries_to_link.name}"])], + expand_if_equal = variable_with_value( + name = "libraries_to_link.type", + value = "interface_library", + ), + ), + flag_group( + flag_groups = [ + flag_group( + flags = ["%{libraries_to_link.name}"], + expand_if_false = "libraries_to_link.is_whole_archive", + ), + flag_group( + flags = ["/WHOLEARCHIVE:%{libraries_to_link.name}"], + expand_if_true = "libraries_to_link.is_whole_archive", + ), + ], + expand_if_equal = variable_with_value( + name = "libraries_to_link.type", + value = "static_library", + ), + ), + ], + expand_if_available = "libraries_to_link", + ), + ], + ), + ], + ) + + fastbuild_feature = feature( + name = "fastbuild", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/Od", "/Z7"])], + ), + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = ["/DEBUG:FASTLINK", "/INCREMENTAL:NO"], + ), + ], + ), + ], + implies = ["generate_pdb_file"], + ) + + user_compile_flags_feature = feature( + name = "user_compile_flags", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ], + flag_groups = [ + flag_group( + flags = ["%{user_compile_flags}"], + iterate_over = "user_compile_flags", + expand_if_available = "user_compile_flags", + ), + ], + ), + ], + ) + + archiver_flags_feature = feature( + name = "archiver_flags", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.cpp_link_static_library], + flag_groups = [ + flag_group( + flags = ["/OUT:%{output_execpath}"], + expand_if_available = "output_execpath", + ), + flag_group( + flags = ["/MACHINE:X64"] + ), + ], + ), + ], + ) + + default_link_flags_feature = feature( + name = "default_link_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["/MACHINE:X64"])], + ), + ], + ) + + static_link_msvcrt_feature = feature(name = "static_link_msvcrt") + + dynamic_link_msvcrt_debug_feature = feature( + name = "dynamic_link_msvcrt_debug", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/MDd"])], + ), + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["/DEFAULTLIB:msvcrtd.lib"])], + ), + ], + requires = [feature_set(features = ["dbg"])], + ) + + dbg_feature = feature( + name = "dbg", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/Od", "/Z7"])], + ), + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = ["/DEBUG:FULL", "/INCREMENTAL:NO"], + ), + ], + ), + ], + implies = ["generate_pdb_file"], + ) + + opt_feature = feature( + name = "opt", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/O2"])], + ), + ], + implies = ["frame_pointer"], + ) + + supports_interface_shared_libraries_feature = feature( + name = "supports_interface_shared_libraries", + enabled = True, + ) + + user_link_flags_feature = feature( + name = "user_link_flags", + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = ["%{user_link_flags}"], + iterate_over = "user_link_flags", + expand_if_available = "user_link_flags", + ), + ], + ), + ], + ) + + default_compile_flags_feature = feature( + name = "default_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = [ + "/DCOMPILER_MSVC", + "/DNOMINMAX", + "/D_WIN32_WINNT=0x0601", + "/D_CRT_SECURE_NO_DEPRECATE", + "/D_CRT_SECURE_NO_WARNINGS", + "/bigobj", + "/Zm500", + "/EHsc", + "/wd4351", + "/wd4291", + "/wd4250", + "/wd4996", + ], + ), + ], + ), + ], + ) + + msvc_compile_env_feature = feature( + name = "msvc_compile_env", + env_sets = [ + env_set( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ], + env_entries = [env_entry(key = "INCLUDE", value = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\INCLUDE;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\ucrt;C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\shared;C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um;C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt;")], + ), + ], + ) + + preprocessor_defines_feature = feature( + name = "preprocessor_defines", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ], + flag_groups = [ + flag_group( + flags = ["/D%{preprocessor_defines}"], + iterate_over = "preprocessor_defines", + ), + ], + ), + ], + ) + + generate_pdb_file_feature = feature( + name = "generate_pdb_file", + requires = [ + feature_set(features = ["dbg"]), + feature_set(features = ["fastbuild"]), + ], + ) + + output_execpath_flags_feature = feature( + name = "output_execpath_flags", + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = ["/OUT:%{output_execpath}"], + expand_if_available = "output_execpath", + ), + ], + ), + ], + ) + + dynamic_link_msvcrt_no_debug_feature = feature( + name = "dynamic_link_msvcrt_no_debug", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/MD"])], + ), + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["/DEFAULTLIB:msvcrt.lib"])], + ), + ], + requires = [ + feature_set(features = ["fastbuild"]), + feature_set(features = ["opt"]), + ], + ) + + disable_assertions_feature = feature( + name = "disable_assertions", + enabled = True, + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/DNDEBUG"])], + with_features = [with_feature_set(features = ["opt"])], + ), + ], + ) + + has_configured_linker_path_feature = feature(name = "has_configured_linker_path") + + supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) + + no_stripping_feature = feature(name = "no_stripping") + + linker_param_file_feature = feature( + name = "linker_param_file", + flag_sets = [ + flag_set( + actions = all_link_actions + + [ACTION_NAMES.cpp_link_static_library], + flag_groups = [ + flag_group( + flags = ["@%{linker_param_file}"], + expand_if_available = "linker_param_file", + ), + ], + ), + ], + ) + + ignore_noisy_warnings_feature = feature( + name = "ignore_noisy_warnings", + enabled = True, + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.cpp_link_static_library], + flag_groups = [flag_group(flags = ["/ignore:4221"])], + ), + ], + ) + + no_legacy_features_feature = feature(name = "no_legacy_features") + + parse_showincludes_feature = feature( + name = "parse_showincludes", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_header_parsing, + ], + flag_groups = [flag_group(flags = ["/showIncludes"])], + ), + ], + ) + + static_link_msvcrt_no_debug_feature = feature( + name = "static_link_msvcrt_no_debug", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/MT"])], + ), + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["/DEFAULTLIB:libcmt.lib"])], + ), + ], + requires = [ + feature_set(features = ["fastbuild"]), + feature_set(features = ["opt"]), + ], + ) + + treat_warnings_as_errors_feature = feature( + name = "treat_warnings_as_errors", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/WX"])], + ), + ], + ) + + windows_export_all_symbols_feature = feature(name = "windows_export_all_symbols") + + no_windows_export_all_symbols_feature = feature(name = "no_windows_export_all_symbols") + + include_paths_feature = feature( + name = "include_paths", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ], + flag_groups = [ + flag_group( + flags = ["/I%{quote_include_paths}"], + iterate_over = "quote_include_paths", + ), + flag_group( + flags = ["/I%{include_paths}"], + iterate_over = "include_paths", + ), + flag_group( + flags = ["/I%{system_include_paths}"], + iterate_over = "system_include_paths", + ), + ], + ), + ], + ) + + linkstamps_feature = feature( + name = "linkstamps", + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = ["%{linkstamp_paths}"], + iterate_over = "linkstamp_paths", + expand_if_available = "linkstamp_paths", + ), + ], + ), + ], + ) + + targets_windows_feature = feature( + name = "targets_windows", + enabled = True, + implies = ["copy_dynamic_libraries_to_binary"], + ) + + linker_subsystem_flag_feature = feature( + name = "linker_subsystem_flag", + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["/SUBSYSTEM:CONSOLE"])], + ), + ], + ) + + static_link_msvcrt_debug_feature = feature( + name = "static_link_msvcrt_debug", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/MTd"])], + ), + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["/DEFAULTLIB:libcmtd.lib"])], + ), + ], + requires = [feature_set(features = ["dbg"])], + ) + + frame_pointer_feature = feature( + name = "frame_pointer", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/Oy-"])], + ), + ], + ) + + compiler_output_flags_feature = feature( + name = "compiler_output_flags", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.assemble], + flag_groups = [ + flag_group( + flag_groups = [ + flag_group( + flags = ["/Fo%{output_file}", "/Zi"], + expand_if_available = "output_file", + expand_if_not_available = "output_assembly_file", + ), + ], + expand_if_not_available = "output_preprocess_file", + ), + ], + ), + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ], + flag_groups = [ + flag_group( + flag_groups = [ + flag_group( + flags = ["/Fo%{output_file}"], + expand_if_not_available = "output_preprocess_file", + ), + ], + expand_if_available = "output_file", + expand_if_not_available = "output_assembly_file", + ), + flag_group( + flag_groups = [ + flag_group( + flags = ["/Fa%{output_file}"], + expand_if_available = "output_assembly_file", + ), + ], + expand_if_available = "output_file", + ), + flag_group( + flag_groups = [ + flag_group( + flags = ["/P", "/Fi%{output_file}"], + expand_if_available = "output_preprocess_file", + ), + ], + expand_if_available = "output_file", + ), + ], + ), + ], + ) + + nologo_feature = feature( + name = "nologo", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ACTION_NAMES.cpp_link_static_library, + ], + flag_groups = [flag_group(flags = ["/nologo"])], + ), + ], + ) + + smaller_binary_feature = feature( + name = "smaller_binary", + enabled = True, + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/Gy", "/Gw"])], + with_features = [with_feature_set(features = ["opt"])], + ), + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["/OPT:ICF", "/OPT:REF"])], + with_features = [with_feature_set(features = ["opt"])], + ), + ], + ) + + compiler_input_flags_feature = feature( + name = "compiler_input_flags", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ], + flag_groups = [ + flag_group( + flags = ["/c", "%{source_file}"], + expand_if_available = "source_file", + ), + ], + ), + ], + ) + + def_file_feature = feature( + name = "def_file", + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = ["/DEF:%{def_file_path}", "/ignore:4070"], + expand_if_available = "def_file_path", + ), + ], + ), + ], + ) + + msvc_env_feature = feature( + name = "msvc_env", + env_sets = [ + env_set( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ACTION_NAMES.cpp_link_static_library, + ], + env_entries = [ + env_entry(key = "PATH", value = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework64\\;C:\\Program Files (x86)\\Windows Kits\\8.1\\bin\\x64;C:\\Program Files (x86)\\Windows Kits\\8.1\\bin\\x86;;C:\\Windows\\system32"), + env_entry(key = "TMP", value = "C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp"), + env_entry(key = "TEMP", value = "C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp"), + ], + ), + ], + implies = ["msvc_compile_env", "msvc_link_env"], + ) + + features = [ + no_legacy_features_feature, + nologo_feature, + has_configured_linker_path_feature, + no_stripping_feature, + targets_windows_feature, + copy_dynamic_libraries_to_binary_feature, + default_compile_flags_feature, + msvc_env_feature, + msvc_compile_env_feature, + msvc_link_env_feature, + include_paths_feature, + preprocessor_defines_feature, + parse_showincludes_feature, + generate_pdb_file_feature, + shared_flag_feature, + linkstamps_feature, + output_execpath_flags_feature, + archiver_flags_feature, + input_param_flags_feature, + linker_subsystem_flag_feature, + user_link_flags_feature, + default_link_flags_feature, + linker_param_file_feature, + static_link_msvcrt_feature, + static_link_msvcrt_no_debug_feature, + dynamic_link_msvcrt_no_debug_feature, + static_link_msvcrt_debug_feature, + dynamic_link_msvcrt_debug_feature, + dbg_feature, + fastbuild_feature, + opt_feature, + frame_pointer_feature, + disable_assertions_feature, + determinism_feature, + treat_warnings_as_errors_feature, + smaller_binary_feature, + ignore_noisy_warnings_feature, + user_compile_flags_feature, + sysroot_feature, + unfiltered_compile_flags_feature, + compiler_param_file_feature, + compiler_output_flags_feature, + compiler_input_flags_feature, + def_file_feature, + windows_export_all_symbols_feature, + no_windows_export_all_symbols_feature, + supports_dynamic_linker_feature, + supports_interface_shared_libraries_feature, + ] + + artifact_name_patterns = [ + artifact_name_pattern( + category_name = "object_file", + prefix = "", + extension = ".obj", + ), + artifact_name_pattern( + category_name = "static_library", + prefix = "", + extension = ".lib", + ), + artifact_name_pattern( + category_name = "alwayslink_static_library", + prefix = "", + extension = ".lo.lib", + ), + artifact_name_pattern( + category_name = "executable", + prefix = "", + extension = ".exe", + ), + artifact_name_pattern( + category_name = "dynamic_library", + prefix = "", + extension = ".dll", + ), + artifact_name_pattern( + category_name = "interface_library", + prefix = "", + extension = ".if.lib", + ), + ] + + make_variables = [] + + tool_paths = [ + tool_path(name = "ar", path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/lib.exe"), + tool_path(name = "ml", path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/ml64.exe"), + tool_path(name = "cpp", path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe"), + tool_path(name = "gcc", path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe"), + tool_path(name = "gcov", path = "wrapper/bin/msvc_nop.bat"), + tool_path(name = "ld", path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/link.exe"), + tool_path(name = "nm", path = "wrapper/bin/msvc_nop.bat"), + tool_path( + name = "objcopy", + path = "wrapper/bin/msvc_nop.bat", + ), + tool_path( + name = "objdump", + path = "wrapper/bin/msvc_nop.bat", + ), + tool_path( + name = "strip", + path = "wrapper/bin/msvc_nop.bat", + ), + ] + + return cc_common.create_cc_toolchain_config_info( + ctx = ctx, + features = features, + action_configs = action_configs, + artifact_name_patterns = artifact_name_patterns, + cxx_builtin_include_directories = cxx_builtin_include_directories, + toolchain_identifier = toolchain_identifier, + host_system_name = host_system_name, + target_system_name = target_system_name, + target_cpu = target_cpu, + target_libc = target_libc, + compiler = compiler, + abi_version = abi_version, + abi_libc_version = abi_libc_version, + tool_paths = tool_paths, + make_variables = make_variables, + builtin_sysroot = builtin_sysroot, + cc_target_os = None, + ) + +def _windows_msys_mingw_impl(ctx): + toolchain_identifier = "msys_x64_mingw" + host_system_name = "local" + target_system_name = "local" + target_cpu = "x64_windows" + target_libc = "mingw" + compiler = "mingw-gcc" + abi_version = "local" + abi_libc_version = "local" + cc_target_os = None + builtin_sysroot = None + action_configs = [] + + targets_windows_feature = feature( + name = "targets_windows", + implies = ["copy_dynamic_libraries_to_binary"], + enabled = True, + ) + + copy_dynamic_libraries_to_binary_feature = feature(name= "copy_dynamic_libraries_to_binary") + + gcc_env_feature = feature( + name = "gcc_env", + enabled = True, + env_sets = [ + env_set ( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ACTION_NAMES.cpp_link_static_library, + ], + env_entries = [ + env_entry(key = "PATH", value = "c:/tools/msys64/mingw64/bin") + ], + ), + ], + ) + + msys_mingw_flags = [ + "-std=gnu++0x" + ] + msys_mingw_link_flags = [ + "-lstdc++" + ] + + default_compile_flags_feature = feature( + name = "default_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + ), + flag_set( + actions = [ + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = ([flag_group(flags = msys_mingw_flags)] if msys_mingw_flags else []), + ), + ], + ) + + compiler_param_file_feature = feature( + name = "compiler_param_file", + ) + + default_link_flags_feature = feature( + name = "default_link_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = ([flag_group(flags = msys_mingw_link_flags)] if msys_mingw_link_flags else []), + ), + ], + ) + + supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) + + features = [ + targets_windows_feature, + copy_dynamic_libraries_to_binary_feature, + gcc_env_feature, + default_compile_flags_feature, + compiler_param_file_feature, + default_link_flags_feature, + supports_dynamic_linker_feature, + ] + + cxx_builtin_include_directories = [ + # This is a workaround for https://github.com/bazelbuild/bazel/issues/5087. + "C:\\botcode\\w", + "c:/tools/msys64/mingw64/", + "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\INCLUDE", + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\ucrt", + "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\shared", + "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um", + "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt" + ] + + artifact_name_patterns = [ + artifact_name_pattern( + category_name = "executable", + prefix = "", + extension = ".exe", + ), + ] + + make_variables = [] + tool_paths = [ + tool_path (name= "ar", path= "c:/tools/msys64/mingw64/bin/ar"), + tool_path (name= "compat-ld", path= "c:/tools/msys64/mingw64/bin/ld"), + tool_path (name= "cpp", path= "c:/tools/msys64/mingw64/bin/cpp"), + tool_path (name= "dwp", path= "c:/tools/msys64/mingw64/bin/dwp"), + tool_path (name= "gcc", path= "c:/tools/msys64/mingw64/bin/gcc"), + tool_path (name= "gcov", path= "c:/tools/msys64/mingw64/bin/gcov"), + tool_path (name= "ld", path= "c:/tools/msys64/mingw64/bin/ld"), + tool_path (name= "nm", path= "c:/tools/msys64/mingw64/bin/nm"), + tool_path (name= "objcopy", path= "c:/tools/msys64/mingw64/bin/objcopy"), + tool_path (name= "objdump", path= "c:/tools/msys64/mingw64/bin/objdump"), + tool_path (name= "strip", path= "c:/tools/msys64/mingw64/bin/strip"), + + ] + + return cc_common.create_cc_toolchain_config_info( + ctx = ctx, + features = features, + action_configs = action_configs, + artifact_name_patterns = artifact_name_patterns, + cxx_builtin_include_directories = cxx_builtin_include_directories, + toolchain_identifier = toolchain_identifier, + host_system_name = host_system_name, + target_system_name = target_system_name, + target_cpu = target_cpu, + target_libc = target_libc, + compiler = compiler, + abi_version = abi_version, + abi_libc_version = abi_libc_version, + tool_paths = tool_paths, + make_variables = make_variables, + builtin_sysroot = builtin_sysroot, + cc_target_os = cc_target_os) + + +def _armeabi_impl(ctx): + toolchain_identifier = "stub_armeabi-v7a" + host_system_name = "armeabi-v7a" + target_system_name = "armeabi-v7a" + target_cpu = "armeabi-v7a" + target_libc = "armeabi-v7a" + compiler = "compiler" + abi_version = "armeabi-v7a" + abi_libc_version = "armeabi-v7a" + cc_target_os = None + builtin_sysroot = None + action_configs = [] + + supports_pic_feature = feature(name = "supports_pic", enabled = True) + supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) + features = [supports_dynamic_linker_feature, supports_pic_feature] + + cxx_builtin_include_directories = [ + # This is a workaround for https://github.com/bazelbuild/bazel/issues/5087. + "C:\\botcode\\w",] + artifact_name_patterns = [] + make_variables = [] + + tool_paths = [ + tool_path(name = "ar", path = "/bin/false"), + tool_path(name = "compat-ld", path = "/bin/false"), + tool_path(name = "cpp", path = "/bin/false"), + tool_path(name = "dwp", path = "/bin/false"), + tool_path(name = "gcc", path = "/bin/false"), + tool_path(name = "gcov", path = "/bin/false"), + tool_path(name = "ld", path = "/bin/false"), + tool_path(name = "nm", path = "/bin/false"), + tool_path(name = "objcopy", path = "/bin/false"), + tool_path(name = "objdump", path = "/bin/false"), + tool_path(name = "strip", path = "/bin/false"), + ] + + return cc_common.create_cc_toolchain_config_info( + ctx = ctx, + features = features, + action_configs = action_configs, + artifact_name_patterns = artifact_name_patterns, + cxx_builtin_include_directories = cxx_builtin_include_directories, + toolchain_identifier = toolchain_identifier, + host_system_name = host_system_name, + target_system_name = target_system_name, + target_cpu = target_cpu, + target_libc = target_libc, + compiler = compiler, + abi_version = abi_version, + abi_libc_version = abi_libc_version, + tool_paths = tool_paths, + make_variables = make_variables, + builtin_sysroot = builtin_sysroot, + cc_target_os = cc_target_os + ) + +def _impl(ctx): + if ctx.attr.cpu == "armeabi-v7a": + return _armeabi_impl(ctx) + elif ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "msvc-cl": + return _windows_msvc_impl(ctx) + elif ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "mingw-gcc": + return _windows_msys_mingw_impl(ctx) + + tool_paths = [ + tool_path (name= "ar", path= "c:/tools/msys64/usr/bin/ar"), + tool_path (name= "compat-ld", path= "c:/tools/msys64/usr/bin/ld"), + tool_path (name= "cpp", path= "c:/tools/msys64/usr/bin/cpp"), + tool_path (name= "dwp", path= "c:/tools/msys64/usr/bin/dwp"), + tool_path (name= "gcc", path= "c:/tools/msys64/usr/bin/gcc"), + tool_path (name= "gcov", path= "c:/tools/msys64/usr/bin/gcov"), + tool_path (name= "ld", path= "c:/tools/msys64/usr/bin/ld"), + tool_path (name= "nm", path= "c:/tools/msys64/usr/bin/nm"), + tool_path (name= "objcopy", path= "c:/tools/msys64/usr/bin/objcopy"), + tool_path (name= "objdump", path= "c:/tools/msys64/usr/bin/objdump"), + tool_path (name= "strip", path= "c:/tools/msys64/usr/bin/strip"), + + ] + + cxx_builtin_include_directories = [ + # This is a workaround for https://github.com/bazelbuild/bazel/issues/5087. + "C:\\botcode\\w", + "c:/tools/msys64/usr/", + "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\INCLUDE", + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\ucrt", + "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\shared", + "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um", + "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt" + ] + + action_configs = [] + + compile_flags = [ + + ] + + dbg_compile_flags = [ + + ] + + opt_compile_flags = [ + + ] + + cxx_flags = [ + "-std=gnu++0x" + ] + + link_flags = [ + "-lstdc++" + ] + + opt_link_flags = [ + + ] + + unfiltered_compile_flags = [ + + ] + + targets_windows_feature = feature( + name = "targets_windows", + implies = ["copy_dynamic_libraries_to_binary"], + enabled = True, + ) + + copy_dynamic_libraries_to_binary_feature = feature(name= "copy_dynamic_libraries_to_binary") + + gcc_env_feature = feature( + name = "gcc_env", + enabled = True, + env_sets = [ + env_set ( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ACTION_NAMES.cpp_link_static_library, + ], + env_entries = [ + env_entry(key = "PATH", value = "c:/tools/msys64/usr/bin") + ], + ), + ], + ) + + windows_features = [ + targets_windows_feature, + copy_dynamic_libraries_to_binary_feature, + gcc_env_feature, + ] + + + + supports_pic_feature = feature( + name = "supports_pic", + enabled = True, + ) + supports_start_end_lib_feature = feature( + name = "supports_start_end_lib", + enabled = True, + ) + + default_compile_flags_feature = feature( + name = "default_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = ([flag_group(flags = compile_flags)] if compile_flags else []), + ), + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = ([flag_group(flags = dbg_compile_flags)] if dbg_compile_flags else []), + with_features = [with_feature_set(features = ["dbg"])], + ), + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = ([flag_group(flags = opt_compile_flags)] if opt_compile_flags else []), + with_features = [with_feature_set(features = ["opt"])], + ), + flag_set( + actions = [ + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = ([flag_group(flags = cxx_flags)] if cxx_flags else []), + ), + ], + ) + + default_link_flags_feature = feature( + name = "default_link_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = ([flag_group(flags = link_flags)] if link_flags else []), + ), + flag_set( + actions = all_link_actions, + flag_groups = ([flag_group(flags = opt_link_flags)] if opt_link_flags else []), + with_features = [with_feature_set(features = ["opt"])], + ), + ], + ) + + dbg_feature = feature(name = "dbg") + + opt_feature = feature(name = "opt") + + sysroot_feature = feature( + name = "sysroot", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ], + flag_groups = [ + flag_group( + flags = ["--sysroot=%{sysroot}"], + expand_if_available = "sysroot", + ), + ], + ), + ], + ) + + fdo_optimize_feature = feature( + name = "fdo_optimize", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [ + flag_group( + flags = [ + "-fprofile-use=%{fdo_profile_path}", + "-fprofile-correction", + ], + expand_if_available = "fdo_profile_path", + ), + ], + ), + ], + provides = ["profile"], + ) + + supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) + + user_compile_flags_feature = feature( + name = "user_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = ["%{user_compile_flags}"], + iterate_over = "user_compile_flags", + expand_if_available = "user_compile_flags", + ), + ], + ), + ], + ) + + unfiltered_compile_flags_feature = feature( + name = "unfiltered_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = ([flag_group(flags = unfiltered_compile_flags)] if unfiltered_compile_flags else []), + ), + ], + ) + + features = windows_features + [ + supports_pic_feature, + + + default_compile_flags_feature, + default_link_flags_feature, + fdo_optimize_feature, + supports_dynamic_linker_feature, + dbg_feature, + opt_feature, + user_compile_flags_feature, + sysroot_feature, + unfiltered_compile_flags_feature, + ] + + artifact_name_patterns = [ + artifact_name_pattern(category_name="executable", prefix="", extension=".exe"), + ] + + make_variables = [] + + return cc_common.create_cc_toolchain_config_info( + ctx = ctx, + features = features, + action_configs = action_configs, + artifact_name_patterns = artifact_name_patterns, + cxx_builtin_include_directories = cxx_builtin_include_directories, + toolchain_identifier = "msys_x64", + host_system_name = "local", + target_system_name = "local", + target_cpu = "x64_windows", + target_libc = "msys", + compiler = "msys-gcc", + abi_version = "local", + abi_libc_version = "local", + tool_paths = tool_paths, + make_variables = make_variables, + builtin_sysroot = "", + cc_target_os = None, + ) + +cc_toolchain_config = rule( + implementation = _impl, + attrs = { + "cpu" : attr.string(mandatory = True), + "compiler": attr.string(), + }, + provides = [CcToolchainConfigInfo], +) + From 4bf00481948f805c2e1ccd705d92802e6b919521 Mon Sep 17 00:00:00 2001 From: Andrew Scherkus Date: Tue, 16 Jul 2019 13:14:28 -0400 Subject: [PATCH 0903/1555] Document --noremotedb flag for grpc_cli. It's surprising that grpc_cli always attempts to use the reflection service even when providing local proto files. Document the existence of a flag that surpresses this behavior. --- doc/command_line_tool.md | 6 ++++++ test/cpp/util/grpc_tool.cc | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/doc/command_line_tool.md b/doc/command_line_tool.md index a373cbea627..4f40481927e 100644 --- a/doc/command_line_tool.md +++ b/doc/command_line_tool.md @@ -70,6 +70,8 @@ guides for , [C++](https://github.com/grpc/grpc/blob/master/doc/server_reflection_tutorial.md) and [Go](https://github.com/grpc/grpc-go/blob/master/Documentation/server-reflection-tutorial.md) +Local proto files can be used as an alternative. See instructions [below](#Call-a-remote-method). + ## Usage ### List services @@ -185,6 +187,10 @@ We can send RPCs to a server and get responses using `grpc_cli call` command. If the proto file is not under the current directory, you can use `--proto_path` to specify a new search root. + Note that the tool will always attempt to use the reflection service first, + falling back to local proto files if the service is not found. Use + `--noremotedb` to avoid attempting to use the reflection service. + - Send non-proto rpc For using gRPC with protocols other than protobuf, you will need the exact diff --git a/test/cpp/util/grpc_tool.cc b/test/cpp/util/grpc_tool.cc index dbac31170f0..a425c2f4c04 100644 --- a/test/cpp/util/grpc_tool.cc +++ b/test/cpp/util/grpc_tool.cc @@ -469,6 +469,8 @@ bool GrpcTool::CallMethod(int argc, const char** argv, " fallback when parsing request/response\n" " --proto_path ; The search path of proto files, valid" " only when --protofiles is given\n" + " --noremotedb ; Don't attempt to use reflection service" + " at all\n" " --metadata ; The metadata to be sent to the server\n" " --infile ; Input filename (defaults to stdin)\n" " --outfile ; Output filename (defaults to stdout)\n" @@ -810,6 +812,8 @@ bool GrpcTool::ParseMessage(int argc, const char** argv, " fallback when parsing request/response\n" " --proto_path ; The search path of proto files, valid" " only when --protofiles is given\n" + " --noremotedb ; Don't attempt to use reflection service" + " at all\n" " --infile ; Input filename (defaults to stdin)\n" " --outfile ; Output filename (defaults to stdout)\n" " --binary_input ; Input in binary format\n" From a07b669ce6d3318f93af2670b4015a0d3a4b3409 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Tue, 16 Jul 2019 10:55:30 -0700 Subject: [PATCH 0904/1555] Used a safer filter --- gRPC-Core.podspec | 4 ++-- templates/gRPC-Core.podspec.template | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index f309161fadb..c3055ae15b9 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -1387,7 +1387,7 @@ Pod::Spec.new do |s| # TODO (mxyan): Instead of this hack, add include path "third_party" to C core's include path? s.prepare_command = <<-END_OF_COMMAND - sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS==1\\\n #include \\\n#else\\\n #include "\\1"\\\n#endif;g' $(find src/core -type f -print | xargs grep -H -c '#if COCOAPODS==1' | grep 0$ | cut -d':' -f1) - sed -E -i '' 's;#include ;#if COCOAPODS==1\\\n #include \\\n#else\\\n #include \\\n#endif;g' $(find src/core -type f \\( -path '*.h' -or -path '*.cc' \\) -print | xargs grep -H -c '#if COCOAPODS==1' | grep 0$ | cut -d':' -f1) + sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS==1\\\n #include \\\n#else\\\n #include "\\1"\\\n#endif;g' $(find src/core -type f -print | xargs grep -H -c '#include ;#if COCOAPODS==1\\\n #include \\\n#else\\\n #include \\\n#endif;g' $(find src/core -type f \\( -path '*.h' -or -path '*.cc' \\) -print | xargs grep -H -c '#include \\\n#else\\\n #include "\\1"\\\n#endif;g' $(find src/core -type f -print | xargs grep -H -c '#if COCOAPODS==1' | grep 0$ | cut -d':' -f1) - sed -E -i '' 's;#include ;#if COCOAPODS==1\\\n #include \\\n#else\\\n #include \\\n#endif;g' $(find src/core -type f \\( -path '*.h' -or -path '*.cc' \\) -print | xargs grep -H -c '#if COCOAPODS==1' | grep 0$ | cut -d':' -f1) + sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS==1\\\n #include \\\n#else\\\n #include "\\1"\\\n#endif;g' $(find src/core -type f -print | xargs grep -H -c '#include ;#if COCOAPODS==1\\\n #include \\\n#else\\\n #include \\\n#endif;g' $(find src/core -type f \\( -path '*.h' -or -path '*.cc' \\) -print | xargs grep -H -c '#include Date: Tue, 2 Jul 2019 15:01:40 -0700 Subject: [PATCH 0905/1555] Fix the entry condition of Bazel hack --- .../grpcio_tests/tests/bazel_namespace_package_hack.py | 5 +++++ tools/bazel.rc | 1 + 2 files changed, 6 insertions(+) diff --git a/src/python/grpcio_tests/tests/bazel_namespace_package_hack.py b/src/python/grpcio_tests/tests/bazel_namespace_package_hack.py index 006a3deecb4..994a8e1e800 100644 --- a/src/python/grpcio_tests/tests/bazel_namespace_package_hack.py +++ b/src/python/grpcio_tests/tests/bazel_namespace_package_hack.py @@ -16,6 +16,8 @@ import os import site import sys +_GRPC_BAZEL_RUNTIME_ENV = "GRPC_BAZEL_RUNTIME" + # TODO(https://github.com/bazelbuild/bazel/issues/6844) Bazel failed to # interpret namespace packages correctly. This monkey patch will force the @@ -24,6 +26,9 @@ import sys # Analysis in depth: https://github.com/bazelbuild/rules_python/issues/55 def sys_path_to_site_dir_hack(): """Add valid sys.path item to site directory to parse the .pth files.""" + # Only run within our Bazel environment + if not os.environ.get(_GRPC_BAZEL_RUNTIME_ENV): + return items = [] for item in sys.path: if os.path.exists(item): diff --git a/tools/bazel.rc b/tools/bazel.rc index 4bd3a5d7445..7a716e85088 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -5,6 +5,7 @@ build --client_env=CC=clang build --copt=-DGRPC_BAZEL_BUILD +build --action_env=GRPC_BAZEL_RUNTIME=1 build:opt --compilation_mode=opt build:opt --copt=-Wframe-larger-than=16384 From 603054a29a68c0eb993180e8f687cc0cafdb0113 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Tue, 16 Jul 2019 18:25:30 -0700 Subject: [PATCH 0906/1555] Modify locality --- src/core/lib/iomgr/executor/threadpool.cc | 2 +- src/core/lib/iomgr/executor/threadpool.h | 2 +- test/core/iomgr/threadpool_test.cc | 40 +++++++++++------------ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/core/lib/iomgr/executor/threadpool.cc b/src/core/lib/iomgr/executor/threadpool.cc index 9bb1fd1d1cd..f0df1bd18eb 100644 --- a/src/core/lib/iomgr/executor/threadpool.cc +++ b/src/core/lib/iomgr/executor/threadpool.cc @@ -51,7 +51,7 @@ void ThreadPool::SharedThreadPoolConstructor() { // All worker threads in thread pool must be joinable. thread_options_.set_joinable(true); - // Create at least 1 worker threads. + // Create at least 1 worker thread. if (num_threads_ <= 0) num_threads_ = 1; queue_ = New(); diff --git a/src/core/lib/iomgr/executor/threadpool.h b/src/core/lib/iomgr/executor/threadpool.h index e37f5727ced..78f61a3139c 100644 --- a/src/core/lib/iomgr/executor/threadpool.h +++ b/src/core/lib/iomgr/executor/threadpool.h @@ -102,7 +102,7 @@ class ThreadPool : public ThreadPoolInterface { public: // Creates a thread pool with size of "num_threads", with default thread name // "ThreadPoolWorker" and all thread options set to default. If the given size - // is 0 or less, there will be 1 worker threads created inside pool. + // is 0 or less, there will be 1 worker thread created inside pool. ThreadPool(int num_threads); // Same as ThreadPool(int num_threads) constructor, except diff --git a/test/core/iomgr/threadpool_test.cc b/test/core/iomgr/threadpool_test.cc index 1219d25f3b7..ac94af170e2 100644 --- a/test/core/iomgr/threadpool_test.cc +++ b/test/core/iomgr/threadpool_test.cc @@ -66,26 +66,6 @@ class SimpleFunctorForAdd : public grpc_experimental_completion_queue_functor { grpc_core::Atomic count_{0}; }; -// Checks the given SimpleFunctorForAdd's count with a given number. -class SimpleFunctorCheckForAdd - : public grpc_experimental_completion_queue_functor { - public: - SimpleFunctorCheckForAdd(int ok, int* count) : count_(count) { - functor_run = &SimpleFunctorCheckForAdd::Run; - internal_success = ok; - } - ~SimpleFunctorCheckForAdd() {} - static void Run(struct grpc_experimental_completion_queue_functor* cb, - int ok) { - auto* callback = static_cast(cb); - (*callback->count_)++; - GPR_ASSERT(*callback->count_ == callback->internal_success); - } - - private: - int* count_; -}; - static void test_add(void) { gpr_log(GPR_INFO, "test_add"); grpc_core::ThreadPool* pool = @@ -157,6 +137,26 @@ static void test_multi_add(void) { gpr_log(GPR_DEBUG, "Done."); } +// Checks the current count with a given number. +class SimpleFunctorCheckForAdd + : public grpc_experimental_completion_queue_functor { + public: + SimpleFunctorCheckForAdd(int ok, int* count) : count_(count) { + functor_run = &SimpleFunctorCheckForAdd::Run; + internal_success = ok; + } + ~SimpleFunctorCheckForAdd() {} + static void Run(struct grpc_experimental_completion_queue_functor* cb, + int ok) { + auto* callback = static_cast(cb); + (*callback->count_)++; + GPR_ASSERT(*callback->count_ == callback->internal_success); + } + + private: + int* count_; +}; + static void test_one_thread_FIFO(void) { gpr_log(GPR_INFO, "test_one_thread_FIFO"); int counter = 0; From dfca76905d152477460b8e33e8249ce6a4c8f27f Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Tue, 16 Jul 2019 18:32:01 -0700 Subject: [PATCH 0907/1555] Removed unused variable enableCFStream --- src/objective-c/GRPCClient/GRPCCall.m | 3 --- src/objective-c/GRPCClient/private/GRPCChannelPool.m | 3 --- 2 files changed, 6 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index c3b06d6c72d..a9b112b5d52 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -790,9 +790,6 @@ const char *kCFStreamVarName = "grpc_cfstream"; [self sendHeaders]; [self invokeCall]; - - // Connectivity monitor is not required for CFStream - char *enableCFStream = getenv(kCFStreamVarName); } // Now that the RPC has been initiated, request writes can start. diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.m b/src/objective-c/GRPCClient/private/GRPCChannelPool.m index e8b6944d4b9..683e203ca31 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannelPool.m +++ b/src/objective-c/GRPCClient/private/GRPCChannelPool.m @@ -214,9 +214,6 @@ static const NSTimeInterval kDefaultChannelDestroyDelay = 30; - (instancetype)initPrivate { if ((self = [super init])) { _channelPool = [NSMutableDictionary dictionary]; - - // Connectivity monitor is not required for CFStream - char *enableCFStream = getenv(kCFStreamVarName); } return self; } From 12ededb237d3c58117fd7bb0dddec146ed2f6408 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Tue, 16 Jul 2019 14:22:16 -0700 Subject: [PATCH 0908/1555] Increase lower bound on DNS re-resolution period to 30 seconds --- .../client_channel/resolver/dns/c_ares/dns_resolver_ares.cc | 2 +- .../filters/client_channel/resolver/dns/native/dns_resolver.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index 4e7bb5ec482..65f80525e54 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -144,7 +144,7 @@ AresDnsResolver::AresDnsResolver(ResolverArgs args) arg = grpc_channel_args_find(channel_args_, GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS); min_time_between_resolutions_ = - grpc_channel_arg_get_integer(arg, {1000, 0, INT_MAX}); + grpc_channel_arg_get_integer(arg, {1000 * 30, 0, INT_MAX}); // Enable SRV queries option arg = grpc_channel_args_find(channel_args_, GRPC_ARG_DNS_ENABLE_SRV_QUERIES); enable_srv_queries_ = grpc_channel_arg_get_bool(arg, false); diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc index bc6d73acac7..629b7360a88 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc @@ -110,7 +110,7 @@ NativeDnsResolver::NativeDnsResolver(ResolverArgs args) const grpc_arg* arg = grpc_channel_args_find( args.args, GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS); min_time_between_resolutions_ = - grpc_channel_arg_get_integer(arg, {1000, 0, INT_MAX}); + grpc_channel_arg_get_integer(arg, {1000 * 30, 0, INT_MAX}); interested_parties_ = grpc_pollset_set_create(); if (args.pollset_set != nullptr) { grpc_pollset_set_add_pollset_set(interested_parties_, args.pollset_set); From 0ada8b68d344bcefb9349c5ffe0c2fbd5012a55a Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 17 Jul 2019 14:10:03 +0200 Subject: [PATCH 0909/1555] add versioning guide --- doc/versioning.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 doc/versioning.md diff --git a/doc/versioning.md b/doc/versioning.md new file mode 100644 index 00000000000..e39334d1df1 --- /dev/null +++ b/doc/versioning.md @@ -0,0 +1,41 @@ +# gRPC Versioning Guide + +## Versioning Overview + +All gRPC implementations use a three-part version number (`vX.Y.Z`) and strictly follow [semantic versioning](https://semver.org/), which defines the semantics of major, minor and patch components of the version number. In addition to that, gRPC versions evolve according to these rules: +- **Major version bumps** only happen on rare occasions. In order to qualify for a major version bump, certain criteria described later in this document need to be met. Most importantly, a major version increase must not break wire compatibility with other gRPC implementations so that existing gRPC libraries remain fully interoperable. +- **Minor version bumps** happen approx. every 6 weeks as part of the normal release cycle as defined by the gRPC release process. A new release branch named vMAJOR.MINOR.PATCH) is cut every 6 weeks based on the [release schedule](https://github.com/grpc/grpc/blob/master/doc/grpc_release_schedule.md). +- **Patch version bump** corresponds to bugfixes done on release branch. + +There are also a few extra rules regarding adding new gRPC implementations (e.g. adding support for a new language) +- New implementations start at v0.x.y version they reaches 1.0, they are considered not ready for production workloads. Breaking API changes are allowed in the 0.x releases as the library is not considered stable yet. +- The "1.0" release has semantics of GA (generally available) and being production ready. Requirements to reach this milestone are at least these + - basic RPC features are feature complete and tested + - implementation is tested for interoperability with other languages + - Public API is declared stable +- Once a gRPC library reaches 1.0 (or higher version), the normal rules for versioning apply. + +## Policy for updating the major version number + +To avoid user confusion and simplify reasoning, the gRPC releases in different languages try to stay synchronized in terms of major and minor version (all languages follow the same release schedule). Nevertheless, because we also strictly follow semantic versioning, there are circumstances in which a gRPC implementation needs to break the version synchronicity and do a major version bump independently of other languages. + +### Situations when it's ok to do a major version bump +- **change forced by the language ecosystem:** when the language itself or its standard libraries that we depend on make a breaking change (something which is out of our control), reacting with updating gRPC APIs may be the only adequate response. +- **voluntary change:** Even in non-forced situations, there might be circumstances in which a breaking API change makes sense and represents a net win, but as a rule of thumb breaking changes are very disruptive for users, cause user fragmentation and incur high maintenance costs. Therefore, breaking API changes should be very rare events that need to be considered with extreme care and the bar for accepting such changes is intentionally set very high. + Example scenarios where a breaking API change might be adequate: + - fixing a security problem which requires changes to API (need to consider the non-breaking alternatives first) + - the change leads to very significant gains to security, usability or development. velocity. These gains need to be clearly documented and claims need to be supported by evidence (ideally by numbers). Costs to the ecosystem (impact on users, dev team etc.) need to be taken into account and the change still needs to be a net positive after subtracting the costs. + + All proposals to make a breaking change need to be documented as a gRFC document (in the grpc/proposal repository) that covers at least these areas: + - Description of the proposal including an explanation why the proposed change is one of the very rare events where a breaking change is introduced. + - Migration costs (= what does it mean for the users to migrate to the new API, what are the costs and risks associated with it) + - Pros of the change (what is gained and how) + - Cons of the change (e.g. user confusion, lost users and user trust, work needed, added maintenance costs) + - Plan for supporting users still using the old major version (in case migration to the new major version is not trivial or not everyone can migrate easily) + +Note that while major version bump allows changing APIs used by the users, it must not impact the interoperability of the implementation with other gRPC implementations and the previous major version released. That means that **no backward incompatible protocol changes are allowed**: old clients must continue interoperating correctly with new servers and new servers with old clients. + +### Situations that DON'T warrant a major version bump +- Because other languages do so. This is not a good enough reason because +doing a major version bump has high potential for disturbing and confusing the users of that language and fragmenting the user base and that is a bigger threat than having language implementations at different major version (provided the state is well documented). Having some languages at different major version seems to be unavoidable anyway (due to forced version bumps), unless we bump some languages artificially. +- "I don't like this API": In retrospect, some API decisions made in the past necessarily turn out more lucky than others, but without strong reasons that would be in favor of changing the API and without enough supporting evidence (see previous section), other strategy than making a breaking API change needs to be used. Possible options: Expand the API to make it useful again; mark API as deprecated while keeping its functionality and providing a new better API. From 170d3633f056a32f0934ef720d0c4c7af35bdef0 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 17 Jul 2019 09:56:34 -0700 Subject: [PATCH 0910/1555] Removed source files GRPCConnectivityMonitor --- gRPC.podspec | 2 +- .../private/GRPCConnectivityMonitor.h | 47 ---------- .../private/GRPCConnectivityMonitor.m | 90 ------------------- 3 files changed, 1 insertion(+), 138 deletions(-) delete mode 100644 src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h delete mode 100644 src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m diff --git a/gRPC.podspec b/gRPC.podspec index 7b253a2b2bb..bbfd08f9774 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -58,8 +58,8 @@ Pod::Spec.new do |s| ss.header_mappings_dir = "#{src_dir}" ss.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}" + ss.exclude_files = "#{src_dir}/GRPCCall+GID.{h,m}" ss.private_header_files = "#{src_dir}/private/*.h", "#{src_dir}/internal/*.h" - ss.exclude_files = "#{src_dir}/GRPCCall+GID.{h,m}", "#{src_dir}/private/GRPCConnectivityMonitor.{h,m}" ss.dependency 'gRPC-Core', version end diff --git a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h b/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h deleted file mode 100644 index d4b49b1b28e..00000000000 --- a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import -#import - -typedef NS_ENUM(NSInteger, GRPCConnectivityStatus) { - GRPCConnectivityUnknown = 0, - GRPCConnectivityNoNetwork = 1, - GRPCConnectivityCellular = 2, - GRPCConnectivityWiFi = 3, -}; - -extern NSString* _Nonnull kGRPCConnectivityNotification; - -// This interface monitors OS reachability interface for any network status -// change. Parties interested in these events should register themselves as -// observer. -@interface GRPCConnectivityMonitor : NSObject - -- (nonnull instancetype)init NS_UNAVAILABLE; - -// Register an object as observer of network status change. \a observer -// must have a notification method with one parameter of type -// (NSNotification *) and should pass it to parameter \a selector. The -// parameter of this notification method is not used for now. -+ (void)registerObserver:(_Nonnull id)observer selector:(_Nonnull SEL)selector; - -// Ungegister an object from observers of network status change. -+ (void)unregisterObserver:(_Nonnull id)observer; - -@end diff --git a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m b/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m deleted file mode 100644 index bb8618ff335..00000000000 --- a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m +++ /dev/null @@ -1,90 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import "GRPCConnectivityMonitor.h" - -#include - -NSString *kGRPCConnectivityNotification = @"kGRPCConnectivityNotification"; - -static SCNetworkReachabilityRef reachability; -static GRPCConnectivityStatus currentStatus; - -// Aggregate information in flags into network status. -GRPCConnectivityStatus CalculateConnectivityStatus(SCNetworkReachabilityFlags flags) { - GRPCConnectivityStatus result = GRPCConnectivityUnknown; - if (((flags & kSCNetworkReachabilityFlagsReachable) == 0) || - ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0)) { - return GRPCConnectivityNoNetwork; - } - result = GRPCConnectivityWiFi; -#if TARGET_OS_IPHONE - if (flags & kSCNetworkReachabilityFlagsIsWWAN) { - return result = GRPCConnectivityCellular; - } -#endif - return result; -} - -static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, - void *info) { - GRPCConnectivityStatus newStatus = CalculateConnectivityStatus(flags); - - if (newStatus != currentStatus) { - [[NSNotificationCenter defaultCenter] postNotificationName:kGRPCConnectivityNotification - object:nil]; - currentStatus = newStatus; - } -} - -@implementation GRPCConnectivityMonitor - -+ (void)initialize { - if (self == [GRPCConnectivityMonitor self]) { - struct sockaddr_in addr = {0}; - addr.sin_len = sizeof(addr); - addr.sin_family = AF_INET; - reachability = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&addr); - currentStatus = GRPCConnectivityUnknown; - - SCNetworkConnectionFlags flags; - if (SCNetworkReachabilityGetFlags(reachability, &flags)) { - currentStatus = CalculateConnectivityStatus(flags); - } - - SCNetworkReachabilityContext context = {0, (__bridge void *)(self), NULL, NULL, NULL}; - if (!SCNetworkReachabilitySetCallback(reachability, ReachabilityCallback, &context) || - !SCNetworkReachabilityScheduleWithRunLoop(reachability, CFRunLoopGetMain(), - kCFRunLoopCommonModes)) { - NSLog(@"gRPC connectivity monitor fail to set"); - } - } -} - -+ (void)registerObserver:(id)observer selector:(SEL)selector { - [[NSNotificationCenter defaultCenter] addObserver:observer - selector:selector - name:kGRPCConnectivityNotification - object:nil]; -} - -+ (void)unregisterObserver:(id)observer { - [[NSNotificationCenter defaultCenter] removeObserver:observer]; -} - -@end From 37126b54463d02b790f26aefc3e1c1294b80f212 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Wed, 17 Jul 2019 10:53:54 -0700 Subject: [PATCH 0911/1555] Lower min-time-between-resolutions for the goaway server test --- test/core/end2end/goaway_server_test.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/core/end2end/goaway_server_test.cc b/test/core/end2end/goaway_server_test.cc index 7e3b418cd94..5db2aebe9a1 100644 --- a/test/core/end2end/goaway_server_test.cc +++ b/test/core/end2end/goaway_server_test.cc @@ -185,13 +185,23 @@ int main(int argc, char** argv) { char* addr; grpc_channel_args client_args; - grpc_arg arg_array[1]; + grpc_arg arg_array[2]; arg_array[0].type = GRPC_ARG_INTEGER; arg_array[0].key = const_cast("grpc.testing.fixed_reconnect_backoff_ms"); arg_array[0].value.integer = 1000; + /* When this test brings down server1 and then brings up server2, + * the targetted server port number changes, and the client channel + * needs to re-resolve to pick this up. This test requires that + * happen within 10 seconds, but gRPC's DNS resolvers rate limit + * resolution attempts to at most once every 30 seconds by default. + * So we tweak it for this test. */ + arg_array[1].type = GRPC_ARG_INTEGER; + arg_array[1].key = + const_cast(GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS); + arg_array[1].value.integer = 1000; client_args.args = arg_array; - client_args.num_args = 1; + client_args.num_args = 2; /* create a channel that picks first amongst the servers */ grpc_channel* chan = From ad38c6eddf4f74398d6a025a819d4d28df2b4490 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 17 Jul 2019 11:03:22 -0700 Subject: [PATCH 0912/1555] Fix clang-tidy error. --- src/core/ext/filters/client_channel/subchannel.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index c3521f46cee..5e6cbccd93f 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -140,8 +140,9 @@ RefCountedPtr SubchannelCall::Create(Args args, const size_t allocation_size = args.connected_subchannel->GetInitialCallSizeEstimate( args.parent_data_size); - return RefCountedPtr(new (args.arena->Alloc( - allocation_size)) SubchannelCall(std::move(args), error)); + Arena* arena = args.arena; + return RefCountedPtr(new ( + arena->Alloc(allocation_size)) SubchannelCall(std::move(args), error)); } SubchannelCall::SubchannelCall(Args args, grpc_error** error) From b8a0271843476dd9e3d8f12550b0fec0cd34c70a Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 17 Jul 2019 14:00:51 -0700 Subject: [PATCH 0913/1555] Removed unused references to connectivityChange(d) --- src/objective-c/GRPCClient/GRPCCall.m | 19 ------------------- .../GRPCClient/private/GRPCChannelPool.m | 4 ---- 2 files changed, 23 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index a9b112b5d52..cd293cc8e59 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -892,23 +892,4 @@ const char *kCFStreamVarName = "grpc_cfstream"; } } -- (void)connectivityChanged:(NSNotification *)note { - // Cancel underlying call upon this notification. - - // Retain because connectivity manager only keeps weak reference to GRPCCall. - __strong GRPCCall *strongSelf = self; - if (strongSelf) { - @synchronized(strongSelf) { - [_wrappedCall cancel]; - [strongSelf - finishWithError:[NSError errorWithDomain:kGRPCErrorDomain - code:GRPCErrorCodeUnavailable - userInfo:@{ - NSLocalizedDescriptionKey : @"Connectivity lost." - }]]; - } - strongSelf->_requestWriter.state = GRXWriterStateFinished; - } -} - @end diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.m b/src/objective-c/GRPCClient/private/GRPCChannelPool.m index 683e203ca31..b6fafd3012f 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannelPool.m +++ b/src/objective-c/GRPCClient/private/GRPCChannelPool.m @@ -260,10 +260,6 @@ static const NSTimeInterval kDefaultChannelDestroyDelay = 30; } } -- (void)connectivityChange:(NSNotification *)note { - [self disconnectAllChannels]; -} - @end @implementation GRPCChannelPool (Test) From 9e675ecb901753a04fb9c0fde19e629b359df4db Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 17 Jul 2019 14:07:09 -0700 Subject: [PATCH 0914/1555] Fixing clang_format_code failure --- src/objective-c/GRPCClient/private/GRPCChannelPool.m | 1 - 1 file changed, 1 deletion(-) diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.m b/src/objective-c/GRPCClient/private/GRPCChannelPool.m index b6fafd3012f..d545793fcce 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannelPool.m +++ b/src/objective-c/GRPCClient/private/GRPCChannelPool.m @@ -219,7 +219,6 @@ static const NSTimeInterval kDefaultChannelDestroyDelay = 30; } - (void)dealloc { - } - (GRPCPooledChannel *)channelWithHost:(NSString *)host callOptions:(GRPCCallOptions *)callOptions { From 3776916fe96e43b0bd3f951d9ed9994ee3040575 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Wed, 17 Jul 2019 14:07:17 -0700 Subject: [PATCH 0915/1555] Modify shutdown check --- src/core/lib/iomgr/executor/threadpool.cc | 6 +++--- src/core/lib/iomgr/executor/threadpool.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/lib/iomgr/executor/threadpool.cc b/src/core/lib/iomgr/executor/threadpool.cc index f0df1bd18eb..29eb0a67cf8 100644 --- a/src/core/lib/iomgr/executor/threadpool.cc +++ b/src/core/lib/iomgr/executor/threadpool.cc @@ -72,9 +72,9 @@ size_t ThreadPool::DefaultStackSize() { #endif } -bool ThreadPool::HasBeenShutDown() { +void ThreadPool::AssertHasBeenShutDown() { // For debug checking purpose, using RELAXED order is sufficient. - return shut_down_.Load(MemoryOrder::RELAXED); + GPR_DEBUG_ASSERT(!shut_down_.Load(MemoryOrder::RELAXED)); } ThreadPool::ThreadPool(int num_threads) : num_threads_(num_threads) { @@ -122,7 +122,7 @@ ThreadPool::~ThreadPool() { } void ThreadPool::Add(grpc_experimental_completion_queue_functor* closure) { - GPR_DEBUG_ASSERT(!HasBeenShutDown()); + AssertHasBeenShutDown(); queue_->Put(static_cast(closure)); } diff --git a/src/core/lib/iomgr/executor/threadpool.h b/src/core/lib/iomgr/executor/threadpool.h index 78f61a3139c..16277838fb0 100644 --- a/src/core/lib/iomgr/executor/threadpool.h +++ b/src/core/lib/iomgr/executor/threadpool.h @@ -145,7 +145,7 @@ class ThreadPool : public ThreadPoolInterface { // platforms is 64K. size_t DefaultStackSize(); // Internal Use Only for debug checking. - bool HasBeenShutDown(); + void AssertHasBeenShutDown(); }; } // namespace grpc_core From b7ee64c042ab088444c58d74dfd30e5781a89f1b Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 17 Jul 2019 13:02:00 -0700 Subject: [PATCH 0916/1555] Disable _FORTIFY_SOURCE when GPR_BACKWARDS_COMPATIBILITY_MODE --- include/grpc/impl/codegen/port_platform.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index d7294d59d41..446ab04868d 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -394,6 +394,17 @@ #endif #endif /* GPR_NO_AUTODETECT_PLATFORM */ +#if defined(GPR_BACKWARDS_COMPATIBILITY_MODE) +/* + * For backward compatibility mode, reset _FORTIFY_SOURCE to prevent + * a library from having non-standard symbols such as __asprintf_chk. + * This helps non-glibc systems such as alpine using musl to find symbols. + */ +#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 +#define _FORTIFY_SOURCE 0 +#endif +#endif + /* * There are platforms for which TLS should not be used even though the * compiler makes it seem like it's supported (Android NDK < r12b for example). From c6993a3841a4802ad177966bd4f5b01c4922f9c9 Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Tue, 16 Jul 2019 16:04:24 -0700 Subject: [PATCH 0917/1555] Run cfstream_test under ASAN and TSAN --- tools/bazel.rc | 3 +++ .../internal_ci/macos/grpc_cfstream_asan.cfg | 23 +++++++++++++++++++ .../internal_ci/macos/grpc_cfstream_tsan.cfg | 23 +++++++++++++++++++ .../internal_ci/macos/grpc_run_bazel_tests.sh | 2 +- 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 tools/internal_ci/macos/grpc_cfstream_asan.cfg create mode 100644 tools/internal_ci/macos/grpc_cfstream_tsan.cfg diff --git a/tools/bazel.rc b/tools/bazel.rc index 7a716e85088..411457a7cf5 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -13,6 +13,9 @@ build:opt --copt=-Wframe-larger-than=16384 build:dbg --compilation_mode=dbg build:asan --strip=never +# Workaround for https://github.com/bazelbuild/bazel/issues/6932 +build:asan --copt -Wno-macro-redefined +build:asan --copt -D_FORTIFY_SOURCE=0 build:asan --copt=-fsanitize=address build:asan --copt=-O0 build:asan --copt=-fno-omit-frame-pointer diff --git a/tools/internal_ci/macos/grpc_cfstream_asan.cfg b/tools/internal_ci/macos/grpc_cfstream_asan.cfg new file mode 100644 index 00000000000..ceff78a4399 --- /dev/null +++ b/tools/internal_ci/macos/grpc_cfstream_asan.cfg @@ -0,0 +1,23 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/macos/grpc_run_bazel_tests.sh" +env_vars { + key: "RUN_TESTS_FLAGS" + value: "--config=asan" +} + diff --git a/tools/internal_ci/macos/grpc_cfstream_tsan.cfg b/tools/internal_ci/macos/grpc_cfstream_tsan.cfg new file mode 100644 index 00000000000..52f1f3eec76 --- /dev/null +++ b/tools/internal_ci/macos/grpc_cfstream_tsan.cfg @@ -0,0 +1,23 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/macos/grpc_run_bazel_tests.sh" +env_vars { + key: "RUN_TESTS_FLAGS" + value: "--config=tsan" +} + diff --git a/tools/internal_ci/macos/grpc_run_bazel_tests.sh b/tools/internal_ci/macos/grpc_run_bazel_tests.sh index 56fae8fd75f..c64dcc5c95d 100644 --- a/tools/internal_ci/macos/grpc_run_bazel_tests.sh +++ b/tools/internal_ci/macos/grpc_run_bazel_tests.sh @@ -29,7 +29,7 @@ which bazel ./tools/run_tests/start_port_server.py # run cfstream_test separately because it messes with the network -bazel test --spawn_strategy=standalone --genrule_strategy=standalone --test_output=all //test/cpp/end2end:cfstream_test +bazel test $RUN_TESTS_FLAGS --spawn_strategy=standalone --genrule_strategy=standalone --test_output=all //test/cpp/end2end:cfstream_test # kill port_server.py to prevent the build from hanging ps aux | grep port_server\\.py | awk '{print $2}' | xargs kill -9 From 09b62fbf3790347114b4ba6e1358af10989fc45a Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Wed, 17 Jul 2019 15:15:44 -0700 Subject: [PATCH 0918/1555] Fix naming --- src/core/lib/iomgr/executor/threadpool.cc | 4 ++-- src/core/lib/iomgr/executor/threadpool.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/lib/iomgr/executor/threadpool.cc b/src/core/lib/iomgr/executor/threadpool.cc index 29eb0a67cf8..e203252ef08 100644 --- a/src/core/lib/iomgr/executor/threadpool.cc +++ b/src/core/lib/iomgr/executor/threadpool.cc @@ -72,7 +72,7 @@ size_t ThreadPool::DefaultStackSize() { #endif } -void ThreadPool::AssertHasBeenShutDown() { +void ThreadPool::AssertHasNotBeenShutDown() { // For debug checking purpose, using RELAXED order is sufficient. GPR_DEBUG_ASSERT(!shut_down_.Load(MemoryOrder::RELAXED)); } @@ -122,7 +122,7 @@ ThreadPool::~ThreadPool() { } void ThreadPool::Add(grpc_experimental_completion_queue_functor* closure) { - AssertHasBeenShutDown(); + AssertHasNotBeenShutDown(); queue_->Put(static_cast(closure)); } diff --git a/src/core/lib/iomgr/executor/threadpool.h b/src/core/lib/iomgr/executor/threadpool.h index 16277838fb0..7b33fb32f36 100644 --- a/src/core/lib/iomgr/executor/threadpool.h +++ b/src/core/lib/iomgr/executor/threadpool.h @@ -145,7 +145,7 @@ class ThreadPool : public ThreadPoolInterface { // platforms is 64K. size_t DefaultStackSize(); // Internal Use Only for debug checking. - void AssertHasBeenShutDown(); + void AssertHasNotBeenShutDown(); }; } // namespace grpc_core From c4481f55384caa44082be9d9716855c1609fc0ff Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Thu, 18 Jul 2019 01:17:54 +0200 Subject: [PATCH 0919/1555] Trying out my upb change. --- bazel/grpc_deps.bzl | 6 +++--- tools/run_tests/sanity/check_submodules.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 327af38e521..d6eb9fbeae1 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -206,9 +206,9 @@ def grpc_deps(): if "upb" not in native.existing_rules(): http_archive( name = "upb", - sha256 = "909b6fca860a85bea7dda4770aae66f6afd6f12586e8a4cb95460d0707fd66ce", - strip_prefix = "upb-312c6b421a3c749e4f7c0e2193d4775cb997cff7", - url = "https://github.com/haberman/upb/archive/312c6b421a3c749e4f7c0e2193d4775cb997cff7.tar.gz", + sha256 = "97a8af639cbda4159c42d193ad166ad3020df92ddb2d888700c2d237ab51c0f7", + strip_prefix = "upb-ce3ba4dcdcd34d85672d93bd552e8bc871f02b53", + url = "https://github.com/protocolbuffers/upb/archive/ce3ba4dcdcd34d85672d93bd552e8bc871f02b53.tar.gz", ) if "envoy_api" not in native.existing_rules(): http_archive( diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index 77fc34e3b10..136d2b960c0 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -40,7 +40,7 @@ cat << EOF | awk '{ print $1 }' | sort > "$want_submodules" 9245d481eb3e890f708ff2d7dadf2a10c04748ba third_party/libcxxabi (heads/release_60) 09745575a923640154bcf307fba8aedff47f240a third_party/protobuf (v3.7.0-rc.2-247-g09745575) e143189bf6f37b3957fb31743df6a1bcf4a8c685 third_party/protoc-gen-validate (v0.0.10) - 312c6b421a3c749e4f7c0e2193d4775cb997cff7 third_party/upb (heads/master) + ce3ba4dcdcd34d85672d93bd552e8bc871f02b53 third_party/upb (heads/master) cacf7f1d4e3d44d871b605da3b647f07d718623f third_party/zlib (v1.2.11) EOF From 8cc5b8f680ed4857e0734b9a951ada1ca25bf069 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 17 Jul 2019 13:14:43 -0700 Subject: [PATCH 0920/1555] Defer grpc shutdown until after channel destruction. --- src/core/lib/surface/channel.cc | 19 +++++++++++++++++++ test/cpp/microbenchmarks/bm_call_create.cc | 6 ++++++ 2 files changed, 25 insertions(+) diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index e61550743b7..db7272dba6d 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -235,6 +235,23 @@ grpc_channel* grpc_channel_create(const char* target, grpc_channel_stack_type channel_stack_type, grpc_transport* optional_transport, grpc_resource_user* resource_user) { + // We need to make sure that grpc_shutdown() does not shut things down + // until after the channel is destroyed. However, the channel may not + // actually be destroyed by the time grpc_channel_destroy() returns, + // since there may be other existing refs to the channel. If those + // refs are held by things that are visible to the wrapped language + // (such as outstanding calls on the channel), then the wrapped + // language can be responsible for making sure that grpc_shutdown() + // does not run until after those refs are released. However, the + // channel may also have refs to itself held internally for various + // things that need to be cleaned up at channel destruction (e.g., + // LB policies, subchannels, etc), and because these refs are not + // visible to the wrapped language, it cannot be responsible for + // deferring grpc_shutdown() until after they are released. To + // accommodate that, we call grpc_init() here and then call + // grpc_shutdown() when the channel is actually destroyed, thus + // ensuring that shutdown is deferred until that point. + grpc_init(); grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create(); const grpc_core::UniquePtr default_authority = get_default_authority(input_args); @@ -468,6 +485,8 @@ static void destroy_channel(void* arg, grpc_error* error) { gpr_mu_destroy(&channel->registered_call_mu); gpr_free(channel->target); gpr_free(channel); + // See comment in grpc_channel_create() for why we do this. + grpc_shutdown(); } void grpc_channel_destroy(grpc_channel* channel) { diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 3bd1464b2aa..aad94afca5b 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -686,6 +686,12 @@ static const grpc_channel_filter isolated_call_filter = { class IsolatedCallFixture : public TrackCounters { public: IsolatedCallFixture() { + // We are calling grpc_channel_stack_builder_create() instead of + // grpc_channel_create() here, which means we're not getting the + // grpc_init() called by grpc_channel_create(), but we are getting + // the grpc_shutdown() run by grpc_channel_destroy(). So we need to + // call grpc_init() manually here to balance things out. + grpc_init(); grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create(); grpc_channel_stack_builder_set_name(builder, "dummy"); grpc_channel_stack_builder_set_target(builder, "dummy_target"); From 38366dfec4a43d11593ae373086246cb129ad209 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 18 Jul 2019 10:39:11 +0200 Subject: [PATCH 0921/1555] fix nits --- doc/versioning.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/versioning.md b/doc/versioning.md index e39334d1df1..11f4c70963d 100644 --- a/doc/versioning.md +++ b/doc/versioning.md @@ -8,7 +8,7 @@ All gRPC implementations use a three-part version number (`vX.Y.Z`) and strictly - **Patch version bump** corresponds to bugfixes done on release branch. There are also a few extra rules regarding adding new gRPC implementations (e.g. adding support for a new language) -- New implementations start at v0.x.y version they reaches 1.0, they are considered not ready for production workloads. Breaking API changes are allowed in the 0.x releases as the library is not considered stable yet. +- New implementations start at v0.x.y version and until they reach 1.0, they are considered not ready for production workloads. Breaking API changes are allowed in the 0.x releases as the library is not considered stable yet. - The "1.0" release has semantics of GA (generally available) and being production ready. Requirements to reach this milestone are at least these - basic RPC features are feature complete and tested - implementation is tested for interoperability with other languages @@ -24,7 +24,7 @@ To avoid user confusion and simplify reasoning, the gRPC releases in different l - **voluntary change:** Even in non-forced situations, there might be circumstances in which a breaking API change makes sense and represents a net win, but as a rule of thumb breaking changes are very disruptive for users, cause user fragmentation and incur high maintenance costs. Therefore, breaking API changes should be very rare events that need to be considered with extreme care and the bar for accepting such changes is intentionally set very high. Example scenarios where a breaking API change might be adequate: - fixing a security problem which requires changes to API (need to consider the non-breaking alternatives first) - - the change leads to very significant gains to security, usability or development. velocity. These gains need to be clearly documented and claims need to be supported by evidence (ideally by numbers). Costs to the ecosystem (impact on users, dev team etc.) need to be taken into account and the change still needs to be a net positive after subtracting the costs. + - the change leads to very significant gains to security, usability or development velocity. These gains need to be clearly documented and claims need to be supported by evidence (ideally by numbers). Costs to the ecosystem (impact on users, dev team etc.) need to be taken into account and the change still needs to be a net positive after subtracting the costs. All proposals to make a breaking change need to be documented as a gRFC document (in the grpc/proposal repository) that covers at least these areas: - Description of the proposal including an explanation why the proposed change is one of the very rare events where a breaking change is introduced. From 5625006c00e49dbdc15e94ffce73f5b2169a17cd Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 18 Jul 2019 10:42:43 +0200 Subject: [PATCH 0922/1555] regenerate doxygen --- tools/doxygen/Doxyfile.c++ | 1 + tools/doxygen/Doxyfile.c++.internal | 1 + tools/doxygen/Doxyfile.core | 1 + tools/doxygen/Doxyfile.core.internal | 1 + 4 files changed, 4 insertions(+) diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index bdb36ae1a7b..e85ae495546 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -794,6 +794,7 @@ doc/ssl-performance.md \ doc/status_ordering.md \ doc/statuscodes.md \ doc/unit_testing.md \ +doc/versioning.md \ doc/wait-for-ready.md \ doc/workarounds.md \ include/grpc++/alarm.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index e711b662eae..626887290be 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -794,6 +794,7 @@ doc/ssl-performance.md \ doc/status_ordering.md \ doc/statuscodes.md \ doc/unit_testing.md \ +doc/versioning.md \ doc/wait-for-ready.md \ doc/workarounds.md \ include/grpc++/alarm.h \ diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index 7235c7b1539..2836412b031 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -801,6 +801,7 @@ doc/ssl-performance.md \ doc/status_ordering.md \ doc/statuscodes.md \ doc/unit_testing.md \ +doc/versioning.md \ doc/wait-for-ready.md \ doc/workarounds.md \ include/grpc/byte_buffer.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 273c56e0242..5ac8256ce4b 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -801,6 +801,7 @@ doc/ssl-performance.md \ doc/status_ordering.md \ doc/statuscodes.md \ doc/unit_testing.md \ +doc/versioning.md \ doc/wait-for-ready.md \ doc/workarounds.md \ include/grpc/byte_buffer.h \ From f5a3e32b9b1ec178de3d23aa6bf173aae9470eca Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Thu, 18 Jul 2019 09:46:42 -0700 Subject: [PATCH 0923/1555] Take the mu_call mutex before zombifying pending calls so that there is no race between publishing new rpcs during a shutdown scenario --- src/core/lib/surface/server.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index a1c7d132ade..7fe05c10a54 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -711,8 +711,10 @@ static void maybe_finish_shutdown(grpc_server* server) { return; } + gpr_mu_lock(&server->mu_call); kill_pending_work_locked( server, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown")); + gpr_mu_unlock(&server->mu_call); if (server->root_channel_data.next != &server->root_channel_data || server->listeners_destroyed < num_listeners(server)) { From 3cd20e3d350e767be4d9baef3b4236a50deaf455 Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Thu, 18 Jul 2019 12:11:01 -0700 Subject: [PATCH 0924/1555] Fix log level in CFStream Downgraded some log level of some log sites from ERROR to DEBUG. --- src/core/lib/iomgr/cfstream_handle.cc | 2 +- src/core/lib/iomgr/lockfree_event.cc | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/lib/iomgr/cfstream_handle.cc b/src/core/lib/iomgr/cfstream_handle.cc index 8d01386a8f9..ea28e620695 100644 --- a/src/core/lib/iomgr/cfstream_handle.cc +++ b/src/core/lib/iomgr/cfstream_handle.cc @@ -184,7 +184,7 @@ void CFStreamHandle::Ref(const char* file, int line, const char* reason) { void CFStreamHandle::Unref(const char* file, int line, const char* reason) { if (grpc_tcp_trace.enabled()) { gpr_atm val = gpr_atm_no_barrier_load(&refcount_.count); - gpr_log(GPR_ERROR, + gpr_log(GPR_DEBUG, "CFStream Handle unref %p : %s %" PRIdPTR " -> %" PRIdPTR, this, reason, val, val - 1); } diff --git a/src/core/lib/iomgr/lockfree_event.cc b/src/core/lib/iomgr/lockfree_event.cc index f33485ee59d..c7082345fd2 100644 --- a/src/core/lib/iomgr/lockfree_event.cc +++ b/src/core/lib/iomgr/lockfree_event.cc @@ -95,7 +95,7 @@ void LockfreeEvent::NotifyOn(grpc_closure* closure) { * referencing it. */ gpr_atm curr = gpr_atm_acq_load(&state_); if (GRPC_TRACE_FLAG_ENABLED(grpc_polling_trace)) { - gpr_log(GPR_ERROR, "LockfreeEvent::NotifyOn: %p curr=%p closure=%p", this, + gpr_log(GPR_DEBUG, "LockfreeEvent::NotifyOn: %p curr=%p closure=%p", this, (void*)curr, closure); } switch (curr) { @@ -161,7 +161,7 @@ bool LockfreeEvent::SetShutdown(grpc_error* shutdown_err) { while (true) { gpr_atm curr = gpr_atm_no_barrier_load(&state_); if (GRPC_TRACE_FLAG_ENABLED(grpc_polling_trace)) { - gpr_log(GPR_ERROR, "LockfreeEvent::SetShutdown: %p curr=%p err=%s", + gpr_log(GPR_DEBUG, "LockfreeEvent::SetShutdown: %p curr=%p err=%s", &state_, (void*)curr, grpc_error_string(shutdown_err)); } switch (curr) { @@ -210,7 +210,7 @@ void LockfreeEvent::SetReady() { gpr_atm curr = gpr_atm_no_barrier_load(&state_); if (GRPC_TRACE_FLAG_ENABLED(grpc_polling_trace)) { - gpr_log(GPR_ERROR, "LockfreeEvent::SetReady: %p curr=%p", &state_, + gpr_log(GPR_DEBUG, "LockfreeEvent::SetReady: %p curr=%p", &state_, (void*)curr); } From b47d22f7f2cfc664277d58b5e3d0657f094d20b5 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Thu, 18 Jul 2019 11:50:11 -0700 Subject: [PATCH 0925/1555] Mark assert failure path as unlikely in codegen. Also, change an assert to debug assert in callback cpp. --- include/grpcpp/impl/codegen/callback_common.h | 4 +++- include/grpcpp/impl/codegen/core_codegen_interface.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/grpcpp/impl/codegen/callback_common.h b/include/grpcpp/impl/codegen/callback_common.h index a3c8c41246c..6170170b978 100644 --- a/include/grpcpp/impl/codegen/callback_common.h +++ b/include/grpcpp/impl/codegen/callback_common.h @@ -201,9 +201,11 @@ class CallbackWithSuccessTag void* ignored = ops_; // Allow a "false" return value from FinalizeResult to silence the // callback, just as it silences a CQ tag in the async cases +#ifndef NDEBUG auto* ops = ops_; +#endif bool do_callback = ops_->FinalizeResult(&ignored, &ok); - GPR_CODEGEN_ASSERT(ignored == ops); + GPR_CODEGEN_DEBUG_ASSERT(ignored == ops); if (do_callback) { CatchingCallback(func_, ok); diff --git a/include/grpcpp/impl/codegen/core_codegen_interface.h b/include/grpcpp/impl/codegen/core_codegen_interface.h index 02b5033c51f..8a7ac0ad452 100644 --- a/include/grpcpp/impl/codegen/core_codegen_interface.h +++ b/include/grpcpp/impl/codegen/core_codegen_interface.h @@ -144,7 +144,7 @@ extern CoreCodegenInterface* g_core_codegen_interface; /// Codegen specific version of \a GPR_ASSERT. #define GPR_CODEGEN_ASSERT(x) \ do { \ - if (!(x)) { \ + if (GPR_UNLIKELY(!(x))) { \ grpc::g_core_codegen_interface->assert_fail(#x, __FILE__, __LINE__); \ } \ } while (0) From 63b4f3d8195fc4c6196bf2e3a4705ab2fa16d1e4 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Thu, 18 Jul 2019 13:00:24 -0700 Subject: [PATCH 0926/1555] Revert "Merge pull request #19673 from markdroth/channel_grpc_init" This reverts commit 4e219807161f3cfe581ca8f79f5ae060c2631a8f, reversing changes made to 62b8a783fa376d6bfe277d6e1877b31f89e16553. --- src/core/lib/surface/channel.cc | 19 ------------------- test/cpp/microbenchmarks/bm_call_create.cc | 6 ------ 2 files changed, 25 deletions(-) diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index db7272dba6d..e61550743b7 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -235,23 +235,6 @@ grpc_channel* grpc_channel_create(const char* target, grpc_channel_stack_type channel_stack_type, grpc_transport* optional_transport, grpc_resource_user* resource_user) { - // We need to make sure that grpc_shutdown() does not shut things down - // until after the channel is destroyed. However, the channel may not - // actually be destroyed by the time grpc_channel_destroy() returns, - // since there may be other existing refs to the channel. If those - // refs are held by things that are visible to the wrapped language - // (such as outstanding calls on the channel), then the wrapped - // language can be responsible for making sure that grpc_shutdown() - // does not run until after those refs are released. However, the - // channel may also have refs to itself held internally for various - // things that need to be cleaned up at channel destruction (e.g., - // LB policies, subchannels, etc), and because these refs are not - // visible to the wrapped language, it cannot be responsible for - // deferring grpc_shutdown() until after they are released. To - // accommodate that, we call grpc_init() here and then call - // grpc_shutdown() when the channel is actually destroyed, thus - // ensuring that shutdown is deferred until that point. - grpc_init(); grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create(); const grpc_core::UniquePtr default_authority = get_default_authority(input_args); @@ -485,8 +468,6 @@ static void destroy_channel(void* arg, grpc_error* error) { gpr_mu_destroy(&channel->registered_call_mu); gpr_free(channel->target); gpr_free(channel); - // See comment in grpc_channel_create() for why we do this. - grpc_shutdown(); } void grpc_channel_destroy(grpc_channel* channel) { diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index aad94afca5b..3bd1464b2aa 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -686,12 +686,6 @@ static const grpc_channel_filter isolated_call_filter = { class IsolatedCallFixture : public TrackCounters { public: IsolatedCallFixture() { - // We are calling grpc_channel_stack_builder_create() instead of - // grpc_channel_create() here, which means we're not getting the - // grpc_init() called by grpc_channel_create(), but we are getting - // the grpc_shutdown() run by grpc_channel_destroy(). So we need to - // call grpc_init() manually here to balance things out. - grpc_init(); grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create(); grpc_channel_stack_builder_set_name(builder, "dummy"); grpc_channel_stack_builder_set_target(builder, "dummy_target"); From 884b68c98467bb408b35828c35564a6768d64e2f Mon Sep 17 00:00:00 2001 From: Pau Freixes Date: Sun, 28 Apr 2019 17:35:07 +0200 Subject: [PATCH 0927/1555] Create App context callback for timer custom When a timer reaches its deadline and it uses the combination of having enabled the custom timer and using a completion queue of callback type we must provide the App context callback at TLS level. Otherwise, a segfault is produced during the enqueuing process of the application callback. --- src/core/lib/iomgr/timer_custom.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/lib/iomgr/timer_custom.cc b/src/core/lib/iomgr/timer_custom.cc index 71d825ff9f5..57675c27a8f 100644 --- a/src/core/lib/iomgr/timer_custom.cc +++ b/src/core/lib/iomgr/timer_custom.cc @@ -32,6 +32,7 @@ static grpc_custom_timer_vtable* custom_timer_impl; void grpc_custom_timer_callback(grpc_custom_timer* t, grpc_error* error) { GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD(); + grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; grpc_timer* timer = t->original; GPR_ASSERT(timer->pending); From 553eff9cb08f091e80a759b44b1a9ac8385981f0 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Thu, 18 Jul 2019 14:03:19 -0700 Subject: [PATCH 0928/1555] Fix a test failure due to unused variable and formatting --- test/cpp/end2end/client_callback_end2end_test.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/cpp/end2end/client_callback_end2end_test.cc b/test/cpp/end2end/client_callback_end2end_test.cc index ea94ac77726..a54158ac1d1 100644 --- a/test/cpp/end2end/client_callback_end2end_test.cc +++ b/test/cpp/end2end/client_callback_end2end_test.cc @@ -391,8 +391,7 @@ TEST_P(ClientCallbackEnd2endTest, SimpleRpcUnderLockNested) { stub_->experimental_async()->Echo( &cli_ctx1, &request1, &response1, [this, &mu1, &mu2, &mu3, &cv, &done, &request1, &request2, &request3, - &response1, &response2, &response3, &cli_ctx1, &cli_ctx2, - &cli_ctx3](Status s1) { + &response1, &response2, &response3, &cli_ctx2, &cli_ctx3](Status s1) { std::lock_guard l1(mu1); EXPECT_TRUE(s1.ok()); EXPECT_EQ(request1.message(), response1.message()); From 43a8461c2430cc734ebab86e0f7361fa825c91bc Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Fri, 19 Jul 2019 00:49:43 +0200 Subject: [PATCH 0929/1555] Rollbacking upb stuff. --- bazel/grpc_deps.bzl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index d6eb9fbeae1..af177cda78b 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -206,9 +206,9 @@ def grpc_deps(): if "upb" not in native.existing_rules(): http_archive( name = "upb", - sha256 = "97a8af639cbda4159c42d193ad166ad3020df92ddb2d888700c2d237ab51c0f7", - strip_prefix = "upb-ce3ba4dcdcd34d85672d93bd552e8bc871f02b53", - url = "https://github.com/protocolbuffers/upb/archive/ce3ba4dcdcd34d85672d93bd552e8bc871f02b53.tar.gz", + sha256 = "d2142e966d4d122ace5c2cc9afc86f12bf0ff93c39544d7a6c6fdcd69d767985", + strip_prefix = "upb-9605c7093c269a4767b9c4a57e2ca021c725644d", + url = "https://github.com/nicolasnoble/upb/archive/9605c7093c269a4767b9c4a57e2ca021c725644d.tar.gz", ) if "envoy_api" not in native.existing_rules(): http_archive( From 126ef2f735c14d406e054efb2d35ce6a75209421 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Thu, 18 Jul 2019 16:24:30 -0700 Subject: [PATCH 0930/1555] Added #undef --- include/grpc/impl/codegen/port_platform.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index 446ab04868d..c0ca9f43716 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -401,6 +401,7 @@ * This helps non-glibc systems such as alpine using musl to find symbols. */ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 +#undef _FORTIFY_SOURCE #define _FORTIFY_SOURCE 0 #endif #endif From 5efa660b41ab05971901f3a7b19e3890ea1e8884 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Thu, 18 Jul 2019 17:01:45 -0700 Subject: [PATCH 0931/1555] Remove warning for old linux without secure_getenv --- src/core/lib/gpr/env_linux.cc | 31 ++++++++++--------------------- src/core/lib/gpr/env_posix.cc | 5 ----- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/src/core/lib/gpr/env_linux.cc b/src/core/lib/gpr/env_linux.cc index 3a3aa541672..6a78dc14155 100644 --- a/src/core/lib/gpr/env_linux.cc +++ b/src/core/lib/gpr/env_linux.cc @@ -38,19 +38,20 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" -static const char* gpr_getenv_silent(const char* name, char** dst) { - const char* insecure_func_used = nullptr; +char* gpr_getenv(const char* name) { char* result = nullptr; #if defined(GPR_BACKWARDS_COMPATIBILITY_MODE) typedef char* (*getenv_type)(const char*); - static getenv_type getenv_func = NULL; + static getenv_type getenv_func = nullptr; /* Check to see which getenv variant is supported (go from most * to least secure) */ - const char* names[] = {"secure_getenv", "__secure_getenv", "getenv"}; - for (size_t i = 0; getenv_func == NULL && i < GPR_ARRAY_SIZE(names); i++) { - getenv_func = (getenv_type)dlsym(RTLD_DEFAULT, names[i]); - if (getenv_func != NULL && strstr(names[i], "secure") == NULL) { - insecure_func_used = names[i]; + if (getenv_func == nullptr) { + const char* names[] = {"secure_getenv", "__secure_getenv", "getenv"}; + for (size_t i = 0; i < GPR_ARRAY_SIZE(names); i++) { + getenv_func = (getenv_type)dlsym(RTLD_DEFAULT, names[i]); + if (getenv_func != nullptr) { + break; + } } } result = getenv_func(name); @@ -58,20 +59,8 @@ static const char* gpr_getenv_silent(const char* name, char** dst) { result = secure_getenv(name); #else result = getenv(name); - insecure_func_used = "getenv"; #endif - *dst = result == nullptr ? result : gpr_strdup(result); - return insecure_func_used; -} - -char* gpr_getenv(const char* name) { - char* result = nullptr; - const char* insecure_func_used = gpr_getenv_silent(name, &result); - if (insecure_func_used != nullptr) { - gpr_log(GPR_DEBUG, "Warning: insecure environment read function '%s' used", - insecure_func_used); - } - return result; + return result == nullptr ? result : gpr_strdup(result); } void gpr_setenv(const char* name, const char* value) { diff --git a/src/core/lib/gpr/env_posix.cc b/src/core/lib/gpr/env_posix.cc index 30ddc50f682..232095b4e22 100644 --- a/src/core/lib/gpr/env_posix.cc +++ b/src/core/lib/gpr/env_posix.cc @@ -29,11 +29,6 @@ #include #include "src/core/lib/gpr/string.h" -const char* gpr_getenv_silent(const char* name, char** dst) { - *dst = gpr_getenv(name); - return nullptr; -} - char* gpr_getenv(const char* name) { char* result = getenv(name); return result == nullptr ? result : gpr_strdup(result); From 029ee95f1ac3d66bb225e1c5aae92fabb50f1909 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 18 Jul 2019 22:37:50 -0700 Subject: [PATCH 0932/1555] Resolve a race when background poller outlives executor --- src/core/lib/iomgr/combiner.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/lib/iomgr/combiner.cc b/src/core/lib/iomgr/combiner.cc index 4fc4a9dccf4..9a6290f29a8 100644 --- a/src/core/lib/iomgr/combiner.cc +++ b/src/core/lib/iomgr/combiner.cc @@ -233,11 +233,11 @@ bool grpc_combiner_continue_exec_ctx() { // offload only if all the following conditions are true: // 1. the combiner is contended and has more than one closure to execute // 2. the current execution context needs to finish as soon as possible - // 3. the DEFAULT executor is threaded - // 4. the current thread is not a worker for any background poller + // 3. the current thread is not a worker for any background poller + // 4. the DEFAULT executor is threaded if (contended && grpc_core::ExecCtx::Get()->IsReadyToFinish() && - grpc_core::Executor::IsThreadedDefault() && - !grpc_iomgr_is_any_background_poller_thread()) { + !grpc_iomgr_is_any_background_poller_thread() && + grpc_core::Executor::IsThreadedDefault()) { GPR_TIMER_MARK("offload_from_finished_exec_ctx", 0); // this execution context wants to move on: schedule remaining work to be // picked up on the executor From c7673983ac5932aa954d4dd141a20cfc80e5b7d6 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 18 Jul 2019 11:34:35 +0200 Subject: [PATCH 0933/1555] get rid of unused Version.csproj.include --- src/csharp/Grpc.Core/Version.csproj.include | 7 ------- src/csharp/build/dependencies.props | 2 +- templates/src/csharp/build/dependencies.props.template | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) delete mode 100755 src/csharp/Grpc.Core/Version.csproj.include diff --git a/src/csharp/Grpc.Core/Version.csproj.include b/src/csharp/Grpc.Core/Version.csproj.include deleted file mode 100755 index e24afdad605..00000000000 --- a/src/csharp/Grpc.Core/Version.csproj.include +++ /dev/null @@ -1,7 +0,0 @@ - - - - 1.19.1 - 3.8.0 - - diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index d9bf90ff007..a91b5e19414 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -2,6 +2,6 @@ 1.23.0-dev - 3.7.0 + 3.8.0 diff --git a/templates/src/csharp/build/dependencies.props.template b/templates/src/csharp/build/dependencies.props.template index 0ed9018a49e..88470df2898 100755 --- a/templates/src/csharp/build/dependencies.props.template +++ b/templates/src/csharp/build/dependencies.props.template @@ -4,6 +4,6 @@ ${settings.csharp_version} - 3.7.0 + 3.8.0 From c6bc2b1875d283d237b64a7ec9b153fd1a98b845 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 19 Jul 2019 10:23:22 -0700 Subject: [PATCH 0934/1555] Add threadpool benchmark and build files --- CMakeLists.txt | 48 +++ Makefile | 49 +++ build.yaml | 21 ++ test/cpp/microbenchmarks/BUILD | 8 + test/cpp/microbenchmarks/bm_threadpool.cc | 343 ++++++++++++++++++ .../generated/sources_and_headers.json | 21 ++ tools/run_tests/generated/tests.json | 22 ++ 7 files changed, 512 insertions(+) create mode 100644 test/cpp/microbenchmarks/bm_threadpool.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 726638aa004..ed6af47010b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -594,6 +594,9 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx bm_pollset) endif() if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) +add_dependencies(buildtests_cxx bm_threadpool) +endif() +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx bm_timer) endif() add_dependencies(buildtests_cxx byte_stream_test) @@ -12414,6 +12417,51 @@ target_link_libraries(bm_pollset ) +endif() +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) +if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) + +add_executable(bm_threadpool + test/cpp/microbenchmarks/bm_threadpool.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(bm_threadpool + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(bm_threadpool + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_benchmark + ${_gRPC_BENCHMARK_LIBRARIES} + grpc++_test_util_unsecure + grpc_test_util_unsecure + grpc++_unsecure + grpc_unsecure + gpr + grpc++_test_config + ${_gRPC_GFLAGS_LIBRARIES} +) + + endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index 4ca15ac0f47..10c3eafddfa 100644 --- a/Makefile +++ b/Makefile @@ -1180,6 +1180,7 @@ bm_fullstack_trickle: $(BINDIR)/$(CONFIG)/bm_fullstack_trickle bm_fullstack_unary_ping_pong: $(BINDIR)/$(CONFIG)/bm_fullstack_unary_ping_pong bm_metadata: $(BINDIR)/$(CONFIG)/bm_metadata bm_pollset: $(BINDIR)/$(CONFIG)/bm_pollset +bm_threadpool: $(BINDIR)/$(CONFIG)/bm_threadpool bm_timer: $(BINDIR)/$(CONFIG)/bm_timer byte_stream_test: $(BINDIR)/$(CONFIG)/byte_stream_test channel_arguments_test: $(BINDIR)/$(CONFIG)/channel_arguments_test @@ -1658,6 +1659,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_fullstack_unary_ping_pong \ $(BINDIR)/$(CONFIG)/bm_metadata \ $(BINDIR)/$(CONFIG)/bm_pollset \ + $(BINDIR)/$(CONFIG)/bm_threadpool \ $(BINDIR)/$(CONFIG)/bm_timer \ $(BINDIR)/$(CONFIG)/byte_stream_test \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ @@ -1824,6 +1826,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_fullstack_unary_ping_pong \ $(BINDIR)/$(CONFIG)/bm_metadata \ $(BINDIR)/$(CONFIG)/bm_pollset \ + $(BINDIR)/$(CONFIG)/bm_threadpool \ $(BINDIR)/$(CONFIG)/bm_timer \ $(BINDIR)/$(CONFIG)/byte_stream_test \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ @@ -2295,6 +2298,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/bm_metadata || ( echo test bm_metadata failed ; exit 1 ) $(E) "[RUN] Testing bm_pollset" $(Q) $(BINDIR)/$(CONFIG)/bm_pollset || ( echo test bm_pollset failed ; exit 1 ) + $(E) "[RUN] Testing bm_threadpool" + $(Q) $(BINDIR)/$(CONFIG)/bm_threadpool || ( echo test bm_threadpool failed ; exit 1 ) $(E) "[RUN] Testing bm_timer" $(Q) $(BINDIR)/$(CONFIG)/bm_timer || ( echo test bm_timer failed ; exit 1 ) $(E) "[RUN] Testing byte_stream_test" @@ -15415,6 +15420,50 @@ endif endif +BM_THREADPOOL_SRC = \ + test/cpp/microbenchmarks/bm_threadpool.cc \ + +BM_THREADPOOL_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BM_THREADPOOL_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/bm_threadpool: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/bm_threadpool: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/bm_threadpool: $(PROTOBUF_DEP) $(BM_THREADPOOL_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(BM_THREADPOOL_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/bm_threadpool + +endif + +endif + +$(BM_THREADPOOL_OBJS): CPPFLAGS += -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX +$(OBJDIR)/$(CONFIG)/test/cpp/microbenchmarks/bm_threadpool.o: $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a + +deps_bm_threadpool: $(BM_THREADPOOL_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(BM_THREADPOOL_OBJS:.o=.dep) +endif +endif + + BM_TIMER_SRC = \ test/cpp/microbenchmarks/bm_timer.cc \ diff --git a/build.yaml b/build.yaml index 6d69c419b71..50689b66ff8 100644 --- a/build.yaml +++ b/build.yaml @@ -4449,6 +4449,27 @@ targets: - mac - linux - posix +- name: bm_threadpool + build: test + language: c++ + src: + - test/cpp/microbenchmarks/bm_threadpool.cc + deps: + - grpc_benchmark + - benchmark + - grpc++_test_util_unsecure + - grpc_test_util_unsecure + - grpc++_unsecure + - grpc_unsecure + - gpr + - grpc++_test_config + benchmark: true + defaults: benchmark + platforms: + - mac + - linux + - posix + uses_polling: false - name: bm_timer build: test language: c++ diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD index d9424f24f16..b8e9b14d4b4 100644 --- a/test/cpp/microbenchmarks/BUILD +++ b/test/cpp/microbenchmarks/BUILD @@ -222,6 +222,14 @@ grpc_cc_binary( deps = [":helpers"], ) +grpc_cc_binary( + name = "bm_threadpool", + testonly = 1, + srcs = ["bm_threadpool.cc"], + tags = ["no_windows"], + deps = [":helpers"], +) + grpc_cc_library( name = "bm_callback_test_service_impl", testonly = 1, diff --git a/test/cpp/microbenchmarks/bm_threadpool.cc b/test/cpp/microbenchmarks/bm_threadpool.cc new file mode 100644 index 00000000000..07b99146064 --- /dev/null +++ b/test/cpp/microbenchmarks/bm_threadpool.cc @@ -0,0 +1,343 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +#include +#include + +#include "src/core/lib/iomgr/executor/threadpool.h" +#include "test/cpp/microbenchmarks/helpers.h" +#include "test/cpp/util/test_config.h" + +namespace grpc { +namespace testing { + +// This helper class allows a thread to block for a pre-specified number of +// actions. BlockingCounter has an initial non-negative count on initialization +// Each call to DecrementCount will decrease the count by 1. When making a call +// to Wait, if the count is greater than 0, the thread will be block, until +// the count reaches 0. +class BlockingCounter { + public: + BlockingCounter(int count) : count_(count) {} + void DecrementCount() { + std::lock_guard l(mu_); + count_--; + if (count_ == 0) cv_.notify_one(); + } + + void Wait() { + std::unique_lock l(mu_); + while (count_ > 0) { + cv_.wait(l); + } + } + private: + int count_; + std::mutex mu_; + std::condition_variable cv_; +}; + +// This is a functor/closure class for threadpool microbenchmark. +// This functor (closure) class will add another functor into pool if the +// number passed in (num_add) is greater than 0. Otherwise, it will decrement +// the counter to indicate that task is finished. This functor will suicide at +// the end, therefore, no need for caller to do clean-ups. +class AddAnotherFunctor : public grpc_experimental_completion_queue_functor { + public: + AddAnotherFunctor(grpc_core::ThreadPool* pool, BlockingCounter* counter, + int num_add) + : pool_(pool), counter_(counter), num_add_(num_add) { + functor_run = &AddAnotherFunctor::Run; + internal_next = this; + internal_success = 0; + } + ~AddAnotherFunctor() {} + // When the functor gets to run in thread pool, it will take itself as first + // argument and internal_success as second one. + static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { + auto* callback = static_cast(cb); + if (--callback->num_add_ > 0) { + callback->pool_->Add(new AddAnotherFunctor( + callback->pool_, callback->counter_, callback->num_add_)); + } else { + callback->counter_->DecrementCount(); + } + // Suicide + delete callback; + } + + private: + grpc_core::ThreadPool* pool_; + BlockingCounter* counter_; + int num_add_; +}; + +void ThreadPoolAddAnotherHelper(benchmark::State& state, + int concurrent_functor) { + const int num_threads = state.range(1); + const int num_iterations = state.range(0); + // number of adds done by each closure + const int num_add = num_iterations / concurrent_functor; + grpc_core::ThreadPool pool(num_threads); + while (state.KeepRunningBatch(num_iterations)) { + BlockingCounter counter(concurrent_functor); + for (int i = 0; i < concurrent_functor; ++i) { + pool.Add(new AddAnotherFunctor(&pool, &counter, num_add)); + } + counter.Wait(); + } + state.SetItemsProcessed(state.iterations()); +} + +static void BM_ThreadPool1AddAnother(benchmark::State& state) { + ThreadPoolAddAnotherHelper(state, 1); +} +// first pair is range for batch_size, second pair is range for thread pool size +BENCHMARK(BM_ThreadPool1AddAnother)->RangePair(524288, 524288, 1, 1024); + +static void BM_ThreadPool4AddAnother(benchmark::State& state) { + ThreadPoolAddAnotherHelper(state, 4); +} +BENCHMARK(BM_ThreadPool4AddAnother)->RangePair(524288, 524288, 1, 1024); + +static void BM_ThreadPool8AddAnother(benchmark::State& state) { + ThreadPoolAddAnotherHelper(state, 8); +} +BENCHMARK(BM_ThreadPool8AddAnother)->RangePair(524288, 524288, 1, 1024); + +static void BM_ThreadPool16AddAnother(benchmark::State& state) { + ThreadPoolAddAnotherHelper(state, 16); +} +BENCHMARK(BM_ThreadPool16AddAnother)->RangePair(524288, 524288, 1, 1024); + +static void BM_ThreadPool32AddAnother(benchmark::State& state) { + ThreadPoolAddAnotherHelper(state, 32); +} +BENCHMARK(BM_ThreadPool32AddAnother)->RangePair(524288, 524288, 1, 1024); + +static void BM_ThreadPool64AddAnother(benchmark::State& state) { + ThreadPoolAddAnotherHelper(state, 64); +} +BENCHMARK(BM_ThreadPool64AddAnother)->RangePair(524288, 524288, 1, 1024); + +static void BM_ThreadPool128AddAnother(benchmark::State& state) { + ThreadPoolAddAnotherHelper(state, 128); +} +BENCHMARK(BM_ThreadPool128AddAnother)->RangePair(524288, 524288, 1, 1024); + +static void BM_ThreadPool512AddAnother(benchmark::State& state) { + ThreadPoolAddAnotherHelper(state, 512); +} +BENCHMARK(BM_ThreadPool512AddAnother)->RangePair(524288, 524288, 1, 1024); + +static void BM_ThreadPool2048AddAnother(benchmark::State& state) { + ThreadPoolAddAnotherHelper(state, 2048); +} +BENCHMARK(BM_ThreadPool2048AddAnother)->RangePair(524288, 524288, 1, 1024); + + + +// A functor class that will delete self on end of running. +class SuicideFunctorForAdd + : public grpc_experimental_completion_queue_functor { + public: + SuicideFunctorForAdd(BlockingCounter* counter) : counter_(counter) { + functor_run = &SuicideFunctorForAdd::Run; + internal_next = this; + internal_success = 0; + } + ~SuicideFunctorForAdd() {} + static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { + // On running, the first argument would be itself. + auto* callback = static_cast(cb); + callback->counter_->DecrementCount(); + delete callback; + } + + private: + BlockingCounter* counter_; +}; + + +// Performs the scenario of external thread(s) adding closures into pool. +static void BM_ThreadPoolExternalAdd(benchmark::State& state) { + static grpc_core::ThreadPool* external_add_pool = nullptr; + // Setup for each run of test + if (state.thread_index == 0) { + const int num_threads = state.range(1); + external_add_pool = new grpc_core::ThreadPool(num_threads); + } +const int num_iterations = state.range(0); + while (state.KeepRunningBatch(num_iterations)) { + BlockingCounter counter(num_iterations); + for (int i = 0; i < num_iterations; ++i) { + external_add_pool->Add(new SuicideFunctorForAdd(&counter)); + } + counter.Wait(); + } + state.SetItemsProcessed(num_iterations); + + // Teardown at the end of each test run + if (state.thread_index == 0) { + Delete(external_add_pool); + } +} +BENCHMARK(BM_ThreadPoolExternalAdd) + ->RangePair(524288, 524288, 1, 1024) // ThreadPool size + ->ThreadRange(1, 256); // Concurrent external thread(s) up to 256 + +// Functor (closure) that adds itself into pool repeatedly. By adding self, the +// overhead would be low and can measure the time of add more accurately. +class AddSelfFunctor : public grpc_experimental_completion_queue_functor { + public: + AddSelfFunctor(grpc_core::ThreadPool* pool, BlockingCounter* counter, + int num_add) + : pool_(pool), counter_(counter), num_add_(num_add) { + functor_run = &AddSelfFunctor::Run; + internal_next = this; + internal_success = 0; + } + ~AddSelfFunctor() {} + // When the functor gets to run in thread pool, it will take internal_next + // as first argument and internal_success as second one. Therefore, the + // first argument here would be the closure itself. + static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { + auto* callback = static_cast(cb); + if (--callback->num_add_ > 0) { + callback->pool_->Add(cb); + } else { + callback->counter_->DecrementCount(); + // Suicide + delete callback; + } + } + + private: + grpc_core::ThreadPool* pool_; + BlockingCounter* counter_; + int num_add_; +}; + +static void BM_ThreadPoolAddSelf(benchmark::State& state) { + const int num_threads = state.range(0); + const int kNumIteration = 524288; + int concurrent_functor = num_threads; + int num_add = kNumIteration / concurrent_functor; + grpc_core::ThreadPool pool(num_threads); + while (state.KeepRunningBatch(kNumIteration)) { + BlockingCounter counter(concurrent_functor); + for (int i = 0; i < concurrent_functor; ++i) { + pool.Add(new AddSelfFunctor(&pool, &counter, num_add)); + } + counter.Wait(); + } + state.SetItemsProcessed(state.iterations()); +} + +BENCHMARK(BM_ThreadPoolAddSelf)->Range(1, 1024); + +#if defined(__GNUC__) && !defined(SWIG) +#if defined(__i386__) || defined(__x86_64__) +#define ABSL_CACHELINE_SIZE 64 +#elif defined(__powerpc64__) +#define ABSL_CACHELINE_SIZE 128 +#elif defined(__aarch64__) +#define ABSL_CACHELINE_SIZE 64 +#elif defined(__arm__) +#if defined(__ARM_ARCH_5T__) +#define ABSL_CACHELINE_SIZE 32 +#elif defined(__ARM_ARCH_7A__) +#define ABSL_CACHELINE_SIZE 64 +#endif +#endif +#ifndef ABSL_CACHELINE_SIZE +#define ABSL_CACHELINE_SIZE 64 +#endif +#endif + +// A functor (closure) that simulates closures with small but non-trivial amount +// of work. +class ShortWorkFunctorForAdd + : public grpc_experimental_completion_queue_functor { + public: + BlockingCounter* counter_; + + ShortWorkFunctorForAdd() { + functor_run = &ShortWorkFunctorForAdd::Run; + internal_next = this; + internal_success = 0; + val_ = 0; + } + ~ShortWorkFunctorForAdd() {} + static void Run(grpc_experimental_completion_queue_functor *cb, int ok) { + auto* callback = static_cast(cb); + for (int i = 0; i < 1000; ++i) { + callback->val_++; + } + callback->counter_->DecrementCount(); + } + private: + char pad[ABSL_CACHELINE_SIZE]; + volatile int val_; +}; + +// Simulates workloads where many short running callbacks are added to the +// threadpool. The callbacks are not enough to keep all the workers busy +// continuously so the number of workers running changes overtime. +// +// In effect this tests how well the threadpool avoids spurious wakeups. +static void BM_SpikyLoad(benchmark::State& state) { + const int num_threads = state.range(0); + + const int kNumSpikes = 1000; + const int batch_size = 3 * num_threads; + std::vector work_vector(batch_size); + while (state.KeepRunningBatch(kNumSpikes * batch_size)) { + grpc_core::ThreadPool pool(num_threads); + for (int i = 0; i != kNumSpikes; ++i) { + BlockingCounter counter(batch_size); + for (auto& w : work_vector) { + w.counter_ = &counter; + pool.Add(&w); + } + counter.Wait(); + } + } + state.SetItemsProcessed(state.iterations() * batch_size); +} +BENCHMARK(BM_SpikyLoad)->Arg(1)->Arg(2)->Arg(4)->Arg(8)->Arg(16); + +} // namespace testing +} // namespace grpc + +// Some distros have RunSpecifiedBenchmarks under the benchmark namespace, +// and others do not. This allows us to support both modes. +namespace benchmark { +void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } +} // namespace benchmark + +int main(int argc, char* argv[]) { + LibraryInitializer libInit; + ::benchmark::Initialize(&argc, argv); + ::grpc::testing::InitTest(&argc, &argv, false); + benchmark::RunTheBenchmarksNamespaced(); + return 0; +} diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index b2feea44d53..524709588f0 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -3140,6 +3140,27 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "benchmark", + "gpr", + "grpc++_test_config", + "grpc++_test_util_unsecure", + "grpc++_unsecure", + "grpc_benchmark", + "grpc_test_util_unsecure", + "grpc_unsecure" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "bm_threadpool", + "src": [ + "test/cpp/microbenchmarks/bm_threadpool.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "benchmark", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index d4a19741729..8f1b0edaff2 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -3903,6 +3903,28 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": true, + "ci_platforms": [ + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": false, + "language": "c++", + "name": "bm_threadpool", + "platforms": [ + "linux", + "mac", + "posix" + ], + "uses_polling": false + }, { "args": [], "benchmark": true, From 91d865fa54b1a1105d50948426f27c5ef30e9616 Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Wed, 17 Jul 2019 17:20:27 -0700 Subject: [PATCH 0935/1555] Create new build config for ASAN on Mac OS Workaround ASAN build issues on Mac OS. Disable LSAN as it's not supported by the version of clang that ships with Mac OS. --- tools/bazel.rc | 24 ++++++++++++++++--- .../internal_ci/macos/grpc_cfstream_asan.cfg | 2 +- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/tools/bazel.rc b/tools/bazel.rc index 411457a7cf5..e2d49355d8f 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -13,9 +13,6 @@ build:opt --copt=-Wframe-larger-than=16384 build:dbg --compilation_mode=dbg build:asan --strip=never -# Workaround for https://github.com/bazelbuild/bazel/issues/6932 -build:asan --copt -Wno-macro-redefined -build:asan --copt -D_FORTIFY_SOURCE=0 build:asan --copt=-fsanitize=address build:asan --copt=-O0 build:asan --copt=-fno-omit-frame-pointer @@ -25,6 +22,27 @@ build:asan --linkopt=-fsanitize=address build:asan --action_env=ASAN_OPTIONS=detect_leaks=1:color=always build:asan --action_env=LSAN_OPTIONS=suppressions=test/core/util/lsan_suppressions.txt:report_objects=1 +# We have a separate ASAN config for Mac OS to workaround a couple of bugs: +# 1. https://github.com/bazelbuild/bazel/issues/6932 +# _FORTIFY_SOURCE=1 is enabled by default on Mac OS, which breaks ASAN. +# We workaround it by setting _FORTIFY_SOURCE=0 and ignoring macro redefined +# warnings. +# 2. https://github.com/google/sanitizers/issues/1026 +# LSAN is not supported by the version of Clang that ships with Mac OS, so +# we disable it. +build:asan_macos --strip=never +build:asan_macos --copt=-fsanitize=address +build:asan_macos --copt -Wno-macro-redefined +build:asan_macos --copt -D_FORTIFY_SOURCE=0 +build:asan_macos --copt=-fsanitize=address +build:asan_macos --copt=-O0 +build:asan_macos --copt=-fno-omit-frame-pointer +build:asan_macos --copt=-DGPR_NO_DIRECT_SYSCALLS +build:asan_macos --copt=-DADDRESS_SANITIZER # used by absl +build:asan_macos --linkopt=-fsanitize=address +build:asan_macos --action_env=ASAN_OPTIONS=detect_leaks=0 + + build:msan --strip=never build:msan --copt=-fsanitize=memory build:msan --copt=-O0 diff --git a/tools/internal_ci/macos/grpc_cfstream_asan.cfg b/tools/internal_ci/macos/grpc_cfstream_asan.cfg index ceff78a4399..ac8a8b63ff6 100644 --- a/tools/internal_ci/macos/grpc_cfstream_asan.cfg +++ b/tools/internal_ci/macos/grpc_cfstream_asan.cfg @@ -18,6 +18,6 @@ build_file: "grpc/tools/internal_ci/macos/grpc_run_bazel_tests.sh" env_vars { key: "RUN_TESTS_FLAGS" - value: "--config=asan" + value: "--config=asan_macos" } From f50301fde8bbccb87bc1ae2c1a85bf48c268e9ba Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 19 Jul 2019 10:36:10 -0700 Subject: [PATCH 0936/1555] Add LIFO and Chunked List --- src/core/lib/iomgr/executor/mpmcqueue.cc | 120 ++++++++++++++++++----- src/core/lib/iomgr/executor/mpmcqueue.h | 72 ++++++++++---- test/core/iomgr/mpmcqueue_test.cc | 45 +++++++++ 3 files changed, 193 insertions(+), 44 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index 72c318e2bb1..7ef5cf40e14 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -26,18 +26,15 @@ DebugOnlyTraceFlag grpc_thread_pool_trace(false, "thread_pool"); inline void* InfLenFIFOQueue::PopFront() { // Caller should already check queue is not empty and has already held the - // mutex. This function will only do the job of removal. + // mutex. This function will assume that there is at least one element in the + // queue (aka queue_head_ content is valid). void* result = queue_head_->content; - Node* head_to_remove = queue_head_; - queue_head_ = queue_head_->next; - count_.Store(count_.Load(MemoryOrder::RELAXED) - 1, MemoryOrder::RELAXED); + // Updates Stats when trace flag turned on. if (GRPC_TRACE_FLAG_ENABLED(grpc_thread_pool_trace)) { - gpr_timespec wait_time = - gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), head_to_remove->insert_time); - - // Updates Stats info + gpr_timespec wait_time = gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), + queue_head_->insert_time); stats_.num_completed++; stats_.total_queue_time = gpr_time_add(stats_.total_queue_time, wait_time); stats_.max_queue_time = gpr_time_max( @@ -58,44 +55,87 @@ inline void* InfLenFIFOQueue::PopFront() { gpr_timespec_to_micros(stats_.busy_queue_time)); } - Delete(head_to_remove); + queue_head_ = queue_head_->next; // Signal waiting thread - if (count_.Load(MemoryOrder::RELAXED) > 0 && num_waiters_ > 0) { - wait_nonempty_.Signal(); + if (count_.Load(MemoryOrder::RELAXED) > 0) { + TopWaiter()->cv.Signal(); } return result; } +InfLenFIFOQueue::Node* InfLenFIFOQueue::AllocateNodes(int num) { + Node* new_chunk = static_cast(gpr_zalloc(sizeof(Node) * num)); + new_chunk[0].next = &new_chunk[1]; + new_chunk[num - 1].prev = &new_chunk[num - 2]; + for (int i = 1; i < num - 1; ++i) { + new_chunk[i].prev = &new_chunk[i - 1]; + new_chunk[i].next = &new_chunk[i + 1]; + } + return new_chunk; +} + +InfLenFIFOQueue::InfLenFIFOQueue() { + delete_list_size_ = 1024; + delete_list_ = + static_cast(gpr_zalloc(sizeof(Node*) * delete_list_size_)); + + Node* new_chunk = AllocateNodes(1024); + delete_list_[delete_list_count_++] = new_chunk; + queue_head_ = queue_tail_ = new_chunk; + new_chunk[0].prev = &new_chunk[1023]; + new_chunk[1023].next = &new_chunk[0]; + + waiters_.next = &waiters_; + waiters_.prev = &waiters_; +} + InfLenFIFOQueue::~InfLenFIFOQueue() { GPR_ASSERT(count_.Load(MemoryOrder::RELAXED) == 0); - GPR_ASSERT(num_waiters_ == 0); + for (size_t i = 0; i < delete_list_count_; ++i) { + gpr_free(delete_list_[i]); + } + gpr_free(delete_list_); } void InfLenFIFOQueue::Put(void* elem) { MutexLock l(&mu_); - Node* new_node = New(elem); - if (count_.Load(MemoryOrder::RELAXED) == 0) { - if (GRPC_TRACE_FLAG_ENABLED(grpc_thread_pool_trace)) { - busy_time = gpr_now(GPR_CLOCK_MONOTONIC); + int curr_count = count_.Load(MemoryOrder::RELAXED); + + if (queue_tail_ == queue_head_ && curr_count!= 0) { + // List is full. Expands list to double size by inserting new chunk of nodes + Node* new_chunk = AllocateNodes(curr_count); + delete_list_[delete_list_count_++] = new_chunk; + // Expands delete list on full. + if (delete_list_count_ == delete_list_size_) { + delete_list_size_ = delete_list_size_ * 2; + delete_list_ = static_cast( + gpr_realloc(delete_list_, sizeof(Node*) * delete_list_size_)); } - queue_head_ = queue_tail_ = new_node; - } else { - queue_tail_->next = new_node; - queue_tail_ = queue_tail_->next; + new_chunk[0].prev = queue_tail_->prev; + new_chunk[curr_count - 1].next = queue_head_; + queue_tail_->prev->next = new_chunk; + queue_head_->prev = &new_chunk[curr_count - 1]; + queue_tail_ = new_chunk; } - count_.Store(count_.Load(MemoryOrder::RELAXED) + 1, MemoryOrder::RELAXED); + queue_tail_->content = static_cast(elem); + // Updates Stats info if (GRPC_TRACE_FLAG_ENABLED(grpc_thread_pool_trace)) { stats_.num_started++; gpr_log(GPR_INFO, "[InfLenFIFOQueue Put] num_started: %" PRIu64, stats_.num_started); + if (curr_count == 0) { + busy_time = gpr_now(GPR_CLOCK_MONOTONIC); + } + queue_tail_->insert_time = gpr_now(GPR_CLOCK_MONOTONIC); } - if (num_waiters_ > 0) { - wait_nonempty_.Signal(); - } + count_.Store(curr_count + 1, MemoryOrder::RELAXED); + queue_tail_ = queue_tail_->next; + + TopWaiter()->cv.Signal(); } void* InfLenFIFOQueue::Get(gpr_timespec* wait_time) { @@ -108,11 +148,12 @@ void* InfLenFIFOQueue::Get(gpr_timespec* wait_time) { start_time = gpr_now(GPR_CLOCK_MONOTONIC); } - num_waiters_++; + Waiter self; + PushWaiter(&self); do { - wait_nonempty_.Wait(&mu_); + self.cv.Wait(&mu_); } while (count_.Load(MemoryOrder::RELAXED) == 0); - num_waiters_--; + RemoveWaiter(&self); if (GRPC_TRACE_FLAG_ENABLED(grpc_thread_pool_trace) && wait_time != nullptr) { *wait_time = gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), start_time); @@ -122,4 +163,29 @@ void* InfLenFIFOQueue::Get(gpr_timespec* wait_time) { return PopFront(); } +size_t InfLenFIFOQueue::num_node() { + size_t num = 1024; + for (size_t i = 1; i < delete_list_count_; ++i) { + num = num* 2; + } + return num; +} + +void InfLenFIFOQueue::PushWaiter(Waiter* waiter) { + waiter->next = waiters_.next; + waiter->prev = &waiters_; + waiter->next->prev = waiter; + waiter->prev->next = waiter; +} + +void InfLenFIFOQueue::RemoveWaiter(Waiter* waiter) { + GPR_DEBUG_ASSERT(waiter != &waiters_); + waiter->next->prev = waiter->prev; + waiter->prev->next = waiter->next; +} + +InfLenFIFOQueue::Waiter* InfLenFIFOQueue::TopWaiter() { + return waiters_.next; +} + } // namespace grpc_core diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index c6102b3add0..05e5a0a7579 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -54,7 +54,7 @@ class MPMCQueueInterface { class InfLenFIFOQueue : public MPMCQueueInterface { public: // Creates a new MPMC Queue. The queue created will have infinite length. - InfLenFIFOQueue() {} + InfLenFIFOQueue(); // Releases all resources held by the queue. The queue must be empty, and no // one waits on conditional variables. @@ -66,8 +66,8 @@ class InfLenFIFOQueue : public MPMCQueueInterface { // Removes the oldest element from the queue and returns it. // This routine will cause the thread to block if queue is currently empty. - // Argument wait_time should be passed in when turning on the trace flag - // grpc_thread_pool_trace (for collecting stats info purpose.) + // Argument wait_time should be passed in when trace flag turning on (for + // collecting stats info purpose.) void* Get(gpr_timespec* wait_time = nullptr); // Returns number of elements in queue currently. @@ -75,24 +75,30 @@ class InfLenFIFOQueue : public MPMCQueueInterface { // quickly. int count() const { return count_.Load(MemoryOrder::RELAXED); } + struct Node { + Node* next; // Linking + Node* prev; + void* content; // Points to actual element + gpr_timespec insert_time; // Time for stats + + Node() { + next = prev = nullptr; + content = nullptr; + } + }; + + // For test purpose only. Returns number of nodes allocated in queue. + // All allocated nodes will not be free until destruction of queue. + size_t num_node(); + private: // For Internal Use Only. // Removes the oldest element from the queue and returns it. This routine // will NOT check whether queue is empty, and it will NOT acquire mutex. - // Caller should do the check and acquire mutex before callling. + // Caller MUST check that queue is not empty and must acquire mutex before + // callling. void* PopFront(); - struct Node { - Node* next; // Linking - void* content; // Points to actual element - gpr_timespec insert_time; // Time for stats - - Node(void* c) : content(c) { - next = nullptr; - insert_time = gpr_now(GPR_CLOCK_MONOTONIC); - } - }; - // Stats of queue. This will only be collect when debug trace mode is on. // All printed stats info will have time measurement in microsecond. struct Stats { @@ -115,15 +121,47 @@ class InfLenFIFOQueue : public MPMCQueueInterface { } }; + // Node for waiting thread queue. Stands for one waiting thread, should have + // exact one thread waiting on its CondVar. + // Using a doubly linked list for waiting thread queue to wake up waiting + // threads in LIFO order to reduce cache misses. + struct Waiter { + CondVar cv; + Waiter* next; + Waiter* prev; + }; + + // Pushs waiter to the front of queue, require caller held mutex + void PushWaiter(Waiter* waiter); + + // Removes waiter from queue, require caller held mutex + void RemoveWaiter(Waiter* waiter); + + // Returns pointer to the waiter that should be waken up next, should be the + // last added waiter. + Waiter* TopWaiter(); + Mutex mu_; // Protecting lock - CondVar wait_nonempty_; // Wait on empty queue on get - int num_waiters_ = 0; // Number of waiters + Waiter waiters_; // Head of waiting thread queue + + Node** delete_list_ = nullptr; // Keeps track of all allocated array entries + // for deleting on destruction + size_t delete_list_count_ = 0; // Number of entries in list + size_t delete_list_size_ = 0; // Size of the list. List will be expanded to + // double size on full Node* queue_head_ = nullptr; // Head of the queue, remove position Node* queue_tail_ = nullptr; // End of queue, insert position Atomic count_{0}; // Number of elements in queue + Stats stats_; // Stats info gpr_timespec busy_time; // Start time of busy queue + + // Internal Helper. + // Allocates an array of nodes of size "num", links all nodes together except + // the first node's prev and last node's next. They should be set by caller + // manually afterward. + Node* AllocateNodes(int num); }; } // namespace grpc_core diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index a301832f608..68d1da65405 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -119,6 +119,50 @@ static void test_FIFO(void) { } } +static void test_space_efficiency(void) { + gpr_log(GPR_INFO, "test_space_efficiency"); + grpc_core::InfLenFIFOQueue queue; + for (int i = 0; i < 1024; ++i) { + queue.Put(static_cast(grpc_core::New(i))); + } + GPR_ASSERT(queue.num_node() == 1024); + for (int i = 0; i < 1024; ++i) { + WorkItem* item = static_cast(queue.Get()); + queue.Put(item); + } + GPR_ASSERT(queue.num_node() == 1024); + for (int i = 0; i < 1024; ++i) { + WorkItem* item = static_cast(queue.Get()); + grpc_core::Delete(item); + } + GPR_ASSERT(queue.num_node() == 1024); + GPR_ASSERT(queue.count() == 0); + // queue empty now + for (int i = 0; i < 4000; ++i) { + queue.Put(static_cast(grpc_core::New(i))); + } + GPR_ASSERT(queue.count() == 4000); + GPR_ASSERT(queue.num_node() == 4096); + for (int i = 0; i < 2000; ++i) { + WorkItem* item = static_cast(queue.Get()); + grpc_core::Delete(item); + } + GPR_ASSERT(queue.count() == 2000); + GPR_ASSERT(queue.num_node() == 4096); + for (int i = 0; i < 1000; ++i) { + queue.Put(static_cast(grpc_core::New(i))); + } + GPR_ASSERT(queue.count() == 3000); + GPR_ASSERT(queue.num_node() == 4096); + for (int i = 0; i < 3000; ++i) { + WorkItem* item = static_cast(queue.Get()); + grpc_core::Delete(item); + } + GPR_ASSERT(queue.count() == 0); + GPR_ASSERT(queue.num_node() == 4096); + gpr_log(GPR_DEBUG, "Done."); +} + static void test_many_thread(void) { gpr_log(GPR_INFO, "test_many_thread"); const int num_producer_threads = 10; @@ -172,6 +216,7 @@ int main(int argc, char** argv) { grpc::testing::TestEnvironment env(argc, argv); grpc_init(); test_FIFO(); + test_space_efficiency(); test_many_thread(); grpc_shutdown(); return 0; From 85314b3fcc4a71ac25911deaac03a1540514e5f7 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 19 Jul 2019 10:49:35 -0700 Subject: [PATCH 0937/1555] Re-format --- test/cpp/microbenchmarks/bm_threadpool.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_threadpool.cc b/test/cpp/microbenchmarks/bm_threadpool.cc index 07b99146064..468b6b53a91 100644 --- a/test/cpp/microbenchmarks/bm_threadpool.cc +++ b/test/cpp/microbenchmarks/bm_threadpool.cc @@ -49,6 +49,7 @@ class BlockingCounter { cv_.wait(l); } } + private: int count_; std::mutex mu_; @@ -153,11 +154,8 @@ static void BM_ThreadPool2048AddAnother(benchmark::State& state) { } BENCHMARK(BM_ThreadPool2048AddAnother)->RangePair(524288, 524288, 1, 1024); - - // A functor class that will delete self on end of running. -class SuicideFunctorForAdd - : public grpc_experimental_completion_queue_functor { +class SuicideFunctorForAdd : public grpc_experimental_completion_queue_functor { public: SuicideFunctorForAdd(BlockingCounter* counter) : counter_(counter) { functor_run = &SuicideFunctorForAdd::Run; @@ -176,7 +174,6 @@ class SuicideFunctorForAdd BlockingCounter* counter_; }; - // Performs the scenario of external thread(s) adding closures into pool. static void BM_ThreadPoolExternalAdd(benchmark::State& state) { static grpc_core::ThreadPool* external_add_pool = nullptr; @@ -185,7 +182,7 @@ static void BM_ThreadPoolExternalAdd(benchmark::State& state) { const int num_threads = state.range(1); external_add_pool = new grpc_core::ThreadPool(num_threads); } -const int num_iterations = state.range(0); + const int num_iterations = state.range(0); while (state.KeepRunningBatch(num_iterations)) { BlockingCounter counter(num_iterations); for (int i = 0; i < num_iterations; ++i) { @@ -287,13 +284,14 @@ class ShortWorkFunctorForAdd val_ = 0; } ~ShortWorkFunctorForAdd() {} - static void Run(grpc_experimental_completion_queue_functor *cb, int ok) { + static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { auto* callback = static_cast(cb); for (int i = 0; i < 1000; ++i) { callback->val_++; } callback->counter_->DecrementCount(); } + private: char pad[ABSL_CACHELINE_SIZE]; volatile int val_; From 8d10d576d08efd1f7b997fc58c48f8e7721e2197 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 19 Jul 2019 10:55:16 -0700 Subject: [PATCH 0938/1555] Change page_size to local variable --- src/core/lib/gprpp/thd_posix.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/core/lib/gprpp/thd_posix.cc b/src/core/lib/gprpp/thd_posix.cc index 99197cbbfa9..2c3ae34ed44 100644 --- a/src/core/lib/gprpp/thd_posix.cc +++ b/src/core/lib/gprpp/thd_posix.cc @@ -49,11 +49,10 @@ struct thd_arg { bool tracked; }; -// TODO(yunjiaw): move this to a function-level static, or remove the use of a -// non-constexpr initializer when possible -const size_t page_size = static_cast(sysconf(_SC_PAGESIZE)); - size_t RoundUpToPageSize(size_t size) { + // TODO(yunjiaw): Change this variable (page_size) to a function-level static + // when possible + size_t page_size = static_cast(sysconf(_SC_PAGESIZE)); return (size + page_size - 1) & ~(page_size - 1); } From 3ec57262161aafe4a5d0d1c0a52400016c97ce74 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 19 Jul 2019 10:57:28 -0700 Subject: [PATCH 0939/1555] Re-format --- src/core/lib/iomgr/executor/mpmcqueue.cc | 12 +++++------- src/core/lib/iomgr/executor/mpmcqueue.h | 10 +++++----- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index 7ef5cf40e14..15b2938a3ac 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -33,8 +33,8 @@ inline void* InfLenFIFOQueue::PopFront() { // Updates Stats when trace flag turned on. if (GRPC_TRACE_FLAG_ENABLED(grpc_thread_pool_trace)) { - gpr_timespec wait_time = gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), - queue_head_->insert_time); + gpr_timespec wait_time = + gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), queue_head_->insert_time); stats_.num_completed++; stats_.total_queue_time = gpr_time_add(stats_.total_queue_time, wait_time); stats_.max_queue_time = gpr_time_max( @@ -103,7 +103,7 @@ void InfLenFIFOQueue::Put(void* elem) { int curr_count = count_.Load(MemoryOrder::RELAXED); - if (queue_tail_ == queue_head_ && curr_count!= 0) { + if (queue_tail_ == queue_head_ && curr_count != 0) { // List is full. Expands list to double size by inserting new chunk of nodes Node* new_chunk = AllocateNodes(curr_count); delete_list_[delete_list_count_++] = new_chunk; @@ -166,7 +166,7 @@ void* InfLenFIFOQueue::Get(gpr_timespec* wait_time) { size_t InfLenFIFOQueue::num_node() { size_t num = 1024; for (size_t i = 1; i < delete_list_count_; ++i) { - num = num* 2; + num = num * 2; } return num; } @@ -184,8 +184,6 @@ void InfLenFIFOQueue::RemoveWaiter(Waiter* waiter) { waiter->prev->next = waiter->next; } -InfLenFIFOQueue::Waiter* InfLenFIFOQueue::TopWaiter() { - return waiters_.next; -} +InfLenFIFOQueue::Waiter* InfLenFIFOQueue::TopWaiter() { return waiters_.next; } } // namespace grpc_core diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index 05e5a0a7579..49bebf8af4b 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -76,7 +76,7 @@ class InfLenFIFOQueue : public MPMCQueueInterface { int count() const { return count_.Load(MemoryOrder::RELAXED); } struct Node { - Node* next; // Linking + Node* next; // Linking Node* prev; void* content; // Points to actual element gpr_timespec insert_time; // Time for stats @@ -141,8 +141,8 @@ class InfLenFIFOQueue : public MPMCQueueInterface { // last added waiter. Waiter* TopWaiter(); - Mutex mu_; // Protecting lock - Waiter waiters_; // Head of waiting thread queue + Mutex mu_; // Protecting lock + Waiter waiters_; // Head of waiting thread queue Node** delete_list_ = nullptr; // Keeps track of all allocated array entries // for deleting on destruction @@ -154,8 +154,8 @@ class InfLenFIFOQueue : public MPMCQueueInterface { Node* queue_tail_ = nullptr; // End of queue, insert position Atomic count_{0}; // Number of elements in queue - Stats stats_; // Stats info - gpr_timespec busy_time; // Start time of busy queue + Stats stats_; // Stats info + gpr_timespec busy_time; // Start time of busy queue // Internal Helper. // Allocates an array of nodes of size "num", links all nodes together except From 6d984166bd00bccd729ebbb2ae01752195b63f98 Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Fri, 19 Jul 2019 11:45:33 -0700 Subject: [PATCH 0940/1555] Porting Aaron Jacob's unit test that detecting the race --- test/cpp/end2end/generic_end2end_test.cc | 77 ++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index c2807310aa4..d0571dc1a6f 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -92,6 +92,7 @@ class GenericEnd2endTest : public ::testing::Test { void ResetStub() { std::shared_ptr channel = grpc::CreateChannel( server_address_.str(), InsecureChannelCredentials()); + stub_ = grpc::testing::EchoTestService::NewStub(channel); generic_stub_.reset(new GenericStub(channel)); } @@ -177,6 +178,54 @@ class GenericEnd2endTest : public ::testing::Test { } } + // Return errors to up to one call that comes in on the supplied completion + // queue, until the CQ is being shut down (and therefore we can no longer + // enqueue further events). + void DriveCompletionQueue() { + enum class Event : uintptr_t { + kCallReceived, + kResponseSent, + }; + // Request the call, but only if the main thread hasn't beaten us to + // shutting down the CQ. + grpc::GenericServerContext server_context; + grpc::GenericServerAsyncReaderWriter reader_writer(&server_context); + + { + std::lock_guard lock(shutting_down_mu_); + if (!shutting_down_) { + generic_service_.RequestCall( + &server_context, &reader_writer, srv_cq_.get(), srv_cq_.get(), + reinterpret_cast(Event::kCallReceived)); + } + } + // Process events. + { + Event event; + bool ok; + while (srv_cq_->Next(reinterpret_cast(&event), &ok)) { + std::lock_guard lock(shutting_down_mu_); + if (shutting_down_) { + // The main thread has started shutting down. Simply continue to drain + // events. + continue; + } + + switch (event) { + case Event::kCallReceived: + reader_writer.Finish( + ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "go away"), + reinterpret_cast(Event::kResponseSent)); + break; + + case Event::kResponseSent: + // We are done. + break; + } + } + } + } + CompletionQueue cli_cq_; std::unique_ptr srv_cq_; std::unique_ptr stub_; @@ -185,6 +234,8 @@ class GenericEnd2endTest : public ::testing::Test { AsyncGenericService generic_service_; const grpc::string server_host_; std::ostringstream server_address_; + bool shutting_down_; + std::mutex shutting_down_mu_; }; TEST_F(GenericEnd2endTest, SimpleRpc) { @@ -330,6 +381,32 @@ TEST_F(GenericEnd2endTest, Deadline) { gpr_time_from_seconds(10, GPR_TIMESPAN))); } +TEST_F(GenericEnd2endTest, ShortDeadline) { + ResetStub(); + + ClientContext cli_ctx; + EchoRequest request; + EchoResponse response; + + { + std::lock_guard lock(shutting_down_mu_); + shutting_down_ = false; + } + std::thread driver([=] { DriveCompletionQueue(); }); + + request.set_message(""); + cli_ctx.set_deadline(gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_micros(500, GPR_TIMESPAN))); + Status s = stub_->Echo(&cli_ctx, request, &response); + EXPECT_FALSE(s.ok()); + { + std::lock_guard lock(shutting_down_mu_); + shutting_down_ = true; + } + TearDown(); + driver.join(); +} + } // namespace } // namespace testing } // namespace grpc From 847faf407f4f2a45aa13478d97187b38d9ea350e Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Fri, 19 Jul 2019 12:10:52 -0700 Subject: [PATCH 0941/1555] Removes unused variable error --- test/cpp/microbenchmarks/bm_threadpool.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/test/cpp/microbenchmarks/bm_threadpool.cc b/test/cpp/microbenchmarks/bm_threadpool.cc index 468b6b53a91..cee0fa4c497 100644 --- a/test/cpp/microbenchmarks/bm_threadpool.cc +++ b/test/cpp/microbenchmarks/bm_threadpool.cc @@ -286,6 +286,7 @@ class ShortWorkFunctorForAdd ~ShortWorkFunctorForAdd() {} static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { auto* callback = static_cast(cb); + callback->pad[0] = 0; for (int i = 0; i < 1000; ++i) { callback->val_++; } From f4b1182a100c81eca490a614ad56e32b068750db Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Fri, 19 Jul 2019 13:48:35 -0700 Subject: [PATCH 0942/1555] Addressed review comments --- test/cpp/end2end/generic_end2end_test.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index d0571dc1a6f..92654ff0de0 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -388,11 +388,8 @@ TEST_F(GenericEnd2endTest, ShortDeadline) { EchoRequest request; EchoResponse response; - { - std::lock_guard lock(shutting_down_mu_); - shutting_down_ = false; - } - std::thread driver([=] { DriveCompletionQueue(); }); + shutting_down_ = false; + std::thread driver([this] { DriveCompletionQueue(); }); request.set_message(""); cli_ctx.set_deadline(gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), From da85cec0f2251f504227af90798c8b38258b4e00 Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Fri, 19 Jul 2019 14:19:23 -0700 Subject: [PATCH 0943/1555] Add condition to avoid duplicate shutdown --- test/cpp/end2end/generic_end2end_test.cc | 28 ++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index 92654ff0de0..f9f68bbe023 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -62,6 +62,7 @@ class GenericEnd2endTest : public ::testing::Test { GenericEnd2endTest() : server_host_("localhost") {} void SetUp() override { + shut_down_ = false; int port = grpc_pick_unused_port_or_die(); server_address_ << server_host_ << ":" << port; // Setup server @@ -77,17 +78,21 @@ class GenericEnd2endTest : public ::testing::Test { server_ = builder.BuildAndStart(); } - void TearDown() override { - server_->Shutdown(); - void* ignored_tag; - bool ignored_ok; - cli_cq_.Shutdown(); - srv_cq_->Shutdown(); - while (cli_cq_.Next(&ignored_tag, &ignored_ok)) - ; - while (srv_cq_->Next(&ignored_tag, &ignored_ok)) - ; + void ShutDownServerAndCQs() { + if (!shut_down_) { + server_->Shutdown(); + void* ignored_tag; + bool ignored_ok; + cli_cq_.Shutdown(); + srv_cq_->Shutdown(); + while (cli_cq_.Next(&ignored_tag, &ignored_ok)) + ; + while (srv_cq_->Next(&ignored_tag, &ignored_ok)) + ; + shut_down_ = true; + } } + void TearDown() override { ShutDownServerAndCQs(); } void ResetStub() { std::shared_ptr channel = grpc::CreateChannel( @@ -235,6 +240,7 @@ class GenericEnd2endTest : public ::testing::Test { const grpc::string server_host_; std::ostringstream server_address_; bool shutting_down_; + bool shut_down_; std::mutex shutting_down_mu_; }; @@ -400,7 +406,7 @@ TEST_F(GenericEnd2endTest, ShortDeadline) { std::lock_guard lock(shutting_down_mu_); shutting_down_ = true; } - TearDown(); + ShutDownServerAndCQs(); driver.join(); } From 6e7ed1441c88b0d996c7c95ca6abbad9352ae73a Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Fri, 19 Jul 2019 16:29:24 -0700 Subject: [PATCH 0944/1555] Added copyright statements --- .../tvOS-sample/tvOS-sample/AppDelegate.h | 24 ++++++++++++------ .../tvOS-sample/tvOS-sample/AppDelegate.m | 24 ++++++++++++------ .../tvOS-sample/tvOS-sample/ViewController.h | 24 ++++++++++++------ .../tvOS-sample/tvOS-sample/ViewController.m | 24 ++++++++++++------ .../examples/tvOS-sample/tvOS-sample/main.m | 24 ++++++++++++------ .../ExtensionDelegate.h | 24 ++++++++++++------ .../ExtensionDelegate.m | 24 ++++++++++++------ .../InterfaceController.h | 24 ++++++++++++------ .../InterfaceController.m | 25 +++++++++++++------ .../watchOS-sample/AppDelegate.h | 24 ++++++++++++------ .../watchOS-sample/AppDelegate.m | 24 ++++++++++++------ .../watchOS-sample/ViewController.h | 24 ++++++++++++------ .../watchOS-sample/ViewController.m | 24 ++++++++++++------ .../watchOS-sample/watchOS-sample/main.m | 24 ++++++++++++------ 14 files changed, 238 insertions(+), 99 deletions(-) diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.h b/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.h index 24f0d222e54..a1de90167cd 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.h +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.h @@ -1,10 +1,20 @@ -// -// AppDelegate.h -// tvOS-sample -// -// Created by Tony Lu on 7/12/19. -// Copyright © 2019 Tony Lu. All rights reserved. -// +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ #import diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m index e04dba4c4c1..25b429523a3 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m @@ -1,10 +1,20 @@ -// -// AppDelegate.m -// tvOS-sample -// -// Created by Tony Lu on 7/12/19. -// Copyright © 2019 Tony Lu. All rights reserved. -// +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ #import "AppDelegate.h" diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.h b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.h index 703e8bdb36e..79de577af81 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.h +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.h @@ -1,10 +1,20 @@ -// -// ViewController.h -// tvOS-sample -// -// Created by Tony Lu on 7/12/19. -// Copyright © 2019 Tony Lu. All rights reserved. -// +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ #import diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m index 69e1e0ce87b..289de19f5de 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m @@ -1,10 +1,20 @@ -// -// ViewController.m -// tvOS-sample -// -// Created by Tony Lu on 7/12/19. -// Copyright © 2019 Tony Lu. All rights reserved. -// +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ #import "ViewController.h" diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/main.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/main.m index f18a9db860e..62a9f8e6efb 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/main.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/main.m @@ -1,10 +1,20 @@ -// -// main.m -// tvOS-sample -// -// Created by Tony Lu on 7/12/19. -// Copyright © 2019 Tony Lu. All rights reserved. -// +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ #import #import "AppDelegate.h" diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.h b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.h index df2e8e156b6..9b48cc95e6a 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.h +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.h @@ -1,10 +1,20 @@ -// -// ExtensionDelegate.h -// watchOS-sample WatchKit Extension -// -// Created by Tony Lu on 7/12/19. -// Copyright © 2019 Tony Lu. All rights reserved. -// +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ #import diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.m b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.m index 97d553aa855..47de32a3de9 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.m @@ -1,10 +1,20 @@ -// -// ExtensionDelegate.m -// watchOS-sample WatchKit Extension -// -// Created by Tony Lu on 7/12/19. -// Copyright © 2019 Tony Lu. All rights reserved. -// +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ #import "ExtensionDelegate.h" diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.h b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.h index cd5752bcc5c..46032d6030e 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.h +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.h @@ -1,10 +1,20 @@ -// -// InterfaceController.h -// watchOS-sample WatchKit Extension -// -// Created by Tony Lu on 7/12/19. -// Copyright © 2019 Tony Lu. All rights reserved. -// +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ #import #import diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.m b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.m index 9722a80ca50..ec3e90c95a5 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.m @@ -1,11 +1,20 @@ -// -// InterfaceController.m -// watchOS-sample WatchKit Extension -// -// Created by Tony Lu on 7/12/19. -// Copyright © 2019 Tony Lu. All rights reserved. -// - +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ #import "InterfaceController.h" #import diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.h b/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.h index 762a16888a2..a1de90167cd 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.h +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.h @@ -1,10 +1,20 @@ -// -// AppDelegate.h -// watchOS-sample -// -// Created by Tony Lu on 7/12/19. -// Copyright © 2019 Tony Lu. All rights reserved. -// +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ #import diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m b/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m index 1f77c1fb15c..571139a3d64 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m @@ -1,10 +1,20 @@ -// -// AppDelegate.m -// watchOS-sample -// -// Created by Tony Lu on 7/12/19. -// Copyright © 2019 Tony Lu. All rights reserved. -// +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ #import "AppDelegate.h" diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.h b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.h index 336e0ee57f2..79de577af81 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.h +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.h @@ -1,10 +1,20 @@ -// -// ViewController.h -// watchOS-sample -// -// Created by Tony Lu on 7/12/19. -// Copyright © 2019 Tony Lu. All rights reserved. -// +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ #import diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m index bc2f24a168b..c5cea11f5bc 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m @@ -1,10 +1,20 @@ -// -// ViewController.m -// watchOS-sample -// -// Created by Tony Lu on 7/12/19. -// Copyright © 2019 Tony Lu. All rights reserved. -// +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ #import "ViewController.h" diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/main.m b/src/objective-c/examples/watchOS-sample/watchOS-sample/main.m index a57a3cac1a5..62a9f8e6efb 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/main.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/main.m @@ -1,10 +1,20 @@ -// -// main.m -// watchOS-sample -// -// Created by Tony Lu on 7/12/19. -// Copyright © 2019 Tony Lu. All rights reserved. -// +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ #import #import "AppDelegate.h" From b458f3e6a52b9811a1e47c5a649cfc29a158933a Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Fri, 19 Jul 2019 16:33:40 -0700 Subject: [PATCH 0945/1555] Fixed clang_code_format --- .../tvOS-sample/tvOS-sample/AppDelegate.h | 6 ++-- .../tvOS-sample/tvOS-sample/AppDelegate.m | 32 ++++++++++--------- .../tvOS-sample/tvOS-sample/ViewController.h | 2 -- .../tvOS-sample/tvOS-sample/ViewController.m | 9 +++--- .../examples/tvOS-sample/tvOS-sample/main.m | 4 +-- .../watchOS-sample/AppDelegate.h | 6 ++-- .../watchOS-sample/AppDelegate.m | 32 ++++++++++--------- .../watchOS-sample/ViewController.h | 2 -- .../watchOS-sample/ViewController.m | 1 - .../watchOS-sample/watchOS-sample/main.m | 4 +-- templates/gRPC-Core.podspec.template | 3 +- templates/gRPC-RxLibrary.podspec.template | 1 + templates/gRPC.podspec.template | 1 + 13 files changed, 50 insertions(+), 53 deletions(-) diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.h b/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.h index a1de90167cd..183abcf4ec8 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.h +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.h @@ -18,10 +18,8 @@ #import -@interface AppDelegate : UIResponder - -@property (strong, nonatomic) UIWindow *window; +@interface AppDelegate : UIResponder +@property(strong, nonatomic) UIWindow* window; @end - diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m index 25b429523a3..11b6c418aee 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m @@ -24,38 +24,40 @@ @implementation AppDelegate - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { +- (BOOL)application:(UIApplication *)application + didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. return YES; } - - (void)applicationWillResignActive:(UIApplication *)application { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. + // Sent when the application is about to move from active to inactive state. This can occur for + // certain types of temporary interruptions (such as an incoming phone call or SMS message) or + // when the user quits the application and it begins the transition to the background state. Use + // this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. + // Games should use this method to pause the game. } - - (void)applicationDidEnterBackground:(UIApplication *)application { - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + // Use this method to release shared resources, save user data, invalidate timers, and store + // enough application state information to restore your application to its current state in case + // it is terminated later. If your application supports background execution, this method is + // called instead of applicationWillTerminate: when the user quits. } - - (void)applicationWillEnterForeground:(UIApplication *)application { - // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + // Called as part of the transition from the background to the active state; here you can undo + // many of the changes made on entering the background. } - - (void)applicationDidBecomeActive:(UIApplication *)application { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + // Restart any tasks that were paused (or not yet started) while the application was inactive. If + // the application was previously in the background, optionally refresh the user interface. } - - (void)applicationWillTerminate:(UIApplication *)application { - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + // Called when the application is about to terminate. Save data if appropriate. See also + // applicationDidEnterBackground:. } - @end diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.h b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.h index 79de577af81..0aa0b2a73a7 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.h +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.h @@ -20,6 +20,4 @@ @interface ViewController : UIViewController - @end - diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m index 289de19f5de..0d291e44842 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m @@ -32,10 +32,10 @@ - (void)viewDidLoad { [super viewDidLoad]; - + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; _options = options; - + _service = [[RMTTestService alloc] initWithHost:@"grpc-test.sandbox.googleapis.com" callOptions:_options]; } @@ -43,9 +43,8 @@ - (IBAction)makeCall:(id)sender { RMTSimpleRequest *request = [RMTSimpleRequest message]; request.responseSize = 100; - GRPCUnaryProtoCall *call = [_service unaryCallWithMessage:request - responseHandler:self - callOptions:nil]; + GRPCUnaryProtoCall *call = + [_service unaryCallWithMessage:request responseHandler:self callOptions:nil]; [call start]; } diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/main.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/main.m index 62a9f8e6efb..2797c6f17f2 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/main.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/main.m @@ -19,8 +19,8 @@ #import #import "AppDelegate.h" -int main(int argc, char * argv[]) { +int main(int argc, char* argv[]) { @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.h b/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.h index a1de90167cd..183abcf4ec8 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.h +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.h @@ -18,10 +18,8 @@ #import -@interface AppDelegate : UIResponder - -@property (strong, nonatomic) UIWindow *window; +@interface AppDelegate : UIResponder +@property(strong, nonatomic) UIWindow* window; @end - diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m b/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m index 571139a3d64..d78f5f2175c 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m @@ -24,38 +24,40 @@ @implementation AppDelegate - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { +- (BOOL)application:(UIApplication *)application + didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. return YES; } - - (void)applicationWillResignActive:(UIApplication *)application { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + // Sent when the application is about to move from active to inactive state. This can occur for + // certain types of temporary interruptions (such as an incoming phone call or SMS message) or + // when the user quits the application and it begins the transition to the background state. Use + // this method to pause ongoing tasks, disable timers, and invalidate graphics rendering + // callbacks. Games should use this method to pause the game. } - - (void)applicationDidEnterBackground:(UIApplication *)application { - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + // Use this method to release shared resources, save user data, invalidate timers, and store + // enough application state information to restore your application to its current state in case + // it is terminated later. If your application supports background execution, this method is + // called instead of applicationWillTerminate: when the user quits. } - - (void)applicationWillEnterForeground:(UIApplication *)application { - // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + // Called as part of the transition from the background to the active state; here you can undo + // many of the changes made on entering the background. } - - (void)applicationDidBecomeActive:(UIApplication *)application { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + // Restart any tasks that were paused (or not yet started) while the application was inactive. If + // the application was previously in the background, optionally refresh the user interface. } - - (void)applicationWillTerminate:(UIApplication *)application { - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + // Called when the application is about to terminate. Save data if appropriate. See also + // applicationDidEnterBackground:. } - @end diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.h b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.h index 79de577af81..0aa0b2a73a7 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.h +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.h @@ -20,6 +20,4 @@ @interface ViewController : UIViewController - @end - diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m index c5cea11f5bc..cd06242f80b 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m @@ -31,5 +31,4 @@ // Do any additional setup after loading the view, typically from a nib. } - @end diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/main.m b/src/objective-c/examples/watchOS-sample/watchOS-sample/main.m index 62a9f8e6efb..2797c6f17f2 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/main.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/main.m @@ -19,8 +19,8 @@ #import #import "AppDelegate.h" -int main(int argc, char * argv[]) { +int main(int argc, char* argv[]) { @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template index d367ce4f45f..43645edf2e4 100644 --- a/templates/gRPC-Core.podspec.template +++ b/templates/gRPC-Core.podspec.template @@ -94,7 +94,8 @@ s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' s.tvos.deployment_target = '10.0' - + s.watchos.deployment_target = '4.0' + s.requires_arc = false name = 'grpc' diff --git a/templates/gRPC-RxLibrary.podspec.template b/templates/gRPC-RxLibrary.podspec.template index 0973b6551db..9389c5ecd8d 100644 --- a/templates/gRPC-RxLibrary.podspec.template +++ b/templates/gRPC-RxLibrary.podspec.template @@ -38,6 +38,7 @@ s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '4.0' name = 'RxLibrary' s.module_name = name diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index c9723933fcd..8cb380ede03 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -37,6 +37,7 @@ s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '4.0' name = 'GRPCClient' s.module_name = name From 3b5f0fd7658c1d9713665051ddb0743ffe022f22 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 10 Jul 2019 18:47:38 -0700 Subject: [PATCH 0946/1555] Make dependency injection for Objective-C transport --- gRPC.podspec | 84 +- .../GRPCClient/GRPCCall+ChannelArg.m | 4 +- .../GRPCClient/GRPCCall+ChannelCredentials.m | 2 +- src/objective-c/GRPCClient/GRPCCall+Cronet.h | 12 +- src/objective-c/GRPCClient/GRPCCall+Cronet.m | 4 +- src/objective-c/GRPCClient/GRPCCall+Tests.m | 2 +- src/objective-c/GRPCClient/GRPCCall.h | 134 +-- src/objective-c/GRPCClient/GRPCCall.m | 872 +++--------------- src/objective-c/GRPCClient/GRPCCallLegacy.h | 136 +++ src/objective-c/GRPCClient/GRPCCallLegacy.m | 679 ++++++++++++++ src/objective-c/GRPCClient/GRPCCallOptions.h | 31 +- src/objective-c/GRPCClient/GRPCCallOptions.m | 27 +- src/objective-c/GRPCClient/GRPCDispatchable.h | 30 + src/objective-c/GRPCClient/GRPCInterceptor.h | 33 +- src/objective-c/GRPCClient/GRPCInterceptor.m | 267 ++++-- src/objective-c/GRPCClient/GRPCTransport.h | 61 ++ src/objective-c/GRPCClient/GRPCTransport.m | 116 +++ .../internal_testing/GRPCCall+InternalTests.m | 2 +- .../private/{ => GRPCCore}/ChannelArgsUtil.h | 0 .../private/{ => GRPCCore}/ChannelArgsUtil.m | 0 .../private/{ => GRPCCore}/GRPCCall+V2API.h | 6 - .../private/{ => GRPCCore}/GRPCCallInternal.h | 15 +- .../private/{ => GRPCCore}/GRPCCallInternal.m | 138 +-- .../private/{ => GRPCCore}/GRPCChannel.h | 0 .../private/{ => GRPCCore}/GRPCChannel.m | 70 +- .../{ => GRPCCore}/GRPCChannelFactory.h | 0 .../{ => GRPCCore}/GRPCChannelPool+Test.h | 0 .../private/{ => GRPCCore}/GRPCChannelPool.h | 4 +- .../private/{ => GRPCCore}/GRPCChannelPool.m | 4 +- .../{ => GRPCCore}/GRPCCompletionQueue.h | 0 .../{ => GRPCCore}/GRPCCompletionQueue.m | 0 .../GRPCCoreCronet/GRPCCoreCronetFactory.h | 23 + .../GRPCCoreCronet/GRPCCoreCronetFactory.m | 53 ++ .../GRPCCronetChannelFactory.h | 0 .../GRPCCronetChannelFactory.m | 20 - .../private/GRPCCore/GRPCCoreFactory.h | 40 + .../private/GRPCCore/GRPCCoreFactory.m | 68 ++ .../private/{ => GRPCCore}/GRPCHost.h | 0 .../private/{ => GRPCCore}/GRPCHost.m | 21 +- .../GRPCInsecureChannelFactory.h | 0 .../GRPCInsecureChannelFactory.m | 0 .../private/{ => GRPCCore}/GRPCOpBatchLog.h | 0 .../private/{ => GRPCCore}/GRPCOpBatchLog.m | 0 .../GRPCReachabilityFlagNames.xmacro.h | 0 .../{ => GRPCCore}/GRPCRequestHeaders.h | 2 +- .../{ => GRPCCore}/GRPCRequestHeaders.m | 0 .../{ => GRPCCore}/GRPCSecureChannelFactory.h | 0 .../{ => GRPCCore}/GRPCSecureChannelFactory.m | 0 .../private/{ => GRPCCore}/GRPCWrappedCall.h | 0 .../private/{ => GRPCCore}/GRPCWrappedCall.m | 0 .../private/{ => GRPCCore}/NSData+GRPC.h | 0 .../private/{ => GRPCCore}/NSData+GRPC.m | 0 .../{ => GRPCCore}/NSDictionary+GRPC.h | 0 .../{ => GRPCCore}/NSDictionary+GRPC.m | 0 .../private/{ => GRPCCore}/NSError+GRPC.h | 0 .../private/{ => GRPCCore}/NSError+GRPC.m | 0 .../GRPCClient/private/GRPCCore/version.h | 25 + .../private/GRPCTransport+Private.h | 55 ++ .../private/GRPCTransport+Private.m | 108 +++ src/objective-c/tests/ConfigureCronet.h | 4 - src/objective-c/tests/ConfigureCronet.m | 4 - .../InteropTestsRemoteWithCronet.m | 16 + .../tests/InteropTests/InteropTests.h | 8 + .../tests/InteropTests/InteropTests.m | 174 ++-- .../InteropTests/InteropTestsLocalCleartext.m | 5 +- .../tests/InteropTests/InteropTestsLocalSSL.m | 7 +- .../InteropTestsMultipleChannels.m | 2 - .../tests/InteropTests/InteropTestsRemote.m | 6 - src/objective-c/tests/Podfile | 4 +- .../tests/Tests.xcodeproj/project.pbxproj | 4 +- .../tests/UnitTests/ChannelPoolTest.m | 6 +- .../tests/UnitTests/ChannelTests.m | 10 +- .../tests/UnitTests/NSErrorUnitTests.m | 2 +- templates/gRPC.podspec.template | 84 +- 74 files changed, 2146 insertions(+), 1338 deletions(-) create mode 100644 src/objective-c/GRPCClient/GRPCCallLegacy.h create mode 100644 src/objective-c/GRPCClient/GRPCCallLegacy.m create mode 100644 src/objective-c/GRPCClient/GRPCDispatchable.h create mode 100644 src/objective-c/GRPCClient/GRPCTransport.h create mode 100644 src/objective-c/GRPCClient/GRPCTransport.m rename src/objective-c/GRPCClient/private/{ => GRPCCore}/ChannelArgsUtil.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/ChannelArgsUtil.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCCall+V2API.h (79%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCCallInternal.h (71%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCCallInternal.m (68%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCChannel.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCChannel.m (77%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCChannelFactory.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCChannelPool+Test.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCChannelPool.h (97%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCChannelPool.m (98%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCCompletionQueue.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCCompletionQueue.m (100%) create mode 100644 src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h create mode 100644 src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m rename src/objective-c/GRPCClient/private/{ => GRPCCore/GRPCCoreCronet}/GRPCCronetChannelFactory.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore/GRPCCoreCronet}/GRPCCronetChannelFactory.m (79%) create mode 100644 src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h create mode 100644 src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCHost.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCHost.m (87%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCInsecureChannelFactory.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCInsecureChannelFactory.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCOpBatchLog.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCOpBatchLog.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCReachabilityFlagNames.xmacro.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCRequestHeaders.h (95%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCRequestHeaders.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCSecureChannelFactory.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCSecureChannelFactory.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCWrappedCall.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCWrappedCall.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/NSData+GRPC.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/NSData+GRPC.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/NSDictionary+GRPC.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/NSDictionary+GRPC.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/NSError+GRPC.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/NSError+GRPC.m (100%) create mode 100644 src/objective-c/GRPCClient/private/GRPCCore/version.h create mode 100644 src/objective-c/GRPCClient/private/GRPCTransport+Private.h create mode 100644 src/objective-c/GRPCClient/private/GRPCTransport+Private.m diff --git a/gRPC.podspec b/gRPC.podspec index bbfd08f9774..815da6ef7c1 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -40,10 +40,8 @@ Pod::Spec.new do |s| s.module_name = name s.header_dir = name - src_dir = 'src/objective-c/GRPCClient' - s.dependency 'gRPC-RxLibrary', version - s.default_subspec = 'Main' + s.default_subspec = 'Interface', 'GRPCCore' # Certificates, to be able to establish TLS connections: s.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } @@ -54,29 +52,75 @@ Pod::Spec.new do |s| 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO', } - s.subspec 'Main' do |ss| - ss.header_mappings_dir = "#{src_dir}" + s.subspec 'Interface' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' - ss.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}" - ss.exclude_files = "#{src_dir}/GRPCCall+GID.{h,m}" - ss.private_header_files = "#{src_dir}/private/*.h", "#{src_dir}/internal/*.h" + ss.public_header_files = 'src/objective-c/GRPCClient/GRPCCall.h', + 'src/objective-c/GRPCClient/GRPCCall+Interceptor.h', + 'src/objective-c/GRPCClient/GRPCCallOptions.h', + 'src/objective-c/GRPCClient/GRPCInterceptor.h', + 'src/objective-c/GRPCClient/GRPCTransport.h', + 'src/objective-c/GRPCClient/GRPCDispatchable.h', + 'src/objective-c/GRPCClient/internal/*.h' + + ss.source_files = 'src/objective-c/GRPCClient/GRPCCall.h', + 'src/objective-c/GRPCClient/GRPCCall.m', + 'src/objective-c/GRPCClient/GRPCCall+Interceptor.h', + 'src/objective-c/GRPCClient/GRPCCall+Interceptor.m', + 'src/objective-c/GRPCClient/GRPCCallOptions.h', + 'src/objective-c/GRPCClient/GRPCCallOptions.m', + 'src/objective-c/GRPCClient/GRPCDispatchable.h', + 'src/objective-c/GRPCClient/GRPCInterceptor.h', + 'src/objective-c/GRPCClient/GRPCInterceptor.m', + 'src/objective-c/GRPCClient/GRPCTransport.h', + 'src/objective-c/GRPCClient/GRPCTransport.m', + 'src/objective-c/GRPCClient/private/GRPCTransport+Private.h', + 'src/objective-c/GRPCClient/private/GRPCTransport+Private.m' + end + + s.subspec 'GRPCCore' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' + + ss.public_header_files = 'src/objective-c/GRPCClient/ChannelArg.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', + 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', + 'src/objective-c/GRPCClient/GRPCCall+Tests.h', + 'src/objective-c/GRPCClient/GRPCCallLegacy.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', + 'src/objective-c/GRPCClient/internal_testing/*.h' + ss.private_header_files = 'src/objective-c/GRPCClient/private/GRPCCore/*.h' + ss.source_files = 'src/objective-c/GRPCClient/internal_testing/*.h', + 'src/objective-c/GRPCClient/private/GRPCCore/*.{h,m}', + 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.m', + 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.m', + 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', + 'src/objective-c/GRPCClient/GRPCCall+OAuth2.m', + 'src/objective-c/GRPCClient/GRPCCall+Tests.h', + 'src/objective-c/GRPCClient/GRPCCall+Tests.m', + 'src/objective-c/GRPCClient/GRPCCallLegacy.h', + 'src/objective-c/GRPCClient/GRPCCallLegacy.m' ss.dependency 'gRPC-Core', version + ss.dependency "#{s.name}/Interface", version + end + + s.subspec 'GRPCCoreCronet' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' + + ss.source_files = 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.m', + 'src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/*.{h,m}' + ss.dependency 'CronetFramework' + ss.dependency 'gRPC-Core/Cronet-Implementation', version end # CFStream is now default. Leaving this subspec only for compatibility purpose. s.subspec 'CFStream' do |ss| - ss.dependency "#{s.name}/Main", version - end - - s.subspec 'GID' do |ss| - ss.ios.deployment_target = '7.0' - - ss.header_mappings_dir = "#{src_dir}" - - ss.source_files = "#{src_dir}/GRPCCall+GID.{h,m}" - - ss.dependency "#{s.name}/Main", version - ss.dependency 'Google/SignIn' + ss.dependency "#{s.name}/GRPCCore", version end end diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m index ae60d6208e1..aae1b740c71 100644 --- a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m @@ -18,8 +18,8 @@ #import "GRPCCall+ChannelArg.h" -#import "private/GRPCChannelPool.h" -#import "private/GRPCHost.h" +#import "private/GRPCCore/GRPCChannelPool.h" +#import "private/GRPCCore/GRPCHost.h" #import diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m b/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m index 2689ec2effb..aa97ca82bf8 100644 --- a/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m @@ -18,7 +18,7 @@ #import "GRPCCall+ChannelCredentials.h" -#import "private/GRPCHost.h" +#import "private/GRPCCore/GRPCHost.h" @implementation GRPCCall (ChannelCredentials) diff --git a/src/objective-c/GRPCClient/GRPCCall+Cronet.h b/src/objective-c/GRPCClient/GRPCCall+Cronet.h index 3059c6f1860..c77816b8df6 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Cronet.h +++ b/src/objective-c/GRPCClient/GRPCCall+Cronet.h @@ -15,12 +15,16 @@ * limitations under the License. * */ -#ifdef GRPC_COMPILE_WITH_CRONET -#import #import "GRPCCall.h" +#import "GRPCTransport.h" -// Deprecated interface. Please use GRPCCallOptions instead. +typedef struct stream_engine stream_engine; + +// Transport id for Cronet transport +extern const GRPCTransportId gGRPCCoreCronetId; + +// Deprecated class. Please use the previous transport id with GRPCCallOptions instead. @interface GRPCCall (Cronet) + (void)useCronetWithEngine:(stream_engine*)engine; @@ -28,4 +32,4 @@ + (BOOL)isUsingCronet; @end -#endif + diff --git a/src/objective-c/GRPCClient/GRPCCall+Cronet.m b/src/objective-c/GRPCClient/GRPCCall+Cronet.m index ba8d2c23db8..a732208e1f6 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Cronet.m +++ b/src/objective-c/GRPCClient/GRPCCall+Cronet.m @@ -18,7 +18,8 @@ #import "GRPCCall+Cronet.h" -#ifdef GRPC_COMPILE_WITH_CRONET +const GRPCTransportId gGRPCCoreCronetId = "io.grpc.transport.core.cronet"; + static BOOL useCronet = NO; static stream_engine *globalCronetEngine; @@ -38,4 +39,3 @@ static stream_engine *globalCronetEngine; } @end -#endif diff --git a/src/objective-c/GRPCClient/GRPCCall+Tests.m b/src/objective-c/GRPCClient/GRPCCall+Tests.m index ac3b6a658f9..9a704443e62 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Tests.m +++ b/src/objective-c/GRPCClient/GRPCCall+Tests.m @@ -18,7 +18,7 @@ #import "GRPCCall+Tests.h" -#import "private/GRPCHost.h" +#import "private/GRPCCore/GRPCHost.h" #import "GRPCCallOptions.h" diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index d02ec601727..504da43329a 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -33,11 +33,16 @@ */ #import -#import -#include +#import "GRPCCallOptions.h" +#import "GRPCDispatchable.h" -#include "GRPCCallOptions.h" +// The legacy header is included for backwards compatibility. Some V1 API users are still using +// GRPCCall by importing GRPCCall.h header so we need this import. However, if a user needs to +// exclude the core implementation, they may do so by defining GRPC_OBJC_NO_LEGACY_COMPATIBILITY. +#ifndef GRPC_OBJC_NO_LEGACY_COMPATIBILITY +#import "GRPCCallLegacy.h" +#endif NS_ASSUME_NONNULL_BEGIN @@ -52,6 +57,8 @@ extern NSString *const kGRPCErrorDomain; * server applications to produce. */ typedef NS_ENUM(NSUInteger, GRPCErrorCode) { + GRPCErrorCodeOk = 0, + /** The operation was cancelled (typically by the caller). */ GRPCErrorCodeCancelled = 1, @@ -152,15 +159,7 @@ extern NSString *const kGRPCHeadersKey; extern NSString *const kGRPCTrailersKey; /** An object can implement this protocol to receive responses from server from a call. */ -@protocol GRPCResponseHandler - -@required - -/** - * All the responses must be issued to a user-provided dispatch queue. This property specifies the - * dispatch queue to be used for issuing the notifications. - */ -@property(atomic, readonly) dispatch_queue_t dispatchQueue; +@protocol GRPCResponseHandler @optional @@ -302,114 +301,3 @@ extern NSString *const kGRPCTrailersKey; @end NS_ASSUME_NONNULL_END - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wnullability-completeness" - -/** - * This interface is deprecated. Please use \a GRPCcall2. - * - * Represents a single gRPC remote call. - */ -@interface GRPCCall : GRXWriter - -- (instancetype)init NS_UNAVAILABLE; - -/** - * The container of the request headers of an RPC conforms to this protocol, which is a subset of - * NSMutableDictionary's interface. It will become a NSMutableDictionary later on. - * The keys of this container are the header names, which per the HTTP standard are case- - * insensitive. They are stored in lowercase (which is how HTTP/2 mandates them on the wire), and - * can only consist of ASCII characters. - * A header value is a NSString object (with only ASCII characters), unless the header name has the - * suffix "-bin", in which case the value has to be a NSData object. - */ -/** - * These HTTP headers will be passed to the server as part of this call. Each HTTP header is a - * name-value pair with string names and either string or binary values. - * - * The passed dictionary has to use NSString keys, corresponding to the header names. The value - * associated to each can be a NSString object or a NSData object. E.g.: - * - * call.requestHeaders = @{@"authorization": @"Bearer ..."}; - * - * call.requestHeaders[@"my-header-bin"] = someData; - * - * After the call is started, trying to modify this property is an error. - * - * The property is initialized to an empty NSMutableDictionary. - */ -@property(atomic, readonly) NSMutableDictionary *requestHeaders; - -/** - * This dictionary is populated with the HTTP headers received from the server. This happens before - * any response message is received from the server. It has the same structure as the request - * headers dictionary: Keys are NSString header names; names ending with the suffix "-bin" have a - * NSData value; the others have a NSString value. - * - * The value of this property is nil until all response headers are received, and will change before - * any of -writeValue: or -writesFinishedWithError: are sent to the writeable. - */ -@property(atomic, readonly) NSDictionary *responseHeaders; - -/** - * Same as responseHeaders, but populated with the HTTP trailers received from the server before the - * call finishes. - * - * The value of this property is nil until all response trailers are received, and will change - * before -writesFinishedWithError: is sent to the writeable. - */ -@property(atomic, readonly) NSDictionary *responseTrailers; - -/** - * The request writer has to write NSData objects into the provided Writeable. The server will - * receive each of those separately and in order as distinct messages. - * A gRPC call might not complete until the request writer finishes. On the other hand, the request - * finishing doesn't necessarily make the call to finish, as the server might continue sending - * messages to the response side of the call indefinitely (depending on the semantics of the - * specific remote method called). - * To finish a call right away, invoke cancel. - * host parameter should not contain the scheme (http:// or https://), only the name or IP addr - * and the port number, for example @"localhost:5050". - */ -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - requestsWriter:(GRXWriter *)requestWriter; - -/** - * Finishes the request side of this call, notifies the server that the RPC should be cancelled, and - * finishes the response side of the call with an error of code CANCELED. - */ -- (void)cancel; - -/** - * The following methods are deprecated. - */ -+ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path; -@property(atomic, copy, readwrite) NSString *serverName; -@property NSTimeInterval timeout; -- (void)setResponseDispatchQueue:(dispatch_queue_t)queue; - -@end - -#pragma mark Backwards compatibiity - -/** This protocol is kept for backwards compatibility with existing code. */ -DEPRECATED_MSG_ATTRIBUTE("Use NSDictionary or NSMutableDictionary instead.") -@protocol GRPCRequestHeaders -@property(nonatomic, readonly) NSUInteger count; - -- (id)objectForKeyedSubscript:(id)key; -- (void)setObject:(id)obj forKeyedSubscript:(id)key; - -- (void)removeAllObjects; -- (void)removeObjectForKey:(id)key; -@end - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated" -/** This is only needed for backwards-compatibility. */ -@interface NSMutableDictionary (GRPCRequestHeaders) -@end -#pragma clang diagnostic pop -#pragma clang diagnostic pop diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index cd293cc8e59..2f2a89c20ac 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -17,56 +17,84 @@ */ #import "GRPCCall.h" -#import "GRPCCall+Interceptor.h" -#import "GRPCCall+OAuth2.h" + +#include #import "GRPCCallOptions.h" #import "GRPCInterceptor.h" +#import "GRPCCall+Interceptor.h" -#import -#import -#import -#import -#include -#include - -#import "private/GRPCCall+V2API.h" -#import "private/GRPCCallInternal.h" -#import "private/GRPCChannelPool.h" -#import "private/GRPCCompletionQueue.h" -#import "private/GRPCHost.h" -#import "private/GRPCRequestHeaders.h" -#import "private/GRPCWrappedCall.h" -#import "private/NSData+GRPC.h" -#import "private/NSDictionary+GRPC.h" -#import "private/NSError+GRPC.h" - -// At most 6 ops can be in an op batch for a client: SEND_INITIAL_METADATA, -// SEND_MESSAGE, SEND_CLOSE_FROM_CLIENT, RECV_INITIAL_METADATA, RECV_MESSAGE, -// and RECV_STATUS_ON_CLIENT. -NSInteger kMaxClientBatch = 6; +#import "private/GRPCTransport+Private.h" +#import "private/GRPCCore/GRPCCoreFactory.h" NSString *const kGRPCHeadersKey = @"io.grpc.HeadersKey"; NSString *const kGRPCTrailersKey = @"io.grpc.TrailersKey"; -static NSMutableDictionary *callFlags; -static NSString *const kAuthorizationHeader = @"authorization"; -static NSString *const kBearerPrefix = @"Bearer "; +/** + * The response dispatcher creates its own serial dispatch queue and target the queue to the + * dispatch queue of a user provided response handler. It removes the requirement of having to use + * serial dispatch queue in the user provided response handler. + */ +@interface GRPCResponseDispatcher : NSObject -const char *kCFStreamVarName = "grpc_cfstream"; +- (nullable instancetype)initWithResponseHandler:(id)responseHandler; -@interface GRPCCall () -// Make them read-write. -@property(atomic, strong) NSDictionary *responseHeaders; -@property(atomic, strong) NSDictionary *responseTrailers; +@end -- (void)receiveNextMessages:(NSUInteger)numberOfMessages; +@implementation GRPCResponseDispatcher { + id _responseHandler; + dispatch_queue_t _dispatchQueue; +} -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - callSafety:(GRPCCallSafety)safety - requestsWriter:(GRXWriter *)requestsWriter - callOptions:(GRPCCallOptions *)callOptions - writeDone:(void (^)(void))writeDone; +- (instancetype)initWithResponseHandler:(id)responseHandler { + if ((self = [super init])) { + _responseHandler = responseHandler; +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 + if (@available(iOS 8.0, macOS 10.10, *)) { + _dispatchQueue = dispatch_queue_create(NULL, dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); + } else { +#else + { +#endif + _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); + } + dispatch_set_target_queue(_dispatchQueue, _responseHandler.dispatchQueue); + } + + return self; +} + + - (dispatch_queue_t)dispatchQueue { + return _dispatchQueue; + } + + - (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata { + if ([_responseHandler respondsToSelector:@selector(didReceiveInitialMetadata:)]) { + [_responseHandler didReceiveInitialMetadata:initialMetadata]; + } + } + + - (void)didReceiveData:(id)data { + // For backwards compatibility with didReceiveRawMessage, if the user provided a response handler + // that handles didReceiveRawMesssage, we issue to that method instead + if ([_responseHandler respondsToSelector:@selector(didReceiveRawMessage:)]) { + [_responseHandler didReceiveRawMessage:data]; + } else if ([_responseHandler respondsToSelector:@selector(didReceiveData:)]) { + [_responseHandler didReceiveData:data]; + } + } + + - (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata +error:(nullable NSError *)error { + if ([_responseHandler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { + [_responseHandler didCloseWithTrailingMetadata:trailingMetadata error:error]; + } +} + + - (void)didWriteData { + if ([_responseHandler respondsToSelector:@selector(didWriteData)]) { + [_responseHandler didWriteData]; + } + } @end @@ -140,54 +168,35 @@ const char *kCFStreamVarName = "grpc_cfstream"; } _responseHandler = responseHandler; - // Initialize the interceptor chain - - // First initialize the internal call - GRPCCall2Internal *internalCall = [[GRPCCall2Internal alloc] init]; - id nextInterceptor = internalCall; - GRPCInterceptorManager *nextManager = nil; - - // Then initialize the global interceptor, if applicable - id globalInterceptorFactory = [GRPCCall2 globalInterceptorFactory]; - if (globalInterceptorFactory) { - GRPCInterceptorManager *manager = - [[GRPCInterceptorManager alloc] initWithNextInterceptor:nextInterceptor]; - GRPCInterceptor *interceptor = - [globalInterceptorFactory createInterceptorWithManager:manager]; - if (interceptor != nil) { - [internalCall setResponseHandler:interceptor]; - nextInterceptor = interceptor; - nextManager = manager; - } - } - - // Finally initialize the interceptors in the chain - NSArray *interceptorFactories = _actualCallOptions.interceptorFactories; - for (int i = (int)interceptorFactories.count - 1; i >= 0; i--) { - GRPCInterceptorManager *manager = - [[GRPCInterceptorManager alloc] initWithNextInterceptor:nextInterceptor]; - GRPCInterceptor *interceptor = [interceptorFactories[i] createInterceptorWithManager:manager]; - NSAssert(interceptor != nil, @"Failed to create interceptor from factory: %@", - interceptorFactories[i]); - if (interceptor == nil) { - NSLog(@"Failed to create interceptor from factory: %@", interceptorFactories[i]); - continue; - } - if (nextManager == nil) { - [internalCall setResponseHandler:interceptor]; - } else { - [nextManager setPreviousInterceptor:interceptor]; - } - nextInterceptor = interceptor; - nextManager = manager; - } - if (nextManager == nil) { - [internalCall setResponseHandler:_responseHandler]; + GRPCResponseDispatcher *dispatcher = [[GRPCResponseDispatcher alloc] initWithResponseHandler:_responseHandler]; + NSMutableArray> *interceptorFactories; + if (_actualCallOptions.interceptorFactories != nil) { + interceptorFactories = [NSMutableArray arrayWithArray:_actualCallOptions.interceptorFactories]; } else { - [nextManager setPreviousInterceptor:_responseHandler]; + interceptorFactories = [NSMutableArray array]; + } + id globalInterceptorFactory = [GRPCCall2 globalInterceptorFactory]; + if (globalInterceptorFactory != nil) { + [interceptorFactories addObject:globalInterceptorFactory]; + } + // continuously create interceptor until one is successfully created + while (_firstInterceptor == nil) { + if (interceptorFactories.count == 0) { + _firstInterceptor = [[GRPCTransportManager alloc] initWithTransportId:_callOptions.transport previousInterceptor:dispatcher]; + break; + } else { + _firstInterceptor = [[GRPCInterceptorManager alloc] initWithFactories:interceptorFactories + previousInterceptor:dispatcher + transportId:_callOptions.transport]; + if (_firstInterceptor == nil) { + [interceptorFactories removeObjectAtIndex:0]; + } + } + } + NSAssert(_firstInterceptor != nil, @"Failed to create interceptor or transport."); + if (_firstInterceptor == nil) { + NSLog(@"Failed to create interceptor or transport."); } - - _firstInterceptor = nextInterceptor; } return self; @@ -200,696 +209,43 @@ const char *kCFStreamVarName = "grpc_cfstream"; } - (void)start { - id copiedFirstInterceptor; - @synchronized(self) { - copiedFirstInterceptor = _firstInterceptor; - } - GRPCRequestOptions *requestOptions = [_requestOptions copy]; - GRPCCallOptions *callOptions = [_actualCallOptions copy]; - if ([copiedFirstInterceptor respondsToSelector:@selector(startWithRequestOptions:callOptions:)]) { - dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ - [copiedFirstInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; - }); - } + id copiedFirstInterceptor = _firstInterceptor; + GRPCRequestOptions *requestOptions = _requestOptions; + GRPCCallOptions *callOptions = _actualCallOptions; + dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ + [copiedFirstInterceptor startWithRequestOptions:requestOptions + callOptions:callOptions]; + }); } - (void)cancel { - id copiedFirstInterceptor; - @synchronized(self) { - copiedFirstInterceptor = _firstInterceptor; - } - if ([copiedFirstInterceptor respondsToSelector:@selector(cancel)]) { - dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ + id copiedFirstInterceptor = _firstInterceptor; + if (copiedFirstInterceptor != nil) { + dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ [copiedFirstInterceptor cancel]; }); } } - (void)writeData:(id)data { - id copiedFirstInterceptor; - @synchronized(self) { - copiedFirstInterceptor = _firstInterceptor; - } - if ([copiedFirstInterceptor respondsToSelector:@selector(writeData:)]) { - dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ - [copiedFirstInterceptor writeData:data]; - }); - } + id copiedFirstInterceptor = _firstInterceptor; + dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ + [copiedFirstInterceptor writeData:data]; + }); } - (void)finish { - id copiedFirstInterceptor; - @synchronized(self) { - copiedFirstInterceptor = _firstInterceptor; - } - if ([copiedFirstInterceptor respondsToSelector:@selector(finish)]) { - dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ - [copiedFirstInterceptor finish]; - }); - } -} - -- (void)receiveNextMessages:(NSUInteger)numberOfMessages { - id copiedFirstInterceptor; - @synchronized(self) { - copiedFirstInterceptor = _firstInterceptor; - } - if ([copiedFirstInterceptor respondsToSelector:@selector(receiveNextMessages:)]) { - dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ - [copiedFirstInterceptor receiveNextMessages:numberOfMessages]; - }); - } -} - -@end - -// The following methods of a C gRPC call object aren't reentrant, and thus -// calls to them must be serialized: -// - start_batch -// - destroy -// -// start_batch with a SEND_MESSAGE argument can only be called after the -// OP_COMPLETE event for any previous write is received. This is achieved by -// pausing the requests writer immediately every time it writes a value, and -// resuming it again when OP_COMPLETE is received. -// -// Similarly, start_batch with a RECV_MESSAGE argument can only be called after -// the OP_COMPLETE event for any previous read is received.This is easier to -// enforce, as we're writing the received messages into the writeable: -// start_batch is enqueued once upon receiving the OP_COMPLETE event for the -// RECV_METADATA batch, and then once after receiving each OP_COMPLETE event for -// each RECV_MESSAGE batch. -@implementation GRPCCall { - dispatch_queue_t _callQueue; - - NSString *_host; - NSString *_path; - GRPCCallSafety _callSafety; - GRPCCallOptions *_callOptions; - GRPCWrappedCall *_wrappedCall; - - // The C gRPC library has less guarantees on the ordering of events than we - // do. Particularly, in the face of errors, there's no ordering guarantee at - // all. This wrapper over our actual writeable ensures thread-safety and - // correct ordering. - GRXConcurrentWriteable *_responseWriteable; - - // The network thread wants the requestWriter to resume (when the server is ready for more input), - // or to stop (on errors), concurrently with user threads that want to start it, pause it or stop - // it. Because a writer isn't thread-safe, we'll synchronize those operations on it. - // We don't use a dispatch queue for that purpose, because the writer can call writeValue: or - // writesFinishedWithError: on this GRPCCall as part of those operations. We want to be able to - // pause the writer immediately on writeValue:, so we need our locking to be recursive. - GRXWriter *_requestWriter; - - // To create a retain cycle when a call is started, up until it finishes. See - // |startWithWriteable:| and |finishWithError:|. This saves users from having to retain a - // reference to the call object if all they're interested in is the handler being executed when - // the response arrives. - GRPCCall *_retainSelf; - - GRPCRequestHeaders *_requestHeaders; - - // In the case that the call is a unary call (i.e. the writer to GRPCCall is of type - // GRXImmediateSingleWriter), GRPCCall will delay sending ops (not send them to C core - // immediately) and buffer them into a batch _unaryOpBatch. The batch is sent to C core when - // the SendClose op is added. - BOOL _unaryCall; - NSMutableArray *_unaryOpBatch; - - // The dispatch queue to be used for enqueuing responses to user. Defaulted to the main dispatch - // queue - dispatch_queue_t _responseQueue; - - // The OAuth2 token fetched from a token provider. - NSString *_fetchedOauth2AccessToken; - - // The callback to be called when a write message op is done. - void (^_writeDone)(void); - - // Indicate a read request to core is pending. - BOOL _pendingCoreRead; - - // Indicate pending read message request from user. - NSUInteger _pendingReceiveNextMessages; -} - -@synthesize state = _state; - -+ (void)initialize { - // Guarantees the code in {} block is invoked only once. See ref at: - // https://developer.apple.com/documentation/objectivec/nsobject/1418639-initialize?language=objc - if (self == [GRPCCall self]) { - grpc_init(); - callFlags = [NSMutableDictionary dictionary]; - } -} - -+ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path { - if (host.length == 0 || path.length == 0) { - return; - } - NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path]; - @synchronized(callFlags) { - switch (callSafety) { - case GRPCCallSafetyDefault: - callFlags[hostAndPath] = @0; - break; - case GRPCCallSafetyIdempotentRequest: - callFlags[hostAndPath] = @GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST; - break; - case GRPCCallSafetyCacheableRequest: - callFlags[hostAndPath] = @GRPC_INITIAL_METADATA_CACHEABLE_REQUEST; - break; - default: - break; - } - } -} - -+ (uint32_t)callFlagsForHost:(NSString *)host path:(NSString *)path { - NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path]; - @synchronized(callFlags) { - return [callFlags[hostAndPath] intValue]; - } -} - -// Designated initializer -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - requestsWriter:(GRXWriter *)requestWriter { - return [self initWithHost:host - path:path - callSafety:GRPCCallSafetyDefault - requestsWriter:requestWriter - callOptions:nil]; -} - -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - callSafety:(GRPCCallSafety)safety - requestsWriter:(GRXWriter *)requestsWriter - callOptions:(GRPCCallOptions *)callOptions { - return [self initWithHost:host - path:path - callSafety:safety - requestsWriter:requestsWriter - callOptions:callOptions - writeDone:nil]; -} - -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - callSafety:(GRPCCallSafety)safety - requestsWriter:(GRXWriter *)requestsWriter - callOptions:(GRPCCallOptions *)callOptions - writeDone:(void (^)(void))writeDone { - // Purposely using pointer rather than length (host.length == 0) for backwards compatibility. - NSAssert(host != nil && path != nil, @"Neither host nor path can be nil."); - NSAssert(safety <= GRPCCallSafetyCacheableRequest, @"Invalid call safety value."); - NSAssert(requestsWriter.state == GRXWriterStateNotStarted, - @"The requests writer can't be already started."); - if (!host || !path) { - return nil; - } - if (safety > GRPCCallSafetyCacheableRequest) { - return nil; - } - if (requestsWriter.state != GRXWriterStateNotStarted) { - return nil; - } - - if ((self = [super init])) { - _host = [host copy]; - _path = [path copy]; - _callSafety = safety; - _callOptions = [callOptions copy]; - - // Serial queue to invoke the non-reentrant methods of the grpc_call object. - _callQueue = dispatch_queue_create("io.grpc.call", DISPATCH_QUEUE_SERIAL); - - _requestWriter = requestsWriter; - _requestHeaders = [[GRPCRequestHeaders alloc] initWithCall:self]; - _writeDone = writeDone; - - if ([requestsWriter isKindOfClass:[GRXImmediateSingleWriter class]]) { - _unaryCall = YES; - _unaryOpBatch = [NSMutableArray arrayWithCapacity:kMaxClientBatch]; - } - - _responseQueue = dispatch_get_main_queue(); - - // do not start a read until initial metadata is received - _pendingReceiveNextMessages = 0; - _pendingCoreRead = YES; - } - return self; -} - -- (void)setResponseDispatchQueue:(dispatch_queue_t)queue { - @synchronized(self) { - if (_state != GRXWriterStateNotStarted) { - return; - } - _responseQueue = queue; - } -} - -#pragma mark Finish - -// This function should support being called within a @synchronized(self) block in another function -// Should not manipulate _requestWriter for deadlock prevention. -- (void)finishWithError:(NSError *)errorOrNil { - @synchronized(self) { - if (_state == GRXWriterStateFinished) { - return; - } - _state = GRXWriterStateFinished; - - if (errorOrNil) { - [_responseWriteable cancelWithError:errorOrNil]; - } else { - [_responseWriteable enqueueSuccessfulCompletion]; - } - - // If the call isn't retained anywhere else, it can be deallocated now. - _retainSelf = nil; - } -} - -- (void)cancel { - @synchronized(self) { - if (_state == GRXWriterStateFinished) { - return; - } - [self finishWithError:[NSError - errorWithDomain:kGRPCErrorDomain - code:GRPCErrorCodeCancelled - userInfo:@{NSLocalizedDescriptionKey : @"Canceled by app"}]]; - [_wrappedCall cancel]; - } - _requestWriter.state = GRXWriterStateFinished; -} - -- (void)dealloc { - __block GRPCWrappedCall *wrappedCall = _wrappedCall; - dispatch_async(_callQueue, ^{ - wrappedCall = nil; - }); -} - -#pragma mark Read messages - -// Only called from the call queue. -// The handler will be called from the network queue. -- (void)startReadWithHandler:(void (^)(grpc_byte_buffer *))handler { - // TODO(jcanizales): Add error handlers for async failures - [_wrappedCall startBatchWithOperations:@[ [[GRPCOpRecvMessage alloc] initWithHandler:handler] ]]; -} - -// Called initially from the network queue once response headers are received, -// then "recursively" from the responseWriteable queue after each response from the -// server has been written. -// If the call is currently paused, this is a noop. Restarting the call will invoke this -// method. -// TODO(jcanizales): Rename to readResponseIfNotPaused. -- (void)maybeStartNextRead { - @synchronized(self) { - if (_state != GRXWriterStateStarted) { - return; - } - if (_callOptions.flowControlEnabled && (_pendingCoreRead || _pendingReceiveNextMessages == 0)) { - return; - } - _pendingCoreRead = YES; - _pendingReceiveNextMessages--; - } - - dispatch_async(_callQueue, ^{ - __weak GRPCCall *weakSelf = self; - [self startReadWithHandler:^(grpc_byte_buffer *message) { - if (message == NULL) { - // No more messages from the server - return; - } - __strong GRPCCall *strongSelf = weakSelf; - if (strongSelf == nil) { - grpc_byte_buffer_destroy(message); - return; - } - NSData *data = [NSData grpc_dataWithByteBuffer:message]; - grpc_byte_buffer_destroy(message); - if (!data) { - // The app doesn't have enough memory to hold the server response. We - // don't want to throw, because the app shouldn't crash for a behavior - // that's on the hands of any server to have. Instead we finish and ask - // the server to cancel. - @synchronized(strongSelf) { - strongSelf->_pendingCoreRead = NO; - [strongSelf - finishWithError:[NSError errorWithDomain:kGRPCErrorDomain - code:GRPCErrorCodeResourceExhausted - userInfo:@{ - NSLocalizedDescriptionKey : - @"Client does not have enough memory to " - @"hold the server response." - }]]; - [strongSelf->_wrappedCall cancel]; - } - strongSelf->_requestWriter.state = GRXWriterStateFinished; - } else { - @synchronized(strongSelf) { - [strongSelf->_responseWriteable enqueueValue:data - completionHandler:^{ - __strong GRPCCall *strongSelf = weakSelf; - if (strongSelf) { - @synchronized(strongSelf) { - strongSelf->_pendingCoreRead = NO; - [strongSelf maybeStartNextRead]; - } - } - }]; - } - } - }]; - }); -} - -#pragma mark Send headers - -- (void)sendHeaders { - // TODO (mxyan): Remove after deprecated methods are removed - uint32_t callSafetyFlags = 0; - switch (_callSafety) { - case GRPCCallSafetyDefault: - callSafetyFlags = 0; - break; - case GRPCCallSafetyIdempotentRequest: - callSafetyFlags = GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST; - break; - case GRPCCallSafetyCacheableRequest: - callSafetyFlags = GRPC_INITIAL_METADATA_CACHEABLE_REQUEST; - break; - } - - NSMutableDictionary *headers = [_requestHeaders mutableCopy]; - NSString *fetchedOauth2AccessToken; - @synchronized(self) { - fetchedOauth2AccessToken = _fetchedOauth2AccessToken; - } - if (fetchedOauth2AccessToken != nil) { - headers[@"authorization"] = [kBearerPrefix stringByAppendingString:fetchedOauth2AccessToken]; - } else if (_callOptions.oauth2AccessToken != nil) { - headers[@"authorization"] = - [kBearerPrefix stringByAppendingString:_callOptions.oauth2AccessToken]; - } - - // TODO(jcanizales): Add error handlers for async failures - GRPCOpSendMetadata *op = [[GRPCOpSendMetadata alloc] - initWithMetadata:headers - flags:callSafetyFlags - handler:nil]; // No clean-up needed after SEND_INITIAL_METADATA - dispatch_async(_callQueue, ^{ - if (!self->_unaryCall) { - [self->_wrappedCall startBatchWithOperations:@[ op ]]; - } else { - [self->_unaryOpBatch addObject:op]; - } + id copiedFirstInterceptor = _firstInterceptor; + dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ + [copiedFirstInterceptor finish]; }); } - (void)receiveNextMessages:(NSUInteger)numberOfMessages { - if (numberOfMessages == 0) { - return; - } - @synchronized(self) { - _pendingReceiveNextMessages += numberOfMessages; - - if (_state != GRXWriterStateStarted || !_callOptions.flowControlEnabled) { - return; - } - [self maybeStartNextRead]; - } -} - -#pragma mark GRXWriteable implementation - -// Only called from the call queue. The error handler will be called from the -// network queue if the write didn't succeed. -// If the call is a unary call, parameter \a errorHandler will be ignored and -// the error handler of GRPCOpSendClose will be executed in case of error. -- (void)writeMessage:(NSData *)message withErrorHandler:(void (^)(void))errorHandler { - __weak GRPCCall *weakSelf = self; - void (^resumingHandler)(void) = ^{ - // Resume the request writer. - GRPCCall *strongSelf = weakSelf; - if (strongSelf) { - strongSelf->_requestWriter.state = GRXWriterStateStarted; - if (strongSelf->_writeDone) { - strongSelf->_writeDone(); - } - } - }; - GRPCOpSendMessage *op = - [[GRPCOpSendMessage alloc] initWithMessage:message handler:resumingHandler]; - if (!_unaryCall) { - [_wrappedCall startBatchWithOperations:@[ op ] errorHandler:errorHandler]; - } else { - // Ignored errorHandler since it is the same as the one for GRPCOpSendClose. - // TODO (mxyan): unify the error handlers of all Ops into a single closure. - [_unaryOpBatch addObject:op]; - } -} - -- (void)writeValue:(id)value { - NSAssert([value isKindOfClass:[NSData class]], @"value must be of type NSData"); - - @synchronized(self) { - if (_state == GRXWriterStateFinished) { - return; - } - } - - // Pause the input and only resume it when the C layer notifies us that writes - // can proceed. - _requestWriter.state = GRXWriterStatePaused; - - dispatch_async(_callQueue, ^{ - // Write error is not processed here. It is handled by op batch of GRPC_OP_RECV_STATUS_ON_CLIENT - [self writeMessage:value withErrorHandler:nil]; + id copiedFirstInterceptor = _firstInterceptor; + dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ + [copiedFirstInterceptor receiveNextMessages:numberOfMessages]; }); } -// Only called from the call queue. The error handler will be called from the -// network queue if the requests stream couldn't be closed successfully. -- (void)finishRequestWithErrorHandler:(void (^)(void))errorHandler { - if (!_unaryCall) { - [_wrappedCall startBatchWithOperations:@[ [[GRPCOpSendClose alloc] init] ] - errorHandler:errorHandler]; - } else { - [_unaryOpBatch addObject:[[GRPCOpSendClose alloc] init]]; - [_wrappedCall startBatchWithOperations:_unaryOpBatch errorHandler:errorHandler]; - } -} - -- (void)writesFinishedWithError:(NSError *)errorOrNil { - if (errorOrNil) { - [self cancel]; - } else { - dispatch_async(_callQueue, ^{ - // EOS error is not processed here. It is handled by op batch of GRPC_OP_RECV_STATUS_ON_CLIENT - [self finishRequestWithErrorHandler:nil]; - }); - } -} - -#pragma mark Invoke - -// Both handlers will eventually be called, from the network queue. Writes can start immediately -// after this. -// The first one (headersHandler), when the response headers are received. -// The second one (completionHandler), whenever the RPC finishes for any reason. -- (void)invokeCallWithHeadersHandler:(void (^)(NSDictionary *))headersHandler - completionHandler:(void (^)(NSError *, NSDictionary *))completionHandler { - dispatch_async(_callQueue, ^{ - // TODO(jcanizales): Add error handlers for async failures - [self->_wrappedCall - startBatchWithOperations:@[ [[GRPCOpRecvMetadata alloc] initWithHandler:headersHandler] ]]; - [self->_wrappedCall - startBatchWithOperations:@[ [[GRPCOpRecvStatus alloc] initWithHandler:completionHandler] ]]; - }); -} - -- (void)invokeCall { - __weak GRPCCall *weakSelf = self; - [self invokeCallWithHeadersHandler:^(NSDictionary *headers) { - // Response headers received. - __strong GRPCCall *strongSelf = weakSelf; - if (strongSelf) { - @synchronized(strongSelf) { - // it is ok to set nil because headers are only received once - strongSelf.responseHeaders = nil; - // copy the header so that the GRPCOpRecvMetadata object may be dealloc'ed - NSDictionary *copiedHeaders = - [[NSDictionary alloc] initWithDictionary:headers copyItems:YES]; - strongSelf.responseHeaders = copiedHeaders; - strongSelf->_pendingCoreRead = NO; - [strongSelf maybeStartNextRead]; - } - } - } - completionHandler:^(NSError *error, NSDictionary *trailers) { - __strong GRPCCall *strongSelf = weakSelf; - if (strongSelf) { - strongSelf.responseTrailers = trailers; - - if (error) { - NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; - if (error.userInfo) { - [userInfo addEntriesFromDictionary:error.userInfo]; - } - userInfo[kGRPCTrailersKey] = strongSelf.responseTrailers; - // Since gRPC core does not guarantee the headers block being called before this block, - // responseHeaders might be nil. - userInfo[kGRPCHeadersKey] = strongSelf.responseHeaders; - error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo]; - } - [strongSelf finishWithError:error]; - strongSelf->_requestWriter.state = GRXWriterStateFinished; - } - }]; -} - -#pragma mark GRXWriter implementation - -// Lock acquired inside startWithWriteable: -- (void)startCallWithWriteable:(id)writeable { - @synchronized(self) { - if (_state == GRXWriterStateFinished) { - return; - } - - _responseWriteable = - [[GRXConcurrentWriteable alloc] initWithWriteable:writeable dispatchQueue:_responseQueue]; - - GRPCPooledChannel *channel = - [[GRPCChannelPool sharedInstance] channelWithHost:_host callOptions:_callOptions]; - _wrappedCall = [channel wrappedCallWithPath:_path - completionQueue:[GRPCCompletionQueue completionQueue] - callOptions:_callOptions]; - - if (_wrappedCall == nil) { - [self finishWithError:[NSError errorWithDomain:kGRPCErrorDomain - code:GRPCErrorCodeUnavailable - userInfo:@{ - NSLocalizedDescriptionKey : - @"Failed to create call or channel." - }]]; - return; - } - - [self sendHeaders]; - [self invokeCall]; - } - - // Now that the RPC has been initiated, request writes can start. - [_requestWriter startWithWriteable:self]; -} - -- (void)startWithWriteable:(id)writeable { - id tokenProvider = nil; - @synchronized(self) { - _state = GRXWriterStateStarted; - - // Create a retain cycle so that this instance lives until the RPC finishes (or is cancelled). - // This makes RPCs in which the call isn't externally retained possible (as long as it is - // started before being autoreleased). Care is taken not to retain self strongly in any of the - // blocks used in this implementation, so that the life of the instance is determined by this - // retain cycle. - _retainSelf = self; - - if (_callOptions == nil) { - GRPCMutableCallOptions *callOptions = [[GRPCHost callOptionsForHost:_host] mutableCopy]; - if (_serverName.length != 0) { - callOptions.serverAuthority = _serverName; - } - if (_timeout > 0) { - callOptions.timeout = _timeout; - } - uint32_t callFlags = [GRPCCall callFlagsForHost:_host path:_path]; - if (callFlags != 0) { - if (callFlags == GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) { - _callSafety = GRPCCallSafetyIdempotentRequest; - } else if (callFlags == GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) { - _callSafety = GRPCCallSafetyCacheableRequest; - } - } - - id tokenProvider = self.tokenProvider; - if (tokenProvider != nil) { - callOptions.authTokenProvider = tokenProvider; - } - _callOptions = callOptions; - } - - NSAssert(_callOptions.authTokenProvider == nil || _callOptions.oauth2AccessToken == nil, - @"authTokenProvider and oauth2AccessToken cannot be set at the same time"); - - tokenProvider = _callOptions.authTokenProvider; - } - - if (tokenProvider != nil) { - __weak typeof(self) weakSelf = self; - [tokenProvider getTokenWithHandler:^(NSString *token) { - __strong typeof(self) strongSelf = weakSelf; - if (strongSelf) { - BOOL startCall = NO; - @synchronized(strongSelf) { - if (strongSelf->_state != GRXWriterStateFinished) { - startCall = YES; - if (token) { - strongSelf->_fetchedOauth2AccessToken = [token copy]; - } - } - } - if (startCall) { - [strongSelf startCallWithWriteable:writeable]; - } - } - }]; - } else { - [self startCallWithWriteable:writeable]; - } -} - -- (void)setState:(GRXWriterState)newState { - @synchronized(self) { - // Manual transitions are only allowed from the started or paused states. - if (_state == GRXWriterStateNotStarted || _state == GRXWriterStateFinished) { - return; - } - - switch (newState) { - case GRXWriterStateFinished: - _state = newState; - // Per GRXWriter's contract, setting the state to Finished manually - // means one doesn't wish the writeable to be messaged anymore. - [_responseWriteable cancelSilently]; - _responseWriteable = nil; - return; - case GRXWriterStatePaused: - _state = newState; - return; - case GRXWriterStateStarted: - if (_state == GRXWriterStatePaused) { - _state = newState; - [self maybeStartNextRead]; - } - return; - case GRXWriterStateNotStarted: - return; - } - } -} - @end diff --git a/src/objective-c/GRPCClient/GRPCCallLegacy.h b/src/objective-c/GRPCClient/GRPCCallLegacy.h new file mode 100644 index 00000000000..6c2c8ceada8 --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCCallLegacy.h @@ -0,0 +1,136 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/** + * This is the legacy interface of this gRPC library. This API is deprecated and users should use + * the API in GRPCCall.h. This API exists solely for the purpose of backwards compatibility. + */ + +#import "GRPCCallOptions.h" +#import + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnullability-completeness" + +/** + * This interface is deprecated. Please use \a GRPCCall2. + * + * Represents a single gRPC remote call. + */ +@interface GRPCCall : GRXWriter + +- (instancetype)init NS_UNAVAILABLE; + +/** + * The container of the request headers of an RPC conforms to this protocol, which is a subset of + * NSMutableDictionary's interface. It will become a NSMutableDictionary later on. + * The keys of this container are the header names, which per the HTTP standard are case- + * insensitive. They are stored in lowercase (which is how HTTP/2 mandates them on the wire), and + * can only consist of ASCII characters. + * A header value is a NSString object (with only ASCII characters), unless the header name has the + * suffix "-bin", in which case the value has to be a NSData object. + */ +/** + * These HTTP headers will be passed to the server as part of this call. Each HTTP header is a + * name-value pair with string names and either string or binary values. + * + * The passed dictionary has to use NSString keys, corresponding to the header names. The value + * associated to each can be a NSString object or a NSData object. E.g.: + * + * call.requestHeaders = @{@"authorization": @"Bearer ..."}; + * + * call.requestHeaders[@"my-header-bin"] = someData; + * + * After the call is started, trying to modify this property is an error. + * + * The property is initialized to an empty NSMutableDictionary. + */ +@property(atomic, readonly) NSMutableDictionary *requestHeaders; + +/** + * This dictionary is populated with the HTTP headers received from the server. This happens before + * any response message is received from the server. It has the same structure as the request + * headers dictionary: Keys are NSString header names; names ending with the suffix "-bin" have a + * NSData value; the others have a NSString value. + * + * The value of this property is nil until all response headers are received, and will change before + * any of -writeValue: or -writesFinishedWithError: are sent to the writeable. + */ +@property(atomic, readonly) NSDictionary *responseHeaders; + +/** + * Same as responseHeaders, but populated with the HTTP trailers received from the server before the + * call finishes. + * + * The value of this property is nil until all response trailers are received, and will change + * before -writesFinishedWithError: is sent to the writeable. + */ +@property(atomic, readonly) NSDictionary *responseTrailers; + +/** + * The request writer has to write NSData objects into the provided Writeable. The server will + * receive each of those separately and in order as distinct messages. + * A gRPC call might not complete until the request writer finishes. On the other hand, the request + * finishing doesn't necessarily make the call to finish, as the server might continue sending + * messages to the response side of the call indefinitely (depending on the semantics of the + * specific remote method called). + * To finish a call right away, invoke cancel. + * host parameter should not contain the scheme (http:// or https://), only the name or IP addr + * and the port number, for example @"localhost:5050". + */ +- (instancetype)initWithHost:(NSString *)host + path:(NSString *)path + requestsWriter:(GRXWriter *)requestWriter; + +/** + * Finishes the request side of this call, notifies the server that the RPC should be cancelled, and + * finishes the response side of the call with an error of code CANCELED. + */ +- (void)cancel; + +/** + * The following methods are deprecated. + */ ++ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path; +@property(atomic, copy, readwrite) NSString *serverName; +@property NSTimeInterval timeout; +- (void)setResponseDispatchQueue:(dispatch_queue_t)queue; + +@end + +#pragma mark Backwards compatibiity + +/** This protocol is kept for backwards compatibility with existing code. */ +DEPRECATED_MSG_ATTRIBUTE("Use NSDictionary or NSMutableDictionary instead.") +@protocol GRPCRequestHeaders +@property(nonatomic, readonly) NSUInteger count; + +- (id)objectForKeyedSubscript:(id)key; +- (void)setObject:(id)obj forKeyedSubscript:(id)key; + +- (void)removeAllObjects; +- (void)removeObjectForKey:(id)key; +@end + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated" +/** This is only needed for backwards-compatibility. */ +@interface NSMutableDictionary (GRPCRequestHeaders) +@end +#pragma clang diagnostic pop +#pragma clang diagnostic pop diff --git a/src/objective-c/GRPCClient/GRPCCallLegacy.m b/src/objective-c/GRPCClient/GRPCCallLegacy.m new file mode 100644 index 00000000000..18a1eda1b39 --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCCallLegacy.m @@ -0,0 +1,679 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "GRPCCallLegacy.h" + +#import "GRPCCall+OAuth2.h" +#import "GRPCCallOptions.h" +#import "GRPCCall+Cronet.h" + +#import "private/GRPCCore/GRPCChannelPool.h" +#import "private/GRPCCore/GRPCCompletionQueue.h" +#import "private/GRPCCore/GRPCHost.h" +#import "private/GRPCCore/GRPCWrappedCall.h" +#import "private/GRPCCore/NSData+GRPC.h" + +#import +#import +#import +#import + +#include + +const char *kCFStreamVarName = "grpc_cfstream"; +static NSMutableDictionary *callFlags; + +// At most 6 ops can be in an op batch for a client: SEND_INITIAL_METADATA, +// SEND_MESSAGE, SEND_CLOSE_FROM_CLIENT, RECV_INITIAL_METADATA, RECV_MESSAGE, +// and RECV_STATUS_ON_CLIENT. +NSInteger kMaxClientBatch = 6; + +static NSString *const kAuthorizationHeader = @"authorization"; +static NSString *const kBearerPrefix = @"Bearer "; + +@interface GRPCCall () +// Make them read-write. +@property(atomic, strong) NSDictionary *responseHeaders; +@property(atomic, strong) NSDictionary *responseTrailers; + +- (void)receiveNextMessages:(NSUInteger)numberOfMessages; + +@end + +// The following methods of a C gRPC call object aren't reentrant, and thus +// calls to them must be serialized: +// - start_batch +// - destroy +// +// start_batch with a SEND_MESSAGE argument can only be called after the +// OP_COMPLETE event for any previous write is received. This is achieved by +// pausing the requests writer immediately every time it writes a value, and +// resuming it again when OP_COMPLETE is received. +// +// Similarly, start_batch with a RECV_MESSAGE argument can only be called after +// the OP_COMPLETE event for any previous read is received.This is easier to +// enforce, as we're writing the received messages into the writeable: +// start_batch is enqueued once upon receiving the OP_COMPLETE event for the +// RECV_METADATA batch, and then once after receiving each OP_COMPLETE event for +// each RECV_MESSAGE batch. +@implementation GRPCCall { + dispatch_queue_t _callQueue; + + NSString *_host; + NSString *_path; + GRPCCallSafety _callSafety; + GRPCCallOptions *_callOptions; + GRPCWrappedCall *_wrappedCall; + + // The C gRPC library has less guarantees on the ordering of events than we + // do. Particularly, in the face of errors, there's no ordering guarantee at + // all. This wrapper over our actual writeable ensures thread-safety and + // correct ordering. + GRXConcurrentWriteable *_responseWriteable; + + // The network thread wants the requestWriter to resume (when the server is ready for more input), + // or to stop (on errors), concurrently with user threads that want to start it, pause it or stop + // it. Because a writer isn't thread-safe, we'll synchronize those operations on it. + // We don't use a dispatch queue for that purpose, because the writer can call writeValue: or + // writesFinishedWithError: on this GRPCCall as part of those operations. We want to be able to + // pause the writer immediately on writeValue:, so we need our locking to be recursive. + GRXWriter *_requestWriter; + + // To create a retain cycle when a call is started, up until it finishes. See + // |startWithWriteable:| and |finishWithError:|. This saves users from having to retain a + // reference to the call object if all they're interested in is the handler being executed when + // the response arrives. + GRPCCall *_retainSelf; + + GRPCRequestHeaders *_requestHeaders; + + // In the case that the call is a unary call (i.e. the writer to GRPCCall is of type + // GRXImmediateSingleWriter), GRPCCall will delay sending ops (not send them to C core + // immediately) and buffer them into a batch _unaryOpBatch. The batch is sent to C core when + // the SendClose op is added. + BOOL _unaryCall; + NSMutableArray *_unaryOpBatch; + + // The dispatch queue to be used for enqueuing responses to user. Defaulted to the main dispatch + // queue + dispatch_queue_t _responseQueue; + + // The OAuth2 token fetched from a token provider. + NSString *_fetchedOauth2AccessToken; + + // The callback to be called when a write message op is done. + void (^_writeDone)(void); + + // Indicate a read request to core is pending. + BOOL _pendingCoreRead; + + // Indicate pending read message request from user. + NSUInteger _pendingReceiveNextMessages; +} + +@synthesize state = _state; + ++ (void)initialize { + // Guarantees the code in {} block is invoked only once. See ref at: + // https://developer.apple.com/documentation/objectivec/nsobject/1418639-initialize?language=objc + if (self == [GRPCCall self]) { + grpc_init(); + callFlags = [NSMutableDictionary dictionary]; + } +} + ++ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path { + if (host.length == 0 || path.length == 0) { + return; + } + NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path]; + @synchronized(callFlags) { + switch (callSafety) { + case GRPCCallSafetyDefault: + callFlags[hostAndPath] = @0; + break; + case GRPCCallSafetyIdempotentRequest: + callFlags[hostAndPath] = @GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST; + break; + case GRPCCallSafetyCacheableRequest: + callFlags[hostAndPath] = @GRPC_INITIAL_METADATA_CACHEABLE_REQUEST; + break; + default: + break; + } + } +} + ++ (uint32_t)callFlagsForHost:(NSString *)host path:(NSString *)path { + NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path]; + @synchronized(callFlags) { + return [callFlags[hostAndPath] intValue]; + } +} + +- (instancetype)initWithHost:(NSString *)host + path:(NSString *)path + requestsWriter:(GRXWriter *)requestWriter { + return [self initWithHost:host + path:path + callSafety:GRPCCallSafetyDefault + requestsWriter:requestWriter + callOptions:nil + writeDone:nil]; +} + +- (instancetype)initWithHost:(NSString *)host + path:(NSString *)path + callSafety:(GRPCCallSafety)safety + requestsWriter:(GRXWriter *)requestsWriter + callOptions:(GRPCCallOptions *)callOptions + writeDone:(void (^)(void))writeDone { + // Purposely using pointer rather than length (host.length == 0) for backwards compatibility. + NSAssert(host != nil && path != nil, @"Neither host nor path can be nil."); + NSAssert(safety <= GRPCCallSafetyCacheableRequest, @"Invalid call safety value."); + NSAssert(requestsWriter.state == GRXWriterStateNotStarted, + @"The requests writer can't be already started."); + if (!host || !path) { + return nil; + } + if (safety > GRPCCallSafetyCacheableRequest) { + return nil; + } + if (requestsWriter.state != GRXWriterStateNotStarted) { + return nil; + } + + if ((self = [super init])) { + _host = [host copy]; + _path = [path copy]; + _callSafety = safety; + _callOptions = [callOptions copy]; + + // Serial queue to invoke the non-reentrant methods of the grpc_call object. + _callQueue = dispatch_queue_create("io.grpc.call", DISPATCH_QUEUE_SERIAL); + + _requestWriter = requestsWriter; + _requestHeaders = [[GRPCRequestHeaders alloc] initWithCall:self]; + _writeDone = writeDone; + + if ([requestsWriter isKindOfClass:[GRXImmediateSingleWriter class]]) { + _unaryCall = YES; + _unaryOpBatch = [NSMutableArray arrayWithCapacity:kMaxClientBatch]; + } + + _responseQueue = dispatch_get_main_queue(); + + // do not start a read until initial metadata is received + _pendingReceiveNextMessages = 0; + _pendingCoreRead = YES; + } + return self; +} + +- (void)setResponseDispatchQueue:(dispatch_queue_t)queue { + @synchronized(self) { + if (_state != GRXWriterStateNotStarted) { + return; + } + _responseQueue = queue; + } +} + +#pragma mark Finish + +// This function should support being called within a @synchronized(self) block in another function +// Should not manipulate _requestWriter for deadlock prevention. +- (void)finishWithError:(NSError *)errorOrNil { + @synchronized(self) { + if (_state == GRXWriterStateFinished) { + return; + } + _state = GRXWriterStateFinished; + + if (errorOrNil) { + [_responseWriteable cancelWithError:errorOrNil]; + } else { + [_responseWriteable enqueueSuccessfulCompletion]; + } + + // If the call isn't retained anywhere else, it can be deallocated now. + _retainSelf = nil; + } +} + +- (void)cancel { + @synchronized(self) { + if (_state == GRXWriterStateFinished) { + return; + } + [self finishWithError:[NSError + errorWithDomain:kGRPCErrorDomain + code:GRPCErrorCodeCancelled + userInfo:@{NSLocalizedDescriptionKey : @"Canceled by app"}]]; + [_wrappedCall cancel]; + } + _requestWriter.state = GRXWriterStateFinished; +} + +- (void)dealloc { + __block GRPCWrappedCall *wrappedCall = _wrappedCall; + dispatch_async(_callQueue, ^{ + wrappedCall = nil; + }); +} + +#pragma mark Read messages + +// Only called from the call queue. +// The handler will be called from the network queue. +- (void)startReadWithHandler:(void (^)(grpc_byte_buffer *))handler { + // TODO(jcanizales): Add error handlers for async failures + [_wrappedCall startBatchWithOperations:@[ [[GRPCOpRecvMessage alloc] initWithHandler:handler] ]]; +} + +// Called initially from the network queue once response headers are received, +// then "recursively" from the responseWriteable queue after each response from the +// server has been written. +// If the call is currently paused, this is a noop. Restarting the call will invoke this +// method. +// TODO(jcanizales): Rename to readResponseIfNotPaused. +- (void)maybeStartNextRead { + @synchronized(self) { + if (_state != GRXWriterStateStarted) { + return; + } + if (_callOptions.flowControlEnabled && (_pendingCoreRead || _pendingReceiveNextMessages == 0)) { + return; + } + _pendingCoreRead = YES; + _pendingReceiveNextMessages--; + } + + dispatch_async(_callQueue, ^{ + __weak GRPCCall *weakSelf = self; + [self startReadWithHandler:^(grpc_byte_buffer *message) { + if (message == NULL) { + // No more messages from the server + return; + } + __strong GRPCCall *strongSelf = weakSelf; + if (strongSelf == nil) { + grpc_byte_buffer_destroy(message); + return; + } + NSData *data = [NSData grpc_dataWithByteBuffer:message]; + grpc_byte_buffer_destroy(message); + if (!data) { + // The app doesn't have enough memory to hold the server response. We + // don't want to throw, because the app shouldn't crash for a behavior + // that's on the hands of any server to have. Instead we finish and ask + // the server to cancel. + @synchronized(strongSelf) { + strongSelf->_pendingCoreRead = NO; + [strongSelf + finishWithError:[NSError errorWithDomain:kGRPCErrorDomain + code:GRPCErrorCodeResourceExhausted + userInfo:@{ + NSLocalizedDescriptionKey : + @"Client does not have enough memory to " + @"hold the server response." + }]]; + [strongSelf->_wrappedCall cancel]; + } + strongSelf->_requestWriter.state = GRXWriterStateFinished; + } else { + @synchronized(strongSelf) { + [strongSelf->_responseWriteable enqueueValue:data + completionHandler:^{ + __strong GRPCCall *strongSelf = weakSelf; + if (strongSelf) { + @synchronized(strongSelf) { + strongSelf->_pendingCoreRead = NO; + [strongSelf maybeStartNextRead]; + } + } + }]; + } + } + }]; + }); +} + +#pragma mark Send headers + +- (void)sendHeaders { + // TODO (mxyan): Remove after deprecated methods are removed + uint32_t callSafetyFlags = 0; + switch (_callSafety) { + case GRPCCallSafetyDefault: + callSafetyFlags = 0; + break; + case GRPCCallSafetyIdempotentRequest: + callSafetyFlags = GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST; + break; + case GRPCCallSafetyCacheableRequest: + callSafetyFlags = GRPC_INITIAL_METADATA_CACHEABLE_REQUEST; + break; + } + + NSMutableDictionary *headers = [_requestHeaders mutableCopy]; + NSString *fetchedOauth2AccessToken; + @synchronized(self) { + fetchedOauth2AccessToken = _fetchedOauth2AccessToken; + } + if (fetchedOauth2AccessToken != nil) { + headers[@"authorization"] = [kBearerPrefix stringByAppendingString:fetchedOauth2AccessToken]; + } else if (_callOptions.oauth2AccessToken != nil) { + headers[@"authorization"] = + [kBearerPrefix stringByAppendingString:_callOptions.oauth2AccessToken]; + } + + // TODO(jcanizales): Add error handlers for async failures + GRPCOpSendMetadata *op = [[GRPCOpSendMetadata alloc] + initWithMetadata:headers + flags:callSafetyFlags + handler:nil]; // No clean-up needed after SEND_INITIAL_METADATA + dispatch_async(_callQueue, ^{ + if (!self->_unaryCall) { + [self->_wrappedCall startBatchWithOperations:@[ op ]]; + } else { + [self->_unaryOpBatch addObject:op]; + } + }); +} + +- (void)receiveNextMessages:(NSUInteger)numberOfMessages { + if (numberOfMessages == 0) { + return; + } + @synchronized(self) { + _pendingReceiveNextMessages += numberOfMessages; + + if (_state != GRXWriterStateStarted || !_callOptions.flowControlEnabled) { + return; + } + [self maybeStartNextRead]; + } +} + +#pragma mark GRXWriteable implementation + +// Only called from the call queue. The error handler will be called from the +// network queue if the write didn't succeed. +// If the call is a unary call, parameter \a errorHandler will be ignored and +// the error handler of GRPCOpSendClose will be executed in case of error. +- (void)writeMessage:(NSData *)message withErrorHandler:(void (^)(void))errorHandler { + __weak GRPCCall *weakSelf = self; + void (^resumingHandler)(void) = ^{ + // Resume the request writer. + GRPCCall *strongSelf = weakSelf; + if (strongSelf) { + strongSelf->_requestWriter.state = GRXWriterStateStarted; + if (strongSelf->_writeDone) { + strongSelf->_writeDone(); + } + } + }; + GRPCOpSendMessage *op = + [[GRPCOpSendMessage alloc] initWithMessage:message handler:resumingHandler]; + if (!_unaryCall) { + [_wrappedCall startBatchWithOperations:@[ op ] errorHandler:errorHandler]; + } else { + // Ignored errorHandler since it is the same as the one for GRPCOpSendClose. + // TODO (mxyan): unify the error handlers of all Ops into a single closure. + [_unaryOpBatch addObject:op]; + } +} + +- (void)writeValue:(id)value { + NSAssert([value isKindOfClass:[NSData class]], @"value must be of type NSData"); + + @synchronized(self) { + if (_state == GRXWriterStateFinished) { + return; + } + } + + // Pause the input and only resume it when the C layer notifies us that writes + // can proceed. + _requestWriter.state = GRXWriterStatePaused; + + dispatch_async(_callQueue, ^{ + // Write error is not processed here. It is handled by op batch of GRPC_OP_RECV_STATUS_ON_CLIENT + [self writeMessage:value withErrorHandler:nil]; + }); +} + +// Only called from the call queue. The error handler will be called from the +// network queue if the requests stream couldn't be closed successfully. +- (void)finishRequestWithErrorHandler:(void (^)(void))errorHandler { + if (!_unaryCall) { + [_wrappedCall startBatchWithOperations:@[ [[GRPCOpSendClose alloc] init] ] + errorHandler:errorHandler]; + } else { + [_unaryOpBatch addObject:[[GRPCOpSendClose alloc] init]]; + [_wrappedCall startBatchWithOperations:_unaryOpBatch errorHandler:errorHandler]; + } +} + +- (void)writesFinishedWithError:(NSError *)errorOrNil { + if (errorOrNil) { + [self cancel]; + } else { + dispatch_async(_callQueue, ^{ + // EOS error is not processed here. It is handled by op batch of GRPC_OP_RECV_STATUS_ON_CLIENT + [self finishRequestWithErrorHandler:nil]; + }); + } +} + +#pragma mark Invoke + +// Both handlers will eventually be called, from the network queue. Writes can start immediately +// after this. +// The first one (headersHandler), when the response headers are received. +// The second one (completionHandler), whenever the RPC finishes for any reason. +- (void)invokeCallWithHeadersHandler:(void (^)(NSDictionary *))headersHandler + completionHandler:(void (^)(NSError *, NSDictionary *))completionHandler { + dispatch_async(_callQueue, ^{ + // TODO(jcanizales): Add error handlers for async failures + [self->_wrappedCall + startBatchWithOperations:@[ [[GRPCOpRecvMetadata alloc] initWithHandler:headersHandler] ]]; + [self->_wrappedCall + startBatchWithOperations:@[ [[GRPCOpRecvStatus alloc] initWithHandler:completionHandler] ]]; + }); +} + +- (void)invokeCall { + __weak GRPCCall *weakSelf = self; + [self invokeCallWithHeadersHandler:^(NSDictionary *headers) { + // Response headers received. + __strong GRPCCall *strongSelf = weakSelf; + if (strongSelf) { + @synchronized(strongSelf) { + // it is ok to set nil because headers are only received once + strongSelf.responseHeaders = nil; + // copy the header so that the GRPCOpRecvMetadata object may be dealloc'ed + NSDictionary *copiedHeaders = + [[NSDictionary alloc] initWithDictionary:headers copyItems:YES]; + strongSelf.responseHeaders = copiedHeaders; + strongSelf->_pendingCoreRead = NO; + [strongSelf maybeStartNextRead]; + } + } + } + completionHandler:^(NSError *error, NSDictionary *trailers) { + __strong GRPCCall *strongSelf = weakSelf; + if (strongSelf) { + strongSelf.responseTrailers = trailers; + + if (error) { + NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; + if (error.userInfo) { + [userInfo addEntriesFromDictionary:error.userInfo]; + } + userInfo[kGRPCTrailersKey] = strongSelf.responseTrailers; + // Since gRPC core does not guarantee the headers block being called before this block, + // responseHeaders might be nil. + userInfo[kGRPCHeadersKey] = strongSelf.responseHeaders; + error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo]; + } + [strongSelf finishWithError:error]; + strongSelf->_requestWriter.state = GRXWriterStateFinished; + } + }]; +} + +#pragma mark GRXWriter implementation + +// Lock acquired inside startWithWriteable: +- (void)startCallWithWriteable:(id)writeable { + @synchronized(self) { + if (_state == GRXWriterStateFinished) { + return; + } + + _responseWriteable = + [[GRXConcurrentWriteable alloc] initWithWriteable:writeable dispatchQueue:_responseQueue]; + + GRPCPooledChannel *channel = + [[GRPCChannelPool sharedInstance] channelWithHost:_host callOptions:_callOptions]; + _wrappedCall = [channel wrappedCallWithPath:_path + completionQueue:[GRPCCompletionQueue completionQueue] + callOptions:_callOptions]; + + if (_wrappedCall == nil) { + [self finishWithError:[NSError errorWithDomain:kGRPCErrorDomain + code:GRPCErrorCodeUnavailable + userInfo:@{ + NSLocalizedDescriptionKey : + @"Failed to create call or channel." + }]]; + return; + } + + [self sendHeaders]; + [self invokeCall]; + } + + // Now that the RPC has been initiated, request writes can start. + [_requestWriter startWithWriteable:self]; +} + +- (void)startWithWriteable:(id)writeable { + id tokenProvider = nil; + @synchronized(self) { + _state = GRXWriterStateStarted; + + // Create a retain cycle so that this instance lives until the RPC finishes (or is cancelled). + // This makes RPCs in which the call isn't externally retained possible (as long as it is + // started before being autoreleased). Care is taken not to retain self strongly in any of the + // blocks used in this implementation, so that the life of the instance is determined by this + // retain cycle. + _retainSelf = self; + + if (_callOptions == nil) { + GRPCMutableCallOptions *callOptions = [[GRPCHost callOptionsForHost:_host] mutableCopy]; + // By v1 API logic, insecure channel precedes Cronet channel; Cronet channel preceeds default + // channel. We maintain backwards compatibility here with v1 API by keep this logic. + if (callOptions.transport == GRPCTransportTypeDefault && [GRPCCall isUsingCronet]) { + callOptions.transport = gGRPCCoreCronetId; + } + if (_serverName.length != 0) { + callOptions.serverAuthority = _serverName; + } + if (_timeout > 0) { + callOptions.timeout = _timeout; + } + uint32_t callFlags = [GRPCCall callFlagsForHost:_host path:_path]; + if (callFlags != 0) { + if (callFlags == GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) { + _callSafety = GRPCCallSafetyIdempotentRequest; + } else if (callFlags == GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) { + _callSafety = GRPCCallSafetyCacheableRequest; + } + } + + id tokenProvider = self.tokenProvider; + if (tokenProvider != nil) { + callOptions.authTokenProvider = tokenProvider; + } + _callOptions = callOptions; + } + + NSAssert(_callOptions.authTokenProvider == nil || _callOptions.oauth2AccessToken == nil, + @"authTokenProvider and oauth2AccessToken cannot be set at the same time"); + + tokenProvider = _callOptions.authTokenProvider; + } + + if (tokenProvider != nil) { + __weak typeof(self) weakSelf = self; + [tokenProvider getTokenWithHandler:^(NSString *token) { + __strong typeof(self) strongSelf = weakSelf; + if (strongSelf) { + BOOL startCall = NO; + @synchronized(strongSelf) { + if (strongSelf->_state != GRXWriterStateFinished) { + startCall = YES; + if (token) { + strongSelf->_fetchedOauth2AccessToken = [token copy]; + } + } + } + if (startCall) { + [strongSelf startCallWithWriteable:writeable]; + } + } + }]; + } else { + [self startCallWithWriteable:writeable]; + } +} + +- (void)setState:(GRXWriterState)newState { + @synchronized(self) { + // Manual transitions are only allowed from the started or paused states. + if (_state == GRXWriterStateNotStarted || _state == GRXWriterStateFinished) { + return; + } + + switch (newState) { + case GRXWriterStateFinished: + _state = newState; + // Per GRXWriter's contract, setting the state to Finished manually + // means one doesn't wish the writeable to be messaged anymore. + [_responseWriteable cancelSilently]; + _responseWriteable = nil; + return; + case GRXWriterStatePaused: + _state = newState; + return; + case GRXWriterStateStarted: + if (_state == GRXWriterStatePaused) { + _state = newState; + [self maybeStartNextRead]; + } + return; + case GRXWriterStateNotStarted: + return; + } + } +} + +@end diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.h b/src/objective-c/GRPCClient/GRPCCallOptions.h index 98511e3f5cb..80c0244d78d 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.h +++ b/src/objective-c/GRPCClient/GRPCCallOptions.h @@ -20,6 +20,9 @@ NS_ASSUME_NONNULL_BEGIN +typedef char *GRPCTransportId; +@protocol GRPCInterceptorFactory; + /** * Safety remark of a gRPC method as defined in RFC 2616 Section 9.1 */ @@ -104,7 +107,7 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { * this array. This parameter should not be modified by any interceptor and will * not take effect if done so. */ -@property(copy, readonly) NSArray *interceptorFactories; +@property(copy, readonly) NSArray> *interceptorFactories; // OAuth2 parameters. Users of gRPC may specify one of the following two parameters. @@ -192,10 +195,21 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { @property(copy, readonly, nullable) NSString *PEMCertificateChain; /** + * Deprecated: this option is deprecated. Please use the property \a transport + * instead. + * * Select the transport type to be used for this call. */ @property(readonly) GRPCTransportType transportType; +/** + * The transport to be used for this call. Users may choose a native transport + * identifier defined in \a GRPCTransport or provided by a non-native transport + * implementation. If the option is left to be NULL, gRPC will use its default + * transport. + */ +@property(readonly) GRPCTransportId transport; + /** * Override the hostname during the TLS hostname validation process. */ @@ -267,7 +281,7 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { * this array. This parameter should not be modified by any interceptor and will * not take effect if done so. */ -@property(copy, readwrite) NSArray *interceptorFactories; +@property(copy, readwrite) NSArray> *interceptorFactories; // OAuth2 parameters. Users of gRPC may specify one of the following two parameters. @@ -357,10 +371,23 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { @property(copy, readwrite, nullable) NSString *PEMCertificateChain; /** + * Deprecated: this option is deprecated. Please use the property \a transport + * instead. + * * Select the transport type to be used for this call. */ @property(readwrite) GRPCTransportType transportType; +/** + * The transport to be used for this call. Users may choose a native transport + * identifier defined in \a GRPCTransport or provided by a non-native ttransport + * implementation. If the option is left to be NULL, gRPC will use its default + * transport. + * + * An interceptor must not change the value of this option. + */ +@property(readwrite) GRPCTransportId transport; + /** * Override the hostname during the TLS hostname validation process. */ diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.m b/src/objective-c/GRPCClient/GRPCCallOptions.m index 392e42a9d47..2080f9915a9 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.m +++ b/src/objective-c/GRPCClient/GRPCCallOptions.m @@ -18,12 +18,13 @@ #import "GRPCCallOptions.h" #import "internal/GRPCCallOptions+Internal.h" +#import "GRPCTransport.h" // The default values for the call options. static NSString *const kDefaultServerAuthority = nil; static const NSTimeInterval kDefaultTimeout = 0; static const BOOL kDefaultFlowControlEnabled = NO; -static NSArray *const kDefaultInterceptorFactories = nil; +static NSArray> *const kDefaultInterceptorFactories = nil; static NSDictionary *const kDefaultInitialMetadata = nil; static NSString *const kDefaultUserAgentPrefix = nil; static const NSUInteger kDefaultResponseSizeLimit = 0; @@ -41,6 +42,7 @@ static NSString *const kDefaultPEMCertificateChain = nil; static NSString *const kDefaultOauth2AccessToken = nil; static const id kDefaultAuthTokenProvider = nil; static const GRPCTransportType kDefaultTransportType = GRPCTransportTypeChttp2BoringSSL; +static const GRPCTransportId kDefaultTransport = NULL; static NSString *const kDefaultHostNameOverride = nil; static const id kDefaultLogContext = nil; static NSString *const kDefaultChannelPoolDomain = nil; @@ -62,7 +64,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { NSString *_serverAuthority; NSTimeInterval _timeout; BOOL _flowControlEnabled; - NSArray *_interceptorFactories; + NSArray> *_interceptorFactories; NSString *_oauth2AccessToken; id _authTokenProvider; NSDictionary *_initialMetadata; @@ -80,6 +82,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { NSString *_PEMPrivateKey; NSString *_PEMCertificateChain; GRPCTransportType _transportType; + GRPCTransportId _transport; NSString *_hostNameOverride; id _logContext; NSString *_channelPoolDomain; @@ -107,6 +110,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { @synthesize PEMPrivateKey = _PEMPrivateKey; @synthesize PEMCertificateChain = _PEMCertificateChain; @synthesize transportType = _transportType; +@synthesize transport = _transport; @synthesize hostNameOverride = _hostNameOverride; @synthesize logContext = _logContext; @synthesize channelPoolDomain = _channelPoolDomain; @@ -134,6 +138,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:kDefaultPEMPrivateKey PEMCertificateChain:kDefaultPEMCertificateChain transportType:kDefaultTransportType + transport:kDefaultTransport hostNameOverride:kDefaultHostNameOverride logContext:kDefaultLogContext channelPoolDomain:kDefaultChannelPoolDomain @@ -143,7 +148,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { - (instancetype)initWithServerAuthority:(NSString *)serverAuthority timeout:(NSTimeInterval)timeout flowControlEnabled:(BOOL)flowControlEnabled - interceptorFactories:(NSArray *)interceptorFactories + interceptorFactories:(NSArray> *)interceptorFactories oauth2AccessToken:(NSString *)oauth2AccessToken authTokenProvider:(id)authTokenProvider initialMetadata:(NSDictionary *)initialMetadata @@ -161,6 +166,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:(NSString *)PEMPrivateKey PEMCertificateChain:(NSString *)PEMCertificateChain transportType:(GRPCTransportType)transportType + transport:(GRPCTransportId)transport hostNameOverride:(NSString *)hostNameOverride logContext:(id)logContext channelPoolDomain:(NSString *)channelPoolDomain @@ -193,6 +199,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { _PEMPrivateKey = [PEMPrivateKey copy]; _PEMCertificateChain = [PEMCertificateChain copy]; _transportType = transportType; + _transport = transport; _hostNameOverride = [hostNameOverride copy]; _logContext = logContext; _channelPoolDomain = [channelPoolDomain copy]; @@ -224,6 +231,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:_PEMPrivateKey PEMCertificateChain:_PEMCertificateChain transportType:_transportType + transport:_transport hostNameOverride:_hostNameOverride logContext:_logContext channelPoolDomain:_channelPoolDomain @@ -256,6 +264,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:[_PEMPrivateKey copy] PEMCertificateChain:[_PEMCertificateChain copy] transportType:_transportType + transport:_transport hostNameOverride:[_hostNameOverride copy] logContext:_logContext channelPoolDomain:[_channelPoolDomain copy] @@ -280,6 +289,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { if (!areObjectsEqual(callOptions.PEMCertificateChain, _PEMCertificateChain)) return NO; if (!areObjectsEqual(callOptions.hostNameOverride, _hostNameOverride)) return NO; if (!(callOptions.transportType == _transportType)) return NO; + if (!(TransportIdIsEqual(callOptions.transport, _transport))) return NO; if (!areObjectsEqual(callOptions.logContext, _logContext)) return NO; if (!areObjectsEqual(callOptions.channelPoolDomain, _channelPoolDomain)) return NO; if (!(callOptions.channelID == _channelID)) return NO; @@ -304,6 +314,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { result ^= _PEMCertificateChain.hash; result ^= _hostNameOverride.hash; result ^= _transportType; + result ^= TransportIdHash(_transport); result ^= _logContext.hash; result ^= _channelPoolDomain.hash; result ^= _channelID; @@ -336,6 +347,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { @dynamic PEMPrivateKey; @dynamic PEMCertificateChain; @dynamic transportType; +@dynamic transport; @dynamic hostNameOverride; @dynamic logContext; @dynamic channelPoolDomain; @@ -363,6 +375,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:kDefaultPEMPrivateKey PEMCertificateChain:kDefaultPEMCertificateChain transportType:kDefaultTransportType + transport:kDefaultTransport hostNameOverride:kDefaultHostNameOverride logContext:kDefaultLogContext channelPoolDomain:kDefaultChannelPoolDomain @@ -392,6 +405,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:_PEMPrivateKey PEMCertificateChain:_PEMCertificateChain transportType:_transportType + transport:_transport hostNameOverride:_hostNameOverride logContext:_logContext channelPoolDomain:_channelPoolDomain @@ -422,6 +436,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:_PEMPrivateKey PEMCertificateChain:_PEMCertificateChain transportType:_transportType + transport:_transport hostNameOverride:_hostNameOverride logContext:_logContext channelPoolDomain:_channelPoolDomain @@ -445,7 +460,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { _flowControlEnabled = flowControlEnabled; } -- (void)setInterceptorFactories:(NSArray *)interceptorFactories { +- (void)setInterceptorFactories:(NSArray> *)interceptorFactories { _interceptorFactories = interceptorFactories; } @@ -538,6 +553,10 @@ static BOOL areObjectsEqual(id obj1, id obj2) { _transportType = transportType; } +- (void)setTransport:(GRPCTransportId)transport { + _transport = transport; +} + - (void)setHostNameOverride:(NSString *)hostNameOverride { _hostNameOverride = [hostNameOverride copy]; } diff --git a/src/objective-c/GRPCClient/GRPCDispatchable.h b/src/objective-c/GRPCClient/GRPCDispatchable.h new file mode 100644 index 00000000000..3322766e3bc --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCDispatchable.h @@ -0,0 +1,30 @@ + +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/** + * An object that process its methods with a dispatch queue. + */ +@protocol GRPCDispatchable + +/** + * The dispatch queue where the object's methods should be run on. + */ +@property(atomic, readonly) dispatch_queue_t dispatchQueue; + +@end diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.h b/src/objective-c/GRPCClient/GRPCInterceptor.h index 3b62c1b3ec0..f8a97ac13e8 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.h +++ b/src/objective-c/GRPCClient/GRPCInterceptor.h @@ -106,22 +106,20 @@ */ #import "GRPCCall.h" +#import "GRPCDispatchable.h" NS_ASSUME_NONNULL_BEGIN @class GRPCInterceptorManager; @class GRPCInterceptor; +@class GRPCRequestOptions; +@class GRPCCallOptions; +@protocol GRPCResponseHandler; /** * The GRPCInterceptorInterface defines the request events that can occur to an interceptr. */ -@protocol GRPCInterceptorInterface - -/** - * The queue on which all methods of this interceptor should be dispatched on. The queue must be a - * serial queue. - */ -@property(readonly) dispatch_queue_t requestDispatchQueue; +@protocol GRPCInterceptorInterface /** * To start the call. This method will only be called once for each instance. @@ -171,19 +169,16 @@ NS_ASSUME_NONNULL_BEGIN * invoke shutDown method of its corresponding manager so that references to other interceptors can * be released. */ -@interface GRPCInterceptorManager : NSObject +@interface GRPCInterceptorManager : NSObject - (instancetype)init NS_UNAVAILABLE; + (instancetype) new NS_UNAVAILABLE; -- (nullable instancetype)initWithNextInterceptor:(id)nextInterceptor - NS_DESIGNATED_INITIALIZER; +- (nullable instancetype)initWithFactories:(nullable NSArray> *)factories + previousInterceptor:(nullable id)previousInterceptor + transportId:(GRPCTransportId)transportId; -/** Set the previous interceptor in the chain. Can only be set once. */ -- (void)setPreviousInterceptor:(id)previousInterceptor; - -/** Indicate shutdown of the interceptor; release the reference to other interceptors */ - (void)shutDown; // Methods to forward GRPCInterceptorInterface calls to the next interceptor @@ -235,22 +230,18 @@ NS_ASSUME_NONNULL_BEGIN @interface GRPCInterceptor : NSObject - (instancetype)init NS_UNAVAILABLE; - -+ (instancetype) new NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; /** * Initialize the interceptor with the next interceptor in the chain, and provide the dispatch queue * that this interceptor's methods are dispatched onto. */ - (nullable instancetype)initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - requestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue - NS_DESIGNATED_INITIALIZER; + dispatchQueue:(dispatch_queue_t)dispatchQueue; // Default implementation of GRPCInterceptorInterface -- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions - callOptions:(GRPCCallOptions *)callOptions; +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions; - (void)writeData:(id)data; - (void)finish; - (void)cancel; diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.m b/src/objective-c/GRPCClient/GRPCInterceptor.m index a385ecd7813..aa3380cc024 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.m +++ b/src/objective-c/GRPCClient/GRPCInterceptor.m @@ -19,150 +19,273 @@ #import #import "GRPCInterceptor.h" +#import "private/GRPCTransport+Private.h" + +@interface GRPCInterceptorManager () + +@end @implementation GRPCInterceptorManager { id _nextInterceptor; id _previousInterceptor; + GRPCInterceptor *_thisInterceptor; + dispatch_queue_t _dispatchQueue; + NSArray> *_factories; + GRPCTransportId _transportId; + BOOL _shutDown; } -- (instancetype)initWithNextInterceptor:(id)nextInterceptor { +- (instancetype)initWithFactories:(NSArray> *)factories + previousInterceptor:(id)previousInterceptor + transportId:(nonnull GRPCTransportId)transportId { if ((self = [super init])) { - _nextInterceptor = nextInterceptor; + if (factories.count == 0) { + [NSException raise:NSInternalInconsistencyException format:@"Interceptor manager must have factories"]; + } + _thisInterceptor = [factories[0] createInterceptorWithManager:self]; + if (_thisInterceptor == nil) { + return nil; + } + _previousInterceptor = previousInterceptor; + _factories = factories; + // Generate interceptor +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 + if (@available(iOS 8.0, macOS 10.10, *)) { + _dispatchQueue = dispatch_queue_create(NULL, dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); + } else { +#else + { +#endif + _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); + } + dispatch_set_target_queue(_dispatchQueue, _thisInterceptor.dispatchQueue); + _transportId = transportId; } - - return self; -} - -- (void)setPreviousInterceptor:(id)previousInterceptor { - _previousInterceptor = previousInterceptor; + return self; } - (void)shutDown { _nextInterceptor = nil; _previousInterceptor = nil; + _thisInterceptor = nil; + _shutDown = YES; } -- (void)startNextInterceptorWithRequest:(GRPCRequestOptions *)requestOptions - callOptions:(GRPCCallOptions *)callOptions { - if (_nextInterceptor != nil) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; - }); + - (void)createNextInterceptor { + NSAssert(_nextInterceptor == nil, @"Starting the next interceptor more than once"); + NSAssert(_factories.count > 0, @"Interceptor manager of transport cannot start next interceptor"); + if (_nextInterceptor != nil) { + NSLog(@"Starting the next interceptor more than once"); + return; + } + NSMutableArray> *interceptorFactories = [NSMutableArray arrayWithArray:[_factories subarrayWithRange:NSMakeRange(1, _factories.count - 1)]]; + while (_nextInterceptor == nil) { + if (interceptorFactories.count == 0) { + _nextInterceptor = [[GRPCTransportManager alloc] initWithTransportId:_transportId previousInterceptor:self]; + break; + } else { + _nextInterceptor = [[GRPCInterceptorManager alloc] initWithFactories:interceptorFactories + previousInterceptor:self + transportId:_transportId]; + if (_nextInterceptor == nil) { + [interceptorFactories removeObjectAtIndex:0]; + } + } + } + NSAssert(_nextInterceptor != nil, @"Failed to create interceptor or transport."); + if (_nextInterceptor == nil) { + NSLog(@"Failed to create interceptor or transport."); + } } + + - (void)startNextInterceptorWithRequest:(GRPCRequestOptions *)requestOptions +callOptions:(GRPCCallOptions *)callOptions { + if (_nextInterceptor == nil && !_shutDown) { + [self createNextInterceptor]; + } + if (_nextInterceptor == nil) { + return; + } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ + [copiedNextInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; + }); } - (void)writeNextInterceptorWithData:(id)data { - if (_nextInterceptor != nil) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor writeData:data]; - }); + if (_nextInterceptor == nil && !_shutDown) { + [self createNextInterceptor]; } + if (_nextInterceptor == nil) { + return; + } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ + [copiedNextInterceptor writeData:data]; + }); } - (void)finishNextInterceptor { - if (_nextInterceptor != nil) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor finish]; - }); + if (_nextInterceptor == nil && !_shutDown) { + [self createNextInterceptor]; } + if (_nextInterceptor == nil) { + return; + } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ + [copiedNextInterceptor finish]; + }); } - (void)cancelNextInterceptor { - if (_nextInterceptor != nil) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor cancel]; - }); + if (_nextInterceptor == nil && !_shutDown) { + [self createNextInterceptor]; } + if (_nextInterceptor == nil) { + return; + } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ + [copiedNextInterceptor cancel]; + }); } /** Notify the next interceptor in the chain to receive more messages */ - (void)receiveNextInterceptorMessages:(NSUInteger)numberOfMessages { - if (_nextInterceptor != nil) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor receiveNextMessages:numberOfMessages]; - }); + if (_nextInterceptor == nil && !_shutDown) { + [self createNextInterceptor]; } + if (_nextInterceptor == nil) { + return; + } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ + [copiedNextInterceptor receiveNextMessages:numberOfMessages]; + }); } // Methods to forward GRPCResponseHandler callbacks to the previous object /** Forward initial metadata to the previous interceptor in the chain */ -- (void)forwardPreviousInterceptorWithInitialMetadata:(nullable NSDictionary *)initialMetadata { - if ([_previousInterceptor respondsToSelector:@selector(didReceiveInitialMetadata:)]) { - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didReceiveInitialMetadata:initialMetadata]; - }); +- (void)forwardPreviousInterceptorWithInitialMetadata:(NSDictionary *)initialMetadata { + if (_nextInterceptor == nil && !_shutDown) { + [self createNextInterceptor]; } + if (_nextInterceptor == nil) { + return; + } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didReceiveInitialMetadata:initialMetadata]; + }); } /** Forward a received message to the previous interceptor in the chain */ - (void)forwardPreviousInterceptorWithData:(id)data { - if ([_previousInterceptor respondsToSelector:@selector(didReceiveData:)]) { - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didReceiveData:data]; - }); + if (_previousInterceptor == nil) { + return; } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didReceiveData:data]; + }); } /** Forward call close and trailing metadata to the previous interceptor in the chain */ -- (void)forwardPreviousInterceptorCloseWithTrailingMetadata: - (nullable NSDictionary *)trailingMetadata - error:(nullable NSError *)error { - if ([_previousInterceptor respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; - }); + - (void)forwardPreviousInterceptorCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata +error:(NSError *)error { + if (_previousInterceptor == nil) { + return; } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; + }); } /** Forward write completion to the previous interceptor in the chain */ - (void)forwardPreviousInterceptorDidWriteData { - if ([_previousInterceptor respondsToSelector:@selector(didWriteData)]) { - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didWriteData]; - }); + if (_previousInterceptor == nil) { + return; + } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didWriteData]; + }); +} + + - (dispatch_queue_t)dispatchQueue { + return _dispatchQueue; + } + + - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { + [_thisInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; + } + + - (void)writeData:(id)data { + [_thisInterceptor writeData:data]; + } + + - (void)finish { + [_thisInterceptor finish]; + } + + - (void)cancel { + [_thisInterceptor cancel]; + } + + - (void)receiveNextMessages:(NSUInteger)numberOfMessages { + [_thisInterceptor receiveNextMessages:numberOfMessages]; + } + + - (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata { + if ([_thisInterceptor respondsToSelector:@selector(didReceiveInitialMetadata:)]) { + [_thisInterceptor didReceiveInitialMetadata:initialMetadata]; + } + } + + - (void)didReceiveData:(id)data { + if ([_thisInterceptor respondsToSelector:@selector(didReceiveData:)]) { + [_thisInterceptor didReceiveData:data]; + } + } + + - (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata + error:(nullable NSError *)error { + if ([_thisInterceptor respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { + [_thisInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; } } + - (void)didWriteData { + if ([_thisInterceptor respondsToSelector:@selector(didWriteData)]) { + [_thisInterceptor didWriteData]; + } + } + @end @implementation GRPCInterceptor { GRPCInterceptorManager *_manager; - dispatch_queue_t _requestDispatchQueue; - dispatch_queue_t _responseDispatchQueue; + dispatch_queue_t _dispatchQueue; } - (instancetype)initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - requestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue { + dispatchQueue:(dispatch_queue_t)dispatchQueue { if ((self = [super init])) { _manager = interceptorManager; - _requestDispatchQueue = requestDispatchQueue; - _responseDispatchQueue = responseDispatchQueue; + _dispatchQueue = dispatchQueue; } return self; } -- (dispatch_queue_t)requestDispatchQueue { - return _requestDispatchQueue; -} - - (dispatch_queue_t)dispatchQueue { - return _responseDispatchQueue; + return _dispatchQueue; } -- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions - callOptions:(GRPCCallOptions *)callOptions { +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { [_manager startNextInterceptorWithRequest:requestOptions callOptions:callOptions]; } diff --git a/src/objective-c/GRPCClient/GRPCTransport.h b/src/objective-c/GRPCClient/GRPCTransport.h new file mode 100644 index 00000000000..2da6ab3dc6a --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCTransport.h @@ -0,0 +1,61 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "GRPCInterceptor.h" + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark Transport ID + +extern const struct GRPCTransportImplList { + const GRPCTransportId core_secure; + const GRPCTransportId core_insecure; +} GRPCTransportImplList; + +BOOL TransportIdIsEqual(GRPCTransportId lhs, GRPCTransportId rhs); + +NSUInteger TransportIdHash(GRPCTransportId); + +#pragma mark Transport and factory + +@protocol GRPCInterceptorInterface; +@protocol GRPCResponseHandler; +@class GRPCTransportManager; +@class GRPCRequestOptions; +@class GRPCCallOptions; +@class GRPCTransport; + +@protocol GRPCTransportFactory + +- (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager; + +@end + +@interface GRPCTransportRegistry : NSObject + ++ (instancetype)sharedInstance; + +- (void)registerTransportWithId:(GRPCTransportId)id factory:(id)factory; + +@end + +@interface GRPCTransport : NSObject + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/objective-c/GRPCClient/GRPCTransport.m b/src/objective-c/GRPCClient/GRPCTransport.m new file mode 100644 index 00000000000..0621c4e6450 --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCTransport.m @@ -0,0 +1,116 @@ +#import "GRPCTransport.h" + +static const GRPCTransportId gGRPCCoreSecureId = "io.grpc.transport.core.secure"; +static const GRPCTransportId gGRPCCoreInsecureId = "io.grpc.transport.core.insecure"; + +const struct GRPCTransportImplList GRPCTransportImplList = { + .core_secure = gGRPCCoreSecureId, + .core_insecure = gGRPCCoreInsecureId}; + +static const GRPCTransportId gDefaultTransportId = gGRPCCoreSecureId; + +static GRPCTransportRegistry *gTransportRegistry = nil; +static dispatch_once_t initTransportRegistry; + +BOOL TransportIdIsEqual(GRPCTransportId lhs, GRPCTransportId rhs) { + // Directly comparing pointers works because we require users to use the id provided by each + // implementation, not coming up with their own string. + return lhs == rhs; +} + +NSUInteger TransportIdHash(GRPCTransportId transportId) { + if (transportId == NULL) { + transportId = gDefaultTransportId; + } + return [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding].hash; +} + +@implementation GRPCTransportRegistry { + NSMutableDictionary> *_registry; + id _defaultFactory; +} + ++ (instancetype)sharedInstance { + dispatch_once(&initTransportRegistry, ^{ + gTransportRegistry = [[GRPCTransportRegistry alloc] init]; + NSAssert(gTransportRegistry != nil, @"Unable to initialize transport registry."); + if (gTransportRegistry == nil) { + NSLog(@"Unable to initialize transport registry."); + [NSException raise:NSGenericException format:@"Unable to initialize transport registry."]; + } + }); + return gTransportRegistry; +} + +- (instancetype)init { + if ((self = [super init])) { + _registry = [NSMutableDictionary dictionary]; + } + return self; +} + +- (void)registerTransportWithId:(GRPCTransportId)transportId factory:(id)factory { + NSString *nsTransportId = [NSString stringWithCString:transportId + encoding:NSUTF8StringEncoding]; + NSAssert(_registry[nsTransportId] == nil, @"The transport %@ has already been registered.", nsTransportId); + if (_registry[nsTransportId] != nil) { + NSLog(@"The transport %@ has already been registered.", nsTransportId); + return; + } + _registry[nsTransportId] = factory; + + // if the default transport is registered, mark it. + if (0 == strcmp(transportId, gDefaultTransportId)) { + _defaultFactory = factory; + } +} + +- (id)getTransportFactoryWithId:(GRPCTransportId)transportId { + if (transportId == NULL) { + if (_defaultFactory == nil) { + [NSException raise:NSInvalidArgumentException format:@"Unable to get default transport factory"]; + return nil; + } + return _defaultFactory; + } + NSString *nsTransportId = [NSString stringWithCString:transportId + encoding:NSUTF8StringEncoding]; + id transportFactory = _registry[nsTransportId]; + if (transportFactory == nil) { + // User named a transport id that was not registered with the registry. + [NSException raise:NSInvalidArgumentException format:@"Unable to get transport factory with id %s", transportId]; + return nil; + } + return transportFactory; +} + +@end + +@implementation GRPCTransport + +- (dispatch_queue_t)dispatchQueue { + [NSException raise:NSGenericException format:@"Implementations should override the dispatch queue"]; + return nil; +} + +- (void)startWithRequestOptions:(nonnull GRPCRequestOptions *)requestOptions callOptions:(nonnull GRPCCallOptions *)callOptions { + [NSException raise:NSGenericException format:@"Implementations should override the methods of GRPCTransport"]; +} + +- (void)writeData:(nonnull id)data { + [NSException raise:NSGenericException format:@"Implementations should override the methods of GRPCTransport"]; +} + +- (void)cancel { + [NSException raise:NSGenericException format:@"Implementations should override the methods of GRPCTransport"]; +} + +- (void)finish { + [NSException raise:NSGenericException format:@"Implementations should override the methods of GRPCTransport"]; +} + +- (void)receiveNextMessages:(NSUInteger)numberOfMessages { + [NSException raise:NSGenericException format:@"Implementations should override the methods of GRPCTransport"]; +} + +@end diff --git a/src/objective-c/GRPCClient/internal_testing/GRPCCall+InternalTests.m b/src/objective-c/GRPCClient/internal_testing/GRPCCall+InternalTests.m index 1bb352f0be2..8f98daa6348 100644 --- a/src/objective-c/GRPCClient/internal_testing/GRPCCall+InternalTests.m +++ b/src/objective-c/GRPCClient/internal_testing/GRPCCall+InternalTests.m @@ -20,7 +20,7 @@ #import "GRPCCall+InternalTests.h" -#import "../private/GRPCOpBatchLog.h" +#import "../private/GRPCCore/GRPCOpBatchLog.h" @implementation GRPCCall (InternalTests) diff --git a/src/objective-c/GRPCClient/private/ChannelArgsUtil.h b/src/objective-c/GRPCClient/private/GRPCCore/ChannelArgsUtil.h similarity index 100% rename from src/objective-c/GRPCClient/private/ChannelArgsUtil.h rename to src/objective-c/GRPCClient/private/GRPCCore/ChannelArgsUtil.h diff --git a/src/objective-c/GRPCClient/private/ChannelArgsUtil.m b/src/objective-c/GRPCClient/private/GRPCCore/ChannelArgsUtil.m similarity index 100% rename from src/objective-c/GRPCClient/private/ChannelArgsUtil.m rename to src/objective-c/GRPCClient/private/GRPCCore/ChannelArgsUtil.m diff --git a/src/objective-c/GRPCClient/private/GRPCCall+V2API.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCall+V2API.h similarity index 79% rename from src/objective-c/GRPCClient/private/GRPCCall+V2API.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCall+V2API.h index 22bf16962c6..f6db3023cac 100644 --- a/src/objective-c/GRPCClient/private/GRPCCall+V2API.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCall+V2API.h @@ -18,12 +18,6 @@ @interface GRPCCall (V2API) -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - callSafety:(GRPCCallSafety)safety - requestsWriter:(GRXWriter *)requestsWriter - callOptions:(GRPCCallOptions *)callOptions; - - (instancetype)initWithHost:(NSString *)host path:(NSString *)path callSafety:(GRPCCallSafety)safety diff --git a/src/objective-c/GRPCClient/private/GRPCCallInternal.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.h similarity index 71% rename from src/objective-c/GRPCClient/private/GRPCCallInternal.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.h index ac2d1cba2ec..ff7a9f6e838 100644 --- a/src/objective-c/GRPCClient/private/GRPCCallInternal.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.h @@ -16,20 +16,21 @@ * */ -#import +#import NS_ASSUME_NONNULL_BEGIN -@interface GRPCCall2Internal : NSObject +@protocol GRPCResponseHandler; +@class GRPCCallOptions; +@protocol GRPCChannelFactory; -- (instancetype)init; +@interface GRPCCall2Internal : GRPCTransport -- (void)setResponseHandler:(id)responseHandler; +- (instancetype)initWithTransportManager:(GRPCTransportManager*)transportManager; -- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions - callOptions:(nullable GRPCCallOptions *)callOptions; +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions; -- (void)writeData:(NSData *)data; +- (void)writeData:(id)data; - (void)finish; diff --git a/src/objective-c/GRPCClient/private/GRPCCallInternal.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m similarity index 68% rename from src/objective-c/GRPCClient/private/GRPCCallInternal.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m index 32e38158fad..7ff8c6a5945 100644 --- a/src/objective-c/GRPCClient/private/GRPCCallInternal.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m @@ -19,17 +19,19 @@ #import "GRPCCallInternal.h" #import +#import #import #import "GRPCCall+V2API.h" +#import "../GRPCTransport+Private.h" @implementation GRPCCall2Internal { /** Request for the call. */ GRPCRequestOptions *_requestOptions; /** Options for the call. */ GRPCCallOptions *_callOptions; - /** The handler of responses. */ - id _handler; + /** The interceptor manager to process responses. */ + GRPCTransportManager *_transportManager; /** * Make use of legacy GRPCCall to make calls. Nullified when call is finished. @@ -51,45 +53,33 @@ NSUInteger _pendingReceiveNextMessages; } -- (instancetype)init { - if ((self = [super init])) { - // Set queue QoS only when iOS version is 8.0 or above and Xcode version is 9.0 or above + - (instancetype)initWithTransportManager:(GRPCTransportManager *)transportManager { + dispatch_queue_t dispatchQueue; + // Set queue QoS only when iOS version is 8.0 or above and Xcode version is 9.0 or above #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 if (@available(iOS 8.0, macOS 10.10, *)) { - _dispatchQueue = dispatch_queue_create( - NULL, - dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); + dispatchQueue = dispatch_queue_create( + NULL, + dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); } else { #else - { + { #endif - _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); - } + dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); + } + if ((self = [super init])) { _pipe = [GRXBufferedPipe pipe]; + _transportManager = transportManager; + _dispatchQueue = dispatchQueue; } return self; } -- (void)setResponseHandler:(id)responseHandler { - @synchronized(self) { - NSAssert(!_started, @"Call already started."); - if (_started) { - return; - } - _handler = responseHandler; - _initialMetadataPublished = NO; - _started = NO; - _canceled = NO; - _finished = NO; - } -} - -- (dispatch_queue_t)requestDispatchQueue { +- (dispatch_queue_t)dispatchQueue { return _dispatchQueue; } -- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions - callOptions:(GRPCCallOptions *)callOptions { +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { NSAssert(requestOptions.host.length != 0 && requestOptions.path.length != 0, @"Neither host nor path can be nil."); NSAssert(requestOptions.safety <= GRPCCallSafetyCacheableRequest, @"Invalid call safety value."); @@ -102,26 +92,15 @@ return; } + GRPCCall *copiedCall = nil; @synchronized(self) { - NSAssert(_handler != nil, @"Response handler required."); - if (_handler == nil) { - NSLog(@"Invalid response handler."); - return; - } _requestOptions = requestOptions; if (callOptions == nil) { _callOptions = [[GRPCCallOptions alloc] init]; } else { _callOptions = [callOptions copy]; } - } - [self start]; -} - -- (void)start { - GRPCCall *copiedCall = nil; - @synchronized(self) { NSAssert(!_started, @"Call already started."); NSAssert(!_canceled, @"Call already canceled."); if (_started) { @@ -140,7 +119,7 @@ callOptions:_callOptions writeDone:^{ @synchronized(self) { - if (self->_handler) { + if (self->_transportManager) { [self issueDidWriteData]; } } @@ -158,7 +137,7 @@ void (^valueHandler)(id value) = ^(id value) { @synchronized(self) { - if (self->_handler) { + if (self->_transportManager) { if (!self->_initialMetadataPublished) { self->_initialMetadataPublished = YES; [self issueInitialMetadata:self->_call.responseHeaders]; @@ -171,7 +150,7 @@ }; void (^completionHandler)(NSError *errorOrNil) = ^(NSError *errorOrNil) { @synchronized(self) { - if (self->_handler) { + if (self->_transportManager) { if (!self->_initialMetadataPublished) { self->_initialMetadataPublished = YES; [self issueInitialMetadata:self->_call.responseHeaders]; @@ -207,20 +186,15 @@ _call = nil; _pipe = nil; - if ([_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { - id copiedHandler = _handler; - _handler = nil; - dispatch_async(copiedHandler.dispatchQueue, ^{ - [copiedHandler didCloseWithTrailingMetadata:nil - error:[NSError errorWithDomain:kGRPCErrorDomain - code:GRPCErrorCodeCancelled - userInfo:@{ - NSLocalizedDescriptionKey : - @"Canceled by app" - }]]; - }); - } else { - _handler = nil; + if (_transportManager != nil) { + [_transportManager forwardPreviousInterceptorCloseWithTrailingMetadata:nil + error:[NSError errorWithDomain:kGRPCErrorDomain + code:GRPCErrorCodeCancelled + userInfo:@{ + NSLocalizedDescriptionKey : + @"Canceled by app" + }]]; + [_transportManager shutDown]; } } [copiedCall cancel]; @@ -271,59 +245,25 @@ } - (void)issueInitialMetadata:(NSDictionary *)initialMetadata { - @synchronized(self) { - if (initialMetadata != nil && - [_handler respondsToSelector:@selector(didReceiveInitialMetadata:)]) { - id copiedHandler = _handler; - dispatch_async(_handler.dispatchQueue, ^{ - [copiedHandler didReceiveInitialMetadata:initialMetadata]; - }); - } + if (initialMetadata != nil) { + [_transportManager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; } } - (void)issueMessage:(id)message { - @synchronized(self) { - if (message != nil) { - if ([_handler respondsToSelector:@selector(didReceiveData:)]) { - id copiedHandler = _handler; - dispatch_async(_handler.dispatchQueue, ^{ - [copiedHandler didReceiveData:message]; - }); - } else if ([_handler respondsToSelector:@selector(didReceiveRawMessage:)]) { - id copiedHandler = _handler; - dispatch_async(_handler.dispatchQueue, ^{ - [copiedHandler didReceiveRawMessage:message]; - }); - } - } + if (message != nil) { + [_transportManager forwardPreviousInterceptorWithData:message]; } } - (void)issueClosedWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { - @synchronized(self) { - if ([_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { - id copiedHandler = _handler; - // Clean up _handler so that no more responses are reported to the handler. - _handler = nil; - dispatch_async(copiedHandler.dispatchQueue, ^{ - [copiedHandler didCloseWithTrailingMetadata:trailingMetadata error:error]; - }); - } else { - _handler = nil; - } - } + [_transportManager forwardPreviousInterceptorCloseWithTrailingMetadata:trailingMetadata + error:error]; + [_transportManager shutDown]; } - (void)issueDidWriteData { - @synchronized(self) { - if (_callOptions.flowControlEnabled && [_handler respondsToSelector:@selector(didWriteData)]) { - id copiedHandler = _handler; - dispatch_async(copiedHandler.dispatchQueue, ^{ - [copiedHandler didWriteData]; - }); - } - } + [_transportManager forwardPreviousInterceptorDidWriteData]; } - (void)receiveNextMessages:(NSUInteger)numberOfMessages { diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCChannel.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.h diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m similarity index 77% rename from src/objective-c/GRPCClient/private/GRPCChannel.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m index 1a79fb04a0d..846e8331b4b 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m @@ -20,15 +20,16 @@ #include -#import "../internal/GRPCCallOptions+Internal.h" +#import "../../internal/GRPCCallOptions+Internal.h" #import "ChannelArgsUtil.h" #import "GRPCChannelFactory.h" #import "GRPCChannelPool.h" #import "GRPCCompletionQueue.h" -#import "GRPCCronetChannelFactory.h" #import "GRPCInsecureChannelFactory.h" #import "GRPCSecureChannelFactory.h" #import "version.h" +#import "GRPCCoreFactory.h" +#import "../GRPCTransport+Private.h" #import #import @@ -50,32 +51,44 @@ } - (id)channelFactory { - GRPCTransportType type = _callOptions.transportType; - switch (type) { - case GRPCTransportTypeChttp2BoringSSL: - // TODO (mxyan): Remove when the API is deprecated -#ifdef GRPC_COMPILE_WITH_CRONET - if (![GRPCCall isUsingCronet]) { -#else - { -#endif - NSError *error; - id factory = [GRPCSecureChannelFactory - factoryWithPEMRootCertificates:_callOptions.PEMRootCertificates - privateKey:_callOptions.PEMPrivateKey - certChain:_callOptions.PEMCertificateChain - error:&error]; - NSAssert(factory != nil, @"Failed to create secure channel factory"); - if (factory == nil) { - NSLog(@"Error creating secure channel factory: %@", error); - } - return factory; + if (_callOptions.transport != NULL) { + id transportFactory = [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:_callOptions.transport]; + if (![transportFactory respondsToSelector:@selector(createCoreChannelFactoryWithCallOptions:)]) { + // impossible because we are using GRPCCore now + [NSException raise:NSInternalInconsistencyException format:@"Transport factory type is wrong"]; + } + id coreTransportFactory = (id)transportFactory; + return [coreTransportFactory createCoreChannelFactoryWithCallOptions:_callOptions]; + } else { + // To maintain backwards compatibility with tranportType + GRPCTransportType type = _callOptions.transportType; + switch (type) { + case GRPCTransportTypeChttp2BoringSSL: + // TODO (mxyan): Remove when the API is deprecated + { + NSError *error; + id factory = [GRPCSecureChannelFactory + factoryWithPEMRootCertificates:_callOptions.PEMRootCertificates + privateKey:_callOptions.PEMPrivateKey + certChain:_callOptions.PEMCertificateChain + error:&error]; + NSAssert(factory != nil, @"Failed to create secure channel factory"); + if (factory == nil) { + NSLog(@"Error creating secure channel factory: %@", error); + } + return factory; + } + case GRPCTransportTypeCronet: + { + id transportFactory = (id)[[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:gGRPCCoreCronetId]; + return [transportFactory createCoreChannelFactoryWithCallOptions:_callOptions]; } - // fallthrough - case GRPCTransportTypeCronet: - return [GRPCCronetChannelFactory sharedInstance]; - case GRPCTransportTypeInsecure: - return [GRPCInsecureChannelFactory sharedInstance]; + case GRPCTransportTypeInsecure: + return [GRPCInsecureChannelFactory sharedInstance]; + default: + NSLog(@"Unrecognized transport type"); + return nil; + } } } @@ -178,7 +191,7 @@ grpc_channel *_unmanagedChannel; } -- (instancetype)initWithChannelConfiguration:(GRPCChannelConfiguration *)channelConfiguration { + - (instancetype)initWithChannelConfiguration:(GRPCChannelConfiguration *)channelConfiguration { NSAssert(channelConfiguration != nil, @"channelConfiguration must not be empty."); if (channelConfiguration == nil) { return nil; @@ -198,6 +211,7 @@ } else { channelArgs = channelConfiguration.channelArgs; } + id factory = channelConfiguration.channelFactory; _unmanagedChannel = [factory createChannelWithHost:host channelArgs:channelArgs]; NSAssert(_unmanagedChannel != NULL, @"Failed to create channel"); diff --git a/src/objective-c/GRPCClient/private/GRPCChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelFactory.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCChannelFactory.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelFactory.h diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool+Test.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool+Test.h diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.h similarity index 97% rename from src/objective-c/GRPCClient/private/GRPCChannelPool.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.h index e00ee69e63a..5adb9cea168 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannelPool.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.h @@ -18,8 +18,6 @@ #import -#import "GRPCChannelFactory.h" - NS_ASSUME_NONNULL_BEGIN @protocol GRPCChannel; @@ -45,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN * Initialize with an actual channel object \a channel and a reference to the channel pool. */ - (nullable instancetype)initWithChannelConfiguration: - (GRPCChannelConfiguration *)channelConfiguration; +(GRPCChannelConfiguration *)channelConfiguration; /** * Create a GRPCWrappedCall object (grpc_call) from this channel. If channel is disconnected, get a diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.m similarity index 98% rename from src/objective-c/GRPCClient/private/GRPCChannelPool.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.m index d545793fcce..faabb3ae336 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannelPool.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.m @@ -18,19 +18,17 @@ #import -#import "../internal/GRPCCallOptions+Internal.h" +#import "../../internal/GRPCCallOptions+Internal.h" #import "GRPCChannel.h" #import "GRPCChannelFactory.h" #import "GRPCChannelPool+Test.h" #import "GRPCChannelPool.h" #import "GRPCCompletionQueue.h" -#import "GRPCCronetChannelFactory.h" #import "GRPCInsecureChannelFactory.h" #import "GRPCSecureChannelFactory.h" #import "GRPCWrappedCall.h" #import "version.h" -#import #include extern const char *kCFStreamVarName; diff --git a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCompletionQueue.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.h diff --git a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCompletionQueue.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.m diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h new file mode 100644 index 00000000000..8c781f4a448 --- /dev/null +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h @@ -0,0 +1,23 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "GRPCCoreFactory.h" + +@interface GRPCCoreCronetFactory : NSObject + +@end diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m new file mode 100644 index 00000000000..661df006e57 --- /dev/null +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m @@ -0,0 +1,53 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "GRPCCoreCronetFactory.h" + +#import +#import + +#import "GRPCCoreFactory.h" +#import "GRPCCallInternal.h" +#import "GRPCCronetChannelFactory.h" + +static GRPCCoreCronetFactory *gGRPCCoreCronetFactory = nil; +static dispatch_once_t gInitGRPCCoreCronetFactory; + +@implementation GRPCCoreCronetFactory + ++ (instancetype)sharedInstance { + dispatch_once(&gInitGRPCCoreCronetFactory, ^{ + gGRPCCoreCronetFactory = [[GRPCCoreCronetFactory alloc] init]; + }); + return gGRPCCoreCronetFactory; +} + ++ (void)load { + [[GRPCTransportRegistry sharedInstance] registerTransportWithId:gGRPCCoreCronetId + factory:[GRPCCoreCronetFactory sharedInstance]]; +} + +- (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager { + return [[GRPCCall2Internal alloc] initWithTransportManager:transportManager]; +} + +- (id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions { + return [GRPCCronetChannelFactory sharedInstance]; +} + +@end diff --git a/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.h diff --git a/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.m similarity index 79% rename from src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.m index 5bcb021dc4b..8744d27e04f 100644 --- a/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.m @@ -21,8 +21,6 @@ #import "ChannelArgsUtil.h" #import "GRPCChannel.h" -#ifdef GRPC_COMPILE_WITH_CRONET - #import #include @@ -59,21 +57,3 @@ } @end - -#else - -@implementation GRPCCronetChannelFactory - -+ (instancetype)sharedInstance { - NSAssert(NO, @"Must enable macro GRPC_COMPILE_WITH_CRONET to build Cronet channel."); - return nil; -} - -- (grpc_channel *)createChannelWithHost:(NSString *)host channelArgs:(NSDictionary *)args { - NSAssert(NO, @"Must enable macro GRPC_COMPILE_WITH_CRONET to build Cronet channel."); - return NULL; -} - -@end - -#endif diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h new file mode 100644 index 00000000000..d4d8ef586df --- /dev/null +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h @@ -0,0 +1,40 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol GRPCChannelFactory; +@protocol GRPCCallOptions; + +@protocol GRPCCoreTransportFactory + +- (nullable id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions; + +@end + +@interface GRPCCoreSecureFactory : NSObject + +@end + +@interface GRPCCoreInsecureFactory : NSObject + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m new file mode 100644 index 00000000000..609cda17697 --- /dev/null +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m @@ -0,0 +1,68 @@ +#import "GRPCCoreFactory.h" + +#import + +#import "GRPCCallInternal.h" +#import "GRPCSecureChannelFactory.h" +#import "GRPCInsecureChannelFactory.h" + +static GRPCCoreSecureFactory *gGRPCCoreSecureFactory = nil; +static GRPCCoreInsecureFactory *gGRPCCoreInsecureFactory = nil; +static dispatch_once_t gInitGRPCCoreSecureFactory; +static dispatch_once_t gInitGRPCCoreInsecureFactory; + +@implementation GRPCCoreSecureFactory + ++ (instancetype)sharedInstance { + dispatch_once(&gInitGRPCCoreSecureFactory, ^{ + gGRPCCoreSecureFactory = [[GRPCCoreSecureFactory alloc] init]; + }); + return gGRPCCoreSecureFactory; +} + ++ (void)load { + [[GRPCTransportRegistry sharedInstance] registerTransportWithId:GRPCTransportImplList.core_secure + factory:[self sharedInstance]]; +} + +- (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager { + return [[GRPCCall2Internal alloc] initWithTransportManager:transportManager]; +} + +- (id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions { + NSError *error; + id factory = [GRPCSecureChannelFactory factoryWithPEMRootCertificates:callOptions.PEMRootCertificates + privateKey:callOptions.PEMPrivateKey + certChain:callOptions.PEMCertificateChain error:&error]; + if (error != nil) { + NSLog(@"Unable to create secure channel factory"); + return nil; + } + return factory; +} + +@end + +@implementation GRPCCoreInsecureFactory + ++ (instancetype)sharedInstance { + dispatch_once(&gInitGRPCCoreInsecureFactory, ^{ + gGRPCCoreInsecureFactory = [[GRPCCoreInsecureFactory alloc] init]; + }); + return gGRPCCoreInsecureFactory; +} + ++ (void)load { + [[GRPCTransportRegistry sharedInstance] registerTransportWithId:GRPCTransportImplList.core_insecure + factory:[self sharedInstance]]; +} + +- (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager { + return [[GRPCCall2Internal alloc] initWithTransportManager:transportManager]; +} + +- (id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions { + return [GRPCInsecureChannelFactory sharedInstance]; +} + +@end diff --git a/src/objective-c/GRPCClient/private/GRPCHost.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCHost.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.h diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m similarity index 87% rename from src/objective-c/GRPCClient/private/GRPCHost.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m index 63ffc927411..89a184d8c26 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m @@ -25,10 +25,9 @@ #include #include -#import "../internal/GRPCCallOptions+Internal.h" +#import "../../internal/GRPCCallOptions+Internal.h" #import "GRPCChannelFactory.h" #import "GRPCCompletionQueue.h" -#import "GRPCCronetChannelFactory.h" #import "GRPCSecureChannelFactory.h" #import "NSDictionary+GRPC.h" #import "version.h" @@ -113,20 +112,10 @@ static NSMutableDictionary *gHostCache; options.PEMPrivateKey = _PEMPrivateKey; options.PEMCertificateChain = _PEMCertificateChain; options.hostNameOverride = _hostNameOverride; -#ifdef GRPC_COMPILE_WITH_CRONET - // By old API logic, insecure channel precedes Cronet channel; Cronet channel preceeds default - // channel. - if ([GRPCCall isUsingCronet]) { - if (_transportType == GRPCTransportTypeInsecure) { - options.transportType = GRPCTransportTypeInsecure; - } else { - NSAssert(_transportType == GRPCTransportTypeDefault, @"Invalid transport type"); - options.transportType = GRPCTransportTypeCronet; - } - } else -#endif - { - options.transportType = _transportType; + if (_transportType == GRPCTransportTypeInsecure) { + options.transport = GRPCTransportImplList.core_insecure; + } else { + options.transport = GRPCTransportImplList.core_secure; } options.logContext = _logContext; diff --git a/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.h diff --git a/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.m diff --git a/src/objective-c/GRPCClient/private/GRPCOpBatchLog.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCOpBatchLog.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCOpBatchLog.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCOpBatchLog.h diff --git a/src/objective-c/GRPCClient/private/GRPCOpBatchLog.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCOpBatchLog.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCOpBatchLog.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCOpBatchLog.m diff --git a/src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCReachabilityFlagNames.xmacro.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCReachabilityFlagNames.xmacro.h diff --git a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.h similarity index 95% rename from src/objective-c/GRPCClient/private/GRPCRequestHeaders.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.h index 545ff1cea82..0fced0c385a 100644 --- a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.h @@ -18,7 +18,7 @@ #import -#import "../GRPCCall.h" +#import @interface GRPCRequestHeaders : NSMutableDictionary diff --git a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCRequestHeaders.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.m diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.h diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.m diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCWrappedCall.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.h diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCWrappedCall.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.m diff --git a/src/objective-c/GRPCClient/private/NSData+GRPC.h b/src/objective-c/GRPCClient/private/GRPCCore/NSData+GRPC.h similarity index 100% rename from src/objective-c/GRPCClient/private/NSData+GRPC.h rename to src/objective-c/GRPCClient/private/GRPCCore/NSData+GRPC.h diff --git a/src/objective-c/GRPCClient/private/NSData+GRPC.m b/src/objective-c/GRPCClient/private/GRPCCore/NSData+GRPC.m similarity index 100% rename from src/objective-c/GRPCClient/private/NSData+GRPC.m rename to src/objective-c/GRPCClient/private/GRPCCore/NSData+GRPC.m diff --git a/src/objective-c/GRPCClient/private/NSDictionary+GRPC.h b/src/objective-c/GRPCClient/private/GRPCCore/NSDictionary+GRPC.h similarity index 100% rename from src/objective-c/GRPCClient/private/NSDictionary+GRPC.h rename to src/objective-c/GRPCClient/private/GRPCCore/NSDictionary+GRPC.h diff --git a/src/objective-c/GRPCClient/private/NSDictionary+GRPC.m b/src/objective-c/GRPCClient/private/GRPCCore/NSDictionary+GRPC.m similarity index 100% rename from src/objective-c/GRPCClient/private/NSDictionary+GRPC.m rename to src/objective-c/GRPCClient/private/GRPCCore/NSDictionary+GRPC.m diff --git a/src/objective-c/GRPCClient/private/NSError+GRPC.h b/src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.h similarity index 100% rename from src/objective-c/GRPCClient/private/NSError+GRPC.h rename to src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.h diff --git a/src/objective-c/GRPCClient/private/NSError+GRPC.m b/src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m similarity index 100% rename from src/objective-c/GRPCClient/private/NSError+GRPC.m rename to src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m diff --git a/src/objective-c/GRPCClient/private/GRPCCore/version.h b/src/objective-c/GRPCClient/private/GRPCCore/version.h new file mode 100644 index 00000000000..3b248db0148 --- /dev/null +++ b/src/objective-c/GRPCClient/private/GRPCCore/version.h @@ -0,0 +1,25 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// This file is autogenerated from a template file. Please make +// modifications to +// `templates/src/objective-c/GRPCClient/private/version.h.template` +// instead. This file can be regenerated from the template by running +// `tools/buildgen/generate_projects.sh`. + +#define GRPC_OBJC_VERSION_STRING @"1.23.0-dev" diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h new file mode 100644 index 00000000000..9115b915659 --- /dev/null +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h @@ -0,0 +1,55 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface GRPCTransportRegistry (Private) + +- (nullable instancetype)initWithTransportId:(GRPCTransportId)transportId + previousInterceptor:(id)previousInterceptor; + +- (id)getTransportFactoryWithId:(GRPCTransportId)id; + +@end + +@interface GRPCTransportManager : NSObject + +- (instancetype)initWithTransportId:(GRPCTransportId)transportId + previousInterceptor:(id)previousInterceptor; + +- (void)shutDown; + +/** Forward initial metadata to the previous interceptor in the interceptor chain */ +- (void)forwardPreviousInterceptorWithInitialMetadata:(nullable NSDictionary *)initialMetadata; + +/** Forward a received message to the previous interceptor in the interceptor chain */ +- (void)forwardPreviousInterceptorWithData:(nullable id)data; + +/** Forward call close and trailing metadata to the previous interceptor in the interceptor chain */ +- (void)forwardPreviousInterceptorCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata + error:(nullable NSError *)error; + +/** Forward write completion to the previous interceptor in the interceptor chain */ +- (void)forwardPreviousInterceptorDidWriteData; + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m new file mode 100644 index 00000000000..1050280e07b --- /dev/null +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m @@ -0,0 +1,108 @@ +#import "GRPCTransport+Private.h" + +#import + +@implementation GRPCTransportManager { + GRPCTransportId _transportId; + GRPCTransport *_transport; + id _previousInterceptor; + dispatch_queue_t _dispatchQueue; +} + +- (instancetype)initWithTransportId:(GRPCTransportId)transportId + previousInterceptor:(id)previousInterceptor { + if ((self = [super init])) { + id factory = [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:transportId]; + + _transport = [factory createTransportWithManager:self]; + NSAssert(_transport != nil, @"Failed to create transport with id: %s", transportId); + if (_transport == nil) { + NSLog(@"Failed to create transport with id: %s", transportId); + return nil; + } + _previousInterceptor = previousInterceptor; + _dispatchQueue = _transport.dispatchQueue; + _transportId = transportId; + } + return self; +} + +- (void)shutDown { + _transport = nil; + _previousInterceptor = nil; +} + +- (dispatch_queue_t)dispatchQueue { + return _dispatchQueue; +} + +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { + if (_transportId != callOptions.transport) { + [NSException raise:NSInvalidArgumentException format:@"Interceptors cannot change the call option 'transport'"]; + return; + } + [_transport startWithRequestOptions:requestOptions callOptions:callOptions]; +} + +- (void)writeData:(id)data { + [_transport writeData:data]; +} + +- (void)finish { + [_transport finish]; +} + +- (void)cancel { + [_transport cancel]; +} + +- (void)receiveNextMessages:(NSUInteger)numberOfMessages { + [_transport receiveNextMessages:numberOfMessages]; +} + +/** Forward initial metadata to the previous interceptor in the chain */ +- (void)forwardPreviousInterceptorWithInitialMetadata:(NSDictionary *)initialMetadata { + if (_previousInterceptor == nil) { + return; + } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didReceiveInitialMetadata:initialMetadata]; + }); +} + +/** Forward a received message to the previous interceptor in the chain */ +- (void)forwardPreviousInterceptorWithData:(id)data { + if (_previousInterceptor == nil) { + return; + } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didReceiveData:data]; + }); +} + +/** Forward call close and trailing metadata to the previous interceptor in the chain */ +- (void)forwardPreviousInterceptorCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata + error:(NSError *)error { + if (_previousInterceptor == nil) { + return; + } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; + }); +} + +/** Forward write completion to the previous interceptor in the chain */ +- (void)forwardPreviousInterceptorDidWriteData { + if (_previousInterceptor == nil) { + return; + } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didWriteData]; + }); +} + +@end diff --git a/src/objective-c/tests/ConfigureCronet.h b/src/objective-c/tests/ConfigureCronet.h index cc5c038f3c6..ba0efc4df66 100644 --- a/src/objective-c/tests/ConfigureCronet.h +++ b/src/objective-c/tests/ConfigureCronet.h @@ -16,8 +16,6 @@ * */ -#ifdef GRPC_COMPILE_WITH_CRONET - #ifdef __cplusplus extern "C" { #endif @@ -30,5 +28,3 @@ void configureCronet(void); #ifdef __cplusplus } #endif - -#endif diff --git a/src/objective-c/tests/ConfigureCronet.m b/src/objective-c/tests/ConfigureCronet.m index ab137e28cad..6fc7e0ee9f5 100644 --- a/src/objective-c/tests/ConfigureCronet.m +++ b/src/objective-c/tests/ConfigureCronet.m @@ -16,8 +16,6 @@ * */ -#ifdef GRPC_COMPILE_WITH_CRONET - #import "ConfigureCronet.h" #import @@ -35,5 +33,3 @@ void configureCronet(void) { [Cronet startNetLogToFile:@"cronet_netlog.json" logBytes:YES]; }); } - -#endif diff --git a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m index a2a79c46316..c1c51fb06ab 100644 --- a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m +++ b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m @@ -23,6 +23,8 @@ #import #import "InteropTests.h" +#import "../ConfigureCronet.h" + // The server address is derived from preprocessor macro, which is // in turn derived from environment variable of the same name. @@ -40,10 +42,24 @@ static int32_t kRemoteInteropServerOverhead = 12; @implementation InteropTestsRemoteWithCronet ++ (void)setUp { + configureCronet(); + if ([self useCronet]) { + [GRPCCall useCronetWithEngine:[Cronet getGlobalEngine]]; + } + + [super setUp]; +} + + + (NSString *)host { return kRemoteSSLHost; } ++ (GRPCTransportId)transport { + return gGRPCCoreCronetId; +} + + (BOOL)useCronet { return YES; } diff --git a/src/objective-c/tests/InteropTests/InteropTests.h b/src/objective-c/tests/InteropTests/InteropTests.h index cffa90ac497..b6af8e316e2 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.h +++ b/src/objective-c/tests/InteropTests/InteropTests.h @@ -42,11 +42,19 @@ - (int32_t)encodingOverhead; /** + * DEPRECATED: \a transportType is a deprecated option. Please use \a transport instead. + * * The type of transport to be used. The base implementation returns default. Subclasses should * override to appropriate settings. */ + (GRPCTransportType)transportType; +/* + * The transport to be used. The base implementation returns NULL. Subclasses should override to + * appropriate settings. + */ ++ (GRPCTransportId)transport; + /** * The root certificates to be used. The base implementation returns nil. Subclasses should override * to appropriate settings. diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 3260e918f2f..25f96050e59 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -20,9 +20,7 @@ #include -#ifdef GRPC_COMPILE_WITH_CRONET #import -#endif #import #import #import @@ -38,7 +36,6 @@ #import #import -#import "../ConfigureCronet.h" #import "InteropTestsBlockCallbacks.h" #define TEST_TIMEOUT 32 @@ -92,8 +89,7 @@ BOOL isRemoteInteropTest(NSString *host) { - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { dispatch_queue_t queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); return [[GRPCInterceptor alloc] initWithInterceptorManager:interceptorManager - requestDispatchQueue:queue - responseDispatchQueue:queue]; + dispatchQueue:queue]; } @end @@ -101,8 +97,7 @@ BOOL isRemoteInteropTest(NSString *host) { @interface HookInterceptorFactory : NSObject - (instancetype) -initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue +initWithDispatchQueue:(dispatch_queue_t)dispatchQueue startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook @@ -125,8 +120,7 @@ initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - (instancetype) initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - requestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue +dispatchQueue:(dispatch_queue_t)dispatchQueue startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook @@ -155,13 +149,11 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager void (^_responseCloseHook)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager); void (^_didWriteDataHook)(GRPCInterceptorManager *manager); - dispatch_queue_t _requestDispatchQueue; - dispatch_queue_t _responseDispatchQueue; + dispatch_queue_t _dispatchQueue; } - (instancetype) -initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue +initWithDispatchQueue:(dispatch_queue_t)dispatchQueue startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook @@ -176,8 +168,7 @@ initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue GRPCInterceptorManager *manager))responseCloseHook didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { if ((self = [super init])) { - _requestDispatchQueue = requestDispatchQueue; - _responseDispatchQueue = responseDispatchQueue; + _dispatchQueue = dispatchQueue; _startHook = startHook; _writeDataHook = writeDataHook; _finishHook = finishHook; @@ -192,8 +183,7 @@ initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { return [[HookInterceptor alloc] initWithInterceptorManager:interceptorManager - requestDispatchQueue:_requestDispatchQueue - responseDispatchQueue:_responseDispatchQueue + dispatchQueue:_dispatchQueue startHook:_startHook writeDataHook:_writeDataHook finishHook:_finishHook @@ -218,22 +208,16 @@ initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue GRPCInterceptorManager *manager); void (^_didWriteDataHook)(GRPCInterceptorManager *manager); GRPCInterceptorManager *_manager; - dispatch_queue_t _requestDispatchQueue; - dispatch_queue_t _responseDispatchQueue; -} - -- (dispatch_queue_t)requestDispatchQueue { - return _requestDispatchQueue; + dispatch_queue_t _dispatchQueue; } - (dispatch_queue_t)dispatchQueue { - return _responseDispatchQueue; + return _dispatchQueue; } - (instancetype) initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - requestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue +dispatchQueue:(dispatch_queue_t)dispatchQueue startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook @@ -248,8 +232,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager GRPCInterceptorManager *manager))responseCloseHook didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { if ((self = [super initWithInterceptorManager:interceptorManager - requestDispatchQueue:requestDispatchQueue - responseDispatchQueue:responseDispatchQueue])) { + dispatchQueue:dispatchQueue])) { _startHook = startHook; _writeDataHook = writeDataHook; _finishHook = finishHook; @@ -258,8 +241,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager _responseDataHook = responseDataHook; _responseCloseHook = responseCloseHook; _didWriteDataHook = didWriteDataHook; - _requestDispatchQueue = requestDispatchQueue; - _responseDispatchQueue = responseDispatchQueue; + _dispatchQueue = dispatchQueue; _manager = interceptorManager; } return self; @@ -320,8 +302,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager @property BOOL enabled; -- (instancetype)initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue; +- (instancetype)initWithDispatchQueue:(dispatch_queue_t)dispatchQueue; - (void)setStartHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook @@ -340,11 +321,9 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager @implementation GlobalInterceptorFactory -- (instancetype)initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue { +- (instancetype)initWithDispatchQueue:(dispatch_queue_t)dispatchQueue { _enabled = NO; - return [super initWithRequestDispatchQueue:requestDispatchQueue - responseDispatchQueue:responseDispatchQueue + return [super initWithDispatchQueue:dispatchQueue startHook:nil writeDataHook:nil finishHook:nil @@ -358,8 +337,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { if (_enabled) { return [[HookInterceptor alloc] initWithInterceptorManager:interceptorManager - requestDispatchQueue:_requestDispatchQueue - responseDispatchQueue:_responseDispatchQueue + dispatchQueue:_dispatchQueue startHook:_startHook writeDataHook:_writeDataHook finishHook:_finishHook @@ -417,10 +395,15 @@ static dispatch_once_t initGlobalInterceptorFactory; return 0; } +// For backwards compatibility + (GRPCTransportType)transportType { return GRPCTransportTypeChttp2BoringSSL; } ++ (GRPCTransportId)transport { + return NULL; +} + + (NSString *)PEMRootCertificates { return nil; } @@ -434,21 +417,10 @@ static dispatch_once_t initGlobalInterceptorFactory; } + (void)setUp { -#ifdef GRPC_COMPILE_WITH_CRONET - configureCronet(); - if ([self useCronet]) { - [GRPCCall useCronetWithEngine:[Cronet getGlobalEngine]]; - } -#endif -#ifdef GRPC_CFSTREAM - setenv(kCFStreamVarName, "1", 1); -#endif - dispatch_once(&initGlobalInterceptorFactory, ^{ dispatch_queue_t globalInterceptorQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); globalInterceptorFactory = - [[GlobalInterceptorFactory alloc] initWithRequestDispatchQueue:globalInterceptorQueue - responseDispatchQueue:globalInterceptorQueue]; + [[GlobalInterceptorFactory alloc] initWithDispatchQueue:globalInterceptorQueue]; [GRPCCall2 registerGlobalInterceptor:globalInterceptorFactory]; }); } @@ -494,7 +466,9 @@ static dispatch_once_t initGlobalInterceptorFactory; GPBEmpty *request = [GPBEmpty message]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -523,7 +497,9 @@ static dispatch_once_t initGlobalInterceptorFactory; GPBEmpty *request = [GPBEmpty message]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -600,7 +576,9 @@ static dispatch_once_t initGlobalInterceptorFactory; request.payload.body = [NSMutableData dataWithLength:271828]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -648,7 +626,9 @@ static dispatch_once_t initGlobalInterceptorFactory; request.responseStatus.code = GRPC_STATUS_CANCELLED; } GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -950,7 +930,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -1002,7 +984,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.flowControlEnabled = YES; @@ -1159,7 +1143,9 @@ static dispatch_once_t initGlobalInterceptorFactory; __block BOOL receivedResponse = NO; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = self.class.transportType; + options.transport = [[self class] transport]; options.PEMRootCertificates = self.class.PEMRootCertificates; options.hostNameOverride = [[self class] hostNameOverride]; @@ -1192,7 +1178,9 @@ static dispatch_once_t initGlobalInterceptorFactory; [self expectationWithDescription:@"Call completed."]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = self.class.transportType; + options.transport = [[self class] transport]; options.PEMRootCertificates = self.class.PEMRootCertificates; options.hostNameOverride = [[self class] hostNameOverride]; @@ -1278,48 +1266,43 @@ static dispatch_once_t initGlobalInterceptorFactory; [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; } -#ifndef GRPC_COMPILE_WITH_CRONET -- (void)testKeepalive { +- (void)testKeepaliveWithV2API { XCTAssertNotNil([[self class] host]); __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Keepalive"]; - [GRPCCall setKeepaliveWithInterval:1500 timeout:0 forHost:[[self class] host]]; - NSArray *requests = @[ @27182, @8 ]; - NSArray *responses = @[ @31415, @9 ]; + NSNumber *kRequestSize = @27182; + NSNumber *kResponseSize = @31415; - GRXBufferedPipe *requestsBuffer = [[GRXBufferedPipe alloc] init]; + id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:kRequestSize + requestedResponseSize:kResponseSize]; + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; + options.PEMRootCertificates = [[self class] PEMRootCertificates]; + options.hostNameOverride = [[self class] hostNameOverride]; + options.keepaliveInterval = 1.5; + options.keepaliveTimeout = 0; - __block int index = 0; - - id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] - requestedResponseSize:responses[index]]; - [requestsBuffer writeValue:request]; - - [_service - fullDuplexCallWithRequestsWriter:requestsBuffer - eventHandler:^(BOOL done, RMTStreamingOutputCallResponse *response, - NSError *error) { - if (index == 0) { - XCTAssertNil(error, @"Finished with unexpected error: %@", error); - XCTAssertTrue(response, @"Event handler called without an event."); - XCTAssertFalse(done); - index++; - } else { - // Keepalive should kick after 1s elapsed and fails the call. - XCTAssertNotNil(error); - XCTAssertEqual(error.code, GRPC_STATUS_UNAVAILABLE); - XCTAssertEqualObjects( - error.localizedDescription, @"keepalive watchdog timeout", - @"Unexpected failure that is not keepalive watchdog timeout."); - XCTAssertTrue(done); - [expectation fulfill]; - } - }]; + __block GRPCStreamingProtoCall *call = [_service + fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + XCTAssertNotNil(error); + XCTAssertEqual(error.code, GRPC_STATUS_UNAVAILABLE, + @"Received status %ld instead of UNAVAILABLE (14).", + error.code); + [expectation fulfill]; + }] + callOptions:options]; + [call writeMessage:request]; + [call start]; [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; + [call finish]; } -#endif - (void)testDefaultInterceptor { XCTAssertNotNil([[self class] host]); @@ -1334,7 +1317,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.interceptorFactories = @[ [[DefaultInterceptorFactory alloc] init] ]; @@ -1389,8 +1374,7 @@ static dispatch_once_t initGlobalInterceptorFactory; __block NSUInteger responseCloseCount = 0; __block NSUInteger didWriteDataCount = 0; id factory = [[HookInterceptorFactory alloc] - initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager) { startCount++; @@ -1438,7 +1422,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.flowControlEnabled = YES; @@ -1516,8 +1502,7 @@ static dispatch_once_t initGlobalInterceptorFactory; __block NSUInteger responseDataCount = 0; __block NSUInteger responseCloseCount = 0; id factory = [[HookInterceptorFactory alloc] - initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager) { startCount++; @@ -1544,6 +1529,7 @@ static dispatch_once_t initGlobalInterceptorFactory; // finish must happen after the hijacking, so directly reply with a close [manager forwardPreviousInterceptorCloseWithTrailingMetadata:@{@"grpc-status" : @"0"} error:nil]; + [manager shutDown]; } receiveNextMessagesHook:nil responseHeaderHook:^(NSDictionary *initialMetadata, GRPCInterceptorManager *manager) { @@ -1563,14 +1549,16 @@ static dispatch_once_t initGlobalInterceptorFactory; XCTAssertEqual(error.code, GRPC_STATUS_CANCELLED); [expectCallInternalComplete fulfill]; } - didWriteDataHook:nil]; + didWriteDataHook:nil]; NSArray *requests = @[ @1, @2, @3, @4 ]; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.interceptorFactories = @[ [[DefaultInterceptorFactory alloc] init], factory ]; @@ -1679,7 +1667,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.flowControlEnabled = YES; @@ -1734,8 +1724,7 @@ static dispatch_once_t initGlobalInterceptorFactory; - (void)testConflictingGlobalInterceptors { id factory = [[HookInterceptorFactory alloc] - initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) startHook:nil writeDataHook:nil finishHook:nil @@ -1767,8 +1756,7 @@ static dispatch_once_t initGlobalInterceptorFactory; __block NSUInteger didWriteDataCount = 0; id factory = [[HookInterceptorFactory alloc] - initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager) { startCount++; @@ -1864,7 +1852,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.flowControlEnabled = YES; diff --git a/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m b/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m index a9c69183332..c8d21199454 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m +++ b/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m @@ -18,6 +18,7 @@ #import #import +#import #import "InteropTests.h" @@ -60,8 +61,8 @@ static int32_t kLocalInteropServerOverhead = 10; [GRPCCall useInsecureConnectionsForHost:kLocalCleartextHost]; } -+ (GRPCTransportType)transportType { - return GRPCTransportTypeInsecure; ++ (GRPCTransportId)transport { + return GRPCTransportImplList.core_insecure; } @end diff --git a/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m b/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m index e8222f602f4..d28513cc673 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m +++ b/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m @@ -18,6 +18,7 @@ #import #import +#import #import "InteropTests.h" // The server address is derived from preprocessor macro, which is @@ -57,7 +58,11 @@ static int32_t kLocalInteropServerOverhead = 10; } + (GRPCTransportType)transportType { - return GRPCTransportTypeChttp2BoringSSL; + return GRPCTransportTypeDefault; +} + ++ (GRPCTransportId)transport { + return GRPCTransportImplList.core_secure; } - (void)setUp { diff --git a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m index 14ba2871aa2..fef9f2e7ddd 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m +++ b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m @@ -18,9 +18,7 @@ #import -#ifdef GRPC_COMPILE_WITH_CRONET #import -#endif #import #import #import diff --git a/src/objective-c/tests/InteropTests/InteropTestsRemote.m b/src/objective-c/tests/InteropTests/InteropTestsRemote.m index c1cd9b81efc..2dd8f0aed89 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsRemote.m +++ b/src/objective-c/tests/InteropTests/InteropTestsRemote.m @@ -53,14 +53,8 @@ static int32_t kRemoteInteropServerOverhead = 12; return kRemoteInteropServerOverhead; // bytes } -#ifdef GRPC_COMPILE_WITH_CRONET -+ (GRPCTransportType)transportType { - return GRPCTransportTypeCronet; -} -#else + (GRPCTransportType)transportType { return GRPCTransportTypeChttp2BoringSSL; } -#endif @end diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile index 60d2a98fba2..4a821df85dc 100644 --- a/src/objective-c/tests/Podfile +++ b/src/objective-c/tests/Podfile @@ -50,13 +50,13 @@ end pod 'BoringSSL-GRPC', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true - pod 'gRPC', :path => GRPC_LOCAL_SRC + pod 'gRPC/GRPCCoreCronet', :path => GRPC_LOCAL_SRC pod 'gRPC-Core', :path => GRPC_LOCAL_SRC pod 'gRPC-RxLibrary', :path => GRPC_LOCAL_SRC pod 'gRPC-ProtoRPC', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true pod 'RemoteTest', :path => "RemoteTestClient", :inhibit_warnings => true - pod 'gRPC-Core/Cronet-Implementation', :path => GRPC_LOCAL_SRC + # pod 'gRPC-Core/Cronet-Implementation', :path => GRPC_LOCAL_SRC pod 'CronetFramework', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" pod 'gRPC-Core/Tests', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true end diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index 737d52b547d..a37b2a75d5f 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -630,7 +630,7 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", + "${PODS_CONFIGURATION_BUILD_DIR}/gRPC.default-GRPCCoreCronet/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; outputPaths = ( @@ -728,7 +728,7 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", + "${PODS_CONFIGURATION_BUILD_DIR}/gRPC.default-GRPCCoreCronet/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; outputPaths = ( diff --git a/src/objective-c/tests/UnitTests/ChannelPoolTest.m b/src/objective-c/tests/UnitTests/ChannelPoolTest.m index eab8c5193fb..0b1eca389b9 100644 --- a/src/objective-c/tests/UnitTests/ChannelPoolTest.m +++ b/src/objective-c/tests/UnitTests/ChannelPoolTest.m @@ -18,9 +18,9 @@ #import -#import "../../GRPCClient/private/GRPCChannel.h" -#import "../../GRPCClient/private/GRPCChannelPool+Test.h" -#import "../../GRPCClient/private/GRPCCompletionQueue.h" +#import "../../GRPCClient/private/GRPCCore/GRPCChannel.h" +#import "../../GRPCClient/private/GRPCCore/GRPCChannelPool+Test.h" +#import "../../GRPCClient/private/GRPCCore/GRPCCompletionQueue.h" #define TEST_TIMEOUT 32 diff --git a/src/objective-c/tests/UnitTests/ChannelTests.m b/src/objective-c/tests/UnitTests/ChannelTests.m index df78e8b1162..1ed0f16ecaf 100644 --- a/src/objective-c/tests/UnitTests/ChannelTests.m +++ b/src/objective-c/tests/UnitTests/ChannelTests.m @@ -19,11 +19,11 @@ #import #import "../../GRPCClient/GRPCCallOptions.h" -#import "../../GRPCClient/private/GRPCChannel.h" -#import "../../GRPCClient/private/GRPCChannelPool+Test.h" -#import "../../GRPCClient/private/GRPCChannelPool.h" -#import "../../GRPCClient/private/GRPCCompletionQueue.h" -#import "../../GRPCClient/private/GRPCWrappedCall.h" +#import "../../GRPCClient/private/GRPCCore/GRPCChannel.h" +#import "../../GRPCClient/private/GRPCCore/GRPCChannelPool+Test.h" +#import "../../GRPCClient/private/GRPCCore/GRPCChannelPool.h" +#import "../../GRPCClient/private/GRPCCore/GRPCCompletionQueue.h" +#import "../../GRPCClient/private/GRPCCore/GRPCWrappedCall.h" static NSString *kDummyHost = @"dummy.host"; static NSString *kDummyPath = @"/dummy/path"; diff --git a/src/objective-c/tests/UnitTests/NSErrorUnitTests.m b/src/objective-c/tests/UnitTests/NSErrorUnitTests.m index 8a4f03a4460..74e5794c480 100644 --- a/src/objective-c/tests/UnitTests/NSErrorUnitTests.m +++ b/src/objective-c/tests/UnitTests/NSErrorUnitTests.m @@ -20,7 +20,7 @@ #import -#import "../../GRPCClient/private/NSError+GRPC.h" +#import "../../GRPCClient/private/GRPCCore/NSError+GRPC.h" @interface NSErrorUnitTests : XCTestCase diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index c9723933fcd..fa4d7608c26 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -42,10 +42,8 @@ s.module_name = name s.header_dir = name - src_dir = 'src/objective-c/GRPCClient' - s.dependency 'gRPC-RxLibrary', version - s.default_subspec = 'Main' + s.default_subspec = 'Interface', 'GRPCCore' # Certificates, to be able to establish TLS connections: s.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } @@ -56,29 +54,75 @@ 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO', } - s.subspec 'Main' do |ss| - ss.header_mappings_dir = "#{src_dir}" + s.subspec 'Interface' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' - ss.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}" - ss.exclude_files = "#{src_dir}/GRPCCall+GID.{h,m}" - ss.private_header_files = "#{src_dir}/private/*.h", "#{src_dir}/internal/*.h" + ss.public_header_files = 'src/objective-c/GRPCClient/GRPCCall.h', + 'src/objective-c/GRPCClient/GRPCCall+Interceptor.h', + 'src/objective-c/GRPCClient/GRPCCallOptions.h', + 'src/objective-c/GRPCClient/GRPCInterceptor.h', + 'src/objective-c/GRPCClient/GRPCTransport.h', + 'src/objective-c/GRPCClient/GRPCDispatchable.h', + 'src/objective-c/GRPCClient/internal/*.h' + + ss.source_files = 'src/objective-c/GRPCClient/GRPCCall.h', + 'src/objective-c/GRPCClient/GRPCCall.m', + 'src/objective-c/GRPCClient/GRPCCall+Interceptor.h', + 'src/objective-c/GRPCClient/GRPCCall+Interceptor.m', + 'src/objective-c/GRPCClient/GRPCCallOptions.h', + 'src/objective-c/GRPCClient/GRPCCallOptions.m', + 'src/objective-c/GRPCClient/GRPCDispatchable.h', + 'src/objective-c/GRPCClient/GRPCInterceptor.h', + 'src/objective-c/GRPCClient/GRPCInterceptor.m', + 'src/objective-c/GRPCClient/GRPCTransport.h', + 'src/objective-c/GRPCClient/GRPCTransport.m', + 'src/objective-c/GRPCClient/private/GRPCTransport+Private.h', + 'src/objective-c/GRPCClient/private/GRPCTransport+Private.m' + end + + s.subspec 'GRPCCore' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' + + ss.public_header_files = 'src/objective-c/GRPCClient/ChannelArg.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', + 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', + 'src/objective-c/GRPCClient/GRPCCall+Tests.h', + 'src/objective-c/GRPCClient/GRPCCallLegacy.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', + 'src/objective-c/GRPCClient/internal_testing/*.h' + ss.private_header_files = 'src/objective-c/GRPCClient/private/GRPCCore/*.h' + ss.source_files = 'src/objective-c/GRPCClient/internal_testing/*.h', + 'src/objective-c/GRPCClient/private/GRPCCore/*.{h,m}', + 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.m', + 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.m', + 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', + 'src/objective-c/GRPCClient/GRPCCall+OAuth2.m', + 'src/objective-c/GRPCClient/GRPCCall+Tests.h', + 'src/objective-c/GRPCClient/GRPCCall+Tests.m', + 'src/objective-c/GRPCClient/GRPCCallLegacy.h', + 'src/objective-c/GRPCClient/GRPCCallLegacy.m' ss.dependency 'gRPC-Core', version + ss.dependency "#{s.name}/Interface", version + end + + s.subspec 'GRPCCoreCronet' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' + + ss.source_files = 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.m', + 'src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/*.{h,m}' + ss.dependency 'CronetFramework' + ss.dependency 'gRPC-Core/Cronet-Implementation', version end # CFStream is now default. Leaving this subspec only for compatibility purpose. s.subspec 'CFStream' do |ss| - ss.dependency "#{s.name}/Main", version - end - - s.subspec 'GID' do |ss| - ss.ios.deployment_target = '7.0' - - ss.header_mappings_dir = "#{src_dir}" - - ss.source_files = "#{src_dir}/GRPCCall+GID.{h,m}" - - ss.dependency "#{s.name}/Main", version - ss.dependency 'Google/SignIn' + ss.dependency "#{s.name}/GRPCCore", version end end From 640966dbf397b26a763d1b445a522d6fa3d59eca Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 22 Jul 2019 10:03:08 -0700 Subject: [PATCH 0947/1555] fix internal testing targets --- gRPC.podspec | 2 +- src/objective-c/tests/Podfile | 2 +- templates/gRPC.podspec.template | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gRPC.podspec b/gRPC.podspec index 815da6ef7c1..b2d7b910042 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -90,7 +90,7 @@ Pod::Spec.new do |s| 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', 'src/objective-c/GRPCClient/internal_testing/*.h' ss.private_header_files = 'src/objective-c/GRPCClient/private/GRPCCore/*.h' - ss.source_files = 'src/objective-c/GRPCClient/internal_testing/*.h', + ss.source_files = 'src/objective-c/GRPCClient/internal_testing/*.{h,m}', 'src/objective-c/GRPCClient/private/GRPCCore/*.{h,m}', 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.m', diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile index 4a821df85dc..20a68f7bf67 100644 --- a/src/objective-c/tests/Podfile +++ b/src/objective-c/tests/Podfile @@ -116,7 +116,7 @@ post_install do |installer| # the test target 'InteropTestsRemoteWithCronet' # Activate GRPCCall+InternalTests functions for the dedicated build configuration 'Test', which will # be used by all test targets using it. - if /gRPC-(mac|i)OS/.match(target.name) + if /gRPC(-macOS|-iOS|\.)/.match(target.name) target.build_configurations.each do |config| if config.name == 'Cronet' config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_COMPILE_WITH_CRONET=1 GRPC_TEST_OBJC=1' diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index fa4d7608c26..2ba7089c717 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -92,7 +92,7 @@ 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', 'src/objective-c/GRPCClient/internal_testing/*.h' ss.private_header_files = 'src/objective-c/GRPCClient/private/GRPCCore/*.h' - ss.source_files = 'src/objective-c/GRPCClient/internal_testing/*.h', + ss.source_files = 'src/objective-c/GRPCClient/internal_testing/*.{h,m}', 'src/objective-c/GRPCClient/private/GRPCCore/*.{h,m}', 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.m', From 6a2bec7fcdb1164bf338e5867b55421d9c492958 Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Fri, 19 Jul 2019 11:30:39 -0700 Subject: [PATCH 0948/1555] Channelz: track listen sockets in the server node --- src/core/lib/channel/channelz.cc | 24 ++++++++++++++++-------- src/core/lib/channel/channelz.h | 19 ++++++++++++------- src/core/lib/surface/server.cc | 15 ++++++--------- src/core/lib/surface/server.h | 4 ---- 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/core/lib/channel/channelz.cc b/src/core/lib/channel/channelz.cc index b9f65870cfe..5aabedac043 100644 --- a/src/core/lib/channel/channelz.cc +++ b/src/core/lib/channel/channelz.cc @@ -303,9 +303,7 @@ void ChannelNode::RemoveChildSubchannel(intptr_t child_uuid) { // ServerNode::ServerNode(grpc_server* server, size_t channel_tracer_max_nodes) - : BaseNode(EntityType::kServer), - server_(server), - trace_(channel_tracer_max_nodes) {} + : BaseNode(EntityType::kServer), trace_(channel_tracer_max_nodes) {} ServerNode::~ServerNode() {} @@ -319,6 +317,16 @@ void ServerNode::RemoveChildSocket(intptr_t child_uuid) { child_sockets_.erase(child_uuid); } +void ServerNode::AddChildListenSocket(intptr_t child_uuid) { + MutexLock lock(&child_mu_); + child_listen_sockets_.insert(MakePair(child_uuid, true)); +} + +void ServerNode::RemoveChildListenSocket(intptr_t child_uuid) { + MutexLock lock(&child_mu_); + child_listen_sockets_.erase(child_uuid); +} + char* ServerNode::RenderServerSockets(intptr_t start_socket_id, intptr_t max_results) { // If user does not set max_results, we choose 500. @@ -382,17 +390,17 @@ grpc_json* ServerNode::RenderJson() { // ask CallCountingHelper to populate trace and call count data. call_counter_.PopulateCallCounts(json); json = top_level_json; - ChildRefsList listen_sockets; - grpc_server_populate_listen_sockets(server_, &listen_sockets); - if (!listen_sockets.empty()) { + // Render listen sockets + MutexLock lock(&child_mu_); + if (!child_listen_sockets_.empty()) { grpc_json* array_parent = grpc_json_create_child( nullptr, json, "listenSocket", nullptr, GRPC_JSON_ARRAY, false); - for (size_t i = 0; i < listen_sockets.size(); ++i) { + for (const auto& it : child_listen_sockets_) { json_iterator = grpc_json_create_child(json_iterator, array_parent, nullptr, nullptr, GRPC_JSON_OBJECT, false); grpc_json_add_number_string_child(json_iterator, nullptr, "socketId", - listen_sockets[i]); + it.first); } } return top_level_json; diff --git a/src/core/lib/channel/channelz.h b/src/core/lib/channel/channelz.h index a02cb82cc75..4f4dc76f8ef 100644 --- a/src/core/lib/channel/channelz.h +++ b/src/core/lib/channel/channelz.h @@ -58,11 +58,6 @@ namespace channelz { grpc_arg MakeParentUuidArg(intptr_t parent_uuid); intptr_t GetParentUuidFromArgs(const grpc_channel_args& args); -// TODO(ncteisen), this only contains the uuids of the children for now, -// since that is all that is strictly needed. In a future enhancement we will -// add human readable names as in the channelz.proto -typedef InlinedVector ChildRefsList; - class SocketNode; namespace testing { @@ -217,6 +212,13 @@ class ServerNode : public BaseNode { void RemoveChildSocket(intptr_t child_uuid); + // TODO(ncteisen): This only takes in the uuid of the child socket for now, + // since that is all that is strictly needed. In a future enhancement we will + // add human readable names as in the channelz.proto + void AddChildListenSocket(intptr_t child_uuid); + + void RemoveChildListenSocket(intptr_t child_uuid); + // proxy methods to composed classes. void AddTraceEvent(ChannelTrace::Severity severity, const grpc_slice& data) { trace_.AddTraceEvent(severity, data); @@ -232,11 +234,14 @@ class ServerNode : public BaseNode { void RecordCallSucceeded() { call_counter_.RecordCallSucceeded(); } private: - grpc_server* server_; CallCountingHelper call_counter_; ChannelTrace trace_; - Mutex child_mu_; // Guards child map below. + Mutex child_mu_; // Guards child maps below. Map> child_sockets_; + // TODO(roth): We don't actually use the values here, only the keys, so + // these should be sets instead of maps, but we don't currently have a set + // implementation. Change this if/when we have one. + Map child_listen_sockets_; }; // Handles channelz bookkeeping for sockets diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index a1c7d132ade..ad929e1d639 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -1252,15 +1252,6 @@ void grpc_server_setup_transport( grpc_transport_perform_op(transport, op); } -void grpc_server_populate_listen_sockets( - grpc_server* server, grpc_core::channelz::ChildRefsList* listen_sockets) { - gpr_mu_lock(&server->mu_global); - for (listener* l = server->listeners; l != nullptr; l = l->next) { - listen_sockets->push_back(l->socket_uuid); - } - gpr_mu_unlock(&server->mu_global); -} - void done_published_shutdown(void* done_arg, grpc_cq_completion* storage) { (void)done_arg; gpr_free(storage); @@ -1348,6 +1339,9 @@ void grpc_server_shutdown_and_notify(grpc_server* server, GRPC_CLOSURE_INIT(&l->destroy_done, listener_destroy_done, server, grpc_schedule_on_exec_ctx); l->destroy(server, l->arg, &l->destroy_done); + if (server->channelz_server != nullptr && l->socket_uuid != 0) { + server->channelz_server->RemoveChildListenSocket(l->socket_uuid); + } } channel_broadcaster_shutdown(&broadcaster, true /* send_goaway */, @@ -1411,6 +1405,9 @@ void grpc_server_add_listener(grpc_server* server, void* arg, l->start = start; l->destroy = destroy; l->socket_uuid = socket_uuid; + if (server->channelz_server != nullptr && socket_uuid != 0) { + server->channelz_server->AddChildListenSocket(socket_uuid); + } l->next = server->listeners; server->listeners = l; } diff --git a/src/core/lib/surface/server.h b/src/core/lib/surface/server.h index 926a5825006..67ad0310a96 100644 --- a/src/core/lib/surface/server.h +++ b/src/core/lib/surface/server.h @@ -51,10 +51,6 @@ void grpc_server_setup_transport( socket_node, grpc_resource_user* resource_user = nullptr); -/* fills in the uuids of all listen sockets on this server */ -void grpc_server_populate_listen_sockets( - grpc_server* server, grpc_core::channelz::ChildRefsList* listen_sockets); - grpc_core::channelz::ServerNode* grpc_server_get_channelz_node( grpc_server* server); From 685695f8bcb27dc2e7c70e0e34e2169dfb414b53 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Mon, 22 Jul 2019 22:33:14 +0200 Subject: [PATCH 0949/1555] Trying one another fix for upb. --- bazel/grpc_deps.bzl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index af177cda78b..8fe090ad5cb 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -206,9 +206,9 @@ def grpc_deps(): if "upb" not in native.existing_rules(): http_archive( name = "upb", - sha256 = "d2142e966d4d122ace5c2cc9afc86f12bf0ff93c39544d7a6c6fdcd69d767985", - strip_prefix = "upb-9605c7093c269a4767b9c4a57e2ca021c725644d", - url = "https://github.com/nicolasnoble/upb/archive/9605c7093c269a4767b9c4a57e2ca021c725644d.tar.gz", + sha256 = "f479b263d82690a97b234cb37c8b4026cb7aa10ec578f14e8408dbfa2529a635", + strip_prefix = "upb-6e85c2bf036c4a18a45224dd9d929ab3639e67f3", + url = "https://github.com/nicolasnoble/upb/archive/6e85c2bf036c4a18a45224dd9d929ab3639e67f3.tar.gz", ) if "envoy_api" not in native.existing_rules(): http_archive( From 1c54390f4f02dd6567e58af5f12303ffd0d92660 Mon Sep 17 00:00:00 2001 From: Igor Zhilianin Date: Mon, 22 Jul 2019 00:17:20 +0300 Subject: [PATCH 0950/1555] Check call.trailing_metadata() for None before iterating it --- src/python/grpcio_status/grpc_status/rpc_status.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/python/grpcio_status/grpc_status/rpc_status.py b/src/python/grpcio_status/grpc_status/rpc_status.py index 76891e2422e..4e424e1394b 100644 --- a/src/python/grpcio_status/grpc_status/rpc_status.py +++ b/src/python/grpcio_status/grpc_status/rpc_status.py @@ -52,6 +52,8 @@ def from_call(call): ValueError: If the gRPC call's code or details are inconsistent with the status code and message inside of the google.rpc.status.Status. """ + if call.trailing_metadata() is None: + return None for key, value in call.trailing_metadata(): if key == _GRPC_DETAILS_METADATA_KEY: rich_status = status_pb2.Status.FromString(value) From a1189961afe41f6be5c19e7f9a228afcc7503e37 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Mon, 22 Jul 2019 23:09:17 +0200 Subject: [PATCH 0951/1555] Another upb Windows change. --- bazel/grpc_deps.bzl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 8fe090ad5cb..2160d84525b 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -206,9 +206,9 @@ def grpc_deps(): if "upb" not in native.existing_rules(): http_archive( name = "upb", - sha256 = "f479b263d82690a97b234cb37c8b4026cb7aa10ec578f14e8408dbfa2529a635", - strip_prefix = "upb-6e85c2bf036c4a18a45224dd9d929ab3639e67f3", - url = "https://github.com/nicolasnoble/upb/archive/6e85c2bf036c4a18a45224dd9d929ab3639e67f3.tar.gz", + sha256 = "67874e217f39e66a3015f51dcdc6831575c25f2260fff9b80482f190278ea586", + strip_prefix = "upb-4d8af5e4b998fccc8c9a5d5505866f4722f64954", + url = "https://github.com/nicolasnoble/upb/archive/4d8af5e4b998fccc8c9a5d5505866f4722f64954.tar.gz", ) if "envoy_api" not in native.existing_rules(): http_archive( From 81013e54d38f0611cc1782d801709e400a75cdeb Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Mon, 22 Jul 2019 14:49:33 -0700 Subject: [PATCH 0952/1555] Move GetChannelConnectivityStateChangeString to channelz code --- .../filters/client_channel/client_channel.cc | 19 +------------------ src/core/lib/channel/channelz.h | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 19105c01429..6c273180da9 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -733,7 +733,7 @@ class ChannelData::ConnectivityStateAndPickerSetter { chand->channelz_node_->AddTraceEvent( channelz::ChannelTrace::Severity::Info, grpc_slice_from_static_string( - GetChannelConnectivityStateChangeString(state))); + channelz::GetChannelConnectivityStateChangeString(state))); } // Bounce into the data plane combiner to reset the picker. GRPC_CHANNEL_STACK_REF(chand->owning_stack_, @@ -744,23 +744,6 @@ class ChannelData::ConnectivityStateAndPickerSetter { } private: - static const char* GetChannelConnectivityStateChangeString( - grpc_connectivity_state state) { - switch (state) { - case GRPC_CHANNEL_IDLE: - return "Channel state change to IDLE"; - case GRPC_CHANNEL_CONNECTING: - return "Channel state change to CONNECTING"; - case GRPC_CHANNEL_READY: - return "Channel state change to READY"; - case GRPC_CHANNEL_TRANSIENT_FAILURE: - return "Channel state change to TRANSIENT_FAILURE"; - case GRPC_CHANNEL_SHUTDOWN: - return "Channel state change to SHUTDOWN"; - } - GPR_UNREACHABLE_CODE(return "UNKNOWN"); - } - static void SetPicker(void* arg, grpc_error* ignored) { auto* self = static_cast(arg); // Update picker. diff --git a/src/core/lib/channel/channelz.h b/src/core/lib/channel/channelz.h index a02cb82cc75..554e9ae4ad7 100644 --- a/src/core/lib/channel/channelz.h +++ b/src/core/lib/channel/channelz.h @@ -70,6 +70,23 @@ class CallCountingHelperPeer; class ChannelNodePeer; } // namespace testing +inline static const char* GetChannelConnectivityStateChangeString( + grpc_connectivity_state state) { + switch (state) { + case GRPC_CHANNEL_IDLE: + return "Channel state change to IDLE"; + case GRPC_CHANNEL_CONNECTING: + return "Channel state change to CONNECTING"; + case GRPC_CHANNEL_READY: + return "Channel state change to READY"; + case GRPC_CHANNEL_TRANSIENT_FAILURE: + return "Channel state change to TRANSIENT_FAILURE"; + case GRPC_CHANNEL_SHUTDOWN: + return "Channel state change to SHUTDOWN"; + } + GPR_UNREACHABLE_CODE(return "UNKNOWN"); +} + // base class for all channelz entities class BaseNode : public RefCounted { public: From 6898c23a5d22486e3204129ff2c1e856f9332ca0 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 18 Jul 2019 21:36:23 -0700 Subject: [PATCH 0953/1555] Add experimental control plane creds C-core API --- CMakeLists.txt | 35 ++ Makefile | 36 ++ build.yaml | 9 + .../lib/security/credentials/credentials.cc | 72 +++ .../lib/security/credentials/credentials.h | 43 ++ src/core/lib/surface/init_secure.cc | 5 +- test/core/security/BUILD | 13 + .../control_plane_credentials_test.cc | 458 ++++++++++++++++++ .../generated/sources_and_headers.json | 16 + tools/run_tests/generated/tests.json | 24 + 10 files changed, 710 insertions(+), 1 deletion(-) create mode 100644 test/core/security/control_plane_credentials_test.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 726638aa004..23305ce6fd9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -331,6 +331,7 @@ add_dependencies(buildtests_c grpc_channel_stack_builder_test) add_dependencies(buildtests_c grpc_channel_stack_test) add_dependencies(buildtests_c grpc_completion_queue_test) add_dependencies(buildtests_c grpc_completion_queue_threading_test) +add_dependencies(buildtests_c grpc_control_plane_credentials_test) add_dependencies(buildtests_c grpc_credentials_test) add_dependencies(buildtests_c grpc_ipv6_loopback_available_test) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) @@ -8210,6 +8211,40 @@ target_link_libraries(grpc_completion_queue_threading_test target_compile_options(grpc_completion_queue_threading_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) endif() +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + +add_executable(grpc_control_plane_credentials_test + test/core/security/control_plane_credentials_test.cc +) + + +target_include_directories(grpc_control_plane_credentials_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} +) + +target_link_libraries(grpc_control_plane_credentials_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + grpc + gpr +) + + # avoid dependency on libstdc++ + if (_gRPC_CORE_NOSTDCXX_FLAGS) + set_target_properties(grpc_control_plane_credentials_test PROPERTIES LINKER_LANGUAGE C) + target_compile_options(grpc_control_plane_credentials_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) + endif() + endif (gRPC_BUILD_TESTS) add_executable(grpc_create_jwt diff --git a/Makefile b/Makefile index 4ca15ac0f47..4755955de7d 100644 --- a/Makefile +++ b/Makefile @@ -1054,6 +1054,7 @@ grpc_channel_stack_builder_test: $(BINDIR)/$(CONFIG)/grpc_channel_stack_builder_ grpc_channel_stack_test: $(BINDIR)/$(CONFIG)/grpc_channel_stack_test grpc_completion_queue_test: $(BINDIR)/$(CONFIG)/grpc_completion_queue_test grpc_completion_queue_threading_test: $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test +grpc_control_plane_credentials_test: $(BINDIR)/$(CONFIG)/grpc_control_plane_credentials_test grpc_create_jwt: $(BINDIR)/$(CONFIG)/grpc_create_jwt grpc_credentials_test: $(BINDIR)/$(CONFIG)/grpc_credentials_test grpc_ipv6_loopback_available_test: $(BINDIR)/$(CONFIG)/grpc_ipv6_loopback_available_test @@ -1490,6 +1491,7 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/grpc_channel_stack_test \ $(BINDIR)/$(CONFIG)/grpc_completion_queue_test \ $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test \ + $(BINDIR)/$(CONFIG)/grpc_control_plane_credentials_test \ $(BINDIR)/$(CONFIG)/grpc_credentials_test \ $(BINDIR)/$(CONFIG)/grpc_ipv6_loopback_available_test \ $(BINDIR)/$(CONFIG)/grpc_json_token_test \ @@ -2069,6 +2071,8 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/grpc_completion_queue_test || ( echo test grpc_completion_queue_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_completion_queue_threading_test" $(Q) $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test || ( echo test grpc_completion_queue_threading_test failed ; exit 1 ) + $(E) "[RUN] Testing grpc_control_plane_credentials_test" + $(Q) $(BINDIR)/$(CONFIG)/grpc_control_plane_credentials_test || ( echo test grpc_control_plane_credentials_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_credentials_test" $(Q) $(BINDIR)/$(CONFIG)/grpc_credentials_test || ( echo test grpc_credentials_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_ipv6_loopback_available_test" @@ -10936,6 +10940,38 @@ endif endif +GRPC_CONTROL_PLANE_CREDENTIALS_TEST_SRC = \ + test/core/security/control_plane_credentials_test.cc \ + +GRPC_CONTROL_PLANE_CREDENTIALS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_CONTROL_PLANE_CREDENTIALS_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/grpc_control_plane_credentials_test: openssl_dep_error + +else + + + +$(BINDIR)/$(CONFIG)/grpc_control_plane_credentials_test: $(GRPC_CONTROL_PLANE_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LD) $(LDFLAGS) $(GRPC_CONTROL_PLANE_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_control_plane_credentials_test + +endif + +$(OBJDIR)/$(CONFIG)/test/core/security/control_plane_credentials_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_grpc_control_plane_credentials_test: $(GRPC_CONTROL_PLANE_CREDENTIALS_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(GRPC_CONTROL_PLANE_CREDENTIALS_TEST_OBJS:.o=.dep) +endif +endif + + GRPC_CREATE_JWT_SRC = \ test/core/security/create_jwt.cc \ test/core/util/cmdline.cc \ diff --git a/build.yaml b/build.yaml index 6d69c419b71..7b4a396b19c 100644 --- a/build.yaml +++ b/build.yaml @@ -2845,6 +2845,15 @@ targets: - gpr exclude_iomgrs: - uv +- name: grpc_control_plane_credentials_test + build: test + language: c + src: + - test/core/security/control_plane_credentials_test.cc + deps: + - grpc_test_util + - grpc + - gpr - name: grpc_create_jwt build: tool language: c diff --git a/src/core/lib/security/credentials/credentials.cc b/src/core/lib/security/credentials/credentials.cc index 90452d68d61..2a1a5546bcf 100644 --- a/src/core/lib/security/credentials/credentials.cc +++ b/src/core/lib/security/credentials/credentials.cc @@ -45,6 +45,78 @@ void grpc_channel_credentials_release(grpc_channel_credentials* creds) { if (creds) creds->Unref(); } +static grpc_core::Map, + grpc_core::RefCountedPtr, + grpc_core::StringLess>* g_grpc_control_plane_creds; +static gpr_mu g_control_plane_creds_mu; + +static void do_control_plane_creds_init() { + gpr_mu_init(&g_control_plane_creds_mu); + GPR_ASSERT(g_grpc_control_plane_creds == nullptr); + g_grpc_control_plane_creds = grpc_core::New< + grpc_core::Map, + grpc_core::RefCountedPtr, + grpc_core::StringLess>>(); +} + +void grpc_control_plane_credentials_init() { + static gpr_once once_init_control_plane_creds = GPR_ONCE_INIT; + gpr_once_init(&once_init_control_plane_creds, do_control_plane_creds_init); +} + +bool grpc_channel_credentials_attach_credentials( + grpc_channel_credentials* credentials, const char* authority, + grpc_channel_credentials* control_plane_creds) { + grpc_core::ExecCtx exec_ctx; + return credentials->attach_credentials(authority, control_plane_creds->Ref()); +} + +bool grpc_control_plane_credentials_register( + const char* authority, grpc_channel_credentials* control_plane_creds) { + grpc_core::ExecCtx exec_ctx; + { + grpc_core::MutexLock lock(&g_control_plane_creds_mu); + auto key = grpc_core::UniquePtr(gpr_strdup(authority)); + if (g_grpc_control_plane_creds->find(key) != + g_grpc_control_plane_creds->end()) { + return false; + } + (*g_grpc_control_plane_creds)[std::move(key)] = control_plane_creds->Ref(); + } + return true; +} + +bool grpc_channel_credentials::attach_credentials( + const char* authority, + grpc_core::RefCountedPtr control_plane_creds) { + auto key = grpc_core::UniquePtr(gpr_strdup(authority)); + if (local_control_plane_creds_.find(key) != + local_control_plane_creds_.end()) { + return false; + } + local_control_plane_creds_[std::move(key)] = std::move(control_plane_creds); + return true; +} + +grpc_core::RefCountedPtr +grpc_channel_credentials::get_control_plane_credentials(const char* authority) { + { + auto key = grpc_core::UniquePtr(gpr_strdup(authority)); + auto local_lookup = local_control_plane_creds_.find(key); + if (local_lookup != local_control_plane_creds_.end()) { + return local_lookup->second; + } + { + grpc_core::MutexLock lock(&g_control_plane_creds_mu); + auto global_lookup = g_grpc_control_plane_creds->find(key); + if (global_lookup != g_grpc_control_plane_creds->end()) { + return global_lookup->second; + } + } + } + return duplicate_without_call_credentials(); +} + void grpc_call_credentials_release(grpc_call_credentials* creds) { GRPC_API_TRACE("grpc_call_credentials_release(creds=%p)", 1, (creds)); grpc_core::ExecCtx exec_ctx; diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h index 907cf2b02f6..0d95f8f4caa 100644 --- a/src/core/lib/security/credentials/credentials.h +++ b/src/core/lib/security/credentials/credentials.h @@ -26,7 +26,9 @@ #include #include "src/core/lib/transport/metadata_batch.h" +#include "src/core/lib/gprpp/map.h" #include "src/core/lib/gprpp/ref_counted.h" +#include "src/core/lib/gprpp/sync.h" #include "src/core/lib/http/httpcli.h" #include "src/core/lib/http/parser.h" #include "src/core/lib/iomgr/polling_entity.h" @@ -131,12 +133,31 @@ struct grpc_channel_credentials return args; } + // Attaches control_plane_creds to the local registry, under authority, + // if no other creds are currently registered under authority. Returns + // true if registered successfully and false if not. + bool attach_credentials( + const char* authority, + grpc_core::RefCountedPtr control_plane_creds); + + // Gets the control plane credentials registered under authority. This + // prefers the local control plane creds registry but falls back to the + // global registry. Lastly, this returns self but with any attached + // call credentials stripped off, in the case that neither the local + // registry nor the global registry have an entry for authority. + grpc_core::RefCountedPtr + get_control_plane_credentials(const char* authority); + const char* type() const { return type_; } GRPC_ABSTRACT_BASE_CLASS private: const char* type_; + grpc_core::Map, + grpc_core::RefCountedPtr, + grpc_core::StringLess> + local_control_plane_creds_; }; /* Util to encapsulate the channel credentials in a channel arg. */ @@ -150,6 +171,28 @@ grpc_channel_credentials* grpc_channel_credentials_from_arg( grpc_channel_credentials* grpc_channel_credentials_find_in_args( const grpc_channel_args* args); +/** EXPERIMENTAL. API MAY CHANGE IN THE FUTURE. + Attaches \a control_plane_creds to \a credentials + under the key \a authority. Returns false if \a authority + is already present, in which case no changes are made. + Note that this API is not thread safe. Only one thread may + attach control plane creds to a given credentials object at + any one time, and new control plane creds must not be + attached after \a credentials has been used to create a channel. */ +bool grpc_channel_credentials_attach_credentials( + grpc_channel_credentials* credentials, const char* authority, + grpc_channel_credentials* control_plane_creds); + +/** EXPERIMENTAL. API MAY CHANGE IN THE FUTURE. + Registers \a control_plane_creds in the global registry + under the key \a authority. Returns false if \a authority + is already present, in which case no changes are made. */ +bool grpc_control_plane_credentials_register( + const char* authority, grpc_channel_credentials* control_plane_creds); + +/* Initializes global control plane credentials data. */ +void grpc_control_plane_credentials_init(); + /* --- grpc_credentials_mdelem_array. --- */ typedef struct { diff --git a/src/core/lib/surface/init_secure.cc b/src/core/lib/surface/init_secure.cc index 0e83a11a5f0..233089437e9 100644 --- a/src/core/lib/surface/init_secure.cc +++ b/src/core/lib/surface/init_secure.cc @@ -78,4 +78,7 @@ void grpc_register_security_filters(void) { maybe_prepend_server_auth_filter, nullptr); } -void grpc_security_init() { grpc_core::SecurityRegisterHandshakerFactories(); } +void grpc_security_init() { + grpc_core::SecurityRegisterHandshakerFactories(); + grpc_control_plane_credentials_init(); +} diff --git a/test/core/security/BUILD b/test/core/security/BUILD index 835c0ad7b65..d430ccfe215 100644 --- a/test/core/security/BUILD +++ b/test/core/security/BUILD @@ -76,6 +76,19 @@ grpc_cc_test( ], ) +grpc_cc_test( + name = "control_plane_credentials_test", + srcs = ["control_plane_credentials_test.cc"], + language = "C++", + deps = [ + "//:gpr", + "//:grpc", + "//test/core/end2end:cq_verifier", + "//test/core/end2end:ssl_test_data", + "//test/core/util:grpc_test_util", + ], +) + grpc_cc_test( name = "json_token_test", srcs = ["json_token_test.cc"], diff --git a/test/core/security/control_plane_credentials_test.cc b/test/core/security/control_plane_credentials_test.cc new file mode 100644 index 00000000000..d7c401d9ad1 --- /dev/null +++ b/test/core/security/control_plane_credentials_test.cc @@ -0,0 +1,458 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/security/credentials/credentials.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/iomgr/error.h" +#include "src/core/lib/security/credentials/composite/composite_credentials.h" +#include "src/core/lib/slice/slice_string_helpers.h" + +#include "test/core/util/port.h" +#include "test/core/util/test_config.h" + +#include "test/core/end2end/cq_verifier.h" +#include "test/core/end2end/data/ssl_test_data.h" + +namespace { + +grpc_completion_queue* g_cq; +grpc_server* g_server; +int g_port; + +void drain_cq(grpc_completion_queue* cq) { + grpc_event ev; + do { + ev = grpc_completion_queue_next( + cq, grpc_timeout_milliseconds_to_deadline(5000), nullptr); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); +} + +void* tag(int i) { return (void*)static_cast(i); } + +grpc_channel_credentials* create_test_ssl_plus_token_channel_creds( + const char* token) { + grpc_channel_credentials* channel_creds = + grpc_ssl_credentials_create(test_root_cert, nullptr, nullptr, nullptr); + grpc_call_credentials* call_creds = + grpc_access_token_credentials_create(token, nullptr); + grpc_channel_credentials* composite_creds = + grpc_composite_channel_credentials_create(channel_creds, call_creds, + nullptr); + grpc_channel_credentials_release(channel_creds); + grpc_call_credentials_release(call_creds); + return composite_creds; +} + +grpc_server_credentials* create_test_ssl_server_creds() { + grpc_ssl_pem_key_cert_pair pem_cert_key_pair = {test_server1_key, + test_server1_cert}; + return grpc_ssl_server_credentials_create_ex( + test_root_cert, &pem_cert_key_pair, 1, + GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE, nullptr); +} + +// Perform a simple RPC and capture the ASCII value of the +// authorization metadata sent to the server, if any. Return +// nullptr if no authorization metadata was sent to the server. +grpc_core::UniquePtr perform_call_and_get_authorization_header( + grpc_channel_credentials* channel_creds) { + // Create a new channel and call + grpc_core::UniquePtr server_addr = nullptr; + grpc_core::JoinHostPort(&server_addr, "localhost", g_port); + grpc_arg ssl_name_override = { + GRPC_ARG_STRING, + const_cast(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), + {const_cast("foo.test.google.fr")}}; + grpc_channel_args* channel_args = + grpc_channel_args_copy_and_add(nullptr, &ssl_name_override, 1); + grpc_channel* channel = grpc_secure_channel_create( + channel_creds, server_addr.get(), channel_args, nullptr); + grpc_channel_args_destroy(channel_args); + grpc_call* c; + grpc_call* s; + cq_verifier* cqv = cq_verifier_create(g_cq); + grpc_op ops[6]; + grpc_op* op; + grpc_metadata_array initial_metadata_recv; + grpc_metadata_array trailing_metadata_recv; + grpc_metadata_array request_metadata_recv; + grpc_call_details call_details; + grpc_status_code status; + grpc_call_error error; + grpc_slice details; + gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("request"); + grpc_byte_buffer* request_payload = + grpc_raw_byte_buffer_create(&request_payload_slice, 1); + grpc_slice response_payload_slice = grpc_slice_from_copied_string("response"); + grpc_byte_buffer* response_payload = + grpc_raw_byte_buffer_create(&response_payload_slice, 1); + grpc_byte_buffer* request_payload_recv = nullptr; + grpc_byte_buffer* response_payload_recv = nullptr; + // Start a call + c = grpc_channel_create_call(channel, nullptr, GRPC_PROPAGATE_DEFAULTS, g_cq, + grpc_slice_from_static_string("/foo"), nullptr, + deadline, nullptr); + GPR_ASSERT(c); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op->reserved = nullptr; + op++; + op->op = GRPC_OP_SEND_MESSAGE; + op->data.send_message.send_message = request_payload; + op->flags = 0; + op->reserved = nullptr; + op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; + op->flags = 0; + op->reserved = nullptr; + op++; + op->op = GRPC_OP_RECV_INITIAL_METADATA; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; + op->flags = 0; + op->reserved = nullptr; + op++; + op->op = GRPC_OP_RECV_MESSAGE; + op->data.recv_message.recv_message = &response_payload_recv; + op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; + op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; + op->data.recv_status_on_client.status = &status; + op->data.recv_status_on_client.status_details = &details; + op->flags = 0; + op->reserved = nullptr; + op++; + error = grpc_call_start_batch(c, ops, static_cast(op - ops), tag(1), + nullptr); + GPR_ASSERT(GRPC_CALL_OK == error); + // Request a call on the server + error = + grpc_server_request_call(g_server, &s, &call_details, + &request_metadata_recv, g_cq, g_cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + CQ_EXPECT_COMPLETION(cqv, tag(101), 1); + cq_verify(cqv); + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op->reserved = nullptr; + op++; + op->op = GRPC_OP_SEND_MESSAGE; + op->data.send_message.send_message = response_payload; + op->flags = 0; + op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; + op->data.send_status_from_server.trailing_metadata_count = 0; + op->data.send_status_from_server.status = GRPC_STATUS_OK; + op->flags = 0; + op->reserved = nullptr; + op++; + op->op = GRPC_OP_RECV_MESSAGE; + op->data.recv_message.recv_message = &request_payload_recv; + op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; + op->flags = 0; + op->reserved = nullptr; + op++; + error = grpc_call_start_batch(s, ops, static_cast(op - ops), tag(102), + nullptr); + GPR_ASSERT(GRPC_CALL_OK == error); + CQ_EXPECT_COMPLETION(cqv, tag(102), 1); + CQ_EXPECT_COMPLETION(cqv, tag(1), 1); + cq_verify(cqv); + GPR_ASSERT(status == GRPC_STATUS_OK); + // Extract the ascii value of the authorization header, if present + grpc_core::UniquePtr authorization_header_val; + gpr_log(GPR_DEBUG, "RPC done. Now examine received metadata on server..."); + for (size_t i = 0; i < request_metadata_recv.count; i++) { + char* cur_key = + grpc_dump_slice(request_metadata_recv.metadata[i].key, GPR_DUMP_ASCII); + char* cur_val = grpc_dump_slice(request_metadata_recv.metadata[i].value, + GPR_DUMP_ASCII); + gpr_log(GPR_DEBUG, "key[%" PRIdPTR "]=%s val[%" PRIdPTR "]=%s", i, cur_key, + i, cur_val); + if (gpr_stricmp(cur_key, "authorization") == 0) { + // This test is broken if we found multiple authorization headers. + GPR_ASSERT(authorization_header_val == nullptr); + authorization_header_val.reset(gpr_strdup(cur_val)); + gpr_log(GPR_DEBUG, "Found authorization header: %s", + authorization_header_val.get()); + } + gpr_free(cur_key); + gpr_free(cur_val); + } + // cleanup + grpc_slice_unref(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(response_payload); + grpc_byte_buffer_destroy(request_payload_recv); + grpc_byte_buffer_destroy(response_payload_recv); + grpc_call_unref(c); + grpc_call_unref(s); + cq_verifier_destroy(cqv); + grpc_channel_destroy(channel); + return authorization_header_val; +} + +void test_attach_and_get() { + grpc_channel_credentials* main_creds = + create_test_ssl_plus_token_channel_creds("main-auth-header"); + grpc_channel_credentials* foo_creds = + create_test_ssl_plus_token_channel_creds("foo-auth-header"); + grpc_channel_credentials* bar_creds = + create_test_ssl_plus_token_channel_creds("bar-auth-header"); + auto foo_key = grpc_core::UniquePtr(gpr_strdup("foo")); + GPR_ASSERT(grpc_channel_credentials_attach_credentials( + main_creds, foo_key.get(), foo_creds) == true); + auto bar_key = grpc_core::UniquePtr(gpr_strdup("bar")); + GPR_ASSERT(grpc_channel_credentials_attach_credentials( + main_creds, bar_key.get(), bar_creds) == true); + GPR_ASSERT(grpc_channel_credentials_attach_credentials(main_creds, "foo", + foo_creds) == false); + GPR_ASSERT(grpc_channel_credentials_attach_credentials(main_creds, "bar", + bar_creds) == false); + grpc_channel_credentials_release(foo_creds); + grpc_channel_credentials_release(bar_creds); + { + // Creds that send auth header with value "foo-auth-header" are attached on + // main creds under key "foo" + auto foo_auth_header = perform_call_and_get_authorization_header( + main_creds->get_control_plane_credentials("foo").get()); + GPR_ASSERT(foo_auth_header != nullptr && + gpr_stricmp(foo_auth_header.get(), "Bearer foo-auth-header") == + 0); + } + { + // Creds that send auth header with value "bar-auth-header" are attached on + // main creds under key "bar" + auto bar_auth_header = perform_call_and_get_authorization_header( + main_creds->get_control_plane_credentials("bar").get()); + GPR_ASSERT(bar_auth_header != nullptr && + gpr_stricmp(bar_auth_header.get(), "Bearer bar-auth-header") == + 0); + } + { + // Sanity check that the main creds themselves send an authorization header + // with value "main". + auto main_auth_header = + perform_call_and_get_authorization_header(main_creds); + GPR_ASSERT(main_auth_header != nullptr && + gpr_stricmp(main_auth_header.get(), "Bearer main-auth-header") == + 0); + } + { + // If a key isn't mapped in the per channel or global registries, then the + // credentials should be returned but with their per-call creds stripped. + // The end effect is that we shouldn't see any authorization metadata + // sent from client to server. + auto unmapped_auth_header = perform_call_and_get_authorization_header( + main_creds->get_control_plane_credentials("unmapped").get()); + GPR_ASSERT(unmapped_auth_header == nullptr); + } + grpc_channel_credentials_release(main_creds); +} + +void test_registering_same_creds_under_different_keys() { + grpc_channel_credentials* main_creds = + create_test_ssl_plus_token_channel_creds("main-auth-header"); + grpc_channel_credentials* foo_creds = + create_test_ssl_plus_token_channel_creds("foo-auth-header"); + auto foo_key = grpc_core::UniquePtr(gpr_strdup("foo")); + GPR_ASSERT(grpc_channel_credentials_attach_credentials( + main_creds, foo_key.get(), foo_creds) == true); + auto foo2_key = grpc_core::UniquePtr(gpr_strdup("foo2")); + GPR_ASSERT(grpc_channel_credentials_attach_credentials( + main_creds, foo2_key.get(), foo_creds) == true); + GPR_ASSERT(grpc_channel_credentials_attach_credentials(main_creds, "foo", + foo_creds) == false); + GPR_ASSERT(grpc_channel_credentials_attach_credentials(main_creds, "foo2", + foo_creds) == false); + grpc_channel_credentials_release(foo_creds); + { + // Access foo creds via foo + auto foo_auth_header = perform_call_and_get_authorization_header( + main_creds->get_control_plane_credentials("foo").get()); + GPR_ASSERT(foo_auth_header != nullptr && + gpr_stricmp(foo_auth_header.get(), "Bearer foo-auth-header") == + 0); + } + { + // Access foo creds via foo2 + auto foo_auth_header = perform_call_and_get_authorization_header( + main_creds->get_control_plane_credentials("foo2").get()); + GPR_ASSERT(foo_auth_header != nullptr && + gpr_stricmp(foo_auth_header.get(), "Bearer foo-auth-header") == + 0); + } + grpc_channel_credentials_release(main_creds); +} + +// Note that this test uses control plane creds registered in the global +// map. This global registration is done before this and any other +// test is invoked. +void test_attach_and_get_with_global_registry() { + grpc_channel_credentials* main_creds = + create_test_ssl_plus_token_channel_creds("main-auth-header"); + grpc_channel_credentials* global_override_creds = + create_test_ssl_plus_token_channel_creds("global-override-auth-header"); + grpc_channel_credentials* random_creds = + create_test_ssl_plus_token_channel_creds("random-auth-header"); + auto global_key = grpc_core::UniquePtr(gpr_strdup("global")); + GPR_ASSERT(grpc_channel_credentials_attach_credentials( + main_creds, global_key.get(), global_override_creds) == true); + GPR_ASSERT(grpc_channel_credentials_attach_credentials( + main_creds, "global", global_override_creds) == false); + grpc_channel_credentials_release(global_override_creds); + { + // The global registry should be used if a key isn't registered on the per + // channel registry + auto global_auth_header = perform_call_and_get_authorization_header( + random_creds->get_control_plane_credentials("global").get()); + GPR_ASSERT(global_auth_header != nullptr && + gpr_stricmp(global_auth_header.get(), + "Bearer global-auth-header") == 0); + } + { + // The per-channel registry should be preferred over the global registry + auto override_auth_header = perform_call_and_get_authorization_header( + main_creds->get_control_plane_credentials("global").get()); + GPR_ASSERT(override_auth_header != nullptr && + gpr_stricmp(override_auth_header.get(), + "Bearer global-override-auth-header") == 0); + } + { + // Sanity check that random creds themselves send authorization header with + // value "random". + auto random_auth_header = + perform_call_and_get_authorization_header(random_creds); + GPR_ASSERT(random_auth_header != nullptr && + gpr_stricmp(random_auth_header.get(), + "Bearer random-auth-header") == 0); + } + { + // If a key isn't mapped in the per channel or global registries, then the + // credentials should be returned but with their per-call creds stripped. + // The end effect is that we shouldn't see any authorization metadata + // sent from client to server. + auto unmapped_auth_header = perform_call_and_get_authorization_header( + random_creds->get_control_plane_credentials("unmapped").get()); + GPR_ASSERT(unmapped_auth_header == nullptr); + } + grpc_channel_credentials_release(main_creds); + grpc_channel_credentials_release(random_creds); +} + +} // namespace + +int main(int argc, char** argv) { + { + grpc::testing::TestEnvironment env(argc, argv); + grpc_init(); + // First setup a global server for all tests to use + g_cq = grpc_completion_queue_create_for_next(nullptr); + grpc_server_credentials* server_creds = create_test_ssl_server_creds(); + g_server = grpc_server_create(nullptr, nullptr); + g_port = grpc_pick_unused_port_or_die(); + grpc_server_register_completion_queue(g_server, g_cq, nullptr); + grpc_core::UniquePtr localaddr; + grpc_core::JoinHostPort(&localaddr, "localhost", g_port); + GPR_ASSERT(grpc_server_add_secure_http2_port(g_server, localaddr.get(), + server_creds)); + grpc_server_credentials_release(server_creds); + grpc_server_start(g_server); + { + // First, Register one channel creds in the global registry; all tests + // will have access. + grpc_channel_credentials* global_creds = + create_test_ssl_plus_token_channel_creds("global-auth-header"); + auto global_key = grpc_core::UniquePtr(gpr_strdup("global")); + GPR_ASSERT(grpc_control_plane_credentials_register(global_key.get(), + global_creds) == true); + GPR_ASSERT(grpc_control_plane_credentials_register( + "global", global_creds) == false); + grpc_channel_credentials_release(global_creds); + } + // Run tests + { + test_attach_and_get(); + test_registering_same_creds_under_different_keys(); + test_attach_and_get_with_global_registry(); + } + // cleanup + grpc_completion_queue* shutdown_cq = + grpc_completion_queue_create_for_pluck(nullptr); + grpc_server_shutdown_and_notify(g_server, shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + nullptr) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(g_server); + grpc_completion_queue_shutdown(shutdown_cq); + grpc_completion_queue_destroy(shutdown_cq); + grpc_completion_queue_shutdown(g_cq); + drain_cq(g_cq); + grpc_completion_queue_destroy(g_cq); + grpc_shutdown(); + } + { + grpc::testing::TestEnvironment env(argc, argv); + grpc_init(); + // The entries in the global registry must still persist through + // a full shutdown and restart of the library. + grpc_channel_credentials* global_creds = + create_test_ssl_plus_token_channel_creds("global-auth-header"); + auto global_key = grpc_core::UniquePtr(gpr_strdup("global")); + GPR_ASSERT(grpc_control_plane_credentials_register(global_key.get(), + global_creds) == false); + grpc_channel_credentials_release(global_creds); + // Sanity check that unmapped authorities can still register in + // the global registry. + grpc_channel_credentials* global_creds_2 = + create_test_ssl_plus_token_channel_creds("global-auth-header"); + GPR_ASSERT(grpc_control_plane_credentials_register("global_2", + global_creds_2) == true); + GPR_ASSERT(grpc_control_plane_credentials_register( + "global_2", global_creds_2) == false); + grpc_channel_credentials_release(global_creds_2); + grpc_shutdown(); + } + return 0; +} diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index b2feea44d53..ceec3f0e6c3 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -992,6 +992,22 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "grpc", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c", + "name": "grpc_control_plane_credentials_test", + "src": [ + "test/core/security/control_plane_credentials_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "cmdline", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index d4a19741729..f6aac1d8cd0 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -1341,6 +1341,30 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": false, + "language": "c", + "name": "grpc_control_plane_credentials_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": true + }, { "args": [], "benchmark": false, From 8278d3e6a5e4181d56b5b90f3cea343065548d49 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Mon, 22 Jul 2019 17:24:09 -0700 Subject: [PATCH 0954/1555] Resolving comments --- test/cpp/microbenchmarks/bm_threadpool.cc | 61 ++++++++++++----------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_threadpool.cc b/test/cpp/microbenchmarks/bm_threadpool.cc index cee0fa4c497..128f3c2d63d 100644 --- a/test/cpp/microbenchmarks/bm_threadpool.cc +++ b/test/cpp/microbenchmarks/bm_threadpool.cc @@ -30,9 +30,9 @@ namespace grpc { namespace testing { // This helper class allows a thread to block for a pre-specified number of -// actions. BlockingCounter has an initial non-negative count on initialization +// actions. BlockingCounter has an initial non-negative count on initialization. // Each call to DecrementCount will decrease the count by 1. When making a call -// to Wait, if the count is greater than 0, the thread will be block, until +// to Wait, if the count is greater than 0, the thread will be blocked, until // the count reaches 0. class BlockingCounter { public: @@ -81,7 +81,7 @@ class AddAnotherFunctor : public grpc_experimental_completion_queue_functor { } else { callback->counter_->DecrementCount(); } - // Suicide + // Suicides. delete callback; } @@ -93,9 +93,9 @@ class AddAnotherFunctor : public grpc_experimental_completion_queue_functor { void ThreadPoolAddAnotherHelper(benchmark::State& state, int concurrent_functor) { - const int num_threads = state.range(1); const int num_iterations = state.range(0); - // number of adds done by each closure + const int num_threads = state.range(1); + // Number of adds done by each closure. const int num_add = num_iterations / concurrent_functor; grpc_core::ThreadPool pool(num_threads); while (state.KeepRunningBatch(num_iterations)) { @@ -111,7 +111,8 @@ void ThreadPoolAddAnotherHelper(benchmark::State& state, static void BM_ThreadPool1AddAnother(benchmark::State& state) { ThreadPoolAddAnotherHelper(state, 1); } -// first pair is range for batch_size, second pair is range for thread pool size +// First pair is range for number of iterations (num_iterations). +// Second pair is range for thread pool size (num_threads). BENCHMARK(BM_ThreadPool1AddAnother)->RangePair(524288, 524288, 1, 1024); static void BM_ThreadPool4AddAnother(benchmark::State& state) { @@ -177,12 +178,12 @@ class SuicideFunctorForAdd : public grpc_experimental_completion_queue_functor { // Performs the scenario of external thread(s) adding closures into pool. static void BM_ThreadPoolExternalAdd(benchmark::State& state) { static grpc_core::ThreadPool* external_add_pool = nullptr; - // Setup for each run of test + // Setup for each run of test. if (state.thread_index == 0) { const int num_threads = state.range(1); - external_add_pool = new grpc_core::ThreadPool(num_threads); + external_add_pool = grpc_core::New(num_threads); } - const int num_iterations = state.range(0); + const int num_iterations = state.range(0) / state.threads; while (state.KeepRunningBatch(num_iterations)) { BlockingCounter counter(num_iterations); for (int i = 0; i < num_iterations; ++i) { @@ -190,15 +191,17 @@ static void BM_ThreadPoolExternalAdd(benchmark::State& state) { } counter.Wait(); } - state.SetItemsProcessed(num_iterations); - // Teardown at the end of each test run + // Teardown at the end of each test run. if (state.thread_index == 0) { - Delete(external_add_pool); + state.SetItemsProcessed(state.range(0)); + grpc_core::Delete(external_add_pool); } } BENCHMARK(BM_ThreadPoolExternalAdd) - ->RangePair(524288, 524288, 1, 1024) // ThreadPool size + // First pair is range for number of iterations (num_iterations). + // Second pair is range for thread pool size (num_threads). + ->RangePair(524288, 524288, 1, 1024) ->ThreadRange(1, 256); // Concurrent external thread(s) up to 256 // Functor (closure) that adds itself into pool repeatedly. By adding self, the @@ -222,7 +225,7 @@ class AddSelfFunctor : public grpc_experimental_completion_queue_functor { callback->pool_->Add(cb); } else { callback->counter_->DecrementCount(); - // Suicide + // Suicides. delete callback; } } @@ -234,12 +237,12 @@ class AddSelfFunctor : public grpc_experimental_completion_queue_functor { }; static void BM_ThreadPoolAddSelf(benchmark::State& state) { - const int num_threads = state.range(0); - const int kNumIteration = 524288; + const int num_iterations = state.range(0); + const int num_threads = state.range(1); int concurrent_functor = num_threads; - int num_add = kNumIteration / concurrent_functor; + int num_add = num_iterations / concurrent_functor; grpc_core::ThreadPool pool(num_threads); - while (state.KeepRunningBatch(kNumIteration)) { + while (state.KeepRunningBatch(num_iterations)) { BlockingCounter counter(concurrent_functor); for (int i = 0; i < concurrent_functor; ++i) { pool.Add(new AddSelfFunctor(&pool, &counter, num_add)); @@ -248,25 +251,26 @@ static void BM_ThreadPoolAddSelf(benchmark::State& state) { } state.SetItemsProcessed(state.iterations()); } - -BENCHMARK(BM_ThreadPoolAddSelf)->Range(1, 1024); +// First pair is range for number of iterations (num_iterations). +// Second pair is range for thread pool size (num_threads). +BENCHMARK(BM_ThreadPoolAddSelf)->RangePair(524288, 524288, 1, 1024); #if defined(__GNUC__) && !defined(SWIG) #if defined(__i386__) || defined(__x86_64__) -#define ABSL_CACHELINE_SIZE 64 +#define CACHELINE_SIZE 64 #elif defined(__powerpc64__) -#define ABSL_CACHELINE_SIZE 128 +#define CACHELINE_SIZE 128 #elif defined(__aarch64__) -#define ABSL_CACHELINE_SIZE 64 +#define CACHELINE_SIZE 64 #elif defined(__arm__) #if defined(__ARM_ARCH_5T__) -#define ABSL_CACHELINE_SIZE 32 +#define CACHELINE_SIZE 32 #elif defined(__ARM_ARCH_7A__) -#define ABSL_CACHELINE_SIZE 64 +#define CACHELINE_SIZE 64 #endif #endif -#ifndef ABSL_CACHELINE_SIZE -#define ABSL_CACHELINE_SIZE 64 +#ifndef CACHELINE_SIZE +#define CACHELINE_SIZE 64 #endif #endif @@ -286,6 +290,7 @@ class ShortWorkFunctorForAdd ~ShortWorkFunctorForAdd() {} static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { auto* callback = static_cast(cb); + // Uses pad to avoid compiler complaining unused variable error. callback->pad[0] = 0; for (int i = 0; i < 1000; ++i) { callback->val_++; @@ -294,7 +299,7 @@ class ShortWorkFunctorForAdd } private: - char pad[ABSL_CACHELINE_SIZE]; + char pad[CACHELINE_SIZE]; volatile int val_; }; From 64ead823c31d5cad60a1a9612e93c858235cc846 Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Mon, 22 Jul 2019 18:05:16 -0700 Subject: [PATCH 0955/1555] Respond to reviewer comments --- .../filters/client_channel/client_channel.cc | 3 ++- src/core/lib/channel/channelz.cc | 17 +++++++++++++++ src/core/lib/channel/channelz.h | 21 ++++--------------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 6c273180da9..9aeb4be76d8 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -733,7 +733,8 @@ class ChannelData::ConnectivityStateAndPickerSetter { chand->channelz_node_->AddTraceEvent( channelz::ChannelTrace::Severity::Info, grpc_slice_from_static_string( - channelz::GetChannelConnectivityStateChangeString(state))); + channelz::ChannelNode::GetChannelConnectivityStateChangeString( + state))); } // Bounce into the data plane combiner to reset the picker. GRPC_CHANNEL_STACK_REF(chand->owning_stack_, diff --git a/src/core/lib/channel/channelz.cc b/src/core/lib/channel/channelz.cc index b9f65870cfe..ab1e93a1bc7 100644 --- a/src/core/lib/channel/channelz.cc +++ b/src/core/lib/channel/channelz.cc @@ -192,6 +192,23 @@ ChannelNode::ChannelNode(UniquePtr target, trace_(channel_tracer_max_nodes), parent_uuid_(parent_uuid) {} +const char* ChannelNode::GetChannelConnectivityStateChangeString( + grpc_connectivity_state state) { + switch (state) { + case GRPC_CHANNEL_IDLE: + return "Channel state change to IDLE"; + case GRPC_CHANNEL_CONNECTING: + return "Channel state change to CONNECTING"; + case GRPC_CHANNEL_READY: + return "Channel state change to READY"; + case GRPC_CHANNEL_TRANSIENT_FAILURE: + return "Channel state change to TRANSIENT_FAILURE"; + case GRPC_CHANNEL_SHUTDOWN: + return "Channel state change to SHUTDOWN"; + } + GPR_UNREACHABLE_CODE(return "UNKNOWN"); +} + grpc_json* ChannelNode::RenderJson() { // We need to track these three json objects to build our object grpc_json* top_level_json = grpc_json_create(GRPC_JSON_OBJECT); diff --git a/src/core/lib/channel/channelz.h b/src/core/lib/channel/channelz.h index 554e9ae4ad7..1dc1f0a3cbb 100644 --- a/src/core/lib/channel/channelz.h +++ b/src/core/lib/channel/channelz.h @@ -70,23 +70,6 @@ class CallCountingHelperPeer; class ChannelNodePeer; } // namespace testing -inline static const char* GetChannelConnectivityStateChangeString( - grpc_connectivity_state state) { - switch (state) { - case GRPC_CHANNEL_IDLE: - return "Channel state change to IDLE"; - case GRPC_CHANNEL_CONNECTING: - return "Channel state change to CONNECTING"; - case GRPC_CHANNEL_READY: - return "Channel state change to READY"; - case GRPC_CHANNEL_TRANSIENT_FAILURE: - return "Channel state change to TRANSIENT_FAILURE"; - case GRPC_CHANNEL_SHUTDOWN: - return "Channel state change to SHUTDOWN"; - } - GPR_UNREACHABLE_CODE(return "UNKNOWN"); -} - // base class for all channelz entities class BaseNode : public RefCounted { public: @@ -170,6 +153,10 @@ class ChannelNode : public BaseNode { ChannelNode(UniquePtr target, size_t channel_tracer_max_nodes, intptr_t parent_uuid); + // Returns the string description of the given connectivity state. + static const char* GetChannelConnectivityStateChangeString( + grpc_connectivity_state state); + intptr_t parent_uuid() const { return parent_uuid_; } grpc_json* RenderJson() override; From b82d5ecc5ad524335f3eb47f231bb0277d0e9a37 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Mon, 22 Jul 2019 17:52:12 -0700 Subject: [PATCH 0956/1555] Removed space from dir name to fix clang_format_code --- gRPC-Core.podspec | 2 +- src/core/lib/gpr/env_linux.cc | 31 ++++++------------- src/core/lib/gpr/env_posix.cc | 5 --- src/core/lib/iomgr/combiner.cc | 8 ++--- src/core/lib/surface/completion_queue.cc | 24 +++++++++----- src/core/lib/surface/server.cc | 2 ++ .../Circular.imageset/Contents.json | 0 .../Contents.json | 0 .../Extra Large.imageset/Contents.json | 0 .../Graphic Bezel.imageset/Contents.json | 0 .../Graphic Circular.imageset/Contents.json | 0 .../Graphic Corner.imageset/Contents.json | 0 .../Contents.json | 0 .../Modular.imageset/Contents.json | 0 .../Utilitarian.imageset/Contents.json | 0 .../Assets.xcassets/Contents.json | 0 .../ExtensionDelegate.h | 0 .../ExtensionDelegate.m | 0 .../Info.plist | 0 .../InterfaceController.h | 0 .../InterfaceController.m | 0 .../watchOS-sample.xcodeproj/project.pbxproj | 10 +++--- templates/gRPC-Core.podspec.template | 2 +- templates/gRPC-ProtoRPC.podspec.template | 1 + ...!ProtoCompiler-gRPCPlugin.podspec.template | 1 + .../BoringSSL-GRPC.podspec.template | 1 + 26 files changed, 43 insertions(+), 44 deletions(-) rename src/objective-c/examples/watchOS-sample/{watchOS-sample WatchKit Extension => watchOS-sample-WatchKit-Extension}/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample WatchKit Extension => watchOS-sample-WatchKit-Extension}/Assets.xcassets/Complication.complicationset/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample WatchKit Extension => watchOS-sample-WatchKit-Extension}/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample WatchKit Extension => watchOS-sample-WatchKit-Extension}/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample WatchKit Extension => watchOS-sample-WatchKit-Extension}/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample WatchKit Extension => watchOS-sample-WatchKit-Extension}/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample WatchKit Extension => watchOS-sample-WatchKit-Extension}/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample WatchKit Extension => watchOS-sample-WatchKit-Extension}/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample WatchKit Extension => watchOS-sample-WatchKit-Extension}/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample WatchKit Extension => watchOS-sample-WatchKit-Extension}/Assets.xcassets/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample WatchKit Extension => watchOS-sample-WatchKit-Extension}/ExtensionDelegate.h (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample WatchKit Extension => watchOS-sample-WatchKit-Extension}/ExtensionDelegate.m (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample WatchKit Extension => watchOS-sample-WatchKit-Extension}/Info.plist (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample WatchKit Extension => watchOS-sample-WatchKit-Extension}/InterfaceController.h (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample WatchKit Extension => watchOS-sample-WatchKit-Extension}/InterfaceController.m (100%) diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 0d4f8e4f0d3..9583f7f0740 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.9' s.tvos.deployment_target = '10.0' s.watchos.deployment_target = '4.0' - + s.requires_arc = false name = 'grpc' diff --git a/src/core/lib/gpr/env_linux.cc b/src/core/lib/gpr/env_linux.cc index 3a3aa541672..6a78dc14155 100644 --- a/src/core/lib/gpr/env_linux.cc +++ b/src/core/lib/gpr/env_linux.cc @@ -38,19 +38,20 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" -static const char* gpr_getenv_silent(const char* name, char** dst) { - const char* insecure_func_used = nullptr; +char* gpr_getenv(const char* name) { char* result = nullptr; #if defined(GPR_BACKWARDS_COMPATIBILITY_MODE) typedef char* (*getenv_type)(const char*); - static getenv_type getenv_func = NULL; + static getenv_type getenv_func = nullptr; /* Check to see which getenv variant is supported (go from most * to least secure) */ - const char* names[] = {"secure_getenv", "__secure_getenv", "getenv"}; - for (size_t i = 0; getenv_func == NULL && i < GPR_ARRAY_SIZE(names); i++) { - getenv_func = (getenv_type)dlsym(RTLD_DEFAULT, names[i]); - if (getenv_func != NULL && strstr(names[i], "secure") == NULL) { - insecure_func_used = names[i]; + if (getenv_func == nullptr) { + const char* names[] = {"secure_getenv", "__secure_getenv", "getenv"}; + for (size_t i = 0; i < GPR_ARRAY_SIZE(names); i++) { + getenv_func = (getenv_type)dlsym(RTLD_DEFAULT, names[i]); + if (getenv_func != nullptr) { + break; + } } } result = getenv_func(name); @@ -58,20 +59,8 @@ static const char* gpr_getenv_silent(const char* name, char** dst) { result = secure_getenv(name); #else result = getenv(name); - insecure_func_used = "getenv"; #endif - *dst = result == nullptr ? result : gpr_strdup(result); - return insecure_func_used; -} - -char* gpr_getenv(const char* name) { - char* result = nullptr; - const char* insecure_func_used = gpr_getenv_silent(name, &result); - if (insecure_func_used != nullptr) { - gpr_log(GPR_DEBUG, "Warning: insecure environment read function '%s' used", - insecure_func_used); - } - return result; + return result == nullptr ? result : gpr_strdup(result); } void gpr_setenv(const char* name, const char* value) { diff --git a/src/core/lib/gpr/env_posix.cc b/src/core/lib/gpr/env_posix.cc index 30ddc50f682..232095b4e22 100644 --- a/src/core/lib/gpr/env_posix.cc +++ b/src/core/lib/gpr/env_posix.cc @@ -29,11 +29,6 @@ #include #include "src/core/lib/gpr/string.h" -const char* gpr_getenv_silent(const char* name, char** dst) { - *dst = gpr_getenv(name); - return nullptr; -} - char* gpr_getenv(const char* name) { char* result = getenv(name); return result == nullptr ? result : gpr_strdup(result); diff --git a/src/core/lib/iomgr/combiner.cc b/src/core/lib/iomgr/combiner.cc index 4fc4a9dccf4..9a6290f29a8 100644 --- a/src/core/lib/iomgr/combiner.cc +++ b/src/core/lib/iomgr/combiner.cc @@ -233,11 +233,11 @@ bool grpc_combiner_continue_exec_ctx() { // offload only if all the following conditions are true: // 1. the combiner is contended and has more than one closure to execute // 2. the current execution context needs to finish as soon as possible - // 3. the DEFAULT executor is threaded - // 4. the current thread is not a worker for any background poller + // 3. the current thread is not a worker for any background poller + // 4. the DEFAULT executor is threaded if (contended && grpc_core::ExecCtx::Get()->IsReadyToFinish() && - grpc_core::Executor::IsThreadedDefault() && - !grpc_iomgr_is_any_background_poller_thread()) { + !grpc_iomgr_is_any_background_poller_thread() && + grpc_core::Executor::IsThreadedDefault()) { GPR_TIMER_MARK("offload_from_finished_exec_ctx", 0); // this execution context wants to move on: schedule remaining work to be // picked up on the executor diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index 60a7d78b525..82f87e769bf 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -857,17 +857,20 @@ static void cq_end_op_for_callback( } auto* functor = static_cast(tag); - if (internal) { + if (internal || grpc_iomgr_is_any_background_poller_thread()) { grpc_core::ApplicationCallbackExecCtx::Enqueue(functor, (error == GRPC_ERROR_NONE)); GRPC_ERROR_UNREF(error); - } else { - GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_CREATE( - functor_callback, functor, - grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), - error); + return; } + + // Schedule the callback on a closure if not internal or triggered + // from a background poller thread. + GRPC_CLOSURE_SCHED( + GRPC_CLOSURE_CREATE( + functor_callback, functor, + grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), + error); } void grpc_cq_end_op(grpc_completion_queue* cq, void* tag, grpc_error* error, @@ -1352,6 +1355,13 @@ static void cq_finish_shutdown_callback(grpc_completion_queue* cq) { GPR_ASSERT(cqd->shutdown_called); cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done); + if (grpc_iomgr_is_any_background_poller_thread()) { + grpc_core::ApplicationCallbackExecCtx::Enqueue(callback, true); + return; + } + + // Schedule the callback on a closure if not internal or triggered + // from a background poller thread. GRPC_CLOSURE_SCHED( GRPC_CLOSURE_CREATE( functor_callback, callback, diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index a1c7d132ade..7fe05c10a54 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -711,8 +711,10 @@ static void maybe_finish_shutdown(grpc_server* server) { return; } + gpr_mu_lock(&server->mu_call); kill_pending_work_locked( server, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown")); + gpr_mu_unlock(&server->mu_call); if (server->root_channel_data.next != &server->root_channel_data || server->listeners_destroyed < num_listeners(server)) { diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json rename to src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Contents.json rename to src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json rename to src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json rename to src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json rename to src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json rename to src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json rename to src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json rename to src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json rename to src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Assets.xcassets/Contents.json rename to src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.h b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.h similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.h rename to src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.h diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.m b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.m similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/ExtensionDelegate.m rename to src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.m diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Info.plist b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Info.plist similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/Info.plist rename to src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Info.plist diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.h b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.h similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.h rename to src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.h diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.m b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.m similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit Extension/InterfaceController.m rename to src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.m diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj index 12e7f29b7a0..191bde5d9e0 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj @@ -148,7 +148,7 @@ children = ( ABB17D5622D93BAB00C26D6E /* watchOS-sample */, ABB17D6E22D93BAC00C26D6E /* watchOS-sample WatchKit App */, - ABB17D7D22D93BAC00C26D6E /* watchOS-sample WatchKit Extension */, + ABB17D7D22D93BAC00C26D6E /* watchOS-sample-WatchKit-Extension */, ABB17D5522D93BAB00C26D6E /* Products */, 2C4A0708747AAA7298F757DA /* Pods */, 589283F4A582EEF2434E0220 /* Frameworks */, @@ -191,7 +191,7 @@ path = "watchOS-sample WatchKit App"; sourceTree = ""; }; - ABB17D7D22D93BAC00C26D6E /* watchOS-sample WatchKit Extension */ = { + ABB17D7D22D93BAC00C26D6E /* watchOS-sample-WatchKit-Extension */ = { isa = PBXGroup; children = ( ABB17D7E22D93BAC00C26D6E /* InterfaceController.h */, @@ -201,7 +201,7 @@ ABB17D8422D93BAD00C26D6E /* Assets.xcassets */, ABB17D8622D93BAD00C26D6E /* Info.plist */, ); - path = "watchOS-sample WatchKit Extension"; + path = "watchOS-sample-WatchKit-Extension"; sourceTree = ""; }; /* End PBXGroup section */ @@ -598,7 +598,7 @@ ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6T98ZJNPG5; - INFOPLIST_FILE = "watchOS-sample WatchKit Extension/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/watchOS-sample-WatchKit-Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -620,7 +620,7 @@ ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6T98ZJNPG5; - INFOPLIST_FILE = "watchOS-sample WatchKit Extension/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/watchOS-sample-WatchKit-Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template index 43645edf2e4..b838e86413a 100644 --- a/templates/gRPC-Core.podspec.template +++ b/templates/gRPC-Core.podspec.template @@ -94,7 +94,7 @@ s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' s.tvos.deployment_target = '10.0' - s.watchos.deployment_target = '4.0' + s.watchos.deployment_target = '4.0' s.requires_arc = false diff --git a/templates/gRPC-ProtoRPC.podspec.template b/templates/gRPC-ProtoRPC.podspec.template index e4d5f3ffd3d..457d2988036 100644 --- a/templates/gRPC-ProtoRPC.podspec.template +++ b/templates/gRPC-ProtoRPC.podspec.template @@ -38,6 +38,7 @@ s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '4.0' name = 'ProtoRPC' s.module_name = name diff --git a/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template b/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template index b2335ac8a9e..f612bd56cff 100644 --- a/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template +++ b/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template @@ -108,6 +108,7 @@ s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '4.0' # Restrict the gRPC runtime version to the one supported by this plugin. s.dependency 'gRPC-ProtoRPC', v diff --git a/templates/src/objective-c/BoringSSL-GRPC.podspec.template b/templates/src/objective-c/BoringSSL-GRPC.podspec.template index 408970e25e3..3d2736e3307 100644 --- a/templates/src/objective-c/BoringSSL-GRPC.podspec.template +++ b/templates/src/objective-c/BoringSSL-GRPC.podspec.template @@ -87,6 +87,7 @@ s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.7' s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '4.0' name = 'openssl_grpc' From 609107586a572c1ad3db50fd490f0b95de61a977 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Mon, 22 Jul 2019 19:26:03 -0700 Subject: [PATCH 0957/1555] Add a way for tests with LeakDetector to free the control plane creds map --- src/core/lib/security/credentials/credentials.cc | 12 ++++++++++++ src/core/lib/security/credentials/credentials.h | 13 +++++++++++++ test/core/end2end/fuzzers/client_fuzzer.cc | 3 +++ test/core/end2end/fuzzers/server_fuzzer.cc | 3 +++ test/core/security/alts_credentials_fuzzer.cc | 3 +++ test/core/slice/percent_decode_fuzzer.cc | 3 +++ test/core/slice/percent_encode_fuzzer.cc | 3 +++ 7 files changed, 40 insertions(+) diff --git a/src/core/lib/security/credentials/credentials.cc b/src/core/lib/security/credentials/credentials.cc index 2a1a5546bcf..f2ec9b7f2f2 100644 --- a/src/core/lib/security/credentials/credentials.cc +++ b/src/core/lib/security/credentials/credentials.cc @@ -64,6 +64,18 @@ void grpc_control_plane_credentials_init() { gpr_once_init(&once_init_control_plane_creds, do_control_plane_creds_init); } +void grpc_test_only_control_plane_credentials_destroy() { + grpc_core::Delete(g_grpc_control_plane_creds); + g_grpc_control_plane_creds = nullptr; + gpr_mu_destroy(&g_control_plane_creds_mu); +} + +void grpc_test_only_control_plane_credentials_force_init() { + if (g_grpc_control_plane_creds == nullptr) { + do_control_plane_creds_init(); + } +} + bool grpc_channel_credentials_attach_credentials( grpc_channel_credentials* credentials, const char* authority, grpc_channel_credentials* control_plane_creds) { diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h index 0d95f8f4caa..f3fbe881598 100644 --- a/src/core/lib/security/credentials/credentials.h +++ b/src/core/lib/security/credentials/credentials.h @@ -193,6 +193,19 @@ bool grpc_control_plane_credentials_register( /* Initializes global control plane credentials data. */ void grpc_control_plane_credentials_init(); +/* Test only: destroy global control plane credentials data. + * This API is meant for use by a few tests that need to + * satisdy grpc_core::LeakDetector. */ +void grpc_test_only_control_plane_credentials_destroy(); + +/* Test only: force re-initialization of global control + * plane credentials data if it was previously destroyed. + * This API is meant to be used in + * tandem with the + * grpc_test_only_control_plane_credentials_destroy, for + * the few tests that need it. */ +void grpc_test_only_control_plane_credentials_force_init(); + /* --- grpc_credentials_mdelem_array. --- */ typedef struct { diff --git a/test/core/end2end/fuzzers/client_fuzzer.cc b/test/core/end2end/fuzzers/client_fuzzer.cc index 55e6ce695ad..8ff8c1a5474 100644 --- a/test/core/end2end/fuzzers/client_fuzzer.cc +++ b/test/core/end2end/fuzzers/client_fuzzer.cc @@ -24,6 +24,7 @@ #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/iomgr/executor.h" +#include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/channel.h" #include "test/core/util/memory_counters.h" @@ -43,6 +44,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { if (squelch) gpr_set_log_function(dont_log); grpc_core::testing::LeakDetector leak_detector(leak_check); grpc_init(); + grpc_test_only_control_plane_credentials_force_init(); { grpc_core::ExecCtx exec_ctx; grpc_core::Executor::SetThreadingAll(false); @@ -158,6 +160,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_byte_buffer_destroy(response_payload_recv); } } + grpc_test_only_control_plane_credentials_destroy(); grpc_shutdown_blocking(); return 0; } diff --git a/test/core/end2end/fuzzers/server_fuzzer.cc b/test/core/end2end/fuzzers/server_fuzzer.cc index f010066ea27..130b58f6292 100644 --- a/test/core/end2end/fuzzers/server_fuzzer.cc +++ b/test/core/end2end/fuzzers/server_fuzzer.cc @@ -20,6 +20,7 @@ #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/iomgr/executor.h" +#include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/server.h" #include "test/core/util/memory_counters.h" @@ -40,6 +41,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { if (squelch) gpr_set_log_function(dont_log); grpc_core::testing::LeakDetector leak_detector(leak_check); grpc_init(); + grpc_test_only_control_plane_credentials_force_init(); { grpc_core::ExecCtx exec_ctx; grpc_core::Executor::SetThreadingAll(false); @@ -134,6 +136,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_server_destroy(server); grpc_completion_queue_destroy(cq); } + grpc_test_only_control_plane_credentials_destroy(); grpc_shutdown(); return 0; } diff --git a/test/core/security/alts_credentials_fuzzer.cc b/test/core/security/alts_credentials_fuzzer.cc index abe50031687..3dc0146f000 100644 --- a/test/core/security/alts_credentials_fuzzer.cc +++ b/test/core/security/alts_credentials_fuzzer.cc @@ -30,6 +30,7 @@ #include "src/core/lib/security/credentials/alts/alts_credentials.h" #include "src/core/lib/security/credentials/alts/check_gcp_environment.h" #include "src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h" +#include "src/core/lib/security/credentials/credentials.h" using grpc_core::testing::grpc_fuzzer_get_next_byte; using grpc_core::testing::grpc_fuzzer_get_next_string; @@ -69,6 +70,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_core::testing::LeakDetector leak_detector(leak_check); input_stream inp = {data, data + size}; grpc_init(); + grpc_test_only_control_plane_credentials_force_init(); bool is_on_gcp = grpc_alts_is_running_on_gcp(); while (inp.cur != inp.end) { bool enable_untrusted_alts = grpc_fuzzer_get_next_byte(&inp) & 0x01; @@ -107,6 +109,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { } gpr_free(handshaker_service_url); } + grpc_test_only_control_plane_credentials_destroy(); grpc_shutdown(); return 0; } diff --git a/test/core/slice/percent_decode_fuzzer.cc b/test/core/slice/percent_decode_fuzzer.cc index da8e03a4662..bf4ae00be77 100644 --- a/test/core/slice/percent_decode_fuzzer.cc +++ b/test/core/slice/percent_decode_fuzzer.cc @@ -24,6 +24,7 @@ #include #include +#include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/slice/percent_encoding.h" #include "test/core/util/memory_counters.h" @@ -33,6 +34,7 @@ bool leak_check = true; extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_core::testing::LeakDetector leak_detector(true); grpc_init(); + grpc_test_only_control_plane_credentials_force_init(); grpc_slice input = grpc_slice_from_copied_buffer((const char*)data, size); grpc_slice output; if (grpc_strict_percent_decode_slice( @@ -45,6 +47,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { } grpc_slice_unref(grpc_permissive_percent_decode_slice(input)); grpc_slice_unref(input); + grpc_test_only_control_plane_credentials_destroy(); grpc_shutdown_blocking(); return 0; } diff --git a/test/core/slice/percent_encode_fuzzer.cc b/test/core/slice/percent_encode_fuzzer.cc index 4efa7a8d8e7..0fed4b7cce5 100644 --- a/test/core/slice/percent_encode_fuzzer.cc +++ b/test/core/slice/percent_encode_fuzzer.cc @@ -24,6 +24,7 @@ #include #include +#include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/slice/percent_encoding.h" #include "test/core/util/memory_counters.h" @@ -33,6 +34,7 @@ bool leak_check = true; static void test(const uint8_t* data, size_t size, const uint8_t* dict) { grpc_core::testing::LeakDetector leak_detector(true); grpc_init(); + grpc_test_only_control_plane_credentials_force_init(); grpc_slice input = grpc_slice_from_copied_buffer(reinterpret_cast(data), size); grpc_slice output = grpc_percent_encode_slice(input, dict); @@ -48,6 +50,7 @@ static void test(const uint8_t* data, size_t size, const uint8_t* dict) { grpc_slice_unref(output); grpc_slice_unref(decoded_output); grpc_slice_unref(permissive_decoded_output); + grpc_test_only_control_plane_credentials_destroy(); grpc_shutdown_blocking(); } From 46f706c99b63937ab2b8f0fa828ed6a54e7be13e Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 23 Jul 2019 07:50:27 -0700 Subject: [PATCH 0958/1555] Revert "Merge pull request #19686 from gnossen/revert_breakage" This reverts commit 1f2398b0d5cd504702b582e5594fad559a061625, reversing changes made to 99169d811c81e80572574901b13eb289df6f770f. --- src/core/lib/surface/channel.cc | 19 +++++++++++++++++++ test/cpp/microbenchmarks/bm_call_create.cc | 6 ++++++ 2 files changed, 25 insertions(+) diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index e61550743b7..db7272dba6d 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -235,6 +235,23 @@ grpc_channel* grpc_channel_create(const char* target, grpc_channel_stack_type channel_stack_type, grpc_transport* optional_transport, grpc_resource_user* resource_user) { + // We need to make sure that grpc_shutdown() does not shut things down + // until after the channel is destroyed. However, the channel may not + // actually be destroyed by the time grpc_channel_destroy() returns, + // since there may be other existing refs to the channel. If those + // refs are held by things that are visible to the wrapped language + // (such as outstanding calls on the channel), then the wrapped + // language can be responsible for making sure that grpc_shutdown() + // does not run until after those refs are released. However, the + // channel may also have refs to itself held internally for various + // things that need to be cleaned up at channel destruction (e.g., + // LB policies, subchannels, etc), and because these refs are not + // visible to the wrapped language, it cannot be responsible for + // deferring grpc_shutdown() until after they are released. To + // accommodate that, we call grpc_init() here and then call + // grpc_shutdown() when the channel is actually destroyed, thus + // ensuring that shutdown is deferred until that point. + grpc_init(); grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create(); const grpc_core::UniquePtr default_authority = get_default_authority(input_args); @@ -468,6 +485,8 @@ static void destroy_channel(void* arg, grpc_error* error) { gpr_mu_destroy(&channel->registered_call_mu); gpr_free(channel->target); gpr_free(channel); + // See comment in grpc_channel_create() for why we do this. + grpc_shutdown(); } void grpc_channel_destroy(grpc_channel* channel) { diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 3bd1464b2aa..aad94afca5b 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -686,6 +686,12 @@ static const grpc_channel_filter isolated_call_filter = { class IsolatedCallFixture : public TrackCounters { public: IsolatedCallFixture() { + // We are calling grpc_channel_stack_builder_create() instead of + // grpc_channel_create() here, which means we're not getting the + // grpc_init() called by grpc_channel_create(), but we are getting + // the grpc_shutdown() run by grpc_channel_destroy(). So we need to + // call grpc_init() manually here to balance things out. + grpc_init(); grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create(); grpc_channel_stack_builder_set_name(builder, "dummy"); grpc_channel_stack_builder_set_target(builder, "dummy_target"); From c5c36a07d844d0e93e952d9f80a77fc6f855f918 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 23 Jul 2019 07:54:54 -0700 Subject: [PATCH 0959/1555] Call grpc_shutdown() if grpc_channel_create() fails. --- src/core/lib/surface/channel.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index db7272dba6d..aadb3f5fae3 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -267,6 +267,7 @@ grpc_channel* grpc_channel_create(const char* target, if (resource_user != nullptr) { grpc_resource_user_free(resource_user, GRPC_RESOURCE_QUOTA_CHANNEL_SIZE); } + grpc_shutdown(); // Since we won't call destroy_channel(). return nullptr; } // We only need to do this for clients here. For servers, this will be @@ -274,7 +275,12 @@ grpc_channel* grpc_channel_create(const char* target, if (grpc_channel_stack_type_is_client(channel_stack_type)) { CreateChannelzNode(builder); } - return grpc_channel_create_with_builder(builder, channel_stack_type); + grpc_channel* channel = + grpc_channel_create_with_builder(builder, channel_stack_type); + if (channel == nullptr) { + grpc_shutdown(); // Since we won't call destroy_channel(). + } + return channel; } size_t grpc_channel_get_call_size_estimate(grpc_channel* channel) { From 9d974ae531f7fabc2bbc9d5da2f76ef4463e280d Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 23 Jul 2019 11:00:18 -0400 Subject: [PATCH 0960/1555] add fake unary call native method for benchmarking --- src/csharp/ext/grpc_csharp_ext.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 51e498bcfb8..02e219ead87 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -632,6 +632,26 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_unary( ctx, NULL); } +/* Only for testing. Shortcircuits the unary call logic and only echoes the + message as if it was received from the server */ +GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_test_call_start_unary_echo( + grpc_call* call, grpcsharp_batch_context* ctx, const char* send_buffer, + size_t send_buffer_len, uint32_t write_flags, + grpc_metadata_array* initial_metadata, uint32_t initial_metadata_flags) { + // prepare as if we were performing a normal RPC. + grpc_byte_buffer* send_message = + string_to_byte_buffer(send_buffer, send_buffer_len); + + ctx->recv_message = send_message; // echo message sent by the client as if + // received from server. + ctx->recv_status_on_client.status = GRPC_STATUS_OK; + ctx->recv_status_on_client.status_details = grpc_empty_slice(); + // echo initial metadata as if received from server (as trailing metadata) + grpcsharp_metadata_array_move(&(ctx->recv_status_on_client.trailing_metadata), + initial_metadata); + return GRPC_CALL_OK; +} + GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_client_streaming( grpc_call* call, grpcsharp_batch_context* ctx, grpc_metadata_array* initial_metadata, uint32_t initial_metadata_flags) { From 1650d6ab4001ec3068c7d4e101c8a0c5a234db5a Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 23 Jul 2019 11:08:28 -0400 Subject: [PATCH 0961/1555] add grpcsharp_test_call_start_unary_echo stub --- .../Grpc.Core/Internal/NativeMethods.Generated.cs | 11 +++++++++++ .../Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c | 4 ++++ .../csharp/Grpc.Core/Internal/native_methods.include | 1 + 3 files changed, 16 insertions(+) diff --git a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs index 170fc5c5657..ca3dfe97ce1 100644 --- a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs +++ b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs @@ -130,6 +130,7 @@ namespace Grpc.Core.Internal public readonly Delegates.grpcsharp_test_callback_delegate grpcsharp_test_callback; public readonly Delegates.grpcsharp_test_nop_delegate grpcsharp_test_nop; public readonly Delegates.grpcsharp_test_override_method_delegate grpcsharp_test_override_method; + public readonly Delegates.grpcsharp_test_call_start_unary_echo_delegate grpcsharp_test_call_start_unary_echo; #endregion @@ -231,6 +232,7 @@ namespace Grpc.Core.Internal this.grpcsharp_test_callback = GetMethodDelegate(library); this.grpcsharp_test_nop = GetMethodDelegate(library); this.grpcsharp_test_override_method = GetMethodDelegate(library); + this.grpcsharp_test_call_start_unary_echo = GetMethodDelegate(library); } public NativeMethods(DllImportsFromStaticLib unusedInstance) @@ -331,6 +333,7 @@ namespace Grpc.Core.Internal this.grpcsharp_test_callback = DllImportsFromStaticLib.grpcsharp_test_callback; this.grpcsharp_test_nop = DllImportsFromStaticLib.grpcsharp_test_nop; this.grpcsharp_test_override_method = DllImportsFromStaticLib.grpcsharp_test_override_method; + this.grpcsharp_test_call_start_unary_echo = DllImportsFromStaticLib.grpcsharp_test_call_start_unary_echo; } public NativeMethods(DllImportsFromSharedLib unusedInstance) @@ -431,6 +434,7 @@ namespace Grpc.Core.Internal this.grpcsharp_test_callback = DllImportsFromSharedLib.grpcsharp_test_callback; this.grpcsharp_test_nop = DllImportsFromSharedLib.grpcsharp_test_nop; this.grpcsharp_test_override_method = DllImportsFromSharedLib.grpcsharp_test_override_method; + this.grpcsharp_test_call_start_unary_echo = DllImportsFromSharedLib.grpcsharp_test_call_start_unary_echo; } /// @@ -534,6 +538,7 @@ namespace Grpc.Core.Internal public delegate CallError grpcsharp_test_callback_delegate([MarshalAs(UnmanagedType.FunctionPtr)] NativeCallbackTestDelegate callback); public delegate IntPtr grpcsharp_test_nop_delegate(IntPtr ptr); public delegate void grpcsharp_test_override_method_delegate(string methodName, string variant); + public delegate CallError grpcsharp_test_call_start_unary_echo_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); } /// @@ -830,6 +835,9 @@ namespace Grpc.Core.Internal [DllImport(ImportName)] public static extern void grpcsharp_test_override_method(string methodName, string variant); + + [DllImport(ImportName)] + public static extern CallError grpcsharp_test_call_start_unary_echo(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); } /// @@ -1126,6 +1134,9 @@ namespace Grpc.Core.Internal [DllImport(ImportName)] public static extern void grpcsharp_test_override_method(string methodName, string variant); + + [DllImport(ImportName)] + public static extern CallError grpcsharp_test_call_start_unary_echo(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); } } } diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c index c2f9d20333d..8ff26e4ca4d 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c @@ -406,3 +406,7 @@ void grpcsharp_test_override_method() { fprintf(stderr, "Should never reach here"); abort(); } +void grpcsharp_test_call_start_unary_echo() { + fprintf(stderr, "Should never reach here"); + abort(); +} diff --git a/templates/src/csharp/Grpc.Core/Internal/native_methods.include b/templates/src/csharp/Grpc.Core/Internal/native_methods.include index ffcaf16bca9..ed7c93a7479 100644 --- a/templates/src/csharp/Grpc.Core/Internal/native_methods.include +++ b/templates/src/csharp/Grpc.Core/Internal/native_methods.include @@ -96,6 +96,7 @@ native_method_signatures = [ 'CallError grpcsharp_test_callback([MarshalAs(UnmanagedType.FunctionPtr)] NativeCallbackTestDelegate callback)', 'IntPtr grpcsharp_test_nop(IntPtr ptr)', 'void grpcsharp_test_override_method(string methodName, string variant)', + 'CallError grpcsharp_test_call_start_unary_echo(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', ] import re From 34dfa06b4b4898799016e12c9c5b77abb800c475 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 23 Jul 2019 11:01:10 -0400 Subject: [PATCH 0962/1555] add unary call overhead benchmark --- .../UnaryCallOverheadBenchmark.cs | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs diff --git a/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs new file mode 100644 index 00000000000..a58a46695be --- /dev/null +++ b/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs @@ -0,0 +1,93 @@ +#region Copyright notice and license + +// Copyright 2019 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System.Threading.Tasks; +using BenchmarkDotNet.Attributes; +using Grpc.Core; +using Grpc.Core.Internal; +using System; + +namespace Grpc.Microbenchmarks +{ + // this test creates a real server and client, measuring the inherent inbuilt + // platform overheads; the marshallers **DO NOT ALLOCATE**, so any allocations + // are from the framework, not the messages themselves + + // important: allocs are not reliable on .NET Core until .NET Core 3, since + // this test involves multiple threads + + [ClrJob, CoreJob] // test .NET Core and .NET Framework + [MemoryDiagnoser] // allocations + public class UnaryCallOverheadBenchmark + { + private static readonly Task CompletedString = Task.FromResult(""); + private static readonly byte[] EmptyBlob = new byte[0]; + private static readonly Marshaller EmptyMarshaller = new Marshaller(_ => EmptyBlob, _ => ""); + private static readonly Method PingMethod = new Method(MethodType.Unary, nameof(PingBenchmark), "Ping", EmptyMarshaller, EmptyMarshaller); + + [Benchmark] + public string Ping() + { + return client.Ping("", new CallOptions()); + } + + Channel channel; + PingClient client; + + [GlobalSetup] + public void Setup() + { + // create client + channel = new Channel("localhost", 10042, ChannelCredentials.Insecure); + client = new PingClient(new DefaultCallInvoker(channel)); + + var native = NativeMethods.Get(); + + // replace the implementation of a native method with a fake + NativeMethods.Delegates.grpcsharp_call_start_unary_delegate fakeCallStartUnary = (CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags) => { + return native.grpcsharp_test_call_start_unary_echo(call, ctx, sendBuffer, sendBufferLen, writeFlags, metadataArray, metadataFlags); + }; + native.GetType().GetField(nameof(native.grpcsharp_call_start_unary)).SetValue(native, fakeCallStartUnary); + + NativeMethods.Delegates.grpcsharp_completion_queue_pluck_delegate fakeCqPluck = (CompletionQueueSafeHandle cq, IntPtr tag) => { + return new CompletionQueueEvent { + type = CompletionQueueEvent.CompletionType.OpComplete, + success = 1, + tag = tag + }; + }; + native.GetType().GetField(nameof(native.grpcsharp_completion_queue_pluck)).SetValue(native, fakeCqPluck); + } + + [GlobalCleanup] + public async Task Cleanup() + { + await channel.ShutdownAsync(); + } + + class PingClient : LiteClientBase + { + public PingClient(CallInvoker callInvoker) : base(callInvoker) { } + + public string Ping(string request, CallOptions options) + { + return CallInvoker.BlockingUnaryCall(PingMethod, null, options, request); + } + } + } +} From 9242fe122d2eaec7c7e4486799c1215a1fe479e2 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Tue, 23 Jul 2019 09:47:26 -0700 Subject: [PATCH 0963/1555] AddSelf more scenarios --- test/cpp/microbenchmarks/bm_threadpool.cc | 53 +++++++++++++++++++++-- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_threadpool.cc b/test/cpp/microbenchmarks/bm_threadpool.cc index 128f3c2d63d..1cd41dafa7f 100644 --- a/test/cpp/microbenchmarks/bm_threadpool.cc +++ b/test/cpp/microbenchmarks/bm_threadpool.cc @@ -236,11 +236,12 @@ class AddSelfFunctor : public grpc_experimental_completion_queue_functor { int num_add_; }; -static void BM_ThreadPoolAddSelf(benchmark::State& state) { +void ThreadPoolAddSelfHelper(benchmark::State& state, + int concurrent_functor) { const int num_iterations = state.range(0); const int num_threads = state.range(1); - int concurrent_functor = num_threads; - int num_add = num_iterations / concurrent_functor; + // Number of adds done by each closure. + const int num_add = num_iterations / concurrent_functor; grpc_core::ThreadPool pool(num_threads); while (state.KeepRunningBatch(num_iterations)) { BlockingCounter counter(concurrent_functor); @@ -251,9 +252,53 @@ static void BM_ThreadPoolAddSelf(benchmark::State& state) { } state.SetItemsProcessed(state.iterations()); } + +static void BM_ThreadPool1AddSelf(benchmark::State& state) { + ThreadPoolAddSelfHelper(state, 1); +} // First pair is range for number of iterations (num_iterations). // Second pair is range for thread pool size (num_threads). -BENCHMARK(BM_ThreadPoolAddSelf)->RangePair(524288, 524288, 1, 1024); +BENCHMARK(BM_ThreadPool1AddSelf)->RangePair(524288, 524288, 1, 1024); + +static void BM_ThreadPool4AddSelf(benchmark::State& state) { + ThreadPoolAddSelfHelper(state, 4); +} +BENCHMARK(BM_ThreadPool4AddSelf)->RangePair(524288, 524288, 1, 1024); + +static void BM_ThreadPool8AddSelf(benchmark::State& state) { + ThreadPoolAddSelfHelper(state, 8); +} +BENCHMARK(BM_ThreadPool8AddSelf)->RangePair(524288, 524288, 1, 1024); + +static void BM_ThreadPool16AddSelf(benchmark::State& state) { + ThreadPoolAddSelfHelper(state, 16); +} +BENCHMARK(BM_ThreadPool16AddSelf)->RangePair(524288, 524288, 1, 1024); + +static void BM_ThreadPool32AddSelf(benchmark::State& state) { + ThreadPoolAddSelfHelper(state, 32); +} +BENCHMARK(BM_ThreadPool32AddSelf)->RangePair(524288, 524288, 1, 1024); + +static void BM_ThreadPool64AddSelf(benchmark::State& state) { + ThreadPoolAddSelfHelper(state, 64); +} +BENCHMARK(BM_ThreadPool64AddSelf)->RangePair(524288, 524288, 1, 1024); + +static void BM_ThreadPool128AddSelf(benchmark::State& state) { + ThreadPoolAddSelfHelper(state, 128); +} +BENCHMARK(BM_ThreadPool128AddSelf)->RangePair(524288, 524288, 1, 1024); + +static void BM_ThreadPool512AddSelf(benchmark::State& state) { + ThreadPoolAddSelfHelper(state, 512); +} +BENCHMARK(BM_ThreadPool512AddSelf)->RangePair(524288, 524288, 1, 1024); + +static void BM_ThreadPool2048AddSelf(benchmark::State& state) { + ThreadPoolAddSelfHelper(state, 2048); +} +BENCHMARK(BM_ThreadPool2048AddSelf)->RangePair(524288, 524288, 1, 1024); #if defined(__GNUC__) && !defined(SWIG) #if defined(__i386__) || defined(__x86_64__) From 1423df37a89951839ad8663c40eac41dbdf4aa7a Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 22 Jul 2019 16:56:02 -0700 Subject: [PATCH 0964/1555] Minor podspec change --- gRPC.podspec | 5 ++--- templates/gRPC.podspec.template | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/gRPC.podspec b/gRPC.podspec index b2d7b910042..e4eb63ff4e7 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -40,7 +40,6 @@ Pod::Spec.new do |s| s.module_name = name s.header_dir = name - s.dependency 'gRPC-RxLibrary', version s.default_subspec = 'Interface', 'GRPCCore' # Certificates, to be able to establish TLS connections: @@ -81,8 +80,7 @@ Pod::Spec.new do |s| s.subspec 'GRPCCore' do |ss| ss.header_mappings_dir = 'src/objective-c/GRPCClient' - ss.public_header_files = 'src/objective-c/GRPCClient/ChannelArg.h', - 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', + ss.public_header_files = 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', 'src/objective-c/GRPCClient/GRPCCall+Tests.h', @@ -107,6 +105,7 @@ Pod::Spec.new do |s| ss.dependency 'gRPC-Core', version ss.dependency "#{s.name}/Interface", version + ss.dependency 'gRPC-RxLibrary', version end s.subspec 'GRPCCoreCronet' do |ss| diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index 2ba7089c717..146da4a323a 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -42,7 +42,6 @@ s.module_name = name s.header_dir = name - s.dependency 'gRPC-RxLibrary', version s.default_subspec = 'Interface', 'GRPCCore' # Certificates, to be able to establish TLS connections: @@ -83,8 +82,7 @@ s.subspec 'GRPCCore' do |ss| ss.header_mappings_dir = 'src/objective-c/GRPCClient' - ss.public_header_files = 'src/objective-c/GRPCClient/ChannelArg.h', - 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', + ss.public_header_files = 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', 'src/objective-c/GRPCClient/GRPCCall+Tests.h', @@ -109,6 +107,7 @@ ss.dependency 'gRPC-Core', version ss.dependency "#{s.name}/Interface", version + ss.dependency 'gRPC-RxLibrary', version end s.subspec 'GRPCCoreCronet' do |ss| From ad51e66324b0885f5ade6ee656e28e8113cd1b3e Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 22 Jul 2019 18:22:41 -0700 Subject: [PATCH 0965/1555] Update proto compiler --- src/compiler/objective_c_generator.cc | 75 ++++++++++++++++----------- src/compiler/objective_c_generator.h | 11 ++-- src/compiler/objective_c_plugin.cc | 28 +++++++--- 3 files changed, 75 insertions(+), 39 deletions(-) diff --git a/src/compiler/objective_c_generator.cc b/src/compiler/objective_c_generator.cc index 24845ecdb06..5b2609f5b03 100644 --- a/src/compiler/objective_c_generator.cc +++ b/src/compiler/objective_c_generator.cc @@ -238,19 +238,21 @@ void PrintV2Implementation(Printer* printer, const MethodDescriptor* method, } void PrintMethodImplementations(Printer* printer, - const MethodDescriptor* method) { + const MethodDescriptor* method, + const Parameters& generator_params) { map< ::grpc::string, ::grpc::string> vars = GetMethodVars(method); PrintProtoRpcDeclarationAsPragma(printer, method, vars); - // TODO(jcanizales): Print documentation from the method. - printer->Print("// Deprecated methods.\n"); - PrintSimpleSignature(printer, method, vars); - PrintSimpleImplementation(printer, method, vars); + if (!generator_params.no_v1_compatibility) { + // TODO(jcanizales): Print documentation from the method. + PrintSimpleSignature(printer, method, vars); + PrintSimpleImplementation(printer, method, vars); - printer->Print("// Returns a not-yet-started RPC object.\n"); - PrintAdvancedSignature(printer, method, vars); - PrintAdvancedImplementation(printer, method, vars); + printer->Print("// Returns a not-yet-started RPC object.\n"); + PrintAdvancedSignature(printer, method, vars); + PrintAdvancedImplementation(printer, method, vars); + } PrintV2Signature(printer, method, vars); PrintV2Implementation(printer, method, vars); @@ -276,9 +278,11 @@ void PrintMethodImplementations(Printer* printer, return output; } -::grpc::string GetProtocol(const ServiceDescriptor* service) { +::grpc::string GetProtocol(const ServiceDescriptor* service, const Parameters& generator_params) { ::grpc::string output; + if (generator_params.no_v1_compatibility) return output; + // Scope the output stream so it closes and finalizes output to the string. grpc::protobuf::io::StringOutputStream output_stream(&output); Printer printer(&output_stream, '$'); @@ -292,7 +296,7 @@ void PrintMethodImplementations(Printer* printer, "that have been deprecated. They do not\n" " * recognize call options provided in the initializer. Using " "the v2 protocol is recommended.\n" - " */\n"); + " */\n\n"); printer.Print(vars, "@protocol $service_class$ \n\n"); for (int i = 0; i < service->method_count(); i++) { PrintMethodDeclarations(&printer, service->method(i)); @@ -321,7 +325,7 @@ void PrintMethodImplementations(Printer* printer, return output; } -::grpc::string GetInterface(const ServiceDescriptor* service) { +::grpc::string GetInterface(const ServiceDescriptor* service, const Parameters& generator_params) { ::grpc::string output; // Scope the output stream so it closes and finalizes output to the string. @@ -338,7 +342,11 @@ void PrintMethodImplementations(Printer* printer, " */\n"); printer.Print(vars, "@interface $service_class$ :" - " GRPCProtoService<$service_class$, $service_class$2>\n"); + " GRPCProtoService<$service_class$2"); + if (!generator_params.no_v1_compatibility) { + printer.Print(vars, ", $service_class$"); + } + printer.Print(">\n"); printer.Print( "- (instancetype)initWithHost:(NSString *)host " "callOptions:(GRPCCallOptions " @@ -347,17 +355,19 @@ void PrintMethodImplementations(Printer* printer, printer.Print( "+ (instancetype)serviceWithHost:(NSString *)host " "callOptions:(GRPCCallOptions *_Nullable)callOptions;\n"); - printer.Print( - "// The following methods belong to a set of old APIs that have been " - "deprecated.\n"); - printer.Print("- (instancetype)initWithHost:(NSString *)host;\n"); - printer.Print("+ (instancetype)serviceWithHost:(NSString *)host;\n"); + if (!generator_params.no_v1_compatibility) { + printer.Print( + "// The following methods belong to a set of old APIs that have been " + "deprecated.\n"); + printer.Print("- (instancetype)initWithHost:(NSString *)host;\n"); + printer.Print("+ (instancetype)serviceWithHost:(NSString *)host;\n"); + } printer.Print("@end\n"); return output; } -::grpc::string GetSource(const ServiceDescriptor* service) { +::grpc::string GetSource(const ServiceDescriptor* service, const Parameters& generator_params) { ::grpc::string output; { // Scope the output stream so it closes and finalizes output to the string. @@ -381,13 +391,16 @@ void PrintMethodImplementations(Printer* printer, " packageName:@\"$package$\"\n" " serviceName:@\"$service_name$\"\n" " callOptions:callOptions];\n" - "}\n\n" - "- (instancetype)initWithHost:(NSString *)host {\n" - " return [super initWithHost:host\n" - " packageName:@\"$package$\"\n" - " serviceName:@\"$service_name$\"];\n" - "}\n\n" - "#pragma clang diagnostic pop\n\n"); + "}\n\n"); + if (!generator_params.no_v1_compatibility) { + printer.Print(vars, + "- (instancetype)initWithHost:(NSString *)host {\n" + " return [super initWithHost:host\n" + " packageName:@\"$package$\"\n" + " serviceName:@\"$service_name$\"];\n" + "}\n\n"); + } + printer.Print("#pragma clang diagnostic pop\n\n"); printer.Print( "// Override superclass initializer to disallow different" @@ -404,11 +417,13 @@ void PrintMethodImplementations(Printer* printer, " return [self initWithHost:host callOptions:callOptions];\n" "}\n\n"); + printer.Print("#pragma mark - Class Methods\n\n"); + if (!generator_params.no_v1_compatibility) { + printer.Print("+ (instancetype)serviceWithHost:(NSString *)host {\n" + " return [[self alloc] initWithHost:host];\n" + "}\n\n"); + } printer.Print( - "#pragma mark - Class Methods\n\n" - "+ (instancetype)serviceWithHost:(NSString *)host {\n" - " return [[self alloc] initWithHost:host];\n" - "}\n\n" "+ (instancetype)serviceWithHost:(NSString *)host " "callOptions:(GRPCCallOptions *_Nullable)callOptions {\n" " return [[self alloc] initWithHost:host callOptions:callOptions];\n" @@ -417,7 +432,7 @@ void PrintMethodImplementations(Printer* printer, printer.Print("#pragma mark - Method Implementations\n\n"); for (int i = 0; i < service->method_count(); i++) { - PrintMethodImplementations(&printer, service->method(i)); + PrintMethodImplementations(&printer, service->method(i), generator_params); } printer.Print("@end\n"); diff --git a/src/compiler/objective_c_generator.h b/src/compiler/objective_c_generator.h index c171e5bf772..3f5b3e8b780 100644 --- a/src/compiler/objective_c_generator.h +++ b/src/compiler/objective_c_generator.h @@ -23,6 +23,11 @@ namespace grpc_objective_c_generator { +struct Parameters { + // Do not generate V1 interface and implementation + bool no_v1_compatibility; +}; + using ::grpc::protobuf::FileDescriptor; using ::grpc::protobuf::FileDescriptor; using ::grpc::protobuf::ServiceDescriptor; @@ -34,7 +39,7 @@ string GetAllMessageClasses(const FileDescriptor* file); // Returns the content to be included defining the @protocol segment at the // insertion point of the generated implementation file. This interface is // legacy and for backwards compatibility. -string GetProtocol(const ServiceDescriptor* service); +string GetProtocol(const ServiceDescriptor* service, const Parameters& generator_params); // Returns the content to be included defining the @protocol segment at the // insertion point of the generated implementation file. @@ -42,11 +47,11 @@ string GetV2Protocol(const ServiceDescriptor* service); // Returns the content to be included defining the @interface segment at the // insertion point of the generated implementation file. -string GetInterface(const ServiceDescriptor* service); +string GetInterface(const ServiceDescriptor* service, const Parameters& generator_params); // Returns the content to be included in the "global_scope" insertion point of // the generated implementation file. -string GetSource(const ServiceDescriptor* service); +string GetSource(const ServiceDescriptor* service, const Parameters& generator_params); } // namespace grpc_objective_c_generator diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index 87977095d05..b46a50b81a1 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -83,13 +83,29 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string file_name = google::protobuf::compiler::objectivec::FilePath(file); + grpc_objective_c_generator::Parameters generator_params; + generator_params.no_v1_compatibility = false; + + if (!parameter.empty()) { + std::vector parameters_list = + grpc_generator::tokenize(parameter, ","); + for (auto parameter_string = parameters_list.begin(); + parameter_string != parameters_list.end(); parameter_string++) { + std::vector param = + grpc_generator::tokenize(*parameter_string, "="); + if (param[0] == "no_v1_compatibility") { + generator_params.no_v1_compatibility = true; + } + } + } + { // Generate .pbrpc.h ::grpc::string imports = LocalImport(file_name + ".pbobjc.h"); - ::grpc::string system_imports = SystemImport("ProtoRPC/ProtoService.h") + - SystemImport("ProtoRPC/ProtoRPC.h") + + ::grpc::string system_imports = (generator_params.no_v1_compatibility ? SystemImport("ProtoRPC/ProtoService.h") : SystemImport("ProtoRPC/ProtoServiceLegacy.h")) + + (generator_params.no_v1_compatibility ? SystemImport("ProtoRPC/ProtoRPC.h") : SystemImport("ProtoRPC/ProtoRPCLegacy.h")) + SystemImport("RxLibrary/GRXWriteable.h") + SystemImport("RxLibrary/GRXWriter.h"); @@ -118,13 +134,13 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string protocols; for (int i = 0; i < file->service_count(); i++) { const grpc::protobuf::ServiceDescriptor* service = file->service(i); - protocols += grpc_objective_c_generator::GetProtocol(service); + protocols += grpc_objective_c_generator::GetProtocol(service, generator_params); } ::grpc::string interfaces; for (int i = 0; i < file->service_count(); i++) { const grpc::protobuf::ServiceDescriptor* service = file->service(i); - interfaces += grpc_objective_c_generator::GetInterface(service); + interfaces += grpc_objective_c_generator::GetInterface(service, generator_params); } Write(context, file_name + ".pbrpc.h", @@ -143,7 +159,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string imports = LocalImport(file_name + ".pbrpc.h") + LocalImport(file_name + ".pbobjc.h") + - SystemImport("ProtoRPC/ProtoRPC.h") + + (generator_params.no_v1_compatibility ? SystemImport("ProtoRPC/ProtoRPC.h") : SystemImport("ProtoRPC/ProtoRPCLegacy.h")) + SystemImport("RxLibrary/GRXWriter+Immediate.h"); ::grpc::string class_imports; @@ -154,7 +170,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string definitions; for (int i = 0; i < file->service_count(); i++) { const grpc::protobuf::ServiceDescriptor* service = file->service(i); - definitions += grpc_objective_c_generator::GetSource(service); + definitions += grpc_objective_c_generator::GetSource(service, generator_params); } Write(context, file_name + ".pbrpc.m", From d6a201b62b0673bb7d24a10f2f9ecb7b843d499a Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 23 Jul 2019 10:14:25 -0700 Subject: [PATCH 0966/1555] Isolate legacy in ProtoRPC --- gRPC-ProtoRPC.podspec | 18 +++- src/objective-c/GRPCClient/GRPCCall.h | 5 +- src/objective-c/ProtoRPC/ProtoRPC.h | 37 ++------ src/objective-c/ProtoRPC/ProtoRPC.m | 75 +---------------- src/objective-c/ProtoRPC/ProtoRPCLegacy.h | 34 ++++++++ src/objective-c/ProtoRPC/ProtoRPCLegacy.m | 84 +++++++++++++++++++ src/objective-c/ProtoRPC/ProtoService.h | 15 ++-- src/objective-c/ProtoRPC/ProtoService.m | 35 +------- src/objective-c/ProtoRPC/ProtoServiceLegacy.h | 18 ++++ src/objective-c/ProtoRPC/ProtoServiceLegacy.m | 40 +++++++++ templates/gRPC-ProtoRPC.podspec.template | 18 +++- 11 files changed, 220 insertions(+), 159 deletions(-) create mode 100644 src/objective-c/ProtoRPC/ProtoRPCLegacy.h create mode 100644 src/objective-c/ProtoRPC/ProtoRPCLegacy.m create mode 100644 src/objective-c/ProtoRPC/ProtoServiceLegacy.h create mode 100644 src/objective-c/ProtoRPC/ProtoServiceLegacy.m diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 2c0441ba95c..3de3c553567 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -43,20 +43,32 @@ Pod::Spec.new do |s| src_dir = 'src/objective-c/ProtoRPC' - s.default_subspec = 'Main' + s.default_subspec = 'Main', 'Legacy' s.subspec 'Main' do |ss| ss.header_mappings_dir = "#{src_dir}" ss.dependency 'gRPC', version + ss.dependency 'Protobuf', '~> 3.0' + + ss.source_files = "src/objective-c/ProtoRPC/ProtoMethod.{h,m}", + "src/objective-c/ProtoRPC/ProtoRPC.{h,m}", + "src/objective-c/ProtoRPC/ProtoService.{h,m}" + end + + s.subspec 'Legacy' do |ss| + ss.header_mappings_dir = "#{src_dir}" + ss.dependency "#{s.name}/Main", version + ss.dependency 'gRPC/GRPCCore', version ss.dependency 'gRPC-RxLibrary', version ss.dependency 'Protobuf', '~> 3.0' - ss.source_files = "#{src_dir}/*.{h,m}" + ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.{h,m}", + "src/objective-c/ProtoRPC/ProtoServiceLegacy.{h,m}" end # CFStream is now default. Leaving this subspec only for compatibility purpose. s.subspec 'CFStream' do |ss| - ss.dependency "#{s.name}/Main", version + ss.dependency "#{s.name}/Legacy", version end s.pod_target_xcconfig = { diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index 504da43329a..2ab69480fb8 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -38,11 +38,8 @@ #import "GRPCDispatchable.h" // The legacy header is included for backwards compatibility. Some V1 API users are still using -// GRPCCall by importing GRPCCall.h header so we need this import. However, if a user needs to -// exclude the core implementation, they may do so by defining GRPC_OBJC_NO_LEGACY_COMPATIBILITY. -#ifndef GRPC_OBJC_NO_LEGACY_COMPATIBILITY +// GRPCCall by importing GRPCCall.h header so we need this import. #import "GRPCCallLegacy.h" -#endif NS_ASSUME_NONNULL_BEGIN diff --git a/src/objective-c/ProtoRPC/ProtoRPC.h b/src/objective-c/ProtoRPC/ProtoRPC.h index 12db46adeda..ab9a180eb97 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.h +++ b/src/objective-c/ProtoRPC/ProtoRPC.h @@ -17,12 +17,13 @@ */ #import -#import #import "ProtoMethod.h" NS_ASSUME_NONNULL_BEGIN +@class GRPCRequestOptions; +@class GRPCCallOptions; @class GPBMessage; /** An object can implement this protocol to receive responses from server from a call. */ @@ -159,36 +160,10 @@ NS_ASSUME_NONNULL_BEGIN @end -NS_ASSUME_NONNULL_END - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wnullability-completeness" - -__attribute__((deprecated("Please use GRPCProtoCall."))) @interface ProtoRPC - : GRPCCall - - /** - * host parameter should not contain the scheme (http:// or https://), only the name or IP - * addr and the port number, for example @"localhost:5050". - */ - - - (instancetype)initWithHost : (NSString *)host method - : (GRPCProtoMethod *)method requestsWriter : (GRXWriter *)requestsWriter responseClass - : (Class)responseClass responsesWriteable - : (id)responsesWriteable NS_DESIGNATED_INITIALIZER; - -- (void)start; -@end - /** - * This subclass is empty now. Eventually we'll remove ProtoRPC class - * to avoid potential naming conflict + * Generate an NSError object that represents a failure in parsing a proto class. For gRPC internal + * use only. */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - @interface GRPCProtoCall : ProtoRPC -#pragma clang diagnostic pop +NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError); - @end - -#pragma clang diagnostic pop +NS_ASSUME_NONNULL_END diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m index 4700fdd1124..4067dbd1820 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.m +++ b/src/objective-c/ProtoRPC/ProtoRPC.m @@ -30,7 +30,7 @@ /** * Generate an NSError object that represents a failure in parsing a proto class. */ -static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError) { +NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError) { NSDictionary *info = @{ NSLocalizedDescriptionKey : @"Unable to parse response from the server", NSLocalizedRecoverySuggestionErrorKey : @@ -291,76 +291,3 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing } @end - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-implementations" -@implementation ProtoRPC { -#pragma clang diagnostic pop - id _responseWriteable; -} - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wobjc-designated-initializers" -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - requestsWriter:(GRXWriter *)requestsWriter { - [NSException raise:NSInvalidArgumentException - format:@"Please use ProtoRPC's designated initializer instead."]; - return nil; -} -#pragma clang diagnostic pop - -// Designated initializer -- (instancetype)initWithHost:(NSString *)host - method:(GRPCProtoMethod *)method - requestsWriter:(GRXWriter *)requestsWriter - responseClass:(Class)responseClass - responsesWriteable:(id)responsesWriteable { - // Because we can't tell the type system to constrain the class, we need to check at runtime: - if (![responseClass respondsToSelector:@selector(parseFromData:error:)]) { - [NSException raise:NSInvalidArgumentException - format:@"A protobuf class to parse the responses must be provided."]; - } - // A writer that serializes the proto messages to send. - GRXWriter *bytesWriter = [requestsWriter map:^id(GPBMessage *proto) { - if (![proto isKindOfClass:[GPBMessage class]]) { - [NSException raise:NSInvalidArgumentException - format:@"Request must be a proto message: %@", proto]; - } - return [proto data]; - }]; - if ((self = [super initWithHost:host path:method.HTTPPath requestsWriter:bytesWriter])) { - __weak ProtoRPC *weakSelf = self; - - // A writeable that parses the proto messages received. - _responseWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { - // TODO(jcanizales): This is done in the main thread, and needs to happen in another thread. - NSError *error = nil; - id parsed = [responseClass parseFromData:value error:&error]; - if (parsed) { - [responsesWriteable writeValue:parsed]; - } else { - [weakSelf finishWithError:ErrorForBadProto(value, responseClass, error)]; - } - } - completionHandler:^(NSError *errorOrNil) { - [responsesWriteable writesFinishedWithError:errorOrNil]; - }]; - } - return self; -} - -- (void)start { - [self startWithWriteable:_responseWriteable]; -} - -- (void)startWithWriteable:(id)writeable { - [super startWithWriteable:writeable]; - // Break retain cycles. - _responseWriteable = nil; -} -@end - -@implementation GRPCProtoCall - -@end diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.h b/src/objective-c/ProtoRPC/ProtoRPCLegacy.h new file mode 100644 index 00000000000..893d8047104 --- /dev/null +++ b/src/objective-c/ProtoRPC/ProtoRPCLegacy.h @@ -0,0 +1,34 @@ +#import "ProtoRPC.h" +#import + +@class GRPCProtoMethod; +@class GRXWriter; +@protocol GRXWriteable; + +__attribute__((deprecated("Please use GRPCProtoCall."))) @interface ProtoRPC +: GRPCCall + +/** + * host parameter should not contain the scheme (http:// or https://), only the name or IP + * addr and the port number, for example @"localhost:5050". + */ +- +(instancetype)initWithHost : (NSString *)host method +: (GRPCProtoMethod *)method requestsWriter : (GRXWriter *)requestsWriter responseClass +: (Class)responseClass responsesWriteable +: (id)responsesWriteable NS_DESIGNATED_INITIALIZER; + +- (void)start; +@end + +/** + * This subclass is empty now. Eventually we'll remove ProtoRPC class + * to avoid potential naming conflict + */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +@interface GRPCProtoCall : ProtoRPC +#pragma clang diagnostic pop + +@end + diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.m b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m new file mode 100644 index 00000000000..45f873dc889 --- /dev/null +++ b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m @@ -0,0 +1,84 @@ +#import "ProtoRPCLegacy.h" + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS +#import +#else +#import +#endif +#import +#import +#import + + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-implementations" +@implementation ProtoRPC { +#pragma clang diagnostic pop + id _responseWriteable; +} + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wobjc-designated-initializers" +- (instancetype)initWithHost:(NSString *)host + path:(NSString *)path + requestsWriter:(GRXWriter *)requestsWriter { + [NSException raise:NSInvalidArgumentException + format:@"Please use ProtoRPC's designated initializer instead."]; + return nil; +} +#pragma clang diagnostic pop + +// Designated initializer +- (instancetype)initWithHost:(NSString *)host + method:(GRPCProtoMethod *)method + requestsWriter:(GRXWriter *)requestsWriter + responseClass:(Class)responseClass + responsesWriteable:(id)responsesWriteable { + // Because we can't tell the type system to constrain the class, we need to check at runtime: + if (![responseClass respondsToSelector:@selector(parseFromData:error:)]) { + [NSException raise:NSInvalidArgumentException + format:@"A protobuf class to parse the responses must be provided."]; + } + // A writer that serializes the proto messages to send. + GRXWriter *bytesWriter = [requestsWriter map:^id(GPBMessage *proto) { + if (![proto isKindOfClass:[GPBMessage class]]) { + [NSException raise:NSInvalidArgumentException + format:@"Request must be a proto message: %@", proto]; + } + return [proto data]; + }]; + if ((self = [super initWithHost:host path:method.HTTPPath requestsWriter:bytesWriter])) { + __weak ProtoRPC *weakSelf = self; + + // A writeable that parses the proto messages received. + _responseWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { + // TODO(jcanizales): This is done in the main thread, and needs to happen in another thread. + NSError *error = nil; + id parsed = [responseClass parseFromData:value error:&error]; + if (parsed) { + [responsesWriteable writeValue:parsed]; + } else { + [weakSelf finishWithError:ErrorForBadProto(value, responseClass, error)]; + } + } + completionHandler:^(NSError *errorOrNil) { + [responsesWriteable writesFinishedWithError:errorOrNil]; + }]; + } + return self; +} + +- (void)start { + [self startWithWriteable:_responseWriteable]; +} + +- (void)startWithWriteable:(id)writeable { + [super startWithWriteable:writeable]; + // Break retain cycles. + _responseWriteable = nil; +} +@end + +@implementation GRPCProtoCall + +@end diff --git a/src/objective-c/ProtoRPC/ProtoService.h b/src/objective-c/ProtoRPC/ProtoService.h index 900ec8d0e1e..e99d75fd3d8 100644 --- a/src/objective-c/ProtoRPC/ProtoService.h +++ b/src/objective-c/ProtoRPC/ProtoService.h @@ -31,22 +31,17 @@ #pragma clang diagnostic ignored "-Wnullability-completeness" __attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoService - : NSObject +: NSObject { + NSString *_host; + NSString *_packageName; + NSString *_serviceName; +} - (nullable instancetype)initWithHost : (nonnull NSString *)host packageName : (nonnull NSString *)packageName serviceName : (nonnull NSString *)serviceName callOptions : (nullable GRPCCallOptions *)callOptions NS_DESIGNATED_INITIALIZER; -- (instancetype)initWithHost:(NSString *)host - packageName:(NSString *)packageName - serviceName:(NSString *)serviceName; - -- (GRPCProtoCall *)RPCToMethod:(NSString *)method - requestsWriter:(GRXWriter *)requestsWriter - responseClass:(Class)responseClass - responsesWriteable:(id)responsesWriteable; - - (nullable GRPCUnaryProtoCall *)RPCToMethod:(nonnull NSString *)method message:(nonnull id)message responseHandler:(nonnull id)handler diff --git a/src/objective-c/ProtoRPC/ProtoService.m b/src/objective-c/ProtoRPC/ProtoService.m index 80a1f2f226c..3a8417d0afa 100644 --- a/src/objective-c/ProtoRPC/ProtoService.m +++ b/src/objective-c/ProtoRPC/ProtoService.m @@ -29,14 +29,11 @@ #pragma clang diagnostic ignored "-Wdeprecated-implementations" @implementation ProtoService { #pragma clang diagnostic pop - NSString *_host; - NSString *_packageName; - NSString *_serviceName; GRPCCallOptions *_callOptions; } - (instancetype)init { - return [self initWithHost:nil packageName:nil serviceName:nil]; + return [self initWithHost:nil packageName:nil serviceName:nil callOptions:nil]; } // Designated initializer @@ -58,38 +55,8 @@ return self; } -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wobjc-designated-initializers" -// Do not call designated initializer here due to nullability incompatibility. This method is from -// old API and does not assert on nullability of the parameters. - -- (instancetype)initWithHost:(NSString *)host - packageName:(NSString *)packageName - serviceName:(NSString *)serviceName { - if ((self = [super init])) { - _host = [host copy]; - _packageName = [packageName copy]; - _serviceName = [serviceName copy]; - _callOptions = nil; - } - return self; -} - #pragma clang diagnostic pop -- (GRPCProtoCall *)RPCToMethod:(NSString *)method - requestsWriter:(GRXWriter *)requestsWriter - responseClass:(Class)responseClass - responsesWriteable:(id)responsesWriteable { - GRPCProtoMethod *methodName = - [[GRPCProtoMethod alloc] initWithPackage:_packageName service:_serviceName method:method]; - return [[GRPCProtoCall alloc] initWithHost:_host - method:methodName - requestsWriter:requestsWriter - responseClass:responseClass - responsesWriteable:responsesWriteable]; -} - - (GRPCUnaryProtoCall *)RPCToMethod:(NSString *)method message:(id)message responseHandler:(id)handler diff --git a/src/objective-c/ProtoRPC/ProtoServiceLegacy.h b/src/objective-c/ProtoRPC/ProtoServiceLegacy.h new file mode 100644 index 00000000000..dd5e533379c --- /dev/null +++ b/src/objective-c/ProtoRPC/ProtoServiceLegacy.h @@ -0,0 +1,18 @@ +#import "ProtoService.h" + +@class GRPCProtoCall; +@class GRXWriter; +@protocol GRXWriteable; + +@interface ProtoService (Legacy) + +- (instancetype)initWithHost:(NSString *)host + packageName:(NSString *)packageName + serviceName:(NSString *)serviceName; + +- (GRPCProtoCall *)RPCToMethod:(NSString *)method + requestsWriter:(GRXWriter *)requestsWriter + responseClass:(Class)responseClass + responsesWriteable:(id)responsesWriteable; + +@end diff --git a/src/objective-c/ProtoRPC/ProtoServiceLegacy.m b/src/objective-c/ProtoRPC/ProtoServiceLegacy.m new file mode 100644 index 00000000000..34f2b0f2cbb --- /dev/null +++ b/src/objective-c/ProtoRPC/ProtoServiceLegacy.m @@ -0,0 +1,40 @@ +#import "ProtoServiceLegacy.h" +#import "ProtoRPCLegacy.h" +#import "ProtoMethod.h" + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-implementations" +@implementation ProtoService (Legacy) +#pragma clang diagnostic pop + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wobjc-designated-initializers" +// Do not call designated initializer here due to nullability incompatibility. This method is from +// old API and does not assert on nullability of the parameters. + +- (instancetype)initWithHost:(NSString *)host + packageName:(NSString *)packageName + serviceName:(NSString *)serviceName { + if ((self = [super init])) { + _host = [host copy]; + _packageName = [packageName copy]; + _serviceName = [serviceName copy]; + } + return self; +} + + +- (GRPCProtoCall *)RPCToMethod:(NSString *)method + requestsWriter:(GRXWriter *)requestsWriter + responseClass:(Class)responseClass + responsesWriteable:(id)responsesWriteable { + GRPCProtoMethod *methodName = + [[GRPCProtoMethod alloc] initWithPackage:_packageName service:_serviceName method:method]; + return [[GRPCProtoCall alloc] initWithHost:_host + method:methodName + requestsWriter:requestsWriter + responseClass:responseClass + responsesWriteable:responsesWriteable]; +} + +@end diff --git a/templates/gRPC-ProtoRPC.podspec.template b/templates/gRPC-ProtoRPC.podspec.template index e4d5f3ffd3d..8c0d7ffdb3e 100644 --- a/templates/gRPC-ProtoRPC.podspec.template +++ b/templates/gRPC-ProtoRPC.podspec.template @@ -45,20 +45,32 @@ src_dir = 'src/objective-c/ProtoRPC' - s.default_subspec = 'Main' + s.default_subspec = 'Main', 'Legacy' s.subspec 'Main' do |ss| ss.header_mappings_dir = "#{src_dir}" ss.dependency 'gRPC', version + ss.dependency 'Protobuf', '~> 3.0' + + ss.source_files = "src/objective-c/ProtoRPC/ProtoMethod.{h,m}", + "src/objective-c/ProtoRPC/ProtoRPC.{h,m}", + "src/objective-c/ProtoRPC/ProtoService.{h,m}" + end + + s.subspec 'Legacy' do |ss| + ss.header_mappings_dir = "#{src_dir}" + ss.dependency "#{s.name}/Main", version + ss.dependency 'gRPC/GRPCCore', version ss.dependency 'gRPC-RxLibrary', version ss.dependency 'Protobuf', '~> 3.0' - ss.source_files = "#{src_dir}/*.{h,m}" + ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.{h,m}", + "src/objective-c/ProtoRPC/ProtoServiceLegacy.{h,m}" end # CFStream is now default. Leaving this subspec only for compatibility purpose. s.subspec 'CFStream' do |ss| - ss.dependency "#{s.name}/Main", version + ss.dependency "#{s.name}/Legacy", version end s.pod_target_xcconfig = { From 4a4b37ef1ce61c741f21b2a5916d65a9e5a1ada8 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Tue, 23 Jul 2019 10:48:37 -0700 Subject: [PATCH 0967/1555] Adapted to Bazel/Blaze's import/include convention --- .../project.pbxproj | 76 +++++++++---------- .../InterceptorSample/ViewController.m | 4 +- .../RemoteTestClient/RemoteTest.podspec | 17 +++-- .../examples/RemoteTestClient/test.proto | 2 +- 4 files changed, 51 insertions(+), 48 deletions(-) diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj b/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj index 8b8811d4c62..f3388fc2a84 100644 --- a/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 1C4854A76EEB56F8096DBDEF /* libPods-InterceptorSample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CB7A7A5B91FC976FCF4637AE /* libPods-InterceptorSample.a */; }; 5EE960FB2266768A0044A74F /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE960FA2266768A0044A74F /* AppDelegate.m */; }; 5EE960FE2266768A0044A74F /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE960FD2266768A0044A74F /* ViewController.m */; }; 5EE961012266768A0044A74F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5EE960FF2266768A0044A74F /* Main.storyboard */; }; @@ -15,10 +14,11 @@ 5EE961062266768C0044A74F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5EE961042266768C0044A74F /* LaunchScreen.storyboard */; }; 5EE961092266768C0044A74F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE961082266768C0044A74F /* main.m */; }; 5EE9611222668CF20044A74F /* CacheInterceptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE9611122668CF20044A74F /* CacheInterceptor.m */; }; + B39AA5EDA7B541C915C1D823 /* libPods-InterceptorSample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EE3A6DB9460D83EFDECDEF27 /* libPods-InterceptorSample.a */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 09457A264AAE5323BF50B1F8 /* Pods-InterceptorSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InterceptorSample.debug.xcconfig"; path = "Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample.debug.xcconfig"; sourceTree = ""; }; + 53E7AEA20F8F0F23BFC5E85A /* Pods-InterceptorSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InterceptorSample.release.xcconfig"; path = "Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample.release.xcconfig"; sourceTree = ""; }; 5EE960F62266768A0044A74F /* InterceptorSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = InterceptorSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 5EE960FA2266768A0044A74F /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 5EE960FC2266768A0044A74F /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; @@ -31,8 +31,8 @@ 5EE9610F2266774C0044A74F /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 5EE9611022668CE20044A74F /* CacheInterceptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CacheInterceptor.h; sourceTree = ""; }; 5EE9611122668CF20044A74F /* CacheInterceptor.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CacheInterceptor.m; sourceTree = ""; }; - A0789280A4035D0F22F96BE6 /* Pods-InterceptorSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InterceptorSample.release.xcconfig"; path = "Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample.release.xcconfig"; sourceTree = ""; }; - CB7A7A5B91FC976FCF4637AE /* libPods-InterceptorSample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InterceptorSample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 61819C78C7CC39640B0AF90B /* Pods-InterceptorSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InterceptorSample.debug.xcconfig"; path = "Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample.debug.xcconfig"; sourceTree = ""; }; + EE3A6DB9460D83EFDECDEF27 /* libPods-InterceptorSample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InterceptorSample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -40,20 +40,28 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 1C4854A76EEB56F8096DBDEF /* libPods-InterceptorSample.a in Frameworks */, + B39AA5EDA7B541C915C1D823 /* libPods-InterceptorSample.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 5DBBA8A4C272D71DA0B942A2 /* Frameworks */ = { + isa = PBXGroup; + children = ( + EE3A6DB9460D83EFDECDEF27 /* libPods-InterceptorSample.a */, + ); + name = Frameworks; + sourceTree = ""; + }; 5EE960ED2266768A0044A74F = { isa = PBXGroup; children = ( 5EE960F82266768A0044A74F /* InterceptorSample */, 5EE960F72266768A0044A74F /* Products */, 9D49DB75F3BEDAFDE7028B51 /* Pods */, - BD7184728351C7DDAFBA5FA2 /* Frameworks */, + 5DBBA8A4C272D71DA0B942A2 /* Frameworks */, ); sourceTree = ""; }; @@ -86,20 +94,12 @@ 9D49DB75F3BEDAFDE7028B51 /* Pods */ = { isa = PBXGroup; children = ( - 09457A264AAE5323BF50B1F8 /* Pods-InterceptorSample.debug.xcconfig */, - A0789280A4035D0F22F96BE6 /* Pods-InterceptorSample.release.xcconfig */, + 61819C78C7CC39640B0AF90B /* Pods-InterceptorSample.debug.xcconfig */, + 53E7AEA20F8F0F23BFC5E85A /* Pods-InterceptorSample.release.xcconfig */, ); path = Pods; sourceTree = ""; }; - BD7184728351C7DDAFBA5FA2 /* Frameworks */ = { - isa = PBXGroup; - children = ( - CB7A7A5B91FC976FCF4637AE /* libPods-InterceptorSample.a */, - ); - name = Frameworks; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -107,11 +107,11 @@ isa = PBXNativeTarget; buildConfigurationList = 5EE9610C2266768C0044A74F /* Build configuration list for PBXNativeTarget "InterceptorSample" */; buildPhases = ( - 7531607F028A04DAAF5E97B5 /* [CP] Check Pods Manifest.lock */, + 6313E891EAC080560B6D470D /* [CP] Check Pods Manifest.lock */, 5EE960F22266768A0044A74F /* Sources */, 5EE960F32266768A0044A74F /* Frameworks */, 5EE960F42266768A0044A74F /* Resources */, - 17700C95BAEBB27F7A3D1B01 /* [CP] Copy Pods Resources */, + A3ABCCE79BCEB8687DE0D995 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -168,24 +168,7 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 17700C95BAEBB27F7A3D1B01 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample-resources-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample-resources-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 7531607F028A04DAAF5E97B5 /* [CP] Check Pods Manifest.lock */ = { + 6313E891EAC080560B6D470D /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -207,6 +190,23 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + A3ABCCE79BCEB8687DE0D995 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -357,7 +357,7 @@ }; 5EE9610D2266768C0044A74F /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 09457A264AAE5323BF50B1F8 /* Pods-InterceptorSample.debug.xcconfig */; + baseConfigurationReference = 61819C78C7CC39640B0AF90B /* Pods-InterceptorSample.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; @@ -374,7 +374,7 @@ }; 5EE9610E2266768C0044A74F /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = A0789280A4035D0F22F96BE6 /* Pods-InterceptorSample.release.xcconfig */; + baseConfigurationReference = 53E7AEA20F8F0F23BFC5E85A /* Pods-InterceptorSample.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.m b/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.m index 9da6dedbf9e..b0e66636028 100644 --- a/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.m +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.m @@ -19,8 +19,8 @@ #import "ViewController.h" #import -#import -#import +#import "src/objective-c/examples/RemoteTestClient/Messages.pbobjc.h" +#import "src/objective-c/examples/RemoteTestClient/Test.pbrpc.h" #import "CacheInterceptor.h" diff --git a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec index cd9464c453e..f6c2f91f16a 100644 --- a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec +++ b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec @@ -14,31 +14,34 @@ Pod::Spec.new do |s| s.dependency "!ProtoCompiler-gRPCPlugin" repo_root = '../../../..' - bin_dir = "#{repo_root}/bins/$CONFIG" + bin_dir = "bins/$CONFIG" protoc = "#{bin_dir}/protobuf/protoc" - well_known_types_dir = "#{repo_root}/third_party/protobuf/src" + well_known_types_dir = "third_party/protobuf/src" plugin = "#{bin_dir}/grpc_objective_c_plugin" + out_dir = "src/objective-c/examples/RemoteTestClient" s.prepare_command = <<-CMD + pushd #{repo_root} #{protoc} \ --plugin=protoc-gen-grpc=#{plugin} \ - --objc_out=. \ - --grpc_out=. \ + --objc_out=#{out_dir} \ + --grpc_out=#{out_dir} \ -I . \ -I #{well_known_types_dir} \ - *.proto + #{out_dir}/*.proto + popd CMD s.subspec 'Messages' do |ms| - ms.source_files = '*.pbobjc.{h,m}' + ms.source_files = '**/*.pbobjc.{h,m}' ms.header_mappings_dir = '.' ms.requires_arc = false ms.dependency 'Protobuf' end s.subspec 'Services' do |ss| - ss.source_files = '*.pbrpc.{h,m}' + ss.source_files = '**/*.pbrpc.{h,m}' ss.header_mappings_dir = '.' ss.requires_arc = true ss.dependency 'gRPC-ProtoRPC' diff --git a/src/objective-c/examples/RemoteTestClient/test.proto b/src/objective-c/examples/RemoteTestClient/test.proto index c5696043630..8c91f7d9f2e 100644 --- a/src/objective-c/examples/RemoteTestClient/test.proto +++ b/src/objective-c/examples/RemoteTestClient/test.proto @@ -17,7 +17,7 @@ syntax = "proto3"; import "google/protobuf/empty.proto"; -import "messages.proto"; +import "src/objective-c/examples/RemoteTestClient/messages.proto"; package grpc.testing; From b489b5e6945b4edf3226d401feaea879531ce68e Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 23 Jul 2019 13:59:26 -0400 Subject: [PATCH 0968/1555] review comments --- .../UnaryCallOverheadBenchmark.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs index a58a46695be..4953806f6f4 100644 --- a/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs @@ -24,13 +24,10 @@ using System; namespace Grpc.Microbenchmarks { - // this test creates a real server and client, measuring the inherent inbuilt - // platform overheads; the marshallers **DO NOT ALLOCATE**, so any allocations + // this test measures the overhead of C# wrapping layer when invoking calls; + // the marshallers **DO NOT ALLOCATE**, so any allocations // are from the framework, not the messages themselves - // important: allocs are not reliable on .NET Core until .NET Core 3, since - // this test involves multiple threads - [ClrJob, CoreJob] // test .NET Core and .NET Framework [MemoryDiagnoser] // allocations public class UnaryCallOverheadBenchmark @@ -41,7 +38,7 @@ namespace Grpc.Microbenchmarks private static readonly Method PingMethod = new Method(MethodType.Unary, nameof(PingBenchmark), "Ping", EmptyMarshaller, EmptyMarshaller); [Benchmark] - public string Ping() + public string SyncUnaryCallOverhead() { return client.Ping("", new CallOptions()); } @@ -52,7 +49,7 @@ namespace Grpc.Microbenchmarks [GlobalSetup] public void Setup() { - // create client + // create client, the channel will actually never connect because call logic will be short-circuited channel = new Channel("localhost", 10042, ChannelCredentials.Insecure); client = new PingClient(new DefaultCallInvoker(channel)); From 0975e12db1af7fdf17144140f0d267fc666b586a Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Thu, 18 Jul 2019 12:45:47 -0700 Subject: [PATCH 0969/1555] Reduced atomic strictness inside grpc_core::Fork. The enable state for fork operations, used by ExecCtx initialization, uses default std::atomic semantics on read/write - this is sequential consistency by default. However, this variable is only set: 1) On init, 2) Using testing interfaces And thus we can just use relaxed semantics instead. This PR also moves from std::atomic to grpc_core::Atomic. --- src/core/lib/gprpp/fork.cc | 35 ++++++++++++++--------------------- src/core/lib/gprpp/fork.h | 19 +++++++++++++++---- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/core/lib/gprpp/fork.cc b/src/core/lib/gprpp/fork.cc index 37552692373..51836d52cf4 100644 --- a/src/core/lib/gprpp/fork.cc +++ b/src/core/lib/gprpp/fork.cc @@ -168,40 +168,33 @@ class ThreadState { void Fork::GlobalInit() { if (!override_enabled_) { - support_enabled_ = GPR_GLOBAL_CONFIG_GET(grpc_enable_fork_support); + support_enabled_.Store(GPR_GLOBAL_CONFIG_GET(grpc_enable_fork_support), + MemoryOrder::RELAXED); } - if (support_enabled_) { + if (support_enabled_.Load(MemoryOrder::RELAXED)) { exec_ctx_state_ = grpc_core::New(); thread_state_ = grpc_core::New(); } } void Fork::GlobalShutdown() { - if (support_enabled_) { + if (support_enabled_.Load(MemoryOrder::RELAXED)) { grpc_core::Delete(exec_ctx_state_); grpc_core::Delete(thread_state_); } } -bool Fork::Enabled() { return support_enabled_; } +bool Fork::Enabled() { return support_enabled_.Load(MemoryOrder::RELAXED); } // Testing Only void Fork::Enable(bool enable) { override_enabled_ = true; - support_enabled_ = enable; + support_enabled_.Store(enable, MemoryOrder::RELAXED); } -void Fork::IncExecCtxCount() { - if (support_enabled_) { - exec_ctx_state_->IncExecCtxCount(); - } -} +void Fork::DoIncExecCtxCount() { exec_ctx_state_->IncExecCtxCount(); } -void Fork::DecExecCtxCount() { - if (support_enabled_) { - exec_ctx_state_->DecExecCtxCount(); - } -} +void Fork::DoDecExecCtxCount() { exec_ctx_state_->DecExecCtxCount(); } void Fork::SetResetChildPollingEngineFunc( Fork::child_postfork_func reset_child_polling_engine) { @@ -212,38 +205,38 @@ Fork::child_postfork_func Fork::GetResetChildPollingEngineFunc() { } bool Fork::BlockExecCtx() { - if (support_enabled_) { + if (support_enabled_.Load(MemoryOrder::RELAXED)) { return exec_ctx_state_->BlockExecCtx(); } return false; } void Fork::AllowExecCtx() { - if (support_enabled_) { + if (support_enabled_.Load(MemoryOrder::RELAXED)) { exec_ctx_state_->AllowExecCtx(); } } void Fork::IncThreadCount() { - if (support_enabled_) { + if (support_enabled_.Load(MemoryOrder::RELAXED)) { thread_state_->IncThreadCount(); } } void Fork::DecThreadCount() { - if (support_enabled_) { + if (support_enabled_.Load(MemoryOrder::RELAXED)) { thread_state_->DecThreadCount(); } } void Fork::AwaitThreads() { - if (support_enabled_) { + if (support_enabled_.Load(MemoryOrder::RELAXED)) { thread_state_->AwaitThreads(); } } internal::ExecCtxState* Fork::exec_ctx_state_ = nullptr; internal::ThreadState* Fork::thread_state_ = nullptr; -std::atomic Fork::support_enabled_; +Atomic Fork::support_enabled_(false); bool Fork::override_enabled_ = false; Fork::child_postfork_func Fork::reset_child_polling_engine_ = nullptr; } // namespace grpc_core diff --git a/src/core/lib/gprpp/fork.h b/src/core/lib/gprpp/fork.h index 73f2fa56aa7..3601d7ca925 100644 --- a/src/core/lib/gprpp/fork.h +++ b/src/core/lib/gprpp/fork.h @@ -21,7 +21,7 @@ #include -#include +#include "src/core/lib/gprpp/atomic.h" /* * NOTE: FORKING IS NOT GENERALLY SUPPORTED, THIS IS ONLY INTENDED TO WORK @@ -47,10 +47,18 @@ class Fork { // Increment the count of active ExecCtxs. // Will block until a pending fork is complete if one is in progress. - static void IncExecCtxCount(); + static void IncExecCtxCount() { + if (GPR_UNLIKELY(support_enabled_.Load(MemoryOrder::RELAXED))) { + DoIncExecCtxCount(); + } + } // Decrement the count of active ExecCtxs - static void DecExecCtxCount(); + static void DecExecCtxCount() { + if (GPR_UNLIKELY(support_enabled_.Load(MemoryOrder::RELAXED))) { + DoDecExecCtxCount(); + } + } // Provide a function that will be invoked in the child's postfork handler to // reset the polling engine's internal state. @@ -80,9 +88,12 @@ class Fork { static void Enable(bool enable); private: + static void DoIncExecCtxCount(); + static void DoDecExecCtxCount(); + static internal::ExecCtxState* exec_ctx_state_; static internal::ThreadState* thread_state_; - static std::atomic support_enabled_; + static grpc_core::Atomic support_enabled_; static bool override_enabled_; static child_postfork_func reset_child_polling_engine_; }; From efd6946d21a86212e58e992c9960da9ab8838eee Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Tue, 23 Jul 2019 15:35:50 -0700 Subject: [PATCH 0970/1555] Reformat --- test/cpp/microbenchmarks/bm_threadpool.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_threadpool.cc b/test/cpp/microbenchmarks/bm_threadpool.cc index 1cd41dafa7f..c800fadf9d0 100644 --- a/test/cpp/microbenchmarks/bm_threadpool.cc +++ b/test/cpp/microbenchmarks/bm_threadpool.cc @@ -236,8 +236,7 @@ class AddSelfFunctor : public grpc_experimental_completion_queue_functor { int num_add_; }; -void ThreadPoolAddSelfHelper(benchmark::State& state, - int concurrent_functor) { +void ThreadPoolAddSelfHelper(benchmark::State& state, int concurrent_functor) { const int num_iterations = state.range(0); const int num_threads = state.range(1); // Number of adds done by each closure. From b2e8417400a3b7a5030a2d28299e1cdcb1b8bafb Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Tue, 23 Jul 2019 16:23:10 -0700 Subject: [PATCH 0971/1555] clang_format_code'd files previously parsed wrong --- .../ExtensionDelegate.h | 2 +- .../ExtensionDelegate.m | 80 +++++++++++-------- .../InterfaceController.h | 2 +- .../InterfaceController.m | 13 +-- 4 files changed, 50 insertions(+), 47 deletions(-) diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.h b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.h index 9b48cc95e6a..fbf67335f7d 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.h +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.h @@ -18,6 +18,6 @@ #import -@interface ExtensionDelegate : NSObject +@interface ExtensionDelegate : NSObject @end diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.m b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.m index 47de32a3de9..5be441937b6 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.m @@ -21,51 +21,61 @@ @implementation ExtensionDelegate - (void)applicationDidFinishLaunching { - // Perform any final initialization of your application. + // Perform any final initialization of your application. } - (void)applicationDidBecomeActive { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + // Restart any tasks that were paused (or not yet started) while the application was inactive. If + // the application was previously in the background, optionally refresh the user interface. } - (void)applicationWillResignActive { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, etc. + // Sent when the application is about to move from active to inactive state. This can occur for + // certain types of temporary interruptions (such as an incoming phone call or SMS message) or + // when the user quits the application and it begins the transition to the background state. Use + // this method to pause ongoing tasks, disable timers, etc. } - (void)handleBackgroundTasks:(NSSet *)backgroundTasks { - // Sent when the system needs to launch the application in the background to process tasks. Tasks arrive in a set, so loop through and process each one. - for (WKRefreshBackgroundTask * task in backgroundTasks) { - // Check the Class of each task to decide how to process it - if ([task isKindOfClass:[WKApplicationRefreshBackgroundTask class]]) { - // Be sure to complete the background task once you’re done. - WKApplicationRefreshBackgroundTask *backgroundTask = (WKApplicationRefreshBackgroundTask*)task; - [backgroundTask setTaskCompletedWithSnapshot:NO]; - } else if ([task isKindOfClass:[WKSnapshotRefreshBackgroundTask class]]) { - // Snapshot tasks have a unique completion call, make sure to set your expiration date - WKSnapshotRefreshBackgroundTask *snapshotTask = (WKSnapshotRefreshBackgroundTask*)task; - [snapshotTask setTaskCompletedWithDefaultStateRestored:YES estimatedSnapshotExpiration:[NSDate distantFuture] userInfo:nil]; - } else if ([task isKindOfClass:[WKWatchConnectivityRefreshBackgroundTask class]]) { - // Be sure to complete the background task once you’re done. - WKWatchConnectivityRefreshBackgroundTask *backgroundTask = (WKWatchConnectivityRefreshBackgroundTask*)task; - [backgroundTask setTaskCompletedWithSnapshot:NO]; - } else if ([task isKindOfClass:[WKURLSessionRefreshBackgroundTask class]]) { - // Be sure to complete the background task once you’re done. - WKURLSessionRefreshBackgroundTask *backgroundTask = (WKURLSessionRefreshBackgroundTask*)task; - [backgroundTask setTaskCompletedWithSnapshot:NO]; - } else if ([task isKindOfClass:[WKRelevantShortcutRefreshBackgroundTask class]]) { - // Be sure to complete the relevant-shortcut task once you’re done. - WKRelevantShortcutRefreshBackgroundTask *relevantShortcutTask = (WKRelevantShortcutRefreshBackgroundTask*)task; - [relevantShortcutTask setTaskCompletedWithSnapshot:NO]; - } else if ([task isKindOfClass:[WKIntentDidRunRefreshBackgroundTask class]]) { - // Be sure to complete the intent-did-run task once you’re done. - WKIntentDidRunRefreshBackgroundTask *intentDidRunTask = (WKIntentDidRunRefreshBackgroundTask*)task; - [intentDidRunTask setTaskCompletedWithSnapshot:NO]; - } else { - // make sure to complete unhandled task types - [task setTaskCompletedWithSnapshot:NO]; - } + // Sent when the system needs to launch the application in the background to process tasks. Tasks + // arrive in a set, so loop through and process each one. + for (WKRefreshBackgroundTask *task in backgroundTasks) { + // Check the Class of each task to decide how to process it + if ([task isKindOfClass:[WKApplicationRefreshBackgroundTask class]]) { + // Be sure to complete the background task once you’re done. + WKApplicationRefreshBackgroundTask *backgroundTask = + (WKApplicationRefreshBackgroundTask *)task; + [backgroundTask setTaskCompletedWithSnapshot:NO]; + } else if ([task isKindOfClass:[WKSnapshotRefreshBackgroundTask class]]) { + // Snapshot tasks have a unique completion call, make sure to set your expiration date + WKSnapshotRefreshBackgroundTask *snapshotTask = (WKSnapshotRefreshBackgroundTask *)task; + [snapshotTask setTaskCompletedWithDefaultStateRestored:YES + estimatedSnapshotExpiration:[NSDate distantFuture] + userInfo:nil]; + } else if ([task isKindOfClass:[WKWatchConnectivityRefreshBackgroundTask class]]) { + // Be sure to complete the background task once you’re done. + WKWatchConnectivityRefreshBackgroundTask *backgroundTask = + (WKWatchConnectivityRefreshBackgroundTask *)task; + [backgroundTask setTaskCompletedWithSnapshot:NO]; + } else if ([task isKindOfClass:[WKURLSessionRefreshBackgroundTask class]]) { + // Be sure to complete the background task once you’re done. + WKURLSessionRefreshBackgroundTask *backgroundTask = (WKURLSessionRefreshBackgroundTask *)task; + [backgroundTask setTaskCompletedWithSnapshot:NO]; + } else if ([task isKindOfClass:[WKRelevantShortcutRefreshBackgroundTask class]]) { + // Be sure to complete the relevant-shortcut task once you’re done. + WKRelevantShortcutRefreshBackgroundTask *relevantShortcutTask = + (WKRelevantShortcutRefreshBackgroundTask *)task; + [relevantShortcutTask setTaskCompletedWithSnapshot:NO]; + } else if ([task isKindOfClass:[WKIntentDidRunRefreshBackgroundTask class]]) { + // Be sure to complete the intent-did-run task once you’re done. + WKIntentDidRunRefreshBackgroundTask *intentDidRunTask = + (WKIntentDidRunRefreshBackgroundTask *)task; + [intentDidRunTask setTaskCompletedWithSnapshot:NO]; + } else { + // make sure to complete unhandled task types + [task setTaskCompletedWithSnapshot:NO]; } + } } @end diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.h b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.h index 46032d6030e..edcc75d5530 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.h +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.h @@ -16,8 +16,8 @@ * */ -#import #import +#import @interface InterfaceController : WKInterfaceController diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.m b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.m index ec3e90c95a5..77efbc42447 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.m @@ -24,7 +24,6 @@ @end - @implementation InterfaceController { GRPCCallOptions *_options; RMTTestService *_service; @@ -35,10 +34,9 @@ // Configure interface objects here. - GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; _options = options; - + _service = [[RMTTestService alloc] initWithHost:@"grpc-test.sandbox.googleapis.com" callOptions:_options]; } @@ -54,12 +52,10 @@ } - (IBAction)makeCall { - RMTSimpleRequest *request = [RMTSimpleRequest message]; request.responseSize = 100; - GRPCUnaryProtoCall *call = [_service unaryCallWithMessage:request - responseHandler:self - callOptions:nil]; + GRPCUnaryProtoCall *call = + [_service unaryCallWithMessage:request responseHandler:self callOptions:nil]; [call start]; } @@ -72,6 +68,3 @@ } @end - - - From d452fb52815cc759eda3c0fa49e861a6a0646367 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 4 Jun 2019 09:14:00 -0700 Subject: [PATCH 0972/1555] Fix typo of channelz proto --- src/proto/grpc/channelz/channelz.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proto/grpc/channelz/channelz.proto b/src/proto/grpc/channelz/channelz.proto index 20de23f7fa3..f0b3b10837e 100644 --- a/src/proto/grpc/channelz/channelz.proto +++ b/src/proto/grpc/channelz/channelz.proto @@ -165,7 +165,7 @@ message ChannelRef { reserved 3, 4, 5, 6, 7, 8; } -// ChannelRef is a reference to a Subchannel. +// SubchannelRef is a reference to a Subchannel. message SubchannelRef { // The globally unique id for this subchannel. Must be a positive number. int64 subchannel_id = 7; From a4608cb3735d77d5dc74256ee8a7da497125207a Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Wed, 24 Jul 2019 01:34:08 +0200 Subject: [PATCH 0973/1555] Properly using upb's upstream. --- .gitmodules | 2 +- bazel/grpc_deps.bzl | 6 +++--- third_party/upb | 2 +- tools/run_tests/sanity/check_submodules.sh | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitmodules b/.gitmodules index da360131e43..6443f8362aa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -53,4 +53,4 @@ url = https://github.com/envoyproxy/protoc-gen-validate.git [submodule "third_party/upb"] path = third_party/upb - url = https://github.com/google/upb.git + url = https://github.com/protocolbuffers/upb.git diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 2160d84525b..5ad1b92900b 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -206,9 +206,9 @@ def grpc_deps(): if "upb" not in native.existing_rules(): http_archive( name = "upb", - sha256 = "67874e217f39e66a3015f51dcdc6831575c25f2260fff9b80482f190278ea586", - strip_prefix = "upb-4d8af5e4b998fccc8c9a5d5505866f4722f64954", - url = "https://github.com/nicolasnoble/upb/archive/4d8af5e4b998fccc8c9a5d5505866f4722f64954.tar.gz", + sha256 = "1107ca1ea9aef3880b60ffb2179d06970394f1d6b62d0565e72b544b4924468d", + strip_prefix = "upb-1ee1e362565f681fdd46f16bf9f70f51c905ddd4", + url = "https://github.com/protocolbuffers/upb/archive/1ee1e362565f681fdd46f16bf9f70f51c905ddd4.tar.gz", ) if "envoy_api" not in native.existing_rules(): http_archive( diff --git a/third_party/upb b/third_party/upb index 312c6b421a3..1ee1e362565 160000 --- a/third_party/upb +++ b/third_party/upb @@ -1 +1 @@ -Subproject commit 312c6b421a3c749e4f7c0e2193d4775cb997cff7 +Subproject commit 1ee1e362565f681fdd46f16bf9f70f51c905ddd4 diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index 136d2b960c0..977b4be2c2f 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -40,7 +40,7 @@ cat << EOF | awk '{ print $1 }' | sort > "$want_submodules" 9245d481eb3e890f708ff2d7dadf2a10c04748ba third_party/libcxxabi (heads/release_60) 09745575a923640154bcf307fba8aedff47f240a third_party/protobuf (v3.7.0-rc.2-247-g09745575) e143189bf6f37b3957fb31743df6a1bcf4a8c685 third_party/protoc-gen-validate (v0.0.10) - ce3ba4dcdcd34d85672d93bd552e8bc871f02b53 third_party/upb (heads/master) + 1ee1e362565f681fdd46f16bf9f70f51c905ddd4 third_party/upb (heads/master) cacf7f1d4e3d44d871b605da3b647f07d718623f third_party/zlib (v1.2.11) EOF From 0161de3a566d030891c3ffb245b6ba17e46c613e Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Tue, 23 Jul 2019 17:11:45 -0700 Subject: [PATCH 0974/1555] Addressing comments --- src/core/lib/iomgr/executor/mpmcqueue.cc | 20 +++++------- src/core/lib/iomgr/executor/mpmcqueue.h | 9 +++++- test/core/iomgr/mpmcqueue_test.cc | 40 ++++++++++++++---------- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index 15b2938a3ac..377a135e1f3 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -27,7 +27,7 @@ DebugOnlyTraceFlag grpc_thread_pool_trace(false, "thread_pool"); inline void* InfLenFIFOQueue::PopFront() { // Caller should already check queue is not empty and has already held the // mutex. This function will assume that there is at least one element in the - // queue (aka queue_head_ content is valid). + // queue (i.e. queue_head_->content is valid). void* result = queue_head_->content; count_.Store(count_.Load(MemoryOrder::RELAXED) - 1, MemoryOrder::RELAXED); @@ -65,6 +65,7 @@ inline void* InfLenFIFOQueue::PopFront() { } InfLenFIFOQueue::Node* InfLenFIFOQueue::AllocateNodes(int num) { + num_nodes_ = num_nodes_ + num; Node* new_chunk = static_cast(gpr_zalloc(sizeof(Node) * num)); new_chunk[0].next = &new_chunk[1]; new_chunk[num - 1].prev = &new_chunk[num - 2]; @@ -76,11 +77,11 @@ InfLenFIFOQueue::Node* InfLenFIFOQueue::AllocateNodes(int num) { } InfLenFIFOQueue::InfLenFIFOQueue() { - delete_list_size_ = 1024; + delete_list_size_ = kDeleteListInitSize; delete_list_ = static_cast(gpr_zalloc(sizeof(Node*) * delete_list_size_)); - Node* new_chunk = AllocateNodes(1024); + Node* new_chunk = AllocateNodes(kDeleteListInitSize); delete_list_[delete_list_count_++] = new_chunk; queue_head_ = queue_tail_ = new_chunk; new_chunk[0].prev = &new_chunk[1023]; @@ -126,10 +127,11 @@ void InfLenFIFOQueue::Put(void* elem) { stats_.num_started++; gpr_log(GPR_INFO, "[InfLenFIFOQueue Put] num_started: %" PRIu64, stats_.num_started); + auto current_time = gpr_now(GPR_CLOCK_MONOTONIC); if (curr_count == 0) { - busy_time = gpr_now(GPR_CLOCK_MONOTONIC); + busy_time = current_time; } - queue_tail_->insert_time = gpr_now(GPR_CLOCK_MONOTONIC); + queue_tail_->insert_time = current_time; } count_.Store(curr_count + 1, MemoryOrder::RELAXED); @@ -163,14 +165,6 @@ void* InfLenFIFOQueue::Get(gpr_timespec* wait_time) { return PopFront(); } -size_t InfLenFIFOQueue::num_node() { - size_t num = 1024; - for (size_t i = 1; i < delete_list_count_; ++i) { - num = num * 2; - } - return num; -} - void InfLenFIFOQueue::PushWaiter(Waiter* waiter) { waiter->next = waiters_.next; waiter->prev = &waiters_; diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index 49bebf8af4b..41e7e2a11be 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -89,7 +89,10 @@ class InfLenFIFOQueue : public MPMCQueueInterface { // For test purpose only. Returns number of nodes allocated in queue. // All allocated nodes will not be free until destruction of queue. - size_t num_node(); + int num_nodes() const { return num_nodes_; } + + // For test purpose only. Returns the initial number of nodes in queue. + int init_num_nodes() const { return kQueueInitNumNodes; } private: // For Internal Use Only. @@ -144,6 +147,9 @@ class InfLenFIFOQueue : public MPMCQueueInterface { Mutex mu_; // Protecting lock Waiter waiters_; // Head of waiting thread queue + const int kDeleteListInitSize = 1024; // Initial size for delete list + const int kQueueInitNumNodes = 1024; // Initial number of nodes allocated + Node** delete_list_ = nullptr; // Keeps track of all allocated array entries // for deleting on destruction size_t delete_list_count_ = 0; // Number of entries in list @@ -153,6 +159,7 @@ class InfLenFIFOQueue : public MPMCQueueInterface { Node* queue_head_ = nullptr; // Head of the queue, remove position Node* queue_tail_ = nullptr; // End of queue, insert position Atomic count_{0}; // Number of elements in queue + int num_nodes_ = 0; // Number of nodes allocated Stats stats_; // Stats info gpr_timespec busy_time; // Start time of busy queue diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index 68d1da65405..732c43a06f5 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -119,47 +119,53 @@ static void test_FIFO(void) { } } +// Test if queue's behavior of expanding is correct. (Only does expansion when +// it gets full, and each time expands to doubled size). static void test_space_efficiency(void) { gpr_log(GPR_INFO, "test_space_efficiency"); grpc_core::InfLenFIFOQueue queue; - for (int i = 0; i < 1024; ++i) { + for (int i = 0; i < queue.init_num_nodes(); ++i) { queue.Put(static_cast(grpc_core::New(i))); } - GPR_ASSERT(queue.num_node() == 1024); - for (int i = 0; i < 1024; ++i) { + // List should not have been expanded at this time. + GPR_ASSERT(queue.num_nodes() == queue.init_num_nodes()); + for (int i = 0; i < queue.init_num_nodes(); ++i) { WorkItem* item = static_cast(queue.Get()); queue.Put(item); } - GPR_ASSERT(queue.num_node() == 1024); - for (int i = 0; i < 1024; ++i) { + GPR_ASSERT(queue.num_nodes() == queue.init_num_nodes()); + for (int i = 0; i < queue.init_num_nodes(); ++i) { WorkItem* item = static_cast(queue.Get()); grpc_core::Delete(item); } - GPR_ASSERT(queue.num_node() == 1024); + GPR_ASSERT(queue.num_nodes() == queue.init_num_nodes()); GPR_ASSERT(queue.count() == 0); // queue empty now - for (int i = 0; i < 4000; ++i) { + for (int i = 0; i < queue.init_num_nodes() * 2; ++i) { queue.Put(static_cast(grpc_core::New(i))); } - GPR_ASSERT(queue.count() == 4000); - GPR_ASSERT(queue.num_node() == 4096); - for (int i = 0; i < 2000; ++i) { + GPR_ASSERT(queue.count() == queue.init_num_nodes() * 2); + // List should have been expanded once. + GPR_ASSERT(queue.num_nodes() == queue.init_num_nodes() * 2); + for (int i = 0; i < queue.init_num_nodes(); ++i) { WorkItem* item = static_cast(queue.Get()); grpc_core::Delete(item); } - GPR_ASSERT(queue.count() == 2000); - GPR_ASSERT(queue.num_node() == 4096); - for (int i = 0; i < 1000; ++i) { + GPR_ASSERT(queue.count() == queue.init_num_nodes()); + // List will never shrink, should keep same number of node as before. + GPR_ASSERT(queue.num_nodes() == queue.init_num_nodes() * 2); + for (int i = 0; i < queue.init_num_nodes() + 1; ++i) { queue.Put(static_cast(grpc_core::New(i))); } - GPR_ASSERT(queue.count() == 3000); - GPR_ASSERT(queue.num_node() == 4096); - for (int i = 0; i < 3000; ++i) { + GPR_ASSERT(queue.count() == queue.init_num_nodes() * 2 + 1); + // List should have been expanded twice. + GPR_ASSERT(queue.num_nodes() == queue.init_num_nodes() * 4); + for (int i = 0; i < queue.init_num_nodes() * 2 + 1; ++i) { WorkItem* item = static_cast(queue.Get()); grpc_core::Delete(item); } GPR_ASSERT(queue.count() == 0); - GPR_ASSERT(queue.num_node() == 4096); + GPR_ASSERT(queue.num_nodes() == queue.init_num_nodes() * 4); gpr_log(GPR_DEBUG, "Done."); } From 8b3da5a69863c62b1358b5d8a02d27bd3483733c Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Tue, 23 Jul 2019 18:49:15 -0700 Subject: [PATCH 0975/1555] Adopted the Bazel way of import + quick fix on Swift sample --- .../project.pbxproj | 48 +- .../RemoteTestClient/RemoteTest.podspec | 16 +- .../Sample/Sample.xcodeproj/project.pbxproj | 34 +- .../examples/Sample/Sample/ViewController.m | 4 +- src/objective-c/examples/SwiftSample/Podfile | 2 +- .../examples/SwiftSample/RemoteTest.podspec | 55 +++ .../SwiftSample.xcodeproj/project.pbxproj | 65 ++- .../examples/SwiftSample/messages.proto | 118 +++++ .../examples/SwiftSample/test.proto | 57 +++ .../tests/InteropTests/InteropTests.m | 6 +- .../InteropTestsMultipleChannels.m | 6 +- src/objective-c/tests/MacTests/StressTests.m | 6 +- .../tests/RemoteTestClient/RemoteTest.podspec | 12 +- .../tests/RemoteTestClient/test.proto | 2 +- .../tests/Tests.xcodeproj/project.pbxproj | 417 ++++++------------ src/objective-c/tests/UnitTests/APIv2Tests.m | 2 +- .../tests/UnitTests/GRPCClientTests.m | 2 +- 17 files changed, 454 insertions(+), 398 deletions(-) create mode 100644 src/objective-c/examples/SwiftSample/RemoteTest.podspec create mode 100644 src/objective-c/examples/SwiftSample/messages.proto create mode 100644 src/objective-c/examples/SwiftSample/test.proto diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj b/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj index f3388fc2a84..840f9760879 100644 --- a/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj @@ -3,10 +3,11 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 51; objects = { /* Begin PBXBuildFile section */ + 4182FA3FC32428BA5E84C311 /* libPods-InterceptorSample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 48F0BD18AEBB640DE5E58D79 /* libPods-InterceptorSample.a */; }; 5EE960FB2266768A0044A74F /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE960FA2266768A0044A74F /* AppDelegate.m */; }; 5EE960FE2266768A0044A74F /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE960FD2266768A0044A74F /* ViewController.m */; }; 5EE961012266768A0044A74F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5EE960FF2266768A0044A74F /* Main.storyboard */; }; @@ -14,11 +15,10 @@ 5EE961062266768C0044A74F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5EE961042266768C0044A74F /* LaunchScreen.storyboard */; }; 5EE961092266768C0044A74F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE961082266768C0044A74F /* main.m */; }; 5EE9611222668CF20044A74F /* CacheInterceptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE9611122668CF20044A74F /* CacheInterceptor.m */; }; - B39AA5EDA7B541C915C1D823 /* libPods-InterceptorSample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EE3A6DB9460D83EFDECDEF27 /* libPods-InterceptorSample.a */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 53E7AEA20F8F0F23BFC5E85A /* Pods-InterceptorSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InterceptorSample.release.xcconfig"; path = "Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample.release.xcconfig"; sourceTree = ""; }; + 48F0BD18AEBB640DE5E58D79 /* libPods-InterceptorSample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InterceptorSample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 5EE960F62266768A0044A74F /* InterceptorSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = InterceptorSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 5EE960FA2266768A0044A74F /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 5EE960FC2266768A0044A74F /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; @@ -31,8 +31,8 @@ 5EE9610F2266774C0044A74F /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 5EE9611022668CE20044A74F /* CacheInterceptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CacheInterceptor.h; sourceTree = ""; }; 5EE9611122668CF20044A74F /* CacheInterceptor.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CacheInterceptor.m; sourceTree = ""; }; - 61819C78C7CC39640B0AF90B /* Pods-InterceptorSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InterceptorSample.debug.xcconfig"; path = "Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample.debug.xcconfig"; sourceTree = ""; }; - EE3A6DB9460D83EFDECDEF27 /* libPods-InterceptorSample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InterceptorSample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 64B0278876AF54F8F95EDDCE /* Pods-InterceptorSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InterceptorSample.release.xcconfig"; path = "Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample.release.xcconfig"; sourceTree = ""; }; + 6637EF5BBDFE0FFD47D9EAE7 /* Pods-InterceptorSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InterceptorSample.debug.xcconfig"; path = "Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -40,28 +40,20 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - B39AA5EDA7B541C915C1D823 /* libPods-InterceptorSample.a in Frameworks */, + 4182FA3FC32428BA5E84C311 /* libPods-InterceptorSample.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 5DBBA8A4C272D71DA0B942A2 /* Frameworks */ = { - isa = PBXGroup; - children = ( - EE3A6DB9460D83EFDECDEF27 /* libPods-InterceptorSample.a */, - ); - name = Frameworks; - sourceTree = ""; - }; 5EE960ED2266768A0044A74F = { isa = PBXGroup; children = ( 5EE960F82266768A0044A74F /* InterceptorSample */, 5EE960F72266768A0044A74F /* Products */, 9D49DB75F3BEDAFDE7028B51 /* Pods */, - 5DBBA8A4C272D71DA0B942A2 /* Frameworks */, + A48ECC1BD9AFC8D93ECD2467 /* Frameworks */, ); sourceTree = ""; }; @@ -94,12 +86,20 @@ 9D49DB75F3BEDAFDE7028B51 /* Pods */ = { isa = PBXGroup; children = ( - 61819C78C7CC39640B0AF90B /* Pods-InterceptorSample.debug.xcconfig */, - 53E7AEA20F8F0F23BFC5E85A /* Pods-InterceptorSample.release.xcconfig */, + 6637EF5BBDFE0FFD47D9EAE7 /* Pods-InterceptorSample.debug.xcconfig */, + 64B0278876AF54F8F95EDDCE /* Pods-InterceptorSample.release.xcconfig */, ); path = Pods; sourceTree = ""; }; + A48ECC1BD9AFC8D93ECD2467 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 48F0BD18AEBB640DE5E58D79 /* libPods-InterceptorSample.a */, + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -107,11 +107,11 @@ isa = PBXNativeTarget; buildConfigurationList = 5EE9610C2266768C0044A74F /* Build configuration list for PBXNativeTarget "InterceptorSample" */; buildPhases = ( - 6313E891EAC080560B6D470D /* [CP] Check Pods Manifest.lock */, + 471EAA5F4DD4F2A125B3488B /* [CP] Check Pods Manifest.lock */, 5EE960F22266768A0044A74F /* Sources */, 5EE960F32266768A0044A74F /* Frameworks */, 5EE960F42266768A0044A74F /* Resources */, - A3ABCCE79BCEB8687DE0D995 /* [CP] Copy Pods Resources */, + 77C5553636C977821737C752 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -168,7 +168,7 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 6313E891EAC080560B6D470D /* [CP] Check Pods Manifest.lock */ = { + 471EAA5F4DD4F2A125B3488B /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -190,7 +190,7 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - A3ABCCE79BCEB8687DE0D995 /* [CP] Copy Pods Resources */ = { + 77C5553636C977821737C752 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -357,7 +357,7 @@ }; 5EE9610D2266768C0044A74F /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 61819C78C7CC39640B0AF90B /* Pods-InterceptorSample.debug.xcconfig */; + baseConfigurationReference = 6637EF5BBDFE0FFD47D9EAE7 /* Pods-InterceptorSample.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; @@ -369,12 +369,13 @@ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InterceptorSample; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = ""; }; name = Debug; }; 5EE9610E2266768C0044A74F /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 53E7AEA20F8F0F23BFC5E85A /* Pods-InterceptorSample.release.xcconfig */; + baseConfigurationReference = 64B0278876AF54F8F95EDDCE /* Pods-InterceptorSample.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; @@ -386,6 +387,7 @@ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InterceptorSample; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = ""; }; name = Release; }; diff --git a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec index f6c2f91f16a..cf7e317be70 100644 --- a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec +++ b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec @@ -14,23 +14,20 @@ Pod::Spec.new do |s| s.dependency "!ProtoCompiler-gRPCPlugin" repo_root = '../../../..' - bin_dir = "bins/$CONFIG" + bin_dir = "#{repo_root}/bins/$CONFIG" protoc = "#{bin_dir}/protobuf/protoc" - well_known_types_dir = "third_party/protobuf/src" + well_known_types_dir = "#{repo_root}/third_party/protobuf/src" plugin = "#{bin_dir}/grpc_objective_c_plugin" - out_dir = "src/objective-c/examples/RemoteTestClient" s.prepare_command = <<-CMD - pushd #{repo_root} #{protoc} \ --plugin=protoc-gen-grpc=#{plugin} \ - --objc_out=#{out_dir} \ - --grpc_out=#{out_dir} \ - -I . \ + --objc_out=. \ + --grpc_out=. \ + -I #{repo_root} \ -I #{well_known_types_dir} \ - #{out_dir}/*.proto - popd + #{repo_root}/src/objective-c/examples/RemoteTestClient/*.proto CMD s.subspec 'Messages' do |ms| @@ -54,4 +51,5 @@ Pod::Spec.new do |s| # This is needed by all pods that depend on gRPC-RxLibrary: 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES', } + end diff --git a/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj b/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj index cdd1c6c8f7e..33bdc378165 100644 --- a/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj @@ -7,12 +7,12 @@ objects = { /* Begin PBXBuildFile section */ - 3F035697392F601049D3DDE1 /* Pods_Sample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC1B27EA0C428429B07BC34B /* Pods_Sample.framework */; }; 6369A2701A9322E20015FC5C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6369A26F1A9322E20015FC5C /* main.m */; }; 6369A2731A9322E20015FC5C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6369A2721A9322E20015FC5C /* AppDelegate.m */; }; 6369A2761A9322E20015FC5C /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6369A2751A9322E20015FC5C /* ViewController.m */; }; 6369A2791A9322E20015FC5C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6369A2771A9322E20015FC5C /* Main.storyboard */; }; 6369A27B1A9322E20015FC5C /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6369A27A1A9322E20015FC5C /* Images.xcassets */; }; + C8B8323DA07AC8C4499DC557 /* libPods-Sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A874B5E91AC811A1EA0D12CF /* libPods-Sample.a */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -26,7 +26,7 @@ 6369A2751A9322E20015FC5C /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 6369A2781A9322E20015FC5C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 6369A27A1A9322E20015FC5C /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; - CC1B27EA0C428429B07BC34B /* Pods_Sample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Sample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + A874B5E91AC811A1EA0D12CF /* libPods-Sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; E3C01DF315C4E7433BCEC6E6 /* Pods-Sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -35,7 +35,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 3F035697392F601049D3DDE1 /* Pods_Sample.framework in Frameworks */, + C8B8323DA07AC8C4499DC557 /* libPods-Sample.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -95,7 +95,7 @@ C4C2C5219053E079C9EFB930 /* Frameworks */ = { isa = PBXGroup; children = ( - CC1B27EA0C428429B07BC34B /* Pods_Sample.framework */, + A874B5E91AC811A1EA0D12CF /* libPods-Sample.a */, ); name = Frameworks; sourceTree = ""; @@ -112,7 +112,6 @@ 6369A2671A9322E20015FC5C /* Frameworks */, 6369A2681A9322E20015FC5C /* Resources */, 04554623324BE4A838846086 /* [CP] Copy Pods Resources */, - C7FAD018D05AB5F0B0FE81E2 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -174,13 +173,16 @@ files = ( ); inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Sample/Pods-Sample-resources.sh", + "${PODS_CONFIGURATION_BUILD_DIR}/gRPC/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; outputPaths = ( + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Sample/Pods-Sample-resources.sh\"\n"; showEnvVarsInLog = 0; }; 41F7486D8F66994B0BFB84AF /* [CP] Check Pods Manifest.lock */ = { @@ -189,28 +191,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Sample-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; - showEnvVarsInLog = 0; - }; - C7FAD018D05AB5F0B0FE81E2 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ diff --git a/src/objective-c/examples/Sample/Sample/ViewController.m b/src/objective-c/examples/Sample/Sample/ViewController.m index 9bcb002027b..2171a923d79 100644 --- a/src/objective-c/examples/Sample/Sample/ViewController.m +++ b/src/objective-c/examples/Sample/Sample/ViewController.m @@ -20,8 +20,8 @@ #import #import -#import -#import +#import "src/objective-c/examples/RemoteTestClient/Messages.pbobjc.h" +#import "src/objective-c/examples/RemoteTestClient/Test.pbrpc.h" #import #import diff --git a/src/objective-c/examples/SwiftSample/Podfile b/src/objective-c/examples/SwiftSample/Podfile index 8214371bc59..01ef90696ca 100644 --- a/src/objective-c/examples/SwiftSample/Podfile +++ b/src/objective-c/examples/SwiftSample/Podfile @@ -10,7 +10,7 @@ GRPC_LOCAL_SRC = '../../../..' target 'SwiftSample' do # Depend on the generated RemoteTestClient library - pod 'RemoteTest', :path => "../RemoteTestClient" + pod 'RemoteTest', :path => "." # Use the local versions of Protobuf, BoringSSL, and gRPC. You don't need any of the following # lines in your application. diff --git a/src/objective-c/examples/SwiftSample/RemoteTest.podspec b/src/objective-c/examples/SwiftSample/RemoteTest.podspec new file mode 100644 index 00000000000..e5f910c82d0 --- /dev/null +++ b/src/objective-c/examples/SwiftSample/RemoteTest.podspec @@ -0,0 +1,55 @@ +Pod::Spec.new do |s| + s.name = 'RemoteTest' + s.version = '0.0.1' + s.license = 'Apache License, Version 2.0' + s.authors = { 'gRPC contributors' => 'grpc-io@googlegroups.com' } + s.homepage = 'https://grpc.io/' + s.summary = 'RemoteTest example' + s.source = { :git => 'https://github.com/grpc/grpc.git' } + + s.ios.deployment_target = '7.1' + s.osx.deployment_target = '10.9' + + # Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients. + s.dependency "!ProtoCompiler-gRPCPlugin" + + repo_root = '../../../..' + bin_dir = "#{repo_root}/bins/$CONFIG" + + protoc = "#{bin_dir}/protobuf/protoc" + well_known_types_dir = "#{repo_root}/third_party/protobuf/src" + plugin = "#{bin_dir}/grpc_objective_c_plugin" + + s.prepare_command = <<-CMD + #{protoc} \ + --plugin=protoc-gen-grpc=#{plugin} \ + --objc_out=. \ + --grpc_out=. \ + -I . \ + -I #{well_known_types_dir} \ + *.proto + CMD + + s.subspec 'Messages' do |ms| + ms.source_files = '**/*.pbobjc.{h,m}' + ms.header_mappings_dir = '.' + ms.requires_arc = false + ms.dependency 'Protobuf' + end + + s.subspec 'Services' do |ss| + ss.source_files = '**/*.pbrpc.{h,m}' + ss.header_mappings_dir = '.' + ss.requires_arc = true + ss.dependency 'gRPC-ProtoRPC' + ss.dependency "#{s.name}/Messages" + end + + s.pod_target_xcconfig = { + # This is needed by all pods that depend on Protobuf: + 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1', + # This is needed by all pods that depend on gRPC-RxLibrary: + 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES', + } + +end diff --git a/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj b/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj index 0113d9c5d6a..ec8883456e4 100644 --- a/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj @@ -7,7 +7,7 @@ objects = { /* Begin PBXBuildFile section */ - 2C0B024CB798839E17F76126 /* Pods_SwiftSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B394F343BDE186C5436DBDB9 /* Pods_SwiftSample.framework */; }; + 2A4D33FC1BAD9EE77F27E82F /* Pods_SwiftSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D24BFC7BA3339DF6B9A04EF /* Pods_SwiftSample.framework */; }; 633BFFC81B950B210007E424 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 633BFFC71B950B210007E424 /* AppDelegate.swift */; }; 633BFFCA1B950B210007E424 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 633BFFC91B950B210007E424 /* ViewController.swift */; }; 633BFFCD1B950B210007E424 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 633BFFCB1B950B210007E424 /* Main.storyboard */; }; @@ -21,9 +21,9 @@ 633BFFC91B950B210007E424 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 633BFFCC1B950B210007E424 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 633BFFCE1B950B210007E424 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; - A7E614A494D89D01BB395761 /* Pods-SwiftSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftSample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SwiftSample/Pods-SwiftSample.debug.xcconfig"; sourceTree = ""; }; - B394F343BDE186C5436DBDB9 /* Pods_SwiftSample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftSample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - C314E3E246AF23AC29B38FCF /* Pods-SwiftSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftSample.release.xcconfig"; path = "Pods/Target Support Files/Pods-SwiftSample/Pods-SwiftSample.release.xcconfig"; sourceTree = ""; }; + 7AD632A1760ED763C0BFFD0A /* Pods-SwiftSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftSample.release.xcconfig"; path = "Target Support Files/Pods-SwiftSample/Pods-SwiftSample.release.xcconfig"; sourceTree = ""; }; + 7D24BFC7BA3339DF6B9A04EF /* Pods_SwiftSample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftSample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + D6F1AAEB4FD0559A16605616 /* Pods-SwiftSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftSample.debug.xcconfig"; path = "Target Support Files/Pods-SwiftSample/Pods-SwiftSample.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -31,20 +31,21 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 2C0B024CB798839E17F76126 /* Pods_SwiftSample.framework in Frameworks */, + 2A4D33FC1BAD9EE77F27E82F /* Pods_SwiftSample.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 31F283C976AE97586C17CCD9 /* Pods */ = { + 3C394733A73BFFE2995E6DC5 /* Pods */ = { isa = PBXGroup; children = ( - A7E614A494D89D01BB395761 /* Pods-SwiftSample.debug.xcconfig */, - C314E3E246AF23AC29B38FCF /* Pods-SwiftSample.release.xcconfig */, + D6F1AAEB4FD0559A16605616 /* Pods-SwiftSample.debug.xcconfig */, + 7AD632A1760ED763C0BFFD0A /* Pods-SwiftSample.release.xcconfig */, ); name = Pods; + path = Pods; sourceTree = ""; }; 633BFFB91B950B210007E424 = { @@ -52,8 +53,8 @@ children = ( 633BFFC41B950B210007E424 /* SwiftSample */, 633BFFC31B950B210007E424 /* Products */, - 31F283C976AE97586C17CCD9 /* Pods */, - 9D63A7F6423989BA306810CA /* Frameworks */, + 3C394733A73BFFE2995E6DC5 /* Pods */, + B3B46435EDEAE7572BF484F5 /* Frameworks */, ); sourceTree = ""; }; @@ -85,10 +86,10 @@ name = "Supporting Files"; sourceTree = ""; }; - 9D63A7F6423989BA306810CA /* Frameworks */ = { + B3B46435EDEAE7572BF484F5 /* Frameworks */ = { isa = PBXGroup; children = ( - B394F343BDE186C5436DBDB9 /* Pods_SwiftSample.framework */, + 7D24BFC7BA3339DF6B9A04EF /* Pods_SwiftSample.framework */, ); name = Frameworks; sourceTree = ""; @@ -100,12 +101,11 @@ isa = PBXNativeTarget; buildConfigurationList = 633BFFE11B950B210007E424 /* Build configuration list for PBXNativeTarget "SwiftSample" */; buildPhases = ( - 6BEEB33CA2705D7D2F2210E6 /* [CP] Check Pods Manifest.lock */, + 0BCFE5CC859FA15414AF3B5A /* [CP] Check Pods Manifest.lock */, 633BFFBE1B950B210007E424 /* Sources */, 633BFFBF1B950B210007E424 /* Frameworks */, 633BFFC01B950B210007E424 /* Resources */, - AC2F6F9AB1C090BB0BEE6E4D /* [CP] Copy Pods Resources */, - A1738A987353B0BF2C64F0F7 /* [CP] Embed Pods Frameworks */, + 6998570BEA68700C0183464C /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -162,16 +162,20 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 6BEEB33CA2705D7D2F2210E6 /* [CP] Check Pods Manifest.lock */ = { + 0BCFE5CC859FA15414AF3B5A /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); + inputFileListPaths = ( + ); inputPaths = ( "${PODS_PODFILE_DIR_PATH}/Podfile.lock", "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); outputPaths = ( "$(DERIVED_FILE_DIR)/Pods-SwiftSample-checkManifestLockResult.txt", ); @@ -180,14 +184,14 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - A1738A987353B0BF2C64F0F7 /* [CP] Embed Pods Frameworks */ = { + 6998570BEA68700C0183464C /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-SwiftSample/Pods-SwiftSample-frameworks.sh", - "${BUILT_PRODUCTS_DIR}/BoringSSL/openssl.framework", + "${PODS_ROOT}/Target Support Files/Pods-SwiftSample/Pods-SwiftSample-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/BoringSSL-GRPC/openssl_grpc.framework", "${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework", "${BUILT_PRODUCTS_DIR}/RemoteTest/RemoteTest.framework", "${BUILT_PRODUCTS_DIR}/gRPC/GRPCClient.framework", @@ -198,7 +202,7 @@ ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/openssl.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/openssl_grpc.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RemoteTest.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GRPCClient.framework", @@ -209,22 +213,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwiftSample/Pods-SwiftSample-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - AC2F6F9AB1C090BB0BEE6E4D /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwiftSample/Pods-SwiftSample-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-SwiftSample/Pods-SwiftSample-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -341,7 +330,7 @@ }; 633BFFE21B950B210007E424 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = A7E614A494D89D01BB395761 /* Pods-SwiftSample.debug.xcconfig */; + baseConfigurationReference = D6F1AAEB4FD0559A16605616 /* Pods-SwiftSample.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Info.plist; @@ -356,7 +345,7 @@ }; 633BFFE31B950B210007E424 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = C314E3E246AF23AC29B38FCF /* Pods-SwiftSample.release.xcconfig */; + baseConfigurationReference = 7AD632A1760ED763C0BFFD0A /* Pods-SwiftSample.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Info.plist; diff --git a/src/objective-c/examples/SwiftSample/messages.proto b/src/objective-c/examples/SwiftSample/messages.proto new file mode 100644 index 00000000000..128efd9337e --- /dev/null +++ b/src/objective-c/examples/SwiftSample/messages.proto @@ -0,0 +1,118 @@ +// Copyright 2015 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Message definitions to be used by integration test service definitions. + +syntax = "proto3"; + +package grpc.testing; + +option objc_class_prefix = "RMT"; + +// The type of payload that should be returned. +enum PayloadType { + // Compressable text format. + COMPRESSABLE = 0; + + // Uncompressable binary format. + UNCOMPRESSABLE = 1; + + // Randomly chosen from all other formats defined in this enum. + RANDOM = 2; +} + +// A block of data, to simply increase gRPC message size. +message Payload { + // The type of data in body. + PayloadType type = 1; + // Primary contents of payload. + bytes body = 2; +} + +// Unary request. +message SimpleRequest { + // Desired payload type in the response from the server. + // If response_type is RANDOM, server randomly chooses one from other formats. + PayloadType response_type = 1; + + // Desired payload size in the response from the server. + // If response_type is COMPRESSABLE, this denotes the size before compression. + int32 response_size = 2; + + // Optional input payload sent along with the request. + Payload payload = 3; + + // Whether SimpleResponse should include username. + bool fill_username = 4; + + // Whether SimpleResponse should include OAuth scope. + bool fill_oauth_scope = 5; +} + +// Unary response, as configured by the request. +message SimpleResponse { + // Payload to increase message size. + Payload payload = 1; + // The user the request came from, for verifying authentication was + // successful when the client expected it. + string username = 2; + // OAuth scope. + string oauth_scope = 3; +} + +// Client-streaming request. +message StreamingInputCallRequest { + // Optional input payload sent along with the request. + Payload payload = 1; + + // Not expecting any payload from the response. +} + +// Client-streaming response. +message StreamingInputCallResponse { + // Aggregated size of payloads received from the client. + int32 aggregated_payload_size = 1; +} + +// Configuration for a particular response. +message ResponseParameters { + // Desired payload sizes in responses from the server. + // If response_type is COMPRESSABLE, this denotes the size before compression. + int32 size = 1; + + // Desired interval between consecutive responses in the response stream in + // microseconds. + int32 interval_us = 2; +} + +// Server-streaming request. +message StreamingOutputCallRequest { + // Desired payload type in the response from the server. + // If response_type is RANDOM, the payload from each response in the stream + // might be of different types. This is to simulate a mixed type of payload + // stream. + PayloadType response_type = 1; + + // Configuration for each expected response message. + repeated ResponseParameters response_parameters = 2; + + // Optional input payload sent along with the request. + Payload payload = 3; +} + +// Server-streaming response, as configured by the request and parameters. +message StreamingOutputCallResponse { + // Payload to increase response size. + Payload payload = 1; +} diff --git a/src/objective-c/examples/SwiftSample/test.proto b/src/objective-c/examples/SwiftSample/test.proto new file mode 100644 index 00000000000..c5696043630 --- /dev/null +++ b/src/objective-c/examples/SwiftSample/test.proto @@ -0,0 +1,57 @@ +// Copyright 2015 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// An integration test service that covers all the method signature permutations +// of unary/streaming requests/responses. +syntax = "proto3"; + +import "google/protobuf/empty.proto"; +import "messages.proto"; + +package grpc.testing; + +option objc_class_prefix = "RMT"; + +// A simple service to test the various types of RPCs and experiment with +// performance with various types of payload. +service TestService { + // One empty request followed by one empty response. + rpc EmptyCall(google.protobuf.Empty) returns (google.protobuf.Empty); + + // One request followed by one response. + rpc UnaryCall(SimpleRequest) returns (SimpleResponse); + + // One request followed by a sequence of responses (streamed download). + // The server returns the payload with client desired type and sizes. + rpc StreamingOutputCall(StreamingOutputCallRequest) + returns (stream StreamingOutputCallResponse); + + // A sequence of requests followed by one response (streamed upload). + // The server returns the aggregated size of client payload as the result. + rpc StreamingInputCall(stream StreamingInputCallRequest) + returns (StreamingInputCallResponse); + + // A sequence of requests with each request served by the server immediately. + // As one request could lead to multiple responses, this interface + // demonstrates the idea of full duplexing. + rpc FullDuplexCall(stream StreamingOutputCallRequest) + returns (stream StreamingOutputCallResponse); + + // A sequence of requests followed by a sequence of responses. + // The server buffers all the client requests and then serves them in order. A + // stream of responses are returned to the client when the server starts with + // first request. + rpc HalfDuplexCall(stream StreamingOutputCallRequest) + returns (stream StreamingOutputCallResponse); +} diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 3260e918f2f..ae5651651e0 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -30,9 +30,9 @@ #import #import #import -#import -#import -#import +#import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" +#import "src/objective-c/tests/RemoteTestClient/Test.pbobjc.h" +#import "src/objective-c/tests/RemoteTestClient/Test.pbrpc.h" #import #import #import diff --git a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m index 14ba2871aa2..44bd5ab3924 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m +++ b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m @@ -21,9 +21,9 @@ #ifdef GRPC_COMPILE_WITH_CRONET #import #endif -#import -#import -#import +#import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" +#import "src/objective-c/tests/RemoteTestClient/Test.pbobjc.h" +#import "src/objective-c/tests/RemoteTestClient/Test.pbrpc.h" #import #import "../ConfigureCronet.h" diff --git a/src/objective-c/tests/MacTests/StressTests.m b/src/objective-c/tests/MacTests/StressTests.m index 3c6ecd52610..8421d48e108 100644 --- a/src/objective-c/tests/MacTests/StressTests.m +++ b/src/objective-c/tests/MacTests/StressTests.m @@ -21,9 +21,9 @@ #import #import #import -#import -#import -#import +#import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" +#import "src/objective-c/tests/RemoteTestClient/Test.pbobjc.h" +#import "src/objective-c/tests/RemoteTestClient/Test.pbrpc.h" #import #import #import diff --git a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec index 93b56d56059..60727d4d94e 100644 --- a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec +++ b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec @@ -27,9 +27,9 @@ Pod::Spec.new do |s| --plugin=protoc-gen-grpc=#{plugin} \ --objc_out=. \ --grpc_out=. \ - -I . \ + -I #{repo_root} \ -I #{well_known_types_dir} \ - *.proto + #{repo_root}/src/objective-c/tests/RemoteTestClient/*.proto else # protoc was not found bin_dir, use installed version instead (>&2 echo "\nWARNING: Using installed version of protoc. It might be incompatible with gRPC") @@ -38,21 +38,21 @@ Pod::Spec.new do |s| --plugin=protoc-gen-grpc=#{plugin} \ --objc_out=. \ --grpc_out=. \ - -I . \ + -I #{repo_root} \ -I #{well_known_types_dir} \ - *.proto + #{repo_root}/src/objective-c/tests/RemoteTestClient/*.proto fi CMD s.subspec "Messages" do |ms| - ms.source_files = "*.pbobjc.{h,m}" + ms.source_files = "**/*.pbobjc.{h,m}" ms.header_mappings_dir = "." ms.requires_arc = false ms.dependency "Protobuf" end s.subspec "Services" do |ss| - ss.source_files = "*.pbrpc.{h,m}" + ss.source_files = "**/*.pbrpc.{h,m}" ss.header_mappings_dir = "." ss.requires_arc = true ss.dependency "gRPC-ProtoRPC" diff --git a/src/objective-c/tests/RemoteTestClient/test.proto b/src/objective-c/tests/RemoteTestClient/test.proto index c5696043630..6931600edc0 100644 --- a/src/objective-c/tests/RemoteTestClient/test.proto +++ b/src/objective-c/tests/RemoteTestClient/test.proto @@ -17,7 +17,7 @@ syntax = "proto3"; import "google/protobuf/empty.proto"; -import "messages.proto"; +import "src/objective-c/tests/RemoteTestClient/messages.proto"; package grpc.testing; diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index 737d52b547d..578970f4271 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 01574004C238BE75F6A7651D /* libPods-MacTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B6E36AF835D0DC279DC0C18 /* libPods-MacTests.a */; }; + 3E8DD339E611E92DCE8A5A48 /* libPods-CronetTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2067DD4BEA93EFB61A753183 /* libPods-CronetTests.a */; }; 5E0282E9215AA697007AC99D /* NSErrorUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E0282E8215AA697007AC99D /* NSErrorUnitTests.m */; }; 5E3F14842278B461007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; 5E3F14852278BF5D007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; @@ -34,62 +36,24 @@ 5EA4770322736178000F72FC /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; 5EA477042273617B000F72FC /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; 5EA4770522736AC4000F72FC /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; - 65EB19E418B39A8374D407BB /* libPods-CronetTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B1511C20E16A8422B58D61A /* libPods-CronetTests.a */; }; - 903163C7FE885838580AEC7A /* libPods-InteropTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D457AD9797664CFA191C3280 /* libPods-InteropTests.a */; }; - 953CD2942A3A6D6CE695BE87 /* libPods-MacTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 276873A05AC5479B60DF6079 /* libPods-MacTests.a */; }; + 80EA8F48AFAA5E3D758AC3D5 /* libPods-UnitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2D4287E190CCD0CACC3F2CC3 /* libPods-UnitTests.a */; }; B071230B22669EED004B64A1 /* StressTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B071230A22669EED004B64A1 /* StressTests.m */; }; B0BB3F08225E7ABA008DA580 /* NSErrorUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E0282E8215AA697007AC99D /* NSErrorUnitTests.m */; }; B0BB3F0A225EA511008DA580 /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; B0D39B9A2266F3CB00A4078D /* StressTestsSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D39B992266F3CB00A4078D /* StressTestsSSL.m */; }; B0D39B9C2266FF9800A4078D /* StressTestsCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D39B9B2266FF9800A4078D /* StressTestsCleartext.m */; }; - CCF5C0719EF608276AE16374 /* libPods-UnitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 22A3EBB488699C8CEA19707B /* libPods-UnitTests.a */; }; + C8217D49007E8E4693F058B1 /* libPods-InteropTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DD0F486470BDFF1E1E4943B8 /* libPods-InteropTests.a */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 02192CF1FF9534E3D18C65FC /* Pods-CronetUnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetUnitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests.release.xcconfig"; sourceTree = ""; }; - 070266E2626EB997B54880A3 /* Pods-InteropTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTests/Pods-InteropTests.test.xcconfig"; sourceTree = ""; }; - 07D10A965323BEA7FE59A74B /* Pods-RxLibraryUnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.debug.xcconfig"; sourceTree = ""; }; - 0A4F89D9C90E9C30990218F0 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; - 0BDA4BA011779D5D25B5618C /* libPods-InteropTestsLocalCleartextCFStream.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalCleartextCFStream.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 0D2284C3DF7E57F0ED504E39 /* Pods-CoreCronetEnd2EndTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CoreCronetEnd2EndTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests.debug.xcconfig"; sourceTree = ""; }; - 1286B30AD74CB64CD91FB17D /* Pods-APIv2Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIv2Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests.debug.xcconfig"; sourceTree = ""; }; - 1295CCBD1082B4A7CFCED95F /* Pods-InteropTestsMultipleChannels.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsMultipleChannels.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels.cronet.xcconfig"; sourceTree = ""; }; - 12B238CD1702393C2BA5DE80 /* Pods-APIv2Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIv2Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests.release.xcconfig"; sourceTree = ""; }; - 14B09A58FEE53A7A6B838920 /* Pods-InteropTestsLocalSSL.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.cronet.xcconfig"; sourceTree = ""; }; - 1588C85DEAF7FC0ACDEA4C02 /* Pods-InteropTestsLocalCleartext.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartext.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext.test.xcconfig"; sourceTree = ""; }; - 16A2E4C5839C83FBDA63881F /* Pods-MacTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MacTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-MacTests/Pods-MacTests.cronet.xcconfig"; sourceTree = ""; }; - 17F60BF2871F6AF85FB3FA12 /* Pods-InteropTestsRemoteWithCronet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.debug.xcconfig"; sourceTree = ""; }; - 1B1511C20E16A8422B58D61A /* libPods-CronetTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CronetTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 1E43EAE443CBB4482B1EB071 /* Pods-MacTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MacTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-MacTests/Pods-MacTests.release.xcconfig"; sourceTree = ""; }; - 1F5E788FBF9A4A06EB9E1ACD /* Pods-MacTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MacTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-MacTests/Pods-MacTests.test.xcconfig"; sourceTree = ""; }; - 20DFF2F3C97EF098FE5A3171 /* libPods-Tests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Tests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 20F6A3D59D0EE091E2D43953 /* Pods-CronetTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests.cronet.xcconfig"; sourceTree = ""; }; - 22A3EBB488699C8CEA19707B /* libPods-UnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-UnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 2650FEF00956E7924772F9D9 /* Pods-InteropTestsMultipleChannels.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsMultipleChannels.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels.release.xcconfig"; sourceTree = ""; }; - 276873A05AC5479B60DF6079 /* libPods-MacTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-MacTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 2B89F3037963E6EDDD48D8C3 /* Pods-InteropTestsRemoteWithCronet.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.test.xcconfig"; sourceTree = ""; }; - 303F4A17EB1650FC44603D17 /* Pods-InteropTestsRemoteCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream.release.xcconfig"; sourceTree = ""; }; - 32748C4078AEB05F8F954361 /* Pods-InteropTestsRemoteCFStream.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteCFStream.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream.debug.xcconfig"; sourceTree = ""; }; - 355D0E30AD224763BC9519F4 /* libPods-InteropTestsMultipleChannels.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsMultipleChannels.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 35F2B6BF3BAE8F0DC4AFD76E /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 386712AEACF7C2190C4B8B3F /* Pods-CronetUnitTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetUnitTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests.cronet.xcconfig"; sourceTree = ""; }; - 3A98DF08852F60AF1D96481D /* Pods-InteropTestsCallOptions.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsCallOptions.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions.debug.xcconfig"; sourceTree = ""; }; - 3B0861FC805389C52DB260D4 /* Pods-RxLibraryUnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.release.xcconfig"; sourceTree = ""; }; - 3CADF86203B9D03EA96C359D /* Pods-InteropTestsMultipleChannels.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsMultipleChannels.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels.debug.xcconfig"; sourceTree = ""; }; - 3EB55EF291706E3DDE23C3B7 /* Pods-InteropTestsLocalSSLCFStream.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.debug.xcconfig"; sourceTree = ""; }; - 3F27B2E744482771EB93C394 /* Pods-InteropTestsRemoteWithCronet.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.cronet.xcconfig"; sourceTree = ""; }; - 41AA59529240A6BBBD3DB904 /* Pods-InteropTestsLocalSSLCFStream.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.test.xcconfig"; sourceTree = ""; }; - 48F1841C9A920626995DC28C /* libPods-ChannelTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ChannelTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 4A1A42B2E941CCD453489E5B /* Pods-InteropTestsRemoteCFStream.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteCFStream.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream.cronet.xcconfig"; sourceTree = ""; }; - 4AD97096D13D7416DC91A72A /* Pods-CoreCronetEnd2EndTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CoreCronetEnd2EndTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests.release.xcconfig"; sourceTree = ""; }; - 4ADEA1C8BBE10D90940AC68E /* Pods-InteropTestsRemote.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemote.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote.cronet.xcconfig"; sourceTree = ""; }; - 51A275E86C141416ED63FF76 /* Pods-InteropTestsLocalCleartext.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartext.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext.release.xcconfig"; sourceTree = ""; }; - 51F2A64B7AADBA1B225B132E /* Pods-APIv2Tests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIv2Tests.test.xcconfig"; path = "Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests.test.xcconfig"; sourceTree = ""; }; - 553BBBED24E4162D1F769D65 /* Pods-InteropTestsLocalSSL.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.debug.xcconfig"; sourceTree = ""; }; - 55B630C1FF8C36D1EFC4E0A4 /* Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig"; sourceTree = ""; }; - 573450F334B331D0BED8B961 /* Pods-CoreCronetEnd2EndTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CoreCronetEnd2EndTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests.cronet.xcconfig"; sourceTree = ""; }; - 5761E98978DDDF136A58CB7E /* Pods-AllTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.release.xcconfig"; sourceTree = ""; }; - 5AB9A82F289D548D6B8816F9 /* Pods-CronetTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests.test.xcconfig"; sourceTree = ""; }; + 16B9B1262FE6FBFC353B62BB /* Pods-InteropTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.cronet.xcconfig"; path = "Target Support Files/Pods-InteropTests/Pods-InteropTests.cronet.xcconfig"; sourceTree = ""; }; + 2067DD4BEA93EFB61A753183 /* libPods-CronetTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CronetTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 2D4287E190CCD0CACC3F2CC3 /* libPods-UnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-UnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 42DF8A339EF81AFE13553D04 /* Pods-InteropTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.release.xcconfig"; path = "Target Support Files/Pods-InteropTests/Pods-InteropTests.release.xcconfig"; sourceTree = ""; }; + 4A76E027206C07B7DBECB301 /* Pods-UnitTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.cronet.xcconfig"; path = "Target Support Files/Pods-UnitTests/Pods-UnitTests.cronet.xcconfig"; sourceTree = ""; }; + 5287652093398BAA7C5A90E8 /* Pods-MacTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MacTests.release.xcconfig"; path = "Target Support Files/Pods-MacTests/Pods-MacTests.release.xcconfig"; sourceTree = ""; }; + 55BBF7900C93644CD8236BD2 /* Pods-CronetTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.test.xcconfig"; path = "Target Support Files/Pods-CronetTests/Pods-CronetTests.test.xcconfig"; sourceTree = ""; }; + 5CF07AAE0442D200BCD81ABC /* Pods-InteropTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.test.xcconfig"; path = "Target Support Files/Pods-InteropTests/Pods-InteropTests.test.xcconfig"; sourceTree = ""; }; 5E0282E6215AA697007AC99D /* UnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 5E0282E8215AA697007AC99D /* NSErrorUnitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NSErrorUnitTests.m; sourceTree = ""; }; 5E3F14822278B42D007C6D90 /* InteropTestsBlockCallbacks.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InteropTestsBlockCallbacks.h; sourceTree = ""; }; @@ -109,7 +73,6 @@ 5E7F488822778B04006656AD /* InteropTestsRemote.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InteropTestsRemote.m; sourceTree = ""; }; 5E7F488A22778B5D006656AD /* RxLibraryUnitTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RxLibraryUnitTests.m; sourceTree = ""; }; 5EA476F42272816A000F72FC /* InteropTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 5EA908CF4CDA4CE218352A06 /* Pods-InteropTestsLocalSSLCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.release.xcconfig"; sourceTree = ""; }; 5EAD6D261E27047400002378 /* CronetUnitTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = CronetUnitTests.mm; path = CronetTests/CronetUnitTests.mm; sourceTree = SOURCE_ROOT; }; 5EAFE8271F8EFB87007F2189 /* version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = version.h; sourceTree = ""; }; 5EE84BF31D4717E40050C6CC /* InteropTestsRemoteWithCronet.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = InteropTestsRemoteWithCronet.m; path = CronetTests/InteropTestsRemoteWithCronet.m; sourceTree = SOURCE_ROOT; }; @@ -117,66 +80,24 @@ 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = InteropTestsLocalCleartext.m; path = InteropTests/InteropTestsLocalCleartext.m; sourceTree = SOURCE_ROOT; }; 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = InteropTestsLocalSSL.m; path = InteropTests/InteropTestsLocalSSL.m; sourceTree = SOURCE_ROOT; }; 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = TestCertificates.bundle; sourceTree = ""; }; - 64F68A9A6A63CC930DD30A6E /* Pods-CronetUnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetUnitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests.debug.xcconfig"; sourceTree = ""; }; - 6793C9D019CB268C5BB491A2 /* Pods-CoreCronetEnd2EndTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CoreCronetEnd2EndTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests.test.xcconfig"; sourceTree = ""; }; - 680439AC2BC8761EDD54A1EA /* Pods-InteropTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTests/Pods-InteropTests.debug.xcconfig"; sourceTree = ""; }; - 73D2DF07027835BA0FB0B1C0 /* Pods-InteropTestsCallOptions.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsCallOptions.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions.cronet.xcconfig"; sourceTree = ""; }; - 781089FAE980F51F88A3BE0B /* Pods-RxLibraryUnitTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.test.xcconfig"; sourceTree = ""; }; - 79C68EFFCB5533475D810B79 /* Pods-RxLibraryUnitTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.cronet.xcconfig"; sourceTree = ""; }; - 7A2E97E3F469CC2A758D77DE /* Pods-InteropTestsLocalSSL.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.release.xcconfig"; sourceTree = ""; }; - 7BA53C6D224288D5870FE6F3 /* Pods-InteropTestsLocalCleartextCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.release.xcconfig"; sourceTree = ""; }; - 7F4F42EBAF311E9F84FCA32E /* Pods-CronetTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests.release.xcconfig"; sourceTree = ""; }; - 8B498B05C6DA0818B2FA91D4 /* Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig"; sourceTree = ""; }; - 8C233E85C3EB45B3CAE52EDF /* Pods-APIv2Tests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIv2Tests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests.cronet.xcconfig"; sourceTree = ""; }; - 90E63AD3C4A1E3E6BC745096 /* Pods-ChannelTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChannelTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests.cronet.xcconfig"; sourceTree = ""; }; - 943138072A9605B5B8DC1FC0 /* Pods-InteropTestsLocalCleartextCFStream.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.debug.xcconfig"; sourceTree = ""; }; - 94D7A5FAA13480E9A5166D7A /* Pods-UnitTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests.test.xcconfig"; sourceTree = ""; }; - 9E9444C764F0FFF64A7EB58E /* libPods-InteropTestsRemoteWithCronet.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsRemoteWithCronet.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - A25967A0D40ED14B3287AD81 /* Pods-InteropTestsCallOptions.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsCallOptions.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions.test.xcconfig"; sourceTree = ""; }; - A2DCF2570BE515B62CB924CA /* Pods-UnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests.debug.xcconfig"; sourceTree = ""; }; - A58BE6DF1C62D1739EBB2C78 /* libPods-RxLibraryUnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RxLibraryUnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - A6F832FCEFA6F6881E620F12 /* Pods-InteropTestsRemote.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemote.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote.test.xcconfig"; sourceTree = ""; }; - AA7CB64B4DD9915AE7C03163 /* Pods-InteropTestsLocalCleartext.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartext.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext.cronet.xcconfig"; sourceTree = ""; }; - AC414EF7A6BF76ED02B6E480 /* Pods-InteropTestsRemoteWithCronet.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.release.xcconfig"; sourceTree = ""; }; - AF3FC2CFFE7B0961823BC740 /* libPods-InteropTestsCallOptions.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsCallOptions.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 6B6E36AF835D0DC279DC0C18 /* libPods-MacTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-MacTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 7612BA4B2A55BC4F508570C2 /* Pods-MacTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MacTests.cronet.xcconfig"; path = "Target Support Files/Pods-MacTests/Pods-MacTests.cronet.xcconfig"; sourceTree = ""; }; + 936ADE0FD98D66144C935C37 /* Pods-UnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.debug.xcconfig"; path = "Target Support Files/Pods-UnitTests/Pods-UnitTests.debug.xcconfig"; sourceTree = ""; }; + 9AEB5A4889D2018866BE6050 /* Pods-CronetTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.debug.xcconfig"; path = "Target Support Files/Pods-CronetTests/Pods-CronetTests.debug.xcconfig"; sourceTree = ""; }; + 9E48AF01E76B19FAAAACAE23 /* Pods-UnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.release.xcconfig"; path = "Target Support Files/Pods-UnitTests/Pods-UnitTests.release.xcconfig"; sourceTree = ""; }; B071230A22669EED004B64A1 /* StressTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StressTests.m; sourceTree = ""; }; B0BB3EF7225E795F008DA580 /* MacTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MacTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; B0BB3EFB225E795F008DA580 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; B0C5FC172267C77200F192BE /* StressTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StressTests.h; sourceTree = ""; }; B0D39B992266F3CB00A4078D /* StressTestsSSL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StressTestsSSL.m; sourceTree = ""; }; B0D39B9B2266FF9800A4078D /* StressTestsCleartext.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StressTestsCleartext.m; sourceTree = ""; }; - B226619DC4E709E0FFFF94B8 /* Pods-CronetUnitTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetUnitTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests.test.xcconfig"; sourceTree = ""; }; - B6AD69CACF67505B0F028E92 /* libPods-APIv2Tests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-APIv2Tests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - B94C27C06733CF98CE1B2757 /* Pods-AllTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.debug.xcconfig"; sourceTree = ""; }; - BED74BC8ABF9917C66175879 /* Pods-ChannelTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChannelTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests.test.xcconfig"; sourceTree = ""; }; - C17F57E5BCB989AB1C2F1F25 /* Pods-InteropTestsRemoteCFStream.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteCFStream.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream.test.xcconfig"; sourceTree = ""; }; - C6134277D2EB8B380862A03F /* libPods-CronetUnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CronetUnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - C9172F9020E8C97A470D7250 /* Pods-InteropTestsCallOptions.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsCallOptions.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions.release.xcconfig"; sourceTree = ""; }; - CAE086D5B470DA367D415AB0 /* libPods-AllTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AllTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - CDF6CC70B8BF9D10EFE7D199 /* Pods-InteropTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTests/Pods-InteropTests.cronet.xcconfig"; sourceTree = ""; }; - D13BEC8181B8E678A1B52F54 /* Pods-InteropTestsLocalSSL.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.test.xcconfig"; sourceTree = ""; }; - D457AD9797664CFA191C3280 /* libPods-InteropTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - D52B92A7108602F170DA8091 /* Pods-ChannelTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChannelTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests.release.xcconfig"; sourceTree = ""; }; - DB1F4391AF69D20D38D74B67 /* Pods-AllTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.test.xcconfig"; sourceTree = ""; }; - DBE059B4AC7A51919467EEC0 /* libPods-InteropTestsRemote.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsRemote.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - DBEDE45BDA60DF1E1C8950C0 /* libPods-InteropTestsLocalSSL.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalSSL.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - DC3CA1D948F068E76957A861 /* Pods-InteropTestsRemote.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemote.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote.debug.xcconfig"; sourceTree = ""; }; - E1486220285AF123EB124008 /* Pods-InteropTestsLocalCleartext.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartext.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext.debug.xcconfig"; sourceTree = ""; }; - E1E7660656D902104F728892 /* Pods-UnitTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests.cronet.xcconfig"; sourceTree = ""; }; - E3ACD4D5902745976D9C2229 /* Pods-MacTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MacTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-MacTests/Pods-MacTests.debug.xcconfig"; sourceTree = ""; }; - E4275A759BDBDF143B9B438F /* Pods-InteropTestsRemote.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemote.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote.release.xcconfig"; sourceTree = ""; }; - E4FD4606D4AB8D5A314D72F0 /* Pods-InteropTestsLocalCleartextCFStream.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.test.xcconfig"; sourceTree = ""; }; - E7E4D3FD76E3B745D992AF5F /* Pods-AllTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.cronet.xcconfig"; sourceTree = ""; }; - EA8B122ACDE73E3AAA0E4A19 /* Pods-InteropTestsMultipleChannels.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsMultipleChannels.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels.test.xcconfig"; sourceTree = ""; }; - EBFFEC04B514CB0D4922DC40 /* Pods-UnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests.release.xcconfig"; sourceTree = ""; }; - EC66920112123D2DB1CB7F6C /* Pods-CronetTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests.debug.xcconfig"; sourceTree = ""; }; - F3AB031E0E26AC8EF30A2A2A /* libPods-InteropTestsLocalSSLCFStream.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalSSLCFStream.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - F44AC3F44E3491A8C0D890FE /* libPods-InteropTestsRemoteCFStream.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsRemoteCFStream.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - F6A7EECACBB4849DDD3F450A /* Pods-InteropTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTests/Pods-InteropTests.release.xcconfig"; sourceTree = ""; }; - F9E48EF5ACB1F38825171C5F /* Pods-ChannelTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChannelTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests.debug.xcconfig"; sourceTree = ""; }; - FBD98AC417B9882D32B19F28 /* libPods-CoreCronetEnd2EndTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CoreCronetEnd2EndTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - FD346DB2C23F676C4842F3FF /* libPods-InteropTestsLocalCleartext.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalCleartext.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - FF7B5489BCFE40111D768DD0 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; + B3C890A1E6F082CD283069BF /* Pods-UnitTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.test.xcconfig"; path = "Target Support Files/Pods-UnitTests/Pods-UnitTests.test.xcconfig"; sourceTree = ""; }; + B43404F2B37A38483BE4704A /* Pods-CronetTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.cronet.xcconfig"; path = "Target Support Files/Pods-CronetTests/Pods-CronetTests.cronet.xcconfig"; sourceTree = ""; }; + BC5D3F3B5B38B71CA279AF7F /* Pods-MacTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MacTests.debug.xcconfig"; path = "Target Support Files/Pods-MacTests/Pods-MacTests.debug.xcconfig"; sourceTree = ""; }; + C56A093740F31650ACDD9630 /* Pods-InteropTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.debug.xcconfig"; path = "Target Support Files/Pods-InteropTests/Pods-InteropTests.debug.xcconfig"; sourceTree = ""; }; + DA532DBBE1BC0DC8EC879FE1 /* Pods-MacTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MacTests.test.xcconfig"; path = "Target Support Files/Pods-MacTests/Pods-MacTests.test.xcconfig"; sourceTree = ""; }; + DD0F486470BDFF1E1E4943B8 /* libPods-InteropTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + FF0A4B1F995C18C1EB86D155 /* Pods-CronetTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.release.xcconfig"; path = "Target Support Files/Pods-CronetTests/Pods-CronetTests.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -184,7 +105,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - CCF5C0719EF608276AE16374 /* libPods-UnitTests.a in Frameworks */, + 80EA8F48AFAA5E3D758AC3D5 /* libPods-UnitTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -192,7 +113,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 65EB19E418B39A8374D407BB /* libPods-CronetTests.a in Frameworks */, + 3E8DD339E611E92DCE8A5A48 /* libPods-CronetTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -200,7 +121,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 903163C7FE885838580AEC7A /* libPods-InteropTests.a in Frameworks */, + C8217D49007E8E4693F058B1 /* libPods-InteropTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -208,7 +129,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 953CD2942A3A6D6CE695BE87 /* libPods-MacTests.a in Frameworks */, + 01574004C238BE75F6A7651D /* libPods-MacTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -219,116 +140,14 @@ isa = PBXGroup; children = ( 5E7F486622776AD8006656AD /* Cronet.framework */, - 35F2B6BF3BAE8F0DC4AFD76E /* libPods.a */, - CAE086D5B470DA367D415AB0 /* libPods-AllTests.a */, - FD346DB2C23F676C4842F3FF /* libPods-InteropTestsLocalCleartext.a */, - DBEDE45BDA60DF1E1C8950C0 /* libPods-InteropTestsLocalSSL.a */, - DBE059B4AC7A51919467EEC0 /* libPods-InteropTestsRemote.a */, - A58BE6DF1C62D1739EBB2C78 /* libPods-RxLibraryUnitTests.a */, - 20DFF2F3C97EF098FE5A3171 /* libPods-Tests.a */, - FBD98AC417B9882D32B19F28 /* libPods-CoreCronetEnd2EndTests.a */, - 9E9444C764F0FFF64A7EB58E /* libPods-InteropTestsRemoteWithCronet.a */, - C6134277D2EB8B380862A03F /* libPods-CronetUnitTests.a */, - F44AC3F44E3491A8C0D890FE /* libPods-InteropTestsRemoteCFStream.a */, - 0BDA4BA011779D5D25B5618C /* libPods-InteropTestsLocalCleartextCFStream.a */, - F3AB031E0E26AC8EF30A2A2A /* libPods-InteropTestsLocalSSLCFStream.a */, - 48F1841C9A920626995DC28C /* libPods-ChannelTests.a */, - 355D0E30AD224763BC9519F4 /* libPods-InteropTestsMultipleChannels.a */, - AF3FC2CFFE7B0961823BC740 /* libPods-InteropTestsCallOptions.a */, - 22A3EBB488699C8CEA19707B /* libPods-UnitTests.a */, - B6AD69CACF67505B0F028E92 /* libPods-APIv2Tests.a */, - 276873A05AC5479B60DF6079 /* libPods-MacTests.a */, - D457AD9797664CFA191C3280 /* libPods-InteropTests.a */, - 1B1511C20E16A8422B58D61A /* libPods-CronetTests.a */, + 2067DD4BEA93EFB61A753183 /* libPods-CronetTests.a */, + DD0F486470BDFF1E1E4943B8 /* libPods-InteropTests.a */, + 6B6E36AF835D0DC279DC0C18 /* libPods-MacTests.a */, + 2D4287E190CCD0CACC3F2CC3 /* libPods-UnitTests.a */, ); name = Frameworks; sourceTree = ""; }; - 51E4650F34F854F41FF053B3 /* Pods */ = { - isa = PBXGroup; - children = ( - FF7B5489BCFE40111D768DD0 /* Pods.debug.xcconfig */, - 0A4F89D9C90E9C30990218F0 /* Pods.release.xcconfig */, - B94C27C06733CF98CE1B2757 /* Pods-AllTests.debug.xcconfig */, - 5761E98978DDDF136A58CB7E /* Pods-AllTests.release.xcconfig */, - E1486220285AF123EB124008 /* Pods-InteropTestsLocalCleartext.debug.xcconfig */, - 51A275E86C141416ED63FF76 /* Pods-InteropTestsLocalCleartext.release.xcconfig */, - 553BBBED24E4162D1F769D65 /* Pods-InteropTestsLocalSSL.debug.xcconfig */, - 7A2E97E3F469CC2A758D77DE /* Pods-InteropTestsLocalSSL.release.xcconfig */, - DC3CA1D948F068E76957A861 /* Pods-InteropTestsRemote.debug.xcconfig */, - E4275A759BDBDF143B9B438F /* Pods-InteropTestsRemote.release.xcconfig */, - 07D10A965323BEA7FE59A74B /* Pods-RxLibraryUnitTests.debug.xcconfig */, - 3B0861FC805389C52DB260D4 /* Pods-RxLibraryUnitTests.release.xcconfig */, - 0D2284C3DF7E57F0ED504E39 /* Pods-CoreCronetEnd2EndTests.debug.xcconfig */, - 4AD97096D13D7416DC91A72A /* Pods-CoreCronetEnd2EndTests.release.xcconfig */, - 17F60BF2871F6AF85FB3FA12 /* Pods-InteropTestsRemoteWithCronet.debug.xcconfig */, - AC414EF7A6BF76ED02B6E480 /* Pods-InteropTestsRemoteWithCronet.release.xcconfig */, - E7E4D3FD76E3B745D992AF5F /* Pods-AllTests.cronet.xcconfig */, - 573450F334B331D0BED8B961 /* Pods-CoreCronetEnd2EndTests.cronet.xcconfig */, - AA7CB64B4DD9915AE7C03163 /* Pods-InteropTestsLocalCleartext.cronet.xcconfig */, - 14B09A58FEE53A7A6B838920 /* Pods-InteropTestsLocalSSL.cronet.xcconfig */, - 4ADEA1C8BBE10D90940AC68E /* Pods-InteropTestsRemote.cronet.xcconfig */, - 3F27B2E744482771EB93C394 /* Pods-InteropTestsRemoteWithCronet.cronet.xcconfig */, - 79C68EFFCB5533475D810B79 /* Pods-RxLibraryUnitTests.cronet.xcconfig */, - 64F68A9A6A63CC930DD30A6E /* Pods-CronetUnitTests.debug.xcconfig */, - 386712AEACF7C2190C4B8B3F /* Pods-CronetUnitTests.cronet.xcconfig */, - 02192CF1FF9534E3D18C65FC /* Pods-CronetUnitTests.release.xcconfig */, - DB1F4391AF69D20D38D74B67 /* Pods-AllTests.test.xcconfig */, - 6793C9D019CB268C5BB491A2 /* Pods-CoreCronetEnd2EndTests.test.xcconfig */, - B226619DC4E709E0FFFF94B8 /* Pods-CronetUnitTests.test.xcconfig */, - 1588C85DEAF7FC0ACDEA4C02 /* Pods-InteropTestsLocalCleartext.test.xcconfig */, - D13BEC8181B8E678A1B52F54 /* Pods-InteropTestsLocalSSL.test.xcconfig */, - A6F832FCEFA6F6881E620F12 /* Pods-InteropTestsRemote.test.xcconfig */, - 2B89F3037963E6EDDD48D8C3 /* Pods-InteropTestsRemoteWithCronet.test.xcconfig */, - 781089FAE980F51F88A3BE0B /* Pods-RxLibraryUnitTests.test.xcconfig */, - 32748C4078AEB05F8F954361 /* Pods-InteropTestsRemoteCFStream.debug.xcconfig */, - C17F57E5BCB989AB1C2F1F25 /* Pods-InteropTestsRemoteCFStream.test.xcconfig */, - 4A1A42B2E941CCD453489E5B /* Pods-InteropTestsRemoteCFStream.cronet.xcconfig */, - 303F4A17EB1650FC44603D17 /* Pods-InteropTestsRemoteCFStream.release.xcconfig */, - 943138072A9605B5B8DC1FC0 /* Pods-InteropTestsLocalCleartextCFStream.debug.xcconfig */, - E4FD4606D4AB8D5A314D72F0 /* Pods-InteropTestsLocalCleartextCFStream.test.xcconfig */, - 8B498B05C6DA0818B2FA91D4 /* Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig */, - 7BA53C6D224288D5870FE6F3 /* Pods-InteropTestsLocalCleartextCFStream.release.xcconfig */, - 3EB55EF291706E3DDE23C3B7 /* Pods-InteropTestsLocalSSLCFStream.debug.xcconfig */, - 41AA59529240A6BBBD3DB904 /* Pods-InteropTestsLocalSSLCFStream.test.xcconfig */, - 55B630C1FF8C36D1EFC4E0A4 /* Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig */, - 5EA908CF4CDA4CE218352A06 /* Pods-InteropTestsLocalSSLCFStream.release.xcconfig */, - F9E48EF5ACB1F38825171C5F /* Pods-ChannelTests.debug.xcconfig */, - BED74BC8ABF9917C66175879 /* Pods-ChannelTests.test.xcconfig */, - 90E63AD3C4A1E3E6BC745096 /* Pods-ChannelTests.cronet.xcconfig */, - D52B92A7108602F170DA8091 /* Pods-ChannelTests.release.xcconfig */, - 3CADF86203B9D03EA96C359D /* Pods-InteropTestsMultipleChannels.debug.xcconfig */, - EA8B122ACDE73E3AAA0E4A19 /* Pods-InteropTestsMultipleChannels.test.xcconfig */, - 1295CCBD1082B4A7CFCED95F /* Pods-InteropTestsMultipleChannels.cronet.xcconfig */, - 2650FEF00956E7924772F9D9 /* Pods-InteropTestsMultipleChannels.release.xcconfig */, - 3A98DF08852F60AF1D96481D /* Pods-InteropTestsCallOptions.debug.xcconfig */, - A25967A0D40ED14B3287AD81 /* Pods-InteropTestsCallOptions.test.xcconfig */, - 73D2DF07027835BA0FB0B1C0 /* Pods-InteropTestsCallOptions.cronet.xcconfig */, - C9172F9020E8C97A470D7250 /* Pods-InteropTestsCallOptions.release.xcconfig */, - A2DCF2570BE515B62CB924CA /* Pods-UnitTests.debug.xcconfig */, - 94D7A5FAA13480E9A5166D7A /* Pods-UnitTests.test.xcconfig */, - E1E7660656D902104F728892 /* Pods-UnitTests.cronet.xcconfig */, - EBFFEC04B514CB0D4922DC40 /* Pods-UnitTests.release.xcconfig */, - 1286B30AD74CB64CD91FB17D /* Pods-APIv2Tests.debug.xcconfig */, - 51F2A64B7AADBA1B225B132E /* Pods-APIv2Tests.test.xcconfig */, - 8C233E85C3EB45B3CAE52EDF /* Pods-APIv2Tests.cronet.xcconfig */, - 12B238CD1702393C2BA5DE80 /* Pods-APIv2Tests.release.xcconfig */, - E3ACD4D5902745976D9C2229 /* Pods-MacTests.debug.xcconfig */, - 1F5E788FBF9A4A06EB9E1ACD /* Pods-MacTests.test.xcconfig */, - 16A2E4C5839C83FBDA63881F /* Pods-MacTests.cronet.xcconfig */, - 1E43EAE443CBB4482B1EB071 /* Pods-MacTests.release.xcconfig */, - 680439AC2BC8761EDD54A1EA /* Pods-InteropTests.debug.xcconfig */, - 070266E2626EB997B54880A3 /* Pods-InteropTests.test.xcconfig */, - CDF6CC70B8BF9D10EFE7D199 /* Pods-InteropTests.cronet.xcconfig */, - F6A7EECACBB4849DDD3F450A /* Pods-InteropTests.release.xcconfig */, - EC66920112123D2DB1CB7F6C /* Pods-CronetTests.debug.xcconfig */, - 5AB9A82F289D548D6B8816F9 /* Pods-CronetTests.test.xcconfig */, - 20F6A3D59D0EE091E2D43953 /* Pods-CronetTests.cronet.xcconfig */, - 7F4F42EBAF311E9F84FCA32E /* Pods-CronetTests.release.xcconfig */, - ); - name = Pods; - sourceTree = ""; - }; 5E0282E7215AA697007AC99D /* UnitTests */ = { isa = PBXGroup; children = ( @@ -377,8 +196,8 @@ B0BB3EF8225E795F008DA580 /* MacTests */, 5E7F485A22775B15006656AD /* CronetTests */, 635697C81B14FC11007A7283 /* Products */, - 51E4650F34F854F41FF053B3 /* Pods */, 136D535E19727099B941D7B1 /* Frameworks */, + E549E472D8DBE9DD5C7D6247 /* Pods */, ); sourceTree = ""; }; @@ -424,6 +243,30 @@ path = MacTests; sourceTree = ""; }; + E549E472D8DBE9DD5C7D6247 /* Pods */ = { + isa = PBXGroup; + children = ( + 9AEB5A4889D2018866BE6050 /* Pods-CronetTests.debug.xcconfig */, + 55BBF7900C93644CD8236BD2 /* Pods-CronetTests.test.xcconfig */, + B43404F2B37A38483BE4704A /* Pods-CronetTests.cronet.xcconfig */, + FF0A4B1F995C18C1EB86D155 /* Pods-CronetTests.release.xcconfig */, + C56A093740F31650ACDD9630 /* Pods-InteropTests.debug.xcconfig */, + 5CF07AAE0442D200BCD81ABC /* Pods-InteropTests.test.xcconfig */, + 16B9B1262FE6FBFC353B62BB /* Pods-InteropTests.cronet.xcconfig */, + 42DF8A339EF81AFE13553D04 /* Pods-InteropTests.release.xcconfig */, + BC5D3F3B5B38B71CA279AF7F /* Pods-MacTests.debug.xcconfig */, + DA532DBBE1BC0DC8EC879FE1 /* Pods-MacTests.test.xcconfig */, + 7612BA4B2A55BC4F508570C2 /* Pods-MacTests.cronet.xcconfig */, + 5287652093398BAA7C5A90E8 /* Pods-MacTests.release.xcconfig */, + 936ADE0FD98D66144C935C37 /* Pods-UnitTests.debug.xcconfig */, + B3C890A1E6F082CD283069BF /* Pods-UnitTests.test.xcconfig */, + 4A76E027206C07B7DBECB301 /* Pods-UnitTests.cronet.xcconfig */, + 9E48AF01E76B19FAAAACAE23 /* Pods-UnitTests.release.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -431,11 +274,11 @@ isa = PBXNativeTarget; buildConfigurationList = 5E0282F2215AA697007AC99D /* Build configuration list for PBXNativeTarget "UnitTests" */; buildPhases = ( - F07941C0BAF6A7C67AA60C48 /* [CP] Check Pods Manifest.lock */, + 1C48C52EEA28609437176C56 /* [CP] Check Pods Manifest.lock */, 5E0282E2215AA697007AC99D /* Sources */, 5E0282E3215AA697007AC99D /* Frameworks */, 5E0282E4215AA697007AC99D /* Resources */, - 9AD0B5E94F2AA5962EA6AA36 /* [CP] Copy Pods Resources */, + 9D72085F3319466831FF534B /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -450,12 +293,12 @@ isa = PBXNativeTarget; buildConfigurationList = 5E7F485E22775B15006656AD /* Build configuration list for PBXNativeTarget "CronetTests" */; buildPhases = ( - CCAEC0F23E05489651A07D53 /* [CP] Check Pods Manifest.lock */, + A9802246E6D152C53B842F78 /* [CP] Check Pods Manifest.lock */, 5E7F485522775B15006656AD /* Sources */, 5E7F485622775B15006656AD /* Frameworks */, 5E7F485722775B15006656AD /* Resources */, - 292EA42A76AC7933A37235FD /* [CP] Embed Pods Frameworks */, - 30AFD6F6FC40B9923632A866 /* [CP] Copy Pods Resources */, + B112143D0A46BAE4E66475F8 /* [CP] Embed Pods Frameworks */, + 996BCBE3467BA6EA7FD49408 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -470,12 +313,12 @@ isa = PBXNativeTarget; buildConfigurationList = 5EA477002272816B000F72FC /* Build configuration list for PBXNativeTarget "InteropTests" */; buildPhases = ( - 40BCDB09674DF988C708D22B /* [CP] Check Pods Manifest.lock */, + 71F4FF8BADB6E545CD692B6C /* [CP] Check Pods Manifest.lock */, 5EA476F02272816A000F72FC /* Sources */, 5EA476F12272816A000F72FC /* Frameworks */, 5EA476F22272816A000F72FC /* Resources */, - D11CB94CF56A1E53760D29D8 /* [CP] Copy Pods Resources */, - 0FEFD5FC6B323AC95549AE4A /* [CP] Embed Pods Frameworks */, + E31E6BE4FCE4DD9487BBAD24 /* [CP] Embed Pods Frameworks */, + 4CC1D806002539B97E065D5A /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -490,11 +333,11 @@ isa = PBXNativeTarget; buildConfigurationList = B0BB3EFC225E795F008DA580 /* Build configuration list for PBXNativeTarget "MacTests" */; buildPhases = ( - E5B20F69559C6AE299DFEA7C /* [CP] Check Pods Manifest.lock */, + E180B0BE16D2B14B9071B2F8 /* [CP] Check Pods Manifest.lock */, B0BB3EF3225E795F008DA580 /* Sources */, B0BB3EF4225E795F008DA580 /* Frameworks */, B0BB3EF5225E795F008DA580 /* Resources */, - 452FDC3918FEC23ECAFD31EC /* [CP] Copy Pods Resources */, + 8694D2A1C7CEB7391B497CE0 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -587,49 +430,35 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 0FEFD5FC6B323AC95549AE4A /* [CP] Embed Pods Frameworks */ = { + 1C48C52EEA28609437176C56 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); - inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-frameworks.sh", - "${PODS_ROOT}/CronetFramework/Cronet.framework", + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( ); - name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", + "$(DERIVED_FILE_DIR)/Pods-UnitTests-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-frameworks.sh\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 292EA42A76AC7933A37235FD /* [CP] Embed Pods Frameworks */ = { + 4CC1D806002539B97E065D5A /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-frameworks.sh", - "${PODS_ROOT}/CronetFramework/Cronet.framework", - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - 30AFD6F6FC40B9923632A866 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; @@ -638,10 +467,10 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 40BCDB09674DF988C708D22B /* [CP] Check Pods Manifest.lock */ = { + 71F4FF8BADB6E545CD692B6C /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -663,7 +492,7 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 452FDC3918FEC23ECAFD31EC /* [CP] Copy Pods Resources */ = { + 8694D2A1C7CEB7391B497CE0 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -681,7 +510,25 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MacTests/Pods-MacTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 9AD0B5E94F2AA5962EA6AA36 /* [CP] Copy Pods Resources */ = { + 996BCBE3467BA6EA7FD49408 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-resources.sh", + "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 9D72085F3319466831FF534B /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -699,7 +546,7 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-UnitTests/Pods-UnitTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; - CCAEC0F23E05489651A07D53 /* [CP] Check Pods Manifest.lock */ = { + A9802246E6D152C53B842F78 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -721,25 +568,25 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - D11CB94CF56A1E53760D29D8 /* [CP] Copy Pods Resources */ = { + B112143D0A46BAE4E66475F8 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", + "${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-frameworks.sh", + "${PODS_ROOT}/CronetFramework/Cronet.framework", ); - name = "[CP] Copy Pods Resources"; + name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - E5B20F69559C6AE299DFEA7C /* [CP] Check Pods Manifest.lock */ = { + E180B0BE16D2B14B9071B2F8 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -761,22 +608,22 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - F07941C0BAF6A7C67AA60C48 /* [CP] Check Pods Manifest.lock */ = { + E31E6BE4FCE4DD9487BBAD24 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", + "${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-frameworks.sh", + "${PODS_ROOT}/CronetFramework/Cronet.framework", ); - name = "[CP] Check Pods Manifest.lock"; + name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-UnitTests-checkManifestLockResult.txt", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -845,7 +692,7 @@ /* Begin XCBuildConfiguration section */ 5E0282EE215AA697007AC99D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = A2DCF2570BE515B62CB924CA /* Pods-UnitTests.debug.xcconfig */; + baseConfigurationReference = 936ADE0FD98D66144C935C37 /* Pods-UnitTests.debug.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -876,7 +723,7 @@ }; 5E0282EF215AA697007AC99D /* Test */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 94D7A5FAA13480E9A5166D7A /* Pods-UnitTests.test.xcconfig */; + baseConfigurationReference = B3C890A1E6F082CD283069BF /* Pods-UnitTests.test.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -905,7 +752,7 @@ }; 5E0282F0215AA697007AC99D /* Cronet */ = { isa = XCBuildConfiguration; - baseConfigurationReference = E1E7660656D902104F728892 /* Pods-UnitTests.cronet.xcconfig */; + baseConfigurationReference = 4A76E027206C07B7DBECB301 /* Pods-UnitTests.cronet.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -934,7 +781,7 @@ }; 5E0282F1215AA697007AC99D /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = EBFFEC04B514CB0D4922DC40 /* Pods-UnitTests.release.xcconfig */; + baseConfigurationReference = 9E48AF01E76B19FAAAACAE23 /* Pods-UnitTests.release.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1010,7 +857,7 @@ }; 5E7F485F22775B15006656AD /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = EC66920112123D2DB1CB7F6C /* Pods-CronetTests.debug.xcconfig */; + baseConfigurationReference = 9AEB5A4889D2018866BE6050 /* Pods-CronetTests.debug.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1051,7 +898,7 @@ }; 5E7F486022775B15006656AD /* Test */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 5AB9A82F289D548D6B8816F9 /* Pods-CronetTests.test.xcconfig */; + baseConfigurationReference = 55BBF7900C93644CD8236BD2 /* Pods-CronetTests.test.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1089,7 +936,7 @@ }; 5E7F486122775B15006656AD /* Cronet */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 20F6A3D59D0EE091E2D43953 /* Pods-CronetTests.cronet.xcconfig */; + baseConfigurationReference = B43404F2B37A38483BE4704A /* Pods-CronetTests.cronet.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1127,7 +974,7 @@ }; 5E7F486222775B15006656AD /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7F4F42EBAF311E9F84FCA32E /* Pods-CronetTests.release.xcconfig */; + baseConfigurationReference = FF0A4B1F995C18C1EB86D155 /* Pods-CronetTests.release.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1165,7 +1012,7 @@ }; 5EA476FC2272816B000F72FC /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 680439AC2BC8761EDD54A1EA /* Pods-InteropTests.debug.xcconfig */; + baseConfigurationReference = C56A093740F31650ACDD9630 /* Pods-InteropTests.debug.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1200,7 +1047,7 @@ }; 5EA476FD2272816B000F72FC /* Test */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 070266E2626EB997B54880A3 /* Pods-InteropTests.test.xcconfig */; + baseConfigurationReference = 5CF07AAE0442D200BCD81ABC /* Pods-InteropTests.test.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1232,7 +1079,7 @@ }; 5EA476FE2272816B000F72FC /* Cronet */ = { isa = XCBuildConfiguration; - baseConfigurationReference = CDF6CC70B8BF9D10EFE7D199 /* Pods-InteropTests.cronet.xcconfig */; + baseConfigurationReference = 16B9B1262FE6FBFC353B62BB /* Pods-InteropTests.cronet.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1264,7 +1111,7 @@ }; 5EA476FF2272816B000F72FC /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = F6A7EECACBB4849DDD3F450A /* Pods-InteropTests.release.xcconfig */; + baseConfigurationReference = 42DF8A339EF81AFE13553D04 /* Pods-InteropTests.release.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1424,7 +1271,7 @@ }; B0BB3EFD225E795F008DA580 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = E3ACD4D5902745976D9C2229 /* Pods-MacTests.debug.xcconfig */; + baseConfigurationReference = BC5D3F3B5B38B71CA279AF7F /* Pods-MacTests.debug.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1461,7 +1308,7 @@ }; B0BB3EFE225E795F008DA580 /* Test */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 1F5E788FBF9A4A06EB9E1ACD /* Pods-MacTests.test.xcconfig */; + baseConfigurationReference = DA532DBBE1BC0DC8EC879FE1 /* Pods-MacTests.test.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1504,7 +1351,7 @@ }; B0BB3EFF225E795F008DA580 /* Cronet */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 16A2E4C5839C83FBDA63881F /* Pods-MacTests.cronet.xcconfig */; + baseConfigurationReference = 7612BA4B2A55BC4F508570C2 /* Pods-MacTests.cronet.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1538,7 +1385,7 @@ }; B0BB3F00225E795F008DA580 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 1E43EAE443CBB4482B1EB071 /* Pods-MacTests.release.xcconfig */; + baseConfigurationReference = 5287652093398BAA7C5A90E8 /* Pods-MacTests.release.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; diff --git a/src/objective-c/tests/UnitTests/APIv2Tests.m b/src/objective-c/tests/UnitTests/APIv2Tests.m index db293750ca3..99c947e335b 100644 --- a/src/objective-c/tests/UnitTests/APIv2Tests.m +++ b/src/objective-c/tests/UnitTests/APIv2Tests.m @@ -18,7 +18,7 @@ #import #import -#import +#import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" #import #include diff --git a/src/objective-c/tests/UnitTests/GRPCClientTests.m b/src/objective-c/tests/UnitTests/GRPCClientTests.m index bcd87c17b78..579f113eada 100644 --- a/src/objective-c/tests/UnitTests/GRPCClientTests.m +++ b/src/objective-c/tests/UnitTests/GRPCClientTests.m @@ -26,7 +26,7 @@ #import #import #import -#import +#import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" #import #import #import From 7142d9e2dc53f66f91222dfe1e8813b8c39950b0 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 12 Jul 2019 05:56:46 -0400 Subject: [PATCH 0976/1555] dont use shutdownRef count for sync completion queue --- .../Internal/CompletionQueueSafeHandle.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs index 28135d7b0d5..25540b40a10 100644 --- a/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs @@ -29,7 +29,7 @@ namespace Grpc.Core.Internal { static readonly NativeMethods Native = NativeMethods.Get(); - AtomicCounter shutdownRefcount = new AtomicCounter(1); + AtomicCounter shutdownRefcount; CompletionRegistry completionRegistry; private CompletionQueueSafeHandle() @@ -51,6 +51,7 @@ namespace Grpc.Core.Internal { var cq = Native.grpcsharp_completion_queue_create_async(); cq.completionRegistry = completionRegistry; + cq.shutdownRefcount = new AtomicCounter(1); return cq; } @@ -95,7 +96,7 @@ namespace Grpc.Core.Internal private void DecrementShutdownRefcount() { - if (shutdownRefcount.Decrement() == 0) + if (shutdownRefcount == null || shutdownRefcount.Decrement() == 0) { Native.grpcsharp_completion_queue_shutdown(this); } @@ -103,14 +104,20 @@ namespace Grpc.Core.Internal private void BeginOp() { - bool success = false; - shutdownRefcount.IncrementIfNonzero(ref success); - GrpcPreconditions.CheckState(success, "Shutdown has already been called"); + if (shutdownRefcount != null) + { + bool success = false; + shutdownRefcount.IncrementIfNonzero(ref success); + GrpcPreconditions.CheckState(success, "Shutdown has already been called"); + } } private void EndOp() { - DecrementShutdownRefcount(); + if (shutdownRefcount != null) + { + DecrementShutdownRefcount(); + } } // Allows declaring BeginOp and EndOp of a completion queue with a using statement. From bc1283c43b2e568a5d1dd690fd40a6cb634536fc Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 24 Jul 2019 07:39:43 -0400 Subject: [PATCH 0977/1555] forbid BeginOp and EndOp for sync completion queue altogether --- .../Internal/CompletionQueueSafeHandle.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs index 25540b40a10..6103ba99aab 100644 --- a/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs @@ -104,20 +104,16 @@ namespace Grpc.Core.Internal private void BeginOp() { - if (shutdownRefcount != null) - { - bool success = false; - shutdownRefcount.IncrementIfNonzero(ref success); - GrpcPreconditions.CheckState(success, "Shutdown has already been called"); - } + GrpcPreconditions.CheckNotNull(shutdownRefcount, nameof(shutdownRefcount)); + bool success = false; + shutdownRefcount.IncrementIfNonzero(ref success); + GrpcPreconditions.CheckState(success, "Shutdown has already been called"); } private void EndOp() { - if (shutdownRefcount != null) - { - DecrementShutdownRefcount(); - } + GrpcPreconditions.CheckNotNull(shutdownRefcount, nameof(shutdownRefcount)); + DecrementShutdownRefcount(); } // Allows declaring BeginOp and EndOp of a completion queue with a using statement. From 29480c4f6b547bbb9fc01a5b0251fe25da166e39 Mon Sep 17 00:00:00 2001 From: Qiancheng Zhao Date: Wed, 24 Jul 2019 10:04:41 -0700 Subject: [PATCH 0978/1555] add client idle filter --- BUILD | 12 + BUILD.gn | 1 + CMakeLists.txt | 2 + Makefile | 2 + build.yaml | 8 + config.m4 | 2 + config.w32 | 2 + gRPC-Core.podspec | 1 + grpc.gemspec | 1 + grpc.gyp | 2 + include/grpc/impl/codegen/grpc_types.h | 13 +- package.xml | 1 + .../filters/client_channel/client_channel.cc | 47 +++- .../resolver/fake/fake_resolver.cc | 183 ++++++++---- .../resolver/fake/fake_resolver.h | 11 +- .../filters/client_idle/client_idle_filter.cc | 264 ++++++++++++++++++ .../ext/filters/max_age/max_age_filter.cc | 2 +- src/core/lib/iomgr/error.cc | 2 + src/core/lib/iomgr/error.h | 2 + .../plugin_registry/grpc_plugin_registry.cc | 4 + .../grpc_unsecure_plugin_registry.cc | 4 + src/python/grpcio/grpc_core_dependencies.py | 1 + test/cpp/end2end/client_lb_end2end_test.cc | 28 +- tools/doxygen/Doxyfile.core.internal | 1 + .../generated/sources_and_headers.json | 17 ++ 25 files changed, 532 insertions(+), 81 deletions(-) create mode 100644 src/core/ext/filters/client_idle/client_idle_filter.cc diff --git a/BUILD b/BUILD index 474fc053ad6..56c1ff34afe 100644 --- a/BUILD +++ b/BUILD @@ -998,6 +998,7 @@ grpc_cc_library( "grpc_client_authority_filter", "grpc_lb_policy_pick_first", "grpc_lb_policy_round_robin", + "grpc_client_idle_filter", "grpc_max_age_filter", "grpc_message_size_filter", "grpc_resolver_dns_ares", @@ -1085,6 +1086,17 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "grpc_client_idle_filter", + srcs = [ + "src/core/ext/filters/client_idle/client_idle_filter.cc", + ], + language = "c++", + deps = [ + "grpc_base", + ], +) + grpc_cc_library( name = "grpc_max_age_filter", srcs = [ diff --git a/BUILD.gn b/BUILD.gn index 9dacd14bb45..83cc1ec4bda 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -348,6 +348,7 @@ config("grpc_config") { "src/core/ext/filters/client_channel/subchannel_interface.h", "src/core/ext/filters/client_channel/subchannel_pool_interface.cc", "src/core/ext/filters/client_channel/subchannel_pool_interface.h", + "src/core/ext/filters/client_idle/client_idle_filter.cc", "src/core/ext/filters/deadline/deadline_filter.cc", "src/core/ext/filters/deadline/deadline_filter.h", "src/core/ext/filters/http/client/http_client_filter.cc", diff --git a/CMakeLists.txt b/CMakeLists.txt index 23305ce6fd9..0ce5e5e0661 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1326,6 +1326,7 @@ add_library(grpc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc src/core/ext/filters/census/grpc_context.cc + src/core/ext/filters/client_idle/client_idle_filter.cc src/core/ext/filters/max_age/max_age_filter.cc src/core/ext/filters/message_size/message_size_filter.cc src/core/ext/filters/http/client_authority_filter.cc @@ -2757,6 +2758,7 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc src/core/ext/filters/census/grpc_context.cc + src/core/ext/filters/client_idle/client_idle_filter.cc src/core/ext/filters/max_age/max_age_filter.cc src/core/ext/filters/message_size/message_size_filter.cc src/core/ext/filters/http/client_authority_filter.cc diff --git a/Makefile b/Makefile index 4755955de7d..fa9128187dd 100644 --- a/Makefile +++ b/Makefile @@ -3843,6 +3843,7 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ src/core/ext/filters/census/grpc_context.cc \ + src/core/ext/filters/client_idle/client_idle_filter.cc \ src/core/ext/filters/max_age/max_age_filter.cc \ src/core/ext/filters/message_size/message_size_filter.cc \ src/core/ext/filters/http/client_authority_filter.cc \ @@ -5210,6 +5211,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc \ src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc \ src/core/ext/filters/census/grpc_context.cc \ + src/core/ext/filters/client_idle/client_idle_filter.cc \ src/core/ext/filters/max_age/max_age_filter.cc \ src/core/ext/filters/message_size/message_size_filter.cc \ src/core/ext/filters/http/client_authority_filter.cc \ diff --git a/build.yaml b/build.yaml index 7b4a396b19c..92fbad06f4a 100644 --- a/build.yaml +++ b/build.yaml @@ -634,6 +634,12 @@ filegroups: - grpc_base - grpc_deadline_filter - health_proto +- name: grpc_client_idle_filter + src: + - src/core/ext/filters/client_idle/client_idle_filter.cc + plugin: grpc_client_idle_filter + uses: + - grpc_base - name: grpc_codegen public_headers: - include/grpc/impl/codegen/byte_buffer.h @@ -1606,6 +1612,7 @@ libs: - grpc_resolver_fake - grpc_secure - census + - grpc_client_idle_filter - grpc_max_age_filter - grpc_message_size_filter - grpc_deadline_filter @@ -1679,6 +1686,7 @@ libs: - grpc_lb_policy_pick_first - grpc_lb_policy_round_robin - census + - grpc_client_idle_filter - grpc_max_age_filter - grpc_message_size_filter - grpc_deadline_filter diff --git a/config.m4 b/config.m4 index 50b789bb7bb..6eeeafce9a5 100644 --- a/config.m4 +++ b/config.m4 @@ -417,6 +417,7 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ src/core/ext/filters/census/grpc_context.cc \ + src/core/ext/filters/client_idle/client_idle_filter.cc \ src/core/ext/filters/max_age/max_age_filter.cc \ src/core/ext/filters/message_size/message_size_filter.cc \ src/core/ext/filters/http/client_authority_filter.cc \ @@ -702,6 +703,7 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns/native) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/fake) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/sockaddr) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_idle) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/deadline) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http/client) diff --git a/config.w32 b/config.w32 index 7048f83facf..fd7920f72fd 100644 --- a/config.w32 +++ b/config.w32 @@ -392,6 +392,7 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\native\\dns_resolver.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\sockaddr\\sockaddr_resolver.cc " + "src\\core\\ext\\filters\\census\\grpc_context.cc " + + "src\\core\\ext\\filters\\client_idle\\client_idle_filter.cc " + "src\\core\\ext\\filters\\max_age\\max_age_filter.cc " + "src\\core\\ext\\filters\\message_size\\message_size_filter.cc " + "src\\core\\ext\\filters\\http\\client_authority_filter.cc " + @@ -712,6 +713,7 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\resolver\\dns\\native"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\resolver\\fake"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\resolver\\sockaddr"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_idle"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\deadline"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\http"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\http\\client"); diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 47cf5b8d47f..16ac9a571e5 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -879,6 +879,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/census/grpc_context.cc', + 'src/core/ext/filters/client_idle/client_idle_filter.cc', 'src/core/ext/filters/max_age/max_age_filter.cc', 'src/core/ext/filters/message_size/message_size_filter.cc', 'src/core/ext/filters/http/client_authority_filter.cc', diff --git a/grpc.gemspec b/grpc.gemspec index 1f4cf237ada..eda96081c73 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -816,6 +816,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc ) s.files += %w( src/core/ext/filters/census/grpc_context.cc ) + s.files += %w( src/core/ext/filters/client_idle/client_idle_filter.cc ) s.files += %w( src/core/ext/filters/max_age/max_age_filter.cc ) s.files += %w( src/core/ext/filters/message_size/message_size_filter.cc ) s.files += %w( src/core/ext/filters/http/client_authority_filter.cc ) diff --git a/grpc.gyp b/grpc.gyp index 5eeab74d4c7..d3292a42ef9 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -599,6 +599,7 @@ 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/census/grpc_context.cc', + 'src/core/ext/filters/client_idle/client_idle_filter.cc', 'src/core/ext/filters/max_age/max_age_filter.cc', 'src/core/ext/filters/message_size/message_size_filter.cc', 'src/core/ext/filters/http/client_authority_filter.cc', @@ -1380,6 +1381,7 @@ 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc', 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc', 'src/core/ext/filters/census/grpc_context.cc', + 'src/core/ext/filters/client_idle/client_idle_filter.cc', 'src/core/ext/filters/max_age/max_age_filter.cc', 'src/core/ext/filters/message_size/message_size_filter.cc', 'src/core/ext/filters/http/client_authority_filter.cc', diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 65582e6e85d..ab29e917ed8 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -157,8 +157,9 @@ typedef struct { /** Maximum message length that the channel can send. Int valued, bytes. -1 means unlimited. */ #define GRPC_ARG_MAX_SEND_MESSAGE_LENGTH "grpc.max_send_message_length" -/** Maximum time that a channel may have no outstanding rpcs. Int valued, - milliseconds. INT_MAX means unlimited. */ +/** Maximum time that a channel may have no outstanding rpcs, after which the + * server will close the connection. Int valued, milliseconds. INT_MAX means + * unlimited. */ #define GRPC_ARG_MAX_CONNECTION_IDLE_MS "grpc.max_connection_idle_ms" /** Maximum time that a channel may exist. Int valued, milliseconds. * INT_MAX means unlimited. */ @@ -166,6 +167,14 @@ typedef struct { /** Grace period after the channel reaches its max age. Int valued, milliseconds. INT_MAX means unlimited. */ #define GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS "grpc.max_connection_age_grace_ms" +/** Timeout after the last RPC finishes on the client channel at which the + * channel goes back into IDLE state. Int valued, milliseconds. INT_MAX means + * unlimited. */ +/** TODO(qianchengz): Currently the default value is INT_MAX, which means the + * client idle filter is disabled by default. After the client idle filter + * proves no perfomance issue, we will change the default value to a reasonable + * value. */ +#define GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS "grpc.client_idle_timeout_ms" /** Enable/disable support for per-message compression. Defaults to 1, unless GRPC_ARG_MINIMAL_STACK is enabled, in which case it defaults to 0. */ #define GRPC_ARG_ENABLE_PER_MESSAGE_COMPRESSION "grpc.per_message_compression" diff --git a/package.xml b/package.xml index 584c6510a60..cb221ff932d 100644 --- a/package.xml +++ b/package.xml @@ -821,6 +821,7 @@ + diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 9aeb4be76d8..3c2e75ad8d3 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -726,6 +726,13 @@ class ChannelData::ConnectivityStateAndPickerSetter { ChannelData* chand, grpc_connectivity_state state, const char* reason, UniquePtr picker) : chand_(chand), picker_(std::move(picker)) { + // Clean the control plane when entering IDLE, while holding control plane + // combiner. + if (picker_ == nullptr) { + chand->health_check_service_name_.reset(); + chand->saved_service_config_.reset(); + chand->received_first_resolver_result_ = false; + } // Update connectivity state here, while holding control plane combiner. grpc_connectivity_state_set(&chand->state_tracker_, state, reason); if (chand->channelz_node_ != nullptr) { @@ -749,6 +756,12 @@ class ChannelData::ConnectivityStateAndPickerSetter { auto* self = static_cast(arg); // Update picker. self->chand_->picker_ = std::move(self->picker_); + // Clean the data plane if the updated picker is nullptr. + if (self->chand_->picker_ == nullptr) { + self->chand_->received_service_config_data_ = false; + self->chand_->retry_throttle_data_.reset(); + self->chand_->service_config_.reset(); + } // Re-process queued picks. for (QueuedPick* pick = self->chand_->queued_picks_; pick != nullptr; pick = pick->next) { @@ -1486,19 +1499,31 @@ void ChannelData::StartTransportOpLocked(void* arg, grpc_error* ignored) { chand->resolving_lb_policy_->ResetBackoffLocked(); } } - // Disconnect. + // Disconnect or enter IDLE. if (op->disconnect_with_error != GRPC_ERROR_NONE) { - grpc_error* error = GRPC_ERROR_NONE; - GPR_ASSERT(chand->disconnect_error_.CompareExchangeStrong( - &error, op->disconnect_with_error, MemoryOrder::ACQ_REL, - MemoryOrder::ACQUIRE)); chand->DestroyResolvingLoadBalancingPolicyLocked(); - // Will delete itself. - New( - chand, GRPC_CHANNEL_SHUTDOWN, "shutdown from API", - UniquePtr( - New( - GRPC_ERROR_REF(op->disconnect_with_error)))); + intptr_t value; + if (grpc_error_get_int(op->disconnect_with_error, + GRPC_ERROR_INT_CHANNEL_CONNECTIVITY_STATE, &value) && + static_cast(value) == GRPC_CHANNEL_IDLE) { + if (chand->disconnect_error() == GRPC_ERROR_NONE) { + // Enter IDLE state. + New(chand, GRPC_CHANNEL_IDLE, + "channel entering IDLE", nullptr); + } + GRPC_ERROR_UNREF(op->disconnect_with_error); + } else { + // Disconnect. + grpc_error* error = GRPC_ERROR_NONE; + GPR_ASSERT(chand->disconnect_error_.CompareExchangeStrong( + &error, op->disconnect_with_error, MemoryOrder::ACQ_REL, + MemoryOrder::ACQUIRE)); + New( + chand, GRPC_CHANNEL_SHUTDOWN, "shutdown from API", + UniquePtr( + New( + GRPC_ERROR_REF(op->disconnect_with_error)))); + } } GRPC_CHANNEL_STACK_UNREF(chand->owning_stack_, "start_transport_op"); GRPC_CLOSURE_SCHED(op->on_consumed, GRPC_ERROR_NONE); diff --git a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc index 761b27292da..443a709ea6c 100644 --- a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc @@ -60,7 +60,13 @@ class FakeResolver : public Resolver { virtual ~FakeResolver(); - void ShutdownLocked() override { active_ = false; } + void ShutdownLocked() override { + shutdown_ = true; + if (response_generator_ != nullptr) { + response_generator_->SetFakeResolver(nullptr); + response_generator_.reset(); + } + } void MaybeSendResultLocked(); @@ -68,6 +74,7 @@ class FakeResolver : public Resolver { // passed-in parameters grpc_channel_args* channel_args_ = nullptr; + RefCountedPtr response_generator_; // If has_next_result_ is true, next_result_ is the next resolution result // to be returned. bool has_next_result_ = false; @@ -76,8 +83,10 @@ class FakeResolver : public Resolver { // RequestReresolutionLocked(). bool has_reresolution_result_ = false; Result reresolution_result_; - // True between the calls to StartLocked() ShutdownLocked(). - bool active_ = false; + // True after the call to StartLocked(). + bool started_ = false; + // True after the call to ShutdownLocked(). + bool shutdown_ = false; // if true, return failure bool return_failure_ = false; // pending re-resolution @@ -86,11 +95,11 @@ class FakeResolver : public Resolver { }; FakeResolver::FakeResolver(ResolverArgs args) - : Resolver(args.combiner, std::move(args.result_handler)) { + : Resolver(args.combiner, std::move(args.result_handler)), + response_generator_( + FakeResolverResponseGenerator::GetFromArgs(args.args)) { GRPC_CLOSURE_INIT(&reresolution_closure_, ReturnReresolutionResult, this, grpc_combiner_scheduler(combiner())); - FakeResolverResponseGenerator* response_generator = - FakeResolverResponseGenerator::GetFromArgs(args.args); // Channels sharing the same subchannels may have different resolver response // generators. If we don't remove this arg, subchannel pool will create new // subchannels for the same address instead of reusing existing ones because @@ -98,19 +107,15 @@ FakeResolver::FakeResolver(ResolverArgs args) const char* args_to_remove[] = {GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR}; channel_args_ = grpc_channel_args_copy_and_remove( args.args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove)); - if (response_generator != nullptr) { - response_generator->resolver_ = this; - if (response_generator->has_result_) { - response_generator->SetResponse(std::move(response_generator->result_)); - response_generator->has_result_ = false; - } + if (response_generator_ != nullptr) { + response_generator_->SetFakeResolver(Ref()); } } FakeResolver::~FakeResolver() { grpc_channel_args_destroy(channel_args_); } void FakeResolver::StartLocked() { - active_ = true; + started_ = true; MaybeSendResultLocked(); } @@ -130,7 +135,7 @@ void FakeResolver::RequestReresolutionLocked() { } void FakeResolver::MaybeSendResultLocked() { - if (!active_) return; + if (!started_ || shutdown_) return; if (return_failure_) { // TODO(roth): Change resolver result generator to be able to inject // the error to be returned. @@ -165,9 +170,13 @@ void FakeResolver::ReturnReresolutionResult(void* arg, grpc_error* error) { // FakeResolverResponseGenerator // +FakeResolverResponseGenerator::FakeResolverResponseGenerator() {} + +FakeResolverResponseGenerator::~FakeResolverResponseGenerator() {} + struct SetResponseClosureArg { grpc_closure set_response_closure; - FakeResolverResponseGenerator* generator; + RefCountedPtr resolver; Resolver::Result result; bool has_result = false; bool immediate = true; @@ -176,97 +185,146 @@ struct SetResponseClosureArg { void FakeResolverResponseGenerator::SetResponseLocked(void* arg, grpc_error* error) { SetResponseClosureArg* closure_arg = static_cast(arg); - FakeResolver* resolver = closure_arg->generator->resolver_; - resolver->next_result_ = std::move(closure_arg->result); - resolver->has_next_result_ = true; - resolver->MaybeSendResultLocked(); - closure_arg->generator->Unref(); + auto& resolver = closure_arg->resolver; + if (!resolver->shutdown_) { + resolver->next_result_ = std::move(closure_arg->result); + resolver->has_next_result_ = true; + resolver->MaybeSendResultLocked(); + } Delete(closure_arg); } void FakeResolverResponseGenerator::SetResponse(Resolver::Result result) { - if (resolver_ != nullptr) { - Ref().release(); // ref to be held by closure - SetResponseClosureArg* closure_arg = New(); - closure_arg->generator = this; - closure_arg->result = std::move(result); - GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_INIT(&closure_arg->set_response_closure, SetResponseLocked, - closure_arg, - grpc_combiner_scheduler(resolver_->combiner())), - GRPC_ERROR_NONE); - } else { - has_result_ = true; - result_ = std::move(result); + RefCountedPtr resolver; + { + MutexLock lock(&mu_); + if (resolver_ == nullptr) { + has_result_ = true; + result_ = std::move(result); + return; + } + resolver = resolver_->Ref(); } + SetResponseClosureArg* closure_arg = New(); + closure_arg->resolver = std::move(resolver); + closure_arg->result = std::move(result); + GRPC_CLOSURE_SCHED( + GRPC_CLOSURE_INIT( + &closure_arg->set_response_closure, SetResponseLocked, closure_arg, + grpc_combiner_scheduler(closure_arg->resolver->combiner())), + GRPC_ERROR_NONE); } void FakeResolverResponseGenerator::SetReresolutionResponseLocked( void* arg, grpc_error* error) { SetResponseClosureArg* closure_arg = static_cast(arg); - FakeResolver* resolver = closure_arg->generator->resolver_; - resolver->reresolution_result_ = std::move(closure_arg->result); - resolver->has_reresolution_result_ = closure_arg->has_result; + auto& resolver = closure_arg->resolver; + if (!resolver->shutdown_) { + resolver->reresolution_result_ = std::move(closure_arg->result); + resolver->has_reresolution_result_ = closure_arg->has_result; + } Delete(closure_arg); } void FakeResolverResponseGenerator::SetReresolutionResponse( Resolver::Result result) { - GPR_ASSERT(resolver_ != nullptr); + RefCountedPtr resolver; + { + MutexLock lock(&mu_); + GPR_ASSERT(resolver_ != nullptr); + resolver = resolver_->Ref(); + } SetResponseClosureArg* closure_arg = New(); - closure_arg->generator = this; + closure_arg->resolver = std::move(resolver); closure_arg->result = std::move(result); closure_arg->has_result = true; GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_INIT(&closure_arg->set_response_closure, - SetReresolutionResponseLocked, closure_arg, - grpc_combiner_scheduler(resolver_->combiner())), + GRPC_CLOSURE_INIT( + &closure_arg->set_response_closure, SetReresolutionResponseLocked, + closure_arg, + grpc_combiner_scheduler(closure_arg->resolver->combiner())), GRPC_ERROR_NONE); } void FakeResolverResponseGenerator::UnsetReresolutionResponse() { - GPR_ASSERT(resolver_ != nullptr); + RefCountedPtr resolver; + { + MutexLock lock(&mu_); + GPR_ASSERT(resolver_ != nullptr); + resolver = resolver_->Ref(); + } SetResponseClosureArg* closure_arg = New(); - closure_arg->generator = this; + closure_arg->resolver = std::move(resolver); GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_INIT(&closure_arg->set_response_closure, - SetReresolutionResponseLocked, closure_arg, - grpc_combiner_scheduler(resolver_->combiner())), + GRPC_CLOSURE_INIT( + &closure_arg->set_response_closure, SetReresolutionResponseLocked, + closure_arg, + grpc_combiner_scheduler(closure_arg->resolver->combiner())), GRPC_ERROR_NONE); } void FakeResolverResponseGenerator::SetFailureLocked(void* arg, grpc_error* error) { SetResponseClosureArg* closure_arg = static_cast(arg); - FakeResolver* resolver = closure_arg->generator->resolver_; - resolver->return_failure_ = true; - if (closure_arg->immediate) resolver->MaybeSendResultLocked(); + auto& resolver = closure_arg->resolver; + if (!resolver->shutdown_) { + resolver->return_failure_ = true; + if (closure_arg->immediate) resolver->MaybeSendResultLocked(); + } Delete(closure_arg); } void FakeResolverResponseGenerator::SetFailure() { - GPR_ASSERT(resolver_ != nullptr); + RefCountedPtr resolver; + { + MutexLock lock(&mu_); + GPR_ASSERT(resolver_ != nullptr); + resolver = resolver_->Ref(); + } SetResponseClosureArg* closure_arg = New(); - closure_arg->generator = this; + closure_arg->resolver = std::move(resolver); GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_INIT(&closure_arg->set_response_closure, SetFailureLocked, - closure_arg, - grpc_combiner_scheduler(resolver_->combiner())), + GRPC_CLOSURE_INIT( + &closure_arg->set_response_closure, SetFailureLocked, closure_arg, + grpc_combiner_scheduler(closure_arg->resolver->combiner())), GRPC_ERROR_NONE); } void FakeResolverResponseGenerator::SetFailureOnReresolution() { - GPR_ASSERT(resolver_ != nullptr); + RefCountedPtr resolver; + { + MutexLock lock(&mu_); + GPR_ASSERT(resolver_ != nullptr); + resolver = resolver_->Ref(); + } SetResponseClosureArg* closure_arg = New(); - closure_arg->generator = this; + closure_arg->resolver = std::move(resolver); closure_arg->immediate = false; GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_INIT(&closure_arg->set_response_closure, SetFailureLocked, - closure_arg, - grpc_combiner_scheduler(resolver_->combiner())), + GRPC_CLOSURE_INIT( + &closure_arg->set_response_closure, SetFailureLocked, closure_arg, + grpc_combiner_scheduler(closure_arg->resolver->combiner())), GRPC_ERROR_NONE); } +void FakeResolverResponseGenerator::SetFakeResolver( + RefCountedPtr resolver) { + MutexLock lock(&mu_); + resolver_ = std::move(resolver); + if (resolver_ == nullptr) return; + if (has_result_) { + SetResponseClosureArg* closure_arg = New(); + closure_arg->resolver = resolver_->Ref(); + closure_arg->result = std::move(result_); + GRPC_CLOSURE_SCHED( + GRPC_CLOSURE_INIT(&closure_arg->set_response_closure, SetResponseLocked, + closure_arg, + grpc_combiner_scheduler(resolver_->combiner())), + GRPC_ERROR_NONE); + has_result_ = false; + } +} + namespace { static void* response_generator_arg_copy(void* p) { @@ -304,12 +362,13 @@ grpc_arg FakeResolverResponseGenerator::MakeChannelArg( return arg; } -FakeResolverResponseGenerator* FakeResolverResponseGenerator::GetFromArgs( - const grpc_channel_args* args) { +RefCountedPtr +FakeResolverResponseGenerator::GetFromArgs(const grpc_channel_args* args) { const grpc_arg* arg = grpc_channel_args_find(args, GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR); if (arg == nullptr || arg->type != GRPC_ARG_POINTER) return nullptr; - return static_cast(arg->value.pointer.p); + return static_cast(arg->value.pointer.p) + ->Ref(); } // diff --git a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h index 3b1ea8e8909..c04c7c38e17 100644 --- a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +++ b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h @@ -42,7 +42,8 @@ class FakeResolver; class FakeResolverResponseGenerator : public RefCounted { public: - FakeResolverResponseGenerator() {} + FakeResolverResponseGenerator(); + ~FakeResolverResponseGenerator(); // Instructs the fake resolver associated with the response generator // instance to trigger a new resolution with the specified result. If the @@ -71,17 +72,21 @@ class FakeResolverResponseGenerator static grpc_arg MakeChannelArg(FakeResolverResponseGenerator* generator); // Returns the response generator in \a args, or null if not found. - static FakeResolverResponseGenerator* GetFromArgs( + static RefCountedPtr GetFromArgs( const grpc_channel_args* args); private: friend class FakeResolver; + // Set the corresponding FakeResolver to this generator. + void SetFakeResolver(RefCountedPtr resolver); static void SetResponseLocked(void* arg, grpc_error* error); static void SetReresolutionResponseLocked(void* arg, grpc_error* error); static void SetFailureLocked(void* arg, grpc_error* error); - FakeResolver* resolver_ = nullptr; // Do not own. + // Mutex protecting the members below. + Mutex mu_; + RefCountedPtr resolver_; Resolver::Result result_; bool has_result_ = false; }; diff --git a/src/core/ext/filters/client_idle/client_idle_filter.cc b/src/core/ext/filters/client_idle/client_idle_filter.cc new file mode 100644 index 00000000000..d2b23a9d20f --- /dev/null +++ b/src/core/ext/filters/client_idle/client_idle_filter.cc @@ -0,0 +1,264 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include + +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/channel/channel_stack_builder.h" +#include "src/core/lib/gprpp/atomic.h" +#include "src/core/lib/iomgr/timer.h" +#include "src/core/lib/surface/channel_init.h" +#include "src/core/lib/transport/http2_errors.h" + +// The idle filter is disabled in client channel by default. +// To enable the idle filte, set GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS to [0, INT_MAX) +// in channel args. +// TODO(qianchengz): Find a reasonable default value. Maybe check what deault +// value Java uses. +#define DEFAULT_IDLE_TIMEOUT_MS INT_MAX + +namespace grpc_core { + +TraceFlag grpc_trace_client_idle_filter(false, "client_idle_filter"); + +#define GRPC_IDLE_FILTER_LOG(format, ...) \ + do { \ + if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_client_idle_filter)) { \ + gpr_log(GPR_INFO, "(client idle filter) " format, ##__VA_ARGS__); \ + } \ + } while (0) + +namespace { + +grpc_millis GetClientIdleTimeout(const grpc_channel_args* args) { + return grpc_channel_arg_get_integer( + grpc_channel_args_find(args, GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS), + {DEFAULT_IDLE_TIMEOUT_MS, 0, INT_MAX}); +} + +class ChannelData { + public: + static grpc_error* Init(grpc_channel_element* elem, + grpc_channel_element_args* args); + static void Destroy(grpc_channel_element* elem); + + static void StartTransportOp(grpc_channel_element* elem, + grpc_transport_op* op); + + void IncreaseCallCount(); + + void DecreaseCallCount(); + + private: + ChannelData(grpc_channel_element* elem, grpc_channel_element_args* args, + grpc_error** error); + ~ChannelData() = default; + + static void IdleTimerCallback(void* arg, grpc_error* error); + static void IdleTransportOpCompleteCallback(void* arg, grpc_error* error); + + void StartIdleTimer(); + + void EnterIdle(); + + grpc_channel_element* elem_; + // The channel stack to which we take refs for pending callbacks. + grpc_channel_stack* channel_stack_; + // Timeout after the last RPC finishes on the client channel at which the + // channel goes back into IDLE state. + const grpc_millis client_idle_timeout_; + + // Member data used to track the state of channel. + Mutex call_count_mu_; + size_t call_count_; + + // Idle timer and its callback closure. + grpc_timer idle_timer_; + grpc_closure idle_timer_callback_; + + // The transport op telling the client channel to enter IDLE. + grpc_transport_op idle_transport_op_; + grpc_closure idle_transport_op_complete_callback_; +}; + +grpc_error* ChannelData::Init(grpc_channel_element* elem, + grpc_channel_element_args* args) { + grpc_error* error = GRPC_ERROR_NONE; + new (elem->channel_data) ChannelData(elem, args, &error); + return error; +} + +void ChannelData::Destroy(grpc_channel_element* elem) { + ChannelData* chand = static_cast(elem->channel_data); + chand->~ChannelData(); +} + +void ChannelData::StartTransportOp(grpc_channel_element* elem, + grpc_transport_op* op) { + ChannelData* chand = static_cast(elem->channel_data); + // Catch the disconnect_with_error transport op. + if (op->disconnect_with_error != nullptr) { + // Disconnect. Cancel the timer if we set it before. + // IncreaseCallCount() introduces a dummy call. It will cancel the timer and + // prevent the timer from being reset by other threads. + chand->IncreaseCallCount(); + } + // Pass the op to the next filter. + grpc_channel_next_op(elem, op); +} + +void ChannelData::IncreaseCallCount() { + MutexLock lock(&call_count_mu_); + if (call_count_++ == 0) { + grpc_timer_cancel(&idle_timer_); + } + GRPC_IDLE_FILTER_LOG("call counter has increased to %" PRIuPTR, call_count_); +} + +void ChannelData::DecreaseCallCount() { + MutexLock lock(&call_count_mu_); + if (call_count_-- == 1) { + StartIdleTimer(); + } + GRPC_IDLE_FILTER_LOG("call counter has decreased to %" PRIuPTR, call_count_); +} + +ChannelData::ChannelData(grpc_channel_element* elem, + grpc_channel_element_args* args, grpc_error** error) + : elem_(elem), + channel_stack_(args->channel_stack), + client_idle_timeout_(GetClientIdleTimeout(args->channel_args)), + call_count_(0) { + // If the idle filter is explicitly disabled in channel args, this ctor should + // not get called. + GPR_ASSERT(client_idle_timeout_ != GRPC_MILLIS_INF_FUTURE); + GRPC_IDLE_FILTER_LOG("created with max_leisure_time = %" PRId64 " ms", + client_idle_timeout_); + // Initialize the idle timer without setting it. + grpc_timer_init_unset(&idle_timer_); + // Initialize the idle timer callback closure. + GRPC_CLOSURE_INIT(&idle_timer_callback_, IdleTimerCallback, this, + grpc_schedule_on_exec_ctx); + // Initialize the idle transport op complete callback. + GRPC_CLOSURE_INIT(&idle_transport_op_complete_callback_, + IdleTransportOpCompleteCallback, this, + grpc_schedule_on_exec_ctx); +} + +void ChannelData::IdleTimerCallback(void* arg, grpc_error* error) { + GRPC_IDLE_FILTER_LOG("timer alarms"); + ChannelData* chand = static_cast(arg); + { + MutexLock lock(&chand->call_count_mu_); + if (error == GRPC_ERROR_NONE && chand->call_count_ == 0) { + chand->EnterIdle(); + } + } + GRPC_IDLE_FILTER_LOG("timer finishes"); + GRPC_CHANNEL_STACK_UNREF(chand->channel_stack_, "max idle timer callback"); +} + +void ChannelData::IdleTransportOpCompleteCallback(void* arg, + grpc_error* error) { + ChannelData* chand = static_cast(arg); + GRPC_CHANNEL_STACK_UNREF(chand->channel_stack_, "idle transport op"); +} + +void ChannelData::StartIdleTimer() { + GRPC_IDLE_FILTER_LOG("timer has started"); + // Hold a ref to the channel stack for the timer callback. + GRPC_CHANNEL_STACK_REF(channel_stack_, "max idle timer callback"); + grpc_timer_init(&idle_timer_, ExecCtx::Get()->Now() + client_idle_timeout_, + &idle_timer_callback_); +} + +void ChannelData::EnterIdle() { + GRPC_IDLE_FILTER_LOG("the channel will enter IDLE"); + // Hold a ref to the channel stack for the transport op. + GRPC_CHANNEL_STACK_REF(channel_stack_, "idle transport op"); + // Initialize the transport op. + memset(&idle_transport_op_, 0, sizeof(idle_transport_op_)); + idle_transport_op_.disconnect_with_error = grpc_error_set_int( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("enter idle"), + GRPC_ERROR_INT_CHANNEL_CONNECTIVITY_STATE, GRPC_CHANNEL_IDLE); + idle_transport_op_.on_consumed = &idle_transport_op_complete_callback_; + // Pass the transport op down to the channel stack. + grpc_channel_next_op(elem_, &idle_transport_op_); +} + +class CallData { + public: + static grpc_error* Init(grpc_call_element* elem, + const grpc_call_element_args* args); + static void Destroy(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* then_schedule_closure); +}; + +grpc_error* CallData::Init(grpc_call_element* elem, + const grpc_call_element_args* args) { + ChannelData* chand = static_cast(elem->channel_data); + chand->IncreaseCallCount(); + return GRPC_ERROR_NONE; +} + +void CallData::Destroy(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) { + ChannelData* chand = static_cast(elem->channel_data); + chand->DecreaseCallCount(); +} + +const grpc_channel_filter grpc_client_idle_filter = { + grpc_call_next_op, + ChannelData::StartTransportOp, + sizeof(CallData), + CallData::Init, + grpc_call_stack_ignore_set_pollset_or_pollset_set, + CallData::Destroy, + sizeof(ChannelData), + ChannelData::Init, + ChannelData::Destroy, + grpc_channel_next_get_info, + "client_idle"}; + +static bool MaybeAddClientIdleFilter(grpc_channel_stack_builder* builder, + void* arg) { + const grpc_channel_args* channel_args = + grpc_channel_stack_builder_get_channel_arguments(builder); + if (!grpc_channel_args_want_minimal_stack(channel_args) && + GetClientIdleTimeout(channel_args) != INT_MAX) { + return grpc_channel_stack_builder_prepend_filter( + builder, &grpc_client_idle_filter, nullptr, nullptr); + } else { + return true; + } +} + +} // namespace +} // namespace grpc_core + +void grpc_client_idle_filter_init(void) { + grpc_channel_init_register_stage( + GRPC_CLIENT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, + grpc_core::MaybeAddClientIdleFilter, nullptr); +} + +void grpc_client_idle_filter_shutdown(void) {} diff --git a/src/core/ext/filters/max_age/max_age_filter.cc b/src/core/ext/filters/max_age/max_age_filter.cc index f2308581c13..c8823cc5c6a 100644 --- a/src/core/ext/filters/max_age/max_age_filter.cc +++ b/src/core/ext/filters/max_age/max_age_filter.cc @@ -47,7 +47,7 @@ namespace { struct channel_data { - /* We take a reference to the channel stack for the timer callback */ + /* The channel stack to which we take refs for pending callbacks. */ grpc_channel_stack* channel_stack; /* Guards access to max_age_timer, max_age_timer_pending, max_age_grace_timer and max_age_grace_timer_pending */ diff --git a/src/core/lib/iomgr/error.cc b/src/core/lib/iomgr/error.cc index eb44c9a2c90..dedc8376578 100644 --- a/src/core/lib/iomgr/error.cc +++ b/src/core/lib/iomgr/error.cc @@ -73,6 +73,8 @@ static const char* error_int_name(grpc_error_ints key) { return "limit"; case GRPC_ERROR_INT_OCCURRED_DURING_WRITE: return "occurred_during_write"; + case GRPC_ERROR_INT_CHANNEL_CONNECTIVITY_STATE: + return "channel_connectivity_state"; case GRPC_ERROR_INT_MAX: GPR_UNREACHABLE_CODE(return "unknown"); } diff --git a/src/core/lib/iomgr/error.h b/src/core/lib/iomgr/error.h index 0a72e5ca101..8c22357b951 100644 --- a/src/core/lib/iomgr/error.h +++ b/src/core/lib/iomgr/error.h @@ -73,6 +73,8 @@ typedef enum { GRPC_ERROR_INT_LIMIT, /// chttp2: did the error occur while a write was in progress GRPC_ERROR_INT_OCCURRED_DURING_WRITE, + /// channel connectivity state associated with the error + GRPC_ERROR_INT_CHANNEL_CONNECTIVITY_STATE, /// Must always be last GRPC_ERROR_INT_MAX, diff --git a/src/core/plugin_registry/grpc_plugin_registry.cc b/src/core/plugin_registry/grpc_plugin_registry.cc index cde40ef65cf..9b011d8df0f 100644 --- a/src/core/plugin_registry/grpc_plugin_registry.cc +++ b/src/core/plugin_registry/grpc_plugin_registry.cc @@ -46,6 +46,8 @@ void grpc_resolver_dns_native_init(void); void grpc_resolver_dns_native_shutdown(void); void grpc_resolver_sockaddr_init(void); void grpc_resolver_sockaddr_shutdown(void); +void grpc_client_idle_filter_init(void); +void grpc_client_idle_filter_shutdown(void); void grpc_max_age_filter_init(void); void grpc_max_age_filter_shutdown(void); void grpc_message_size_filter_init(void); @@ -82,6 +84,8 @@ void grpc_register_built_in_plugins(void) { grpc_resolver_dns_native_shutdown); grpc_register_plugin(grpc_resolver_sockaddr_init, grpc_resolver_sockaddr_shutdown); + grpc_register_plugin(grpc_client_idle_filter_init, + grpc_client_idle_filter_shutdown); grpc_register_plugin(grpc_max_age_filter_init, grpc_max_age_filter_shutdown); grpc_register_plugin(grpc_message_size_filter_init, diff --git a/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc b/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc index 5749ab6b954..055c3ccc134 100644 --- a/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc +++ b/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc @@ -46,6 +46,8 @@ void grpc_lb_policy_pick_first_init(void); void grpc_lb_policy_pick_first_shutdown(void); void grpc_lb_policy_round_robin_init(void); void grpc_lb_policy_round_robin_shutdown(void); +void grpc_client_idle_filter_init(void); +void grpc_client_idle_filter_shutdown(void); void grpc_max_age_filter_init(void); void grpc_max_age_filter_shutdown(void); void grpc_message_size_filter_init(void); @@ -82,6 +84,8 @@ void grpc_register_built_in_plugins(void) { grpc_lb_policy_pick_first_shutdown); grpc_register_plugin(grpc_lb_policy_round_robin_init, grpc_lb_policy_round_robin_shutdown); + grpc_register_plugin(grpc_client_idle_filter_init, + grpc_client_idle_filter_shutdown); grpc_register_plugin(grpc_max_age_filter_init, grpc_max_age_filter_shutdown); grpc_register_plugin(grpc_message_size_filter_init, diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 6a8b208b914..aab3768b02e 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -391,6 +391,7 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/census/grpc_context.cc', + 'src/core/ext/filters/client_idle/client_idle_filter.cc', 'src/core/ext/filters/max_age/max_age_filter.cc', 'src/core/ext/filters/message_size/message_size_filter.cc', 'src/core/ext/filters/http/client_authority_filter.cc', diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index 8fc0eacc2fc..dac7860141c 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -209,7 +209,6 @@ class ClientLbEnd2endTest : public ::testing::Test { // Explicitly destroy all the members so that we can make sure grpc_shutdown // has finished by the end of this function, and thus all the registered // LB policy factories are removed. - stub_.reset(); servers_.clear(); creds_.reset(); grpc_shutdown_blocking(); @@ -421,7 +420,6 @@ class ClientLbEnd2endTest : public ::testing::Test { } const grpc::string server_host_; - std::unique_ptr stub_; std::vector> servers_; const grpc::string kRequestMessage_; std::shared_ptr creds_; @@ -1467,6 +1465,32 @@ TEST_F(ClientLbEnd2endTest, RoundRobinWithHealthCheckingServiceNamePerChannel) { EnableDefaultHealthCheckService(false); } +TEST_F(ClientLbEnd2endTest, ChannelIdleness) { + // Start server. + const int kNumServers = 1; + StartServers(kNumServers); + // Set max idle time and build the channel. + ChannelArguments args; + args.SetInt(GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS, 100); + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("", response_generator, args); + auto stub = BuildStub(channel); + // The initial channel state should be IDLE. + EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_IDLE); + // After sending RPC, channel state should be READY. + response_generator.SetNextResolution(GetServersPorts()); + CheckRpcSendOk(stub, DEBUG_LOCATION); + EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); + // After a period time not using the channel, the channel state should switch + // to IDLE. + gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(120)); + EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_IDLE); + // Sending a new RPC should awake the IDLE channel. + response_generator.SetNextResolution(GetServersPorts()); + CheckRpcSendOk(stub, DEBUG_LOCATION); + EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); +} + class ClientLbInterceptTrailingMetadataTest : public ClientLbEnd2endTest { protected: void SetUp() override { diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 9bb01cb67f8..6c1253f7ae8 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -978,6 +978,7 @@ src/core/ext/filters/client_channel/subchannel.h \ src/core/ext/filters/client_channel/subchannel_interface.h \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.h \ +src/core/ext/filters/client_idle/client_idle_filter.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ src/core/ext/filters/deadline/deadline_filter.h \ src/core/ext/filters/http/client/http_client_filter.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index ceec3f0e6c3..179ce39407b 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -6680,6 +6680,7 @@ "gpr", "grpc_base", "grpc_client_authority_filter", + "grpc_client_idle_filter", "grpc_deadline_filter", "grpc_lb_policy_grpclb_secure", "grpc_lb_policy_pick_first", @@ -6772,6 +6773,7 @@ "gpr", "grpc_base", "grpc_client_authority_filter", + "grpc_client_idle_filter", "grpc_deadline_filter", "grpc_lb_policy_grpclb", "grpc_lb_policy_pick_first", @@ -9132,6 +9134,21 @@ "third_party": false, "type": "filegroup" }, + { + "deps": [ + "gpr", + "grpc_base" + ], + "headers": [], + "is_filegroup": true, + "language": "c", + "name": "grpc_client_idle_filter", + "src": [ + "src/core/ext/filters/client_idle/client_idle_filter.cc" + ], + "third_party": false, + "type": "filegroup" + }, { "deps": [ "gpr_codegen" From f78f3e4d6c712b92ff214b207c5221f3283a86e6 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Wed, 24 Jul 2019 10:36:51 -0700 Subject: [PATCH 0979/1555] Re-format --- src/core/lib/iomgr/executor/mpmcqueue.cc | 2 +- src/core/lib/iomgr/executor/mpmcqueue.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index 377a135e1f3..62226450a18 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -65,7 +65,7 @@ inline void* InfLenFIFOQueue::PopFront() { } InfLenFIFOQueue::Node* InfLenFIFOQueue::AllocateNodes(int num) { - num_nodes_ = num_nodes_ + num; + num_nodes_ = num_nodes_ + num; Node* new_chunk = static_cast(gpr_zalloc(sizeof(Node) * num)); new_chunk[0].next = &new_chunk[1]; new_chunk[num - 1].prev = &new_chunk[num - 2]; diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index 41e7e2a11be..0d44b7231d3 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -159,7 +159,7 @@ class InfLenFIFOQueue : public MPMCQueueInterface { Node* queue_head_ = nullptr; // Head of the queue, remove position Node* queue_tail_ = nullptr; // End of queue, insert position Atomic count_{0}; // Number of elements in queue - int num_nodes_ = 0; // Number of nodes allocated + int num_nodes_ = 0; // Number of nodes allocated Stats stats_; // Stats info gpr_timespec busy_time; // Start time of busy queue From d87b5285cab2959c65e8dc0ec6df120f3be3b1c3 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Wed, 24 Jul 2019 13:33:24 -0700 Subject: [PATCH 0980/1555] Fix comment --- test/cpp/microbenchmarks/bm_threadpool.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_threadpool.cc b/test/cpp/microbenchmarks/bm_threadpool.cc index c800fadf9d0..8b83aa2ed28 100644 --- a/test/cpp/microbenchmarks/bm_threadpool.cc +++ b/test/cpp/microbenchmarks/bm_threadpool.cc @@ -40,7 +40,7 @@ class BlockingCounter { void DecrementCount() { std::lock_guard l(mu_); count_--; - if (count_ == 0) cv_.notify_one(); + if (count_ == 0) cv_.notify_all(); } void Wait() { @@ -70,7 +70,6 @@ class AddAnotherFunctor : public grpc_experimental_completion_queue_functor { internal_next = this; internal_success = 0; } - ~AddAnotherFunctor() {} // When the functor gets to run in thread pool, it will take itself as first // argument and internal_success as second one. static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { @@ -163,7 +162,7 @@ class SuicideFunctorForAdd : public grpc_experimental_completion_queue_functor { internal_next = this; internal_success = 0; } - ~SuicideFunctorForAdd() {} + static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { // On running, the first argument would be itself. auto* callback = static_cast(cb); @@ -215,10 +214,8 @@ class AddSelfFunctor : public grpc_experimental_completion_queue_functor { internal_next = this; internal_success = 0; } - ~AddSelfFunctor() {} - // When the functor gets to run in thread pool, it will take internal_next - // as first argument and internal_success as second one. Therefore, the - // first argument here would be the closure itself. + // When the functor gets to run in thread pool, it will take itself as first + // argument and internal_success as second one. static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { auto* callback = static_cast(cb); if (--callback->num_add_ > 0) { @@ -331,7 +328,6 @@ class ShortWorkFunctorForAdd internal_success = 0; val_ = 0; } - ~ShortWorkFunctorForAdd() {} static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { auto* callback = static_cast(cb); // Uses pad to avoid compiler complaining unused variable error. From e246a307d316b0468274b73b1b08cb277c888854 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 24 Jul 2019 13:36:31 -0700 Subject: [PATCH 0981/1555] more generator fix --- src/compiler/objective_c_generator.cc | 17 ++++++++++------- src/compiler/objective_c_plugin.cc | 22 ++++++++++++++-------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/compiler/objective_c_generator.cc b/src/compiler/objective_c_generator.cc index 5b2609f5b03..837113841a8 100644 --- a/src/compiler/objective_c_generator.cc +++ b/src/compiler/objective_c_generator.cc @@ -402,14 +402,17 @@ void PrintMethodImplementations(Printer* printer, } printer.Print("#pragma clang diagnostic pop\n\n"); + if (!generator_params.no_v1_compatibility) { + printer.Print( + "// Override superclass initializer to disallow different" + " package and service names.\n" + "- (instancetype)initWithHost:(NSString *)host\n" + " packageName:(NSString *)packageName\n" + " serviceName:(NSString *)serviceName {\n" + " return [self initWithHost:host];\n" + "}\n\n"); + } printer.Print( - "// Override superclass initializer to disallow different" - " package and service names.\n" - "- (instancetype)initWithHost:(NSString *)host\n" - " packageName:(NSString *)packageName\n" - " serviceName:(NSString *)serviceName {\n" - " return [self initWithHost:host];\n" - "}\n\n" "- (instancetype)initWithHost:(NSString *)host\n" " packageName:(NSString *)packageName\n" " serviceName:(NSString *)serviceName\n" diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index b46a50b81a1..21c68995cbb 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -105,17 +105,21 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string imports = LocalImport(file_name + ".pbobjc.h"); ::grpc::string system_imports = (generator_params.no_v1_compatibility ? SystemImport("ProtoRPC/ProtoService.h") : SystemImport("ProtoRPC/ProtoServiceLegacy.h")) + - (generator_params.no_v1_compatibility ? SystemImport("ProtoRPC/ProtoRPC.h") : SystemImport("ProtoRPC/ProtoRPCLegacy.h")) + - SystemImport("RxLibrary/GRXWriteable.h") + - SystemImport("RxLibrary/GRXWriter.h"); + (generator_params.no_v1_compatibility ? SystemImport("ProtoRPC/ProtoRPC.h") : SystemImport("ProtoRPC/ProtoRPCLegacy.h")); + if (!generator_params.no_v1_compatibility) { + system_imports += SystemImport("RxLibrary/GRXWriteable.h") + + SystemImport("RxLibrary/GRXWriter.h"); + } ::grpc::string forward_declarations = - "@class GRPCProtoCall;\n" "@class GRPCUnaryProtoCall;\n" "@class GRPCStreamingProtoCall;\n" "@class GRPCCallOptions;\n" - "@protocol GRPCProtoResponseHandler;\n" - "\n"; + "@protocol GRPCProtoResponseHandler;\n"; + if (!generator_params.no_v1_compatibility) { + forward_declarations += "@class GRPCProtoCall;\n"; + } + forward_declarations += "\n"; ::grpc::string class_declarations = grpc_objective_c_generator::GetAllMessageClasses(file); @@ -159,8 +163,10 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string imports = LocalImport(file_name + ".pbrpc.h") + LocalImport(file_name + ".pbobjc.h") + - (generator_params.no_v1_compatibility ? SystemImport("ProtoRPC/ProtoRPC.h") : SystemImport("ProtoRPC/ProtoRPCLegacy.h")) + - SystemImport("RxLibrary/GRXWriter+Immediate.h"); + (generator_params.no_v1_compatibility ? SystemImport("ProtoRPC/ProtoRPC.h") : SystemImport("ProtoRPC/ProtoRPCLegacy.h")); + if (!generator_params.no_v1_compatibility) { + imports += SystemImport("RxLibrary/GRXWriter+Immediate.h"); + } ::grpc::string class_imports; for (int i = 0; i < file->dependency_count(); i++) { From ded9f46c06ece6e8cd4db88fe4d48c7fbdb4e37b Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 24 Jul 2019 14:37:14 -0700 Subject: [PATCH 0982/1555] Refactored BUILD file to isolate cronet rules --- BUILD | 41 +- CMakeLists.txt | 581 +---------------- Makefile | 611 +----------------- bazel/grpc_build_system.bzl | 16 +- build.yaml | 26 +- gRPC-Core.podspec | 1 + include/grpcpp/security/credentials.h | 5 - include/grpcpp/security/credentials_impl.h | 3 - include/grpcpp/security/cronet_credentials.h | 33 + .../grpcpp/security/cronet_credentials_impl.h | 33 + src/core/ext/transport/cronet/BUILD | 65 ++ .../client/secure/cronet_channel_create.cc | 3 +- .../client/secure/cronet_channel_create.h | 39 ++ .../grpc_cronet_plugin_registry.cc | 9 +- .../cronet/transport/cronet_transport.cc | 1 + templates/gRPC-Core.podspec.template | 2 +- .../public_headers_must_be_c89.c.template | 4 +- third_party/BUILD | 1 - third_party/objective_c/Cronet/BUILD | 27 + .../generated/sources_and_headers.json | 28 +- 20 files changed, 222 insertions(+), 1307 deletions(-) create mode 100644 include/grpcpp/security/cronet_credentials.h create mode 100644 include/grpcpp/security/cronet_credentials_impl.h create mode 100644 src/core/ext/transport/cronet/BUILD create mode 100644 src/core/ext/transport/cronet/client/secure/cronet_channel_create.h rename src/core/{ => ext/transport/cronet}/plugin_registry/grpc_cronet_plugin_registry.cc (78%) create mode 100644 third_party/objective_c/Cronet/BUILD diff --git a/BUILD b/BUILD index 474fc053ad6..ac5ed963f22 100644 --- a/BUILD +++ b/BUILD @@ -136,7 +136,7 @@ GRPCXX_SRCS = [ "src/cpp/common/resource_quota_cc.cc", "src/cpp/common/rpc_method.cc", "src/cpp/common/version_cc.cc", - "src/cpp/common/validate_service_config.cc", + "src/cpp/common/validate_service_config.cc", "src/cpp/server/async_generic_service.cc", "src/cpp/server/channel_argument_option.cc", "src/cpp/server/create_default_thread_pool.cc", @@ -292,7 +292,7 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/support/sync_stream.h", "include/grpcpp/support/sync_stream_impl.h", "include/grpcpp/support/time.h", - "include/grpcpp/support/validate_service_config.h", + "include/grpcpp/support/validate_service_config.h", ] grpc_cc_library( @@ -341,20 +341,6 @@ grpc_cc_library( ], ) -grpc_cc_library( - name = "grpc_cronet", - srcs = [ - "src/core/lib/surface/init.cc", - "src/core/plugin_registry/grpc_cronet_plugin_registry.cc", - ], - language = "c++", - deps = [ - "grpc_base", - "grpc_http_filters", - "grpc_transport_chttp2_client_secure", - "grpc_transport_cronet_client_secure", - ], -) grpc_cc_library( name = "grpc++_public_hdrs", @@ -1823,29 +1809,6 @@ grpc_cc_library( ], ) -grpc_cc_library( - name = "grpc_transport_cronet_client_secure", - srcs = [ - "src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc", - "src/core/ext/transport/cronet/transport/cronet_api_dummy.cc", - "src/core/ext/transport/cronet/transport/cronet_transport.cc", - ], - hdrs = [ - "src/core/ext/transport/cronet/transport/cronet_transport.h", - "third_party/objective_c/Cronet/bidirectional_stream_c.h", - ], - language = "c++", - public_hdrs = [ - "include/grpc/grpc_cronet.h", - "include/grpc/grpc_security.h", - "include/grpc/grpc_security_constants.h", - ], - deps = [ - "grpc_base", - "grpc_transport_chttp2", - ], -) - grpc_cc_library( name = "grpc_transport_inproc", srcs = [ diff --git a/CMakeLists.txt b/CMakeLists.txt index 23305ce6fd9..43841b9c71e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1433,6 +1433,7 @@ endif() add_library(grpc_cronet + src/core/ext/transport/cronet/plugin_registry/grpc_cronet_plugin_registry.cc src/core/lib/surface/init.cc src/core/lib/avl/avl.cc src/core/lib/backoff/backoff.cc @@ -1734,7 +1735,6 @@ add_library(grpc_cronet src/core/tsi/ssl/session_cache/ssl_session_openssl.cc src/core/tsi/ssl_transport_security.cc src/core/tsi/transport_security_grpc.cc - src/core/plugin_registry/grpc_cronet_plugin_registry.cc ) if(WIN32 AND MSVC) @@ -3472,585 +3472,6 @@ endif (gRPC_BUILD_CODEGEN) endif (gRPC_BUILD_TESTS) -add_library(grpc++_cronet - src/cpp/client/cronet_credentials.cc - src/cpp/client/insecure_credentials.cc - src/cpp/common/insecure_create_auth_context.cc - src/cpp/server/insecure_server_credentials.cc - src/cpp/client/channel_cc.cc - src/cpp/client/client_context.cc - src/cpp/client/client_interceptor.cc - src/cpp/client/create_channel.cc - src/cpp/client/create_channel_internal.cc - src/cpp/client/create_channel_posix.cc - src/cpp/client/credentials_cc.cc - src/cpp/client/generic_stub.cc - src/cpp/common/alarm.cc - src/cpp/common/channel_arguments.cc - src/cpp/common/channel_filter.cc - src/cpp/common/completion_queue_cc.cc - src/cpp/common/core_codegen.cc - src/cpp/common/resource_quota_cc.cc - src/cpp/common/rpc_method.cc - src/cpp/common/validate_service_config.cc - src/cpp/common/version_cc.cc - src/cpp/server/async_generic_service.cc - src/cpp/server/channel_argument_option.cc - src/cpp/server/create_default_thread_pool.cc - src/cpp/server/dynamic_thread_pool.cc - src/cpp/server/external_connection_acceptor_impl.cc - src/cpp/server/health/default_health_check_service.cc - src/cpp/server/health/health_check_service.cc - src/cpp/server/health/health_check_service_server_builder_option.cc - src/cpp/server/server_builder.cc - src/cpp/server/server_cc.cc - src/cpp/server/server_context.cc - src/cpp/server/server_credentials.cc - src/cpp/server/server_posix.cc - src/cpp/thread_manager/thread_manager.cc - src/cpp/util/byte_buffer_cc.cc - src/cpp/util/status.cc - src/cpp/util/string_ref.cc - src/cpp/util/time_cc.cc - src/core/ext/filters/client_channel/health/health.pb.c - third_party/nanopb/pb_common.c - third_party/nanopb/pb_decode.c - third_party/nanopb/pb_encode.c - src/cpp/codegen/codegen_init.cc - src/core/ext/transport/chttp2/client/insecure/channel_create.cc - src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc - src/core/ext/transport/chttp2/client/authority.cc - src/core/ext/transport/chttp2/client/chttp2_connector.cc - src/core/ext/transport/chttp2/transport/bin_decoder.cc - src/core/ext/transport/chttp2/transport/bin_encoder.cc - src/core/ext/transport/chttp2/transport/chttp2_plugin.cc - src/core/ext/transport/chttp2/transport/chttp2_transport.cc - src/core/ext/transport/chttp2/transport/context_list.cc - src/core/ext/transport/chttp2/transport/flow_control.cc - src/core/ext/transport/chttp2/transport/frame_data.cc - src/core/ext/transport/chttp2/transport/frame_goaway.cc - src/core/ext/transport/chttp2/transport/frame_ping.cc - src/core/ext/transport/chttp2/transport/frame_rst_stream.cc - src/core/ext/transport/chttp2/transport/frame_settings.cc - src/core/ext/transport/chttp2/transport/frame_window_update.cc - src/core/ext/transport/chttp2/transport/hpack_encoder.cc - src/core/ext/transport/chttp2/transport/hpack_parser.cc - src/core/ext/transport/chttp2/transport/hpack_table.cc - src/core/ext/transport/chttp2/transport/http2_settings.cc - src/core/ext/transport/chttp2/transport/huffsyms.cc - src/core/ext/transport/chttp2/transport/incoming_metadata.cc - src/core/ext/transport/chttp2/transport/parsing.cc - src/core/ext/transport/chttp2/transport/stream_lists.cc - src/core/ext/transport/chttp2/transport/stream_map.cc - src/core/ext/transport/chttp2/transport/varint.cc - src/core/ext/transport/chttp2/transport/writing.cc - src/core/lib/avl/avl.cc - src/core/lib/backoff/backoff.cc - src/core/lib/channel/channel_args.cc - src/core/lib/channel/channel_stack.cc - src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_trace.cc - src/core/lib/channel/channelz.cc - src/core/lib/channel/channelz_registry.cc - src/core/lib/channel/connected_channel.cc - src/core/lib/channel/handshaker.cc - src/core/lib/channel/handshaker_registry.cc - src/core/lib/channel/status_util.cc - src/core/lib/compression/compression.cc - src/core/lib/compression/compression_args.cc - src/core/lib/compression/compression_internal.cc - src/core/lib/compression/message_compress.cc - src/core/lib/compression/stream_compression.cc - src/core/lib/compression/stream_compression_gzip.cc - src/core/lib/compression/stream_compression_identity.cc - src/core/lib/debug/stats.cc - src/core/lib/debug/stats_data.cc - src/core/lib/http/format_request.cc - src/core/lib/http/httpcli.cc - src/core/lib/http/parser.cc - src/core/lib/iomgr/buffer_list.cc - src/core/lib/iomgr/call_combiner.cc - src/core/lib/iomgr/cfstream_handle.cc - src/core/lib/iomgr/combiner.cc - src/core/lib/iomgr/endpoint.cc - src/core/lib/iomgr/endpoint_cfstream.cc - src/core/lib/iomgr/endpoint_pair_posix.cc - src/core/lib/iomgr/endpoint_pair_uv.cc - src/core/lib/iomgr/endpoint_pair_windows.cc - src/core/lib/iomgr/error.cc - src/core/lib/iomgr/error_cfstream.cc - src/core/lib/iomgr/ev_epoll1_linux.cc - src/core/lib/iomgr/ev_epollex_linux.cc - src/core/lib/iomgr/ev_poll_posix.cc - src/core/lib/iomgr/ev_posix.cc - src/core/lib/iomgr/ev_windows.cc - src/core/lib/iomgr/exec_ctx.cc - src/core/lib/iomgr/executor.cc - src/core/lib/iomgr/executor/mpmcqueue.cc - src/core/lib/iomgr/executor/threadpool.cc - src/core/lib/iomgr/fork_posix.cc - src/core/lib/iomgr/fork_windows.cc - src/core/lib/iomgr/gethostname_fallback.cc - src/core/lib/iomgr/gethostname_host_name_max.cc - src/core/lib/iomgr/gethostname_sysconf.cc - src/core/lib/iomgr/grpc_if_nametoindex_posix.cc - src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc - src/core/lib/iomgr/internal_errqueue.cc - src/core/lib/iomgr/iocp_windows.cc - src/core/lib/iomgr/iomgr.cc - src/core/lib/iomgr/iomgr_custom.cc - src/core/lib/iomgr/iomgr_internal.cc - src/core/lib/iomgr/iomgr_posix.cc - src/core/lib/iomgr/iomgr_posix_cfstream.cc - src/core/lib/iomgr/iomgr_uv.cc - src/core/lib/iomgr/iomgr_windows.cc - src/core/lib/iomgr/is_epollexclusive_available.cc - src/core/lib/iomgr/load_file.cc - src/core/lib/iomgr/lockfree_event.cc - src/core/lib/iomgr/polling_entity.cc - src/core/lib/iomgr/pollset.cc - src/core/lib/iomgr/pollset_custom.cc - src/core/lib/iomgr/pollset_set.cc - src/core/lib/iomgr/pollset_set_custom.cc - src/core/lib/iomgr/pollset_set_windows.cc - src/core/lib/iomgr/pollset_uv.cc - src/core/lib/iomgr/pollset_windows.cc - src/core/lib/iomgr/resolve_address.cc - src/core/lib/iomgr/resolve_address_custom.cc - src/core/lib/iomgr/resolve_address_posix.cc - src/core/lib/iomgr/resolve_address_windows.cc - src/core/lib/iomgr/resource_quota.cc - src/core/lib/iomgr/sockaddr_utils.cc - src/core/lib/iomgr/socket_factory_posix.cc - src/core/lib/iomgr/socket_mutator.cc - src/core/lib/iomgr/socket_utils_common_posix.cc - src/core/lib/iomgr/socket_utils_linux.cc - src/core/lib/iomgr/socket_utils_posix.cc - src/core/lib/iomgr/socket_utils_uv.cc - src/core/lib/iomgr/socket_utils_windows.cc - src/core/lib/iomgr/socket_windows.cc - src/core/lib/iomgr/tcp_client.cc - src/core/lib/iomgr/tcp_client_cfstream.cc - src/core/lib/iomgr/tcp_client_custom.cc - src/core/lib/iomgr/tcp_client_posix.cc - src/core/lib/iomgr/tcp_client_windows.cc - src/core/lib/iomgr/tcp_custom.cc - src/core/lib/iomgr/tcp_posix.cc - src/core/lib/iomgr/tcp_server.cc - src/core/lib/iomgr/tcp_server_custom.cc - src/core/lib/iomgr/tcp_server_posix.cc - src/core/lib/iomgr/tcp_server_utils_posix_common.cc - src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc - src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc - src/core/lib/iomgr/tcp_server_windows.cc - src/core/lib/iomgr/tcp_uv.cc - src/core/lib/iomgr/tcp_windows.cc - src/core/lib/iomgr/time_averaged_stats.cc - src/core/lib/iomgr/timer.cc - src/core/lib/iomgr/timer_custom.cc - src/core/lib/iomgr/timer_generic.cc - src/core/lib/iomgr/timer_heap.cc - src/core/lib/iomgr/timer_manager.cc - src/core/lib/iomgr/timer_uv.cc - src/core/lib/iomgr/udp_server.cc - src/core/lib/iomgr/unix_sockets_posix.cc - src/core/lib/iomgr/unix_sockets_posix_noop.cc - src/core/lib/iomgr/wakeup_fd_eventfd.cc - src/core/lib/iomgr/wakeup_fd_nospecial.cc - src/core/lib/iomgr/wakeup_fd_pipe.cc - src/core/lib/iomgr/wakeup_fd_posix.cc - src/core/lib/json/json.cc - src/core/lib/json/json_reader.cc - src/core/lib/json/json_string.cc - src/core/lib/json/json_writer.cc - src/core/lib/slice/b64.cc - src/core/lib/slice/percent_encoding.cc - src/core/lib/slice/slice.cc - src/core/lib/slice/slice_buffer.cc - src/core/lib/slice/slice_intern.cc - src/core/lib/slice/slice_string_helpers.cc - src/core/lib/surface/api_trace.cc - src/core/lib/surface/byte_buffer.cc - src/core/lib/surface/byte_buffer_reader.cc - src/core/lib/surface/call.cc - src/core/lib/surface/call_details.cc - src/core/lib/surface/call_log_batch.cc - src/core/lib/surface/channel.cc - src/core/lib/surface/channel_init.cc - src/core/lib/surface/channel_ping.cc - src/core/lib/surface/channel_stack_type.cc - src/core/lib/surface/completion_queue.cc - src/core/lib/surface/completion_queue_factory.cc - src/core/lib/surface/event_string.cc - src/core/lib/surface/lame_client.cc - src/core/lib/surface/metadata_array.cc - src/core/lib/surface/server.cc - src/core/lib/surface/validate_metadata.cc - src/core/lib/surface/version.cc - src/core/lib/transport/bdp_estimator.cc - src/core/lib/transport/byte_stream.cc - src/core/lib/transport/connectivity_state.cc - src/core/lib/transport/error_utils.cc - src/core/lib/transport/metadata.cc - src/core/lib/transport/metadata_batch.cc - src/core/lib/transport/pid_controller.cc - src/core/lib/transport/static_metadata.cc - src/core/lib/transport/status_conversion.cc - src/core/lib/transport/status_metadata.cc - src/core/lib/transport/timeout_encoding.cc - src/core/lib/transport/transport.cc - src/core/lib/transport/transport_op_string.cc - src/core/lib/uri/uri_parser.cc - src/core/lib/debug/trace.cc - src/core/ext/transport/chttp2/alpn/alpn.cc - src/core/ext/filters/http/client/http_client_filter.cc - src/core/ext/filters/http/http_filters_plugin.cc - src/core/ext/filters/http/message_compress/message_compress_filter.cc - src/core/ext/filters/http/server/http_server_filter.cc - src/core/ext/filters/client_channel/backup_poller.cc - src/core/ext/filters/client_channel/channel_connectivity.cc - src/core/ext/filters/client_channel/client_channel.cc - src/core/ext/filters/client_channel/client_channel_channelz.cc - src/core/ext/filters/client_channel/client_channel_factory.cc - src/core/ext/filters/client_channel/client_channel_plugin.cc - src/core/ext/filters/client_channel/connector.cc - src/core/ext/filters/client_channel/global_subchannel_pool.cc - src/core/ext/filters/client_channel/health/health_check_client.cc - src/core/ext/filters/client_channel/http_connect_handshaker.cc - src/core/ext/filters/client_channel/http_proxy.cc - src/core/ext/filters/client_channel/lb_policy.cc - src/core/ext/filters/client_channel/lb_policy_registry.cc - src/core/ext/filters/client_channel/local_subchannel_pool.cc - src/core/ext/filters/client_channel/parse_address.cc - src/core/ext/filters/client_channel/proxy_mapper.cc - src/core/ext/filters/client_channel/proxy_mapper_registry.cc - src/core/ext/filters/client_channel/resolver.cc - src/core/ext/filters/client_channel/resolver_registry.cc - src/core/ext/filters/client_channel/resolver_result_parsing.cc - src/core/ext/filters/client_channel/resolving_lb_policy.cc - src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/server_address.cc - src/core/ext/filters/client_channel/service_config.cc - src/core/ext/filters/client_channel/subchannel.cc - src/core/ext/filters/client_channel/subchannel_pool_interface.cc - src/core/ext/filters/deadline/deadline_filter.cc - src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc - src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc - src/core/ext/transport/chttp2/server/chttp2_server.cc - src/core/ext/filters/census/grpc_context.cc -) - -if(WIN32 AND MSVC) - set_target_properties(grpc++_cronet PROPERTIES COMPILE_PDB_NAME "grpc++_cronet" - COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" - ) - if (gRPC_INSTALL) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_cronet.pdb - DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL - ) - endif() -endif() - - -target_include_directories(grpc++_cronet - PUBLIC $ $ - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTO_GENS_DIR} -) -target_link_libraries(grpc++_cronet - ${_gRPC_BASELIB_LIBRARIES} - ${_gRPC_SSL_LIBRARIES} - ${_gRPC_PROTOBUF_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} - gpr - grpc_cronet - grpc -) -if (_gRPC_PLATFORM_IOS OR _gRPC_PLATFORM_MAC) - target_link_libraries(grpc++_cronet "-framework CoreFoundation") -endif() - -foreach(_hdr - include/grpc++/alarm.h - include/grpc++/channel.h - include/grpc++/client_context.h - include/grpc++/completion_queue.h - include/grpc++/create_channel.h - include/grpc++/create_channel_posix.h - include/grpc++/ext/health_check_service_server_builder_option.h - include/grpc++/generic/async_generic_service.h - include/grpc++/generic/generic_stub.h - include/grpc++/grpc++.h - include/grpc++/health_check_service_interface.h - include/grpc++/impl/call.h - include/grpc++/impl/channel_argument_option.h - include/grpc++/impl/client_unary_call.h - include/grpc++/impl/codegen/core_codegen.h - include/grpc++/impl/grpc_library.h - include/grpc++/impl/method_handler_impl.h - include/grpc++/impl/rpc_method.h - include/grpc++/impl/rpc_service_method.h - include/grpc++/impl/serialization_traits.h - include/grpc++/impl/server_builder_option.h - include/grpc++/impl/server_builder_plugin.h - include/grpc++/impl/server_initializer.h - include/grpc++/impl/service_type.h - include/grpc++/resource_quota.h - include/grpc++/security/auth_context.h - include/grpc++/security/auth_metadata_processor.h - include/grpc++/security/credentials.h - include/grpc++/security/server_credentials.h - include/grpc++/server.h - include/grpc++/server_builder.h - include/grpc++/server_context.h - include/grpc++/server_posix.h - include/grpc++/support/async_stream.h - include/grpc++/support/async_unary_call.h - include/grpc++/support/byte_buffer.h - include/grpc++/support/channel_arguments.h - include/grpc++/support/config.h - include/grpc++/support/slice.h - include/grpc++/support/status.h - include/grpc++/support/status_code_enum.h - include/grpc++/support/string_ref.h - include/grpc++/support/stub_options.h - include/grpc++/support/sync_stream.h - include/grpc++/support/time.h - include/grpcpp/alarm.h - include/grpcpp/alarm_impl.h - include/grpcpp/channel.h - include/grpcpp/channel_impl.h - include/grpcpp/client_context.h - include/grpcpp/completion_queue.h - include/grpcpp/completion_queue_impl.h - include/grpcpp/create_channel.h - include/grpcpp/create_channel_impl.h - include/grpcpp/create_channel_posix.h - include/grpcpp/create_channel_posix_impl.h - include/grpcpp/ext/health_check_service_server_builder_option.h - include/grpcpp/generic/async_generic_service.h - include/grpcpp/generic/generic_stub.h - include/grpcpp/generic/generic_stub_impl.h - include/grpcpp/grpcpp.h - include/grpcpp/health_check_service_interface.h - include/grpcpp/health_check_service_interface_impl.h - include/grpcpp/impl/call.h - include/grpcpp/impl/channel_argument_option.h - include/grpcpp/impl/client_unary_call.h - include/grpcpp/impl/codegen/core_codegen.h - include/grpcpp/impl/grpc_library.h - include/grpcpp/impl/method_handler_impl.h - include/grpcpp/impl/rpc_method.h - include/grpcpp/impl/rpc_service_method.h - include/grpcpp/impl/serialization_traits.h - include/grpcpp/impl/server_builder_option.h - include/grpcpp/impl/server_builder_option_impl.h - include/grpcpp/impl/server_builder_plugin.h - include/grpcpp/impl/server_initializer.h - include/grpcpp/impl/server_initializer_impl.h - include/grpcpp/impl/service_type.h - include/grpcpp/resource_quota.h - include/grpcpp/resource_quota_impl.h - include/grpcpp/security/auth_context.h - include/grpcpp/security/auth_metadata_processor.h - include/grpcpp/security/auth_metadata_processor_impl.h - include/grpcpp/security/credentials.h - include/grpcpp/security/credentials_impl.h - include/grpcpp/security/server_credentials.h - include/grpcpp/security/server_credentials_impl.h - include/grpcpp/server.h - include/grpcpp/server_builder.h - include/grpcpp/server_builder_impl.h - include/grpcpp/server_context.h - include/grpcpp/server_impl.h - include/grpcpp/server_posix.h - include/grpcpp/server_posix_impl.h - include/grpcpp/support/async_stream.h - include/grpcpp/support/async_stream_impl.h - include/grpcpp/support/async_unary_call.h - include/grpcpp/support/async_unary_call_impl.h - include/grpcpp/support/byte_buffer.h - include/grpcpp/support/channel_arguments.h - include/grpcpp/support/channel_arguments_impl.h - include/grpcpp/support/client_callback.h - include/grpcpp/support/client_callback_impl.h - include/grpcpp/support/client_interceptor.h - include/grpcpp/support/config.h - include/grpcpp/support/interceptor.h - include/grpcpp/support/message_allocator.h - include/grpcpp/support/proto_buffer_reader.h - include/grpcpp/support/proto_buffer_writer.h - include/grpcpp/support/server_callback.h - include/grpcpp/support/server_callback_impl.h - include/grpcpp/support/server_interceptor.h - include/grpcpp/support/slice.h - include/grpcpp/support/status.h - include/grpcpp/support/status_code_enum.h - include/grpcpp/support/string_ref.h - include/grpcpp/support/stub_options.h - include/grpcpp/support/sync_stream.h - include/grpcpp/support/sync_stream_impl.h - include/grpcpp/support/time.h - include/grpcpp/support/validate_service_config.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_windows.h - include/grpc/support/cpu.h - include/grpc/support/log.h - include/grpc/support/log_windows.h - include/grpc/support/port_platform.h - include/grpc/support/string_util.h - include/grpc/support/sync.h - include/grpc/support/sync_custom.h - include/grpc/support/sync_generic.h - include/grpc/support/sync_posix.h - include/grpc/support/sync_windows.h - include/grpc/support/thd_id.h - include/grpc/support/time.h - include/grpc/impl/codegen/atm.h - include/grpc/impl/codegen/atm_gcc_atomic.h - include/grpc/impl/codegen/atm_gcc_sync.h - include/grpc/impl/codegen/atm_windows.h - include/grpc/impl/codegen/fork.h - include/grpc/impl/codegen/gpr_slice.h - include/grpc/impl/codegen/gpr_types.h - include/grpc/impl/codegen/log.h - include/grpc/impl/codegen/port_platform.h - include/grpc/impl/codegen/sync.h - include/grpc/impl/codegen/sync_custom.h - include/grpc/impl/codegen/sync_generic.h - include/grpc/impl/codegen/sync_posix.h - include/grpc/impl/codegen/sync_windows.h - include/grpc/byte_buffer.h - include/grpc/byte_buffer_reader.h - include/grpc/compression.h - include/grpc/fork.h - include/grpc/grpc.h - include/grpc/grpc_posix.h - include/grpc/grpc_security_constants.h - include/grpc/load_reporting.h - include/grpc/slice.h - include/grpc/slice_buffer.h - include/grpc/status.h - include/grpc/support/workaround_list.h - include/grpc/impl/codegen/byte_buffer.h - include/grpc/impl/codegen/byte_buffer_reader.h - include/grpc/impl/codegen/compression_types.h - include/grpc/impl/codegen/connectivity_state.h - include/grpc/impl/codegen/grpc_types.h - include/grpc/impl/codegen/propagation_bits.h - include/grpc/impl/codegen/slice.h - include/grpc/impl/codegen/status.h - include/grpc++/impl/codegen/async_stream.h - include/grpc++/impl/codegen/async_unary_call.h - include/grpc++/impl/codegen/byte_buffer.h - include/grpc++/impl/codegen/call.h - include/grpc++/impl/codegen/call_hook.h - include/grpc++/impl/codegen/channel_interface.h - include/grpc++/impl/codegen/client_context.h - include/grpc++/impl/codegen/client_unary_call.h - include/grpc++/impl/codegen/completion_queue.h - include/grpc++/impl/codegen/completion_queue_tag.h - include/grpc++/impl/codegen/config.h - include/grpc++/impl/codegen/core_codegen_interface.h - include/grpc++/impl/codegen/create_auth_context.h - include/grpc++/impl/codegen/grpc_library.h - include/grpc++/impl/codegen/metadata_map.h - include/grpc++/impl/codegen/method_handler_impl.h - include/grpc++/impl/codegen/rpc_method.h - include/grpc++/impl/codegen/rpc_service_method.h - include/grpc++/impl/codegen/security/auth_context.h - include/grpc++/impl/codegen/serialization_traits.h - include/grpc++/impl/codegen/server_context.h - include/grpc++/impl/codegen/server_interface.h - include/grpc++/impl/codegen/service_type.h - include/grpc++/impl/codegen/slice.h - include/grpc++/impl/codegen/status.h - include/grpc++/impl/codegen/status_code_enum.h - include/grpc++/impl/codegen/string_ref.h - include/grpc++/impl/codegen/stub_options.h - include/grpc++/impl/codegen/sync_stream.h - include/grpc++/impl/codegen/time.h - include/grpcpp/impl/codegen/async_generic_service.h - include/grpcpp/impl/codegen/async_stream.h - include/grpcpp/impl/codegen/async_stream_impl.h - include/grpcpp/impl/codegen/async_unary_call.h - include/grpcpp/impl/codegen/async_unary_call_impl.h - include/grpcpp/impl/codegen/byte_buffer.h - include/grpcpp/impl/codegen/call.h - include/grpcpp/impl/codegen/call_hook.h - include/grpcpp/impl/codegen/call_op_set.h - include/grpcpp/impl/codegen/call_op_set_interface.h - include/grpcpp/impl/codegen/callback_common.h - include/grpcpp/impl/codegen/channel_interface.h - include/grpcpp/impl/codegen/client_callback.h - include/grpcpp/impl/codegen/client_callback_impl.h - include/grpcpp/impl/codegen/client_context.h - include/grpcpp/impl/codegen/client_context_impl.h - include/grpcpp/impl/codegen/client_interceptor.h - include/grpcpp/impl/codegen/client_unary_call.h - include/grpcpp/impl/codegen/completion_queue.h - include/grpcpp/impl/codegen/completion_queue_impl.h - include/grpcpp/impl/codegen/completion_queue_tag.h - include/grpcpp/impl/codegen/config.h - include/grpcpp/impl/codegen/core_codegen_interface.h - include/grpcpp/impl/codegen/create_auth_context.h - include/grpcpp/impl/codegen/grpc_library.h - include/grpcpp/impl/codegen/intercepted_channel.h - include/grpcpp/impl/codegen/interceptor.h - include/grpcpp/impl/codegen/interceptor_common.h - include/grpcpp/impl/codegen/message_allocator.h - include/grpcpp/impl/codegen/metadata_map.h - include/grpcpp/impl/codegen/method_handler_impl.h - include/grpcpp/impl/codegen/rpc_method.h - include/grpcpp/impl/codegen/rpc_service_method.h - include/grpcpp/impl/codegen/security/auth_context.h - include/grpcpp/impl/codegen/serialization_traits.h - include/grpcpp/impl/codegen/server_callback.h - include/grpcpp/impl/codegen/server_callback_impl.h - include/grpcpp/impl/codegen/server_context.h - include/grpcpp/impl/codegen/server_context_impl.h - include/grpcpp/impl/codegen/server_interceptor.h - include/grpcpp/impl/codegen/server_interface.h - include/grpcpp/impl/codegen/service_type.h - include/grpcpp/impl/codegen/slice.h - include/grpcpp/impl/codegen/status.h - include/grpcpp/impl/codegen/status_code_enum.h - include/grpcpp/impl/codegen/string_ref.h - include/grpcpp/impl/codegen/stub_options.h - include/grpcpp/impl/codegen/sync_stream.h - include/grpcpp/impl/codegen/sync_stream_impl.h - include/grpcpp/impl/codegen/time.h - include/grpcpp/impl/codegen/sync.h - include/grpc/census.h -) - string(REPLACE "include/" "" _path ${_hdr}) - get_filename_component(_path ${_path} PATH) - install(FILES ${_hdr} - DESTINATION "${gRPC_INSTALL_INCLUDEDIR}/${_path}" - ) -endforeach() - - -if (gRPC_INSTALL) - install(TARGETS grpc++_cronet EXPORT gRPCTargets - RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} - LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} - ) -endif() - - if (gRPC_BUILD_CODEGEN) add_library(grpc++_error_details ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/status/status.pb.cc diff --git a/Makefile b/Makefile index 4755955de7d..b30bee1ce11 100644 --- a/Makefile +++ b/Makefile @@ -1398,14 +1398,14 @@ static: static_c static_cxx static_c: pc_c pc_c_unsecure cache.mk $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgrpc_cronet.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a -static_cxx: pc_cxx pc_cxx_unsecure cache.mk $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc++_cronet.a $(LIBDIR)/$(CONFIG)/libgrpc++_error_details.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpcpp_channelz.a +static_cxx: pc_cxx pc_cxx_unsecure cache.mk $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc++_error_details.a $(LIBDIR)/$(CONFIG)/libgrpc++_reflection.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpcpp_channelz.a static_csharp: static_c $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.a shared: shared_c shared_cxx shared_c: pc_c pc_c_unsecure cache.mk $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -shared_cxx: pc_cxx pc_cxx_unsecure cache.mk $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_error_details$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpcpp_channelz$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) +shared_cxx: pc_cxx pc_cxx_unsecure cache.mk $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_error_details$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpcpp_channelz$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) shared_csharp: shared_c $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) grpc_csharp_ext: shared_csharp @@ -2563,8 +2563,6 @@ strip-static_cxx: static_cxx ifeq ($(CONFIG),opt) $(E) "[STRIP] Stripping libgrpc++.a" $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/libgrpc++.a - $(E) "[STRIP] Stripping libgrpc++_cronet.a" - $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/libgrpc++_cronet.a $(E) "[STRIP] Stripping libgrpc++_error_details.a" $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/libgrpc++_error_details.a $(E) "[STRIP] Stripping libgrpc++_reflection.a" @@ -2593,8 +2591,6 @@ strip-shared_cxx: shared_cxx ifeq ($(CONFIG),opt) $(E) "[STRIP] Stripping $(SHARED_PREFIX)grpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)" $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) - $(E) "[STRIP] Stripping $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)" - $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(E) "[STRIP] Stripping $(SHARED_PREFIX)grpc++_error_details$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)" $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_error_details$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(E) "[STRIP] Stripping $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)" @@ -3071,9 +3067,6 @@ install-static_cxx: static_cxx strip-static_cxx install-pkg-config_cxx $(E) "[INSTALL] Installing libgrpc++.a" $(Q) $(INSTALL) -d $(prefix)/lib $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++.a $(prefix)/lib/libgrpc++.a - $(E) "[INSTALL] Installing libgrpc++_cronet.a" - $(Q) $(INSTALL) -d $(prefix)/lib - $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++_cronet.a $(prefix)/lib/libgrpc++_cronet.a $(E) "[INSTALL] Installing libgrpc++_error_details.a" $(Q) $(INSTALL) -d $(prefix)/lib $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++_error_details.a $(prefix)/lib/libgrpc++_error_details.a @@ -3151,15 +3144,6 @@ ifeq ($(SYSTEM),MINGW32) else ifneq ($(SYSTEM),Darwin) $(Q) ln -sf $(SHARED_PREFIX)grpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++.so.1 $(Q) ln -sf $(SHARED_PREFIX)grpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++.so -endif - $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)" - $(Q) $(INSTALL) -d $(prefix)/lib - $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/$(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) -ifeq ($(SYSTEM),MINGW32) - $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP)-dll.a $(prefix)/lib/libgrpc++_cronet.a -else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_cronet.so.1 - $(Q) ln -sf $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_cronet.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc++_error_details$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)" $(Q) $(INSTALL) -d $(prefix)/lib @@ -3941,6 +3925,7 @@ endif LIBGRPC_CRONET_SRC = \ + src/core/ext/transport/cronet/plugin_registry/grpc_cronet_plugin_registry.cc \ src/core/lib/surface/init.cc \ src/core/lib/avl/avl.cc \ src/core/lib/backoff/backoff.cc \ @@ -4242,7 +4227,6 @@ LIBGRPC_CRONET_SRC = \ src/core/tsi/ssl/session_cache/ssl_session_openssl.cc \ src/core/tsi/ssl_transport_security.cc \ src/core/tsi/transport_security_grpc.cc \ - src/core/plugin_registry/grpc_cronet_plugin_registry.cc \ PUBLIC_HEADERS_C += \ include/grpc/impl/codegen/byte_buffer.h \ @@ -5895,592 +5879,6 @@ endif $(OBJDIR)/$(CONFIG)/src/cpp/util/core_stats.o: $(GENDIR)/src/proto/grpc/core/stats.pb.cc $(GENDIR)/src/proto/grpc/core/stats.grpc.pb.cc -LIBGRPC++_CRONET_SRC = \ - src/cpp/client/cronet_credentials.cc \ - src/cpp/client/insecure_credentials.cc \ - src/cpp/common/insecure_create_auth_context.cc \ - src/cpp/server/insecure_server_credentials.cc \ - src/cpp/client/channel_cc.cc \ - src/cpp/client/client_context.cc \ - src/cpp/client/client_interceptor.cc \ - src/cpp/client/create_channel.cc \ - src/cpp/client/create_channel_internal.cc \ - src/cpp/client/create_channel_posix.cc \ - src/cpp/client/credentials_cc.cc \ - src/cpp/client/generic_stub.cc \ - src/cpp/common/alarm.cc \ - src/cpp/common/channel_arguments.cc \ - src/cpp/common/channel_filter.cc \ - src/cpp/common/completion_queue_cc.cc \ - src/cpp/common/core_codegen.cc \ - src/cpp/common/resource_quota_cc.cc \ - src/cpp/common/rpc_method.cc \ - src/cpp/common/validate_service_config.cc \ - src/cpp/common/version_cc.cc \ - src/cpp/server/async_generic_service.cc \ - src/cpp/server/channel_argument_option.cc \ - src/cpp/server/create_default_thread_pool.cc \ - src/cpp/server/dynamic_thread_pool.cc \ - src/cpp/server/external_connection_acceptor_impl.cc \ - src/cpp/server/health/default_health_check_service.cc \ - src/cpp/server/health/health_check_service.cc \ - src/cpp/server/health/health_check_service_server_builder_option.cc \ - src/cpp/server/server_builder.cc \ - src/cpp/server/server_cc.cc \ - src/cpp/server/server_context.cc \ - src/cpp/server/server_credentials.cc \ - src/cpp/server/server_posix.cc \ - src/cpp/thread_manager/thread_manager.cc \ - src/cpp/util/byte_buffer_cc.cc \ - src/cpp/util/status.cc \ - src/cpp/util/string_ref.cc \ - src/cpp/util/time_cc.cc \ - src/core/ext/filters/client_channel/health/health.pb.c \ - third_party/nanopb/pb_common.c \ - third_party/nanopb/pb_decode.c \ - third_party/nanopb/pb_encode.c \ - src/cpp/codegen/codegen_init.cc \ - src/core/ext/transport/chttp2/client/insecure/channel_create.cc \ - src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \ - src/core/ext/transport/chttp2/client/authority.cc \ - src/core/ext/transport/chttp2/client/chttp2_connector.cc \ - src/core/ext/transport/chttp2/transport/bin_decoder.cc \ - src/core/ext/transport/chttp2/transport/bin_encoder.cc \ - src/core/ext/transport/chttp2/transport/chttp2_plugin.cc \ - src/core/ext/transport/chttp2/transport/chttp2_transport.cc \ - src/core/ext/transport/chttp2/transport/context_list.cc \ - src/core/ext/transport/chttp2/transport/flow_control.cc \ - src/core/ext/transport/chttp2/transport/frame_data.cc \ - src/core/ext/transport/chttp2/transport/frame_goaway.cc \ - src/core/ext/transport/chttp2/transport/frame_ping.cc \ - src/core/ext/transport/chttp2/transport/frame_rst_stream.cc \ - src/core/ext/transport/chttp2/transport/frame_settings.cc \ - src/core/ext/transport/chttp2/transport/frame_window_update.cc \ - src/core/ext/transport/chttp2/transport/hpack_encoder.cc \ - src/core/ext/transport/chttp2/transport/hpack_parser.cc \ - src/core/ext/transport/chttp2/transport/hpack_table.cc \ - src/core/ext/transport/chttp2/transport/http2_settings.cc \ - src/core/ext/transport/chttp2/transport/huffsyms.cc \ - src/core/ext/transport/chttp2/transport/incoming_metadata.cc \ - src/core/ext/transport/chttp2/transport/parsing.cc \ - src/core/ext/transport/chttp2/transport/stream_lists.cc \ - src/core/ext/transport/chttp2/transport/stream_map.cc \ - src/core/ext/transport/chttp2/transport/varint.cc \ - src/core/ext/transport/chttp2/transport/writing.cc \ - src/core/lib/avl/avl.cc \ - src/core/lib/backoff/backoff.cc \ - src/core/lib/channel/channel_args.cc \ - src/core/lib/channel/channel_stack.cc \ - src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_trace.cc \ - src/core/lib/channel/channelz.cc \ - src/core/lib/channel/channelz_registry.cc \ - src/core/lib/channel/connected_channel.cc \ - src/core/lib/channel/handshaker.cc \ - src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/status_util.cc \ - src/core/lib/compression/compression.cc \ - src/core/lib/compression/compression_args.cc \ - src/core/lib/compression/compression_internal.cc \ - src/core/lib/compression/message_compress.cc \ - src/core/lib/compression/stream_compression.cc \ - src/core/lib/compression/stream_compression_gzip.cc \ - src/core/lib/compression/stream_compression_identity.cc \ - src/core/lib/debug/stats.cc \ - src/core/lib/debug/stats_data.cc \ - src/core/lib/http/format_request.cc \ - src/core/lib/http/httpcli.cc \ - src/core/lib/http/parser.cc \ - src/core/lib/iomgr/buffer_list.cc \ - src/core/lib/iomgr/call_combiner.cc \ - src/core/lib/iomgr/cfstream_handle.cc \ - src/core/lib/iomgr/combiner.cc \ - src/core/lib/iomgr/endpoint.cc \ - src/core/lib/iomgr/endpoint_cfstream.cc \ - src/core/lib/iomgr/endpoint_pair_posix.cc \ - src/core/lib/iomgr/endpoint_pair_uv.cc \ - src/core/lib/iomgr/endpoint_pair_windows.cc \ - src/core/lib/iomgr/error.cc \ - src/core/lib/iomgr/error_cfstream.cc \ - src/core/lib/iomgr/ev_epoll1_linux.cc \ - src/core/lib/iomgr/ev_epollex_linux.cc \ - src/core/lib/iomgr/ev_poll_posix.cc \ - src/core/lib/iomgr/ev_posix.cc \ - src/core/lib/iomgr/ev_windows.cc \ - src/core/lib/iomgr/exec_ctx.cc \ - src/core/lib/iomgr/executor.cc \ - src/core/lib/iomgr/executor/mpmcqueue.cc \ - src/core/lib/iomgr/executor/threadpool.cc \ - src/core/lib/iomgr/fork_posix.cc \ - src/core/lib/iomgr/fork_windows.cc \ - src/core/lib/iomgr/gethostname_fallback.cc \ - src/core/lib/iomgr/gethostname_host_name_max.cc \ - src/core/lib/iomgr/gethostname_sysconf.cc \ - src/core/lib/iomgr/grpc_if_nametoindex_posix.cc \ - src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc \ - src/core/lib/iomgr/internal_errqueue.cc \ - src/core/lib/iomgr/iocp_windows.cc \ - src/core/lib/iomgr/iomgr.cc \ - src/core/lib/iomgr/iomgr_custom.cc \ - src/core/lib/iomgr/iomgr_internal.cc \ - src/core/lib/iomgr/iomgr_posix.cc \ - src/core/lib/iomgr/iomgr_posix_cfstream.cc \ - src/core/lib/iomgr/iomgr_uv.cc \ - src/core/lib/iomgr/iomgr_windows.cc \ - src/core/lib/iomgr/is_epollexclusive_available.cc \ - src/core/lib/iomgr/load_file.cc \ - src/core/lib/iomgr/lockfree_event.cc \ - src/core/lib/iomgr/polling_entity.cc \ - src/core/lib/iomgr/pollset.cc \ - src/core/lib/iomgr/pollset_custom.cc \ - src/core/lib/iomgr/pollset_set.cc \ - src/core/lib/iomgr/pollset_set_custom.cc \ - src/core/lib/iomgr/pollset_set_windows.cc \ - src/core/lib/iomgr/pollset_uv.cc \ - src/core/lib/iomgr/pollset_windows.cc \ - src/core/lib/iomgr/resolve_address.cc \ - src/core/lib/iomgr/resolve_address_custom.cc \ - src/core/lib/iomgr/resolve_address_posix.cc \ - src/core/lib/iomgr/resolve_address_windows.cc \ - src/core/lib/iomgr/resource_quota.cc \ - src/core/lib/iomgr/sockaddr_utils.cc \ - src/core/lib/iomgr/socket_factory_posix.cc \ - src/core/lib/iomgr/socket_mutator.cc \ - src/core/lib/iomgr/socket_utils_common_posix.cc \ - src/core/lib/iomgr/socket_utils_linux.cc \ - src/core/lib/iomgr/socket_utils_posix.cc \ - src/core/lib/iomgr/socket_utils_uv.cc \ - src/core/lib/iomgr/socket_utils_windows.cc \ - src/core/lib/iomgr/socket_windows.cc \ - src/core/lib/iomgr/tcp_client.cc \ - src/core/lib/iomgr/tcp_client_cfstream.cc \ - src/core/lib/iomgr/tcp_client_custom.cc \ - src/core/lib/iomgr/tcp_client_posix.cc \ - src/core/lib/iomgr/tcp_client_windows.cc \ - src/core/lib/iomgr/tcp_custom.cc \ - src/core/lib/iomgr/tcp_posix.cc \ - src/core/lib/iomgr/tcp_server.cc \ - src/core/lib/iomgr/tcp_server_custom.cc \ - src/core/lib/iomgr/tcp_server_posix.cc \ - src/core/lib/iomgr/tcp_server_utils_posix_common.cc \ - src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc \ - src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc \ - src/core/lib/iomgr/tcp_server_windows.cc \ - src/core/lib/iomgr/tcp_uv.cc \ - src/core/lib/iomgr/tcp_windows.cc \ - src/core/lib/iomgr/time_averaged_stats.cc \ - src/core/lib/iomgr/timer.cc \ - src/core/lib/iomgr/timer_custom.cc \ - src/core/lib/iomgr/timer_generic.cc \ - src/core/lib/iomgr/timer_heap.cc \ - src/core/lib/iomgr/timer_manager.cc \ - src/core/lib/iomgr/timer_uv.cc \ - src/core/lib/iomgr/udp_server.cc \ - src/core/lib/iomgr/unix_sockets_posix.cc \ - src/core/lib/iomgr/unix_sockets_posix_noop.cc \ - src/core/lib/iomgr/wakeup_fd_eventfd.cc \ - src/core/lib/iomgr/wakeup_fd_nospecial.cc \ - src/core/lib/iomgr/wakeup_fd_pipe.cc \ - src/core/lib/iomgr/wakeup_fd_posix.cc \ - src/core/lib/json/json.cc \ - src/core/lib/json/json_reader.cc \ - src/core/lib/json/json_string.cc \ - src/core/lib/json/json_writer.cc \ - src/core/lib/slice/b64.cc \ - src/core/lib/slice/percent_encoding.cc \ - src/core/lib/slice/slice.cc \ - src/core/lib/slice/slice_buffer.cc \ - src/core/lib/slice/slice_intern.cc \ - src/core/lib/slice/slice_string_helpers.cc \ - src/core/lib/surface/api_trace.cc \ - src/core/lib/surface/byte_buffer.cc \ - src/core/lib/surface/byte_buffer_reader.cc \ - src/core/lib/surface/call.cc \ - src/core/lib/surface/call_details.cc \ - src/core/lib/surface/call_log_batch.cc \ - src/core/lib/surface/channel.cc \ - src/core/lib/surface/channel_init.cc \ - src/core/lib/surface/channel_ping.cc \ - src/core/lib/surface/channel_stack_type.cc \ - src/core/lib/surface/completion_queue.cc \ - src/core/lib/surface/completion_queue_factory.cc \ - src/core/lib/surface/event_string.cc \ - src/core/lib/surface/lame_client.cc \ - src/core/lib/surface/metadata_array.cc \ - src/core/lib/surface/server.cc \ - src/core/lib/surface/validate_metadata.cc \ - src/core/lib/surface/version.cc \ - src/core/lib/transport/bdp_estimator.cc \ - src/core/lib/transport/byte_stream.cc \ - src/core/lib/transport/connectivity_state.cc \ - src/core/lib/transport/error_utils.cc \ - src/core/lib/transport/metadata.cc \ - src/core/lib/transport/metadata_batch.cc \ - src/core/lib/transport/pid_controller.cc \ - src/core/lib/transport/static_metadata.cc \ - src/core/lib/transport/status_conversion.cc \ - src/core/lib/transport/status_metadata.cc \ - src/core/lib/transport/timeout_encoding.cc \ - src/core/lib/transport/transport.cc \ - src/core/lib/transport/transport_op_string.cc \ - src/core/lib/uri/uri_parser.cc \ - src/core/lib/debug/trace.cc \ - src/core/ext/transport/chttp2/alpn/alpn.cc \ - src/core/ext/filters/http/client/http_client_filter.cc \ - src/core/ext/filters/http/http_filters_plugin.cc \ - src/core/ext/filters/http/message_compress/message_compress_filter.cc \ - src/core/ext/filters/http/server/http_server_filter.cc \ - src/core/ext/filters/client_channel/backup_poller.cc \ - src/core/ext/filters/client_channel/channel_connectivity.cc \ - src/core/ext/filters/client_channel/client_channel.cc \ - src/core/ext/filters/client_channel/client_channel_channelz.cc \ - src/core/ext/filters/client_channel/client_channel_factory.cc \ - src/core/ext/filters/client_channel/client_channel_plugin.cc \ - src/core/ext/filters/client_channel/connector.cc \ - src/core/ext/filters/client_channel/global_subchannel_pool.cc \ - src/core/ext/filters/client_channel/health/health_check_client.cc \ - src/core/ext/filters/client_channel/http_connect_handshaker.cc \ - src/core/ext/filters/client_channel/http_proxy.cc \ - src/core/ext/filters/client_channel/lb_policy.cc \ - src/core/ext/filters/client_channel/lb_policy_registry.cc \ - src/core/ext/filters/client_channel/local_subchannel_pool.cc \ - src/core/ext/filters/client_channel/parse_address.cc \ - src/core/ext/filters/client_channel/proxy_mapper.cc \ - src/core/ext/filters/client_channel/proxy_mapper_registry.cc \ - src/core/ext/filters/client_channel/resolver.cc \ - src/core/ext/filters/client_channel/resolver_registry.cc \ - src/core/ext/filters/client_channel/resolver_result_parsing.cc \ - src/core/ext/filters/client_channel/resolving_lb_policy.cc \ - src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/server_address.cc \ - src/core/ext/filters/client_channel/service_config.cc \ - src/core/ext/filters/client_channel/subchannel.cc \ - src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ - src/core/ext/filters/deadline/deadline_filter.cc \ - src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc \ - src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc \ - src/core/ext/transport/chttp2/server/chttp2_server.cc \ - src/core/ext/filters/census/grpc_context.cc \ - -PUBLIC_HEADERS_CXX += \ - include/grpc++/alarm.h \ - include/grpc++/channel.h \ - include/grpc++/client_context.h \ - include/grpc++/completion_queue.h \ - include/grpc++/create_channel.h \ - include/grpc++/create_channel_posix.h \ - include/grpc++/ext/health_check_service_server_builder_option.h \ - include/grpc++/generic/async_generic_service.h \ - include/grpc++/generic/generic_stub.h \ - include/grpc++/grpc++.h \ - include/grpc++/health_check_service_interface.h \ - include/grpc++/impl/call.h \ - include/grpc++/impl/channel_argument_option.h \ - include/grpc++/impl/client_unary_call.h \ - include/grpc++/impl/codegen/core_codegen.h \ - include/grpc++/impl/grpc_library.h \ - include/grpc++/impl/method_handler_impl.h \ - include/grpc++/impl/rpc_method.h \ - include/grpc++/impl/rpc_service_method.h \ - include/grpc++/impl/serialization_traits.h \ - include/grpc++/impl/server_builder_option.h \ - include/grpc++/impl/server_builder_plugin.h \ - include/grpc++/impl/server_initializer.h \ - include/grpc++/impl/service_type.h \ - include/grpc++/resource_quota.h \ - include/grpc++/security/auth_context.h \ - include/grpc++/security/auth_metadata_processor.h \ - include/grpc++/security/credentials.h \ - include/grpc++/security/server_credentials.h \ - include/grpc++/server.h \ - include/grpc++/server_builder.h \ - include/grpc++/server_context.h \ - include/grpc++/server_posix.h \ - include/grpc++/support/async_stream.h \ - include/grpc++/support/async_unary_call.h \ - include/grpc++/support/byte_buffer.h \ - include/grpc++/support/channel_arguments.h \ - include/grpc++/support/config.h \ - include/grpc++/support/slice.h \ - include/grpc++/support/status.h \ - include/grpc++/support/status_code_enum.h \ - include/grpc++/support/string_ref.h \ - include/grpc++/support/stub_options.h \ - include/grpc++/support/sync_stream.h \ - include/grpc++/support/time.h \ - include/grpcpp/alarm.h \ - include/grpcpp/alarm_impl.h \ - include/grpcpp/channel.h \ - include/grpcpp/channel_impl.h \ - include/grpcpp/client_context.h \ - include/grpcpp/completion_queue.h \ - include/grpcpp/completion_queue_impl.h \ - include/grpcpp/create_channel.h \ - include/grpcpp/create_channel_impl.h \ - include/grpcpp/create_channel_posix.h \ - include/grpcpp/create_channel_posix_impl.h \ - include/grpcpp/ext/health_check_service_server_builder_option.h \ - include/grpcpp/generic/async_generic_service.h \ - include/grpcpp/generic/generic_stub.h \ - include/grpcpp/generic/generic_stub_impl.h \ - include/grpcpp/grpcpp.h \ - include/grpcpp/health_check_service_interface.h \ - include/grpcpp/health_check_service_interface_impl.h \ - include/grpcpp/impl/call.h \ - include/grpcpp/impl/channel_argument_option.h \ - include/grpcpp/impl/client_unary_call.h \ - include/grpcpp/impl/codegen/core_codegen.h \ - include/grpcpp/impl/grpc_library.h \ - include/grpcpp/impl/method_handler_impl.h \ - include/grpcpp/impl/rpc_method.h \ - include/grpcpp/impl/rpc_service_method.h \ - include/grpcpp/impl/serialization_traits.h \ - include/grpcpp/impl/server_builder_option.h \ - include/grpcpp/impl/server_builder_option_impl.h \ - include/grpcpp/impl/server_builder_plugin.h \ - include/grpcpp/impl/server_initializer.h \ - include/grpcpp/impl/server_initializer_impl.h \ - include/grpcpp/impl/service_type.h \ - include/grpcpp/resource_quota.h \ - include/grpcpp/resource_quota_impl.h \ - include/grpcpp/security/auth_context.h \ - include/grpcpp/security/auth_metadata_processor.h \ - include/grpcpp/security/auth_metadata_processor_impl.h \ - include/grpcpp/security/credentials.h \ - include/grpcpp/security/credentials_impl.h \ - include/grpcpp/security/server_credentials.h \ - include/grpcpp/security/server_credentials_impl.h \ - include/grpcpp/server.h \ - include/grpcpp/server_builder.h \ - include/grpcpp/server_builder_impl.h \ - include/grpcpp/server_context.h \ - include/grpcpp/server_impl.h \ - include/grpcpp/server_posix.h \ - include/grpcpp/server_posix_impl.h \ - include/grpcpp/support/async_stream.h \ - include/grpcpp/support/async_stream_impl.h \ - include/grpcpp/support/async_unary_call.h \ - include/grpcpp/support/async_unary_call_impl.h \ - include/grpcpp/support/byte_buffer.h \ - include/grpcpp/support/channel_arguments.h \ - include/grpcpp/support/channel_arguments_impl.h \ - include/grpcpp/support/client_callback.h \ - include/grpcpp/support/client_callback_impl.h \ - include/grpcpp/support/client_interceptor.h \ - include/grpcpp/support/config.h \ - include/grpcpp/support/interceptor.h \ - include/grpcpp/support/message_allocator.h \ - include/grpcpp/support/proto_buffer_reader.h \ - include/grpcpp/support/proto_buffer_writer.h \ - include/grpcpp/support/server_callback.h \ - include/grpcpp/support/server_callback_impl.h \ - include/grpcpp/support/server_interceptor.h \ - include/grpcpp/support/slice.h \ - include/grpcpp/support/status.h \ - include/grpcpp/support/status_code_enum.h \ - include/grpcpp/support/string_ref.h \ - include/grpcpp/support/stub_options.h \ - include/grpcpp/support/sync_stream.h \ - include/grpcpp/support/sync_stream_impl.h \ - include/grpcpp/support/time.h \ - include/grpcpp/support/validate_service_config.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_windows.h \ - include/grpc/support/cpu.h \ - include/grpc/support/log.h \ - include/grpc/support/log_windows.h \ - include/grpc/support/port_platform.h \ - include/grpc/support/string_util.h \ - include/grpc/support/sync.h \ - include/grpc/support/sync_custom.h \ - include/grpc/support/sync_generic.h \ - include/grpc/support/sync_posix.h \ - include/grpc/support/sync_windows.h \ - include/grpc/support/thd_id.h \ - include/grpc/support/time.h \ - include/grpc/impl/codegen/atm.h \ - include/grpc/impl/codegen/atm_gcc_atomic.h \ - include/grpc/impl/codegen/atm_gcc_sync.h \ - include/grpc/impl/codegen/atm_windows.h \ - include/grpc/impl/codegen/fork.h \ - include/grpc/impl/codegen/gpr_slice.h \ - include/grpc/impl/codegen/gpr_types.h \ - include/grpc/impl/codegen/log.h \ - include/grpc/impl/codegen/port_platform.h \ - include/grpc/impl/codegen/sync.h \ - include/grpc/impl/codegen/sync_custom.h \ - include/grpc/impl/codegen/sync_generic.h \ - include/grpc/impl/codegen/sync_posix.h \ - include/grpc/impl/codegen/sync_windows.h \ - include/grpc/byte_buffer.h \ - include/grpc/byte_buffer_reader.h \ - include/grpc/compression.h \ - include/grpc/fork.h \ - include/grpc/grpc.h \ - include/grpc/grpc_posix.h \ - include/grpc/grpc_security_constants.h \ - include/grpc/load_reporting.h \ - include/grpc/slice.h \ - include/grpc/slice_buffer.h \ - include/grpc/status.h \ - include/grpc/support/workaround_list.h \ - include/grpc/impl/codegen/byte_buffer.h \ - include/grpc/impl/codegen/byte_buffer_reader.h \ - include/grpc/impl/codegen/compression_types.h \ - include/grpc/impl/codegen/connectivity_state.h \ - include/grpc/impl/codegen/grpc_types.h \ - include/grpc/impl/codegen/propagation_bits.h \ - include/grpc/impl/codegen/slice.h \ - include/grpc/impl/codegen/status.h \ - include/grpc++/impl/codegen/async_stream.h \ - include/grpc++/impl/codegen/async_unary_call.h \ - include/grpc++/impl/codegen/byte_buffer.h \ - include/grpc++/impl/codegen/call.h \ - include/grpc++/impl/codegen/call_hook.h \ - include/grpc++/impl/codegen/channel_interface.h \ - include/grpc++/impl/codegen/client_context.h \ - include/grpc++/impl/codegen/client_unary_call.h \ - include/grpc++/impl/codegen/completion_queue.h \ - include/grpc++/impl/codegen/completion_queue_tag.h \ - include/grpc++/impl/codegen/config.h \ - include/grpc++/impl/codegen/core_codegen_interface.h \ - include/grpc++/impl/codegen/create_auth_context.h \ - include/grpc++/impl/codegen/grpc_library.h \ - include/grpc++/impl/codegen/metadata_map.h \ - include/grpc++/impl/codegen/method_handler_impl.h \ - include/grpc++/impl/codegen/rpc_method.h \ - include/grpc++/impl/codegen/rpc_service_method.h \ - include/grpc++/impl/codegen/security/auth_context.h \ - include/grpc++/impl/codegen/serialization_traits.h \ - include/grpc++/impl/codegen/server_context.h \ - include/grpc++/impl/codegen/server_interface.h \ - include/grpc++/impl/codegen/service_type.h \ - include/grpc++/impl/codegen/slice.h \ - include/grpc++/impl/codegen/status.h \ - include/grpc++/impl/codegen/status_code_enum.h \ - include/grpc++/impl/codegen/string_ref.h \ - include/grpc++/impl/codegen/stub_options.h \ - include/grpc++/impl/codegen/sync_stream.h \ - include/grpc++/impl/codegen/time.h \ - include/grpcpp/impl/codegen/async_generic_service.h \ - include/grpcpp/impl/codegen/async_stream.h \ - include/grpcpp/impl/codegen/async_stream_impl.h \ - include/grpcpp/impl/codegen/async_unary_call.h \ - include/grpcpp/impl/codegen/async_unary_call_impl.h \ - include/grpcpp/impl/codegen/byte_buffer.h \ - include/grpcpp/impl/codegen/call.h \ - include/grpcpp/impl/codegen/call_hook.h \ - include/grpcpp/impl/codegen/call_op_set.h \ - include/grpcpp/impl/codegen/call_op_set_interface.h \ - include/grpcpp/impl/codegen/callback_common.h \ - include/grpcpp/impl/codegen/channel_interface.h \ - include/grpcpp/impl/codegen/client_callback.h \ - include/grpcpp/impl/codegen/client_callback_impl.h \ - include/grpcpp/impl/codegen/client_context.h \ - include/grpcpp/impl/codegen/client_context_impl.h \ - include/grpcpp/impl/codegen/client_interceptor.h \ - include/grpcpp/impl/codegen/client_unary_call.h \ - include/grpcpp/impl/codegen/completion_queue.h \ - include/grpcpp/impl/codegen/completion_queue_impl.h \ - include/grpcpp/impl/codegen/completion_queue_tag.h \ - include/grpcpp/impl/codegen/config.h \ - include/grpcpp/impl/codegen/core_codegen_interface.h \ - include/grpcpp/impl/codegen/create_auth_context.h \ - include/grpcpp/impl/codegen/grpc_library.h \ - include/grpcpp/impl/codegen/intercepted_channel.h \ - include/grpcpp/impl/codegen/interceptor.h \ - include/grpcpp/impl/codegen/interceptor_common.h \ - include/grpcpp/impl/codegen/message_allocator.h \ - include/grpcpp/impl/codegen/metadata_map.h \ - include/grpcpp/impl/codegen/method_handler_impl.h \ - include/grpcpp/impl/codegen/rpc_method.h \ - include/grpcpp/impl/codegen/rpc_service_method.h \ - include/grpcpp/impl/codegen/security/auth_context.h \ - include/grpcpp/impl/codegen/serialization_traits.h \ - include/grpcpp/impl/codegen/server_callback.h \ - include/grpcpp/impl/codegen/server_callback_impl.h \ - include/grpcpp/impl/codegen/server_context.h \ - include/grpcpp/impl/codegen/server_context_impl.h \ - include/grpcpp/impl/codegen/server_interceptor.h \ - include/grpcpp/impl/codegen/server_interface.h \ - include/grpcpp/impl/codegen/service_type.h \ - include/grpcpp/impl/codegen/slice.h \ - include/grpcpp/impl/codegen/status.h \ - include/grpcpp/impl/codegen/status_code_enum.h \ - include/grpcpp/impl/codegen/string_ref.h \ - include/grpcpp/impl/codegen/stub_options.h \ - include/grpcpp/impl/codegen/sync_stream.h \ - include/grpcpp/impl/codegen/sync_stream_impl.h \ - include/grpcpp/impl/codegen/time.h \ - include/grpcpp/impl/codegen/sync.h \ - include/grpc/census.h \ - -LIBGRPC++_CRONET_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_CRONET_SRC)))) - - -ifeq ($(NO_SECURE),true) - -# You can't build secure libraries if you don't have OpenSSL. - -$(LIBDIR)/$(CONFIG)/libgrpc++_cronet.a: openssl_dep_error - -$(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP): 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++_cronet.a: protobuf_dep_error - -$(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP): protobuf_dep_error - -else - -$(LIBDIR)/$(CONFIG)/libgrpc++_cronet.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(PROTOBUF_DEP) $(LIBGRPC++_CRONET_OBJS) $(LIBGPR_OBJS) $(ZLIB_MERGE_OBJS) $(CARES_MERGE_OBJS) $(ADDRESS_SORTING_MERGE_OBJS) $(OPENSSL_MERGE_OBJS) - $(E) "[AR] Creating $@" - $(Q) mkdir -p `dirname $@` - $(Q) rm -f $(LIBDIR)/$(CONFIG)/libgrpc++_cronet.a - $(Q) $(AR) $(AROPTS) $(LIBDIR)/$(CONFIG)/libgrpc++_cronet.a $(LIBGRPC++_CRONET_OBJS) $(LIBGPR_OBJS) $(ZLIB_MERGE_OBJS) $(CARES_MERGE_OBJS) $(ADDRESS_SORTING_MERGE_OBJS) $(OPENSSL_MERGE_OBJS) -ifeq ($(SYSTEM),Darwin) - $(Q) ranlib -no_warning_for_no_symbols $(LIBDIR)/$(CONFIG)/libgrpc++_cronet.a -endif - - - -ifeq ($(SYSTEM),MINGW32) -$(LIBDIR)/$(CONFIG)/grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP): $(LIBGRPC++_CRONET_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(PROTOBUF_DEP) $(LIBDIR)/$(CONFIG)/gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(OPENSSL_DEP) - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc++_cronet$(SHARED_VERSION_CPP).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_CRONET_OBJS) $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgpr$(SHARED_VERSION_CORE)-dll -lgrpc_cronet$(SHARED_VERSION_CORE)-dll -lgrpc$(SHARED_VERSION_CORE)-dll -else -$(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP): $(LIBGRPC++_CRONET_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(PROTOBUF_DEP) $(LIBDIR)/$(CONFIG)/libgpr.$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_cronet.$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc.$(SHARED_EXT_CORE) $(OPENSSL_DEP) - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` -ifeq ($(SYSTEM),Darwin) - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_CRONET_OBJS) $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgpr -lgrpc_cronet -lgrpc -else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++_cronet.so.1 -o $(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_CRONET_OBJS) $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgpr -lgrpc_cronet -lgrpc - $(Q) ln -sf $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP).so.1 - $(Q) ln -sf $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP).so -endif -endif - -endif - -endif - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(LIBGRPC++_CRONET_OBJS:.o=.dep) -endif -endif - - LIBGRPC++_ERROR_DETAILS_SRC = \ $(GENDIR)/src/proto/grpc/status/status.pb.cc $(GENDIR)/src/proto/grpc/status/status.grpc.pb.cc \ src/cpp/util/error_details.cc \ @@ -22918,6 +22316,7 @@ src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc: $(OPENS src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc: $(OPENSSL_DEP) src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc: $(OPENSSL_DEP) src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc: $(OPENSSL_DEP) +src/core/ext/transport/cronet/plugin_registry/grpc_cronet_plugin_registry.cc: $(OPENSSL_DEP) src/core/ext/transport/cronet/transport/cronet_api_dummy.cc: $(OPENSSL_DEP) src/core/ext/transport/cronet/transport/cronet_transport.cc: $(OPENSSL_DEP) src/core/lib/http/httpcli_security_connector.cc: $(OPENSSL_DEP) @@ -22963,7 +22362,6 @@ src/core/lib/security/transport/target_authority_table.cc: $(OPENSSL_DEP) src/core/lib/security/transport/tsi_error.cc: $(OPENSSL_DEP) src/core/lib/security/util/json_util.cc: $(OPENSSL_DEP) src/core/lib/surface/init_secure.cc: $(OPENSSL_DEP) -src/core/plugin_registry/grpc_cronet_plugin_registry.cc: $(OPENSSL_DEP) src/core/plugin_registry/grpc_plugin_registry.cc: $(OPENSSL_DEP) src/core/tsi/alts/crypt/aes_gcm.cc: $(OPENSSL_DEP) src/core/tsi/alts/crypt/gsec.cc: $(OPENSSL_DEP) @@ -22997,7 +22395,6 @@ src/core/tsi/ssl/session_cache/ssl_session_openssl.cc: $(OPENSSL_DEP) src/core/tsi/ssl_transport_security.cc: $(OPENSSL_DEP) src/core/tsi/transport_security.cc: $(OPENSSL_DEP) src/core/tsi/transport_security_grpc.cc: $(OPENSSL_DEP) -src/cpp/client/cronet_credentials.cc: $(OPENSSL_DEP) src/cpp/client/secure_credentials.cc: $(OPENSSL_DEP) src/cpp/common/auth_property_iterator.cc: $(OPENSSL_DEP) src/cpp/common/secure_auth_context.cc: $(OPENSSL_DEP) diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 5f8477d7325..721f3379174 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -51,22 +51,12 @@ def _get_external_deps(external_deps): "//:grpc_no_ares": [], "//conditions:default": ["//external:cares"], }) + elif dep == "cronet_c_for_grpc": + ret += ["//third_party/objective_c/Cronet:cronet_c_for_grpc"] else: ret += ["//external:" + dep] return ret -def _maybe_update_cc_library_hdrs(hdrs): - ret = [] - hdrs_to_update = { - "third_party/objective_c/Cronet/bidirectional_stream_c.h": "//third_party:objective_c/Cronet/bidirectional_stream_c.h", - } - for h in hdrs: - if h in hdrs_to_update.keys(): - ret.append(hdrs_to_update[h]) - else: - ret.append(h) - return ret - def grpc_cc_library( name, srcs = [], @@ -106,7 +96,7 @@ def grpc_cc_library( "//:grpc_disallow_exceptions": ["GRPC_ALLOW_EXCEPTIONS=0"], "//conditions:default": [], }), - hdrs = _maybe_update_cc_library_hdrs(hdrs + public_hdrs), + hdrs = hdrs + public_hdrs, deps = deps + _get_external_deps(external_deps), copts = copts, visibility = visibility, diff --git a/build.yaml b/build.yaml index 7b4a396b19c..58fa8406d4e 100644 --- a/build.yaml +++ b/build.yaml @@ -1113,6 +1113,7 @@ filegroups: - include/grpc/grpc_security.h - include/grpc/grpc_security_constants.h headers: + - src/core/ext/transport/cronet/client/secure/cronet_channel_create.h - src/core/ext/transport/cronet/transport/cronet_transport.h - third_party/objective_c/Cronet/bidirectional_stream_c.h src: @@ -1618,6 +1619,7 @@ libs: build: all language: c src: + - src/core/ext/transport/cronet/plugin_registry/grpc_cronet_plugin_registry.cc - src/core/lib/surface/init.cc baselib: true deps_linkage: static @@ -1626,7 +1628,6 @@ libs: - grpc_base - grpc_transport_cronet_client_secure - grpc_transport_chttp2_client_secure - generate_plugin_registry: true platforms: - linux secure: true @@ -1773,29 +1774,6 @@ libs: - src/cpp/util/core_stats.cc deps: - grpc++ -- name: grpc++_cronet - build: all - language: c++ - src: - - src/cpp/client/cronet_credentials.cc - - src/cpp/client/insecure_credentials.cc - - src/cpp/common/insecure_create_auth_context.cc - - src/cpp/server/insecure_server_credentials.cc - deps: - - gpr - - grpc_cronet - baselib: true - dll: true - filegroups: - - grpc++_base - - grpc++_codegen_base - - grpc++_codegen_base_src - - grpc_transport_chttp2_client_insecure - - grpc_transport_chttp2_server_insecure - - census - platforms: - - linux - secure: true - name: grpc++_error_details build: all language: c++ diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 47cf5b8d47f..1368b3ca8e2 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -1231,6 +1231,7 @@ Pod::Spec.new do |s| 'third_party/nanopb/pb_common.c', 'third_party/nanopb/pb_decode.c', 'third_party/nanopb/pb_encode.c', + 'src/core/ext/transport/cronet/client/secure/cronet_channel_create.h', 'src/core/ext/transport/cronet/transport/cronet_transport.h', 'third_party/objective_c/Cronet/bidirectional_stream_c.h', 'third_party/nanopb/pb.h', diff --git a/include/grpcpp/security/credentials.h b/include/grpcpp/security/credentials.h index 5190b1b3393..4df69f996f8 100644 --- a/include/grpcpp/security/credentials.h +++ b/include/grpcpp/security/credentials.h @@ -91,11 +91,6 @@ InsecureChannelCredentials() { return ::grpc_impl::InsecureChannelCredentials(); } -static inline std::shared_ptr -CronetChannelCredentials(void* engine) { - return ::grpc_impl::CronetChannelCredentials(engine); -} - typedef ::grpc_impl::MetadataCredentialsPlugin MetadataCredentialsPlugin; static inline std::shared_ptr diff --git a/include/grpcpp/security/credentials_impl.h b/include/grpcpp/security/credentials_impl.h index e236512f43e..bd79f30ae12 100644 --- a/include/grpcpp/security/credentials_impl.h +++ b/include/grpcpp/security/credentials_impl.h @@ -228,9 +228,6 @@ std::shared_ptr CompositeCallCredentials( /// Credentials for an unencrypted, unauthenticated channel std::shared_ptr InsecureChannelCredentials(); -/// Credentials for a channel using Cronet. -std::shared_ptr CronetChannelCredentials(void* engine); - /// User defined metadata credentials. class MetadataCredentialsPlugin { public: diff --git a/include/grpcpp/security/cronet_credentials.h b/include/grpcpp/security/cronet_credentials.h new file mode 100644 index 00000000000..008570b8cdf --- /dev/null +++ b/include/grpcpp/security/cronet_credentials.h @@ -0,0 +1,33 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SECURITY_CRONET_CREDENTIALS_H +#define GRPCPP_SECURITY_CRONET_CREDENTIALS_H + +#include + +namespace grpc { + +static inline std::shared_ptr +CronetChannelCredentials(void* engine) { + return ::grpc_impl::CronetChannelCredentials(engine); +} + +} // namespace grpc + +#endif // GRPCPP_SECURITY_CRONET_CREDENTIALS_H diff --git a/include/grpcpp/security/cronet_credentials_impl.h b/include/grpcpp/security/cronet_credentials_impl.h new file mode 100644 index 00000000000..e9211581348 --- /dev/null +++ b/include/grpcpp/security/cronet_credentials_impl.h @@ -0,0 +1,33 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SECURITY_CRONET_CREDENTIALS_IMPL_H +#define GRPCPP_SECURITY_CRONET_CREDENTIALS_IMPL_H + +#include + +namespace grpc_impl { + +class ChannelCredentials; + +/// Credentials for a channel using Cronet. +std::shared_ptr CronetChannelCredentials(void* engine); + +} // namespace grpc_impl + +#endif // GRPCPP_SECURITY_CRONET_CREDENTIALS_IMPL_H diff --git a/src/core/ext/transport/cronet/BUILD b/src/core/ext/transport/cronet/BUILD new file mode 100644 index 00000000000..c77bf19af1f --- /dev/null +++ b/src/core/ext/transport/cronet/BUILD @@ -0,0 +1,65 @@ +# gRPC Bazel BUILD file. +# +# Copyright 2016 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load( + "//bazel:grpc_build_system.bzl", + "grpc_cc_library", +) + +licenses(["notice"]) # Apache v2 + +package( + default_visibility = ["//visibility:public"], + features = [ + "-layering_check", + "-parse_headers", + ], +) + +grpc_cc_library( + name = "grpc_transport_cronet_client_secure", + srcs = [ + "client/secure/cronet_channel_create.cc", + "transport/cronet_api_dummy.cc", + "transport/cronet_transport.cc", + "transport/cronet_transport.h", + ], + external_deps = [ + "cronet_c_for_grpc", + ], + language = "c++", + public_hdrs = [ + "client/secure/cronet_channel_create.h", + ], + deps = [ + "//:grpc_base", + "//:grpc_transport_chttp2", + ], +) + +grpc_cc_library( + name = "grpc_cronet_plugin_registry", + srcs = [ + "plugin_registry/grpc_cronet_plugin_registry.cc", + ], + language = "c++", + deps = [ + ":grpc_transport_cronet_client_secure", + "//:grpc_base", + "//:grpc_http_filters", + "//:grpc_transport_chttp2_client_secure", + ], +) diff --git a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc index 6e08d27b21d..c3fc25630e7 100644 --- a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc +++ b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc @@ -21,11 +21,10 @@ #include #include -#include - #include #include +#include "src/core/ext/transport/cronet/client/secure/cronet_channel_create.h" #include "src/core/ext/transport/cronet/transport/cronet_transport.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/transport/transport_impl.h" diff --git a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.h b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.h new file mode 100644 index 00000000000..7427f9fb21d --- /dev/null +++ b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.h @@ -0,0 +1,39 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CRONET_CLIENT_SECURE_CRONET_CHANNEL_CREATE_H +#define GRPC_CORE_EXT_TRANSPORT_CRONET_CLIENT_SECURE_CRONET_CHANNEL_CREATE_H + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +GRPCAPI grpc_channel* grpc_cronet_secure_channel_create( + void* engine, const char* target, const grpc_channel_args* args, + void* reserved); + +#ifdef __cplusplus +} +#endif + +#endif /* GRPC_CORE_EXT_TRANSPORT_CRONET_CLIENT_SECURE_CRONET_CHANNEL_CREATE_H \ + */ diff --git a/src/core/plugin_registry/grpc_cronet_plugin_registry.cc b/src/core/ext/transport/cronet/plugin_registry/grpc_cronet_plugin_registry.cc similarity index 78% rename from src/core/plugin_registry/grpc_cronet_plugin_registry.cc rename to src/core/ext/transport/cronet/plugin_registry/grpc_cronet_plugin_registry.cc index 92085d31d70..8df100f17a3 100644 --- a/src/core/plugin_registry/grpc_cronet_plugin_registry.cc +++ b/src/core/ext/transport/cronet/plugin_registry/grpc_cronet_plugin_registry.cc @@ -30,12 +30,9 @@ void grpc_client_channel_init(void); void grpc_client_channel_shutdown(void); void grpc_register_built_in_plugins(void) { - grpc_register_plugin(grpc_http_filters_init, - grpc_http_filters_shutdown); - grpc_register_plugin(grpc_chttp2_plugin_init, - grpc_chttp2_plugin_shutdown); + grpc_register_plugin(grpc_http_filters_init, grpc_http_filters_shutdown); + grpc_register_plugin(grpc_chttp2_plugin_init, grpc_chttp2_plugin_shutdown); grpc_register_plugin(grpc_deadline_filter_init, grpc_deadline_filter_shutdown); - grpc_register_plugin(grpc_client_channel_init, - grpc_client_channel_shutdown); + grpc_register_plugin(grpc_client_channel_init, grpc_client_channel_shutdown); } diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc index a5f6571c510..28e6c04869e 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.cc +++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc @@ -41,6 +41,7 @@ #include "src/core/lib/transport/metadata_batch.h" #include "src/core/lib/transport/static_metadata.h" #include "src/core/lib/transport/transport_impl.h" + #include "third_party/objective_c/Cronet/bidirectional_stream_c.h" #define GRPC_HEADER_SIZE_IN_BYTES 5 diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template index d367ce4f45f..0ed3b8399b5 100644 --- a/templates/gRPC-Core.podspec.template +++ b/templates/gRPC-Core.podspec.template @@ -47,7 +47,7 @@ excl = grpc_private_files(libs) excl += [ # We do not need cronet dedicated plugin registry - "src/core/plugin_registry/grpc_cronet_plugin_registry.cc", + "src/core/ext/transport/cronet/plugin_registry/grpc_cronet_plugin_registry.cc", # We do not need dummy cronet API for ObjC "src/core/ext/transport/cronet/transport/cronet_api_dummy.cc", ] diff --git a/templates/test/core/surface/public_headers_must_be_c89.c.template b/templates/test/core/surface/public_headers_must_be_c89.c.template index 6e4a83666e6..dde5c81e1ce 100644 --- a/templates/test/core/surface/public_headers_must_be_c89.c.template +++ b/templates/test/core/surface/public_headers_must_be_c89.c.template @@ -25,13 +25,15 @@ if platform_identifier in hdr: return True return False + def is_cronet_header(hdr): + return "cronet" in hdr hdrs = set() pfx = 'include/' for lib in libs: if lib.language != 'c': continue for hdr in lib.get('public_headers', []): if is_platform_header(hdr): continue - if 'grpc_cronet.h' in hdr: continue + if is_cronet_header(hdr): continue assert(hdr[0:len(pfx)] == pfx) hdrs.add(hdr[len(pfx):]) hdrs = sorted(list(hdrs)) diff --git a/third_party/BUILD b/third_party/BUILD index 8b43d6b8300..91d73b2c688 100644 --- a/third_party/BUILD +++ b/third_party/BUILD @@ -1,6 +1,5 @@ exports_files([ "gtest.BUILD", - "objective_c/Cronet/bidirectional_stream_c.h", "zlib.BUILD", "twisted.BUILD", "yaml.BUILD", diff --git a/third_party/objective_c/Cronet/BUILD b/third_party/objective_c/Cronet/BUILD new file mode 100644 index 00000000000..8d8a1d55d48 --- /dev/null +++ b/third_party/objective_c/Cronet/BUILD @@ -0,0 +1,27 @@ +# gRPC Bazel BUILD file. +# +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +licenses(["notice"]) # Apache v2 + +package(default_visibility = ["//:__subpackages__"]) + +# C Header files used by GRPC C Transport. +cc_library( + name = "cronet_c_for_grpc", + hdrs = [ + "bidirectional_stream_c.h", + ] +) diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index ceec3f0e6c3..a02ef3ea03a 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -6722,6 +6722,7 @@ "language": "c", "name": "grpc_cronet", "src": [ + "src/core/ext/transport/cronet/plugin_registry/grpc_cronet_plugin_registry.cc", "src/core/lib/surface/init.cc" ], "third_party": false, @@ -6938,31 +6939,6 @@ "third_party": false, "type": "lib" }, - { - "deps": [ - "census", - "gpr", - "grpc", - "grpc++_base", - "grpc++_codegen_base", - "grpc++_codegen_base_src", - "grpc_cronet", - "grpc_transport_chttp2_client_insecure", - "grpc_transport_chttp2_server_insecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "grpc++_cronet", - "src": [ - "src/cpp/client/cronet_credentials.cc", - "src/cpp/client/insecure_credentials.cc", - "src/cpp/common/insecure_create_auth_context.cc", - "src/cpp/server/insecure_server_credentials.cc" - ], - "third_party": false, - "type": "lib" - }, { "deps": [ "grpc++" @@ -10024,6 +10000,7 @@ "include/grpc/grpc_cronet.h", "include/grpc/grpc_security.h", "include/grpc/grpc_security_constants.h", + "src/core/ext/transport/cronet/client/secure/cronet_channel_create.h", "src/core/ext/transport/cronet/transport/cronet_transport.h", "third_party/objective_c/Cronet/bidirectional_stream_c.h" ], @@ -10035,6 +10012,7 @@ "include/grpc/grpc_security.h", "include/grpc/grpc_security_constants.h", "src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc", + "src/core/ext/transport/cronet/client/secure/cronet_channel_create.h", "src/core/ext/transport/cronet/transport/cronet_api_dummy.cc", "src/core/ext/transport/cronet/transport/cronet_transport.cc", "src/core/ext/transport/cronet/transport/cronet_transport.h" From 9ab38afa138eb3a462abe7cc7095f3e19fb89aed Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Tue, 23 Jul 2019 12:34:37 -0700 Subject: [PATCH 0983/1555] CH2 interned metadata key parsing fastpath. on_initial_header() and on_trailing_header() are called by the hpack parser. The hpack parser interns the key elements for metadata that it parses. Thus, the called functions don't need to do a slowpath slice value check when performing metadata key comparisons. --- .../ext/transport/chttp2/transport/parsing.cc | 43 +++++++++++++------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index 1aa6d971684..4e6ff60caf8 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -394,6 +394,32 @@ error_handler: static void free_timeout(void* p) { gpr_free(p); } +static bool md_key_cmp(grpc_mdelem md, const grpc_slice& reference) { + GPR_DEBUG_ASSERT(grpc_slice_is_interned(GRPC_MDKEY(md))); + return GRPC_MDKEY(md).refcount == reference.refcount; +} + +static bool md_cmp(grpc_mdelem md, grpc_mdelem ref_md, + const grpc_slice& ref_key) { + if (GPR_LIKELY(GRPC_MDELEM_IS_INTERNED(md))) { + return md.payload == ref_md.payload; + } + if (md_key_cmp(md, ref_key)) { + return grpc_slice_eq_static_interned(GRPC_MDVALUE(md), + GRPC_MDVALUE(ref_md)); + } + return false; +} + +static bool is_nonzero_status(grpc_mdelem md) { + // If md.payload == GRPC_MDELEM_GRPC_STATUS_1 or GRPC_MDELEM_GRPC_STATUS_2, + // then we have seen an error. In fact, if it is a GRPC_STATUS and it's + // not equal to GRPC_MDELEM_GRPC_STATUS_0, then we have seen an error. + // TODO(ctiller): check for a status like " 0" + return md_key_cmp(md, GRPC_MDSTR_GRPC_STATUS) && + !md_cmp(md, GRPC_MDELEM_GRPC_STATUS_0, GRPC_MDSTR_GRPC_STATUS); +} + static void on_initial_header(void* tp, grpc_mdelem md) { GPR_TIMER_SCOPE("on_initial_header", 0); @@ -411,15 +437,9 @@ static void on_initial_header(void* tp, grpc_mdelem md) { gpr_free(value); } - // If md.payload == GRPC_MDELEM_GRPC_STATUS_1 or GRPC_MDELEM_GRPC_STATUS_2, - // then we have seen an error. In fact, if it is a GRPC_STATUS and it's - // not equal to GRPC_MDELEM_GRPC_STATUS_0, then we have seen an error. - if (grpc_slice_eq_static_interned(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_STATUS) && - !grpc_mdelem_static_value_eq(md, GRPC_MDELEM_GRPC_STATUS_0)) { - /* TODO(ctiller): check for a status like " 0" */ + if (is_nonzero_status(md)) { // not GRPC_MDELEM_GRPC_STATUS_0? s->seen_error = true; - } else if (grpc_slice_eq_static_interned(GRPC_MDKEY(md), - GRPC_MDSTR_GRPC_TIMEOUT)) { + } else if (md_key_cmp(md, GRPC_MDSTR_GRPC_TIMEOUT)) { grpc_millis* cached_timeout = static_cast(grpc_mdelem_get_user_data(md, free_timeout)); grpc_millis timeout; @@ -496,12 +516,7 @@ static void on_trailing_header(void* tp, grpc_mdelem md) { gpr_free(value); } - // If md.payload == GRPC_MDELEM_GRPC_STATUS_1 or GRPC_MDELEM_GRPC_STATUS_2, - // then we have seen an error. In fact, if it is a GRPC_STATUS and it's - // not equal to GRPC_MDELEM_GRPC_STATUS_0, then we have seen an error. - if (grpc_slice_eq_static_interned(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_STATUS) && - !grpc_mdelem_static_value_eq(md, GRPC_MDELEM_GRPC_STATUS_0)) { - /* TODO(ctiller): check for a status like " 0" */ + if (is_nonzero_status(md)) { // not GRPC_MDELEM_GRPC_STATUS_0? s->seen_error = true; } From 32aad8a11c8726cb02b0551b6ae6dc4d07029a0b Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 24 Jul 2019 15:46:56 -0700 Subject: [PATCH 0984/1555] More fixes --- src/objective-c/GRPCClient/GRPCCall.m | 2 -- .../private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h | 2 +- .../private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m | 4 ++-- .../GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.h | 2 +- .../GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.m | 4 ++-- src/objective-c/ProtoRPC/ProtoService.m | 5 +++++ 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 2f2a89c20ac..c62cb03ddd8 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -18,13 +18,11 @@ #import "GRPCCall.h" -#include #import "GRPCCallOptions.h" #import "GRPCInterceptor.h" #import "GRPCCall+Interceptor.h" #import "private/GRPCTransport+Private.h" -#import "private/GRPCCore/GRPCCoreFactory.h" NSString *const kGRPCHeadersKey = @"io.grpc.HeadersKey"; NSString *const kGRPCTrailersKey = @"io.grpc.TrailersKey"; diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h index 8c781f4a448..f1ad1b05e44 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h @@ -16,7 +16,7 @@ * */ -#import "GRPCCoreFactory.h" +#import "../GRPCCoreFactory.h" @interface GRPCCoreCronetFactory : NSObject diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m index 661df006e57..0a19e31999e 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m @@ -21,8 +21,8 @@ #import #import -#import "GRPCCoreFactory.h" -#import "GRPCCallInternal.h" +#import "../GRPCCoreFactory.h" +#import "../GRPCCallInternal.h" #import "GRPCCronetChannelFactory.h" static GRPCCoreCronetFactory *gGRPCCoreCronetFactory = nil; diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.h index 738dfdb7370..138ddf1f730 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.h @@ -15,7 +15,7 @@ * limitations under the License. * */ -#import "GRPCChannelFactory.h" +#import "../GRPCChannelFactory.h" @class GRPCChannel; typedef struct stream_engine stream_engine; diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.m index 8744d27e04f..da3f3afd855 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.m @@ -18,8 +18,8 @@ #import "GRPCCronetChannelFactory.h" -#import "ChannelArgsUtil.h" -#import "GRPCChannel.h" +#import "../ChannelArgsUtil.h" +#import "../GRPCChannel.h" #import #include diff --git a/src/objective-c/ProtoRPC/ProtoService.m b/src/objective-c/ProtoRPC/ProtoService.m index 3a8417d0afa..c3684c8e2f2 100644 --- a/src/objective-c/ProtoRPC/ProtoService.m +++ b/src/objective-c/ProtoRPC/ProtoService.m @@ -32,9 +32,14 @@ GRPCCallOptions *_callOptions; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnonnull" +// Do not call the default init method - (instancetype)init { + [NSException raise:NSGenericException format:@"Do not call init method of ProtoService"]; return [self initWithHost:nil packageName:nil serviceName:nil callOptions:nil]; } +#pragma clang diasnostic pop // Designated initializer - (instancetype)initWithHost:(NSString *)host From e6b07f9e582243c9a70d1246e5ec516d05e215ed Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 24 Jul 2019 15:47:32 -0700 Subject: [PATCH 0985/1555] Added cronet to gRPC-C++.podspec --- gRPC-C++.podspec | 5 ++++- templates/gRPC-C++.podspec.template | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index d2680ee5d03..56d6f5b3edb 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -205,7 +205,9 @@ Pod::Spec.new do |s| 'include/grpcpp/impl/codegen/sync_stream.h', 'include/grpcpp/impl/codegen/sync_stream_impl.h', 'include/grpcpp/impl/codegen/time.h', - 'include/grpcpp/impl/codegen/sync.h' + 'include/grpcpp/impl/codegen/sync.h', + 'include/grpcpp/security/cronet_credentials.h', + 'include/grpcpp/security/cronet_credentials_impl.h' end s.subspec 'Implementation' do |ss| @@ -269,6 +271,7 @@ Pod::Spec.new do |s| 'src/cpp/util/string_ref.cc', 'src/cpp/util/time_cc.cc', 'src/cpp/codegen/codegen_init.cc', + 'src/cpp/client/cronet_credentials.cc', 'src/core/lib/gpr/alloc.h', 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', diff --git a/templates/gRPC-C++.podspec.template b/templates/gRPC-C++.podspec.template index 40368e422d9..9ecdf80143e 100644 --- a/templates/gRPC-C++.podspec.template +++ b/templates/gRPC-C++.podspec.template @@ -28,6 +28,13 @@ if lib.name in expect_libs: for group in groups: out += lib.get(group, []) + # Add cronet-related files manually since they're not in BUILD.yaml. + if "grpc++" in expect_libs: + if "public_headers" in groups: + out += ["include/grpcpp/security/cronet_credentials.h", + "include/grpcpp/security/cronet_credentials_impl.h"] + if "src" in groups: + out += ["src/cpp/client/cronet_credentials.cc"] return out def filter_grpcpp(files): @@ -65,7 +72,6 @@ out += [file for file in grpc_private_headers(libs) if not file.startswith("third_party/nanopb/")] out = filter_grpcpp(out) - return out def grpcpp_private_headers(libs, filegroups): From 3ea28709148f0b9615d892eb44d3b394a7d2816e Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 24 Jul 2019 16:59:09 -0700 Subject: [PATCH 0986/1555] Config'd the projects so that they actually run on tvOS 10.0 and watchOS 4.0 Removed unnecessary code stubs --- .../tvOS-sample.xcodeproj/project.pbxproj | 5 +- .../tvOS-sample/tvOS-sample/AppDelegate.m | 36 ----- .../ExtensionDelegate.m | 58 ------- .../InterfaceController.m | 10 -- .../watchOS-sample.xcodeproj/project.pbxproj | 144 +++++++++--------- .../watchOS-sample WatchKit App.xcscheme | 127 +++++++++++++++ .../xcschemes/watchOS-sample.xcscheme | 91 +++++++++++ .../watchOS-sample/AppDelegate.m | 36 ----- .../watchOS-sample/ViewController.m | 5 - 9 files changed, 293 insertions(+), 219 deletions(-) create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample WatchKit App.xcscheme create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample.xcscheme diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj b/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj index 8840882b145..a19281242bd 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 51; objects = { /* Begin PBXBuildFile section */ @@ -48,7 +48,6 @@ D2D1C60CE9BD00C1371BC913 /* Pods-tvOS-sample.debug.xcconfig */, 93F3CF0DB110860F8E180685 /* Pods-tvOS-sample.release.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; @@ -352,6 +351,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.google.tvOS-grpc-sample"; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = 3; + TVOS_DEPLOYMENT_TARGET = 10.0; }; name = Debug; }; @@ -371,6 +371,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.google.tvOS-grpc-sample"; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = 3; + TVOS_DEPLOYMENT_TARGET = 10.0; }; name = Release; }; diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m index 11b6c418aee..4a76f4c488c 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m @@ -24,40 +24,4 @@ @implementation AppDelegate -- (BOOL)application:(UIApplication *)application - didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - // Override point for customization after application launch. - return YES; -} - -- (void)applicationWillResignActive:(UIApplication *)application { - // Sent when the application is about to move from active to inactive state. This can occur for - // certain types of temporary interruptions (such as an incoming phone call or SMS message) or - // when the user quits the application and it begins the transition to the background state. Use - // this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. - // Games should use this method to pause the game. -} - -- (void)applicationDidEnterBackground:(UIApplication *)application { - // Use this method to release shared resources, save user data, invalidate timers, and store - // enough application state information to restore your application to its current state in case - // it is terminated later. If your application supports background execution, this method is - // called instead of applicationWillTerminate: when the user quits. -} - -- (void)applicationWillEnterForeground:(UIApplication *)application { - // Called as part of the transition from the background to the active state; here you can undo - // many of the changes made on entering the background. -} - -- (void)applicationDidBecomeActive:(UIApplication *)application { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If - // the application was previously in the background, optionally refresh the user interface. -} - -- (void)applicationWillTerminate:(UIApplication *)application { - // Called when the application is about to terminate. Save data if appropriate. See also - // applicationDidEnterBackground:. -} - @end diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.m b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.m index 5be441937b6..b64d60256de 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.m @@ -20,62 +20,4 @@ @implementation ExtensionDelegate -- (void)applicationDidFinishLaunching { - // Perform any final initialization of your application. -} - -- (void)applicationDidBecomeActive { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If - // the application was previously in the background, optionally refresh the user interface. -} - -- (void)applicationWillResignActive { - // Sent when the application is about to move from active to inactive state. This can occur for - // certain types of temporary interruptions (such as an incoming phone call or SMS message) or - // when the user quits the application and it begins the transition to the background state. Use - // this method to pause ongoing tasks, disable timers, etc. -} - -- (void)handleBackgroundTasks:(NSSet *)backgroundTasks { - // Sent when the system needs to launch the application in the background to process tasks. Tasks - // arrive in a set, so loop through and process each one. - for (WKRefreshBackgroundTask *task in backgroundTasks) { - // Check the Class of each task to decide how to process it - if ([task isKindOfClass:[WKApplicationRefreshBackgroundTask class]]) { - // Be sure to complete the background task once you’re done. - WKApplicationRefreshBackgroundTask *backgroundTask = - (WKApplicationRefreshBackgroundTask *)task; - [backgroundTask setTaskCompletedWithSnapshot:NO]; - } else if ([task isKindOfClass:[WKSnapshotRefreshBackgroundTask class]]) { - // Snapshot tasks have a unique completion call, make sure to set your expiration date - WKSnapshotRefreshBackgroundTask *snapshotTask = (WKSnapshotRefreshBackgroundTask *)task; - [snapshotTask setTaskCompletedWithDefaultStateRestored:YES - estimatedSnapshotExpiration:[NSDate distantFuture] - userInfo:nil]; - } else if ([task isKindOfClass:[WKWatchConnectivityRefreshBackgroundTask class]]) { - // Be sure to complete the background task once you’re done. - WKWatchConnectivityRefreshBackgroundTask *backgroundTask = - (WKWatchConnectivityRefreshBackgroundTask *)task; - [backgroundTask setTaskCompletedWithSnapshot:NO]; - } else if ([task isKindOfClass:[WKURLSessionRefreshBackgroundTask class]]) { - // Be sure to complete the background task once you’re done. - WKURLSessionRefreshBackgroundTask *backgroundTask = (WKURLSessionRefreshBackgroundTask *)task; - [backgroundTask setTaskCompletedWithSnapshot:NO]; - } else if ([task isKindOfClass:[WKRelevantShortcutRefreshBackgroundTask class]]) { - // Be sure to complete the relevant-shortcut task once you’re done. - WKRelevantShortcutRefreshBackgroundTask *relevantShortcutTask = - (WKRelevantShortcutRefreshBackgroundTask *)task; - [relevantShortcutTask setTaskCompletedWithSnapshot:NO]; - } else if ([task isKindOfClass:[WKIntentDidRunRefreshBackgroundTask class]]) { - // Be sure to complete the intent-did-run task once you’re done. - WKIntentDidRunRefreshBackgroundTask *intentDidRunTask = - (WKIntentDidRunRefreshBackgroundTask *)task; - [intentDidRunTask setTaskCompletedWithSnapshot:NO]; - } else { - // make sure to complete unhandled task types - [task setTaskCompletedWithSnapshot:NO]; - } - } -} - @end diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.m b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.m index 77efbc42447..d7f0c94adc9 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.m @@ -41,16 +41,6 @@ callOptions:_options]; } -- (void)willActivate { - // This method is called when watch view controller is about to be visible to user - [super willActivate]; -} - -- (void)didDeactivate { - // This method is called when watch view controller is no longer visible - [super didDeactivate]; -} - - (IBAction)makeCall { RMTSimpleRequest *request = [RMTSimpleRequest message]; request.responseSize = 100; diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj index 191bde5d9e0..9d40fc4b0cf 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj @@ -7,8 +7,7 @@ objects = { /* Begin PBXBuildFile section */ - 8C710D86B987697CC3B243A8 /* libPods-watchOS-sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 56BDF7E8B01683A4EFDEC9CF /* libPods-watchOS-sample.a */; }; - 8F4EFFA8E14960D3C5BD0046 /* libPods-watchOS-sample WatchKit Extension.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 76AFD66D880975F945E377C9 /* libPods-watchOS-sample WatchKit Extension.a */; }; + 6CD34817C1124B7090EFB679 /* libPods-watchOS-sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 81BB6B1D8754281EF32EB3F2 /* libPods-watchOS-sample.a */; }; ABB17D5922D93BAB00C26D6E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D5822D93BAB00C26D6E /* AppDelegate.m */; }; ABB17D5C22D93BAB00C26D6E /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D5B22D93BAB00C26D6E /* ViewController.m */; }; ABB17D5F22D93BAB00C26D6E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D5D22D93BAB00C26D6E /* Main.storyboard */; }; @@ -22,6 +21,7 @@ ABB17D8022D93BAC00C26D6E /* InterfaceController.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D7F22D93BAC00C26D6E /* InterfaceController.m */; }; ABB17D8322D93BAC00C26D6E /* ExtensionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D8222D93BAC00C26D6E /* ExtensionDelegate.m */; }; ABB17D8522D93BAD00C26D6E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D8422D93BAD00C26D6E /* Assets.xcassets */; }; + CCC7943770AD2447C8F33431 /* libPods-watchOS-sample WatchKit Extension.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B9B6F1C6465A4AAC45CAF14 /* libPods-watchOS-sample WatchKit Extension.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -67,11 +67,10 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 0D53169393FEB36944484D25 /* Pods-watchOS-sample WatchKit Extension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample WatchKit Extension.release.xcconfig"; path = "Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension.release.xcconfig"; sourceTree = ""; }; - 56BDF7E8B01683A4EFDEC9CF /* libPods-watchOS-sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-watchOS-sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 76AFD66D880975F945E377C9 /* libPods-watchOS-sample WatchKit Extension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-watchOS-sample WatchKit Extension.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 7DB8462D385A70A534800DAF /* Pods-watchOS-sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample.release.xcconfig"; path = "Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample.release.xcconfig"; sourceTree = ""; }; - 8C5540E3A034586596BEFE2B /* Pods-watchOS-sample WatchKit Extension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample WatchKit Extension.debug.xcconfig"; path = "Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension.debug.xcconfig"; sourceTree = ""; }; + 574DCD2DDCABCC45B2308601 /* Pods-watchOS-sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample.debug.xcconfig"; path = "Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample.debug.xcconfig"; sourceTree = ""; }; + 5B9B6F1C6465A4AAC45CAF14 /* libPods-watchOS-sample WatchKit Extension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-watchOS-sample WatchKit Extension.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 81BB6B1D8754281EF32EB3F2 /* libPods-watchOS-sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-watchOS-sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 957B59E3DE8281B41B6DB3FD /* Pods-watchOS-sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample.release.xcconfig"; path = "Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample.release.xcconfig"; sourceTree = ""; }; ABB17D5422D93BAB00C26D6E /* watchOS-sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "watchOS-sample.app"; sourceTree = BUILT_PRODUCTS_DIR; }; ABB17D5722D93BAB00C26D6E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; ABB17D5822D93BAB00C26D6E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; @@ -93,7 +92,8 @@ ABB17D8222D93BAC00C26D6E /* ExtensionDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ExtensionDelegate.m; sourceTree = ""; }; ABB17D8422D93BAD00C26D6E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; ABB17D8622D93BAD00C26D6E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - CC865626944D2C3DD838F762 /* Pods-watchOS-sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample.debug.xcconfig"; path = "Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample.debug.xcconfig"; sourceTree = ""; }; + EDC6FF21CD9F393E8FDF02F6 /* Pods-watchOS-sample WatchKit Extension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample WatchKit Extension.release.xcconfig"; path = "Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension.release.xcconfig"; sourceTree = ""; }; + FBBABD10A996E7CCA4B2F937 /* Pods-watchOS-sample WatchKit Extension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample WatchKit Extension.debug.xcconfig"; path = "Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -101,7 +101,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 8C710D86B987697CC3B243A8 /* libPods-watchOS-sample.a in Frameworks */, + 6CD34817C1124B7090EFB679 /* libPods-watchOS-sample.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -109,7 +109,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 8F4EFFA8E14960D3C5BD0046 /* libPods-watchOS-sample WatchKit Extension.a in Frameworks */, + CCC7943770AD2447C8F33431 /* libPods-watchOS-sample WatchKit Extension.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -126,23 +126,14 @@ 2C4A0708747AAA7298F757DA /* Pods */ = { isa = PBXGroup; children = ( - CC865626944D2C3DD838F762 /* Pods-watchOS-sample.debug.xcconfig */, - 7DB8462D385A70A534800DAF /* Pods-watchOS-sample.release.xcconfig */, - 8C5540E3A034586596BEFE2B /* Pods-watchOS-sample WatchKit Extension.debug.xcconfig */, - 0D53169393FEB36944484D25 /* Pods-watchOS-sample WatchKit Extension.release.xcconfig */, + 574DCD2DDCABCC45B2308601 /* Pods-watchOS-sample.debug.xcconfig */, + 957B59E3DE8281B41B6DB3FD /* Pods-watchOS-sample.release.xcconfig */, + FBBABD10A996E7CCA4B2F937 /* Pods-watchOS-sample WatchKit Extension.debug.xcconfig */, + EDC6FF21CD9F393E8FDF02F6 /* Pods-watchOS-sample WatchKit Extension.release.xcconfig */, ); path = Pods; sourceTree = ""; }; - 589283F4A582EEF2434E0220 /* Frameworks */ = { - isa = PBXGroup; - children = ( - 56BDF7E8B01683A4EFDEC9CF /* libPods-watchOS-sample.a */, - 76AFD66D880975F945E377C9 /* libPods-watchOS-sample WatchKit Extension.a */, - ); - name = Frameworks; - sourceTree = ""; - }; ABB17D4B22D93BAB00C26D6E = { isa = PBXGroup; children = ( @@ -151,7 +142,7 @@ ABB17D7D22D93BAC00C26D6E /* watchOS-sample-WatchKit-Extension */, ABB17D5522D93BAB00C26D6E /* Products */, 2C4A0708747AAA7298F757DA /* Pods */, - 589283F4A582EEF2434E0220 /* Frameworks */, + FDB2CA47351660A961DBE458 /* Frameworks */, ); sourceTree = ""; }; @@ -204,6 +195,15 @@ path = "watchOS-sample-WatchKit-Extension"; sourceTree = ""; }; + FDB2CA47351660A961DBE458 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 81BB6B1D8754281EF32EB3F2 /* libPods-watchOS-sample.a */, + 5B9B6F1C6465A4AAC45CAF14 /* libPods-watchOS-sample WatchKit Extension.a */, + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -211,12 +211,12 @@ isa = PBXNativeTarget; buildConfigurationList = ABB17D9122D93BAD00C26D6E /* Build configuration list for PBXNativeTarget "watchOS-sample" */; buildPhases = ( - 94316399D2F0BC04388E77B0 /* [CP] Check Pods Manifest.lock */, + C094DF31B83C380F13D80132 /* [CP] Check Pods Manifest.lock */, ABB17D5022D93BAB00C26D6E /* Sources */, ABB17D5122D93BAB00C26D6E /* Frameworks */, ABB17D5222D93BAB00C26D6E /* Resources */, ABB17D9022D93BAD00C26D6E /* Embed Watch Content */, - 1E38C9CB686CAEF71A5A25B7 /* [CP] Copy Pods Resources */, + E8B22C16C7C7397CEC79CCF6 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -250,11 +250,11 @@ isa = PBXNativeTarget; buildConfigurationList = ABB17D8922D93BAD00C26D6E /* Build configuration list for PBXNativeTarget "watchOS-sample WatchKit Extension" */; buildPhases = ( - 097AA61E20DEB1DB1E771FC9 /* [CP] Check Pods Manifest.lock */, + 370B91D5CA71A3A771721814 /* [CP] Check Pods Manifest.lock */, ABB17D7522D93BAC00C26D6E /* Sources */, ABB17D7622D93BAC00C26D6E /* Frameworks */, ABB17D7722D93BAC00C26D6E /* Resources */, - 8F82497BD93485F0621F0F30 /* [CP] Copy Pods Resources */, + DB65546E9DFC6EADD365E270 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -336,7 +336,7 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 097AA61E20DEB1DB1E771FC9 /* [CP] Check Pods Manifest.lock */ = { + 370B91D5CA71A3A771721814 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -358,41 +358,7 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 1E38C9CB686CAEF71A5A25B7 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-resources-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-resources-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 8F82497BD93485F0621F0F30 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-resources-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-resources-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 94316399D2F0BC04388E77B0 /* [CP] Check Pods Manifest.lock */ = { + C094DF31B83C380F13D80132 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -414,6 +380,40 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + DB65546E9DFC6EADD365E270 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + E8B22C16C7C7397CEC79CCF6 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -593,7 +593,7 @@ }; ABB17D8A22D93BAD00C26D6E /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 8C5540E3A034586596BEFE2B /* Pods-watchOS-sample WatchKit Extension.debug.xcconfig */; + baseConfigurationReference = FBBABD10A996E7CCA4B2F937 /* Pods-watchOS-sample WatchKit Extension.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication; CODE_SIGN_STYLE = Automatic; @@ -609,13 +609,13 @@ SDKROOT = watchos; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 5.1; + WATCHOS_DEPLOYMENT_TARGET = 4.0; }; name = Debug; }; ABB17D8B22D93BAD00C26D6E /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 0D53169393FEB36944484D25 /* Pods-watchOS-sample WatchKit Extension.release.xcconfig */; + baseConfigurationReference = EDC6FF21CD9F393E8FDF02F6 /* Pods-watchOS-sample WatchKit Extension.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication; CODE_SIGN_STYLE = Automatic; @@ -631,7 +631,7 @@ SDKROOT = watchos; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 5.1; + WATCHOS_DEPLOYMENT_TARGET = 4.0; }; name = Release; }; @@ -648,7 +648,7 @@ SDKROOT = watchos; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 5.1; + WATCHOS_DEPLOYMENT_TARGET = 4.0; }; name = Debug; }; @@ -665,13 +665,13 @@ SDKROOT = watchos; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 5.1; + WATCHOS_DEPLOYMENT_TARGET = 4.0; }; name = Release; }; ABB17D9222D93BAD00C26D6E /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = CC865626944D2C3DD838F762 /* Pods-watchOS-sample.debug.xcconfig */; + baseConfigurationReference = 574DCD2DDCABCC45B2308601 /* Pods-watchOS-sample.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; @@ -689,7 +689,7 @@ }; ABB17D9322D93BAD00C26D6E /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7DB8462D385A70A534800DAF /* Pods-watchOS-sample.release.xcconfig */; + baseConfigurationReference = 957B59E3DE8281B41B6DB3FD /* Pods-watchOS-sample.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample WatchKit App.xcscheme b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample WatchKit App.xcscheme new file mode 100644 index 00000000000..7c7e35eea14 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample WatchKit App.xcscheme @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample.xcscheme b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample.xcscheme new file mode 100644 index 00000000000..51e4fa09792 --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m b/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m index d78f5f2175c..4a76f4c488c 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m @@ -24,40 +24,4 @@ @implementation AppDelegate -- (BOOL)application:(UIApplication *)application - didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - // Override point for customization after application launch. - return YES; -} - -- (void)applicationWillResignActive:(UIApplication *)application { - // Sent when the application is about to move from active to inactive state. This can occur for - // certain types of temporary interruptions (such as an incoming phone call or SMS message) or - // when the user quits the application and it begins the transition to the background state. Use - // this method to pause ongoing tasks, disable timers, and invalidate graphics rendering - // callbacks. Games should use this method to pause the game. -} - -- (void)applicationDidEnterBackground:(UIApplication *)application { - // Use this method to release shared resources, save user data, invalidate timers, and store - // enough application state information to restore your application to its current state in case - // it is terminated later. If your application supports background execution, this method is - // called instead of applicationWillTerminate: when the user quits. -} - -- (void)applicationWillEnterForeground:(UIApplication *)application { - // Called as part of the transition from the background to the active state; here you can undo - // many of the changes made on entering the background. -} - -- (void)applicationDidBecomeActive:(UIApplication *)application { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If - // the application was previously in the background, optionally refresh the user interface. -} - -- (void)applicationWillTerminate:(UIApplication *)application { - // Called when the application is about to terminate. Save data if appropriate. See also - // applicationDidEnterBackground:. -} - @end diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m index cd06242f80b..d15c78482bb 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m @@ -26,9 +26,4 @@ @implementation ViewController -- (void)viewDidLoad { - [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. -} - @end From 3e4cdf20b04b199a77fd15e860404721d0ba6bbe Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 24 Jul 2019 18:16:12 -0700 Subject: [PATCH 0987/1555] Tring --objc_opt=generate_for_named_framework --- .../RemoteTestClient/RemoteTest.podspec | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec index cf7e317be70..5bf1252aed8 100644 --- a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec +++ b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec @@ -19,15 +19,26 @@ Pod::Spec.new do |s| protoc = "#{bin_dir}/protobuf/protoc" well_known_types_dir = "#{repo_root}/third_party/protobuf/src" plugin = "#{bin_dir}/grpc_objective_c_plugin" - + s.prepare_command = <<-CMD - #{protoc} \ - --plugin=protoc-gen-grpc=#{plugin} \ - --objc_out=. \ - --grpc_out=. \ - -I #{repo_root} \ - -I #{well_known_types_dir} \ - #{repo_root}/src/objective-c/examples/RemoteTestClient/*.proto + if [ "$FRAMEWORKS" == "" ]; then + #{protoc} \ + --plugin=protoc-gen-grpc=#{plugin} \ + --objc_out=. \ + --grpc_out=. \ + -I #{repo_root} \ + -I #{well_known_types_dir} \ + #{repo_root}/src/objective-c/examples/RemoteTestClient/*.proto + else + #{protoc} \ + --plugin=protoc-gen-grpc=#{plugin} \ + --objc_out=. \ + --grpc_out=. \ + --objc_opt=generate_for_named_framework=#{s.name} \ + -I #{repo_root} \ + -I #{well_known_types_dir} \ + #{repo_root}/src/objective-c/examples/RemoteTestClient/*.proto + fi CMD s.subspec 'Messages' do |ms| From 1d038a8f2970168901071c17f4dcc1765690a00a Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 24 Jul 2019 20:57:54 -0700 Subject: [PATCH 0988/1555] More proto fixes --- src/objective-c/GRPCClient/GRPCCall.h | 2 -- src/objective-c/ProtoRPC/ProtoRPC.h | 9 +++------ src/objective-c/ProtoRPC/ProtoRPC.m | 18 ------------------ src/objective-c/ProtoRPC/ProtoRPCLegacy.h | 7 ++++++- src/objective-c/ProtoRPC/ProtoRPCLegacy.m | 19 +++++++++++++++++++ 5 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index 2ab69480fb8..153ddc5c171 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -54,8 +54,6 @@ extern NSString *const kGRPCErrorDomain; * server applications to produce. */ typedef NS_ENUM(NSUInteger, GRPCErrorCode) { - GRPCErrorCodeOk = 0, - /** The operation was cancelled (typically by the caller). */ GRPCErrorCodeCancelled = 1, diff --git a/src/objective-c/ProtoRPC/ProtoRPC.h b/src/objective-c/ProtoRPC/ProtoRPC.h index ab9a180eb97..c91adc7b7cd 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.h +++ b/src/objective-c/ProtoRPC/ProtoRPC.h @@ -18,6 +18,9 @@ #import +// import legacy header for compatibility with users using the ProtoRPC interface +#import "ProtoRPCLegacy.h" + #import "ProtoMethod.h" NS_ASSUME_NONNULL_BEGIN @@ -160,10 +163,4 @@ NS_ASSUME_NONNULL_BEGIN @end -/** - * Generate an NSError object that represents a failure in parsing a proto class. For gRPC internal - * use only. - */ -NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError); - NS_ASSUME_NONNULL_END diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m index 4067dbd1820..dbfa3c0f23d 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.m +++ b/src/objective-c/ProtoRPC/ProtoRPC.m @@ -27,24 +27,6 @@ #import #import -/** - * Generate an NSError object that represents a failure in parsing a proto class. - */ -NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError) { - NSDictionary *info = @{ - NSLocalizedDescriptionKey : @"Unable to parse response from the server", - NSLocalizedRecoverySuggestionErrorKey : - @"If this RPC is idempotent, retry " - @"with exponential backoff. Otherwise, query the server status before " - @"retrying.", - NSUnderlyingErrorKey : parsingError, - @"Expected class" : expectedClass, - @"Received value" : proto, - }; - // TODO(jcanizales): Use kGRPCErrorDomain and GRPCErrorCodeInternal when they're public. - return [NSError errorWithDomain:@"io.grpc" code:13 userInfo:info]; -} - @implementation GRPCUnaryProtoCall { GRPCStreamingProtoCall *_call; GPBMessage *_message; diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.h b/src/objective-c/ProtoRPC/ProtoRPCLegacy.h index 893d8047104..bff487e9a0b 100644 --- a/src/objective-c/ProtoRPC/ProtoRPCLegacy.h +++ b/src/objective-c/ProtoRPC/ProtoRPCLegacy.h @@ -1,4 +1,3 @@ -#import "ProtoRPC.h" #import @class GRPCProtoMethod; @@ -32,3 +31,9 @@ __attribute__((deprecated("Please use GRPCProtoCall."))) @interface ProtoRPC @end +/** + * Generate an NSError object that represents a failure in parsing a proto class. For gRPC internal + * use only. + */ +NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError); + diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.m b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m index 45f873dc889..d20da5db840 100644 --- a/src/objective-c/ProtoRPC/ProtoRPCLegacy.m +++ b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m @@ -82,3 +82,22 @@ @implementation GRPCProtoCall @end + +/** + * Generate an NSError object that represents a failure in parsing a proto class. + */ +NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError) { + NSDictionary *info = @{ + NSLocalizedDescriptionKey : @"Unable to parse response from the server", + NSLocalizedRecoverySuggestionErrorKey : + @"If this RPC is idempotent, retry " + @"with exponential backoff. Otherwise, query the server status before " + @"retrying.", + NSUnderlyingErrorKey : parsingError, + @"Expected class" : expectedClass, + @"Received value" : proto, + }; + // TODO(jcanizales): Use kGRPCErrorDomain and GRPCErrorCodeInternal when they're public. + return [NSError errorWithDomain:@"io.grpc" code:13 userInfo:info]; +} + From 9e80f743266f5f44878b78a6877db7747f023e9e Mon Sep 17 00:00:00 2001 From: Pau Freixes Date: Sun, 5 May 2019 16:51:42 +0200 Subject: [PATCH 0989/1555] Add missing APP callback context for custom iomgr This PR adds the following missing APP callback context rerlated to the usage of a custom iomgr. - When a new TCP connection is established - When a new TCP connection is accepted - When a new domain resolution finishes - When network primitives, like read and write, finish they job Without these APP contexts, pending user app callbacks are never executed. --- src/core/lib/iomgr/resolve_address_custom.cc | 1 + src/core/lib/iomgr/tcp_client_custom.cc | 1 + src/core/lib/iomgr/tcp_custom.cc | 4 ++++ src/core/lib/iomgr/tcp_server_custom.cc | 1 + 4 files changed, 7 insertions(+) diff --git a/src/core/lib/iomgr/resolve_address_custom.cc b/src/core/lib/iomgr/resolve_address_custom.cc index 9cf7817f66e..fecc63c8bdf 100644 --- a/src/core/lib/iomgr/resolve_address_custom.cc +++ b/src/core/lib/iomgr/resolve_address_custom.cc @@ -71,6 +71,7 @@ void grpc_custom_resolve_callback(grpc_custom_resolver* r, grpc_resolved_addresses* result, grpc_error* error) { GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD(); + grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; if (error == GRPC_ERROR_NONE) { *r->addresses = result; diff --git a/src/core/lib/iomgr/tcp_client_custom.cc b/src/core/lib/iomgr/tcp_client_custom.cc index 14a8b78dc68..6f236ae4d4e 100644 --- a/src/core/lib/iomgr/tcp_client_custom.cc +++ b/src/core/lib/iomgr/tcp_client_custom.cc @@ -101,6 +101,7 @@ static void custom_connect_callback_internal(grpc_custom_socket* socket, static void custom_connect_callback(grpc_custom_socket* socket, grpc_error* error) { + grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; if (grpc_core::ExecCtx::Get() == nullptr) { /* If we are being run on a thread which does not have an exec_ctx created * yet, we should create one. */ diff --git a/src/core/lib/iomgr/tcp_custom.cc b/src/core/lib/iomgr/tcp_custom.cc index 66df5082e98..05cdd1ed358 100644 --- a/src/core/lib/iomgr/tcp_custom.cc +++ b/src/core/lib/iomgr/tcp_custom.cc @@ -145,6 +145,7 @@ static void call_read_cb(custom_tcp_endpoint* tcp, grpc_error* error) { static void custom_read_callback(grpc_custom_socket* socket, size_t nread, grpc_error* error) { + grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; grpc_slice_buffer garbage; custom_tcp_endpoint* tcp = (custom_tcp_endpoint*)socket->endpoint; @@ -207,6 +208,7 @@ static void endpoint_read(grpc_endpoint* ep, grpc_slice_buffer* read_slices, static void custom_write_callback(grpc_custom_socket* socket, grpc_error* error) { + grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; custom_tcp_endpoint* tcp = (custom_tcp_endpoint*)socket->endpoint; grpc_closure* cb = tcp->write_cb; @@ -301,6 +303,7 @@ static void custom_close_callback(grpc_custom_socket* socket) { grpc_custom_socket_vtable->destroy(socket); gpr_free(socket); } else if (socket->endpoint) { + grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; custom_tcp_endpoint* tcp = (custom_tcp_endpoint*)socket->endpoint; TCP_UNREF(tcp, "destroy"); @@ -343,6 +346,7 @@ grpc_endpoint* custom_tcp_endpoint_create(grpc_custom_socket* socket, char* peer_string) { custom_tcp_endpoint* tcp = (custom_tcp_endpoint*)gpr_malloc(sizeof(custom_tcp_endpoint)); + grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { diff --git a/src/core/lib/iomgr/tcp_server_custom.cc b/src/core/lib/iomgr/tcp_server_custom.cc index 767404be21d..c4fe5afb65b 100644 --- a/src/core/lib/iomgr/tcp_server_custom.cc +++ b/src/core/lib/iomgr/tcp_server_custom.cc @@ -245,6 +245,7 @@ static void custom_accept_callback(grpc_custom_socket* socket, static void custom_accept_callback(grpc_custom_socket* socket, grpc_custom_socket* client, grpc_error* error) { + grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; grpc_tcp_listener* sp = socket->listener; if (error != GRPC_ERROR_NONE) { From f20cfd38442cff30b94e2867436ad4f1ae4e404d Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 24 Jul 2019 21:40:58 -0700 Subject: [PATCH 0990/1555] Build system reorg --- gRPC-ProtoRPC.podspec | 18 ++++++++++++------ gRPC.podspec | 23 ++++++++++++++++------- src/objective-c/ProtoRPC/ProtoRPCLegacy.m | 2 ++ templates/gRPC-ProtoRPC.podspec.template | 18 ++++++++++++------ templates/gRPC.podspec.template | 23 ++++++++++++++++------- 5 files changed, 58 insertions(+), 26 deletions(-) diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 3de3c553567..28ef1d980c6 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -41,13 +41,18 @@ Pod::Spec.new do |s| s.module_name = name s.header_dir = name - src_dir = 'src/objective-c/ProtoRPC' + s.default_subspec = 'Main', 'Legacy', 'Legacy-Header' - s.default_subspec = 'Main', 'Legacy' + s.subspec 'Legacy-Header' do |ss| + ss.header_mappings_dir = "src/objective-c/ProtoRPC" + ss.public_header_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.h" + ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.h" + end s.subspec 'Main' do |ss| - ss.header_mappings_dir = "#{src_dir}" - ss.dependency 'gRPC', version + ss.header_mappings_dir = "src/objective-c/ProtoRPC" + ss.dependency "#{s.name}/Legacy-Header", version + ss.dependency 'gRPC/Interface', version ss.dependency 'Protobuf', '~> 3.0' ss.source_files = "src/objective-c/ProtoRPC/ProtoMethod.{h,m}", @@ -56,13 +61,14 @@ Pod::Spec.new do |s| end s.subspec 'Legacy' do |ss| - ss.header_mappings_dir = "#{src_dir}" + ss.header_mappings_dir = "src/objective-c/ProtoRPC" ss.dependency "#{s.name}/Main", version + ss.dependency "#{s.name}/Legacy-Header", version ss.dependency 'gRPC/GRPCCore', version ss.dependency 'gRPC-RxLibrary', version ss.dependency 'Protobuf', '~> 3.0' - ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.{h,m}", + ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.m", "src/objective-c/ProtoRPC/ProtoServiceLegacy.{h,m}" end diff --git a/gRPC.podspec b/gRPC.podspec index e4eb63ff4e7..7af8e841d78 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -42,15 +42,20 @@ Pod::Spec.new do |s| s.default_subspec = 'Interface', 'GRPCCore' - # Certificates, to be able to establish TLS connections: - s.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } - s.pod_target_xcconfig = { # This is needed by all pods that depend on gRPC-RxLibrary: 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES', 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO', } + s.subspec 'Interface-Legacy' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' + + ss.public_header_files = "src/objective-c/GRPCClient/GRPCCallLegacy.h" + + ss.source_files = "src/objective-c/GRPCClient/GRPCCallLegacy.h" + end + s.subspec 'Interface' do |ss| ss.header_mappings_dir = 'src/objective-c/GRPCClient' @@ -75,6 +80,8 @@ Pod::Spec.new do |s| 'src/objective-c/GRPCClient/GRPCTransport.m', 'src/objective-c/GRPCClient/private/GRPCTransport+Private.h', 'src/objective-c/GRPCClient/private/GRPCTransport+Private.m' + + ss.dependency "#{s.name}/Interface-Legacy", version end s.subspec 'GRPCCore' do |ss| @@ -84,7 +91,6 @@ Pod::Spec.new do |s| 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', 'src/objective-c/GRPCClient/GRPCCall+Tests.h', - 'src/objective-c/GRPCClient/GRPCCallLegacy.h', 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', 'src/objective-c/GRPCClient/internal_testing/*.h' ss.private_header_files = 'src/objective-c/GRPCClient/private/GRPCCore/*.h' @@ -100,11 +106,13 @@ Pod::Spec.new do |s| 'src/objective-c/GRPCClient/GRPCCall+OAuth2.m', 'src/objective-c/GRPCClient/GRPCCall+Tests.h', 'src/objective-c/GRPCClient/GRPCCall+Tests.m', - 'src/objective-c/GRPCClient/GRPCCallLegacy.h', 'src/objective-c/GRPCClient/GRPCCallLegacy.m' - ss.dependency 'gRPC-Core', version + # Certificates, to be able to establish TLS connections: + ss.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } + ss.dependency "#{s.name}/Interface", version + ss.dependency 'gRPC-Core', version ss.dependency 'gRPC-RxLibrary', version end @@ -114,8 +122,9 @@ Pod::Spec.new do |s| ss.source_files = 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', 'src/objective-c/GRPCClient/GRPCCall+Cronet.m', 'src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/*.{h,m}' - ss.dependency 'CronetFramework' + ss.dependency "#{s.name}/GRPCCore", version ss.dependency 'gRPC-Core/Cronet-Implementation', version + ss.dependency 'CronetFramework' end # CFStream is now default. Leaving this subspec only for compatibility purpose. diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.m b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m index d20da5db840..a4ea1836bdf 100644 --- a/src/objective-c/ProtoRPC/ProtoRPCLegacy.m +++ b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m @@ -1,5 +1,7 @@ #import "ProtoRPCLegacy.h" +#import "ProtoMethod.h" + #if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS #import #else diff --git a/templates/gRPC-ProtoRPC.podspec.template b/templates/gRPC-ProtoRPC.podspec.template index 8c0d7ffdb3e..b8a881c06a9 100644 --- a/templates/gRPC-ProtoRPC.podspec.template +++ b/templates/gRPC-ProtoRPC.podspec.template @@ -43,13 +43,18 @@ s.module_name = name s.header_dir = name - src_dir = 'src/objective-c/ProtoRPC' + s.default_subspec = 'Main', 'Legacy', 'Legacy-Header' - s.default_subspec = 'Main', 'Legacy' + s.subspec 'Legacy-Header' do |ss| + ss.header_mappings_dir = "src/objective-c/ProtoRPC" + ss.public_header_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.h" + ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.h" + end s.subspec 'Main' do |ss| - ss.header_mappings_dir = "#{src_dir}" - ss.dependency 'gRPC', version + ss.header_mappings_dir = "src/objective-c/ProtoRPC" + ss.dependency "#{s.name}/Legacy-Header", version + ss.dependency 'gRPC/Interface', version ss.dependency 'Protobuf', '~> 3.0' ss.source_files = "src/objective-c/ProtoRPC/ProtoMethod.{h,m}", @@ -58,13 +63,14 @@ end s.subspec 'Legacy' do |ss| - ss.header_mappings_dir = "#{src_dir}" + ss.header_mappings_dir = "src/objective-c/ProtoRPC" ss.dependency "#{s.name}/Main", version + ss.dependency "#{s.name}/Legacy-Header", version ss.dependency 'gRPC/GRPCCore', version ss.dependency 'gRPC-RxLibrary', version ss.dependency 'Protobuf', '~> 3.0' - ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.{h,m}", + ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.m", "src/objective-c/ProtoRPC/ProtoServiceLegacy.{h,m}" end diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index 146da4a323a..59ef8290b6f 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -44,15 +44,20 @@ s.default_subspec = 'Interface', 'GRPCCore' - # Certificates, to be able to establish TLS connections: - s.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } - s.pod_target_xcconfig = { # This is needed by all pods that depend on gRPC-RxLibrary: 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES', 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO', } + s.subspec 'Interface-Legacy' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' + + ss.public_header_files = "src/objective-c/GRPCClient/GRPCCallLegacy.h" + + ss.source_files = "src/objective-c/GRPCClient/GRPCCallLegacy.h" + end + s.subspec 'Interface' do |ss| ss.header_mappings_dir = 'src/objective-c/GRPCClient' @@ -77,6 +82,8 @@ 'src/objective-c/GRPCClient/GRPCTransport.m', 'src/objective-c/GRPCClient/private/GRPCTransport+Private.h', 'src/objective-c/GRPCClient/private/GRPCTransport+Private.m' + + ss.dependency "#{s.name}/Interface-Legacy", version end s.subspec 'GRPCCore' do |ss| @@ -86,7 +93,6 @@ 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', 'src/objective-c/GRPCClient/GRPCCall+Tests.h', - 'src/objective-c/GRPCClient/GRPCCallLegacy.h', 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', 'src/objective-c/GRPCClient/internal_testing/*.h' ss.private_header_files = 'src/objective-c/GRPCClient/private/GRPCCore/*.h' @@ -102,11 +108,13 @@ 'src/objective-c/GRPCClient/GRPCCall+OAuth2.m', 'src/objective-c/GRPCClient/GRPCCall+Tests.h', 'src/objective-c/GRPCClient/GRPCCall+Tests.m', - 'src/objective-c/GRPCClient/GRPCCallLegacy.h', 'src/objective-c/GRPCClient/GRPCCallLegacy.m' - ss.dependency 'gRPC-Core', version + # Certificates, to be able to establish TLS connections: + ss.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } + ss.dependency "#{s.name}/Interface", version + ss.dependency 'gRPC-Core', version ss.dependency 'gRPC-RxLibrary', version end @@ -116,8 +124,9 @@ ss.source_files = 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', 'src/objective-c/GRPCClient/GRPCCall+Cronet.m', 'src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/*.{h,m}' - ss.dependency 'CronetFramework' + ss.dependency "#{s.name}/GRPCCore", version ss.dependency 'gRPC-Core/Cronet-Implementation', version + ss.dependency 'CronetFramework' end # CFStream is now default. Leaving this subspec only for compatibility purpose. From 8fa870c4e55780e96b6d39e07685363befb2f7fd Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 25 Jul 2019 14:17:54 +0200 Subject: [PATCH 0991/1555] Make UnaryCallOverheadBenchmark parametrized --- .../UnaryCallOverheadBenchmark.cs | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs index 4953806f6f4..8448f03dd62 100644 --- a/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs @@ -33,14 +33,28 @@ namespace Grpc.Microbenchmarks public class UnaryCallOverheadBenchmark { private static readonly Task CompletedString = Task.FromResult(""); - private static readonly byte[] EmptyBlob = new byte[0]; - private static readonly Marshaller EmptyMarshaller = new Marshaller(_ => EmptyBlob, _ => ""); - private static readonly Method PingMethod = new Method(MethodType.Unary, nameof(PingBenchmark), "Ping", EmptyMarshaller, EmptyMarshaller); + private static readonly Marshaller IdentityMarshaller = new Marshaller(msg => msg, payload => payload); + private static readonly Method PingMethod = new Method(MethodType.Unary, nameof(PingBenchmark), "Ping", IdentityMarshaller, IdentityMarshaller); + + private int payloadSize; + private byte[] payload; + + // size of payload that is sent as request and received as response. + [Params(0, 1, 10, 100, 1000)] + public int PayloadSize + { + get { return payloadSize; } + set + { + payloadSize = value; + payload = new byte[value]; + } + } [Benchmark] - public string SyncUnaryCallOverhead() + public byte[] SyncUnaryCallOverhead() { - return client.Ping("", new CallOptions()); + return client.Ping(payload, new CallOptions()); } Channel channel; @@ -81,7 +95,7 @@ namespace Grpc.Microbenchmarks { public PingClient(CallInvoker callInvoker) : base(callInvoker) { } - public string Ping(string request, CallOptions options) + public byte[] Ping(byte[] request, CallOptions options) { return CallInvoker.BlockingUnaryCall(PingMethod, null, options, request); } From 5e1f96c5b8588b48cfdd1d86dd2f411670c58275 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 25 Jul 2019 08:45:02 -0700 Subject: [PATCH 0992/1555] Test fixes --- .../tests/CronetTests/InteropTestsRemoteWithCronet.m | 8 +------- src/objective-c/tests/InteropTests/InteropTests.h | 5 ----- src/objective-c/tests/InteropTests/InteropTests.m | 9 ++++----- src/objective-c/tests/Podfile | 4 ++-- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m index c1c51fb06ab..37fa1b418c1 100644 --- a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m +++ b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m @@ -44,9 +44,7 @@ static int32_t kRemoteInteropServerOverhead = 12; + (void)setUp { configureCronet(); - if ([self useCronet]) { - [GRPCCall useCronetWithEngine:[Cronet getGlobalEngine]]; - } + [GRPCCall useCronetWithEngine:[Cronet getGlobalEngine]]; [super setUp]; } @@ -60,10 +58,6 @@ static int32_t kRemoteInteropServerOverhead = 12; return gGRPCCoreCronetId; } -+ (BOOL)useCronet { - return YES; -} - - (int32_t)encodingOverhead { return kRemoteInteropServerOverhead; // bytes } diff --git a/src/objective-c/tests/InteropTests/InteropTests.h b/src/objective-c/tests/InteropTests/InteropTests.h index b6af8e316e2..17fdedc75f4 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.h +++ b/src/objective-c/tests/InteropTests/InteropTests.h @@ -67,9 +67,4 @@ */ + (NSString *)hostNameOverride; -/** - * Whether to use Cronet for all the v1 API tests in the test suite. - */ -+ (BOOL)useCronet; - @end diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 25f96050e59..dcdbdc2beb5 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -20,7 +20,6 @@ #include -#import #import #import #import @@ -412,10 +411,6 @@ static dispatch_once_t initGlobalInterceptorFactory; return nil; } -+ (BOOL)useCronet { - return NO; -} - + (void)setUp { dispatch_once(&initGlobalInterceptorFactory, ^{ dispatch_queue_t globalInterceptorQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); @@ -1268,6 +1263,10 @@ static dispatch_once_t initGlobalInterceptorFactory; - (void)testKeepaliveWithV2API { XCTAssertNotNil([[self class] host]); + if ([[self class] transport] == gGRPCCoreCronetId) { + // Cronet does not support keepalive + return; + } __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Keepalive"]; diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile index 20a68f7bf67..7f50fa19c5a 100644 --- a/src/objective-c/tests/Podfile +++ b/src/objective-c/tests/Podfile @@ -116,7 +116,7 @@ post_install do |installer| # the test target 'InteropTestsRemoteWithCronet' # Activate GRPCCall+InternalTests functions for the dedicated build configuration 'Test', which will # be used by all test targets using it. - if /gRPC(-macOS|-iOS|\.)/.match(target.name) + if /gRPC(-macOS|-iOS|\.|-[0-9a-f])/.match(target.name) target.build_configurations.each do |config| if config.name == 'Cronet' config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_COMPILE_WITH_CRONET=1 GRPC_TEST_OBJC=1' @@ -127,7 +127,7 @@ post_install do |installer| end # Enable NSAssert on gRPC - if /(gRPC|ProtoRPC|RxLibrary)-(mac|i)OS/.match(target.name) + if /(gRPC|ProtoRPC|RxLibrary)/.match(target.name) target.build_configurations.each do |config| if config.name != 'Release' config.build_settings['ENABLE_NS_ASSERTIONS'] = 'YES' From 08b21aed41d92e0e1b8477cd89a5a7b80ecbf75c Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 25 Jul 2019 09:53:15 -0700 Subject: [PATCH 0993/1555] add comments and clang-format --- src/compiler/objective_c_generator.cc | 19 ++- src/compiler/objective_c_generator.h | 9 +- src/compiler/objective_c_plugin.cc | 27 +++- src/objective-c/GRPCClient/GRPCCall+Cronet.h | 3 +- src/objective-c/GRPCClient/GRPCCall.m | 69 ++++---- src/objective-c/GRPCClient/GRPCCallLegacy.h | 2 +- src/objective-c/GRPCClient/GRPCCallLegacy.m | 4 +- src/objective-c/GRPCClient/GRPCCallOptions.m | 14 +- src/objective-c/GRPCClient/GRPCDispatchable.h | 2 +- src/objective-c/GRPCClient/GRPCInterceptor.h | 11 +- src/objective-c/GRPCClient/GRPCInterceptor.m | 147 +++++++++--------- src/objective-c/GRPCClient/GRPCTransport.h | 29 +++- src/objective-c/GRPCClient/GRPCTransport.m | 44 +++--- .../private/GRPCCore/GRPCCallInternal.h | 5 +- .../private/GRPCCore/GRPCCallInternal.m | 46 +++--- .../GRPCClient/private/GRPCCore/GRPCChannel.m | 48 +++--- .../private/GRPCCore/GRPCChannelPool.h | 2 +- .../GRPCCoreCronet/GRPCCoreCronetFactory.h | 9 ++ .../GRPCCoreCronet/GRPCCoreCronetFactory.m | 9 +- .../private/GRPCCore/GRPCCoreFactory.h | 9 +- .../private/GRPCCore/GRPCCoreFactory.m | 20 ++- .../GRPCClient/private/GRPCCore/GRPCHost.m | 4 +- .../private/GRPCTransport+Private.h | 21 ++- .../private/GRPCTransport+Private.m | 11 +- src/objective-c/ProtoRPC/ProtoRPCLegacy.h | 37 ++--- src/objective-c/ProtoRPC/ProtoRPCLegacy.m | 8 +- src/objective-c/ProtoRPC/ProtoService.h | 12 +- src/objective-c/ProtoRPC/ProtoServiceLegacy.m | 5 +- .../InteropTestsRemoteWithCronet.m | 4 +- .../tests/InteropTests/InteropTests.m | 131 ++++++++-------- .../InteropTests/InteropTestsLocalCleartext.m | 4 +- .../tests/InteropTests/InteropTestsLocalSSL.m | 4 +- 32 files changed, 433 insertions(+), 336 deletions(-) diff --git a/src/compiler/objective_c_generator.cc b/src/compiler/objective_c_generator.cc index 837113841a8..122ea3c3b69 100644 --- a/src/compiler/objective_c_generator.cc +++ b/src/compiler/objective_c_generator.cc @@ -278,7 +278,8 @@ void PrintMethodImplementations(Printer* printer, return output; } -::grpc::string GetProtocol(const ServiceDescriptor* service, const Parameters& generator_params) { +::grpc::string GetProtocol(const ServiceDescriptor* service, + const Parameters& generator_params) { ::grpc::string output; if (generator_params.no_v1_compatibility) return output; @@ -325,7 +326,8 @@ void PrintMethodImplementations(Printer* printer, return output; } -::grpc::string GetInterface(const ServiceDescriptor* service, const Parameters& generator_params) { +::grpc::string GetInterface(const ServiceDescriptor* service, + const Parameters& generator_params) { ::grpc::string output; // Scope the output stream so it closes and finalizes output to the string. @@ -367,7 +369,8 @@ void PrintMethodImplementations(Printer* printer, return output; } -::grpc::string GetSource(const ServiceDescriptor* service, const Parameters& generator_params) { +::grpc::string GetSource(const ServiceDescriptor* service, + const Parameters& generator_params) { ::grpc::string output; { // Scope the output stream so it closes and finalizes output to the string. @@ -422,9 +425,10 @@ void PrintMethodImplementations(Printer* printer, printer.Print("#pragma mark - Class Methods\n\n"); if (!generator_params.no_v1_compatibility) { - printer.Print("+ (instancetype)serviceWithHost:(NSString *)host {\n" - " return [[self alloc] initWithHost:host];\n" - "}\n\n"); + printer.Print( + "+ (instancetype)serviceWithHost:(NSString *)host {\n" + " return [[self alloc] initWithHost:host];\n" + "}\n\n"); } printer.Print( "+ (instancetype)serviceWithHost:(NSString *)host " @@ -435,7 +439,8 @@ void PrintMethodImplementations(Printer* printer, printer.Print("#pragma mark - Method Implementations\n\n"); for (int i = 0; i < service->method_count(); i++) { - PrintMethodImplementations(&printer, service->method(i), generator_params); + PrintMethodImplementations(&printer, service->method(i), + generator_params); } printer.Print("@end\n"); diff --git a/src/compiler/objective_c_generator.h b/src/compiler/objective_c_generator.h index 3f5b3e8b780..518962fceee 100644 --- a/src/compiler/objective_c_generator.h +++ b/src/compiler/objective_c_generator.h @@ -39,7 +39,8 @@ string GetAllMessageClasses(const FileDescriptor* file); // Returns the content to be included defining the @protocol segment at the // insertion point of the generated implementation file. This interface is // legacy and for backwards compatibility. -string GetProtocol(const ServiceDescriptor* service, const Parameters& generator_params); +string GetProtocol(const ServiceDescriptor* service, + const Parameters& generator_params); // Returns the content to be included defining the @protocol segment at the // insertion point of the generated implementation file. @@ -47,11 +48,13 @@ string GetV2Protocol(const ServiceDescriptor* service); // Returns the content to be included defining the @interface segment at the // insertion point of the generated implementation file. -string GetInterface(const ServiceDescriptor* service, const Parameters& generator_params); +string GetInterface(const ServiceDescriptor* service, + const Parameters& generator_params); // Returns the content to be included in the "global_scope" insertion point of // the generated implementation file. -string GetSource(const ServiceDescriptor* service, const Parameters& generator_params); +string GetSource(const ServiceDescriptor* service, + const Parameters& generator_params); } // namespace grpc_objective_c_generator diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index 21c68995cbb..cdd184b6c18 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -104,8 +104,13 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string imports = LocalImport(file_name + ".pbobjc.h"); - ::grpc::string system_imports = (generator_params.no_v1_compatibility ? SystemImport("ProtoRPC/ProtoService.h") : SystemImport("ProtoRPC/ProtoServiceLegacy.h")) + - (generator_params.no_v1_compatibility ? SystemImport("ProtoRPC/ProtoRPC.h") : SystemImport("ProtoRPC/ProtoRPCLegacy.h")); + ::grpc::string system_imports = + (generator_params.no_v1_compatibility + ? SystemImport("ProtoRPC/ProtoService.h") + : SystemImport("ProtoRPC/ProtoServiceLegacy.h")) + + (generator_params.no_v1_compatibility + ? SystemImport("ProtoRPC/ProtoRPC.h") + : SystemImport("ProtoRPC/ProtoRPCLegacy.h")); if (!generator_params.no_v1_compatibility) { system_imports += SystemImport("RxLibrary/GRXWriteable.h") + SystemImport("RxLibrary/GRXWriter.h"); @@ -138,13 +143,15 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string protocols; for (int i = 0; i < file->service_count(); i++) { const grpc::protobuf::ServiceDescriptor* service = file->service(i); - protocols += grpc_objective_c_generator::GetProtocol(service, generator_params); + protocols += + grpc_objective_c_generator::GetProtocol(service, generator_params); } ::grpc::string interfaces; for (int i = 0; i < file->service_count(); i++) { const grpc::protobuf::ServiceDescriptor* service = file->service(i); - interfaces += grpc_objective_c_generator::GetInterface(service, generator_params); + interfaces += + grpc_objective_c_generator::GetInterface(service, generator_params); } Write(context, file_name + ".pbrpc.h", @@ -161,9 +168,12 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { { // Generate .pbrpc.m - ::grpc::string imports = LocalImport(file_name + ".pbrpc.h") + - LocalImport(file_name + ".pbobjc.h") + - (generator_params.no_v1_compatibility ? SystemImport("ProtoRPC/ProtoRPC.h") : SystemImport("ProtoRPC/ProtoRPCLegacy.h")); + ::grpc::string imports = + LocalImport(file_name + ".pbrpc.h") + + LocalImport(file_name + ".pbobjc.h") + + (generator_params.no_v1_compatibility + ? SystemImport("ProtoRPC/ProtoRPC.h") + : SystemImport("ProtoRPC/ProtoRPCLegacy.h")); if (!generator_params.no_v1_compatibility) { imports += SystemImport("RxLibrary/GRXWriter+Immediate.h"); } @@ -176,7 +186,8 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string definitions; for (int i = 0; i < file->service_count(); i++) { const grpc::protobuf::ServiceDescriptor* service = file->service(i); - definitions += grpc_objective_c_generator::GetSource(service, generator_params); + definitions += + grpc_objective_c_generator::GetSource(service, generator_params); } Write(context, file_name + ".pbrpc.m", diff --git a/src/objective-c/GRPCClient/GRPCCall+Cronet.h b/src/objective-c/GRPCClient/GRPCCall+Cronet.h index c77816b8df6..c49d7cf16f3 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Cronet.h +++ b/src/objective-c/GRPCClient/GRPCCall+Cronet.h @@ -24,7 +24,7 @@ typedef struct stream_engine stream_engine; // Transport id for Cronet transport extern const GRPCTransportId gGRPCCoreCronetId; -// Deprecated class. Please use the previous transport id with GRPCCallOptions instead. +// Deprecated class. Please use the gGRPCCoreCronetId with GRPCCallOptions.transport instead. @interface GRPCCall (Cronet) + (void)useCronetWithEngine:(stream_engine*)engine; @@ -32,4 +32,3 @@ extern const GRPCTransportId gGRPCCoreCronetId; + (BOOL)isUsingCronet; @end - diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index c62cb03ddd8..26f42032537 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -18,9 +18,9 @@ #import "GRPCCall.h" +#import "GRPCCall+Interceptor.h" #import "GRPCCallOptions.h" #import "GRPCInterceptor.h" -#import "GRPCCall+Interceptor.h" #import "private/GRPCTransport+Private.h" @@ -32,7 +32,7 @@ NSString *const kGRPCTrailersKey = @"io.grpc.TrailersKey"; * dispatch queue of a user provided response handler. It removes the requirement of having to use * serial dispatch queue in the user provided response handler. */ -@interface GRPCResponseDispatcher : NSObject +@interface GRPCResponseDispatcher : NSObject - (nullable instancetype)initWithResponseHandler:(id)responseHandler; @@ -48,7 +48,9 @@ NSString *const kGRPCTrailersKey = @"io.grpc.TrailersKey"; _responseHandler = responseHandler; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 if (@available(iOS 8.0, macOS 10.10, *)) { - _dispatchQueue = dispatch_queue_create(NULL, dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); + _dispatchQueue = dispatch_queue_create( + NULL, + dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); } else { #else { @@ -61,38 +63,38 @@ NSString *const kGRPCTrailersKey = @"io.grpc.TrailersKey"; return self; } - - (dispatch_queue_t)dispatchQueue { - return _dispatchQueue; - } +- (dispatch_queue_t)dispatchQueue { + return _dispatchQueue; +} - - (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata { - if ([_responseHandler respondsToSelector:@selector(didReceiveInitialMetadata:)]) { - [_responseHandler didReceiveInitialMetadata:initialMetadata]; - } +- (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata { + if ([_responseHandler respondsToSelector:@selector(didReceiveInitialMetadata:)]) { + [_responseHandler didReceiveInitialMetadata:initialMetadata]; } +} - - (void)didReceiveData:(id)data { - // For backwards compatibility with didReceiveRawMessage, if the user provided a response handler - // that handles didReceiveRawMesssage, we issue to that method instead - if ([_responseHandler respondsToSelector:@selector(didReceiveRawMessage:)]) { - [_responseHandler didReceiveRawMessage:data]; - } else if ([_responseHandler respondsToSelector:@selector(didReceiveData:)]) { - [_responseHandler didReceiveData:data]; - } +- (void)didReceiveData:(id)data { + // For backwards compatibility with didReceiveRawMessage, if the user provided a response handler + // that handles didReceiveRawMesssage, we issue to that method instead + if ([_responseHandler respondsToSelector:@selector(didReceiveRawMessage:)]) { + [_responseHandler didReceiveRawMessage:data]; + } else if ([_responseHandler respondsToSelector:@selector(didReceiveData:)]) { + [_responseHandler didReceiveData:data]; } +} - - (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata -error:(nullable NSError *)error { +- (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata + error:(nullable NSError *)error { if ([_responseHandler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { [_responseHandler didCloseWithTrailingMetadata:trailingMetadata error:error]; } } - - (void)didWriteData { - if ([_responseHandler respondsToSelector:@selector(didWriteData)]) { - [_responseHandler didWriteData]; - } +- (void)didWriteData { + if ([_responseHandler respondsToSelector:@selector(didWriteData)]) { + [_responseHandler didWriteData]; } +} @end @@ -166,10 +168,12 @@ error:(nullable NSError *)error { } _responseHandler = responseHandler; - GRPCResponseDispatcher *dispatcher = [[GRPCResponseDispatcher alloc] initWithResponseHandler:_responseHandler]; + GRPCResponseDispatcher *dispatcher = + [[GRPCResponseDispatcher alloc] initWithResponseHandler:_responseHandler]; NSMutableArray> *interceptorFactories; if (_actualCallOptions.interceptorFactories != nil) { - interceptorFactories = [NSMutableArray arrayWithArray:_actualCallOptions.interceptorFactories]; + interceptorFactories = + [NSMutableArray arrayWithArray:_actualCallOptions.interceptorFactories]; } else { interceptorFactories = [NSMutableArray array]; } @@ -180,12 +184,14 @@ error:(nullable NSError *)error { // continuously create interceptor until one is successfully created while (_firstInterceptor == nil) { if (interceptorFactories.count == 0) { - _firstInterceptor = [[GRPCTransportManager alloc] initWithTransportId:_callOptions.transport previousInterceptor:dispatcher]; + _firstInterceptor = [[GRPCTransportManager alloc] initWithTransportId:_callOptions.transport + previousInterceptor:dispatcher]; break; } else { - _firstInterceptor = [[GRPCInterceptorManager alloc] initWithFactories:interceptorFactories - previousInterceptor:dispatcher - transportId:_callOptions.transport]; + _firstInterceptor = + [[GRPCInterceptorManager alloc] initWithFactories:interceptorFactories + previousInterceptor:dispatcher + transportId:_callOptions.transport]; if (_firstInterceptor == nil) { [interceptorFactories removeObjectAtIndex:0]; } @@ -211,8 +217,7 @@ error:(nullable NSError *)error { GRPCRequestOptions *requestOptions = _requestOptions; GRPCCallOptions *callOptions = _actualCallOptions; dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ - [copiedFirstInterceptor startWithRequestOptions:requestOptions - callOptions:callOptions]; + [copiedFirstInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; }); } diff --git a/src/objective-c/GRPCClient/GRPCCallLegacy.h b/src/objective-c/GRPCClient/GRPCCallLegacy.h index 6c2c8ceada8..e6103498639 100644 --- a/src/objective-c/GRPCClient/GRPCCallLegacy.h +++ b/src/objective-c/GRPCClient/GRPCCallLegacy.h @@ -21,8 +21,8 @@ * the API in GRPCCall.h. This API exists solely for the purpose of backwards compatibility. */ -#import "GRPCCallOptions.h" #import +#import "GRPCCallOptions.h" #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnullability-completeness" diff --git a/src/objective-c/GRPCClient/GRPCCallLegacy.m b/src/objective-c/GRPCClient/GRPCCallLegacy.m index 18a1eda1b39..e25048cfc7e 100644 --- a/src/objective-c/GRPCClient/GRPCCallLegacy.m +++ b/src/objective-c/GRPCClient/GRPCCallLegacy.m @@ -18,9 +18,9 @@ #import "GRPCCallLegacy.h" +#import "GRPCCall+Cronet.h" #import "GRPCCall+OAuth2.h" #import "GRPCCallOptions.h" -#import "GRPCCall+Cronet.h" #import "private/GRPCCore/GRPCChannelPool.h" #import "private/GRPCCore/GRPCCompletionQueue.h" @@ -552,7 +552,7 @@ static NSString *const kBearerPrefix = @"Bearer "; [[GRXConcurrentWriteable alloc] initWithWriteable:writeable dispatchQueue:_responseQueue]; GRPCPooledChannel *channel = - [[GRPCChannelPool sharedInstance] channelWithHost:_host callOptions:_callOptions]; + [[GRPCChannelPool sharedInstance] channelWithHost:_host callOptions:_callOptions]; _wrappedCall = [channel wrappedCallWithPath:_path completionQueue:[GRPCCompletionQueue completionQueue] callOptions:_callOptions]; diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.m b/src/objective-c/GRPCClient/GRPCCallOptions.m index 2080f9915a9..7f88098eb6f 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.m +++ b/src/objective-c/GRPCClient/GRPCCallOptions.m @@ -17,8 +17,8 @@ */ #import "GRPCCallOptions.h" -#import "internal/GRPCCallOptions+Internal.h" #import "GRPCTransport.h" +#import "internal/GRPCCallOptions+Internal.h" // The default values for the call options. static NSString *const kDefaultServerAuthority = nil; @@ -138,7 +138,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:kDefaultPEMPrivateKey PEMCertificateChain:kDefaultPEMCertificateChain transportType:kDefaultTransportType - transport:kDefaultTransport + transport:kDefaultTransport hostNameOverride:kDefaultHostNameOverride logContext:kDefaultLogContext channelPoolDomain:kDefaultChannelPoolDomain @@ -166,7 +166,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:(NSString *)PEMPrivateKey PEMCertificateChain:(NSString *)PEMCertificateChain transportType:(GRPCTransportType)transportType - transport:(GRPCTransportId)transport + transport:(GRPCTransportId)transport hostNameOverride:(NSString *)hostNameOverride logContext:(id)logContext channelPoolDomain:(NSString *)channelPoolDomain @@ -231,7 +231,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:_PEMPrivateKey PEMCertificateChain:_PEMCertificateChain transportType:_transportType - transport:_transport + transport:_transport hostNameOverride:_hostNameOverride logContext:_logContext channelPoolDomain:_channelPoolDomain @@ -264,7 +264,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:[_PEMPrivateKey copy] PEMCertificateChain:[_PEMCertificateChain copy] transportType:_transportType - transport:_transport + transport:_transport hostNameOverride:[_hostNameOverride copy] logContext:_logContext channelPoolDomain:[_channelPoolDomain copy] @@ -375,7 +375,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:kDefaultPEMPrivateKey PEMCertificateChain:kDefaultPEMCertificateChain transportType:kDefaultTransportType - transport:kDefaultTransport + transport:kDefaultTransport hostNameOverride:kDefaultHostNameOverride logContext:kDefaultLogContext channelPoolDomain:kDefaultChannelPoolDomain @@ -436,7 +436,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:_PEMPrivateKey PEMCertificateChain:_PEMCertificateChain transportType:_transportType - transport:_transport + transport:_transport hostNameOverride:_hostNameOverride logContext:_logContext channelPoolDomain:_channelPoolDomain diff --git a/src/objective-c/GRPCClient/GRPCDispatchable.h b/src/objective-c/GRPCClient/GRPCDispatchable.h index 3322766e3bc..650103603d4 100644 --- a/src/objective-c/GRPCClient/GRPCDispatchable.h +++ b/src/objective-c/GRPCClient/GRPCDispatchable.h @@ -18,7 +18,7 @@ */ /** - * An object that process its methods with a dispatch queue. + * An object that processes its methods with a dispatch queue. */ @protocol GRPCDispatchable diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.h b/src/objective-c/GRPCClient/GRPCInterceptor.h index f8a97ac13e8..509749769b3 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.h +++ b/src/objective-c/GRPCClient/GRPCInterceptor.h @@ -169,7 +169,7 @@ NS_ASSUME_NONNULL_BEGIN * invoke shutDown method of its corresponding manager so that references to other interceptors can * be released. */ -@interface GRPCInterceptorManager : NSObject +@interface GRPCInterceptorManager : NSObject - (instancetype)init NS_UNAVAILABLE; @@ -179,6 +179,10 @@ NS_ASSUME_NONNULL_BEGIN previousInterceptor:(nullable id)previousInterceptor transportId:(GRPCTransportId)transportId; +/** + * Notify the manager that the interceptor has shut down and the manager should release references + * to other interceptors and stop forwarding requests/responses. + */ - (void)shutDown; // Methods to forward GRPCInterceptorInterface calls to the next interceptor @@ -230,7 +234,7 @@ NS_ASSUME_NONNULL_BEGIN @interface GRPCInterceptor : NSObject - (instancetype)init NS_UNAVAILABLE; -+ (instancetype)new NS_UNAVAILABLE; ++ (instancetype) new NS_UNAVAILABLE; /** * Initialize the interceptor with the next interceptor in the chain, and provide the dispatch queue @@ -241,7 +245,8 @@ NS_ASSUME_NONNULL_BEGIN // Default implementation of GRPCInterceptorInterface -- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions; +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions + callOptions:(GRPCCallOptions *)callOptions; - (void)writeData:(id)data; - (void)finish; - (void)cancel; diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.m b/src/objective-c/GRPCClient/GRPCInterceptor.m index aa3380cc024..b18f7550260 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.m +++ b/src/objective-c/GRPCClient/GRPCInterceptor.m @@ -40,7 +40,8 @@ transportId:(nonnull GRPCTransportId)transportId { if ((self = [super init])) { if (factories.count == 0) { - [NSException raise:NSInternalInconsistencyException format:@"Interceptor manager must have factories"]; + [NSException raise:NSInternalInconsistencyException + format:@"Interceptor manager must have factories"]; } _thisInterceptor = [factories[0] createInterceptorWithManager:self]; if (_thisInterceptor == nil) { @@ -48,20 +49,22 @@ } _previousInterceptor = previousInterceptor; _factories = factories; - // Generate interceptor + // Generate interceptor #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 if (@available(iOS 8.0, macOS 10.10, *)) { - _dispatchQueue = dispatch_queue_create(NULL, dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); + _dispatchQueue = dispatch_queue_create( + NULL, + dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); } else { #else - { + { #endif - _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); - } - dispatch_set_target_queue(_dispatchQueue, _thisInterceptor.dispatchQueue); - _transportId = transportId; + _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); + } + dispatch_set_target_queue(_dispatchQueue, _thisInterceptor.dispatchQueue); + _transportId = transportId; } - return self; + return self; } - (void)shutDown { @@ -71,35 +74,37 @@ _shutDown = YES; } - - (void)createNextInterceptor { - NSAssert(_nextInterceptor == nil, @"Starting the next interceptor more than once"); - NSAssert(_factories.count > 0, @"Interceptor manager of transport cannot start next interceptor"); - if (_nextInterceptor != nil) { - NSLog(@"Starting the next interceptor more than once"); - return; - } - NSMutableArray> *interceptorFactories = [NSMutableArray arrayWithArray:[_factories subarrayWithRange:NSMakeRange(1, _factories.count - 1)]]; - while (_nextInterceptor == nil) { - if (interceptorFactories.count == 0) { - _nextInterceptor = [[GRPCTransportManager alloc] initWithTransportId:_transportId previousInterceptor:self]; - break; - } else { - _nextInterceptor = [[GRPCInterceptorManager alloc] initWithFactories:interceptorFactories - previousInterceptor:self - transportId:_transportId]; - if (_nextInterceptor == nil) { - [interceptorFactories removeObjectAtIndex:0]; - } +- (void)createNextInterceptor { + NSAssert(_nextInterceptor == nil, @"Starting the next interceptor more than once"); + NSAssert(_factories.count > 0, @"Interceptor manager of transport cannot start next interceptor"); + if (_nextInterceptor != nil) { + NSLog(@"Starting the next interceptor more than once"); + return; + } + NSMutableArray> *interceptorFactories = [NSMutableArray + arrayWithArray:[_factories subarrayWithRange:NSMakeRange(1, _factories.count - 1)]]; + while (_nextInterceptor == nil) { + if (interceptorFactories.count == 0) { + _nextInterceptor = + [[GRPCTransportManager alloc] initWithTransportId:_transportId previousInterceptor:self]; + break; + } else { + _nextInterceptor = [[GRPCInterceptorManager alloc] initWithFactories:interceptorFactories + previousInterceptor:self + transportId:_transportId]; + if (_nextInterceptor == nil) { + [interceptorFactories removeObjectAtIndex:0]; } } - NSAssert(_nextInterceptor != nil, @"Failed to create interceptor or transport."); - if (_nextInterceptor == nil) { - NSLog(@"Failed to create interceptor or transport."); - } } + NSAssert(_nextInterceptor != nil, @"Failed to create interceptor or transport."); + if (_nextInterceptor == nil) { + NSLog(@"Failed to create interceptor or transport."); + } +} - - (void)startNextInterceptorWithRequest:(GRPCRequestOptions *)requestOptions -callOptions:(GRPCCallOptions *)callOptions { +- (void)startNextInterceptorWithRequest:(GRPCRequestOptions *)requestOptions + callOptions:(GRPCCallOptions *)callOptions { if (_nextInterceptor == nil && !_shutDown) { [self createNextInterceptor]; } @@ -193,8 +198,8 @@ callOptions:(GRPCCallOptions *)callOptions { } /** Forward call close and trailing metadata to the previous interceptor in the chain */ - - (void)forwardPreviousInterceptorCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata -error:(NSError *)error { +- (void)forwardPreviousInterceptorCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata + error:(NSError *)error { if (_previousInterceptor == nil) { return; } @@ -215,54 +220,55 @@ error:(NSError *)error { }); } - - (dispatch_queue_t)dispatchQueue { - return _dispatchQueue; - } +- (dispatch_queue_t)dispatchQueue { + return _dispatchQueue; +} - - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { - [_thisInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; - } +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions + callOptions:(GRPCCallOptions *)callOptions { + [_thisInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; +} - - (void)writeData:(id)data { - [_thisInterceptor writeData:data]; - } +- (void)writeData:(id)data { + [_thisInterceptor writeData:data]; +} - - (void)finish { - [_thisInterceptor finish]; - } +- (void)finish { + [_thisInterceptor finish]; +} - - (void)cancel { - [_thisInterceptor cancel]; - } +- (void)cancel { + [_thisInterceptor cancel]; +} - - (void)receiveNextMessages:(NSUInteger)numberOfMessages { - [_thisInterceptor receiveNextMessages:numberOfMessages]; - } +- (void)receiveNextMessages:(NSUInteger)numberOfMessages { + [_thisInterceptor receiveNextMessages:numberOfMessages]; +} - - (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata { - if ([_thisInterceptor respondsToSelector:@selector(didReceiveInitialMetadata:)]) { - [_thisInterceptor didReceiveInitialMetadata:initialMetadata]; - } +- (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata { + if ([_thisInterceptor respondsToSelector:@selector(didReceiveInitialMetadata:)]) { + [_thisInterceptor didReceiveInitialMetadata:initialMetadata]; } +} - - (void)didReceiveData:(id)data { - if ([_thisInterceptor respondsToSelector:@selector(didReceiveData:)]) { - [_thisInterceptor didReceiveData:data]; - } +- (void)didReceiveData:(id)data { + if ([_thisInterceptor respondsToSelector:@selector(didReceiveData:)]) { + [_thisInterceptor didReceiveData:data]; } +} - - (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata - error:(nullable NSError *)error { +- (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata + error:(nullable NSError *)error { if ([_thisInterceptor respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { [_thisInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; } } - - (void)didWriteData { - if ([_thisInterceptor respondsToSelector:@selector(didWriteData)]) { - [_thisInterceptor didWriteData]; - } +- (void)didWriteData { + if ([_thisInterceptor respondsToSelector:@selector(didWriteData)]) { + [_thisInterceptor didWriteData]; } +} @end @@ -272,7 +278,7 @@ error:(NSError *)error { } - (instancetype)initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - dispatchQueue:(dispatch_queue_t)dispatchQueue { + dispatchQueue:(dispatch_queue_t)dispatchQueue { if ((self = [super init])) { _manager = interceptorManager; _dispatchQueue = dispatchQueue; @@ -285,7 +291,8 @@ error:(NSError *)error { return _dispatchQueue; } -- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions + callOptions:(GRPCCallOptions *)callOptions { [_manager startNextInterceptorWithRequest:requestOptions callOptions:callOptions]; } diff --git a/src/objective-c/GRPCClient/GRPCTransport.h b/src/objective-c/GRPCClient/GRPCTransport.h index 2da6ab3dc6a..d5637922152 100644 --- a/src/objective-c/GRPCClient/GRPCTransport.h +++ b/src/objective-c/GRPCClient/GRPCTransport.h @@ -16,19 +16,27 @@ * */ +// The interface for a transport implementation + #import "GRPCInterceptor.h" NS_ASSUME_NONNULL_BEGIN #pragma mark Transport ID -extern const struct GRPCTransportImplList { +/** + * The default transport implementations available in gRPC. These implementations will be provided + * by gRPC by default unless explicitly excluded. + */ +extern const struct GRPCDefaultTransportImplList { const GRPCTransportId core_secure; const GRPCTransportId core_insecure; -} GRPCTransportImplList; +} GRPCDefaultTransportImplList; +/** Returns whether two transport id's are identical. */ BOOL TransportIdIsEqual(GRPCTransportId lhs, GRPCTransportId rhs); +/** Returns the hash value of a transport id. */ NSUInteger TransportIdHash(GRPCTransportId); #pragma mark Transport and factory @@ -40,20 +48,33 @@ NSUInteger TransportIdHash(GRPCTransportId); @class GRPCCallOptions; @class GRPCTransport; -@protocol GRPCTransportFactory +/** The factory method to create a transport. */ +@protocol GRPCTransportFactory - (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager; @end +/** The registry of transport implementations. */ @interface GRPCTransportRegistry : NSObject + (instancetype)sharedInstance; -- (void)registerTransportWithId:(GRPCTransportId)id factory:(id)factory; +/** + * Register a transport implementation with the registry. All transport implementations to be used + * in a process must register with the registry on process start-up in its +load: class method. + * Parameter \a transportId is the identifier of the implementation, and \a factory is the factory + * object to create the corresponding transport instance. + */ +- (void)registerTransportWithId:(GRPCTransportId)transportId + factory:(id)factory; @end +/** + * Base class for transport implementations. All transport implementation should inherit from this + * class. + */ @interface GRPCTransport : NSObject @end diff --git a/src/objective-c/GRPCClient/GRPCTransport.m b/src/objective-c/GRPCClient/GRPCTransport.m index 0621c4e6450..edb973a8f62 100644 --- a/src/objective-c/GRPCClient/GRPCTransport.m +++ b/src/objective-c/GRPCClient/GRPCTransport.m @@ -3,9 +3,8 @@ static const GRPCTransportId gGRPCCoreSecureId = "io.grpc.transport.core.secure"; static const GRPCTransportId gGRPCCoreInsecureId = "io.grpc.transport.core.insecure"; -const struct GRPCTransportImplList GRPCTransportImplList = { - .core_secure = gGRPCCoreSecureId, - .core_insecure = gGRPCCoreInsecureId}; +const struct GRPCDefaultTransportImplList GRPCDefaultTransportImplList = { + .core_secure = gGRPCCoreSecureId, .core_insecure = gGRPCCoreInsecureId}; static const GRPCTransportId gDefaultTransportId = gGRPCCoreSecureId; @@ -49,10 +48,11 @@ NSUInteger TransportIdHash(GRPCTransportId transportId) { return self; } -- (void)registerTransportWithId:(GRPCTransportId)transportId factory:(id)factory { - NSString *nsTransportId = [NSString stringWithCString:transportId - encoding:NSUTF8StringEncoding]; - NSAssert(_registry[nsTransportId] == nil, @"The transport %@ has already been registered.", nsTransportId); +- (void)registerTransportWithId:(GRPCTransportId)transportId + factory:(id)factory { + NSString *nsTransportId = [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding]; + NSAssert(_registry[nsTransportId] == nil, @"The transport %@ has already been registered.", + nsTransportId); if (_registry[nsTransportId] != nil) { NSLog(@"The transport %@ has already been registered.", nsTransportId); return; @@ -68,17 +68,18 @@ NSUInteger TransportIdHash(GRPCTransportId transportId) { - (id)getTransportFactoryWithId:(GRPCTransportId)transportId { if (transportId == NULL) { if (_defaultFactory == nil) { - [NSException raise:NSInvalidArgumentException format:@"Unable to get default transport factory"]; + [NSException raise:NSInvalidArgumentException + format:@"Unable to get default transport factory"]; return nil; } return _defaultFactory; } - NSString *nsTransportId = [NSString stringWithCString:transportId - encoding:NSUTF8StringEncoding]; + NSString *nsTransportId = [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding]; id transportFactory = _registry[nsTransportId]; if (transportFactory == nil) { // User named a transport id that was not registered with the registry. - [NSException raise:NSInvalidArgumentException format:@"Unable to get transport factory with id %s", transportId]; + [NSException raise:NSInvalidArgumentException + format:@"Unable to get transport factory with id %s", transportId]; return nil; } return transportFactory; @@ -89,28 +90,35 @@ NSUInteger TransportIdHash(GRPCTransportId transportId) { @implementation GRPCTransport - (dispatch_queue_t)dispatchQueue { - [NSException raise:NSGenericException format:@"Implementations should override the dispatch queue"]; + [NSException raise:NSGenericException + format:@"Implementations should override the dispatch queue"]; return nil; } -- (void)startWithRequestOptions:(nonnull GRPCRequestOptions *)requestOptions callOptions:(nonnull GRPCCallOptions *)callOptions { - [NSException raise:NSGenericException format:@"Implementations should override the methods of GRPCTransport"]; +- (void)startWithRequestOptions:(nonnull GRPCRequestOptions *)requestOptions + callOptions:(nonnull GRPCCallOptions *)callOptions { + [NSException raise:NSGenericException + format:@"Implementations should override the methods of GRPCTransport"]; } - (void)writeData:(nonnull id)data { - [NSException raise:NSGenericException format:@"Implementations should override the methods of GRPCTransport"]; + [NSException raise:NSGenericException + format:@"Implementations should override the methods of GRPCTransport"]; } - (void)cancel { - [NSException raise:NSGenericException format:@"Implementations should override the methods of GRPCTransport"]; + [NSException raise:NSGenericException + format:@"Implementations should override the methods of GRPCTransport"]; } - (void)finish { - [NSException raise:NSGenericException format:@"Implementations should override the methods of GRPCTransport"]; + [NSException raise:NSGenericException + format:@"Implementations should override the methods of GRPCTransport"]; } - (void)receiveNextMessages:(NSUInteger)numberOfMessages { - [NSException raise:NSGenericException format:@"Implementations should override the methods of GRPCTransport"]; + [NSException raise:NSGenericException + format:@"Implementations should override the methods of GRPCTransport"]; } @end diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.h index ff7a9f6e838..641b1fb2e8a 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.h @@ -26,9 +26,10 @@ NS_ASSUME_NONNULL_BEGIN @interface GRPCCall2Internal : GRPCTransport -- (instancetype)initWithTransportManager:(GRPCTransportManager*)transportManager; +- (instancetype)initWithTransportManager:(GRPCTransportManager *)transportManager; -- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions; +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions + callOptions:(GRPCCallOptions *)callOptions; - (void)writeData:(id)data; diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m index 7ff8c6a5945..ea01fcaf594 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m @@ -22,8 +22,8 @@ #import #import -#import "GRPCCall+V2API.h" #import "../GRPCTransport+Private.h" +#import "GRPCCall+V2API.h" @implementation GRPCCall2Internal { /** Request for the call. */ @@ -53,20 +53,19 @@ NSUInteger _pendingReceiveNextMessages; } - - (instancetype)initWithTransportManager:(GRPCTransportManager *)transportManager { - dispatch_queue_t dispatchQueue; - // Set queue QoS only when iOS version is 8.0 or above and Xcode version is 9.0 or above +- (instancetype)initWithTransportManager:(GRPCTransportManager *)transportManager { + dispatch_queue_t dispatchQueue; + // Set queue QoS only when iOS version is 8.0 or above and Xcode version is 9.0 or above #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 - if (@available(iOS 8.0, macOS 10.10, *)) { - dispatchQueue = dispatch_queue_create( - NULL, - dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); - } else { + if (@available(iOS 8.0, macOS 10.10, *)) { + dispatchQueue = dispatch_queue_create( + NULL, dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); + } else { #else - { + { #endif - dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); - } + dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); + } if ((self = [super init])) { _pipe = [GRXBufferedPipe pipe]; _transportManager = transportManager; @@ -79,7 +78,8 @@ return _dispatchQueue; } -- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions + callOptions:(GRPCCallOptions *)callOptions { NSAssert(requestOptions.host.length != 0 && requestOptions.path.length != 0, @"Neither host nor path can be nil."); NSAssert(requestOptions.safety <= GRPCCallSafetyCacheableRequest, @"Invalid call safety value."); @@ -187,13 +187,17 @@ _pipe = nil; if (_transportManager != nil) { - [_transportManager forwardPreviousInterceptorCloseWithTrailingMetadata:nil - error:[NSError errorWithDomain:kGRPCErrorDomain - code:GRPCErrorCodeCancelled - userInfo:@{ - NSLocalizedDescriptionKey : - @"Canceled by app" - }]]; + [_transportManager + forwardPreviousInterceptorCloseWithTrailingMetadata:nil + error: + [NSError + errorWithDomain:kGRPCErrorDomain + code: + GRPCErrorCodeCancelled + userInfo:@{ + NSLocalizedDescriptionKey : + @"Canceled by app" + }]]; [_transportManager shutDown]; } } @@ -258,7 +262,7 @@ - (void)issueClosedWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { [_transportManager forwardPreviousInterceptorCloseWithTrailingMetadata:trailingMetadata - error:error]; + error:error]; [_transportManager shutDown]; } diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m index 846e8331b4b..e0fd4c18e78 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m @@ -21,15 +21,15 @@ #include #import "../../internal/GRPCCallOptions+Internal.h" +#import "../GRPCTransport+Private.h" #import "ChannelArgsUtil.h" #import "GRPCChannelFactory.h" #import "GRPCChannelPool.h" #import "GRPCCompletionQueue.h" +#import "GRPCCoreFactory.h" #import "GRPCInsecureChannelFactory.h" #import "GRPCSecureChannelFactory.h" #import "version.h" -#import "GRPCCoreFactory.h" -#import "../GRPCTransport+Private.h" #import #import @@ -52,12 +52,16 @@ - (id)channelFactory { if (_callOptions.transport != NULL) { - id transportFactory = [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:_callOptions.transport]; - if (![transportFactory respondsToSelector:@selector(createCoreChannelFactoryWithCallOptions:)]) { + id transportFactory = + [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:_callOptions.transport]; + if (! + [transportFactory respondsToSelector:@selector(createCoreChannelFactoryWithCallOptions:)]) { // impossible because we are using GRPCCore now - [NSException raise:NSInternalInconsistencyException format:@"Transport factory type is wrong"]; + [NSException raise:NSInternalInconsistencyException + format:@"Transport factory type is wrong"]; } - id coreTransportFactory = (id)transportFactory; + id coreTransportFactory = + (id)transportFactory; return [coreTransportFactory createCoreChannelFactoryWithCallOptions:_callOptions]; } else { // To maintain backwards compatibility with tranportType @@ -65,22 +69,22 @@ switch (type) { case GRPCTransportTypeChttp2BoringSSL: // TODO (mxyan): Remove when the API is deprecated - { - NSError *error; - id factory = [GRPCSecureChannelFactory - factoryWithPEMRootCertificates:_callOptions.PEMRootCertificates - privateKey:_callOptions.PEMPrivateKey - certChain:_callOptions.PEMCertificateChain - error:&error]; - NSAssert(factory != nil, @"Failed to create secure channel factory"); - if (factory == nil) { - NSLog(@"Error creating secure channel factory: %@", error); - } - return factory; + { + NSError *error; + id factory = [GRPCSecureChannelFactory + factoryWithPEMRootCertificates:_callOptions.PEMRootCertificates + privateKey:_callOptions.PEMPrivateKey + certChain:_callOptions.PEMCertificateChain + error:&error]; + NSAssert(factory != nil, @"Failed to create secure channel factory"); + if (factory == nil) { + NSLog(@"Error creating secure channel factory: %@", error); } - case GRPCTransportTypeCronet: - { - id transportFactory = (id)[[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:gGRPCCoreCronetId]; + return factory; + } + case GRPCTransportTypeCronet: { + id transportFactory = (id)[ + [GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:gGRPCCoreCronetId]; return [transportFactory createCoreChannelFactoryWithCallOptions:_callOptions]; } case GRPCTransportTypeInsecure: @@ -191,7 +195,7 @@ grpc_channel *_unmanagedChannel; } - - (instancetype)initWithChannelConfiguration:(GRPCChannelConfiguration *)channelConfiguration { +- (instancetype)initWithChannelConfiguration:(GRPCChannelConfiguration *)channelConfiguration { NSAssert(channelConfiguration != nil, @"channelConfiguration must not be empty."); if (channelConfiguration == nil) { return nil; diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.h index 5adb9cea168..b83a28a2368 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.h @@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN * Initialize with an actual channel object \a channel and a reference to the channel pool. */ - (nullable instancetype)initWithChannelConfiguration: -(GRPCChannelConfiguration *)channelConfiguration; + (GRPCChannelConfiguration *)channelConfiguration; /** * Create a GRPCWrappedCall object (grpc_call) from this channel. If channel is disconnected, get a diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h index f1ad1b05e44..83d279d2c72 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h @@ -18,6 +18,15 @@ #import "../GRPCCoreFactory.h" +/** + * The factory for gRPC Core + Cronet transport implementation. The + * implementation is not part of the default transports of gRPC and is for + * testing purpose only on Github. + * + * To use this transport, a user must include the GRPCCoreCronet module as a + * dependency of the project and use gGRPCCoreCronetId in call options to + * specify that this is the transport to be used for a call. + */ @interface GRPCCoreCronetFactory : NSObject @end diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m index 0a19e31999e..5772694fc54 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m @@ -18,11 +18,11 @@ #import "GRPCCoreCronetFactory.h" -#import #import +#import -#import "../GRPCCoreFactory.h" #import "../GRPCCallInternal.h" +#import "../GRPCCoreFactory.h" #import "GRPCCronetChannelFactory.h" static GRPCCoreCronetFactory *gGRPCCoreCronetFactory = nil; @@ -38,8 +38,9 @@ static dispatch_once_t gInitGRPCCoreCronetFactory; } + (void)load { - [[GRPCTransportRegistry sharedInstance] registerTransportWithId:gGRPCCoreCronetId - factory:[GRPCCoreCronetFactory sharedInstance]]; + [[GRPCTransportRegistry sharedInstance] + registerTransportWithId:gGRPCCoreCronetId + factory:[GRPCCoreCronetFactory sharedInstance]]; } - (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager { diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h index d4d8ef586df..3cd312d4ad0 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h @@ -23,16 +23,21 @@ NS_ASSUME_NONNULL_BEGIN @protocol GRPCChannelFactory; @protocol GRPCCallOptions; -@protocol GRPCCoreTransportFactory +/** The interface for transport implementations that are based on Core. */ +@protocol GRPCCoreTransportFactory -- (nullable id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions; +/** Get the channel factory for GRPCChannel from call options. */ +- (nullable id)createCoreChannelFactoryWithCallOptions: + (GRPCCallOptions *)callOptions; @end +/** The factory for gRPC Core + CFStream + TLS secure channel transport implementation. */ @interface GRPCCoreSecureFactory : NSObject @end +/** The factory for gRPC Core + CFStream + insecure channel transport implementation. */ @interface GRPCCoreInsecureFactory : NSObject @end diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m index 609cda17697..f5d6276a570 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m @@ -3,8 +3,8 @@ #import #import "GRPCCallInternal.h" -#import "GRPCSecureChannelFactory.h" #import "GRPCInsecureChannelFactory.h" +#import "GRPCSecureChannelFactory.h" static GRPCCoreSecureFactory *gGRPCCoreSecureFactory = nil; static GRPCCoreInsecureFactory *gGRPCCoreInsecureFactory = nil; @@ -21,8 +21,9 @@ static dispatch_once_t gInitGRPCCoreInsecureFactory; } + (void)load { - [[GRPCTransportRegistry sharedInstance] registerTransportWithId:GRPCTransportImplList.core_secure - factory:[self sharedInstance]]; + [[GRPCTransportRegistry sharedInstance] + registerTransportWithId:GRPCDefaultTransportImplList.core_secure + factory:[self sharedInstance]]; } - (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager { @@ -31,9 +32,11 @@ static dispatch_once_t gInitGRPCCoreInsecureFactory; - (id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions { NSError *error; - id factory = [GRPCSecureChannelFactory factoryWithPEMRootCertificates:callOptions.PEMRootCertificates - privateKey:callOptions.PEMPrivateKey - certChain:callOptions.PEMCertificateChain error:&error]; + id factory = + [GRPCSecureChannelFactory factoryWithPEMRootCertificates:callOptions.PEMRootCertificates + privateKey:callOptions.PEMPrivateKey + certChain:callOptions.PEMCertificateChain + error:&error]; if (error != nil) { NSLog(@"Unable to create secure channel factory"); return nil; @@ -53,8 +56,9 @@ static dispatch_once_t gInitGRPCCoreInsecureFactory; } + (void)load { - [[GRPCTransportRegistry sharedInstance] registerTransportWithId:GRPCTransportImplList.core_insecure - factory:[self sharedInstance]]; + [[GRPCTransportRegistry sharedInstance] + registerTransportWithId:GRPCDefaultTransportImplList.core_insecure + factory:[self sharedInstance]]; } - (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager { diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m index 89a184d8c26..efee85e3108 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m @@ -113,9 +113,9 @@ static NSMutableDictionary *gHostCache; options.PEMCertificateChain = _PEMCertificateChain; options.hostNameOverride = _hostNameOverride; if (_transportType == GRPCTransportTypeInsecure) { - options.transport = GRPCTransportImplList.core_insecure; + options.transport = GRPCDefaultTransportImplList.core_insecure; } else { - options.transport = GRPCTransportImplList.core_secure; + options.transport = GRPCDefaultTransportImplList.core_secure; } options.logContext = _logContext; diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h index 9115b915659..dd826a8fc1a 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h @@ -16,17 +16,21 @@ * */ -#import #import +#import NS_ASSUME_NONNULL_BEGIN +/** + * Private interfaces of the transport registry. + */ @interface GRPCTransportRegistry (Private) -- (nullable instancetype)initWithTransportId:(GRPCTransportId)transportId - previousInterceptor:(id)previousInterceptor; - -- (id)getTransportFactoryWithId:(GRPCTransportId)id; +/** + * Get a transport implementation's factory by its transport id. If the transport id was not + * registered with the registry, nil is returned. + */ +- (id)getTransportFactoryWithId:(GRPCTransportId)transportId; @end @@ -35,6 +39,10 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithTransportId:(GRPCTransportId)transportId previousInterceptor:(id)previousInterceptor; +/** + * Notify the manager that the transport has shut down and the manager should release references to + * its response handler and stop forwarding requests/responses. + */ - (void)shutDown; /** Forward initial metadata to the previous interceptor in the interceptor chain */ @@ -44,7 +52,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)forwardPreviousInterceptorWithData:(nullable id)data; /** Forward call close and trailing metadata to the previous interceptor in the interceptor chain */ -- (void)forwardPreviousInterceptorCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata +- (void)forwardPreviousInterceptorCloseWithTrailingMetadata: + (nullable NSDictionary *)trailingMetadata error:(nullable NSError *)error; /** Forward write completion to the previous interceptor in the interceptor chain */ diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m index 1050280e07b..c8198462bd4 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m @@ -12,8 +12,9 @@ - (instancetype)initWithTransportId:(GRPCTransportId)transportId previousInterceptor:(id)previousInterceptor { if ((self = [super init])) { - id factory = [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:transportId]; - + id factory = + [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:transportId]; + _transport = [factory createTransportWithManager:self]; NSAssert(_transport != nil, @"Failed to create transport with id: %s", transportId); if (_transport == nil) { @@ -36,9 +37,11 @@ return _dispatchQueue; } -- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions + callOptions:(GRPCCallOptions *)callOptions { if (_transportId != callOptions.transport) { - [NSException raise:NSInvalidArgumentException format:@"Interceptors cannot change the call option 'transport'"]; + [NSException raise:NSInvalidArgumentException + format:@"Interceptors cannot change the call option 'transport'"]; return; } [_transport startWithRequestOptions:requestOptions callOptions:callOptions]; diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.h b/src/objective-c/ProtoRPC/ProtoRPCLegacy.h index bff487e9a0b..2ceb4339bd1 100644 --- a/src/objective-c/ProtoRPC/ProtoRPCLegacy.h +++ b/src/objective-c/ProtoRPC/ProtoRPCLegacy.h @@ -5,17 +5,17 @@ @protocol GRXWriteable; __attribute__((deprecated("Please use GRPCProtoCall."))) @interface ProtoRPC -: GRPCCall + : GRPCCall -/** - * host parameter should not contain the scheme (http:// or https://), only the name or IP - * addr and the port number, for example @"localhost:5050". - */ -- -(instancetype)initWithHost : (NSString *)host method -: (GRPCProtoMethod *)method requestsWriter : (GRXWriter *)requestsWriter responseClass -: (Class)responseClass responsesWriteable -: (id)responsesWriteable NS_DESIGNATED_INITIALIZER; + /** + * host parameter should not contain the scheme (http:// or https://), only the name or IP + * addr and the port number, for example @"localhost:5050". + */ + - + (instancetype)initWithHost : (NSString *)host method + : (GRPCProtoMethod *)method requestsWriter : (GRXWriter *)requestsWriter responseClass + : (Class)responseClass responsesWriteable + : (id)responsesWriteable NS_DESIGNATED_INITIALIZER; - (void)start; @end @@ -26,14 +26,15 @@ __attribute__((deprecated("Please use GRPCProtoCall."))) @interface ProtoRPC */ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" -@interface GRPCProtoCall : ProtoRPC + @interface GRPCProtoCall + : ProtoRPC #pragma clang diagnostic pop -@end - -/** - * Generate an NSError object that represents a failure in parsing a proto class. For gRPC internal - * use only. - */ -NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError); + @end + /** + * Generate an NSError object that represents a failure in parsing a proto class. For gRPC + * internal use only. + */ + NSError * + ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError); diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.m b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m index a4ea1836bdf..b5c0c847c66 100644 --- a/src/objective-c/ProtoRPC/ProtoRPCLegacy.m +++ b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m @@ -11,7 +11,6 @@ #import #import - #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-implementations" @implementation ProtoRPC { @@ -63,9 +62,9 @@ [weakSelf finishWithError:ErrorForBadProto(value, responseClass, error)]; } } - completionHandler:^(NSError *errorOrNil) { - [responsesWriteable writesFinishedWithError:errorOrNil]; - }]; + completionHandler:^(NSError *errorOrNil) { + [responsesWriteable writesFinishedWithError:errorOrNil]; + }]; } return self; } @@ -102,4 +101,3 @@ NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError) // TODO(jcanizales): Use kGRPCErrorDomain and GRPCErrorCodeInternal when they're public. return [NSError errorWithDomain:@"io.grpc" code:13 userInfo:info]; } - diff --git a/src/objective-c/ProtoRPC/ProtoService.h b/src/objective-c/ProtoRPC/ProtoService.h index e99d75fd3d8..d55ed30a39b 100644 --- a/src/objective-c/ProtoRPC/ProtoService.h +++ b/src/objective-c/ProtoRPC/ProtoService.h @@ -30,17 +30,17 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnullability-completeness" -__attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoService -: NSObject { +__attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoService : NSObject { NSString *_host; NSString *_packageName; NSString *_serviceName; } - - - (nullable instancetype)initWithHost : (nonnull NSString *)host packageName - : (nonnull NSString *)packageName serviceName : (nonnull NSString *)serviceName callOptions - : (nullable GRPCCallOptions *)callOptions NS_DESIGNATED_INITIALIZER; +- (nullable instancetype)initWithHost:(nonnull NSString *)host + packageName:(nonnull NSString *)packageName + serviceName:(nonnull NSString *)serviceName + callOptions:(nullable GRPCCallOptions *)callOptions + NS_DESIGNATED_INITIALIZER; - (nullable GRPCUnaryProtoCall *)RPCToMethod:(nonnull NSString *)method message:(nonnull id)message diff --git a/src/objective-c/ProtoRPC/ProtoServiceLegacy.m b/src/objective-c/ProtoRPC/ProtoServiceLegacy.m index 34f2b0f2cbb..9484f432216 100644 --- a/src/objective-c/ProtoRPC/ProtoServiceLegacy.m +++ b/src/objective-c/ProtoRPC/ProtoServiceLegacy.m @@ -1,6 +1,6 @@ #import "ProtoServiceLegacy.h" -#import "ProtoRPCLegacy.h" #import "ProtoMethod.h" +#import "ProtoRPCLegacy.h" #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-implementations" @@ -23,13 +23,12 @@ return self; } - - (GRPCProtoCall *)RPCToMethod:(NSString *)method requestsWriter:(GRXWriter *)requestsWriter responseClass:(Class)responseClass responsesWriteable:(id)responsesWriteable { GRPCProtoMethod *methodName = - [[GRPCProtoMethod alloc] initWithPackage:_packageName service:_serviceName method:method]; + [[GRPCProtoMethod alloc] initWithPackage:_packageName service:_serviceName method:method]; return [[GRPCProtoCall alloc] initWithHost:_host method:methodName requestsWriter:requestsWriter diff --git a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m index 37fa1b418c1..aa1af301b96 100644 --- a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m +++ b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m @@ -22,9 +22,8 @@ #import #import -#import "InteropTests.h" #import "../ConfigureCronet.h" - +#import "InteropTests.h" // The server address is derived from preprocessor macro, which is // in turn derived from environment variable of the same name. @@ -49,7 +48,6 @@ static int32_t kRemoteInteropServerOverhead = 12; [super setUp]; } - + (NSString *)host { return kRemoteSSLHost; } diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index dcdbdc2beb5..2cb5ba21a2f 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -87,8 +87,8 @@ BOOL isRemoteInteropTest(NSString *host) { - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { dispatch_queue_t queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); - return [[GRPCInterceptor alloc] initWithInterceptorManager:interceptorManager - dispatchQueue:queue]; + return + [[GRPCInterceptor alloc] initWithInterceptorManager:interceptorManager dispatchQueue:queue]; } @end @@ -96,20 +96,19 @@ BOOL isRemoteInteropTest(NSString *host) { @interface HookInterceptorFactory : NSObject - (instancetype) -initWithDispatchQueue:(dispatch_queue_t)dispatchQueue - startHook:(void (^)(GRPCRequestOptions *requestOptions, - GRPCCallOptions *callOptions, - GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook - finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook - receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, - GRPCInterceptorManager *manager))receiveNextMessagesHook - responseHeaderHook:(void (^)(NSDictionary *initialMetadata, - GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook - responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, - GRPCInterceptorManager *manager))responseCloseHook - didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook; + initWithDispatchQueue:(dispatch_queue_t)dispatchQueue + startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager))startHook + writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook + finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook +receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, + GRPCInterceptorManager *manager))receiveNextMessagesHook + responseHeaderHook:(void (^)(NSDictionary *initialMetadata, + GRPCInterceptorManager *manager))responseHeaderHook + responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook + responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager))responseCloseHook + didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook; - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager; @@ -119,7 +118,7 @@ initWithDispatchQueue:(dispatch_queue_t)dispatchQueue - (instancetype) initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager -dispatchQueue:(dispatch_queue_t)dispatchQueue + dispatchQueue:(dispatch_queue_t)dispatchQueue startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook @@ -152,20 +151,19 @@ dispatchQueue:(dispatch_queue_t)dispatchQueue } - (instancetype) -initWithDispatchQueue:(dispatch_queue_t)dispatchQueue - startHook:(void (^)(GRPCRequestOptions *requestOptions, - GRPCCallOptions *callOptions, - GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook - finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook - receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, - GRPCInterceptorManager *manager))receiveNextMessagesHook - responseHeaderHook:(void (^)(NSDictionary *initialMetadata, - GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook - responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, - GRPCInterceptorManager *manager))responseCloseHook - didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { + initWithDispatchQueue:(dispatch_queue_t)dispatchQueue + startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager))startHook + writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook + finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook +receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, + GRPCInterceptorManager *manager))receiveNextMessagesHook + responseHeaderHook:(void (^)(NSDictionary *initialMetadata, + GRPCInterceptorManager *manager))responseHeaderHook + responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook + responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager))responseCloseHook + didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { if ((self = [super init])) { _dispatchQueue = dispatchQueue; _startHook = startHook; @@ -182,7 +180,7 @@ initWithDispatchQueue:(dispatch_queue_t)dispatchQueue - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { return [[HookInterceptor alloc] initWithInterceptorManager:interceptorManager - dispatchQueue:_dispatchQueue + dispatchQueue:_dispatchQueue startHook:_startHook writeDataHook:_writeDataHook finishHook:_finishHook @@ -216,7 +214,7 @@ initWithDispatchQueue:(dispatch_queue_t)dispatchQueue - (instancetype) initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager -dispatchQueue:(dispatch_queue_t)dispatchQueue + dispatchQueue:(dispatch_queue_t)dispatchQueue startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook @@ -230,8 +228,7 @@ dispatchQueue:(dispatch_queue_t)dispatchQueue responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager))responseCloseHook didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { - if ((self = [super initWithInterceptorManager:interceptorManager - dispatchQueue:dispatchQueue])) { + if ((self = [super initWithInterceptorManager:interceptorManager dispatchQueue:dispatchQueue])) { _startHook = startHook; _writeDataHook = writeDataHook; _finishHook = finishHook; @@ -323,14 +320,14 @@ dispatchQueue:(dispatch_queue_t)dispatchQueue - (instancetype)initWithDispatchQueue:(dispatch_queue_t)dispatchQueue { _enabled = NO; return [super initWithDispatchQueue:dispatchQueue - startHook:nil - writeDataHook:nil - finishHook:nil - receiveNextMessagesHook:nil - responseHeaderHook:nil - responseDataHook:nil - responseCloseHook:nil - didWriteDataHook:nil]; + startHook:nil + writeDataHook:nil + finishHook:nil + receiveNextMessagesHook:nil + responseHeaderHook:nil + responseDataHook:nil + responseCloseHook:nil + didWriteDataHook:nil]; } - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { @@ -621,7 +618,7 @@ static dispatch_once_t initGlobalInterceptorFactory; request.responseStatus.code = GRPC_STATUS_CANCELLED; } GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - // For backwards compatibility + // For backwards compatibility options.transportType = [[self class] transportType]; options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; @@ -1269,7 +1266,6 @@ static dispatch_once_t initGlobalInterceptorFactory; } __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Keepalive"]; - NSNumber *kRequestSize = @27182; NSNumber *kResponseSize = @31415; @@ -1284,18 +1280,19 @@ static dispatch_once_t initGlobalInterceptorFactory; options.keepaliveTimeout = 0; __block GRPCStreamingProtoCall *call = [_service - fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:nil - messageCallback:nil - closeCallback:^(NSDictionary *trailingMetadata, - NSError *error) { - XCTAssertNotNil(error); - XCTAssertEqual(error.code, GRPC_STATUS_UNAVAILABLE, - @"Received status %ld instead of UNAVAILABLE (14).", - error.code); - [expectation fulfill]; - }] - callOptions:options]; + fullDuplexCallWithResponseHandler: + [[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + XCTAssertNotNil(error); + XCTAssertEqual( + error.code, GRPC_STATUS_UNAVAILABLE, + @"Received status %ld instead of UNAVAILABLE (14).", + error.code); + [expectation fulfill]; + }] + callOptions:options]; [call writeMessage:request]; [call start]; @@ -1548,7 +1545,7 @@ static dispatch_once_t initGlobalInterceptorFactory; XCTAssertEqual(error.code, GRPC_STATUS_CANCELLED); [expectCallInternalComplete fulfill]; } - didWriteDataHook:nil]; + didWriteDataHook:nil]; NSArray *requests = @[ @1, @2, @3, @4 ]; @@ -1723,15 +1720,15 @@ static dispatch_once_t initGlobalInterceptorFactory; - (void)testConflictingGlobalInterceptors { id factory = [[HookInterceptorFactory alloc] - initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - startHook:nil - writeDataHook:nil - finishHook:nil - receiveNextMessagesHook:nil - responseHeaderHook:nil - responseDataHook:nil - responseCloseHook:nil - didWriteDataHook:nil]; + initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + startHook:nil + writeDataHook:nil + finishHook:nil + receiveNextMessagesHook:nil + responseHeaderHook:nil + responseDataHook:nil + responseCloseHook:nil + didWriteDataHook:nil]; @try { [GRPCCall2 registerGlobalInterceptor:factory]; XCTFail(@"Did not receive an exception when registering global interceptor the second time"); diff --git a/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m b/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m index c8d21199454..2e638099e1e 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m +++ b/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m @@ -17,8 +17,8 @@ */ #import -#import #import +#import #import "InteropTests.h" @@ -62,7 +62,7 @@ static int32_t kLocalInteropServerOverhead = 10; } + (GRPCTransportId)transport { - return GRPCTransportImplList.core_insecure; + return GRPCDefaultTransportImplList.core_insecure; } @end diff --git a/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m b/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m index d28513cc673..1c1c1ddeb1e 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m +++ b/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m @@ -17,8 +17,8 @@ */ #import -#import #import +#import #import "InteropTests.h" // The server address is derived from preprocessor macro, which is @@ -62,7 +62,7 @@ static int32_t kLocalInteropServerOverhead = 10; } + (GRPCTransportId)transport { - return GRPCTransportImplList.core_secure; + return GRPCDefaultTransportImplList.core_secure; } - (void)setUp { From 3f16518947238b2cafc6f7a648fa38c6ba53a073 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 25 Jul 2019 10:02:10 -0700 Subject: [PATCH 0994/1555] Fix build --- gRPC.podspec | 1 + templates/gRPC.podspec.template | 1 + 2 files changed, 2 insertions(+) diff --git a/gRPC.podspec b/gRPC.podspec index 7af8e841d78..9ddbb18d393 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -78,6 +78,7 @@ Pod::Spec.new do |s| 'src/objective-c/GRPCClient/GRPCInterceptor.m', 'src/objective-c/GRPCClient/GRPCTransport.h', 'src/objective-c/GRPCClient/GRPCTransport.m', + 'src/objective-c/GRPCClient/internal/*.h', 'src/objective-c/GRPCClient/private/GRPCTransport+Private.h', 'src/objective-c/GRPCClient/private/GRPCTransport+Private.m' diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index 59ef8290b6f..21cce3c23ee 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -80,6 +80,7 @@ 'src/objective-c/GRPCClient/GRPCInterceptor.m', 'src/objective-c/GRPCClient/GRPCTransport.h', 'src/objective-c/GRPCClient/GRPCTransport.m', + 'src/objective-c/GRPCClient/internal/*.h', 'src/objective-c/GRPCClient/private/GRPCTransport+Private.h', 'src/objective-c/GRPCClient/private/GRPCTransport+Private.m' From c3896fa84d54e44dc1910d6f202a47d3640b6fa5 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Thu, 25 Jul 2019 10:37:22 -0700 Subject: [PATCH 0995/1555] Make Map<> movable --- src/core/lib/gprpp/map.h | 17 +++++++++++++++++ test/core/gprpp/map_test.cc | 29 +++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/src/core/lib/gprpp/map.h b/src/core/lib/gprpp/map.h index 36e32d60c07..2babe35cd1b 100644 --- a/src/core/lib/gprpp/map.h +++ b/src/core/lib/gprpp/map.h @@ -55,8 +55,25 @@ class Map { typedef Compare key_compare; class iterator; + Map() = default; ~Map() { clear(); } + // Movable. + Map(Map&& other) : root_(other.root_), size_(other.size_) { + other.root_ = nullptr; + other.size_ = 0; + } + Map& operator=(Map&& other) { + if (this != &other) { + clear(); + root_ = other.root_; + size_ = other.size_; + other.root_ = nullptr; + other.size_ = 0; + } + return *this; + } + T& operator[](key_type&& key); T& operator[](const key_type& key); iterator find(const key_type& k); diff --git a/test/core/gprpp/map_test.cc b/test/core/gprpp/map_test.cc index 30d9eb0b207..21aeee82486 100644 --- a/test/core/gprpp/map_test.cc +++ b/test/core/gprpp/map_test.cc @@ -437,6 +437,35 @@ TEST_F(MapTest, LowerBound) { EXPECT_EQ(it, test_map.end()); } +// Test move ctor +TEST_F(MapTest, MoveCtor) { + Map test_map; + for (int i = 0; i < 5; i++) { + test_map.emplace(kKeys[i], Payload(i)); + } + Map test_map2 = std::move(test_map); + for (int i = 0; i < 5; i++) { + EXPECT_EQ(test_map.end(), test_map.find(kKeys[i])); + EXPECT_EQ(i, test_map2.find(kKeys[i])->second.data()); + } +} + +// Test move assignment +TEST_F(MapTest, MoveAssignment) { + Map test_map; + for (int i = 0; i < 5; i++) { + test_map.emplace(kKeys[i], Payload(i)); + } + Map test_map2; + test_map2.emplace("xxx", Payload(123)); + test_map2 = std::move(test_map); + for (int i = 0; i < 5; i++) { + EXPECT_EQ(test_map.end(), test_map.find(kKeys[i])); + EXPECT_EQ(i, test_map2.find(kKeys[i])->second.data()); + } + EXPECT_EQ(test_map2.end(), test_map2.find("xxx")); +} + } // namespace testing } // namespace grpc_core From 6b7664f642da9537a793775ee7b99e9a55355ee3 Mon Sep 17 00:00:00 2001 From: Menghan Li Date: Thu, 25 Jul 2019 11:12:17 -0700 Subject: [PATCH 0996/1555] Add 1.21.1 and 1.22.1 of grpc-go to interop matrix --- tools/interop_matrix/client_matrix.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index 585734283a7..51a47d92f97 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -142,8 +142,8 @@ LANG_RELEASE_MATRIX = { ('v1.19.0', ReleaseInfo(runtimes=['go1.11'], testcases_file='go__v1.0.5')), ('v1.20.0', ReleaseInfo(runtimes=['go1.11'])), - ('v1.21.0', ReleaseInfo(runtimes=['go1.11'])), - ('v1.22.0', ReleaseInfo(runtimes=['go1.11'])), + ('v1.21.2', ReleaseInfo(runtimes=['go1.11'])), + ('v1.22.1', ReleaseInfo(runtimes=['go1.11'])), ]), 'java': OrderedDict([ From 224f0ef8370d15534c5bbfe7ab66a6ba775ede9d Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 25 Jul 2019 13:33:56 -0700 Subject: [PATCH 0997/1555] Second attempt: Hide ConnectedSubchannel from LB policy API. --- .../filters/client_channel/client_channel.cc | 420 +++++++++++++----- .../ext/filters/client_channel/lb_policy.h | 2 +- .../client_channel/lb_policy/grpclb/grpclb.cc | 9 +- .../lb_policy/pick_first/pick_first.cc | 30 +- .../lb_policy/round_robin/round_robin.cc | 20 +- .../lb_policy/subchannel_list.h | 126 ++---- .../client_channel/lb_policy/xds/xds.cc | 2 +- .../ext/filters/client_channel/subchannel.cc | 23 +- .../ext/filters/client_channel/subchannel.h | 71 ++- .../client_channel/subchannel_interface.h | 45 +- src/core/lib/gprpp/map.h | 8 + src/core/lib/transport/metadata.cc | 5 + test/core/util/test_lb_policies.cc | 2 +- 13 files changed, 465 insertions(+), 298 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 3c2e75ad8d3..4cbd52a486a 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -147,6 +147,9 @@ class ChannelData { return service_config_; } + RefCountedPtr GetConnectedSubchannelInDataPlane( + SubchannelInterface* subchannel) const; + grpc_connectivity_state CheckConnectivityState(bool try_to_connect); void AddExternalConnectivityWatcher(grpc_polling_entity pollent, grpc_connectivity_state* state, @@ -161,9 +164,9 @@ class ChannelData { } private: + class SubchannelWrapper; class ConnectivityStateAndPickerSetter; class ServiceConfigSetter; - class GrpcSubchannel; class ClientChannelControlHelper; class ExternalConnectivityWatcher { @@ -268,7 +271,14 @@ class ChannelData { UniquePtr health_check_service_name_; RefCountedPtr saved_service_config_; bool received_first_resolver_result_ = false; + // The number of SubchannelWrapper instances referencing a given Subchannel. Map subchannel_refcount_map_; + // Pending ConnectedSubchannel updates for each SubchannelWrapper. + // Updates are queued here in the control plane combiner and then applied + // in the data plane combiner when the picker is updated. + Map, RefCountedPtr, + RefCountedPtrLess> + pending_subchannel_updates_; // // Fields accessed from both data plane and control plane combiners. @@ -712,6 +722,247 @@ class CallData { grpc_metadata_batch send_trailing_metadata_; }; +// +// ChannelData::SubchannelWrapper +// + +// This class is a wrapper for Subchannel that hides details of the +// channel's implementation (such as the health check service name and +// connected subchannel) from the LB policy API. +// +// Note that no synchronization is needed here, because even if the +// underlying subchannel is shared between channels, this wrapper will only +// be used within one channel, so it will always be synchronized by the +// control plane combiner. +class ChannelData::SubchannelWrapper : public SubchannelInterface { + public: + SubchannelWrapper(ChannelData* chand, Subchannel* subchannel, + UniquePtr health_check_service_name) + : SubchannelInterface(&grpc_client_channel_routing_trace), + chand_(chand), + subchannel_(subchannel), + health_check_service_name_(std::move(health_check_service_name)) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { + gpr_log(GPR_INFO, + "chand=%p: creating subchannel wrapper %p for subchannel %p", + chand, this, subchannel_); + } + GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "SubchannelWrapper"); + auto* subchannel_node = subchannel_->channelz_node(); + if (subchannel_node != nullptr) { + intptr_t subchannel_uuid = subchannel_node->uuid(); + auto it = chand_->subchannel_refcount_map_.find(subchannel_); + if (it == chand_->subchannel_refcount_map_.end()) { + chand_->channelz_node_->AddChildSubchannel(subchannel_uuid); + it = chand_->subchannel_refcount_map_.emplace(subchannel_, 0).first; + } + ++it->second; + } + } + + ~SubchannelWrapper() { + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { + gpr_log(GPR_INFO, + "chand=%p: destroying subchannel wrapper %p for subchannel %p", + chand_, this, subchannel_); + } + auto* subchannel_node = subchannel_->channelz_node(); + if (subchannel_node != nullptr) { + intptr_t subchannel_uuid = subchannel_node->uuid(); + auto it = chand_->subchannel_refcount_map_.find(subchannel_); + GPR_ASSERT(it != chand_->subchannel_refcount_map_.end()); + --it->second; + if (it->second == 0) { + chand_->channelz_node_->RemoveChildSubchannel(subchannel_uuid); + chand_->subchannel_refcount_map_.erase(it); + } + } + GRPC_SUBCHANNEL_UNREF(subchannel_, "unref from LB"); + GRPC_CHANNEL_STACK_UNREF(chand_->owning_stack_, "SubchannelWrapper"); + } + + grpc_connectivity_state CheckConnectivityState() override { + RefCountedPtr connected_subchannel; + grpc_connectivity_state connectivity_state = + subchannel_->CheckConnectivityState(health_check_service_name_.get(), + &connected_subchannel); + MaybeUpdateConnectedSubchannel(std::move(connected_subchannel)); + return connectivity_state; + } + + void WatchConnectivityState( + grpc_connectivity_state initial_state, + UniquePtr watcher) override { + auto& watcher_wrapper = watcher_map_[watcher.get()]; + GPR_ASSERT(watcher_wrapper == nullptr); + watcher_wrapper = New( + std::move(watcher), Ref(DEBUG_LOCATION, "WatcherWrapper")); + subchannel_->WatchConnectivityState( + initial_state, + UniquePtr(gpr_strdup(health_check_service_name_.get())), + OrphanablePtr( + watcher_wrapper)); + } + + void CancelConnectivityStateWatch( + ConnectivityStateWatcherInterface* watcher) override { + auto it = watcher_map_.find(watcher); + GPR_ASSERT(it != watcher_map_.end()); + subchannel_->CancelConnectivityStateWatch(health_check_service_name_.get(), + it->second); + watcher_map_.erase(it); + } + + void AttemptToConnect() override { subchannel_->AttemptToConnect(); } + + void ResetBackoff() override { subchannel_->ResetBackoff(); } + + const grpc_channel_args* channel_args() override { + return subchannel_->channel_args(); + } + + // Caller must be holding the control-plane combiner. + ConnectedSubchannel* connected_subchannel() const { + return connected_subchannel_.get(); + } + + // Caller must be holding the data-plane combiner. + ConnectedSubchannel* connected_subchannel_in_data_plane() const { + return connected_subchannel_in_data_plane_.get(); + } + void set_connected_subchannel_in_data_plane( + RefCountedPtr connected_subchannel) { + connected_subchannel_in_data_plane_ = std::move(connected_subchannel); + } + + private: + // Subchannel and SubchannelInterface have different interfaces for + // their respective ConnectivityStateWatcherInterface classes. + // The one in Subchannel updates the ConnectedSubchannel along with + // the state, whereas the one in SubchannelInterface does not expose + // the ConnectedSubchannel. + // + // This wrapper provides a bridge between the two. It implements + // Subchannel::ConnectivityStateWatcherInterface and wraps + // the instance of SubchannelInterface::ConnectivityStateWatcherInterface + // that was passed in by the LB policy. We pass an instance of this + // class to the underlying Subchannel, and when we get updates from + // the subchannel, we pass those on to the wrapped watcher to return + // the update to the LB policy. This allows us to set the connected + // subchannel before passing the result back to the LB policy. + class WatcherWrapper : public Subchannel::ConnectivityStateWatcherInterface { + public: + WatcherWrapper( + UniquePtr + watcher, + RefCountedPtr parent) + : watcher_(std::move(watcher)), parent_(std::move(parent)) {} + + ~WatcherWrapper() { parent_.reset(DEBUG_LOCATION, "WatcherWrapper"); } + + void Orphan() override { Unref(); } + + void OnConnectivityStateChange( + grpc_connectivity_state new_state, + RefCountedPtr connected_subchannel) override { + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { + gpr_log(GPR_INFO, + "chand=%p: connectivity change for subchannel wrapper %p " + "subchannel %p (connected_subchannel=%p state=%s); " + "hopping into combiner", + parent_->chand_, parent_.get(), parent_->subchannel_, + connected_subchannel.get(), + grpc_connectivity_state_name(new_state)); + } + // Will delete itself. + New(Ref(), new_state, std::move(connected_subchannel)); + } + + grpc_pollset_set* interested_parties() override { + return watcher_->interested_parties(); + } + + private: + class Updater { + public: + Updater(RefCountedPtr parent, + grpc_connectivity_state new_state, + RefCountedPtr connected_subchannel) + : parent_(std::move(parent)), + state_(new_state), + connected_subchannel_(std::move(connected_subchannel)) { + GRPC_CLOSURE_INIT( + &closure_, ApplyUpdateInControlPlaneCombiner, this, + grpc_combiner_scheduler(parent_->parent_->chand_->combiner_)); + GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE); + } + + private: + static void ApplyUpdateInControlPlaneCombiner(void* arg, + grpc_error* error) { + Updater* self = static_cast(arg); + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { + gpr_log(GPR_INFO, + "chand=%p: processing connectivity change in combiner " + "for subchannel wrapper %p subchannel %p " + "(connected_subchannel=%p state=%s)", + self->parent_->parent_->chand_, self->parent_->parent_.get(), + self->parent_->parent_->subchannel_, + self->connected_subchannel_.get(), + grpc_connectivity_state_name(self->state_)); + } + self->parent_->parent_->MaybeUpdateConnectedSubchannel( + std::move(self->connected_subchannel_)); + self->parent_->watcher_->OnConnectivityStateChange(self->state_); + Delete(self); + } + + RefCountedPtr parent_; + grpc_connectivity_state state_; + RefCountedPtr connected_subchannel_; + grpc_closure closure_; + }; + + UniquePtr watcher_; + RefCountedPtr parent_; + }; + + void MaybeUpdateConnectedSubchannel( + RefCountedPtr connected_subchannel) { + // Update the connected subchannel only if the channel is not shutting + // down. This is because once the channel is shutting down, we + // ignore picker updates from the LB policy, which means that + // ConnectivityStateAndPickerSetter will never process the entries + // in chand_->pending_subchannel_updates_. So we don't want to add + // entries there that will never be processed, since that would + // leave dangling refs to the channel and prevent its destruction. + grpc_error* disconnect_error = chand_->disconnect_error(); + if (disconnect_error != GRPC_ERROR_NONE) return; + // Not shutting down, so do the update. + if (connected_subchannel_ != connected_subchannel) { + connected_subchannel_ = std::move(connected_subchannel); + // Record the new connected subchannel so that it can be updated + // in the data plane combiner the next time the picker is updated. + chand_->pending_subchannel_updates_[Ref( + DEBUG_LOCATION, "ConnectedSubchannelUpdate")] = connected_subchannel_; + } + } + + ChannelData* chand_; + Subchannel* subchannel_; + UniquePtr health_check_service_name_; + // Maps from the address of the watcher passed to us by the LB policy + // to the address of the WrapperWatcher that we passed to the underlying + // subchannel. This is needed so that when the LB policy calls + // CancelConnectivityStateWatch() with its watcher, we know the + // corresponding WrapperWatcher to cancel on the underlying subchannel. + Map watcher_map_; + // To be accessed only in the control plane combiner. + RefCountedPtr connected_subchannel_; + // To be accessed only in the data plane combiner. + RefCountedPtr connected_subchannel_in_data_plane_; +}; + // // ChannelData::ConnectivityStateAndPickerSetter // @@ -743,19 +994,34 @@ class ChannelData::ConnectivityStateAndPickerSetter { channelz::ChannelNode::GetChannelConnectivityStateChangeString( state))); } + // Grab any pending subchannel updates. + pending_subchannel_updates_ = + std::move(chand_->pending_subchannel_updates_); // Bounce into the data plane combiner to reset the picker. GRPC_CHANNEL_STACK_REF(chand->owning_stack_, "ConnectivityStateAndPickerSetter"); - GRPC_CLOSURE_INIT(&closure_, SetPicker, this, + GRPC_CLOSURE_INIT(&closure_, SetPickerInDataPlane, this, grpc_combiner_scheduler(chand->data_plane_combiner_)); GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE); } private: - static void SetPicker(void* arg, grpc_error* ignored) { + static void SetPickerInDataPlane(void* arg, grpc_error* ignored) { auto* self = static_cast(arg); - // Update picker. - self->chand_->picker_ = std::move(self->picker_); + // Handle subchannel updates. + for (auto& p : self->pending_subchannel_updates_) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { + gpr_log(GPR_INFO, + "chand=%p: updating subchannel wrapper %p data plane " + "connected_subchannel to %p", + self->chand_, p.first.get(), p.second.get()); + } + p.first->set_connected_subchannel_in_data_plane(std::move(p.second)); + } + // Swap out the picker. We hang on to the old picker so that it can + // be deleted in the control-plane combiner, since that's where we need + // to unref the subchannel wrappers that are reffed by the picker. + self->picker_.swap(self->chand_->picker_); // Clean the data plane if the updated picker is nullptr. if (self->chand_->picker_ == nullptr) { self->chand_->received_service_config_data_ = false; @@ -767,7 +1033,17 @@ class ChannelData::ConnectivityStateAndPickerSetter { pick = pick->next) { CallData::StartPickLocked(pick->elem, GRPC_ERROR_NONE); } - // Clean up. + // Pop back into the control plane combiner to delete ourself, so + // that we make sure to unref subchannel wrappers there. This + // includes both the ones reffed by the old picker (now stored in + // self->picker_) and the ones in self->pending_subchannel_updates_. + GRPC_CLOSURE_INIT(&self->closure_, CleanUpInControlPlane, self, + grpc_combiner_scheduler(self->chand_->combiner_)); + GRPC_CLOSURE_SCHED(&self->closure_, GRPC_ERROR_NONE); + } + + static void CleanUpInControlPlane(void* arg, grpc_error* ignored) { + auto* self = static_cast(arg); GRPC_CHANNEL_STACK_UNREF(self->chand_->owning_stack_, "ConnectivityStateAndPickerSetter"); Delete(self); @@ -775,6 +1051,9 @@ class ChannelData::ConnectivityStateAndPickerSetter { ChannelData* chand_; UniquePtr picker_; + Map, RefCountedPtr, + RefCountedPtrLess> + pending_subchannel_updates_; grpc_closure closure_; }; @@ -949,89 +1228,6 @@ void ChannelData::ExternalConnectivityWatcher::WatchConnectivityStateLocked( &self->chand_->state_tracker_, self->state_, &self->my_closure_); } -// -// ChannelData::GrpcSubchannel -// - -// This class is a wrapper for Subchannel that hides details of the -// channel's implementation (such as the health check service name) from -// the LB policy API. -// -// Note that no synchronization is needed here, because even if the -// underlying subchannel is shared between channels, this wrapper will only -// be used within one channel, so it will always be synchronized by the -// control plane combiner. -class ChannelData::GrpcSubchannel : public SubchannelInterface { - public: - GrpcSubchannel(ChannelData* chand, Subchannel* subchannel, - UniquePtr health_check_service_name) - : chand_(chand), - subchannel_(subchannel), - health_check_service_name_(std::move(health_check_service_name)) { - GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "GrpcSubchannel"); - auto* subchannel_node = subchannel_->channelz_node(); - if (subchannel_node != nullptr) { - intptr_t subchannel_uuid = subchannel_node->uuid(); - auto it = chand_->subchannel_refcount_map_.find(subchannel_); - if (it == chand_->subchannel_refcount_map_.end()) { - chand_->channelz_node_->AddChildSubchannel(subchannel_uuid); - it = chand_->subchannel_refcount_map_.emplace(subchannel_, 0).first; - } - ++it->second; - } - } - - ~GrpcSubchannel() { - auto* subchannel_node = subchannel_->channelz_node(); - if (subchannel_node != nullptr) { - intptr_t subchannel_uuid = subchannel_node->uuid(); - auto it = chand_->subchannel_refcount_map_.find(subchannel_); - GPR_ASSERT(it != chand_->subchannel_refcount_map_.end()); - --it->second; - if (it->second == 0) { - chand_->channelz_node_->RemoveChildSubchannel(subchannel_uuid); - chand_->subchannel_refcount_map_.erase(it); - } - } - GRPC_SUBCHANNEL_UNREF(subchannel_, "unref from LB"); - GRPC_CHANNEL_STACK_UNREF(chand_->owning_stack_, "GrpcSubchannel"); - } - - grpc_connectivity_state CheckConnectivityState( - RefCountedPtr* connected_subchannel) - override { - RefCountedPtr tmp; - auto retval = subchannel_->CheckConnectivityState( - health_check_service_name_.get(), &tmp); - *connected_subchannel = std::move(tmp); - return retval; - } - - void WatchConnectivityState( - grpc_connectivity_state initial_state, - UniquePtr watcher) override { - subchannel_->WatchConnectivityState( - initial_state, - UniquePtr(gpr_strdup(health_check_service_name_.get())), - std::move(watcher)); - } - - void CancelConnectivityStateWatch( - ConnectivityStateWatcher* watcher) override { - subchannel_->CancelConnectivityStateWatch(health_check_service_name_.get(), - watcher); - } - - void AttemptToConnect() override { subchannel_->AttemptToConnect(); } - - void ResetBackoff() override { subchannel_->ResetBackoff(); } - - private: - ChannelData* chand_; - Subchannel* subchannel_; - UniquePtr health_check_service_name_; -}; - // // ChannelData::ClientChannelControlHelper // @@ -1069,8 +1265,8 @@ class ChannelData::ClientChannelControlHelper chand_->client_channel_factory_->CreateSubchannel(new_args); grpc_channel_args_destroy(new_args); if (subchannel == nullptr) return nullptr; - return MakeRefCounted(chand_, subchannel, - std::move(health_check_service_name)); + return MakeRefCounted( + chand_, subchannel, std::move(health_check_service_name)); } grpc_channel* CreateChannel(const char* target, @@ -1081,8 +1277,7 @@ class ChannelData::ClientChannelControlHelper void UpdateState( grpc_connectivity_state state, UniquePtr picker) override { - grpc_error* disconnect_error = - chand_->disconnect_error_.Load(MemoryOrder::ACQUIRE); + grpc_error* disconnect_error = chand_->disconnect_error(); if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { const char* extra = disconnect_error == GRPC_ERROR_NONE ? "" @@ -1456,9 +1651,13 @@ grpc_error* ChannelData::DoPingLocked(grpc_transport_op* op) { } LoadBalancingPolicy::PickResult result = picker_->Pick(LoadBalancingPolicy::PickArgs()); - if (result.connected_subchannel != nullptr) { - ConnectedSubchannel* connected_subchannel = - static_cast(result.connected_subchannel.get()); + ConnectedSubchannel* connected_subchannel = nullptr; + if (result.subchannel != nullptr) { + SubchannelWrapper* subchannel = + static_cast(result.subchannel.get()); + connected_subchannel = subchannel->connected_subchannel(); + } + if (connected_subchannel != nullptr) { connected_subchannel->Ping(op->send_ping.on_initiate, op->send_ping.on_ack); } else { if (result.error == GRPC_ERROR_NONE) { @@ -1501,6 +1700,10 @@ void ChannelData::StartTransportOpLocked(void* arg, grpc_error* ignored) { } // Disconnect or enter IDLE. if (op->disconnect_with_error != GRPC_ERROR_NONE) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) { + gpr_log(GPR_INFO, "chand=%p: disconnect_with_error: %s", chand, + grpc_error_string(op->disconnect_with_error)); + } chand->DestroyResolvingLoadBalancingPolicyLocked(); intptr_t value; if (grpc_error_get_int(op->disconnect_with_error, @@ -1584,6 +1787,17 @@ void ChannelData::RemoveQueuedPick(QueuedPick* to_remove, } } +RefCountedPtr +ChannelData::GetConnectedSubchannelInDataPlane( + SubchannelInterface* subchannel) const { + SubchannelWrapper* subchannel_wrapper = + static_cast(subchannel); + ConnectedSubchannel* connected_subchannel = + subchannel_wrapper->connected_subchannel_in_data_plane(); + if (connected_subchannel == nullptr) return nullptr; + return connected_subchannel->Ref(); +} + void ChannelData::TryToConnectLocked(void* arg, grpc_error* error_ignored) { auto* chand = static_cast(arg); if (chand->resolving_lb_policy_ != nullptr) { @@ -3522,10 +3736,9 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { auto result = chand->picker()->Pick(pick_args); if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { gpr_log(GPR_INFO, - "chand=%p calld=%p: LB pick returned %s (connected_subchannel=%p, " - "error=%s)", + "chand=%p calld=%p: LB pick returned %s (subchannel=%p, error=%s)", chand, calld, PickResultTypeName(result.type), - result.connected_subchannel.get(), grpc_error_string(result.error)); + result.subchannel.get(), grpc_error_string(result.error)); } switch (result.type) { case LoadBalancingPolicy::PickResult::PICK_TRANSIENT_FAILURE: { @@ -3567,11 +3780,16 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { break; default: // PICK_COMPLETE // Handle drops. - if (GPR_UNLIKELY(result.connected_subchannel == nullptr)) { + if (GPR_UNLIKELY(result.subchannel == nullptr)) { result.error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Call dropped by load balancing policy"); + } else { + // Grab a ref to the connected subchannel while we're still + // holding the data plane combiner. + calld->connected_subchannel_ = + chand->GetConnectedSubchannelInDataPlane(result.subchannel.get()); + GPR_ASSERT(calld->connected_subchannel_ != nullptr); } - calld->connected_subchannel_ = std::move(result.connected_subchannel); calld->lb_recv_trailing_metadata_ready_ = result.recv_trailing_metadata_ready; calld->lb_recv_trailing_metadata_ready_user_data_ = diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h index f98a41dee07..c21e9d90ec4 100644 --- a/src/core/ext/filters/client_channel/lb_policy.h +++ b/src/core/ext/filters/client_channel/lb_policy.h @@ -128,7 +128,7 @@ class LoadBalancingPolicy : public InternallyRefCounted { /// Used only if type is PICK_COMPLETE. Will be set to the selected /// subchannel, or nullptr if the LB policy decides to drop the call. - RefCountedPtr connected_subchannel; + RefCountedPtr subchannel; /// Used only if type is PICK_TRANSIENT_FAILURE. /// Error to be set when returning a transient failure. diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 71e8e248770..2eb1d9d4237 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -572,13 +572,12 @@ GrpcLb::PickResult GrpcLb::Picker::Pick(PickArgs args) { result = child_picker_->Pick(args); // If pick succeeded, add LB token to initial metadata. if (result.type == PickResult::PICK_COMPLETE && - result.connected_subchannel != nullptr) { + result.subchannel != nullptr) { const grpc_arg* arg = grpc_channel_args_find( - result.connected_subchannel->args(), GRPC_ARG_GRPCLB_ADDRESS_LB_TOKEN); + result.subchannel->channel_args(), GRPC_ARG_GRPCLB_ADDRESS_LB_TOKEN); if (arg == nullptr) { - gpr_log(GPR_ERROR, - "[grpclb %p picker %p] No LB token for connected subchannel %p", - parent_, this, result.connected_subchannel.get()); + gpr_log(GPR_ERROR, "[grpclb %p picker %p] No LB token for subchannel %p", + parent_, this, result.subchannel.get()); abort(); } grpc_mdelem lb_token = {reinterpret_cast(arg->value.pointer.p)}; diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index 411d528354a..b40b0325421 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -28,7 +28,6 @@ #include "src/core/ext/filters/client_channel/subchannel.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/sync.h" -#include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/transport/connectivity_state.h" @@ -85,9 +84,8 @@ class PickFirst : public LoadBalancingPolicy { public: PickFirstSubchannelList(PickFirst* policy, TraceFlag* tracer, const ServerAddressList& addresses, - grpc_combiner* combiner, const grpc_channel_args& args) - : SubchannelList(policy, tracer, addresses, combiner, + : SubchannelList(policy, tracer, addresses, policy->channel_control_helper(), args) { // Need to maintain a ref to the LB policy as long as we maintain // any references to subchannels, since the subchannels' @@ -111,19 +109,18 @@ class PickFirst : public LoadBalancingPolicy { class Picker : public SubchannelPicker { public: - explicit Picker( - RefCountedPtr connected_subchannel) - : connected_subchannel_(std::move(connected_subchannel)) {} + explicit Picker(RefCountedPtr subchannel) + : subchannel_(std::move(subchannel)) {} PickResult Pick(PickArgs args) override { PickResult result; result.type = PickResult::PICK_COMPLETE; - result.connected_subchannel = connected_subchannel_; + result.subchannel = subchannel_; return result; } private: - RefCountedPtr connected_subchannel_; + RefCountedPtr subchannel_; }; void ShutdownLocked() override; @@ -170,6 +167,9 @@ void PickFirst::ShutdownLocked() { void PickFirst::ExitIdleLocked() { if (shutdown_) return; if (idle_) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_pick_first_trace)) { + gpr_log(GPR_INFO, "Pick First %p exiting idle", this); + } idle_ = false; AttemptToConnectUsingLatestUpdateArgsLocked(); } @@ -186,7 +186,7 @@ void PickFirst::AttemptToConnectUsingLatestUpdateArgsLocked() { // Create a subchannel list from the latest_update_args_. auto subchannel_list = MakeOrphanable( this, &grpc_lb_pick_first_trace, latest_update_args_.addresses, - combiner(), *latest_update_args_.args); + *latest_update_args_.args); // Empty update or no valid subchannels. if (subchannel_list->num_subchannels() == 0) { // Unsubscribe from all current subchannels. @@ -347,8 +347,8 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( // some connectivity state notifications. if (connectivity_state == GRPC_CHANNEL_READY) { p->channel_control_helper()->UpdateState( - GRPC_CHANNEL_READY, UniquePtr(New( - connected_subchannel()->Ref()))); + GRPC_CHANNEL_READY, + UniquePtr(New(subchannel()->Ref()))); } else { // CONNECTING p->channel_control_helper()->UpdateState( connectivity_state, UniquePtr(New( @@ -443,13 +443,13 @@ void PickFirst::PickFirstSubchannelData::ProcessUnselectedReadyLocked() { p->subchannel_list_ = std::move(p->latest_pending_subchannel_list_); } // Cases 1 and 2. - p->selected_ = this; - p->channel_control_helper()->UpdateState( - GRPC_CHANNEL_READY, - UniquePtr(New(connected_subchannel()->Ref()))); if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_pick_first_trace)) { gpr_log(GPR_INFO, "Pick First %p selected subchannel %p", p, subchannel()); } + p->selected_ = this; + p->channel_control_helper()->UpdateState( + GRPC_CHANNEL_READY, + UniquePtr(New(subchannel()->Ref()))); for (size_t i = 0; i < subchannel_list()->num_subchannels(); ++i) { if (i != Index()) { subchannel_list()->subchannel(i)->ShutdownLocked(); diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc index c6655c7d9bb..04308ee254c 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc @@ -38,7 +38,6 @@ #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/sync.h" -#include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/transport/connectivity_state.h" #include "src/core/lib/transport/static_metadata.h" @@ -106,9 +105,8 @@ class RoundRobin : public LoadBalancingPolicy { public: RoundRobinSubchannelList(RoundRobin* policy, TraceFlag* tracer, const ServerAddressList& addresses, - grpc_combiner* combiner, const grpc_channel_args& args) - : SubchannelList(policy, tracer, addresses, combiner, + : SubchannelList(policy, tracer, addresses, policy->channel_control_helper(), args) { // Need to maintain a ref to the LB policy as long as we maintain // any references to subchannels, since the subchannels' @@ -155,7 +153,7 @@ class RoundRobin : public LoadBalancingPolicy { RoundRobin* parent_; size_t last_picked_index_; - InlinedVector, 10> subchannels_; + InlinedVector, 10> subchannels_; }; void ShutdownLocked() override; @@ -180,10 +178,9 @@ RoundRobin::Picker::Picker(RoundRobin* parent, RoundRobinSubchannelList* subchannel_list) : parent_(parent) { for (size_t i = 0; i < subchannel_list->num_subchannels(); ++i) { - auto* connected_subchannel = - subchannel_list->subchannel(i)->connected_subchannel(); - if (connected_subchannel != nullptr) { - subchannels_.push_back(connected_subchannel->Ref()); + RoundRobinSubchannelData* sd = subchannel_list->subchannel(i); + if (sd->connectivity_state() == GRPC_CHANNEL_READY) { + subchannels_.push_back(sd->subchannel()->Ref()); } } // For discussion on why we generate a random starting index for @@ -204,14 +201,13 @@ RoundRobin::PickResult RoundRobin::Picker::Pick(PickArgs args) { last_picked_index_ = (last_picked_index_ + 1) % subchannels_.size(); if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_round_robin_trace)) { gpr_log(GPR_INFO, - "[RR %p picker %p] returning index %" PRIuPTR - ", connected_subchannel=%p", + "[RR %p picker %p] returning index %" PRIuPTR ", subchannel=%p", parent_, this, last_picked_index_, subchannels_[last_picked_index_].get()); } PickResult result; result.type = PickResult::PICK_COMPLETE; - result.connected_subchannel = subchannels_[last_picked_index_]; + result.subchannel = subchannels_[last_picked_index_]; return result; } @@ -424,7 +420,7 @@ void RoundRobin::UpdateLocked(UpdateArgs args) { } } latest_pending_subchannel_list_ = MakeOrphanable( - this, &grpc_lb_round_robin_trace, args.addresses, combiner(), *args.args); + this, &grpc_lb_round_robin_trace, args.addresses, *args.args); if (latest_pending_subchannel_list_->num_subchannels() == 0) { // If the new list is empty, immediately promote the new list to the // current list and transition to TRANSIENT_FAILURE. diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h index 7d70928a83c..34cd0f549fe 100644 --- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h @@ -39,7 +39,6 @@ #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/closure.h" -#include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/transport/connectivity_state.h" @@ -64,8 +63,7 @@ class MySubchannelList }; */ -// All methods with a Locked() suffix must be called from within the -// client_channel combiner. +// All methods will be called from within the client_channel combiner. namespace grpc_core { @@ -93,20 +91,13 @@ class SubchannelData { // Returns a pointer to the subchannel. SubchannelInterface* subchannel() const { return subchannel_.get(); } - // Returns the connected subchannel. Will be null if the subchannel - // is not connected. - ConnectedSubchannelInterface* connected_subchannel() const { - return connected_subchannel_.get(); - } - // Synchronously checks the subchannel's connectivity state. // Must not be called while there is a connectivity notification // pending (i.e., between calling StartConnectivityWatchLocked() and // calling CancelConnectivityWatchLocked()). grpc_connectivity_state CheckConnectivityStateLocked() { GPR_ASSERT(pending_watcher_ == nullptr); - connectivity_state_ = - subchannel()->CheckConnectivityState(&connected_subchannel_); + connectivity_state_ = subchannel_->CheckConnectivityState(); return connectivity_state_; } @@ -144,7 +135,8 @@ class SubchannelData { private: // Watcher for subchannel connectivity state. - class Watcher : public SubchannelInterface::ConnectivityStateWatcher { + class Watcher + : public SubchannelInterface::ConnectivityStateWatcherInterface { public: Watcher( SubchannelData* subchannel_data, @@ -154,42 +146,13 @@ class SubchannelData { ~Watcher() { subchannel_list_.reset(DEBUG_LOCATION, "Watcher dtor"); } - void OnConnectivityStateChange(grpc_connectivity_state new_state, - RefCountedPtr - connected_subchannel) override; + void OnConnectivityStateChange(grpc_connectivity_state new_state) override; grpc_pollset_set* interested_parties() override { return subchannel_list_->policy()->interested_parties(); } private: - // A fire-and-forget class that bounces into the combiner to process - // a connectivity state update. - class Updater { - public: - Updater( - SubchannelData* - subchannel_data, - RefCountedPtr> - subchannel_list, - grpc_connectivity_state state, - RefCountedPtr connected_subchannel); - - ~Updater() { - subchannel_list_.reset(DEBUG_LOCATION, "Watcher::Updater dtor"); - } - - private: - static void OnUpdateLocked(void* arg, grpc_error* error); - - SubchannelData* subchannel_data_; - RefCountedPtr> - subchannel_list_; - const grpc_connectivity_state state_; - RefCountedPtr connected_subchannel_; - grpc_closure closure_; - }; - SubchannelData* subchannel_data_; RefCountedPtr subchannel_list_; }; @@ -202,10 +165,10 @@ class SubchannelData { // The subchannel. RefCountedPtr subchannel_; // Will be non-null when the subchannel's state is being watched. - SubchannelInterface::ConnectivityStateWatcher* pending_watcher_ = nullptr; + SubchannelInterface::ConnectivityStateWatcherInterface* pending_watcher_ = + nullptr; // Data updated by the watcher. grpc_connectivity_state connectivity_state_; - RefCountedPtr connected_subchannel_; }; // A list of subchannels. @@ -232,7 +195,6 @@ class SubchannelList : public InternallyRefCounted { // the backoff code out of subchannels and into LB policies. void ResetBackoffLocked(); - // Note: Caller must ensure that this is invoked inside of the combiner. void Orphan() override { ShutdownLocked(); InternallyRefCounted::Unref(DEBUG_LOCATION, "shutdown"); @@ -242,7 +204,7 @@ class SubchannelList : public InternallyRefCounted { protected: SubchannelList(LoadBalancingPolicy* policy, TraceFlag* tracer, - const ServerAddressList& addresses, grpc_combiner* combiner, + const ServerAddressList& addresses, LoadBalancingPolicy::ChannelControlHelper* helper, const grpc_channel_args& args); @@ -263,8 +225,6 @@ class SubchannelList : public InternallyRefCounted { TraceFlag* tracer_; - grpc_combiner* combiner_; - // The list of subchannels. SubchannelVector subchannels_; @@ -284,59 +244,26 @@ class SubchannelList : public InternallyRefCounted { template void SubchannelData::Watcher:: - OnConnectivityStateChange( - grpc_connectivity_state new_state, - RefCountedPtr connected_subchannel) { - // Will delete itself. - New(subchannel_data_, - subchannel_list_->Ref(DEBUG_LOCATION, "Watcher::Updater"), - new_state, std::move(connected_subchannel)); -} - -template -SubchannelData::Watcher::Updater:: - Updater( - SubchannelData* subchannel_data, - RefCountedPtr> - subchannel_list, - grpc_connectivity_state state, - RefCountedPtr connected_subchannel) - : subchannel_data_(subchannel_data), - subchannel_list_(std::move(subchannel_list)), - state_(state), - connected_subchannel_(std::move(connected_subchannel)) { - GRPC_CLOSURE_INIT(&closure_, &OnUpdateLocked, this, - grpc_combiner_scheduler(subchannel_list_->combiner_)); - GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE); -} - -template -void SubchannelData::Watcher::Updater:: - OnUpdateLocked(void* arg, grpc_error* error) { - Updater* self = static_cast(arg); - SubchannelData* sd = self->subchannel_data_; - if (GRPC_TRACE_FLAG_ENABLED(*sd->subchannel_list_->tracer())) { + OnConnectivityStateChange(grpc_connectivity_state new_state) { + if (GRPC_TRACE_FLAG_ENABLED(*subchannel_list_->tracer())) { gpr_log(GPR_INFO, "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR " (subchannel %p): connectivity changed: state=%s, " - "connected_subchannel=%p, shutting_down=%d, pending_watcher=%p", - sd->subchannel_list_->tracer()->name(), - sd->subchannel_list_->policy(), sd->subchannel_list_, sd->Index(), - sd->subchannel_list_->num_subchannels(), sd->subchannel_.get(), - grpc_connectivity_state_name(self->state_), - self->connected_subchannel_.get(), - sd->subchannel_list_->shutting_down(), sd->pending_watcher_); + "shutting_down=%d, pending_watcher=%p", + subchannel_list_->tracer()->name(), subchannel_list_->policy(), + subchannel_list_.get(), subchannel_data_->Index(), + subchannel_list_->num_subchannels(), + subchannel_data_->subchannel_.get(), + grpc_connectivity_state_name(new_state), + subchannel_list_->shutting_down(), + subchannel_data_->pending_watcher_); } - if (!sd->subchannel_list_->shutting_down() && - sd->pending_watcher_ != nullptr) { - sd->connectivity_state_ = self->state_; - // Get or release ref to connected subchannel. - sd->connected_subchannel_ = std::move(self->connected_subchannel_); + if (!subchannel_list_->shutting_down() && + subchannel_data_->pending_watcher_ != nullptr) { + subchannel_data_->connectivity_state_ = new_state; // Call the subclass's ProcessConnectivityChangeLocked() method. - sd->ProcessConnectivityChangeLocked(sd->connectivity_state_); + subchannel_data_->ProcessConnectivityChangeLocked(new_state); } - // Clean up. - Delete(self); } // @@ -371,7 +298,6 @@ void SubchannelData:: subchannel_.get()); } subchannel_.reset(); - connected_subchannel_.reset(); } } @@ -400,7 +326,7 @@ void SubchannelData(this, subchannel_list()->Ref(DEBUG_LOCATION, "Watcher")); subchannel_->WatchConnectivityState( connectivity_state_, - UniquePtr( + UniquePtr( pending_watcher_)); } @@ -434,13 +360,12 @@ void SubchannelData::ShutdownLocked() { template SubchannelList::SubchannelList( LoadBalancingPolicy* policy, TraceFlag* tracer, - const ServerAddressList& addresses, grpc_combiner* combiner, + const ServerAddressList& addresses, LoadBalancingPolicy::ChannelControlHelper* helper, const grpc_channel_args& args) : InternallyRefCounted(tracer), policy_(policy), - tracer_(tracer), - combiner_(GRPC_COMBINER_REF(combiner, "subchannel_list")) { + tracer_(tracer) { if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) { gpr_log(GPR_INFO, "[%s %p] Creating subchannel list %p for %" PRIuPTR " subchannels", @@ -509,7 +434,6 @@ SubchannelList::~SubchannelList() { gpr_log(GPR_INFO, "[%s %p] Destroying subchannel_list %p", tracer_->name(), policy_, this); } - GRPC_COMBINER_UNREF(combiner_, "subchannel_list"); } template diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index ca9ea9e31cc..ff608e58857 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -567,7 +567,7 @@ XdsLb::PickResult XdsLb::Picker::Pick(PickArgs args) { PickResult result = PickFromLocality(key, args); // If pick succeeded, add client stats. if (result.type == PickResult::PICK_COMPLETE && - result.connected_subchannel != nullptr && client_stats_ != nullptr) { + result.subchannel != nullptr && client_stats_ != nullptr) { // TODO(roth): Add support for client stats. } return result; diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 5e6cbccd93f..e248cc6b5fc 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -85,7 +85,7 @@ DebugOnlyTraceFlag grpc_trace_subchannel_refcount(false, "subchannel_refcount"); ConnectedSubchannel::ConnectedSubchannel( grpc_channel_stack* channel_stack, const grpc_channel_args* args, RefCountedPtr channelz_subchannel) - : ConnectedSubchannelInterface(&grpc_trace_subchannel_refcount), + : RefCounted(&grpc_trace_subchannel_refcount), channel_stack_(channel_stack), args_(grpc_channel_args_copy(args)), channelz_subchannel_(std::move(channelz_subchannel)) {} @@ -385,12 +385,12 @@ class Subchannel::ConnectedSubchannelStateWatcher { // void Subchannel::ConnectivityStateWatcherList::AddWatcherLocked( - UniquePtr watcher) { + OrphanablePtr watcher) { watchers_.insert(MakePair(watcher.get(), std::move(watcher))); } void Subchannel::ConnectivityStateWatcherList::RemoveWatcherLocked( - ConnectivityStateWatcher* watcher) { + ConnectivityStateWatcherInterface* watcher) { watchers_.erase(watcher); } @@ -445,8 +445,9 @@ class Subchannel::HealthWatcherMap::HealthWatcher grpc_connectivity_state state() const { return state_; } - void AddWatcherLocked(grpc_connectivity_state initial_state, - UniquePtr watcher) { + void AddWatcherLocked( + grpc_connectivity_state initial_state, + OrphanablePtr watcher) { if (state_ != initial_state) { RefCountedPtr connected_subchannel; if (state_ == GRPC_CHANNEL_READY) { @@ -458,7 +459,7 @@ class Subchannel::HealthWatcherMap::HealthWatcher watcher_list_.AddWatcherLocked(std::move(watcher)); } - void RemoveWatcherLocked(ConnectivityStateWatcher* watcher) { + void RemoveWatcherLocked(ConnectivityStateWatcherInterface* watcher) { watcher_list_.RemoveWatcherLocked(watcher); } @@ -534,7 +535,7 @@ class Subchannel::HealthWatcherMap::HealthWatcher void Subchannel::HealthWatcherMap::AddWatcherLocked( Subchannel* subchannel, grpc_connectivity_state initial_state, UniquePtr health_check_service_name, - UniquePtr watcher) { + OrphanablePtr watcher) { // If the health check service name is not already present in the map, // add it. auto it = map_.find(health_check_service_name.get()); @@ -553,7 +554,8 @@ void Subchannel::HealthWatcherMap::AddWatcherLocked( } void Subchannel::HealthWatcherMap::RemoveWatcherLocked( - const char* health_check_service_name, ConnectivityStateWatcher* watcher) { + const char* health_check_service_name, + ConnectivityStateWatcherInterface* watcher) { auto it = map_.find(health_check_service_name); GPR_ASSERT(it != map_.end()); it->second->RemoveWatcherLocked(watcher); @@ -817,7 +819,7 @@ grpc_connectivity_state Subchannel::CheckConnectivityState( void Subchannel::WatchConnectivityState( grpc_connectivity_state initial_state, UniquePtr health_check_service_name, - UniquePtr watcher) { + OrphanablePtr watcher) { MutexLock lock(&mu_); grpc_pollset_set* interested_parties = watcher->interested_parties(); if (interested_parties != nullptr) { @@ -836,7 +838,8 @@ void Subchannel::WatchConnectivityState( } void Subchannel::CancelConnectivityStateWatch( - const char* health_check_service_name, ConnectivityStateWatcher* watcher) { + const char* health_check_service_name, + ConnectivityStateWatcherInterface* watcher) { MutexLock lock(&mu_); grpc_pollset_set* interested_parties = watcher->interested_parties(); if (interested_parties != nullptr) { diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h index d1c4b7d1073..d745bc8ddc2 100644 --- a/src/core/ext/filters/client_channel/subchannel.h +++ b/src/core/ext/filters/client_channel/subchannel.h @@ -23,7 +23,6 @@ #include "src/core/ext/filters/client_channel/client_channel_channelz.h" #include "src/core/ext/filters/client_channel/connector.h" -#include "src/core/ext/filters/client_channel/subchannel_interface.h" #include "src/core/ext/filters/client_channel/subchannel_pool_interface.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_stack.h" @@ -70,7 +69,7 @@ namespace grpc_core { class SubchannelCall; -class ConnectedSubchannel : public ConnectedSubchannelInterface { +class ConnectedSubchannel : public RefCounted { public: ConnectedSubchannel( grpc_channel_stack* channel_stack, const grpc_channel_args* args, @@ -83,7 +82,7 @@ class ConnectedSubchannel : public ConnectedSubchannelInterface { void Ping(grpc_closure* on_initiate, grpc_closure* on_ack); grpc_channel_stack* channel_stack() const { return channel_stack_; } - const grpc_channel_args* args() const override { return args_; } + const grpc_channel_args* args() const { return args_; } channelz::SubchannelNode* channelz_subchannel() const { return channelz_subchannel_.get(); } @@ -169,10 +168,35 @@ class SubchannelCall { // A subchannel that knows how to connect to exactly one target address. It // provides a target for load balancing. +// +// Note that this is the "real" subchannel implementation, whose API is +// different from the SubchannelInterface that is exposed to LB policy +// implementations. The client channel provides an adaptor class +// (SubchannelWrapper) that "converts" between the two. class Subchannel { public: - typedef SubchannelInterface::ConnectivityStateWatcher - ConnectivityStateWatcher; + class ConnectivityStateWatcherInterface + : public InternallyRefCounted { + public: + virtual ~ConnectivityStateWatcherInterface() = default; + + // Will be invoked whenever the subchannel's connectivity state + // changes. There will be only one invocation of this method on a + // given watcher instance at any given time. + // + // When the state changes to READY, connected_subchannel will + // contain a ref to the connected subchannel. When it changes from + // READY to some other state, the implementation must release its + // ref to the connected subchannel. + virtual void OnConnectivityStateChange( + grpc_connectivity_state new_state, + RefCountedPtr connected_subchannel) // NOLINT + GRPC_ABSTRACT; + + virtual grpc_pollset_set* interested_parties() GRPC_ABSTRACT; + + GRPC_ABSTRACT_BASE_CLASS + }; // The ctor and dtor are not intended to use directly. Subchannel(SubchannelKey* key, grpc_connector* connector, @@ -197,6 +221,8 @@ class Subchannel { // Caller doesn't take ownership. const char* GetTargetAddress(); + const grpc_channel_args* channel_args() const { return args_; } + channelz::SubchannelNode* channelz_node(); // Returns the current connectivity state of the subchannel. @@ -216,14 +242,15 @@ class Subchannel { // changes. // The watcher will be destroyed either when the subchannel is // destroyed or when CancelConnectivityStateWatch() is called. - void WatchConnectivityState(grpc_connectivity_state initial_state, - UniquePtr health_check_service_name, - UniquePtr watcher); + void WatchConnectivityState( + grpc_connectivity_state initial_state, + UniquePtr health_check_service_name, + OrphanablePtr watcher); // Cancels a connectivity state watch. // If the watcher has already been destroyed, this is a no-op. void CancelConnectivityStateWatch(const char* health_check_service_name, - ConnectivityStateWatcher* watcher); + ConnectivityStateWatcherInterface* watcher); // Attempt to connect to the backend. Has no effect if already connected. void AttemptToConnect(); @@ -248,14 +275,15 @@ class Subchannel { grpc_resolved_address* addr); private: - // A linked list of ConnectivityStateWatchers that are monitoring the - // subchannel's state. + // A linked list of ConnectivityStateWatcherInterfaces that are monitoring + // the subchannel's state. class ConnectivityStateWatcherList { public: ~ConnectivityStateWatcherList() { Clear(); } - void AddWatcherLocked(UniquePtr watcher); - void RemoveWatcherLocked(ConnectivityStateWatcher* watcher); + void AddWatcherLocked( + OrphanablePtr watcher); + void RemoveWatcherLocked(ConnectivityStateWatcherInterface* watcher); // Notifies all watchers in the list about a change to state. void NotifyLocked(Subchannel* subchannel, grpc_connectivity_state state); @@ -267,12 +295,13 @@ class Subchannel { private: // TODO(roth): This could be a set instead of a map if we had a set // implementation. - Map> + Map> watchers_; }; - // A map that tracks ConnectivityStateWatchers using a particular health - // check service name. + // A map that tracks ConnectivityStateWatcherInterfaces using a particular + // health check service name. // // There is one entry in the map for each health check service name. // Entries exist only as long as there are watchers using the @@ -282,12 +311,12 @@ class Subchannel { // state READY. class HealthWatcherMap { public: - void AddWatcherLocked(Subchannel* subchannel, - grpc_connectivity_state initial_state, - UniquePtr health_check_service_name, - UniquePtr watcher); + void AddWatcherLocked( + Subchannel* subchannel, grpc_connectivity_state initial_state, + UniquePtr health_check_service_name, + OrphanablePtr watcher); void RemoveWatcherLocked(const char* health_check_service_name, - ConnectivityStateWatcher* watcher); + ConnectivityStateWatcherInterface* watcher); // Notifies the watcher when the subchannel's state changes. void NotifyLocked(grpc_connectivity_state state); diff --git a/src/core/ext/filters/client_channel/subchannel_interface.h b/src/core/ext/filters/client_channel/subchannel_interface.h index 10b1bf124c2..2e448dc5a64 100644 --- a/src/core/ext/filters/client_channel/subchannel_interface.h +++ b/src/core/ext/filters/client_channel/subchannel_interface.h @@ -21,42 +21,22 @@ #include -#include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" namespace grpc_core { -// TODO(roth): In a subsequent PR, remove this from this API. -class ConnectedSubchannelInterface - : public RefCounted { - public: - virtual const grpc_channel_args* args() const GRPC_ABSTRACT; - - protected: - template - explicit ConnectedSubchannelInterface(TraceFlagT* trace_flag = nullptr) - : RefCounted(trace_flag) {} -}; - +// The interface for subchannels that is exposed to LB policy implementations. class SubchannelInterface : public RefCounted { public: - class ConnectivityStateWatcher { + class ConnectivityStateWatcherInterface { public: - virtual ~ConnectivityStateWatcher() = default; + virtual ~ConnectivityStateWatcherInterface() = default; // Will be invoked whenever the subchannel's connectivity state // changes. There will be only one invocation of this method on a // given watcher instance at any given time. - // - // When the state changes to READY, connected_subchannel will - // contain a ref to the connected subchannel. When it changes from - // READY to some other state, the implementation must release its - // ref to the connected subchannel. - virtual void OnConnectivityStateChange( - grpc_connectivity_state new_state, - RefCountedPtr - connected_subchannel) // NOLINT + virtual void OnConnectivityStateChange(grpc_connectivity_state new_state) GRPC_ABSTRACT; // TODO(roth): Remove this as soon as we move to EventManager-based @@ -66,12 +46,14 @@ class SubchannelInterface : public RefCounted { GRPC_ABSTRACT_BASE_CLASS }; + template + explicit SubchannelInterface(TraceFlagT* trace_flag = nullptr) + : RefCounted(trace_flag) {} + virtual ~SubchannelInterface() = default; // Returns the current connectivity state of the subchannel. - virtual grpc_connectivity_state CheckConnectivityState( - RefCountedPtr* connected_subchannel) - GRPC_ABSTRACT; + virtual grpc_connectivity_state CheckConnectivityState() GRPC_ABSTRACT; // Starts watching the subchannel's connectivity state. // The first callback to the watcher will be delivered when the @@ -86,12 +68,12 @@ class SubchannelInterface : public RefCounted { // the previous watcher using CancelConnectivityStateWatch(). virtual void WatchConnectivityState( grpc_connectivity_state initial_state, - UniquePtr watcher) GRPC_ABSTRACT; + UniquePtr watcher) GRPC_ABSTRACT; // Cancels a connectivity state watch. // If the watcher has already been destroyed, this is a no-op. - virtual void CancelConnectivityStateWatch(ConnectivityStateWatcher* watcher) - GRPC_ABSTRACT; + virtual void CancelConnectivityStateWatch( + ConnectivityStateWatcherInterface* watcher) GRPC_ABSTRACT; // Attempt to connect to the backend. Has no effect if already connected. // If the subchannel is currently in backoff delay due to a previously @@ -105,6 +87,9 @@ class SubchannelInterface : public RefCounted { // attempt will be started as soon as AttemptToConnect() is called. virtual void ResetBackoff() GRPC_ABSTRACT; + // TODO(roth): Need a better non-grpc-specific abstraction here. + virtual const grpc_channel_args* channel_args() GRPC_ABSTRACT; + GRPC_ABSTRACT_BASE_CLASS }; diff --git a/src/core/lib/gprpp/map.h b/src/core/lib/gprpp/map.h index 2babe35cd1b..5238f43469f 100644 --- a/src/core/lib/gprpp/map.h +++ b/src/core/lib/gprpp/map.h @@ -30,6 +30,7 @@ #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/pair.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" namespace grpc_core { struct StringLess { @@ -41,6 +42,13 @@ struct StringLess { } }; +template +struct RefCountedPtrLess { + bool operator()(const RefCountedPtr& p1, const RefCountedPtr& p2) { + return p1.get() < p2.get(); + } +}; + namespace testing { class MapTest; } diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc index 1523ced16d8..7766ee186c6 100644 --- a/src/core/lib/transport/metadata.cc +++ b/src/core/lib/transport/metadata.cc @@ -222,7 +222,12 @@ void grpc_mdctx_global_shutdown() { abort(); } } + // For ASAN builds, we don't want to crash here, because that will + // prevent ASAN from providing leak detection information, which is + // far more useful than this simple assertion. +#ifndef GRPC_ASAN_ENABLED GPR_DEBUG_ASSERT(shard->count == 0); +#endif gpr_free(shard->elems); } } diff --git a/test/core/util/test_lb_policies.cc b/test/core/util/test_lb_policies.cc index 2c1f988d173..041ce1f45a1 100644 --- a/test/core/util/test_lb_policies.cc +++ b/test/core/util/test_lb_policies.cc @@ -117,7 +117,7 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy PickResult Pick(PickArgs args) override { PickResult result = delegate_picker_->Pick(args); if (result.type == PickResult::PICK_COMPLETE && - result.connected_subchannel != nullptr) { + result.subchannel != nullptr) { new (args.call_state->Alloc(sizeof(TrailingMetadataHandler))) TrailingMetadataHandler(&result, cb_, user_data_); } From 431c5306baad10b5623f734d060d9eb40eebd74d Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Thu, 25 Jul 2019 14:48:14 -0700 Subject: [PATCH 0998/1555] Used framework imports within generated stubs where necessary --- src/compiler/objective_c_generator_helpers.h | 12 ++ src/compiler/objective_c_plugin.cc | 48 +++++-- .../project.pbxproj | 64 +++++----- .../InterceptorSample/ViewController.m | 5 + .../examples/InterceptorSample/Podfile | 2 + .../RemoteTestClient/RemoteTest.podspec | 31 ++--- src/objective-c/examples/Sample/Podfile | 2 +- .../Sample/Sample.xcodeproj/project.pbxproj | 102 +++++++++------ .../examples/Sample/Sample/ViewController.m | 5 + .../AppIcon.appiconset/Contents.json | 30 +++++ .../examples/SwiftSample/RemoteTest.podspec | 55 -------- .../SwiftSample.xcodeproj/project.pbxproj | 50 ++++---- .../examples/SwiftSample/messages.proto | 118 ------------------ .../examples/SwiftSample/test.proto | 57 --------- 14 files changed, 228 insertions(+), 353 deletions(-) delete mode 100644 src/objective-c/examples/SwiftSample/RemoteTest.podspec delete mode 100644 src/objective-c/examples/SwiftSample/messages.proto delete mode 100644 src/objective-c/examples/SwiftSample/test.proto diff --git a/src/compiler/objective_c_generator_helpers.h b/src/compiler/objective_c_generator_helpers.h index a284da97f4b..de8f52d802c 100644 --- a/src/compiler/objective_c_generator_helpers.h +++ b/src/compiler/objective_c_generator_helpers.h @@ -19,6 +19,10 @@ #ifndef GRPC_INTERNAL_COMPILER_OBJECTIVE_C_GENERATOR_HELPERS_H #define GRPC_INTERNAL_COMPILER_OBJECTIVE_C_GENERATOR_HELPERS_H +#include +using namespace std; + + #include #include "src/compiler/config.h" #include "src/compiler/generator_helpers.h" @@ -45,6 +49,14 @@ inline ::grpc::string LocalImport(const ::grpc::string& import) { return ::grpc::string("#import \"" + import + "\"\n"); } +inline ::grpc::string FrameworkImport(const ::grpc::string& import, const ::grpc::string& framework) { + // Flattens the directory structure + std::size_t pos = import.rfind("/"); + ::grpc::string filename = import.substr(pos + 1, import.size() - pos); + cerr << filename << endl; + return ::grpc::string("#import <" + framework + "/" + filename + ">\n"); +} + inline ::grpc::string SystemImport(const ::grpc::string& import) { return ::grpc::string("#import <" + import + ">\n"); } diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index 87977095d05..3ac7ea13a96 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -30,6 +30,7 @@ using ::google::protobuf::compiler::objectivec:: IsProtobufLibraryBundledProtoFile; using ::google::protobuf::compiler::objectivec::ProtobufLibraryFrameworkName; using ::grpc_objective_c_generator::LocalImport; +using ::grpc_objective_c_generator::FrameworkImport; using ::grpc_objective_c_generator::PreprocIfElse; using ::grpc_objective_c_generator::PreprocIfNot; using ::grpc_objective_c_generator::SystemImport; @@ -37,11 +38,16 @@ using ::grpc_objective_c_generator::SystemImport; namespace { inline ::grpc::string ImportProtoHeaders( - const grpc::protobuf::FileDescriptor* dep, const char* indent) { + const grpc::protobuf::FileDescriptor* dep, const char* indent, const ::grpc::string &framework) { ::grpc::string header = grpc_objective_c_generator::MessageHeaderName(dep); + // cerr << header << endl; if (!IsProtobufLibraryBundledProtoFile(dep)) { - return indent + LocalImport(header); + if (framework.empty()) { + return indent + LocalImport(header); + } else { + return indent + FrameworkImport(header, framework); + } } ::grpc::string base_name = header; @@ -74,6 +80,15 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { return true; } + ::grpc::string framework; + std::vector<::grpc::string> params_list = grpc_generator::tokenize(parameter, ","); + for (auto param_str = params_list.begin(); param_str != params_list.end(); ++param_str) { + std::vector<::grpc::string> param = grpc_generator::tokenize(*param_str, "="); + if (param[0] == "generate_for_named_framework") { + framework = param[1]; + } + } + static const ::grpc::string kNonNullBegin = "NS_ASSUME_NONNULL_BEGIN\n"; static const ::grpc::string kNonNullEnd = "NS_ASSUME_NONNULL_END\n"; static const ::grpc::string kProtocolOnly = "GPB_GRPC_PROTOCOL_ONLY"; @@ -85,8 +100,13 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { { // Generate .pbrpc.h - - ::grpc::string imports = LocalImport(file_name + ".pbobjc.h"); + + ::grpc::string imports; + if (framework.empty()) { + imports = LocalImport(file_name + ".pbobjc.h"); + } else { + imports = FrameworkImport(file_name + ".pbobjc.h", framework); + } ::grpc::string system_imports = SystemImport("ProtoRPC/ProtoService.h") + SystemImport("ProtoRPC/ProtoRPC.h") + @@ -106,7 +126,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string class_imports; for (int i = 0; i < file->dependency_count(); i++) { - class_imports += ImportProtoHeaders(file->dependency(i), " "); + class_imports += ImportProtoHeaders(file->dependency(i), " ", framework); } ::grpc::string ng_protocols; @@ -141,14 +161,22 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { { // Generate .pbrpc.m - ::grpc::string imports = LocalImport(file_name + ".pbrpc.h") + - LocalImport(file_name + ".pbobjc.h") + - SystemImport("ProtoRPC/ProtoRPC.h") + - SystemImport("RxLibrary/GRXWriter+Immediate.h"); + ::grpc::string imports; + if (framework.empty()) { + imports = LocalImport(file_name + ".pbrpc.h") + + LocalImport(file_name + ".pbobjc.h") + + SystemImport("ProtoRPC/ProtoRPC.h") + + SystemImport("RxLibrary/GRXWriter+Immediate.h"); + } else { + imports = FrameworkImport(file_name + ".pbrpc.h", framework) + + FrameworkImport(file_name + ".pbobjc.h", framework) + + SystemImport("ProtoRPC/ProtoRPC.h") + + SystemImport("RxLibrary/GRXWriter+Immediate.h"); + } ::grpc::string class_imports; for (int i = 0; i < file->dependency_count(); i++) { - class_imports += ImportProtoHeaders(file->dependency(i), ""); + class_imports += ImportProtoHeaders(file->dependency(i), "", framework); } ::grpc::string definitions; diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj b/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj index 840f9760879..b3f9d0500e5 100644 --- a/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 4182FA3FC32428BA5E84C311 /* libPods-InterceptorSample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 48F0BD18AEBB640DE5E58D79 /* libPods-InterceptorSample.a */; }; 5EE960FB2266768A0044A74F /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE960FA2266768A0044A74F /* AppDelegate.m */; }; 5EE960FE2266768A0044A74F /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE960FD2266768A0044A74F /* ViewController.m */; }; 5EE961012266768A0044A74F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5EE960FF2266768A0044A74F /* Main.storyboard */; }; @@ -15,10 +14,11 @@ 5EE961062266768C0044A74F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5EE961042266768C0044A74F /* LaunchScreen.storyboard */; }; 5EE961092266768C0044A74F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE961082266768C0044A74F /* main.m */; }; 5EE9611222668CF20044A74F /* CacheInterceptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE9611122668CF20044A74F /* CacheInterceptor.m */; }; + 9F142CE7AFDA64BD5AEE9849 /* libPods-InterceptorSample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B8FBA9621C9B11B3AC233A96 /* libPods-InterceptorSample.a */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 48F0BD18AEBB640DE5E58D79 /* libPods-InterceptorSample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InterceptorSample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 18F2D91B047D36868BCD504B /* Pods-InterceptorSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InterceptorSample.release.xcconfig"; path = "Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample.release.xcconfig"; sourceTree = ""; }; 5EE960F62266768A0044A74F /* InterceptorSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = InterceptorSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 5EE960FA2266768A0044A74F /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 5EE960FC2266768A0044A74F /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; @@ -31,8 +31,8 @@ 5EE9610F2266774C0044A74F /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 5EE9611022668CE20044A74F /* CacheInterceptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CacheInterceptor.h; sourceTree = ""; }; 5EE9611122668CF20044A74F /* CacheInterceptor.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CacheInterceptor.m; sourceTree = ""; }; - 64B0278876AF54F8F95EDDCE /* Pods-InterceptorSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InterceptorSample.release.xcconfig"; path = "Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample.release.xcconfig"; sourceTree = ""; }; - 6637EF5BBDFE0FFD47D9EAE7 /* Pods-InterceptorSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InterceptorSample.debug.xcconfig"; path = "Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample.debug.xcconfig"; sourceTree = ""; }; + AD256CCFA3FE501D3D876F1D /* Pods-InterceptorSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InterceptorSample.debug.xcconfig"; path = "Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample.debug.xcconfig"; sourceTree = ""; }; + B8FBA9621C9B11B3AC233A96 /* libPods-InterceptorSample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InterceptorSample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -40,7 +40,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 4182FA3FC32428BA5E84C311 /* libPods-InterceptorSample.a in Frameworks */, + 9F142CE7AFDA64BD5AEE9849 /* libPods-InterceptorSample.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -53,7 +53,7 @@ 5EE960F82266768A0044A74F /* InterceptorSample */, 5EE960F72266768A0044A74F /* Products */, 9D49DB75F3BEDAFDE7028B51 /* Pods */, - A48ECC1BD9AFC8D93ECD2467 /* Frameworks */, + B3868CDC20EB754A8D582F03 /* Frameworks */, ); sourceTree = ""; }; @@ -86,16 +86,16 @@ 9D49DB75F3BEDAFDE7028B51 /* Pods */ = { isa = PBXGroup; children = ( - 6637EF5BBDFE0FFD47D9EAE7 /* Pods-InterceptorSample.debug.xcconfig */, - 64B0278876AF54F8F95EDDCE /* Pods-InterceptorSample.release.xcconfig */, + AD256CCFA3FE501D3D876F1D /* Pods-InterceptorSample.debug.xcconfig */, + 18F2D91B047D36868BCD504B /* Pods-InterceptorSample.release.xcconfig */, ); path = Pods; sourceTree = ""; }; - A48ECC1BD9AFC8D93ECD2467 /* Frameworks */ = { + B3868CDC20EB754A8D582F03 /* Frameworks */ = { isa = PBXGroup; children = ( - 48F0BD18AEBB640DE5E58D79 /* libPods-InterceptorSample.a */, + B8FBA9621C9B11B3AC233A96 /* libPods-InterceptorSample.a */, ); name = Frameworks; sourceTree = ""; @@ -107,11 +107,11 @@ isa = PBXNativeTarget; buildConfigurationList = 5EE9610C2266768C0044A74F /* Build configuration list for PBXNativeTarget "InterceptorSample" */; buildPhases = ( - 471EAA5F4DD4F2A125B3488B /* [CP] Check Pods Manifest.lock */, + D31C16F578D4BF95F5638778 /* [CP] Check Pods Manifest.lock */, 5EE960F22266768A0044A74F /* Sources */, 5EE960F32266768A0044A74F /* Frameworks */, 5EE960F42266768A0044A74F /* Resources */, - 77C5553636C977821737C752 /* [CP] Copy Pods Resources */, + 45857CF606BB268EB3BC476F /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -168,7 +168,24 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 471EAA5F4DD4F2A125B3488B /* [CP] Check Pods Manifest.lock */ = { + 45857CF606BB268EB3BC476F /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + D31C16F578D4BF95F5638778 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -190,23 +207,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 77C5553636C977821737C752 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample-resources-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample-resources-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -357,7 +357,7 @@ }; 5EE9610D2266768C0044A74F /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 6637EF5BBDFE0FFD47D9EAE7 /* Pods-InterceptorSample.debug.xcconfig */; + baseConfigurationReference = AD256CCFA3FE501D3D876F1D /* Pods-InterceptorSample.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; @@ -375,7 +375,7 @@ }; 5EE9610E2266768C0044A74F /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 64B0278876AF54F8F95EDDCE /* Pods-InterceptorSample.release.xcconfig */; + baseConfigurationReference = 18F2D91B047D36868BCD504B /* Pods-InterceptorSample.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.m b/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.m index b0e66636028..ac6ce6752d9 100644 --- a/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.m +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.m @@ -19,8 +19,13 @@ #import "ViewController.h" #import +#if USE_FRAMEWORKS +#import +#import +#else #import "src/objective-c/examples/RemoteTestClient/Messages.pbobjc.h" #import "src/objective-c/examples/RemoteTestClient/Test.pbrpc.h" +#endif #import "CacheInterceptor.h" diff --git a/src/objective-c/examples/InterceptorSample/Podfile b/src/objective-c/examples/InterceptorSample/Podfile index b20813d32aa..6df6c962148 100644 --- a/src/objective-c/examples/InterceptorSample/Podfile +++ b/src/objective-c/examples/InterceptorSample/Podfile @@ -2,6 +2,8 @@ platform :ios, '8.0' install! 'cocoapods', :deterministic_uuids => false +use_frameworks! if ENV['FRAMEWORKS'] != 'NO' + ROOT_DIR = '../../../..' target 'InterceptorSample' do diff --git a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec index 5bf1252aed8..fbc37317ba1 100644 --- a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec +++ b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec @@ -20,26 +20,29 @@ Pod::Spec.new do |s| well_known_types_dir = "#{repo_root}/third_party/protobuf/src" plugin = "#{bin_dir}/grpc_objective_c_plugin" - s.prepare_command = <<-CMD - if [ "$FRAMEWORKS" == "" ]; then + if ENV['FRAMEWORKS'] != 'NO' then + s.user_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'USE_FRAMEWORKS=1' } + s.prepare_command = <<-CMD #{protoc} \ --plugin=protoc-gen-grpc=#{plugin} \ --objc_out=. \ - --grpc_out=. \ - -I #{repo_root} \ - -I #{well_known_types_dir} \ - #{repo_root}/src/objective-c/examples/RemoteTestClient/*.proto - else - #{protoc} \ - --plugin=protoc-gen-grpc=#{plugin} \ - --objc_out=. \ - --grpc_out=. \ + --grpc_out=generate_for_named_framework=#{s.name}:. \ --objc_opt=generate_for_named_framework=#{s.name} \ -I #{repo_root} \ -I #{well_known_types_dir} \ #{repo_root}/src/objective-c/examples/RemoteTestClient/*.proto - fi - CMD + CMD + else + s.prepare_command = <<-CMD + #{protoc} \ + --plugin=protoc-gen-grpc=#{plugin} \ + --objc_out=. \ + --grpc_out=. \ + -I #{repo_root} \ + -I #{well_known_types_dir} \ + #{repo_root}/src/objective-c/examples/RemoteTestClient/*.proto + CMD + end s.subspec 'Messages' do |ms| ms.source_files = '**/*.pbobjc.{h,m}' @@ -55,7 +58,7 @@ Pod::Spec.new do |s| ss.dependency 'gRPC-ProtoRPC' ss.dependency "#{s.name}/Messages" end - + s.pod_target_xcconfig = { # This is needed by all pods that depend on Protobuf: 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1', diff --git a/src/objective-c/examples/Sample/Podfile b/src/objective-c/examples/Sample/Podfile index bebd55bd628..741a199602e 100644 --- a/src/objective-c/examples/Sample/Podfile +++ b/src/objective-c/examples/Sample/Podfile @@ -3,7 +3,7 @@ platform :ios, '8.0' install! 'cocoapods', :deterministic_uuids => false -use_frameworks! if ENV['FRAMEWORKS'] == 'YES' +use_frameworks! if ENV['FRAMEWORKS'] != 'NO' # Location of gRPC's repo root relative to this file. GRPC_LOCAL_SRC = '../../../..' diff --git a/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj b/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj index 33bdc378165..43bcac028a1 100644 --- a/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj @@ -12,11 +12,10 @@ 6369A2761A9322E20015FC5C /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6369A2751A9322E20015FC5C /* ViewController.m */; }; 6369A2791A9322E20015FC5C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6369A2771A9322E20015FC5C /* Main.storyboard */; }; 6369A27B1A9322E20015FC5C /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6369A27A1A9322E20015FC5C /* Images.xcassets */; }; - C8B8323DA07AC8C4499DC557 /* libPods-Sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A874B5E91AC811A1EA0D12CF /* libPods-Sample.a */; }; + 81BD5DEB744A906EF0708B68 /* Pods_Sample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6E85B2D77543A74F6CACF59A /* Pods_Sample.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 5A8C9F4B28733B249DE4AB6D /* Pods-Sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.release.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.release.xcconfig"; sourceTree = ""; }; 6369A26A1A9322E20015FC5C /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 6369A26E1A9322E20015FC5C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 6369A26F1A9322E20015FC5C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -26,8 +25,9 @@ 6369A2751A9322E20015FC5C /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 6369A2781A9322E20015FC5C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 6369A27A1A9322E20015FC5C /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; - A874B5E91AC811A1EA0D12CF /* libPods-Sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - E3C01DF315C4E7433BCEC6E6 /* Pods-Sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.debug.xcconfig"; sourceTree = ""; }; + 6E85B2D77543A74F6CACF59A /* Pods_Sample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Sample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 7544F97DDF1CB3F915E41CB9 /* Pods-Sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.debug.xcconfig"; path = "Target Support Files/Pods-Sample/Pods-Sample.debug.xcconfig"; sourceTree = ""; }; + 8BDAC28EF9131C53B2E6870D /* Pods-Sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.release.xcconfig"; path = "Target Support Files/Pods-Sample/Pods-Sample.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -35,20 +35,28 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - C8B8323DA07AC8C4499DC557 /* libPods-Sample.a in Frameworks */, + 81BD5DEB744A906EF0708B68 /* Pods_Sample.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 14C78F05D9C5E2D5F426D233 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 6E85B2D77543A74F6CACF59A /* Pods_Sample.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; 6369A2611A9322E20015FC5C = { isa = PBXGroup; children = ( 6369A26C1A9322E20015FC5C /* Sample */, 6369A26B1A9322E20015FC5C /* Products */, - AB3331C9AE6488E61B2B094E /* Pods */, - C4C2C5219053E079C9EFB930 /* Frameworks */, + 9A3B057E55DE3C4F4A543CC5 /* Pods */, + 14C78F05D9C5E2D5F426D233 /* Frameworks */, ); sourceTree = ""; }; @@ -83,21 +91,13 @@ name = "Supporting Files"; sourceTree = ""; }; - AB3331C9AE6488E61B2B094E /* Pods */ = { + 9A3B057E55DE3C4F4A543CC5 /* Pods */ = { isa = PBXGroup; children = ( - E3C01DF315C4E7433BCEC6E6 /* Pods-Sample.debug.xcconfig */, - 5A8C9F4B28733B249DE4AB6D /* Pods-Sample.release.xcconfig */, + 7544F97DDF1CB3F915E41CB9 /* Pods-Sample.debug.xcconfig */, + 8BDAC28EF9131C53B2E6870D /* Pods-Sample.release.xcconfig */, ); - name = Pods; - sourceTree = ""; - }; - C4C2C5219053E079C9EFB930 /* Frameworks */ = { - isa = PBXGroup; - children = ( - A874B5E91AC811A1EA0D12CF /* libPods-Sample.a */, - ); - name = Frameworks; + path = Pods; sourceTree = ""; }; /* End PBXGroup section */ @@ -107,11 +107,11 @@ isa = PBXNativeTarget; buildConfigurationList = 6369A28D1A9322E20015FC5C /* Build configuration list for PBXNativeTarget "Sample" */; buildPhases = ( - 41F7486D8F66994B0BFB84AF /* [CP] Check Pods Manifest.lock */, + B8CFD95B6470E21429BC7DF0 /* [CP] Check Pods Manifest.lock */, 6369A2661A9322E20015FC5C /* Sources */, 6369A2671A9322E20015FC5C /* Frameworks */, 6369A2681A9322E20015FC5C /* Resources */, - 04554623324BE4A838846086 /* [CP] Copy Pods Resources */, + BFA56A3C239159EE5FFE4D61 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -167,34 +167,20 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 04554623324BE4A838846086 /* [CP] Copy Pods Resources */ = { + B8CFD95B6470E21429BC7DF0 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); - inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Sample/Pods-Sample-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC/gRPCCertificates.bundle", - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Sample/Pods-Sample-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 41F7486D8F66994B0BFB84AF /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( + inputFileListPaths = ( ); inputPaths = ( "${PODS_PODFILE_DIR_PATH}/Podfile.lock", "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); outputPaths = ( "$(DERIVED_FILE_DIR)/Pods-Sample-checkManifestLockResult.txt", ); @@ -203,6 +189,38 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + BFA56A3C239159EE5FFE4D61 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/BoringSSL-GRPC/openssl_grpc.framework", + "${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework", + "${BUILT_PRODUCTS_DIR}/RemoteTest/RemoteTest.framework", + "${BUILT_PRODUCTS_DIR}/gRPC/GRPCClient.framework", + "${BUILT_PRODUCTS_DIR}/gRPC-Core/grpc.framework", + "${BUILT_PRODUCTS_DIR}/gRPC-ProtoRPC/ProtoRPC.framework", + "${BUILT_PRODUCTS_DIR}/gRPC-RxLibrary/RxLibrary.framework", + "${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/openssl_grpc.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RemoteTest.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GRPCClient.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/grpc.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ProtoRPC.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxLibrary.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -311,9 +329,10 @@ }; 6369A28E1A9322E20015FC5C /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = E3C01DF315C4E7433BCEC6E6 /* Pods-Sample.debug.xcconfig */; + baseConfigurationReference = 7544F97DDF1CB3F915E41CB9 /* Pods-Sample.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; INFOPLIST_FILE = Sample/Info.plist; LD_GENERATE_MAP_FILE = YES; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -324,9 +343,10 @@ }; 6369A28F1A9322E20015FC5C /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 5A8C9F4B28733B249DE4AB6D /* Pods-Sample.release.xcconfig */; + baseConfigurationReference = 8BDAC28EF9131C53B2E6870D /* Pods-Sample.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; INFOPLIST_FILE = Sample/Info.plist; LD_GENERATE_MAP_FILE = YES; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; diff --git a/src/objective-c/examples/Sample/Sample/ViewController.m b/src/objective-c/examples/Sample/Sample/ViewController.m index 2171a923d79..e4f3712d72d 100644 --- a/src/objective-c/examples/Sample/Sample/ViewController.m +++ b/src/objective-c/examples/Sample/Sample/ViewController.m @@ -20,8 +20,13 @@ #import #import +#if USE_FRAMEWORKS +#import +#import +#else #import "src/objective-c/examples/RemoteTestClient/Messages.pbobjc.h" #import "src/objective-c/examples/RemoteTestClient/Test.pbrpc.h" +#endif #import #import diff --git a/src/objective-c/examples/SwiftSample/Images.xcassets/AppIcon.appiconset/Contents.json b/src/objective-c/examples/SwiftSample/Images.xcassets/AppIcon.appiconset/Contents.json index 36d2c80d889..d8db8d65fd7 100644 --- a/src/objective-c/examples/SwiftSample/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/src/objective-c/examples/SwiftSample/Images.xcassets/AppIcon.appiconset/Contents.json @@ -1,5 +1,15 @@ { "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "29x29", @@ -30,6 +40,16 @@ "size" : "60x60", "scale" : "3x" }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, { "idiom" : "ipad", "size" : "29x29", @@ -59,6 +79,16 @@ "idiom" : "ipad", "size" : "76x76", "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : { diff --git a/src/objective-c/examples/SwiftSample/RemoteTest.podspec b/src/objective-c/examples/SwiftSample/RemoteTest.podspec deleted file mode 100644 index e5f910c82d0..00000000000 --- a/src/objective-c/examples/SwiftSample/RemoteTest.podspec +++ /dev/null @@ -1,55 +0,0 @@ -Pod::Spec.new do |s| - s.name = 'RemoteTest' - s.version = '0.0.1' - s.license = 'Apache License, Version 2.0' - s.authors = { 'gRPC contributors' => 'grpc-io@googlegroups.com' } - s.homepage = 'https://grpc.io/' - s.summary = 'RemoteTest example' - s.source = { :git => 'https://github.com/grpc/grpc.git' } - - s.ios.deployment_target = '7.1' - s.osx.deployment_target = '10.9' - - # Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients. - s.dependency "!ProtoCompiler-gRPCPlugin" - - repo_root = '../../../..' - bin_dir = "#{repo_root}/bins/$CONFIG" - - protoc = "#{bin_dir}/protobuf/protoc" - well_known_types_dir = "#{repo_root}/third_party/protobuf/src" - plugin = "#{bin_dir}/grpc_objective_c_plugin" - - s.prepare_command = <<-CMD - #{protoc} \ - --plugin=protoc-gen-grpc=#{plugin} \ - --objc_out=. \ - --grpc_out=. \ - -I . \ - -I #{well_known_types_dir} \ - *.proto - CMD - - s.subspec 'Messages' do |ms| - ms.source_files = '**/*.pbobjc.{h,m}' - ms.header_mappings_dir = '.' - ms.requires_arc = false - ms.dependency 'Protobuf' - end - - s.subspec 'Services' do |ss| - ss.source_files = '**/*.pbrpc.{h,m}' - ss.header_mappings_dir = '.' - ss.requires_arc = true - ss.dependency 'gRPC-ProtoRPC' - ss.dependency "#{s.name}/Messages" - end - - s.pod_target_xcconfig = { - # This is needed by all pods that depend on Protobuf: - 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1', - # This is needed by all pods that depend on gRPC-RxLibrary: - 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES', - } - -end diff --git a/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj b/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj index ec8883456e4..953152e6153 100644 --- a/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj @@ -7,23 +7,23 @@ objects = { /* Begin PBXBuildFile section */ - 2A4D33FC1BAD9EE77F27E82F /* Pods_SwiftSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D24BFC7BA3339DF6B9A04EF /* Pods_SwiftSample.framework */; }; 633BFFC81B950B210007E424 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 633BFFC71B950B210007E424 /* AppDelegate.swift */; }; 633BFFCA1B950B210007E424 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 633BFFC91B950B210007E424 /* ViewController.swift */; }; 633BFFCD1B950B210007E424 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 633BFFCB1B950B210007E424 /* Main.storyboard */; }; 633BFFCF1B950B210007E424 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 633BFFCE1B950B210007E424 /* Images.xcassets */; }; + AC669361C16100FA4D34D7D1 /* Pods_SwiftSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5CB8E8B90EEE20DEB124EE37 /* Pods_SwiftSample.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 544DD51C2905B1B0B00F57F3 /* Pods-SwiftSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftSample.debug.xcconfig"; path = "Target Support Files/Pods-SwiftSample/Pods-SwiftSample.debug.xcconfig"; sourceTree = ""; }; + 5CB8E8B90EEE20DEB124EE37 /* Pods_SwiftSample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftSample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 633BFFC21B950B210007E424 /* SwiftSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 633BFFC61B950B210007E424 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 633BFFC71B950B210007E424 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 633BFFC91B950B210007E424 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 633BFFCC1B950B210007E424 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 633BFFCE1B950B210007E424 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; - 7AD632A1760ED763C0BFFD0A /* Pods-SwiftSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftSample.release.xcconfig"; path = "Target Support Files/Pods-SwiftSample/Pods-SwiftSample.release.xcconfig"; sourceTree = ""; }; - 7D24BFC7BA3339DF6B9A04EF /* Pods_SwiftSample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftSample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - D6F1AAEB4FD0559A16605616 /* Pods-SwiftSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftSample.debug.xcconfig"; path = "Target Support Files/Pods-SwiftSample/Pods-SwiftSample.debug.xcconfig"; sourceTree = ""; }; + FAF69508F6AEB00B2D2EB3F2 /* Pods-SwiftSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftSample.release.xcconfig"; path = "Target Support Files/Pods-SwiftSample/Pods-SwiftSample.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -31,30 +31,20 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 2A4D33FC1BAD9EE77F27E82F /* Pods_SwiftSample.framework in Frameworks */, + AC669361C16100FA4D34D7D1 /* Pods_SwiftSample.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 3C394733A73BFFE2995E6DC5 /* Pods */ = { - isa = PBXGroup; - children = ( - D6F1AAEB4FD0559A16605616 /* Pods-SwiftSample.debug.xcconfig */, - 7AD632A1760ED763C0BFFD0A /* Pods-SwiftSample.release.xcconfig */, - ); - name = Pods; - path = Pods; - sourceTree = ""; - }; 633BFFB91B950B210007E424 = { isa = PBXGroup; children = ( 633BFFC41B950B210007E424 /* SwiftSample */, 633BFFC31B950B210007E424 /* Products */, - 3C394733A73BFFE2995E6DC5 /* Pods */, - B3B46435EDEAE7572BF484F5 /* Frameworks */, + B26D8B90A783952E7BE194D9 /* Pods */, + 66C10D7692132083F1F396C6 /* Frameworks */, ); sourceTree = ""; }; @@ -86,14 +76,24 @@ name = "Supporting Files"; sourceTree = ""; }; - B3B46435EDEAE7572BF484F5 /* Frameworks */ = { + 66C10D7692132083F1F396C6 /* Frameworks */ = { isa = PBXGroup; children = ( - 7D24BFC7BA3339DF6B9A04EF /* Pods_SwiftSample.framework */, + 5CB8E8B90EEE20DEB124EE37 /* Pods_SwiftSample.framework */, ); name = Frameworks; sourceTree = ""; }; + B26D8B90A783952E7BE194D9 /* Pods */ = { + isa = PBXGroup; + children = ( + 544DD51C2905B1B0B00F57F3 /* Pods-SwiftSample.debug.xcconfig */, + FAF69508F6AEB00B2D2EB3F2 /* Pods-SwiftSample.release.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -101,11 +101,11 @@ isa = PBXNativeTarget; buildConfigurationList = 633BFFE11B950B210007E424 /* Build configuration list for PBXNativeTarget "SwiftSample" */; buildPhases = ( - 0BCFE5CC859FA15414AF3B5A /* [CP] Check Pods Manifest.lock */, + 405474DAAC9EB5A0055F82FA /* [CP] Check Pods Manifest.lock */, 633BFFBE1B950B210007E424 /* Sources */, 633BFFBF1B950B210007E424 /* Frameworks */, 633BFFC01B950B210007E424 /* Resources */, - 6998570BEA68700C0183464C /* [CP] Embed Pods Frameworks */, + 983E7AC7007F28ADB66E485B /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -162,7 +162,7 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 0BCFE5CC859FA15414AF3B5A /* [CP] Check Pods Manifest.lock */ = { + 405474DAAC9EB5A0055F82FA /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -184,7 +184,7 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 6998570BEA68700C0183464C /* [CP] Embed Pods Frameworks */ = { + 983E7AC7007F28ADB66E485B /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -330,7 +330,7 @@ }; 633BFFE21B950B210007E424 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = D6F1AAEB4FD0559A16605616 /* Pods-SwiftSample.debug.xcconfig */; + baseConfigurationReference = 544DD51C2905B1B0B00F57F3 /* Pods-SwiftSample.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Info.plist; @@ -345,7 +345,7 @@ }; 633BFFE31B950B210007E424 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AD632A1760ED763C0BFFD0A /* Pods-SwiftSample.release.xcconfig */; + baseConfigurationReference = FAF69508F6AEB00B2D2EB3F2 /* Pods-SwiftSample.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Info.plist; diff --git a/src/objective-c/examples/SwiftSample/messages.proto b/src/objective-c/examples/SwiftSample/messages.proto deleted file mode 100644 index 128efd9337e..00000000000 --- a/src/objective-c/examples/SwiftSample/messages.proto +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2015 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Message definitions to be used by integration test service definitions. - -syntax = "proto3"; - -package grpc.testing; - -option objc_class_prefix = "RMT"; - -// The type of payload that should be returned. -enum PayloadType { - // Compressable text format. - COMPRESSABLE = 0; - - // Uncompressable binary format. - UNCOMPRESSABLE = 1; - - // Randomly chosen from all other formats defined in this enum. - RANDOM = 2; -} - -// A block of data, to simply increase gRPC message size. -message Payload { - // The type of data in body. - PayloadType type = 1; - // Primary contents of payload. - bytes body = 2; -} - -// Unary request. -message SimpleRequest { - // Desired payload type in the response from the server. - // If response_type is RANDOM, server randomly chooses one from other formats. - PayloadType response_type = 1; - - // Desired payload size in the response from the server. - // If response_type is COMPRESSABLE, this denotes the size before compression. - int32 response_size = 2; - - // Optional input payload sent along with the request. - Payload payload = 3; - - // Whether SimpleResponse should include username. - bool fill_username = 4; - - // Whether SimpleResponse should include OAuth scope. - bool fill_oauth_scope = 5; -} - -// Unary response, as configured by the request. -message SimpleResponse { - // Payload to increase message size. - Payload payload = 1; - // The user the request came from, for verifying authentication was - // successful when the client expected it. - string username = 2; - // OAuth scope. - string oauth_scope = 3; -} - -// Client-streaming request. -message StreamingInputCallRequest { - // Optional input payload sent along with the request. - Payload payload = 1; - - // Not expecting any payload from the response. -} - -// Client-streaming response. -message StreamingInputCallResponse { - // Aggregated size of payloads received from the client. - int32 aggregated_payload_size = 1; -} - -// Configuration for a particular response. -message ResponseParameters { - // Desired payload sizes in responses from the server. - // If response_type is COMPRESSABLE, this denotes the size before compression. - int32 size = 1; - - // Desired interval between consecutive responses in the response stream in - // microseconds. - int32 interval_us = 2; -} - -// Server-streaming request. -message StreamingOutputCallRequest { - // Desired payload type in the response from the server. - // If response_type is RANDOM, the payload from each response in the stream - // might be of different types. This is to simulate a mixed type of payload - // stream. - PayloadType response_type = 1; - - // Configuration for each expected response message. - repeated ResponseParameters response_parameters = 2; - - // Optional input payload sent along with the request. - Payload payload = 3; -} - -// Server-streaming response, as configured by the request and parameters. -message StreamingOutputCallResponse { - // Payload to increase response size. - Payload payload = 1; -} diff --git a/src/objective-c/examples/SwiftSample/test.proto b/src/objective-c/examples/SwiftSample/test.proto deleted file mode 100644 index c5696043630..00000000000 --- a/src/objective-c/examples/SwiftSample/test.proto +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2015 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// An integration test service that covers all the method signature permutations -// of unary/streaming requests/responses. -syntax = "proto3"; - -import "google/protobuf/empty.proto"; -import "messages.proto"; - -package grpc.testing; - -option objc_class_prefix = "RMT"; - -// A simple service to test the various types of RPCs and experiment with -// performance with various types of payload. -service TestService { - // One empty request followed by one empty response. - rpc EmptyCall(google.protobuf.Empty) returns (google.protobuf.Empty); - - // One request followed by one response. - rpc UnaryCall(SimpleRequest) returns (SimpleResponse); - - // One request followed by a sequence of responses (streamed download). - // The server returns the payload with client desired type and sizes. - rpc StreamingOutputCall(StreamingOutputCallRequest) - returns (stream StreamingOutputCallResponse); - - // A sequence of requests followed by one response (streamed upload). - // The server returns the aggregated size of client payload as the result. - rpc StreamingInputCall(stream StreamingInputCallRequest) - returns (StreamingInputCallResponse); - - // A sequence of requests with each request served by the server immediately. - // As one request could lead to multiple responses, this interface - // demonstrates the idea of full duplexing. - rpc FullDuplexCall(stream StreamingOutputCallRequest) - returns (stream StreamingOutputCallResponse); - - // A sequence of requests followed by a sequence of responses. - // The server buffers all the client requests and then serves them in order. A - // stream of responses are returned to the client when the server starts with - // first request. - rpc HalfDuplexCall(stream StreamingOutputCallRequest) - returns (stream StreamingOutputCallResponse); -} From 7c1081964180add6101925ee7fb7b7dea01f3636 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Thu, 25 Jul 2019 15:31:26 -0700 Subject: [PATCH 0999/1555] Fix comments --- src/core/lib/iomgr/executor/mpmcqueue.cc | 6 +++--- src/core/lib/iomgr/executor/mpmcqueue.h | 8 +++++--- test/core/iomgr/mpmcqueue_test.cc | 9 +++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/core/lib/iomgr/executor/mpmcqueue.cc b/src/core/lib/iomgr/executor/mpmcqueue.cc index 62226450a18..74096a4c5b0 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.cc +++ b/src/core/lib/iomgr/executor/mpmcqueue.cc @@ -81,11 +81,11 @@ InfLenFIFOQueue::InfLenFIFOQueue() { delete_list_ = static_cast(gpr_zalloc(sizeof(Node*) * delete_list_size_)); - Node* new_chunk = AllocateNodes(kDeleteListInitSize); + Node* new_chunk = AllocateNodes(kQueueInitNumNodes); delete_list_[delete_list_count_++] = new_chunk; queue_head_ = queue_tail_ = new_chunk; - new_chunk[0].prev = &new_chunk[1023]; - new_chunk[1023].next = &new_chunk[0]; + new_chunk[0].prev = &new_chunk[kQueueInitNumNodes - 1]; + new_chunk[kQueueInitNumNodes - 1].next = &new_chunk[0]; waiters_.next = &waiters_; waiters_.prev = &waiters_; diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index 0d44b7231d3..ab5c484e094 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -88,7 +88,7 @@ class InfLenFIFOQueue : public MPMCQueueInterface { }; // For test purpose only. Returns number of nodes allocated in queue. - // All allocated nodes will not be free until destruction of queue. + // Any allocated node will be alive until the destruction of the queue. int num_nodes() const { return num_nodes_; } // For test purpose only. Returns the initial number of nodes in queue. @@ -147,8 +147,10 @@ class InfLenFIFOQueue : public MPMCQueueInterface { Mutex mu_; // Protecting lock Waiter waiters_; // Head of waiting thread queue - const int kDeleteListInitSize = 1024; // Initial size for delete list - const int kQueueInitNumNodes = 1024; // Initial number of nodes allocated + // Initial size for delete list + static const int kDeleteListInitSize = 1024; + // Initial number of nodes allocated + static const int kQueueInitNumNodes = 1024; Node** delete_list_ = nullptr; // Keeps track of all allocated array entries // for deleting on destruction diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index 732c43a06f5..9ebc1cc7363 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -127,7 +127,7 @@ static void test_space_efficiency(void) { for (int i = 0; i < queue.init_num_nodes(); ++i) { queue.Put(static_cast(grpc_core::New(i))); } - // List should not have been expanded at this time. + // Queue should not have been expanded at this time. GPR_ASSERT(queue.num_nodes() == queue.init_num_nodes()); for (int i = 0; i < queue.init_num_nodes(); ++i) { WorkItem* item = static_cast(queue.Get()); @@ -138,6 +138,7 @@ static void test_space_efficiency(void) { WorkItem* item = static_cast(queue.Get()); grpc_core::Delete(item); } + // Queue never shrinks even it is empty. GPR_ASSERT(queue.num_nodes() == queue.init_num_nodes()); GPR_ASSERT(queue.count() == 0); // queue empty now @@ -145,20 +146,20 @@ static void test_space_efficiency(void) { queue.Put(static_cast(grpc_core::New(i))); } GPR_ASSERT(queue.count() == queue.init_num_nodes() * 2); - // List should have been expanded once. + // Queue should have been expanded once. GPR_ASSERT(queue.num_nodes() == queue.init_num_nodes() * 2); for (int i = 0; i < queue.init_num_nodes(); ++i) { WorkItem* item = static_cast(queue.Get()); grpc_core::Delete(item); } GPR_ASSERT(queue.count() == queue.init_num_nodes()); - // List will never shrink, should keep same number of node as before. + // Queue will never shrink, should keep same number of node as before. GPR_ASSERT(queue.num_nodes() == queue.init_num_nodes() * 2); for (int i = 0; i < queue.init_num_nodes() + 1; ++i) { queue.Put(static_cast(grpc_core::New(i))); } GPR_ASSERT(queue.count() == queue.init_num_nodes() * 2 + 1); - // List should have been expanded twice. + // Queue should have been expanded twice. GPR_ASSERT(queue.num_nodes() == queue.init_num_nodes() * 4); for (int i = 0; i < queue.init_num_nodes() * 2 + 1; ++i) { WorkItem* item = static_cast(queue.Get()); From f0fb27e8cd4016cefad318fb101bcd3960dad503 Mon Sep 17 00:00:00 2001 From: Hannah Shi Date: Wed, 24 Jul 2019 14:35:39 -0700 Subject: [PATCH 1000/1555] add if statement around PersistentChannelTests. run the tests by default --- src/php/bin/run_tests.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/php/bin/run_tests.sh b/src/php/bin/run_tests.sh index a78dd259e2f..31506c58936 100755 --- a/src/php/bin/run_tests.sh +++ b/src/php/bin/run_tests.sh @@ -25,8 +25,18 @@ export DYLD_LIBRARY_PATH=$root/libs/$CONFIG $(which php) $extension_dir -d max_execution_time=300 $(which phpunit) -v --debug \ --exclude-group persistent_list_bound_tests ../tests/unit_tests -$(which php) $extension_dir -d max_execution_time=300 $(which phpunit) -v --debug \ - ../tests/unit_tests/PersistentChannelTests +for arg in "$@" +do + if [[ "$arg" == "--skip-persistent-channel-tests" ]]; then + SKIP_PERSISTENT_CHANNEL_TESTS=true + break + fi +done + +if [[ "$SKIP_PERSISTENT_CHANNEL_TESTS" != "true" ]]; then + $(which php) $extension_dir -d max_execution_time=300 $(which phpunit) -v --debug \ + ../tests/unit_tests/PersistentChannelTests +fi export ZEND_DONT_UNLOAD_MODULES=1 export USE_ZEND_ALLOC=0 From 9841ed0763546f898cdfaed699317b9ebe778e5a Mon Sep 17 00:00:00 2001 From: Hannah Shi Date: Wed, 24 Jul 2019 13:25:08 -0700 Subject: [PATCH 1001/1555] fix #19721 missing addref in channel::constructor() --- src/php/ext/grpc/channel.c | 1 + src/php/tests/unit_tests/ChannelTest.php | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/php/ext/grpc/channel.c b/src/php/ext/grpc/channel.c index 860d38be34a..8551ba2c196 100644 --- a/src/php/ext/grpc/channel.c +++ b/src/php/ext/grpc/channel.c @@ -330,6 +330,7 @@ PHP_METHOD(Channel, __construct) { 1 TSRMLS_CC); return; } else { + Z_ADDREF(*creds_obj); creds = PHP_GRPC_GET_WRAPPED_OBJECT(wrapped_grpc_channel_credentials, creds_obj); php_grpc_zend_hash_del(array_hash, "credentials", sizeof("credentials")); diff --git a/src/php/tests/unit_tests/ChannelTest.php b/src/php/tests/unit_tests/ChannelTest.php index 583c618d32a..58f96a740b6 100644 --- a/src/php/tests/unit_tests/ChannelTest.php +++ b/src/php/tests/unit_tests/ChannelTest.php @@ -37,6 +37,12 @@ class ChannelTest extends PHPUnit_Framework_TestCase $this->assertSame('Grpc\Channel', get_class($this->channel)); } + public function testConstructorCreateSsl() + { + new Grpc\Channel('localhost:50033', + ['credentials' => \Grpc\ChannelCredentials::createSsl()]); + } + public function testGetConnectivityState() { $this->channel = new Grpc\Channel('localhost:50001', From e76a5dd73cb719aa588e4844cb4f69956b39b89b Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Thu, 25 Jul 2019 14:52:40 -0700 Subject: [PATCH 1002/1555] Fixed clang_format_code --- src/compiler/objective_c_generator_helpers.h | 4 +- src/compiler/objective_c_plugin.cc | 31 +++++----- .../Sample/Sample.xcodeproj/project.pbxproj | 56 +++++++++---------- .../tests/InteropTests/InteropTests.m | 6 +- .../InteropTestsMultipleChannels.m | 2 +- src/objective-c/tests/MacTests/StressTests.m | 6 +- src/objective-c/tests/UnitTests/APIv2Tests.m | 2 +- .../tests/UnitTests/GRPCClientTests.m | 2 +- 8 files changed, 57 insertions(+), 52 deletions(-) diff --git a/src/compiler/objective_c_generator_helpers.h b/src/compiler/objective_c_generator_helpers.h index de8f52d802c..b5262fcdd6f 100644 --- a/src/compiler/objective_c_generator_helpers.h +++ b/src/compiler/objective_c_generator_helpers.h @@ -22,7 +22,6 @@ #include using namespace std; - #include #include "src/compiler/config.h" #include "src/compiler/generator_helpers.h" @@ -49,7 +48,8 @@ inline ::grpc::string LocalImport(const ::grpc::string& import) { return ::grpc::string("#import \"" + import + "\"\n"); } -inline ::grpc::string FrameworkImport(const ::grpc::string& import, const ::grpc::string& framework) { +inline ::grpc::string FrameworkImport(const ::grpc::string& import, + const ::grpc::string& framework) { // Flattens the directory structure std::size_t pos = import.rfind("/"); ::grpc::string filename = import.substr(pos + 1, import.size() - pos); diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index 3ac7ea13a96..4a452a8265c 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -29,8 +29,8 @@ using ::google::protobuf::compiler::objectivec:: IsProtobufLibraryBundledProtoFile; using ::google::protobuf::compiler::objectivec::ProtobufLibraryFrameworkName; -using ::grpc_objective_c_generator::LocalImport; using ::grpc_objective_c_generator::FrameworkImport; +using ::grpc_objective_c_generator::LocalImport; using ::grpc_objective_c_generator::PreprocIfElse; using ::grpc_objective_c_generator::PreprocIfNot; using ::grpc_objective_c_generator::SystemImport; @@ -38,7 +38,8 @@ using ::grpc_objective_c_generator::SystemImport; namespace { inline ::grpc::string ImportProtoHeaders( - const grpc::protobuf::FileDescriptor* dep, const char* indent, const ::grpc::string &framework) { + const grpc::protobuf::FileDescriptor* dep, const char* indent, + const ::grpc::string& framework) { ::grpc::string header = grpc_objective_c_generator::MessageHeaderName(dep); // cerr << header << endl; @@ -81,9 +82,12 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { } ::grpc::string framework; - std::vector<::grpc::string> params_list = grpc_generator::tokenize(parameter, ","); - for (auto param_str = params_list.begin(); param_str != params_list.end(); ++param_str) { - std::vector<::grpc::string> param = grpc_generator::tokenize(*param_str, "="); + std::vector<::grpc::string> params_list = + grpc_generator::tokenize(parameter, ","); + for (auto param_str = params_list.begin(); param_str != params_list.end(); + ++param_str) { + std::vector<::grpc::string> param = + grpc_generator::tokenize(*param_str, "="); if (param[0] == "generate_for_named_framework") { framework = param[1]; } @@ -100,7 +104,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { { // Generate .pbrpc.h - + ::grpc::string imports; if (framework.empty()) { imports = LocalImport(file_name + ".pbobjc.h"); @@ -126,7 +130,8 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string class_imports; for (int i = 0; i < file->dependency_count(); i++) { - class_imports += ImportProtoHeaders(file->dependency(i), " ", framework); + class_imports += + ImportProtoHeaders(file->dependency(i), " ", framework); } ::grpc::string ng_protocols; @@ -164,14 +169,14 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string imports; if (framework.empty()) { imports = LocalImport(file_name + ".pbrpc.h") + - LocalImport(file_name + ".pbobjc.h") + - SystemImport("ProtoRPC/ProtoRPC.h") + - SystemImport("RxLibrary/GRXWriter+Immediate.h"); + LocalImport(file_name + ".pbobjc.h") + + SystemImport("ProtoRPC/ProtoRPC.h") + + SystemImport("RxLibrary/GRXWriter+Immediate.h"); } else { imports = FrameworkImport(file_name + ".pbrpc.h", framework) + - FrameworkImport(file_name + ".pbobjc.h", framework) + - SystemImport("ProtoRPC/ProtoRPC.h") + - SystemImport("RxLibrary/GRXWriter+Immediate.h"); + FrameworkImport(file_name + ".pbobjc.h", framework) + + SystemImport("ProtoRPC/ProtoRPC.h") + + SystemImport("RxLibrary/GRXWriter+Immediate.h"); } ::grpc::string class_imports; diff --git a/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj b/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj index 43bcac028a1..efb4835eb8d 100644 --- a/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj @@ -12,7 +12,7 @@ 6369A2761A9322E20015FC5C /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6369A2751A9322E20015FC5C /* ViewController.m */; }; 6369A2791A9322E20015FC5C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6369A2771A9322E20015FC5C /* Main.storyboard */; }; 6369A27B1A9322E20015FC5C /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6369A27A1A9322E20015FC5C /* Images.xcassets */; }; - 81BD5DEB744A906EF0708B68 /* Pods_Sample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6E85B2D77543A74F6CACF59A /* Pods_Sample.framework */; }; + 983179392696210F31F36D26 /* Pods_Sample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CCD4500A079C9D59E6CC5062 /* Pods_Sample.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -25,9 +25,9 @@ 6369A2751A9322E20015FC5C /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 6369A2781A9322E20015FC5C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 6369A27A1A9322E20015FC5C /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; - 6E85B2D77543A74F6CACF59A /* Pods_Sample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Sample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 7544F97DDF1CB3F915E41CB9 /* Pods-Sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.debug.xcconfig"; path = "Target Support Files/Pods-Sample/Pods-Sample.debug.xcconfig"; sourceTree = ""; }; 8BDAC28EF9131C53B2E6870D /* Pods-Sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.release.xcconfig"; path = "Target Support Files/Pods-Sample/Pods-Sample.release.xcconfig"; sourceTree = ""; }; + CCD4500A079C9D59E6CC5062 /* Pods_Sample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Sample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -35,7 +35,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 81BD5DEB744A906EF0708B68 /* Pods_Sample.framework in Frameworks */, + 983179392696210F31F36D26 /* Pods_Sample.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -45,7 +45,7 @@ 14C78F05D9C5E2D5F426D233 /* Frameworks */ = { isa = PBXGroup; children = ( - 6E85B2D77543A74F6CACF59A /* Pods_Sample.framework */, + CCD4500A079C9D59E6CC5062 /* Pods_Sample.framework */, ); name = Frameworks; sourceTree = ""; @@ -111,7 +111,7 @@ 6369A2661A9322E20015FC5C /* Sources */, 6369A2671A9322E20015FC5C /* Frameworks */, 6369A2681A9322E20015FC5C /* Resources */, - BFA56A3C239159EE5FFE4D61 /* [CP] Embed Pods Frameworks */, + 619CBF6DBB6BFE7F5B5A4777 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -167,29 +167,7 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - B8CFD95B6470E21429BC7DF0 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Sample-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - BFA56A3C239159EE5FFE4D61 /* [CP] Embed Pods Frameworks */ = { + 619CBF6DBB6BFE7F5B5A4777 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -221,6 +199,28 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; + B8CFD95B6470E21429BC7DF0 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Sample-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index ae5651651e0..c13dd1e2b35 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -30,13 +30,13 @@ #import #import #import -#import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" -#import "src/objective-c/tests/RemoteTestClient/Test.pbobjc.h" -#import "src/objective-c/tests/RemoteTestClient/Test.pbrpc.h" #import #import #import #import +#import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" +#import "src/objective-c/tests/RemoteTestClient/Test.pbobjc.h" +#import "src/objective-c/tests/RemoteTestClient/Test.pbrpc.h" #import "../ConfigureCronet.h" #import "InteropTestsBlockCallbacks.h" diff --git a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m index 44bd5ab3924..a2a3e64b1b1 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m +++ b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m @@ -21,10 +21,10 @@ #ifdef GRPC_COMPILE_WITH_CRONET #import #endif +#import #import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" #import "src/objective-c/tests/RemoteTestClient/Test.pbobjc.h" #import "src/objective-c/tests/RemoteTestClient/Test.pbrpc.h" -#import #import "../ConfigureCronet.h" #import "InteropTestsBlockCallbacks.h" diff --git a/src/objective-c/tests/MacTests/StressTests.m b/src/objective-c/tests/MacTests/StressTests.m index 8421d48e108..c7020740eac 100644 --- a/src/objective-c/tests/MacTests/StressTests.m +++ b/src/objective-c/tests/MacTests/StressTests.m @@ -21,13 +21,13 @@ #import #import #import -#import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" -#import "src/objective-c/tests/RemoteTestClient/Test.pbobjc.h" -#import "src/objective-c/tests/RemoteTestClient/Test.pbrpc.h" #import #import #import #import +#import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" +#import "src/objective-c/tests/RemoteTestClient/Test.pbobjc.h" +#import "src/objective-c/tests/RemoteTestClient/Test.pbrpc.h" #define TEST_TIMEOUT 32 diff --git a/src/objective-c/tests/UnitTests/APIv2Tests.m b/src/objective-c/tests/UnitTests/APIv2Tests.m index 99c947e335b..86d4e8b3619 100644 --- a/src/objective-c/tests/UnitTests/APIv2Tests.m +++ b/src/objective-c/tests/UnitTests/APIv2Tests.m @@ -18,8 +18,8 @@ #import #import -#import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" #import +#import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" #include #include diff --git a/src/objective-c/tests/UnitTests/GRPCClientTests.m b/src/objective-c/tests/UnitTests/GRPCClientTests.m index 579f113eada..3d144c33b06 100644 --- a/src/objective-c/tests/UnitTests/GRPCClientTests.m +++ b/src/objective-c/tests/UnitTests/GRPCClientTests.m @@ -26,10 +26,10 @@ #import #import #import -#import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" #import #import #import +#import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" #include From 6b99f47bbfc0137ffea34d47030b1d369e459d23 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Thu, 25 Jul 2019 17:56:16 -0700 Subject: [PATCH 1003/1555] Try modifying kokoro job because Sample's default FRAMEWORK is set to YES now --- tools/run_tests/run_tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index f11927bd5d6..cbcd98700c1 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1066,7 +1066,8 @@ class ObjCLanguage(object): cpu_cost=1e6, environ={ 'SCHEME': 'Sample', - 'EXAMPLE_PATH': 'src/objective-c/examples/Sample' + 'EXAMPLE_PATH': 'src/objective-c/examples/Sample', + 'FRAMEWORKS': 'NO' })) out.append( self.config.job_spec( From 07dc75b5ca5fca2ed44a641b14e8ea91aabb416f Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 25 Jul 2019 20:38:48 -0700 Subject: [PATCH 1004/1555] Fix Frameworks build error --- gRPC.podspec | 12 +++--- src/objective-c/GRPCClient/GRPCCallLegacy.h | 2 +- src/objective-c/GRPCClient/GRPCCallOptions.h | 39 +------------------ src/objective-c/GRPCClient/GRPCTypes.h | 37 ++++++++++++++++++ .../InteropTestsMultipleChannels.m | 1 + templates/gRPC.podspec.template | 12 +++--- 6 files changed, 55 insertions(+), 48 deletions(-) create mode 100644 src/objective-c/GRPCClient/GRPCTypes.h diff --git a/gRPC.podspec b/gRPC.podspec index 9ddbb18d393..19811a01e1f 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -40,7 +40,7 @@ Pod::Spec.new do |s| s.module_name = name s.header_dir = name - s.default_subspec = 'Interface', 'GRPCCore' + s.default_subspec = 'Interface', 'GRPCCore', 'Interface-Legacy' s.pod_target_xcconfig = { # This is needed by all pods that depend on gRPC-RxLibrary: @@ -51,9 +51,11 @@ Pod::Spec.new do |s| s.subspec 'Interface-Legacy' do |ss| ss.header_mappings_dir = 'src/objective-c/GRPCClient' - ss.public_header_files = "src/objective-c/GRPCClient/GRPCCallLegacy.h" + ss.public_header_files = "src/objective-c/GRPCClient/GRPCCallLegacy.h", + "src/objective-c/GRPCClient/GRPCTypes.h" - ss.source_files = "src/objective-c/GRPCClient/GRPCCallLegacy.h" + ss.source_files = "src/objective-c/GRPCClient/GRPCCallLegacy.h", + "src/objective-c/GRPCClient/GRPCTypes.h" end s.subspec 'Interface' do |ss| @@ -64,8 +66,7 @@ Pod::Spec.new do |s| 'src/objective-c/GRPCClient/GRPCCallOptions.h', 'src/objective-c/GRPCClient/GRPCInterceptor.h', 'src/objective-c/GRPCClient/GRPCTransport.h', - 'src/objective-c/GRPCClient/GRPCDispatchable.h', - 'src/objective-c/GRPCClient/internal/*.h' + 'src/objective-c/GRPCClient/GRPCDispatchable.h' ss.source_files = 'src/objective-c/GRPCClient/GRPCCall.h', 'src/objective-c/GRPCClient/GRPCCall.m', @@ -112,6 +113,7 @@ Pod::Spec.new do |s| # Certificates, to be able to establish TLS connections: ss.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } + ss.dependency "#{s.name}/Interface-Legacy", version ss.dependency "#{s.name}/Interface", version ss.dependency 'gRPC-Core', version ss.dependency 'gRPC-RxLibrary', version diff --git a/src/objective-c/GRPCClient/GRPCCallLegacy.h b/src/objective-c/GRPCClient/GRPCCallLegacy.h index e6103498639..51dd7da3440 100644 --- a/src/objective-c/GRPCClient/GRPCCallLegacy.h +++ b/src/objective-c/GRPCClient/GRPCCallLegacy.h @@ -22,7 +22,7 @@ */ #import -#import "GRPCCallOptions.h" +#import "GRPCTypes.h" #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnullability-completeness" diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.h b/src/objective-c/GRPCClient/GRPCCallOptions.h index 80c0244d78d..6adc8aa1776 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.h +++ b/src/objective-c/GRPCClient/GRPCCallOptions.h @@ -18,48 +18,13 @@ #import +#import "GRPCTypes.h" + NS_ASSUME_NONNULL_BEGIN typedef char *GRPCTransportId; @protocol GRPCInterceptorFactory; -/** - * Safety remark of a gRPC method as defined in RFC 2616 Section 9.1 - */ -typedef NS_ENUM(NSUInteger, GRPCCallSafety) { - /** Signal that there is no guarantees on how the call affects the server state. */ - GRPCCallSafetyDefault = 0, - /** Signal that the call is idempotent. gRPC is free to use PUT verb. */ - GRPCCallSafetyIdempotentRequest = 1, - /** - * Signal that the call is cacheable and will not affect server state. gRPC is free to use GET - * verb. - */ - GRPCCallSafetyCacheableRequest = 2, -}; - -// Compression algorithm to be used by a gRPC call -typedef NS_ENUM(NSUInteger, GRPCCompressionAlgorithm) { - GRPCCompressNone = 0, - GRPCCompressDeflate, - GRPCCompressGzip, - GRPCStreamCompressGzip, -}; - -// GRPCCompressAlgorithm is deprecated; use GRPCCompressionAlgorithm -typedef GRPCCompressionAlgorithm GRPCCompressAlgorithm; - -/** The transport to be used by a gRPC call */ -typedef NS_ENUM(NSUInteger, GRPCTransportType) { - GRPCTransportTypeDefault = 0, - /** gRPC internal HTTP/2 stack with BoringSSL */ - GRPCTransportTypeChttp2BoringSSL = 0, - /** Cronet stack */ - GRPCTransportTypeCronet, - /** Insecure channel. FOR TEST ONLY! */ - GRPCTransportTypeInsecure, -}; - /** * Implement this protocol to provide a token to gRPC when a call is initiated. */ diff --git a/src/objective-c/GRPCClient/GRPCTypes.h b/src/objective-c/GRPCClient/GRPCTypes.h new file mode 100644 index 00000000000..45fbe219a91 --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCTypes.h @@ -0,0 +1,37 @@ +/** + * Safety remark of a gRPC method as defined in RFC 2616 Section 9.1 + */ +typedef NS_ENUM(NSUInteger, GRPCCallSafety) { + /** Signal that there is no guarantees on how the call affects the server state. */ + GRPCCallSafetyDefault = 0, + /** Signal that the call is idempotent. gRPC is free to use PUT verb. */ + GRPCCallSafetyIdempotentRequest = 1, + /** + * Signal that the call is cacheable and will not affect server state. gRPC is free to use GET + * verb. + */ + GRPCCallSafetyCacheableRequest = 2, +}; + +// Compression algorithm to be used by a gRPC call +typedef NS_ENUM(NSUInteger, GRPCCompressionAlgorithm) { + GRPCCompressNone = 0, + GRPCCompressDeflate, + GRPCCompressGzip, + GRPCStreamCompressGzip, +}; + +// GRPCCompressAlgorithm is deprecated; use GRPCCompressionAlgorithm +typedef GRPCCompressionAlgorithm GRPCCompressAlgorithm; + +/** The transport to be used by a gRPC call */ +typedef NS_ENUM(NSUInteger, GRPCTransportType) { + GRPCTransportTypeDefault = 0, + /** gRPC internal HTTP/2 stack with BoringSSL */ + GRPCTransportTypeChttp2BoringSSL = 0, + /** Cronet stack */ + GRPCTransportTypeCronet, + /** Insecure channel. FOR TEST ONLY! */ + GRPCTransportTypeInsecure, +}; + diff --git a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m index fef9f2e7ddd..4a3c2b955ac 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m +++ b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m @@ -23,6 +23,7 @@ #import #import #import +#import #import "../ConfigureCronet.h" #import "InteropTestsBlockCallbacks.h" diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index 21cce3c23ee..78e95abdc9e 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -42,7 +42,7 @@ s.module_name = name s.header_dir = name - s.default_subspec = 'Interface', 'GRPCCore' + s.default_subspec = 'Interface', 'GRPCCore', 'Interface-Legacy' s.pod_target_xcconfig = { # This is needed by all pods that depend on gRPC-RxLibrary: @@ -53,9 +53,11 @@ s.subspec 'Interface-Legacy' do |ss| ss.header_mappings_dir = 'src/objective-c/GRPCClient' - ss.public_header_files = "src/objective-c/GRPCClient/GRPCCallLegacy.h" + ss.public_header_files = "src/objective-c/GRPCClient/GRPCCallLegacy.h", + "src/objective-c/GRPCClient/GRPCTypes.h" - ss.source_files = "src/objective-c/GRPCClient/GRPCCallLegacy.h" + ss.source_files = "src/objective-c/GRPCClient/GRPCCallLegacy.h", + "src/objective-c/GRPCClient/GRPCTypes.h" end s.subspec 'Interface' do |ss| @@ -66,8 +68,7 @@ 'src/objective-c/GRPCClient/GRPCCallOptions.h', 'src/objective-c/GRPCClient/GRPCInterceptor.h', 'src/objective-c/GRPCClient/GRPCTransport.h', - 'src/objective-c/GRPCClient/GRPCDispatchable.h', - 'src/objective-c/GRPCClient/internal/*.h' + 'src/objective-c/GRPCClient/GRPCDispatchable.h' ss.source_files = 'src/objective-c/GRPCClient/GRPCCall.h', 'src/objective-c/GRPCClient/GRPCCall.m', @@ -114,6 +115,7 @@ # Certificates, to be able to establish TLS connections: ss.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } + ss.dependency "#{s.name}/Interface-Legacy", version ss.dependency "#{s.name}/Interface", version ss.dependency 'gRPC-Core', version ss.dependency 'gRPC-RxLibrary', version From 7e367da22a137e2e7caeae8342c239a91434ba50 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 26 Jul 2019 09:11:34 -0700 Subject: [PATCH 1005/1555] Added more protos to upb --- BUILD | 15 + build.yaml | 38 + .../upb-generated/grpc/gcp/altscontext.upb.c | 49 ++ .../upb-generated/grpc/gcp/altscontext.upb.h | 126 ++++ .../upb-generated/grpc/gcp/handshaker.upb.c | 209 ++++++ .../upb-generated/grpc/gcp/handshaker.upb.h | 681 ++++++++++++++++++ .../grpc/gcp/transport_security_common.upb.c | 42 ++ .../grpc/gcp/transport_security_common.upb.h | 109 +++ .../upb-generated/grpc/health/v1/health.upb.c | 36 + .../upb-generated/grpc/health/v1/health.upb.h | 84 +++ .../grpc/lb/v1/load_balancer.upb.c | 133 ++++ .../grpc/lb/v1/load_balancer.upb.h | 359 +++++++++ src/proto/grpc/gcp/BUILD | 25 + src/proto/grpc/gcp/altscontext.proto | 50 ++ src/proto/grpc/gcp/handshaker.proto | 234 ++++++ .../grpc/gcp/transport_security_common.proto | 46 ++ src/proto/grpc/lb/v1/BUILD | 9 + tools/codegen/core/gen_upb_api.sh | 78 +- .../generated/sources_and_headers.json | 86 +++ 19 files changed, 2382 insertions(+), 27 deletions(-) create mode 100644 src/core/ext/upb-generated/grpc/gcp/altscontext.upb.c create mode 100644 src/core/ext/upb-generated/grpc/gcp/altscontext.upb.h create mode 100644 src/core/ext/upb-generated/grpc/gcp/handshaker.upb.c create mode 100644 src/core/ext/upb-generated/grpc/gcp/handshaker.upb.h create mode 100644 src/core/ext/upb-generated/grpc/gcp/transport_security_common.upb.c create mode 100644 src/core/ext/upb-generated/grpc/gcp/transport_security_common.upb.h create mode 100644 src/core/ext/upb-generated/grpc/health/v1/health.upb.c create mode 100644 src/core/ext/upb-generated/grpc/health/v1/health.upb.h create mode 100644 src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.c create mode 100644 src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.h create mode 100644 src/proto/grpc/gcp/BUILD create mode 100644 src/proto/grpc/gcp/altscontext.proto create mode 100644 src/proto/grpc/gcp/handshaker.proto create mode 100644 src/proto/grpc/gcp/transport_security_common.proto diff --git a/BUILD b/BUILD index a0823bd9a62..6b51f07b82f 100644 --- a/BUILD +++ b/BUILD @@ -2317,6 +2317,21 @@ grpc_cc_library( tags = ["no_windows"], ) +grpc_upb_proto_library( + name = "grpc_health_upb", + deps = ["//src/proto/grpc/health/v1:health_proto_descriptor"] +) + +grpc_upb_proto_library( + name = "grpc_lb_upb", + deps = ["//src/proto/grpc/lb/v1:load_balancer_proto_descriptor"] +) + +grpc_upb_proto_library( + name = "alts_upb", + deps = ["//src/proto/grpc/gcp:alts_handshaker_proto"] +) + grpc_generate_one_off_targets() filegroup( diff --git a/build.yaml b/build.yaml index 6d44356dc63..f16a8f25d11 100644 --- a/build.yaml +++ b/build.yaml @@ -70,6 +70,15 @@ filegroups: - tsi_interface - tsi - grpc_shadow_boringssl +- name: alts_upb + headers: + - src/core/ext/upb-generated/altscontext.upb.h + - src/core/ext/upb-generated/handshaker.upb.h + - src/core/ext/upb-generated/transport_security_common.upb.h + src: + - src/core/ext/upb-generated/altscontext.upb.c + - src/core/ext/upb-generated/handshaker.upb.c + - src/core/ext/upb-generated/transport_security_common.upb.c - name: alts_util public_headers: - include/grpc/grpc_security.h @@ -111,6 +120,23 @@ filegroups: - test/core/util/cmdline.cc uses: - gpr_base_headers +- name: google_api_upb + headers: + - src/core/ext/upb-generated/google/protobuf/any.upb.h + - src/core/ext/upb-generated/google/protobuf/descriptor.upb.h + - src/core/ext/upb-generated/google/protobuf/duration.upb.h + - src/core/ext/upb-generated/google/protobuf/empty.upb.h + - src/core/ext/upb-generated/google/protobuf/struct.upb.h + - src/core/ext/upb-generated/google/protobuf/timestamp.upb.h + - src/core/ext/upb-generated/google/protobuf/wrappers.upb.h + src: + - src/core/ext/upb-generated/google/protobuf/any.upb.c + - src/core/ext/upb-generated/google/protobuf/descriptor.upb.c + - src/core/ext/upb-generated/google/protobuf/duration.upb.c + - src/core/ext/upb-generated/google/protobuf/empty.upb.c + - src/core/ext/upb-generated/google/protobuf/struct.upb.c + - src/core/ext/upb-generated/google/protobuf/timestamp.upb.c + - src/core/ext/upb-generated/google/protobuf/wrappers.upb.c - name: gpr_base src: - src/core/lib/gpr/alloc.cc @@ -660,6 +686,11 @@ filegroups: plugin: grpc_deadline_filter uses: - grpc_base +- name: grpc_health_upb + headers: + - src/core/ext/upb-generated/grpc/health/v1/health.upb.c + src: + - src/core/ext/upb-generated/grpc/health/v1/health.upb.h - name: grpc_http_filters headers: - src/core/ext/filters/http/client/http_client_filter.h @@ -773,6 +804,13 @@ filegroups: uses: - grpc_base - grpc_client_channel +- name: grpc_lb_upb + headers: + - src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.h + src: + - src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.c + uses: + - google_api_upb - name: grpc_max_age_filter headers: - src/core/ext/filters/max_age/max_age_filter.h diff --git a/src/core/ext/upb-generated/grpc/gcp/altscontext.upb.c b/src/core/ext/upb-generated/grpc/gcp/altscontext.upb.c new file mode 100644 index 00000000000..52477e183dc --- /dev/null +++ b/src/core/ext/upb-generated/grpc/gcp/altscontext.upb.c @@ -0,0 +1,49 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * grpc/gcp/altscontext.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#include +#include "upb/msg.h" +#include "grpc/gcp/altscontext.upb.h" +#include "src/proto/grpc/gcp/transport_security_common.upb.h" + +#include "upb/port_def.inc" + +static const upb_msglayout *const grpc_gcp_AltsContext_submsgs[2] = { + &grpc_gcp_AltsContext_PeerAttributesEntry_msginit, + &grpc_gcp_RpcProtocolVersions_msginit, +}; + +static const upb_msglayout_field grpc_gcp_AltsContext__fields[7] = { + {1, UPB_SIZE(8, 8), 0, 0, 9, 1}, + {2, UPB_SIZE(16, 24), 0, 0, 9, 1}, + {3, UPB_SIZE(0, 0), 0, 0, 14, 1}, + {4, UPB_SIZE(24, 40), 0, 0, 9, 1}, + {5, UPB_SIZE(32, 56), 0, 0, 9, 1}, + {6, UPB_SIZE(40, 72), 0, 1, 11, 1}, + {7, UPB_SIZE(44, 80), 0, 0, 11, 3}, +}; + +const upb_msglayout grpc_gcp_AltsContext_msginit = { + &grpc_gcp_AltsContext_submsgs[0], + &grpc_gcp_AltsContext__fields[0], + UPB_SIZE(48, 96), 7, false, +}; + +static const upb_msglayout_field grpc_gcp_AltsContext_PeerAttributesEntry__fields[2] = { + {1, UPB_SIZE(0, 0), 0, 0, 9, 1}, + {2, UPB_SIZE(8, 16), 0, 0, 9, 1}, +}; + +const upb_msglayout grpc_gcp_AltsContext_PeerAttributesEntry_msginit = { + NULL, + &grpc_gcp_AltsContext_PeerAttributesEntry__fields[0], + UPB_SIZE(16, 32), 2, false, +}; + +#include "upb/port_undef.inc" + diff --git a/src/core/ext/upb-generated/grpc/gcp/altscontext.upb.h b/src/core/ext/upb-generated/grpc/gcp/altscontext.upb.h new file mode 100644 index 00000000000..d9a4d58854d --- /dev/null +++ b/src/core/ext/upb-generated/grpc/gcp/altscontext.upb.h @@ -0,0 +1,126 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * grpc/gcp/altscontext.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#ifndef GRPC_GCP_ALTSCONTEXT_PROTO_UPB_H_ +#define GRPC_GCP_ALTSCONTEXT_PROTO_UPB_H_ + +#include "upb/generated_util.h" +#include "upb/msg.h" +#include "upb/decode.h" +#include "upb/encode.h" + +#include "upb/port_def.inc" + +#ifdef __cplusplus +extern "C" { +#endif + +struct grpc_gcp_AltsContext; +struct grpc_gcp_AltsContext_PeerAttributesEntry; +typedef struct grpc_gcp_AltsContext grpc_gcp_AltsContext; +typedef struct grpc_gcp_AltsContext_PeerAttributesEntry grpc_gcp_AltsContext_PeerAttributesEntry; +extern const upb_msglayout grpc_gcp_AltsContext_msginit; +extern const upb_msglayout grpc_gcp_AltsContext_PeerAttributesEntry_msginit; +struct grpc_gcp_RpcProtocolVersions; +extern const upb_msglayout grpc_gcp_RpcProtocolVersions_msginit; + + +/* grpc.gcp.AltsContext */ + +UPB_INLINE grpc_gcp_AltsContext *grpc_gcp_AltsContext_new(upb_arena *arena) { + return (grpc_gcp_AltsContext *)upb_msg_new(&grpc_gcp_AltsContext_msginit, arena); +} +UPB_INLINE grpc_gcp_AltsContext *grpc_gcp_AltsContext_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_gcp_AltsContext *ret = grpc_gcp_AltsContext_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_gcp_AltsContext_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_gcp_AltsContext_serialize(const grpc_gcp_AltsContext *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_gcp_AltsContext_msginit, arena, len); +} + +UPB_INLINE upb_strview grpc_gcp_AltsContext_application_protocol(const grpc_gcp_AltsContext *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)); } +UPB_INLINE upb_strview grpc_gcp_AltsContext_record_protocol(const grpc_gcp_AltsContext *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(16, 24)); } +UPB_INLINE int32_t grpc_gcp_AltsContext_security_level(const grpc_gcp_AltsContext *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)); } +UPB_INLINE upb_strview grpc_gcp_AltsContext_peer_service_account(const grpc_gcp_AltsContext *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(24, 40)); } +UPB_INLINE upb_strview grpc_gcp_AltsContext_local_service_account(const grpc_gcp_AltsContext *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(32, 56)); } +UPB_INLINE const struct grpc_gcp_RpcProtocolVersions* grpc_gcp_AltsContext_peer_rpc_versions(const grpc_gcp_AltsContext *msg) { return UPB_FIELD_AT(msg, const struct grpc_gcp_RpcProtocolVersions*, UPB_SIZE(40, 72)); } +UPB_INLINE const grpc_gcp_AltsContext_PeerAttributesEntry* const* grpc_gcp_AltsContext_peer_attributes(const grpc_gcp_AltsContext *msg, size_t *len) { return (const grpc_gcp_AltsContext_PeerAttributesEntry* const*)_upb_array_accessor(msg, UPB_SIZE(44, 80), len); } + +UPB_INLINE void grpc_gcp_AltsContext_set_application_protocol(grpc_gcp_AltsContext *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)) = value; +} +UPB_INLINE void grpc_gcp_AltsContext_set_record_protocol(grpc_gcp_AltsContext *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(16, 24)) = value; +} +UPB_INLINE void grpc_gcp_AltsContext_set_security_level(grpc_gcp_AltsContext *msg, int32_t value) { + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE void grpc_gcp_AltsContext_set_peer_service_account(grpc_gcp_AltsContext *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(24, 40)) = value; +} +UPB_INLINE void grpc_gcp_AltsContext_set_local_service_account(grpc_gcp_AltsContext *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(32, 56)) = value; +} +UPB_INLINE void grpc_gcp_AltsContext_set_peer_rpc_versions(grpc_gcp_AltsContext *msg, struct grpc_gcp_RpcProtocolVersions* value) { + UPB_FIELD_AT(msg, struct grpc_gcp_RpcProtocolVersions*, UPB_SIZE(40, 72)) = value; +} +UPB_INLINE struct grpc_gcp_RpcProtocolVersions* grpc_gcp_AltsContext_mutable_peer_rpc_versions(grpc_gcp_AltsContext *msg, upb_arena *arena) { + struct grpc_gcp_RpcProtocolVersions* sub = (struct grpc_gcp_RpcProtocolVersions*)grpc_gcp_AltsContext_peer_rpc_versions(msg); + if (sub == NULL) { + sub = (struct grpc_gcp_RpcProtocolVersions*)upb_msg_new(&grpc_gcp_RpcProtocolVersions_msginit, arena); + if (!sub) return NULL; + grpc_gcp_AltsContext_set_peer_rpc_versions(msg, sub); + } + return sub; +} +UPB_INLINE grpc_gcp_AltsContext_PeerAttributesEntry** grpc_gcp_AltsContext_mutable_peer_attributes(grpc_gcp_AltsContext *msg, size_t *len) { + return (grpc_gcp_AltsContext_PeerAttributesEntry**)_upb_array_mutable_accessor(msg, UPB_SIZE(44, 80), len); +} +UPB_INLINE grpc_gcp_AltsContext_PeerAttributesEntry** grpc_gcp_AltsContext_resize_peer_attributes(grpc_gcp_AltsContext *msg, size_t len, upb_arena *arena) { + return (grpc_gcp_AltsContext_PeerAttributesEntry**)_upb_array_resize_accessor(msg, UPB_SIZE(44, 80), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct grpc_gcp_AltsContext_PeerAttributesEntry* grpc_gcp_AltsContext_add_peer_attributes(grpc_gcp_AltsContext *msg, upb_arena *arena) { + struct grpc_gcp_AltsContext_PeerAttributesEntry* sub = (struct grpc_gcp_AltsContext_PeerAttributesEntry*)upb_msg_new(&grpc_gcp_AltsContext_PeerAttributesEntry_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(44, 80), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} + +/* grpc.gcp.AltsContext.PeerAttributesEntry */ + +UPB_INLINE grpc_gcp_AltsContext_PeerAttributesEntry *grpc_gcp_AltsContext_PeerAttributesEntry_new(upb_arena *arena) { + return (grpc_gcp_AltsContext_PeerAttributesEntry *)upb_msg_new(&grpc_gcp_AltsContext_PeerAttributesEntry_msginit, arena); +} +UPB_INLINE grpc_gcp_AltsContext_PeerAttributesEntry *grpc_gcp_AltsContext_PeerAttributesEntry_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_gcp_AltsContext_PeerAttributesEntry *ret = grpc_gcp_AltsContext_PeerAttributesEntry_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_gcp_AltsContext_PeerAttributesEntry_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_gcp_AltsContext_PeerAttributesEntry_serialize(const grpc_gcp_AltsContext_PeerAttributesEntry *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_gcp_AltsContext_PeerAttributesEntry_msginit, arena, len); +} + +UPB_INLINE upb_strview grpc_gcp_AltsContext_PeerAttributesEntry_key(const grpc_gcp_AltsContext_PeerAttributesEntry *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } +UPB_INLINE upb_strview grpc_gcp_AltsContext_PeerAttributesEntry_value(const grpc_gcp_AltsContext_PeerAttributesEntry *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)); } + +UPB_INLINE void grpc_gcp_AltsContext_PeerAttributesEntry_set_key(grpc_gcp_AltsContext_PeerAttributesEntry *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE void grpc_gcp_AltsContext_PeerAttributesEntry_set_value(grpc_gcp_AltsContext_PeerAttributesEntry *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)) = value; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#include "upb/port_undef.inc" + +#endif /* GRPC_GCP_ALTSCONTEXT_PROTO_UPB_H_ */ diff --git a/src/core/ext/upb-generated/grpc/gcp/handshaker.upb.c b/src/core/ext/upb-generated/grpc/gcp/handshaker.upb.c new file mode 100644 index 00000000000..9e957538323 --- /dev/null +++ b/src/core/ext/upb-generated/grpc/gcp/handshaker.upb.c @@ -0,0 +1,209 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * grpc/gcp/handshaker.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#include +#include "upb/msg.h" +#include "grpc/gcp/handshaker.upb.h" +#include "src/proto/grpc/gcp/transport_security_common.upb.h" + +#include "upb/port_def.inc" + +static const upb_msglayout_field grpc_gcp_Endpoint__fields[3] = { + {1, UPB_SIZE(12, 16), 0, 0, 9, 1}, + {2, UPB_SIZE(8, 8), 0, 0, 5, 1}, + {3, UPB_SIZE(0, 0), 0, 0, 14, 1}, +}; + +const upb_msglayout grpc_gcp_Endpoint_msginit = { + NULL, + &grpc_gcp_Endpoint__fields[0], + UPB_SIZE(24, 32), 3, false, +}; + +static const upb_msglayout *const grpc_gcp_Identity_submsgs[1] = { + &grpc_gcp_Identity_AttributesEntry_msginit, +}; + +static const upb_msglayout_field grpc_gcp_Identity__fields[3] = { + {1, UPB_SIZE(4, 8), UPB_SIZE(-13, -25), 0, 9, 1}, + {2, UPB_SIZE(4, 8), UPB_SIZE(-13, -25), 0, 9, 1}, + {3, UPB_SIZE(0, 0), 0, 0, 11, 3}, +}; + +const upb_msglayout grpc_gcp_Identity_msginit = { + &grpc_gcp_Identity_submsgs[0], + &grpc_gcp_Identity__fields[0], + UPB_SIZE(16, 32), 3, false, +}; + +static const upb_msglayout_field grpc_gcp_Identity_AttributesEntry__fields[2] = { + {1, UPB_SIZE(0, 0), 0, 0, 9, 1}, + {2, UPB_SIZE(8, 16), 0, 0, 9, 1}, +}; + +const upb_msglayout grpc_gcp_Identity_AttributesEntry_msginit = { + NULL, + &grpc_gcp_Identity_AttributesEntry__fields[0], + UPB_SIZE(16, 32), 2, false, +}; + +static const upb_msglayout *const grpc_gcp_StartClientHandshakeReq_submsgs[5] = { + &grpc_gcp_Endpoint_msginit, + &grpc_gcp_Identity_msginit, + &grpc_gcp_RpcProtocolVersions_msginit, +}; + +static const upb_msglayout_field grpc_gcp_StartClientHandshakeReq__fields[9] = { + {1, UPB_SIZE(0, 0), 0, 0, 14, 1}, + {2, UPB_SIZE(32, 56), 0, 0, 9, 3}, + {3, UPB_SIZE(36, 64), 0, 0, 9, 3}, + {4, UPB_SIZE(40, 72), 0, 1, 11, 3}, + {5, UPB_SIZE(16, 24), 0, 1, 11, 1}, + {6, UPB_SIZE(20, 32), 0, 0, 11, 1}, + {7, UPB_SIZE(24, 40), 0, 0, 11, 1}, + {8, UPB_SIZE(8, 8), 0, 0, 9, 1}, + {9, UPB_SIZE(28, 48), 0, 2, 11, 1}, +}; + +const upb_msglayout grpc_gcp_StartClientHandshakeReq_msginit = { + &grpc_gcp_StartClientHandshakeReq_submsgs[0], + &grpc_gcp_StartClientHandshakeReq__fields[0], + UPB_SIZE(48, 80), 9, false, +}; + +static const upb_msglayout *const grpc_gcp_ServerHandshakeParameters_submsgs[1] = { + &grpc_gcp_Identity_msginit, +}; + +static const upb_msglayout_field grpc_gcp_ServerHandshakeParameters__fields[2] = { + {1, UPB_SIZE(0, 0), 0, 0, 9, 3}, + {2, UPB_SIZE(4, 8), 0, 0, 11, 3}, +}; + +const upb_msglayout grpc_gcp_ServerHandshakeParameters_msginit = { + &grpc_gcp_ServerHandshakeParameters_submsgs[0], + &grpc_gcp_ServerHandshakeParameters__fields[0], + UPB_SIZE(8, 16), 2, false, +}; + +static const upb_msglayout *const grpc_gcp_StartServerHandshakeReq_submsgs[4] = { + &grpc_gcp_Endpoint_msginit, + &grpc_gcp_RpcProtocolVersions_msginit, + &grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_msginit, +}; + +static const upb_msglayout_field grpc_gcp_StartServerHandshakeReq__fields[6] = { + {1, UPB_SIZE(20, 40), 0, 0, 9, 3}, + {2, UPB_SIZE(24, 48), 0, 2, 11, 3}, + {3, UPB_SIZE(0, 0), 0, 0, 12, 1}, + {4, UPB_SIZE(8, 16), 0, 0, 11, 1}, + {5, UPB_SIZE(12, 24), 0, 0, 11, 1}, + {6, UPB_SIZE(16, 32), 0, 1, 11, 1}, +}; + +const upb_msglayout grpc_gcp_StartServerHandshakeReq_msginit = { + &grpc_gcp_StartServerHandshakeReq_submsgs[0], + &grpc_gcp_StartServerHandshakeReq__fields[0], + UPB_SIZE(32, 64), 6, false, +}; + +static const upb_msglayout *const grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_submsgs[1] = { + &grpc_gcp_ServerHandshakeParameters_msginit, +}; + +static const upb_msglayout_field grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry__fields[2] = { + {1, UPB_SIZE(0, 0), 0, 0, 5, 1}, + {2, UPB_SIZE(4, 8), 0, 0, 11, 1}, +}; + +const upb_msglayout grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_msginit = { + &grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_submsgs[0], + &grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry__fields[0], + UPB_SIZE(8, 16), 2, false, +}; + +static const upb_msglayout_field grpc_gcp_NextHandshakeMessageReq__fields[1] = { + {1, UPB_SIZE(0, 0), 0, 0, 12, 1}, +}; + +const upb_msglayout grpc_gcp_NextHandshakeMessageReq_msginit = { + NULL, + &grpc_gcp_NextHandshakeMessageReq__fields[0], + UPB_SIZE(8, 16), 1, false, +}; + +static const upb_msglayout *const grpc_gcp_HandshakerReq_submsgs[3] = { + &grpc_gcp_NextHandshakeMessageReq_msginit, + &grpc_gcp_StartClientHandshakeReq_msginit, + &grpc_gcp_StartServerHandshakeReq_msginit, +}; + +static const upb_msglayout_field grpc_gcp_HandshakerReq__fields[3] = { + {1, UPB_SIZE(0, 0), UPB_SIZE(-5, -9), 1, 11, 1}, + {2, UPB_SIZE(0, 0), UPB_SIZE(-5, -9), 2, 11, 1}, + {3, UPB_SIZE(0, 0), UPB_SIZE(-5, -9), 0, 11, 1}, +}; + +const upb_msglayout grpc_gcp_HandshakerReq_msginit = { + &grpc_gcp_HandshakerReq_submsgs[0], + &grpc_gcp_HandshakerReq__fields[0], + UPB_SIZE(8, 16), 3, false, +}; + +static const upb_msglayout *const grpc_gcp_HandshakerResult_submsgs[3] = { + &grpc_gcp_Identity_msginit, + &grpc_gcp_RpcProtocolVersions_msginit, +}; + +static const upb_msglayout_field grpc_gcp_HandshakerResult__fields[7] = { + {1, UPB_SIZE(4, 8), 0, 0, 9, 1}, + {2, UPB_SIZE(12, 24), 0, 0, 9, 1}, + {3, UPB_SIZE(20, 40), 0, 0, 12, 1}, + {4, UPB_SIZE(28, 56), 0, 0, 11, 1}, + {5, UPB_SIZE(32, 64), 0, 0, 11, 1}, + {6, UPB_SIZE(0, 0), 0, 0, 8, 1}, + {7, UPB_SIZE(36, 72), 0, 1, 11, 1}, +}; + +const upb_msglayout grpc_gcp_HandshakerResult_msginit = { + &grpc_gcp_HandshakerResult_submsgs[0], + &grpc_gcp_HandshakerResult__fields[0], + UPB_SIZE(40, 80), 7, false, +}; + +static const upb_msglayout_field grpc_gcp_HandshakerStatus__fields[2] = { + {1, UPB_SIZE(0, 0), 0, 0, 13, 1}, + {2, UPB_SIZE(4, 8), 0, 0, 9, 1}, +}; + +const upb_msglayout grpc_gcp_HandshakerStatus_msginit = { + NULL, + &grpc_gcp_HandshakerStatus__fields[0], + UPB_SIZE(16, 32), 2, false, +}; + +static const upb_msglayout *const grpc_gcp_HandshakerResp_submsgs[2] = { + &grpc_gcp_HandshakerResult_msginit, + &grpc_gcp_HandshakerStatus_msginit, +}; + +static const upb_msglayout_field grpc_gcp_HandshakerResp__fields[4] = { + {1, UPB_SIZE(4, 8), 0, 0, 12, 1}, + {2, UPB_SIZE(0, 0), 0, 0, 13, 1}, + {3, UPB_SIZE(12, 24), 0, 0, 11, 1}, + {4, UPB_SIZE(16, 32), 0, 1, 11, 1}, +}; + +const upb_msglayout grpc_gcp_HandshakerResp_msginit = { + &grpc_gcp_HandshakerResp_submsgs[0], + &grpc_gcp_HandshakerResp__fields[0], + UPB_SIZE(24, 48), 4, false, +}; + +#include "upb/port_undef.inc" + diff --git a/src/core/ext/upb-generated/grpc/gcp/handshaker.upb.h b/src/core/ext/upb-generated/grpc/gcp/handshaker.upb.h new file mode 100644 index 00000000000..97c8d44f45e --- /dev/null +++ b/src/core/ext/upb-generated/grpc/gcp/handshaker.upb.h @@ -0,0 +1,681 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * grpc/gcp/handshaker.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#ifndef GRPC_GCP_HANDSHAKER_PROTO_UPB_H_ +#define GRPC_GCP_HANDSHAKER_PROTO_UPB_H_ + +#include "upb/generated_util.h" +#include "upb/msg.h" +#include "upb/decode.h" +#include "upb/encode.h" + +#include "upb/port_def.inc" + +#ifdef __cplusplus +extern "C" { +#endif + +struct grpc_gcp_Endpoint; +struct grpc_gcp_Identity; +struct grpc_gcp_Identity_AttributesEntry; +struct grpc_gcp_StartClientHandshakeReq; +struct grpc_gcp_ServerHandshakeParameters; +struct grpc_gcp_StartServerHandshakeReq; +struct grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry; +struct grpc_gcp_NextHandshakeMessageReq; +struct grpc_gcp_HandshakerReq; +struct grpc_gcp_HandshakerResult; +struct grpc_gcp_HandshakerStatus; +struct grpc_gcp_HandshakerResp; +typedef struct grpc_gcp_Endpoint grpc_gcp_Endpoint; +typedef struct grpc_gcp_Identity grpc_gcp_Identity; +typedef struct grpc_gcp_Identity_AttributesEntry grpc_gcp_Identity_AttributesEntry; +typedef struct grpc_gcp_StartClientHandshakeReq grpc_gcp_StartClientHandshakeReq; +typedef struct grpc_gcp_ServerHandshakeParameters grpc_gcp_ServerHandshakeParameters; +typedef struct grpc_gcp_StartServerHandshakeReq grpc_gcp_StartServerHandshakeReq; +typedef struct grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry; +typedef struct grpc_gcp_NextHandshakeMessageReq grpc_gcp_NextHandshakeMessageReq; +typedef struct grpc_gcp_HandshakerReq grpc_gcp_HandshakerReq; +typedef struct grpc_gcp_HandshakerResult grpc_gcp_HandshakerResult; +typedef struct grpc_gcp_HandshakerStatus grpc_gcp_HandshakerStatus; +typedef struct grpc_gcp_HandshakerResp grpc_gcp_HandshakerResp; +extern const upb_msglayout grpc_gcp_Endpoint_msginit; +extern const upb_msglayout grpc_gcp_Identity_msginit; +extern const upb_msglayout grpc_gcp_Identity_AttributesEntry_msginit; +extern const upb_msglayout grpc_gcp_StartClientHandshakeReq_msginit; +extern const upb_msglayout grpc_gcp_ServerHandshakeParameters_msginit; +extern const upb_msglayout grpc_gcp_StartServerHandshakeReq_msginit; +extern const upb_msglayout grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_msginit; +extern const upb_msglayout grpc_gcp_NextHandshakeMessageReq_msginit; +extern const upb_msglayout grpc_gcp_HandshakerReq_msginit; +extern const upb_msglayout grpc_gcp_HandshakerResult_msginit; +extern const upb_msglayout grpc_gcp_HandshakerStatus_msginit; +extern const upb_msglayout grpc_gcp_HandshakerResp_msginit; +struct grpc_gcp_RpcProtocolVersions; +extern const upb_msglayout grpc_gcp_RpcProtocolVersions_msginit; + +typedef enum { + grpc_gcp_HANDSHAKE_PROTOCOL_UNSPECIFIED = 0, + grpc_gcp_TLS = 1, + grpc_gcp_ALTS = 2 +} grpc_gcp_HandshakeProtocol; + +typedef enum { + grpc_gcp_NETWORK_PROTOCOL_UNSPECIFIED = 0, + grpc_gcp_TCP = 1, + grpc_gcp_UDP = 2 +} grpc_gcp_NetworkProtocol; + + +/* grpc.gcp.Endpoint */ + +UPB_INLINE grpc_gcp_Endpoint *grpc_gcp_Endpoint_new(upb_arena *arena) { + return (grpc_gcp_Endpoint *)upb_msg_new(&grpc_gcp_Endpoint_msginit, arena); +} +UPB_INLINE grpc_gcp_Endpoint *grpc_gcp_Endpoint_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_gcp_Endpoint *ret = grpc_gcp_Endpoint_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_gcp_Endpoint_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_gcp_Endpoint_serialize(const grpc_gcp_Endpoint *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_gcp_Endpoint_msginit, arena, len); +} + +UPB_INLINE upb_strview grpc_gcp_Endpoint_ip_address(const grpc_gcp_Endpoint *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 16)); } +UPB_INLINE int32_t grpc_gcp_Endpoint_port(const grpc_gcp_Endpoint *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); } +UPB_INLINE int32_t grpc_gcp_Endpoint_protocol(const grpc_gcp_Endpoint *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)); } + +UPB_INLINE void grpc_gcp_Endpoint_set_ip_address(grpc_gcp_Endpoint *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 16)) = value; +} +UPB_INLINE void grpc_gcp_Endpoint_set_port(grpc_gcp_Endpoint *msg, int32_t value) { + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; +} +UPB_INLINE void grpc_gcp_Endpoint_set_protocol(grpc_gcp_Endpoint *msg, int32_t value) { + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)) = value; +} + +/* grpc.gcp.Identity */ + +UPB_INLINE grpc_gcp_Identity *grpc_gcp_Identity_new(upb_arena *arena) { + return (grpc_gcp_Identity *)upb_msg_new(&grpc_gcp_Identity_msginit, arena); +} +UPB_INLINE grpc_gcp_Identity *grpc_gcp_Identity_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_gcp_Identity *ret = grpc_gcp_Identity_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_gcp_Identity_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_gcp_Identity_serialize(const grpc_gcp_Identity *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_gcp_Identity_msginit, arena, len); +} + +typedef enum { + grpc_gcp_Identity_identity_oneof_service_account = 1, + grpc_gcp_Identity_identity_oneof_hostname = 2, + grpc_gcp_Identity_identity_oneof_NOT_SET = 0 +} grpc_gcp_Identity_identity_oneof_oneofcases; +UPB_INLINE grpc_gcp_Identity_identity_oneof_oneofcases grpc_gcp_Identity_identity_oneof_case(const grpc_gcp_Identity* msg) { return (grpc_gcp_Identity_identity_oneof_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(12, 24)); } + +UPB_INLINE bool grpc_gcp_Identity_has_service_account(const grpc_gcp_Identity *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(12, 24), 1); } +UPB_INLINE upb_strview grpc_gcp_Identity_service_account(const grpc_gcp_Identity *msg) { return UPB_READ_ONEOF(msg, upb_strview, UPB_SIZE(4, 8), UPB_SIZE(12, 24), 1, upb_strview_make("", strlen(""))); } +UPB_INLINE bool grpc_gcp_Identity_has_hostname(const grpc_gcp_Identity *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(12, 24), 2); } +UPB_INLINE upb_strview grpc_gcp_Identity_hostname(const grpc_gcp_Identity *msg) { return UPB_READ_ONEOF(msg, upb_strview, UPB_SIZE(4, 8), UPB_SIZE(12, 24), 2, upb_strview_make("", strlen(""))); } +UPB_INLINE const grpc_gcp_Identity_AttributesEntry* const* grpc_gcp_Identity_attributes(const grpc_gcp_Identity *msg, size_t *len) { return (const grpc_gcp_Identity_AttributesEntry* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); } + +UPB_INLINE void grpc_gcp_Identity_set_service_account(grpc_gcp_Identity *msg, upb_strview value) { + UPB_WRITE_ONEOF(msg, upb_strview, UPB_SIZE(4, 8), value, UPB_SIZE(12, 24), 1); +} +UPB_INLINE void grpc_gcp_Identity_set_hostname(grpc_gcp_Identity *msg, upb_strview value) { + UPB_WRITE_ONEOF(msg, upb_strview, UPB_SIZE(4, 8), value, UPB_SIZE(12, 24), 2); +} +UPB_INLINE grpc_gcp_Identity_AttributesEntry** grpc_gcp_Identity_mutable_attributes(grpc_gcp_Identity *msg, size_t *len) { + return (grpc_gcp_Identity_AttributesEntry**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len); +} +UPB_INLINE grpc_gcp_Identity_AttributesEntry** grpc_gcp_Identity_resize_attributes(grpc_gcp_Identity *msg, size_t len, upb_arena *arena) { + return (grpc_gcp_Identity_AttributesEntry**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct grpc_gcp_Identity_AttributesEntry* grpc_gcp_Identity_add_attributes(grpc_gcp_Identity *msg, upb_arena *arena) { + struct grpc_gcp_Identity_AttributesEntry* sub = (struct grpc_gcp_Identity_AttributesEntry*)upb_msg_new(&grpc_gcp_Identity_AttributesEntry_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} + +/* grpc.gcp.Identity.AttributesEntry */ + +UPB_INLINE grpc_gcp_Identity_AttributesEntry *grpc_gcp_Identity_AttributesEntry_new(upb_arena *arena) { + return (grpc_gcp_Identity_AttributesEntry *)upb_msg_new(&grpc_gcp_Identity_AttributesEntry_msginit, arena); +} +UPB_INLINE grpc_gcp_Identity_AttributesEntry *grpc_gcp_Identity_AttributesEntry_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_gcp_Identity_AttributesEntry *ret = grpc_gcp_Identity_AttributesEntry_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_gcp_Identity_AttributesEntry_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_gcp_Identity_AttributesEntry_serialize(const grpc_gcp_Identity_AttributesEntry *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_gcp_Identity_AttributesEntry_msginit, arena, len); +} + +UPB_INLINE upb_strview grpc_gcp_Identity_AttributesEntry_key(const grpc_gcp_Identity_AttributesEntry *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } +UPB_INLINE upb_strview grpc_gcp_Identity_AttributesEntry_value(const grpc_gcp_Identity_AttributesEntry *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)); } + +UPB_INLINE void grpc_gcp_Identity_AttributesEntry_set_key(grpc_gcp_Identity_AttributesEntry *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE void grpc_gcp_Identity_AttributesEntry_set_value(grpc_gcp_Identity_AttributesEntry *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 16)) = value; +} + +/* grpc.gcp.StartClientHandshakeReq */ + +UPB_INLINE grpc_gcp_StartClientHandshakeReq *grpc_gcp_StartClientHandshakeReq_new(upb_arena *arena) { + return (grpc_gcp_StartClientHandshakeReq *)upb_msg_new(&grpc_gcp_StartClientHandshakeReq_msginit, arena); +} +UPB_INLINE grpc_gcp_StartClientHandshakeReq *grpc_gcp_StartClientHandshakeReq_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_gcp_StartClientHandshakeReq *ret = grpc_gcp_StartClientHandshakeReq_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_gcp_StartClientHandshakeReq_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_gcp_StartClientHandshakeReq_serialize(const grpc_gcp_StartClientHandshakeReq *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_gcp_StartClientHandshakeReq_msginit, arena, len); +} + +UPB_INLINE int32_t grpc_gcp_StartClientHandshakeReq_handshake_security_protocol(const grpc_gcp_StartClientHandshakeReq *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)); } +UPB_INLINE upb_strview const* grpc_gcp_StartClientHandshakeReq_application_protocols(const grpc_gcp_StartClientHandshakeReq *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(32, 56), len); } +UPB_INLINE upb_strview const* grpc_gcp_StartClientHandshakeReq_record_protocols(const grpc_gcp_StartClientHandshakeReq *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(36, 64), len); } +UPB_INLINE const grpc_gcp_Identity* const* grpc_gcp_StartClientHandshakeReq_target_identities(const grpc_gcp_StartClientHandshakeReq *msg, size_t *len) { return (const grpc_gcp_Identity* const*)_upb_array_accessor(msg, UPB_SIZE(40, 72), len); } +UPB_INLINE const grpc_gcp_Identity* grpc_gcp_StartClientHandshakeReq_local_identity(const grpc_gcp_StartClientHandshakeReq *msg) { return UPB_FIELD_AT(msg, const grpc_gcp_Identity*, UPB_SIZE(16, 24)); } +UPB_INLINE const grpc_gcp_Endpoint* grpc_gcp_StartClientHandshakeReq_local_endpoint(const grpc_gcp_StartClientHandshakeReq *msg) { return UPB_FIELD_AT(msg, const grpc_gcp_Endpoint*, UPB_SIZE(20, 32)); } +UPB_INLINE const grpc_gcp_Endpoint* grpc_gcp_StartClientHandshakeReq_remote_endpoint(const grpc_gcp_StartClientHandshakeReq *msg) { return UPB_FIELD_AT(msg, const grpc_gcp_Endpoint*, UPB_SIZE(24, 40)); } +UPB_INLINE upb_strview grpc_gcp_StartClientHandshakeReq_target_name(const grpc_gcp_StartClientHandshakeReq *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)); } +UPB_INLINE const struct grpc_gcp_RpcProtocolVersions* grpc_gcp_StartClientHandshakeReq_rpc_versions(const grpc_gcp_StartClientHandshakeReq *msg) { return UPB_FIELD_AT(msg, const struct grpc_gcp_RpcProtocolVersions*, UPB_SIZE(28, 48)); } + +UPB_INLINE void grpc_gcp_StartClientHandshakeReq_set_handshake_security_protocol(grpc_gcp_StartClientHandshakeReq *msg, int32_t value) { + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE upb_strview* grpc_gcp_StartClientHandshakeReq_mutable_application_protocols(grpc_gcp_StartClientHandshakeReq *msg, size_t *len) { + return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(32, 56), len); +} +UPB_INLINE upb_strview* grpc_gcp_StartClientHandshakeReq_resize_application_protocols(grpc_gcp_StartClientHandshakeReq *msg, size_t len, upb_arena *arena) { + return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(32, 56), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); +} +UPB_INLINE bool grpc_gcp_StartClientHandshakeReq_add_application_protocols(grpc_gcp_StartClientHandshakeReq *msg, upb_strview val, upb_arena *arena) { + return _upb_array_append_accessor( + msg, UPB_SIZE(32, 56), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); +} +UPB_INLINE upb_strview* grpc_gcp_StartClientHandshakeReq_mutable_record_protocols(grpc_gcp_StartClientHandshakeReq *msg, size_t *len) { + return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(36, 64), len); +} +UPB_INLINE upb_strview* grpc_gcp_StartClientHandshakeReq_resize_record_protocols(grpc_gcp_StartClientHandshakeReq *msg, size_t len, upb_arena *arena) { + return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(36, 64), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); +} +UPB_INLINE bool grpc_gcp_StartClientHandshakeReq_add_record_protocols(grpc_gcp_StartClientHandshakeReq *msg, upb_strview val, upb_arena *arena) { + return _upb_array_append_accessor( + msg, UPB_SIZE(36, 64), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); +} +UPB_INLINE grpc_gcp_Identity** grpc_gcp_StartClientHandshakeReq_mutable_target_identities(grpc_gcp_StartClientHandshakeReq *msg, size_t *len) { + return (grpc_gcp_Identity**)_upb_array_mutable_accessor(msg, UPB_SIZE(40, 72), len); +} +UPB_INLINE grpc_gcp_Identity** grpc_gcp_StartClientHandshakeReq_resize_target_identities(grpc_gcp_StartClientHandshakeReq *msg, size_t len, upb_arena *arena) { + return (grpc_gcp_Identity**)_upb_array_resize_accessor(msg, UPB_SIZE(40, 72), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct grpc_gcp_Identity* grpc_gcp_StartClientHandshakeReq_add_target_identities(grpc_gcp_StartClientHandshakeReq *msg, upb_arena *arena) { + struct grpc_gcp_Identity* sub = (struct grpc_gcp_Identity*)upb_msg_new(&grpc_gcp_Identity_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(40, 72), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} +UPB_INLINE void grpc_gcp_StartClientHandshakeReq_set_local_identity(grpc_gcp_StartClientHandshakeReq *msg, grpc_gcp_Identity* value) { + UPB_FIELD_AT(msg, grpc_gcp_Identity*, UPB_SIZE(16, 24)) = value; +} +UPB_INLINE struct grpc_gcp_Identity* grpc_gcp_StartClientHandshakeReq_mutable_local_identity(grpc_gcp_StartClientHandshakeReq *msg, upb_arena *arena) { + struct grpc_gcp_Identity* sub = (struct grpc_gcp_Identity*)grpc_gcp_StartClientHandshakeReq_local_identity(msg); + if (sub == NULL) { + sub = (struct grpc_gcp_Identity*)upb_msg_new(&grpc_gcp_Identity_msginit, arena); + if (!sub) return NULL; + grpc_gcp_StartClientHandshakeReq_set_local_identity(msg, sub); + } + return sub; +} +UPB_INLINE void grpc_gcp_StartClientHandshakeReq_set_local_endpoint(grpc_gcp_StartClientHandshakeReq *msg, grpc_gcp_Endpoint* value) { + UPB_FIELD_AT(msg, grpc_gcp_Endpoint*, UPB_SIZE(20, 32)) = value; +} +UPB_INLINE struct grpc_gcp_Endpoint* grpc_gcp_StartClientHandshakeReq_mutable_local_endpoint(grpc_gcp_StartClientHandshakeReq *msg, upb_arena *arena) { + struct grpc_gcp_Endpoint* sub = (struct grpc_gcp_Endpoint*)grpc_gcp_StartClientHandshakeReq_local_endpoint(msg); + if (sub == NULL) { + sub = (struct grpc_gcp_Endpoint*)upb_msg_new(&grpc_gcp_Endpoint_msginit, arena); + if (!sub) return NULL; + grpc_gcp_StartClientHandshakeReq_set_local_endpoint(msg, sub); + } + return sub; +} +UPB_INLINE void grpc_gcp_StartClientHandshakeReq_set_remote_endpoint(grpc_gcp_StartClientHandshakeReq *msg, grpc_gcp_Endpoint* value) { + UPB_FIELD_AT(msg, grpc_gcp_Endpoint*, UPB_SIZE(24, 40)) = value; +} +UPB_INLINE struct grpc_gcp_Endpoint* grpc_gcp_StartClientHandshakeReq_mutable_remote_endpoint(grpc_gcp_StartClientHandshakeReq *msg, upb_arena *arena) { + struct grpc_gcp_Endpoint* sub = (struct grpc_gcp_Endpoint*)grpc_gcp_StartClientHandshakeReq_remote_endpoint(msg); + if (sub == NULL) { + sub = (struct grpc_gcp_Endpoint*)upb_msg_new(&grpc_gcp_Endpoint_msginit, arena); + if (!sub) return NULL; + grpc_gcp_StartClientHandshakeReq_set_remote_endpoint(msg, sub); + } + return sub; +} +UPB_INLINE void grpc_gcp_StartClientHandshakeReq_set_target_name(grpc_gcp_StartClientHandshakeReq *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)) = value; +} +UPB_INLINE void grpc_gcp_StartClientHandshakeReq_set_rpc_versions(grpc_gcp_StartClientHandshakeReq *msg, struct grpc_gcp_RpcProtocolVersions* value) { + UPB_FIELD_AT(msg, struct grpc_gcp_RpcProtocolVersions*, UPB_SIZE(28, 48)) = value; +} +UPB_INLINE struct grpc_gcp_RpcProtocolVersions* grpc_gcp_StartClientHandshakeReq_mutable_rpc_versions(grpc_gcp_StartClientHandshakeReq *msg, upb_arena *arena) { + struct grpc_gcp_RpcProtocolVersions* sub = (struct grpc_gcp_RpcProtocolVersions*)grpc_gcp_StartClientHandshakeReq_rpc_versions(msg); + if (sub == NULL) { + sub = (struct grpc_gcp_RpcProtocolVersions*)upb_msg_new(&grpc_gcp_RpcProtocolVersions_msginit, arena); + if (!sub) return NULL; + grpc_gcp_StartClientHandshakeReq_set_rpc_versions(msg, sub); + } + return sub; +} + +/* grpc.gcp.ServerHandshakeParameters */ + +UPB_INLINE grpc_gcp_ServerHandshakeParameters *grpc_gcp_ServerHandshakeParameters_new(upb_arena *arena) { + return (grpc_gcp_ServerHandshakeParameters *)upb_msg_new(&grpc_gcp_ServerHandshakeParameters_msginit, arena); +} +UPB_INLINE grpc_gcp_ServerHandshakeParameters *grpc_gcp_ServerHandshakeParameters_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_gcp_ServerHandshakeParameters *ret = grpc_gcp_ServerHandshakeParameters_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_gcp_ServerHandshakeParameters_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_gcp_ServerHandshakeParameters_serialize(const grpc_gcp_ServerHandshakeParameters *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_gcp_ServerHandshakeParameters_msginit, arena, len); +} + +UPB_INLINE upb_strview const* grpc_gcp_ServerHandshakeParameters_record_protocols(const grpc_gcp_ServerHandshakeParameters *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); } +UPB_INLINE const grpc_gcp_Identity* const* grpc_gcp_ServerHandshakeParameters_local_identities(const grpc_gcp_ServerHandshakeParameters *msg, size_t *len) { return (const grpc_gcp_Identity* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); } + +UPB_INLINE upb_strview* grpc_gcp_ServerHandshakeParameters_mutable_record_protocols(grpc_gcp_ServerHandshakeParameters *msg, size_t *len) { + return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len); +} +UPB_INLINE upb_strview* grpc_gcp_ServerHandshakeParameters_resize_record_protocols(grpc_gcp_ServerHandshakeParameters *msg, size_t len, upb_arena *arena) { + return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); +} +UPB_INLINE bool grpc_gcp_ServerHandshakeParameters_add_record_protocols(grpc_gcp_ServerHandshakeParameters *msg, upb_strview val, upb_arena *arena) { + return _upb_array_append_accessor( + msg, UPB_SIZE(0, 0), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); +} +UPB_INLINE grpc_gcp_Identity** grpc_gcp_ServerHandshakeParameters_mutable_local_identities(grpc_gcp_ServerHandshakeParameters *msg, size_t *len) { + return (grpc_gcp_Identity**)_upb_array_mutable_accessor(msg, UPB_SIZE(4, 8), len); +} +UPB_INLINE grpc_gcp_Identity** grpc_gcp_ServerHandshakeParameters_resize_local_identities(grpc_gcp_ServerHandshakeParameters *msg, size_t len, upb_arena *arena) { + return (grpc_gcp_Identity**)_upb_array_resize_accessor(msg, UPB_SIZE(4, 8), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct grpc_gcp_Identity* grpc_gcp_ServerHandshakeParameters_add_local_identities(grpc_gcp_ServerHandshakeParameters *msg, upb_arena *arena) { + struct grpc_gcp_Identity* sub = (struct grpc_gcp_Identity*)upb_msg_new(&grpc_gcp_Identity_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(4, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} + +/* grpc.gcp.StartServerHandshakeReq */ + +UPB_INLINE grpc_gcp_StartServerHandshakeReq *grpc_gcp_StartServerHandshakeReq_new(upb_arena *arena) { + return (grpc_gcp_StartServerHandshakeReq *)upb_msg_new(&grpc_gcp_StartServerHandshakeReq_msginit, arena); +} +UPB_INLINE grpc_gcp_StartServerHandshakeReq *grpc_gcp_StartServerHandshakeReq_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_gcp_StartServerHandshakeReq *ret = grpc_gcp_StartServerHandshakeReq_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_gcp_StartServerHandshakeReq_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_gcp_StartServerHandshakeReq_serialize(const grpc_gcp_StartServerHandshakeReq *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_gcp_StartServerHandshakeReq_msginit, arena, len); +} + +UPB_INLINE upb_strview const* grpc_gcp_StartServerHandshakeReq_application_protocols(const grpc_gcp_StartServerHandshakeReq *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len); } +UPB_INLINE const grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry* const* grpc_gcp_StartServerHandshakeReq_handshake_parameters(const grpc_gcp_StartServerHandshakeReq *msg, size_t *len) { return (const grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry* const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len); } +UPB_INLINE upb_strview grpc_gcp_StartServerHandshakeReq_in_bytes(const grpc_gcp_StartServerHandshakeReq *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } +UPB_INLINE const grpc_gcp_Endpoint* grpc_gcp_StartServerHandshakeReq_local_endpoint(const grpc_gcp_StartServerHandshakeReq *msg) { return UPB_FIELD_AT(msg, const grpc_gcp_Endpoint*, UPB_SIZE(8, 16)); } +UPB_INLINE const grpc_gcp_Endpoint* grpc_gcp_StartServerHandshakeReq_remote_endpoint(const grpc_gcp_StartServerHandshakeReq *msg) { return UPB_FIELD_AT(msg, const grpc_gcp_Endpoint*, UPB_SIZE(12, 24)); } +UPB_INLINE const struct grpc_gcp_RpcProtocolVersions* grpc_gcp_StartServerHandshakeReq_rpc_versions(const grpc_gcp_StartServerHandshakeReq *msg) { return UPB_FIELD_AT(msg, const struct grpc_gcp_RpcProtocolVersions*, UPB_SIZE(16, 32)); } + +UPB_INLINE upb_strview* grpc_gcp_StartServerHandshakeReq_mutable_application_protocols(grpc_gcp_StartServerHandshakeReq *msg, size_t *len) { + return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 40), len); +} +UPB_INLINE upb_strview* grpc_gcp_StartServerHandshakeReq_resize_application_protocols(grpc_gcp_StartServerHandshakeReq *msg, size_t len, upb_arena *arena) { + return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(20, 40), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); +} +UPB_INLINE bool grpc_gcp_StartServerHandshakeReq_add_application_protocols(grpc_gcp_StartServerHandshakeReq *msg, upb_strview val, upb_arena *arena) { + return _upb_array_append_accessor( + msg, UPB_SIZE(20, 40), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); +} +UPB_INLINE grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry** grpc_gcp_StartServerHandshakeReq_mutable_handshake_parameters(grpc_gcp_StartServerHandshakeReq *msg, size_t *len) { + return (grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry**)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 48), len); +} +UPB_INLINE grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry** grpc_gcp_StartServerHandshakeReq_resize_handshake_parameters(grpc_gcp_StartServerHandshakeReq *msg, size_t len, upb_arena *arena) { + return (grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry**)_upb_array_resize_accessor(msg, UPB_SIZE(24, 48), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry* grpc_gcp_StartServerHandshakeReq_add_handshake_parameters(grpc_gcp_StartServerHandshakeReq *msg, upb_arena *arena) { + struct grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry* sub = (struct grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry*)upb_msg_new(&grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(24, 48), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} +UPB_INLINE void grpc_gcp_StartServerHandshakeReq_set_in_bytes(grpc_gcp_StartServerHandshakeReq *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE void grpc_gcp_StartServerHandshakeReq_set_local_endpoint(grpc_gcp_StartServerHandshakeReq *msg, grpc_gcp_Endpoint* value) { + UPB_FIELD_AT(msg, grpc_gcp_Endpoint*, UPB_SIZE(8, 16)) = value; +} +UPB_INLINE struct grpc_gcp_Endpoint* grpc_gcp_StartServerHandshakeReq_mutable_local_endpoint(grpc_gcp_StartServerHandshakeReq *msg, upb_arena *arena) { + struct grpc_gcp_Endpoint* sub = (struct grpc_gcp_Endpoint*)grpc_gcp_StartServerHandshakeReq_local_endpoint(msg); + if (sub == NULL) { + sub = (struct grpc_gcp_Endpoint*)upb_msg_new(&grpc_gcp_Endpoint_msginit, arena); + if (!sub) return NULL; + grpc_gcp_StartServerHandshakeReq_set_local_endpoint(msg, sub); + } + return sub; +} +UPB_INLINE void grpc_gcp_StartServerHandshakeReq_set_remote_endpoint(grpc_gcp_StartServerHandshakeReq *msg, grpc_gcp_Endpoint* value) { + UPB_FIELD_AT(msg, grpc_gcp_Endpoint*, UPB_SIZE(12, 24)) = value; +} +UPB_INLINE struct grpc_gcp_Endpoint* grpc_gcp_StartServerHandshakeReq_mutable_remote_endpoint(grpc_gcp_StartServerHandshakeReq *msg, upb_arena *arena) { + struct grpc_gcp_Endpoint* sub = (struct grpc_gcp_Endpoint*)grpc_gcp_StartServerHandshakeReq_remote_endpoint(msg); + if (sub == NULL) { + sub = (struct grpc_gcp_Endpoint*)upb_msg_new(&grpc_gcp_Endpoint_msginit, arena); + if (!sub) return NULL; + grpc_gcp_StartServerHandshakeReq_set_remote_endpoint(msg, sub); + } + return sub; +} +UPB_INLINE void grpc_gcp_StartServerHandshakeReq_set_rpc_versions(grpc_gcp_StartServerHandshakeReq *msg, struct grpc_gcp_RpcProtocolVersions* value) { + UPB_FIELD_AT(msg, struct grpc_gcp_RpcProtocolVersions*, UPB_SIZE(16, 32)) = value; +} +UPB_INLINE struct grpc_gcp_RpcProtocolVersions* grpc_gcp_StartServerHandshakeReq_mutable_rpc_versions(grpc_gcp_StartServerHandshakeReq *msg, upb_arena *arena) { + struct grpc_gcp_RpcProtocolVersions* sub = (struct grpc_gcp_RpcProtocolVersions*)grpc_gcp_StartServerHandshakeReq_rpc_versions(msg); + if (sub == NULL) { + sub = (struct grpc_gcp_RpcProtocolVersions*)upb_msg_new(&grpc_gcp_RpcProtocolVersions_msginit, arena); + if (!sub) return NULL; + grpc_gcp_StartServerHandshakeReq_set_rpc_versions(msg, sub); + } + return sub; +} + +/* grpc.gcp.StartServerHandshakeReq.HandshakeParametersEntry */ + +UPB_INLINE grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry *grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_new(upb_arena *arena) { + return (grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry *)upb_msg_new(&grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_msginit, arena); +} +UPB_INLINE grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry *grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry *ret = grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_serialize(const grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_msginit, arena, len); +} + +UPB_INLINE int32_t grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_key(const grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)); } +UPB_INLINE const grpc_gcp_ServerHandshakeParameters* grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_value(const grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry *msg) { return UPB_FIELD_AT(msg, const grpc_gcp_ServerHandshakeParameters*, UPB_SIZE(4, 8)); } + +UPB_INLINE void grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_set_key(grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry *msg, int32_t value) { + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE void grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_set_value(grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry *msg, grpc_gcp_ServerHandshakeParameters* value) { + UPB_FIELD_AT(msg, grpc_gcp_ServerHandshakeParameters*, UPB_SIZE(4, 8)) = value; +} +UPB_INLINE struct grpc_gcp_ServerHandshakeParameters* grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_mutable_value(grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry *msg, upb_arena *arena) { + struct grpc_gcp_ServerHandshakeParameters* sub = (struct grpc_gcp_ServerHandshakeParameters*)grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_value(msg); + if (sub == NULL) { + sub = (struct grpc_gcp_ServerHandshakeParameters*)upb_msg_new(&grpc_gcp_ServerHandshakeParameters_msginit, arena); + if (!sub) return NULL; + grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_set_value(msg, sub); + } + return sub; +} + +/* grpc.gcp.NextHandshakeMessageReq */ + +UPB_INLINE grpc_gcp_NextHandshakeMessageReq *grpc_gcp_NextHandshakeMessageReq_new(upb_arena *arena) { + return (grpc_gcp_NextHandshakeMessageReq *)upb_msg_new(&grpc_gcp_NextHandshakeMessageReq_msginit, arena); +} +UPB_INLINE grpc_gcp_NextHandshakeMessageReq *grpc_gcp_NextHandshakeMessageReq_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_gcp_NextHandshakeMessageReq *ret = grpc_gcp_NextHandshakeMessageReq_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_gcp_NextHandshakeMessageReq_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_gcp_NextHandshakeMessageReq_serialize(const grpc_gcp_NextHandshakeMessageReq *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_gcp_NextHandshakeMessageReq_msginit, arena, len); +} + +UPB_INLINE upb_strview grpc_gcp_NextHandshakeMessageReq_in_bytes(const grpc_gcp_NextHandshakeMessageReq *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } + +UPB_INLINE void grpc_gcp_NextHandshakeMessageReq_set_in_bytes(grpc_gcp_NextHandshakeMessageReq *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; +} + +/* grpc.gcp.HandshakerReq */ + +UPB_INLINE grpc_gcp_HandshakerReq *grpc_gcp_HandshakerReq_new(upb_arena *arena) { + return (grpc_gcp_HandshakerReq *)upb_msg_new(&grpc_gcp_HandshakerReq_msginit, arena); +} +UPB_INLINE grpc_gcp_HandshakerReq *grpc_gcp_HandshakerReq_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_gcp_HandshakerReq *ret = grpc_gcp_HandshakerReq_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_gcp_HandshakerReq_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_gcp_HandshakerReq_serialize(const grpc_gcp_HandshakerReq *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_gcp_HandshakerReq_msginit, arena, len); +} + +typedef enum { + grpc_gcp_HandshakerReq_req_oneof_client_start = 1, + grpc_gcp_HandshakerReq_req_oneof_server_start = 2, + grpc_gcp_HandshakerReq_req_oneof_next = 3, + grpc_gcp_HandshakerReq_req_oneof_NOT_SET = 0 +} grpc_gcp_HandshakerReq_req_oneof_oneofcases; +UPB_INLINE grpc_gcp_HandshakerReq_req_oneof_oneofcases grpc_gcp_HandshakerReq_req_oneof_case(const grpc_gcp_HandshakerReq* msg) { return (grpc_gcp_HandshakerReq_req_oneof_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 8)); } + +UPB_INLINE bool grpc_gcp_HandshakerReq_has_client_start(const grpc_gcp_HandshakerReq *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(4, 8), 1); } +UPB_INLINE const grpc_gcp_StartClientHandshakeReq* grpc_gcp_HandshakerReq_client_start(const grpc_gcp_HandshakerReq *msg) { return UPB_READ_ONEOF(msg, const grpc_gcp_StartClientHandshakeReq*, UPB_SIZE(0, 0), UPB_SIZE(4, 8), 1, NULL); } +UPB_INLINE bool grpc_gcp_HandshakerReq_has_server_start(const grpc_gcp_HandshakerReq *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(4, 8), 2); } +UPB_INLINE const grpc_gcp_StartServerHandshakeReq* grpc_gcp_HandshakerReq_server_start(const grpc_gcp_HandshakerReq *msg) { return UPB_READ_ONEOF(msg, const grpc_gcp_StartServerHandshakeReq*, UPB_SIZE(0, 0), UPB_SIZE(4, 8), 2, NULL); } +UPB_INLINE bool grpc_gcp_HandshakerReq_has_next(const grpc_gcp_HandshakerReq *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(4, 8), 3); } +UPB_INLINE const grpc_gcp_NextHandshakeMessageReq* grpc_gcp_HandshakerReq_next(const grpc_gcp_HandshakerReq *msg) { return UPB_READ_ONEOF(msg, const grpc_gcp_NextHandshakeMessageReq*, UPB_SIZE(0, 0), UPB_SIZE(4, 8), 3, NULL); } + +UPB_INLINE void grpc_gcp_HandshakerReq_set_client_start(grpc_gcp_HandshakerReq *msg, grpc_gcp_StartClientHandshakeReq* value) { + UPB_WRITE_ONEOF(msg, grpc_gcp_StartClientHandshakeReq*, UPB_SIZE(0, 0), value, UPB_SIZE(4, 8), 1); +} +UPB_INLINE struct grpc_gcp_StartClientHandshakeReq* grpc_gcp_HandshakerReq_mutable_client_start(grpc_gcp_HandshakerReq *msg, upb_arena *arena) { + struct grpc_gcp_StartClientHandshakeReq* sub = (struct grpc_gcp_StartClientHandshakeReq*)grpc_gcp_HandshakerReq_client_start(msg); + if (sub == NULL) { + sub = (struct grpc_gcp_StartClientHandshakeReq*)upb_msg_new(&grpc_gcp_StartClientHandshakeReq_msginit, arena); + if (!sub) return NULL; + grpc_gcp_HandshakerReq_set_client_start(msg, sub); + } + return sub; +} +UPB_INLINE void grpc_gcp_HandshakerReq_set_server_start(grpc_gcp_HandshakerReq *msg, grpc_gcp_StartServerHandshakeReq* value) { + UPB_WRITE_ONEOF(msg, grpc_gcp_StartServerHandshakeReq*, UPB_SIZE(0, 0), value, UPB_SIZE(4, 8), 2); +} +UPB_INLINE struct grpc_gcp_StartServerHandshakeReq* grpc_gcp_HandshakerReq_mutable_server_start(grpc_gcp_HandshakerReq *msg, upb_arena *arena) { + struct grpc_gcp_StartServerHandshakeReq* sub = (struct grpc_gcp_StartServerHandshakeReq*)grpc_gcp_HandshakerReq_server_start(msg); + if (sub == NULL) { + sub = (struct grpc_gcp_StartServerHandshakeReq*)upb_msg_new(&grpc_gcp_StartServerHandshakeReq_msginit, arena); + if (!sub) return NULL; + grpc_gcp_HandshakerReq_set_server_start(msg, sub); + } + return sub; +} +UPB_INLINE void grpc_gcp_HandshakerReq_set_next(grpc_gcp_HandshakerReq *msg, grpc_gcp_NextHandshakeMessageReq* value) { + UPB_WRITE_ONEOF(msg, grpc_gcp_NextHandshakeMessageReq*, UPB_SIZE(0, 0), value, UPB_SIZE(4, 8), 3); +} +UPB_INLINE struct grpc_gcp_NextHandshakeMessageReq* grpc_gcp_HandshakerReq_mutable_next(grpc_gcp_HandshakerReq *msg, upb_arena *arena) { + struct grpc_gcp_NextHandshakeMessageReq* sub = (struct grpc_gcp_NextHandshakeMessageReq*)grpc_gcp_HandshakerReq_next(msg); + if (sub == NULL) { + sub = (struct grpc_gcp_NextHandshakeMessageReq*)upb_msg_new(&grpc_gcp_NextHandshakeMessageReq_msginit, arena); + if (!sub) return NULL; + grpc_gcp_HandshakerReq_set_next(msg, sub); + } + return sub; +} + +/* grpc.gcp.HandshakerResult */ + +UPB_INLINE grpc_gcp_HandshakerResult *grpc_gcp_HandshakerResult_new(upb_arena *arena) { + return (grpc_gcp_HandshakerResult *)upb_msg_new(&grpc_gcp_HandshakerResult_msginit, arena); +} +UPB_INLINE grpc_gcp_HandshakerResult *grpc_gcp_HandshakerResult_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_gcp_HandshakerResult *ret = grpc_gcp_HandshakerResult_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_gcp_HandshakerResult_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_gcp_HandshakerResult_serialize(const grpc_gcp_HandshakerResult *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_gcp_HandshakerResult_msginit, arena, len); +} + +UPB_INLINE upb_strview grpc_gcp_HandshakerResult_application_protocol(const grpc_gcp_HandshakerResult *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } +UPB_INLINE upb_strview grpc_gcp_HandshakerResult_record_protocol(const grpc_gcp_HandshakerResult *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)); } +UPB_INLINE upb_strview grpc_gcp_HandshakerResult_key_data(const grpc_gcp_HandshakerResult *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(20, 40)); } +UPB_INLINE const grpc_gcp_Identity* grpc_gcp_HandshakerResult_peer_identity(const grpc_gcp_HandshakerResult *msg) { return UPB_FIELD_AT(msg, const grpc_gcp_Identity*, UPB_SIZE(28, 56)); } +UPB_INLINE const grpc_gcp_Identity* grpc_gcp_HandshakerResult_local_identity(const grpc_gcp_HandshakerResult *msg) { return UPB_FIELD_AT(msg, const grpc_gcp_Identity*, UPB_SIZE(32, 64)); } +UPB_INLINE bool grpc_gcp_HandshakerResult_keep_channel_open(const grpc_gcp_HandshakerResult *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)); } +UPB_INLINE const struct grpc_gcp_RpcProtocolVersions* grpc_gcp_HandshakerResult_peer_rpc_versions(const grpc_gcp_HandshakerResult *msg) { return UPB_FIELD_AT(msg, const struct grpc_gcp_RpcProtocolVersions*, UPB_SIZE(36, 72)); } + +UPB_INLINE void grpc_gcp_HandshakerResult_set_application_protocol(grpc_gcp_HandshakerResult *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; +} +UPB_INLINE void grpc_gcp_HandshakerResult_set_record_protocol(grpc_gcp_HandshakerResult *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)) = value; +} +UPB_INLINE void grpc_gcp_HandshakerResult_set_key_data(grpc_gcp_HandshakerResult *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(20, 40)) = value; +} +UPB_INLINE void grpc_gcp_HandshakerResult_set_peer_identity(grpc_gcp_HandshakerResult *msg, grpc_gcp_Identity* value) { + UPB_FIELD_AT(msg, grpc_gcp_Identity*, UPB_SIZE(28, 56)) = value; +} +UPB_INLINE struct grpc_gcp_Identity* grpc_gcp_HandshakerResult_mutable_peer_identity(grpc_gcp_HandshakerResult *msg, upb_arena *arena) { + struct grpc_gcp_Identity* sub = (struct grpc_gcp_Identity*)grpc_gcp_HandshakerResult_peer_identity(msg); + if (sub == NULL) { + sub = (struct grpc_gcp_Identity*)upb_msg_new(&grpc_gcp_Identity_msginit, arena); + if (!sub) return NULL; + grpc_gcp_HandshakerResult_set_peer_identity(msg, sub); + } + return sub; +} +UPB_INLINE void grpc_gcp_HandshakerResult_set_local_identity(grpc_gcp_HandshakerResult *msg, grpc_gcp_Identity* value) { + UPB_FIELD_AT(msg, grpc_gcp_Identity*, UPB_SIZE(32, 64)) = value; +} +UPB_INLINE struct grpc_gcp_Identity* grpc_gcp_HandshakerResult_mutable_local_identity(grpc_gcp_HandshakerResult *msg, upb_arena *arena) { + struct grpc_gcp_Identity* sub = (struct grpc_gcp_Identity*)grpc_gcp_HandshakerResult_local_identity(msg); + if (sub == NULL) { + sub = (struct grpc_gcp_Identity*)upb_msg_new(&grpc_gcp_Identity_msginit, arena); + if (!sub) return NULL; + grpc_gcp_HandshakerResult_set_local_identity(msg, sub); + } + return sub; +} +UPB_INLINE void grpc_gcp_HandshakerResult_set_keep_channel_open(grpc_gcp_HandshakerResult *msg, bool value) { + UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE void grpc_gcp_HandshakerResult_set_peer_rpc_versions(grpc_gcp_HandshakerResult *msg, struct grpc_gcp_RpcProtocolVersions* value) { + UPB_FIELD_AT(msg, struct grpc_gcp_RpcProtocolVersions*, UPB_SIZE(36, 72)) = value; +} +UPB_INLINE struct grpc_gcp_RpcProtocolVersions* grpc_gcp_HandshakerResult_mutable_peer_rpc_versions(grpc_gcp_HandshakerResult *msg, upb_arena *arena) { + struct grpc_gcp_RpcProtocolVersions* sub = (struct grpc_gcp_RpcProtocolVersions*)grpc_gcp_HandshakerResult_peer_rpc_versions(msg); + if (sub == NULL) { + sub = (struct grpc_gcp_RpcProtocolVersions*)upb_msg_new(&grpc_gcp_RpcProtocolVersions_msginit, arena); + if (!sub) return NULL; + grpc_gcp_HandshakerResult_set_peer_rpc_versions(msg, sub); + } + return sub; +} + +/* grpc.gcp.HandshakerStatus */ + +UPB_INLINE grpc_gcp_HandshakerStatus *grpc_gcp_HandshakerStatus_new(upb_arena *arena) { + return (grpc_gcp_HandshakerStatus *)upb_msg_new(&grpc_gcp_HandshakerStatus_msginit, arena); +} +UPB_INLINE grpc_gcp_HandshakerStatus *grpc_gcp_HandshakerStatus_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_gcp_HandshakerStatus *ret = grpc_gcp_HandshakerStatus_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_gcp_HandshakerStatus_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_gcp_HandshakerStatus_serialize(const grpc_gcp_HandshakerStatus *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_gcp_HandshakerStatus_msginit, arena, len); +} + +UPB_INLINE uint32_t grpc_gcp_HandshakerStatus_code(const grpc_gcp_HandshakerStatus *msg) { return UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(0, 0)); } +UPB_INLINE upb_strview grpc_gcp_HandshakerStatus_details(const grpc_gcp_HandshakerStatus *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } + +UPB_INLINE void grpc_gcp_HandshakerStatus_set_code(grpc_gcp_HandshakerStatus *msg, uint32_t value) { + UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE void grpc_gcp_HandshakerStatus_set_details(grpc_gcp_HandshakerStatus *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; +} + +/* grpc.gcp.HandshakerResp */ + +UPB_INLINE grpc_gcp_HandshakerResp *grpc_gcp_HandshakerResp_new(upb_arena *arena) { + return (grpc_gcp_HandshakerResp *)upb_msg_new(&grpc_gcp_HandshakerResp_msginit, arena); +} +UPB_INLINE grpc_gcp_HandshakerResp *grpc_gcp_HandshakerResp_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_gcp_HandshakerResp *ret = grpc_gcp_HandshakerResp_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_gcp_HandshakerResp_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_gcp_HandshakerResp_serialize(const grpc_gcp_HandshakerResp *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_gcp_HandshakerResp_msginit, arena, len); +} + +UPB_INLINE upb_strview grpc_gcp_HandshakerResp_out_frames(const grpc_gcp_HandshakerResp *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } +UPB_INLINE uint32_t grpc_gcp_HandshakerResp_bytes_consumed(const grpc_gcp_HandshakerResp *msg) { return UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(0, 0)); } +UPB_INLINE const grpc_gcp_HandshakerResult* grpc_gcp_HandshakerResp_result(const grpc_gcp_HandshakerResp *msg) { return UPB_FIELD_AT(msg, const grpc_gcp_HandshakerResult*, UPB_SIZE(12, 24)); } +UPB_INLINE const grpc_gcp_HandshakerStatus* grpc_gcp_HandshakerResp_status(const grpc_gcp_HandshakerResp *msg) { return UPB_FIELD_AT(msg, const grpc_gcp_HandshakerStatus*, UPB_SIZE(16, 32)); } + +UPB_INLINE void grpc_gcp_HandshakerResp_set_out_frames(grpc_gcp_HandshakerResp *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; +} +UPB_INLINE void grpc_gcp_HandshakerResp_set_bytes_consumed(grpc_gcp_HandshakerResp *msg, uint32_t value) { + UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE void grpc_gcp_HandshakerResp_set_result(grpc_gcp_HandshakerResp *msg, grpc_gcp_HandshakerResult* value) { + UPB_FIELD_AT(msg, grpc_gcp_HandshakerResult*, UPB_SIZE(12, 24)) = value; +} +UPB_INLINE struct grpc_gcp_HandshakerResult* grpc_gcp_HandshakerResp_mutable_result(grpc_gcp_HandshakerResp *msg, upb_arena *arena) { + struct grpc_gcp_HandshakerResult* sub = (struct grpc_gcp_HandshakerResult*)grpc_gcp_HandshakerResp_result(msg); + if (sub == NULL) { + sub = (struct grpc_gcp_HandshakerResult*)upb_msg_new(&grpc_gcp_HandshakerResult_msginit, arena); + if (!sub) return NULL; + grpc_gcp_HandshakerResp_set_result(msg, sub); + } + return sub; +} +UPB_INLINE void grpc_gcp_HandshakerResp_set_status(grpc_gcp_HandshakerResp *msg, grpc_gcp_HandshakerStatus* value) { + UPB_FIELD_AT(msg, grpc_gcp_HandshakerStatus*, UPB_SIZE(16, 32)) = value; +} +UPB_INLINE struct grpc_gcp_HandshakerStatus* grpc_gcp_HandshakerResp_mutable_status(grpc_gcp_HandshakerResp *msg, upb_arena *arena) { + struct grpc_gcp_HandshakerStatus* sub = (struct grpc_gcp_HandshakerStatus*)grpc_gcp_HandshakerResp_status(msg); + if (sub == NULL) { + sub = (struct grpc_gcp_HandshakerStatus*)upb_msg_new(&grpc_gcp_HandshakerStatus_msginit, arena); + if (!sub) return NULL; + grpc_gcp_HandshakerResp_set_status(msg, sub); + } + return sub; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#include "upb/port_undef.inc" + +#endif /* GRPC_GCP_HANDSHAKER_PROTO_UPB_H_ */ diff --git a/src/core/ext/upb-generated/grpc/gcp/transport_security_common.upb.c b/src/core/ext/upb-generated/grpc/gcp/transport_security_common.upb.c new file mode 100644 index 00000000000..19859504b87 --- /dev/null +++ b/src/core/ext/upb-generated/grpc/gcp/transport_security_common.upb.c @@ -0,0 +1,42 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * grpc/gcp/transport_security_common.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#include +#include "upb/msg.h" +#include "grpc/gcp/transport_security_common.upb.h" + +#include "upb/port_def.inc" + +static const upb_msglayout *const grpc_gcp_RpcProtocolVersions_submsgs[2] = { + &grpc_gcp_RpcProtocolVersions_Version_msginit, +}; + +static const upb_msglayout_field grpc_gcp_RpcProtocolVersions__fields[2] = { + {1, UPB_SIZE(0, 0), 0, 0, 11, 1}, + {2, UPB_SIZE(4, 8), 0, 0, 11, 1}, +}; + +const upb_msglayout grpc_gcp_RpcProtocolVersions_msginit = { + &grpc_gcp_RpcProtocolVersions_submsgs[0], + &grpc_gcp_RpcProtocolVersions__fields[0], + UPB_SIZE(8, 16), 2, false, +}; + +static const upb_msglayout_field grpc_gcp_RpcProtocolVersions_Version__fields[2] = { + {1, UPB_SIZE(0, 0), 0, 0, 13, 1}, + {2, UPB_SIZE(4, 4), 0, 0, 13, 1}, +}; + +const upb_msglayout grpc_gcp_RpcProtocolVersions_Version_msginit = { + NULL, + &grpc_gcp_RpcProtocolVersions_Version__fields[0], + UPB_SIZE(8, 8), 2, false, +}; + +#include "upb/port_undef.inc" + diff --git a/src/core/ext/upb-generated/grpc/gcp/transport_security_common.upb.h b/src/core/ext/upb-generated/grpc/gcp/transport_security_common.upb.h new file mode 100644 index 00000000000..14d4898b2ab --- /dev/null +++ b/src/core/ext/upb-generated/grpc/gcp/transport_security_common.upb.h @@ -0,0 +1,109 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * grpc/gcp/transport_security_common.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#ifndef GRPC_GCP_TRANSPORT_SECURITY_COMMON_PROTO_UPB_H_ +#define GRPC_GCP_TRANSPORT_SECURITY_COMMON_PROTO_UPB_H_ + +#include "upb/generated_util.h" +#include "upb/msg.h" +#include "upb/decode.h" +#include "upb/encode.h" + +#include "upb/port_def.inc" + +#ifdef __cplusplus +extern "C" { +#endif + +struct grpc_gcp_RpcProtocolVersions; +struct grpc_gcp_RpcProtocolVersions_Version; +typedef struct grpc_gcp_RpcProtocolVersions grpc_gcp_RpcProtocolVersions; +typedef struct grpc_gcp_RpcProtocolVersions_Version grpc_gcp_RpcProtocolVersions_Version; +extern const upb_msglayout grpc_gcp_RpcProtocolVersions_msginit; +extern const upb_msglayout grpc_gcp_RpcProtocolVersions_Version_msginit; + +typedef enum { + grpc_gcp_SECURITY_NONE = 0, + grpc_gcp_INTEGRITY_ONLY = 1, + grpc_gcp_INTEGRITY_AND_PRIVACY = 2 +} grpc_gcp_SecurityLevel; + + +/* grpc.gcp.RpcProtocolVersions */ + +UPB_INLINE grpc_gcp_RpcProtocolVersions *grpc_gcp_RpcProtocolVersions_new(upb_arena *arena) { + return (grpc_gcp_RpcProtocolVersions *)upb_msg_new(&grpc_gcp_RpcProtocolVersions_msginit, arena); +} +UPB_INLINE grpc_gcp_RpcProtocolVersions *grpc_gcp_RpcProtocolVersions_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_gcp_RpcProtocolVersions *ret = grpc_gcp_RpcProtocolVersions_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_gcp_RpcProtocolVersions_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_gcp_RpcProtocolVersions_serialize(const grpc_gcp_RpcProtocolVersions *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_gcp_RpcProtocolVersions_msginit, arena, len); +} + +UPB_INLINE const grpc_gcp_RpcProtocolVersions_Version* grpc_gcp_RpcProtocolVersions_max_rpc_version(const grpc_gcp_RpcProtocolVersions *msg) { return UPB_FIELD_AT(msg, const grpc_gcp_RpcProtocolVersions_Version*, UPB_SIZE(0, 0)); } +UPB_INLINE const grpc_gcp_RpcProtocolVersions_Version* grpc_gcp_RpcProtocolVersions_min_rpc_version(const grpc_gcp_RpcProtocolVersions *msg) { return UPB_FIELD_AT(msg, const grpc_gcp_RpcProtocolVersions_Version*, UPB_SIZE(4, 8)); } + +UPB_INLINE void grpc_gcp_RpcProtocolVersions_set_max_rpc_version(grpc_gcp_RpcProtocolVersions *msg, grpc_gcp_RpcProtocolVersions_Version* value) { + UPB_FIELD_AT(msg, grpc_gcp_RpcProtocolVersions_Version*, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE struct grpc_gcp_RpcProtocolVersions_Version* grpc_gcp_RpcProtocolVersions_mutable_max_rpc_version(grpc_gcp_RpcProtocolVersions *msg, upb_arena *arena) { + struct grpc_gcp_RpcProtocolVersions_Version* sub = (struct grpc_gcp_RpcProtocolVersions_Version*)grpc_gcp_RpcProtocolVersions_max_rpc_version(msg); + if (sub == NULL) { + sub = (struct grpc_gcp_RpcProtocolVersions_Version*)upb_msg_new(&grpc_gcp_RpcProtocolVersions_Version_msginit, arena); + if (!sub) return NULL; + grpc_gcp_RpcProtocolVersions_set_max_rpc_version(msg, sub); + } + return sub; +} +UPB_INLINE void grpc_gcp_RpcProtocolVersions_set_min_rpc_version(grpc_gcp_RpcProtocolVersions *msg, grpc_gcp_RpcProtocolVersions_Version* value) { + UPB_FIELD_AT(msg, grpc_gcp_RpcProtocolVersions_Version*, UPB_SIZE(4, 8)) = value; +} +UPB_INLINE struct grpc_gcp_RpcProtocolVersions_Version* grpc_gcp_RpcProtocolVersions_mutable_min_rpc_version(grpc_gcp_RpcProtocolVersions *msg, upb_arena *arena) { + struct grpc_gcp_RpcProtocolVersions_Version* sub = (struct grpc_gcp_RpcProtocolVersions_Version*)grpc_gcp_RpcProtocolVersions_min_rpc_version(msg); + if (sub == NULL) { + sub = (struct grpc_gcp_RpcProtocolVersions_Version*)upb_msg_new(&grpc_gcp_RpcProtocolVersions_Version_msginit, arena); + if (!sub) return NULL; + grpc_gcp_RpcProtocolVersions_set_min_rpc_version(msg, sub); + } + return sub; +} + +/* grpc.gcp.RpcProtocolVersions.Version */ + +UPB_INLINE grpc_gcp_RpcProtocolVersions_Version *grpc_gcp_RpcProtocolVersions_Version_new(upb_arena *arena) { + return (grpc_gcp_RpcProtocolVersions_Version *)upb_msg_new(&grpc_gcp_RpcProtocolVersions_Version_msginit, arena); +} +UPB_INLINE grpc_gcp_RpcProtocolVersions_Version *grpc_gcp_RpcProtocolVersions_Version_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_gcp_RpcProtocolVersions_Version *ret = grpc_gcp_RpcProtocolVersions_Version_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_gcp_RpcProtocolVersions_Version_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_gcp_RpcProtocolVersions_Version_serialize(const grpc_gcp_RpcProtocolVersions_Version *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_gcp_RpcProtocolVersions_Version_msginit, arena, len); +} + +UPB_INLINE uint32_t grpc_gcp_RpcProtocolVersions_Version_major(const grpc_gcp_RpcProtocolVersions_Version *msg) { return UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(0, 0)); } +UPB_INLINE uint32_t grpc_gcp_RpcProtocolVersions_Version_minor(const grpc_gcp_RpcProtocolVersions_Version *msg) { return UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(4, 4)); } + +UPB_INLINE void grpc_gcp_RpcProtocolVersions_Version_set_major(grpc_gcp_RpcProtocolVersions_Version *msg, uint32_t value) { + UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE void grpc_gcp_RpcProtocolVersions_Version_set_minor(grpc_gcp_RpcProtocolVersions_Version *msg, uint32_t value) { + UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(4, 4)) = value; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#include "upb/port_undef.inc" + +#endif /* GRPC_GCP_TRANSPORT_SECURITY_COMMON_PROTO_UPB_H_ */ diff --git a/src/core/ext/upb-generated/grpc/health/v1/health.upb.c b/src/core/ext/upb-generated/grpc/health/v1/health.upb.c new file mode 100644 index 00000000000..e672d431005 --- /dev/null +++ b/src/core/ext/upb-generated/grpc/health/v1/health.upb.c @@ -0,0 +1,36 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * grpc/health/v1/health.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#include +#include "upb/msg.h" +#include "grpc/health/v1/health.upb.h" + +#include "upb/port_def.inc" + +static const upb_msglayout_field grpc_health_v1_HealthCheckRequest__fields[1] = { + {1, UPB_SIZE(0, 0), 0, 0, 9, 1}, +}; + +const upb_msglayout grpc_health_v1_HealthCheckRequest_msginit = { + NULL, + &grpc_health_v1_HealthCheckRequest__fields[0], + UPB_SIZE(8, 16), 1, false, +}; + +static const upb_msglayout_field grpc_health_v1_HealthCheckResponse__fields[1] = { + {1, UPB_SIZE(0, 0), 0, 0, 14, 1}, +}; + +const upb_msglayout grpc_health_v1_HealthCheckResponse_msginit = { + NULL, + &grpc_health_v1_HealthCheckResponse__fields[0], + UPB_SIZE(8, 8), 1, false, +}; + +#include "upb/port_undef.inc" + diff --git a/src/core/ext/upb-generated/grpc/health/v1/health.upb.h b/src/core/ext/upb-generated/grpc/health/v1/health.upb.h new file mode 100644 index 00000000000..536e7d8131b --- /dev/null +++ b/src/core/ext/upb-generated/grpc/health/v1/health.upb.h @@ -0,0 +1,84 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * grpc/health/v1/health.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#ifndef GRPC_HEALTH_V1_HEALTH_PROTO_UPB_H_ +#define GRPC_HEALTH_V1_HEALTH_PROTO_UPB_H_ + +#include "upb/generated_util.h" +#include "upb/msg.h" +#include "upb/decode.h" +#include "upb/encode.h" + +#include "upb/port_def.inc" + +#ifdef __cplusplus +extern "C" { +#endif + +struct grpc_health_v1_HealthCheckRequest; +struct grpc_health_v1_HealthCheckResponse; +typedef struct grpc_health_v1_HealthCheckRequest grpc_health_v1_HealthCheckRequest; +typedef struct grpc_health_v1_HealthCheckResponse grpc_health_v1_HealthCheckResponse; +extern const upb_msglayout grpc_health_v1_HealthCheckRequest_msginit; +extern const upb_msglayout grpc_health_v1_HealthCheckResponse_msginit; + +typedef enum { + grpc_health_v1_HealthCheckResponse_UNKNOWN = 0, + grpc_health_v1_HealthCheckResponse_SERVING = 1, + grpc_health_v1_HealthCheckResponse_NOT_SERVING = 2, + grpc_health_v1_HealthCheckResponse_SERVICE_UNKNOWN = 3 +} grpc_health_v1_HealthCheckResponse_ServingStatus; + + +/* grpc.health.v1.HealthCheckRequest */ + +UPB_INLINE grpc_health_v1_HealthCheckRequest *grpc_health_v1_HealthCheckRequest_new(upb_arena *arena) { + return (grpc_health_v1_HealthCheckRequest *)upb_msg_new(&grpc_health_v1_HealthCheckRequest_msginit, arena); +} +UPB_INLINE grpc_health_v1_HealthCheckRequest *grpc_health_v1_HealthCheckRequest_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_health_v1_HealthCheckRequest *ret = grpc_health_v1_HealthCheckRequest_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_health_v1_HealthCheckRequest_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_health_v1_HealthCheckRequest_serialize(const grpc_health_v1_HealthCheckRequest *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_health_v1_HealthCheckRequest_msginit, arena, len); +} + +UPB_INLINE upb_strview grpc_health_v1_HealthCheckRequest_service(const grpc_health_v1_HealthCheckRequest *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } + +UPB_INLINE void grpc_health_v1_HealthCheckRequest_set_service(grpc_health_v1_HealthCheckRequest *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; +} + +/* grpc.health.v1.HealthCheckResponse */ + +UPB_INLINE grpc_health_v1_HealthCheckResponse *grpc_health_v1_HealthCheckResponse_new(upb_arena *arena) { + return (grpc_health_v1_HealthCheckResponse *)upb_msg_new(&grpc_health_v1_HealthCheckResponse_msginit, arena); +} +UPB_INLINE grpc_health_v1_HealthCheckResponse *grpc_health_v1_HealthCheckResponse_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_health_v1_HealthCheckResponse *ret = grpc_health_v1_HealthCheckResponse_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_health_v1_HealthCheckResponse_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_health_v1_HealthCheckResponse_serialize(const grpc_health_v1_HealthCheckResponse *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_health_v1_HealthCheckResponse_msginit, arena, len); +} + +UPB_INLINE int32_t grpc_health_v1_HealthCheckResponse_status(const grpc_health_v1_HealthCheckResponse *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)); } + +UPB_INLINE void grpc_health_v1_HealthCheckResponse_set_status(grpc_health_v1_HealthCheckResponse *msg, int32_t value) { + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)) = value; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#include "upb/port_undef.inc" + +#endif /* GRPC_HEALTH_V1_HEALTH_PROTO_UPB_H_ */ diff --git a/src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.c b/src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.c new file mode 100644 index 00000000000..74a01dc8d98 --- /dev/null +++ b/src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.c @@ -0,0 +1,133 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * grpc/lb/v1/load_balancer.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#include +#include "upb/msg.h" +#include "grpc/lb/v1/load_balancer.upb.h" +#include "google/protobuf/duration.upb.h" +#include "google/protobuf/timestamp.upb.h" + +#include "upb/port_def.inc" + +static const upb_msglayout *const grpc_lb_v1_LoadBalanceRequest_submsgs[2] = { + &grpc_lb_v1_ClientStats_msginit, + &grpc_lb_v1_InitialLoadBalanceRequest_msginit, +}; + +static const upb_msglayout_field grpc_lb_v1_LoadBalanceRequest__fields[2] = { + {1, UPB_SIZE(0, 0), UPB_SIZE(-5, -9), 1, 11, 1}, + {2, UPB_SIZE(0, 0), UPB_SIZE(-5, -9), 0, 11, 1}, +}; + +const upb_msglayout grpc_lb_v1_LoadBalanceRequest_msginit = { + &grpc_lb_v1_LoadBalanceRequest_submsgs[0], + &grpc_lb_v1_LoadBalanceRequest__fields[0], + UPB_SIZE(8, 16), 2, false, +}; + +static const upb_msglayout_field grpc_lb_v1_InitialLoadBalanceRequest__fields[1] = { + {1, UPB_SIZE(0, 0), 0, 0, 9, 1}, +}; + +const upb_msglayout grpc_lb_v1_InitialLoadBalanceRequest_msginit = { + NULL, + &grpc_lb_v1_InitialLoadBalanceRequest__fields[0], + UPB_SIZE(8, 16), 1, false, +}; + +static const upb_msglayout_field grpc_lb_v1_ClientStatsPerToken__fields[2] = { + {1, UPB_SIZE(8, 8), 0, 0, 9, 1}, + {2, UPB_SIZE(0, 0), 0, 0, 3, 1}, +}; + +const upb_msglayout grpc_lb_v1_ClientStatsPerToken_msginit = { + NULL, + &grpc_lb_v1_ClientStatsPerToken__fields[0], + UPB_SIZE(16, 32), 2, false, +}; + +static const upb_msglayout *const grpc_lb_v1_ClientStats_submsgs[2] = { + &google_protobuf_Timestamp_msginit, + &grpc_lb_v1_ClientStatsPerToken_msginit, +}; + +static const upb_msglayout_field grpc_lb_v1_ClientStats__fields[6] = { + {1, UPB_SIZE(32, 32), 0, 0, 11, 1}, + {2, UPB_SIZE(0, 0), 0, 0, 3, 1}, + {3, UPB_SIZE(8, 8), 0, 0, 3, 1}, + {6, UPB_SIZE(16, 16), 0, 0, 3, 1}, + {7, UPB_SIZE(24, 24), 0, 0, 3, 1}, + {8, UPB_SIZE(36, 40), 0, 1, 11, 3}, +}; + +const upb_msglayout grpc_lb_v1_ClientStats_msginit = { + &grpc_lb_v1_ClientStats_submsgs[0], + &grpc_lb_v1_ClientStats__fields[0], + UPB_SIZE(40, 48), 6, false, +}; + +static const upb_msglayout *const grpc_lb_v1_LoadBalanceResponse_submsgs[2] = { + &grpc_lb_v1_InitialLoadBalanceResponse_msginit, + &grpc_lb_v1_ServerList_msginit, +}; + +static const upb_msglayout_field grpc_lb_v1_LoadBalanceResponse__fields[2] = { + {1, UPB_SIZE(0, 0), UPB_SIZE(-5, -9), 0, 11, 1}, + {2, UPB_SIZE(0, 0), UPB_SIZE(-5, -9), 1, 11, 1}, +}; + +const upb_msglayout grpc_lb_v1_LoadBalanceResponse_msginit = { + &grpc_lb_v1_LoadBalanceResponse_submsgs[0], + &grpc_lb_v1_LoadBalanceResponse__fields[0], + UPB_SIZE(8, 16), 2, false, +}; + +static const upb_msglayout *const grpc_lb_v1_InitialLoadBalanceResponse_submsgs[1] = { + &google_protobuf_Duration_msginit, +}; + +static const upb_msglayout_field grpc_lb_v1_InitialLoadBalanceResponse__fields[2] = { + {1, UPB_SIZE(0, 0), 0, 0, 9, 1}, + {2, UPB_SIZE(8, 16), 0, 0, 11, 1}, +}; + +const upb_msglayout grpc_lb_v1_InitialLoadBalanceResponse_msginit = { + &grpc_lb_v1_InitialLoadBalanceResponse_submsgs[0], + &grpc_lb_v1_InitialLoadBalanceResponse__fields[0], + UPB_SIZE(16, 32), 2, false, +}; + +static const upb_msglayout *const grpc_lb_v1_ServerList_submsgs[1] = { + &grpc_lb_v1_Server_msginit, +}; + +static const upb_msglayout_field grpc_lb_v1_ServerList__fields[1] = { + {1, UPB_SIZE(0, 0), 0, 0, 11, 3}, +}; + +const upb_msglayout grpc_lb_v1_ServerList_msginit = { + &grpc_lb_v1_ServerList_submsgs[0], + &grpc_lb_v1_ServerList__fields[0], + UPB_SIZE(4, 8), 1, false, +}; + +static const upb_msglayout_field grpc_lb_v1_Server__fields[4] = { + {1, UPB_SIZE(8, 8), 0, 0, 12, 1}, + {2, UPB_SIZE(0, 0), 0, 0, 5, 1}, + {3, UPB_SIZE(16, 24), 0, 0, 9, 1}, + {4, UPB_SIZE(4, 4), 0, 0, 8, 1}, +}; + +const upb_msglayout grpc_lb_v1_Server_msginit = { + NULL, + &grpc_lb_v1_Server__fields[0], + UPB_SIZE(24, 48), 4, false, +}; + +#include "upb/port_undef.inc" + diff --git a/src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.h b/src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.h new file mode 100644 index 00000000000..398da3b71fe --- /dev/null +++ b/src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.h @@ -0,0 +1,359 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * grpc/lb/v1/load_balancer.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#ifndef GRPC_LB_V1_LOAD_BALANCER_PROTO_UPB_H_ +#define GRPC_LB_V1_LOAD_BALANCER_PROTO_UPB_H_ + +#include "upb/generated_util.h" +#include "upb/msg.h" +#include "upb/decode.h" +#include "upb/encode.h" + +#include "upb/port_def.inc" + +#ifdef __cplusplus +extern "C" { +#endif + +struct grpc_lb_v1_LoadBalanceRequest; +struct grpc_lb_v1_InitialLoadBalanceRequest; +struct grpc_lb_v1_ClientStatsPerToken; +struct grpc_lb_v1_ClientStats; +struct grpc_lb_v1_LoadBalanceResponse; +struct grpc_lb_v1_InitialLoadBalanceResponse; +struct grpc_lb_v1_ServerList; +struct grpc_lb_v1_Server; +typedef struct grpc_lb_v1_LoadBalanceRequest grpc_lb_v1_LoadBalanceRequest; +typedef struct grpc_lb_v1_InitialLoadBalanceRequest grpc_lb_v1_InitialLoadBalanceRequest; +typedef struct grpc_lb_v1_ClientStatsPerToken grpc_lb_v1_ClientStatsPerToken; +typedef struct grpc_lb_v1_ClientStats grpc_lb_v1_ClientStats; +typedef struct grpc_lb_v1_LoadBalanceResponse grpc_lb_v1_LoadBalanceResponse; +typedef struct grpc_lb_v1_InitialLoadBalanceResponse grpc_lb_v1_InitialLoadBalanceResponse; +typedef struct grpc_lb_v1_ServerList grpc_lb_v1_ServerList; +typedef struct grpc_lb_v1_Server grpc_lb_v1_Server; +extern const upb_msglayout grpc_lb_v1_LoadBalanceRequest_msginit; +extern const upb_msglayout grpc_lb_v1_InitialLoadBalanceRequest_msginit; +extern const upb_msglayout grpc_lb_v1_ClientStatsPerToken_msginit; +extern const upb_msglayout grpc_lb_v1_ClientStats_msginit; +extern const upb_msglayout grpc_lb_v1_LoadBalanceResponse_msginit; +extern const upb_msglayout grpc_lb_v1_InitialLoadBalanceResponse_msginit; +extern const upb_msglayout grpc_lb_v1_ServerList_msginit; +extern const upb_msglayout grpc_lb_v1_Server_msginit; +struct google_protobuf_Duration; +struct google_protobuf_Timestamp; +extern const upb_msglayout google_protobuf_Duration_msginit; +extern const upb_msglayout google_protobuf_Timestamp_msginit; + + +/* grpc.lb.v1.LoadBalanceRequest */ + +UPB_INLINE grpc_lb_v1_LoadBalanceRequest *grpc_lb_v1_LoadBalanceRequest_new(upb_arena *arena) { + return (grpc_lb_v1_LoadBalanceRequest *)upb_msg_new(&grpc_lb_v1_LoadBalanceRequest_msginit, arena); +} +UPB_INLINE grpc_lb_v1_LoadBalanceRequest *grpc_lb_v1_LoadBalanceRequest_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_lb_v1_LoadBalanceRequest *ret = grpc_lb_v1_LoadBalanceRequest_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_lb_v1_LoadBalanceRequest_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_lb_v1_LoadBalanceRequest_serialize(const grpc_lb_v1_LoadBalanceRequest *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_lb_v1_LoadBalanceRequest_msginit, arena, len); +} + +typedef enum { + grpc_lb_v1_LoadBalanceRequest_load_balance_request_type_initial_request = 1, + grpc_lb_v1_LoadBalanceRequest_load_balance_request_type_client_stats = 2, + grpc_lb_v1_LoadBalanceRequest_load_balance_request_type_NOT_SET = 0 +} grpc_lb_v1_LoadBalanceRequest_load_balance_request_type_oneofcases; +UPB_INLINE grpc_lb_v1_LoadBalanceRequest_load_balance_request_type_oneofcases grpc_lb_v1_LoadBalanceRequest_load_balance_request_type_case(const grpc_lb_v1_LoadBalanceRequest* msg) { return (grpc_lb_v1_LoadBalanceRequest_load_balance_request_type_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 8)); } + +UPB_INLINE bool grpc_lb_v1_LoadBalanceRequest_has_initial_request(const grpc_lb_v1_LoadBalanceRequest *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(4, 8), 1); } +UPB_INLINE const grpc_lb_v1_InitialLoadBalanceRequest* grpc_lb_v1_LoadBalanceRequest_initial_request(const grpc_lb_v1_LoadBalanceRequest *msg) { return UPB_READ_ONEOF(msg, const grpc_lb_v1_InitialLoadBalanceRequest*, UPB_SIZE(0, 0), UPB_SIZE(4, 8), 1, NULL); } +UPB_INLINE bool grpc_lb_v1_LoadBalanceRequest_has_client_stats(const grpc_lb_v1_LoadBalanceRequest *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(4, 8), 2); } +UPB_INLINE const grpc_lb_v1_ClientStats* grpc_lb_v1_LoadBalanceRequest_client_stats(const grpc_lb_v1_LoadBalanceRequest *msg) { return UPB_READ_ONEOF(msg, const grpc_lb_v1_ClientStats*, UPB_SIZE(0, 0), UPB_SIZE(4, 8), 2, NULL); } + +UPB_INLINE void grpc_lb_v1_LoadBalanceRequest_set_initial_request(grpc_lb_v1_LoadBalanceRequest *msg, grpc_lb_v1_InitialLoadBalanceRequest* value) { + UPB_WRITE_ONEOF(msg, grpc_lb_v1_InitialLoadBalanceRequest*, UPB_SIZE(0, 0), value, UPB_SIZE(4, 8), 1); +} +UPB_INLINE struct grpc_lb_v1_InitialLoadBalanceRequest* grpc_lb_v1_LoadBalanceRequest_mutable_initial_request(grpc_lb_v1_LoadBalanceRequest *msg, upb_arena *arena) { + struct grpc_lb_v1_InitialLoadBalanceRequest* sub = (struct grpc_lb_v1_InitialLoadBalanceRequest*)grpc_lb_v1_LoadBalanceRequest_initial_request(msg); + if (sub == NULL) { + sub = (struct grpc_lb_v1_InitialLoadBalanceRequest*)upb_msg_new(&grpc_lb_v1_InitialLoadBalanceRequest_msginit, arena); + if (!sub) return NULL; + grpc_lb_v1_LoadBalanceRequest_set_initial_request(msg, sub); + } + return sub; +} +UPB_INLINE void grpc_lb_v1_LoadBalanceRequest_set_client_stats(grpc_lb_v1_LoadBalanceRequest *msg, grpc_lb_v1_ClientStats* value) { + UPB_WRITE_ONEOF(msg, grpc_lb_v1_ClientStats*, UPB_SIZE(0, 0), value, UPB_SIZE(4, 8), 2); +} +UPB_INLINE struct grpc_lb_v1_ClientStats* grpc_lb_v1_LoadBalanceRequest_mutable_client_stats(grpc_lb_v1_LoadBalanceRequest *msg, upb_arena *arena) { + struct grpc_lb_v1_ClientStats* sub = (struct grpc_lb_v1_ClientStats*)grpc_lb_v1_LoadBalanceRequest_client_stats(msg); + if (sub == NULL) { + sub = (struct grpc_lb_v1_ClientStats*)upb_msg_new(&grpc_lb_v1_ClientStats_msginit, arena); + if (!sub) return NULL; + grpc_lb_v1_LoadBalanceRequest_set_client_stats(msg, sub); + } + return sub; +} + +/* grpc.lb.v1.InitialLoadBalanceRequest */ + +UPB_INLINE grpc_lb_v1_InitialLoadBalanceRequest *grpc_lb_v1_InitialLoadBalanceRequest_new(upb_arena *arena) { + return (grpc_lb_v1_InitialLoadBalanceRequest *)upb_msg_new(&grpc_lb_v1_InitialLoadBalanceRequest_msginit, arena); +} +UPB_INLINE grpc_lb_v1_InitialLoadBalanceRequest *grpc_lb_v1_InitialLoadBalanceRequest_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_lb_v1_InitialLoadBalanceRequest *ret = grpc_lb_v1_InitialLoadBalanceRequest_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_lb_v1_InitialLoadBalanceRequest_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_lb_v1_InitialLoadBalanceRequest_serialize(const grpc_lb_v1_InitialLoadBalanceRequest *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_lb_v1_InitialLoadBalanceRequest_msginit, arena, len); +} + +UPB_INLINE upb_strview grpc_lb_v1_InitialLoadBalanceRequest_name(const grpc_lb_v1_InitialLoadBalanceRequest *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } + +UPB_INLINE void grpc_lb_v1_InitialLoadBalanceRequest_set_name(grpc_lb_v1_InitialLoadBalanceRequest *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; +} + +/* grpc.lb.v1.ClientStatsPerToken */ + +UPB_INLINE grpc_lb_v1_ClientStatsPerToken *grpc_lb_v1_ClientStatsPerToken_new(upb_arena *arena) { + return (grpc_lb_v1_ClientStatsPerToken *)upb_msg_new(&grpc_lb_v1_ClientStatsPerToken_msginit, arena); +} +UPB_INLINE grpc_lb_v1_ClientStatsPerToken *grpc_lb_v1_ClientStatsPerToken_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_lb_v1_ClientStatsPerToken *ret = grpc_lb_v1_ClientStatsPerToken_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_lb_v1_ClientStatsPerToken_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_lb_v1_ClientStatsPerToken_serialize(const grpc_lb_v1_ClientStatsPerToken *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_lb_v1_ClientStatsPerToken_msginit, arena, len); +} + +UPB_INLINE upb_strview grpc_lb_v1_ClientStatsPerToken_load_balance_token(const grpc_lb_v1_ClientStatsPerToken *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)); } +UPB_INLINE int64_t grpc_lb_v1_ClientStatsPerToken_num_calls(const grpc_lb_v1_ClientStatsPerToken *msg) { return UPB_FIELD_AT(msg, int64_t, UPB_SIZE(0, 0)); } + +UPB_INLINE void grpc_lb_v1_ClientStatsPerToken_set_load_balance_token(grpc_lb_v1_ClientStatsPerToken *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)) = value; +} +UPB_INLINE void grpc_lb_v1_ClientStatsPerToken_set_num_calls(grpc_lb_v1_ClientStatsPerToken *msg, int64_t value) { + UPB_FIELD_AT(msg, int64_t, UPB_SIZE(0, 0)) = value; +} + +/* grpc.lb.v1.ClientStats */ + +UPB_INLINE grpc_lb_v1_ClientStats *grpc_lb_v1_ClientStats_new(upb_arena *arena) { + return (grpc_lb_v1_ClientStats *)upb_msg_new(&grpc_lb_v1_ClientStats_msginit, arena); +} +UPB_INLINE grpc_lb_v1_ClientStats *grpc_lb_v1_ClientStats_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_lb_v1_ClientStats *ret = grpc_lb_v1_ClientStats_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_lb_v1_ClientStats_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_lb_v1_ClientStats_serialize(const grpc_lb_v1_ClientStats *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_lb_v1_ClientStats_msginit, arena, len); +} + +UPB_INLINE const struct google_protobuf_Timestamp* grpc_lb_v1_ClientStats_timestamp(const grpc_lb_v1_ClientStats *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Timestamp*, UPB_SIZE(32, 32)); } +UPB_INLINE int64_t grpc_lb_v1_ClientStats_num_calls_started(const grpc_lb_v1_ClientStats *msg) { return UPB_FIELD_AT(msg, int64_t, UPB_SIZE(0, 0)); } +UPB_INLINE int64_t grpc_lb_v1_ClientStats_num_calls_finished(const grpc_lb_v1_ClientStats *msg) { return UPB_FIELD_AT(msg, int64_t, UPB_SIZE(8, 8)); } +UPB_INLINE int64_t grpc_lb_v1_ClientStats_num_calls_finished_with_client_failed_to_send(const grpc_lb_v1_ClientStats *msg) { return UPB_FIELD_AT(msg, int64_t, UPB_SIZE(16, 16)); } +UPB_INLINE int64_t grpc_lb_v1_ClientStats_num_calls_finished_known_received(const grpc_lb_v1_ClientStats *msg) { return UPB_FIELD_AT(msg, int64_t, UPB_SIZE(24, 24)); } +UPB_INLINE const grpc_lb_v1_ClientStatsPerToken* const* grpc_lb_v1_ClientStats_calls_finished_with_drop(const grpc_lb_v1_ClientStats *msg, size_t *len) { return (const grpc_lb_v1_ClientStatsPerToken* const*)_upb_array_accessor(msg, UPB_SIZE(36, 40), len); } + +UPB_INLINE void grpc_lb_v1_ClientStats_set_timestamp(grpc_lb_v1_ClientStats *msg, struct google_protobuf_Timestamp* value) { + UPB_FIELD_AT(msg, struct google_protobuf_Timestamp*, UPB_SIZE(32, 32)) = value; +} +UPB_INLINE struct google_protobuf_Timestamp* grpc_lb_v1_ClientStats_mutable_timestamp(grpc_lb_v1_ClientStats *msg, upb_arena *arena) { + struct google_protobuf_Timestamp* sub = (struct google_protobuf_Timestamp*)grpc_lb_v1_ClientStats_timestamp(msg); + if (sub == NULL) { + sub = (struct google_protobuf_Timestamp*)upb_msg_new(&google_protobuf_Timestamp_msginit, arena); + if (!sub) return NULL; + grpc_lb_v1_ClientStats_set_timestamp(msg, sub); + } + return sub; +} +UPB_INLINE void grpc_lb_v1_ClientStats_set_num_calls_started(grpc_lb_v1_ClientStats *msg, int64_t value) { + UPB_FIELD_AT(msg, int64_t, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE void grpc_lb_v1_ClientStats_set_num_calls_finished(grpc_lb_v1_ClientStats *msg, int64_t value) { + UPB_FIELD_AT(msg, int64_t, UPB_SIZE(8, 8)) = value; +} +UPB_INLINE void grpc_lb_v1_ClientStats_set_num_calls_finished_with_client_failed_to_send(grpc_lb_v1_ClientStats *msg, int64_t value) { + UPB_FIELD_AT(msg, int64_t, UPB_SIZE(16, 16)) = value; +} +UPB_INLINE void grpc_lb_v1_ClientStats_set_num_calls_finished_known_received(grpc_lb_v1_ClientStats *msg, int64_t value) { + UPB_FIELD_AT(msg, int64_t, UPB_SIZE(24, 24)) = value; +} +UPB_INLINE grpc_lb_v1_ClientStatsPerToken** grpc_lb_v1_ClientStats_mutable_calls_finished_with_drop(grpc_lb_v1_ClientStats *msg, size_t *len) { + return (grpc_lb_v1_ClientStatsPerToken**)_upb_array_mutable_accessor(msg, UPB_SIZE(36, 40), len); +} +UPB_INLINE grpc_lb_v1_ClientStatsPerToken** grpc_lb_v1_ClientStats_resize_calls_finished_with_drop(grpc_lb_v1_ClientStats *msg, size_t len, upb_arena *arena) { + return (grpc_lb_v1_ClientStatsPerToken**)_upb_array_resize_accessor(msg, UPB_SIZE(36, 40), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct grpc_lb_v1_ClientStatsPerToken* grpc_lb_v1_ClientStats_add_calls_finished_with_drop(grpc_lb_v1_ClientStats *msg, upb_arena *arena) { + struct grpc_lb_v1_ClientStatsPerToken* sub = (struct grpc_lb_v1_ClientStatsPerToken*)upb_msg_new(&grpc_lb_v1_ClientStatsPerToken_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(36, 40), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} + +/* grpc.lb.v1.LoadBalanceResponse */ + +UPB_INLINE grpc_lb_v1_LoadBalanceResponse *grpc_lb_v1_LoadBalanceResponse_new(upb_arena *arena) { + return (grpc_lb_v1_LoadBalanceResponse *)upb_msg_new(&grpc_lb_v1_LoadBalanceResponse_msginit, arena); +} +UPB_INLINE grpc_lb_v1_LoadBalanceResponse *grpc_lb_v1_LoadBalanceResponse_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_lb_v1_LoadBalanceResponse *ret = grpc_lb_v1_LoadBalanceResponse_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_lb_v1_LoadBalanceResponse_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_lb_v1_LoadBalanceResponse_serialize(const grpc_lb_v1_LoadBalanceResponse *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_lb_v1_LoadBalanceResponse_msginit, arena, len); +} + +typedef enum { + grpc_lb_v1_LoadBalanceResponse_load_balance_response_type_initial_response = 1, + grpc_lb_v1_LoadBalanceResponse_load_balance_response_type_server_list = 2, + grpc_lb_v1_LoadBalanceResponse_load_balance_response_type_NOT_SET = 0 +} grpc_lb_v1_LoadBalanceResponse_load_balance_response_type_oneofcases; +UPB_INLINE grpc_lb_v1_LoadBalanceResponse_load_balance_response_type_oneofcases grpc_lb_v1_LoadBalanceResponse_load_balance_response_type_case(const grpc_lb_v1_LoadBalanceResponse* msg) { return (grpc_lb_v1_LoadBalanceResponse_load_balance_response_type_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 8)); } + +UPB_INLINE bool grpc_lb_v1_LoadBalanceResponse_has_initial_response(const grpc_lb_v1_LoadBalanceResponse *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(4, 8), 1); } +UPB_INLINE const grpc_lb_v1_InitialLoadBalanceResponse* grpc_lb_v1_LoadBalanceResponse_initial_response(const grpc_lb_v1_LoadBalanceResponse *msg) { return UPB_READ_ONEOF(msg, const grpc_lb_v1_InitialLoadBalanceResponse*, UPB_SIZE(0, 0), UPB_SIZE(4, 8), 1, NULL); } +UPB_INLINE bool grpc_lb_v1_LoadBalanceResponse_has_server_list(const grpc_lb_v1_LoadBalanceResponse *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(4, 8), 2); } +UPB_INLINE const grpc_lb_v1_ServerList* grpc_lb_v1_LoadBalanceResponse_server_list(const grpc_lb_v1_LoadBalanceResponse *msg) { return UPB_READ_ONEOF(msg, const grpc_lb_v1_ServerList*, UPB_SIZE(0, 0), UPB_SIZE(4, 8), 2, NULL); } + +UPB_INLINE void grpc_lb_v1_LoadBalanceResponse_set_initial_response(grpc_lb_v1_LoadBalanceResponse *msg, grpc_lb_v1_InitialLoadBalanceResponse* value) { + UPB_WRITE_ONEOF(msg, grpc_lb_v1_InitialLoadBalanceResponse*, UPB_SIZE(0, 0), value, UPB_SIZE(4, 8), 1); +} +UPB_INLINE struct grpc_lb_v1_InitialLoadBalanceResponse* grpc_lb_v1_LoadBalanceResponse_mutable_initial_response(grpc_lb_v1_LoadBalanceResponse *msg, upb_arena *arena) { + struct grpc_lb_v1_InitialLoadBalanceResponse* sub = (struct grpc_lb_v1_InitialLoadBalanceResponse*)grpc_lb_v1_LoadBalanceResponse_initial_response(msg); + if (sub == NULL) { + sub = (struct grpc_lb_v1_InitialLoadBalanceResponse*)upb_msg_new(&grpc_lb_v1_InitialLoadBalanceResponse_msginit, arena); + if (!sub) return NULL; + grpc_lb_v1_LoadBalanceResponse_set_initial_response(msg, sub); + } + return sub; +} +UPB_INLINE void grpc_lb_v1_LoadBalanceResponse_set_server_list(grpc_lb_v1_LoadBalanceResponse *msg, grpc_lb_v1_ServerList* value) { + UPB_WRITE_ONEOF(msg, grpc_lb_v1_ServerList*, UPB_SIZE(0, 0), value, UPB_SIZE(4, 8), 2); +} +UPB_INLINE struct grpc_lb_v1_ServerList* grpc_lb_v1_LoadBalanceResponse_mutable_server_list(grpc_lb_v1_LoadBalanceResponse *msg, upb_arena *arena) { + struct grpc_lb_v1_ServerList* sub = (struct grpc_lb_v1_ServerList*)grpc_lb_v1_LoadBalanceResponse_server_list(msg); + if (sub == NULL) { + sub = (struct grpc_lb_v1_ServerList*)upb_msg_new(&grpc_lb_v1_ServerList_msginit, arena); + if (!sub) return NULL; + grpc_lb_v1_LoadBalanceResponse_set_server_list(msg, sub); + } + return sub; +} + +/* grpc.lb.v1.InitialLoadBalanceResponse */ + +UPB_INLINE grpc_lb_v1_InitialLoadBalanceResponse *grpc_lb_v1_InitialLoadBalanceResponse_new(upb_arena *arena) { + return (grpc_lb_v1_InitialLoadBalanceResponse *)upb_msg_new(&grpc_lb_v1_InitialLoadBalanceResponse_msginit, arena); +} +UPB_INLINE grpc_lb_v1_InitialLoadBalanceResponse *grpc_lb_v1_InitialLoadBalanceResponse_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_lb_v1_InitialLoadBalanceResponse *ret = grpc_lb_v1_InitialLoadBalanceResponse_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_lb_v1_InitialLoadBalanceResponse_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_lb_v1_InitialLoadBalanceResponse_serialize(const grpc_lb_v1_InitialLoadBalanceResponse *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_lb_v1_InitialLoadBalanceResponse_msginit, arena, len); +} + +UPB_INLINE upb_strview grpc_lb_v1_InitialLoadBalanceResponse_load_balancer_delegate(const grpc_lb_v1_InitialLoadBalanceResponse *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } +UPB_INLINE const struct google_protobuf_Duration* grpc_lb_v1_InitialLoadBalanceResponse_client_stats_report_interval(const grpc_lb_v1_InitialLoadBalanceResponse *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(8, 16)); } + +UPB_INLINE void grpc_lb_v1_InitialLoadBalanceResponse_set_load_balancer_delegate(grpc_lb_v1_InitialLoadBalanceResponse *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE void grpc_lb_v1_InitialLoadBalanceResponse_set_client_stats_report_interval(grpc_lb_v1_InitialLoadBalanceResponse *msg, struct google_protobuf_Duration* value) { + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(8, 16)) = value; +} +UPB_INLINE struct google_protobuf_Duration* grpc_lb_v1_InitialLoadBalanceResponse_mutable_client_stats_report_interval(grpc_lb_v1_InitialLoadBalanceResponse *msg, upb_arena *arena) { + struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)grpc_lb_v1_InitialLoadBalanceResponse_client_stats_report_interval(msg); + if (sub == NULL) { + sub = (struct google_protobuf_Duration*)upb_msg_new(&google_protobuf_Duration_msginit, arena); + if (!sub) return NULL; + grpc_lb_v1_InitialLoadBalanceResponse_set_client_stats_report_interval(msg, sub); + } + return sub; +} + +/* grpc.lb.v1.ServerList */ + +UPB_INLINE grpc_lb_v1_ServerList *grpc_lb_v1_ServerList_new(upb_arena *arena) { + return (grpc_lb_v1_ServerList *)upb_msg_new(&grpc_lb_v1_ServerList_msginit, arena); +} +UPB_INLINE grpc_lb_v1_ServerList *grpc_lb_v1_ServerList_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_lb_v1_ServerList *ret = grpc_lb_v1_ServerList_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_lb_v1_ServerList_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_lb_v1_ServerList_serialize(const grpc_lb_v1_ServerList *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_lb_v1_ServerList_msginit, arena, len); +} + +UPB_INLINE const grpc_lb_v1_Server* const* grpc_lb_v1_ServerList_servers(const grpc_lb_v1_ServerList *msg, size_t *len) { return (const grpc_lb_v1_Server* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); } + +UPB_INLINE grpc_lb_v1_Server** grpc_lb_v1_ServerList_mutable_servers(grpc_lb_v1_ServerList *msg, size_t *len) { + return (grpc_lb_v1_Server**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len); +} +UPB_INLINE grpc_lb_v1_Server** grpc_lb_v1_ServerList_resize_servers(grpc_lb_v1_ServerList *msg, size_t len, upb_arena *arena) { + return (grpc_lb_v1_Server**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct grpc_lb_v1_Server* grpc_lb_v1_ServerList_add_servers(grpc_lb_v1_ServerList *msg, upb_arena *arena) { + struct grpc_lb_v1_Server* sub = (struct grpc_lb_v1_Server*)upb_msg_new(&grpc_lb_v1_Server_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} + +/* grpc.lb.v1.Server */ + +UPB_INLINE grpc_lb_v1_Server *grpc_lb_v1_Server_new(upb_arena *arena) { + return (grpc_lb_v1_Server *)upb_msg_new(&grpc_lb_v1_Server_msginit, arena); +} +UPB_INLINE grpc_lb_v1_Server *grpc_lb_v1_Server_parse(const char *buf, size_t size, + upb_arena *arena) { + grpc_lb_v1_Server *ret = grpc_lb_v1_Server_new(arena); + return (ret && upb_decode(buf, size, ret, &grpc_lb_v1_Server_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *grpc_lb_v1_Server_serialize(const grpc_lb_v1_Server *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &grpc_lb_v1_Server_msginit, arena, len); +} + +UPB_INLINE upb_strview grpc_lb_v1_Server_ip_address(const grpc_lb_v1_Server *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)); } +UPB_INLINE int32_t grpc_lb_v1_Server_port(const grpc_lb_v1_Server *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)); } +UPB_INLINE upb_strview grpc_lb_v1_Server_load_balance_token(const grpc_lb_v1_Server *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(16, 24)); } +UPB_INLINE bool grpc_lb_v1_Server_drop(const grpc_lb_v1_Server *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(4, 4)); } + +UPB_INLINE void grpc_lb_v1_Server_set_ip_address(grpc_lb_v1_Server *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)) = value; +} +UPB_INLINE void grpc_lb_v1_Server_set_port(grpc_lb_v1_Server *msg, int32_t value) { + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE void grpc_lb_v1_Server_set_load_balance_token(grpc_lb_v1_Server *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(16, 24)) = value; +} +UPB_INLINE void grpc_lb_v1_Server_set_drop(grpc_lb_v1_Server *msg, bool value) { + UPB_FIELD_AT(msg, bool, UPB_SIZE(4, 4)) = value; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#include "upb/port_undef.inc" + +#endif /* GRPC_LB_V1_LOAD_BALANCER_PROTO_UPB_H_ */ diff --git a/src/proto/grpc/gcp/BUILD b/src/proto/grpc/gcp/BUILD new file mode 100644 index 00000000000..1c22d89e464 --- /dev/null +++ b/src/proto/grpc/gcp/BUILD @@ -0,0 +1,25 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +licenses(["notice"]) # Apache v2 + +proto_library( + name = "alts_handshaker_proto", + srcs = [ + "altscontext.proto", + "handshaker.proto", + "transport_security_common.proto", + ], + visibility = ["//visibility:public"], +) diff --git a/src/proto/grpc/gcp/altscontext.proto b/src/proto/grpc/gcp/altscontext.proto new file mode 100644 index 00000000000..cce6dd2afc5 --- /dev/null +++ b/src/proto/grpc/gcp/altscontext.proto @@ -0,0 +1,50 @@ +// Copyright 2018 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// The canonical version of this proto can be found at +// https://github.com/grpc/grpc-proto/blob/master/grpc/gcp/altscontext.proto + +syntax = "proto3"; + +package grpc.gcp; + +import "src/proto/grpc/gcp/transport_security_common.proto"; + +option go_package = "google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp"; +option java_multiple_files = true; +option java_outer_classname = "AltsContextProto"; +option java_package = "io.grpc.alts.internal"; + +message AltsContext { + // The application protocol negotiated for this connection. + string application_protocol = 1; + + // The record protocol negotiated for this connection. + string record_protocol = 2; + + // The security level of the created secure channel. + SecurityLevel security_level = 3; + + // The peer service account. + string peer_service_account = 4; + + // The local service account. + string local_service_account = 5; + + // The RPC protocol versions supported by the peer. + RpcProtocolVersions peer_rpc_versions = 6; + + // Additional attributes of the peer. + map peer_attributes = 7; +} diff --git a/src/proto/grpc/gcp/handshaker.proto b/src/proto/grpc/gcp/handshaker.proto new file mode 100644 index 00000000000..702945f5795 --- /dev/null +++ b/src/proto/grpc/gcp/handshaker.proto @@ -0,0 +1,234 @@ +// Copyright 2018 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// The canonical version of this proto can be found at +// https://github.com/grpc/grpc-proto/blob/master/grpc/gcp/handshaker.proto + +syntax = "proto3"; + +package grpc.gcp; + +import "src/proto/grpc/gcp/transport_security_common.proto"; + +option go_package = "google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp"; +option java_multiple_files = true; +option java_outer_classname = "HandshakerProto"; +option java_package = "io.grpc.alts.internal"; + + +enum HandshakeProtocol { + // Default value. + HANDSHAKE_PROTOCOL_UNSPECIFIED = 0; + + // TLS handshake protocol. + TLS = 1; + + // Application Layer Transport Security handshake protocol. + ALTS = 2; +} + +enum NetworkProtocol { + NETWORK_PROTOCOL_UNSPECIFIED = 0; + TCP = 1; + UDP = 2; +} + +message Endpoint { + // IP address. It should contain an IPv4 or IPv6 string literal, e.g. + // "192.168.0.1" or "2001:db8::1". + string ip_address = 1; + + // Port number. + int32 port = 2; + + // Network protocol (e.g., TCP, UDP) associated with this endpoint. + NetworkProtocol protocol = 3; +} + +message Identity { + oneof identity_oneof { + // Service account of a connection endpoint. + string service_account = 1; + + // Hostname of a connection endpoint. + string hostname = 2; + } + + // Additional attributes of the identity. + map attributes = 3; +} + +message StartClientHandshakeReq { + // Handshake security protocol requested by the client. + HandshakeProtocol handshake_security_protocol = 1; + + // The application protocols supported by the client, e.g., "h2" (for http2), + // "grpc". + repeated string application_protocols = 2; + + // The record protocols supported by the client, e.g., + // "ALTSRP_GCM_AES128". + repeated string record_protocols = 3; + + // (Optional) Describes which server identities are acceptable by the client. + // If target identities are provided and none of them matches the peer + // identity of the server, handshake will fail. + repeated Identity target_identities = 4; + + // (Optional) Application may specify a local identity. Otherwise, the + // handshaker chooses a default local identity. + Identity local_identity = 5; + + // (Optional) Local endpoint information of the connection to the server, + // such as local IP address, port number, and network protocol. + Endpoint local_endpoint = 6; + + // (Optional) Endpoint information of the remote server, such as IP address, + // port number, and network protocol. + Endpoint remote_endpoint = 7; + + // (Optional) If target name is provided, a secure naming check is performed + // to verify that the peer authenticated identity is indeed authorized to run + // the target name. + string target_name = 8; + + // (Optional) RPC protocol versions supported by the client. + RpcProtocolVersions rpc_versions = 9; +} + +message ServerHandshakeParameters { + // The record protocols supported by the server, e.g., + // "ALTSRP_GCM_AES128". + repeated string record_protocols = 1; + + // (Optional) A list of local identities supported by the server, if + // specified. Otherwise, the handshaker chooses a default local identity. + repeated Identity local_identities = 2; +} + +message StartServerHandshakeReq { + // The application protocols supported by the server, e.g., "h2" (for http2), + // "grpc". + repeated string application_protocols = 1; + + // Handshake parameters (record protocols and local identities supported by + // the server) mapped by the handshake protocol. Each handshake security + // protocol (e.g., TLS or ALTS) has its own set of record protocols and local + // identities. Since protobuf does not support enum as key to the map, the key + // to handshake_parameters is the integer value of HandshakeProtocol enum. + map handshake_parameters = 2; + + // Bytes in out_frames returned from the peer's HandshakerResp. It is possible + // that the peer's out_frames are split into multiple HandshakReq messages. + bytes in_bytes = 3; + + // (Optional) Local endpoint information of the connection to the client, + // such as local IP address, port number, and network protocol. + Endpoint local_endpoint = 4; + + // (Optional) Endpoint information of the remote client, such as IP address, + // port number, and network protocol. + Endpoint remote_endpoint = 5; + + // (Optional) RPC protocol versions supported by the server. + RpcProtocolVersions rpc_versions = 6; +} + +message NextHandshakeMessageReq { + // Bytes in out_frames returned from the peer's HandshakerResp. It is possible + // that the peer's out_frames are split into multiple NextHandshakerMessageReq + // messages. + bytes in_bytes = 1; +} + +message HandshakerReq { + oneof req_oneof { + // The start client handshake request message. + StartClientHandshakeReq client_start = 1; + + // The start server handshake request message. + StartServerHandshakeReq server_start = 2; + + // The next handshake request message. + NextHandshakeMessageReq next = 3; + } +} + +message HandshakerResult { + // The application protocol negotiated for this connection. + string application_protocol = 1; + + // The record protocol negotiated for this connection. + string record_protocol = 2; + + // Cryptographic key data. The key data may be more than the key length + // required for the record protocol, thus the client of the handshaker + // service needs to truncate the key data into the right key length. + bytes key_data = 3; + + // The authenticated identity of the peer. + Identity peer_identity = 4; + + // The local identity used in the handshake. + Identity local_identity = 5; + + // Indicate whether the handshaker service client should keep the channel + // between the handshaker service open, e.g., in order to handle + // post-handshake messages in the future. + bool keep_channel_open = 6; + + // The RPC protocol versions supported by the peer. + RpcProtocolVersions peer_rpc_versions = 7; +} + +message HandshakerStatus { + // The status code. This could be the gRPC status code. + uint32 code = 1; + + // The status details. + string details = 2; +} + +message HandshakerResp { + // Frames to be given to the peer for the NextHandshakeMessageReq. May be + // empty if no out_frames have to be sent to the peer or if in_bytes in the + // HandshakerReq are incomplete. All the non-empty out frames must be sent to + // the peer even if the handshaker status is not OK as these frames may + // contain the alert frames. + bytes out_frames = 1; + + // Number of bytes in the in_bytes consumed by the handshaker. It is possible + // that part of in_bytes in HandshakerReq was unrelated to the handshake + // process. + uint32 bytes_consumed = 2; + + // This is set iff the handshake was successful. out_frames may still be set + // to frames that needs to be forwarded to the peer. + HandshakerResult result = 3; + + // Status of the handshaker. + HandshakerStatus status = 4; +} + +service HandshakerService { + // Handshaker service accepts a stream of handshaker request, returning a + // stream of handshaker response. Client is expected to send exactly one + // message with either client_start or server_start followed by one or more + // messages with next. Each time client sends a request, the handshaker + // service expects to respond. Client does not have to wait for service's + // response before sending next request. + rpc DoHandshake(stream HandshakerReq) + returns (stream HandshakerResp) { + } +} diff --git a/src/proto/grpc/gcp/transport_security_common.proto b/src/proto/grpc/gcp/transport_security_common.proto new file mode 100644 index 00000000000..8f01be79e36 --- /dev/null +++ b/src/proto/grpc/gcp/transport_security_common.proto @@ -0,0 +1,46 @@ +// Copyright 2018 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// The canonical version of this proto can be found at +// https://github.com/grpc/grpc-proto/blob/master/grpc/gcp/transport_security_common.proto + +syntax = "proto3"; + +package grpc.gcp; + +option go_package = "google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp"; +option java_multiple_files = true; +option java_outer_classname = "TransportSecurityCommonProto"; +option java_package = "io.grpc.alts.internal"; + +// The security level of the created channel. The list is sorted in increasing +// level of security. This order must always be maintained. +enum SecurityLevel { + SECURITY_NONE = 0; + INTEGRITY_ONLY = 1; + INTEGRITY_AND_PRIVACY = 2; +} + +// Max and min supported RPC protocol versions. +message RpcProtocolVersions { + // RPC version contains a major version and a minor version. + message Version { + uint32 major = 1; + uint32 minor = 2; + } + // Maximum supported RPC version. + Version max_rpc_version = 1; + // Minimum supported RPC version. + Version min_rpc_version = 2; +} diff --git a/src/proto/grpc/lb/v1/BUILD b/src/proto/grpc/lb/v1/BUILD index fd01f847fd5..2a6e82a57e7 100644 --- a/src/proto/grpc/lb/v1/BUILD +++ b/src/proto/grpc/lb/v1/BUILD @@ -29,6 +29,15 @@ grpc_proto_library( well_known_protos = True, ) +proto_library( + name = "load_balancer_proto_descriptor", + srcs = ["load_balancer.proto"], + deps = [ + "@com_google_protobuf//:duration_proto", + "@com_google_protobuf//:timestamp_proto", + ], +) + grpc_proto_library( name = "load_reporter_proto", srcs = ["load_reporter.proto"], diff --git a/tools/codegen/core/gen_upb_api.sh b/tools/codegen/core/gen_upb_api.sh index 4dbc4bbec3e..710039b0157 100755 --- a/tools/codegen/core/gen_upb_api.sh +++ b/tools/codegen/core/gen_upb_api.sh @@ -16,15 +16,41 @@ # REQUIRES: Bazel set -ex -rm -rf src/core/ext/upb-generated -mkdir src/core/ext/upb-generated -cd third_party -cd upb -bazel build :protoc-gen-upb -cd ../.. +pushd third_party/protobuf +bazel build :protoc +PROTOC=$PWD/bazel-bin/protoc +popd + +pushd third_party/upb +bazel build :protoc-gen-upb +UPB_PLUGIN=$PWD/bazel-bin/protoc-gen-upb +popd + +UPB_OUTPUT_DIR=$PWD/src/core/ext/upb-generated +rm -rf $UPB_OUTPUT_DIR +mkdir $UPB_OUTPUT_DIR proto_files=( \ + "envoy/api/v2/auth/cert.proto" \ + "envoy/api/v2/cds.proto" \ + "envoy/api/v2/cluster/circuit_breaker.proto" \ + "envoy/api/v2/cluster/outlier_detection.proto" \ + "envoy/api/v2/core/address.proto" \ + "envoy/api/v2/core/base.proto" \ + "envoy/api/v2/core/config_source.proto" \ + "envoy/api/v2/core/grpc_service.proto" \ + "envoy/api/v2/core/health_check.proto" \ + "envoy/api/v2/core/protocol.proto" \ + "envoy/api/v2/discovery.proto" \ + "envoy/api/v2/eds.proto" \ + "envoy/api/v2/endpoint/endpoint.proto" \ + "envoy/api/v2/endpoint/load_report.proto" \ + "envoy/service/discovery/v2/ads.proto" \ + "envoy/service/load_stats/v2/lrs.proto" \ + "envoy/type/percent.proto" \ + "envoy/type/range.proto" \ + "gogoproto/gogo.proto" \ "google/api/annotations.proto" \ "google/api/http.proto" \ "google/protobuf/any.proto" \ @@ -35,28 +61,26 @@ proto_files=( \ "google/protobuf/timestamp.proto" \ "google/protobuf/wrappers.proto" \ "google/rpc/status.proto" \ - "gogoproto/gogo.proto" \ - "validate/validate.proto" \ - "envoy/type/percent.proto" \ - "envoy/type/range.proto" \ - "envoy/api/v2/core/address.proto" \ - "envoy/api/v2/core/base.proto" \ - "envoy/api/v2/core/config_source.proto" \ - "envoy/api/v2/core/grpc_service.proto" \ - "envoy/api/v2/core/health_check.proto" \ - "envoy/api/v2/core/protocol.proto" \ - "envoy/api/v2/auth/cert.proto" \ - "envoy/api/v2/cluster/circuit_breaker.proto" \ - "envoy/api/v2/cluster/outlier_detection.proto" \ - "envoy/api/v2/discovery.proto" \ - "envoy/api/v2/cds.proto" \ - "envoy/api/v2/eds.proto" \ - "envoy/api/v2/endpoint/endpoint.proto" \ - "envoy/api/v2/endpoint/load_report.proto" \ - "envoy/service/discovery/v2/ads.proto" \ - "envoy/service/load_stats/v2/lrs.proto") + "grpc/gcp/altscontext.proto" \ + "grpc/gcp/handshaker.proto" \ + "grpc/gcp/transport_security_common.proto" \ + "grpc/health/v1/health.proto" \ + "grpc/lb/v1/load_balancer.proto" \ + "validate/validate.proto") for i in "${proto_files[@]}" do - protoc -I=$PWD/third_party/envoy-api -I=$PWD/third_party/googleapis -I=$PWD/third_party/protobuf -I=$PWD/third_party/protoc-gen-validate $i --upb_out=./src/core/ext/upb-generated --plugin=protoc-gen-upb=third_party/upb/bazel-bin/protoc-gen-upb + $PROTOC \ + -I=$PWD/third_party/envoy-api \ + -I=$PWD/third_party/googleapis \ + -I=$PWD/third_party/protobuf/src \ + -I=$PWD/third_party/protoc-gen-validate \ + -I=$PWD/src/proto \ + -I=$PWD \ + $i \ + --upb_out=$UPB_OUTPUT_DIR \ + --plugin=protoc-gen-upb=$UPB_PLUGIN done + +find $UPB_OUTPUT_DIR -name "*.upbdefs.c" -type f -delete +find $UPB_OUTPUT_DIR -name "*.upbdefs.h" -type f -delete diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index d19ce06db5c..7cc164693e2 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -8185,6 +8185,27 @@ "third_party": false, "type": "filegroup" }, + { + "deps": [], + "headers": [ + "src/core/ext/upb-generated/altscontext.upb.h", + "src/core/ext/upb-generated/handshaker.upb.h", + "src/core/ext/upb-generated/transport_security_common.upb.h" + ], + "is_filegroup": true, + "language": "c", + "name": "alts_upb", + "src": [ + "src/core/ext/upb-generated/altscontext.upb.c", + "src/core/ext/upb-generated/altscontext.upb.h", + "src/core/ext/upb-generated/handshaker.upb.c", + "src/core/ext/upb-generated/handshaker.upb.h", + "src/core/ext/upb-generated/transport_security_common.upb.c", + "src/core/ext/upb-generated/transport_security_common.upb.h" + ], + "third_party": false, + "type": "filegroup" + }, { "deps": [ "alts_proto", @@ -8263,6 +8284,39 @@ "third_party": false, "type": "filegroup" }, + { + "deps": [], + "headers": [ + "src/core/ext/upb-generated/google/protobuf/any.upb.h", + "src/core/ext/upb-generated/google/protobuf/descriptor.upb.h", + "src/core/ext/upb-generated/google/protobuf/duration.upb.h", + "src/core/ext/upb-generated/google/protobuf/empty.upb.h", + "src/core/ext/upb-generated/google/protobuf/struct.upb.h", + "src/core/ext/upb-generated/google/protobuf/timestamp.upb.h", + "src/core/ext/upb-generated/google/protobuf/wrappers.upb.h" + ], + "is_filegroup": true, + "language": "c", + "name": "google_api_upb", + "src": [ + "src/core/ext/upb-generated/google/protobuf/any.upb.c", + "src/core/ext/upb-generated/google/protobuf/any.upb.h", + "src/core/ext/upb-generated/google/protobuf/descriptor.upb.c", + "src/core/ext/upb-generated/google/protobuf/descriptor.upb.h", + "src/core/ext/upb-generated/google/protobuf/duration.upb.c", + "src/core/ext/upb-generated/google/protobuf/duration.upb.h", + "src/core/ext/upb-generated/google/protobuf/empty.upb.c", + "src/core/ext/upb-generated/google/protobuf/empty.upb.h", + "src/core/ext/upb-generated/google/protobuf/struct.upb.c", + "src/core/ext/upb-generated/google/protobuf/struct.upb.h", + "src/core/ext/upb-generated/google/protobuf/timestamp.upb.c", + "src/core/ext/upb-generated/google/protobuf/timestamp.upb.h", + "src/core/ext/upb-generated/google/protobuf/wrappers.upb.c", + "src/core/ext/upb-generated/google/protobuf/wrappers.upb.h" + ], + "third_party": false, + "type": "filegroup" + }, { "deps": [ "gpr_base_headers" @@ -9173,6 +9227,21 @@ "third_party": false, "type": "filegroup" }, + { + "deps": [], + "headers": [ + "src/core/ext/upb-generated/grpc/health/v1/health.upb.c" + ], + "is_filegroup": true, + "language": "c", + "name": "grpc_health_upb", + "src": [ + "src/core/ext/upb-generated/grpc/health/v1/health.upb.c", + "src/core/ext/upb-generated/grpc/health/v1/health.upb.h" + ], + "third_party": false, + "type": "filegroup" + }, { "deps": [ "gpr", @@ -9382,6 +9451,23 @@ "third_party": false, "type": "filegroup" }, + { + "deps": [ + "google_api_upb" + ], + "headers": [ + "src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.h" + ], + "is_filegroup": true, + "language": "c", + "name": "grpc_lb_upb", + "src": [ + "src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.c", + "src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.h" + ], + "third_party": false, + "type": "filegroup" + }, { "deps": [ "gpr", From c914fbbc1d9be8030e76d07a005927a63109fc61 Mon Sep 17 00:00:00 2001 From: Lev Pachmanov Date: Fri, 26 Jul 2019 19:49:57 +0300 Subject: [PATCH 1006/1555] catch the error if socket initialization fails --- src/core/lib/iomgr/tcp_server_custom.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/tcp_server_custom.cc b/src/core/lib/iomgr/tcp_server_custom.cc index 767404be21d..61b307fc4c0 100644 --- a/src/core/lib/iomgr/tcp_server_custom.cc +++ b/src/core/lib/iomgr/tcp_server_custom.cc @@ -391,7 +391,7 @@ static grpc_error* tcp_server_add_port(grpc_tcp_server* s, socket->endpoint = nullptr; socket->listener = nullptr; socket->connector = nullptr; - grpc_custom_socket_vtable->init(socket, family); + error = grpc_custom_socket_vtable->init(socket, family); if (error == GRPC_ERROR_NONE) { error = add_socket_to_server(s, socket, addr, port_index, &sp); From 39bc63c88cc362b45869e402b2a0383caae3c79e Mon Sep 17 00:00:00 2001 From: Qiancheng Zhao Date: Fri, 26 Jul 2019 09:59:57 -0700 Subject: [PATCH 1007/1555] change memory order of operations on disconnect_error_ in client_channel --- src/core/ext/filters/client_channel/client_channel.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 4cbd52a486a..c06e995f5a5 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -1717,10 +1717,10 @@ void ChannelData::StartTransportOpLocked(void* arg, grpc_error* ignored) { GRPC_ERROR_UNREF(op->disconnect_with_error); } else { // Disconnect. - grpc_error* error = GRPC_ERROR_NONE; - GPR_ASSERT(chand->disconnect_error_.CompareExchangeStrong( - &error, op->disconnect_with_error, MemoryOrder::ACQ_REL, - MemoryOrder::ACQUIRE)); + GPR_ASSERT(chand->disconnect_error_.Load(MemoryOrder::RELAXED) == + GRPC_ERROR_NONE); + chand->disconnect_error_.Store(op->disconnect_with_error, + MemoryOrder::RELEASE); New( chand, GRPC_CHANNEL_SHUTDOWN, "shutdown from API", UniquePtr( From 79b0530dce58e245c7cb0d0d5d7b017924237e02 Mon Sep 17 00:00:00 2001 From: Qiancheng Zhao Date: Fri, 26 Jul 2019 10:29:57 -0700 Subject: [PATCH 1008/1555] fix typo in max_age_filter.cc --- src/core/ext/filters/max_age/max_age_filter.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/ext/filters/max_age/max_age_filter.cc b/src/core/ext/filters/max_age/max_age_filter.cc index c8823cc5c6a..96f2f02056f 100644 --- a/src/core/ext/filters/max_age/max_age_filter.cc +++ b/src/core/ext/filters/max_age/max_age_filter.cc @@ -122,8 +122,8 @@ struct channel_data { MAX_IDLE_STATE_SEEN_ENTER_IDLE: The state after the timer is set and the at least one call has arrived after the timer is set, BUT the channel - currently has 1 or 1+ active calls. If the timer is fired in this state, we - will reschudle it. + currently has 0 active calls. If the timer is fired in this state, we will + reschudle it. max_idle_timer will not be cancelled (unless the channel is shutting down). If the timer callback is called when the max_idle_timer is valid (i.e. From e6d58923dfa42c3e55faf4b6d649068b9d8fd678 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 26 Jul 2019 14:29:42 -0700 Subject: [PATCH 1009/1555] Add a detection of missing file in filegroup.uses --- tools/buildgen/plugins/expand_filegroups.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/buildgen/plugins/expand_filegroups.py b/tools/buildgen/plugins/expand_filegroups.py index 99d9463b3f9..99e33332c85 100755 --- a/tools/buildgen/plugins/expand_filegroups.py +++ b/tools/buildgen/plugins/expand_filegroups.py @@ -55,6 +55,7 @@ def mako_plugin(dictionary): libs = dictionary.get('libs') targets = dictionary.get('targets') filegroups_list = dictionary.get('filegroups') + filegroups_set = set(fg['name'] for fg in filegroups_list) filegroups = {} for fg in filegroups_list: @@ -78,8 +79,10 @@ def mako_plugin(dictionary): todo = todo[1:] # check all uses filegroups are present (if no, skip and come back later) skip = False - for uses in cur.get('uses', []): - if uses not in filegroups: + for use in cur.get('uses', []): + assert use in filegroups_set, ( + "filegroup(%s) uses non-existent %s" % (cur['name'], use)) + if use not in filegroups: skip = True if skip: skips += 1 From 44de9634f6d4e5797cb6cd786c2160d16fe7b2d7 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 26 Jul 2019 15:41:29 -0700 Subject: [PATCH 1010/1555] Update third_party/upb to the latest --- bazel/grpc_deps.bzl | 6 +++--- third_party/upb | 2 +- tools/run_tests/sanity/check_submodules.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 5ad1b92900b..b8df184f734 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -206,9 +206,9 @@ def grpc_deps(): if "upb" not in native.existing_rules(): http_archive( name = "upb", - sha256 = "1107ca1ea9aef3880b60ffb2179d06970394f1d6b62d0565e72b544b4924468d", - strip_prefix = "upb-1ee1e362565f681fdd46f16bf9f70f51c905ddd4", - url = "https://github.com/protocolbuffers/upb/archive/1ee1e362565f681fdd46f16bf9f70f51c905ddd4.tar.gz", + sha256 = "73deded75313f80779eba109c32f3c59a813addf5064bf6e7c213fca1e7d8e32", + strip_prefix = "upb-423ea5ca9ce8da69611e6e95559efcb3a1ba8ad8", + url = "https://github.com/protocolbuffers/upb/archive/423ea5ca9ce8da69611e6e95559efcb3a1ba8ad8.tar.gz", ) if "envoy_api" not in native.existing_rules(): http_archive( diff --git a/third_party/upb b/third_party/upb index 1ee1e362565..423ea5ca9ce 160000 --- a/third_party/upb +++ b/third_party/upb @@ -1 +1 @@ -Subproject commit 1ee1e362565f681fdd46f16bf9f70f51c905ddd4 +Subproject commit 423ea5ca9ce8da69611e6e95559efcb3a1ba8ad8 diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index 977b4be2c2f..e518e912719 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -40,7 +40,7 @@ cat << EOF | awk '{ print $1 }' | sort > "$want_submodules" 9245d481eb3e890f708ff2d7dadf2a10c04748ba third_party/libcxxabi (heads/release_60) 09745575a923640154bcf307fba8aedff47f240a third_party/protobuf (v3.7.0-rc.2-247-g09745575) e143189bf6f37b3957fb31743df6a1bcf4a8c685 third_party/protoc-gen-validate (v0.0.10) - 1ee1e362565f681fdd46f16bf9f70f51c905ddd4 third_party/upb (heads/master) + 423ea5ca9ce8da69611e6e95559efcb3a1ba8ad8 third_party/upb (heads/master) cacf7f1d4e3d44d871b605da3b647f07d718623f third_party/zlib (v1.2.11) EOF From c3de8448ea3460184d769e99c99507e050ffcb96 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Fri, 26 Jul 2019 16:49:05 -0700 Subject: [PATCH 1011/1555] Reverting projct.pbxproj --- .../project.pbxproj | 36 +- .../Sample/Sample.xcodeproj/project.pbxproj | 122 +++-- .../SwiftSample.xcodeproj/project.pbxproj | 77 ++-- .../tests/Tests.xcodeproj/project.pbxproj | 415 ++++++++++++------ 4 files changed, 401 insertions(+), 249 deletions(-) diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj b/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj index b3f9d0500e5..8b8811d4c62 100644 --- a/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample.xcodeproj/project.pbxproj @@ -3,10 +3,11 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 50; objects = { /* Begin PBXBuildFile section */ + 1C4854A76EEB56F8096DBDEF /* libPods-InterceptorSample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CB7A7A5B91FC976FCF4637AE /* libPods-InterceptorSample.a */; }; 5EE960FB2266768A0044A74F /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE960FA2266768A0044A74F /* AppDelegate.m */; }; 5EE960FE2266768A0044A74F /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE960FD2266768A0044A74F /* ViewController.m */; }; 5EE961012266768A0044A74F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5EE960FF2266768A0044A74F /* Main.storyboard */; }; @@ -14,11 +15,10 @@ 5EE961062266768C0044A74F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5EE961042266768C0044A74F /* LaunchScreen.storyboard */; }; 5EE961092266768C0044A74F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE961082266768C0044A74F /* main.m */; }; 5EE9611222668CF20044A74F /* CacheInterceptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE9611122668CF20044A74F /* CacheInterceptor.m */; }; - 9F142CE7AFDA64BD5AEE9849 /* libPods-InterceptorSample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B8FBA9621C9B11B3AC233A96 /* libPods-InterceptorSample.a */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 18F2D91B047D36868BCD504B /* Pods-InterceptorSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InterceptorSample.release.xcconfig"; path = "Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample.release.xcconfig"; sourceTree = ""; }; + 09457A264AAE5323BF50B1F8 /* Pods-InterceptorSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InterceptorSample.debug.xcconfig"; path = "Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample.debug.xcconfig"; sourceTree = ""; }; 5EE960F62266768A0044A74F /* InterceptorSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = InterceptorSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 5EE960FA2266768A0044A74F /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 5EE960FC2266768A0044A74F /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; @@ -31,8 +31,8 @@ 5EE9610F2266774C0044A74F /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 5EE9611022668CE20044A74F /* CacheInterceptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CacheInterceptor.h; sourceTree = ""; }; 5EE9611122668CF20044A74F /* CacheInterceptor.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CacheInterceptor.m; sourceTree = ""; }; - AD256CCFA3FE501D3D876F1D /* Pods-InterceptorSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InterceptorSample.debug.xcconfig"; path = "Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample.debug.xcconfig"; sourceTree = ""; }; - B8FBA9621C9B11B3AC233A96 /* libPods-InterceptorSample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InterceptorSample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + A0789280A4035D0F22F96BE6 /* Pods-InterceptorSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InterceptorSample.release.xcconfig"; path = "Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample.release.xcconfig"; sourceTree = ""; }; + CB7A7A5B91FC976FCF4637AE /* libPods-InterceptorSample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InterceptorSample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -40,7 +40,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 9F142CE7AFDA64BD5AEE9849 /* libPods-InterceptorSample.a in Frameworks */, + 1C4854A76EEB56F8096DBDEF /* libPods-InterceptorSample.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -53,7 +53,7 @@ 5EE960F82266768A0044A74F /* InterceptorSample */, 5EE960F72266768A0044A74F /* Products */, 9D49DB75F3BEDAFDE7028B51 /* Pods */, - B3868CDC20EB754A8D582F03 /* Frameworks */, + BD7184728351C7DDAFBA5FA2 /* Frameworks */, ); sourceTree = ""; }; @@ -86,16 +86,16 @@ 9D49DB75F3BEDAFDE7028B51 /* Pods */ = { isa = PBXGroup; children = ( - AD256CCFA3FE501D3D876F1D /* Pods-InterceptorSample.debug.xcconfig */, - 18F2D91B047D36868BCD504B /* Pods-InterceptorSample.release.xcconfig */, + 09457A264AAE5323BF50B1F8 /* Pods-InterceptorSample.debug.xcconfig */, + A0789280A4035D0F22F96BE6 /* Pods-InterceptorSample.release.xcconfig */, ); path = Pods; sourceTree = ""; }; - B3868CDC20EB754A8D582F03 /* Frameworks */ = { + BD7184728351C7DDAFBA5FA2 /* Frameworks */ = { isa = PBXGroup; children = ( - B8FBA9621C9B11B3AC233A96 /* libPods-InterceptorSample.a */, + CB7A7A5B91FC976FCF4637AE /* libPods-InterceptorSample.a */, ); name = Frameworks; sourceTree = ""; @@ -107,11 +107,11 @@ isa = PBXNativeTarget; buildConfigurationList = 5EE9610C2266768C0044A74F /* Build configuration list for PBXNativeTarget "InterceptorSample" */; buildPhases = ( - D31C16F578D4BF95F5638778 /* [CP] Check Pods Manifest.lock */, + 7531607F028A04DAAF5E97B5 /* [CP] Check Pods Manifest.lock */, 5EE960F22266768A0044A74F /* Sources */, 5EE960F32266768A0044A74F /* Frameworks */, 5EE960F42266768A0044A74F /* Resources */, - 45857CF606BB268EB3BC476F /* [CP] Copy Pods Resources */, + 17700C95BAEBB27F7A3D1B01 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -168,7 +168,7 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 45857CF606BB268EB3BC476F /* [CP] Copy Pods Resources */ = { + 17700C95BAEBB27F7A3D1B01 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -185,7 +185,7 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InterceptorSample/Pods-InterceptorSample-resources.sh\"\n"; showEnvVarsInLog = 0; }; - D31C16F578D4BF95F5638778 /* [CP] Check Pods Manifest.lock */ = { + 7531607F028A04DAAF5E97B5 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -357,7 +357,7 @@ }; 5EE9610D2266768C0044A74F /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = AD256CCFA3FE501D3D876F1D /* Pods-InterceptorSample.debug.xcconfig */; + baseConfigurationReference = 09457A264AAE5323BF50B1F8 /* Pods-InterceptorSample.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; @@ -369,13 +369,12 @@ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InterceptorSample; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; - USER_HEADER_SEARCH_PATHS = ""; }; name = Debug; }; 5EE9610E2266768C0044A74F /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 18F2D91B047D36868BCD504B /* Pods-InterceptorSample.release.xcconfig */; + baseConfigurationReference = A0789280A4035D0F22F96BE6 /* Pods-InterceptorSample.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; @@ -387,7 +386,6 @@ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InterceptorSample; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; - USER_HEADER_SEARCH_PATHS = ""; }; name = Release; }; diff --git a/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj b/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj index efb4835eb8d..cdd1c6c8f7e 100644 --- a/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj @@ -7,15 +7,16 @@ objects = { /* Begin PBXBuildFile section */ + 3F035697392F601049D3DDE1 /* Pods_Sample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC1B27EA0C428429B07BC34B /* Pods_Sample.framework */; }; 6369A2701A9322E20015FC5C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6369A26F1A9322E20015FC5C /* main.m */; }; 6369A2731A9322E20015FC5C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6369A2721A9322E20015FC5C /* AppDelegate.m */; }; 6369A2761A9322E20015FC5C /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6369A2751A9322E20015FC5C /* ViewController.m */; }; 6369A2791A9322E20015FC5C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6369A2771A9322E20015FC5C /* Main.storyboard */; }; 6369A27B1A9322E20015FC5C /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6369A27A1A9322E20015FC5C /* Images.xcassets */; }; - 983179392696210F31F36D26 /* Pods_Sample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CCD4500A079C9D59E6CC5062 /* Pods_Sample.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 5A8C9F4B28733B249DE4AB6D /* Pods-Sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.release.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.release.xcconfig"; sourceTree = ""; }; 6369A26A1A9322E20015FC5C /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 6369A26E1A9322E20015FC5C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 6369A26F1A9322E20015FC5C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -25,9 +26,8 @@ 6369A2751A9322E20015FC5C /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 6369A2781A9322E20015FC5C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 6369A27A1A9322E20015FC5C /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; - 7544F97DDF1CB3F915E41CB9 /* Pods-Sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.debug.xcconfig"; path = "Target Support Files/Pods-Sample/Pods-Sample.debug.xcconfig"; sourceTree = ""; }; - 8BDAC28EF9131C53B2E6870D /* Pods-Sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.release.xcconfig"; path = "Target Support Files/Pods-Sample/Pods-Sample.release.xcconfig"; sourceTree = ""; }; - CCD4500A079C9D59E6CC5062 /* Pods_Sample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Sample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + CC1B27EA0C428429B07BC34B /* Pods_Sample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Sample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + E3C01DF315C4E7433BCEC6E6 /* Pods-Sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -35,28 +35,20 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 983179392696210F31F36D26 /* Pods_Sample.framework in Frameworks */, + 3F035697392F601049D3DDE1 /* Pods_Sample.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 14C78F05D9C5E2D5F426D233 /* Frameworks */ = { - isa = PBXGroup; - children = ( - CCD4500A079C9D59E6CC5062 /* Pods_Sample.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; 6369A2611A9322E20015FC5C = { isa = PBXGroup; children = ( 6369A26C1A9322E20015FC5C /* Sample */, 6369A26B1A9322E20015FC5C /* Products */, - 9A3B057E55DE3C4F4A543CC5 /* Pods */, - 14C78F05D9C5E2D5F426D233 /* Frameworks */, + AB3331C9AE6488E61B2B094E /* Pods */, + C4C2C5219053E079C9EFB930 /* Frameworks */, ); sourceTree = ""; }; @@ -91,13 +83,21 @@ name = "Supporting Files"; sourceTree = ""; }; - 9A3B057E55DE3C4F4A543CC5 /* Pods */ = { + AB3331C9AE6488E61B2B094E /* Pods */ = { isa = PBXGroup; children = ( - 7544F97DDF1CB3F915E41CB9 /* Pods-Sample.debug.xcconfig */, - 8BDAC28EF9131C53B2E6870D /* Pods-Sample.release.xcconfig */, + E3C01DF315C4E7433BCEC6E6 /* Pods-Sample.debug.xcconfig */, + 5A8C9F4B28733B249DE4AB6D /* Pods-Sample.release.xcconfig */, ); - path = Pods; + name = Pods; + sourceTree = ""; + }; + C4C2C5219053E079C9EFB930 /* Frameworks */ = { + isa = PBXGroup; + children = ( + CC1B27EA0C428429B07BC34B /* Pods_Sample.framework */, + ); + name = Frameworks; sourceTree = ""; }; /* End PBXGroup section */ @@ -107,11 +107,12 @@ isa = PBXNativeTarget; buildConfigurationList = 6369A28D1A9322E20015FC5C /* Build configuration list for PBXNativeTarget "Sample" */; buildPhases = ( - B8CFD95B6470E21429BC7DF0 /* [CP] Check Pods Manifest.lock */, + 41F7486D8F66994B0BFB84AF /* [CP] Check Pods Manifest.lock */, 6369A2661A9322E20015FC5C /* Sources */, 6369A2671A9322E20015FC5C /* Frameworks */, 6369A2681A9322E20015FC5C /* Resources */, - 619CBF6DBB6BFE7F5B5A4777 /* [CP] Embed Pods Frameworks */, + 04554623324BE4A838846086 /* [CP] Copy Pods Resources */, + C7FAD018D05AB5F0B0FE81E2 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -167,58 +168,49 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 619CBF6DBB6BFE7F5B5A4777 /* [CP] Embed Pods Frameworks */ = { + 04554623324BE4A838846086 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 41F7486D8F66994B0BFB84AF /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + C7FAD018D05AB5F0B0FE81E2 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh", - "${BUILT_PRODUCTS_DIR}/BoringSSL-GRPC/openssl_grpc.framework", - "${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework", - "${BUILT_PRODUCTS_DIR}/RemoteTest/RemoteTest.framework", - "${BUILT_PRODUCTS_DIR}/gRPC/GRPCClient.framework", - "${BUILT_PRODUCTS_DIR}/gRPC-Core/grpc.framework", - "${BUILT_PRODUCTS_DIR}/gRPC-ProtoRPC/ProtoRPC.framework", - "${BUILT_PRODUCTS_DIR}/gRPC-RxLibrary/RxLibrary.framework", - "${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/openssl_grpc.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RemoteTest.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GRPCClient.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/grpc.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ProtoRPC.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxLibrary.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - B8CFD95B6470E21429BC7DF0 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Sample-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -329,10 +321,9 @@ }; 6369A28E1A9322E20015FC5C /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7544F97DDF1CB3F915E41CB9 /* Pods-Sample.debug.xcconfig */; + baseConfigurationReference = E3C01DF315C4E7433BCEC6E6 /* Pods-Sample.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; INFOPLIST_FILE = Sample/Info.plist; LD_GENERATE_MAP_FILE = YES; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -343,10 +334,9 @@ }; 6369A28F1A9322E20015FC5C /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 8BDAC28EF9131C53B2E6870D /* Pods-Sample.release.xcconfig */; + baseConfigurationReference = 5A8C9F4B28733B249DE4AB6D /* Pods-Sample.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; INFOPLIST_FILE = Sample/Info.plist; LD_GENERATE_MAP_FILE = YES; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; diff --git a/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj b/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj index 953152e6153..0113d9c5d6a 100644 --- a/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj @@ -7,23 +7,23 @@ objects = { /* Begin PBXBuildFile section */ + 2C0B024CB798839E17F76126 /* Pods_SwiftSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B394F343BDE186C5436DBDB9 /* Pods_SwiftSample.framework */; }; 633BFFC81B950B210007E424 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 633BFFC71B950B210007E424 /* AppDelegate.swift */; }; 633BFFCA1B950B210007E424 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 633BFFC91B950B210007E424 /* ViewController.swift */; }; 633BFFCD1B950B210007E424 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 633BFFCB1B950B210007E424 /* Main.storyboard */; }; 633BFFCF1B950B210007E424 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 633BFFCE1B950B210007E424 /* Images.xcassets */; }; - AC669361C16100FA4D34D7D1 /* Pods_SwiftSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5CB8E8B90EEE20DEB124EE37 /* Pods_SwiftSample.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 544DD51C2905B1B0B00F57F3 /* Pods-SwiftSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftSample.debug.xcconfig"; path = "Target Support Files/Pods-SwiftSample/Pods-SwiftSample.debug.xcconfig"; sourceTree = ""; }; - 5CB8E8B90EEE20DEB124EE37 /* Pods_SwiftSample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftSample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 633BFFC21B950B210007E424 /* SwiftSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 633BFFC61B950B210007E424 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 633BFFC71B950B210007E424 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 633BFFC91B950B210007E424 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 633BFFCC1B950B210007E424 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 633BFFCE1B950B210007E424 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; - FAF69508F6AEB00B2D2EB3F2 /* Pods-SwiftSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftSample.release.xcconfig"; path = "Target Support Files/Pods-SwiftSample/Pods-SwiftSample.release.xcconfig"; sourceTree = ""; }; + A7E614A494D89D01BB395761 /* Pods-SwiftSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftSample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SwiftSample/Pods-SwiftSample.debug.xcconfig"; sourceTree = ""; }; + B394F343BDE186C5436DBDB9 /* Pods_SwiftSample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftSample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + C314E3E246AF23AC29B38FCF /* Pods-SwiftSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftSample.release.xcconfig"; path = "Pods/Target Support Files/Pods-SwiftSample/Pods-SwiftSample.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -31,20 +31,29 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - AC669361C16100FA4D34D7D1 /* Pods_SwiftSample.framework in Frameworks */, + 2C0B024CB798839E17F76126 /* Pods_SwiftSample.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 31F283C976AE97586C17CCD9 /* Pods */ = { + isa = PBXGroup; + children = ( + A7E614A494D89D01BB395761 /* Pods-SwiftSample.debug.xcconfig */, + C314E3E246AF23AC29B38FCF /* Pods-SwiftSample.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; 633BFFB91B950B210007E424 = { isa = PBXGroup; children = ( 633BFFC41B950B210007E424 /* SwiftSample */, 633BFFC31B950B210007E424 /* Products */, - B26D8B90A783952E7BE194D9 /* Pods */, - 66C10D7692132083F1F396C6 /* Frameworks */, + 31F283C976AE97586C17CCD9 /* Pods */, + 9D63A7F6423989BA306810CA /* Frameworks */, ); sourceTree = ""; }; @@ -76,24 +85,14 @@ name = "Supporting Files"; sourceTree = ""; }; - 66C10D7692132083F1F396C6 /* Frameworks */ = { + 9D63A7F6423989BA306810CA /* Frameworks */ = { isa = PBXGroup; children = ( - 5CB8E8B90EEE20DEB124EE37 /* Pods_SwiftSample.framework */, + B394F343BDE186C5436DBDB9 /* Pods_SwiftSample.framework */, ); name = Frameworks; sourceTree = ""; }; - B26D8B90A783952E7BE194D9 /* Pods */ = { - isa = PBXGroup; - children = ( - 544DD51C2905B1B0B00F57F3 /* Pods-SwiftSample.debug.xcconfig */, - FAF69508F6AEB00B2D2EB3F2 /* Pods-SwiftSample.release.xcconfig */, - ); - name = Pods; - path = Pods; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -101,11 +100,12 @@ isa = PBXNativeTarget; buildConfigurationList = 633BFFE11B950B210007E424 /* Build configuration list for PBXNativeTarget "SwiftSample" */; buildPhases = ( - 405474DAAC9EB5A0055F82FA /* [CP] Check Pods Manifest.lock */, + 6BEEB33CA2705D7D2F2210E6 /* [CP] Check Pods Manifest.lock */, 633BFFBE1B950B210007E424 /* Sources */, 633BFFBF1B950B210007E424 /* Frameworks */, 633BFFC01B950B210007E424 /* Resources */, - 983E7AC7007F28ADB66E485B /* [CP] Embed Pods Frameworks */, + AC2F6F9AB1C090BB0BEE6E4D /* [CP] Copy Pods Resources */, + A1738A987353B0BF2C64F0F7 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -162,20 +162,16 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 405474DAAC9EB5A0055F82FA /* [CP] Check Pods Manifest.lock */ = { + 6BEEB33CA2705D7D2F2210E6 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${PODS_PODFILE_DIR_PATH}/Podfile.lock", "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); outputPaths = ( "$(DERIVED_FILE_DIR)/Pods-SwiftSample-checkManifestLockResult.txt", ); @@ -184,14 +180,14 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 983E7AC7007F28ADB66E485B /* [CP] Embed Pods Frameworks */ = { + A1738A987353B0BF2C64F0F7 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-SwiftSample/Pods-SwiftSample-frameworks.sh", - "${BUILT_PRODUCTS_DIR}/BoringSSL-GRPC/openssl_grpc.framework", + "${SRCROOT}/Pods/Target Support Files/Pods-SwiftSample/Pods-SwiftSample-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/BoringSSL/openssl.framework", "${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework", "${BUILT_PRODUCTS_DIR}/RemoteTest/RemoteTest.framework", "${BUILT_PRODUCTS_DIR}/gRPC/GRPCClient.framework", @@ -202,7 +198,7 @@ ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/openssl_grpc.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/openssl.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RemoteTest.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GRPCClient.framework", @@ -213,7 +209,22 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-SwiftSample/Pods-SwiftSample-frameworks.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwiftSample/Pods-SwiftSample-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + AC2F6F9AB1C090BB0BEE6E4D /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwiftSample/Pods-SwiftSample-resources.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -330,7 +341,7 @@ }; 633BFFE21B950B210007E424 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 544DD51C2905B1B0B00F57F3 /* Pods-SwiftSample.debug.xcconfig */; + baseConfigurationReference = A7E614A494D89D01BB395761 /* Pods-SwiftSample.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Info.plist; @@ -345,7 +356,7 @@ }; 633BFFE31B950B210007E424 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = FAF69508F6AEB00B2D2EB3F2 /* Pods-SwiftSample.release.xcconfig */; + baseConfigurationReference = C314E3E246AF23AC29B38FCF /* Pods-SwiftSample.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Info.plist; diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index 578970f4271..737d52b547d 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -7,8 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 01574004C238BE75F6A7651D /* libPods-MacTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B6E36AF835D0DC279DC0C18 /* libPods-MacTests.a */; }; - 3E8DD339E611E92DCE8A5A48 /* libPods-CronetTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2067DD4BEA93EFB61A753183 /* libPods-CronetTests.a */; }; 5E0282E9215AA697007AC99D /* NSErrorUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E0282E8215AA697007AC99D /* NSErrorUnitTests.m */; }; 5E3F14842278B461007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; 5E3F14852278BF5D007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; @@ -36,24 +34,62 @@ 5EA4770322736178000F72FC /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; 5EA477042273617B000F72FC /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; 5EA4770522736AC4000F72FC /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; - 80EA8F48AFAA5E3D758AC3D5 /* libPods-UnitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2D4287E190CCD0CACC3F2CC3 /* libPods-UnitTests.a */; }; + 65EB19E418B39A8374D407BB /* libPods-CronetTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B1511C20E16A8422B58D61A /* libPods-CronetTests.a */; }; + 903163C7FE885838580AEC7A /* libPods-InteropTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D457AD9797664CFA191C3280 /* libPods-InteropTests.a */; }; + 953CD2942A3A6D6CE695BE87 /* libPods-MacTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 276873A05AC5479B60DF6079 /* libPods-MacTests.a */; }; B071230B22669EED004B64A1 /* StressTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B071230A22669EED004B64A1 /* StressTests.m */; }; B0BB3F08225E7ABA008DA580 /* NSErrorUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E0282E8215AA697007AC99D /* NSErrorUnitTests.m */; }; B0BB3F0A225EA511008DA580 /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; B0D39B9A2266F3CB00A4078D /* StressTestsSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D39B992266F3CB00A4078D /* StressTestsSSL.m */; }; B0D39B9C2266FF9800A4078D /* StressTestsCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D39B9B2266FF9800A4078D /* StressTestsCleartext.m */; }; - C8217D49007E8E4693F058B1 /* libPods-InteropTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DD0F486470BDFF1E1E4943B8 /* libPods-InteropTests.a */; }; + CCF5C0719EF608276AE16374 /* libPods-UnitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 22A3EBB488699C8CEA19707B /* libPods-UnitTests.a */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 16B9B1262FE6FBFC353B62BB /* Pods-InteropTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.cronet.xcconfig"; path = "Target Support Files/Pods-InteropTests/Pods-InteropTests.cronet.xcconfig"; sourceTree = ""; }; - 2067DD4BEA93EFB61A753183 /* libPods-CronetTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CronetTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 2D4287E190CCD0CACC3F2CC3 /* libPods-UnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-UnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 42DF8A339EF81AFE13553D04 /* Pods-InteropTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.release.xcconfig"; path = "Target Support Files/Pods-InteropTests/Pods-InteropTests.release.xcconfig"; sourceTree = ""; }; - 4A76E027206C07B7DBECB301 /* Pods-UnitTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.cronet.xcconfig"; path = "Target Support Files/Pods-UnitTests/Pods-UnitTests.cronet.xcconfig"; sourceTree = ""; }; - 5287652093398BAA7C5A90E8 /* Pods-MacTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MacTests.release.xcconfig"; path = "Target Support Files/Pods-MacTests/Pods-MacTests.release.xcconfig"; sourceTree = ""; }; - 55BBF7900C93644CD8236BD2 /* Pods-CronetTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.test.xcconfig"; path = "Target Support Files/Pods-CronetTests/Pods-CronetTests.test.xcconfig"; sourceTree = ""; }; - 5CF07AAE0442D200BCD81ABC /* Pods-InteropTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.test.xcconfig"; path = "Target Support Files/Pods-InteropTests/Pods-InteropTests.test.xcconfig"; sourceTree = ""; }; + 02192CF1FF9534E3D18C65FC /* Pods-CronetUnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetUnitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests.release.xcconfig"; sourceTree = ""; }; + 070266E2626EB997B54880A3 /* Pods-InteropTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTests/Pods-InteropTests.test.xcconfig"; sourceTree = ""; }; + 07D10A965323BEA7FE59A74B /* Pods-RxLibraryUnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.debug.xcconfig"; sourceTree = ""; }; + 0A4F89D9C90E9C30990218F0 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; + 0BDA4BA011779D5D25B5618C /* libPods-InteropTestsLocalCleartextCFStream.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalCleartextCFStream.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 0D2284C3DF7E57F0ED504E39 /* Pods-CoreCronetEnd2EndTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CoreCronetEnd2EndTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests.debug.xcconfig"; sourceTree = ""; }; + 1286B30AD74CB64CD91FB17D /* Pods-APIv2Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIv2Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests.debug.xcconfig"; sourceTree = ""; }; + 1295CCBD1082B4A7CFCED95F /* Pods-InteropTestsMultipleChannels.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsMultipleChannels.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels.cronet.xcconfig"; sourceTree = ""; }; + 12B238CD1702393C2BA5DE80 /* Pods-APIv2Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIv2Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests.release.xcconfig"; sourceTree = ""; }; + 14B09A58FEE53A7A6B838920 /* Pods-InteropTestsLocalSSL.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.cronet.xcconfig"; sourceTree = ""; }; + 1588C85DEAF7FC0ACDEA4C02 /* Pods-InteropTestsLocalCleartext.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartext.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext.test.xcconfig"; sourceTree = ""; }; + 16A2E4C5839C83FBDA63881F /* Pods-MacTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MacTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-MacTests/Pods-MacTests.cronet.xcconfig"; sourceTree = ""; }; + 17F60BF2871F6AF85FB3FA12 /* Pods-InteropTestsRemoteWithCronet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.debug.xcconfig"; sourceTree = ""; }; + 1B1511C20E16A8422B58D61A /* libPods-CronetTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CronetTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 1E43EAE443CBB4482B1EB071 /* Pods-MacTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MacTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-MacTests/Pods-MacTests.release.xcconfig"; sourceTree = ""; }; + 1F5E788FBF9A4A06EB9E1ACD /* Pods-MacTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MacTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-MacTests/Pods-MacTests.test.xcconfig"; sourceTree = ""; }; + 20DFF2F3C97EF098FE5A3171 /* libPods-Tests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Tests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 20F6A3D59D0EE091E2D43953 /* Pods-CronetTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests.cronet.xcconfig"; sourceTree = ""; }; + 22A3EBB488699C8CEA19707B /* libPods-UnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-UnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 2650FEF00956E7924772F9D9 /* Pods-InteropTestsMultipleChannels.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsMultipleChannels.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels.release.xcconfig"; sourceTree = ""; }; + 276873A05AC5479B60DF6079 /* libPods-MacTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-MacTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 2B89F3037963E6EDDD48D8C3 /* Pods-InteropTestsRemoteWithCronet.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.test.xcconfig"; sourceTree = ""; }; + 303F4A17EB1650FC44603D17 /* Pods-InteropTestsRemoteCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream.release.xcconfig"; sourceTree = ""; }; + 32748C4078AEB05F8F954361 /* Pods-InteropTestsRemoteCFStream.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteCFStream.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream.debug.xcconfig"; sourceTree = ""; }; + 355D0E30AD224763BC9519F4 /* libPods-InteropTestsMultipleChannels.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsMultipleChannels.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 35F2B6BF3BAE8F0DC4AFD76E /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 386712AEACF7C2190C4B8B3F /* Pods-CronetUnitTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetUnitTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests.cronet.xcconfig"; sourceTree = ""; }; + 3A98DF08852F60AF1D96481D /* Pods-InteropTestsCallOptions.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsCallOptions.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions.debug.xcconfig"; sourceTree = ""; }; + 3B0861FC805389C52DB260D4 /* Pods-RxLibraryUnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.release.xcconfig"; sourceTree = ""; }; + 3CADF86203B9D03EA96C359D /* Pods-InteropTestsMultipleChannels.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsMultipleChannels.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels.debug.xcconfig"; sourceTree = ""; }; + 3EB55EF291706E3DDE23C3B7 /* Pods-InteropTestsLocalSSLCFStream.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.debug.xcconfig"; sourceTree = ""; }; + 3F27B2E744482771EB93C394 /* Pods-InteropTestsRemoteWithCronet.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.cronet.xcconfig"; sourceTree = ""; }; + 41AA59529240A6BBBD3DB904 /* Pods-InteropTestsLocalSSLCFStream.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.test.xcconfig"; sourceTree = ""; }; + 48F1841C9A920626995DC28C /* libPods-ChannelTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ChannelTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 4A1A42B2E941CCD453489E5B /* Pods-InteropTestsRemoteCFStream.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteCFStream.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream.cronet.xcconfig"; sourceTree = ""; }; + 4AD97096D13D7416DC91A72A /* Pods-CoreCronetEnd2EndTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CoreCronetEnd2EndTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests.release.xcconfig"; sourceTree = ""; }; + 4ADEA1C8BBE10D90940AC68E /* Pods-InteropTestsRemote.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemote.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote.cronet.xcconfig"; sourceTree = ""; }; + 51A275E86C141416ED63FF76 /* Pods-InteropTestsLocalCleartext.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartext.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext.release.xcconfig"; sourceTree = ""; }; + 51F2A64B7AADBA1B225B132E /* Pods-APIv2Tests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIv2Tests.test.xcconfig"; path = "Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests.test.xcconfig"; sourceTree = ""; }; + 553BBBED24E4162D1F769D65 /* Pods-InteropTestsLocalSSL.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.debug.xcconfig"; sourceTree = ""; }; + 55B630C1FF8C36D1EFC4E0A4 /* Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig"; sourceTree = ""; }; + 573450F334B331D0BED8B961 /* Pods-CoreCronetEnd2EndTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CoreCronetEnd2EndTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests.cronet.xcconfig"; sourceTree = ""; }; + 5761E98978DDDF136A58CB7E /* Pods-AllTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.release.xcconfig"; sourceTree = ""; }; + 5AB9A82F289D548D6B8816F9 /* Pods-CronetTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests.test.xcconfig"; sourceTree = ""; }; 5E0282E6215AA697007AC99D /* UnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 5E0282E8215AA697007AC99D /* NSErrorUnitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NSErrorUnitTests.m; sourceTree = ""; }; 5E3F14822278B42D007C6D90 /* InteropTestsBlockCallbacks.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InteropTestsBlockCallbacks.h; sourceTree = ""; }; @@ -73,6 +109,7 @@ 5E7F488822778B04006656AD /* InteropTestsRemote.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InteropTestsRemote.m; sourceTree = ""; }; 5E7F488A22778B5D006656AD /* RxLibraryUnitTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RxLibraryUnitTests.m; sourceTree = ""; }; 5EA476F42272816A000F72FC /* InteropTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 5EA908CF4CDA4CE218352A06 /* Pods-InteropTestsLocalSSLCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.release.xcconfig"; sourceTree = ""; }; 5EAD6D261E27047400002378 /* CronetUnitTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = CronetUnitTests.mm; path = CronetTests/CronetUnitTests.mm; sourceTree = SOURCE_ROOT; }; 5EAFE8271F8EFB87007F2189 /* version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = version.h; sourceTree = ""; }; 5EE84BF31D4717E40050C6CC /* InteropTestsRemoteWithCronet.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = InteropTestsRemoteWithCronet.m; path = CronetTests/InteropTestsRemoteWithCronet.m; sourceTree = SOURCE_ROOT; }; @@ -80,24 +117,66 @@ 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = InteropTestsLocalCleartext.m; path = InteropTests/InteropTestsLocalCleartext.m; sourceTree = SOURCE_ROOT; }; 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = InteropTestsLocalSSL.m; path = InteropTests/InteropTestsLocalSSL.m; sourceTree = SOURCE_ROOT; }; 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = TestCertificates.bundle; sourceTree = ""; }; - 6B6E36AF835D0DC279DC0C18 /* libPods-MacTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-MacTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 7612BA4B2A55BC4F508570C2 /* Pods-MacTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MacTests.cronet.xcconfig"; path = "Target Support Files/Pods-MacTests/Pods-MacTests.cronet.xcconfig"; sourceTree = ""; }; - 936ADE0FD98D66144C935C37 /* Pods-UnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.debug.xcconfig"; path = "Target Support Files/Pods-UnitTests/Pods-UnitTests.debug.xcconfig"; sourceTree = ""; }; - 9AEB5A4889D2018866BE6050 /* Pods-CronetTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.debug.xcconfig"; path = "Target Support Files/Pods-CronetTests/Pods-CronetTests.debug.xcconfig"; sourceTree = ""; }; - 9E48AF01E76B19FAAAACAE23 /* Pods-UnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.release.xcconfig"; path = "Target Support Files/Pods-UnitTests/Pods-UnitTests.release.xcconfig"; sourceTree = ""; }; + 64F68A9A6A63CC930DD30A6E /* Pods-CronetUnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetUnitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests.debug.xcconfig"; sourceTree = ""; }; + 6793C9D019CB268C5BB491A2 /* Pods-CoreCronetEnd2EndTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CoreCronetEnd2EndTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests.test.xcconfig"; sourceTree = ""; }; + 680439AC2BC8761EDD54A1EA /* Pods-InteropTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTests/Pods-InteropTests.debug.xcconfig"; sourceTree = ""; }; + 73D2DF07027835BA0FB0B1C0 /* Pods-InteropTestsCallOptions.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsCallOptions.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions.cronet.xcconfig"; sourceTree = ""; }; + 781089FAE980F51F88A3BE0B /* Pods-RxLibraryUnitTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.test.xcconfig"; sourceTree = ""; }; + 79C68EFFCB5533475D810B79 /* Pods-RxLibraryUnitTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.cronet.xcconfig"; sourceTree = ""; }; + 7A2E97E3F469CC2A758D77DE /* Pods-InteropTestsLocalSSL.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.release.xcconfig"; sourceTree = ""; }; + 7BA53C6D224288D5870FE6F3 /* Pods-InteropTestsLocalCleartextCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.release.xcconfig"; sourceTree = ""; }; + 7F4F42EBAF311E9F84FCA32E /* Pods-CronetTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests.release.xcconfig"; sourceTree = ""; }; + 8B498B05C6DA0818B2FA91D4 /* Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig"; sourceTree = ""; }; + 8C233E85C3EB45B3CAE52EDF /* Pods-APIv2Tests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIv2Tests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests.cronet.xcconfig"; sourceTree = ""; }; + 90E63AD3C4A1E3E6BC745096 /* Pods-ChannelTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChannelTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests.cronet.xcconfig"; sourceTree = ""; }; + 943138072A9605B5B8DC1FC0 /* Pods-InteropTestsLocalCleartextCFStream.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.debug.xcconfig"; sourceTree = ""; }; + 94D7A5FAA13480E9A5166D7A /* Pods-UnitTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests.test.xcconfig"; sourceTree = ""; }; + 9E9444C764F0FFF64A7EB58E /* libPods-InteropTestsRemoteWithCronet.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsRemoteWithCronet.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + A25967A0D40ED14B3287AD81 /* Pods-InteropTestsCallOptions.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsCallOptions.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions.test.xcconfig"; sourceTree = ""; }; + A2DCF2570BE515B62CB924CA /* Pods-UnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests.debug.xcconfig"; sourceTree = ""; }; + A58BE6DF1C62D1739EBB2C78 /* libPods-RxLibraryUnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RxLibraryUnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + A6F832FCEFA6F6881E620F12 /* Pods-InteropTestsRemote.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemote.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote.test.xcconfig"; sourceTree = ""; }; + AA7CB64B4DD9915AE7C03163 /* Pods-InteropTestsLocalCleartext.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartext.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext.cronet.xcconfig"; sourceTree = ""; }; + AC414EF7A6BF76ED02B6E480 /* Pods-InteropTestsRemoteWithCronet.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.release.xcconfig"; sourceTree = ""; }; + AF3FC2CFFE7B0961823BC740 /* libPods-InteropTestsCallOptions.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsCallOptions.a"; sourceTree = BUILT_PRODUCTS_DIR; }; B071230A22669EED004B64A1 /* StressTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StressTests.m; sourceTree = ""; }; B0BB3EF7225E795F008DA580 /* MacTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MacTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; B0BB3EFB225E795F008DA580 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; B0C5FC172267C77200F192BE /* StressTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StressTests.h; sourceTree = ""; }; B0D39B992266F3CB00A4078D /* StressTestsSSL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StressTestsSSL.m; sourceTree = ""; }; B0D39B9B2266FF9800A4078D /* StressTestsCleartext.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StressTestsCleartext.m; sourceTree = ""; }; - B3C890A1E6F082CD283069BF /* Pods-UnitTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.test.xcconfig"; path = "Target Support Files/Pods-UnitTests/Pods-UnitTests.test.xcconfig"; sourceTree = ""; }; - B43404F2B37A38483BE4704A /* Pods-CronetTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.cronet.xcconfig"; path = "Target Support Files/Pods-CronetTests/Pods-CronetTests.cronet.xcconfig"; sourceTree = ""; }; - BC5D3F3B5B38B71CA279AF7F /* Pods-MacTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MacTests.debug.xcconfig"; path = "Target Support Files/Pods-MacTests/Pods-MacTests.debug.xcconfig"; sourceTree = ""; }; - C56A093740F31650ACDD9630 /* Pods-InteropTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.debug.xcconfig"; path = "Target Support Files/Pods-InteropTests/Pods-InteropTests.debug.xcconfig"; sourceTree = ""; }; - DA532DBBE1BC0DC8EC879FE1 /* Pods-MacTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MacTests.test.xcconfig"; path = "Target Support Files/Pods-MacTests/Pods-MacTests.test.xcconfig"; sourceTree = ""; }; - DD0F486470BDFF1E1E4943B8 /* libPods-InteropTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - FF0A4B1F995C18C1EB86D155 /* Pods-CronetTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.release.xcconfig"; path = "Target Support Files/Pods-CronetTests/Pods-CronetTests.release.xcconfig"; sourceTree = ""; }; + B226619DC4E709E0FFFF94B8 /* Pods-CronetUnitTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetUnitTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests.test.xcconfig"; sourceTree = ""; }; + B6AD69CACF67505B0F028E92 /* libPods-APIv2Tests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-APIv2Tests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + B94C27C06733CF98CE1B2757 /* Pods-AllTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.debug.xcconfig"; sourceTree = ""; }; + BED74BC8ABF9917C66175879 /* Pods-ChannelTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChannelTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests.test.xcconfig"; sourceTree = ""; }; + C17F57E5BCB989AB1C2F1F25 /* Pods-InteropTestsRemoteCFStream.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteCFStream.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream.test.xcconfig"; sourceTree = ""; }; + C6134277D2EB8B380862A03F /* libPods-CronetUnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CronetUnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + C9172F9020E8C97A470D7250 /* Pods-InteropTestsCallOptions.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsCallOptions.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions.release.xcconfig"; sourceTree = ""; }; + CAE086D5B470DA367D415AB0 /* libPods-AllTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AllTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + CDF6CC70B8BF9D10EFE7D199 /* Pods-InteropTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTests/Pods-InteropTests.cronet.xcconfig"; sourceTree = ""; }; + D13BEC8181B8E678A1B52F54 /* Pods-InteropTestsLocalSSL.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.test.xcconfig"; sourceTree = ""; }; + D457AD9797664CFA191C3280 /* libPods-InteropTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + D52B92A7108602F170DA8091 /* Pods-ChannelTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChannelTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests.release.xcconfig"; sourceTree = ""; }; + DB1F4391AF69D20D38D74B67 /* Pods-AllTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.test.xcconfig"; sourceTree = ""; }; + DBE059B4AC7A51919467EEC0 /* libPods-InteropTestsRemote.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsRemote.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + DBEDE45BDA60DF1E1C8950C0 /* libPods-InteropTestsLocalSSL.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalSSL.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + DC3CA1D948F068E76957A861 /* Pods-InteropTestsRemote.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemote.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote.debug.xcconfig"; sourceTree = ""; }; + E1486220285AF123EB124008 /* Pods-InteropTestsLocalCleartext.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartext.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext.debug.xcconfig"; sourceTree = ""; }; + E1E7660656D902104F728892 /* Pods-UnitTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests.cronet.xcconfig"; sourceTree = ""; }; + E3ACD4D5902745976D9C2229 /* Pods-MacTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MacTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-MacTests/Pods-MacTests.debug.xcconfig"; sourceTree = ""; }; + E4275A759BDBDF143B9B438F /* Pods-InteropTestsRemote.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemote.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote.release.xcconfig"; sourceTree = ""; }; + E4FD4606D4AB8D5A314D72F0 /* Pods-InteropTestsLocalCleartextCFStream.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.test.xcconfig"; sourceTree = ""; }; + E7E4D3FD76E3B745D992AF5F /* Pods-AllTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.cronet.xcconfig"; sourceTree = ""; }; + EA8B122ACDE73E3AAA0E4A19 /* Pods-InteropTestsMultipleChannels.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsMultipleChannels.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels.test.xcconfig"; sourceTree = ""; }; + EBFFEC04B514CB0D4922DC40 /* Pods-UnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests.release.xcconfig"; sourceTree = ""; }; + EC66920112123D2DB1CB7F6C /* Pods-CronetTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests.debug.xcconfig"; sourceTree = ""; }; + F3AB031E0E26AC8EF30A2A2A /* libPods-InteropTestsLocalSSLCFStream.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalSSLCFStream.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + F44AC3F44E3491A8C0D890FE /* libPods-InteropTestsRemoteCFStream.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsRemoteCFStream.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + F6A7EECACBB4849DDD3F450A /* Pods-InteropTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTests/Pods-InteropTests.release.xcconfig"; sourceTree = ""; }; + F9E48EF5ACB1F38825171C5F /* Pods-ChannelTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChannelTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests.debug.xcconfig"; sourceTree = ""; }; + FBD98AC417B9882D32B19F28 /* libPods-CoreCronetEnd2EndTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CoreCronetEnd2EndTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + FD346DB2C23F676C4842F3FF /* libPods-InteropTestsLocalCleartext.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalCleartext.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + FF7B5489BCFE40111D768DD0 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -105,7 +184,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 80EA8F48AFAA5E3D758AC3D5 /* libPods-UnitTests.a in Frameworks */, + CCF5C0719EF608276AE16374 /* libPods-UnitTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -113,7 +192,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 3E8DD339E611E92DCE8A5A48 /* libPods-CronetTests.a in Frameworks */, + 65EB19E418B39A8374D407BB /* libPods-CronetTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -121,7 +200,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - C8217D49007E8E4693F058B1 /* libPods-InteropTests.a in Frameworks */, + 903163C7FE885838580AEC7A /* libPods-InteropTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -129,7 +208,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 01574004C238BE75F6A7651D /* libPods-MacTests.a in Frameworks */, + 953CD2942A3A6D6CE695BE87 /* libPods-MacTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -140,14 +219,116 @@ isa = PBXGroup; children = ( 5E7F486622776AD8006656AD /* Cronet.framework */, - 2067DD4BEA93EFB61A753183 /* libPods-CronetTests.a */, - DD0F486470BDFF1E1E4943B8 /* libPods-InteropTests.a */, - 6B6E36AF835D0DC279DC0C18 /* libPods-MacTests.a */, - 2D4287E190CCD0CACC3F2CC3 /* libPods-UnitTests.a */, + 35F2B6BF3BAE8F0DC4AFD76E /* libPods.a */, + CAE086D5B470DA367D415AB0 /* libPods-AllTests.a */, + FD346DB2C23F676C4842F3FF /* libPods-InteropTestsLocalCleartext.a */, + DBEDE45BDA60DF1E1C8950C0 /* libPods-InteropTestsLocalSSL.a */, + DBE059B4AC7A51919467EEC0 /* libPods-InteropTestsRemote.a */, + A58BE6DF1C62D1739EBB2C78 /* libPods-RxLibraryUnitTests.a */, + 20DFF2F3C97EF098FE5A3171 /* libPods-Tests.a */, + FBD98AC417B9882D32B19F28 /* libPods-CoreCronetEnd2EndTests.a */, + 9E9444C764F0FFF64A7EB58E /* libPods-InteropTestsRemoteWithCronet.a */, + C6134277D2EB8B380862A03F /* libPods-CronetUnitTests.a */, + F44AC3F44E3491A8C0D890FE /* libPods-InteropTestsRemoteCFStream.a */, + 0BDA4BA011779D5D25B5618C /* libPods-InteropTestsLocalCleartextCFStream.a */, + F3AB031E0E26AC8EF30A2A2A /* libPods-InteropTestsLocalSSLCFStream.a */, + 48F1841C9A920626995DC28C /* libPods-ChannelTests.a */, + 355D0E30AD224763BC9519F4 /* libPods-InteropTestsMultipleChannels.a */, + AF3FC2CFFE7B0961823BC740 /* libPods-InteropTestsCallOptions.a */, + 22A3EBB488699C8CEA19707B /* libPods-UnitTests.a */, + B6AD69CACF67505B0F028E92 /* libPods-APIv2Tests.a */, + 276873A05AC5479B60DF6079 /* libPods-MacTests.a */, + D457AD9797664CFA191C3280 /* libPods-InteropTests.a */, + 1B1511C20E16A8422B58D61A /* libPods-CronetTests.a */, ); name = Frameworks; sourceTree = ""; }; + 51E4650F34F854F41FF053B3 /* Pods */ = { + isa = PBXGroup; + children = ( + FF7B5489BCFE40111D768DD0 /* Pods.debug.xcconfig */, + 0A4F89D9C90E9C30990218F0 /* Pods.release.xcconfig */, + B94C27C06733CF98CE1B2757 /* Pods-AllTests.debug.xcconfig */, + 5761E98978DDDF136A58CB7E /* Pods-AllTests.release.xcconfig */, + E1486220285AF123EB124008 /* Pods-InteropTestsLocalCleartext.debug.xcconfig */, + 51A275E86C141416ED63FF76 /* Pods-InteropTestsLocalCleartext.release.xcconfig */, + 553BBBED24E4162D1F769D65 /* Pods-InteropTestsLocalSSL.debug.xcconfig */, + 7A2E97E3F469CC2A758D77DE /* Pods-InteropTestsLocalSSL.release.xcconfig */, + DC3CA1D948F068E76957A861 /* Pods-InteropTestsRemote.debug.xcconfig */, + E4275A759BDBDF143B9B438F /* Pods-InteropTestsRemote.release.xcconfig */, + 07D10A965323BEA7FE59A74B /* Pods-RxLibraryUnitTests.debug.xcconfig */, + 3B0861FC805389C52DB260D4 /* Pods-RxLibraryUnitTests.release.xcconfig */, + 0D2284C3DF7E57F0ED504E39 /* Pods-CoreCronetEnd2EndTests.debug.xcconfig */, + 4AD97096D13D7416DC91A72A /* Pods-CoreCronetEnd2EndTests.release.xcconfig */, + 17F60BF2871F6AF85FB3FA12 /* Pods-InteropTestsRemoteWithCronet.debug.xcconfig */, + AC414EF7A6BF76ED02B6E480 /* Pods-InteropTestsRemoteWithCronet.release.xcconfig */, + E7E4D3FD76E3B745D992AF5F /* Pods-AllTests.cronet.xcconfig */, + 573450F334B331D0BED8B961 /* Pods-CoreCronetEnd2EndTests.cronet.xcconfig */, + AA7CB64B4DD9915AE7C03163 /* Pods-InteropTestsLocalCleartext.cronet.xcconfig */, + 14B09A58FEE53A7A6B838920 /* Pods-InteropTestsLocalSSL.cronet.xcconfig */, + 4ADEA1C8BBE10D90940AC68E /* Pods-InteropTestsRemote.cronet.xcconfig */, + 3F27B2E744482771EB93C394 /* Pods-InteropTestsRemoteWithCronet.cronet.xcconfig */, + 79C68EFFCB5533475D810B79 /* Pods-RxLibraryUnitTests.cronet.xcconfig */, + 64F68A9A6A63CC930DD30A6E /* Pods-CronetUnitTests.debug.xcconfig */, + 386712AEACF7C2190C4B8B3F /* Pods-CronetUnitTests.cronet.xcconfig */, + 02192CF1FF9534E3D18C65FC /* Pods-CronetUnitTests.release.xcconfig */, + DB1F4391AF69D20D38D74B67 /* Pods-AllTests.test.xcconfig */, + 6793C9D019CB268C5BB491A2 /* Pods-CoreCronetEnd2EndTests.test.xcconfig */, + B226619DC4E709E0FFFF94B8 /* Pods-CronetUnitTests.test.xcconfig */, + 1588C85DEAF7FC0ACDEA4C02 /* Pods-InteropTestsLocalCleartext.test.xcconfig */, + D13BEC8181B8E678A1B52F54 /* Pods-InteropTestsLocalSSL.test.xcconfig */, + A6F832FCEFA6F6881E620F12 /* Pods-InteropTestsRemote.test.xcconfig */, + 2B89F3037963E6EDDD48D8C3 /* Pods-InteropTestsRemoteWithCronet.test.xcconfig */, + 781089FAE980F51F88A3BE0B /* Pods-RxLibraryUnitTests.test.xcconfig */, + 32748C4078AEB05F8F954361 /* Pods-InteropTestsRemoteCFStream.debug.xcconfig */, + C17F57E5BCB989AB1C2F1F25 /* Pods-InteropTestsRemoteCFStream.test.xcconfig */, + 4A1A42B2E941CCD453489E5B /* Pods-InteropTestsRemoteCFStream.cronet.xcconfig */, + 303F4A17EB1650FC44603D17 /* Pods-InteropTestsRemoteCFStream.release.xcconfig */, + 943138072A9605B5B8DC1FC0 /* Pods-InteropTestsLocalCleartextCFStream.debug.xcconfig */, + E4FD4606D4AB8D5A314D72F0 /* Pods-InteropTestsLocalCleartextCFStream.test.xcconfig */, + 8B498B05C6DA0818B2FA91D4 /* Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig */, + 7BA53C6D224288D5870FE6F3 /* Pods-InteropTestsLocalCleartextCFStream.release.xcconfig */, + 3EB55EF291706E3DDE23C3B7 /* Pods-InteropTestsLocalSSLCFStream.debug.xcconfig */, + 41AA59529240A6BBBD3DB904 /* Pods-InteropTestsLocalSSLCFStream.test.xcconfig */, + 55B630C1FF8C36D1EFC4E0A4 /* Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig */, + 5EA908CF4CDA4CE218352A06 /* Pods-InteropTestsLocalSSLCFStream.release.xcconfig */, + F9E48EF5ACB1F38825171C5F /* Pods-ChannelTests.debug.xcconfig */, + BED74BC8ABF9917C66175879 /* Pods-ChannelTests.test.xcconfig */, + 90E63AD3C4A1E3E6BC745096 /* Pods-ChannelTests.cronet.xcconfig */, + D52B92A7108602F170DA8091 /* Pods-ChannelTests.release.xcconfig */, + 3CADF86203B9D03EA96C359D /* Pods-InteropTestsMultipleChannels.debug.xcconfig */, + EA8B122ACDE73E3AAA0E4A19 /* Pods-InteropTestsMultipleChannels.test.xcconfig */, + 1295CCBD1082B4A7CFCED95F /* Pods-InteropTestsMultipleChannels.cronet.xcconfig */, + 2650FEF00956E7924772F9D9 /* Pods-InteropTestsMultipleChannels.release.xcconfig */, + 3A98DF08852F60AF1D96481D /* Pods-InteropTestsCallOptions.debug.xcconfig */, + A25967A0D40ED14B3287AD81 /* Pods-InteropTestsCallOptions.test.xcconfig */, + 73D2DF07027835BA0FB0B1C0 /* Pods-InteropTestsCallOptions.cronet.xcconfig */, + C9172F9020E8C97A470D7250 /* Pods-InteropTestsCallOptions.release.xcconfig */, + A2DCF2570BE515B62CB924CA /* Pods-UnitTests.debug.xcconfig */, + 94D7A5FAA13480E9A5166D7A /* Pods-UnitTests.test.xcconfig */, + E1E7660656D902104F728892 /* Pods-UnitTests.cronet.xcconfig */, + EBFFEC04B514CB0D4922DC40 /* Pods-UnitTests.release.xcconfig */, + 1286B30AD74CB64CD91FB17D /* Pods-APIv2Tests.debug.xcconfig */, + 51F2A64B7AADBA1B225B132E /* Pods-APIv2Tests.test.xcconfig */, + 8C233E85C3EB45B3CAE52EDF /* Pods-APIv2Tests.cronet.xcconfig */, + 12B238CD1702393C2BA5DE80 /* Pods-APIv2Tests.release.xcconfig */, + E3ACD4D5902745976D9C2229 /* Pods-MacTests.debug.xcconfig */, + 1F5E788FBF9A4A06EB9E1ACD /* Pods-MacTests.test.xcconfig */, + 16A2E4C5839C83FBDA63881F /* Pods-MacTests.cronet.xcconfig */, + 1E43EAE443CBB4482B1EB071 /* Pods-MacTests.release.xcconfig */, + 680439AC2BC8761EDD54A1EA /* Pods-InteropTests.debug.xcconfig */, + 070266E2626EB997B54880A3 /* Pods-InteropTests.test.xcconfig */, + CDF6CC70B8BF9D10EFE7D199 /* Pods-InteropTests.cronet.xcconfig */, + F6A7EECACBB4849DDD3F450A /* Pods-InteropTests.release.xcconfig */, + EC66920112123D2DB1CB7F6C /* Pods-CronetTests.debug.xcconfig */, + 5AB9A82F289D548D6B8816F9 /* Pods-CronetTests.test.xcconfig */, + 20F6A3D59D0EE091E2D43953 /* Pods-CronetTests.cronet.xcconfig */, + 7F4F42EBAF311E9F84FCA32E /* Pods-CronetTests.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; 5E0282E7215AA697007AC99D /* UnitTests */ = { isa = PBXGroup; children = ( @@ -196,8 +377,8 @@ B0BB3EF8225E795F008DA580 /* MacTests */, 5E7F485A22775B15006656AD /* CronetTests */, 635697C81B14FC11007A7283 /* Products */, + 51E4650F34F854F41FF053B3 /* Pods */, 136D535E19727099B941D7B1 /* Frameworks */, - E549E472D8DBE9DD5C7D6247 /* Pods */, ); sourceTree = ""; }; @@ -243,30 +424,6 @@ path = MacTests; sourceTree = ""; }; - E549E472D8DBE9DD5C7D6247 /* Pods */ = { - isa = PBXGroup; - children = ( - 9AEB5A4889D2018866BE6050 /* Pods-CronetTests.debug.xcconfig */, - 55BBF7900C93644CD8236BD2 /* Pods-CronetTests.test.xcconfig */, - B43404F2B37A38483BE4704A /* Pods-CronetTests.cronet.xcconfig */, - FF0A4B1F995C18C1EB86D155 /* Pods-CronetTests.release.xcconfig */, - C56A093740F31650ACDD9630 /* Pods-InteropTests.debug.xcconfig */, - 5CF07AAE0442D200BCD81ABC /* Pods-InteropTests.test.xcconfig */, - 16B9B1262FE6FBFC353B62BB /* Pods-InteropTests.cronet.xcconfig */, - 42DF8A339EF81AFE13553D04 /* Pods-InteropTests.release.xcconfig */, - BC5D3F3B5B38B71CA279AF7F /* Pods-MacTests.debug.xcconfig */, - DA532DBBE1BC0DC8EC879FE1 /* Pods-MacTests.test.xcconfig */, - 7612BA4B2A55BC4F508570C2 /* Pods-MacTests.cronet.xcconfig */, - 5287652093398BAA7C5A90E8 /* Pods-MacTests.release.xcconfig */, - 936ADE0FD98D66144C935C37 /* Pods-UnitTests.debug.xcconfig */, - B3C890A1E6F082CD283069BF /* Pods-UnitTests.test.xcconfig */, - 4A76E027206C07B7DBECB301 /* Pods-UnitTests.cronet.xcconfig */, - 9E48AF01E76B19FAAAACAE23 /* Pods-UnitTests.release.xcconfig */, - ); - name = Pods; - path = Pods; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -274,11 +431,11 @@ isa = PBXNativeTarget; buildConfigurationList = 5E0282F2215AA697007AC99D /* Build configuration list for PBXNativeTarget "UnitTests" */; buildPhases = ( - 1C48C52EEA28609437176C56 /* [CP] Check Pods Manifest.lock */, + F07941C0BAF6A7C67AA60C48 /* [CP] Check Pods Manifest.lock */, 5E0282E2215AA697007AC99D /* Sources */, 5E0282E3215AA697007AC99D /* Frameworks */, 5E0282E4215AA697007AC99D /* Resources */, - 9D72085F3319466831FF534B /* [CP] Copy Pods Resources */, + 9AD0B5E94F2AA5962EA6AA36 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -293,12 +450,12 @@ isa = PBXNativeTarget; buildConfigurationList = 5E7F485E22775B15006656AD /* Build configuration list for PBXNativeTarget "CronetTests" */; buildPhases = ( - A9802246E6D152C53B842F78 /* [CP] Check Pods Manifest.lock */, + CCAEC0F23E05489651A07D53 /* [CP] Check Pods Manifest.lock */, 5E7F485522775B15006656AD /* Sources */, 5E7F485622775B15006656AD /* Frameworks */, 5E7F485722775B15006656AD /* Resources */, - B112143D0A46BAE4E66475F8 /* [CP] Embed Pods Frameworks */, - 996BCBE3467BA6EA7FD49408 /* [CP] Copy Pods Resources */, + 292EA42A76AC7933A37235FD /* [CP] Embed Pods Frameworks */, + 30AFD6F6FC40B9923632A866 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -313,12 +470,12 @@ isa = PBXNativeTarget; buildConfigurationList = 5EA477002272816B000F72FC /* Build configuration list for PBXNativeTarget "InteropTests" */; buildPhases = ( - 71F4FF8BADB6E545CD692B6C /* [CP] Check Pods Manifest.lock */, + 40BCDB09674DF988C708D22B /* [CP] Check Pods Manifest.lock */, 5EA476F02272816A000F72FC /* Sources */, 5EA476F12272816A000F72FC /* Frameworks */, 5EA476F22272816A000F72FC /* Resources */, - E31E6BE4FCE4DD9487BBAD24 /* [CP] Embed Pods Frameworks */, - 4CC1D806002539B97E065D5A /* [CP] Copy Pods Resources */, + D11CB94CF56A1E53760D29D8 /* [CP] Copy Pods Resources */, + 0FEFD5FC6B323AC95549AE4A /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -333,11 +490,11 @@ isa = PBXNativeTarget; buildConfigurationList = B0BB3EFC225E795F008DA580 /* Build configuration list for PBXNativeTarget "MacTests" */; buildPhases = ( - E180B0BE16D2B14B9071B2F8 /* [CP] Check Pods Manifest.lock */, + E5B20F69559C6AE299DFEA7C /* [CP] Check Pods Manifest.lock */, B0BB3EF3225E795F008DA580 /* Sources */, B0BB3EF4225E795F008DA580 /* Frameworks */, B0BB3EF5225E795F008DA580 /* Resources */, - 8694D2A1C7CEB7391B497CE0 /* [CP] Copy Pods Resources */, + 452FDC3918FEC23ECAFD31EC /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -430,35 +587,49 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 1C48C52EEA28609437176C56 /* [CP] Check Pods Manifest.lock */ = { + 0FEFD5FC6B323AC95549AE4A /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-frameworks.sh", + "${PODS_ROOT}/CronetFramework/Cronet.framework", ); + name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-UnitTests-checkManifestLockResult.txt", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - 4CC1D806002539B97E065D5A /* [CP] Copy Pods Resources */ = { + 292EA42A76AC7933A37235FD /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-frameworks.sh", + "${PODS_ROOT}/CronetFramework/Cronet.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 30AFD6F6FC40B9923632A866 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; @@ -467,10 +638,10 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 71F4FF8BADB6E545CD692B6C /* [CP] Check Pods Manifest.lock */ = { + 40BCDB09674DF988C708D22B /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -492,7 +663,7 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 8694D2A1C7CEB7391B497CE0 /* [CP] Copy Pods Resources */ = { + 452FDC3918FEC23ECAFD31EC /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -510,25 +681,7 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MacTests/Pods-MacTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 996BCBE3467BA6EA7FD49408 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 9D72085F3319466831FF534B /* [CP] Copy Pods Resources */ = { + 9AD0B5E94F2AA5962EA6AA36 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -546,7 +699,7 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-UnitTests/Pods-UnitTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; - A9802246E6D152C53B842F78 /* [CP] Check Pods Manifest.lock */ = { + CCAEC0F23E05489651A07D53 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -568,25 +721,25 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - B112143D0A46BAE4E66475F8 /* [CP] Embed Pods Frameworks */ = { + D11CB94CF56A1E53760D29D8 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-frameworks.sh", - "${PODS_ROOT}/CronetFramework/Cronet.framework", + "${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-resources.sh", + "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); - name = "[CP] Embed Pods Frameworks"; + name = "[CP] Copy Pods Resources"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; - E180B0BE16D2B14B9071B2F8 /* [CP] Check Pods Manifest.lock */ = { + E5B20F69559C6AE299DFEA7C /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -608,22 +761,22 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - E31E6BE4FCE4DD9487BBAD24 /* [CP] Embed Pods Frameworks */ = { + F07941C0BAF6A7C67AA60C48 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-frameworks.sh", - "${PODS_ROOT}/CronetFramework/Cronet.framework", + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); - name = "[CP] Embed Pods Frameworks"; + name = "[CP] Check Pods Manifest.lock"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", + "$(DERIVED_FILE_DIR)/Pods-UnitTests-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-frameworks.sh\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -692,7 +845,7 @@ /* Begin XCBuildConfiguration section */ 5E0282EE215AA697007AC99D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 936ADE0FD98D66144C935C37 /* Pods-UnitTests.debug.xcconfig */; + baseConfigurationReference = A2DCF2570BE515B62CB924CA /* Pods-UnitTests.debug.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -723,7 +876,7 @@ }; 5E0282EF215AA697007AC99D /* Test */ = { isa = XCBuildConfiguration; - baseConfigurationReference = B3C890A1E6F082CD283069BF /* Pods-UnitTests.test.xcconfig */; + baseConfigurationReference = 94D7A5FAA13480E9A5166D7A /* Pods-UnitTests.test.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -752,7 +905,7 @@ }; 5E0282F0215AA697007AC99D /* Cronet */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 4A76E027206C07B7DBECB301 /* Pods-UnitTests.cronet.xcconfig */; + baseConfigurationReference = E1E7660656D902104F728892 /* Pods-UnitTests.cronet.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -781,7 +934,7 @@ }; 5E0282F1215AA697007AC99D /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 9E48AF01E76B19FAAAACAE23 /* Pods-UnitTests.release.xcconfig */; + baseConfigurationReference = EBFFEC04B514CB0D4922DC40 /* Pods-UnitTests.release.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -857,7 +1010,7 @@ }; 5E7F485F22775B15006656AD /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 9AEB5A4889D2018866BE6050 /* Pods-CronetTests.debug.xcconfig */; + baseConfigurationReference = EC66920112123D2DB1CB7F6C /* Pods-CronetTests.debug.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -898,7 +1051,7 @@ }; 5E7F486022775B15006656AD /* Test */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 55BBF7900C93644CD8236BD2 /* Pods-CronetTests.test.xcconfig */; + baseConfigurationReference = 5AB9A82F289D548D6B8816F9 /* Pods-CronetTests.test.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -936,7 +1089,7 @@ }; 5E7F486122775B15006656AD /* Cronet */ = { isa = XCBuildConfiguration; - baseConfigurationReference = B43404F2B37A38483BE4704A /* Pods-CronetTests.cronet.xcconfig */; + baseConfigurationReference = 20F6A3D59D0EE091E2D43953 /* Pods-CronetTests.cronet.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -974,7 +1127,7 @@ }; 5E7F486222775B15006656AD /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = FF0A4B1F995C18C1EB86D155 /* Pods-CronetTests.release.xcconfig */; + baseConfigurationReference = 7F4F42EBAF311E9F84FCA32E /* Pods-CronetTests.release.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1012,7 +1165,7 @@ }; 5EA476FC2272816B000F72FC /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = C56A093740F31650ACDD9630 /* Pods-InteropTests.debug.xcconfig */; + baseConfigurationReference = 680439AC2BC8761EDD54A1EA /* Pods-InteropTests.debug.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1047,7 +1200,7 @@ }; 5EA476FD2272816B000F72FC /* Test */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 5CF07AAE0442D200BCD81ABC /* Pods-InteropTests.test.xcconfig */; + baseConfigurationReference = 070266E2626EB997B54880A3 /* Pods-InteropTests.test.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1079,7 +1232,7 @@ }; 5EA476FE2272816B000F72FC /* Cronet */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 16B9B1262FE6FBFC353B62BB /* Pods-InteropTests.cronet.xcconfig */; + baseConfigurationReference = CDF6CC70B8BF9D10EFE7D199 /* Pods-InteropTests.cronet.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1111,7 +1264,7 @@ }; 5EA476FF2272816B000F72FC /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 42DF8A339EF81AFE13553D04 /* Pods-InteropTests.release.xcconfig */; + baseConfigurationReference = F6A7EECACBB4849DDD3F450A /* Pods-InteropTests.release.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1271,7 +1424,7 @@ }; B0BB3EFD225E795F008DA580 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = BC5D3F3B5B38B71CA279AF7F /* Pods-MacTests.debug.xcconfig */; + baseConfigurationReference = E3ACD4D5902745976D9C2229 /* Pods-MacTests.debug.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1308,7 +1461,7 @@ }; B0BB3EFE225E795F008DA580 /* Test */ = { isa = XCBuildConfiguration; - baseConfigurationReference = DA532DBBE1BC0DC8EC879FE1 /* Pods-MacTests.test.xcconfig */; + baseConfigurationReference = 1F5E788FBF9A4A06EB9E1ACD /* Pods-MacTests.test.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1351,7 +1504,7 @@ }; B0BB3EFF225E795F008DA580 /* Cronet */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7612BA4B2A55BC4F508570C2 /* Pods-MacTests.cronet.xcconfig */; + baseConfigurationReference = 16A2E4C5839C83FBDA63881F /* Pods-MacTests.cronet.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1385,7 +1538,7 @@ }; B0BB3F00225E795F008DA580 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 5287652093398BAA7C5A90E8 /* Pods-MacTests.release.xcconfig */; + baseConfigurationReference = 1E43EAE443CBB4482B1EB071 /* Pods-MacTests.release.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; From 2d498d2b6c01f5f20be71bbe52d49b46ce751332 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 26 Jul 2019 17:18:37 -0700 Subject: [PATCH 1012/1555] Add a few tests for ContextList and BufferList. Also, check that timestamps is non-null before modifying it. --- .../chttp2/transport/context_list.cc | 4 +- test/core/iomgr/buffer_list_test.cc | 24 +++++++ .../transport/chttp2/context_list_test.cc | 72 +++++++++++++++++-- 3 files changed, 95 insertions(+), 5 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/context_list.cc b/src/core/ext/transport/chttp2/transport/context_list.cc index df09809067d..245e8135833 100644 --- a/src/core/ext/transport/chttp2/transport/context_list.cc +++ b/src/core/ext/transport/chttp2/transport/context_list.cc @@ -46,7 +46,9 @@ void ContextList::Execute(void* arg, grpc_core::Timestamps* ts, ContextList* to_be_freed; while (head != nullptr) { if (write_timestamps_callback_g) { - ts->byte_offset = static_cast(head->byte_offset_); + if (ts) { + ts->byte_offset = static_cast(head->byte_offset_); + } write_timestamps_callback_g(head->trace_context_, ts, error); } to_be_freed = head; diff --git a/test/core/iomgr/buffer_list_test.cc b/test/core/iomgr/buffer_list_test.cc index 70e36940425..d71bb9ace2b 100644 --- a/test/core/iomgr/buffer_list_test.cc +++ b/test/core/iomgr/buffer_list_test.cc @@ -92,9 +92,33 @@ static void TestVerifierCalledOnAck() { grpc_core::TracedBuffer::Shutdown(&list, nullptr, GRPC_ERROR_NONE); } +/** Tests that shutdown can be called repeatedly. + */ +static void TestRepeatedShutdown() { + struct sock_extended_err serr; + serr.ee_data = 213; + serr.ee_info = grpc_core::SCM_TSTAMP_ACK; + struct grpc_core::scm_timestamping tss; + tss.ts[0].tv_sec = 123; + tss.ts[0].tv_nsec = 456; + grpc_core::grpc_tcp_set_write_timestamps_callback( + TestVerifierCalledOnAckVerifier); + grpc_core::TracedBuffer* list = nullptr; + gpr_atm verifier_called; + gpr_atm_rel_store(&verifier_called, static_cast(0)); + grpc_core::TracedBuffer::AddNewEntry(&list, 213, 0, &verifier_called); + grpc_core::TracedBuffer::ProcessTimestamp(&list, &serr, nullptr, &tss); + GPR_ASSERT(gpr_atm_acq_load(&verifier_called) == static_cast(1)); + GPR_ASSERT(list == nullptr); + grpc_core::TracedBuffer::Shutdown(&list, nullptr, GRPC_ERROR_NONE); + grpc_core::TracedBuffer::Shutdown(&list, nullptr, GRPC_ERROR_NONE); + grpc_core::TracedBuffer::Shutdown(&list, nullptr, GRPC_ERROR_NONE); +} + static void TestTcpBufferList() { TestVerifierCalledOnAck(); TestShutdownFlushesList(); + TestRepeatedShutdown(); } int main(int argc, char** argv) { diff --git a/test/core/transport/chttp2/context_list_test.cc b/test/core/transport/chttp2/context_list_test.cc index 0379eaaee4c..f8c0bee0afb 100644 --- a/test/core/transport/chttp2/context_list_test.cc +++ b/test/core/transport/chttp2/context_list_test.cc @@ -42,21 +42,29 @@ void TestExecuteFlushesListVerifier(void* arg, grpc_core::Timestamps* ts, grpc_error* error) { ASSERT_NE(arg, nullptr); EXPECT_EQ(error, GRPC_ERROR_NONE); - EXPECT_EQ(ts->byte_offset, kByteOffset); + if (ts) { + EXPECT_EQ(ts->byte_offset, kByteOffset); + } gpr_atm* done = reinterpret_cast(arg); gpr_atm_rel_store(done, static_cast(1)); } void discard_write(grpc_slice slice) {} +class ContextListTest : public ::testing::Test { + protected: + void SetUp() override { + grpc_http2_set_write_timestamps_callback(TestExecuteFlushesListVerifier); + grpc_http2_set_fn_get_copied_context(DummyArgsCopier); + } +}; + /** Tests that all ContextList elements in the list are flushed out on * execute. * Also tests that arg and byte_counter are passed correctly. */ -TEST(ContextList, ExecuteFlushesList) { +TEST_F(ContextListTest, ExecuteFlushesList) { grpc_core::ContextList* list = nullptr; - grpc_http2_set_write_timestamps_callback(TestExecuteFlushesListVerifier); - grpc_http2_set_fn_get_copied_context(DummyArgsCopier); const int kNumElems = 5; grpc_core::ExecCtx exec_ctx; grpc_stream_refcount ref; @@ -95,6 +103,62 @@ TEST(ContextList, ExecuteFlushesList) { grpc_resource_quota_unref(resource_quota); exec_ctx.Flush(); } + +TEST_F(ContextListTest, EmptyList) { + grpc_core::ContextList* list = nullptr; + grpc_core::ExecCtx exec_ctx; + grpc_core::Timestamps ts; + grpc_core::ContextList::Execute(list, &ts, GRPC_ERROR_NONE); + exec_ctx.Flush(); +} + +TEST_F(ContextListTest, EmptyListEmptyTimestamp) { + grpc_core::ContextList* list = nullptr; + grpc_core::ExecCtx exec_ctx; + grpc_core::ContextList::Execute(list, nullptr, GRPC_ERROR_NONE); + exec_ctx.Flush(); +} + +TEST_F(ContextListTest, NonEmptyListEmptyTimestamp) { + grpc_core::ContextList* list = nullptr; + const int kNumElems = 5; + grpc_core::ExecCtx exec_ctx; + grpc_stream_refcount ref; + GRPC_STREAM_REF_INIT(&ref, 1, nullptr, nullptr, "dummy ref"); + grpc_resource_quota* resource_quota = + grpc_resource_quota_create("context_list_test"); + grpc_endpoint* mock_endpoint = + grpc_mock_endpoint_create(discard_write, resource_quota); + grpc_transport* t = + grpc_create_chttp2_transport(nullptr, mock_endpoint, true); + std::vector s; + s.reserve(kNumElems); + gpr_atm verifier_called[kNumElems]; + for (auto i = 0; i < kNumElems; i++) { + s.push_back(static_cast( + gpr_malloc(grpc_transport_stream_size(t)))); + grpc_transport_init_stream(reinterpret_cast(t), + reinterpret_cast(s[i]), &ref, + nullptr, nullptr); + s[i]->context = &verifier_called[i]; + s[i]->byte_counter = kByteOffset; + gpr_atm_rel_store(&verifier_called[i], static_cast(0)); + grpc_core::ContextList::Append(&list, s[i]); + } + grpc_core::ContextList::Execute(list, nullptr, GRPC_ERROR_NONE); + for (auto i = 0; i < kNumElems; i++) { + EXPECT_EQ(gpr_atm_acq_load(&verifier_called[i]), static_cast(1)); + grpc_transport_destroy_stream(reinterpret_cast(t), + reinterpret_cast(s[i]), + nullptr); + exec_ctx.Flush(); + gpr_free(s[i]); + } + grpc_transport_destroy(t); + grpc_resource_quota_unref(resource_quota); + exec_ctx.Flush(); +} + } // namespace } // namespace testing } // namespace grpc_core From d06618d56a56775323c1ed4571716ec2f6724dbb Mon Sep 17 00:00:00 2001 From: Zhehao /Tony/ Lu Date: Fri, 26 Jul 2019 22:13:28 -0700 Subject: [PATCH 1013/1555] Modified script to empty Build/ before each build --- src/objective-c/examples/SwiftSample/Podfile | 2 +- src/objective-c/tests/build_one_example.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/objective-c/examples/SwiftSample/Podfile b/src/objective-c/examples/SwiftSample/Podfile index 01ef90696ca..8214371bc59 100644 --- a/src/objective-c/examples/SwiftSample/Podfile +++ b/src/objective-c/examples/SwiftSample/Podfile @@ -10,7 +10,7 @@ GRPC_LOCAL_SRC = '../../../..' target 'SwiftSample' do # Depend on the generated RemoteTestClient library - pod 'RemoteTest', :path => "." + pod 'RemoteTest', :path => "../RemoteTestClient" # Use the local versions of Protobuf, BoringSSL, and gRPC. You don't need any of the following # lines in your application. diff --git a/src/objective-c/tests/build_one_example.sh b/src/objective-c/tests/build_one_example.sh index 084147f1d46..a7d1eef7b30 100755 --- a/src/objective-c/tests/build_one_example.sh +++ b/src/objective-c/tests/build_one_example.sh @@ -30,6 +30,7 @@ cd `dirname $0`/../../.. cd $EXAMPLE_PATH # clean the directory +rm -rf Build/* rm -rf Pods rm -rf $SCHEME.xcworkspace rm -f Podfile.lock From 0975fc20649779036d66daf2eb5b000ba1ca7032 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Sat, 27 Jul 2019 12:31:23 -0700 Subject: [PATCH 1014/1555] Second attempt: Simplify LB policy and resolver shutdown. --- .../ext/filters/client_channel/lb_policy.cc | 19 ++----------------- .../ext/filters/client_channel/lb_policy.h | 4 +--- .../client_channel/lb_policy/xds/xds.cc | 3 +++ .../ext/filters/client_channel/resolver.h | 14 +++----------- 4 files changed, 9 insertions(+), 31 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy.cc b/src/core/ext/filters/client_channel/lb_policy.cc index 3e4d3703c82..3207f888044 100644 --- a/src/core/ext/filters/client_channel/lb_policy.cc +++ b/src/core/ext/filters/client_channel/lb_policy.cc @@ -43,23 +43,8 @@ LoadBalancingPolicy::~LoadBalancingPolicy() { } void LoadBalancingPolicy::Orphan() { - // Invoke ShutdownAndUnrefLocked() inside of the combiner. - // TODO(roth): Is this actually needed? We should already be in the - // combiner here. Note that if we directly call ShutdownLocked(), - // then we can probably remove the hack whereby the helper is - // destroyed at shutdown instead of at destruction. - GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_CREATE(&LoadBalancingPolicy::ShutdownAndUnrefLocked, this, - grpc_combiner_scheduler(combiner_)), - GRPC_ERROR_NONE); -} - -void LoadBalancingPolicy::ShutdownAndUnrefLocked(void* arg, - grpc_error* ignored) { - LoadBalancingPolicy* policy = static_cast(arg); - policy->ShutdownLocked(); - policy->channel_control_helper_.reset(); - policy->Unref(); + ShutdownLocked(); + Unref(); } // diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h index c21e9d90ec4..ecc235bb71b 100644 --- a/src/core/ext/filters/client_channel/lb_policy.h +++ b/src/core/ext/filters/client_channel/lb_policy.h @@ -282,6 +282,7 @@ class LoadBalancingPolicy : public InternallyRefCounted { grpc_pollset_set* interested_parties() const { return interested_parties_; } + // Note: This must be invoked while holding the combiner. void Orphan() override; // A picker that returns PICK_QUEUE for all picks. @@ -322,7 +323,6 @@ class LoadBalancingPolicy : public InternallyRefCounted { // Note: LB policies MUST NOT call any method on the helper from their // constructor. - // Note: This will return null after ShutdownLocked() has been called. ChannelControlHelper* channel_control_helper() const { return channel_control_helper_.get(); } @@ -331,8 +331,6 @@ class LoadBalancingPolicy : public InternallyRefCounted { virtual void ShutdownLocked() GRPC_ABSTRACT; private: - static void ShutdownAndUnrefLocked(void* arg, grpc_error* ignored); - /// Combiner under which LB policy actions take place. grpc_combiner* combiner_; /// Owned pointer to interested parties in load balancing decisions. diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index ff608e58857..9721972511a 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -1986,6 +1986,9 @@ void XdsLb::LocalityMap::LocalityEntry::ShutdownLocked() { parent_->interested_parties()); pending_child_policy_.reset(); } + // Drop our ref to the child's picker, in case it's holding a ref to + // the child. + picker_ref_.reset(); } void XdsLb::LocalityMap::LocalityEntry::ResetBackoffLocked() { diff --git a/src/core/ext/filters/client_channel/resolver.h b/src/core/ext/filters/client_channel/resolver.h index 87a4442d75b..829a860040a 100644 --- a/src/core/ext/filters/client_channel/resolver.h +++ b/src/core/ext/filters/client_channel/resolver.h @@ -117,12 +117,10 @@ class Resolver : public InternallyRefCounted { /// implementations. At that point, this method can go away. virtual void ResetBackoffLocked() {} + // Note: This must be invoked while holding the combiner. void Orphan() override { - // Invoke ShutdownAndUnrefLocked() inside of the combiner. - GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_CREATE(&Resolver::ShutdownAndUnrefLocked, this, - grpc_combiner_scheduler(combiner_)), - GRPC_ERROR_NONE); + ShutdownLocked(); + Unref(); } GRPC_ABSTRACT_BASE_CLASS @@ -147,12 +145,6 @@ class Resolver : public InternallyRefCounted { ResultHandler* result_handler() const { return result_handler_.get(); } private: - static void ShutdownAndUnrefLocked(void* arg, grpc_error* ignored) { - Resolver* resolver = static_cast(arg); - resolver->ShutdownLocked(); - resolver->Unref(); - } - UniquePtr result_handler_; grpc_combiner* combiner_; }; From db3d8be6471998f73a39e37d9f6ee9fb95ab6b9c Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Sat, 27 Jul 2019 12:35:38 -0700 Subject: [PATCH 1015/1555] Add MetadataInterface abstraction to LB policy API. --- .../filters/client_channel/client_channel.cc | 62 +- .../ext/filters/client_channel/lb_policy.h | 38 +- .../grpclb/client_load_reporting_filter.cc | 30 +- .../client_channel/lb_policy/grpclb/grpclb.cc | 126 ++-- .../client_channel/lb_policy/grpclb/grpclb.h | 7 + .../server_load_reporting_filter.cc | 6 +- src/core/lib/transport/static_metadata.cc | 653 +++++++++--------- src/core/lib/transport/static_metadata.h | 202 +++--- test/core/end2end/fuzzers/hpack.dictionary | 2 - test/core/util/test_lb_policies.cc | 24 +- tools/codegen/core/gen_static_metadata.py | 49 +- 11 files changed, 672 insertions(+), 527 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index c06e995f5a5..8234237cc19 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -320,6 +320,54 @@ class CallData { private: class QueuedPickCanceller; + class Metadata : public LoadBalancingPolicy::MetadataInterface { + public: + Metadata(CallData* calld, grpc_metadata_batch* batch) + : calld_(calld), batch_(batch) {} + + void Add(StringView key, StringView value) override { + grpc_linked_mdelem* linked_mdelem = static_cast( + calld_->arena_->Alloc(sizeof(grpc_linked_mdelem))); + linked_mdelem->md = grpc_mdelem_from_slices( + grpc_slice_from_static_buffer_internal(key.data(), key.size()), + grpc_slice_from_static_buffer_internal(value.data(), value.size())); + GPR_ASSERT(grpc_metadata_batch_link_tail(batch_, linked_mdelem) == + GRPC_ERROR_NONE); + } + + Iterator Begin() const override { + static_assert(sizeof(grpc_linked_mdelem*) <= sizeof(Iterator), + "iterator size too large"); + return reinterpret_cast(batch_->list.head); + } + bool IsEnd(Iterator it) const override { + return reinterpret_cast(it) == nullptr; + } + void Next(Iterator* it) const override { + *it = reinterpret_cast( + reinterpret_cast(*it)->next); + } + StringView Key(Iterator it) const override { + return StringView( + GRPC_MDKEY(reinterpret_cast(it)->md)); + } + StringView Value(Iterator it) const override { + return StringView( + GRPC_MDVALUE(reinterpret_cast(it)->md)); + } + + void Erase(Iterator* it) override { + grpc_linked_mdelem* linked_mdelem = + reinterpret_cast(*it); + *it = reinterpret_cast(linked_mdelem->next); + grpc_metadata_batch_remove(batch_, linked_mdelem); + } + + private: + CallData* calld_; + grpc_metadata_batch* batch_; + }; + class LbCallState : public LoadBalancingPolicy::CallState { public: explicit LbCallState(CallData* calld) : calld_(calld) {} @@ -660,7 +708,8 @@ class CallData { LbCallState lb_call_state_; RefCountedPtr connected_subchannel_; void (*lb_recv_trailing_metadata_ready_)( - void* user_data, grpc_metadata_batch* recv_trailing_metadata, + void* user_data, + LoadBalancingPolicy::MetadataInterface* recv_trailing_metadata, LoadBalancingPolicy::CallState* call_state) = nullptr; void* lb_recv_trailing_metadata_ready_user_data_ = nullptr; grpc_closure pick_closure_; @@ -2109,9 +2158,10 @@ void CallData::RecvTrailingMetadataReadyForLoadBalancingPolicy( void* arg, grpc_error* error) { CallData* calld = static_cast(arg); // Invoke callback to LB policy. + Metadata trailing_metadata(calld, calld->recv_trailing_metadata_); calld->lb_recv_trailing_metadata_ready_( - calld->lb_recv_trailing_metadata_ready_user_data_, - calld->recv_trailing_metadata_, &calld->lb_call_state_); + calld->lb_recv_trailing_metadata_ready_user_data_, &trailing_metadata, + &calld->lb_call_state_); // Chain to original callback. GRPC_CLOSURE_RUN(calld->original_recv_trailing_metadata_ready_, GRPC_ERROR_REF(error)); @@ -3716,11 +3766,13 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { // attempt) to the LB policy instead the one from the parent channel. LoadBalancingPolicy::PickArgs pick_args; pick_args.call_state = &calld->lb_call_state_; - pick_args.initial_metadata = + Metadata initial_metadata( + calld, calld->seen_send_initial_metadata_ ? &calld->send_initial_metadata_ : calld->pending_batches_[0] - .batch->payload->send_initial_metadata.send_initial_metadata; + .batch->payload->send_initial_metadata.send_initial_metadata); + pick_args.initial_metadata = &initial_metadata; // Grab initial metadata flags so that we can check later if the call has // wait_for_ready enabled. const uint32_t send_initial_metadata_flags = diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h index c21e9d90ec4..c7d3f7c929e 100644 --- a/src/core/ext/filters/client_channel/lb_policy.h +++ b/src/core/ext/filters/client_channel/lb_policy.h @@ -27,10 +27,10 @@ #include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" +#include "src/core/lib/gprpp/string_view.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/polling_entity.h" #include "src/core/lib/transport/connectivity_state.h" -#include "src/core/lib/transport/metadata_batch.h" namespace grpc_core { @@ -92,14 +92,44 @@ class LoadBalancingPolicy : public InternallyRefCounted { GRPC_ABSTRACT_BASE_CLASS }; + /// Interface for accessing metadata. + class MetadataInterface { + public: + // Implementations whose iterators fit in intptr_t may internally + // cast this directly to their iterator type. Otherwise, they may + // dynamically allocate their iterators and store the address here. + typedef intptr_t Iterator; + + virtual ~MetadataInterface() = default; + + /// Adds a key/value pair. + /// Does NOT take ownership of \a key or \a value. + /// Implementations must ensure that the key and value remain alive + /// until the call ends. If desired, they may be allocated via + /// CallState::Alloc(). + virtual void Add(StringView key, StringView value) GRPC_ABSTRACT; + + /// Iteration interface. + virtual Iterator Begin() const GRPC_ABSTRACT; + virtual bool IsEnd(Iterator it) const GRPC_ABSTRACT; + virtual void Next(Iterator* it) const GRPC_ABSTRACT; + virtual StringView Key(Iterator it) const GRPC_ABSTRACT; + virtual StringView Value(Iterator it) const GRPC_ABSTRACT; + + /// Removes the element pointed to by \a it, which is modified to + /// point to the next element. + virtual void Erase(Iterator* it) GRPC_ABSTRACT; + + GRPC_ABSTRACT_BASE_CLASS + }; + /// Arguments used when picking a subchannel for an RPC. struct PickArgs { /// Initial metadata associated with the picking call. /// The LB policy may use the existing metadata to influence its routing /// decision, and it may add new metadata elements to be sent with the /// call to the chosen backend. - // TODO(roth): Provide a more generic metadata API here. - grpc_metadata_batch* initial_metadata = nullptr; + MetadataInterface* initial_metadata; /// An interface for accessing call state. Can be used to allocate /// data associated with the call in an efficient way. CallState* call_state; @@ -145,7 +175,7 @@ class LoadBalancingPolicy : public InternallyRefCounted { /// however, so any data that needs to be used after returning must /// be copied. void (*recv_trailing_metadata_ready)( - void* user_data, grpc_metadata_batch* recv_trailing_metadata, + void* user_data, MetadataInterface* recv_trailing_metadata, CallState* call_state) = nullptr; void* recv_trailing_metadata_ready_user_data = nullptr; }; diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc index 3bb31fe3b08..3057b26d315 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc @@ -20,9 +20,12 @@ #include "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h" +#include + #include #include +#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h" #include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/profiling/timers.h" @@ -95,22 +98,33 @@ static void start_transport_stream_op_batch( GPR_TIMER_SCOPE("clr_start_transport_stream_op_batch", 0); // Handle send_initial_metadata. if (batch->send_initial_metadata) { - // Grab client stats object from user_data for LB token metadata. - grpc_linked_mdelem* lb_token = - batch->payload->send_initial_metadata.send_initial_metadata->idx.named - .lb_token; - if (lb_token != nullptr) { + // Grab client stats object from metadata. + grpc_linked_mdelem* client_stats_md = + batch->payload->send_initial_metadata.send_initial_metadata->list.head; + for (; client_stats_md != nullptr; + client_stats_md = client_stats_md->next) { + if (GRPC_SLICE_START_PTR(GRPC_MDKEY(client_stats_md->md)) == + static_cast(grpc_core::kGrpcLbClientStatsMetadataKey)) { + break; + } + } + if (client_stats_md != nullptr) { grpc_core::GrpcLbClientStats* client_stats = - static_cast(grpc_mdelem_get_user_data( - lb_token->md, grpc_core::GrpcLbClientStats::Destroy)); + const_cast( + reinterpret_cast( + GRPC_SLICE_START_PTR(GRPC_MDVALUE(client_stats_md->md)))); if (client_stats != nullptr) { - calld->client_stats = client_stats->Ref(); + calld->client_stats.reset(client_stats); // Intercept completion. calld->original_on_complete_for_send = batch->on_complete; GRPC_CLOSURE_INIT(&calld->on_complete_for_send, on_complete_for_send, calld, grpc_schedule_on_exec_ctx); batch->on_complete = &calld->on_complete_for_send; } + // Remove metadata so it doesn't go out on the wire. + grpc_metadata_batch_remove( + batch->payload->send_initial_metadata.send_initial_metadata, + client_stats_md); } } // Intercept completion of recv_initial_metadata. diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 2eb1d9d4237..bc4b63b74ec 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -108,11 +108,15 @@ #define GRPC_GRPCLB_DEFAULT_FALLBACK_TIMEOUT_MS 10000 #define GRPC_ARG_GRPCLB_ADDRESS_LB_TOKEN "grpc.grpclb_address_lb_token" +#define GRPC_ARG_GRPCLB_ADDRESS_CLIENT_STATS "grpc.grpclb_address_client_stats" namespace grpc_core { TraceFlag grpc_lb_glb_trace(false, "glb"); +const char kGrpcLbClientStatsMetadataKey[] = "grpclb_client_stats"; +const char kGrpcLbLbTokenMetadataKey[] = "lb-token"; + namespace { constexpr char kGrpclb[] = "grpclb"; @@ -445,24 +449,44 @@ UniquePtr GrpcLb::Serverlist::AsText() const { return result; } -// vtable for LB token channel arg. +// vtables for channel args for LB token and client stats. void* lb_token_copy(void* token) { - return token == nullptr - ? nullptr - : (void*)GRPC_MDELEM_REF(grpc_mdelem{(uintptr_t)token}).payload; + return gpr_strdup(static_cast(token)); } -void lb_token_destroy(void* token) { - if (token != nullptr) { - GRPC_MDELEM_UNREF(grpc_mdelem{(uintptr_t)token}); - } +void lb_token_destroy(void* token) { gpr_free(token); } +void* client_stats_copy(void* p) { + GrpcLbClientStats* client_stats = static_cast(p); + client_stats->Ref().release(); + return p; } -int lb_token_cmp(void* token1, void* token2) { +void client_stats_destroy(void* p) { + GrpcLbClientStats* client_stats = static_cast(p); + client_stats->Unref(); +} +int equal_cmp(void* p1, void* p2) { // Always indicate a match, since we don't want this channel arg to // affect the subchannel's key in the index. + // TODO(roth): Is this right? This does prevent us from needlessly + // recreating the subchannel whenever the LB token or client stats + // changes (i.e., when the balancer call is terminated and reestablished). + // However, it means that we don't actually recreate the subchannel, + // which means that we won't ever switch over to using the new LB + // token or client stats. A better approach might be to find somewhere + // other than the subchannel args to store the LB token and client + // stats. They could be stored in a map and then looked up for each + // call (although we'd need to make sure our Map<> implementation is + // performant enough). Or we could do something more complicated whereby + // we create our own subchannel wrapper to store them, although that would + // involve a lot of refcounting overhead. + // Given that we're trying to move from grpclb to xds at this point, + // and that no one has actually reported any problems with this, we + // probably won't bother fixing this at this point. return 0; } const grpc_arg_pointer_vtable lb_token_arg_vtable = { - lb_token_copy, lb_token_destroy, lb_token_cmp}; + lb_token_copy, lb_token_destroy, equal_cmp}; +const grpc_arg_pointer_vtable client_stats_arg_vtable = { + client_stats_copy, client_stats_destroy, equal_cmp}; bool IsServerValid(const grpc_grpclb_server* server, size_t idx, bool log) { if (server->drop) return false; @@ -498,20 +522,14 @@ ServerAddressList GrpcLb::Serverlist::GetServerAddressList( grpc_resolved_address addr; ParseServer(server, &addr); // LB token processing. - grpc_mdelem lb_token; + char lb_token[GPR_ARRAY_SIZE(server->load_balance_token) + 1]; if (server->has_load_balance_token) { const size_t lb_token_max_length = GPR_ARRAY_SIZE(server->load_balance_token); const size_t lb_token_length = strnlen(server->load_balance_token, lb_token_max_length); - grpc_slice lb_token_mdstr = grpc_slice_from_copied_buffer( - server->load_balance_token, lb_token_length); - lb_token = grpc_mdelem_from_slices(GRPC_MDSTR_LB_TOKEN, lb_token_mdstr); - if (client_stats != nullptr) { - GPR_ASSERT(grpc_mdelem_set_user_data( - lb_token, GrpcLbClientStats::Destroy, - client_stats->Ref().release()) == client_stats); - } + memcpy(lb_token, server->load_balance_token, lb_token_length); + lb_token[lb_token_length] = '\0'; } else { char* uri = grpc_sockaddr_to_uri(&addr); gpr_log(GPR_INFO, @@ -519,16 +537,21 @@ ServerAddressList GrpcLb::Serverlist::GetServerAddressList( "be used instead", uri); gpr_free(uri); - lb_token = GRPC_MDELEM_LB_TOKEN_EMPTY; + lb_token[0] = '\0'; } // Add address. - grpc_arg arg = grpc_channel_arg_pointer_create( - const_cast(GRPC_ARG_GRPCLB_ADDRESS_LB_TOKEN), - (void*)lb_token.payload, &lb_token_arg_vtable); - grpc_channel_args* args = grpc_channel_args_copy_and_add(nullptr, &arg, 1); + InlinedVector args_to_add; + args_to_add.emplace_back(grpc_channel_arg_pointer_create( + const_cast(GRPC_ARG_GRPCLB_ADDRESS_LB_TOKEN), lb_token, + &lb_token_arg_vtable)); + if (client_stats != nullptr) { + args_to_add.emplace_back(grpc_channel_arg_pointer_create( + const_cast(GRPC_ARG_GRPCLB_ADDRESS_CLIENT_STATS), client_stats, + &client_stats_arg_vtable)); + } + grpc_channel_args* args = grpc_channel_args_copy_and_add( + nullptr, args_to_add.data(), args_to_add.size()); addresses.emplace_back(addr, args); - // Clean up. - GRPC_MDELEM_UNREF(lb_token); } return addresses; } @@ -573,25 +596,35 @@ GrpcLb::PickResult GrpcLb::Picker::Pick(PickArgs args) { // If pick succeeded, add LB token to initial metadata. if (result.type == PickResult::PICK_COMPLETE && result.subchannel != nullptr) { - const grpc_arg* arg = grpc_channel_args_find( - result.subchannel->channel_args(), GRPC_ARG_GRPCLB_ADDRESS_LB_TOKEN); + // Encode client stats object into metadata for use by + // client_load_reporting filter. + const grpc_arg* arg = + grpc_channel_args_find(result.subchannel->channel_args(), + GRPC_ARG_GRPCLB_ADDRESS_CLIENT_STATS); + if (arg != nullptr && arg->type == GRPC_ARG_POINTER && + arg->value.pointer.p != nullptr) { + GrpcLbClientStats* client_stats = + static_cast(arg->value.pointer.p); + client_stats->Ref().release(); // Ref passed via metadata. + // The metadata value is a hack: we pretend the pointer points to + // a string and rely on the client_load_reporting filter to know + // how to interpret it. + args.initial_metadata->Add( + kGrpcLbClientStatsMetadataKey, + StringView(reinterpret_cast(client_stats), 0)); + // Update calls-started. + client_stats->AddCallStarted(); + } + // Encode the LB token in metadata. + arg = grpc_channel_args_find(result.subchannel->channel_args(), + GRPC_ARG_GRPCLB_ADDRESS_LB_TOKEN); if (arg == nullptr) { gpr_log(GPR_ERROR, "[grpclb %p picker %p] No LB token for subchannel %p", parent_, this, result.subchannel.get()); abort(); } - grpc_mdelem lb_token = {reinterpret_cast(arg->value.pointer.p)}; - GPR_ASSERT(!GRPC_MDISNULL(lb_token)); - grpc_linked_mdelem* mdelem_storage = static_cast( - args.call_state->Alloc(sizeof(grpc_linked_mdelem))); - GPR_ASSERT(grpc_metadata_batch_add_tail( - args.initial_metadata, mdelem_storage, - GRPC_MDELEM_REF(lb_token)) == GRPC_ERROR_NONE); - GrpcLbClientStats* client_stats = static_cast( - grpc_mdelem_get_user_data(lb_token, GrpcLbClientStats::Destroy)); - if (client_stats != nullptr) { - client_stats->AddCallStarted(); - } + args.initial_metadata->Add(kGrpcLbLbTokenMetadataKey, + static_cast(arg->value.pointer.p)); } return result; } @@ -1411,10 +1444,10 @@ void GrpcLb::UpdateLocked(UpdateArgs args) { // Returns the backend addresses extracted from the given addresses. ServerAddressList ExtractBackendAddresses(const ServerAddressList& addresses) { - void* lb_token = (void*)GRPC_MDELEM_LB_TOKEN_EMPTY.payload; + static const char* lb_token = ""; grpc_arg arg = grpc_channel_arg_pointer_create( - const_cast(GRPC_ARG_GRPCLB_ADDRESS_LB_TOKEN), lb_token, - &lb_token_arg_vtable); + const_cast(GRPC_ARG_GRPCLB_ADDRESS_LB_TOKEN), + const_cast(lb_token), &lb_token_arg_vtable); ServerAddressList backend_addresses; for (size_t i = 0; i < addresses.size(); ++i) { if (!addresses[i].IsBalancer()) { @@ -1826,7 +1859,12 @@ bool maybe_add_client_load_reporting_filter(grpc_channel_stack_builder* builder, grpc_channel_args_find(args, GRPC_ARG_LB_POLICY_NAME); if (channel_arg != nullptr && channel_arg->type == GRPC_ARG_STRING && strcmp(channel_arg->value.string, "grpclb") == 0) { - return grpc_channel_stack_builder_append_filter( + // TODO(roth): When we get around to re-attempting + // https://github.com/grpc/grpc/pull/16214, we should try to keep + // this filter at the very top of the subchannel stack, since that + // will minimize the number of metadata elements that the filter + // needs to iterate through to find the ClientStats object. + return grpc_channel_stack_builder_prepend_filter( builder, (const grpc_channel_filter*)arg, nullptr, nullptr); } return true; diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h index 4d39c4d504b..a032b5dbf1d 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h @@ -32,5 +32,12 @@ #define GRPC_ARG_ADDRESS_IS_BACKEND_FROM_GRPCLB_LOAD_BALANCER \ "grpc.address_is_backend_from_grpclb_load_balancer" +namespace grpc_core { + +extern const char kGrpcLbClientStatsMetadataKey[]; +extern const char kGrpcLbLbTokenMetadataKey[]; + +} // namespace grpc_core + #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_GRPCLB_H \ */ diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc b/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc index 1d373c5b994..f48b0f4fdcf 100644 --- a/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc +++ b/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc @@ -18,12 +18,15 @@ #include +#include + #include #include #include #include #include +#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h" #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/load_reporting/registered_opencensus_objects.h" #include "src/core/ext/filters/load_reporting/server_load_reporting_filter.h" @@ -225,7 +228,8 @@ grpc_filtered_mdelem ServerLoadReportingCallData::RecvInitialMetadataFilter( calld->target_host_[i] = static_cast( tolower(GRPC_SLICE_START_PTR(target_host_slice)[i])); } - } else if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_LB_TOKEN)) { + } else if (grpc_slice_str_cmp(GRPC_MDKEY(md), + grpc_core::kGrpcLbLbTokenMetadataKey) == 0) { if (calld->client_ip_and_lr_token_ == nullptr) { calld->StoreClientIpAndLrToken( reinterpret_cast GRPC_SLICE_START_PTR(GRPC_MDVALUE(md)), diff --git a/src/core/lib/transport/static_metadata.cc b/src/core/lib/transport/static_metadata.cc index 8b0a6f482d7..c83d1e59491 100644 --- a/src/core/lib/transport/static_metadata.cc +++ b/src/core/lib/transport/static_metadata.cc @@ -49,72 +49,72 @@ static uint8_t g_bytes[] = { 101, 113, 117, 101, 115, 116, 103, 114, 112, 99, 45, 105, 110, 116, 101, 114, 110, 97, 108, 45, 115, 116, 114, 101, 97, 109, 45, 101, 110, 99, 111, 100, 105, 110, 103, 45, 114, 101, 113, 117, 101, 115, 116, 117, 115, - 101, 114, 45, 97, 103, 101, 110, 116, 104, 111, 115, 116, 108, 98, 45, - 116, 111, 107, 101, 110, 103, 114, 112, 99, 45, 112, 114, 101, 118, 105, - 111, 117, 115, 45, 114, 112, 99, 45, 97, 116, 116, 101, 109, 112, 116, - 115, 103, 114, 112, 99, 45, 114, 101, 116, 114, 121, 45, 112, 117, 115, - 104, 98, 97, 99, 107, 45, 109, 115, 103, 114, 112, 99, 45, 116, 105, - 109, 101, 111, 117, 116, 49, 50, 51, 52, 103, 114, 112, 99, 46, 119, - 97, 105, 116, 95, 102, 111, 114, 95, 114, 101, 97, 100, 121, 103, 114, - 112, 99, 46, 116, 105, 109, 101, 111, 117, 116, 103, 114, 112, 99, 46, - 109, 97, 120, 95, 114, 101, 113, 117, 101, 115, 116, 95, 109, 101, 115, - 115, 97, 103, 101, 95, 98, 121, 116, 101, 115, 103, 114, 112, 99, 46, - 109, 97, 120, 95, 114, 101, 115, 112, 111, 110, 115, 101, 95, 109, 101, - 115, 115, 97, 103, 101, 95, 98, 121, 116, 101, 115, 47, 103, 114, 112, - 99, 46, 108, 98, 46, 118, 49, 46, 76, 111, 97, 100, 66, 97, 108, - 97, 110, 99, 101, 114, 47, 66, 97, 108, 97, 110, 99, 101, 76, 111, - 97, 100, 47, 103, 114, 112, 99, 46, 104, 101, 97, 108, 116, 104, 46, - 118, 49, 46, 72, 101, 97, 108, 116, 104, 47, 87, 97, 116, 99, 104, - 47, 101, 110, 118, 111, 121, 46, 115, 101, 114, 118, 105, 99, 101, 46, - 100, 105, 115, 99, 111, 118, 101, 114, 121, 46, 118, 50, 46, 65, 103, - 103, 114, 101, 103, 97, 116, 101, 100, 68, 105, 115, 99, 111, 118, 101, - 114, 121, 83, 101, 114, 118, 105, 99, 101, 47, 83, 116, 114, 101, 97, - 109, 65, 103, 103, 114, 101, 103, 97, 116, 101, 100, 82, 101, 115, 111, - 117, 114, 99, 101, 115, 100, 101, 102, 108, 97, 116, 101, 103, 122, 105, - 112, 115, 116, 114, 101, 97, 109, 47, 103, 122, 105, 112, 71, 69, 84, - 80, 79, 83, 84, 47, 47, 105, 110, 100, 101, 120, 46, 104, 116, 109, - 108, 104, 116, 116, 112, 104, 116, 116, 112, 115, 50, 48, 48, 50, 48, - 52, 50, 48, 54, 51, 48, 52, 52, 48, 48, 52, 48, 52, 53, 48, - 48, 97, 99, 99, 101, 112, 116, 45, 99, 104, 97, 114, 115, 101, 116, - 103, 122, 105, 112, 44, 32, 100, 101, 102, 108, 97, 116, 101, 97, 99, - 99, 101, 112, 116, 45, 108, 97, 110, 103, 117, 97, 103, 101, 97, 99, - 99, 101, 112, 116, 45, 114, 97, 110, 103, 101, 115, 97, 99, 99, 101, - 112, 116, 97, 99, 99, 101, 115, 115, 45, 99, 111, 110, 116, 114, 111, - 108, 45, 97, 108, 108, 111, 119, 45, 111, 114, 105, 103, 105, 110, 97, - 103, 101, 97, 108, 108, 111, 119, 97, 117, 116, 104, 111, 114, 105, 122, - 97, 116, 105, 111, 110, 99, 97, 99, 104, 101, 45, 99, 111, 110, 116, - 114, 111, 108, 99, 111, 110, 116, 101, 110, 116, 45, 100, 105, 115, 112, - 111, 115, 105, 116, 105, 111, 110, 99, 111, 110, 116, 101, 110, 116, 45, - 108, 97, 110, 103, 117, 97, 103, 101, 99, 111, 110, 116, 101, 110, 116, - 45, 108, 101, 110, 103, 116, 104, 99, 111, 110, 116, 101, 110, 116, 45, - 108, 111, 99, 97, 116, 105, 111, 110, 99, 111, 110, 116, 101, 110, 116, - 45, 114, 97, 110, 103, 101, 99, 111, 111, 107, 105, 101, 100, 97, 116, - 101, 101, 116, 97, 103, 101, 120, 112, 101, 99, 116, 101, 120, 112, 105, - 114, 101, 115, 102, 114, 111, 109, 105, 102, 45, 109, 97, 116, 99, 104, - 105, 102, 45, 109, 111, 100, 105, 102, 105, 101, 100, 45, 115, 105, 110, - 99, 101, 105, 102, 45, 110, 111, 110, 101, 45, 109, 97, 116, 99, 104, - 105, 102, 45, 114, 97, 110, 103, 101, 105, 102, 45, 117, 110, 109, 111, - 100, 105, 102, 105, 101, 100, 45, 115, 105, 110, 99, 101, 108, 97, 115, - 116, 45, 109, 111, 100, 105, 102, 105, 101, 100, 108, 105, 110, 107, 108, - 111, 99, 97, 116, 105, 111, 110, 109, 97, 120, 45, 102, 111, 114, 119, - 97, 114, 100, 115, 112, 114, 111, 120, 121, 45, 97, 117, 116, 104, 101, - 110, 116, 105, 99, 97, 116, 101, 112, 114, 111, 120, 121, 45, 97, 117, - 116, 104, 111, 114, 105, 122, 97, 116, 105, 111, 110, 114, 97, 110, 103, - 101, 114, 101, 102, 101, 114, 101, 114, 114, 101, 102, 114, 101, 115, 104, - 114, 101, 116, 114, 121, 45, 97, 102, 116, 101, 114, 115, 101, 114, 118, - 101, 114, 115, 101, 116, 45, 99, 111, 111, 107, 105, 101, 115, 116, 114, - 105, 99, 116, 45, 116, 114, 97, 110, 115, 112, 111, 114, 116, 45, 115, - 101, 99, 117, 114, 105, 116, 121, 116, 114, 97, 110, 115, 102, 101, 114, - 45, 101, 110, 99, 111, 100, 105, 110, 103, 118, 97, 114, 121, 118, 105, - 97, 119, 119, 119, 45, 97, 117, 116, 104, 101, 110, 116, 105, 99, 97, - 116, 101, 48, 105, 100, 101, 110, 116, 105, 116, 121, 116, 114, 97, 105, - 108, 101, 114, 115, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, - 47, 103, 114, 112, 99, 103, 114, 112, 99, 80, 85, 84, 108, 98, 45, - 99, 111, 115, 116, 45, 98, 105, 110, 105, 100, 101, 110, 116, 105, 116, - 121, 44, 100, 101, 102, 108, 97, 116, 101, 105, 100, 101, 110, 116, 105, - 116, 121, 44, 103, 122, 105, 112, 100, 101, 102, 108, 97, 116, 101, 44, - 103, 122, 105, 112, 105, 100, 101, 110, 116, 105, 116, 121, 44, 100, 101, - 102, 108, 97, 116, 101, 44, 103, 122, 105, 112}; + 101, 114, 45, 97, 103, 101, 110, 116, 104, 111, 115, 116, 103, 114, 112, + 99, 45, 112, 114, 101, 118, 105, 111, 117, 115, 45, 114, 112, 99, 45, + 97, 116, 116, 101, 109, 112, 116, 115, 103, 114, 112, 99, 45, 114, 101, + 116, 114, 121, 45, 112, 117, 115, 104, 98, 97, 99, 107, 45, 109, 115, + 103, 114, 112, 99, 45, 116, 105, 109, 101, 111, 117, 116, 49, 50, 51, + 52, 103, 114, 112, 99, 46, 119, 97, 105, 116, 95, 102, 111, 114, 95, + 114, 101, 97, 100, 121, 103, 114, 112, 99, 46, 116, 105, 109, 101, 111, + 117, 116, 103, 114, 112, 99, 46, 109, 97, 120, 95, 114, 101, 113, 117, + 101, 115, 116, 95, 109, 101, 115, 115, 97, 103, 101, 95, 98, 121, 116, + 101, 115, 103, 114, 112, 99, 46, 109, 97, 120, 95, 114, 101, 115, 112, + 111, 110, 115, 101, 95, 109, 101, 115, 115, 97, 103, 101, 95, 98, 121, + 116, 101, 115, 47, 103, 114, 112, 99, 46, 108, 98, 46, 118, 49, 46, + 76, 111, 97, 100, 66, 97, 108, 97, 110, 99, 101, 114, 47, 66, 97, + 108, 97, 110, 99, 101, 76, 111, 97, 100, 47, 103, 114, 112, 99, 46, + 104, 101, 97, 108, 116, 104, 46, 118, 49, 46, 72, 101, 97, 108, 116, + 104, 47, 87, 97, 116, 99, 104, 47, 101, 110, 118, 111, 121, 46, 115, + 101, 114, 118, 105, 99, 101, 46, 100, 105, 115, 99, 111, 118, 101, 114, + 121, 46, 118, 50, 46, 65, 103, 103, 114, 101, 103, 97, 116, 101, 100, + 68, 105, 115, 99, 111, 118, 101, 114, 121, 83, 101, 114, 118, 105, 99, + 101, 47, 83, 116, 114, 101, 97, 109, 65, 103, 103, 114, 101, 103, 97, + 116, 101, 100, 82, 101, 115, 111, 117, 114, 99, 101, 115, 100, 101, 102, + 108, 97, 116, 101, 103, 122, 105, 112, 115, 116, 114, 101, 97, 109, 47, + 103, 122, 105, 112, 71, 69, 84, 80, 79, 83, 84, 47, 47, 105, 110, + 100, 101, 120, 46, 104, 116, 109, 108, 104, 116, 116, 112, 104, 116, 116, + 112, 115, 50, 48, 48, 50, 48, 52, 50, 48, 54, 51, 48, 52, 52, + 48, 48, 52, 48, 52, 53, 48, 48, 97, 99, 99, 101, 112, 116, 45, + 99, 104, 97, 114, 115, 101, 116, 103, 122, 105, 112, 44, 32, 100, 101, + 102, 108, 97, 116, 101, 97, 99, 99, 101, 112, 116, 45, 108, 97, 110, + 103, 117, 97, 103, 101, 97, 99, 99, 101, 112, 116, 45, 114, 97, 110, + 103, 101, 115, 97, 99, 99, 101, 112, 116, 97, 99, 99, 101, 115, 115, + 45, 99, 111, 110, 116, 114, 111, 108, 45, 97, 108, 108, 111, 119, 45, + 111, 114, 105, 103, 105, 110, 97, 103, 101, 97, 108, 108, 111, 119, 97, + 117, 116, 104, 111, 114, 105, 122, 97, 116, 105, 111, 110, 99, 97, 99, + 104, 101, 45, 99, 111, 110, 116, 114, 111, 108, 99, 111, 110, 116, 101, + 110, 116, 45, 100, 105, 115, 112, 111, 115, 105, 116, 105, 111, 110, 99, + 111, 110, 116, 101, 110, 116, 45, 108, 97, 110, 103, 117, 97, 103, 101, + 99, 111, 110, 116, 101, 110, 116, 45, 108, 101, 110, 103, 116, 104, 99, + 111, 110, 116, 101, 110, 116, 45, 108, 111, 99, 97, 116, 105, 111, 110, + 99, 111, 110, 116, 101, 110, 116, 45, 114, 97, 110, 103, 101, 99, 111, + 111, 107, 105, 101, 100, 97, 116, 101, 101, 116, 97, 103, 101, 120, 112, + 101, 99, 116, 101, 120, 112, 105, 114, 101, 115, 102, 114, 111, 109, 105, + 102, 45, 109, 97, 116, 99, 104, 105, 102, 45, 109, 111, 100, 105, 102, + 105, 101, 100, 45, 115, 105, 110, 99, 101, 105, 102, 45, 110, 111, 110, + 101, 45, 109, 97, 116, 99, 104, 105, 102, 45, 114, 97, 110, 103, 101, + 105, 102, 45, 117, 110, 109, 111, 100, 105, 102, 105, 101, 100, 45, 115, + 105, 110, 99, 101, 108, 97, 115, 116, 45, 109, 111, 100, 105, 102, 105, + 101, 100, 108, 105, 110, 107, 108, 111, 99, 97, 116, 105, 111, 110, 109, + 97, 120, 45, 102, 111, 114, 119, 97, 114, 100, 115, 112, 114, 111, 120, + 121, 45, 97, 117, 116, 104, 101, 110, 116, 105, 99, 97, 116, 101, 112, + 114, 111, 120, 121, 45, 97, 117, 116, 104, 111, 114, 105, 122, 97, 116, + 105, 111, 110, 114, 97, 110, 103, 101, 114, 101, 102, 101, 114, 101, 114, + 114, 101, 102, 114, 101, 115, 104, 114, 101, 116, 114, 121, 45, 97, 102, + 116, 101, 114, 115, 101, 114, 118, 101, 114, 115, 101, 116, 45, 99, 111, + 111, 107, 105, 101, 115, 116, 114, 105, 99, 116, 45, 116, 114, 97, 110, + 115, 112, 111, 114, 116, 45, 115, 101, 99, 117, 114, 105, 116, 121, 116, + 114, 97, 110, 115, 102, 101, 114, 45, 101, 110, 99, 111, 100, 105, 110, + 103, 118, 97, 114, 121, 118, 105, 97, 119, 119, 119, 45, 97, 117, 116, + 104, 101, 110, 116, 105, 99, 97, 116, 101, 48, 105, 100, 101, 110, 116, + 105, 116, 121, 116, 114, 97, 105, 108, 101, 114, 115, 97, 112, 112, 108, + 105, 99, 97, 116, 105, 111, 110, 47, 103, 114, 112, 99, 103, 114, 112, + 99, 80, 85, 84, 108, 98, 45, 99, 111, 115, 116, 45, 98, 105, 110, + 105, 100, 101, 110, 116, 105, 116, 121, 44, 100, 101, 102, 108, 97, 116, + 101, 105, 100, 101, 110, 116, 105, 116, 121, 44, 103, 122, 105, 112, 100, + 101, 102, 108, 97, 116, 101, 44, 103, 122, 105, 112, 105, 100, 101, 110, + 116, 105, 116, 121, 44, 100, 101, 102, 108, 97, 116, 101, 44, 103, 122, + 105, 112}; static grpc_slice_refcount static_sub_refcnt; grpc_slice_refcount grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT] = { @@ -224,7 +224,6 @@ grpc_slice_refcount grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT] = { grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), }; const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT] = { @@ -249,92 +248,91 @@ const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT] = { {&grpc_static_metadata_refcounts[18], {{37, g_bytes + 231}}}, {&grpc_static_metadata_refcounts[19], {{10, g_bytes + 268}}}, {&grpc_static_metadata_refcounts[20], {{4, g_bytes + 278}}}, - {&grpc_static_metadata_refcounts[21], {{8, g_bytes + 282}}}, - {&grpc_static_metadata_refcounts[22], {{26, g_bytes + 290}}}, - {&grpc_static_metadata_refcounts[23], {{22, g_bytes + 316}}}, - {&grpc_static_metadata_refcounts[24], {{12, g_bytes + 338}}}, - {&grpc_static_metadata_refcounts[25], {{1, g_bytes + 350}}}, - {&grpc_static_metadata_refcounts[26], {{1, g_bytes + 351}}}, - {&grpc_static_metadata_refcounts[27], {{1, g_bytes + 352}}}, - {&grpc_static_metadata_refcounts[28], {{1, g_bytes + 353}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, - {&grpc_static_metadata_refcounts[30], {{19, g_bytes + 354}}}, - {&grpc_static_metadata_refcounts[31], {{12, g_bytes + 373}}}, - {&grpc_static_metadata_refcounts[32], {{30, g_bytes + 385}}}, - {&grpc_static_metadata_refcounts[33], {{31, g_bytes + 415}}}, - {&grpc_static_metadata_refcounts[34], {{36, g_bytes + 446}}}, - {&grpc_static_metadata_refcounts[35], {{28, g_bytes + 482}}}, - {&grpc_static_metadata_refcounts[36], {{80, g_bytes + 510}}}, - {&grpc_static_metadata_refcounts[37], {{7, g_bytes + 590}}}, - {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}, - {&grpc_static_metadata_refcounts[39], {{11, g_bytes + 601}}}, - {&grpc_static_metadata_refcounts[40], {{3, g_bytes + 612}}}, - {&grpc_static_metadata_refcounts[41], {{4, g_bytes + 615}}}, - {&grpc_static_metadata_refcounts[42], {{1, g_bytes + 619}}}, - {&grpc_static_metadata_refcounts[43], {{11, g_bytes + 620}}}, - {&grpc_static_metadata_refcounts[44], {{4, g_bytes + 631}}}, - {&grpc_static_metadata_refcounts[45], {{5, g_bytes + 635}}}, - {&grpc_static_metadata_refcounts[46], {{3, g_bytes + 640}}}, - {&grpc_static_metadata_refcounts[47], {{3, g_bytes + 643}}}, - {&grpc_static_metadata_refcounts[48], {{3, g_bytes + 646}}}, - {&grpc_static_metadata_refcounts[49], {{3, g_bytes + 649}}}, - {&grpc_static_metadata_refcounts[50], {{3, g_bytes + 652}}}, - {&grpc_static_metadata_refcounts[51], {{3, g_bytes + 655}}}, - {&grpc_static_metadata_refcounts[52], {{3, g_bytes + 658}}}, - {&grpc_static_metadata_refcounts[53], {{14, g_bytes + 661}}}, - {&grpc_static_metadata_refcounts[54], {{13, g_bytes + 675}}}, - {&grpc_static_metadata_refcounts[55], {{15, g_bytes + 688}}}, - {&grpc_static_metadata_refcounts[56], {{13, g_bytes + 703}}}, - {&grpc_static_metadata_refcounts[57], {{6, g_bytes + 716}}}, - {&grpc_static_metadata_refcounts[58], {{27, g_bytes + 722}}}, - {&grpc_static_metadata_refcounts[59], {{3, g_bytes + 749}}}, - {&grpc_static_metadata_refcounts[60], {{5, g_bytes + 752}}}, - {&grpc_static_metadata_refcounts[61], {{13, g_bytes + 757}}}, - {&grpc_static_metadata_refcounts[62], {{13, g_bytes + 770}}}, - {&grpc_static_metadata_refcounts[63], {{19, g_bytes + 783}}}, - {&grpc_static_metadata_refcounts[64], {{16, g_bytes + 802}}}, - {&grpc_static_metadata_refcounts[65], {{14, g_bytes + 818}}}, - {&grpc_static_metadata_refcounts[66], {{16, g_bytes + 832}}}, - {&grpc_static_metadata_refcounts[67], {{13, g_bytes + 848}}}, - {&grpc_static_metadata_refcounts[68], {{6, g_bytes + 861}}}, - {&grpc_static_metadata_refcounts[69], {{4, g_bytes + 867}}}, - {&grpc_static_metadata_refcounts[70], {{4, g_bytes + 871}}}, - {&grpc_static_metadata_refcounts[71], {{6, g_bytes + 875}}}, - {&grpc_static_metadata_refcounts[72], {{7, g_bytes + 881}}}, - {&grpc_static_metadata_refcounts[73], {{4, g_bytes + 888}}}, - {&grpc_static_metadata_refcounts[74], {{8, g_bytes + 892}}}, - {&grpc_static_metadata_refcounts[75], {{17, g_bytes + 900}}}, - {&grpc_static_metadata_refcounts[76], {{13, g_bytes + 917}}}, - {&grpc_static_metadata_refcounts[77], {{8, g_bytes + 930}}}, - {&grpc_static_metadata_refcounts[78], {{19, g_bytes + 938}}}, - {&grpc_static_metadata_refcounts[79], {{13, g_bytes + 957}}}, - {&grpc_static_metadata_refcounts[80], {{4, g_bytes + 970}}}, - {&grpc_static_metadata_refcounts[81], {{8, g_bytes + 974}}}, - {&grpc_static_metadata_refcounts[82], {{12, g_bytes + 982}}}, - {&grpc_static_metadata_refcounts[83], {{18, g_bytes + 994}}}, - {&grpc_static_metadata_refcounts[84], {{19, g_bytes + 1012}}}, - {&grpc_static_metadata_refcounts[85], {{5, g_bytes + 1031}}}, - {&grpc_static_metadata_refcounts[86], {{7, g_bytes + 1036}}}, - {&grpc_static_metadata_refcounts[87], {{7, g_bytes + 1043}}}, - {&grpc_static_metadata_refcounts[88], {{11, g_bytes + 1050}}}, - {&grpc_static_metadata_refcounts[89], {{6, g_bytes + 1061}}}, - {&grpc_static_metadata_refcounts[90], {{10, g_bytes + 1067}}}, - {&grpc_static_metadata_refcounts[91], {{25, g_bytes + 1077}}}, - {&grpc_static_metadata_refcounts[92], {{17, g_bytes + 1102}}}, - {&grpc_static_metadata_refcounts[93], {{4, g_bytes + 1119}}}, - {&grpc_static_metadata_refcounts[94], {{3, g_bytes + 1123}}}, - {&grpc_static_metadata_refcounts[95], {{16, g_bytes + 1126}}}, - {&grpc_static_metadata_refcounts[96], {{1, g_bytes + 1142}}}, + {&grpc_static_metadata_refcounts[21], {{26, g_bytes + 282}}}, + {&grpc_static_metadata_refcounts[22], {{22, g_bytes + 308}}}, + {&grpc_static_metadata_refcounts[23], {{12, g_bytes + 330}}}, + {&grpc_static_metadata_refcounts[24], {{1, g_bytes + 342}}}, + {&grpc_static_metadata_refcounts[25], {{1, g_bytes + 343}}}, + {&grpc_static_metadata_refcounts[26], {{1, g_bytes + 344}}}, + {&grpc_static_metadata_refcounts[27], {{1, g_bytes + 345}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, + {&grpc_static_metadata_refcounts[29], {{19, g_bytes + 346}}}, + {&grpc_static_metadata_refcounts[30], {{12, g_bytes + 365}}}, + {&grpc_static_metadata_refcounts[31], {{30, g_bytes + 377}}}, + {&grpc_static_metadata_refcounts[32], {{31, g_bytes + 407}}}, + {&grpc_static_metadata_refcounts[33], {{36, g_bytes + 438}}}, + {&grpc_static_metadata_refcounts[34], {{28, g_bytes + 474}}}, + {&grpc_static_metadata_refcounts[35], {{80, g_bytes + 502}}}, + {&grpc_static_metadata_refcounts[36], {{7, g_bytes + 582}}}, + {&grpc_static_metadata_refcounts[37], {{4, g_bytes + 589}}}, + {&grpc_static_metadata_refcounts[38], {{11, g_bytes + 593}}}, + {&grpc_static_metadata_refcounts[39], {{3, g_bytes + 604}}}, + {&grpc_static_metadata_refcounts[40], {{4, g_bytes + 607}}}, + {&grpc_static_metadata_refcounts[41], {{1, g_bytes + 611}}}, + {&grpc_static_metadata_refcounts[42], {{11, g_bytes + 612}}}, + {&grpc_static_metadata_refcounts[43], {{4, g_bytes + 623}}}, + {&grpc_static_metadata_refcounts[44], {{5, g_bytes + 627}}}, + {&grpc_static_metadata_refcounts[45], {{3, g_bytes + 632}}}, + {&grpc_static_metadata_refcounts[46], {{3, g_bytes + 635}}}, + {&grpc_static_metadata_refcounts[47], {{3, g_bytes + 638}}}, + {&grpc_static_metadata_refcounts[48], {{3, g_bytes + 641}}}, + {&grpc_static_metadata_refcounts[49], {{3, g_bytes + 644}}}, + {&grpc_static_metadata_refcounts[50], {{3, g_bytes + 647}}}, + {&grpc_static_metadata_refcounts[51], {{3, g_bytes + 650}}}, + {&grpc_static_metadata_refcounts[52], {{14, g_bytes + 653}}}, + {&grpc_static_metadata_refcounts[53], {{13, g_bytes + 667}}}, + {&grpc_static_metadata_refcounts[54], {{15, g_bytes + 680}}}, + {&grpc_static_metadata_refcounts[55], {{13, g_bytes + 695}}}, + {&grpc_static_metadata_refcounts[56], {{6, g_bytes + 708}}}, + {&grpc_static_metadata_refcounts[57], {{27, g_bytes + 714}}}, + {&grpc_static_metadata_refcounts[58], {{3, g_bytes + 741}}}, + {&grpc_static_metadata_refcounts[59], {{5, g_bytes + 744}}}, + {&grpc_static_metadata_refcounts[60], {{13, g_bytes + 749}}}, + {&grpc_static_metadata_refcounts[61], {{13, g_bytes + 762}}}, + {&grpc_static_metadata_refcounts[62], {{19, g_bytes + 775}}}, + {&grpc_static_metadata_refcounts[63], {{16, g_bytes + 794}}}, + {&grpc_static_metadata_refcounts[64], {{14, g_bytes + 810}}}, + {&grpc_static_metadata_refcounts[65], {{16, g_bytes + 824}}}, + {&grpc_static_metadata_refcounts[66], {{13, g_bytes + 840}}}, + {&grpc_static_metadata_refcounts[67], {{6, g_bytes + 853}}}, + {&grpc_static_metadata_refcounts[68], {{4, g_bytes + 859}}}, + {&grpc_static_metadata_refcounts[69], {{4, g_bytes + 863}}}, + {&grpc_static_metadata_refcounts[70], {{6, g_bytes + 867}}}, + {&grpc_static_metadata_refcounts[71], {{7, g_bytes + 873}}}, + {&grpc_static_metadata_refcounts[72], {{4, g_bytes + 880}}}, + {&grpc_static_metadata_refcounts[73], {{8, g_bytes + 884}}}, + {&grpc_static_metadata_refcounts[74], {{17, g_bytes + 892}}}, + {&grpc_static_metadata_refcounts[75], {{13, g_bytes + 909}}}, + {&grpc_static_metadata_refcounts[76], {{8, g_bytes + 922}}}, + {&grpc_static_metadata_refcounts[77], {{19, g_bytes + 930}}}, + {&grpc_static_metadata_refcounts[78], {{13, g_bytes + 949}}}, + {&grpc_static_metadata_refcounts[79], {{4, g_bytes + 962}}}, + {&grpc_static_metadata_refcounts[80], {{8, g_bytes + 966}}}, + {&grpc_static_metadata_refcounts[81], {{12, g_bytes + 974}}}, + {&grpc_static_metadata_refcounts[82], {{18, g_bytes + 986}}}, + {&grpc_static_metadata_refcounts[83], {{19, g_bytes + 1004}}}, + {&grpc_static_metadata_refcounts[84], {{5, g_bytes + 1023}}}, + {&grpc_static_metadata_refcounts[85], {{7, g_bytes + 1028}}}, + {&grpc_static_metadata_refcounts[86], {{7, g_bytes + 1035}}}, + {&grpc_static_metadata_refcounts[87], {{11, g_bytes + 1042}}}, + {&grpc_static_metadata_refcounts[88], {{6, g_bytes + 1053}}}, + {&grpc_static_metadata_refcounts[89], {{10, g_bytes + 1059}}}, + {&grpc_static_metadata_refcounts[90], {{25, g_bytes + 1069}}}, + {&grpc_static_metadata_refcounts[91], {{17, g_bytes + 1094}}}, + {&grpc_static_metadata_refcounts[92], {{4, g_bytes + 1111}}}, + {&grpc_static_metadata_refcounts[93], {{3, g_bytes + 1115}}}, + {&grpc_static_metadata_refcounts[94], {{16, g_bytes + 1118}}}, + {&grpc_static_metadata_refcounts[95], {{1, g_bytes + 1134}}}, + {&grpc_static_metadata_refcounts[96], {{8, g_bytes + 1135}}}, {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}, - {&grpc_static_metadata_refcounts[98], {{8, g_bytes + 1151}}}, - {&grpc_static_metadata_refcounts[99], {{16, g_bytes + 1159}}}, - {&grpc_static_metadata_refcounts[100], {{4, g_bytes + 1175}}}, - {&grpc_static_metadata_refcounts[101], {{3, g_bytes + 1179}}}, - {&grpc_static_metadata_refcounts[102], {{11, g_bytes + 1182}}}, - {&grpc_static_metadata_refcounts[103], {{16, g_bytes + 1193}}}, - {&grpc_static_metadata_refcounts[104], {{13, g_bytes + 1209}}}, - {&grpc_static_metadata_refcounts[105], {{12, g_bytes + 1222}}}, - {&grpc_static_metadata_refcounts[106], {{21, g_bytes + 1234}}}, + {&grpc_static_metadata_refcounts[98], {{16, g_bytes + 1151}}}, + {&grpc_static_metadata_refcounts[99], {{4, g_bytes + 1167}}}, + {&grpc_static_metadata_refcounts[100], {{3, g_bytes + 1171}}}, + {&grpc_static_metadata_refcounts[101], {{11, g_bytes + 1174}}}, + {&grpc_static_metadata_refcounts[102], {{16, g_bytes + 1185}}}, + {&grpc_static_metadata_refcounts[103], {{13, g_bytes + 1201}}}, + {&grpc_static_metadata_refcounts[104], {{12, g_bytes + 1214}}}, + {&grpc_static_metadata_refcounts[105], {{21, g_bytes + 1226}}}, }; /* Warning: the core static metadata currently operates under the soft @@ -716,65 +714,60 @@ grpc_mdelem grpc_static_mdelem_manifested[GRPC_STATIC_MDELEM_COUNT] = { GRPC_MAKE_MDELEM( &grpc_static_mdelem_table[73].data(), GRPC_MDELEM_STORAGE_STATIC), - /* GRPC_MDELEM_LB_TOKEN_EMPTY: - "lb-token": "" */ - GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[74].data(), - GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_LB_COST_BIN_EMPTY: "lb-cost-bin": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[75].data(), + &grpc_static_mdelem_table[74].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY: "grpc-accept-encoding": "identity" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[76].data(), + &grpc_static_mdelem_table[75].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE: "grpc-accept-encoding": "deflate" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[77].data(), + &grpc_static_mdelem_table[76].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE: "grpc-accept-encoding": "identity,deflate" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[78].data(), + &grpc_static_mdelem_table[77].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_GZIP: "grpc-accept-encoding": "gzip" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[79].data(), + &grpc_static_mdelem_table[78].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP: "grpc-accept-encoding": "identity,gzip" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[80].data(), + &grpc_static_mdelem_table[79].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE_COMMA_GZIP: "grpc-accept-encoding": "deflate,gzip" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[81].data(), + &grpc_static_mdelem_table[80].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP: "grpc-accept-encoding": "identity,deflate,gzip" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[82].data(), + &grpc_static_mdelem_table[81].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY: "accept-encoding": "identity" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[83].data(), + &grpc_static_mdelem_table[82].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_ACCEPT_ENCODING_GZIP: "accept-encoding": "gzip" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[84].data(), + &grpc_static_mdelem_table[83].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP: "accept-encoding": "identity,gzip" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[85].data(), + &grpc_static_mdelem_table[84].data(), GRPC_MDELEM_STORAGE_STATIC) // clang-format on }; @@ -782,20 +775,20 @@ uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 4, 6, 6, 8, 8, 2, 4, 4}; + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 4, 6, 6, 8, 8, 2, 4, 4}; static const int8_t elems_r[] = { - 15, 10, -8, 0, 2, -42, -81, -43, 0, 6, -8, 0, 0, 0, 2, - -3, -10, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, -64, 0, -67, -68, -69, -70, 0, - 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, - 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, - 5, 4, 5, 4, 4, 8, 8, 0, 0, 0, 0, 0, 0, -5, 0}; + 15, 10, -8, 0, 2, -42, -80, -43, 0, 6, -8, 0, 0, 0, 2, + -3, -10, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -63, 0, -47, -68, -69, -70, -52, 0, + 31, 30, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, + 18, 17, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, + 4, 3, 4, 3, 3, 7, 0, 0, 0, 0, 0, 0, -5, 0}; static uint32_t elems_phash(uint32_t i) { - i -= 42; - uint32_t x = i % 105; - uint32_t y = i / 105; + i -= 41; + uint32_t x = i % 104; + uint32_t y = i / 104; uint32_t h = x; if (y < GPR_ARRAY_SIZE(elems_r)) { uint32_t delta = (uint32_t)elems_r[y]; @@ -805,29 +798,28 @@ static uint32_t elems_phash(uint32_t i) { } static const uint16_t elem_keys[] = { - 260, 261, 262, 263, 264, 265, 266, 1107, 1108, 1741, 147, 148, - 472, 473, 1634, 42, 43, 1527, 1750, 1000, 1001, 774, 775, 1643, - 633, 845, 2062, 2169, 2276, 5700, 5914, 6021, 6128, 6235, 1766, 6342, - 6449, 6556, 6663, 6770, 6877, 6984, 7091, 7198, 7305, 7412, 7519, 7626, - 7733, 7840, 7947, 8054, 8161, 8268, 8375, 8482, 8589, 8696, 8803, 8910, - 9017, 9124, 9231, 9338, 9445, 9552, 9659, 1167, 528, 9766, 9873, 208, - 9980, 1173, 1174, 1175, 1176, 1809, 10087, 1060, 10194, 10943, 1702, 0, - 1816, 0, 0, 1597, 0, 0, 350, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0}; + 257, 258, 259, 260, 261, 262, 263, 1096, 1097, 1724, 145, 146, + 467, 468, 1618, 41, 42, 1512, 1733, 990, 991, 766, 767, 1627, + 627, 837, 2042, 2148, 5540, 5858, 5964, 6070, 6282, 6388, 1749, 6494, + 6600, 6706, 6812, 6918, 7024, 7130, 7236, 7342, 7448, 7554, 7660, 7766, + 5752, 7872, 7978, 6176, 8084, 8190, 8296, 8402, 8508, 8614, 8720, 8826, + 8932, 9038, 9144, 9250, 9356, 9462, 9568, 1156, 523, 9674, 9780, 206, + 9886, 1162, 1163, 1164, 1165, 1792, 9992, 1050, 10734, 0, 1686, 0, + 1799, 0, 0, 1582, 0, 346, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0}; static const uint8_t elem_idxs[] = { - 7, 8, 9, 10, 11, 12, 13, 77, 79, 71, 1, 2, 5, 6, 25, 3, - 4, 30, 84, 66, 65, 62, 63, 73, 67, 61, 57, 37, 74, 14, 16, 17, - 18, 19, 15, 20, 21, 22, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34, - 35, 36, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 76, 69, 55, 56, 70, 58, 78, 80, 81, 82, 83, 59, 64, - 60, 75, 72, 255, 85, 255, 255, 68, 255, 255, 0}; + 7, 8, 9, 10, 11, 12, 13, 76, 78, 71, 1, 2, 5, 6, 25, 3, 4, 30, + 83, 66, 65, 62, 63, 73, 67, 61, 57, 37, 14, 17, 18, 19, 21, 22, 15, 23, + 24, 26, 27, 28, 29, 31, 32, 33, 34, 35, 36, 38, 16, 39, 40, 20, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 75, 69, 56, 58, 70, + 59, 77, 79, 80, 81, 82, 60, 64, 74, 255, 72, 255, 84, 255, 255, 68, 255, 0}; grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b) { if (a == -1 || b == -1) return GRPC_MDNULL; - uint32_t k = static_cast(a * 107 + b); + uint32_t k = static_cast(a * 106 + b); uint32_t h = elems_phash(k); return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k && elem_idxs[h] != 255 @@ -839,264 +831,261 @@ grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b) { grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[3], {{10, g_bytes + 19}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 0), + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 0), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, - {&grpc_static_metadata_refcounts[40], {{3, g_bytes + 612}}}, 1), + {&grpc_static_metadata_refcounts[39], {{3, g_bytes + 604}}}, 1), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, - {&grpc_static_metadata_refcounts[41], {{4, g_bytes + 615}}}, 2), + {&grpc_static_metadata_refcounts[40], {{4, g_bytes + 607}}}, 2), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[0], {{5, g_bytes + 0}}}, - {&grpc_static_metadata_refcounts[42], {{1, g_bytes + 619}}}, 3), + {&grpc_static_metadata_refcounts[41], {{1, g_bytes + 611}}}, 3), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[0], {{5, g_bytes + 0}}}, - {&grpc_static_metadata_refcounts[43], {{11, g_bytes + 620}}}, 4), + {&grpc_static_metadata_refcounts[42], {{11, g_bytes + 612}}}, 4), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, - {&grpc_static_metadata_refcounts[44], {{4, g_bytes + 631}}}, 5), + {&grpc_static_metadata_refcounts[43], {{4, g_bytes + 623}}}, 5), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, - {&grpc_static_metadata_refcounts[45], {{5, g_bytes + 635}}}, 6), + {&grpc_static_metadata_refcounts[44], {{5, g_bytes + 627}}}, 6), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[46], {{3, g_bytes + 640}}}, 7), + {&grpc_static_metadata_refcounts[45], {{3, g_bytes + 632}}}, 7), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[47], {{3, g_bytes + 643}}}, 8), + {&grpc_static_metadata_refcounts[46], {{3, g_bytes + 635}}}, 8), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[48], {{3, g_bytes + 646}}}, 9), + {&grpc_static_metadata_refcounts[47], {{3, g_bytes + 638}}}, 9), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[49], {{3, g_bytes + 649}}}, 10), + {&grpc_static_metadata_refcounts[48], {{3, g_bytes + 641}}}, 10), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[50], {{3, g_bytes + 652}}}, 11), + {&grpc_static_metadata_refcounts[49], {{3, g_bytes + 644}}}, 11), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[51], {{3, g_bytes + 655}}}, 12), + {&grpc_static_metadata_refcounts[50], {{3, g_bytes + 647}}}, 12), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[52], {{3, g_bytes + 658}}}, 13), + {&grpc_static_metadata_refcounts[51], {{3, g_bytes + 650}}}, 13), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[53], {{14, g_bytes + 661}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 14), + {&grpc_static_metadata_refcounts[52], {{14, g_bytes + 653}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 14), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[54], {{13, g_bytes + 675}}}, 15), + {&grpc_static_metadata_refcounts[53], {{13, g_bytes + 667}}}, 15), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[55], {{15, g_bytes + 688}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 16), + {&grpc_static_metadata_refcounts[54], {{15, g_bytes + 680}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 16), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[56], {{13, g_bytes + 703}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 17), + {&grpc_static_metadata_refcounts[55], {{13, g_bytes + 695}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 17), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[57], {{6, g_bytes + 716}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 18), + {&grpc_static_metadata_refcounts[56], {{6, g_bytes + 708}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 18), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[58], {{27, g_bytes + 722}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 19), + {&grpc_static_metadata_refcounts[57], {{27, g_bytes + 714}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 19), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[59], {{3, g_bytes + 749}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 20), + {&grpc_static_metadata_refcounts[58], {{3, g_bytes + 741}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 20), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[60], {{5, g_bytes + 752}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 21), + {&grpc_static_metadata_refcounts[59], {{5, g_bytes + 744}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 21), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[61], {{13, g_bytes + 757}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 22), + {&grpc_static_metadata_refcounts[60], {{13, g_bytes + 749}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 22), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[62], {{13, g_bytes + 770}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 23), + {&grpc_static_metadata_refcounts[61], {{13, g_bytes + 762}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 23), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[63], {{19, g_bytes + 783}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 24), + {&grpc_static_metadata_refcounts[62], {{19, g_bytes + 775}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 24), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 25), + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 25), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[64], {{16, g_bytes + 802}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 26), + {&grpc_static_metadata_refcounts[63], {{16, g_bytes + 794}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 26), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[65], {{14, g_bytes + 818}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 27), + {&grpc_static_metadata_refcounts[64], {{14, g_bytes + 810}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 27), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[66], {{16, g_bytes + 832}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 28), + {&grpc_static_metadata_refcounts[65], {{16, g_bytes + 824}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 28), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[67], {{13, g_bytes + 848}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 29), + {&grpc_static_metadata_refcounts[66], {{13, g_bytes + 840}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 29), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[14], {{12, g_bytes + 158}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 30), + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 30), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[68], {{6, g_bytes + 861}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 31), + {&grpc_static_metadata_refcounts[67], {{6, g_bytes + 853}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 31), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[69], {{4, g_bytes + 867}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 32), + {&grpc_static_metadata_refcounts[68], {{4, g_bytes + 859}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 32), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[70], {{4, g_bytes + 871}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 33), + {&grpc_static_metadata_refcounts[69], {{4, g_bytes + 863}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 33), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[71], {{6, g_bytes + 875}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 34), + {&grpc_static_metadata_refcounts[70], {{6, g_bytes + 867}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 34), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[72], {{7, g_bytes + 881}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 35), + {&grpc_static_metadata_refcounts[71], {{7, g_bytes + 873}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 35), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[73], {{4, g_bytes + 888}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 36), + {&grpc_static_metadata_refcounts[72], {{4, g_bytes + 880}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 36), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[20], {{4, g_bytes + 278}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 37), + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 37), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[74], {{8, g_bytes + 892}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 38), + {&grpc_static_metadata_refcounts[73], {{8, g_bytes + 884}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 38), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[75], {{17, g_bytes + 900}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 39), + {&grpc_static_metadata_refcounts[74], {{17, g_bytes + 892}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 39), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[76], {{13, g_bytes + 917}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 40), + {&grpc_static_metadata_refcounts[75], {{13, g_bytes + 909}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 40), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[77], {{8, g_bytes + 930}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 41), + {&grpc_static_metadata_refcounts[76], {{8, g_bytes + 922}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 41), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[78], {{19, g_bytes + 938}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 42), + {&grpc_static_metadata_refcounts[77], {{19, g_bytes + 930}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 42), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[79], {{13, g_bytes + 957}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 43), + {&grpc_static_metadata_refcounts[78], {{13, g_bytes + 949}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 43), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[80], {{4, g_bytes + 970}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 44), + {&grpc_static_metadata_refcounts[79], {{4, g_bytes + 962}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 44), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[81], {{8, g_bytes + 974}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 45), + {&grpc_static_metadata_refcounts[80], {{8, g_bytes + 966}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 45), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[82], {{12, g_bytes + 982}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 46), + {&grpc_static_metadata_refcounts[81], {{12, g_bytes + 974}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 46), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[83], {{18, g_bytes + 994}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 47), + {&grpc_static_metadata_refcounts[82], {{18, g_bytes + 986}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 47), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[84], {{19, g_bytes + 1012}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 48), + {&grpc_static_metadata_refcounts[83], {{19, g_bytes + 1004}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 48), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[85], {{5, g_bytes + 1031}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 49), + {&grpc_static_metadata_refcounts[84], {{5, g_bytes + 1023}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 49), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[86], {{7, g_bytes + 1036}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 50), + {&grpc_static_metadata_refcounts[85], {{7, g_bytes + 1028}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 50), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[87], {{7, g_bytes + 1043}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 51), + {&grpc_static_metadata_refcounts[86], {{7, g_bytes + 1035}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 51), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[88], {{11, g_bytes + 1050}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 52), + {&grpc_static_metadata_refcounts[87], {{11, g_bytes + 1042}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 52), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[89], {{6, g_bytes + 1061}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 53), + {&grpc_static_metadata_refcounts[88], {{6, g_bytes + 1053}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 53), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[90], {{10, g_bytes + 1067}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 54), + {&grpc_static_metadata_refcounts[89], {{10, g_bytes + 1059}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 54), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[91], {{25, g_bytes + 1077}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 55), + {&grpc_static_metadata_refcounts[90], {{25, g_bytes + 1069}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 55), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[92], {{17, g_bytes + 1102}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 56), + {&grpc_static_metadata_refcounts[91], {{17, g_bytes + 1094}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 56), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[19], {{10, g_bytes + 268}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 57), + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 57), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[93], {{4, g_bytes + 1119}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 58), + {&grpc_static_metadata_refcounts[92], {{4, g_bytes + 1111}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 58), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[94], {{3, g_bytes + 1123}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 59), + {&grpc_static_metadata_refcounts[93], {{3, g_bytes + 1115}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 59), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[95], {{16, g_bytes + 1126}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 60), + {&grpc_static_metadata_refcounts[94], {{16, g_bytes + 1118}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 60), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, - {&grpc_static_metadata_refcounts[96], {{1, g_bytes + 1142}}}, 61), + {&grpc_static_metadata_refcounts[95], {{1, g_bytes + 1134}}}, 61), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, - {&grpc_static_metadata_refcounts[25], {{1, g_bytes + 350}}}, 62), + {&grpc_static_metadata_refcounts[24], {{1, g_bytes + 342}}}, 62), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, - {&grpc_static_metadata_refcounts[26], {{1, g_bytes + 351}}}, 63), + {&grpc_static_metadata_refcounts[25], {{1, g_bytes + 343}}}, 63), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, - {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}, 64), + {&grpc_static_metadata_refcounts[96], {{8, g_bytes + 1135}}}, 64), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, - {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}, 65), + {&grpc_static_metadata_refcounts[37], {{4, g_bytes + 589}}}, 65), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, - {&grpc_static_metadata_refcounts[37], {{7, g_bytes + 590}}}, 66), + {&grpc_static_metadata_refcounts[36], {{7, g_bytes + 582}}}, 66), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[5], {{2, g_bytes + 36}}}, - {&grpc_static_metadata_refcounts[98], {{8, g_bytes + 1151}}}, 67), + {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}, 67), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[14], {{12, g_bytes + 158}}}, - {&grpc_static_metadata_refcounts[99], {{16, g_bytes + 1159}}}, 68), + {&grpc_static_metadata_refcounts[98], {{16, g_bytes + 1151}}}, 68), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, - {&grpc_static_metadata_refcounts[100], {{4, g_bytes + 1175}}}, 69), + {&grpc_static_metadata_refcounts[99], {{4, g_bytes + 1167}}}, 69), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, - {&grpc_static_metadata_refcounts[101], {{3, g_bytes + 1179}}}, 70), + {&grpc_static_metadata_refcounts[100], {{3, g_bytes + 1171}}}, 70), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 71), + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 71), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, - {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}, 72), + {&grpc_static_metadata_refcounts[96], {{8, g_bytes + 1135}}}, 72), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, - {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}, 73), + {&grpc_static_metadata_refcounts[37], {{4, g_bytes + 589}}}, 73), grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[21], {{8, g_bytes + 282}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 74), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[102], {{11, g_bytes + 1182}}}, - {&grpc_static_metadata_refcounts[29], {{0, g_bytes + 354}}}, 75), + {&grpc_static_metadata_refcounts[101], {{11, g_bytes + 1174}}}, + {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 74), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}, 76), + {&grpc_static_metadata_refcounts[96], {{8, g_bytes + 1135}}}, 75), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[37], {{7, g_bytes + 590}}}, 77), + {&grpc_static_metadata_refcounts[36], {{7, g_bytes + 582}}}, 76), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[103], {{16, g_bytes + 1193}}}, 78), + {&grpc_static_metadata_refcounts[102], {{16, g_bytes + 1185}}}, 77), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}, 79), + {&grpc_static_metadata_refcounts[37], {{4, g_bytes + 589}}}, 78), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[104], {{13, g_bytes + 1209}}}, 80), + {&grpc_static_metadata_refcounts[103], {{13, g_bytes + 1201}}}, 79), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[105], {{12, g_bytes + 1222}}}, 81), + {&grpc_static_metadata_refcounts[104], {{12, g_bytes + 1214}}}, 80), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[106], {{21, g_bytes + 1234}}}, 82), + {&grpc_static_metadata_refcounts[105], {{21, g_bytes + 1226}}}, 81), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}, 83), + {&grpc_static_metadata_refcounts[96], {{8, g_bytes + 1135}}}, 82), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[38], {{4, g_bytes + 597}}}, 84), + {&grpc_static_metadata_refcounts[37], {{4, g_bytes + 589}}}, 83), grpc_core::StaticMetadata( {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[104], {{13, g_bytes + 1209}}}, 85), + {&grpc_static_metadata_refcounts[103], {{13, g_bytes + 1201}}}, 84), }; -const uint8_t grpc_static_accept_encoding_metadata[8] = {0, 76, 77, 78, - 79, 80, 81, 82}; +const uint8_t grpc_static_accept_encoding_metadata[8] = {0, 75, 76, 77, + 78, 79, 80, 81}; -const uint8_t grpc_static_accept_stream_encoding_metadata[4] = {0, 83, 84, 85}; +const uint8_t grpc_static_accept_stream_encoding_metadata[4] = {0, 82, 83, 84}; diff --git a/src/core/lib/transport/static_metadata.h b/src/core/lib/transport/static_metadata.h index 458e87d30a7..991a7970cb6 100644 --- a/src/core/lib/transport/static_metadata.h +++ b/src/core/lib/transport/static_metadata.h @@ -33,7 +33,7 @@ #include "src/core/lib/transport/metadata.h" -#define GRPC_STATIC_MDSTR_COUNT 107 +#define GRPC_STATIC_MDSTR_COUNT 106 extern const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT]; /* ":path" */ #define GRPC_MDSTR_PATH (grpc_static_slice_table[0]) @@ -78,185 +78,183 @@ extern const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT]; #define GRPC_MDSTR_USER_AGENT (grpc_static_slice_table[19]) /* "host" */ #define GRPC_MDSTR_HOST (grpc_static_slice_table[20]) -/* "lb-token" */ -#define GRPC_MDSTR_LB_TOKEN (grpc_static_slice_table[21]) /* "grpc-previous-rpc-attempts" */ -#define GRPC_MDSTR_GRPC_PREVIOUS_RPC_ATTEMPTS (grpc_static_slice_table[22]) +#define GRPC_MDSTR_GRPC_PREVIOUS_RPC_ATTEMPTS (grpc_static_slice_table[21]) /* "grpc-retry-pushback-ms" */ -#define GRPC_MDSTR_GRPC_RETRY_PUSHBACK_MS (grpc_static_slice_table[23]) +#define GRPC_MDSTR_GRPC_RETRY_PUSHBACK_MS (grpc_static_slice_table[22]) /* "grpc-timeout" */ -#define GRPC_MDSTR_GRPC_TIMEOUT (grpc_static_slice_table[24]) +#define GRPC_MDSTR_GRPC_TIMEOUT (grpc_static_slice_table[23]) /* "1" */ -#define GRPC_MDSTR_1 (grpc_static_slice_table[25]) +#define GRPC_MDSTR_1 (grpc_static_slice_table[24]) /* "2" */ -#define GRPC_MDSTR_2 (grpc_static_slice_table[26]) +#define GRPC_MDSTR_2 (grpc_static_slice_table[25]) /* "3" */ -#define GRPC_MDSTR_3 (grpc_static_slice_table[27]) +#define GRPC_MDSTR_3 (grpc_static_slice_table[26]) /* "4" */ -#define GRPC_MDSTR_4 (grpc_static_slice_table[28]) +#define GRPC_MDSTR_4 (grpc_static_slice_table[27]) /* "" */ -#define GRPC_MDSTR_EMPTY (grpc_static_slice_table[29]) +#define GRPC_MDSTR_EMPTY (grpc_static_slice_table[28]) /* "grpc.wait_for_ready" */ -#define GRPC_MDSTR_GRPC_DOT_WAIT_FOR_READY (grpc_static_slice_table[30]) +#define GRPC_MDSTR_GRPC_DOT_WAIT_FOR_READY (grpc_static_slice_table[29]) /* "grpc.timeout" */ -#define GRPC_MDSTR_GRPC_DOT_TIMEOUT (grpc_static_slice_table[31]) +#define GRPC_MDSTR_GRPC_DOT_TIMEOUT (grpc_static_slice_table[30]) /* "grpc.max_request_message_bytes" */ #define GRPC_MDSTR_GRPC_DOT_MAX_REQUEST_MESSAGE_BYTES \ - (grpc_static_slice_table[32]) + (grpc_static_slice_table[31]) /* "grpc.max_response_message_bytes" */ #define GRPC_MDSTR_GRPC_DOT_MAX_RESPONSE_MESSAGE_BYTES \ - (grpc_static_slice_table[33]) + (grpc_static_slice_table[32]) /* "/grpc.lb.v1.LoadBalancer/BalanceLoad" */ #define GRPC_MDSTR_SLASH_GRPC_DOT_LB_DOT_V1_DOT_LOADBALANCER_SLASH_BALANCELOAD \ - (grpc_static_slice_table[34]) + (grpc_static_slice_table[33]) /* "/grpc.health.v1.Health/Watch" */ #define GRPC_MDSTR_SLASH_GRPC_DOT_HEALTH_DOT_V1_DOT_HEALTH_SLASH_WATCH \ - (grpc_static_slice_table[35]) + (grpc_static_slice_table[34]) /* "/envoy.service.discovery.v2.AggregatedDiscoveryService/StreamAggregatedResources" */ #define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_DISCOVERY_DOT_V2_DOT_AGGREGATEDDISCOVERYSERVICE_SLASH_STREAMAGGREGATEDRESOURCES \ - (grpc_static_slice_table[36]) + (grpc_static_slice_table[35]) /* "deflate" */ -#define GRPC_MDSTR_DEFLATE (grpc_static_slice_table[37]) +#define GRPC_MDSTR_DEFLATE (grpc_static_slice_table[36]) /* "gzip" */ -#define GRPC_MDSTR_GZIP (grpc_static_slice_table[38]) +#define GRPC_MDSTR_GZIP (grpc_static_slice_table[37]) /* "stream/gzip" */ -#define GRPC_MDSTR_STREAM_SLASH_GZIP (grpc_static_slice_table[39]) +#define GRPC_MDSTR_STREAM_SLASH_GZIP (grpc_static_slice_table[38]) /* "GET" */ -#define GRPC_MDSTR_GET (grpc_static_slice_table[40]) +#define GRPC_MDSTR_GET (grpc_static_slice_table[39]) /* "POST" */ -#define GRPC_MDSTR_POST (grpc_static_slice_table[41]) +#define GRPC_MDSTR_POST (grpc_static_slice_table[40]) /* "/" */ -#define GRPC_MDSTR_SLASH (grpc_static_slice_table[42]) +#define GRPC_MDSTR_SLASH (grpc_static_slice_table[41]) /* "/index.html" */ -#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (grpc_static_slice_table[43]) +#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (grpc_static_slice_table[42]) /* "http" */ -#define GRPC_MDSTR_HTTP (grpc_static_slice_table[44]) +#define GRPC_MDSTR_HTTP (grpc_static_slice_table[43]) /* "https" */ -#define GRPC_MDSTR_HTTPS (grpc_static_slice_table[45]) +#define GRPC_MDSTR_HTTPS (grpc_static_slice_table[44]) /* "200" */ -#define GRPC_MDSTR_200 (grpc_static_slice_table[46]) +#define GRPC_MDSTR_200 (grpc_static_slice_table[45]) /* "204" */ -#define GRPC_MDSTR_204 (grpc_static_slice_table[47]) +#define GRPC_MDSTR_204 (grpc_static_slice_table[46]) /* "206" */ -#define GRPC_MDSTR_206 (grpc_static_slice_table[48]) +#define GRPC_MDSTR_206 (grpc_static_slice_table[47]) /* "304" */ -#define GRPC_MDSTR_304 (grpc_static_slice_table[49]) +#define GRPC_MDSTR_304 (grpc_static_slice_table[48]) /* "400" */ -#define GRPC_MDSTR_400 (grpc_static_slice_table[50]) +#define GRPC_MDSTR_400 (grpc_static_slice_table[49]) /* "404" */ -#define GRPC_MDSTR_404 (grpc_static_slice_table[51]) +#define GRPC_MDSTR_404 (grpc_static_slice_table[50]) /* "500" */ -#define GRPC_MDSTR_500 (grpc_static_slice_table[52]) +#define GRPC_MDSTR_500 (grpc_static_slice_table[51]) /* "accept-charset" */ -#define GRPC_MDSTR_ACCEPT_CHARSET (grpc_static_slice_table[53]) +#define GRPC_MDSTR_ACCEPT_CHARSET (grpc_static_slice_table[52]) /* "gzip, deflate" */ -#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (grpc_static_slice_table[54]) +#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (grpc_static_slice_table[53]) /* "accept-language" */ -#define GRPC_MDSTR_ACCEPT_LANGUAGE (grpc_static_slice_table[55]) +#define GRPC_MDSTR_ACCEPT_LANGUAGE (grpc_static_slice_table[54]) /* "accept-ranges" */ -#define GRPC_MDSTR_ACCEPT_RANGES (grpc_static_slice_table[56]) +#define GRPC_MDSTR_ACCEPT_RANGES (grpc_static_slice_table[55]) /* "accept" */ -#define GRPC_MDSTR_ACCEPT (grpc_static_slice_table[57]) +#define GRPC_MDSTR_ACCEPT (grpc_static_slice_table[56]) /* "access-control-allow-origin" */ -#define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN (grpc_static_slice_table[58]) +#define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN (grpc_static_slice_table[57]) /* "age" */ -#define GRPC_MDSTR_AGE (grpc_static_slice_table[59]) +#define GRPC_MDSTR_AGE (grpc_static_slice_table[58]) /* "allow" */ -#define GRPC_MDSTR_ALLOW (grpc_static_slice_table[60]) +#define GRPC_MDSTR_ALLOW (grpc_static_slice_table[59]) /* "authorization" */ -#define GRPC_MDSTR_AUTHORIZATION (grpc_static_slice_table[61]) +#define GRPC_MDSTR_AUTHORIZATION (grpc_static_slice_table[60]) /* "cache-control" */ -#define GRPC_MDSTR_CACHE_CONTROL (grpc_static_slice_table[62]) +#define GRPC_MDSTR_CACHE_CONTROL (grpc_static_slice_table[61]) /* "content-disposition" */ -#define GRPC_MDSTR_CONTENT_DISPOSITION (grpc_static_slice_table[63]) +#define GRPC_MDSTR_CONTENT_DISPOSITION (grpc_static_slice_table[62]) /* "content-language" */ -#define GRPC_MDSTR_CONTENT_LANGUAGE (grpc_static_slice_table[64]) +#define GRPC_MDSTR_CONTENT_LANGUAGE (grpc_static_slice_table[63]) /* "content-length" */ -#define GRPC_MDSTR_CONTENT_LENGTH (grpc_static_slice_table[65]) +#define GRPC_MDSTR_CONTENT_LENGTH (grpc_static_slice_table[64]) /* "content-location" */ -#define GRPC_MDSTR_CONTENT_LOCATION (grpc_static_slice_table[66]) +#define GRPC_MDSTR_CONTENT_LOCATION (grpc_static_slice_table[65]) /* "content-range" */ -#define GRPC_MDSTR_CONTENT_RANGE (grpc_static_slice_table[67]) +#define GRPC_MDSTR_CONTENT_RANGE (grpc_static_slice_table[66]) /* "cookie" */ -#define GRPC_MDSTR_COOKIE (grpc_static_slice_table[68]) +#define GRPC_MDSTR_COOKIE (grpc_static_slice_table[67]) /* "date" */ -#define GRPC_MDSTR_DATE (grpc_static_slice_table[69]) +#define GRPC_MDSTR_DATE (grpc_static_slice_table[68]) /* "etag" */ -#define GRPC_MDSTR_ETAG (grpc_static_slice_table[70]) +#define GRPC_MDSTR_ETAG (grpc_static_slice_table[69]) /* "expect" */ -#define GRPC_MDSTR_EXPECT (grpc_static_slice_table[71]) +#define GRPC_MDSTR_EXPECT (grpc_static_slice_table[70]) /* "expires" */ -#define GRPC_MDSTR_EXPIRES (grpc_static_slice_table[72]) +#define GRPC_MDSTR_EXPIRES (grpc_static_slice_table[71]) /* "from" */ -#define GRPC_MDSTR_FROM (grpc_static_slice_table[73]) +#define GRPC_MDSTR_FROM (grpc_static_slice_table[72]) /* "if-match" */ -#define GRPC_MDSTR_IF_MATCH (grpc_static_slice_table[74]) +#define GRPC_MDSTR_IF_MATCH (grpc_static_slice_table[73]) /* "if-modified-since" */ -#define GRPC_MDSTR_IF_MODIFIED_SINCE (grpc_static_slice_table[75]) +#define GRPC_MDSTR_IF_MODIFIED_SINCE (grpc_static_slice_table[74]) /* "if-none-match" */ -#define GRPC_MDSTR_IF_NONE_MATCH (grpc_static_slice_table[76]) +#define GRPC_MDSTR_IF_NONE_MATCH (grpc_static_slice_table[75]) /* "if-range" */ -#define GRPC_MDSTR_IF_RANGE (grpc_static_slice_table[77]) +#define GRPC_MDSTR_IF_RANGE (grpc_static_slice_table[76]) /* "if-unmodified-since" */ -#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (grpc_static_slice_table[78]) +#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (grpc_static_slice_table[77]) /* "last-modified" */ -#define GRPC_MDSTR_LAST_MODIFIED (grpc_static_slice_table[79]) +#define GRPC_MDSTR_LAST_MODIFIED (grpc_static_slice_table[78]) /* "link" */ -#define GRPC_MDSTR_LINK (grpc_static_slice_table[80]) +#define GRPC_MDSTR_LINK (grpc_static_slice_table[79]) /* "location" */ -#define GRPC_MDSTR_LOCATION (grpc_static_slice_table[81]) +#define GRPC_MDSTR_LOCATION (grpc_static_slice_table[80]) /* "max-forwards" */ -#define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table[82]) +#define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table[81]) /* "proxy-authenticate" */ -#define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table[83]) +#define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table[82]) /* "proxy-authorization" */ -#define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table[84]) +#define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table[83]) /* "range" */ -#define GRPC_MDSTR_RANGE (grpc_static_slice_table[85]) +#define GRPC_MDSTR_RANGE (grpc_static_slice_table[84]) /* "referer" */ -#define GRPC_MDSTR_REFERER (grpc_static_slice_table[86]) +#define GRPC_MDSTR_REFERER (grpc_static_slice_table[85]) /* "refresh" */ -#define GRPC_MDSTR_REFRESH (grpc_static_slice_table[87]) +#define GRPC_MDSTR_REFRESH (grpc_static_slice_table[86]) /* "retry-after" */ -#define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table[88]) +#define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table[87]) /* "server" */ -#define GRPC_MDSTR_SERVER (grpc_static_slice_table[89]) +#define GRPC_MDSTR_SERVER (grpc_static_slice_table[88]) /* "set-cookie" */ -#define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table[90]) +#define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table[89]) /* "strict-transport-security" */ -#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table[91]) +#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table[90]) /* "transfer-encoding" */ -#define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table[92]) +#define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table[91]) /* "vary" */ -#define GRPC_MDSTR_VARY (grpc_static_slice_table[93]) +#define GRPC_MDSTR_VARY (grpc_static_slice_table[92]) /* "via" */ -#define GRPC_MDSTR_VIA (grpc_static_slice_table[94]) +#define GRPC_MDSTR_VIA (grpc_static_slice_table[93]) /* "www-authenticate" */ -#define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table[95]) +#define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table[94]) /* "0" */ -#define GRPC_MDSTR_0 (grpc_static_slice_table[96]) +#define GRPC_MDSTR_0 (grpc_static_slice_table[95]) /* "identity" */ -#define GRPC_MDSTR_IDENTITY (grpc_static_slice_table[97]) +#define GRPC_MDSTR_IDENTITY (grpc_static_slice_table[96]) /* "trailers" */ -#define GRPC_MDSTR_TRAILERS (grpc_static_slice_table[98]) +#define GRPC_MDSTR_TRAILERS (grpc_static_slice_table[97]) /* "application/grpc" */ -#define GRPC_MDSTR_APPLICATION_SLASH_GRPC (grpc_static_slice_table[99]) +#define GRPC_MDSTR_APPLICATION_SLASH_GRPC (grpc_static_slice_table[98]) /* "grpc" */ -#define GRPC_MDSTR_GRPC (grpc_static_slice_table[100]) +#define GRPC_MDSTR_GRPC (grpc_static_slice_table[99]) /* "PUT" */ -#define GRPC_MDSTR_PUT (grpc_static_slice_table[101]) +#define GRPC_MDSTR_PUT (grpc_static_slice_table[100]) /* "lb-cost-bin" */ -#define GRPC_MDSTR_LB_COST_BIN (grpc_static_slice_table[102]) +#define GRPC_MDSTR_LB_COST_BIN (grpc_static_slice_table[101]) /* "identity,deflate" */ -#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (grpc_static_slice_table[103]) +#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (grpc_static_slice_table[102]) /* "identity,gzip" */ -#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (grpc_static_slice_table[104]) +#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (grpc_static_slice_table[103]) /* "deflate,gzip" */ -#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (grpc_static_slice_table[105]) +#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (grpc_static_slice_table[104]) /* "identity,deflate,gzip" */ #define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \ - (grpc_static_slice_table[106]) + (grpc_static_slice_table[105]) extern grpc_slice_refcount grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT]; @@ -268,7 +266,7 @@ extern grpc_slice_refcount (static_cast( \ ((static_slice).refcount - grpc_static_metadata_refcounts))) -#define GRPC_STATIC_MDELEM_COUNT 86 +#define GRPC_STATIC_MDELEM_COUNT 85 extern grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT]; extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT]; @@ -429,38 +427,36 @@ extern grpc_mdelem grpc_static_mdelem_manifested[GRPC_STATIC_MDELEM_COUNT]; (grpc_static_mdelem_manifested[72]) /* "content-encoding": "gzip" */ #define GRPC_MDELEM_CONTENT_ENCODING_GZIP (grpc_static_mdelem_manifested[73]) -/* "lb-token": "" */ -#define GRPC_MDELEM_LB_TOKEN_EMPTY (grpc_static_mdelem_manifested[74]) /* "lb-cost-bin": "" */ -#define GRPC_MDELEM_LB_COST_BIN_EMPTY (grpc_static_mdelem_manifested[75]) +#define GRPC_MDELEM_LB_COST_BIN_EMPTY (grpc_static_mdelem_manifested[74]) /* "grpc-accept-encoding": "identity" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY \ - (grpc_static_mdelem_manifested[76]) + (grpc_static_mdelem_manifested[75]) /* "grpc-accept-encoding": "deflate" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE \ - (grpc_static_mdelem_manifested[77]) + (grpc_static_mdelem_manifested[76]) /* "grpc-accept-encoding": "identity,deflate" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE \ - (grpc_static_mdelem_manifested[78]) + (grpc_static_mdelem_manifested[77]) /* "grpc-accept-encoding": "gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_GZIP \ - (grpc_static_mdelem_manifested[79]) + (grpc_static_mdelem_manifested[78]) /* "grpc-accept-encoding": "identity,gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \ - (grpc_static_mdelem_manifested[80]) + (grpc_static_mdelem_manifested[79]) /* "grpc-accept-encoding": "deflate,gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE_COMMA_GZIP \ - (grpc_static_mdelem_manifested[81]) + (grpc_static_mdelem_manifested[80]) /* "grpc-accept-encoding": "identity,deflate,gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \ - (grpc_static_mdelem_manifested[82]) + (grpc_static_mdelem_manifested[81]) /* "accept-encoding": "identity" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY (grpc_static_mdelem_manifested[83]) +#define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY (grpc_static_mdelem_manifested[82]) /* "accept-encoding": "gzip" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP (grpc_static_mdelem_manifested[84]) +#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP (grpc_static_mdelem_manifested[83]) /* "accept-encoding": "identity,gzip" */ #define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \ - (grpc_static_mdelem_manifested[85]) + (grpc_static_mdelem_manifested[84]) grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b); typedef enum { @@ -485,7 +481,6 @@ typedef enum { GRPC_BATCH_GRPC_INTERNAL_STREAM_ENCODING_REQUEST, GRPC_BATCH_USER_AGENT, GRPC_BATCH_HOST, - GRPC_BATCH_LB_TOKEN, GRPC_BATCH_GRPC_PREVIOUS_RPC_ATTEMPTS, GRPC_BATCH_GRPC_RETRY_PUSHBACK_MS, GRPC_BATCH_CALLOUTS_COUNT @@ -515,7 +510,6 @@ typedef union { struct grpc_linked_mdelem* grpc_internal_stream_encoding_request; struct grpc_linked_mdelem* user_agent; struct grpc_linked_mdelem* host; - struct grpc_linked_mdelem* lb_token; struct grpc_linked_mdelem* grpc_previous_rpc_attempts; struct grpc_linked_mdelem* grpc_retry_pushback_ms; } named; diff --git a/test/core/end2end/fuzzers/hpack.dictionary b/test/core/end2end/fuzzers/hpack.dictionary index 0469421c975..abad1720ee8 100644 --- a/test/core/end2end/fuzzers/hpack.dictionary +++ b/test/core/end2end/fuzzers/hpack.dictionary @@ -20,7 +20,6 @@ "%grpc-internal-stream-encoding-request" "\x0Auser-agent" "\x04host" -"\x08lb-token" "\x1Agrpc-previous-rpc-attempts" "\x16grpc-retry-pushback-ms" "\x0Cgrpc-timeout" @@ -180,7 +179,6 @@ "\x00\x0Faccept-encoding\x00" "\x00\x10content-encoding\x08identity" "\x00\x10content-encoding\x04gzip" -"\x00\x08lb-token\x00" "\x00\x0Blb-cost-bin\x00" "\x00\x14grpc-accept-encoding\x08identity" "\x00\x14grpc-accept-encoding\x07deflate" diff --git a/test/core/util/test_lb_policies.cc b/test/core/util/test_lb_policies.cc index 041ce1f45a1..12a042ab827 100644 --- a/test/core/util/test_lb_policies.cc +++ b/test/core/util/test_lb_policies.cc @@ -20,6 +20,8 @@ #include +#include + #include "src/core/ext/filters/client_channel/lb_policy.h" #include "src/core/ext/filters/client_channel/lb_policy_registry.h" #include "src/core/lib/channel/channel_args.h" @@ -115,7 +117,13 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy user_data_(user_data) {} PickResult Pick(PickArgs args) override { + // Check that we can read initial metadata. + gpr_log(GPR_INFO, "initial metadata:"); + InterceptRecvTrailingMetadataLoadBalancingPolicy::LogMetadata( + args.initial_metadata); + // Do pick. PickResult result = delegate_picker_->Pick(args); + // Intercept trailing metadata. if (result.type == PickResult::PICK_COMPLETE && result.subchannel != nullptr) { new (args.call_state->Alloc(sizeof(TrailingMetadataHandler))) @@ -180,11 +188,14 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy private: static void RecordRecvTrailingMetadata( - void* arg, grpc_metadata_batch* recv_trailing_metadata, + void* arg, MetadataInterface* recv_trailing_metadata, CallState* call_state) { TrailingMetadataHandler* self = static_cast(arg); GPR_ASSERT(recv_trailing_metadata != nullptr); + gpr_log(GPR_INFO, "trailing metadata:"); + InterceptRecvTrailingMetadataLoadBalancingPolicy::LogMetadata( + recv_trailing_metadata); self->cb_(self->user_data_); self->~TrailingMetadataHandler(); } @@ -192,6 +203,17 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy InterceptRecvTrailingMetadataCallback cb_; void* user_data_; }; + + static void LogMetadata(MetadataInterface* metadata) { + for (MetadataInterface::Iterator it = metadata->Begin(); + !metadata->IsEnd(it); metadata->Next(&it)) { + gpr_log(GPR_INFO, " \"%.*s\"=>\"%.*s\"", + static_cast(metadata->Key(it).size()), + metadata->Key(it).data(), + static_cast(metadata->Value(it).size()), + metadata->Value(it).data()); + } + } }; class InterceptTrailingFactory : public LoadBalancingPolicyFactory { diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py index 95a545f5542..6b034347bf8 100755 --- a/tools/codegen/core/gen_static_metadata.py +++ b/tools/codegen/core/gen_static_metadata.py @@ -146,38 +146,35 @@ CONFIG = [ ('accept-encoding', ''), ('content-encoding', 'identity'), ('content-encoding', 'gzip'), - ('lb-token', ''), ('lb-cost-bin', ''), ] # All entries here are ignored when counting non-default initial metadata that # prevents the chttp2 server from sending a Trailers-Only response. METADATA_BATCH_CALLOUTS = [ - # (name) - (':path'), - (':method'), - (':status'), - (':authority'), - (':scheme'), - ('te'), - ('grpc-message'), - ('grpc-status'), - ('grpc-payload-bin'), - ('grpc-encoding'), - ('grpc-accept-encoding'), - ('grpc-server-stats-bin'), - ('grpc-tags-bin'), - ('grpc-trace-bin'), - ('content-type'), - ('content-encoding'), - ('accept-encoding'), - ('grpc-internal-encoding-request'), - ('grpc-internal-stream-encoding-request'), - ('user-agent'), - ('host'), - ('lb-token'), - ('grpc-previous-rpc-attempts'), - ('grpc-retry-pushback-ms'), + ':path', + ':method', + ':status', + ':authority', + ':scheme', + 'te', + 'grpc-message', + 'grpc-status', + 'grpc-payload-bin', + 'grpc-encoding', + 'grpc-accept-encoding', + 'grpc-server-stats-bin', + 'grpc-tags-bin', + 'grpc-trace-bin', + 'content-type', + 'content-encoding', + 'accept-encoding', + 'grpc-internal-encoding-request', + 'grpc-internal-stream-encoding-request', + 'user-agent', + 'host', + 'grpc-previous-rpc-attempts', + 'grpc-retry-pushback-ms', ] COMPRESSION_ALGORITHMS = [ From f00dd31ace908df44c1cf6d80bb971830d0473bd Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Sat, 27 Jul 2019 17:52:15 -0700 Subject: [PATCH 1016/1555] Upgrade Cocoapods to the second latest version Reverting build_one_sample --- src/objective-c/tests/build_one_example.sh | 1 - tools/internal_ci/helper_scripts/prepare_build_macos_rc | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/objective-c/tests/build_one_example.sh b/src/objective-c/tests/build_one_example.sh index a7d1eef7b30..084147f1d46 100755 --- a/src/objective-c/tests/build_one_example.sh +++ b/src/objective-c/tests/build_one_example.sh @@ -30,7 +30,6 @@ cd `dirname $0`/../../.. cd $EXAMPLE_PATH # clean the directory -rm -rf Build/* rm -rf Pods rm -rf $SCHEME.xcworkspace rm -f Podfile.lock diff --git a/tools/internal_ci/helper_scripts/prepare_build_macos_rc b/tools/internal_ci/helper_scripts/prepare_build_macos_rc index e2f52e73117..009cc067578 100644 --- a/tools/internal_ci/helper_scripts/prepare_build_macos_rc +++ b/tools/internal_ci/helper_scripts/prepare_build_macos_rc @@ -37,7 +37,7 @@ set -e # rvm commands are very verbose time rvm install 2.5.0 rvm use 2.5.0 --default time gem install bundler -v 1.17.3 --no-ri --no-doc -time gem install cocoapods --version 1.3.1 --no-ri --no-doc +time gem install cocoapods --version 1.6.1 --no-ri --no-doc time gem install rake-compiler --no-ri --no-doc rvm osx-ssl-certs status all rvm osx-ssl-certs update all From f9d9fbd36bfdd3d89a1622adee238d2d7fd65c32 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Sat, 27 Jul 2019 18:51:52 -0700 Subject: [PATCH 1017/1555] Only include src/objective-c/examples/RemoteTestClient/.. stubs Reverting other files & removing redundant spaces --- .../RemoteTestClient/RemoteTest.podspec | 6 ++-- .../AppIcon.appiconset/Contents.json | 30 ------------------- .../tests/RemoteTestClient/RemoteTest.podspec | 4 +-- .../helper_scripts/prepare_build_macos_rc | 2 +- 4 files changed, 6 insertions(+), 36 deletions(-) diff --git a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec index fbc37317ba1..747df63ac5b 100644 --- a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec +++ b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec @@ -45,20 +45,20 @@ Pod::Spec.new do |s| end s.subspec 'Messages' do |ms| - ms.source_files = '**/*.pbobjc.{h,m}' + ms.source_files = 'src/objective-c/examples/RemoteTestClient/*.pbobjc.{h,m}' ms.header_mappings_dir = '.' ms.requires_arc = false ms.dependency 'Protobuf' end s.subspec 'Services' do |ss| - ss.source_files = '**/*.pbrpc.{h,m}' + ss.source_files = 'src/objective-c/examples/RemoteTestClient/*.pbrpc.{h,m}' ss.header_mappings_dir = '.' ss.requires_arc = true ss.dependency 'gRPC-ProtoRPC' ss.dependency "#{s.name}/Messages" end - + s.pod_target_xcconfig = { # This is needed by all pods that depend on Protobuf: 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1', diff --git a/src/objective-c/examples/SwiftSample/Images.xcassets/AppIcon.appiconset/Contents.json b/src/objective-c/examples/SwiftSample/Images.xcassets/AppIcon.appiconset/Contents.json index d8db8d65fd7..36d2c80d889 100644 --- a/src/objective-c/examples/SwiftSample/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/src/objective-c/examples/SwiftSample/Images.xcassets/AppIcon.appiconset/Contents.json @@ -1,15 +1,5 @@ { "images" : [ - { - "idiom" : "iphone", - "size" : "20x20", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "20x20", - "scale" : "3x" - }, { "idiom" : "iphone", "size" : "29x29", @@ -40,16 +30,6 @@ "size" : "60x60", "scale" : "3x" }, - { - "idiom" : "ipad", - "size" : "20x20", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "20x20", - "scale" : "2x" - }, { "idiom" : "ipad", "size" : "29x29", @@ -79,16 +59,6 @@ "idiom" : "ipad", "size" : "76x76", "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "83.5x83.5", - "scale" : "2x" - }, - { - "idiom" : "ios-marketing", - "size" : "1024x1024", - "scale" : "1x" } ], "info" : { diff --git a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec index 60727d4d94e..27b7fab069f 100644 --- a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec +++ b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec @@ -45,14 +45,14 @@ Pod::Spec.new do |s| CMD s.subspec "Messages" do |ms| - ms.source_files = "**/*.pbobjc.{h,m}" + ms.source_files = "src/objective-c/tests/RemoteTestClient/*.pbobjc.{h,m}" ms.header_mappings_dir = "." ms.requires_arc = false ms.dependency "Protobuf" end s.subspec "Services" do |ss| - ss.source_files = "**/*.pbrpc.{h,m}" + ss.source_files = "src/objective-c/tests/RemoteTestClient/*.pbrpc.{h,m}" ss.header_mappings_dir = "." ss.requires_arc = true ss.dependency "gRPC-ProtoRPC" diff --git a/tools/internal_ci/helper_scripts/prepare_build_macos_rc b/tools/internal_ci/helper_scripts/prepare_build_macos_rc index 009cc067578..e2f52e73117 100644 --- a/tools/internal_ci/helper_scripts/prepare_build_macos_rc +++ b/tools/internal_ci/helper_scripts/prepare_build_macos_rc @@ -37,7 +37,7 @@ set -e # rvm commands are very verbose time rvm install 2.5.0 rvm use 2.5.0 --default time gem install bundler -v 1.17.3 --no-ri --no-doc -time gem install cocoapods --version 1.6.1 --no-ri --no-doc +time gem install cocoapods --version 1.3.1 --no-ri --no-doc time gem install rake-compiler --no-ri --no-doc rvm osx-ssl-certs status all rvm osx-ssl-certs update all From 8f3b487838ebb50543185ddef22692d761422e7f Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Sun, 28 Jul 2019 13:49:26 -0700 Subject: [PATCH 1018/1555] Added some edge case checks --- src/compiler/objective_c_generator_helpers.h | 7 ++++--- src/compiler/objective_c_plugin.cc | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/compiler/objective_c_generator_helpers.h b/src/compiler/objective_c_generator_helpers.h index b5262fcdd6f..d686014faa5 100644 --- a/src/compiler/objective_c_generator_helpers.h +++ b/src/compiler/objective_c_generator_helpers.h @@ -50,10 +50,11 @@ inline ::grpc::string LocalImport(const ::grpc::string& import) { inline ::grpc::string FrameworkImport(const ::grpc::string& import, const ::grpc::string& framework) { - // Flattens the directory structure + // Flattens the directory structure: grab the file name only std::size_t pos = import.rfind("/"); - ::grpc::string filename = import.substr(pos + 1, import.size() - pos); - cerr << filename << endl; + // If pos is npos, pos + 1 is 0, which gives us the entire string, + // so there's no need to check that + ::grpc::string filename = import.substr(pos + 1, import.size() - (pos + 1)); return ::grpc::string("#import <" + framework + "/" + filename + ">\n"); } diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index 4a452a8265c..7d6af7cdbec 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -42,7 +42,6 @@ inline ::grpc::string ImportProtoHeaders( const ::grpc::string& framework) { ::grpc::string header = grpc_objective_c_generator::MessageHeaderName(dep); - // cerr << header << endl; if (!IsProtobufLibraryBundledProtoFile(dep)) { if (framework.empty()) { return indent + LocalImport(header); @@ -89,6 +88,10 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { std::vector<::grpc::string> param = grpc_generator::tokenize(*param_str, "="); if (param[0] == "generate_for_named_framework") { + if (param[1].empty()) { + *error = grpc::string("Name of framework cannot be empty for parameter: ") + param[0]; + return false; + } framework = param[1]; } } From 6172ef8bd6a0b70dd53a521a02a9123e2c73f5c8 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Sun, 28 Jul 2019 14:03:29 -0700 Subject: [PATCH 1019/1555] Fixed clang_format_code --- src/compiler/objective_c_plugin.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index 7d6af7cdbec..feebe12797e 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -89,7 +89,9 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { grpc_generator::tokenize(*param_str, "="); if (param[0] == "generate_for_named_framework") { if (param[1].empty()) { - *error = grpc::string("Name of framework cannot be empty for parameter: ") + param[0]; + *error = grpc::string( + "Name of framework cannot be empty for parameter: ") + + param[0]; return false; } framework = param[1]; From d9cb5718aec1b00041b9cbc71b85b59be3bfa243 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 29 Jul 2019 10:01:57 -0700 Subject: [PATCH 1020/1555] nit comment --- src/objective-c/GRPCClient/private/GRPCTransport+Private.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h index dd826a8fc1a..2dc7357c363 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h @@ -28,7 +28,8 @@ NS_ASSUME_NONNULL_BEGIN /** * Get a transport implementation's factory by its transport id. If the transport id was not - * registered with the registry, nil is returned. + * registered with the registry, the default transport factory (core + secure) is returned. If the + * default transport does not exist, an exception is thrown. */ - (id)getTransportFactoryWithId:(GRPCTransportId)transportId; From e45c5f021be938fca5e1fe53a6aa780e1df1a121 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Mon, 29 Jul 2019 10:03:38 -0700 Subject: [PATCH 1021/1555] Add check_upb_output to sanity test --- tools/codegen/core/gen_upb_api.sh | 12 ++++++++---- tools/distrib/check_upb_output.sh | 23 +++++++++++++++++++++++ tools/run_tests/sanity/sanity_tests.yaml | 15 ++++++++------- 3 files changed, 39 insertions(+), 11 deletions(-) create mode 100755 tools/distrib/check_upb_output.sh diff --git a/tools/codegen/core/gen_upb_api.sh b/tools/codegen/core/gen_upb_api.sh index 710039b0157..d7871d88671 100755 --- a/tools/codegen/core/gen_upb_api.sh +++ b/tools/codegen/core/gen_upb_api.sh @@ -17,6 +17,14 @@ # REQUIRES: Bazel set -ex +if [ $# -eq 0 ]; then + UPB_OUTPUT_DIR=$PWD/src/core/ext/upb-generated + rm -rf $UPB_OUTPUT_DIR + mkdir $UPB_OUTPUT_DIR +else + UPB_OUTPUT_DIR=$1 +fi + pushd third_party/protobuf bazel build :protoc PROTOC=$PWD/bazel-bin/protoc @@ -27,10 +35,6 @@ bazel build :protoc-gen-upb UPB_PLUGIN=$PWD/bazel-bin/protoc-gen-upb popd -UPB_OUTPUT_DIR=$PWD/src/core/ext/upb-generated -rm -rf $UPB_OUTPUT_DIR -mkdir $UPB_OUTPUT_DIR - proto_files=( \ "envoy/api/v2/auth/cert.proto" \ "envoy/api/v2/cds.proto" \ diff --git a/tools/distrib/check_upb_output.sh b/tools/distrib/check_upb_output.sh new file mode 100755 index 00000000000..6febd0e9835 --- /dev/null +++ b/tools/distrib/check_upb_output.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +readonly UPB_GENERATED_SRC=src/core/ext/upb-generated +readonly UPB_TMP_OUTPUT="$(mktemp -d)" + +tools/codegen/core/gen_upb_api.sh "$UPB_TMP_OUTPUT" + +diff -rq "$UPB_GENERATED_SRC" "$UPB_TMP_OUTPUT" diff --git a/tools/run_tests/sanity/sanity_tests.yaml b/tools/run_tests/sanity/sanity_tests.yaml index 1c5dc5d4312..e9459911a1e 100644 --- a/tools/run_tests/sanity/sanity_tests.yaml +++ b/tools/run_tests/sanity/sanity_tests.yaml @@ -2,7 +2,9 @@ - script: tools/run_tests/sanity/check_bad_dependencies.sh - script: tools/run_tests/sanity/check_bazel_workspace.py - script: tools/run_tests/sanity/check_cache_mk.sh +- script: tools/run_tests/sanity/check_deprecated_grpc++.py - script: tools/run_tests/sanity/check_owners.sh +- script: tools/run_tests/sanity/check_port_platform.py - script: tools/run_tests/sanity/check_qps_scenario_changes.py - script: tools/run_tests/sanity/check_shellcheck.sh - script: tools/run_tests/sanity/check_submodules.sh @@ -10,19 +12,18 @@ - script: tools/run_tests/sanity/check_tracer_sanity.py - script: tools/run_tests/sanity/core_banned_functions.py - script: tools/run_tests/sanity/core_untyped_structs.sh -- script: tools/run_tests/sanity/check_deprecated_grpc++.py -- script: tools/run_tests/sanity/check_port_platform.py - script: tools/buildgen/generate_projects.sh -j 3 cpu_cost: 3 - script: tools/distrib/check_copyright.py +- script: tools/distrib/check_include_guards.py +- script: tools/distrib/check_nanopb_output.sh +- script: tools/distrib/check_trailing_newlines.sh +- script: tools/distrib/check_upb_output.sh - script: tools/distrib/clang_format_code.sh - script: tools/distrib/clang_tidy_code.sh -- script: tools/distrib/check_trailing_newlines.sh -- script: tools/distrib/check_nanopb_output.sh -- script: tools/distrib/check_include_guards.py - script: tools/distrib/pylint_code.sh -- script: tools/distrib/yapf_code.sh - script: tools/distrib/python/check_grpcio_tools.py +- script: tools/distrib/yapf_code.sh cpu_cost: 1000 -- script: tools/distrib/check_shadow_boringssl_symbol_list.sh - script: tools/distrib/check_protobuf_pod_version.sh +- script: tools/distrib/check_shadow_boringssl_symbol_list.sh From c7c74bc41dea7c1f0107fb5fe7e874280d12599c Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 29 Jul 2019 10:21:15 -0700 Subject: [PATCH 1022/1555] comments and clang format --- src/objective-c/GRPCClient/GRPCTransport.m | 18 ++++++++++++ src/objective-c/GRPCClient/GRPCTypes.h | 28 ++++++++++++++++--- .../private/GRPCCore/GRPCCoreFactory.m | 18 ++++++++++++ .../private/GRPCTransport+Private.m | 18 ++++++++++++ src/objective-c/ProtoRPC/ProtoRPCLegacy.h | 18 ++++++++++++ src/objective-c/ProtoRPC/ProtoRPCLegacy.m | 18 ++++++++++++ src/objective-c/ProtoRPC/ProtoServiceLegacy.h | 18 ++++++++++++ src/objective-c/ProtoRPC/ProtoServiceLegacy.m | 18 ++++++++++++ .../InteropTestsMultipleChannels.m | 2 +- 9 files changed, 151 insertions(+), 5 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCTransport.m b/src/objective-c/GRPCClient/GRPCTransport.m index edb973a8f62..439acfb9cc2 100644 --- a/src/objective-c/GRPCClient/GRPCTransport.m +++ b/src/objective-c/GRPCClient/GRPCTransport.m @@ -1,3 +1,21 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + #import "GRPCTransport.h" static const GRPCTransportId gGRPCCoreSecureId = "io.grpc.transport.core.secure"; diff --git a/src/objective-c/GRPCClient/GRPCTypes.h b/src/objective-c/GRPCClient/GRPCTypes.h index 45fbe219a91..332b6e86a2b 100644 --- a/src/objective-c/GRPCClient/GRPCTypes.h +++ b/src/objective-c/GRPCClient/GRPCTypes.h @@ -1,14 +1,35 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /** * Safety remark of a gRPC method as defined in RFC 2616 Section 9.1 */ typedef NS_ENUM(NSUInteger, GRPCCallSafety) { - /** Signal that there is no guarantees on how the call affects the server state. */ + /** + * Signal that there is no guarantees on how the call affects the server + * state. + */ GRPCCallSafetyDefault = 0, /** Signal that the call is idempotent. gRPC is free to use PUT verb. */ GRPCCallSafetyIdempotentRequest = 1, /** - * Signal that the call is cacheable and will not affect server state. gRPC is free to use GET - * verb. + * Signal that the call is cacheable and will not affect server state. gRPC is + * free to use GET verb. */ GRPCCallSafetyCacheableRequest = 2, }; @@ -34,4 +55,3 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { /** Insecure channel. FOR TEST ONLY! */ GRPCTransportTypeInsecure, }; - diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m index f5d6276a570..19d7231a203 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m @@ -1,3 +1,21 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + #import "GRPCCoreFactory.h" #import diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m index c8198462bd4..2482ff86e6a 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m @@ -1,3 +1,21 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + #import "GRPCTransport+Private.h" #import diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.h b/src/objective-c/ProtoRPC/ProtoRPCLegacy.h index 2ceb4339bd1..7b9658d5b94 100644 --- a/src/objective-c/ProtoRPC/ProtoRPCLegacy.h +++ b/src/objective-c/ProtoRPC/ProtoRPCLegacy.h @@ -1,3 +1,21 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + #import @class GRPCProtoMethod; diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.m b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m index b5c0c847c66..4ba93674063 100644 --- a/src/objective-c/ProtoRPC/ProtoRPCLegacy.m +++ b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m @@ -1,3 +1,21 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + #import "ProtoRPCLegacy.h" #import "ProtoMethod.h" diff --git a/src/objective-c/ProtoRPC/ProtoServiceLegacy.h b/src/objective-c/ProtoRPC/ProtoServiceLegacy.h index dd5e533379c..28686f51e37 100644 --- a/src/objective-c/ProtoRPC/ProtoServiceLegacy.h +++ b/src/objective-c/ProtoRPC/ProtoServiceLegacy.h @@ -1,3 +1,21 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + #import "ProtoService.h" @class GRPCProtoCall; diff --git a/src/objective-c/ProtoRPC/ProtoServiceLegacy.m b/src/objective-c/ProtoRPC/ProtoServiceLegacy.m index 9484f432216..3f1cb278723 100644 --- a/src/objective-c/ProtoRPC/ProtoServiceLegacy.m +++ b/src/objective-c/ProtoRPC/ProtoServiceLegacy.m @@ -1,3 +1,21 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + #import "ProtoServiceLegacy.h" #import "ProtoMethod.h" #import "ProtoRPCLegacy.h" diff --git a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m index 4a3c2b955ac..94820553d24 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m +++ b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m @@ -19,11 +19,11 @@ #import #import +#import #import #import #import #import -#import #import "../ConfigureCronet.h" #import "InteropTestsBlockCallbacks.h" From c3c24d089dda2ea09fb9f637a79ffca8750649d9 Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Mon, 29 Jul 2019 10:30:09 -0700 Subject: [PATCH 1023/1555] Use Template --- test/cpp/microbenchmarks/bm_threadpool.cc | 139 ++++++---------------- 1 file changed, 38 insertions(+), 101 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_threadpool.cc b/test/cpp/microbenchmarks/bm_threadpool.cc index 8b83aa2ed28..d3d25074460 100644 --- a/test/cpp/microbenchmarks/bm_threadpool.cc +++ b/test/cpp/microbenchmarks/bm_threadpool.cc @@ -90,16 +90,16 @@ class AddAnotherFunctor : public grpc_experimental_completion_queue_functor { int num_add_; }; -void ThreadPoolAddAnotherHelper(benchmark::State& state, - int concurrent_functor) { +template +static void ThreadPoolAddAnother(benchmark::State& state) { const int num_iterations = state.range(0); const int num_threads = state.range(1); // Number of adds done by each closure. - const int num_add = num_iterations / concurrent_functor; + const int num_add = num_iterations / kConcurrentFunctor; grpc_core::ThreadPool pool(num_threads); while (state.KeepRunningBatch(num_iterations)) { - BlockingCounter counter(concurrent_functor); - for (int i = 0; i < concurrent_functor; ++i) { + BlockingCounter counter(kConcurrentFunctor); + for (int i = 0; i < kConcurrentFunctor; ++i) { pool.Add(new AddAnotherFunctor(&pool, &counter, num_add)); } counter.Wait(); @@ -107,52 +107,23 @@ void ThreadPoolAddAnotherHelper(benchmark::State& state, state.SetItemsProcessed(state.iterations()); } -static void BM_ThreadPool1AddAnother(benchmark::State& state) { - ThreadPoolAddAnotherHelper(state, 1); -} -// First pair is range for number of iterations (num_iterations). -// Second pair is range for thread pool size (num_threads). -BENCHMARK(BM_ThreadPool1AddAnother)->RangePair(524288, 524288, 1, 1024); - -static void BM_ThreadPool4AddAnother(benchmark::State& state) { - ThreadPoolAddAnotherHelper(state, 4); -} -BENCHMARK(BM_ThreadPool4AddAnother)->RangePair(524288, 524288, 1, 1024); - -static void BM_ThreadPool8AddAnother(benchmark::State& state) { - ThreadPoolAddAnotherHelper(state, 8); -} -BENCHMARK(BM_ThreadPool8AddAnother)->RangePair(524288, 524288, 1, 1024); - -static void BM_ThreadPool16AddAnother(benchmark::State& state) { - ThreadPoolAddAnotherHelper(state, 16); -} -BENCHMARK(BM_ThreadPool16AddAnother)->RangePair(524288, 524288, 1, 1024); - -static void BM_ThreadPool32AddAnother(benchmark::State& state) { - ThreadPoolAddAnotherHelper(state, 32); -} -BENCHMARK(BM_ThreadPool32AddAnother)->RangePair(524288, 524288, 1, 1024); - -static void BM_ThreadPool64AddAnother(benchmark::State& state) { - ThreadPoolAddAnotherHelper(state, 64); -} -BENCHMARK(BM_ThreadPool64AddAnother)->RangePair(524288, 524288, 1, 1024); - -static void BM_ThreadPool128AddAnother(benchmark::State& state) { - ThreadPoolAddAnotherHelper(state, 128); -} -BENCHMARK(BM_ThreadPool128AddAnother)->RangePair(524288, 524288, 1, 1024); - -static void BM_ThreadPool512AddAnother(benchmark::State& state) { - ThreadPoolAddAnotherHelper(state, 512); -} -BENCHMARK(BM_ThreadPool512AddAnother)->RangePair(524288, 524288, 1, 1024); - -static void BM_ThreadPool2048AddAnother(benchmark::State& state) { - ThreadPoolAddAnotherHelper(state, 2048); -} -BENCHMARK(BM_ThreadPool2048AddAnother)->RangePair(524288, 524288, 1, 1024); +// First pair of arguments is range for number of iterations (num_iterations). +// Second pair of arguments is range for thread pool size (num_threads). +BENCHMARK_TEMPLATE(ThreadPoolAddAnother, 1)->RangePair(524288, 524288, 1, 1024); +BENCHMARK_TEMPLATE(ThreadPoolAddAnother, 4)->RangePair(524288, 524288, 1, 1024); +BENCHMARK_TEMPLATE(ThreadPoolAddAnother, 8)->RangePair(524288, 524288, 1, 1024); +BENCHMARK_TEMPLATE(ThreadPoolAddAnother, 16) + ->RangePair(524288, 524288, 1, 1024); +BENCHMARK_TEMPLATE(ThreadPoolAddAnother, 32) + ->RangePair(524288, 524288, 1, 1024); +BENCHMARK_TEMPLATE(ThreadPoolAddAnother, 64) + ->RangePair(524288, 524288, 1, 1024); +BENCHMARK_TEMPLATE(ThreadPoolAddAnother, 128) + ->RangePair(524288, 524288, 1, 1024); +BENCHMARK_TEMPLATE(ThreadPoolAddAnother, 512) + ->RangePair(524288, 524288, 1, 1024); +BENCHMARK_TEMPLATE(ThreadPoolAddAnother, 2048) + ->RangePair(524288, 524288, 1, 1024); // A functor class that will delete self on end of running. class SuicideFunctorForAdd : public grpc_experimental_completion_queue_functor { @@ -233,15 +204,16 @@ class AddSelfFunctor : public grpc_experimental_completion_queue_functor { int num_add_; }; -void ThreadPoolAddSelfHelper(benchmark::State& state, int concurrent_functor) { +template +static void ThreadPoolAddSelf(benchmark::State& state) { const int num_iterations = state.range(0); const int num_threads = state.range(1); // Number of adds done by each closure. - const int num_add = num_iterations / concurrent_functor; + const int num_add = num_iterations / kConcurrentFunctor; grpc_core::ThreadPool pool(num_threads); while (state.KeepRunningBatch(num_iterations)) { - BlockingCounter counter(concurrent_functor); - for (int i = 0; i < concurrent_functor; ++i) { + BlockingCounter counter(kConcurrentFunctor); + for (int i = 0; i < kConcurrentFunctor; ++i) { pool.Add(new AddSelfFunctor(&pool, &counter, num_add)); } counter.Wait(); @@ -249,52 +221,17 @@ void ThreadPoolAddSelfHelper(benchmark::State& state, int concurrent_functor) { state.SetItemsProcessed(state.iterations()); } -static void BM_ThreadPool1AddSelf(benchmark::State& state) { - ThreadPoolAddSelfHelper(state, 1); -} -// First pair is range for number of iterations (num_iterations). -// Second pair is range for thread pool size (num_threads). -BENCHMARK(BM_ThreadPool1AddSelf)->RangePair(524288, 524288, 1, 1024); - -static void BM_ThreadPool4AddSelf(benchmark::State& state) { - ThreadPoolAddSelfHelper(state, 4); -} -BENCHMARK(BM_ThreadPool4AddSelf)->RangePair(524288, 524288, 1, 1024); - -static void BM_ThreadPool8AddSelf(benchmark::State& state) { - ThreadPoolAddSelfHelper(state, 8); -} -BENCHMARK(BM_ThreadPool8AddSelf)->RangePair(524288, 524288, 1, 1024); - -static void BM_ThreadPool16AddSelf(benchmark::State& state) { - ThreadPoolAddSelfHelper(state, 16); -} -BENCHMARK(BM_ThreadPool16AddSelf)->RangePair(524288, 524288, 1, 1024); - -static void BM_ThreadPool32AddSelf(benchmark::State& state) { - ThreadPoolAddSelfHelper(state, 32); -} -BENCHMARK(BM_ThreadPool32AddSelf)->RangePair(524288, 524288, 1, 1024); - -static void BM_ThreadPool64AddSelf(benchmark::State& state) { - ThreadPoolAddSelfHelper(state, 64); -} -BENCHMARK(BM_ThreadPool64AddSelf)->RangePair(524288, 524288, 1, 1024); - -static void BM_ThreadPool128AddSelf(benchmark::State& state) { - ThreadPoolAddSelfHelper(state, 128); -} -BENCHMARK(BM_ThreadPool128AddSelf)->RangePair(524288, 524288, 1, 1024); - -static void BM_ThreadPool512AddSelf(benchmark::State& state) { - ThreadPoolAddSelfHelper(state, 512); -} -BENCHMARK(BM_ThreadPool512AddSelf)->RangePair(524288, 524288, 1, 1024); - -static void BM_ThreadPool2048AddSelf(benchmark::State& state) { - ThreadPoolAddSelfHelper(state, 2048); -} -BENCHMARK(BM_ThreadPool2048AddSelf)->RangePair(524288, 524288, 1, 1024); +// First pair of arguments is range for number of iterations (num_iterations). +// Second pair of arguments is range for thread pool size (num_threads). +BENCHMARK_TEMPLATE(ThreadPoolAddSelf, 1)->RangePair(524288, 524288, 1, 1024); +BENCHMARK_TEMPLATE(ThreadPoolAddSelf, 4)->RangePair(524288, 524288, 1, 1024); +BENCHMARK_TEMPLATE(ThreadPoolAddSelf, 8)->RangePair(524288, 524288, 1, 1024); +BENCHMARK_TEMPLATE(ThreadPoolAddSelf, 16)->RangePair(524288, 524288, 1, 1024); +BENCHMARK_TEMPLATE(ThreadPoolAddSelf, 32)->RangePair(524288, 524288, 1, 1024); +BENCHMARK_TEMPLATE(ThreadPoolAddSelf, 64)->RangePair(524288, 524288, 1, 1024); +BENCHMARK_TEMPLATE(ThreadPoolAddSelf, 128)->RangePair(524288, 524288, 1, 1024); +BENCHMARK_TEMPLATE(ThreadPoolAddSelf, 512)->RangePair(524288, 524288, 1, 1024); +BENCHMARK_TEMPLATE(ThreadPoolAddSelf, 2048)->RangePair(524288, 524288, 1, 1024); #if defined(__GNUC__) && !defined(SWIG) #if defined(__i386__) || defined(__x86_64__) From 232725b99aa715c901da828061edc05d3dd6a066 Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Wed, 24 Jul 2019 00:53:23 -0700 Subject: [PATCH 1024/1555] Add C++ Cronet end2end tests --- src/cpp/Protobuf-C++.podspec | 42 ++ .../!ProtoCompiler-gRPCCppPlugin.podspec | 125 ++++ ...otoCompiler-gRPCCppPlugin.podspec.template | 127 ++++ .../ios/CronetTests/CppCronetEnd2EndTests.mm | 569 +++++++++++++++++ test/cpp/ios/CronetTests/TestHelper.h | 81 +++ test/cpp/ios/CronetTests/TestHelper.mm | 198 ++++++ test/cpp/ios/Info.plist | 24 + test/cpp/ios/Podfile | 102 +++ .../RemoteTestClientCpp/RemoteTestCpp.podspec | 98 +++ test/cpp/ios/Tests.xcodeproj/project.pbxproj | 594 ++++++++++++++++++ .../xcschemes/CronetTests.xcscheme | 95 +++ test/cpp/ios/build_tests.sh | 40 ++ test/cpp/ios/run_tests.sh | 34 + .../macos/grpc_basictests_cpp_ios.cfg | 31 + tools/run_tests/run_tests.py | 8 + 15 files changed, 2168 insertions(+) create mode 100644 src/cpp/Protobuf-C++.podspec create mode 100644 src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec create mode 100644 templates/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec.template create mode 100644 test/cpp/ios/CronetTests/CppCronetEnd2EndTests.mm create mode 100644 test/cpp/ios/CronetTests/TestHelper.h create mode 100644 test/cpp/ios/CronetTests/TestHelper.mm create mode 100644 test/cpp/ios/Info.plist create mode 100644 test/cpp/ios/Podfile create mode 100644 test/cpp/ios/RemoteTestClientCpp/RemoteTestCpp.podspec create mode 100644 test/cpp/ios/Tests.xcodeproj/project.pbxproj create mode 100644 test/cpp/ios/Tests.xcodeproj/xcshareddata/xcschemes/CronetTests.xcscheme create mode 100755 test/cpp/ios/build_tests.sh create mode 100755 test/cpp/ios/run_tests.sh create mode 100644 tools/internal_ci/macos/grpc_basictests_cpp_ios.cfg diff --git a/src/cpp/Protobuf-C++.podspec b/src/cpp/Protobuf-C++.podspec new file mode 100644 index 00000000000..f6a488dc350 --- /dev/null +++ b/src/cpp/Protobuf-C++.podspec @@ -0,0 +1,42 @@ +Pod::Spec.new do |s| + s.name = 'Protobuf-C++' + s.version = '3.8.0' + s.summary = 'Protocol Buffers v3 runtime library for C++.' + s.homepage = 'https://github.com/google/protobuf' + s.license = '3-Clause BSD License' + s.authors = { 'The Protocol Buffers contributors' => 'protobuf@googlegroups.com' } + s.cocoapods_version = '>= 1.0' + + s.source = { :git => 'https://github.com/google/protobuf.git', + :tag => "v#{s.version}" } + + s.source_files = 'src/google/protobuf/*.{h,cc,inc}', + 'src/google/protobuf/stubs/*.{h,cc}', + 'src/google/protobuf/io/*.{h,cc}', + 'src/google/protobuf/util/*.{h,cc}', + 'src/google/protobuf/util/internal/*.{h,cc}' + + # Excluding all the tests in the directories above + s.exclude_files = 'src/google/**/*_test.{h,cc,inc}', + 'src/google/**/*_unittest.{h,cc}', + 'src/google/protobuf/test_util*.{h,cc}', + 'src/google/protobuf/map_lite_test_util.{h,cc}', + 'src/google/protobuf/map_test_util*.{h,cc,inc}' + + s.header_mappings_dir = 'src' + + s.ios.deployment_target = '7.0' + s.osx.deployment_target = '10.9' + s.tvos.deployment_target = '9.0' + s.watchos.deployment_target = '2.0' + + s.pod_target_xcconfig = { + # Do not let src/google/protobuf/stubs/time.h override system API + 'USE_HEADERMAP' => 'NO', + 'ALWAYS_SEARCH_USER_PATHS' => 'NO', + + # Configure tool is not being used for Xcode. When building, assume pthread is supported. + 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "HAVE_PTHREAD=1"', + } + +end diff --git a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec new file mode 100644 index 00000000000..dc1f8b2c090 --- /dev/null +++ b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec @@ -0,0 +1,125 @@ +# This file has been automatically generated from a template file. +# Please make modifications to +# `templates/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec.template` +# instead. This file can be regenerated from the template by running +# `tools/buildgen/generate_projects.sh`. + +# CocoaPods podspec for the gRPC Proto Compiler Plugin +# +# Copyright 2019, 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. + +Pod::Spec.new do |s| + # This pod is only a utility that will be used by other pods _at install time_ (not at compile + # time). Other pods can access it in their `prepare_command` script, under /. + # Because CocoaPods installs pods in alphabetical order, beginning this pod's name with an + # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed + # before them. + s.name = '!ProtoCompiler-gRPCCppPlugin' + v = '1.23.0-dev' + s.version = v + s.summary = 'The gRPC ProtoC plugin generates C++ files from .proto services.' + s.description = <<-DESC + This podspec only downloads the gRPC protoc plugin so that local pods generating protos can use + it in their invocation of protoc, as part of their prepare_command. + DESC + s.homepage = 'https://grpc.io' + s.license = { + :type => 'Apache License, Version 2.0', + :text => <<-LICENSE + Copyright 2019, 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. + LICENSE + } + s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } + + repo = 'grpc/grpc' + file = "grpc_cpp_plugin-#{v}-macos-x86_64.zip" + s.source = { + :http => "https://github.com/#{repo}/releases/download/v#{v}/#{file}", + # TODO(jcanizales): Add sha1 or sha256 + # :sha1 => '??', + } + + repo_root = '../..' + plugin = 'grpc_cpp_plugin' + + s.preserve_paths = plugin + + # Restrict the protoc version to the one supported by this plugin. + s.dependency '!ProtoCompiler', '3.8.0' + # For the Protobuf dependency not to complain: + s.ios.deployment_target = '7.0' + s.osx.deployment_target = '10.9' + s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '2.0' + + # This is only for local development of the plugin: If the Podfile brings this pod from a local + # directory using `:path`, CocoaPods won't download the zip file and so the plugin won't be + # present in this pod's directory. We use that knowledge to check for the existence of the file + # and, if absent, compile the plugin from the local sources. + s.prepare_command = <<-CMD + if [ ! -f #{plugin} ]; then + cd #{repo_root} + # This will build the plugin and put it in #{repo_root}/bins/opt. + # + # TODO(jcanizales): I reckon make will try to use locally-installed libprotoc (headers and + # library binary) if found, which _we do not want_. Find a way for this to always use the + # sources in the repo. + make #{plugin} + cd - + fi + CMD +end diff --git a/templates/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec.template b/templates/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec.template new file mode 100644 index 00000000000..259a5c54f24 --- /dev/null +++ b/templates/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec.template @@ -0,0 +1,127 @@ +%YAML 1.2 +--- | + # This file has been automatically generated from a template file. + # Please make modifications to + # `templates/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec.template` + # instead. This file can be regenerated from the template by running + # `tools/buildgen/generate_projects.sh`. + + # CocoaPods podspec for the gRPC Proto Compiler Plugin + # + # Copyright 2019, 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. + + Pod::Spec.new do |s| + # This pod is only a utility that will be used by other pods _at install time_ (not at compile + # time). Other pods can access it in their `prepare_command` script, under /. + # Because CocoaPods installs pods in alphabetical order, beginning this pod's name with an + # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed + # before them. + s.name = '!ProtoCompiler-gRPCCppPlugin' + v = '${settings.version}' + s.version = v + s.summary = 'The gRPC ProtoC plugin generates C++ files from .proto services.' + s.description = <<-DESC + This podspec only downloads the gRPC protoc plugin so that local pods generating protos can use + it in their invocation of protoc, as part of their prepare_command. + DESC + s.homepage = 'https://grpc.io' + s.license = { + :type => 'Apache License, Version 2.0', + :text => <<-LICENSE + Copyright 2019, 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. + LICENSE + } + s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } + + repo = 'grpc/grpc' + file = "grpc_cpp_plugin-#{v}-macos-x86_64.zip" + s.source = { + :http => "https://github.com/#{repo}/releases/download/v#{v}/#{file}", + # TODO(jcanizales): Add sha1 or sha256 + # :sha1 => '??', + } + + repo_root = '../..' + plugin = 'grpc_cpp_plugin' + + s.preserve_paths = plugin + + # Restrict the protoc version to the one supported by this plugin. + s.dependency '!ProtoCompiler', '3.8.0' + # For the Protobuf dependency not to complain: + s.ios.deployment_target = '7.0' + s.osx.deployment_target = '10.9' + s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '2.0' + + # This is only for local development of the plugin: If the Podfile brings this pod from a local + # directory using `:path`, CocoaPods won't download the zip file and so the plugin won't be + # present in this pod's directory. We use that knowledge to check for the existence of the file + # and, if absent, compile the plugin from the local sources. + s.prepare_command = <<-CMD + if [ ! -f #{plugin} ]; then + cd #{repo_root} + # This will build the plugin and put it in #{repo_root}/bins/opt. + # + # TODO(jcanizales): I reckon make will try to use locally-installed libprotoc (headers and + # library binary) if found, which _we do not want_. Find a way for this to always use the + # sources in the repo. + make #{plugin} + cd - + fi + CMD + end diff --git a/test/cpp/ios/CronetTests/CppCronetEnd2EndTests.mm b/test/cpp/ios/CronetTests/CppCronetEnd2EndTests.mm new file mode 100644 index 00000000000..07b514f6c65 --- /dev/null +++ b/test/cpp/ios/CronetTests/CppCronetEnd2EndTests.mm @@ -0,0 +1,569 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import +#import + +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import + +#import "TestHelper.h" +#import "test/core/end2end/data/ssl_test_data.h" + +#import +#import +#import +#import + +using namespace grpc::testing; +using std::chrono::system_clock; +using grpc::Status; +using grpc::ServerContext; +using grpc::ClientContext; + +@interface CppCronetEnd2EndTests : XCTestCase + +@end + +@implementation CppCronetEnd2EndTests { + std::unique_ptr _server; + TestServiceImpl _service; + TestServiceImpl _foo_service; +} + +// The setUp() function is run before the test cases run and only run once ++ (void)setUp { + [super setUp]; + configureCronet(); +} + +- (void)startServer { + if (_server) { + // server is already running + return; + } + + grpc::ServerBuilder builder; + grpc::SslServerCredentialsOptions ssl_opts; + + ssl_opts.pem_root_certs = ""; + grpc::SslServerCredentialsOptions::PemKeyCertPair pkcp = {test_server1_key, test_server1_cert}; + ssl_opts.pem_key_cert_pairs.push_back(pkcp); + auto server_creds = SslServerCredentials(ssl_opts); + builder.AddListeningPort("localhost:5000", server_creds); + builder.RegisterService(&_service); + builder.RegisterService("foo.test.youtube.com", &_foo_service); + _server = builder.BuildAndStart(); +} + +- (void)stopServer { + _server.reset(); +} + +- (void)restartServer { + [self stopServer]; + [self startServer]; +} + +- (void)setUp { + [self startServer]; +} + +- (void)sendRPCWithStub:(EchoTestService::Stub*)stub + numRPCs:(int)num_rpcs + withBinaryMetadata:(BOOL)with_binary_metadata { + EchoRequest request; + EchoResponse response; + request.set_message("Hello hello hello hello"); + + for (int i = 0; i < num_rpcs; ++i) { + ClientContext context; + if (with_binary_metadata) { + char bytes[8] = {'\0', '\1', '\2', '\3', '\4', '\5', '\6', static_cast(i)}; + context.AddMetadata("custom-bin", grpc::string(bytes, 8)); + } + context.set_compression_algorithm(GRPC_COMPRESS_GZIP); + Status s = stub->Echo(&context, request, &response); + XCTAssertEqual(response.message(), request.message()); + XCTAssertTrue(s.ok()); + } +} + +- (std::shared_ptr<::grpc::Channel>)getChannel { + stream_engine* cronetEngine = [Cronet getGlobalEngine]; + auto cronetChannelCredentials = grpc::CronetChannelCredentials(cronetEngine); + grpc::ChannelArguments args; + args.SetSslTargetNameOverride("foo.test.google.fr"); + args.SetUserAgentPrefix("custom_prefix"); + args.SetString(GRPC_ARG_SECONDARY_USER_AGENT_STRING, "end2end_test"); + auto channel = grpc::CreateCustomChannel("127.0.0.1:5000", cronetChannelCredentials, args); + return channel; +} + +- (std::shared_ptr<::grpc::Channel>)getChannelWithInterceptors: + (std::vector>)creators { + stream_engine* cronetEngine = [Cronet getGlobalEngine]; + auto cronetChannelCredentials = grpc::CronetChannelCredentials(cronetEngine); + grpc::ChannelArguments args; + args.SetSslTargetNameOverride("foo.test.google.fr"); + args.SetUserAgentPrefix("custom_prefix"); + args.SetString(GRPC_ARG_SECONDARY_USER_AGENT_STRING, "end2end_test"); + auto channel = grpc::experimental::CreateCustomChannelWithInterceptors( + "127.0.01:5000", cronetChannelCredentials, args, std::move(creators)); + return channel; +} + +- (std::unique_ptr)getStub { + auto channel = [self getChannel]; + auto stub = EchoTestService::NewStub(channel); + return stub; +} + +- (void)testUserAgent { + ClientContext context; + EchoRequest request; + EchoResponse response; + request.set_message("Hello"); + request.mutable_param()->set_echo_metadata(true); + auto stub = [self getStub]; + Status s = stub->Echo(&context, request, &response); + XCTAssertTrue(s.ok()); + const auto& trailing_metadata = context.GetServerTrailingMetadata(); + auto iter = trailing_metadata.find("user-agent"); + XCTAssert(iter->second.starts_with("custom_prefix grpc-c++")); +} + +- (void)testMultipleRPCs { + auto stub = [self getStub]; + std::vector threads; + threads.reserve(10); + for (int i = 0; i < 10; ++i) { + threads.emplace_back( + [self, &stub]() { [self sendRPCWithStub:stub.get() numRPCs:10 withBinaryMetadata:NO]; }); + } + for (int i = 0; i < 10; ++i) { + threads[i].join(); + } +} + +- (void)testMultipleRPCsWithBinaryMetadata { + auto stub = [self getStub]; + std::vector threads; + threads.reserve(10); + for (int i = 0; i < 10; ++i) { + threads.emplace_back( + [self, &stub]() { [self sendRPCWithStub:stub.get() numRPCs:10 withBinaryMetadata:YES]; }); + } + for (int i = 0; i < 10; ++i) { + threads[i].join(); + } +} + +- (void)testEmptyBinaryMetadata { + EchoRequest request; + EchoResponse response; + request.set_message("Hello hello hello hello"); + ClientContext context; + context.AddMetadata("custom-bin", ""); + auto stub = [self getStub]; + Status s = stub->Echo(&context, request, &response); + XCTAssertEqual(response.message(), request.message()); + XCTAssertTrue(s.ok()); +} + +- (void)testReconnectChannel { + auto stub = [self getStub]; + [self sendRPCWithStub:stub.get() numRPCs:1 withBinaryMetadata:NO]; + + [self restartServer]; + [self sendRPCWithStub:stub.get() numRPCs:1 withBinaryMetadata:NO]; +} + +- (void)testRequestStreamOneRequest { + auto stub = [self getStub]; + EchoRequest request; + EchoResponse response; + ClientContext context; + auto stream = stub->RequestStream(&context, &response); + request.set_message("hello"); + XCTAssertTrue(stream->Write(request)); + stream->WritesDone(); + Status s = stream->Finish(); + XCTAssertEqual(response.message(), request.message()); + XCTAssertTrue(s.ok()); + XCTAssertTrue(context.debug_error_string().empty()); +} + +- (void)testRequestStreamOneRequestWithCoalescingApi { + auto stub = [self getStub]; + EchoRequest request; + EchoResponse response; + ClientContext context; + context.set_initial_metadata_corked(true); + auto stream = stub->RequestStream(&context, &response); + request.set_message("hello"); + XCTAssertTrue(stream->Write(request)); + stream->WritesDone(); + Status s = stream->Finish(); + XCTAssertEqual(response.message(), request.message()); + XCTAssertTrue(s.ok()); +} + +- (void)testRequestStreamTwoRequests { + auto stub = [self getStub]; + EchoRequest request; + EchoResponse response; + ClientContext context; + auto stream = stub->RequestStream(&context, &response); + request.set_message("hello"); + XCTAssertTrue(stream->Write(request)); + XCTAssertTrue(stream->Write(request)); + stream->WritesDone(); + Status s = stream->Finish(); + XCTAssertEqual(response.message(), "hellohello"); + XCTAssertTrue(s.ok()); +} + +- (void)testResponseStream { + auto stub = [self getStub]; + EchoRequest request; + EchoResponse response; + ClientContext context; + request.set_message("hello"); + + auto stream = stub->ResponseStream(&context, request); + for (int i = 0; i < kServerDefaultResponseStreamsToSend; ++i) { + XCTAssertTrue(stream->Read(&response)); + XCTAssertEqual(response.message(), request.message() + grpc::to_string(i)); + } + XCTAssertFalse(stream->Read(&response)); + + Status s = stream->Finish(); + XCTAssertTrue(s.ok()); +} + +- (void)testBidiStream { + auto stub = [self getStub]; + EchoRequest request; + EchoResponse response; + ClientContext context; + grpc::string msg("hello"); + + auto stream = stub->BidiStream(&context); + + for (int i = 0; i < kServerDefaultResponseStreamsToSend; ++i) { + request.set_message(msg + grpc::to_string(i)); + XCTAssertTrue(stream->Write(request)); + XCTAssertTrue(stream->Read(&response)); + XCTAssertEqual(response.message(), request.message()); + } + + stream->WritesDone(); + XCTAssertFalse(stream->Read(&response)); + XCTAssertFalse(stream->Read(&response)); + + Status s = stream->Finish(); + XCTAssertTrue(s.ok()); +} + +- (void)testBidiStreamWithCoalescingApi { + auto stub = [self getStub]; + EchoRequest request; + EchoResponse response; + ClientContext context; + context.AddMetadata(kServerFinishAfterNReads, "3"); + context.set_initial_metadata_corked(true); + grpc::string msg("hello"); + + auto stream = stub->BidiStream(&context); + + request.set_message(msg + "0"); + XCTAssertTrue(stream->Write(request)); + XCTAssertTrue(stream->Read(&response)); + XCTAssertEqual(response.message(), request.message()); + + request.set_message(msg + "1"); + XCTAssertTrue(stream->Write(request)); + XCTAssertTrue(stream->Read(&response)); + XCTAssertEqual(response.message(), request.message()); + + request.set_message(msg + "2"); + stream->WriteLast(request, grpc::WriteOptions()); + XCTAssertTrue(stream->Read(&response)); + XCTAssertEqual(response.message(), request.message()); + + XCTAssertFalse(stream->Read(&response)); + XCTAssertFalse(stream->Read(&response)); + + Status s = stream->Finish(); + XCTAssertTrue(s.ok()); +} + +- (void)testCancelBeforeStart { + auto stub = [self getStub]; + EchoRequest request; + EchoResponse response; + ClientContext context; + request.set_message("hello"); + context.TryCancel(); + Status s = stub->Echo(&context, request, &response); + XCTAssertEqual("", response.message()); + XCTAssertEqual(grpc::StatusCode::CANCELLED, s.error_code()); +} + +- (void)testClientCancelsRequestStream { + auto stub = [self getStub]; + EchoRequest request; + EchoResponse response; + ClientContext context; + request.set_message("hello"); + + auto stream = stub->RequestStream(&context, &response); + XCTAssertTrue(stream->Write(request)); + XCTAssertTrue(stream->Write(request)); + + context.TryCancel(); + + Status s = stream->Finish(); + XCTAssertEqual(grpc::StatusCode::CANCELLED, s.error_code()); + XCTAssertEqual(response.message(), ""); +} + +- (void)testClientCancelsResponseStream { + auto stub = [self getStub]; + EchoRequest request; + EchoResponse response; + ClientContext context; + request.set_message("hello"); + + auto stream = stub->ResponseStream(&context, request); + + XCTAssertTrue(stream->Read(&response)); + XCTAssertEqual(response.message(), request.message() + "0"); + XCTAssertTrue(stream->Read(&response)); + XCTAssertEqual(response.message(), request.message() + "1"); + + context.TryCancel(); + + // The cancellation races with responses, so there might be zero or + // one responses pending, read till failure + + if (stream->Read(&response)) { + XCTAssertEqual(response.message(), request.message() + "2"); + // Since we have cancelled, we expect the next attempt to read to fail + XCTAssertFalse(stream->Read(&response)); + } +} + +- (void)testlClientCancelsBidiStream { + auto stub = [self getStub]; + EchoRequest request; + EchoResponse response; + ClientContext context; + grpc::string msg("hello"); + + auto stream = stub->BidiStream(&context); + + request.set_message(msg + "0"); + XCTAssertTrue(stream->Write(request)); + XCTAssertTrue(stream->Read(&response)); + XCTAssertEqual(response.message(), request.message()); + + request.set_message(msg + "1"); + XCTAssertTrue(stream->Write(request)); + + context.TryCancel(); + + // The cancellation races with responses, so there might be zero or + // one responses pending, read till failure + + if (stream->Read(&response)) { + XCTAssertEqual(response.message(), request.message()); + // Since we have cancelled, we expect the next attempt to read to fail + XCTAssertFalse(stream->Read(&response)); + } + + Status s = stream->Finish(); + XCTAssertEqual(grpc::StatusCode::CANCELLED, s.error_code()); +} + +- (void)testNonExistingService { + auto channel = [self getChannel]; + auto stub = grpc::testing::UnimplementedEchoService::NewStub(channel); + + EchoRequest request; + EchoResponse response; + request.set_message("Hello"); + + ClientContext context; + Status s = stub->Unimplemented(&context, request, &response); + XCTAssertEqual(grpc::StatusCode::UNIMPLEMENTED, s.error_code()); + XCTAssertEqual("", s.error_message()); +} + +- (void)testBinaryTrailer { + auto stub = [self getStub]; + EchoRequest request; + EchoResponse response; + ClientContext context; + + request.mutable_param()->set_echo_metadata(true); + DebugInfo* info = request.mutable_param()->mutable_debug_info(); + info->add_stack_entries("stack_entry_1"); + info->add_stack_entries("stack_entry_2"); + info->add_stack_entries("stack_entry_3"); + info->set_detail("detailed debug info"); + grpc::string expected_string = info->SerializeAsString(); + request.set_message("Hello"); + + Status s = stub->Echo(&context, request, &response); + XCTAssertFalse(s.ok()); + auto trailers = context.GetServerTrailingMetadata(); + XCTAssertEqual(1u, trailers.count(kDebugInfoTrailerKey)); + auto iter = trailers.find(kDebugInfoTrailerKey); + XCTAssertEqual(expected_string, iter->second); + // Parse the returned trailer into a DebugInfo proto. + DebugInfo returned_info; + XCTAssertTrue(returned_info.ParseFromString(ToString(iter->second))); +} + +- (void)testExpectError { + auto stub = [self getStub]; + std::vector expected_status; + expected_status.emplace_back(); + expected_status.back().set_code(13); // INTERNAL + // No Error message or details + + expected_status.emplace_back(); + expected_status.back().set_code(13); // INTERNAL + expected_status.back().set_error_message("text error message"); + expected_status.back().set_binary_error_details("text error details"); + + expected_status.emplace_back(); + expected_status.back().set_code(13); // INTERNAL + expected_status.back().set_error_message("text error message"); + expected_status.back().set_binary_error_details("\x0\x1\x2\x3\x4\x5\x6\x8\x9\xA\xB"); + + for (auto iter = expected_status.begin(); iter != expected_status.end(); ++iter) { + EchoRequest request; + EchoResponse response; + ClientContext context; + request.set_message("Hello"); + auto* error = request.mutable_param()->mutable_expected_error(); + error->set_code(iter->code()); + error->set_error_message(iter->error_message()); + error->set_binary_error_details(iter->binary_error_details()); + + Status s = stub->Echo(&context, request, &response); + XCTAssertFalse(s.ok()); + XCTAssertEqual(iter->code(), s.error_code()); + XCTAssertEqual(iter->error_message(), s.error_message()); + XCTAssertEqual(iter->binary_error_details(), s.error_details()); + XCTAssertTrue(context.debug_error_string().find("created") != std::string::npos); + XCTAssertTrue(context.debug_error_string().find("file") != std::string::npos); + XCTAssertTrue(context.debug_error_string().find("line") != std::string::npos); + XCTAssertTrue(context.debug_error_string().find("status") != std::string::npos); + XCTAssertTrue(context.debug_error_string().find("13") != std::string::npos); + } +} + +- (void)testRpcDeadlineExpires { + auto stub = [self getStub]; + EchoRequest request; + EchoResponse response; + request.set_message("Hello"); + request.mutable_param()->set_skip_cancelled_check(true); + // Let server sleep for 40 ms first to guarantee expiry. + request.mutable_param()->set_server_sleep_us(40 * 1000); + + ClientContext context; + std::chrono::system_clock::time_point deadline = + std::chrono::system_clock::now() + std::chrono::milliseconds(1); + context.set_deadline(deadline); + Status s = stub->Echo(&context, request, &response); + XCTAssertEqual(grpc::StatusCode::DEADLINE_EXCEEDED, s.error_code()); +} + +- (void)testRpcLongDeadline { + auto stub = [self getStub]; + EchoRequest request; + EchoResponse response; + request.set_message("Hello"); + + ClientContext context; + std::chrono::system_clock::time_point deadline = + std::chrono::system_clock::now() + std::chrono::hours(1); + context.set_deadline(deadline); + Status s = stub->Echo(&context, request, &response); + XCTAssertEqual(response.message(), request.message()); + XCTAssertTrue(s.ok()); +} + +- (void)testEchoDeadlineForNoDeadlineRpc { + auto stub = [self getStub]; + EchoRequest request; + EchoResponse response; + request.set_message("Hello"); + request.mutable_param()->set_echo_deadline(true); + + ClientContext context; + Status s = stub->Echo(&context, request, &response); + XCTAssertEqual(response.message(), request.message()); + XCTAssertTrue(s.ok()); + XCTAssertEqual(response.param().request_deadline(), gpr_inf_future(GPR_CLOCK_REALTIME).tv_sec); +} + +- (void)testPeer { + auto stub = [self getStub]; + EchoRequest request; + EchoResponse response; + request.set_message("Hello"); + ClientContext context; + Status s = stub->Echo(&context, request, &response); + XCTAssertTrue(s.ok()); + XCTAssertTrue(CheckIsLocalhost(context.peer())); +} + +- (void)testClientInterceptor { + DummyInterceptor::Reset(); + std::vector> creators; + // Add 20 dummy interceptors + for (auto i = 0; i < 20; i++) { + creators.push_back(std::unique_ptr(new DummyInterceptorFactory())); + } + auto channel = [self getChannelWithInterceptors:std::move(creators)]; + auto stub = EchoTestService::NewStub(channel); + + EchoRequest request; + EchoResponse response; + ClientContext context; + request.set_message("Hello"); + Status s = stub->Echo(&context, request, &response); + XCTAssertTrue(s.ok()); + XCTAssertEqual(DummyInterceptor::GetNumTimesRun(), 20); +} + +@end diff --git a/test/cpp/ios/CronetTests/TestHelper.h b/test/cpp/ios/CronetTests/TestHelper.h new file mode 100644 index 00000000000..fb8a42d459a --- /dev/null +++ b/test/cpp/ios/CronetTests/TestHelper.h @@ -0,0 +1,81 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef TESTHELPER_H +#define TESTHELPER_H + +#import +#import +#import + +#import +#import +#import +#import +#import + +const char* const kServerFinishAfterNReads = "server_finish_after_n_reads"; +const char* const kServerResponseStreamsToSend = "server_responses_to_send"; +const int kServerDefaultResponseStreamsToSend = 3; +const char* const kDebugInfoTrailerKey = "debug-info-bin"; + +grpc::string ToString(const grpc::string_ref& r); +void configureCronet(void); +bool CheckIsLocalhost(const grpc::string& addr); + +class DummyInterceptor : public grpc::experimental::Interceptor { + public: + DummyInterceptor() {} + virtual void Intercept(grpc::experimental::InterceptorBatchMethods* methods); + static void Reset(); + static int GetNumTimesRun(); + + private: + static std::atomic num_times_run_; + static std::atomic num_times_run_reverse_; +}; + +class DummyInterceptorFactory + : public grpc::experimental::ClientInterceptorFactoryInterface { + public: + virtual grpc::experimental::Interceptor* CreateClientInterceptor( + grpc::experimental::ClientRpcInfo* info) override { + return new DummyInterceptor(); + } +}; + +class TestServiceImpl : public grpc::testing::EchoTestService::Service { + public: + grpc::Status Echo(grpc::ServerContext* context, + const grpc::testing::EchoRequest* request, + grpc::testing::EchoResponse* response); + grpc::Status RequestStream( + grpc::ServerContext* context, + grpc::ServerReader* reader, + grpc::testing::EchoResponse* response); + grpc::Status ResponseStream( + grpc::ServerContext* context, const grpc::testing::EchoRequest* request, + grpc::ServerWriter* writer); + + grpc::Status BidiStream( + grpc::ServerContext* context, + grpc::ServerReaderWriter* stream); +}; + +#endif /* TESTHELPER_H */ diff --git a/test/cpp/ios/CronetTests/TestHelper.mm b/test/cpp/ios/CronetTests/TestHelper.mm new file mode 100644 index 00000000000..3b2d1803960 --- /dev/null +++ b/test/cpp/ios/CronetTests/TestHelper.mm @@ -0,0 +1,198 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "TestHelper.h" +#import +#import +#import + +using std::chrono::system_clock; +using grpc::testing::EchoRequest; +using grpc::testing::EchoResponse; +using grpc::testing::EchoTestService; +using grpc::ServerContext; +using grpc::Status; + +std::atomic DummyInterceptor::num_times_run_; +std::atomic DummyInterceptor::num_times_run_reverse_; + +grpc::string ToString(const grpc::string_ref& r) { return grpc::string(r.data(), r.size()); } + +void configureCronet(void) { + static dispatch_once_t configureCronet; + dispatch_once(&configureCronet, ^{ + [Cronet setHttp2Enabled:YES]; + [Cronet setSslKeyLogFileName:@"Documents/key"]; + [Cronet enableTestCertVerifierForTesting]; + NSURL* url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory + inDomains:NSUserDomainMask] lastObject]; + [Cronet start]; + [Cronet startNetLogToFile:@"cronet_netlog.json" logBytes:YES]; + }); +} + +bool CheckIsLocalhost(const grpc::string& addr) { + const grpc::string kIpv6("[::1]:"); + const grpc::string kIpv4MappedIpv6("[::ffff:127.0.0.1]:"); + const grpc::string kIpv4("127.0.0.1:"); + return addr.substr(0, kIpv4.size()) == kIpv4 || + addr.substr(0, kIpv4MappedIpv6.size()) == kIpv4MappedIpv6 || + addr.substr(0, kIpv6.size()) == kIpv6; +} + +int GetIntValueFromMetadataHelper(const char* key, + const std::multimap& metadata, + int default_value) { + if (metadata.find(key) != metadata.end()) { + std::istringstream iss(ToString(metadata.find(key)->second)); + iss >> default_value; + } + + return default_value; +} + +int GetIntValueFromMetadata(const char* key, + const std::multimap& metadata, + int default_value) { + return GetIntValueFromMetadataHelper(key, metadata, default_value); +} + +// When echo_deadline is requested, deadline seen in the ServerContext is set in +// the response in seconds. +void MaybeEchoDeadline(ServerContext* context, const EchoRequest* request, EchoResponse* response) { + if (request->has_param() && request->param().echo_deadline()) { + gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_REALTIME); + if (context->deadline() != system_clock::time_point::max()) { + grpc::Timepoint2Timespec(context->deadline(), &deadline); + } + response->mutable_param()->set_request_deadline(deadline.tv_sec); + } +} + +Status TestServiceImpl::Echo(ServerContext* context, const EchoRequest* request, + EchoResponse* response) { + // A bit of sleep to make sure that short deadline tests fail + if (request->has_param() && request->param().server_sleep_us() > 0) { + gpr_sleep_until( + gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_micros(request->param().server_sleep_us(), GPR_TIMESPAN))); + } + + if (request->has_param() && request->param().has_expected_error()) { + const auto& error = request->param().expected_error(); + return Status(static_cast(error.code()), error.error_message(), + error.binary_error_details()); + } + + if (request->has_param() && request->param().echo_metadata()) { + const std::multimap& client_metadata = + context->client_metadata(); + for (std::multimap::const_iterator iter = + client_metadata.begin(); + iter != client_metadata.end(); ++iter) { + context->AddTrailingMetadata(ToString(iter->first), ToString(iter->second)); + } + // Terminate rpc with error and debug info in trailer. + if (request->param().debug_info().stack_entries_size() || + !request->param().debug_info().detail().empty()) { + grpc::string serialized_debug_info = request->param().debug_info().SerializeAsString(); + context->AddTrailingMetadata(kDebugInfoTrailerKey, serialized_debug_info); + return Status::CANCELLED; + } + } + + response->set_message(request->message()); + MaybeEchoDeadline(context, request, response); + return Status::OK; +} + +Status TestServiceImpl::RequestStream(ServerContext* context, + grpc::ServerReader* reader, + EchoResponse* response) { + EchoRequest request; + response->set_message(""); + int num_msgs_read = 0; + while (reader->Read(&request)) { + response->mutable_message()->append(request.message()); + ++num_msgs_read; + } + return Status::OK; +} + +Status TestServiceImpl::ResponseStream(ServerContext* context, const EchoRequest* request, + grpc::ServerWriter* writer) { + EchoResponse response; + int server_responses_to_send = + GetIntValueFromMetadata(kServerResponseStreamsToSend, context->client_metadata(), + kServerDefaultResponseStreamsToSend); + for (int i = 0; i < server_responses_to_send; i++) { + response.set_message(request->message() + grpc::to_string(i)); + if (i == server_responses_to_send - 1) { + writer->WriteLast(response, grpc::WriteOptions()); + } else { + writer->Write(response); + } + } + return Status::OK; +} + +Status TestServiceImpl::BidiStream(ServerContext* context, + grpc::ServerReaderWriter* stream) { + EchoRequest request; + EchoResponse response; + + // kServerFinishAfterNReads suggests after how many reads, the server should + // write the last message and send status (coalesced using WriteLast) + int server_write_last = + GetIntValueFromMetadata(kServerFinishAfterNReads, context->client_metadata(), 0); + + int read_counts = 0; + while (stream->Read(&request)) { + read_counts++; + response.set_message(request.message()); + if (read_counts == server_write_last) { + stream->WriteLast(response, grpc::WriteOptions()); + } else { + stream->Write(response); + } + } + + return Status::OK; +} + +void DummyInterceptor::Intercept(grpc::experimental::InterceptorBatchMethods* methods) { + if (methods->QueryInterceptionHookPoint( + grpc::experimental::InterceptionHookPoints::PRE_SEND_INITIAL_METADATA)) { + num_times_run_++; + } else if (methods->QueryInterceptionHookPoint( + grpc::experimental::InterceptionHookPoints::POST_RECV_INITIAL_METADATA)) { + num_times_run_reverse_++; + } + methods->Proceed(); +} + +void DummyInterceptor::Reset() { + num_times_run_.store(0); + num_times_run_reverse_.store(0); +} + +int DummyInterceptor::GetNumTimesRun() { + NSCAssert(num_times_run_.load() == num_times_run_reverse_.load(), + @"Interceptor must run same number of times in both directions"); + return num_times_run_.load(); +} diff --git a/test/cpp/ios/Info.plist b/test/cpp/ios/Info.plist new file mode 100644 index 00000000000..fbeeb96ba6c --- /dev/null +++ b/test/cpp/ios/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + gRPC.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/test/cpp/ios/Podfile b/test/cpp/ios/Podfile new file mode 100644 index 00000000000..49044d2a050 --- /dev/null +++ b/test/cpp/ios/Podfile @@ -0,0 +1,102 @@ +source 'https://github.com/CocoaPods/Specs.git' + +install! 'cocoapods', :deterministic_uuids => false + +# Location of gRPC's repo root relative to this file. +GRPC_LOCAL_SRC = '../../..' + + +target 'CronetTests' do + platform :ios, '8.0' + pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf", :inhibit_warnings => true + + pod '!ProtoCompiler', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" + pod '!ProtoCompiler-gRPCCppPlugin', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" + pod 'Protobuf-C++', :podspec => "#{GRPC_LOCAL_SRC}/src/cpp", :inhibit_warnings => true + + pod 'BoringSSL-GRPC', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true + + pod 'gRPC-Core', :path => GRPC_LOCAL_SRC + pod 'gRPC-C++', :path => GRPC_LOCAL_SRC + pod 'gRPC-C++/Protobuf', :path => GRPC_LOCAL_SRC + pod 'RemoteTestCpp', :path => "RemoteTestClientCpp", :inhibit_warnings => true + + pod 'gRPC-Core/Cronet-Implementation', :path => GRPC_LOCAL_SRC + pod 'CronetFramework', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" + pod 'gRPC-Core/Tests', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true +end + +# gRPC-Core.podspec needs to be modified to be successfully used for local development. A Podfile's +# pre_install hook lets us do that. The block passed to it runs after the podspecs are downloaded +# and before they are installed in the user project. +# +# This podspec searches for the gRPC core library headers under "$(PODS_ROOT)/gRPC-Core", where +# Cocoapods normally places the downloaded sources. When doing local development of the libraries, +# though, Cocoapods just takes the sources from whatever directory was specified using `:path`, and +# doesn't copy them under $(PODS_ROOT). When using static libraries, one can sometimes rely on the +# symbolic links to the pods headers that Cocoapods creates under "$(PODS_ROOT)/Headers". But those +# aren't created when using dynamic frameworks. So our solution is to modify the podspec on the fly +# to point at the local directory where the sources are. +# +# TODO(jcanizales): Send a PR to Cocoapods to get rid of this need. +pre_install do |installer| + # This is the gRPC-Core podspec object, as initialized by its podspec file. + grpc_core_spec = installer.pod_targets.find{|t| t.name.start_with?('gRPC-Core')}.root_spec + + # Copied from gRPC-Core.podspec, except for the adjusted src_root: + src_root = "$(PODS_ROOT)/../#{GRPC_LOCAL_SRC}" + grpc_core_spec.pod_target_xcconfig = { + 'GRPC_SRC_ROOT' => src_root, + 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"', + 'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"', + # If we don't set these two settings, `include/grpc/support/time.h` and + # `src/core/lib/gpr/string.h` shadow the system `` and ``, breaking the + # build. + 'USE_HEADERMAP' => 'NO', + 'ALWAYS_SEARCH_USER_PATHS' => 'NO', + } +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'YES' + end + + # CocoaPods creates duplicated library targets of gRPC-Core when the test targets include + # non-default subspecs of gRPC-Core. All of these library targets start with prefix 'gRPC-Core' + # and require the same error suppresion. + if target.name.start_with?('gRPC-Core') + target.build_configurations.each do |config| + # TODO(zyc): Remove this setting after the issue is resolved + # GPR_UNREACHABLE_CODE causes "Control may reach end of non-void + # function" warning + config.build_settings['GCC_WARN_ABOUT_RETURN_TYPE'] = 'NO' + config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_CRONET_WITH_PACKET_COALESCING=1 GRPC_CFSTREAM=1' + end + end + + # Activate Cronet for the dedicated build configuration 'Cronet', which will be used solely by + # the test target 'InteropTestsRemoteWithCronet' + # Activate GRPCCall+InternalTests functions for the dedicated build configuration 'Test', which will + # be used by all test targets using it. + if /gRPC-(mac|i)OS/.match(target.name) + target.build_configurations.each do |config| + if config.name == 'Cronet' + config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_COMPILE_WITH_CRONET=1 GRPC_TEST_OBJC=1' + elsif config.name == 'Test' + config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_TEST_OBJC=1' + end + end + end + + # Enable NSAssert on gRPC + if /(gRPC|ProtoRPC|RxLibrary)-(mac|i)OS/.match(target.name) + target.build_configurations.each do |config| + if config.name != 'Release' + config.build_settings['ENABLE_NS_ASSERTIONS'] = 'YES' + end + end + end + end +end diff --git a/test/cpp/ios/RemoteTestClientCpp/RemoteTestCpp.podspec b/test/cpp/ios/RemoteTestClientCpp/RemoteTestCpp.podspec new file mode 100644 index 00000000000..0d51fdab31e --- /dev/null +++ b/test/cpp/ios/RemoteTestClientCpp/RemoteTestCpp.podspec @@ -0,0 +1,98 @@ +Pod::Spec.new do |s| + s.name = "RemoteTestCpp" + s.version = "0.0.1" + s.license = "Apache License, Version 2.0" + s.authors = { 'gRPC contributors' => 'grpc-io@googlegroups.com' } + s.homepage = "https://grpc.io/" + s.summary = "RemoteTest example" + s.source = { :git => 'https://github.com/grpc/grpc.git' } + + s.ios.deployment_target = '7.1' + s.osx.deployment_target = '10.9' + + # Run protoc with the C++ and gRPC plugins to generate protocol messages and gRPC clients. + s.dependency "!ProtoCompiler-gRPCCppPlugin" + s.dependency "Protobuf-C++" + s.dependency "gRPC-C++" + s.source_files = "src/proto/grpc/testing/*.pb.{h,cc}" + s.header_mappings_dir = "RemoteTestCpp" + s.requires_arc = false + + repo_root = '../../../..' + config = ENV['CONFIG'] || 'opt' + bin_dir = "#{repo_root}/bins/#{config}" + + protoc = "#{bin_dir}/protobuf/protoc" + well_known_types_dir = "#{repo_root}/third_party/protobuf/src" + plugin = "#{bin_dir}/grpc_cpp_plugin" + proto_dir = "#{repo_root}/src/proto/grpc/testing" + + s.prepare_command = <<-CMD + if [ -f #{protoc} ]; then + #{protoc} \ + --plugin=protoc-gen-grpc=#{plugin} \ + --cpp_out=. \ + --grpc_out=. \ + -I #{repo_root} \ + -I #{proto_dir} \ + -I #{well_known_types_dir} \ + #{proto_dir}/echo.proto + #{protoc} \ + --plugin=protoc-gen-grpc=#{plugin} \ + --cpp_out=. \ + --grpc_out=. \ + -I #{repo_root} \ + -I #{proto_dir} \ + -I #{well_known_types_dir} \ + #{proto_dir}/echo_messages.proto + #{protoc} \ + --plugin=protoc-gen-grpc=#{plugin} \ + --cpp_out=. \ + --grpc_out=. \ + -I #{repo_root} \ + -I #{proto_dir} \ + -I #{well_known_types_dir} \ + #{proto_dir}/simple_messages.proto + else + # protoc was not found bin_dir, use installed version instead + + if ! [ -x "$(command -v protoc)" ]; then + (>&2 echo "\nERROR: protoc not found") + exit 1 + fi + (>&2 echo "\nWARNING: Using installed version of protoc. It might be incompatible with gRPC") + + protoc \ + --plugin=protoc-gen-grpc=#{plugin} \ + --cpp_out=. \ + --grpc_out=. \ + -I #{repo_root} \ + -I #{proto_dir} \ + -I #{well_known_types_dir} \ + #{proto_dir}/echo.proto + protoc \ + --plugin=protoc-gen-grpc=#{plugin} \ + --cpp_out=. \ + --grpc_out=. \ + -I #{repo_root} \ + -I #{proto_dir} \ + -I #{well_known_types_dir} \ + #{proto_dir}/echo_messages.proto + protoc \ + --plugin=protoc-gen-grpc=#{plugin} \ + --cpp_out=. \ + --grpc_out=. \ + -I #{repo_root} \ + -I #{proto_dir} \ + -I #{well_known_types_dir} \ + #{proto_dir}/simple_messages.proto + fi + CMD + + s.pod_target_xcconfig = { + # This is needed by all pods that depend on Protobuf: + 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1 GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO=1', + # This is needed by all pods that depend on gRPC-RxLibrary: + 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES', + } +end diff --git a/test/cpp/ios/Tests.xcodeproj/project.pbxproj b/test/cpp/ios/Tests.xcodeproj/project.pbxproj new file mode 100644 index 00000000000..865fc6636ff --- /dev/null +++ b/test/cpp/ios/Tests.xcodeproj/project.pbxproj @@ -0,0 +1,594 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + B02C351522E8E5FE00708B55 /* TestHelper.mm in Sources */ = {isa = PBXBuildFile; fileRef = B02C351322E8E5FE00708B55 /* TestHelper.mm */; }; + B0B151E622D7DFCA00C4BFE0 /* CppCronetEnd2EndTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = B0B151E522D7DFCA00C4BFE0 /* CppCronetEnd2EndTests.mm */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 00DA7762CD572056A66501B3 /* Pods-CronetTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests.cronet.xcconfig"; sourceTree = ""; }; + 5E7F485922775B15006656AD /* CronetTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CronetTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 5E7F486622776AD8006656AD /* Cronet.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cronet.framework; path = Pods/CronetFramework/Cronet.framework; sourceTree = ""; }; + 635697D81B14FC11007A7283 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 7B0DE0EC5EB517A302CD4698 /* Pods-CronetTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests.release.xcconfig"; sourceTree = ""; }; + B02C351322E8E5FE00708B55 /* TestHelper.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TestHelper.mm; sourceTree = ""; }; + B02C351422E8E5FE00708B55 /* TestHelper.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; path = TestHelper.h; sourceTree = ""; }; + B0B151E522D7DFCA00C4BFE0 /* CppCronetEnd2EndTests.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; path = CppCronetEnd2EndTests.mm; sourceTree = ""; }; + CDB4E9D8890B97B6FAF35A4F /* Pods-CronetTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests.debug.xcconfig"; sourceTree = ""; }; + ED8BB10304E81C38CAE911C2 /* Pods-CronetTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests.test.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 5E7F485622775B15006656AD /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 136D535E19727099B941D7B1 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 5E7F486622776AD8006656AD /* Cronet.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 51E4650F34F854F41FF053B3 /* Pods */ = { + isa = PBXGroup; + children = ( + CDB4E9D8890B97B6FAF35A4F /* Pods-CronetTests.debug.xcconfig */, + ED8BB10304E81C38CAE911C2 /* Pods-CronetTests.test.xcconfig */, + 00DA7762CD572056A66501B3 /* Pods-CronetTests.cronet.xcconfig */, + 7B0DE0EC5EB517A302CD4698 /* Pods-CronetTests.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + 5E7F485A22775B15006656AD /* CronetTests */ = { + isa = PBXGroup; + children = ( + B0B151E522D7DFCA00C4BFE0 /* CppCronetEnd2EndTests.mm */, + B02C351322E8E5FE00708B55 /* TestHelper.mm */, + B02C351422E8E5FE00708B55 /* TestHelper.h */, + ); + path = CronetTests; + sourceTree = ""; + }; + 635697BE1B14FC11007A7283 = { + isa = PBXGroup; + children = ( + 635697C91B14FC11007A7283 /* Tests */, + 5E7F485A22775B15006656AD /* CronetTests */, + 635697C81B14FC11007A7283 /* Products */, + 51E4650F34F854F41FF053B3 /* Pods */, + 136D535E19727099B941D7B1 /* Frameworks */, + ); + sourceTree = ""; + }; + 635697C81B14FC11007A7283 /* Products */ = { + isa = PBXGroup; + children = ( + 5E7F485922775B15006656AD /* CronetTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 635697C91B14FC11007A7283 /* Tests */ = { + isa = PBXGroup; + children = ( + 635697D71B14FC11007A7283 /* Supporting Files */, + ); + name = Tests; + sourceTree = SOURCE_ROOT; + }; + 635697D71B14FC11007A7283 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 635697D81B14FC11007A7283 /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 5E7F485822775B15006656AD /* CronetTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5E7F485E22775B15006656AD /* Build configuration list for PBXNativeTarget "CronetTests" */; + buildPhases = ( + CCAEC0F23E05489651A07D53 /* [CP] Check Pods Manifest.lock */, + 5E7F485522775B15006656AD /* Sources */, + 5E7F485622775B15006656AD /* Frameworks */, + 5E7F485722775B15006656AD /* Resources */, + 292EA42A76AC7933A37235FD /* [CP] Embed Pods Frameworks */, + 30AFD6F6FC40B9923632A866 /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = CronetTests; + productName = CronetTests; + productReference = 5E7F485922775B15006656AD /* CronetTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 635697BF1B14FC11007A7283 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0630; + ORGANIZATIONNAME = gRPC; + TargetAttributes = { + 5E7F485822775B15006656AD = { + CreatedOnToolsVersion = 10.1; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 635697C21B14FC11007A7283 /* Build configuration list for PBXProject "Tests" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + English, + en, + ); + mainGroup = 635697BE1B14FC11007A7283; + productRefGroup = 635697C81B14FC11007A7283 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 5E7F485822775B15006656AD /* CronetTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 5E7F485722775B15006656AD /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 292EA42A76AC7933A37235FD /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests-frameworks.sh", + "${PODS_ROOT}/CronetFramework/Cronet.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 30AFD6F6FC40B9923632A866 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests-resources.sh", + "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-C++/gRPCCertificates-Cpp.bundle", + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates-Cpp.bundle", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + CCAEC0F23E05489651A07D53 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-CronetTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 5E7F485522775B15006656AD /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B0B151E622D7DFCA00C4BFE0 /* CppCronetEnd2EndTests.mm in Sources */, + B02C351522E8E5FE00708B55 /* TestHelper.mm in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 5E1228981E4D400F00E8504F /* Test */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + "GRPC_TEST_OBJC=1", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.3; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Test; + }; + 5E7F485F22775B15006656AD /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = CDB4E9D8890B97B6FAF35A4F /* Pods-CronetTests.debug.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_TESTABILITY = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Pods/CronetFramework", + ); + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_INHIBIT_ALL_WARNINGS = YES; + INFOPLIST_FILE = Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CronetTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = ../../..; + }; + name = Debug; + }; + 5E7F486022775B15006656AD /* Test */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = ED8BB10304E81C38CAE911C2 /* Pods-CronetTests.test.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Pods/CronetFramework", + ); + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_INHIBIT_ALL_WARNINGS = YES; + INFOPLIST_FILE = Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CronetTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = ../../..; + }; + name = Test; + }; + 5E7F486122775B15006656AD /* Cronet */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 00DA7762CD572056A66501B3 /* Pods-CronetTests.cronet.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Pods/CronetFramework", + ); + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_INHIBIT_ALL_WARNINGS = YES; + INFOPLIST_FILE = Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CronetTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = ../../..; + }; + name = Cronet; + }; + 5E7F486222775B15006656AD /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7B0DE0EC5EB517A302CD4698 /* Pods-CronetTests.release.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Pods/CronetFramework", + ); + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_INHIBIT_ALL_WARNINGS = YES; + INFOPLIST_FILE = Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CronetTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = ../../..; + }; + name = Release; + }; + 5EC3C7A01D4FC18C000330E2 /* Cronet */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + "GRPC_TEST_OBJC=1", + "GRPC_COMPILE_WITH_CRONET=1", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.3; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Cronet; + }; + 635697D91B14FC11007A7283 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.3; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 635697DA1B14FC11007A7283 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.3; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 5E7F485E22775B15006656AD /* Build configuration list for PBXNativeTarget "CronetTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5E7F485F22775B15006656AD /* Debug */, + 5E7F486022775B15006656AD /* Test */, + 5E7F486122775B15006656AD /* Cronet */, + 5E7F486222775B15006656AD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 635697C21B14FC11007A7283 /* Build configuration list for PBXProject "Tests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 635697D91B14FC11007A7283 /* Debug */, + 5E1228981E4D400F00E8504F /* Test */, + 5EC3C7A01D4FC18C000330E2 /* Cronet */, + 635697DA1B14FC11007A7283 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 635697BF1B14FC11007A7283 /* Project object */; +} diff --git a/test/cpp/ios/Tests.xcodeproj/xcshareddata/xcschemes/CronetTests.xcscheme b/test/cpp/ios/Tests.xcodeproj/xcshareddata/xcschemes/CronetTests.xcscheme new file mode 100644 index 00000000000..0156c906971 --- /dev/null +++ b/test/cpp/ios/Tests.xcodeproj/xcshareddata/xcschemes/CronetTests.xcscheme @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/cpp/ios/build_tests.sh b/test/cpp/ios/build_tests.sh new file mode 100755 index 00000000000..ead0159dcc9 --- /dev/null +++ b/test/cpp/ios/build_tests.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Don't run this script standalone. Instead, run from the repository root: +# ./tools/run_tests/run_tests.py -l objc + +set -e + +# CocoaPods requires the terminal to be using UTF-8 encoding. +export LANG=en_US.UTF-8 + +cd "$(dirname "$0")" + +hash pod 2>/dev/null || { echo >&2 "Cocoapods needs to be installed."; exit 1; } +hash xcodebuild 2>/dev/null || { + echo >&2 "XCode command-line tools need to be installed." + exit 1 +} + +# clean the directory +rm -rf Pods +rm -rf Tests.xcworkspace +rm -f Podfile.lock +rm -rf RemoteTestClientCpp/src + +echo "TIME: $(date)" +pod install + diff --git a/test/cpp/ios/run_tests.sh b/test/cpp/ios/run_tests.sh new file mode 100755 index 00000000000..9eee0cd28ca --- /dev/null +++ b/test/cpp/ios/run_tests.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Don't run this script standalone. Instead, run from the repository root: +# ./tools/run_tests/run_tests.py -l c++ + +set -ev + +cd "$(dirname "$0")" + + +set -o pipefail + +XCODEBUILD_FILTER='(^CompileC |^Ld |^ *[^ ]*clang |^ *cd |^ *export |^Libtool |^ *[^ ]*libtool |^CpHeader |^ *builtin-copy )' + +xcodebuild \ + -workspace Tests.xcworkspace \ + -scheme CronetTests \ + -destination name="iPhone 8" \ + test \ + | egrep -v "$XCODEBUILD_FILTER" \ + | egrep -v '^$' - diff --git a/tools/internal_ci/macos/grpc_basictests_cpp_ios.cfg b/tools/internal_ci/macos/grpc_basictests_cpp_ios.cfg new file mode 100644 index 00000000000..3c8e402d3fc --- /dev/null +++ b/tools/internal_ci/macos/grpc_basictests_cpp_ios.cfg @@ -0,0 +1,31 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" +timeout_mins: 120 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results --extra_args -r ios-cpp-test-.*" +} diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index f11927bd5d6..082ca6dd64e 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1130,6 +1130,13 @@ class ObjCLanguage(object): environ={ 'SCHEME': 'CronetTests' })) + out.append( + self.config.job_spec( + ['test/cpp/ios/run_tests.sh'], + timeout_seconds=20 * 60, + shortname='ios-cpp-test-cronet', + cpu_cost=1e6, + environ=_FORCE_ENVIRON_FOR_WRAPPERS)) out.append( self.config.job_spec( ['src/objective-c/tests/run_one_test.sh'], @@ -1156,6 +1163,7 @@ class ObjCLanguage(object): return [ ['src/objective-c/tests/build_tests.sh'], ['test/core/iomgr/ios/CFStreamTests/build_tests.sh'], + ['test/cpp/ios/build_tests.sh'], ] def post_tests_steps(self): From 8318e578db62a999b8c03d6a47c12fe4c1d9e92d Mon Sep 17 00:00:00 2001 From: Yunjia Wang Date: Mon, 29 Jul 2019 10:52:32 -0700 Subject: [PATCH 1025/1555] SpikyLoad: construct outside --- test/cpp/microbenchmarks/bm_threadpool.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/microbenchmarks/bm_threadpool.cc b/test/cpp/microbenchmarks/bm_threadpool.cc index d3d25074460..55c8772e5b5 100644 --- a/test/cpp/microbenchmarks/bm_threadpool.cc +++ b/test/cpp/microbenchmarks/bm_threadpool.cc @@ -291,8 +291,8 @@ static void BM_SpikyLoad(benchmark::State& state) { const int kNumSpikes = 1000; const int batch_size = 3 * num_threads; std::vector work_vector(batch_size); + grpc_core::ThreadPool pool(num_threads); while (state.KeepRunningBatch(kNumSpikes * batch_size)) { - grpc_core::ThreadPool pool(num_threads); for (int i = 0; i != kNumSpikes; ++i) { BlockingCounter counter(batch_size); for (auto& w : work_vector) { From 6b24df29454cb9048d48f86dcb91a036da199da2 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Mon, 29 Jul 2019 10:41:55 -0700 Subject: [PATCH 1026/1555] Refined edge case checks + added comments --- src/compiler/objective_c_generator_helpers.h | 3 --- src/compiler/objective_c_plugin.cc | 6 +++++- src/objective-c/examples/InterceptorSample/Podfile | 3 +++ .../examples/RemoteTestClient/RemoteTest.podspec | 5 ++++- src/objective-c/examples/Sample/Podfile | 3 +++ 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/compiler/objective_c_generator_helpers.h b/src/compiler/objective_c_generator_helpers.h index d686014faa5..0ed27738c2e 100644 --- a/src/compiler/objective_c_generator_helpers.h +++ b/src/compiler/objective_c_generator_helpers.h @@ -19,9 +19,6 @@ #ifndef GRPC_INTERNAL_COMPILER_OBJECTIVE_C_GENERATOR_HELPERS_H #define GRPC_INTERNAL_COMPILER_OBJECTIVE_C_GENERATOR_HELPERS_H -#include -using namespace std; - #include #include "src/compiler/config.h" #include "src/compiler/generator_helpers.h" diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index feebe12797e..f398033f6db 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -88,7 +88,11 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { std::vector<::grpc::string> param = grpc_generator::tokenize(*param_str, "="); if (param[0] == "generate_for_named_framework") { - if (param[1].empty()) { + if (param.size() != 2) { + *error = + grpc::string("Format: generate_for_named_framework="); + return false; + } else if (param[1].empty()) { *error = grpc::string( "Name of framework cannot be empty for parameter: ") + param[0]; diff --git a/src/objective-c/examples/InterceptorSample/Podfile b/src/objective-c/examples/InterceptorSample/Podfile index 6df6c962148..0252451eff9 100644 --- a/src/objective-c/examples/InterceptorSample/Podfile +++ b/src/objective-c/examples/InterceptorSample/Podfile @@ -2,6 +2,9 @@ platform :ios, '8.0' install! 'cocoapods', :deterministic_uuids => false +# Default to use framework, so that providing no 'FRAMEWORK' env parameter works consistently +# for all Samples, specifically because Swift only supports framework. +# Only effective for examples/ use_frameworks! if ENV['FRAMEWORKS'] != 'NO' ROOT_DIR = '../../../..' diff --git a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec index 747df63ac5b..93ba46fcb6d 100644 --- a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec +++ b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec @@ -19,10 +19,13 @@ Pod::Spec.new do |s| protoc = "#{bin_dir}/protobuf/protoc" well_known_types_dir = "#{repo_root}/third_party/protobuf/src" plugin = "#{bin_dir}/grpc_objective_c_plugin" - + + # Since we switched to importing full path, -I needs to be set to the directory + # from which the imported file can be found, which is the grpc's root here if ENV['FRAMEWORKS'] != 'NO' then s.user_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'USE_FRAMEWORKS=1' } s.prepare_command = <<-CMD + # Cannot find file if using *.proto. Maybe files' paths must match the -I flags #{protoc} \ --plugin=protoc-gen-grpc=#{plugin} \ --objc_out=. \ diff --git a/src/objective-c/examples/Sample/Podfile b/src/objective-c/examples/Sample/Podfile index 741a199602e..e7ee700cb17 100644 --- a/src/objective-c/examples/Sample/Podfile +++ b/src/objective-c/examples/Sample/Podfile @@ -3,6 +3,9 @@ platform :ios, '8.0' install! 'cocoapods', :deterministic_uuids => false +# Default to use framework, so that providing no 'FRAMEWORK' env parameter works consistently +# for all Samples, specifically because Swift only supports framework. +# Only effective for examples/ use_frameworks! if ENV['FRAMEWORKS'] != 'NO' # Location of gRPC's repo root relative to this file. From b02ac1be1d1416cae0cbe8968939d2b441b230d4 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Mon, 29 Jul 2019 14:44:37 -0700 Subject: [PATCH 1027/1555] Avoid copybara import error --- src/proto/gen_build_yaml.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/proto/gen_build_yaml.py b/src/proto/gen_build_yaml.py index 1a935b56d89..fc1b5f7986e 100755 --- a/src/proto/gen_build_yaml.py +++ b/src/proto/gen_build_yaml.py @@ -15,6 +15,7 @@ """Generates the appropriate build.json data for all the proto files.""" +from __future__ import print_function import yaml import collections import os @@ -36,6 +37,10 @@ def update_deps(key, proto_filename, deps, deps_external, is_trans, visited): deps_external[key] = [] deps_external[key].append(imp_proto[:-6]) continue + # In case that the path is changed by copybara, + # revert the change to avoid file error. + if imp_proto.startswith('third_party/grpc'): + imp_proto = imp_proto[17:] if key not in deps: deps[key] = [] deps[key].append(imp_proto[:-6]) if is_trans: @@ -66,7 +71,7 @@ def main(): 'proto_transitive_external_deps': deps_external_trans } - print yaml.dump(json) + print(yaml.dump(json)) if __name__ == '__main__': main() From 65b28a29b23d40ffbe6c8eb7655d5265edabc8ee Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Thu, 9 May 2019 10:50:57 -0400 Subject: [PATCH 1028/1555] Initialize compression state only if they are used. Add a lazy initialization path, so that we do not have to initialize/access the state that's only used when we compress. Move the frequently access fields to the front so we are more cache friendly. --- .../message_compress_filter.cc | 42 +++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.cc b/src/core/ext/filters/http/message_compress/message_compress_filter.cc index 3ce79b305df..0e0be6e9cff 100644 --- a/src/core/ext/filters/http/message_compress/message_compress_filter.cc +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.cc @@ -72,29 +72,31 @@ struct call_data { GRPC_CLOSURE_INIT(&start_send_message_batch_in_call_combiner, start_send_message_batch, elem, grpc_schedule_on_exec_ctx); - grpc_slice_buffer_init(&slices); - GRPC_CLOSURE_INIT(&send_message_on_complete, ::send_message_on_complete, - elem, grpc_schedule_on_exec_ctx); - GRPC_CLOSURE_INIT(&on_send_message_next_done, ::on_send_message_next_done, - elem, grpc_schedule_on_exec_ctx); } ~call_data() { - grpc_slice_buffer_destroy_internal(&slices); + if (state_initialized) { + grpc_slice_buffer_destroy_internal(&slices); + } GRPC_ERROR_UNREF(cancel_error); } grpc_core::CallCombiner* call_combiner; + grpc_message_compression_algorithm message_compression_algorithm = + GRPC_MESSAGE_COMPRESS_NONE; + grpc_error* cancel_error = GRPC_ERROR_NONE; + grpc_transport_stream_op_batch* send_message_batch = nullptr; + bool seen_initial_metadata = false; + /* Set to true, if the fields below are initialized. */ + bool state_initialized = false; + grpc_closure start_send_message_batch_in_call_combiner; + /* The fields below are only initialized when we compress the payload. + * Keep them at the bottom of the struct, so they don't pollute the + * cache-lines. */ grpc_linked_mdelem message_compression_algorithm_storage; grpc_linked_mdelem stream_compression_algorithm_storage; grpc_linked_mdelem accept_encoding_storage; grpc_linked_mdelem accept_stream_encoding_storage; - grpc_message_compression_algorithm message_compression_algorithm = - GRPC_MESSAGE_COMPRESS_NONE; - bool seen_initial_metadata = false; - grpc_error* cancel_error = GRPC_ERROR_NONE; - grpc_closure start_send_message_batch_in_call_combiner; - grpc_transport_stream_op_batch* send_message_batch = nullptr; grpc_slice_buffer slices; /**< Buffers up input slices to be compressed */ grpc_core::ManualConstructor replacement_stream; @@ -157,6 +159,18 @@ static grpc_compression_algorithm find_compression_algorithm( return GRPC_COMPRESS_NONE; } +static void initialize_state(grpc_call_element* elem, call_data* calld) { + GPR_DEBUG_ASSERT(!calld->state_initialized); + calld->state_initialized = true; + grpc_slice_buffer_init(&calld->slices); + GRPC_CLOSURE_INIT(&calld->send_message_on_complete, + ::send_message_on_complete, elem, + grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_INIT(&calld->on_send_message_next_done, + ::on_send_message_next_done, elem, + grpc_schedule_on_exec_ctx); +} + static grpc_error* process_send_initial_metadata( grpc_call_element* elem, grpc_metadata_batch* initial_metadata) GRPC_MUST_USE_RESULT; @@ -177,11 +191,13 @@ static grpc_error* process_send_initial_metadata( // Hint compression algorithm. grpc_error* error = GRPC_ERROR_NONE; if (calld->message_compression_algorithm != GRPC_MESSAGE_COMPRESS_NONE) { + initialize_state(elem, calld); error = grpc_metadata_batch_add_tail( initial_metadata, &calld->message_compression_algorithm_storage, grpc_message_compression_encoding_mdelem( calld->message_compression_algorithm)); } else if (stream_compression_algorithm != GRPC_STREAM_COMPRESS_NONE) { + initialize_state(elem, calld); error = grpc_metadata_batch_add_tail( initial_metadata, &calld->stream_compression_algorithm_storage, grpc_stream_compression_encoding_mdelem(stream_compression_algorithm)); @@ -225,6 +241,8 @@ static void send_message_batch_continue(grpc_call_element* elem) { static void finish_send_message(grpc_call_element* elem) { call_data* calld = static_cast(elem->call_data); + GPR_DEBUG_ASSERT(calld->message_compression_algorithm != + GRPC_MESSAGE_COMPRESS_NONE); // Compress the data if appropriate. grpc_slice_buffer tmp; grpc_slice_buffer_init(&tmp); From d88ee54854a2f5d6f53578fe724a6d90b462b178 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Mon, 29 Jul 2019 16:23:11 -0700 Subject: [PATCH 1029/1555] Added missing dependency to channelz_proto_descriptors --- src/proto/grpc/channelz/BUILD | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/proto/grpc/channelz/BUILD b/src/proto/grpc/channelz/BUILD index 1d80ec23af1..cfc8531de1b 100644 --- a/src/proto/grpc/channelz/BUILD +++ b/src/proto/grpc/channelz/BUILD @@ -28,6 +28,12 @@ grpc_proto_library( proto_library( name = "channelz_proto_descriptors", srcs = ["channelz.proto"], + deps = [ + "@com_google_protobuf//:any_proto", + "@com_google_protobuf//:duration_proto", + "@com_google_protobuf//:timestamp_proto", + "@com_google_protobuf//:wrappers_proto", + ], ) filegroup( From 96742f41ff19d2aa36adfa37bdff26f89041ccb4 Mon Sep 17 00:00:00 2001 From: Ryo Murakami Date: Tue, 30 Jul 2019 08:04:02 +0900 Subject: [PATCH 1030/1555] update Scripting Runtime Version empty commit empty commit --- src/csharp/experimental/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/csharp/experimental/README.md b/src/csharp/experimental/README.md index b5c106e320c..cfa9c4b0324 100644 --- a/src/csharp/experimental/README.md +++ b/src/csharp/experimental/README.md @@ -23,7 +23,7 @@ Unity and provide feedback! How to test gRPC in a Unity project -1. Create a Unity project that targets .NET 4.x (Edit -> Project Settings -> Editor -> Scripting Runtime Version). gRPC uses APIs that are only available in .NET4.5+ so this is a requirement. +1. Create a Unity project that targets .NET 4.x Equivalent (Edit -> Project Settings -> Player -> Configuration -> Scripting Runtime Version). gRPC uses APIs that are only available in .NET4.5+ so this is a requirement. 2. Download the latest development build of `grpc_unity_package.VERSION.zip` from [daily builds](https://packages.grpc.io/) From d38178a27db894afe46baf23e188682117ff8434 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 30 Jul 2019 02:52:24 +0200 Subject: [PATCH 1031/1555] Few fixes to the gen_upb_api.sh script. --- tools/codegen/core/gen_upb_api.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/codegen/core/gen_upb_api.sh b/tools/codegen/core/gen_upb_api.sh index d7871d88671..3b8e072d9f3 100755 --- a/tools/codegen/core/gen_upb_api.sh +++ b/tools/codegen/core/gen_upb_api.sh @@ -14,24 +14,26 @@ # See the License for the specific language governing permissions and # limitations under the License. -# REQUIRES: Bazel set -ex +cd $(dirname $0)/../../.. +bazel=`pwd`/tools/bazel + if [ $# -eq 0 ]; then UPB_OUTPUT_DIR=$PWD/src/core/ext/upb-generated rm -rf $UPB_OUTPUT_DIR - mkdir $UPB_OUTPUT_DIR + mkdir -p $UPB_OUTPUT_DIR else UPB_OUTPUT_DIR=$1 fi pushd third_party/protobuf -bazel build :protoc +$bazel build :protoc PROTOC=$PWD/bazel-bin/protoc popd pushd third_party/upb -bazel build :protoc-gen-upb +$bazel build :protoc-gen-upb UPB_PLUGIN=$PWD/bazel-bin/protoc-gen-upb popd From 20f1ea44b0d2d11f85cd36a5f50e956d152a1b65 Mon Sep 17 00:00:00 2001 From: Dalei Li Date: Tue, 30 Jul 2019 10:51:57 +0200 Subject: [PATCH 1032/1555] update grpc and protobuf compatibility table The compatible protobuf version in newer grpc releases has to be manually inspected. This PR updates it. --- src/php/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/php/README.md b/src/php/README.md index dde6152cfce..0b8727ca864 100644 --- a/src/php/README.md +++ b/src/php/README.md @@ -174,6 +174,16 @@ v1.4.0 | 3.3.0 v1.6.0 | 3.4.0 v1.8.0 | 3.5.0 v1.12.0 | 3.5.2 +v1.13.1 | 3.5.2 +v1.14.2 | 3.5.2 +v1.15.1 | 3.6.1 +v1.16.1 | 3.6.1 +v1.17.2 | 3.6.1 +v1.18.0 | 3.6.1 +v1.19.1 | 3.6.1 +v1.20.1 | 3.7.0 +v1.21.3 | 3.7.0 +v1.22.0 | 3.8.0 If `protoc` hasn't been installed, you can download the `protoc` binaries from [the protocol buffers Github repository](https://github.com/google/protobuf/releases). From 46dddacdf302188ae5f029b471697fcd20c9a1ac Mon Sep 17 00:00:00 2001 From: Christian Maurer Date: Thu, 18 Jul 2019 13:11:18 +0200 Subject: [PATCH 1033/1555] remove all unused-parameter warnings --- .../impl/codegen/async_generic_service.h | 2 +- .../grpcpp/impl/codegen/async_stream_impl.h | 6 +- .../impl/codegen/async_unary_call_impl.h | 8 +- include/grpcpp/impl/codegen/call_op_set.h | 35 ++--- include/grpcpp/impl/codegen/callback_common.h | 4 +- .../grpcpp/impl/codegen/channel_interface.h | 8 +- .../impl/codegen/client_callback_impl.h | 44 +++---- .../grpcpp/impl/codegen/interceptor_common.h | 4 +- .../grpcpp/impl/codegen/method_handler_impl.h | 8 +- .../grpcpp/impl/codegen/rpc_service_method.h | 4 +- .../impl/codegen/server_callback_impl.h | 25 ++-- .../grpcpp/impl/codegen/server_interface.h | 2 +- include/grpcpp/impl/codegen/time.h | 2 +- include/grpcpp/impl/server_builder_plugin.h | 4 +- include/grpcpp/security/credentials_impl.h | 4 +- include/grpcpp/server_impl.h | 8 +- .../grpcpp/support/channel_arguments_impl.h | 2 +- src/compiler/cpp_generator.cc | 85 +++++++------ test/cpp/codegen/compiler_test_golden | 120 +++++++++--------- 19 files changed, 191 insertions(+), 184 deletions(-) diff --git a/include/grpcpp/impl/codegen/async_generic_service.h b/include/grpcpp/impl/codegen/async_generic_service.h index 7c720ce3c23..c7dd5f7d24a 100644 --- a/include/grpcpp/impl/codegen/async_generic_service.h +++ b/include/grpcpp/impl/codegen/async_generic_service.h @@ -100,7 +100,7 @@ class ServerGenericBidiReactor /// Similar to ServerBidiReactor::OnStarted except for argument type. /// /// \param[in] context The context object associated with this RPC. - virtual void OnStarted(GenericServerContext* context) {} + virtual void OnStarted(GenericServerContext* /*context*/) {} private: void OnStarted(::grpc_impl::ServerContext* ctx) final { diff --git a/include/grpcpp/impl/codegen/async_stream_impl.h b/include/grpcpp/impl/codegen/async_stream_impl.h index 633a3d5dd00..4b94c470a52 100644 --- a/include/grpcpp/impl/codegen/async_stream_impl.h +++ b/include/grpcpp/impl/codegen/async_stream_impl.h @@ -197,7 +197,7 @@ template class ClientAsyncReader final : public ClientAsyncReaderInterface { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(ClientAsyncReader)); } @@ -346,7 +346,7 @@ template class ClientAsyncWriter final : public ClientAsyncWriterInterface { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(ClientAsyncWriter)); } @@ -514,7 +514,7 @@ class ClientAsyncReaderWriter final : public ClientAsyncReaderWriterInterface { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(ClientAsyncReaderWriter)); } diff --git a/include/grpcpp/impl/codegen/async_unary_call_impl.h b/include/grpcpp/impl/codegen/async_unary_call_impl.h index ff8bf15602b..e885a077031 100644 --- a/include/grpcpp/impl/codegen/async_unary_call_impl.h +++ b/include/grpcpp/impl/codegen/async_unary_call_impl.h @@ -96,7 +96,7 @@ class ClientAsyncResponseReader final : public ClientAsyncResponseReaderInterface { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(ClientAsyncResponseReader)); } @@ -178,7 +178,7 @@ class ClientAsyncResponseReader final // disable operator new static void* operator new(std::size_t size); - static void* operator new(std::size_t size, void* p) { return p; } + static void* operator new(std::size_t /*size*/, void* p) { return p; } ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, ::grpc::internal::CallOpSendMessage, @@ -303,12 +303,12 @@ namespace std { template class default_delete<::grpc_impl::ClientAsyncResponseReader> { public: - void operator()(void* p) {} + void operator()(void* /*p*/) {} }; template class default_delete<::grpc_impl::ClientAsyncResponseReaderInterface> { public: - void operator()(void* p) {} + void operator()(void* /*p*/) {} }; } // namespace std diff --git a/include/grpcpp/impl/codegen/call_op_set.h b/include/grpcpp/impl/codegen/call_op_set.h index 84d1407cbe2..c062963a13a 100644 --- a/include/grpcpp/impl/codegen/call_op_set.h +++ b/include/grpcpp/impl/codegen/call_op_set.h @@ -206,13 +206,14 @@ namespace internal { template class CallNoOp { protected: - void AddOp(grpc_op* ops, size_t* nops) {} - void FinishOp(bool* status) {} + void AddOp(grpc_op* /*ops*/, size_t* /*nops*/) {} + void FinishOp(bool* /*status*/) {} void SetInterceptionHookPoint( - InterceptorBatchMethodsImpl* interceptor_methods) {} + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} void SetFinishInterceptionHookPoint( - InterceptorBatchMethodsImpl* interceptor_methods) {} - void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) {} + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { + } }; class CallOpSendInitialMetadata { @@ -252,7 +253,7 @@ class CallOpSendInitialMetadata { maybe_compression_level_.level; } } - void FinishOp(bool* status) { + void FinishOp(bool* /*status*/) { if (!send_ || hijacked_) return; g_core_codegen_interface->gpr_free(initial_metadata_); send_ = false; @@ -267,9 +268,9 @@ class CallOpSendInitialMetadata { } void SetFinishInterceptionHookPoint( - InterceptorBatchMethodsImpl* interceptor_methods) {} + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} - void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) { + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { hijacked_ = true; } @@ -363,7 +364,7 @@ class CallOpSendMessage { nullptr); } - void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) { + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { hijacked_ = true; } @@ -605,7 +606,7 @@ class CallOpClientSendClose { op->flags = 0; op->reserved = NULL; } - void FinishOp(bool* status) { send_ = false; } + void FinishOp(bool* /*status*/) { send_ = false; } void SetInterceptionHookPoint( InterceptorBatchMethodsImpl* interceptor_methods) { @@ -615,9 +616,9 @@ class CallOpClientSendClose { } void SetFinishInterceptionHookPoint( - InterceptorBatchMethodsImpl* interceptor_methods) {} + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} - void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) { + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { hijacked_ = true; } @@ -658,7 +659,7 @@ class CallOpServerSendStatus { op->reserved = NULL; } - void FinishOp(bool* status) { + void FinishOp(bool* /*status*/) { if (!send_status_available_ || hijacked_) return; g_core_codegen_interface->gpr_free(trailing_metadata_); send_status_available_ = false; @@ -675,9 +676,9 @@ class CallOpServerSendStatus { } void SetFinishInterceptionHookPoint( - InterceptorBatchMethodsImpl* interceptor_methods) {} + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} - void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) { + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { hijacked_ = true; } @@ -712,7 +713,7 @@ class CallOpRecvInitialMetadata { op->reserved = NULL; } - void FinishOp(bool* status) { + void FinishOp(bool* /*status*/) { if (metadata_map_ == nullptr || hijacked_) return; } @@ -766,7 +767,7 @@ class CallOpClientRecvStatus { op->reserved = NULL; } - void FinishOp(bool* status) { + void FinishOp(bool* /*status*/) { if (recv_status_ == nullptr || hijacked_) return; grpc::string binary_error_details = metadata_map_->GetBinaryErrorDetails(); *recv_status_ = diff --git a/include/grpcpp/impl/codegen/callback_common.h b/include/grpcpp/impl/codegen/callback_common.h index 6170170b978..5adf4596c85 100644 --- a/include/grpcpp/impl/codegen/callback_common.h +++ b/include/grpcpp/impl/codegen/callback_common.h @@ -69,7 +69,7 @@ class CallbackWithStatusTag : public grpc_experimental_completion_queue_functor { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(CallbackWithStatusTag)); } @@ -133,7 +133,7 @@ class CallbackWithSuccessTag : public grpc_experimental_completion_queue_functor { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(CallbackWithSuccessTag)); } diff --git a/include/grpcpp/impl/codegen/channel_interface.h b/include/grpcpp/impl/codegen/channel_interface.h index dd2fe8d687a..06d96abeca4 100644 --- a/include/grpcpp/impl/codegen/channel_interface.h +++ b/include/grpcpp/impl/codegen/channel_interface.h @@ -149,10 +149,10 @@ class ChannelInterface { // Returns an empty Call object (rather than being pure) since this is a new // method and adding a new pure method to an interface would be a breaking // change (even though this is private and non-API) - virtual internal::Call CreateCallInternal(const internal::RpcMethod& method, - ::grpc_impl::ClientContext* context, - ::grpc_impl::CompletionQueue* cq, - size_t interceptor_pos) { + virtual internal::Call CreateCallInternal( + const internal::RpcMethod& /*method*/, + ::grpc_impl::ClientContext* /*context*/, + ::grpc_impl::CompletionQueue* /*cq*/, size_t /*interceptor_pos*/) { return internal::Call(); } diff --git a/include/grpcpp/impl/codegen/client_callback_impl.h b/include/grpcpp/impl/codegen/client_callback_impl.h index 81847bc9e04..37746ef5ce4 100644 --- a/include/grpcpp/impl/codegen/client_callback_impl.h +++ b/include/grpcpp/impl/codegen/client_callback_impl.h @@ -272,7 +272,7 @@ class ClientBidiReactor { /// have completed and provides the RPC status outcome. /// /// \param[in] s The status outcome of this RPC - virtual void OnDone(const ::grpc::Status& s) {} + virtual void OnDone(const ::grpc::Status& /*s*/) {} /// Notifies the application that a read of initial metadata from the /// server is done. If the application chooses not to implement this method, @@ -281,19 +281,19 @@ class ClientBidiReactor { /// /// \param[in] ok Was the initial metadata read successfully? If false, no /// further read-side operation will succeed. - virtual void OnReadInitialMetadataDone(bool ok) {} + virtual void OnReadInitialMetadataDone(bool /*ok*/) {} /// Notifies the application that a StartRead operation completed. /// /// \param[in] ok Was it successful? If false, no further read-side operation /// will succeed. - virtual void OnReadDone(bool ok) {} + virtual void OnReadDone(bool /*ok*/) {} /// Notifies the application that a StartWrite operation completed. /// /// \param[in] ok Was it successful? If false, no further write-side operation /// will succeed. - virtual void OnWriteDone(bool ok) {} + virtual void OnWriteDone(bool /*ok*/) {} /// Notifies the application that a StartWritesDone operation completed. Note /// that this is only used on explicit StartWritesDone operations and not for @@ -301,7 +301,7 @@ class ClientBidiReactor { /// /// \param[in] ok Was it successful? If false, the application will later see /// the failure reflected as a bad status in OnDone. - virtual void OnWritesDoneDone(bool ok) {} + virtual void OnWritesDoneDone(bool /*ok*/) {} private: friend class ClientCallbackReaderWriter; @@ -325,9 +325,9 @@ class ClientReadReactor { void AddMultipleHolds(int holds) { reader_->AddHold(holds); } void RemoveHold() { reader_->RemoveHold(); } - virtual void OnDone(const ::grpc::Status& s) {} - virtual void OnReadInitialMetadataDone(bool ok) {} - virtual void OnReadDone(bool ok) {} + virtual void OnDone(const ::grpc::Status& /*s*/) {} + virtual void OnReadInitialMetadataDone(bool /*ok*/) {} + virtual void OnReadDone(bool /*ok*/) {} private: friend class ClientCallbackReader; @@ -358,10 +358,10 @@ class ClientWriteReactor { void AddMultipleHolds(int holds) { writer_->AddHold(holds); } void RemoveHold() { writer_->RemoveHold(); } - virtual void OnDone(const ::grpc::Status& s) {} - virtual void OnReadInitialMetadataDone(bool ok) {} - virtual void OnWriteDone(bool ok) {} - virtual void OnWritesDoneDone(bool ok) {} + virtual void OnDone(const ::grpc::Status& /*s*/) {} + virtual void OnReadInitialMetadataDone(bool /*ok*/) {} + virtual void OnWriteDone(bool /*ok*/) {} + virtual void OnWritesDoneDone(bool /*ok*/) {} private: friend class ClientCallbackWriter; @@ -385,8 +385,8 @@ class ClientUnaryReactor { virtual ~ClientUnaryReactor() {} void StartCall() { call_->StartCall(); } - virtual void OnDone(const ::grpc::Status& s) {} - virtual void OnReadInitialMetadataDone(bool ok) {} + virtual void OnDone(const ::grpc::Status& /*s*/) {} + virtual void OnReadInitialMetadataDone(bool /*ok*/) {} private: friend class ClientCallbackUnary; @@ -416,7 +416,7 @@ class ClientCallbackReaderWriterImpl : public experimental::ClientCallbackReaderWriter { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(ClientCallbackReaderWriterImpl)); } @@ -490,7 +490,7 @@ class ClientCallbackReaderWriterImpl call_.PerformOps(&writes_done_ops_); } - finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, + finish_tag_.Set(call_.call(), [this](bool /*ok*/) { MaybeFinish(); }, &finish_ops_); finish_ops_.ClientRecvStatus(context_, &finish_status_); finish_ops_.set_core_cq_tag(&finish_tag_); @@ -628,7 +628,7 @@ class ClientCallbackReaderImpl : public experimental::ClientCallbackReader { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(ClientCallbackReaderImpl)); } @@ -682,7 +682,7 @@ class ClientCallbackReaderImpl call_.PerformOps(&read_ops_); } - finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, + finish_tag_.Set(call_.call(), [this](bool /*ok*/) { MaybeFinish(); }, &finish_ops_); finish_ops_.ClientRecvStatus(context_, &finish_status_); finish_ops_.set_core_cq_tag(&finish_tag_); @@ -768,7 +768,7 @@ class ClientCallbackWriterImpl : public experimental::ClientCallbackWriter { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(ClientCallbackWriterImpl)); } @@ -830,7 +830,7 @@ class ClientCallbackWriterImpl call_.PerformOps(&writes_done_ops_); } - finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, + finish_tag_.Set(call_.call(), [this](bool /*ok*/) { MaybeFinish(); }, &finish_ops_); finish_ops_.ClientRecvStatus(context_, &finish_status_); finish_ops_.set_core_cq_tag(&finish_tag_); @@ -956,7 +956,7 @@ class ClientCallbackWriterFactory { class ClientCallbackUnaryImpl final : public experimental::ClientCallbackUnary { public: // always allocated against a call arena, no memory free required - static void operator delete(void* ptr, std::size_t size) { + static void operator delete(void* /*ptr*/, std::size_t size) { assert(size == sizeof(ClientCallbackUnaryImpl)); } @@ -985,7 +985,7 @@ class ClientCallbackUnaryImpl final : public experimental::ClientCallbackUnary { start_ops_.set_core_cq_tag(&start_tag_); call_.PerformOps(&start_ops_); - finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, + finish_tag_.Set(call_.call(), [this](bool /*ok*/) { MaybeFinish(); }, &finish_ops_); finish_ops_.ClientRecvStatus(context_, &finish_status_); finish_ops_.set_core_cq_tag(&finish_tag_); diff --git a/include/grpcpp/impl/codegen/interceptor_common.h b/include/grpcpp/impl/codegen/interceptor_common.h index e7290aca838..01ffe19bc4a 100644 --- a/include/grpcpp/impl/codegen/interceptor_common.h +++ b/include/grpcpp/impl/codegen/interceptor_common.h @@ -465,7 +465,7 @@ class CancelInterceptorBatchMethods return nullptr; } - void ModifySendMessage(const void* message) override { + void ModifySendMessage(const void* /*message*/) override { GPR_CODEGEN_ASSERT( false && "It is illegal to call ModifySendMessage on a method which " @@ -486,7 +486,7 @@ class CancelInterceptorBatchMethods return Status(); } - void ModifySendStatus(const Status& status) override { + void ModifySendStatus(const Status& /*status*/) override { GPR_CODEGEN_ASSERT(false && "It is illegal to call ModifySendStatus on a method " "which has a Cancel notification"); diff --git a/include/grpcpp/impl/codegen/method_handler_impl.h b/include/grpcpp/impl/codegen/method_handler_impl.h index 1903f898ba8..f18a56249a5 100644 --- a/include/grpcpp/impl/codegen/method_handler_impl.h +++ b/include/grpcpp/impl/codegen/method_handler_impl.h @@ -88,7 +88,7 @@ class RpcMethodHandler : public MethodHandler { } void* Deserialize(grpc_call* call, grpc_byte_buffer* req, Status* status, - void** handler_data) final { + void** /*handler_data*/) final { ByteBuffer buf; buf.set_buffer(req); auto* request = new (g_core_codegen_interface->grpc_call_arena_alloc( @@ -193,7 +193,7 @@ class ServerStreamingHandler : public MethodHandler { } void* Deserialize(grpc_call* call, grpc_byte_buffer* req, Status* status, - void** handler_data) final { + void** /*handler_data*/) final { ByteBuffer buf; buf.set_buffer(req); auto* request = new (g_core_codegen_interface->grpc_call_arena_alloc( @@ -328,8 +328,8 @@ class ErrorMethodHandler : public MethodHandler { param.call->cq()->Pluck(&ops); } - void* Deserialize(grpc_call* call, grpc_byte_buffer* req, Status* status, - void** handler_data) final { + void* Deserialize(grpc_call* /*call*/, grpc_byte_buffer* req, + Status* /*status*/, void** /*handler_data*/) final { // We have to destroy any request payload if (req != nullptr) { g_core_codegen_interface->grpc_byte_buffer_destroy(req); diff --git a/include/grpcpp/impl/codegen/rpc_service_method.h b/include/grpcpp/impl/codegen/rpc_service_method.h index 0b16feed820..fb4c32659fc 100644 --- a/include/grpcpp/impl/codegen/rpc_service_method.h +++ b/include/grpcpp/impl/codegen/rpc_service_method.h @@ -76,8 +76,8 @@ class MethodHandler { a HandlerParameter and passed to RunHandler. It is illegal to access the pointer after calling RunHandler. Ownership of the deserialized request is retained by the handler. Returns nullptr if deserialization failed. */ - virtual void* Deserialize(grpc_call* call, grpc_byte_buffer* req, - Status* status, void** handler_data) { + virtual void* Deserialize(grpc_call* /*call*/, grpc_byte_buffer* req, + Status* /*status*/, void** /*handler_data*/) { GPR_CODEGEN_ASSERT(req == nullptr); return nullptr; } diff --git a/include/grpcpp/impl/codegen/server_callback_impl.h b/include/grpcpp/impl/codegen/server_callback_impl.h index 08ecdfd6497..052548c2236 100644 --- a/include/grpcpp/impl/codegen/server_callback_impl.h +++ b/include/grpcpp/impl/codegen/server_callback_impl.h @@ -314,7 +314,7 @@ class ServerBidiReactor : public internal::ServerReactor { /// is a result of the client calling StartCall(). /// /// \param[in] context The context object now associated with this RPC - virtual void OnStarted(::grpc_impl::ServerContext* context) {} + virtual void OnStarted(::grpc_impl::ServerContext* /*context*/) {} /// Notifies the application that an explicit StartSendInitialMetadata /// operation completed. Not used when the sending of initial metadata @@ -322,20 +322,20 @@ class ServerBidiReactor : public internal::ServerReactor { /// /// \param[in] ok Was it successful? If false, no further write-side operation /// will succeed. - virtual void OnSendInitialMetadataDone(bool ok) {} + virtual void OnSendInitialMetadataDone(bool /*ok*/) {} /// Notifies the application that a StartRead operation completed. /// /// \param[in] ok Was it successful? If false, no further read-side operation /// will succeed. - virtual void OnReadDone(bool ok) {} + virtual void OnReadDone(bool /*ok*/) {} /// Notifies the application that a StartWrite (or StartWriteLast) operation /// completed. /// /// \param[in] ok Was it successful? If false, no further write-side operation /// will succeed. - virtual void OnWriteDone(bool ok) {} + virtual void OnWriteDone(bool /*ok*/) {} /// Notifies the application that all operations associated with this RPC /// have completed. This is an override (from the internal base class) but not @@ -376,11 +376,12 @@ class ServerReadReactor : public internal::ServerReactor { /// /// \param[in] context The context object now associated with this RPC /// \param[in] resp The response object to be used by this RPC - virtual void OnStarted(::grpc_impl::ServerContext* context, Response* resp) {} + virtual void OnStarted(::grpc_impl::ServerContext* /*context*/, + Response* /*resp*/) {} /// The following notifications are exactly like ServerBidiReactor. - virtual void OnSendInitialMetadataDone(bool ok) {} - virtual void OnReadDone(bool ok) {} + virtual void OnSendInitialMetadataDone(bool /*ok*/) {} + virtual void OnReadDone(bool /*ok*/) {} void OnDone() override {} void OnCancel() override {} @@ -423,12 +424,12 @@ class ServerWriteReactor : public internal::ServerReactor { /// /// \param[in] context The context object now associated with this RPC /// \param[in] req The request object sent by the client - virtual void OnStarted(::grpc_impl::ServerContext* context, - const Request* req) {} + virtual void OnStarted(::grpc_impl::ServerContext* /*context*/, + const Request* /*req*/) {} /// The following notifications are exactly like ServerBidiReactor. - virtual void OnSendInitialMetadataDone(bool ok) {} - virtual void OnWriteDone(bool ok) {} + virtual void OnSendInitialMetadataDone(bool /*ok*/) {} + virtual void OnWriteDone(bool /*ok*/) {} void OnDone() override {} void OnCancel() override {} @@ -849,7 +850,7 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler { } void* Deserialize(grpc_call* call, grpc_byte_buffer* req, - ::grpc::Status* status, void** handler_data) final { + ::grpc::Status* status, void** /*handler_data*/) final { ::grpc::ByteBuffer buf; buf.set_buffer(req); auto* request = diff --git a/include/grpcpp/impl/codegen/server_interface.h b/include/grpcpp/impl/codegen/server_interface.h index a375d3c0b4c..eb44b632ca0 100644 --- a/include/grpcpp/impl/codegen/server_interface.h +++ b/include/grpcpp/impl/codegen/server_interface.h @@ -130,7 +130,7 @@ class ServerInterface : public internal::CallHook { virtual ~experimental_registration_interface() {} /// May not be abstract since this is a post-1.0 API addition virtual void RegisterCallbackGenericService( - experimental::CallbackGenericService* service) {} + experimental::CallbackGenericService* /*service*/) {} }; /// NOTE: The function experimental_registration() is not stable public API. diff --git a/include/grpcpp/impl/codegen/time.h b/include/grpcpp/impl/codegen/time.h index c32f2544fa9..b3521722e9e 100644 --- a/include/grpcpp/impl/codegen/time.h +++ b/include/grpcpp/impl/codegen/time.h @@ -39,7 +39,7 @@ namespace grpc { template class TimePoint { public: - TimePoint(const T& time) { you_need_a_specialization_of_TimePoint(); } + TimePoint(const T& /*time*/) { you_need_a_specialization_of_TimePoint(); } gpr_timespec raw_time() { gpr_timespec t; return t; diff --git a/include/grpcpp/impl/server_builder_plugin.h b/include/grpcpp/impl/server_builder_plugin.h index 349995c8c1c..203e5465bc3 100644 --- a/include/grpcpp/impl/server_builder_plugin.h +++ b/include/grpcpp/impl/server_builder_plugin.h @@ -42,7 +42,7 @@ class ServerBuilderPlugin { /// UpdateServerBuilder will be called at an early stage in /// ServerBuilder::BuildAndStart(), right after the ServerBuilderOptions have /// done their updates. - virtual void UpdateServerBuilder(grpc_impl::ServerBuilder* builder) {} + virtual void UpdateServerBuilder(grpc_impl::ServerBuilder* /*builder*/) {} /// InitServer will be called in ServerBuilder::BuildAndStart(), after the /// Server instance is created. @@ -57,7 +57,7 @@ class ServerBuilderPlugin { /// UpdateChannelArguments will be called in ServerBuilder::BuildAndStart(), /// before the Server instance is created. - virtual void UpdateChannelArguments(ChannelArguments* args) {} + virtual void UpdateChannelArguments(ChannelArguments* /*args*/) {} virtual bool has_sync_methods() const { return false; } virtual bool has_async_methods() const { return false; } diff --git a/include/grpcpp/security/credentials_impl.h b/include/grpcpp/security/credentials_impl.h index bd79f30ae12..05a74fef0e0 100644 --- a/include/grpcpp/security/credentials_impl.h +++ b/include/grpcpp/security/credentials_impl.h @@ -95,10 +95,10 @@ class ChannelCredentials : private grpc::GrpcLibraryCodegen { // This function should have been a pure virtual function, but it is // implemented as a virtual function so that it does not break API. virtual std::shared_ptr CreateChannelWithInterceptors( - const grpc::string& target, const ChannelArguments& args, + const grpc::string& /*target*/, const ChannelArguments& /*args*/, std::vector> - interceptor_creators) { + /*interceptor_creators*/) { return nullptr; } }; diff --git a/include/grpcpp/server_impl.h b/include/grpcpp/server_impl.h index 52988b50288..390def53719 100644 --- a/include/grpcpp/server_impl.h +++ b/include/grpcpp/server_impl.h @@ -81,16 +81,16 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { public: virtual ~GlobalCallbacks() {} /// Called before server is created. - virtual void UpdateArguments(ChannelArguments* args) {} + virtual void UpdateArguments(ChannelArguments* /*args*/) {} /// Called before application callback for each synchronous server request virtual void PreSynchronousRequest(grpc_impl::ServerContext* context) = 0; /// Called after application callback for each synchronous server request virtual void PostSynchronousRequest(grpc_impl::ServerContext* context) = 0; /// Called before server is started. - virtual void PreServerStart(Server* server) {} + virtual void PreServerStart(Server* /*server*/) {} /// Called after a server port is added. - virtual void AddPort(Server* server, const grpc::string& addr, - grpc::ServerCredentials* creds, int port) {} + virtual void AddPort(Server* /*server*/, const grpc::string& /*addr*/, + grpc::ServerCredentials* /*creds*/, int /*port*/) {} }; /// Set the global callback object. Can only be called once per application. /// Does not take ownership of callbacks, and expects the pointed to object diff --git a/include/grpcpp/support/channel_arguments_impl.h b/include/grpcpp/support/channel_arguments_impl.h index ac3b6c4a7e2..ca3188a9e75 100644 --- a/include/grpcpp/support/channel_arguments_impl.h +++ b/include/grpcpp/support/channel_arguments_impl.h @@ -132,7 +132,7 @@ class ChannelArguments { /// Default pointer argument operations. struct PointerVtableMembers { static void* Copy(void* in) { return in; } - static void Destroy(void* in) {} + static void Destroy(void* /*in*/) {} static int Compare(void* a, void* b) { if (a < b) return -1; if (a > b) return 1; diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index 044647d9a81..a253df8f1bb 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -794,8 +794,8 @@ void PrintHeaderServerAsyncMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "$Response$* response) override {\n" + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); @@ -815,9 +815,9 @@ void PrintHeaderServerAsyncMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReader< $Request$>* reader, " - "$Response$* response) override {\n" + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReader< $Request$>* /*reader*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); @@ -837,8 +837,8 @@ void PrintHeaderServerAsyncMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "::grpc::ServerWriter< $Response$>* writer) override " + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "::grpc::ServerWriter< $Response$>* /*writer*/) override " "{\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" @@ -860,8 +860,8 @@ void PrintHeaderServerAsyncMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReaderWriter< $Response$, $Request$>* stream) " + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReaderWriter< $Response$, $Request$>* /*stream*/) " " override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" @@ -896,7 +896,8 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer, "class WithAsyncMethod_$Method$ : public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service *service) {}\n"); + " void BaseClassMustBeDerivedFromService(const Service * /*service*/) " + "{}\n"); printer->Print(" public:\n"); printer->Indent(); printer->Print(*vars, @@ -923,16 +924,16 @@ void PrintHeaderServerCallbackMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "$Response$* response) override {\n" + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); printer->Print( *vars, "virtual void $Method$(" - "::grpc::ServerContext* context, const $RealRequest$* request, " - "$RealResponse$* response, " + "::grpc::ServerContext* /*context*/, const $RealRequest$* /*request*/, " + "$RealResponse$* /*response*/, " "::grpc::experimental::ServerCallbackRpcController* " "controller) { controller->Finish(::grpc::Status(" "::grpc::StatusCode::UNIMPLEMENTED, \"\")); }\n"); @@ -941,9 +942,9 @@ void PrintHeaderServerCallbackMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReader< $Request$>* reader, " - "$Response$* response) override {\n" + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReader< $Request$>* /*reader*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); @@ -958,8 +959,8 @@ void PrintHeaderServerCallbackMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "::grpc::ServerWriter< $Response$>* writer) override " + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "::grpc::ServerWriter< $Response$>* /*writer*/) override " "{\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" @@ -975,8 +976,8 @@ void PrintHeaderServerCallbackMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReaderWriter< $Response$, $Request$>* stream) " + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReaderWriter< $Response$, $Request$>* /*stream*/) " " override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" @@ -1006,7 +1007,8 @@ void PrintHeaderServerMethodCallback( "class ExperimentalWithCallbackMethod_$Method$ : public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service *service) {}\n"); + " void BaseClassMustBeDerivedFromService(const Service * /*service*/) " + "{}\n"); printer->Print(" public:\n"); printer->Indent(); printer->Print(*vars, "ExperimentalWithCallbackMethod_$Method$() {\n"); @@ -1080,7 +1082,8 @@ void PrintHeaderServerMethodRawCallback( "BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service *service) {}\n"); + " void BaseClassMustBeDerivedFromService(const Service * /*service*/) " + "{}\n"); printer->Print(" public:\n"); printer->Indent(); printer->Print(*vars, "ExperimentalWithRawCallbackMethod_$Method$() {\n"); @@ -1143,7 +1146,7 @@ void PrintHeaderServerMethodStreamedUnary( "public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service *service) " + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " "{}\n"); printer->Print(" public:\n"); printer->Indent(); @@ -1164,8 +1167,8 @@ void PrintHeaderServerMethodStreamedUnary( *vars, "// disable regular version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "$Response$* response) override {\n" + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); @@ -1194,7 +1197,7 @@ void PrintHeaderServerMethodSplitStreaming( "public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service *service) " + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " "{}\n"); printer->Print(" public:\n"); printer->Indent(); @@ -1216,8 +1219,8 @@ void PrintHeaderServerMethodSplitStreaming( *vars, "// disable regular version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "::grpc::ServerWriter< $Response$>* writer) override " + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "::grpc::ServerWriter< $Response$>* /*writer*/) override " "{\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" @@ -1245,7 +1248,8 @@ void PrintHeaderServerMethodGeneric( "class WithGenericMethod_$Method$ : public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service *service) {}\n"); + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " + "{}\n"); printer->Print(" public:\n"); printer->Indent(); printer->Print(*vars, @@ -1261,8 +1265,8 @@ void PrintHeaderServerMethodGeneric( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "$Response$* response) override {\n" + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); @@ -1271,9 +1275,9 @@ void PrintHeaderServerMethodGeneric( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReader< $Request$>* reader, " - "$Response$* response) override {\n" + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReader< $Request$>* /*reader*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); @@ -1282,8 +1286,8 @@ void PrintHeaderServerMethodGeneric( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "::grpc::ServerWriter< $Response$>* writer) override " + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "::grpc::ServerWriter< $Response$>* /*writer*/) override " "{\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" @@ -1293,8 +1297,8 @@ void PrintHeaderServerMethodGeneric( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReaderWriter< $Response$, $Request$>* stream) " + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReaderWriter< $Response$, $Request$>* /*stream*/) " " override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" @@ -1318,7 +1322,8 @@ void PrintHeaderServerMethodRaw(grpc_generator::Printer* printer, printer->Print(*vars, "class WithRawMethod_$Method$ : public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service *service) {}\n"); + " void BaseClassMustBeDerivedFromService(const Service * /*service*/) " + "{}\n"); printer->Print(" public:\n"); printer->Indent(); printer->Print(*vars, diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index 34fb5bfb53f..56ee741e0b2 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -252,7 +252,7 @@ class ServiceA final { template class WithAsyncMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithAsyncMethod_MethodA1() { ::grpc::Service::MarkMethodAsync(0); @@ -261,7 +261,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -272,7 +272,7 @@ class ServiceA final { template class WithAsyncMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithAsyncMethod_MethodA2() { ::grpc::Service::MarkMethodAsync(1); @@ -281,7 +281,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA2(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< ::grpc::testing::Request>* /*reader*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -292,7 +292,7 @@ class ServiceA final { template class WithAsyncMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithAsyncMethod_MethodA3() { ::grpc::Service::MarkMethodAsync(2); @@ -301,7 +301,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override { + ::grpc::Status MethodA3(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::ServerWriter< ::grpc::testing::Response>* /*writer*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -312,7 +312,7 @@ class ServiceA final { template class WithAsyncMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithAsyncMethod_MethodA4() { ::grpc::Service::MarkMethodAsync(3); @@ -321,7 +321,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override { + ::grpc::Status MethodA4(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* /*stream*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -333,7 +333,7 @@ class ServiceA final { template class ExperimentalWithCallbackMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithCallbackMethod_MethodA1() { ::grpc::Service::experimental().MarkMethodCallback(0, @@ -355,16 +355,16 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - virtual void MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } + virtual void MethodA1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } }; template class ExperimentalWithCallbackMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithCallbackMethod_MethodA2() { ::grpc::Service::experimental().MarkMethodCallback(1, @@ -375,7 +375,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA2(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< ::grpc::testing::Request>* /*reader*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -386,7 +386,7 @@ class ServiceA final { template class ExperimentalWithCallbackMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithCallbackMethod_MethodA3() { ::grpc::Service::experimental().MarkMethodCallback(2, @@ -397,7 +397,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override { + ::grpc::Status MethodA3(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::ServerWriter< ::grpc::testing::Response>* /*writer*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -408,7 +408,7 @@ class ServiceA final { template class ExperimentalWithCallbackMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithCallbackMethod_MethodA4() { ::grpc::Service::experimental().MarkMethodCallback(3, @@ -419,7 +419,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override { + ::grpc::Status MethodA4(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* /*stream*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -431,7 +431,7 @@ class ServiceA final { template class WithGenericMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_MethodA1() { ::grpc::Service::MarkMethodGeneric(0); @@ -440,7 +440,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -448,7 +448,7 @@ class ServiceA final { template class WithGenericMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_MethodA2() { ::grpc::Service::MarkMethodGeneric(1); @@ -457,7 +457,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA2(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< ::grpc::testing::Request>* /*reader*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -465,7 +465,7 @@ class ServiceA final { template class WithGenericMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_MethodA3() { ::grpc::Service::MarkMethodGeneric(2); @@ -474,7 +474,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override { + ::grpc::Status MethodA3(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::ServerWriter< ::grpc::testing::Response>* /*writer*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -482,7 +482,7 @@ class ServiceA final { template class WithGenericMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_MethodA4() { ::grpc::Service::MarkMethodGeneric(3); @@ -491,7 +491,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override { + ::grpc::Status MethodA4(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* /*stream*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -499,7 +499,7 @@ class ServiceA final { template class WithRawMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithRawMethod_MethodA1() { ::grpc::Service::MarkMethodRaw(0); @@ -508,7 +508,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -519,7 +519,7 @@ class ServiceA final { template class WithRawMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithRawMethod_MethodA2() { ::grpc::Service::MarkMethodRaw(1); @@ -528,7 +528,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA2(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< ::grpc::testing::Request>* /*reader*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -539,7 +539,7 @@ class ServiceA final { template class WithRawMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithRawMethod_MethodA3() { ::grpc::Service::MarkMethodRaw(2); @@ -548,7 +548,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override { + ::grpc::Status MethodA3(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::ServerWriter< ::grpc::testing::Response>* /*writer*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -559,7 +559,7 @@ class ServiceA final { template class WithRawMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithRawMethod_MethodA4() { ::grpc::Service::MarkMethodRaw(3); @@ -568,7 +568,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override { + ::grpc::Status MethodA4(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* /*stream*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -579,7 +579,7 @@ class ServiceA final { template class ExperimentalWithRawCallbackMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodA1() { ::grpc::Service::experimental().MarkMethodRawCallback(0, @@ -595,16 +595,16 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - virtual void MethodA1(::grpc::ServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } + virtual void MethodA1(::grpc::ServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } }; template class ExperimentalWithRawCallbackMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodA2() { ::grpc::Service::experimental().MarkMethodRawCallback(1, @@ -615,7 +615,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA2(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< ::grpc::testing::Request>* /*reader*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -626,7 +626,7 @@ class ServiceA final { template class ExperimentalWithRawCallbackMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodA3() { ::grpc::Service::experimental().MarkMethodRawCallback(2, @@ -637,7 +637,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override { + ::grpc::Status MethodA3(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::ServerWriter< ::grpc::testing::Response>* /*writer*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -648,7 +648,7 @@ class ServiceA final { template class ExperimentalWithRawCallbackMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodA4() { ::grpc::Service::experimental().MarkMethodRawCallback(3, @@ -659,7 +659,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override { + ::grpc::Status MethodA4(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* /*stream*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -670,7 +670,7 @@ class ServiceA final { template class WithStreamedUnaryMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithStreamedUnaryMethod_MethodA1() { ::grpc::Service::MarkMethodStreamed(0, @@ -680,7 +680,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable regular version of this method - ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -691,7 +691,7 @@ class ServiceA final { template class WithSplitStreamingMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithSplitStreamingMethod_MethodA3() { ::grpc::Service::MarkMethodStreamed(2, @@ -701,7 +701,7 @@ class ServiceA final { BaseClassMustBeDerivedFromService(this); } // disable regular version of this method - ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override { + ::grpc::Status MethodA3(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::ServerWriter< ::grpc::testing::Response>* /*writer*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -790,7 +790,7 @@ class ServiceB final { template class WithAsyncMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithAsyncMethod_MethodB1() { ::grpc::Service::MarkMethodAsync(0); @@ -799,7 +799,7 @@ class ServiceB final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodB1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -811,7 +811,7 @@ class ServiceB final { template class ExperimentalWithCallbackMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithCallbackMethod_MethodB1() { ::grpc::Service::experimental().MarkMethodCallback(0, @@ -833,17 +833,17 @@ class ServiceB final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodB1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - virtual void MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } + virtual void MethodB1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } }; typedef ExperimentalWithCallbackMethod_MethodB1 ExperimentalCallbackService; template class WithGenericMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_MethodB1() { ::grpc::Service::MarkMethodGeneric(0); @@ -852,7 +852,7 @@ class ServiceB final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodB1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -860,7 +860,7 @@ class ServiceB final { template class WithRawMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: WithRawMethod_MethodB1() { ::grpc::Service::MarkMethodRaw(0); @@ -869,7 +869,7 @@ class ServiceB final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodB1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -880,7 +880,7 @@ class ServiceB final { template class ExperimentalWithRawCallbackMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodB1() { ::grpc::Service::experimental().MarkMethodRawCallback(0, @@ -896,16 +896,16 @@ class ServiceB final { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodB1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - virtual void MethodB1(::grpc::ServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } + virtual void MethodB1(::grpc::ServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } }; template class WithStreamedUnaryMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithStreamedUnaryMethod_MethodB1() { ::grpc::Service::MarkMethodStreamed(0, @@ -915,7 +915,7 @@ class ServiceB final { BaseClassMustBeDerivedFromService(this); } // disable regular version of this method - ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodB1(::grpc::ServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } From f0b53e1f1bb59a26efc1da4ba98b52232a9ee6de Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 30 Jul 2019 10:33:34 -0700 Subject: [PATCH 1034/1555] set C# major version to 2, adjust expand_version.py --- build.yaml | 1 + .../Grpc.Core.Api/VersionInfo.cs.template | 4 ++-- tools/buildgen/plugins/expand_version.py | 24 +++++++++++-------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/build.yaml b/build.yaml index e6d9ccac886..999c761056f 100644 --- a/build.yaml +++ b/build.yaml @@ -13,6 +13,7 @@ settings: '#09': Per-language overrides are possible with (eg) ruby_version tag here '#10': See the expand_version.py for all the quirks here core_version: 7.0.0 + csharp_major_version: 2 g_stands_for: gangnam version: 1.23.0-dev filegroups: diff --git a/templates/src/csharp/Grpc.Core.Api/VersionInfo.cs.template b/templates/src/csharp/Grpc.Core.Api/VersionInfo.cs.template index e94f8c296b6..a9b59a227fe 100644 --- a/templates/src/csharp/Grpc.Core.Api/VersionInfo.cs.template +++ b/templates/src/csharp/Grpc.Core.Api/VersionInfo.cs.template @@ -30,12 +30,12 @@ /// /// Current AssemblyVersion attribute of gRPC C# assemblies /// - public const string CurrentAssemblyVersion = "1.0.0.0"; + public const string CurrentAssemblyVersion = "${settings.csharp_version.major}.0.0.0"; /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "${settings.version.major}.${settings.version.minor}.${settings.version.patch}.0"; + public const string CurrentAssemblyFileVersion = "${settings.csharp_version.major}.${settings.csharp_version.minor}.${settings.csharp_version.patch}.0"; /// /// Current version of gRPC C# diff --git a/tools/buildgen/plugins/expand_version.py b/tools/buildgen/plugins/expand_version.py index a73446940da..02615f841fe 100755 --- a/tools/buildgen/plugins/expand_version.py +++ b/tools/buildgen/plugins/expand_version.py @@ -34,18 +34,20 @@ LANGUAGES = [ class Version: - def __init__(self, s): + def __init__(self, version_str, override_major=None): self.tag = None - if '-' in s: - s, self.tag = s.split('-') - self.major, self.minor, self.patch = [int(x) for x in s.split('.')] + if '-' in version_str: + version_str, self.tag = version_str.split('-') + self.major, self.minor, self.patch = [int(x) for x in version_str.split('.')] + if override_major: + self.major = override_major def __str__(self): """Version string in a somewhat idiomatic style for most languages""" - s = '%d.%d.%d' % (self.major, self.minor, self.patch) + version_str = '%d.%d.%d' % (self.major, self.minor, self.patch) if self.tag: - s += '-%s' % self.tag - return s + version_str += '-%s' % self.tag + return version_str def pep440(self): """Version string in Python PEP440 style""" @@ -105,11 +107,13 @@ def mako_plugin(dictionary): """ settings = dictionary['settings'] - master_version = Version(settings['version']) + version_str = settings['version'] + master_version = Version(version_str) settings['version'] = master_version for language in LANGUAGES: version_tag = '%s_version' % language + override_major = settings.get('%s_major_version' % language, None) if version_tag in settings: - settings[version_tag] = Version(settings[version_tag]) + settings[version_tag] = Version(settings[version_tag], override_major=override_major) else: - settings[version_tag] = master_version + settings[version_tag] = Version(version_str, override_major=override_major) From 2b0ff8619cb1cdd1def687c4e3713caa5480b52d Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 30 Jul 2019 10:35:19 -0700 Subject: [PATCH 1035/1555] regenerate projects --- Makefile | 10 +++++----- src/csharp/Grpc.Core.Api/VersionInfo.cs | 6 +++--- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 5457f698a64..0107f145204 100644 --- a/Makefile +++ b/Makefile @@ -462,7 +462,7 @@ endif CORE_VERSION = 7.0.0 CPP_VERSION = 1.23.0-dev -CSHARP_VERSION = 1.23.0-dev +CSHARP_VERSION = 2.23.0-dev CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) @@ -512,7 +512,7 @@ SHARED_EXT_CSHARP = dll SHARED_PREFIX = SHARED_VERSION_CORE = -7 SHARED_VERSION_CPP = -1 -SHARED_VERSION_CSHARP = -1 +SHARED_VERSION_CSHARP = -2 else ifeq ($(SYSTEM),Darwin) EXECUTABLE_SUFFIX = SHARED_EXT_CORE = dylib @@ -3200,7 +3200,7 @@ install-shared_csharp: shared_csharp strip-shared_csharp ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP)-dll.a $(prefix)/lib/libgrpc_csharp_ext.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(prefix)/lib/libgrpc_csharp_ext.so.1 + $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(prefix)/lib/libgrpc_csharp_ext.so.2 $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(prefix)/lib/libgrpc_csharp_ext.so endif ifneq ($(SYSTEM),MINGW32) @@ -7502,8 +7502,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHA ifeq ($(SYSTEM),Darwin) $(Q) $(LD) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_csharp_ext.so.1 -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).so.1 + $(Q) $(LD) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_csharp_ext.so.2 -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).so.2 $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).so endif endif diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index 6469aeb3f4b..d84da7c9e2f 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -28,16 +28,16 @@ namespace Grpc.Core /// /// Current AssemblyVersion attribute of gRPC C# assemblies /// - public const string CurrentAssemblyVersion = "1.0.0.0"; + public const string CurrentAssemblyVersion = "2.0.0.0"; /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "1.23.0.0"; + public const string CurrentAssemblyFileVersion = "2.23.0.0"; /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.23.0-dev"; + public const string CurrentVersion = "2.23.0-dev"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index a91b5e19414..4f100873bc7 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 1.23.0-dev + 2.23.0-dev 3.8.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index 06552e8464b..a40eddddf2e 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=1.23.0-dev +set VERSION=2.23.0-dev @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe From 47a14ba3948d53993ad2120077e60efb703da43a Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 22 Jul 2019 13:34:50 +0200 Subject: [PATCH 1036/1555] move ChannelCredentials to Grpc.Core.Api --- src/csharp/Grpc.Core.Api/CallCredentials.cs | 4 +- .../ChannelCredentials.cs | 126 +++++------------ .../ChannelCredentialsConfiguratorBase.cs | 44 ++++++ .../KeyCertificatePair.cs | 0 .../VerifyPeerContext.cs | 0 .../Grpc.Core.Tests/ChannelCredentialsTest.cs | 14 +- src/csharp/Grpc.Core.Tests/FakeCredentials.cs | 4 +- src/csharp/Grpc.Core/Channel.cs | 2 +- src/csharp/Grpc.Core/ForwardedTypes.cs | 4 + .../DefaultChannelCredentialsConfigurator.cs | 130 ++++++++++++++++++ 10 files changed, 226 insertions(+), 102 deletions(-) rename src/csharp/{Grpc.Core => Grpc.Core.Api}/ChannelCredentials.cs (64%) create mode 100644 src/csharp/Grpc.Core.Api/ChannelCredentialsConfiguratorBase.cs rename src/csharp/{Grpc.Core => Grpc.Core.Api}/KeyCertificatePair.cs (100%) rename src/csharp/{Grpc.Core => Grpc.Core.Api}/VerifyPeerContext.cs (100%) create mode 100644 src/csharp/Grpc.Core/Internal/DefaultChannelCredentialsConfigurator.cs diff --git a/src/csharp/Grpc.Core.Api/CallCredentials.cs b/src/csharp/Grpc.Core.Api/CallCredentials.cs index 6344a881070..3b150a211c2 100644 --- a/src/csharp/Grpc.Core.Api/CallCredentials.cs +++ b/src/csharp/Grpc.Core.Api/CallCredentials.cs @@ -51,8 +51,8 @@ namespace Grpc.Core } /// - /// Populates this call credential instances. - /// You never need to invoke this, part of internal implementation. + /// Populates call credentials configurator with this instance's configuration. + /// End users never need to invoke this method as it is part of internal implementation. /// public abstract void InternalPopulateConfiguration(CallCredentialsConfiguratorBase configurator, object state); diff --git a/src/csharp/Grpc.Core/ChannelCredentials.cs b/src/csharp/Grpc.Core.Api/ChannelCredentials.cs similarity index 64% rename from src/csharp/Grpc.Core/ChannelCredentials.cs rename to src/csharp/Grpc.Core.Api/ChannelCredentials.cs index dcbe9f3599b..10020a3d8d4 100644 --- a/src/csharp/Grpc.Core/ChannelCredentials.cs +++ b/src/csharp/Grpc.Core.Api/ChannelCredentials.cs @@ -18,11 +18,9 @@ using System; using System.Collections.Generic; -using System.Runtime.InteropServices; using System.Threading.Tasks; using Grpc.Core.Internal; -using Grpc.Core.Logging; using Grpc.Core.Utils; namespace Grpc.Core @@ -33,7 +31,9 @@ namespace Grpc.Core public abstract class ChannelCredentials { static readonly ChannelCredentials InsecureInstance = new InsecureCredentialsImpl(); - readonly Lazy cachedNativeCredentials; + + // TODO: caching the instance!!!! + //readonly Lazy cachedNativeCredentials; /// /// Creates a new instance of channel credentials @@ -44,7 +44,7 @@ namespace Grpc.Core // with secure connections. See https://github.com/grpc/grpc/issues/15207. // We rely on finalizer to clean up the native portion of ChannelCredentialsSafeHandle after the ChannelCredentials // instance becomes unused. - this.cachedNativeCredentials = new Lazy(() => CreateNativeCredentials()); + //this.cachedNativeCredentials = new Lazy(() => CreateNativeCredentials()); } /// @@ -72,36 +72,39 @@ namespace Grpc.Core } /// - /// Gets native object for the credentials, creating one if it already doesn't exist. May return null if insecure channel - /// should be created. Caller must not call Dispose() on the returned native credentials as their lifetime - /// is managed by this class (and instances of native credentials are cached). + /// Populates channel credentials configurator with this instance's configuration. + /// End users never need to invoke this method as it is part of internal implementation. /// - /// The native credentials. - internal ChannelCredentialsSafeHandle GetNativeCredentials() - { - return cachedNativeCredentials.Value; - } + public abstract void InternalPopulateConfiguration(ChannelCredentialsConfiguratorBase configurator, object state); - /// - /// Creates a new native object for the credentials. May return null if insecure channel - /// should be created. For internal use only, use instead. - /// - /// The native credentials. - internal abstract ChannelCredentialsSafeHandle CreateNativeCredentials(); + // / + // / Gets native object for the credentials, creating one if it already doesn't exist. May return null if insecure channel + // / should be created. Caller must not call Dispose() on the returned native credentials as their lifetime + // / is managed by this class (and instances of native credentials are cached). + // / + // / The native credentials. + //internal ChannelCredentialsSafeHandle GetNativeCredentials() + //{ + // return cachedNativeCredentials.Value; + //} + + // / + // / Creates a new native object for the credentials. May return null if insecure channel + // / should be created. For internal use only, use instead. + // / + // / The native credentials. + //internal abstract ChannelCredentialsSafeHandle CreateNativeCredentials(); /// /// Returns true if this credential type allows being composed by CompositeCredentials. /// - internal virtual bool IsComposable - { - get { return false; } - } + internal virtual bool IsComposable => false; private sealed class InsecureCredentialsImpl : ChannelCredentials { - internal override ChannelCredentialsSafeHandle CreateNativeCredentials() + public override void InternalPopulateConfiguration(ChannelCredentialsConfiguratorBase configurator, object state) { - return null; + configurator.SetInsecureCredentials(state); } } } @@ -126,8 +129,6 @@ namespace Grpc.Core /// public sealed class SslCredentials : ChannelCredentials { - static readonly ILogger Logger = GrpcEnvironment.Logger.ForType(); - readonly string rootCertificates; readonly KeyCertificatePair keyCertificatePair; readonly VerifyPeerCallback verifyPeerCallback; @@ -196,63 +197,16 @@ namespace Grpc.Core } } - // Composing composite makes no sense. - internal override bool IsComposable + /// + /// Populates channel credentials configurator with this instance's configuration. + /// End users never need to invoke this method as it is part of internal implementation. + /// + public override void InternalPopulateConfiguration(ChannelCredentialsConfiguratorBase configurator, object state) { - get { return true; } + configurator.SetSslCredentials(state, rootCertificates, keyCertificatePair, verifyPeerCallback); } - internal override ChannelCredentialsSafeHandle CreateNativeCredentials() - { - IntPtr verifyPeerCallbackTag = IntPtr.Zero; - if (verifyPeerCallback != null) - { - verifyPeerCallbackTag = new VerifyPeerCallbackRegistration(verifyPeerCallback).CallbackRegistration.Tag; - } - return ChannelCredentialsSafeHandle.CreateSslCredentials(rootCertificates, keyCertificatePair, verifyPeerCallbackTag); - } - - private class VerifyPeerCallbackRegistration - { - readonly VerifyPeerCallback verifyPeerCallback; - readonly NativeCallbackRegistration callbackRegistration; - - public VerifyPeerCallbackRegistration(VerifyPeerCallback verifyPeerCallback) - { - this.verifyPeerCallback = verifyPeerCallback; - this.callbackRegistration = NativeCallbackDispatcher.RegisterCallback(HandleUniversalCallback); - } - - public NativeCallbackRegistration CallbackRegistration => callbackRegistration; - - private int HandleUniversalCallback(IntPtr arg0, IntPtr arg1, IntPtr arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5) - { - return VerifyPeerCallbackHandler(arg0, arg1, arg2 != IntPtr.Zero); - } - - private int VerifyPeerCallbackHandler(IntPtr targetName, IntPtr peerPem, bool isDestroy) - { - if (isDestroy) - { - this.callbackRegistration.Dispose(); - return 0; - } - - try - { - var context = new VerifyPeerContext(Marshal.PtrToStringAnsi(targetName), Marshal.PtrToStringAnsi(peerPem)); - - return this.verifyPeerCallback(context) ? 0 : 1; - } - catch (Exception e) - { - // eat the exception, we must not throw when inside callback from native code. - Logger.Error(e, "Exception occurred while invoking verify peer callback handler."); - // Return validation failure in case of exception. - return 1; - } - } - } + internal override bool IsComposable => true; } /// @@ -277,17 +231,9 @@ namespace Grpc.Core GrpcPreconditions.CheckArgument(channelCredentials.IsComposable, "Supplied channel credentials do not allow composition."); } - internal override ChannelCredentialsSafeHandle CreateNativeCredentials() + public override void InternalPopulateConfiguration(ChannelCredentialsConfiguratorBase configurator, object state) { - using (var callCreds = callCredentials.ToNativeCredentials()) - { - var nativeComposite = ChannelCredentialsSafeHandle.CreateComposite(channelCredentials.GetNativeCredentials(), callCreds); - if (nativeComposite.IsInvalid) - { - throw new ArgumentException("Error creating native composite credentials. Likely, this is because you are trying to compose incompatible credentials."); - } - return nativeComposite; - } + configurator.SetCompositeCredentials(state, channelCredentials, callCredentials); } } } diff --git a/src/csharp/Grpc.Core.Api/ChannelCredentialsConfiguratorBase.cs b/src/csharp/Grpc.Core.Api/ChannelCredentialsConfiguratorBase.cs new file mode 100644 index 00000000000..5c779bc66b4 --- /dev/null +++ b/src/csharp/Grpc.Core.Api/ChannelCredentialsConfiguratorBase.cs @@ -0,0 +1,44 @@ +#region Copyright notice and license + +// Copyright 2019 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System.Collections.Generic; + +namespace Grpc.Core +{ + /// + /// Base class for objects that can consume configuration from CallCredentials objects. + /// Note: experimental API that can change or be removed without any prior notice. + /// + public abstract class ChannelCredentialsConfiguratorBase + { + /// + /// Configures the credentials to use insecure credentials. + /// + public abstract void SetInsecureCredentials(object state); + + /// + /// Configures the credentials to use SslCredentials. + /// + public abstract void SetSslCredentials(object state, string rootCertificates, KeyCertificatePair keyCertificatePair, VerifyPeerCallback verifyPeerCallback); + + /// + /// Configures the credentials to use composite channel credentials (a composite of channel credentials and call credentials). + /// + public abstract void SetCompositeCredentials(object state, ChannelCredentials channelCredentials, CallCredentials callCredentials); + } +} diff --git a/src/csharp/Grpc.Core/KeyCertificatePair.cs b/src/csharp/Grpc.Core.Api/KeyCertificatePair.cs similarity index 100% rename from src/csharp/Grpc.Core/KeyCertificatePair.cs rename to src/csharp/Grpc.Core.Api/KeyCertificatePair.cs diff --git a/src/csharp/Grpc.Core/VerifyPeerContext.cs b/src/csharp/Grpc.Core.Api/VerifyPeerContext.cs similarity index 100% rename from src/csharp/Grpc.Core/VerifyPeerContext.cs rename to src/csharp/Grpc.Core.Api/VerifyPeerContext.cs diff --git a/src/csharp/Grpc.Core.Tests/ChannelCredentialsTest.cs b/src/csharp/Grpc.Core.Tests/ChannelCredentialsTest.cs index 843d88bfb6a..fd50ce4f064 100644 --- a/src/csharp/Grpc.Core.Tests/ChannelCredentialsTest.cs +++ b/src/csharp/Grpc.Core.Tests/ChannelCredentialsTest.cs @@ -48,25 +48,25 @@ namespace Grpc.Core.Tests { // always returning the same native object is critical for subchannel sharing to work with secure channels var creds = new SslCredentials(); - var nativeCreds1 = creds.GetNativeCredentials(); - var nativeCreds2 = creds.GetNativeCredentials(); + var nativeCreds1 = creds.ToNativeCredentials(); + var nativeCreds2 = creds.ToNativeCredentials(); Assert.AreSame(nativeCreds1, nativeCreds2); } [Test] public void ChannelCredentials_CreateExceptionIsCached() { - var creds = new ChannelCredentialsWithCreateNativeThrows(); - var ex1 = Assert.Throws(typeof(Exception), () => creds.GetNativeCredentials()); - var ex2 = Assert.Throws(typeof(Exception), () => creds.GetNativeCredentials()); + var creds = new ChannelCredentialsWithPopulateConfigurationThrows(); + var ex1 = Assert.Throws(typeof(Exception), () => creds.ToNativeCredentials()); + var ex2 = Assert.Throws(typeof(Exception), () => creds.ToNativeCredentials()); Assert.AreSame(ex1, ex2); } - internal class ChannelCredentialsWithCreateNativeThrows : ChannelCredentials + internal class ChannelCredentialsWithPopulateConfigurationThrows : ChannelCredentials { internal override bool IsComposable => false; - internal override ChannelCredentialsSafeHandle CreateNativeCredentials() + public override void InternalPopulateConfiguration(ChannelCredentialsConfiguratorBase configurator, object state) { throw new Exception("Creation of native credentials has failed on purpose."); } diff --git a/src/csharp/Grpc.Core.Tests/FakeCredentials.cs b/src/csharp/Grpc.Core.Tests/FakeCredentials.cs index 59587b9a510..e38e0e136cc 100644 --- a/src/csharp/Grpc.Core.Tests/FakeCredentials.cs +++ b/src/csharp/Grpc.Core.Tests/FakeCredentials.cs @@ -34,9 +34,9 @@ namespace Grpc.Core.Tests get { return composable; } } - internal override ChannelCredentialsSafeHandle CreateNativeCredentials() + public override void InternalPopulateConfiguration(ChannelCredentialsConfiguratorBase configurator, object state) { - return null; + // not invoking configuration on purpose } } diff --git a/src/csharp/Grpc.Core/Channel.cs b/src/csharp/Grpc.Core/Channel.cs index fb58c077c70..8d1fb921ff4 100644 --- a/src/csharp/Grpc.Core/Channel.cs +++ b/src/csharp/Grpc.Core/Channel.cs @@ -72,7 +72,7 @@ namespace Grpc.Core this.completionQueue = this.environment.PickCompletionQueue(); using (var nativeChannelArgs = ChannelOptions.CreateChannelArgs(this.options.Values)) { - var nativeCredentials = credentials.GetNativeCredentials(); + var nativeCredentials = credentials.ToNativeCredentials(); if (nativeCredentials != null) { this.handle = ChannelSafeHandle.CreateSecure(nativeCredentials, target, nativeChannelArgs); diff --git a/src/csharp/Grpc.Core/ForwardedTypes.cs b/src/csharp/Grpc.Core/ForwardedTypes.cs index ad30814eb70..f860545a9a2 100644 --- a/src/csharp/Grpc.Core/ForwardedTypes.cs +++ b/src/csharp/Grpc.Core/ForwardedTypes.cs @@ -40,6 +40,7 @@ using Grpc.Core.Utils; [assembly:TypeForwardedToAttribute(typeof(CallOptions))] [assembly:TypeForwardedToAttribute(typeof(ClientBase))] [assembly:TypeForwardedToAttribute(typeof(ClientBase<>))] +[assembly:TypeForwardedToAttribute(typeof(ChannelCredentials))] [assembly:TypeForwardedToAttribute(typeof(ClientInterceptorContext<,>))] [assembly:TypeForwardedToAttribute(typeof(ContextPropagationOptions))] [assembly:TypeForwardedToAttribute(typeof(ContextPropagationToken))] @@ -50,6 +51,7 @@ using Grpc.Core.Utils; [assembly:TypeForwardedToAttribute(typeof(Interceptor))] [assembly:TypeForwardedToAttribute(typeof(InterceptingCallInvoker))] [assembly:TypeForwardedToAttribute(typeof(IServerStreamWriter<>))] +[assembly:TypeForwardedToAttribute(typeof(KeyCertificatePair))] [assembly:TypeForwardedToAttribute(typeof(Marshaller<>))] [assembly:TypeForwardedToAttribute(typeof(Marshallers))] [assembly:TypeForwardedToAttribute(typeof(Metadata))] @@ -65,8 +67,10 @@ using Grpc.Core.Utils; [assembly:TypeForwardedToAttribute(typeof(DuplexStreamingServerMethod<,>))] [assembly:TypeForwardedToAttribute(typeof(ServerServiceDefinition))] [assembly:TypeForwardedToAttribute(typeof(ServiceBinderBase))] +[assembly:TypeForwardedToAttribute(typeof(SslCredentials))] [assembly:TypeForwardedToAttribute(typeof(Status))] [assembly:TypeForwardedToAttribute(typeof(StatusCode))] +[assembly:TypeForwardedToAttribute(typeof(VerifyPeerContext))] [assembly:TypeForwardedToAttribute(typeof(VersionInfo))] [assembly:TypeForwardedToAttribute(typeof(WriteOptions))] [assembly:TypeForwardedToAttribute(typeof(WriteFlags))] diff --git a/src/csharp/Grpc.Core/Internal/DefaultChannelCredentialsConfigurator.cs b/src/csharp/Grpc.Core/Internal/DefaultChannelCredentialsConfigurator.cs new file mode 100644 index 00000000000..8b9e1758598 --- /dev/null +++ b/src/csharp/Grpc.Core/Internal/DefaultChannelCredentialsConfigurator.cs @@ -0,0 +1,130 @@ +#region Copyright notice and license + +// Copyright 2019 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using Grpc.Core.Utils; +using Grpc.Core.Logging; + +namespace Grpc.Core.Internal +{ + /// + /// Creates native call credential objects from instances of ChannelCredentials. + /// + internal class DefaultChannelCredentialsConfigurator : ChannelCredentialsConfiguratorBase + { + static readonly ILogger Logger = GrpcEnvironment.Logger.ForType(); + + bool configured; + ChannelCredentialsSafeHandle nativeCredentials; + + public ChannelCredentialsSafeHandle NativeCredentials => nativeCredentials; + + public override void SetInsecureCredentials(object state) + { + GrpcPreconditions.CheckState(!configured); + // null corresponds to insecure credentials. + configured = true; + nativeCredentials = null; + } + + public override void SetSslCredentials(object state, string rootCertificates, KeyCertificatePair keyCertificatePair, VerifyPeerCallback verifyPeerCallback) + { + GrpcPreconditions.CheckState(!configured); + configured = true; + IntPtr verifyPeerCallbackTag = IntPtr.Zero; + if (verifyPeerCallback != null) + { + verifyPeerCallbackTag = new VerifyPeerCallbackRegistration(verifyPeerCallback).CallbackRegistration.Tag; + } + nativeCredentials = ChannelCredentialsSafeHandle.CreateSslCredentials(rootCertificates, keyCertificatePair, verifyPeerCallbackTag); + } + + public override void SetCompositeCredentials(object state, ChannelCredentials channelCredentials, CallCredentials callCredentials) + { + GrpcPreconditions.CheckState(!configured); + configured = true; + using (var callCreds = callCredentials.ToNativeCredentials()) + { + var nativeComposite = ChannelCredentialsSafeHandle.CreateComposite(channelCredentials.ToNativeCredentials(), callCreds); + if (nativeComposite.IsInvalid) + { + throw new ArgumentException("Error creating native composite credentials. Likely, this is because you are trying to compose incompatible credentials."); + } + nativeCredentials = nativeComposite; + } + } + + private class VerifyPeerCallbackRegistration + { + readonly VerifyPeerCallback verifyPeerCallback; + readonly NativeCallbackRegistration callbackRegistration; + + public VerifyPeerCallbackRegistration(VerifyPeerCallback verifyPeerCallback) + { + this.verifyPeerCallback = verifyPeerCallback; + this.callbackRegistration = NativeCallbackDispatcher.RegisterCallback(HandleUniversalCallback); + } + + public NativeCallbackRegistration CallbackRegistration => callbackRegistration; + + private int HandleUniversalCallback(IntPtr arg0, IntPtr arg1, IntPtr arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5) + { + return VerifyPeerCallbackHandler(arg0, arg1, arg2 != IntPtr.Zero); + } + + private int VerifyPeerCallbackHandler(IntPtr targetName, IntPtr peerPem, bool isDestroy) + { + if (isDestroy) + { + this.callbackRegistration.Dispose(); + return 0; + } + + try + { + var context = new VerifyPeerContext(Marshal.PtrToStringAnsi(targetName), Marshal.PtrToStringAnsi(peerPem)); + + return this.verifyPeerCallback(context) ? 0 : 1; + } + catch (Exception e) + { + // eat the exception, we must not throw when inside callback from native code. + Logger.Error(e, "Exception occurred while invoking verify peer callback handler."); + // Return validation failure in case of exception. + return 1; + } + } + } + } + + internal static class ChannelCredentialsExtensions + { + /// + /// Creates native object for the credentials. + /// + /// The native credentials. + public static ChannelCredentialsSafeHandle ToNativeCredentials(this ChannelCredentials credentials) + { + var configurator = new DefaultChannelCredentialsConfigurator(); + credentials.InternalPopulateConfiguration(configurator, credentials); + return configurator.NativeCredentials; + } + } +} From 1a34d0c12890f0b08fc3b0cc86781c28856b91de Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 22 Jul 2019 13:47:26 +0200 Subject: [PATCH 1037/1555] more forwards --- src/csharp/Grpc.Core/ForwardedTypes.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/csharp/Grpc.Core/ForwardedTypes.cs b/src/csharp/Grpc.Core/ForwardedTypes.cs index f860545a9a2..4394a7c907c 100644 --- a/src/csharp/Grpc.Core/ForwardedTypes.cs +++ b/src/csharp/Grpc.Core/ForwardedTypes.cs @@ -70,6 +70,7 @@ using Grpc.Core.Utils; [assembly:TypeForwardedToAttribute(typeof(SslCredentials))] [assembly:TypeForwardedToAttribute(typeof(Status))] [assembly:TypeForwardedToAttribute(typeof(StatusCode))] +[assembly:TypeForwardedToAttribute(typeof(VerifyPeerCallback))] [assembly:TypeForwardedToAttribute(typeof(VerifyPeerContext))] [assembly:TypeForwardedToAttribute(typeof(VersionInfo))] [assembly:TypeForwardedToAttribute(typeof(WriteOptions))] From 606a0a0ad3006c97fa0330dfef1cb726735ad285 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 22 Jul 2019 13:48:18 +0200 Subject: [PATCH 1038/1555] split up ChannelCredentials.cs --- .../Grpc.Core.Api/ChannelCredentials.cs | 134 +++--------------- src/csharp/Grpc.Core.Api/SslCredentials.cs | 122 ++++++++++++++++ 2 files changed, 139 insertions(+), 117 deletions(-) create mode 100644 src/csharp/Grpc.Core.Api/SslCredentials.cs diff --git a/src/csharp/Grpc.Core.Api/ChannelCredentials.cs b/src/csharp/Grpc.Core.Api/ChannelCredentials.cs index 10020a3d8d4..fae390ce109 100644 --- a/src/csharp/Grpc.Core.Api/ChannelCredentials.cs +++ b/src/csharp/Grpc.Core.Api/ChannelCredentials.cs @@ -107,133 +107,33 @@ namespace Grpc.Core configurator.SetInsecureCredentials(state); } } - } - - /// - /// Callback invoked with the expected targetHost and the peer's certificate. - /// If false is returned by this callback then it is treated as a - /// verification failure and the attempted connection will fail. - /// Invocation of the callback is blocking, so any - /// implementation should be light-weight. - /// Note that the callback can potentially be invoked multiple times, - /// concurrently from different threads (e.g. when multiple connections - /// are being created for the same credentials). - /// - /// The associated with the callback - /// true if verification succeeded, false otherwise. - /// Note: experimental API that can change or be removed without any prior notice. - public delegate bool VerifyPeerCallback(VerifyPeerContext context); - - /// - /// Client-side SSL credentials. - /// - public sealed class SslCredentials : ChannelCredentials - { - readonly string rootCertificates; - readonly KeyCertificatePair keyCertificatePair; - readonly VerifyPeerCallback verifyPeerCallback; /// - /// Creates client-side SSL credentials loaded from - /// disk file pointed to by the GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment variable. - /// If that fails, gets the roots certificates from a well known place on disk. + /// Credentials that allow composing one object and + /// one or more objects into a single . /// - public SslCredentials() : this(null, null, null) + private sealed class CompositeChannelCredentials : ChannelCredentials { - } + readonly ChannelCredentials channelCredentials; + readonly CallCredentials callCredentials; - /// - /// Creates client-side SSL credentials from - /// a string containing PEM encoded root certificates. - /// - public SslCredentials(string rootCertificates) : this(rootCertificates, null, null) - { - } - - /// - /// Creates client-side SSL credentials. - /// - /// string containing PEM encoded server root certificates. - /// a key certificate pair. - public SslCredentials(string rootCertificates, KeyCertificatePair keyCertificatePair) : - this(rootCertificates, keyCertificatePair, null) - { - } - - /// - /// Creates client-side SSL credentials. - /// - /// string containing PEM encoded server root certificates. - /// a key certificate pair. - /// a callback to verify peer's target name and certificate. - /// Note: experimental API that can change or be removed without any prior notice. - public SslCredentials(string rootCertificates, KeyCertificatePair keyCertificatePair, VerifyPeerCallback verifyPeerCallback) - { - this.rootCertificates = rootCertificates; - this.keyCertificatePair = keyCertificatePair; - this.verifyPeerCallback = verifyPeerCallback; - } - - /// - /// PEM encoding of the server root certificates. - /// - public string RootCertificates - { - get + /// + /// Initializes a new instance of CompositeChannelCredentials class. + /// The resulting credentials object will be composite of all the credentials specified as parameters. + /// + /// channelCredentials to compose + /// channelCredentials to compose + public CompositeChannelCredentials(ChannelCredentials channelCredentials, CallCredentials callCredentials) { - return this.rootCertificates; + this.channelCredentials = GrpcPreconditions.CheckNotNull(channelCredentials); + this.callCredentials = GrpcPreconditions.CheckNotNull(callCredentials); + GrpcPreconditions.CheckArgument(channelCredentials.IsComposable, "Supplied channel credentials do not allow composition."); } - } - /// - /// Client side key and certificate pair. - /// If null, client will not use key and certificate pair. - /// - public KeyCertificatePair KeyCertificatePair - { - get + public override void InternalPopulateConfiguration(ChannelCredentialsConfiguratorBase configurator, object state) { - return this.keyCertificatePair; + configurator.SetCompositeCredentials(state, channelCredentials, callCredentials); } } - - /// - /// Populates channel credentials configurator with this instance's configuration. - /// End users never need to invoke this method as it is part of internal implementation. - /// - public override void InternalPopulateConfiguration(ChannelCredentialsConfiguratorBase configurator, object state) - { - configurator.SetSslCredentials(state, rootCertificates, keyCertificatePair, verifyPeerCallback); - } - - internal override bool IsComposable => true; - } - - /// - /// Credentials that allow composing one object and - /// one or more objects into a single . - /// - internal sealed class CompositeChannelCredentials : ChannelCredentials - { - readonly ChannelCredentials channelCredentials; - readonly CallCredentials callCredentials; - - /// - /// Initializes a new instance of CompositeChannelCredentials class. - /// The resulting credentials object will be composite of all the credentials specified as parameters. - /// - /// channelCredentials to compose - /// channelCredentials to compose - public CompositeChannelCredentials(ChannelCredentials channelCredentials, CallCredentials callCredentials) - { - this.channelCredentials = GrpcPreconditions.CheckNotNull(channelCredentials); - this.callCredentials = GrpcPreconditions.CheckNotNull(callCredentials); - GrpcPreconditions.CheckArgument(channelCredentials.IsComposable, "Supplied channel credentials do not allow composition."); - } - - public override void InternalPopulateConfiguration(ChannelCredentialsConfiguratorBase configurator, object state) - { - configurator.SetCompositeCredentials(state, channelCredentials, callCredentials); - } } } diff --git a/src/csharp/Grpc.Core.Api/SslCredentials.cs b/src/csharp/Grpc.Core.Api/SslCredentials.cs new file mode 100644 index 00000000000..21db7cdfb66 --- /dev/null +++ b/src/csharp/Grpc.Core.Api/SslCredentials.cs @@ -0,0 +1,122 @@ +#region Copyright notice and license + +// Copyright 2019 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +namespace Grpc.Core +{ + /// + /// Callback invoked with the expected targetHost and the peer's certificate. + /// If false is returned by this callback then it is treated as a + /// verification failure and the attempted connection will fail. + /// Invocation of the callback is blocking, so any + /// implementation should be light-weight. + /// Note that the callback can potentially be invoked multiple times, + /// concurrently from different threads (e.g. when multiple connections + /// are being created for the same credentials). + /// + /// The associated with the callback + /// true if verification succeeded, false otherwise. + /// Note: experimental API that can change or be removed without any prior notice. + public delegate bool VerifyPeerCallback(VerifyPeerContext context); + + /// + /// Client-side SSL credentials. + /// + public sealed class SslCredentials : ChannelCredentials + { + readonly string rootCertificates; + readonly KeyCertificatePair keyCertificatePair; + readonly VerifyPeerCallback verifyPeerCallback; + + /// + /// Creates client-side SSL credentials loaded from + /// disk file pointed to by the GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment variable. + /// If that fails, gets the roots certificates from a well known place on disk. + /// + public SslCredentials() : this(null, null, null) + { + } + + /// + /// Creates client-side SSL credentials from + /// a string containing PEM encoded root certificates. + /// + public SslCredentials(string rootCertificates) : this(rootCertificates, null, null) + { + } + + /// + /// Creates client-side SSL credentials. + /// + /// string containing PEM encoded server root certificates. + /// a key certificate pair. + public SslCredentials(string rootCertificates, KeyCertificatePair keyCertificatePair) : + this(rootCertificates, keyCertificatePair, null) + { + } + + /// + /// Creates client-side SSL credentials. + /// + /// string containing PEM encoded server root certificates. + /// a key certificate pair. + /// a callback to verify peer's target name and certificate. + /// Note: experimental API that can change or be removed without any prior notice. + public SslCredentials(string rootCertificates, KeyCertificatePair keyCertificatePair, VerifyPeerCallback verifyPeerCallback) + { + this.rootCertificates = rootCertificates; + this.keyCertificatePair = keyCertificatePair; + this.verifyPeerCallback = verifyPeerCallback; + } + + /// + /// PEM encoding of the server root certificates. + /// + public string RootCertificates + { + get + { + return this.rootCertificates; + } + } + + /// + /// Client side key and certificate pair. + /// If null, client will not use key and certificate pair. + /// + public KeyCertificatePair KeyCertificatePair + { + get + { + return this.keyCertificatePair; + } + } + + /// + /// Populates channel credentials configurator with this instance's configuration. + /// End users never need to invoke this method as it is part of internal implementation. + /// + public override void InternalPopulateConfiguration(ChannelCredentialsConfiguratorBase configurator, object state) + { + configurator.SetSslCredentials(state, rootCertificates, keyCertificatePair, verifyPeerCallback); + } + + internal override bool IsComposable => true; + } + + +} From b46ac4ae21e3affc4a2cf92ca78308a5a6f696bb Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 22 Jul 2019 11:53:37 -0400 Subject: [PATCH 1039/1555] implement caching of native channel credentials --- .../Grpc.Core.Api/ChannelCredentials.cs | 26 --------- .../DefaultChannelCredentialsConfigurator.cs | 57 ++++++++++++++++--- 2 files changed, 50 insertions(+), 33 deletions(-) diff --git a/src/csharp/Grpc.Core.Api/ChannelCredentials.cs b/src/csharp/Grpc.Core.Api/ChannelCredentials.cs index fae390ce109..23ede0a512e 100644 --- a/src/csharp/Grpc.Core.Api/ChannelCredentials.cs +++ b/src/csharp/Grpc.Core.Api/ChannelCredentials.cs @@ -31,20 +31,12 @@ namespace Grpc.Core public abstract class ChannelCredentials { static readonly ChannelCredentials InsecureInstance = new InsecureCredentialsImpl(); - - // TODO: caching the instance!!!! - //readonly Lazy cachedNativeCredentials; /// /// Creates a new instance of channel credentials /// public ChannelCredentials() { - // Native credentials object need to be kept alive once initialized for subchannel sharing to work correctly - // with secure connections. See https://github.com/grpc/grpc/issues/15207. - // We rely on finalizer to clean up the native portion of ChannelCredentialsSafeHandle after the ChannelCredentials - // instance becomes unused. - //this.cachedNativeCredentials = new Lazy(() => CreateNativeCredentials()); } /// @@ -77,24 +69,6 @@ namespace Grpc.Core /// public abstract void InternalPopulateConfiguration(ChannelCredentialsConfiguratorBase configurator, object state); - // / - // / Gets native object for the credentials, creating one if it already doesn't exist. May return null if insecure channel - // / should be created. Caller must not call Dispose() on the returned native credentials as their lifetime - // / is managed by this class (and instances of native credentials are cached). - // / - // / The native credentials. - //internal ChannelCredentialsSafeHandle GetNativeCredentials() - //{ - // return cachedNativeCredentials.Value; - //} - - // / - // / Creates a new native object for the credentials. May return null if insecure channel - // / should be created. For internal use only, use instead. - // / - // / The native credentials. - //internal abstract ChannelCredentialsSafeHandle CreateNativeCredentials(); - /// /// Returns true if this credential type allows being composed by CompositeCredentials. /// diff --git a/src/csharp/Grpc.Core/Internal/DefaultChannelCredentialsConfigurator.cs b/src/csharp/Grpc.Core/Internal/DefaultChannelCredentialsConfigurator.cs index 8b9e1758598..aaccbdfe6f7 100644 --- a/src/csharp/Grpc.Core/Internal/DefaultChannelCredentialsConfigurator.cs +++ b/src/csharp/Grpc.Core/Internal/DefaultChannelCredentialsConfigurator.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using Grpc.Core.Utils; using Grpc.Core.Logging; @@ -31,6 +32,12 @@ namespace Grpc.Core.Internal { static readonly ILogger Logger = GrpcEnvironment.Logger.ForType(); + // Native credentials object need to be kept alive once initialized for subchannel sharing to work correctly + // with secure connections. See https://github.com/grpc/grpc/issues/15207. + // We rely on finalizer to clean up the native portion of ChannelCredentialsSafeHandle after the ChannelCredentials + // instance becomes unused. + static readonly ConditionalWeakTable> CachedNativeCredentials = new ConditionalWeakTable>(); + bool configured; ChannelCredentialsSafeHandle nativeCredentials; @@ -48,18 +55,30 @@ namespace Grpc.Core.Internal { GrpcPreconditions.CheckState(!configured); configured = true; - IntPtr verifyPeerCallbackTag = IntPtr.Zero; - if (verifyPeerCallback != null) - { - verifyPeerCallbackTag = new VerifyPeerCallbackRegistration(verifyPeerCallback).CallbackRegistration.Tag; - } - nativeCredentials = ChannelCredentialsSafeHandle.CreateSslCredentials(rootCertificates, keyCertificatePair, verifyPeerCallbackTag); + nativeCredentials = GetOrCreateNativeCredentials((ChannelCredentials) state, + () => CreateNativeSslCredentials(rootCertificates, keyCertificatePair, verifyPeerCallback)); } public override void SetCompositeCredentials(object state, ChannelCredentials channelCredentials, CallCredentials callCredentials) { GrpcPreconditions.CheckState(!configured); configured = true; + nativeCredentials = GetOrCreateNativeCredentials((ChannelCredentials) state, + () => CreateNativeCompositeCredentials(channelCredentials, callCredentials)); + } + + private ChannelCredentialsSafeHandle CreateNativeSslCredentials(string rootCertificates, KeyCertificatePair keyCertificatePair, VerifyPeerCallback verifyPeerCallback) + { + IntPtr verifyPeerCallbackTag = IntPtr.Zero; + if (verifyPeerCallback != null) + { + verifyPeerCallbackTag = new VerifyPeerCallbackRegistration(verifyPeerCallback).CallbackRegistration.Tag; + } + return ChannelCredentialsSafeHandle.CreateSslCredentials(rootCertificates, keyCertificatePair, verifyPeerCallbackTag); + } + + private ChannelCredentialsSafeHandle CreateNativeCompositeCredentials(ChannelCredentials channelCredentials, CallCredentials callCredentials) + { using (var callCreds = callCredentials.ToNativeCredentials()) { var nativeComposite = ChannelCredentialsSafeHandle.CreateComposite(channelCredentials.ToNativeCredentials(), callCreds); @@ -67,10 +86,34 @@ namespace Grpc.Core.Internal { throw new ArgumentException("Error creating native composite credentials. Likely, this is because you are trying to compose incompatible credentials."); } - nativeCredentials = nativeComposite; + return nativeComposite; } } + private ChannelCredentialsSafeHandle GetOrCreateNativeCredentials(ChannelCredentials key, Func nativeCredentialsFactory) + { + Lazy lazyValue; + while (true) + { + if (CachedNativeCredentials.TryGetValue(key, out lazyValue)) + { + break; + } + + lazyValue = new Lazy(nativeCredentialsFactory); + try + { + CachedNativeCredentials.Add(key, lazyValue); + break; + } + catch (ArgumentException) + { + // key exists, next TryGetValue should fetch the value + } + } + return lazyValue.Value; + } + private class VerifyPeerCallbackRegistration { readonly VerifyPeerCallback verifyPeerCallback; From a1030e23b0c3684e51b502e9637c4d61a72f5881 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 22 Jul 2019 13:15:22 -0400 Subject: [PATCH 1040/1555] remove unnecessary test --- .../Grpc.Core.Tests/ChannelCredentialsTest.cs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/ChannelCredentialsTest.cs b/src/csharp/Grpc.Core.Tests/ChannelCredentialsTest.cs index fd50ce4f064..57acfc0bab5 100644 --- a/src/csharp/Grpc.Core.Tests/ChannelCredentialsTest.cs +++ b/src/csharp/Grpc.Core.Tests/ChannelCredentialsTest.cs @@ -52,24 +52,5 @@ namespace Grpc.Core.Tests var nativeCreds2 = creds.ToNativeCredentials(); Assert.AreSame(nativeCreds1, nativeCreds2); } - - [Test] - public void ChannelCredentials_CreateExceptionIsCached() - { - var creds = new ChannelCredentialsWithPopulateConfigurationThrows(); - var ex1 = Assert.Throws(typeof(Exception), () => creds.ToNativeCredentials()); - var ex2 = Assert.Throws(typeof(Exception), () => creds.ToNativeCredentials()); - Assert.AreSame(ex1, ex2); - } - - internal class ChannelCredentialsWithPopulateConfigurationThrows : ChannelCredentials - { - internal override bool IsComposable => false; - - public override void InternalPopulateConfiguration(ChannelCredentialsConfiguratorBase configurator, object state) - { - throw new Exception("Creation of native credentials has failed on purpose."); - } - } } } From 11bf6dbad650add92f160a41ca9677564004c10c Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 30 Jul 2019 10:59:59 -0700 Subject: [PATCH 1041/1555] simplify CachedNativeCredentials --- .../DefaultChannelCredentialsConfigurator.cs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/csharp/Grpc.Core/Internal/DefaultChannelCredentialsConfigurator.cs b/src/csharp/Grpc.Core/Internal/DefaultChannelCredentialsConfigurator.cs index aaccbdfe6f7..c4c044cd577 100644 --- a/src/csharp/Grpc.Core/Internal/DefaultChannelCredentialsConfigurator.cs +++ b/src/csharp/Grpc.Core/Internal/DefaultChannelCredentialsConfigurator.cs @@ -37,6 +37,7 @@ namespace Grpc.Core.Internal // We rely on finalizer to clean up the native portion of ChannelCredentialsSafeHandle after the ChannelCredentials // instance becomes unused. static readonly ConditionalWeakTable> CachedNativeCredentials = new ConditionalWeakTable>(); + static readonly object StaticLock = new object(); bool configured; ChannelCredentialsSafeHandle nativeCredentials; @@ -93,22 +94,11 @@ namespace Grpc.Core.Internal private ChannelCredentialsSafeHandle GetOrCreateNativeCredentials(ChannelCredentials key, Func nativeCredentialsFactory) { Lazy lazyValue; - while (true) - { - if (CachedNativeCredentials.TryGetValue(key, out lazyValue)) - { - break; - } - - lazyValue = new Lazy(nativeCredentialsFactory); - try + lock (StaticLock) { + if (!CachedNativeCredentials.TryGetValue(key, out lazyValue)) { + lazyValue = new Lazy(nativeCredentialsFactory); CachedNativeCredentials.Add(key, lazyValue); - break; - } - catch (ArgumentException) - { - // key exists, next TryGetValue should fetch the value } } return lazyValue.Value; From d4e778ca2fbaa7296270906a5809258462e9cae5 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 30 Jul 2019 11:01:07 -0700 Subject: [PATCH 1042/1555] make Grpc.Auth only depend on Grpc.Core.Api --- src/csharp/Grpc.Auth/Grpc.Auth.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/csharp/Grpc.Auth/Grpc.Auth.csproj b/src/csharp/Grpc.Auth/Grpc.Auth.csproj index 298b721409e..1e559c19872 100755 --- a/src/csharp/Grpc.Auth/Grpc.Auth.csproj +++ b/src/csharp/Grpc.Auth/Grpc.Auth.csproj @@ -27,7 +27,7 @@ - + None From fb85fb8c19a2de21a503aea037682eff00a01977 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 30 Jul 2019 11:44:02 -0700 Subject: [PATCH 1043/1555] make Grpc.Auth build again --- src/csharp/Grpc.Auth/GoogleAuthInterceptors.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/csharp/Grpc.Auth/GoogleAuthInterceptors.cs b/src/csharp/Grpc.Auth/GoogleAuthInterceptors.cs index d859075c3bd..e6c973431d7 100644 --- a/src/csharp/Grpc.Auth/GoogleAuthInterceptors.cs +++ b/src/csharp/Grpc.Auth/GoogleAuthInterceptors.cs @@ -61,7 +61,7 @@ namespace Grpc.Auth return new AsyncAuthInterceptor((context, metadata) => { metadata.Add(CreateBearerTokenHeader(accessToken)); - return TaskUtils.CompletedTask; + return GetCompletedTask(); }); } @@ -69,5 +69,17 @@ namespace Grpc.Auth { return new Metadata.Entry(AuthorizationHeader, Schema + " " + accessToken); } + + /// + /// Framework independent equivalent of Task.CompletedTask. + /// + private static Task GetCompletedTask() + { +#if NETSTANDARD1_5 || NETSTANDARD2_0 + return Task.CompletedTask; +#else + return Task.FromResult(null); // for .NET45, emulate the functionality +#endif + } } } From 6b86d4706b3fb752ee27a56f5369b1a04d86d7b3 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 30 Jul 2019 11:54:55 -0700 Subject: [PATCH 1044/1555] yapf code --- tools/buildgen/plugins/expand_version.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/buildgen/plugins/expand_version.py b/tools/buildgen/plugins/expand_version.py index 02615f841fe..08cc10b3c60 100755 --- a/tools/buildgen/plugins/expand_version.py +++ b/tools/buildgen/plugins/expand_version.py @@ -38,7 +38,9 @@ class Version: self.tag = None if '-' in version_str: version_str, self.tag = version_str.split('-') - self.major, self.minor, self.patch = [int(x) for x in version_str.split('.')] + self.major, self.minor, self.patch = [ + int(x) for x in version_str.split('.') + ] if override_major: self.major = override_major @@ -114,6 +116,8 @@ def mako_plugin(dictionary): version_tag = '%s_version' % language override_major = settings.get('%s_major_version' % language, None) if version_tag in settings: - settings[version_tag] = Version(settings[version_tag], override_major=override_major) + settings[version_tag] = Version( + settings[version_tag], override_major=override_major) else: - settings[version_tag] = Version(version_str, override_major=override_major) + settings[version_tag] = Version( + version_str, override_major=override_major) From 40ab822fea5e594af0fc7541da9a51072ffad889 Mon Sep 17 00:00:00 2001 From: yang-g Date: Tue, 30 Jul 2019 12:58:46 -0700 Subject: [PATCH 1045/1555] Let CFStreamHandle be covered by grpc_init/shutdown --- src/core/lib/iomgr/cfstream_handle.cc | 5 +++++ src/core/lib/iomgr/cfstream_handle.h | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/cfstream_handle.cc b/src/core/lib/iomgr/cfstream_handle.cc index ea28e620695..c1e7d67e568 100644 --- a/src/core/lib/iomgr/cfstream_handle.cc +++ b/src/core/lib/iomgr/cfstream_handle.cc @@ -25,6 +25,7 @@ #import #import "src/core/lib/iomgr/cfstream_handle.h" +#include #include #include @@ -35,6 +36,10 @@ extern grpc_core::TraceFlag grpc_tcp_trace; +GrpcLibraryInitHolder::GrpcLibraryInitHolder() { grpc_init(); } + +GrpcLibraryInitHolder::~GrpcLibraryInitHolder() { grpc_shutdown(); } + void* CFStreamHandle::Retain(void* info) { CFStreamHandle* handle = static_cast(info); CFSTREAM_HANDLE_REF(handle, "retain"); diff --git a/src/core/lib/iomgr/cfstream_handle.h b/src/core/lib/iomgr/cfstream_handle.h index 05f45ed6251..5f3a525930c 100644 --- a/src/core/lib/iomgr/cfstream_handle.h +++ b/src/core/lib/iomgr/cfstream_handle.h @@ -33,11 +33,17 @@ #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/lockfree_event.h" -class CFStreamHandle final { +class GrpcLibraryInitHolder { + public: + GrpcLibraryInitHolder(); + virtual ~GrpcLibraryInitHolder(); +}; + +class CFStreamHandle : public GrpcLibraryInitHolder { public: static CFStreamHandle* CreateStreamHandle(CFReadStreamRef read_stream, CFWriteStreamRef write_stream); - ~CFStreamHandle(); + ~CFStreamHandle() override; CFStreamHandle(const CFStreamHandle& ref) = delete; CFStreamHandle(CFStreamHandle&& ref) = delete; CFStreamHandle& operator=(const CFStreamHandle& rhs) = delete; From cb6e5481cc2640d19b654bd5da925f9c8a35ed96 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 30 Jul 2019 14:19:26 -0700 Subject: [PATCH 1046/1555] remove System.Interactive.Async dependency from the Unity package --- src/csharp/build_unitypackage.bat | 1 - src/csharp/experimental/build_unitypackage.sh | 32 ------------------- .../Plugins/System.Interactive.Async.meta | 10 ------ .../Plugins/System.Interactive.Async/lib.meta | 10 ------ .../System.Interactive.Async/lib/net45.meta | 10 ------ .../net45/System.Interactive.Async.dll.meta | 32 ------------------- .../net45/System.Interactive.Async.xml.meta | 9 ------ .../csharp/build_unitypackage.bat.template | 1 - 8 files changed, 105 deletions(-) delete mode 100755 src/csharp/experimental/build_unitypackage.sh delete mode 100644 src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async.meta delete mode 100644 src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async/lib.meta delete mode 100644 src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async/lib/net45.meta delete mode 100644 src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async/lib/net45/System.Interactive.Async.dll.meta delete mode 100644 src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async/lib/net45/System.Interactive.Async.xml.meta diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index a40eddddf2e..f29bd98b5a2 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -64,7 +64,6 @@ copy /Y nativelibs\csharp_ext_macos_ios\libgrpc.a unitypackage\unitypackage_skel @rem add gRPC dependencies @rem TODO(jtattermusch): also include XMLdoc -copy /Y Grpc.Core\bin\Release\net45\System.Interactive.Async.dll unitypackage\unitypackage_skeleton\Plugins\System.Interactive.Async\lib\net45\System.Interactive.Async.dll || goto :error copy /Y Grpc.Core\bin\Release\net45\System.Runtime.CompilerServices.Unsafe.dll unitypackage\unitypackage_skeleton\Plugins\System.Runtime.CompilerServices.Unsafe\lib\net45\System.Runtime.CompilerServices.Unsafe.dll || goto :error copy /Y Grpc.Core\bin\Release\net45\System.Buffers.dll unitypackage\unitypackage_skeleton\Plugins\System.Buffers\lib\net45\System.Buffers.dll || goto :error copy /Y Grpc.Core\bin\Release\net45\System.Memory.dll unitypackage\unitypackage_skeleton\Plugins\System.Memory\lib\net45\System.Memory.dll || goto :error diff --git a/src/csharp/experimental/build_unitypackage.sh b/src/csharp/experimental/build_unitypackage.sh deleted file mode 100755 index cca52658e85..00000000000 --- a/src/csharp/experimental/build_unitypackage.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# Copyright 2018 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Builds an experimental .unitypackage file to be imported into Unity projects. - -set -ex - -cd "$(dirname "$0")/.." - -dotnet restore Grpc.sln - -mkdir -p GrpcUnity -dotnet build --configuration Release --framework net45 Grpc.Core --output ../GrpcUnity - -#TODO: add ThirdParty/Grpc.Core: -# - assembly -# - native libraries (mac dylib need to be renamed to grpc_csharp_ext.bundle) - -#TODO: add ThirdParty/Grpc.Tools: -# - protoc and grpc plugin diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async.meta deleted file mode 100644 index 6f1b910534d..00000000000 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b2ba2199282e9c641bc2e611f1e776a0 -folderAsset: yes -timeCreated: 1531219385 -licenseType: Free -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async/lib.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async/lib.meta deleted file mode 100644 index d7ae012a397..00000000000 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async/lib.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: bd5ddd2522dc301488ffe002106fe0ab -folderAsset: yes -timeCreated: 1531219385 -licenseType: Free -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async/lib/net45.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async/lib/net45.meta deleted file mode 100644 index 9b1748d3e76..00000000000 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async/lib/net45.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: a68443518bcd1d44ba88a871dcab0c83 -folderAsset: yes -timeCreated: 1531219385 -licenseType: Free -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async/lib/net45/System.Interactive.Async.dll.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async/lib/net45/System.Interactive.Async.dll.meta deleted file mode 100644 index bb910fe9229..00000000000 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async/lib/net45/System.Interactive.Async.dll.meta +++ /dev/null @@ -1,32 +0,0 @@ -fileFormatVersion: 2 -guid: 4c05e46cbf00c68408f5ddc1eef9ae3b -timeCreated: 1531219386 -licenseType: Free -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - isPreloaded: 0 - isOverridable: 0 - platformData: - - first: - Any: - second: - enabled: 1 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Windows Store Apps: WindowsStoreApps - second: - enabled: 0 - settings: - CPU: AnyCPU - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async/lib/net45/System.Interactive.Async.xml.meta b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async/lib/net45/System.Interactive.Async.xml.meta deleted file mode 100644 index 53f91502bd6..00000000000 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/System.Interactive.Async/lib/net45/System.Interactive.Async.xml.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 6fc38864f2d3dde46b3833c62c91a008 -timeCreated: 1531219386 -licenseType: Free -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/templates/src/csharp/build_unitypackage.bat.template b/templates/src/csharp/build_unitypackage.bat.template index 07f19c2af3e..2dbb22a0d17 100755 --- a/templates/src/csharp/build_unitypackage.bat.template +++ b/templates/src/csharp/build_unitypackage.bat.template @@ -66,7 +66,6 @@ @rem add gRPC dependencies @rem TODO(jtattermusch): also include XMLdoc - copy /Y Grpc.Core\bin\Release\net45\System.Interactive.Async.dll unitypackage\unitypackage_skeleton\Plugins\System.Interactive.Async\lib\net45\System.Interactive.Async.dll || goto :error copy /Y Grpc.Core\bin\Release\net45\System.Runtime.CompilerServices.Unsafe.dll unitypackage\unitypackage_skeleton\Plugins\System.Runtime.CompilerServices.Unsafe\lib\net45\System.Runtime.CompilerServices.Unsafe.dll || goto :error copy /Y Grpc.Core\bin\Release\net45\System.Buffers.dll unitypackage\unitypackage_skeleton\Plugins\System.Buffers\lib\net45\System.Buffers.dll || goto :error copy /Y Grpc.Core\bin\Release\net45\System.Memory.dll unitypackage\unitypackage_skeleton\Plugins\System.Memory\lib\net45\System.Memory.dll || goto :error From bd8a04a6e92645a56cf12318bd8f7e5759343aeb Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Mon, 29 Jul 2019 16:06:06 -0700 Subject: [PATCH 1047/1555] Add human-readable names for channelz sockets and listen sockets --- .../client_channel/client_channel_channelz.cc | 22 ++++++++---- .../client_channel/client_channel_channelz.h | 12 +++---- .../ext/filters/client_channel/connector.h | 12 +++++-- .../ext/filters/client_channel/subchannel.cc | 9 ++--- .../chttp2/client/chttp2_connector.cc | 7 ++-- .../transport/chttp2/server/chttp2_server.cc | 12 ++++--- .../chttp2/transport/chttp2_transport.cc | 5 ++- src/core/lib/channel/channelz.cc | 36 ++++++++++++------- src/core/lib/channel/channelz.h | 27 +++++++------- src/core/lib/surface/server.cc | 24 +++++++------ src/core/lib/surface/server.h | 13 ++++--- test/core/channel/channelz_registry_test.cc | 26 +++++++------- test/cpp/end2end/channelz_service_test.cc | 7 ++++ 13 files changed, 127 insertions(+), 85 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel_channelz.cc b/src/core/ext/filters/client_channel/client_channel_channelz.cc index a489685df40..87a76601f02 100644 --- a/src/core/ext/filters/client_channel/client_channel_channelz.cc +++ b/src/core/ext/filters/client_channel/client_channel_channelz.cc @@ -32,7 +32,8 @@ namespace channelz { SubchannelNode::SubchannelNode(const char* target_address, size_t channel_tracer_max_nodes) - : BaseNode(EntityType::kSubchannel), + : BaseNode(EntityType::kSubchannel, + UniquePtr(gpr_strdup(target_address))), target_(UniquePtr(gpr_strdup(target_address))), trace_(channel_tracer_max_nodes) {} @@ -42,8 +43,9 @@ void SubchannelNode::UpdateConnectivityState(grpc_connectivity_state state) { connectivity_state_.Store(state, MemoryOrder::RELAXED); } -void SubchannelNode::SetChildSocketUuid(intptr_t uuid) { - child_socket_uuid_.Store(uuid, MemoryOrder::RELAXED); +void SubchannelNode::SetChildSocket(RefCountedPtr socket) { + MutexLock lock(&socket_mu_); + child_socket_ = std::move(socket); } void SubchannelNode::PopulateConnectivityState(grpc_json* json) { @@ -88,14 +90,20 @@ grpc_json* SubchannelNode::RenderJson() { call_counter_.PopulateCallCounts(json); json = top_level_json; // populate the child socket. - intptr_t socket_uuid = child_socket_uuid_.Load(MemoryOrder::RELAXED); - if (socket_uuid != 0) { + RefCountedPtr child_socket; + { + MutexLock lock(&socket_mu_); + child_socket = child_socket_; + } + if (child_socket != nullptr && child_socket->uuid() != 0) { grpc_json* array_parent = grpc_json_create_child( nullptr, json, "socketRef", nullptr, GRPC_JSON_ARRAY, false); json_iterator = grpc_json_create_child(json_iterator, array_parent, nullptr, nullptr, GRPC_JSON_OBJECT, false); - grpc_json_add_number_string_child(json_iterator, nullptr, "socketId", - socket_uuid); + grpc_json* sibling_iterator = grpc_json_add_number_string_child( + json_iterator, nullptr, "socketId", child_socket->uuid()); + grpc_json_create_child(sibling_iterator, json_iterator, "name", + child_socket->name(), GRPC_JSON_STRING, false); } return top_level_json; } diff --git a/src/core/ext/filters/client_channel/client_channel_channelz.h b/src/core/ext/filters/client_channel/client_channel_channelz.h index 80a6fd230c8..5a1a1adcd1b 100644 --- a/src/core/ext/filters/client_channel/client_channel_channelz.h +++ b/src/core/ext/filters/client_channel/client_channel_channelz.h @@ -40,11 +40,10 @@ class SubchannelNode : public BaseNode { // Sets the subchannel's connectivity state without health checking. void UpdateConnectivityState(grpc_connectivity_state state); - // Used when the subchannel's child socket uuid changes. This should be set - // when the subchannel's transport is created and set to 0 when the subchannel - // unrefs the transport. A uuid of 0 indicates that the child socket is no - // longer associated with this subchannel. - void SetChildSocketUuid(intptr_t uuid); + // Used when the subchannel's child socket changes. This should be set when + // the subchannel's transport is created and set to nullptr when the + // subchannel unrefs the transport. + void SetChildSocket(RefCountedPtr socket); grpc_json* RenderJson() override; @@ -66,7 +65,8 @@ class SubchannelNode : public BaseNode { void PopulateConnectivityState(grpc_json* json); Atomic connectivity_state_{GRPC_CHANNEL_IDLE}; - Atomic child_socket_uuid_{0}; + Mutex socket_mu_; + RefCountedPtr child_socket_; UniquePtr target_; CallCountingHelper call_counter_; ChannelTrace trace_; diff --git a/src/core/ext/filters/client_channel/connector.h b/src/core/ext/filters/client_channel/connector.h index ea34dcdab57..2bd5ff26e3e 100644 --- a/src/core/ext/filters/client_channel/connector.h +++ b/src/core/ext/filters/client_channel/connector.h @@ -22,6 +22,7 @@ #include #include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/channel/channelz.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/transport/transport.h" @@ -48,8 +49,15 @@ typedef struct { /** channel arguments (to be passed to the filters) */ grpc_channel_args* channel_args; - /** socket uuid of the connected transport. 0 if not available */ - intptr_t socket_uuid; + /** channelz socket node of the connected transport. nullptr if not available + */ + grpc_core::RefCountedPtr socket; + + void reset() { + transport = nullptr; + channel_args = nullptr; + socket = nullptr; + } } grpc_connect_out_args; struct grpc_connector_vtable { diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index e248cc6b5fc..e30d915d03c 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -349,7 +349,7 @@ class Subchannel::ConnectedSubchannelStateWatcher { } c->connected_subchannel_.reset(); if (c->channelz_node() != nullptr) { - c->channelz_node()->SetChildSocketUuid(0); + c->channelz_node()->SetChildSocket(nullptr); } c->SetConnectivityStateLocked(GRPC_CHANNEL_TRANSIENT_FAILURE); c->backoff_begun_ = false; @@ -1072,8 +1072,9 @@ bool Subchannel::PublishTransportLocked() { GRPC_ERROR_UNREF(error); return false; } - intptr_t socket_uuid = connecting_result_.socket_uuid; - memset(&connecting_result_, 0, sizeof(connecting_result_)); + RefCountedPtr socket = + std::move(connecting_result_.socket); + connecting_result_.reset(); if (disconnected_) { grpc_channel_stack_destroy(stk); gpr_free(stk); @@ -1085,7 +1086,7 @@ bool Subchannel::PublishTransportLocked() { gpr_log(GPR_INFO, "New connected subchannel at %p for subchannel %p", connected_subchannel_.get(), this); if (channelz_node_ != nullptr) { - channelz_node_->SetChildSocketUuid(socket_uuid); + channelz_node_->SetChildSocket(std::move(socket)); } // Instantiate state watcher. Will clean itself up. New(this); diff --git a/src/core/ext/transport/chttp2/client/chttp2_connector.cc b/src/core/ext/transport/chttp2/client/chttp2_connector.cc index c324c2c9243..6b6d299b6e2 100644 --- a/src/core/ext/transport/chttp2/client/chttp2_connector.cc +++ b/src/core/ext/transport/chttp2/client/chttp2_connector.cc @@ -111,15 +111,14 @@ static void on_handshake_done(void* arg, grpc_error* error) { } else { error = GRPC_ERROR_REF(error); } - memset(c->result, 0, sizeof(*c->result)); + c->result->reset(); } else { grpc_endpoint_delete_from_pollset_set(args->endpoint, c->args.interested_parties); c->result->transport = grpc_create_chttp2_transport(args->args, args->endpoint, true); - grpc_core::RefCountedPtr socket_node = + c->result->socket = grpc_chttp2_transport_get_socket_node(c->result->transport); - c->result->socket_uuid = socket_node == nullptr ? 0 : socket_node->uuid(); GPR_ASSERT(c->result->transport); // TODO(roth): We ideally want to wait until we receive HTTP/2 // settings from the server before we consider the connection @@ -180,7 +179,7 @@ static void connected(void* arg, grpc_error* error) { } else { error = GRPC_ERROR_REF(error); } - memset(c->result, 0, sizeof(*c->result)); + c->result->reset(); grpc_closure* notify = c->notify; c->notify = nullptr; GRPC_CLOSURE_SCHED(notify, error); diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc index dc60ec2487b..5e9cd77d18a 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -317,7 +317,7 @@ static grpc_error* chttp2_server_add_acceptor(grpc_server* server, *arg_val = grpc_tcp_server_create_fd_handler(tcp_server); grpc_server_add_listener(server, state, server_start_listener, - server_destroy_listener, /* socket_uuid */ 0); + server_destroy_listener, /* node */ nullptr); return err; /* Error path: cleanup and return */ @@ -345,7 +345,6 @@ grpc_error* grpc_chttp2_server_add_port(grpc_server* server, const char* addr, grpc_error** errors = nullptr; size_t naddrs = 0; const grpc_arg* arg = nullptr; - intptr_t socket_uuid = 0; *port_num = -1; @@ -413,15 +412,18 @@ grpc_error* grpc_chttp2_server_add_port(grpc_server* server, const char* addr, arg = grpc_channel_args_find(args, GRPC_ARG_ENABLE_CHANNELZ); if (grpc_channel_arg_get_bool(arg, GRPC_ENABLE_CHANNELZ_DEFAULT)) { + char* socket_name = nullptr; + gpr_asprintf(&socket_name, "chttp2 listener %s", addr); state->channelz_listen_socket = grpc_core::MakeRefCounted( - grpc_core::UniquePtr(gpr_strdup(addr))); - socket_uuid = state->channelz_listen_socket->uuid(); + grpc_core::UniquePtr(gpr_strdup(addr)), + grpc_core::UniquePtr(socket_name)); } /* Register with the server only upon success */ grpc_server_add_listener(server, state, server_start_listener, - server_destroy_listener, socket_uuid); + server_destroy_listener, + state->channelz_listen_socket); goto done; /* Error path: cleanup and return */ diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 43f2db1309f..67b6e18bcff 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -378,10 +378,13 @@ static bool read_channel_args(grpc_chttp2_transport* t, if (channelz_enabled) { // TODO(ncteisen): add an API to endpoint to query for local addr, and pass // it in here, so SocketNode knows its own address. + char* socket_name = nullptr; + gpr_asprintf(&socket_name, "%s %s", get_vtable()->name, t->peer_string); t->channelz_socket = grpc_core::MakeRefCounted( grpc_core::UniquePtr(), - grpc_core::UniquePtr(gpr_strdup(t->peer_string))); + grpc_core::UniquePtr(gpr_strdup(t->peer_string)), + grpc_core::UniquePtr(socket_name)); } return enable_bdp; } diff --git a/src/core/lib/channel/channelz.cc b/src/core/lib/channel/channelz.cc index f03c9adba26..325131b8439 100644 --- a/src/core/lib/channel/channelz.cc +++ b/src/core/lib/channel/channelz.cc @@ -85,7 +85,8 @@ intptr_t GetParentUuidFromArgs(const grpc_channel_args& args) { // BaseNode // -BaseNode::BaseNode(EntityType type) : type_(type), uuid_(-1) { +BaseNode::BaseNode(EntityType type, UniquePtr name) + : type_(type), uuid_(-1), name_(std::move(name)) { // The registry will set uuid_ under its lock. ChannelzRegistry::Register(this); } @@ -187,7 +188,8 @@ void CallCountingHelper::PopulateCallCounts(grpc_json* json) { ChannelNode::ChannelNode(UniquePtr target, size_t channel_tracer_max_nodes, intptr_t parent_uuid) : BaseNode(parent_uuid == 0 ? EntityType::kTopLevelChannel - : EntityType::kInternalChannel), + : EntityType::kInternalChannel, + UniquePtr(gpr_strdup(target.get()))), target_(std::move(target)), trace_(channel_tracer_max_nodes), parent_uuid_(parent_uuid) {} @@ -320,7 +322,8 @@ void ChannelNode::RemoveChildSubchannel(intptr_t child_uuid) { // ServerNode::ServerNode(grpc_server* server, size_t channel_tracer_max_nodes) - : BaseNode(EntityType::kServer), trace_(channel_tracer_max_nodes) {} + : BaseNode(EntityType::kServer, /* name */ nullptr), + trace_(channel_tracer_max_nodes) {} ServerNode::~ServerNode() {} @@ -334,9 +337,9 @@ void ServerNode::RemoveChildSocket(intptr_t child_uuid) { child_sockets_.erase(child_uuid); } -void ServerNode::AddChildListenSocket(intptr_t child_uuid) { +void ServerNode::AddChildListenSocket(RefCountedPtr node) { MutexLock lock(&child_mu_); - child_listen_sockets_.insert(MakePair(child_uuid, true)); + child_listen_sockets_.insert(MakePair(node->uuid(), std::move(node))); } void ServerNode::RemoveChildListenSocket(intptr_t child_uuid) { @@ -366,7 +369,7 @@ char* ServerNode::RenderServerSockets(intptr_t start_socket_id, json_iterator = grpc_json_add_number_string_child( socket_ref_json, nullptr, "socketId", it->first); grpc_json_create_child(json_iterator, socket_ref_json, "name", - it->second->remote(), GRPC_JSON_STRING, false); + it->second->name(), GRPC_JSON_STRING, false); } } if (sockets_rendered == child_sockets_.size()) { @@ -416,8 +419,10 @@ grpc_json* ServerNode::RenderJson() { json_iterator = grpc_json_create_child(json_iterator, array_parent, nullptr, nullptr, GRPC_JSON_OBJECT, false); - grpc_json_add_number_string_child(json_iterator, nullptr, "socketId", - it.first); + grpc_json* sibling_iterator = grpc_json_add_number_string_child( + json_iterator, nullptr, "socketId", it.first); + grpc_json_create_child(sibling_iterator, json_iterator, "name", + it.second->name(), GRPC_JSON_STRING, false); } } return top_level_json; @@ -480,8 +485,9 @@ void PopulateSocketAddressJson(grpc_json* json, const char* name, } // namespace -SocketNode::SocketNode(UniquePtr local, UniquePtr remote) - : BaseNode(EntityType::kSocket), +SocketNode::SocketNode(UniquePtr local, UniquePtr remote, + UniquePtr name) + : BaseNode(EntityType::kSocket, std::move(name)), local_(std::move(local)), remote_(std::move(remote)) {} @@ -521,6 +527,8 @@ grpc_json* SocketNode::RenderJson() { json_iterator = nullptr; json_iterator = grpc_json_add_number_string_child(json, json_iterator, "socketId", uuid()); + json_iterator = grpc_json_create_child(json_iterator, json, "name", name(), + GRPC_JSON_STRING, false); json = top_level_json; PopulateSocketAddressJson(json, "remote", remote_.get()); PopulateSocketAddressJson(json, "local", local_.get()); @@ -600,8 +608,10 @@ grpc_json* SocketNode::RenderJson() { // ListenSocketNode // -ListenSocketNode::ListenSocketNode(UniquePtr local_addr) - : BaseNode(EntityType::kSocket), local_addr_(std::move(local_addr)) {} +ListenSocketNode::ListenSocketNode(UniquePtr local_addr, + UniquePtr name) + : BaseNode(EntityType::kSocket, std::move(name)), + local_addr_(std::move(local_addr)) {} grpc_json* ListenSocketNode::RenderJson() { // We need to track these three json objects to build our object @@ -615,6 +625,8 @@ grpc_json* ListenSocketNode::RenderJson() { json_iterator = nullptr; json_iterator = grpc_json_add_number_string_child(json, json_iterator, "socketId", uuid()); + json_iterator = grpc_json_create_child(json_iterator, json, "name", name(), + GRPC_JSON_STRING, false); json = top_level_json; PopulateSocketAddressJson(json, "local", local_addr_.get()); diff --git a/src/core/lib/channel/channelz.h b/src/core/lib/channel/channelz.h index b0b137a1ec8..e1af701834d 100644 --- a/src/core/lib/channel/channelz.h +++ b/src/core/lib/channel/channelz.h @@ -59,6 +59,7 @@ grpc_arg MakeParentUuidArg(intptr_t parent_uuid); intptr_t GetParentUuidFromArgs(const grpc_channel_args& args); class SocketNode; +class ListenSocketNode; namespace testing { class CallCountingHelperPeer; @@ -79,7 +80,7 @@ class BaseNode : public RefCounted { kSocket, }; - explicit BaseNode(EntityType type); + BaseNode(EntityType type, UniquePtr name); virtual ~BaseNode(); // All children must implement this function. @@ -91,12 +92,14 @@ class BaseNode : public RefCounted { EntityType type() const { return type_; } intptr_t uuid() const { return uuid_; } + const char* name() const { return name_.get(); } private: // to allow the ChannelzRegistry to set uuid_ under its lock. friend class ChannelzRegistry; const EntityType type_; intptr_t uuid_; + UniquePtr name_; }; // This class is a helper class for channelz entities that deal with Channels, @@ -172,9 +175,13 @@ class ChannelNode : public BaseNode { void SetConnectivityState(grpc_connectivity_state state); + // TODO(roth): take in a RefCountedPtr to the child channel so we can retrieve + // the human-readable name. void AddChildChannel(intptr_t child_uuid); void RemoveChildChannel(intptr_t child_uuid); + // TODO(roth): take in a RefCountedPtr to the child subchannel so we can + // retrieve the human-readable name. void AddChildSubchannel(intptr_t child_uuid); void RemoveChildSubchannel(intptr_t child_uuid); @@ -212,14 +219,11 @@ class ServerNode : public BaseNode { char* RenderServerSockets(intptr_t start_socket_id, intptr_t max_results); - void AddChildSocket(RefCountedPtr); + void AddChildSocket(RefCountedPtr node); void RemoveChildSocket(intptr_t child_uuid); - // TODO(ncteisen): This only takes in the uuid of the child socket for now, - // since that is all that is strictly needed. In a future enhancement we will - // add human readable names as in the channelz.proto - void AddChildListenSocket(intptr_t child_uuid); + void AddChildListenSocket(RefCountedPtr node); void RemoveChildListenSocket(intptr_t child_uuid); @@ -242,16 +246,14 @@ class ServerNode : public BaseNode { ChannelTrace trace_; Mutex child_mu_; // Guards child maps below. Map> child_sockets_; - // TODO(roth): We don't actually use the values here, only the keys, so - // these should be sets instead of maps, but we don't currently have a set - // implementation. Change this if/when we have one. - Map child_listen_sockets_; + Map> child_listen_sockets_; }; // Handles channelz bookkeeping for sockets class SocketNode : public BaseNode { public: - SocketNode(UniquePtr local, UniquePtr remote); + SocketNode(UniquePtr local, UniquePtr remote, + UniquePtr name); ~SocketNode() override {} grpc_json* RenderJson() override; @@ -290,8 +292,7 @@ class SocketNode : public BaseNode { // Handles channelz bookkeeping for listen sockets class ListenSocketNode : public BaseNode { public: - // ListenSocketNode takes ownership of host. - explicit ListenSocketNode(UniquePtr local_addr); + ListenSocketNode(UniquePtr local_addr, UniquePtr name); ~ListenSocketNode() override {} grpc_json* RenderJson() override; diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 702853e0afe..db2d291bc59 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -1395,20 +1395,22 @@ void grpc_server_destroy(grpc_server* server) { server_unref(server); } -void grpc_server_add_listener(grpc_server* server, void* arg, - void (*start)(grpc_server* server, void* arg, - grpc_pollset** pollsets, - size_t pollset_count), - void (*destroy)(grpc_server* server, void* arg, - grpc_closure* on_done), - intptr_t socket_uuid) { +void grpc_server_add_listener( + grpc_server* server, void* listener_arg, + void (*start)(grpc_server* server, void* arg, grpc_pollset** pollsets, + size_t pollset_count), + void (*destroy)(grpc_server* server, void* arg, grpc_closure* on_done), + grpc_core::RefCountedPtr node) { listener* l = static_cast(gpr_malloc(sizeof(listener))); - l->arg = arg; + l->arg = listener_arg; l->start = start; l->destroy = destroy; - l->socket_uuid = socket_uuid; - if (server->channelz_server != nullptr && socket_uuid != 0) { - server->channelz_server->AddChildListenSocket(socket_uuid); + l->socket_uuid = 0; + if (node != nullptr) { + l->socket_uuid = node->uuid(); + if (server->channelz_server != nullptr) { + server->channelz_server->AddChildListenSocket(std::move(node)); + } } l->next = server->listeners; server->listeners = l; diff --git a/src/core/lib/surface/server.h b/src/core/lib/surface/server.h index 67ad0310a96..2285821e11b 100644 --- a/src/core/lib/surface/server.h +++ b/src/core/lib/surface/server.h @@ -34,13 +34,12 @@ extern grpc_core::TraceFlag grpc_server_channel_trace; /* Add a listener to the server: when the server starts, it will call start, and when it shuts down, it will call destroy */ -void grpc_server_add_listener(grpc_server* server, void* listener, - void (*start)(grpc_server* server, void* arg, - grpc_pollset** pollsets, - size_t npollsets), - void (*destroy)(grpc_server* server, void* arg, - grpc_closure* on_done), - intptr_t socket_uuid); +void grpc_server_add_listener( + grpc_server* server, void* listener_arg, + void (*start)(grpc_server* server, void* arg, grpc_pollset** pollsets, + size_t npollsets), + void (*destroy)(grpc_server* server, void* arg, grpc_closure* on_done), + grpc_core::RefCountedPtr node); /* Setup a transport - creates a channel stack, binds the transport to the server */ diff --git a/test/core/channel/channelz_registry_test.cc b/test/core/channel/channelz_registry_test.cc index deb85d85624..995182da249 100644 --- a/test/core/channel/channelz_registry_test.cc +++ b/test/core/channel/channelz_registry_test.cc @@ -53,7 +53,7 @@ class ChannelzRegistryTest : public ::testing::Test { TEST_F(ChannelzRegistryTest, UuidStartsAboveZeroTest) { RefCountedPtr channelz_channel = - MakeRefCounted(BaseNode::EntityType::kTopLevelChannel); + MakeRefCounted(BaseNode::EntityType::kTopLevelChannel, nullptr); intptr_t uuid = channelz_channel->uuid(); EXPECT_GT(uuid, 0) << "First uuid chose must be greater than zero. Zero if " "reserved according to " @@ -65,8 +65,8 @@ TEST_F(ChannelzRegistryTest, UuidsAreIncreasing) { std::vector> channelz_channels; channelz_channels.reserve(10); for (int i = 0; i < 10; ++i) { - channelz_channels.push_back( - MakeRefCounted(BaseNode::EntityType::kTopLevelChannel)); + channelz_channels.push_back(MakeRefCounted( + BaseNode::EntityType::kTopLevelChannel, nullptr)); } for (size_t i = 1; i < channelz_channels.size(); ++i) { EXPECT_LT(channelz_channels[i - 1]->uuid(), channelz_channels[i]->uuid()) @@ -76,7 +76,7 @@ TEST_F(ChannelzRegistryTest, UuidsAreIncreasing) { TEST_F(ChannelzRegistryTest, RegisterGetTest) { RefCountedPtr channelz_channel = - MakeRefCounted(BaseNode::EntityType::kTopLevelChannel); + MakeRefCounted(BaseNode::EntityType::kTopLevelChannel, nullptr); RefCountedPtr retrieved = ChannelzRegistry::Get(channelz_channel->uuid()); EXPECT_EQ(channelz_channel, retrieved); @@ -85,8 +85,8 @@ TEST_F(ChannelzRegistryTest, RegisterGetTest) { TEST_F(ChannelzRegistryTest, RegisterManyItems) { std::vector> channelz_channels; for (int i = 0; i < 100; i++) { - channelz_channels.push_back( - MakeRefCounted(BaseNode::EntityType::kTopLevelChannel)); + channelz_channels.push_back(MakeRefCounted( + BaseNode::EntityType::kTopLevelChannel, nullptr)); RefCountedPtr retrieved = ChannelzRegistry::Get(channelz_channels[i]->uuid()); EXPECT_EQ(channelz_channels[i], retrieved); @@ -95,7 +95,7 @@ TEST_F(ChannelzRegistryTest, RegisterManyItems) { TEST_F(ChannelzRegistryTest, NullIfNotPresentTest) { RefCountedPtr channelz_channel = - MakeRefCounted(BaseNode::EntityType::kTopLevelChannel); + MakeRefCounted(BaseNode::EntityType::kTopLevelChannel, nullptr); // try to pull out a uuid that does not exist. RefCountedPtr nonexistant = ChannelzRegistry::Get(channelz_channel->uuid() + 1); @@ -117,10 +117,10 @@ TEST_F(ChannelzRegistryTest, TestUnregistration) { std::vector> odd_channels; odd_channels.reserve(kLoopIterations); for (int i = 0; i < kLoopIterations; i++) { - even_channels.push_back( - MakeRefCounted(BaseNode::EntityType::kTopLevelChannel)); - odd_channels.push_back( - MakeRefCounted(BaseNode::EntityType::kTopLevelChannel)); + even_channels.push_back(MakeRefCounted( + BaseNode::EntityType::kTopLevelChannel, nullptr)); + odd_channels.push_back(MakeRefCounted( + BaseNode::EntityType::kTopLevelChannel, nullptr)); odd_uuids.push_back(odd_channels[i]->uuid()); } } @@ -137,8 +137,8 @@ TEST_F(ChannelzRegistryTest, TestUnregistration) { std::vector> more_channels; more_channels.reserve(kLoopIterations); for (int i = 0; i < kLoopIterations; i++) { - more_channels.push_back( - MakeRefCounted(BaseNode::EntityType::kTopLevelChannel)); + more_channels.push_back(MakeRefCounted( + BaseNode::EntityType::kTopLevelChannel, nullptr)); RefCountedPtr retrieved = ChannelzRegistry::Get(more_channels[i]->uuid()); EXPECT_EQ(more_channels[i], retrieved); diff --git a/test/cpp/end2end/channelz_service_test.cc b/test/cpp/end2end/channelz_service_test.cc index 69c56c574f9..1ed2d8c65f2 100644 --- a/test/cpp/end2end/channelz_service_test.cc +++ b/test/cpp/end2end/channelz_service_test.cc @@ -571,6 +571,8 @@ TEST_F(ChannelzServerTest, ManySubchannelsAndSockets) { get_subchannel_resp.subchannel().socket_ref(0).socket_id()); s = channelz_stub_->GetSocket(&get_socket_ctx, get_socket_req, &get_socket_resp); + EXPECT_TRUE( + get_subchannel_resp.subchannel().socket_ref(0).name().find("http")); EXPECT_TRUE(s.ok()) << s.error_message(); // calls started == streams started AND stream succeeded. Since none of // these RPCs were canceled, all of the streams will succeeded even though @@ -626,6 +628,8 @@ TEST_F(ChannelzServerTest, StreamingRPC) { ClientContext get_socket_context; get_socket_request.set_socket_id( get_subchannel_response.subchannel().socket_ref(0).socket_id()); + EXPECT_TRUE( + get_subchannel_response.subchannel().socket_ref(0).name().find("http")); s = channelz_stub_->GetSocket(&get_socket_context, get_socket_request, &get_socket_response); EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); @@ -659,6 +663,7 @@ TEST_F(ChannelzServerTest, GetServerSocketsTest) { &get_server_sockets_response); EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); EXPECT_EQ(get_server_sockets_response.socket_ref_size(), 1); + EXPECT_TRUE(get_server_sockets_response.socket_ref(0).name().find("http")); } TEST_F(ChannelzServerTest, GetServerSocketsPaginationTest) { @@ -738,6 +743,8 @@ TEST_F(ChannelzServerTest, GetServerListenSocketsTest) { GetSocketResponse get_socket_response; get_socket_request.set_socket_id( get_server_response.server(0).listen_socket(0).socket_id()); + EXPECT_TRUE( + get_server_response.server(0).listen_socket(0).name().find("http")); ClientContext get_socket_context; s = channelz_stub_->GetSocket(&get_socket_context, get_socket_request, &get_socket_response); From 44868ae12ad93544bd483360fe6b2e49054caf5b Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Tue, 30 Jul 2019 16:28:14 -0700 Subject: [PATCH 1048/1555] Starting a new branch with same changes from https://github.com/grpc/grpc/pull/19621 --- WORKSPACE | 7 + bazel/generate_objc.bzl | 215 +++++++++ bazel/grpc_build_system.bzl | 50 +++ bazel/grpc_deps.bzl | 8 + bazel/grpc_util.bzl | 46 ++ bazel/objc_grpc_library.bzl | 68 +++ src/objective-c/BUILD | 96 ++++ src/objective-c/examples/BUILD | 69 +++ .../BazelBuildSamples/ios-sample/Podfile | 31 ++ .../ios-sample.xcodeproj/project.pbxproj | 413 ++++++++++++++++++ .../ios-sample/ios-sample/AppDelegate.h | 25 ++ .../ios-sample/ios-sample/AppDelegate.m | 63 +++ .../AppIcon.appiconset/Contents.json | 98 +++++ .../ios-sample/Assets.xcassets/Contents.json | 6 + .../Base.lproj/LaunchScreen.storyboard | 25 ++ .../ios-sample/Base.lproj/Main.storyboard | 38 ++ .../ios-sample/ios-sample/Info.plist | 45 ++ .../ios-sample/ios-sample/ViewController.h | 23 + .../ios-sample/ios-sample/ViewController.m | 86 ++++ .../ios-sample/ios-sample/main.m | 26 ++ .../examples/BazelBuildSamples/messages.proto | 118 +++++ .../examples/BazelBuildSamples/rmt/BUILD | 28 ++ .../examples/BazelBuildSamples/rmt/test.proto | 57 +++ 23 files changed, 1641 insertions(+) create mode 100644 bazel/generate_objc.bzl create mode 100644 bazel/grpc_util.bzl create mode 100644 bazel/objc_grpc_library.bzl create mode 100644 src/objective-c/BUILD create mode 100644 src/objective-c/examples/BUILD create mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/Podfile create mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample.xcodeproj/project.pbxproj create mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/AppDelegate.h create mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/AppDelegate.m create mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Assets.xcassets/Contents.json create mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Base.lproj/LaunchScreen.storyboard create mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Base.lproj/Main.storyboard create mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Info.plist create mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/ViewController.h create mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/ViewController.m create mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/main.m create mode 100644 src/objective-c/examples/BazelBuildSamples/messages.proto create mode 100644 src/objective-c/examples/BazelBuildSamples/rmt/BUILD create mode 100644 src/objective-c/examples/BazelBuildSamples/rmt/test.proto diff --git a/WORKSPACE b/WORKSPACE index e8ec470efec..6cfa9d67b75 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -76,3 +76,10 @@ api_dependencies() load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains") go_rules_dependencies() go_register_toolchains() + + +load("@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies") +apple_rules_dependencies() + +load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies") +apple_support_dependencies() \ No newline at end of file diff --git a/bazel/generate_objc.bzl b/bazel/generate_objc.bzl new file mode 100644 index 00000000000..6140015a1fa --- /dev/null +++ b/bazel/generate_objc.bzl @@ -0,0 +1,215 @@ +load( + "//bazel:protobuf.bzl", + "get_include_protoc_args", + "get_plugin_args", + "proto_path_to_generated_filename", +) +load(":grpc_util.bzl", "to_upper_camel_with_extension",) + +_GRPC_PROTO_HEADER_FMT = "{}.pbrpc.h" +_GRPC_PROTO_SRC_FMT = "{}.pbrpc.m" +_PROTO_HEADER_FMT = "{}.pbobjc.h" +_PROTO_SRC_FMT = "{}.pbobjc.m" +_GENERATED_PROTOS_DIR = "_generated_protos" + +_GENERATE_HDRS = 1 +_GENERATE_SRCS = 2 +_GENERATE_NON_ARC_SRCS = 3 + +def _generate_objc_impl(ctx): + """Implementation of the generate_objc rule.""" + protos = [ + f + for src in ctx.attr.deps + for f in src[ProtoInfo].transitive_imports.to_list() + ] + + target_package = _join_directories([ctx.label.workspace_root, ctx.label.package]) + + files_with_rpc = [_label_to_full_file_path(f, target_package) for f in ctx.attr.srcs] + + outs = [] + for proto in protos: + outs += [_get_output_file_name_from_proto(proto, _PROTO_HEADER_FMT)] + outs += [_get_output_file_name_from_proto(proto, _PROTO_SRC_FMT)] + + file_path = _get_full_path_from_file(proto) + if file_path in files_with_rpc: + outs += [_get_output_file_name_from_proto(proto, _GRPC_PROTO_HEADER_FMT)] + outs += [_get_output_file_name_from_proto(proto, _GRPC_PROTO_SRC_FMT)] + + out_files = [ctx.actions.declare_file(out) for out in outs] + dir_out = _join_directories([ + str(ctx.genfiles_dir.path), target_package, _GENERATED_PROTOS_DIR + ]) + + arguments = [] + if ctx.executable.plugin: + arguments += get_plugin_args( + ctx.executable.plugin, + [], + dir_out, + False, + ) + tools = [ctx.executable.plugin] + arguments += ["--objc_out=" + dir_out] + + arguments += ["--proto_path=."] + arguments += get_include_protoc_args(protos) + # Include the output directory so that protoc puts the generated code in the + # right directory. + arguments += ["--proto_path={}".format(dir_out)] + arguments += ["--proto_path={}".format(_get_directory_from_proto(proto)) for proto in protos] + arguments += [_get_full_path_from_file(proto) for proto in protos] + + # create a list of well known proto files if the argument is non-None + well_known_proto_files = [] + if ctx.attr.use_well_known_protos: + f = ctx.attr.well_known_protos.files.to_list()[0].dirname + # go two levels up so that #import "google/protobuf/..." is correct + arguments += ["-I{0}".format(f + "/../..")] + well_known_proto_files = ctx.attr.well_known_protos.files.to_list() + ctx.actions.run( + inputs = protos + well_known_proto_files, + tools = tools, + outputs = out_files, + executable = ctx.executable._protoc, + arguments = arguments, + ) + + return struct(files = depset(out_files)) + +def _label_to_full_file_path(src, package): + if not src.startswith("//"): + # Relative from current package + if not src.startswith(":"): + # "a.proto" -> ":a.proto" + src = ":" + src + src = "//" + package + src + # Converts //path/to/package:File.ext to path/to/package/File.ext. + src = src.replace("//", "") + src = src.replace(":", "/") + if src.startswith("/"): + # "//:a.proto" -> "/a.proto" so remove the initial slash + return src[1:] + else: + return src + +def _get_output_file_name_from_proto(proto, fmt): + return proto_path_to_generated_filename( + _GENERATED_PROTOS_DIR + "/" + + _get_directory_from_proto(proto) + _get_slash_or_null_from_proto(proto) + + to_upper_camel_with_extension(_get_file_name_from_proto(proto), "proto"), + fmt, + ) + +def _get_file_name_from_proto(proto): + return proto.path.rpartition("/")[2] + +def _get_slash_or_null_from_proto(proto): + """Potentially returns empty (if the file is in the root directory)""" + return proto.path.rpartition("/")[1] + +def _get_directory_from_proto(proto): + return proto.path.rpartition("/")[0] + +def _get_full_path_from_file(file): + gen_dir_length = 0 + # if file is generated, then prepare to remote its root + # (including CPU architecture...) + if not file.is_source: + gen_dir_length = len(file.root.path) + 1 + + return file.path[gen_dir_length:] + +def _join_directories(directories): + massaged_directories = [directory for directory in directories if len(directory) != 0] + return "/".join(massaged_directories) + + +generate_objc = rule( + attrs = { + "deps": attr.label_list( + mandatory = True, + allow_empty = False, + providers = [ProtoInfo], + ), + "plugin": attr.label( + default = "@com_github_grpc_grpc//src/compiler:grpc_objective_c_plugin", + executable = True, + providers = ["files_to_run"], + cfg = "host", + ), + "srcs": attr.string_list( + mandatory = False, + allow_empty = True + ), + "use_well_known_protos": attr.bool( + mandatory = False, + default = False + ), + "well_known_protos": attr.label( + default = "@com_google_protobuf//:well_known_protos" + ), + "_protoc": attr.label( + default = Label("//external:protocol_compiler"), + executable = True, + cfg = "host", + ), + }, + output_to_genfiles = True, + implementation = _generate_objc_impl +) + +def _group_objc_files_impl(ctx): + suffix = "" + if ctx.attr.gen_mode == _GENERATE_HDRS: + suffix = "h" + elif ctx.attr.gen_mode == _GENERATE_SRCS: + suffix = "pbrpc.m" + elif ctx.attr.gen_mode == _GENERATE_NON_ARC_SRCS: + suffix = "pbobjc.m" + else: + fail("Undefined gen_mode") + out_files = [ + file + for file in ctx.attr.src.files.to_list() + if file.basename.endswith(suffix) + ] + return struct(files = depset(out_files)) + +generate_objc_hdrs = rule( + attrs = { + "src": attr.label( + mandatory = True, + ), + "gen_mode": attr.int( + default = _GENERATE_HDRS, + ) + }, + implementation = _group_objc_files_impl +) + +generate_objc_srcs = rule( + attrs = { + "src": attr.label( + mandatory = True, + ), + "gen_mode": attr.int( + default = _GENERATE_SRCS, + ) + }, + implementation = _group_objc_files_impl +) + +generate_objc_non_arc_srcs = rule( + attrs = { + "src": attr.label( + mandatory = True, + ), + "gen_mode": attr.int( + default = _GENERATE_NON_ARC_SRCS, + ) + }, + implementation = _group_objc_files_impl +) diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 9fc4b1a26db..9e967d8fa9a 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -24,6 +24,7 @@ # load("//bazel:cc_grpc_library.bzl", "cc_grpc_library") +load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle") load("@upb//bazel:upb_proto_library.bzl", "upb_proto_library") # The set of pollers to test against if a test exercises polling @@ -198,6 +199,19 @@ def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], da ) def grpc_generate_one_off_targets(): + apple_resource_bundle( + # The choice of name is signicant here, since it determines the bundle name. + name = "gRPCCertificates", + resources = ["etc/roots.pem"], + ) + + # In open-source, grpc_objc* libraries depend directly on //:grpc + native.alias( + name = "grpc_objc", + actual = "//:grpc", + ) + +def grpc_objc_use_cronet_config(): pass def grpc_sh_test(name, srcs, args = [], data = []): @@ -240,6 +254,42 @@ def grpc_package(name, visibility = "private", features = []): features = features, ) +def grpc_objc_library( + name, + srcs, + hdrs = [], + textual_hdrs = [], + data = [], + deps = [], + defines = [], + includes = [], + visibility = ["//visibility:public"]): + """The grpc version of objc_library, only used for the Objective-C library compilation + + Args: + name: name of target + hdrs: public headers + srcs: all source files (.m) + textual_hdrs: private headers + data: any other bundle resources + defines: preprocessors + includes: added to search path, always [the path to objc directory] + deps: dependencies + visibility: visibility, default to public + """ + + native.objc_library( + name = name, + hdrs = hdrs, + srcs = srcs, + textual_hdrs = textual_hdrs, + data = data, + deps = deps, + defines = defines, + includes = includes, + visibility = visibility, + ) + def grpc_upb_proto_library(name, deps): upb_proto_library(name = name, deps = deps) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index b8df184f734..cce2f88fe87 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -224,6 +224,14 @@ def grpc_deps(): urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.18.5/rules_go-0.18.5.tar.gz"], sha256 = "a82a352bffae6bee4e95f68a8d80a70e87f42c4741e6a448bec11998fcc82329", ) + + if "build_bazel_rules_apple" not in native.existing_rules(): + git_repository( + name = "build_bazel_rules_apple", + remote = "https://github.com/bazelbuild/rules_apple.git", + tag = "0.17.2", + ) + # TODO: move some dependencies from "grpc_deps" here? def grpc_test_only_deps(): """Internal, not intended for use by packages that are consuming grpc. diff --git a/bazel/grpc_util.bzl b/bazel/grpc_util.bzl new file mode 100644 index 00000000000..779747c8719 --- /dev/null +++ b/bazel/grpc_util.bzl @@ -0,0 +1,46 @@ +# Follows convention set in objectivec_helpers.cc in the protobuf ObjC compiler. +_upper_segments_list = ["url", "http", "https"] + +def strip_extension(str): + return str.rpartition(".")[0] + +def capitalize(word): + if word in _upper_segments_list: + return word.upper() + else: + return word.capitalize() + +def lower_underscore_to_upper_camel(str): + str = strip_extension(str) + camel_case_str = "" + word = "" + for c in str.elems(): # NB: assumes ASCII! + if c.isalpha(): + word += c.lower() + else: + # Last word is finished. + if len(word): + camel_case_str += capitalize(word) + word = "" + if c.isdigit(): + camel_case_str += c + + # Otherwise, drop the character. See UnderscoresToCamelCase in: + # third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc + + if len(word): + camel_case_str += capitalize(word) + return camel_case_str + +def file_to_upper_camel(src): + elements = src.rpartition("/") + upper_camel = lower_underscore_to_upper_camel(elements[-1]) + return "".join(list(elements[:-1]) + [upper_camel]) + +def file_with_extension(src, ext): + elements = src.rpartition("/") + return "".join(list(elements[:-1]) + [elements[-1], "." + ext]) + +def to_upper_camel_with_extension(src, ext): + src = file_to_upper_camel(src) + return file_with_extension(src, ext) diff --git a/bazel/objc_grpc_library.bzl b/bazel/objc_grpc_library.bzl new file mode 100644 index 00000000000..7647ab08053 --- /dev/null +++ b/bazel/objc_grpc_library.bzl @@ -0,0 +1,68 @@ +load( + "//bazel:generate_objc.bzl", + "generate_objc", + "generate_objc_hdrs", + "generate_objc_srcs", + "generate_objc_non_arc_srcs" +) +load("//bazel:protobuf.bzl", "well_known_proto_libs") + +def objc_grpc_library(name, deps, srcs = [], use_well_known_protos = False, **kwargs): + """Generates messages and/or service stubs for given proto_library and all transitively dependent proto files + + Args: + name: name of target + deps: a list of proto_library targets that needs to be compiled + srcs: a list of labels to proto files with service stubs to be generated, + labels specified must include service stubs; otherwise Bazel will complain about srcs being empty + use_well_known_protos: whether to use the well known protos defined in + @com_google_protobuf//src/google/protobuf, default to false + **kwargs: other arguments + """ + objc_grpc_library_name = "_" + name + "_objc_grpc_library" + + generate_objc( + name = objc_grpc_library_name, + srcs = srcs, + deps = deps, + use_well_known_protos = use_well_known_protos, + **kwargs + ) + + generate_objc_hdrs( + name = objc_grpc_library_name + "_hdrs", + src = ":" + objc_grpc_library_name, + ) + + generate_objc_non_arc_srcs( + name = objc_grpc_library_name + "_non_arc_srcs", + src = ":" + objc_grpc_library_name, + ) + + arc_srcs = None + if len(srcs) > 0: + generate_objc_srcs( + name = objc_grpc_library_name + "_srcs", + src = ":" + objc_grpc_library_name, + ) + arc_srcs = [":" + objc_grpc_library_name + "_srcs"] + + native.objc_library( + name = name, + hdrs = [":" + objc_grpc_library_name + "_hdrs"], + non_arc_srcs = [":" + objc_grpc_library_name + "_non_arc_srcs"], + srcs = arc_srcs, + defines = [ + "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0", + "GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO=0", + ], + includes = [ + "_generated_protos", + "src/objective-c", + ], + deps = [ + "@com_github_grpc_grpc//src/objective-c:proto_objc_rpc", + "@com_google_protobuf//:protobuf_objc", + ], + ) + diff --git a/src/objective-c/BUILD b/src/objective-c/BUILD new file mode 100644 index 00000000000..2492ce8a21f --- /dev/null +++ b/src/objective-c/BUILD @@ -0,0 +1,96 @@ +# gRPC Bazel BUILD file. +# +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +licenses(["notice"]) # Apache v2 + +package(default_visibility = ["//visibility:public"]) + +load("//bazel:grpc_build_system.bzl", "grpc_objc_library", "grpc_objc_use_cronet_config") + +exports_files(["LICENSE"]) + +grpc_objc_use_cronet_config() + +grpc_objc_library( + name = "rx_library", + srcs = glob([ + "RxLibrary/*.m", + "RxLibrary/transformations/*.m", + ]), + hdrs = glob([ + "RxLibrary/*.h", + "RxLibrary/transformations/*.h", + ]), + includes = ["."], + deps = [":rx_library_private"], +) + +grpc_objc_library( + name = "rx_library_private", + srcs = glob([ + "RxLibrary/private/*.m", + ]), + textual_hdrs = glob([ + "RxLibrary/private/*.h", + ]), + visibility = ["//visibility:private"], +) + +grpc_objc_library( + name = "grpc_objc_client", + srcs = glob( + [ + "GRPCClient/*.m", + "GRPCClient/private/*.m", + ], + exclude = ["GRPCClient/GRPCCall+GID.m"], + ), + hdrs = glob( + [ + "GRPCClient/*.h", + "GRPCClient/internal/*.h", + ], + exclude = ["GRPCClient/GRPCCall+GID.h"], + ), + data = ["//:gRPCCertificates"], + includes = ["."], + textual_hdrs = glob([ + "GRPCClient/private/*.h", + ]), + deps = [ + ":rx_library", + "//:grpc_objc", + ], +) + +grpc_objc_library( + name = "proto_objc_rpc", + srcs = glob( + ["ProtoRPC/*.m"], + ), + hdrs = glob( + ["ProtoRPC/*.h"], + ), + # Different from Cocoapods, do not import as if @com_google_protobuf//:protobuf_objc is a framework, + # use the real paths of @com_google_protobuf//:protobuf_objc instead + defines = ["GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0"], + includes = ["src/objective-c"], + deps = [ + ":grpc_objc_client", + ":rx_library", + "@com_google_protobuf//:protobuf_objc", + ], +) diff --git a/src/objective-c/examples/BUILD b/src/objective-c/examples/BUILD new file mode 100644 index 00000000000..27ddfcd6031 --- /dev/null +++ b/src/objective-c/examples/BUILD @@ -0,0 +1,69 @@ +# gRPC Bazel BUILD file. +# +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application") +load( + "@com_github_grpc_grpc//bazel:objc_grpc_library.bzl", + "objc_grpc_library", +) + +proto_library( + name = "messages_proto", + srcs = ["BazelBuildSamples/messages.proto"], + visibility = ["//visibility:public"], +) + +objc_grpc_library( + name = "test_grpc_objc", + srcs = ["BazelBuildSamples/rmt/test.proto"], + use_well_known_protos = True, + deps = [ + "//src/objective-c/examples/BazelBuildSamples/rmt:test_proto", + ], +) + +# Proof that without this works without srcs +objc_grpc_library( + name = "test_objc", + use_well_known_protos = True, + deps = [ + "//src/objective-c/examples/BazelBuildSamples/rmt:test_proto", + ] +) + +objc_library( + name = "ios-sample-lib", + srcs = glob(["BazelBuildSamples/ios-sample/ios-sample/**/*.m"]), + hdrs = glob(["BazelBuildSamples/ios-sample/ios-sample/**/*.h"]), + data = glob([ + "BazelBuildSamples/ios-sample/ios-sample/Assets.xcassets/**/*", + "BazelBuildSamples/ios-sample/ios-sample/Base.lproj/**/*" + ]), + deps = [ + ":test_grpc_objc", + ] +) + +ios_application( + name = "ios-sample", + bundle_id = "com.google.ios-sample-objc-bazel", + families = ["iphone"], + minimum_os_version = "9.0", + infoplists = ["BazelBuildSamples/ios-sample/ios-sample/Info.plist"], + visibility = ["//visibility:public"], + deps = [":ios-sample-lib"], +) \ No newline at end of file diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/Podfile b/src/objective-c/examples/BazelBuildSamples/ios-sample/Podfile new file mode 100644 index 00000000000..8648992d84f --- /dev/null +++ b/src/objective-c/examples/BazelBuildSamples/ios-sample/Podfile @@ -0,0 +1,31 @@ +platform :ios, '8.0' + +install! 'cocoapods', :deterministic_uuids => false + +ROOT_DIR = '../../../../..' + +target 'ios-sample' do + pod 'gRPC-ProtoRPC', :path => ROOT_DIR + pod 'gRPC', :path => ROOT_DIR + pod 'gRPC-Core', :path => ROOT_DIR + pod 'gRPC-RxLibrary', :path => ROOT_DIR + pod 'RemoteTest', :path => "../../RemoteTestClient" + pod '!ProtoCompiler-gRPCPlugin', :path => "#{ROOT_DIR}/src/objective-c" +end + +pre_install do |installer| + grpc_core_spec = installer.pod_targets.find{|t| t.name.start_with?('gRPC-Core')}.root_spec + + src_root = "$(PODS_TARGET_SRCROOT)" + grpc_core_spec.pod_target_xcconfig = { + 'GRPC_SRC_ROOT' => src_root, + 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"', + 'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"', + # If we don't set these two settings, `include/grpc/support/time.h` and + # `src/core/lib/gpr/string.h` shadow the system `` and ``, breaking the + # build. + 'USE_HEADERMAP' => 'NO', + 'ALWAYS_SEARCH_USER_PATHS' => 'NO', + } +end + diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample.xcodeproj/project.pbxproj b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample.xcodeproj/project.pbxproj new file mode 100644 index 00000000000..05344a69bfc --- /dev/null +++ b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample.xcodeproj/project.pbxproj @@ -0,0 +1,413 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + AB433CC922D7E38000D579CC /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = AB433CC822D7E38000D579CC /* AppDelegate.m */; }; + AB433CCC22D7E38000D579CC /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AB433CCB22D7E38000D579CC /* ViewController.m */; }; + AB433CCF22D7E38000D579CC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AB433CCD22D7E38000D579CC /* Main.storyboard */; }; + AB433CD122D7E38100D579CC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AB433CD022D7E38100D579CC /* Assets.xcassets */; }; + AB433CD422D7E38100D579CC /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AB433CD222D7E38100D579CC /* LaunchScreen.storyboard */; }; + AB433CD722D7E38100D579CC /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = AB433CD622D7E38100D579CC /* main.m */; }; + ED11F6CDF54788FC7CFD87B1 /* libPods-ios-sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5AF80A181E30BD84FA56BE33 /* libPods-ios-sample.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 112D4595FA3E81552DA9E877 /* Pods-ios-sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ios-sample.release.xcconfig"; path = "Target Support Files/Pods-ios-sample/Pods-ios-sample.release.xcconfig"; sourceTree = ""; }; + 5AF80A181E30BD84FA56BE33 /* libPods-ios-sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ios-sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 72599BE4AC5785D3368D40DD /* Pods-ios-sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ios-sample.debug.xcconfig"; path = "Target Support Files/Pods-ios-sample/Pods-ios-sample.debug.xcconfig"; sourceTree = ""; }; + AB433CC422D7E38000D579CC /* ios-sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ios-sample.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + AB433CC722D7E38000D579CC /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + AB433CC822D7E38000D579CC /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + AB433CCA22D7E38000D579CC /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + AB433CCB22D7E38000D579CC /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + AB433CCE22D7E38000D579CC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + AB433CD022D7E38100D579CC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + AB433CD322D7E38100D579CC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + AB433CD522D7E38100D579CC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + AB433CD622D7E38100D579CC /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + AB433CC122D7E38000D579CC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ED11F6CDF54788FC7CFD87B1 /* libPods-ios-sample.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 2A170580B60E92B1A65525D4 /* Pods */ = { + isa = PBXGroup; + children = ( + 72599BE4AC5785D3368D40DD /* Pods-ios-sample.debug.xcconfig */, + 112D4595FA3E81552DA9E877 /* Pods-ios-sample.release.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; + AB433CBB22D7E38000D579CC = { + isa = PBXGroup; + children = ( + AB433CC622D7E38000D579CC /* ios-sample */, + AB433CC522D7E38000D579CC /* Products */, + 2A170580B60E92B1A65525D4 /* Pods */, + FD148AE940967C50DB2C12CB /* Frameworks */, + ); + sourceTree = ""; + }; + AB433CC522D7E38000D579CC /* Products */ = { + isa = PBXGroup; + children = ( + AB433CC422D7E38000D579CC /* ios-sample.app */, + ); + name = Products; + sourceTree = ""; + }; + AB433CC622D7E38000D579CC /* ios-sample */ = { + isa = PBXGroup; + children = ( + AB433CC722D7E38000D579CC /* AppDelegate.h */, + AB433CC822D7E38000D579CC /* AppDelegate.m */, + AB433CCA22D7E38000D579CC /* ViewController.h */, + AB433CCB22D7E38000D579CC /* ViewController.m */, + AB433CCD22D7E38000D579CC /* Main.storyboard */, + AB433CD022D7E38100D579CC /* Assets.xcassets */, + AB433CD222D7E38100D579CC /* LaunchScreen.storyboard */, + AB433CD522D7E38100D579CC /* Info.plist */, + AB433CD622D7E38100D579CC /* main.m */, + ); + path = "ios-sample"; + sourceTree = ""; + }; + FD148AE940967C50DB2C12CB /* Frameworks */ = { + isa = PBXGroup; + children = ( + 5AF80A181E30BD84FA56BE33 /* libPods-ios-sample.a */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + AB433CC322D7E38000D579CC /* ios-sample */ = { + isa = PBXNativeTarget; + buildConfigurationList = AB433CDA22D7E38100D579CC /* Build configuration list for PBXNativeTarget "ios-sample" */; + buildPhases = ( + 9DD34A50D448CD3F464D4A3C /* [CP] Check Pods Manifest.lock */, + AB433CC022D7E38000D579CC /* Sources */, + AB433CC122D7E38000D579CC /* Frameworks */, + AB433CC222D7E38000D579CC /* Resources */, + 630985F7228D41528084692C /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "ios-sample"; + productName = "ios-sample"; + productReference = AB433CC422D7E38000D579CC /* ios-sample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + AB433CBC22D7E38000D579CC /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1010; + ORGANIZATIONNAME = "Tony Lu"; + TargetAttributes = { + AB433CC322D7E38000D579CC = { + CreatedOnToolsVersion = 10.1; + }; + }; + }; + buildConfigurationList = AB433CBF22D7E38000D579CC /* Build configuration list for PBXProject "ios-sample" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = AB433CBB22D7E38000D579CC; + productRefGroup = AB433CC522D7E38000D579CC /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + AB433CC322D7E38000D579CC /* ios-sample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + AB433CC222D7E38000D579CC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + AB433CD422D7E38100D579CC /* LaunchScreen.storyboard in Resources */, + AB433CD122D7E38100D579CC /* Assets.xcassets in Resources */, + AB433CCF22D7E38000D579CC /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 630985F7228D41528084692C /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-ios-sample/Pods-ios-sample-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-ios-sample/Pods-ios-sample-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ios-sample/Pods-ios-sample-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 9DD34A50D448CD3F464D4A3C /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-ios-sample-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + AB433CC022D7E38000D579CC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + AB433CCC22D7E38000D579CC /* ViewController.m in Sources */, + AB433CD722D7E38100D579CC /* main.m in Sources */, + AB433CC922D7E38000D579CC /* AppDelegate.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + AB433CCD22D7E38000D579CC /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + AB433CCE22D7E38000D579CC /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + AB433CD222D7E38100D579CC /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + AB433CD322D7E38100D579CC /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + AB433CD822D7E38100D579CC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + AB433CD922D7E38100D579CC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + AB433CDB22D7E38100D579CC /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 72599BE4AC5785D3368D40DD /* Pods-ios-sample.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6T98ZJNPG5; + INFOPLIST_FILE = "ios-sample/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.google.ios-sample-objc-bazel"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + AB433CDC22D7E38100D579CC /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 112D4595FA3E81552DA9E877 /* Pods-ios-sample.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6T98ZJNPG5; + INFOPLIST_FILE = "ios-sample/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.google.ios-sample-objc-bazel"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + AB433CBF22D7E38000D579CC /* Build configuration list for PBXProject "ios-sample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + AB433CD822D7E38100D579CC /* Debug */, + AB433CD922D7E38100D579CC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + AB433CDA22D7E38100D579CC /* Build configuration list for PBXNativeTarget "ios-sample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + AB433CDB22D7E38100D579CC /* Debug */, + AB433CDC22D7E38100D579CC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = AB433CBC22D7E38000D579CC /* Project object */; +} diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/AppDelegate.h b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/AppDelegate.h new file mode 100644 index 00000000000..183abcf4ec8 --- /dev/null +++ b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/AppDelegate.h @@ -0,0 +1,25 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import + +@interface AppDelegate : UIResponder + +@property(strong, nonatomic) UIWindow* window; + +@end diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/AppDelegate.m b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/AppDelegate.m new file mode 100644 index 00000000000..d78f5f2175c --- /dev/null +++ b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/AppDelegate.m @@ -0,0 +1,63 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application + didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application { + // Sent when the application is about to move from active to inactive state. This can occur for + // certain types of temporary interruptions (such as an incoming phone call or SMS message) or + // when the user quits the application and it begins the transition to the background state. Use + // this method to pause ongoing tasks, disable timers, and invalidate graphics rendering + // callbacks. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // Use this method to release shared resources, save user data, invalidate timers, and store + // enough application state information to restore your application to its current state in case + // it is terminated later. If your application supports background execution, this method is + // called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the active state; here you can undo + // many of the changes made on entering the background. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If + // the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also + // applicationDidEnterBackground:. +} + +@end diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Assets.xcassets/AppIcon.appiconset/Contents.json b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000000..d8db8d65fd7 --- /dev/null +++ b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Assets.xcassets/Contents.json b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Assets.xcassets/Contents.json new file mode 100644 index 00000000000..da4a164c918 --- /dev/null +++ b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Base.lproj/LaunchScreen.storyboard b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000000..bfa36129419 --- /dev/null +++ b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Base.lproj/Main.storyboard b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Base.lproj/Main.storyboard new file mode 100644 index 00000000000..5e257390b33 --- /dev/null +++ b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Base.lproj/Main.storyboard @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Info.plist b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Info.plist new file mode 100644 index 00000000000..e5d82108923 --- /dev/null +++ b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + en_US + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/ViewController.h b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/ViewController.h new file mode 100644 index 00000000000..0aa0b2a73a7 --- /dev/null +++ b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/ViewController.h @@ -0,0 +1,23 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import + +@interface ViewController : UIViewController + +@end diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/ViewController.m b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/ViewController.m new file mode 100644 index 00000000000..6cb5a0be9df --- /dev/null +++ b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/ViewController.m @@ -0,0 +1,86 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "ViewController.h" + +#import +#if COCOAPODS +#import +#import +#else +#import "src/objective-c/examples/BazelBuildSamples/Messages.pbobjc.h" +#import "src/objective-c/examples/BazelBuildSamples/rmt/Test.pbrpc.h" +#endif + +static NSString *const kPackage = @"grpc.testing"; +static NSString *const kService = @"TestService"; + +@interface ViewController () + +@end + +@implementation ViewController { + GRPCCallOptions *_options; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // optionally modify options + _options = options; +} + +- (IBAction)tapCall:(id)sender { + GRPCProtoMethod *kUnaryCallMethod = + [[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"UnaryCall"]; + + GRPCRequestOptions *requestOptions = + [[GRPCRequestOptions alloc] initWithHost:@"grpc-test.sandbox.googleapis.com" + path:kUnaryCallMethod.HTTPPath + safety:GRPCCallSafetyCacheableRequest]; + + GRPCCall2 *call = [[GRPCCall2 alloc] initWithRequestOptions:requestOptions + responseHandler:self + callOptions:_options]; + + RMTSimpleRequest *request = [RMTSimpleRequest message]; + request.responseSize = 100; + + [call start]; + [call writeData:[request data]]; + [call finish]; +} + +- (dispatch_queue_t)dispatchQueue { + return dispatch_get_main_queue(); +} + +- (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata { + NSLog(@"Header: %@", initialMetadata); +} + +- (void)didReceiveData:(id)data { + NSLog(@"Message: %@", data); +} + +- (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { + NSLog(@"Trailer: %@\nError: %@", trailingMetadata, error); +} + +@end diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/main.m b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/main.m new file mode 100644 index 00000000000..2797c6f17f2 --- /dev/null +++ b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/main.m @@ -0,0 +1,26 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import +#import "AppDelegate.h" + +int main(int argc, char* argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/src/objective-c/examples/BazelBuildSamples/messages.proto b/src/objective-c/examples/BazelBuildSamples/messages.proto new file mode 100644 index 00000000000..128efd9337e --- /dev/null +++ b/src/objective-c/examples/BazelBuildSamples/messages.proto @@ -0,0 +1,118 @@ +// Copyright 2015 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Message definitions to be used by integration test service definitions. + +syntax = "proto3"; + +package grpc.testing; + +option objc_class_prefix = "RMT"; + +// The type of payload that should be returned. +enum PayloadType { + // Compressable text format. + COMPRESSABLE = 0; + + // Uncompressable binary format. + UNCOMPRESSABLE = 1; + + // Randomly chosen from all other formats defined in this enum. + RANDOM = 2; +} + +// A block of data, to simply increase gRPC message size. +message Payload { + // The type of data in body. + PayloadType type = 1; + // Primary contents of payload. + bytes body = 2; +} + +// Unary request. +message SimpleRequest { + // Desired payload type in the response from the server. + // If response_type is RANDOM, server randomly chooses one from other formats. + PayloadType response_type = 1; + + // Desired payload size in the response from the server. + // If response_type is COMPRESSABLE, this denotes the size before compression. + int32 response_size = 2; + + // Optional input payload sent along with the request. + Payload payload = 3; + + // Whether SimpleResponse should include username. + bool fill_username = 4; + + // Whether SimpleResponse should include OAuth scope. + bool fill_oauth_scope = 5; +} + +// Unary response, as configured by the request. +message SimpleResponse { + // Payload to increase message size. + Payload payload = 1; + // The user the request came from, for verifying authentication was + // successful when the client expected it. + string username = 2; + // OAuth scope. + string oauth_scope = 3; +} + +// Client-streaming request. +message StreamingInputCallRequest { + // Optional input payload sent along with the request. + Payload payload = 1; + + // Not expecting any payload from the response. +} + +// Client-streaming response. +message StreamingInputCallResponse { + // Aggregated size of payloads received from the client. + int32 aggregated_payload_size = 1; +} + +// Configuration for a particular response. +message ResponseParameters { + // Desired payload sizes in responses from the server. + // If response_type is COMPRESSABLE, this denotes the size before compression. + int32 size = 1; + + // Desired interval between consecutive responses in the response stream in + // microseconds. + int32 interval_us = 2; +} + +// Server-streaming request. +message StreamingOutputCallRequest { + // Desired payload type in the response from the server. + // If response_type is RANDOM, the payload from each response in the stream + // might be of different types. This is to simulate a mixed type of payload + // stream. + PayloadType response_type = 1; + + // Configuration for each expected response message. + repeated ResponseParameters response_parameters = 2; + + // Optional input payload sent along with the request. + Payload payload = 3; +} + +// Server-streaming response, as configured by the request and parameters. +message StreamingOutputCallResponse { + // Payload to increase response size. + Payload payload = 1; +} diff --git a/src/objective-c/examples/BazelBuildSamples/rmt/BUILD b/src/objective-c/examples/BazelBuildSamples/rmt/BUILD new file mode 100644 index 00000000000..5264196c08e --- /dev/null +++ b/src/objective-c/examples/BazelBuildSamples/rmt/BUILD @@ -0,0 +1,28 @@ +# gRPC Bazel BUILD file. +# +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +licenses(["notice"]) # Apache v2 + +package(default_visibility = ["//visibility:public"]) + +exports_files(["LICENSE"]) + +proto_library( + name = "test_proto", + srcs = ["test.proto"], + deps = ["//src/objective-c/examples:messages_proto"], + visibility = ["//visibility:public"], +) \ No newline at end of file diff --git a/src/objective-c/examples/BazelBuildSamples/rmt/test.proto b/src/objective-c/examples/BazelBuildSamples/rmt/test.proto new file mode 100644 index 00000000000..ddc511e1428 --- /dev/null +++ b/src/objective-c/examples/BazelBuildSamples/rmt/test.proto @@ -0,0 +1,57 @@ +// Copyright 2015 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// An integration test service that covers all the method signature permutations +// of unary/streaming requests/responses. +syntax = "proto3"; + +import "google/protobuf/empty.proto"; +import "src/objective-c/examples/BazelBuildSamples/messages.proto"; + +package grpc.testing; + +option objc_class_prefix = "RMT"; + +// A simple service to test the various types of RPCs and experiment with +// performance with various types of payload. +service TestService { + // One empty request followed by one empty response. + rpc EmptyCall(google.protobuf.Empty) returns (google.protobuf.Empty); + + // One request followed by one response. + rpc UnaryCall(SimpleRequest) returns (SimpleResponse); + + // One request followed by a sequence of responses (streamed download). + // The server returns the payload with client desired type and sizes. + rpc StreamingOutputCall(StreamingOutputCallRequest) + returns (stream StreamingOutputCallResponse); + + // A sequence of requests followed by one response (streamed upload). + // The server returns the aggregated size of client payload as the result. + rpc StreamingInputCall(stream StreamingInputCallRequest) + returns (StreamingInputCallResponse); + + // A sequence of requests with each request served by the server immediately. + // As one request could lead to multiple responses, this interface + // demonstrates the idea of full duplexing. + rpc FullDuplexCall(stream StreamingOutputCallRequest) + returns (stream StreamingOutputCallResponse); + + // A sequence of requests followed by a sequence of responses. + // The server buffers all the client requests and then serves them in order. A + // stream of responses are returned to the client when the server starts with + // first request. + rpc HalfDuplexCall(stream StreamingOutputCallRequest) + returns (stream StreamingOutputCallResponse); +} From 557446a11e6679d1eb800c549d40e2fc2898fda0 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Mon, 24 Jun 2019 17:59:26 -0700 Subject: [PATCH 1049/1555] Added specializations for grpc_mdelem_create. In several cases, we create grpc mdelem structures using known-static metadata inputs. Furthermore, in several cases we create a slice on the heap (e.g. grpc_slice_from_copied_buffer) where we know we are transferring refcount ownership. In several cases, then, we can: 1) Avoid unnecessary ref/unref operations that are no-ops (for static slices) or superfluous (if we're transferring ownership). 2) Avoid unnecessarily comprehensive calls to grpc_slice_eq (since they'd only be called with static or interned slice arguments, which by construction would have equal refcounts if they were in fact equal. 3) Avoid unnecessary checks to see if a slice is interned (when we know that they are). To avoid polluting the internal API, we introduce the notion of strongly-typed grpc_slice objects. We draw a distinction between Internal (interned and static-storage) slices and Extern (inline and non-statically allocated). We introduce overloads to grpc_mdelem_create() and grpc_mdelem_from_slices() for the fastpath cases identified above based on these slice types. From the programmer's point of view, though, nothing changes - they need only use grpc_mdelem_create() and grpc_mdelem_from_slices() as before, and the appropriate fastpath will be picked based on type inference. If no special knowledge exists for the slice type (i.e. we pass in generic grpc_slice objects), the slowpath method will still always return correct behaviour. This is good for: - Roughly 1-3% reduction in CPU time for several unary/streaming ping pong fullstack microbenchmarks. - Reduction of about 15-20% in CPU time for some hpack parser microbenchmarks. - 10-12% reduction of CPU time for metadata microbenchmarks involving interned slice comparisons. --- .../filters/client_channel/client_channel.cc | 4 +- .../filters/http/client/http_client_filter.cc | 9 +- .../filters/http/client_authority_filter.cc | 6 +- .../chttp2/transport/chttp2_transport.cc | 2 +- .../chttp2/transport/hpack_encoder.cc | 4 +- .../chttp2/transport/hpack_parser.cc | 73 +- .../ext/transport/inproc/inproc_transport.cc | 2 +- .../credentials/oauth2/oauth2_credentials.cc | 8 +- src/core/lib/slice/slice.cc | 82 +- src/core/lib/slice/slice_intern.cc | 177 ++- src/core/lib/slice/slice_internal.h | 17 +- src/core/lib/slice/slice_utils.h | 120 ++ src/core/lib/surface/channel.cc | 12 +- src/core/lib/surface/lame_client.cc | 4 +- src/core/lib/transport/error_utils.cc | 2 +- src/core/lib/transport/metadata.cc | 232 +++- src/core/lib/transport/metadata.h | 78 +- src/core/lib/transport/static_metadata.cc | 1084 +++++++++++------ src/core/lib/transport/static_metadata.h | 6 +- src/cpp/ext/filters/census/client_filter.cc | 2 +- src/cpp/ext/filters/census/server_filter.cc | 2 +- test/cpp/microbenchmarks/bm_metadata.cc | 76 +- tools/codegen/core/gen_static_metadata.py | 18 +- 23 files changed, 1430 insertions(+), 590 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 8234237cc19..7aafca6f8ae 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -329,8 +329,8 @@ class CallData { grpc_linked_mdelem* linked_mdelem = static_cast( calld_->arena_->Alloc(sizeof(grpc_linked_mdelem))); linked_mdelem->md = grpc_mdelem_from_slices( - grpc_slice_from_static_buffer_internal(key.data(), key.size()), - grpc_slice_from_static_buffer_internal(value.data(), value.size())); + grpc_core::ExternallyManagedSlice(key.data(), key.size()), + grpc_core::ExternallyManagedSlice(value.data(), value.size())); GPR_ASSERT(grpc_metadata_batch_link_tail(batch_, linked_mdelem) == GRPC_ERROR_NONE); } diff --git a/src/core/ext/filters/http/client/http_client_filter.cc b/src/core/ext/filters/http/client/http_client_filter.cc index d014460b34e..9ec7aaf4ec8 100644 --- a/src/core/ext/filters/http/client/http_client_filter.cc +++ b/src/core/ext/filters/http/client/http_client_filter.cc @@ -304,7 +304,7 @@ static grpc_error* update_path_for_get(grpc_call_element* elem, estimated_len += grpc_base64_estimate_encoded_size( batch->payload->send_message.send_message->length(), true /* url_safe */, false /* multi_line */); - grpc_slice path_with_query_slice = GRPC_SLICE_MALLOC(estimated_len); + grpc_core::UnmanagedMemorySlice path_with_query_slice(estimated_len); /* memcopy individual pieces into this slice */ char* write_ptr = reinterpret_cast GRPC_SLICE_START_PTR(path_with_query_slice); @@ -514,13 +514,12 @@ static size_t max_payload_size_from_args(const grpc_channel_args* args) { return kMaxPayloadSizeForGet; } -static grpc_slice user_agent_from_args(const grpc_channel_args* args, - const char* transport_name) { +static grpc_core::ManagedMemorySlice user_agent_from_args( + const grpc_channel_args* args, const char* transport_name) { gpr_strvec v; size_t i; int is_first = 1; char* tmp; - grpc_slice result; gpr_strvec_init(&v); @@ -558,7 +557,7 @@ static grpc_slice user_agent_from_args(const grpc_channel_args* args, tmp = gpr_strvec_flatten(&v, nullptr); gpr_strvec_destroy(&v); - result = grpc_slice_intern(grpc_slice_from_static_string_internal(tmp)); + grpc_core::ManagedMemorySlice result(tmp); gpr_free(tmp); return result; diff --git a/src/core/ext/filters/http/client_authority_filter.cc b/src/core/ext/filters/http/client_authority_filter.cc index 4bd666ecfee..13c6ce58fec 100644 --- a/src/core/ext/filters/http/client_authority_filter.cc +++ b/src/core/ext/filters/http/client_authority_filter.cc @@ -44,7 +44,7 @@ struct call_data { }; struct channel_data { - grpc_slice default_authority; + grpc_core::ManagedMemorySlice default_authority; grpc_mdelem default_authority_mdelem; }; @@ -101,8 +101,8 @@ grpc_error* init_channel_elem(grpc_channel_element* elem, return GRPC_ERROR_CREATE_FROM_STATIC_STRING( "GRPC_ARG_DEFAULT_AUTHORITY channel arg. must be a string"); } - chand->default_authority = grpc_slice_intern( - grpc_slice_from_static_string_internal(default_authority_str)); + chand->default_authority = + grpc_core::ManagedMemorySlice(default_authority_str); chand->default_authority_mdelem = grpc_mdelem_create( GRPC_MDSTR_AUTHORITY, chand->default_authority, nullptr); GPR_ASSERT(!args->is_last); diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 43f2db1309f..92762ef859b 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -2152,7 +2152,7 @@ void grpc_chttp2_fake_status(grpc_chttp2_transport* t, grpc_chttp2_stream* s, &s->metadata_buffer[1], grpc_mdelem_from_slices( GRPC_MDSTR_GRPC_STATUS, - grpc_slice_from_copied_string(status_string)))); + grpc_core::UnmanagedMemorySlice(status_string)))); if (!GRPC_SLICE_IS_EMPTY(slice)) { GRPC_LOG_IF_ERROR( "add_status_message", diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc index 2b40b7b03ed..e46504d9b30 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc @@ -604,8 +604,8 @@ static void deadline_enc(grpc_chttp2_hpack_compressor* c, grpc_millis deadline, grpc_mdelem mdelem; grpc_http2_encode_timeout(deadline - grpc_core::ExecCtx::Get()->Now(), timeout_str); - mdelem = grpc_mdelem_from_slices(GRPC_MDSTR_GRPC_TIMEOUT, - grpc_slice_from_copied_string(timeout_str)); + mdelem = grpc_mdelem_from_slices( + GRPC_MDSTR_GRPC_TIMEOUT, grpc_core::UnmanagedMemorySlice(timeout_str)); hpack_enc(c, mdelem, st); GRPC_MDELEM_UNREF(mdelem); } diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index 32848929363..724c6c1bffc 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -660,24 +660,32 @@ static grpc_error* on_hdr(grpc_chttp2_hpack_parser* p, grpc_mdelem md) { return GRPC_ERROR_NONE; } -static grpc_slice take_string(grpc_chttp2_hpack_parser* p, - grpc_chttp2_hpack_parser_string* str, - bool intern) { - grpc_slice s; +static grpc_core::UnmanagedMemorySlice take_string_extern( + grpc_chttp2_hpack_parser* p, grpc_chttp2_hpack_parser_string* str) { + grpc_core::UnmanagedMemorySlice s; if (!str->copied) { - if (intern) { - s = grpc_slice_intern(str->data.referenced); - grpc_slice_unref_internal(str->data.referenced); - } else { - s = str->data.referenced; - } + GPR_DEBUG_ASSERT(!grpc_slice_is_interned(str->data.referenced)); + s = static_cast(str->data.referenced); + str->copied = true; + str->data.referenced = grpc_core::UnmanagedMemorySlice(); + } else { + s = grpc_core::UnmanagedMemorySlice(str->data.copied.str, + str->data.copied.length); + } + str->data.copied.length = 0; + return s; +} + +static grpc_core::ManagedMemorySlice take_string_intern( + grpc_chttp2_hpack_parser* p, grpc_chttp2_hpack_parser_string* str) { + grpc_core::ManagedMemorySlice s; + if (!str->copied) { + s = grpc_core::ManagedMemorySlice(&str->data.referenced); + grpc_slice_unref_internal(str->data.referenced); str->copied = true; str->data.referenced = grpc_empty_slice(); - } else if (intern) { - s = grpc_slice_intern(grpc_slice_from_static_buffer_internal( - str->data.copied.str, str->data.copied.length)); } else { - s = grpc_slice_from_copied_buffer(str->data.copied.str, + s = grpc_core::ManagedMemorySlice(str->data.copied.str, str->data.copied.length); } str->data.copied.length = 0; @@ -812,6 +820,12 @@ static grpc_mdelem get_precomputed_md_for_idx(grpc_chttp2_hpack_parser* p) { return md; } +static const grpc_core::ManagedMemorySlice& get_indexed_key(grpc_mdelem md) { + GPR_DEBUG_ASSERT(GRPC_MDELEM_IS_INTERNED(md)); + return static_cast( + grpc_slice_ref_internal(GRPC_MDKEY(md))); +} + /* finish a literal header with incremental indexing */ static grpc_error* finish_lithdr_incidx(grpc_chttp2_hpack_parser* p, const uint8_t* cur, @@ -819,8 +833,8 @@ static grpc_error* finish_lithdr_incidx(grpc_chttp2_hpack_parser* p, GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX(); grpc_mdelem md = get_precomputed_md_for_idx(p); grpc_error* err = on_hdr( - p, grpc_mdelem_from_slices(grpc_slice_ref_internal(GRPC_MDKEY(md)), - take_string(p, &p->value, true))); + p, grpc_mdelem_from_slices(get_indexed_key(md), + take_string_intern(p, &p->value))); if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err); return parse_begin(p, cur, end); } @@ -830,9 +844,9 @@ static grpc_error* finish_lithdr_incidx_v(grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end) { GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX_V(); - grpc_error* err = - on_hdr(p, grpc_mdelem_from_slices(take_string(p, &p->key, true), - take_string(p, &p->value, true))); + grpc_error* err = on_hdr( + p, grpc_mdelem_from_slices(take_string_intern(p, &p->key), + take_string_intern(p, &p->value))); if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err); return parse_begin(p, cur, end); } @@ -883,8 +897,8 @@ static grpc_error* finish_lithdr_notidx(grpc_chttp2_hpack_parser* p, GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX(); grpc_mdelem md = get_precomputed_md_for_idx(p); grpc_error* err = on_hdr( - p, grpc_mdelem_from_slices(grpc_slice_ref_internal(GRPC_MDKEY(md)), - take_string(p, &p->value, false))); + p, grpc_mdelem_from_slices(get_indexed_key(md), + take_string_extern(p, &p->value))); if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err); return parse_begin(p, cur, end); } @@ -895,8 +909,8 @@ static grpc_error* finish_lithdr_notidx_v(grpc_chttp2_hpack_parser* p, const uint8_t* end) { GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX_V(); grpc_error* err = on_hdr( - p, grpc_mdelem_from_slices(take_string(p, &p->key, true), - take_string(p, &p->value, false))); + p, grpc_mdelem_from_slices(take_string_intern(p, &p->key), + take_string_extern(p, &p->value))); if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err); return parse_begin(p, cur, end); } @@ -947,8 +961,8 @@ static grpc_error* finish_lithdr_nvridx(grpc_chttp2_hpack_parser* p, GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX(); grpc_mdelem md = get_precomputed_md_for_idx(p); grpc_error* err = on_hdr( - p, grpc_mdelem_from_slices(grpc_slice_ref_internal(GRPC_MDKEY(md)), - take_string(p, &p->value, false))); + p, grpc_mdelem_from_slices(get_indexed_key(md), + take_string_extern(p, &p->value))); if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err); return parse_begin(p, cur, end); } @@ -959,8 +973,8 @@ static grpc_error* finish_lithdr_nvridx_v(grpc_chttp2_hpack_parser* p, const uint8_t* end) { GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX_V(); grpc_error* err = on_hdr( - p, grpc_mdelem_from_slices(take_string(p, &p->key, true), - take_string(p, &p->value, false))); + p, grpc_mdelem_from_slices(take_string_intern(p, &p->key), + take_string_extern(p, &p->value))); if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err); return parse_begin(p, cur, end); } @@ -1510,13 +1524,12 @@ static grpc_error* parse_key_string(grpc_chttp2_hpack_parser* p, static bool is_binary_literal_header(grpc_chttp2_hpack_parser* p) { /* We know that either argument here is a reference counter slice. - * 1. If a result of grpc_slice_from_static_buffer_internal, the refcount is - * set to kNoopRefcount. + * 1. If it is a grpc_core::StaticSlice, the refcount is set to kNoopRefcount. * 2. If it's p->key.data.referenced, then p->key.copied was set to false, * which occurs in begin_parse_string() - where the refcount is set to * p->current_slice_refcount, which is not null. */ return grpc_is_refcounted_slice_binary_header( - p->key.copied ? grpc_slice_from_static_buffer_internal( + p->key.copied ? grpc_core::ExternallyManagedSlice( p->key.data.copied.str, p->key.data.copied.length) : p->key.data.referenced); } diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc index 8cb9ac4a2fd..a7f67879287 100644 --- a/src/core/ext/transport/inproc/inproc_transport.cc +++ b/src/core/ext/transport/inproc/inproc_transport.cc @@ -1203,7 +1203,7 @@ void inproc_transports_create(grpc_transport** server_transport, */ void grpc_inproc_transport_init(void) { grpc_core::ExecCtx exec_ctx; - g_empty_slice = grpc_slice_from_static_buffer_internal(nullptr, 0); + g_empty_slice = grpc_core::ExternallyManagedSlice(); grpc_slice key_tmp = grpc_slice_from_static_string(":path"); g_fake_path_key = grpc_slice_intern(key_tmp); diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc index 7a584835b96..87aa0357be7 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc @@ -199,8 +199,8 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response( *token_lifetime = strtol(expires_in->value, nullptr, 10) * GPR_MS_PER_SEC; if (!GRPC_MDISNULL(*token_md)) GRPC_MDELEM_UNREF(*token_md); *token_md = grpc_mdelem_from_slices( - grpc_slice_from_static_string(GRPC_AUTHORIZATION_METADATA_KEY), - grpc_slice_from_copied_string(new_access_token)); + grpc_core::ExternallyManagedSlice(GRPC_AUTHORIZATION_METADATA_KEY), + grpc_core::UnmanagedMemorySlice(new_access_token)); status = GRPC_CREDENTIALS_OK; } @@ -721,8 +721,8 @@ grpc_access_token_credentials::grpc_access_token_credentials( gpr_asprintf(&token_md_value, "Bearer %s", access_token); grpc_core::ExecCtx exec_ctx; access_token_md_ = grpc_mdelem_from_slices( - grpc_slice_from_static_string(GRPC_AUTHORIZATION_METADATA_KEY), - grpc_slice_from_copied_string(token_md_value)); + grpc_core::ExternallyManagedSlice(GRPC_AUTHORIZATION_METADATA_KEY), + grpc_core::UnmanagedMemorySlice(token_md_value)); gpr_free(token_md_value); } diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc index 57862518feb..d3480abaa87 100644 --- a/src/core/lib/slice/slice.cc +++ b/src/core/lib/slice/slice.cc @@ -37,12 +37,7 @@ char* grpc_slice_to_c_string(grpc_slice slice) { return out; } -grpc_slice grpc_empty_slice(void) { - grpc_slice out; - out.refcount = nullptr; - out.data.inlined.length = 0; - return out; -} +grpc_slice grpc_empty_slice(void) { return grpc_core::UnmanagedMemorySlice(); } grpc_slice grpc_slice_copy(grpc_slice s) { grpc_slice out = GRPC_SLICE_MALLOC(GRPC_SLICE_LENGTH(s)); @@ -112,11 +107,11 @@ size_t grpc_slice_memory_usage(grpc_slice s) { } grpc_slice grpc_slice_from_static_buffer(const void* s, size_t len) { - return grpc_slice_from_static_buffer_internal(s, len); + return grpc_core::ExternallyManagedSlice(s, len); } grpc_slice grpc_slice_from_static_string(const char* s) { - return grpc_slice_from_static_buffer_internal(s, strlen(s)); + return grpc_core::ExternallyManagedSlice(s, strlen(s)); } grpc_slice grpc_slice_new_with_user_data(void* p, size_t len, @@ -202,15 +197,29 @@ grpc_slice grpc_slice_new_with_len(void* p, size_t len, return slice; } +grpc_core::UnmanagedMemorySlice::UnmanagedMemorySlice(const char* source, + size_t length) { + if (length <= sizeof(data.inlined.bytes)) { + refcount = nullptr; + data.inlined.length = static_cast(length); + } else { + HeapInit(length); + } + if (length > 0) { + memcpy(GRPC_SLICE_START_PTR(*this), source, length); + } +} + +grpc_core::UnmanagedMemorySlice::UnmanagedMemorySlice(const char* source) + : grpc_core::UnmanagedMemorySlice::UnmanagedMemorySlice(source, + strlen(source)) {} + grpc_slice grpc_slice_from_copied_buffer(const char* source, size_t length) { - if (length == 0) return grpc_empty_slice(); - grpc_slice slice = GRPC_SLICE_MALLOC(length); - memcpy(GRPC_SLICE_START_PTR(slice), source, length); - return slice; + return grpc_core::UnmanagedMemorySlice(source, length); } grpc_slice grpc_slice_from_copied_string(const char* source) { - return grpc_slice_from_copied_buffer(source, strlen(source)); + return grpc_core::UnmanagedMemorySlice(source, strlen(source)); } grpc_slice grpc_slice_from_moved_buffer(grpc_core::UniquePtr p, @@ -261,8 +270,11 @@ class MallocRefCount { } // namespace grpc_slice grpc_slice_malloc_large(size_t length) { - grpc_slice slice; + return grpc_core::UnmanagedMemorySlice( + length, grpc_core::UnmanagedMemorySlice::ForceHeapAllocation()); +} +void grpc_core::UnmanagedMemorySlice::HeapInit(size_t length) { /* Memory layout used by the slice created here: +-----------+----------------------------------------------------------+ @@ -281,29 +293,30 @@ grpc_slice grpc_slice_malloc_large(size_t length) { /* Build up the slice to be returned. */ /* The slices refcount points back to the allocated block. */ - slice.refcount = rc->base_refcount(); + refcount = rc->base_refcount(); /* The data bytes are placed immediately after the refcount struct */ - slice.data.refcounted.bytes = reinterpret_cast(rc + 1); + data.refcounted.bytes = reinterpret_cast(rc + 1); /* And the length of the block is set to the requested length */ - slice.data.refcounted.length = length; - return slice; + data.refcounted.length = length; } grpc_slice grpc_slice_malloc(size_t length) { - grpc_slice slice; - - if (length > sizeof(slice.data.inlined.bytes)) { - return grpc_slice_malloc_large(length); - } else { - /* small slice: just inline the data */ - slice.refcount = nullptr; - slice.data.inlined.length = static_cast(length); - } - return slice; + return grpc_core::UnmanagedMemorySlice(length); } -grpc_slice grpc_slice_sub_no_ref(grpc_slice source, size_t begin, size_t end) { - grpc_slice subset; +grpc_core::UnmanagedMemorySlice::UnmanagedMemorySlice(size_t length) { + if (length > sizeof(data.inlined.bytes)) { + HeapInit(length); + } else { + /* small slice: just inline the data */ + refcount = nullptr; + data.inlined.length = static_cast(length); + } +} + +template +static Slice sub_no_ref(const Slice& source, size_t begin, size_t end) { + Slice subset; GPR_ASSERT(end >= begin); @@ -327,6 +340,15 @@ grpc_slice grpc_slice_sub_no_ref(grpc_slice source, size_t begin, size_t end) { return subset; } +grpc_slice grpc_slice_sub_no_ref(grpc_slice source, size_t begin, size_t end) { + return sub_no_ref(source, begin, end); +} + +grpc_core::UnmanagedMemorySlice grpc_slice_sub_no_ref( + const grpc_core::UnmanagedMemorySlice& source, size_t begin, size_t end) { + return sub_no_ref(source, begin, end); +} + grpc_slice grpc_slice_sub(grpc_slice source, size_t begin, size_t end) { grpc_slice subset; diff --git a/src/core/lib/slice/slice_intern.cc b/src/core/lib/slice/slice_intern.cc index 81d34ddce25..13fe1ab40e9 100644 --- a/src/core/lib/slice/slice_intern.cc +++ b/src/core/lib/slice/slice_intern.cc @@ -107,12 +107,10 @@ static void grow_shard(slice_shard* shard) { shard->capacity = capacity; } -static grpc_slice materialize(InternedSliceRefcount* s) { - grpc_slice slice; - slice.refcount = &s->base; - slice.data.refcounted.bytes = reinterpret_cast(s + 1); - slice.data.refcounted.length = s->length; - return slice; +grpc_core::InternedSlice::InternedSlice(InternedSliceRefcount* s) { + refcount = &s->base; + data.refcounted.bytes = reinterpret_cast(s + 1); + data.refcounted.length = s->length; } uint32_t grpc_slice_default_hash_impl(grpc_slice s) { @@ -152,57 +150,150 @@ grpc_slice grpc_slice_maybe_static_intern(grpc_slice slice, } grpc_slice grpc_slice_intern(grpc_slice slice) { - GPR_TIMER_SCOPE("grpc_slice_intern", 0); - if (GRPC_IS_STATIC_METADATA_STRING(slice)) { - return slice; - } - - uint32_t hash = grpc_slice_hash_internal(slice); + /* TODO(arjunroy): At present, this is capable of returning either a static or + an interned slice. This yields weirdness like the constructor for + ManagedMemorySlice instantiating itself as an instance of a derived type + (StaticMetadataSlice or InternedSlice). Should reexamine. */ + return grpc_core::ManagedMemorySlice(&slice); +} +// Attempt to see if the provided slice or string matches a static slice. +// SliceArgs... is either a const grpc_slice& or a string and length. In either +// case, hash is the pre-computed hash value. +// +// Returns: a matching static slice, or null. +template +static const grpc_core::StaticMetadataSlice* MatchStaticSlice( + uint32_t hash, SliceArgs&&... args) { for (uint32_t i = 0; i <= max_static_metadata_hash_probe; i++) { static_metadata_hash_ent ent = static_metadata_hash[(hash + i) % GPR_ARRAY_SIZE(static_metadata_hash)]; if (ent.hash == hash && ent.idx < GRPC_STATIC_MDSTR_COUNT && - grpc_slice_eq_static_interned(slice, - grpc_static_slice_table[ent.idx])) { - return grpc_static_slice_table[ent.idx]; + grpc_static_slice_table[ent.idx].Equals( + std::forward(args)...)) { + return &grpc_static_slice_table[ent.idx]; } } + return nullptr; +} - InternedSliceRefcount* s; - slice_shard* shard = &g_shards[SHARD_IDX(hash)]; +// Helper methods to enable us to select appropriately overloaded slice methods +// whether we're dealing with a slice, or a buffer with length, when interning +// strings. Helpers for FindOrCreateInternedSlice(). +static const void* GetBuffer(const void* buf, size_t len) { return buf; } +static size_t GetLength(const void* buf, size_t len) { return len; } +static const void* GetBuffer(const grpc_slice& slice) { + return GRPC_SLICE_START_PTR(slice); +} +static size_t GetLength(const grpc_slice& slice) { + return GRPC_SLICE_LENGTH(slice); +} - gpr_mu_lock(&shard->mu); - - /* search for an existing string */ - size_t idx = TABLE_IDX(hash, shard->capacity); - for (s = shard->strs[idx]; s; s = s->bucket_next) { - if (s->hash == hash && - grpc_slice_eq_static_interned(slice, materialize(s))) { - if (s->refcnt.RefIfNonZero()) { - gpr_mu_unlock(&shard->mu); - return materialize(s); - } - } - } - - /* not found: create a new string */ +// Creates an interned slice for a string that does not currently exist in the +// intern table. SliceArgs... is either a const grpc_slice& or a string and +// length. In either case, hash is the pre-computed hash value. We must already +// hold the shard lock. Helper for FindOrCreateInternedSlice(). +// +// Returns: a newly interned slice. +template +static InternedSliceRefcount* InternNewStringLocked(slice_shard* shard, + size_t shard_idx, + uint32_t hash, + SliceArgs&&... args) { /* string data goes after the internal_string header */ - s = static_cast( - gpr_malloc(sizeof(*s) + GRPC_SLICE_LENGTH(slice))); - - new (s) grpc_core::InternedSliceRefcount(GRPC_SLICE_LENGTH(slice), hash, - shard->strs[idx]); - memcpy(reinterpret_cast(s + 1), GRPC_SLICE_START_PTR(slice), - GRPC_SLICE_LENGTH(slice)); - shard->strs[idx] = s; + size_t len = GetLength(std::forward(args)...); + const void* buffer = GetBuffer(std::forward(args)...); + InternedSliceRefcount* s = + static_cast(gpr_malloc(sizeof(*s) + len)); + new (s) grpc_core::InternedSliceRefcount(len, hash, shard->strs[shard_idx]); + memcpy(reinterpret_cast(s + 1), buffer, len); + shard->strs[shard_idx] = s; shard->count++; if (shard->count > shard->capacity * 2) { grow_shard(shard); } + return s; +} +// Attempt to see if the provided slice or string matches an existing interned +// slice. SliceArgs... is either a const grpc_slice& or a string and length. In +// either case, hash is the pre-computed hash value. We must already hold the +// shard lock. Helper for FindOrCreateInternedSlice(). +// +// Returns: a pre-existing matching static slice, or null. +template +static InternedSliceRefcount* MatchInternedSliceLocked(uint32_t hash, + size_t idx, + SliceArgs&&... args) { + InternedSliceRefcount* s; + slice_shard* shard = &g_shards[SHARD_IDX(hash)]; + /* search for an existing string */ + for (s = shard->strs[idx]; s; s = s->bucket_next) { + if (s->hash == hash && + grpc_core::InternedSlice(s).Equals(std::forward(args)...)) { + if (s->refcnt.RefIfNonZero()) { + return s; + } + } + } + return nullptr; +} + +// Attempt to see if the provided slice or string matches an existing interned +// slice, and failing that, create an interned slice with its contents. Returns +// either the existing matching interned slice or the newly created one. +// SliceArgs... is either a const grpc_slice& or a string and length. In either +// case, hash is the pre-computed hash value. We do not hold the shard lock +// here, but do take it. +// +// Returns: an interned slice, either pre-existing/matched or newly created. +template +static InternedSliceRefcount* FindOrCreateInternedSlice(uint32_t hash, + SliceArgs&&... args) { + slice_shard* shard = &g_shards[SHARD_IDX(hash)]; + gpr_mu_lock(&shard->mu); + const size_t idx = TABLE_IDX(hash, shard->capacity); + InternedSliceRefcount* s = + MatchInternedSliceLocked(hash, idx, std::forward(args)...); + if (s == nullptr) { + s = InternNewStringLocked(shard, idx, hash, + std::forward(args)...); + } gpr_mu_unlock(&shard->mu); - return materialize(s); + return s; +} + +grpc_core::ManagedMemorySlice::ManagedMemorySlice(const char* string) + : grpc_core::ManagedMemorySlice::ManagedMemorySlice(string, + strlen(string)) {} + +grpc_core::ManagedMemorySlice::ManagedMemorySlice(const char* string, + size_t len) { + GPR_TIMER_SCOPE("grpc_slice_intern", 0); + const uint32_t hash = gpr_murmur_hash3(string, len, g_hash_seed); + const StaticMetadataSlice* static_slice = MatchStaticSlice(hash, string, len); + if (static_slice) { + *this = *static_slice; + } else { + *this = + grpc_core::InternedSlice(FindOrCreateInternedSlice(hash, string, len)); + } +} + +grpc_core::ManagedMemorySlice::ManagedMemorySlice(const grpc_slice* slice_ptr) { + GPR_TIMER_SCOPE("grpc_slice_intern", 0); + const grpc_slice& slice = *slice_ptr; + if (GRPC_IS_STATIC_METADATA_STRING(slice)) { + *this = static_cast(slice); + return; + } + const uint32_t hash = grpc_slice_hash_internal(slice); + const StaticMetadataSlice* static_slice = MatchStaticSlice(hash, slice); + if (static_slice) { + *this = *static_slice; + } else { + *this = grpc_core::InternedSlice(FindOrCreateInternedSlice(hash, slice)); + } } void grpc_test_only_set_slice_hash_seed(uint32_t seed) { @@ -259,8 +350,8 @@ void grpc_slice_intern_shutdown(void) { shard->count); for (size_t j = 0; j < shard->capacity; j++) { for (InternedSliceRefcount* s = shard->strs[j]; s; s = s->bucket_next) { - char* text = - grpc_dump_slice(materialize(s), GPR_DUMP_HEX | GPR_DUMP_ASCII); + char* text = grpc_dump_slice(grpc_core::InternedSlice(s), + GPR_DUMP_HEX | GPR_DUMP_ASCII); gpr_log(GPR_DEBUG, "LEAKED: %s", text); gpr_free(text); } diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index 54badeb9ab9..219266c3941 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -30,6 +30,7 @@ #include "src/core/lib/gpr/murmur_hash.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/ref_counted.h" +#include "src/core/lib/slice/slice_utils.h" #include "src/core/lib/transport/static_metadata.h" // Interned slices have specific fast-path operations for hashing. To inline @@ -95,6 +96,8 @@ extern uint32_t g_hash_seed; // In total, this saves us roughly 1-2% latency for unary calls, with smaller // calls benefitting. The effect is present, but not as useful, for larger calls // where the cost of sending the data dominates. +// TODO(arjunroy): Investigate if this can be removed with strongly typed +// grpc_slices. struct grpc_slice_refcount { public: enum class Type { @@ -314,17 +317,7 @@ grpc_slice grpc_slice_from_moved_string(grpc_core::UniquePtr p); // 0. All other slices will return the size of the allocated chars. size_t grpc_slice_memory_usage(grpc_slice s); -inline grpc_slice grpc_slice_from_static_buffer_internal(const void* s, - size_t len) { - grpc_slice slice; - slice.refcount = &grpc_core::kNoopRefcount; - slice.data.refcounted.bytes = (uint8_t*)s; - slice.data.refcounted.length = len; - return slice; -} - -inline grpc_slice grpc_slice_from_static_string_internal(const char* s) { - return grpc_slice_from_static_buffer_internal(s, strlen(s)); -} +grpc_core::UnmanagedMemorySlice grpc_slice_sub_no_ref( + const grpc_core::UnmanagedMemorySlice& source, size_t begin, size_t end); #endif /* GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H */ diff --git a/src/core/lib/slice/slice_utils.h b/src/core/lib/slice/slice_utils.h index 7589bf8f0f7..161300abe1e 100644 --- a/src/core/lib/slice/slice_utils.h +++ b/src/core/lib/slice/slice_utils.h @@ -21,6 +21,8 @@ #include +#include + #include // When we compare two slices, and we know the latter is not inlined, we can @@ -36,6 +38,7 @@ // x86-64/clang with differs(). int grpc_slice_differs_refcounted(const grpc_slice& a, const grpc_slice& b_not_inline); + // When we compare two slices, and we *know* that one of them is static or // interned, we can short circuit our slice equality function. The second slice // here must be static or interned; slice a can be any slice, inlined or not. @@ -47,4 +50,121 @@ inline bool grpc_slice_eq_static_interned(const grpc_slice& a, return !grpc_slice_differs_refcounted(a, b_static_interned); } +// TODO(arjunroy): These type declarations ought to be in +// src/core/lib/slice/slice_internal.h instead; they are here due to a circular +// header depedency between slice_internal.h and +// src/core/lib/transport/metadata.h. We need to fix this circular reference and +// when we do, move these type declarations. +// +// Internal slice type declarations. +// Externally, a grpc_slice is a grpc_slice is a grpc_slice. +// Internally, we may have heap allocated slices, static slices, interned +// slices, and inlined slices. If we know the specific type of slice +// we're dealing with, we can save cycles (e.g. fast-paths when we know we don't +// need to take a reference on a slice). Rather than introducing new methods +// ad-hoc in these cases, we rely on type-system backed overloads to keep +// internal APIs clean. +// +// For each overload, the definition and layout of the underlying slice does not +// change; this is purely type-system information. +namespace grpc_core { + +// There are two main types of slices: those that have their memory +// managed by the slice library and those that do not. +// +// The following types of slices are not managed: +// - inlined slices (i.e., refcount is null) +// - slices that have a custom refcount type (i.e., not STATIC or INTERNED) +// - slices where the memory is managed by some external agent. The slice is not +// ref-counted by grpc, and the programmer is responsible for ensuring the +// data is valid for the duration of the period that grpc may access it. +// +// The following types of slices are managed: +// - static metadata slices (i.e., refcount type is STATIC) +// - interned slices (i.e., refcount type is INTERNED) +// +// This categorization is reflected in the following hierarchy: +// +// - grpc_slice +// > - UnmanagedMemorySlice +// > - ExternallyManagedSlice +// - ManagedMemorySlice +// > - InternedSlice +// - StaticMetadataSlice +// +struct ManagedMemorySlice : public grpc_slice { + ManagedMemorySlice() { + refcount = nullptr; + data.refcounted.bytes = nullptr; + data.refcounted.length = 0; + } + explicit ManagedMemorySlice(const char* string); + ManagedMemorySlice(const char* buf, size_t len); + explicit ManagedMemorySlice(const grpc_slice* slice); + bool Equals(const grpc_slice& other) const { + if (refcount == other.refcount) { + return true; + } + return !grpc_slice_differs_refcounted(other, *this); + } + bool Equals(const char* buf, const size_t len) const { + return data.refcounted.length == len && + memcmp(buf, data.refcounted.bytes, len) == 0; + } +}; +struct UnmanagedMemorySlice : public grpc_slice { + // TODO(arjunroy): Can we use a default=false param instead of this enum? + enum class ForceHeapAllocation {}; + UnmanagedMemorySlice() { + refcount = nullptr; + data.inlined.length = 0; + } + explicit UnmanagedMemorySlice(const char* source); + UnmanagedMemorySlice(const char* source, size_t length); + // The first constructor creates a slice that may be heap allocated, or + // inlined in the slice structure if length is small enough + // (< GRPC_SLICE_INLINED_SIZE). The second constructor forces heap alloc. + explicit UnmanagedMemorySlice(size_t length); + explicit UnmanagedMemorySlice(size_t length, const ForceHeapAllocation&) { + HeapInit(length); + } + + private: + void HeapInit(size_t length); +}; + +extern grpc_slice_refcount kNoopRefcount; + +struct ExternallyManagedSlice : public UnmanagedMemorySlice { + ExternallyManagedSlice() + : ExternallyManagedSlice(&kNoopRefcount, 0, nullptr) {} + explicit ExternallyManagedSlice(const char* s) + : ExternallyManagedSlice(s, strlen(s)) {} + ExternallyManagedSlice(const void* s, size_t len) + : ExternallyManagedSlice( + &kNoopRefcount, len, + reinterpret_cast(const_cast(s))) {} + ExternallyManagedSlice(grpc_slice_refcount* ref, size_t length, + uint8_t* bytes) { + refcount = ref; + data.refcounted.length = length; + data.refcounted.bytes = bytes; + } +}; + +struct StaticMetadataSlice : public ManagedMemorySlice { + StaticMetadataSlice(grpc_slice_refcount* ref, size_t length, uint8_t* bytes) { + refcount = ref; + data.refcounted.length = length; + data.refcounted.bytes = bytes; + } +}; + +struct InternedSliceRefcount; +struct InternedSlice : public ManagedMemorySlice { + explicit InternedSlice(InternedSliceRefcount* s); +}; + +} // namespace grpc_core + #endif /* GRPC_CORE_LIB_SLICE_SLICE_UTILS_H */ diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index aadb3f5fae3..942af37a830 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -416,13 +416,11 @@ void* grpc_channel_register_call(grpc_channel* channel, const char* method, GPR_ASSERT(!reserved); grpc_core::ExecCtx exec_ctx; - rc->path = grpc_mdelem_from_slices( - GRPC_MDSTR_PATH, - grpc_slice_intern(grpc_slice_from_static_string(method))); + rc->path = grpc_mdelem_from_slices(GRPC_MDSTR_PATH, + grpc_core::ManagedMemorySlice(method)); rc->authority = - host ? grpc_mdelem_from_slices( - GRPC_MDSTR_AUTHORITY, - grpc_slice_intern(grpc_slice_from_static_string(host))) + host ? grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY, + grpc_core::ManagedMemorySlice(host)) : GRPC_MDNULL; gpr_mu_lock(&channel->registered_call_mu); rc->next = channel->registered_calls; @@ -513,5 +511,5 @@ grpc_mdelem grpc_channel_get_reffed_status_elem_slowpath(grpc_channel* channel, char tmp[GPR_LTOA_MIN_BUFSIZE]; gpr_ltoa(i, tmp); return grpc_mdelem_from_slices(GRPC_MDSTR_GRPC_STATUS, - grpc_slice_from_copied_string(tmp)); + grpc_core::UnmanagedMemorySlice(tmp)); } diff --git a/src/core/lib/surface/lame_client.cc b/src/core/lib/surface/lame_client.cc index dde39b8c681..10a27924073 100644 --- a/src/core/lib/surface/lame_client.cc +++ b/src/core/lib/surface/lame_client.cc @@ -61,10 +61,10 @@ static void fill_metadata(grpc_call_element* elem, grpc_metadata_batch* mdb) { char tmp[GPR_LTOA_MIN_BUFSIZE]; gpr_ltoa(chand->error_code, tmp); calld->status.md = grpc_mdelem_from_slices( - GRPC_MDSTR_GRPC_STATUS, grpc_slice_from_copied_string(tmp)); + GRPC_MDSTR_GRPC_STATUS, grpc_core::UnmanagedMemorySlice(tmp)); calld->details.md = grpc_mdelem_from_slices( GRPC_MDSTR_GRPC_MESSAGE, - grpc_slice_from_copied_string(chand->error_message)); + grpc_core::UnmanagedMemorySlice(chand->error_message)); calld->status.prev = calld->details.next = nullptr; calld->status.next = &calld->details; calld->details.prev = &calld->status; diff --git a/src/core/lib/transport/error_utils.cc b/src/core/lib/transport/error_utils.cc index 5be98c9f04f..78a324b2d7f 100644 --- a/src/core/lib/transport/error_utils.cc +++ b/src/core/lib/transport/error_utils.cc @@ -61,7 +61,7 @@ void grpc_error_get_status(grpc_error* error, grpc_millis deadline, // 3) The resulting slice is statically known. // 4) Said resulting slice is of length 0 (""). // This means 3 movs, instead of 10s of instructions and a strlen. - *slice = grpc_slice_from_static_string_internal(""); + *slice = grpc_core::ExternallyManagedSlice(""); } if (http_error != nullptr) { *http_error = GRPC_HTTP2_NO_ERROR; diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc index 7766ee186c6..4242923283e 100644 --- a/src/core/lib/transport/metadata.cc +++ b/src/core/lib/transport/metadata.cc @@ -68,8 +68,8 @@ void grpc_mdelem_trace_ref(void* md, const grpc_slice& key, char* key_str = grpc_slice_to_c_string(key); char* value_str = grpc_slice_to_c_string(value); gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "ELM REF:%p:%" PRIdPTR "->%" PRIdPTR ": '%s' = '%s'", md, refcnt, - refcnt + 1, key_str, value_str); + "mdelem REF:%p:%" PRIdPTR "->%" PRIdPTR ": '%s' = '%s'", md, + refcnt, refcnt + 1, key_str, value_str); gpr_free(key_str); gpr_free(value_str); } @@ -82,7 +82,7 @@ void grpc_mdelem_trace_unref(void* md, const grpc_slice& key, char* key_str = grpc_slice_to_c_string(key); char* value_str = grpc_slice_to_c_string(value); gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "ELM UNREF:%p:%" PRIdPTR "->%" PRIdPTR ": '%s' = '%s'", md, + "mdelem UNREF:%p:%" PRIdPTR "->%" PRIdPTR ": '%s' = '%s'", md, refcnt, refcnt - 1, key_str, value_str); gpr_free(key_str); gpr_free(value_str); @@ -112,14 +112,33 @@ AllocatedMetadata::AllocatedMetadata(const grpc_slice& key, : RefcountedMdBase(grpc_slice_ref_internal(key), grpc_slice_ref_internal(value)) { #ifndef NDEBUG - if (grpc_trace_metadata.enabled()) { - char* key_str = grpc_slice_to_c_string(key); - char* value_str = grpc_slice_to_c_string(value); - gpr_log(GPR_DEBUG, "ELM ALLOC:%p:%" PRIdPTR ": '%s' = '%s'", this, - RefValue(), key_str, value_str); - gpr_free(key_str); - gpr_free(value_str); - } + TraceAtStart("ALLOC_MD"); +#endif +} + +AllocatedMetadata::AllocatedMetadata(const grpc_slice& key, + const grpc_slice& value, const NoRefKey*) + : RefcountedMdBase(key, grpc_slice_ref_internal(value)) { +#ifndef NDEBUG + TraceAtStart("ALLOC_MD_NOREF_KEY"); +#endif +} + +AllocatedMetadata::AllocatedMetadata( + const grpc_core::ManagedMemorySlice& key, + const grpc_core::UnmanagedMemorySlice& value) + : RefcountedMdBase(key, value) { +#ifndef NDEBUG + TraceAtStart("ALLOC_MD_NOREF_KEY_VAL"); +#endif +} + +AllocatedMetadata::AllocatedMetadata( + const grpc_core::ExternallyManagedSlice& key, + const grpc_core::UnmanagedMemorySlice& value) + : RefcountedMdBase(key, value) { +#ifndef NDEBUG + TraceAtStart("ALLOC_MD_NOREF_KEY_VAL"); #endif } @@ -134,6 +153,19 @@ AllocatedMetadata::~AllocatedMetadata() { } } +#ifndef NDEBUG +void grpc_core::RefcountedMdBase::TraceAtStart(const char* tag) { + if (grpc_trace_metadata.enabled()) { + char* key_str = grpc_slice_to_c_string(key()); + char* value_str = grpc_slice_to_c_string(value()); + gpr_log(GPR_DEBUG, "mdelem %s:%p:%" PRIdPTR ": '%s' = '%s'", tag, this, + RefValue(), key_str, value_str); + gpr_free(key_str); + gpr_free(value_str); + } +} +#endif + InternedMetadata::InternedMetadata(const grpc_slice& key, const grpc_slice& value, uint32_t hash, InternedMetadata* next) @@ -141,14 +173,16 @@ InternedMetadata::InternedMetadata(const grpc_slice& key, grpc_slice_ref_internal(value), hash), link_(next) { #ifndef NDEBUG - if (grpc_trace_metadata.enabled()) { - char* key_str = grpc_slice_to_c_string(key); - char* value_str = grpc_slice_to_c_string(value); - gpr_log(GPR_DEBUG, "ELM NEW:%p:%" PRIdPTR ": '%s' = '%s'", this, - RefValue(), key_str, value_str); - gpr_free(key_str); - gpr_free(value_str); - } + TraceAtStart("INTERNED_MD"); +#endif +} + +InternedMetadata::InternedMetadata(const grpc_slice& key, + const grpc_slice& value, uint32_t hash, + InternedMetadata* next, const NoRefKey*) + : RefcountedMdBase(key, grpc_slice_ref_internal(value), hash), link_(next) { +#ifndef NDEBUG + TraceAtStart("INTERNED_MD_NOREF_KEY"); #endif } @@ -248,8 +282,8 @@ void InternedMetadata::RefWithShardLocked(mdtab_shard* shard) { char* value_str = grpc_slice_to_c_string(value()); intptr_t value = RefValue(); gpr_log(__FILE__, __LINE__, GPR_LOG_SEVERITY_DEBUG, - "ELM REF:%p:%" PRIdPTR "->%" PRIdPTR ": '%s' = '%s'", this, value, - value + 1, key_str, value_str); + "mdelem REF:%p:%" PRIdPTR "->%" PRIdPTR ": '%s' = '%s'", this, + value, value + 1, key_str, value_str); gpr_free(key_str); gpr_free(value_str); } @@ -307,36 +341,100 @@ static void rehash_mdtab(mdtab_shard* shard) { } } -grpc_mdelem grpc_mdelem_create( +template +static grpc_mdelem md_create_maybe_static(const grpc_slice& key, + const grpc_slice& value); +template +static grpc_mdelem md_create_must_intern(const grpc_slice& key, + const grpc_slice& value, + uint32_t hash); + +template +static grpc_mdelem md_create( const grpc_slice& key, const grpc_slice& value, grpc_mdelem_data* compatible_external_backing_store) { + // Ensure slices are, in fact, static if we claimed they were. + GPR_DEBUG_ASSERT(!key_definitely_static || + GRPC_IS_STATIC_METADATA_STRING(key)); + GPR_DEBUG_ASSERT(!value_definitely_static || + GRPC_IS_STATIC_METADATA_STRING(value)); + const bool key_is_interned = + key_definitely_static || grpc_slice_is_interned(key); + const bool value_is_interned = + value_definitely_static || grpc_slice_is_interned(value); // External storage if either slice is not interned and the caller already // created a backing store. If no backing store, we allocate one. - if (!grpc_slice_is_interned(key) || !grpc_slice_is_interned(value)) { + if (!key_is_interned || !value_is_interned) { if (compatible_external_backing_store != nullptr) { // Caller provided backing store. return GRPC_MAKE_MDELEM(compatible_external_backing_store, GRPC_MDELEM_STORAGE_EXTERNAL); } else { // We allocate backing store. - return GRPC_MAKE_MDELEM(grpc_core::New(key, value), - GRPC_MDELEM_STORAGE_ALLOCATED); + return key_definitely_static + ? GRPC_MAKE_MDELEM( + grpc_core::New( + key, value, + static_cast( + nullptr)), + GRPC_MDELEM_STORAGE_ALLOCATED) + : GRPC_MAKE_MDELEM( + grpc_core::New(key, value), + GRPC_MDELEM_STORAGE_ALLOCATED); } } + return md_create_maybe_static( + key, value); +} + +template +static grpc_mdelem md_create_maybe_static(const grpc_slice& key, + const grpc_slice& value) { + // Ensure slices are, in fact, static if we claimed they were. + GPR_DEBUG_ASSERT(!key_definitely_static || + GRPC_IS_STATIC_METADATA_STRING(key)); + GPR_DEBUG_ASSERT(!value_definitely_static || + GRPC_IS_STATIC_METADATA_STRING(value)); + GPR_DEBUG_ASSERT(key.refcount != nullptr); + GPR_DEBUG_ASSERT(value.refcount != nullptr); + + const bool key_is_static_mdstr = + key_definitely_static || + key.refcount->GetType() == grpc_slice_refcount::Type::STATIC; + const bool value_is_static_mdstr = + value_definitely_static || + value.refcount->GetType() == grpc_slice_refcount::Type::STATIC; + + const intptr_t kidx = GRPC_STATIC_METADATA_INDEX(key); // Not all static slice input yields a statically stored metadata element. - // It may be worth documenting why. - if (GRPC_IS_STATIC_METADATA_STRING(key) && - GRPC_IS_STATIC_METADATA_STRING(value)) { + if (key_is_static_mdstr && value_is_static_mdstr) { grpc_mdelem static_elem = grpc_static_mdelem_for_static_strings( - GRPC_STATIC_METADATA_INDEX(key), GRPC_STATIC_METADATA_INDEX(value)); + kidx, GRPC_STATIC_METADATA_INDEX(value)); if (!GRPC_MDISNULL(static_elem)) { return static_elem; } } - uint32_t hash = GRPC_MDSTR_KV_HASH(grpc_slice_hash_refcounted(key), - grpc_slice_hash_refcounted(value)); + uint32_t khash = key_definitely_static + ? grpc_static_metadata_hash_values[kidx] + : grpc_slice_hash_refcounted(key); + + uint32_t hash = GRPC_MDSTR_KV_HASH(khash, grpc_slice_hash_refcounted(value)); + return md_create_must_intern(key, value, hash); +} + +template +static grpc_mdelem md_create_must_intern(const grpc_slice& key, + const grpc_slice& value, + uint32_t hash) { + // Here, we know both key and value are both at least interned, and both + // possibly static. We know that anything inside the shared interned table is + // also at least interned (and maybe static). Note that equality for a static + // and interned slice implies that they are both the same exact slice. + // The same applies to a pair of interned slices, or a pair of static slices. + // Rather than run the full equality check, we can therefore just do a pointer + // comparison of the refcounts. InternedMetadata* md; mdtab_shard* shard = &g_shards[SHARD_IDX(hash)]; size_t idx; @@ -348,7 +446,8 @@ grpc_mdelem grpc_mdelem_create( idx = TABLE_IDX(hash, shard->capacity); /* search for an existing pair */ for (md = shard->elems[idx].next; md; md = md->bucket_next()) { - if (grpc_slice_eq(key, md->key()) && grpc_slice_eq(value, md->value())) { + if (grpc_slice_static_interned_equal(key, md->key()) && + grpc_slice_static_interned_equal(value, md->value())) { md->RefWithShardLocked(shard); gpr_mu_unlock(&shard->mu); return GRPC_MAKE_MDELEM(md, GRPC_MDELEM_STORAGE_INTERNED); @@ -356,8 +455,12 @@ grpc_mdelem grpc_mdelem_create( } /* not found: create a new pair */ - md = grpc_core::New(key, value, hash, - shard->elems[idx].next); + md = key_definitely_static + ? grpc_core::New( + key, value, hash, shard->elems[idx].next, + static_cast(nullptr)) + : grpc_core::New(key, value, hash, + shard->elems[idx].next); shard->elems[idx].next = md; shard->count++; @@ -370,9 +473,68 @@ grpc_mdelem grpc_mdelem_create( return GRPC_MAKE_MDELEM(md, GRPC_MDELEM_STORAGE_INTERNED); } +grpc_mdelem grpc_mdelem_create( + const grpc_slice& key, const grpc_slice& value, + grpc_mdelem_data* compatible_external_backing_store) { + return md_create(key, value, compatible_external_backing_store); +} + +grpc_mdelem grpc_mdelem_create( + const grpc_core::StaticMetadataSlice& key, const grpc_slice& value, + grpc_mdelem_data* compatible_external_backing_store) { + return md_create(key, value, compatible_external_backing_store); +} + +/* Create grpc_mdelem from provided slices. We specify via template parameter + whether we know that the input key is static or not. If it is, we short + circuit various comparisons and a no-op unref. */ +template +static grpc_mdelem md_from_slices(const grpc_slice& key, + const grpc_slice& value) { + // Ensure key is, in fact, static if we claimed it was. + GPR_DEBUG_ASSERT(!key_definitely_static || + GRPC_IS_STATIC_METADATA_STRING(key)); + grpc_mdelem out = md_create(key, value, nullptr); + if (!key_definitely_static) { + grpc_slice_unref_internal(key); + } + grpc_slice_unref_internal(value); + return out; +} + grpc_mdelem grpc_mdelem_from_slices(const grpc_slice& key, const grpc_slice& value) { - grpc_mdelem out = grpc_mdelem_create(key, value, nullptr); + return md_from_slices(key, value); +} + +grpc_mdelem grpc_mdelem_from_slices(const grpc_core::StaticMetadataSlice& key, + const grpc_slice& value) { + return md_from_slices(key, value); +} + +grpc_mdelem grpc_mdelem_from_slices( + const grpc_core::StaticMetadataSlice& key, + const grpc_core::StaticMetadataSlice& value) { + grpc_mdelem out = md_create_maybe_static(key, value); + return out; +} + +grpc_mdelem grpc_mdelem_from_slices( + const grpc_core::StaticMetadataSlice& key, + const grpc_core::ManagedMemorySlice& value) { + // TODO(arjunroy): We can save the unref if md_create_maybe_static ended up + // creating a new interned metadata. But otherwise - we need this here. + grpc_mdelem out = md_create_maybe_static(key, value); + grpc_slice_unref_internal(value); + return out; +} + +grpc_mdelem grpc_mdelem_from_slices( + const grpc_core::ManagedMemorySlice& key, + const grpc_core::ManagedMemorySlice& value) { + grpc_mdelem out = md_create_maybe_static(key, value); + // TODO(arjunroy): We can save the unref if md_create_maybe_static ended up + // creating a new interned metadata. But otherwise - we need this here. grpc_slice_unref_internal(key); grpc_slice_unref_internal(value); return out; diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h index 4621433bf01..3d3a68119f2 100644 --- a/src/core/lib/transport/metadata.h +++ b/src/core/lib/transport/metadata.h @@ -118,10 +118,31 @@ struct grpc_mdelem { ((grpc_mdelem_data_storage)((md).payload & \ (uintptr_t)GRPC_MDELEM_STORAGE_INTERNED_BIT)) -/* Unrefs the slices. */ +/* Given arbitrary input slices, create a grpc_mdelem object. The caller refs + * the input slices; we unref them. This method is always safe to call; however, + * if we know data about the slices in question (e.g. if we knew our key was + * static) we can call specializations that save on cycle count. */ grpc_mdelem grpc_mdelem_from_slices(const grpc_slice& key, const grpc_slice& value); +/* Like grpc_mdelem_from_slices, but we know that key is a static slice. This + saves us a few branches and a no-op call to md_unref() for the key. */ +grpc_mdelem grpc_mdelem_from_slices(const grpc_core::StaticMetadataSlice& key, + const grpc_slice& value); + +/* Like grpc_mdelem_from_slices, but key is static and val is static. */ +grpc_mdelem grpc_mdelem_from_slices( + const grpc_core::StaticMetadataSlice& key, + const grpc_core::StaticMetadataSlice& value); + +/* Like grpc_mdelem_from_slices, but key is static and val is interned. */ +grpc_mdelem grpc_mdelem_from_slices(const grpc_core::StaticMetadataSlice& key, + const grpc_core::ManagedMemorySlice& value); + +/* Like grpc_mdelem_from_slices, but key and val are interned. */ +grpc_mdelem grpc_mdelem_from_slices(const grpc_core::ManagedMemorySlice& key, + const grpc_core::ManagedMemorySlice& value); + /* Cheaply convert a grpc_metadata to a grpc_mdelem; may use the grpc_metadata object as backing storage (so lifetimes should align) */ grpc_mdelem grpc_mdelem_from_grpc_metadata(grpc_metadata* metadata); @@ -134,6 +155,11 @@ grpc_mdelem grpc_mdelem_create( const grpc_slice& key, const grpc_slice& value, grpc_mdelem_data* compatible_external_backing_store); +/* Like grpc_mdelem_create, but we know that key is static. */ +grpc_mdelem grpc_mdelem_create( + const grpc_core::StaticMetadataSlice& key, const grpc_slice& value, + grpc_mdelem_data* compatible_external_backing_store); + #define GRPC_MDKEY(md) (GRPC_MDELEM_DATA(md)->key) #define GRPC_MDVALUE(md) (GRPC_MDELEM_DATA(md)->value) @@ -239,6 +265,10 @@ class RefcountedMdBase { } protected: +#ifndef NDEBUG + void TraceAtStart(const char* tag); +#endif + intptr_t RefValue() { return refcnt_.Load(MemoryOrder::RELAXED); } bool AllRefsDropped() { return refcnt_.Load(MemoryOrder::ACQUIRE) == 0; } bool FirstRef() { return refcnt_.FetchAdd(1, MemoryOrder::RELAXED) == 0; } @@ -253,16 +283,19 @@ class RefcountedMdBase { class InternedMetadata : public RefcountedMdBase { public: + // TODO(arjunroy): Change to use strongly typed slices instead. + struct NoRefKey {}; struct BucketLink { explicit BucketLink(InternedMetadata* md) : next(md) {} InternedMetadata* next = nullptr; }; - InternedMetadata(const grpc_slice& key, const grpc_slice& value, uint32_t hash, InternedMetadata* next); - ~InternedMetadata(); + InternedMetadata(const grpc_slice& key, const grpc_slice& value, + uint32_t hash, InternedMetadata* next, const NoRefKey*); + ~InternedMetadata(); void RefWithShardLocked(mdtab_shard* shard); UserData* user_data() { return &user_data_; } InternedMetadata* bucket_next() { return link_.next; } @@ -278,7 +311,15 @@ class InternedMetadata : public RefcountedMdBase { /* Shadow structure for grpc_mdelem_data for allocated elements */ class AllocatedMetadata : public RefcountedMdBase { public: + // TODO(arjunroy): Change to use strongly typed slices instead. + struct NoRefKey {}; AllocatedMetadata(const grpc_slice& key, const grpc_slice& value); + AllocatedMetadata(const grpc_core::ManagedMemorySlice& key, + const grpc_core::UnmanagedMemorySlice& value); + AllocatedMetadata(const grpc_core::ExternallyManagedSlice& key, + const grpc_core::UnmanagedMemorySlice& value); + AllocatedMetadata(const grpc_slice& key, const grpc_slice& value, + const NoRefKey*); ~AllocatedMetadata(); UserData* user_data() { return &user_data_; } @@ -374,4 +415,35 @@ inline void grpc_mdelem_unref(grpc_mdelem gmd) { void grpc_mdctx_global_init(void); void grpc_mdctx_global_shutdown(); +/* Like grpc_mdelem_from_slices, but we know that key is a static or interned + slice and value is not static or interned. This gives us an inlinable + fastpath - we know we must allocate metadata now, and that we do not need to + unref the value (rather, we just transfer the ref). We can avoid a ref since: + 1) the key slice is passed in already ref'd + 2) We're guaranteed to create a new Allocated slice, thus meaning the + ref can be considered 'transferred'.*/ +inline grpc_mdelem grpc_mdelem_from_slices( + const grpc_core::ManagedMemorySlice& key, + const grpc_core::UnmanagedMemorySlice& value) { + using grpc_core::AllocatedMetadata; + return GRPC_MAKE_MDELEM(grpc_core::New(key, value), + GRPC_MDELEM_STORAGE_ALLOCATED); +} + +inline grpc_mdelem grpc_mdelem_from_slices( + const grpc_core::ExternallyManagedSlice& key, + const grpc_core::UnmanagedMemorySlice& value) { + using grpc_core::AllocatedMetadata; + return GRPC_MAKE_MDELEM(grpc_core::New(key, value), + GRPC_MDELEM_STORAGE_ALLOCATED); +} + +inline grpc_mdelem grpc_mdelem_from_slices( + const grpc_core::StaticMetadataSlice& key, + const grpc_core::UnmanagedMemorySlice& value) { + using grpc_core::AllocatedMetadata; + return GRPC_MAKE_MDELEM(grpc_core::New(key, value), + GRPC_MDELEM_STORAGE_ALLOCATED); +} + #endif /* GRPC_CORE_LIB_TRANSPORT_METADATA_H */ diff --git a/src/core/lib/transport/static_metadata.cc b/src/core/lib/transport/static_metadata.cc index c83d1e59491..ec5db5515a7 100644 --- a/src/core/lib/transport/static_metadata.cc +++ b/src/core/lib/transport/static_metadata.cc @@ -226,113 +226,220 @@ grpc_slice_refcount grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT] = { grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), }; -const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT] = { - {&grpc_static_metadata_refcounts[0], {{5, g_bytes + 0}}}, - {&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, - {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[3], {{10, g_bytes + 19}}}, - {&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, - {&grpc_static_metadata_refcounts[5], {{2, g_bytes + 36}}}, - {&grpc_static_metadata_refcounts[6], {{12, g_bytes + 38}}}, - {&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, - {&grpc_static_metadata_refcounts[8], {{16, g_bytes + 61}}}, - {&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, - {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[11], {{21, g_bytes + 110}}}, - {&grpc_static_metadata_refcounts[12], {{13, g_bytes + 131}}}, - {&grpc_static_metadata_refcounts[13], {{14, g_bytes + 144}}}, - {&grpc_static_metadata_refcounts[14], {{12, g_bytes + 158}}}, - {&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, - {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[17], {{30, g_bytes + 201}}}, - {&grpc_static_metadata_refcounts[18], {{37, g_bytes + 231}}}, - {&grpc_static_metadata_refcounts[19], {{10, g_bytes + 268}}}, - {&grpc_static_metadata_refcounts[20], {{4, g_bytes + 278}}}, - {&grpc_static_metadata_refcounts[21], {{26, g_bytes + 282}}}, - {&grpc_static_metadata_refcounts[22], {{22, g_bytes + 308}}}, - {&grpc_static_metadata_refcounts[23], {{12, g_bytes + 330}}}, - {&grpc_static_metadata_refcounts[24], {{1, g_bytes + 342}}}, - {&grpc_static_metadata_refcounts[25], {{1, g_bytes + 343}}}, - {&grpc_static_metadata_refcounts[26], {{1, g_bytes + 344}}}, - {&grpc_static_metadata_refcounts[27], {{1, g_bytes + 345}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, - {&grpc_static_metadata_refcounts[29], {{19, g_bytes + 346}}}, - {&grpc_static_metadata_refcounts[30], {{12, g_bytes + 365}}}, - {&grpc_static_metadata_refcounts[31], {{30, g_bytes + 377}}}, - {&grpc_static_metadata_refcounts[32], {{31, g_bytes + 407}}}, - {&grpc_static_metadata_refcounts[33], {{36, g_bytes + 438}}}, - {&grpc_static_metadata_refcounts[34], {{28, g_bytes + 474}}}, - {&grpc_static_metadata_refcounts[35], {{80, g_bytes + 502}}}, - {&grpc_static_metadata_refcounts[36], {{7, g_bytes + 582}}}, - {&grpc_static_metadata_refcounts[37], {{4, g_bytes + 589}}}, - {&grpc_static_metadata_refcounts[38], {{11, g_bytes + 593}}}, - {&grpc_static_metadata_refcounts[39], {{3, g_bytes + 604}}}, - {&grpc_static_metadata_refcounts[40], {{4, g_bytes + 607}}}, - {&grpc_static_metadata_refcounts[41], {{1, g_bytes + 611}}}, - {&grpc_static_metadata_refcounts[42], {{11, g_bytes + 612}}}, - {&grpc_static_metadata_refcounts[43], {{4, g_bytes + 623}}}, - {&grpc_static_metadata_refcounts[44], {{5, g_bytes + 627}}}, - {&grpc_static_metadata_refcounts[45], {{3, g_bytes + 632}}}, - {&grpc_static_metadata_refcounts[46], {{3, g_bytes + 635}}}, - {&grpc_static_metadata_refcounts[47], {{3, g_bytes + 638}}}, - {&grpc_static_metadata_refcounts[48], {{3, g_bytes + 641}}}, - {&grpc_static_metadata_refcounts[49], {{3, g_bytes + 644}}}, - {&grpc_static_metadata_refcounts[50], {{3, g_bytes + 647}}}, - {&grpc_static_metadata_refcounts[51], {{3, g_bytes + 650}}}, - {&grpc_static_metadata_refcounts[52], {{14, g_bytes + 653}}}, - {&grpc_static_metadata_refcounts[53], {{13, g_bytes + 667}}}, - {&grpc_static_metadata_refcounts[54], {{15, g_bytes + 680}}}, - {&grpc_static_metadata_refcounts[55], {{13, g_bytes + 695}}}, - {&grpc_static_metadata_refcounts[56], {{6, g_bytes + 708}}}, - {&grpc_static_metadata_refcounts[57], {{27, g_bytes + 714}}}, - {&grpc_static_metadata_refcounts[58], {{3, g_bytes + 741}}}, - {&grpc_static_metadata_refcounts[59], {{5, g_bytes + 744}}}, - {&grpc_static_metadata_refcounts[60], {{13, g_bytes + 749}}}, - {&grpc_static_metadata_refcounts[61], {{13, g_bytes + 762}}}, - {&grpc_static_metadata_refcounts[62], {{19, g_bytes + 775}}}, - {&grpc_static_metadata_refcounts[63], {{16, g_bytes + 794}}}, - {&grpc_static_metadata_refcounts[64], {{14, g_bytes + 810}}}, - {&grpc_static_metadata_refcounts[65], {{16, g_bytes + 824}}}, - {&grpc_static_metadata_refcounts[66], {{13, g_bytes + 840}}}, - {&grpc_static_metadata_refcounts[67], {{6, g_bytes + 853}}}, - {&grpc_static_metadata_refcounts[68], {{4, g_bytes + 859}}}, - {&grpc_static_metadata_refcounts[69], {{4, g_bytes + 863}}}, - {&grpc_static_metadata_refcounts[70], {{6, g_bytes + 867}}}, - {&grpc_static_metadata_refcounts[71], {{7, g_bytes + 873}}}, - {&grpc_static_metadata_refcounts[72], {{4, g_bytes + 880}}}, - {&grpc_static_metadata_refcounts[73], {{8, g_bytes + 884}}}, - {&grpc_static_metadata_refcounts[74], {{17, g_bytes + 892}}}, - {&grpc_static_metadata_refcounts[75], {{13, g_bytes + 909}}}, - {&grpc_static_metadata_refcounts[76], {{8, g_bytes + 922}}}, - {&grpc_static_metadata_refcounts[77], {{19, g_bytes + 930}}}, - {&grpc_static_metadata_refcounts[78], {{13, g_bytes + 949}}}, - {&grpc_static_metadata_refcounts[79], {{4, g_bytes + 962}}}, - {&grpc_static_metadata_refcounts[80], {{8, g_bytes + 966}}}, - {&grpc_static_metadata_refcounts[81], {{12, g_bytes + 974}}}, - {&grpc_static_metadata_refcounts[82], {{18, g_bytes + 986}}}, - {&grpc_static_metadata_refcounts[83], {{19, g_bytes + 1004}}}, - {&grpc_static_metadata_refcounts[84], {{5, g_bytes + 1023}}}, - {&grpc_static_metadata_refcounts[85], {{7, g_bytes + 1028}}}, - {&grpc_static_metadata_refcounts[86], {{7, g_bytes + 1035}}}, - {&grpc_static_metadata_refcounts[87], {{11, g_bytes + 1042}}}, - {&grpc_static_metadata_refcounts[88], {{6, g_bytes + 1053}}}, - {&grpc_static_metadata_refcounts[89], {{10, g_bytes + 1059}}}, - {&grpc_static_metadata_refcounts[90], {{25, g_bytes + 1069}}}, - {&grpc_static_metadata_refcounts[91], {{17, g_bytes + 1094}}}, - {&grpc_static_metadata_refcounts[92], {{4, g_bytes + 1111}}}, - {&grpc_static_metadata_refcounts[93], {{3, g_bytes + 1115}}}, - {&grpc_static_metadata_refcounts[94], {{16, g_bytes + 1118}}}, - {&grpc_static_metadata_refcounts[95], {{1, g_bytes + 1134}}}, - {&grpc_static_metadata_refcounts[96], {{8, g_bytes + 1135}}}, - {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}, - {&grpc_static_metadata_refcounts[98], {{16, g_bytes + 1151}}}, - {&grpc_static_metadata_refcounts[99], {{4, g_bytes + 1167}}}, - {&grpc_static_metadata_refcounts[100], {{3, g_bytes + 1171}}}, - {&grpc_static_metadata_refcounts[101], {{11, g_bytes + 1174}}}, - {&grpc_static_metadata_refcounts[102], {{16, g_bytes + 1185}}}, - {&grpc_static_metadata_refcounts[103], {{13, g_bytes + 1201}}}, - {&grpc_static_metadata_refcounts[104], {{12, g_bytes + 1214}}}, - {&grpc_static_metadata_refcounts[105], {{21, g_bytes + 1226}}}, +const grpc_core::StaticMetadataSlice + grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT] = { + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[0], 5, + g_bytes + 0), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1], 7, + g_bytes + 5), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2], 7, + g_bytes + 12), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[3], 10, + g_bytes + 19), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4], 7, + g_bytes + 29), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[5], 2, + g_bytes + 36), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[6], 12, + g_bytes + 38), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7], 11, + g_bytes + 50), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[8], 16, + g_bytes + 61), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9], 13, + g_bytes + 77), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10], 20, + g_bytes + 90), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[11], 21, + g_bytes + 110), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[12], 13, + g_bytes + 131), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[13], 14, + g_bytes + 144), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[14], 12, + g_bytes + 158), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15], 16, + g_bytes + 170), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16], 15, + g_bytes + 186), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[17], 30, + g_bytes + 201), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[18], 37, + g_bytes + 231), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[19], 10, + g_bytes + 268), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[20], 4, + g_bytes + 278), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[21], 26, + g_bytes + 282), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[22], 22, + g_bytes + 308), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[23], 12, + g_bytes + 330), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[24], 1, + g_bytes + 342), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[25], 1, + g_bytes + 343), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[26], 1, + g_bytes + 344), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[27], 1, + g_bytes + 345), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[29], 19, + g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[30], 12, + g_bytes + 365), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[31], 30, + g_bytes + 377), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[32], 31, + g_bytes + 407), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[33], 36, + g_bytes + 438), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[34], 28, + g_bytes + 474), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[35], 80, + g_bytes + 502), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[36], 7, + g_bytes + 582), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37], 4, + g_bytes + 589), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[38], 11, + g_bytes + 593), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[39], 3, + g_bytes + 604), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[40], 4, + g_bytes + 607), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[41], 1, + g_bytes + 611), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[42], 11, + g_bytes + 612), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[43], 4, + g_bytes + 623), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[44], 5, + g_bytes + 627), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[45], 3, + g_bytes + 632), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[46], 3, + g_bytes + 635), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[47], 3, + g_bytes + 638), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[48], 3, + g_bytes + 641), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[49], 3, + g_bytes + 644), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[50], 3, + g_bytes + 647), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[51], 3, + g_bytes + 650), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[52], 14, + g_bytes + 653), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[53], 13, + g_bytes + 667), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[54], 15, + g_bytes + 680), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[55], 13, + g_bytes + 695), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[56], 6, + g_bytes + 708), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[57], 27, + g_bytes + 714), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[58], 3, + g_bytes + 741), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[59], 5, + g_bytes + 744), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[60], 13, + g_bytes + 749), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[61], 13, + g_bytes + 762), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[62], 19, + g_bytes + 775), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[63], 16, + g_bytes + 794), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[64], 14, + g_bytes + 810), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[65], 16, + g_bytes + 824), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[66], 13, + g_bytes + 840), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[67], 6, + g_bytes + 853), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[68], 4, + g_bytes + 859), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[69], 4, + g_bytes + 863), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[70], 6, + g_bytes + 867), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[71], 7, + g_bytes + 873), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[72], 4, + g_bytes + 880), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[73], 8, + g_bytes + 884), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[74], 17, + g_bytes + 892), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[75], 13, + g_bytes + 909), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[76], 8, + g_bytes + 922), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[77], 19, + g_bytes + 930), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[78], 13, + g_bytes + 949), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[79], 4, + g_bytes + 962), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[80], 8, + g_bytes + 966), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[81], 12, + g_bytes + 974), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[82], 18, + g_bytes + 986), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[83], 19, + g_bytes + 1004), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[84], 5, + g_bytes + 1023), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[85], 7, + g_bytes + 1028), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[86], 7, + g_bytes + 1035), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[87], 11, + g_bytes + 1042), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[88], 6, + g_bytes + 1053), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[89], 10, + g_bytes + 1059), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[90], 25, + g_bytes + 1069), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[91], 17, + g_bytes + 1094), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[92], 4, + g_bytes + 1111), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[93], 3, + g_bytes + 1115), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[94], 16, + g_bytes + 1118), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[95], 1, + g_bytes + 1134), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96], 8, + g_bytes + 1135), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97], 8, + g_bytes + 1143), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98], 16, + g_bytes + 1151), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[99], 4, + g_bytes + 1167), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[100], 3, + g_bytes + 1171), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[101], 11, + g_bytes + 1174), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[102], 16, + g_bytes + 1185), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[103], 13, + g_bytes + 1201), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[104], 12, + g_bytes + 1214), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[105], 21, + g_bytes + 1226), }; /* Warning: the core static metadata currently operates under the soft @@ -830,260 +937,515 @@ grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b) { grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[3], {{10, g_bytes + 19}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 0), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, - {&grpc_static_metadata_refcounts[39], {{3, g_bytes + 604}}}, 1), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, - {&grpc_static_metadata_refcounts[40], {{4, g_bytes + 607}}}, 2), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[0], {{5, g_bytes + 0}}}, - {&grpc_static_metadata_refcounts[41], {{1, g_bytes + 611}}}, 3), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[0], {{5, g_bytes + 0}}}, - {&grpc_static_metadata_refcounts[42], {{11, g_bytes + 612}}}, 4), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, - {&grpc_static_metadata_refcounts[43], {{4, g_bytes + 623}}}, 5), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, - {&grpc_static_metadata_refcounts[44], {{5, g_bytes + 627}}}, 6), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[45], {{3, g_bytes + 632}}}, 7), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[46], {{3, g_bytes + 635}}}, 8), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[47], {{3, g_bytes + 638}}}, 9), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[48], {{3, g_bytes + 641}}}, 10), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[49], {{3, g_bytes + 644}}}, 11), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[50], {{3, g_bytes + 647}}}, 12), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[2], {{7, g_bytes + 12}}}, - {&grpc_static_metadata_refcounts[51], {{3, g_bytes + 650}}}, 13), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[52], {{14, g_bytes + 653}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 14), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[53], {{13, g_bytes + 667}}}, 15), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[54], {{15, g_bytes + 680}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 16), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[55], {{13, g_bytes + 695}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 17), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[56], {{6, g_bytes + 708}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 18), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[57], {{27, g_bytes + 714}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 19), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[58], {{3, g_bytes + 741}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 20), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[59], {{5, g_bytes + 744}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 21), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[60], {{13, g_bytes + 749}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 22), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[61], {{13, g_bytes + 762}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 23), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[62], {{19, g_bytes + 775}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 24), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 25), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[63], {{16, g_bytes + 794}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 26), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[64], {{14, g_bytes + 810}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 27), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[65], {{16, g_bytes + 824}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 28), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[66], {{13, g_bytes + 840}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 29), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[14], {{12, g_bytes + 158}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 30), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[67], {{6, g_bytes + 853}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 31), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[68], {{4, g_bytes + 859}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 32), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[69], {{4, g_bytes + 863}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 33), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[70], {{6, g_bytes + 867}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 34), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[71], {{7, g_bytes + 873}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 35), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[72], {{4, g_bytes + 880}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 36), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[20], {{4, g_bytes + 278}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 37), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[73], {{8, g_bytes + 884}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 38), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[74], {{17, g_bytes + 892}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 39), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[75], {{13, g_bytes + 909}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 40), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[76], {{8, g_bytes + 922}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 41), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[77], {{19, g_bytes + 930}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 42), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[78], {{13, g_bytes + 949}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 43), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[79], {{4, g_bytes + 962}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 44), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[80], {{8, g_bytes + 966}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 45), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[81], {{12, g_bytes + 974}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 46), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[82], {{18, g_bytes + 986}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 47), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[83], {{19, g_bytes + 1004}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 48), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[84], {{5, g_bytes + 1023}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 49), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[85], {{7, g_bytes + 1028}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 50), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[86], {{7, g_bytes + 1035}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 51), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[87], {{11, g_bytes + 1042}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 52), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[88], {{6, g_bytes + 1053}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 53), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[89], {{10, g_bytes + 1059}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 54), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[90], {{25, g_bytes + 1069}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 55), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[91], {{17, g_bytes + 1094}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 56), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[19], {{10, g_bytes + 268}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 57), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[92], {{4, g_bytes + 1111}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 58), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[93], {{3, g_bytes + 1115}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 59), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[94], {{16, g_bytes + 1118}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 60), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, - {&grpc_static_metadata_refcounts[95], {{1, g_bytes + 1134}}}, 61), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, - {&grpc_static_metadata_refcounts[24], {{1, g_bytes + 342}}}, 62), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[7], {{11, g_bytes + 50}}}, - {&grpc_static_metadata_refcounts[25], {{1, g_bytes + 343}}}, 63), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, - {&grpc_static_metadata_refcounts[96], {{8, g_bytes + 1135}}}, 64), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, - {&grpc_static_metadata_refcounts[37], {{4, g_bytes + 589}}}, 65), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[9], {{13, g_bytes + 77}}}, - {&grpc_static_metadata_refcounts[36], {{7, g_bytes + 582}}}, 66), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[5], {{2, g_bytes + 36}}}, - {&grpc_static_metadata_refcounts[97], {{8, g_bytes + 1143}}}, 67), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[14], {{12, g_bytes + 158}}}, - {&grpc_static_metadata_refcounts[98], {{16, g_bytes + 1151}}}, 68), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[4], {{7, g_bytes + 29}}}, - {&grpc_static_metadata_refcounts[99], {{4, g_bytes + 1167}}}, 69), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[1], {{7, g_bytes + 5}}}, - {&grpc_static_metadata_refcounts[100], {{3, g_bytes + 1171}}}, 70), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 71), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, - {&grpc_static_metadata_refcounts[96], {{8, g_bytes + 1135}}}, 72), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[15], {{16, g_bytes + 170}}}, - {&grpc_static_metadata_refcounts[37], {{4, g_bytes + 589}}}, 73), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[101], {{11, g_bytes + 1174}}}, - {&grpc_static_metadata_refcounts[28], {{0, g_bytes + 346}}}, 74), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[96], {{8, g_bytes + 1135}}}, 75), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[36], {{7, g_bytes + 582}}}, 76), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[102], {{16, g_bytes + 1185}}}, 77), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[37], {{4, g_bytes + 589}}}, 78), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[103], {{13, g_bytes + 1201}}}, 79), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[104], {{12, g_bytes + 1214}}}, 80), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[10], {{20, g_bytes + 90}}}, - {&grpc_static_metadata_refcounts[105], {{21, g_bytes + 1226}}}, 81), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[96], {{8, g_bytes + 1135}}}, 82), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[37], {{4, g_bytes + 589}}}, 83), - grpc_core::StaticMetadata( - {&grpc_static_metadata_refcounts[16], {{15, g_bytes + 186}}}, - {&grpc_static_metadata_refcounts[103], {{13, g_bytes + 1201}}}, 84), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[3], 10, + g_bytes + 19), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 0), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1], 7, + g_bytes + 5), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[39], 3, + g_bytes + 604), + 1), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1], 7, + g_bytes + 5), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[40], 4, + g_bytes + 607), + 2), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[0], 5, + g_bytes + 0), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[41], 1, + g_bytes + 611), + 3), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[0], 5, + g_bytes + 0), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[42], 11, + g_bytes + 612), + 4), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4], 7, + g_bytes + 29), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[43], 4, + g_bytes + 623), + 5), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4], 7, + g_bytes + 29), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[44], 5, + g_bytes + 627), + 6), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2], 7, + g_bytes + 12), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[45], 3, + g_bytes + 632), + 7), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2], 7, + g_bytes + 12), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[46], 3, + g_bytes + 635), + 8), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2], 7, + g_bytes + 12), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[47], 3, + g_bytes + 638), + 9), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2], 7, + g_bytes + 12), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[48], 3, + g_bytes + 641), + 10), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2], 7, + g_bytes + 12), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[49], 3, + g_bytes + 644), + 11), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2], 7, + g_bytes + 12), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[50], 3, + g_bytes + 647), + 12), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2], 7, + g_bytes + 12), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[51], 3, + g_bytes + 650), + 13), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[52], 14, + g_bytes + 653), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 14), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16], 15, + g_bytes + 186), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[53], 13, + g_bytes + 667), + 15), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[54], 15, + g_bytes + 680), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 16), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[55], 13, + g_bytes + 695), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 17), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[56], 6, + g_bytes + 708), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 18), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[57], 27, + g_bytes + 714), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 19), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[58], 3, + g_bytes + 741), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 20), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[59], 5, + g_bytes + 744), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 21), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[60], 13, + g_bytes + 749), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 22), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[61], 13, + g_bytes + 762), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 23), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[62], 19, + g_bytes + 775), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 24), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15], 16, + g_bytes + 170), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 25), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[63], 16, + g_bytes + 794), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 26), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[64], 14, + g_bytes + 810), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 27), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[65], 16, + g_bytes + 824), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 28), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[66], 13, + g_bytes + 840), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 29), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[14], 12, + g_bytes + 158), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 30), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[67], 6, + g_bytes + 853), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 31), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[68], 4, + g_bytes + 859), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 32), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[69], 4, + g_bytes + 863), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 33), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[70], 6, + g_bytes + 867), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 34), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[71], 7, + g_bytes + 873), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 35), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[72], 4, + g_bytes + 880), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 36), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[20], 4, + g_bytes + 278), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 37), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[73], 8, + g_bytes + 884), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 38), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[74], 17, + g_bytes + 892), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 39), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[75], 13, + g_bytes + 909), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 40), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[76], 8, + g_bytes + 922), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 41), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[77], 19, + g_bytes + 930), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 42), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[78], 13, + g_bytes + 949), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 43), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[79], 4, + g_bytes + 962), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 44), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[80], 8, + g_bytes + 966), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 45), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[81], 12, + g_bytes + 974), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 46), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[82], 18, + g_bytes + 986), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 47), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[83], 19, + g_bytes + 1004), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 48), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[84], 5, + g_bytes + 1023), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 49), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[85], 7, + g_bytes + 1028), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 50), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[86], 7, + g_bytes + 1035), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 51), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[87], 11, + g_bytes + 1042), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 52), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[88], 6, + g_bytes + 1053), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 53), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[89], 10, + g_bytes + 1059), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 54), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[90], 25, + g_bytes + 1069), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 55), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[91], 17, + g_bytes + 1094), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 56), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[19], 10, + g_bytes + 268), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 57), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[92], 4, + g_bytes + 1111), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 58), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[93], 3, + g_bytes + 1115), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 59), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[94], 16, + g_bytes + 1118), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 60), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7], 11, + g_bytes + 50), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[95], 1, + g_bytes + 1134), + 61), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7], 11, + g_bytes + 50), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[24], 1, + g_bytes + 342), + 62), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7], 11, + g_bytes + 50), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[25], 1, + g_bytes + 343), + 63), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9], 13, + g_bytes + 77), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96], 8, + g_bytes + 1135), + 64), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9], 13, + g_bytes + 77), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37], 4, + g_bytes + 589), + 65), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9], 13, + g_bytes + 77), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[36], 7, + g_bytes + 582), + 66), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[5], 2, + g_bytes + 36), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97], 8, + g_bytes + 1143), + 67), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[14], 12, + g_bytes + 158), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98], 16, + g_bytes + 1151), + 68), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4], 7, + g_bytes + 29), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[99], 4, + g_bytes + 1167), + 69), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1], 7, + g_bytes + 5), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[100], 3, + g_bytes + 1171), + 70), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16], 15, + g_bytes + 186), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 71), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15], 16, + g_bytes + 170), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96], 8, + g_bytes + 1135), + 72), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15], 16, + g_bytes + 170), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37], 4, + g_bytes + 589), + 73), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[101], 11, + g_bytes + 1174), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, + g_bytes + 346), + 74), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10], 20, + g_bytes + 90), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96], 8, + g_bytes + 1135), + 75), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10], 20, + g_bytes + 90), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[36], 7, + g_bytes + 582), + 76), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10], 20, + g_bytes + 90), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[102], 16, + g_bytes + 1185), + 77), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10], 20, + g_bytes + 90), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37], 4, + g_bytes + 589), + 78), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10], 20, + g_bytes + 90), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[103], 13, + g_bytes + 1201), + 79), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10], 20, + g_bytes + 90), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[104], 12, + g_bytes + 1214), + 80), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10], 20, + g_bytes + 90), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[105], 21, + g_bytes + 1226), + 81), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16], 15, + g_bytes + 186), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96], 8, + g_bytes + 1135), + 82), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16], 15, + g_bytes + 186), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37], 4, + g_bytes + 589), + 83), + grpc_core::StaticMetadata( + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16], 15, + g_bytes + 186), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[103], 13, + g_bytes + 1201), + 84), }; const uint8_t grpc_static_accept_encoding_metadata[8] = {0, 75, 76, 77, 78, 79, 80, 81}; diff --git a/src/core/lib/transport/static_metadata.h b/src/core/lib/transport/static_metadata.h index 991a7970cb6..7c05b27cc07 100644 --- a/src/core/lib/transport/static_metadata.h +++ b/src/core/lib/transport/static_metadata.h @@ -33,8 +33,12 @@ #include "src/core/lib/transport/metadata.h" +static_assert( + std::is_trivially_destructible::value, + "grpc_core::StaticMetadataSlice must be trivially destructible."); #define GRPC_STATIC_MDSTR_COUNT 106 -extern const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT]; +extern const grpc_core::StaticMetadataSlice + grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT]; /* ":path" */ #define GRPC_MDSTR_PATH (grpc_static_slice_table[0]) /* ":method" */ diff --git a/src/cpp/ext/filters/census/client_filter.cc b/src/cpp/ext/filters/census/client_filter.cc index 940d42d1000..0f69e793551 100644 --- a/src/cpp/ext/filters/census/client_filter.cc +++ b/src/cpp/ext/filters/census/client_filter.cc @@ -94,7 +94,7 @@ void CensusClientCallData::StartTransportStreamOpBatch( op->send_initial_metadata()->batch(), &tracing_bin_, grpc_mdelem_from_slices( GRPC_MDSTR_GRPC_TRACE_BIN, - grpc_slice_from_copied_buffer(tracing_buf_, tracing_len)))); + grpc_core::UnmanagedMemorySlice(tracing_buf_, tracing_len)))); } grpc_slice tags = grpc_empty_slice(); // TODO: Add in tagging serialization. diff --git a/src/cpp/ext/filters/census/server_filter.cc b/src/cpp/ext/filters/census/server_filter.cc index b5f3d5a13a7..603d1f90bbb 100644 --- a/src/cpp/ext/filters/census/server_filter.cc +++ b/src/cpp/ext/filters/census/server_filter.cc @@ -155,7 +155,7 @@ void CensusServerCallData::StartTransportStreamOpBatch( op->send_trailing_metadata()->batch(), &census_bin_, grpc_mdelem_from_slices( GRPC_MDSTR_GRPC_SERVER_STATS_BIN, - grpc_slice_from_copied_buffer(stats_buf_, len)))); + grpc_core::UnmanagedMemorySlice(stats_buf_, len)))); } } // Call next op. diff --git a/test/cpp/microbenchmarks/bm_metadata.cc b/test/cpp/microbenchmarks/bm_metadata.cc index ff8fe541dfc..d472363eb87 100644 --- a/test/cpp/microbenchmarks/bm_metadata.cc +++ b/test/cpp/microbenchmarks/bm_metadata.cc @@ -21,6 +21,7 @@ #include #include +#include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/static_metadata.h" @@ -30,7 +31,7 @@ static void BM_SliceFromStatic(benchmark::State& state) { TrackCounters track_counters; while (state.KeepRunning()) { - benchmark::DoNotOptimize(grpc_slice_from_static_string("abc")); + benchmark::DoNotOptimize(grpc_core::ExternallyManagedSlice("abc")); } track_counters.Finish(state); } @@ -39,7 +40,7 @@ BENCHMARK(BM_SliceFromStatic); static void BM_SliceFromCopied(benchmark::State& state) { TrackCounters track_counters; while (state.KeepRunning()) { - grpc_slice_unref(grpc_slice_from_copied_string("abc")); + grpc_slice_unref(grpc_core::UnmanagedMemorySlice("abc")); } track_counters.Finish(state); } @@ -47,9 +48,9 @@ BENCHMARK(BM_SliceFromCopied); static void BM_SliceIntern(benchmark::State& state) { TrackCounters track_counters; - gpr_slice slice = grpc_slice_from_static_string("abc"); + grpc_core::ExternallyManagedSlice slice("abc"); while (state.KeepRunning()) { - grpc_slice_unref(grpc_slice_intern(slice)); + grpc_slice_unref(grpc_core::ManagedMemorySlice(&slice)); } track_counters.Finish(state); } @@ -57,11 +58,11 @@ BENCHMARK(BM_SliceIntern); static void BM_SliceReIntern(benchmark::State& state) { TrackCounters track_counters; - gpr_slice slice = grpc_slice_intern(grpc_slice_from_static_string("abc")); + grpc_core::ExternallyManagedSlice static_slice("abc"); + grpc_core::ManagedMemorySlice slice(&static_slice); while (state.KeepRunning()) { - grpc_slice_unref(grpc_slice_intern(slice)); + grpc_slice_unref(grpc_core::ManagedMemorySlice(&slice)); } - grpc_slice_unref(slice); track_counters.Finish(state); } BENCHMARK(BM_SliceReIntern); @@ -69,7 +70,7 @@ BENCHMARK(BM_SliceReIntern); static void BM_SliceInternStaticMetadata(benchmark::State& state) { TrackCounters track_counters; while (state.KeepRunning()) { - grpc_slice_intern(GRPC_MDSTR_GZIP); + benchmark::DoNotOptimize(grpc_core::ManagedMemorySlice(&GRPC_MDSTR_GZIP)); } track_counters.Finish(state); } @@ -77,9 +78,9 @@ BENCHMARK(BM_SliceInternStaticMetadata); static void BM_SliceInternEqualToStaticMetadata(benchmark::State& state) { TrackCounters track_counters; - gpr_slice slice = grpc_slice_from_static_string("gzip"); + grpc_core::ExternallyManagedSlice slice("gzip"); while (state.KeepRunning()) { - grpc_slice_intern(slice); + benchmark::DoNotOptimize(grpc_core::ManagedMemorySlice(&slice)); } track_counters.Finish(state); } @@ -87,8 +88,8 @@ BENCHMARK(BM_SliceInternEqualToStaticMetadata); static void BM_MetadataFromNonInternedSlices(benchmark::State& state) { TrackCounters track_counters; - gpr_slice k = grpc_slice_from_static_string("key"); - gpr_slice v = grpc_slice_from_static_string("value"); + grpc_core::ExternallyManagedSlice k("key"); + grpc_core::ExternallyManagedSlice v("value"); grpc_core::ExecCtx exec_ctx; while (state.KeepRunning()) { GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr)); @@ -100,8 +101,8 @@ BENCHMARK(BM_MetadataFromNonInternedSlices); static void BM_MetadataFromInternedSlices(benchmark::State& state) { TrackCounters track_counters; - gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key")); - gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value")); + grpc_core::ManagedMemorySlice k("key"); + grpc_core::ManagedMemorySlice v("value"); grpc_core::ExecCtx exec_ctx; while (state.KeepRunning()) { GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr)); @@ -116,8 +117,8 @@ BENCHMARK(BM_MetadataFromInternedSlices); static void BM_MetadataFromInternedSlicesAlreadyInIndex( benchmark::State& state) { TrackCounters track_counters; - gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key")); - gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value")); + grpc_core::ManagedMemorySlice k("key"); + grpc_core::ManagedMemorySlice v("value"); grpc_core::ExecCtx exec_ctx; grpc_mdelem seed = grpc_mdelem_create(k, v, nullptr); while (state.KeepRunning()) { @@ -133,8 +134,8 @@ BENCHMARK(BM_MetadataFromInternedSlicesAlreadyInIndex); static void BM_MetadataFromInternedKey(benchmark::State& state) { TrackCounters track_counters; - gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key")); - gpr_slice v = grpc_slice_from_static_string("value"); + grpc_core::ManagedMemorySlice k("key"); + grpc_core::ExternallyManagedSlice v("value"); grpc_core::ExecCtx exec_ctx; while (state.KeepRunning()) { GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr)); @@ -148,8 +149,8 @@ BENCHMARK(BM_MetadataFromInternedKey); static void BM_MetadataFromNonInternedSlicesWithBackingStore( benchmark::State& state) { TrackCounters track_counters; - gpr_slice k = grpc_slice_from_static_string("key"); - gpr_slice v = grpc_slice_from_static_string("value"); + grpc_core::ExternallyManagedSlice k("key"); + grpc_core::ExternallyManagedSlice v("value"); char backing_store[sizeof(grpc_mdelem_data)]; grpc_core::ExecCtx exec_ctx; while (state.KeepRunning()) { @@ -164,8 +165,8 @@ BENCHMARK(BM_MetadataFromNonInternedSlicesWithBackingStore); static void BM_MetadataFromInternedSlicesWithBackingStore( benchmark::State& state) { TrackCounters track_counters; - gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key")); - gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value")); + grpc_core::ManagedMemorySlice k("key"); + grpc_core::ManagedMemorySlice v("value"); char backing_store[sizeof(grpc_mdelem_data)]; grpc_core::ExecCtx exec_ctx; while (state.KeepRunning()) { @@ -182,8 +183,8 @@ BENCHMARK(BM_MetadataFromInternedSlicesWithBackingStore); static void BM_MetadataFromInternedKeyWithBackingStore( benchmark::State& state) { TrackCounters track_counters; - gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key")); - gpr_slice v = grpc_slice_from_static_string("value"); + grpc_core::ManagedMemorySlice k("key"); + grpc_core::ExternallyManagedSlice v("value"); char backing_store[sizeof(grpc_mdelem_data)]; grpc_core::ExecCtx exec_ctx; while (state.KeepRunning()) { @@ -198,14 +199,12 @@ BENCHMARK(BM_MetadataFromInternedKeyWithBackingStore); static void BM_MetadataFromStaticMetadataStrings(benchmark::State& state) { TrackCounters track_counters; - gpr_slice k = GRPC_MDSTR_STATUS; - gpr_slice v = GRPC_MDSTR_200; grpc_core::ExecCtx exec_ctx; while (state.KeepRunning()) { - GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr)); + GRPC_MDELEM_UNREF( + grpc_mdelem_create(GRPC_MDSTR_STATUS, GRPC_MDSTR_200, nullptr)); } - grpc_slice_unref(k); track_counters.Finish(state); } BENCHMARK(BM_MetadataFromStaticMetadataStrings); @@ -213,14 +212,12 @@ BENCHMARK(BM_MetadataFromStaticMetadataStrings); static void BM_MetadataFromStaticMetadataStringsNotIndexed( benchmark::State& state) { TrackCounters track_counters; - gpr_slice k = GRPC_MDSTR_STATUS; - gpr_slice v = GRPC_MDSTR_GZIP; grpc_core::ExecCtx exec_ctx; while (state.KeepRunning()) { - GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr)); + GRPC_MDELEM_UNREF( + grpc_mdelem_create(GRPC_MDSTR_STATUS, GRPC_MDSTR_GZIP, nullptr)); } - grpc_slice_unref(k); track_counters.Finish(state); } BENCHMARK(BM_MetadataFromStaticMetadataStringsNotIndexed); @@ -229,9 +226,10 @@ static void BM_MetadataRefUnrefExternal(benchmark::State& state) { TrackCounters track_counters; char backing_store[sizeof(grpc_mdelem_data)]; grpc_core::ExecCtx exec_ctx; - grpc_mdelem el = grpc_mdelem_create( - grpc_slice_from_static_string("a"), grpc_slice_from_static_string("b"), - reinterpret_cast(backing_store)); + grpc_mdelem el = + grpc_mdelem_create(grpc_core::ExternallyManagedSlice("a"), + grpc_core::ExternallyManagedSlice("b"), + reinterpret_cast(backing_store)); while (state.KeepRunning()) { GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el)); } @@ -245,8 +243,8 @@ static void BM_MetadataRefUnrefInterned(benchmark::State& state) { TrackCounters track_counters; char backing_store[sizeof(grpc_mdelem_data)]; grpc_core::ExecCtx exec_ctx; - gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key")); - gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value")); + grpc_core::ManagedMemorySlice k("key"); + grpc_core::ManagedMemorySlice v("value"); grpc_mdelem el = grpc_mdelem_create( k, v, reinterpret_cast(backing_store)); grpc_slice_unref(k); @@ -264,8 +262,8 @@ static void BM_MetadataRefUnrefAllocated(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; grpc_mdelem el = - grpc_mdelem_create(grpc_slice_from_static_string("a"), - grpc_slice_from_static_string("b"), nullptr); + grpc_mdelem_create(grpc_core::ExternallyManagedSlice("a"), + grpc_core::ExternallyManagedSlice("b"), nullptr); while (state.KeepRunning()) { GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el)); } diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py index 6b034347bf8..213efd22346 100755 --- a/tools/codegen/core/gen_static_metadata.py +++ b/tools/codegen/core/gen_static_metadata.py @@ -392,16 +392,21 @@ for i, elem in enumerate(all_strs): def slice_def(i): - return ('{&grpc_static_metadata_refcounts[%d],' - ' {{%d, g_bytes+%d}}}') % (i, len(all_strs[i]), id2strofs[i]) + return ( + 'grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[%d], %d, g_bytes+%d)' + ) % (i, len(all_strs[i]), id2strofs[i]) # validate configuration for elem in METADATA_BATCH_CALLOUTS: assert elem in all_strs - +static_slice_dest_assert = ( + 'static_assert(std::is_trivially_destructible' + + '::value, ' + '"grpc_core::StaticMetadataSlice must be trivially destructible.");') +print >> H, static_slice_dest_assert print >> H, '#define GRPC_STATIC_MDSTR_COUNT %d' % len(all_strs) -print >> H, ('extern const grpc_slice ' +print >> H, ('extern const grpc_core::StaticMetadataSlice ' 'grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT];') for i, elem in enumerate(all_strs): print >> H, '/* "%s" */' % elem @@ -425,8 +430,9 @@ print >> H, '#define GRPC_IS_STATIC_METADATA_STRING(slice) \\' print >> H, (' ((slice).refcount != NULL && (slice).refcount->GetType() == ' 'grpc_slice_refcount::Type::STATIC)') print >> H -print >> C, ('const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT]' - ' = {') +print >> C, ( + 'const grpc_core::StaticMetadataSlice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT]' + ' = {') for i, elem in enumerate(all_strs): print >> C, slice_def(i) + ',' print >> C, '};' From f4ff1a12d0431736dc369e181f89c4f9cc5e57a9 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Tue, 30 Jul 2019 19:09:30 -0700 Subject: [PATCH 1050/1555] Whitelisted build_bazel_rules_apple --- tools/run_tests/sanity/check_bazel_workspace.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/run_tests/sanity/check_bazel_workspace.py b/tools/run_tests/sanity/check_bazel_workspace.py index 10fb0ccf6a8..4ddbc74646f 100755 --- a/tools/run_tests/sanity/check_bazel_workspace.py +++ b/tools/run_tests/sanity/check_bazel_workspace.py @@ -63,6 +63,7 @@ _GRPC_DEP_NAMES = [ _ZOPEFOUNDATION_ZOPE_INTERFACE_DEP_NAME, _TWISTED_CONSTANTLY_DEP_NAME, 'io_bazel_rules_go', + 'build_bazel_rules_apple', ] _GRPC_BAZEL_ONLY_DEPS = [ @@ -76,6 +77,7 @@ _GRPC_BAZEL_ONLY_DEPS = [ _ZOPEFOUNDATION_ZOPE_INTERFACE_DEP_NAME, _TWISTED_CONSTANTLY_DEP_NAME, 'io_bazel_rules_go', + 'build_bazel_rules_apple', ] @@ -106,6 +108,13 @@ class BazelEvalState(object): return self.names_and_urls[args['name']] = args['url'] + def git_repository(self, **args): + assert self.names_and_urls.get(args['name']) is None + if args['name'] in _GRPC_BAZEL_ONLY_DEPS: + self.names_and_urls[args['name']] = 'dont care' + return + self.names_and_urls[args['name']] = args['remote'] + # Parse git hashes from bazel/grpc_deps.bzl {new_}http_archive rules with open(os.path.join('bazel', 'grpc_deps.bzl'), 'r') as f: @@ -121,6 +130,7 @@ build_rules = { 'native': eval_state, 'http_archive': lambda **args: eval_state.http_archive(**args), 'load': lambda a, b: None, + 'git_repository': lambda **args: eval_state.git_repository(**args), } exec bazel_file in build_rules for name in _GRPC_DEP_NAMES: @@ -162,6 +172,7 @@ for name in _GRPC_DEP_NAMES: 'native': state, 'http_archive': lambda **args: state.http_archive(**args), 'load': lambda a, b: None, + 'git_repository': lambda **args: state.git_repository(**args), } exec bazel_file in rules assert name not in names_and_urls_with_overridden_name.keys() From b2cda1e1853bcf17cf3fc0449f9065698e6f60cb Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Wed, 17 Jul 2019 11:17:54 -0700 Subject: [PATCH 1051/1555] Reduced ops for grpc_chttp2_stream_map_find(). Several asserts in grpc_chttp2_stream_map_find() can be converted to debug asserts. This PR also templatizes the internal find() method to have it be strict in the delete case (which saves some branches). --- .../chttp2/transport/chttp2_transport.cc | 8 +--- .../ext/transport/chttp2/transport/internal.h | 7 ++- .../transport/chttp2/transport/stream_map.cc | 46 +++++++++++-------- test/core/transport/chttp2/stream_map_test.cc | 24 ---------- 4 files changed, 34 insertions(+), 51 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index aff4506577e..16146569886 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -785,12 +785,6 @@ static void destroy_stream(grpc_transport* gt, grpc_stream* gs, GRPC_ERROR_NONE); } -grpc_chttp2_stream* grpc_chttp2_parsing_lookup_stream(grpc_chttp2_transport* t, - uint32_t id) { - return static_cast( - grpc_chttp2_stream_map_find(&t->stream_map, id)); -} - grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_chttp2_transport* t, uint32_t id) { if (t->channel_callback.accept_stream == nullptr) { @@ -2069,7 +2063,7 @@ static void remove_stream(grpc_chttp2_transport* t, uint32_t id, grpc_error* error) { grpc_chttp2_stream* s = static_cast( grpc_chttp2_stream_map_delete(&t->stream_map, id)); - GPR_ASSERT(s); + GPR_DEBUG_ASSERT(s); if (t->incoming_stream == s) { t->incoming_stream = nullptr; grpc_chttp2_parsing_become_skip_parser(t); diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 732bc38a0ac..643cd25b8bd 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -745,8 +745,11 @@ void grpc_chttp2_act_on_flowctl_action( /********* End of Flow Control ***************/ -grpc_chttp2_stream* grpc_chttp2_parsing_lookup_stream(grpc_chttp2_transport* t, - uint32_t id); +inline grpc_chttp2_stream* grpc_chttp2_parsing_lookup_stream( + grpc_chttp2_transport* t, uint32_t id) { + return static_cast( + grpc_chttp2_stream_map_find(&t->stream_map, id)); +} grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_chttp2_transport* t, uint32_t id); diff --git a/src/core/ext/transport/chttp2/transport/stream_map.cc b/src/core/ext/transport/chttp2/transport/stream_map.cc index f300e2356c9..647214b94a0 100644 --- a/src/core/ext/transport/chttp2/transport/stream_map.cc +++ b/src/core/ext/transport/chttp2/transport/stream_map.cc @@ -27,7 +27,7 @@ void grpc_chttp2_stream_map_init(grpc_chttp2_stream_map* map, size_t initial_capacity) { - GPR_ASSERT(initial_capacity > 1); + GPR_DEBUG_ASSERT(initial_capacity > 1); map->keys = static_cast(gpr_malloc(sizeof(uint32_t) * initial_capacity)); map->values = @@ -63,9 +63,17 @@ void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map* map, uint32_t key, uint32_t* keys = map->keys; void** values = map->values; + // The first assertion ensures that the table is monotonically increasing. GPR_ASSERT(count == 0 || keys[count - 1] < key); - GPR_ASSERT(value); - GPR_ASSERT(grpc_chttp2_stream_map_find(map, key) == nullptr); + GPR_DEBUG_ASSERT(value); + // Asserting that the key is not already in the map can be a debug assertion. + // Why: we're already checking that the map elements are monotonically + // increasing. If we re-add a key, i.e. if the key is already present, then + // either it is the most recently added key in the map (in which case the + // first assertion fails due to key == last_key) or there is a more recently + // added (larger) key at the end of the map: in which case the first assertion + // still fails due to key < last_key. + GPR_DEBUG_ASSERT(grpc_chttp2_stream_map_find(map, key) == nullptr); if (count == capacity) { if (map->free > capacity / 4) { @@ -74,7 +82,7 @@ void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map* map, uint32_t key, } else { /* resize when less than 25% of the table is free, because compaction won't help much */ - map->capacity = capacity = 3 * capacity / 2; + map->capacity = capacity = 2 * capacity; map->keys = keys = static_cast( gpr_realloc(keys, capacity * sizeof(uint32_t))); map->values = values = @@ -87,6 +95,7 @@ void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map* map, uint32_t key, map->count = count + 1; } +template static void** find(grpc_chttp2_stream_map* map, uint32_t key) { size_t min_idx = 0; size_t max_idx = map->count; @@ -95,7 +104,8 @@ static void** find(grpc_chttp2_stream_map* map, uint32_t key) { void** values = map->values; uint32_t mid_key; - if (max_idx == 0) return nullptr; + GPR_DEBUG_ASSERT(!strict_find || max_idx > 0); + if (!strict_find && max_idx == 0) return nullptr; while (min_idx < max_idx) { /* find the midpoint, avoiding overflow */ @@ -112,28 +122,28 @@ static void** find(grpc_chttp2_stream_map* map, uint32_t key) { } } + GPR_DEBUG_ASSERT(!strict_find); return nullptr; } void* grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map* map, uint32_t key) { - void** pvalue = find(map, key); - void* out = nullptr; - if (pvalue != nullptr) { - out = *pvalue; - *pvalue = nullptr; - map->free += (out != nullptr); - /* recognize complete emptyness and ensure we can skip - * defragmentation later */ - if (map->free == map->count) { - map->free = map->count = 0; - } - GPR_ASSERT(grpc_chttp2_stream_map_find(map, key) == nullptr); + void** pvalue = find(map, key); + GPR_DEBUG_ASSERT(pvalue != nullptr); + void* out = *pvalue; + GPR_DEBUG_ASSERT(out != nullptr); + *pvalue = nullptr; + map->free++; + /* recognize complete emptyness and ensure we can skip + defragmentation later */ + if (map->free == map->count) { + map->free = map->count = 0; } + GPR_DEBUG_ASSERT(grpc_chttp2_stream_map_find(map, key) == nullptr); return out; } void* grpc_chttp2_stream_map_find(grpc_chttp2_stream_map* map, uint32_t key) { - void** pvalue = find(map, key); + void** pvalue = find(map, key); return pvalue != nullptr ? *pvalue : nullptr; } diff --git a/test/core/transport/chttp2/stream_map_test.cc b/test/core/transport/chttp2/stream_map_test.cc index a36c496eb1e..3452c86cdc9 100644 --- a/test/core/transport/chttp2/stream_map_test.cc +++ b/test/core/transport/chttp2/stream_map_test.cc @@ -43,29 +43,6 @@ static void test_empty_find(void) { grpc_chttp2_stream_map_destroy(&map); } -/* test it's safe to delete twice */ -static void test_double_deletion(void) { - grpc_chttp2_stream_map map; - - LOG_TEST("test_double_deletion"); - - grpc_chttp2_stream_map_init(&map, 8); - GPR_ASSERT(0 == grpc_chttp2_stream_map_size(&map)); - grpc_chttp2_stream_map_add(&map, 1, (void*)1); - GPR_ASSERT((void*)1 == grpc_chttp2_stream_map_find(&map, 1)); - GPR_ASSERT(1 == grpc_chttp2_stream_map_size(&map)); - GPR_ASSERT((void*)1 == grpc_chttp2_stream_map_delete(&map, 1)); - GPR_ASSERT(0 == grpc_chttp2_stream_map_size(&map)); - GPR_ASSERT(nullptr == grpc_chttp2_stream_map_find(&map, 1)); - GPR_ASSERT(nullptr == grpc_chttp2_stream_map_delete(&map, 1)); - GPR_ASSERT(nullptr == grpc_chttp2_stream_map_find(&map, 1)); - GPR_ASSERT(nullptr == grpc_chttp2_stream_map_delete(&map, 1)); - GPR_ASSERT(nullptr == grpc_chttp2_stream_map_find(&map, 1)); - GPR_ASSERT(nullptr == grpc_chttp2_stream_map_delete(&map, 1)); - GPR_ASSERT(nullptr == grpc_chttp2_stream_map_find(&map, 1)); - grpc_chttp2_stream_map_destroy(&map); -} - /* test add & lookup */ static void test_basic_add_find(uint32_t n) { grpc_chttp2_stream_map map; @@ -197,7 +174,6 @@ int main(int argc, char** argv) { test_no_op(); test_empty_find(); - test_double_deletion(); while (n < 100000) { test_basic_add_find(n); From ec181d96957fc150d8c8545752a2ca483741d738 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 31 Jul 2019 14:15:50 -0700 Subject: [PATCH 1052/1555] Added TvTests target with Xcode 9.2 --- src/objective-c/tests/Podfile | 45 ++- .../tests/RemoteTestClient/RemoteTest.podspec | 2 + .../tests/Tests.xcodeproj/project.pbxproj | 267 +++++++++++++++++- .../xcshareddata/xcschemes/TvTests.xcscheme | 95 +++++++ src/objective-c/tests/TvTests/Info.plist | 22 ++ 5 files changed, 390 insertions(+), 41 deletions(-) create mode 100644 src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/TvTests.xcscheme create mode 100644 src/objective-c/tests/TvTests/Info.plist diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile index 60d2a98fba2..442f3599bb1 100644 --- a/src/objective-c/tests/Podfile +++ b/src/objective-c/tests/Podfile @@ -5,15 +5,14 @@ install! 'cocoapods', :deterministic_uuids => false # Location of gRPC's repo root relative to this file. GRPC_LOCAL_SRC = '../../..' -target 'MacTests' do - platform :osx, '10.13' +def grpc_deps pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf", :inhibit_warnings => true - + pod '!ProtoCompiler', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" pod '!ProtoCompiler-gRPCPlugin', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" - + pod 'BoringSSL-GRPC', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true - + pod 'gRPC', :path => GRPC_LOCAL_SRC pod 'gRPC-Core', :path => GRPC_LOCAL_SRC pod 'gRPC-RxLibrary', :path => GRPC_LOCAL_SRC @@ -21,20 +20,19 @@ target 'MacTests' do pod 'RemoteTest', :path => "RemoteTestClient", :inhibit_warnings => true end +target 'TvTests' do + platform :tvos, '10.0' + grpc_deps +end + +target 'MacTests' do + platform :osx, '10.13' + grpc_deps +end + target 'UnitTests' do platform :ios, '8.0' - pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf", :inhibit_warnings => true - - pod '!ProtoCompiler', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" - pod '!ProtoCompiler-gRPCPlugin', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" - - pod 'BoringSSL-GRPC', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true - - pod 'gRPC', :path => GRPC_LOCAL_SRC - pod 'gRPC-Core', :path => GRPC_LOCAL_SRC - pod 'gRPC-RxLibrary', :path => GRPC_LOCAL_SRC - pod 'gRPC-ProtoRPC', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true - pod 'RemoteTest', :path => "RemoteTestClient", :inhibit_warnings => true + grpc_deps end %w( @@ -43,18 +41,7 @@ end ).each do |target_name| target target_name do platform :ios, '8.0' - pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf", :inhibit_warnings => true - - pod '!ProtoCompiler', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" - pod '!ProtoCompiler-gRPCPlugin', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" - - pod 'BoringSSL-GRPC', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true - - pod 'gRPC', :path => GRPC_LOCAL_SRC - pod 'gRPC-Core', :path => GRPC_LOCAL_SRC - pod 'gRPC-RxLibrary', :path => GRPC_LOCAL_SRC - pod 'gRPC-ProtoRPC', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true - pod 'RemoteTest', :path => "RemoteTestClient", :inhibit_warnings => true + grpc_deps pod 'gRPC-Core/Cronet-Implementation', :path => GRPC_LOCAL_SRC pod 'CronetFramework', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" diff --git a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec index 93b56d56059..be8fce9993b 100644 --- a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec +++ b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec @@ -9,6 +9,8 @@ Pod::Spec.new do |s| s.ios.deployment_target = '7.1' s.osx.deployment_target = '10.9' + s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '4.0' # Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients. s.dependency "!ProtoCompiler-gRPCPlugin" diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index 737d52b547d..8548620522d 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -37,16 +37,26 @@ 65EB19E418B39A8374D407BB /* libPods-CronetTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B1511C20E16A8422B58D61A /* libPods-CronetTests.a */; }; 903163C7FE885838580AEC7A /* libPods-InteropTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D457AD9797664CFA191C3280 /* libPods-InteropTests.a */; }; 953CD2942A3A6D6CE695BE87 /* libPods-MacTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 276873A05AC5479B60DF6079 /* libPods-MacTests.a */; }; + ABCB3EE422F23BEF00F0FECE /* InteropTestsRemote.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F488822778B04006656AD /* InteropTestsRemote.m */; }; + ABCB3EE522F23BEF00F0FECE /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F488222778A88006656AD /* InteropTests.m */; }; + ABCB3EE622F23BEF00F0FECE /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; + ABCB3EE722F23BEF00F0FECE /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; + ABCB3EE822F23BEF00F0FECE /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; + ABCB3EE922F23BF500F0FECE /* RxLibraryUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F488A22778B5D006656AD /* RxLibraryUnitTests.m */; }; + ABCB3EEA22F23BF500F0FECE /* APIv2Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487F227782C1006656AD /* APIv2Tests.m */; }; + ABCB3EEB22F23BF500F0FECE /* NSErrorUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E0282E8215AA697007AC99D /* NSErrorUnitTests.m */; }; B071230B22669EED004B64A1 /* StressTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B071230A22669EED004B64A1 /* StressTests.m */; }; B0BB3F08225E7ABA008DA580 /* NSErrorUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E0282E8215AA697007AC99D /* NSErrorUnitTests.m */; }; B0BB3F0A225EA511008DA580 /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; B0D39B9A2266F3CB00A4078D /* StressTestsSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D39B992266F3CB00A4078D /* StressTestsSSL.m */; }; B0D39B9C2266FF9800A4078D /* StressTestsCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D39B9B2266FF9800A4078D /* StressTestsCleartext.m */; }; CCF5C0719EF608276AE16374 /* libPods-UnitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 22A3EBB488699C8CEA19707B /* libPods-UnitTests.a */; }; + F4E21D69D650D61FE8F02696 /* libPods-TvTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A0A5455106001F60357A4B6 /* libPods-TvTests.a */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 02192CF1FF9534E3D18C65FC /* Pods-CronetUnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetUnitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests.release.xcconfig"; sourceTree = ""; }; + 038286E5BBEC3F03D4701CCC /* Pods-TvTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TvTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-TvTests/Pods-TvTests.cronet.xcconfig"; sourceTree = ""; }; 070266E2626EB997B54880A3 /* Pods-InteropTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTests/Pods-InteropTests.test.xcconfig"; sourceTree = ""; }; 07D10A965323BEA7FE59A74B /* Pods-RxLibraryUnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.debug.xcconfig"; sourceTree = ""; }; 0A4F89D9C90E9C30990218F0 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; @@ -67,6 +77,7 @@ 22A3EBB488699C8CEA19707B /* libPods-UnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-UnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 2650FEF00956E7924772F9D9 /* Pods-InteropTestsMultipleChannels.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsMultipleChannels.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels.release.xcconfig"; sourceTree = ""; }; 276873A05AC5479B60DF6079 /* libPods-MacTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-MacTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 2A0A5455106001F60357A4B6 /* libPods-TvTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-TvTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 2B89F3037963E6EDDD48D8C3 /* Pods-InteropTestsRemoteWithCronet.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.test.xcconfig"; sourceTree = ""; }; 303F4A17EB1650FC44603D17 /* Pods-InteropTestsRemoteCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream.release.xcconfig"; sourceTree = ""; }; 32748C4078AEB05F8F954361 /* Pods-InteropTestsRemoteCFStream.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteCFStream.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream.debug.xcconfig"; sourceTree = ""; }; @@ -78,6 +89,7 @@ 3CADF86203B9D03EA96C359D /* Pods-InteropTestsMultipleChannels.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsMultipleChannels.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels.debug.xcconfig"; sourceTree = ""; }; 3EB55EF291706E3DDE23C3B7 /* Pods-InteropTestsLocalSSLCFStream.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.debug.xcconfig"; sourceTree = ""; }; 3F27B2E744482771EB93C394 /* Pods-InteropTestsRemoteWithCronet.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.cronet.xcconfig"; sourceTree = ""; }; + 4151F1CACF6F364277DA312F /* Pods-TvTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TvTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TvTests/Pods-TvTests.debug.xcconfig"; sourceTree = ""; }; 41AA59529240A6BBBD3DB904 /* Pods-InteropTestsLocalSSLCFStream.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.test.xcconfig"; sourceTree = ""; }; 48F1841C9A920626995DC28C /* libPods-ChannelTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ChannelTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 4A1A42B2E941CCD453489E5B /* Pods-InteropTestsRemoteCFStream.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteCFStream.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream.cronet.xcconfig"; sourceTree = ""; }; @@ -126,6 +138,7 @@ 7A2E97E3F469CC2A758D77DE /* Pods-InteropTestsLocalSSL.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.release.xcconfig"; sourceTree = ""; }; 7BA53C6D224288D5870FE6F3 /* Pods-InteropTestsLocalCleartextCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.release.xcconfig"; sourceTree = ""; }; 7F4F42EBAF311E9F84FCA32E /* Pods-CronetTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-CronetTests/Pods-CronetTests.release.xcconfig"; sourceTree = ""; }; + 8809F3EB70C19F2CFA1F4CA6 /* Pods-TvTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TvTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-TvTests/Pods-TvTests.release.xcconfig"; sourceTree = ""; }; 8B498B05C6DA0818B2FA91D4 /* Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig"; sourceTree = ""; }; 8C233E85C3EB45B3CAE52EDF /* Pods-APIv2Tests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIv2Tests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests.cronet.xcconfig"; sourceTree = ""; }; 90E63AD3C4A1E3E6BC745096 /* Pods-ChannelTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChannelTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests.cronet.xcconfig"; sourceTree = ""; }; @@ -134,9 +147,12 @@ 9E9444C764F0FFF64A7EB58E /* libPods-InteropTestsRemoteWithCronet.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsRemoteWithCronet.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A25967A0D40ED14B3287AD81 /* Pods-InteropTestsCallOptions.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsCallOptions.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions.test.xcconfig"; sourceTree = ""; }; A2DCF2570BE515B62CB924CA /* Pods-UnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests.debug.xcconfig"; sourceTree = ""; }; + A52BDBDE1F6643E6FD1F3CBA /* Pods-TvTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TvTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-TvTests/Pods-TvTests.test.xcconfig"; sourceTree = ""; }; A58BE6DF1C62D1739EBB2C78 /* libPods-RxLibraryUnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RxLibraryUnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A6F832FCEFA6F6881E620F12 /* Pods-InteropTestsRemote.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemote.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote.test.xcconfig"; sourceTree = ""; }; AA7CB64B4DD9915AE7C03163 /* Pods-InteropTestsLocalCleartext.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartext.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext.cronet.xcconfig"; sourceTree = ""; }; + ABCB3EDA22F23B9700F0FECE /* TvTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TvTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + ABCB3EDE22F23B9700F0FECE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; AC414EF7A6BF76ED02B6E480 /* Pods-InteropTestsRemoteWithCronet.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.release.xcconfig"; sourceTree = ""; }; AF3FC2CFFE7B0961823BC740 /* libPods-InteropTestsCallOptions.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsCallOptions.a"; sourceTree = BUILT_PRODUCTS_DIR; }; B071230A22669EED004B64A1 /* StressTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StressTests.m; sourceTree = ""; }; @@ -204,6 +220,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + ABCB3ED722F23B9700F0FECE /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + F4E21D69D650D61FE8F02696 /* libPods-TvTests.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; B0BB3EF4225E795F008DA580 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -240,6 +264,7 @@ 276873A05AC5479B60DF6079 /* libPods-MacTests.a */, D457AD9797664CFA191C3280 /* libPods-InteropTests.a */, 1B1511C20E16A8422B58D61A /* libPods-CronetTests.a */, + 2A0A5455106001F60357A4B6 /* libPods-TvTests.a */, ); name = Frameworks; sourceTree = ""; @@ -325,6 +350,10 @@ 5AB9A82F289D548D6B8816F9 /* Pods-CronetTests.test.xcconfig */, 20F6A3D59D0EE091E2D43953 /* Pods-CronetTests.cronet.xcconfig */, 7F4F42EBAF311E9F84FCA32E /* Pods-CronetTests.release.xcconfig */, + 4151F1CACF6F364277DA312F /* Pods-TvTests.debug.xcconfig */, + A52BDBDE1F6643E6FD1F3CBA /* Pods-TvTests.test.xcconfig */, + 038286E5BBEC3F03D4701CCC /* Pods-TvTests.cronet.xcconfig */, + 8809F3EB70C19F2CFA1F4CA6 /* Pods-TvTests.release.xcconfig */, ); name = Pods; sourceTree = ""; @@ -376,6 +405,7 @@ 5E0282E7215AA697007AC99D /* UnitTests */, B0BB3EF8225E795F008DA580 /* MacTests */, 5E7F485A22775B15006656AD /* CronetTests */, + ABCB3EDB22F23B9700F0FECE /* TvTests */, 635697C81B14FC11007A7283 /* Products */, 51E4650F34F854F41FF053B3 /* Pods */, 136D535E19727099B941D7B1 /* Frameworks */, @@ -389,6 +419,7 @@ B0BB3EF7225E795F008DA580 /* MacTests.xctest */, 5EA476F42272816A000F72FC /* InteropTests.xctest */, 5E7F485922775B15006656AD /* CronetTests.xctest */, + ABCB3EDA22F23B9700F0FECE /* TvTests.xctest */, ); name = Products; sourceTree = ""; @@ -412,6 +443,14 @@ name = "Supporting Files"; sourceTree = ""; }; + ABCB3EDB22F23B9700F0FECE /* TvTests */ = { + isa = PBXGroup; + children = ( + ABCB3EDE22F23B9700F0FECE /* Info.plist */, + ); + path = TvTests; + sourceTree = ""; + }; B0BB3EF8225E795F008DA580 /* MacTests */ = { isa = PBXGroup; children = ( @@ -486,6 +525,25 @@ productReference = 5EA476F42272816A000F72FC /* InteropTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; + ABCB3ED922F23B9700F0FECE /* TvTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = ABCB3EE322F23B9700F0FECE /* Build configuration list for PBXNativeTarget "TvTests" */; + buildPhases = ( + 03423EFD6B98B0F3DD4C2E0D /* [CP] Check Pods Manifest.lock */, + ABCB3ED622F23B9700F0FECE /* Sources */, + ABCB3ED722F23B9700F0FECE /* Frameworks */, + ABCB3ED822F23B9700F0FECE /* Resources */, + 88CEEDBB95DA992ABDDE8B7E /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = TvTests; + productName = TvTests; + productReference = ABCB3EDA22F23B9700F0FECE /* TvTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; B0BB3EF6225E795F008DA580 /* MacTests */ = { isa = PBXNativeTarget; buildConfigurationList = B0BB3EFC225E795F008DA580 /* Build configuration list for PBXNativeTarget "MacTests" */; @@ -526,6 +584,11 @@ CreatedOnToolsVersion = 10.1; ProvisioningStyle = Automatic; }; + ABCB3ED922F23B9700F0FECE = { + CreatedOnToolsVersion = 9.2; + DevelopmentTeam = 6T98ZJNPG5; + ProvisioningStyle = Automatic; + }; B0BB3EF6225E795F008DA580 = { CreatedOnToolsVersion = 10.1; ProvisioningStyle = Automatic; @@ -549,6 +612,7 @@ B0BB3EF6225E795F008DA580 /* MacTests */, 5EA476F32272816A000F72FC /* InteropTests */, 5E7F485822775B15006656AD /* CronetTests */, + ABCB3ED922F23B9700F0FECE /* TvTests */, ); }; /* End PBXProject section */ @@ -576,6 +640,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + ABCB3ED822F23B9700F0FECE /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; B0BB3EF5225E795F008DA580 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -587,6 +658,24 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 03423EFD6B98B0F3DD4C2E0D /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-TvTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; 0FEFD5FC6B323AC95549AE4A /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -646,15 +735,11 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${PODS_PODFILE_DIR_PATH}/Podfile.lock", "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); outputPaths = ( "$(DERIVED_FILE_DIR)/Pods-InteropTests-checkManifestLockResult.txt", ); @@ -681,6 +766,24 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MacTests/Pods-MacTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; + 88CEEDBB95DA992ABDDE8B7E /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-TvTests/Pods-TvTests-resources.sh", + "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-tvOS/gRPCCertificates.bundle", + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-TvTests/Pods-TvTests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; 9AD0B5E94F2AA5962EA6AA36 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -704,15 +807,11 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${PODS_PODFILE_DIR_PATH}/Podfile.lock", "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); outputPaths = ( "$(DERIVED_FILE_DIR)/Pods-CronetTests-checkManifestLockResult.txt", ); @@ -744,15 +843,11 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${PODS_PODFILE_DIR_PATH}/Podfile.lock", "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); outputPaths = ( "$(DERIVED_FILE_DIR)/Pods-MacTests-checkManifestLockResult.txt", ); @@ -822,6 +917,21 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + ABCB3ED622F23B9700F0FECE /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ABCB3EEA22F23BF500F0FECE /* APIv2Tests.m in Sources */, + ABCB3EE822F23BEF00F0FECE /* InteropTestsBlockCallbacks.m in Sources */, + ABCB3EE422F23BEF00F0FECE /* InteropTestsRemote.m in Sources */, + ABCB3EEB22F23BF500F0FECE /* NSErrorUnitTests.m in Sources */, + ABCB3EE522F23BEF00F0FECE /* InteropTests.m in Sources */, + ABCB3EE722F23BEF00F0FECE /* InteropTestsLocalCleartext.m in Sources */, + ABCB3EE622F23BEF00F0FECE /* InteropTestsLocalSSL.m in Sources */, + ABCB3EE922F23BF500F0FECE /* RxLibraryUnitTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; B0BB3EF3225E795F008DA580 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -1422,6 +1532,128 @@ }; name = Release; }; + ABCB3EDF22F23B9700F0FECE /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 4151F1CACF6F364277DA312F /* Pods-TvTests.debug.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = 6T98ZJNPG5; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = TvTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.google.TvTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = appletvos; + TARGETED_DEVICE_FAMILY = 3; + TVOS_DEPLOYMENT_TARGET = 10.0; + }; + name = Debug; + }; + ABCB3EE022F23B9700F0FECE /* Test */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = A52BDBDE1F6643E6FD1F3CBA /* Pods-TvTests.test.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6T98ZJNPG5; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = TvTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.google.TvTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = appletvos; + TARGETED_DEVICE_FAMILY = 3; + TVOS_DEPLOYMENT_TARGET = 10.0; + }; + name = Test; + }; + ABCB3EE122F23B9700F0FECE /* Cronet */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 038286E5BBEC3F03D4701CCC /* Pods-TvTests.cronet.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6T98ZJNPG5; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = TvTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.google.TvTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = appletvos; + TARGETED_DEVICE_FAMILY = 3; + TVOS_DEPLOYMENT_TARGET = 10.0; + }; + name = Cronet; + }; + ABCB3EE222F23B9700F0FECE /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 8809F3EB70C19F2CFA1F4CA6 /* Pods-TvTests.release.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6T98ZJNPG5; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = TvTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.google.TvTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = appletvos; + TARGETED_DEVICE_FAMILY = 3; + TVOS_DEPLOYMENT_TARGET = 10.0; + }; + name = Release; + }; B0BB3EFD225E795F008DA580 /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = E3ACD4D5902745976D9C2229 /* Pods-MacTests.debug.xcconfig */; @@ -1617,6 +1849,17 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + ABCB3EE322F23B9700F0FECE /* Build configuration list for PBXNativeTarget "TvTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + ABCB3EDF22F23B9700F0FECE /* Debug */, + ABCB3EE022F23B9700F0FECE /* Test */, + ABCB3EE122F23B9700F0FECE /* Cronet */, + ABCB3EE222F23B9700F0FECE /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; B0BB3EFC225E795F008DA580 /* Build configuration list for PBXNativeTarget "MacTests" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/TvTests.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/TvTests.xcscheme new file mode 100644 index 00000000000..cc6823528b5 --- /dev/null +++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/TvTests.xcscheme @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/objective-c/tests/TvTests/Info.plist b/src/objective-c/tests/TvTests/Info.plist new file mode 100644 index 00000000000..6c40a6cd0c4 --- /dev/null +++ b/src/objective-c/tests/TvTests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + From 63e6329c65dbe72993dfb4f26a4c6fe9bc324cff Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 31 Jul 2019 16:47:34 -0700 Subject: [PATCH 1053/1555] Added Kokoro jobs for tvos unit tests --- .../macos/grpc_basictests_objc_tvos.cfg | 32 +++++++++++++++++++ .../grpc_basictests_objc_tvos.cfg | 31 ++++++++++++++++++ tools/run_tests/run_tests.py | 10 ++++++ 3 files changed, 73 insertions(+) create mode 100644 tools/internal_ci/macos/grpc_basictests_objc_tvos.cfg create mode 100644 tools/internal_ci/macos/pull_request/grpc_basictests_objc_tvos.cfg diff --git a/tools/internal_ci/macos/grpc_basictests_objc_tvos.cfg b/tools/internal_ci/macos/grpc_basictests_objc_tvos.cfg new file mode 100644 index 00000000000..a3f3935b5d6 --- /dev/null +++ b/tools/internal_ci/macos/grpc_basictests_objc_tvos.cfg @@ -0,0 +1,32 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" +timeout_mins: 120 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --bq_result_table aggregate_results --extra_args -r tvos-test-.*" +} + diff --git a/tools/internal_ci/macos/pull_request/grpc_basictests_objc_tvos.cfg b/tools/internal_ci/macos/pull_request/grpc_basictests_objc_tvos.cfg new file mode 100644 index 00000000000..ec776def565 --- /dev/null +++ b/tools/internal_ci/macos/pull_request/grpc_basictests_objc_tvos.cfg @@ -0,0 +1,31 @@ +# Copyright 2018 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" +timeout_mins: 120 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --extra_args -r tvos-test-.*" +} diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index f11927bd5d6..06991365136 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1140,6 +1140,16 @@ class ObjCLanguage(object): 'SCHEME': 'MacTests', 'PLATFORM': 'macos' })) + out.append( + self.config.job_spec( + ['src/objective-c/tests/run_one_test.sh'], + timeout_seconds=30 * 60, + shortname='tvos-test-basictests', + cpu_cost=1e6, + environ={ + 'SCHEME': 'TvTests', + 'PLATFORM': 'tvos' + })) return sorted(out) From efe9fd0d60e49bb6ec8f01f73879b9c2d020ddf9 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 26 Jul 2019 17:08:45 +0200 Subject: [PATCH 1054/1555] scalable benchmarks --- .../CommonThreadedBase.cs | 71 +++++++++++++++++-- .../ScalabityExampleBenchmark.cs | 56 +++++++++++++++ 2 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 src/csharp/Grpc.Microbenchmarks/ScalabityExampleBenchmark.cs diff --git a/src/csharp/Grpc.Microbenchmarks/CommonThreadedBase.cs b/src/csharp/Grpc.Microbenchmarks/CommonThreadedBase.cs index c6bdf471b8a..c42c6481ffb 100644 --- a/src/csharp/Grpc.Microbenchmarks/CommonThreadedBase.cs +++ b/src/csharp/Grpc.Microbenchmarks/CommonThreadedBase.cs @@ -17,6 +17,8 @@ #endregion using System; +using System.Collections.Concurrent; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using BenchmarkDotNet.Attributes; @@ -35,22 +37,42 @@ namespace Grpc.Microbenchmarks { protected virtual bool NeedsEnvironment => true; - [Params(1, 2, 4, 8, 12)] + [Params(1, 2, 4, 6)] public int ThreadCount { get; set; } protected GrpcEnvironment Environment { get; private set; } + private List workers; + + private List> dispatchQueues; + [GlobalSetup] public virtual void Setup() { - ThreadPool.GetMinThreads(out var workers, out var iocp); - if (workers <= ThreadCount) ThreadPool.SetMinThreads(ThreadCount + 1, iocp); + dispatchQueues = new List>(); + workers = new List(); + for (int i = 0; i < ThreadCount; i++) + { + var dispatchQueue = new BlockingCollection(); + var thread = new Thread(new ThreadStart(() => WorkerThreadBody(dispatchQueue))); + thread.Name = string.Format("threaded benchmark worker {0}", i); + thread.Start(); + workers.Add(thread); + dispatchQueues.Add(dispatchQueue); + } + if (NeedsEnvironment) Environment = GrpcEnvironment.AddRef(); } [GlobalCleanup] public virtual void Cleanup() { + for (int i = 0; i < ThreadCount; i++) + { + dispatchQueues[i].Add(null); // null action request termination of the worker thread. + workers[i].Join(); + } + if (Environment != null) { Environment = null; @@ -58,9 +80,50 @@ namespace Grpc.Microbenchmarks } } + /// + /// Runs the operation in parallel (once on each worker thread). + /// This method tries to incur as little + /// overhead as possible, but there is some inherent overhead + /// that is hard to avoid (thread hop etc.). Therefore it is strongly + /// recommended that the benchmarked operation runs long enough to + /// make this overhead negligible. + /// protected void RunConcurrent(Action operation) { - Parallel.For(0, ThreadCount, _ => operation()); + var workItemTasks = new Task[ThreadCount]; + for (int i = 0; i < ThreadCount; i++) + { + var tcs = new TaskCompletionSource(); + var workItem = new Action(() => + { + try + { + operation(); + tcs.SetResult(null); + } + catch (Exception e) + { + tcs.SetException(e); + } + }); + workItemTasks[i] = tcs.Task; + dispatchQueues[i].Add(workItem); + } + Task.WaitAll(workItemTasks); + } + + private void WorkerThreadBody(BlockingCollection dispatchQueue) + { + while(true) + { + var workItem = dispatchQueue.Take(); + if (workItem == null) + { + // stop the worker if null action was provided + break; + } + workItem(); + } } } } diff --git a/src/csharp/Grpc.Microbenchmarks/ScalabityExampleBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/ScalabityExampleBenchmark.cs new file mode 100644 index 00000000000..1ef117c83e7 --- /dev/null +++ b/src/csharp/Grpc.Microbenchmarks/ScalabityExampleBenchmark.cs @@ -0,0 +1,56 @@ +#region Copyright notice and license + +// Copyright 2015 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using System.Runtime.InteropServices; +using BenchmarkDotNet.Attributes; +using Grpc.Core.Internal; + +namespace Grpc.Microbenchmarks +{ + public class ScalabilityExampleBenchmark : CommonThreadedBase + { + protected override bool NeedsEnvironment => false; + + // An example of testing scalability of a method that scales perfectly. + // This method provides a baseline for how well can CommonThreadedBase + // measure scalability. + const int Iterations = 50 * 1000 * 1000; // High number to make the overhead of RunConcurrent negligible. + [Benchmark(OperationsPerInvoke = Iterations)] + public void PerfectScalingExample() + { + RunConcurrent(() => { RunBody(); }); + } + + private int RunBody() + { + int result = 0; + for (int i = 0; i < Iterations; i++) + { + // perform some operation that is completely independent from + // other threads and therefore should scale perfectly if given + // a dedicated thread. + for (int j = 0; j < 100; j++) + { + result = result ^ i ^ j ; + } + } + return result; + } + } +} From 7372c195e717e65c1a60e7b07165d0eaf89b7509 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 1 Aug 2019 04:00:23 +0200 Subject: [PATCH 1055/1555] adjust iteration count in scalability benchmarks --- src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs | 2 +- src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs | 2 +- src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs index e4cd7eeb1f6..2374148bfe0 100644 --- a/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs @@ -27,7 +27,7 @@ namespace Grpc.Microbenchmarks [Params(false, true)] public bool UseSharedRegistry { get; set; } - const int Iterations = 1000000; // High number to make the overhead of RunConcurrent negligible. + const int Iterations = 5 * 1000 * 1000; // High number to make the overhead of RunConcurrent negligible. [Benchmark(OperationsPerInvoke = Iterations)] public void RegisterExtract() { diff --git a/src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs index de4e635580f..1ede7453db6 100644 --- a/src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/PInvokeByteArrayBenchmark.cs @@ -32,7 +32,7 @@ namespace Grpc.Microbenchmarks [Params(0)] public int PayloadSize { get; set; } - const int Iterations = 1000000; // High number to make the overhead of RunConcurrent negligible. + const int Iterations = 5 * 1000 * 1000; // High number to make the overhead of RunConcurrent negligible. [Benchmark(OperationsPerInvoke = Iterations)] public void AllocFree() { diff --git a/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs index d9554db00db..8496813efb0 100644 --- a/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs @@ -36,7 +36,7 @@ namespace Grpc.Microbenchmarks [Params(0)] public int PayloadSize { get; set; } - const int Iterations = 1000000; // High number to make the overhead of RunConcurrent negligible. + const int Iterations = 5 * 1000 * 1000; // High number to make the overhead of RunConcurrent negligible. [Benchmark(OperationsPerInvoke = Iterations)] public void SendMessage() { From a16a43945889870438cd6217574861e1276aff04 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 1 Aug 2019 04:53:35 +0200 Subject: [PATCH 1056/1555] fix CompletionRegistryBenchmark for UseSharedRegistry=true --- .../Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs index 2374148bfe0..9426882b54b 100644 --- a/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/CompletionRegistryBenchmark.cs @@ -31,8 +31,9 @@ namespace Grpc.Microbenchmarks [Benchmark(OperationsPerInvoke = Iterations)] public void RegisterExtract() { - RunConcurrent(() => { - CompletionRegistry sharedRegistry = UseSharedRegistry ? new CompletionRegistry(Environment, () => BatchContextSafeHandle.Create(), () => RequestCallContextSafeHandle.Create()) : null; + CompletionRegistry sharedRegistry = UseSharedRegistry ? new CompletionRegistry(Environment, () => BatchContextSafeHandle.Create(), () => RequestCallContextSafeHandle.Create()) : null; + RunConcurrent(() => + { RunBody(sharedRegistry); }); } From 46253995bb5ac760f20e47bb88a2aeb809d47a76 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 1 Aug 2019 04:55:04 +0200 Subject: [PATCH 1057/1555] add AtomicCounterBenchmark --- .../AtomicCounterBenchmark.cs | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/csharp/Grpc.Microbenchmarks/AtomicCounterBenchmark.cs diff --git a/src/csharp/Grpc.Microbenchmarks/AtomicCounterBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/AtomicCounterBenchmark.cs new file mode 100644 index 00000000000..03984f40728 --- /dev/null +++ b/src/csharp/Grpc.Microbenchmarks/AtomicCounterBenchmark.cs @@ -0,0 +1,52 @@ +#region Copyright notice and license + +// Copyright 2015 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using System.Runtime.InteropServices; +using BenchmarkDotNet.Attributes; +using Grpc.Core.Internal; + +namespace Grpc.Microbenchmarks +{ + public class AtomicCounterBenchmark : CommonThreadedBase + { + protected override bool NeedsEnvironment => false; + + // An example of testing scalability of a method that scales perfectly. + // This method provides a baseline for how well can CommonThreadedBase + // measure scalability. + const int Iterations = 20 * 1000 * 1000; // High number to make the overhead of RunConcurrent negligible. + [Benchmark(OperationsPerInvoke = Iterations)] + + public void SharedAtomicCounterIncrement() + { + RunConcurrent(() => { RunBody(); }); + } + + readonly AtomicCounter sharedCounter = new AtomicCounter(); + + private int RunBody() + { + for (int i = 0; i < Iterations; i++) + { + sharedCounter.Increment(); + } + return (int) sharedCounter.Count; + } + } +} From af8637661e28f57414d70741bd3626ee3f69aaa6 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Thu, 1 Aug 2019 10:33:20 -0700 Subject: [PATCH 1058/1555] Made compatible with back to Xcode 8.0. Shortened file paths (removed some) --- .../tvOS-sample.xcodeproj/project.pbxproj | 32 +++------ .../Content.imageset/Contents.json | 11 --- .../Contents.json | 17 ----- .../Content.imageset/Contents.json | 11 --- .../Content.imageset/Contents.json | 11 --- .../Middle.imagestacklayer/Contents.json | 6 -- .../Content.imageset/Contents.json | 16 ----- .../Back.imagestacklayer/Contents.json | 6 -- .../App Icon.imagestack/Contents.json | 17 ----- .../Content.imageset/Contents.json | 16 ----- .../Front.imagestacklayer/Contents.json | 6 -- .../Content.imageset/Contents.json | 16 ----- .../Middle.imagestacklayer/Contents.json | 6 -- .../Contents.json | 32 --------- .../Contents.json | 24 ------- .../Top Shelf Image.imageset/Contents.json | 24 ------- .../tvOS-sample/Assets.xcassets/Contents.json | 6 -- .../Launch Image.launchimage/Contents.json | 22 ------ .../AppIcon.appiconset/Contents.json | 0 .../Assets.xcassets}/Contents.json | 0 .../Base.lproj/Interface.storyboard | 0 .../Info.plist | 0 .../Circular.imageset/Contents.json | 0 .../Contents.json | 0 .../Extra Large.imageset/Contents.json | 0 .../Graphic Bezel.imageset/Contents.json | 0 .../Graphic Circular.imageset/Contents.json | 0 .../Graphic Corner.imageset/Contents.json | 0 .../Contents.json | 0 .../Modular.imageset/Contents.json | 0 .../Utilitarian.imageset/Contents.json | 0 .../Assets.xcassets}/Contents.json | 0 .../ExtensionDelegate.h | 0 .../ExtensionDelegate.m | 0 .../Info.plist | 0 .../InterfaceController.h | 0 .../InterfaceController.m | 0 .../Assets.xcassets/Contents.json | 6 -- .../Assets.xcassets/Contents.json | 6 -- .../watchOS-sample.xcodeproj/project.pbxproj | 71 +++++++------------ 40 files changed, 37 insertions(+), 325 deletions(-) delete mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Content.imageset/Contents.json delete mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Contents.json delete mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Content.imageset/Contents.json delete mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json delete mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Contents.json delete mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Content.imageset/Contents.json delete mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Contents.json delete mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Contents.json delete mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Content.imageset/Contents.json delete mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Contents.json delete mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json delete mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Contents.json delete mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json delete mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json delete mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json delete mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/Contents.json delete mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/Launch Image.launchimage/Contents.json rename src/objective-c/examples/watchOS-sample/{watchOS-sample WatchKit App => WatchKit-App}/Assets.xcassets/AppIcon.appiconset/Contents.json (100%) rename src/objective-c/examples/{tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer => watchOS-sample/WatchKit-App/Assets.xcassets}/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample WatchKit App => WatchKit-App}/Base.lproj/Interface.storyboard (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample WatchKit App => WatchKit-App}/Info.plist (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample-WatchKit-Extension => WatchKit-Extension}/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample-WatchKit-Extension => WatchKit-Extension}/Assets.xcassets/Complication.complicationset/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample-WatchKit-Extension => WatchKit-Extension}/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample-WatchKit-Extension => WatchKit-Extension}/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample-WatchKit-Extension => WatchKit-Extension}/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample-WatchKit-Extension => WatchKit-Extension}/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample-WatchKit-Extension => WatchKit-Extension}/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample-WatchKit-Extension => WatchKit-Extension}/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample-WatchKit-Extension => WatchKit-Extension}/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json (100%) rename src/objective-c/examples/{tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer => watchOS-sample/WatchKit-Extension/Assets.xcassets}/Contents.json (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample-WatchKit-Extension => WatchKit-Extension}/ExtensionDelegate.h (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample-WatchKit-Extension => WatchKit-Extension}/ExtensionDelegate.m (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample-WatchKit-Extension => WatchKit-Extension}/Info.plist (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample-WatchKit-Extension => WatchKit-Extension}/InterfaceController.h (100%) rename src/objective-c/examples/watchOS-sample/{watchOS-sample-WatchKit-Extension => WatchKit-Extension}/InterfaceController.m (100%) delete mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Assets.xcassets/Contents.json delete mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Contents.json diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj b/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj index a19281242bd..f9acf7fe186 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj @@ -3,14 +3,13 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 48; objects = { /* Begin PBXBuildFile section */ ABB17D3A22D8FB8B00C26D6E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D3922D8FB8B00C26D6E /* AppDelegate.m */; }; ABB17D3D22D8FB8B00C26D6E /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D3C22D8FB8B00C26D6E /* ViewController.m */; }; ABB17D4022D8FB8B00C26D6E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D3E22D8FB8B00C26D6E /* Main.storyboard */; }; - ABB17D4222D8FB8D00C26D6E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D4122D8FB8D00C26D6E /* Assets.xcassets */; }; ABB17D4522D8FB8D00C26D6E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D4422D8FB8D00C26D6E /* main.m */; }; F9B775DB1DDCBD39DF92BFA8 /* libPods-tvOS-sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 40071025CBF9E79B9522398F /* libPods-tvOS-sample.a */; }; /* End PBXBuildFile section */ @@ -24,7 +23,6 @@ ABB17D3B22D8FB8B00C26D6E /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; ABB17D3C22D8FB8B00C26D6E /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; ABB17D3F22D8FB8B00C26D6E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - ABB17D4122D8FB8D00C26D6E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; ABB17D4322D8FB8D00C26D6E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; ABB17D4422D8FB8D00C26D6E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; D2D1C60CE9BD00C1371BC913 /* Pods-tvOS-sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-tvOS-sample.debug.xcconfig"; path = "Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample.debug.xcconfig"; sourceTree = ""; }; @@ -77,7 +75,6 @@ ABB17D3B22D8FB8B00C26D6E /* ViewController.h */, ABB17D3C22D8FB8B00C26D6E /* ViewController.m */, ABB17D3E22D8FB8B00C26D6E /* Main.storyboard */, - ABB17D4122D8FB8D00C26D6E /* Assets.xcassets */, ABB17D4322D8FB8D00C26D6E /* Info.plist */, ABB17D4422D8FB8D00C26D6E /* main.m */, ); @@ -125,11 +122,12 @@ TargetAttributes = { ABB17D3422D8FB8B00C26D6E = { CreatedOnToolsVersion = 10.1; + ProvisioningStyle = Automatic; }; }; }; buildConfigurationList = ABB17D3022D8FB8B00C26D6E /* Build configuration list for PBXProject "tvOS-sample" */; - compatibilityVersion = "Xcode 9.3"; + compatibilityVersion = "Xcode 8.0"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( @@ -151,7 +149,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - ABB17D4222D8FB8D00C26D6E /* Assets.xcassets in Resources */, ABB17D4022D8FB8B00C26D6E /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -164,12 +161,13 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-resources-${CONFIGURATION}-input-files.xcfilelist", + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-resources.sh", + "${PODS_CONFIGURATION_BUILD_DIR}/gRPC/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-resources-${CONFIGURATION}-output-files.xcfilelist", + outputPaths = ( + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -181,15 +179,11 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${PODS_PODFILE_DIR_PATH}/Podfile.lock", "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); outputPaths = ( "$(DERIVED_FILE_DIR)/Pods-tvOS-sample-checkManifestLockResult.txt", ); @@ -344,10 +338,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6T98ZJNPG5; INFOPLIST_FILE = "tvOS-sample/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.google.tvOS-grpc-sample"; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = 3; @@ -364,10 +355,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6T98ZJNPG5; INFOPLIST_FILE = "tvOS-sample/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.google.tvOS-grpc-sample"; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = 3; diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Content.imageset/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Content.imageset/Contents.json deleted file mode 100644 index 48ecb4fa43e..00000000000 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "images" : [ - { - "idiom" : "tv" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Contents.json deleted file mode 100644 index d29f024ed5c..00000000000 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Contents.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "layers" : [ - { - "filename" : "Front.imagestacklayer" - }, - { - "filename" : "Middle.imagestacklayer" - }, - { - "filename" : "Back.imagestacklayer" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Content.imageset/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Content.imageset/Contents.json deleted file mode 100644 index 48ecb4fa43e..00000000000 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "images" : [ - { - "idiom" : "tv" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json deleted file mode 100644 index 48ecb4fa43e..00000000000 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "images" : [ - { - "idiom" : "tv" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Contents.json deleted file mode 100644 index da4a164c918..00000000000 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Content.imageset/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Content.imageset/Contents.json deleted file mode 100644 index 16a370df014..00000000000 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "images" : [ - { - "idiom" : "tv", - "scale" : "1x" - }, - { - "idiom" : "tv", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Contents.json deleted file mode 100644 index da4a164c918..00000000000 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Contents.json deleted file mode 100644 index d29f024ed5c..00000000000 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Contents.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "layers" : [ - { - "filename" : "Front.imagestacklayer" - }, - { - "filename" : "Middle.imagestacklayer" - }, - { - "filename" : "Back.imagestacklayer" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Content.imageset/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Content.imageset/Contents.json deleted file mode 100644 index 16a370df014..00000000000 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "images" : [ - { - "idiom" : "tv", - "scale" : "1x" - }, - { - "idiom" : "tv", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Contents.json deleted file mode 100644 index da4a164c918..00000000000 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json deleted file mode 100644 index 16a370df014..00000000000 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "images" : [ - { - "idiom" : "tv", - "scale" : "1x" - }, - { - "idiom" : "tv", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Contents.json deleted file mode 100644 index da4a164c918..00000000000 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json deleted file mode 100644 index db288f368f1..00000000000 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "assets" : [ - { - "size" : "1280x768", - "idiom" : "tv", - "filename" : "App Icon - App Store.imagestack", - "role" : "primary-app-icon" - }, - { - "size" : "400x240", - "idiom" : "tv", - "filename" : "App Icon.imagestack", - "role" : "primary-app-icon" - }, - { - "size" : "2320x720", - "idiom" : "tv", - "filename" : "Top Shelf Image Wide.imageset", - "role" : "top-shelf-image-wide" - }, - { - "size" : "1920x720", - "idiom" : "tv", - "filename" : "Top Shelf Image.imageset", - "role" : "top-shelf-image" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json deleted file mode 100644 index 7dc95020229..00000000000 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "images" : [ - { - "idiom" : "tv", - "scale" : "1x" - }, - { - "idiom" : "tv", - "scale" : "2x" - }, - { - "idiom" : "tv-marketing", - "scale" : "1x" - }, - { - "idiom" : "tv-marketing", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json deleted file mode 100644 index 7dc95020229..00000000000 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "images" : [ - { - "idiom" : "tv", - "scale" : "1x" - }, - { - "idiom" : "tv", - "scale" : "2x" - }, - { - "idiom" : "tv-marketing", - "scale" : "1x" - }, - { - "idiom" : "tv-marketing", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/Contents.json deleted file mode 100644 index da4a164c918..00000000000 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/Launch Image.launchimage/Contents.json b/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/Launch Image.launchimage/Contents.json deleted file mode 100644 index d746a609003..00000000000 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/Launch Image.launchimage/Contents.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "images" : [ - { - "orientation" : "landscape", - "idiom" : "tv", - "extent" : "full-screen", - "minimum-system-version" : "11.0", - "scale" : "2x" - }, - { - "orientation" : "landscape", - "idiom" : "tv", - "extent" : "full-screen", - "minimum-system-version" : "9.0", - "scale" : "1x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Assets.xcassets/AppIcon.appiconset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-App/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Assets.xcassets/AppIcon.appiconset/Contents.json rename to src/objective-c/examples/watchOS-sample/WatchKit-App/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-App/Assets.xcassets/Contents.json similarity index 100% rename from src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Contents.json rename to src/objective-c/examples/watchOS-sample/WatchKit-App/Assets.xcassets/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Base.lproj/Interface.storyboard b/src/objective-c/examples/watchOS-sample/WatchKit-App/Base.lproj/Interface.storyboard similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Base.lproj/Interface.storyboard rename to src/objective-c/examples/watchOS-sample/WatchKit-App/Base.lproj/Interface.storyboard diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Info.plist b/src/objective-c/examples/watchOS-sample/WatchKit-App/Info.plist similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Info.plist rename to src/objective-c/examples/watchOS-sample/WatchKit-App/Info.plist diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json rename to src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Contents.json rename to src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json rename to src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json rename to src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json rename to src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json rename to src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json rename to src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json rename to src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json rename to src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Contents.json similarity index 100% rename from src/objective-c/examples/tvOS-sample/tvOS-sample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Contents.json rename to src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Contents.json diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.h b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.h similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.h rename to src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.h diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.m b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.m similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/ExtensionDelegate.m rename to src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.m diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Info.plist b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Info.plist similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Info.plist rename to src/objective-c/examples/watchOS-sample/WatchKit-Extension/Info.plist diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.h b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.h similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.h rename to src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.h diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.m b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m similarity index 100% rename from src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/InterfaceController.m rename to src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Assets.xcassets/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Assets.xcassets/Contents.json deleted file mode 100644 index da4a164c918..00000000000 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample WatchKit App/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Contents.json deleted file mode 100644 index da4a164c918..00000000000 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample-WatchKit-Extension/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj index 9d40fc4b0cf..5494aee418c 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 48; objects = { /* Begin PBXBuildFile section */ @@ -138,8 +138,8 @@ isa = PBXGroup; children = ( ABB17D5622D93BAB00C26D6E /* watchOS-sample */, - ABB17D6E22D93BAC00C26D6E /* watchOS-sample WatchKit App */, - ABB17D7D22D93BAC00C26D6E /* watchOS-sample-WatchKit-Extension */, + ABB17D6E22D93BAC00C26D6E /* WatchKit-App */, + ABB17D7D22D93BAC00C26D6E /* WatchKit-Extension */, ABB17D5522D93BAB00C26D6E /* Products */, 2C4A0708747AAA7298F757DA /* Pods */, FDB2CA47351660A961DBE458 /* Frameworks */, @@ -172,17 +172,17 @@ path = "watchOS-sample"; sourceTree = ""; }; - ABB17D6E22D93BAC00C26D6E /* watchOS-sample WatchKit App */ = { + ABB17D6E22D93BAC00C26D6E /* WatchKit-App */ = { isa = PBXGroup; children = ( ABB17D6F22D93BAC00C26D6E /* Interface.storyboard */, ABB17D7222D93BAC00C26D6E /* Assets.xcassets */, ABB17D7422D93BAC00C26D6E /* Info.plist */, ); - path = "watchOS-sample WatchKit App"; + path = "WatchKit-App"; sourceTree = ""; }; - ABB17D7D22D93BAC00C26D6E /* watchOS-sample-WatchKit-Extension */ = { + ABB17D7D22D93BAC00C26D6E /* WatchKit-Extension */ = { isa = PBXGroup; children = ( ABB17D7E22D93BAC00C26D6E /* InterfaceController.h */, @@ -192,7 +192,7 @@ ABB17D8422D93BAD00C26D6E /* Assets.xcassets */, ABB17D8622D93BAD00C26D6E /* Info.plist */, ); - path = "watchOS-sample-WatchKit-Extension"; + path = "WatchKit-Extension"; sourceTree = ""; }; FDB2CA47351660A961DBE458 /* Frameworks */ = { @@ -276,17 +276,20 @@ TargetAttributes = { ABB17D5322D93BAB00C26D6E = { CreatedOnToolsVersion = 10.1; + ProvisioningStyle = Automatic; }; ABB17D6922D93BAC00C26D6E = { CreatedOnToolsVersion = 10.1; + ProvisioningStyle = Automatic; }; ABB17D7822D93BAC00C26D6E = { CreatedOnToolsVersion = 10.1; + ProvisioningStyle = Automatic; }; }; }; buildConfigurationList = ABB17D4F22D93BAB00C26D6E /* Build configuration list for PBXProject "watchOS-sample" */; - compatibilityVersion = "Xcode 9.3"; + compatibilityVersion = "Xcode 8.0"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( @@ -341,15 +344,11 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${PODS_PODFILE_DIR_PATH}/Podfile.lock", "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); outputPaths = ( "$(DERIVED_FILE_DIR)/Pods-watchOS-sample WatchKit Extension-checkManifestLockResult.txt", ); @@ -363,15 +362,11 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${PODS_PODFILE_DIR_PATH}/Podfile.lock", "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); outputPaths = ( "$(DERIVED_FILE_DIR)/Pods-watchOS-sample-checkManifestLockResult.txt", ); @@ -385,12 +380,13 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-resources-${CONFIGURATION}-input-files.xcfilelist", + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-resources.sh", + "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-watchOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-resources-${CONFIGURATION}-output-files.xcfilelist", + outputPaths = ( + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -402,12 +398,13 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-resources-${CONFIGURATION}-input-files.xcfilelist", + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-resources.sh", + "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-resources-${CONFIGURATION}-output-files.xcfilelist", + outputPaths = ( + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -530,7 +527,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -583,7 +580,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; @@ -599,11 +596,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6T98ZJNPG5; INFOPLIST_FILE = "$(SRCROOT)/watchOS-sample-WatchKit-Extension/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@executable_path/../../Frameworks", - ); + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample.watchkitapp.watchkitextension"; PRODUCT_NAME = "${TARGET_NAME}"; SDKROOT = watchos; @@ -621,11 +614,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6T98ZJNPG5; INFOPLIST_FILE = "$(SRCROOT)/watchOS-sample-WatchKit-Extension/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@executable_path/../../Frameworks", - ); + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample.watchkitapp.watchkitextension"; PRODUCT_NAME = "${TARGET_NAME}"; SDKROOT = watchos; @@ -677,10 +666,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6T98ZJNPG5; INFOPLIST_FILE = "watchOS-sample/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample"; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; @@ -695,10 +681,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6T98ZJNPG5; INFOPLIST_FILE = "watchOS-sample/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample"; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; From 6c7184a36010f1b315998db5ca35da158d62095e Mon Sep 17 00:00:00 2001 From: Qiancheng Zhao Date: Thu, 1 Aug 2019 10:54:21 -0700 Subject: [PATCH 1059/1555] fix memory_usage_test failure --- src/core/ext/filters/client_channel/client_channel.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 7aafca6f8ae..ac79ae92d5a 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -1510,7 +1510,7 @@ void ChannelData::CreateResolvingLoadBalancingPolicyLocked() { UniquePtr( New(this)); lb_args.args = channel_args_; - UniquePtr target_uri(strdup(target_uri_.get())); + UniquePtr target_uri(gpr_strdup(target_uri_.get())); resolving_lb_policy_.reset(New( std::move(lb_args), &grpc_client_channel_routing_trace, std::move(target_uri), ProcessResolverResultLocked, this)); From 0d6eec8b8f46f52d9e5e2062b7e596d8b0425fe8 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 1 Aug 2019 20:26:58 +0200 Subject: [PATCH 1060/1555] a few fixes for run_performance_tests.py flame graph generators --- .../run_tests/performance/process_local_perf_flamegraphs.sh | 3 +++ .../performance/process_remote_perf_flamegraphs.sh | 3 +++ tools/run_tests/run_performance_tests.py | 6 +++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/run_tests/performance/process_local_perf_flamegraphs.sh b/tools/run_tests/performance/process_local_perf_flamegraphs.sh index ccb5b19f2a8..b7b05fde3d9 100755 --- a/tools/run_tests/performance/process_local_perf_flamegraphs.sh +++ b/tools/run_tests/performance/process_local_perf_flamegraphs.sh @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +set -ex + mkdir -p "$OUTPUT_DIR" PERF_DATA_FILE="${PERF_BASE_NAME}-perf.data" @@ -22,4 +24,5 @@ PERF_SCRIPT_OUTPUT="${PERF_BASE_NAME}-out.perf" echo "running perf script on $PERF_DATA_FILE" perf script -i "$PERF_DATA_FILE" > "$PERF_SCRIPT_OUTPUT" +# use https://github.com/brendangregg/FlameGraph ~/FlameGraph/stackcollapse-perf.pl "$PERF_SCRIPT_OUTPUT" | ~/FlameGraph/flamegraph.pl > "${OUTPUT_DIR}/${OUTPUT_FILENAME}.svg" diff --git a/tools/run_tests/performance/process_remote_perf_flamegraphs.sh b/tools/run_tests/performance/process_remote_perf_flamegraphs.sh index 2ea6b4f2a6c..6e42564d5f4 100755 --- a/tools/run_tests/performance/process_remote_perf_flamegraphs.sh +++ b/tools/run_tests/performance/process_remote_perf_flamegraphs.sh @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +set -ex + mkdir -p "$OUTPUT_DIR" PERF_DATA_FILE="${PERF_BASE_NAME}-perf.data" @@ -27,4 +29,5 @@ scp "$USER_AT_HOST:~/performance_workspace/grpc/$PERF_SCRIPT_OUTPUT.gz" . gzip -d -f "$PERF_SCRIPT_OUTPUT.gz" +# use https://github.com/brendangregg/FlameGraph ~/FlameGraph/stackcollapse-perf.pl --kernel "$PERF_SCRIPT_OUTPUT" | ~/FlameGraph/flamegraph.pl --color=java --hash > "${OUTPUT_DIR}/${OUTPUT_FILENAME}.svg" diff --git a/tools/run_tests/run_performance_tests.py b/tools/run_tests/run_performance_tests.py index c6e67eaf563..4ecd6d6efd1 100755 --- a/tools/run_tests/run_performance_tests.py +++ b/tools/run_tests/run_performance_tests.py @@ -328,10 +328,10 @@ def perf_report_processor_job(worker_host, perf_base_name, output_filename, cmd = '' if worker_host != 'localhost': user_at_host = "%s@%s" % (_REMOTE_HOST_USERNAME, worker_host) - cmd = "USER_AT_HOST=%s OUTPUT_FILENAME=%s OUTPUT_DIR=%s PERF_BASE_NAME=%stools/run_tests/performance/process_remote_perf_flamegraphs.sh" % ( + cmd = "USER_AT_HOST=%s OUTPUT_FILENAME=%s OUTPUT_DIR=%s PERF_BASE_NAME=%s tools/run_tests/performance/process_remote_perf_flamegraphs.sh" % ( user_at_host, output_filename, flame_graph_reports, perf_base_name) else: - cmd = "OUTPUT_FILENAME=%s OUTPUT_DIR=%s PERF_BASE_NAME=%stools/run_tests/performance/process_local_perf_flamegraphs.sh" % ( + cmd = "OUTPUT_FILENAME=%s OUTPUT_DIR=%s PERF_BASE_NAME=%s tools/run_tests/performance/process_local_perf_flamegraphs.sh" % ( output_filename, flame_graph_reports, perf_base_name) return jobset.JobSpec( @@ -484,7 +484,7 @@ def run_collect_perf_profile_jobs(hosts_and_base_names, scenario_name, failures, _ = jobset.run( perf_report_jobs, newline_on_success=True, maxjobs=1) jobset.message( - 'END', 'Collecting perf reports from qps workers', do_newline=True) + 'SUCCESS', 'Collecting perf reports from qps workers', do_newline=True) return failures From 5be988f41215e84c315d3f31dc358166480501c4 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Thu, 1 Aug 2019 11:46:48 -0700 Subject: [PATCH 1061/1555] Adapted samples to new imports & added experimental kokoro jobs --- src/objective-c/examples/tvOS-sample/Podfile | 2 + .../tvOS-sample.xcodeproj/project.pbxproj | 16 +++-- .../tvOS-sample/tvOS-sample/ViewController.m | 5 ++ .../examples/watchOS-sample/Podfile | 2 + .../watchOS-sample/WatchKit-App/Info.plist | 2 +- .../WatchKit-Extension/Info.plist | 2 +- .../WatchKit-Extension/InterfaceController.m | 5 ++ .../watchOS-sample.xcodeproj/project.pbxproj | 68 +++++++++---------- .../watchOS-sample/ViewController.m | 2 - tools/run_tests/run_tests.py | 44 ++++++++++++ 10 files changed, 104 insertions(+), 44 deletions(-) diff --git a/src/objective-c/examples/tvOS-sample/Podfile b/src/objective-c/examples/tvOS-sample/Podfile index 20d20e27bdf..79427b98b90 100644 --- a/src/objective-c/examples/tvOS-sample/Podfile +++ b/src/objective-c/examples/tvOS-sample/Podfile @@ -2,6 +2,8 @@ platform :tvos, '10.0' install! 'cocoapods', :deterministic_uuids => false +use_frameworks! if ENV['FRAMEWORKS'] != 'NO' + ROOT_DIR = '../../../..' target 'tvOS-sample' do diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj b/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj index f9acf7fe186..7f8198aa320 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj @@ -7,15 +7,15 @@ objects = { /* Begin PBXBuildFile section */ + 8E4F1CA090367C7618548546 /* libPods-tvOS-sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 65430D45E5C272C975E4CCCA /* libPods-tvOS-sample.a */; }; ABB17D3A22D8FB8B00C26D6E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D3922D8FB8B00C26D6E /* AppDelegate.m */; }; ABB17D3D22D8FB8B00C26D6E /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D3C22D8FB8B00C26D6E /* ViewController.m */; }; ABB17D4022D8FB8B00C26D6E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D3E22D8FB8B00C26D6E /* Main.storyboard */; }; ABB17D4522D8FB8D00C26D6E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D4422D8FB8D00C26D6E /* main.m */; }; - F9B775DB1DDCBD39DF92BFA8 /* libPods-tvOS-sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 40071025CBF9E79B9522398F /* libPods-tvOS-sample.a */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 40071025CBF9E79B9522398F /* libPods-tvOS-sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-tvOS-sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 65430D45E5C272C975E4CCCA /* libPods-tvOS-sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-tvOS-sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 93F3CF0DB110860F8E180685 /* Pods-tvOS-sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-tvOS-sample.release.xcconfig"; path = "Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample.release.xcconfig"; sourceTree = ""; }; ABB17D3522D8FB8B00C26D6E /* tvOS-sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "tvOS-sample.app"; sourceTree = BUILT_PRODUCTS_DIR; }; ABB17D3822D8FB8B00C26D6E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; @@ -33,7 +33,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - F9B775DB1DDCBD39DF92BFA8 /* libPods-tvOS-sample.a in Frameworks */, + 8E4F1CA090367C7618548546 /* libPods-tvOS-sample.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -84,7 +84,7 @@ D280E557B55AAB044C083DB5 /* Frameworks */ = { isa = PBXGroup; children = ( - 40071025CBF9E79B9522398F /* libPods-tvOS-sample.a */, + 65430D45E5C272C975E4CCCA /* libPods-tvOS-sample.a */, ); name = Frameworks; sourceTree = ""; @@ -100,7 +100,7 @@ ABB17D3122D8FB8B00C26D6E /* Sources */, ABB17D3222D8FB8B00C26D6E /* Frameworks */, ABB17D3322D8FB8B00C26D6E /* Resources */, - 340B0470EBFB87C5242C058E /* [CP] Copy Pods Resources */, + 53B9CBB782EEE8A7572F10EC /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -156,16 +156,20 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 340B0470EBFB87C5242C058E /* [CP] Copy Pods Resources */ = { + 53B9CBB782EEE8A7572F10EC /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); + inputFileListPaths = ( + ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/gRPC/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + ); outputPaths = ( "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", ); diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m index 0d291e44842..c94ee8c2569 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m @@ -18,8 +18,13 @@ #import "ViewController.h" +#if USE_FRAMEWORKS #import #import +#else +#import "src/objective-c/examples/RemoteTestClient/Messages.pbobjc.h" +#import "src/objective-c/examples/RemoteTestClient/Test.pbrpc.h" +#endif @interface ViewController () diff --git a/src/objective-c/examples/watchOS-sample/Podfile b/src/objective-c/examples/watchOS-sample/Podfile index a0f93bef730..59d30ab86c0 100644 --- a/src/objective-c/examples/watchOS-sample/Podfile +++ b/src/objective-c/examples/watchOS-sample/Podfile @@ -1,5 +1,7 @@ install! 'cocoapods', :deterministic_uuids => false +use_frameworks! if ENV['FRAMEWORKS'] != 'NO' + ROOT_DIR = '../../../..' def grpc_deps diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-App/Info.plist b/src/objective-c/examples/watchOS-sample/WatchKit-App/Info.plist index 68081b1f6e0..f0396b31ef7 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-App/Info.plist +++ b/src/objective-c/examples/watchOS-sample/WatchKit-App/Info.plist @@ -5,7 +5,7 @@ CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName - watchOS-sample WatchKit App + WatchKit-App CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Info.plist b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Info.plist index 457a48af2d8..fcbeef72a4d 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Info.plist +++ b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Info.plist @@ -5,7 +5,7 @@ CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName - watchOS-sample WatchKit Extension + WatchKit-Extension CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m index d7f0c94adc9..3e97767cf0c 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m +++ b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m @@ -17,8 +17,13 @@ */ #import "InterfaceController.h" +#if USE_FRAMEWORKS #import #import +#else +#import "src/objective-c/examples/RemoteTestClient/Messages.pbobjc.h" +#import "src/objective-c/examples/RemoteTestClient/Test.pbrpc.h" +#endif @interface InterfaceController () diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj index 5494aee418c..7f57c514775 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj @@ -7,7 +7,8 @@ objects = { /* Begin PBXBuildFile section */ - 6CD34817C1124B7090EFB679 /* libPods-watchOS-sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 81BB6B1D8754281EF32EB3F2 /* libPods-watchOS-sample.a */; }; + 26FD050F4CCE95ED8CB98A62 /* libPods-watchOS-sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7CD8313B9B59F6F095035EF8 /* libPods-watchOS-sample.a */; }; + A82AA8DDE95C58A13334A932 /* libPods-watchOS-sample WatchKit Extension.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E347FF230AC1FAC0C374BE0C /* libPods-watchOS-sample WatchKit Extension.a */; }; ABB17D5922D93BAB00C26D6E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D5822D93BAB00C26D6E /* AppDelegate.m */; }; ABB17D5C22D93BAB00C26D6E /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D5B22D93BAB00C26D6E /* ViewController.m */; }; ABB17D5F22D93BAB00C26D6E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D5D22D93BAB00C26D6E /* Main.storyboard */; }; @@ -21,7 +22,6 @@ ABB17D8022D93BAC00C26D6E /* InterfaceController.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D7F22D93BAC00C26D6E /* InterfaceController.m */; }; ABB17D8322D93BAC00C26D6E /* ExtensionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D8222D93BAC00C26D6E /* ExtensionDelegate.m */; }; ABB17D8522D93BAD00C26D6E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D8422D93BAD00C26D6E /* Assets.xcassets */; }; - CCC7943770AD2447C8F33431 /* libPods-watchOS-sample WatchKit Extension.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B9B6F1C6465A4AAC45CAF14 /* libPods-watchOS-sample WatchKit Extension.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -68,8 +68,7 @@ /* Begin PBXFileReference section */ 574DCD2DDCABCC45B2308601 /* Pods-watchOS-sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample.debug.xcconfig"; path = "Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample.debug.xcconfig"; sourceTree = ""; }; - 5B9B6F1C6465A4AAC45CAF14 /* libPods-watchOS-sample WatchKit Extension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-watchOS-sample WatchKit Extension.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 81BB6B1D8754281EF32EB3F2 /* libPods-watchOS-sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-watchOS-sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 7CD8313B9B59F6F095035EF8 /* libPods-watchOS-sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-watchOS-sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 957B59E3DE8281B41B6DB3FD /* Pods-watchOS-sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample.release.xcconfig"; path = "Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample.release.xcconfig"; sourceTree = ""; }; ABB17D5422D93BAB00C26D6E /* watchOS-sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "watchOS-sample.app"; sourceTree = BUILT_PRODUCTS_DIR; }; ABB17D5722D93BAB00C26D6E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; @@ -92,6 +91,7 @@ ABB17D8222D93BAC00C26D6E /* ExtensionDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ExtensionDelegate.m; sourceTree = ""; }; ABB17D8422D93BAD00C26D6E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; ABB17D8622D93BAD00C26D6E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + E347FF230AC1FAC0C374BE0C /* libPods-watchOS-sample WatchKit Extension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-watchOS-sample WatchKit Extension.a"; sourceTree = BUILT_PRODUCTS_DIR; }; EDC6FF21CD9F393E8FDF02F6 /* Pods-watchOS-sample WatchKit Extension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample WatchKit Extension.release.xcconfig"; path = "Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension.release.xcconfig"; sourceTree = ""; }; FBBABD10A996E7CCA4B2F937 /* Pods-watchOS-sample WatchKit Extension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample WatchKit Extension.debug.xcconfig"; path = "Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -101,7 +101,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 6CD34817C1124B7090EFB679 /* libPods-watchOS-sample.a in Frameworks */, + 26FD050F4CCE95ED8CB98A62 /* libPods-watchOS-sample.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -109,7 +109,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - CCC7943770AD2447C8F33431 /* libPods-watchOS-sample WatchKit Extension.a in Frameworks */, + A82AA8DDE95C58A13334A932 /* libPods-watchOS-sample WatchKit Extension.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -198,8 +198,8 @@ FDB2CA47351660A961DBE458 /* Frameworks */ = { isa = PBXGroup; children = ( - 81BB6B1D8754281EF32EB3F2 /* libPods-watchOS-sample.a */, - 5B9B6F1C6465A4AAC45CAF14 /* libPods-watchOS-sample WatchKit Extension.a */, + 7CD8313B9B59F6F095035EF8 /* libPods-watchOS-sample.a */, + E347FF230AC1FAC0C374BE0C /* libPods-watchOS-sample WatchKit Extension.a */, ); name = Frameworks; sourceTree = ""; @@ -216,7 +216,7 @@ ABB17D5122D93BAB00C26D6E /* Frameworks */, ABB17D5222D93BAB00C26D6E /* Resources */, ABB17D9022D93BAD00C26D6E /* Embed Watch Content */, - E8B22C16C7C7397CEC79CCF6 /* [CP] Copy Pods Resources */, + 9A5D1B4A7574524FF0BB9310 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -254,7 +254,7 @@ ABB17D7522D93BAC00C26D6E /* Sources */, ABB17D7622D93BAC00C26D6E /* Frameworks */, ABB17D7722D93BAC00C26D6E /* Resources */, - DB65546E9DFC6EADD365E270 /* [CP] Copy Pods Resources */, + 7246FFBCAD3F9270364EFC9E /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -357,25 +357,7 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - C094DF31B83C380F13D80132 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-watchOS-sample-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - DB65546E9DFC6EADD365E270 /* [CP] Copy Pods Resources */ = { + 7246FFBCAD3F9270364EFC9E /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -393,7 +375,7 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-resources.sh\"\n"; showEnvVarsInLog = 0; }; - E8B22C16C7C7397CEC79CCF6 /* [CP] Copy Pods Resources */ = { + 9A5D1B4A7574524FF0BB9310 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -411,6 +393,24 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-resources.sh\"\n"; showEnvVarsInLog = 0; }; + C094DF31B83C380F13D80132 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-watchOS-sample-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -595,7 +595,7 @@ ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6T98ZJNPG5; - INFOPLIST_FILE = "$(SRCROOT)/watchOS-sample-WatchKit-Extension/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/WatchKit-Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample.watchkitapp.watchkitextension"; PRODUCT_NAME = "${TARGET_NAME}"; @@ -613,7 +613,7 @@ ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6T98ZJNPG5; - INFOPLIST_FILE = "$(SRCROOT)/watchOS-sample-WatchKit-Extension/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/WatchKit-Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample.watchkitapp.watchkitextension"; PRODUCT_NAME = "${TARGET_NAME}"; @@ -631,7 +631,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6T98ZJNPG5; IBSC_MODULE = watchOS_sample_WatchKit_Extension; - INFOPLIST_FILE = "watchOS-sample WatchKit App/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/WatchKit-App/Info.plist"; PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample.watchkitapp"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = watchos; @@ -648,7 +648,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6T98ZJNPG5; IBSC_MODULE = watchOS_sample_WatchKit_Extension; - INFOPLIST_FILE = "watchOS-sample WatchKit App/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/WatchKit-App/Info.plist"; PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample.watchkitapp"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = watchos; diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m index d15c78482bb..4bc98912bf9 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m @@ -18,8 +18,6 @@ #import "ViewController.h" -#import - @interface ViewController () @end diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index dad570ee0ca..a4e647a7833 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1090,6 +1090,50 @@ class ObjCLanguage(object): 'SCHEME': 'SwiftSample', 'EXAMPLE_PATH': 'src/objective-c/examples/SwiftSample' })) + out.append( + self.config.job_spec( + ['src/objective-c/tests/build_one_example.sh'], + timeout_seconds=10 * 60, + shortname='ios-buildtest-example-tvOS-sample', + cpu_cost=1e6, + environ={ + 'SCHEME': 'tvOS-sample', + 'EXAMPLE_PATH': 'src/objective-c/examples/tvOS-sample', + 'FRAMEWORKS': 'NO' + })) + out.append( + self.config.job_spec( + ['src/objective-c/tests/build_one_example.sh'], + timeout_seconds=10 * 60, + shortname='ios-buildtest-example-tvOS-sample-framework', + cpu_cost=1e6, + environ={ + 'SCHEME': 'tvOS-sample', + 'EXAMPLE_PATH': 'src/objective-c/examples/tvOS-sample', + 'FRAMEWORKS': 'YES' + })) + out.append( + self.config.job_spec( + ['src/objective-c/tests/build_one_example.sh'], + timeout_seconds=10 * 60, + shortname='ios-buildtest-example-watchOS-sample', + cpu_cost=1e6, + environ={ + 'SCHEME': 'watchOS-sample', + 'EXAMPLE_PATH': 'src/objective-c/examples/watchOS-sample', + 'FRAMEWORKS': 'NO' + })) + out.append( + self.config.job_spec( + ['src/objective-c/tests/build_one_example.sh'], + timeout_seconds=10 * 60, + shortname='ios-buildtest-example-watchOS-sample-framework', + cpu_cost=1e6, + environ={ + 'SCHEME': 'watchOS-sample', + 'EXAMPLE_PATH': 'src/objective-c/examples/watchOS-sample', + 'FRAMEWORKS': 'YES' + })) out.append( self.config.job_spec( ['src/objective-c/tests/run_plugin_tests.sh'], From b437dc0c6804132396fb5efff7f3ade399772611 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Tue, 16 Jul 2019 14:11:21 -0700 Subject: [PATCH 1062/1555] Reduce instruction count for CH2 metadata ops. 1) Statically pre-compute static slice indices to save some ALU ops when linking batched metadata. 2) Change some asserts to debug_asserts since they can provably not be triggered with the current implementation. 3) Save some slice comparison cycles inside CH2 parsing. --- .../chttp2/transport/incoming_metadata.cc | 3 +- .../ext/transport/chttp2/transport/parsing.cc | 28 +- src/core/lib/slice/slice_internal.h | 11 + src/core/lib/transport/metadata_batch.cc | 2 +- src/core/lib/transport/static_metadata.cc | 1321 +++++++++-------- src/core/lib/transport/static_metadata.h | 24 +- tools/codegen/core/gen_static_metadata.py | 37 +- 7 files changed, 731 insertions(+), 695 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/incoming_metadata.cc b/src/core/ext/transport/chttp2/transport/incoming_metadata.cc index 02623c978d7..d04630d726b 100644 --- a/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +++ b/src/core/ext/transport/chttp2/transport/incoming_metadata.cc @@ -38,7 +38,8 @@ grpc_error* grpc_chttp2_incoming_metadata_buffer_add( storage = static_cast( buffer->arena->Alloc(sizeof(grpc_linked_mdelem))); } - return grpc_metadata_batch_add_tail(&buffer->batch, storage, elem); + storage->md = elem; + return grpc_metadata_batch_link_tail(&buffer->batch, storage); } grpc_error* grpc_chttp2_incoming_metadata_buffer_replace_or_add( diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index 4e6ff60caf8..796f63573c0 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -108,7 +108,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t, /* fallthrough */ dts_fh_0: case GRPC_DTS_FH_0: - GPR_ASSERT(cur < end); + GPR_DEBUG_ASSERT(cur < end); t->incoming_frame_size = (static_cast(*cur)) << 16; if (++cur == end) { t->deframe_state = GRPC_DTS_FH_1; @@ -116,7 +116,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t, } /* fallthrough */ case GRPC_DTS_FH_1: - GPR_ASSERT(cur < end); + GPR_DEBUG_ASSERT(cur < end); t->incoming_frame_size |= (static_cast(*cur)) << 8; if (++cur == end) { t->deframe_state = GRPC_DTS_FH_2; @@ -124,7 +124,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t, } /* fallthrough */ case GRPC_DTS_FH_2: - GPR_ASSERT(cur < end); + GPR_DEBUG_ASSERT(cur < end); t->incoming_frame_size |= *cur; if (++cur == end) { t->deframe_state = GRPC_DTS_FH_3; @@ -132,7 +132,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t, } /* fallthrough */ case GRPC_DTS_FH_3: - GPR_ASSERT(cur < end); + GPR_DEBUG_ASSERT(cur < end); t->incoming_frame_type = *cur; if (++cur == end) { t->deframe_state = GRPC_DTS_FH_4; @@ -140,7 +140,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t, } /* fallthrough */ case GRPC_DTS_FH_4: - GPR_ASSERT(cur < end); + GPR_DEBUG_ASSERT(cur < end); t->incoming_frame_flags = *cur; if (++cur == end) { t->deframe_state = GRPC_DTS_FH_5; @@ -148,7 +148,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t, } /* fallthrough */ case GRPC_DTS_FH_5: - GPR_ASSERT(cur < end); + GPR_DEBUG_ASSERT(cur < end); t->incoming_stream_id = ((static_cast(*cur)) & 0x7f) << 24; if (++cur == end) { t->deframe_state = GRPC_DTS_FH_6; @@ -156,7 +156,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t, } /* fallthrough */ case GRPC_DTS_FH_6: - GPR_ASSERT(cur < end); + GPR_DEBUG_ASSERT(cur < end); t->incoming_stream_id |= (static_cast(*cur)) << 16; if (++cur == end) { t->deframe_state = GRPC_DTS_FH_7; @@ -164,7 +164,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t, } /* fallthrough */ case GRPC_DTS_FH_7: - GPR_ASSERT(cur < end); + GPR_DEBUG_ASSERT(cur < end); t->incoming_stream_id |= (static_cast(*cur)) << 8; if (++cur == end) { t->deframe_state = GRPC_DTS_FH_8; @@ -172,7 +172,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t, } /* fallthrough */ case GRPC_DTS_FH_8: - GPR_ASSERT(cur < end); + GPR_DEBUG_ASSERT(cur < end); t->incoming_stream_id |= (static_cast(*cur)); t->deframe_state = GRPC_DTS_FRAME; err = init_frame_parser(t); @@ -208,7 +208,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t, } /* fallthrough */ case GRPC_DTS_FRAME: - GPR_ASSERT(cur < end); + GPR_DEBUG_ASSERT(cur < end); if (static_cast(end - cur) == t->incoming_frame_size) { err = parse_frame_slice( t, @@ -425,7 +425,7 @@ static void on_initial_header(void* tp, grpc_mdelem md) { grpc_chttp2_transport* t = static_cast(tp); grpc_chttp2_stream* s = t->incoming_stream; - GPR_ASSERT(s != nullptr); + GPR_DEBUG_ASSERT(s != nullptr); if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { char* key = grpc_slice_to_c_string(GRPC_MDKEY(md)); @@ -473,7 +473,7 @@ static void on_initial_header(void* tp, grpc_mdelem md) { const size_t metadata_size_limit = t->settings[GRPC_ACKED_SETTINGS] [GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE]; - if (new_size > metadata_size_limit) { + if (GPR_UNLIKELY(new_size > metadata_size_limit)) { gpr_log(GPR_DEBUG, "received initial metadata size exceeds limit (%" PRIuPTR " vs. %" PRIuPTR ")", @@ -504,7 +504,7 @@ static void on_trailing_header(void* tp, grpc_mdelem md) { grpc_chttp2_transport* t = static_cast(tp); grpc_chttp2_stream* s = t->incoming_stream; - GPR_ASSERT(s != nullptr); + GPR_DEBUG_ASSERT(s != nullptr); if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { char* key = grpc_slice_to_c_string(GRPC_MDKEY(md)); @@ -627,7 +627,7 @@ static grpc_error* init_header_frame_parser(grpc_chttp2_transport* t, } else { t->incoming_stream = s; } - GPR_ASSERT(s != nullptr); + GPR_DEBUG_ASSERT(s != nullptr); s->stats.incoming.framing_bytes += 9; if (GPR_UNLIKELY(s->read_closed)) { GRPC_CHTTP2_IF_TRACING(gpr_log( diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index 219266c3941..e61f57c01ab 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -174,6 +174,17 @@ struct grpc_slice_refcount { namespace grpc_core { +struct StaticSliceRefcount { + static grpc_slice_refcount kStaticSubRefcount; + + StaticSliceRefcount(uint32_t index) + : base(&kStaticSubRefcount, grpc_slice_refcount::Type::STATIC), + index(index) {} + + grpc_slice_refcount base; + uint32_t index; +}; + extern grpc_slice_refcount kNoopRefcount; struct InternedSliceRefcount { diff --git a/src/core/lib/transport/metadata_batch.cc b/src/core/lib/transport/metadata_batch.cc index 49a56e709d5..74356b2caf2 100644 --- a/src/core/lib/transport/metadata_batch.cc +++ b/src/core/lib/transport/metadata_batch.cc @@ -104,7 +104,7 @@ static grpc_error* maybe_link_callout(grpc_metadata_batch* batch, if (idx == GRPC_BATCH_CALLOUTS_COUNT) { return GRPC_ERROR_NONE; } - if (batch->idx.array[idx] == nullptr) { + if (GPR_LIKELY(batch->idx.array[idx] == nullptr)) { ++batch->list.default_count; batch->idx.array[idx] = storage; return GRPC_ERROR_NONE; diff --git a/src/core/lib/transport/static_metadata.cc b/src/core/lib/transport/static_metadata.cc index ec5db5515a7..3085348d9e5 100644 --- a/src/core/lib/transport/static_metadata.cc +++ b/src/core/lib/transport/static_metadata.cc @@ -116,330 +116,331 @@ static uint8_t g_bytes[] = { 116, 105, 116, 121, 44, 100, 101, 102, 108, 97, 116, 101, 44, 103, 122, 105, 112}; -static grpc_slice_refcount static_sub_refcnt; -grpc_slice_refcount grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT] = { - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), - grpc_slice_refcount(&static_sub_refcnt, grpc_slice_refcount::Type::STATIC), +grpc_slice_refcount grpc_core::StaticSliceRefcount::kStaticSubRefcount; +grpc_core::StaticSliceRefcount + grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT] = { + grpc_core::StaticSliceRefcount(0), + grpc_core::StaticSliceRefcount(1), + grpc_core::StaticSliceRefcount(2), + grpc_core::StaticSliceRefcount(3), + grpc_core::StaticSliceRefcount(4), + grpc_core::StaticSliceRefcount(5), + grpc_core::StaticSliceRefcount(6), + grpc_core::StaticSliceRefcount(7), + grpc_core::StaticSliceRefcount(8), + grpc_core::StaticSliceRefcount(9), + grpc_core::StaticSliceRefcount(10), + grpc_core::StaticSliceRefcount(11), + grpc_core::StaticSliceRefcount(12), + grpc_core::StaticSliceRefcount(13), + grpc_core::StaticSliceRefcount(14), + grpc_core::StaticSliceRefcount(15), + grpc_core::StaticSliceRefcount(16), + grpc_core::StaticSliceRefcount(17), + grpc_core::StaticSliceRefcount(18), + grpc_core::StaticSliceRefcount(19), + grpc_core::StaticSliceRefcount(20), + grpc_core::StaticSliceRefcount(21), + grpc_core::StaticSliceRefcount(22), + grpc_core::StaticSliceRefcount(23), + grpc_core::StaticSliceRefcount(24), + grpc_core::StaticSliceRefcount(25), + grpc_core::StaticSliceRefcount(26), + grpc_core::StaticSliceRefcount(27), + grpc_core::StaticSliceRefcount(28), + grpc_core::StaticSliceRefcount(29), + grpc_core::StaticSliceRefcount(30), + grpc_core::StaticSliceRefcount(31), + grpc_core::StaticSliceRefcount(32), + grpc_core::StaticSliceRefcount(33), + grpc_core::StaticSliceRefcount(34), + grpc_core::StaticSliceRefcount(35), + grpc_core::StaticSliceRefcount(36), + grpc_core::StaticSliceRefcount(37), + grpc_core::StaticSliceRefcount(38), + grpc_core::StaticSliceRefcount(39), + grpc_core::StaticSliceRefcount(40), + grpc_core::StaticSliceRefcount(41), + grpc_core::StaticSliceRefcount(42), + grpc_core::StaticSliceRefcount(43), + grpc_core::StaticSliceRefcount(44), + grpc_core::StaticSliceRefcount(45), + grpc_core::StaticSliceRefcount(46), + grpc_core::StaticSliceRefcount(47), + grpc_core::StaticSliceRefcount(48), + grpc_core::StaticSliceRefcount(49), + grpc_core::StaticSliceRefcount(50), + grpc_core::StaticSliceRefcount(51), + grpc_core::StaticSliceRefcount(52), + grpc_core::StaticSliceRefcount(53), + grpc_core::StaticSliceRefcount(54), + grpc_core::StaticSliceRefcount(55), + grpc_core::StaticSliceRefcount(56), + grpc_core::StaticSliceRefcount(57), + grpc_core::StaticSliceRefcount(58), + grpc_core::StaticSliceRefcount(59), + grpc_core::StaticSliceRefcount(60), + grpc_core::StaticSliceRefcount(61), + grpc_core::StaticSliceRefcount(62), + grpc_core::StaticSliceRefcount(63), + grpc_core::StaticSliceRefcount(64), + grpc_core::StaticSliceRefcount(65), + grpc_core::StaticSliceRefcount(66), + grpc_core::StaticSliceRefcount(67), + grpc_core::StaticSliceRefcount(68), + grpc_core::StaticSliceRefcount(69), + grpc_core::StaticSliceRefcount(70), + grpc_core::StaticSliceRefcount(71), + grpc_core::StaticSliceRefcount(72), + grpc_core::StaticSliceRefcount(73), + grpc_core::StaticSliceRefcount(74), + grpc_core::StaticSliceRefcount(75), + grpc_core::StaticSliceRefcount(76), + grpc_core::StaticSliceRefcount(77), + grpc_core::StaticSliceRefcount(78), + grpc_core::StaticSliceRefcount(79), + grpc_core::StaticSliceRefcount(80), + grpc_core::StaticSliceRefcount(81), + grpc_core::StaticSliceRefcount(82), + grpc_core::StaticSliceRefcount(83), + grpc_core::StaticSliceRefcount(84), + grpc_core::StaticSliceRefcount(85), + grpc_core::StaticSliceRefcount(86), + grpc_core::StaticSliceRefcount(87), + grpc_core::StaticSliceRefcount(88), + grpc_core::StaticSliceRefcount(89), + grpc_core::StaticSliceRefcount(90), + grpc_core::StaticSliceRefcount(91), + grpc_core::StaticSliceRefcount(92), + grpc_core::StaticSliceRefcount(93), + grpc_core::StaticSliceRefcount(94), + grpc_core::StaticSliceRefcount(95), + grpc_core::StaticSliceRefcount(96), + grpc_core::StaticSliceRefcount(97), + grpc_core::StaticSliceRefcount(98), + grpc_core::StaticSliceRefcount(99), + grpc_core::StaticSliceRefcount(100), + grpc_core::StaticSliceRefcount(101), + grpc_core::StaticSliceRefcount(102), + grpc_core::StaticSliceRefcount(103), + grpc_core::StaticSliceRefcount(104), + grpc_core::StaticSliceRefcount(105), }; const grpc_core::StaticMetadataSlice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT] = { - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[0], 5, - g_bytes + 0), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1], 7, - g_bytes + 5), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2], 7, - g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[3], 10, - g_bytes + 19), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4], 7, - g_bytes + 29), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[5], 2, - g_bytes + 36), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[6], 12, - g_bytes + 38), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7], 11, - g_bytes + 50), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[8], 16, - g_bytes + 61), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9], 13, - g_bytes + 77), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10], 20, - g_bytes + 90), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[11], 21, - g_bytes + 110), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[12], 13, - g_bytes + 131), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[13], 14, - g_bytes + 144), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[14], 12, - g_bytes + 158), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15], 16, - g_bytes + 170), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16], 15, - g_bytes + 186), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[17], 30, - g_bytes + 201), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[18], 37, - g_bytes + 231), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[19], 10, - g_bytes + 268), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[20], 4, - g_bytes + 278), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[21], 26, - g_bytes + 282), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[22], 22, - g_bytes + 308), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[23], 12, - g_bytes + 330), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[24], 1, - g_bytes + 342), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[25], 1, - g_bytes + 343), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[26], 1, - g_bytes + 344), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[27], 1, - g_bytes + 345), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[29], 19, - g_bytes + 346), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[30], 12, - g_bytes + 365), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[31], 30, - g_bytes + 377), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[32], 31, - g_bytes + 407), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[33], 36, - g_bytes + 438), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[34], 28, - g_bytes + 474), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[35], 80, - g_bytes + 502), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[36], 7, - g_bytes + 582), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37], 4, - g_bytes + 589), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[38], 11, - g_bytes + 593), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[39], 3, - g_bytes + 604), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[40], 4, - g_bytes + 607), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[41], 1, - g_bytes + 611), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[42], 11, - g_bytes + 612), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[43], 4, - g_bytes + 623), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[44], 5, - g_bytes + 627), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[45], 3, - g_bytes + 632), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[46], 3, - g_bytes + 635), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[47], 3, - g_bytes + 638), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[48], 3, - g_bytes + 641), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[49], 3, - g_bytes + 644), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[50], 3, - g_bytes + 647), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[51], 3, - g_bytes + 650), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[52], 14, - g_bytes + 653), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[53], 13, - g_bytes + 667), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[54], 15, - g_bytes + 680), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[55], 13, - g_bytes + 695), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[56], 6, - g_bytes + 708), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[57], 27, - g_bytes + 714), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[58], 3, - g_bytes + 741), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[59], 5, - g_bytes + 744), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[60], 13, - g_bytes + 749), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[61], 13, - g_bytes + 762), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[62], 19, - g_bytes + 775), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[63], 16, - g_bytes + 794), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[64], 14, - g_bytes + 810), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[65], 16, - g_bytes + 824), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[66], 13, - g_bytes + 840), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[67], 6, - g_bytes + 853), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[68], 4, - g_bytes + 859), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[69], 4, - g_bytes + 863), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[70], 6, - g_bytes + 867), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[71], 7, - g_bytes + 873), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[72], 4, - g_bytes + 880), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[73], 8, - g_bytes + 884), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[74], 17, - g_bytes + 892), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[75], 13, - g_bytes + 909), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[76], 8, - g_bytes + 922), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[77], 19, - g_bytes + 930), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[78], 13, - g_bytes + 949), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[79], 4, - g_bytes + 962), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[80], 8, - g_bytes + 966), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[81], 12, - g_bytes + 974), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[82], 18, - g_bytes + 986), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[83], 19, - g_bytes + 1004), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[84], 5, - g_bytes + 1023), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[85], 7, - g_bytes + 1028), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[86], 7, - g_bytes + 1035), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[87], 11, - g_bytes + 1042), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[88], 6, - g_bytes + 1053), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[89], 10, - g_bytes + 1059), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[90], 25, - g_bytes + 1069), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[91], 17, - g_bytes + 1094), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[92], 4, - g_bytes + 1111), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[93], 3, - g_bytes + 1115), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[94], 16, - g_bytes + 1118), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[95], 1, - g_bytes + 1134), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96], 8, - g_bytes + 1135), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97], 8, - g_bytes + 1143), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98], 16, - g_bytes + 1151), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[99], 4, - g_bytes + 1167), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[100], 3, - g_bytes + 1171), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[101], 11, - g_bytes + 1174), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[102], 16, - g_bytes + 1185), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[103], 13, - g_bytes + 1201), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[104], 12, - g_bytes + 1214), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[105], 21, - g_bytes + 1226), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[0].base, + 5, g_bytes + 0), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1].base, + 7, g_bytes + 5), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, + 7, g_bytes + 12), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[3].base, + 10, g_bytes + 19), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4].base, + 7, g_bytes + 29), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[5].base, + 2, g_bytes + 36), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[6].base, + 12, g_bytes + 38), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7].base, + 11, g_bytes + 50), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[8].base, + 16, g_bytes + 61), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9].base, + 13, g_bytes + 77), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, + 20, g_bytes + 90), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[11].base, + 21, g_bytes + 110), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[12].base, + 13, g_bytes + 131), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[13].base, + 14, g_bytes + 144), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[14].base, + 12, g_bytes + 158), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15].base, + 16, g_bytes + 170), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, + 15, g_bytes + 186), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[17].base, + 30, g_bytes + 201), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[18].base, + 37, g_bytes + 231), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[19].base, + 10, g_bytes + 268), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[20].base, + 4, g_bytes + 278), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[21].base, + 26, g_bytes + 282), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[22].base, + 22, g_bytes + 308), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[23].base, + 12, g_bytes + 330), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[24].base, + 1, g_bytes + 342), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[25].base, + 1, g_bytes + 343), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[26].base, + 1, g_bytes + 344), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[27].base, + 1, g_bytes + 345), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[29].base, + 19, g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[30].base, + 12, g_bytes + 365), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[31].base, + 30, g_bytes + 377), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[32].base, + 31, g_bytes + 407), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[33].base, + 36, g_bytes + 438), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[34].base, + 28, g_bytes + 474), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[35].base, + 80, g_bytes + 502), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[36].base, + 7, g_bytes + 582), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37].base, + 4, g_bytes + 589), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[38].base, + 11, g_bytes + 593), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[39].base, + 3, g_bytes + 604), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[40].base, + 4, g_bytes + 607), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[41].base, + 1, g_bytes + 611), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[42].base, + 11, g_bytes + 612), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[43].base, + 4, g_bytes + 623), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[44].base, + 5, g_bytes + 627), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[45].base, + 3, g_bytes + 632), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[46].base, + 3, g_bytes + 635), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[47].base, + 3, g_bytes + 638), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[48].base, + 3, g_bytes + 641), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[49].base, + 3, g_bytes + 644), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[50].base, + 3, g_bytes + 647), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[51].base, + 3, g_bytes + 650), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[52].base, + 14, g_bytes + 653), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[53].base, + 13, g_bytes + 667), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[54].base, + 15, g_bytes + 680), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[55].base, + 13, g_bytes + 695), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[56].base, + 6, g_bytes + 708), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[57].base, + 27, g_bytes + 714), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[58].base, + 3, g_bytes + 741), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[59].base, + 5, g_bytes + 744), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[60].base, + 13, g_bytes + 749), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[61].base, + 13, g_bytes + 762), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[62].base, + 19, g_bytes + 775), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[63].base, + 16, g_bytes + 794), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[64].base, + 14, g_bytes + 810), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[65].base, + 16, g_bytes + 824), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[66].base, + 13, g_bytes + 840), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[67].base, + 6, g_bytes + 853), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[68].base, + 4, g_bytes + 859), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[69].base, + 4, g_bytes + 863), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[70].base, + 6, g_bytes + 867), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[71].base, + 7, g_bytes + 873), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[72].base, + 4, g_bytes + 880), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[73].base, + 8, g_bytes + 884), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[74].base, + 17, g_bytes + 892), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[75].base, + 13, g_bytes + 909), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[76].base, + 8, g_bytes + 922), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[77].base, + 19, g_bytes + 930), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[78].base, + 13, g_bytes + 949), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[79].base, + 4, g_bytes + 962), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[80].base, + 8, g_bytes + 966), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[81].base, + 12, g_bytes + 974), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[82].base, + 18, g_bytes + 986), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[83].base, + 19, g_bytes + 1004), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[84].base, + 5, g_bytes + 1023), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[85].base, + 7, g_bytes + 1028), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[86].base, + 7, g_bytes + 1035), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[87].base, + 11, g_bytes + 1042), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[88].base, + 6, g_bytes + 1053), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[89].base, + 10, g_bytes + 1059), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[90].base, + 25, g_bytes + 1069), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[91].base, + 17, g_bytes + 1094), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[92].base, + 4, g_bytes + 1111), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[93].base, + 3, g_bytes + 1115), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[94].base, + 16, g_bytes + 1118), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[95].base, + 1, g_bytes + 1134), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96].base, + 8, g_bytes + 1135), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97].base, + 8, g_bytes + 1143), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98].base, + 16, g_bytes + 1151), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[99].base, + 4, g_bytes + 1167), + grpc_core::StaticMetadataSlice( + &grpc_static_metadata_refcounts[100].base, 3, g_bytes + 1171), + grpc_core::StaticMetadataSlice( + &grpc_static_metadata_refcounts[101].base, 11, g_bytes + 1174), + grpc_core::StaticMetadataSlice( + &grpc_static_metadata_refcounts[102].base, 16, g_bytes + 1185), + grpc_core::StaticMetadataSlice( + &grpc_static_metadata_refcounts[103].base, 13, g_bytes + 1201), + grpc_core::StaticMetadataSlice( + &grpc_static_metadata_refcounts[104].base, 12, g_bytes + 1214), + grpc_core::StaticMetadataSlice( + &grpc_static_metadata_refcounts[105].base, 21, g_bytes + 1226), }; /* Warning: the core static metadata currently operates under the soft @@ -937,514 +938,514 @@ grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b) { grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[3], 10, - g_bytes + 19), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[3].base, + 10, g_bytes + 19), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 0), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1], 7, - g_bytes + 5), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[39], 3, - g_bytes + 604), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1].base, + 7, g_bytes + 5), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[39].base, + 3, g_bytes + 604), 1), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1], 7, - g_bytes + 5), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[40], 4, - g_bytes + 607), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1].base, + 7, g_bytes + 5), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[40].base, + 4, g_bytes + 607), 2), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[0], 5, - g_bytes + 0), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[41], 1, - g_bytes + 611), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[0].base, + 5, g_bytes + 0), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[41].base, + 1, g_bytes + 611), 3), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[0], 5, - g_bytes + 0), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[42], 11, - g_bytes + 612), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[0].base, + 5, g_bytes + 0), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[42].base, + 11, g_bytes + 612), 4), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4], 7, - g_bytes + 29), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[43], 4, - g_bytes + 623), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4].base, + 7, g_bytes + 29), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[43].base, + 4, g_bytes + 623), 5), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4], 7, - g_bytes + 29), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[44], 5, - g_bytes + 627), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4].base, + 7, g_bytes + 29), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[44].base, + 5, g_bytes + 627), 6), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2], 7, - g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[45], 3, - g_bytes + 632), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, + 7, g_bytes + 12), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[45].base, + 3, g_bytes + 632), 7), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2], 7, - g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[46], 3, - g_bytes + 635), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, + 7, g_bytes + 12), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[46].base, + 3, g_bytes + 635), 8), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2], 7, - g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[47], 3, - g_bytes + 638), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, + 7, g_bytes + 12), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[47].base, + 3, g_bytes + 638), 9), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2], 7, - g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[48], 3, - g_bytes + 641), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, + 7, g_bytes + 12), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[48].base, + 3, g_bytes + 641), 10), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2], 7, - g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[49], 3, - g_bytes + 644), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, + 7, g_bytes + 12), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[49].base, + 3, g_bytes + 644), 11), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2], 7, - g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[50], 3, - g_bytes + 647), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, + 7, g_bytes + 12), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[50].base, + 3, g_bytes + 647), 12), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2], 7, - g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[51], 3, - g_bytes + 650), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, + 7, g_bytes + 12), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[51].base, + 3, g_bytes + 650), 13), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[52], 14, - g_bytes + 653), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[52].base, + 14, g_bytes + 653), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 14), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16], 15, - g_bytes + 186), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[53], 13, - g_bytes + 667), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, + 15, g_bytes + 186), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[53].base, + 13, g_bytes + 667), 15), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[54], 15, - g_bytes + 680), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[54].base, + 15, g_bytes + 680), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 16), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[55], 13, - g_bytes + 695), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[55].base, + 13, g_bytes + 695), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 17), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[56], 6, - g_bytes + 708), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[56].base, + 6, g_bytes + 708), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 18), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[57], 27, - g_bytes + 714), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[57].base, + 27, g_bytes + 714), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 19), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[58], 3, - g_bytes + 741), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[58].base, + 3, g_bytes + 741), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 20), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[59], 5, - g_bytes + 744), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[59].base, + 5, g_bytes + 744), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 21), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[60], 13, - g_bytes + 749), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[60].base, + 13, g_bytes + 749), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 22), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[61], 13, - g_bytes + 762), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[61].base, + 13, g_bytes + 762), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 23), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[62], 19, - g_bytes + 775), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[62].base, + 19, g_bytes + 775), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 24), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15], 16, - g_bytes + 170), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15].base, + 16, g_bytes + 170), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 25), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[63], 16, - g_bytes + 794), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[63].base, + 16, g_bytes + 794), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 26), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[64], 14, - g_bytes + 810), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[64].base, + 14, g_bytes + 810), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 27), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[65], 16, - g_bytes + 824), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[65].base, + 16, g_bytes + 824), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 28), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[66], 13, - g_bytes + 840), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[66].base, + 13, g_bytes + 840), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 29), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[14], 12, - g_bytes + 158), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[14].base, + 12, g_bytes + 158), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 30), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[67], 6, - g_bytes + 853), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[67].base, + 6, g_bytes + 853), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 31), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[68], 4, - g_bytes + 859), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[68].base, + 4, g_bytes + 859), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 32), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[69], 4, - g_bytes + 863), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[69].base, + 4, g_bytes + 863), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 33), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[70], 6, - g_bytes + 867), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[70].base, + 6, g_bytes + 867), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 34), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[71], 7, - g_bytes + 873), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[71].base, + 7, g_bytes + 873), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 35), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[72], 4, - g_bytes + 880), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[72].base, + 4, g_bytes + 880), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 36), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[20], 4, - g_bytes + 278), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[20].base, + 4, g_bytes + 278), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 37), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[73], 8, - g_bytes + 884), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[73].base, + 8, g_bytes + 884), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 38), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[74], 17, - g_bytes + 892), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[74].base, + 17, g_bytes + 892), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 39), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[75], 13, - g_bytes + 909), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[75].base, + 13, g_bytes + 909), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 40), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[76], 8, - g_bytes + 922), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[76].base, + 8, g_bytes + 922), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 41), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[77], 19, - g_bytes + 930), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[77].base, + 19, g_bytes + 930), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 42), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[78], 13, - g_bytes + 949), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[78].base, + 13, g_bytes + 949), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 43), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[79], 4, - g_bytes + 962), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[79].base, + 4, g_bytes + 962), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 44), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[80], 8, - g_bytes + 966), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[80].base, + 8, g_bytes + 966), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 45), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[81], 12, - g_bytes + 974), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[81].base, + 12, g_bytes + 974), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 46), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[82], 18, - g_bytes + 986), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[82].base, + 18, g_bytes + 986), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 47), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[83], 19, - g_bytes + 1004), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[83].base, + 19, g_bytes + 1004), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 48), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[84], 5, - g_bytes + 1023), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[84].base, + 5, g_bytes + 1023), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 49), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[85], 7, - g_bytes + 1028), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[85].base, + 7, g_bytes + 1028), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 50), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[86], 7, - g_bytes + 1035), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[86].base, + 7, g_bytes + 1035), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 51), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[87], 11, - g_bytes + 1042), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[87].base, + 11, g_bytes + 1042), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 52), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[88], 6, - g_bytes + 1053), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[88].base, + 6, g_bytes + 1053), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 53), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[89], 10, - g_bytes + 1059), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[89].base, + 10, g_bytes + 1059), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 54), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[90], 25, - g_bytes + 1069), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[90].base, + 25, g_bytes + 1069), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 55), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[91], 17, - g_bytes + 1094), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[91].base, + 17, g_bytes + 1094), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 56), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[19], 10, - g_bytes + 268), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[19].base, + 10, g_bytes + 268), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 57), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[92], 4, - g_bytes + 1111), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[92].base, + 4, g_bytes + 1111), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 58), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[93], 3, - g_bytes + 1115), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[93].base, + 3, g_bytes + 1115), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 59), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[94], 16, - g_bytes + 1118), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[94].base, + 16, g_bytes + 1118), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 60), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7], 11, - g_bytes + 50), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[95], 1, - g_bytes + 1134), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7].base, + 11, g_bytes + 50), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[95].base, + 1, g_bytes + 1134), 61), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7], 11, - g_bytes + 50), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[24], 1, - g_bytes + 342), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7].base, + 11, g_bytes + 50), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[24].base, + 1, g_bytes + 342), 62), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7], 11, - g_bytes + 50), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[25], 1, - g_bytes + 343), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7].base, + 11, g_bytes + 50), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[25].base, + 1, g_bytes + 343), 63), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9], 13, - g_bytes + 77), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96], 8, - g_bytes + 1135), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9].base, + 13, g_bytes + 77), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96].base, + 8, g_bytes + 1135), 64), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9], 13, - g_bytes + 77), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37], 4, - g_bytes + 589), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9].base, + 13, g_bytes + 77), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37].base, + 4, g_bytes + 589), 65), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9], 13, - g_bytes + 77), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[36], 7, - g_bytes + 582), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9].base, + 13, g_bytes + 77), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[36].base, + 7, g_bytes + 582), 66), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[5], 2, - g_bytes + 36), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97], 8, - g_bytes + 1143), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[5].base, + 2, g_bytes + 36), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97].base, + 8, g_bytes + 1143), 67), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[14], 12, - g_bytes + 158), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98], 16, - g_bytes + 1151), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[14].base, + 12, g_bytes + 158), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98].base, + 16, g_bytes + 1151), 68), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4], 7, - g_bytes + 29), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[99], 4, - g_bytes + 1167), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4].base, + 7, g_bytes + 29), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[99].base, + 4, g_bytes + 1167), 69), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1], 7, - g_bytes + 5), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[100], 3, - g_bytes + 1171), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1].base, + 7, g_bytes + 5), + grpc_core::StaticMetadataSlice( + &grpc_static_metadata_refcounts[100].base, 3, g_bytes + 1171), 70), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16], 15, - g_bytes + 186), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, + 15, g_bytes + 186), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 71), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15], 16, - g_bytes + 170), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96], 8, - g_bytes + 1135), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15].base, + 16, g_bytes + 170), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96].base, + 8, g_bytes + 1135), 72), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15], 16, - g_bytes + 170), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37], 4, - g_bytes + 589), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15].base, + 16, g_bytes + 170), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37].base, + 4, g_bytes + 589), 73), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[101], 11, - g_bytes + 1174), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28], 0, - g_bytes + 346), + grpc_core::StaticMetadataSlice( + &grpc_static_metadata_refcounts[101].base, 11, g_bytes + 1174), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, + 0, g_bytes + 346), 74), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10], 20, - g_bytes + 90), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96], 8, - g_bytes + 1135), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, + 20, g_bytes + 90), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96].base, + 8, g_bytes + 1135), 75), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10], 20, - g_bytes + 90), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[36], 7, - g_bytes + 582), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, + 20, g_bytes + 90), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[36].base, + 7, g_bytes + 582), 76), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10], 20, - g_bytes + 90), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[102], 16, - g_bytes + 1185), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, + 20, g_bytes + 90), + grpc_core::StaticMetadataSlice( + &grpc_static_metadata_refcounts[102].base, 16, g_bytes + 1185), 77), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10], 20, - g_bytes + 90), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37], 4, - g_bytes + 589), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, + 20, g_bytes + 90), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37].base, + 4, g_bytes + 589), 78), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10], 20, - g_bytes + 90), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[103], 13, - g_bytes + 1201), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, + 20, g_bytes + 90), + grpc_core::StaticMetadataSlice( + &grpc_static_metadata_refcounts[103].base, 13, g_bytes + 1201), 79), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10], 20, - g_bytes + 90), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[104], 12, - g_bytes + 1214), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, + 20, g_bytes + 90), + grpc_core::StaticMetadataSlice( + &grpc_static_metadata_refcounts[104].base, 12, g_bytes + 1214), 80), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10], 20, - g_bytes + 90), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[105], 21, - g_bytes + 1226), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, + 20, g_bytes + 90), + grpc_core::StaticMetadataSlice( + &grpc_static_metadata_refcounts[105].base, 21, g_bytes + 1226), 81), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16], 15, - g_bytes + 186), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96], 8, - g_bytes + 1135), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, + 15, g_bytes + 186), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96].base, + 8, g_bytes + 1135), 82), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16], 15, - g_bytes + 186), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37], 4, - g_bytes + 589), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, + 15, g_bytes + 186), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37].base, + 4, g_bytes + 589), 83), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16], 15, - g_bytes + 186), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[103], 13, - g_bytes + 1201), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, + 15, g_bytes + 186), + grpc_core::StaticMetadataSlice( + &grpc_static_metadata_refcounts[103].base, 13, g_bytes + 1201), 84), }; const uint8_t grpc_static_accept_encoding_metadata[8] = {0, 75, 76, 77, diff --git a/src/core/lib/transport/static_metadata.h b/src/core/lib/transport/static_metadata.h index 7c05b27cc07..30082985b5c 100644 --- a/src/core/lib/transport/static_metadata.h +++ b/src/core/lib/transport/static_metadata.h @@ -260,15 +260,18 @@ extern const grpc_core::StaticMetadataSlice #define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \ (grpc_static_slice_table[105]) -extern grpc_slice_refcount +namespace grpc_core { +struct StaticSliceRefcount; +} +extern grpc_core::StaticSliceRefcount grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT]; #define GRPC_IS_STATIC_METADATA_STRING(slice) \ ((slice).refcount != NULL && \ (slice).refcount->GetType() == grpc_slice_refcount::Type::STATIC) -#define GRPC_STATIC_METADATA_INDEX(static_slice) \ - (static_cast( \ - ((static_slice).refcount - grpc_static_metadata_refcounts))) +#define GRPC_STATIC_METADATA_INDEX(static_slice) \ + (reinterpret_cast((static_slice).refcount) \ + ->index) #define GRPC_STATIC_MDELEM_COUNT 85 extern grpc_core::StaticMetadata @@ -519,11 +522,14 @@ typedef union { } named; } grpc_metadata_batch_callouts; -#define GRPC_BATCH_INDEX_OF(slice) \ - (GRPC_IS_STATIC_METADATA_STRING((slice)) \ - ? static_cast( \ - GPR_CLAMP(GRPC_STATIC_METADATA_INDEX((slice)), 0, \ - static_cast(GRPC_BATCH_CALLOUTS_COUNT))) \ +#define GRPC_BATCH_INDEX_OF(slice) \ + (GRPC_IS_STATIC_METADATA_STRING((slice)) && \ + reinterpret_cast((slice).refcount) \ + ->index <= static_cast(GRPC_BATCH_CALLOUTS_COUNT) \ + ? static_cast( \ + reinterpret_cast( \ + (slice).refcount) \ + ->index) \ : GRPC_BATCH_CALLOUTS_COUNT) extern const uint8_t grpc_static_accept_encoding_metadata[8]; diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py index 213efd22346..fd1d9cbfb49 100755 --- a/tools/codegen/core/gen_static_metadata.py +++ b/tools/codegen/core/gen_static_metadata.py @@ -393,7 +393,7 @@ for i, elem in enumerate(all_strs): def slice_def(i): return ( - 'grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[%d], %d, g_bytes+%d)' + 'grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[%d].base, %d, g_bytes+%d)' ) % (i, len(all_strs[i]), id2strofs[i]) @@ -416,14 +416,14 @@ print >> H print >> C, 'static uint8_t g_bytes[] = {%s};' % (','.join( '%d' % ord(c) for c in ''.join(all_strs))) print >> C -print >> C, ('static grpc_slice_refcount static_sub_refcnt;') -print >> H, ('extern grpc_slice_refcount ' +print >> H, ('namespace grpc_core { struct StaticSliceRefcount; }') +print >> H, ('extern grpc_core::StaticSliceRefcount ' 'grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT];') -print >> C, ('grpc_slice_refcount ' +print >> C, 'grpc_slice_refcount grpc_core::StaticSliceRefcount::kStaticSubRefcount;' +print >> C, ('grpc_core::StaticSliceRefcount ' 'grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT] = {') for i, elem in enumerate(all_strs): - print >> C, (' grpc_slice_refcount(&static_sub_refcnt, ' - 'grpc_slice_refcount::Type::STATIC), ') + print >> C, ' grpc_core::StaticSliceRefcount(%d), ' % i print >> C, '};' print >> C print >> H, '#define GRPC_IS_STATIC_METADATA_STRING(slice) \\' @@ -438,8 +438,7 @@ for i, elem in enumerate(all_strs): print >> C, '};' print >> C print >> H, '#define GRPC_STATIC_METADATA_INDEX(static_slice) \\' -print >> H, (' (static_cast(((static_slice).refcount - ' - 'grpc_static_metadata_refcounts)))') +print >> H, '(reinterpret_cast((static_slice).refcount)->index)' print >> H print >> D, '# hpack fuzzing dictionary' @@ -598,8 +597,26 @@ for elem in METADATA_BATCH_CALLOUTS: print >> H, ' } named;' print >> H, '} grpc_metadata_batch_callouts;' print >> H -print >> H, '#define GRPC_BATCH_INDEX_OF(slice) \\' -print >> H, ' (GRPC_IS_STATIC_METADATA_STRING((slice)) ? static_cast(GPR_CLAMP(GRPC_STATIC_METADATA_INDEX((slice)), 0, static_cast(GRPC_BATCH_CALLOUTS_COUNT))) : GRPC_BATCH_CALLOUTS_COUNT)' + +batch_idx_of_hdr = '#define GRPC_BATCH_INDEX_OF(slice) \\' +static_slice = 'GRPC_IS_STATIC_METADATA_STRING((slice))' +slice_to_slice_ref = '(slice).refcount' +static_slice_ref_type = 'grpc_core::StaticSliceRefcount*' +slice_ref_as_static = ('reinterpret_cast<' + static_slice_ref_type + '>(' + + slice_to_slice_ref + ')') +slice_ref_idx = slice_ref_as_static + '->index' +batch_idx_type = 'grpc_metadata_batch_callouts_index' +slice_ref_idx_to_batch_idx = ( + 'static_cast<' + batch_idx_type + '>(' + slice_ref_idx + ')') +batch_invalid_idx = 'GRPC_BATCH_CALLOUTS_COUNT' +batch_invalid_u32 = 'static_cast(' + batch_invalid_idx + ')' +# Assemble GRPC_BATCH_INDEX_OF(slice) macro as a join for ease of reading. +batch_idx_of_pieces = [ + batch_idx_of_hdr, '\n', '(', static_slice, '&&', slice_ref_idx, '<=', + batch_invalid_u32, '?', slice_ref_idx_to_batch_idx, ':', batch_invalid_idx, + ')' +] +print >> H, ''.join(batch_idx_of_pieces) print >> H print >> H, 'extern const uint8_t grpc_static_accept_encoding_metadata[%d];' % ( From 732f55ac2288d74e988043a62b50b7493c31c5aa Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Thu, 1 Aug 2019 15:01:11 -0700 Subject: [PATCH 1063/1555] iOS UI test: fix path to generated code --- src/objective-c/manual_tests/ViewController.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/objective-c/manual_tests/ViewController.m b/src/objective-c/manual_tests/ViewController.m index 50a729e4d6a..30181c9d67e 100644 --- a/src/objective-c/manual_tests/ViewController.m +++ b/src/objective-c/manual_tests/ViewController.m @@ -20,8 +20,8 @@ #import #import -#import -#import +#import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" +#import "src/objective-c/tests/RemoteTestClient/Test.pbrpc.h" NSString *const kRemoteHost = @"grpc-test.sandbox.googleapis.com"; const int32_t kMessageSize = 100; From e9d81fb0f22691f69c6b42d1967eb3ba440de194 Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Thu, 1 Aug 2019 13:33:50 -0700 Subject: [PATCH 1064/1555] Send RPC deadline to server in cronet header --- .../cronet/transport/cronet_transport.cc | 31 ++++++++++++++----- .../ios/CronetTests/CppCronetEnd2EndTests.mm | 26 ++++++++++++++++ 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc index 28e6c04869e..19477bf9485 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.cc +++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc @@ -40,6 +40,7 @@ #include "src/core/lib/surface/validate_metadata.h" #include "src/core/lib/transport/metadata_batch.h" #include "src/core/lib/transport/static_metadata.h" +#include "src/core/lib/transport/timeout_encoding.h" #include "src/core/lib/transport/transport_impl.h" #include "third_party/objective_c/Cronet/bidirectional_stream_c.h" @@ -718,16 +719,20 @@ static void create_grpc_frame(grpc_slice_buffer* write_slice_buffer, Convert metadata in a format that Cronet can consume */ static void convert_metadata_to_cronet_headers( - grpc_linked_mdelem* head, const char* host, char** pp_url, + grpc_metadata_batch* metadata, const char* host, char** pp_url, bidirectional_stream_header** pp_headers, size_t* p_num_headers, const char** method) { - grpc_linked_mdelem* curr = head; + grpc_linked_mdelem* curr = metadata->list.head; /* Walk the linked list and get number of header fields */ size_t num_headers_available = 0; while (curr != nullptr) { curr = curr->next; num_headers_available++; } + grpc_millis deadline = metadata->deadline; + if (deadline != GRPC_MILLIS_INF_FUTURE) { + num_headers_available++; + } /* Allocate enough memory. It is freed in the on_stream_ready callback */ bidirectional_stream_header* headers = @@ -740,7 +745,7 @@ static void convert_metadata_to_cronet_headers( are not used for cronet. TODO (makdharma): Eliminate need to traverse the LL second time for perf. */ - curr = head; + curr = metadata->list.head; size_t num_headers = 0; while (num_headers < num_headers_available) { grpc_mdelem mdelem = curr->md; @@ -788,6 +793,18 @@ static void convert_metadata_to_cronet_headers( break; } } + if (deadline != GRPC_MILLIS_INF_FUTURE) { + char* key = grpc_slice_to_c_string(GRPC_MDSTR_GRPC_TIMEOUT); + char* value = + static_cast(gpr_malloc(GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE)); + grpc_http2_encode_timeout(deadline - grpc_core::ExecCtx::Get()->Now(), + value); + headers[num_headers].key = key; + headers[num_headers].value = value; + + num_headers++; + } + *p_num_headers = num_headers; } @@ -1028,10 +1045,10 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) { char* url = nullptr; const char* method = "POST"; s->header_array.headers = nullptr; - convert_metadata_to_cronet_headers(stream_op->payload->send_initial_metadata - .send_initial_metadata->list.head, - t->host, &url, &s->header_array.headers, - &s->header_array.count, &method); + convert_metadata_to_cronet_headers( + stream_op->payload->send_initial_metadata.send_initial_metadata, + t->host, &url, &s->header_array.headers, &s->header_array.count, + &method); s->header_array.capacity = s->header_array.count; CRONET_LOG(GPR_DEBUG, "bidirectional_stream_start(%p, %s)", s->cbs, url); bidirectional_stream_start(s->cbs, url, 0, method, &s->header_array, false); diff --git a/test/cpp/ios/CronetTests/CppCronetEnd2EndTests.mm b/test/cpp/ios/CronetTests/CppCronetEnd2EndTests.mm index 07b514f6c65..c6c3e3f345b 100644 --- a/test/cpp/ios/CronetTests/CppCronetEnd2EndTests.mm +++ b/test/cpp/ios/CronetTests/CppCronetEnd2EndTests.mm @@ -536,6 +536,32 @@ using grpc::ClientContext; XCTAssertEqual(response.param().request_deadline(), gpr_inf_future(GPR_CLOCK_REALTIME).tv_sec); } +- (void)testEchoDeadline { + auto stub = [self getStub]; + EchoRequest request; + EchoResponse response; + request.set_message("Hello"); + request.mutable_param()->set_echo_deadline(true); + + ClientContext context; + std::chrono::system_clock::time_point deadline = + std::chrono::system_clock::now() + std::chrono::seconds(100); + context.set_deadline(deadline); + Status s = stub->Echo(&context, request, &response); + XCTAssertEqual(response.message(), request.message()); + XCTAssertTrue(s.ok()); + gpr_timespec sent_deadline; + grpc::Timepoint2Timespec(deadline, &sent_deadline); + // We want to allow some reasonable error given: + // - request_deadline() only has 1sec resolution so the best we can do is +-1 + // - if sent_deadline.tv_nsec is very close to the next second's boundary we + // can end up being off by 2 in one direction. + XCTAssertLessThanOrEqual(response.param().request_deadline() - sent_deadline.tv_sec, 2); + XCTAssertGreaterThanOrEqual(response.param().request_deadline() - sent_deadline.tv_sec, -1); + NSLog(@"request deadline: %d sent_deadline: %d", response.param().request_deadline(), + sent_deadline.tv_sec); +} + - (void)testPeer { auto stub = [self getStub]; EchoRequest request; From 7b2c8c27b06f92b7d3594ec4f2863e5d759f1760 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 16 Jul 2019 15:20:56 -0700 Subject: [PATCH 1065/1555] Separate py_grpc_library and py_proto_library. By popular demand, we'll now be offering separate py_grpc_library and py_proto_library targets sharing the same interface as within google3. This change necessitated some modifications to how we pull in our own Python-level dependencies and how we make those available to those pulling in our project via Bazel. There is now a grpc_python_deps() Bazel workspace rule that pulls in the appropriate dependencies, which should be called from the client project's WORKSPACE file. A test has been added to the bazel/test/ directory to verify that this behavior works as intended. It's worth noting that the protobuf repository's usage of Starlark bind() caused a great deal of trouble in ensuring that we could also pull in six. This change also required a change in the way generated proto code is imported in the channelz and health-check modules, as well as in their associated tests. We were importing them two different ways, each relative. This resulted in two different module objects being imported into the process, which were incompatible. I am not sure exactly what caused this behavior to begin, as this should have been possible before this PR. As a workaround, I am simply trying two different absolute imports and using the one that works. This should function both inside and outside of Bazel environments. --- WORKSPACE | 43 ++-- bazel/grpc_python_deps.bzl | 69 +++++- bazel/python_rules.bzl | 222 ++++++++++-------- bazel/test/python_test_repo/.gitignore | 2 + bazel/test/python_test_repo/BUILD | 46 ++++ bazel/test/python_test_repo/WORKSPACE | 10 + bazel/test/python_test_repo/helloworld.proto | 43 ++++ bazel/test/python_test_repo/helloworld.py | 73 ++++++ bazel/test/python_test_repo/tools/bazel | 1 + examples/BUILD | 16 +- examples/python/multiprocessing/BUILD | 18 +- examples/python/wait_for_ready/BUILD.bazel | 3 +- src/proto/grpc/channelz/BUILD | 10 +- src/proto/grpc/testing/BUILD | 31 ++- src/proto/grpc/testing/proto2/BUILD.bazel | 8 +- src/python/grpcio/grpc/BUILD.bazel | 6 +- .../grpcio/grpc/experimental/BUILD.bazel | 1 - .../grpcio/grpc/framework/common/BUILD.bazel | 5 +- .../grpc/framework/foundation/BUILD.bazel | 11 +- .../framework/interfaces/base/BUILD.bazel | 7 +- .../framework/interfaces/face/BUILD.bazel | 5 +- .../grpc_channelz/v1/BUILD.bazel | 16 +- .../grpc_channelz/v1/channelz.py | 8 +- .../grpc_health/v1/BUILD.bazel | 15 +- .../grpc_health/v1/health.py | 9 +- .../grpc_reflection/v1alpha/BUILD.bazel | 17 +- .../grpc_reflection/v1alpha/reflection.py | 8 +- .../grpcio_status/grpc_status/BUILD.bazel | 2 +- .../tests/channelz/_channelz_servicer_test.py | 11 +- .../health_check/_health_servicer_test.py | 15 +- .../grpcio_tests/tests/interop/BUILD.bazel | 7 +- .../grpcio_tests/tests/reflection/BUILD.bazel | 2 +- .../reflection/_reflection_servicer_test.py | 11 +- .../grpcio_tests/tests/unit/BUILD.bazel | 4 +- third_party/BUILD | 3 + third_party/enum34.BUILD | 6 + third_party/futures.BUILD | 6 + third_party/six.BUILD | 6 + .../linux/grpc_python_bazel_test_in_docker.sh | 3 + 39 files changed, 573 insertions(+), 206 deletions(-) create mode 100644 bazel/test/python_test_repo/.gitignore create mode 100644 bazel/test/python_test_repo/BUILD create mode 100644 bazel/test/python_test_repo/WORKSPACE create mode 100644 bazel/test/python_test_repo/helloworld.proto create mode 100644 bazel/test/python_test_repo/helloworld.py create mode 120000 bazel/test/python_test_repo/tools/bazel create mode 100644 third_party/enum34.BUILD create mode 100644 third_party/futures.BUILD create mode 100644 third_party/six.BUILD diff --git a/WORKSPACE b/WORKSPACE index 60582d1a0f5..a9a8cfbba1b 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -18,33 +18,6 @@ register_toolchains( "//third_party/toolchains/bazel_0.23.2_rbe_windows:cc-toolchain-x64_windows", ) -git_repository( - name = "io_bazel_rules_python", - commit = "fdbb17a4118a1728d19e638a5291b4c4266ea5b8", - remote = "https://github.com/bazelbuild/rules_python.git", -) - -load("@io_bazel_rules_python//python:pip.bzl", "pip_repositories", "pip_import") - -pip_import( - name = "grpc_python_dependencies", - requirements = "//:requirements.bazel.txt", -) - -http_archive( - name = "cython", - build_file = "//third_party:cython.BUILD", - sha256 = "d68138a2381afbdd0876c3cb2a22389043fa01c4badede1228ee073032b07a27", - strip_prefix = "cython-c2b80d87658a8525ce091cbe146cb7eaa29fed5c", - urls = [ - "https://github.com/cython/cython/archive/c2b80d87658a8525ce091cbe146cb7eaa29fed5c.tar.gz", - ], -) - -load("//bazel:grpc_python_deps.bzl", "grpc_python_deps") - -grpc_python_deps() - load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig") # Create toolchain configuration for remote execution. @@ -65,3 +38,19 @@ rbe_autoconfig( }, ), ) + +load("@com_github_grpc_grpc//bazel:grpc_python_deps.bzl", "grpc_python_deps") +grpc_python_deps() + + +load("@io_bazel_rules_python//python:pip.bzl", "pip_repositories", "pip_import") + +pip_import( + name = "grpc_python_dependencies", + requirements = "@com_github_grpc_grpc//:requirements.bazel.txt", +) + +load("@io_bazel_rules_python//python:pip.bzl", "pip_repositories") +load("@grpc_python_dependencies//:requirements.bzl", "pip_install") +pip_repositories() +pip_install() diff --git a/bazel/grpc_python_deps.bzl b/bazel/grpc_python_deps.bzl index 91438f3927b..4e7cc1537fa 100644 --- a/bazel/grpc_python_deps.bzl +++ b/bazel/grpc_python_deps.bzl @@ -1,8 +1,67 @@ -load("//third_party/py:python_configure.bzl", "python_configure") -load("@io_bazel_rules_python//python:pip.bzl", "pip_repositories") -load("@grpc_python_dependencies//:requirements.bzl", "pip_install") +"""Load dependencies needed to compile and test the grpc python library as a 3rd-party consumer.""" + +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@com_github_grpc_grpc//third_party/py:python_configure.bzl", "python_configure") def grpc_python_deps(): + native.bind( + name = "six", + actual = "@six_archive//:six", + ) + + # protobuf binds to the name "six", so we can't use it here. + # See https://github.com/bazelbuild/bazel/issues/1952 for why bind is + # horrible. + if "six_archive" not in native.existing_rules(): + http_archive( + name = "six_archive", + strip_prefix = "six-1.12.0", + build_file = "@com_github_grpc_grpc//third_party:six.BUILD", + sha256 = "d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73", + urls = ["https://files.pythonhosted.org/packages/dd/bf/4138e7bfb757de47d1f4b6994648ec67a51efe58fa907c1e11e350cddfca/six-1.12.0.tar.gz"], + ) + + if "enum34" not in native.existing_rules(): + http_archive( + name = "enum34", + build_file = "@com_github_grpc_grpc//third_party:enum34.BUILD", + strip_prefix = "enum34-1.1.6", + sha256 = "8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1", + urls = ["https://files.pythonhosted.org/packages/bf/3e/31d502c25302814a7c2f1d3959d2a3b3f78e509002ba91aea64993936876/enum34-1.1.6.tar.gz"], + ) + + if "futures" not in native.existing_rules(): + http_archive( + name = "futures", + build_file = "@com_github_grpc_grpc//third_party:futures.BUILD", + strip_prefix = "futures-3.3.0", + sha256 = "7e033af76a5e35f58e56da7a91e687706faf4e7bdfb2cbc3f2cca6b9bcda9794", + urls = ["https://files.pythonhosted.org/packages/47/04/5fc6c74ad114032cd2c544c575bffc17582295e9cd6a851d6026ab4b2c00/futures-3.3.0.tar.gz"], + ) + + if "io_bazel_rules_python" not in native.existing_rules(): + git_repository( + name = "io_bazel_rules_python", + commit = "fdbb17a4118a1728d19e638a5291b4c4266ea5b8", + remote = "https://github.com/bazelbuild/rules_python.git", + ) + python_configure(name = "local_config_python") - pip_repositories() - pip_install() + + native.bind( + name = "python_headers", + actual = "@local_config_python//:python_headers", + ) + + if "cython" not in native.existing_rules(): + http_archive( + name = "cython", + build_file = "@com_github_grpc_grpc//third_party:cython.BUILD", + sha256 = "d68138a2381afbdd0876c3cb2a22389043fa01c4badede1228ee073032b07a27", + strip_prefix = "cython-c2b80d87658a8525ce091cbe146cb7eaa29fed5c", + urls = [ + "https://github.com/cython/cython/archive/c2b80d87658a8525ce091cbe146cb7eaa29fed5c.tar.gz", + ], + ) + diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index 14550852a4a..eb4ac9c9721 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -1,6 +1,5 @@ """Generates and compiles Python gRPC stubs from proto_library rules.""" -load("@grpc_python_dependencies//:requirements.bzl", "requirement") load( "//bazel:protobuf.bzl", "get_include_protoc_args", @@ -36,34 +35,115 @@ def _generate_py_impl(context): for file in src[ProtoInfo].transitive_imports.to_list() ] proto_root = get_proto_root(context.label.workspace_root) - format_str = (_GENERATED_GRPC_PROTO_FORMAT if context.executable.plugin else _GENERATED_PROTO_FORMAT) out_files = [ context.actions.declare_file( proto_path_to_generated_filename( proto.basename, - format_str, + _GENERATED_PROTO_FORMAT, + ), + ) + for proto in protos + ] + + tools = [context.executable._protoc] + arguments = ([ + "--python_out={}".format( + context.genfiles_dir.path, + ), + ] + get_include_protoc_args(includes) + [ + "--proto_path={}".format(context.genfiles_dir.path) + for proto in protos + ]) + for proto in protos: + massaged_path = proto.path + if massaged_path.startswith(context.genfiles_dir.path): + massaged_path = proto.path[len(context.genfiles_dir.path) + 1:] + arguments.append(massaged_path) + + context.actions.run( + inputs = protos + includes, + tools = tools, + outputs = out_files, + executable = context.executable._protoc, + arguments = arguments, + mnemonic = "ProtocInvocation", + ) + return struct(files = depset(out_files)) + +_generate_pb2_src = rule( + attrs = { + "deps": attr.label_list( + mandatory = True, + allow_empty = False, + providers = [ProtoInfo], + ), + "_protoc": attr.label( + default = Label("//external:protocol_compiler"), + providers = ["files_to_run"], + executable = True, + cfg = "host", + ), + }, + implementation = _generate_py_impl, +) + +def py_proto_library( + name, + srcs, + **kwargs): + """Generate python code for a protobuf. + + Args: + name: The name of the target. + srcs: A list of proto_library dependencies. Must contain a single element. + """ + codegen_target = "_{}_codegen".format(name) + if len(srcs) > 1: + fail("Can only compile a single proto at a time.") + + + _generate_pb2_src( + name = codegen_target, + deps = srcs, + **kwargs + ) + + native.py_library( + name = name, + srcs = [":{}".format(codegen_target)], + deps = ["@com_google_protobuf//:protobuf_python"], + **kwargs + ) + +def _generate_pb2_grpc_src_impl(context): + protos = [] + for src in context.attr.deps: + for file in src[ProtoInfo].direct_sources: + protos.append(_get_staged_proto_file(context, file)) + includes = [ + file + for src in context.attr.deps + for file in src[ProtoInfo].transitive_imports.to_list() + ] + proto_root = get_proto_root(context.label.workspace_root) + out_files = [ + context.actions.declare_file( + proto_path_to_generated_filename( + proto.basename, + _GENERATED_GRPC_PROTO_FORMAT, ), ) for proto in protos ] arguments = [] - tools = [context.executable._protoc] - if context.executable.plugin: - arguments += get_plugin_args( - context.executable.plugin, - context.attr.flags, - context.genfiles_dir.path, - False, - ) - tools += [context.executable.plugin] - else: - arguments += [ - "--python_out={}:{}".format( - ",".join(context.attr.flags), - context.genfiles_dir.path, - ), - ] + tools = [context.executable._protoc, context.executable._plugin] + arguments += get_plugin_args( + context.executable._plugin, + [], + context.genfiles_dir.path, + False, + ) arguments += get_include_protoc_args(includes) arguments += [ @@ -76,16 +156,8 @@ def _generate_py_impl(context): massaged_path = proto.path[len(context.genfiles_dir.path) + 1:] arguments.append(massaged_path) - well_known_proto_files = [] - if context.attr.well_known_protos: - well_known_proto_directory = context.attr.well_known_protos.files.to_list( - )[0].dirname - - arguments += ["-I{}".format(well_known_proto_directory + "/../..")] - well_known_proto_files = context.attr.well_known_protos.files.to_list() - context.actions.run( - inputs = protos + includes + well_known_proto_files, + inputs = protos + includes, tools = tools, outputs = out_files, executable = context.executable._protoc, @@ -94,93 +166,59 @@ def _generate_py_impl(context): ) return struct(files = depset(out_files)) -__generate_py = rule( + +_generate_pb2_grpc_src = rule( attrs = { "deps": attr.label_list( mandatory = True, allow_empty = False, providers = [ProtoInfo], ), - "plugin": attr.label( + "_plugin": attr.label( executable = True, providers = ["files_to_run"], cfg = "host", + default = Label("//src/compiler:grpc_python_plugin"), ), - "flags": attr.string_list( - mandatory = False, - allow_empty = True, - ), - "well_known_protos": attr.label(mandatory = False), "_protoc": attr.label( - default = Label("//external:protocol_compiler"), executable = True, + providers = ["files_to_run"], cfg = "host", + default = Label("//external:protocol_compiler"), ), }, - output_to_genfiles = True, - implementation = _generate_py_impl, + implementation = _generate_pb2_grpc_src_impl, ) -def _generate_py(well_known_protos, **kwargs): - if well_known_protos: - __generate_py( - well_known_protos = "@com_google_protobuf//:well_known_protos", - **kwargs - ) - else: - __generate_py(**kwargs) - -def py_proto_library( - name, - deps, - well_known_protos = True, - proto_only = False, - **kwargs): - """Generate python code for a protobuf. +def py_grpc_library( + name, + srcs, + deps, + **kwargs): + """Generate python code for gRPC services defined in a protobuf. Args: name: The name of the target. - deps: A list of dependencies. Must contain a single element. - well_known_protos: A bool indicating whether or not to include well-known - protos. - proto_only: A bool indicating whether to generate vanilla protobuf code - or to also generate gRPC code. + srcs: (List of `labels`) a single proto_library target containing the + schema of the service. + deps: (List of `labels`) a single py_proto_library target for the + proto_library in `srcs`. """ - if len(deps) > 1: - fail("The supported length of 'deps' is 1.") - - codegen_target = "_{}_codegen".format(name) codegen_grpc_target = "_{}_grpc_codegen".format(name) + if len(srcs) > 1: + fail("Can only compile a single proto at a time.") - _generate_py( - name = codegen_target, - deps = deps, - well_known_protos = well_known_protos, + _generate_pb2_grpc_src( + name = codegen_grpc_target, + deps = srcs, **kwargs ) - if not proto_only: - _generate_py( - name = codegen_grpc_target, - deps = deps, - plugin = "//src/compiler:grpc_python_plugin", - well_known_protos = well_known_protos, - **kwargs - ) - - native.py_library( - name = name, - srcs = [ - ":{}".format(codegen_grpc_target), - ":{}".format(codegen_target), - ], - deps = [requirement("protobuf")], - **kwargs - ) - else: - native.py_library( - name = name, - srcs = [":{}".format(codegen_target), ":{}".format(codegen_target)], - deps = [requirement("protobuf")], - **kwargs - ) + native.py_library( + name = name, + srcs = [ + ":{}".format(codegen_grpc_target), + ], + deps = [Label("//src/python/grpcio/grpc:grpcio")] + deps, + **kwargs + ) diff --git a/bazel/test/python_test_repo/.gitignore b/bazel/test/python_test_repo/.gitignore new file mode 100644 index 00000000000..7146a250705 --- /dev/null +++ b/bazel/test/python_test_repo/.gitignore @@ -0,0 +1,2 @@ +bazel-* +tools/bazel-* diff --git a/bazel/test/python_test_repo/BUILD b/bazel/test/python_test_repo/BUILD new file mode 100644 index 00000000000..ed4ffd3b74f --- /dev/null +++ b/bazel/test/python_test_repo/BUILD @@ -0,0 +1,46 @@ +load("@com_github_grpc_grpc//bazel:python_rules.bzl", "py_proto_library", "py_grpc_library") + +package(default_testonly = 1) + +proto_library( + name = "helloworld_proto", + srcs = ["helloworld.proto"], + deps = [ + "@com_google_protobuf//:duration_proto", + "@com_google_protobuf//:timestamp_proto", + ], +) + +py_proto_library( + name = "helloworld_py_pb2", + srcs = [":helloworld_proto"], +) + +py_grpc_library( + name = "helloworld_py_pb2_grpc", + srcs = [":helloworld_proto"], + deps = [":helloworld_py_pb2"], +) + +py_proto_library( + name = "duration_py_pb2", + srcs = ["@com_google_protobuf//:duration_proto"], +) + +py_proto_library( + name = "timestamp_py_pb2", + srcs = ["@com_google_protobuf//:timestamp_proto"], +) + +py_test( + name = "import_test", + main = "helloworld.py", + srcs = ["helloworld.py"], + deps = [ + ":helloworld_py_pb2", + ":helloworld_py_pb2_grpc", + ":duration_py_pb2", + ":timestamp_py_pb2", + ], + python_version = "PY3", +) diff --git a/bazel/test/python_test_repo/WORKSPACE b/bazel/test/python_test_repo/WORKSPACE new file mode 100644 index 00000000000..69d34ac933c --- /dev/null +++ b/bazel/test/python_test_repo/WORKSPACE @@ -0,0 +1,10 @@ +local_repository( + name = "com_github_grpc_grpc", + path = "../../..", +) + +load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") +grpc_deps() + +load("@com_github_grpc_grpc//bazel:grpc_python_deps.bzl", "grpc_python_deps") +grpc_python_deps() diff --git a/bazel/test/python_test_repo/helloworld.proto b/bazel/test/python_test_repo/helloworld.proto new file mode 100644 index 00000000000..b333a7409b8 --- /dev/null +++ b/bazel/test/python_test_repo/helloworld.proto @@ -0,0 +1,43 @@ +// Copyright 2019 The gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +option java_multiple_files = true; +option java_package = "io.grpc.examples.helloworld"; +option java_outer_classname = "HelloWorldProto"; +option objc_class_prefix = "HLW"; + +package helloworld; + +import "google/protobuf/timestamp.proto"; +import "google/protobuf/duration.proto"; + +// The greeting service definition. +service Greeter { + // Sends a greeting + rpc SayHello (HelloRequest) returns (HelloReply) {} +} + +// The request message containing the user's name. +message HelloRequest { + string name = 1; + google.protobuf.Timestamp request_initiation = 2; +} + +// The response message containing the greetings +message HelloReply { + string message = 1; + google.protobuf.Duration request_duration = 2; +} diff --git a/bazel/test/python_test_repo/helloworld.py b/bazel/test/python_test_repo/helloworld.py new file mode 100644 index 00000000000..deee36a8f71 --- /dev/null +++ b/bazel/test/python_test_repo/helloworld.py @@ -0,0 +1,73 @@ +# Copyright 2019 the gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""The Python implementation of the GRPC helloworld.Greeter client.""" + +import contextlib +import datetime +import logging +import unittest + +import grpc + +import duration_pb2 +import helloworld_pb2 +import helloworld_pb2_grpc + +_HOST = 'localhost' +_SERVER_ADDRESS = '{}:0'.format(_HOST) + + +class Greeter(helloworld_pb2_grpc.GreeterServicer): + + def SayHello(self, request, context): + request_in_flight = datetime.now() - request.request_initation.ToDatetime() + request_duration = duration_pb2.Duration() + request_duration.FromTimedelta(request_in_flight) + return helloworld_pb2.HelloReply( + message='Hello, %s!' % request.name, + request_duration=request_duration, + ) + + +@contextlib.contextmanager +def _listening_server(): + server = grpc.server(futures.ThreadPoolExecutor()) + helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server) + port = server.add_insecure_port(_SERVER_ADDRESS) + server.start() + try: + yield port + finally: + server.stop(0) + + +class ImportTest(unittest.TestCase): + def run(): + with _listening_server() as port: + with grpc.insecure_channel('{}:{}'.format(_HOST, port)) as channel: + stub = helloworld_pb2_grpc.GreeterStub(channel) + request_timestamp = timestamp_pb2.Timestamp() + request_timestamp.GetCurrentTime() + response = stub.SayHello(helloworld_pb2.HelloRequest( + name='you', + request_initiation=request_timestamp, + ), + wait_for_ready=True) + self.assertEqual(response.message, "Hello, you!") + self.assertGreater(response.request_duration.microseconds, 0) + + +if __name__ == '__main__': + logging.basicConfig() + unittest.main() diff --git a/bazel/test/python_test_repo/tools/bazel b/bazel/test/python_test_repo/tools/bazel new file mode 120000 index 00000000000..ad4a1267bcd --- /dev/null +++ b/bazel/test/python_test_repo/tools/bazel @@ -0,0 +1 @@ +../../../../tools/bazel \ No newline at end of file diff --git a/examples/BUILD b/examples/BUILD index a9dd94902a4..b3c5d0a825c 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -18,7 +18,8 @@ package(default_visibility = ["//visibility:public"]) load("//bazel:grpc_build_system.bzl", "grpc_proto_library") load("//bazel:cc_grpc_library.bzl", "cc_grpc_library") -load("//bazel:python_rules.bzl", "py_proto_library") +load("//bazel:python_rules.bzl", "py_proto_library", "py_grpc_library") +load("@grpc_python_dependencies//:requirements.bzl", "requirement") grpc_proto_library( name = "auth_sample", @@ -60,13 +61,20 @@ grpc_proto_library( ) proto_library( - name = "helloworld_proto_descriptor", + name = "protos/helloworld_proto", srcs = ["protos/helloworld.proto"], ) py_proto_library( - name = "py_helloworld", - deps = [":helloworld_proto_descriptor"], + name = "helloworld_py_pb2", + srcs = [":protos/helloworld_proto"], + deps = [requirement('protobuf')], +) + +py_grpc_library( + name = "helloworld_py_pb2_grpc", + srcs = [":protos/helloworld_proto"], + deps = [":helloworld_py_pb2"], ) cc_binary( diff --git a/examples/python/multiprocessing/BUILD b/examples/python/multiprocessing/BUILD index f9fa6598068..257523f14bb 100644 --- a/examples/python/multiprocessing/BUILD +++ b/examples/python/multiprocessing/BUILD @@ -14,8 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@grpc_python_dependencies//:requirements.bzl", "requirement") -load("//bazel:python_rules.bzl", "py_proto_library") +load("//bazel:python_rules.bzl", "py_proto_library", "py_grpc_library") proto_library( name = "prime_proto", @@ -24,8 +23,13 @@ proto_library( py_proto_library( name = "prime_proto_pb2", - deps = [":prime_proto"], - well_known_protos = False, + srcs = [":prime_proto"], +) + +py_grpc_library( + name = "prime_proto_pb2_grpc", + srcs = [":prime_proto"], + deps = [":prime_proto_pb2"], ) py_binary( @@ -35,6 +39,7 @@ py_binary( deps = [ "//src/python/grpcio/grpc:grpcio", ":prime_proto_pb2", + ":prime_proto_pb2_grpc", ], srcs_version = "PY3", ) @@ -45,9 +50,10 @@ py_binary( srcs = ["server.py"], deps = [ "//src/python/grpcio/grpc:grpcio", - ":prime_proto_pb2" + ":prime_proto_pb2", + ":prime_proto_pb2_grpc", ] + select({ - "//conditions:default": [requirement("futures")], + "//conditions:default": ["@futures//:futures"], "//:python3": [], }), srcs_version = "PY3", diff --git a/examples/python/wait_for_ready/BUILD.bazel b/examples/python/wait_for_ready/BUILD.bazel index 70daf83d334..f074ae7bb7f 100644 --- a/examples/python/wait_for_ready/BUILD.bazel +++ b/examples/python/wait_for_ready/BUILD.bazel @@ -20,7 +20,8 @@ py_library( srcs = ["wait_for_ready_example.py"], deps = [ "//src/python/grpcio/grpc:grpcio", - "//examples:py_helloworld", + "//examples:helloworld_py_pb2", + "//examples:helloworld_py_pb2_grpc", ], ) diff --git a/src/proto/grpc/channelz/BUILD b/src/proto/grpc/channelz/BUILD index 1d80ec23af1..5d1ec5a60cb 100644 --- a/src/proto/grpc/channelz/BUILD +++ b/src/proto/grpc/channelz/BUILD @@ -27,7 +27,15 @@ grpc_proto_library( proto_library( name = "channelz_proto_descriptors", - srcs = ["channelz.proto"], + srcs = [ + "channelz.proto", + ], + deps = [ + "@com_google_protobuf//:any_proto", + "@com_google_protobuf//:duration_proto", + "@com_google_protobuf//:timestamp_proto", + "@com_google_protobuf//:wrappers_proto", + ], ) filegroup( diff --git a/src/proto/grpc/testing/BUILD b/src/proto/grpc/testing/BUILD index 212f0f3cca7..15be8227de1 100644 --- a/src/proto/grpc/testing/BUILD +++ b/src/proto/grpc/testing/BUILD @@ -16,7 +16,7 @@ licenses(["notice"]) # Apache v2 load("//bazel:grpc_build_system.bzl", "grpc_proto_library", "grpc_package") load("@grpc_python_dependencies//:requirements.bzl", "requirement") -load("//bazel:python_rules.bzl", "py_proto_library") +load("//bazel:python_rules.bzl", "py_proto_library", "py_grpc_library") grpc_package( name = "testing", @@ -75,8 +75,14 @@ proto_library( ) py_proto_library( - name = "py_empty_proto", - deps = [":empty_proto_descriptor"], + name = "empty_py_pb2", + srcs = [":empty_proto_descriptor"], +) + +py_grpc_library( + name = "empty_py_pb2_grpc", + srcs = [":empty_proto_descriptor"], + deps = [":empty_py_pb2"], ) grpc_proto_library( @@ -92,7 +98,13 @@ proto_library( py_proto_library( name = "py_messages_proto", - deps = [":messages_proto_descriptor"], + srcs = [":messages_proto_descriptor"], +) + +py_grpc_library( + name = "messages_py_pb2_grpc", + srcs = [":messages_proto_descriptor"], + deps = [":py_messages_proto"], ) grpc_proto_library( @@ -196,7 +208,12 @@ proto_library( py_proto_library( name = "py_test_proto", - deps = [ - ":test_proto_descriptor", - ], + srcs = [":test_proto_descriptor"], ) + +py_grpc_library( + name = "test_py_pb2_grpc", + srcs = [":test_proto_descriptor"], + deps = [":py_test_proto"], +) + diff --git a/src/proto/grpc/testing/proto2/BUILD.bazel b/src/proto/grpc/testing/proto2/BUILD.bazel index e939c523a64..668d0a484ea 100644 --- a/src/proto/grpc/testing/proto2/BUILD.bazel +++ b/src/proto/grpc/testing/proto2/BUILD.bazel @@ -10,9 +10,7 @@ proto_library( py_proto_library( name = "empty2_proto", - deps = [ - ":empty2_proto_descriptor", - ], + srcs = [":empty2_proto_descriptor"], ) proto_library( @@ -25,8 +23,6 @@ proto_library( py_proto_library( name = "empty2_extensions_proto", - deps = [ - ":empty2_extensions_proto_descriptor", - ], + srcs = [":empty2_extensions_proto_descriptor"], ) diff --git a/src/python/grpcio/grpc/BUILD.bazel b/src/python/grpcio/grpc/BUILD.bazel index a2bedae4bea..1b5a018249a 100644 --- a/src/python/grpcio/grpc/BUILD.bazel +++ b/src/python/grpcio/grpc/BUILD.bazel @@ -1,5 +1,3 @@ -load("@grpc_python_dependencies//:requirements.bzl", "requirement") - package(default_visibility = ["//visibility:public"]) py_library( @@ -16,9 +14,9 @@ py_library( "//src/python/grpcio/grpc/_cython:cygrpc", "//src/python/grpcio/grpc/experimental", "//src/python/grpcio/grpc/framework", - requirement('six'), + "@six_archive//:six", ] + select({ - "//conditions:default": [requirement('enum34'),], + "//conditions:default": ["@enum34//:enum34",], "//:python3": [], }), data = [ diff --git a/src/python/grpcio/grpc/experimental/BUILD.bazel b/src/python/grpcio/grpc/experimental/BUILD.bazel index 6598d02747b..cd8afe533b6 100644 --- a/src/python/grpcio/grpc/experimental/BUILD.bazel +++ b/src/python/grpcio/grpc/experimental/BUILD.bazel @@ -1,4 +1,3 @@ -load("@grpc_python_dependencies//:requirements.bzl", "requirement") package(default_visibility = ["//visibility:public"]) py_library( diff --git a/src/python/grpcio/grpc/framework/common/BUILD.bazel b/src/python/grpcio/grpc/framework/common/BUILD.bazel index 52fbb2b516c..c0d1486d537 100644 --- a/src/python/grpcio/grpc/framework/common/BUILD.bazel +++ b/src/python/grpcio/grpc/framework/common/BUILD.bazel @@ -1,4 +1,3 @@ -load("@grpc_python_dependencies//:requirements.bzl", "requirement") package(default_visibility = ["//visibility:public"]) py_library( @@ -14,7 +13,7 @@ py_library( name = "cardinality", srcs = ["cardinality.py"], deps = select({ - "//conditions:default": [requirement('enum34'),], + "//conditions:default": ["@enum34//:enum34",], "//:python3": [], }), ) @@ -23,7 +22,7 @@ py_library( name = "style", srcs = ["style.py"], deps = select({ - "//conditions:default": [requirement('enum34'),], + "//conditions:default": ["@enum34//:enum34",], "//:python3": [], }), ) diff --git a/src/python/grpcio/grpc/framework/foundation/BUILD.bazel b/src/python/grpcio/grpc/framework/foundation/BUILD.bazel index a447ecded49..b539fa46da7 100644 --- a/src/python/grpcio/grpc/framework/foundation/BUILD.bazel +++ b/src/python/grpcio/grpc/framework/foundation/BUILD.bazel @@ -1,4 +1,3 @@ -load("@grpc_python_dependencies//:requirements.bzl", "requirement") package(default_visibility = ["//visibility:public"]) py_library( @@ -23,9 +22,9 @@ py_library( name = "callable_util", srcs = ["callable_util.py"], deps = [ - requirement("six"), + "//external:six", ] + select({ - "//conditions:default": [requirement('enum34'),], + "//conditions:default": ["@enum34//:enum34",], "//:python3": [], }), ) @@ -34,7 +33,7 @@ py_library( name = "future", srcs = ["future.py"], deps = [ - requirement("six"), + "//external:six", ], ) @@ -42,7 +41,7 @@ py_library( name = "logging_pool", srcs = ["logging_pool.py"], deps = select({ - "//conditions:default": [requirement('futures'),], + "//conditions:default": ["@futures//:futures",], "//:python3": [], }), ) @@ -59,6 +58,6 @@ py_library( name = "stream", srcs = ["stream.py"], deps = [ - requirement("six"), + "//external:six", ], ) diff --git a/src/python/grpcio/grpc/framework/interfaces/base/BUILD.bazel b/src/python/grpcio/grpc/framework/interfaces/base/BUILD.bazel index 35cfe877f34..5d0c06950a8 100644 --- a/src/python/grpcio/grpc/framework/interfaces/base/BUILD.bazel +++ b/src/python/grpcio/grpc/framework/interfaces/base/BUILD.bazel @@ -1,4 +1,3 @@ -load("@grpc_python_dependencies//:requirements.bzl", "requirement") package(default_visibility = ["//visibility:public"]) py_library( @@ -15,9 +14,9 @@ py_library( srcs = ["base.py"], deps = [ "//src/python/grpcio/grpc/framework/foundation:abandonment", - requirement("six"), + "//external:six", ] + select({ - "//conditions:default": [requirement('enum34'),], + "//conditions:default": ["@enum34//:enum34",], "//:python3": [], }), ) @@ -26,7 +25,7 @@ py_library( name = "utilities", srcs = ["utilities.py"], deps = select({ - "//conditions:default": [requirement('enum34'),], + "//conditions:default": ["@enum34//:enum34",], "//:python3": [], }), ) diff --git a/src/python/grpcio/grpc/framework/interfaces/face/BUILD.bazel b/src/python/grpcio/grpc/framework/interfaces/face/BUILD.bazel index 83fadb6372e..3af1404eade 100644 --- a/src/python/grpcio/grpc/framework/interfaces/face/BUILD.bazel +++ b/src/python/grpcio/grpc/framework/interfaces/face/BUILD.bazel @@ -1,4 +1,3 @@ -load("@grpc_python_dependencies//:requirements.bzl", "requirement") package(default_visibility = ["//visibility:public"]) py_library( @@ -16,9 +15,9 @@ py_library( deps = [ "//src/python/grpcio/grpc/framework/foundation", "//src/python/grpcio/grpc/framework/common", - requirement("six"), + "//external:six", ] + select({ - "//conditions:default": [requirement('enum34'),], + "//conditions:default": ["@enum34//:enum34",], "//:python3": [], }), ) diff --git a/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel b/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel index eccc166577d..c0a7e3d3026 100644 --- a/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel +++ b/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel @@ -1,17 +1,23 @@ -load("//bazel:python_rules.bzl", "py_proto_library") +load("//bazel:python_rules.bzl", "py_proto_library", "py_grpc_library") package(default_visibility = ["//visibility:public"]) py_proto_library( - name = "py_channelz_proto", - well_known_protos = True, - deps = ["//src/proto/grpc/channelz:channelz_proto_descriptors"], + name = "channelz_py_pb2", + srcs = ["//src/proto/grpc/channelz:channelz_proto_descriptors"], +) + +py_grpc_library( + name = "channelz_py_pb2_grpc", + srcs = ["//src/proto/grpc/channelz:channelz_proto_descriptors"], + deps = [":channelz_py_pb2"], ) py_library( name = "grpc_channelz", srcs = ["channelz.py",], deps = [ - ":py_channelz_proto", + ":channelz_py_pb2", + ":channelz_py_pb2_grpc", "//src/python/grpcio/grpc:grpcio", ], imports=["../../",], diff --git a/src/python/grpcio_channelz/grpc_channelz/v1/channelz.py b/src/python/grpcio_channelz/grpc_channelz/v1/channelz.py index 00eca311dc1..18810cab290 100644 --- a/src/python/grpcio_channelz/grpc_channelz/v1/channelz.py +++ b/src/python/grpcio_channelz/grpc_channelz/v1/channelz.py @@ -16,8 +16,12 @@ import grpc from grpc._cython import cygrpc -import grpc_channelz.v1.channelz_pb2 as _channelz_pb2 -import grpc_channelz.v1.channelz_pb2_grpc as _channelz_pb2_grpc +try: + from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2 as _channelz_pb2 + from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2_grpc as _channelz_pb2_grpc +except ImportError: + import grpc_channelz.v1.channelz_pb2 as _channelz_pb2 + import grpc_channelz.v1.channelz_pb2_grpc as _channelz_pb2_grpc from google.protobuf import json_format diff --git a/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel b/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel index 9e4fff34581..0ee176f0506 100644 --- a/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel +++ b/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel @@ -1,16 +1,23 @@ -load("//bazel:python_rules.bzl", "py_proto_library") +load("//bazel:python_rules.bzl", "py_proto_library", "py_grpc_library") package(default_visibility = ["//visibility:public"]) py_proto_library( - name = "py_health_proto", - deps = ["//src/proto/grpc/health/v1:health_proto_descriptor",], + name = "health_py_pb2", + srcs = ["//src/proto/grpc/health/v1:health_proto_descriptor",], +) + +py_grpc_library( + name = "health_py_pb2_grpc", + srcs = ["//src/proto/grpc/health/v1:health_proto_descriptor",], + deps = [":health_py_pb2"], ) py_library( name = "grpc_health", srcs = ["health.py",], deps = [ - ":py_health_proto", + ":health_py_pb2", + ":health_py_pb2_grpc", "//src/python/grpcio/grpc:grpcio", ], imports=["../../",], diff --git a/src/python/grpcio_health_checking/grpc_health/v1/health.py b/src/python/grpcio_health_checking/grpc_health/v1/health.py index 15494fafdbc..93c1895df4c 100644 --- a/src/python/grpcio_health_checking/grpc_health/v1/health.py +++ b/src/python/grpcio_health_checking/grpc_health/v1/health.py @@ -18,8 +18,13 @@ import threading import grpc -from grpc_health.v1 import health_pb2 as _health_pb2 -from grpc_health.v1 import health_pb2_grpc as _health_pb2_grpc +# Import using an absolute path to ensure no duplicate loaded modules. +try: + from src.python.grpcio_health_checking.grpc_health.v1 import health_pb2 as _health_pb2 + from src.python.grpcio_health_checking.grpc_health.v1 import health_pb2_grpc as _health_pb2_grpc +except ImportError: + from grpc_health.v1 import health_pb2 as _health_pb2 + from grpc_health.v1 import health_pb2_grpc as _health_pb2_grpc SERVICE_NAME = _health_pb2.DESCRIPTOR.services_by_name['Health'].full_name diff --git a/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel b/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel index 6aaa4dd3bdd..49bc517caf1 100644 --- a/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel +++ b/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel @@ -1,20 +1,27 @@ -load("//bazel:python_rules.bzl", "py_proto_library") +load("//bazel:python_rules.bzl", "py_proto_library", "py_grpc_library") load("@grpc_python_dependencies//:requirements.bzl", "requirement") package(default_visibility = ["//visibility:public"]) py_proto_library( - name = "py_reflection_proto", - deps = ["//src/proto/grpc/reflection/v1alpha:reflection_proto_descriptor",], + name = "reflection_py_pb2", + srcs = ["//src/proto/grpc/reflection/v1alpha:reflection_proto_descriptor",], +) + +py_grpc_library( + name = "reflection_py_pb2_grpc", + srcs = ["//src/proto/grpc/reflection/v1alpha:reflection_proto_descriptor",], + deps = ["reflection_py_pb2"], ) py_library( name = "grpc_reflection", srcs = ["reflection.py",], deps = [ - ":py_reflection_proto", + ":reflection_py_pb2", + ":reflection_py_pb2_grpc", "//src/python/grpcio/grpc:grpcio", - requirement('protobuf'), + "@com_google_protobuf//:protobuf_python", ], imports=["../../",], ) diff --git a/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py b/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py index 6df1a364269..70c506c1c7d 100644 --- a/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py +++ b/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py @@ -17,8 +17,12 @@ import grpc from google.protobuf import descriptor_pb2 from google.protobuf import descriptor_pool -from grpc_reflection.v1alpha import reflection_pb2 as _reflection_pb2 -from grpc_reflection.v1alpha import reflection_pb2_grpc as _reflection_pb2_grpc +try: + from src.python.grpcio_reflection.grpc_reflection.v1alpha import reflection_pb2 as _reflection_pb2 + from src.python.grpcio_reflection.grpc_reflection.v1alpha import reflection_pb2_grpc as _reflection_pb2_grpc +except ImportError: + from grpc_reflection.v1alpha import reflection_pb2 as _reflection_pb2 + from grpc_reflection.v1alpha import reflection_pb2_grpc as _reflection_pb2_grpc _POOL = descriptor_pool.Default() SERVICE_NAME = _reflection_pb2.DESCRIPTOR.services_by_name[ diff --git a/src/python/grpcio_status/grpc_status/BUILD.bazel b/src/python/grpcio_status/grpc_status/BUILD.bazel index 223a077c3f2..a7d47c9f34e 100644 --- a/src/python/grpcio_status/grpc_status/BUILD.bazel +++ b/src/python/grpcio_status/grpc_status/BUILD.bazel @@ -7,7 +7,7 @@ py_library( srcs = ["rpc_status.py",], deps = [ "//src/python/grpcio/grpc:grpcio", - requirement('protobuf'), + "@com_google_protobuf//:protobuf_python", requirement('googleapis-common-protos'), ], imports=["../",], diff --git a/src/python/grpcio_tests/tests/channelz/_channelz_servicer_test.py b/src/python/grpcio_tests/tests/channelz/_channelz_servicer_test.py index 5265911a0be..bfe184107ec 100644 --- a/src/python/grpcio_tests/tests/channelz/_channelz_servicer_test.py +++ b/src/python/grpcio_tests/tests/channelz/_channelz_servicer_test.py @@ -18,9 +18,14 @@ import unittest from concurrent import futures import grpc -from grpc_channelz.v1 import channelz -from grpc_channelz.v1 import channelz_pb2 -from grpc_channelz.v1 import channelz_pb2_grpc +try: + from src.python.grpcio_channelz.grpc_channelz.v1 import channelz + from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2 + from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2_grpc +except ImportError: + from grpc_channelz.v1 import channelz + from grpc_channelz.v1 import channelz_pb2 + from grpc_channelz.v1 import channelz_pb2_grpc from tests.unit import test_common from tests.unit.framework.common import test_constants diff --git a/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py b/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py index 7a332b8390f..91e841a4d60 100644 --- a/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py +++ b/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py @@ -13,14 +13,22 @@ # limitations under the License. """Tests of grpc_health.v1.health.""" +import logging import threading import time import unittest import grpc -from grpc_health.v1 import health -from grpc_health.v1 import health_pb2 -from grpc_health.v1 import health_pb2_grpc + +# Import using an absolute path to ensure no duplicate loaded modules. +try: + from src.python.grpcio_health_checking.grpc_health.v1 import health + from src.python.grpcio_health_checking.grpc_health.v1 import health_pb2 + from src.python.grpcio_health_checking.grpc_health.v1 import health_pb2_grpc +except ImportError: + from grpc_health.v1 import health + from grpc_health.v1 import health_pb2 + from grpc_health.v1 import health_pb2_grpc from tests.unit import test_common from tests.unit import thread_pool @@ -276,4 +284,5 @@ class HealthServicerBackwardsCompatibleWatchTest(BaseWatchTests.WatchTests): if __name__ == '__main__': + logging.basicConfig() unittest.main(verbosity=2) diff --git a/src/python/grpcio_tests/tests/interop/BUILD.bazel b/src/python/grpcio_tests/tests/interop/BUILD.bazel index fd636556074..43fdc7ab462 100644 --- a/src/python/grpcio_tests/tests/interop/BUILD.bazel +++ b/src/python/grpcio_tests/tests/interop/BUILD.bazel @@ -31,9 +31,12 @@ py_library( deps = [ "//src/python/grpcio/grpc:grpcio", "//src/python/grpcio_tests/tests:bazel_namespace_package_hack", - "//src/proto/grpc/testing:py_empty_proto", + "//src/proto/grpc/testing:empty_py_pb2", + "//src/proto/grpc/testing:empty_py_pb2_grpc", "//src/proto/grpc/testing:py_messages_proto", + "//src/proto/grpc/testing:messages_py_pb2_grpc", "//src/proto/grpc/testing:py_test_proto", + "//src/proto/grpc/testing:test_py_pb2_grpc", requirement("google-auth"), requirement("requests"), requirement("urllib3"), @@ -59,7 +62,7 @@ py_library( srcs = ["service.py"], imports = ["../../"], deps = [ - "//src/proto/grpc/testing:py_empty_proto", + "//src/proto/grpc/testing:empty_py_pb2", "//src/proto/grpc/testing:py_messages_proto", "//src/proto/grpc/testing:py_test_proto", "//src/python/grpcio/grpc:grpcio", diff --git a/src/python/grpcio_tests/tests/reflection/BUILD.bazel b/src/python/grpcio_tests/tests/reflection/BUILD.bazel index b635b721631..e9b56191df8 100644 --- a/src/python/grpcio_tests/tests/reflection/BUILD.bazel +++ b/src/python/grpcio_tests/tests/reflection/BUILD.bazel @@ -12,7 +12,7 @@ py_test( "//src/python/grpcio/grpc:grpcio", "//src/python/grpcio_reflection/grpc_reflection/v1alpha:grpc_reflection", "//src/python/grpcio_tests/tests/unit:test_common", - "//src/proto/grpc/testing:py_empty_proto", + "//src/proto/grpc/testing:empty_py_pb2", "//src/proto/grpc/testing/proto2:empty2_extensions_proto", "//src/proto/grpc/testing/proto2:empty2_proto", requirement('protobuf'), diff --git a/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py b/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py index 29bb292c913..1a1fdc83163 100644 --- a/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py +++ b/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py @@ -16,9 +16,14 @@ import unittest import grpc -from grpc_reflection.v1alpha import reflection -from grpc_reflection.v1alpha import reflection_pb2 -from grpc_reflection.v1alpha import reflection_pb2_grpc +try: + from src.python.grpcio_reflection.grpc_reflection.v1alpha import reflection + from src.python.grpcio_reflection.grpc_reflection.v1alpha import reflection_pb2 + from src.python.grpcio_reflection.grpc_reflection.v1alpha import reflection_pb2_grpc +except ImportError: + from grpc_reflection.v1alpha import reflection + from grpc_reflection.v1alpha import reflection_pb2 + from grpc_reflection.v1alpha import reflection_pb2_grpc from google.protobuf import descriptor_pool from google.protobuf import descriptor_pb2 diff --git a/src/python/grpcio_tests/tests/unit/BUILD.bazel b/src/python/grpcio_tests/tests/unit/BUILD.bazel index a161794f8be..cf4350a6beb 100644 --- a/src/python/grpcio_tests/tests/unit/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/BUILD.bazel @@ -1,5 +1,3 @@ -load("@grpc_python_dependencies//:requirements.bzl", "requirement") - package(default_visibility = ["//visibility:public"]) GRPCIO_TESTS_UNIT = [ @@ -89,7 +87,7 @@ py_library( ":_tcp_proxy", "//src/python/grpcio_tests/tests/unit/framework/common", "//src/python/grpcio_tests/tests/testing", - requirement('six'), + "//external:six" ], imports=["../../",], data=[ diff --git a/third_party/BUILD b/third_party/BUILD index 8b43d6b8300..cd4a6dad72b 100644 --- a/third_party/BUILD +++ b/third_party/BUILD @@ -8,4 +8,7 @@ exports_files([ "zope_interface.BUILD", "constantly.BUILD", "cython.BUILD", + "six.BUILD", + "enum34.BUILD", + "futures.BUILD", ]) diff --git a/third_party/enum34.BUILD b/third_party/enum34.BUILD new file mode 100644 index 00000000000..3fc2b3de571 --- /dev/null +++ b/third_party/enum34.BUILD @@ -0,0 +1,6 @@ +py_library( + name = "enum34", + srcs = ["enum/__init__.py"], + srcs_version = "PY2AND3", + visibility = ["//visibility:public"], +) diff --git a/third_party/futures.BUILD b/third_party/futures.BUILD new file mode 100644 index 00000000000..c280e1edfd7 --- /dev/null +++ b/third_party/futures.BUILD @@ -0,0 +1,6 @@ +py_library( + name = "futures", + srcs = glob(["concurrent/**/*.py"]), + srcs_version = "PY2AND3", + visibility = ["//visibility:public"], +) diff --git a/third_party/six.BUILD b/third_party/six.BUILD new file mode 100644 index 00000000000..60dc7811492 --- /dev/null +++ b/third_party/six.BUILD @@ -0,0 +1,6 @@ +py_library( + name = "six", + srcs = ["six.py"], + srcs_version = "PY2AND3", + visibility = ["//visibility:public"], +) diff --git a/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh b/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh index d844cff7f9a..f33fd0f4f55 100755 --- a/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh +++ b/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh @@ -29,3 +29,6 @@ bazel test --spawn_strategy=standalone --genrule_strategy=standalone --test_outp bazel clean --expunge bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //src/python/... bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //examples/python/... +(cd bazel/test/python_test_repo; + bazel test --test_output=errors //... +) From 2b7ec3ad2300266c05a50786486003eb5afba9c7 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Thu, 1 Aug 2019 16:09:25 -0700 Subject: [PATCH 1066/1555] Fix up examples. --- examples/BUILD | 1 - examples/python/auth/BUILD.bazel | 9 +++++---- examples/python/compression/BUILD.bazel | 6 ++++-- examples/python/debug/BUILD.bazel | 11 +++++++---- examples/python/debug/get_stats.py | 9 +++++++-- examples/python/errors/BUILD.bazel | 6 ++++-- 6 files changed, 27 insertions(+), 15 deletions(-) diff --git a/examples/BUILD b/examples/BUILD index b3c5d0a825c..aa9ed945849 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -68,7 +68,6 @@ proto_library( py_proto_library( name = "helloworld_py_pb2", srcs = [":protos/helloworld_proto"], - deps = [requirement('protobuf')], ) py_grpc_library( diff --git a/examples/python/auth/BUILD.bazel b/examples/python/auth/BUILD.bazel index 7bb4203f93f..cc454fdfdfe 100644 --- a/examples/python/auth/BUILD.bazel +++ b/examples/python/auth/BUILD.bazel @@ -36,7 +36,8 @@ py_binary( deps = [ ":_credentials", "//src/python/grpcio/grpc:grpcio", - "//examples:py_helloworld", + "//examples:helloworld_py_pb2", + "//examples:helloworld_py_pb2_grpc", ], ) @@ -47,8 +48,8 @@ py_binary( deps = [ ":_credentials", "//src/python/grpcio/grpc:grpcio", - "//examples:py_helloworld", - + "//examples:helloworld_py_pb2", + "//examples:helloworld_py_pb2_grpc", ], ) @@ -57,7 +58,7 @@ py_test( srcs = ["test/_auth_example_test.py"], deps = [ "//src/python/grpcio/grpc:grpcio", - "//examples:py_helloworld", + "//examples:helloworld_py_pb2", ":customized_auth_client", ":customized_auth_server", ":_credentials", diff --git a/examples/python/compression/BUILD.bazel b/examples/python/compression/BUILD.bazel index b95d7cccc77..9d5f6bb83ed 100644 --- a/examples/python/compression/BUILD.bazel +++ b/examples/python/compression/BUILD.bazel @@ -17,7 +17,8 @@ py_binary( srcs = ["server.py"], deps = [ "//src/python/grpcio/grpc:grpcio", - "//examples:py_helloworld", + "//examples:helloworld_py_pb2", + "//examples:helloworld_py_pb2_grpc", ], srcs_version = "PY2AND3", ) @@ -27,7 +28,8 @@ py_binary( srcs = ["client.py"], deps = [ "//src/python/grpcio/grpc:grpcio", - "//examples:py_helloworld", + "//examples:helloworld_py_pb2", + "//examples:helloworld_py_pb2_grpc", ], srcs_version = "PY2AND3", ) diff --git a/examples/python/debug/BUILD.bazel b/examples/python/debug/BUILD.bazel index 0134d8675ed..657ae860ae3 100644 --- a/examples/python/debug/BUILD.bazel +++ b/examples/python/debug/BUILD.bazel @@ -21,7 +21,8 @@ py_binary( deps = [ "//src/python/grpcio/grpc:grpcio", "//src/python/grpcio_channelz/grpc_channelz/v1:grpc_channelz", - "//examples:py_helloworld", + "//examples:helloworld_py_pb2", + "//examples:helloworld_py_pb2_grpc", ], ) @@ -31,7 +32,8 @@ py_binary( srcs = ["send_message.py"], deps = [ "//src/python/grpcio/grpc:grpcio", - "//examples:py_helloworld", + "//examples:helloworld_py_pb2", + "//examples:helloworld_py_pb2_grpc", ], ) @@ -51,9 +53,10 @@ py_test( deps = [ "//src/python/grpcio/grpc:grpcio", "//src/python/grpcio_channelz/grpc_channelz/v1:grpc_channelz", - "//examples:py_helloworld", + "//examples:helloworld_py_pb2", + "//examples:helloworld_py_pb2_grpc", ":debug_server", ":send_message", ":get_stats", ], -) \ No newline at end of file +) diff --git a/examples/python/debug/get_stats.py b/examples/python/debug/get_stats.py index d0b7061c54f..6eb593deb22 100644 --- a/examples/python/debug/get_stats.py +++ b/examples/python/debug/get_stats.py @@ -20,8 +20,13 @@ from __future__ import print_function import logging import argparse import grpc -from grpc_channelz.v1 import channelz_pb2 -from grpc_channelz.v1 import channelz_pb2_grpc + +try: + from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2 + from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2_grpc +except ImportError: + from grpc_channelz.v1 import channelz_pb2 + from grpc_channelz.v1 import channelz_pb2_grpc def run(addr): diff --git a/examples/python/errors/BUILD.bazel b/examples/python/errors/BUILD.bazel index b07dd12ebd3..4b779ddfcf1 100644 --- a/examples/python/errors/BUILD.bazel +++ b/examples/python/errors/BUILD.bazel @@ -21,7 +21,8 @@ py_library( deps = [ "//src/python/grpcio/grpc:grpcio", "//src/python/grpcio_status/grpc_status:grpc_status", - "//examples:py_helloworld", + "//examples:helloworld_py_pb2", + "//examples:helloworld_py_pb2_grpc", requirement('googleapis-common-protos'), ], ) @@ -33,7 +34,8 @@ py_library( deps = [ "//src/python/grpcio/grpc:grpcio", "//src/python/grpcio_status/grpc_status:grpc_status", - "//examples:py_helloworld", + "//examples:helloworld_py_pb2", + "//examples:helloworld_py_pb2_grpc", ] + select({ "//conditions:default": [requirement("futures")], "//:python3": [], From e64961d658d9e0de870ce37fed7154d35d57f5c1 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Thu, 1 Aug 2019 16:22:02 -0700 Subject: [PATCH 1067/1555] Shorten long lines. --- .../grpcio_reflection/grpc_reflection/v1alpha/reflection.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py b/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py index 70c506c1c7d..bc76136cc5a 100644 --- a/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py +++ b/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py @@ -18,8 +18,10 @@ from google.protobuf import descriptor_pb2 from google.protobuf import descriptor_pool try: - from src.python.grpcio_reflection.grpc_reflection.v1alpha import reflection_pb2 as _reflection_pb2 - from src.python.grpcio_reflection.grpc_reflection.v1alpha import reflection_pb2_grpc as _reflection_pb2_grpc + from src.python.grpcio_reflection.grpc_reflection.v1alpha \ + import reflection_pb2 as _reflection_pb2 + from src.python.grpcio_reflection.grpc_reflection.v1alpha \ + import reflection_pb2_grpc as _reflection_pb2_grpc except ImportError: from grpc_reflection.v1alpha import reflection_pb2 as _reflection_pb2 from grpc_reflection.v1alpha import reflection_pb2_grpc as _reflection_pb2_grpc From 01ec8299457e8deeda68439c6012846d5cca645e Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 1 Aug 2019 16:25:11 -0700 Subject: [PATCH 1068/1555] Mark private methods of DelegatingChannel final (other than WaitForStateChangeImpl and NotifyOnStateChangeImpl) --- include/grpcpp/impl/codegen/delegating_channel.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/grpcpp/impl/codegen/delegating_channel.h b/include/grpcpp/impl/codegen/delegating_channel.h index eb2802c68c9..a18622235f9 100644 --- a/include/grpcpp/impl/codegen/delegating_channel.h +++ b/include/grpcpp/impl/codegen/delegating_channel.h @@ -40,16 +40,16 @@ class DelegatingChannel : public ::grpc::ChannelInterface { private: internal::Call CreateCall(const internal::RpcMethod& method, ClientContext* context, - ::grpc_impl::CompletionQueue* cq) override { + ::grpc_impl::CompletionQueue* cq) final { return delegate_channel()->CreateCall(method, context, cq); } void PerformOpsOnCall(internal::CallOpSetInterface* ops, - internal::Call* call) override { + internal::Call* call) final { delegate_channel()->PerformOpsOnCall(ops, call); } - void* RegisterMethod(const char* method) override { + void* RegisterMethod(const char* method) final { return delegate_channel()->RegisterMethod(method); } @@ -69,12 +69,12 @@ class DelegatingChannel : public ::grpc::ChannelInterface { internal::Call CreateCallInternal(const internal::RpcMethod& method, ClientContext* context, ::grpc_impl::CompletionQueue* cq, - size_t interceptor_pos) override { + size_t interceptor_pos) final { return delegate_channel()->CreateCallInternal(method, context, cq, interceptor_pos); } - ::grpc_impl::CompletionQueue* CallbackCQ() override { + ::grpc_impl::CompletionQueue* CallbackCQ() final { return delegate_channel()->CallbackCQ(); } From 6954030175eab57951b721ffbf2bebaf94dbc9b1 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Thu, 1 Aug 2019 16:40:26 -0700 Subject: [PATCH 1069/1555] Cd to an absolute path. --- tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh b/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh index f33fd0f4f55..eda730d3a54 100755 --- a/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh +++ b/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh @@ -29,6 +29,6 @@ bazel test --spawn_strategy=standalone --genrule_strategy=standalone --test_outp bazel clean --expunge bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //src/python/... bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //examples/python/... -(cd bazel/test/python_test_repo; +(cd /var/local/git/grpc/bazel/test/python_test_repo; bazel test --test_output=errors //... ) From 835b3d32930cd6e179b8c244837d2b49477cce01 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Thu, 1 Aug 2019 17:11:56 -0700 Subject: [PATCH 1070/1555] Copyright. --- bazel/test/python_test_repo/BUILD | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bazel/test/python_test_repo/BUILD b/bazel/test/python_test_repo/BUILD index ed4ffd3b74f..0df3700ec93 100644 --- a/bazel/test/python_test_repo/BUILD +++ b/bazel/test/python_test_repo/BUILD @@ -1,3 +1,19 @@ +# gRPC Bazel BUILD file. +# +# Copyright 2019 The gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + load("@com_github_grpc_grpc//bazel:python_rules.bzl", "py_proto_library", "py_grpc_library") package(default_testonly = 1) From 3eb376c911c010d243e82a146d8a9082e5ab08ad Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 1 Aug 2019 17:18:18 -0700 Subject: [PATCH 1071/1555] Make py3 syntax check happy --- tools/run_tests/sanity/check_bazel_workspace.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/sanity/check_bazel_workspace.py b/tools/run_tests/sanity/check_bazel_workspace.py index 4ddbc74646f..81fee5aa536 100755 --- a/tools/run_tests/sanity/check_bazel_workspace.py +++ b/tools/run_tests/sanity/check_bazel_workspace.py @@ -132,7 +132,7 @@ build_rules = { 'load': lambda a, b: None, 'git_repository': lambda **args: eval_state.git_repository(**args), } -exec bazel_file in build_rules +exec(bazel_file in build_rules) for name in _GRPC_DEP_NAMES: assert name in names_and_urls.keys() assert len(_GRPC_DEP_NAMES) == len(names_and_urls.keys()) From f20171f28bdcde810bf2c02b3d10d5a22d724f13 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 1 Aug 2019 17:27:27 -0700 Subject: [PATCH 1072/1555] Found another breakage --- tools/run_tests/sanity/check_bazel_workspace.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/sanity/check_bazel_workspace.py b/tools/run_tests/sanity/check_bazel_workspace.py index 81fee5aa536..612f908bbfe 100755 --- a/tools/run_tests/sanity/check_bazel_workspace.py +++ b/tools/run_tests/sanity/check_bazel_workspace.py @@ -174,7 +174,7 @@ for name in _GRPC_DEP_NAMES: 'load': lambda a, b: None, 'git_repository': lambda **args: state.git_repository(**args), } - exec bazel_file in rules + exec(bazel_file in rules) assert name not in names_and_urls_with_overridden_name.keys() sys.exit(0) From 48516216307a262cf028759156ff1c8f99568d09 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Thu, 1 Aug 2019 17:30:47 -0700 Subject: [PATCH 1073/1555] Bump version to v1.24.x --- BUILD | 4 ++-- build.yaml | 4 ++-- doc/g_stands_for.md | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/BUILD b/BUILD index 6b51f07b82f..89e2cda3fdc 100644 --- a/BUILD +++ b/BUILD @@ -74,11 +74,11 @@ config_setting( ) # This should be updated along with build.yaml -g_stands_for = "gangnam" +g_stands_for = "ganges" core_version = "7.0.0" -version = "1.23.0-dev" +version = "1.24.0-dev" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index 999c761056f..7f123dae740 100644 --- a/build.yaml +++ b/build.yaml @@ -14,8 +14,8 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 7.0.0 csharp_major_version: 2 - g_stands_for: gangnam - version: 1.23.0-dev + g_stands_for: ganges + version: 1.24.0-dev filegroups: - name: alts_proto headers: diff --git a/doc/g_stands_for.md b/doc/g_stands_for.md index fe1cbc90005..413ddcb341d 100644 --- a/doc/g_stands_for.md +++ b/doc/g_stands_for.md @@ -22,4 +22,5 @@ - 1.20 'g' stands for ['godric'](https://github.com/grpc/grpc/tree/v1.20.x) - 1.21 'g' stands for ['gandalf'](https://github.com/grpc/grpc/tree/v1.21.x) - 1.22 'g' stands for ['gale'](https://github.com/grpc/grpc/tree/v1.22.x) -- 1.23 'g' stands for ['gangnam'](https://github.com/grpc/grpc/tree/master) +- 1.23 'g' stands for ['gangnam'](https://github.com/grpc/grpc/tree/v1.23.x) +- 1.24 'g' stands for ['ganges'](https://github.com/grpc/grpc/tree/master) From fcb43f9deeeaf545085130087a923c963377bdda Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Thu, 1 Aug 2019 17:34:02 -0700 Subject: [PATCH 1074/1555] Regenerate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 4 ++-- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 4 ++-- src/core/lib/surface/version.cc | 2 +- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 4 ++-- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/composer.json | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 32 files changed, 36 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12b2707f951..f2363910cc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 3.5.1) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.23.0-dev") +set(PACKAGE_VERSION "1.24.0-dev") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 0107f145204..c22b2d2ef4b 100644 --- a/Makefile +++ b/Makefile @@ -461,8 +461,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.23.0-dev -CSHARP_VERSION = 2.23.0-dev +CPP_VERSION = 1.24.0-dev +CSHARP_VERSION = 2.24.0-dev CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 56d6f5b3edb..16ca8088f72 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,7 +23,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.23.0-dev' + # version = '1.24.0-dev' version = '0.0.9-dev' s.version = version s.summary = 'gRPC C++ library' @@ -31,7 +31,7 @@ Pod::Spec.new do |s| s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.23.0-dev' + grpc_version = '1.24.0-dev' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 6325348602e..a08b3cc680f 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.23.0-dev' + version = '1.24.0-dev' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 2c0441ba95c..3163c031ab8 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.23.0-dev' + version = '1.24.0-dev' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 12a8728ac34..8505bba9fcf 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.23.0-dev' + version = '1.24.0-dev' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index bbfd08f9774..fcdd4968f04 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.23.0-dev' + version = '1.24.0-dev' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index cb221ff932d..af06829c733 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2018-01-19 - 1.23.0dev - 1.23.0dev + 1.24.0dev + 1.24.0dev beta diff --git a/src/core/lib/surface/version.cc b/src/core/lib/surface/version.cc index 848a49d1eff..182eed2ced2 100644 --- a/src/core/lib/surface/version.cc +++ b/src/core/lib/surface/version.cc @@ -25,4 +25,4 @@ const char* grpc_version_string(void) { return "7.0.0"; } -const char* grpc_g_stands_for(void) { return "gangnam"; } +const char* grpc_g_stands_for(void) { return "ganges"; } diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 7fb7823c9f2..71ddc6e5d71 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.23.0-dev"; } +grpc::string Version() { return "1.24.0-dev"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index d84da7c9e2f..f732af32ec3 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -33,11 +33,11 @@ namespace Grpc.Core /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "2.23.0.0"; + public const string CurrentAssemblyFileVersion = "2.24.0.0"; /// /// Current version of gRPC C# /// - public const string CurrentVersion = "2.23.0-dev"; + public const string CurrentVersion = "2.24.0-dev"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index 4f100873bc7..d45d3b1b0eb 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 2.23.0-dev + 2.24.0-dev 3.8.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index f29bd98b5a2..9fade5c1dd0 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=2.23.0-dev +set VERSION=2.24.0-dev @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec index dc1f8b2c090..56ca7ce6ae4 100644 --- a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCCppPlugin' - v = '1.23.0-dev' + v = '1.24.0-dev' s.version = v s.summary = 'The gRPC ProtoC plugin generates C++ files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 939078def22..c98aed5bc55 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.23.0-dev' + v = '1.24.0-dev' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 3b248db0148..fc6982c55d6 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.23.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.24.0-dev" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 231ba1a9a9f..d724fdd8e07 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.23.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.24.0-dev" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/composer.json b/src/php/composer.json index e29c9c33fde..6da1fd77d65 100644 --- a/src/php/composer.json +++ b/src/php/composer.json @@ -2,7 +2,7 @@ "name": "grpc/grpc-dev", "description": "gRPC library for PHP - for Developement use only", "license": "Apache-2.0", - "version": "1.23.0", + "version": "1.24.0", "require": { "php": ">=5.5.0", "google/protobuf": "^v3.3.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index bb707f50a9f..000508dd3f8 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.23.0dev" +#define PHP_GRPC_VERSION "1.24.0dev" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index d2f8be43f34..ff1b1a17d25 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.23.0.dev0""" +__version__ = """1.24.0.dev0""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index 548d2810b5b..e0280abaa7c 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.24.0.dev0' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index f7029fff484..93a448ecb64 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.24.0.dev0' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index d66daa473ed..2a1aa0c9359 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.24.0.dev0' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 97213872a91..93c28ba9fac 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.24.0.dev0' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index 31921b4cc90..a2b5a814b52 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.24.0.dev0' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 5c8926cb6c8..937e57da02f 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.24.0.dev0' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index a1fc87448a1..a1e43215b09 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.24.0.dev0' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 051bc067e55..43f08a0c87b 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.23.0.dev' + VERSION = '1.24.0.dev' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index e66a4a799fd..b08edb08478 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.23.0.dev' + VERSION = '1.24.0.dev' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 127d3c1f9bc..184a0a9dda6 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.24.0.dev0' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index e85ae495546..15eedc7a888 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.23.0-dev +PROJECT_NUMBER = 1.24.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 96da09eefc6..61b858b1952 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.23.0-dev +PROJECT_NUMBER = 1.24.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From 07c4b1e0bb3726ae0d22ded27aaefe82060195bf Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Thu, 1 Aug 2019 17:48:31 -0700 Subject: [PATCH 1075/1555] Bump version to v1.23.0-pre1 --- BUILD | 2 +- build.yaml | 2 +- doc/g_stands_for.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/BUILD b/BUILD index 6b51f07b82f..c708318ecbf 100644 --- a/BUILD +++ b/BUILD @@ -78,7 +78,7 @@ g_stands_for = "gangnam" core_version = "7.0.0" -version = "1.23.0-dev" +version = "1.23.0-pre1" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index 999c761056f..1ba055c65dd 100644 --- a/build.yaml +++ b/build.yaml @@ -15,7 +15,7 @@ settings: core_version: 7.0.0 csharp_major_version: 2 g_stands_for: gangnam - version: 1.23.0-dev + version: 1.23.0-pre1 filegroups: - name: alts_proto headers: diff --git a/doc/g_stands_for.md b/doc/g_stands_for.md index fe1cbc90005..373357ab8a6 100644 --- a/doc/g_stands_for.md +++ b/doc/g_stands_for.md @@ -22,4 +22,4 @@ - 1.20 'g' stands for ['godric'](https://github.com/grpc/grpc/tree/v1.20.x) - 1.21 'g' stands for ['gandalf'](https://github.com/grpc/grpc/tree/v1.21.x) - 1.22 'g' stands for ['gale'](https://github.com/grpc/grpc/tree/v1.22.x) -- 1.23 'g' stands for ['gangnam'](https://github.com/grpc/grpc/tree/master) +- 1.23 'g' stands for ['gangnam'](https://github.com/grpc/grpc/tree/v1.23.x) From d030df29518fe15d8b247aa7ce248b0bef77d631 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Thu, 1 Aug 2019 17:48:59 -0700 Subject: [PATCH 1076/1555] Regenerate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 6 +++--- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 4 ++-- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 2 +- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 30 files changed, 34 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12b2707f951..6a5b4b5cd8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 3.5.1) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.23.0-dev") +set(PACKAGE_VERSION "1.23.0-pre1") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 0107f145204..d4d82581cef 100644 --- a/Makefile +++ b/Makefile @@ -461,8 +461,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.23.0-dev -CSHARP_VERSION = 2.23.0-dev +CPP_VERSION = 1.23.0-pre1 +CSHARP_VERSION = 2.23.0-pre1 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 56d6f5b3edb..304ae372101 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,15 +23,15 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.23.0-dev' - version = '0.0.9-dev' + # version = '1.23.0-pre1' + version = '0.0.9-pre1' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.23.0-dev' + grpc_version = '1.23.0-pre1' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 6325348602e..d3a82b572dc 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.23.0-dev' + version = '1.23.0-pre1' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 2c0441ba95c..c90445baae2 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.23.0-dev' + version = '1.23.0-pre1' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 12a8728ac34..87bd9e7c481 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.23.0-dev' + version = '1.23.0-pre1' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index bbfd08f9774..dc05dc86ba2 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.23.0-dev' + version = '1.23.0-pre1' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index cb221ff932d..7d2cb708925 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2018-01-19 - 1.23.0dev - 1.23.0dev + 1.23.0RC1 + 1.23.0RC1 beta diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 7fb7823c9f2..751cbfa1c22 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.23.0-dev"; } +grpc::string Version() { return "1.23.0-pre1"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index d84da7c9e2f..ca9e88f268d 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -38,6 +38,6 @@ namespace Grpc.Core /// /// Current version of gRPC C# /// - public const string CurrentVersion = "2.23.0-dev"; + public const string CurrentVersion = "2.23.0-pre1"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index 4f100873bc7..00ff3ccb780 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 2.23.0-dev + 2.23.0-pre1 3.8.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index f29bd98b5a2..1906f266e20 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=2.23.0-dev +set VERSION=2.23.0-pre1 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec index dc1f8b2c090..6dc9d4a3f13 100644 --- a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCCppPlugin' - v = '1.23.0-dev' + v = '1.23.0-pre1' s.version = v s.summary = 'The gRPC ProtoC plugin generates C++ files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 939078def22..98b4ef0dc12 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.23.0-dev' + v = '1.23.0-pre1' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 3b248db0148..bf467558d31 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.23.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.23.0-pre1" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 231ba1a9a9f..f5d7ec747af 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.23.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.23.0-pre1" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index bb707f50a9f..038ca5c1b25 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.23.0dev" +#define PHP_GRPC_VERSION "1.23.0RC1" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index d2f8be43f34..d8f04ec88f3 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.23.0.dev0""" +__version__ = """1.23.0rc1""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index 548d2810b5b..2215172be39 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.23.0rc1' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index f7029fff484..d7b9e92800b 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.23.0rc1' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index d66daa473ed..04a5cd79401 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.23.0rc1' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 97213872a91..8f47ca23c9b 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.23.0rc1' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index 31921b4cc90..42aad42fa57 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.23.0rc1' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 5c8926cb6c8..71930c6730f 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.23.0rc1' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index a1fc87448a1..aab9f1b57ab 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.23.0rc1' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 051bc067e55..fa31c144282 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.23.0.dev' + VERSION = '1.23.0.pre1' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index e66a4a799fd..e5e7a16717c 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.23.0.dev' + VERSION = '1.23.0.pre1' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 127d3c1f9bc..2b4e8218b50 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.23.0.dev0' +VERSION = '1.23.0rc1' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index e85ae495546..d508459f0fd 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.23.0-dev +PROJECT_NUMBER = 1.23.0-pre1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 96da09eefc6..ec0c30b0e79 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.23.0-dev +PROJECT_NUMBER = 1.23.0-pre1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From efa43e1bb3b5cb77abece370321c036a487aefe2 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Thu, 1 Aug 2019 17:56:59 -0700 Subject: [PATCH 1077/1555] Modified scripts to run builds correct schemes on correct platforms --- src/objective-c/tests/build_one_example.sh | 18 ++++++++++++++++-- tools/run_tests/run_tests.py | 4 ++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/objective-c/tests/build_one_example.sh b/src/objective-c/tests/build_one_example.sh index 084147f1d46..caa048e258b 100755 --- a/src/objective-c/tests/build_one_example.sh +++ b/src/objective-c/tests/build_one_example.sh @@ -31,14 +31,26 @@ cd $EXAMPLE_PATH # clean the directory rm -rf Pods -rm -rf $SCHEME.xcworkspace +rm -rf *.xcworkspace rm -f Podfile.lock pod install set -o pipefail XCODEBUILD_FILTER='(^CompileC |^Ld |^.*clang |^ *cd |^ *export |^Libtool |^.*libtool |^CpHeader |^ *builtin-copy )' -xcodebuild \ +if [ "$SCHEME" == "tvOS-sample" ]; then + xcodebuild \ + build \ + -workspace *.xcworkspace \ + -scheme $SCHEME \ + -destination generic/platform=tvOS \ + -derivedDataPath Build/Build \ + CODE_SIGN_IDENTITY="" \ + CODE_SIGNING_REQUIRED=NO \ + | egrep -v "$XCODEBUILD_FILTER" \ + | egrep -v "^$" - +else + xcodebuild \ build \ -workspace *.xcworkspace \ -scheme $SCHEME \ @@ -48,3 +60,5 @@ xcodebuild \ CODE_SIGNING_REQUIRED=NO \ | egrep -v "$XCODEBUILD_FILTER" \ | egrep -v "^$" - +fi + diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index a4e647a7833..db75d884aa9 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1119,7 +1119,7 @@ class ObjCLanguage(object): shortname='ios-buildtest-example-watchOS-sample', cpu_cost=1e6, environ={ - 'SCHEME': 'watchOS-sample', + 'SCHEME': 'watchOS-sample-WatchKit-App', 'EXAMPLE_PATH': 'src/objective-c/examples/watchOS-sample', 'FRAMEWORKS': 'NO' })) @@ -1130,7 +1130,7 @@ class ObjCLanguage(object): shortname='ios-buildtest-example-watchOS-sample-framework', cpu_cost=1e6, environ={ - 'SCHEME': 'watchOS-sample', + 'SCHEME': 'watchOS-sample-WatchKit-App', 'EXAMPLE_PATH': 'src/objective-c/examples/watchOS-sample', 'FRAMEWORKS': 'YES' })) From a0ba0b1ff235ed9378898f9402d64aa9b839fb7d Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 1 Aug 2019 17:59:27 -0700 Subject: [PATCH 1078/1555] Change format --- tools/run_tests/sanity/check_bazel_workspace.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/run_tests/sanity/check_bazel_workspace.py b/tools/run_tests/sanity/check_bazel_workspace.py index 612f908bbfe..fa1ae2574fb 100755 --- a/tools/run_tests/sanity/check_bazel_workspace.py +++ b/tools/run_tests/sanity/check_bazel_workspace.py @@ -132,7 +132,7 @@ build_rules = { 'load': lambda a, b: None, 'git_repository': lambda **args: eval_state.git_repository(**args), } -exec(bazel_file in build_rules) +exec (bazel_file) in build_rules for name in _GRPC_DEP_NAMES: assert name in names_and_urls.keys() assert len(_GRPC_DEP_NAMES) == len(names_and_urls.keys()) @@ -174,7 +174,7 @@ for name in _GRPC_DEP_NAMES: 'load': lambda a, b: None, 'git_repository': lambda **args: state.git_repository(**args), } - exec(bazel_file in rules) + exec (bazel_file) in rules assert name not in names_and_urls_with_overridden_name.keys() sys.exit(0) From 5476b0512dcd5eab4771d222bd43c943ee1004d1 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Thu, 1 Aug 2019 18:01:23 -0700 Subject: [PATCH 1079/1555] Remade projects for backwards compatibility --- .../tvOS-sample.xcodeproj/project.pbxproj | 241 +++---- .../tvOS-sample/tvOS-sample/AppDelegate.m | 1 + .../tvOS-sample/Base.lproj/Main.storyboard | 8 +- .../tvOS-sample/tvOS-sample/ViewController.m | 7 +- .../examples/tvOS-sample/tvOS-sample/main.m | 1 + .../AppIcon.appiconset/Contents.json | 21 - .../Assets.xcassets/Contents.json | 6 - .../Base.lproj/Interface.storyboard | 10 +- .../watchOS-sample/WatchKit-App/Info.plist | 2 +- .../Circular.imageset/Contents.json | 18 - .../Contents.json | 48 -- .../Extra Large.imageset/Contents.json | 18 - .../Graphic Bezel.imageset/Contents.json | 18 - .../Graphic Circular.imageset/Contents.json | 18 - .../Graphic Corner.imageset/Contents.json | 18 - .../Contents.json | 18 - .../Modular.imageset/Contents.json | 18 - .../Utilitarian.imageset/Contents.json | 18 - .../Assets.xcassets/Contents.json | 6 - .../WatchKit-Extension/ExtensionDelegate.h | 1 + .../WatchKit-Extension/ExtensionDelegate.m | 1 + .../WatchKit-Extension/Info.plist | 4 +- .../WatchKit-Extension/InterfaceController.h | 1 + .../WatchKit-Extension/InterfaceController.m | 8 +- .../watchOS-sample.xcodeproj/project.pbxproj | 612 ++++++++++-------- .../watchOS-sample WatchKit App.xcscheme | 127 ---- .../xcschemes/watchOS-sample.xcscheme | 91 --- .../watchOS-sample/AppDelegate.m | 1 + .../AppIcon.appiconset/Contents.json | 5 - .../Assets.xcassets/Contents.json | 6 - .../Base.lproj/LaunchScreen.storyboard | 2 +- .../watchOS-sample/Base.lproj/Main.storyboard | 2 +- .../watchOS-sample/ViewController.m | 1 + .../watchOS-sample/watchOS-sample/main.m | 1 + 34 files changed, 508 insertions(+), 850 deletions(-) delete mode 100644 src/objective-c/examples/watchOS-sample/WatchKit-App/Assets.xcassets/Contents.json delete mode 100644 src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json delete mode 100644 src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Contents.json delete mode 100644 src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json delete mode 100644 src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json delete mode 100644 src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json delete mode 100644 src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json delete mode 100644 src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json delete mode 100644 src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json delete mode 100644 src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json delete mode 100644 src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Contents.json delete mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample WatchKit App.xcscheme delete mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample.xcscheme delete mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample/Assets.xcassets/Contents.json diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj b/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj index 7f8198aa320..84eafed2608 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj @@ -7,100 +7,101 @@ objects = { /* Begin PBXBuildFile section */ - 8E4F1CA090367C7618548546 /* libPods-tvOS-sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 65430D45E5C272C975E4CCCA /* libPods-tvOS-sample.a */; }; - ABB17D3A22D8FB8B00C26D6E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D3922D8FB8B00C26D6E /* AppDelegate.m */; }; - ABB17D3D22D8FB8B00C26D6E /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D3C22D8FB8B00C26D6E /* ViewController.m */; }; - ABB17D4022D8FB8B00C26D6E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D3E22D8FB8B00C26D6E /* Main.storyboard */; }; - ABB17D4522D8FB8D00C26D6E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D4422D8FB8D00C26D6E /* main.m */; }; + 02EBA696CC670AE7C839A074 /* libPods-tvOS-sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E06AA8437E1C07D35F65494 /* libPods-tvOS-sample.a */; }; + AB065AFB22F3A66000418B42 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = AB065AFA22F3A66000418B42 /* AppDelegate.m */; }; + AB065AFE22F3A66000418B42 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AB065AFD22F3A66000418B42 /* ViewController.m */; }; + AB065B0122F3A66000418B42 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AB065AFF22F3A66000418B42 /* Main.storyboard */; }; + AB065B0622F3A66000418B42 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = AB065B0522F3A66000418B42 /* main.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 65430D45E5C272C975E4CCCA /* libPods-tvOS-sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-tvOS-sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 93F3CF0DB110860F8E180685 /* Pods-tvOS-sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-tvOS-sample.release.xcconfig"; path = "Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample.release.xcconfig"; sourceTree = ""; }; - ABB17D3522D8FB8B00C26D6E /* tvOS-sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "tvOS-sample.app"; sourceTree = BUILT_PRODUCTS_DIR; }; - ABB17D3822D8FB8B00C26D6E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; - ABB17D3922D8FB8B00C26D6E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - ABB17D3B22D8FB8B00C26D6E /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; - ABB17D3C22D8FB8B00C26D6E /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; - ABB17D3F22D8FB8B00C26D6E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - ABB17D4322D8FB8D00C26D6E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - ABB17D4422D8FB8D00C26D6E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - D2D1C60CE9BD00C1371BC913 /* Pods-tvOS-sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-tvOS-sample.debug.xcconfig"; path = "Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample.debug.xcconfig"; sourceTree = ""; }; + 48F25040998C073D575D8368 /* Pods-tvOS-sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-tvOS-sample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample.debug.xcconfig"; sourceTree = ""; }; + 4E06AA8437E1C07D35F65494 /* libPods-tvOS-sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-tvOS-sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 6DEA6A97511C324413DA4309 /* Pods-tvOS-sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-tvOS-sample.release.xcconfig"; path = "Pods/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample.release.xcconfig"; sourceTree = ""; }; + AB065AF622F3A66000418B42 /* tvOS-sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "tvOS-sample.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + AB065AF922F3A66000418B42 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + AB065AFA22F3A66000418B42 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + AB065AFC22F3A66000418B42 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + AB065AFD22F3A66000418B42 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + AB065B0022F3A66000418B42 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + AB065B0422F3A66000418B42 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + AB065B0522F3A66000418B42 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - ABB17D3222D8FB8B00C26D6E /* Frameworks */ = { + AB065AF322F3A66000418B42 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 8E4F1CA090367C7618548546 /* libPods-tvOS-sample.a in Frameworks */, + 02EBA696CC670AE7C839A074 /* libPods-tvOS-sample.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 28FD2EFD84992131D85ADAE6 /* Pods */ = { + 0BEC1FEC387B8EE89F6F099A /* Frameworks */ = { isa = PBXGroup; children = ( - D2D1C60CE9BD00C1371BC913 /* Pods-tvOS-sample.debug.xcconfig */, - 93F3CF0DB110860F8E180685 /* Pods-tvOS-sample.release.xcconfig */, + 4E06AA8437E1C07D35F65494 /* libPods-tvOS-sample.a */, ); - path = Pods; + name = Frameworks; sourceTree = ""; }; - ABB17D2C22D8FB8B00C26D6E = { + 3FED17B5BF1125421CC89007 /* Pods */ = { isa = PBXGroup; children = ( - ABB17D3722D8FB8B00C26D6E /* tvOS-sample */, - ABB17D3622D8FB8B00C26D6E /* Products */, - 28FD2EFD84992131D85ADAE6 /* Pods */, - D280E557B55AAB044C083DB5 /* Frameworks */, + 48F25040998C073D575D8368 /* Pods-tvOS-sample.debug.xcconfig */, + 6DEA6A97511C324413DA4309 /* Pods-tvOS-sample.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + AB065AED22F3A66000418B42 = { + isa = PBXGroup; + children = ( + AB065AF822F3A66000418B42 /* tvOS-sample */, + AB065AF722F3A66000418B42 /* Products */, + 3FED17B5BF1125421CC89007 /* Pods */, + 0BEC1FEC387B8EE89F6F099A /* Frameworks */, ); sourceTree = ""; }; - ABB17D3622D8FB8B00C26D6E /* Products */ = { + AB065AF722F3A66000418B42 /* Products */ = { isa = PBXGroup; children = ( - ABB17D3522D8FB8B00C26D6E /* tvOS-sample.app */, + AB065AF622F3A66000418B42 /* tvOS-sample.app */, ); name = Products; sourceTree = ""; }; - ABB17D3722D8FB8B00C26D6E /* tvOS-sample */ = { + AB065AF822F3A66000418B42 /* tvOS-sample */ = { isa = PBXGroup; children = ( - ABB17D3822D8FB8B00C26D6E /* AppDelegate.h */, - ABB17D3922D8FB8B00C26D6E /* AppDelegate.m */, - ABB17D3B22D8FB8B00C26D6E /* ViewController.h */, - ABB17D3C22D8FB8B00C26D6E /* ViewController.m */, - ABB17D3E22D8FB8B00C26D6E /* Main.storyboard */, - ABB17D4322D8FB8D00C26D6E /* Info.plist */, - ABB17D4422D8FB8D00C26D6E /* main.m */, + AB065AF922F3A66000418B42 /* AppDelegate.h */, + AB065AFA22F3A66000418B42 /* AppDelegate.m */, + AB065AFC22F3A66000418B42 /* ViewController.h */, + AB065AFD22F3A66000418B42 /* ViewController.m */, + AB065AFF22F3A66000418B42 /* Main.storyboard */, + AB065B0422F3A66000418B42 /* Info.plist */, + AB065B0522F3A66000418B42 /* main.m */, ); path = "tvOS-sample"; sourceTree = ""; }; - D280E557B55AAB044C083DB5 /* Frameworks */ = { - isa = PBXGroup; - children = ( - 65430D45E5C272C975E4CCCA /* libPods-tvOS-sample.a */, - ); - name = Frameworks; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - ABB17D3422D8FB8B00C26D6E /* tvOS-sample */ = { + AB065AF522F3A66000418B42 /* tvOS-sample */ = { isa = PBXNativeTarget; - buildConfigurationList = ABB17D4822D8FB8D00C26D6E /* Build configuration list for PBXNativeTarget "tvOS-sample" */; + buildConfigurationList = AB065B0922F3A66000418B42 /* Build configuration list for PBXNativeTarget "tvOS-sample" */; buildPhases = ( - BCFBD1317F97D9F34D9AFD4A /* [CP] Check Pods Manifest.lock */, - ABB17D3122D8FB8B00C26D6E /* Sources */, - ABB17D3222D8FB8B00C26D6E /* Frameworks */, - ABB17D3322D8FB8B00C26D6E /* Resources */, - 53B9CBB782EEE8A7572F10EC /* [CP] Copy Pods Resources */, + 2C94076AB2C1F2771A45E0FF /* [CP] Check Pods Manifest.lock */, + AB065AF222F3A66000418B42 /* Sources */, + AB065AF322F3A66000418B42 /* Frameworks */, + AB065AF422F3A66000418B42 /* Resources */, + 000AD98AD507990B4381492E /* [CP] Embed Pods Frameworks */, + EC4FC44DCB7C66394A17FCF9 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -108,25 +109,25 @@ ); name = "tvOS-sample"; productName = "tvOS-sample"; - productReference = ABB17D3522D8FB8B00C26D6E /* tvOS-sample.app */; + productReference = AB065AF622F3A66000418B42 /* tvOS-sample.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ - ABB17D2D22D8FB8B00C26D6E /* Project object */ = { + AB065AEE22F3A66000418B42 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1010; + LastUpgradeCheck = 0920; ORGANIZATIONNAME = "Tony Lu"; TargetAttributes = { - ABB17D3422D8FB8B00C26D6E = { - CreatedOnToolsVersion = 10.1; + AB065AF522F3A66000418B42 = { + CreatedOnToolsVersion = 9.2; ProvisioningStyle = Automatic; }; }; }; - buildConfigurationList = ABB17D3022D8FB8B00C26D6E /* Build configuration list for PBXProject "tvOS-sample" */; + buildConfigurationList = AB065AF122F3A66000418B42 /* Build configuration list for PBXProject "tvOS-sample" */; compatibilityVersion = "Xcode 8.0"; developmentRegion = en; hasScannedForEncodings = 0; @@ -134,51 +135,61 @@ en, Base, ); - mainGroup = ABB17D2C22D8FB8B00C26D6E; - productRefGroup = ABB17D3622D8FB8B00C26D6E /* Products */; + mainGroup = AB065AED22F3A66000418B42; + productRefGroup = AB065AF722F3A66000418B42 /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( - ABB17D3422D8FB8B00C26D6E /* tvOS-sample */, + AB065AF522F3A66000418B42 /* tvOS-sample */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ - ABB17D3322D8FB8B00C26D6E /* Resources */ = { + AB065AF422F3A66000418B42 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - ABB17D4022D8FB8B00C26D6E /* Main.storyboard in Resources */, + AB065B0122F3A66000418B42 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 53B9CBB782EEE8A7572F10EC /* [CP] Copy Pods Resources */ = { + 000AD98AD507990B4381492E /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC/gRPCCertificates.bundle", - ); - name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/BoringSSL-GRPC/openssl_grpc.framework", + "${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework", + "${BUILT_PRODUCTS_DIR}/RemoteTest/RemoteTest.framework", + "${BUILT_PRODUCTS_DIR}/gRPC/GRPCClient.framework", + "${BUILT_PRODUCTS_DIR}/gRPC-Core/grpc.framework", + "${BUILT_PRODUCTS_DIR}/gRPC-ProtoRPC/ProtoRPC.framework", + "${BUILT_PRODUCTS_DIR}/gRPC-RxLibrary/RxLibrary.framework", + "${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework", ); + name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/openssl_grpc.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RemoteTest.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GRPCClient.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/grpc.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ProtoRPC.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxLibrary.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-resources.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - BCFBD1317F97D9F34D9AFD4A /* [CP] Check Pods Manifest.lock */ = { + 2C94076AB2C1F2771A45E0FF /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -196,26 +207,44 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + EC4FC44DCB7C66394A17FCF9 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-resources.sh", + "$PODS_CONFIGURATION_BUILD_DIR/gRPC/gRPCCertificates.bundle", + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ - ABB17D3122D8FB8B00C26D6E /* Sources */ = { + AB065AF222F3A66000418B42 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - ABB17D3D22D8FB8B00C26D6E /* ViewController.m in Sources */, - ABB17D4522D8FB8D00C26D6E /* main.m in Sources */, - ABB17D3A22D8FB8B00C26D6E /* AppDelegate.m in Sources */, + AB065AFE22F3A66000418B42 /* ViewController.m in Sources */, + AB065B0622F3A66000418B42 /* main.m in Sources */, + AB065AFB22F3A66000418B42 /* AppDelegate.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ - ABB17D3E22D8FB8B00C26D6E /* Main.storyboard */ = { + AB065AFF22F3A66000418B42 /* Main.storyboard */ = { isa = PBXVariantGroup; children = ( - ABB17D3F22D8FB8B00C26D6E /* Base */, + AB065B0022F3A66000418B42 /* Base */, ); name = Main.storyboard; sourceTree = ""; @@ -223,7 +252,7 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ - ABB17D4622D8FB8D00C26D6E /* Debug */ = { + AB065B0722F3A66000418B42 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -233,12 +262,10 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -246,7 +273,6 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -273,15 +299,14 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; + MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = appletvos; - TVOS_DEPLOYMENT_TARGET = 12.1; + TVOS_DEPLOYMENT_TARGET = 11.2; }; name = Debug; }; - ABB17D4722D8FB8D00C26D6E /* Release */ = { + AB065B0822F3A66000418B42 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -291,12 +316,10 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -304,7 +327,6 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -326,42 +348,45 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; SDKROOT = appletvos; - TVOS_DEPLOYMENT_TARGET = 12.1; + TVOS_DEPLOYMENT_TARGET = 11.2; VALIDATE_PRODUCT = YES; }; name = Release; }; - ABB17D4922D8FB8D00C26D6E /* Debug */ = { + AB065B0A22F3A66000418B42 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = D2D1C60CE9BD00C1371BC913 /* Pods-tvOS-sample.debug.xcconfig */; + baseConfigurationReference = 48F25040998C073D575D8368 /* Pods-tvOS-sample.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 6T98ZJNPG5; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "tvOS-sample/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.google.tvOS-grpc-sample"; + PRODUCT_BUNDLE_IDENTIFIER = "com.google.tvOS-sample"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 10.0; }; name = Debug; }; - ABB17D4A22D8FB8D00C26D6E /* Release */ = { + AB065B0B22F3A66000418B42 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 93F3CF0DB110860F8E180685 /* Pods-tvOS-sample.release.xcconfig */; + baseConfigurationReference = 6DEA6A97511C324413DA4309 /* Pods-tvOS-sample.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 6T98ZJNPG5; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "tvOS-sample/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.google.tvOS-grpc-sample"; + PRODUCT_BUNDLE_IDENTIFIER = "com.google.tvOS-sample"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 10.0; }; @@ -370,25 +395,25 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - ABB17D3022D8FB8B00C26D6E /* Build configuration list for PBXProject "tvOS-sample" */ = { + AB065AF122F3A66000418B42 /* Build configuration list for PBXProject "tvOS-sample" */ = { isa = XCConfigurationList; buildConfigurations = ( - ABB17D4622D8FB8D00C26D6E /* Debug */, - ABB17D4722D8FB8D00C26D6E /* Release */, + AB065B0722F3A66000418B42 /* Debug */, + AB065B0822F3A66000418B42 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - ABB17D4822D8FB8D00C26D6E /* Build configuration list for PBXNativeTarget "tvOS-sample" */ = { + AB065B0922F3A66000418B42 /* Build configuration list for PBXNativeTarget "tvOS-sample" */ = { isa = XCConfigurationList; buildConfigurations = ( - ABB17D4922D8FB8D00C26D6E /* Debug */, - ABB17D4A22D8FB8D00C26D6E /* Release */, + AB065B0A22F3A66000418B42 /* Debug */, + AB065B0B22F3A66000418B42 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; - rootObject = ABB17D2D22D8FB8B00C26D6E /* Project object */; + rootObject = AB065AEE22F3A66000418B42 /* Project object */; } diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m index 4a76f4c488c..2a0849df3d4 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m @@ -25,3 +25,4 @@ @implementation AppDelegate @end + diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Base.lproj/Main.storyboard b/src/objective-c/examples/tvOS-sample/tvOS-sample/Base.lproj/Main.storyboard index 783cc4062b3..0f2fc518164 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Base.lproj/Main.storyboard +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Base.lproj/Main.storyboard @@ -1,11 +1,11 @@ - + - + @@ -22,13 +22,13 @@ - diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m index c94ee8c2569..76f172bef0c 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m @@ -37,10 +37,10 @@ - (void)viewDidLoad { [super viewDidLoad]; - + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; _options = options; - + _service = [[RMTTestService alloc] initWithHost:@"grpc-test.sandbox.googleapis.com" callOptions:_options]; } @@ -49,7 +49,7 @@ RMTSimpleRequest *request = [RMTSimpleRequest message]; request.responseSize = 100; GRPCUnaryProtoCall *call = - [_service unaryCallWithMessage:request responseHandler:self callOptions:nil]; + [_service unaryCallWithMessage:request responseHandler:self callOptions:nil]; [call start]; } @@ -62,3 +62,4 @@ } @end + diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/main.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/main.m index 2797c6f17f2..38ec506adc3 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/main.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/main.m @@ -24,3 +24,4 @@ int main(int argc, char* argv[]) { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } + diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-App/Assets.xcassets/AppIcon.appiconset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-App/Assets.xcassets/AppIcon.appiconset/Contents.json index 6c0f2b4204b..215c1ddfee9 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-App/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/src/objective-c/examples/watchOS-sample/WatchKit-App/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -33,20 +33,6 @@ "role" : "appLauncher", "subtype" : "38mm" }, - { - "size" : "44x44", - "idiom" : "watch", - "scale" : "2x", - "role" : "appLauncher", - "subtype" : "40mm" - }, - { - "size" : "50x50", - "idiom" : "watch", - "scale" : "2x", - "role" : "appLauncher", - "subtype" : "44mm" - }, { "size" : "86x86", "idiom" : "watch", @@ -61,13 +47,6 @@ "role" : "quickLook", "subtype" : "42mm" }, - { - "size" : "108x108", - "idiom" : "watch", - "scale" : "2x", - "role" : "quickLook", - "subtype" : "44mm" - }, { "idiom" : "watch-marketing", "size" : "1024x1024", diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-App/Assets.xcassets/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-App/Assets.xcassets/Contents.json deleted file mode 100644 index da4a164c918..00000000000 --- a/src/objective-c/examples/watchOS-sample/WatchKit-App/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-App/Base.lproj/Interface.storyboard b/src/objective-c/examples/watchOS-sample/WatchKit-App/Base.lproj/Interface.storyboard index 6c4d9248113..b261f45f206 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-App/Base.lproj/Interface.storyboard +++ b/src/objective-c/examples/watchOS-sample/WatchKit-App/Base.lproj/Interface.storyboard @@ -1,12 +1,12 @@ - + - - + + @@ -14,9 +14,9 @@ - diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-App/Info.plist b/src/objective-c/examples/watchOS-sample/WatchKit-App/Info.plist index f0396b31ef7..309d7867639 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-App/Info.plist +++ b/src/objective-c/examples/watchOS-sample/WatchKit-App/Info.plist @@ -26,7 +26,7 @@ UIInterfaceOrientationPortraitUpsideDown WKCompanionAppBundleIdentifier - com.google.watchOS-grpc-sample + com.google.watchOS-sample WKWatchKitApp diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json deleted file mode 100644 index f84499ba516..00000000000 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "images" : [ - { - "idiom" : "watch", - "scale" : "2x", - "screen-width" : "<=145" - }, - { - "idiom" : "watch", - "scale" : "2x", - "screen-width" : ">145" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Contents.json deleted file mode 100644 index 1571c7e531b..00000000000 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Contents.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "assets" : [ - { - "idiom" : "watch", - "filename" : "Circular.imageset", - "role" : "circular" - }, - { - "idiom" : "watch", - "filename" : "Extra Large.imageset", - "role" : "extra-large" - }, - { - "idiom" : "watch", - "filename" : "Graphic Bezel.imageset", - "role" : "graphic-bezel" - }, - { - "idiom" : "watch", - "filename" : "Graphic Circular.imageset", - "role" : "graphic-circular" - }, - { - "idiom" : "watch", - "filename" : "Graphic Corner.imageset", - "role" : "graphic-corner" - }, - { - "idiom" : "watch", - "filename" : "Graphic Large Rectangular.imageset", - "role" : "graphic-large-rectangular" - }, - { - "idiom" : "watch", - "filename" : "Modular.imageset", - "role" : "modular" - }, - { - "idiom" : "watch", - "filename" : "Utilitarian.imageset", - "role" : "utilitarian" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json deleted file mode 100644 index f84499ba516..00000000000 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "images" : [ - { - "idiom" : "watch", - "scale" : "2x", - "screen-width" : "<=145" - }, - { - "idiom" : "watch", - "scale" : "2x", - "screen-width" : ">145" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json deleted file mode 100644 index f84499ba516..00000000000 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "images" : [ - { - "idiom" : "watch", - "scale" : "2x", - "screen-width" : "<=145" - }, - { - "idiom" : "watch", - "scale" : "2x", - "screen-width" : ">145" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json deleted file mode 100644 index f84499ba516..00000000000 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "images" : [ - { - "idiom" : "watch", - "scale" : "2x", - "screen-width" : "<=145" - }, - { - "idiom" : "watch", - "scale" : "2x", - "screen-width" : ">145" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json deleted file mode 100644 index f84499ba516..00000000000 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "images" : [ - { - "idiom" : "watch", - "scale" : "2x", - "screen-width" : "<=145" - }, - { - "idiom" : "watch", - "scale" : "2x", - "screen-width" : ">145" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json deleted file mode 100644 index f84499ba516..00000000000 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "images" : [ - { - "idiom" : "watch", - "scale" : "2x", - "screen-width" : "<=145" - }, - { - "idiom" : "watch", - "scale" : "2x", - "screen-width" : ">145" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json deleted file mode 100644 index f84499ba516..00000000000 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "images" : [ - { - "idiom" : "watch", - "scale" : "2x", - "screen-width" : "<=145" - }, - { - "idiom" : "watch", - "scale" : "2x", - "screen-width" : ">145" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json deleted file mode 100644 index f84499ba516..00000000000 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "images" : [ - { - "idiom" : "watch", - "scale" : "2x", - "screen-width" : "<=145" - }, - { - "idiom" : "watch", - "scale" : "2x", - "screen-width" : ">145" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Contents.json deleted file mode 100644 index da4a164c918..00000000000 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.h b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.h index fbf67335f7d..df3ac1dbe2e 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.h +++ b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.h @@ -21,3 +21,4 @@ @interface ExtensionDelegate : NSObject @end + diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.m b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.m index b64d60256de..d9c9951f264 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.m +++ b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.m @@ -21,3 +21,4 @@ @implementation ExtensionDelegate @end + diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Info.plist b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Info.plist index fcbeef72a4d..bc09fa0f786 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Info.plist +++ b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Info.plist @@ -5,7 +5,7 @@ CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName - WatchKit-Extension + watchOS-sample WatchKit Extension CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier @@ -25,7 +25,7 @@ NSExtensionAttributes WKAppBundleIdentifier - com.google.watchOS-grpc-sample.watchkitapp + com.google.watchOS-sample.watchkitapp NSExtensionPointIdentifier com.apple.watchkit diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.h b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.h index edcc75d5530..24390ac4693 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.h +++ b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.h @@ -22,3 +22,4 @@ @interface InterfaceController : WKInterfaceController @end + diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m index 3e97767cf0c..7ed3a1a0004 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m +++ b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m @@ -36,12 +36,12 @@ - (void)awakeWithContext:(id)context { [super awakeWithContext:context]; - + // Configure interface objects here. - + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; _options = options; - + _service = [[RMTTestService alloc] initWithHost:@"grpc-test.sandbox.googleapis.com" callOptions:_options]; } @@ -50,7 +50,7 @@ RMTSimpleRequest *request = [RMTSimpleRequest message]; request.responseSize = 100; GRPCUnaryProtoCall *call = - [_service unaryCallWithMessage:request responseHandler:self callOptions:nil]; + [_service unaryCallWithMessage:request responseHandler:self callOptions:nil]; [call start]; } diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj index 7f57c514775..ddd91170243 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj @@ -7,59 +7,58 @@ objects = { /* Begin PBXBuildFile section */ - 26FD050F4CCE95ED8CB98A62 /* libPods-watchOS-sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7CD8313B9B59F6F095035EF8 /* libPods-watchOS-sample.a */; }; - A82AA8DDE95C58A13334A932 /* libPods-watchOS-sample WatchKit Extension.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E347FF230AC1FAC0C374BE0C /* libPods-watchOS-sample WatchKit Extension.a */; }; - ABB17D5922D93BAB00C26D6E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D5822D93BAB00C26D6E /* AppDelegate.m */; }; - ABB17D5C22D93BAB00C26D6E /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D5B22D93BAB00C26D6E /* ViewController.m */; }; - ABB17D5F22D93BAB00C26D6E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D5D22D93BAB00C26D6E /* Main.storyboard */; }; - ABB17D6122D93BAC00C26D6E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D6022D93BAC00C26D6E /* Assets.xcassets */; }; - ABB17D6422D93BAC00C26D6E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D6222D93BAC00C26D6E /* LaunchScreen.storyboard */; }; - ABB17D6722D93BAC00C26D6E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D6622D93BAC00C26D6E /* main.m */; }; - ABB17D6B22D93BAC00C26D6E /* watchOS-sample WatchKit App.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = ABB17D6A22D93BAC00C26D6E /* watchOS-sample WatchKit App.app */; }; - ABB17D7122D93BAC00C26D6E /* Interface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D6F22D93BAC00C26D6E /* Interface.storyboard */; }; - ABB17D7322D93BAC00C26D6E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D7222D93BAC00C26D6E /* Assets.xcassets */; }; - ABB17D7A22D93BAC00C26D6E /* watchOS-sample WatchKit Extension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = ABB17D7922D93BAC00C26D6E /* watchOS-sample WatchKit Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; - ABB17D8022D93BAC00C26D6E /* InterfaceController.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D7F22D93BAC00C26D6E /* InterfaceController.m */; }; - ABB17D8322D93BAC00C26D6E /* ExtensionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB17D8222D93BAC00C26D6E /* ExtensionDelegate.m */; }; - ABB17D8522D93BAD00C26D6E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ABB17D8422D93BAD00C26D6E /* Assets.xcassets */; }; + 6DC02D8E4E24CB3EAAA9C0F7 /* libPods-watchOS-sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2D836D6D1793B03D9D9A05E4 /* libPods-watchOS-sample.a */; }; + AB35433822F3A88000C1B2E9 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = AB35433722F3A88000C1B2E9 /* AppDelegate.m */; }; + AB35433B22F3A88000C1B2E9 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AB35433A22F3A88000C1B2E9 /* ViewController.m */; }; + AB35433E22F3A88000C1B2E9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AB35433C22F3A88000C1B2E9 /* Main.storyboard */; }; + AB35434022F3A88000C1B2E9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AB35433F22F3A88000C1B2E9 /* Assets.xcassets */; }; + AB35434322F3A88000C1B2E9 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AB35434122F3A88000C1B2E9 /* LaunchScreen.storyboard */; }; + AB35434622F3A88000C1B2E9 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = AB35434522F3A88000C1B2E9 /* main.m */; }; + AB35434A22F3A88000C1B2E9 /* watchOS-sample WatchKit App.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = AB35434922F3A88000C1B2E9 /* watchOS-sample WatchKit App.app */; }; + AB35435022F3A88000C1B2E9 /* Interface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AB35434E22F3A88000C1B2E9 /* Interface.storyboard */; }; + AB35435222F3A88000C1B2E9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AB35435122F3A88000C1B2E9 /* Assets.xcassets */; }; + AB35435922F3A88000C1B2E9 /* watchOS-sample WatchKit Extension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = AB35435822F3A88000C1B2E9 /* watchOS-sample WatchKit Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + AB35435F22F3A88000C1B2E9 /* InterfaceController.m in Sources */ = {isa = PBXBuildFile; fileRef = AB35435E22F3A88000C1B2E9 /* InterfaceController.m */; }; + AB35436222F3A88000C1B2E9 /* ExtensionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = AB35436122F3A88000C1B2E9 /* ExtensionDelegate.m */; }; + FF523208A6A52E881C6C4CA2 /* libPods-watchOS-sample WatchKit Extension.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C68E1F9D1CE4435317B0009 /* libPods-watchOS-sample WatchKit Extension.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - ABB17D6C22D93BAC00C26D6E /* PBXContainerItemProxy */ = { + AB35434B22F3A88000C1B2E9 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = ABB17D4C22D93BAB00C26D6E /* Project object */; + containerPortal = AB35432B22F3A88000C1B2E9 /* Project object */; proxyType = 1; - remoteGlobalIDString = ABB17D6922D93BAC00C26D6E; + remoteGlobalIDString = AB35434822F3A88000C1B2E9; remoteInfo = "watchOS-sample WatchKit App"; }; - ABB17D7B22D93BAC00C26D6E /* PBXContainerItemProxy */ = { + AB35435A22F3A88000C1B2E9 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = ABB17D4C22D93BAB00C26D6E /* Project object */; + containerPortal = AB35432B22F3A88000C1B2E9 /* Project object */; proxyType = 1; - remoteGlobalIDString = ABB17D7822D93BAC00C26D6E; + remoteGlobalIDString = AB35435722F3A88000C1B2E9; remoteInfo = "watchOS-sample WatchKit Extension"; }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ - ABB17D8C22D93BAD00C26D6E /* Embed App Extensions */ = { + AB35436B22F3A88000C1B2E9 /* Embed App Extensions */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = ""; dstSubfolderSpec = 13; files = ( - ABB17D7A22D93BAC00C26D6E /* watchOS-sample WatchKit Extension.appex in Embed App Extensions */, + AB35435922F3A88000C1B2E9 /* watchOS-sample WatchKit Extension.appex in Embed App Extensions */, ); name = "Embed App Extensions"; runOnlyForDeploymentPostprocessing = 0; }; - ABB17D9022D93BAD00C26D6E /* Embed Watch Content */ = { + AB35436F22F3A88000C1B2E9 /* Embed Watch Content */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = "$(CONTENTS_FOLDER_PATH)/Watch"; dstSubfolderSpec = 16; files = ( - ABB17D6B22D93BAC00C26D6E /* watchOS-sample WatchKit App.app in Embed Watch Content */, + AB35434A22F3A88000C1B2E9 /* watchOS-sample WatchKit App.app in Embed Watch Content */, ); name = "Embed Watch Content"; runOnlyForDeploymentPostprocessing = 0; @@ -67,194 +66,194 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 574DCD2DDCABCC45B2308601 /* Pods-watchOS-sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample.debug.xcconfig"; path = "Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample.debug.xcconfig"; sourceTree = ""; }; - 7CD8313B9B59F6F095035EF8 /* libPods-watchOS-sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-watchOS-sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 957B59E3DE8281B41B6DB3FD /* Pods-watchOS-sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample.release.xcconfig"; path = "Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample.release.xcconfig"; sourceTree = ""; }; - ABB17D5422D93BAB00C26D6E /* watchOS-sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "watchOS-sample.app"; sourceTree = BUILT_PRODUCTS_DIR; }; - ABB17D5722D93BAB00C26D6E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; - ABB17D5822D93BAB00C26D6E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - ABB17D5A22D93BAB00C26D6E /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; - ABB17D5B22D93BAB00C26D6E /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; - ABB17D5E22D93BAB00C26D6E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - ABB17D6022D93BAC00C26D6E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - ABB17D6322D93BAC00C26D6E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; - ABB17D6522D93BAC00C26D6E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - ABB17D6622D93BAC00C26D6E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - ABB17D6A22D93BAC00C26D6E /* watchOS-sample WatchKit App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "watchOS-sample WatchKit App.app"; sourceTree = BUILT_PRODUCTS_DIR; }; - ABB17D7022D93BAC00C26D6E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Interface.storyboard; sourceTree = ""; }; - ABB17D7222D93BAC00C26D6E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - ABB17D7422D93BAC00C26D6E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - ABB17D7922D93BAC00C26D6E /* watchOS-sample WatchKit Extension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "watchOS-sample WatchKit Extension.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; - ABB17D7E22D93BAC00C26D6E /* InterfaceController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InterfaceController.h; sourceTree = ""; }; - ABB17D7F22D93BAC00C26D6E /* InterfaceController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InterfaceController.m; sourceTree = ""; }; - ABB17D8122D93BAC00C26D6E /* ExtensionDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExtensionDelegate.h; sourceTree = ""; }; - ABB17D8222D93BAC00C26D6E /* ExtensionDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ExtensionDelegate.m; sourceTree = ""; }; - ABB17D8422D93BAD00C26D6E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - ABB17D8622D93BAD00C26D6E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - E347FF230AC1FAC0C374BE0C /* libPods-watchOS-sample WatchKit Extension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-watchOS-sample WatchKit Extension.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - EDC6FF21CD9F393E8FDF02F6 /* Pods-watchOS-sample WatchKit Extension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample WatchKit Extension.release.xcconfig"; path = "Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension.release.xcconfig"; sourceTree = ""; }; - FBBABD10A996E7CCA4B2F937 /* Pods-watchOS-sample WatchKit Extension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample WatchKit Extension.debug.xcconfig"; path = "Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension.debug.xcconfig"; sourceTree = ""; }; + 0980DE37FA805E61D7665FC3 /* Pods-watchOS-sample WatchKit Extension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample WatchKit Extension.release.xcconfig"; path = "Pods/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension.release.xcconfig"; sourceTree = ""; }; + 0E281AAFDD87686AFF4DA811 /* Pods-watchOS-sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample.release.xcconfig"; path = "Pods/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample.release.xcconfig"; sourceTree = ""; }; + 2D836D6D1793B03D9D9A05E4 /* libPods-watchOS-sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-watchOS-sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 4C68E1F9D1CE4435317B0009 /* libPods-watchOS-sample WatchKit Extension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-watchOS-sample WatchKit Extension.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 9760150292F726236301FFB4 /* Pods-watchOS-sample WatchKit Extension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample WatchKit Extension.debug.xcconfig"; path = "Pods/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension.debug.xcconfig"; sourceTree = ""; }; + AB35433322F3A88000C1B2E9 /* watchOS-sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "watchOS-sample.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + AB35433622F3A88000C1B2E9 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + AB35433722F3A88000C1B2E9 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + AB35433922F3A88000C1B2E9 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + AB35433A22F3A88000C1B2E9 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + AB35433D22F3A88000C1B2E9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + AB35433F22F3A88000C1B2E9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + AB35434222F3A88000C1B2E9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + AB35434422F3A88000C1B2E9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + AB35434522F3A88000C1B2E9 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + AB35434922F3A88000C1B2E9 /* watchOS-sample WatchKit App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "watchOS-sample WatchKit App.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + AB35434F22F3A88000C1B2E9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Interface.storyboard; sourceTree = ""; }; + AB35435122F3A88000C1B2E9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + AB35435322F3A88000C1B2E9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + AB35435822F3A88000C1B2E9 /* watchOS-sample WatchKit Extension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "watchOS-sample WatchKit Extension.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; + AB35435D22F3A88000C1B2E9 /* InterfaceController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InterfaceController.h; sourceTree = ""; }; + AB35435E22F3A88000C1B2E9 /* InterfaceController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InterfaceController.m; sourceTree = ""; }; + AB35436022F3A88000C1B2E9 /* ExtensionDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExtensionDelegate.h; sourceTree = ""; }; + AB35436122F3A88000C1B2E9 /* ExtensionDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ExtensionDelegate.m; sourceTree = ""; }; + AB35436522F3A88000C1B2E9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + B04FF36D5367E20E26B17EE8 /* Pods-watchOS-sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-watchOS-sample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - ABB17D5122D93BAB00C26D6E /* Frameworks */ = { + 23B5B63423F9068CAAF8C6A8 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 26FD050F4CCE95ED8CB98A62 /* libPods-watchOS-sample.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; - ABB17D7622D93BAC00C26D6E /* Frameworks */ = { + AB35433022F3A88000C1B2E9 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - A82AA8DDE95C58A13334A932 /* libPods-watchOS-sample WatchKit Extension.a in Frameworks */, + 6DC02D8E4E24CB3EAAA9C0F7 /* libPods-watchOS-sample.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; - F374C9EC9D24282B20A64719 /* Frameworks */ = { + AB35435522F3A88000C1B2E9 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + FF523208A6A52E881C6C4CA2 /* libPods-watchOS-sample WatchKit Extension.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 2C4A0708747AAA7298F757DA /* Pods */ = { + 38A0EA6120D821E9244482B4 /* Frameworks */ = { isa = PBXGroup; children = ( - 574DCD2DDCABCC45B2308601 /* Pods-watchOS-sample.debug.xcconfig */, - 957B59E3DE8281B41B6DB3FD /* Pods-watchOS-sample.release.xcconfig */, - FBBABD10A996E7CCA4B2F937 /* Pods-watchOS-sample WatchKit Extension.debug.xcconfig */, - EDC6FF21CD9F393E8FDF02F6 /* Pods-watchOS-sample WatchKit Extension.release.xcconfig */, + 2D836D6D1793B03D9D9A05E4 /* libPods-watchOS-sample.a */, + 4C68E1F9D1CE4435317B0009 /* libPods-watchOS-sample WatchKit Extension.a */, ); - path = Pods; + name = Frameworks; sourceTree = ""; }; - ABB17D4B22D93BAB00C26D6E = { + 93EDCC6DB32E10D3C92C69E5 /* Pods */ = { isa = PBXGroup; children = ( - ABB17D5622D93BAB00C26D6E /* watchOS-sample */, - ABB17D6E22D93BAC00C26D6E /* WatchKit-App */, - ABB17D7D22D93BAC00C26D6E /* WatchKit-Extension */, - ABB17D5522D93BAB00C26D6E /* Products */, - 2C4A0708747AAA7298F757DA /* Pods */, - FDB2CA47351660A961DBE458 /* Frameworks */, + B04FF36D5367E20E26B17EE8 /* Pods-watchOS-sample.debug.xcconfig */, + 0E281AAFDD87686AFF4DA811 /* Pods-watchOS-sample.release.xcconfig */, + 9760150292F726236301FFB4 /* Pods-watchOS-sample WatchKit Extension.debug.xcconfig */, + 0980DE37FA805E61D7665FC3 /* Pods-watchOS-sample WatchKit Extension.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + AB35432A22F3A88000C1B2E9 = { + isa = PBXGroup; + children = ( + AB35433522F3A88000C1B2E9 /* watchOS-sample */, + AB35434D22F3A88000C1B2E9 /* WatchKit-App */, + AB35435C22F3A88000C1B2E9 /* WatchKit-Extension */, + AB35433422F3A88000C1B2E9 /* Products */, + 93EDCC6DB32E10D3C92C69E5 /* Pods */, + 38A0EA6120D821E9244482B4 /* Frameworks */, ); sourceTree = ""; }; - ABB17D5522D93BAB00C26D6E /* Products */ = { + AB35433422F3A88000C1B2E9 /* Products */ = { isa = PBXGroup; children = ( - ABB17D5422D93BAB00C26D6E /* watchOS-sample.app */, - ABB17D6A22D93BAC00C26D6E /* watchOS-sample WatchKit App.app */, - ABB17D7922D93BAC00C26D6E /* watchOS-sample WatchKit Extension.appex */, + AB35433322F3A88000C1B2E9 /* watchOS-sample.app */, + AB35434922F3A88000C1B2E9 /* watchOS-sample WatchKit App.app */, + AB35435822F3A88000C1B2E9 /* watchOS-sample WatchKit Extension.appex */, ); name = Products; sourceTree = ""; }; - ABB17D5622D93BAB00C26D6E /* watchOS-sample */ = { + AB35433522F3A88000C1B2E9 /* watchOS-sample */ = { isa = PBXGroup; children = ( - ABB17D5722D93BAB00C26D6E /* AppDelegate.h */, - ABB17D5822D93BAB00C26D6E /* AppDelegate.m */, - ABB17D5A22D93BAB00C26D6E /* ViewController.h */, - ABB17D5B22D93BAB00C26D6E /* ViewController.m */, - ABB17D5D22D93BAB00C26D6E /* Main.storyboard */, - ABB17D6022D93BAC00C26D6E /* Assets.xcassets */, - ABB17D6222D93BAC00C26D6E /* LaunchScreen.storyboard */, - ABB17D6522D93BAC00C26D6E /* Info.plist */, - ABB17D6622D93BAC00C26D6E /* main.m */, + AB35433622F3A88000C1B2E9 /* AppDelegate.h */, + AB35433722F3A88000C1B2E9 /* AppDelegate.m */, + AB35433922F3A88000C1B2E9 /* ViewController.h */, + AB35433A22F3A88000C1B2E9 /* ViewController.m */, + AB35433C22F3A88000C1B2E9 /* Main.storyboard */, + AB35433F22F3A88000C1B2E9 /* Assets.xcassets */, + AB35434122F3A88000C1B2E9 /* LaunchScreen.storyboard */, + AB35434422F3A88000C1B2E9 /* Info.plist */, + AB35434522F3A88000C1B2E9 /* main.m */, ); path = "watchOS-sample"; sourceTree = ""; }; - ABB17D6E22D93BAC00C26D6E /* WatchKit-App */ = { + AB35434D22F3A88000C1B2E9 /* WatchKit-App */ = { isa = PBXGroup; children = ( - ABB17D6F22D93BAC00C26D6E /* Interface.storyboard */, - ABB17D7222D93BAC00C26D6E /* Assets.xcassets */, - ABB17D7422D93BAC00C26D6E /* Info.plist */, + AB35434E22F3A88000C1B2E9 /* Interface.storyboard */, + AB35435122F3A88000C1B2E9 /* Assets.xcassets */, + AB35435322F3A88000C1B2E9 /* Info.plist */, ); path = "WatchKit-App"; sourceTree = ""; }; - ABB17D7D22D93BAC00C26D6E /* WatchKit-Extension */ = { + AB35435C22F3A88000C1B2E9 /* WatchKit-Extension */ = { isa = PBXGroup; children = ( - ABB17D7E22D93BAC00C26D6E /* InterfaceController.h */, - ABB17D7F22D93BAC00C26D6E /* InterfaceController.m */, - ABB17D8122D93BAC00C26D6E /* ExtensionDelegate.h */, - ABB17D8222D93BAC00C26D6E /* ExtensionDelegate.m */, - ABB17D8422D93BAD00C26D6E /* Assets.xcassets */, - ABB17D8622D93BAD00C26D6E /* Info.plist */, + AB35435D22F3A88000C1B2E9 /* InterfaceController.h */, + AB35435E22F3A88000C1B2E9 /* InterfaceController.m */, + AB35436022F3A88000C1B2E9 /* ExtensionDelegate.h */, + AB35436122F3A88000C1B2E9 /* ExtensionDelegate.m */, + AB35436522F3A88000C1B2E9 /* Info.plist */, ); path = "WatchKit-Extension"; sourceTree = ""; }; - FDB2CA47351660A961DBE458 /* Frameworks */ = { - isa = PBXGroup; - children = ( - 7CD8313B9B59F6F095035EF8 /* libPods-watchOS-sample.a */, - E347FF230AC1FAC0C374BE0C /* libPods-watchOS-sample WatchKit Extension.a */, - ); - name = Frameworks; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - ABB17D5322D93BAB00C26D6E /* watchOS-sample */ = { + AB35433222F3A88000C1B2E9 /* watchOS-sample */ = { isa = PBXNativeTarget; - buildConfigurationList = ABB17D9122D93BAD00C26D6E /* Build configuration list for PBXNativeTarget "watchOS-sample" */; + buildConfigurationList = AB35437022F3A88000C1B2E9 /* Build configuration list for PBXNativeTarget "watchOS-sample" */; buildPhases = ( - C094DF31B83C380F13D80132 /* [CP] Check Pods Manifest.lock */, - ABB17D5022D93BAB00C26D6E /* Sources */, - ABB17D5122D93BAB00C26D6E /* Frameworks */, - ABB17D5222D93BAB00C26D6E /* Resources */, - ABB17D9022D93BAD00C26D6E /* Embed Watch Content */, - 9A5D1B4A7574524FF0BB9310 /* [CP] Copy Pods Resources */, + 7CBBF7FBEB5B8AB30A349E22 /* [CP] Check Pods Manifest.lock */, + AB35432F22F3A88000C1B2E9 /* Sources */, + AB35433022F3A88000C1B2E9 /* Frameworks */, + AB35433122F3A88000C1B2E9 /* Resources */, + AB35436F22F3A88000C1B2E9 /* Embed Watch Content */, + 5644E359E6C67CF9FD7B659D /* [CP] Embed Pods Frameworks */, + 42609F71FF3FEF23C402967B /* [CP] Copy Pods Resources */, ); buildRules = ( ); dependencies = ( - ABB17D6D22D93BAC00C26D6E /* PBXTargetDependency */, + AB35434C22F3A88000C1B2E9 /* PBXTargetDependency */, ); name = "watchOS-sample"; productName = "watchOS-sample"; - productReference = ABB17D5422D93BAB00C26D6E /* watchOS-sample.app */; + productReference = AB35433322F3A88000C1B2E9 /* watchOS-sample.app */; productType = "com.apple.product-type.application"; }; - ABB17D6922D93BAC00C26D6E /* watchOS-sample WatchKit App */ = { + AB35434822F3A88000C1B2E9 /* watchOS-sample WatchKit App */ = { isa = PBXNativeTarget; - buildConfigurationList = ABB17D8D22D93BAD00C26D6E /* Build configuration list for PBXNativeTarget "watchOS-sample WatchKit App" */; + buildConfigurationList = AB35436C22F3A88000C1B2E9 /* Build configuration list for PBXNativeTarget "watchOS-sample WatchKit App" */; buildPhases = ( - ABB17D6822D93BAC00C26D6E /* Resources */, - ABB17D8C22D93BAD00C26D6E /* Embed App Extensions */, - F374C9EC9D24282B20A64719 /* Frameworks */, + AB35434722F3A88000C1B2E9 /* Resources */, + AB35436B22F3A88000C1B2E9 /* Embed App Extensions */, + 23B5B63423F9068CAAF8C6A8 /* Frameworks */, ); buildRules = ( ); dependencies = ( - ABB17D7C22D93BAC00C26D6E /* PBXTargetDependency */, + AB35435B22F3A88000C1B2E9 /* PBXTargetDependency */, ); name = "watchOS-sample WatchKit App"; productName = "watchOS-sample WatchKit App"; - productReference = ABB17D6A22D93BAC00C26D6E /* watchOS-sample WatchKit App.app */; + productReference = AB35434922F3A88000C1B2E9 /* watchOS-sample WatchKit App.app */; productType = "com.apple.product-type.application.watchapp2"; }; - ABB17D7822D93BAC00C26D6E /* watchOS-sample WatchKit Extension */ = { + AB35435722F3A88000C1B2E9 /* watchOS-sample WatchKit Extension */ = { isa = PBXNativeTarget; - buildConfigurationList = ABB17D8922D93BAD00C26D6E /* Build configuration list for PBXNativeTarget "watchOS-sample WatchKit Extension" */; + buildConfigurationList = AB35436822F3A88000C1B2E9 /* Build configuration list for PBXNativeTarget "watchOS-sample WatchKit Extension" */; buildPhases = ( - 370B91D5CA71A3A771721814 /* [CP] Check Pods Manifest.lock */, - ABB17D7522D93BAC00C26D6E /* Sources */, - ABB17D7622D93BAC00C26D6E /* Frameworks */, - ABB17D7722D93BAC00C26D6E /* Resources */, - 7246FFBCAD3F9270364EFC9E /* [CP] Copy Pods Resources */, + C80BFB1E1525B018E6C87AF0 /* [CP] Check Pods Manifest.lock */, + AB35435422F3A88000C1B2E9 /* Sources */, + AB35435522F3A88000C1B2E9 /* Frameworks */, + AB35435622F3A88000C1B2E9 /* Resources */, + E0C622F545CB8A6103793708 /* [CP] Embed Pods Frameworks */, + D202361DA337959ACDB8D358 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -262,33 +261,33 @@ ); name = "watchOS-sample WatchKit Extension"; productName = "watchOS-sample WatchKit Extension"; - productReference = ABB17D7922D93BAC00C26D6E /* watchOS-sample WatchKit Extension.appex */; + productReference = AB35435822F3A88000C1B2E9 /* watchOS-sample WatchKit Extension.appex */; productType = "com.apple.product-type.watchkit2-extension"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ - ABB17D4C22D93BAB00C26D6E /* Project object */ = { + AB35432B22F3A88000C1B2E9 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1010; + LastUpgradeCheck = 0920; ORGANIZATIONNAME = "Tony Lu"; TargetAttributes = { - ABB17D5322D93BAB00C26D6E = { - CreatedOnToolsVersion = 10.1; + AB35433222F3A88000C1B2E9 = { + CreatedOnToolsVersion = 9.2; ProvisioningStyle = Automatic; }; - ABB17D6922D93BAC00C26D6E = { - CreatedOnToolsVersion = 10.1; + AB35434822F3A88000C1B2E9 = { + CreatedOnToolsVersion = 9.2; ProvisioningStyle = Automatic; }; - ABB17D7822D93BAC00C26D6E = { - CreatedOnToolsVersion = 10.1; + AB35435722F3A88000C1B2E9 = { + CreatedOnToolsVersion = 9.2; ProvisioningStyle = Automatic; }; }; }; - buildConfigurationList = ABB17D4F22D93BAB00C26D6E /* Build configuration list for PBXProject "watchOS-sample" */; + buildConfigurationList = AB35432E22F3A88000C1B2E9 /* Build configuration list for PBXProject "watchOS-sample" */; compatibilityVersion = "Xcode 8.0"; developmentRegion = en; hasScannedForEncodings = 0; @@ -296,113 +295,120 @@ en, Base, ); - mainGroup = ABB17D4B22D93BAB00C26D6E; - productRefGroup = ABB17D5522D93BAB00C26D6E /* Products */; + mainGroup = AB35432A22F3A88000C1B2E9; + productRefGroup = AB35433422F3A88000C1B2E9 /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( - ABB17D5322D93BAB00C26D6E /* watchOS-sample */, - ABB17D6922D93BAC00C26D6E /* watchOS-sample WatchKit App */, - ABB17D7822D93BAC00C26D6E /* watchOS-sample WatchKit Extension */, + AB35433222F3A88000C1B2E9 /* watchOS-sample */, + AB35434822F3A88000C1B2E9 /* watchOS-sample WatchKit App */, + AB35435722F3A88000C1B2E9 /* watchOS-sample WatchKit Extension */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ - ABB17D5222D93BAB00C26D6E /* Resources */ = { + AB35433122F3A88000C1B2E9 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - ABB17D6422D93BAC00C26D6E /* LaunchScreen.storyboard in Resources */, - ABB17D6122D93BAC00C26D6E /* Assets.xcassets in Resources */, - ABB17D5F22D93BAB00C26D6E /* Main.storyboard in Resources */, + AB35434322F3A88000C1B2E9 /* LaunchScreen.storyboard in Resources */, + AB35434022F3A88000C1B2E9 /* Assets.xcassets in Resources */, + AB35433E22F3A88000C1B2E9 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; - ABB17D6822D93BAC00C26D6E /* Resources */ = { + AB35434722F3A88000C1B2E9 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - ABB17D7322D93BAC00C26D6E /* Assets.xcassets in Resources */, - ABB17D7122D93BAC00C26D6E /* Interface.storyboard in Resources */, + AB35435222F3A88000C1B2E9 /* Assets.xcassets in Resources */, + AB35435022F3A88000C1B2E9 /* Interface.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; - ABB17D7722D93BAC00C26D6E /* Resources */ = { + AB35435622F3A88000C1B2E9 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - ABB17D8522D93BAD00C26D6E /* Assets.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 370B91D5CA71A3A771721814 /* [CP] Check Pods Manifest.lock */ = { + 42609F71FF3FEF23C402967B /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); + inputFileListPaths = ( + ); + inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-resources.sh", + "$PODS_CONFIGURATION_BUILD_DIR/gRPC-iOS/gRPCCertificates.bundle", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + ); + outputPaths = ( + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 5644E359E6C67CF9FD7B659D /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/BoringSSL-GRPC-iOS/openssl_grpc.framework", + "${BUILT_PRODUCTS_DIR}/Protobuf-iOS/Protobuf.framework", + "${BUILT_PRODUCTS_DIR}/RemoteTest-iOS/RemoteTest.framework", + "${BUILT_PRODUCTS_DIR}/gRPC-iOS/GRPCClient.framework", + "${BUILT_PRODUCTS_DIR}/gRPC-Core-iOS/grpc.framework", + "${BUILT_PRODUCTS_DIR}/gRPC-ProtoRPC-iOS/ProtoRPC.framework", + "${BUILT_PRODUCTS_DIR}/gRPC-RxLibrary-iOS/RxLibrary.framework", + "${BUILT_PRODUCTS_DIR}/nanopb-iOS/nanopb.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + ); + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/openssl_grpc.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RemoteTest.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GRPCClient.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/grpc.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ProtoRPC.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxLibrary.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 7CBBF7FBEB5B8AB30A349E22 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); inputPaths = ( "${PODS_PODFILE_DIR_PATH}/Podfile.lock", "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-watchOS-sample WatchKit Extension-checkManifestLockResult.txt", + outputFileListPaths = ( ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 7246FFBCAD3F9270364EFC9E /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-watchOS/gRPCCertificates.bundle", - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 9A5D1B4A7574524FF0BB9310 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - C094DF31B83C380F13D80132 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; outputPaths = ( "$(DERIVED_FILE_DIR)/Pods-watchOS-sample-checkManifestLockResult.txt", ); @@ -411,64 +417,144 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + C80BFB1E1525B018E6C87AF0 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-watchOS-sample WatchKit Extension-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + D202361DA337959ACDB8D358 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-resources.sh", + "$PODS_CONFIGURATION_BUILD_DIR/gRPC-watchOS/gRPCCertificates.bundle", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + ); + outputPaths = ( + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + E0C622F545CB8A6103793708 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/BoringSSL-GRPC-watchOS/openssl_grpc.framework", + "${BUILT_PRODUCTS_DIR}/Protobuf-watchOS/Protobuf.framework", + "${BUILT_PRODUCTS_DIR}/RemoteTest-watchOS/RemoteTest.framework", + "${BUILT_PRODUCTS_DIR}/gRPC-watchOS/GRPCClient.framework", + "${BUILT_PRODUCTS_DIR}/gRPC-Core-watchOS/grpc.framework", + "${BUILT_PRODUCTS_DIR}/gRPC-ProtoRPC-watchOS/ProtoRPC.framework", + "${BUILT_PRODUCTS_DIR}/gRPC-RxLibrary-watchOS/RxLibrary.framework", + "${BUILT_PRODUCTS_DIR}/nanopb-watchOS/nanopb.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + ); + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/openssl_grpc.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RemoteTest.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GRPCClient.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/grpc.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ProtoRPC.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxLibrary.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ - ABB17D5022D93BAB00C26D6E /* Sources */ = { + AB35432F22F3A88000C1B2E9 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - ABB17D5C22D93BAB00C26D6E /* ViewController.m in Sources */, - ABB17D6722D93BAC00C26D6E /* main.m in Sources */, - ABB17D5922D93BAB00C26D6E /* AppDelegate.m in Sources */, + AB35433B22F3A88000C1B2E9 /* ViewController.m in Sources */, + AB35434622F3A88000C1B2E9 /* main.m in Sources */, + AB35433822F3A88000C1B2E9 /* AppDelegate.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; - ABB17D7522D93BAC00C26D6E /* Sources */ = { + AB35435422F3A88000C1B2E9 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - ABB17D8322D93BAC00C26D6E /* ExtensionDelegate.m in Sources */, - ABB17D8022D93BAC00C26D6E /* InterfaceController.m in Sources */, + AB35436222F3A88000C1B2E9 /* ExtensionDelegate.m in Sources */, + AB35435F22F3A88000C1B2E9 /* InterfaceController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - ABB17D6D22D93BAC00C26D6E /* PBXTargetDependency */ = { + AB35434C22F3A88000C1B2E9 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = ABB17D6922D93BAC00C26D6E /* watchOS-sample WatchKit App */; - targetProxy = ABB17D6C22D93BAC00C26D6E /* PBXContainerItemProxy */; + target = AB35434822F3A88000C1B2E9 /* watchOS-sample WatchKit App */; + targetProxy = AB35434B22F3A88000C1B2E9 /* PBXContainerItemProxy */; }; - ABB17D7C22D93BAC00C26D6E /* PBXTargetDependency */ = { + AB35435B22F3A88000C1B2E9 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = ABB17D7822D93BAC00C26D6E /* watchOS-sample WatchKit Extension */; - targetProxy = ABB17D7B22D93BAC00C26D6E /* PBXContainerItemProxy */; + target = AB35435722F3A88000C1B2E9 /* watchOS-sample WatchKit Extension */; + targetProxy = AB35435A22F3A88000C1B2E9 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ - ABB17D5D22D93BAB00C26D6E /* Main.storyboard */ = { + AB35433C22F3A88000C1B2E9 /* Main.storyboard */ = { isa = PBXVariantGroup; children = ( - ABB17D5E22D93BAB00C26D6E /* Base */, + AB35433D22F3A88000C1B2E9 /* Base */, ); name = Main.storyboard; sourceTree = ""; }; - ABB17D6222D93BAC00C26D6E /* LaunchScreen.storyboard */ = { + AB35434122F3A88000C1B2E9 /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( - ABB17D6322D93BAC00C26D6E /* Base */, + AB35434222F3A88000C1B2E9 /* Base */, ); name = LaunchScreen.storyboard; sourceTree = ""; }; - ABB17D6F22D93BAC00C26D6E /* Interface.storyboard */ = { + AB35434E22F3A88000C1B2E9 /* Interface.storyboard */ = { isa = PBXVariantGroup; children = ( - ABB17D7022D93BAC00C26D6E /* Base */, + AB35434F22F3A88000C1B2E9 /* Base */, ); name = Interface.storyboard; sourceTree = ""; @@ -476,7 +562,7 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ - ABB17D8722D93BAD00C26D6E /* Debug */ = { + AB35436622F3A88000C1B2E9 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -486,12 +572,10 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -499,7 +583,6 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -527,15 +610,14 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; }; name = Debug; }; - ABB17D8822D93BAD00C26D6E /* Release */ = { + AB35436722F3A88000C1B2E9 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -545,12 +627,10 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -558,7 +638,6 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -580,24 +659,23 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; name = Release; }; - ABB17D8A22D93BAD00C26D6E /* Debug */ = { + AB35436922F3A88000C1B2E9 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = FBBABD10A996E7CCA4B2F937 /* Pods-watchOS-sample WatchKit Extension.debug.xcconfig */; + baseConfigurationReference = 9760150292F726236301FFB4 /* Pods-watchOS-sample WatchKit Extension.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6T98ZJNPG5; INFOPLIST_FILE = "$(SRCROOT)/WatchKit-Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample.watchkitapp.watchkitextension"; + PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-sample.watchkitapp.watchkitextension"; PRODUCT_NAME = "${TARGET_NAME}"; SDKROOT = watchos; SKIP_INSTALL = YES; @@ -606,16 +684,16 @@ }; name = Debug; }; - ABB17D8B22D93BAD00C26D6E /* Release */ = { + AB35436A22F3A88000C1B2E9 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = EDC6FF21CD9F393E8FDF02F6 /* Pods-watchOS-sample WatchKit Extension.release.xcconfig */; + baseConfigurationReference = 0980DE37FA805E61D7665FC3 /* Pods-watchOS-sample WatchKit Extension.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6T98ZJNPG5; INFOPLIST_FILE = "$(SRCROOT)/WatchKit-Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample.watchkitapp.watchkitextension"; + PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-sample.watchkitapp.watchkitextension"; PRODUCT_NAME = "${TARGET_NAME}"; SDKROOT = watchos; SKIP_INSTALL = YES; @@ -624,7 +702,7 @@ }; name = Release; }; - ABB17D8E22D93BAD00C26D6E /* Debug */ = { + AB35436D22F3A88000C1B2E9 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; @@ -632,7 +710,7 @@ DEVELOPMENT_TEAM = 6T98ZJNPG5; IBSC_MODULE = watchOS_sample_WatchKit_Extension; INFOPLIST_FILE = "$(SRCROOT)/WatchKit-App/Info.plist"; - PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample.watchkitapp"; + PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-sample.watchkitapp"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = watchos; SKIP_INSTALL = YES; @@ -641,7 +719,7 @@ }; name = Debug; }; - ABB17D8F22D93BAD00C26D6E /* Release */ = { + AB35436E22F3A88000C1B2E9 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; @@ -649,7 +727,7 @@ DEVELOPMENT_TEAM = 6T98ZJNPG5; IBSC_MODULE = watchOS_sample_WatchKit_Extension; INFOPLIST_FILE = "$(SRCROOT)/WatchKit-App/Info.plist"; - PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample.watchkitapp"; + PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-sample.watchkitapp"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = watchos; SKIP_INSTALL = YES; @@ -658,31 +736,31 @@ }; name = Release; }; - ABB17D9222D93BAD00C26D6E /* Debug */ = { + AB35437122F3A88000C1B2E9 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 574DCD2DDCABCC45B2308601 /* Pods-watchOS-sample.debug.xcconfig */; + baseConfigurationReference = B04FF36D5367E20E26B17EE8 /* Pods-watchOS-sample.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6T98ZJNPG5; INFOPLIST_FILE = "watchOS-sample/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample"; + PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-sample"; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; - ABB17D9322D93BAD00C26D6E /* Release */ = { + AB35437222F3A88000C1B2E9 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 957B59E3DE8281B41B6DB3FD /* Pods-watchOS-sample.release.xcconfig */; + baseConfigurationReference = 0E281AAFDD87686AFF4DA811 /* Pods-watchOS-sample.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6T98ZJNPG5; INFOPLIST_FILE = "watchOS-sample/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-grpc-sample"; + PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-sample"; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -691,43 +769,43 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - ABB17D4F22D93BAB00C26D6E /* Build configuration list for PBXProject "watchOS-sample" */ = { + AB35432E22F3A88000C1B2E9 /* Build configuration list for PBXProject "watchOS-sample" */ = { isa = XCConfigurationList; buildConfigurations = ( - ABB17D8722D93BAD00C26D6E /* Debug */, - ABB17D8822D93BAD00C26D6E /* Release */, + AB35436622F3A88000C1B2E9 /* Debug */, + AB35436722F3A88000C1B2E9 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - ABB17D8922D93BAD00C26D6E /* Build configuration list for PBXNativeTarget "watchOS-sample WatchKit Extension" */ = { + AB35436822F3A88000C1B2E9 /* Build configuration list for PBXNativeTarget "watchOS-sample WatchKit Extension" */ = { isa = XCConfigurationList; buildConfigurations = ( - ABB17D8A22D93BAD00C26D6E /* Debug */, - ABB17D8B22D93BAD00C26D6E /* Release */, + AB35436922F3A88000C1B2E9 /* Debug */, + AB35436A22F3A88000C1B2E9 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - ABB17D8D22D93BAD00C26D6E /* Build configuration list for PBXNativeTarget "watchOS-sample WatchKit App" */ = { + AB35436C22F3A88000C1B2E9 /* Build configuration list for PBXNativeTarget "watchOS-sample WatchKit App" */ = { isa = XCConfigurationList; buildConfigurations = ( - ABB17D8E22D93BAD00C26D6E /* Debug */, - ABB17D8F22D93BAD00C26D6E /* Release */, + AB35436D22F3A88000C1B2E9 /* Debug */, + AB35436E22F3A88000C1B2E9 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - ABB17D9122D93BAD00C26D6E /* Build configuration list for PBXNativeTarget "watchOS-sample" */ = { + AB35437022F3A88000C1B2E9 /* Build configuration list for PBXNativeTarget "watchOS-sample" */ = { isa = XCConfigurationList; buildConfigurations = ( - ABB17D9222D93BAD00C26D6E /* Debug */, - ABB17D9322D93BAD00C26D6E /* Release */, + AB35437122F3A88000C1B2E9 /* Debug */, + AB35437222F3A88000C1B2E9 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; - rootObject = ABB17D4C22D93BAB00C26D6E /* Project object */; + rootObject = AB35432B22F3A88000C1B2E9 /* Project object */; } diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample WatchKit App.xcscheme b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample WatchKit App.xcscheme deleted file mode 100644 index 7c7e35eea14..00000000000 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample WatchKit App.xcscheme +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample.xcscheme b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample.xcscheme deleted file mode 100644 index 51e4fa09792..00000000000 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample.xcscheme +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m b/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m index 4a76f4c488c..2a0849df3d4 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m @@ -25,3 +25,4 @@ @implementation AppDelegate @end + diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/Assets.xcassets/AppIcon.appiconset/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample/Assets.xcassets/AppIcon.appiconset/Contents.json index d8db8d65fd7..1d060ed2882 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -84,11 +84,6 @@ "idiom" : "ipad", "size" : "83.5x83.5", "scale" : "2x" - }, - { - "idiom" : "ios-marketing", - "size" : "1024x1024", - "scale" : "1x" } ], "info" : { diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/Assets.xcassets/Contents.json b/src/objective-c/examples/watchOS-sample/watchOS-sample/Assets.xcassets/Contents.json deleted file mode 100644 index da4a164c918..00000000000 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/Base.lproj/LaunchScreen.storyboard b/src/objective-c/examples/watchOS-sample/watchOS-sample/Base.lproj/LaunchScreen.storyboard index bfa36129419..f83f6fd5810 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/Base.lproj/LaunchScreen.storyboard +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/Base.lproj/LaunchScreen.storyboard @@ -1,5 +1,5 @@ - + diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/Base.lproj/Main.storyboard b/src/objective-c/examples/watchOS-sample/watchOS-sample/Base.lproj/Main.storyboard index 123b8115aa4..06af18034ab 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/Base.lproj/Main.storyboard +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ - + diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m index 4bc98912bf9..49ffd668163 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m @@ -25,3 +25,4 @@ @implementation ViewController @end + diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/main.m b/src/objective-c/examples/watchOS-sample/watchOS-sample/main.m index 2797c6f17f2..38ec506adc3 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/main.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/main.m @@ -24,3 +24,4 @@ int main(int argc, char* argv[]) { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } + From 36af2bcce205691d87010967a4d18c3d5b000648 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Fri, 2 Aug 2019 10:12:40 -0700 Subject: [PATCH 1080/1555] Added build schemes --- .../xcschemes/tvOS-sample.xcscheme | 93 +++++++++++++ .../watchOS-sample-WatchKit-App.xcscheme | 129 ++++++++++++++++++ 2 files changed, 222 insertions(+) create mode 100644 src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/xcshareddata/xcschemes/tvOS-sample.xcscheme create mode 100644 src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample-WatchKit-App.xcscheme diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/xcshareddata/xcschemes/tvOS-sample.xcscheme b/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/xcshareddata/xcschemes/tvOS-sample.xcscheme new file mode 100644 index 00000000000..1223d0933b4 --- /dev/null +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/xcshareddata/xcschemes/tvOS-sample.xcscheme @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample-WatchKit-App.xcscheme b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample-WatchKit-App.xcscheme new file mode 100644 index 00000000000..20a5f02ba8f --- /dev/null +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/xcshareddata/xcschemes/watchOS-sample-WatchKit-App.xcscheme @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 2aeb7dc28fa01dfbdde231c37333597782aa149a Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Fri, 2 Aug 2019 10:18:32 -0700 Subject: [PATCH 1081/1555] Fixed clang_format_code --- .../examples/tvOS-sample/tvOS-sample/AppDelegate.m | 1 - .../examples/tvOS-sample/tvOS-sample/ViewController.m | 7 +++---- src/objective-c/examples/tvOS-sample/tvOS-sample/main.m | 1 - .../watchOS-sample/WatchKit-Extension/ExtensionDelegate.h | 1 - .../watchOS-sample/WatchKit-Extension/ExtensionDelegate.m | 1 - .../WatchKit-Extension/InterfaceController.h | 1 - .../WatchKit-Extension/InterfaceController.m | 8 ++++---- .../examples/watchOS-sample/watchOS-sample/AppDelegate.m | 1 - .../watchOS-sample/watchOS-sample/ViewController.m | 1 - .../examples/watchOS-sample/watchOS-sample/main.m | 1 - 10 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m index 2a0849df3d4..4a76f4c488c 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.m @@ -25,4 +25,3 @@ @implementation AppDelegate @end - diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m index 76f172bef0c..c94ee8c2569 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m @@ -37,10 +37,10 @@ - (void)viewDidLoad { [super viewDidLoad]; - + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; _options = options; - + _service = [[RMTTestService alloc] initWithHost:@"grpc-test.sandbox.googleapis.com" callOptions:_options]; } @@ -49,7 +49,7 @@ RMTSimpleRequest *request = [RMTSimpleRequest message]; request.responseSize = 100; GRPCUnaryProtoCall *call = - [_service unaryCallWithMessage:request responseHandler:self callOptions:nil]; + [_service unaryCallWithMessage:request responseHandler:self callOptions:nil]; [call start]; } @@ -62,4 +62,3 @@ } @end - diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/main.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/main.m index 38ec506adc3..2797c6f17f2 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/main.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/main.m @@ -24,4 +24,3 @@ int main(int argc, char* argv[]) { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } - diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.h b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.h index df3ac1dbe2e..fbf67335f7d 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.h +++ b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.h @@ -21,4 +21,3 @@ @interface ExtensionDelegate : NSObject @end - diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.m b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.m index d9c9951f264..b64d60256de 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.m +++ b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.m @@ -21,4 +21,3 @@ @implementation ExtensionDelegate @end - diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.h b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.h index 24390ac4693..edcc75d5530 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.h +++ b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.h @@ -22,4 +22,3 @@ @interface InterfaceController : WKInterfaceController @end - diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m index 7ed3a1a0004..3e97767cf0c 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m +++ b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m @@ -36,12 +36,12 @@ - (void)awakeWithContext:(id)context { [super awakeWithContext:context]; - + // Configure interface objects here. - + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; _options = options; - + _service = [[RMTTestService alloc] initWithHost:@"grpc-test.sandbox.googleapis.com" callOptions:_options]; } @@ -50,7 +50,7 @@ RMTSimpleRequest *request = [RMTSimpleRequest message]; request.responseSize = 100; GRPCUnaryProtoCall *call = - [_service unaryCallWithMessage:request responseHandler:self callOptions:nil]; + [_service unaryCallWithMessage:request responseHandler:self callOptions:nil]; [call start]; } diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m b/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m index 2a0849df3d4..4a76f4c488c 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.m @@ -25,4 +25,3 @@ @implementation AppDelegate @end - diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m index 49ffd668163..4bc98912bf9 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/ViewController.m @@ -25,4 +25,3 @@ @implementation ViewController @end - diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/main.m b/src/objective-c/examples/watchOS-sample/watchOS-sample/main.m index 38ec506adc3..2797c6f17f2 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/main.m +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/main.m @@ -24,4 +24,3 @@ int main(int argc, char* argv[]) { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } - From f054bd73f48111536be316631cc7ef3d57b8c837 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Fri, 2 Aug 2019 14:47:18 -0700 Subject: [PATCH 1082/1555] Compensate for missing upb dependencies --- bazel/test/python_test_repo/WORKSPACE | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bazel/test/python_test_repo/WORKSPACE b/bazel/test/python_test_repo/WORKSPACE index 69d34ac933c..29bec643f96 100644 --- a/bazel/test/python_test_repo/WORKSPACE +++ b/bazel/test/python_test_repo/WORKSPACE @@ -8,3 +8,9 @@ grpc_deps() load("@com_github_grpc_grpc//bazel:grpc_python_deps.bzl", "grpc_python_deps") grpc_python_deps() + + +# TODO(https://github.com/grpc/grpc/issues/19835): Remove. +load("@upb//bazel:workspace_deps.bzl", "upb_deps") +upb_deps() + From 5ab60a849bbd16956df54578278a9304fd07b9c9 Mon Sep 17 00:00:00 2001 From: yang-g Date: Fri, 2 Aug 2019 14:55:11 -0700 Subject: [PATCH 1083/1555] dead code removal --- src/core/lib/iomgr/exec_ctx.cc | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/core/lib/iomgr/exec_ctx.cc b/src/core/lib/iomgr/exec_ctx.cc index f45def43397..a847b4dcefc 100644 --- a/src/core/lib/iomgr/exec_ctx.cc +++ b/src/core/lib/iomgr/exec_ctx.cc @@ -53,13 +53,6 @@ static void exec_ctx_sched(grpc_closure* closure, grpc_error* error) { static gpr_timespec g_start_time; -// For debug of the timer manager crash only. -// TODO (mxyan): remove after bug is fixed. -#ifdef GRPC_DEBUG_TIMER_MANAGER -extern int64_t g_start_time_sec; -extern int64_t g_start_time_nsec; -#endif // GRPC_DEBUG_TIMER_MANAGER - static grpc_millis timespec_to_millis_round_down(gpr_timespec ts) { ts = gpr_time_sub(ts, g_start_time); double x = GPR_MS_PER_SEC * static_cast(ts.tv_sec) + @@ -125,12 +118,6 @@ void ExecCtx::TestOnlyGlobalInit(gpr_timespec new_val) { void ExecCtx::GlobalInit(void) { g_start_time = gpr_now(GPR_CLOCK_MONOTONIC); - // For debug of the timer manager crash only. - // TODO (mxyan): remove after bug is fixed. -#ifdef GRPC_DEBUG_TIMER_MANAGER - g_start_time_sec = g_start_time.tv_sec; - g_start_time_nsec = g_start_time.tv_nsec; -#endif gpr_tls_init(&exec_ctx_); } From 9f6243e824247648534e05414e7253245ca135f2 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 7 Jun 2019 17:37:55 -0700 Subject: [PATCH 1084/1555] Add wait_for_termination method to grpc.Server --- src/python/grpcio/grpc/__init__.py | 14 ++++++++++++++ src/python/grpcio/grpc/_server.py | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index a1df5fb161c..814bfbac1bd 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -1444,6 +1444,20 @@ class Server(six.with_metaclass(abc.ABCMeta)): """ raise NotImplementedError() + def wait_for_termination(self, grace=None): + """Block current thread until the server stops. + + The wait will not consume computational resources during blocking, and it + will block indefinitely. There are two ways to unblock: + + 1) Calling `stop` on the server in another thread; + 2) The `__del__` of the server object is invoked. + + Args: + grace: A duration of time in seconds or None. + """ + raise NotImplementedError() + ################################# Functions ################################ diff --git a/src/python/grpcio/grpc/_server.py b/src/python/grpcio/grpc/_server.py index 370c81100af..70acbcd5068 100644 --- a/src/python/grpcio/grpc/_server.py +++ b/src/python/grpcio/grpc/_server.py @@ -959,6 +959,17 @@ class _Server(grpc.Server): def start(self): _start(self._state) + def wait_for_termination(self, grace=None): + termination_event = threading.Event() + + with self._state.lock: + if self._state.stage is _ServerStage.STOPPED: + raise ValueError('Failed to wait for a stopped server.') + else: + self._state.shutdown_events.append(termination_event) + + termination_event.wait() + def stop(self, grace): return _stop(self._state, grace) From 72575082947970d002f1c544470bc3ecf2899859 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Mon, 10 Jun 2019 17:41:36 -0700 Subject: [PATCH 1085/1555] Add a unit test for wait_for_termination --- src/python/grpcio/grpc/__init__.py | 5 +- src/python/grpcio/grpc/_server.py | 5 +- src/python/grpcio_tests/tests/tests.json | 1 + .../grpcio_tests/tests/unit/BUILD.bazel | 1 + .../unit/_server_wait_for_termination.py | 65 +++++++++++++++++++ 5 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 src/python/grpcio_tests/tests/unit/_server_wait_for_termination.py diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index 814bfbac1bd..e3f0762b77e 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -1444,7 +1444,7 @@ class Server(six.with_metaclass(abc.ABCMeta)): """ raise NotImplementedError() - def wait_for_termination(self, grace=None): + def wait_for_termination(self): """Block current thread until the server stops. The wait will not consume computational resources during blocking, and it @@ -1452,9 +1452,6 @@ class Server(six.with_metaclass(abc.ABCMeta)): 1) Calling `stop` on the server in another thread; 2) The `__del__` of the server object is invoked. - - Args: - grace: A duration of time in seconds or None. """ raise NotImplementedError() diff --git a/src/python/grpcio/grpc/_server.py b/src/python/grpcio/grpc/_server.py index 70acbcd5068..ee184adaf21 100644 --- a/src/python/grpcio/grpc/_server.py +++ b/src/python/grpcio/grpc/_server.py @@ -764,7 +764,7 @@ class _ServerState(object): self.interceptor_pipeline = interceptor_pipeline self.thread_pool = thread_pool self.stage = _ServerStage.STOPPED - self.shutdown_events = None + self.shutdown_events = [] self.maximum_concurrent_rpcs = maximum_concurrent_rpcs self.active_rpc_count = 0 @@ -876,7 +876,6 @@ def _begin_shutdown_once(state): if state.stage is _ServerStage.STARTED: state.server.shutdown(state.completion_queue, _SHUTDOWN_TAG) state.stage = _ServerStage.GRACE - state.shutdown_events = [] state.due.add(_SHUTDOWN_TAG) @@ -959,7 +958,7 @@ class _Server(grpc.Server): def start(self): _start(self._state) - def wait_for_termination(self, grace=None): + def wait_for_termination(self): termination_event = threading.Event() with self._state.lock: diff --git a/src/python/grpcio_tests/tests/tests.json b/src/python/grpcio_tests/tests/tests.json index 16ba4847bc0..7b977a42e20 100644 --- a/src/python/grpcio_tests/tests/tests.json +++ b/src/python/grpcio_tests/tests/tests.json @@ -66,6 +66,7 @@ "unit._server_ssl_cert_config_test.ServerSSLCertReloadTestWithClientAuth", "unit._server_ssl_cert_config_test.ServerSSLCertReloadTestWithoutClientAuth", "unit._server_test.ServerTest", + "unit._server_wait_for_termination.ServerWaitForTerminationTest", "unit._session_cache_test.SSLSessionCacheTest", "unit._signal_handling_test.SignalHandlingTest", "unit._version_test.VersionTest", diff --git a/src/python/grpcio_tests/tests/unit/BUILD.bazel b/src/python/grpcio_tests/tests/unit/BUILD.bazel index d21f5a59ad1..bd0826af902 100644 --- a/src/python/grpcio_tests/tests/unit/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/BUILD.bazel @@ -33,6 +33,7 @@ GRPCIO_TESTS_UNIT = [ # "_server_ssl_cert_config_test.py", "_server_test.py", "_server_shutdown_test.py", + "_server_wait_for_termination.py", "_session_cache_test.py", ] diff --git a/src/python/grpcio_tests/tests/unit/_server_wait_for_termination.py b/src/python/grpcio_tests/tests/unit/_server_wait_for_termination.py new file mode 100644 index 00000000000..5f168c6843d --- /dev/null +++ b/src/python/grpcio_tests/tests/unit/_server_wait_for_termination.py @@ -0,0 +1,65 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import datetime +from concurrent import futures +import unittest +import time +import threading +import six + +import grpc +from tests.unit.framework.common import test_constants + + +_WAIT_FOR_BLOCKING = datetime.timedelta(seconds=1) + + +def _block_on_waiting(server, termination_event): + server.start() + server.wait_for_termination() + termination_event.set() + +class ServerWaitForTerminationTest(unittest.TestCase): + + def test_unblock_by_invoking_stop(self): + termination_event = threading.Event() + server = grpc.server(futures.ThreadPoolExecutor()) + + wait_thread = threading.Thread(target=_block_on_waiting, args=(server, termination_event,)) + wait_thread.daemon = True + wait_thread.start() + time.sleep(_WAIT_FOR_BLOCKING.total_seconds()) + + server.stop(None) + termination_event.wait(timeout=test_constants.SHORT_TIMEOUT) + self.assertTrue(termination_event.is_set()) + + def test_unblock_by_del(self): + termination_event = threading.Event() + server = grpc.server(futures.ThreadPoolExecutor()) + + wait_thread = threading.Thread(target=_block_on_waiting, args=(server, termination_event,)) + wait_thread.daemon = True + wait_thread.start() + time.sleep(_WAIT_FOR_BLOCKING.total_seconds()) + + # Invoke manually here, in Python 2 it will be invoked by GC sometime. + server.__del__() + termination_event.wait(timeout=test_constants.SHORT_TIMEOUT) + self.assertTrue(termination_event.is_set()) + + +if __name__ == '__main__': + unittest.main(verbosity=2) From c4b7831f209071907fc640342630839eb804881e Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Tue, 11 Jun 2019 11:49:20 -0700 Subject: [PATCH 1086/1555] Make sanity test happy --- src/python/grpcio_tests/tests/tests.json | 2 +- src/python/grpcio_tests/tests/unit/BUILD.bazel | 2 +- ...ion.py => _server_wait_for_termination_test.py} | 14 +++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) rename src/python/grpcio_tests/tests/unit/{_server_wait_for_termination.py => _server_wait_for_termination_test.py} (86%) diff --git a/src/python/grpcio_tests/tests/tests.json b/src/python/grpcio_tests/tests/tests.json index 7b977a42e20..ab70943e5ed 100644 --- a/src/python/grpcio_tests/tests/tests.json +++ b/src/python/grpcio_tests/tests/tests.json @@ -66,7 +66,7 @@ "unit._server_ssl_cert_config_test.ServerSSLCertReloadTestWithClientAuth", "unit._server_ssl_cert_config_test.ServerSSLCertReloadTestWithoutClientAuth", "unit._server_test.ServerTest", - "unit._server_wait_for_termination.ServerWaitForTerminationTest", + "unit._server_wait_for_termination_test.ServerWaitForTerminationTest", "unit._session_cache_test.SSLSessionCacheTest", "unit._signal_handling_test.SignalHandlingTest", "unit._version_test.VersionTest", diff --git a/src/python/grpcio_tests/tests/unit/BUILD.bazel b/src/python/grpcio_tests/tests/unit/BUILD.bazel index bd0826af902..28336703845 100644 --- a/src/python/grpcio_tests/tests/unit/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/BUILD.bazel @@ -33,7 +33,7 @@ GRPCIO_TESTS_UNIT = [ # "_server_ssl_cert_config_test.py", "_server_test.py", "_server_shutdown_test.py", - "_server_wait_for_termination.py", + "_server_wait_for_termination_test.py", "_session_cache_test.py", ] diff --git a/src/python/grpcio_tests/tests/unit/_server_wait_for_termination.py b/src/python/grpcio_tests/tests/unit/_server_wait_for_termination_test.py similarity index 86% rename from src/python/grpcio_tests/tests/unit/_server_wait_for_termination.py rename to src/python/grpcio_tests/tests/unit/_server_wait_for_termination_test.py index 5f168c6843d..6a07dc7e3a4 100644 --- a/src/python/grpcio_tests/tests/unit/_server_wait_for_termination.py +++ b/src/python/grpcio_tests/tests/unit/_server_wait_for_termination_test.py @@ -22,7 +22,6 @@ import six import grpc from tests.unit.framework.common import test_constants - _WAIT_FOR_BLOCKING = datetime.timedelta(seconds=1) @@ -31,13 +30,18 @@ def _block_on_waiting(server, termination_event): server.wait_for_termination() termination_event.set() + class ServerWaitForTerminationTest(unittest.TestCase): def test_unblock_by_invoking_stop(self): termination_event = threading.Event() server = grpc.server(futures.ThreadPoolExecutor()) - wait_thread = threading.Thread(target=_block_on_waiting, args=(server, termination_event,)) + wait_thread = threading.Thread( + target=_block_on_waiting, args=( + server, + termination_event, + )) wait_thread.daemon = True wait_thread.start() time.sleep(_WAIT_FOR_BLOCKING.total_seconds()) @@ -50,7 +54,11 @@ class ServerWaitForTerminationTest(unittest.TestCase): termination_event = threading.Event() server = grpc.server(futures.ThreadPoolExecutor()) - wait_thread = threading.Thread(target=_block_on_waiting, args=(server, termination_event,)) + wait_thread = threading.Thread( + target=_block_on_waiting, args=( + server, + termination_event, + )) wait_thread.daemon = True wait_thread.start() time.sleep(_WAIT_FOR_BLOCKING.total_seconds()) From 8f6ee973451481d2eec87c01109e581c443f18eb Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Wed, 12 Jun 2019 15:34:30 -0700 Subject: [PATCH 1087/1555] "EXPERIMENTAL API" added in docstring --- src/python/grpcio/grpc/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index e3f0762b77e..d5fe01e4c88 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -1447,6 +1447,8 @@ class Server(six.with_metaclass(abc.ABCMeta)): def wait_for_termination(self): """Block current thread until the server stops. + This is an EXPERIMENTAL API. + The wait will not consume computational resources during blocking, and it will block indefinitely. There are two ways to unblock: From 59555d5b0ca4e1a46d6f087cac5a94e004b5df47 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 13 Jun 2019 15:48:30 -0700 Subject: [PATCH 1088/1555] Add timeout argument to wait_for_termination --- src/python/grpcio/grpc/__init__.py | 17 ++++++++++---- src/python/grpcio/grpc/_server.py | 6 ++--- .../unit/_server_wait_for_termination_test.py | 23 +++++++++++++++++-- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index d5fe01e4c88..e9622b4d44c 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -1444,16 +1444,23 @@ class Server(six.with_metaclass(abc.ABCMeta)): """ raise NotImplementedError() - def wait_for_termination(self): + def wait_for_termination(self, timeout=None): """Block current thread until the server stops. This is an EXPERIMENTAL API. - The wait will not consume computational resources during blocking, and it - will block indefinitely. There are two ways to unblock: + The wait will not consume computational resources during blocking, and + it will block until one of the two following conditions are met: - 1) Calling `stop` on the server in another thread; - 2) The `__del__` of the server object is invoked. + 1) The server is stopped or terminated; + 2) A timeout occurs if timeout is not `None`. + + The timeout argument works in the same way as `threading.Event.wait()`. + https://docs.python.org/3/library/threading.html#threading.Event.wait + + Args: + timeout: A floating point number specifying a timeout for the + operation in seconds. """ raise NotImplementedError() diff --git a/src/python/grpcio/grpc/_server.py b/src/python/grpcio/grpc/_server.py index ee184adaf21..063b16b4791 100644 --- a/src/python/grpcio/grpc/_server.py +++ b/src/python/grpcio/grpc/_server.py @@ -958,16 +958,16 @@ class _Server(grpc.Server): def start(self): _start(self._state) - def wait_for_termination(self): + def wait_for_termination(self, timeout=None): termination_event = threading.Event() with self._state.lock: if self._state.stage is _ServerStage.STOPPED: - raise ValueError('Failed to wait for a stopped server.') + return else: self._state.shutdown_events.append(termination_event) - termination_event.wait() + termination_event.wait(timeout=timeout) def stop(self, grace): return _stop(self._state, grace) diff --git a/src/python/grpcio_tests/tests/unit/_server_wait_for_termination_test.py b/src/python/grpcio_tests/tests/unit/_server_wait_for_termination_test.py index 6a07dc7e3a4..c5c1f6da38e 100644 --- a/src/python/grpcio_tests/tests/unit/_server_wait_for_termination_test.py +++ b/src/python/grpcio_tests/tests/unit/_server_wait_for_termination_test.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division + import datetime from concurrent import futures import unittest @@ -25,9 +27,9 @@ from tests.unit.framework.common import test_constants _WAIT_FOR_BLOCKING = datetime.timedelta(seconds=1) -def _block_on_waiting(server, termination_event): +def _block_on_waiting(server, termination_event, timeout=None): server.start() - server.wait_for_termination() + server.wait_for_termination(timeout=timeout) termination_event.set() @@ -68,6 +70,23 @@ class ServerWaitForTerminationTest(unittest.TestCase): termination_event.wait(timeout=test_constants.SHORT_TIMEOUT) self.assertTrue(termination_event.is_set()) + def test_unblock_by_timeout(self): + termination_event = threading.Event() + server = grpc.server(futures.ThreadPoolExecutor()) + + wait_thread = threading.Thread( + target=_block_on_waiting, + args=( + server, + termination_event, + test_constants.SHORT_TIMEOUT / 2, + )) + wait_thread.daemon = True + wait_thread.start() + + termination_event.wait(timeout=test_constants.SHORT_TIMEOUT) + self.assertTrue(termination_event.is_set()) + if __name__ == '__main__': unittest.main(verbosity=2) From 518b55a433d95e8955fd6149151ae538c1fd6364 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 13 Jun 2019 16:14:19 -0700 Subject: [PATCH 1089/1555] Simplify implementation --- examples/python/helloworld/greeter_server.py | 7 ++----- src/python/grpcio/grpc/__init__.py | 3 +++ src/python/grpcio/grpc/_server.py | 13 +++---------- .../tests/unit/_server_wait_for_termination_test.py | 5 +++++ 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/examples/python/helloworld/greeter_server.py b/examples/python/helloworld/greeter_server.py index e3b4f2c1ff9..a9f55e593c5 100644 --- a/examples/python/helloworld/greeter_server.py +++ b/examples/python/helloworld/greeter_server.py @@ -36,11 +36,8 @@ def serve(): helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server) server.add_insecure_port('[::]:50051') server.start() - try: - while True: - time.sleep(_ONE_DAY_IN_SECONDS) - except KeyboardInterrupt: - server.stop(0) + + server.wait_for_termination() if __name__ == '__main__': diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index e9622b4d44c..7dae90c89e8 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -1461,6 +1461,9 @@ class Server(six.with_metaclass(abc.ABCMeta)): Args: timeout: A floating point number specifying a timeout for the operation in seconds. + + Returns: + A bool indicates if the operation times out. """ raise NotImplementedError() diff --git a/src/python/grpcio/grpc/_server.py b/src/python/grpcio/grpc/_server.py index 063b16b4791..6320c4d8fef 100644 --- a/src/python/grpcio/grpc/_server.py +++ b/src/python/grpcio/grpc/_server.py @@ -764,7 +764,8 @@ class _ServerState(object): self.interceptor_pipeline = interceptor_pipeline self.thread_pool = thread_pool self.stage = _ServerStage.STOPPED - self.shutdown_events = [] + self.termination_event = threading.Event() + self.shutdown_events = [self.termination_event] self.maximum_concurrent_rpcs = maximum_concurrent_rpcs self.active_rpc_count = 0 @@ -959,15 +960,7 @@ class _Server(grpc.Server): _start(self._state) def wait_for_termination(self, timeout=None): - termination_event = threading.Event() - - with self._state.lock: - if self._state.stage is _ServerStage.STOPPED: - return - else: - self._state.shutdown_events.append(termination_event) - - termination_event.wait(timeout=timeout) + return self._state.termination_event.wait(timeout=timeout) def stop(self, grace): return _stop(self._state, grace) diff --git a/src/python/grpcio_tests/tests/unit/_server_wait_for_termination_test.py b/src/python/grpcio_tests/tests/unit/_server_wait_for_termination_test.py index c5c1f6da38e..cdd1067ee10 100644 --- a/src/python/grpcio_tests/tests/unit/_server_wait_for_termination_test.py +++ b/src/python/grpcio_tests/tests/unit/_server_wait_for_termination_test.py @@ -87,6 +87,11 @@ class ServerWaitForTerminationTest(unittest.TestCase): termination_event.wait(timeout=test_constants.SHORT_TIMEOUT) self.assertTrue(termination_event.is_set()) + def test_just_block(self): + server = grpc.server(futures.ThreadPoolExecutor()) + server.start() + server.wait_for_termination(timeout=-1) + if __name__ == '__main__': unittest.main(verbosity=2) From 42e8bd21b4c3ebd2bc39ba3f13d5578fd4c40a79 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 13 Jun 2019 17:19:33 -0700 Subject: [PATCH 1090/1555] Add a workaround for CPython issue 35935 --- src/python/grpcio/grpc/_server.py | 6 ++++++ .../tests/unit/_server_wait_for_termination_test.py | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/python/grpcio/grpc/_server.py b/src/python/grpcio/grpc/_server.py index 6320c4d8fef..7fe1b23075b 100644 --- a/src/python/grpcio/grpc/_server.py +++ b/src/python/grpcio/grpc/_server.py @@ -50,6 +50,7 @@ _CANCELLED = 'cancelled' _EMPTY_FLAGS = 0 _DEALLOCATED_SERVER_CHECK_PERIOD_S = 1.0 +_INF_TIMEOUT = 1e9 def _serialized_request(request_event): @@ -960,6 +961,11 @@ class _Server(grpc.Server): _start(self._state) def wait_for_termination(self, timeout=None): + # TODO(https://bugs.python.org/issue35935) + # Remove this workaround once threading.Event.wait() is working with + # CTRL+C across platforms. + if timeout is None: + timeout = _INF_TIMEOUT return self._state.termination_event.wait(timeout=timeout) def stop(self, grace): diff --git a/src/python/grpcio_tests/tests/unit/_server_wait_for_termination_test.py b/src/python/grpcio_tests/tests/unit/_server_wait_for_termination_test.py index cdd1067ee10..c5c1f6da38e 100644 --- a/src/python/grpcio_tests/tests/unit/_server_wait_for_termination_test.py +++ b/src/python/grpcio_tests/tests/unit/_server_wait_for_termination_test.py @@ -87,11 +87,6 @@ class ServerWaitForTerminationTest(unittest.TestCase): termination_event.wait(timeout=test_constants.SHORT_TIMEOUT) self.assertTrue(termination_event.is_set()) - def test_just_block(self): - server = grpc.server(futures.ThreadPoolExecutor()) - server.start() - server.wait_for_termination(timeout=-1) - if __name__ == '__main__': unittest.main(verbosity=2) From 1e62124cfb3b3c30cc10a9f8fb1ff25ee2e4aa56 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Wed, 26 Jun 2019 09:52:39 -0700 Subject: [PATCH 1091/1555] Revert changes to helloworld example --- examples/python/helloworld/greeter_server.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/python/helloworld/greeter_server.py b/examples/python/helloworld/greeter_server.py index a9f55e593c5..e3b4f2c1ff9 100644 --- a/examples/python/helloworld/greeter_server.py +++ b/examples/python/helloworld/greeter_server.py @@ -36,8 +36,11 @@ def serve(): helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server) server.add_insecure_port('[::]:50051') server.start() - - server.wait_for_termination() + try: + while True: + time.sleep(_ONE_DAY_IN_SECONDS) + except KeyboardInterrupt: + server.stop(0) if __name__ == '__main__': From e2ebdc794d409ff7eca9c0f158008e058390167a Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Thu, 25 Jul 2019 17:38:47 -0700 Subject: [PATCH 1092/1555] Fixed time_change_test flakes --- test/cpp/end2end/time_change_test.cc | 100 ++++++--------------------- 1 file changed, 21 insertions(+), 79 deletions(-) diff --git a/test/cpp/end2end/time_change_test.cc b/test/cpp/end2end/time_change_test.cc index 688549e5772..a42b7bf6498 100644 --- a/test/cpp/end2end/time_change_test.cc +++ b/test/cpp/end2end/time_change_test.cc @@ -129,25 +129,34 @@ class TimeChangeTest : public ::testing::Test { protected: TimeChangeTest() {} - void SetUp() { + static void SetUpTestCase() { auto port = grpc_pick_unused_port_or_die(); std::ostringstream addr_stream; addr_stream << "localhost:" << port; - auto addr = addr_stream.str(); + server_address_ = addr_stream.str(); server_.reset(new SubProcess({ g_root + "/client_crash_test_server", - "--address=" + addr, + "--address=" + server_address_, })); GPR_ASSERT(server_); - channel_ = grpc::CreateChannel(addr, InsecureChannelCredentials()); + // connect to server and make sure it's reachable. + auto channel = + grpc::CreateChannel(server_address_, InsecureChannelCredentials()); + GPR_ASSERT(channel); + EXPECT_TRUE(channel->WaitForConnected( + grpc_timeout_milliseconds_to_deadline(30000))); + } + + static void TearDownTestCase() { server_.reset(); } + + void SetUp() { + channel_ = + grpc::CreateChannel(server_address_, InsecureChannelCredentials()); GPR_ASSERT(channel_); stub_ = grpc::testing::EchoTestService::NewStub(channel_); } - void TearDown() { - server_.reset(); - reset_now_offset(); - } + void TearDown() { reset_now_offset(); } std::unique_ptr CreateStub() { return grpc::testing::EchoTestService::NewStub(channel_); @@ -159,10 +168,13 @@ class TimeChangeTest : public ::testing::Test { const int TIME_OFFSET2 = 5678; private: - std::unique_ptr server_; + static std::string server_address_; + static std::unique_ptr server_; std::shared_ptr channel_; std::unique_ptr stub_; }; +std::string TimeChangeTest::server_address_; +std::unique_ptr TimeChangeTest::server_; // Wall-clock time jumps forward on client before bidi stream is created TEST_F(TimeChangeTest, TimeJumpForwardBeforeStreamCreated) { @@ -283,76 +295,6 @@ TEST_F(TimeChangeTest, TimeJumpBackAfterStreamCreated) { EXPECT_TRUE(status.ok()); } -// Wall-clock time jumps forward on client before connection to server is up -TEST_F(TimeChangeTest, TimeJumpForwardBeforeServerConnect) { - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_deadline(grpc_timeout_milliseconds_to_deadline(5000)); - context.AddMetadata(kServerResponseStreamsToSend, "2"); - - auto channel = GetChannel(); - GPR_ASSERT(channel); - - // time jumps forward by TIME_OFFSET2 milliseconds - set_now_offset(TIME_OFFSET2); - - auto ret = - channel->WaitForConnected(grpc_timeout_milliseconds_to_deadline(5000)); - // We use monotonic clock for pthread_cond_timedwait() deadline on linux, and - // realtime clock on other platforms - see gpr_cv_wait() in sync_posix.cc. - // So changes in system clock affect deadlines on non-linux platforms -#ifdef GPR_LINUX - EXPECT_TRUE(ret); - auto stub = CreateStub(); - auto stream = stub->BidiStream(&context); - - request.set_message("Hello"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->Read(&response)); - request.set_message("World"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->WritesDone()); - EXPECT_TRUE(stream->Read(&response)); - - auto status = stream->Finish(); - EXPECT_TRUE(status.ok()); -#else - EXPECT_FALSE(ret); -#endif -} - -// Wall-clock time jumps back on client before connection to server is up -TEST_F(TimeChangeTest, TimeJumpBackBeforeServerConnect) { - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_deadline(grpc_timeout_milliseconds_to_deadline(5000)); - context.AddMetadata(kServerResponseStreamsToSend, "2"); - - auto channel = GetChannel(); - GPR_ASSERT(channel); - - // time jumps back by TIME_OFFSET2 milliseconds - set_now_offset(-TIME_OFFSET2); - - EXPECT_TRUE( - channel->WaitForConnected(grpc_timeout_milliseconds_to_deadline(5000))); - auto stub = CreateStub(); - auto stream = stub->BidiStream(&context); - - request.set_message("Hello"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->Read(&response)); - request.set_message("World"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->WritesDone()); - EXPECT_TRUE(stream->Read(&response)); - - auto status = stream->Finish(); - EXPECT_TRUE(status.ok()); -} - // Wall-clock time jumps forward and backwards during call TEST_F(TimeChangeTest, TimeJumpForwardAndBackDuringCall) { EchoRequest request; From 66114201b45f805278c632906c7bc0366482b07f Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Fri, 2 Aug 2019 15:11:06 -0700 Subject: [PATCH 1093/1555] Modernize cancellation example --- examples/python/cancellation/BUILD.bazel | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/examples/python/cancellation/BUILD.bazel b/examples/python/cancellation/BUILD.bazel index 81cd3a881b8..41b394a07a2 100644 --- a/examples/python/cancellation/BUILD.bazel +++ b/examples/python/cancellation/BUILD.bazel @@ -15,7 +15,7 @@ # limitations under the License. load("@grpc_python_dependencies//:requirements.bzl", "requirement") -load("//bazel:python_rules.bzl", "py_proto_library") +load("//bazel:python_rules.bzl", "py_proto_library", "py_grpc_library") package(default_testonly = 1) @@ -25,9 +25,14 @@ proto_library( ) py_proto_library( - name = "hash_name_proto_pb2", - deps = [":hash_name_proto"], - well_known_protos = False, + name = "hash_name_py_pb2", + srcs = [":hash_name_proto"], +) + +py_grpc_library( + name = "hash_name_py_pb2_grpc", + srcs = [":hash_name_proto"], + deps = [":hash_name_py_pb2"], ) py_binary( @@ -35,8 +40,9 @@ py_binary( srcs = ["client.py"], deps = [ "//src/python/grpcio/grpc:grpcio", - ":hash_name_proto_pb2", - requirement("six"), + ":hash_name_py_pb2", + ":hash_name_py_pb2_grpc", + "//external:six" ], srcs_version = "PY2AND3", ) @@ -46,7 +52,7 @@ py_library( srcs = ["search.py"], srcs_version = "PY2AND3", deps = [ - ":hash_name_proto_pb2", + ":hash_name_py_pb2", ], ) @@ -55,10 +61,10 @@ py_binary( srcs = ["server.py"], deps = [ "//src/python/grpcio/grpc:grpcio", - ":hash_name_proto_pb2", + ":hash_name_py_pb2", ":search", ] + select({ - "//conditions:default": [requirement("futures")], + "//conditions:default": ["@futures//:futures"], "//:python3": [], }), srcs_version = "PY2AND3", From 3e84f47d3fbbc4042683adf7b5203d2a4be8a68a Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 2 Aug 2019 15:09:03 -0700 Subject: [PATCH 1094/1555] Apply the spin wait mechansim --- src/python/grpcio/grpc/_server.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/python/grpcio/grpc/_server.py b/src/python/grpcio/grpc/_server.py index 7fe1b23075b..99255432eb4 100644 --- a/src/python/grpcio/grpc/_server.py +++ b/src/python/grpcio/grpc/_server.py @@ -961,12 +961,13 @@ class _Server(grpc.Server): _start(self._state) def wait_for_termination(self, timeout=None): - # TODO(https://bugs.python.org/issue35935) + # NOTE(https://bugs.python.org/issue35935) # Remove this workaround once threading.Event.wait() is working with # CTRL+C across platforms. - if timeout is None: - timeout = _INF_TIMEOUT - return self._state.termination_event.wait(timeout=timeout) + return _common.wait( + self._state.termination_event.wait, + self._state.termination_event.is_set, + timeout=timeout) def stop(self, grace): return _stop(self._state, grace) From 0c94e5b2f61e0728bde58c093f17f4797fe5d674 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 2 Aug 2019 15:52:42 -0700 Subject: [PATCH 1095/1555] Remove ref and unref on keep reading --- src/core/ext/transport/chttp2/transport/chttp2_transport.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 16146569886..633b35e7d61 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -2591,7 +2591,6 @@ static void read_action_locked(void* tp, grpc_error* error) { t->endpoint_reading = 0; } else if (t->closed_with_error == GRPC_ERROR_NONE) { keep_reading = true; - GRPC_CHTTP2_REF_TRANSPORT(t, "keep_reading"); /* Since we have read a byte, reset the keepalive timer */ if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING) { grpc_timer_cancel(&t->keepalive_ping_timer); @@ -2604,7 +2603,6 @@ static void read_action_locked(void* tp, grpc_error* error) { grpc_endpoint_read(t->ep, &t->read_buffer, &t->read_action_locked, urgent); grpc_chttp2_act_on_flowctl_action(t->flow_control->MakeAction(), t, nullptr); - GRPC_CHTTP2_UNREF_TRANSPORT(t, "keep_reading"); } else { GRPC_CHTTP2_UNREF_TRANSPORT(t, "reading_action"); } From e89096cdf2b6dab56f5c1e910ac3c38361886dcd Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Fri, 2 Aug 2019 16:04:59 -0700 Subject: [PATCH 1096/1555] AAAAAAAHHHHHH --- bazel/test/python_test_repo/WORKSPACE | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bazel/test/python_test_repo/WORKSPACE b/bazel/test/python_test_repo/WORKSPACE index 29bec643f96..0bc58045693 100644 --- a/bazel/test/python_test_repo/WORKSPACE +++ b/bazel/test/python_test_repo/WORKSPACE @@ -9,8 +9,12 @@ grpc_deps() load("@com_github_grpc_grpc//bazel:grpc_python_deps.bzl", "grpc_python_deps") grpc_python_deps() - # TODO(https://github.com/grpc/grpc/issues/19835): Remove. load("@upb//bazel:workspace_deps.bzl", "upb_deps") upb_deps() +load("@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies") +apple_rules_dependencies() + +load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies") +apple_support_dependencies() From d5191a5f8bee46762285b2668c19890390351001 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Sat, 3 Aug 2019 01:44:02 +0200 Subject: [PATCH 1097/1555] Adding src/core/ext/upb-generated in our include path. This enables us to build both from Bazel and make. --- Makefile | 2 +- templates/Makefile.template | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3cef3bc5e10..fd9d5521a17 100644 --- a/Makefile +++ b/Makefile @@ -370,7 +370,7 @@ CPPFLAGS += -fPIC LDFLAGS += -fPIC endif -INCLUDES = . include $(GENDIR) third_party/upb third_party/upb/generated_for_cmake +INCLUDES = . include $(GENDIR) third_party/upb third_party/upb/generated_for_cmake src/core/ext/upb-generated LDFLAGS += -Llibs/$(CONFIG) ifeq ($(SYSTEM),Darwin) diff --git a/templates/Makefile.template b/templates/Makefile.template index a46a27061ab..21e1b6cd01c 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -240,7 +240,7 @@ LDFLAGS += -fPIC endif - INCLUDES = . include $(GENDIR) third_party/upb third_party/upb/generated_for_cmake + INCLUDES = . include $(GENDIR) third_party/upb third_party/upb/generated_for_cmake src/core/ext/upb-generated LDFLAGS += -Llibs/$(CONFIG) ifeq ($(SYSTEM),Darwin) From 28ed900adca35ca2583d1b4144cf9a5ff3105b9d Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Fri, 2 Aug 2019 17:41:35 -0700 Subject: [PATCH 1098/1555] Increased timeout limit --- tools/run_tests/run_tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index db75d884aa9..2a4ec8ce156 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1115,7 +1115,7 @@ class ObjCLanguage(object): out.append( self.config.job_spec( ['src/objective-c/tests/build_one_example.sh'], - timeout_seconds=10 * 60, + timeout_seconds=20 * 60, shortname='ios-buildtest-example-watchOS-sample', cpu_cost=1e6, environ={ @@ -1126,7 +1126,7 @@ class ObjCLanguage(object): out.append( self.config.job_spec( ['src/objective-c/tests/build_one_example.sh'], - timeout_seconds=10 * 60, + timeout_seconds=20 * 60, shortname='ios-buildtest-example-watchOS-sample-framework', cpu_cost=1e6, environ={ From a1477e8b7e5e0141456d549888b1bf41911320e1 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Mon, 5 Aug 2019 10:14:30 -0700 Subject: [PATCH 1099/1555] Fix uninitialized memory in sockaddr utils --- src/core/lib/iomgr/sockaddr_utils.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/core/lib/iomgr/sockaddr_utils.cc b/src/core/lib/iomgr/sockaddr_utils.cc index baadf1da99e..2f8ed2225a6 100644 --- a/src/core/lib/iomgr/sockaddr_utils.cc +++ b/src/core/lib/iomgr/sockaddr_utils.cc @@ -201,13 +201,11 @@ int grpc_sockaddr_to_string(char** out, } void grpc_string_to_sockaddr(grpc_resolved_address* out, char* addr, int port) { + memset(out, 0, sizeof(grpc_resolved_address)); grpc_sockaddr_in6* addr6 = (grpc_sockaddr_in6*)out->addr; grpc_sockaddr_in* addr4 = (grpc_sockaddr_in*)out->addr; - if (grpc_inet_pton(GRPC_AF_INET6, addr, &addr6->sin6_addr) == 1) { addr6->sin6_family = GRPC_AF_INET6; - addr6->sin6_flowinfo = 0; - addr6->sin6_scope_id = 0; out->len = sizeof(grpc_sockaddr_in6); } else if (grpc_inet_pton(GRPC_AF_INET, addr, &addr4->sin_addr) == 1) { addr4->sin_family = GRPC_AF_INET; From 4c23c6f22a108cd7be029dfbe2eef92711833f65 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Mon, 5 Aug 2019 11:20:53 -0700 Subject: [PATCH 1100/1555] Fix ServerAddress move assignment --- src/core/ext/filters/client_channel/server_address.cc | 4 +--- src/core/ext/filters/client_channel/server_address.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/core/ext/filters/client_channel/server_address.cc b/src/core/ext/filters/client_channel/server_address.cc index 31c0edaca17..d46896b754b 100644 --- a/src/core/ext/filters/client_channel/server_address.cc +++ b/src/core/ext/filters/client_channel/server_address.cc @@ -20,8 +20,6 @@ #include "src/core/ext/filters/client_channel/server_address.h" -#include - namespace grpc_core { // @@ -39,7 +37,7 @@ ServerAddress::ServerAddress(const void* address, size_t address_len, address_.len = static_cast(address_len); } -bool ServerAddress::operator==(const grpc_core::ServerAddress& other) const { +bool ServerAddress::operator==(const ServerAddress& other) const { return address_.len == other.address_.len && memcmp(address_.addr, other.address_.addr, address_.len) == 0 && grpc_channel_args_compare(args_, other.args_) == 0; diff --git a/src/core/ext/filters/client_channel/server_address.h b/src/core/ext/filters/client_channel/server_address.h index 1b68a59ed85..acd71358810 100644 --- a/src/core/ext/filters/client_channel/server_address.h +++ b/src/core/ext/filters/client_channel/server_address.h @@ -24,7 +24,6 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/iomgr/resolve_address.h" -#include "src/core/lib/uri/uri_parser.h" // Channel arg key for a bool indicating whether an address is a grpclb // load balancer (as opposed to a backend). @@ -68,6 +67,7 @@ class ServerAddress { } ServerAddress& operator=(ServerAddress&& other) { address_ = other.address_; + grpc_channel_args_destroy(args_); args_ = other.args_; other.args_ = nullptr; return *this; From 3638167e4092cb72b45c07888fa81a6a2016ce90 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 5 Aug 2019 12:57:50 -0700 Subject: [PATCH 1101/1555] Call grpc_python_deps() from grpc_deps(). --- WORKSPACE | 6 +----- bazel/grpc_deps.bzl | 8 +++++++- bazel/test/python_test_repo/WORKSPACE | 3 --- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 3f7911b0a22..523b0153d7b 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -39,10 +39,6 @@ rbe_autoconfig( ), ) -load("@com_github_grpc_grpc//bazel:grpc_python_deps.bzl", "grpc_python_deps") -grpc_python_deps() - - load("@io_bazel_rules_python//python:pip.bzl", "pip_repositories", "pip_import") pip_import( @@ -70,4 +66,4 @@ load("@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependenci apple_rules_dependencies() load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies") -apple_support_dependencies() \ No newline at end of file +apple_support_dependencies() diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index cce2f88fe87..f9e84065b73 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -2,6 +2,8 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@com_github_grpc_grpc//bazel:grpc_python_deps.bzl", "grpc_python_deps") + def grpc_deps(): """Loads dependencies need to compile and test the grpc library.""" @@ -231,7 +233,10 @@ def grpc_deps(): remote = "https://github.com/bazelbuild/rules_apple.git", tag = "0.17.2", ) - + + grpc_python_deps() + + # TODO: move some dependencies from "grpc_deps" here? def grpc_test_only_deps(): """Internal, not intended for use by packages that are consuming grpc. @@ -290,3 +295,4 @@ def grpc_test_only_deps(): url = "https://github.com/twisted/constantly/archive/15.1.0.zip", build_file = "@com_github_grpc_grpc//third_party:constantly.BUILD", ) + diff --git a/bazel/test/python_test_repo/WORKSPACE b/bazel/test/python_test_repo/WORKSPACE index 0bc58045693..f8a00c88283 100644 --- a/bazel/test/python_test_repo/WORKSPACE +++ b/bazel/test/python_test_repo/WORKSPACE @@ -6,9 +6,6 @@ local_repository( load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") grpc_deps() -load("@com_github_grpc_grpc//bazel:grpc_python_deps.bzl", "grpc_python_deps") -grpc_python_deps() - # TODO(https://github.com/grpc/grpc/issues/19835): Remove. load("@upb//bazel:workspace_deps.bzl", "upb_deps") upb_deps() From 024a864209cc078f54d4f3d9ded91571a2e75767 Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Mon, 5 Aug 2019 14:11:03 -0700 Subject: [PATCH 1102/1555] Added kokoro config to run grpc_basictests_cpp_ios as part of presubmit --- .../pull_request/grpc_basictests_cpp_ios.cfg | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tools/internal_ci/macos/pull_request/grpc_basictests_cpp_ios.cfg diff --git a/tools/internal_ci/macos/pull_request/grpc_basictests_cpp_ios.cfg b/tools/internal_ci/macos/pull_request/grpc_basictests_cpp_ios.cfg new file mode 100644 index 00000000000..f831aba3b94 --- /dev/null +++ b/tools/internal_ci/macos/pull_request/grpc_basictests_cpp_ios.cfg @@ -0,0 +1,31 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" +timeout_mins: 120 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-f basictests macos objc opt --internal_ci -j 1 --inner_jobs 4 --extra_args -r ios-cpp-test-.*" +} From 37b6c8cefd1e59fa700d7986456aa40d04e79677 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 5 Aug 2019 14:18:52 -0700 Subject: [PATCH 1103/1555] Fix sanity check --- tools/run_tests/sanity/check_bazel_workspace.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/run_tests/sanity/check_bazel_workspace.py b/tools/run_tests/sanity/check_bazel_workspace.py index 4ddbc74646f..40a4f5b4fd2 100755 --- a/tools/run_tests/sanity/check_bazel_workspace.py +++ b/tools/run_tests/sanity/check_bazel_workspace.py @@ -115,6 +115,9 @@ class BazelEvalState(object): return self.names_and_urls[args['name']] = args['remote'] + def grpc_python_deps(self): + pass + # Parse git hashes from bazel/grpc_deps.bzl {new_}http_archive rules with open(os.path.join('bazel', 'grpc_deps.bzl'), 'r') as f: @@ -131,6 +134,7 @@ build_rules = { 'http_archive': lambda **args: eval_state.http_archive(**args), 'load': lambda a, b: None, 'git_repository': lambda **args: eval_state.git_repository(**args), + 'grpc_python_deps': lambda: None, } exec bazel_file in build_rules for name in _GRPC_DEP_NAMES: @@ -173,6 +177,7 @@ for name in _GRPC_DEP_NAMES: 'http_archive': lambda **args: state.http_archive(**args), 'load': lambda a, b: None, 'git_repository': lambda **args: state.git_repository(**args), + 'grpc_python_deps': lambda *args, **kwargs: None, } exec bazel_file in rules assert name not in names_and_urls_with_overridden_name.keys() From dab3bdde61ab84c7ed6efc780477b4a2c76b9591 Mon Sep 17 00:00:00 2001 From: Yihua Zhang Date: Mon, 5 Aug 2019 14:42:50 -0700 Subject: [PATCH 1104/1555] recongize URI and email address SAN fields --- src/core/tsi/ssl_transport_security.cc | 18 +++++++++---- src/core/tsi/ssl_transport_security.h | 4 +++ src/core/tsi/test_creds/multi-domain.key | 27 ++++++++++++++++++++ src/core/tsi/test_creds/multi-domain.pem | 23 +++++++++++++++++ test/core/tsi/ssl_transport_security_test.cc | 21 +++++++++++++++ 5 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 src/core/tsi/test_creds/multi-domain.key create mode 100644 src/core/tsi/test_creds/multi-domain.pem diff --git a/src/core/tsi/ssl_transport_security.cc b/src/core/tsi/ssl_transport_security.cc index d3c8982c847..f3982fa1caa 100644 --- a/src/core/tsi/ssl_transport_security.cc +++ b/src/core/tsi/ssl_transport_security.cc @@ -350,11 +350,19 @@ static tsi_result add_subject_alt_names_properties_to_peer( for (i = 0; i < subject_alt_name_count; i++) { GENERAL_NAME* subject_alt_name = sk_GENERAL_NAME_value(subject_alt_names, TSI_SIZE_AS_SIZE(i)); - /* Filter out the non-dns entries names. */ - if (subject_alt_name->type == GEN_DNS) { + if (subject_alt_name->type == GEN_DNS || + subject_alt_name->type == GEN_EMAIL || + subject_alt_name->type == GEN_URI) { unsigned char* name = nullptr; int name_size; - name_size = ASN1_STRING_to_UTF8(&name, subject_alt_name->d.dNSName); + if (subject_alt_name->type == GEN_DNS) { + name_size = ASN1_STRING_to_UTF8(&name, subject_alt_name->d.dNSName); + } else if (subject_alt_name->type == GEN_EMAIL) { + name_size = ASN1_STRING_to_UTF8(&name, subject_alt_name->d.rfc822Name); + } else { + name_size = ASN1_STRING_to_UTF8( + &name, subject_alt_name->d.uniformResourceIdentifier); + } if (name_size < 0) { gpr_log(GPR_ERROR, "Could not get utf8 from asn1 string."); result = TSI_INTERNAL_ERROR; @@ -703,8 +711,8 @@ static tsi_result populate_ssl_context( } /* Extracts the CN and the SANs from an X509 cert as a peer object. */ -static tsi_result extract_x509_subject_names_from_pem_cert(const char* pem_cert, - tsi_peer* peer) { +tsi_result extract_x509_subject_names_from_pem_cert(const char* pem_cert, + tsi_peer* peer) { tsi_result result = TSI_OK; X509* cert = nullptr; BIO* pem; diff --git a/src/core/tsi/ssl_transport_security.h b/src/core/tsi/ssl_transport_security.h index 0203141e56e..638c088442c 100644 --- a/src/core/tsi/ssl_transport_security.h +++ b/src/core/tsi/ssl_transport_security.h @@ -332,4 +332,8 @@ const tsi_ssl_handshaker_factory_vtable* tsi_ssl_handshaker_factory_swap_vtable( tsi_ssl_handshaker_factory* factory, tsi_ssl_handshaker_factory_vtable* new_vtable); +/* Exposed for testing only. */ +tsi_result extract_x509_subject_names_from_pem_cert(const char* pem_cert, + tsi_peer* peer); + #endif /* GRPC_CORE_TSI_SSL_TRANSPORT_SECURITY_H */ diff --git a/src/core/tsi/test_creds/multi-domain.key b/src/core/tsi/test_creds/multi-domain.key new file mode 100644 index 00000000000..59008191888 --- /dev/null +++ b/src/core/tsi/test_creds/multi-domain.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCAQEA1e+GwyVNsoKu7PqvOf/EubN45rB5o5PQF9A5fBPpiBtKZdvb +bOouGlulRwaMQOLDZi9M6l/AhE1b207+iSBTn9jSQT0elaYwVtKgb/qoehQjFAG8 +BckPmA9E4SDx2Ug9AtV3rTVs4V2yaDHNSfDSXQ2PS9fuIx7FK5mMnUM2fjskcZqu +HV5f8McXEtvpuTktnb+KDgETO0Cdu3+rf/RtraTuKZb0kmAgf+KaNWDL2j5QsFKa +6sT4812Vfwaevm9qKOtzgAFobCwdVt+Ap/B0XWj4CmzJMPN/SXESluoBHszmTi6Q +mkTEzYbzmD/ObyTxXVKu46kRVmJKXh6BE1wk2QIDAQABAoIBAQDPpS8OFhT14LXc +Oez9xGyzOaltb3iA9qURl/9TmRggDS0G9IBjlGCvIKio6YgUKoUxl1N2YP3A7Dzt +/hw8CG5iRda9j48x/R4KB2HFjmscIpNxhcVzcBV8p8VZJdrX5K+jIoKIUcSecY0K +aNwymlX0D4c4PBtdZy5FBUJgGa64kPQqd+1Ha4cKgD9+oZzSo5Me04cGV7gWqBGt +qY9KL9j8RGA5m+CHu4Qi2ZXnFlkeH/teXuH5AhFzxeYZG4ZwtXCTjNXxQelVNbYw +mIOnADvd+RhJoeLZnGdM/gyFfLpJW6rtqva9l4h2qxKxnO3CcYHwac475wE49ukv +qx027fopAoGBAPTXRsXRHnK+ZZbj1mafFXeM4G+f8QMLxaSP/za6uYKd1BihXurr +NUhYCQ+d6E+HXnCsYQcfR4AMTSqZRA2XImW4ZW8HRog+OBOn9LDaRcvqlqenKs/Z +IoOUqaqVTqNF2ukkH4usnBugPvdxiqtIGXCBFlS0st+PwIoBtRYD0u6bAoGBAN+v +qElfO/LOjzYWsV6bUSxWRp1XFnfxujitkcYbai+AnBITvZ6BcPfcATQ9IIp42HKk +vQ5PVViN2eCzB0R4I09fSOk/1PPGQM/jzgDQ5Q7zy644ee/lPbryKeFbCOxQtQ50 +0ZRHmQmUW/L9FmNxW1Dx0wcicMC2Bq+VnXvkHVebAoGBAMChpxL4Boasee0PcJ3o +x9D5S5NHOS32Uxe4G0mJ+25ikn6WZ8FYMOGsMeTRjfcUQB9R4DzkRTLfes7rKvmu +UOfK/jMufDWxDhmY6RFDiep3tPROt4Y0Bc2UZzDIq8gVq7gGLbOMqH2rxB6WfE1q +Ommjhlg6mwj9ZrStxzV86LXFAoGAISX22miyiZjywCE8x7hcnyVp8YcmXUAFSMDw +CVumsMNuXX9vaj3kb9a6lvM4D005RkQDgEtham4bC6F8QjlLgkeslmRPOpD2qdgo +fxZ123Fljbvw1gwyybF5Y1wKRnrvWeUV6dNyamkB91BqMPJrheNQUo5YBzbyZrLV +U7bKYmECgYEAj7ekhtCiIUMih8noMfpHR0lJG4VhdfqiVL+w25CgnpZJDa6o7pYD +F5fMivdfdKaSAOA5mUGN5u6NrTpfFKhHDucpIOM2+WGOzbbWEc/gEDQ/xEyPEhxj +t4ErMTByrDGKtGuaolNYzAU0SSbCnAAH3L2MRChC9Qv7f5ZVOZX1GPQ= +-----END RSA PRIVATE KEY----- diff --git a/src/core/tsi/test_creds/multi-domain.pem b/src/core/tsi/test_creds/multi-domain.pem new file mode 100644 index 00000000000..c60d2baef6e --- /dev/null +++ b/src/core/tsi/test_creds/multi-domain.pem @@ -0,0 +1,23 @@ +-----BEGIN CERTIFICATE----- +MIIDwDCCAqigAwIBAgIUYSe4/8nE/RVUX7e7QeyCmqPWd6AwDQYJKoZIhvcNAQEL +BQAwODELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMQswCQYDVQQHDAJTRjEPMA0G +A1UECwwGR29vZ2xlMB4XDTE5MDgwNTE4MDYwNVoXDTIwMDgwNDE4MDYwNVowODEL +MAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMQswCQYDVQQHDAJTRjEPMA0GA1UECwwG +R29vZ2xlMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1e+GwyVNsoKu +7PqvOf/EubN45rB5o5PQF9A5fBPpiBtKZdvbbOouGlulRwaMQOLDZi9M6l/AhE1b +207+iSBTn9jSQT0elaYwVtKgb/qoehQjFAG8BckPmA9E4SDx2Ug9AtV3rTVs4V2y +aDHNSfDSXQ2PS9fuIx7FK5mMnUM2fjskcZquHV5f8McXEtvpuTktnb+KDgETO0Cd +u3+rf/RtraTuKZb0kmAgf+KaNWDL2j5QsFKa6sT4812Vfwaevm9qKOtzgAFobCwd +Vt+Ap/B0XWj4CmzJMPN/SXESluoBHszmTi6QmkTEzYbzmD/ObyTxXVKu46kRVmJK +Xh6BE1wk2QIDAQABo4HBMIG+MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgXgMIGjBgNV +HREEgZswgZiCE2Zvby50ZXN0LmRvbWFpbi5jb22CE2Jhci50ZXN0LmRvbWFpbi5j +b22GIGh0dHBzOi8vZm9vLnRlc3QuZG9tYWluLmNvbS90ZXN0hiBodHRwczovL2Jh +ci50ZXN0LmRvbWFpbi5jb20vdGVzdIETZm9vQHRlc3QuZG9tYWluLmNvbYETYmFy +QHRlc3QuZG9tYWluLmNvbTANBgkqhkiG9w0BAQsFAAOCAQEAzBhVGeqIntQs9qpK +xGOjpFTBMzCjYORNAq09Otkc/IBwtPOq0K2as7fp6Vr5DRStN7hDSBrMjZh+XujY +3GNEv4pIR5fWwrZg/fnNyG5BIUhdq/qtC3JAMqBjno3OJjg1t4KzS4l+ozHeevJA +qT9t6aodsn1r7w89MfAVGPIw7D3n9n5N4z2b/co17W8B0RyMWX2PmQWkEqn7kId/ +Jj+hmw2n9UV1IU3xhcepxG+wzjFLIB9nsDwgtZogK6f5p9FFBG8raqk6QhVSlRgh +JmNqmK5+hyUy1zbjGqgfM5eVmQ/A3qWVQTrk3HeTr2hO9GoBHeXQfinjlIhnbbtJ +xouhvA== +-----END CERTIFICATE----- diff --git a/test/core/tsi/ssl_transport_security_test.cc b/test/core/tsi/ssl_transport_security_test.cc index 5985b0ecaa5..014127a3042 100644 --- a/test/core/tsi/ssl_transport_security_test.cc +++ b/test/core/tsi/ssl_transport_security_test.cc @@ -790,6 +790,26 @@ void ssl_tsi_test_duplicate_root_certificates() { gpr_free(dup_root_cert); } +void ssl_tsi_test_uri_email_subject_alt_names() { + char* cert = load_file(SSL_TSI_TEST_CREDENTIALS_DIR, "multi-domain.pem"); + tsi_peer peer; + GPR_ASSERT(extract_x509_subject_names_from_pem_cert(cert, &peer) == TSI_OK); + // One for common name, one for certificate, and six for SAN fields. + size_t expected_property_count = 8; + GPR_ASSERT(peer.property_count == expected_property_count); + // Check DNS + GPR_ASSERT(check_subject_alt_name(&peer, "foo.test.domain.com") == 1); + GPR_ASSERT(check_subject_alt_name(&peer, "bar.test.domain.com") == 1); + // Check URI + GPR_ASSERT( + check_subject_alt_name(&peer, "https://foo.test.domain.com/test") == 1); + GPR_ASSERT( + check_subject_alt_name(&peer, "https://bar.test.domain.com/test") == 1); + // Check email address + GPR_ASSERT(check_subject_alt_name(&peer, "foo@test.domain.com") == 1); + GPR_ASSERT(check_subject_alt_name(&peer, "bar@test.domain.com") == 1); +} + int main(int argc, char** argv) { grpc::testing::TestEnvironment env(argc, argv); grpc_init(); @@ -815,6 +835,7 @@ int main(int argc, char** argv) { ssl_tsi_test_do_round_trip_odd_buffer_size(); ssl_tsi_test_handshaker_factory_internals(); ssl_tsi_test_duplicate_root_certificates(); + ssl_tsi_test_uri_email_subject_alt_names(); grpc_shutdown(); return 0; } From 00793c1c786cfc3091f3ee1f382b5dd4a9087e93 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Mon, 5 Aug 2019 15:42:05 -0700 Subject: [PATCH 1105/1555] Don't use != in InlinedVector::== --- src/core/lib/gprpp/inlined_vector.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/lib/gprpp/inlined_vector.h b/src/core/lib/gprpp/inlined_vector.h index ffc37387ec3..f511d520f50 100644 --- a/src/core/lib/gprpp/inlined_vector.h +++ b/src/core/lib/gprpp/inlined_vector.h @@ -100,7 +100,9 @@ class InlinedVector { bool operator==(const InlinedVector& other) const { if (size_ != other.size_) return false; for (size_t i = 0; i < size_; ++i) { - if (data()[i] != other.data()[i]) return false; + // Note that this uses == instead of != so that the data class doesn't + // have to implement !=. + if (!(data()[i] == other.data()[i])) return false; } return true; } From e32980fba211022c632a4c7a0785198f3f73dee0 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 5 Aug 2019 16:19:49 -0700 Subject: [PATCH 1106/1555] Quit waiting for a day --- examples/python/auth/customized_auth_client.py | 2 -- examples/python/auth/customized_auth_server.py | 13 +++---------- examples/python/cancellation/server.py | 16 +++------------- examples/python/compression/server.py | 8 +------- examples/python/debug/debug_server.py | 8 +------- examples/python/errors/server.py | 9 +-------- examples/python/helloworld/greeter_server.py | 9 +-------- .../helloworld/greeter_server_with_reflection.py | 9 +-------- .../interceptors/headers/greeter_server.py | 9 +-------- examples/python/metadata/metadata_server.py | 9 +-------- examples/python/multiplex/multiplex_server.py | 8 +------- .../python/route_guide/route_guide_server.py | 8 +------- .../wait_for_ready/wait_for_ready_example.py | 2 -- src/python/grpcio_tests/tests/interop/server.py | 11 ++--------- 14 files changed, 17 insertions(+), 104 deletions(-) diff --git a/examples/python/auth/customized_auth_client.py b/examples/python/auth/customized_auth_client.py index 0236c07adb1..9bcf1b5085f 100644 --- a/examples/python/auth/customized_auth_client.py +++ b/examples/python/auth/customized_auth_client.py @@ -29,8 +29,6 @@ from examples.python.auth import _credentials _LOGGER = logging.getLogger(__name__) _LOGGER.setLevel(logging.INFO) -_ONE_DAY_IN_SECONDS = 60 * 60 * 24 - _SERVER_ADDR_TEMPLATE = 'localhost:%d' _SIGNATURE_HEADER_KEY = 'x-signature' diff --git a/examples/python/auth/customized_auth_server.py b/examples/python/auth/customized_auth_server.py index 1debc6c3c5f..374537c64fc 100644 --- a/examples/python/auth/customized_auth_server.py +++ b/examples/python/auth/customized_auth_server.py @@ -20,7 +20,6 @@ from __future__ import print_function import argparse import contextlib import logging -import time from concurrent import futures import grpc @@ -31,8 +30,6 @@ from examples.python.auth import _credentials _LOGGER = logging.getLogger(__name__) _LOGGER.setLevel(logging.INFO) -_ONE_DAY_IN_SECONDS = 60 * 60 * 24 - _LISTEN_ADDRESS_TEMPLATE = 'localhost:%d' _SIGNATURE_HEADER_KEY = 'x-signature' @@ -85,7 +82,7 @@ def run_server(port): server.start() try: - yield port + yield server, port, finally: server.stop(0) @@ -96,13 +93,9 @@ def main(): '--port', nargs='?', type=int, default=50051, help='the listening port') args = parser.parse_args() - with run_server(args.port) as port: + with run_server(args.port) as (server, port): logging.info('Server is listening at port :%d', port) - try: - while True: - time.sleep(_ONE_DAY_IN_SECONDS) - except KeyboardInterrupt: - pass + server.wait_for_termination() if __name__ == '__main__': diff --git a/examples/python/cancellation/server.py b/examples/python/cancellation/server.py index 9597e8941b4..f27825d68ed 100644 --- a/examples/python/cancellation/server.py +++ b/examples/python/cancellation/server.py @@ -19,9 +19,7 @@ from __future__ import print_function from concurrent import futures import argparse -import contextlib import logging -import time import threading import grpc @@ -32,7 +30,6 @@ from examples.python.cancellation import hash_name_pb2_grpc _LOGGER = logging.getLogger(__name__) _SERVER_HOST = 'localhost' -_ONE_DAY_IN_SECONDS = 60 * 60 * 24 _DESCRIPTION = "A server for finding hashes similar to names." @@ -88,7 +85,6 @@ class HashFinder(hash_name_pb2_grpc.HashFinderServicer): _LOGGER.debug("Regained servicer thread.") -@contextlib.contextmanager def _running_server(port, maximum_hashes): # We use only a single servicer thread here to demonstrate that, if managed # carefully, cancelled RPCs can need not continue occupying servicers @@ -101,12 +97,7 @@ def _running_server(port, maximum_hashes): actual_port = server.add_insecure_port(address) server.start() print("Server listening at '{}'".format(address)) - try: - yield actual_port - except KeyboardInterrupt: - pass - finally: - server.stop(None) + return server def main(): @@ -124,9 +115,8 @@ def main(): nargs='?', help='The maximum number of hashes to search before cancelling.') args = parser.parse_args() - with _running_server(args.port, args.maximum_hashes): - while True: - time.sleep(_ONE_DAY_IN_SECONDS) + server = _running_server(args.port, args.maximum_hashes) + server.wait_for_termination() if __name__ == "__main__": diff --git a/examples/python/compression/server.py b/examples/python/compression/server.py index bc13e60cb5b..69411f10eb0 100644 --- a/examples/python/compression/server.py +++ b/examples/python/compression/server.py @@ -21,7 +21,6 @@ from concurrent import futures import argparse import logging import threading -import time import grpc from examples import helloworld_pb2 @@ -36,7 +35,6 @@ _COMPRESSION_OPTIONS = { _LOGGER = logging.getLogger(__name__) _SERVER_HOST = 'localhost' -_ONE_DAY_IN_SECONDS = 60 * 60 * 24 class Greeter(helloworld_pb2_grpc.GreeterServicer): @@ -72,11 +70,7 @@ def run_server(server_compression, no_compress_every_n, port): server.add_insecure_port(address) server.start() print("Server listening at '{}'".format(address)) - try: - while True: - time.sleep(_ONE_DAY_IN_SECONDS) - except KeyboardInterrupt: - server.stop(None) + server.wait_for_termination() def main(): diff --git a/examples/python/debug/debug_server.py b/examples/python/debug/debug_server.py index 64926b53457..3bc52f7c3f4 100644 --- a/examples/python/debug/debug_server.py +++ b/examples/python/debug/debug_server.py @@ -19,7 +19,6 @@ from __future__ import print_function import argparse import logging -import time from concurrent import futures import random @@ -32,7 +31,6 @@ from examples import helloworld_pb2_grpc _LOGGER = logging.getLogger(__name__) _LOGGER.setLevel(logging.INFO) -_ONE_DAY_IN_SECONDS = 60 * 60 * 24 _RANDOM_FAILURE_RATE = 0.3 @@ -78,11 +76,7 @@ def main(): server = create_server(addr=args.addr, failure_rate=args.failure_rate) server.start() - try: - while True: - time.sleep(_ONE_DAY_IN_SECONDS) - except KeyboardInterrupt: - server.stop(0) + server.wait_for_termination() if __name__ == '__main__': diff --git a/examples/python/errors/server.py b/examples/python/errors/server.py index 50d4a2ac671..a4a70e1e201 100644 --- a/examples/python/errors/server.py +++ b/examples/python/errors/server.py @@ -14,7 +14,6 @@ """This example sends out rich error status from server-side.""" from concurrent import futures -import time import logging import threading @@ -27,8 +26,6 @@ from google.rpc import code_pb2, status_pb2, error_details_pb2 from examples import helloworld_pb2 from examples import helloworld_pb2_grpc -_ONE_DAY_IN_SECONDS = 60 * 60 * 24 - def create_greet_limit_exceed_error_status(name): detail = any_pb2.Any() @@ -73,11 +70,7 @@ def create_server(server_address): def serve(server): server.start() - try: - while True: - time.sleep(_ONE_DAY_IN_SECONDS) - except KeyboardInterrupt: - server.stop(None) + server.wait_for_termination() def main(): diff --git a/examples/python/helloworld/greeter_server.py b/examples/python/helloworld/greeter_server.py index e3b4f2c1ff9..7bc3f2f725c 100644 --- a/examples/python/helloworld/greeter_server.py +++ b/examples/python/helloworld/greeter_server.py @@ -14,7 +14,6 @@ """The Python implementation of the GRPC helloworld.Greeter server.""" from concurrent import futures -import time import logging import grpc @@ -22,8 +21,6 @@ import grpc import helloworld_pb2 import helloworld_pb2_grpc -_ONE_DAY_IN_SECONDS = 60 * 60 * 24 - class Greeter(helloworld_pb2_grpc.GreeterServicer): @@ -36,11 +33,7 @@ def serve(): helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server) server.add_insecure_port('[::]:50051') server.start() - try: - while True: - time.sleep(_ONE_DAY_IN_SECONDS) - except KeyboardInterrupt: - server.stop(0) + server.wait_for_termination() if __name__ == '__main__': diff --git a/examples/python/helloworld/greeter_server_with_reflection.py b/examples/python/helloworld/greeter_server_with_reflection.py index 5acedbcb71f..7c73a42eb66 100644 --- a/examples/python/helloworld/greeter_server_with_reflection.py +++ b/examples/python/helloworld/greeter_server_with_reflection.py @@ -14,7 +14,6 @@ """The reflection-enabled version of gRPC helloworld.Greeter server.""" from concurrent import futures -import time import logging import grpc @@ -23,8 +22,6 @@ from grpc_reflection.v1alpha import reflection import helloworld_pb2 import helloworld_pb2_grpc -_ONE_DAY_IN_SECONDS = 60 * 60 * 24 - class Greeter(helloworld_pb2_grpc.GreeterServicer): @@ -42,11 +39,7 @@ def serve(): reflection.enable_server_reflection(SERVICE_NAMES, server) server.add_insecure_port('[::]:50051') server.start() - try: - while True: - time.sleep(_ONE_DAY_IN_SECONDS) - except KeyboardInterrupt: - server.stop(0) + server.wait_for_termination() if __name__ == '__main__': diff --git a/examples/python/interceptors/headers/greeter_server.py b/examples/python/interceptors/headers/greeter_server.py index 6b0f4058bcd..32706ae7094 100644 --- a/examples/python/interceptors/headers/greeter_server.py +++ b/examples/python/interceptors/headers/greeter_server.py @@ -14,7 +14,6 @@ """The Python implementation of the GRPC helloworld.Greeter server.""" from concurrent import futures -import time import logging import grpc @@ -23,8 +22,6 @@ import helloworld_pb2 import helloworld_pb2_grpc from request_header_validator_interceptor import RequestHeaderValidatorInterceptor -_ONE_DAY_IN_SECONDS = 60 * 60 * 24 - class Greeter(helloworld_pb2_grpc.GreeterServicer): @@ -42,11 +39,7 @@ def serve(): helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server) server.add_insecure_port('[::]:50051') server.start() - try: - while True: - time.sleep(_ONE_DAY_IN_SECONDS) - except KeyboardInterrupt: - server.stop(0) + server.wait_for_termination() if __name__ == '__main__': diff --git a/examples/python/metadata/metadata_server.py b/examples/python/metadata/metadata_server.py index a4329df79aa..79eb380092e 100644 --- a/examples/python/metadata/metadata_server.py +++ b/examples/python/metadata/metadata_server.py @@ -15,7 +15,6 @@ from __future__ import print_function from concurrent import futures -import time import logging import grpc @@ -23,8 +22,6 @@ import grpc import helloworld_pb2 import helloworld_pb2_grpc -_ONE_DAY_IN_SECONDS = 60 * 60 * 24 - class Greeter(helloworld_pb2_grpc.GreeterServicer): @@ -44,11 +41,7 @@ def serve(): helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server) server.add_insecure_port('[::]:50051') server.start() - try: - while True: - time.sleep(_ONE_DAY_IN_SECONDS) - except KeyboardInterrupt: - server.stop(0) + server.wait_for_termination() if __name__ == '__main__': diff --git a/examples/python/multiplex/multiplex_server.py b/examples/python/multiplex/multiplex_server.py index c01824b3a97..f168fe7f1b3 100644 --- a/examples/python/multiplex/multiplex_server.py +++ b/examples/python/multiplex/multiplex_server.py @@ -26,8 +26,6 @@ import route_guide_pb2 import route_guide_pb2_grpc import route_guide_resources -_ONE_DAY_IN_SECONDS = 60 * 60 * 24 - def _get_feature(feature_db, point): """Returns Feature at given location or None.""" @@ -129,11 +127,7 @@ def serve(): _RouteGuideServicer(), server) server.add_insecure_port('[::]:50051') server.start() - try: - while True: - time.sleep(_ONE_DAY_IN_SECONDS) - except KeyboardInterrupt: - server.stop(0) + server.wait_for_termination() if __name__ == '__main__': diff --git a/examples/python/route_guide/route_guide_server.py b/examples/python/route_guide/route_guide_server.py index e00cb699084..4ab33e68f28 100644 --- a/examples/python/route_guide/route_guide_server.py +++ b/examples/python/route_guide/route_guide_server.py @@ -24,8 +24,6 @@ import route_guide_pb2 import route_guide_pb2_grpc import route_guide_resources -_ONE_DAY_IN_SECONDS = 60 * 60 * 24 - def get_feature(feature_db, point): """Returns Feature at given location or None.""" @@ -119,11 +117,7 @@ def serve(): RouteGuideServicer(), server) server.add_insecure_port('[::]:50051') server.start() - try: - while True: - time.sleep(_ONE_DAY_IN_SECONDS) - except KeyboardInterrupt: - server.stop(0) + server.wait_for_termination() if __name__ == '__main__': diff --git a/examples/python/wait_for_ready/wait_for_ready_example.py b/examples/python/wait_for_ready/wait_for_ready_example.py index a0f076e894a..8dd770d6a0e 100644 --- a/examples/python/wait_for_ready/wait_for_ready_example.py +++ b/examples/python/wait_for_ready/wait_for_ready_example.py @@ -28,8 +28,6 @@ from examples import helloworld_pb2_grpc _LOGGER = logging.getLogger(__name__) _LOGGER.setLevel(logging.INFO) -_ONE_DAY_IN_SECONDS = 60 * 60 * 24 - @contextmanager def get_free_loopback_tcp_port(): diff --git a/src/python/grpcio_tests/tests/interop/server.py b/src/python/grpcio_tests/tests/interop/server.py index 3611ffdbb2f..aaeee52ed87 100644 --- a/src/python/grpcio_tests/tests/interop/server.py +++ b/src/python/grpcio_tests/tests/interop/server.py @@ -16,7 +16,6 @@ import argparse from concurrent import futures import logging -import time import grpc from src.proto.grpc.testing import test_pb2_grpc @@ -25,7 +24,6 @@ from tests.interop import service from tests.interop import resources from tests.unit import test_common -_ONE_DAY_IN_SECONDS = 60 * 60 * 24 logging.basicConfig() _LOGGER = logging.getLogger(__name__) @@ -55,13 +53,8 @@ def serve(): server.start() _LOGGER.info('Server serving.') - try: - while True: - time.sleep(_ONE_DAY_IN_SECONDS) - except BaseException as e: - _LOGGER.info('Caught exception "%s"; stopping server...', e) - server.stop(None) - _LOGGER.info('Server stopped; exiting.') + server.wait_for_termination() + _LOGGER.info('Server stopped; exiting.') if __name__ == '__main__': From 0aa30c6f239ded57cb191c1c18038dd5b293d091 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 5 Aug 2019 16:34:47 -0700 Subject: [PATCH 1107/1555] Remove unintentional dependencies --- src/python/grpcio_tests/tests/interop/BUILD.bazel | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/python/grpcio_tests/tests/interop/BUILD.bazel b/src/python/grpcio_tests/tests/interop/BUILD.bazel index 43fdc7ab462..8ac3f7d52d5 100644 --- a/src/python/grpcio_tests/tests/interop/BUILD.bazel +++ b/src/python/grpcio_tests/tests/interop/BUILD.bazel @@ -32,9 +32,7 @@ py_library( "//src/python/grpcio/grpc:grpcio", "//src/python/grpcio_tests/tests:bazel_namespace_package_hack", "//src/proto/grpc/testing:empty_py_pb2", - "//src/proto/grpc/testing:empty_py_pb2_grpc", "//src/proto/grpc/testing:py_messages_proto", - "//src/proto/grpc/testing:messages_py_pb2_grpc", "//src/proto/grpc/testing:py_test_proto", "//src/proto/grpc/testing:test_py_pb2_grpc", requirement("google-auth"), From 8c99479bc7bc90177357376207a9056857b4d7ce Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 5 Aug 2019 16:38:15 -0700 Subject: [PATCH 1108/1555] move ChannelExtensions to Grpc.Core.Api --- .../Interceptors/ChannelExtensions.cs | 12 ++++++------ src/csharp/Grpc.Core/ForwardedTypes.cs | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) rename src/csharp/{Grpc.Core => Grpc.Core.Api}/Interceptors/ChannelExtensions.cs (87%) diff --git a/src/csharp/Grpc.Core/Interceptors/ChannelExtensions.cs b/src/csharp/Grpc.Core.Api/Interceptors/ChannelExtensions.cs similarity index 87% rename from src/csharp/Grpc.Core/Interceptors/ChannelExtensions.cs rename to src/csharp/Grpc.Core.Api/Interceptors/ChannelExtensions.cs index c7d0c2472a1..fe3b516857e 100644 --- a/src/csharp/Grpc.Core/Interceptors/ChannelExtensions.cs +++ b/src/csharp/Grpc.Core.Api/Interceptors/ChannelExtensions.cs @@ -38,9 +38,9 @@ namespace Grpc.Core.Interceptors /// building a chain like "channel.Intercept(c).Intercept(b).Intercept(a)". Note that /// in this case, the last interceptor added will be the first to take control. /// - public static CallInvoker Intercept(this Channel channel, Interceptor interceptor) + public static CallInvoker Intercept(this ChannelBase channel, Interceptor interceptor) { - return new DefaultCallInvoker(channel).Intercept(interceptor); + return channel.CreateCallInvoker().Intercept(interceptor); } /// @@ -59,9 +59,9 @@ namespace Grpc.Core.Interceptors /// building a chain like "channel.Intercept(c).Intercept(b).Intercept(a)". Note that /// in this case, the last interceptor added will be the first to take control. /// - public static CallInvoker Intercept(this Channel channel, params Interceptor[] interceptors) + public static CallInvoker Intercept(this ChannelBase channel, params Interceptor[] interceptors) { - return new DefaultCallInvoker(channel).Intercept(interceptors); + return channel.CreateCallInvoker().Intercept(interceptors); } /// @@ -79,9 +79,9 @@ namespace Grpc.Core.Interceptors /// building a chain like "channel.Intercept(c).Intercept(b).Intercept(a)". Note that /// in this case, the last interceptor added will be the first to take control. /// - public static CallInvoker Intercept(this Channel channel, Func interceptor) + public static CallInvoker Intercept(this ChannelBase channel, Func interceptor) { - return new DefaultCallInvoker(channel).Intercept(interceptor); + return channel.CreateCallInvoker().Intercept(interceptor); } } } diff --git a/src/csharp/Grpc.Core/ForwardedTypes.cs b/src/csharp/Grpc.Core/ForwardedTypes.cs index 4394a7c907c..eaf974c3356 100644 --- a/src/csharp/Grpc.Core/ForwardedTypes.cs +++ b/src/csharp/Grpc.Core/ForwardedTypes.cs @@ -38,6 +38,7 @@ using Grpc.Core.Utils; [assembly:TypeForwardedToAttribute(typeof(CallInvoker))] [assembly:TypeForwardedToAttribute(typeof(CallInvokerExtensions))] [assembly:TypeForwardedToAttribute(typeof(CallOptions))] +[assembly:TypeForwardedToAttribute(typeof(ChannelExtensions))] [assembly:TypeForwardedToAttribute(typeof(ClientBase))] [assembly:TypeForwardedToAttribute(typeof(ClientBase<>))] [assembly:TypeForwardedToAttribute(typeof(ChannelCredentials))] From a77404ae6b8e286ccf0e5b61f7e3b1d3d3fafd3c Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 5 Aug 2019 16:38:41 -0700 Subject: [PATCH 1109/1555] Add README to bazel test --- bazel/test/python_test_repo/README.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 bazel/test/python_test_repo/README.md diff --git a/bazel/test/python_test_repo/README.md b/bazel/test/python_test_repo/README.md new file mode 100644 index 00000000000..d9dfd1d99b5 --- /dev/null +++ b/bazel/test/python_test_repo/README.md @@ -0,0 +1,5 @@ +## Bazel Workspace Test + +This directory houses a test ensuring that downstream projects can use +`@com_github_grpc_grpc//src/python/grpcio:grpcio`, `py_proto_library`, and +`py_grpc_library`. From b7eaa36a8cb9264cf8cc7dbc7248086805b066ec Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 5 Aug 2019 16:43:31 -0700 Subject: [PATCH 1110/1555] Add todo to create new kokoro job. --- tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh b/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh index eda730d3a54..00bf971a3e2 100755 --- a/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh +++ b/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh @@ -29,6 +29,9 @@ bazel test --spawn_strategy=standalone --genrule_strategy=standalone --test_outp bazel clean --expunge bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //src/python/... bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //examples/python/... + +# TODO(https://github.com/grpc/grpc/issues/19854): Move this to a new kokoro +# job. (cd /var/local/git/grpc/bazel/test/python_test_repo; bazel test --test_output=errors //... ) From 81719815927e4d8a0621ab97d5fde5a0af6c61f3 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Mon, 5 Aug 2019 16:37:33 -0700 Subject: [PATCH 1111/1555] Added Bazel BUILD for tests/ A few test failures to resolve --- src/objective-c/BUILD | 40 +++- .../GRPCClient/private/GRPCOpBatchLog.h | 1 + .../grpc_objc_internal_library.bzl | 174 +++++++++++++++ src/objective-c/tests/BUILD | 202 ++++++++++++++++++ .../tests/InteropTests/InteropTests.h | 6 + .../tests/InteropTests/InteropTests.m | 8 + .../InteropTestsMultipleChannels.m | 3 +- src/objective-c/tests/MacTests/StressTests.h | 6 + src/objective-c/tests/MacTests/StressTests.m | 8 + 9 files changed, 446 insertions(+), 2 deletions(-) create mode 100644 src/objective-c/grpc_objc_internal_library.bzl create mode 100644 src/objective-c/tests/BUILD diff --git a/src/objective-c/BUILD b/src/objective-c/BUILD index 2492ce8a21f..c3629d0ada4 100644 --- a/src/objective-c/BUILD +++ b/src/objective-c/BUILD @@ -87,10 +87,48 @@ grpc_objc_library( # Different from Cocoapods, do not import as if @com_google_protobuf//:protobuf_objc is a framework, # use the real paths of @com_google_protobuf//:protobuf_objc instead defines = ["GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0"], - includes = ["src/objective-c"], deps = [ ":grpc_objc_client", ":rx_library", "@com_google_protobuf//:protobuf_objc", ], ) + +grpc_objc_library( + name = "grpc_objc_client_internal_testing", + srcs = glob( + [ + "GRPCClient/*.m", + "GRPCClient/private/*.m", + "GRPCClient/internal_testing/*.m", + "ProtoRPC/*.m", + ], + exclude = ["GRPCClient/GRPCCall+GID.m"], + ), + hdrs = glob( + [ + "GRPCClient/*.h", + "GRPCClient/internal/*.h", + "GRPCClient/internal_testing/*.h", + "ProtoRPC/*.h", + ], + exclude = ["GRPCClient/GRPCCall+GID.h"], + ), + includes = ["."], + data = ["//:gRPCCertificates"], + defines = [ + "GRPC_TEST_OBJC=1", + "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0", + ], + textual_hdrs = glob( + [ + "GRPCClient/private/*.h", + ], + ), + deps = [ + ":rx_library", + "//:grpc_objc", + "@com_google_protobuf//:protobuf_objc", + ], + visibility = ["//visibility:public"], +) diff --git a/src/objective-c/GRPCClient/private/GRPCOpBatchLog.h b/src/objective-c/GRPCClient/private/GRPCOpBatchLog.h index 700d19a206b..1235a5e8d05 100644 --- a/src/objective-c/GRPCClient/private/GRPCOpBatchLog.h +++ b/src/objective-c/GRPCClient/private/GRPCOpBatchLog.h @@ -17,6 +17,7 @@ */ #ifdef GRPC_TEST_OBJC +#import /** * Logs the op batches of a client. Used for testing. diff --git a/src/objective-c/grpc_objc_internal_library.bzl b/src/objective-c/grpc_objc_internal_library.bzl new file mode 100644 index 00000000000..b043a0f6880 --- /dev/null +++ b/src/objective-c/grpc_objc_internal_library.bzl @@ -0,0 +1,174 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# This is for the gRPC build system. This isn't intended to be used outsite of +# the BUILD file for gRPC. It contains the mapping for the template system we +# use to generate other platform's build system files. +# +# Please consider that there should be a high bar for additions and changes to +# this file. +# Each rule listed must be re-written for Google's internal build system, and +# each change must be ported from one to the other. +# + +load( + "//bazel:generate_objc.bzl", + "generate_objc", + "generate_objc_hdrs", + "generate_objc_srcs", + "generate_objc_non_arc_srcs" +) +load("//bazel:protobuf.bzl", "well_known_proto_libs") + +def grpc_objc_testing_library( + name, + srcs = [], + hdrs = [], + textual_hdrs = [], + data = [], + deps = [], + defines = [], + includes = []): + """objc_library for testing, only works in //src/objective-c/tests + + Args: + name: name of target + hdrs: public headers + srcs: all source files (.m) + textual_hdrs: private headers + data: any other bundle resources + defines: preprocessors + includes: added to search path, always [the path to objc directory] + deps: dependencies + """ + + additional_deps = [ + ":RemoteTest", + "//src/objective-c:grpc_objc_client_internal_testing", + ] + + if not name == "TestConfigs": + additional_deps += [":TestConfigs"] + + native.objc_library( + name = name, + hdrs = hdrs, + srcs = srcs, + textual_hdrs = textual_hdrs, + data = data, + defines = defines, + includes = includes, + deps = deps + additional_deps, + ) + +def local_objc_grpc_library(name, deps, srcs = [], use_well_known_protos = False, **kwargs): + """!!For local targets within the gRPC repository only!! Will not work outside of the repo + """ + objc_grpc_library_name = "_" + name + "_objc_grpc_library" + + generate_objc( + name = objc_grpc_library_name, + srcs = srcs, + deps = deps, + use_well_known_protos = use_well_known_protos, + **kwargs + ) + + generate_objc_hdrs( + name = objc_grpc_library_name + "_hdrs", + src = ":" + objc_grpc_library_name, + ) + + generate_objc_non_arc_srcs( + name = objc_grpc_library_name + "_non_arc_srcs", + src = ":" + objc_grpc_library_name, + ) + + arc_srcs = None + if len(srcs) > 0: + generate_objc_srcs( + name = objc_grpc_library_name + "_srcs", + src = ":" + objc_grpc_library_name, + ) + arc_srcs = [":" + objc_grpc_library_name + "_srcs"] + + native.objc_library( + name = name, + hdrs = [":" + objc_grpc_library_name + "_hdrs"], + non_arc_srcs = [":" + objc_grpc_library_name + "_non_arc_srcs"], + srcs = arc_srcs, + defines = [ + "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0", + "GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO=0", + ], + includes = [ + "_generated_protos", + "src/objective-c", + ], + deps = [ + "//src/objective-c:proto_objc_rpc", + "@com_google_protobuf//:protobuf_objc", + ], + ) + +def testing_objc_grpc_library(name, deps, srcs = [], use_well_known_protos = False, **kwargs): + """!!For testing within the gRPC repository only!! Will not work outside of the repo + """ + objc_grpc_library_name = "_" + name + "_objc_grpc_library" + + generate_objc( + name = objc_grpc_library_name, + srcs = srcs, + deps = deps, + use_well_known_protos = use_well_known_protos, + **kwargs + ) + + generate_objc_hdrs( + name = objc_grpc_library_name + "_hdrs", + src = ":" + objc_grpc_library_name, + ) + + generate_objc_non_arc_srcs( + name = objc_grpc_library_name + "_non_arc_srcs", + src = ":" + objc_grpc_library_name, + ) + + arc_srcs = None + if len(srcs) > 0: + generate_objc_srcs( + name = objc_grpc_library_name + "_srcs", + src = ":" + objc_grpc_library_name, + ) + arc_srcs = [":" + objc_grpc_library_name + "_srcs"] + + native.objc_library( + name = name, + hdrs = [":" + objc_grpc_library_name + "_hdrs"], + non_arc_srcs = [":" + objc_grpc_library_name + "_non_arc_srcs"], + srcs = arc_srcs, + defines = [ + "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0", + "GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO=0", + ], + includes = [ + "_generated_protos", + "src/objective-c", + ], + deps = [ + "//src/objective-c:grpc_objc_client_internal_testing", + "@com_google_protobuf//:protobuf_objc", + ], + ) diff --git a/src/objective-c/tests/BUILD b/src/objective-c/tests/BUILD new file mode 100644 index 00000000000..2718cca5880 --- /dev/null +++ b/src/objective-c/tests/BUILD @@ -0,0 +1,202 @@ +# gRPC Bazel BUILD file. +# +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +licenses(["notice"]) # Apache v2 + +package(default_visibility = ["//visibility:private"]) + +load( + "//src/objective-c:grpc_objc_internal_library.bzl", + "grpc_objc_testing_library", + "testing_objc_grpc_library" +) +load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle") +load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test") +load("@build_bazel_rules_apple//apple:macos.bzl", "macos_unit_test") +load("@build_bazel_rules_apple//apple:tvos.bzl", "tvos_unit_test") + +exports_files(["LICENSE"]) + +proto_library( + name = "messages_proto", + srcs = ["RemoteTestClient/messages.proto"], +) + +proto_library( + name = "test_proto", + srcs = ["RemoteTestClient/test.proto"], + deps = [":messages_proto"], +) + +testing_objc_grpc_library( + name = "RemoteTest", + srcs = ["RemoteTestClient/test.proto"], + use_well_known_protos = True, + deps = [":test_proto"], +) + +apple_resource_bundle( + name = "TestCertificates", + resources = ["TestCertificates.bundle/test-certificates.pem"], +) + +# TestConfigs is added to each grpc_objc_testing_library's deps +grpc_objc_testing_library( + name = "TestConfigs", + hdrs = ["version.h"], + data = [":TestCertificates"], + defines = [ + "HOST_PORT_LOCALSSL=localhost:5051", + "HOST_PORT_LOCAL=localhost:5050", + "HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com", + ], +) + +grpc_objc_testing_library( + name = "CronetConfig", + srcs = ["ConfigureCronet.m"], + hdrs = ["ConfigureCronet.h"], +) + +grpc_objc_testing_library( + name = "InteropTests-lib", + hdrs = ["InteropTests/InteropTests.h"], + srcs = ["InteropTests/InteropTests.m"], + deps = [ + ":InteropTestsBlockCallbacks-lib", + ":CronetConfig", + ], +) + +grpc_objc_testing_library( + name = "InteropTestsRemote-lib", + srcs = ["InteropTests/InteropTestsRemote.m"], + deps = [":InteropTests-lib"], +) + +grpc_objc_testing_library( + name = "InteropTestsBlockCallbacks-lib", + hdrs = ["InteropTests/InteropTestsBlockCallbacks.h"], + srcs = ["InteropTests/InteropTestsBlockCallbacks.m"], +) + +grpc_objc_testing_library( + name = "InteropTestsLocalSSL-lib", + srcs = ["InteropTests/InteropTestsLocalSSL.m"], + deps = [":InteropTests-lib"], +) + +grpc_objc_testing_library( + name = "InteropTestsLocalCleartext-lib", + srcs = ["InteropTests/InteropTestsLocalCleartext.m"], + deps = [":InteropTests-lib"], +) + +grpc_objc_testing_library( + name = "InteropTestsMultipleChannels-lib", + srcs = ["InteropTests/InteropTestsMultipleChannels.m"], + deps = [":InteropTests-lib"], +) + +grpc_objc_testing_library( + name = "RxLibraryUnitTests-lib", + srcs = ["UnitTests/RxLibraryUnitTests.m"], +) + +grpc_objc_testing_library( + name = "GRPCClientTests-lib", + srcs = ["UnitTests/GRPCClientTests.m"], +) + +grpc_objc_testing_library( + name = "APIv2Tests-lib", + srcs = ["UnitTests/APIv2Tests.m"], +) + +grpc_objc_testing_library( + name = "ChannelPoolTest-lib", + srcs = ["UnitTests/ChannelPoolTest.m"], +) + +grpc_objc_testing_library( + name = "ChannelTests-lib", + srcs = ["UnitTests/ChannelTests.m"], +) + +grpc_objc_testing_library( + name = "NSErrorUnitTests-lib", + srcs = ["UnitTests/NSErrorUnitTests.m"], +) + +grpc_objc_testing_library( + name = "MacStressTests-lib", + srcs = glob([ + "MacTests/*.m", + ]), + hdrs = ["MacTests/StressTests.h"], +) + +ios_unit_test( + name = "UnitTests", + minimum_os_version = "8.0", + deps = [ + ":RxLibraryUnitTests-lib", + ":GRPCClientTests-lib", + ":APIv2Tests-lib", + ":ChannelPoolTest-lib", + ":ChannelTests-lib", + ":NSErrorUnitTests-lib", + ] +) + +ios_unit_test( + name = "InteropTests", + minimum_os_version = "8.0", + deps = [ + ":InteropTestsRemote-lib", + ":InteropTestsLocalSSL-lib", + ":InteropTestsLocalCleartext-lib", + # ":InteropTestsMultipleChannels-lib", #??????? Cronet must be used? + ], +) + +macos_unit_test( + name = "MacTests", + minimum_os_version = "10.9", + deps = [ + ":APIv2Tests-lib", + ":RxLibraryUnitTests-lib", + ":NSErrorUnitTests-lib", + ":InteropTestsRemote-lib", + ":InteropTestsLocalSSL-lib", + ":InteropTestsLocalCleartext-lib", + ":MacStressTests-lib", + ] +) + +# cares does not support tvOS CPU architecture with Bazel yet +tvos_unit_test( + name = "TvTests", + minimum_os_version = "10.0", + deps = [ + ":APIv2Tests-lib", + ":RxLibraryUnitTests-lib", + ":NSErrorUnitTests-lib", + ":InteropTestsRemote-lib", + ":InteropTestsLocalSSL-lib", + ":InteropTestsLocalCleartext-lib", + ] +) \ No newline at end of file diff --git a/src/objective-c/tests/InteropTests/InteropTests.h b/src/objective-c/tests/InteropTests/InteropTests.h index cffa90ac497..28fcbff9695 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.h +++ b/src/objective-c/tests/InteropTests/InteropTests.h @@ -27,6 +27,12 @@ * This is an abstract class that needs to be subclassed. See |+host|. */ @interface InteropTests : XCTestCase +/** + * The test suite to run, checking if the current XCTestCase instance is the base class. + * If so, run no tests (disabled). Otherwise, proceed to normal execution. + */ +@property(class, readonly) XCTestSuite *defaultTestSuite; + /** * Host to send the RPCs to. The base implementation returns nil, which would make all tests to * fail. diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index c13dd1e2b35..a8f7db7ee93 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -406,6 +406,14 @@ static dispatch_once_t initGlobalInterceptorFactory; RMTTestService *_service; } ++ (XCTestSuite *)defaultTestSuite { + if (self == [InteropTests class]) { + return [XCTestSuite testSuiteWithName:@"InteropTestsEmptySuite"]; + } else { + return super.defaultTestSuite; + } +} + + (NSString *)host { return nil; } diff --git a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m index a2a3e64b1b1..c363e523250 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m +++ b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m @@ -86,8 +86,9 @@ dispatch_once_t initCronet; self.continueAfterFailure = NO; _remoteService = [RMTTestService serviceWithHost:kRemoteSSLHost callOptions:nil]; - +#ifdef GRPC_COMPILE_WITH_CRONET configureCronet(); +#endif // Default stack with remote host GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; diff --git a/src/objective-c/tests/MacTests/StressTests.h b/src/objective-c/tests/MacTests/StressTests.h index 8bee0e66274..2608a710845 100644 --- a/src/objective-c/tests/MacTests/StressTests.h +++ b/src/objective-c/tests/MacTests/StressTests.h @@ -21,6 +21,12 @@ #import @interface StressTests : XCTestCase +/** + * The test suite to run, checking if the current XCTestCase instance is the base class. + * If so, run no tests (disabled). Otherwise, proceed to normal execution. + */ +@property(class, readonly) XCTestSuite *defaultTestSuite; + /** * Host to send the RPCs to. The base implementation returns nil, which would make all tests to * fail. diff --git a/src/objective-c/tests/MacTests/StressTests.m b/src/objective-c/tests/MacTests/StressTests.m index c7020740eac..622c80ea91a 100644 --- a/src/objective-c/tests/MacTests/StressTests.m +++ b/src/objective-c/tests/MacTests/StressTests.m @@ -89,6 +89,14 @@ extern const char *kCFStreamVarName; RMTTestService *_service; } ++ (XCTestSuite *)defaultTestSuite { + if (self == [StressTests class]) { + return [XCTestSuite testSuiteWithName:@"StressTestsEmptySuite"]; + } else { + return super.defaultTestSuite; + } +} + + (NSString *)host { return nil; } From 4f13303ec460b3550cac11e71a09cafa45920f86 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 5 Aug 2019 16:46:29 -0700 Subject: [PATCH 1112/1555] Validate length of deps in py_grpc_library --- bazel/python_rules.bzl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index eb4ac9c9721..8f696b1022d 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -208,6 +208,9 @@ def py_grpc_library( if len(srcs) > 1: fail("Can only compile a single proto at a time.") + if len(deps) > 1: + fail("Deps must have length 1.") + _generate_pb2_grpc_src( name = codegen_grpc_target, deps = srcs, From 08795cd20632f1137c03aaff5abaf5c7d0a96eb4 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Mon, 5 Aug 2019 17:07:54 -0700 Subject: [PATCH 1113/1555] Removed framework tests for tv and watch examples --- tools/run_tests/run_tests.py | 44 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 2a4ec8ce156..d3b028d4590 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1101,17 +1101,17 @@ class ObjCLanguage(object): 'EXAMPLE_PATH': 'src/objective-c/examples/tvOS-sample', 'FRAMEWORKS': 'NO' })) - out.append( - self.config.job_spec( - ['src/objective-c/tests/build_one_example.sh'], - timeout_seconds=10 * 60, - shortname='ios-buildtest-example-tvOS-sample-framework', - cpu_cost=1e6, - environ={ - 'SCHEME': 'tvOS-sample', - 'EXAMPLE_PATH': 'src/objective-c/examples/tvOS-sample', - 'FRAMEWORKS': 'YES' - })) + # out.append( + # self.config.job_spec( + # ['src/objective-c/tests/build_one_example.sh'], + # timeout_seconds=10 * 60, + # shortname='ios-buildtest-example-tvOS-sample-framework', + # cpu_cost=1e6, + # environ={ + # 'SCHEME': 'tvOS-sample', + # 'EXAMPLE_PATH': 'src/objective-c/examples/tvOS-sample', + # 'FRAMEWORKS': 'YES' + # })) out.append( self.config.job_spec( ['src/objective-c/tests/build_one_example.sh'], @@ -1123,17 +1123,17 @@ class ObjCLanguage(object): 'EXAMPLE_PATH': 'src/objective-c/examples/watchOS-sample', 'FRAMEWORKS': 'NO' })) - out.append( - self.config.job_spec( - ['src/objective-c/tests/build_one_example.sh'], - timeout_seconds=20 * 60, - shortname='ios-buildtest-example-watchOS-sample-framework', - cpu_cost=1e6, - environ={ - 'SCHEME': 'watchOS-sample-WatchKit-App', - 'EXAMPLE_PATH': 'src/objective-c/examples/watchOS-sample', - 'FRAMEWORKS': 'YES' - })) + # out.append( + # self.config.job_spec( + # ['src/objective-c/tests/build_one_example.sh'], + # timeout_seconds=20 * 60, + # shortname='ios-buildtest-example-watchOS-sample-framework', + # cpu_cost=1e6, + # environ={ + # 'SCHEME': 'watchOS-sample-WatchKit-App', + # 'EXAMPLE_PATH': 'src/objective-c/examples/watchOS-sample', + # 'FRAMEWORKS': 'YES' + # })) out.append( self.config.job_spec( ['src/objective-c/tests/run_plugin_tests.sh'], From 79611aca519183d9d8ec1d395c6e8cd98400e4d7 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 5 Aug 2019 17:22:43 -0700 Subject: [PATCH 1114/1555] Fix up unit test --- examples/python/auth/customized_auth_server.py | 2 +- examples/python/auth/test/_auth_example_test.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/python/auth/customized_auth_server.py b/examples/python/auth/customized_auth_server.py index 374537c64fc..4bb74d6a871 100644 --- a/examples/python/auth/customized_auth_server.py +++ b/examples/python/auth/customized_auth_server.py @@ -82,7 +82,7 @@ def run_server(port): server.start() try: - yield server, port, + yield server, port finally: server.stop(0) diff --git a/examples/python/auth/test/_auth_example_test.py b/examples/python/auth/test/_auth_example_test.py index e2214267212..8e1a3b2b359 100644 --- a/examples/python/auth/test/_auth_example_test.py +++ b/examples/python/auth/test/_auth_example_test.py @@ -30,20 +30,20 @@ _SERVER_ADDR_TEMPLATE = 'localhost:%d' class AuthExampleTest(unittest.TestCase): def test_successful_call(self): - with customized_auth_server.run_server(0) as port: + with customized_auth_server.run_server(0) as (_, port): with customized_auth_client.create_client_channel( _SERVER_ADDR_TEMPLATE % port) as channel: customized_auth_client.send_rpc(channel) # No unhandled exception raised, test passed! def test_no_channel_credential(self): - with customized_auth_server.run_server(0) as port: + with customized_auth_server.run_server(0) as (_, port): with grpc.insecure_channel(_SERVER_ADDR_TEMPLATE % port) as channel: resp = customized_auth_client.send_rpc(channel) self.assertEqual(resp.code(), grpc.StatusCode.UNAVAILABLE) def test_no_call_credential(self): - with customized_auth_server.run_server(0) as port: + with customized_auth_server.run_server(0) as (_, port): channel_credential = grpc.ssl_channel_credentials( _credentials.ROOT_CERTIFICATE) with grpc.secure_channel(_SERVER_ADDR_TEMPLATE % port, From 4c958e8745ba5d6715561bdcf16e15c23096fd65 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Mon, 5 Aug 2019 20:15:49 -0700 Subject: [PATCH 1115/1555] Modified BUILD for examples --- src/objective-c/examples/BUILD | 84 ++-- .../BazelBuildSamples/ios-sample/Podfile | 31 -- .../ios-sample.xcodeproj/project.pbxproj | 413 ------------------ .../ios-sample/ios-sample/AppDelegate.h | 25 -- .../ios-sample/ios-sample/AppDelegate.m | 63 --- .../AppIcon.appiconset/Contents.json | 98 ----- .../ios-sample/Assets.xcassets/Contents.json | 6 - .../Base.lproj/LaunchScreen.storyboard | 25 -- .../ios-sample/Base.lproj/Main.storyboard | 38 -- .../ios-sample/ios-sample/Info.plist | 45 -- .../ios-sample/ios-sample/ViewController.h | 23 - .../ios-sample/ios-sample/ViewController.m | 86 ---- .../ios-sample/ios-sample/main.m | 26 -- .../examples/BazelBuildSamples/messages.proto | 118 ----- .../examples/BazelBuildSamples/rmt/BUILD | 28 -- .../examples/BazelBuildSamples/rmt/test.proto | 57 --- .../InterceptorSample/Info.plist | 2 +- 17 files changed, 57 insertions(+), 1111 deletions(-) delete mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/Podfile delete mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample.xcodeproj/project.pbxproj delete mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/AppDelegate.h delete mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/AppDelegate.m delete mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Assets.xcassets/AppIcon.appiconset/Contents.json delete mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Assets.xcassets/Contents.json delete mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Base.lproj/LaunchScreen.storyboard delete mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Base.lproj/Main.storyboard delete mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Info.plist delete mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/ViewController.h delete mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/ViewController.m delete mode 100644 src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/main.m delete mode 100644 src/objective-c/examples/BazelBuildSamples/messages.proto delete mode 100644 src/objective-c/examples/BazelBuildSamples/rmt/BUILD delete mode 100644 src/objective-c/examples/BazelBuildSamples/rmt/test.proto diff --git a/src/objective-c/examples/BUILD b/src/objective-c/examples/BUILD index 27ddfcd6031..d3a5a76b89a 100644 --- a/src/objective-c/examples/BUILD +++ b/src/objective-c/examples/BUILD @@ -15,55 +15,83 @@ # limitations under the License. +load("//src/objective-c:grpc_objc_internal_library.bzl", "local_objc_grpc_library") load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application") -load( - "@com_github_grpc_grpc//bazel:objc_grpc_library.bzl", - "objc_grpc_library", -) +load("@build_bazel_rules_apple//apple:tvos.bzl", "tvos_application") +load("@build_bazel_rules_apple//apple:watchos.bzl", "watchos_application") proto_library( name = "messages_proto", - srcs = ["BazelBuildSamples/messages.proto"], - visibility = ["//visibility:public"], + srcs = ["RemoteTestClient/messages.proto"], ) -objc_grpc_library( +proto_library( + name = "test_proto", + srcs = ["RemoteTestClient/test.proto"], + deps = [":messages_proto"], +) + +# use objc_grpc_library in bazel:objc_grpc_library.bzl when developing outside the repo +local_objc_grpc_library( name = "test_grpc_objc", - srcs = ["BazelBuildSamples/rmt/test.proto"], + srcs = ["RemoteTestClient/test.proto"], use_well_known_protos = True, deps = [ - "//src/objective-c/examples/BazelBuildSamples/rmt:test_proto", + "//src/objective-c/examples:test_proto", ], ) # Proof that without this works without srcs -objc_grpc_library( +local_objc_grpc_library( name = "test_objc", use_well_known_protos = True, deps = [ - "//src/objective-c/examples/BazelBuildSamples/rmt:test_proto", - ] + "//src/objective-c/examples:test_proto", + ], ) objc_library( - name = "ios-sample-lib", - srcs = glob(["BazelBuildSamples/ios-sample/ios-sample/**/*.m"]), - hdrs = glob(["BazelBuildSamples/ios-sample/ios-sample/**/*.h"]), + name = "Sample-lib", + srcs = glob(["Sample/**/*.m"]), + hdrs = glob(["Sample/**/*.h"]), data = glob([ - "BazelBuildSamples/ios-sample/ios-sample/Assets.xcassets/**/*", - "BazelBuildSamples/ios-sample/ios-sample/Base.lproj/**/*" + "Sample/Sample/Base.lproj/**", + "Sample/Sample/Images.xcassets/**", ]), - deps = [ - ":test_grpc_objc", - ] + deps = [":test_grpc_objc"], ) ios_application( - name = "ios-sample", - bundle_id = "com.google.ios-sample-objc-bazel", - families = ["iphone"], - minimum_os_version = "9.0", - infoplists = ["BazelBuildSamples/ios-sample/ios-sample/Info.plist"], - visibility = ["//visibility:public"], - deps = [":ios-sample-lib"], -) \ No newline at end of file + name = "Sample", + bundle_id = "grpc.objc.examples.Sample", + minimum_os_version = "8.0", + infoplists = ["Sample/Sample/Info.plist"], + families = [ + "iphone", + "ipad", + ], + deps = ["Sample-lib"], +) + +objc_library( + name = "InterceptorSample-lib", + srcs = glob(["InterceptorSample/**/*.m"]), + hdrs = glob(["InterceptorSample/**/*.h"]), + data = glob([ + "InterceptorSample/InterceptorSample/Base.lproj/**", + "InterceptorSample/InterceptorSample/Images.xcassets/**", + ]), + deps = [":test_grpc_objc"], +) + +ios_application( + name = "InterceptorSample", + bundle_id = "grpc.objc.examples.InterceptorSample", + minimum_os_version = "9.0", # Safe Area Layout Guide used + infoplists = ["InterceptorSample/InterceptorSample/Info.plist"], + families = [ + "iphone", + "ipad", + ], + deps = ["InterceptorSample-lib"], +) diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/Podfile b/src/objective-c/examples/BazelBuildSamples/ios-sample/Podfile deleted file mode 100644 index 8648992d84f..00000000000 --- a/src/objective-c/examples/BazelBuildSamples/ios-sample/Podfile +++ /dev/null @@ -1,31 +0,0 @@ -platform :ios, '8.0' - -install! 'cocoapods', :deterministic_uuids => false - -ROOT_DIR = '../../../../..' - -target 'ios-sample' do - pod 'gRPC-ProtoRPC', :path => ROOT_DIR - pod 'gRPC', :path => ROOT_DIR - pod 'gRPC-Core', :path => ROOT_DIR - pod 'gRPC-RxLibrary', :path => ROOT_DIR - pod 'RemoteTest', :path => "../../RemoteTestClient" - pod '!ProtoCompiler-gRPCPlugin', :path => "#{ROOT_DIR}/src/objective-c" -end - -pre_install do |installer| - grpc_core_spec = installer.pod_targets.find{|t| t.name.start_with?('gRPC-Core')}.root_spec - - src_root = "$(PODS_TARGET_SRCROOT)" - grpc_core_spec.pod_target_xcconfig = { - 'GRPC_SRC_ROOT' => src_root, - 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"', - 'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"', - # If we don't set these two settings, `include/grpc/support/time.h` and - # `src/core/lib/gpr/string.h` shadow the system `` and ``, breaking the - # build. - 'USE_HEADERMAP' => 'NO', - 'ALWAYS_SEARCH_USER_PATHS' => 'NO', - } -end - diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample.xcodeproj/project.pbxproj b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample.xcodeproj/project.pbxproj deleted file mode 100644 index 05344a69bfc..00000000000 --- a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample.xcodeproj/project.pbxproj +++ /dev/null @@ -1,413 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 50; - objects = { - -/* Begin PBXBuildFile section */ - AB433CC922D7E38000D579CC /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = AB433CC822D7E38000D579CC /* AppDelegate.m */; }; - AB433CCC22D7E38000D579CC /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AB433CCB22D7E38000D579CC /* ViewController.m */; }; - AB433CCF22D7E38000D579CC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AB433CCD22D7E38000D579CC /* Main.storyboard */; }; - AB433CD122D7E38100D579CC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AB433CD022D7E38100D579CC /* Assets.xcassets */; }; - AB433CD422D7E38100D579CC /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AB433CD222D7E38100D579CC /* LaunchScreen.storyboard */; }; - AB433CD722D7E38100D579CC /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = AB433CD622D7E38100D579CC /* main.m */; }; - ED11F6CDF54788FC7CFD87B1 /* libPods-ios-sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5AF80A181E30BD84FA56BE33 /* libPods-ios-sample.a */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 112D4595FA3E81552DA9E877 /* Pods-ios-sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ios-sample.release.xcconfig"; path = "Target Support Files/Pods-ios-sample/Pods-ios-sample.release.xcconfig"; sourceTree = ""; }; - 5AF80A181E30BD84FA56BE33 /* libPods-ios-sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ios-sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 72599BE4AC5785D3368D40DD /* Pods-ios-sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ios-sample.debug.xcconfig"; path = "Target Support Files/Pods-ios-sample/Pods-ios-sample.debug.xcconfig"; sourceTree = ""; }; - AB433CC422D7E38000D579CC /* ios-sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ios-sample.app"; sourceTree = BUILT_PRODUCTS_DIR; }; - AB433CC722D7E38000D579CC /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; - AB433CC822D7E38000D579CC /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - AB433CCA22D7E38000D579CC /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; - AB433CCB22D7E38000D579CC /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; - AB433CCE22D7E38000D579CC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - AB433CD022D7E38100D579CC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - AB433CD322D7E38100D579CC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; - AB433CD522D7E38100D579CC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - AB433CD622D7E38100D579CC /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - AB433CC122D7E38000D579CC /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ED11F6CDF54788FC7CFD87B1 /* libPods-ios-sample.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 2A170580B60E92B1A65525D4 /* Pods */ = { - isa = PBXGroup; - children = ( - 72599BE4AC5785D3368D40DD /* Pods-ios-sample.debug.xcconfig */, - 112D4595FA3E81552DA9E877 /* Pods-ios-sample.release.xcconfig */, - ); - name = Pods; - path = Pods; - sourceTree = ""; - }; - AB433CBB22D7E38000D579CC = { - isa = PBXGroup; - children = ( - AB433CC622D7E38000D579CC /* ios-sample */, - AB433CC522D7E38000D579CC /* Products */, - 2A170580B60E92B1A65525D4 /* Pods */, - FD148AE940967C50DB2C12CB /* Frameworks */, - ); - sourceTree = ""; - }; - AB433CC522D7E38000D579CC /* Products */ = { - isa = PBXGroup; - children = ( - AB433CC422D7E38000D579CC /* ios-sample.app */, - ); - name = Products; - sourceTree = ""; - }; - AB433CC622D7E38000D579CC /* ios-sample */ = { - isa = PBXGroup; - children = ( - AB433CC722D7E38000D579CC /* AppDelegate.h */, - AB433CC822D7E38000D579CC /* AppDelegate.m */, - AB433CCA22D7E38000D579CC /* ViewController.h */, - AB433CCB22D7E38000D579CC /* ViewController.m */, - AB433CCD22D7E38000D579CC /* Main.storyboard */, - AB433CD022D7E38100D579CC /* Assets.xcassets */, - AB433CD222D7E38100D579CC /* LaunchScreen.storyboard */, - AB433CD522D7E38100D579CC /* Info.plist */, - AB433CD622D7E38100D579CC /* main.m */, - ); - path = "ios-sample"; - sourceTree = ""; - }; - FD148AE940967C50DB2C12CB /* Frameworks */ = { - isa = PBXGroup; - children = ( - 5AF80A181E30BD84FA56BE33 /* libPods-ios-sample.a */, - ); - name = Frameworks; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - AB433CC322D7E38000D579CC /* ios-sample */ = { - isa = PBXNativeTarget; - buildConfigurationList = AB433CDA22D7E38100D579CC /* Build configuration list for PBXNativeTarget "ios-sample" */; - buildPhases = ( - 9DD34A50D448CD3F464D4A3C /* [CP] Check Pods Manifest.lock */, - AB433CC022D7E38000D579CC /* Sources */, - AB433CC122D7E38000D579CC /* Frameworks */, - AB433CC222D7E38000D579CC /* Resources */, - 630985F7228D41528084692C /* [CP] Copy Pods Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "ios-sample"; - productName = "ios-sample"; - productReference = AB433CC422D7E38000D579CC /* ios-sample.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - AB433CBC22D7E38000D579CC /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 1010; - ORGANIZATIONNAME = "Tony Lu"; - TargetAttributes = { - AB433CC322D7E38000D579CC = { - CreatedOnToolsVersion = 10.1; - }; - }; - }; - buildConfigurationList = AB433CBF22D7E38000D579CC /* Build configuration list for PBXProject "ios-sample" */; - compatibilityVersion = "Xcode 9.3"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = AB433CBB22D7E38000D579CC; - productRefGroup = AB433CC522D7E38000D579CC /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - AB433CC322D7E38000D579CC /* ios-sample */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - AB433CC222D7E38000D579CC /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - AB433CD422D7E38100D579CC /* LaunchScreen.storyboard in Resources */, - AB433CD122D7E38100D579CC /* Assets.xcassets in Resources */, - AB433CCF22D7E38000D579CC /* Main.storyboard in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 630985F7228D41528084692C /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-ios-sample/Pods-ios-sample-resources-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-ios-sample/Pods-ios-sample-resources-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ios-sample/Pods-ios-sample-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 9DD34A50D448CD3F464D4A3C /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-ios-sample-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - AB433CC022D7E38000D579CC /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - AB433CCC22D7E38000D579CC /* ViewController.m in Sources */, - AB433CD722D7E38100D579CC /* main.m in Sources */, - AB433CC922D7E38000D579CC /* AppDelegate.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ - AB433CCD22D7E38000D579CC /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - AB433CCE22D7E38000D579CC /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; - AB433CD222D7E38100D579CC /* LaunchScreen.storyboard */ = { - isa = PBXVariantGroup; - children = ( - AB433CD322D7E38100D579CC /* Base */, - ); - name = LaunchScreen.storyboard; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - AB433CD822D7E38100D579CC /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - }; - name = Debug; - }; - AB433CD922D7E38100D579CC /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - AB433CDB22D7E38100D579CC /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 72599BE4AC5785D3368D40DD /* Pods-ios-sample.debug.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 6T98ZJNPG5; - INFOPLIST_FILE = "ios-sample/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = "com.google.ios-sample-objc-bazel"; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - AB433CDC22D7E38100D579CC /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 112D4595FA3E81552DA9E877 /* Pods-ios-sample.release.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 6T98ZJNPG5; - INFOPLIST_FILE = "ios-sample/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = "com.google.ios-sample-objc-bazel"; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - AB433CBF22D7E38000D579CC /* Build configuration list for PBXProject "ios-sample" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - AB433CD822D7E38100D579CC /* Debug */, - AB433CD922D7E38100D579CC /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - AB433CDA22D7E38100D579CC /* Build configuration list for PBXNativeTarget "ios-sample" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - AB433CDB22D7E38100D579CC /* Debug */, - AB433CDC22D7E38100D579CC /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = AB433CBC22D7E38000D579CC /* Project object */; -} diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/AppDelegate.h b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/AppDelegate.h deleted file mode 100644 index 183abcf4ec8..00000000000 --- a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/AppDelegate.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import - -@interface AppDelegate : UIResponder - -@property(strong, nonatomic) UIWindow* window; - -@end diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/AppDelegate.m b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/AppDelegate.m deleted file mode 100644 index d78f5f2175c..00000000000 --- a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/AppDelegate.m +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import "AppDelegate.h" - -@interface AppDelegate () - -@end - -@implementation AppDelegate - -- (BOOL)application:(UIApplication *)application - didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - // Override point for customization after application launch. - return YES; -} - -- (void)applicationWillResignActive:(UIApplication *)application { - // Sent when the application is about to move from active to inactive state. This can occur for - // certain types of temporary interruptions (such as an incoming phone call or SMS message) or - // when the user quits the application and it begins the transition to the background state. Use - // this method to pause ongoing tasks, disable timers, and invalidate graphics rendering - // callbacks. Games should use this method to pause the game. -} - -- (void)applicationDidEnterBackground:(UIApplication *)application { - // Use this method to release shared resources, save user data, invalidate timers, and store - // enough application state information to restore your application to its current state in case - // it is terminated later. If your application supports background execution, this method is - // called instead of applicationWillTerminate: when the user quits. -} - -- (void)applicationWillEnterForeground:(UIApplication *)application { - // Called as part of the transition from the background to the active state; here you can undo - // many of the changes made on entering the background. -} - -- (void)applicationDidBecomeActive:(UIApplication *)application { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If - // the application was previously in the background, optionally refresh the user interface. -} - -- (void)applicationWillTerminate:(UIApplication *)application { - // Called when the application is about to terminate. Save data if appropriate. See also - // applicationDidEnterBackground:. -} - -@end diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Assets.xcassets/AppIcon.appiconset/Contents.json b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index d8db8d65fd7..00000000000 --- a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "images" : [ - { - "idiom" : "iphone", - "size" : "20x20", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "20x20", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "3x" - }, - { - "idiom" : "ipad", - "size" : "20x20", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "20x20", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "29x29", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "40x40", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "40x40", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "76x76", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "76x76", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "83.5x83.5", - "scale" : "2x" - }, - { - "idiom" : "ios-marketing", - "size" : "1024x1024", - "scale" : "1x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Assets.xcassets/Contents.json b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Assets.xcassets/Contents.json deleted file mode 100644 index da4a164c918..00000000000 --- a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Base.lproj/LaunchScreen.storyboard b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Base.lproj/LaunchScreen.storyboard deleted file mode 100644 index bfa36129419..00000000000 --- a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Base.lproj/LaunchScreen.storyboard +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Base.lproj/Main.storyboard b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Base.lproj/Main.storyboard deleted file mode 100644 index 5e257390b33..00000000000 --- a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Base.lproj/Main.storyboard +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Info.plist b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Info.plist deleted file mode 100644 index e5d82108923..00000000000 --- a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/Info.plist +++ /dev/null @@ -1,45 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en_US - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - LSRequiresIPhoneOS - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - - diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/ViewController.h b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/ViewController.h deleted file mode 100644 index 0aa0b2a73a7..00000000000 --- a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/ViewController.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import - -@interface ViewController : UIViewController - -@end diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/ViewController.m b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/ViewController.m deleted file mode 100644 index 6cb5a0be9df..00000000000 --- a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/ViewController.m +++ /dev/null @@ -1,86 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import "ViewController.h" - -#import -#if COCOAPODS -#import -#import -#else -#import "src/objective-c/examples/BazelBuildSamples/Messages.pbobjc.h" -#import "src/objective-c/examples/BazelBuildSamples/rmt/Test.pbrpc.h" -#endif - -static NSString *const kPackage = @"grpc.testing"; -static NSString *const kService = @"TestService"; - -@interface ViewController () - -@end - -@implementation ViewController { - GRPCCallOptions *_options; -} - -- (void)viewDidLoad { - [super viewDidLoad]; - - GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - // optionally modify options - _options = options; -} - -- (IBAction)tapCall:(id)sender { - GRPCProtoMethod *kUnaryCallMethod = - [[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"UnaryCall"]; - - GRPCRequestOptions *requestOptions = - [[GRPCRequestOptions alloc] initWithHost:@"grpc-test.sandbox.googleapis.com" - path:kUnaryCallMethod.HTTPPath - safety:GRPCCallSafetyCacheableRequest]; - - GRPCCall2 *call = [[GRPCCall2 alloc] initWithRequestOptions:requestOptions - responseHandler:self - callOptions:_options]; - - RMTSimpleRequest *request = [RMTSimpleRequest message]; - request.responseSize = 100; - - [call start]; - [call writeData:[request data]]; - [call finish]; -} - -- (dispatch_queue_t)dispatchQueue { - return dispatch_get_main_queue(); -} - -- (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata { - NSLog(@"Header: %@", initialMetadata); -} - -- (void)didReceiveData:(id)data { - NSLog(@"Message: %@", data); -} - -- (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { - NSLog(@"Trailer: %@\nError: %@", trailingMetadata, error); -} - -@end diff --git a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/main.m b/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/main.m deleted file mode 100644 index 2797c6f17f2..00000000000 --- a/src/objective-c/examples/BazelBuildSamples/ios-sample/ios-sample/main.m +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import -#import "AppDelegate.h" - -int main(int argc, char* argv[]) { - @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); - } -} diff --git a/src/objective-c/examples/BazelBuildSamples/messages.proto b/src/objective-c/examples/BazelBuildSamples/messages.proto deleted file mode 100644 index 128efd9337e..00000000000 --- a/src/objective-c/examples/BazelBuildSamples/messages.proto +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2015 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Message definitions to be used by integration test service definitions. - -syntax = "proto3"; - -package grpc.testing; - -option objc_class_prefix = "RMT"; - -// The type of payload that should be returned. -enum PayloadType { - // Compressable text format. - COMPRESSABLE = 0; - - // Uncompressable binary format. - UNCOMPRESSABLE = 1; - - // Randomly chosen from all other formats defined in this enum. - RANDOM = 2; -} - -// A block of data, to simply increase gRPC message size. -message Payload { - // The type of data in body. - PayloadType type = 1; - // Primary contents of payload. - bytes body = 2; -} - -// Unary request. -message SimpleRequest { - // Desired payload type in the response from the server. - // If response_type is RANDOM, server randomly chooses one from other formats. - PayloadType response_type = 1; - - // Desired payload size in the response from the server. - // If response_type is COMPRESSABLE, this denotes the size before compression. - int32 response_size = 2; - - // Optional input payload sent along with the request. - Payload payload = 3; - - // Whether SimpleResponse should include username. - bool fill_username = 4; - - // Whether SimpleResponse should include OAuth scope. - bool fill_oauth_scope = 5; -} - -// Unary response, as configured by the request. -message SimpleResponse { - // Payload to increase message size. - Payload payload = 1; - // The user the request came from, for verifying authentication was - // successful when the client expected it. - string username = 2; - // OAuth scope. - string oauth_scope = 3; -} - -// Client-streaming request. -message StreamingInputCallRequest { - // Optional input payload sent along with the request. - Payload payload = 1; - - // Not expecting any payload from the response. -} - -// Client-streaming response. -message StreamingInputCallResponse { - // Aggregated size of payloads received from the client. - int32 aggregated_payload_size = 1; -} - -// Configuration for a particular response. -message ResponseParameters { - // Desired payload sizes in responses from the server. - // If response_type is COMPRESSABLE, this denotes the size before compression. - int32 size = 1; - - // Desired interval between consecutive responses in the response stream in - // microseconds. - int32 interval_us = 2; -} - -// Server-streaming request. -message StreamingOutputCallRequest { - // Desired payload type in the response from the server. - // If response_type is RANDOM, the payload from each response in the stream - // might be of different types. This is to simulate a mixed type of payload - // stream. - PayloadType response_type = 1; - - // Configuration for each expected response message. - repeated ResponseParameters response_parameters = 2; - - // Optional input payload sent along with the request. - Payload payload = 3; -} - -// Server-streaming response, as configured by the request and parameters. -message StreamingOutputCallResponse { - // Payload to increase response size. - Payload payload = 1; -} diff --git a/src/objective-c/examples/BazelBuildSamples/rmt/BUILD b/src/objective-c/examples/BazelBuildSamples/rmt/BUILD deleted file mode 100644 index 5264196c08e..00000000000 --- a/src/objective-c/examples/BazelBuildSamples/rmt/BUILD +++ /dev/null @@ -1,28 +0,0 @@ -# gRPC Bazel BUILD file. -# -# Copyright 2019 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -licenses(["notice"]) # Apache v2 - -package(default_visibility = ["//visibility:public"]) - -exports_files(["LICENSE"]) - -proto_library( - name = "test_proto", - srcs = ["test.proto"], - deps = ["//src/objective-c/examples:messages_proto"], - visibility = ["//visibility:public"], -) \ No newline at end of file diff --git a/src/objective-c/examples/BazelBuildSamples/rmt/test.proto b/src/objective-c/examples/BazelBuildSamples/rmt/test.proto deleted file mode 100644 index ddc511e1428..00000000000 --- a/src/objective-c/examples/BazelBuildSamples/rmt/test.proto +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2015 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// An integration test service that covers all the method signature permutations -// of unary/streaming requests/responses. -syntax = "proto3"; - -import "google/protobuf/empty.proto"; -import "src/objective-c/examples/BazelBuildSamples/messages.proto"; - -package grpc.testing; - -option objc_class_prefix = "RMT"; - -// A simple service to test the various types of RPCs and experiment with -// performance with various types of payload. -service TestService { - // One empty request followed by one empty response. - rpc EmptyCall(google.protobuf.Empty) returns (google.protobuf.Empty); - - // One request followed by one response. - rpc UnaryCall(SimpleRequest) returns (SimpleResponse); - - // One request followed by a sequence of responses (streamed download). - // The server returns the payload with client desired type and sizes. - rpc StreamingOutputCall(StreamingOutputCallRequest) - returns (stream StreamingOutputCallResponse); - - // A sequence of requests followed by one response (streamed upload). - // The server returns the aggregated size of client payload as the result. - rpc StreamingInputCall(stream StreamingInputCallRequest) - returns (StreamingInputCallResponse); - - // A sequence of requests with each request served by the server immediately. - // As one request could lead to multiple responses, this interface - // demonstrates the idea of full duplexing. - rpc FullDuplexCall(stream StreamingOutputCallRequest) - returns (stream StreamingOutputCallResponse); - - // A sequence of requests followed by a sequence of responses. - // The server buffers all the client requests and then serves them in order. A - // stream of responses are returned to the client when the server starts with - // first request. - rpc HalfDuplexCall(stream StreamingOutputCallRequest) - returns (stream StreamingOutputCallResponse); -} diff --git a/src/objective-c/examples/InterceptorSample/InterceptorSample/Info.plist b/src/objective-c/examples/InterceptorSample/InterceptorSample/Info.plist index 16be3b68112..e5d82108923 100644 --- a/src/objective-c/examples/InterceptorSample/InterceptorSample/Info.plist +++ b/src/objective-c/examples/InterceptorSample/InterceptorSample/Info.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) + en_US CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier From 6522294325382399e28285c972fff597dbc6b88f Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Mon, 5 Aug 2019 21:04:21 -0700 Subject: [PATCH 1116/1555] Fix key gen in locality picking --- src/core/ext/filters/client_channel/lb_policy/xds/xds.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index 9721972511a..81f17fbfe3d 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -559,9 +559,8 @@ class XdsLb : public LoadBalancingPolicy { XdsLb::PickResult XdsLb::Picker::Pick(PickArgs args) { // TODO(roth): Add support for drop handling. - // Generate a random number between 0 and the total weight - const uint32_t key = - (rand() * pickers_[pickers_.size() - 1].first) / RAND_MAX; + // Generate a random number in [0, total weight). + const uint32_t key = rand() % pickers_[pickers_.size() - 1].first; // Forward pick to whichever locality maps to the range in which the // random number falls in. PickResult result = PickFromLocality(key, args); From 33b8b3f998a469dd38b6774399d717393c1a4841 Mon Sep 17 00:00:00 2001 From: Christian Maurer Date: Tue, 6 Aug 2019 12:48:37 +0200 Subject: [PATCH 1117/1555] Removed whitespace before asterisk --- src/compiler/cpp_generator.cc | 8 +++--- test/cpp/codegen/compiler_test_golden | 40 +++++++++++++-------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index a253df8f1bb..d4545ad49a8 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -896,7 +896,7 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer, "class WithAsyncMethod_$Method$ : public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service * /*service*/) " + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " "{}\n"); printer->Print(" public:\n"); printer->Indent(); @@ -1007,7 +1007,7 @@ void PrintHeaderServerMethodCallback( "class ExperimentalWithCallbackMethod_$Method$ : public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service * /*service*/) " + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " "{}\n"); printer->Print(" public:\n"); printer->Indent(); @@ -1082,7 +1082,7 @@ void PrintHeaderServerMethodRawCallback( "BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service * /*service*/) " + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " "{}\n"); printer->Print(" public:\n"); printer->Indent(); @@ -1322,7 +1322,7 @@ void PrintHeaderServerMethodRaw(grpc_generator::Printer* printer, printer->Print(*vars, "class WithRawMethod_$Method$ : public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service * /*service*/) " + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " "{}\n"); printer->Print(" public:\n"); printer->Indent(); diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index 56ee741e0b2..4f97076e39a 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -252,7 +252,7 @@ class ServiceA final { template class WithAsyncMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_MethodA1() { ::grpc::Service::MarkMethodAsync(0); @@ -272,7 +272,7 @@ class ServiceA final { template class WithAsyncMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_MethodA2() { ::grpc::Service::MarkMethodAsync(1); @@ -292,7 +292,7 @@ class ServiceA final { template class WithAsyncMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_MethodA3() { ::grpc::Service::MarkMethodAsync(2); @@ -312,7 +312,7 @@ class ServiceA final { template class WithAsyncMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_MethodA4() { ::grpc::Service::MarkMethodAsync(3); @@ -333,7 +333,7 @@ class ServiceA final { template class ExperimentalWithCallbackMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithCallbackMethod_MethodA1() { ::grpc::Service::experimental().MarkMethodCallback(0, @@ -364,7 +364,7 @@ class ServiceA final { template class ExperimentalWithCallbackMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithCallbackMethod_MethodA2() { ::grpc::Service::experimental().MarkMethodCallback(1, @@ -386,7 +386,7 @@ class ServiceA final { template class ExperimentalWithCallbackMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithCallbackMethod_MethodA3() { ::grpc::Service::experimental().MarkMethodCallback(2, @@ -408,7 +408,7 @@ class ServiceA final { template class ExperimentalWithCallbackMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithCallbackMethod_MethodA4() { ::grpc::Service::experimental().MarkMethodCallback(3, @@ -499,7 +499,7 @@ class ServiceA final { template class WithRawMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_MethodA1() { ::grpc::Service::MarkMethodRaw(0); @@ -519,7 +519,7 @@ class ServiceA final { template class WithRawMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_MethodA2() { ::grpc::Service::MarkMethodRaw(1); @@ -539,7 +539,7 @@ class ServiceA final { template class WithRawMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_MethodA3() { ::grpc::Service::MarkMethodRaw(2); @@ -559,7 +559,7 @@ class ServiceA final { template class WithRawMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_MethodA4() { ::grpc::Service::MarkMethodRaw(3); @@ -579,7 +579,7 @@ class ServiceA final { template class ExperimentalWithRawCallbackMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodA1() { ::grpc::Service::experimental().MarkMethodRawCallback(0, @@ -604,7 +604,7 @@ class ServiceA final { template class ExperimentalWithRawCallbackMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodA2() { ::grpc::Service::experimental().MarkMethodRawCallback(1, @@ -626,7 +626,7 @@ class ServiceA final { template class ExperimentalWithRawCallbackMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodA3() { ::grpc::Service::experimental().MarkMethodRawCallback(2, @@ -648,7 +648,7 @@ class ServiceA final { template class ExperimentalWithRawCallbackMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodA4() { ::grpc::Service::experimental().MarkMethodRawCallback(3, @@ -790,7 +790,7 @@ class ServiceB final { template class WithAsyncMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_MethodB1() { ::grpc::Service::MarkMethodAsync(0); @@ -811,7 +811,7 @@ class ServiceB final { template class ExperimentalWithCallbackMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithCallbackMethod_MethodB1() { ::grpc::Service::experimental().MarkMethodCallback(0, @@ -860,7 +860,7 @@ class ServiceB final { template class WithRawMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_MethodB1() { ::grpc::Service::MarkMethodRaw(0); @@ -880,7 +880,7 @@ class ServiceB final { template class ExperimentalWithRawCallbackMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service * /*service*/) {} + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: ExperimentalWithRawCallbackMethod_MethodB1() { ::grpc::Service::experimental().MarkMethodRawCallback(0, From e2ba3aa07009292617c3cabe734e8e44099b22ac Mon Sep 17 00:00:00 2001 From: "Lukacs T. Berki" Date: Tue, 6 Aug 2019 14:00:11 +0200 Subject: [PATCH 1118/1555] Update C++ code generation to work with Bazel 0.29 . The above Bazel version changes proto compilation slightly: some proto files are put into a `_virtual_imports` directory and thus `_get_include_directory` needs to be updated accordingly. Ideally, it would use instead the `ProtoInfo` provider to tease out the proto import directories, but that's a bit more intrusive change. --- bazel/protobuf.bzl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bazel/protobuf.bzl b/bazel/protobuf.bzl index f2df7bd87b2..3066e1d5500 100644 --- a/bazel/protobuf.bzl +++ b/bazel/protobuf.bzl @@ -59,6 +59,13 @@ def proto_path_to_generated_filename(proto_path, fmt_str): def _get_include_directory(include): directory = include.path prefix_len = 0 + + virtual_imports = "/_virtual_imports/" + if not include.is_source and virtual_imports in include.path: + root, relative = include.path.split(virtual_imports, 2) + result = root + virtual_imports + relative.split("/", 1)[0] + return result + if not include.is_source and directory.startswith(include.root.path): prefix_len = len(include.root.path) + 1 From de3131016d4580077f91cef6702dc7ffaea0b375 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 6 Aug 2019 08:52:31 -0700 Subject: [PATCH 1119/1555] update BUILD following the new style --- bazel/grpc_build_system.bzl | 9 +- src/compiler/objective_c_plugin.cc | 4 +- src/objective-c/BUILD | 167 ++++++++++++++++++------ src/objective-c/ProtoRPC/ProtoService.m | 2 +- 4 files changed, 132 insertions(+), 50 deletions(-) diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 9e967d8fa9a..c31f3421a58 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -24,7 +24,6 @@ # load("//bazel:cc_grpc_library.bzl", "cc_grpc_library") -load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle") load("@upb//bazel:upb_proto_library.bzl", "upb_proto_library") # The set of pollers to test against if a test exercises polling @@ -199,12 +198,6 @@ def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], da ) def grpc_generate_one_off_targets(): - apple_resource_bundle( - # The choice of name is signicant here, since it determines the bundle name. - name = "gRPCCertificates", - resources = ["etc/roots.pem"], - ) - # In open-source, grpc_objc* libraries depend directly on //:grpc native.alias( name = "grpc_objc", @@ -256,7 +249,7 @@ def grpc_package(name, visibility = "private", features = []): def grpc_objc_library( name, - srcs, + srcs = [], hdrs = [], textual_hdrs = [], data = [], diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index 03f7f721b1a..f9066af4aa6 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -205,10 +205,10 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string imports; if (framework.empty()) { imports = LocalImport(file_name + ".pbrpc.h") + - LocalImport(file_name + ".pbobjc.h") + + LocalImport(file_name + ".pbobjc.h"); } else { imports = FrameworkImport(file_name + ".pbrpc.h", framework) + - FrameworkImport(file_name + ".pbobjc.h", framework) + + FrameworkImport(file_name + ".pbobjc.h", framework); } imports += (generator_params.no_v1_compatibility ? SystemImport("ProtoRPC/ProtoRPC.h") diff --git a/src/objective-c/BUILD b/src/objective-c/BUILD index 2492ce8a21f..ba973141bcd 100644 --- a/src/objective-c/BUILD +++ b/src/objective-c/BUILD @@ -25,17 +25,25 @@ exports_files(["LICENSE"]) grpc_objc_use_cronet_config() grpc_objc_library( - name = "rx_library", - srcs = glob([ - "RxLibrary/*.m", - "RxLibrary/transformations/*.m", - ]), + name = "rx_library_headers", hdrs = glob([ "RxLibrary/*.h", "RxLibrary/transformations/*.h", ]), includes = ["."], - deps = [":rx_library_private"], +) + +grpc_objc_library( + name = "rx_library", + srcs = glob([ + "RxLibrary/*.m", + "RxLibrary/transformations/*.m", + ]), + includes = ["."], + deps = [ + ":rx_library_private", + ":rx_library_headers", + ], ) grpc_objc_library( @@ -50,47 +58,128 @@ grpc_objc_library( ) grpc_objc_library( - name = "grpc_objc_client", - srcs = glob( - [ - "GRPCClient/*.m", - "GRPCClient/private/*.m", - ], - exclude = ["GRPCClient/GRPCCall+GID.m"], - ), - hdrs = glob( - [ - "GRPCClient/*.h", - "GRPCClient/internal/*.h", - ], - exclude = ["GRPCClient/GRPCCall+GID.h"], - ), - data = ["//:gRPCCertificates"], - includes = ["."], - textual_hdrs = glob([ - "GRPCClient/private/*.h", - ]), + name = "grpc_objc_interface_legacy", + hdrs = [ + "GRPCClient/GRPCCallLegacy.h", + "GRPCClient/GRPCTypes.h", + ], deps = [ + "rx_library_headers", + ], +) + +grpc_objc_library( + name = "grpc_objc_interface", + hdrs = [ + "GRPCClient/GRPCCall.h", + "GRPCClient/GRPCCall+Interceptor.h", + "GRPCClient/GRPCCallOptions.h", + "GRPCClient/GRPCInterceptor.h", + "GRPCClient/GRPCTransport.h", + "GRPCClient/GRPCDispatchable.h", + "GRPCClient/internal/GRPCCallOptions+Internal.h", + ], + srcs = [ + "GRPCClient/GRPCCall.m", + "GRPCClient/GRPCCall+Interceptor.m", + "GRPCClient/GRPCCallOptions.m", + "GRPCClient/GRPCInterceptor.m", + "GRPCClient/GRPCTransport.m", + "GRPCClient/private/GRPCTransport+Private.m", + ], + includes = ["."], + textual_hdrs = [ + "GRPCClient/private/GRPCTransport+Private.h", + ], + deps = [ + ":grpc_objc_interface_legacy", + ], +) + +grpc_objc_library( + name = "grpc_objc_client_core", + hdrs = [ + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", + "GRPCClient/GRPCCall+ChannelArg.h", + ], + textual_hdrs = native.glob(["GRPCClient/private/GRPCCore/*.h"]), + srcs = [ + "GRPCClient/GRPCCall+ChannelArg.m", + "GRPCClient/GRPCCall+ChannelCredentials.m", + "GRPCClient/GRPCCall+Cronet.m", + "GRPCClient/GRPCCall+OAuth2.m", + "GRPCClient/GRPCCall+Tests.m", + "GRPCClient/GRPCCallLegacy.m", + ] + native.glob(["GRPCClient/private/GRPCCore/*.m"]), + data = [":gRPCCertificates"], + includes = ["."], + deps = [ + ":grpc_objc_interface", + ":grpc_objc_interface_legacy", ":rx_library", "//:grpc_objc", ], ) +alias( + name = "grpc_objc_client", + actual = "grpc_objc_client_core", +) + grpc_objc_library( - name = "proto_objc_rpc", - srcs = glob( - ["ProtoRPC/*.m"], - ), - hdrs = glob( - ["ProtoRPC/*.h"], - ), - # Different from Cocoapods, do not import as if @com_google_protobuf//:protobuf_objc is a framework, - # use the real paths of @com_google_protobuf//:protobuf_objc instead - defines = ["GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0"], - includes = ["src/objective-c"], + name = "proto_objc_rpc_legacy_header", + hdrs = [ + "ProtoRPC/ProtoRPCLegacy.h", + ], + includes = ["."], +) + +grpc_objc_library( + name = "proto_objc_rpc_v2", + srcs = [ + "ProtoRPC/ProtoMethod.m", + "ProtoRPC/ProtoRPC.m", + "ProtoRPC/ProtoService.m", + ], + hdrs = [ + "ProtoRPC/ProtoMethod.h", + "ProtoRPC/ProtoRPC.h", + "ProtoRPC/ProtoService.h", + ], + includes = ["."], deps = [ - ":grpc_objc_client", - ":rx_library", + ":grpc_objc_interface", + ":proto_objc_rpc_legacy_header", "@com_google_protobuf//:protobuf_objc", ], ) + +native.objc_library( + name = "proto_objc_rpc", + srcs = [ + "ProtoRPC/ProtoRPCLegacy.m", + "ProtoRPC/ProtoServiceLegacy.m", + ], + hdrs = [ + "ProtoRPC/ProtoServiceLegacy.h", + ], + deps = [ + ":rx_library", + ":proto_objc_rpc_v2", + ":proto_objc_rpc_legacy_header", + ":grpc_objc_client_core", + "@com_google_protobuf//:protobuf_objc", + ], +) + +load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle") + +apple_resource_bundle( + # The choice of name is signicant here, since it determines the bundle name. + name = "gRPCCertificates", + resources = ["etc/roots.pem"], +) + diff --git a/src/objective-c/ProtoRPC/ProtoService.m b/src/objective-c/ProtoRPC/ProtoService.m index c3684c8e2f2..40c51ed48e7 100644 --- a/src/objective-c/ProtoRPC/ProtoService.m +++ b/src/objective-c/ProtoRPC/ProtoService.m @@ -39,7 +39,7 @@ [NSException raise:NSGenericException format:@"Do not call init method of ProtoService"]; return [self initWithHost:nil packageName:nil serviceName:nil callOptions:nil]; } -#pragma clang diasnostic pop +#pragma clang diagnostic pop // Designated initializer - (instancetype)initWithHost:(NSString *)host From f0c3f7b1baa5ac14d8238f941b6276af8895e57a Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 6 Aug 2019 10:26:16 -0700 Subject: [PATCH 1120/1555] native.objc_library -> grpc_objc_library --- src/objective-c/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/BUILD b/src/objective-c/BUILD index ba973141bcd..26d0bf00384 100644 --- a/src/objective-c/BUILD +++ b/src/objective-c/BUILD @@ -157,7 +157,7 @@ grpc_objc_library( ], ) -native.objc_library( +grpc_objc_library( name = "proto_objc_rpc", srcs = [ "ProtoRPC/ProtoRPCLegacy.m", From 5fd25f3c7c04ef4153fe26fcb1e42a2a0556b829 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 6 Aug 2019 10:41:54 -0700 Subject: [PATCH 1121/1555] Refactor rule. --- bazel/protobuf.bzl | 60 +++++++++++++++++++++++++++++++++++ bazel/python_rules.bzl | 71 +++++++----------------------------------- 2 files changed, 72 insertions(+), 59 deletions(-) diff --git a/bazel/protobuf.bzl b/bazel/protobuf.bzl index f2df7bd87b2..39a8cabcdc9 100644 --- a/bazel/protobuf.bzl +++ b/bazel/protobuf.bzl @@ -102,3 +102,63 @@ def get_plugin_args(plugin, flags, dir_out, generate_mocks): "--plugin=protoc-gen-PLUGIN=" + plugin.path, "--PLUGIN_out=" + ",".join(augmented_flags) + ":" + dir_out, ] + +def _get_staged_proto_file(context, source_file): + if source_file.dirname == context.label.package: + return source_file + else: + copied_proto = context.actions.declare_file(source_file.basename) + context.actions.run_shell( + inputs = [source_file], + outputs = [copied_proto], + command = "cp {} {}".format(source_file.path, copied_proto.path), + mnemonic = "CopySourceProto", + ) + return copied_proto + + +def protos_from_context(context): + """Copies proto files to the appropriate location. + + Args: + context: The ctx object for the rule. + + Returns: + A list of the protos. + """ + protos = [] + for src in context.attr.deps: + for file in src[ProtoInfo].direct_sources: + protos.append(_get_staged_proto_file(context, file)) + return protos + + +def includes_from_deps(deps): + """Get includes from rule dependencies.""" + return [ + file + for src in deps + for file in src[ProtoInfo].transitive_imports.to_list() + ] + +def get_proto_arguments(protos, genfiles_dir_path): + """Get the protoc arguments specifying which protos to compile.""" + arguments = [] + for proto in protos: + massaged_path = proto.path + if massaged_path.startswith(genfiles_dir_path): + massaged_path = proto.path[len(genfiles_dir_path) + 1:] + arguments.append(massaged_path) + return arguments + +def declare_out_files(protos, context, generated_file_format): + """Declares and returns the files to be generated.""" + return [ + context.actions.declare_file( + proto_path_to_generated_filename( + proto.basename, + generated_file_format, + ), + ) + for proto in protos + ] diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index 8f696b1022d..c8fdd1ed3c0 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -6,44 +6,20 @@ load( "get_plugin_args", "get_proto_root", "proto_path_to_generated_filename", + "protos_from_context", + "includes_from_deps", + "get_proto_arguments", + "declare_out_files", ) _GENERATED_PROTO_FORMAT = "{}_pb2.py" _GENERATED_GRPC_PROTO_FORMAT = "{}_pb2_grpc.py" -def _get_staged_proto_file(context, source_file): - if source_file.dirname == context.label.package: - return source_file - else: - copied_proto = context.actions.declare_file(source_file.basename) - context.actions.run_shell( - inputs = [source_file], - outputs = [copied_proto], - command = "cp {} {}".format(source_file.path, copied_proto.path), - mnemonic = "CopySourceProto", - ) - return copied_proto - def _generate_py_impl(context): - protos = [] - for src in context.attr.deps: - for file in src[ProtoInfo].direct_sources: - protos.append(_get_staged_proto_file(context, file)) - includes = [ - file - for src in context.attr.deps - for file in src[ProtoInfo].transitive_imports.to_list() - ] + protos = protos_from_context(context) + includes = includes_from_deps(context.attr.deps) proto_root = get_proto_root(context.label.workspace_root) - out_files = [ - context.actions.declare_file( - proto_path_to_generated_filename( - proto.basename, - _GENERATED_PROTO_FORMAT, - ), - ) - for proto in protos - ] + out_files = declare_out_files(protos, context, _GENERATED_PROTO_FORMAT) tools = [context.executable._protoc] arguments = ([ @@ -54,11 +30,7 @@ def _generate_py_impl(context): "--proto_path={}".format(context.genfiles_dir.path) for proto in protos ]) - for proto in protos: - massaged_path = proto.path - if massaged_path.startswith(context.genfiles_dir.path): - massaged_path = proto.path[len(context.genfiles_dir.path) + 1:] - arguments.append(massaged_path) + arguments += get_proto_arguments(protos, context.genfiles_dir.path) context.actions.run( inputs = protos + includes, @@ -116,25 +88,10 @@ def py_proto_library( ) def _generate_pb2_grpc_src_impl(context): - protos = [] - for src in context.attr.deps: - for file in src[ProtoInfo].direct_sources: - protos.append(_get_staged_proto_file(context, file)) - includes = [ - file - for src in context.attr.deps - for file in src[ProtoInfo].transitive_imports.to_list() - ] + protos = protos_from_context(context) + includes = includes_from_deps(context.attr.deps) proto_root = get_proto_root(context.label.workspace_root) - out_files = [ - context.actions.declare_file( - proto_path_to_generated_filename( - proto.basename, - _GENERATED_GRPC_PROTO_FORMAT, - ), - ) - for proto in protos - ] + out_files = declare_out_files(protos, context, _GENERATED_GRPC_PROTO_FORMAT) arguments = [] tools = [context.executable._protoc, context.executable._plugin] @@ -150,11 +107,7 @@ def _generate_pb2_grpc_src_impl(context): "--proto_path={}".format(context.genfiles_dir.path) for proto in protos ] - for proto in protos: - massaged_path = proto.path - if massaged_path.startswith(context.genfiles_dir.path): - massaged_path = proto.path[len(context.genfiles_dir.path) + 1:] - arguments.append(massaged_path) + arguments += get_proto_arguments(protos, context.genfiles_dir.path) context.actions.run( inputs = protos + includes, From 82b2dbfc1dfe9ba07c1b0ee61a08df8fdd0ec7ef Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 6 Aug 2019 12:04:02 -0700 Subject: [PATCH 1122/1555] Fix import issue --- src/objective-c/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/BUILD b/src/objective-c/BUILD index 26d0bf00384..13a26187e9f 100644 --- a/src/objective-c/BUILD +++ b/src/objective-c/BUILD @@ -180,6 +180,6 @@ load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle") apple_resource_bundle( # The choice of name is signicant here, since it determines the bundle name. name = "gRPCCertificates", - resources = ["etc/roots.pem"], + resources = ["//:etc/roots.pem"], ) From b99d3e146497b06e556317c1aa6a43f364ae2772 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Tue, 6 Aug 2019 14:10:14 -0700 Subject: [PATCH 1123/1555] Remove redundant and problematic memset --- src/core/ext/filters/client_idle/client_idle_filter.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/core/ext/filters/client_idle/client_idle_filter.cc b/src/core/ext/filters/client_idle/client_idle_filter.cc index d2b23a9d20f..542fad05b80 100644 --- a/src/core/ext/filters/client_idle/client_idle_filter.cc +++ b/src/core/ext/filters/client_idle/client_idle_filter.cc @@ -193,8 +193,6 @@ void ChannelData::EnterIdle() { GRPC_IDLE_FILTER_LOG("the channel will enter IDLE"); // Hold a ref to the channel stack for the transport op. GRPC_CHANNEL_STACK_REF(channel_stack_, "idle transport op"); - // Initialize the transport op. - memset(&idle_transport_op_, 0, sizeof(idle_transport_op_)); idle_transport_op_.disconnect_with_error = grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("enter idle"), GRPC_ERROR_INT_CHANNEL_CONNECTIVITY_STATE, GRPC_CHANNEL_IDLE); From f212cbad9a2348e73a8158f5a6851bdb6765c160 Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Mon, 5 Aug 2019 13:20:29 -0700 Subject: [PATCH 1124/1555] Remove references to GRPCConnectivityMonitor from ConnectivityTestingApp --- .../Connectivity/ConnectivityTestingApp/ViewController.m | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/objective-c/tests/Connectivity/ConnectivityTestingApp/ViewController.m b/src/objective-c/tests/Connectivity/ConnectivityTestingApp/ViewController.m index 3c77fe2f2c3..34c93878765 100644 --- a/src/objective-c/tests/Connectivity/ConnectivityTestingApp/ViewController.m +++ b/src/objective-c/tests/Connectivity/ConnectivityTestingApp/ViewController.m @@ -24,8 +24,6 @@ #import #import -#import "src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h" - NSString *host = @"grpc-test.sandbox.googleapis.com"; @interface ViewController : UIViewController @@ -34,10 +32,6 @@ NSString *host = @"grpc-test.sandbox.googleapis.com"; @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; - -#ifndef GRPC_CFSTREAM - [GRPCConnectivityMonitor registerObserver:self selector:@selector(reachabilityChanged:)]; -#endif } - (void)reachabilityChanged:(NSNotification *)note { From 3db88288767e903db35130c03c920fca709047be Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 6 Aug 2019 15:24:09 -0700 Subject: [PATCH 1125/1555] Add TODOs for prefix stripping --- examples/python/debug/get_stats.py | 1 + src/python/grpcio_channelz/grpc_channelz/v1/channelz.py | 1 + src/python/grpcio_health_checking/grpc_health/v1/health.py | 2 +- .../grpcio_reflection/grpc_reflection/v1alpha/reflection.py | 1 + .../grpcio_tests/tests/channelz/_channelz_servicer_test.py | 2 ++ .../grpcio_tests/tests/health_check/_health_servicer_test.py | 2 +- .../grpcio_tests/tests/reflection/_reflection_servicer_test.py | 2 ++ 7 files changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/python/debug/get_stats.py b/examples/python/debug/get_stats.py index 6eb593deb22..2da51d0efcf 100644 --- a/examples/python/debug/get_stats.py +++ b/examples/python/debug/get_stats.py @@ -21,6 +21,7 @@ import logging import argparse import grpc +# TODO(https://github.com/grpc/grpc/issues/19863): Remove. try: from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2 from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2_grpc diff --git a/src/python/grpcio_channelz/grpc_channelz/v1/channelz.py b/src/python/grpcio_channelz/grpc_channelz/v1/channelz.py index 18810cab290..965797f89ec 100644 --- a/src/python/grpcio_channelz/grpc_channelz/v1/channelz.py +++ b/src/python/grpcio_channelz/grpc_channelz/v1/channelz.py @@ -16,6 +16,7 @@ import grpc from grpc._cython import cygrpc +# TODO(https://github.com/grpc/grpc/issues/19863): Remove. try: from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2 as _channelz_pb2 from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2_grpc as _channelz_pb2_grpc diff --git a/src/python/grpcio_health_checking/grpc_health/v1/health.py b/src/python/grpcio_health_checking/grpc_health/v1/health.py index 93c1895df4c..a0d55570990 100644 --- a/src/python/grpcio_health_checking/grpc_health/v1/health.py +++ b/src/python/grpcio_health_checking/grpc_health/v1/health.py @@ -18,7 +18,7 @@ import threading import grpc -# Import using an absolute path to ensure no duplicate loaded modules. +# TODO(https://github.com/grpc/grpc/issues/19863): Remove. try: from src.python.grpcio_health_checking.grpc_health.v1 import health_pb2 as _health_pb2 from src.python.grpcio_health_checking.grpc_health.v1 import health_pb2_grpc as _health_pb2_grpc diff --git a/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py b/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py index bc76136cc5a..61153d9d625 100644 --- a/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py +++ b/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py @@ -17,6 +17,7 @@ import grpc from google.protobuf import descriptor_pb2 from google.protobuf import descriptor_pool +# TODO(https://github.com/grpc/grpc/issues/19863): Remove. try: from src.python.grpcio_reflection.grpc_reflection.v1alpha \ import reflection_pb2 as _reflection_pb2 diff --git a/src/python/grpcio_tests/tests/channelz/_channelz_servicer_test.py b/src/python/grpcio_tests/tests/channelz/_channelz_servicer_test.py index bfe184107ec..f2357a4e4a3 100644 --- a/src/python/grpcio_tests/tests/channelz/_channelz_servicer_test.py +++ b/src/python/grpcio_tests/tests/channelz/_channelz_servicer_test.py @@ -18,6 +18,8 @@ import unittest from concurrent import futures import grpc + +# TODO(https://github.com/grpc/grpc/issues/19863): Remove. try: from src.python.grpcio_channelz.grpc_channelz.v1 import channelz from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2 diff --git a/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py b/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py index 91e841a4d60..428806c71b0 100644 --- a/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py +++ b/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py @@ -20,7 +20,7 @@ import unittest import grpc -# Import using an absolute path to ensure no duplicate loaded modules. +# TODO(https://github.com/grpc/grpc/issues/19863): Remove. try: from src.python.grpcio_health_checking.grpc_health.v1 import health from src.python.grpcio_health_checking.grpc_health.v1 import health_pb2 diff --git a/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py b/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py index 1a1fdc83163..e45f98abec6 100644 --- a/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py +++ b/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py @@ -16,6 +16,8 @@ import unittest import grpc + +# TODO(https://github.com/grpc/grpc/issues/19863): Remove. try: from src.python.grpcio_reflection.grpc_reflection.v1alpha import reflection from src.python.grpcio_reflection.grpc_reflection.v1alpha import reflection_pb2 From f88bd06ee5203013b15989df75827a65516f97e4 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 30 Jul 2019 09:59:44 -0700 Subject: [PATCH 1126/1555] Go UPB! --- .clang_complete | 23 +- BUILD | 167 +- BUILD.gn | 38 + CMakeLists.txt | 4487 +++++++++++------ Makefile | 128 +- bazel/grpc_build_system.bzl | 5 +- bazel/grpc_deps.bzl | 6 +- build.yaml | 60 +- cmake/upb.cmake | 19 + config.m4 | 29 +- config.w32 | 43 +- gRPC-C++.podspec | 18 + gRPC-Core.podspec | 46 + grpc.gemspec | 29 + grpc.gyp | 128 +- package.xml | 29 + setup.py | 23 +- .../google/protobuf/descriptor.upb.c | 485 -- .../google/protobuf/descriptor.upb.h | 1690 ------- .../proto}/grpc/gcp/altscontext.upb.c | 4 +- .../proto}/grpc/gcp/altscontext.upb.h | 8 +- .../{ => src/proto}/grpc/gcp/handshaker.upb.c | 4 +- .../{ => src/proto}/grpc/gcp/handshaker.upb.h | 8 +- .../grpc/gcp/transport_security_common.upb.c | 4 +- .../grpc/gcp/transport_security_common.upb.h | 8 +- .../proto}/grpc/health/v1/health.upb.c | 4 +- .../proto}/grpc/health/v1/health.upb.h | 8 +- .../proto}/grpc/lb/v1/load_balancer.upb.c | 4 +- .../proto}/grpc/lb/v1/load_balancer.upb.h | 8 +- src/python/grpcio/grpc_core_dependencies.py | 18 + src/ruby/ext/grpc/ext-export.clang | 1 + src/ruby/ext/grpc/ext-export.gcc | 6 + src/ruby/ext/grpc/extconf.rb | 5 + src/upb/gen_build_yaml.py | 40 +- templates/CMakeLists.txt.template | 33 +- templates/Makefile.template | 6 +- templates/config.m4.template | 5 +- templates/config.w32.template | 9 +- templates/gRPC-C++.podspec.template | 6 + templates/gRPC-Core.podspec.template | 6 + third_party/upb | 2 +- tools/codegen/core/gen_upb_api.sh | 13 +- .../clang_tidy_all_the_things.sh | 2 +- tools/doxygen/Doxyfile.c++.internal | 11 +- tools/doxygen/Doxyfile.core.internal | 31 +- tools/profiling/ios_bin/binary_size.py | 4 +- .../generated/sources_and_headers.json | 111 +- tools/run_tests/sanity/check_submodules.sh | 2 +- 48 files changed, 3751 insertions(+), 4073 deletions(-) create mode 100644 cmake/upb.cmake delete mode 100644 src/core/ext/upb-generated/google/protobuf/descriptor.upb.c delete mode 100644 src/core/ext/upb-generated/google/protobuf/descriptor.upb.h rename src/core/ext/upb-generated/{ => src/proto}/grpc/gcp/altscontext.upb.c (93%) rename src/core/ext/upb-generated/{ => src/proto}/grpc/gcp/altscontext.upb.h (97%) rename src/core/ext/upb-generated/{ => src/proto}/grpc/gcp/handshaker.upb.c (98%) rename src/core/ext/upb-generated/{ => src/proto}/grpc/gcp/handshaker.upb.h (99%) rename src/core/ext/upb-generated/{ => src/proto}/grpc/gcp/transport_security_common.upb.c (89%) rename src/core/ext/upb-generated/{ => src/proto}/grpc/gcp/transport_security_common.upb.h (95%) rename src/core/ext/upb-generated/{ => src/proto}/grpc/health/v1/health.upb.c (89%) rename src/core/ext/upb-generated/{ => src/proto}/grpc/health/v1/health.upb.h (94%) rename src/core/ext/upb-generated/{ => src/proto}/grpc/lb/v1/load_balancer.upb.c (97%) rename src/core/ext/upb-generated/{ => src/proto}/grpc/lb/v1/load_balancer.upb.h (99%) create mode 100644 src/ruby/ext/grpc/ext-export.clang create mode 100644 src/ruby/ext/grpc/ext-export.gcc diff --git a/.clang_complete b/.clang_complete index 1448b01342d..f789455ea95 100644 --- a/.clang_complete +++ b/.clang_complete @@ -1,18 +1,19 @@ -Wall -Wc++-compat --Ithird_party/googletest/include --Ithird_party/googletest --Iinclude --Igens -I. --Ithird_party/boringssl/include --Ithird_party/benchmark/include --Ithird_party/zlib --Ithird_party/protobuf/src +-Igens +-Iinclude +-Isrc/core/ext/upb-generated -Ithird_party/abseil-cpp --Ithird_party/cares/cares +-Ithird_party/benchmark/include +-Ithird_party/boringssl/include -Ithird_party/cares --Ithird_party/googletest/googletest/include +-Ithird_party/cares/cares +-Ithird_party/googletest -Ithird_party/googletest/googlemock/include +-Ithird_party/googletest/googletest/include +-Ithird_party/googletest/include -Ithird_party/nanopb - +-Ithird_party/protobuf/src +-Ithird_party/upb +-Ithird_party/zlib diff --git a/BUILD b/BUILD index 39c6166cc5e..5da2eda36a3 100644 --- a/BUILD +++ b/BUILD @@ -342,7 +342,6 @@ grpc_cc_library( ], ) - grpc_cc_library( name = "grpc++_public_hdrs", hdrs = GRPCXX_PUBLIC_HDRS, @@ -1065,6 +1064,7 @@ grpc_cc_library( "grpc_base", "grpc_client_authority_filter", "grpc_deadline_filter", + "grpc_health_upb", "health_proto", "inlined_vector", "orphanable", @@ -2002,6 +2002,7 @@ grpc_cc_library( deps = [ "grpc", "grpc++_codegen_base", + "grpc_health_upb", "health_proto", ], ) @@ -2014,6 +2015,7 @@ grpc_cc_library( public_hdrs = GRPCXX_PUBLIC_HDRS, deps = [ "grpc++_codegen_base", + "grpc_health_upb", "grpc_unsecure", "health_proto", ], @@ -2077,7 +2079,7 @@ grpc_cc_library( "include/grpcpp/impl/codegen/config.h", "include/grpcpp/impl/codegen/core_codegen_interface.h", "include/grpcpp/impl/codegen/create_auth_context.h", - "include/grpcpp/impl/codegen/delegating_channel.h", + "include/grpcpp/impl/codegen/delegating_channel.h", "include/grpcpp/impl/codegen/grpc_library.h", "include/grpcpp/impl/codegen/intercepted_channel.h", "include/grpcpp/impl/codegen/interceptor.h", @@ -2277,60 +2279,137 @@ grpc_cc_library( ], ) -grpc_upb_proto_library( - name = "upb_load_report", - deps = ["@envoy_api//envoy/api/v2/endpoint:load_report_export"] -) +# Once upb code-gen issue is resolved, use this. +# grpc_upb_proto_library( +# name = "upb_load_report", +# deps = ["@envoy_api//envoy/api/v2/endpoint:load_report_export"], +# ) +# +# grpc_upb_proto_library( +# name = "upb_lrs", +# deps = ["@envoy_api//envoy/service/load_stats/v2:lrs_export"], +# ) +# +# grpc_upb_proto_library( +# name = "upb_cds", +# deps = ["@envoy_api//envoy/api/v2:cds_export"], +# ) -grpc_upb_proto_library( - name = "upb_lrs", - deps = ["@envoy_api//envoy/service/load_stats/v2:lrs_export"] -) +# grpc_cc_library( +# name = "envoy_lrs_upb", +# external_deps = [ +# "upb_lib", +# ], +# language = "c++", +# tags = ["no_windows"], +# deps = [ +# ":upb_load_report", +# ":upb_lrs", +# ], +# ) -grpc_upb_proto_library( - name = "upb_cds", - deps = ["@envoy_api//envoy/api/v2:cds_export"] -) +# grpc_cc_library( +# name = "envoy_ads_upb", +# external_deps = [ +# "upb_lib", +# ], +# language = "c++", +# tags = ["no_windows"], +# deps = [ +# ":upb_cds", +# ], +# ) -#TODO: Get this into build.yaml once we start using it. -grpc_cc_library( - name = "envoy_lrs_upb", - language = "c++", - external_deps = [ - "upb_lib", - ], - deps = [ - ":upb_load_report", - ":upb_lrs" - ], - tags = ["no_windows"], -) +# Once upb code-gen issue is resolved, replace grpc_health_upb with this. +# grpc_upb_proto_library( +# name = "grpc_health_upb", +# deps = ["//src/proto/grpc/health/v1:health_proto_descriptor"], +# ) grpc_cc_library( - name = "envoy_ads_upb", - external_deps = [ - "upb_lib", - ], - language = "c++", - deps = [ - ":upb_cds", - ], - tags = ["no_windows"], -) - -grpc_upb_proto_library( name = "grpc_health_upb", - deps = ["//src/proto/grpc/health/v1:health_proto_descriptor"] + srcs = [ + "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c", + ], + hdrs = [ + "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h", + ], + external_deps = [ + "upb_lib", + ], + language = "c++", ) -grpc_upb_proto_library( +# Once upb code-gen issue is resolved, remove this. +grpc_cc_library( + name = "google_api_upb", + srcs = [ + "src/core/ext/upb-generated/google/protobuf/any.upb.c", + "src/core/ext/upb-generated/google/protobuf/duration.upb.c", + "src/core/ext/upb-generated/google/protobuf/empty.upb.c", + "src/core/ext/upb-generated/google/protobuf/struct.upb.c", + "src/core/ext/upb-generated/google/protobuf/timestamp.upb.c", + "src/core/ext/upb-generated/google/protobuf/wrappers.upb.c", + ], + hdrs = [ + "src/core/ext/upb-generated/google/protobuf/any.upb.h", + "src/core/ext/upb-generated/google/protobuf/duration.upb.h", + "src/core/ext/upb-generated/google/protobuf/empty.upb.h", + "src/core/ext/upb-generated/google/protobuf/struct.upb.h", + "src/core/ext/upb-generated/google/protobuf/timestamp.upb.h", + "src/core/ext/upb-generated/google/protobuf/wrappers.upb.h", + ], + external_deps = [ + "upb_lib", + ], + language = "c++", +) + +# Once upb code-gen issue is resolved, replace grpc_lb_upb with this. +# grpc_upb_proto_library( +# name = "grpc_lb_upb", +# deps = ["//src/proto/grpc/lb/v1:load_balancer_proto_descriptor"], +# ) + +grpc_cc_library( name = "grpc_lb_upb", - deps = ["//src/proto/grpc/lb/v1:load_balancer_proto_descriptor"] + srcs = [ + "src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c", + ], + hdrs = [ + "src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h", + ], + external_deps = [ + "upb_lib", + ], + language = "c++", + deps = [ + "google_api_upb", + ], ) -grpc_upb_proto_library( +# Once upb code-gen issue is resolved, replace alts_upb with this. +# grpc_upb_proto_library( +# name = "alts_upb", +# deps = ["//src/proto/grpc/gcp:alts_handshaker_proto"], +# ) + +grpc_cc_library( name = "alts_upb", - deps = ["//src/proto/grpc/gcp:alts_handshaker_proto"] + srcs = [ + "src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c", + "src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c", + "src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c", + ], + hdrs = [ + "src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h", + "src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h", + "src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h", + ], + external_deps = [ + "upb_lib", + ], + language = "c++", ) grpc_generate_one_off_targets() diff --git a/BUILD.gn b/BUILD.gn index 8f0967e30ca..5e76bc64065 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -429,6 +429,28 @@ config("grpc_config") { "src/core/ext/transport/inproc/inproc_plugin.cc", "src/core/ext/transport/inproc/inproc_transport.cc", "src/core/ext/transport/inproc/inproc_transport.h", + "src/core/ext/upb-generated/google/protobuf/any.upb.c", + "src/core/ext/upb-generated/google/protobuf/any.upb.h", + "src/core/ext/upb-generated/google/protobuf/duration.upb.c", + "src/core/ext/upb-generated/google/protobuf/duration.upb.h", + "src/core/ext/upb-generated/google/protobuf/empty.upb.c", + "src/core/ext/upb-generated/google/protobuf/empty.upb.h", + "src/core/ext/upb-generated/google/protobuf/struct.upb.c", + "src/core/ext/upb-generated/google/protobuf/struct.upb.h", + "src/core/ext/upb-generated/google/protobuf/timestamp.upb.c", + "src/core/ext/upb-generated/google/protobuf/timestamp.upb.h", + "src/core/ext/upb-generated/google/protobuf/wrappers.upb.c", + "src/core/ext/upb-generated/google/protobuf/wrappers.upb.h", + "src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c", + "src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h", + "src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c", + "src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h", + "src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c", + "src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h", + "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c", + "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h", + "src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c", + "src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h", "src/core/lib/avl/avl.cc", "src/core/lib/avl/avl.h", "src/core/lib/backoff/backoff.cc", @@ -874,6 +896,13 @@ config("grpc_config") { "src/core/tsi/transport_security_grpc.cc", "src/core/tsi/transport_security_grpc.h", "src/core/tsi/transport_security_interface.h", + "third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c", + "third_party/upb/upb/decode.c", + "third_party/upb/upb/encode.c", + "third_party/upb/upb/msg.c", + "third_party/upb/upb/port.c", + "third_party/upb/upb/table.c", + "third_party/upb/upb/upb.c", ] deps = [ "//third_party/boringssl", @@ -1162,6 +1191,8 @@ config("grpc_config") { "include/grpcpp/support/time.h", "include/grpcpp/support/validate_service_config.h", "src/core/ext/transport/inproc/inproc_transport.h", + "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c", + "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h", "src/core/lib/avl/avl.h", "src/core/lib/backoff/backoff.h", "src/core/lib/channel/channel_args.h", @@ -1391,6 +1422,13 @@ config("grpc_config") { "src/cpp/util/status.cc", "src/cpp/util/string_ref.cc", "src/cpp/util/time_cc.cc", + "third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c", + "third_party/upb/upb/decode.c", + "third_party/upb/upb/encode.c", + "third_party/upb/upb/msg.c", + "third_party/upb/upb/port.c", + "third_party/upb/upb/table.c", + "third_party/upb/upb/upb.c", ] deps = [ "//third_party/boringssl", diff --git a/CMakeLists.txt b/CMakeLists.txt index e2cff6ab631..cf31e17beb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,14 +137,15 @@ else() set(_gRPC_CORE_NOSTDCXX_FLAGS "") endif() -include(cmake/zlib.cmake) +include(cmake/address_sorting.cmake) +include(cmake/benchmark.cmake) include(cmake/cares.cmake) +include(cmake/gflags.cmake) +include(cmake/nanopb.cmake) include(cmake/protobuf.cmake) include(cmake/ssl.cmake) -include(cmake/gflags.cmake) -include(cmake/benchmark.cmake) -include(cmake/address_sorting.cmake) -include(cmake/nanopb.cmake) +include(cmake/upb.cmake) +include(cmake/zlib.cmake) if(NOT MSVC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") @@ -787,14 +788,17 @@ endif() target_include_directories(address_sorting PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) # avoid dependency on libstdc++ if (_gRPC_CORE_NOSTDCXX_FLAGS) @@ -839,14 +843,17 @@ endif() target_include_directories(alts_test_util PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) # avoid dependency on libstdc++ if (_gRPC_CORE_NOSTDCXX_FLAGS) @@ -921,14 +928,17 @@ endif() target_include_directories(gpr PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) # avoid dependency on libstdc++ if (_gRPC_CORE_NOSTDCXX_FLAGS) @@ -1255,7 +1265,17 @@ add_library(grpc third_party/nanopb/pb_common.c third_party/nanopb/pb_decode.c third_party/nanopb/pb_encode.c + src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c + src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c + src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c src/core/tsi/transport_security.cc + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c + third_party/upb/upb/decode.c + third_party/upb/upb/encode.c + third_party/upb/upb/msg.c + third_party/upb/upb/port.c + third_party/upb/upb/table.c + third_party/upb/upb/upb.c src/core/ext/transport/chttp2/client/insecure/channel_create.cc src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc src/core/ext/transport/chttp2/client/authority.cc @@ -1287,6 +1307,7 @@ add_library(grpc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c src/core/ext/filters/client_channel/health/health.pb.c src/core/tsi/fake_transport_security.cc src/core/tsi/local_transport_security.cc @@ -1306,6 +1327,13 @@ add_library(grpc src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc + src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c + src/core/ext/upb-generated/google/protobuf/any.upb.c + src/core/ext/upb-generated/google/protobuf/duration.upb.c + src/core/ext/upb-generated/google/protobuf/empty.upb.c + src/core/ext/upb-generated/google/protobuf/struct.upb.c + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c @@ -1354,14 +1382,17 @@ endif() target_include_directories(grpc PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) # avoid dependency on libstdc++ if (_gRPC_CORE_NOSTDCXX_FLAGS) @@ -1657,6 +1688,14 @@ add_library(grpc_cronet src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c + third_party/upb/upb/decode.c + third_party/upb/upb/encode.c + third_party/upb/upb/msg.c + third_party/upb/upb/port.c + third_party/upb/upb/table.c + third_party/upb/upb/upb.c src/core/ext/filters/client_channel/health/health.pb.c third_party/nanopb/pb_common.c third_party/nanopb/pb_decode.c @@ -1728,6 +1767,9 @@ add_library(grpc_cronet src/core/tsi/alts/handshaker/altscontext.pb.c src/core/tsi/alts/handshaker/handshaker.pb.c src/core/tsi/alts/handshaker/transport_security_common.pb.c + src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c + src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c + src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c src/core/tsi/transport_security.cc src/core/ext/transport/chttp2/client/insecure/channel_create.cc src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc @@ -1757,14 +1799,17 @@ endif() target_include_directories(grpc_cronet PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) # avoid dependency on libstdc++ if (_gRPC_CORE_NOSTDCXX_FLAGS) @@ -2046,6 +2091,14 @@ add_library(grpc_test_util src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c + third_party/upb/upb/decode.c + third_party/upb/upb/encode.c + third_party/upb/upb/msg.c + third_party/upb/upb/port.c + third_party/upb/upb/table.c + third_party/upb/upb/upb.c src/core/ext/filters/client_channel/health/health.pb.c third_party/nanopb/pb_common.c third_party/nanopb/pb_decode.c @@ -2095,14 +2148,17 @@ endif() target_include_directories(grpc_test_util PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) # avoid dependency on libstdc++ if (_gRPC_CORE_NOSTDCXX_FLAGS) @@ -2381,6 +2437,14 @@ add_library(grpc_test_util_unsecure src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c + third_party/upb/upb/decode.c + third_party/upb/upb/encode.c + third_party/upb/upb/msg.c + third_party/upb/upb/port.c + third_party/upb/upb/table.c + third_party/upb/upb/upb.c src/core/ext/filters/client_channel/health/health.pb.c third_party/nanopb/pb_common.c third_party/nanopb/pb_decode.c @@ -2430,14 +2494,17 @@ endif() target_include_directories(grpc_test_util_unsecure PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) # avoid dependency on libstdc++ if (_gRPC_CORE_NOSTDCXX_FLAGS) @@ -2727,6 +2794,14 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c + third_party/upb/upb/decode.c + third_party/upb/upb/encode.c + third_party/upb/upb/msg.c + third_party/upb/upb/port.c + third_party/upb/upb/table.c + third_party/upb/upb/upb.c src/core/ext/filters/client_channel/health/health.pb.c third_party/nanopb/pb_common.c third_party/nanopb/pb_decode.c @@ -2752,6 +2827,13 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc + src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c + src/core/ext/upb-generated/google/protobuf/any.upb.c + src/core/ext/upb-generated/google/protobuf/duration.upb.c + src/core/ext/upb-generated/google/protobuf/empty.upb.c + src/core/ext/upb-generated/google/protobuf/struct.upb.c + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c @@ -2786,14 +2868,17 @@ endif() target_include_directories(grpc_unsecure PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) # avoid dependency on libstdc++ if (_gRPC_CORE_NOSTDCXX_FLAGS) @@ -2887,14 +2972,17 @@ endif() target_include_directories(reconnect_server PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) # avoid dependency on libstdc++ if (_gRPC_CORE_NOSTDCXX_FLAGS) @@ -2933,14 +3021,17 @@ endif() target_include_directories(test_tcp_server PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) # avoid dependency on libstdc++ if (_gRPC_CORE_NOSTDCXX_FLAGS) @@ -2987,14 +3078,17 @@ protobuf_generate_grpc_cpp( target_include_directories(bm_callback_test_service_impl PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -3039,14 +3133,17 @@ endif() target_include_directories(dns_test_util PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -3106,6 +3203,14 @@ add_library(grpc++ src/cpp/util/status.cc src/cpp/util/string_ref.cc src/cpp/util/time_cc.cc + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c + third_party/upb/upb/decode.c + third_party/upb/upb/encode.c + third_party/upb/upb/msg.c + third_party/upb/upb/port.c + third_party/upb/upb/table.c + third_party/upb/upb/upb.c src/core/ext/filters/client_channel/health/health.pb.c third_party/nanopb/pb_common.c third_party/nanopb/pb_decode.c @@ -3128,14 +3233,17 @@ endif() target_include_directories(grpc++ PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTO_GENS_DIR} ) target_link_libraries(grpc++ @@ -3454,14 +3562,17 @@ protobuf_generate_grpc_cpp( target_include_directories(grpc++_core_stats PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -3506,14 +3617,17 @@ protobuf_generate_grpc_cpp( target_include_directories(grpc++_error_details PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTO_GENS_DIR} ) target_link_libraries(grpc++_error_details @@ -3576,14 +3690,17 @@ protobuf_generate_grpc_cpp( target_include_directories(grpc++_proto_reflection_desc_db PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -3640,14 +3757,17 @@ protobuf_generate_grpc_cpp( target_include_directories(grpc++_reflection PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTO_GENS_DIR} ) target_link_libraries(grpc++_reflection @@ -3702,14 +3822,17 @@ endif() target_include_directories(grpc++_test_config PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -3797,14 +3920,17 @@ protobuf_generate_grpc_cpp( target_include_directories(grpc++_test_util PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -4004,14 +4130,17 @@ protobuf_generate_grpc_cpp( target_include_directories(grpc++_test_util_unsecure PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -4188,6 +4317,14 @@ add_library(grpc++_unsecure src/cpp/util/status.cc src/cpp/util/string_ref.cc src/cpp/util/time_cc.cc + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c + third_party/upb/upb/decode.c + third_party/upb/upb/encode.c + third_party/upb/upb/msg.c + third_party/upb/upb/port.c + third_party/upb/upb/table.c + third_party/upb/upb/upb.c src/core/ext/filters/client_channel/health/health.pb.c third_party/nanopb/pb_common.c third_party/nanopb/pb_decode.c @@ -4210,14 +4347,17 @@ endif() target_include_directories(grpc++_unsecure PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTO_GENS_DIR} ) target_link_libraries(grpc++_unsecure @@ -4521,14 +4661,17 @@ endif() target_include_directories(grpc_benchmark PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -4580,14 +4723,17 @@ protobuf_generate_grpc_cpp( target_include_directories(grpc_cli_libs PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -4642,14 +4788,17 @@ endif() target_include_directories(grpc_plugin_support PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTO_GENS_DIR} ) target_link_libraries(grpc_plugin_support @@ -4707,14 +4856,17 @@ protobuf_generate_grpc_cpp( target_include_directories(grpcpp_channelz PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTO_GENS_DIR} ) target_link_libraries(grpcpp_channelz @@ -4790,14 +4942,17 @@ protobuf_generate_grpc_cpp( target_include_directories(http2_client_main PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -4847,14 +5002,17 @@ protobuf_generate_grpc_cpp( target_include_directories(interop_client_helper PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -4919,14 +5077,17 @@ protobuf_generate_grpc_cpp( target_include_directories(interop_client_main PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -4970,14 +5131,17 @@ endif() target_include_directories(interop_server_helper PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -5040,14 +5204,17 @@ protobuf_generate_grpc_cpp( target_include_directories(interop_server_lib PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -5091,14 +5258,17 @@ endif() target_include_directories(interop_server_main PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -5197,14 +5367,17 @@ protobuf_generate_grpc_cpp( target_include_directories(qps PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -5246,14 +5419,17 @@ endif() target_include_directories(grpc_csharp_ext PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) # avoid dependency on libstdc++ if (_gRPC_CORE_NOSTDCXX_FLAGS) @@ -5299,14 +5475,17 @@ endif() target_include_directories(bad_client_test PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -5345,14 +5524,17 @@ endif() target_include_directories(bad_ssl_test_server PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) # avoid dependency on libstdc++ if (_gRPC_CORE_NOSTDCXX_FLAGS) @@ -5469,14 +5651,17 @@ endif() target_include_directories(end2end_tests PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) # avoid dependency on libstdc++ if (_gRPC_CORE_NOSTDCXX_FLAGS) @@ -5593,14 +5778,17 @@ endif() target_include_directories(end2end_nosec_tests PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) # avoid dependency on libstdc++ if (_gRPC_CORE_NOSTDCXX_FLAGS) @@ -5628,14 +5816,17 @@ add_executable(algorithm_test target_include_directories(algorithm_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(algorithm_test @@ -5662,14 +5853,17 @@ add_executable(alloc_test target_include_directories(alloc_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(alloc_test @@ -5696,14 +5890,17 @@ add_executable(alpn_test target_include_directories(alpn_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(alpn_test @@ -5730,14 +5927,17 @@ add_executable(arena_test target_include_directories(arena_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(arena_test @@ -5764,14 +5964,17 @@ add_executable(avl_test target_include_directories(avl_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(avl_test @@ -5798,14 +6001,17 @@ add_executable(bad_server_response_test target_include_directories(bad_server_response_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(bad_server_response_test @@ -5833,14 +6039,17 @@ add_executable(bin_decoder_test target_include_directories(bin_decoder_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(bin_decoder_test @@ -5866,14 +6075,17 @@ add_executable(bin_encoder_test target_include_directories(bin_encoder_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(bin_encoder_test @@ -5900,14 +6112,17 @@ add_executable(buffer_list_test target_include_directories(buffer_list_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(buffer_list_test @@ -5935,14 +6150,17 @@ add_executable(channel_create_test target_include_directories(channel_create_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(channel_create_test @@ -5968,14 +6186,17 @@ add_executable(check_epollexclusive target_include_directories(check_epollexclusive PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(check_epollexclusive @@ -6000,14 +6221,17 @@ add_executable(chttp2_hpack_encoder_test target_include_directories(chttp2_hpack_encoder_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(chttp2_hpack_encoder_test @@ -6034,14 +6258,17 @@ add_executable(chttp2_stream_map_test target_include_directories(chttp2_stream_map_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(chttp2_stream_map_test @@ -6068,14 +6295,17 @@ add_executable(chttp2_varint_test target_include_directories(chttp2_varint_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(chttp2_varint_test @@ -6103,14 +6333,17 @@ add_executable(close_fd_test target_include_directories(close_fd_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(close_fd_test @@ -6138,14 +6371,17 @@ add_executable(cmdline_test target_include_directories(cmdline_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(cmdline_test @@ -6172,14 +6408,17 @@ add_executable(combiner_test target_include_directories(combiner_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(combiner_test @@ -6206,14 +6445,17 @@ add_executable(compression_test target_include_directories(compression_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(compression_test @@ -6240,14 +6482,17 @@ add_executable(concurrent_connectivity_test target_include_directories(concurrent_connectivity_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(concurrent_connectivity_test @@ -6274,14 +6519,17 @@ add_executable(connection_refused_test target_include_directories(connection_refused_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(connection_refused_test @@ -6308,14 +6556,17 @@ add_executable(dns_resolver_connectivity_test target_include_directories(dns_resolver_connectivity_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(dns_resolver_connectivity_test @@ -6342,14 +6593,17 @@ add_executable(dns_resolver_cooldown_using_ares_resolver_test target_include_directories(dns_resolver_cooldown_using_ares_resolver_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(dns_resolver_cooldown_using_ares_resolver_test @@ -6376,14 +6630,17 @@ add_executable(dns_resolver_cooldown_using_native_resolver_test target_include_directories(dns_resolver_cooldown_using_native_resolver_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(dns_resolver_cooldown_using_native_resolver_test @@ -6410,14 +6667,17 @@ add_executable(dns_resolver_test target_include_directories(dns_resolver_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(dns_resolver_test @@ -6445,14 +6705,17 @@ add_executable(dualstack_socket_test target_include_directories(dualstack_socket_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(dualstack_socket_test @@ -6480,14 +6743,17 @@ add_executable(endpoint_pair_test target_include_directories(endpoint_pair_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(endpoint_pair_test @@ -6514,14 +6780,17 @@ add_executable(error_test target_include_directories(error_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(error_test @@ -6549,14 +6818,17 @@ add_executable(ev_epollex_linux_test target_include_directories(ev_epollex_linux_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(ev_epollex_linux_test @@ -6584,14 +6856,17 @@ add_executable(fake_resolver_test target_include_directories(fake_resolver_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(fake_resolver_test @@ -6620,14 +6895,17 @@ add_executable(fake_transport_security_test target_include_directories(fake_transport_security_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(fake_transport_security_test @@ -6656,14 +6934,17 @@ add_executable(fd_conservation_posix_test target_include_directories(fd_conservation_posix_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(fd_conservation_posix_test @@ -6692,14 +6973,17 @@ add_executable(fd_posix_test target_include_directories(fd_posix_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(fd_posix_test @@ -6727,14 +7011,17 @@ add_executable(fling_client target_include_directories(fling_client PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(fling_client @@ -6761,14 +7048,17 @@ add_executable(fling_server target_include_directories(fling_server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(fling_server @@ -6796,14 +7086,17 @@ add_executable(fling_stream_test target_include_directories(fling_stream_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(fling_stream_test @@ -6832,14 +7125,17 @@ add_executable(fling_test target_include_directories(fling_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(fling_test @@ -6868,14 +7164,17 @@ add_executable(fork_test target_include_directories(fork_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(fork_test @@ -6904,14 +7203,17 @@ add_executable(goaway_server_test target_include_directories(goaway_server_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(goaway_server_test @@ -6939,14 +7241,17 @@ add_executable(gpr_cpu_test target_include_directories(gpr_cpu_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(gpr_cpu_test @@ -6973,14 +7278,17 @@ add_executable(gpr_env_test target_include_directories(gpr_env_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(gpr_env_test @@ -7007,14 +7315,17 @@ add_executable(gpr_host_port_test target_include_directories(gpr_host_port_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(gpr_host_port_test @@ -7041,14 +7352,17 @@ add_executable(gpr_log_test target_include_directories(gpr_log_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(gpr_log_test @@ -7075,14 +7389,17 @@ add_executable(gpr_manual_constructor_test target_include_directories(gpr_manual_constructor_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(gpr_manual_constructor_test @@ -7109,14 +7426,17 @@ add_executable(gpr_mpscq_test target_include_directories(gpr_mpscq_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(gpr_mpscq_test @@ -7143,14 +7463,17 @@ add_executable(gpr_spinlock_test target_include_directories(gpr_spinlock_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(gpr_spinlock_test @@ -7177,14 +7500,17 @@ add_executable(gpr_string_test target_include_directories(gpr_string_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(gpr_string_test @@ -7211,14 +7537,17 @@ add_executable(gpr_sync_test target_include_directories(gpr_sync_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(gpr_sync_test @@ -7245,14 +7574,17 @@ add_executable(gpr_thd_test target_include_directories(gpr_thd_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(gpr_thd_test @@ -7279,14 +7611,17 @@ add_executable(gpr_time_test target_include_directories(gpr_time_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(gpr_time_test @@ -7313,14 +7648,17 @@ add_executable(gpr_tls_test target_include_directories(gpr_tls_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(gpr_tls_test @@ -7347,14 +7685,17 @@ add_executable(gpr_useful_test target_include_directories(gpr_useful_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(gpr_useful_test @@ -7381,14 +7722,17 @@ add_executable(grpc_auth_context_test target_include_directories(grpc_auth_context_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(grpc_auth_context_test @@ -7415,14 +7759,17 @@ add_executable(grpc_b64_test target_include_directories(grpc_b64_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(grpc_b64_test @@ -7449,14 +7796,17 @@ add_executable(grpc_byte_buffer_reader_test target_include_directories(grpc_byte_buffer_reader_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(grpc_byte_buffer_reader_test @@ -7483,14 +7833,17 @@ add_executable(grpc_channel_args_test target_include_directories(grpc_channel_args_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(grpc_channel_args_test @@ -7517,14 +7870,17 @@ add_executable(grpc_channel_stack_builder_test target_include_directories(grpc_channel_stack_builder_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(grpc_channel_stack_builder_test @@ -7551,14 +7907,17 @@ add_executable(grpc_channel_stack_test target_include_directories(grpc_channel_stack_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(grpc_channel_stack_test @@ -7585,14 +7944,17 @@ add_executable(grpc_completion_queue_test target_include_directories(grpc_completion_queue_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(grpc_completion_queue_test @@ -7619,14 +7981,17 @@ add_executable(grpc_completion_queue_threading_test target_include_directories(grpc_completion_queue_threading_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(grpc_completion_queue_threading_test @@ -7653,14 +8018,17 @@ add_executable(grpc_control_plane_credentials_test target_include_directories(grpc_control_plane_credentials_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(grpc_control_plane_credentials_test @@ -7687,14 +8055,17 @@ add_executable(grpc_create_jwt target_include_directories(grpc_create_jwt PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(grpc_create_jwt @@ -7720,14 +8091,17 @@ add_executable(grpc_credentials_test target_include_directories(grpc_credentials_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(grpc_credentials_test @@ -7754,14 +8128,17 @@ add_executable(grpc_ipv6_loopback_available_test target_include_directories(grpc_ipv6_loopback_available_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(grpc_ipv6_loopback_available_test @@ -7789,14 +8166,17 @@ add_executable(grpc_json_token_test target_include_directories(grpc_json_token_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(grpc_json_token_test @@ -7824,14 +8204,17 @@ add_executable(grpc_jwt_verifier_test target_include_directories(grpc_jwt_verifier_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(grpc_jwt_verifier_test @@ -7858,14 +8241,17 @@ add_executable(grpc_print_google_default_creds_token target_include_directories(grpc_print_google_default_creds_token PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(grpc_print_google_default_creds_token @@ -7890,14 +8276,17 @@ add_executable(grpc_security_connector_test target_include_directories(grpc_security_connector_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(grpc_security_connector_test @@ -7924,14 +8313,17 @@ add_executable(grpc_ssl_credentials_test target_include_directories(grpc_ssl_credentials_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(grpc_ssl_credentials_test @@ -7958,14 +8350,17 @@ add_executable(grpc_verify_jwt target_include_directories(grpc_verify_jwt PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(grpc_verify_jwt @@ -7991,14 +8386,17 @@ add_executable(handshake_client_ssl target_include_directories(handshake_client_ssl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(handshake_client_ssl @@ -8029,14 +8427,17 @@ add_executable(handshake_server_ssl target_include_directories(handshake_server_ssl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(handshake_server_ssl @@ -8067,14 +8468,17 @@ add_executable(handshake_server_with_readahead_handshaker target_include_directories(handshake_server_with_readahead_handshaker PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(handshake_server_with_readahead_handshaker @@ -8104,14 +8508,17 @@ add_executable(handshake_verify_peer_options target_include_directories(handshake_verify_peer_options PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(handshake_verify_peer_options @@ -8140,14 +8547,17 @@ add_executable(histogram_test target_include_directories(histogram_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(histogram_test @@ -8173,14 +8583,17 @@ add_executable(hpack_parser_test target_include_directories(hpack_parser_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(hpack_parser_test @@ -8207,14 +8620,17 @@ add_executable(hpack_table_test target_include_directories(hpack_table_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(hpack_table_test @@ -8241,14 +8657,17 @@ add_executable(http_parser_test target_include_directories(http_parser_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(http_parser_test @@ -8275,14 +8694,17 @@ add_executable(httpcli_format_request_test target_include_directories(httpcli_format_request_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(httpcli_format_request_test @@ -8310,14 +8732,17 @@ add_executable(httpcli_test target_include_directories(httpcli_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(httpcli_test @@ -8346,14 +8771,17 @@ add_executable(httpscli_test target_include_directories(httpscli_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(httpscli_test @@ -8381,14 +8809,17 @@ add_executable(init_test target_include_directories(init_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(init_test @@ -8415,14 +8846,17 @@ add_executable(inproc_callback_test target_include_directories(inproc_callback_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(inproc_callback_test @@ -8449,14 +8883,17 @@ add_executable(invalid_call_argument_test target_include_directories(invalid_call_argument_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(invalid_call_argument_test @@ -8483,14 +8920,17 @@ add_executable(json_rewrite target_include_directories(json_rewrite PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(json_rewrite @@ -8517,14 +8957,17 @@ add_executable(json_rewrite_test target_include_directories(json_rewrite_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(json_rewrite_test @@ -8551,14 +8994,17 @@ add_executable(json_stream_error_test target_include_directories(json_stream_error_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(json_stream_error_test @@ -8585,14 +9031,17 @@ add_executable(json_test target_include_directories(json_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(json_test @@ -8619,14 +9068,17 @@ add_executable(lame_client_test target_include_directories(lame_client_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(lame_client_test @@ -8653,14 +9105,17 @@ add_executable(load_file_test target_include_directories(load_file_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(load_file_test @@ -8687,14 +9142,17 @@ add_executable(memory_usage_client target_include_directories(memory_usage_client PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(memory_usage_client @@ -8721,14 +9179,17 @@ add_executable(memory_usage_server target_include_directories(memory_usage_server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(memory_usage_server @@ -8756,14 +9217,17 @@ add_executable(memory_usage_test target_include_directories(memory_usage_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(memory_usage_test @@ -8791,14 +9255,17 @@ add_executable(message_compress_test target_include_directories(message_compress_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(message_compress_test @@ -8825,14 +9292,17 @@ add_executable(minimal_stack_is_minimal_test target_include_directories(minimal_stack_is_minimal_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(minimal_stack_is_minimal_test @@ -8859,14 +9329,17 @@ add_executable(mpmcqueue_test target_include_directories(mpmcqueue_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(mpmcqueue_test @@ -8893,14 +9366,17 @@ add_executable(multiple_server_queues_test target_include_directories(multiple_server_queues_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(multiple_server_queues_test @@ -8927,14 +9403,17 @@ add_executable(murmur_hash_test target_include_directories(murmur_hash_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(murmur_hash_test @@ -8961,14 +9440,17 @@ add_executable(no_server_test target_include_directories(no_server_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(no_server_test @@ -8995,14 +9477,17 @@ add_executable(num_external_connectivity_watchers_test target_include_directories(num_external_connectivity_watchers_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(num_external_connectivity_watchers_test @@ -9029,14 +9514,17 @@ add_executable(parse_address_test target_include_directories(parse_address_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(parse_address_test @@ -9064,14 +9552,17 @@ add_executable(parse_address_with_named_scope_id_test target_include_directories(parse_address_with_named_scope_id_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(parse_address_with_named_scope_id_test @@ -9099,14 +9590,17 @@ add_executable(percent_encoding_test target_include_directories(percent_encoding_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(percent_encoding_test @@ -9134,14 +9628,17 @@ add_executable(resolve_address_using_ares_resolver_posix_test target_include_directories(resolve_address_using_ares_resolver_posix_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(resolve_address_using_ares_resolver_posix_test @@ -9169,14 +9666,17 @@ add_executable(resolve_address_using_ares_resolver_test target_include_directories(resolve_address_using_ares_resolver_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(resolve_address_using_ares_resolver_test @@ -9204,14 +9704,17 @@ add_executable(resolve_address_using_native_resolver_posix_test target_include_directories(resolve_address_using_native_resolver_posix_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(resolve_address_using_native_resolver_posix_test @@ -9239,14 +9742,17 @@ add_executable(resolve_address_using_native_resolver_test target_include_directories(resolve_address_using_native_resolver_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(resolve_address_using_native_resolver_test @@ -9273,14 +9779,17 @@ add_executable(resource_quota_test target_include_directories(resource_quota_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(resource_quota_test @@ -9307,14 +9816,17 @@ add_executable(secure_channel_create_test target_include_directories(secure_channel_create_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(secure_channel_create_test @@ -9341,14 +9853,17 @@ add_executable(secure_endpoint_test target_include_directories(secure_endpoint_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(secure_endpoint_test @@ -9375,14 +9890,17 @@ add_executable(sequential_connectivity_test target_include_directories(sequential_connectivity_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(sequential_connectivity_test @@ -9409,14 +9927,17 @@ add_executable(server_chttp2_test target_include_directories(server_chttp2_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(server_chttp2_test @@ -9443,14 +9964,17 @@ add_executable(server_test target_include_directories(server_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(server_test @@ -9477,14 +10001,17 @@ add_executable(slice_buffer_test target_include_directories(slice_buffer_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(slice_buffer_test @@ -9511,14 +10038,17 @@ add_executable(slice_string_helpers_test target_include_directories(slice_string_helpers_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(slice_string_helpers_test @@ -9545,14 +10075,17 @@ add_executable(slice_test target_include_directories(slice_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(slice_test @@ -9579,14 +10112,17 @@ add_executable(sockaddr_resolver_test target_include_directories(sockaddr_resolver_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(sockaddr_resolver_test @@ -9613,14 +10149,17 @@ add_executable(sockaddr_utils_test target_include_directories(sockaddr_utils_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(sockaddr_utils_test @@ -9648,14 +10187,17 @@ add_executable(socket_utils_test target_include_directories(socket_utils_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(socket_utils_test @@ -9685,14 +10227,17 @@ add_executable(ssl_transport_security_test target_include_directories(ssl_transport_security_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(ssl_transport_security_test @@ -9720,14 +10265,17 @@ add_executable(status_conversion_test target_include_directories(status_conversion_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(status_conversion_test @@ -9754,14 +10302,17 @@ add_executable(stream_compression_test target_include_directories(stream_compression_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(stream_compression_test @@ -9788,14 +10339,17 @@ add_executable(stream_owned_slice_test target_include_directories(stream_owned_slice_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(stream_owned_slice_test @@ -9823,14 +10377,17 @@ add_executable(tcp_client_posix_test target_include_directories(tcp_client_posix_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(tcp_client_posix_test @@ -9858,14 +10415,17 @@ add_executable(tcp_client_uv_test target_include_directories(tcp_client_uv_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(tcp_client_uv_test @@ -9893,14 +10453,17 @@ add_executable(tcp_posix_test target_include_directories(tcp_posix_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(tcp_posix_test @@ -9929,14 +10492,17 @@ add_executable(tcp_server_posix_test target_include_directories(tcp_server_posix_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(tcp_server_posix_test @@ -9964,14 +10530,17 @@ add_executable(tcp_server_uv_test target_include_directories(tcp_server_uv_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(tcp_server_uv_test @@ -9998,14 +10567,17 @@ add_executable(threadpool_test target_include_directories(threadpool_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(threadpool_test @@ -10032,14 +10604,17 @@ add_executable(time_averaged_stats_test target_include_directories(time_averaged_stats_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(time_averaged_stats_test @@ -10066,14 +10641,17 @@ add_executable(timeout_encoding_test target_include_directories(timeout_encoding_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(timeout_encoding_test @@ -10100,14 +10678,17 @@ add_executable(timer_heap_test target_include_directories(timer_heap_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(timer_heap_test @@ -10134,14 +10715,17 @@ add_executable(timer_list_test target_include_directories(timer_list_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(timer_list_test @@ -10168,14 +10752,17 @@ add_executable(transport_connectivity_state_test target_include_directories(transport_connectivity_state_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(transport_connectivity_state_test @@ -10202,14 +10789,17 @@ add_executable(transport_metadata_test target_include_directories(transport_metadata_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(transport_metadata_test @@ -10237,14 +10827,17 @@ add_executable(transport_security_test target_include_directories(transport_security_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(transport_security_test @@ -10273,14 +10866,17 @@ add_executable(udp_server_test target_include_directories(udp_server_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(udp_server_test @@ -10308,14 +10904,17 @@ add_executable(uri_parser_test target_include_directories(uri_parser_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(uri_parser_test @@ -10344,14 +10943,17 @@ add_executable(alarm_test target_include_directories(alarm_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -10384,14 +10986,17 @@ add_executable(alts_counter_test target_include_directories(alts_counter_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -10422,14 +11027,17 @@ add_executable(alts_crypt_test target_include_directories(alts_crypt_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -10461,14 +11069,17 @@ add_executable(alts_crypter_test target_include_directories(alts_crypter_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -10499,14 +11110,17 @@ add_executable(alts_frame_handler_test target_include_directories(alts_frame_handler_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -10538,14 +11152,17 @@ add_executable(alts_frame_protector_test target_include_directories(alts_frame_protector_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -10576,14 +11193,17 @@ add_executable(alts_grpc_record_protocol_test target_include_directories(alts_grpc_record_protocol_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -10614,14 +11234,17 @@ add_executable(alts_handshaker_client_test target_include_directories(alts_handshaker_client_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -10652,14 +11275,17 @@ add_executable(alts_handshaker_service_api_test target_include_directories(alts_handshaker_service_api_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -10690,14 +11316,17 @@ add_executable(alts_iovec_record_protocol_test target_include_directories(alts_iovec_record_protocol_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -10728,14 +11357,17 @@ add_executable(alts_security_connector_test target_include_directories(alts_security_connector_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -10765,14 +11397,17 @@ add_executable(alts_tsi_handshaker_test target_include_directories(alts_tsi_handshaker_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -10803,14 +11438,17 @@ add_executable(alts_tsi_utils_test target_include_directories(alts_tsi_utils_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -10841,14 +11479,17 @@ add_executable(alts_zero_copy_grpc_protector_test target_include_directories(alts_zero_copy_grpc_protector_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -10879,14 +11520,17 @@ add_executable(async_end2end_test target_include_directories(async_end2end_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -10919,14 +11563,17 @@ add_executable(auth_property_iterator_test target_include_directories(auth_property_iterator_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -10959,14 +11606,17 @@ add_executable(backoff_test target_include_directories(backoff_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -10997,14 +11647,17 @@ add_executable(bdp_estimator_test target_include_directories(bdp_estimator_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11038,14 +11691,17 @@ add_executable(bm_alarm target_include_directories(bm_alarm PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11083,14 +11739,17 @@ add_executable(bm_arena target_include_directories(bm_arena PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11128,14 +11787,17 @@ add_executable(bm_byte_buffer target_include_directories(bm_byte_buffer PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11173,14 +11835,17 @@ add_executable(bm_call_create target_include_directories(bm_call_create PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11218,14 +11883,17 @@ add_executable(bm_callback_streaming_ping_pong target_include_directories(bm_callback_streaming_ping_pong PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11264,14 +11932,17 @@ add_executable(bm_callback_unary_ping_pong target_include_directories(bm_callback_unary_ping_pong PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11310,14 +11981,17 @@ add_executable(bm_channel target_include_directories(bm_channel PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11355,14 +12029,17 @@ add_executable(bm_chttp2_hpack target_include_directories(bm_chttp2_hpack PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11400,14 +12077,17 @@ add_executable(bm_chttp2_transport target_include_directories(bm_chttp2_transport PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11445,14 +12125,17 @@ add_executable(bm_closure target_include_directories(bm_closure PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11490,14 +12173,17 @@ add_executable(bm_cq target_include_directories(bm_cq PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11535,14 +12221,17 @@ add_executable(bm_cq_multiple_threads target_include_directories(bm_cq_multiple_threads PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11580,14 +12269,17 @@ add_executable(bm_error target_include_directories(bm_error PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11625,14 +12317,17 @@ add_executable(bm_fullstack_streaming_ping_pong target_include_directories(bm_fullstack_streaming_ping_pong PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11670,14 +12365,17 @@ add_executable(bm_fullstack_streaming_pump target_include_directories(bm_fullstack_streaming_pump PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11715,14 +12413,17 @@ add_executable(bm_fullstack_trickle target_include_directories(bm_fullstack_trickle PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11760,14 +12461,17 @@ add_executable(bm_fullstack_unary_ping_pong target_include_directories(bm_fullstack_unary_ping_pong PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11805,14 +12509,17 @@ add_executable(bm_metadata target_include_directories(bm_metadata PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11850,14 +12557,17 @@ add_executable(bm_pollset target_include_directories(bm_pollset PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11895,14 +12605,17 @@ add_executable(bm_threadpool target_include_directories(bm_threadpool PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11940,14 +12653,17 @@ add_executable(bm_timer target_include_directories(bm_timer PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -11984,14 +12700,17 @@ add_executable(byte_stream_test target_include_directories(byte_stream_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12022,14 +12741,17 @@ add_executable(channel_arguments_test target_include_directories(channel_arguments_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12060,14 +12782,17 @@ add_executable(channel_filter_test target_include_directories(channel_filter_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12105,14 +12830,17 @@ protobuf_generate_grpc_cpp( target_include_directories(channel_trace_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12145,14 +12873,17 @@ add_executable(channelz_registry_test target_include_directories(channelz_registry_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12192,14 +12923,17 @@ protobuf_generate_grpc_cpp( target_include_directories(channelz_service_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12240,14 +12974,17 @@ protobuf_generate_grpc_cpp( target_include_directories(channelz_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12280,14 +13017,17 @@ add_executable(check_gcp_environment_linux_test target_include_directories(check_gcp_environment_linux_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12317,14 +13057,17 @@ add_executable(check_gcp_environment_windows_test target_include_directories(check_gcp_environment_windows_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12354,14 +13097,17 @@ add_executable(chttp2_settings_timeout_test target_include_directories(chttp2_settings_timeout_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12392,14 +13138,17 @@ add_executable(cli_call_test target_include_directories(cli_call_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12434,14 +13183,17 @@ add_executable(client_callback_end2end_test target_include_directories(client_callback_end2end_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12481,14 +13233,17 @@ protobuf_generate_grpc_cpp( target_include_directories(client_channel_stress_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12522,14 +13277,17 @@ add_executable(client_crash_test target_include_directories(client_crash_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12563,14 +13321,17 @@ add_executable(client_crash_test_server target_include_directories(client_crash_test_server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12605,14 +13366,17 @@ add_executable(client_interceptors_end2end_test target_include_directories(client_interceptors_end2end_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12645,14 +13409,17 @@ add_executable(client_lb_end2end_test target_include_directories(client_lb_end2end_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12734,14 +13501,17 @@ protobuf_generate_grpc_cpp( target_include_directories(codegen_test_full PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12823,14 +13593,17 @@ protobuf_generate_grpc_cpp( target_include_directories(codegen_test_minimal PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12861,14 +13634,17 @@ add_executable(context_list_test target_include_directories(context_list_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12899,14 +13675,17 @@ add_executable(credentials_test target_include_directories(credentials_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12937,14 +13716,17 @@ add_executable(cxx_byte_buffer_test target_include_directories(cxx_byte_buffer_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -12976,14 +13758,17 @@ add_executable(cxx_slice_test target_include_directories(cxx_slice_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -13015,14 +13800,17 @@ add_executable(cxx_string_ref_test target_include_directories(cxx_string_ref_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -13052,14 +13840,17 @@ add_executable(cxx_time_test target_include_directories(cxx_time_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -13091,14 +13882,17 @@ add_executable(delegating_channel_test target_include_directories(delegating_channel_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -13132,14 +13926,17 @@ add_executable(end2end_test target_include_directories(end2end_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -13179,14 +13976,17 @@ protobuf_generate_grpc_cpp( target_include_directories(error_details_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -13216,14 +14016,17 @@ add_executable(exception_test target_include_directories(exception_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -13256,14 +14059,17 @@ add_executable(filter_end2end_test target_include_directories(filter_end2end_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -13296,14 +14102,17 @@ add_executable(generic_end2end_test target_include_directories(generic_end2end_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -13336,14 +14145,17 @@ add_executable(global_config_env_test target_include_directories(global_config_env_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -13373,14 +14185,17 @@ add_executable(global_config_test target_include_directories(global_config_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -13417,14 +14232,17 @@ protobuf_generate_grpc_cpp( target_include_directories(golden_file_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -13456,14 +14274,17 @@ add_executable(grpc_alts_credentials_options_test target_include_directories(grpc_alts_credentials_options_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -13493,14 +14314,17 @@ add_executable(grpc_cli target_include_directories(grpc_cli PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -13534,14 +14358,17 @@ add_executable(grpc_core_map_test target_include_directories(grpc_core_map_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -13571,14 +14398,17 @@ add_executable(grpc_cpp_plugin target_include_directories(grpc_cpp_plugin PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTO_GENS_DIR} ) @@ -13610,14 +14440,17 @@ add_executable(grpc_csharp_plugin target_include_directories(grpc_csharp_plugin PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTO_GENS_DIR} ) @@ -13651,14 +14484,17 @@ add_executable(grpc_fetch_oauth2 target_include_directories(grpc_fetch_oauth2 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -13690,14 +14526,17 @@ add_executable(grpc_linux_system_roots_test target_include_directories(grpc_linux_system_roots_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -13726,14 +14565,17 @@ add_executable(grpc_node_plugin target_include_directories(grpc_node_plugin PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTO_GENS_DIR} ) @@ -13765,14 +14607,17 @@ add_executable(grpc_objective_c_plugin target_include_directories(grpc_objective_c_plugin PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTO_GENS_DIR} ) @@ -13804,14 +14649,17 @@ add_executable(grpc_php_plugin target_include_directories(grpc_php_plugin PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTO_GENS_DIR} ) @@ -13843,14 +14691,17 @@ add_executable(grpc_python_plugin target_include_directories(grpc_python_plugin PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTO_GENS_DIR} ) @@ -13882,14 +14733,17 @@ add_executable(grpc_ruby_plugin target_include_directories(grpc_ruby_plugin PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTO_GENS_DIR} ) @@ -13937,14 +14791,17 @@ protobuf_generate_grpc_cpp( target_include_directories(grpc_tool_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -13987,14 +14844,17 @@ protobuf_generate_grpc_cpp( target_include_directories(grpclb_api_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14033,14 +14893,17 @@ protobuf_generate_grpc_cpp( target_include_directories(grpclb_end2end_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14095,14 +14958,17 @@ protobuf_generate_grpc_cpp( target_include_directories(grpclb_fallback_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14137,14 +15003,17 @@ add_executable(h2_ssl_cert_test target_include_directories(h2_ssl_cert_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14176,14 +15045,17 @@ add_executable(h2_ssl_session_reuse_test target_include_directories(h2_ssl_session_reuse_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14215,14 +15087,17 @@ add_executable(health_service_end2end_test target_include_directories(health_service_end2end_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14255,14 +15130,17 @@ add_executable(http2_client target_include_directories(http2_client PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14297,14 +15175,17 @@ add_executable(hybrid_end2end_test target_include_directories(hybrid_end2end_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14337,14 +15218,17 @@ add_executable(inlined_vector_test target_include_directories(inlined_vector_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14377,14 +15261,17 @@ add_executable(inproc_sync_unary_ping_pong_test target_include_directories(inproc_sync_unary_ping_pong_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14421,14 +15308,17 @@ add_executable(interop_client target_include_directories(interop_client PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14465,14 +15355,17 @@ add_executable(interop_server target_include_directories(interop_server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14511,14 +15404,17 @@ add_executable(interop_test target_include_directories(interop_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14552,14 +15448,17 @@ add_executable(json_run_localhost target_include_directories(json_run_localhost PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14594,14 +15493,17 @@ add_executable(memory_test target_include_directories(memory_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14633,14 +15535,17 @@ add_executable(message_allocator_end2end_test target_include_directories(message_allocator_end2end_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14680,14 +15585,17 @@ protobuf_generate_grpc_cpp( target_include_directories(metrics_client PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14719,14 +15627,17 @@ add_executable(mock_test target_include_directories(mock_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14759,14 +15670,17 @@ add_executable(nonblocking_test target_include_directories(nonblocking_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14799,14 +15713,17 @@ add_executable(noop-benchmark target_include_directories(noop-benchmark PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14835,14 +15752,17 @@ add_executable(optional_test target_include_directories(optional_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14874,14 +15794,17 @@ add_executable(orphanable_test target_include_directories(orphanable_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14913,14 +15836,17 @@ add_executable(port_sharing_end2end_test target_include_directories(port_sharing_end2end_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14954,14 +15880,17 @@ add_executable(proto_server_reflection_test target_include_directories(proto_server_reflection_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -14996,14 +15925,17 @@ add_executable(proto_utils_test target_include_directories(proto_utils_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15034,14 +15966,17 @@ add_executable(qps_interarrival_test target_include_directories(qps_interarrival_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15077,14 +16012,17 @@ add_executable(qps_json_driver target_include_directories(qps_json_driver PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15121,14 +16059,17 @@ add_executable(qps_openloop_test target_include_directories(qps_openloop_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15165,14 +16106,17 @@ add_executable(qps_worker target_include_directories(qps_worker PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15208,14 +16152,17 @@ add_executable(raw_end2end_test target_include_directories(raw_end2end_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15269,14 +16216,17 @@ protobuf_generate_grpc_cpp( target_include_directories(reconnect_interop_client PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15331,14 +16281,17 @@ protobuf_generate_grpc_cpp( target_include_directories(reconnect_interop_server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15374,14 +16327,17 @@ add_executable(ref_counted_ptr_test target_include_directories(ref_counted_ptr_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15413,14 +16369,17 @@ add_executable(ref_counted_test target_include_directories(ref_counted_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15452,14 +16411,17 @@ add_executable(retry_throttle_test target_include_directories(retry_throttle_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15490,14 +16452,17 @@ add_executable(secure_auth_context_test target_include_directories(secure_auth_context_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15531,14 +16496,17 @@ add_executable(secure_sync_unary_ping_pong_test target_include_directories(secure_sync_unary_ping_pong_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15575,14 +16543,17 @@ add_executable(server_builder_plugin_test target_include_directories(server_builder_plugin_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15629,14 +16600,17 @@ protobuf_generate_grpc_cpp( target_include_directories(server_builder_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15684,14 +16658,17 @@ protobuf_generate_grpc_cpp( target_include_directories(server_builder_with_socket_mutator_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15725,14 +16702,17 @@ add_executable(server_context_test_spouse_test target_include_directories(server_context_test_spouse_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15765,14 +16745,17 @@ add_executable(server_crash_test target_include_directories(server_crash_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15806,14 +16789,17 @@ add_executable(server_crash_test_client target_include_directories(server_crash_test_client PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15847,14 +16833,17 @@ add_executable(server_early_return_test target_include_directories(server_early_return_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15888,14 +16877,17 @@ add_executable(server_interceptors_end2end_test target_include_directories(server_interceptors_end2end_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15942,14 +16934,17 @@ protobuf_generate_grpc_cpp( target_include_directories(server_request_call_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -15982,14 +16977,17 @@ add_executable(service_config_end2end_test target_include_directories(service_config_end2end_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16022,14 +17020,17 @@ add_executable(service_config_test target_include_directories(service_config_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16061,14 +17062,17 @@ add_executable(shutdown_test target_include_directories(shutdown_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16101,14 +17105,17 @@ add_executable(slice_hash_table_test target_include_directories(slice_hash_table_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16139,14 +17146,17 @@ add_executable(slice_weak_hash_table_test target_include_directories(slice_weak_hash_table_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16177,14 +17187,17 @@ add_executable(stats_test target_include_directories(stats_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16216,14 +17229,17 @@ add_executable(status_metadata_test target_include_directories(status_metadata_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16252,14 +17268,17 @@ add_executable(status_util_test target_include_directories(status_util_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16289,14 +17308,17 @@ add_executable(streaming_throughput_test target_include_directories(streaming_throughput_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16361,14 +17383,17 @@ protobuf_generate_grpc_cpp( target_include_directories(stress_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16402,14 +17427,17 @@ add_executable(string_view_test target_include_directories(string_view_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16441,14 +17469,17 @@ add_executable(thread_manager_test target_include_directories(thread_manager_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16480,14 +17511,17 @@ add_executable(thread_stress_test target_include_directories(thread_stress_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16521,14 +17555,17 @@ add_executable(time_change_test target_include_directories(time_change_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16562,14 +17599,17 @@ add_executable(transport_pid_controller_test target_include_directories(transport_pid_controller_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16602,14 +17642,17 @@ add_executable(transport_security_common_api_test target_include_directories(transport_security_common_api_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16641,14 +17684,17 @@ add_executable(writes_per_rpc_test target_include_directories(writes_per_rpc_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16689,14 +17735,17 @@ protobuf_generate_grpc_cpp( target_include_directories(xds_end2end_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16727,14 +17776,17 @@ add_executable(public_headers_must_be_c89 target_include_directories(public_headers_must_be_c89 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(public_headers_must_be_c89 @@ -16754,14 +17806,17 @@ add_executable(gen_hpack_tables target_include_directories(gen_hpack_tables PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(gen_hpack_tables @@ -16780,14 +17835,17 @@ add_executable(gen_legal_metadata_characters target_include_directories(gen_legal_metadata_characters PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(gen_legal_metadata_characters @@ -16804,14 +17862,17 @@ add_executable(gen_percent_encoding_tables target_include_directories(gen_percent_encoding_tables PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(gen_percent_encoding_tables @@ -16831,14 +17892,17 @@ add_executable(bad_streaming_id_bad_client_test target_include_directories(bad_streaming_id_bad_client_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16871,14 +17935,17 @@ add_executable(badreq_bad_client_test target_include_directories(badreq_bad_client_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16911,14 +17978,17 @@ add_executable(connection_prefix_bad_client_test target_include_directories(connection_prefix_bad_client_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16951,14 +18021,17 @@ add_executable(duplicate_header_bad_client_test target_include_directories(duplicate_header_bad_client_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -16991,14 +18064,17 @@ add_executable(head_of_line_blocking_bad_client_test target_include_directories(head_of_line_blocking_bad_client_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -17031,14 +18107,17 @@ add_executable(headers_bad_client_test target_include_directories(headers_bad_client_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -17071,14 +18150,17 @@ add_executable(initial_settings_frame_bad_client_test target_include_directories(initial_settings_frame_bad_client_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -17111,14 +18193,17 @@ add_executable(large_metadata_bad_client_test target_include_directories(large_metadata_bad_client_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -17151,14 +18236,17 @@ add_executable(out_of_bounds_bad_client_test target_include_directories(out_of_bounds_bad_client_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -17191,14 +18279,17 @@ add_executable(server_registered_method_bad_client_test target_include_directories(server_registered_method_bad_client_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -17231,14 +18322,17 @@ add_executable(simple_request_bad_client_test target_include_directories(simple_request_bad_client_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -17271,14 +18365,17 @@ add_executable(unknown_frame_bad_client_test target_include_directories(unknown_frame_bad_client_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -17311,14 +18408,17 @@ add_executable(window_overflow_bad_client_test target_include_directories(window_overflow_bad_client_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -17350,14 +18450,17 @@ add_executable(bad_ssl_cert_server target_include_directories(bad_ssl_cert_server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(bad_ssl_cert_server @@ -17387,14 +18490,17 @@ add_executable(bad_ssl_cert_test target_include_directories(bad_ssl_cert_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(bad_ssl_cert_test @@ -17422,14 +18528,17 @@ add_executable(h2_census_test target_include_directories(h2_census_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_census_test @@ -17457,14 +18566,17 @@ add_executable(h2_compress_test target_include_directories(h2_compress_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_compress_test @@ -17492,14 +18604,17 @@ add_executable(h2_fakesec_test target_include_directories(h2_fakesec_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_fakesec_test @@ -17528,14 +18643,17 @@ add_executable(h2_fd_test target_include_directories(h2_fd_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_fd_test @@ -17564,14 +18682,17 @@ add_executable(h2_full_test target_include_directories(h2_full_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_full_test @@ -17600,14 +18721,17 @@ add_executable(h2_full+pipe_test target_include_directories(h2_full+pipe_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_full+pipe_test @@ -17636,14 +18760,17 @@ add_executable(h2_full+trace_test target_include_directories(h2_full+trace_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_full+trace_test @@ -17671,14 +18798,17 @@ add_executable(h2_full+workarounds_test target_include_directories(h2_full+workarounds_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_full+workarounds_test @@ -17706,14 +18836,17 @@ add_executable(h2_http_proxy_test target_include_directories(h2_http_proxy_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_http_proxy_test @@ -17742,14 +18875,17 @@ add_executable(h2_local_ipv4_test target_include_directories(h2_local_ipv4_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_local_ipv4_test @@ -17779,14 +18915,17 @@ add_executable(h2_local_ipv6_test target_include_directories(h2_local_ipv6_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_local_ipv6_test @@ -17816,14 +18955,17 @@ add_executable(h2_local_uds_test target_include_directories(h2_local_uds_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_local_uds_test @@ -17852,14 +18994,17 @@ add_executable(h2_oauth2_test target_include_directories(h2_oauth2_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_oauth2_test @@ -17887,14 +19032,17 @@ add_executable(h2_proxy_test target_include_directories(h2_proxy_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_proxy_test @@ -17922,14 +19070,17 @@ add_executable(h2_sockpair_test target_include_directories(h2_sockpair_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_sockpair_test @@ -17957,14 +19108,17 @@ add_executable(h2_sockpair+trace_test target_include_directories(h2_sockpair+trace_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_sockpair+trace_test @@ -17992,14 +19146,17 @@ add_executable(h2_sockpair_1byte_test target_include_directories(h2_sockpair_1byte_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_sockpair_1byte_test @@ -18027,14 +19184,17 @@ add_executable(h2_spiffe_test target_include_directories(h2_spiffe_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_spiffe_test @@ -18062,14 +19222,17 @@ add_executable(h2_ssl_test target_include_directories(h2_ssl_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_ssl_test @@ -18097,14 +19260,17 @@ add_executable(h2_ssl_cred_reload_test target_include_directories(h2_ssl_cred_reload_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_ssl_cred_reload_test @@ -18132,14 +19298,17 @@ add_executable(h2_ssl_proxy_test target_include_directories(h2_ssl_proxy_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_ssl_proxy_test @@ -18168,14 +19337,17 @@ add_executable(h2_uds_test target_include_directories(h2_uds_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_uds_test @@ -18204,14 +19376,17 @@ add_executable(inproc_test target_include_directories(inproc_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(inproc_test @@ -18239,14 +19414,17 @@ add_executable(h2_census_nosec_test target_include_directories(h2_census_nosec_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_census_nosec_test @@ -18274,14 +19452,17 @@ add_executable(h2_compress_nosec_test target_include_directories(h2_compress_nosec_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_compress_nosec_test @@ -18310,14 +19491,17 @@ add_executable(h2_fd_nosec_test target_include_directories(h2_fd_nosec_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_fd_nosec_test @@ -18346,14 +19530,17 @@ add_executable(h2_full_nosec_test target_include_directories(h2_full_nosec_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_full_nosec_test @@ -18382,14 +19569,17 @@ add_executable(h2_full+pipe_nosec_test target_include_directories(h2_full+pipe_nosec_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_full+pipe_nosec_test @@ -18418,14 +19608,17 @@ add_executable(h2_full+trace_nosec_test target_include_directories(h2_full+trace_nosec_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_full+trace_nosec_test @@ -18453,14 +19646,17 @@ add_executable(h2_full+workarounds_nosec_test target_include_directories(h2_full+workarounds_nosec_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_full+workarounds_nosec_test @@ -18488,14 +19684,17 @@ add_executable(h2_http_proxy_nosec_test target_include_directories(h2_http_proxy_nosec_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_http_proxy_nosec_test @@ -18523,14 +19722,17 @@ add_executable(h2_proxy_nosec_test target_include_directories(h2_proxy_nosec_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_proxy_nosec_test @@ -18558,14 +19760,17 @@ add_executable(h2_sockpair_nosec_test target_include_directories(h2_sockpair_nosec_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_sockpair_nosec_test @@ -18593,14 +19798,17 @@ add_executable(h2_sockpair+trace_nosec_test target_include_directories(h2_sockpair+trace_nosec_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_sockpair+trace_nosec_test @@ -18628,14 +19836,17 @@ add_executable(h2_sockpair_1byte_nosec_test target_include_directories(h2_sockpair_1byte_nosec_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_sockpair_1byte_nosec_test @@ -18664,14 +19875,17 @@ add_executable(h2_uds_nosec_test target_include_directories(h2_uds_nosec_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(h2_uds_nosec_test @@ -18702,14 +19916,17 @@ add_executable(resolver_component_test_unsecure target_include_directories(resolver_component_test_unsecure PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -18744,14 +19961,17 @@ add_executable(resolver_component_test target_include_directories(resolver_component_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -18787,14 +20007,17 @@ add_executable(resolver_component_tests_runner_invoker_unsecure target_include_directories(resolver_component_tests_runner_invoker_unsecure PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -18830,14 +20053,17 @@ add_executable(resolver_component_tests_runner_invoker target_include_directories(resolver_component_tests_runner_invoker PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -18872,14 +20098,17 @@ add_executable(address_sorting_test_unsecure target_include_directories(address_sorting_test_unsecure PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -18913,14 +20142,17 @@ add_executable(address_sorting_test target_include_directories(address_sorting_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -18954,14 +20186,17 @@ add_executable(cancel_ares_query_test target_include_directories(cancel_ares_query_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest PRIVATE third_party/googletest/googlemock/include @@ -18995,14 +20230,17 @@ add_executable(alts_credentials_fuzzer_one_entry target_include_directories(alts_credentials_fuzzer_one_entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(alts_credentials_fuzzer_one_entry @@ -19030,14 +20268,17 @@ add_executable(api_fuzzer_one_entry target_include_directories(api_fuzzer_one_entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(api_fuzzer_one_entry @@ -19065,14 +20306,17 @@ add_executable(client_fuzzer_one_entry target_include_directories(client_fuzzer_one_entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(client_fuzzer_one_entry @@ -19100,14 +20344,17 @@ add_executable(hpack_parser_fuzzer_test_one_entry target_include_directories(hpack_parser_fuzzer_test_one_entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(hpack_parser_fuzzer_test_one_entry @@ -19135,14 +20382,17 @@ add_executable(http_request_fuzzer_test_one_entry target_include_directories(http_request_fuzzer_test_one_entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(http_request_fuzzer_test_one_entry @@ -19170,14 +20420,17 @@ add_executable(http_response_fuzzer_test_one_entry target_include_directories(http_response_fuzzer_test_one_entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(http_response_fuzzer_test_one_entry @@ -19205,14 +20458,17 @@ add_executable(json_fuzzer_test_one_entry target_include_directories(json_fuzzer_test_one_entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(json_fuzzer_test_one_entry @@ -19240,14 +20496,17 @@ add_executable(nanopb_fuzzer_response_test_one_entry target_include_directories(nanopb_fuzzer_response_test_one_entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(nanopb_fuzzer_response_test_one_entry @@ -19275,14 +20534,17 @@ add_executable(nanopb_fuzzer_serverlist_test_one_entry target_include_directories(nanopb_fuzzer_serverlist_test_one_entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(nanopb_fuzzer_serverlist_test_one_entry @@ -19310,14 +20572,17 @@ add_executable(percent_decode_fuzzer_one_entry target_include_directories(percent_decode_fuzzer_one_entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(percent_decode_fuzzer_one_entry @@ -19345,14 +20610,17 @@ add_executable(percent_encode_fuzzer_one_entry target_include_directories(percent_encode_fuzzer_one_entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(percent_encode_fuzzer_one_entry @@ -19380,14 +20648,17 @@ add_executable(server_fuzzer_one_entry target_include_directories(server_fuzzer_one_entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(server_fuzzer_one_entry @@ -19415,14 +20686,17 @@ add_executable(ssl_server_fuzzer_one_entry target_include_directories(ssl_server_fuzzer_one_entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(ssl_server_fuzzer_one_entry @@ -19450,14 +20724,17 @@ add_executable(uri_fuzzer_test_one_entry target_include_directories(uri_fuzzer_test_one_entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) target_link_libraries(uri_fuzzer_test_one_entry diff --git a/Makefile b/Makefile index fd9d5521a17..e77c5d71089 100644 --- a/Makefile +++ b/Makefile @@ -306,12 +306,6 @@ ifeq ($(HAS_WORKING_NO_CXX14_COMPAT),true) W_NO_CXX14_COMPAT=-Wno-c++14-compat endif -CHECK_SHADOW_WORKS_CMD = $(CC) -std=c99 -Werror -Wshadow -o $(TMPOUT) -c test/build/shadow.c -HAS_WORKING_SHADOW = $(shell $(CHECK_SHADOW_WORKS_CMD) 2> /dev/null && echo true || echo false) -ifeq ($(HAS_WORKING_SHADOW),true) -W_SHADOW=-Wshadow -NO_W_SHADOW=-Wno-shadow -endif CHECK_EXTRA_SEMI_WORKS_CMD = $(CC) -std=c99 -Werror -Wextra-semi -o $(TMPOUT) -c test/build/extra-semi.c HAS_WORKING_EXTRA_SEMI = $(shell $(CHECK_EXTRA_SEMI_WORKS_CMD) 2> /dev/null && echo true || echo false) ifeq ($(HAS_WORKING_EXTRA_SEMI),true) @@ -347,14 +341,14 @@ HOST_CXX ?= $(CXX) HOST_LD ?= $(LD) HOST_LDXX ?= $(LDXX) -CFLAGS += -std=c99 -Wsign-conversion -Wconversion $(W_SHADOW) $(W_EXTRA_SEMI) +CFLAGS += -std=c99 $(W_EXTRA_SEMI) CXXFLAGS += -std=c++11 ifeq ($(SYSTEM),Darwin) CXXFLAGS += -stdlib=libc++ LDFLAGS += -framework CoreFoundation endif CXXFLAGS += -Wnon-virtual-dtor -CPPFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter -DOSATOMIC_USE_INLINED=1 -Wno-deprecated-declarations -Ithird_party/nanopb -DPB_FIELD_32BIT +CPPFLAGS += -g -Wall -Wextra -Werror -Wno-unknown-warning-option -Wno-long-long -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-maybe-uninitialized -DPB_FIELD_32BIT -DOSATOMIC_USE_INLINED=1 -Ithird_party/nanopb -Ithird_party/upb -Ithird_party/upb/generated_for_cmake -Isrc/core/ext/upb-generated COREFLAGS += -fno-rtti -fno-exceptions LDFLAGS += -g @@ -370,7 +364,7 @@ CPPFLAGS += -fPIC LDFLAGS += -fPIC endif -INCLUDES = . include $(GENDIR) third_party/upb third_party/upb/generated_for_cmake src/core/ext/upb-generated +INCLUDES = . include $(GENDIR) LDFLAGS += -Llibs/$(CONFIG) ifeq ($(SYSTEM),Darwin) @@ -1416,7 +1410,7 @@ plugins: $(PROTOC_PLUGINS) privatelibs: privatelibs_c privatelibs_cxx -privatelibs_c: $(LIBDIR)/$(CONFIG)/libalts_test_util.a $(LIBDIR)/$(CONFIG)/libcxxabi.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libreconnect_server.a $(LIBDIR)/$(CONFIG)/libtest_tcp_server.a $(LIBDIR)/$(CONFIG)/libupb.a $(LIBDIR)/$(CONFIG)/libz.a $(LIBDIR)/$(CONFIG)/libares.a $(LIBDIR)/$(CONFIG)/libbad_ssl_test_server.a $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a +privatelibs_c: $(LIBDIR)/$(CONFIG)/libalts_test_util.a $(LIBDIR)/$(CONFIG)/libcxxabi.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libreconnect_server.a $(LIBDIR)/$(CONFIG)/libtest_tcp_server.a $(LIBDIR)/$(CONFIG)/libz.a $(LIBDIR)/$(CONFIG)/libares.a $(LIBDIR)/$(CONFIG)/libbad_ssl_test_server.a $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a pc_c: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc pc_c_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc @@ -3762,7 +3756,17 @@ LIBGRPC_SRC = \ third_party/nanopb/pb_common.c \ third_party/nanopb/pb_decode.c \ third_party/nanopb/pb_encode.c \ + src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c \ + src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c \ + src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c \ src/core/tsi/transport_security.cc \ + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ + third_party/upb/upb/decode.c \ + third_party/upb/upb/encode.c \ + third_party/upb/upb/msg.c \ + third_party/upb/upb/port.c \ + third_party/upb/upb/table.c \ + third_party/upb/upb/upb.c \ src/core/ext/transport/chttp2/client/insecure/channel_create.cc \ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \ src/core/ext/transport/chttp2/client/authority.cc \ @@ -3794,6 +3798,7 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ src/core/ext/filters/client_channel/health/health.pb.c \ src/core/tsi/fake_transport_security.cc \ src/core/tsi/local_transport_security.cc \ @@ -3813,6 +3818,13 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \ + src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ + src/core/ext/upb-generated/google/protobuf/any.upb.c \ + src/core/ext/upb-generated/google/protobuf/duration.upb.c \ + src/core/ext/upb-generated/google/protobuf/empty.upb.c \ + src/core/ext/upb-generated/google/protobuf/struct.upb.c \ + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c \ @@ -4155,6 +4167,14 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ + third_party/upb/upb/decode.c \ + third_party/upb/upb/encode.c \ + third_party/upb/upb/msg.c \ + third_party/upb/upb/port.c \ + third_party/upb/upb/table.c \ + third_party/upb/upb/upb.c \ src/core/ext/filters/client_channel/health/health.pb.c \ third_party/nanopb/pb_common.c \ third_party/nanopb/pb_decode.c \ @@ -4226,6 +4246,9 @@ LIBGRPC_CRONET_SRC = \ src/core/tsi/alts/handshaker/altscontext.pb.c \ src/core/tsi/alts/handshaker/handshaker.pb.c \ src/core/tsi/alts/handshaker/transport_security_common.pb.c \ + src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c \ + src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c \ + src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c \ src/core/tsi/transport_security.cc \ src/core/ext/transport/chttp2/client/insecure/channel_create.cc \ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \ @@ -4534,6 +4557,14 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ + third_party/upb/upb/decode.c \ + third_party/upb/upb/encode.c \ + third_party/upb/upb/msg.c \ + third_party/upb/upb/port.c \ + third_party/upb/upb/table.c \ + third_party/upb/upb/upb.c \ src/core/ext/filters/client_channel/health/health.pb.c \ third_party/nanopb/pb_common.c \ third_party/nanopb/pb_decode.c \ @@ -4853,6 +4884,14 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ + third_party/upb/upb/decode.c \ + third_party/upb/upb/encode.c \ + third_party/upb/upb/msg.c \ + third_party/upb/upb/port.c \ + third_party/upb/upb/table.c \ + third_party/upb/upb/upb.c \ src/core/ext/filters/client_channel/health/health.pb.c \ third_party/nanopb/pb_common.c \ third_party/nanopb/pb_decode.c \ @@ -5170,6 +5209,14 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ + third_party/upb/upb/decode.c \ + third_party/upb/upb/encode.c \ + third_party/upb/upb/msg.c \ + third_party/upb/upb/port.c \ + third_party/upb/upb/table.c \ + third_party/upb/upb/upb.c \ src/core/ext/filters/client_channel/health/health.pb.c \ third_party/nanopb/pb_common.c \ third_party/nanopb/pb_decode.c \ @@ -5195,6 +5242,13 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \ + src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ + src/core/ext/upb-generated/google/protobuf/any.upb.c \ + src/core/ext/upb-generated/google/protobuf/duration.upb.c \ + src/core/ext/upb-generated/google/protobuf/empty.upb.c \ + src/core/ext/upb-generated/google/protobuf/struct.upb.c \ + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ @@ -5510,6 +5564,14 @@ LIBGRPC++_SRC = \ src/cpp/util/status.cc \ src/cpp/util/string_ref.cc \ src/cpp/util/time_cc.cc \ + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ + third_party/upb/upb/decode.c \ + third_party/upb/upb/encode.c \ + third_party/upb/upb/msg.c \ + third_party/upb/upb/port.c \ + third_party/upb/upb/table.c \ + third_party/upb/upb/upb.c \ src/core/ext/filters/client_channel/health/health.pb.c \ third_party/nanopb/pb_common.c \ third_party/nanopb/pb_decode.c \ @@ -6538,6 +6600,14 @@ LIBGRPC++_UNSECURE_SRC = \ src/cpp/util/status.cc \ src/cpp/util/string_ref.cc \ src/cpp/util/time_cc.cc \ + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ + third_party/upb/upb/decode.c \ + third_party/upb/upb/encode.c \ + third_party/upb/upb/msg.c \ + third_party/upb/upb/port.c \ + third_party/upb/upb/table.c \ + third_party/upb/upb/upb.c \ src/core/ext/filters/client_channel/health/health.pb.c \ third_party/nanopb/pb_common.c \ third_party/nanopb/pb_decode.c \ @@ -7903,41 +7973,6 @@ ifneq ($(NO_DEPS),true) endif -LIBUPB_SRC = \ - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ - third_party/upb/upb/decode.c \ - third_party/upb/upb/def.c \ - third_party/upb/upb/encode.c \ - third_party/upb/upb/handlers.c \ - third_party/upb/upb/msg.c \ - third_party/upb/upb/msgfactory.c \ - third_party/upb/upb/sink.c \ - third_party/upb/upb/table.c \ - third_party/upb/upb/upb.c \ - -PUBLIC_HEADERS_C += \ - -LIBUPB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBUPB_SRC)))) - -$(LIBUPB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers - -$(LIBDIR)/$(CONFIG)/libupb.a: $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBUPB_OBJS) - $(E) "[AR] Creating $@" - $(Q) mkdir -p `dirname $@` - $(Q) rm -f $(LIBDIR)/$(CONFIG)/libupb.a - $(Q) $(AR) $(AROPTS) $(LIBDIR)/$(CONFIG)/libupb.a $(LIBUPB_OBJS) -ifeq ($(SYSTEM),Darwin) - $(Q) ranlib -no_warning_for_no_symbols $(LIBDIR)/$(CONFIG)/libupb.a -endif - - - - -ifneq ($(NO_DEPS),true) --include $(LIBUPB_OBJS:.o=.dep) -endif - - LIBZ_SRC = \ third_party/zlib/adler32.c \ third_party/zlib/compress.c \ @@ -22422,6 +22457,9 @@ src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc: $(OPENSSL_ src/core/ext/transport/cronet/plugin_registry/grpc_cronet_plugin_registry.cc: $(OPENSSL_DEP) src/core/ext/transport/cronet/transport/cronet_api_dummy.cc: $(OPENSSL_DEP) src/core/ext/transport/cronet/transport/cronet_transport.cc: $(OPENSSL_DEP) +src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c: $(OPENSSL_DEP) +src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c: $(OPENSSL_DEP) +src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c: $(OPENSSL_DEP) src/core/lib/http/httpcli_security_connector.cc: $(OPENSSL_DEP) src/core/lib/security/context/security_context.cc: $(OPENSSL_DEP) src/core/lib/security/credentials/alts/alts_credentials.cc: $(OPENSSL_DEP) diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 9e967d8fa9a..7111b5b8c34 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -104,7 +104,10 @@ def grpc_cc_library( visibility = visibility, testonly = testonly, linkopts = linkopts, - includes = ["include"] + if_not_windows(["src/core/ext/upb-generated"]), + includes = [ + "include", + "src/core/ext/upb-generated", # Once upb code-gen issue is resolved, remove this. + ], alwayslink = alwayslink, data = data, tags = tags, diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index cce2f88fe87..726dc21b44d 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -206,9 +206,9 @@ def grpc_deps(): if "upb" not in native.existing_rules(): http_archive( name = "upb", - sha256 = "73deded75313f80779eba109c32f3c59a813addf5064bf6e7c213fca1e7d8e32", - strip_prefix = "upb-423ea5ca9ce8da69611e6e95559efcb3a1ba8ad8", - url = "https://github.com/protocolbuffers/upb/archive/423ea5ca9ce8da69611e6e95559efcb3a1ba8ad8.tar.gz", + sha256 = "6e3c81c9e6c609d918b399110a88d10efeab73b2c8eb3131de15658b1ec86141", + strip_prefix = "upb-b70f68269a7d51c5ce372a93742bf6960215ffef", + url = "https://github.com/protocolbuffers/upb/archive/b70f68269a7d51c5ce372a93742bf6960215ffef.tar.gz", ) if "envoy_api" not in native.existing_rules(): http_archive( diff --git a/build.yaml b/build.yaml index f8d5458db16..2e81fae5687 100644 --- a/build.yaml +++ b/build.yaml @@ -73,13 +73,13 @@ filegroups: - grpc_shadow_boringssl - name: alts_upb headers: - - src/core/ext/upb-generated/altscontext.upb.h - - src/core/ext/upb-generated/handshaker.upb.h - - src/core/ext/upb-generated/transport_security_common.upb.h + - src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h + - src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h + - src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h src: - - src/core/ext/upb-generated/altscontext.upb.c - - src/core/ext/upb-generated/handshaker.upb.c - - src/core/ext/upb-generated/transport_security_common.upb.c + - src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c + - src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c + - src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c - name: alts_util public_headers: - include/grpc/grpc_security.h @@ -104,9 +104,11 @@ filegroups: - src/core/tsi/alts/handshaker/transport_security_common_api.cc uses: - alts_proto + - alts_upb - grpc_base - - tsi_interface - nanopb + - tsi_interface + - upb - name: census public_headers: - include/grpc/census.h @@ -124,7 +126,6 @@ filegroups: - name: google_api_upb headers: - src/core/ext/upb-generated/google/protobuf/any.upb.h - - src/core/ext/upb-generated/google/protobuf/descriptor.upb.h - src/core/ext/upb-generated/google/protobuf/duration.upb.h - src/core/ext/upb-generated/google/protobuf/empty.upb.h - src/core/ext/upb-generated/google/protobuf/struct.upb.h @@ -132,7 +133,6 @@ filegroups: - src/core/ext/upb-generated/google/protobuf/wrappers.upb.h src: - src/core/ext/upb-generated/google/protobuf/any.upb.c - - src/core/ext/upb-generated/google/protobuf/descriptor.upb.c - src/core/ext/upb-generated/google/protobuf/duration.upb.c - src/core/ext/upb-generated/google/protobuf/empty.upb.c - src/core/ext/upb-generated/google/protobuf/struct.upb.c @@ -660,6 +660,7 @@ filegroups: uses: - grpc_base - grpc_deadline_filter + - grpc_health_upb - health_proto - name: grpc_client_idle_filter src: @@ -689,9 +690,11 @@ filegroups: - grpc_base - name: grpc_health_upb headers: - - src/core/ext/upb-generated/grpc/health/v1/health.upb.c + - src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h src: - - src/core/ext/upb-generated/grpc/health/v1/health.upb.h + - src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c + uses: + - upb - name: grpc_http_filters headers: - src/core/ext/filters/http/client/http_client_filter.h @@ -722,9 +725,11 @@ filegroups: uses: - grpc_base - grpc_client_channel - - nanopb + - grpc_lb_upb - grpc_resolver_fake - grpclb_proto + - nanopb + - upb - name: grpc_lb_policy_grpclb_secure headers: - src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h @@ -741,11 +746,13 @@ filegroups: plugin: grpc_lb_policy_grpclb uses: - grpc_base - - grpc_secure - grpc_client_channel - - nanopb + - grpc_lb_upb - grpc_resolver_fake + - grpc_secure - grpclb_proto + - nanopb + - upb - name: grpc_lb_policy_pick_first src: - src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -777,9 +784,11 @@ filegroups: uses: - grpc_base - grpc_client_channel - - nanopb + - grpc_lb_upb - grpc_resolver_fake - grpclb_proto + - nanopb + - upb - name: grpc_lb_policy_xds_secure headers: - src/core/ext/filters/client_channel/lb_policy/xds/xds.h @@ -794,11 +803,13 @@ filegroups: plugin: grpc_lb_policy_xds uses: - grpc_base - - grpc_secure - grpc_client_channel - - nanopb + - grpc_lb_upb - grpc_resolver_fake + - grpc_secure - grpclb_proto + - nanopb + - upb - name: grpc_lb_subchannel_list headers: - src/core/ext/filters/client_channel/lb_policy/subchannel_list.h @@ -807,9 +818,9 @@ filegroups: - grpc_client_channel - name: grpc_lb_upb headers: - - src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.h + - src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h src: - - src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.c + - src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c uses: - google_api_upb - name: grpc_max_age_filter @@ -1543,6 +1554,7 @@ filegroups: - grpc_transport_inproc_headers - grpc++_codegen_base - grpc++_internal_hdrs_only + - grpc_health_upb - nanopb_headers - health_proto - name: grpc++_config_proto @@ -6195,13 +6207,13 @@ defaults: CXXFLAGS: $(W_NO_CXX14_COMPAT) global: COREFLAGS: -fno-rtti -fno-exceptions - CPPFLAGS: -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter -DOSATOMIC_USE_INLINED=1 - -Wno-deprecated-declarations -Ithird_party/nanopb -DPB_FIELD_32BIT + CPPFLAGS: -g -Wall -Wextra -Werror -Wno-unknown-warning-option -Wno-long-long + -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow + -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers + -Wno-maybe-uninitialized -DPB_FIELD_32BIT -DOSATOMIC_USE_INLINED=1 -Ithird_party/nanopb + -Ithird_party/upb -Ithird_party/upb/generated_for_cmake -Isrc/core/ext/upb-generated CXXFLAGS: -Wnon-virtual-dtor LDFLAGS: -g - upb: - CFLAGS: -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough - -Wno-sign-compare -Wno-missing-field-initializers zlib: CFLAGS: -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration -Wno-implicit-fallthrough $(W_NO_SHIFT_NEGATIVE_VALUE) -fvisibility=hidden diff --git a/cmake/upb.cmake b/cmake/upb.cmake new file mode 100644 index 00000000000..8a5ef86f1c4 --- /dev/null +++ b/cmake/upb.cmake @@ -0,0 +1,19 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(UPB_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/upb) + +set(_gRPC_UPB_INCLUDE_DIR "${UPB_ROOT_DIR}") +set(_gRPC_UPB_GENERATED_DIR "${UPB_ROOT_DIR}/generated_for_cmake") +set(_gRPC_UPB_GRPC_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/core/ext/upb-generated") diff --git a/config.m4 b/config.m4 index 6eeeafce9a5..07925b2d0ac 100644 --- a/config.m4 +++ b/config.m4 @@ -6,10 +6,13 @@ if test "$PHP_GRPC" != "no"; then dnl # --with-grpc -> add include path PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/include) + PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/core/ext/upb-generated) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/php/ext/grpc) - PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/boringssl/include) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/address_sorting/include) + PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/boringssl/include) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/nanopb) + PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/upb) + PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/upb/generated_for_cmake) LIBS="-lpthread $LIBS" @@ -342,7 +345,17 @@ if test "$PHP_GRPC" != "no"; then third_party/nanopb/pb_common.c \ third_party/nanopb/pb_decode.c \ third_party/nanopb/pb_encode.c \ + src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c \ + src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c \ + src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c \ src/core/tsi/transport_security.cc \ + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ + third_party/upb/upb/decode.c \ + third_party/upb/upb/encode.c \ + third_party/upb/upb/msg.c \ + third_party/upb/upb/port.c \ + third_party/upb/upb/table.c \ + third_party/upb/upb/upb.c \ src/core/ext/transport/chttp2/client/insecure/channel_create.cc \ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \ src/core/ext/transport/chttp2/client/authority.cc \ @@ -374,6 +387,7 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ src/core/ext/filters/client_channel/health/health.pb.c \ src/core/tsi/fake_transport_security.cc \ src/core/tsi/local_transport_security.cc \ @@ -393,6 +407,13 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \ + src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ + src/core/ext/upb-generated/google/protobuf/any.upb.c \ + src/core/ext/upb-generated/google/protobuf/duration.upb.c \ + src/core/ext/upb-generated/google/protobuf/empty.upb.c \ + src/core/ext/upb-generated/google/protobuf/struct.upb.c \ + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c \ @@ -721,6 +742,10 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/server/secure) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/transport) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/inproc) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/google/protobuf) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/src/proto/grpc/gcp) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/src/proto/grpc/health/v1) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/src/proto/grpc/lb/v1) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/avl) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/backoff) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/channel) @@ -805,4 +830,6 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/ssl) PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/third_party/fiat) PHP_ADD_BUILD_DIR($ext_builddir/third_party/nanopb) + PHP_ADD_BUILD_DIR($ext_builddir/third_party/upb/generated_for_cmake/google/protobuf) + PHP_ADD_BUILD_DIR($ext_builddir/third_party/upb/upb) fi diff --git a/config.w32 b/config.w32 index fd7920f72fd..8963d80a76d 100644 --- a/config.w32 +++ b/config.w32 @@ -317,7 +317,17 @@ if (PHP_GRPC != "no") { "third_party\\nanopb\\pb_common.c " + "third_party\\nanopb\\pb_decode.c " + "third_party\\nanopb\\pb_encode.c " + + "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\gcp\\altscontext.upb.c " + + "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\gcp\\handshaker.upb.c " + + "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\gcp\\transport_security_common.upb.c " + "src\\core\\tsi\\transport_security.cc " + + "third_party\\upb\\generated_for_cmake\\google\\protobuf\\descriptor.upb.c " + + "third_party\\upb\\upb\\decode.c " + + "third_party\\upb\\upb\\encode.c " + + "third_party\\upb\\upb\\msg.c " + + "third_party\\upb\\upb\\port.c " + + "third_party\\upb\\upb\\table.c " + + "third_party\\upb\\upb\\upb.c " + "src\\core\\ext\\transport\\chttp2\\client\\insecure\\channel_create.cc " + "src\\core\\ext\\transport\\chttp2\\client\\insecure\\channel_create_posix.cc " + "src\\core\\ext\\transport\\chttp2\\client\\authority.cc " + @@ -349,6 +359,7 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\subchannel.cc " + "src\\core\\ext\\filters\\client_channel\\subchannel_pool_interface.cc " + "src\\core\\ext\\filters\\deadline\\deadline_filter.cc " + + "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\health\\v1\\health.upb.c " + "src\\core\\ext\\filters\\client_channel\\health\\health.pb.c " + "src\\core\\tsi\\fake_transport_security.cc " + "src\\core\\tsi\\local_transport_security.cc " + @@ -368,6 +379,13 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\grpclb_channel_secure.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\grpclb_client_stats.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\load_balancer_api.cc " + + "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\lb\\v1\\load_balancer.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\any.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\duration.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\empty.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\struct.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\timestamp.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\wrappers.upb.c " + "src\\core\\ext\\filters\\client_channel\\resolver\\fake\\fake_resolver.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto\\grpc\\lb\\v1\\google\\protobuf\\duration.pb.c " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto\\grpc\\lb\\v1\\google\\protobuf\\timestamp.pb.c " + @@ -679,11 +697,14 @@ if (PHP_GRPC != "no") { "/DPB_FIELD_32BIT "+ "/I"+configure_module_dirname+" "+ "/I"+configure_module_dirname+"\\include "+ + "/I"+configure_module_dirname+"\\src\\core\\ext\\upb-generated "+ "/I"+configure_module_dirname+"\\src\\php\\ext\\grpc "+ - "/I"+configure_module_dirname+"\\third_party\\boringssl\\include "+ - "/I"+configure_module_dirname+"\\third_party\\zlib "+ "/I"+configure_module_dirname+"\\third_party\\address_sorting\\include "+ - "/I"+configure_module_dirname+"\\third_party\\nanopb"); + "/I"+configure_module_dirname+"\\third_party\\boringssl\\include "+ + "/I"+configure_module_dirname+"\\third_party\\nanopb "+ + "/I"+configure_module_dirname+"\\third_party\\upb "+ + "/I"+configure_module_dirname+"\\third_party\\upb\\generated_for_cmake "+ + "/I"+configure_module_dirname+"\\third_party\\zlib "); base_dir = get_define('BUILD_DIR'); FSO.CreateFolder(base_dir+"\\ext"); @@ -733,6 +754,17 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2\\server\\secure"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2\\transport"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\inproc"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\google"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\google\\protobuf"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\gcp"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\health"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\health\\v1"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\lb"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\lb\\v1"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\avl"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\backoff"); @@ -827,6 +859,11 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\third_party"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\third_party\\fiat"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\nanopb"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\upb"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\upb\\generated_for_cmake"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\upb\\generated_for_cmake\\google"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\upb\\generated_for_cmake\\google\\protobuf"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\upb\\upb"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\zlib"); _build_dirs = new Array(); for (i = 0; i < build_dirs.length; i++) { diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index e9816a481b8..1fb00deb22e 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -387,6 +387,9 @@ Pod::Spec.new do |s| 'src/core/tsi/alts/handshaker/altscontext.pb.h', 'src/core/tsi/alts/handshaker/handshaker.pb.h', 'src/core/tsi/alts/handshaker/transport_security_common.pb.h', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', 'src/core/ext/transport/chttp2/client/authority.h', @@ -419,6 +422,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/subchannel_interface.h', 'src/core/ext/filters/client_channel/subchannel_pool_interface.h', 'src/core/ext/filters/deadline/deadline_filter.h', + 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h', 'src/core/ext/filters/client_channel/health/health.pb.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/local_transport_security.h', @@ -578,6 +582,13 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h', + 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h', + 'src/core/ext/upb-generated/google/protobuf/any.upb.h', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.h', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.h', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.h', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.h', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.h', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h', @@ -782,6 +793,7 @@ Pod::Spec.new do |s| 'src/core/lib/uri/uri_parser.h', 'src/core/lib/debug/trace.h', 'src/core/ext/transport/inproc/inproc_transport.h', + 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h', 'src/core/ext/filters/client_channel/health/health.pb.h' end @@ -801,5 +813,11 @@ Pod::Spec.new do |s| find src/cpp/ -type f -path '*.grpc_back' -print0 | xargs -0 rm find src/core/ -type f ! -path '*.grpc_back' -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(pb(_.*)?\\.h)";#include ;g' find src/core/ -type f -path '*.grpc_back' -print0 | xargs -0 rm + find src/core/ third_party/upb/ -type f \\( -name '*.h' -or -name '*.c' -or -name '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "upb/(.*)";#if COCOAPODS==1\\\n #include "third_party/upb/upb/\\1"\\\n#else\\\n #include "upb/\\1"\\\n#endif;g' + find src/core/ third_party/upb/ -type f -name '*.grpc_back' -print0 | xargs -0 rm + find src/core/ src/cpp/ -type f \\( -name '*.h' -or -name '*.c' -or -name '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(.*).upb.h";#if COCOAPODS==1\\\n #include "src/core/ext/upb-generated/\\1.upb.h"\\\n#else\\\n #include "\\1.upb.h"\\\n#endif;g' + find src/core/ src/cpp/ -type f -name '*.grpc_back' -print0 | xargs -0 rm + find third_party/upb/ -type f \\( -name '*.h' -or -name '*.c' -or -name '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(.*).upb.h";#if COCOAPODS==1\\\n #include "third_party/upb/generated_for_cmake/\\1.upb.h"\\\n#else\\\n #include "\\1.upb.h"\\\n#endif;g' + find third_party/upb/ -type f -name '*.grpc_back' -print0 | xargs -0 rm END_OF_COMMAND end diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index a08b3cc680f..b00fe01fdd9 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -342,6 +342,9 @@ Pod::Spec.new do |s| 'src/core/tsi/alts/handshaker/altscontext.pb.h', 'src/core/tsi/alts/handshaker/handshaker.pb.h', 'src/core/tsi/alts/handshaker/transport_security_common.pb.h', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', 'src/core/ext/transport/chttp2/client/authority.h', @@ -374,6 +377,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/subchannel_interface.h', 'src/core/ext/filters/client_channel/subchannel_pool_interface.h', 'src/core/ext/filters/deadline/deadline_filter.h', + 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h', 'src/core/ext/filters/client_channel/health/health.pb.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/local_transport_security.h', @@ -533,6 +537,13 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h', + 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h', + 'src/core/ext/upb-generated/google/protobuf/any.upb.h', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.h', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.h', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.h', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.h', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.h', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h', @@ -804,7 +815,17 @@ Pod::Spec.new do |s| 'src/core/tsi/alts/handshaker/altscontext.pb.c', 'src/core/tsi/alts/handshaker/handshaker.pb.c', 'src/core/tsi/alts/handshaker/transport_security_common.pb.c', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c', 'src/core/tsi/transport_security.cc', + 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', + 'third_party/upb/upb/decode.c', + 'third_party/upb/upb/encode.c', + 'third_party/upb/upb/msg.c', + 'third_party/upb/upb/port.c', + 'third_party/upb/upb/table.c', + 'third_party/upb/upb/upb.c', 'src/core/ext/transport/chttp2/client/insecure/channel_create.cc', 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc', 'src/core/ext/transport/chttp2/client/authority.cc', @@ -836,6 +857,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', + 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', 'src/core/ext/filters/client_channel/health/health.pb.c', 'src/core/tsi/fake_transport_security.cc', 'src/core/tsi/local_transport_security.cc', @@ -855,6 +877,13 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', + 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c', + 'src/core/ext/upb-generated/google/protobuf/any.upb.c', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c', @@ -1001,6 +1030,9 @@ Pod::Spec.new do |s| 'src/core/tsi/alts/handshaker/altscontext.pb.h', 'src/core/tsi/alts/handshaker/handshaker.pb.h', 'src/core/tsi/alts/handshaker/transport_security_common.pb.h', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', 'src/core/ext/transport/chttp2/client/authority.h', @@ -1033,6 +1065,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/subchannel_interface.h', 'src/core/ext/filters/client_channel/subchannel_pool_interface.h', 'src/core/ext/filters/deadline/deadline_filter.h', + 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h', 'src/core/ext/filters/client_channel/health/health.pb.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/local_transport_security.h', @@ -1192,6 +1225,13 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h', + 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h', + 'src/core/ext/upb-generated/google/protobuf/any.upb.h', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.h', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.h', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.h', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.h', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.h', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h', @@ -1394,5 +1434,11 @@ Pod::Spec.new do |s| s.prepare_command = <<-END_OF_COMMAND sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS==1\\\n #include \\\n#else\\\n #include "\\1"\\\n#endif;g' $(find src/core -type f -print | xargs grep -H -c '#include ;#if COCOAPODS==1\\\n #include \\\n#else\\\n #include \\\n#endif;g' $(find src/core -type f \\( -path '*.h' -or -path '*.cc' \\) -print | xargs grep -H -c '#include + + + @@ -313,6 +316,7 @@ + @@ -472,6 +476,13 @@ + + + + + + + @@ -746,7 +757,17 @@ + + + + + + + + + + @@ -778,6 +799,7 @@ + @@ -797,6 +819,13 @@ + + + + + + + diff --git a/setup.py b/setup.py index 1e205bdf91d..fe8e8d05afd 100644 --- a/setup.py +++ b/setup.py @@ -35,9 +35,7 @@ egg_info.manifest_maker.template = 'PYTHON-MANIFEST.in' PY3 = sys.version_info.major == 3 PYTHON_STEM = os.path.join('src', 'python', 'grpcio') CORE_INCLUDE = ('include', '.',) -SSL_INCLUDE = (os.path.join('third_party', 'boringssl', 'include'),) -ZLIB_INCLUDE = (os.path.join('third_party', 'zlib'),) -NANOPB_INCLUDE = (os.path.join('third_party', 'nanopb'),) +ADDRESS_SORTING_INCLUDE = (os.path.join('third_party', 'address_sorting', 'include'),) CARES_INCLUDE = ( os.path.join('third_party', 'cares'), os.path.join('third_party', 'cares', 'cares'),) @@ -49,7 +47,12 @@ if 'linux' in sys.platform: CARES_INCLUDE += (os.path.join('third_party', 'cares', 'config_linux'),) if 'openbsd' in sys.platform: CARES_INCLUDE += (os.path.join('third_party', 'cares', 'config_openbsd'),) -ADDRESS_SORTING_INCLUDE = (os.path.join('third_party', 'address_sorting', 'include'),) +NANOPB_INCLUDE = (os.path.join('third_party', 'nanopb'),) +SSL_INCLUDE = (os.path.join('third_party', 'boringssl', 'include'),) +UPB_INCLUDE = (os.path.join('third_party', 'upb'),) +UPB_GENERATED_INCLUDE = (os.path.join('third_party','upb', 'generated_for_cmake'),) +UPB_GRPC_GENERATED_INCLUDE = (os.path.join('src', 'core', 'ext', 'upb-generated'),) +ZLIB_INCLUDE = (os.path.join('third_party', 'zlib'),) README = os.path.join(PYTHON_STEM, 'README.rst') # Ensure we're in the proper directory whether or not we're being used by pip. @@ -203,8 +206,16 @@ if BUILD_WITH_SYSTEM_CARES: CARES_INCLUDE = (os.path.join('/usr', 'include'),) EXTENSION_INCLUDE_DIRECTORIES = ( - (PYTHON_STEM,) + CORE_INCLUDE + SSL_INCLUDE + ZLIB_INCLUDE + - NANOPB_INCLUDE + CARES_INCLUDE + ADDRESS_SORTING_INCLUDE) + (PYTHON_STEM,) + + CORE_INCLUDE + + ADDRESS_SORTING_INCLUDE + + CARES_INCLUDE + + NANOPB_INCLUDE + + SSL_INCLUDE + + UPB_INCLUDE + + UPB_GENERATED_INCLUDE + + UPB_GRPC_GENERATED_INCLUDE + + ZLIB_INCLUDE) EXTENSION_LIBRARIES = () if "linux" in sys.platform: diff --git a/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c b/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c deleted file mode 100644 index 61b9299bb43..00000000000 --- a/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +++ /dev/null @@ -1,485 +0,0 @@ -/* This file was generated by upbc (the upb compiler) from the input - * file: - * - * google/protobuf/descriptor.proto - * - * Do not edit -- your changes will be discarded when the file is - * regenerated. */ - -#include -#include "upb/msg.h" -#include "google/protobuf/descriptor.upb.h" - -#include "upb/port_def.inc" - -static const upb_msglayout *const google_protobuf_FileDescriptorSet_submsgs[1] = { - &google_protobuf_FileDescriptorProto_msginit, -}; - -static const upb_msglayout_field google_protobuf_FileDescriptorSet__fields[1] = { - {1, UPB_SIZE(0, 0), 0, 0, 11, 3}, -}; - -const upb_msglayout google_protobuf_FileDescriptorSet_msginit = { - &google_protobuf_FileDescriptorSet_submsgs[0], - &google_protobuf_FileDescriptorSet__fields[0], - UPB_SIZE(4, 8), 1, false, -}; - -static const upb_msglayout *const google_protobuf_FileDescriptorProto_submsgs[6] = { - &google_protobuf_DescriptorProto_msginit, - &google_protobuf_EnumDescriptorProto_msginit, - &google_protobuf_FieldDescriptorProto_msginit, - &google_protobuf_FileOptions_msginit, - &google_protobuf_ServiceDescriptorProto_msginit, - &google_protobuf_SourceCodeInfo_msginit, -}; - -static const upb_msglayout_field google_protobuf_FileDescriptorProto__fields[12] = { - {1, UPB_SIZE(4, 8), 1, 0, 9, 1}, - {2, UPB_SIZE(12, 24), 2, 0, 9, 1}, - {3, UPB_SIZE(36, 72), 0, 0, 9, 3}, - {4, UPB_SIZE(40, 80), 0, 0, 11, 3}, - {5, UPB_SIZE(44, 88), 0, 1, 11, 3}, - {6, UPB_SIZE(48, 96), 0, 4, 11, 3}, - {7, UPB_SIZE(52, 104), 0, 2, 11, 3}, - {8, UPB_SIZE(28, 56), 4, 3, 11, 1}, - {9, UPB_SIZE(32, 64), 5, 5, 11, 1}, - {10, UPB_SIZE(56, 112), 0, 0, 5, 3}, - {11, UPB_SIZE(60, 120), 0, 0, 5, 3}, - {12, UPB_SIZE(20, 40), 3, 0, 9, 1}, -}; - -const upb_msglayout google_protobuf_FileDescriptorProto_msginit = { - &google_protobuf_FileDescriptorProto_submsgs[0], - &google_protobuf_FileDescriptorProto__fields[0], - UPB_SIZE(64, 128), 12, false, -}; - -static const upb_msglayout *const google_protobuf_DescriptorProto_submsgs[8] = { - &google_protobuf_DescriptorProto_msginit, - &google_protobuf_DescriptorProto_ExtensionRange_msginit, - &google_protobuf_DescriptorProto_ReservedRange_msginit, - &google_protobuf_EnumDescriptorProto_msginit, - &google_protobuf_FieldDescriptorProto_msginit, - &google_protobuf_MessageOptions_msginit, - &google_protobuf_OneofDescriptorProto_msginit, -}; - -static const upb_msglayout_field google_protobuf_DescriptorProto__fields[10] = { - {1, UPB_SIZE(4, 8), 1, 0, 9, 1}, - {2, UPB_SIZE(16, 32), 0, 4, 11, 3}, - {3, UPB_SIZE(20, 40), 0, 0, 11, 3}, - {4, UPB_SIZE(24, 48), 0, 3, 11, 3}, - {5, UPB_SIZE(28, 56), 0, 1, 11, 3}, - {6, UPB_SIZE(32, 64), 0, 4, 11, 3}, - {7, UPB_SIZE(12, 24), 2, 5, 11, 1}, - {8, UPB_SIZE(36, 72), 0, 6, 11, 3}, - {9, UPB_SIZE(40, 80), 0, 2, 11, 3}, - {10, UPB_SIZE(44, 88), 0, 0, 9, 3}, -}; - -const upb_msglayout google_protobuf_DescriptorProto_msginit = { - &google_protobuf_DescriptorProto_submsgs[0], - &google_protobuf_DescriptorProto__fields[0], - UPB_SIZE(48, 96), 10, false, -}; - -static const upb_msglayout *const google_protobuf_DescriptorProto_ExtensionRange_submsgs[1] = { - &google_protobuf_ExtensionRangeOptions_msginit, -}; - -static const upb_msglayout_field google_protobuf_DescriptorProto_ExtensionRange__fields[3] = { - {1, UPB_SIZE(4, 4), 1, 0, 5, 1}, - {2, UPB_SIZE(8, 8), 2, 0, 5, 1}, - {3, UPB_SIZE(12, 16), 3, 0, 11, 1}, -}; - -const upb_msglayout google_protobuf_DescriptorProto_ExtensionRange_msginit = { - &google_protobuf_DescriptorProto_ExtensionRange_submsgs[0], - &google_protobuf_DescriptorProto_ExtensionRange__fields[0], - UPB_SIZE(16, 24), 3, false, -}; - -static const upb_msglayout_field google_protobuf_DescriptorProto_ReservedRange__fields[2] = { - {1, UPB_SIZE(4, 4), 1, 0, 5, 1}, - {2, UPB_SIZE(8, 8), 2, 0, 5, 1}, -}; - -const upb_msglayout google_protobuf_DescriptorProto_ReservedRange_msginit = { - NULL, - &google_protobuf_DescriptorProto_ReservedRange__fields[0], - UPB_SIZE(12, 12), 2, false, -}; - -static const upb_msglayout *const google_protobuf_ExtensionRangeOptions_submsgs[1] = { - &google_protobuf_UninterpretedOption_msginit, -}; - -static const upb_msglayout_field google_protobuf_ExtensionRangeOptions__fields[1] = { - {999, UPB_SIZE(0, 0), 0, 0, 11, 3}, -}; - -const upb_msglayout google_protobuf_ExtensionRangeOptions_msginit = { - &google_protobuf_ExtensionRangeOptions_submsgs[0], - &google_protobuf_ExtensionRangeOptions__fields[0], - UPB_SIZE(4, 8), 1, false, -}; - -static const upb_msglayout *const google_protobuf_FieldDescriptorProto_submsgs[1] = { - &google_protobuf_FieldOptions_msginit, -}; - -static const upb_msglayout_field google_protobuf_FieldDescriptorProto__fields[10] = { - {1, UPB_SIZE(32, 32), 5, 0, 9, 1}, - {2, UPB_SIZE(40, 48), 6, 0, 9, 1}, - {3, UPB_SIZE(24, 24), 3, 0, 5, 1}, - {4, UPB_SIZE(8, 8), 1, 0, 14, 1}, - {5, UPB_SIZE(16, 16), 2, 0, 14, 1}, - {6, UPB_SIZE(48, 64), 7, 0, 9, 1}, - {7, UPB_SIZE(56, 80), 8, 0, 9, 1}, - {8, UPB_SIZE(72, 112), 10, 0, 11, 1}, - {9, UPB_SIZE(28, 28), 4, 0, 5, 1}, - {10, UPB_SIZE(64, 96), 9, 0, 9, 1}, -}; - -const upb_msglayout google_protobuf_FieldDescriptorProto_msginit = { - &google_protobuf_FieldDescriptorProto_submsgs[0], - &google_protobuf_FieldDescriptorProto__fields[0], - UPB_SIZE(80, 128), 10, false, -}; - -static const upb_msglayout *const google_protobuf_OneofDescriptorProto_submsgs[1] = { - &google_protobuf_OneofOptions_msginit, -}; - -static const upb_msglayout_field google_protobuf_OneofDescriptorProto__fields[2] = { - {1, UPB_SIZE(4, 8), 1, 0, 9, 1}, - {2, UPB_SIZE(12, 24), 2, 0, 11, 1}, -}; - -const upb_msglayout google_protobuf_OneofDescriptorProto_msginit = { - &google_protobuf_OneofDescriptorProto_submsgs[0], - &google_protobuf_OneofDescriptorProto__fields[0], - UPB_SIZE(16, 32), 2, false, -}; - -static const upb_msglayout *const google_protobuf_EnumDescriptorProto_submsgs[3] = { - &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, - &google_protobuf_EnumOptions_msginit, - &google_protobuf_EnumValueDescriptorProto_msginit, -}; - -static const upb_msglayout_field google_protobuf_EnumDescriptorProto__fields[5] = { - {1, UPB_SIZE(4, 8), 1, 0, 9, 1}, - {2, UPB_SIZE(16, 32), 0, 2, 11, 3}, - {3, UPB_SIZE(12, 24), 2, 1, 11, 1}, - {4, UPB_SIZE(20, 40), 0, 0, 11, 3}, - {5, UPB_SIZE(24, 48), 0, 0, 9, 3}, -}; - -const upb_msglayout google_protobuf_EnumDescriptorProto_msginit = { - &google_protobuf_EnumDescriptorProto_submsgs[0], - &google_protobuf_EnumDescriptorProto__fields[0], - UPB_SIZE(32, 64), 5, false, -}; - -static const upb_msglayout_field google_protobuf_EnumDescriptorProto_EnumReservedRange__fields[2] = { - {1, UPB_SIZE(4, 4), 1, 0, 5, 1}, - {2, UPB_SIZE(8, 8), 2, 0, 5, 1}, -}; - -const upb_msglayout google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit = { - NULL, - &google_protobuf_EnumDescriptorProto_EnumReservedRange__fields[0], - UPB_SIZE(12, 12), 2, false, -}; - -static const upb_msglayout *const google_protobuf_EnumValueDescriptorProto_submsgs[1] = { - &google_protobuf_EnumValueOptions_msginit, -}; - -static const upb_msglayout_field google_protobuf_EnumValueDescriptorProto__fields[3] = { - {1, UPB_SIZE(8, 8), 2, 0, 9, 1}, - {2, UPB_SIZE(4, 4), 1, 0, 5, 1}, - {3, UPB_SIZE(16, 24), 3, 0, 11, 1}, -}; - -const upb_msglayout google_protobuf_EnumValueDescriptorProto_msginit = { - &google_protobuf_EnumValueDescriptorProto_submsgs[0], - &google_protobuf_EnumValueDescriptorProto__fields[0], - UPB_SIZE(24, 32), 3, false, -}; - -static const upb_msglayout *const google_protobuf_ServiceDescriptorProto_submsgs[2] = { - &google_protobuf_MethodDescriptorProto_msginit, - &google_protobuf_ServiceOptions_msginit, -}; - -static const upb_msglayout_field google_protobuf_ServiceDescriptorProto__fields[3] = { - {1, UPB_SIZE(4, 8), 1, 0, 9, 1}, - {2, UPB_SIZE(16, 32), 0, 0, 11, 3}, - {3, UPB_SIZE(12, 24), 2, 1, 11, 1}, -}; - -const upb_msglayout google_protobuf_ServiceDescriptorProto_msginit = { - &google_protobuf_ServiceDescriptorProto_submsgs[0], - &google_protobuf_ServiceDescriptorProto__fields[0], - UPB_SIZE(24, 48), 3, false, -}; - -static const upb_msglayout *const google_protobuf_MethodDescriptorProto_submsgs[1] = { - &google_protobuf_MethodOptions_msginit, -}; - -static const upb_msglayout_field google_protobuf_MethodDescriptorProto__fields[6] = { - {1, UPB_SIZE(4, 8), 3, 0, 9, 1}, - {2, UPB_SIZE(12, 24), 4, 0, 9, 1}, - {3, UPB_SIZE(20, 40), 5, 0, 9, 1}, - {4, UPB_SIZE(28, 56), 6, 0, 11, 1}, - {5, UPB_SIZE(1, 1), 1, 0, 8, 1}, - {6, UPB_SIZE(2, 2), 2, 0, 8, 1}, -}; - -const upb_msglayout google_protobuf_MethodDescriptorProto_msginit = { - &google_protobuf_MethodDescriptorProto_submsgs[0], - &google_protobuf_MethodDescriptorProto__fields[0], - UPB_SIZE(32, 64), 6, false, -}; - -static const upb_msglayout *const google_protobuf_FileOptions_submsgs[1] = { - &google_protobuf_UninterpretedOption_msginit, -}; - -static const upb_msglayout_field google_protobuf_FileOptions__fields[21] = { - {1, UPB_SIZE(28, 32), 11, 0, 9, 1}, - {8, UPB_SIZE(36, 48), 12, 0, 9, 1}, - {9, UPB_SIZE(8, 8), 1, 0, 14, 1}, - {10, UPB_SIZE(16, 16), 2, 0, 8, 1}, - {11, UPB_SIZE(44, 64), 13, 0, 9, 1}, - {16, UPB_SIZE(17, 17), 3, 0, 8, 1}, - {17, UPB_SIZE(18, 18), 4, 0, 8, 1}, - {18, UPB_SIZE(19, 19), 5, 0, 8, 1}, - {20, UPB_SIZE(20, 20), 6, 0, 8, 1}, - {23, UPB_SIZE(21, 21), 7, 0, 8, 1}, - {27, UPB_SIZE(22, 22), 8, 0, 8, 1}, - {31, UPB_SIZE(23, 23), 9, 0, 8, 1}, - {36, UPB_SIZE(52, 80), 14, 0, 9, 1}, - {37, UPB_SIZE(60, 96), 15, 0, 9, 1}, - {39, UPB_SIZE(68, 112), 16, 0, 9, 1}, - {40, UPB_SIZE(76, 128), 17, 0, 9, 1}, - {41, UPB_SIZE(84, 144), 18, 0, 9, 1}, - {42, UPB_SIZE(24, 24), 10, 0, 8, 1}, - {44, UPB_SIZE(92, 160), 19, 0, 9, 1}, - {45, UPB_SIZE(100, 176), 20, 0, 9, 1}, - {999, UPB_SIZE(108, 192), 0, 0, 11, 3}, -}; - -const upb_msglayout google_protobuf_FileOptions_msginit = { - &google_protobuf_FileOptions_submsgs[0], - &google_protobuf_FileOptions__fields[0], - UPB_SIZE(112, 208), 21, false, -}; - -static const upb_msglayout *const google_protobuf_MessageOptions_submsgs[1] = { - &google_protobuf_UninterpretedOption_msginit, -}; - -static const upb_msglayout_field google_protobuf_MessageOptions__fields[5] = { - {1, UPB_SIZE(1, 1), 1, 0, 8, 1}, - {2, UPB_SIZE(2, 2), 2, 0, 8, 1}, - {3, UPB_SIZE(3, 3), 3, 0, 8, 1}, - {7, UPB_SIZE(4, 4), 4, 0, 8, 1}, - {999, UPB_SIZE(8, 8), 0, 0, 11, 3}, -}; - -const upb_msglayout google_protobuf_MessageOptions_msginit = { - &google_protobuf_MessageOptions_submsgs[0], - &google_protobuf_MessageOptions__fields[0], - UPB_SIZE(12, 16), 5, false, -}; - -static const upb_msglayout *const google_protobuf_FieldOptions_submsgs[1] = { - &google_protobuf_UninterpretedOption_msginit, -}; - -static const upb_msglayout_field google_protobuf_FieldOptions__fields[7] = { - {1, UPB_SIZE(8, 8), 1, 0, 14, 1}, - {2, UPB_SIZE(24, 24), 3, 0, 8, 1}, - {3, UPB_SIZE(25, 25), 4, 0, 8, 1}, - {5, UPB_SIZE(26, 26), 5, 0, 8, 1}, - {6, UPB_SIZE(16, 16), 2, 0, 14, 1}, - {10, UPB_SIZE(27, 27), 6, 0, 8, 1}, - {999, UPB_SIZE(28, 32), 0, 0, 11, 3}, -}; - -const upb_msglayout google_protobuf_FieldOptions_msginit = { - &google_protobuf_FieldOptions_submsgs[0], - &google_protobuf_FieldOptions__fields[0], - UPB_SIZE(32, 40), 7, false, -}; - -static const upb_msglayout *const google_protobuf_OneofOptions_submsgs[1] = { - &google_protobuf_UninterpretedOption_msginit, -}; - -static const upb_msglayout_field google_protobuf_OneofOptions__fields[1] = { - {999, UPB_SIZE(0, 0), 0, 0, 11, 3}, -}; - -const upb_msglayout google_protobuf_OneofOptions_msginit = { - &google_protobuf_OneofOptions_submsgs[0], - &google_protobuf_OneofOptions__fields[0], - UPB_SIZE(4, 8), 1, false, -}; - -static const upb_msglayout *const google_protobuf_EnumOptions_submsgs[1] = { - &google_protobuf_UninterpretedOption_msginit, -}; - -static const upb_msglayout_field google_protobuf_EnumOptions__fields[3] = { - {2, UPB_SIZE(1, 1), 1, 0, 8, 1}, - {3, UPB_SIZE(2, 2), 2, 0, 8, 1}, - {999, UPB_SIZE(4, 8), 0, 0, 11, 3}, -}; - -const upb_msglayout google_protobuf_EnumOptions_msginit = { - &google_protobuf_EnumOptions_submsgs[0], - &google_protobuf_EnumOptions__fields[0], - UPB_SIZE(8, 16), 3, false, -}; - -static const upb_msglayout *const google_protobuf_EnumValueOptions_submsgs[1] = { - &google_protobuf_UninterpretedOption_msginit, -}; - -static const upb_msglayout_field google_protobuf_EnumValueOptions__fields[2] = { - {1, UPB_SIZE(1, 1), 1, 0, 8, 1}, - {999, UPB_SIZE(4, 8), 0, 0, 11, 3}, -}; - -const upb_msglayout google_protobuf_EnumValueOptions_msginit = { - &google_protobuf_EnumValueOptions_submsgs[0], - &google_protobuf_EnumValueOptions__fields[0], - UPB_SIZE(8, 16), 2, false, -}; - -static const upb_msglayout *const google_protobuf_ServiceOptions_submsgs[1] = { - &google_protobuf_UninterpretedOption_msginit, -}; - -static const upb_msglayout_field google_protobuf_ServiceOptions__fields[2] = { - {33, UPB_SIZE(1, 1), 1, 0, 8, 1}, - {999, UPB_SIZE(4, 8), 0, 0, 11, 3}, -}; - -const upb_msglayout google_protobuf_ServiceOptions_msginit = { - &google_protobuf_ServiceOptions_submsgs[0], - &google_protobuf_ServiceOptions__fields[0], - UPB_SIZE(8, 16), 2, false, -}; - -static const upb_msglayout *const google_protobuf_MethodOptions_submsgs[1] = { - &google_protobuf_UninterpretedOption_msginit, -}; - -static const upb_msglayout_field google_protobuf_MethodOptions__fields[3] = { - {33, UPB_SIZE(16, 16), 2, 0, 8, 1}, - {34, UPB_SIZE(8, 8), 1, 0, 14, 1}, - {999, UPB_SIZE(20, 24), 0, 0, 11, 3}, -}; - -const upb_msglayout google_protobuf_MethodOptions_msginit = { - &google_protobuf_MethodOptions_submsgs[0], - &google_protobuf_MethodOptions__fields[0], - UPB_SIZE(24, 32), 3, false, -}; - -static const upb_msglayout *const google_protobuf_UninterpretedOption_submsgs[1] = { - &google_protobuf_UninterpretedOption_NamePart_msginit, -}; - -static const upb_msglayout_field google_protobuf_UninterpretedOption__fields[7] = { - {2, UPB_SIZE(56, 80), 0, 0, 11, 3}, - {3, UPB_SIZE(32, 32), 4, 0, 9, 1}, - {4, UPB_SIZE(8, 8), 1, 0, 4, 1}, - {5, UPB_SIZE(16, 16), 2, 0, 3, 1}, - {6, UPB_SIZE(24, 24), 3, 0, 1, 1}, - {7, UPB_SIZE(40, 48), 5, 0, 12, 1}, - {8, UPB_SIZE(48, 64), 6, 0, 9, 1}, -}; - -const upb_msglayout google_protobuf_UninterpretedOption_msginit = { - &google_protobuf_UninterpretedOption_submsgs[0], - &google_protobuf_UninterpretedOption__fields[0], - UPB_SIZE(64, 96), 7, false, -}; - -static const upb_msglayout_field google_protobuf_UninterpretedOption_NamePart__fields[2] = { - {1, UPB_SIZE(4, 8), 2, 0, 9, 2}, - {2, UPB_SIZE(1, 1), 1, 0, 8, 2}, -}; - -const upb_msglayout google_protobuf_UninterpretedOption_NamePart_msginit = { - NULL, - &google_protobuf_UninterpretedOption_NamePart__fields[0], - UPB_SIZE(16, 32), 2, false, -}; - -static const upb_msglayout *const google_protobuf_SourceCodeInfo_submsgs[1] = { - &google_protobuf_SourceCodeInfo_Location_msginit, -}; - -static const upb_msglayout_field google_protobuf_SourceCodeInfo__fields[1] = { - {1, UPB_SIZE(0, 0), 0, 0, 11, 3}, -}; - -const upb_msglayout google_protobuf_SourceCodeInfo_msginit = { - &google_protobuf_SourceCodeInfo_submsgs[0], - &google_protobuf_SourceCodeInfo__fields[0], - UPB_SIZE(4, 8), 1, false, -}; - -static const upb_msglayout_field google_protobuf_SourceCodeInfo_Location__fields[5] = { - {1, UPB_SIZE(20, 40), 0, 0, 5, 3}, - {2, UPB_SIZE(24, 48), 0, 0, 5, 3}, - {3, UPB_SIZE(4, 8), 1, 0, 9, 1}, - {4, UPB_SIZE(12, 24), 2, 0, 9, 1}, - {6, UPB_SIZE(28, 56), 0, 0, 9, 3}, -}; - -const upb_msglayout google_protobuf_SourceCodeInfo_Location_msginit = { - NULL, - &google_protobuf_SourceCodeInfo_Location__fields[0], - UPB_SIZE(32, 64), 5, false, -}; - -static const upb_msglayout *const google_protobuf_GeneratedCodeInfo_submsgs[1] = { - &google_protobuf_GeneratedCodeInfo_Annotation_msginit, -}; - -static const upb_msglayout_field google_protobuf_GeneratedCodeInfo__fields[1] = { - {1, UPB_SIZE(0, 0), 0, 0, 11, 3}, -}; - -const upb_msglayout google_protobuf_GeneratedCodeInfo_msginit = { - &google_protobuf_GeneratedCodeInfo_submsgs[0], - &google_protobuf_GeneratedCodeInfo__fields[0], - UPB_SIZE(4, 8), 1, false, -}; - -static const upb_msglayout_field google_protobuf_GeneratedCodeInfo_Annotation__fields[4] = { - {1, UPB_SIZE(20, 32), 0, 0, 5, 3}, - {2, UPB_SIZE(12, 16), 3, 0, 9, 1}, - {3, UPB_SIZE(4, 4), 1, 0, 5, 1}, - {4, UPB_SIZE(8, 8), 2, 0, 5, 1}, -}; - -const upb_msglayout google_protobuf_GeneratedCodeInfo_Annotation_msginit = { - NULL, - &google_protobuf_GeneratedCodeInfo_Annotation__fields[0], - UPB_SIZE(24, 48), 4, false, -}; - -#include "upb/port_undef.inc" - diff --git a/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h b/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h deleted file mode 100644 index 681614910e0..00000000000 --- a/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +++ /dev/null @@ -1,1690 +0,0 @@ -/* This file was generated by upbc (the upb compiler) from the input - * file: - * - * google/protobuf/descriptor.proto - * - * Do not edit -- your changes will be discarded when the file is - * regenerated. */ - -#ifndef GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_ -#define GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_ - -#include "upb/generated_util.h" -#include "upb/msg.h" -#include "upb/decode.h" -#include "upb/encode.h" - -#include "upb/port_def.inc" - -#ifdef __cplusplus -extern "C" { -#endif - -struct google_protobuf_FileDescriptorSet; -struct google_protobuf_FileDescriptorProto; -struct google_protobuf_DescriptorProto; -struct google_protobuf_DescriptorProto_ExtensionRange; -struct google_protobuf_DescriptorProto_ReservedRange; -struct google_protobuf_ExtensionRangeOptions; -struct google_protobuf_FieldDescriptorProto; -struct google_protobuf_OneofDescriptorProto; -struct google_protobuf_EnumDescriptorProto; -struct google_protobuf_EnumDescriptorProto_EnumReservedRange; -struct google_protobuf_EnumValueDescriptorProto; -struct google_protobuf_ServiceDescriptorProto; -struct google_protobuf_MethodDescriptorProto; -struct google_protobuf_FileOptions; -struct google_protobuf_MessageOptions; -struct google_protobuf_FieldOptions; -struct google_protobuf_OneofOptions; -struct google_protobuf_EnumOptions; -struct google_protobuf_EnumValueOptions; -struct google_protobuf_ServiceOptions; -struct google_protobuf_MethodOptions; -struct google_protobuf_UninterpretedOption; -struct google_protobuf_UninterpretedOption_NamePart; -struct google_protobuf_SourceCodeInfo; -struct google_protobuf_SourceCodeInfo_Location; -struct google_protobuf_GeneratedCodeInfo; -struct google_protobuf_GeneratedCodeInfo_Annotation; -typedef struct google_protobuf_FileDescriptorSet google_protobuf_FileDescriptorSet; -typedef struct google_protobuf_FileDescriptorProto google_protobuf_FileDescriptorProto; -typedef struct google_protobuf_DescriptorProto google_protobuf_DescriptorProto; -typedef struct google_protobuf_DescriptorProto_ExtensionRange google_protobuf_DescriptorProto_ExtensionRange; -typedef struct google_protobuf_DescriptorProto_ReservedRange google_protobuf_DescriptorProto_ReservedRange; -typedef struct google_protobuf_ExtensionRangeOptions google_protobuf_ExtensionRangeOptions; -typedef struct google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto; -typedef struct google_protobuf_OneofDescriptorProto google_protobuf_OneofDescriptorProto; -typedef struct google_protobuf_EnumDescriptorProto google_protobuf_EnumDescriptorProto; -typedef struct google_protobuf_EnumDescriptorProto_EnumReservedRange google_protobuf_EnumDescriptorProto_EnumReservedRange; -typedef struct google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescriptorProto; -typedef struct google_protobuf_ServiceDescriptorProto google_protobuf_ServiceDescriptorProto; -typedef struct google_protobuf_MethodDescriptorProto google_protobuf_MethodDescriptorProto; -typedef struct google_protobuf_FileOptions google_protobuf_FileOptions; -typedef struct google_protobuf_MessageOptions google_protobuf_MessageOptions; -typedef struct google_protobuf_FieldOptions google_protobuf_FieldOptions; -typedef struct google_protobuf_OneofOptions google_protobuf_OneofOptions; -typedef struct google_protobuf_EnumOptions google_protobuf_EnumOptions; -typedef struct google_protobuf_EnumValueOptions google_protobuf_EnumValueOptions; -typedef struct google_protobuf_ServiceOptions google_protobuf_ServiceOptions; -typedef struct google_protobuf_MethodOptions google_protobuf_MethodOptions; -typedef struct google_protobuf_UninterpretedOption google_protobuf_UninterpretedOption; -typedef struct google_protobuf_UninterpretedOption_NamePart google_protobuf_UninterpretedOption_NamePart; -typedef struct google_protobuf_SourceCodeInfo google_protobuf_SourceCodeInfo; -typedef struct google_protobuf_SourceCodeInfo_Location google_protobuf_SourceCodeInfo_Location; -typedef struct google_protobuf_GeneratedCodeInfo google_protobuf_GeneratedCodeInfo; -typedef struct google_protobuf_GeneratedCodeInfo_Annotation google_protobuf_GeneratedCodeInfo_Annotation; -extern const upb_msglayout google_protobuf_FileDescriptorSet_msginit; -extern const upb_msglayout google_protobuf_FileDescriptorProto_msginit; -extern const upb_msglayout google_protobuf_DescriptorProto_msginit; -extern const upb_msglayout google_protobuf_DescriptorProto_ExtensionRange_msginit; -extern const upb_msglayout google_protobuf_DescriptorProto_ReservedRange_msginit; -extern const upb_msglayout google_protobuf_ExtensionRangeOptions_msginit; -extern const upb_msglayout google_protobuf_FieldDescriptorProto_msginit; -extern const upb_msglayout google_protobuf_OneofDescriptorProto_msginit; -extern const upb_msglayout google_protobuf_EnumDescriptorProto_msginit; -extern const upb_msglayout google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit; -extern const upb_msglayout google_protobuf_EnumValueDescriptorProto_msginit; -extern const upb_msglayout google_protobuf_ServiceDescriptorProto_msginit; -extern const upb_msglayout google_protobuf_MethodDescriptorProto_msginit; -extern const upb_msglayout google_protobuf_FileOptions_msginit; -extern const upb_msglayout google_protobuf_MessageOptions_msginit; -extern const upb_msglayout google_protobuf_FieldOptions_msginit; -extern const upb_msglayout google_protobuf_OneofOptions_msginit; -extern const upb_msglayout google_protobuf_EnumOptions_msginit; -extern const upb_msglayout google_protobuf_EnumValueOptions_msginit; -extern const upb_msglayout google_protobuf_ServiceOptions_msginit; -extern const upb_msglayout google_protobuf_MethodOptions_msginit; -extern const upb_msglayout google_protobuf_UninterpretedOption_msginit; -extern const upb_msglayout google_protobuf_UninterpretedOption_NamePart_msginit; -extern const upb_msglayout google_protobuf_SourceCodeInfo_msginit; -extern const upb_msglayout google_protobuf_SourceCodeInfo_Location_msginit; -extern const upb_msglayout google_protobuf_GeneratedCodeInfo_msginit; -extern const upb_msglayout google_protobuf_GeneratedCodeInfo_Annotation_msginit; - -typedef enum { - google_protobuf_FieldDescriptorProto_LABEL_OPTIONAL = 1, - google_protobuf_FieldDescriptorProto_LABEL_REQUIRED = 2, - google_protobuf_FieldDescriptorProto_LABEL_REPEATED = 3 -} google_protobuf_FieldDescriptorProto_Label; - -typedef enum { - google_protobuf_FieldDescriptorProto_TYPE_DOUBLE = 1, - google_protobuf_FieldDescriptorProto_TYPE_FLOAT = 2, - google_protobuf_FieldDescriptorProto_TYPE_INT64 = 3, - google_protobuf_FieldDescriptorProto_TYPE_UINT64 = 4, - google_protobuf_FieldDescriptorProto_TYPE_INT32 = 5, - google_protobuf_FieldDescriptorProto_TYPE_FIXED64 = 6, - google_protobuf_FieldDescriptorProto_TYPE_FIXED32 = 7, - google_protobuf_FieldDescriptorProto_TYPE_BOOL = 8, - google_protobuf_FieldDescriptorProto_TYPE_STRING = 9, - google_protobuf_FieldDescriptorProto_TYPE_GROUP = 10, - google_protobuf_FieldDescriptorProto_TYPE_MESSAGE = 11, - google_protobuf_FieldDescriptorProto_TYPE_BYTES = 12, - google_protobuf_FieldDescriptorProto_TYPE_UINT32 = 13, - google_protobuf_FieldDescriptorProto_TYPE_ENUM = 14, - google_protobuf_FieldDescriptorProto_TYPE_SFIXED32 = 15, - google_protobuf_FieldDescriptorProto_TYPE_SFIXED64 = 16, - google_protobuf_FieldDescriptorProto_TYPE_SINT32 = 17, - google_protobuf_FieldDescriptorProto_TYPE_SINT64 = 18 -} google_protobuf_FieldDescriptorProto_Type; - -typedef enum { - google_protobuf_FieldOptions_STRING = 0, - google_protobuf_FieldOptions_CORD = 1, - google_protobuf_FieldOptions_STRING_PIECE = 2 -} google_protobuf_FieldOptions_CType; - -typedef enum { - google_protobuf_FieldOptions_JS_NORMAL = 0, - google_protobuf_FieldOptions_JS_STRING = 1, - google_protobuf_FieldOptions_JS_NUMBER = 2 -} google_protobuf_FieldOptions_JSType; - -typedef enum { - google_protobuf_FileOptions_SPEED = 1, - google_protobuf_FileOptions_CODE_SIZE = 2, - google_protobuf_FileOptions_LITE_RUNTIME = 3 -} google_protobuf_FileOptions_OptimizeMode; - -typedef enum { - google_protobuf_MethodOptions_IDEMPOTENCY_UNKNOWN = 0, - google_protobuf_MethodOptions_NO_SIDE_EFFECTS = 1, - google_protobuf_MethodOptions_IDEMPOTENT = 2 -} google_protobuf_MethodOptions_IdempotencyLevel; - - -/* google.protobuf.FileDescriptorSet */ - -UPB_INLINE google_protobuf_FileDescriptorSet *google_protobuf_FileDescriptorSet_new(upb_arena *arena) { - return (google_protobuf_FileDescriptorSet *)upb_msg_new(&google_protobuf_FileDescriptorSet_msginit, arena); -} -UPB_INLINE google_protobuf_FileDescriptorSet *google_protobuf_FileDescriptorSet_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_FileDescriptorSet *ret = google_protobuf_FileDescriptorSet_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_FileDescriptorSet_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_FileDescriptorSet_serialize(const google_protobuf_FileDescriptorSet *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_FileDescriptorSet_msginit, arena, len); -} - -UPB_INLINE const google_protobuf_FileDescriptorProto* const* google_protobuf_FileDescriptorSet_file(const google_protobuf_FileDescriptorSet *msg, size_t *len) { return (const google_protobuf_FileDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); } - -UPB_INLINE google_protobuf_FileDescriptorProto** google_protobuf_FileDescriptorSet_mutable_file(google_protobuf_FileDescriptorSet *msg, size_t *len) { - return (google_protobuf_FileDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len); -} -UPB_INLINE google_protobuf_FileDescriptorProto** google_protobuf_FileDescriptorSet_resize_file(google_protobuf_FileDescriptorSet *msg, size_t len, upb_arena *arena) { - return (google_protobuf_FileDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorSet_add_file(google_protobuf_FileDescriptorSet *msg, upb_arena *arena) { - struct google_protobuf_FileDescriptorProto* sub = (struct google_protobuf_FileDescriptorProto*)upb_msg_new(&google_protobuf_FileDescriptorProto_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} - -/* google.protobuf.FileDescriptorProto */ - -UPB_INLINE google_protobuf_FileDescriptorProto *google_protobuf_FileDescriptorProto_new(upb_arena *arena) { - return (google_protobuf_FileDescriptorProto *)upb_msg_new(&google_protobuf_FileDescriptorProto_msginit, arena); -} -UPB_INLINE google_protobuf_FileDescriptorProto *google_protobuf_FileDescriptorProto_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_FileDescriptorProto *ret = google_protobuf_FileDescriptorProto_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_FileDescriptorProto_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_FileDescriptorProto_serialize(const google_protobuf_FileDescriptorProto *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_FileDescriptorProto_msginit, arena, len); -} - -UPB_INLINE bool google_protobuf_FileDescriptorProto_has_name(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE upb_strview google_protobuf_FileDescriptorProto_name(const google_protobuf_FileDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } -UPB_INLINE bool google_protobuf_FileDescriptorProto_has_package(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE upb_strview google_protobuf_FileDescriptorProto_package(const google_protobuf_FileDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)); } -UPB_INLINE upb_strview const* google_protobuf_FileDescriptorProto_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(36, 72), len); } -UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_FileDescriptorProto_message_type(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(40, 80), len); } -UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_FileDescriptorProto_enum_type(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(44, 88), len); } -UPB_INLINE const google_protobuf_ServiceDescriptorProto* const* google_protobuf_FileDescriptorProto_service(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_ServiceDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(48, 96), len); } -UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_FileDescriptorProto_extension(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(52, 104), len); } -UPB_INLINE bool google_protobuf_FileDescriptorProto_has_options(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 4); } -UPB_INLINE const google_protobuf_FileOptions* google_protobuf_FileDescriptorProto_options(const google_protobuf_FileDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_FileOptions*, UPB_SIZE(28, 56)); } -UPB_INLINE bool google_protobuf_FileDescriptorProto_has_source_code_info(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 5); } -UPB_INLINE const google_protobuf_SourceCodeInfo* google_protobuf_FileDescriptorProto_source_code_info(const google_protobuf_FileDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_SourceCodeInfo*, UPB_SIZE(32, 64)); } -UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_public_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(56, 112), len); } -UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_weak_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(60, 120), len); } -UPB_INLINE bool google_protobuf_FileDescriptorProto_has_syntax(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 3); } -UPB_INLINE upb_strview google_protobuf_FileDescriptorProto_syntax(const google_protobuf_FileDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(20, 40)); } - -UPB_INLINE void google_protobuf_FileDescriptorProto_set_name(google_protobuf_FileDescriptorProto *msg, upb_strview value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; -} -UPB_INLINE void google_protobuf_FileDescriptorProto_set_package(google_protobuf_FileDescriptorProto *msg, upb_strview value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)) = value; -} -UPB_INLINE upb_strview* google_protobuf_FileDescriptorProto_mutable_dependency(google_protobuf_FileDescriptorProto *msg, size_t *len) { - return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(36, 72), len); -} -UPB_INLINE upb_strview* google_protobuf_FileDescriptorProto_resize_dependency(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) { - return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(36, 72), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); -} -UPB_INLINE bool google_protobuf_FileDescriptorProto_add_dependency(google_protobuf_FileDescriptorProto *msg, upb_strview val, upb_arena *arena) { - return _upb_array_append_accessor( - msg, UPB_SIZE(36, 72), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); -} -UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_FileDescriptorProto_mutable_message_type(google_protobuf_FileDescriptorProto *msg, size_t *len) { - return (google_protobuf_DescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(40, 80), len); -} -UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_FileDescriptorProto_resize_message_type(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) { - return (google_protobuf_DescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(40, 80), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_DescriptorProto* google_protobuf_FileDescriptorProto_add_message_type(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_DescriptorProto* sub = (struct google_protobuf_DescriptorProto*)upb_msg_new(&google_protobuf_DescriptorProto_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(40, 80), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} -UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_FileDescriptorProto_mutable_enum_type(google_protobuf_FileDescriptorProto *msg, size_t *len) { - return (google_protobuf_EnumDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(44, 88), len); -} -UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_FileDescriptorProto_resize_enum_type(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) { - return (google_protobuf_EnumDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(44, 88), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_EnumDescriptorProto* google_protobuf_FileDescriptorProto_add_enum_type(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_EnumDescriptorProto* sub = (struct google_protobuf_EnumDescriptorProto*)upb_msg_new(&google_protobuf_EnumDescriptorProto_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(44, 88), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} -UPB_INLINE google_protobuf_ServiceDescriptorProto** google_protobuf_FileDescriptorProto_mutable_service(google_protobuf_FileDescriptorProto *msg, size_t *len) { - return (google_protobuf_ServiceDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(48, 96), len); -} -UPB_INLINE google_protobuf_ServiceDescriptorProto** google_protobuf_FileDescriptorProto_resize_service(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) { - return (google_protobuf_ServiceDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(48, 96), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_ServiceDescriptorProto* google_protobuf_FileDescriptorProto_add_service(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_ServiceDescriptorProto* sub = (struct google_protobuf_ServiceDescriptorProto*)upb_msg_new(&google_protobuf_ServiceDescriptorProto_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(48, 96), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} -UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_FileDescriptorProto_mutable_extension(google_protobuf_FileDescriptorProto *msg, size_t *len) { - return (google_protobuf_FieldDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(52, 104), len); -} -UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_FileDescriptorProto_resize_extension(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) { - return (google_protobuf_FieldDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(52, 104), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_FileDescriptorProto_add_extension(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)upb_msg_new(&google_protobuf_FieldDescriptorProto_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(52, 104), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} -UPB_INLINE void google_protobuf_FileDescriptorProto_set_options(google_protobuf_FileDescriptorProto *msg, google_protobuf_FileOptions* value) { - _upb_sethas(msg, 4); - UPB_FIELD_AT(msg, google_protobuf_FileOptions*, UPB_SIZE(28, 56)) = value; -} -UPB_INLINE struct google_protobuf_FileOptions* google_protobuf_FileDescriptorProto_mutable_options(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_FileOptions* sub = (struct google_protobuf_FileOptions*)google_protobuf_FileDescriptorProto_options(msg); - if (sub == NULL) { - sub = (struct google_protobuf_FileOptions*)upb_msg_new(&google_protobuf_FileOptions_msginit, arena); - if (!sub) return NULL; - google_protobuf_FileDescriptorProto_set_options(msg, sub); - } - return sub; -} -UPB_INLINE void google_protobuf_FileDescriptorProto_set_source_code_info(google_protobuf_FileDescriptorProto *msg, google_protobuf_SourceCodeInfo* value) { - _upb_sethas(msg, 5); - UPB_FIELD_AT(msg, google_protobuf_SourceCodeInfo*, UPB_SIZE(32, 64)) = value; -} -UPB_INLINE struct google_protobuf_SourceCodeInfo* google_protobuf_FileDescriptorProto_mutable_source_code_info(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_SourceCodeInfo* sub = (struct google_protobuf_SourceCodeInfo*)google_protobuf_FileDescriptorProto_source_code_info(msg); - if (sub == NULL) { - sub = (struct google_protobuf_SourceCodeInfo*)upb_msg_new(&google_protobuf_SourceCodeInfo_msginit, arena); - if (!sub) return NULL; - google_protobuf_FileDescriptorProto_set_source_code_info(msg, sub); - } - return sub; -} -UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_mutable_public_dependency(google_protobuf_FileDescriptorProto *msg, size_t *len) { - return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(56, 112), len); -} -UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_resize_public_dependency(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) { - return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(56, 112), len, UPB_SIZE(4, 4), UPB_TYPE_INT32, arena); -} -UPB_INLINE bool google_protobuf_FileDescriptorProto_add_public_dependency(google_protobuf_FileDescriptorProto *msg, int32_t val, upb_arena *arena) { - return _upb_array_append_accessor( - msg, UPB_SIZE(56, 112), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val, arena); -} -UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_mutable_weak_dependency(google_protobuf_FileDescriptorProto *msg, size_t *len) { - return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(60, 120), len); -} -UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_resize_weak_dependency(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) { - return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(60, 120), len, UPB_SIZE(4, 4), UPB_TYPE_INT32, arena); -} -UPB_INLINE bool google_protobuf_FileDescriptorProto_add_weak_dependency(google_protobuf_FileDescriptorProto *msg, int32_t val, upb_arena *arena) { - return _upb_array_append_accessor( - msg, UPB_SIZE(60, 120), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val, arena); -} -UPB_INLINE void google_protobuf_FileDescriptorProto_set_syntax(google_protobuf_FileDescriptorProto *msg, upb_strview value) { - _upb_sethas(msg, 3); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(20, 40)) = value; -} - -/* google.protobuf.DescriptorProto */ - -UPB_INLINE google_protobuf_DescriptorProto *google_protobuf_DescriptorProto_new(upb_arena *arena) { - return (google_protobuf_DescriptorProto *)upb_msg_new(&google_protobuf_DescriptorProto_msginit, arena); -} -UPB_INLINE google_protobuf_DescriptorProto *google_protobuf_DescriptorProto_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_DescriptorProto *ret = google_protobuf_DescriptorProto_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_DescriptorProto_serialize(const google_protobuf_DescriptorProto *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_DescriptorProto_msginit, arena, len); -} - -UPB_INLINE bool google_protobuf_DescriptorProto_has_name(const google_protobuf_DescriptorProto *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE upb_strview google_protobuf_DescriptorProto_name(const google_protobuf_DescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } -UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_DescriptorProto_field(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len); } -UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_DescriptorProto_nested_type(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len); } -UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_DescriptorProto_enum_type(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len); } -UPB_INLINE const google_protobuf_DescriptorProto_ExtensionRange* const* google_protobuf_DescriptorProto_extension_range(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto_ExtensionRange* const*)_upb_array_accessor(msg, UPB_SIZE(28, 56), len); } -UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_DescriptorProto_extension(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(32, 64), len); } -UPB_INLINE bool google_protobuf_DescriptorProto_has_options(const google_protobuf_DescriptorProto *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE const google_protobuf_MessageOptions* google_protobuf_DescriptorProto_options(const google_protobuf_DescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_MessageOptions*, UPB_SIZE(12, 24)); } -UPB_INLINE const google_protobuf_OneofDescriptorProto* const* google_protobuf_DescriptorProto_oneof_decl(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_OneofDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(36, 72), len); } -UPB_INLINE const google_protobuf_DescriptorProto_ReservedRange* const* google_protobuf_DescriptorProto_reserved_range(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto_ReservedRange* const*)_upb_array_accessor(msg, UPB_SIZE(40, 80), len); } -UPB_INLINE upb_strview const* google_protobuf_DescriptorProto_reserved_name(const google_protobuf_DescriptorProto *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(44, 88), len); } - -UPB_INLINE void google_protobuf_DescriptorProto_set_name(google_protobuf_DescriptorProto *msg, upb_strview value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; -} -UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_mutable_field(google_protobuf_DescriptorProto *msg, size_t *len) { - return (google_protobuf_FieldDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len); -} -UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_resize_field(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) { - return (google_protobuf_FieldDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(16, 32), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_DescriptorProto_add_field(google_protobuf_DescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)upb_msg_new(&google_protobuf_FieldDescriptorProto_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(16, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} -UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_DescriptorProto_mutable_nested_type(google_protobuf_DescriptorProto *msg, size_t *len) { - return (google_protobuf_DescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 40), len); -} -UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_DescriptorProto_resize_nested_type(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) { - return (google_protobuf_DescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(20, 40), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_add_nested_type(google_protobuf_DescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_DescriptorProto* sub = (struct google_protobuf_DescriptorProto*)upb_msg_new(&google_protobuf_DescriptorProto_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(20, 40), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} -UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_DescriptorProto_mutable_enum_type(google_protobuf_DescriptorProto *msg, size_t *len) { - return (google_protobuf_EnumDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 48), len); -} -UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_DescriptorProto_resize_enum_type(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) { - return (google_protobuf_EnumDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(24, 48), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_EnumDescriptorProto* google_protobuf_DescriptorProto_add_enum_type(google_protobuf_DescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_EnumDescriptorProto* sub = (struct google_protobuf_EnumDescriptorProto*)upb_msg_new(&google_protobuf_EnumDescriptorProto_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(24, 48), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} -UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange** google_protobuf_DescriptorProto_mutable_extension_range(google_protobuf_DescriptorProto *msg, size_t *len) { - return (google_protobuf_DescriptorProto_ExtensionRange**)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 56), len); -} -UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange** google_protobuf_DescriptorProto_resize_extension_range(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) { - return (google_protobuf_DescriptorProto_ExtensionRange**)_upb_array_resize_accessor(msg, UPB_SIZE(28, 56), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_add_extension_range(google_protobuf_DescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_DescriptorProto_ExtensionRange* sub = (struct google_protobuf_DescriptorProto_ExtensionRange*)upb_msg_new(&google_protobuf_DescriptorProto_ExtensionRange_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(28, 56), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} -UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_mutable_extension(google_protobuf_DescriptorProto *msg, size_t *len) { - return (google_protobuf_FieldDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(32, 64), len); -} -UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_resize_extension(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) { - return (google_protobuf_FieldDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(32, 64), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_DescriptorProto_add_extension(google_protobuf_DescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)upb_msg_new(&google_protobuf_FieldDescriptorProto_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(32, 64), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} -UPB_INLINE void google_protobuf_DescriptorProto_set_options(google_protobuf_DescriptorProto *msg, google_protobuf_MessageOptions* value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, google_protobuf_MessageOptions*, UPB_SIZE(12, 24)) = value; -} -UPB_INLINE struct google_protobuf_MessageOptions* google_protobuf_DescriptorProto_mutable_options(google_protobuf_DescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_MessageOptions* sub = (struct google_protobuf_MessageOptions*)google_protobuf_DescriptorProto_options(msg); - if (sub == NULL) { - sub = (struct google_protobuf_MessageOptions*)upb_msg_new(&google_protobuf_MessageOptions_msginit, arena); - if (!sub) return NULL; - google_protobuf_DescriptorProto_set_options(msg, sub); - } - return sub; -} -UPB_INLINE google_protobuf_OneofDescriptorProto** google_protobuf_DescriptorProto_mutable_oneof_decl(google_protobuf_DescriptorProto *msg, size_t *len) { - return (google_protobuf_OneofDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(36, 72), len); -} -UPB_INLINE google_protobuf_OneofDescriptorProto** google_protobuf_DescriptorProto_resize_oneof_decl(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) { - return (google_protobuf_OneofDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(36, 72), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_OneofDescriptorProto* google_protobuf_DescriptorProto_add_oneof_decl(google_protobuf_DescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_OneofDescriptorProto* sub = (struct google_protobuf_OneofDescriptorProto*)upb_msg_new(&google_protobuf_OneofDescriptorProto_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(36, 72), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} -UPB_INLINE google_protobuf_DescriptorProto_ReservedRange** google_protobuf_DescriptorProto_mutable_reserved_range(google_protobuf_DescriptorProto *msg, size_t *len) { - return (google_protobuf_DescriptorProto_ReservedRange**)_upb_array_mutable_accessor(msg, UPB_SIZE(40, 80), len); -} -UPB_INLINE google_protobuf_DescriptorProto_ReservedRange** google_protobuf_DescriptorProto_resize_reserved_range(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) { - return (google_protobuf_DescriptorProto_ReservedRange**)_upb_array_resize_accessor(msg, UPB_SIZE(40, 80), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_add_reserved_range(google_protobuf_DescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_DescriptorProto_ReservedRange* sub = (struct google_protobuf_DescriptorProto_ReservedRange*)upb_msg_new(&google_protobuf_DescriptorProto_ReservedRange_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(40, 80), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} -UPB_INLINE upb_strview* google_protobuf_DescriptorProto_mutable_reserved_name(google_protobuf_DescriptorProto *msg, size_t *len) { - return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(44, 88), len); -} -UPB_INLINE upb_strview* google_protobuf_DescriptorProto_resize_reserved_name(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) { - return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(44, 88), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); -} -UPB_INLINE bool google_protobuf_DescriptorProto_add_reserved_name(google_protobuf_DescriptorProto *msg, upb_strview val, upb_arena *arena) { - return _upb_array_append_accessor( - msg, UPB_SIZE(44, 88), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); -} - -/* google.protobuf.DescriptorProto.ExtensionRange */ - -UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange *google_protobuf_DescriptorProto_ExtensionRange_new(upb_arena *arena) { - return (google_protobuf_DescriptorProto_ExtensionRange *)upb_msg_new(&google_protobuf_DescriptorProto_ExtensionRange_msginit, arena); -} -UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange *google_protobuf_DescriptorProto_ExtensionRange_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_DescriptorProto_ExtensionRange *ret = google_protobuf_DescriptorProto_ExtensionRange_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ExtensionRange_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_DescriptorProto_ExtensionRange_serialize(const google_protobuf_DescriptorProto_ExtensionRange *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_DescriptorProto_ExtensionRange_msginit, arena, len); -} - -UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_start(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_start(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)); } -UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_end(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_end(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); } -UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_options(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return _upb_has_field(msg, 3); } -UPB_INLINE const google_protobuf_ExtensionRangeOptions* google_protobuf_DescriptorProto_ExtensionRange_options(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return UPB_FIELD_AT(msg, const google_protobuf_ExtensionRangeOptions*, UPB_SIZE(12, 16)); } - -UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_start(google_protobuf_DescriptorProto_ExtensionRange *msg, int32_t value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)) = value; -} -UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_end(google_protobuf_DescriptorProto_ExtensionRange *msg, int32_t value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; -} -UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_options(google_protobuf_DescriptorProto_ExtensionRange *msg, google_protobuf_ExtensionRangeOptions* value) { - _upb_sethas(msg, 3); - UPB_FIELD_AT(msg, google_protobuf_ExtensionRangeOptions*, UPB_SIZE(12, 16)) = value; -} -UPB_INLINE struct google_protobuf_ExtensionRangeOptions* google_protobuf_DescriptorProto_ExtensionRange_mutable_options(google_protobuf_DescriptorProto_ExtensionRange *msg, upb_arena *arena) { - struct google_protobuf_ExtensionRangeOptions* sub = (struct google_protobuf_ExtensionRangeOptions*)google_protobuf_DescriptorProto_ExtensionRange_options(msg); - if (sub == NULL) { - sub = (struct google_protobuf_ExtensionRangeOptions*)upb_msg_new(&google_protobuf_ExtensionRangeOptions_msginit, arena); - if (!sub) return NULL; - google_protobuf_DescriptorProto_ExtensionRange_set_options(msg, sub); - } - return sub; -} - -/* google.protobuf.DescriptorProto.ReservedRange */ - -UPB_INLINE google_protobuf_DescriptorProto_ReservedRange *google_protobuf_DescriptorProto_ReservedRange_new(upb_arena *arena) { - return (google_protobuf_DescriptorProto_ReservedRange *)upb_msg_new(&google_protobuf_DescriptorProto_ReservedRange_msginit, arena); -} -UPB_INLINE google_protobuf_DescriptorProto_ReservedRange *google_protobuf_DescriptorProto_ReservedRange_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_DescriptorProto_ReservedRange *ret = google_protobuf_DescriptorProto_ReservedRange_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ReservedRange_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_DescriptorProto_ReservedRange_serialize(const google_protobuf_DescriptorProto_ReservedRange *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_DescriptorProto_ReservedRange_msginit, arena, len); -} - -UPB_INLINE bool google_protobuf_DescriptorProto_ReservedRange_has_start(const google_protobuf_DescriptorProto_ReservedRange *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_start(const google_protobuf_DescriptorProto_ReservedRange *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)); } -UPB_INLINE bool google_protobuf_DescriptorProto_ReservedRange_has_end(const google_protobuf_DescriptorProto_ReservedRange *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_end(const google_protobuf_DescriptorProto_ReservedRange *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); } - -UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_set_start(google_protobuf_DescriptorProto_ReservedRange *msg, int32_t value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)) = value; -} -UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_set_end(google_protobuf_DescriptorProto_ReservedRange *msg, int32_t value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; -} - -/* google.protobuf.ExtensionRangeOptions */ - -UPB_INLINE google_protobuf_ExtensionRangeOptions *google_protobuf_ExtensionRangeOptions_new(upb_arena *arena) { - return (google_protobuf_ExtensionRangeOptions *)upb_msg_new(&google_protobuf_ExtensionRangeOptions_msginit, arena); -} -UPB_INLINE google_protobuf_ExtensionRangeOptions *google_protobuf_ExtensionRangeOptions_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_ExtensionRangeOptions *ret = google_protobuf_ExtensionRangeOptions_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_ExtensionRangeOptions_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_ExtensionRangeOptions_serialize(const google_protobuf_ExtensionRangeOptions *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_ExtensionRangeOptions_msginit, arena, len); -} - -UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_ExtensionRangeOptions_uninterpreted_option(const google_protobuf_ExtensionRangeOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); } - -UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ExtensionRangeOptions_mutable_uninterpreted_option(google_protobuf_ExtensionRangeOptions *msg, size_t *len) { - return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len); -} -UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ExtensionRangeOptions_resize_uninterpreted_option(google_protobuf_ExtensionRangeOptions *msg, size_t len, upb_arena *arena) { - return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_ExtensionRangeOptions_add_uninterpreted_option(google_protobuf_ExtensionRangeOptions *msg, upb_arena *arena) { - struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} - -/* google.protobuf.FieldDescriptorProto */ - -UPB_INLINE google_protobuf_FieldDescriptorProto *google_protobuf_FieldDescriptorProto_new(upb_arena *arena) { - return (google_protobuf_FieldDescriptorProto *)upb_msg_new(&google_protobuf_FieldDescriptorProto_msginit, arena); -} -UPB_INLINE google_protobuf_FieldDescriptorProto *google_protobuf_FieldDescriptorProto_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_FieldDescriptorProto *ret = google_protobuf_FieldDescriptorProto_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_FieldDescriptorProto_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_FieldDescriptorProto_serialize(const google_protobuf_FieldDescriptorProto *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_FieldDescriptorProto_msginit, arena, len); -} - -UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_name(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 5); } -UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_name(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(32, 32)); } -UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_extendee(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 6); } -UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_extendee(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(40, 48)); } -UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_number(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 3); } -UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_number(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(24, 24)); } -UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_label(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_label(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); } -UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_type(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_type(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 16)); } -UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_type_name(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 7); } -UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_type_name(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(48, 64)); } -UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_default_value(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 8); } -UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_default_value(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(56, 80)); } -UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_options(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 10); } -UPB_INLINE const google_protobuf_FieldOptions* google_protobuf_FieldDescriptorProto_options(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_FieldOptions*, UPB_SIZE(72, 112)); } -UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_oneof_index(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 4); } -UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_oneof_index(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(28, 28)); } -UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_json_name(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 9); } -UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_json_name(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(64, 96)); } - -UPB_INLINE void google_protobuf_FieldDescriptorProto_set_name(google_protobuf_FieldDescriptorProto *msg, upb_strview value) { - _upb_sethas(msg, 5); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(32, 32)) = value; -} -UPB_INLINE void google_protobuf_FieldDescriptorProto_set_extendee(google_protobuf_FieldDescriptorProto *msg, upb_strview value) { - _upb_sethas(msg, 6); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(40, 48)) = value; -} -UPB_INLINE void google_protobuf_FieldDescriptorProto_set_number(google_protobuf_FieldDescriptorProto *msg, int32_t value) { - _upb_sethas(msg, 3); - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(24, 24)) = value; -} -UPB_INLINE void google_protobuf_FieldDescriptorProto_set_label(google_protobuf_FieldDescriptorProto *msg, int32_t value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; -} -UPB_INLINE void google_protobuf_FieldDescriptorProto_set_type(google_protobuf_FieldDescriptorProto *msg, int32_t value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 16)) = value; -} -UPB_INLINE void google_protobuf_FieldDescriptorProto_set_type_name(google_protobuf_FieldDescriptorProto *msg, upb_strview value) { - _upb_sethas(msg, 7); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(48, 64)) = value; -} -UPB_INLINE void google_protobuf_FieldDescriptorProto_set_default_value(google_protobuf_FieldDescriptorProto *msg, upb_strview value) { - _upb_sethas(msg, 8); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(56, 80)) = value; -} -UPB_INLINE void google_protobuf_FieldDescriptorProto_set_options(google_protobuf_FieldDescriptorProto *msg, google_protobuf_FieldOptions* value) { - _upb_sethas(msg, 10); - UPB_FIELD_AT(msg, google_protobuf_FieldOptions*, UPB_SIZE(72, 112)) = value; -} -UPB_INLINE struct google_protobuf_FieldOptions* google_protobuf_FieldDescriptorProto_mutable_options(google_protobuf_FieldDescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_FieldOptions* sub = (struct google_protobuf_FieldOptions*)google_protobuf_FieldDescriptorProto_options(msg); - if (sub == NULL) { - sub = (struct google_protobuf_FieldOptions*)upb_msg_new(&google_protobuf_FieldOptions_msginit, arena); - if (!sub) return NULL; - google_protobuf_FieldDescriptorProto_set_options(msg, sub); - } - return sub; -} -UPB_INLINE void google_protobuf_FieldDescriptorProto_set_oneof_index(google_protobuf_FieldDescriptorProto *msg, int32_t value) { - _upb_sethas(msg, 4); - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(28, 28)) = value; -} -UPB_INLINE void google_protobuf_FieldDescriptorProto_set_json_name(google_protobuf_FieldDescriptorProto *msg, upb_strview value) { - _upb_sethas(msg, 9); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(64, 96)) = value; -} - -/* google.protobuf.OneofDescriptorProto */ - -UPB_INLINE google_protobuf_OneofDescriptorProto *google_protobuf_OneofDescriptorProto_new(upb_arena *arena) { - return (google_protobuf_OneofDescriptorProto *)upb_msg_new(&google_protobuf_OneofDescriptorProto_msginit, arena); -} -UPB_INLINE google_protobuf_OneofDescriptorProto *google_protobuf_OneofDescriptorProto_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_OneofDescriptorProto *ret = google_protobuf_OneofDescriptorProto_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_OneofDescriptorProto_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_OneofDescriptorProto_serialize(const google_protobuf_OneofDescriptorProto *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_OneofDescriptorProto_msginit, arena, len); -} - -UPB_INLINE bool google_protobuf_OneofDescriptorProto_has_name(const google_protobuf_OneofDescriptorProto *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE upb_strview google_protobuf_OneofDescriptorProto_name(const google_protobuf_OneofDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } -UPB_INLINE bool google_protobuf_OneofDescriptorProto_has_options(const google_protobuf_OneofDescriptorProto *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE const google_protobuf_OneofOptions* google_protobuf_OneofDescriptorProto_options(const google_protobuf_OneofDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_OneofOptions*, UPB_SIZE(12, 24)); } - -UPB_INLINE void google_protobuf_OneofDescriptorProto_set_name(google_protobuf_OneofDescriptorProto *msg, upb_strview value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; -} -UPB_INLINE void google_protobuf_OneofDescriptorProto_set_options(google_protobuf_OneofDescriptorProto *msg, google_protobuf_OneofOptions* value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, google_protobuf_OneofOptions*, UPB_SIZE(12, 24)) = value; -} -UPB_INLINE struct google_protobuf_OneofOptions* google_protobuf_OneofDescriptorProto_mutable_options(google_protobuf_OneofDescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_OneofOptions* sub = (struct google_protobuf_OneofOptions*)google_protobuf_OneofDescriptorProto_options(msg); - if (sub == NULL) { - sub = (struct google_protobuf_OneofOptions*)upb_msg_new(&google_protobuf_OneofOptions_msginit, arena); - if (!sub) return NULL; - google_protobuf_OneofDescriptorProto_set_options(msg, sub); - } - return sub; -} - -/* google.protobuf.EnumDescriptorProto */ - -UPB_INLINE google_protobuf_EnumDescriptorProto *google_protobuf_EnumDescriptorProto_new(upb_arena *arena) { - return (google_protobuf_EnumDescriptorProto *)upb_msg_new(&google_protobuf_EnumDescriptorProto_msginit, arena); -} -UPB_INLINE google_protobuf_EnumDescriptorProto *google_protobuf_EnumDescriptorProto_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_EnumDescriptorProto *ret = google_protobuf_EnumDescriptorProto_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_EnumDescriptorProto_serialize(const google_protobuf_EnumDescriptorProto *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_EnumDescriptorProto_msginit, arena, len); -} - -UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_name(const google_protobuf_EnumDescriptorProto *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE upb_strview google_protobuf_EnumDescriptorProto_name(const google_protobuf_EnumDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } -UPB_INLINE const google_protobuf_EnumValueDescriptorProto* const* google_protobuf_EnumDescriptorProto_value(const google_protobuf_EnumDescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumValueDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len); } -UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_options(const google_protobuf_EnumDescriptorProto *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE const google_protobuf_EnumOptions* google_protobuf_EnumDescriptorProto_options(const google_protobuf_EnumDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_EnumOptions*, UPB_SIZE(12, 24)); } -UPB_INLINE const google_protobuf_EnumDescriptorProto_EnumReservedRange* const* google_protobuf_EnumDescriptorProto_reserved_range(const google_protobuf_EnumDescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumDescriptorProto_EnumReservedRange* const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len); } -UPB_INLINE upb_strview const* google_protobuf_EnumDescriptorProto_reserved_name(const google_protobuf_EnumDescriptorProto *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len); } - -UPB_INLINE void google_protobuf_EnumDescriptorProto_set_name(google_protobuf_EnumDescriptorProto *msg, upb_strview value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; -} -UPB_INLINE google_protobuf_EnumValueDescriptorProto** google_protobuf_EnumDescriptorProto_mutable_value(google_protobuf_EnumDescriptorProto *msg, size_t *len) { - return (google_protobuf_EnumValueDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len); -} -UPB_INLINE google_protobuf_EnumValueDescriptorProto** google_protobuf_EnumDescriptorProto_resize_value(google_protobuf_EnumDescriptorProto *msg, size_t len, upb_arena *arena) { - return (google_protobuf_EnumValueDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(16, 32), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_EnumValueDescriptorProto* google_protobuf_EnumDescriptorProto_add_value(google_protobuf_EnumDescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_EnumValueDescriptorProto* sub = (struct google_protobuf_EnumValueDescriptorProto*)upb_msg_new(&google_protobuf_EnumValueDescriptorProto_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(16, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} -UPB_INLINE void google_protobuf_EnumDescriptorProto_set_options(google_protobuf_EnumDescriptorProto *msg, google_protobuf_EnumOptions* value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, google_protobuf_EnumOptions*, UPB_SIZE(12, 24)) = value; -} -UPB_INLINE struct google_protobuf_EnumOptions* google_protobuf_EnumDescriptorProto_mutable_options(google_protobuf_EnumDescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_EnumOptions* sub = (struct google_protobuf_EnumOptions*)google_protobuf_EnumDescriptorProto_options(msg); - if (sub == NULL) { - sub = (struct google_protobuf_EnumOptions*)upb_msg_new(&google_protobuf_EnumOptions_msginit, arena); - if (!sub) return NULL; - google_protobuf_EnumDescriptorProto_set_options(msg, sub); - } - return sub; -} -UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange** google_protobuf_EnumDescriptorProto_mutable_reserved_range(google_protobuf_EnumDescriptorProto *msg, size_t *len) { - return (google_protobuf_EnumDescriptorProto_EnumReservedRange**)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 40), len); -} -UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange** google_protobuf_EnumDescriptorProto_resize_reserved_range(google_protobuf_EnumDescriptorProto *msg, size_t len, upb_arena *arena) { - return (google_protobuf_EnumDescriptorProto_EnumReservedRange**)_upb_array_resize_accessor(msg, UPB_SIZE(20, 40), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_EnumDescriptorProto_EnumReservedRange* google_protobuf_EnumDescriptorProto_add_reserved_range(google_protobuf_EnumDescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_EnumDescriptorProto_EnumReservedRange* sub = (struct google_protobuf_EnumDescriptorProto_EnumReservedRange*)upb_msg_new(&google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(20, 40), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} -UPB_INLINE upb_strview* google_protobuf_EnumDescriptorProto_mutable_reserved_name(google_protobuf_EnumDescriptorProto *msg, size_t *len) { - return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 48), len); -} -UPB_INLINE upb_strview* google_protobuf_EnumDescriptorProto_resize_reserved_name(google_protobuf_EnumDescriptorProto *msg, size_t len, upb_arena *arena) { - return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(24, 48), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); -} -UPB_INLINE bool google_protobuf_EnumDescriptorProto_add_reserved_name(google_protobuf_EnumDescriptorProto *msg, upb_strview val, upb_arena *arena) { - return _upb_array_append_accessor( - msg, UPB_SIZE(24, 48), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); -} - -/* google.protobuf.EnumDescriptorProto.EnumReservedRange */ - -UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange *google_protobuf_EnumDescriptorProto_EnumReservedRange_new(upb_arena *arena) { - return (google_protobuf_EnumDescriptorProto_EnumReservedRange *)upb_msg_new(&google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena); -} -UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange *google_protobuf_EnumDescriptorProto_EnumReservedRange_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_EnumDescriptorProto_EnumReservedRange *ret = google_protobuf_EnumDescriptorProto_EnumReservedRange_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_EnumDescriptorProto_EnumReservedRange_serialize(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena, len); -} - -UPB_INLINE bool google_protobuf_EnumDescriptorProto_EnumReservedRange_has_start(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE int32_t google_protobuf_EnumDescriptorProto_EnumReservedRange_start(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)); } -UPB_INLINE bool google_protobuf_EnumDescriptorProto_EnumReservedRange_has_end(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE int32_t google_protobuf_EnumDescriptorProto_EnumReservedRange_end(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); } - -UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_set_start(google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, int32_t value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)) = value; -} -UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_set_end(google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, int32_t value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; -} - -/* google.protobuf.EnumValueDescriptorProto */ - -UPB_INLINE google_protobuf_EnumValueDescriptorProto *google_protobuf_EnumValueDescriptorProto_new(upb_arena *arena) { - return (google_protobuf_EnumValueDescriptorProto *)upb_msg_new(&google_protobuf_EnumValueDescriptorProto_msginit, arena); -} -UPB_INLINE google_protobuf_EnumValueDescriptorProto *google_protobuf_EnumValueDescriptorProto_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_EnumValueDescriptorProto *ret = google_protobuf_EnumValueDescriptorProto_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumValueDescriptorProto_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_EnumValueDescriptorProto_serialize(const google_protobuf_EnumValueDescriptorProto *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_EnumValueDescriptorProto_msginit, arena, len); -} - -UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_name(const google_protobuf_EnumValueDescriptorProto *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE upb_strview google_protobuf_EnumValueDescriptorProto_name(const google_protobuf_EnumValueDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)); } -UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_number(const google_protobuf_EnumValueDescriptorProto *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE int32_t google_protobuf_EnumValueDescriptorProto_number(const google_protobuf_EnumValueDescriptorProto *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)); } -UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_options(const google_protobuf_EnumValueDescriptorProto *msg) { return _upb_has_field(msg, 3); } -UPB_INLINE const google_protobuf_EnumValueOptions* google_protobuf_EnumValueDescriptorProto_options(const google_protobuf_EnumValueDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_EnumValueOptions*, UPB_SIZE(16, 24)); } - -UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_name(google_protobuf_EnumValueDescriptorProto *msg, upb_strview value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)) = value; -} -UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_number(google_protobuf_EnumValueDescriptorProto *msg, int32_t value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)) = value; -} -UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_options(google_protobuf_EnumValueDescriptorProto *msg, google_protobuf_EnumValueOptions* value) { - _upb_sethas(msg, 3); - UPB_FIELD_AT(msg, google_protobuf_EnumValueOptions*, UPB_SIZE(16, 24)) = value; -} -UPB_INLINE struct google_protobuf_EnumValueOptions* google_protobuf_EnumValueDescriptorProto_mutable_options(google_protobuf_EnumValueDescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_EnumValueOptions* sub = (struct google_protobuf_EnumValueOptions*)google_protobuf_EnumValueDescriptorProto_options(msg); - if (sub == NULL) { - sub = (struct google_protobuf_EnumValueOptions*)upb_msg_new(&google_protobuf_EnumValueOptions_msginit, arena); - if (!sub) return NULL; - google_protobuf_EnumValueDescriptorProto_set_options(msg, sub); - } - return sub; -} - -/* google.protobuf.ServiceDescriptorProto */ - -UPB_INLINE google_protobuf_ServiceDescriptorProto *google_protobuf_ServiceDescriptorProto_new(upb_arena *arena) { - return (google_protobuf_ServiceDescriptorProto *)upb_msg_new(&google_protobuf_ServiceDescriptorProto_msginit, arena); -} -UPB_INLINE google_protobuf_ServiceDescriptorProto *google_protobuf_ServiceDescriptorProto_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_ServiceDescriptorProto *ret = google_protobuf_ServiceDescriptorProto_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_ServiceDescriptorProto_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_ServiceDescriptorProto_serialize(const google_protobuf_ServiceDescriptorProto *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_ServiceDescriptorProto_msginit, arena, len); -} - -UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_name(const google_protobuf_ServiceDescriptorProto *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE upb_strview google_protobuf_ServiceDescriptorProto_name(const google_protobuf_ServiceDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } -UPB_INLINE const google_protobuf_MethodDescriptorProto* const* google_protobuf_ServiceDescriptorProto_method(const google_protobuf_ServiceDescriptorProto *msg, size_t *len) { return (const google_protobuf_MethodDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len); } -UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_options(const google_protobuf_ServiceDescriptorProto *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE const google_protobuf_ServiceOptions* google_protobuf_ServiceDescriptorProto_options(const google_protobuf_ServiceDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_ServiceOptions*, UPB_SIZE(12, 24)); } - -UPB_INLINE void google_protobuf_ServiceDescriptorProto_set_name(google_protobuf_ServiceDescriptorProto *msg, upb_strview value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; -} -UPB_INLINE google_protobuf_MethodDescriptorProto** google_protobuf_ServiceDescriptorProto_mutable_method(google_protobuf_ServiceDescriptorProto *msg, size_t *len) { - return (google_protobuf_MethodDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len); -} -UPB_INLINE google_protobuf_MethodDescriptorProto** google_protobuf_ServiceDescriptorProto_resize_method(google_protobuf_ServiceDescriptorProto *msg, size_t len, upb_arena *arena) { - return (google_protobuf_MethodDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(16, 32), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_MethodDescriptorProto* google_protobuf_ServiceDescriptorProto_add_method(google_protobuf_ServiceDescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_MethodDescriptorProto* sub = (struct google_protobuf_MethodDescriptorProto*)upb_msg_new(&google_protobuf_MethodDescriptorProto_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(16, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} -UPB_INLINE void google_protobuf_ServiceDescriptorProto_set_options(google_protobuf_ServiceDescriptorProto *msg, google_protobuf_ServiceOptions* value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, google_protobuf_ServiceOptions*, UPB_SIZE(12, 24)) = value; -} -UPB_INLINE struct google_protobuf_ServiceOptions* google_protobuf_ServiceDescriptorProto_mutable_options(google_protobuf_ServiceDescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_ServiceOptions* sub = (struct google_protobuf_ServiceOptions*)google_protobuf_ServiceDescriptorProto_options(msg); - if (sub == NULL) { - sub = (struct google_protobuf_ServiceOptions*)upb_msg_new(&google_protobuf_ServiceOptions_msginit, arena); - if (!sub) return NULL; - google_protobuf_ServiceDescriptorProto_set_options(msg, sub); - } - return sub; -} - -/* google.protobuf.MethodDescriptorProto */ - -UPB_INLINE google_protobuf_MethodDescriptorProto *google_protobuf_MethodDescriptorProto_new(upb_arena *arena) { - return (google_protobuf_MethodDescriptorProto *)upb_msg_new(&google_protobuf_MethodDescriptorProto_msginit, arena); -} -UPB_INLINE google_protobuf_MethodDescriptorProto *google_protobuf_MethodDescriptorProto_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_MethodDescriptorProto *ret = google_protobuf_MethodDescriptorProto_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_MethodDescriptorProto_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_MethodDescriptorProto_serialize(const google_protobuf_MethodDescriptorProto *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_MethodDescriptorProto_msginit, arena, len); -} - -UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_name(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 3); } -UPB_INLINE upb_strview google_protobuf_MethodDescriptorProto_name(const google_protobuf_MethodDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } -UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_input_type(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 4); } -UPB_INLINE upb_strview google_protobuf_MethodDescriptorProto_input_type(const google_protobuf_MethodDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)); } -UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_output_type(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 5); } -UPB_INLINE upb_strview google_protobuf_MethodDescriptorProto_output_type(const google_protobuf_MethodDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(20, 40)); } -UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_options(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 6); } -UPB_INLINE const google_protobuf_MethodOptions* google_protobuf_MethodDescriptorProto_options(const google_protobuf_MethodDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_MethodOptions*, UPB_SIZE(28, 56)); } -UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_client_streaming(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE bool google_protobuf_MethodDescriptorProto_client_streaming(const google_protobuf_MethodDescriptorProto *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); } -UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_server_streaming(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE bool google_protobuf_MethodDescriptorProto_server_streaming(const google_protobuf_MethodDescriptorProto *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)); } - -UPB_INLINE void google_protobuf_MethodDescriptorProto_set_name(google_protobuf_MethodDescriptorProto *msg, upb_strview value) { - _upb_sethas(msg, 3); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; -} -UPB_INLINE void google_protobuf_MethodDescriptorProto_set_input_type(google_protobuf_MethodDescriptorProto *msg, upb_strview value) { - _upb_sethas(msg, 4); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)) = value; -} -UPB_INLINE void google_protobuf_MethodDescriptorProto_set_output_type(google_protobuf_MethodDescriptorProto *msg, upb_strview value) { - _upb_sethas(msg, 5); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(20, 40)) = value; -} -UPB_INLINE void google_protobuf_MethodDescriptorProto_set_options(google_protobuf_MethodDescriptorProto *msg, google_protobuf_MethodOptions* value) { - _upb_sethas(msg, 6); - UPB_FIELD_AT(msg, google_protobuf_MethodOptions*, UPB_SIZE(28, 56)) = value; -} -UPB_INLINE struct google_protobuf_MethodOptions* google_protobuf_MethodDescriptorProto_mutable_options(google_protobuf_MethodDescriptorProto *msg, upb_arena *arena) { - struct google_protobuf_MethodOptions* sub = (struct google_protobuf_MethodOptions*)google_protobuf_MethodDescriptorProto_options(msg); - if (sub == NULL) { - sub = (struct google_protobuf_MethodOptions*)upb_msg_new(&google_protobuf_MethodOptions_msginit, arena); - if (!sub) return NULL; - google_protobuf_MethodDescriptorProto_set_options(msg, sub); - } - return sub; -} -UPB_INLINE void google_protobuf_MethodDescriptorProto_set_client_streaming(google_protobuf_MethodDescriptorProto *msg, bool value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value; -} -UPB_INLINE void google_protobuf_MethodDescriptorProto_set_server_streaming(google_protobuf_MethodDescriptorProto *msg, bool value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)) = value; -} - -/* google.protobuf.FileOptions */ - -UPB_INLINE google_protobuf_FileOptions *google_protobuf_FileOptions_new(upb_arena *arena) { - return (google_protobuf_FileOptions *)upb_msg_new(&google_protobuf_FileOptions_msginit, arena); -} -UPB_INLINE google_protobuf_FileOptions *google_protobuf_FileOptions_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_FileOptions *ret = google_protobuf_FileOptions_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_FileOptions_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_FileOptions_serialize(const google_protobuf_FileOptions *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_FileOptions_msginit, arena, len); -} - -UPB_INLINE bool google_protobuf_FileOptions_has_java_package(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 11); } -UPB_INLINE upb_strview google_protobuf_FileOptions_java_package(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(28, 32)); } -UPB_INLINE bool google_protobuf_FileOptions_has_java_outer_classname(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 12); } -UPB_INLINE upb_strview google_protobuf_FileOptions_java_outer_classname(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(36, 48)); } -UPB_INLINE bool google_protobuf_FileOptions_has_optimize_for(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE int32_t google_protobuf_FileOptions_optimize_for(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); } -UPB_INLINE bool google_protobuf_FileOptions_has_java_multiple_files(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE bool google_protobuf_FileOptions_java_multiple_files(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(16, 16)); } -UPB_INLINE bool google_protobuf_FileOptions_has_go_package(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 13); } -UPB_INLINE upb_strview google_protobuf_FileOptions_go_package(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(44, 64)); } -UPB_INLINE bool google_protobuf_FileOptions_has_cc_generic_services(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 3); } -UPB_INLINE bool google_protobuf_FileOptions_cc_generic_services(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(17, 17)); } -UPB_INLINE bool google_protobuf_FileOptions_has_java_generic_services(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 4); } -UPB_INLINE bool google_protobuf_FileOptions_java_generic_services(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(18, 18)); } -UPB_INLINE bool google_protobuf_FileOptions_has_py_generic_services(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 5); } -UPB_INLINE bool google_protobuf_FileOptions_py_generic_services(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(19, 19)); } -UPB_INLINE bool google_protobuf_FileOptions_has_java_generate_equals_and_hash(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 6); } -UPB_INLINE bool google_protobuf_FileOptions_java_generate_equals_and_hash(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(20, 20)); } -UPB_INLINE bool google_protobuf_FileOptions_has_deprecated(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 7); } -UPB_INLINE bool google_protobuf_FileOptions_deprecated(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(21, 21)); } -UPB_INLINE bool google_protobuf_FileOptions_has_java_string_check_utf8(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 8); } -UPB_INLINE bool google_protobuf_FileOptions_java_string_check_utf8(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(22, 22)); } -UPB_INLINE bool google_protobuf_FileOptions_has_cc_enable_arenas(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 9); } -UPB_INLINE bool google_protobuf_FileOptions_cc_enable_arenas(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(23, 23)); } -UPB_INLINE bool google_protobuf_FileOptions_has_objc_class_prefix(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 14); } -UPB_INLINE upb_strview google_protobuf_FileOptions_objc_class_prefix(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(52, 80)); } -UPB_INLINE bool google_protobuf_FileOptions_has_csharp_namespace(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 15); } -UPB_INLINE upb_strview google_protobuf_FileOptions_csharp_namespace(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(60, 96)); } -UPB_INLINE bool google_protobuf_FileOptions_has_swift_prefix(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 16); } -UPB_INLINE upb_strview google_protobuf_FileOptions_swift_prefix(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(68, 112)); } -UPB_INLINE bool google_protobuf_FileOptions_has_php_class_prefix(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 17); } -UPB_INLINE upb_strview google_protobuf_FileOptions_php_class_prefix(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(76, 128)); } -UPB_INLINE bool google_protobuf_FileOptions_has_php_namespace(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 18); } -UPB_INLINE upb_strview google_protobuf_FileOptions_php_namespace(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(84, 144)); } -UPB_INLINE bool google_protobuf_FileOptions_has_php_generic_services(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 10); } -UPB_INLINE bool google_protobuf_FileOptions_php_generic_services(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(24, 24)); } -UPB_INLINE bool google_protobuf_FileOptions_has_php_metadata_namespace(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 19); } -UPB_INLINE upb_strview google_protobuf_FileOptions_php_metadata_namespace(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(92, 160)); } -UPB_INLINE bool google_protobuf_FileOptions_has_ruby_package(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 20); } -UPB_INLINE upb_strview google_protobuf_FileOptions_ruby_package(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(100, 176)); } -UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_FileOptions_uninterpreted_option(const google_protobuf_FileOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(108, 192), len); } - -UPB_INLINE void google_protobuf_FileOptions_set_java_package(google_protobuf_FileOptions *msg, upb_strview value) { - _upb_sethas(msg, 11); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(28, 32)) = value; -} -UPB_INLINE void google_protobuf_FileOptions_set_java_outer_classname(google_protobuf_FileOptions *msg, upb_strview value) { - _upb_sethas(msg, 12); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(36, 48)) = value; -} -UPB_INLINE void google_protobuf_FileOptions_set_optimize_for(google_protobuf_FileOptions *msg, int32_t value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; -} -UPB_INLINE void google_protobuf_FileOptions_set_java_multiple_files(google_protobuf_FileOptions *msg, bool value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, bool, UPB_SIZE(16, 16)) = value; -} -UPB_INLINE void google_protobuf_FileOptions_set_go_package(google_protobuf_FileOptions *msg, upb_strview value) { - _upb_sethas(msg, 13); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(44, 64)) = value; -} -UPB_INLINE void google_protobuf_FileOptions_set_cc_generic_services(google_protobuf_FileOptions *msg, bool value) { - _upb_sethas(msg, 3); - UPB_FIELD_AT(msg, bool, UPB_SIZE(17, 17)) = value; -} -UPB_INLINE void google_protobuf_FileOptions_set_java_generic_services(google_protobuf_FileOptions *msg, bool value) { - _upb_sethas(msg, 4); - UPB_FIELD_AT(msg, bool, UPB_SIZE(18, 18)) = value; -} -UPB_INLINE void google_protobuf_FileOptions_set_py_generic_services(google_protobuf_FileOptions *msg, bool value) { - _upb_sethas(msg, 5); - UPB_FIELD_AT(msg, bool, UPB_SIZE(19, 19)) = value; -} -UPB_INLINE void google_protobuf_FileOptions_set_java_generate_equals_and_hash(google_protobuf_FileOptions *msg, bool value) { - _upb_sethas(msg, 6); - UPB_FIELD_AT(msg, bool, UPB_SIZE(20, 20)) = value; -} -UPB_INLINE void google_protobuf_FileOptions_set_deprecated(google_protobuf_FileOptions *msg, bool value) { - _upb_sethas(msg, 7); - UPB_FIELD_AT(msg, bool, UPB_SIZE(21, 21)) = value; -} -UPB_INLINE void google_protobuf_FileOptions_set_java_string_check_utf8(google_protobuf_FileOptions *msg, bool value) { - _upb_sethas(msg, 8); - UPB_FIELD_AT(msg, bool, UPB_SIZE(22, 22)) = value; -} -UPB_INLINE void google_protobuf_FileOptions_set_cc_enable_arenas(google_protobuf_FileOptions *msg, bool value) { - _upb_sethas(msg, 9); - UPB_FIELD_AT(msg, bool, UPB_SIZE(23, 23)) = value; -} -UPB_INLINE void google_protobuf_FileOptions_set_objc_class_prefix(google_protobuf_FileOptions *msg, upb_strview value) { - _upb_sethas(msg, 14); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(52, 80)) = value; -} -UPB_INLINE void google_protobuf_FileOptions_set_csharp_namespace(google_protobuf_FileOptions *msg, upb_strview value) { - _upb_sethas(msg, 15); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(60, 96)) = value; -} -UPB_INLINE void google_protobuf_FileOptions_set_swift_prefix(google_protobuf_FileOptions *msg, upb_strview value) { - _upb_sethas(msg, 16); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(68, 112)) = value; -} -UPB_INLINE void google_protobuf_FileOptions_set_php_class_prefix(google_protobuf_FileOptions *msg, upb_strview value) { - _upb_sethas(msg, 17); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(76, 128)) = value; -} -UPB_INLINE void google_protobuf_FileOptions_set_php_namespace(google_protobuf_FileOptions *msg, upb_strview value) { - _upb_sethas(msg, 18); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(84, 144)) = value; -} -UPB_INLINE void google_protobuf_FileOptions_set_php_generic_services(google_protobuf_FileOptions *msg, bool value) { - _upb_sethas(msg, 10); - UPB_FIELD_AT(msg, bool, UPB_SIZE(24, 24)) = value; -} -UPB_INLINE void google_protobuf_FileOptions_set_php_metadata_namespace(google_protobuf_FileOptions *msg, upb_strview value) { - _upb_sethas(msg, 19); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(92, 160)) = value; -} -UPB_INLINE void google_protobuf_FileOptions_set_ruby_package(google_protobuf_FileOptions *msg, upb_strview value) { - _upb_sethas(msg, 20); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(100, 176)) = value; -} -UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FileOptions_mutable_uninterpreted_option(google_protobuf_FileOptions *msg, size_t *len) { - return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(108, 192), len); -} -UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FileOptions_resize_uninterpreted_option(google_protobuf_FileOptions *msg, size_t len, upb_arena *arena) { - return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(108, 192), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_FileOptions_add_uninterpreted_option(google_protobuf_FileOptions *msg, upb_arena *arena) { - struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(108, 192), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} - -/* google.protobuf.MessageOptions */ - -UPB_INLINE google_protobuf_MessageOptions *google_protobuf_MessageOptions_new(upb_arena *arena) { - return (google_protobuf_MessageOptions *)upb_msg_new(&google_protobuf_MessageOptions_msginit, arena); -} -UPB_INLINE google_protobuf_MessageOptions *google_protobuf_MessageOptions_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_MessageOptions *ret = google_protobuf_MessageOptions_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_MessageOptions_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_MessageOptions_serialize(const google_protobuf_MessageOptions *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_MessageOptions_msginit, arena, len); -} - -UPB_INLINE bool google_protobuf_MessageOptions_has_message_set_wire_format(const google_protobuf_MessageOptions *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE bool google_protobuf_MessageOptions_message_set_wire_format(const google_protobuf_MessageOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); } -UPB_INLINE bool google_protobuf_MessageOptions_has_no_standard_descriptor_accessor(const google_protobuf_MessageOptions *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE bool google_protobuf_MessageOptions_no_standard_descriptor_accessor(const google_protobuf_MessageOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)); } -UPB_INLINE bool google_protobuf_MessageOptions_has_deprecated(const google_protobuf_MessageOptions *msg) { return _upb_has_field(msg, 3); } -UPB_INLINE bool google_protobuf_MessageOptions_deprecated(const google_protobuf_MessageOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(3, 3)); } -UPB_INLINE bool google_protobuf_MessageOptions_has_map_entry(const google_protobuf_MessageOptions *msg) { return _upb_has_field(msg, 4); } -UPB_INLINE bool google_protobuf_MessageOptions_map_entry(const google_protobuf_MessageOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(4, 4)); } -UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_MessageOptions_uninterpreted_option(const google_protobuf_MessageOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(8, 8), len); } - -UPB_INLINE void google_protobuf_MessageOptions_set_message_set_wire_format(google_protobuf_MessageOptions *msg, bool value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value; -} -UPB_INLINE void google_protobuf_MessageOptions_set_no_standard_descriptor_accessor(google_protobuf_MessageOptions *msg, bool value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)) = value; -} -UPB_INLINE void google_protobuf_MessageOptions_set_deprecated(google_protobuf_MessageOptions *msg, bool value) { - _upb_sethas(msg, 3); - UPB_FIELD_AT(msg, bool, UPB_SIZE(3, 3)) = value; -} -UPB_INLINE void google_protobuf_MessageOptions_set_map_entry(google_protobuf_MessageOptions *msg, bool value) { - _upb_sethas(msg, 4); - UPB_FIELD_AT(msg, bool, UPB_SIZE(4, 4)) = value; -} -UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MessageOptions_mutable_uninterpreted_option(google_protobuf_MessageOptions *msg, size_t *len) { - return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(8, 8), len); -} -UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MessageOptions_resize_uninterpreted_option(google_protobuf_MessageOptions *msg, size_t len, upb_arena *arena) { - return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(8, 8), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_MessageOptions_add_uninterpreted_option(google_protobuf_MessageOptions *msg, upb_arena *arena) { - struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(8, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} - -/* google.protobuf.FieldOptions */ - -UPB_INLINE google_protobuf_FieldOptions *google_protobuf_FieldOptions_new(upb_arena *arena) { - return (google_protobuf_FieldOptions *)upb_msg_new(&google_protobuf_FieldOptions_msginit, arena); -} -UPB_INLINE google_protobuf_FieldOptions *google_protobuf_FieldOptions_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_FieldOptions *ret = google_protobuf_FieldOptions_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_FieldOptions_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_FieldOptions_serialize(const google_protobuf_FieldOptions *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_FieldOptions_msginit, arena, len); -} - -UPB_INLINE bool google_protobuf_FieldOptions_has_ctype(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE int32_t google_protobuf_FieldOptions_ctype(const google_protobuf_FieldOptions *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); } -UPB_INLINE bool google_protobuf_FieldOptions_has_packed(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 3); } -UPB_INLINE bool google_protobuf_FieldOptions_packed(const google_protobuf_FieldOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(24, 24)); } -UPB_INLINE bool google_protobuf_FieldOptions_has_deprecated(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 4); } -UPB_INLINE bool google_protobuf_FieldOptions_deprecated(const google_protobuf_FieldOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(25, 25)); } -UPB_INLINE bool google_protobuf_FieldOptions_has_lazy(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 5); } -UPB_INLINE bool google_protobuf_FieldOptions_lazy(const google_protobuf_FieldOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(26, 26)); } -UPB_INLINE bool google_protobuf_FieldOptions_has_jstype(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE int32_t google_protobuf_FieldOptions_jstype(const google_protobuf_FieldOptions *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 16)); } -UPB_INLINE bool google_protobuf_FieldOptions_has_weak(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 6); } -UPB_INLINE bool google_protobuf_FieldOptions_weak(const google_protobuf_FieldOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(27, 27)); } -UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_FieldOptions_uninterpreted_option(const google_protobuf_FieldOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(28, 32), len); } - -UPB_INLINE void google_protobuf_FieldOptions_set_ctype(google_protobuf_FieldOptions *msg, int32_t value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; -} -UPB_INLINE void google_protobuf_FieldOptions_set_packed(google_protobuf_FieldOptions *msg, bool value) { - _upb_sethas(msg, 3); - UPB_FIELD_AT(msg, bool, UPB_SIZE(24, 24)) = value; -} -UPB_INLINE void google_protobuf_FieldOptions_set_deprecated(google_protobuf_FieldOptions *msg, bool value) { - _upb_sethas(msg, 4); - UPB_FIELD_AT(msg, bool, UPB_SIZE(25, 25)) = value; -} -UPB_INLINE void google_protobuf_FieldOptions_set_lazy(google_protobuf_FieldOptions *msg, bool value) { - _upb_sethas(msg, 5); - UPB_FIELD_AT(msg, bool, UPB_SIZE(26, 26)) = value; -} -UPB_INLINE void google_protobuf_FieldOptions_set_jstype(google_protobuf_FieldOptions *msg, int32_t value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 16)) = value; -} -UPB_INLINE void google_protobuf_FieldOptions_set_weak(google_protobuf_FieldOptions *msg, bool value) { - _upb_sethas(msg, 6); - UPB_FIELD_AT(msg, bool, UPB_SIZE(27, 27)) = value; -} -UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FieldOptions_mutable_uninterpreted_option(google_protobuf_FieldOptions *msg, size_t *len) { - return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 32), len); -} -UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FieldOptions_resize_uninterpreted_option(google_protobuf_FieldOptions *msg, size_t len, upb_arena *arena) { - return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(28, 32), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_FieldOptions_add_uninterpreted_option(google_protobuf_FieldOptions *msg, upb_arena *arena) { - struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(28, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} - -/* google.protobuf.OneofOptions */ - -UPB_INLINE google_protobuf_OneofOptions *google_protobuf_OneofOptions_new(upb_arena *arena) { - return (google_protobuf_OneofOptions *)upb_msg_new(&google_protobuf_OneofOptions_msginit, arena); -} -UPB_INLINE google_protobuf_OneofOptions *google_protobuf_OneofOptions_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_OneofOptions *ret = google_protobuf_OneofOptions_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_OneofOptions_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_OneofOptions_serialize(const google_protobuf_OneofOptions *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_OneofOptions_msginit, arena, len); -} - -UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_OneofOptions_uninterpreted_option(const google_protobuf_OneofOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); } - -UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_OneofOptions_mutable_uninterpreted_option(google_protobuf_OneofOptions *msg, size_t *len) { - return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len); -} -UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_OneofOptions_resize_uninterpreted_option(google_protobuf_OneofOptions *msg, size_t len, upb_arena *arena) { - return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_OneofOptions_add_uninterpreted_option(google_protobuf_OneofOptions *msg, upb_arena *arena) { - struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} - -/* google.protobuf.EnumOptions */ - -UPB_INLINE google_protobuf_EnumOptions *google_protobuf_EnumOptions_new(upb_arena *arena) { - return (google_protobuf_EnumOptions *)upb_msg_new(&google_protobuf_EnumOptions_msginit, arena); -} -UPB_INLINE google_protobuf_EnumOptions *google_protobuf_EnumOptions_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_EnumOptions *ret = google_protobuf_EnumOptions_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumOptions_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_EnumOptions_serialize(const google_protobuf_EnumOptions *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_EnumOptions_msginit, arena, len); -} - -UPB_INLINE bool google_protobuf_EnumOptions_has_allow_alias(const google_protobuf_EnumOptions *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE bool google_protobuf_EnumOptions_allow_alias(const google_protobuf_EnumOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); } -UPB_INLINE bool google_protobuf_EnumOptions_has_deprecated(const google_protobuf_EnumOptions *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE bool google_protobuf_EnumOptions_deprecated(const google_protobuf_EnumOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)); } -UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_EnumOptions_uninterpreted_option(const google_protobuf_EnumOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); } - -UPB_INLINE void google_protobuf_EnumOptions_set_allow_alias(google_protobuf_EnumOptions *msg, bool value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value; -} -UPB_INLINE void google_protobuf_EnumOptions_set_deprecated(google_protobuf_EnumOptions *msg, bool value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)) = value; -} -UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumOptions_mutable_uninterpreted_option(google_protobuf_EnumOptions *msg, size_t *len) { - return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(4, 8), len); -} -UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumOptions_resize_uninterpreted_option(google_protobuf_EnumOptions *msg, size_t len, upb_arena *arena) { - return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(4, 8), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_EnumOptions_add_uninterpreted_option(google_protobuf_EnumOptions *msg, upb_arena *arena) { - struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(4, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} - -/* google.protobuf.EnumValueOptions */ - -UPB_INLINE google_protobuf_EnumValueOptions *google_protobuf_EnumValueOptions_new(upb_arena *arena) { - return (google_protobuf_EnumValueOptions *)upb_msg_new(&google_protobuf_EnumValueOptions_msginit, arena); -} -UPB_INLINE google_protobuf_EnumValueOptions *google_protobuf_EnumValueOptions_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_EnumValueOptions *ret = google_protobuf_EnumValueOptions_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumValueOptions_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_EnumValueOptions_serialize(const google_protobuf_EnumValueOptions *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_EnumValueOptions_msginit, arena, len); -} - -UPB_INLINE bool google_protobuf_EnumValueOptions_has_deprecated(const google_protobuf_EnumValueOptions *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE bool google_protobuf_EnumValueOptions_deprecated(const google_protobuf_EnumValueOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); } -UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_EnumValueOptions_uninterpreted_option(const google_protobuf_EnumValueOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); } - -UPB_INLINE void google_protobuf_EnumValueOptions_set_deprecated(google_protobuf_EnumValueOptions *msg, bool value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value; -} -UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumValueOptions_mutable_uninterpreted_option(google_protobuf_EnumValueOptions *msg, size_t *len) { - return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(4, 8), len); -} -UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumValueOptions_resize_uninterpreted_option(google_protobuf_EnumValueOptions *msg, size_t len, upb_arena *arena) { - return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(4, 8), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_EnumValueOptions_add_uninterpreted_option(google_protobuf_EnumValueOptions *msg, upb_arena *arena) { - struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(4, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} - -/* google.protobuf.ServiceOptions */ - -UPB_INLINE google_protobuf_ServiceOptions *google_protobuf_ServiceOptions_new(upb_arena *arena) { - return (google_protobuf_ServiceOptions *)upb_msg_new(&google_protobuf_ServiceOptions_msginit, arena); -} -UPB_INLINE google_protobuf_ServiceOptions *google_protobuf_ServiceOptions_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_ServiceOptions *ret = google_protobuf_ServiceOptions_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_ServiceOptions_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_ServiceOptions_serialize(const google_protobuf_ServiceOptions *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_ServiceOptions_msginit, arena, len); -} - -UPB_INLINE bool google_protobuf_ServiceOptions_has_deprecated(const google_protobuf_ServiceOptions *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE bool google_protobuf_ServiceOptions_deprecated(const google_protobuf_ServiceOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); } -UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_ServiceOptions_uninterpreted_option(const google_protobuf_ServiceOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); } - -UPB_INLINE void google_protobuf_ServiceOptions_set_deprecated(google_protobuf_ServiceOptions *msg, bool value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value; -} -UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ServiceOptions_mutable_uninterpreted_option(google_protobuf_ServiceOptions *msg, size_t *len) { - return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(4, 8), len); -} -UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ServiceOptions_resize_uninterpreted_option(google_protobuf_ServiceOptions *msg, size_t len, upb_arena *arena) { - return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(4, 8), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_ServiceOptions_add_uninterpreted_option(google_protobuf_ServiceOptions *msg, upb_arena *arena) { - struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(4, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} - -/* google.protobuf.MethodOptions */ - -UPB_INLINE google_protobuf_MethodOptions *google_protobuf_MethodOptions_new(upb_arena *arena) { - return (google_protobuf_MethodOptions *)upb_msg_new(&google_protobuf_MethodOptions_msginit, arena); -} -UPB_INLINE google_protobuf_MethodOptions *google_protobuf_MethodOptions_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_MethodOptions *ret = google_protobuf_MethodOptions_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_MethodOptions_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_MethodOptions_serialize(const google_protobuf_MethodOptions *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_MethodOptions_msginit, arena, len); -} - -UPB_INLINE bool google_protobuf_MethodOptions_has_deprecated(const google_protobuf_MethodOptions *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE bool google_protobuf_MethodOptions_deprecated(const google_protobuf_MethodOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(16, 16)); } -UPB_INLINE bool google_protobuf_MethodOptions_has_idempotency_level(const google_protobuf_MethodOptions *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE int32_t google_protobuf_MethodOptions_idempotency_level(const google_protobuf_MethodOptions *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); } -UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_MethodOptions_uninterpreted_option(const google_protobuf_MethodOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(20, 24), len); } - -UPB_INLINE void google_protobuf_MethodOptions_set_deprecated(google_protobuf_MethodOptions *msg, bool value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, bool, UPB_SIZE(16, 16)) = value; -} -UPB_INLINE void google_protobuf_MethodOptions_set_idempotency_level(google_protobuf_MethodOptions *msg, int32_t value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; -} -UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MethodOptions_mutable_uninterpreted_option(google_protobuf_MethodOptions *msg, size_t *len) { - return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 24), len); -} -UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MethodOptions_resize_uninterpreted_option(google_protobuf_MethodOptions *msg, size_t len, upb_arena *arena) { - return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(20, 24), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_MethodOptions_add_uninterpreted_option(google_protobuf_MethodOptions *msg, upb_arena *arena) { - struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(20, 24), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} - -/* google.protobuf.UninterpretedOption */ - -UPB_INLINE google_protobuf_UninterpretedOption *google_protobuf_UninterpretedOption_new(upb_arena *arena) { - return (google_protobuf_UninterpretedOption *)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); -} -UPB_INLINE google_protobuf_UninterpretedOption *google_protobuf_UninterpretedOption_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_UninterpretedOption *ret = google_protobuf_UninterpretedOption_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_UninterpretedOption_serialize(const google_protobuf_UninterpretedOption *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_UninterpretedOption_msginit, arena, len); -} - -UPB_INLINE const google_protobuf_UninterpretedOption_NamePart* const* google_protobuf_UninterpretedOption_name(const google_protobuf_UninterpretedOption *msg, size_t *len) { return (const google_protobuf_UninterpretedOption_NamePart* const*)_upb_array_accessor(msg, UPB_SIZE(56, 80), len); } -UPB_INLINE bool google_protobuf_UninterpretedOption_has_identifier_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 4); } -UPB_INLINE upb_strview google_protobuf_UninterpretedOption_identifier_value(const google_protobuf_UninterpretedOption *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(32, 32)); } -UPB_INLINE bool google_protobuf_UninterpretedOption_has_positive_int_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE uint64_t google_protobuf_UninterpretedOption_positive_int_value(const google_protobuf_UninterpretedOption *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(8, 8)); } -UPB_INLINE bool google_protobuf_UninterpretedOption_has_negative_int_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE int64_t google_protobuf_UninterpretedOption_negative_int_value(const google_protobuf_UninterpretedOption *msg) { return UPB_FIELD_AT(msg, int64_t, UPB_SIZE(16, 16)); } -UPB_INLINE bool google_protobuf_UninterpretedOption_has_double_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 3); } -UPB_INLINE double google_protobuf_UninterpretedOption_double_value(const google_protobuf_UninterpretedOption *msg) { return UPB_FIELD_AT(msg, double, UPB_SIZE(24, 24)); } -UPB_INLINE bool google_protobuf_UninterpretedOption_has_string_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 5); } -UPB_INLINE upb_strview google_protobuf_UninterpretedOption_string_value(const google_protobuf_UninterpretedOption *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(40, 48)); } -UPB_INLINE bool google_protobuf_UninterpretedOption_has_aggregate_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 6); } -UPB_INLINE upb_strview google_protobuf_UninterpretedOption_aggregate_value(const google_protobuf_UninterpretedOption *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(48, 64)); } - -UPB_INLINE google_protobuf_UninterpretedOption_NamePart** google_protobuf_UninterpretedOption_mutable_name(google_protobuf_UninterpretedOption *msg, size_t *len) { - return (google_protobuf_UninterpretedOption_NamePart**)_upb_array_mutable_accessor(msg, UPB_SIZE(56, 80), len); -} -UPB_INLINE google_protobuf_UninterpretedOption_NamePart** google_protobuf_UninterpretedOption_resize_name(google_protobuf_UninterpretedOption *msg, size_t len, upb_arena *arena) { - return (google_protobuf_UninterpretedOption_NamePart**)_upb_array_resize_accessor(msg, UPB_SIZE(56, 80), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_UninterpretedOption_NamePart* google_protobuf_UninterpretedOption_add_name(google_protobuf_UninterpretedOption *msg, upb_arena *arena) { - struct google_protobuf_UninterpretedOption_NamePart* sub = (struct google_protobuf_UninterpretedOption_NamePart*)upb_msg_new(&google_protobuf_UninterpretedOption_NamePart_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(56, 80), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} -UPB_INLINE void google_protobuf_UninterpretedOption_set_identifier_value(google_protobuf_UninterpretedOption *msg, upb_strview value) { - _upb_sethas(msg, 4); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(32, 32)) = value; -} -UPB_INLINE void google_protobuf_UninterpretedOption_set_positive_int_value(google_protobuf_UninterpretedOption *msg, uint64_t value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(8, 8)) = value; -} -UPB_INLINE void google_protobuf_UninterpretedOption_set_negative_int_value(google_protobuf_UninterpretedOption *msg, int64_t value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, int64_t, UPB_SIZE(16, 16)) = value; -} -UPB_INLINE void google_protobuf_UninterpretedOption_set_double_value(google_protobuf_UninterpretedOption *msg, double value) { - _upb_sethas(msg, 3); - UPB_FIELD_AT(msg, double, UPB_SIZE(24, 24)) = value; -} -UPB_INLINE void google_protobuf_UninterpretedOption_set_string_value(google_protobuf_UninterpretedOption *msg, upb_strview value) { - _upb_sethas(msg, 5); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(40, 48)) = value; -} -UPB_INLINE void google_protobuf_UninterpretedOption_set_aggregate_value(google_protobuf_UninterpretedOption *msg, upb_strview value) { - _upb_sethas(msg, 6); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(48, 64)) = value; -} - -/* google.protobuf.UninterpretedOption.NamePart */ - -UPB_INLINE google_protobuf_UninterpretedOption_NamePart *google_protobuf_UninterpretedOption_NamePart_new(upb_arena *arena) { - return (google_protobuf_UninterpretedOption_NamePart *)upb_msg_new(&google_protobuf_UninterpretedOption_NamePart_msginit, arena); -} -UPB_INLINE google_protobuf_UninterpretedOption_NamePart *google_protobuf_UninterpretedOption_NamePart_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_UninterpretedOption_NamePart *ret = google_protobuf_UninterpretedOption_NamePart_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_NamePart_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_UninterpretedOption_NamePart_serialize(const google_protobuf_UninterpretedOption_NamePart *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_UninterpretedOption_NamePart_msginit, arena, len); -} - -UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_has_name_part(const google_protobuf_UninterpretedOption_NamePart *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE upb_strview google_protobuf_UninterpretedOption_NamePart_name_part(const google_protobuf_UninterpretedOption_NamePart *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } -UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_has_is_extension(const google_protobuf_UninterpretedOption_NamePart *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_is_extension(const google_protobuf_UninterpretedOption_NamePart *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); } - -UPB_INLINE void google_protobuf_UninterpretedOption_NamePart_set_name_part(google_protobuf_UninterpretedOption_NamePart *msg, upb_strview value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; -} -UPB_INLINE void google_protobuf_UninterpretedOption_NamePart_set_is_extension(google_protobuf_UninterpretedOption_NamePart *msg, bool value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value; -} - -/* google.protobuf.SourceCodeInfo */ - -UPB_INLINE google_protobuf_SourceCodeInfo *google_protobuf_SourceCodeInfo_new(upb_arena *arena) { - return (google_protobuf_SourceCodeInfo *)upb_msg_new(&google_protobuf_SourceCodeInfo_msginit, arena); -} -UPB_INLINE google_protobuf_SourceCodeInfo *google_protobuf_SourceCodeInfo_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_SourceCodeInfo *ret = google_protobuf_SourceCodeInfo_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_SourceCodeInfo_serialize(const google_protobuf_SourceCodeInfo *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_SourceCodeInfo_msginit, arena, len); -} - -UPB_INLINE const google_protobuf_SourceCodeInfo_Location* const* google_protobuf_SourceCodeInfo_location(const google_protobuf_SourceCodeInfo *msg, size_t *len) { return (const google_protobuf_SourceCodeInfo_Location* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); } - -UPB_INLINE google_protobuf_SourceCodeInfo_Location** google_protobuf_SourceCodeInfo_mutable_location(google_protobuf_SourceCodeInfo *msg, size_t *len) { - return (google_protobuf_SourceCodeInfo_Location**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len); -} -UPB_INLINE google_protobuf_SourceCodeInfo_Location** google_protobuf_SourceCodeInfo_resize_location(google_protobuf_SourceCodeInfo *msg, size_t len, upb_arena *arena) { - return (google_protobuf_SourceCodeInfo_Location**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_SourceCodeInfo_Location* google_protobuf_SourceCodeInfo_add_location(google_protobuf_SourceCodeInfo *msg, upb_arena *arena) { - struct google_protobuf_SourceCodeInfo_Location* sub = (struct google_protobuf_SourceCodeInfo_Location*)upb_msg_new(&google_protobuf_SourceCodeInfo_Location_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} - -/* google.protobuf.SourceCodeInfo.Location */ - -UPB_INLINE google_protobuf_SourceCodeInfo_Location *google_protobuf_SourceCodeInfo_Location_new(upb_arena *arena) { - return (google_protobuf_SourceCodeInfo_Location *)upb_msg_new(&google_protobuf_SourceCodeInfo_Location_msginit, arena); -} -UPB_INLINE google_protobuf_SourceCodeInfo_Location *google_protobuf_SourceCodeInfo_Location_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_SourceCodeInfo_Location *ret = google_protobuf_SourceCodeInfo_Location_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_Location_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_SourceCodeInfo_Location_serialize(const google_protobuf_SourceCodeInfo_Location *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_SourceCodeInfo_Location_msginit, arena, len); -} - -UPB_INLINE int32_t const* google_protobuf_SourceCodeInfo_Location_path(const google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len); } -UPB_INLINE int32_t const* google_protobuf_SourceCodeInfo_Location_span(const google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len); } -UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_leading_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE upb_strview google_protobuf_SourceCodeInfo_Location_leading_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } -UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_trailing_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE upb_strview google_protobuf_SourceCodeInfo_Location_trailing_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)); } -UPB_INLINE upb_strview const* google_protobuf_SourceCodeInfo_Location_leading_detached_comments(const google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(28, 56), len); } - -UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_mutable_path(google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { - return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 40), len); -} -UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_resize_path(google_protobuf_SourceCodeInfo_Location *msg, size_t len, upb_arena *arena) { - return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(20, 40), len, UPB_SIZE(4, 4), UPB_TYPE_INT32, arena); -} -UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_path(google_protobuf_SourceCodeInfo_Location *msg, int32_t val, upb_arena *arena) { - return _upb_array_append_accessor( - msg, UPB_SIZE(20, 40), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val, arena); -} -UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_mutable_span(google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { - return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 48), len); -} -UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_resize_span(google_protobuf_SourceCodeInfo_Location *msg, size_t len, upb_arena *arena) { - return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(24, 48), len, UPB_SIZE(4, 4), UPB_TYPE_INT32, arena); -} -UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_span(google_protobuf_SourceCodeInfo_Location *msg, int32_t val, upb_arena *arena) { - return _upb_array_append_accessor( - msg, UPB_SIZE(24, 48), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val, arena); -} -UPB_INLINE void google_protobuf_SourceCodeInfo_Location_set_leading_comments(google_protobuf_SourceCodeInfo_Location *msg, upb_strview value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; -} -UPB_INLINE void google_protobuf_SourceCodeInfo_Location_set_trailing_comments(google_protobuf_SourceCodeInfo_Location *msg, upb_strview value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)) = value; -} -UPB_INLINE upb_strview* google_protobuf_SourceCodeInfo_Location_mutable_leading_detached_comments(google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { - return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 56), len); -} -UPB_INLINE upb_strview* google_protobuf_SourceCodeInfo_Location_resize_leading_detached_comments(google_protobuf_SourceCodeInfo_Location *msg, size_t len, upb_arena *arena) { - return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(28, 56), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); -} -UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_leading_detached_comments(google_protobuf_SourceCodeInfo_Location *msg, upb_strview val, upb_arena *arena) { - return _upb_array_append_accessor( - msg, UPB_SIZE(28, 56), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); -} - -/* google.protobuf.GeneratedCodeInfo */ - -UPB_INLINE google_protobuf_GeneratedCodeInfo *google_protobuf_GeneratedCodeInfo_new(upb_arena *arena) { - return (google_protobuf_GeneratedCodeInfo *)upb_msg_new(&google_protobuf_GeneratedCodeInfo_msginit, arena); -} -UPB_INLINE google_protobuf_GeneratedCodeInfo *google_protobuf_GeneratedCodeInfo_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_GeneratedCodeInfo *ret = google_protobuf_GeneratedCodeInfo_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_GeneratedCodeInfo_serialize(const google_protobuf_GeneratedCodeInfo *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_GeneratedCodeInfo_msginit, arena, len); -} - -UPB_INLINE const google_protobuf_GeneratedCodeInfo_Annotation* const* google_protobuf_GeneratedCodeInfo_annotation(const google_protobuf_GeneratedCodeInfo *msg, size_t *len) { return (const google_protobuf_GeneratedCodeInfo_Annotation* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); } - -UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation** google_protobuf_GeneratedCodeInfo_mutable_annotation(google_protobuf_GeneratedCodeInfo *msg, size_t *len) { - return (google_protobuf_GeneratedCodeInfo_Annotation**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len); -} -UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation** google_protobuf_GeneratedCodeInfo_resize_annotation(google_protobuf_GeneratedCodeInfo *msg, size_t len, upb_arena *arena) { - return (google_protobuf_GeneratedCodeInfo_Annotation**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); -} -UPB_INLINE struct google_protobuf_GeneratedCodeInfo_Annotation* google_protobuf_GeneratedCodeInfo_add_annotation(google_protobuf_GeneratedCodeInfo *msg, upb_arena *arena) { - struct google_protobuf_GeneratedCodeInfo_Annotation* sub = (struct google_protobuf_GeneratedCodeInfo_Annotation*)upb_msg_new(&google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena); - bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); - if (!ok) return NULL; - return sub; -} - -/* google.protobuf.GeneratedCodeInfo.Annotation */ - -UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation *google_protobuf_GeneratedCodeInfo_Annotation_new(upb_arena *arena) { - return (google_protobuf_GeneratedCodeInfo_Annotation *)upb_msg_new(&google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena); -} -UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation *google_protobuf_GeneratedCodeInfo_Annotation_parse(const char *buf, size_t size, - upb_arena *arena) { - google_protobuf_GeneratedCodeInfo_Annotation *ret = google_protobuf_GeneratedCodeInfo_Annotation_new(arena); - return (ret && upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena)) ? ret : NULL; -} -UPB_INLINE char *google_protobuf_GeneratedCodeInfo_Annotation_serialize(const google_protobuf_GeneratedCodeInfo_Annotation *msg, upb_arena *arena, size_t *len) { - return upb_encode(msg, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena, len); -} - -UPB_INLINE int32_t const* google_protobuf_GeneratedCodeInfo_Annotation_path(const google_protobuf_GeneratedCodeInfo_Annotation *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(20, 32), len); } -UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_source_file(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return _upb_has_field(msg, 3); } -UPB_INLINE upb_strview google_protobuf_GeneratedCodeInfo_Annotation_source_file(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 16)); } -UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_begin(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return _upb_has_field(msg, 1); } -UPB_INLINE int32_t google_protobuf_GeneratedCodeInfo_Annotation_begin(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)); } -UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_end(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return _upb_has_field(msg, 2); } -UPB_INLINE int32_t google_protobuf_GeneratedCodeInfo_Annotation_end(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); } - -UPB_INLINE int32_t* google_protobuf_GeneratedCodeInfo_Annotation_mutable_path(google_protobuf_GeneratedCodeInfo_Annotation *msg, size_t *len) { - return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 32), len); -} -UPB_INLINE int32_t* google_protobuf_GeneratedCodeInfo_Annotation_resize_path(google_protobuf_GeneratedCodeInfo_Annotation *msg, size_t len, upb_arena *arena) { - return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(20, 32), len, UPB_SIZE(4, 4), UPB_TYPE_INT32, arena); -} -UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_add_path(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t val, upb_arena *arena) { - return _upb_array_append_accessor( - msg, UPB_SIZE(20, 32), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val, arena); -} -UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_source_file(google_protobuf_GeneratedCodeInfo_Annotation *msg, upb_strview value) { - _upb_sethas(msg, 3); - UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 16)) = value; -} -UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_begin(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t value) { - _upb_sethas(msg, 1); - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)) = value; -} -UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_end(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t value) { - _upb_sethas(msg, 2); - UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; -} - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#include "upb/port_undef.inc" - -#endif /* GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_ */ diff --git a/src/core/ext/upb-generated/grpc/gcp/altscontext.upb.c b/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c similarity index 93% rename from src/core/ext/upb-generated/grpc/gcp/altscontext.upb.c rename to src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c index 52477e183dc..9ffd2fbb4c0 100644 --- a/src/core/ext/upb-generated/grpc/gcp/altscontext.upb.c +++ b/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c @@ -1,14 +1,14 @@ /* This file was generated by upbc (the upb compiler) from the input * file: * - * grpc/gcp/altscontext.proto + * src/proto/grpc/gcp/altscontext.proto * * Do not edit -- your changes will be discarded when the file is * regenerated. */ #include #include "upb/msg.h" -#include "grpc/gcp/altscontext.upb.h" +#include "src/proto/grpc/gcp/altscontext.upb.h" #include "src/proto/grpc/gcp/transport_security_common.upb.h" #include "upb/port_def.inc" diff --git a/src/core/ext/upb-generated/grpc/gcp/altscontext.upb.h b/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h similarity index 97% rename from src/core/ext/upb-generated/grpc/gcp/altscontext.upb.h rename to src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h index d9a4d58854d..ce32864cbc3 100644 --- a/src/core/ext/upb-generated/grpc/gcp/altscontext.upb.h +++ b/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h @@ -1,13 +1,13 @@ /* This file was generated by upbc (the upb compiler) from the input * file: * - * grpc/gcp/altscontext.proto + * src/proto/grpc/gcp/altscontext.proto * * Do not edit -- your changes will be discarded when the file is * regenerated. */ -#ifndef GRPC_GCP_ALTSCONTEXT_PROTO_UPB_H_ -#define GRPC_GCP_ALTSCONTEXT_PROTO_UPB_H_ +#ifndef SRC_PROTO_GRPC_GCP_ALTSCONTEXT_PROTO_UPB_H_ +#define SRC_PROTO_GRPC_GCP_ALTSCONTEXT_PROTO_UPB_H_ #include "upb/generated_util.h" #include "upb/msg.h" @@ -123,4 +123,4 @@ UPB_INLINE void grpc_gcp_AltsContext_PeerAttributesEntry_set_value(grpc_gcp_Alts #include "upb/port_undef.inc" -#endif /* GRPC_GCP_ALTSCONTEXT_PROTO_UPB_H_ */ +#endif /* SRC_PROTO_GRPC_GCP_ALTSCONTEXT_PROTO_UPB_H_ */ diff --git a/src/core/ext/upb-generated/grpc/gcp/handshaker.upb.c b/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c similarity index 98% rename from src/core/ext/upb-generated/grpc/gcp/handshaker.upb.c rename to src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c index 9e957538323..80f3a0a82dc 100644 --- a/src/core/ext/upb-generated/grpc/gcp/handshaker.upb.c +++ b/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c @@ -1,14 +1,14 @@ /* This file was generated by upbc (the upb compiler) from the input * file: * - * grpc/gcp/handshaker.proto + * src/proto/grpc/gcp/handshaker.proto * * Do not edit -- your changes will be discarded when the file is * regenerated. */ #include #include "upb/msg.h" -#include "grpc/gcp/handshaker.upb.h" +#include "src/proto/grpc/gcp/handshaker.upb.h" #include "src/proto/grpc/gcp/transport_security_common.upb.h" #include "upb/port_def.inc" diff --git a/src/core/ext/upb-generated/grpc/gcp/handshaker.upb.h b/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h similarity index 99% rename from src/core/ext/upb-generated/grpc/gcp/handshaker.upb.h rename to src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h index 97c8d44f45e..11a64324867 100644 --- a/src/core/ext/upb-generated/grpc/gcp/handshaker.upb.h +++ b/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h @@ -1,13 +1,13 @@ /* This file was generated by upbc (the upb compiler) from the input * file: * - * grpc/gcp/handshaker.proto + * src/proto/grpc/gcp/handshaker.proto * * Do not edit -- your changes will be discarded when the file is * regenerated. */ -#ifndef GRPC_GCP_HANDSHAKER_PROTO_UPB_H_ -#define GRPC_GCP_HANDSHAKER_PROTO_UPB_H_ +#ifndef SRC_PROTO_GRPC_GCP_HANDSHAKER_PROTO_UPB_H_ +#define SRC_PROTO_GRPC_GCP_HANDSHAKER_PROTO_UPB_H_ #include "upb/generated_util.h" #include "upb/msg.h" @@ -678,4 +678,4 @@ UPB_INLINE struct grpc_gcp_HandshakerStatus* grpc_gcp_HandshakerResp_mutable_sta #include "upb/port_undef.inc" -#endif /* GRPC_GCP_HANDSHAKER_PROTO_UPB_H_ */ +#endif /* SRC_PROTO_GRPC_GCP_HANDSHAKER_PROTO_UPB_H_ */ diff --git a/src/core/ext/upb-generated/grpc/gcp/transport_security_common.upb.c b/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c similarity index 89% rename from src/core/ext/upb-generated/grpc/gcp/transport_security_common.upb.c rename to src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c index 19859504b87..9b6303458e2 100644 --- a/src/core/ext/upb-generated/grpc/gcp/transport_security_common.upb.c +++ b/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c @@ -1,14 +1,14 @@ /* This file was generated by upbc (the upb compiler) from the input * file: * - * grpc/gcp/transport_security_common.proto + * src/proto/grpc/gcp/transport_security_common.proto * * Do not edit -- your changes will be discarded when the file is * regenerated. */ #include #include "upb/msg.h" -#include "grpc/gcp/transport_security_common.upb.h" +#include "src/proto/grpc/gcp/transport_security_common.upb.h" #include "upb/port_def.inc" diff --git a/src/core/ext/upb-generated/grpc/gcp/transport_security_common.upb.h b/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h similarity index 95% rename from src/core/ext/upb-generated/grpc/gcp/transport_security_common.upb.h rename to src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h index 14d4898b2ab..0e55e45f4fb 100644 --- a/src/core/ext/upb-generated/grpc/gcp/transport_security_common.upb.h +++ b/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h @@ -1,13 +1,13 @@ /* This file was generated by upbc (the upb compiler) from the input * file: * - * grpc/gcp/transport_security_common.proto + * src/proto/grpc/gcp/transport_security_common.proto * * Do not edit -- your changes will be discarded when the file is * regenerated. */ -#ifndef GRPC_GCP_TRANSPORT_SECURITY_COMMON_PROTO_UPB_H_ -#define GRPC_GCP_TRANSPORT_SECURITY_COMMON_PROTO_UPB_H_ +#ifndef SRC_PROTO_GRPC_GCP_TRANSPORT_SECURITY_COMMON_PROTO_UPB_H_ +#define SRC_PROTO_GRPC_GCP_TRANSPORT_SECURITY_COMMON_PROTO_UPB_H_ #include "upb/generated_util.h" #include "upb/msg.h" @@ -106,4 +106,4 @@ UPB_INLINE void grpc_gcp_RpcProtocolVersions_Version_set_minor(grpc_gcp_RpcProto #include "upb/port_undef.inc" -#endif /* GRPC_GCP_TRANSPORT_SECURITY_COMMON_PROTO_UPB_H_ */ +#endif /* SRC_PROTO_GRPC_GCP_TRANSPORT_SECURITY_COMMON_PROTO_UPB_H_ */ diff --git a/src/core/ext/upb-generated/grpc/health/v1/health.upb.c b/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c similarity index 89% rename from src/core/ext/upb-generated/grpc/health/v1/health.upb.c rename to src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c index e672d431005..8a3359bb769 100644 --- a/src/core/ext/upb-generated/grpc/health/v1/health.upb.c +++ b/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c @@ -1,14 +1,14 @@ /* This file was generated by upbc (the upb compiler) from the input * file: * - * grpc/health/v1/health.proto + * src/proto/grpc/health/v1/health.proto * * Do not edit -- your changes will be discarded when the file is * regenerated. */ #include #include "upb/msg.h" -#include "grpc/health/v1/health.upb.h" +#include "src/proto/grpc/health/v1/health.upb.h" #include "upb/port_def.inc" diff --git a/src/core/ext/upb-generated/grpc/health/v1/health.upb.h b/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h similarity index 94% rename from src/core/ext/upb-generated/grpc/health/v1/health.upb.h rename to src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h index 536e7d8131b..103b4ddbafc 100644 --- a/src/core/ext/upb-generated/grpc/health/v1/health.upb.h +++ b/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h @@ -1,13 +1,13 @@ /* This file was generated by upbc (the upb compiler) from the input * file: * - * grpc/health/v1/health.proto + * src/proto/grpc/health/v1/health.proto * * Do not edit -- your changes will be discarded when the file is * regenerated. */ -#ifndef GRPC_HEALTH_V1_HEALTH_PROTO_UPB_H_ -#define GRPC_HEALTH_V1_HEALTH_PROTO_UPB_H_ +#ifndef SRC_PROTO_GRPC_HEALTH_V1_HEALTH_PROTO_UPB_H_ +#define SRC_PROTO_GRPC_HEALTH_V1_HEALTH_PROTO_UPB_H_ #include "upb/generated_util.h" #include "upb/msg.h" @@ -81,4 +81,4 @@ UPB_INLINE void grpc_health_v1_HealthCheckResponse_set_status(grpc_health_v1_Hea #include "upb/port_undef.inc" -#endif /* GRPC_HEALTH_V1_HEALTH_PROTO_UPB_H_ */ +#endif /* SRC_PROTO_GRPC_HEALTH_V1_HEALTH_PROTO_UPB_H_ */ diff --git a/src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.c b/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c similarity index 97% rename from src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.c rename to src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c index 74a01dc8d98..75f07614920 100644 --- a/src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.c +++ b/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c @@ -1,14 +1,14 @@ /* This file was generated by upbc (the upb compiler) from the input * file: * - * grpc/lb/v1/load_balancer.proto + * src/proto/grpc/lb/v1/load_balancer.proto * * Do not edit -- your changes will be discarded when the file is * regenerated. */ #include #include "upb/msg.h" -#include "grpc/lb/v1/load_balancer.upb.h" +#include "src/proto/grpc/lb/v1/load_balancer.upb.h" #include "google/protobuf/duration.upb.h" #include "google/protobuf/timestamp.upb.h" diff --git a/src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.h b/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h similarity index 99% rename from src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.h rename to src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h index 398da3b71fe..64845660d17 100644 --- a/src/core/ext/upb-generated/grpc/lb/v1/load_balancer.upb.h +++ b/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h @@ -1,13 +1,13 @@ /* This file was generated by upbc (the upb compiler) from the input * file: * - * grpc/lb/v1/load_balancer.proto + * src/proto/grpc/lb/v1/load_balancer.proto * * Do not edit -- your changes will be discarded when the file is * regenerated. */ -#ifndef GRPC_LB_V1_LOAD_BALANCER_PROTO_UPB_H_ -#define GRPC_LB_V1_LOAD_BALANCER_PROTO_UPB_H_ +#ifndef SRC_PROTO_GRPC_LB_V1_LOAD_BALANCER_PROTO_UPB_H_ +#define SRC_PROTO_GRPC_LB_V1_LOAD_BALANCER_PROTO_UPB_H_ #include "upb/generated_util.h" #include "upb/msg.h" @@ -356,4 +356,4 @@ UPB_INLINE void grpc_lb_v1_Server_set_drop(grpc_lb_v1_Server *msg, bool value) { #include "upb/port_undef.inc" -#endif /* GRPC_LB_V1_LOAD_BALANCER_PROTO_UPB_H_ */ +#endif /* SRC_PROTO_GRPC_LB_V1_LOAD_BALANCER_PROTO_UPB_H_ */ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index aab3768b02e..95f1d0eea1d 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -316,7 +316,17 @@ CORE_SOURCE_FILES = [ 'third_party/nanopb/pb_common.c', 'third_party/nanopb/pb_decode.c', 'third_party/nanopb/pb_encode.c', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c', 'src/core/tsi/transport_security.cc', + 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', + 'third_party/upb/upb/decode.c', + 'third_party/upb/upb/encode.c', + 'third_party/upb/upb/msg.c', + 'third_party/upb/upb/port.c', + 'third_party/upb/upb/table.c', + 'third_party/upb/upb/upb.c', 'src/core/ext/transport/chttp2/client/insecure/channel_create.cc', 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc', 'src/core/ext/transport/chttp2/client/authority.cc', @@ -348,6 +358,7 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', + 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', 'src/core/ext/filters/client_channel/health/health.pb.c', 'src/core/tsi/fake_transport_security.cc', 'src/core/tsi/local_transport_security.cc', @@ -367,6 +378,13 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', + 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c', + 'src/core/ext/upb-generated/google/protobuf/any.upb.c', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c', diff --git a/src/ruby/ext/grpc/ext-export.clang b/src/ruby/ext/grpc/ext-export.clang new file mode 100644 index 00000000000..d568e8e40e0 --- /dev/null +++ b/src/ruby/ext/grpc/ext-export.clang @@ -0,0 +1 @@ +_Init_grpc_c diff --git a/src/ruby/ext/grpc/ext-export.gcc b/src/ruby/ext/grpc/ext-export.gcc new file mode 100644 index 00000000000..b9c8c560334 --- /dev/null +++ b/src/ruby/ext/grpc/ext-export.gcc @@ -0,0 +1,6 @@ +grpc_1.0 { + global: + Init_grpc_c; + local: + *; +}; \ No newline at end of file diff --git a/src/ruby/ext/grpc/extconf.rb b/src/ruby/ext/grpc/extconf.rb index 9950976eeb1..8cdd03f297e 100644 --- a/src/ruby/ext/grpc/extconf.rb +++ b/src/ruby/ext/grpc/extconf.rb @@ -60,6 +60,11 @@ unless windows end $CFLAGS << ' -I' + File.join(grpc_root, 'include') + +ext_export_file = File.join(grpc_root, 'src', 'ruby', 'ext', 'grpc', 'ext-export') +$LDFLAGS << ' -Wl,--version-script="' + ext_export_file + '.gcc"' if RUBY_PLATFORM =~ /linux/ +$LDFLAGS << ' -Wl,-exported_symbols_list,"' + ext_export_file + '.clang"' if RUBY_PLATFORM =~ /darwin/ + $LDFLAGS << ' ' + File.join(grpc_lib_dir, 'libgrpc.a') unless windows if grpc_config == 'gcov' $CFLAGS << ' -O0 -fprofile-arcs -ftest-coverage' diff --git a/src/upb/gen_build_yaml.py b/src/upb/gen_build_yaml.py index 181d026fbd2..0eb9eb1bd47 100755 --- a/src/upb/gen_build_yaml.py +++ b/src/upb/gen_build_yaml.py @@ -21,43 +21,37 @@ import os import sys import yaml +hdrs = [ + "third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.h", + "third_party/upb/upb/decode.h", + "third_party/upb/upb/encode.h", + "third_party/upb/upb/generated_util.h", + "third_party/upb/upb/msg.h", + "third_party/upb/upb/port_def.inc", + "third_party/upb/upb/port_undef.inc", + "third_party/upb/upb/table.int.h", + "third_party/upb/upb/upb.h", +] + srcs = [ "third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c", "third_party/upb/upb/decode.c", - "third_party/upb/upb/def.c", "third_party/upb/upb/encode.c", - "third_party/upb/upb/handlers.c", "third_party/upb/upb/msg.c", - "third_party/upb/upb/msgfactory.c", - "third_party/upb/upb/sink.c", + "third_party/upb/upb/port.c", "third_party/upb/upb/table.c", "third_party/upb/upb/upb.c", ] -hdrs = [ - "third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.h", - "third_party/upb/upb/decode.h", - "third_party/upb/upb/def.h", - "third_party/upb/upb/encode.h", - "third_party/upb/upb/handlers.h", - "third_party/upb/upb/msg.h", - "third_party/upb/upb/msgfactory.h", - "third_party/upb/upb/sink.h", - "third_party/upb/upb/upb.h", -] - -os.chdir(os.path.dirname(sys.argv[0])+'/../..') - out = {} try: - out['libs'] = [{ + out['filegroups'] = [{ 'name': 'upb', - 'defaults': 'upb', - 'build': 'private', - 'language': 'c', - 'secure': 'no', 'src': srcs, + 'uses': [ 'nanopb_headers' ], + }, { + 'name': 'upb_headers', 'headers': hdrs, }] except: diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index 87088abfc53..8d01540453c 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -186,14 +186,15 @@ set(_gRPC_CORE_NOSTDCXX_FLAGS "") endif() - include(cmake/zlib.cmake) + include(cmake/address_sorting.cmake) + include(cmake/benchmark.cmake) include(cmake/cares.cmake) + include(cmake/gflags.cmake) + include(cmake/nanopb.cmake) include(cmake/protobuf.cmake) include(cmake/ssl.cmake) - include(cmake/gflags.cmake) - include(cmake/benchmark.cmake) - include(cmake/address_sorting.cmake) - include(cmake/nanopb.cmake) + include(cmake/upb.cmake) + include(cmake/zlib.cmake) if(NOT MSVC) set(CMAKE_C_FLAGS "<%text>${CMAKE_C_FLAGS} -std=c99") @@ -426,14 +427,17 @@ target_include_directories(${lib.name} PUBLIC <%text>$ $ PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE <%text>${_gRPC_SSL_INCLUDE_DIR} - PRIVATE <%text>${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE <%text>${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE <%text>${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE <%text>${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE <%text>${_gRPC_CARES_INCLUDE_DIR} PRIVATE <%text>${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE <%text>${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE <%text>${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE <%text>${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE <%text>${_gRPC_SSL_INCLUDE_DIR} + PRIVATE <%text>${_gRPC_UPB_GENERATED_DIR} + PRIVATE <%text>${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE <%text>${_gRPC_UPB_INCLUDE_DIR} + PRIVATE <%text>${_gRPC_ZLIB_INCLUDE_DIR} % if lib.build in ['test', 'private'] and lib.language == 'c++': PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest @@ -522,14 +526,17 @@ target_include_directories(${tgt.name} PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR} PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE <%text>${_gRPC_SSL_INCLUDE_DIR} - PRIVATE <%text>${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE <%text>${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE <%text>${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE <%text>${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE <%text>${_gRPC_CARES_INCLUDE_DIR} PRIVATE <%text>${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE <%text>${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} PRIVATE <%text>${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE <%text>${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE <%text>${_gRPC_SSL_INCLUDE_DIR} + PRIVATE <%text>${_gRPC_UPB_GENERATED_DIR} + PRIVATE <%text>${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE <%text>${_gRPC_UPB_INCLUDE_DIR} + PRIVATE <%text>${_gRPC_ZLIB_INCLUDE_DIR} % if tgt.build in ['test', 'private'] and tgt.language == 'c++': PRIVATE third_party/googletest/googletest/include PRIVATE third_party/googletest/googletest diff --git a/templates/Makefile.template b/templates/Makefile.template index 21e1b6cd01c..c7f8a05739e 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -36,7 +36,7 @@ sources_that_don_t_need_openssl = set() # warnings we'd like, but that dont exist in all compilers - PREFERRED_WARNINGS=['shadow', 'extra-semi'] + PREFERRED_WARNINGS=['extra-semi'] CHECK_WARNINGS=PREFERRED_WARNINGS + ['no-shift-negative-value', 'no-unused-but-set-variable', 'no-maybe-uninitialized'] def warning_var(fmt, warning): @@ -216,7 +216,7 @@ HOST_LD ?= $(LD) HOST_LDXX ?= $(LDXX) - CFLAGS += -std=c99 -Wsign-conversion -Wconversion ${' '.join(warning_var('$(W_%s)', warning) for warning in PREFERRED_WARNINGS)} + CFLAGS += -std=c99 ${' '.join(warning_var('$(W_%s)', warning) for warning in PREFERRED_WARNINGS)} CXXFLAGS += -std=c++11 ifeq ($(SYSTEM),Darwin) CXXFLAGS += -stdlib=libc++ @@ -240,7 +240,7 @@ LDFLAGS += -fPIC endif - INCLUDES = . include $(GENDIR) third_party/upb third_party/upb/generated_for_cmake src/core/ext/upb-generated + INCLUDES = . include $(GENDIR) LDFLAGS += -Llibs/$(CONFIG) ifeq ($(SYSTEM),Darwin) diff --git a/templates/config.m4.template b/templates/config.m4.template index 18378cfc34d..db55a34d84c 100644 --- a/templates/config.m4.template +++ b/templates/config.m4.template @@ -8,10 +8,13 @@ dnl # --with-grpc -> add include path PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/include) + PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/core/ext/upb-generated) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/php/ext/grpc) - PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/boringssl/include) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/address_sorting/include) + PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/boringssl/include) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/nanopb) + PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/upb) + PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/upb/generated_for_cmake) LIBS="-lpthread $LIBS" diff --git a/templates/config.w32.template b/templates/config.w32.template index 5e37cf568c2..b9e9acd1ec1 100644 --- a/templates/config.w32.template +++ b/templates/config.w32.template @@ -26,11 +26,14 @@ "/DPB_FIELD_32BIT "+ "/I"+configure_module_dirname+" "+ "/I"+configure_module_dirname+"\\include "+ + "/I"+configure_module_dirname+"\\src\\core\\ext\\upb-generated "+ "/I"+configure_module_dirname+"\\src\\php\\ext\\grpc "+ - "/I"+configure_module_dirname+"\\third_party\\boringssl\\include "+ - "/I"+configure_module_dirname+"\\third_party\\zlib "+ "/I"+configure_module_dirname+"\\third_party\\address_sorting\\include "+ - "/I"+configure_module_dirname+"\\third_party\\nanopb"); + "/I"+configure_module_dirname+"\\third_party\\boringssl\\include "+ + "/I"+configure_module_dirname+"\\third_party\\nanopb "+ + "/I"+configure_module_dirname+"\\third_party\\upb "+ + "/I"+configure_module_dirname+"\\third_party\\upb\\generated_for_cmake "+ + "/I"+configure_module_dirname+"\\third_party\\zlib "); <% dirs = {} for lib in libs: diff --git a/templates/gRPC-C++.podspec.template b/templates/gRPC-C++.podspec.template index 9ecdf80143e..1ec2d877542 100644 --- a/templates/gRPC-C++.podspec.template +++ b/templates/gRPC-C++.podspec.template @@ -227,5 +227,11 @@ find src/cpp/ -type f -path '*.grpc_back' -print0 | xargs -0 rm find src/core/ -type f ! -path '*.grpc_back' -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(pb(_.*)?\\.h)";#include ;g' find src/core/ -type f -path '*.grpc_back' -print0 | xargs -0 rm + find src/core/ third_party/upb/ -type f \\( -name '*.h' -or -name '*.c' -or -name '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "upb/(.*)";#if COCOAPODS==1\\\n #include "third_party/upb/upb/\\1"\\\n#else\\\n #include "upb/\\1"\\\n#endif;g' + find src/core/ third_party/upb/ -type f -name '*.grpc_back' -print0 | xargs -0 rm + find src/core/ src/cpp/ -type f \\( -name '*.h' -or -name '*.c' -or -name '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(.*).upb.h";#if COCOAPODS==1\\\n #include "src/core/ext/upb-generated/\\1.upb.h"\\\n#else\\\n #include "\\1.upb.h"\\\n#endif;g' + find src/core/ src/cpp/ -type f -name '*.grpc_back' -print0 | xargs -0 rm + find third_party/upb/ -type f \\( -name '*.h' -or -name '*.c' -or -name '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(.*).upb.h";#if COCOAPODS==1\\\n #include "third_party/upb/generated_for_cmake/\\1.upb.h"\\\n#else\\\n #include "\\1.upb.h"\\\n#endif;g' + find third_party/upb/ -type f -name '*.grpc_back' -print0 | xargs -0 rm END_OF_COMMAND end diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template index 0ed3b8399b5..9d4f1b4d4a0 100644 --- a/templates/gRPC-Core.podspec.template +++ b/templates/gRPC-Core.podspec.template @@ -214,5 +214,11 @@ s.prepare_command = <<-END_OF_COMMAND sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS==1\\\n #include \\\n#else\\\n #include "\\1"\\\n#endif;g' $(find src/core -type f -print | xargs grep -H -c '#include ;#if COCOAPODS==1\\\n #include \\\n#else\\\n #include \\\n#endif;g' $(find src/core -type f \\( -path '*.h' -or -path '*.cc' \\) -print | xargs grep -H -c '#include "$want_submodules" 9245d481eb3e890f708ff2d7dadf2a10c04748ba third_party/libcxxabi (heads/release_60) 09745575a923640154bcf307fba8aedff47f240a third_party/protobuf (v3.7.0-rc.2-247-g09745575) e143189bf6f37b3957fb31743df6a1bcf4a8c685 third_party/protoc-gen-validate (v0.0.10) - 423ea5ca9ce8da69611e6e95559efcb3a1ba8ad8 third_party/upb (heads/master) + b70f68269a7d51c5ce372a93742bf6960215ffef third_party/upb (heads/master) cacf7f1d4e3d44d871b605da3b647f07d718623f third_party/zlib (v1.2.11) EOF From bc83ccd08b80d8e9b2854715d2b5c97a7e50c3b7 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 6 Aug 2019 15:37:18 -0700 Subject: [PATCH 1127/1555] Log goaway only if it ended with an non NO_ERROR code --- src/core/ext/transport/chttp2/transport/chttp2_transport.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 633b35e7d61..791caaf4ba5 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -1155,8 +1155,10 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t, gpr_log(GPR_INFO, "transport %p got goaway with last stream id %d", t, last_stream_id)); /* We want to log this irrespective of whether http tracing is enabled */ - gpr_log(GPR_INFO, "%s: Got goaway [%d] err=%s", t->peer_string, goaway_error, - grpc_error_string(t->goaway_error)); + if (goaway_error != GRPC_HTTP2_NO_ERROR) { + gpr_log(GPR_INFO, "%s: Got goaway [%d] err=%s", t->peer_string, + goaway_error, grpc_error_string(t->goaway_error)); + } /* When a client receives a GOAWAY with error code ENHANCE_YOUR_CALM and debug * data equal to "too_many_pings", it should log the occurrence at a log level From 308ce6b64a4c50b9699c39a92f84f85e0fd70b49 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 6 Aug 2019 15:46:01 -0700 Subject: [PATCH 1128/1555] Reviewer comments --- src/core/ext/transport/chttp2/transport/chttp2_transport.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 791caaf4ba5..578300e559b 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -1154,7 +1154,8 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t, GRPC_CHTTP2_IF_TRACING( gpr_log(GPR_INFO, "transport %p got goaway with last stream id %d", t, last_stream_id)); - /* We want to log this irrespective of whether http tracing is enabled */ + /* We want to log this irrespective of whether http tracing is enabled if we + * received a GOAWAY with a non NO_ERROR code. */ if (goaway_error != GRPC_HTTP2_NO_ERROR) { gpr_log(GPR_INFO, "%s: Got goaway [%d] err=%s", t->peer_string, goaway_error, grpc_error_string(t->goaway_error)); From 04fa4328316a70fe776930582f810c5447a95ff2 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 6 Aug 2019 16:12:51 -0700 Subject: [PATCH 1129/1555] Fail SEND_MESSAGE ops if stream is closed for writes --- .../chttp2/transport/chttp2_transport.cc | 16 +++++----------- src/core/lib/surface/call.cc | 6 ++++++ src/core/lib/transport/transport.h | 12 ++++++++++++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 633b35e7d61..1a1c03208eb 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -1532,19 +1532,13 @@ static void perform_stream_op_locked(void* stream_op, on_complete->next_data.scratch |= CLOSURE_BARRIER_MAY_COVER_WRITE; s->fetching_send_message_finished = add_closure_barrier(op->on_complete); if (s->write_closed) { - // Return an error unless the client has already received trailing - // metadata from the server, since an application using a - // streaming call might send another message before getting a - // recv_message failure, breaking out of its loop, and then - // starting recv_trailing_metadata. + op->payload->send_message.stream_write_closed = true; + // We should NOT return an error here, so as to avoid a cancel OP being + // started. The surface layer will notice that the stream has been closed + // for writes and fail the send message op. op->payload->send_message.send_message.reset(); grpc_chttp2_complete_closure_step( - t, s, &s->fetching_send_message_finished, - t->is_client && s->received_trailing_metadata - ? GRPC_ERROR_NONE - : GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( - "Attempt to send message after stream was closed", - &s->write_closed_error, 1), + t, s, &s->fetching_send_message_finished, GRPC_ERROR_NONE, "fetching_send_message_finished"); } else { GPR_ASSERT(s->fetching_send_message == nullptr); diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 13b1d126393..378d148c674 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -1175,6 +1175,12 @@ static void post_batch_completion(batch_control* bctl) { &call->metadata_batch[0 /* is_receiving */][0 /* is_trailing */]); } if (bctl->op.send_message) { + if (bctl->op.payload->send_message.stream_write_closed && + error == GRPC_ERROR_NONE) { + error = grpc_error_add_child( + error, GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "Attempt to send message after stream was closed.")); + } call->sending_message = false; } if (bctl->op.send_trailing_metadata) { diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h index 17608f4bc60..c40b290d535 100644 --- a/src/core/lib/transport/transport.h +++ b/src/core/lib/transport/transport.h @@ -245,6 +245,18 @@ struct grpc_transport_stream_op_batch_payload { // The batch's on_complete will not be called until after the byte // stream is orphaned. grpc_core::OrphanablePtr send_message; + // Set by the transport if the stream has been closed for writes. If this + // is set and send message op is present, we set the operation to be a + // failure without sending a cancel OP down the stack. This is so that the + // status of the call does not get overwritten by the Cancel OP, which would + // be especially problematic if we had received a valid status from the + // server. + // For send_initial_metadata, it is fine for the status to be overwritten + // because at that point, the client will not have received a status. + // For send_trailing_metadata, we might overwrite the status if we have + // non-zero metadata to send. This is fine because the API does not allow + // the client to send trailing metadata. + bool stream_write_closed = false; } send_message; struct { From fc76cc0d1e9972893816c59671e867c4483f0025 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 6 Aug 2019 16:28:58 -0700 Subject: [PATCH 1130/1555] Remove received_trailing_metadata since it's no longer used --- src/core/ext/transport/chttp2/transport/internal.h | 2 -- src/core/ext/transport/chttp2/transport/parsing.cc | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 643cd25b8bd..2204691726a 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -564,8 +564,6 @@ struct grpc_chttp2_stream { /** Are we buffering writes on this stream? If yes, we won't become writable until there's enough queued up in the flow_controlled_buffer */ bool write_buffering = false; - /** Has trailing metadata been received. */ - bool received_trailing_metadata = false; /* have we sent or received the EOS bit? */ bool eos_received = false; diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index 796f63573c0..c1b226c5fb3 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -648,7 +648,6 @@ static grpc_error* init_header_frame_parser(grpc_chttp2_transport* t, *s->trailing_metadata_available = true; } t->hpack_parser.on_header = on_trailing_header; - s->received_trailing_metadata = true; } else { GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_INFO, "parsing initial_metadata")); t->hpack_parser.on_header = on_initial_header; @@ -657,7 +656,6 @@ static grpc_error* init_header_frame_parser(grpc_chttp2_transport* t, case 1: GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_INFO, "parsing trailing_metadata")); t->hpack_parser.on_header = on_trailing_header; - s->received_trailing_metadata = true; break; case 2: gpr_log(GPR_ERROR, "too many header frames received"); From 8dfa3c2255bdbf9075e20c0850754bde57a1c15f Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 6 Aug 2019 17:40:02 -0700 Subject: [PATCH 1131/1555] Remove upb targets from BUILD --- BUILD | 3 - BUILD.gn | 31 ------- CMakeLists.txt | 83 +++--------------- Makefile | 86 +++---------------- build.yaml | 7 -- config.m4 | 15 ---- config.w32 | 22 ----- gRPC-C++.podspec | 12 --- gRPC-Core.podspec | 33 ------- grpc.gemspec | 22 ----- grpc.gyp | 65 ++------------ package.xml | 22 ----- src/python/grpcio/grpc_core_dependencies.py | 11 --- tools/doxygen/Doxyfile.c++.internal | 11 +-- tools/doxygen/Doxyfile.core.internal | 22 ----- .../generated/sources_and_headers.json | 7 -- 16 files changed, 36 insertions(+), 416 deletions(-) diff --git a/BUILD b/BUILD index 5da2eda36a3..d42572b6559 100644 --- a/BUILD +++ b/BUILD @@ -1064,7 +1064,6 @@ grpc_cc_library( "grpc_base", "grpc_client_authority_filter", "grpc_deadline_filter", - "grpc_health_upb", "health_proto", "inlined_vector", "orphanable", @@ -2002,7 +2001,6 @@ grpc_cc_library( deps = [ "grpc", "grpc++_codegen_base", - "grpc_health_upb", "health_proto", ], ) @@ -2015,7 +2013,6 @@ grpc_cc_library( public_hdrs = GRPCXX_PUBLIC_HDRS, deps = [ "grpc++_codegen_base", - "grpc_health_upb", "grpc_unsecure", "health_proto", ], diff --git a/BUILD.gn b/BUILD.gn index 5e76bc64065..1ee7929c0cb 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -429,28 +429,6 @@ config("grpc_config") { "src/core/ext/transport/inproc/inproc_plugin.cc", "src/core/ext/transport/inproc/inproc_transport.cc", "src/core/ext/transport/inproc/inproc_transport.h", - "src/core/ext/upb-generated/google/protobuf/any.upb.c", - "src/core/ext/upb-generated/google/protobuf/any.upb.h", - "src/core/ext/upb-generated/google/protobuf/duration.upb.c", - "src/core/ext/upb-generated/google/protobuf/duration.upb.h", - "src/core/ext/upb-generated/google/protobuf/empty.upb.c", - "src/core/ext/upb-generated/google/protobuf/empty.upb.h", - "src/core/ext/upb-generated/google/protobuf/struct.upb.c", - "src/core/ext/upb-generated/google/protobuf/struct.upb.h", - "src/core/ext/upb-generated/google/protobuf/timestamp.upb.c", - "src/core/ext/upb-generated/google/protobuf/timestamp.upb.h", - "src/core/ext/upb-generated/google/protobuf/wrappers.upb.c", - "src/core/ext/upb-generated/google/protobuf/wrappers.upb.h", - "src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c", - "src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h", - "src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c", - "src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h", - "src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c", - "src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h", - "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c", - "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h", - "src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c", - "src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h", "src/core/lib/avl/avl.cc", "src/core/lib/avl/avl.h", "src/core/lib/backoff/backoff.cc", @@ -1191,8 +1169,6 @@ config("grpc_config") { "include/grpcpp/support/time.h", "include/grpcpp/support/validate_service_config.h", "src/core/ext/transport/inproc/inproc_transport.h", - "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c", - "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h", "src/core/lib/avl/avl.h", "src/core/lib/backoff/backoff.h", "src/core/lib/channel/channel_args.h", @@ -1422,13 +1398,6 @@ config("grpc_config") { "src/cpp/util/status.cc", "src/cpp/util/string_ref.cc", "src/cpp/util/time_cc.cc", - "third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c", - "third_party/upb/upb/decode.c", - "third_party/upb/upb/encode.c", - "third_party/upb/upb/msg.c", - "third_party/upb/upb/port.c", - "third_party/upb/upb/table.c", - "third_party/upb/upb/upb.c", ] deps = [ "//third_party/boringssl", diff --git a/CMakeLists.txt b/CMakeLists.txt index cf31e17beb1..68d3ade6519 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1265,9 +1265,6 @@ add_library(grpc third_party/nanopb/pb_common.c third_party/nanopb/pb_decode.c third_party/nanopb/pb_encode.c - src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c - src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c - src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c src/core/tsi/transport_security.cc third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c third_party/upb/upb/decode.c @@ -1307,7 +1304,6 @@ add_library(grpc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc - src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c src/core/ext/filters/client_channel/health/health.pb.c src/core/tsi/fake_transport_security.cc src/core/tsi/local_transport_security.cc @@ -1327,13 +1323,6 @@ add_library(grpc src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc - src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c - src/core/ext/upb-generated/google/protobuf/any.upb.c - src/core/ext/upb-generated/google/protobuf/duration.upb.c - src/core/ext/upb-generated/google/protobuf/empty.upb.c - src/core/ext/upb-generated/google/protobuf/struct.upb.c - src/core/ext/upb-generated/google/protobuf/timestamp.upb.c - src/core/ext/upb-generated/google/protobuf/wrappers.upb.c src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c @@ -1688,14 +1677,6 @@ add_library(grpc_cronet src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc - src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c - third_party/upb/upb/decode.c - third_party/upb/upb/encode.c - third_party/upb/upb/msg.c - third_party/upb/upb/port.c - third_party/upb/upb/table.c - third_party/upb/upb/upb.c src/core/ext/filters/client_channel/health/health.pb.c third_party/nanopb/pb_common.c third_party/nanopb/pb_decode.c @@ -1767,10 +1748,14 @@ add_library(grpc_cronet src/core/tsi/alts/handshaker/altscontext.pb.c src/core/tsi/alts/handshaker/handshaker.pb.c src/core/tsi/alts/handshaker/transport_security_common.pb.c - src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c - src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c - src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c src/core/tsi/transport_security.cc + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c + third_party/upb/upb/decode.c + third_party/upb/upb/encode.c + third_party/upb/upb/msg.c + third_party/upb/upb/port.c + third_party/upb/upb/table.c + third_party/upb/upb/upb.c src/core/ext/transport/chttp2/client/insecure/channel_create.cc src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc src/core/ext/transport/chttp2/client/authority.cc @@ -2091,14 +2076,6 @@ add_library(grpc_test_util src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc - src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c - third_party/upb/upb/decode.c - third_party/upb/upb/encode.c - third_party/upb/upb/msg.c - third_party/upb/upb/port.c - third_party/upb/upb/table.c - third_party/upb/upb/upb.c src/core/ext/filters/client_channel/health/health.pb.c third_party/nanopb/pb_common.c third_party/nanopb/pb_decode.c @@ -2437,14 +2414,6 @@ add_library(grpc_test_util_unsecure src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc - src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c - third_party/upb/upb/decode.c - third_party/upb/upb/encode.c - third_party/upb/upb/msg.c - third_party/upb/upb/port.c - third_party/upb/upb/table.c - third_party/upb/upb/upb.c src/core/ext/filters/client_channel/health/health.pb.c third_party/nanopb/pb_common.c third_party/nanopb/pb_decode.c @@ -2794,14 +2763,6 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc - src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c - third_party/upb/upb/decode.c - third_party/upb/upb/encode.c - third_party/upb/upb/msg.c - third_party/upb/upb/port.c - third_party/upb/upb/table.c - third_party/upb/upb/upb.c src/core/ext/filters/client_channel/health/health.pb.c third_party/nanopb/pb_common.c third_party/nanopb/pb_decode.c @@ -2827,16 +2788,16 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc - src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c - src/core/ext/upb-generated/google/protobuf/any.upb.c - src/core/ext/upb-generated/google/protobuf/duration.upb.c - src/core/ext/upb-generated/google/protobuf/empty.upb.c - src/core/ext/upb-generated/google/protobuf/struct.upb.c - src/core/ext/upb-generated/google/protobuf/timestamp.upb.c - src/core/ext/upb-generated/google/protobuf/wrappers.upb.c src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c + third_party/upb/upb/decode.c + third_party/upb/upb/encode.c + third_party/upb/upb/msg.c + third_party/upb/upb/port.c + third_party/upb/upb/table.c + third_party/upb/upb/upb.c src/core/ext/filters/client_channel/lb_policy/xds/xds.cc src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc @@ -3203,14 +3164,6 @@ add_library(grpc++ src/cpp/util/status.cc src/cpp/util/string_ref.cc src/cpp/util/time_cc.cc - src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c - third_party/upb/upb/decode.c - third_party/upb/upb/encode.c - third_party/upb/upb/msg.c - third_party/upb/upb/port.c - third_party/upb/upb/table.c - third_party/upb/upb/upb.c src/core/ext/filters/client_channel/health/health.pb.c third_party/nanopb/pb_common.c third_party/nanopb/pb_decode.c @@ -4317,14 +4270,6 @@ add_library(grpc++_unsecure src/cpp/util/status.cc src/cpp/util/string_ref.cc src/cpp/util/time_cc.cc - src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c - third_party/upb/upb/decode.c - third_party/upb/upb/encode.c - third_party/upb/upb/msg.c - third_party/upb/upb/port.c - third_party/upb/upb/table.c - third_party/upb/upb/upb.c src/core/ext/filters/client_channel/health/health.pb.c third_party/nanopb/pb_common.c third_party/nanopb/pb_decode.c diff --git a/Makefile b/Makefile index e77c5d71089..87a43958abc 100644 --- a/Makefile +++ b/Makefile @@ -3756,9 +3756,6 @@ LIBGRPC_SRC = \ third_party/nanopb/pb_common.c \ third_party/nanopb/pb_decode.c \ third_party/nanopb/pb_encode.c \ - src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c \ - src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c \ - src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c \ src/core/tsi/transport_security.cc \ third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ third_party/upb/upb/decode.c \ @@ -3798,7 +3795,6 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ - src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ src/core/ext/filters/client_channel/health/health.pb.c \ src/core/tsi/fake_transport_security.cc \ src/core/tsi/local_transport_security.cc \ @@ -3818,13 +3814,6 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \ - src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ - src/core/ext/upb-generated/google/protobuf/any.upb.c \ - src/core/ext/upb-generated/google/protobuf/duration.upb.c \ - src/core/ext/upb-generated/google/protobuf/empty.upb.c \ - src/core/ext/upb-generated/google/protobuf/struct.upb.c \ - src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ - src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c \ @@ -4167,14 +4156,6 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ - src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ - third_party/upb/upb/decode.c \ - third_party/upb/upb/encode.c \ - third_party/upb/upb/msg.c \ - third_party/upb/upb/port.c \ - third_party/upb/upb/table.c \ - third_party/upb/upb/upb.c \ src/core/ext/filters/client_channel/health/health.pb.c \ third_party/nanopb/pb_common.c \ third_party/nanopb/pb_decode.c \ @@ -4246,10 +4227,14 @@ LIBGRPC_CRONET_SRC = \ src/core/tsi/alts/handshaker/altscontext.pb.c \ src/core/tsi/alts/handshaker/handshaker.pb.c \ src/core/tsi/alts/handshaker/transport_security_common.pb.c \ - src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c \ - src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c \ - src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c \ src/core/tsi/transport_security.cc \ + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ + third_party/upb/upb/decode.c \ + third_party/upb/upb/encode.c \ + third_party/upb/upb/msg.c \ + third_party/upb/upb/port.c \ + third_party/upb/upb/table.c \ + third_party/upb/upb/upb.c \ src/core/ext/transport/chttp2/client/insecure/channel_create.cc \ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \ src/core/ext/transport/chttp2/client/authority.cc \ @@ -4557,14 +4542,6 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ - src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ - third_party/upb/upb/decode.c \ - third_party/upb/upb/encode.c \ - third_party/upb/upb/msg.c \ - third_party/upb/upb/port.c \ - third_party/upb/upb/table.c \ - third_party/upb/upb/upb.c \ src/core/ext/filters/client_channel/health/health.pb.c \ third_party/nanopb/pb_common.c \ third_party/nanopb/pb_decode.c \ @@ -4884,14 +4861,6 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ - src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ - third_party/upb/upb/decode.c \ - third_party/upb/upb/encode.c \ - third_party/upb/upb/msg.c \ - third_party/upb/upb/port.c \ - third_party/upb/upb/table.c \ - third_party/upb/upb/upb.c \ src/core/ext/filters/client_channel/health/health.pb.c \ third_party/nanopb/pb_common.c \ third_party/nanopb/pb_decode.c \ @@ -5209,14 +5178,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ - src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ - third_party/upb/upb/decode.c \ - third_party/upb/upb/encode.c \ - third_party/upb/upb/msg.c \ - third_party/upb/upb/port.c \ - third_party/upb/upb/table.c \ - third_party/upb/upb/upb.c \ src/core/ext/filters/client_channel/health/health.pb.c \ third_party/nanopb/pb_common.c \ third_party/nanopb/pb_decode.c \ @@ -5242,16 +5203,16 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \ - src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ - src/core/ext/upb-generated/google/protobuf/any.upb.c \ - src/core/ext/upb-generated/google/protobuf/duration.upb.c \ - src/core/ext/upb-generated/google/protobuf/empty.upb.c \ - src/core/ext/upb-generated/google/protobuf/struct.upb.c \ - src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ - src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ + third_party/upb/upb/decode.c \ + third_party/upb/upb/encode.c \ + third_party/upb/upb/msg.c \ + third_party/upb/upb/port.c \ + third_party/upb/upb/table.c \ + third_party/upb/upb/upb.c \ src/core/ext/filters/client_channel/lb_policy/xds/xds.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc \ @@ -5564,14 +5525,6 @@ LIBGRPC++_SRC = \ src/cpp/util/status.cc \ src/cpp/util/string_ref.cc \ src/cpp/util/time_cc.cc \ - src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ - third_party/upb/upb/decode.c \ - third_party/upb/upb/encode.c \ - third_party/upb/upb/msg.c \ - third_party/upb/upb/port.c \ - third_party/upb/upb/table.c \ - third_party/upb/upb/upb.c \ src/core/ext/filters/client_channel/health/health.pb.c \ third_party/nanopb/pb_common.c \ third_party/nanopb/pb_decode.c \ @@ -6600,14 +6553,6 @@ LIBGRPC++_UNSECURE_SRC = \ src/cpp/util/status.cc \ src/cpp/util/string_ref.cc \ src/cpp/util/time_cc.cc \ - src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ - third_party/upb/upb/decode.c \ - third_party/upb/upb/encode.c \ - third_party/upb/upb/msg.c \ - third_party/upb/upb/port.c \ - third_party/upb/upb/table.c \ - third_party/upb/upb/upb.c \ src/core/ext/filters/client_channel/health/health.pb.c \ third_party/nanopb/pb_common.c \ third_party/nanopb/pb_decode.c \ @@ -22457,9 +22402,6 @@ src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc: $(OPENSSL_ src/core/ext/transport/cronet/plugin_registry/grpc_cronet_plugin_registry.cc: $(OPENSSL_DEP) src/core/ext/transport/cronet/transport/cronet_api_dummy.cc: $(OPENSSL_DEP) src/core/ext/transport/cronet/transport/cronet_transport.cc: $(OPENSSL_DEP) -src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c: $(OPENSSL_DEP) -src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c: $(OPENSSL_DEP) -src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c: $(OPENSSL_DEP) src/core/lib/http/httpcli_security_connector.cc: $(OPENSSL_DEP) src/core/lib/security/context/security_context.cc: $(OPENSSL_DEP) src/core/lib/security/credentials/alts/alts_credentials.cc: $(OPENSSL_DEP) diff --git a/build.yaml b/build.yaml index 2e81fae5687..87a2f09cb8e 100644 --- a/build.yaml +++ b/build.yaml @@ -104,7 +104,6 @@ filegroups: - src/core/tsi/alts/handshaker/transport_security_common_api.cc uses: - alts_proto - - alts_upb - grpc_base - nanopb - tsi_interface @@ -660,7 +659,6 @@ filegroups: uses: - grpc_base - grpc_deadline_filter - - grpc_health_upb - health_proto - name: grpc_client_idle_filter src: @@ -725,7 +723,6 @@ filegroups: uses: - grpc_base - grpc_client_channel - - grpc_lb_upb - grpc_resolver_fake - grpclb_proto - nanopb @@ -747,7 +744,6 @@ filegroups: uses: - grpc_base - grpc_client_channel - - grpc_lb_upb - grpc_resolver_fake - grpc_secure - grpclb_proto @@ -784,7 +780,6 @@ filegroups: uses: - grpc_base - grpc_client_channel - - grpc_lb_upb - grpc_resolver_fake - grpclb_proto - nanopb @@ -804,7 +799,6 @@ filegroups: uses: - grpc_base - grpc_client_channel - - grpc_lb_upb - grpc_resolver_fake - grpc_secure - grpclb_proto @@ -1554,7 +1548,6 @@ filegroups: - grpc_transport_inproc_headers - grpc++_codegen_base - grpc++_internal_hdrs_only - - grpc_health_upb - nanopb_headers - health_proto - name: grpc++_config_proto diff --git a/config.m4 b/config.m4 index 07925b2d0ac..0b7e67ed5ca 100644 --- a/config.m4 +++ b/config.m4 @@ -345,9 +345,6 @@ if test "$PHP_GRPC" != "no"; then third_party/nanopb/pb_common.c \ third_party/nanopb/pb_decode.c \ third_party/nanopb/pb_encode.c \ - src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c \ - src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c \ - src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c \ src/core/tsi/transport_security.cc \ third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ third_party/upb/upb/decode.c \ @@ -387,7 +384,6 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ - src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ src/core/ext/filters/client_channel/health/health.pb.c \ src/core/tsi/fake_transport_security.cc \ src/core/tsi/local_transport_security.cc \ @@ -407,13 +403,6 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \ - src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ - src/core/ext/upb-generated/google/protobuf/any.upb.c \ - src/core/ext/upb-generated/google/protobuf/duration.upb.c \ - src/core/ext/upb-generated/google/protobuf/empty.upb.c \ - src/core/ext/upb-generated/google/protobuf/struct.upb.c \ - src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ - src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c \ @@ -742,10 +731,6 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/server/secure) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/transport) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/inproc) - PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/google/protobuf) - PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/src/proto/grpc/gcp) - PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/src/proto/grpc/health/v1) - PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/src/proto/grpc/lb/v1) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/avl) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/backoff) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/channel) diff --git a/config.w32 b/config.w32 index 8963d80a76d..fc2eec7fcc7 100644 --- a/config.w32 +++ b/config.w32 @@ -317,9 +317,6 @@ if (PHP_GRPC != "no") { "third_party\\nanopb\\pb_common.c " + "third_party\\nanopb\\pb_decode.c " + "third_party\\nanopb\\pb_encode.c " + - "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\gcp\\altscontext.upb.c " + - "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\gcp\\handshaker.upb.c " + - "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\gcp\\transport_security_common.upb.c " + "src\\core\\tsi\\transport_security.cc " + "third_party\\upb\\generated_for_cmake\\google\\protobuf\\descriptor.upb.c " + "third_party\\upb\\upb\\decode.c " + @@ -359,7 +356,6 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\subchannel.cc " + "src\\core\\ext\\filters\\client_channel\\subchannel_pool_interface.cc " + "src\\core\\ext\\filters\\deadline\\deadline_filter.cc " + - "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\health\\v1\\health.upb.c " + "src\\core\\ext\\filters\\client_channel\\health\\health.pb.c " + "src\\core\\tsi\\fake_transport_security.cc " + "src\\core\\tsi\\local_transport_security.cc " + @@ -379,13 +375,6 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\grpclb_channel_secure.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\grpclb_client_stats.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\load_balancer_api.cc " + - "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\lb\\v1\\load_balancer.upb.c " + - "src\\core\\ext\\upb-generated\\google\\protobuf\\any.upb.c " + - "src\\core\\ext\\upb-generated\\google\\protobuf\\duration.upb.c " + - "src\\core\\ext\\upb-generated\\google\\protobuf\\empty.upb.c " + - "src\\core\\ext\\upb-generated\\google\\protobuf\\struct.upb.c " + - "src\\core\\ext\\upb-generated\\google\\protobuf\\timestamp.upb.c " + - "src\\core\\ext\\upb-generated\\google\\protobuf\\wrappers.upb.c " + "src\\core\\ext\\filters\\client_channel\\resolver\\fake\\fake_resolver.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto\\grpc\\lb\\v1\\google\\protobuf\\duration.pb.c " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto\\grpc\\lb\\v1\\google\\protobuf\\timestamp.pb.c " + @@ -754,17 +743,6 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2\\server\\secure"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2\\transport"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\inproc"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\google"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\google\\protobuf"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\gcp"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\health"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\health\\v1"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\lb"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\lb\\v1"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\avl"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\backoff"); diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 1fb00deb22e..08f2395769a 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -387,9 +387,6 @@ Pod::Spec.new do |s| 'src/core/tsi/alts/handshaker/altscontext.pb.h', 'src/core/tsi/alts/handshaker/handshaker.pb.h', 'src/core/tsi/alts/handshaker/transport_security_common.pb.h', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', 'src/core/ext/transport/chttp2/client/authority.h', @@ -422,7 +419,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/subchannel_interface.h', 'src/core/ext/filters/client_channel/subchannel_pool_interface.h', 'src/core/ext/filters/deadline/deadline_filter.h', - 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h', 'src/core/ext/filters/client_channel/health/health.pb.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/local_transport_security.h', @@ -582,13 +578,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h', - 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h', - 'src/core/ext/upb-generated/google/protobuf/any.upb.h', - 'src/core/ext/upb-generated/google/protobuf/duration.upb.h', - 'src/core/ext/upb-generated/google/protobuf/empty.upb.h', - 'src/core/ext/upb-generated/google/protobuf/struct.upb.h', - 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.h', - 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.h', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h', @@ -793,7 +782,6 @@ Pod::Spec.new do |s| 'src/core/lib/uri/uri_parser.h', 'src/core/lib/debug/trace.h', 'src/core/ext/transport/inproc/inproc_transport.h', - 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h', 'src/core/ext/filters/client_channel/health/health.pb.h' end diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index b00fe01fdd9..206be3da588 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -342,9 +342,6 @@ Pod::Spec.new do |s| 'src/core/tsi/alts/handshaker/altscontext.pb.h', 'src/core/tsi/alts/handshaker/handshaker.pb.h', 'src/core/tsi/alts/handshaker/transport_security_common.pb.h', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', 'src/core/ext/transport/chttp2/client/authority.h', @@ -377,7 +374,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/subchannel_interface.h', 'src/core/ext/filters/client_channel/subchannel_pool_interface.h', 'src/core/ext/filters/deadline/deadline_filter.h', - 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h', 'src/core/ext/filters/client_channel/health/health.pb.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/local_transport_security.h', @@ -537,13 +533,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h', - 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h', - 'src/core/ext/upb-generated/google/protobuf/any.upb.h', - 'src/core/ext/upb-generated/google/protobuf/duration.upb.h', - 'src/core/ext/upb-generated/google/protobuf/empty.upb.h', - 'src/core/ext/upb-generated/google/protobuf/struct.upb.h', - 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.h', - 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.h', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h', @@ -815,9 +804,6 @@ Pod::Spec.new do |s| 'src/core/tsi/alts/handshaker/altscontext.pb.c', 'src/core/tsi/alts/handshaker/handshaker.pb.c', 'src/core/tsi/alts/handshaker/transport_security_common.pb.c', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c', 'src/core/tsi/transport_security.cc', 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', 'third_party/upb/upb/decode.c', @@ -857,7 +843,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', - 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', 'src/core/ext/filters/client_channel/health/health.pb.c', 'src/core/tsi/fake_transport_security.cc', 'src/core/tsi/local_transport_security.cc', @@ -877,13 +862,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', - 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c', - 'src/core/ext/upb-generated/google/protobuf/any.upb.c', - 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', - 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', - 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', - 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', - 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c', @@ -1030,9 +1008,6 @@ Pod::Spec.new do |s| 'src/core/tsi/alts/handshaker/altscontext.pb.h', 'src/core/tsi/alts/handshaker/handshaker.pb.h', 'src/core/tsi/alts/handshaker/transport_security_common.pb.h', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', 'src/core/ext/transport/chttp2/client/authority.h', @@ -1065,7 +1040,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/subchannel_interface.h', 'src/core/ext/filters/client_channel/subchannel_pool_interface.h', 'src/core/ext/filters/deadline/deadline_filter.h', - 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h', 'src/core/ext/filters/client_channel/health/health.pb.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/local_transport_security.h', @@ -1225,13 +1199,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h', - 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h', - 'src/core/ext/upb-generated/google/protobuf/any.upb.h', - 'src/core/ext/upb-generated/google/protobuf/duration.upb.h', - 'src/core/ext/upb-generated/google/protobuf/empty.upb.h', - 'src/core/ext/upb-generated/google/protobuf/struct.upb.h', - 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.h', - 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.h', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h', diff --git a/grpc.gemspec b/grpc.gemspec index 757228dd232..ff7b0663ca2 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -276,9 +276,6 @@ Gem::Specification.new do |s| s.files += %w( third_party/nanopb/pb_common.h ) s.files += %w( third_party/nanopb/pb_decode.h ) s.files += %w( third_party/nanopb/pb_encode.h ) - s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h ) - s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h ) - s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h ) s.files += %w( src/core/tsi/transport_security.h ) s.files += %w( src/core/tsi/transport_security_interface.h ) s.files += %w( src/core/ext/transport/chttp2/client/authority.h ) @@ -311,7 +308,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/subchannel_interface.h ) s.files += %w( src/core/ext/filters/client_channel/subchannel_pool_interface.h ) s.files += %w( src/core/ext/filters/deadline/deadline_filter.h ) - s.files += %w( src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h ) s.files += %w( src/core/ext/filters/client_channel/health/health.pb.h ) s.files += %w( src/core/tsi/fake_transport_security.h ) s.files += %w( src/core/tsi/local_transport_security.h ) @@ -471,13 +467,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h ) - s.files += %w( src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/any.upb.h ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/duration.upb.h ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/empty.upb.h ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/struct.upb.h ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/timestamp.upb.h ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/wrappers.upb.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h ) @@ -752,9 +741,6 @@ Gem::Specification.new do |s| s.files += %w( third_party/nanopb/pb_common.c ) s.files += %w( third_party/nanopb/pb_decode.c ) s.files += %w( third_party/nanopb/pb_encode.c ) - s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c ) - s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c ) - s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c ) s.files += %w( src/core/tsi/transport_security.cc ) s.files += %w( third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c ) s.files += %w( third_party/upb/upb/decode.c ) @@ -794,7 +780,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/subchannel.cc ) s.files += %w( src/core/ext/filters/client_channel/subchannel_pool_interface.cc ) s.files += %w( src/core/ext/filters/deadline/deadline_filter.cc ) - s.files += %w( src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c ) s.files += %w( src/core/ext/filters/client_channel/health/health.pb.c ) s.files += %w( src/core/tsi/fake_transport_security.cc ) s.files += %w( src/core/tsi/local_transport_security.cc ) @@ -814,13 +799,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc ) - s.files += %w( src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/any.upb.c ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/duration.upb.c ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/empty.upb.c ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/struct.upb.c ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/timestamp.upb.c ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/wrappers.upb.c ) s.files += %w( src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c ) diff --git a/grpc.gyp b/grpc.gyp index a6e39f8bacc..5f9f900c2cd 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -557,9 +557,6 @@ 'third_party/nanopb/pb_common.c', 'third_party/nanopb/pb_decode.c', 'third_party/nanopb/pb_encode.c', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c', 'src/core/tsi/transport_security.cc', 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', 'third_party/upb/upb/decode.c', @@ -599,7 +596,6 @@ 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', - 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', 'src/core/ext/filters/client_channel/health/health.pb.c', 'src/core/tsi/fake_transport_security.cc', 'src/core/tsi/local_transport_security.cc', @@ -619,13 +615,6 @@ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', - 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c', - 'src/core/ext/upb-generated/google/protobuf/any.upb.c', - 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', - 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', - 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', - 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', - 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c', @@ -882,14 +871,6 @@ 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', - 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', - 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', - 'third_party/upb/upb/decode.c', - 'third_party/upb/upb/encode.c', - 'third_party/upb/upb/msg.c', - 'third_party/upb/upb/port.c', - 'third_party/upb/upb/table.c', - 'third_party/upb/upb/upb.c', 'src/core/ext/filters/client_channel/health/health.pb.c', 'third_party/nanopb/pb_common.c', 'third_party/nanopb/pb_decode.c', @@ -1142,14 +1123,6 @@ 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', - 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', - 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', - 'third_party/upb/upb/decode.c', - 'third_party/upb/upb/encode.c', - 'third_party/upb/upb/msg.c', - 'third_party/upb/upb/port.c', - 'third_party/upb/upb/table.c', - 'third_party/upb/upb/upb.c', 'src/core/ext/filters/client_channel/health/health.pb.c', 'third_party/nanopb/pb_common.c', 'third_party/nanopb/pb_decode.c', @@ -1413,14 +1386,6 @@ 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', - 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', - 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', - 'third_party/upb/upb/decode.c', - 'third_party/upb/upb/encode.c', - 'third_party/upb/upb/msg.c', - 'third_party/upb/upb/port.c', - 'third_party/upb/upb/table.c', - 'third_party/upb/upb/upb.c', 'src/core/ext/filters/client_channel/health/health.pb.c', 'third_party/nanopb/pb_common.c', 'third_party/nanopb/pb_decode.c', @@ -1446,16 +1411,16 @@ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', - 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c', - 'src/core/ext/upb-generated/google/protobuf/any.upb.c', - 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', - 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', - 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', - 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', - 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', + 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', + 'third_party/upb/upb/decode.c', + 'third_party/upb/upb/encode.c', + 'third_party/upb/upb/msg.c', + 'third_party/upb/upb/port.c', + 'third_party/upb/upb/table.c', + 'third_party/upb/upb/upb.c', 'src/core/ext/filters/client_channel/lb_policy/xds/xds.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc', @@ -1575,14 +1540,6 @@ 'src/cpp/util/status.cc', 'src/cpp/util/string_ref.cc', 'src/cpp/util/time_cc.cc', - 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', - 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', - 'third_party/upb/upb/decode.c', - 'third_party/upb/upb/encode.c', - 'third_party/upb/upb/msg.c', - 'third_party/upb/upb/port.c', - 'third_party/upb/upb/table.c', - 'third_party/upb/upb/upb.c', 'src/core/ext/filters/client_channel/health/health.pb.c', 'third_party/nanopb/pb_common.c', 'third_party/nanopb/pb_decode.c', @@ -1740,14 +1697,6 @@ 'src/cpp/util/status.cc', 'src/cpp/util/string_ref.cc', 'src/cpp/util/time_cc.cc', - 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', - 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', - 'third_party/upb/upb/decode.c', - 'third_party/upb/upb/encode.c', - 'third_party/upb/upb/msg.c', - 'third_party/upb/upb/port.c', - 'third_party/upb/upb/table.c', - 'third_party/upb/upb/upb.c', 'src/core/ext/filters/client_channel/health/health.pb.c', 'third_party/nanopb/pb_common.c', 'third_party/nanopb/pb_decode.c', diff --git a/package.xml b/package.xml index 89a199f0198..adf09c06361 100644 --- a/package.xml +++ b/package.xml @@ -281,9 +281,6 @@ - - - @@ -316,7 +313,6 @@ - @@ -476,13 +472,6 @@ - - - - - - - @@ -757,9 +746,6 @@ - - - @@ -799,7 +785,6 @@ - @@ -819,13 +804,6 @@ - - - - - - - diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 95f1d0eea1d..49a591c5f23 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -316,9 +316,6 @@ CORE_SOURCE_FILES = [ 'third_party/nanopb/pb_common.c', 'third_party/nanopb/pb_decode.c', 'third_party/nanopb/pb_encode.c', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c', 'src/core/tsi/transport_security.cc', 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', 'third_party/upb/upb/decode.c', @@ -358,7 +355,6 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', - 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', 'src/core/ext/filters/client_channel/health/health.pb.c', 'src/core/tsi/fake_transport_security.cc', 'src/core/tsi/local_transport_security.cc', @@ -378,13 +374,6 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', - 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c', - 'src/core/ext/upb-generated/google/protobuf/any.upb.c', - 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', - 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', - 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', - 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', - 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c', diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 0ef86c9065e..b43ae2f4254 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1062,8 +1062,6 @@ include/grpcpp/support/validate_service_config.h \ src/core/ext/filters/client_channel/health/health.pb.c \ src/core/ext/filters/client_channel/health/health.pb.h \ src/core/ext/transport/inproc/inproc_transport.h \ -src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ -src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h \ src/core/lib/avl/avl.h \ src/core/lib/backoff/backoff.h \ src/core/lib/channel/channel_args.h \ @@ -1300,14 +1298,7 @@ third_party/nanopb/pb_common.h \ third_party/nanopb/pb_decode.c \ third_party/nanopb/pb_decode.h \ third_party/nanopb/pb_encode.c \ -third_party/nanopb/pb_encode.h \ -third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ -third_party/upb/upb/decode.c \ -third_party/upb/upb/encode.c \ -third_party/upb/upb/msg.c \ -third_party/upb/upb/port.c \ -third_party/upb/upb/table.c \ -third_party/upb/upb/upb.c +third_party/nanopb/pb_encode.h # 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/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index c1a5102709c..d11ea7f7daa 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1066,28 +1066,6 @@ src/core/ext/transport/chttp2/transport/writing.cc \ src/core/ext/transport/inproc/inproc_plugin.cc \ src/core/ext/transport/inproc/inproc_transport.cc \ src/core/ext/transport/inproc/inproc_transport.h \ -src/core/ext/upb-generated/google/protobuf/any.upb.c \ -src/core/ext/upb-generated/google/protobuf/any.upb.h \ -src/core/ext/upb-generated/google/protobuf/duration.upb.c \ -src/core/ext/upb-generated/google/protobuf/duration.upb.h \ -src/core/ext/upb-generated/google/protobuf/empty.upb.c \ -src/core/ext/upb-generated/google/protobuf/empty.upb.h \ -src/core/ext/upb-generated/google/protobuf/struct.upb.c \ -src/core/ext/upb-generated/google/protobuf/struct.upb.h \ -src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ -src/core/ext/upb-generated/google/protobuf/timestamp.upb.h \ -src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ -src/core/ext/upb-generated/google/protobuf/wrappers.upb.h \ -src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c \ -src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h \ -src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c \ -src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h \ -src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c \ -src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h \ -src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ -src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h \ -src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ -src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h \ src/core/lib/README.md \ src/core/lib/avl/avl.cc \ src/core/lib/avl/avl.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index f06e6522c99..0dcecd83a6b 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -8228,7 +8228,6 @@ { "deps": [ "alts_proto", - "alts_upb", "gpr", "grpc_base", "nanopb", @@ -9090,7 +9089,6 @@ "gpr", "grpc_base", "grpc_deadline_filter", - "grpc_health_upb", "health_proto" ], "headers": [ @@ -9293,7 +9291,6 @@ "gpr", "grpc_base", "grpc_client_channel", - "grpc_lb_upb", "grpc_resolver_fake", "grpclb_proto", "nanopb", @@ -9329,7 +9326,6 @@ "gpr", "grpc_base", "grpc_client_channel", - "grpc_lb_upb", "grpc_resolver_fake", "grpc_secure", "grpclb_proto", @@ -9400,7 +9396,6 @@ "gpr", "grpc_base", "grpc_client_channel", - "grpc_lb_upb", "grpc_resolver_fake", "grpclb_proto", "nanopb", @@ -9433,7 +9428,6 @@ "gpr", "grpc_base", "grpc_client_channel", - "grpc_lb_upb", "grpc_resolver_fake", "grpc_secure", "grpclb_proto", @@ -10569,7 +10563,6 @@ "grpc++_codegen_base", "grpc++_internal_hdrs_only", "grpc_base_headers", - "grpc_health_upb", "grpc_transport_inproc_headers", "health_proto", "nanopb_headers" From d12f310b0d6c26f09eee4c3909eca9788d373e23 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Tue, 6 Aug 2019 17:48:53 -0700 Subject: [PATCH 1132/1555] Added targets for examples --- src/objective-c/BUILD | 1 - src/objective-c/examples/BUILD | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/objective-c/BUILD b/src/objective-c/BUILD index c3629d0ada4..3a71086f0f6 100644 --- a/src/objective-c/BUILD +++ b/src/objective-c/BUILD @@ -130,5 +130,4 @@ grpc_objc_library( "//:grpc_objc", "@com_google_protobuf//:protobuf_objc", ], - visibility = ["//visibility:public"], ) diff --git a/src/objective-c/examples/BUILD b/src/objective-c/examples/BUILD index d3a5a76b89a..d6e1140d8f5 100644 --- a/src/objective-c/examples/BUILD +++ b/src/objective-c/examples/BUILD @@ -52,8 +52,8 @@ local_objc_grpc_library( objc_library( name = "Sample-lib", - srcs = glob(["Sample/**/*.m"]), - hdrs = glob(["Sample/**/*.h"]), + srcs = glob(["Sample/Sample/**/*.m"]), + hdrs = glob(["Sample/Sample/**/*.h"]), data = glob([ "Sample/Sample/Base.lproj/**", "Sample/Sample/Images.xcassets/**", @@ -71,12 +71,13 @@ ios_application( "ipad", ], deps = ["Sample-lib"], + visibility = ["//visibility:public"], ) objc_library( name = "InterceptorSample-lib", - srcs = glob(["InterceptorSample/**/*.m"]), - hdrs = glob(["InterceptorSample/**/*.h"]), + srcs = glob(["InterceptorSample/InterceptorSample/**/*.m"]), + hdrs = glob(["InterceptorSample/InterceptorSample/**/*.h"]), data = glob([ "InterceptorSample/InterceptorSample/Base.lproj/**", "InterceptorSample/InterceptorSample/Images.xcassets/**", From f7454a9876c136502e1679312ef1d3a9ae87baf3 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 31 Jul 2019 09:42:16 -0700 Subject: [PATCH 1133/1555] Modified health_check to use upb proto instead of nanopb --- BUILD | 22 +---- BUILD.gn | 33 +++---- CMakeLists.txt | 94 +++++++++++-------- Makefile | 94 +++++++++++-------- build.yaml | 11 +-- config.m4 | 3 +- config.w32 | 8 +- gRPC-C++.podspec | 6 +- gRPC-Core.podspec | 9 +- grpc.gemspec | 4 +- grpc.gyp | 72 ++++++++------ package.xml | 4 +- .../health/health_check_client.cc | 48 ++++------ .../health/default_health_check_service.cc | 58 ++++++------ src/python/grpcio/grpc_core_dependencies.py | 2 +- tools/doxygen/Doxyfile.c++.internal | 16 ++-- tools/doxygen/Doxyfile.core.internal | 4 +- .../generated/sources_and_headers.json | 21 +---- 18 files changed, 255 insertions(+), 254 deletions(-) diff --git a/BUILD b/BUILD index d42572b6559..ac23308620d 100644 --- a/BUILD +++ b/BUILD @@ -1064,7 +1064,7 @@ grpc_cc_library( "grpc_base", "grpc_client_authority_filter", "grpc_deadline_filter", - "health_proto", + "grpc_health_upb", "inlined_vector", "orphanable", "ref_counted", @@ -1192,20 +1192,6 @@ grpc_cc_library( ], ) -grpc_cc_library( - name = "health_proto", - srcs = [ - "src/core/ext/filters/client_channel/health/health.pb.c", - ], - hdrs = [ - "src/core/ext/filters/client_channel/health/health.pb.h", - ], - external_deps = [ - "nanopb", - ], - language = "c++", -) - grpc_cc_library( name = "grpclb_proto", srcs = [ @@ -1999,9 +1985,9 @@ grpc_cc_library( language = "c++", public_hdrs = GRPCXX_PUBLIC_HDRS, deps = [ - "grpc", "grpc++_codegen_base", - "health_proto", + "grpc", + "grpc_health_upb", ], ) @@ -2014,7 +2000,7 @@ grpc_cc_library( deps = [ "grpc++_codegen_base", "grpc_unsecure", - "health_proto", + "grpc_health_upb", ], ) diff --git a/BUILD.gn b/BUILD.gn index 1ee7929c0cb..df9329bdacd 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -33,25 +33,6 @@ config("grpc_config") { - source_set("health_proto") { - sources = [ - "src/core/ext/filters/client_channel/health/health.pb.c", - "src/core/ext/filters/client_channel/health/health.pb.h", - ] - deps = [ - ":nanopb", - ] - - public_configs = [ - ":grpc_config", - ] - include_dirs = [ - "third_party/nanopb", - ] - } - - - source_set("nanopb") { sources = [ "third_party/nanopb/pb.h", @@ -429,6 +410,8 @@ config("grpc_config") { "src/core/ext/transport/inproc/inproc_plugin.cc", "src/core/ext/transport/inproc/inproc_transport.cc", "src/core/ext/transport/inproc/inproc_transport.h", + "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c", + "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h", "src/core/lib/avl/avl.cc", "src/core/lib/avl/avl.h", "src/core/lib/backoff/backoff.cc", @@ -889,7 +872,6 @@ config("grpc_config") { "//third_party/cares", ":address_sorting", ":nanopb", - ":health_proto", ] public_configs = [ @@ -1169,6 +1151,8 @@ config("grpc_config") { "include/grpcpp/support/time.h", "include/grpcpp/support/validate_service_config.h", "src/core/ext/transport/inproc/inproc_transport.h", + "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c", + "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h", "src/core/lib/avl/avl.h", "src/core/lib/backoff/backoff.h", "src/core/lib/channel/channel_args.h", @@ -1398,14 +1382,19 @@ config("grpc_config") { "src/cpp/util/status.cc", "src/cpp/util/string_ref.cc", "src/cpp/util/time_cc.cc", + "third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c", + "third_party/upb/upb/decode.c", + "third_party/upb/upb/encode.c", + "third_party/upb/upb/msg.c", + "third_party/upb/upb/port.c", + "third_party/upb/upb/table.c", + "third_party/upb/upb/upb.c", ] deps = [ "//third_party/boringssl", "//third_party/protobuf:protobuf_lite", ":grpc", ":gpr", - ":nanopb", - ":health_proto", ] public_configs = [ diff --git a/CMakeLists.txt b/CMakeLists.txt index 68d3ade6519..00183363fdc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1304,7 +1304,7 @@ add_library(grpc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc - src/core/ext/filters/client_channel/health/health.pb.c + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c src/core/tsi/fake_transport_security.cc src/core/tsi/local_transport_security.cc src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc @@ -1677,10 +1677,14 @@ add_library(grpc_cronet src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc - src/core/ext/filters/client_channel/health/health.pb.c - third_party/nanopb/pb_common.c - third_party/nanopb/pb_decode.c - third_party/nanopb/pb_encode.c + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c + third_party/upb/upb/decode.c + third_party/upb/upb/encode.c + third_party/upb/upb/msg.c + third_party/upb/upb/port.c + third_party/upb/upb/table.c + third_party/upb/upb/upb.c src/core/lib/http/httpcli_security_connector.cc src/core/lib/security/context/security_context.cc src/core/lib/security/credentials/alts/alts_credentials.cc @@ -1748,14 +1752,10 @@ add_library(grpc_cronet src/core/tsi/alts/handshaker/altscontext.pb.c src/core/tsi/alts/handshaker/handshaker.pb.c src/core/tsi/alts/handshaker/transport_security_common.pb.c + third_party/nanopb/pb_common.c + third_party/nanopb/pb_decode.c + third_party/nanopb/pb_encode.c src/core/tsi/transport_security.cc - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c - third_party/upb/upb/decode.c - third_party/upb/upb/encode.c - third_party/upb/upb/msg.c - third_party/upb/upb/port.c - third_party/upb/upb/table.c - third_party/upb/upb/upb.c src/core/ext/transport/chttp2/client/insecure/channel_create.cc src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc src/core/ext/transport/chttp2/client/authority.cc @@ -2076,10 +2076,14 @@ add_library(grpc_test_util src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc - src/core/ext/filters/client_channel/health/health.pb.c - third_party/nanopb/pb_common.c - third_party/nanopb/pb_decode.c - third_party/nanopb/pb_encode.c + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c + third_party/upb/upb/decode.c + third_party/upb/upb/encode.c + third_party/upb/upb/msg.c + third_party/upb/upb/port.c + third_party/upb/upb/table.c + third_party/upb/upb/upb.c src/core/ext/transport/chttp2/transport/bin_decoder.cc src/core/ext/transport/chttp2/transport/bin_encoder.cc src/core/ext/transport/chttp2/transport/chttp2_plugin.cc @@ -2414,10 +2418,14 @@ add_library(grpc_test_util_unsecure src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc - src/core/ext/filters/client_channel/health/health.pb.c - third_party/nanopb/pb_common.c - third_party/nanopb/pb_decode.c - third_party/nanopb/pb_encode.c + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c + third_party/upb/upb/decode.c + third_party/upb/upb/encode.c + third_party/upb/upb/msg.c + third_party/upb/upb/port.c + third_party/upb/upb/table.c + third_party/upb/upb/upb.c src/core/ext/transport/chttp2/transport/bin_decoder.cc src/core/ext/transport/chttp2/transport/bin_encoder.cc src/core/ext/transport/chttp2/transport/chttp2_plugin.cc @@ -2763,10 +2771,14 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc - src/core/ext/filters/client_channel/health/health.pb.c - third_party/nanopb/pb_common.c - third_party/nanopb/pb_decode.c - third_party/nanopb/pb_encode.c + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c + third_party/upb/upb/decode.c + third_party/upb/upb/encode.c + third_party/upb/upb/msg.c + third_party/upb/upb/port.c + third_party/upb/upb/table.c + third_party/upb/upb/upb.c src/core/ext/transport/inproc/inproc_plugin.cc src/core/ext/transport/inproc/inproc_transport.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -2791,13 +2803,9 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c - third_party/upb/upb/decode.c - third_party/upb/upb/encode.c - third_party/upb/upb/msg.c - third_party/upb/upb/port.c - third_party/upb/upb/table.c - third_party/upb/upb/upb.c + third_party/nanopb/pb_common.c + third_party/nanopb/pb_decode.c + third_party/nanopb/pb_encode.c src/core/ext/filters/client_channel/lb_policy/xds/xds.cc src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc @@ -3164,10 +3172,14 @@ add_library(grpc++ src/cpp/util/status.cc src/cpp/util/string_ref.cc src/cpp/util/time_cc.cc - src/core/ext/filters/client_channel/health/health.pb.c - third_party/nanopb/pb_common.c - third_party/nanopb/pb_decode.c - third_party/nanopb/pb_encode.c + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c + third_party/upb/upb/decode.c + third_party/upb/upb/encode.c + third_party/upb/upb/msg.c + third_party/upb/upb/port.c + third_party/upb/upb/table.c + third_party/upb/upb/upb.c src/cpp/codegen/codegen_init.cc ) @@ -4270,10 +4282,14 @@ add_library(grpc++_unsecure src/cpp/util/status.cc src/cpp/util/string_ref.cc src/cpp/util/time_cc.cc - src/core/ext/filters/client_channel/health/health.pb.c - third_party/nanopb/pb_common.c - third_party/nanopb/pb_decode.c - third_party/nanopb/pb_encode.c + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c + third_party/upb/upb/decode.c + third_party/upb/upb/encode.c + third_party/upb/upb/msg.c + third_party/upb/upb/port.c + third_party/upb/upb/table.c + third_party/upb/upb/upb.c src/cpp/codegen/codegen_init.cc ) diff --git a/Makefile b/Makefile index 87a43958abc..97eaae13b2e 100644 --- a/Makefile +++ b/Makefile @@ -3795,7 +3795,7 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ - src/core/ext/filters/client_channel/health/health.pb.c \ + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ src/core/tsi/fake_transport_security.cc \ src/core/tsi/local_transport_security.cc \ src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc \ @@ -4156,10 +4156,14 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ - src/core/ext/filters/client_channel/health/health.pb.c \ - third_party/nanopb/pb_common.c \ - third_party/nanopb/pb_decode.c \ - third_party/nanopb/pb_encode.c \ + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ + third_party/upb/upb/decode.c \ + third_party/upb/upb/encode.c \ + third_party/upb/upb/msg.c \ + third_party/upb/upb/port.c \ + third_party/upb/upb/table.c \ + third_party/upb/upb/upb.c \ src/core/lib/http/httpcli_security_connector.cc \ src/core/lib/security/context/security_context.cc \ src/core/lib/security/credentials/alts/alts_credentials.cc \ @@ -4227,14 +4231,10 @@ LIBGRPC_CRONET_SRC = \ src/core/tsi/alts/handshaker/altscontext.pb.c \ src/core/tsi/alts/handshaker/handshaker.pb.c \ src/core/tsi/alts/handshaker/transport_security_common.pb.c \ + third_party/nanopb/pb_common.c \ + third_party/nanopb/pb_decode.c \ + third_party/nanopb/pb_encode.c \ src/core/tsi/transport_security.cc \ - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ - third_party/upb/upb/decode.c \ - third_party/upb/upb/encode.c \ - third_party/upb/upb/msg.c \ - third_party/upb/upb/port.c \ - third_party/upb/upb/table.c \ - third_party/upb/upb/upb.c \ src/core/ext/transport/chttp2/client/insecure/channel_create.cc \ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \ src/core/ext/transport/chttp2/client/authority.cc \ @@ -4542,10 +4542,14 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ - src/core/ext/filters/client_channel/health/health.pb.c \ - third_party/nanopb/pb_common.c \ - third_party/nanopb/pb_decode.c \ - third_party/nanopb/pb_encode.c \ + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ + third_party/upb/upb/decode.c \ + third_party/upb/upb/encode.c \ + third_party/upb/upb/msg.c \ + third_party/upb/upb/port.c \ + third_party/upb/upb/table.c \ + third_party/upb/upb/upb.c \ src/core/ext/transport/chttp2/transport/bin_decoder.cc \ src/core/ext/transport/chttp2/transport/bin_encoder.cc \ src/core/ext/transport/chttp2/transport/chttp2_plugin.cc \ @@ -4861,10 +4865,14 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ - src/core/ext/filters/client_channel/health/health.pb.c \ - third_party/nanopb/pb_common.c \ - third_party/nanopb/pb_decode.c \ - third_party/nanopb/pb_encode.c \ + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ + third_party/upb/upb/decode.c \ + third_party/upb/upb/encode.c \ + third_party/upb/upb/msg.c \ + third_party/upb/upb/port.c \ + third_party/upb/upb/table.c \ + third_party/upb/upb/upb.c \ src/core/ext/transport/chttp2/transport/bin_decoder.cc \ src/core/ext/transport/chttp2/transport/bin_encoder.cc \ src/core/ext/transport/chttp2/transport/chttp2_plugin.cc \ @@ -5178,10 +5186,14 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ - src/core/ext/filters/client_channel/health/health.pb.c \ - third_party/nanopb/pb_common.c \ - third_party/nanopb/pb_decode.c \ - third_party/nanopb/pb_encode.c \ + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ + third_party/upb/upb/decode.c \ + third_party/upb/upb/encode.c \ + third_party/upb/upb/msg.c \ + third_party/upb/upb/port.c \ + third_party/upb/upb/table.c \ + third_party/upb/upb/upb.c \ src/core/ext/transport/inproc/inproc_plugin.cc \ src/core/ext/transport/inproc/inproc_transport.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc \ @@ -5206,13 +5218,9 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ - third_party/upb/upb/decode.c \ - third_party/upb/upb/encode.c \ - third_party/upb/upb/msg.c \ - third_party/upb/upb/port.c \ - third_party/upb/upb/table.c \ - third_party/upb/upb/upb.c \ + third_party/nanopb/pb_common.c \ + third_party/nanopb/pb_decode.c \ + third_party/nanopb/pb_encode.c \ src/core/ext/filters/client_channel/lb_policy/xds/xds.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc \ @@ -5525,10 +5533,14 @@ LIBGRPC++_SRC = \ src/cpp/util/status.cc \ src/cpp/util/string_ref.cc \ src/cpp/util/time_cc.cc \ - src/core/ext/filters/client_channel/health/health.pb.c \ - third_party/nanopb/pb_common.c \ - third_party/nanopb/pb_decode.c \ - third_party/nanopb/pb_encode.c \ + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ + third_party/upb/upb/decode.c \ + third_party/upb/upb/encode.c \ + third_party/upb/upb/msg.c \ + third_party/upb/upb/port.c \ + third_party/upb/upb/table.c \ + third_party/upb/upb/upb.c \ src/cpp/codegen/codegen_init.cc \ PUBLIC_HEADERS_CXX += \ @@ -6553,10 +6565,14 @@ LIBGRPC++_UNSECURE_SRC = \ src/cpp/util/status.cc \ src/cpp/util/string_ref.cc \ src/cpp/util/time_cc.cc \ - src/core/ext/filters/client_channel/health/health.pb.c \ - third_party/nanopb/pb_common.c \ - third_party/nanopb/pb_decode.c \ - third_party/nanopb/pb_encode.c \ + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ + third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ + third_party/upb/upb/decode.c \ + third_party/upb/upb/encode.c \ + third_party/upb/upb/msg.c \ + third_party/upb/upb/port.c \ + third_party/upb/upb/table.c \ + third_party/upb/upb/upb.c \ src/cpp/codegen/codegen_init.cc \ PUBLIC_HEADERS_CXX += \ diff --git a/build.yaml b/build.yaml index 87a2f09cb8e..ee6c05795d7 100644 --- a/build.yaml +++ b/build.yaml @@ -659,7 +659,7 @@ filegroups: uses: - grpc_base - grpc_deadline_filter - - health_proto + - grpc_health_upb - name: grpc_client_idle_filter src: - src/core/ext/filters/client_idle/client_idle_filter.cc @@ -1207,13 +1207,6 @@ filegroups: - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c uses: - nanopb -- name: health_proto - headers: - - src/core/ext/filters/client_channel/health/health.pb.h - src: - - src/core/ext/filters/client_channel/health/health.pb.c - uses: - - nanopb - name: nanopb src: - third_party/nanopb/pb_common.c @@ -1545,11 +1538,11 @@ filegroups: uses: - gpr_base_headers - grpc_base_headers + - grpc_health_upb - grpc_transport_inproc_headers - grpc++_codegen_base - grpc++_internal_hdrs_only - nanopb_headers - - health_proto - name: grpc++_config_proto language: c++ public_headers: diff --git a/config.m4 b/config.m4 index 0b7e67ed5ca..dfb4f7eb0c6 100644 --- a/config.m4 +++ b/config.m4 @@ -384,7 +384,7 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ - src/core/ext/filters/client_channel/health/health.pb.c \ + src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ src/core/tsi/fake_transport_security.cc \ src/core/tsi/local_transport_security.cc \ src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc \ @@ -731,6 +731,7 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/server/secure) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/transport) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/inproc) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/src/proto/grpc/health/v1) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/avl) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/backoff) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/channel) diff --git a/config.w32 b/config.w32 index fc2eec7fcc7..06a52da2904 100644 --- a/config.w32 +++ b/config.w32 @@ -356,7 +356,7 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\subchannel.cc " + "src\\core\\ext\\filters\\client_channel\\subchannel_pool_interface.cc " + "src\\core\\ext\\filters\\deadline\\deadline_filter.cc " + - "src\\core\\ext\\filters\\client_channel\\health\\health.pb.c " + + "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\health\\v1\\health.upb.c " + "src\\core\\tsi\\fake_transport_security.cc " + "src\\core\\tsi\\local_transport_security.cc " + "src\\core\\tsi\\ssl\\session_cache\\ssl_session_boringssl.cc " + @@ -743,6 +743,12 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2\\server\\secure"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2\\transport"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\inproc"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\health"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\health\\v1"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\avl"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\backoff"); diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 08f2395769a..b6482fe66b9 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -419,7 +419,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/subchannel_interface.h', 'src/core/ext/filters/client_channel/subchannel_pool_interface.h', 'src/core/ext/filters/deadline/deadline_filter.h', - 'src/core/ext/filters/client_channel/health/health.pb.h', + 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/local_transport_security.h', 'src/core/tsi/ssl/session_cache/ssl_session.h', @@ -781,8 +781,8 @@ Pod::Spec.new do |s| 'src/core/lib/transport/transport_impl.h', 'src/core/lib/uri/uri_parser.h', 'src/core/lib/debug/trace.h', - 'src/core/ext/transport/inproc/inproc_transport.h', - 'src/core/ext/filters/client_channel/health/health.pb.h' + 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h', + 'src/core/ext/transport/inproc/inproc_transport.h' end s.subspec 'Protobuf' do |ss| diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 206be3da588..07dccee41f9 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -374,7 +374,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/subchannel_interface.h', 'src/core/ext/filters/client_channel/subchannel_pool_interface.h', 'src/core/ext/filters/deadline/deadline_filter.h', - 'src/core/ext/filters/client_channel/health/health.pb.h', + 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/local_transport_security.h', 'src/core/tsi/ssl/session_cache/ssl_session.h', @@ -843,7 +843,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', - 'src/core/ext/filters/client_channel/health/health.pb.c', + 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', 'src/core/tsi/fake_transport_security.cc', 'src/core/tsi/local_transport_security.cc', 'src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc', @@ -1040,7 +1040,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/subchannel_interface.h', 'src/core/ext/filters/client_channel/subchannel_pool_interface.h', 'src/core/ext/filters/deadline/deadline_filter.h', - 'src/core/ext/filters/client_channel/health/health.pb.h', + 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/local_transport_security.h', 'src/core/tsi/ssl/session_cache/ssl_session.h', @@ -1282,9 +1282,6 @@ Pod::Spec.new do |s| 'test/core/util/tracer_util.cc', 'test/core/util/trickle_endpoint.cc', 'test/core/util/cmdline.cc', - 'third_party/nanopb/pb_common.c', - 'third_party/nanopb/pb_decode.c', - 'third_party/nanopb/pb_encode.c', 'test/core/end2end/data/ssl_test_data.h', 'test/core/security/oauth2_utils.h', 'test/core/end2end/cq_verifier.h', diff --git a/grpc.gemspec b/grpc.gemspec index ff7b0663ca2..d56ed118d6d 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -308,7 +308,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/subchannel_interface.h ) s.files += %w( src/core/ext/filters/client_channel/subchannel_pool_interface.h ) s.files += %w( src/core/ext/filters/deadline/deadline_filter.h ) - s.files += %w( src/core/ext/filters/client_channel/health/health.pb.h ) + s.files += %w( src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h ) s.files += %w( src/core/tsi/fake_transport_security.h ) s.files += %w( src/core/tsi/local_transport_security.h ) s.files += %w( src/core/tsi/ssl/session_cache/ssl_session.h ) @@ -780,7 +780,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/subchannel.cc ) s.files += %w( src/core/ext/filters/client_channel/subchannel_pool_interface.cc ) s.files += %w( src/core/ext/filters/deadline/deadline_filter.cc ) - s.files += %w( src/core/ext/filters/client_channel/health/health.pb.c ) + s.files += %w( src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c ) s.files += %w( src/core/tsi/fake_transport_security.cc ) s.files += %w( src/core/tsi/local_transport_security.cc ) s.files += %w( src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc ) diff --git a/grpc.gyp b/grpc.gyp index 5f9f900c2cd..b4c19bb6124 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -596,7 +596,7 @@ 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', - 'src/core/ext/filters/client_channel/health/health.pb.c', + 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', 'src/core/tsi/fake_transport_security.cc', 'src/core/tsi/local_transport_security.cc', 'src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc', @@ -871,10 +871,14 @@ 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', - 'src/core/ext/filters/client_channel/health/health.pb.c', - 'third_party/nanopb/pb_common.c', - 'third_party/nanopb/pb_decode.c', - 'third_party/nanopb/pb_encode.c', + 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', + 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', + 'third_party/upb/upb/decode.c', + 'third_party/upb/upb/encode.c', + 'third_party/upb/upb/msg.c', + 'third_party/upb/upb/port.c', + 'third_party/upb/upb/table.c', + 'third_party/upb/upb/upb.c', 'src/core/ext/transport/chttp2/transport/bin_decoder.cc', 'src/core/ext/transport/chttp2/transport/bin_encoder.cc', 'src/core/ext/transport/chttp2/transport/chttp2_plugin.cc', @@ -1123,10 +1127,14 @@ 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', - 'src/core/ext/filters/client_channel/health/health.pb.c', - 'third_party/nanopb/pb_common.c', - 'third_party/nanopb/pb_decode.c', - 'third_party/nanopb/pb_encode.c', + 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', + 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', + 'third_party/upb/upb/decode.c', + 'third_party/upb/upb/encode.c', + 'third_party/upb/upb/msg.c', + 'third_party/upb/upb/port.c', + 'third_party/upb/upb/table.c', + 'third_party/upb/upb/upb.c', 'src/core/ext/transport/chttp2/transport/bin_decoder.cc', 'src/core/ext/transport/chttp2/transport/bin_encoder.cc', 'src/core/ext/transport/chttp2/transport/chttp2_plugin.cc', @@ -1386,10 +1394,14 @@ 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', - 'src/core/ext/filters/client_channel/health/health.pb.c', - 'third_party/nanopb/pb_common.c', - 'third_party/nanopb/pb_decode.c', - 'third_party/nanopb/pb_encode.c', + 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', + 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', + 'third_party/upb/upb/decode.c', + 'third_party/upb/upb/encode.c', + 'third_party/upb/upb/msg.c', + 'third_party/upb/upb/port.c', + 'third_party/upb/upb/table.c', + 'third_party/upb/upb/upb.c', 'src/core/ext/transport/inproc/inproc_plugin.cc', 'src/core/ext/transport/inproc/inproc_transport.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc', @@ -1414,13 +1426,9 @@ 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', - 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', - 'third_party/upb/upb/decode.c', - 'third_party/upb/upb/encode.c', - 'third_party/upb/upb/msg.c', - 'third_party/upb/upb/port.c', - 'third_party/upb/upb/table.c', - 'third_party/upb/upb/upb.c', + 'third_party/nanopb/pb_common.c', + 'third_party/nanopb/pb_decode.c', + 'third_party/nanopb/pb_encode.c', 'src/core/ext/filters/client_channel/lb_policy/xds/xds.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc', @@ -1540,10 +1548,14 @@ 'src/cpp/util/status.cc', 'src/cpp/util/string_ref.cc', 'src/cpp/util/time_cc.cc', - 'src/core/ext/filters/client_channel/health/health.pb.c', - 'third_party/nanopb/pb_common.c', - 'third_party/nanopb/pb_decode.c', - 'third_party/nanopb/pb_encode.c', + 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', + 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', + 'third_party/upb/upb/decode.c', + 'third_party/upb/upb/encode.c', + 'third_party/upb/upb/msg.c', + 'third_party/upb/upb/port.c', + 'third_party/upb/upb/table.c', + 'third_party/upb/upb/upb.c', 'src/cpp/codegen/codegen_init.cc', ], }, @@ -1697,10 +1709,14 @@ 'src/cpp/util/status.cc', 'src/cpp/util/string_ref.cc', 'src/cpp/util/time_cc.cc', - 'src/core/ext/filters/client_channel/health/health.pb.c', - 'third_party/nanopb/pb_common.c', - 'third_party/nanopb/pb_decode.c', - 'third_party/nanopb/pb_encode.c', + 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', + 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', + 'third_party/upb/upb/decode.c', + 'third_party/upb/upb/encode.c', + 'third_party/upb/upb/msg.c', + 'third_party/upb/upb/port.c', + 'third_party/upb/upb/table.c', + 'third_party/upb/upb/upb.c', 'src/cpp/codegen/codegen_init.cc', ], }, diff --git a/package.xml b/package.xml index adf09c06361..575449448ea 100644 --- a/package.xml +++ b/package.xml @@ -313,7 +313,7 @@ - + @@ -785,7 +785,7 @@ - + diff --git a/src/core/ext/filters/client_channel/health/health_check_client.cc b/src/core/ext/filters/client_channel/health/health_check_client.cc index a6b910b5dad..63a0a455fc1 100644 --- a/src/core/ext/filters/client_channel/health/health_check_client.cc +++ b/src/core/ext/filters/client_channel/health/health_check_client.cc @@ -23,14 +23,12 @@ #include "src/core/ext/filters/client_channel/health/health_check_client.h" -#include "pb_decode.h" -#include "pb_encode.h" -#include "src/core/ext/filters/client_channel/health/health.pb.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/error_utils.h" #include "src/core/lib/transport/status_metadata.h" +#include "src/proto/grpc/health/v1/health.upb.h" #define HEALTH_CHECK_INITIAL_CONNECT_BACKOFF_SECONDS 1 #define HEALTH_CHECK_RECONNECT_BACKOFF_MULTIPLIER 1.6 @@ -202,19 +200,16 @@ namespace { void EncodeRequest(const char* service_name, ManualConstructor* send_message) { - grpc_health_v1_HealthCheckRequest request_struct; - request_struct.has_service = true; - snprintf(request_struct.service, sizeof(request_struct.service), "%s", - service_name); - pb_ostream_t ostream; - memset(&ostream, 0, sizeof(ostream)); - pb_encode(&ostream, grpc_health_v1_HealthCheckRequest_fields, - &request_struct); - grpc_slice request_slice = GRPC_SLICE_MALLOC(ostream.bytes_written); - ostream = pb_ostream_from_buffer(GRPC_SLICE_START_PTR(request_slice), - GRPC_SLICE_LENGTH(request_slice)); - GPR_ASSERT(pb_encode(&ostream, grpc_health_v1_HealthCheckRequest_fields, - &request_struct) != 0); + upb::Arena arena; + grpc_health_v1_HealthCheckRequest* request_struct = + grpc_health_v1_HealthCheckRequest_new(arena.ptr()); + grpc_health_v1_HealthCheckRequest_set_service( + request_struct, upb_strview_makez(service_name)); + size_t buf_length; + char* buf = grpc_health_v1_HealthCheckRequest_serialize( + request_struct, arena.ptr(), &buf_length); + grpc_slice request_slice = GRPC_SLICE_MALLOC(buf_length); + memcpy(GRPC_SLICE_START_PTR(request_slice), buf, buf_length); grpc_slice_buffer slice_buffer; grpc_slice_buffer_init(&slice_buffer); grpc_slice_buffer_add(&slice_buffer, request_slice); @@ -248,24 +243,19 @@ bool DecodeResponse(grpc_slice_buffer* slice_buffer, grpc_error** error) { } } // Deserialize message. - grpc_health_v1_HealthCheckResponse response_struct; - pb_istream_t istream = - pb_istream_from_buffer(recv_message, slice_buffer->length); - if (!pb_decode(&istream, grpc_health_v1_HealthCheckResponse_fields, - &response_struct)) { + upb::Arena arena; + grpc_health_v1_HealthCheckResponse* response_struct = + grpc_health_v1_HealthCheckResponse_parse( + reinterpret_cast(recv_message), slice_buffer->length, + arena.ptr()); + if (response_struct == nullptr) { // Can't parse message; assume unhealthy. *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "cannot parse health check response"); return false; } - if (!response_struct.has_status) { - // Field not present; assume unhealthy. - *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "status field not present in health check response"); - return false; - } - return response_struct.status == - grpc_health_v1_HealthCheckResponse_ServingStatus_SERVING; + int32_t status = grpc_health_v1_HealthCheckResponse_status(response_struct); + return status == grpc_health_v1_HealthCheckResponse_SERVING; } } // namespace diff --git a/src/cpp/server/health/default_health_check_service.cc b/src/cpp/server/health/default_health_check_service.cc index 01bc51aa213..c6fd4c20fff 100644 --- a/src/cpp/server/health/default_health_check_service.cc +++ b/src/cpp/server/health/default_health_check_service.cc @@ -24,10 +24,10 @@ #include #include -#include "pb_decode.h" -#include "pb_encode.h" -#include "src/core/ext/filters/client_channel/health/health.pb.h" #include "src/cpp/server/health/default_health_check_service.h" +#include "src/proto/grpc/health/v1/health.upb.h" + +#define MAX_SERVICE_NAME_LENGTH 200 namespace grpc { @@ -204,8 +204,6 @@ bool DefaultHealthCheckService::HealthCheckServiceImpl::DecodeRequest( if (!request.Dump(&slices).ok()) return false; uint8_t* request_bytes = nullptr; size_t request_size = 0; - grpc_health_v1_HealthCheckRequest request_struct; - request_struct.has_service = false; if (slices.size() == 1) { request_bytes = const_cast(slices[0].begin()); request_size = slices[0].size(); @@ -217,37 +215,43 @@ bool DefaultHealthCheckService::HealthCheckServiceImpl::DecodeRequest( copy_to += slices[i].size(); } } - pb_istream_t istream = pb_istream_from_buffer(request_bytes, request_size); - bool decode_status = pb_decode( - &istream, grpc_health_v1_HealthCheckRequest_fields, &request_struct); + upb::Arena arena; + grpc_health_v1_HealthCheckRequest* request_struct = + grpc_health_v1_HealthCheckRequest_parse( + reinterpret_cast(request_bytes), request_size, arena.ptr()); if (slices.size() > 1) { gpr_free(request_bytes); } - if (!decode_status) return false; - *service_name = request_struct.has_service ? request_struct.service : ""; + if (request_struct == nullptr) { + return false; + } + upb_strview service = + grpc_health_v1_HealthCheckRequest_service(request_struct); + if (service.size > MAX_SERVICE_NAME_LENGTH) { + return false; + } + service_name->assign(service.data, service.size); return true; } bool DefaultHealthCheckService::HealthCheckServiceImpl::EncodeResponse( ServingStatus status, ByteBuffer* response) { - grpc_health_v1_HealthCheckResponse response_struct; - response_struct.has_status = true; - response_struct.status = + upb::Arena arena; + grpc_health_v1_HealthCheckResponse* response_struct = + grpc_health_v1_HealthCheckResponse_new(arena.ptr()); + grpc_health_v1_HealthCheckResponse_set_status( + response_struct, status == NOT_FOUND - ? grpc_health_v1_HealthCheckResponse_ServingStatus_SERVICE_UNKNOWN - : status == SERVING - ? grpc_health_v1_HealthCheckResponse_ServingStatus_SERVING - : grpc_health_v1_HealthCheckResponse_ServingStatus_NOT_SERVING; - pb_ostream_t ostream; - memset(&ostream, 0, sizeof(ostream)); - pb_encode(&ostream, grpc_health_v1_HealthCheckResponse_fields, - &response_struct); - grpc_slice response_slice = grpc_slice_malloc(ostream.bytes_written); - ostream = pb_ostream_from_buffer(GRPC_SLICE_START_PTR(response_slice), - GRPC_SLICE_LENGTH(response_slice)); - bool encode_status = pb_encode( - &ostream, grpc_health_v1_HealthCheckResponse_fields, &response_struct); - if (!encode_status) return false; + ? grpc_health_v1_HealthCheckResponse_SERVICE_UNKNOWN + : status == SERVING ? grpc_health_v1_HealthCheckResponse_SERVING + : grpc_health_v1_HealthCheckResponse_NOT_SERVING); + size_t buf_length; + char* buf = grpc_health_v1_HealthCheckResponse_serialize( + response_struct, arena.ptr(), &buf_length); + if (buf == nullptr) { + return false; + } + grpc_slice response_slice = grpc_slice_from_copied_buffer(buf, buf_length); Slice encoded_response(response_slice, Slice::STEAL_REF); ByteBuffer response_buffer(&encoded_response, 1); response->Swap(&response_buffer); diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 49a591c5f23..cf9f284db88 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -355,7 +355,7 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', - 'src/core/ext/filters/client_channel/health/health.pb.c', + 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', 'src/core/tsi/fake_transport_security.cc', 'src/core/tsi/local_transport_security.cc', 'src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc', diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index b43ae2f4254..3b7b4843815 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1059,9 +1059,9 @@ include/grpcpp/support/sync_stream.h \ include/grpcpp/support/sync_stream_impl.h \ include/grpcpp/support/time.h \ include/grpcpp/support/validate_service_config.h \ -src/core/ext/filters/client_channel/health/health.pb.c \ -src/core/ext/filters/client_channel/health/health.pb.h \ src/core/ext/transport/inproc/inproc_transport.h \ +src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ +src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h \ src/core/lib/avl/avl.h \ src/core/lib/backoff/backoff.h \ src/core/lib/channel/channel_args.h \ @@ -1293,12 +1293,16 @@ src/cpp/util/status.cc \ src/cpp/util/string_ref.cc \ src/cpp/util/time_cc.cc \ third_party/nanopb/pb.h \ -third_party/nanopb/pb_common.c \ third_party/nanopb/pb_common.h \ -third_party/nanopb/pb_decode.c \ third_party/nanopb/pb_decode.h \ -third_party/nanopb/pb_encode.c \ -third_party/nanopb/pb_encode.h +third_party/nanopb/pb_encode.h \ +third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ +third_party/upb/upb/decode.c \ +third_party/upb/upb/encode.c \ +third_party/upb/upb/msg.c \ +third_party/upb/upb/port.c \ +third_party/upb/upb/table.c \ +third_party/upb/upb/upb.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/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index d11ea7f7daa..e64dce2e3f1 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -889,8 +889,6 @@ src/core/ext/filters/client_channel/connector.cc \ src/core/ext/filters/client_channel/connector.h \ src/core/ext/filters/client_channel/global_subchannel_pool.cc \ src/core/ext/filters/client_channel/global_subchannel_pool.h \ -src/core/ext/filters/client_channel/health/health.pb.c \ -src/core/ext/filters/client_channel/health/health.pb.h \ src/core/ext/filters/client_channel/health/health_check_client.cc \ src/core/ext/filters/client_channel/health/health_check_client.h \ src/core/ext/filters/client_channel/http_connect_handshaker.cc \ @@ -1066,6 +1064,8 @@ src/core/ext/transport/chttp2/transport/writing.cc \ src/core/ext/transport/inproc/inproc_plugin.cc \ src/core/ext/transport/inproc/inproc_transport.cc \ src/core/ext/transport/inproc/inproc_transport.h \ +src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ +src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h \ src/core/lib/README.md \ src/core/lib/avl/avl.cc \ src/core/lib/avl/avl.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 0dcecd83a6b..b7ba89293a0 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -9089,7 +9089,7 @@ "gpr", "grpc_base", "grpc_deadline_filter", - "health_proto" + "grpc_health_upb" ], "headers": [ "src/core/ext/filters/client_channel/backup_poller.h", @@ -10222,23 +10222,6 @@ "third_party": false, "type": "filegroup" }, - { - "deps": [ - "nanopb" - ], - "headers": [ - "src/core/ext/filters/client_channel/health/health.pb.h" - ], - "is_filegroup": true, - "language": "c", - "name": "health_proto", - "src": [ - "src/core/ext/filters/client_channel/health/health.pb.c", - "src/core/ext/filters/client_channel/health/health.pb.h" - ], - "third_party": false, - "type": "filegroup" - }, { "deps": [ "nanopb_headers" @@ -10563,8 +10546,8 @@ "grpc++_codegen_base", "grpc++_internal_hdrs_only", "grpc_base_headers", + "grpc_health_upb", "grpc_transport_inproc_headers", - "health_proto", "nanopb_headers" ], "headers": [ From b892ea749c0af8bee6146e12f41170fc9a013c13 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Tue, 6 Aug 2019 17:49:16 -0700 Subject: [PATCH 1134/1555] Fixed address resolution failure by attaching to a host application Added copyright statements Fix clang format code --- src/objective-c/tests/BUILD | 45 ++++++++++++++++--- .../tests/Hosts/ios-host/AppDelegate.h | 25 +++++++++++ .../tests/Hosts/ios-host/AppDelegate.m | 27 +++++++++++ .../tests/Hosts/ios-host/Info.plist | 41 +++++++++++++++++ src/objective-c/tests/Hosts/ios-host/main.m | 26 +++++++++++ 5 files changed, 158 insertions(+), 6 deletions(-) create mode 100644 src/objective-c/tests/Hosts/ios-host/AppDelegate.h create mode 100644 src/objective-c/tests/Hosts/ios-host/AppDelegate.m create mode 100644 src/objective-c/tests/Hosts/ios-host/Info.plist create mode 100644 src/objective-c/tests/Hosts/ios-host/main.m diff --git a/src/objective-c/tests/BUILD b/src/objective-c/tests/BUILD index 2718cca5880..0817bbdd6c7 100644 --- a/src/objective-c/tests/BUILD +++ b/src/objective-c/tests/BUILD @@ -24,9 +24,9 @@ load( "testing_objc_grpc_library" ) load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle") -load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test") +load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application", "ios_unit_test") load("@build_bazel_rules_apple//apple:macos.bzl", "macos_unit_test") -load("@build_bazel_rules_apple//apple:tvos.bzl", "tvos_unit_test") +load("@build_bazel_rules_apple//apple:tvos.bzl", "tvos_application", "tvos_unit_test") exports_files(["LICENSE"]) @@ -59,12 +59,42 @@ grpc_objc_testing_library( hdrs = ["version.h"], data = [":TestCertificates"], defines = [ + "DEBUG=1", + "PB_FIELD_32BIT=1", + "PB_NO_PACKED_STRUCTS=1", + "PB_ENABLE_MALLOC=1", "HOST_PORT_LOCALSSL=localhost:5051", "HOST_PORT_LOCAL=localhost:5050", "HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com", ], ) +objc_library( + name = "host-lib", + srcs = glob(["Hosts/ios-host/*.m"]), + hdrs = glob(["Hosts/ios-host/*.h"]), +) + +ios_application( + name = "ios-host", + bundle_id = "grpc.objc.tests.ios-host", + infoplists = ["Hosts/ios-host/Info.plist"], + minimum_os_version = "9.0", + families = [ + "iphone", + "ipad", + ], + deps = ["host-lib"], +) + +tvos_application( + name = "tvos-host", + bundle_id = "grpc.objc.tests.tvos-host", + infoplists = ["Hosts/ios-host/Info.plist"], + minimum_os_version = "10.0", + deps = ["host-lib"], +) + grpc_objc_testing_library( name = "CronetConfig", srcs = ["ConfigureCronet.m"], @@ -159,7 +189,8 @@ ios_unit_test( ":ChannelPoolTest-lib", ":ChannelTests-lib", ":NSErrorUnitTests-lib", - ] + ], + test_host = ":ios-host", ) ios_unit_test( @@ -169,8 +200,9 @@ ios_unit_test( ":InteropTestsRemote-lib", ":InteropTestsLocalSSL-lib", ":InteropTestsLocalCleartext-lib", - # ":InteropTestsMultipleChannels-lib", #??????? Cronet must be used? + # ":InteropTestsMulitpleChannels-lib", # needs Cronet ], + test_host = ":ios-host", ) macos_unit_test( @@ -187,7 +219,7 @@ macos_unit_test( ] ) -# cares does not support tvOS CPU architecture with Bazel yet +# c-ares does not support tvOS CPU architecture with Bazel yet tvos_unit_test( name = "TvTests", minimum_os_version = "10.0", @@ -198,5 +230,6 @@ tvos_unit_test( ":InteropTestsRemote-lib", ":InteropTestsLocalSSL-lib", ":InteropTestsLocalCleartext-lib", - ] + ], + test_host = ":tvos-host", ) \ No newline at end of file diff --git a/src/objective-c/tests/Hosts/ios-host/AppDelegate.h b/src/objective-c/tests/Hosts/ios-host/AppDelegate.h new file mode 100644 index 00000000000..183abcf4ec8 --- /dev/null +++ b/src/objective-c/tests/Hosts/ios-host/AppDelegate.h @@ -0,0 +1,25 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import + +@interface AppDelegate : UIResponder + +@property(strong, nonatomic) UIWindow* window; + +@end diff --git a/src/objective-c/tests/Hosts/ios-host/AppDelegate.m b/src/objective-c/tests/Hosts/ios-host/AppDelegate.m new file mode 100644 index 00000000000..4a76f4c488c --- /dev/null +++ b/src/objective-c/tests/Hosts/ios-host/AppDelegate.m @@ -0,0 +1,27 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + +@end diff --git a/src/objective-c/tests/Hosts/ios-host/Info.plist b/src/objective-c/tests/Hosts/ios-host/Info.plist new file mode 100644 index 00000000000..e5baf19b85c --- /dev/null +++ b/src/objective-c/tests/Hosts/ios-host/Info.plist @@ -0,0 +1,41 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/src/objective-c/tests/Hosts/ios-host/main.m b/src/objective-c/tests/Hosts/ios-host/main.m new file mode 100644 index 00000000000..2797c6f17f2 --- /dev/null +++ b/src/objective-c/tests/Hosts/ios-host/main.m @@ -0,0 +1,26 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import +#import "AppDelegate.h" + +int main(int argc, char* argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} From b26b25113f2fd09046613a2956c7d84971259e7b Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 7 Aug 2019 11:22:01 -0700 Subject: [PATCH 1135/1555] Make soruce file validation exact --- bazel/python_rules.bzl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index c8fdd1ed3c0..0f00d53b6fb 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -70,7 +70,7 @@ def py_proto_library( srcs: A list of proto_library dependencies. Must contain a single element. """ codegen_target = "_{}_codegen".format(name) - if len(srcs) > 1: + if len(srcs) != 1: fail("Can only compile a single proto at a time.") @@ -158,10 +158,10 @@ def py_grpc_library( proto_library in `srcs`. """ codegen_grpc_target = "_{}_grpc_codegen".format(name) - if len(srcs) > 1: + if len(srcs) != 1: fail("Can only compile a single proto at a time.") - if len(deps) > 1: + if len(deps) != 1: fail("Deps must have length 1.") _generate_pb2_grpc_src( From bdd3fdddb26496b86bdd6aa117a04b140555b713 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Thu, 2 May 2019 11:08:59 -0400 Subject: [PATCH 1136/1555] Expose cycle counter and use it /channelz. We are using clock real time (which is very expensive) on every RPC to update channelz. We should simply use cycle clock. This patch exposes cycle clock, enables RDTSC on intel, and use it for channelz. This patch also changes the implementation of time_precise_init to that more accurately using the monotonic clock and shorter by looping at most a few hundred milliseconds. This is part of a larger performance series. --- include/grpc/impl/codegen/port_platform.h | 17 +++ src/core/lib/channel/channelz.cc | 110 ++++++++-------- src/core/lib/channel/channelz.h | 38 ++++-- src/core/lib/gpr/time_precise.cc | 145 ++++++++++++++++------ src/core/lib/gpr/time_precise.h | 36 ++++++ src/core/lib/gprpp/inlined_vector.h | 20 ++- test/core/channel/channelz_test.cc | 3 +- 7 files changed, 260 insertions(+), 109 deletions(-) diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index c0ca9f43716..dd49a66fe25 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -463,6 +463,23 @@ typedef unsigned __int64 uint64_t; #include #endif /* _MSC_VER */ +/* Type of cycle clock implementation */ +#ifdef GPR_LINUX +/* Disable cycle clock by default. + TODO(soheil): enable when we support fallback for unstable cycle clocks. +#if defined(__i386__) +#define GPR_CYCLE_COUNTER_RDTSC_32 1 +#elif defined(__x86_64__) || defined(__amd64__) +#define GPR_CYCLE_COUNTER_RDTSC_64 1 +#else +#define GPR_CYCLE_COUNTER_FALLBACK 1 +#endif +*/ +#define GPR_CYCLE_COUNTER_FALLBACK 1 +#else +#define GPR_CYCLE_COUNTER_FALLBACK 1 +#endif /* GPR_LINUX */ + /* Cache line alignment */ #ifndef GPR_CACHELINE_SIZE_LOG #if defined(__i386__) || defined(__x86_64__) diff --git a/src/core/lib/channel/channelz.cc b/src/core/lib/channel/channelz.cc index 325131b8439..fb913beb0f0 100644 --- a/src/core/lib/channel/channelz.cc +++ b/src/core/lib/channel/channelz.cc @@ -107,51 +107,45 @@ char* BaseNode::RenderJsonString() { CallCountingHelper::CallCountingHelper() { num_cores_ = GPR_MAX(1, gpr_cpu_num_cores()); - per_cpu_counter_data_storage_ = static_cast( - gpr_zalloc(sizeof(AtomicCounterData) * num_cores_)); -} - -CallCountingHelper::~CallCountingHelper() { - gpr_free(per_cpu_counter_data_storage_); + per_cpu_counter_data_storage_.reserve(num_cores_); + for (size_t i = 0; i < num_cores_; ++i) { + per_cpu_counter_data_storage_.emplace_back(); + } } void CallCountingHelper::RecordCallStarted() { - gpr_atm_no_barrier_fetch_add( - &per_cpu_counter_data_storage_[grpc_core::ExecCtx::Get()->starting_cpu()] - .calls_started, - static_cast(1)); - gpr_atm_no_barrier_store( - &per_cpu_counter_data_storage_[grpc_core::ExecCtx::Get()->starting_cpu()] - .last_call_started_millis, - (gpr_atm)ExecCtx::Get()->Now()); + AtomicCounterData& data = + per_cpu_counter_data_storage_[ExecCtx::Get()->starting_cpu()]; + data.calls_started.FetchAdd(1, MemoryOrder::RELAXED); + data.last_call_started_cycle.Store(gpr_get_cycle_counter(), + MemoryOrder::RELAXED); } void CallCountingHelper::RecordCallFailed() { - gpr_atm_no_barrier_fetch_add( - &per_cpu_counter_data_storage_[grpc_core::ExecCtx::Get()->starting_cpu()] - .calls_failed, - static_cast(1)); + per_cpu_counter_data_storage_[ExecCtx::Get()->starting_cpu()] + .calls_failed.FetchAdd(1, MemoryOrder::RELAXED); } void CallCountingHelper::RecordCallSucceeded() { - gpr_atm_no_barrier_fetch_add( - &per_cpu_counter_data_storage_[grpc_core::ExecCtx::Get()->starting_cpu()] - .calls_succeeded, - static_cast(1)); + per_cpu_counter_data_storage_[ExecCtx::Get()->starting_cpu()] + .calls_succeeded.FetchAdd(1, MemoryOrder::RELAXED); } void CallCountingHelper::CollectData(CounterData* out) { for (size_t core = 0; core < num_cores_; ++core) { - out->calls_started += gpr_atm_no_barrier_load( - &per_cpu_counter_data_storage_[core].calls_started); - out->calls_succeeded += gpr_atm_no_barrier_load( - &per_cpu_counter_data_storage_[core].calls_succeeded); - out->calls_failed += gpr_atm_no_barrier_load( - &per_cpu_counter_data_storage_[core].calls_failed); - gpr_atm last_call = gpr_atm_no_barrier_load( - &per_cpu_counter_data_storage_[core].last_call_started_millis); - if (last_call > out->last_call_started_millis) { - out->last_call_started_millis = last_call; + AtomicCounterData& data = per_cpu_counter_data_storage_[core]; + + out->calls_started += data.calls_started.Load(MemoryOrder::RELAXED); + out->calls_succeeded += + per_cpu_counter_data_storage_[core].calls_succeeded.Load( + MemoryOrder::RELAXED); + out->calls_failed += per_cpu_counter_data_storage_[core].calls_failed.Load( + MemoryOrder::RELAXED); + const gpr_cycle_counter last_call = + per_cpu_counter_data_storage_[core].last_call_started_cycle.Load( + MemoryOrder::RELAXED); + if (last_call > out->last_call_started_cycle) { + out->last_call_started_cycle = last_call; } } } @@ -173,8 +167,9 @@ void CallCountingHelper::PopulateCallCounts(grpc_json* json) { json, json_iterator, "callsFailed", data.calls_failed); } if (data.calls_started != 0) { - gpr_timespec ts = grpc_millis_to_timespec(data.last_call_started_millis, - GPR_CLOCK_REALTIME); + gpr_timespec ts = gpr_convert_clock_type( + gpr_cycle_counter_to_time(data.last_call_started_cycle), + GPR_CLOCK_REALTIME); json_iterator = grpc_json_create_child(json_iterator, json, "lastCallStartedTimestamp", gpr_format_timespec(ts), GRPC_JSON_STRING, true); @@ -493,26 +488,25 @@ SocketNode::SocketNode(UniquePtr local, UniquePtr remote, void SocketNode::RecordStreamStartedFromLocal() { gpr_atm_no_barrier_fetch_add(&streams_started_, static_cast(1)); - gpr_atm_no_barrier_store(&last_local_stream_created_millis_, - (gpr_atm)ExecCtx::Get()->Now()); + gpr_atm_no_barrier_store(&last_local_stream_created_cycle_, + gpr_get_cycle_counter()); } void SocketNode::RecordStreamStartedFromRemote() { gpr_atm_no_barrier_fetch_add(&streams_started_, static_cast(1)); - gpr_atm_no_barrier_store(&last_remote_stream_created_millis_, - (gpr_atm)ExecCtx::Get()->Now()); + gpr_atm_no_barrier_store(&last_remote_stream_created_cycle_, + gpr_get_cycle_counter()); } void SocketNode::RecordMessagesSent(uint32_t num_sent) { gpr_atm_no_barrier_fetch_add(&messages_sent_, static_cast(num_sent)); - gpr_atm_no_barrier_store(&last_message_sent_millis_, - (gpr_atm)ExecCtx::Get()->Now()); + gpr_atm_no_barrier_store(&last_message_sent_cycle_, gpr_get_cycle_counter()); } void SocketNode::RecordMessageReceived() { gpr_atm_no_barrier_fetch_add(&messages_received_, static_cast(1)); - gpr_atm_no_barrier_store(&last_message_received_millis_, - (gpr_atm)ExecCtx::Get()->Now()); + gpr_atm_no_barrier_store(&last_message_received_cycle_, + gpr_get_cycle_counter()); } grpc_json* SocketNode::RenderJson() { @@ -545,20 +539,22 @@ grpc_json* SocketNode::RenderJson() { if (streams_started != 0) { json_iterator = grpc_json_add_number_string_child( json, json_iterator, "streamsStarted", streams_started); - gpr_atm last_local_stream_created_millis = - gpr_atm_no_barrier_load(&last_local_stream_created_millis_); - if (last_local_stream_created_millis != 0) { - ts = grpc_millis_to_timespec(last_local_stream_created_millis, - GPR_CLOCK_REALTIME); + gpr_cycle_counter last_local_stream_created_cycle = + gpr_atm_no_barrier_load(&last_local_stream_created_cycle_); + if (last_local_stream_created_cycle != 0) { + ts = gpr_convert_clock_type( + gpr_cycle_counter_to_time(last_local_stream_created_cycle), + GPR_CLOCK_REALTIME); json_iterator = grpc_json_create_child( json_iterator, json, "lastLocalStreamCreatedTimestamp", gpr_format_timespec(ts), GRPC_JSON_STRING, true); } - gpr_atm last_remote_stream_created_millis = - gpr_atm_no_barrier_load(&last_remote_stream_created_millis_); - if (last_remote_stream_created_millis != 0) { - ts = grpc_millis_to_timespec(last_remote_stream_created_millis, - GPR_CLOCK_REALTIME); + gpr_cycle_counter last_remote_stream_created_cycle = + gpr_atm_no_barrier_load(&last_remote_stream_created_cycle_); + if (last_remote_stream_created_cycle != 0) { + ts = gpr_convert_clock_type( + gpr_cycle_counter_to_time(last_remote_stream_created_cycle), + GPR_CLOCK_REALTIME); json_iterator = grpc_json_create_child( json_iterator, json, "lastRemoteStreamCreatedTimestamp", gpr_format_timespec(ts), GRPC_JSON_STRING, true); @@ -578,8 +574,9 @@ grpc_json* SocketNode::RenderJson() { if (messages_sent != 0) { json_iterator = grpc_json_add_number_string_child( json, json_iterator, "messagesSent", messages_sent); - ts = grpc_millis_to_timespec( - gpr_atm_no_barrier_load(&last_message_sent_millis_), + ts = gpr_convert_clock_type( + gpr_cycle_counter_to_time( + gpr_atm_no_barrier_load(&last_message_sent_cycle_)), GPR_CLOCK_REALTIME); json_iterator = grpc_json_create_child(json_iterator, json, "lastMessageSentTimestamp", @@ -589,8 +586,9 @@ grpc_json* SocketNode::RenderJson() { if (messages_received != 0) { json_iterator = grpc_json_add_number_string_child( json, json_iterator, "messagesReceived", messages_received); - ts = grpc_millis_to_timespec( - gpr_atm_no_barrier_load(&last_message_received_millis_), + ts = gpr_convert_clock_type( + gpr_cycle_counter_to_time( + gpr_atm_no_barrier_load(&last_message_received_cycle_)), GPR_CLOCK_REALTIME); json_iterator = grpc_json_create_child( json_iterator, json, "lastMessageReceivedTimestamp", diff --git a/src/core/lib/channel/channelz.h b/src/core/lib/channel/channelz.h index e1af701834d..2561bff807e 100644 --- a/src/core/lib/channel/channelz.h +++ b/src/core/lib/channel/channelz.h @@ -24,6 +24,7 @@ #include #include "src/core/lib/channel/channel_trace.h" +#include "src/core/lib/gpr/time_precise.h" #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/gprpp/map.h" @@ -111,7 +112,6 @@ class BaseNode : public RefCounted { class CallCountingHelper { public: CallCountingHelper(); - ~CallCountingHelper(); void RecordCallStarted(); void RecordCallFailed(); @@ -124,24 +124,38 @@ class CallCountingHelper { // testing peer friend. friend class testing::CallCountingHelperPeer; + // TODO(soheil): add a proper PerCPU helper and use it here. struct AtomicCounterData { - gpr_atm calls_started = 0; - gpr_atm calls_succeeded = 0; - gpr_atm calls_failed = 0; - gpr_atm last_call_started_millis = 0; - }; + // Define the ctors so that we can use this structure in InlinedVector. + AtomicCounterData() = default; + AtomicCounterData(const AtomicCounterData& that) + : calls_started(that.calls_started.Load(MemoryOrder::RELAXED)), + calls_succeeded(that.calls_succeeded.Load(MemoryOrder::RELAXED)), + calls_failed(that.calls_failed.Load(MemoryOrder::RELAXED)), + last_call_started_cycle( + that.last_call_started_cycle.Load(MemoryOrder::RELAXED)) {} + + Atomic calls_started{0}; + Atomic calls_succeeded{0}; + Atomic calls_failed{0}; + Atomic last_call_started_cycle{0}; + // Make sure the size is exactly one cache line. + uint8_t padding[GPR_CACHELINE_SIZE - 3 * sizeof(Atomic) - + sizeof(Atomic)]; + } GPR_ALIGN_STRUCT(GPR_CACHELINE_SIZE); struct CounterData { intptr_t calls_started = 0; intptr_t calls_succeeded = 0; intptr_t calls_failed = 0; - intptr_t last_call_started_millis = 0; + gpr_cycle_counter last_call_started_cycle = 0; }; // collects the sharded data into one CounterData struct. void CollectData(CounterData* out); - AtomicCounterData* per_cpu_counter_data_storage_ = nullptr; + // Really zero-sized, but 0-sized arrays are illegal on MSVC. + InlinedVector per_cpu_counter_data_storage_; size_t num_cores_ = 0; }; @@ -281,10 +295,10 @@ class SocketNode : public BaseNode { gpr_atm messages_sent_ = 0; gpr_atm messages_received_ = 0; gpr_atm keepalives_sent_ = 0; - gpr_atm last_local_stream_created_millis_ = 0; - gpr_atm last_remote_stream_created_millis_ = 0; - gpr_atm last_message_sent_millis_ = 0; - gpr_atm last_message_received_millis_ = 0; + gpr_atm last_local_stream_created_cycle_ = 0; + gpr_atm last_remote_stream_created_cycle_ = 0; + gpr_atm last_message_sent_cycle_ = 0; + gpr_atm last_message_received_cycle_ = 0; UniquePtr local_; UniquePtr remote_; }; diff --git a/src/core/lib/gpr/time_precise.cc b/src/core/lib/gpr/time_precise.cc index 1b34fd7eb1b..9d11c66831c 100644 --- a/src/core/lib/gpr/time_precise.cc +++ b/src/core/lib/gpr/time_precise.cc @@ -18,61 +18,132 @@ #include +#if GPR_LINUX +#include +#include +#endif + +#include + +#include #include #include -#include #include "src/core/lib/gpr/time_precise.h" -#ifdef GRPC_TIMERS_RDTSC -#if defined(__i386__) -static void gpr_get_cycle_counter(int64_t int* clk) { - int64_t int ret; - __asm__ volatile("rdtsc" : "=A"(ret)); - *clk = ret; +#if GPR_CYCLE_COUNTER_RDTSC_32 or GPR_CYCLE_COUNTER_RDTSC_64 +#if GPR_LINUX +static bool read_freq_from_kernel(double* freq) { + // Google production kernel export the frequency for us in kHz. + int fd = open("/sys/devices/system/cpu/cpu0/tsc_freq_khz", O_RDONLY); + if (fd == -1) { + return false; + } + char line[1024] = {}; + char* err; + bool ret = false; + int len = read(fd, line, sizeof(line) - 1); + if (len > 0) { + const long val = strtol(line, &err, 10); + if (line[0] != '\0' && (*err == '\n' || *err == '\0')) { + *freq = val * 1e3; // Value is kHz. + ret = true; + } + } + close(fd); + return ret; } - -// ---------------------------------------------------------------- -#elif defined(__x86_64__) || defined(__amd64__) -static void gpr_get_cycle_counter(int64_t* clk) { - uint64_t low, high; - __asm__ volatile("rdtsc" : "=a"(low), "=d"(high)); - *clk = (int64_t)(high << 32) | (int64_t)low; -} -#endif +#endif /* GPR_LINUX */ static double cycles_per_second = 0; -static int64_t start_cycle; +static gpr_cycle_counter start_cycle; + +static bool is_fake_clock() { + gpr_timespec start = gpr_now(GPR_CLOCK_MONOTONIC); + int64_t sum = 0; + for (int i = 0; i < 8; ++i) { + gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); + gpr_timespec delta = gpr_time_sub(now, start); + sum += delta.tv_sec * GPR_NS_PER_SEC + delta.tv_nsec; + } + // If the clock doesn't move even a nano after 8 tries, it's a fake one. + return sum == 0; +} + void gpr_precise_clock_init(void) { - time_t start; - int64_t end_cycle; gpr_log(GPR_DEBUG, "Calibrating timers"); - start = time(NULL); - while (time(NULL) == start) - ; - gpr_get_cycle_counter(&start_cycle); - while (time(NULL) <= start + 10) - ; - gpr_get_cycle_counter(&end_cycle); - cycles_per_second = (double)(end_cycle - start_cycle) / 10.0; + +#if GPR_LINUX + if (read_freq_from_kernel(&cycles_per_second)) { + start_cycle = gpr_get_cycle_counter(); + return; + } +#endif /* GPR_LINUX */ + + if (is_fake_clock()) { + cycles_per_second = 1; + start_cycle = 0; + return; + } + // Start from a loop of 1ms, and gradually increase the loop duration + // until we either converge or we have passed 255ms (1ms+2ms+...+128ms). + int64_t measurement_ns = GPR_NS_PER_MS; + double last_freq = -1; + bool converged = false; + for (int i = 0; i < 8 && !converged; ++i, measurement_ns *= 2) { + start_cycle = gpr_get_cycle_counter(); + int64_t loop_ns; + gpr_timespec start = gpr_now(GPR_CLOCK_MONOTONIC); + do { + // TODO(soheil): Maybe sleep instead of busy polling. + gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); + gpr_timespec delta = gpr_time_sub(now, start); + loop_ns = delta.tv_sec * GPR_NS_PER_SEC + delta.tv_nsec; + } while (loop_ns < measurement_ns); + gpr_cycle_counter end_cycle = gpr_get_cycle_counter(); + // Frequency should be in Hz. + const double freq = + static_cast(end_cycle - start_cycle) / loop_ns * GPR_NS_PER_SEC; + converged = + last_freq != -1 && (freq * 0.99 < last_freq && last_freq < freq * 1.01); + last_freq = freq; + } + cycles_per_second = last_freq; gpr_log(GPR_DEBUG, "... cycles_per_second = %f\n", cycles_per_second); } -void gpr_precise_clock_now(gpr_timespec* clk) { - int64_t counter; - double secs; - gpr_get_cycle_counter(&counter); - secs = (double)(counter - start_cycle) / cycles_per_second; - clk->clock_type = GPR_CLOCK_PRECISE; - clk->tv_sec = (int64_t)secs; - clk->tv_nsec = (int32_t)(1e9 * (secs - (double)clk->tv_sec)); +gpr_timespec gpr_cycle_counter_to_time(gpr_cycle_counter cycles) { + double secs = static_cast(cycles - start_cycle) / cycles_per_second; + gpr_timespec ts; + ts.tv_sec = static_cast(secs); + ts.tv_nsec = static_cast(GPR_NS_PER_SEC * + (secs - static_cast(ts.tv_sec))); + ts.clock_type = GPR_CLOCK_PRECISE; + return ts; } -#else /* GRPC_TIMERS_RDTSC */ +void gpr_precise_clock_now(gpr_timespec* clk) { + int64_t counter = gpr_get_cycle_counter(); + *clk = gpr_cycle_counter_to_time(counter); +} +#elif GPR_CYCLE_COUNTER_FALLBACK void gpr_precise_clock_init(void) {} +gpr_cycle_counter gpr_get_cycle_counter() { + gpr_timespec ts = gpr_now(GPR_CLOCK_REALTIME); + return gpr_timespec_to_micros(ts); +} + +gpr_timespec gpr_cycle_counter_to_time(gpr_cycle_counter cycles) { + gpr_timespec ts; + ts.tv_sec = cycles / GPR_US_PER_SEC; + ts.tv_nsec = (cycles - ts.tv_sec * GPR_US_PER_SEC) * GPR_NS_PER_US; + ts.clock_type = GPR_CLOCK_PRECISE; + return ts; +} + void gpr_precise_clock_now(gpr_timespec* clk) { *clk = gpr_now(GPR_CLOCK_REALTIME); clk->clock_type = GPR_CLOCK_PRECISE; } -#endif /* GRPC_TIMERS_RDTSC */ +#endif /* GPR_CYCLE_COUNTER_FALLBACK */ diff --git a/src/core/lib/gpr/time_precise.h b/src/core/lib/gpr/time_precise.h index a63ea9dc689..ce16bafab2d 100644 --- a/src/core/lib/gpr/time_precise.h +++ b/src/core/lib/gpr/time_precise.h @@ -21,9 +21,45 @@ #include +#include #include +// Depending on the platform gpr_get_cycle_counter() can have a resolution as +// low as a usec. Use other clock sources or gpr_precise_clock_now(), +// where you need high resolution clocks. +// +// Using gpr_get_cycle_counter() is preferred to using ExecCtx::Get()->Now() +// whenever possible. + +#if GPR_CYCLE_COUNTER_RDTSC_32 +typedef int64_t gpr_cycle_counter; +inline gpr_cycle_counter gpr_get_cycle_counter() { + int64_t ret; + __asm__ volatile("rdtsc" : "=A"(ret)); + return ret; +} +#elif GPR_CYCLE_COUNTER_RDTSC_64 +typedef int64_t gpr_cycle_counter; +inline gpr_cycle_counter gpr_get_cycle_counter() { + uint64_t low, high; + __asm__ volatile("rdtsc" : "=a"(low), "=d"(high)); + return (high << 32) | low; +} +#elif GPR_CYCLE_COUNTER_FALLBACK +// TODO(soheil): add support for mrs on Arm. + +// Real time in micros. +typedef double gpr_cycle_counter; +gpr_cycle_counter gpr_get_cycle_counter(); +#else +#error Must define exactly one of \ + GPR_CYCLE_COUNTER_RDTSC_32, \ + GPR_CYCLE_COUNTER_RDTSC_64, or \ + GPR_CYCLE_COUNTER_FALLBACK +#endif + void gpr_precise_clock_init(void); void gpr_precise_clock_now(gpr_timespec* clk); +gpr_timespec gpr_cycle_counter_to_time(gpr_cycle_counter cycles); #endif /* GRPC_CORE_LIB_GPR_TIME_PRECISE_H */ diff --git a/src/core/lib/gprpp/inlined_vector.h b/src/core/lib/gprpp/inlined_vector.h index f511d520f50..c5ae0e8e65d 100644 --- a/src/core/lib/gprpp/inlined_vector.h +++ b/src/core/lib/gprpp/inlined_vector.h @@ -109,9 +109,13 @@ class InlinedVector { void reserve(size_t capacity) { if (capacity > capacity_) { - T* new_dynamic = static_cast(gpr_malloc(sizeof(T) * capacity)); + T* new_dynamic = + std::alignment_of::value == 0 + ? static_cast(gpr_malloc(sizeof(T) * capacity)) + : static_cast(gpr_malloc_aligned( + sizeof(T) * capacity, std::alignment_of::value)); move_elements(data(), new_dynamic, size_); - gpr_free(dynamic_); + free_dynamic(); dynamic_ = new_dynamic; capacity_ = capacity; } @@ -196,7 +200,17 @@ class InlinedVector { T& value = data()[i]; value.~T(); } - gpr_free(dynamic_); + free_dynamic(); + } + + void free_dynamic() { + if (dynamic_ != nullptr) { + if (std::alignment_of::value == 0) { + gpr_free(dynamic_); + } else { + gpr_free_aligned(dynamic_); + } + } } typename std::aligned_storage::type inline_[N]; diff --git a/test/core/channel/channelz_test.cc b/test/core/channel/channelz_test.cc index 7c55f9ffe0f..08ed4dd4fa5 100644 --- a/test/core/channel/channelz_test.cc +++ b/test/core/channel/channelz_test.cc @@ -51,7 +51,8 @@ class CallCountingHelperPeer { grpc_millis last_call_started_millis() const { CallCountingHelper::CounterData data; node_->CollectData(&data); - return (grpc_millis)gpr_atm_no_barrier_load(&data.last_call_started_millis); + gpr_timespec ts = gpr_cycle_counter_to_time(data.last_call_started_cycle); + return grpc_timespec_to_millis_round_up(ts); } private: From b1021ae64816c1da0ec01a5aa390267651bf0d63 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 7 Aug 2019 11:22:56 -0700 Subject: [PATCH 1137/1555] Capitalize name. --- tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh b/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh index 00bf971a3e2..f725eb7a3d7 100755 --- a/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh +++ b/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh @@ -30,7 +30,7 @@ bazel clean --expunge bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //src/python/... bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //examples/python/... -# TODO(https://github.com/grpc/grpc/issues/19854): Move this to a new kokoro +# TODO(https://github.com/grpc/grpc/issues/19854): Move this to a new Kokoro # job. (cd /var/local/git/grpc/bazel/test/python_test_repo; bazel test --test_output=errors //... From 6ddfb384c120f129e92bd85589e2ae7aad99e253 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 7 Aug 2019 11:59:36 -0700 Subject: [PATCH 1138/1555] Added google/protobuf/descriptor.upb.* to google_api_upb --- BUILD | 2 + BUILD.gn | 2 - CMakeLists.txt | 7 - Makefile | 9 +- build.yaml | 4 +- cmake/upb.cmake | 1 - config.m4 | 3 - config.w32 | 5 - gRPC-C++.podspec | 2 - gRPC-Core.podspec | 3 - grpc.gemspec | 1 - grpc.gyp | 9 - package.xml | 1 - setup.py | 2 - .../google/protobuf/descriptor.upb.c | 485 +++++ .../google/protobuf/descriptor.upb.h | 1690 +++++++++++++++++ src/python/grpcio/grpc_core_dependencies.py | 1 - src/upb/gen_build_yaml.py | 2 - templates/config.m4.template | 1 - templates/config.w32.template | 1 - templates/gRPC-C++.podspec.template | 2 - templates/gRPC-Core.podspec.template | 2 - tools/codegen/core/gen_upb_api.sh | 1 + tools/doxygen/Doxyfile.c++.internal | 1 - tools/doxygen/Doxyfile.core.internal | 1 - .../generated/sources_and_headers.json | 4 +- 26 files changed, 2185 insertions(+), 57 deletions(-) create mode 100644 src/core/ext/upb-generated/google/protobuf/descriptor.upb.c create mode 100644 src/core/ext/upb-generated/google/protobuf/descriptor.upb.h diff --git a/BUILD b/BUILD index ac23308620d..74af17760a9 100644 --- a/BUILD +++ b/BUILD @@ -2329,6 +2329,7 @@ grpc_cc_library( srcs = [ "src/core/ext/upb-generated/google/protobuf/any.upb.c", "src/core/ext/upb-generated/google/protobuf/duration.upb.c", + "src/core/ext/upb-generated/google/protobuf/descriptor.upb.c", "src/core/ext/upb-generated/google/protobuf/empty.upb.c", "src/core/ext/upb-generated/google/protobuf/struct.upb.c", "src/core/ext/upb-generated/google/protobuf/timestamp.upb.c", @@ -2337,6 +2338,7 @@ grpc_cc_library( hdrs = [ "src/core/ext/upb-generated/google/protobuf/any.upb.h", "src/core/ext/upb-generated/google/protobuf/duration.upb.h", + "src/core/ext/upb-generated/google/protobuf/descriptor.upb.h", "src/core/ext/upb-generated/google/protobuf/empty.upb.h", "src/core/ext/upb-generated/google/protobuf/struct.upb.h", "src/core/ext/upb-generated/google/protobuf/timestamp.upb.h", diff --git a/BUILD.gn b/BUILD.gn index df9329bdacd..9b003465bc8 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -857,7 +857,6 @@ config("grpc_config") { "src/core/tsi/transport_security_grpc.cc", "src/core/tsi/transport_security_grpc.h", "src/core/tsi/transport_security_interface.h", - "third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c", "third_party/upb/upb/decode.c", "third_party/upb/upb/encode.c", "third_party/upb/upb/msg.c", @@ -1382,7 +1381,6 @@ config("grpc_config") { "src/cpp/util/status.cc", "src/cpp/util/string_ref.cc", "src/cpp/util/time_cc.cc", - "third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c", "third_party/upb/upb/decode.c", "third_party/upb/upb/encode.c", "third_party/upb/upb/msg.c", diff --git a/CMakeLists.txt b/CMakeLists.txt index 00183363fdc..2034ec6c490 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1266,7 +1266,6 @@ add_library(grpc third_party/nanopb/pb_decode.c third_party/nanopb/pb_encode.c src/core/tsi/transport_security.cc - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c third_party/upb/upb/decode.c third_party/upb/upb/encode.c third_party/upb/upb/msg.c @@ -1678,7 +1677,6 @@ add_library(grpc_cronet src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c third_party/upb/upb/decode.c third_party/upb/upb/encode.c third_party/upb/upb/msg.c @@ -2077,7 +2075,6 @@ add_library(grpc_test_util src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c third_party/upb/upb/decode.c third_party/upb/upb/encode.c third_party/upb/upb/msg.c @@ -2419,7 +2416,6 @@ add_library(grpc_test_util_unsecure src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c third_party/upb/upb/decode.c third_party/upb/upb/encode.c third_party/upb/upb/msg.c @@ -2772,7 +2768,6 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c third_party/upb/upb/decode.c third_party/upb/upb/encode.c third_party/upb/upb/msg.c @@ -3173,7 +3168,6 @@ add_library(grpc++ src/cpp/util/string_ref.cc src/cpp/util/time_cc.cc src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c third_party/upb/upb/decode.c third_party/upb/upb/encode.c third_party/upb/upb/msg.c @@ -4283,7 +4277,6 @@ add_library(grpc++_unsecure src/cpp/util/string_ref.cc src/cpp/util/time_cc.cc src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c third_party/upb/upb/decode.c third_party/upb/upb/encode.c third_party/upb/upb/msg.c diff --git a/Makefile b/Makefile index 97eaae13b2e..97eb59912ec 100644 --- a/Makefile +++ b/Makefile @@ -348,7 +348,7 @@ CXXFLAGS += -stdlib=libc++ LDFLAGS += -framework CoreFoundation endif CXXFLAGS += -Wnon-virtual-dtor -CPPFLAGS += -g -Wall -Wextra -Werror -Wno-unknown-warning-option -Wno-long-long -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-maybe-uninitialized -DPB_FIELD_32BIT -DOSATOMIC_USE_INLINED=1 -Ithird_party/nanopb -Ithird_party/upb -Ithird_party/upb/generated_for_cmake -Isrc/core/ext/upb-generated +CPPFLAGS += -g -Wall -Wextra -Werror -Wno-unknown-warning-option -Wno-long-long -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-maybe-uninitialized -DPB_FIELD_32BIT -DOSATOMIC_USE_INLINED=1 -Ithird_party/nanopb -Ithird_party/upb -Isrc/core/ext/upb-generated COREFLAGS += -fno-rtti -fno-exceptions LDFLAGS += -g @@ -3757,7 +3757,6 @@ LIBGRPC_SRC = \ third_party/nanopb/pb_decode.c \ third_party/nanopb/pb_encode.c \ src/core/tsi/transport_security.cc \ - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ third_party/upb/upb/decode.c \ third_party/upb/upb/encode.c \ third_party/upb/upb/msg.c \ @@ -4157,7 +4156,6 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ third_party/upb/upb/decode.c \ third_party/upb/upb/encode.c \ third_party/upb/upb/msg.c \ @@ -4543,7 +4541,6 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ third_party/upb/upb/decode.c \ third_party/upb/upb/encode.c \ third_party/upb/upb/msg.c \ @@ -4866,7 +4863,6 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ third_party/upb/upb/decode.c \ third_party/upb/upb/encode.c \ third_party/upb/upb/msg.c \ @@ -5187,7 +5183,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ third_party/upb/upb/decode.c \ third_party/upb/upb/encode.c \ third_party/upb/upb/msg.c \ @@ -5534,7 +5529,6 @@ LIBGRPC++_SRC = \ src/cpp/util/string_ref.cc \ src/cpp/util/time_cc.cc \ src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ third_party/upb/upb/decode.c \ third_party/upb/upb/encode.c \ third_party/upb/upb/msg.c \ @@ -6566,7 +6560,6 @@ LIBGRPC++_UNSECURE_SRC = \ src/cpp/util/string_ref.cc \ src/cpp/util/time_cc.cc \ src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ third_party/upb/upb/decode.c \ third_party/upb/upb/encode.c \ third_party/upb/upb/msg.c \ diff --git a/build.yaml b/build.yaml index ee6c05795d7..0563f6558fb 100644 --- a/build.yaml +++ b/build.yaml @@ -125,6 +125,7 @@ filegroups: - name: google_api_upb headers: - src/core/ext/upb-generated/google/protobuf/any.upb.h + - src/core/ext/upb-generated/google/protobuf/descriptor.upb.h - src/core/ext/upb-generated/google/protobuf/duration.upb.h - src/core/ext/upb-generated/google/protobuf/empty.upb.h - src/core/ext/upb-generated/google/protobuf/struct.upb.h @@ -132,6 +133,7 @@ filegroups: - src/core/ext/upb-generated/google/protobuf/wrappers.upb.h src: - src/core/ext/upb-generated/google/protobuf/any.upb.c + - src/core/ext/upb-generated/google/protobuf/descriptor.upb.c - src/core/ext/upb-generated/google/protobuf/duration.upb.c - src/core/ext/upb-generated/google/protobuf/empty.upb.c - src/core/ext/upb-generated/google/protobuf/struct.upb.c @@ -6197,7 +6199,7 @@ defaults: -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-maybe-uninitialized -DPB_FIELD_32BIT -DOSATOMIC_USE_INLINED=1 -Ithird_party/nanopb - -Ithird_party/upb -Ithird_party/upb/generated_for_cmake -Isrc/core/ext/upb-generated + -Ithird_party/upb -Isrc/core/ext/upb-generated CXXFLAGS: -Wnon-virtual-dtor LDFLAGS: -g zlib: diff --git a/cmake/upb.cmake b/cmake/upb.cmake index 8a5ef86f1c4..3affa25d382 100644 --- a/cmake/upb.cmake +++ b/cmake/upb.cmake @@ -15,5 +15,4 @@ set(UPB_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/upb) set(_gRPC_UPB_INCLUDE_DIR "${UPB_ROOT_DIR}") -set(_gRPC_UPB_GENERATED_DIR "${UPB_ROOT_DIR}/generated_for_cmake") set(_gRPC_UPB_GRPC_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/core/ext/upb-generated") diff --git a/config.m4 b/config.m4 index dfb4f7eb0c6..34974f18ac2 100644 --- a/config.m4 +++ b/config.m4 @@ -12,7 +12,6 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/boringssl/include) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/nanopb) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/upb) - PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/upb/generated_for_cmake) LIBS="-lpthread $LIBS" @@ -346,7 +345,6 @@ if test "$PHP_GRPC" != "no"; then third_party/nanopb/pb_decode.c \ third_party/nanopb/pb_encode.c \ src/core/tsi/transport_security.cc \ - third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ third_party/upb/upb/decode.c \ third_party/upb/upb/encode.c \ third_party/upb/upb/msg.c \ @@ -816,6 +814,5 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/ssl) PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/third_party/fiat) PHP_ADD_BUILD_DIR($ext_builddir/third_party/nanopb) - PHP_ADD_BUILD_DIR($ext_builddir/third_party/upb/generated_for_cmake/google/protobuf) PHP_ADD_BUILD_DIR($ext_builddir/third_party/upb/upb) fi diff --git a/config.w32 b/config.w32 index 06a52da2904..db7f05c7aa5 100644 --- a/config.w32 +++ b/config.w32 @@ -318,7 +318,6 @@ if (PHP_GRPC != "no") { "third_party\\nanopb\\pb_decode.c " + "third_party\\nanopb\\pb_encode.c " + "src\\core\\tsi\\transport_security.cc " + - "third_party\\upb\\generated_for_cmake\\google\\protobuf\\descriptor.upb.c " + "third_party\\upb\\upb\\decode.c " + "third_party\\upb\\upb\\encode.c " + "third_party\\upb\\upb\\msg.c " + @@ -692,7 +691,6 @@ if (PHP_GRPC != "no") { "/I"+configure_module_dirname+"\\third_party\\boringssl\\include "+ "/I"+configure_module_dirname+"\\third_party\\nanopb "+ "/I"+configure_module_dirname+"\\third_party\\upb "+ - "/I"+configure_module_dirname+"\\third_party\\upb\\generated_for_cmake "+ "/I"+configure_module_dirname+"\\third_party\\zlib "); base_dir = get_define('BUILD_DIR'); @@ -844,9 +842,6 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\third_party\\fiat"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\nanopb"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\upb"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\upb\\generated_for_cmake"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\upb\\generated_for_cmake\\google"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\upb\\generated_for_cmake\\google\\protobuf"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\upb\\upb"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\zlib"); _build_dirs = new Array(); diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index b6482fe66b9..7e728026e68 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -805,7 +805,5 @@ Pod::Spec.new do |s| find src/core/ third_party/upb/ -type f -name '*.grpc_back' -print0 | xargs -0 rm find src/core/ src/cpp/ -type f \\( -name '*.h' -or -name '*.c' -or -name '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(.*).upb.h";#if COCOAPODS==1\\\n #include "src/core/ext/upb-generated/\\1.upb.h"\\\n#else\\\n #include "\\1.upb.h"\\\n#endif;g' find src/core/ src/cpp/ -type f -name '*.grpc_back' -print0 | xargs -0 rm - find third_party/upb/ -type f \\( -name '*.h' -or -name '*.c' -or -name '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(.*).upb.h";#if COCOAPODS==1\\\n #include "third_party/upb/generated_for_cmake/\\1.upb.h"\\\n#else\\\n #include "\\1.upb.h"\\\n#endif;g' - find third_party/upb/ -type f -name '*.grpc_back' -print0 | xargs -0 rm END_OF_COMMAND end diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 07dccee41f9..1e2be599afb 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -805,7 +805,6 @@ Pod::Spec.new do |s| 'src/core/tsi/alts/handshaker/handshaker.pb.c', 'src/core/tsi/alts/handshaker/transport_security_common.pb.c', 'src/core/tsi/transport_security.cc', - 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', 'third_party/upb/upb/decode.c', 'third_party/upb/upb/encode.c', 'third_party/upb/upb/msg.c', @@ -1402,7 +1401,5 @@ Pod::Spec.new do |s| find src/core/ third_party/upb/ -type f -name '*.grpc_back' -print0 | xargs -0 rm find src/core/ src/cpp/ -type f \\( -name '*.h' -or -name '*.c' -or -name '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(.*).upb.h";#if COCOAPODS==1\\\n #include "src/core/ext/upb-generated/\\1.upb.h"\\\n#else\\\n #include "\\1.upb.h"\\\n#endif;g' find src/core/ src/cpp/ -type f -name '*.grpc_back' -print0 | xargs -0 rm - find third_party/upb/ -type f \\( -name '*.h' -or -name '*.c' -or -name '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(.*).upb.h";#if COCOAPODS==1\\\n #include "third_party/upb/generated_for_cmake/\\1.upb.h"\\\n#else\\\n #include "\\1.upb.h"\\\n#endif;g' - find third_party/upb/ -type f -name '*.grpc_back' -print0 | xargs -0 rm END_OF_COMMAND end diff --git a/grpc.gemspec b/grpc.gemspec index d56ed118d6d..45f4a759473 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -742,7 +742,6 @@ Gem::Specification.new do |s| s.files += %w( third_party/nanopb/pb_decode.c ) s.files += %w( third_party/nanopb/pb_encode.c ) s.files += %w( src/core/tsi/transport_security.cc ) - s.files += %w( third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c ) s.files += %w( third_party/upb/upb/decode.c ) s.files += %w( third_party/upb/upb/encode.c ) s.files += %w( third_party/upb/upb/msg.c ) diff --git a/grpc.gyp b/grpc.gyp index b4c19bb6124..a5287a606ed 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -70,7 +70,6 @@ '-DOSATOMIC_USE_INLINED=1', '-Ithird_party/nanopb', '-Ithird_party/upb', - '-Ithird_party/upb/generated_for_cmake', '-Isrc/core/ext/upb-generated', ], 'ldflags': [ @@ -162,7 +161,6 @@ '-DOSATOMIC_USE_INLINED=1', '-Ithird_party/nanopb', '-Ithird_party/upb', - '-Ithird_party/upb/generated_for_cmake', '-Isrc/core/ext/upb-generated', ], 'OTHER_CPLUSPLUSFLAGS': [ @@ -185,7 +183,6 @@ '-DOSATOMIC_USE_INLINED=1', '-Ithird_party/nanopb', '-Ithird_party/upb', - '-Ithird_party/upb/generated_for_cmake', '-Isrc/core/ext/upb-generated', '-stdlib=libc++', '-std=c++11', @@ -558,7 +555,6 @@ 'third_party/nanopb/pb_decode.c', 'third_party/nanopb/pb_encode.c', 'src/core/tsi/transport_security.cc', - 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', 'third_party/upb/upb/decode.c', 'third_party/upb/upb/encode.c', 'third_party/upb/upb/msg.c', @@ -872,7 +868,6 @@ 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', - 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', 'third_party/upb/upb/decode.c', 'third_party/upb/upb/encode.c', 'third_party/upb/upb/msg.c', @@ -1128,7 +1123,6 @@ 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', - 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', 'third_party/upb/upb/decode.c', 'third_party/upb/upb/encode.c', 'third_party/upb/upb/msg.c', @@ -1395,7 +1389,6 @@ 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', - 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', 'third_party/upb/upb/decode.c', 'third_party/upb/upb/encode.c', 'third_party/upb/upb/msg.c', @@ -1549,7 +1542,6 @@ 'src/cpp/util/string_ref.cc', 'src/cpp/util/time_cc.cc', 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', - 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', 'third_party/upb/upb/decode.c', 'third_party/upb/upb/encode.c', 'third_party/upb/upb/msg.c', @@ -1710,7 +1702,6 @@ 'src/cpp/util/string_ref.cc', 'src/cpp/util/time_cc.cc', 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', - 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', 'third_party/upb/upb/decode.c', 'third_party/upb/upb/encode.c', 'third_party/upb/upb/msg.c', diff --git a/package.xml b/package.xml index 575449448ea..fc68a9cdf12 100644 --- a/package.xml +++ b/package.xml @@ -747,7 +747,6 @@ - diff --git a/setup.py b/setup.py index fe8e8d05afd..4f787c05cf7 100644 --- a/setup.py +++ b/setup.py @@ -50,7 +50,6 @@ if 'openbsd' in sys.platform: NANOPB_INCLUDE = (os.path.join('third_party', 'nanopb'),) SSL_INCLUDE = (os.path.join('third_party', 'boringssl', 'include'),) UPB_INCLUDE = (os.path.join('third_party', 'upb'),) -UPB_GENERATED_INCLUDE = (os.path.join('third_party','upb', 'generated_for_cmake'),) UPB_GRPC_GENERATED_INCLUDE = (os.path.join('src', 'core', 'ext', 'upb-generated'),) ZLIB_INCLUDE = (os.path.join('third_party', 'zlib'),) README = os.path.join(PYTHON_STEM, 'README.rst') @@ -213,7 +212,6 @@ EXTENSION_INCLUDE_DIRECTORIES = ( NANOPB_INCLUDE + SSL_INCLUDE + UPB_INCLUDE + - UPB_GENERATED_INCLUDE + UPB_GRPC_GENERATED_INCLUDE + ZLIB_INCLUDE) diff --git a/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c b/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c new file mode 100644 index 00000000000..61b9299bb43 --- /dev/null +++ b/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c @@ -0,0 +1,485 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * google/protobuf/descriptor.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#include +#include "upb/msg.h" +#include "google/protobuf/descriptor.upb.h" + +#include "upb/port_def.inc" + +static const upb_msglayout *const google_protobuf_FileDescriptorSet_submsgs[1] = { + &google_protobuf_FileDescriptorProto_msginit, +}; + +static const upb_msglayout_field google_protobuf_FileDescriptorSet__fields[1] = { + {1, UPB_SIZE(0, 0), 0, 0, 11, 3}, +}; + +const upb_msglayout google_protobuf_FileDescriptorSet_msginit = { + &google_protobuf_FileDescriptorSet_submsgs[0], + &google_protobuf_FileDescriptorSet__fields[0], + UPB_SIZE(4, 8), 1, false, +}; + +static const upb_msglayout *const google_protobuf_FileDescriptorProto_submsgs[6] = { + &google_protobuf_DescriptorProto_msginit, + &google_protobuf_EnumDescriptorProto_msginit, + &google_protobuf_FieldDescriptorProto_msginit, + &google_protobuf_FileOptions_msginit, + &google_protobuf_ServiceDescriptorProto_msginit, + &google_protobuf_SourceCodeInfo_msginit, +}; + +static const upb_msglayout_field google_protobuf_FileDescriptorProto__fields[12] = { + {1, UPB_SIZE(4, 8), 1, 0, 9, 1}, + {2, UPB_SIZE(12, 24), 2, 0, 9, 1}, + {3, UPB_SIZE(36, 72), 0, 0, 9, 3}, + {4, UPB_SIZE(40, 80), 0, 0, 11, 3}, + {5, UPB_SIZE(44, 88), 0, 1, 11, 3}, + {6, UPB_SIZE(48, 96), 0, 4, 11, 3}, + {7, UPB_SIZE(52, 104), 0, 2, 11, 3}, + {8, UPB_SIZE(28, 56), 4, 3, 11, 1}, + {9, UPB_SIZE(32, 64), 5, 5, 11, 1}, + {10, UPB_SIZE(56, 112), 0, 0, 5, 3}, + {11, UPB_SIZE(60, 120), 0, 0, 5, 3}, + {12, UPB_SIZE(20, 40), 3, 0, 9, 1}, +}; + +const upb_msglayout google_protobuf_FileDescriptorProto_msginit = { + &google_protobuf_FileDescriptorProto_submsgs[0], + &google_protobuf_FileDescriptorProto__fields[0], + UPB_SIZE(64, 128), 12, false, +}; + +static const upb_msglayout *const google_protobuf_DescriptorProto_submsgs[8] = { + &google_protobuf_DescriptorProto_msginit, + &google_protobuf_DescriptorProto_ExtensionRange_msginit, + &google_protobuf_DescriptorProto_ReservedRange_msginit, + &google_protobuf_EnumDescriptorProto_msginit, + &google_protobuf_FieldDescriptorProto_msginit, + &google_protobuf_MessageOptions_msginit, + &google_protobuf_OneofDescriptorProto_msginit, +}; + +static const upb_msglayout_field google_protobuf_DescriptorProto__fields[10] = { + {1, UPB_SIZE(4, 8), 1, 0, 9, 1}, + {2, UPB_SIZE(16, 32), 0, 4, 11, 3}, + {3, UPB_SIZE(20, 40), 0, 0, 11, 3}, + {4, UPB_SIZE(24, 48), 0, 3, 11, 3}, + {5, UPB_SIZE(28, 56), 0, 1, 11, 3}, + {6, UPB_SIZE(32, 64), 0, 4, 11, 3}, + {7, UPB_SIZE(12, 24), 2, 5, 11, 1}, + {8, UPB_SIZE(36, 72), 0, 6, 11, 3}, + {9, UPB_SIZE(40, 80), 0, 2, 11, 3}, + {10, UPB_SIZE(44, 88), 0, 0, 9, 3}, +}; + +const upb_msglayout google_protobuf_DescriptorProto_msginit = { + &google_protobuf_DescriptorProto_submsgs[0], + &google_protobuf_DescriptorProto__fields[0], + UPB_SIZE(48, 96), 10, false, +}; + +static const upb_msglayout *const google_protobuf_DescriptorProto_ExtensionRange_submsgs[1] = { + &google_protobuf_ExtensionRangeOptions_msginit, +}; + +static const upb_msglayout_field google_protobuf_DescriptorProto_ExtensionRange__fields[3] = { + {1, UPB_SIZE(4, 4), 1, 0, 5, 1}, + {2, UPB_SIZE(8, 8), 2, 0, 5, 1}, + {3, UPB_SIZE(12, 16), 3, 0, 11, 1}, +}; + +const upb_msglayout google_protobuf_DescriptorProto_ExtensionRange_msginit = { + &google_protobuf_DescriptorProto_ExtensionRange_submsgs[0], + &google_protobuf_DescriptorProto_ExtensionRange__fields[0], + UPB_SIZE(16, 24), 3, false, +}; + +static const upb_msglayout_field google_protobuf_DescriptorProto_ReservedRange__fields[2] = { + {1, UPB_SIZE(4, 4), 1, 0, 5, 1}, + {2, UPB_SIZE(8, 8), 2, 0, 5, 1}, +}; + +const upb_msglayout google_protobuf_DescriptorProto_ReservedRange_msginit = { + NULL, + &google_protobuf_DescriptorProto_ReservedRange__fields[0], + UPB_SIZE(12, 12), 2, false, +}; + +static const upb_msglayout *const google_protobuf_ExtensionRangeOptions_submsgs[1] = { + &google_protobuf_UninterpretedOption_msginit, +}; + +static const upb_msglayout_field google_protobuf_ExtensionRangeOptions__fields[1] = { + {999, UPB_SIZE(0, 0), 0, 0, 11, 3}, +}; + +const upb_msglayout google_protobuf_ExtensionRangeOptions_msginit = { + &google_protobuf_ExtensionRangeOptions_submsgs[0], + &google_protobuf_ExtensionRangeOptions__fields[0], + UPB_SIZE(4, 8), 1, false, +}; + +static const upb_msglayout *const google_protobuf_FieldDescriptorProto_submsgs[1] = { + &google_protobuf_FieldOptions_msginit, +}; + +static const upb_msglayout_field google_protobuf_FieldDescriptorProto__fields[10] = { + {1, UPB_SIZE(32, 32), 5, 0, 9, 1}, + {2, UPB_SIZE(40, 48), 6, 0, 9, 1}, + {3, UPB_SIZE(24, 24), 3, 0, 5, 1}, + {4, UPB_SIZE(8, 8), 1, 0, 14, 1}, + {5, UPB_SIZE(16, 16), 2, 0, 14, 1}, + {6, UPB_SIZE(48, 64), 7, 0, 9, 1}, + {7, UPB_SIZE(56, 80), 8, 0, 9, 1}, + {8, UPB_SIZE(72, 112), 10, 0, 11, 1}, + {9, UPB_SIZE(28, 28), 4, 0, 5, 1}, + {10, UPB_SIZE(64, 96), 9, 0, 9, 1}, +}; + +const upb_msglayout google_protobuf_FieldDescriptorProto_msginit = { + &google_protobuf_FieldDescriptorProto_submsgs[0], + &google_protobuf_FieldDescriptorProto__fields[0], + UPB_SIZE(80, 128), 10, false, +}; + +static const upb_msglayout *const google_protobuf_OneofDescriptorProto_submsgs[1] = { + &google_protobuf_OneofOptions_msginit, +}; + +static const upb_msglayout_field google_protobuf_OneofDescriptorProto__fields[2] = { + {1, UPB_SIZE(4, 8), 1, 0, 9, 1}, + {2, UPB_SIZE(12, 24), 2, 0, 11, 1}, +}; + +const upb_msglayout google_protobuf_OneofDescriptorProto_msginit = { + &google_protobuf_OneofDescriptorProto_submsgs[0], + &google_protobuf_OneofDescriptorProto__fields[0], + UPB_SIZE(16, 32), 2, false, +}; + +static const upb_msglayout *const google_protobuf_EnumDescriptorProto_submsgs[3] = { + &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, + &google_protobuf_EnumOptions_msginit, + &google_protobuf_EnumValueDescriptorProto_msginit, +}; + +static const upb_msglayout_field google_protobuf_EnumDescriptorProto__fields[5] = { + {1, UPB_SIZE(4, 8), 1, 0, 9, 1}, + {2, UPB_SIZE(16, 32), 0, 2, 11, 3}, + {3, UPB_SIZE(12, 24), 2, 1, 11, 1}, + {4, UPB_SIZE(20, 40), 0, 0, 11, 3}, + {5, UPB_SIZE(24, 48), 0, 0, 9, 3}, +}; + +const upb_msglayout google_protobuf_EnumDescriptorProto_msginit = { + &google_protobuf_EnumDescriptorProto_submsgs[0], + &google_protobuf_EnumDescriptorProto__fields[0], + UPB_SIZE(32, 64), 5, false, +}; + +static const upb_msglayout_field google_protobuf_EnumDescriptorProto_EnumReservedRange__fields[2] = { + {1, UPB_SIZE(4, 4), 1, 0, 5, 1}, + {2, UPB_SIZE(8, 8), 2, 0, 5, 1}, +}; + +const upb_msglayout google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit = { + NULL, + &google_protobuf_EnumDescriptorProto_EnumReservedRange__fields[0], + UPB_SIZE(12, 12), 2, false, +}; + +static const upb_msglayout *const google_protobuf_EnumValueDescriptorProto_submsgs[1] = { + &google_protobuf_EnumValueOptions_msginit, +}; + +static const upb_msglayout_field google_protobuf_EnumValueDescriptorProto__fields[3] = { + {1, UPB_SIZE(8, 8), 2, 0, 9, 1}, + {2, UPB_SIZE(4, 4), 1, 0, 5, 1}, + {3, UPB_SIZE(16, 24), 3, 0, 11, 1}, +}; + +const upb_msglayout google_protobuf_EnumValueDescriptorProto_msginit = { + &google_protobuf_EnumValueDescriptorProto_submsgs[0], + &google_protobuf_EnumValueDescriptorProto__fields[0], + UPB_SIZE(24, 32), 3, false, +}; + +static const upb_msglayout *const google_protobuf_ServiceDescriptorProto_submsgs[2] = { + &google_protobuf_MethodDescriptorProto_msginit, + &google_protobuf_ServiceOptions_msginit, +}; + +static const upb_msglayout_field google_protobuf_ServiceDescriptorProto__fields[3] = { + {1, UPB_SIZE(4, 8), 1, 0, 9, 1}, + {2, UPB_SIZE(16, 32), 0, 0, 11, 3}, + {3, UPB_SIZE(12, 24), 2, 1, 11, 1}, +}; + +const upb_msglayout google_protobuf_ServiceDescriptorProto_msginit = { + &google_protobuf_ServiceDescriptorProto_submsgs[0], + &google_protobuf_ServiceDescriptorProto__fields[0], + UPB_SIZE(24, 48), 3, false, +}; + +static const upb_msglayout *const google_protobuf_MethodDescriptorProto_submsgs[1] = { + &google_protobuf_MethodOptions_msginit, +}; + +static const upb_msglayout_field google_protobuf_MethodDescriptorProto__fields[6] = { + {1, UPB_SIZE(4, 8), 3, 0, 9, 1}, + {2, UPB_SIZE(12, 24), 4, 0, 9, 1}, + {3, UPB_SIZE(20, 40), 5, 0, 9, 1}, + {4, UPB_SIZE(28, 56), 6, 0, 11, 1}, + {5, UPB_SIZE(1, 1), 1, 0, 8, 1}, + {6, UPB_SIZE(2, 2), 2, 0, 8, 1}, +}; + +const upb_msglayout google_protobuf_MethodDescriptorProto_msginit = { + &google_protobuf_MethodDescriptorProto_submsgs[0], + &google_protobuf_MethodDescriptorProto__fields[0], + UPB_SIZE(32, 64), 6, false, +}; + +static const upb_msglayout *const google_protobuf_FileOptions_submsgs[1] = { + &google_protobuf_UninterpretedOption_msginit, +}; + +static const upb_msglayout_field google_protobuf_FileOptions__fields[21] = { + {1, UPB_SIZE(28, 32), 11, 0, 9, 1}, + {8, UPB_SIZE(36, 48), 12, 0, 9, 1}, + {9, UPB_SIZE(8, 8), 1, 0, 14, 1}, + {10, UPB_SIZE(16, 16), 2, 0, 8, 1}, + {11, UPB_SIZE(44, 64), 13, 0, 9, 1}, + {16, UPB_SIZE(17, 17), 3, 0, 8, 1}, + {17, UPB_SIZE(18, 18), 4, 0, 8, 1}, + {18, UPB_SIZE(19, 19), 5, 0, 8, 1}, + {20, UPB_SIZE(20, 20), 6, 0, 8, 1}, + {23, UPB_SIZE(21, 21), 7, 0, 8, 1}, + {27, UPB_SIZE(22, 22), 8, 0, 8, 1}, + {31, UPB_SIZE(23, 23), 9, 0, 8, 1}, + {36, UPB_SIZE(52, 80), 14, 0, 9, 1}, + {37, UPB_SIZE(60, 96), 15, 0, 9, 1}, + {39, UPB_SIZE(68, 112), 16, 0, 9, 1}, + {40, UPB_SIZE(76, 128), 17, 0, 9, 1}, + {41, UPB_SIZE(84, 144), 18, 0, 9, 1}, + {42, UPB_SIZE(24, 24), 10, 0, 8, 1}, + {44, UPB_SIZE(92, 160), 19, 0, 9, 1}, + {45, UPB_SIZE(100, 176), 20, 0, 9, 1}, + {999, UPB_SIZE(108, 192), 0, 0, 11, 3}, +}; + +const upb_msglayout google_protobuf_FileOptions_msginit = { + &google_protobuf_FileOptions_submsgs[0], + &google_protobuf_FileOptions__fields[0], + UPB_SIZE(112, 208), 21, false, +}; + +static const upb_msglayout *const google_protobuf_MessageOptions_submsgs[1] = { + &google_protobuf_UninterpretedOption_msginit, +}; + +static const upb_msglayout_field google_protobuf_MessageOptions__fields[5] = { + {1, UPB_SIZE(1, 1), 1, 0, 8, 1}, + {2, UPB_SIZE(2, 2), 2, 0, 8, 1}, + {3, UPB_SIZE(3, 3), 3, 0, 8, 1}, + {7, UPB_SIZE(4, 4), 4, 0, 8, 1}, + {999, UPB_SIZE(8, 8), 0, 0, 11, 3}, +}; + +const upb_msglayout google_protobuf_MessageOptions_msginit = { + &google_protobuf_MessageOptions_submsgs[0], + &google_protobuf_MessageOptions__fields[0], + UPB_SIZE(12, 16), 5, false, +}; + +static const upb_msglayout *const google_protobuf_FieldOptions_submsgs[1] = { + &google_protobuf_UninterpretedOption_msginit, +}; + +static const upb_msglayout_field google_protobuf_FieldOptions__fields[7] = { + {1, UPB_SIZE(8, 8), 1, 0, 14, 1}, + {2, UPB_SIZE(24, 24), 3, 0, 8, 1}, + {3, UPB_SIZE(25, 25), 4, 0, 8, 1}, + {5, UPB_SIZE(26, 26), 5, 0, 8, 1}, + {6, UPB_SIZE(16, 16), 2, 0, 14, 1}, + {10, UPB_SIZE(27, 27), 6, 0, 8, 1}, + {999, UPB_SIZE(28, 32), 0, 0, 11, 3}, +}; + +const upb_msglayout google_protobuf_FieldOptions_msginit = { + &google_protobuf_FieldOptions_submsgs[0], + &google_protobuf_FieldOptions__fields[0], + UPB_SIZE(32, 40), 7, false, +}; + +static const upb_msglayout *const google_protobuf_OneofOptions_submsgs[1] = { + &google_protobuf_UninterpretedOption_msginit, +}; + +static const upb_msglayout_field google_protobuf_OneofOptions__fields[1] = { + {999, UPB_SIZE(0, 0), 0, 0, 11, 3}, +}; + +const upb_msglayout google_protobuf_OneofOptions_msginit = { + &google_protobuf_OneofOptions_submsgs[0], + &google_protobuf_OneofOptions__fields[0], + UPB_SIZE(4, 8), 1, false, +}; + +static const upb_msglayout *const google_protobuf_EnumOptions_submsgs[1] = { + &google_protobuf_UninterpretedOption_msginit, +}; + +static const upb_msglayout_field google_protobuf_EnumOptions__fields[3] = { + {2, UPB_SIZE(1, 1), 1, 0, 8, 1}, + {3, UPB_SIZE(2, 2), 2, 0, 8, 1}, + {999, UPB_SIZE(4, 8), 0, 0, 11, 3}, +}; + +const upb_msglayout google_protobuf_EnumOptions_msginit = { + &google_protobuf_EnumOptions_submsgs[0], + &google_protobuf_EnumOptions__fields[0], + UPB_SIZE(8, 16), 3, false, +}; + +static const upb_msglayout *const google_protobuf_EnumValueOptions_submsgs[1] = { + &google_protobuf_UninterpretedOption_msginit, +}; + +static const upb_msglayout_field google_protobuf_EnumValueOptions__fields[2] = { + {1, UPB_SIZE(1, 1), 1, 0, 8, 1}, + {999, UPB_SIZE(4, 8), 0, 0, 11, 3}, +}; + +const upb_msglayout google_protobuf_EnumValueOptions_msginit = { + &google_protobuf_EnumValueOptions_submsgs[0], + &google_protobuf_EnumValueOptions__fields[0], + UPB_SIZE(8, 16), 2, false, +}; + +static const upb_msglayout *const google_protobuf_ServiceOptions_submsgs[1] = { + &google_protobuf_UninterpretedOption_msginit, +}; + +static const upb_msglayout_field google_protobuf_ServiceOptions__fields[2] = { + {33, UPB_SIZE(1, 1), 1, 0, 8, 1}, + {999, UPB_SIZE(4, 8), 0, 0, 11, 3}, +}; + +const upb_msglayout google_protobuf_ServiceOptions_msginit = { + &google_protobuf_ServiceOptions_submsgs[0], + &google_protobuf_ServiceOptions__fields[0], + UPB_SIZE(8, 16), 2, false, +}; + +static const upb_msglayout *const google_protobuf_MethodOptions_submsgs[1] = { + &google_protobuf_UninterpretedOption_msginit, +}; + +static const upb_msglayout_field google_protobuf_MethodOptions__fields[3] = { + {33, UPB_SIZE(16, 16), 2, 0, 8, 1}, + {34, UPB_SIZE(8, 8), 1, 0, 14, 1}, + {999, UPB_SIZE(20, 24), 0, 0, 11, 3}, +}; + +const upb_msglayout google_protobuf_MethodOptions_msginit = { + &google_protobuf_MethodOptions_submsgs[0], + &google_protobuf_MethodOptions__fields[0], + UPB_SIZE(24, 32), 3, false, +}; + +static const upb_msglayout *const google_protobuf_UninterpretedOption_submsgs[1] = { + &google_protobuf_UninterpretedOption_NamePart_msginit, +}; + +static const upb_msglayout_field google_protobuf_UninterpretedOption__fields[7] = { + {2, UPB_SIZE(56, 80), 0, 0, 11, 3}, + {3, UPB_SIZE(32, 32), 4, 0, 9, 1}, + {4, UPB_SIZE(8, 8), 1, 0, 4, 1}, + {5, UPB_SIZE(16, 16), 2, 0, 3, 1}, + {6, UPB_SIZE(24, 24), 3, 0, 1, 1}, + {7, UPB_SIZE(40, 48), 5, 0, 12, 1}, + {8, UPB_SIZE(48, 64), 6, 0, 9, 1}, +}; + +const upb_msglayout google_protobuf_UninterpretedOption_msginit = { + &google_protobuf_UninterpretedOption_submsgs[0], + &google_protobuf_UninterpretedOption__fields[0], + UPB_SIZE(64, 96), 7, false, +}; + +static const upb_msglayout_field google_protobuf_UninterpretedOption_NamePart__fields[2] = { + {1, UPB_SIZE(4, 8), 2, 0, 9, 2}, + {2, UPB_SIZE(1, 1), 1, 0, 8, 2}, +}; + +const upb_msglayout google_protobuf_UninterpretedOption_NamePart_msginit = { + NULL, + &google_protobuf_UninterpretedOption_NamePart__fields[0], + UPB_SIZE(16, 32), 2, false, +}; + +static const upb_msglayout *const google_protobuf_SourceCodeInfo_submsgs[1] = { + &google_protobuf_SourceCodeInfo_Location_msginit, +}; + +static const upb_msglayout_field google_protobuf_SourceCodeInfo__fields[1] = { + {1, UPB_SIZE(0, 0), 0, 0, 11, 3}, +}; + +const upb_msglayout google_protobuf_SourceCodeInfo_msginit = { + &google_protobuf_SourceCodeInfo_submsgs[0], + &google_protobuf_SourceCodeInfo__fields[0], + UPB_SIZE(4, 8), 1, false, +}; + +static const upb_msglayout_field google_protobuf_SourceCodeInfo_Location__fields[5] = { + {1, UPB_SIZE(20, 40), 0, 0, 5, 3}, + {2, UPB_SIZE(24, 48), 0, 0, 5, 3}, + {3, UPB_SIZE(4, 8), 1, 0, 9, 1}, + {4, UPB_SIZE(12, 24), 2, 0, 9, 1}, + {6, UPB_SIZE(28, 56), 0, 0, 9, 3}, +}; + +const upb_msglayout google_protobuf_SourceCodeInfo_Location_msginit = { + NULL, + &google_protobuf_SourceCodeInfo_Location__fields[0], + UPB_SIZE(32, 64), 5, false, +}; + +static const upb_msglayout *const google_protobuf_GeneratedCodeInfo_submsgs[1] = { + &google_protobuf_GeneratedCodeInfo_Annotation_msginit, +}; + +static const upb_msglayout_field google_protobuf_GeneratedCodeInfo__fields[1] = { + {1, UPB_SIZE(0, 0), 0, 0, 11, 3}, +}; + +const upb_msglayout google_protobuf_GeneratedCodeInfo_msginit = { + &google_protobuf_GeneratedCodeInfo_submsgs[0], + &google_protobuf_GeneratedCodeInfo__fields[0], + UPB_SIZE(4, 8), 1, false, +}; + +static const upb_msglayout_field google_protobuf_GeneratedCodeInfo_Annotation__fields[4] = { + {1, UPB_SIZE(20, 32), 0, 0, 5, 3}, + {2, UPB_SIZE(12, 16), 3, 0, 9, 1}, + {3, UPB_SIZE(4, 4), 1, 0, 5, 1}, + {4, UPB_SIZE(8, 8), 2, 0, 5, 1}, +}; + +const upb_msglayout google_protobuf_GeneratedCodeInfo_Annotation_msginit = { + NULL, + &google_protobuf_GeneratedCodeInfo_Annotation__fields[0], + UPB_SIZE(24, 48), 4, false, +}; + +#include "upb/port_undef.inc" + diff --git a/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h b/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h new file mode 100644 index 00000000000..681614910e0 --- /dev/null +++ b/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h @@ -0,0 +1,1690 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * google/protobuf/descriptor.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#ifndef GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_ +#define GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_ + +#include "upb/generated_util.h" +#include "upb/msg.h" +#include "upb/decode.h" +#include "upb/encode.h" + +#include "upb/port_def.inc" + +#ifdef __cplusplus +extern "C" { +#endif + +struct google_protobuf_FileDescriptorSet; +struct google_protobuf_FileDescriptorProto; +struct google_protobuf_DescriptorProto; +struct google_protobuf_DescriptorProto_ExtensionRange; +struct google_protobuf_DescriptorProto_ReservedRange; +struct google_protobuf_ExtensionRangeOptions; +struct google_protobuf_FieldDescriptorProto; +struct google_protobuf_OneofDescriptorProto; +struct google_protobuf_EnumDescriptorProto; +struct google_protobuf_EnumDescriptorProto_EnumReservedRange; +struct google_protobuf_EnumValueDescriptorProto; +struct google_protobuf_ServiceDescriptorProto; +struct google_protobuf_MethodDescriptorProto; +struct google_protobuf_FileOptions; +struct google_protobuf_MessageOptions; +struct google_protobuf_FieldOptions; +struct google_protobuf_OneofOptions; +struct google_protobuf_EnumOptions; +struct google_protobuf_EnumValueOptions; +struct google_protobuf_ServiceOptions; +struct google_protobuf_MethodOptions; +struct google_protobuf_UninterpretedOption; +struct google_protobuf_UninterpretedOption_NamePart; +struct google_protobuf_SourceCodeInfo; +struct google_protobuf_SourceCodeInfo_Location; +struct google_protobuf_GeneratedCodeInfo; +struct google_protobuf_GeneratedCodeInfo_Annotation; +typedef struct google_protobuf_FileDescriptorSet google_protobuf_FileDescriptorSet; +typedef struct google_protobuf_FileDescriptorProto google_protobuf_FileDescriptorProto; +typedef struct google_protobuf_DescriptorProto google_protobuf_DescriptorProto; +typedef struct google_protobuf_DescriptorProto_ExtensionRange google_protobuf_DescriptorProto_ExtensionRange; +typedef struct google_protobuf_DescriptorProto_ReservedRange google_protobuf_DescriptorProto_ReservedRange; +typedef struct google_protobuf_ExtensionRangeOptions google_protobuf_ExtensionRangeOptions; +typedef struct google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto; +typedef struct google_protobuf_OneofDescriptorProto google_protobuf_OneofDescriptorProto; +typedef struct google_protobuf_EnumDescriptorProto google_protobuf_EnumDescriptorProto; +typedef struct google_protobuf_EnumDescriptorProto_EnumReservedRange google_protobuf_EnumDescriptorProto_EnumReservedRange; +typedef struct google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescriptorProto; +typedef struct google_protobuf_ServiceDescriptorProto google_protobuf_ServiceDescriptorProto; +typedef struct google_protobuf_MethodDescriptorProto google_protobuf_MethodDescriptorProto; +typedef struct google_protobuf_FileOptions google_protobuf_FileOptions; +typedef struct google_protobuf_MessageOptions google_protobuf_MessageOptions; +typedef struct google_protobuf_FieldOptions google_protobuf_FieldOptions; +typedef struct google_protobuf_OneofOptions google_protobuf_OneofOptions; +typedef struct google_protobuf_EnumOptions google_protobuf_EnumOptions; +typedef struct google_protobuf_EnumValueOptions google_protobuf_EnumValueOptions; +typedef struct google_protobuf_ServiceOptions google_protobuf_ServiceOptions; +typedef struct google_protobuf_MethodOptions google_protobuf_MethodOptions; +typedef struct google_protobuf_UninterpretedOption google_protobuf_UninterpretedOption; +typedef struct google_protobuf_UninterpretedOption_NamePart google_protobuf_UninterpretedOption_NamePart; +typedef struct google_protobuf_SourceCodeInfo google_protobuf_SourceCodeInfo; +typedef struct google_protobuf_SourceCodeInfo_Location google_protobuf_SourceCodeInfo_Location; +typedef struct google_protobuf_GeneratedCodeInfo google_protobuf_GeneratedCodeInfo; +typedef struct google_protobuf_GeneratedCodeInfo_Annotation google_protobuf_GeneratedCodeInfo_Annotation; +extern const upb_msglayout google_protobuf_FileDescriptorSet_msginit; +extern const upb_msglayout google_protobuf_FileDescriptorProto_msginit; +extern const upb_msglayout google_protobuf_DescriptorProto_msginit; +extern const upb_msglayout google_protobuf_DescriptorProto_ExtensionRange_msginit; +extern const upb_msglayout google_protobuf_DescriptorProto_ReservedRange_msginit; +extern const upb_msglayout google_protobuf_ExtensionRangeOptions_msginit; +extern const upb_msglayout google_protobuf_FieldDescriptorProto_msginit; +extern const upb_msglayout google_protobuf_OneofDescriptorProto_msginit; +extern const upb_msglayout google_protobuf_EnumDescriptorProto_msginit; +extern const upb_msglayout google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit; +extern const upb_msglayout google_protobuf_EnumValueDescriptorProto_msginit; +extern const upb_msglayout google_protobuf_ServiceDescriptorProto_msginit; +extern const upb_msglayout google_protobuf_MethodDescriptorProto_msginit; +extern const upb_msglayout google_protobuf_FileOptions_msginit; +extern const upb_msglayout google_protobuf_MessageOptions_msginit; +extern const upb_msglayout google_protobuf_FieldOptions_msginit; +extern const upb_msglayout google_protobuf_OneofOptions_msginit; +extern const upb_msglayout google_protobuf_EnumOptions_msginit; +extern const upb_msglayout google_protobuf_EnumValueOptions_msginit; +extern const upb_msglayout google_protobuf_ServiceOptions_msginit; +extern const upb_msglayout google_protobuf_MethodOptions_msginit; +extern const upb_msglayout google_protobuf_UninterpretedOption_msginit; +extern const upb_msglayout google_protobuf_UninterpretedOption_NamePart_msginit; +extern const upb_msglayout google_protobuf_SourceCodeInfo_msginit; +extern const upb_msglayout google_protobuf_SourceCodeInfo_Location_msginit; +extern const upb_msglayout google_protobuf_GeneratedCodeInfo_msginit; +extern const upb_msglayout google_protobuf_GeneratedCodeInfo_Annotation_msginit; + +typedef enum { + google_protobuf_FieldDescriptorProto_LABEL_OPTIONAL = 1, + google_protobuf_FieldDescriptorProto_LABEL_REQUIRED = 2, + google_protobuf_FieldDescriptorProto_LABEL_REPEATED = 3 +} google_protobuf_FieldDescriptorProto_Label; + +typedef enum { + google_protobuf_FieldDescriptorProto_TYPE_DOUBLE = 1, + google_protobuf_FieldDescriptorProto_TYPE_FLOAT = 2, + google_protobuf_FieldDescriptorProto_TYPE_INT64 = 3, + google_protobuf_FieldDescriptorProto_TYPE_UINT64 = 4, + google_protobuf_FieldDescriptorProto_TYPE_INT32 = 5, + google_protobuf_FieldDescriptorProto_TYPE_FIXED64 = 6, + google_protobuf_FieldDescriptorProto_TYPE_FIXED32 = 7, + google_protobuf_FieldDescriptorProto_TYPE_BOOL = 8, + google_protobuf_FieldDescriptorProto_TYPE_STRING = 9, + google_protobuf_FieldDescriptorProto_TYPE_GROUP = 10, + google_protobuf_FieldDescriptorProto_TYPE_MESSAGE = 11, + google_protobuf_FieldDescriptorProto_TYPE_BYTES = 12, + google_protobuf_FieldDescriptorProto_TYPE_UINT32 = 13, + google_protobuf_FieldDescriptorProto_TYPE_ENUM = 14, + google_protobuf_FieldDescriptorProto_TYPE_SFIXED32 = 15, + google_protobuf_FieldDescriptorProto_TYPE_SFIXED64 = 16, + google_protobuf_FieldDescriptorProto_TYPE_SINT32 = 17, + google_protobuf_FieldDescriptorProto_TYPE_SINT64 = 18 +} google_protobuf_FieldDescriptorProto_Type; + +typedef enum { + google_protobuf_FieldOptions_STRING = 0, + google_protobuf_FieldOptions_CORD = 1, + google_protobuf_FieldOptions_STRING_PIECE = 2 +} google_protobuf_FieldOptions_CType; + +typedef enum { + google_protobuf_FieldOptions_JS_NORMAL = 0, + google_protobuf_FieldOptions_JS_STRING = 1, + google_protobuf_FieldOptions_JS_NUMBER = 2 +} google_protobuf_FieldOptions_JSType; + +typedef enum { + google_protobuf_FileOptions_SPEED = 1, + google_protobuf_FileOptions_CODE_SIZE = 2, + google_protobuf_FileOptions_LITE_RUNTIME = 3 +} google_protobuf_FileOptions_OptimizeMode; + +typedef enum { + google_protobuf_MethodOptions_IDEMPOTENCY_UNKNOWN = 0, + google_protobuf_MethodOptions_NO_SIDE_EFFECTS = 1, + google_protobuf_MethodOptions_IDEMPOTENT = 2 +} google_protobuf_MethodOptions_IdempotencyLevel; + + +/* google.protobuf.FileDescriptorSet */ + +UPB_INLINE google_protobuf_FileDescriptorSet *google_protobuf_FileDescriptorSet_new(upb_arena *arena) { + return (google_protobuf_FileDescriptorSet *)upb_msg_new(&google_protobuf_FileDescriptorSet_msginit, arena); +} +UPB_INLINE google_protobuf_FileDescriptorSet *google_protobuf_FileDescriptorSet_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_FileDescriptorSet *ret = google_protobuf_FileDescriptorSet_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_FileDescriptorSet_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_FileDescriptorSet_serialize(const google_protobuf_FileDescriptorSet *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_FileDescriptorSet_msginit, arena, len); +} + +UPB_INLINE const google_protobuf_FileDescriptorProto* const* google_protobuf_FileDescriptorSet_file(const google_protobuf_FileDescriptorSet *msg, size_t *len) { return (const google_protobuf_FileDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); } + +UPB_INLINE google_protobuf_FileDescriptorProto** google_protobuf_FileDescriptorSet_mutable_file(google_protobuf_FileDescriptorSet *msg, size_t *len) { + return (google_protobuf_FileDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len); +} +UPB_INLINE google_protobuf_FileDescriptorProto** google_protobuf_FileDescriptorSet_resize_file(google_protobuf_FileDescriptorSet *msg, size_t len, upb_arena *arena) { + return (google_protobuf_FileDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorSet_add_file(google_protobuf_FileDescriptorSet *msg, upb_arena *arena) { + struct google_protobuf_FileDescriptorProto* sub = (struct google_protobuf_FileDescriptorProto*)upb_msg_new(&google_protobuf_FileDescriptorProto_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} + +/* google.protobuf.FileDescriptorProto */ + +UPB_INLINE google_protobuf_FileDescriptorProto *google_protobuf_FileDescriptorProto_new(upb_arena *arena) { + return (google_protobuf_FileDescriptorProto *)upb_msg_new(&google_protobuf_FileDescriptorProto_msginit, arena); +} +UPB_INLINE google_protobuf_FileDescriptorProto *google_protobuf_FileDescriptorProto_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_FileDescriptorProto *ret = google_protobuf_FileDescriptorProto_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_FileDescriptorProto_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_FileDescriptorProto_serialize(const google_protobuf_FileDescriptorProto *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_FileDescriptorProto_msginit, arena, len); +} + +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_name(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE upb_strview google_protobuf_FileDescriptorProto_name(const google_protobuf_FileDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_package(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE upb_strview google_protobuf_FileDescriptorProto_package(const google_protobuf_FileDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)); } +UPB_INLINE upb_strview const* google_protobuf_FileDescriptorProto_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(36, 72), len); } +UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_FileDescriptorProto_message_type(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(40, 80), len); } +UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_FileDescriptorProto_enum_type(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(44, 88), len); } +UPB_INLINE const google_protobuf_ServiceDescriptorProto* const* google_protobuf_FileDescriptorProto_service(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_ServiceDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(48, 96), len); } +UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_FileDescriptorProto_extension(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(52, 104), len); } +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_options(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 4); } +UPB_INLINE const google_protobuf_FileOptions* google_protobuf_FileDescriptorProto_options(const google_protobuf_FileDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_FileOptions*, UPB_SIZE(28, 56)); } +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_source_code_info(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 5); } +UPB_INLINE const google_protobuf_SourceCodeInfo* google_protobuf_FileDescriptorProto_source_code_info(const google_protobuf_FileDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_SourceCodeInfo*, UPB_SIZE(32, 64)); } +UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_public_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(56, 112), len); } +UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_weak_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(60, 120), len); } +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_syntax(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_field(msg, 3); } +UPB_INLINE upb_strview google_protobuf_FileDescriptorProto_syntax(const google_protobuf_FileDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(20, 40)); } + +UPB_INLINE void google_protobuf_FileDescriptorProto_set_name(google_protobuf_FileDescriptorProto *msg, upb_strview value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_set_package(google_protobuf_FileDescriptorProto *msg, upb_strview value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)) = value; +} +UPB_INLINE upb_strview* google_protobuf_FileDescriptorProto_mutable_dependency(google_protobuf_FileDescriptorProto *msg, size_t *len) { + return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(36, 72), len); +} +UPB_INLINE upb_strview* google_protobuf_FileDescriptorProto_resize_dependency(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) { + return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(36, 72), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_add_dependency(google_protobuf_FileDescriptorProto *msg, upb_strview val, upb_arena *arena) { + return _upb_array_append_accessor( + msg, UPB_SIZE(36, 72), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); +} +UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_FileDescriptorProto_mutable_message_type(google_protobuf_FileDescriptorProto *msg, size_t *len) { + return (google_protobuf_DescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(40, 80), len); +} +UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_FileDescriptorProto_resize_message_type(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) { + return (google_protobuf_DescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(40, 80), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_DescriptorProto* google_protobuf_FileDescriptorProto_add_message_type(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_DescriptorProto* sub = (struct google_protobuf_DescriptorProto*)upb_msg_new(&google_protobuf_DescriptorProto_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(40, 80), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} +UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_FileDescriptorProto_mutable_enum_type(google_protobuf_FileDescriptorProto *msg, size_t *len) { + return (google_protobuf_EnumDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(44, 88), len); +} +UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_FileDescriptorProto_resize_enum_type(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) { + return (google_protobuf_EnumDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(44, 88), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_EnumDescriptorProto* google_protobuf_FileDescriptorProto_add_enum_type(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_EnumDescriptorProto* sub = (struct google_protobuf_EnumDescriptorProto*)upb_msg_new(&google_protobuf_EnumDescriptorProto_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(44, 88), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} +UPB_INLINE google_protobuf_ServiceDescriptorProto** google_protobuf_FileDescriptorProto_mutable_service(google_protobuf_FileDescriptorProto *msg, size_t *len) { + return (google_protobuf_ServiceDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(48, 96), len); +} +UPB_INLINE google_protobuf_ServiceDescriptorProto** google_protobuf_FileDescriptorProto_resize_service(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) { + return (google_protobuf_ServiceDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(48, 96), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_ServiceDescriptorProto* google_protobuf_FileDescriptorProto_add_service(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_ServiceDescriptorProto* sub = (struct google_protobuf_ServiceDescriptorProto*)upb_msg_new(&google_protobuf_ServiceDescriptorProto_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(48, 96), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} +UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_FileDescriptorProto_mutable_extension(google_protobuf_FileDescriptorProto *msg, size_t *len) { + return (google_protobuf_FieldDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(52, 104), len); +} +UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_FileDescriptorProto_resize_extension(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) { + return (google_protobuf_FieldDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(52, 104), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_FileDescriptorProto_add_extension(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)upb_msg_new(&google_protobuf_FieldDescriptorProto_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(52, 104), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_set_options(google_protobuf_FileDescriptorProto *msg, google_protobuf_FileOptions* value) { + _upb_sethas(msg, 4); + UPB_FIELD_AT(msg, google_protobuf_FileOptions*, UPB_SIZE(28, 56)) = value; +} +UPB_INLINE struct google_protobuf_FileOptions* google_protobuf_FileDescriptorProto_mutable_options(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_FileOptions* sub = (struct google_protobuf_FileOptions*)google_protobuf_FileDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FileOptions*)upb_msg_new(&google_protobuf_FileOptions_msginit, arena); + if (!sub) return NULL; + google_protobuf_FileDescriptorProto_set_options(msg, sub); + } + return sub; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_set_source_code_info(google_protobuf_FileDescriptorProto *msg, google_protobuf_SourceCodeInfo* value) { + _upb_sethas(msg, 5); + UPB_FIELD_AT(msg, google_protobuf_SourceCodeInfo*, UPB_SIZE(32, 64)) = value; +} +UPB_INLINE struct google_protobuf_SourceCodeInfo* google_protobuf_FileDescriptorProto_mutable_source_code_info(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_SourceCodeInfo* sub = (struct google_protobuf_SourceCodeInfo*)google_protobuf_FileDescriptorProto_source_code_info(msg); + if (sub == NULL) { + sub = (struct google_protobuf_SourceCodeInfo*)upb_msg_new(&google_protobuf_SourceCodeInfo_msginit, arena); + if (!sub) return NULL; + google_protobuf_FileDescriptorProto_set_source_code_info(msg, sub); + } + return sub; +} +UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_mutable_public_dependency(google_protobuf_FileDescriptorProto *msg, size_t *len) { + return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(56, 112), len); +} +UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_resize_public_dependency(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) { + return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(56, 112), len, UPB_SIZE(4, 4), UPB_TYPE_INT32, arena); +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_add_public_dependency(google_protobuf_FileDescriptorProto *msg, int32_t val, upb_arena *arena) { + return _upb_array_append_accessor( + msg, UPB_SIZE(56, 112), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val, arena); +} +UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_mutable_weak_dependency(google_protobuf_FileDescriptorProto *msg, size_t *len) { + return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(60, 120), len); +} +UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_resize_weak_dependency(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) { + return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(60, 120), len, UPB_SIZE(4, 4), UPB_TYPE_INT32, arena); +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_add_weak_dependency(google_protobuf_FileDescriptorProto *msg, int32_t val, upb_arena *arena) { + return _upb_array_append_accessor( + msg, UPB_SIZE(60, 120), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val, arena); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_set_syntax(google_protobuf_FileDescriptorProto *msg, upb_strview value) { + _upb_sethas(msg, 3); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(20, 40)) = value; +} + +/* google.protobuf.DescriptorProto */ + +UPB_INLINE google_protobuf_DescriptorProto *google_protobuf_DescriptorProto_new(upb_arena *arena) { + return (google_protobuf_DescriptorProto *)upb_msg_new(&google_protobuf_DescriptorProto_msginit, arena); +} +UPB_INLINE google_protobuf_DescriptorProto *google_protobuf_DescriptorProto_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_DescriptorProto *ret = google_protobuf_DescriptorProto_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_DescriptorProto_serialize(const google_protobuf_DescriptorProto *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_DescriptorProto_msginit, arena, len); +} + +UPB_INLINE bool google_protobuf_DescriptorProto_has_name(const google_protobuf_DescriptorProto *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE upb_strview google_protobuf_DescriptorProto_name(const google_protobuf_DescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } +UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_DescriptorProto_field(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len); } +UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_DescriptorProto_nested_type(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len); } +UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_DescriptorProto_enum_type(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len); } +UPB_INLINE const google_protobuf_DescriptorProto_ExtensionRange* const* google_protobuf_DescriptorProto_extension_range(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto_ExtensionRange* const*)_upb_array_accessor(msg, UPB_SIZE(28, 56), len); } +UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_DescriptorProto_extension(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(32, 64), len); } +UPB_INLINE bool google_protobuf_DescriptorProto_has_options(const google_protobuf_DescriptorProto *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE const google_protobuf_MessageOptions* google_protobuf_DescriptorProto_options(const google_protobuf_DescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_MessageOptions*, UPB_SIZE(12, 24)); } +UPB_INLINE const google_protobuf_OneofDescriptorProto* const* google_protobuf_DescriptorProto_oneof_decl(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_OneofDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(36, 72), len); } +UPB_INLINE const google_protobuf_DescriptorProto_ReservedRange* const* google_protobuf_DescriptorProto_reserved_range(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto_ReservedRange* const*)_upb_array_accessor(msg, UPB_SIZE(40, 80), len); } +UPB_INLINE upb_strview const* google_protobuf_DescriptorProto_reserved_name(const google_protobuf_DescriptorProto *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(44, 88), len); } + +UPB_INLINE void google_protobuf_DescriptorProto_set_name(google_protobuf_DescriptorProto *msg, upb_strview value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; +} +UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_mutable_field(google_protobuf_DescriptorProto *msg, size_t *len) { + return (google_protobuf_FieldDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len); +} +UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_resize_field(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) { + return (google_protobuf_FieldDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(16, 32), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_DescriptorProto_add_field(google_protobuf_DescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)upb_msg_new(&google_protobuf_FieldDescriptorProto_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(16, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} +UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_DescriptorProto_mutable_nested_type(google_protobuf_DescriptorProto *msg, size_t *len) { + return (google_protobuf_DescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 40), len); +} +UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_DescriptorProto_resize_nested_type(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) { + return (google_protobuf_DescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(20, 40), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_add_nested_type(google_protobuf_DescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_DescriptorProto* sub = (struct google_protobuf_DescriptorProto*)upb_msg_new(&google_protobuf_DescriptorProto_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(20, 40), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} +UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_DescriptorProto_mutable_enum_type(google_protobuf_DescriptorProto *msg, size_t *len) { + return (google_protobuf_EnumDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 48), len); +} +UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_DescriptorProto_resize_enum_type(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) { + return (google_protobuf_EnumDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(24, 48), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_EnumDescriptorProto* google_protobuf_DescriptorProto_add_enum_type(google_protobuf_DescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_EnumDescriptorProto* sub = (struct google_protobuf_EnumDescriptorProto*)upb_msg_new(&google_protobuf_EnumDescriptorProto_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(24, 48), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} +UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange** google_protobuf_DescriptorProto_mutable_extension_range(google_protobuf_DescriptorProto *msg, size_t *len) { + return (google_protobuf_DescriptorProto_ExtensionRange**)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 56), len); +} +UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange** google_protobuf_DescriptorProto_resize_extension_range(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) { + return (google_protobuf_DescriptorProto_ExtensionRange**)_upb_array_resize_accessor(msg, UPB_SIZE(28, 56), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_add_extension_range(google_protobuf_DescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_DescriptorProto_ExtensionRange* sub = (struct google_protobuf_DescriptorProto_ExtensionRange*)upb_msg_new(&google_protobuf_DescriptorProto_ExtensionRange_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(28, 56), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} +UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_mutable_extension(google_protobuf_DescriptorProto *msg, size_t *len) { + return (google_protobuf_FieldDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(32, 64), len); +} +UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_resize_extension(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) { + return (google_protobuf_FieldDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(32, 64), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_DescriptorProto_add_extension(google_protobuf_DescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)upb_msg_new(&google_protobuf_FieldDescriptorProto_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(32, 64), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} +UPB_INLINE void google_protobuf_DescriptorProto_set_options(google_protobuf_DescriptorProto *msg, google_protobuf_MessageOptions* value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, google_protobuf_MessageOptions*, UPB_SIZE(12, 24)) = value; +} +UPB_INLINE struct google_protobuf_MessageOptions* google_protobuf_DescriptorProto_mutable_options(google_protobuf_DescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_MessageOptions* sub = (struct google_protobuf_MessageOptions*)google_protobuf_DescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_MessageOptions*)upb_msg_new(&google_protobuf_MessageOptions_msginit, arena); + if (!sub) return NULL; + google_protobuf_DescriptorProto_set_options(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_OneofDescriptorProto** google_protobuf_DescriptorProto_mutable_oneof_decl(google_protobuf_DescriptorProto *msg, size_t *len) { + return (google_protobuf_OneofDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(36, 72), len); +} +UPB_INLINE google_protobuf_OneofDescriptorProto** google_protobuf_DescriptorProto_resize_oneof_decl(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) { + return (google_protobuf_OneofDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(36, 72), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_OneofDescriptorProto* google_protobuf_DescriptorProto_add_oneof_decl(google_protobuf_DescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_OneofDescriptorProto* sub = (struct google_protobuf_OneofDescriptorProto*)upb_msg_new(&google_protobuf_OneofDescriptorProto_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(36, 72), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} +UPB_INLINE google_protobuf_DescriptorProto_ReservedRange** google_protobuf_DescriptorProto_mutable_reserved_range(google_protobuf_DescriptorProto *msg, size_t *len) { + return (google_protobuf_DescriptorProto_ReservedRange**)_upb_array_mutable_accessor(msg, UPB_SIZE(40, 80), len); +} +UPB_INLINE google_protobuf_DescriptorProto_ReservedRange** google_protobuf_DescriptorProto_resize_reserved_range(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) { + return (google_protobuf_DescriptorProto_ReservedRange**)_upb_array_resize_accessor(msg, UPB_SIZE(40, 80), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_add_reserved_range(google_protobuf_DescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_DescriptorProto_ReservedRange* sub = (struct google_protobuf_DescriptorProto_ReservedRange*)upb_msg_new(&google_protobuf_DescriptorProto_ReservedRange_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(40, 80), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} +UPB_INLINE upb_strview* google_protobuf_DescriptorProto_mutable_reserved_name(google_protobuf_DescriptorProto *msg, size_t *len) { + return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(44, 88), len); +} +UPB_INLINE upb_strview* google_protobuf_DescriptorProto_resize_reserved_name(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) { + return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(44, 88), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); +} +UPB_INLINE bool google_protobuf_DescriptorProto_add_reserved_name(google_protobuf_DescriptorProto *msg, upb_strview val, upb_arena *arena) { + return _upb_array_append_accessor( + msg, UPB_SIZE(44, 88), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); +} + +/* google.protobuf.DescriptorProto.ExtensionRange */ + +UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange *google_protobuf_DescriptorProto_ExtensionRange_new(upb_arena *arena) { + return (google_protobuf_DescriptorProto_ExtensionRange *)upb_msg_new(&google_protobuf_DescriptorProto_ExtensionRange_msginit, arena); +} +UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange *google_protobuf_DescriptorProto_ExtensionRange_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_DescriptorProto_ExtensionRange *ret = google_protobuf_DescriptorProto_ExtensionRange_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ExtensionRange_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_DescriptorProto_ExtensionRange_serialize(const google_protobuf_DescriptorProto_ExtensionRange *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_DescriptorProto_ExtensionRange_msginit, arena, len); +} + +UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_start(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_start(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)); } +UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_end(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_end(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); } +UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_options(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return _upb_has_field(msg, 3); } +UPB_INLINE const google_protobuf_ExtensionRangeOptions* google_protobuf_DescriptorProto_ExtensionRange_options(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return UPB_FIELD_AT(msg, const google_protobuf_ExtensionRangeOptions*, UPB_SIZE(12, 16)); } + +UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_start(google_protobuf_DescriptorProto_ExtensionRange *msg, int32_t value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)) = value; +} +UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_end(google_protobuf_DescriptorProto_ExtensionRange *msg, int32_t value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; +} +UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_options(google_protobuf_DescriptorProto_ExtensionRange *msg, google_protobuf_ExtensionRangeOptions* value) { + _upb_sethas(msg, 3); + UPB_FIELD_AT(msg, google_protobuf_ExtensionRangeOptions*, UPB_SIZE(12, 16)) = value; +} +UPB_INLINE struct google_protobuf_ExtensionRangeOptions* google_protobuf_DescriptorProto_ExtensionRange_mutable_options(google_protobuf_DescriptorProto_ExtensionRange *msg, upb_arena *arena) { + struct google_protobuf_ExtensionRangeOptions* sub = (struct google_protobuf_ExtensionRangeOptions*)google_protobuf_DescriptorProto_ExtensionRange_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_ExtensionRangeOptions*)upb_msg_new(&google_protobuf_ExtensionRangeOptions_msginit, arena); + if (!sub) return NULL; + google_protobuf_DescriptorProto_ExtensionRange_set_options(msg, sub); + } + return sub; +} + +/* google.protobuf.DescriptorProto.ReservedRange */ + +UPB_INLINE google_protobuf_DescriptorProto_ReservedRange *google_protobuf_DescriptorProto_ReservedRange_new(upb_arena *arena) { + return (google_protobuf_DescriptorProto_ReservedRange *)upb_msg_new(&google_protobuf_DescriptorProto_ReservedRange_msginit, arena); +} +UPB_INLINE google_protobuf_DescriptorProto_ReservedRange *google_protobuf_DescriptorProto_ReservedRange_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_DescriptorProto_ReservedRange *ret = google_protobuf_DescriptorProto_ReservedRange_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ReservedRange_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_DescriptorProto_ReservedRange_serialize(const google_protobuf_DescriptorProto_ReservedRange *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_DescriptorProto_ReservedRange_msginit, arena, len); +} + +UPB_INLINE bool google_protobuf_DescriptorProto_ReservedRange_has_start(const google_protobuf_DescriptorProto_ReservedRange *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_start(const google_protobuf_DescriptorProto_ReservedRange *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)); } +UPB_INLINE bool google_protobuf_DescriptorProto_ReservedRange_has_end(const google_protobuf_DescriptorProto_ReservedRange *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_end(const google_protobuf_DescriptorProto_ReservedRange *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); } + +UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_set_start(google_protobuf_DescriptorProto_ReservedRange *msg, int32_t value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)) = value; +} +UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_set_end(google_protobuf_DescriptorProto_ReservedRange *msg, int32_t value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; +} + +/* google.protobuf.ExtensionRangeOptions */ + +UPB_INLINE google_protobuf_ExtensionRangeOptions *google_protobuf_ExtensionRangeOptions_new(upb_arena *arena) { + return (google_protobuf_ExtensionRangeOptions *)upb_msg_new(&google_protobuf_ExtensionRangeOptions_msginit, arena); +} +UPB_INLINE google_protobuf_ExtensionRangeOptions *google_protobuf_ExtensionRangeOptions_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_ExtensionRangeOptions *ret = google_protobuf_ExtensionRangeOptions_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_ExtensionRangeOptions_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_ExtensionRangeOptions_serialize(const google_protobuf_ExtensionRangeOptions *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_ExtensionRangeOptions_msginit, arena, len); +} + +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_ExtensionRangeOptions_uninterpreted_option(const google_protobuf_ExtensionRangeOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); } + +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ExtensionRangeOptions_mutable_uninterpreted_option(google_protobuf_ExtensionRangeOptions *msg, size_t *len) { + return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len); +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ExtensionRangeOptions_resize_uninterpreted_option(google_protobuf_ExtensionRangeOptions *msg, size_t len, upb_arena *arena) { + return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_ExtensionRangeOptions_add_uninterpreted_option(google_protobuf_ExtensionRangeOptions *msg, upb_arena *arena) { + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} + +/* google.protobuf.FieldDescriptorProto */ + +UPB_INLINE google_protobuf_FieldDescriptorProto *google_protobuf_FieldDescriptorProto_new(upb_arena *arena) { + return (google_protobuf_FieldDescriptorProto *)upb_msg_new(&google_protobuf_FieldDescriptorProto_msginit, arena); +} +UPB_INLINE google_protobuf_FieldDescriptorProto *google_protobuf_FieldDescriptorProto_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_FieldDescriptorProto *ret = google_protobuf_FieldDescriptorProto_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_FieldDescriptorProto_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_FieldDescriptorProto_serialize(const google_protobuf_FieldDescriptorProto *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_FieldDescriptorProto_msginit, arena, len); +} + +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_name(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 5); } +UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_name(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(32, 32)); } +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_extendee(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 6); } +UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_extendee(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(40, 48)); } +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_number(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 3); } +UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_number(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(24, 24)); } +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_label(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_label(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); } +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_type(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_type(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 16)); } +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_type_name(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 7); } +UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_type_name(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(48, 64)); } +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_default_value(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 8); } +UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_default_value(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(56, 80)); } +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_options(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 10); } +UPB_INLINE const google_protobuf_FieldOptions* google_protobuf_FieldDescriptorProto_options(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_FieldOptions*, UPB_SIZE(72, 112)); } +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_oneof_index(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 4); } +UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_oneof_index(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(28, 28)); } +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_json_name(const google_protobuf_FieldDescriptorProto *msg) { return _upb_has_field(msg, 9); } +UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_json_name(const google_protobuf_FieldDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(64, 96)); } + +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_name(google_protobuf_FieldDescriptorProto *msg, upb_strview value) { + _upb_sethas(msg, 5); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(32, 32)) = value; +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_extendee(google_protobuf_FieldDescriptorProto *msg, upb_strview value) { + _upb_sethas(msg, 6); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(40, 48)) = value; +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_number(google_protobuf_FieldDescriptorProto *msg, int32_t value) { + _upb_sethas(msg, 3); + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(24, 24)) = value; +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_label(google_protobuf_FieldDescriptorProto *msg, int32_t value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_type(google_protobuf_FieldDescriptorProto *msg, int32_t value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 16)) = value; +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_type_name(google_protobuf_FieldDescriptorProto *msg, upb_strview value) { + _upb_sethas(msg, 7); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(48, 64)) = value; +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_default_value(google_protobuf_FieldDescriptorProto *msg, upb_strview value) { + _upb_sethas(msg, 8); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(56, 80)) = value; +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_options(google_protobuf_FieldDescriptorProto *msg, google_protobuf_FieldOptions* value) { + _upb_sethas(msg, 10); + UPB_FIELD_AT(msg, google_protobuf_FieldOptions*, UPB_SIZE(72, 112)) = value; +} +UPB_INLINE struct google_protobuf_FieldOptions* google_protobuf_FieldDescriptorProto_mutable_options(google_protobuf_FieldDescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_FieldOptions* sub = (struct google_protobuf_FieldOptions*)google_protobuf_FieldDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FieldOptions*)upb_msg_new(&google_protobuf_FieldOptions_msginit, arena); + if (!sub) return NULL; + google_protobuf_FieldDescriptorProto_set_options(msg, sub); + } + return sub; +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_oneof_index(google_protobuf_FieldDescriptorProto *msg, int32_t value) { + _upb_sethas(msg, 4); + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(28, 28)) = value; +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_json_name(google_protobuf_FieldDescriptorProto *msg, upb_strview value) { + _upb_sethas(msg, 9); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(64, 96)) = value; +} + +/* google.protobuf.OneofDescriptorProto */ + +UPB_INLINE google_protobuf_OneofDescriptorProto *google_protobuf_OneofDescriptorProto_new(upb_arena *arena) { + return (google_protobuf_OneofDescriptorProto *)upb_msg_new(&google_protobuf_OneofDescriptorProto_msginit, arena); +} +UPB_INLINE google_protobuf_OneofDescriptorProto *google_protobuf_OneofDescriptorProto_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_OneofDescriptorProto *ret = google_protobuf_OneofDescriptorProto_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_OneofDescriptorProto_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_OneofDescriptorProto_serialize(const google_protobuf_OneofDescriptorProto *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_OneofDescriptorProto_msginit, arena, len); +} + +UPB_INLINE bool google_protobuf_OneofDescriptorProto_has_name(const google_protobuf_OneofDescriptorProto *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE upb_strview google_protobuf_OneofDescriptorProto_name(const google_protobuf_OneofDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } +UPB_INLINE bool google_protobuf_OneofDescriptorProto_has_options(const google_protobuf_OneofDescriptorProto *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE const google_protobuf_OneofOptions* google_protobuf_OneofDescriptorProto_options(const google_protobuf_OneofDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_OneofOptions*, UPB_SIZE(12, 24)); } + +UPB_INLINE void google_protobuf_OneofDescriptorProto_set_name(google_protobuf_OneofDescriptorProto *msg, upb_strview value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; +} +UPB_INLINE void google_protobuf_OneofDescriptorProto_set_options(google_protobuf_OneofDescriptorProto *msg, google_protobuf_OneofOptions* value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, google_protobuf_OneofOptions*, UPB_SIZE(12, 24)) = value; +} +UPB_INLINE struct google_protobuf_OneofOptions* google_protobuf_OneofDescriptorProto_mutable_options(google_protobuf_OneofDescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_OneofOptions* sub = (struct google_protobuf_OneofOptions*)google_protobuf_OneofDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_OneofOptions*)upb_msg_new(&google_protobuf_OneofOptions_msginit, arena); + if (!sub) return NULL; + google_protobuf_OneofDescriptorProto_set_options(msg, sub); + } + return sub; +} + +/* google.protobuf.EnumDescriptorProto */ + +UPB_INLINE google_protobuf_EnumDescriptorProto *google_protobuf_EnumDescriptorProto_new(upb_arena *arena) { + return (google_protobuf_EnumDescriptorProto *)upb_msg_new(&google_protobuf_EnumDescriptorProto_msginit, arena); +} +UPB_INLINE google_protobuf_EnumDescriptorProto *google_protobuf_EnumDescriptorProto_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_EnumDescriptorProto *ret = google_protobuf_EnumDescriptorProto_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_EnumDescriptorProto_serialize(const google_protobuf_EnumDescriptorProto *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_EnumDescriptorProto_msginit, arena, len); +} + +UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_name(const google_protobuf_EnumDescriptorProto *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE upb_strview google_protobuf_EnumDescriptorProto_name(const google_protobuf_EnumDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } +UPB_INLINE const google_protobuf_EnumValueDescriptorProto* const* google_protobuf_EnumDescriptorProto_value(const google_protobuf_EnumDescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumValueDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len); } +UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_options(const google_protobuf_EnumDescriptorProto *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE const google_protobuf_EnumOptions* google_protobuf_EnumDescriptorProto_options(const google_protobuf_EnumDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_EnumOptions*, UPB_SIZE(12, 24)); } +UPB_INLINE const google_protobuf_EnumDescriptorProto_EnumReservedRange* const* google_protobuf_EnumDescriptorProto_reserved_range(const google_protobuf_EnumDescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumDescriptorProto_EnumReservedRange* const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len); } +UPB_INLINE upb_strview const* google_protobuf_EnumDescriptorProto_reserved_name(const google_protobuf_EnumDescriptorProto *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len); } + +UPB_INLINE void google_protobuf_EnumDescriptorProto_set_name(google_protobuf_EnumDescriptorProto *msg, upb_strview value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; +} +UPB_INLINE google_protobuf_EnumValueDescriptorProto** google_protobuf_EnumDescriptorProto_mutable_value(google_protobuf_EnumDescriptorProto *msg, size_t *len) { + return (google_protobuf_EnumValueDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len); +} +UPB_INLINE google_protobuf_EnumValueDescriptorProto** google_protobuf_EnumDescriptorProto_resize_value(google_protobuf_EnumDescriptorProto *msg, size_t len, upb_arena *arena) { + return (google_protobuf_EnumValueDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(16, 32), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_EnumValueDescriptorProto* google_protobuf_EnumDescriptorProto_add_value(google_protobuf_EnumDescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_EnumValueDescriptorProto* sub = (struct google_protobuf_EnumValueDescriptorProto*)upb_msg_new(&google_protobuf_EnumValueDescriptorProto_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(16, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_set_options(google_protobuf_EnumDescriptorProto *msg, google_protobuf_EnumOptions* value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, google_protobuf_EnumOptions*, UPB_SIZE(12, 24)) = value; +} +UPB_INLINE struct google_protobuf_EnumOptions* google_protobuf_EnumDescriptorProto_mutable_options(google_protobuf_EnumDescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_EnumOptions* sub = (struct google_protobuf_EnumOptions*)google_protobuf_EnumDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_EnumOptions*)upb_msg_new(&google_protobuf_EnumOptions_msginit, arena); + if (!sub) return NULL; + google_protobuf_EnumDescriptorProto_set_options(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange** google_protobuf_EnumDescriptorProto_mutable_reserved_range(google_protobuf_EnumDescriptorProto *msg, size_t *len) { + return (google_protobuf_EnumDescriptorProto_EnumReservedRange**)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 40), len); +} +UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange** google_protobuf_EnumDescriptorProto_resize_reserved_range(google_protobuf_EnumDescriptorProto *msg, size_t len, upb_arena *arena) { + return (google_protobuf_EnumDescriptorProto_EnumReservedRange**)_upb_array_resize_accessor(msg, UPB_SIZE(20, 40), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_EnumDescriptorProto_EnumReservedRange* google_protobuf_EnumDescriptorProto_add_reserved_range(google_protobuf_EnumDescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_EnumDescriptorProto_EnumReservedRange* sub = (struct google_protobuf_EnumDescriptorProto_EnumReservedRange*)upb_msg_new(&google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(20, 40), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} +UPB_INLINE upb_strview* google_protobuf_EnumDescriptorProto_mutable_reserved_name(google_protobuf_EnumDescriptorProto *msg, size_t *len) { + return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 48), len); +} +UPB_INLINE upb_strview* google_protobuf_EnumDescriptorProto_resize_reserved_name(google_protobuf_EnumDescriptorProto *msg, size_t len, upb_arena *arena) { + return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(24, 48), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); +} +UPB_INLINE bool google_protobuf_EnumDescriptorProto_add_reserved_name(google_protobuf_EnumDescriptorProto *msg, upb_strview val, upb_arena *arena) { + return _upb_array_append_accessor( + msg, UPB_SIZE(24, 48), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); +} + +/* google.protobuf.EnumDescriptorProto.EnumReservedRange */ + +UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange *google_protobuf_EnumDescriptorProto_EnumReservedRange_new(upb_arena *arena) { + return (google_protobuf_EnumDescriptorProto_EnumReservedRange *)upb_msg_new(&google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena); +} +UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange *google_protobuf_EnumDescriptorProto_EnumReservedRange_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_EnumDescriptorProto_EnumReservedRange *ret = google_protobuf_EnumDescriptorProto_EnumReservedRange_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_EnumDescriptorProto_EnumReservedRange_serialize(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena, len); +} + +UPB_INLINE bool google_protobuf_EnumDescriptorProto_EnumReservedRange_has_start(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE int32_t google_protobuf_EnumDescriptorProto_EnumReservedRange_start(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)); } +UPB_INLINE bool google_protobuf_EnumDescriptorProto_EnumReservedRange_has_end(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE int32_t google_protobuf_EnumDescriptorProto_EnumReservedRange_end(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); } + +UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_set_start(google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, int32_t value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)) = value; +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_set_end(google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, int32_t value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; +} + +/* google.protobuf.EnumValueDescriptorProto */ + +UPB_INLINE google_protobuf_EnumValueDescriptorProto *google_protobuf_EnumValueDescriptorProto_new(upb_arena *arena) { + return (google_protobuf_EnumValueDescriptorProto *)upb_msg_new(&google_protobuf_EnumValueDescriptorProto_msginit, arena); +} +UPB_INLINE google_protobuf_EnumValueDescriptorProto *google_protobuf_EnumValueDescriptorProto_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_EnumValueDescriptorProto *ret = google_protobuf_EnumValueDescriptorProto_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumValueDescriptorProto_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_EnumValueDescriptorProto_serialize(const google_protobuf_EnumValueDescriptorProto *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_EnumValueDescriptorProto_msginit, arena, len); +} + +UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_name(const google_protobuf_EnumValueDescriptorProto *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE upb_strview google_protobuf_EnumValueDescriptorProto_name(const google_protobuf_EnumValueDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)); } +UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_number(const google_protobuf_EnumValueDescriptorProto *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE int32_t google_protobuf_EnumValueDescriptorProto_number(const google_protobuf_EnumValueDescriptorProto *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)); } +UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_options(const google_protobuf_EnumValueDescriptorProto *msg) { return _upb_has_field(msg, 3); } +UPB_INLINE const google_protobuf_EnumValueOptions* google_protobuf_EnumValueDescriptorProto_options(const google_protobuf_EnumValueDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_EnumValueOptions*, UPB_SIZE(16, 24)); } + +UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_name(google_protobuf_EnumValueDescriptorProto *msg, upb_strview value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)) = value; +} +UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_number(google_protobuf_EnumValueDescriptorProto *msg, int32_t value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)) = value; +} +UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_options(google_protobuf_EnumValueDescriptorProto *msg, google_protobuf_EnumValueOptions* value) { + _upb_sethas(msg, 3); + UPB_FIELD_AT(msg, google_protobuf_EnumValueOptions*, UPB_SIZE(16, 24)) = value; +} +UPB_INLINE struct google_protobuf_EnumValueOptions* google_protobuf_EnumValueDescriptorProto_mutable_options(google_protobuf_EnumValueDescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_EnumValueOptions* sub = (struct google_protobuf_EnumValueOptions*)google_protobuf_EnumValueDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_EnumValueOptions*)upb_msg_new(&google_protobuf_EnumValueOptions_msginit, arena); + if (!sub) return NULL; + google_protobuf_EnumValueDescriptorProto_set_options(msg, sub); + } + return sub; +} + +/* google.protobuf.ServiceDescriptorProto */ + +UPB_INLINE google_protobuf_ServiceDescriptorProto *google_protobuf_ServiceDescriptorProto_new(upb_arena *arena) { + return (google_protobuf_ServiceDescriptorProto *)upb_msg_new(&google_protobuf_ServiceDescriptorProto_msginit, arena); +} +UPB_INLINE google_protobuf_ServiceDescriptorProto *google_protobuf_ServiceDescriptorProto_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_ServiceDescriptorProto *ret = google_protobuf_ServiceDescriptorProto_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_ServiceDescriptorProto_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_ServiceDescriptorProto_serialize(const google_protobuf_ServiceDescriptorProto *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_ServiceDescriptorProto_msginit, arena, len); +} + +UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_name(const google_protobuf_ServiceDescriptorProto *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE upb_strview google_protobuf_ServiceDescriptorProto_name(const google_protobuf_ServiceDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } +UPB_INLINE const google_protobuf_MethodDescriptorProto* const* google_protobuf_ServiceDescriptorProto_method(const google_protobuf_ServiceDescriptorProto *msg, size_t *len) { return (const google_protobuf_MethodDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len); } +UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_options(const google_protobuf_ServiceDescriptorProto *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE const google_protobuf_ServiceOptions* google_protobuf_ServiceDescriptorProto_options(const google_protobuf_ServiceDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_ServiceOptions*, UPB_SIZE(12, 24)); } + +UPB_INLINE void google_protobuf_ServiceDescriptorProto_set_name(google_protobuf_ServiceDescriptorProto *msg, upb_strview value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; +} +UPB_INLINE google_protobuf_MethodDescriptorProto** google_protobuf_ServiceDescriptorProto_mutable_method(google_protobuf_ServiceDescriptorProto *msg, size_t *len) { + return (google_protobuf_MethodDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len); +} +UPB_INLINE google_protobuf_MethodDescriptorProto** google_protobuf_ServiceDescriptorProto_resize_method(google_protobuf_ServiceDescriptorProto *msg, size_t len, upb_arena *arena) { + return (google_protobuf_MethodDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(16, 32), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_MethodDescriptorProto* google_protobuf_ServiceDescriptorProto_add_method(google_protobuf_ServiceDescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_MethodDescriptorProto* sub = (struct google_protobuf_MethodDescriptorProto*)upb_msg_new(&google_protobuf_MethodDescriptorProto_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(16, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} +UPB_INLINE void google_protobuf_ServiceDescriptorProto_set_options(google_protobuf_ServiceDescriptorProto *msg, google_protobuf_ServiceOptions* value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, google_protobuf_ServiceOptions*, UPB_SIZE(12, 24)) = value; +} +UPB_INLINE struct google_protobuf_ServiceOptions* google_protobuf_ServiceDescriptorProto_mutable_options(google_protobuf_ServiceDescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_ServiceOptions* sub = (struct google_protobuf_ServiceOptions*)google_protobuf_ServiceDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_ServiceOptions*)upb_msg_new(&google_protobuf_ServiceOptions_msginit, arena); + if (!sub) return NULL; + google_protobuf_ServiceDescriptorProto_set_options(msg, sub); + } + return sub; +} + +/* google.protobuf.MethodDescriptorProto */ + +UPB_INLINE google_protobuf_MethodDescriptorProto *google_protobuf_MethodDescriptorProto_new(upb_arena *arena) { + return (google_protobuf_MethodDescriptorProto *)upb_msg_new(&google_protobuf_MethodDescriptorProto_msginit, arena); +} +UPB_INLINE google_protobuf_MethodDescriptorProto *google_protobuf_MethodDescriptorProto_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_MethodDescriptorProto *ret = google_protobuf_MethodDescriptorProto_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_MethodDescriptorProto_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_MethodDescriptorProto_serialize(const google_protobuf_MethodDescriptorProto *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_MethodDescriptorProto_msginit, arena, len); +} + +UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_name(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 3); } +UPB_INLINE upb_strview google_protobuf_MethodDescriptorProto_name(const google_protobuf_MethodDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } +UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_input_type(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 4); } +UPB_INLINE upb_strview google_protobuf_MethodDescriptorProto_input_type(const google_protobuf_MethodDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)); } +UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_output_type(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 5); } +UPB_INLINE upb_strview google_protobuf_MethodDescriptorProto_output_type(const google_protobuf_MethodDescriptorProto *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(20, 40)); } +UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_options(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 6); } +UPB_INLINE const google_protobuf_MethodOptions* google_protobuf_MethodDescriptorProto_options(const google_protobuf_MethodDescriptorProto *msg) { return UPB_FIELD_AT(msg, const google_protobuf_MethodOptions*, UPB_SIZE(28, 56)); } +UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_client_streaming(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE bool google_protobuf_MethodDescriptorProto_client_streaming(const google_protobuf_MethodDescriptorProto *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); } +UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_server_streaming(const google_protobuf_MethodDescriptorProto *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE bool google_protobuf_MethodDescriptorProto_server_streaming(const google_protobuf_MethodDescriptorProto *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)); } + +UPB_INLINE void google_protobuf_MethodDescriptorProto_set_name(google_protobuf_MethodDescriptorProto *msg, upb_strview value) { + _upb_sethas(msg, 3); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_set_input_type(google_protobuf_MethodDescriptorProto *msg, upb_strview value) { + _upb_sethas(msg, 4); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)) = value; +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_set_output_type(google_protobuf_MethodDescriptorProto *msg, upb_strview value) { + _upb_sethas(msg, 5); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(20, 40)) = value; +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_set_options(google_protobuf_MethodDescriptorProto *msg, google_protobuf_MethodOptions* value) { + _upb_sethas(msg, 6); + UPB_FIELD_AT(msg, google_protobuf_MethodOptions*, UPB_SIZE(28, 56)) = value; +} +UPB_INLINE struct google_protobuf_MethodOptions* google_protobuf_MethodDescriptorProto_mutable_options(google_protobuf_MethodDescriptorProto *msg, upb_arena *arena) { + struct google_protobuf_MethodOptions* sub = (struct google_protobuf_MethodOptions*)google_protobuf_MethodDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_MethodOptions*)upb_msg_new(&google_protobuf_MethodOptions_msginit, arena); + if (!sub) return NULL; + google_protobuf_MethodDescriptorProto_set_options(msg, sub); + } + return sub; +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_set_client_streaming(google_protobuf_MethodDescriptorProto *msg, bool value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value; +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_set_server_streaming(google_protobuf_MethodDescriptorProto *msg, bool value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)) = value; +} + +/* google.protobuf.FileOptions */ + +UPB_INLINE google_protobuf_FileOptions *google_protobuf_FileOptions_new(upb_arena *arena) { + return (google_protobuf_FileOptions *)upb_msg_new(&google_protobuf_FileOptions_msginit, arena); +} +UPB_INLINE google_protobuf_FileOptions *google_protobuf_FileOptions_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_FileOptions *ret = google_protobuf_FileOptions_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_FileOptions_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_FileOptions_serialize(const google_protobuf_FileOptions *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_FileOptions_msginit, arena, len); +} + +UPB_INLINE bool google_protobuf_FileOptions_has_java_package(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 11); } +UPB_INLINE upb_strview google_protobuf_FileOptions_java_package(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(28, 32)); } +UPB_INLINE bool google_protobuf_FileOptions_has_java_outer_classname(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 12); } +UPB_INLINE upb_strview google_protobuf_FileOptions_java_outer_classname(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(36, 48)); } +UPB_INLINE bool google_protobuf_FileOptions_has_optimize_for(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE int32_t google_protobuf_FileOptions_optimize_for(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); } +UPB_INLINE bool google_protobuf_FileOptions_has_java_multiple_files(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE bool google_protobuf_FileOptions_java_multiple_files(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(16, 16)); } +UPB_INLINE bool google_protobuf_FileOptions_has_go_package(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 13); } +UPB_INLINE upb_strview google_protobuf_FileOptions_go_package(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(44, 64)); } +UPB_INLINE bool google_protobuf_FileOptions_has_cc_generic_services(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 3); } +UPB_INLINE bool google_protobuf_FileOptions_cc_generic_services(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(17, 17)); } +UPB_INLINE bool google_protobuf_FileOptions_has_java_generic_services(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 4); } +UPB_INLINE bool google_protobuf_FileOptions_java_generic_services(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(18, 18)); } +UPB_INLINE bool google_protobuf_FileOptions_has_py_generic_services(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 5); } +UPB_INLINE bool google_protobuf_FileOptions_py_generic_services(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(19, 19)); } +UPB_INLINE bool google_protobuf_FileOptions_has_java_generate_equals_and_hash(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 6); } +UPB_INLINE bool google_protobuf_FileOptions_java_generate_equals_and_hash(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(20, 20)); } +UPB_INLINE bool google_protobuf_FileOptions_has_deprecated(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 7); } +UPB_INLINE bool google_protobuf_FileOptions_deprecated(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(21, 21)); } +UPB_INLINE bool google_protobuf_FileOptions_has_java_string_check_utf8(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 8); } +UPB_INLINE bool google_protobuf_FileOptions_java_string_check_utf8(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(22, 22)); } +UPB_INLINE bool google_protobuf_FileOptions_has_cc_enable_arenas(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 9); } +UPB_INLINE bool google_protobuf_FileOptions_cc_enable_arenas(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(23, 23)); } +UPB_INLINE bool google_protobuf_FileOptions_has_objc_class_prefix(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 14); } +UPB_INLINE upb_strview google_protobuf_FileOptions_objc_class_prefix(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(52, 80)); } +UPB_INLINE bool google_protobuf_FileOptions_has_csharp_namespace(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 15); } +UPB_INLINE upb_strview google_protobuf_FileOptions_csharp_namespace(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(60, 96)); } +UPB_INLINE bool google_protobuf_FileOptions_has_swift_prefix(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 16); } +UPB_INLINE upb_strview google_protobuf_FileOptions_swift_prefix(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(68, 112)); } +UPB_INLINE bool google_protobuf_FileOptions_has_php_class_prefix(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 17); } +UPB_INLINE upb_strview google_protobuf_FileOptions_php_class_prefix(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(76, 128)); } +UPB_INLINE bool google_protobuf_FileOptions_has_php_namespace(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 18); } +UPB_INLINE upb_strview google_protobuf_FileOptions_php_namespace(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(84, 144)); } +UPB_INLINE bool google_protobuf_FileOptions_has_php_generic_services(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 10); } +UPB_INLINE bool google_protobuf_FileOptions_php_generic_services(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(24, 24)); } +UPB_INLINE bool google_protobuf_FileOptions_has_php_metadata_namespace(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 19); } +UPB_INLINE upb_strview google_protobuf_FileOptions_php_metadata_namespace(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(92, 160)); } +UPB_INLINE bool google_protobuf_FileOptions_has_ruby_package(const google_protobuf_FileOptions *msg) { return _upb_has_field(msg, 20); } +UPB_INLINE upb_strview google_protobuf_FileOptions_ruby_package(const google_protobuf_FileOptions *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(100, 176)); } +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_FileOptions_uninterpreted_option(const google_protobuf_FileOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(108, 192), len); } + +UPB_INLINE void google_protobuf_FileOptions_set_java_package(google_protobuf_FileOptions *msg, upb_strview value) { + _upb_sethas(msg, 11); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(28, 32)) = value; +} +UPB_INLINE void google_protobuf_FileOptions_set_java_outer_classname(google_protobuf_FileOptions *msg, upb_strview value) { + _upb_sethas(msg, 12); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(36, 48)) = value; +} +UPB_INLINE void google_protobuf_FileOptions_set_optimize_for(google_protobuf_FileOptions *msg, int32_t value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; +} +UPB_INLINE void google_protobuf_FileOptions_set_java_multiple_files(google_protobuf_FileOptions *msg, bool value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, bool, UPB_SIZE(16, 16)) = value; +} +UPB_INLINE void google_protobuf_FileOptions_set_go_package(google_protobuf_FileOptions *msg, upb_strview value) { + _upb_sethas(msg, 13); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(44, 64)) = value; +} +UPB_INLINE void google_protobuf_FileOptions_set_cc_generic_services(google_protobuf_FileOptions *msg, bool value) { + _upb_sethas(msg, 3); + UPB_FIELD_AT(msg, bool, UPB_SIZE(17, 17)) = value; +} +UPB_INLINE void google_protobuf_FileOptions_set_java_generic_services(google_protobuf_FileOptions *msg, bool value) { + _upb_sethas(msg, 4); + UPB_FIELD_AT(msg, bool, UPB_SIZE(18, 18)) = value; +} +UPB_INLINE void google_protobuf_FileOptions_set_py_generic_services(google_protobuf_FileOptions *msg, bool value) { + _upb_sethas(msg, 5); + UPB_FIELD_AT(msg, bool, UPB_SIZE(19, 19)) = value; +} +UPB_INLINE void google_protobuf_FileOptions_set_java_generate_equals_and_hash(google_protobuf_FileOptions *msg, bool value) { + _upb_sethas(msg, 6); + UPB_FIELD_AT(msg, bool, UPB_SIZE(20, 20)) = value; +} +UPB_INLINE void google_protobuf_FileOptions_set_deprecated(google_protobuf_FileOptions *msg, bool value) { + _upb_sethas(msg, 7); + UPB_FIELD_AT(msg, bool, UPB_SIZE(21, 21)) = value; +} +UPB_INLINE void google_protobuf_FileOptions_set_java_string_check_utf8(google_protobuf_FileOptions *msg, bool value) { + _upb_sethas(msg, 8); + UPB_FIELD_AT(msg, bool, UPB_SIZE(22, 22)) = value; +} +UPB_INLINE void google_protobuf_FileOptions_set_cc_enable_arenas(google_protobuf_FileOptions *msg, bool value) { + _upb_sethas(msg, 9); + UPB_FIELD_AT(msg, bool, UPB_SIZE(23, 23)) = value; +} +UPB_INLINE void google_protobuf_FileOptions_set_objc_class_prefix(google_protobuf_FileOptions *msg, upb_strview value) { + _upb_sethas(msg, 14); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(52, 80)) = value; +} +UPB_INLINE void google_protobuf_FileOptions_set_csharp_namespace(google_protobuf_FileOptions *msg, upb_strview value) { + _upb_sethas(msg, 15); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(60, 96)) = value; +} +UPB_INLINE void google_protobuf_FileOptions_set_swift_prefix(google_protobuf_FileOptions *msg, upb_strview value) { + _upb_sethas(msg, 16); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(68, 112)) = value; +} +UPB_INLINE void google_protobuf_FileOptions_set_php_class_prefix(google_protobuf_FileOptions *msg, upb_strview value) { + _upb_sethas(msg, 17); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(76, 128)) = value; +} +UPB_INLINE void google_protobuf_FileOptions_set_php_namespace(google_protobuf_FileOptions *msg, upb_strview value) { + _upb_sethas(msg, 18); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(84, 144)) = value; +} +UPB_INLINE void google_protobuf_FileOptions_set_php_generic_services(google_protobuf_FileOptions *msg, bool value) { + _upb_sethas(msg, 10); + UPB_FIELD_AT(msg, bool, UPB_SIZE(24, 24)) = value; +} +UPB_INLINE void google_protobuf_FileOptions_set_php_metadata_namespace(google_protobuf_FileOptions *msg, upb_strview value) { + _upb_sethas(msg, 19); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(92, 160)) = value; +} +UPB_INLINE void google_protobuf_FileOptions_set_ruby_package(google_protobuf_FileOptions *msg, upb_strview value) { + _upb_sethas(msg, 20); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(100, 176)) = value; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FileOptions_mutable_uninterpreted_option(google_protobuf_FileOptions *msg, size_t *len) { + return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(108, 192), len); +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FileOptions_resize_uninterpreted_option(google_protobuf_FileOptions *msg, size_t len, upb_arena *arena) { + return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(108, 192), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_FileOptions_add_uninterpreted_option(google_protobuf_FileOptions *msg, upb_arena *arena) { + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(108, 192), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} + +/* google.protobuf.MessageOptions */ + +UPB_INLINE google_protobuf_MessageOptions *google_protobuf_MessageOptions_new(upb_arena *arena) { + return (google_protobuf_MessageOptions *)upb_msg_new(&google_protobuf_MessageOptions_msginit, arena); +} +UPB_INLINE google_protobuf_MessageOptions *google_protobuf_MessageOptions_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_MessageOptions *ret = google_protobuf_MessageOptions_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_MessageOptions_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_MessageOptions_serialize(const google_protobuf_MessageOptions *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_MessageOptions_msginit, arena, len); +} + +UPB_INLINE bool google_protobuf_MessageOptions_has_message_set_wire_format(const google_protobuf_MessageOptions *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE bool google_protobuf_MessageOptions_message_set_wire_format(const google_protobuf_MessageOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); } +UPB_INLINE bool google_protobuf_MessageOptions_has_no_standard_descriptor_accessor(const google_protobuf_MessageOptions *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE bool google_protobuf_MessageOptions_no_standard_descriptor_accessor(const google_protobuf_MessageOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)); } +UPB_INLINE bool google_protobuf_MessageOptions_has_deprecated(const google_protobuf_MessageOptions *msg) { return _upb_has_field(msg, 3); } +UPB_INLINE bool google_protobuf_MessageOptions_deprecated(const google_protobuf_MessageOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(3, 3)); } +UPB_INLINE bool google_protobuf_MessageOptions_has_map_entry(const google_protobuf_MessageOptions *msg) { return _upb_has_field(msg, 4); } +UPB_INLINE bool google_protobuf_MessageOptions_map_entry(const google_protobuf_MessageOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(4, 4)); } +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_MessageOptions_uninterpreted_option(const google_protobuf_MessageOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(8, 8), len); } + +UPB_INLINE void google_protobuf_MessageOptions_set_message_set_wire_format(google_protobuf_MessageOptions *msg, bool value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value; +} +UPB_INLINE void google_protobuf_MessageOptions_set_no_standard_descriptor_accessor(google_protobuf_MessageOptions *msg, bool value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)) = value; +} +UPB_INLINE void google_protobuf_MessageOptions_set_deprecated(google_protobuf_MessageOptions *msg, bool value) { + _upb_sethas(msg, 3); + UPB_FIELD_AT(msg, bool, UPB_SIZE(3, 3)) = value; +} +UPB_INLINE void google_protobuf_MessageOptions_set_map_entry(google_protobuf_MessageOptions *msg, bool value) { + _upb_sethas(msg, 4); + UPB_FIELD_AT(msg, bool, UPB_SIZE(4, 4)) = value; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MessageOptions_mutable_uninterpreted_option(google_protobuf_MessageOptions *msg, size_t *len) { + return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(8, 8), len); +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MessageOptions_resize_uninterpreted_option(google_protobuf_MessageOptions *msg, size_t len, upb_arena *arena) { + return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(8, 8), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_MessageOptions_add_uninterpreted_option(google_protobuf_MessageOptions *msg, upb_arena *arena) { + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(8, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} + +/* google.protobuf.FieldOptions */ + +UPB_INLINE google_protobuf_FieldOptions *google_protobuf_FieldOptions_new(upb_arena *arena) { + return (google_protobuf_FieldOptions *)upb_msg_new(&google_protobuf_FieldOptions_msginit, arena); +} +UPB_INLINE google_protobuf_FieldOptions *google_protobuf_FieldOptions_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_FieldOptions *ret = google_protobuf_FieldOptions_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_FieldOptions_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_FieldOptions_serialize(const google_protobuf_FieldOptions *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_FieldOptions_msginit, arena, len); +} + +UPB_INLINE bool google_protobuf_FieldOptions_has_ctype(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE int32_t google_protobuf_FieldOptions_ctype(const google_protobuf_FieldOptions *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); } +UPB_INLINE bool google_protobuf_FieldOptions_has_packed(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 3); } +UPB_INLINE bool google_protobuf_FieldOptions_packed(const google_protobuf_FieldOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(24, 24)); } +UPB_INLINE bool google_protobuf_FieldOptions_has_deprecated(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 4); } +UPB_INLINE bool google_protobuf_FieldOptions_deprecated(const google_protobuf_FieldOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(25, 25)); } +UPB_INLINE bool google_protobuf_FieldOptions_has_lazy(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 5); } +UPB_INLINE bool google_protobuf_FieldOptions_lazy(const google_protobuf_FieldOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(26, 26)); } +UPB_INLINE bool google_protobuf_FieldOptions_has_jstype(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE int32_t google_protobuf_FieldOptions_jstype(const google_protobuf_FieldOptions *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 16)); } +UPB_INLINE bool google_protobuf_FieldOptions_has_weak(const google_protobuf_FieldOptions *msg) { return _upb_has_field(msg, 6); } +UPB_INLINE bool google_protobuf_FieldOptions_weak(const google_protobuf_FieldOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(27, 27)); } +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_FieldOptions_uninterpreted_option(const google_protobuf_FieldOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(28, 32), len); } + +UPB_INLINE void google_protobuf_FieldOptions_set_ctype(google_protobuf_FieldOptions *msg, int32_t value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; +} +UPB_INLINE void google_protobuf_FieldOptions_set_packed(google_protobuf_FieldOptions *msg, bool value) { + _upb_sethas(msg, 3); + UPB_FIELD_AT(msg, bool, UPB_SIZE(24, 24)) = value; +} +UPB_INLINE void google_protobuf_FieldOptions_set_deprecated(google_protobuf_FieldOptions *msg, bool value) { + _upb_sethas(msg, 4); + UPB_FIELD_AT(msg, bool, UPB_SIZE(25, 25)) = value; +} +UPB_INLINE void google_protobuf_FieldOptions_set_lazy(google_protobuf_FieldOptions *msg, bool value) { + _upb_sethas(msg, 5); + UPB_FIELD_AT(msg, bool, UPB_SIZE(26, 26)) = value; +} +UPB_INLINE void google_protobuf_FieldOptions_set_jstype(google_protobuf_FieldOptions *msg, int32_t value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 16)) = value; +} +UPB_INLINE void google_protobuf_FieldOptions_set_weak(google_protobuf_FieldOptions *msg, bool value) { + _upb_sethas(msg, 6); + UPB_FIELD_AT(msg, bool, UPB_SIZE(27, 27)) = value; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FieldOptions_mutable_uninterpreted_option(google_protobuf_FieldOptions *msg, size_t *len) { + return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 32), len); +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FieldOptions_resize_uninterpreted_option(google_protobuf_FieldOptions *msg, size_t len, upb_arena *arena) { + return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(28, 32), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_FieldOptions_add_uninterpreted_option(google_protobuf_FieldOptions *msg, upb_arena *arena) { + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(28, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} + +/* google.protobuf.OneofOptions */ + +UPB_INLINE google_protobuf_OneofOptions *google_protobuf_OneofOptions_new(upb_arena *arena) { + return (google_protobuf_OneofOptions *)upb_msg_new(&google_protobuf_OneofOptions_msginit, arena); +} +UPB_INLINE google_protobuf_OneofOptions *google_protobuf_OneofOptions_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_OneofOptions *ret = google_protobuf_OneofOptions_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_OneofOptions_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_OneofOptions_serialize(const google_protobuf_OneofOptions *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_OneofOptions_msginit, arena, len); +} + +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_OneofOptions_uninterpreted_option(const google_protobuf_OneofOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); } + +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_OneofOptions_mutable_uninterpreted_option(google_protobuf_OneofOptions *msg, size_t *len) { + return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len); +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_OneofOptions_resize_uninterpreted_option(google_protobuf_OneofOptions *msg, size_t len, upb_arena *arena) { + return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_OneofOptions_add_uninterpreted_option(google_protobuf_OneofOptions *msg, upb_arena *arena) { + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} + +/* google.protobuf.EnumOptions */ + +UPB_INLINE google_protobuf_EnumOptions *google_protobuf_EnumOptions_new(upb_arena *arena) { + return (google_protobuf_EnumOptions *)upb_msg_new(&google_protobuf_EnumOptions_msginit, arena); +} +UPB_INLINE google_protobuf_EnumOptions *google_protobuf_EnumOptions_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_EnumOptions *ret = google_protobuf_EnumOptions_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumOptions_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_EnumOptions_serialize(const google_protobuf_EnumOptions *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_EnumOptions_msginit, arena, len); +} + +UPB_INLINE bool google_protobuf_EnumOptions_has_allow_alias(const google_protobuf_EnumOptions *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE bool google_protobuf_EnumOptions_allow_alias(const google_protobuf_EnumOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); } +UPB_INLINE bool google_protobuf_EnumOptions_has_deprecated(const google_protobuf_EnumOptions *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE bool google_protobuf_EnumOptions_deprecated(const google_protobuf_EnumOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)); } +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_EnumOptions_uninterpreted_option(const google_protobuf_EnumOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); } + +UPB_INLINE void google_protobuf_EnumOptions_set_allow_alias(google_protobuf_EnumOptions *msg, bool value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value; +} +UPB_INLINE void google_protobuf_EnumOptions_set_deprecated(google_protobuf_EnumOptions *msg, bool value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)) = value; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumOptions_mutable_uninterpreted_option(google_protobuf_EnumOptions *msg, size_t *len) { + return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(4, 8), len); +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumOptions_resize_uninterpreted_option(google_protobuf_EnumOptions *msg, size_t len, upb_arena *arena) { + return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(4, 8), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_EnumOptions_add_uninterpreted_option(google_protobuf_EnumOptions *msg, upb_arena *arena) { + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(4, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} + +/* google.protobuf.EnumValueOptions */ + +UPB_INLINE google_protobuf_EnumValueOptions *google_protobuf_EnumValueOptions_new(upb_arena *arena) { + return (google_protobuf_EnumValueOptions *)upb_msg_new(&google_protobuf_EnumValueOptions_msginit, arena); +} +UPB_INLINE google_protobuf_EnumValueOptions *google_protobuf_EnumValueOptions_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_EnumValueOptions *ret = google_protobuf_EnumValueOptions_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumValueOptions_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_EnumValueOptions_serialize(const google_protobuf_EnumValueOptions *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_EnumValueOptions_msginit, arena, len); +} + +UPB_INLINE bool google_protobuf_EnumValueOptions_has_deprecated(const google_protobuf_EnumValueOptions *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE bool google_protobuf_EnumValueOptions_deprecated(const google_protobuf_EnumValueOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); } +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_EnumValueOptions_uninterpreted_option(const google_protobuf_EnumValueOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); } + +UPB_INLINE void google_protobuf_EnumValueOptions_set_deprecated(google_protobuf_EnumValueOptions *msg, bool value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumValueOptions_mutable_uninterpreted_option(google_protobuf_EnumValueOptions *msg, size_t *len) { + return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(4, 8), len); +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumValueOptions_resize_uninterpreted_option(google_protobuf_EnumValueOptions *msg, size_t len, upb_arena *arena) { + return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(4, 8), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_EnumValueOptions_add_uninterpreted_option(google_protobuf_EnumValueOptions *msg, upb_arena *arena) { + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(4, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} + +/* google.protobuf.ServiceOptions */ + +UPB_INLINE google_protobuf_ServiceOptions *google_protobuf_ServiceOptions_new(upb_arena *arena) { + return (google_protobuf_ServiceOptions *)upb_msg_new(&google_protobuf_ServiceOptions_msginit, arena); +} +UPB_INLINE google_protobuf_ServiceOptions *google_protobuf_ServiceOptions_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_ServiceOptions *ret = google_protobuf_ServiceOptions_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_ServiceOptions_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_ServiceOptions_serialize(const google_protobuf_ServiceOptions *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_ServiceOptions_msginit, arena, len); +} + +UPB_INLINE bool google_protobuf_ServiceOptions_has_deprecated(const google_protobuf_ServiceOptions *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE bool google_protobuf_ServiceOptions_deprecated(const google_protobuf_ServiceOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); } +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_ServiceOptions_uninterpreted_option(const google_protobuf_ServiceOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); } + +UPB_INLINE void google_protobuf_ServiceOptions_set_deprecated(google_protobuf_ServiceOptions *msg, bool value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ServiceOptions_mutable_uninterpreted_option(google_protobuf_ServiceOptions *msg, size_t *len) { + return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(4, 8), len); +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ServiceOptions_resize_uninterpreted_option(google_protobuf_ServiceOptions *msg, size_t len, upb_arena *arena) { + return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(4, 8), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_ServiceOptions_add_uninterpreted_option(google_protobuf_ServiceOptions *msg, upb_arena *arena) { + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(4, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} + +/* google.protobuf.MethodOptions */ + +UPB_INLINE google_protobuf_MethodOptions *google_protobuf_MethodOptions_new(upb_arena *arena) { + return (google_protobuf_MethodOptions *)upb_msg_new(&google_protobuf_MethodOptions_msginit, arena); +} +UPB_INLINE google_protobuf_MethodOptions *google_protobuf_MethodOptions_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_MethodOptions *ret = google_protobuf_MethodOptions_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_MethodOptions_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_MethodOptions_serialize(const google_protobuf_MethodOptions *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_MethodOptions_msginit, arena, len); +} + +UPB_INLINE bool google_protobuf_MethodOptions_has_deprecated(const google_protobuf_MethodOptions *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE bool google_protobuf_MethodOptions_deprecated(const google_protobuf_MethodOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(16, 16)); } +UPB_INLINE bool google_protobuf_MethodOptions_has_idempotency_level(const google_protobuf_MethodOptions *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE int32_t google_protobuf_MethodOptions_idempotency_level(const google_protobuf_MethodOptions *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); } +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_MethodOptions_uninterpreted_option(const google_protobuf_MethodOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(20, 24), len); } + +UPB_INLINE void google_protobuf_MethodOptions_set_deprecated(google_protobuf_MethodOptions *msg, bool value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, bool, UPB_SIZE(16, 16)) = value; +} +UPB_INLINE void google_protobuf_MethodOptions_set_idempotency_level(google_protobuf_MethodOptions *msg, int32_t value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MethodOptions_mutable_uninterpreted_option(google_protobuf_MethodOptions *msg, size_t *len) { + return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 24), len); +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MethodOptions_resize_uninterpreted_option(google_protobuf_MethodOptions *msg, size_t len, upb_arena *arena) { + return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(20, 24), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_MethodOptions_add_uninterpreted_option(google_protobuf_MethodOptions *msg, upb_arena *arena) { + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(20, 24), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} + +/* google.protobuf.UninterpretedOption */ + +UPB_INLINE google_protobuf_UninterpretedOption *google_protobuf_UninterpretedOption_new(upb_arena *arena) { + return (google_protobuf_UninterpretedOption *)upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena); +} +UPB_INLINE google_protobuf_UninterpretedOption *google_protobuf_UninterpretedOption_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_UninterpretedOption *ret = google_protobuf_UninterpretedOption_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_UninterpretedOption_serialize(const google_protobuf_UninterpretedOption *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_UninterpretedOption_msginit, arena, len); +} + +UPB_INLINE const google_protobuf_UninterpretedOption_NamePart* const* google_protobuf_UninterpretedOption_name(const google_protobuf_UninterpretedOption *msg, size_t *len) { return (const google_protobuf_UninterpretedOption_NamePart* const*)_upb_array_accessor(msg, UPB_SIZE(56, 80), len); } +UPB_INLINE bool google_protobuf_UninterpretedOption_has_identifier_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 4); } +UPB_INLINE upb_strview google_protobuf_UninterpretedOption_identifier_value(const google_protobuf_UninterpretedOption *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(32, 32)); } +UPB_INLINE bool google_protobuf_UninterpretedOption_has_positive_int_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE uint64_t google_protobuf_UninterpretedOption_positive_int_value(const google_protobuf_UninterpretedOption *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(8, 8)); } +UPB_INLINE bool google_protobuf_UninterpretedOption_has_negative_int_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE int64_t google_protobuf_UninterpretedOption_negative_int_value(const google_protobuf_UninterpretedOption *msg) { return UPB_FIELD_AT(msg, int64_t, UPB_SIZE(16, 16)); } +UPB_INLINE bool google_protobuf_UninterpretedOption_has_double_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 3); } +UPB_INLINE double google_protobuf_UninterpretedOption_double_value(const google_protobuf_UninterpretedOption *msg) { return UPB_FIELD_AT(msg, double, UPB_SIZE(24, 24)); } +UPB_INLINE bool google_protobuf_UninterpretedOption_has_string_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 5); } +UPB_INLINE upb_strview google_protobuf_UninterpretedOption_string_value(const google_protobuf_UninterpretedOption *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(40, 48)); } +UPB_INLINE bool google_protobuf_UninterpretedOption_has_aggregate_value(const google_protobuf_UninterpretedOption *msg) { return _upb_has_field(msg, 6); } +UPB_INLINE upb_strview google_protobuf_UninterpretedOption_aggregate_value(const google_protobuf_UninterpretedOption *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(48, 64)); } + +UPB_INLINE google_protobuf_UninterpretedOption_NamePart** google_protobuf_UninterpretedOption_mutable_name(google_protobuf_UninterpretedOption *msg, size_t *len) { + return (google_protobuf_UninterpretedOption_NamePart**)_upb_array_mutable_accessor(msg, UPB_SIZE(56, 80), len); +} +UPB_INLINE google_protobuf_UninterpretedOption_NamePart** google_protobuf_UninterpretedOption_resize_name(google_protobuf_UninterpretedOption *msg, size_t len, upb_arena *arena) { + return (google_protobuf_UninterpretedOption_NamePart**)_upb_array_resize_accessor(msg, UPB_SIZE(56, 80), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption_NamePart* google_protobuf_UninterpretedOption_add_name(google_protobuf_UninterpretedOption *msg, upb_arena *arena) { + struct google_protobuf_UninterpretedOption_NamePart* sub = (struct google_protobuf_UninterpretedOption_NamePart*)upb_msg_new(&google_protobuf_UninterpretedOption_NamePart_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(56, 80), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} +UPB_INLINE void google_protobuf_UninterpretedOption_set_identifier_value(google_protobuf_UninterpretedOption *msg, upb_strview value) { + _upb_sethas(msg, 4); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(32, 32)) = value; +} +UPB_INLINE void google_protobuf_UninterpretedOption_set_positive_int_value(google_protobuf_UninterpretedOption *msg, uint64_t value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(8, 8)) = value; +} +UPB_INLINE void google_protobuf_UninterpretedOption_set_negative_int_value(google_protobuf_UninterpretedOption *msg, int64_t value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, int64_t, UPB_SIZE(16, 16)) = value; +} +UPB_INLINE void google_protobuf_UninterpretedOption_set_double_value(google_protobuf_UninterpretedOption *msg, double value) { + _upb_sethas(msg, 3); + UPB_FIELD_AT(msg, double, UPB_SIZE(24, 24)) = value; +} +UPB_INLINE void google_protobuf_UninterpretedOption_set_string_value(google_protobuf_UninterpretedOption *msg, upb_strview value) { + _upb_sethas(msg, 5); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(40, 48)) = value; +} +UPB_INLINE void google_protobuf_UninterpretedOption_set_aggregate_value(google_protobuf_UninterpretedOption *msg, upb_strview value) { + _upb_sethas(msg, 6); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(48, 64)) = value; +} + +/* google.protobuf.UninterpretedOption.NamePart */ + +UPB_INLINE google_protobuf_UninterpretedOption_NamePart *google_protobuf_UninterpretedOption_NamePart_new(upb_arena *arena) { + return (google_protobuf_UninterpretedOption_NamePart *)upb_msg_new(&google_protobuf_UninterpretedOption_NamePart_msginit, arena); +} +UPB_INLINE google_protobuf_UninterpretedOption_NamePart *google_protobuf_UninterpretedOption_NamePart_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_UninterpretedOption_NamePart *ret = google_protobuf_UninterpretedOption_NamePart_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_NamePart_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_UninterpretedOption_NamePart_serialize(const google_protobuf_UninterpretedOption_NamePart *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_UninterpretedOption_NamePart_msginit, arena, len); +} + +UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_has_name_part(const google_protobuf_UninterpretedOption_NamePart *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE upb_strview google_protobuf_UninterpretedOption_NamePart_name_part(const google_protobuf_UninterpretedOption_NamePart *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } +UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_has_is_extension(const google_protobuf_UninterpretedOption_NamePart *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_is_extension(const google_protobuf_UninterpretedOption_NamePart *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); } + +UPB_INLINE void google_protobuf_UninterpretedOption_NamePart_set_name_part(google_protobuf_UninterpretedOption_NamePart *msg, upb_strview value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; +} +UPB_INLINE void google_protobuf_UninterpretedOption_NamePart_set_is_extension(google_protobuf_UninterpretedOption_NamePart *msg, bool value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value; +} + +/* google.protobuf.SourceCodeInfo */ + +UPB_INLINE google_protobuf_SourceCodeInfo *google_protobuf_SourceCodeInfo_new(upb_arena *arena) { + return (google_protobuf_SourceCodeInfo *)upb_msg_new(&google_protobuf_SourceCodeInfo_msginit, arena); +} +UPB_INLINE google_protobuf_SourceCodeInfo *google_protobuf_SourceCodeInfo_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_SourceCodeInfo *ret = google_protobuf_SourceCodeInfo_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_SourceCodeInfo_serialize(const google_protobuf_SourceCodeInfo *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_SourceCodeInfo_msginit, arena, len); +} + +UPB_INLINE const google_protobuf_SourceCodeInfo_Location* const* google_protobuf_SourceCodeInfo_location(const google_protobuf_SourceCodeInfo *msg, size_t *len) { return (const google_protobuf_SourceCodeInfo_Location* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); } + +UPB_INLINE google_protobuf_SourceCodeInfo_Location** google_protobuf_SourceCodeInfo_mutable_location(google_protobuf_SourceCodeInfo *msg, size_t *len) { + return (google_protobuf_SourceCodeInfo_Location**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len); +} +UPB_INLINE google_protobuf_SourceCodeInfo_Location** google_protobuf_SourceCodeInfo_resize_location(google_protobuf_SourceCodeInfo *msg, size_t len, upb_arena *arena) { + return (google_protobuf_SourceCodeInfo_Location**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_SourceCodeInfo_Location* google_protobuf_SourceCodeInfo_add_location(google_protobuf_SourceCodeInfo *msg, upb_arena *arena) { + struct google_protobuf_SourceCodeInfo_Location* sub = (struct google_protobuf_SourceCodeInfo_Location*)upb_msg_new(&google_protobuf_SourceCodeInfo_Location_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} + +/* google.protobuf.SourceCodeInfo.Location */ + +UPB_INLINE google_protobuf_SourceCodeInfo_Location *google_protobuf_SourceCodeInfo_Location_new(upb_arena *arena) { + return (google_protobuf_SourceCodeInfo_Location *)upb_msg_new(&google_protobuf_SourceCodeInfo_Location_msginit, arena); +} +UPB_INLINE google_protobuf_SourceCodeInfo_Location *google_protobuf_SourceCodeInfo_Location_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_SourceCodeInfo_Location *ret = google_protobuf_SourceCodeInfo_Location_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_Location_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_SourceCodeInfo_Location_serialize(const google_protobuf_SourceCodeInfo_Location *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_SourceCodeInfo_Location_msginit, arena, len); +} + +UPB_INLINE int32_t const* google_protobuf_SourceCodeInfo_Location_path(const google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len); } +UPB_INLINE int32_t const* google_protobuf_SourceCodeInfo_Location_span(const google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len); } +UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_leading_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE upb_strview google_protobuf_SourceCodeInfo_Location_leading_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)); } +UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_trailing_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE upb_strview google_protobuf_SourceCodeInfo_Location_trailing_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)); } +UPB_INLINE upb_strview const* google_protobuf_SourceCodeInfo_Location_leading_detached_comments(const google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(28, 56), len); } + +UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_mutable_path(google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { + return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 40), len); +} +UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_resize_path(google_protobuf_SourceCodeInfo_Location *msg, size_t len, upb_arena *arena) { + return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(20, 40), len, UPB_SIZE(4, 4), UPB_TYPE_INT32, arena); +} +UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_path(google_protobuf_SourceCodeInfo_Location *msg, int32_t val, upb_arena *arena) { + return _upb_array_append_accessor( + msg, UPB_SIZE(20, 40), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val, arena); +} +UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_mutable_span(google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { + return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 48), len); +} +UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_resize_span(google_protobuf_SourceCodeInfo_Location *msg, size_t len, upb_arena *arena) { + return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(24, 48), len, UPB_SIZE(4, 4), UPB_TYPE_INT32, arena); +} +UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_span(google_protobuf_SourceCodeInfo_Location *msg, int32_t val, upb_arena *arena) { + return _upb_array_append_accessor( + msg, UPB_SIZE(24, 48), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val, arena); +} +UPB_INLINE void google_protobuf_SourceCodeInfo_Location_set_leading_comments(google_protobuf_SourceCodeInfo_Location *msg, upb_strview value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(4, 8)) = value; +} +UPB_INLINE void google_protobuf_SourceCodeInfo_Location_set_trailing_comments(google_protobuf_SourceCodeInfo_Location *msg, upb_strview value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 24)) = value; +} +UPB_INLINE upb_strview* google_protobuf_SourceCodeInfo_Location_mutable_leading_detached_comments(google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { + return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 56), len); +} +UPB_INLINE upb_strview* google_protobuf_SourceCodeInfo_Location_resize_leading_detached_comments(google_protobuf_SourceCodeInfo_Location *msg, size_t len, upb_arena *arena) { + return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(28, 56), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); +} +UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_leading_detached_comments(google_protobuf_SourceCodeInfo_Location *msg, upb_strview val, upb_arena *arena) { + return _upb_array_append_accessor( + msg, UPB_SIZE(28, 56), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); +} + +/* google.protobuf.GeneratedCodeInfo */ + +UPB_INLINE google_protobuf_GeneratedCodeInfo *google_protobuf_GeneratedCodeInfo_new(upb_arena *arena) { + return (google_protobuf_GeneratedCodeInfo *)upb_msg_new(&google_protobuf_GeneratedCodeInfo_msginit, arena); +} +UPB_INLINE google_protobuf_GeneratedCodeInfo *google_protobuf_GeneratedCodeInfo_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_GeneratedCodeInfo *ret = google_protobuf_GeneratedCodeInfo_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_GeneratedCodeInfo_serialize(const google_protobuf_GeneratedCodeInfo *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_GeneratedCodeInfo_msginit, arena, len); +} + +UPB_INLINE const google_protobuf_GeneratedCodeInfo_Annotation* const* google_protobuf_GeneratedCodeInfo_annotation(const google_protobuf_GeneratedCodeInfo *msg, size_t *len) { return (const google_protobuf_GeneratedCodeInfo_Annotation* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); } + +UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation** google_protobuf_GeneratedCodeInfo_mutable_annotation(google_protobuf_GeneratedCodeInfo *msg, size_t *len) { + return (google_protobuf_GeneratedCodeInfo_Annotation**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len); +} +UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation** google_protobuf_GeneratedCodeInfo_resize_annotation(google_protobuf_GeneratedCodeInfo *msg, size_t len, upb_arena *arena) { + return (google_protobuf_GeneratedCodeInfo_Annotation**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct google_protobuf_GeneratedCodeInfo_Annotation* google_protobuf_GeneratedCodeInfo_add_annotation(google_protobuf_GeneratedCodeInfo *msg, upb_arena *arena) { + struct google_protobuf_GeneratedCodeInfo_Annotation* sub = (struct google_protobuf_GeneratedCodeInfo_Annotation*)upb_msg_new(&google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} + +/* google.protobuf.GeneratedCodeInfo.Annotation */ + +UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation *google_protobuf_GeneratedCodeInfo_Annotation_new(upb_arena *arena) { + return (google_protobuf_GeneratedCodeInfo_Annotation *)upb_msg_new(&google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena); +} +UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation *google_protobuf_GeneratedCodeInfo_Annotation_parse(const char *buf, size_t size, + upb_arena *arena) { + google_protobuf_GeneratedCodeInfo_Annotation *ret = google_protobuf_GeneratedCodeInfo_Annotation_new(arena); + return (ret && upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *google_protobuf_GeneratedCodeInfo_Annotation_serialize(const google_protobuf_GeneratedCodeInfo_Annotation *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena, len); +} + +UPB_INLINE int32_t const* google_protobuf_GeneratedCodeInfo_Annotation_path(const google_protobuf_GeneratedCodeInfo_Annotation *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(20, 32), len); } +UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_source_file(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return _upb_has_field(msg, 3); } +UPB_INLINE upb_strview google_protobuf_GeneratedCodeInfo_Annotation_source_file(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 16)); } +UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_begin(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return _upb_has_field(msg, 1); } +UPB_INLINE int32_t google_protobuf_GeneratedCodeInfo_Annotation_begin(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)); } +UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_end(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return _upb_has_field(msg, 2); } +UPB_INLINE int32_t google_protobuf_GeneratedCodeInfo_Annotation_end(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)); } + +UPB_INLINE int32_t* google_protobuf_GeneratedCodeInfo_Annotation_mutable_path(google_protobuf_GeneratedCodeInfo_Annotation *msg, size_t *len) { + return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 32), len); +} +UPB_INLINE int32_t* google_protobuf_GeneratedCodeInfo_Annotation_resize_path(google_protobuf_GeneratedCodeInfo_Annotation *msg, size_t len, upb_arena *arena) { + return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(20, 32), len, UPB_SIZE(4, 4), UPB_TYPE_INT32, arena); +} +UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_add_path(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t val, upb_arena *arena) { + return _upb_array_append_accessor( + msg, UPB_SIZE(20, 32), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val, arena); +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_source_file(google_protobuf_GeneratedCodeInfo_Annotation *msg, upb_strview value) { + _upb_sethas(msg, 3); + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(12, 16)) = value; +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_begin(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t value) { + _upb_sethas(msg, 1); + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 4)) = value; +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_end(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t value) { + _upb_sethas(msg, 2); + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(8, 8)) = value; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#include "upb/port_undef.inc" + +#endif /* GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_ */ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index cf9f284db88..ec5b79d965b 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -317,7 +317,6 @@ CORE_SOURCE_FILES = [ 'third_party/nanopb/pb_decode.c', 'third_party/nanopb/pb_encode.c', 'src/core/tsi/transport_security.cc', - 'third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c', 'third_party/upb/upb/decode.c', 'third_party/upb/upb/encode.c', 'third_party/upb/upb/msg.c', diff --git a/src/upb/gen_build_yaml.py b/src/upb/gen_build_yaml.py index 0eb9eb1bd47..65d31953b1f 100755 --- a/src/upb/gen_build_yaml.py +++ b/src/upb/gen_build_yaml.py @@ -22,7 +22,6 @@ import sys import yaml hdrs = [ - "third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.h", "third_party/upb/upb/decode.h", "third_party/upb/upb/encode.h", "third_party/upb/upb/generated_util.h", @@ -34,7 +33,6 @@ hdrs = [ ] srcs = [ - "third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c", "third_party/upb/upb/decode.c", "third_party/upb/upb/encode.c", "third_party/upb/upb/msg.c", diff --git a/templates/config.m4.template b/templates/config.m4.template index db55a34d84c..677c7ddf63a 100644 --- a/templates/config.m4.template +++ b/templates/config.m4.template @@ -14,7 +14,6 @@ PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/boringssl/include) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/nanopb) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/upb) - PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/upb/generated_for_cmake) LIBS="-lpthread $LIBS" diff --git a/templates/config.w32.template b/templates/config.w32.template index b9e9acd1ec1..70920f3527d 100644 --- a/templates/config.w32.template +++ b/templates/config.w32.template @@ -32,7 +32,6 @@ "/I"+configure_module_dirname+"\\third_party\\boringssl\\include "+ "/I"+configure_module_dirname+"\\third_party\\nanopb "+ "/I"+configure_module_dirname+"\\third_party\\upb "+ - "/I"+configure_module_dirname+"\\third_party\\upb\\generated_for_cmake "+ "/I"+configure_module_dirname+"\\third_party\\zlib "); <% dirs = {} diff --git a/templates/gRPC-C++.podspec.template b/templates/gRPC-C++.podspec.template index 1ec2d877542..b8080c92731 100644 --- a/templates/gRPC-C++.podspec.template +++ b/templates/gRPC-C++.podspec.template @@ -231,7 +231,5 @@ find src/core/ third_party/upb/ -type f -name '*.grpc_back' -print0 | xargs -0 rm find src/core/ src/cpp/ -type f \\( -name '*.h' -or -name '*.c' -or -name '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(.*).upb.h";#if COCOAPODS==1\\\n #include "src/core/ext/upb-generated/\\1.upb.h"\\\n#else\\\n #include "\\1.upb.h"\\\n#endif;g' find src/core/ src/cpp/ -type f -name '*.grpc_back' -print0 | xargs -0 rm - find third_party/upb/ -type f \\( -name '*.h' -or -name '*.c' -or -name '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(.*).upb.h";#if COCOAPODS==1\\\n #include "third_party/upb/generated_for_cmake/\\1.upb.h"\\\n#else\\\n #include "\\1.upb.h"\\\n#endif;g' - find third_party/upb/ -type f -name '*.grpc_back' -print0 | xargs -0 rm END_OF_COMMAND end diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template index 9d4f1b4d4a0..9f67ae428ae 100644 --- a/templates/gRPC-Core.podspec.template +++ b/templates/gRPC-Core.podspec.template @@ -218,7 +218,5 @@ find src/core/ third_party/upb/ -type f -name '*.grpc_back' -print0 | xargs -0 rm find src/core/ src/cpp/ -type f \\( -name '*.h' -or -name '*.c' -or -name '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(.*).upb.h";#if COCOAPODS==1\\\n #include "src/core/ext/upb-generated/\\1.upb.h"\\\n#else\\\n #include "\\1.upb.h"\\\n#endif;g' find src/core/ src/cpp/ -type f -name '*.grpc_back' -print0 | xargs -0 rm - find third_party/upb/ -type f \\( -name '*.h' -or -name '*.c' -or -name '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(.*).upb.h";#if COCOAPODS==1\\\n #include "third_party/upb/generated_for_cmake/\\1.upb.h"\\\n#else\\\n #include "\\1.upb.h"\\\n#endif;g' - find third_party/upb/ -type f -name '*.grpc_back' -print0 | xargs -0 rm END_OF_COMMAND end diff --git a/tools/codegen/core/gen_upb_api.sh b/tools/codegen/core/gen_upb_api.sh index 8d208c01e32..4a9239a2828 100755 --- a/tools/codegen/core/gen_upb_api.sh +++ b/tools/codegen/core/gen_upb_api.sh @@ -60,6 +60,7 @@ proto_files=( \ "google/api/annotations.proto" \ "google/api/http.proto" \ "google/protobuf/any.proto" \ + "google/protobuf/descriptor.proto" \ "google/protobuf/duration.proto" \ "google/protobuf/empty.proto" \ "google/protobuf/struct.proto" \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 3b7b4843815..ac421d418ba 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1296,7 +1296,6 @@ third_party/nanopb/pb.h \ third_party/nanopb/pb_common.h \ third_party/nanopb/pb_decode.h \ third_party/nanopb/pb_encode.h \ -third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ third_party/upb/upb/decode.c \ third_party/upb/upb/encode.c \ third_party/upb/upb/msg.c \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index e64dce2e3f1..58d719c438e 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1597,7 +1597,6 @@ third_party/nanopb/pb_decode.c \ third_party/nanopb/pb_decode.h \ third_party/nanopb/pb_encode.c \ third_party/nanopb/pb_encode.h \ -third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.c \ third_party/upb/upb/decode.c \ third_party/upb/upb/encode.c \ third_party/upb/upb/msg.c \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index b7ba89293a0..3278e997e6b 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -8308,6 +8308,7 @@ "deps": [], "headers": [ "src/core/ext/upb-generated/google/protobuf/any.upb.h", + "src/core/ext/upb-generated/google/protobuf/descriptor.upb.h", "src/core/ext/upb-generated/google/protobuf/duration.upb.h", "src/core/ext/upb-generated/google/protobuf/empty.upb.h", "src/core/ext/upb-generated/google/protobuf/struct.upb.h", @@ -8320,6 +8321,8 @@ "src": [ "src/core/ext/upb-generated/google/protobuf/any.upb.c", "src/core/ext/upb-generated/google/protobuf/any.upb.h", + "src/core/ext/upb-generated/google/protobuf/descriptor.upb.c", + "src/core/ext/upb-generated/google/protobuf/descriptor.upb.h", "src/core/ext/upb-generated/google/protobuf/duration.upb.c", "src/core/ext/upb-generated/google/protobuf/duration.upb.h", "src/core/ext/upb-generated/google/protobuf/empty.upb.c", @@ -10947,7 +10950,6 @@ { "deps": [], "headers": [ - "third_party/upb/generated_for_cmake/google/protobuf/descriptor.upb.h", "third_party/upb/upb/decode.h", "third_party/upb/upb/encode.h", "third_party/upb/upb/generated_util.h", From c6b0bd08c70cc57cb65c3f634824bd1fda804e7c Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 24 Jul 2019 14:33:18 -0700 Subject: [PATCH 1139/1555] Updated grpclb to use upb --- BUILD | 10 +- BUILD.gn | 16 + CMakeLists.txt | 30 +- Makefile | 30 +- build.yaml | 8 +- config.m4 | 16 +- config.w32 | 18 +- gRPC-C++.podspec | 14 +- gRPC-Core.podspec | 42 ++- grpc.gemspec | 28 +- grpc.gyp | 30 +- package.xml | 28 +- .../client_channel/lb_policy/grpclb/grpclb.cc | 73 ++-- .../lb_policy/grpclb/load_balancer_api.cc | 347 +++++++----------- .../lb_policy/grpclb/load_balancer_api.h | 55 +-- src/python/grpcio/grpc_core_dependencies.py | 14 +- test/core/nanopb/fuzzer_response.cc | 6 +- test/core/nanopb/fuzzer_serverlist.cc | 4 +- test/cpp/grpclb/grpclb_api_test.cc | 39 +- tools/doxygen/Doxyfile.core.internal | 16 + .../generated/sources_and_headers.json | 12 +- 21 files changed, 470 insertions(+), 366 deletions(-) diff --git a/BUILD b/BUILD index 74af17760a9..0f3b426ff06 100644 --- a/BUILD +++ b/BUILD @@ -1226,15 +1226,12 @@ grpc_cc_library( "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h", "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h", ], - external_deps = [ - "nanopb", - ], language = "c++", deps = [ "grpc_base", "grpc_client_channel", "grpc_resolver_fake", - "grpclb_proto", + "grpc_lb_upb", ], ) @@ -1254,16 +1251,13 @@ grpc_cc_library( "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h", "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h", ], - external_deps = [ - "nanopb", - ], language = "c++", deps = [ "grpc_base", "grpc_client_channel", "grpc_resolver_fake", "grpc_secure", - "grpclb_proto", + "grpc_lb_upb", ], ) diff --git a/BUILD.gn b/BUILD.gn index 9b003465bc8..28a950c13cf 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -410,8 +410,24 @@ config("grpc_config") { "src/core/ext/transport/inproc/inproc_plugin.cc", "src/core/ext/transport/inproc/inproc_transport.cc", "src/core/ext/transport/inproc/inproc_transport.h", + "src/core/ext/upb-generated/google/protobuf/any.upb.c", + "src/core/ext/upb-generated/google/protobuf/any.upb.h", + "src/core/ext/upb-generated/google/protobuf/descriptor.upb.c", + "src/core/ext/upb-generated/google/protobuf/descriptor.upb.h", + "src/core/ext/upb-generated/google/protobuf/duration.upb.c", + "src/core/ext/upb-generated/google/protobuf/duration.upb.h", + "src/core/ext/upb-generated/google/protobuf/empty.upb.c", + "src/core/ext/upb-generated/google/protobuf/empty.upb.h", + "src/core/ext/upb-generated/google/protobuf/struct.upb.c", + "src/core/ext/upb-generated/google/protobuf/struct.upb.h", + "src/core/ext/upb-generated/google/protobuf/timestamp.upb.c", + "src/core/ext/upb-generated/google/protobuf/timestamp.upb.h", + "src/core/ext/upb-generated/google/protobuf/wrappers.upb.c", + "src/core/ext/upb-generated/google/protobuf/wrappers.upb.h", "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c", "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h", + "src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c", + "src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h", "src/core/lib/avl/avl.cc", "src/core/lib/avl/avl.h", "src/core/lib/backoff/backoff.cc", diff --git a/CMakeLists.txt b/CMakeLists.txt index 2034ec6c490..6c3c7d3feb0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1322,14 +1322,22 @@ add_library(grpc src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc + src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c + src/core/ext/upb-generated/google/protobuf/any.upb.c + src/core/ext/upb-generated/google/protobuf/descriptor.upb.c + src/core/ext/upb-generated/google/protobuf/duration.upb.c + src/core/ext/upb-generated/google/protobuf/empty.upb.c + src/core/ext/upb-generated/google/protobuf/struct.upb.c + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c src/core/ext/filters/client_channel/lb_policy/xds/xds.cc src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc + src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c + src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c + src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -2795,16 +2803,24 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc + src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c + src/core/ext/upb-generated/google/protobuf/any.upb.c + src/core/ext/upb-generated/google/protobuf/descriptor.upb.c + src/core/ext/upb-generated/google/protobuf/duration.upb.c + src/core/ext/upb-generated/google/protobuf/empty.upb.c + src/core/ext/upb-generated/google/protobuf/struct.upb.c + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c + src/core/ext/filters/client_channel/lb_policy/xds/xds.cc + src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc + src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc + src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c third_party/nanopb/pb_common.c third_party/nanopb/pb_decode.c third_party/nanopb/pb_encode.c - src/core/ext/filters/client_channel/lb_policy/xds/xds.cc - src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc - src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc - src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc src/core/ext/filters/census/grpc_context.cc diff --git a/Makefile b/Makefile index 97eb59912ec..4ea6acdb4bf 100644 --- a/Makefile +++ b/Makefile @@ -3813,14 +3813,22 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \ + src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ + src/core/ext/upb-generated/google/protobuf/any.upb.c \ + src/core/ext/upb-generated/google/protobuf/descriptor.upb.c \ + src/core/ext/upb-generated/google/protobuf/duration.upb.c \ + src/core/ext/upb-generated/google/protobuf/empty.upb.c \ + src/core/ext/upb-generated/google/protobuf/struct.upb.c \ + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c \ - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c \ - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ src/core/ext/filters/client_channel/lb_policy/xds/xds.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc \ + src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c \ + src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c \ + src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc \ src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc \ @@ -5210,16 +5218,24 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \ + src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ + src/core/ext/upb-generated/google/protobuf/any.upb.c \ + src/core/ext/upb-generated/google/protobuf/descriptor.upb.c \ + src/core/ext/upb-generated/google/protobuf/duration.upb.c \ + src/core/ext/upb-generated/google/protobuf/empty.upb.c \ + src/core/ext/upb-generated/google/protobuf/struct.upb.c \ + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ + src/core/ext/filters/client_channel/lb_policy/xds/xds.cc \ + src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc \ + src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc \ + src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ third_party/nanopb/pb_common.c \ third_party/nanopb/pb_decode.c \ third_party/nanopb/pb_encode.c \ - src/core/ext/filters/client_channel/lb_policy/xds/xds.cc \ - src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc \ - src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc \ - src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc \ src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc \ src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc \ src/core/ext/filters/census/grpc_context.cc \ diff --git a/build.yaml b/build.yaml index 0563f6558fb..24da28e2591 100644 --- a/build.yaml +++ b/build.yaml @@ -725,9 +725,8 @@ filegroups: uses: - grpc_base - grpc_client_channel + - grpc_lb_upb - grpc_resolver_fake - - grpclb_proto - - nanopb - upb - name: grpc_lb_policy_grpclb_secure headers: @@ -746,10 +745,9 @@ filegroups: uses: - grpc_base - grpc_client_channel + - grpc_lb_upb - grpc_resolver_fake - grpc_secure - - grpclb_proto - - nanopb - upb - name: grpc_lb_policy_pick_first src: @@ -785,7 +783,6 @@ filegroups: - grpc_resolver_fake - grpclb_proto - nanopb - - upb - name: grpc_lb_policy_xds_secure headers: - src/core/ext/filters/client_channel/lb_policy/xds/xds.h @@ -805,7 +802,6 @@ filegroups: - grpc_secure - grpclb_proto - nanopb - - upb - name: grpc_lb_subchannel_list headers: - src/core/ext/filters/client_channel/lb_policy/subchannel_list.h diff --git a/config.m4 b/config.m4 index 34974f18ac2..a23d65f8542 100644 --- a/config.m4 +++ b/config.m4 @@ -401,14 +401,22 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \ + src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ + src/core/ext/upb-generated/google/protobuf/any.upb.c \ + src/core/ext/upb-generated/google/protobuf/descriptor.upb.c \ + src/core/ext/upb-generated/google/protobuf/duration.upb.c \ + src/core/ext/upb-generated/google/protobuf/empty.upb.c \ + src/core/ext/upb-generated/google/protobuf/struct.upb.c \ + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c \ - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c \ - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ src/core/ext/filters/client_channel/lb_policy/xds/xds.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc \ + src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c \ + src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c \ + src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc \ src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc \ @@ -729,7 +737,9 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/server/secure) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/transport) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/inproc) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/google/protobuf) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/src/proto/grpc/health/v1) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/src/proto/grpc/lb/v1) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/avl) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/backoff) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/channel) diff --git a/config.w32 b/config.w32 index db7f05c7aa5..27635b54544 100644 --- a/config.w32 +++ b/config.w32 @@ -374,14 +374,22 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\grpclb_channel_secure.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\grpclb_client_stats.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\load_balancer_api.cc " + + "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\lb\\v1\\load_balancer.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\any.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\descriptor.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\duration.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\empty.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\struct.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\timestamp.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\wrappers.upb.c " + "src\\core\\ext\\filters\\client_channel\\resolver\\fake\\fake_resolver.cc " + - "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto\\grpc\\lb\\v1\\google\\protobuf\\duration.pb.c " + - "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto\\grpc\\lb\\v1\\google\\protobuf\\timestamp.pb.c " + - "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto\\grpc\\lb\\v1\\load_balancer.pb.c " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\xds\\xds.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\xds\\xds_channel_secure.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\xds\\xds_client_stats.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\xds\\xds_load_balancer_api.cc " + + "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto\\grpc\\lb\\v1\\google\\protobuf\\duration.pb.c " + + "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto\\grpc\\lb\\v1\\google\\protobuf\\timestamp.pb.c " + + "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto\\grpc\\lb\\v1\\load_balancer.pb.c " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\pick_first\\pick_first.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\round_robin\\round_robin.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\dns_resolver_ares.cc " + @@ -742,11 +750,15 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2\\transport"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\inproc"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\google"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\google\\protobuf"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\health"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\health\\v1"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\lb"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\lb\\v1"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\avl"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\backoff"); diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 7e728026e68..b1a169207ac 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -578,13 +578,21 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h', + 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h', + 'src/core/ext/upb-generated/google/protobuf/any.upb.h', + 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.h', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.h', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.h', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.h', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.h', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.h', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h', + 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h', + 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h', + 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 1e2be599afb..6a449efed19 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -533,13 +533,21 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h', + 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h', + 'src/core/ext/upb-generated/google/protobuf/any.upb.h', + 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.h', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.h', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.h', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.h', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.h', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.h', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h', + 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h', + 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h', + 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', @@ -861,14 +869,22 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', + 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c', + 'src/core/ext/upb-generated/google/protobuf/any.upb.c', + 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.c', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', 'src/core/ext/filters/client_channel/lb_policy/xds/xds.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc', + 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c', + 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c', + 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc', 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc', @@ -1198,13 +1214,21 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h', + 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h', + 'src/core/ext/upb-generated/google/protobuf/any.upb.h', + 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.h', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.h', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.h', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.h', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.h', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.h', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h', + 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h', + 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h', + 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', diff --git a/grpc.gemspec b/grpc.gemspec index 45f4a759473..12fddb3252e 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -467,13 +467,21 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h ) + s.files += %w( src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/any.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/descriptor.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/duration.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/empty.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/struct.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/timestamp.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/wrappers.upb.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h ) - s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h ) - s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h ) - s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h ) + s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h ) + s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h ) + s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/subchannel_list.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h ) @@ -798,14 +806,22 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc ) + s.files += %w( src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/any.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/descriptor.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/duration.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/empty.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/struct.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/timestamp.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/wrappers.upb.c ) s.files += %w( src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc ) - s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c ) - s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c ) - s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds.cc ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc ) + s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c ) + s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c ) + s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc ) diff --git a/grpc.gyp b/grpc.gyp index a5287a606ed..040831ec4f3 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -611,14 +611,22 @@ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', + 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c', + 'src/core/ext/upb-generated/google/protobuf/any.upb.c', + 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.c', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', 'src/core/ext/filters/client_channel/lb_policy/xds/xds.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc', + 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c', + 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c', + 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc', 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc', @@ -1416,16 +1424,24 @@ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', + 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c', + 'src/core/ext/upb-generated/google/protobuf/any.upb.c', + 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.c', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', + 'src/core/ext/filters/client_channel/lb_policy/xds/xds.cc', + 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc', + 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc', + 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', 'third_party/nanopb/pb_common.c', 'third_party/nanopb/pb_decode.c', 'third_party/nanopb/pb_encode.c', - 'src/core/ext/filters/client_channel/lb_policy/xds/xds.cc', - 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc', - 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc', - 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc', 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc', 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc', 'src/core/ext/filters/census/grpc_context.cc', diff --git a/package.xml b/package.xml index fc68a9cdf12..5b85159a4f5 100644 --- a/package.xml +++ b/package.xml @@ -472,13 +472,21 @@ + + + + + + + + - - - + + + @@ -803,14 +811,22 @@ + + + + + + + + - - - + + + diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index bc4b63b74ec..6a565e057b9 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -409,18 +409,18 @@ void ParseServer(const grpc_grpclb_server* server, const uint16_t netorder_port = grpc_htons((uint16_t)server->port); /* the addresses are given in binary format (a in(6)_addr struct) in * server->ip_address.bytes. */ - const grpc_grpclb_ip_address* ip = &server->ip_address; - if (ip->size == 4) { + const grpc_grpclb_server_ip_address& ip = server->ip_address; + if (ip.size == 4) { addr->len = static_cast(sizeof(grpc_sockaddr_in)); grpc_sockaddr_in* addr4 = reinterpret_cast(&addr->addr); addr4->sin_family = GRPC_AF_INET; - memcpy(&addr4->sin_addr, ip->bytes, ip->size); + memcpy(&addr4->sin_addr, ip.data, ip.size); addr4->sin_port = netorder_port; - } else if (ip->size == 16) { + } else if (ip.size == 16) { addr->len = static_cast(sizeof(grpc_sockaddr_in6)); grpc_sockaddr_in6* addr6 = (grpc_sockaddr_in6*)&addr->addr; addr6->sin6_family = GRPC_AF_INET6; - memcpy(&addr6->sin6_addr, ip->bytes, ip->size); + memcpy(&addr6->sin6_addr, ip.data, ip.size); addr6->sin6_port = netorder_port; } } @@ -490,7 +490,7 @@ const grpc_arg_pointer_vtable client_stats_arg_vtable = { bool IsServerValid(const grpc_grpclb_server* server, size_t idx, bool log) { if (server->drop) return false; - const grpc_grpclb_ip_address* ip = &server->ip_address; + const grpc_grpclb_server_ip_address& ip = server->ip_address; if (GPR_UNLIKELY(server->port >> 16 != 0)) { if (log) { gpr_log(GPR_ERROR, @@ -499,12 +499,12 @@ bool IsServerValid(const grpc_grpclb_server* server, size_t idx, bool log) { } return false; } - if (GPR_UNLIKELY(ip->size != 4 && ip->size != 16)) { + if (GPR_UNLIKELY(ip.size != 4 && ip.size != 16)) { if (log) { gpr_log(GPR_ERROR, "Expected IP to be 4 or 16 bytes, got %d at index %lu of " "serverlist. Ignoring", - ip->size, (unsigned long)idx); + ip.size, (unsigned long)idx); } return false; } @@ -523,7 +523,7 @@ ServerAddressList GrpcLb::Serverlist::GetServerAddressList( ParseServer(server, &addr); // LB token processing. char lb_token[GPR_ARRAY_SIZE(server->load_balance_token) + 1]; - if (server->has_load_balance_token) { + if (server->load_balance_token[0] != 0) { const size_t lb_token_max_length = GPR_ARRAY_SIZE(server->load_balance_token); const size_t lb_token_length = @@ -790,13 +790,14 @@ GrpcLb::BalancerCallState::BalancerCallState( GRPC_MDSTR_SLASH_GRPC_DOT_LB_DOT_V1_DOT_LOADBALANCER_SLASH_BALANCELOAD, nullptr, deadline, nullptr); // Init the LB call request payload. + upb::Arena arena; grpc_grpclb_request* request = - grpc_grpclb_request_create(grpclb_policy()->server_name_); - grpc_slice request_payload_slice = grpc_grpclb_request_encode(request); + grpc_grpclb_request_create(grpclb_policy()->server_name_, arena.ptr()); + grpc_slice request_payload_slice = + grpc_grpclb_request_encode(request, arena.ptr()); send_message_payload_ = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_slice_unref_internal(request_payload_slice); - grpc_grpclb_request_destroy(request); // Init other data associated with the LB call. grpc_metadata_array_init(&lb_initial_metadata_recv_); grpc_metadata_array_init(&lb_trailing_metadata_recv_); @@ -940,27 +941,32 @@ void GrpcLb::BalancerCallState::MaybeSendClientLoadReportLocked( bool GrpcLb::BalancerCallState::LoadReportCountersAreZero( grpc_grpclb_request* request) { - GrpcLbClientStats::DroppedCallCounts* drop_entries = - static_cast( - request->client_stats.calls_finished_with_drop.arg); - return request->client_stats.num_calls_started == 0 && - request->client_stats.num_calls_finished == 0 && - request->client_stats.num_calls_finished_with_client_failed_to_send == + const grpc_lb_v1_ClientStats* cstats = + grpc_lb_v1_LoadBalanceRequest_client_stats(request); + if (cstats == nullptr) { + return true; + } + size_t drop_count; + grpc_lb_v1_ClientStats_calls_finished_with_drop(cstats, &drop_count); + return grpc_lb_v1_ClientStats_num_calls_started(cstats) == 0 && + grpc_lb_v1_ClientStats_num_calls_finished(cstats) == 0 && + grpc_lb_v1_ClientStats_num_calls_finished_with_client_failed_to_send( + cstats) == 0 && + grpc_lb_v1_ClientStats_num_calls_finished_known_received(cstats) == 0 && - request->client_stats.num_calls_finished_known_received == 0 && - (drop_entries == nullptr || drop_entries->size() == 0); + drop_count == 0; } void GrpcLb::BalancerCallState::SendClientLoadReportLocked() { // Construct message payload. GPR_ASSERT(send_message_payload_ == nullptr); + upb::Arena arena; grpc_grpclb_request* request = - grpc_grpclb_load_report_request_create(client_stats_.get()); + grpc_grpclb_load_report_request_create(client_stats_.get(), arena.ptr()); // Skip client load report if the counters were all zero in the last // report and they are still zero in this one. if (LoadReportCountersAreZero(request)) { if (last_client_load_report_counters_were_zero_) { - grpc_grpclb_request_destroy(request); ScheduleNextClientLoadReportLocked(); return; } @@ -968,11 +974,11 @@ void GrpcLb::BalancerCallState::SendClientLoadReportLocked() { } else { last_client_load_report_counters_were_zero_ = false; } - grpc_slice request_payload_slice = grpc_grpclb_request_encode(request); + grpc_slice request_payload_slice = + grpc_grpclb_request_encode(request, arena.ptr()); send_message_payload_ = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_slice_unref_internal(request_payload_slice); - grpc_grpclb_request_destroy(request); // Send the report. grpc_op op; memset(&op, 0, sizeof(op)); @@ -1034,16 +1040,20 @@ void GrpcLb::BalancerCallState::OnBalancerMessageReceivedLocked( grpc_byte_buffer_reader_destroy(&bbr); grpc_byte_buffer_destroy(lb_calld->recv_message_payload_); lb_calld->recv_message_payload_ = nullptr; - grpc_grpclb_initial_response* initial_response; + const grpc_grpclb_initial_response* initial_response; grpc_grpclb_serverlist* serverlist; + upb::Arena arena; if (!lb_calld->seen_initial_response_ && - (initial_response = grpc_grpclb_initial_response_parse(response_slice)) != - nullptr) { + (initial_response = grpc_grpclb_initial_response_parse( + response_slice, arena.ptr())) != nullptr) { // Have NOT seen initial response, look for initial response. - if (initial_response->has_client_stats_report_interval) { - lb_calld->client_stats_report_interval_ = GPR_MAX( - GPR_MS_PER_SEC, grpc_grpclb_duration_to_millis( - &initial_response->client_stats_report_interval)); + const google_protobuf_Duration* client_stats_report_interval = + grpc_lb_v1_InitialLoadBalanceResponse_client_stats_report_interval( + initial_response); + if (client_stats_report_interval != nullptr) { + lb_calld->client_stats_report_interval_ = + GPR_MAX(GPR_MS_PER_SEC, + grpc_grpclb_duration_to_millis(client_stats_report_interval)); if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) { gpr_log(GPR_INFO, "[grpclb %p] lb_calld=%p: Received initial LB response " @@ -1058,7 +1068,6 @@ void GrpcLb::BalancerCallState::OnBalancerMessageReceivedLocked( "client load reporting NOT enabled", grpclb_policy, lb_calld); } - grpc_grpclb_initial_response_destroy(initial_response); lb_calld->seen_initial_response_ = true; } else if ((serverlist = grpc_grpclb_response_parse_serverlist( response_slice)) != nullptr) { diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc index 22cefc937b0..68097e14a4e 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc @@ -18,213 +18,154 @@ #include -#include "pb_decode.h" -#include "pb_encode.h" #include "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h" +#include "src/core/lib/gpr/useful.h" + +#include "google/protobuf/duration.upb.h" +#include "google/protobuf/timestamp.upb.h" #include -/* invoked once for every Server in ServerList */ -static bool count_serverlist(pb_istream_t* stream, const pb_field_t* field, - void** arg) { - grpc_grpclb_serverlist* sl = static_cast(*arg); - grpc_grpclb_server server; - if (GPR_UNLIKELY(!pb_decode(stream, grpc_lb_v1_Server_fields, &server))) { - gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(stream)); - return false; - } - ++sl->num_servers; - return true; -} +namespace grpc_core { -typedef struct decode_serverlist_arg { - /* The decoding callback is invoked once per server in serverlist. Remember - * which index of the serverlist are we currently decoding */ - size_t decoding_idx; - /* The decoded serverlist */ - grpc_grpclb_serverlist* serverlist; -} decode_serverlist_arg; - -/* invoked once for every Server in ServerList */ -static bool decode_serverlist(pb_istream_t* stream, const pb_field_t* field, - void** arg) { - decode_serverlist_arg* dec_arg = static_cast(*arg); - GPR_ASSERT(dec_arg->serverlist->num_servers >= dec_arg->decoding_idx); - grpc_grpclb_server* server = - static_cast(gpr_zalloc(sizeof(grpc_grpclb_server))); - if (GPR_UNLIKELY(!pb_decode(stream, grpc_lb_v1_Server_fields, server))) { - gpr_free(server); - gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(stream)); - return false; - } - dec_arg->serverlist->servers[dec_arg->decoding_idx++] = server; - return true; -} - -grpc_grpclb_request* grpc_grpclb_request_create(const char* lb_service_name) { - grpc_grpclb_request* req = static_cast( - gpr_malloc(sizeof(grpc_grpclb_request))); - req->has_client_stats = false; - req->has_initial_request = true; - req->initial_request.has_name = true; - // GCC warns (-Wstringop-truncation) because the destination - // buffer size is identical to max-size, leading to a potential - // char[] with no null terminator. nanopb can handle it fine, - // and parantheses around strncpy silence that compiler warning. - (strncpy(req->initial_request.name, lb_service_name, - GRPC_GRPCLB_SERVICE_NAME_MAX_LENGTH)); +grpc_grpclb_request* grpc_grpclb_request_create(const char* lb_service_name, + upb_arena* arena) { + grpc_grpclb_request* req = grpc_lb_v1_LoadBalanceRequest_new(arena); + grpc_lb_v1_InitialLoadBalanceRequest* initial_request = + grpc_lb_v1_LoadBalanceRequest_mutable_initial_request(req, arena); + size_t name_len = + GPR_MIN(strlen(lb_service_name), GRPC_GRPCLB_SERVICE_NAME_MAX_LENGTH); + grpc_lb_v1_InitialLoadBalanceRequest_set_name( + initial_request, upb_strview_make(lb_service_name, name_len)); return req; } -static void populate_timestamp(gpr_timespec timestamp, - grpc_grpclb_timestamp* timestamp_pb) { - timestamp_pb->has_seconds = true; - timestamp_pb->seconds = timestamp.tv_sec; - timestamp_pb->has_nanos = true; - timestamp_pb->nanos = timestamp.tv_nsec; +namespace { + +void google_protobuf_Timestamp_assign(google_protobuf_Timestamp* timestamp, + const gpr_timespec& value) { + google_protobuf_Timestamp_set_seconds(timestamp, value.tv_sec); + google_protobuf_Timestamp_set_nanos(timestamp, value.tv_nsec); } -static bool encode_string(pb_ostream_t* stream, const pb_field_t* field, - void* const* arg) { - char* str = static_cast(*arg); - if (!pb_encode_tag_for_field(stream, field)) return false; - return pb_encode_string(stream, reinterpret_cast(str), strlen(str)); -} - -static bool encode_drops(pb_ostream_t* stream, const pb_field_t* field, - void* const* arg) { - grpc_core::GrpcLbClientStats::DroppedCallCounts* drop_entries = - static_cast(*arg); - if (drop_entries == nullptr) return true; - for (size_t i = 0; i < drop_entries->size(); ++i) { - if (!pb_encode_tag_for_field(stream, field)) return false; - grpc_lb_v1_ClientStatsPerToken drop_message; - drop_message.load_balance_token.funcs.encode = encode_string; - drop_message.load_balance_token.arg = (*drop_entries)[i].token.get(); - drop_message.has_num_calls = true; - drop_message.num_calls = (*drop_entries)[i].count; - if (!pb_encode_submessage(stream, grpc_lb_v1_ClientStatsPerToken_fields, - &drop_message)) { - return false; - } - } - return true; -} +} // namespace grpc_grpclb_request* grpc_grpclb_load_report_request_create( - grpc_core::GrpcLbClientStats* client_stats) { - grpc_grpclb_request* req = static_cast( - gpr_zalloc(sizeof(grpc_grpclb_request))); - req->has_client_stats = true; - req->client_stats.has_timestamp = true; - populate_timestamp(gpr_now(GPR_CLOCK_REALTIME), &req->client_stats.timestamp); - req->client_stats.has_num_calls_started = true; - req->client_stats.has_num_calls_finished = true; - req->client_stats.has_num_calls_finished_with_client_failed_to_send = true; - req->client_stats.has_num_calls_finished_with_client_failed_to_send = true; - req->client_stats.has_num_calls_finished_known_received = true; - req->client_stats.calls_finished_with_drop.funcs.encode = encode_drops; - grpc_core::UniquePtr - drop_counts; - client_stats->Get( - &req->client_stats.num_calls_started, - &req->client_stats.num_calls_finished, - &req->client_stats.num_calls_finished_with_client_failed_to_send, - &req->client_stats.num_calls_finished_known_received, &drop_counts); - // Will be deleted in grpc_grpclb_request_destroy(). - req->client_stats.calls_finished_with_drop.arg = drop_counts.release(); + GrpcLbClientStats* client_stats, upb_arena* arena) { + grpc_grpclb_request* req = grpc_lb_v1_LoadBalanceRequest_new(arena); + grpc_lb_v1_ClientStats* req_stats = + grpc_lb_v1_LoadBalanceRequest_mutable_client_stats(req, arena); + google_protobuf_Timestamp_assign( + grpc_lb_v1_ClientStats_mutable_timestamp(req_stats, arena), + gpr_now(GPR_CLOCK_REALTIME)); + + int64_t num_calls_started; + int64_t num_calls_finished; + int64_t num_calls_finished_with_client_failed_to_send; + int64_t num_calls_finished_known_received; + UniquePtr drop_token_counts; + client_stats->Get(&num_calls_started, &num_calls_finished, + &num_calls_finished_with_client_failed_to_send, + &num_calls_finished_known_received, &drop_token_counts); + grpc_lb_v1_ClientStats_set_num_calls_started(req_stats, num_calls_started); + grpc_lb_v1_ClientStats_set_num_calls_finished(req_stats, num_calls_finished); + grpc_lb_v1_ClientStats_set_num_calls_finished_with_client_failed_to_send( + req_stats, num_calls_finished_with_client_failed_to_send); + grpc_lb_v1_ClientStats_set_num_calls_finished_known_received( + req_stats, num_calls_finished_known_received); + if (drop_token_counts != nullptr) { + for (size_t i = 0; i < drop_token_counts->size(); ++i) { + GrpcLbClientStats::DropTokenCount& cur = (*drop_token_counts)[i]; + grpc_lb_v1_ClientStatsPerToken* cur_msg = + grpc_lb_v1_ClientStats_add_calls_finished_with_drop(req_stats, arena); + + const size_t token_len = strlen(cur.token.get()); + char* token = reinterpret_cast(upb_arena_malloc(arena, token_len)); + memcpy(token, cur.token.get(), token_len); + + grpc_lb_v1_ClientStatsPerToken_set_load_balance_token( + cur_msg, upb_strview_make(token, token_len)); + grpc_lb_v1_ClientStatsPerToken_set_num_calls(cur_msg, cur.count); + } + } return req; } -grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request* request) { - size_t encoded_length; - pb_ostream_t sizestream; - pb_ostream_t outputstream; - grpc_slice slice; - memset(&sizestream, 0, sizeof(pb_ostream_t)); - pb_encode(&sizestream, grpc_lb_v1_LoadBalanceRequest_fields, request); - encoded_length = sizestream.bytes_written; - - slice = GRPC_SLICE_MALLOC(encoded_length); - outputstream = - pb_ostream_from_buffer(GRPC_SLICE_START_PTR(slice), encoded_length); - GPR_ASSERT(pb_encode(&outputstream, grpc_lb_v1_LoadBalanceRequest_fields, - request) != 0); - return slice; +grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request* request, + upb_arena* arena) { + size_t buf_length; + char* buf = + grpc_lb_v1_LoadBalanceRequest_serialize(request, arena, &buf_length); + return grpc_slice_from_copied_buffer(buf, buf_length); } -void grpc_grpclb_request_destroy(grpc_grpclb_request* request) { - if (request->has_client_stats) { - grpc_core::GrpcLbClientStats::DroppedCallCounts* drop_entries = - static_cast( - request->client_stats.calls_finished_with_drop.arg); - grpc_core::Delete(drop_entries); - } - gpr_free(request); -} - -typedef grpc_lb_v1_LoadBalanceResponse grpc_grpclb_response; -grpc_grpclb_initial_response* grpc_grpclb_initial_response_parse( - const grpc_slice& encoded_grpc_grpclb_response) { - pb_istream_t stream = pb_istream_from_buffer( - const_cast(GRPC_SLICE_START_PTR(encoded_grpc_grpclb_response)), - GRPC_SLICE_LENGTH(encoded_grpc_grpclb_response)); - grpc_grpclb_response res; - memset(&res, 0, sizeof(grpc_grpclb_response)); - if (GPR_UNLIKELY( - !pb_decode(&stream, grpc_lb_v1_LoadBalanceResponse_fields, &res))) { - gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&stream)); +const grpc_grpclb_initial_response* grpc_grpclb_initial_response_parse( + const grpc_slice& encoded_grpc_grpclb_response, upb_arena* arena) { + grpc_lb_v1_LoadBalanceResponse* response = + grpc_lb_v1_LoadBalanceResponse_parse( + reinterpret_cast( + GRPC_SLICE_START_PTR(encoded_grpc_grpclb_response)), + GRPC_SLICE_LENGTH(encoded_grpc_grpclb_response), arena); + if (response == nullptr) { + gpr_log(GPR_ERROR, "grpc_lb_v1_LoadBalanceResponse parse error"); return nullptr; } - - if (!res.has_initial_response) return nullptr; - - grpc_grpclb_initial_response* initial_res = - static_cast( - gpr_malloc(sizeof(grpc_grpclb_initial_response))); - memcpy(initial_res, &res.initial_response, - sizeof(grpc_grpclb_initial_response)); - - return initial_res; + return grpc_lb_v1_LoadBalanceResponse_initial_response(response); } grpc_grpclb_serverlist* grpc_grpclb_response_parse_serverlist( const grpc_slice& encoded_grpc_grpclb_response) { - pb_istream_t stream = pb_istream_from_buffer( - const_cast(GRPC_SLICE_START_PTR(encoded_grpc_grpclb_response)), - GRPC_SLICE_LENGTH(encoded_grpc_grpclb_response)); - pb_istream_t stream_at_start = stream; - grpc_grpclb_serverlist* sl = static_cast( - gpr_zalloc(sizeof(grpc_grpclb_serverlist))); - grpc_grpclb_response res; - memset(&res, 0, sizeof(grpc_grpclb_response)); - // First pass: count number of servers. - res.server_list.servers.funcs.decode = count_serverlist; - res.server_list.servers.arg = sl; - bool status = pb_decode(&stream, grpc_lb_v1_LoadBalanceResponse_fields, &res); - if (GPR_UNLIKELY(!status)) { - gpr_free(sl); - gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&stream)); + upb::Arena arena; + grpc_lb_v1_LoadBalanceResponse* response = + grpc_lb_v1_LoadBalanceResponse_parse( + reinterpret_cast( + GRPC_SLICE_START_PTR(encoded_grpc_grpclb_response)), + GRPC_SLICE_LENGTH(encoded_grpc_grpclb_response), arena.ptr()); + if (response == nullptr) { + gpr_log(GPR_ERROR, "grpc_lb_v1_LoadBalanceResponse parse error"); return nullptr; } + grpc_grpclb_serverlist* server_list = static_cast( + gpr_zalloc(sizeof(grpc_grpclb_serverlist))); + // First pass: count number of servers. + const grpc_lb_v1_ServerList* server_list_msg = + grpc_lb_v1_LoadBalanceResponse_server_list(response); + size_t server_count = 0; + const grpc_lb_v1_Server* const* servers = nullptr; + if (server_list_msg != nullptr) { + servers = grpc_lb_v1_ServerList_servers(server_list_msg, &server_count); + } // Second pass: populate servers. - if (sl->num_servers > 0) { - sl->servers = static_cast( - gpr_zalloc(sizeof(grpc_grpclb_server*) * sl->num_servers)); - decode_serverlist_arg decode_arg; - memset(&decode_arg, 0, sizeof(decode_arg)); - decode_arg.serverlist = sl; - res.server_list.servers.funcs.decode = decode_serverlist; - res.server_list.servers.arg = &decode_arg; - status = pb_decode(&stream_at_start, grpc_lb_v1_LoadBalanceResponse_fields, - &res); - if (GPR_UNLIKELY(!status)) { - grpc_grpclb_destroy_serverlist(sl); - gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&stream)); - return nullptr; + if (server_count > 0) { + server_list->servers = static_cast( + gpr_zalloc(sizeof(grpc_grpclb_server*) * server_count)); + server_list->num_servers = server_count; + for (size_t i = 0; i < server_count; ++i) { + grpc_grpclb_server* cur = server_list->servers[i] = + static_cast( + gpr_zalloc(sizeof(grpc_grpclb_server))); + upb_strview address = grpc_lb_v1_Server_ip_address(servers[i]); + if (address.size == 0) { + ; // Nothing to do because cur->ip_address is an empty string. + } else if (address.size <= GRPC_GRPCLB_SERVER_IP_ADDRESS_MAX_SIZE) { + cur->ip_address.size = static_cast(address.size); + memcpy(cur->ip_address.data, address.data, address.size); + } + cur->port = grpc_lb_v1_Server_port(servers[i]); + upb_strview token = grpc_lb_v1_Server_load_balance_token(servers[i]); + if (token.size == 0) { + ; // Nothing to do because cur->load_balance_token is an empty string. + } else if (token.size <= GRPC_GRPCLB_SERVER_LOAD_BALANCE_TOKEN_MAX_SIZE) { + memcpy(cur->load_balance_token, token.data, token.size); + } else { + gpr_log(GPR_ERROR, + "grpc_lb_v1_LoadBalanceResponse has too long token. len=%zu", + token.size); + } + cur->drop = grpc_lb_v1_Server_drop(servers[i]); } } - return sl; + return server_list; } void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist* serverlist) { @@ -239,16 +180,17 @@ void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist* serverlist) { } grpc_grpclb_serverlist* grpc_grpclb_serverlist_copy( - const grpc_grpclb_serverlist* sl) { + const grpc_grpclb_serverlist* server_list) { grpc_grpclb_serverlist* copy = static_cast( gpr_zalloc(sizeof(grpc_grpclb_serverlist))); - copy->num_servers = sl->num_servers; + copy->num_servers = server_list->num_servers; copy->servers = static_cast( - gpr_malloc(sizeof(grpc_grpclb_server*) * sl->num_servers)); - for (size_t i = 0; i < sl->num_servers; i++) { + gpr_malloc(sizeof(grpc_grpclb_server*) * server_list->num_servers)); + for (size_t i = 0; i < server_list->num_servers; i++) { copy->servers[i] = static_cast( gpr_malloc(sizeof(grpc_grpclb_server))); - memcpy(copy->servers[i], sl->servers[i], sizeof(grpc_grpclb_server)); + memcpy(copy->servers[i], server_list->servers[i], + sizeof(grpc_grpclb_server)); } return copy; } @@ -274,38 +216,11 @@ bool grpc_grpclb_server_equals(const grpc_grpclb_server* lhs, return memcmp(lhs, rhs, sizeof(grpc_grpclb_server)) == 0; } -int grpc_grpclb_duration_compare(const grpc_grpclb_duration* lhs, - const grpc_grpclb_duration* rhs) { - GPR_ASSERT(lhs && rhs); - if (lhs->has_seconds && rhs->has_seconds) { - if (lhs->seconds < rhs->seconds) return -1; - if (lhs->seconds > rhs->seconds) return 1; - } else if (lhs->has_seconds) { - return 1; - } else if (rhs->has_seconds) { - return -1; - } - - GPR_ASSERT(lhs->seconds == rhs->seconds); - if (lhs->has_nanos && rhs->has_nanos) { - if (lhs->nanos < rhs->nanos) return -1; - if (lhs->nanos > rhs->nanos) return 1; - } else if (lhs->has_nanos) { - return 1; - } else if (rhs->has_nanos) { - return -1; - } - - return 0; -} - -grpc_millis grpc_grpclb_duration_to_millis(grpc_grpclb_duration* duration_pb) { +grpc_millis grpc_grpclb_duration_to_millis( + const grpc_grpclb_duration* duration_pb) { return static_cast( - (duration_pb->has_seconds ? duration_pb->seconds : 0) * GPR_MS_PER_SEC + - (duration_pb->has_nanos ? duration_pb->nanos : 0) / GPR_NS_PER_MS); + google_protobuf_Duration_seconds(duration_pb) * GPR_MS_PER_SEC + + google_protobuf_Duration_nanos(duration_pb) / GPR_NS_PER_MS); } -void grpc_grpclb_initial_response_destroy( - grpc_grpclb_initial_response* response) { - gpr_free(response); -} +} // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h index 8005f6fe301..3062e9526ae 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h @@ -24,38 +24,57 @@ #include #include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h" -#include "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h" #include "src/core/lib/iomgr/exec_ctx.h" +#include "src/proto/grpc/lb/v1/load_balancer.upb.h" #define GRPC_GRPCLB_SERVICE_NAME_MAX_LENGTH 128 +#define GRPC_GRPCLB_SERVER_IP_ADDRESS_MAX_SIZE 16 +#define GRPC_GRPCLB_SERVER_LOAD_BALANCE_TOKEN_MAX_SIZE 50 + +namespace grpc_core { -typedef grpc_lb_v1_Server_ip_address_t grpc_grpclb_ip_address; typedef grpc_lb_v1_LoadBalanceRequest grpc_grpclb_request; +typedef grpc_lb_v1_LoadBalanceResponse grpc_grpclb_response; typedef grpc_lb_v1_InitialLoadBalanceResponse grpc_grpclb_initial_response; -typedef grpc_lb_v1_Server grpc_grpclb_server; typedef google_protobuf_Duration grpc_grpclb_duration; typedef google_protobuf_Timestamp grpc_grpclb_timestamp; +typedef struct { + int32_t size; + char data[GRPC_GRPCLB_SERVER_IP_ADDRESS_MAX_SIZE]; +} grpc_grpclb_server_ip_address; + +// Contains server information. When the drop field is not true, use the other +// fields. +typedef struct { + grpc_grpclb_server_ip_address ip_address; + int32_t port; + char load_balance_token[GRPC_GRPCLB_SERVER_LOAD_BALANCE_TOKEN_MAX_SIZE]; + bool drop; +} grpc_grpclb_server; + typedef struct { grpc_grpclb_server** servers; size_t num_servers; } grpc_grpclb_serverlist; -/** Create a request for a gRPC LB service under \a lb_service_name */ -grpc_grpclb_request* grpc_grpclb_request_create(const char* lb_service_name); +/** + * Create a request for a gRPC LB service under \a lb_service_name. + * \a lb_service_name should be alive when returned request is being used. + */ +grpc_grpclb_request* grpc_grpclb_request_create(const char* lb_service_name, + upb_arena* arena); grpc_grpclb_request* grpc_grpclb_load_report_request_create( - grpc_core::GrpcLbClientStats* client_stats); + grpc_core::GrpcLbClientStats* client_stats, upb_arena* arena); /** Protocol Buffers v3-encode \a request */ -grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request* request); - -/** Destroy \a request */ -void grpc_grpclb_request_destroy(grpc_grpclb_request* request); +grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request* request, + upb_arena* arena); /** Parse (ie, decode) the bytes in \a encoded_grpc_grpclb_response as a \a * grpc_grpclb_initial_response */ -grpc_grpclb_initial_response* grpc_grpclb_initial_response_parse( - const grpc_slice& encoded_grpc_grpclb_response); +const grpc_grpclb_initial_response* grpc_grpclb_initial_response_parse( + const grpc_slice& encoded_grpc_grpclb_response, upb_arena* arena); /** Parse the list of servers from an encoded \a grpc_grpclb_response */ grpc_grpclb_serverlist* grpc_grpclb_response_parse_serverlist( @@ -75,16 +94,10 @@ bool grpc_grpclb_server_equals(const grpc_grpclb_server* lhs, /** Destroy \a serverlist */ void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist* serverlist); -/** Compare \a lhs against \a rhs and return 0 if \a lhs and \a rhs are equal, - * < 0 if \a lhs represents a duration shorter than \a rhs and > 0 otherwise */ -int grpc_grpclb_duration_compare(const grpc_grpclb_duration* lhs, - const grpc_grpclb_duration* rhs); +grpc_millis grpc_grpclb_duration_to_millis( + const grpc_grpclb_duration* duration_pb); -grpc_millis grpc_grpclb_duration_to_millis(grpc_grpclb_duration* duration_pb); - -/** Destroy \a initial_response */ -void grpc_grpclb_initial_response_destroy( - grpc_grpclb_initial_response* response); +} // namespace grpc_core #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_LOAD_BALANCER_API_H \ */ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index ec5b79d965b..8138b2a6264 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -373,14 +373,22 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', + 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c', + 'src/core/ext/upb-generated/google/protobuf/any.upb.c', + 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.c', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', 'src/core/ext/filters/client_channel/lb_policy/xds/xds.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc', + 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c', + 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c', + 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc', 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc', diff --git a/test/core/nanopb/fuzzer_response.cc b/test/core/nanopb/fuzzer_response.cc index 3a70dea5e98..1f35eac8f64 100644 --- a/test/core/nanopb/fuzzer_response.cc +++ b/test/core/nanopb/fuzzer_response.cc @@ -33,10 +33,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_init(); if (squelch) gpr_set_log_function(dont_log); grpc_slice slice = grpc_slice_from_copied_buffer((const char*)data, size); - grpc_grpclb_initial_response* response; - if ((response = grpc_grpclb_initial_response_parse(slice))) { - grpc_grpclb_initial_response_destroy(response); - } + upb::Arena arena; + grpc_core::grpc_grpclb_initial_response_parse(slice, arena.ptr()); grpc_slice_unref(slice); grpc_shutdown(); return 0; diff --git a/test/core/nanopb/fuzzer_serverlist.cc b/test/core/nanopb/fuzzer_serverlist.cc index d0af117ef96..079fbd34be1 100644 --- a/test/core/nanopb/fuzzer_serverlist.cc +++ b/test/core/nanopb/fuzzer_serverlist.cc @@ -33,8 +33,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_init(); if (squelch) gpr_set_log_function(dont_log); grpc_slice slice = grpc_slice_from_copied_buffer((const char*)data, size); - grpc_grpclb_serverlist* serverlist; - if ((serverlist = grpc_grpclb_response_parse_serverlist(slice))) { + grpc_core::grpc_grpclb_serverlist* serverlist; + if ((serverlist = grpc_core::grpc_grpclb_response_parse_serverlist(slice))) { grpc_grpclb_destroy_serverlist(serverlist); } grpc_slice_unref(slice); diff --git a/test/cpp/grpclb/grpclb_api_test.cc b/test/cpp/grpclb/grpclb_api_test.cc index 0ace512c278..62e7c06bbb8 100644 --- a/test/cpp/grpclb/grpclb_api_test.cc +++ b/test/cpp/grpclb/grpclb_api_test.cc @@ -20,6 +20,7 @@ #include #include +#include "google/protobuf/duration.upb.h" #include "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/sockaddr_utils.h" @@ -44,7 +45,8 @@ grpc::string Ip4ToPackedString(const char* ip_str) { return grpc::string(reinterpret_cast(&ip4), sizeof(ip4)); } -grpc::string PackedStringToIp(const grpc_grpclb_ip_address& pb_ip) { +grpc::string PackedStringToIp( + const grpc_core::grpc_grpclb_server_ip_address& pb_ip) { char ip_str[46] = {0}; int af = -1; if (pb_ip.size == 4) { @@ -54,21 +56,22 @@ grpc::string PackedStringToIp(const grpc_grpclb_ip_address& pb_ip) { } else { abort(); } - GPR_ASSERT(inet_ntop(af, (void*)pb_ip.bytes, ip_str, 46) != nullptr); + GPR_ASSERT(inet_ntop(af, (void*)pb_ip.data, ip_str, 46) != nullptr); return ip_str; } TEST_F(GrpclbTest, CreateRequest) { const grpc::string service_name = "AServiceName"; LoadBalanceRequest request; - grpc_grpclb_request* c_req = grpc_grpclb_request_create(service_name.c_str()); - grpc_slice slice = grpc_grpclb_request_encode(c_req); + upb::Arena arena; + grpc_core::grpc_grpclb_request* c_req = + grpc_core::grpc_grpclb_request_create(service_name.c_str(), arena.ptr()); + grpc_slice slice = grpc_core::grpc_grpclb_request_encode(c_req, arena.ptr()); const int num_bytes_written = GRPC_SLICE_LENGTH(slice); EXPECT_GT(num_bytes_written, 0); request.ParseFromArray(GRPC_SLICE_START_PTR(slice), num_bytes_written); EXPECT_EQ(request.initial_request().name(), service_name); grpc_slice_unref(slice); - grpc_grpclb_request_destroy(c_req); } TEST_F(GrpclbTest, ParseInitialResponse) { @@ -82,13 +85,21 @@ TEST_F(GrpclbTest, ParseInitialResponse) { grpc_slice encoded_slice = grpc_slice_from_copied_string(encoded_response.c_str()); - grpc_grpclb_initial_response* c_initial_response = - grpc_grpclb_initial_response_parse(encoded_slice); - EXPECT_FALSE(c_initial_response->has_load_balancer_delegate); - EXPECT_EQ(c_initial_response->client_stats_report_interval.seconds, 123); - EXPECT_EQ(c_initial_response->client_stats_report_interval.nanos, 456); + upb::Arena arena; + const grpc_core::grpc_grpclb_initial_response* c_initial_response = + grpc_core::grpc_grpclb_initial_response_parse(encoded_slice, arena.ptr()); + + upb_strview load_balancer_delegate = + grpc_lb_v1_InitialLoadBalanceResponse_load_balancer_delegate( + c_initial_response); + EXPECT_EQ(load_balancer_delegate.size, 0); + + const google_protobuf_Duration* report_interval = + grpc_lb_v1_InitialLoadBalanceResponse_client_stats_report_interval( + c_initial_response); + EXPECT_EQ(google_protobuf_Duration_seconds(report_interval), 123); + EXPECT_EQ(google_protobuf_Duration_nanos(report_interval), 456); grpc_slice_unref(encoded_slice); - grpc_grpclb_initial_response_destroy(c_initial_response); } TEST_F(GrpclbTest, ParseResponseServerList) { @@ -108,16 +119,14 @@ TEST_F(GrpclbTest, ParseResponseServerList) { const grpc::string encoded_response = response.SerializeAsString(); const grpc_slice encoded_slice = grpc_slice_from_copied_buffer( encoded_response.data(), encoded_response.size()); - grpc_grpclb_serverlist* c_serverlist = - grpc_grpclb_response_parse_serverlist(encoded_slice); + grpc_core::grpc_grpclb_serverlist* c_serverlist = + grpc_core::grpc_grpclb_response_parse_serverlist(encoded_slice); ASSERT_EQ(c_serverlist->num_servers, 2ul); - EXPECT_TRUE(c_serverlist->servers[0]->has_ip_address); EXPECT_EQ(PackedStringToIp(c_serverlist->servers[0]->ip_address), "127.0.0.1"); EXPECT_EQ(c_serverlist->servers[0]->port, 12345); EXPECT_STREQ(c_serverlist->servers[0]->load_balance_token, "rate_limting"); EXPECT_TRUE(c_serverlist->servers[0]->drop); - EXPECT_TRUE(c_serverlist->servers[1]->has_ip_address); EXPECT_EQ(PackedStringToIp(c_serverlist->servers[1]->ip_address), "10.0.0.1"); EXPECT_EQ(c_serverlist->servers[1]->port, 54321); diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 58d719c438e..e15778c276b 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1064,8 +1064,24 @@ src/core/ext/transport/chttp2/transport/writing.cc \ src/core/ext/transport/inproc/inproc_plugin.cc \ src/core/ext/transport/inproc/inproc_transport.cc \ src/core/ext/transport/inproc/inproc_transport.h \ +src/core/ext/upb-generated/google/protobuf/any.upb.c \ +src/core/ext/upb-generated/google/protobuf/any.upb.h \ +src/core/ext/upb-generated/google/protobuf/descriptor.upb.c \ +src/core/ext/upb-generated/google/protobuf/descriptor.upb.h \ +src/core/ext/upb-generated/google/protobuf/duration.upb.c \ +src/core/ext/upb-generated/google/protobuf/duration.upb.h \ +src/core/ext/upb-generated/google/protobuf/empty.upb.c \ +src/core/ext/upb-generated/google/protobuf/empty.upb.h \ +src/core/ext/upb-generated/google/protobuf/struct.upb.c \ +src/core/ext/upb-generated/google/protobuf/struct.upb.h \ +src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ +src/core/ext/upb-generated/google/protobuf/timestamp.upb.h \ +src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ +src/core/ext/upb-generated/google/protobuf/wrappers.upb.h \ src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h \ +src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ +src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h \ src/core/lib/README.md \ src/core/lib/avl/avl.cc \ src/core/lib/avl/avl.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 3278e997e6b..eea82fd730c 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -9294,9 +9294,8 @@ "gpr", "grpc_base", "grpc_client_channel", + "grpc_lb_upb", "grpc_resolver_fake", - "grpclb_proto", - "nanopb", "upb" ], "headers": [ @@ -9329,10 +9328,9 @@ "gpr", "grpc_base", "grpc_client_channel", + "grpc_lb_upb", "grpc_resolver_fake", "grpc_secure", - "grpclb_proto", - "nanopb", "upb" ], "headers": [ @@ -9401,8 +9399,7 @@ "grpc_client_channel", "grpc_resolver_fake", "grpclb_proto", - "nanopb", - "upb" + "nanopb" ], "headers": [ "src/core/ext/filters/client_channel/lb_policy/xds/xds.h", @@ -9434,8 +9431,7 @@ "grpc_resolver_fake", "grpc_secure", "grpclb_proto", - "nanopb", - "upb" + "nanopb" ], "headers": [ "src/core/ext/filters/client_channel/lb_policy/xds/xds.h", From 8a301a438ac0dfd4311157bd3e62f6880bc19ede Mon Sep 17 00:00:00 2001 From: Yihua Zhang Date: Wed, 7 Aug 2019 14:33:09 -0700 Subject: [PATCH 1140/1555] revision 1 --- src/core/tsi/ssl_transport_security.cc | 6 +-- src/core/tsi/ssl_transport_security.h | 4 +- src/core/tsi/test_creds/multi-domain.key | 50 ++++++++++---------- src/core/tsi/test_creds/multi-domain.pem | 42 ++++++++-------- test/core/tsi/ssl_transport_security_test.cc | 21 ++++++-- 5 files changed, 69 insertions(+), 54 deletions(-) diff --git a/src/core/tsi/ssl_transport_security.cc b/src/core/tsi/ssl_transport_security.cc index f3982fa1caa..32a96b23f29 100644 --- a/src/core/tsi/ssl_transport_security.cc +++ b/src/core/tsi/ssl_transport_security.cc @@ -711,8 +711,8 @@ static tsi_result populate_ssl_context( } /* Extracts the CN and the SANs from an X509 cert as a peer object. */ -tsi_result extract_x509_subject_names_from_pem_cert(const char* pem_cert, - tsi_peer* peer) { +tsi_result tsi_ssl_extract_x509_subject_names_from_pem_cert( + const char* pem_cert, tsi_peer* peer) { tsi_result result = TSI_OK; X509* cert = nullptr; BIO* pem; @@ -1890,7 +1890,7 @@ tsi_result tsi_create_ssl_server_handshaker_factory_with_options( } /* TODO(jboeuf): Add revocation verification. */ - result = extract_x509_subject_names_from_pem_cert( + result = tsi_ssl_extract_x509_subject_names_from_pem_cert( options->pem_key_cert_pairs[i].cert_chain, &impl->ssl_context_x509_subject_names[i]); if (result != TSI_OK) break; diff --git a/src/core/tsi/ssl_transport_security.h b/src/core/tsi/ssl_transport_security.h index 638c088442c..04f038ac3b4 100644 --- a/src/core/tsi/ssl_transport_security.h +++ b/src/core/tsi/ssl_transport_security.h @@ -333,7 +333,7 @@ const tsi_ssl_handshaker_factory_vtable* tsi_ssl_handshaker_factory_swap_vtable( tsi_ssl_handshaker_factory_vtable* new_vtable); /* Exposed for testing only. */ -tsi_result extract_x509_subject_names_from_pem_cert(const char* pem_cert, - tsi_peer* peer); +tsi_result tsi_ssl_extract_x509_subject_names_from_pem_cert( + const char* pem_cert, tsi_peer* peer); #endif /* GRPC_CORE_TSI_SSL_TRANSPORT_SECURITY_H */ diff --git a/src/core/tsi/test_creds/multi-domain.key b/src/core/tsi/test_creds/multi-domain.key index 59008191888..74e8122e186 100644 --- a/src/core/tsi/test_creds/multi-domain.key +++ b/src/core/tsi/test_creds/multi-domain.key @@ -1,27 +1,27 @@ -----BEGIN RSA PRIVATE KEY----- -MIIEpQIBAAKCAQEA1e+GwyVNsoKu7PqvOf/EubN45rB5o5PQF9A5fBPpiBtKZdvb -bOouGlulRwaMQOLDZi9M6l/AhE1b207+iSBTn9jSQT0elaYwVtKgb/qoehQjFAG8 -BckPmA9E4SDx2Ug9AtV3rTVs4V2yaDHNSfDSXQ2PS9fuIx7FK5mMnUM2fjskcZqu -HV5f8McXEtvpuTktnb+KDgETO0Cdu3+rf/RtraTuKZb0kmAgf+KaNWDL2j5QsFKa -6sT4812Vfwaevm9qKOtzgAFobCwdVt+Ap/B0XWj4CmzJMPN/SXESluoBHszmTi6Q -mkTEzYbzmD/ObyTxXVKu46kRVmJKXh6BE1wk2QIDAQABAoIBAQDPpS8OFhT14LXc -Oez9xGyzOaltb3iA9qURl/9TmRggDS0G9IBjlGCvIKio6YgUKoUxl1N2YP3A7Dzt -/hw8CG5iRda9j48x/R4KB2HFjmscIpNxhcVzcBV8p8VZJdrX5K+jIoKIUcSecY0K -aNwymlX0D4c4PBtdZy5FBUJgGa64kPQqd+1Ha4cKgD9+oZzSo5Me04cGV7gWqBGt -qY9KL9j8RGA5m+CHu4Qi2ZXnFlkeH/teXuH5AhFzxeYZG4ZwtXCTjNXxQelVNbYw -mIOnADvd+RhJoeLZnGdM/gyFfLpJW6rtqva9l4h2qxKxnO3CcYHwac475wE49ukv -qx027fopAoGBAPTXRsXRHnK+ZZbj1mafFXeM4G+f8QMLxaSP/za6uYKd1BihXurr -NUhYCQ+d6E+HXnCsYQcfR4AMTSqZRA2XImW4ZW8HRog+OBOn9LDaRcvqlqenKs/Z -IoOUqaqVTqNF2ukkH4usnBugPvdxiqtIGXCBFlS0st+PwIoBtRYD0u6bAoGBAN+v -qElfO/LOjzYWsV6bUSxWRp1XFnfxujitkcYbai+AnBITvZ6BcPfcATQ9IIp42HKk -vQ5PVViN2eCzB0R4I09fSOk/1PPGQM/jzgDQ5Q7zy644ee/lPbryKeFbCOxQtQ50 -0ZRHmQmUW/L9FmNxW1Dx0wcicMC2Bq+VnXvkHVebAoGBAMChpxL4Boasee0PcJ3o -x9D5S5NHOS32Uxe4G0mJ+25ikn6WZ8FYMOGsMeTRjfcUQB9R4DzkRTLfes7rKvmu -UOfK/jMufDWxDhmY6RFDiep3tPROt4Y0Bc2UZzDIq8gVq7gGLbOMqH2rxB6WfE1q -Ommjhlg6mwj9ZrStxzV86LXFAoGAISX22miyiZjywCE8x7hcnyVp8YcmXUAFSMDw -CVumsMNuXX9vaj3kb9a6lvM4D005RkQDgEtham4bC6F8QjlLgkeslmRPOpD2qdgo -fxZ123Fljbvw1gwyybF5Y1wKRnrvWeUV6dNyamkB91BqMPJrheNQUo5YBzbyZrLV -U7bKYmECgYEAj7ekhtCiIUMih8noMfpHR0lJG4VhdfqiVL+w25CgnpZJDa6o7pYD -F5fMivdfdKaSAOA5mUGN5u6NrTpfFKhHDucpIOM2+WGOzbbWEc/gEDQ/xEyPEhxj -t4ErMTByrDGKtGuaolNYzAU0SSbCnAAH3L2MRChC9Qv7f5ZVOZX1GPQ= +MIIEpAIBAAKCAQEAtCJ7xmvXxypNx7d6vV9YWZ3SHtm7+OrnDP9LBokGvpkIUloJ +q6IJxVQPTepJWM7JfXGtWgkdfmUCZjswlQmvbCJSYA8+Y76Sm9M6sf26RsMayxXU +ozWdw227frCpQt2ybor7qOLBBbQ30XbsdxPIwlrJst9Shleey93g56EDkhZWQQMN +8cciakv9zUz6GwRu3XtK4KGtWb3VpsOhf8WAoVQ05o4Cevz3LrY7NcZj2IvIna5V ++E5QxQnRXpd5gNzyE1rbzN3pXmHk2SShGI7sEqgo9HOfu7EufwsfmaCXbuCNGhlS +4YfJvuqZ7ElijUbMnYu3eGKWfjymfp/7qHu87wIDAQABAoIBAQCtgU2BaJy1XN0A +Uo1p3G2IHEioqIazEuesEDaeu9uAOHzYfZs082W/6OC45sLxRHS1XIph38fF19tA +xyBbXbHXURPRLL2ma4hhiUrO6JrEz+Z92LAw6FLmS0q+k8DlBA97BGm0WX0cVmMx +YgAQDkFgWvxOS2b8uWbd7QBVezSqPzN8iV2GNmnEA7FIphqqJbkgEBOxbwJig5Ll +WJ51Q8nWWVZS1AY2kJjf2ndFJgrB3Zbuib0nnmjsG4esB5AS9Fyjadmc+ilU7ceX +y+AdccV2cO0f9k8SBPWHUrRuiuMTcwoQ/r2HN9THaho1QBWPRPjzvXetKLTzRdK0 ++yzEI9x5AoGBAO+CYFKWwt8ylrqQzuGPVYu32RUaVgUtZVsWoF5vzK35WYFCfA+S +qIO+wPs06py79Ytgk/ff5QCz7DRepdlrmyq5ZqZ0xD858H8qzNByySZI0DSJU1wr +7Uw/5vf/+6/1/dmgPrT7HjZyGuvqq1XieBcjonQ5RYooEcjCcCnz9+z9AoGBAMCJ +kApBhTOVBquiXiqEsrbrT7s8u2KbqN9L7E2o5MnfG7sIhrFbY0Bjvdsut1omfBxd +XpTWnyR+OLd6xSpBB5fEBKD21dotwgNmJm+wTAER8ZpohlTLv8gQRHclkFg5chyY +2LJKfssiaXvocKMq3CwM7XAnbI8OTDnwxSqAfCtbAoGBAI7RGGzG90auXNC83pAD +r0gUBb8eqCKIMkMBl/kYA13OLP/1zBJhKlj82wgwQqHZNo64tSL+gAhOQU/tDEo8 +bxcn3LzvLcJh4zWBKQY3HBjXHEfnhyyUCPkJtck1/DetoIQvmJTElPx0R/dbRHV/ +CIsLtahGKmA6inhC8S0jDDhlAoGAX5svglg8q3uB33J17gkMsVYxtlkW94UyGweZ +ZIrMaQ23uG0obSNjKpMcsJ0HAOYBVRhsId5dEgL3aOy2wR+fhJYack9/q6JzJ7ru +tSFG7HUbkr/6jFrMdazWQo/NmHGWH2sql4X0ZixFUvj+DZf30ovsz3dUKclAwriz +P0Kj5ecCgYBbn1REy6+5x6lLO2SIymharMTPSG23GBiwPTSpyMD5WbzqKEQVSSJX +eIaaTPz68HOmgvBZUE7Svbz/OqhDEgZxZG9o7Pr4tsdAUzAt/LNkYA8BOjTnrx7W +ANPvr6b2UHBn26SitdwC5emdsGZIPBGS0XDzznvNwxl2+t14iteEbg== -----END RSA PRIVATE KEY----- diff --git a/src/core/tsi/test_creds/multi-domain.pem b/src/core/tsi/test_creds/multi-domain.pem index c60d2baef6e..cf28b4a6cfa 100644 --- a/src/core/tsi/test_creds/multi-domain.pem +++ b/src/core/tsi/test_creds/multi-domain.pem @@ -1,23 +1,23 @@ -----BEGIN CERTIFICATE----- -MIIDwDCCAqigAwIBAgIUYSe4/8nE/RVUX7e7QeyCmqPWd6AwDQYJKoZIhvcNAQEL -BQAwODELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMQswCQYDVQQHDAJTRjEPMA0G -A1UECwwGR29vZ2xlMB4XDTE5MDgwNTE4MDYwNVoXDTIwMDgwNDE4MDYwNVowODEL -MAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMQswCQYDVQQHDAJTRjEPMA0GA1UECwwG -R29vZ2xlMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1e+GwyVNsoKu -7PqvOf/EubN45rB5o5PQF9A5fBPpiBtKZdvbbOouGlulRwaMQOLDZi9M6l/AhE1b -207+iSBTn9jSQT0elaYwVtKgb/qoehQjFAG8BckPmA9E4SDx2Ug9AtV3rTVs4V2y -aDHNSfDSXQ2PS9fuIx7FK5mMnUM2fjskcZquHV5f8McXEtvpuTktnb+KDgETO0Cd -u3+rf/RtraTuKZb0kmAgf+KaNWDL2j5QsFKa6sT4812Vfwaevm9qKOtzgAFobCwd -Vt+Ap/B0XWj4CmzJMPN/SXESluoBHszmTi6QmkTEzYbzmD/ObyTxXVKu46kRVmJK -Xh6BE1wk2QIDAQABo4HBMIG+MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgXgMIGjBgNV -HREEgZswgZiCE2Zvby50ZXN0LmRvbWFpbi5jb22CE2Jhci50ZXN0LmRvbWFpbi5j -b22GIGh0dHBzOi8vZm9vLnRlc3QuZG9tYWluLmNvbS90ZXN0hiBodHRwczovL2Jh -ci50ZXN0LmRvbWFpbi5jb20vdGVzdIETZm9vQHRlc3QuZG9tYWluLmNvbYETYmFy -QHRlc3QuZG9tYWluLmNvbTANBgkqhkiG9w0BAQsFAAOCAQEAzBhVGeqIntQs9qpK -xGOjpFTBMzCjYORNAq09Otkc/IBwtPOq0K2as7fp6Vr5DRStN7hDSBrMjZh+XujY -3GNEv4pIR5fWwrZg/fnNyG5BIUhdq/qtC3JAMqBjno3OJjg1t4KzS4l+ozHeevJA -qT9t6aodsn1r7w89MfAVGPIw7D3n9n5N4z2b/co17W8B0RyMWX2PmQWkEqn7kId/ -Jj+hmw2n9UV1IU3xhcepxG+wzjFLIB9nsDwgtZogK6f5p9FFBG8raqk6QhVSlRgh -JmNqmK5+hyUy1zbjGqgfM5eVmQ/A3qWVQTrk3HeTr2hO9GoBHeXQfinjlIhnbbtJ -xouhvA== +MIID5DCCAsygAwIBAgIUMmNBVcGnMw2sMASWhdn5IvFktoYwDQYJKoZIhvcNAQEL +BQAwSjELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMQswCQYDVQQHDAJTRjEPMA0G +A1UECwwGR29vZ2xlMRAwDgYDVQQDDAd4cGlnb3JzMB4XDTE5MDgwNzIxMDY0NVoX +DTIwMDgwNjIxMDY0NVowSjELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMQswCQYD +VQQHDAJTRjEPMA0GA1UECwwGR29vZ2xlMRAwDgYDVQQDDAd4cGlnb3JzMIIBIjAN +BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtCJ7xmvXxypNx7d6vV9YWZ3SHtm7 ++OrnDP9LBokGvpkIUloJq6IJxVQPTepJWM7JfXGtWgkdfmUCZjswlQmvbCJSYA8+ +Y76Sm9M6sf26RsMayxXUozWdw227frCpQt2ybor7qOLBBbQ30XbsdxPIwlrJst9S +hleey93g56EDkhZWQQMN8cciakv9zUz6GwRu3XtK4KGtWb3VpsOhf8WAoVQ05o4C +evz3LrY7NcZj2IvIna5V+E5QxQnRXpd5gNzyE1rbzN3pXmHk2SShGI7sEqgo9HOf +u7EufwsfmaCXbuCNGhlS4YfJvuqZ7ElijUbMnYu3eGKWfjymfp/7qHu87wIDAQAB +o4HBMIG+MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgXgMIGjBgNVHREEgZswgZiCE2Zv +by50ZXN0LmRvbWFpbi5jb22CE2Jhci50ZXN0LmRvbWFpbi5jb22BE2Zvb0B0ZXN0 +LmRvbWFpbi5jb22BE2JhckB0ZXN0LmRvbWFpbi5jb22GIGh0dHBzOi8vZm9vLnRl +c3QuZG9tYWluLmNvbS90ZXN0hiBodHRwczovL2Jhci50ZXN0LmRvbWFpbi5jb20v +dGVzdDANBgkqhkiG9w0BAQsFAAOCAQEAIu99zFdybv5OoLNYeyhZsiGjHJQ/ECYr +dp4XeRftwO5lvLUbxDz4nfs7dedDYqk+amfgJsVg9zDykeAslvjmuWHJ1IgACAqm +SlR43gwWt1YMXH7NJ8unAxF3OwGDMdIA5WJfYo2XFz4o55wWCiUbxCpWJYu8hwz6 +6IRmn6hWWsxlflWmgaV5hYKL8bLF13Ku9gZbNFFJw6knyqw+x4b1LwsnKeZGvS7E +EvGVyhMylPVFc0ZZy0TZvk3UOR9TbIMXiztQIWrw30izwPNElvUTzSkAbAg+h6+8 +G7xSZYDr6l81M0a3S2VU75yjMCHKP5/wE9hsfTr/NpWN7w5w5PmqdA== -----END CERTIFICATE----- diff --git a/test/core/tsi/ssl_transport_security_test.cc b/test/core/tsi/ssl_transport_security_test.cc index 014127a3042..c5e6e839b18 100644 --- a/test/core/tsi/ssl_transport_security_test.cc +++ b/test/core/tsi/ssl_transport_security_test.cc @@ -790,13 +790,25 @@ void ssl_tsi_test_duplicate_root_certificates() { gpr_free(dup_root_cert); } -void ssl_tsi_test_uri_email_subject_alt_names() { +void ssl_tsi_test_extract_x509_subject_names() { char* cert = load_file(SSL_TSI_TEST_CREDENTIALS_DIR, "multi-domain.pem"); tsi_peer peer; - GPR_ASSERT(extract_x509_subject_names_from_pem_cert(cert, &peer) == TSI_OK); + GPR_ASSERT(tsi_ssl_extract_x509_subject_names_from_pem_cert(cert, &peer) == + TSI_OK); // One for common name, one for certificate, and six for SAN fields. size_t expected_property_count = 8; GPR_ASSERT(peer.property_count == expected_property_count); + // Check common name + const char* expected_cn = "xpigors"; + const tsi_peer_property* property = tsi_peer_get_property_by_name( + &peer, TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY); + GPR_ASSERT(property != nullptr); + GPR_ASSERT( + memcmp(property->value.data, expected_cn, property->value.length) == 0); + // Check certificate data + property = tsi_peer_get_property_by_name(&peer, TSI_X509_PEM_CERT_PROPERTY); + GPR_ASSERT(property != nullptr); + GPR_ASSERT(memcmp(property->value.data, cert, property->value.length) == 0); // Check DNS GPR_ASSERT(check_subject_alt_name(&peer, "foo.test.domain.com") == 1); GPR_ASSERT(check_subject_alt_name(&peer, "bar.test.domain.com") == 1); @@ -808,6 +820,9 @@ void ssl_tsi_test_uri_email_subject_alt_names() { // Check email address GPR_ASSERT(check_subject_alt_name(&peer, "foo@test.domain.com") == 1); GPR_ASSERT(check_subject_alt_name(&peer, "bar@test.domain.com") == 1); + // Free memory + gpr_free(cert); + tsi_peer_destruct(&peer); } int main(int argc, char** argv) { @@ -835,7 +850,7 @@ int main(int argc, char** argv) { ssl_tsi_test_do_round_trip_odd_buffer_size(); ssl_tsi_test_handshaker_factory_internals(); ssl_tsi_test_duplicate_root_certificates(); - ssl_tsi_test_uri_email_subject_alt_names(); + ssl_tsi_test_extract_x509_subject_names(); grpc_shutdown(); return 0; } From 807cd08f4a1f006a4d9c56ada0947c9da7c6d647 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 7 Aug 2019 15:43:31 -0700 Subject: [PATCH 1141/1555] Fix upb build typo --- BUILD.gn | 16 ++++ gRPC-C++.podspec | 16 ++++ gRPC-Core.podspec | 20 ++++- grpc.gemspec | 8 ++ package.xml | 8 ++ .../filters/client_channel/health/health.pb.c | 23 ------ .../filters/client_channel/health/health.pb.h | 73 ------------------- src/upb/gen_build_yaml.py | 2 +- tools/distrib/check_copyright.py | 2 - tools/doxygen/Doxyfile.c++.internal | 10 ++- tools/doxygen/Doxyfile.core.internal | 10 ++- .../generated/sources_and_headers.json | 2 +- tools/run_tests/sanity/sanity_tests.yaml | 1 - 13 files changed, 84 insertions(+), 107 deletions(-) delete mode 100644 src/core/ext/filters/client_channel/health/health.pb.c delete mode 100644 src/core/ext/filters/client_channel/health/health.pb.h diff --git a/BUILD.gn b/BUILD.gn index 28a950c13cf..95857cc245c 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -874,11 +874,19 @@ config("grpc_config") { "src/core/tsi/transport_security_grpc.h", "src/core/tsi/transport_security_interface.h", "third_party/upb/upb/decode.c", + "third_party/upb/upb/decode.h", "third_party/upb/upb/encode.c", + "third_party/upb/upb/encode.h", + "third_party/upb/upb/generated_util.h", "third_party/upb/upb/msg.c", + "third_party/upb/upb/msg.h", "third_party/upb/upb/port.c", + "third_party/upb/upb/port_def.inc", + "third_party/upb/upb/port_undef.inc", "third_party/upb/upb/table.c", + "third_party/upb/upb/table.int.h", "third_party/upb/upb/upb.c", + "third_party/upb/upb/upb.h", ] deps = [ "//third_party/boringssl", @@ -1398,11 +1406,19 @@ config("grpc_config") { "src/cpp/util/string_ref.cc", "src/cpp/util/time_cc.cc", "third_party/upb/upb/decode.c", + "third_party/upb/upb/decode.h", "third_party/upb/upb/encode.c", + "third_party/upb/upb/encode.h", + "third_party/upb/upb/generated_util.h", "third_party/upb/upb/msg.c", + "third_party/upb/upb/msg.h", "third_party/upb/upb/port.c", + "third_party/upb/upb/port_def.inc", + "third_party/upb/upb/port_undef.inc", "third_party/upb/upb/table.c", + "third_party/upb/upb/table.int.h", "third_party/upb/upb/upb.c", + "third_party/upb/upb/upb.h", ] deps = [ "//third_party/boringssl", diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index b1a169207ac..b90a006e9b1 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -389,6 +389,14 @@ Pod::Spec.new do |s| 'src/core/tsi/alts/handshaker/transport_security_common.pb.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', + 'third_party/upb/upb/decode.h', + 'third_party/upb/upb/encode.h', + 'third_party/upb/upb/generated_util.h', + 'third_party/upb/upb/msg.h', + 'third_party/upb/upb/port_def.inc', + 'third_party/upb/upb/port_undef.inc', + 'third_party/upb/upb/table.int.h', + 'third_party/upb/upb/upb.h', 'src/core/ext/transport/chttp2/client/authority.h', 'src/core/ext/transport/chttp2/client/chttp2_connector.h', 'src/core/ext/filters/client_channel/backup_poller.h', @@ -790,6 +798,14 @@ Pod::Spec.new do |s| 'src/core/lib/uri/uri_parser.h', 'src/core/lib/debug/trace.h', 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h', + 'third_party/upb/upb/decode.h', + 'third_party/upb/upb/encode.h', + 'third_party/upb/upb/generated_util.h', + 'third_party/upb/upb/msg.h', + 'third_party/upb/upb/port_def.inc', + 'third_party/upb/upb/port_undef.inc', + 'third_party/upb/upb/table.int.h', + 'third_party/upb/upb/upb.h', 'src/core/ext/transport/inproc/inproc_transport.h' end diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index f69e985ccf5..6ee74687c74 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -345,6 +345,14 @@ Pod::Spec.new do |s| 'src/core/tsi/alts/handshaker/transport_security_common.pb.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', + 'third_party/upb/upb/decode.h', + 'third_party/upb/upb/encode.h', + 'third_party/upb/upb/generated_util.h', + 'third_party/upb/upb/msg.h', + 'third_party/upb/upb/port_def.inc', + 'third_party/upb/upb/port_undef.inc', + 'third_party/upb/upb/table.int.h', + 'third_party/upb/upb/upb.h', 'src/core/ext/transport/chttp2/client/authority.h', 'src/core/ext/transport/chttp2/client/chttp2_connector.h', 'src/core/ext/filters/client_channel/backup_poller.h', @@ -1026,6 +1034,14 @@ Pod::Spec.new do |s| 'src/core/tsi/alts/handshaker/transport_security_common.pb.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', + 'third_party/upb/upb/decode.h', + 'third_party/upb/upb/encode.h', + 'third_party/upb/upb/generated_util.h', + 'third_party/upb/upb/msg.h', + 'third_party/upb/upb/port_def.inc', + 'third_party/upb/upb/port_undef.inc', + 'third_party/upb/upb/table.int.h', + 'third_party/upb/upb/upb.h', 'src/core/ext/transport/chttp2/client/authority.h', 'src/core/ext/transport/chttp2/client/chttp2_connector.h', 'src/core/ext/filters/client_channel/backup_poller.h', @@ -1330,10 +1346,6 @@ Pod::Spec.new do |s| 'test/core/util/tracer_util.h', 'test/core/util/trickle_endpoint.h', 'test/core/util/cmdline.h', - 'third_party/nanopb/pb.h', - 'third_party/nanopb/pb_common.h', - 'third_party/nanopb/pb_decode.h', - 'third_party/nanopb/pb_encode.h', 'test/core/end2end/end2end_tests.cc', 'test/core/end2end/end2end_test_utils.cc', 'test/core/end2end/tests/authority_not_supported.cc', diff --git a/grpc.gemspec b/grpc.gemspec index 12fddb3252e..af2129350ef 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -278,6 +278,14 @@ Gem::Specification.new do |s| s.files += %w( third_party/nanopb/pb_encode.h ) s.files += %w( src/core/tsi/transport_security.h ) s.files += %w( src/core/tsi/transport_security_interface.h ) + s.files += %w( third_party/upb/upb/decode.h ) + s.files += %w( third_party/upb/upb/encode.h ) + s.files += %w( third_party/upb/upb/generated_util.h ) + s.files += %w( third_party/upb/upb/msg.h ) + s.files += %w( third_party/upb/upb/port_def.inc ) + s.files += %w( third_party/upb/upb/port_undef.inc ) + s.files += %w( third_party/upb/upb/table.int.h ) + s.files += %w( third_party/upb/upb/upb.h ) s.files += %w( src/core/ext/transport/chttp2/client/authority.h ) s.files += %w( src/core/ext/transport/chttp2/client/chttp2_connector.h ) s.files += %w( src/core/ext/filters/client_channel/backup_poller.h ) diff --git a/package.xml b/package.xml index 5b85159a4f5..5352a9f43d7 100644 --- a/package.xml +++ b/package.xml @@ -283,6 +283,14 @@ + + + + + + + + diff --git a/src/core/ext/filters/client_channel/health/health.pb.c b/src/core/ext/filters/client_channel/health/health.pb.c deleted file mode 100644 index 5499c549cc6..00000000000 --- a/src/core/ext/filters/client_channel/health/health.pb.c +++ /dev/null @@ -1,23 +0,0 @@ -/* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.7-dev */ - -#include "src/core/ext/filters/client_channel/health/health.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 -#error Regenerate this file with the current version of nanopb generator. -#endif - - - -const pb_field_t grpc_health_v1_HealthCheckRequest_fields[2] = { - PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, grpc_health_v1_HealthCheckRequest, service, service, 0), - PB_LAST_FIELD -}; - -const pb_field_t grpc_health_v1_HealthCheckResponse_fields[2] = { - PB_FIELD( 1, UENUM , OPTIONAL, STATIC , FIRST, grpc_health_v1_HealthCheckResponse, status, status, 0), - PB_LAST_FIELD -}; - - -/* @@protoc_insertion_point(eof) */ diff --git a/src/core/ext/filters/client_channel/health/health.pb.h b/src/core/ext/filters/client_channel/health/health.pb.h deleted file mode 100644 index 9d54ccd6182..00000000000 --- a/src/core/ext/filters/client_channel/health/health.pb.h +++ /dev/null @@ -1,73 +0,0 @@ -/* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.7-dev */ - -#ifndef PB_GRPC_HEALTH_V1_HEALTH_PB_H_INCLUDED -#define PB_GRPC_HEALTH_V1_HEALTH_PB_H_INCLUDED -#include "pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 -#error Regenerate this file with the current version of nanopb generator. -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Enum definitions */ -typedef enum _grpc_health_v1_HealthCheckResponse_ServingStatus { - grpc_health_v1_HealthCheckResponse_ServingStatus_UNKNOWN = 0, - grpc_health_v1_HealthCheckResponse_ServingStatus_SERVING = 1, - grpc_health_v1_HealthCheckResponse_ServingStatus_NOT_SERVING = 2, - grpc_health_v1_HealthCheckResponse_ServingStatus_SERVICE_UNKNOWN = 3 -} grpc_health_v1_HealthCheckResponse_ServingStatus; -#define _grpc_health_v1_HealthCheckResponse_ServingStatus_MIN grpc_health_v1_HealthCheckResponse_ServingStatus_UNKNOWN -#define _grpc_health_v1_HealthCheckResponse_ServingStatus_MAX grpc_health_v1_HealthCheckResponse_ServingStatus_SERVICE_UNKNOWN -#define _grpc_health_v1_HealthCheckResponse_ServingStatus_ARRAYSIZE ((grpc_health_v1_HealthCheckResponse_ServingStatus)(grpc_health_v1_HealthCheckResponse_ServingStatus_SERVICE_UNKNOWN+1)) - -/* Struct definitions */ -typedef struct _grpc_health_v1_HealthCheckRequest { - bool has_service; - char service[200]; -/* @@protoc_insertion_point(struct:grpc_health_v1_HealthCheckRequest) */ -} grpc_health_v1_HealthCheckRequest; - -typedef struct _grpc_health_v1_HealthCheckResponse { - bool has_status; - grpc_health_v1_HealthCheckResponse_ServingStatus status; -/* @@protoc_insertion_point(struct:grpc_health_v1_HealthCheckResponse) */ -} grpc_health_v1_HealthCheckResponse; - -/* Default values for struct fields */ - -/* Initializer values for message structs */ -#define grpc_health_v1_HealthCheckRequest_init_default {false, ""} -#define grpc_health_v1_HealthCheckResponse_init_default {false, (grpc_health_v1_HealthCheckResponse_ServingStatus)0} -#define grpc_health_v1_HealthCheckRequest_init_zero {false, ""} -#define grpc_health_v1_HealthCheckResponse_init_zero {false, (grpc_health_v1_HealthCheckResponse_ServingStatus)0} - -/* Field tags (for use in manual encoding/decoding) */ -#define grpc_health_v1_HealthCheckRequest_service_tag 1 -#define grpc_health_v1_HealthCheckResponse_status_tag 1 - -/* Struct field encoding specification for nanopb */ -extern const pb_field_t grpc_health_v1_HealthCheckRequest_fields[2]; -extern const pb_field_t grpc_health_v1_HealthCheckResponse_fields[2]; - -/* Maximum encoded size of messages (where known) */ -#define grpc_health_v1_HealthCheckRequest_size 203 -#define grpc_health_v1_HealthCheckResponse_size 2 - -/* Message IDs (where set with "msgid" option) */ -#ifdef PB_MSGID - -#define HEALTH_MESSAGES \ - - -#endif - -#ifdef __cplusplus -} /* extern "C" */ -#endif -/* @@protoc_insertion_point(eof) */ - -#endif diff --git a/src/upb/gen_build_yaml.py b/src/upb/gen_build_yaml.py index 65d31953b1f..ba11ebd846c 100755 --- a/src/upb/gen_build_yaml.py +++ b/src/upb/gen_build_yaml.py @@ -47,7 +47,7 @@ try: out['filegroups'] = [{ 'name': 'upb', 'src': srcs, - 'uses': [ 'nanopb_headers' ], + 'uses': [ 'upb_headers' ], }, { 'name': 'upb_headers', 'headers': hdrs, diff --git a/tools/distrib/check_copyright.py b/tools/distrib/check_copyright.py index aed63474b2d..a67802b2a2c 100755 --- a/tools/distrib/check_copyright.py +++ b/tools/distrib/check_copyright.py @@ -75,8 +75,6 @@ _EXEMPT = frozenset(( 'examples/python/multiplex/route_guide_pb2_grpc.py', 'examples/python/route_guide/route_guide_pb2.py', 'examples/python/route_guide/route_guide_pb2_grpc.py', - 'src/core/ext/filters/client_channel/health/health.pb.h', - 'src/core/ext/filters/client_channel/health/health.pb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h', diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index ac421d418ba..3e6b641c8e4 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1297,11 +1297,19 @@ third_party/nanopb/pb_common.h \ third_party/nanopb/pb_decode.h \ third_party/nanopb/pb_encode.h \ third_party/upb/upb/decode.c \ +third_party/upb/upb/decode.h \ third_party/upb/upb/encode.c \ +third_party/upb/upb/encode.h \ +third_party/upb/upb/generated_util.h \ third_party/upb/upb/msg.c \ +third_party/upb/upb/msg.h \ third_party/upb/upb/port.c \ +third_party/upb/upb/port_def.inc \ +third_party/upb/upb/port_undef.inc \ third_party/upb/upb/table.c \ -third_party/upb/upb/upb.c +third_party/upb/upb/table.int.h \ +third_party/upb/upb/upb.c \ +third_party/upb/upb/upb.h # 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/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index e15778c276b..e1d03c33268 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1614,11 +1614,19 @@ third_party/nanopb/pb_decode.h \ third_party/nanopb/pb_encode.c \ third_party/nanopb/pb_encode.h \ third_party/upb/upb/decode.c \ +third_party/upb/upb/decode.h \ third_party/upb/upb/encode.c \ +third_party/upb/upb/encode.h \ +third_party/upb/upb/generated_util.h \ third_party/upb/upb/msg.c \ +third_party/upb/upb/msg.h \ third_party/upb/upb/port.c \ +third_party/upb/upb/port_def.inc \ +third_party/upb/upb/port_undef.inc \ third_party/upb/upb/table.c \ -third_party/upb/upb/upb.c +third_party/upb/upb/table.int.h \ +third_party/upb/upb/upb.c \ +third_party/upb/upb/upb.h # 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/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index eea82fd730c..c026d6a1caa 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -10933,7 +10933,7 @@ }, { "deps": [ - "nanopb_headers" + "upb_headers" ], "headers": [], "is_filegroup": true, diff --git a/tools/run_tests/sanity/sanity_tests.yaml b/tools/run_tests/sanity/sanity_tests.yaml index e9459911a1e..222e63a46dc 100644 --- a/tools/run_tests/sanity/sanity_tests.yaml +++ b/tools/run_tests/sanity/sanity_tests.yaml @@ -16,7 +16,6 @@ cpu_cost: 3 - script: tools/distrib/check_copyright.py - script: tools/distrib/check_include_guards.py -- script: tools/distrib/check_nanopb_output.sh - script: tools/distrib/check_trailing_newlines.sh - script: tools/distrib/check_upb_output.sh - script: tools/distrib/clang_format_code.sh From 0f02911d3d8258d958cfd2938c37a01458cc147b Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 7 Aug 2019 14:52:09 -0700 Subject: [PATCH 1142/1555] Added targets for tv and watch samples --- src/objective-c/examples/BUILD | 72 ++++++++++++++++++- .../tvOS-sample/tvOS-sample/Info.plist | 2 +- .../AppIcon.appiconset/Contents.json | 21 ++++++ .../watchOS-sample/WatchKit-App/Info.plist | 2 +- .../WatchKit-Extension/Info.plist | 2 +- .../watchOS-sample/watchOS-sample/Info.plist | 2 +- 6 files changed, 96 insertions(+), 5 deletions(-) diff --git a/src/objective-c/examples/BUILD b/src/objective-c/examples/BUILD index d6e1140d8f5..5e3e4f9badd 100644 --- a/src/objective-c/examples/BUILD +++ b/src/objective-c/examples/BUILD @@ -18,7 +18,7 @@ load("//src/objective-c:grpc_objc_internal_library.bzl", "local_objc_grpc_library") load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application") load("@build_bazel_rules_apple//apple:tvos.bzl", "tvos_application") -load("@build_bazel_rules_apple//apple:watchos.bzl", "watchos_application") +load("@build_bazel_rules_apple//apple:watchos.bzl", "watchos_application", "watchos_extension") proto_library( name = "messages_proto", @@ -96,3 +96,73 @@ ios_application( ], deps = ["InterceptorSample-lib"], ) + +objc_library( + name = "tvOS-sample-lib", + srcs = glob(["tvOS-sample/tvOS-sample/**/*.m"]), + hdrs = glob(["tvOS-sample/tvOS-sample/**/*.h"]), + data = glob([ + "tvOS-sample/tvOS-sample/Base.lproj/**", + "tvOS-sample/tvOS-sample/Images.xcassets/**", + ]), + deps = [":test_grpc_objc"], +) + +# c-ares does not support tvOS CPU architecture with Bazel yet +tvos_application( + name = "tvOS-sample", + bundle_id = "grpc.objc.examples.tvOS-sample", + minimum_os_version = "10.0", + infoplists = ["tvOS-sample/tvOS-sample/Info.plist"], + deps = [":tvOS-sample-lib"], +) + +objc_library( + name = "watchOS-sample-iOS-lib", + srcs = glob(["watchOS-sample/watchOS-sample/**/*.m"]), + hdrs = glob(["watchOS-sample/watchOS-sample/**/*.h"]), + data = glob([ + "watchOS-sample/watchOS-sample/Base.lproj/**", + "watchOS-sample/watchOS-sample/Images.xcassets/**", + ]), + deps = [":test_grpc_objc"], +) + +objc_library( + name = "watchOS-sample-extension-lib", + srcs = glob(["watchOS-sample/WatchKit-Extention/**/*.m"]), + hdrs = glob(["watchOS-sample/WatchKit-Extension/**/*.h"]), + deps = [":test_grpc_objc"], + sdk_frameworks = [ + "WatchConnectivity", + "WatchKit", + ], +) + +ios_application( + name = "watchOS-sample", + bundle_id = "com.google.watchOS-sample", + minimum_os_version = "9.0", # Safe Area Layout Guide used + families = ["iphone"], + infoplists = ["watchOS-sample/watchOS-sample/Info.plist"], + deps = [":watchOS-sample-iOS-lib"], + watch_application = "watchOS-sample-watchApp", +) + +# c-ares does not support watchOS CPU architecture with Bazel yet +watchos_application( + name = "watchOS-sample-watchApp", + bundle_id = "com.google.watchOS-sample.watchkitapp", + minimum_os_version = "4.0", + storyboards = ["watchOS-sample/WatchKit-App/Base.lproj/Interface.storyboard"], + infoplists = ["watchOS-sample/WatchKit-App/Info.plist"], + extension = ":watchOS-sample-extension", +) + +watchos_extension( + name = "watchOS-sample-extension", + bundle_id = "com.google.watchOS-sample.watchkitapp.watchkitextension", + minimum_os_version = "4.0", + infoplists = ["watchOS-sample/WatchKit-Extension/Info.plist"], + deps = [":watchOS-sample-extension-lib"], +) diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Info.plist b/src/objective-c/examples/tvOS-sample/tvOS-sample/Info.plist index 02942a34f3e..63dcd6c1d26 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Info.plist +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Info.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) + en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-App/Assets.xcassets/AppIcon.appiconset/Contents.json b/src/objective-c/examples/watchOS-sample/WatchKit-App/Assets.xcassets/AppIcon.appiconset/Contents.json index 215c1ddfee9..6c0f2b4204b 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-App/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/src/objective-c/examples/watchOS-sample/WatchKit-App/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -33,6 +33,20 @@ "role" : "appLauncher", "subtype" : "38mm" }, + { + "size" : "44x44", + "idiom" : "watch", + "scale" : "2x", + "role" : "appLauncher", + "subtype" : "40mm" + }, + { + "size" : "50x50", + "idiom" : "watch", + "scale" : "2x", + "role" : "appLauncher", + "subtype" : "44mm" + }, { "size" : "86x86", "idiom" : "watch", @@ -47,6 +61,13 @@ "role" : "quickLook", "subtype" : "42mm" }, + { + "size" : "108x108", + "idiom" : "watch", + "scale" : "2x", + "role" : "quickLook", + "subtype" : "44mm" + }, { "idiom" : "watch-marketing", "size" : "1024x1024", diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-App/Info.plist b/src/objective-c/examples/watchOS-sample/WatchKit-App/Info.plist index 309d7867639..6dbcfe04d53 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-App/Info.plist +++ b/src/objective-c/examples/watchOS-sample/WatchKit-App/Info.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) + en CFBundleDisplayName WatchKit-App CFBundleExecutable diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Info.plist b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Info.plist index bc09fa0f786..4a0a252b854 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Info.plist +++ b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Info.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) + en CFBundleDisplayName watchOS-sample WatchKit Extension CFBundleExecutable diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/Info.plist b/src/objective-c/examples/watchOS-sample/watchOS-sample/Info.plist index 16be3b68112..d0524738680 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/Info.plist +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/Info.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) + en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier From f036d6ef58f2737bff36872c6cb452dfeeb5ab20 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Thu, 1 Aug 2019 15:28:44 -0700 Subject: [PATCH 1143/1555] s/gpr_ref/grpc_core::RefCount/ for frequent users. --- src/core/lib/iomgr/ev_epollex_linux.cc | 79 ++++++++---------------- src/core/lib/iomgr/tcp_posix.cc | 36 ++++------- src/core/lib/surface/completion_queue.cc | 26 +++----- src/core/lib/surface/server.cc | 10 ++- 4 files changed, 53 insertions(+), 98 deletions(-) diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc index 08116b3ab53..c2d80c08ddb 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.cc +++ b/src/core/lib/iomgr/ev_epollex_linux.cc @@ -47,6 +47,7 @@ #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/gprpp/manual_constructor.h" +#include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/iomgr_internal.h" @@ -89,7 +90,7 @@ typedef struct pollable pollable; /// - PO_MULTI - a pollable containing many fds struct pollable { pollable_type type; // immutable - gpr_refcount refs; + grpc_core::RefCount refs; int epfd; grpc_wakeup_fd wakeup; @@ -135,17 +136,26 @@ static char* pollable_desc(pollable* p) { static pollable* g_empty_pollable; static grpc_error* pollable_create(pollable_type type, pollable** p); -#ifdef NDEBUG -static pollable* pollable_ref(pollable* p); -static void pollable_unref(pollable* p); -#define POLLABLE_REF(p, r) pollable_ref(p) -#define POLLABLE_UNREF(p, r) pollable_unref(p) -#else -static pollable* pollable_ref(pollable* p, int line, const char* reason); -static void pollable_unref(pollable* p, int line, const char* reason); -#define POLLABLE_REF(p, r) pollable_ref((p), __LINE__, (r)) -#define POLLABLE_UNREF(p, r) pollable_unref((p), __LINE__, (r)) -#endif +static pollable* pollable_ref(pollable* p, + const grpc_core::DebugLocation& dbg_loc, + const char* reason) { + p->refs.Ref(dbg_loc, reason); + return p; +} +static void pollable_unref(pollable* p, const grpc_core::DebugLocation& dbg_loc, + const char* reason) { + if (p == nullptr) return; + if (GPR_UNLIKELY(p != nullptr && p->refs.Unref(dbg_loc, reason))) { + GRPC_FD_TRACE("pollable_unref: Closing epfd: %d", p->epfd); + close(p->epfd); + grpc_wakeup_fd_destroy(&p->wakeup); + gpr_mu_destroy(&p->owner_orphan_mu); + gpr_mu_destroy(&p->mu); + gpr_free(p); + } +} +#define POLLABLE_REF(p, r) pollable_ref((p), DEBUG_LOCATION, (r)) +#define POLLABLE_UNREF(p, r) pollable_unref((p), DEBUG_LOCATION, (r)) /******************************************************************************* * Fd Declarations @@ -283,7 +293,7 @@ struct grpc_pollset { */ struct grpc_pollset_set { - gpr_refcount refs; + grpc_core::RefCount refs; gpr_mu mu; grpc_pollset_set* parent; @@ -568,7 +578,7 @@ static grpc_error* pollable_create(pollable_type type, pollable** p) { } (*p)->type = type; - gpr_ref_init(&(*p)->refs, 1); + new (&(*p)->refs) grpc_core::RefCount(1, &grpc_trace_pollable_refcount); gpr_mu_init(&(*p)->mu); (*p)->epfd = epfd; (*p)->owner_fd = nullptr; @@ -582,41 +592,6 @@ static grpc_error* pollable_create(pollable_type type, pollable** p) { return GRPC_ERROR_NONE; } -#ifdef NDEBUG -static pollable* pollable_ref(pollable* p) { -#else -static pollable* pollable_ref(pollable* p, int line, const char* reason) { - if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_pollable_refcount)) { - int r = static_cast gpr_atm_no_barrier_load(&p->refs.count); - gpr_log(__FILE__, line, GPR_LOG_SEVERITY_DEBUG, - "POLLABLE:%p ref %d->%d %s", p, r, r + 1, reason); - } -#endif - gpr_ref(&p->refs); - return p; -} - -#ifdef NDEBUG -static void pollable_unref(pollable* p) { -#else -static void pollable_unref(pollable* p, int line, const char* reason) { - if (p == nullptr) return; - if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_pollable_refcount)) { - int r = static_cast gpr_atm_no_barrier_load(&p->refs.count); - gpr_log(__FILE__, line, GPR_LOG_SEVERITY_DEBUG, - "POLLABLE:%p unref %d->%d %s", p, r, r - 1, reason); - } -#endif - if (p != nullptr && gpr_unref(&p->refs)) { - GRPC_FD_TRACE("pollable_unref: Closing epfd: %d", p->epfd); - close(p->epfd); - grpc_wakeup_fd_destroy(&p->wakeup); - gpr_mu_destroy(&p->owner_orphan_mu); - gpr_mu_destroy(&p->mu); - gpr_free(p); - } -} - static grpc_error* pollable_add_fd(pollable* p, grpc_fd* fd) { grpc_error* error = GRPC_ERROR_NONE; static const char* err_desc = "pollable_add_fd"; @@ -1331,13 +1306,13 @@ static grpc_pollset_set* pollset_set_create(void) { grpc_pollset_set* pss = static_cast(gpr_zalloc(sizeof(*pss))); gpr_mu_init(&pss->mu); - gpr_ref_init(&pss->refs, 1); + new (&pss->refs) grpc_core::RefCount(); return pss; } static void pollset_set_unref(grpc_pollset_set* pss) { if (pss == nullptr) return; - if (!gpr_unref(&pss->refs)) return; + if (GPR_LIKELY(!pss->refs.Unref())) return; pollset_set_unref(pss->parent); gpr_mu_destroy(&pss->mu); for (size_t i = 0; i < pss->pollset_count; i++) { @@ -1528,7 +1503,7 @@ static void pollset_set_add_pollset_set(grpc_pollset_set* a, if (GRPC_TRACE_FLAG_ENABLED(grpc_polling_trace)) { gpr_log(GPR_INFO, "PSS: parent %p to %p", b, a); } - gpr_ref(&a->refs); + a->refs.Ref(); b->parent = a; if (a->fd_capacity < a->fd_count + b->fd_count) { a->fd_capacity = GPR_MAX(2 * a->fd_capacity, a->fd_count + b->fd_count); diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index 819c5284256..498aecc069b 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -89,7 +89,7 @@ struct grpc_tcp { bool is_first_read; double target_length; double bytes_read_this_round; - gpr_refcount refcount; + grpc_core::RefCount refcount; gpr_atm shutdown_count; int min_read_chunk_size; @@ -359,41 +359,29 @@ static void tcp_free(grpc_tcp* tcp) { } #ifndef NDEBUG -#define TCP_UNREF(tcp, reason) tcp_unref((tcp), (reason), __FILE__, __LINE__) -#define TCP_REF(tcp, reason) tcp_ref((tcp), (reason), __FILE__, __LINE__) -static void tcp_unref(grpc_tcp* tcp, const char* reason, const char* file, - int line) { - if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { - gpr_atm val = gpr_atm_no_barrier_load(&tcp->refcount.count); - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "TCP unref %p : %s %" PRIdPTR " -> %" PRIdPTR, tcp, reason, val, - val - 1); - } - if (gpr_unref(&tcp->refcount)) { +#define TCP_UNREF(tcp, reason) tcp_unref((tcp), (reason), DEBUG_LOCATION) +#define TCP_REF(tcp, reason) tcp_ref((tcp), (reason), DEBUG_LOCATION) +static void tcp_unref(grpc_tcp* tcp, const char* reason, + const grpc_core::DebugLocation& debug_location) { + if (GPR_UNLIKELY(tcp->refcount.Unref(debug_location, reason))) { tcp_free(tcp); } } -static void tcp_ref(grpc_tcp* tcp, const char* reason, const char* file, - int line) { - if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { - gpr_atm val = gpr_atm_no_barrier_load(&tcp->refcount.count); - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "TCP ref %p : %s %" PRIdPTR " -> %" PRIdPTR, tcp, reason, val, - val + 1); - } - gpr_ref(&tcp->refcount); +static void tcp_ref(grpc_tcp* tcp, const char* reason, + const grpc_core::DebugLocation& debug_location) { + tcp->refcount.Ref(debug_location, reason); } #else #define TCP_UNREF(tcp, reason) tcp_unref((tcp)) #define TCP_REF(tcp, reason) tcp_ref((tcp)) static void tcp_unref(grpc_tcp* tcp) { - if (gpr_unref(&tcp->refcount)) { + if (GPR_UNLIKELY(tcp->refcount.Unref())) { tcp_free(tcp); } } -static void tcp_ref(grpc_tcp* tcp) { gpr_ref(&tcp->refcount); } +static void tcp_ref(grpc_tcp* tcp) { tcp->refcount.Ref(); } #endif static void tcp_destroy(grpc_endpoint* ep) { @@ -1230,7 +1218,7 @@ grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd, tcp->ts_capable = true; tcp->outgoing_buffer_arg = nullptr; /* paired with unref in grpc_tcp_destroy */ - gpr_ref_init(&tcp->refcount, 1); + new (&tcp->refcount) grpc_core::RefCount(1, &grpc_tcp_trace); gpr_atm_no_barrier_store(&tcp->shutdown_count, 0); tcp->em_fd = em_fd; grpc_slice_buffer_init(&tcp->last_read_buffer); diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index 82f87e769bf..acdf42eae34 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -320,7 +320,7 @@ struct cq_callback_data { /* Completion queue structure */ struct grpc_completion_queue { /** Once owning_refs drops to zero, we will destroy the cq */ - gpr_refcount owning_refs; + grpc_core::RefCount owning_refs; gpr_mu* mu; @@ -518,7 +518,7 @@ grpc_completion_queue* grpc_completion_queue_create_internal( cq->poller_vtable = poller_vtable; /* One for destroy(), one for pollset_shutdown */ - gpr_ref_init(&cq->owning_refs, 2); + new (&cq->owning_refs) grpc_core::RefCount(2); poller_vtable->init(POLLSET_FROM_CQ(cq), &cq->mu); vtable->init(DATA_FROM_CQ(cq), shutdown_callback); @@ -573,16 +573,13 @@ int grpc_get_cq_poll_num(grpc_completion_queue* cq) { #ifndef NDEBUG void grpc_cq_internal_ref(grpc_completion_queue* cq, const char* reason, const char* file, int line) { - if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_cq_refcount)) { - gpr_atm val = gpr_atm_no_barrier_load(&cq->owning_refs.count); - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "CQ:%p ref %" PRIdPTR " -> %" PRIdPTR " %s", cq, val, val + 1, - reason); - } + grpc_core::DebugLocation debug_location(file, line); #else void grpc_cq_internal_ref(grpc_completion_queue* cq) { + grpc_core::DebugLocation debug_location; + const char* reason = nullptr; #endif - gpr_ref(&cq->owning_refs); + cq->owning_refs.Ref(debug_location, reason); } static void on_pollset_shutdown_done(void* arg, grpc_error* error) { @@ -593,16 +590,13 @@ static void on_pollset_shutdown_done(void* arg, grpc_error* error) { #ifndef NDEBUG void grpc_cq_internal_unref(grpc_completion_queue* cq, const char* reason, const char* file, int line) { - if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_cq_refcount)) { - gpr_atm val = gpr_atm_no_barrier_load(&cq->owning_refs.count); - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "CQ:%p unref %" PRIdPTR " -> %" PRIdPTR " %s", cq, val, val - 1, - reason); - } + grpc_core::DebugLocation debug_location(file, line); #else void grpc_cq_internal_unref(grpc_completion_queue* cq) { + grpc_core::DebugLocation debug_location; + const char* reason = nullptr; #endif - if (gpr_unref(&cq->owning_refs)) { + if (GPR_UNLIKELY(cq->owning_refs.Unref(debug_location, reason))) { cq->vtable->destroy(DATA_FROM_CQ(cq)); cq->poller_vtable->destroy(POLLSET_FROM_CQ(cq)); #ifndef NDEBUG diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index db2d291bc59..f344b32d7a6 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -256,7 +256,7 @@ struct grpc_server { listener* listeners; int listeners_destroyed; - gpr_refcount internal_refcount; + grpc_core::RefCount internal_refcount; /** when did we print the last shutdown progress message */ gpr_timespec last_shutdown_message_time; @@ -400,9 +400,7 @@ static void request_matcher_kill_requests(grpc_server* server, * server proper */ -static void server_ref(grpc_server* server) { - gpr_ref(&server->internal_refcount); -} +static void server_ref(grpc_server* server) { server->internal_refcount.Ref(); } static void server_delete(grpc_server* server) { registered_method* rm; @@ -434,7 +432,7 @@ static void server_delete(grpc_server* server) { } static void server_unref(grpc_server* server) { - if (gpr_unref(&server->internal_refcount)) { + if (GPR_UNLIKELY(server->internal_refcount.Unref())) { server_delete(server); } } @@ -1031,7 +1029,7 @@ grpc_server* grpc_server_create(const grpc_channel_args* args, void* reserved) { gpr_cv_init(&server->starting_cv); /* decremented by grpc_server_destroy */ - gpr_ref_init(&server->internal_refcount, 1); + new (&server->internal_refcount) grpc_core::RefCount(); server->root_channel_data.next = server->root_channel_data.prev = &server->root_channel_data; From 820a0892ac1e3ff954d0309e9fd0ead2688ca3e9 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 7 Aug 2019 17:00:59 -0700 Subject: [PATCH 1144/1555] Updated comments (notice) on tvtests --- src/objective-c/tests/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/tests/BUILD b/src/objective-c/tests/BUILD index 0817bbdd6c7..5d8042ca20a 100644 --- a/src/objective-c/tests/BUILD +++ b/src/objective-c/tests/BUILD @@ -219,7 +219,7 @@ macos_unit_test( ] ) -# c-ares does not support tvOS CPU architecture with Bazel yet +# bazel run tvos_unit_test is not yet supported by xctestrunner tvos_unit_test( name = "TvTests", minimum_os_version = "10.0", From c81dfd91dedd0828c89fe2b185c2e11c6e153e7f Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 7 Aug 2019 17:01:37 -0700 Subject: [PATCH 1145/1555] Added cpu architecture for tvos and watchos --- third_party/cares/cares.BUILD | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/third_party/cares/cares.BUILD b/third_party/cares/cares.BUILD index 78a4590c3e0..596dd06f88e 100644 --- a/third_party/cares/cares.BUILD +++ b/third_party/cares/cares.BUILD @@ -44,6 +44,36 @@ config_setting( values = {"cpu": "ios_arm64"}, ) +config_setting( + name = "tvos_x86_64", + values = {"cpu": "tvos_x86_64"}, +) + +config_setting( + name = "tvos_arm64", + values = {"cpu": "tvos_arm64"} +) + +config_setting( + name = "watchos_i386", + values = {"cpu": "watchos_i386"}, +) + +config_setting( + name = "watchos_x86_64", + values = {"cpu": "watchos_x86_64"} +) + +config_setting( + name = "watchos_armv7k", + values = {"cpu": "watchos_armv7k"}, +) + +config_setting( + name = "watchos_arm64_32", + values = {"cpu": "watchos_arm64_32"} +) + genrule( name = "ares_build_h", srcs = ["@com_github_grpc_grpc//third_party/cares:ares_build.h"], @@ -58,6 +88,12 @@ genrule( ":ios_armv7": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"], ":ios_armv7s": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"], ":ios_arm64": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"], + ":tvos_x86_64": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"], + ":tvos_arm64": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"], + ":watchos_i386": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"], + ":watchos_x86_64": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"], + ":watchos_armv7k": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"], + ":watchos_arm64_32": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"], ":darwin": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"], ":darwin_x86_64": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"], ":windows": ["@com_github_grpc_grpc//third_party/cares:config_windows/ares_config.h"], From ddf3f7ffb1c3d877e09118fb41a17a7b3619b238 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 7 Aug 2019 17:26:06 -0700 Subject: [PATCH 1146/1555] Experimentally changed non-framework builds to bazel build Experimentally run Unit/MacTests with Bazel --- src/objective-c/tests/build_one_example.sh | 69 ++++++++++++--------- src/objective-c/tests/run_one_test_bazel.sh | 44 +++++++++++++ tools/run_tests/run_tests.py | 4 +- 3 files changed, 84 insertions(+), 33 deletions(-) create mode 100755 src/objective-c/tests/run_one_test_bazel.sh diff --git a/src/objective-c/tests/build_one_example.sh b/src/objective-c/tests/build_one_example.sh index caa048e258b..0a62008f8de 100755 --- a/src/objective-c/tests/build_one_example.sh +++ b/src/objective-c/tests/build_one_example.sh @@ -29,36 +29,43 @@ cd `dirname $0`/../../.. cd $EXAMPLE_PATH -# clean the directory -rm -rf Pods -rm -rf *.xcworkspace -rm -f Podfile.lock - -pod install - -set -o pipefail -XCODEBUILD_FILTER='(^CompileC |^Ld |^.*clang |^ *cd |^ *export |^Libtool |^.*libtool |^CpHeader |^ *builtin-copy )' -if [ "$SCHEME" == "tvOS-sample" ]; then - xcodebuild \ - build \ - -workspace *.xcworkspace \ - -scheme $SCHEME \ - -destination generic/platform=tvOS \ - -derivedDataPath Build/Build \ - CODE_SIGN_IDENTITY="" \ - CODE_SIGNING_REQUIRED=NO \ - | egrep -v "$XCODEBUILD_FILTER" \ - | egrep -v "^$" - +if [ "$FRAMEWORKS" == "NO" ]; then + if [ "$SCHEME" == "watchOS-sample-WatchKit-App" ]; then + SCHEME="watchOS-sample" + fi + cd .. + ../../../tools/bazel build $SCHEME else - xcodebuild \ - build \ - -workspace *.xcworkspace \ - -scheme $SCHEME \ - -destination generic/platform=iOS \ - -derivedDataPath Build/Build \ - CODE_SIGN_IDENTITY="" \ - CODE_SIGNING_REQUIRED=NO \ - | egrep -v "$XCODEBUILD_FILTER" \ - | egrep -v "^$" - -fi + # clean the directory + rm -rf Pods + rm -rf *.xcworkspace + rm -f Podfile.lock + pod install + + set -o pipefail + XCODEBUILD_FILTER='(^CompileC |^Ld |^.*clang |^ *cd |^ *export |^Libtool |^.*libtool |^CpHeader |^ *builtin-copy )' + if [ "$SCHEME" == "tvOS-sample" ]; then + xcodebuild \ + build \ + -workspace *.xcworkspace \ + -scheme $SCHEME \ + -destination generic/platform=tvOS \ + -derivedDataPath Build/Build \ + CODE_SIGN_IDENTITY="" \ + CODE_SIGNING_REQUIRED=NO \ + | egrep -v "$XCODEBUILD_FILTER" \ + | egrep -v "^$" - + else + xcodebuild \ + build \ + -workspace *.xcworkspace \ + -scheme $SCHEME \ + -destination generic/platform=iOS \ + -derivedDataPath Build/Build \ + CODE_SIGN_IDENTITY="" \ + CODE_SIGNING_REQUIRED=NO \ + | egrep -v "$XCODEBUILD_FILTER" \ + | egrep -v "^$" - + fi +fi diff --git a/src/objective-c/tests/run_one_test_bazel.sh b/src/objective-c/tests/run_one_test_bazel.sh new file mode 100755 index 00000000000..41ffa21490c --- /dev/null +++ b/src/objective-c/tests/run_one_test_bazel.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Don't run this script standalone. Instead, run from the repository root: +# ./tools/run_tests/run_tests.py -l objc + +set -ev + +cd $(dirname $0) + +BINDIR=../../../bins/$CONFIG + +[ -f $BINDIR/interop_server ] || { + echo >&2 "Can't find the test server. Make sure run_tests.py is making" \ + "interop_server before calling this script." + exit 1 +} + +[ -z "$(ps aux |egrep 'port_server\.py.*-p\s32766')" ] && { + echo >&2 "Can't find the port server. Start port server with tools/run_tests/start_port_server.py." + exit 1 +} + +PLAIN_PORT=$(curl localhost:32766/get) +TLS_PORT=$(curl localhost:32766/get) + +$BINDIR/interop_server --port=$PLAIN_PORT --max_send_message_size=8388608 & +$BINDIR/interop_server --port=$TLS_PORT --max_send_message_size=8388608 --use_tls & + +trap 'kill -9 `jobs -p` ; echo "EXIT TIME: $(date)"' EXIT + +../../../tools/bazel run $SCHEME \ No newline at end of file diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index d3b028d4590..1cbf50e5264 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1150,7 +1150,7 @@ class ObjCLanguage(object): environ=_FORCE_ENVIRON_FOR_WRAPPERS)) out.append( self.config.job_spec( - ['src/objective-c/tests/run_one_test.sh'], + ['src/objective-c/tests/run_one_test_bazel.sh'], timeout_seconds=60 * 60, shortname='ios-test-unittests', cpu_cost=1e6, @@ -1184,7 +1184,7 @@ class ObjCLanguage(object): environ=_FORCE_ENVIRON_FOR_WRAPPERS)) out.append( self.config.job_spec( - ['src/objective-c/tests/run_one_test.sh'], + ['src/objective-c/tests/run_one_test_bazel.sh'], timeout_seconds=60 * 60, shortname='mac-test-basictests', cpu_cost=1e6, From a1c5c6053ed5e65b4f92f6f69bfdd83b3df72d50 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 7 Aug 2019 17:49:02 -0700 Subject: [PATCH 1147/1555] Added upb to python manifest --- PYTHON-MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/PYTHON-MANIFEST.in b/PYTHON-MANIFEST.in index 544fefbc487..f3ef08c8263 100644 --- a/PYTHON-MANIFEST.in +++ b/PYTHON-MANIFEST.in @@ -8,6 +8,7 @@ graft third_party/address_sorting graft third_party/boringssl graft third_party/cares graft third_party/nanopb +graft third_party/upb graft third_party/zlib include src/python/grpcio/_parallel_compile_patch.py include src/python/grpcio/_spawn_patch.py From dcd544451a60047ab35cc6d01e342a698881b59b Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Thu, 1 Aug 2019 15:53:19 -0700 Subject: [PATCH 1148/1555] Cache CH2 trace flag at hpack parser init. This removes what may be an atomic read for each header in each request. --- src/core/ext/transport/chttp2/transport/chttp2_transport.h | 1 + src/core/ext/transport/chttp2/transport/hpack_parser.cc | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.h b/src/core/ext/transport/chttp2/transport/chttp2_transport.h index c22cfb0ad7d..39574f93ec7 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.h +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.h @@ -29,6 +29,7 @@ extern grpc_core::TraceFlag grpc_http_trace; extern grpc_core::TraceFlag grpc_trace_http2_stream_state; extern grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_refcount; +extern grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_hpack_parser; extern bool g_flow_control_enabled; diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index 724c6c1bffc..be52d62be3a 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -38,6 +38,9 @@ #include "src/core/lib/surface/validate_metadata.h" #include "src/core/lib/transport/http2_errors.h" +grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_hpack_parser( + false, "chttp2_hpack_parser"); + typedef enum { NOT_BINARY, BINARY_BEGIN, @@ -643,7 +646,7 @@ static void GPR_ATTRIBUTE_NOINLINE on_hdr_log(grpc_mdelem md) { /* emission helpers */ template static grpc_error* on_hdr(grpc_chttp2_hpack_parser* p, grpc_mdelem md) { - if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_chttp2_hpack_parser)) { on_hdr_log(md); } if (do_add) { @@ -1021,7 +1024,7 @@ static grpc_error* parse_lithdr_nvridx_v(grpc_chttp2_hpack_parser* p, /* finish parsing a max table size change */ static grpc_error* finish_max_tbl_size(grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end) { - if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_chttp2_hpack_parser)) { gpr_log(GPR_INFO, "MAX TABLE SIZE: %d", p->index); } grpc_error* err = From 42737d976aa842d82afb7eea327a3ec6b97c8587 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 7 Aug 2019 19:37:19 -0700 Subject: [PATCH 1149/1555] Fixed prepare command to let bazel work after replacement --- gRPC-C++.podspec | 6 ++---- templates/gRPC-C++.podspec.template | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 7e728026e68..fd25efda82a 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -797,10 +797,8 @@ Pod::Spec.new do |s| end s.prepare_command = <<-END_OF_COMMAND - find src/cpp/ -type f ! -path '*.grpc_back' -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(pb(_.*)?\\.h)";#include ;g' - find src/cpp/ -type f -path '*.grpc_back' -print0 | xargs -0 rm - find src/core/ -type f ! -path '*.grpc_back' -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(pb(_.*)?\\.h)";#include ;g' - find src/core/ -type f -path '*.grpc_back' -print0 | xargs -0 rm + sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS==1\\\n #include \\\n#else\\\n #include "\\1"\\\n#endif;g' $(find src/core -type f -print | xargs grep -H -c '#include \\\n#else\\\n #include "\\1"\\\n#endif;g' $(find src/cpp -type f -print | xargs grep -H -c '#include ;g' - find src/cpp/ -type f -path '*.grpc_back' -print0 | xargs -0 rm - find src/core/ -type f ! -path '*.grpc_back' -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(pb(_.*)?\\.h)";#include ;g' - find src/core/ -type f -path '*.grpc_back' -print0 | xargs -0 rm + sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS==1\\\n #include \\\n#else\\\n #include "\\1"\\\n#endif;g' $(find src/core -type f -print | xargs grep -H -c '#include \\\n#else\\\n #include "\\1"\\\n#endif;g' $(find src/cpp -type f -print | xargs grep -H -c '#include Date: Wed, 7 Aug 2019 22:21:50 -0700 Subject: [PATCH 1150/1555] Added upb *.inc to python manifest --- PYTHON-MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PYTHON-MANIFEST.in b/PYTHON-MANIFEST.in index f3ef08c8263..aa044d84074 100644 --- a/PYTHON-MANIFEST.in +++ b/PYTHON-MANIFEST.in @@ -1,4 +1,4 @@ -recursive-include src/python/grpcio/grpc *.c *.h *.py *.pyx *.pxd *.pxi *.python *.pem +recursive-include src/python/grpcio/grpc *.c *.h *.inc *.py *.pyx *.pxd *.pxi *.python *.pem recursive-exclude src/python/grpcio/grpc/_cython *.so *.pyd graft src/python/grpcio/grpcio.egg-info graft src/core From 79f191114e291f0a7874370388f32fa6bced4f5f Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Wed, 7 Aug 2019 22:43:45 -0700 Subject: [PATCH 1151/1555] Use EDS in xds LB policy --- BUILD | 152 ++++- BUILD.gn | 52 +- CMakeLists.txt | 65 +- Makefile | 80 ++- build.yaml | 93 ++- config.m4 | 40 +- config.w32 | 49 +- gRPC-C++.podspec | 26 +- gRPC-Core.podspec | 78 ++- grpc.gemspec | 52 +- grpc.gyp | 55 +- package.xml | 52 +- .../grpc/lb/v1/google/protobuf/duration.pb.c | 19 - .../grpc/lb/v1/google/protobuf/duration.pb.h | 54 -- .../grpc/lb/v1/google/protobuf/timestamp.pb.c | 19 - .../grpc/lb/v1/google/protobuf/timestamp.pb.h | 54 -- .../proto/grpc/lb/v1/load_balancer.pb.c | 89 --- .../proto/grpc/lb/v1/load_balancer.pb.h | 164 ----- .../client_channel/lb_policy/xds/xds.cc | 438 ++++--------- .../lb_policy/xds/xds_load_balancer_api.cc | 497 +++++++------- .../lb_policy/xds/xds_load_balancer_api.h | 139 ++-- src/core/lib/transport/static_metadata.cc | 613 +++++++++--------- src/core/lib/transport/static_metadata.h | 149 ++--- src/proto/grpc/lb/v2/BUILD | 31 + src/proto/grpc/lb/v2/xds_for_test.proto | 553 ++++++++++++++++ src/python/grpcio/grpc_core_dependencies.py | 26 +- test/core/end2end/fuzzers/hpack.dictionary | 1 + test/cpp/end2end/BUILD | 8 +- test/cpp/end2end/xds_end2end_test.cc | 141 ++-- tools/codegen/core/gen_static_metadata.py | 1 + tools/distrib/check_nanopb_output.sh | 26 - tools/doxygen/Doxyfile.core.internal | 52 +- .../generated/sources_and_headers.json | 176 ++++- 33 files changed, 2357 insertions(+), 1687 deletions(-) delete mode 100644 src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c delete mode 100644 src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h delete mode 100644 src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c delete mode 100644 src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h delete mode 100644 src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c delete mode 100644 src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h create mode 100644 src/proto/grpc/lb/v2/BUILD create mode 100644 src/proto/grpc/lb/v2/xds_for_test.proto diff --git a/BUILD b/BUILD index 0f3b426ff06..7b7b4499a26 100644 --- a/BUILD +++ b/BUILD @@ -1192,24 +1192,6 @@ grpc_cc_library( ], ) -grpc_cc_library( - name = "grpclb_proto", - srcs = [ - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c", - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c", - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c", - ], - hdrs = [ - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h", - ], - external_deps = [ - "nanopb", - ], - language = "c++", -) - grpc_cc_library( name = "grpc_lb_policy_grpclb", srcs = [ @@ -1230,8 +1212,8 @@ grpc_cc_library( deps = [ "grpc_base", "grpc_client_channel", - "grpc_resolver_fake", "grpc_lb_upb", + "grpc_resolver_fake", ], ) @@ -1255,9 +1237,9 @@ grpc_cc_library( deps = [ "grpc_base", "grpc_client_channel", + "grpc_lb_upb", "grpc_resolver_fake", "grpc_secure", - "grpc_lb_upb", ], ) @@ -1280,10 +1262,11 @@ grpc_cc_library( ], language = "c++", deps = [ + "envoy_ads_upb", "grpc_base", "grpc_client_channel", + "grpc_lb_upb", "grpc_resolver_fake", - "grpclb_proto", ], ) @@ -1306,11 +1289,12 @@ grpc_cc_library( ], language = "c++", deps = [ + "envoy_ads_upb", "grpc_base", "grpc_client_channel", + "grpc_lb_upb", "grpc_resolver_fake", "grpc_secure", - "grpclb_proto", ], ) @@ -1979,8 +1963,8 @@ grpc_cc_library( language = "c++", public_hdrs = GRPCXX_PUBLIC_HDRS, deps = [ - "grpc++_codegen_base", "grpc", + "grpc++_codegen_base", "grpc_health_upb", ], ) @@ -1993,8 +1977,8 @@ grpc_cc_library( public_hdrs = GRPCXX_PUBLIC_HDRS, deps = [ "grpc++_codegen_base", - "grpc_unsecure", "grpc_health_upb", + "grpc_unsecure", ], ) @@ -2256,7 +2240,9 @@ grpc_cc_library( ], ) -# Once upb code-gen issue is resolved, use this. +# Once upb code-gen issue is resolved, use the targets commented below to replace the ones using +# upb-generated files. + # grpc_upb_proto_library( # name = "upb_load_report", # deps = ["@envoy_api//envoy/api/v2/endpoint:load_report_export"], @@ -2297,6 +2283,112 @@ grpc_cc_library( # ], # ) +grpc_cc_library( + name = "envoy_ads_upb", + srcs = [ + "src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/cds.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/eds.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c", + "src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c", + "src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c", + ], + hdrs = [ + "src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/cds.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/eds.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h", + "src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h", + "src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h", + ], + external_deps = [ + "upb_lib", + ], + language = "c++", + deps = [ + ":envoy_core_upb", + ":envoy_type_upb", + ":google_api_upb", + ":proto_gen_validate_upb", + ], +) + +grpc_cc_library( + name = "envoy_core_upb", + srcs = [ + "src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c", + ], + hdrs = [ + "src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h", + ], + external_deps = [ + "upb_lib", + ], + language = "c++", + deps = [ + ":envoy_type_upb", + ":google_api_upb", + ":proto_gen_validate_upb", + ], +) + +grpc_cc_library( + name = "envoy_type_upb", + srcs = [ + "src/core/ext/upb-generated/envoy/type/percent.upb.c", + "src/core/ext/upb-generated/envoy/type/range.upb.c", + ], + hdrs = [ + "src/core/ext/upb-generated/envoy/type/percent.upb.h", + "src/core/ext/upb-generated/envoy/type/range.upb.h", + ], + external_deps = [ + "upb_lib", + ], + language = "c++", + deps = [ + ":google_api_upb", + ":proto_gen_validate_upb", + ], +) + +grpc_cc_library( + name = "proto_gen_validate_upb", + srcs = [ + "src/core/ext/upb-generated/gogoproto/gogo.upb.c", + "src/core/ext/upb-generated/validate/validate.upb.c", + ], + hdrs = [ + "src/core/ext/upb-generated/gogoproto/gogo.upb.h", + "src/core/ext/upb-generated/validate/validate.upb.h", + ], + external_deps = [ + "upb_lib", + ], + language = "c++", + deps = [ + ":google_api_upb", + ], +) + # Once upb code-gen issue is resolved, replace grpc_health_upb with this. # grpc_upb_proto_library( # name = "grpc_health_upb", @@ -2321,22 +2413,28 @@ grpc_cc_library( grpc_cc_library( name = "google_api_upb", srcs = [ + "src/core/ext/upb-generated/google/api/annotations.upb.c", + "src/core/ext/upb-generated/google/api/http.upb.c", "src/core/ext/upb-generated/google/protobuf/any.upb.c", - "src/core/ext/upb-generated/google/protobuf/duration.upb.c", "src/core/ext/upb-generated/google/protobuf/descriptor.upb.c", + "src/core/ext/upb-generated/google/protobuf/duration.upb.c", "src/core/ext/upb-generated/google/protobuf/empty.upb.c", "src/core/ext/upb-generated/google/protobuf/struct.upb.c", "src/core/ext/upb-generated/google/protobuf/timestamp.upb.c", "src/core/ext/upb-generated/google/protobuf/wrappers.upb.c", + "src/core/ext/upb-generated/google/rpc/status.upb.c", ], hdrs = [ + "src/core/ext/upb-generated/google/api/annotations.upb.h", + "src/core/ext/upb-generated/google/api/http.upb.h", "src/core/ext/upb-generated/google/protobuf/any.upb.h", - "src/core/ext/upb-generated/google/protobuf/duration.upb.h", "src/core/ext/upb-generated/google/protobuf/descriptor.upb.h", + "src/core/ext/upb-generated/google/protobuf/duration.upb.h", "src/core/ext/upb-generated/google/protobuf/empty.upb.h", "src/core/ext/upb-generated/google/protobuf/struct.upb.h", "src/core/ext/upb-generated/google/protobuf/timestamp.upb.h", "src/core/ext/upb-generated/google/protobuf/wrappers.upb.h", + "src/core/ext/upb-generated/google/rpc/status.upb.h", ], external_deps = [ "upb_lib", diff --git a/BUILD.gn b/BUILD.gn index 95857cc245c..e63f7d2f2f1 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -263,12 +263,6 @@ config("grpc_config") { "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h", "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc", "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c", - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c", - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c", - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h", "src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc", "src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc", "src/core/ext/filters/client_channel/lb_policy/subchannel_list.h", @@ -410,6 +404,48 @@ config("grpc_config") { "src/core/ext/transport/inproc/inproc_plugin.cc", "src/core/ext/transport/inproc/inproc_transport.cc", "src/core/ext/transport/inproc/inproc_transport.h", + "src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/cds.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/cds.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/eds.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/eds.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h", + "src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c", + "src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h", + "src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c", + "src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h", + "src/core/ext/upb-generated/envoy/type/percent.upb.c", + "src/core/ext/upb-generated/envoy/type/percent.upb.h", + "src/core/ext/upb-generated/envoy/type/range.upb.c", + "src/core/ext/upb-generated/envoy/type/range.upb.h", + "src/core/ext/upb-generated/gogoproto/gogo.upb.c", + "src/core/ext/upb-generated/gogoproto/gogo.upb.h", + "src/core/ext/upb-generated/google/api/annotations.upb.c", + "src/core/ext/upb-generated/google/api/annotations.upb.h", + "src/core/ext/upb-generated/google/api/http.upb.c", + "src/core/ext/upb-generated/google/api/http.upb.h", "src/core/ext/upb-generated/google/protobuf/any.upb.c", "src/core/ext/upb-generated/google/protobuf/any.upb.h", "src/core/ext/upb-generated/google/protobuf/descriptor.upb.c", @@ -424,10 +460,14 @@ config("grpc_config") { "src/core/ext/upb-generated/google/protobuf/timestamp.upb.h", "src/core/ext/upb-generated/google/protobuf/wrappers.upb.c", "src/core/ext/upb-generated/google/protobuf/wrappers.upb.h", + "src/core/ext/upb-generated/google/rpc/status.upb.c", + "src/core/ext/upb-generated/google/rpc/status.upb.h", "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c", "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h", "src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c", "src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h", + "src/core/ext/upb-generated/validate/validate.upb.c", + "src/core/ext/upb-generated/validate/validate.upb.h", "src/core/lib/avl/avl.cc", "src/core/lib/avl/avl.h", "src/core/lib/backoff/backoff.cc", diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c3c7d3feb0..b1c70db8fcf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1323,6 +1323,8 @@ add_library(grpc src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c + src/core/ext/upb-generated/google/api/annotations.upb.c + src/core/ext/upb-generated/google/api/http.upb.c src/core/ext/upb-generated/google/protobuf/any.upb.c src/core/ext/upb-generated/google/protobuf/descriptor.upb.c src/core/ext/upb-generated/google/protobuf/duration.upb.c @@ -1330,14 +1332,32 @@ add_library(grpc src/core/ext/upb-generated/google/protobuf/struct.upb.c src/core/ext/upb-generated/google/protobuf/timestamp.upb.c src/core/ext/upb-generated/google/protobuf/wrappers.upb.c + src/core/ext/upb-generated/google/rpc/status.upb.c src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc src/core/ext/filters/client_channel/lb_policy/xds/xds.cc src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c + src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c + src/core/ext/upb-generated/envoy/api/v2/cds.upb.c + src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c + src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c + src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c + src/core/ext/upb-generated/envoy/api/v2/eds.upb.c + src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c + src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c + src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c + src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c + src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c + src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c + src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c + src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c + src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c + src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c + src/core/ext/upb-generated/envoy/type/percent.upb.c + src/core/ext/upb-generated/envoy/type/range.upb.c + src/core/ext/upb-generated/gogoproto/gogo.upb.c + src/core/ext/upb-generated/validate/validate.upb.c src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -2804,6 +2824,8 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c + src/core/ext/upb-generated/google/api/annotations.upb.c + src/core/ext/upb-generated/google/api/http.upb.c src/core/ext/upb-generated/google/protobuf/any.upb.c src/core/ext/upb-generated/google/protobuf/descriptor.upb.c src/core/ext/upb-generated/google/protobuf/duration.upb.c @@ -2811,16 +2833,31 @@ add_library(grpc_unsecure src/core/ext/upb-generated/google/protobuf/struct.upb.c src/core/ext/upb-generated/google/protobuf/timestamp.upb.c src/core/ext/upb-generated/google/protobuf/wrappers.upb.c + src/core/ext/upb-generated/google/rpc/status.upb.c src/core/ext/filters/client_channel/lb_policy/xds/xds.cc src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c - third_party/nanopb/pb_common.c - third_party/nanopb/pb_decode.c - third_party/nanopb/pb_encode.c + src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c + src/core/ext/upb-generated/envoy/api/v2/cds.upb.c + src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c + src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c + src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c + src/core/ext/upb-generated/envoy/api/v2/eds.upb.c + src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c + src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c + src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c + src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c + src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c + src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c + src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c + src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c + src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c + src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c + src/core/ext/upb-generated/envoy/type/percent.upb.c + src/core/ext/upb-generated/envoy/type/range.upb.c + src/core/ext/upb-generated/gogoproto/gogo.upb.c + src/core/ext/upb-generated/validate/validate.upb.c src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc src/core/ext/filters/census/grpc_context.cc @@ -17689,17 +17726,17 @@ endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(xds_end2end_test - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.grpc.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/xds_for_test.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/xds_for_test.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/xds_for_test.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/xds_for_test.grpc.pb.h test/cpp/end2end/xds_end2end_test.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc ) protobuf_generate_grpc_cpp( - src/proto/grpc/lb/v1/load_balancer.proto + src/proto/grpc/lb/v2/xds_for_test.proto ) target_include_directories(xds_end2end_test diff --git a/Makefile b/Makefile index 4ea6acdb4bf..51895104453 100644 --- a/Makefile +++ b/Makefile @@ -2704,6 +2704,22 @@ $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc: src/proto/grpc/lb/v1/lo $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin$(EXECUTABLE_SUFFIX) $< endif +ifeq ($(NO_PROTOC),true) +$(GENDIR)/src/proto/grpc/lb/v2/xds_for_test.pb.cc: protoc_dep_error +$(GENDIR)/src/proto/grpc/lb/v2/xds_for_test.grpc.pb.cc: protoc_dep_error +else + +$(GENDIR)/src/proto/grpc/lb/v2/xds_for_test.pb.cc: src/proto/grpc/lb/v2/xds_for_test.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) + $(E) "[PROTOC] Generating protobuf CC file from $<" + $(Q) mkdir -p `dirname $@` + $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --cpp_out=$(GENDIR) $< + +$(GENDIR)/src/proto/grpc/lb/v2/xds_for_test.grpc.pb.cc: src/proto/grpc/lb/v2/xds_for_test.proto $(GENDIR)/src/proto/grpc/lb/v2/xds_for_test.pb.cc $(PROTOBUF_DEP) $(PROTOC_PLUGINS) + $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<" + $(Q) mkdir -p `dirname $@` + $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin$(EXECUTABLE_SUFFIX) $< +endif + ifeq ($(NO_PROTOC),true) $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc: protoc_dep_error @@ -3814,6 +3830,8 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \ src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ + src/core/ext/upb-generated/google/api/annotations.upb.c \ + src/core/ext/upb-generated/google/api/http.upb.c \ src/core/ext/upb-generated/google/protobuf/any.upb.c \ src/core/ext/upb-generated/google/protobuf/descriptor.upb.c \ src/core/ext/upb-generated/google/protobuf/duration.upb.c \ @@ -3821,14 +3839,32 @@ LIBGRPC_SRC = \ src/core/ext/upb-generated/google/protobuf/struct.upb.c \ src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ + src/core/ext/upb-generated/google/rpc/status.upb.c \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc \ - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c \ - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c \ - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ + src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/cds.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/eds.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c \ + src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c \ + src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c \ + src/core/ext/upb-generated/envoy/type/percent.upb.c \ + src/core/ext/upb-generated/envoy/type/range.upb.c \ + src/core/ext/upb-generated/gogoproto/gogo.upb.c \ + src/core/ext/upb-generated/validate/validate.upb.c \ src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc \ src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc \ @@ -5219,6 +5255,8 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \ src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ + src/core/ext/upb-generated/google/api/annotations.upb.c \ + src/core/ext/upb-generated/google/api/http.upb.c \ src/core/ext/upb-generated/google/protobuf/any.upb.c \ src/core/ext/upb-generated/google/protobuf/descriptor.upb.c \ src/core/ext/upb-generated/google/protobuf/duration.upb.c \ @@ -5226,16 +5264,31 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/upb-generated/google/protobuf/struct.upb.c \ src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ + src/core/ext/upb-generated/google/rpc/status.upb.c \ src/core/ext/filters/client_channel/lb_policy/xds/xds.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc \ - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c \ - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c \ - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ - third_party/nanopb/pb_common.c \ - third_party/nanopb/pb_decode.c \ - third_party/nanopb/pb_encode.c \ + src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/cds.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/eds.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c \ + src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c \ + src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c \ + src/core/ext/upb-generated/envoy/type/percent.upb.c \ + src/core/ext/upb-generated/envoy/type/range.upb.c \ + src/core/ext/upb-generated/gogoproto/gogo.upb.c \ + src/core/ext/upb-generated/validate/validate.upb.c \ src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc \ src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc \ src/core/ext/filters/census/grpc_context.cc \ @@ -19749,7 +19802,7 @@ endif XDS_END2END_TEST_SRC = \ - $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc \ + $(GENDIR)/src/proto/grpc/lb/v2/xds_for_test.pb.cc $(GENDIR)/src/proto/grpc/lb/v2/xds_for_test.grpc.pb.cc \ test/cpp/end2end/xds_end2end_test.cc \ XDS_END2END_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(XDS_END2END_TEST_SRC)))) @@ -19781,7 +19834,7 @@ endif endif -$(OBJDIR)/$(CONFIG)/src/proto/grpc/lb/v1/load_balancer.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(OBJDIR)/$(CONFIG)/src/proto/grpc/lb/v2/xds_for_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OBJDIR)/$(CONFIG)/test/cpp/end2end/xds_end2end_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -19792,7 +19845,7 @@ ifneq ($(NO_DEPS),true) -include $(XDS_END2END_TEST_OBJS:.o=.dep) endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/end2end/xds_end2end_test.o: $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/end2end/xds_end2end_test.o: $(GENDIR)/src/proto/grpc/lb/v2/xds_for_test.pb.cc $(GENDIR)/src/proto/grpc/lb/v2/xds_for_test.grpc.pb.cc PUBLIC_HEADERS_MUST_BE_C89_SRC = \ @@ -22567,6 +22620,9 @@ test/cpp/util/string_ref_helper.cc: $(OPENSSL_DEP) test/cpp/util/subprocess.cc: $(OPENSSL_DEP) test/cpp/util/test_config_cc.cc: $(OPENSSL_DEP) test/cpp/util/test_credentials_provider.cc: $(OPENSSL_DEP) +third_party/nanopb/pb_common.c: $(OPENSSL_DEP) +third_party/nanopb/pb_decode.c: $(OPENSSL_DEP) +third_party/nanopb/pb_encode.c: $(OPENSSL_DEP) endif .PHONY: all strip tools dep_error openssl_dep_error openssl_dep_message git_update stop buildtests buildtests_c buildtests_cxx test test_c test_cxx install install_c install_cxx install-headers install-headers_c install-headers_cxx install-shared install-shared_c install-shared_cxx install-static install-static_c install-static_cxx strip strip-shared strip-static strip_c strip-shared_c strip-static_c strip_cxx strip-shared_cxx strip-static_cxx dep_c dep_cxx bins_dep_c bins_dep_cxx clean diff --git a/build.yaml b/build.yaml index 24da28e2591..a18b916ec66 100644 --- a/build.yaml +++ b/build.yaml @@ -122,8 +122,67 @@ filegroups: - test/core/util/cmdline.cc uses: - gpr_base_headers +- name: envoy_ads_upb + headers: + - src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h + - src/core/ext/upb-generated/envoy/api/v2/cds.upb.h + - src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h + - src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h + - src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h + - src/core/ext/upb-generated/envoy/api/v2/eds.upb.h + - src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h + - src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h + - src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h + - src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h + src: + - src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c + - src/core/ext/upb-generated/envoy/api/v2/cds.upb.c + - src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c + - src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c + - src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c + - src/core/ext/upb-generated/envoy/api/v2/eds.upb.c + - src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c + - src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c + - src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c + - src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c + uses: + - envoy_core_upb + - envoy_type_upb + - google_api_upb + - proto_gen_validate_upb +- name: envoy_core_upb + headers: + - src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h + - src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h + - src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h + - src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h + - src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h + - src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h + src: + - src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c + - src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c + - src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c + - src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c + - src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c + - src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c + uses: + - envoy_type_upb + - google_api_upb + - proto_gen_validate_upb +- name: envoy_type_upb + headers: + - src/core/ext/upb-generated/envoy/type/percent.upb.h + - src/core/ext/upb-generated/envoy/type/range.upb.h + src: + - src/core/ext/upb-generated/envoy/type/percent.upb.c + - src/core/ext/upb-generated/envoy/type/range.upb.c + uses: + - google_api_upb + - proto_gen_validate_upb - name: google_api_upb headers: + - src/core/ext/upb-generated/google/api/annotations.upb.h + - src/core/ext/upb-generated/google/api/http.upb.h - src/core/ext/upb-generated/google/protobuf/any.upb.h - src/core/ext/upb-generated/google/protobuf/descriptor.upb.h - src/core/ext/upb-generated/google/protobuf/duration.upb.h @@ -131,7 +190,10 @@ filegroups: - src/core/ext/upb-generated/google/protobuf/struct.upb.h - src/core/ext/upb-generated/google/protobuf/timestamp.upb.h - src/core/ext/upb-generated/google/protobuf/wrappers.upb.h + - src/core/ext/upb-generated/google/rpc/status.upb.h src: + - src/core/ext/upb-generated/google/api/annotations.upb.c + - src/core/ext/upb-generated/google/api/http.upb.c - src/core/ext/upb-generated/google/protobuf/any.upb.c - src/core/ext/upb-generated/google/protobuf/descriptor.upb.c - src/core/ext/upb-generated/google/protobuf/duration.upb.c @@ -139,6 +201,7 @@ filegroups: - src/core/ext/upb-generated/google/protobuf/struct.upb.c - src/core/ext/upb-generated/google/protobuf/timestamp.upb.c - src/core/ext/upb-generated/google/protobuf/wrappers.upb.c + - src/core/ext/upb-generated/google/rpc/status.upb.c - name: gpr_base src: - src/core/lib/gpr/alloc.cc @@ -778,11 +841,11 @@ filegroups: - src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc plugin: grpc_lb_policy_xds uses: + - envoy_ads_upb - grpc_base - grpc_client_channel - grpc_resolver_fake - - grpclb_proto - - nanopb + - grpc_lb_upb - name: grpc_lb_policy_xds_secure headers: - src/core/ext/filters/client_channel/lb_policy/xds/xds.h @@ -796,12 +859,12 @@ filegroups: - src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc plugin: grpc_lb_policy_xds uses: + - envoy_ads_upb - grpc_base - grpc_client_channel - grpc_resolver_fake - grpc_secure - - grpclb_proto - - nanopb + - grpc_lb_upb - name: grpc_lb_subchannel_list headers: - src/core/ext/filters/client_channel/lb_policy/subchannel_list.h @@ -1194,17 +1257,6 @@ filegroups: uses: - grpc_base - grpc_server_backward_compatibility -- name: grpclb_proto - headers: - - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h - - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h - - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h - src: - - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c - - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c - - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c - uses: - - nanopb - name: nanopb src: - third_party/nanopb/pb_common.c @@ -1218,6 +1270,15 @@ filegroups: - third_party/nanopb/pb_common.h - third_party/nanopb/pb_decode.h - third_party/nanopb/pb_encode.h +- name: proto_gen_validate_upb + headers: + - src/core/ext/upb-generated/gogoproto/gogo.upb.h + - src/core/ext/upb-generated/validate/validate.upb.h + src: + - src/core/ext/upb-generated/gogoproto/gogo.upb.c + - src/core/ext/upb-generated/validate/validate.upb.c + uses: + - google_api_upb - name: transport_security_test_lib build: test headers: @@ -5986,7 +6047,7 @@ targets: build: test language: c++ src: - - src/proto/grpc/lb/v1/load_balancer.proto + - src/proto/grpc/lb/v2/xds_for_test.proto - test/cpp/end2end/xds_end2end_test.cc deps: - grpc++_test_util diff --git a/config.m4 b/config.m4 index a23d65f8542..1bc581e6b67 100644 --- a/config.m4 +++ b/config.m4 @@ -402,6 +402,8 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \ src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ + src/core/ext/upb-generated/google/api/annotations.upb.c \ + src/core/ext/upb-generated/google/api/http.upb.c \ src/core/ext/upb-generated/google/protobuf/any.upb.c \ src/core/ext/upb-generated/google/protobuf/descriptor.upb.c \ src/core/ext/upb-generated/google/protobuf/duration.upb.c \ @@ -409,14 +411,32 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/upb-generated/google/protobuf/struct.upb.c \ src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ + src/core/ext/upb-generated/google/rpc/status.upb.c \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc \ - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c \ - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c \ - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ + src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/cds.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/eds.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c \ + src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c \ + src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c \ + src/core/ext/upb-generated/envoy/type/percent.upb.c \ + src/core/ext/upb-generated/envoy/type/range.upb.c \ + src/core/ext/upb-generated/gogoproto/gogo.upb.c \ + src/core/ext/upb-generated/validate/validate.upb.c \ src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc \ src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc \ @@ -709,8 +729,6 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/health) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/grpclb) - PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1) - PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/pick_first) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/round_robin) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/xds) @@ -737,9 +755,21 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/server/secure) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/transport) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/inproc) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/envoy/api/v2) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/envoy/api/v2/auth) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/envoy/api/v2/cluster) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/envoy/api/v2/core) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/envoy/api/v2/endpoint) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/envoy/service/discovery/v2) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/envoy/service/load_stats/v2) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/envoy/type) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/gogoproto) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/google/api) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/google/protobuf) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/google/rpc) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/src/proto/grpc/health/v1) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/src/proto/grpc/lb/v1) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/validate) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/avl) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/backoff) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/channel) diff --git a/config.w32 b/config.w32 index 27635b54544..52553fe5d5f 100644 --- a/config.w32 +++ b/config.w32 @@ -375,6 +375,8 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\grpclb_client_stats.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\load_balancer_api.cc " + "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\lb\\v1\\load_balancer.upb.c " + + "src\\core\\ext\\upb-generated\\google\\api\\annotations.upb.c " + + "src\\core\\ext\\upb-generated\\google\\api\\http.upb.c " + "src\\core\\ext\\upb-generated\\google\\protobuf\\any.upb.c " + "src\\core\\ext\\upb-generated\\google\\protobuf\\descriptor.upb.c " + "src\\core\\ext\\upb-generated\\google\\protobuf\\duration.upb.c " + @@ -382,14 +384,32 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\upb-generated\\google\\protobuf\\struct.upb.c " + "src\\core\\ext\\upb-generated\\google\\protobuf\\timestamp.upb.c " + "src\\core\\ext\\upb-generated\\google\\protobuf\\wrappers.upb.c " + + "src\\core\\ext\\upb-generated\\google\\rpc\\status.upb.c " + "src\\core\\ext\\filters\\client_channel\\resolver\\fake\\fake_resolver.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\xds\\xds.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\xds\\xds_channel_secure.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\xds\\xds_client_stats.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\xds\\xds_load_balancer_api.cc " + - "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto\\grpc\\lb\\v1\\google\\protobuf\\duration.pb.c " + - "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto\\grpc\\lb\\v1\\google\\protobuf\\timestamp.pb.c " + - "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto\\grpc\\lb\\v1\\load_balancer.pb.c " + + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\auth\\cert.upb.c " + + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\cds.upb.c " + + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\cluster\\circuit_breaker.upb.c " + + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\cluster\\outlier_detection.upb.c " + + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\discovery.upb.c " + + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\eds.upb.c " + + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\endpoint\\endpoint.upb.c " + + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\endpoint\\load_report.upb.c " + + "src\\core\\ext\\upb-generated\\envoy\\service\\discovery\\v2\\ads.upb.c " + + "src\\core\\ext\\upb-generated\\envoy\\service\\load_stats\\v2\\lrs.upb.c " + + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\core\\address.upb.c " + + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\core\\base.upb.c " + + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\core\\config_source.upb.c " + + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\core\\grpc_service.upb.c " + + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\core\\health_check.upb.c " + + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\core\\protocol.upb.c " + + "src\\core\\ext\\upb-generated\\envoy\\type\\percent.upb.c " + + "src\\core\\ext\\upb-generated\\envoy\\type\\range.upb.c " + + "src\\core\\ext\\upb-generated\\gogoproto\\gogo.upb.c " + + "src\\core\\ext\\upb-generated\\validate\\validate.upb.c " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\pick_first\\pick_first.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\round_robin\\round_robin.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\dns_resolver_ares.cc " + @@ -714,12 +734,6 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\health"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\lb_policy"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto\\grpc"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto\\grpc\\lb"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto\\grpc\\lb\\v1"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto\\grpc\\lb\\v1\\google"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\proto\\grpc\\lb\\v1\\google\\protobuf"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\lb_policy\\pick_first"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\lb_policy\\round_robin"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\lb_policy\\xds"); @@ -750,8 +764,24 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2\\transport"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\inproc"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\envoy"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\envoy\\api"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\envoy\\api\\v2"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\envoy\\api\\v2\\auth"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\envoy\\api\\v2\\cluster"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\envoy\\api\\v2\\core"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\envoy\\api\\v2\\endpoint"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\envoy\\service"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\envoy\\service\\discovery"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\envoy\\service\\discovery\\v2"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\envoy\\service\\load_stats"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\envoy\\service\\load_stats\\v2"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\envoy\\type"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\gogoproto"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\google"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\google\\api"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\google\\protobuf"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\google\\rpc"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc"); @@ -759,6 +789,7 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\health\\v1"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\lb"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\lb\\v1"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\validate"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\avl"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\backoff"); diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index b90a006e9b1..e0c8a570d48 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -587,6 +587,8 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h', 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h', + 'src/core/ext/upb-generated/google/api/annotations.upb.h', + 'src/core/ext/upb-generated/google/api/http.upb.h', 'src/core/ext/upb-generated/google/protobuf/any.upb.h', 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.h', 'src/core/ext/upb-generated/google/protobuf/duration.upb.h', @@ -594,13 +596,31 @@ Pod::Spec.new do |s| 'src/core/ext/upb-generated/google/protobuf/struct.upb.h', 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.h', 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.h', + 'src/core/ext/upb-generated/google/rpc/status.upb.h', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h', + 'src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/cds.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/eds.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h', + 'src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h', + 'src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h', + 'src/core/ext/upb-generated/envoy/type/percent.upb.h', + 'src/core/ext/upb-generated/envoy/type/range.upb.h', + 'src/core/ext/upb-generated/gogoproto/gogo.upb.h', + 'src/core/ext/upb-generated/validate/validate.upb.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 6ee74687c74..0d6a282a94a 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -543,6 +543,8 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h', 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h', + 'src/core/ext/upb-generated/google/api/annotations.upb.h', + 'src/core/ext/upb-generated/google/api/http.upb.h', 'src/core/ext/upb-generated/google/protobuf/any.upb.h', 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.h', 'src/core/ext/upb-generated/google/protobuf/duration.upb.h', @@ -550,13 +552,31 @@ Pod::Spec.new do |s| 'src/core/ext/upb-generated/google/protobuf/struct.upb.h', 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.h', 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.h', + 'src/core/ext/upb-generated/google/rpc/status.upb.h', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h', + 'src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/cds.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/eds.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h', + 'src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h', + 'src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h', + 'src/core/ext/upb-generated/envoy/type/percent.upb.h', + 'src/core/ext/upb-generated/envoy/type/range.upb.h', + 'src/core/ext/upb-generated/gogoproto/gogo.upb.h', + 'src/core/ext/upb-generated/validate/validate.upb.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', @@ -879,6 +899,8 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c', + 'src/core/ext/upb-generated/google/api/annotations.upb.c', + 'src/core/ext/upb-generated/google/api/http.upb.c', 'src/core/ext/upb-generated/google/protobuf/any.upb.c', 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.c', 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', @@ -886,14 +908,32 @@ Pod::Spec.new do |s| 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', + 'src/core/ext/upb-generated/google/rpc/status.upb.c', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', + 'src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/cds.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/eds.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c', + 'src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c', + 'src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c', + 'src/core/ext/upb-generated/envoy/type/percent.upb.c', + 'src/core/ext/upb-generated/envoy/type/range.upb.c', + 'src/core/ext/upb-generated/gogoproto/gogo.upb.c', + 'src/core/ext/upb-generated/validate/validate.upb.c', 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc', 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc', @@ -1232,6 +1272,8 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h', 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h', + 'src/core/ext/upb-generated/google/api/annotations.upb.h', + 'src/core/ext/upb-generated/google/api/http.upb.h', 'src/core/ext/upb-generated/google/protobuf/any.upb.h', 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.h', 'src/core/ext/upb-generated/google/protobuf/duration.upb.h', @@ -1239,13 +1281,31 @@ Pod::Spec.new do |s| 'src/core/ext/upb-generated/google/protobuf/struct.upb.h', 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.h', 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.h', + 'src/core/ext/upb-generated/google/rpc/status.upb.h', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h', + 'src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/cds.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/eds.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h', + 'src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h', + 'src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h', + 'src/core/ext/upb-generated/envoy/type/percent.upb.h', + 'src/core/ext/upb-generated/envoy/type/range.upb.h', + 'src/core/ext/upb-generated/gogoproto/gogo.upb.h', + 'src/core/ext/upb-generated/validate/validate.upb.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', diff --git a/grpc.gemspec b/grpc.gemspec index af2129350ef..2c658f48d80 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -476,6 +476,8 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h ) s.files += %w( src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/api/annotations.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/api/http.upb.h ) s.files += %w( src/core/ext/upb-generated/google/protobuf/any.upb.h ) s.files += %w( src/core/ext/upb-generated/google/protobuf/descriptor.upb.h ) s.files += %w( src/core/ext/upb-generated/google/protobuf/duration.upb.h ) @@ -483,13 +485,31 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/upb-generated/google/protobuf/struct.upb.h ) s.files += %w( src/core/ext/upb-generated/google/protobuf/timestamp.upb.h ) s.files += %w( src/core/ext/upb-generated/google/protobuf/wrappers.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/rpc/status.upb.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h ) - s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h ) - s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h ) - s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/cds.upb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/eds.upb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/type/percent.upb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/type/range.upb.h ) + s.files += %w( src/core/ext/upb-generated/gogoproto/gogo.upb.h ) + s.files += %w( src/core/ext/upb-generated/validate/validate.upb.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/subchannel_list.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h ) @@ -815,6 +835,8 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc ) s.files += %w( src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/api/annotations.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/api/http.upb.c ) s.files += %w( src/core/ext/upb-generated/google/protobuf/any.upb.c ) s.files += %w( src/core/ext/upb-generated/google/protobuf/descriptor.upb.c ) s.files += %w( src/core/ext/upb-generated/google/protobuf/duration.upb.c ) @@ -822,14 +844,32 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/upb-generated/google/protobuf/struct.upb.c ) s.files += %w( src/core/ext/upb-generated/google/protobuf/timestamp.upb.c ) s.files += %w( src/core/ext/upb-generated/google/protobuf/wrappers.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/rpc/status.upb.c ) s.files += %w( src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds.cc ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc ) - s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c ) - s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c ) - s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/cds.upb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/eds.upb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/type/percent.upb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/type/range.upb.c ) + s.files += %w( src/core/ext/upb-generated/gogoproto/gogo.upb.c ) + s.files += %w( src/core/ext/upb-generated/validate/validate.upb.c ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc ) diff --git a/grpc.gyp b/grpc.gyp index 040831ec4f3..5241a57007a 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -612,6 +612,8 @@ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c', + 'src/core/ext/upb-generated/google/api/annotations.upb.c', + 'src/core/ext/upb-generated/google/api/http.upb.c', 'src/core/ext/upb-generated/google/protobuf/any.upb.c', 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.c', 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', @@ -619,14 +621,32 @@ 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', + 'src/core/ext/upb-generated/google/rpc/status.upb.c', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', + 'src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/cds.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/eds.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c', + 'src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c', + 'src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c', + 'src/core/ext/upb-generated/envoy/type/percent.upb.c', + 'src/core/ext/upb-generated/envoy/type/range.upb.c', + 'src/core/ext/upb-generated/gogoproto/gogo.upb.c', + 'src/core/ext/upb-generated/validate/validate.upb.c', 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc', 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc', @@ -1425,6 +1445,8 @@ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c', + 'src/core/ext/upb-generated/google/api/annotations.upb.c', + 'src/core/ext/upb-generated/google/api/http.upb.c', 'src/core/ext/upb-generated/google/protobuf/any.upb.c', 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.c', 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', @@ -1432,16 +1454,31 @@ 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', + 'src/core/ext/upb-generated/google/rpc/status.upb.c', 'src/core/ext/filters/client_channel/lb_policy/xds/xds.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', - 'third_party/nanopb/pb_common.c', - 'third_party/nanopb/pb_decode.c', - 'third_party/nanopb/pb_encode.c', + 'src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/cds.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/eds.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c', + 'src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c', + 'src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c', + 'src/core/ext/upb-generated/envoy/type/percent.upb.c', + 'src/core/ext/upb-generated/envoy/type/range.upb.c', + 'src/core/ext/upb-generated/gogoproto/gogo.upb.c', + 'src/core/ext/upb-generated/validate/validate.upb.c', 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc', 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc', 'src/core/ext/filters/census/grpc_context.cc', diff --git a/package.xml b/package.xml index 5352a9f43d7..1e1bc3d4176 100644 --- a/package.xml +++ b/package.xml @@ -481,6 +481,8 @@ + + @@ -488,13 +490,31 @@ + - - - + + + + + + + + + + + + + + + + + + + + @@ -820,6 +840,8 @@ + + @@ -827,14 +849,32 @@ + - - - + + + + + + + + + + + + + + + + + + + + diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c b/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c deleted file mode 100644 index 131d9b7cae0..00000000000 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c +++ /dev/null @@ -1,19 +0,0 @@ -/* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.7-dev */ - -#include "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 -#error Regenerate this file with the current version of nanopb generator. -#endif - - - -const pb_field_t google_protobuf_Duration_fields[3] = { - PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, google_protobuf_Duration, seconds, seconds, 0), - PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, google_protobuf_Duration, nanos, seconds, 0), - PB_LAST_FIELD -}; - - -/* @@protoc_insertion_point(eof) */ diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h b/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h deleted file mode 100644 index 93070c65b83..00000000000 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.7-dev */ - -#ifndef PB_GOOGLE_PROTOBUF_DURATION_PB_H_INCLUDED -#define PB_GOOGLE_PROTOBUF_DURATION_PB_H_INCLUDED -#include "pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 -#error Regenerate this file with the current version of nanopb generator. -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Struct definitions */ -typedef struct _google_protobuf_Duration { - bool has_seconds; - int64_t seconds; - bool has_nanos; - int32_t nanos; -/* @@protoc_insertion_point(struct:google_protobuf_Duration) */ -} google_protobuf_Duration; - -/* Default values for struct fields */ - -/* Initializer values for message structs */ -#define google_protobuf_Duration_init_default {false, 0, false, 0} -#define google_protobuf_Duration_init_zero {false, 0, false, 0} - -/* Field tags (for use in manual encoding/decoding) */ -#define google_protobuf_Duration_seconds_tag 1 -#define google_protobuf_Duration_nanos_tag 2 - -/* Struct field encoding specification for nanopb */ -extern const pb_field_t google_protobuf_Duration_fields[3]; - -/* Maximum encoded size of messages (where known) */ -#define google_protobuf_Duration_size 22 - -/* Message IDs (where set with "msgid" option) */ -#ifdef PB_MSGID - -#define DURATION_MESSAGES \ - - -#endif - -#ifdef __cplusplus -} /* extern "C" */ -#endif -/* @@protoc_insertion_point(eof) */ - -#endif diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c b/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c deleted file mode 100644 index b6f8ffc5592..00000000000 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c +++ /dev/null @@ -1,19 +0,0 @@ -/* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.7-dev */ - -#include "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 -#error Regenerate this file with the current version of nanopb generator. -#endif - - - -const pb_field_t google_protobuf_Timestamp_fields[3] = { - PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, google_protobuf_Timestamp, seconds, seconds, 0), - PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, google_protobuf_Timestamp, nanos, seconds, 0), - PB_LAST_FIELD -}; - - -/* @@protoc_insertion_point(eof) */ diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h b/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h deleted file mode 100644 index 7f484815244..00000000000 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.7-dev */ - -#ifndef PB_GOOGLE_PROTOBUF_TIMESTAMP_PB_H_INCLUDED -#define PB_GOOGLE_PROTOBUF_TIMESTAMP_PB_H_INCLUDED -#include "pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 -#error Regenerate this file with the current version of nanopb generator. -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Struct definitions */ -typedef struct _google_protobuf_Timestamp { - bool has_seconds; - int64_t seconds; - bool has_nanos; - int32_t nanos; -/* @@protoc_insertion_point(struct:google_protobuf_Timestamp) */ -} google_protobuf_Timestamp; - -/* Default values for struct fields */ - -/* Initializer values for message structs */ -#define google_protobuf_Timestamp_init_default {false, 0, false, 0} -#define google_protobuf_Timestamp_init_zero {false, 0, false, 0} - -/* Field tags (for use in manual encoding/decoding) */ -#define google_protobuf_Timestamp_seconds_tag 1 -#define google_protobuf_Timestamp_nanos_tag 2 - -/* Struct field encoding specification for nanopb */ -extern const pb_field_t google_protobuf_Timestamp_fields[3]; - -/* Maximum encoded size of messages (where known) */ -#define google_protobuf_Timestamp_size 22 - -/* Message IDs (where set with "msgid" option) */ -#ifdef PB_MSGID - -#define TIMESTAMP_MESSAGES \ - - -#endif - -#ifdef __cplusplus -} /* extern "C" */ -#endif -/* @@protoc_insertion_point(eof) */ - -#endif diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c b/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c deleted file mode 100644 index f6538e1349f..00000000000 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +++ /dev/null @@ -1,89 +0,0 @@ -/* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.7-dev */ - -#include "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 -#error Regenerate this file with the current version of nanopb generator. -#endif - - - -const pb_field_t grpc_lb_v1_LoadBalanceRequest_fields[3] = { - PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, grpc_lb_v1_LoadBalanceRequest, initial_request, initial_request, &grpc_lb_v1_InitialLoadBalanceRequest_fields), - PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_lb_v1_LoadBalanceRequest, client_stats, initial_request, &grpc_lb_v1_ClientStats_fields), - PB_LAST_FIELD -}; - -const pb_field_t grpc_lb_v1_InitialLoadBalanceRequest_fields[2] = { - PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, grpc_lb_v1_InitialLoadBalanceRequest, name, name, 0), - PB_LAST_FIELD -}; - -const pb_field_t grpc_lb_v1_ClientStatsPerToken_fields[3] = { - PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, grpc_lb_v1_ClientStatsPerToken, load_balance_token, load_balance_token, 0), - PB_FIELD( 2, INT64 , OPTIONAL, STATIC , OTHER, grpc_lb_v1_ClientStatsPerToken, num_calls, load_balance_token, 0), - PB_LAST_FIELD -}; - -const pb_field_t grpc_lb_v1_ClientStats_fields[7] = { - PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, grpc_lb_v1_ClientStats, timestamp, timestamp, &google_protobuf_Timestamp_fields), - PB_FIELD( 2, INT64 , OPTIONAL, STATIC , OTHER, grpc_lb_v1_ClientStats, num_calls_started, timestamp, 0), - PB_FIELD( 3, INT64 , OPTIONAL, STATIC , OTHER, grpc_lb_v1_ClientStats, num_calls_finished, num_calls_started, 0), - PB_FIELD( 6, INT64 , OPTIONAL, STATIC , OTHER, grpc_lb_v1_ClientStats, num_calls_finished_with_client_failed_to_send, num_calls_finished, 0), - PB_FIELD( 7, INT64 , OPTIONAL, STATIC , OTHER, grpc_lb_v1_ClientStats, num_calls_finished_known_received, num_calls_finished_with_client_failed_to_send, 0), - PB_FIELD( 8, MESSAGE , REPEATED, CALLBACK, OTHER, grpc_lb_v1_ClientStats, calls_finished_with_drop, num_calls_finished_known_received, &grpc_lb_v1_ClientStatsPerToken_fields), - PB_LAST_FIELD -}; - -const pb_field_t grpc_lb_v1_LoadBalanceResponse_fields[3] = { - PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, grpc_lb_v1_LoadBalanceResponse, initial_response, initial_response, &grpc_lb_v1_InitialLoadBalanceResponse_fields), - PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_lb_v1_LoadBalanceResponse, server_list, initial_response, &grpc_lb_v1_ServerList_fields), - PB_LAST_FIELD -}; - -const pb_field_t grpc_lb_v1_InitialLoadBalanceResponse_fields[3] = { - PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, grpc_lb_v1_InitialLoadBalanceResponse, load_balancer_delegate, load_balancer_delegate, 0), - PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_lb_v1_InitialLoadBalanceResponse, client_stats_report_interval, load_balancer_delegate, &google_protobuf_Duration_fields), - PB_LAST_FIELD -}; - -const pb_field_t grpc_lb_v1_ServerList_fields[2] = { - PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, grpc_lb_v1_ServerList, servers, servers, &grpc_lb_v1_Server_fields), - PB_LAST_FIELD -}; - -const pb_field_t grpc_lb_v1_Server_fields[5] = { - PB_FIELD( 1, BYTES , OPTIONAL, STATIC , FIRST, grpc_lb_v1_Server, ip_address, ip_address, 0), - PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, grpc_lb_v1_Server, port, ip_address, 0), - PB_FIELD( 3, STRING , OPTIONAL, STATIC , OTHER, grpc_lb_v1_Server, load_balance_token, port, 0), - PB_FIELD( 4, BOOL , OPTIONAL, STATIC , OTHER, grpc_lb_v1_Server, drop, load_balance_token, 0), - PB_LAST_FIELD -}; - - -/* Check that field information fits in pb_field_t */ -#if !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_32BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in 8 or 16 bit - * field descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(grpc_lb_v1_LoadBalanceRequest, initial_request) < 65536 && pb_membersize(grpc_lb_v1_LoadBalanceRequest, client_stats) < 65536 && pb_membersize(grpc_lb_v1_ClientStats, timestamp) < 65536 && pb_membersize(grpc_lb_v1_ClientStats, calls_finished_with_drop) < 65536 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, initial_response) < 65536 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, server_list) < 65536 && pb_membersize(grpc_lb_v1_InitialLoadBalanceResponse, client_stats_report_interval) < 65536 && pb_membersize(grpc_lb_v1_ServerList, servers) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_grpc_lb_v1_LoadBalanceRequest_grpc_lb_v1_InitialLoadBalanceRequest_grpc_lb_v1_ClientStatsPerToken_grpc_lb_v1_ClientStats_grpc_lb_v1_LoadBalanceResponse_grpc_lb_v1_InitialLoadBalanceResponse_grpc_lb_v1_ServerList_grpc_lb_v1_Server) -#endif - -#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_16BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in the default - * 8 bit descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(grpc_lb_v1_LoadBalanceRequest, initial_request) < 256 && pb_membersize(grpc_lb_v1_LoadBalanceRequest, client_stats) < 256 && pb_membersize(grpc_lb_v1_ClientStats, timestamp) < 256 && pb_membersize(grpc_lb_v1_ClientStats, calls_finished_with_drop) < 256 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, initial_response) < 256 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, server_list) < 256 && pb_membersize(grpc_lb_v1_InitialLoadBalanceResponse, client_stats_report_interval) < 256 && pb_membersize(grpc_lb_v1_ServerList, servers) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_grpc_lb_v1_LoadBalanceRequest_grpc_lb_v1_InitialLoadBalanceRequest_grpc_lb_v1_ClientStatsPerToken_grpc_lb_v1_ClientStats_grpc_lb_v1_LoadBalanceResponse_grpc_lb_v1_InitialLoadBalanceResponse_grpc_lb_v1_ServerList_grpc_lb_v1_Server) -#endif - - -/* @@protoc_insertion_point(eof) */ diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h b/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h deleted file mode 100644 index a4ff516d8e1..00000000000 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +++ /dev/null @@ -1,164 +0,0 @@ -/* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.7-dev */ - -#ifndef PB_GRPC_LB_V1_LOAD_BALANCER_PB_H_INCLUDED -#define PB_GRPC_LB_V1_LOAD_BALANCER_PB_H_INCLUDED -#include "pb.h" -#include "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h" -#include "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 -#error Regenerate this file with the current version of nanopb generator. -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Struct definitions */ -typedef struct _grpc_lb_v1_ServerList { - pb_callback_t servers; -/* @@protoc_insertion_point(struct:grpc_lb_v1_ServerList) */ -} grpc_lb_v1_ServerList; - -typedef struct _grpc_lb_v1_ClientStats { - bool has_timestamp; - google_protobuf_Timestamp timestamp; - bool has_num_calls_started; - int64_t num_calls_started; - bool has_num_calls_finished; - int64_t num_calls_finished; - bool has_num_calls_finished_with_client_failed_to_send; - int64_t num_calls_finished_with_client_failed_to_send; - bool has_num_calls_finished_known_received; - int64_t num_calls_finished_known_received; - pb_callback_t calls_finished_with_drop; -/* @@protoc_insertion_point(struct:grpc_lb_v1_ClientStats) */ -} grpc_lb_v1_ClientStats; - -typedef struct _grpc_lb_v1_ClientStatsPerToken { - pb_callback_t load_balance_token; - bool has_num_calls; - int64_t num_calls; -/* @@protoc_insertion_point(struct:grpc_lb_v1_ClientStatsPerToken) */ -} grpc_lb_v1_ClientStatsPerToken; - -typedef struct _grpc_lb_v1_InitialLoadBalanceRequest { - bool has_name; - char name[128]; -/* @@protoc_insertion_point(struct:grpc_lb_v1_InitialLoadBalanceRequest) */ -} grpc_lb_v1_InitialLoadBalanceRequest; - -typedef struct _grpc_lb_v1_InitialLoadBalanceResponse { - bool has_load_balancer_delegate; - char load_balancer_delegate[64]; - bool has_client_stats_report_interval; - google_protobuf_Duration client_stats_report_interval; -/* @@protoc_insertion_point(struct:grpc_lb_v1_InitialLoadBalanceResponse) */ -} grpc_lb_v1_InitialLoadBalanceResponse; - -typedef PB_BYTES_ARRAY_T(16) grpc_lb_v1_Server_ip_address_t; -typedef struct _grpc_lb_v1_Server { - bool has_ip_address; - grpc_lb_v1_Server_ip_address_t ip_address; - bool has_port; - int32_t port; - bool has_load_balance_token; - char load_balance_token[50]; - bool has_drop; - bool drop; -/* @@protoc_insertion_point(struct:grpc_lb_v1_Server) */ -} grpc_lb_v1_Server; - -typedef struct _grpc_lb_v1_LoadBalanceRequest { - bool has_initial_request; - grpc_lb_v1_InitialLoadBalanceRequest initial_request; - bool has_client_stats; - grpc_lb_v1_ClientStats client_stats; -/* @@protoc_insertion_point(struct:grpc_lb_v1_LoadBalanceRequest) */ -} grpc_lb_v1_LoadBalanceRequest; - -typedef struct _grpc_lb_v1_LoadBalanceResponse { - bool has_initial_response; - grpc_lb_v1_InitialLoadBalanceResponse initial_response; - bool has_server_list; - grpc_lb_v1_ServerList server_list; -/* @@protoc_insertion_point(struct:grpc_lb_v1_LoadBalanceResponse) */ -} grpc_lb_v1_LoadBalanceResponse; - -/* Default values for struct fields */ - -/* Initializer values for message structs */ -#define grpc_lb_v1_LoadBalanceRequest_init_default {false, grpc_lb_v1_InitialLoadBalanceRequest_init_default, false, grpc_lb_v1_ClientStats_init_default} -#define grpc_lb_v1_InitialLoadBalanceRequest_init_default {false, ""} -#define grpc_lb_v1_ClientStatsPerToken_init_default {{{NULL}, NULL}, false, 0} -#define grpc_lb_v1_ClientStats_init_default {false, google_protobuf_Timestamp_init_default, false, 0, false, 0, false, 0, false, 0, {{NULL}, NULL}} -#define grpc_lb_v1_LoadBalanceResponse_init_default {false, grpc_lb_v1_InitialLoadBalanceResponse_init_default, false, grpc_lb_v1_ServerList_init_default} -#define grpc_lb_v1_InitialLoadBalanceResponse_init_default {false, "", false, google_protobuf_Duration_init_default} -#define grpc_lb_v1_ServerList_init_default {{{NULL}, NULL}} -#define grpc_lb_v1_Server_init_default {false, {0, {0}}, false, 0, false, "", false, 0} -#define grpc_lb_v1_LoadBalanceRequest_init_zero {false, grpc_lb_v1_InitialLoadBalanceRequest_init_zero, false, grpc_lb_v1_ClientStats_init_zero} -#define grpc_lb_v1_InitialLoadBalanceRequest_init_zero {false, ""} -#define grpc_lb_v1_ClientStatsPerToken_init_zero {{{NULL}, NULL}, false, 0} -#define grpc_lb_v1_ClientStats_init_zero {false, google_protobuf_Timestamp_init_zero, false, 0, false, 0, false, 0, false, 0, {{NULL}, NULL}} -#define grpc_lb_v1_LoadBalanceResponse_init_zero {false, grpc_lb_v1_InitialLoadBalanceResponse_init_zero, false, grpc_lb_v1_ServerList_init_zero} -#define grpc_lb_v1_InitialLoadBalanceResponse_init_zero {false, "", false, google_protobuf_Duration_init_zero} -#define grpc_lb_v1_ServerList_init_zero {{{NULL}, NULL}} -#define grpc_lb_v1_Server_init_zero {false, {0, {0}}, false, 0, false, "", false, 0} - -/* Field tags (for use in manual encoding/decoding) */ -#define grpc_lb_v1_ServerList_servers_tag 1 -#define grpc_lb_v1_ClientStats_timestamp_tag 1 -#define grpc_lb_v1_ClientStats_num_calls_started_tag 2 -#define grpc_lb_v1_ClientStats_num_calls_finished_tag 3 -#define grpc_lb_v1_ClientStats_num_calls_finished_with_client_failed_to_send_tag 6 -#define grpc_lb_v1_ClientStats_num_calls_finished_known_received_tag 7 -#define grpc_lb_v1_ClientStats_calls_finished_with_drop_tag 8 -#define grpc_lb_v1_ClientStatsPerToken_load_balance_token_tag 1 -#define grpc_lb_v1_ClientStatsPerToken_num_calls_tag 2 -#define grpc_lb_v1_InitialLoadBalanceRequest_name_tag 1 -#define grpc_lb_v1_InitialLoadBalanceResponse_load_balancer_delegate_tag 1 -#define grpc_lb_v1_InitialLoadBalanceResponse_client_stats_report_interval_tag 2 -#define grpc_lb_v1_Server_ip_address_tag 1 -#define grpc_lb_v1_Server_port_tag 2 -#define grpc_lb_v1_Server_load_balance_token_tag 3 -#define grpc_lb_v1_Server_drop_tag 4 -#define grpc_lb_v1_LoadBalanceRequest_initial_request_tag 1 -#define grpc_lb_v1_LoadBalanceRequest_client_stats_tag 2 -#define grpc_lb_v1_LoadBalanceResponse_initial_response_tag 1 -#define grpc_lb_v1_LoadBalanceResponse_server_list_tag 2 - -/* Struct field encoding specification for nanopb */ -extern const pb_field_t grpc_lb_v1_LoadBalanceRequest_fields[3]; -extern const pb_field_t grpc_lb_v1_InitialLoadBalanceRequest_fields[2]; -extern const pb_field_t grpc_lb_v1_ClientStatsPerToken_fields[3]; -extern const pb_field_t grpc_lb_v1_ClientStats_fields[7]; -extern const pb_field_t grpc_lb_v1_LoadBalanceResponse_fields[3]; -extern const pb_field_t grpc_lb_v1_InitialLoadBalanceResponse_fields[3]; -extern const pb_field_t grpc_lb_v1_ServerList_fields[2]; -extern const pb_field_t grpc_lb_v1_Server_fields[5]; - -/* Maximum encoded size of messages (where known) */ -#define grpc_lb_v1_LoadBalanceRequest_size (140 + grpc_lb_v1_ClientStats_size) -#define grpc_lb_v1_InitialLoadBalanceRequest_size 131 -/* grpc_lb_v1_ClientStatsPerToken_size depends on runtime parameters */ -/* grpc_lb_v1_ClientStats_size depends on runtime parameters */ -#define grpc_lb_v1_LoadBalanceResponse_size (98 + grpc_lb_v1_ServerList_size) -#define grpc_lb_v1_InitialLoadBalanceResponse_size 90 -/* grpc_lb_v1_ServerList_size depends on runtime parameters */ -#define grpc_lb_v1_Server_size 83 - -/* Message IDs (where set with "msgid" option) */ -#ifdef PB_MSGID - -#define LOAD_BALANCER_MESSAGES \ - - -#endif - -#ifdef __cplusplus -} /* extern "C" */ -#endif -/* @@protoc_insertion_point(eof) */ - -#endif diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index 9721972511a..851b84b2a71 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -116,10 +116,6 @@ TraceFlag grpc_lb_xds_trace(false, "xds"); namespace { constexpr char kXds[] = "xds_experimental"; -constexpr char kDefaultLocalityRegion[] = "xds_default_locality_region"; -constexpr char kDefaultLocalityZone[] = "xds_default_locality_zone"; -constexpr char kDefaultLocalitySubzone[] = "xds_default_locality_subzone"; -constexpr uint32_t kDefaultLocalityWeight = 3; class ParsedXdsConfig : public LoadBalancingPolicy::Config { public: @@ -158,9 +154,6 @@ class XdsLb : public LoadBalancingPolicy { void ResetBackoffLocked() override; private: - struct LocalityServerlistEntry; - using LocalityList = InlinedVector, 1>; - /// Contains a channel to the LB server and all the data related to the /// channel. class BalancerChannelState @@ -181,7 +174,7 @@ class XdsLb : public LoadBalancingPolicy { return client_stats_; } - bool seen_initial_response() const { return seen_initial_response_; } + bool seen_response() const { return seen_response_; } private: GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE @@ -220,7 +213,7 @@ class XdsLb : public LoadBalancingPolicy { // recv_message grpc_byte_buffer* recv_message_payload_ = nullptr; grpc_closure lb_on_balancer_message_received_; - bool seen_initial_response_ = false; + bool seen_response_ = false; // recv_trailing_metadata grpc_closure lb_on_balancer_status_received_; @@ -351,57 +344,16 @@ class XdsLb : public LoadBalancingPolicy { LoadBalancingPolicy* child_ = nullptr; }; - class LocalityName : public RefCounted { - public: - struct Less { - bool operator()(const RefCountedPtr& lhs, - const RefCountedPtr& rhs) { - int cmp_result = strcmp(lhs->region_.get(), rhs->region_.get()); - if (cmp_result != 0) return cmp_result < 0; - cmp_result = strcmp(lhs->zone_.get(), rhs->zone_.get()); - if (cmp_result != 0) return cmp_result < 0; - return strcmp(lhs->subzone_.get(), rhs->subzone_.get()) < 0; - } - }; - - LocalityName(UniquePtr region, UniquePtr zone, - UniquePtr subzone) - : region_(std::move(region)), - zone_(std::move(zone)), - subzone_(std::move(subzone)) {} - - bool operator==(const LocalityName& other) const { - return strcmp(region_.get(), other.region_.get()) == 0 && - strcmp(zone_.get(), other.zone_.get()) == 0 && - strcmp(subzone_.get(), other.subzone_.get()) == 0; - } - - const char* AsHumanReadableString() { - if (human_readable_string_ == nullptr) { - char* tmp; - gpr_asprintf(&tmp, "{region=\"%s\", zone=\"%s\", subzone=\"%s\"}", - region_.get(), zone_.get(), subzone_.get()); - human_readable_string_.reset(tmp); - } - return human_readable_string_.get(); - } - - private: - UniquePtr region_; - UniquePtr zone_; - UniquePtr subzone_; - UniquePtr human_readable_string_; - }; - class LocalityMap { public: class LocalityEntry : public InternallyRefCounted { public: LocalityEntry(RefCountedPtr parent, - RefCountedPtr name, uint32_t locality_weight); + RefCountedPtr name, + uint32_t locality_weight); ~LocalityEntry(); - void UpdateLocked(xds_grpclb_serverlist* serverlist, + void UpdateLocked(ServerAddressList serverlist, LoadBalancingPolicy::Config* child_policy_config, const grpc_channel_args* args); void ShutdownLocked(); @@ -441,7 +393,7 @@ class XdsLb : public LoadBalancingPolicy { const grpc_channel_args* args); RefCountedPtr parent_; - RefCountedPtr name_; + RefCountedPtr name_; OrphanablePtr child_policy_; OrphanablePtr pending_child_policy_; RefCountedPtr picker_ref_; @@ -449,35 +401,25 @@ class XdsLb : public LoadBalancingPolicy { uint32_t locality_weight_; }; - void UpdateLocked(const LocalityList& locality_list, + void UpdateLocked(const XdsLocalityList& locality_list, LoadBalancingPolicy::Config* child_policy_config, const grpc_channel_args* args, XdsLb* parent); void ShutdownLocked(); void ResetBackoffLocked(); private: - void PruneLocalities(const LocalityList& locality_list); - Map, OrphanablePtr, - LocalityName::Less> + void PruneLocalities(const XdsLocalityList& locality_list); + Map, OrphanablePtr, + XdsLocalityName::Less> map_; }; - struct LocalityServerlistEntry { - ~LocalityServerlistEntry() { xds_grpclb_destroy_serverlist(serverlist); } - - RefCountedPtr locality_name; - uint32_t locality_weight; - // The deserialized response from the balancer. May be nullptr until one - // such response has arrived. - xds_grpclb_serverlist* serverlist; - }; - ~XdsLb(); void ShutdownLocked() override; // Helper function used in UpdateLocked(). - void ProcessAddressesAndChannelArgsLocked(const ServerAddressList& addresses, + void ProcessAddressesAndChannelArgsLocked(ServerAddressList addresses, const grpc_channel_args& args); // Parses the xds config given the JSON node of the first child of XdsConfig. @@ -499,7 +441,7 @@ class XdsLb : public LoadBalancingPolicy { const char* name, const grpc_channel_args* args); void MaybeExitFallbackMode(); - // Who the client is trying to communicate with. + // Name of the backend server to connect to. const char* server_name_ = nullptr; // Name of the balancer to connect to. @@ -547,7 +489,7 @@ class XdsLb : public LoadBalancingPolicy { LocalityMap locality_map_; // TODO(mhaidry) : Add support for multiple maps of localities // with different priorities - LocalityList locality_serverlist_; + XdsLocalityList locality_list_; // TODO(mhaidry) : Add a pending locality map that may be swapped with the // the current one when new localities in the pending map are ready // to accept connections @@ -677,79 +619,6 @@ void XdsLb::FallbackHelper::AddTraceEvent(TraceSeverity severity, parent_->channel_control_helper()->AddTraceEvent(severity, message); } -// -// serverlist parsing code -// - -// Returns the backend addresses extracted from the given addresses. -ServerAddressList ExtractBackendAddresses(const ServerAddressList& addresses) { - ServerAddressList backend_addresses; - for (size_t i = 0; i < addresses.size(); ++i) { - if (!addresses[i].IsBalancer()) { - backend_addresses.emplace_back(addresses[i]); - } - } - return backend_addresses; -} - -bool IsServerValid(const xds_grpclb_server* server, size_t idx, bool log) { - if (server->drop) return false; - const xds_grpclb_ip_address* ip = &server->ip_address; - if (GPR_UNLIKELY(server->port >> 16 != 0)) { - if (log) { - gpr_log(GPR_ERROR, - "Invalid port '%d' at index %lu of serverlist. Ignoring.", - server->port, (unsigned long)idx); - } - return false; - } - if (GPR_UNLIKELY(ip->size != 4 && ip->size != 16)) { - if (log) { - gpr_log(GPR_ERROR, - "Expected IP to be 4 or 16 bytes, got %d at index %lu of " - "serverlist. Ignoring", - ip->size, (unsigned long)idx); - } - return false; - } - return true; -} - -void ParseServer(const xds_grpclb_server* server, grpc_resolved_address* addr) { - memset(addr, 0, sizeof(*addr)); - if (server->drop) return; - const uint16_t netorder_port = grpc_htons((uint16_t)server->port); - /* the addresses are given in binary format (a in(6)_addr struct) in - * server->ip_address.bytes. */ - const xds_grpclb_ip_address* ip = &server->ip_address; - if (ip->size == 4) { - addr->len = static_cast(sizeof(grpc_sockaddr_in)); - grpc_sockaddr_in* addr4 = reinterpret_cast(&addr->addr); - addr4->sin_family = GRPC_AF_INET; - memcpy(&addr4->sin_addr, ip->bytes, ip->size); - addr4->sin_port = netorder_port; - } else if (ip->size == 16) { - addr->len = static_cast(sizeof(grpc_sockaddr_in6)); - grpc_sockaddr_in6* addr6 = (grpc_sockaddr_in6*)&addr->addr; - addr6->sin6_family = GRPC_AF_INET6; - memcpy(&addr6->sin6_addr, ip->bytes, ip->size); - addr6->sin6_port = netorder_port; - } -} - -// Returns addresses extracted from \a serverlist. -ServerAddressList ProcessServerlist(const xds_grpclb_serverlist* serverlist) { - ServerAddressList addresses; - for (size_t i = 0; i < serverlist->num_servers; ++i) { - const xds_grpclb_server* server = serverlist->servers[i]; - if (!IsServerValid(serverlist->servers[i], i, false)) continue; - grpc_resolved_address addr; - ParseServer(server, &addr); - addresses.emplace_back(addr, nullptr); - } - return addresses; -} - // // XdsLb::BalancerChannelState // @@ -913,19 +782,18 @@ XdsLb::BalancerChannelState::BalancerCallState::BalancerCallState( xdslb_policy()->lb_call_timeout_ms_ == 0 ? GRPC_MILLIS_INF_FUTURE : ExecCtx::Get()->Now() + xdslb_policy()->lb_call_timeout_ms_; + // Create an LB call with the specified method name. lb_call_ = grpc_channel_create_pollset_set_call( lb_chand_->channel_, nullptr, GRPC_PROPAGATE_DEFAULTS, xdslb_policy()->interested_parties(), - GRPC_MDSTR_SLASH_GRPC_DOT_LB_DOT_V1_DOT_LOADBALANCER_SLASH_BALANCELOAD, + GRPC_MDSTR_SLASH_ENVOY_DOT_API_DOT_V2_DOT_ENDPOINTDISCOVERYSERVICE_SLASH_STREAMENDPOINTS, nullptr, deadline, nullptr); // Init the LB call request payload. - xds_grpclb_request* request = - xds_grpclb_request_create(xdslb_policy()->server_name_); - grpc_slice request_payload_slice = xds_grpclb_request_encode(request); + grpc_slice request_payload_slice = + XdsEdsRequestCreateAndEncode(xdslb_policy()->server_name_); send_message_payload_ = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_slice_unref_internal(request_payload_slice); - xds_grpclb_request_destroy(request); // Init other data associated with the LB call. grpc_metadata_array_init(&lb_initial_metadata_recv_); grpc_metadata_array_init(&lb_trailing_metadata_recv_); @@ -1068,15 +936,20 @@ void XdsLb::BalancerChannelState::BalancerCallState:: bool XdsLb::BalancerChannelState::BalancerCallState::LoadReportCountersAreZero( xds_grpclb_request* request) { - XdsLbClientStats::DroppedCallCounts* drop_entries = - static_cast( - request->client_stats.calls_finished_with_drop.arg); - return request->client_stats.num_calls_started == 0 && - request->client_stats.num_calls_finished == 0 && - request->client_stats.num_calls_finished_with_client_failed_to_send == + const grpc_lb_v1_ClientStats* cstats = + grpc_lb_v1_LoadBalanceRequest_client_stats(request); + if (cstats == nullptr) { + return true; + } + size_t drop_count; + grpc_lb_v1_ClientStats_calls_finished_with_drop(cstats, &drop_count); + return grpc_lb_v1_ClientStats_num_calls_started(cstats) == 0 && + grpc_lb_v1_ClientStats_num_calls_finished(cstats) == 0 && + grpc_lb_v1_ClientStats_num_calls_finished_with_client_failed_to_send( + cstats) == 0 && + grpc_lb_v1_ClientStats_num_calls_finished_known_received(cstats) == 0 && - request->client_stats.num_calls_finished_known_received == 0 && - (drop_entries == nullptr || drop_entries->empty()); + drop_count == 0; } // TODO(vpowar): Use LRS to send the client Load Report. @@ -1084,13 +957,13 @@ void XdsLb::BalancerChannelState::BalancerCallState:: SendClientLoadReportLocked() { // Construct message payload. GPR_ASSERT(send_message_payload_ == nullptr); - xds_grpclb_request* request = - xds_grpclb_load_report_request_create_locked(client_stats_.get()); + upb::Arena arena; + xds_grpclb_request* request = xds_grpclb_load_report_request_create_locked( + client_stats_.get(), arena.ptr()); // Skip client load report if the counters were all zero in the last // report and they are still zero in this one. if (LoadReportCountersAreZero(request)) { if (last_client_load_report_counters_were_zero_) { - xds_grpclb_request_destroy(request); ScheduleNextClientLoadReportLocked(); return; } @@ -1099,7 +972,6 @@ void XdsLb::BalancerChannelState::BalancerCallState:: last_client_load_report_counters_were_zero_ = false; } // TODO(vpowar): Send the report on LRS stream. - xds_grpclb_request_destroy(request); } void XdsLb::BalancerChannelState::BalancerCallState::OnInitialRequestSentLocked( @@ -1127,65 +999,67 @@ void XdsLb::BalancerChannelState::BalancerCallState:: lb_calld->Unref(DEBUG_LOCATION, "on_message_received"); return; } + lb_calld->seen_response_ = true; + // Read the response. grpc_byte_buffer_reader bbr; grpc_byte_buffer_reader_init(&bbr, lb_calld->recv_message_payload_); grpc_slice response_slice = grpc_byte_buffer_reader_readall(&bbr); grpc_byte_buffer_reader_destroy(&bbr); grpc_byte_buffer_destroy(lb_calld->recv_message_payload_); lb_calld->recv_message_payload_ = nullptr; - xds_grpclb_initial_response* initial_response; - xds_grpclb_serverlist* serverlist; - if (!lb_calld->seen_initial_response_ && - (initial_response = xds_grpclb_initial_response_parse(response_slice)) != - nullptr) { - // Have NOT seen initial response, look for initial response. - // TODO(juanlishen): When we convert this to use the xds protocol, the - // balancer will send us a fallback timeout such that we should go into - // fallback mode if we have lost contact with the balancer after a certain - // period of time. We will need to save the timeout value here, and then - // when the balancer call ends, we will need to start a timer for the - // specified period of time, and if the timer fires, we go into fallback - // mode. We will also need to cancel the timer when we receive a serverlist - // from the balancer. - if (initial_response->has_client_stats_report_interval) { - const grpc_millis interval = xds_grpclb_duration_to_millis( - &initial_response->client_stats_report_interval); - if (interval > 0) { - lb_calld->client_stats_report_interval_ = - GPR_MAX(GPR_MS_PER_SEC, interval); - } + // TODO(juanlishen): When we convert this to use the xds protocol, the + // balancer will send us a fallback timeout such that we should go into + // fallback mode if we have lost contact with the balancer after a certain + // period of time. We will need to save the timeout value here, and then + // when the balancer call ends, we will need to start a timer for the + // specified period of time, and if the timer fires, we go into fallback + // mode. We will also need to cancel the timer when we receive a serverlist + // from the balancer. + // This anonymous lambda is a hack to avoid the usage of goto. + [&]() { + // Parse the response. + XdsUpdate update; + grpc_error* parse_error = + XdsEdsResponseDecodeAndParse(response_slice, &update); + if (parse_error != GRPC_ERROR_NONE) { + gpr_log(GPR_ERROR, "[xdslb %p] EDS response parsing failed. error=%s", + xdslb_policy, grpc_error_string(parse_error)); + GRPC_ERROR_UNREF(parse_error); + return; } - if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { - if (lb_calld->client_stats_report_interval_ != 0) { - gpr_log(GPR_INFO, - "[xdslb %p] Received initial LB response message; " - "client load reporting interval = %" PRId64 " milliseconds", - xdslb_policy, lb_calld->client_stats_report_interval_); - } else { - gpr_log(GPR_INFO, - "[xdslb %p] Received initial LB response message; client load " - "reporting NOT enabled", - xdslb_policy); - } + if (update.locality_list.empty()) { + char* response_slice_str = + grpc_dump_slice(response_slice, GPR_DUMP_ASCII | GPR_DUMP_HEX); + gpr_log(GPR_ERROR, + "[xdslb %p] EDS response '%s' doesn't contain any valid locality " + "update. Ignoring.", + xdslb_policy, response_slice_str); + gpr_free(response_slice_str); + return; } - xds_grpclb_initial_response_destroy(initial_response); - lb_calld->seen_initial_response_ = true; - } else if ((serverlist = xds_grpclb_response_parse_serverlist( - response_slice)) != nullptr) { - // Have seen initial response, look for serverlist. - GPR_ASSERT(lb_calld->lb_call_ != nullptr); if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { gpr_log(GPR_INFO, - "[xdslb %p] Serverlist with %" PRIuPTR " servers received", - xdslb_policy, serverlist->num_servers); - for (size_t i = 0; i < serverlist->num_servers; ++i) { - grpc_resolved_address addr; - ParseServer(serverlist->servers[i], &addr); - char* ipport; - grpc_sockaddr_to_string(&ipport, &addr, false); - gpr_log(GPR_INFO, "[xdslb %p] Serverlist[%" PRIuPTR "]: %s", - xdslb_policy, i, ipport); - gpr_free(ipport); + "[xdslb %p] EDS response with %" PRIuPTR " localities received", + xdslb_policy, update.locality_list.size()); + for (size_t i = 0; i < update.locality_list.size(); ++i) { + const XdsLocalityInfo& locality = update.locality_list[i]; + gpr_log(GPR_INFO, + "[xdslb %p] Locality %" PRIuPTR " %s contains %" PRIuPTR + " server addresses", + xdslb_policy, i, + locality.locality_name->AsHumanReadableString(), + locality.serverlist.size()); + for (size_t j = 0; j < locality.serverlist.size(); ++j) { + char* ipport; + grpc_sockaddr_to_string(&ipport, &locality.serverlist[j].address(), + false); + gpr_log(GPR_INFO, + "[xdslb %p] Locality %" PRIuPTR + " %s, server address %" PRIuPTR ": %s", + xdslb_policy, i, + locality.locality_name->AsHumanReadableString(), j, ipport); + gpr_free(ipport); + } } } // Pending LB channel receives a serverlist; promote it. @@ -1211,73 +1085,47 @@ void XdsLb::BalancerChannelState::BalancerCallState:: lb_calld->Ref(DEBUG_LOCATION, "client_load_report").release(); lb_calld->ScheduleNextClientLoadReportLocked(); } - if (!xdslb_policy->locality_serverlist_.empty() && - xds_grpclb_serverlist_equals( - xdslb_policy->locality_serverlist_[0]->serverlist, serverlist)) { + // Ignore identical update. + if (xdslb_policy->locality_list_ == update.locality_list) { if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { gpr_log(GPR_INFO, "[xdslb %p] Incoming server list identical to current, " "ignoring.", xdslb_policy); } - xds_grpclb_destroy_serverlist(serverlist); - } else { // New serverlist. - // If the balancer tells us to drop all the calls, we should exit fallback - // mode immediately. - // TODO(juanlishen): When we add EDS drop, we should change to check - // drop_percentage. - if (serverlist->num_servers == 0) xdslb_policy->MaybeExitFallbackMode(); - if (!xdslb_policy->locality_serverlist_.empty()) { - xds_grpclb_destroy_serverlist( - xdslb_policy->locality_serverlist_[0]->serverlist); - } else { - // Initialize locality serverlist, currently the list only handles - // one child. - xdslb_policy->locality_serverlist_.emplace_back( - MakeUnique()); - xdslb_policy->locality_serverlist_[0]->locality_name = - MakeRefCounted( - UniquePtr(gpr_strdup(kDefaultLocalityRegion)), - UniquePtr(gpr_strdup(kDefaultLocalityZone)), - UniquePtr(gpr_strdup(kDefaultLocalitySubzone))); - xdslb_policy->locality_serverlist_[0]->locality_weight = - kDefaultLocalityWeight; - } - // Update the serverlist in the XdsLb instance. This serverlist - // instance will be destroyed either upon the next update or when the - // XdsLb instance is destroyed. - xdslb_policy->locality_serverlist_[0]->serverlist = serverlist; - xdslb_policy->locality_map_.UpdateLocked( - xdslb_policy->locality_serverlist_, - xdslb_policy->child_policy_config_.get(), xdslb_policy->args_, - xdslb_policy); + return; } - } else { - // No valid initial response or serverlist found. - char* response_slice_str = - grpc_dump_slice(response_slice, GPR_DUMP_ASCII | GPR_DUMP_HEX); - gpr_log(GPR_ERROR, - "[xdslb %p] Invalid LB response received: '%s'. Ignoring.", - xdslb_policy, response_slice_str); - gpr_free(response_slice_str); - } + // If the balancer tells us to drop all the calls, we should exit fallback + // mode immediately. + // TODO(juanlishen): When we add EDS drop, we should change to check + // drop_percentage. + if (update.locality_list[0].serverlist.empty()) { + xdslb_policy->MaybeExitFallbackMode(); + } + // Update the locality list. + xdslb_policy->locality_list_ = std::move(update.locality_list); + // Update the locality map. + xdslb_policy->locality_map_.UpdateLocked( + xdslb_policy->locality_list_, xdslb_policy->child_policy_config_.get(), + xdslb_policy->args_, xdslb_policy); + }(); grpc_slice_unref_internal(response_slice); - if (!xdslb_policy->shutting_down_) { - // Keep listening for serverlist updates. - grpc_op op; - memset(&op, 0, sizeof(op)); - op.op = GRPC_OP_RECV_MESSAGE; - op.data.recv_message.recv_message = &lb_calld->recv_message_payload_; - op.flags = 0; - op.reserved = nullptr; - // Reuse the "OnBalancerMessageReceivedLocked" ref taken in StartQuery(). - const grpc_call_error call_error = grpc_call_start_batch_and_execute( - lb_calld->lb_call_, &op, 1, - &lb_calld->lb_on_balancer_message_received_); - GPR_ASSERT(GRPC_CALL_OK == call_error); - } else { + if (xdslb_policy->shutting_down_) { lb_calld->Unref(DEBUG_LOCATION, "on_message_received+xds_shutdown"); + return; } + // Keep listening for serverlist updates. + grpc_op op; + memset(&op, 0, sizeof(op)); + op.op = GRPC_OP_RECV_MESSAGE; + op.data.recv_message.recv_message = &lb_calld->recv_message_payload_; + op.flags = 0; + op.reserved = nullptr; + GPR_ASSERT(lb_calld->lb_call_ != nullptr); + // Reuse the "OnBalancerMessageReceivedLocked" ref taken in StartQuery(). + const grpc_call_error call_error = grpc_call_start_batch_and_execute( + lb_calld->lb_call_, &op, 1, &lb_calld->lb_on_balancer_message_received_); + GPR_ASSERT(GRPC_CALL_OK == call_error); } void XdsLb::BalancerChannelState::BalancerCallState:: @@ -1317,7 +1165,7 @@ void XdsLb::BalancerChannelState::BalancerCallState:: // This channel is the most recently created one. Try to restart the call // and reresolve. lb_chand->lb_calld_.reset(); - if (lb_calld->seen_initial_response_) { + if (lb_calld->seen_response_) { // If we lost connection to the LB server, reset the backoff and restart // the LB call immediately. lb_chand->lb_call_backoff_.Reset(); @@ -1402,9 +1250,7 @@ grpc_channel_args* BuildBalancerChannelArgs(const grpc_channel_args* args) { // XdsLb::XdsLb(Args args) - : LoadBalancingPolicy(std::move(args)), - locality_map_(), - locality_serverlist_() { + : LoadBalancingPolicy(std::move(args)), locality_map_(), locality_list_() { // Record server name. const grpc_arg* arg = grpc_channel_args_find(args.args, GRPC_ARG_SERVER_URI); const char* server_uri = grpc_channel_arg_get_string(arg); @@ -1433,7 +1279,7 @@ XdsLb::~XdsLb() { } gpr_free((void*)server_name_); grpc_channel_args_destroy(args_); - locality_serverlist_.clear(); + locality_list_.clear(); } void XdsLb::ShutdownLocked() { @@ -1482,9 +1328,9 @@ void XdsLb::ResetBackoffLocked() { } void XdsLb::ProcessAddressesAndChannelArgsLocked( - const ServerAddressList& addresses, const grpc_channel_args& args) { + ServerAddressList addresses, const grpc_channel_args& args) { // Update fallback address list. - fallback_backend_addresses_ = ExtractBackendAddresses(addresses); + fallback_backend_addresses_ = std::move(addresses); // Make sure that GRPC_ARG_LB_POLICY_NAME is set in channel args, // since we use this to trigger the client_load_reporting filter. static const char* args_to_remove[] = {GRPC_ARG_LB_POLICY_NAME}; @@ -1536,9 +1382,9 @@ void XdsLb::UpdateLocked(UpdateArgs args) { gpr_log(GPR_ERROR, "[xdslb %p] LB config parsing fails.", this); return; } - ProcessAddressesAndChannelArgsLocked(args.addresses, *args.args); - locality_map_.UpdateLocked(locality_serverlist_, child_policy_config_.get(), - args_, this); + ProcessAddressesAndChannelArgsLocked(std::move(args.addresses), *args.args); + locality_map_.UpdateLocked(locality_list_, child_policy_config_.get(), args_, + this); // Update the existing fallback policy. The fallback policy config and/or the // fallback addresses may be new. if (fallback_policy_ != nullptr) UpdateFallbackPolicyLocked(); @@ -1736,16 +1582,16 @@ void XdsLb::MaybeExitFallbackMode() { // XdsLb::LocalityMap // -void XdsLb::LocalityMap::PruneLocalities(const LocalityList& locality_list) { +void XdsLb::LocalityMap::PruneLocalities(const XdsLocalityList& locality_list) { for (auto iter = map_.begin(); iter != map_.end();) { bool found = false; for (size_t i = 0; i < locality_list.size(); i++) { - if (*locality_list[i]->locality_name == *iter->first) { + if (*locality_list[i].locality_name == *iter->first) { found = true; break; } } - if (!found) { // Remove entries not present in the locality list + if (!found) { // Remove entries not present in the locality list. iter = map_.erase(iter); } else iter++; @@ -1753,27 +1599,27 @@ void XdsLb::LocalityMap::PruneLocalities(const LocalityList& locality_list) { } void XdsLb::LocalityMap::UpdateLocked( - const LocalityList& locality_serverlist, + const XdsLocalityList& locality_list, LoadBalancingPolicy::Config* child_policy_config, const grpc_channel_args* args, XdsLb* parent) { if (parent->shutting_down_) return; - for (size_t i = 0; i < locality_serverlist.size(); i++) { - auto iter = map_.find(locality_serverlist[i]->locality_name); + for (size_t i = 0; i < locality_list.size(); i++) { + auto iter = map_.find(locality_list[i].locality_name); + // Add a new entry in the locality map if a new locality is received in the + // locality list. if (iter == map_.end()) { OrphanablePtr new_entry = MakeOrphanable( parent->Ref(DEBUG_LOCATION, "LocalityEntry"), - locality_serverlist[i]->locality_name, - locality_serverlist[i]->locality_weight); - iter = map_.emplace(locality_serverlist[i]->locality_name, - std::move(new_entry)) + locality_list[i].locality_name, locality_list[i].lb_weight); + iter = map_.emplace(locality_list[i].locality_name, std::move(new_entry)) .first; } - // Don't create new child policies if not directed to - xds_grpclb_serverlist* serverlist = - parent->locality_serverlist_[i]->serverlist; - iter->second->UpdateLocked(serverlist, child_policy_config, args); + // Keep a copy of serverlist in locality_list_ so that we can compare it + // with the future ones. + iter->second->UpdateLocked(locality_list[i].serverlist, child_policy_config, + args); } - PruneLocalities(locality_serverlist); + PruneLocalities(locality_list); } void XdsLb::LocalityMap::ShutdownLocked() { map_.clear(); } @@ -1789,7 +1635,7 @@ void XdsLb::LocalityMap::ResetBackoffLocked() { // XdsLb::LocalityMap::LocalityEntry::LocalityEntry( - RefCountedPtr parent, RefCountedPtr name, + RefCountedPtr parent, RefCountedPtr name, uint32_t locality_weight) : parent_(std::move(parent)), name_(std::move(name)), @@ -1861,13 +1707,13 @@ XdsLb::LocalityMap::LocalityEntry::CreateChildPolicyLocked( } void XdsLb::LocalityMap::LocalityEntry::UpdateLocked( - xds_grpclb_serverlist* serverlist, + ServerAddressList serverlist, LoadBalancingPolicy::Config* child_policy_config, const grpc_channel_args* args_in) { if (parent_->shutting_down_) return; // Construct update args. UpdateArgs update_args; - update_args.addresses = ProcessServerlist(serverlist); + update_args.addresses = std::move(serverlist); update_args.config = child_policy_config == nullptr ? nullptr : child_policy_config->Ref(); update_args.args = CreateChildPolicyArgsLocked(args_in); @@ -2158,7 +2004,7 @@ void XdsLb::LocalityMap::LocalityEntry::Helper::RequestReresolution() { // the child policy. Otherwise, pass the re-resolution request up to the // channel. if (entry_->parent_->lb_chand_->lb_calld() == nullptr || - !entry_->parent_->lb_chand_->lb_calld()->seen_initial_response()) { + !entry_->parent_->lb_chand_->lb_calld()->seen_response()) { entry_->parent_->channel_control_helper()->RequestReresolution(); } } diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc index 58f26bf54ec..8ae6a5e7590 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc @@ -18,294 +18,245 @@ #include -#include "pb_decode.h" -#include "pb_encode.h" -#include "src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h" +#include +#include #include +#include -/* invoked once for every Server in ServerList */ -static bool count_serverlist(pb_istream_t* stream, const pb_field_t* field, - void** arg) { - xds_grpclb_serverlist* sl = static_cast(*arg); - xds_grpclb_server server; - if (GPR_UNLIKELY(!pb_decode(stream, grpc_lb_v1_Server_fields, &server))) { - gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(stream)); - return false; +#include "src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h" +#include "src/core/lib/iomgr/error.h" +#include "src/core/lib/iomgr/sockaddr_utils.h" + +#include "envoy/api/v2/core/address.upb.h" +#include "envoy/api/v2/core/base.upb.h" +#include "envoy/api/v2/discovery.upb.h" +#include "envoy/api/v2/eds.upb.h" +#include "envoy/api/v2/endpoint/endpoint.upb.h" +#include "google/protobuf/any.upb.h" +#include "google/protobuf/struct.upb.h" +#include "google/protobuf/timestamp.upb.h" +#include "google/protobuf/wrappers.upb.h" +#include "upb/upb.h" + +namespace grpc_core { + +namespace { + +constexpr char kEdsTypeUrl[] = + "type.googleapis.com/envoy.api.v2.ClusterLoadAssignment"; +constexpr char kEndpointRequired[] = "endpointRequired"; + +} // namespace + +grpc_slice XdsEdsRequestCreateAndEncode(const char* service_name) { + upb::Arena arena; + // Create a request. + envoy_api_v2_DiscoveryRequest* request = + envoy_api_v2_DiscoveryRequest_new(arena.ptr()); + envoy_api_v2_core_Node* node = + envoy_api_v2_DiscoveryRequest_mutable_node(request, arena.ptr()); + google_protobuf_Struct* metadata = + envoy_api_v2_core_Node_mutable_metadata(node, arena.ptr()); + google_protobuf_Struct_FieldsEntry* field = + google_protobuf_Struct_add_fields(metadata, arena.ptr()); + google_protobuf_Struct_FieldsEntry_set_key( + field, upb_strview_makez(kEndpointRequired)); + google_protobuf_Value* value = + google_protobuf_Struct_FieldsEntry_mutable_value(field, arena.ptr()); + google_protobuf_Value_set_bool_value(value, true); + envoy_api_v2_DiscoveryRequest_add_resource_names( + request, upb_strview_makez(service_name), arena.ptr()); + envoy_api_v2_DiscoveryRequest_set_type_url(request, + upb_strview_makez(kEdsTypeUrl)); + // Encode the request. + size_t output_length; + char* output = envoy_api_v2_DiscoveryRequest_serialize(request, arena.ptr(), + &output_length); + return grpc_slice_from_copied_buffer(output, output_length); +} + +namespace { + +grpc_error* ServerAddressParseAndAppend( + const envoy_api_v2_endpoint_LbEndpoint* lb_endpoint, + ServerAddressList* list) { + // Find the ip:port. + const envoy_api_v2_endpoint_Endpoint* endpoint = + envoy_api_v2_endpoint_LbEndpoint_endpoint(lb_endpoint); + const envoy_api_v2_core_Address* address = + envoy_api_v2_endpoint_Endpoint_address(endpoint); + const envoy_api_v2_core_SocketAddress* socket_address = + envoy_api_v2_core_Address_socket_address(address); + upb_strview address_strview = + envoy_api_v2_core_SocketAddress_address(socket_address); + uint32_t port = envoy_api_v2_core_SocketAddress_port_value(socket_address); + if (GPR_UNLIKELY(port >> 16) != 0) { + return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Invalid port."); } - ++sl->num_servers; - return true; + // Populate grpc_resolved_address. + grpc_resolved_address addr; + char* address_str = static_cast(gpr_malloc(address_strview.size + 1)); + memcpy(address_str, address_strview.data, address_strview.size); + address_str[address_strview.size] = '\0'; + grpc_string_to_sockaddr(&addr, address_str, port); + gpr_free(address_str); + // Append the address to the list. + list->emplace_back(addr, nullptr); + return GRPC_ERROR_NONE; } -typedef struct decode_serverlist_arg { - /* The decoding callback is invoked once per server in serverlist. Remember - * which index of the serverlist are we currently decoding */ - size_t decoding_idx; - /* The decoded serverlist */ - xds_grpclb_serverlist* serverlist; -} decode_serverlist_arg; +namespace { -/* invoked once for every Server in ServerList */ -static bool decode_serverlist(pb_istream_t* stream, const pb_field_t* field, - void** arg) { - decode_serverlist_arg* dec_arg = static_cast(*arg); - GPR_ASSERT(dec_arg->serverlist->num_servers >= dec_arg->decoding_idx); - xds_grpclb_server* server = - static_cast(gpr_zalloc(sizeof(xds_grpclb_server))); - if (GPR_UNLIKELY(!pb_decode(stream, grpc_lb_v1_Server_fields, server))) { - gpr_free(server); - gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(stream)); - return false; +UniquePtr StringCopy(const upb_strview& strview) { + char* str = static_cast(gpr_malloc(strview.size + 1)); + memcpy(str, strview.data, strview.size); + str[strview.size] = '\0'; + return UniquePtr(str); +} + +} // namespace + +grpc_error* LocalityParse( + const envoy_api_v2_endpoint_LocalityLbEndpoints* locality_lb_endpoints, + XdsLocalityInfo* locality_info) { + // Parse locality name. + const envoy_api_v2_core_Locality* locality = + envoy_api_v2_endpoint_LocalityLbEndpoints_locality(locality_lb_endpoints); + locality_info->locality_name = MakeRefCounted( + StringCopy(envoy_api_v2_core_Locality_region(locality)), + StringCopy(envoy_api_v2_core_Locality_zone(locality)), + StringCopy(envoy_api_v2_core_Locality_sub_zone(locality))); + // Parse the addresses. + size_t size; + const envoy_api_v2_endpoint_LbEndpoint* const* lb_endpoints = + envoy_api_v2_endpoint_LocalityLbEndpoints_lb_endpoints( + locality_lb_endpoints, &size); + for (size_t i = 0; i < size; ++i) { + grpc_error* error = ServerAddressParseAndAppend(lb_endpoints[i], + &locality_info->serverlist); + if (error != GRPC_ERROR_NONE) return error; } - dec_arg->serverlist->servers[dec_arg->decoding_idx++] = server; - return true; + // Parse the lb_weight and priority. + const google_protobuf_UInt32Value* lb_weight = + envoy_api_v2_endpoint_LocalityLbEndpoints_load_balancing_weight( + locality_lb_endpoints); + // If LB weight is not specified, the default weight 0 is used, which means + // this locality is assigned no load. + locality_info->lb_weight = + lb_weight != nullptr ? google_protobuf_UInt32Value_value(lb_weight) : 0; + locality_info->priority = + envoy_api_v2_endpoint_LocalityLbEndpoints_priority(locality_lb_endpoints); + return GRPC_ERROR_NONE; } -xds_grpclb_request* xds_grpclb_request_create(const char* lb_service_name) { - xds_grpclb_request* req = - static_cast(gpr_malloc(sizeof(xds_grpclb_request))); - req->has_client_stats = false; - req->has_initial_request = true; - req->initial_request.has_name = true; - // GCC warns (-Wstringop-truncation) because the destination - // buffer size is identical to max-size, leading to a potential - // char[] with no null terminator. nanopb can handle it fine, - // and parantheses around strncpy silence that compiler warning. - (strncpy(req->initial_request.name, lb_service_name, - XDS_SERVICE_NAME_MAX_LENGTH)); - return req; -} +} // namespace -static void populate_timestamp(gpr_timespec timestamp, - xds_grpclb_timestamp* timestamp_pb) { - timestamp_pb->has_seconds = true; - timestamp_pb->seconds = timestamp.tv_sec; - timestamp_pb->has_nanos = true; - timestamp_pb->nanos = timestamp.tv_nsec; -} - -static bool encode_string(pb_ostream_t* stream, const pb_field_t* field, - void* const* arg) { - char* str = static_cast(*arg); - if (!pb_encode_tag_for_field(stream, field)) return false; - return pb_encode_string(stream, reinterpret_cast(str), strlen(str)); -} - -static bool encode_drops(pb_ostream_t* stream, const pb_field_t* field, - void* const* arg) { - grpc_core::XdsLbClientStats::DroppedCallCounts* drop_entries = - static_cast(*arg); - if (drop_entries == nullptr) return true; - for (size_t i = 0; i < drop_entries->size(); ++i) { - if (!pb_encode_tag_for_field(stream, field)) return false; - grpc_lb_v1_ClientStatsPerToken drop_message; - drop_message.load_balance_token.funcs.encode = encode_string; - drop_message.load_balance_token.arg = (*drop_entries)[i].token.get(); - drop_message.has_num_calls = true; - drop_message.num_calls = (*drop_entries)[i].count; - if (!pb_encode_submessage(stream, grpc_lb_v1_ClientStatsPerToken_fields, - &drop_message)) { - return false; - } +grpc_error* XdsEdsResponseDecodeAndParse(const grpc_slice& encoded_response, + XdsUpdate* update) { + upb::Arena arena; + // Decode the response. + const envoy_api_v2_DiscoveryResponse* response = + envoy_api_v2_DiscoveryResponse_parse( + reinterpret_cast(GRPC_SLICE_START_PTR(encoded_response)), + GRPC_SLICE_LENGTH(encoded_response), arena.ptr()); + // Parse the response. + if (response == nullptr) { + return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No response found."); } - return true; + // Check the type_url of the response. + upb_strview type_url = envoy_api_v2_DiscoveryResponse_type_url(response); + upb_strview expected_type_url = upb_strview_makez(kEdsTypeUrl); + if (!upb_strview_eql(type_url, expected_type_url)) { + return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resource is not EDS."); + } + // Get the resources from the response. + size_t size; + const google_protobuf_Any* const* resources = + envoy_api_v2_DiscoveryResponse_resources(response, &size); + if (size < 1) { + return GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "EDS response contains 0 resource."); + } + // Check the type_url of the resource. + type_url = google_protobuf_Any_type_url(resources[0]); + if (!upb_strview_eql(type_url, expected_type_url)) { + return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resource is not EDS."); + } + // Get the cluster_load_assignment. + upb_strview encoded_cluster_load_assignment = + google_protobuf_Any_value(resources[0]); + envoy_api_v2_ClusterLoadAssignment* cluster_load_assignment = + envoy_api_v2_ClusterLoadAssignment_parse( + encoded_cluster_load_assignment.data, + encoded_cluster_load_assignment.size, arena.ptr()); + const envoy_api_v2_endpoint_LocalityLbEndpoints* const* endpoints = + envoy_api_v2_ClusterLoadAssignment_endpoints(cluster_load_assignment, + &size); + for (size_t i = 0; i < size; ++i) { + XdsLocalityInfo locality_info; + grpc_error* error = LocalityParse(endpoints[i], &locality_info); + if (error != GRPC_ERROR_NONE) return error; + update->locality_list.push_back(std::move(locality_info)); + } + // The locality list is sorted here into deterministic order so that it's + // easier to check if two locality lists contain the same set of localities. + std::sort(update->locality_list.data(), + update->locality_list.data() + update->locality_list.size(), + XdsLocalityInfo::Less()); + return GRPC_ERROR_NONE; } +namespace { + +void google_protobuf_Timestamp_assign(google_protobuf_Timestamp* timestamp, + const gpr_timespec& value) { + google_protobuf_Timestamp_set_seconds(timestamp, value.tv_sec); + google_protobuf_Timestamp_set_nanos(timestamp, value.tv_nsec); +} + +} // namespace + xds_grpclb_request* xds_grpclb_load_report_request_create_locked( - grpc_core::XdsLbClientStats* client_stats) { - xds_grpclb_request* req = - static_cast(gpr_zalloc(sizeof(xds_grpclb_request))); - req->has_client_stats = true; - req->client_stats.has_timestamp = true; - populate_timestamp(gpr_now(GPR_CLOCK_REALTIME), &req->client_stats.timestamp); - req->client_stats.has_num_calls_started = true; - req->client_stats.has_num_calls_finished = true; - req->client_stats.has_num_calls_finished_with_client_failed_to_send = true; - req->client_stats.has_num_calls_finished_with_client_failed_to_send = true; - req->client_stats.has_num_calls_finished_known_received = true; - req->client_stats.calls_finished_with_drop.funcs.encode = encode_drops; - grpc_core::UniquePtr - drop_counts; - client_stats->GetLocked( - &req->client_stats.num_calls_started, - &req->client_stats.num_calls_finished, - &req->client_stats.num_calls_finished_with_client_failed_to_send, - &req->client_stats.num_calls_finished_known_received, &drop_counts); - // Will be deleted in xds_grpclb_request_destroy(). - req->client_stats.calls_finished_with_drop.arg = drop_counts.release(); + grpc_core::XdsLbClientStats* client_stats, upb_arena* arena) { + xds_grpclb_request* req = grpc_lb_v1_LoadBalanceRequest_new(arena); + grpc_lb_v1_ClientStats* req_stats = + grpc_lb_v1_LoadBalanceRequest_mutable_client_stats(req, arena); + google_protobuf_Timestamp_assign( + grpc_lb_v1_ClientStats_mutable_timestamp(req_stats, arena), + gpr_now(GPR_CLOCK_REALTIME)); + + int64_t num_calls_started; + int64_t num_calls_finished; + int64_t num_calls_finished_with_client_failed_to_send; + int64_t num_calls_finished_known_received; + UniquePtr drop_token_counts; + client_stats->GetLocked(&num_calls_started, &num_calls_finished, + &num_calls_finished_with_client_failed_to_send, + &num_calls_finished_known_received, + &drop_token_counts); + grpc_lb_v1_ClientStats_set_num_calls_started(req_stats, num_calls_started); + grpc_lb_v1_ClientStats_set_num_calls_finished(req_stats, num_calls_finished); + grpc_lb_v1_ClientStats_set_num_calls_finished_with_client_failed_to_send( + req_stats, num_calls_finished_with_client_failed_to_send); + grpc_lb_v1_ClientStats_set_num_calls_finished_known_received( + req_stats, num_calls_finished_known_received); + if (drop_token_counts != nullptr) { + for (size_t i = 0; i < drop_token_counts->size(); ++i) { + XdsLbClientStats::DropTokenCount& cur = (*drop_token_counts)[i]; + grpc_lb_v1_ClientStatsPerToken* cur_msg = + grpc_lb_v1_ClientStats_add_calls_finished_with_drop(req_stats, arena); + + const size_t token_len = strlen(cur.token.get()); + char* token = reinterpret_cast(upb_arena_malloc(arena, token_len)); + memcpy(token, cur.token.get(), token_len); + + grpc_lb_v1_ClientStatsPerToken_set_load_balance_token( + cur_msg, upb_strview_make(token, token_len)); + grpc_lb_v1_ClientStatsPerToken_set_num_calls(cur_msg, cur.count); + } + } return req; } -grpc_slice xds_grpclb_request_encode(const xds_grpclb_request* request) { - size_t encoded_length; - pb_ostream_t sizestream; - pb_ostream_t outputstream; - grpc_slice slice; - memset(&sizestream, 0, sizeof(pb_ostream_t)); - pb_encode(&sizestream, grpc_lb_v1_LoadBalanceRequest_fields, request); - encoded_length = sizestream.bytes_written; - - slice = GRPC_SLICE_MALLOC(encoded_length); - outputstream = - pb_ostream_from_buffer(GRPC_SLICE_START_PTR(slice), encoded_length); - GPR_ASSERT(pb_encode(&outputstream, grpc_lb_v1_LoadBalanceRequest_fields, - request) != 0); - return slice; -} - -void xds_grpclb_request_destroy(xds_grpclb_request* request) { - if (request->has_client_stats) { - grpc_core::XdsLbClientStats::DroppedCallCounts* drop_entries = - static_cast( - request->client_stats.calls_finished_with_drop.arg); - grpc_core::Delete(drop_entries); - } - gpr_free(request); -} - -typedef grpc_lb_v1_LoadBalanceResponse xds_grpclb_response; -xds_grpclb_initial_response* xds_grpclb_initial_response_parse( - const grpc_slice& encoded_xds_grpclb_response) { - pb_istream_t stream = pb_istream_from_buffer( - const_cast(GRPC_SLICE_START_PTR(encoded_xds_grpclb_response)), - GRPC_SLICE_LENGTH(encoded_xds_grpclb_response)); - xds_grpclb_response res; - memset(&res, 0, sizeof(xds_grpclb_response)); - if (GPR_UNLIKELY( - !pb_decode(&stream, grpc_lb_v1_LoadBalanceResponse_fields, &res))) { - gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&stream)); - return nullptr; - } - - if (!res.has_initial_response) return nullptr; - - xds_grpclb_initial_response* initial_res = - static_cast( - gpr_malloc(sizeof(xds_grpclb_initial_response))); - memcpy(initial_res, &res.initial_response, - sizeof(xds_grpclb_initial_response)); - - return initial_res; -} - -xds_grpclb_serverlist* xds_grpclb_response_parse_serverlist( - const grpc_slice& encoded_xds_grpclb_response) { - pb_istream_t stream = pb_istream_from_buffer( - const_cast(GRPC_SLICE_START_PTR(encoded_xds_grpclb_response)), - GRPC_SLICE_LENGTH(encoded_xds_grpclb_response)); - pb_istream_t stream_at_start = stream; - xds_grpclb_serverlist* sl = static_cast( - gpr_zalloc(sizeof(xds_grpclb_serverlist))); - xds_grpclb_response res; - memset(&res, 0, sizeof(xds_grpclb_response)); - // First pass: count number of servers. - res.server_list.servers.funcs.decode = count_serverlist; - res.server_list.servers.arg = sl; - bool status = pb_decode(&stream, grpc_lb_v1_LoadBalanceResponse_fields, &res); - if (GPR_UNLIKELY(!status)) { - gpr_free(sl); - gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&stream)); - return nullptr; - } - // Second pass: populate servers. - if (sl->num_servers > 0) { - sl->servers = static_cast( - gpr_zalloc(sizeof(xds_grpclb_server*) * sl->num_servers)); - decode_serverlist_arg decode_arg; - memset(&decode_arg, 0, sizeof(decode_arg)); - decode_arg.serverlist = sl; - res.server_list.servers.funcs.decode = decode_serverlist; - res.server_list.servers.arg = &decode_arg; - status = pb_decode(&stream_at_start, grpc_lb_v1_LoadBalanceResponse_fields, - &res); - if (GPR_UNLIKELY(!status)) { - xds_grpclb_destroy_serverlist(sl); - gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&stream)); - return nullptr; - } - } - return sl; -} - -void xds_grpclb_destroy_serverlist(xds_grpclb_serverlist* serverlist) { - if (serverlist == nullptr) { - return; - } - for (size_t i = 0; i < serverlist->num_servers; i++) { - gpr_free(serverlist->servers[i]); - } - gpr_free(serverlist->servers); - gpr_free(serverlist); -} - -xds_grpclb_serverlist* xds_grpclb_serverlist_copy( - const xds_grpclb_serverlist* sl) { - xds_grpclb_serverlist* copy = static_cast( - gpr_zalloc(sizeof(xds_grpclb_serverlist))); - copy->num_servers = sl->num_servers; - copy->servers = static_cast( - gpr_malloc(sizeof(xds_grpclb_server*) * sl->num_servers)); - for (size_t i = 0; i < sl->num_servers; i++) { - copy->servers[i] = - static_cast(gpr_malloc(sizeof(xds_grpclb_server))); - memcpy(copy->servers[i], sl->servers[i], sizeof(xds_grpclb_server)); - } - return copy; -} - -bool xds_grpclb_serverlist_equals(const xds_grpclb_serverlist* lhs, - const xds_grpclb_serverlist* rhs) { - if (lhs == nullptr || rhs == nullptr) { - return false; - } - if (lhs->num_servers != rhs->num_servers) { - return false; - } - for (size_t i = 0; i < lhs->num_servers; i++) { - if (!xds_grpclb_server_equals(lhs->servers[i], rhs->servers[i])) { - return false; - } - } - return true; -} - -bool xds_grpclb_server_equals(const xds_grpclb_server* lhs, - const xds_grpclb_server* rhs) { - return memcmp(lhs, rhs, sizeof(xds_grpclb_server)) == 0; -} - -int xds_grpclb_duration_compare(const xds_grpclb_duration* lhs, - const xds_grpclb_duration* rhs) { - GPR_ASSERT(lhs && rhs); - if (lhs->has_seconds && rhs->has_seconds) { - if (lhs->seconds < rhs->seconds) return -1; - if (lhs->seconds > rhs->seconds) return 1; - } else if (lhs->has_seconds) { - return 1; - } else if (rhs->has_seconds) { - return -1; - } - - GPR_ASSERT(lhs->seconds == rhs->seconds); - if (lhs->has_nanos && rhs->has_nanos) { - if (lhs->nanos < rhs->nanos) return -1; - if (lhs->nanos > rhs->nanos) return 1; - } else if (lhs->has_nanos) { - return 1; - } else if (rhs->has_nanos) { - return -1; - } - - return 0; -} - -grpc_millis xds_grpclb_duration_to_millis(xds_grpclb_duration* duration_pb) { - return static_cast( - (duration_pb->has_seconds ? duration_pb->seconds : 0) * GPR_MS_PER_SEC + - (duration_pb->has_nanos ? duration_pb->nanos : 0) / GPR_NS_PER_MS); -} - -void xds_grpclb_initial_response_destroy( - xds_grpclb_initial_response* response) { - gpr_free(response); -} +} // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h index e52d20f8658..8e31584e257 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h @@ -23,67 +23,100 @@ #include -#include "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h" #include "src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h" -#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/ext/filters/client_channel/server_address.h" +#include "src/proto/grpc/lb/v1/load_balancer.upb.h" -#define XDS_SERVICE_NAME_MAX_LENGTH 128 +namespace grpc_core { -typedef grpc_lb_v1_Server_ip_address_t xds_grpclb_ip_address; typedef grpc_lb_v1_LoadBalanceRequest xds_grpclb_request; -typedef grpc_lb_v1_InitialLoadBalanceResponse xds_grpclb_initial_response; -typedef grpc_lb_v1_Server xds_grpclb_server; -typedef google_protobuf_Duration xds_grpclb_duration; -typedef google_protobuf_Timestamp xds_grpclb_timestamp; -typedef struct { - xds_grpclb_server** servers; - size_t num_servers; -} xds_grpclb_serverlist; +class XdsLocalityName : public RefCounted { + public: + struct Less { + bool operator()(const RefCountedPtr& lhs, + const RefCountedPtr& rhs) { + int cmp_result = strcmp(lhs->region_.get(), rhs->region_.get()); + if (cmp_result != 0) return cmp_result < 0; + cmp_result = strcmp(lhs->zone_.get(), rhs->zone_.get()); + if (cmp_result != 0) return cmp_result < 0; + return strcmp(lhs->sub_zone_.get(), rhs->sub_zone_.get()) < 0; + } + }; -/** Create a request for a gRPC LB service under \a lb_service_name */ -xds_grpclb_request* xds_grpclb_request_create(const char* lb_service_name); + XdsLocalityName(UniquePtr region, UniquePtr zone, + UniquePtr sub_zone) + : region_(std::move(region)), + zone_(std::move(zone)), + sub_zone_(std::move(sub_zone)) {} + + bool operator==(const XdsLocalityName& other) const { + return strcmp(region_.get(), other.region_.get()) == 0 && + strcmp(zone_.get(), other.zone_.get()) == 0 && + strcmp(sub_zone_.get(), other.sub_zone_.get()) == 0; + } + + const char* region() const { return region_.get(); } + const char* zone() const { return zone_.get(); } + const char* sub_zone() const { return sub_zone_.get(); } + + const char* AsHumanReadableString() { + if (human_readable_string_ == nullptr) { + char* tmp; + gpr_asprintf(&tmp, "{region=\"%s\", zone=\"%s\", sub_zone=\"%s\"}", + region_.get(), zone_.get(), sub_zone_.get()); + human_readable_string_.reset(tmp); + } + return human_readable_string_.get(); + } + + private: + UniquePtr region_; + UniquePtr zone_; + UniquePtr sub_zone_; + UniquePtr human_readable_string_; +}; + +struct XdsLocalityInfo { + bool operator==(const XdsLocalityInfo& other) const { + return *locality_name == *other.locality_name && + serverlist == other.serverlist && lb_weight == other.lb_weight && + priority == other.priority; + } + + // This comparator only compares the locality names. + struct Less { + bool operator()(const XdsLocalityInfo& lhs, const XdsLocalityInfo& rhs) { + return XdsLocalityName::Less()(lhs.locality_name, rhs.locality_name); + } + }; + + RefCountedPtr locality_name; + ServerAddressList serverlist; + uint32_t lb_weight; + uint32_t priority; +}; + +using XdsLocalityList = InlinedVector; + +struct XdsUpdate { + XdsLocalityList locality_list; + // TODO(juanlishen): Pass drop_per_million when adding drop support. +}; + +// Creates an EDS request querying \a service_name. +grpc_slice XdsEdsRequestCreateAndEncode(const char* service_name); + +// Parses the EDS response and returns the args to update locality map. If there +// is any error, the output update is invalid. +grpc_error* XdsEdsResponseDecodeAndParse(const grpc_slice& encoded_response, + XdsUpdate* update); + +// TODO(juanlishen): Delete these when LRS is added. xds_grpclb_request* xds_grpclb_load_report_request_create_locked( - grpc_core::XdsLbClientStats* client_stats); + grpc_core::XdsLbClientStats* client_stats, upb_arena* arena); -/** Protocol Buffers v3-encode \a request */ -grpc_slice xds_grpclb_request_encode(const xds_grpclb_request* request); - -/** Destroy \a request */ -void xds_grpclb_request_destroy(xds_grpclb_request* request); - -/** Parse (ie, decode) the bytes in \a encoded_xds_grpclb_response as a \a - * xds_grpclb_initial_response */ -xds_grpclb_initial_response* xds_grpclb_initial_response_parse( - const grpc_slice& encoded_xds_grpclb_response); - -/** Parse the list of servers from an encoded \a xds_grpclb_response */ -xds_grpclb_serverlist* xds_grpclb_response_parse_serverlist( - const grpc_slice& encoded_xds_grpclb_response); - -/** Return a copy of \a sl. The caller is responsible for calling \a - * xds_grpclb_destroy_serverlist on the returned copy. */ -xds_grpclb_serverlist* xds_grpclb_serverlist_copy( - const xds_grpclb_serverlist* sl); - -bool xds_grpclb_serverlist_equals(const xds_grpclb_serverlist* lhs, - const xds_grpclb_serverlist* rhs); - -bool xds_grpclb_server_equals(const xds_grpclb_server* lhs, - const xds_grpclb_server* rhs); - -/** Destroy \a serverlist */ -void xds_grpclb_destroy_serverlist(xds_grpclb_serverlist* serverlist); - -/** Compare \a lhs against \a rhs and return 0 if \a lhs and \a rhs are equal, - * < 0 if \a lhs represents a duration shorter than \a rhs and > 0 otherwise */ -int xds_grpclb_duration_compare(const xds_grpclb_duration* lhs, - const xds_grpclb_duration* rhs); - -grpc_millis xds_grpclb_duration_to_millis(xds_grpclb_duration* duration_pb); - -/** Destroy \a initial_response */ -void xds_grpclb_initial_response_destroy(xds_grpclb_initial_response* response); +} // namespace grpc_core #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_XDS_XDS_LOAD_BALANCER_API_H \ */ diff --git a/src/core/lib/transport/static_metadata.cc b/src/core/lib/transport/static_metadata.cc index 3085348d9e5..d72ea3f63ae 100644 --- a/src/core/lib/transport/static_metadata.cc +++ b/src/core/lib/transport/static_metadata.cc @@ -62,59 +62,62 @@ static uint8_t g_bytes[] = { 111, 110, 115, 101, 95, 109, 101, 115, 115, 97, 103, 101, 95, 98, 121, 116, 101, 115, 47, 103, 114, 112, 99, 46, 108, 98, 46, 118, 49, 46, 76, 111, 97, 100, 66, 97, 108, 97, 110, 99, 101, 114, 47, 66, 97, - 108, 97, 110, 99, 101, 76, 111, 97, 100, 47, 103, 114, 112, 99, 46, - 104, 101, 97, 108, 116, 104, 46, 118, 49, 46, 72, 101, 97, 108, 116, - 104, 47, 87, 97, 116, 99, 104, 47, 101, 110, 118, 111, 121, 46, 115, - 101, 114, 118, 105, 99, 101, 46, 100, 105, 115, 99, 111, 118, 101, 114, - 121, 46, 118, 50, 46, 65, 103, 103, 114, 101, 103, 97, 116, 101, 100, - 68, 105, 115, 99, 111, 118, 101, 114, 121, 83, 101, 114, 118, 105, 99, - 101, 47, 83, 116, 114, 101, 97, 109, 65, 103, 103, 114, 101, 103, 97, - 116, 101, 100, 82, 101, 115, 111, 117, 114, 99, 101, 115, 100, 101, 102, - 108, 97, 116, 101, 103, 122, 105, 112, 115, 116, 114, 101, 97, 109, 47, - 103, 122, 105, 112, 71, 69, 84, 80, 79, 83, 84, 47, 47, 105, 110, - 100, 101, 120, 46, 104, 116, 109, 108, 104, 116, 116, 112, 104, 116, 116, - 112, 115, 50, 48, 48, 50, 48, 52, 50, 48, 54, 51, 48, 52, 52, - 48, 48, 52, 48, 52, 53, 48, 48, 97, 99, 99, 101, 112, 116, 45, - 99, 104, 97, 114, 115, 101, 116, 103, 122, 105, 112, 44, 32, 100, 101, - 102, 108, 97, 116, 101, 97, 99, 99, 101, 112, 116, 45, 108, 97, 110, - 103, 117, 97, 103, 101, 97, 99, 99, 101, 112, 116, 45, 114, 97, 110, - 103, 101, 115, 97, 99, 99, 101, 112, 116, 97, 99, 99, 101, 115, 115, - 45, 99, 111, 110, 116, 114, 111, 108, 45, 97, 108, 108, 111, 119, 45, - 111, 114, 105, 103, 105, 110, 97, 103, 101, 97, 108, 108, 111, 119, 97, - 117, 116, 104, 111, 114, 105, 122, 97, 116, 105, 111, 110, 99, 97, 99, - 104, 101, 45, 99, 111, 110, 116, 114, 111, 108, 99, 111, 110, 116, 101, - 110, 116, 45, 100, 105, 115, 112, 111, 115, 105, 116, 105, 111, 110, 99, - 111, 110, 116, 101, 110, 116, 45, 108, 97, 110, 103, 117, 97, 103, 101, - 99, 111, 110, 116, 101, 110, 116, 45, 108, 101, 110, 103, 116, 104, 99, - 111, 110, 116, 101, 110, 116, 45, 108, 111, 99, 97, 116, 105, 111, 110, - 99, 111, 110, 116, 101, 110, 116, 45, 114, 97, 110, 103, 101, 99, 111, - 111, 107, 105, 101, 100, 97, 116, 101, 101, 116, 97, 103, 101, 120, 112, - 101, 99, 116, 101, 120, 112, 105, 114, 101, 115, 102, 114, 111, 109, 105, - 102, 45, 109, 97, 116, 99, 104, 105, 102, 45, 109, 111, 100, 105, 102, - 105, 101, 100, 45, 115, 105, 110, 99, 101, 105, 102, 45, 110, 111, 110, - 101, 45, 109, 97, 116, 99, 104, 105, 102, 45, 114, 97, 110, 103, 101, - 105, 102, 45, 117, 110, 109, 111, 100, 105, 102, 105, 101, 100, 45, 115, - 105, 110, 99, 101, 108, 97, 115, 116, 45, 109, 111, 100, 105, 102, 105, - 101, 100, 108, 105, 110, 107, 108, 111, 99, 97, 116, 105, 111, 110, 109, - 97, 120, 45, 102, 111, 114, 119, 97, 114, 100, 115, 112, 114, 111, 120, - 121, 45, 97, 117, 116, 104, 101, 110, 116, 105, 99, 97, 116, 101, 112, - 114, 111, 120, 121, 45, 97, 117, 116, 104, 111, 114, 105, 122, 97, 116, - 105, 111, 110, 114, 97, 110, 103, 101, 114, 101, 102, 101, 114, 101, 114, - 114, 101, 102, 114, 101, 115, 104, 114, 101, 116, 114, 121, 45, 97, 102, - 116, 101, 114, 115, 101, 114, 118, 101, 114, 115, 101, 116, 45, 99, 111, - 111, 107, 105, 101, 115, 116, 114, 105, 99, 116, 45, 116, 114, 97, 110, - 115, 112, 111, 114, 116, 45, 115, 101, 99, 117, 114, 105, 116, 121, 116, - 114, 97, 110, 115, 102, 101, 114, 45, 101, 110, 99, 111, 100, 105, 110, - 103, 118, 97, 114, 121, 118, 105, 97, 119, 119, 119, 45, 97, 117, 116, - 104, 101, 110, 116, 105, 99, 97, 116, 101, 48, 105, 100, 101, 110, 116, - 105, 116, 121, 116, 114, 97, 105, 108, 101, 114, 115, 97, 112, 112, 108, - 105, 99, 97, 116, 105, 111, 110, 47, 103, 114, 112, 99, 103, 114, 112, - 99, 80, 85, 84, 108, 98, 45, 99, 111, 115, 116, 45, 98, 105, 110, - 105, 100, 101, 110, 116, 105, 116, 121, 44, 100, 101, 102, 108, 97, 116, - 101, 105, 100, 101, 110, 116, 105, 116, 121, 44, 103, 122, 105, 112, 100, - 101, 102, 108, 97, 116, 101, 44, 103, 122, 105, 112, 105, 100, 101, 110, - 116, 105, 116, 121, 44, 100, 101, 102, 108, 97, 116, 101, 44, 103, 122, - 105, 112}; + 108, 97, 110, 99, 101, 76, 111, 97, 100, 47, 101, 110, 118, 111, 121, + 46, 97, 112, 105, 46, 118, 50, 46, 69, 110, 100, 112, 111, 105, 110, + 116, 68, 105, 115, 99, 111, 118, 101, 114, 121, 83, 101, 114, 118, 105, + 99, 101, 47, 83, 116, 114, 101, 97, 109, 69, 110, 100, 112, 111, 105, + 110, 116, 115, 47, 103, 114, 112, 99, 46, 104, 101, 97, 108, 116, 104, + 46, 118, 49, 46, 72, 101, 97, 108, 116, 104, 47, 87, 97, 116, 99, + 104, 47, 101, 110, 118, 111, 121, 46, 115, 101, 114, 118, 105, 99, 101, + 46, 100, 105, 115, 99, 111, 118, 101, 114, 121, 46, 118, 50, 46, 65, + 103, 103, 114, 101, 103, 97, 116, 101, 100, 68, 105, 115, 99, 111, 118, + 101, 114, 121, 83, 101, 114, 118, 105, 99, 101, 47, 83, 116, 114, 101, + 97, 109, 65, 103, 103, 114, 101, 103, 97, 116, 101, 100, 82, 101, 115, + 111, 117, 114, 99, 101, 115, 100, 101, 102, 108, 97, 116, 101, 103, 122, + 105, 112, 115, 116, 114, 101, 97, 109, 47, 103, 122, 105, 112, 71, 69, + 84, 80, 79, 83, 84, 47, 47, 105, 110, 100, 101, 120, 46, 104, 116, + 109, 108, 104, 116, 116, 112, 104, 116, 116, 112, 115, 50, 48, 48, 50, + 48, 52, 50, 48, 54, 51, 48, 52, 52, 48, 48, 52, 48, 52, 53, + 48, 48, 97, 99, 99, 101, 112, 116, 45, 99, 104, 97, 114, 115, 101, + 116, 103, 122, 105, 112, 44, 32, 100, 101, 102, 108, 97, 116, 101, 97, + 99, 99, 101, 112, 116, 45, 108, 97, 110, 103, 117, 97, 103, 101, 97, + 99, 99, 101, 112, 116, 45, 114, 97, 110, 103, 101, 115, 97, 99, 99, + 101, 112, 116, 97, 99, 99, 101, 115, 115, 45, 99, 111, 110, 116, 114, + 111, 108, 45, 97, 108, 108, 111, 119, 45, 111, 114, 105, 103, 105, 110, + 97, 103, 101, 97, 108, 108, 111, 119, 97, 117, 116, 104, 111, 114, 105, + 122, 97, 116, 105, 111, 110, 99, 97, 99, 104, 101, 45, 99, 111, 110, + 116, 114, 111, 108, 99, 111, 110, 116, 101, 110, 116, 45, 100, 105, 115, + 112, 111, 115, 105, 116, 105, 111, 110, 99, 111, 110, 116, 101, 110, 116, + 45, 108, 97, 110, 103, 117, 97, 103, 101, 99, 111, 110, 116, 101, 110, + 116, 45, 108, 101, 110, 103, 116, 104, 99, 111, 110, 116, 101, 110, 116, + 45, 108, 111, 99, 97, 116, 105, 111, 110, 99, 111, 110, 116, 101, 110, + 116, 45, 114, 97, 110, 103, 101, 99, 111, 111, 107, 105, 101, 100, 97, + 116, 101, 101, 116, 97, 103, 101, 120, 112, 101, 99, 116, 101, 120, 112, + 105, 114, 101, 115, 102, 114, 111, 109, 105, 102, 45, 109, 97, 116, 99, + 104, 105, 102, 45, 109, 111, 100, 105, 102, 105, 101, 100, 45, 115, 105, + 110, 99, 101, 105, 102, 45, 110, 111, 110, 101, 45, 109, 97, 116, 99, + 104, 105, 102, 45, 114, 97, 110, 103, 101, 105, 102, 45, 117, 110, 109, + 111, 100, 105, 102, 105, 101, 100, 45, 115, 105, 110, 99, 101, 108, 97, + 115, 116, 45, 109, 111, 100, 105, 102, 105, 101, 100, 108, 105, 110, 107, + 108, 111, 99, 97, 116, 105, 111, 110, 109, 97, 120, 45, 102, 111, 114, + 119, 97, 114, 100, 115, 112, 114, 111, 120, 121, 45, 97, 117, 116, 104, + 101, 110, 116, 105, 99, 97, 116, 101, 112, 114, 111, 120, 121, 45, 97, + 117, 116, 104, 111, 114, 105, 122, 97, 116, 105, 111, 110, 114, 97, 110, + 103, 101, 114, 101, 102, 101, 114, 101, 114, 114, 101, 102, 114, 101, 115, + 104, 114, 101, 116, 114, 121, 45, 97, 102, 116, 101, 114, 115, 101, 114, + 118, 101, 114, 115, 101, 116, 45, 99, 111, 111, 107, 105, 101, 115, 116, + 114, 105, 99, 116, 45, 116, 114, 97, 110, 115, 112, 111, 114, 116, 45, + 115, 101, 99, 117, 114, 105, 116, 121, 116, 114, 97, 110, 115, 102, 101, + 114, 45, 101, 110, 99, 111, 100, 105, 110, 103, 118, 97, 114, 121, 118, + 105, 97, 119, 119, 119, 45, 97, 117, 116, 104, 101, 110, 116, 105, 99, + 97, 116, 101, 48, 105, 100, 101, 110, 116, 105, 116, 121, 116, 114, 97, + 105, 108, 101, 114, 115, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, + 110, 47, 103, 114, 112, 99, 103, 114, 112, 99, 80, 85, 84, 108, 98, + 45, 99, 111, 115, 116, 45, 98, 105, 110, 105, 100, 101, 110, 116, 105, + 116, 121, 44, 100, 101, 102, 108, 97, 116, 101, 105, 100, 101, 110, 116, + 105, 116, 121, 44, 103, 122, 105, 112, 100, 101, 102, 108, 97, 116, 101, + 44, 103, 122, 105, 112, 105, 100, 101, 110, 116, 105, 116, 121, 44, 100, + 101, 102, 108, 97, 116, 101, 44, 103, 122, 105, 112}; grpc_slice_refcount grpc_core::StaticSliceRefcount::kStaticSubRefcount; grpc_core::StaticSliceRefcount @@ -225,6 +228,7 @@ grpc_core::StaticSliceRefcount grpc_core::StaticSliceRefcount(103), grpc_core::StaticSliceRefcount(104), grpc_core::StaticSliceRefcount(105), + grpc_core::StaticSliceRefcount(106), }; const grpc_core::StaticMetadataSlice @@ -298,149 +302,151 @@ const grpc_core::StaticMetadataSlice grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[33].base, 36, g_bytes + 438), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[34].base, - 28, g_bytes + 474), + 54, g_bytes + 474), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[35].base, - 80, g_bytes + 502), + 28, g_bytes + 528), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[36].base, - 7, g_bytes + 582), + 80, g_bytes + 556), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37].base, - 4, g_bytes + 589), + 7, g_bytes + 636), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[38].base, - 11, g_bytes + 593), + 4, g_bytes + 643), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[39].base, - 3, g_bytes + 604), + 11, g_bytes + 647), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[40].base, - 4, g_bytes + 607), + 3, g_bytes + 658), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[41].base, - 1, g_bytes + 611), + 4, g_bytes + 661), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[42].base, - 11, g_bytes + 612), + 1, g_bytes + 665), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[43].base, - 4, g_bytes + 623), + 11, g_bytes + 666), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[44].base, - 5, g_bytes + 627), + 4, g_bytes + 677), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[45].base, - 3, g_bytes + 632), + 5, g_bytes + 681), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[46].base, - 3, g_bytes + 635), + 3, g_bytes + 686), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[47].base, - 3, g_bytes + 638), + 3, g_bytes + 689), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[48].base, - 3, g_bytes + 641), + 3, g_bytes + 692), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[49].base, - 3, g_bytes + 644), + 3, g_bytes + 695), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[50].base, - 3, g_bytes + 647), + 3, g_bytes + 698), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[51].base, - 3, g_bytes + 650), + 3, g_bytes + 701), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[52].base, - 14, g_bytes + 653), + 3, g_bytes + 704), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[53].base, - 13, g_bytes + 667), + 14, g_bytes + 707), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[54].base, - 15, g_bytes + 680), + 13, g_bytes + 721), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[55].base, - 13, g_bytes + 695), + 15, g_bytes + 734), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[56].base, - 6, g_bytes + 708), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[57].base, - 27, g_bytes + 714), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[58].base, - 3, g_bytes + 741), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[59].base, - 5, g_bytes + 744), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[60].base, 13, g_bytes + 749), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[57].base, + 6, g_bytes + 762), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[58].base, + 27, g_bytes + 768), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[59].base, + 3, g_bytes + 795), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[60].base, + 5, g_bytes + 798), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[61].base, - 13, g_bytes + 762), + 13, g_bytes + 803), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[62].base, - 19, g_bytes + 775), + 13, g_bytes + 816), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[63].base, - 16, g_bytes + 794), + 19, g_bytes + 829), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[64].base, - 14, g_bytes + 810), + 16, g_bytes + 848), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[65].base, - 16, g_bytes + 824), + 14, g_bytes + 864), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[66].base, - 13, g_bytes + 840), + 16, g_bytes + 878), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[67].base, - 6, g_bytes + 853), + 13, g_bytes + 894), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[68].base, - 4, g_bytes + 859), + 6, g_bytes + 907), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[69].base, - 4, g_bytes + 863), + 4, g_bytes + 913), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[70].base, - 6, g_bytes + 867), + 4, g_bytes + 917), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[71].base, - 7, g_bytes + 873), + 6, g_bytes + 921), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[72].base, - 4, g_bytes + 880), + 7, g_bytes + 927), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[73].base, - 8, g_bytes + 884), + 4, g_bytes + 934), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[74].base, - 17, g_bytes + 892), + 8, g_bytes + 938), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[75].base, - 13, g_bytes + 909), + 17, g_bytes + 946), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[76].base, - 8, g_bytes + 922), + 13, g_bytes + 963), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[77].base, - 19, g_bytes + 930), + 8, g_bytes + 976), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[78].base, - 13, g_bytes + 949), + 19, g_bytes + 984), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[79].base, - 4, g_bytes + 962), + 13, g_bytes + 1003), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[80].base, - 8, g_bytes + 966), + 4, g_bytes + 1016), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[81].base, - 12, g_bytes + 974), + 8, g_bytes + 1020), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[82].base, - 18, g_bytes + 986), + 12, g_bytes + 1028), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[83].base, - 19, g_bytes + 1004), + 18, g_bytes + 1040), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[84].base, - 5, g_bytes + 1023), + 19, g_bytes + 1058), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[85].base, - 7, g_bytes + 1028), + 5, g_bytes + 1077), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[86].base, - 7, g_bytes + 1035), + 7, g_bytes + 1082), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[87].base, - 11, g_bytes + 1042), + 7, g_bytes + 1089), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[88].base, - 6, g_bytes + 1053), + 11, g_bytes + 1096), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[89].base, - 10, g_bytes + 1059), + 6, g_bytes + 1107), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[90].base, - 25, g_bytes + 1069), + 10, g_bytes + 1113), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[91].base, - 17, g_bytes + 1094), + 25, g_bytes + 1123), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[92].base, - 4, g_bytes + 1111), + 17, g_bytes + 1148), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[93].base, - 3, g_bytes + 1115), + 4, g_bytes + 1165), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[94].base, - 16, g_bytes + 1118), + 3, g_bytes + 1169), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[95].base, - 1, g_bytes + 1134), + 16, g_bytes + 1172), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96].base, - 8, g_bytes + 1135), + 1, g_bytes + 1188), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97].base, - 8, g_bytes + 1143), + 8, g_bytes + 1189), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98].base, - 16, g_bytes + 1151), + 8, g_bytes + 1197), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[99].base, - 4, g_bytes + 1167), + 16, g_bytes + 1205), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[100].base, 3, g_bytes + 1171), + &grpc_static_metadata_refcounts[100].base, 4, g_bytes + 1221), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[101].base, 11, g_bytes + 1174), + &grpc_static_metadata_refcounts[101].base, 3, g_bytes + 1225), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[102].base, 16, g_bytes + 1185), + &grpc_static_metadata_refcounts[102].base, 11, g_bytes + 1228), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[103].base, 13, g_bytes + 1201), + &grpc_static_metadata_refcounts[103].base, 16, g_bytes + 1239), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[104].base, 12, g_bytes + 1214), + &grpc_static_metadata_refcounts[104].base, 13, g_bytes + 1255), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[105].base, 21, g_bytes + 1226), + &grpc_static_metadata_refcounts[105].base, 12, g_bytes + 1268), + grpc_core::StaticMetadataSlice( + &grpc_static_metadata_refcounts[106].base, 21, g_bytes + 1280), }; /* Warning: the core static metadata currently operates under the soft @@ -886,17 +892,17 @@ uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 4, 6, 6, 8, 8, 2, 4, 4}; static const int8_t elems_r[] = { - 15, 10, -8, 0, 2, -42, -80, -43, 0, 6, -8, 0, 0, 0, 2, - -3, -10, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, -63, 0, -47, -68, -69, -70, -52, 0, - 31, 30, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, - 18, 17, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, - 4, 3, 4, 3, 3, 7, 0, 0, 0, 0, 0, 0, -5, 0}; + 15, 10, -8, 0, 2, -43, -81, -43, 0, 4, -8, 0, 0, 0, 8, + -2, -9, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, -64, 0, -67, -68, -69, -51, -72, + 0, 32, 31, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, + 19, 18, 17, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, + 5, 4, 3, 4, 3, 3, 8, 0, 0, 0, 0, 0, 0, -5, 0}; static uint32_t elems_phash(uint32_t i) { - i -= 41; - uint32_t x = i % 104; - uint32_t y = i / 104; + i -= 42; + uint32_t x = i % 105; + uint32_t y = i / 105; uint32_t h = x; if (y < GPR_ARRAY_SIZE(elems_r)) { uint32_t delta = (uint32_t)elems_r[y]; @@ -906,28 +912,29 @@ static uint32_t elems_phash(uint32_t i) { } static const uint16_t elem_keys[] = { - 257, 258, 259, 260, 261, 262, 263, 1096, 1097, 1724, 145, 146, - 467, 468, 1618, 41, 42, 1512, 1733, 990, 991, 766, 767, 1627, - 627, 837, 2042, 2148, 5540, 5858, 5964, 6070, 6282, 6388, 1749, 6494, - 6600, 6706, 6812, 6918, 7024, 7130, 7236, 7342, 7448, 7554, 7660, 7766, - 5752, 7872, 7978, 6176, 8084, 8190, 8296, 8402, 8508, 8614, 8720, 8826, - 8932, 9038, 9144, 9250, 9356, 9462, 9568, 1156, 523, 9674, 9780, 206, - 9886, 1162, 1163, 1164, 1165, 1792, 9992, 1050, 10734, 0, 1686, 0, - 1799, 0, 0, 1582, 0, 346, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0}; + 260, 261, 262, 263, 264, 265, 266, 1107, 1108, 1740, 147, 148, + 472, 473, 1633, 42, 43, 1000, 1001, 1750, 773, 774, 1526, 633, + 1643, 845, 2061, 2168, 5699, 5913, 6020, 6127, 6341, 6448, 6555, 1766, + 6662, 6769, 6876, 6983, 7090, 7197, 7304, 7411, 7518, 7625, 7732, 7839, + 7946, 8053, 8160, 6234, 8267, 8374, 8481, 8588, 8695, 8802, 8909, 9016, + 9123, 9230, 9337, 9444, 9551, 9658, 9765, 1167, 528, 9872, 9979, 208, + 10086, 1173, 1174, 1175, 1176, 1060, 1809, 10193, 10942, 0, 0, 1702, + 0, 1816, 0, 0, 0, 349, 0, 0, 0, 1597, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0}; static const uint8_t elem_idxs[] = { - 7, 8, 9, 10, 11, 12, 13, 76, 78, 71, 1, 2, 5, 6, 25, 3, 4, 30, - 83, 66, 65, 62, 63, 73, 67, 61, 57, 37, 14, 17, 18, 19, 21, 22, 15, 23, - 24, 26, 27, 28, 29, 31, 32, 33, 34, 35, 36, 38, 16, 39, 40, 20, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 75, 69, 56, 58, 70, - 59, 77, 79, 80, 81, 82, 60, 64, 74, 255, 72, 255, 84, 255, 255, 68, 255, 0}; + 7, 8, 9, 10, 11, 12, 13, 76, 78, 71, 1, 2, 5, 6, 25, 3, + 4, 66, 65, 83, 62, 63, 30, 67, 73, 61, 57, 37, 14, 16, 17, 18, + 20, 21, 22, 15, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34, 35, 36, + 38, 39, 40, 19, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 75, 69, 56, 58, 70, 59, 77, 79, 80, 81, 64, 82, 60, + 74, 255, 255, 72, 255, 84, 255, 255, 255, 0, 255, 255, 255, 68}; grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b) { if (a == -1 || b == -1) return GRPC_MDNULL; - uint32_t k = static_cast(a * 106 + b); + uint32_t k = static_cast(a * 107 + b); uint32_t h = elems_phash(k); return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k && elem_idxs[h] != 255 @@ -946,144 +953,144 @@ grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1].base, 7, g_bytes + 5), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[39].base, - 3, g_bytes + 604), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[40].base, + 3, g_bytes + 658), 1), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1].base, 7, g_bytes + 5), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[40].base, - 4, g_bytes + 607), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[41].base, + 4, g_bytes + 661), 2), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[0].base, 5, g_bytes + 0), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[41].base, - 1, g_bytes + 611), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[42].base, + 1, g_bytes + 665), 3), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[0].base, 5, g_bytes + 0), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[42].base, - 11, g_bytes + 612), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[43].base, + 11, g_bytes + 666), 4), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4].base, 7, g_bytes + 29), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[43].base, - 4, g_bytes + 623), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[44].base, + 4, g_bytes + 677), 5), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4].base, 7, g_bytes + 29), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[44].base, - 5, g_bytes + 627), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[45].base, + 5, g_bytes + 681), 6), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[45].base, - 3, g_bytes + 632), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[46].base, + 3, g_bytes + 686), 7), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[46].base, - 3, g_bytes + 635), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[47].base, + 3, g_bytes + 689), 8), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[47].base, - 3, g_bytes + 638), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[48].base, + 3, g_bytes + 692), 9), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[48].base, - 3, g_bytes + 641), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[49].base, + 3, g_bytes + 695), 10), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[49].base, - 3, g_bytes + 644), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[50].base, + 3, g_bytes + 698), 11), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[50].base, - 3, g_bytes + 647), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[51].base, + 3, g_bytes + 701), 12), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[51].base, - 3, g_bytes + 650), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[52].base, + 3, g_bytes + 704), 13), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[52].base, - 14, g_bytes + 653), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[53].base, + 14, g_bytes + 707), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 14), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, 15, g_bytes + 186), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[53].base, - 13, g_bytes + 667), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[54].base, + 13, g_bytes + 721), 15), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[54].base, - 15, g_bytes + 680), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[55].base, + 15, g_bytes + 734), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 16), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[55].base, - 13, g_bytes + 695), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[56].base, + 13, g_bytes + 749), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 17), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[56].base, - 6, g_bytes + 708), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[57].base, + 6, g_bytes + 762), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 18), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[57].base, - 27, g_bytes + 714), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[58].base, + 27, g_bytes + 768), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 19), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[58].base, - 3, g_bytes + 741), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[59].base, + 3, g_bytes + 795), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 20), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[59].base, - 5, g_bytes + 744), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[60].base, + 5, g_bytes + 798), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 21), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[60].base, - 13, g_bytes + 749), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[61].base, + 13, g_bytes + 803), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 22), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[61].base, - 13, g_bytes + 762), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[62].base, + 13, g_bytes + 816), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 23), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[62].base, - 19, g_bytes + 775), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[63].base, + 19, g_bytes + 829), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 24), @@ -1094,26 +1101,26 @@ grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { 0, g_bytes + 346), 25), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[63].base, - 16, g_bytes + 794), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[64].base, + 16, g_bytes + 848), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 26), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[64].base, - 14, g_bytes + 810), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[65].base, + 14, g_bytes + 864), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 27), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[65].base, - 16, g_bytes + 824), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[66].base, + 16, g_bytes + 878), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 28), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[66].base, - 13, g_bytes + 840), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[67].base, + 13, g_bytes + 894), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 29), @@ -1124,38 +1131,38 @@ grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { 0, g_bytes + 346), 30), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[67].base, - 6, g_bytes + 853), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[68].base, + 6, g_bytes + 907), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 31), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[68].base, - 4, g_bytes + 859), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[69].base, + 4, g_bytes + 913), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 32), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[69].base, - 4, g_bytes + 863), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[70].base, + 4, g_bytes + 917), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 33), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[70].base, - 6, g_bytes + 867), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[71].base, + 6, g_bytes + 921), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 34), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[71].base, - 7, g_bytes + 873), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[72].base, + 7, g_bytes + 927), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 35), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[72].base, - 4, g_bytes + 880), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[73].base, + 4, g_bytes + 934), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 36), @@ -1166,116 +1173,116 @@ grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { 0, g_bytes + 346), 37), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[73].base, - 8, g_bytes + 884), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[74].base, + 8, g_bytes + 938), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 38), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[74].base, - 17, g_bytes + 892), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[75].base, + 17, g_bytes + 946), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 39), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[75].base, - 13, g_bytes + 909), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[76].base, + 13, g_bytes + 963), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 40), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[76].base, - 8, g_bytes + 922), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[77].base, + 8, g_bytes + 976), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 41), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[77].base, - 19, g_bytes + 930), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[78].base, + 19, g_bytes + 984), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 42), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[78].base, - 13, g_bytes + 949), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[79].base, + 13, g_bytes + 1003), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 43), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[79].base, - 4, g_bytes + 962), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[80].base, + 4, g_bytes + 1016), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 44), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[80].base, - 8, g_bytes + 966), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[81].base, + 8, g_bytes + 1020), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 45), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[81].base, - 12, g_bytes + 974), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[82].base, + 12, g_bytes + 1028), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 46), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[82].base, - 18, g_bytes + 986), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[83].base, + 18, g_bytes + 1040), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 47), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[83].base, - 19, g_bytes + 1004), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[84].base, + 19, g_bytes + 1058), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 48), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[84].base, - 5, g_bytes + 1023), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[85].base, + 5, g_bytes + 1077), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 49), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[85].base, - 7, g_bytes + 1028), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[86].base, + 7, g_bytes + 1082), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 50), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[86].base, - 7, g_bytes + 1035), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[87].base, + 7, g_bytes + 1089), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 51), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[87].base, - 11, g_bytes + 1042), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[88].base, + 11, g_bytes + 1096), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 52), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[88].base, - 6, g_bytes + 1053), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[89].base, + 6, g_bytes + 1107), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 53), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[89].base, - 10, g_bytes + 1059), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[90].base, + 10, g_bytes + 1113), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 54), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[90].base, - 25, g_bytes + 1069), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[91].base, + 25, g_bytes + 1123), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 55), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[91].base, - 17, g_bytes + 1094), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[92].base, + 17, g_bytes + 1148), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 56), @@ -1286,28 +1293,28 @@ grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { 0, g_bytes + 346), 57), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[92].base, - 4, g_bytes + 1111), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[93].base, + 4, g_bytes + 1165), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 58), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[93].base, - 3, g_bytes + 1115), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[94].base, + 3, g_bytes + 1169), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 59), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[94].base, - 16, g_bytes + 1118), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[95].base, + 16, g_bytes + 1172), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 60), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7].base, 11, g_bytes + 50), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[95].base, - 1, g_bytes + 1134), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96].base, + 1, g_bytes + 1188), 61), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7].base, @@ -1324,44 +1331,44 @@ grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9].base, 13, g_bytes + 77), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96].base, - 8, g_bytes + 1135), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97].base, + 8, g_bytes + 1189), 64), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9].base, 13, g_bytes + 77), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37].base, - 4, g_bytes + 589), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[38].base, + 4, g_bytes + 643), 65), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9].base, 13, g_bytes + 77), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[36].base, - 7, g_bytes + 582), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37].base, + 7, g_bytes + 636), 66), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[5].base, 2, g_bytes + 36), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97].base, - 8, g_bytes + 1143), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98].base, + 8, g_bytes + 1197), 67), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[14].base, 12, g_bytes + 158), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98].base, - 16, g_bytes + 1151), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[99].base, + 16, g_bytes + 1205), 68), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4].base, 7, g_bytes + 29), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[99].base, - 4, g_bytes + 1167), + grpc_core::StaticMetadataSlice( + &grpc_static_metadata_refcounts[100].base, 4, g_bytes + 1221), 69), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1].base, 7, g_bytes + 5), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[100].base, 3, g_bytes + 1171), + &grpc_static_metadata_refcounts[101].base, 3, g_bytes + 1225), 70), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, @@ -1372,80 +1379,80 @@ grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15].base, 16, g_bytes + 170), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96].base, - 8, g_bytes + 1135), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97].base, + 8, g_bytes + 1189), 72), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15].base, 16, g_bytes + 170), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37].base, - 4, g_bytes + 589), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[38].base, + 4, g_bytes + 643), 73), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[101].base, 11, g_bytes + 1174), + &grpc_static_metadata_refcounts[102].base, 11, g_bytes + 1228), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 74), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, 20, g_bytes + 90), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96].base, - 8, g_bytes + 1135), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97].base, + 8, g_bytes + 1189), 75), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, 20, g_bytes + 90), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[36].base, - 7, g_bytes + 582), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37].base, + 7, g_bytes + 636), 76), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, 20, g_bytes + 90), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[102].base, 16, g_bytes + 1185), + &grpc_static_metadata_refcounts[103].base, 16, g_bytes + 1239), 77), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, 20, g_bytes + 90), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37].base, - 4, g_bytes + 589), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[38].base, + 4, g_bytes + 643), 78), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, 20, g_bytes + 90), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[103].base, 13, g_bytes + 1201), + &grpc_static_metadata_refcounts[104].base, 13, g_bytes + 1255), 79), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, 20, g_bytes + 90), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[104].base, 12, g_bytes + 1214), + &grpc_static_metadata_refcounts[105].base, 12, g_bytes + 1268), 80), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, 20, g_bytes + 90), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[105].base, 21, g_bytes + 1226), + &grpc_static_metadata_refcounts[106].base, 21, g_bytes + 1280), 81), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, 15, g_bytes + 186), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96].base, - 8, g_bytes + 1135), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97].base, + 8, g_bytes + 1189), 82), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, 15, g_bytes + 186), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37].base, - 4, g_bytes + 589), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[38].base, + 4, g_bytes + 643), 83), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, 15, g_bytes + 186), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[103].base, 13, g_bytes + 1201), + &grpc_static_metadata_refcounts[104].base, 13, g_bytes + 1255), 84), }; const uint8_t grpc_static_accept_encoding_metadata[8] = {0, 75, 76, 77, diff --git a/src/core/lib/transport/static_metadata.h b/src/core/lib/transport/static_metadata.h index 30082985b5c..787bae7ede5 100644 --- a/src/core/lib/transport/static_metadata.h +++ b/src/core/lib/transport/static_metadata.h @@ -36,7 +36,7 @@ static_assert( std::is_trivially_destructible::value, "grpc_core::StaticMetadataSlice must be trivially destructible."); -#define GRPC_STATIC_MDSTR_COUNT 106 +#define GRPC_STATIC_MDSTR_COUNT 107 extern const grpc_core::StaticMetadataSlice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT]; /* ":path" */ @@ -111,154 +111,157 @@ extern const grpc_core::StaticMetadataSlice /* "/grpc.lb.v1.LoadBalancer/BalanceLoad" */ #define GRPC_MDSTR_SLASH_GRPC_DOT_LB_DOT_V1_DOT_LOADBALANCER_SLASH_BALANCELOAD \ (grpc_static_slice_table[33]) +/* "/envoy.api.v2.EndpointDiscoveryService/StreamEndpoints" */ +#define GRPC_MDSTR_SLASH_ENVOY_DOT_API_DOT_V2_DOT_ENDPOINTDISCOVERYSERVICE_SLASH_STREAMENDPOINTS \ + (grpc_static_slice_table[34]) /* "/grpc.health.v1.Health/Watch" */ #define GRPC_MDSTR_SLASH_GRPC_DOT_HEALTH_DOT_V1_DOT_HEALTH_SLASH_WATCH \ - (grpc_static_slice_table[34]) + (grpc_static_slice_table[35]) /* "/envoy.service.discovery.v2.AggregatedDiscoveryService/StreamAggregatedResources" */ #define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_DISCOVERY_DOT_V2_DOT_AGGREGATEDDISCOVERYSERVICE_SLASH_STREAMAGGREGATEDRESOURCES \ - (grpc_static_slice_table[35]) + (grpc_static_slice_table[36]) /* "deflate" */ -#define GRPC_MDSTR_DEFLATE (grpc_static_slice_table[36]) +#define GRPC_MDSTR_DEFLATE (grpc_static_slice_table[37]) /* "gzip" */ -#define GRPC_MDSTR_GZIP (grpc_static_slice_table[37]) +#define GRPC_MDSTR_GZIP (grpc_static_slice_table[38]) /* "stream/gzip" */ -#define GRPC_MDSTR_STREAM_SLASH_GZIP (grpc_static_slice_table[38]) +#define GRPC_MDSTR_STREAM_SLASH_GZIP (grpc_static_slice_table[39]) /* "GET" */ -#define GRPC_MDSTR_GET (grpc_static_slice_table[39]) +#define GRPC_MDSTR_GET (grpc_static_slice_table[40]) /* "POST" */ -#define GRPC_MDSTR_POST (grpc_static_slice_table[40]) +#define GRPC_MDSTR_POST (grpc_static_slice_table[41]) /* "/" */ -#define GRPC_MDSTR_SLASH (grpc_static_slice_table[41]) +#define GRPC_MDSTR_SLASH (grpc_static_slice_table[42]) /* "/index.html" */ -#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (grpc_static_slice_table[42]) +#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (grpc_static_slice_table[43]) /* "http" */ -#define GRPC_MDSTR_HTTP (grpc_static_slice_table[43]) +#define GRPC_MDSTR_HTTP (grpc_static_slice_table[44]) /* "https" */ -#define GRPC_MDSTR_HTTPS (grpc_static_slice_table[44]) +#define GRPC_MDSTR_HTTPS (grpc_static_slice_table[45]) /* "200" */ -#define GRPC_MDSTR_200 (grpc_static_slice_table[45]) +#define GRPC_MDSTR_200 (grpc_static_slice_table[46]) /* "204" */ -#define GRPC_MDSTR_204 (grpc_static_slice_table[46]) +#define GRPC_MDSTR_204 (grpc_static_slice_table[47]) /* "206" */ -#define GRPC_MDSTR_206 (grpc_static_slice_table[47]) +#define GRPC_MDSTR_206 (grpc_static_slice_table[48]) /* "304" */ -#define GRPC_MDSTR_304 (grpc_static_slice_table[48]) +#define GRPC_MDSTR_304 (grpc_static_slice_table[49]) /* "400" */ -#define GRPC_MDSTR_400 (grpc_static_slice_table[49]) +#define GRPC_MDSTR_400 (grpc_static_slice_table[50]) /* "404" */ -#define GRPC_MDSTR_404 (grpc_static_slice_table[50]) +#define GRPC_MDSTR_404 (grpc_static_slice_table[51]) /* "500" */ -#define GRPC_MDSTR_500 (grpc_static_slice_table[51]) +#define GRPC_MDSTR_500 (grpc_static_slice_table[52]) /* "accept-charset" */ -#define GRPC_MDSTR_ACCEPT_CHARSET (grpc_static_slice_table[52]) +#define GRPC_MDSTR_ACCEPT_CHARSET (grpc_static_slice_table[53]) /* "gzip, deflate" */ -#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (grpc_static_slice_table[53]) +#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (grpc_static_slice_table[54]) /* "accept-language" */ -#define GRPC_MDSTR_ACCEPT_LANGUAGE (grpc_static_slice_table[54]) +#define GRPC_MDSTR_ACCEPT_LANGUAGE (grpc_static_slice_table[55]) /* "accept-ranges" */ -#define GRPC_MDSTR_ACCEPT_RANGES (grpc_static_slice_table[55]) +#define GRPC_MDSTR_ACCEPT_RANGES (grpc_static_slice_table[56]) /* "accept" */ -#define GRPC_MDSTR_ACCEPT (grpc_static_slice_table[56]) +#define GRPC_MDSTR_ACCEPT (grpc_static_slice_table[57]) /* "access-control-allow-origin" */ -#define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN (grpc_static_slice_table[57]) +#define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN (grpc_static_slice_table[58]) /* "age" */ -#define GRPC_MDSTR_AGE (grpc_static_slice_table[58]) +#define GRPC_MDSTR_AGE (grpc_static_slice_table[59]) /* "allow" */ -#define GRPC_MDSTR_ALLOW (grpc_static_slice_table[59]) +#define GRPC_MDSTR_ALLOW (grpc_static_slice_table[60]) /* "authorization" */ -#define GRPC_MDSTR_AUTHORIZATION (grpc_static_slice_table[60]) +#define GRPC_MDSTR_AUTHORIZATION (grpc_static_slice_table[61]) /* "cache-control" */ -#define GRPC_MDSTR_CACHE_CONTROL (grpc_static_slice_table[61]) +#define GRPC_MDSTR_CACHE_CONTROL (grpc_static_slice_table[62]) /* "content-disposition" */ -#define GRPC_MDSTR_CONTENT_DISPOSITION (grpc_static_slice_table[62]) +#define GRPC_MDSTR_CONTENT_DISPOSITION (grpc_static_slice_table[63]) /* "content-language" */ -#define GRPC_MDSTR_CONTENT_LANGUAGE (grpc_static_slice_table[63]) +#define GRPC_MDSTR_CONTENT_LANGUAGE (grpc_static_slice_table[64]) /* "content-length" */ -#define GRPC_MDSTR_CONTENT_LENGTH (grpc_static_slice_table[64]) +#define GRPC_MDSTR_CONTENT_LENGTH (grpc_static_slice_table[65]) /* "content-location" */ -#define GRPC_MDSTR_CONTENT_LOCATION (grpc_static_slice_table[65]) +#define GRPC_MDSTR_CONTENT_LOCATION (grpc_static_slice_table[66]) /* "content-range" */ -#define GRPC_MDSTR_CONTENT_RANGE (grpc_static_slice_table[66]) +#define GRPC_MDSTR_CONTENT_RANGE (grpc_static_slice_table[67]) /* "cookie" */ -#define GRPC_MDSTR_COOKIE (grpc_static_slice_table[67]) +#define GRPC_MDSTR_COOKIE (grpc_static_slice_table[68]) /* "date" */ -#define GRPC_MDSTR_DATE (grpc_static_slice_table[68]) +#define GRPC_MDSTR_DATE (grpc_static_slice_table[69]) /* "etag" */ -#define GRPC_MDSTR_ETAG (grpc_static_slice_table[69]) +#define GRPC_MDSTR_ETAG (grpc_static_slice_table[70]) /* "expect" */ -#define GRPC_MDSTR_EXPECT (grpc_static_slice_table[70]) +#define GRPC_MDSTR_EXPECT (grpc_static_slice_table[71]) /* "expires" */ -#define GRPC_MDSTR_EXPIRES (grpc_static_slice_table[71]) +#define GRPC_MDSTR_EXPIRES (grpc_static_slice_table[72]) /* "from" */ -#define GRPC_MDSTR_FROM (grpc_static_slice_table[72]) +#define GRPC_MDSTR_FROM (grpc_static_slice_table[73]) /* "if-match" */ -#define GRPC_MDSTR_IF_MATCH (grpc_static_slice_table[73]) +#define GRPC_MDSTR_IF_MATCH (grpc_static_slice_table[74]) /* "if-modified-since" */ -#define GRPC_MDSTR_IF_MODIFIED_SINCE (grpc_static_slice_table[74]) +#define GRPC_MDSTR_IF_MODIFIED_SINCE (grpc_static_slice_table[75]) /* "if-none-match" */ -#define GRPC_MDSTR_IF_NONE_MATCH (grpc_static_slice_table[75]) +#define GRPC_MDSTR_IF_NONE_MATCH (grpc_static_slice_table[76]) /* "if-range" */ -#define GRPC_MDSTR_IF_RANGE (grpc_static_slice_table[76]) +#define GRPC_MDSTR_IF_RANGE (grpc_static_slice_table[77]) /* "if-unmodified-since" */ -#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (grpc_static_slice_table[77]) +#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (grpc_static_slice_table[78]) /* "last-modified" */ -#define GRPC_MDSTR_LAST_MODIFIED (grpc_static_slice_table[78]) +#define GRPC_MDSTR_LAST_MODIFIED (grpc_static_slice_table[79]) /* "link" */ -#define GRPC_MDSTR_LINK (grpc_static_slice_table[79]) +#define GRPC_MDSTR_LINK (grpc_static_slice_table[80]) /* "location" */ -#define GRPC_MDSTR_LOCATION (grpc_static_slice_table[80]) +#define GRPC_MDSTR_LOCATION (grpc_static_slice_table[81]) /* "max-forwards" */ -#define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table[81]) +#define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table[82]) /* "proxy-authenticate" */ -#define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table[82]) +#define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table[83]) /* "proxy-authorization" */ -#define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table[83]) +#define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table[84]) /* "range" */ -#define GRPC_MDSTR_RANGE (grpc_static_slice_table[84]) +#define GRPC_MDSTR_RANGE (grpc_static_slice_table[85]) /* "referer" */ -#define GRPC_MDSTR_REFERER (grpc_static_slice_table[85]) +#define GRPC_MDSTR_REFERER (grpc_static_slice_table[86]) /* "refresh" */ -#define GRPC_MDSTR_REFRESH (grpc_static_slice_table[86]) +#define GRPC_MDSTR_REFRESH (grpc_static_slice_table[87]) /* "retry-after" */ -#define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table[87]) +#define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table[88]) /* "server" */ -#define GRPC_MDSTR_SERVER (grpc_static_slice_table[88]) +#define GRPC_MDSTR_SERVER (grpc_static_slice_table[89]) /* "set-cookie" */ -#define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table[89]) +#define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table[90]) /* "strict-transport-security" */ -#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table[90]) +#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table[91]) /* "transfer-encoding" */ -#define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table[91]) +#define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table[92]) /* "vary" */ -#define GRPC_MDSTR_VARY (grpc_static_slice_table[92]) +#define GRPC_MDSTR_VARY (grpc_static_slice_table[93]) /* "via" */ -#define GRPC_MDSTR_VIA (grpc_static_slice_table[93]) +#define GRPC_MDSTR_VIA (grpc_static_slice_table[94]) /* "www-authenticate" */ -#define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table[94]) +#define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table[95]) /* "0" */ -#define GRPC_MDSTR_0 (grpc_static_slice_table[95]) +#define GRPC_MDSTR_0 (grpc_static_slice_table[96]) /* "identity" */ -#define GRPC_MDSTR_IDENTITY (grpc_static_slice_table[96]) +#define GRPC_MDSTR_IDENTITY (grpc_static_slice_table[97]) /* "trailers" */ -#define GRPC_MDSTR_TRAILERS (grpc_static_slice_table[97]) +#define GRPC_MDSTR_TRAILERS (grpc_static_slice_table[98]) /* "application/grpc" */ -#define GRPC_MDSTR_APPLICATION_SLASH_GRPC (grpc_static_slice_table[98]) +#define GRPC_MDSTR_APPLICATION_SLASH_GRPC (grpc_static_slice_table[99]) /* "grpc" */ -#define GRPC_MDSTR_GRPC (grpc_static_slice_table[99]) +#define GRPC_MDSTR_GRPC (grpc_static_slice_table[100]) /* "PUT" */ -#define GRPC_MDSTR_PUT (grpc_static_slice_table[100]) +#define GRPC_MDSTR_PUT (grpc_static_slice_table[101]) /* "lb-cost-bin" */ -#define GRPC_MDSTR_LB_COST_BIN (grpc_static_slice_table[101]) +#define GRPC_MDSTR_LB_COST_BIN (grpc_static_slice_table[102]) /* "identity,deflate" */ -#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (grpc_static_slice_table[102]) +#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (grpc_static_slice_table[103]) /* "identity,gzip" */ -#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (grpc_static_slice_table[103]) +#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (grpc_static_slice_table[104]) /* "deflate,gzip" */ -#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (grpc_static_slice_table[104]) +#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (grpc_static_slice_table[105]) /* "identity,deflate,gzip" */ #define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \ - (grpc_static_slice_table[105]) + (grpc_static_slice_table[106]) namespace grpc_core { struct StaticSliceRefcount; diff --git a/src/proto/grpc/lb/v2/BUILD b/src/proto/grpc/lb/v2/BUILD new file mode 100644 index 00000000000..bf0f1a78b1c --- /dev/null +++ b/src/proto/grpc/lb/v2/BUILD @@ -0,0 +1,31 @@ +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +licenses(["notice"]) # Apache v2 + +load("//bazel:grpc_build_system.bzl", "grpc_package", "grpc_proto_library") + +grpc_package( + name = "lb", + visibility = "public", +) + +grpc_proto_library( + name = "xds_for_test_proto", + srcs = [ + "xds_for_test.proto", + ], + has_services = True, + well_known_protos = True, +) diff --git a/src/proto/grpc/lb/v2/xds_for_test.proto b/src/proto/grpc/lb/v2/xds_for_test.proto new file mode 100644 index 00000000000..3126095c92d --- /dev/null +++ b/src/proto/grpc/lb/v2/xds_for_test.proto @@ -0,0 +1,553 @@ +// Copyright 2019 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This file contains the xds protocol and its dependency. It can't be used by +// the gRPC library; otherwise there can be duplicate definition problems if +// users depend on both gRPC and Envoy. It can only be used by gRPC tests. +// +// TODO(juanlishen): It's a workaround and should be removed once we have a +// clean solution to use protobuf and external proto files. + +syntax = "proto3"; + +package envoy.api.v2; + +import "google/protobuf/any.proto"; + +message UInt32Value { + // The uint32 value. + uint32 value = 1; +} + +message Status { + // The status code, which should be an enum value of [google.rpc.Code][]. + int32 code = 1; + + // A developer-facing error message, which should be in English. Any + // user-facing error message should be localized and sent in the + // [google.rpc.Status.details][] field, or localized by the client. + string message = 2; + + // A list of messages that carry the error details. There is a common set of + // message types for APIs to use. + repeated google.protobuf.Any details = 3; +} + +// `Struct` represents a structured data value, consisting of fields +// which map to dynamically typed values. In some languages, `Struct` +// might be supported by a native representation. For example, in +// scripting languages like JS a struct is represented as an +// object. The details of that representation are described together +// with the proto support for the language. +// +// The JSON representation for `Struct` is JSON object. +message Struct { + // Unordered map of dynamically typed values. + map fields = 1; +} + +// `Value` represents a dynamically typed value which can be either +// null, a number, a string, a boolean, a recursive struct value, or a +// list of values. A producer of value is expected to set one of that +// variants, absence of any variant indicates an error. +// +// The JSON representation for `Value` is JSON value. +message Value { + // The kind of value. + oneof kind { + // Represents a null value. + NullValue null_value = 1; + // Represents a double value. + double number_value = 2; + // Represents a string value. + string string_value = 3; + // Represents a boolean value. + bool bool_value = 4; + // Represents a structured value. + Struct struct_value = 5; + // Represents a repeated `Value`. + ListValue list_value = 6; + } +} + +// `NullValue` is a singleton enumeration to represent the null value for the +// `Value` type union. +// +// The JSON representation for `NullValue` is JSON `null`. +enum NullValue { + // Null value. + NULL_VALUE = 0; +} + +// `ListValue` is a wrapper around a repeated field of values. +// +// The JSON representation for `ListValue` is JSON array. +message ListValue { + // Repeated field of dynamically typed values. + repeated Value values = 1; +} + +/////////////////////////////////////////////////////////////////////////////// + +// Identifies location of where either Envoy runs or where upstream hosts run. +message Locality { + // Region this :ref:`zone ` belongs to. + string region = 1; + + // Defines the local service zone where Envoy is running. Though optional, it + // should be set if discovery service routing is used and the discovery + // service exposes :ref:`zone data `, + // either in this message or via :option:`--service-zone`. The meaning of zone + // is context dependent, e.g. `Availability Zone (AZ) + // `_ + // on AWS, `Zone `_ on + // GCP, etc. + string zone = 2; + + // When used for locality of upstream hosts, this field further splits zone + // into smaller chunks of sub-zones so they can be load balanced + // independently. + string sub_zone = 3; +} + +// Identifies a specific Envoy instance. The node identifier is presented to the +// management server, which may use this identifier to distinguish per Envoy +// configuration for serving. +message Node { + // An opaque node identifier for the Envoy node. This also provides the local + // service node name. It should be set if any of the following features are + // used: :ref:`statsd `, :ref:`CDS + // `, and :ref:`HTTP tracing + // `, either in this message or via + // :option:`--service-node`. + string id = 1; + + // Defines the local service cluster name where Envoy is running. Though + // optional, it should be set if any of the following features are used: + // :ref:`statsd `, :ref:`health check cluster + // verification `, + // :ref:`runtime override directory `, + // :ref:`user agent addition + // `, + // :ref:`HTTP global rate limiting `, + // :ref:`CDS `, and :ref:`HTTP tracing + // `, either in this message or via + // :option:`--service-cluster`. + string cluster = 2; + + // Opaque metadata extending the node identifier. Envoy will pass this + // directly to the management server. + Struct metadata = 3; + + // Locality specifying where the Envoy instance is running. + Locality locality = 4; + + // This is motivated by informing a management server during canary which + // version of Envoy is being tested in a heterogeneous fleet. This will be set + // by Envoy in management server RPCs. + string build_version = 5; +} + +/////////////////////////////////////////////////////////////////////////////// + +// A DiscoveryRequest requests a set of versioned resources of the same type for +// a given Envoy node on some API. +message DiscoveryRequest { + // The version_info provided in the request messages will be the version_info + // received with the most recent successfully processed response or empty on + // the first request. It is expected that no new request is sent after a + // response is received until the Envoy instance is ready to ACK/NACK the new + // configuration. ACK/NACK takes place by returning the new API config version + // as applied or the previous API config version respectively. Each type_url + // (see below) has an independent version associated with it. + string version_info = 1; + + // The node making the request. + Node node = 2; + + // List of resources to subscribe to, e.g. list of cluster names or a route + // configuration name. If this is empty, all resources for the API are + // returned. LDS/CDS expect empty resource_names, since this is global + // discovery for the Envoy instance. The LDS and CDS responses will then imply + // a number of resources that need to be fetched via EDS/RDS, which will be + // explicitly enumerated in resource_names. + repeated string resource_names = 3; + + // Type of the resource that is being requested, e.g. + // "type.googleapis.com/envoy.api.v2.ClusterLoadAssignment". This is implicit + // in requests made via singleton xDS APIs such as CDS, LDS, etc. but is + // required for ADS. + string type_url = 4; + + // nonce corresponding to DiscoveryResponse being ACK/NACKed. See above + // discussion on version_info and the DiscoveryResponse nonce comment. This + // may be empty if no nonce is available, e.g. at startup or for non-stream + // xDS implementations. + string response_nonce = 5; + + // This is populated when the previous :ref:`DiscoveryResponse ` + // failed to update configuration. The *message* field in *error_details* provides the Envoy + // internal exception related to the failure. It is only intended for consumption during manual + // debugging, the string provided is not guaranteed to be stable across Envoy versions. + Status error_detail = 6; +} + +message DiscoveryResponse { + // The version of the response data. + string version_info = 1; + + // The response resources. These resources are typed and depend on the API being called. + repeated google.protobuf.Any resources = 2; + + // [#not-implemented-hide:] + // Canary is used to support two Envoy command line flags: + // + // * --terminate-on-canary-transition-failure. When set, Envoy is able to + // terminate if it detects that configuration is stuck at canary. Consider + // this example sequence of updates: + // - Management server applies a canary config successfully. + // - Management server rolls back to a production config. + // - Envoy rejects the new production config. + // Since there is no sensible way to continue receiving configuration + // updates, Envoy will then terminate and apply production config from a + // clean slate. + // * --dry-run-canary. When set, a canary response will never be applied, only + // validated via a dry run. + bool canary = 3; + + // Type URL for resources. This must be consistent with the type_url in the + // Any messages for resources if resources is non-empty. This effectively + // identifies the xDS API when muxing over ADS. + string type_url = 4; + + // For gRPC based subscriptions, the nonce provides a way to explicitly ack a + // specific DiscoveryResponse in a following DiscoveryRequest. Additional + // messages may have been sent by Envoy to the management server for the + // previous version on the stream prior to this DiscoveryResponse, that were + // unprocessed at response send time. The nonce allows the management server + // to ignore any further DiscoveryRequests for the previous version until a + // DiscoveryRequest bearing the nonce. The nonce is optional and is not + // required for non-stream based xDS implementations. + string nonce = 5; +} + +/////////////////////////////////////////////////////////////////////////////// + +message Pipe { + // Unix Domain Socket path. On Linux, paths starting with '@' will use the + // abstract namespace. The starting '@' is replaced by a null byte by Envoy. + // Paths starting with '@' will result in an error in environments other than + // Linux. + string path = 1; +} + +message SocketAddress { + enum Protocol { + TCP = 0; + // [#not-implemented-hide:] + UDP = 1; + } + Protocol protocol = 1; + // The address for this socket. :ref:`Listeners ` will bind + // to the address. An empty address is not allowed. Specify ``0.0.0.0`` or ``::`` + // to bind to any address. [#comment:TODO(zuercher) reinstate when implemented: + // It is possible to distinguish a Listener address via the prefix/suffix matching + // in :ref:`FilterChainMatch `.] When used + // within an upstream :ref:`BindConfig `, the address + // controls the source address of outbound connections. For :ref:`clusters + // `, the cluster type determines whether the + // address must be an IP (*STATIC* or *EDS* clusters) or a hostname resolved by DNS + // (*STRICT_DNS* or *LOGICAL_DNS* clusters). Address resolution can be customized + // via :ref:`resolver_name `. + string address = 2; + oneof port_specifier { + uint32 port_value = 3; + // This is only valid if :ref:`resolver_name + // ` is specified below and the + // named resolver is capable of named port resolution. + string named_port = 4; + } + // The name of the resolver. This must have been registered with Envoy. If this is + // empty, a context dependent default applies. If address is a hostname this + // should be set for resolution other than DNS. If the address is a concrete + // IP address, no resolution will occur. + string resolver_name = 5; + + // When binding to an IPv6 address above, this enables `IPv4 compatibity + // `_. Binding to ``::`` will + // allow both IPv4 and IPv6 connections, with peer IPv4 addresses mapped into + // IPv6 space as ``::FFFF:``. + bool ipv4_compat = 6; +} + +// Addresses specify either a logical or physical address and port, which are +// used to tell Envoy where to bind/listen, connect to upstream and find +// management servers. +message Address { + oneof address { + + SocketAddress socket_address = 1; + Pipe pipe = 2; + } +} + +/////////////////////////////////////////////////////////////////////////////// + +message Metadata { + // Key is the reverse DNS filter name, e.g. com.acme.widget. The envoy.* + // namespace is reserved for Envoy's built-in filters. + map filter_metadata = 1; +} + +/////////////////////////////////////////////////////////////////////////////// + +// Endpoint health status. +enum HealthStatus { + // The health status is not known. This is interpreted by Envoy as *HEALTHY*. + UNKNOWN = 0; + + // Healthy. + HEALTHY = 1; + + // Unhealthy. + UNHEALTHY = 2; + + // Connection draining in progress. E.g., + // ``_ + // or + // ``_. + // This is interpreted by Envoy as *UNHEALTHY*. + DRAINING = 3; + + // Health check timed out. This is part of HDS and is interpreted by Envoy as + // *UNHEALTHY*. + TIMEOUT = 4; +} + +/////////////////////////////////////////////////////////////////////////////// + +// Upstream host identifier. +message Endpoint { + // The upstream host address. + // + // .. attention:: + // + // The form of host address depends on the given cluster type. For STATIC or EDS, + // it is expected to be a direct IP address (or something resolvable by the + // specified :ref:`resolver ` + // in the Address). For LOGICAL or STRICT DNS, it is expected to be hostname, + // and will be resolved via DNS. + Address address = 1; + + // The optional health check configuration. + message HealthCheckConfig { + // Optional alternative health check port value. + // + // By default the health check address port of an upstream host is the same + // as the host's serving address port. This provides an alternative health + // check port. Setting this with a non-zero value allows an upstream host + // to have different health check address port. + uint32 port_value = 1; + } + + // The optional health check configuration is used as configuration for the + // health checker to contact the health checked host. + // + // .. attention:: + // + // This takes into effect only for upstream clusters with + // :ref:`active health checking ` enabled. + HealthCheckConfig health_check_config = 2; +} + +// An Endpoint that Envoy can route traffic to. +message LbEndpoint { + // Upstream host identifier + Endpoint endpoint = 1; + + // Optional health status when known and supplied by EDS server. + HealthStatus health_status = 2; + + // The endpoint metadata specifies values that may be used by the load + // balancer to select endpoints in a cluster for a given request. The filter + // name should be specified as *envoy.lb*. An example boolean key-value pair + // is *canary*, providing the optional canary status of the upstream host. + // This may be matched against in a route's + // :ref:`RouteAction ` metadata_match field + // to subset the endpoints considered in cluster load balancing. + Metadata metadata = 3; + + // The optional load balancing weight of the upstream host, in the range 1 - + // 128. Envoy uses the load balancing weight in some of the built in load + // balancers. The load balancing weight for an endpoint is divided by the sum + // of the weights of all endpoints in the endpoint's locality to produce a + // percentage of traffic for the endpoint. This percentage is then further + // weighted by the endpoint's locality's load balancing weight from + // LocalityLbEndpoints. If unspecified, each host is presumed to have equal + // weight in a locality. + // + // .. attention:: + // + // The limit of 128 is somewhat arbitrary, but is applied due to performance + // concerns with the current implementation and can be removed when + // `this issue `_ is fixed. + UInt32Value load_balancing_weight = 4; +} + +// A group of endpoints belonging to a Locality. +// One can have multiple LocalityLbEndpoints for a locality, but this is +// generally only done if the different groups need to have different load +// balancing weights or different priorities. +message LocalityLbEndpoints { + // Identifies location of where the upstream hosts run. + Locality locality = 1; + + // The group of endpoints belonging to the locality specified. + repeated LbEndpoint lb_endpoints = 2; + + // Optional: Per priority/region/zone/sub_zone weight - range 1-128. The load + // balancing weight for a locality is divided by the sum of the weights of all + // localities at the same priority level to produce the effective percentage + // of traffic for the locality. + // + // Locality weights are only considered when :ref:`locality weighted load + // balancing ` is + // configured. These weights are ignored otherwise. If no weights are + // specificed when locality weighted load balancing is enabled, the cluster is + // assumed to have a weight of 1. + // + // .. attention:: + // + // The limit of 128 is somewhat arbitrary, but is applied due to performance + // concerns with the current implementation and can be removed when + // `this issue `_ is fixed. + UInt32Value load_balancing_weight = 3; + + // Optional: the priority for this LocalityLbEndpoints. If unspecified this will + // default to the highest priority (0). + // + // Under usual circumstances, Envoy will only select endpoints for the highest + // priority (0). In the event all endpoints for a particular priority are + // unavailable/unhealthy, Envoy will fail over to selecting endpoints for the + // next highest priority group. + // + // Priorities should range from 0 (highest) to N (lowest) without skipping. + uint32 priority = 5; +} + +/////////////////////////////////////////////////////////////////////////////// + +message FractionalPercent { + // Specifies the numerator. Defaults to 0. + uint32 numerator = 1; + + // Fraction percentages support several fixed denominator values. + enum DenominatorType { + // 100. + // + // **Example**: 1/100 = 1%. + HUNDRED = 0; + + // 10,000. + // + // **Example**: 1/10000 = 0.01%. + TEN_THOUSAND = 1; + + // 1,000,000. + // + // **Example**: 1/1000000 = 0.0001%. + MILLION = 2; + } + + // Specifies the denominator. If the denominator specified is less than the numerator, the final + // fractional percentage is capped at 1 (100%). + DenominatorType denominator = 2; +} + +/////////////////////////////////////////////////////////////////////////////// + +// [#protodoc-title: EDS] +// Endpoint discovery :ref:`architecture overview ` +service EndpointDiscoveryService { + // The resource_names field in DiscoveryRequest specifies a list of clusters + // to subscribe to updates for. + rpc StreamEndpoints(stream DiscoveryRequest) returns (stream DiscoveryResponse) { + } +} + +// Each route from RDS will map to a single cluster or traffic split across +// clusters using weights expressed in the RDS WeightedCluster. +// +// With EDS, each cluster is treated independently from a LB perspective, with +// LB taking place between the Localities within a cluster and at a finer +// granularity between the hosts within a locality. For a given cluster, the +// effective weight of a host is its load_balancing_weight multiplied by the +// load_balancing_weight of its Locality. +message ClusterLoadAssignment { + // Name of the cluster. This will be the :ref:`service_name + // ` value if specified + // in the cluster :ref:`EdsClusterConfig + // `. + string cluster_name = 1; + + // List of endpoints to load balance to. + repeated LocalityLbEndpoints endpoints = 2; + + // Load balancing policy settings. + message Policy { + reserved 1; + + message DropOverload { + // Identifier for the policy specifying the drop. + string category = 1; + + // Percentage of traffic that should be dropped for the category. + FractionalPercent drop_percentage = 2; + } + // Action to trim the overall incoming traffic to protect the upstream + // hosts. This action allows protection in case the hosts are unable to + // recover from an outage, or unable to autoscale or unable to handle + // incoming traffic volume for any reason. + // + // At the client each category is applied one after the other to generate + // the 'actual' drop percentage on all outgoing traffic. For example: + // + // .. code-block:: json + // + // { "drop_overloads": [ + // { "category": "throttle", "drop_percentage": 60 } + // { "category": "lb", "drop_percentage": 50 } + // ]} + // + // The actual drop percentages applied to the traffic at the clients will be + // "throttle"_drop = 60% + // "lb"_drop = 20% // 50% of the remaining 'actual' load, which is 40%. + // actual_outgoing_load = 20% // remaining after applying all categories. + repeated DropOverload drop_overloads = 2; + + // Priority levels and localities are considered overprovisioned with this + // factor (in percentage). This means that we don't consider a priority + // level or locality unhealthy until the percentage of healthy hosts + // multiplied by the overprovisioning factor drops below 100. + // With the default value 140(1.4), Envoy doesn't consider a priority level + // or a locality unhealthy until their percentage of healthy hosts drops + // below 72%. + // Read more at :ref:`priority levels ` and + // :ref:`localities `. + UInt32Value overprovisioning_factor = 3; + } + + // Load balancing policy settings. + Policy policy = 4; +} diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 8138b2a6264..f1c1a72765b 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -374,6 +374,8 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c', + 'src/core/ext/upb-generated/google/api/annotations.upb.c', + 'src/core/ext/upb-generated/google/api/http.upb.c', 'src/core/ext/upb-generated/google/protobuf/any.upb.c', 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.c', 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', @@ -381,14 +383,32 @@ CORE_SOURCE_FILES = [ 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', + 'src/core/ext/upb-generated/google/rpc/status.upb.c', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', + 'src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/cds.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/eds.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c', + 'src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c', + 'src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c', + 'src/core/ext/upb-generated/envoy/type/percent.upb.c', + 'src/core/ext/upb-generated/envoy/type/range.upb.c', + 'src/core/ext/upb-generated/gogoproto/gogo.upb.c', + 'src/core/ext/upb-generated/validate/validate.upb.c', 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc', 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc', diff --git a/test/core/end2end/fuzzers/hpack.dictionary b/test/core/end2end/fuzzers/hpack.dictionary index abad1720ee8..24e3320dd71 100644 --- a/test/core/end2end/fuzzers/hpack.dictionary +++ b/test/core/end2end/fuzzers/hpack.dictionary @@ -33,6 +33,7 @@ "\x1Egrpc.max_request_message_bytes" "\x1Fgrpc.max_response_message_bytes" "$/grpc.lb.v1.LoadBalancer/BalanceLoad" +"6/envoy.api.v2.EndpointDiscoveryService/StreamEndpoints" "\x1C/grpc.health.v1.Health/Watch" "P/envoy.service.discovery.v2.AggregatedDiscoveryService/StreamAggregatedResources" "\x07deflate" diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD index 0ddafc92abe..4b83d0615af 100644 --- a/test/cpp/end2end/BUILD +++ b/test/cpp/end2end/BUILD @@ -89,6 +89,7 @@ grpc_cc_test( external_deps = [ "gtest", ], + tags = ["no_windows"], deps = [ ":test_service_impl", "//:gpr", @@ -99,7 +100,6 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], - tags = ["no_windows"], ) grpc_cc_test( @@ -492,6 +492,7 @@ grpc_cc_test( "//:grpc++", "//:grpc_resolver_fake", "//src/proto/grpc/lb/v1:load_balancer_proto", + "//src/proto/grpc/lb/v2:xds_for_test_proto", "//src/proto/grpc/testing:echo_messages_proto", "//src/proto/grpc/testing:echo_proto", "//src/proto/grpc/testing/duplicate:echo_duplicate_proto", @@ -658,6 +659,7 @@ grpc_cc_test( external_deps = [ "gtest", ], + tags = ["no_windows"], deps = [ "//:gpr", "//:grpc", @@ -668,7 +670,6 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], - tags = ["no_windows"], ) grpc_cc_test( @@ -718,8 +719,8 @@ grpc_cc_test( ], deps = [ ":test_service_impl", - "//:grpc", "//:gpr", + "//:grpc", "//:grpc++", "//src/proto/grpc/testing:echo_messages_proto", "//src/proto/grpc/testing:echo_proto", @@ -746,4 +747,3 @@ grpc_cc_test( "//test/cpp/util:test_util", ], ) - diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index 5e7717e4e06..5aa20e27a49 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -48,7 +48,7 @@ #include "test/core/util/test_config.h" #include "test/cpp/end2end/test_service_impl.h" -#include "src/proto/grpc/lb/v1/load_balancer.grpc.pb.h" +#include "src/proto/grpc/lb/v2/xds_for_test.grpc.pb.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" #include @@ -71,16 +71,23 @@ // 2) the retry timer is active. Again, the weak reference it holds should // prevent a premature call to \a glb_destroy. -using std::chrono::system_clock; - -using grpc::lb::v1::LoadBalanceRequest; -using grpc::lb::v1::LoadBalanceResponse; -using grpc::lb::v1::LoadBalancer; - namespace grpc { namespace testing { namespace { +using std::chrono::system_clock; + +using ::envoy::api::v2::ClusterLoadAssignment; +using ::envoy::api::v2::DiscoveryRequest; +using ::envoy::api::v2::DiscoveryResponse; +using ::envoy::api::v2::EndpointDiscoveryService; + +constexpr char kEdsTypeUrl[] = + "type.googleapis.com/envoy.api.v2.ClusterLoadAssignment"; +constexpr char kDefaultLocalityRegion[] = "xds_default_locality_region"; +constexpr char kDefaultLocalityZone[] = "xds_default_locality_zone"; +constexpr char kDefaultLocalitySubzone[] = "xds_default_locality_subzone"; + template class CountedService : public ServiceType { public: @@ -118,7 +125,7 @@ class CountedService : public ServiceType { }; using BackendService = CountedService; -using BalancerService = CountedService; +using BalancerService = CountedService; const char g_kCallCredsMdKey[] = "Balancer should not ..."; const char g_kCallCredsMdValue[] = "... receive me"; @@ -161,12 +168,6 @@ class BackendServiceImpl : public BackendService { std::set clients_; }; -grpc::string Ip4ToPackedString(const char* ip_str) { - struct in_addr ip4; - GPR_ASSERT(inet_pton(AF_INET, ip_str, &ip4) == 1); - return grpc::string(reinterpret_cast(&ip4), sizeof(ip4)); -} - struct ClientStats { size_t num_calls_started = 0; size_t num_calls_finished = 0; @@ -198,16 +199,16 @@ struct ClientStats { class BalancerServiceImpl : public BalancerService { public: - using Stream = ServerReaderWriter; - using ResponseDelayPair = std::pair; + using Stream = ServerReaderWriter; + using ResponseDelayPair = std::pair; explicit BalancerServiceImpl(int client_load_reporting_interval_seconds) : client_load_reporting_interval_seconds_( client_load_reporting_interval_seconds) {} - Status BalanceLoad(ServerContext* context, Stream* stream) override { + Status StreamEndpoints(ServerContext* context, Stream* stream) override { // TODO(juanlishen): Clean up the scoping. - gpr_log(GPR_INFO, "LB[%p]: BalanceLoad", this); + gpr_log(GPR_INFO, "LB[%p]: EDS starts", this); { grpc::internal::MutexLock lock(&mu_); if (serverlist_done_) goto done; @@ -216,24 +217,12 @@ class BalancerServiceImpl : public BalancerService { // Balancer shouldn't receive the call credentials metadata. EXPECT_EQ(context->client_metadata().find(g_kCallCredsMdKey), context->client_metadata().end()); - LoadBalanceRequest request; + DiscoveryRequest request; std::vector responses_and_delays; - - if (!stream->Read(&request)) { - goto done; - } + if (!stream->Read(&request)) goto done; IncreaseRequestCount(); gpr_log(GPR_INFO, "LB[%p]: received initial message '%s'", this, request.DebugString().c_str()); - - { - LoadBalanceResponse initial_response; - initial_response.mutable_initial_response() - ->mutable_client_stats_report_interval() - ->set_seconds(client_load_reporting_interval_seconds_); - stream->Write(initial_response); - } - { grpc::internal::MutexLock lock(&mu_); responses_and_delays = responses_and_delays_; @@ -246,34 +235,8 @@ class BalancerServiceImpl : public BalancerService { grpc::internal::MutexLock lock(&mu_); serverlist_cond_.WaitUntil(&mu_, [this] { return serverlist_done_; }); } - if (client_load_reporting_interval_seconds_ > 0) { - request.Clear(); - if (stream->Read(&request)) { - gpr_log(GPR_INFO, "LB[%p]: received client load report message '%s'", - this, request.DebugString().c_str()); - GPR_ASSERT(request.has_client_stats()); - // We need to acquire the lock here in order to prevent the notify_one - // below from firing before its corresponding wait is executed. - grpc::internal::MutexLock lock(&mu_); - client_stats_.num_calls_started += - request.client_stats().num_calls_started(); - client_stats_.num_calls_finished += - request.client_stats().num_calls_finished(); - client_stats_.num_calls_finished_with_client_failed_to_send += - request.client_stats() - .num_calls_finished_with_client_failed_to_send(); - client_stats_.num_calls_finished_known_received += - request.client_stats().num_calls_finished_known_received(); - for (const auto& drop_token_count : - request.client_stats().calls_finished_with_drop()) { - client_stats_ - .drop_token_counts[drop_token_count.load_balance_token()] += - drop_token_count.num_calls(); - } - load_report_ready_ = true; - load_report_cond_.Signal(); - } + // TODO(juanlishen): Use LRS to receive load report. } } done: @@ -281,7 +244,7 @@ class BalancerServiceImpl : public BalancerService { return Status::OK; } - void add_response(const LoadBalanceResponse& response, int send_after_ms) { + void add_response(const DiscoveryResponse& response, int send_after_ms) { grpc::internal::MutexLock lock(&mu_); responses_and_delays_.push_back(std::make_pair(response, send_after_ms)); } @@ -290,41 +253,34 @@ class BalancerServiceImpl : public BalancerService { grpc::internal::MutexLock lock(&mu_); NotifyDoneWithServerlistsLocked(); responses_and_delays_.clear(); - client_stats_.Reset(); gpr_log(GPR_INFO, "LB[%p]: shut down", this); } - static LoadBalanceResponse BuildResponseForBackends( + static DiscoveryResponse BuildResponseForBackends( const std::vector& backend_ports, const std::map& drop_token_counts) { - LoadBalanceResponse response; - for (const auto& drop_token_count : drop_token_counts) { - for (size_t i = 0; i < drop_token_count.second; ++i) { - auto* server = response.mutable_server_list()->add_servers(); - server->set_drop(true); - server->set_load_balance_token(drop_token_count.first); - } - } + ClusterLoadAssignment assignment; + assignment.set_cluster_name("service name"); + auto* endpoints = assignment.add_endpoints(); + endpoints->mutable_load_balancing_weight()->set_value(3); + endpoints->set_priority(0); + endpoints->mutable_locality()->set_region(kDefaultLocalityRegion); + endpoints->mutable_locality()->set_zone(kDefaultLocalityZone); + endpoints->mutable_locality()->set_sub_zone(kDefaultLocalitySubzone); for (const int& backend_port : backend_ports) { - auto* server = response.mutable_server_list()->add_servers(); - server->set_ip_address(Ip4ToPackedString("127.0.0.1")); - server->set_port(backend_port); - static int token_count = 0; - char* token; - gpr_asprintf(&token, "token%03d", ++token_count); - server->set_load_balance_token(token); - gpr_free(token); + auto* lb_endpoints = endpoints->add_lb_endpoints(); + auto* endpoint = lb_endpoints->mutable_endpoint(); + auto* address = endpoint->mutable_address(); + auto* socket_address = address->mutable_socket_address(); + socket_address->set_address("127.0.0.1"); + socket_address->set_port_value(backend_port); } + DiscoveryResponse response; + response.set_type_url(kEdsTypeUrl); + response.add_resources()->PackFrom(assignment); return response; } - const ClientStats& WaitForLoadReport() { - grpc::internal::MutexLock lock(&mu_); - load_report_cond_.WaitUntil(&mu_, [this] { return load_report_ready_; }); - load_report_ready_ = false; - return client_stats_; - } - void NotifyDoneWithServerlists() { grpc::internal::MutexLock lock(&mu_); NotifyDoneWithServerlistsLocked(); @@ -338,7 +294,7 @@ class BalancerServiceImpl : public BalancerService { } private: - void SendResponse(Stream* stream, const LoadBalanceResponse& response, + void SendResponse(Stream* stream, const DiscoveryResponse& response, int delay_ms) { gpr_log(GPR_INFO, "LB[%p]: sleeping for %d ms...", this, delay_ms); if (delay_ms > 0) { @@ -353,11 +309,8 @@ class BalancerServiceImpl : public BalancerService { const int client_load_reporting_interval_seconds_; std::vector responses_and_delays_; grpc::internal::Mutex mu_; - grpc::internal::CondVar load_report_cond_; - bool load_report_ready_ = false; grpc::internal::CondVar serverlist_cond_; bool serverlist_done_ = false; - ClientStats client_stats_; }; class XdsEnd2endTest : public ::testing::Test { @@ -450,9 +403,7 @@ class XdsEnd2endTest : public ::testing::Test { ClientStats WaitForLoadReports() { ClientStats client_stats; - for (auto& balancer : balancers_) { - client_stats += balancer->service_.WaitForLoadReport(); - } + // TODO(juanlishen): Wait in LRS. return client_stats; } @@ -597,8 +548,7 @@ class XdsEnd2endTest : public ::testing::Test { return backend_ports; } - void ScheduleResponseForBalancer(size_t i, - const LoadBalanceResponse& response, + void ScheduleResponseForBalancer(size_t i, const DiscoveryResponse& response, int delay_ms) { balancers_[i]->service_.add_response(response, delay_ms); } @@ -820,7 +770,8 @@ TEST_F(SingleBalancerTest, InitiallyEmptyServerlist) { const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor(); const int kCallDeadlineMs = kServerlistDelayMs * 2; // First response is an empty serverlist, sent right away. - ScheduleResponseForBalancer(0, LoadBalanceResponse(), 0); + ScheduleResponseForBalancer( + 0, BalancerServiceImpl::BuildResponseForBackends({}, {}), 0); // Send non-empty serverlist only after kServerlistDelayMs ScheduleResponseForBalancer( 0, BalancerServiceImpl::BuildResponseForBackends(GetBackendPorts(), {}), diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py index fd1d9cbfb49..f0f94c00466 100755 --- a/tools/codegen/core/gen_static_metadata.py +++ b/tools/codegen/core/gen_static_metadata.py @@ -63,6 +63,7 @@ CONFIG = [ 'grpc.max_response_message_bytes', # well known method names '/grpc.lb.v1.LoadBalancer/BalanceLoad', + '/envoy.api.v2.EndpointDiscoveryService/StreamEndpoints', '/grpc.health.v1.Health/Watch', '/envoy.service.discovery.v2.AggregatedDiscoveryService/StreamAggregatedResources', # compression algorithm names diff --git a/tools/distrib/check_nanopb_output.sh b/tools/distrib/check_nanopb_output.sh index 018cbb7b66a..7317e842b89 100755 --- a/tools/distrib/check_nanopb_output.sh +++ b/tools/distrib/check_nanopb_output.sh @@ -42,32 +42,6 @@ make -j 8 # back to the root directory popd -# -# Checks for load_balancer.proto -# -readonly LOAD_BALANCER_GRPC_OUTPUT_PATH='src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1' -# nanopb-compile the proto to a temp location -./tools/codegen/core/gen_nano_proto.sh \ - src/proto/grpc/lb/v1/load_balancer.proto \ - "$NANOPB_TMP_OUTPUT" \ - "$LOAD_BALANCER_GRPC_OUTPUT_PATH" - -./tools/codegen/core/gen_nano_proto.sh \ - third_party/protobuf/src/google/protobuf/duration.proto \ - "$NANOPB_TMP_OUTPUT/google/protobuf" \ - "$LOAD_BALANCER_GRPC_OUTPUT_PATH/google/protobuf" - -./tools/codegen/core/gen_nano_proto.sh \ - third_party/protobuf/src/google/protobuf/timestamp.proto \ - "$NANOPB_TMP_OUTPUT/google/protobuf" \ - "$LOAD_BALANCER_GRPC_OUTPUT_PATH/google/protobuf" - -# compare outputs to checked compiled code -if ! diff -r "$NANOPB_TMP_OUTPUT" src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1; then - echo "Outputs differ: $NANOPB_TMP_OUTPUT vs $LOAD_BALANCER_GRPC_OUTPUT_PATH" - exit 2 -fi - # # checks for health.proto # diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index e1d03c33268..4579af50ee9 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -907,12 +907,6 @@ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h \ -src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c \ -src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h \ -src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c \ -src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h \ -src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ -src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h \ src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc \ src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc \ src/core/ext/filters/client_channel/lb_policy/subchannel_list.h \ @@ -1064,6 +1058,48 @@ src/core/ext/transport/chttp2/transport/writing.cc \ src/core/ext/transport/inproc/inproc_plugin.cc \ src/core/ext/transport/inproc/inproc_transport.cc \ src/core/ext/transport/inproc/inproc_transport.h \ +src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c \ +src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h \ +src/core/ext/upb-generated/envoy/api/v2/cds.upb.c \ +src/core/ext/upb-generated/envoy/api/v2/cds.upb.h \ +src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c \ +src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h \ +src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c \ +src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h \ +src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c \ +src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h \ +src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c \ +src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h \ +src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c \ +src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h \ +src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c \ +src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h \ +src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c \ +src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h \ +src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c \ +src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h \ +src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c \ +src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h \ +src/core/ext/upb-generated/envoy/api/v2/eds.upb.c \ +src/core/ext/upb-generated/envoy/api/v2/eds.upb.h \ +src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c \ +src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h \ +src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c \ +src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h \ +src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c \ +src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h \ +src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c \ +src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h \ +src/core/ext/upb-generated/envoy/type/percent.upb.c \ +src/core/ext/upb-generated/envoy/type/percent.upb.h \ +src/core/ext/upb-generated/envoy/type/range.upb.c \ +src/core/ext/upb-generated/envoy/type/range.upb.h \ +src/core/ext/upb-generated/gogoproto/gogo.upb.c \ +src/core/ext/upb-generated/gogoproto/gogo.upb.h \ +src/core/ext/upb-generated/google/api/annotations.upb.c \ +src/core/ext/upb-generated/google/api/annotations.upb.h \ +src/core/ext/upb-generated/google/api/http.upb.c \ +src/core/ext/upb-generated/google/api/http.upb.h \ src/core/ext/upb-generated/google/protobuf/any.upb.c \ src/core/ext/upb-generated/google/protobuf/any.upb.h \ src/core/ext/upb-generated/google/protobuf/descriptor.upb.c \ @@ -1078,10 +1114,14 @@ src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ src/core/ext/upb-generated/google/protobuf/timestamp.upb.h \ src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ src/core/ext/upb-generated/google/protobuf/wrappers.upb.h \ +src/core/ext/upb-generated/google/rpc/status.upb.c \ +src/core/ext/upb-generated/google/rpc/status.upb.h \ src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h \ src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h \ +src/core/ext/upb-generated/validate/validate.upb.c \ +src/core/ext/upb-generated/validate/validate.upb.h \ src/core/lib/README.md \ src/core/lib/avl/avl.cc \ src/core/lib/avl/avl.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index c026d6a1caa..60ba4d7fa18 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -5323,9 +5323,9 @@ "grpc_test_util" ], "headers": [ - "src/proto/grpc/lb/v1/load_balancer.grpc.pb.h", - "src/proto/grpc/lb/v1/load_balancer.pb.h", - "src/proto/grpc/lb/v1/load_balancer_mock.grpc.pb.h" + "src/proto/grpc/lb/v2/xds_for_test.grpc.pb.h", + "src/proto/grpc/lb/v2/xds_for_test.pb.h", + "src/proto/grpc/lb/v2/xds_for_test_mock.grpc.pb.h" ], "is_filegroup": false, "language": "c++", @@ -8304,21 +8304,130 @@ "third_party": false, "type": "filegroup" }, + { + "deps": [ + "envoy_core_upb", + "envoy_type_upb", + "google_api_upb", + "proto_gen_validate_upb" + ], + "headers": [ + "src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/cds.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/eds.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h", + "src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h", + "src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h" + ], + "is_filegroup": true, + "language": "c", + "name": "envoy_ads_upb", + "src": [ + "src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/cds.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/cds.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/eds.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/eds.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h", + "src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c", + "src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h", + "src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c", + "src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h" + ], + "third_party": false, + "type": "filegroup" + }, + { + "deps": [ + "envoy_type_upb", + "google_api_upb", + "proto_gen_validate_upb" + ], + "headers": [ + "src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h" + ], + "is_filegroup": true, + "language": "c", + "name": "envoy_core_upb", + "src": [ + "src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h" + ], + "third_party": false, + "type": "filegroup" + }, + { + "deps": [ + "google_api_upb", + "proto_gen_validate_upb" + ], + "headers": [ + "src/core/ext/upb-generated/envoy/type/percent.upb.h", + "src/core/ext/upb-generated/envoy/type/range.upb.h" + ], + "is_filegroup": true, + "language": "c", + "name": "envoy_type_upb", + "src": [ + "src/core/ext/upb-generated/envoy/type/percent.upb.c", + "src/core/ext/upb-generated/envoy/type/percent.upb.h", + "src/core/ext/upb-generated/envoy/type/range.upb.c", + "src/core/ext/upb-generated/envoy/type/range.upb.h" + ], + "third_party": false, + "type": "filegroup" + }, { "deps": [], "headers": [ + "src/core/ext/upb-generated/google/api/annotations.upb.h", + "src/core/ext/upb-generated/google/api/http.upb.h", "src/core/ext/upb-generated/google/protobuf/any.upb.h", "src/core/ext/upb-generated/google/protobuf/descriptor.upb.h", "src/core/ext/upb-generated/google/protobuf/duration.upb.h", "src/core/ext/upb-generated/google/protobuf/empty.upb.h", "src/core/ext/upb-generated/google/protobuf/struct.upb.h", "src/core/ext/upb-generated/google/protobuf/timestamp.upb.h", - "src/core/ext/upb-generated/google/protobuf/wrappers.upb.h" + "src/core/ext/upb-generated/google/protobuf/wrappers.upb.h", + "src/core/ext/upb-generated/google/rpc/status.upb.h" ], "is_filegroup": true, "language": "c", "name": "google_api_upb", "src": [ + "src/core/ext/upb-generated/google/api/annotations.upb.c", + "src/core/ext/upb-generated/google/api/annotations.upb.h", + "src/core/ext/upb-generated/google/api/http.upb.c", + "src/core/ext/upb-generated/google/api/http.upb.h", "src/core/ext/upb-generated/google/protobuf/any.upb.c", "src/core/ext/upb-generated/google/protobuf/any.upb.h", "src/core/ext/upb-generated/google/protobuf/descriptor.upb.c", @@ -8332,7 +8441,9 @@ "src/core/ext/upb-generated/google/protobuf/timestamp.upb.c", "src/core/ext/upb-generated/google/protobuf/timestamp.upb.h", "src/core/ext/upb-generated/google/protobuf/wrappers.upb.c", - "src/core/ext/upb-generated/google/protobuf/wrappers.upb.h" + "src/core/ext/upb-generated/google/protobuf/wrappers.upb.h", + "src/core/ext/upb-generated/google/rpc/status.upb.c", + "src/core/ext/upb-generated/google/rpc/status.upb.h" ], "third_party": false, "type": "filegroup" @@ -9394,12 +9505,12 @@ }, { "deps": [ + "envoy_ads_upb", "gpr", "grpc_base", "grpc_client_channel", - "grpc_resolver_fake", - "grpclb_proto", - "nanopb" + "grpc_lb_upb", + "grpc_resolver_fake" ], "headers": [ "src/core/ext/filters/client_channel/lb_policy/xds/xds.h", @@ -9425,13 +9536,13 @@ }, { "deps": [ + "envoy_ads_upb", "gpr", "grpc_base", "grpc_client_channel", + "grpc_lb_upb", "grpc_resolver_fake", - "grpc_secure", - "grpclb_proto", - "nanopb" + "grpc_secure" ], "headers": [ "src/core/ext/filters/client_channel/lb_policy/xds/xds.h", @@ -10198,29 +10309,6 @@ "third_party": false, "type": "filegroup" }, - { - "deps": [ - "nanopb" - ], - "headers": [ - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpclb_proto", - "src": [ - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c", - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c", - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c", - "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h" - ], - "third_party": false, - "type": "filegroup" - }, { "deps": [ "nanopb_headers" @@ -10248,6 +10336,26 @@ "third_party": false, "type": "filegroup" }, + { + "deps": [ + "google_api_upb" + ], + "headers": [ + "src/core/ext/upb-generated/gogoproto/gogo.upb.h", + "src/core/ext/upb-generated/validate/validate.upb.h" + ], + "is_filegroup": true, + "language": "c", + "name": "proto_gen_validate_upb", + "src": [ + "src/core/ext/upb-generated/gogoproto/gogo.upb.c", + "src/core/ext/upb-generated/gogoproto/gogo.upb.h", + "src/core/ext/upb-generated/validate/validate.upb.c", + "src/core/ext/upb-generated/validate/validate.upb.h" + ], + "third_party": false, + "type": "filegroup" + }, { "deps": [ "grpc" From 20885a944cd557eb557366d8a71dc4df6924ecba Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Wed, 7 Aug 2019 23:29:00 -0700 Subject: [PATCH 1152/1555] Fix channel args cmp --- src/core/lib/channel/channel_args.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/lib/channel/channel_args.cc b/src/core/lib/channel/channel_args.cc index a35db186a30..b629ac0e107 100644 --- a/src/core/lib/channel/channel_args.cc +++ b/src/core/lib/channel/channel_args.cc @@ -214,6 +214,8 @@ void grpc_channel_args_destroy(grpc_channel_args* a) { int grpc_channel_args_compare(const grpc_channel_args* a, const grpc_channel_args* b) { + if (a == nullptr && b == nullptr) return 0; + if (a == nullptr || b == nullptr) return a == nullptr ? -1 : 1; int c = GPR_ICMP(a->num_args, b->num_args); if (c != 0) return c; for (size_t i = 0; i < a->num_args; i++) { From 6f2234277a496cde9e60965ad69e1923912116a4 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 7 Aug 2019 20:05:02 -0700 Subject: [PATCH 1153/1555] Disable nanopb fuzzer test --- test/core/nanopb/fuzzer_response.cc | 3 +++ test/core/nanopb/fuzzer_serverlist.cc | 3 +++ 2 files changed, 6 insertions(+) diff --git a/test/core/nanopb/fuzzer_response.cc b/test/core/nanopb/fuzzer_response.cc index 1f35eac8f64..c5fb8905935 100644 --- a/test/core/nanopb/fuzzer_response.cc +++ b/test/core/nanopb/fuzzer_response.cc @@ -32,10 +32,13 @@ static void dont_log(gpr_log_func_args* args) {} extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_init(); if (squelch) gpr_set_log_function(dont_log); + // TODO(veblush): Convert this to upb. + /* grpc_slice slice = grpc_slice_from_copied_buffer((const char*)data, size); upb::Arena arena; grpc_core::grpc_grpclb_initial_response_parse(slice, arena.ptr()); grpc_slice_unref(slice); + */ grpc_shutdown(); return 0; } diff --git a/test/core/nanopb/fuzzer_serverlist.cc b/test/core/nanopb/fuzzer_serverlist.cc index 079fbd34be1..bc812952cd4 100644 --- a/test/core/nanopb/fuzzer_serverlist.cc +++ b/test/core/nanopb/fuzzer_serverlist.cc @@ -32,12 +32,15 @@ static void dont_log(gpr_log_func_args* args) {} extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_init(); if (squelch) gpr_set_log_function(dont_log); + // TODO(veblush): Convert this to upb. + /* grpc_slice slice = grpc_slice_from_copied_buffer((const char*)data, size); grpc_core::grpc_grpclb_serverlist* serverlist; if ((serverlist = grpc_core::grpc_grpclb_response_parse_serverlist(slice))) { grpc_grpclb_destroy_serverlist(serverlist); } grpc_slice_unref(slice); + */ grpc_shutdown(); return 0; } From c414fe06f803a57acda5c29e9ff5fd5cbd9b45d6 Mon Sep 17 00:00:00 2001 From: Yihua Zhang Date: Thu, 8 Aug 2019 09:46:44 -0700 Subject: [PATCH 1154/1555] add cred data to BUILD files --- src/core/tsi/test_creds/BUILD | 2 ++ test/core/tsi/BUILD | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/core/tsi/test_creds/BUILD b/src/core/tsi/test_creds/BUILD index 732f6d91b26..b83c87de723 100644 --- a/src/core/tsi/test_creds/BUILD +++ b/src/core/tsi/test_creds/BUILD @@ -26,4 +26,6 @@ exports_files([ "badserver.pem", "badclient.key", "badclient.pem", + "multi-domain.key", + "multi-domain.pem", ]) diff --git a/test/core/tsi/BUILD b/test/core/tsi/BUILD index 14578c0e48b..e9faf5c99f3 100644 --- a/test/core/tsi/BUILD +++ b/test/core/tsi/BUILD @@ -74,6 +74,8 @@ grpc_cc_test( "//src/core/tsi/test_creds:server0.pem", "//src/core/tsi/test_creds:server1.key", "//src/core/tsi/test_creds:server1.pem", + "//src/core/tsi/test_creds:multi-domain.key", + "//src/core/tsi/test_creds:multi-domain.pem", ], language = "C++", deps = [ From d2ce6e707cdbd68fbe97ad57bf9a70ea2f8b4bd2 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Thu, 8 Aug 2019 11:50:38 -0700 Subject: [PATCH 1155/1555] Isolated test-specific build steps so that unrelated tasks don't run them Move interop making back to run_tests.py --- src/objective-c/tests/build_one_example.sh | 69 +++++++++---------- .../tests/build_one_example_bazel.sh | 35 ++++++++++ src/objective-c/tests/run_one_test.sh | 4 ++ .../{run_tests.sh => build_and_run_tests.sh} | 4 ++ ...{build_tests.sh => build_and_run_tests.sh} | 0 test/cpp/ios/run_tests.sh | 5 ++ tools/run_tests/run_tests.py | 18 ++--- 7 files changed, 86 insertions(+), 49 deletions(-) create mode 100755 src/objective-c/tests/build_one_example_bazel.sh rename test/core/iomgr/ios/CFStreamTests/{run_tests.sh => build_and_run_tests.sh} (97%) rename test/cpp/ios/{build_tests.sh => build_and_run_tests.sh} (100%) diff --git a/src/objective-c/tests/build_one_example.sh b/src/objective-c/tests/build_one_example.sh index 0a62008f8de..caa048e258b 100755 --- a/src/objective-c/tests/build_one_example.sh +++ b/src/objective-c/tests/build_one_example.sh @@ -29,43 +29,36 @@ cd `dirname $0`/../../.. cd $EXAMPLE_PATH -if [ "$FRAMEWORKS" == "NO" ]; then - if [ "$SCHEME" == "watchOS-sample-WatchKit-App" ]; then - SCHEME="watchOS-sample" - fi - cd .. - ../../../tools/bazel build $SCHEME +# clean the directory +rm -rf Pods +rm -rf *.xcworkspace +rm -f Podfile.lock + +pod install + +set -o pipefail +XCODEBUILD_FILTER='(^CompileC |^Ld |^.*clang |^ *cd |^ *export |^Libtool |^.*libtool |^CpHeader |^ *builtin-copy )' +if [ "$SCHEME" == "tvOS-sample" ]; then + xcodebuild \ + build \ + -workspace *.xcworkspace \ + -scheme $SCHEME \ + -destination generic/platform=tvOS \ + -derivedDataPath Build/Build \ + CODE_SIGN_IDENTITY="" \ + CODE_SIGNING_REQUIRED=NO \ + | egrep -v "$XCODEBUILD_FILTER" \ + | egrep -v "^$" - else - # clean the directory - rm -rf Pods - rm -rf *.xcworkspace - rm -f Podfile.lock - - pod install - - set -o pipefail - XCODEBUILD_FILTER='(^CompileC |^Ld |^.*clang |^ *cd |^ *export |^Libtool |^.*libtool |^CpHeader |^ *builtin-copy )' - if [ "$SCHEME" == "tvOS-sample" ]; then - xcodebuild \ - build \ - -workspace *.xcworkspace \ - -scheme $SCHEME \ - -destination generic/platform=tvOS \ - -derivedDataPath Build/Build \ - CODE_SIGN_IDENTITY="" \ - CODE_SIGNING_REQUIRED=NO \ - | egrep -v "$XCODEBUILD_FILTER" \ - | egrep -v "^$" - - else - xcodebuild \ - build \ - -workspace *.xcworkspace \ - -scheme $SCHEME \ - -destination generic/platform=iOS \ - -derivedDataPath Build/Build \ - CODE_SIGN_IDENTITY="" \ - CODE_SIGNING_REQUIRED=NO \ - | egrep -v "$XCODEBUILD_FILTER" \ - | egrep -v "^$" - - fi + xcodebuild \ + build \ + -workspace *.xcworkspace \ + -scheme $SCHEME \ + -destination generic/platform=iOS \ + -derivedDataPath Build/Build \ + CODE_SIGN_IDENTITY="" \ + CODE_SIGNING_REQUIRED=NO \ + | egrep -v "$XCODEBUILD_FILTER" \ + | egrep -v "^$" - fi + diff --git a/src/objective-c/tests/build_one_example_bazel.sh b/src/objective-c/tests/build_one_example_bazel.sh new file mode 100755 index 00000000000..c3fb3f232b5 --- /dev/null +++ b/src/objective-c/tests/build_one_example_bazel.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# Copyright 2016 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Don't run this script standalone. Instead, run from the repository root: +# ./tools/run_tests/run_tests.py -l objc + +set -ev + +# Params: +# EXAMPLE_PATH - directory of the example +# SCHEME - scheme of the example, used by xcodebuild + +# CocoaPods requires the terminal to be using UTF-8 encoding. +export LANG=en_US.UTF-8 + +cd `dirname $0`/../../.. + +cd $EXAMPLE_PATH/.. + +if [ "$SCHEME" == "watchOS-sample-WatchKit-App" ]; then + SCHEME="watchOS-sample watchOS-sample-watchApp" +fi +../../../tools/bazel build $SCHEME \ No newline at end of file diff --git a/src/objective-c/tests/run_one_test.sh b/src/objective-c/tests/run_one_test.sh index b74107e4a66..a643740b64e 100755 --- a/src/objective-c/tests/run_one_test.sh +++ b/src/objective-c/tests/run_one_test.sh @@ -22,6 +22,10 @@ cd $(dirname $0) BINDIR=../../../bins/$CONFIG +[ -d Tests.xcworkspace/ ] || { + ./build_tests.sh +} + [ -f $BINDIR/interop_server ] || { echo >&2 "Can't find the test server. Make sure run_tests.py is making" \ "interop_server before calling this script." diff --git a/test/core/iomgr/ios/CFStreamTests/run_tests.sh b/test/core/iomgr/ios/CFStreamTests/build_and_run_tests.sh similarity index 97% rename from test/core/iomgr/ios/CFStreamTests/run_tests.sh rename to test/core/iomgr/ios/CFStreamTests/build_and_run_tests.sh index e49a2e0b65e..933af6c8d9e 100755 --- a/test/core/iomgr/ios/CFStreamTests/run_tests.sh +++ b/test/core/iomgr/ios/CFStreamTests/build_and_run_tests.sh @@ -23,6 +23,10 @@ cd "$(dirname "$0")" echo "TIME: $(date)" +./build_tests.sh + +echo "TIME: $(date)" + XCODEBUILD_FILTER='(^CompileC |^Ld |^ *[^ ]*clang |^ *cd |^ *export |^Libtool |^ *[^ ]*libtool |^CpHeader |^ *builtin-copy )' xcodebuild \ diff --git a/test/cpp/ios/build_tests.sh b/test/cpp/ios/build_and_run_tests.sh similarity index 100% rename from test/cpp/ios/build_tests.sh rename to test/cpp/ios/build_and_run_tests.sh diff --git a/test/cpp/ios/run_tests.sh b/test/cpp/ios/run_tests.sh index 9eee0cd28ca..83db83fd199 100755 --- a/test/cpp/ios/run_tests.sh +++ b/test/cpp/ios/run_tests.sh @@ -20,6 +20,11 @@ set -ev cd "$(dirname "$0")" +echo "TIME: $(date)" + +./build_tests.sh + +echo "TIME: $(date)" set -o pipefail diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 1cbf50e5264..0f42b52c50e 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1060,7 +1060,7 @@ class ObjCLanguage(object): out = [] out.append( self.config.job_spec( - ['src/objective-c/tests/build_one_example.sh'], + ['src/objective-c/tests/build_one_example_bazel.sh'], timeout_seconds=10 * 60, shortname='ios-buildtest-example-sample', cpu_cost=1e6, @@ -1092,7 +1092,7 @@ class ObjCLanguage(object): })) out.append( self.config.job_spec( - ['src/objective-c/tests/build_one_example.sh'], + ['src/objective-c/tests/build_one_example_bazel.sh'], timeout_seconds=10 * 60, shortname='ios-buildtest-example-tvOS-sample', cpu_cost=1e6, @@ -1114,7 +1114,7 @@ class ObjCLanguage(object): # })) out.append( self.config.job_spec( - ['src/objective-c/tests/build_one_example.sh'], + ['src/objective-c/tests/build_one_example_bazel.sh'], timeout_seconds=20 * 60, shortname='ios-buildtest-example-watchOS-sample', cpu_cost=1e6, @@ -1143,7 +1143,7 @@ class ObjCLanguage(object): environ=_FORCE_ENVIRON_FOR_WRAPPERS)) out.append( self.config.job_spec( - ['test/core/iomgr/ios/CFStreamTests/run_tests.sh'], + ['test/core/iomgr/ios/CFStreamTests/build_and_run_tests.sh'], timeout_seconds=20 * 60, shortname='ios-test-cfstream-tests', cpu_cost=1e6, @@ -1177,14 +1177,14 @@ class ObjCLanguage(object): })) out.append( self.config.job_spec( - ['test/cpp/ios/run_tests.sh'], + ['test/cpp/ios/build_and_run_tests.sh'], timeout_seconds=20 * 60, shortname='ios-cpp-test-cronet', cpu_cost=1e6, environ=_FORCE_ENVIRON_FOR_WRAPPERS)) out.append( self.config.job_spec( - ['src/objective-c/tests/run_one_test_bazel.sh'], + ['src/objective-c/tests/run_one_test.sh'], timeout_seconds=60 * 60, shortname='mac-test-basictests', cpu_cost=1e6, @@ -1215,11 +1215,7 @@ class ObjCLanguage(object): return [] def build_steps(self): - return [ - ['src/objective-c/tests/build_tests.sh'], - ['test/core/iomgr/ios/CFStreamTests/build_tests.sh'], - ['test/cpp/ios/build_tests.sh'], - ] + return [] def post_tests_steps(self): return [] From d06f5448157a00bf101e30cfc7ee23b1716670ec Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 8 Aug 2019 13:41:23 -0700 Subject: [PATCH 1156/1555] Fix Swift build issues --- gRPC.podspec | 14 ++- src/objective-c/BUILD | 11 +- .../GRPCClient/GRPCCall+ChannelArg.h | 2 +- .../GRPCClient/GRPCCall+ChannelCredentials.h | 2 +- src/objective-c/GRPCClient/GRPCCall+Cronet.h | 4 +- src/objective-c/GRPCClient/GRPCCall+GID.h | 2 +- src/objective-c/GRPCClient/GRPCCall+OAuth2.h | 4 +- src/objective-c/GRPCClient/GRPCCall+Tests.h | 2 +- src/objective-c/GRPCClient/GRPCCall.h | 111 +----------------- src/objective-c/GRPCClient/GRPCCallLegacy.m | 1 + src/objective-c/GRPCClient/GRPCCallOptions.h | 1 - src/objective-c/GRPCClient/GRPCTypes.h | 111 ++++++++++++++++++ .../GRPCClient/private/GRPCCore/GRPCHost.m | 1 + .../private/GRPCTransport+Private.m | 4 +- src/objective-c/ProtoRPC/ProtoRPCLegacy.h | 8 ++ src/objective-c/ProtoRPC/ProtoService.h | 6 +- src/objective-c/ProtoRPC/ProtoService.m | 6 +- src/objective-c/ProtoRPC/ProtoServiceLegacy.m | 24 +++- templates/gRPC.podspec.template | 14 ++- 19 files changed, 188 insertions(+), 140 deletions(-) diff --git a/gRPC.podspec b/gRPC.podspec index 4b8f9358e8d..06d553db102 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -51,10 +51,20 @@ Pod::Spec.new do |s| s.subspec 'Interface-Legacy' do |ss| ss.header_mappings_dir = 'src/objective-c/GRPCClient' - ss.public_header_files = "src/objective-c/GRPCClient/GRPCCallLegacy.h", + ss.public_header_files = "GRPCClient/GRPCCall+ChannelArg.h", + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", + "src/objective-c/GRPCClient/GRPCCallLegacy.h", "src/objective-c/GRPCClient/GRPCTypes.h" - ss.source_files = "src/objective-c/GRPCClient/GRPCCallLegacy.h", + ss.source_files = "GRPCClient/GRPCCall+ChannelArg.h", + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", + "src/objective-c/GRPCClient/GRPCCallLegacy.h", "src/objective-c/GRPCClient/GRPCTypes.h" end diff --git a/src/objective-c/BUILD b/src/objective-c/BUILD index 13a26187e9f..9e0181d9e98 100644 --- a/src/objective-c/BUILD +++ b/src/objective-c/BUILD @@ -18,11 +18,11 @@ licenses(["notice"]) # Apache v2 package(default_visibility = ["//visibility:public"]) -load("//bazel:grpc_build_system.bzl", "grpc_objc_library", "grpc_objc_use_cronet_config") +load("//bazel:grpc_build_system.bzl", "grpc_objc_library", "grpc_generate_objc_one_off_targets") exports_files(["LICENSE"]) -grpc_objc_use_cronet_config() +grpc_generate_objc_one_off_targets() grpc_objc_library( name = "rx_library_headers", @@ -41,8 +41,8 @@ grpc_objc_library( ]), includes = ["."], deps = [ - ":rx_library_private", ":rx_library_headers", + ":rx_library_private", ], ) @@ -60,6 +60,11 @@ grpc_objc_library( grpc_objc_library( name = "grpc_objc_interface_legacy", hdrs = [ + "GRPCClient/GRPCCall+ChannelArg.h", + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", "GRPCClient/GRPCCallLegacy.h", "GRPCClient/GRPCTypes.h", ], diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h index 2ddd53a5c66..ff5a153a0f6 100644 --- a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h @@ -15,7 +15,7 @@ * limitations under the License. * */ -#import "GRPCCall.h" +#import "GRPCCallLegacy.h" #include diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h b/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h index 7d6f79b7655..c3d194bff94 100644 --- a/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h @@ -16,7 +16,7 @@ * */ -#import "GRPCCall.h" +#import "GRPCCallLegacy.h" // Deprecated interface. Please use GRPCCallOptions instead. @interface GRPCCall (ChannelCredentials) diff --git a/src/objective-c/GRPCClient/GRPCCall+Cronet.h b/src/objective-c/GRPCClient/GRPCCall+Cronet.h index c49d7cf16f3..d107ada3672 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Cronet.h +++ b/src/objective-c/GRPCClient/GRPCCall+Cronet.h @@ -16,8 +16,8 @@ * */ -#import "GRPCCall.h" -#import "GRPCTransport.h" +#import "GRPCCallLegacy.h" +#import "GRPCTypes.h" typedef struct stream_engine stream_engine; diff --git a/src/objective-c/GRPCClient/GRPCCall+GID.h b/src/objective-c/GRPCClient/GRPCCall+GID.h index 8293e92ebe9..80e34ea98da 100644 --- a/src/objective-c/GRPCClient/GRPCCall+GID.h +++ b/src/objective-c/GRPCClient/GRPCCall+GID.h @@ -17,7 +17,7 @@ */ #import "GRPCCall+OAuth2.h" -#import "GRPCCall.h" +#import "GRPCCallLegacy.h" #import diff --git a/src/objective-c/GRPCClient/GRPCCall+OAuth2.h b/src/objective-c/GRPCClient/GRPCCall+OAuth2.h index 60cdc50bfda..cf60c794f27 100644 --- a/src/objective-c/GRPCClient/GRPCCall+OAuth2.h +++ b/src/objective-c/GRPCClient/GRPCCall+OAuth2.h @@ -16,9 +16,9 @@ * */ -#import "GRPCCall.h" +#import "GRPCCallLegacy.h" -#import "GRPCCallOptions.h" +@protocol GRPCAuthorizationProtocol; // Deprecated interface. Please use GRPCCallOptions instead. @interface GRPCCall (OAuth2) diff --git a/src/objective-c/GRPCClient/GRPCCall+Tests.h b/src/objective-c/GRPCClient/GRPCCall+Tests.h index edaa5ed582c..af81eec6b82 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Tests.h +++ b/src/objective-c/GRPCClient/GRPCCall+Tests.h @@ -16,7 +16,7 @@ * */ -#import "GRPCCall.h" +#import "GRPCCallLegacy.h" // Deprecated interface. Please use GRPCCallOptions instead. @interface GRPCCall (Tests) diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index 153ddc5c171..1c7a10048cf 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -36,6 +36,7 @@ #import "GRPCCallOptions.h" #import "GRPCDispatchable.h" +#import "GRPCTypes.h" // The legacy header is included for backwards compatibility. Some V1 API users are still using // GRPCCall by importing GRPCCall.h header so we need this import. @@ -43,116 +44,6 @@ NS_ASSUME_NONNULL_BEGIN -#pragma mark gRPC errors - -/** Domain of NSError objects produced by gRPC. */ -extern NSString *const kGRPCErrorDomain; - -/** - * gRPC error codes. - * Note that a few of these are never produced by the gRPC libraries, but are of general utility for - * server applications to produce. - */ -typedef NS_ENUM(NSUInteger, GRPCErrorCode) { - /** The operation was cancelled (typically by the caller). */ - GRPCErrorCodeCancelled = 1, - - /** - * Unknown error. Errors raised by APIs that do not return enough error information may be - * converted to this error. - */ - GRPCErrorCodeUnknown = 2, - - /** - * The client specified an invalid argument. Note that this differs from FAILED_PRECONDITION. - * INVALID_ARGUMENT indicates arguments that are problematic regardless of the state of the - * server (e.g., a malformed file name). - */ - GRPCErrorCodeInvalidArgument = 3, - - /** - * Deadline expired before operation could complete. For operations that change the state of the - * server, this error may be returned even if the operation has completed successfully. For - * example, a successful response from the server could have been delayed long enough for the - * deadline to expire. - */ - GRPCErrorCodeDeadlineExceeded = 4, - - /** Some requested entity (e.g., file or directory) was not found. */ - GRPCErrorCodeNotFound = 5, - - /** Some entity that we attempted to create (e.g., file or directory) already exists. */ - GRPCErrorCodeAlreadyExists = 6, - - /** - * The caller does not have permission to execute the specified operation. PERMISSION_DENIED isn't - * used for rejections caused by exhausting some resource (RESOURCE_EXHAUSTED is used instead for - * those errors). PERMISSION_DENIED doesn't indicate a failure to identify the caller - * (UNAUTHENTICATED is used instead for those errors). - */ - GRPCErrorCodePermissionDenied = 7, - - /** - * The request does not have valid authentication credentials for the operation (e.g. the caller's - * identity can't be verified). - */ - GRPCErrorCodeUnauthenticated = 16, - - /** Some resource has been exhausted, perhaps a per-user quota. */ - GRPCErrorCodeResourceExhausted = 8, - - /** - * The RPC was rejected because the server is not in a state required for the procedure's - * execution. For example, a directory to be deleted may be non-empty, etc. - * The client should not retry until the server state has been explicitly fixed (e.g. by - * performing another RPC). The details depend on the service being called, and should be found in - * the NSError's userInfo. - */ - GRPCErrorCodeFailedPrecondition = 9, - - /** - * The RPC was aborted, typically due to a concurrency issue like sequencer check failures, - * transaction aborts, etc. The client should retry at a higher-level (e.g., restarting a read- - * modify-write sequence). - */ - GRPCErrorCodeAborted = 10, - - /** - * The RPC was attempted past the valid range. E.g., enumerating past the end of a list. - * Unlike INVALID_ARGUMENT, this error indicates a problem that may be fixed if the system state - * changes. For example, an RPC to get elements of a list will generate INVALID_ARGUMENT if asked - * to return the element at a negative index, but it will generate OUT_OF_RANGE if asked to return - * the element at an index past the current size of the list. - */ - GRPCErrorCodeOutOfRange = 11, - - /** The procedure is not implemented or not supported/enabled in this server. */ - GRPCErrorCodeUnimplemented = 12, - - /** - * Internal error. Means some invariant expected by the server application or the gRPC library has - * been broken. - */ - GRPCErrorCodeInternal = 13, - - /** - * The server is currently unavailable. This is most likely a transient condition and may be - * corrected by retrying with a backoff. Note that it is not always safe to retry - * non-idempotent operations. - */ - GRPCErrorCodeUnavailable = 14, - - /** Unrecoverable data loss or corruption. */ - GRPCErrorCodeDataLoss = 15, -}; - -/** - * Keys used in |NSError|'s |userInfo| dictionary to store the response headers and trailers sent by - * the server. - */ -extern NSString *const kGRPCHeadersKey; -extern NSString *const kGRPCTrailersKey; - /** An object can implement this protocol to receive responses from server from a call. */ @protocol GRPCResponseHandler diff --git a/src/objective-c/GRPCClient/GRPCCallLegacy.m b/src/objective-c/GRPCClient/GRPCCallLegacy.m index e25048cfc7e..b1220999741 100644 --- a/src/objective-c/GRPCClient/GRPCCallLegacy.m +++ b/src/objective-c/GRPCClient/GRPCCallLegacy.m @@ -21,6 +21,7 @@ #import "GRPCCall+Cronet.h" #import "GRPCCall+OAuth2.h" #import "GRPCCallOptions.h" +#import "GRPCTypes.h" #import "private/GRPCCore/GRPCChannelPool.h" #import "private/GRPCCore/GRPCCompletionQueue.h" diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.h b/src/objective-c/GRPCClient/GRPCCallOptions.h index 6adc8aa1776..d4a60a2a1c7 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.h +++ b/src/objective-c/GRPCClient/GRPCCallOptions.h @@ -22,7 +22,6 @@ NS_ASSUME_NONNULL_BEGIN -typedef char *GRPCTransportId; @protocol GRPCInterceptorFactory; /** diff --git a/src/objective-c/GRPCClient/GRPCTypes.h b/src/objective-c/GRPCClient/GRPCTypes.h index 332b6e86a2b..de4f2f9e93c 100644 --- a/src/objective-c/GRPCClient/GRPCTypes.h +++ b/src/objective-c/GRPCClient/GRPCTypes.h @@ -16,6 +16,104 @@ * */ +/** + * gRPC error codes. + * Note that a few of these are never produced by the gRPC libraries, but are of general utility for + * server applications to produce. + */ +typedef NS_ENUM(NSUInteger, GRPCErrorCode) { + /** The operation was cancelled (typically by the caller). */ + GRPCErrorCodeCancelled = 1, + + /** + * Unknown error. Errors raised by APIs that do not return enough error information may be + * converted to this error. + */ + GRPCErrorCodeUnknown = 2, + + /** + * The client specified an invalid argument. Note that this differs from FAILED_PRECONDITION. + * INVALID_ARGUMENT indicates arguments that are problematic regardless of the state of the + * server (e.g., a malformed file name). + */ + GRPCErrorCodeInvalidArgument = 3, + + /** + * Deadline expired before operation could complete. For operations that change the state of the + * server, this error may be returned even if the operation has completed successfully. For + * example, a successful response from the server could have been delayed long enough for the + * deadline to expire. + */ + GRPCErrorCodeDeadlineExceeded = 4, + + /** Some requested entity (e.g., file or directory) was not found. */ + GRPCErrorCodeNotFound = 5, + + /** Some entity that we attempted to create (e.g., file or directory) already exists. */ + GRPCErrorCodeAlreadyExists = 6, + + /** + * The caller does not have permission to execute the specified operation. PERMISSION_DENIED isn't + * used for rejections caused by exhausting some resource (RESOURCE_EXHAUSTED is used instead for + * those errors). PERMISSION_DENIED doesn't indicate a failure to identify the caller + * (UNAUTHENTICATED is used instead for those errors). + */ + GRPCErrorCodePermissionDenied = 7, + + /** + * The request does not have valid authentication credentials for the operation (e.g. the caller's + * identity can't be verified). + */ + GRPCErrorCodeUnauthenticated = 16, + + /** Some resource has been exhausted, perhaps a per-user quota. */ + GRPCErrorCodeResourceExhausted = 8, + + /** + * The RPC was rejected because the server is not in a state required for the procedure's + * execution. For example, a directory to be deleted may be non-empty, etc. + * The client should not retry until the server state has been explicitly fixed (e.g. by + * performing another RPC). The details depend on the service being called, and should be found in + * the NSError's userInfo. + */ + GRPCErrorCodeFailedPrecondition = 9, + + /** + * The RPC was aborted, typically due to a concurrency issue like sequencer check failures, + * transaction aborts, etc. The client should retry at a higher-level (e.g., restarting a read- + * modify-write sequence). + */ + GRPCErrorCodeAborted = 10, + + /** + * The RPC was attempted past the valid range. E.g., enumerating past the end of a list. + * Unlike INVALID_ARGUMENT, this error indicates a problem that may be fixed if the system state + * changes. For example, an RPC to get elements of a list will generate INVALID_ARGUMENT if asked + * to return the element at a negative index, but it will generate OUT_OF_RANGE if asked to return + * the element at an index past the current size of the list. + */ + GRPCErrorCodeOutOfRange = 11, + + /** The procedure is not implemented or not supported/enabled in this server. */ + GRPCErrorCodeUnimplemented = 12, + + /** + * Internal error. Means some invariant expected by the server application or the gRPC library has + * been broken. + */ + GRPCErrorCodeInternal = 13, + + /** + * The server is currently unavailable. This is most likely a transient condition and may be + * corrected by retrying with a backoff. Note that it is not always safe to retry + * non-idempotent operations. + */ + GRPCErrorCodeUnavailable = 14, + + /** Unrecoverable data loss or corruption. */ + GRPCErrorCodeDataLoss = 15, +}; + /** * Safety remark of a gRPC method as defined in RFC 2616 Section 9.1 */ @@ -55,3 +153,16 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { /** Insecure channel. FOR TEST ONLY! */ GRPCTransportTypeInsecure, }; + +/** Domain of NSError objects produced by gRPC. */ +extern NSString *const kGRPCErrorDomain; + +/** + * Keys used in |NSError|'s |userInfo| dictionary to store the response headers and trailers sent by + * the server. + */ +extern NSString *const kGRPCHeadersKey; +extern NSString *const kGRPCTrailersKey; + +/** The id of a transport implementation. */ +typedef char *GRPCTransportId; diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m index efee85e3108..98f46062786 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m @@ -21,6 +21,7 @@ #import #import #import +#import #include #include diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m index 2482ff86e6a..0daf127d150 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m @@ -83,7 +83,7 @@ /** Forward initial metadata to the previous interceptor in the chain */ - (void)forwardPreviousInterceptorWithInitialMetadata:(NSDictionary *)initialMetadata { - if (_previousInterceptor == nil) { + if (initialMetadata == nil || _previousInterceptor == nil) { return; } id copiedPreviousInterceptor = _previousInterceptor; @@ -94,7 +94,7 @@ /** Forward a received message to the previous interceptor in the chain */ - (void)forwardPreviousInterceptorWithData:(id)data { - if (_previousInterceptor == nil) { + if (data == nil || _previousInterceptor == nil) { return; } id copiedPreviousInterceptor = _previousInterceptor; diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.h b/src/objective-c/ProtoRPC/ProtoRPCLegacy.h index 7b9658d5b94..54823ab90db 100644 --- a/src/objective-c/ProtoRPC/ProtoRPCLegacy.h +++ b/src/objective-c/ProtoRPC/ProtoRPCLegacy.h @@ -18,6 +18,13 @@ #import +// Import category headers for Swift build +#import +#import +#import +#import +#import + @class GRPCProtoMethod; @class GRXWriter; @protocol GRXWriteable; @@ -36,6 +43,7 @@ __attribute__((deprecated("Please use GRPCProtoCall."))) @interface ProtoRPC : (id)responsesWriteable NS_DESIGNATED_INITIALIZER; - (void)start; + @end /** diff --git a/src/objective-c/ProtoRPC/ProtoService.h b/src/objective-c/ProtoRPC/ProtoService.h index d55ed30a39b..2f1d596c59e 100644 --- a/src/objective-c/ProtoRPC/ProtoService.h +++ b/src/objective-c/ProtoRPC/ProtoService.h @@ -30,11 +30,7 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnullability-completeness" -__attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoService : NSObject { - NSString *_host; - NSString *_packageName; - NSString *_serviceName; -} +__attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoService : NSObject - (nullable instancetype)initWithHost:(nonnull NSString *)host packageName:(nonnull NSString *)packageName diff --git a/src/objective-c/ProtoRPC/ProtoService.m b/src/objective-c/ProtoRPC/ProtoService.m index 40c51ed48e7..e84cab8903f 100644 --- a/src/objective-c/ProtoRPC/ProtoService.m +++ b/src/objective-c/ProtoRPC/ProtoService.m @@ -29,7 +29,11 @@ #pragma clang diagnostic ignored "-Wdeprecated-implementations" @implementation ProtoService { #pragma clang diagnostic pop + GRPCCallOptions *_callOptions; + NSString *_host; + NSString *_packageName; + NSString *_serviceName; } #pragma clang diagnostic push @@ -60,8 +64,6 @@ return self; } -#pragma clang diagnostic pop - - (GRPCUnaryProtoCall *)RPCToMethod:(NSString *)method message:(id)message responseHandler:(id)handler diff --git a/src/objective-c/ProtoRPC/ProtoServiceLegacy.m b/src/objective-c/ProtoRPC/ProtoServiceLegacy.m index 3f1cb278723..ecac401703f 100644 --- a/src/objective-c/ProtoRPC/ProtoServiceLegacy.m +++ b/src/objective-c/ProtoRPC/ProtoServiceLegacy.m @@ -16,6 +16,8 @@ * */ +#import + #import "ProtoServiceLegacy.h" #import "ProtoMethod.h" #import "ProtoRPCLegacy.h" @@ -34,20 +36,32 @@ packageName:(NSString *)packageName serviceName:(NSString *)serviceName { if ((self = [super init])) { - _host = [host copy]; - _packageName = [packageName copy]; - _serviceName = [serviceName copy]; + Ivar hostIvar = class_getInstanceVariable([ProtoService class], "_host"); + Ivar packageNameIvar = class_getInstanceVariable([ProtoService class], "_packageName"); + Ivar serviceNameIvar = class_getInstanceVariable([ProtoService class], "_serviceName"); + + object_setIvar(self, hostIvar, [host copy]); + object_setIvar(self, packageNameIvar, [packageName copy]); + object_setIvar(self, serviceNameIvar, [serviceName copy]); } return self; } +#pragma clang diagnostic pop - (GRPCProtoCall *)RPCToMethod:(NSString *)method requestsWriter:(GRXWriter *)requestsWriter responseClass:(Class)responseClass responsesWriteable:(id)responsesWriteable { + Ivar hostIvar = class_getInstanceVariable([ProtoService class], "_host"); + Ivar packageNameIvar = class_getInstanceVariable([ProtoService class], "_packageName"); + Ivar serviceNameIvar = class_getInstanceVariable([ProtoService class], "_serviceName"); + NSString *host = object_getIvar(self, hostIvar); + NSString *packageName = object_getIvar(self, packageNameIvar); + NSString *serviceName = object_getIvar(self, serviceNameIvar); + GRPCProtoMethod *methodName = - [[GRPCProtoMethod alloc] initWithPackage:_packageName service:_serviceName method:method]; - return [[GRPCProtoCall alloc] initWithHost:_host + [[GRPCProtoMethod alloc] initWithPackage:packageName service:serviceName method:method]; + return [[GRPCProtoCall alloc] initWithHost:host method:methodName requestsWriter:requestsWriter responseClass:responseClass diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index 78e95abdc9e..2f1268e5c49 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -53,10 +53,20 @@ s.subspec 'Interface-Legacy' do |ss| ss.header_mappings_dir = 'src/objective-c/GRPCClient' - ss.public_header_files = "src/objective-c/GRPCClient/GRPCCallLegacy.h", + ss.public_header_files = "GRPCClient/GRPCCall+ChannelArg.h", + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", + "src/objective-c/GRPCClient/GRPCCallLegacy.h", "src/objective-c/GRPCClient/GRPCTypes.h" - ss.source_files = "src/objective-c/GRPCClient/GRPCCallLegacy.h", + ss.source_files = "GRPCClient/GRPCCall+ChannelArg.h", + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", + "src/objective-c/GRPCClient/GRPCCallLegacy.h", "src/objective-c/GRPCClient/GRPCTypes.h" end From 25432e011a0bf4ae8f48ad16f251aeab89966ca0 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 8 Aug 2019 14:12:43 -0700 Subject: [PATCH 1157/1555] clang-format --- src/compiler/objective_c_plugin.cc | 4 +- src/objective-c/GRPCClient/GRPCTypes.h | 90 ++++++++++--------- src/objective-c/ProtoRPC/ProtoService.h | 12 +-- src/objective-c/ProtoRPC/ProtoServiceLegacy.m | 4 +- .../InteropTestsMultipleChannels.m | 2 +- 5 files changed, 59 insertions(+), 53 deletions(-) diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index f9066af4aa6..682cc28b739 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -211,8 +211,8 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { FrameworkImport(file_name + ".pbobjc.h", framework); } imports += (generator_params.no_v1_compatibility - ? SystemImport("ProtoRPC/ProtoRPC.h") - : SystemImport("ProtoRPC/ProtoRPCLegacy.h")); + ? SystemImport("ProtoRPC/ProtoRPC.h") + : SystemImport("ProtoRPC/ProtoRPCLegacy.h")); if (!generator_params.no_v1_compatibility) { imports += SystemImport("RxLibrary/GRXWriter+Immediate.h"); } diff --git a/src/objective-c/GRPCClient/GRPCTypes.h b/src/objective-c/GRPCClient/GRPCTypes.h index de4f2f9e93c..0aacf0f9d15 100644 --- a/src/objective-c/GRPCClient/GRPCTypes.h +++ b/src/objective-c/GRPCClient/GRPCTypes.h @@ -18,51 +18,55 @@ /** * gRPC error codes. - * Note that a few of these are never produced by the gRPC libraries, but are of general utility for - * server applications to produce. + * Note that a few of these are never produced by the gRPC libraries, but are of + * general utility for server applications to produce. */ typedef NS_ENUM(NSUInteger, GRPCErrorCode) { /** The operation was cancelled (typically by the caller). */ GRPCErrorCodeCancelled = 1, /** - * Unknown error. Errors raised by APIs that do not return enough error information may be - * converted to this error. + * Unknown error. Errors raised by APIs that do not return enough error + * information may be converted to this error. */ GRPCErrorCodeUnknown = 2, /** - * The client specified an invalid argument. Note that this differs from FAILED_PRECONDITION. - * INVALID_ARGUMENT indicates arguments that are problematic regardless of the state of the - * server (e.g., a malformed file name). + * The client specified an invalid argument. Note that this differs from + * FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments that are + * problematic regardless of the state of the server (e.g., a malformed file + * name). */ GRPCErrorCodeInvalidArgument = 3, /** - * Deadline expired before operation could complete. For operations that change the state of the - * server, this error may be returned even if the operation has completed successfully. For - * example, a successful response from the server could have been delayed long enough for the - * deadline to expire. + * Deadline expired before operation could complete. For operations that + * change the state of the server, this error may be returned even if the + * operation has completed successfully. For example, a successful response + * from the server could have been delayed long enough for the deadline to + * expire. */ GRPCErrorCodeDeadlineExceeded = 4, /** Some requested entity (e.g., file or directory) was not found. */ GRPCErrorCodeNotFound = 5, - /** Some entity that we attempted to create (e.g., file or directory) already exists. */ + /** Some entity that we attempted to create (e.g., file or directory) already + exists. */ GRPCErrorCodeAlreadyExists = 6, /** - * The caller does not have permission to execute the specified operation. PERMISSION_DENIED isn't - * used for rejections caused by exhausting some resource (RESOURCE_EXHAUSTED is used instead for - * those errors). PERMISSION_DENIED doesn't indicate a failure to identify the caller + * The caller does not have permission to execute the specified operation. + * PERMISSION_DENIED isn't used for rejections caused by exhausting some + * resource (RESOURCE_EXHAUSTED is used instead for those errors). + * PERMISSION_DENIED doesn't indicate a failure to identify the caller * (UNAUTHENTICATED is used instead for those errors). */ GRPCErrorCodePermissionDenied = 7, /** - * The request does not have valid authentication credentials for the operation (e.g. the caller's - * identity can't be verified). + * The request does not have valid authentication credentials for the + * operation (e.g. the caller's identity can't be verified). */ GRPCErrorCodeUnauthenticated = 16, @@ -70,43 +74,45 @@ typedef NS_ENUM(NSUInteger, GRPCErrorCode) { GRPCErrorCodeResourceExhausted = 8, /** - * The RPC was rejected because the server is not in a state required for the procedure's - * execution. For example, a directory to be deleted may be non-empty, etc. - * The client should not retry until the server state has been explicitly fixed (e.g. by - * performing another RPC). The details depend on the service being called, and should be found in - * the NSError's userInfo. + * The RPC was rejected because the server is not in a state required for the + * procedure's execution. For example, a directory to be deleted may be + * non-empty, etc. The client should not retry until the server state has been + * explicitly fixed (e.g. by performing another RPC). The details depend on + * the service being called, and should be found in the NSError's userInfo. */ GRPCErrorCodeFailedPrecondition = 9, /** - * The RPC was aborted, typically due to a concurrency issue like sequencer check failures, - * transaction aborts, etc. The client should retry at a higher-level (e.g., restarting a read- - * modify-write sequence). + * The RPC was aborted, typically due to a concurrency issue like sequencer + * check failures, transaction aborts, etc. The client should retry at a + * higher-level (e.g., restarting a read- modify-write sequence). */ GRPCErrorCodeAborted = 10, /** - * The RPC was attempted past the valid range. E.g., enumerating past the end of a list. - * Unlike INVALID_ARGUMENT, this error indicates a problem that may be fixed if the system state - * changes. For example, an RPC to get elements of a list will generate INVALID_ARGUMENT if asked - * to return the element at a negative index, but it will generate OUT_OF_RANGE if asked to return - * the element at an index past the current size of the list. + * The RPC was attempted past the valid range. E.g., enumerating past the end + * of a list. Unlike INVALID_ARGUMENT, this error indicates a problem that may + * be fixed if the system state changes. For example, an RPC to get elements + * of a list will generate INVALID_ARGUMENT if asked to return the element at + * a negative index, but it will generate OUT_OF_RANGE if asked to return the + * element at an index past the current size of the list. */ GRPCErrorCodeOutOfRange = 11, - /** The procedure is not implemented or not supported/enabled in this server. */ + /** The procedure is not implemented or not supported/enabled in this server. + */ GRPCErrorCodeUnimplemented = 12, /** - * Internal error. Means some invariant expected by the server application or the gRPC library has - * been broken. + * Internal error. Means some invariant expected by the server application or + * the gRPC library has been broken. */ GRPCErrorCodeInternal = 13, /** - * The server is currently unavailable. This is most likely a transient condition and may be - * corrected by retrying with a backoff. Note that it is not always safe to retry - * non-idempotent operations. + * The server is currently unavailable. This is most likely a transient + * condition and may be corrected by retrying with a backoff. Note that it is + * not always safe to retry non-idempotent operations. */ GRPCErrorCodeUnavailable = 14, @@ -155,14 +161,14 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { }; /** Domain of NSError objects produced by gRPC. */ -extern NSString *const kGRPCErrorDomain; +extern NSString* const kGRPCErrorDomain; /** - * Keys used in |NSError|'s |userInfo| dictionary to store the response headers and trailers sent by - * the server. + * Keys used in |NSError|'s |userInfo| dictionary to store the response headers + * and trailers sent by the server. */ -extern NSString *const kGRPCHeadersKey; -extern NSString *const kGRPCTrailersKey; +extern NSString* const kGRPCHeadersKey; +extern NSString* const kGRPCTrailersKey; /** The id of a transport implementation. */ -typedef char *GRPCTransportId; +typedef char* GRPCTransportId; diff --git a/src/objective-c/ProtoRPC/ProtoService.h b/src/objective-c/ProtoRPC/ProtoService.h index 2f1d596c59e..34aea380668 100644 --- a/src/objective-c/ProtoRPC/ProtoService.h +++ b/src/objective-c/ProtoRPC/ProtoService.h @@ -30,13 +30,13 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnullability-completeness" -__attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoService : NSObject +__attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoService + : NSObject -- (nullable instancetype)initWithHost:(nonnull NSString *)host - packageName:(nonnull NSString *)packageName - serviceName:(nonnull NSString *)serviceName - callOptions:(nullable GRPCCallOptions *)callOptions - NS_DESIGNATED_INITIALIZER; + - + (nullable instancetype)initWithHost : (nonnull NSString *)host packageName + : (nonnull NSString *)packageName serviceName : (nonnull NSString *)serviceName callOptions + : (nullable GRPCCallOptions *)callOptions NS_DESIGNATED_INITIALIZER; - (nullable GRPCUnaryProtoCall *)RPCToMethod:(nonnull NSString *)method message:(nonnull id)message diff --git a/src/objective-c/ProtoRPC/ProtoServiceLegacy.m b/src/objective-c/ProtoRPC/ProtoServiceLegacy.m index ecac401703f..b8b2766cdb0 100644 --- a/src/objective-c/ProtoRPC/ProtoServiceLegacy.m +++ b/src/objective-c/ProtoRPC/ProtoServiceLegacy.m @@ -18,9 +18,9 @@ #import -#import "ProtoServiceLegacy.h" #import "ProtoMethod.h" #import "ProtoRPCLegacy.h" +#import "ProtoServiceLegacy.h" #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-implementations" @@ -60,7 +60,7 @@ NSString *serviceName = object_getIvar(self, serviceNameIvar); GRPCProtoMethod *methodName = - [[GRPCProtoMethod alloc] initWithPackage:packageName service:serviceName method:method]; + [[GRPCProtoMethod alloc] initWithPackage:packageName service:serviceName method:method]; return [[GRPCProtoCall alloc] initWithHost:host method:methodName requestsWriter:requestsWriter diff --git a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m index 5decdd05a95..d3dd1bf8d7f 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m +++ b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m @@ -20,10 +20,10 @@ #import #import +#import #import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" #import "src/objective-c/tests/RemoteTestClient/Test.pbobjc.h" #import "src/objective-c/tests/RemoteTestClient/Test.pbrpc.h" -#import #import "../ConfigureCronet.h" #import "InteropTestsBlockCallbacks.h" From df59df8ba260eb356b9bca39ff6f180535bdaac8 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Thu, 8 Aug 2019 14:48:10 -0700 Subject: [PATCH 1158/1555] Upgrading bazel_skylib --- bazel/grpc_deps.bzl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 7752ab814e5..c954dc99760 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -191,11 +191,10 @@ def grpc_deps(): ) if "bazel_skylib" not in native.existing_rules(): - http_archive( + git_repository( name = "bazel_skylib", - sha256 = "ba5d15ca230efca96320085d8e4d58da826d1f81b444ef8afccd8b23e0799b52", - strip_prefix = "bazel-skylib-f83cb8dd6f5658bc574ccd873e25197055265d1c", - url = "https://github.com/bazelbuild/bazel-skylib/archive/f83cb8dd6f5658bc574ccd873e25197055265d1c.tar.gz", + remote = "https://github.com/bazelbuild/bazel-skylib", + tag = "0.9.0", ) if "io_opencensus_cpp" not in native.existing_rules(): From 1069dee43a51d04a32cc1f70c3e2ba84f3153183 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Thu, 8 Aug 2019 15:00:02 -0700 Subject: [PATCH 1159/1555] Excluded *.inc from python garbage cleanup --- tools/run_tests/artifacts/build_artifact_python.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/artifacts/build_artifact_python.sh b/tools/run_tests/artifacts/build_artifact_python.sh index c5e380fe5dc..55fd4ead04d 100755 --- a/tools/run_tests/artifacts/build_artifact_python.sh +++ b/tools/run_tests/artifacts/build_artifact_python.sh @@ -48,7 +48,7 @@ clean_non_source_files() { ( cd "$1" find . -type f \ | grep -v '\.c$' | grep -v '\.cc$' | grep -v '\.cpp$' \ - | grep -v '\.h$' | grep -v '\.hh$' \ + | grep -v '\.h$' | grep -v '\.hh$' | grep -v '\.inc$' \ | grep -v '\.s$' | grep -v '\.py$' \ | while read -r file; do rm -f "$file" || true From 4be53843d3f25025cf8f65d5644143305e8a8e54 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Thu, 8 Aug 2019 14:41:46 -0700 Subject: [PATCH 1160/1555] Use bazel to run interop server Removed commented tests --- src/objective-c/tests/run_one_test.sh | 14 ++++------- src/objective-c/tests/run_one_test_bazel.sh | 12 +++++----- src/objective-c/tests/run_tests.sh | 13 +++++------ tools/run_tests/run_tests.py | 26 ++------------------- 4 files changed, 18 insertions(+), 47 deletions(-) diff --git a/src/objective-c/tests/run_one_test.sh b/src/objective-c/tests/run_one_test.sh index a643740b64e..8fb26d75b72 100755 --- a/src/objective-c/tests/run_one_test.sh +++ b/src/objective-c/tests/run_one_test.sh @@ -20,18 +20,12 @@ set -ev cd $(dirname $0) -BINDIR=../../../bins/$CONFIG +BAZEL=../../../tools/bazel -[ -d Tests.xcworkspace/ ] || { +[ -d Tests.xcworkspace ] || { ./build_tests.sh } -[ -f $BINDIR/interop_server ] || { - echo >&2 "Can't find the test server. Make sure run_tests.py is making" \ - "interop_server before calling this script." - exit 1 -} - [ -z "$(ps aux |egrep 'port_server\.py.*-p\s32766')" ] && { echo >&2 "Can't find the port server. Start port server with tools/run_tests/start_port_server.py." exit 1 @@ -40,8 +34,8 @@ BINDIR=../../../bins/$CONFIG PLAIN_PORT=$(curl localhost:32766/get) TLS_PORT=$(curl localhost:32766/get) -$BINDIR/interop_server --port=$PLAIN_PORT --max_send_message_size=8388608 & -$BINDIR/interop_server --port=$TLS_PORT --max_send_message_size=8388608 --use_tls & +BAZEL run -- //test/cpp/interop:interop_server --port=$PLAIN_PORT --max_send_message_size=8388608 & +BAZEL run -- //test/cpp/interop:interop_server --port=$TLS_PORT --max_send_message_size=8388608 --use_tls & trap 'kill -9 `jobs -p` ; echo "EXIT TIME: $(date)"' EXIT diff --git a/src/objective-c/tests/run_one_test_bazel.sh b/src/objective-c/tests/run_one_test_bazel.sh index 41ffa21490c..39c28fb28a5 100755 --- a/src/objective-c/tests/run_one_test_bazel.sh +++ b/src/objective-c/tests/run_one_test_bazel.sh @@ -22,10 +22,10 @@ cd $(dirname $0) BINDIR=../../../bins/$CONFIG -[ -f $BINDIR/interop_server ] || { - echo >&2 "Can't find the test server. Make sure run_tests.py is making" \ - "interop_server before calling this script." - exit 1 +BAZEL=../../../tools/bazel + +[ -d Tests.xcworkspace ] || { + ./build_tests.sh } [ -z "$(ps aux |egrep 'port_server\.py.*-p\s32766')" ] && { @@ -36,8 +36,8 @@ BINDIR=../../../bins/$CONFIG PLAIN_PORT=$(curl localhost:32766/get) TLS_PORT=$(curl localhost:32766/get) -$BINDIR/interop_server --port=$PLAIN_PORT --max_send_message_size=8388608 & -$BINDIR/interop_server --port=$TLS_PORT --max_send_message_size=8388608 --use_tls & +BAZEL run -- //test/cpp/interop:interop_server --port=$PLAIN_PORT --max_send_message_size=8388608 & +BAZEL run -- //test/cpp/interop:interop_server --port=$TLS_PORT --max_send_message_size=8388608 --use_tls & trap 'kill -9 `jobs -p` ; echo "EXIT TIME: $(date)"' EXIT diff --git a/src/objective-c/tests/run_tests.sh b/src/objective-c/tests/run_tests.sh index 24185c561ec..916ca15b39f 100755 --- a/src/objective-c/tests/run_tests.sh +++ b/src/objective-c/tests/run_tests.sh @@ -22,15 +22,14 @@ cd $(dirname $0) # Run the tests server. -BINDIR=../../../bins/$CONFIG +BAZEL=../../../tools/bazel -[ -f $BINDIR/interop_server ] || { - echo >&2 "Can't find the test server. Make sure run_tests.py is making" \ - "interop_server before calling this script." - exit 1 +[ -d Tests.xcworkspace ] || { + ./build_tests.sh } -$BINDIR/interop_server --port=5050 --max_send_message_size=8388608 & -$BINDIR/interop_server --port=5051 --max_send_message_size=8388608 --use_tls & +BAZEL run -- //test/cpp/interop:interop_server --port=5050 --max_send_message_size=8388608 & +BAZEL run -- //test/cpp/interop:interop_server --port=5051 --max_send_message_size=8388608 --use_tls & + # Kill them when this script exits. trap 'kill -9 `jobs -p` ; echo "EXIT TIME: $(date)"' EXIT diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 0f42b52c50e..0c3ef0bd57f 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1101,17 +1101,6 @@ class ObjCLanguage(object): 'EXAMPLE_PATH': 'src/objective-c/examples/tvOS-sample', 'FRAMEWORKS': 'NO' })) - # out.append( - # self.config.job_spec( - # ['src/objective-c/tests/build_one_example.sh'], - # timeout_seconds=10 * 60, - # shortname='ios-buildtest-example-tvOS-sample-framework', - # cpu_cost=1e6, - # environ={ - # 'SCHEME': 'tvOS-sample', - # 'EXAMPLE_PATH': 'src/objective-c/examples/tvOS-sample', - # 'FRAMEWORKS': 'YES' - # })) out.append( self.config.job_spec( ['src/objective-c/tests/build_one_example_bazel.sh'], @@ -1123,17 +1112,6 @@ class ObjCLanguage(object): 'EXAMPLE_PATH': 'src/objective-c/examples/watchOS-sample', 'FRAMEWORKS': 'NO' })) - # out.append( - # self.config.job_spec( - # ['src/objective-c/tests/build_one_example.sh'], - # timeout_seconds=20 * 60, - # shortname='ios-buildtest-example-watchOS-sample-framework', - # cpu_cost=1e6, - # environ={ - # 'SCHEME': 'watchOS-sample-WatchKit-App', - # 'EXAMPLE_PATH': 'src/objective-c/examples/watchOS-sample', - # 'FRAMEWORKS': 'YES' - # })) out.append( self.config.job_spec( ['src/objective-c/tests/run_plugin_tests.sh'], @@ -1150,7 +1128,7 @@ class ObjCLanguage(object): environ=_FORCE_ENVIRON_FOR_WRAPPERS)) out.append( self.config.job_spec( - ['src/objective-c/tests/run_one_test_bazel.sh'], + ['src/objective-c/tests/run_one_test.sh'], timeout_seconds=60 * 60, shortname='ios-test-unittests', cpu_cost=1e6, @@ -1209,7 +1187,7 @@ class ObjCLanguage(object): return [] def make_targets(self): - return ['interop_server'] + return [] def make_options(self): return [] From adbe914f4b434e3138ac348b82624c13fedb12cb Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Thu, 8 Aug 2019 16:19:18 -0700 Subject: [PATCH 1161/1555] Removed nanopb dependency from xDS --- BUILD | 6 ------ 1 file changed, 6 deletions(-) diff --git a/BUILD b/BUILD index 7b7b4499a26..c5abe5ce217 100644 --- a/BUILD +++ b/BUILD @@ -1257,9 +1257,6 @@ grpc_cc_library( "src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h", "src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h", ], - external_deps = [ - "nanopb", - ], language = "c++", deps = [ "envoy_ads_upb", @@ -1284,9 +1281,6 @@ grpc_cc_library( "src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h", "src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h", ], - external_deps = [ - "nanopb", - ], language = "c++", deps = [ "envoy_ads_upb", From be4e684a8259acb8132652d12aa3d511f76c3e09 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 12 Jul 2019 15:41:50 -0700 Subject: [PATCH 1162/1555] Migrated tsi/alts from nanopb to upb --- BUILD | 27 +- BUILD.gn | 17 +- CMakeLists.txt | 66 +- Makefile | 83 +- build.yaml | 32 +- config.m4 | 15 +- config.w32 | 15 +- gRPC-C++.podspec | 16 +- gRPC-Core.podspec | 43 +- grpc.gemspec | 29 +- grpc.gyp | 13 +- package.xml | 29 +- .../alts/handshaker/alts_handshaker_client.cc | 180 +++-- .../handshaker/alts_handshaker_service_api.cc | 520 ------------- .../handshaker/alts_handshaker_service_api.h | 323 -------- .../alts_handshaker_service_api_util.cc | 145 ---- .../alts_handshaker_service_api_util.h | 149 ---- .../alts/handshaker/alts_tsi_handshaker.cc | 41 +- .../tsi/alts/handshaker/alts_tsi_handshaker.h | 4 +- .../tsi/alts/handshaker/alts_tsi_utils.cc | 16 +- src/core/tsi/alts/handshaker/alts_tsi_utils.h | 7 +- src/core/tsi/alts/handshaker/altscontext.pb.c | 47 -- src/core/tsi/alts/handshaker/altscontext.pb.h | 63 -- src/core/tsi/alts/handshaker/handshaker.pb.c | 122 --- src/core/tsi/alts/handshaker/handshaker.pb.h | 254 ------- .../handshaker/transport_security_common.pb.c | 49 -- .../handshaker/transport_security_common.pb.h | 78 -- .../transport_security_common_api.cc | 130 ++-- .../transport_security_common_api.h | 72 +- src/python/grpcio/grpc_core_dependencies.py | 13 +- test/core/tsi/alts/handshaker/BUILD | 11 - .../handshaker/alts_handshaker_client_test.cc | 182 ++--- .../alts_handshaker_service_api_test.cc | 149 ---- .../alts_handshaker_service_api_test_lib.cc | 709 +++--------------- .../alts_handshaker_service_api_test_lib.h | 116 +-- .../handshaker/alts_tsi_handshaker_test.cc | 66 +- .../alts/handshaker/alts_tsi_utils_test.cc | 23 +- .../transport_security_common_api_test.cc | 52 +- tools/distrib/check_nanopb_output.sh | 27 - tools/doxygen/Doxyfile.core.internal | 23 +- .../generated/sources_and_headers.json | 59 +- tools/run_tests/generated/tests.json | 24 - 42 files changed, 650 insertions(+), 3389 deletions(-) delete mode 100644 src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc delete mode 100644 src/core/tsi/alts/handshaker/alts_handshaker_service_api.h delete mode 100644 src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc delete mode 100644 src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h delete mode 100644 src/core/tsi/alts/handshaker/altscontext.pb.c delete mode 100644 src/core/tsi/alts/handshaker/altscontext.pb.h delete mode 100644 src/core/tsi/alts/handshaker/handshaker.pb.c delete mode 100644 src/core/tsi/alts/handshaker/handshaker.pb.h delete mode 100644 src/core/tsi/alts/handshaker/transport_security_common.pb.c delete mode 100644 src/core/tsi/alts/handshaker/transport_security_common.pb.h delete mode 100644 test/core/tsi/alts/handshaker/alts_handshaker_service_api_test.cc diff --git a/BUILD b/BUILD index 7b7b4499a26..1835a909542 100644 --- a/BUILD +++ b/BUILD @@ -1861,24 +1861,6 @@ grpc_cc_library( ], ) -grpc_cc_library( - name = "alts_proto", - srcs = [ - "src/core/tsi/alts/handshaker/altscontext.pb.c", - "src/core/tsi/alts/handshaker/handshaker.pb.c", - "src/core/tsi/alts/handshaker/transport_security_common.pb.c", - ], - hdrs = [ - "src/core/tsi/alts/handshaker/altscontext.pb.h", - "src/core/tsi/alts/handshaker/handshaker.pb.h", - "src/core/tsi/alts/handshaker/transport_security_common.pb.h", - ], - external_deps = [ - "nanopb", - ], - language = "c++", -) - grpc_cc_library( name = "alts_util", srcs = [ @@ -1889,24 +1871,17 @@ grpc_cc_library( "src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc", "src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc", "src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc", - "src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc", - "src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc", "src/core/tsi/alts/handshaker/transport_security_common_api.cc", ], hdrs = [ "src/core/lib/security/credentials/alts/check_gcp_environment.h", "src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h", - "src/core/tsi/alts/handshaker/alts_handshaker_service_api.h", - "src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h", "src/core/tsi/alts/handshaker/transport_security_common_api.h", ], - external_deps = [ - "nanopb", - ], language = "c++", public_hdrs = GRPC_SECURE_PUBLIC_HDRS, deps = [ - "alts_proto", + "alts_upb", "gpr", "grpc_base", ], diff --git a/BUILD.gn b/BUILD.gn index e63f7d2f2f1..18204a17c33 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -462,6 +462,12 @@ config("grpc_config") { "src/core/ext/upb-generated/google/protobuf/wrappers.upb.h", "src/core/ext/upb-generated/google/rpc/status.upb.c", "src/core/ext/upb-generated/google/rpc/status.upb.h", + "src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c", + "src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h", + "src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c", + "src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h", + "src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c", + "src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h", "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c", "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h", "src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c", @@ -865,10 +871,6 @@ config("grpc_config") { "src/core/tsi/alts/frame_protector/frame_handler.h", "src/core/tsi/alts/handshaker/alts_handshaker_client.cc", "src/core/tsi/alts/handshaker/alts_handshaker_client.h", - "src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc", - "src/core/tsi/alts/handshaker/alts_handshaker_service_api.h", - "src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc", - "src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h", "src/core/tsi/alts/handshaker/alts_shared_resource.cc", "src/core/tsi/alts/handshaker/alts_shared_resource.h", "src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc", @@ -876,12 +878,6 @@ config("grpc_config") { "src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h", "src/core/tsi/alts/handshaker/alts_tsi_utils.cc", "src/core/tsi/alts/handshaker/alts_tsi_utils.h", - "src/core/tsi/alts/handshaker/altscontext.pb.c", - "src/core/tsi/alts/handshaker/altscontext.pb.h", - "src/core/tsi/alts/handshaker/handshaker.pb.c", - "src/core/tsi/alts/handshaker/handshaker.pb.h", - "src/core/tsi/alts/handshaker/transport_security_common.pb.c", - "src/core/tsi/alts/handshaker/transport_security_common.pb.h", "src/core/tsi/alts/handshaker/transport_security_common_api.cc", "src/core/tsi/alts/handshaker/transport_security_common_api.h", "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc", @@ -934,7 +930,6 @@ config("grpc_config") { ":gpr", "//third_party/cares", ":address_sorting", - ":nanopb", ] public_configs = [ diff --git a/CMakeLists.txt b/CMakeLists.txt index b1c70db8fcf..70aaedd08a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -528,7 +528,6 @@ add_dependencies(buildtests_cxx alts_frame_handler_test) add_dependencies(buildtests_cxx alts_frame_protector_test) add_dependencies(buildtests_cxx alts_grpc_record_protocol_test) add_dependencies(buildtests_cxx alts_handshaker_client_test) -add_dependencies(buildtests_cxx alts_handshaker_service_api_test) add_dependencies(buildtests_cxx alts_iovec_record_protocol_test) add_dependencies(buildtests_cxx alts_security_connector_test) add_dependencies(buildtests_cxx alts_tsi_handshaker_test) @@ -1255,23 +1254,18 @@ add_library(grpc src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc - src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc - src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc src/core/tsi/alts/handshaker/alts_tsi_utils.cc src/core/tsi/alts/handshaker/transport_security_common_api.cc - src/core/tsi/alts/handshaker/altscontext.pb.c - src/core/tsi/alts/handshaker/handshaker.pb.c - src/core/tsi/alts/handshaker/transport_security_common.pb.c - third_party/nanopb/pb_common.c - third_party/nanopb/pb_decode.c - third_party/nanopb/pb_encode.c - src/core/tsi/transport_security.cc + src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c + src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c + src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c third_party/upb/upb/decode.c third_party/upb/upb/encode.c third_party/upb/upb/msg.c third_party/upb/upb/port.c third_party/upb/upb/table.c third_party/upb/upb/upb.c + src/core/tsi/transport_security.cc src/core/ext/transport/chttp2/client/insecure/channel_create.cc src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc src/core/ext/transport/chttp2/client/authority.cc @@ -1771,16 +1765,11 @@ add_library(grpc_cronet src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc - src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc - src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc src/core/tsi/alts/handshaker/alts_tsi_utils.cc src/core/tsi/alts/handshaker/transport_security_common_api.cc - src/core/tsi/alts/handshaker/altscontext.pb.c - src/core/tsi/alts/handshaker/handshaker.pb.c - src/core/tsi/alts/handshaker/transport_security_common.pb.c - third_party/nanopb/pb_common.c - third_party/nanopb/pb_decode.c - third_party/nanopb/pb_encode.c + src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c + src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c + src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c src/core/tsi/transport_security.cc src/core/ext/transport/chttp2/client/insecure/channel_create.cc src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc @@ -11269,47 +11258,6 @@ target_link_libraries(alts_handshaker_client_test ) -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) - -add_executable(alts_handshaker_service_api_test - test/core/tsi/alts/handshaker/alts_handshaker_service_api_test.cc - third_party/googletest/googletest/src/gtest-all.cc - third_party/googletest/googlemock/src/gmock-all.cc -) - - -target_include_directories(alts_handshaker_service_api_test - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_UPB_GENERATED_DIR} - PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} - PRIVATE ${_gRPC_UPB_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} - PRIVATE third_party/googletest/googletest/include - PRIVATE third_party/googletest/googletest - PRIVATE third_party/googletest/googlemock/include - PRIVATE third_party/googletest/googlemock - PRIVATE ${_gRPC_PROTO_GENS_DIR} -) - -target_link_libraries(alts_handshaker_service_api_test - ${_gRPC_PROTOBUF_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} - alts_test_util - gpr - grpc - ${_gRPC_GFLAGS_LIBRARIES} -) - - endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index 51895104453..ef5963dc441 100644 --- a/Makefile +++ b/Makefile @@ -1146,7 +1146,6 @@ alts_frame_handler_test: $(BINDIR)/$(CONFIG)/alts_frame_handler_test alts_frame_protector_test: $(BINDIR)/$(CONFIG)/alts_frame_protector_test alts_grpc_record_protocol_test: $(BINDIR)/$(CONFIG)/alts_grpc_record_protocol_test alts_handshaker_client_test: $(BINDIR)/$(CONFIG)/alts_handshaker_client_test -alts_handshaker_service_api_test: $(BINDIR)/$(CONFIG)/alts_handshaker_service_api_test alts_iovec_record_protocol_test: $(BINDIR)/$(CONFIG)/alts_iovec_record_protocol_test alts_security_connector_test: $(BINDIR)/$(CONFIG)/alts_security_connector_test alts_tsi_handshaker_test: $(BINDIR)/$(CONFIG)/alts_tsi_handshaker_test @@ -1627,7 +1626,6 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/alts_frame_protector_test \ $(BINDIR)/$(CONFIG)/alts_grpc_record_protocol_test \ $(BINDIR)/$(CONFIG)/alts_handshaker_client_test \ - $(BINDIR)/$(CONFIG)/alts_handshaker_service_api_test \ $(BINDIR)/$(CONFIG)/alts_iovec_record_protocol_test \ $(BINDIR)/$(CONFIG)/alts_security_connector_test \ $(BINDIR)/$(CONFIG)/alts_tsi_handshaker_test \ @@ -1795,7 +1793,6 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/alts_frame_protector_test \ $(BINDIR)/$(CONFIG)/alts_grpc_record_protocol_test \ $(BINDIR)/$(CONFIG)/alts_handshaker_client_test \ - $(BINDIR)/$(CONFIG)/alts_handshaker_service_api_test \ $(BINDIR)/$(CONFIG)/alts_iovec_record_protocol_test \ $(BINDIR)/$(CONFIG)/alts_security_connector_test \ $(BINDIR)/$(CONFIG)/alts_tsi_handshaker_test \ @@ -2241,8 +2238,6 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/alts_grpc_record_protocol_test || ( echo test alts_grpc_record_protocol_test failed ; exit 1 ) $(E) "[RUN] Testing alts_handshaker_client_test" $(Q) $(BINDIR)/$(CONFIG)/alts_handshaker_client_test || ( echo test alts_handshaker_client_test failed ; exit 1 ) - $(E) "[RUN] Testing alts_handshaker_service_api_test" - $(Q) $(BINDIR)/$(CONFIG)/alts_handshaker_service_api_test || ( echo test alts_handshaker_service_api_test failed ; exit 1 ) $(E) "[RUN] Testing alts_iovec_record_protocol_test" $(Q) $(BINDIR)/$(CONFIG)/alts_iovec_record_protocol_test || ( echo test alts_iovec_record_protocol_test failed ; exit 1 ) $(E) "[RUN] Testing alts_security_connector_test" @@ -3762,23 +3757,18 @@ LIBGRPC_SRC = \ src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc \ src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc \ src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc \ - src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc \ - src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc \ src/core/tsi/alts/handshaker/alts_tsi_utils.cc \ src/core/tsi/alts/handshaker/transport_security_common_api.cc \ - src/core/tsi/alts/handshaker/altscontext.pb.c \ - src/core/tsi/alts/handshaker/handshaker.pb.c \ - src/core/tsi/alts/handshaker/transport_security_common.pb.c \ - third_party/nanopb/pb_common.c \ - third_party/nanopb/pb_decode.c \ - third_party/nanopb/pb_encode.c \ - src/core/tsi/transport_security.cc \ + src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c \ + src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c \ + src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c \ third_party/upb/upb/decode.c \ third_party/upb/upb/encode.c \ third_party/upb/upb/msg.c \ third_party/upb/upb/port.c \ third_party/upb/upb/table.c \ third_party/upb/upb/upb.c \ + src/core/tsi/transport_security.cc \ src/core/ext/transport/chttp2/client/insecure/channel_create.cc \ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \ src/core/ext/transport/chttp2/client/authority.cc \ @@ -4266,16 +4256,11 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc \ src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc \ src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc \ - src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc \ - src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc \ src/core/tsi/alts/handshaker/alts_tsi_utils.cc \ src/core/tsi/alts/handshaker/transport_security_common_api.cc \ - src/core/tsi/alts/handshaker/altscontext.pb.c \ - src/core/tsi/alts/handshaker/handshaker.pb.c \ - src/core/tsi/alts/handshaker/transport_security_common.pb.c \ - third_party/nanopb/pb_common.c \ - third_party/nanopb/pb_decode.c \ - third_party/nanopb/pb_encode.c \ + src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c \ + src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c \ + src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c \ src/core/tsi/transport_security.cc \ src/core/ext/transport/chttp2/client/insecure/channel_create.cc \ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \ @@ -13657,49 +13642,6 @@ endif endif -ALTS_HANDSHAKER_SERVICE_API_TEST_SRC = \ - test/core/tsi/alts/handshaker/alts_handshaker_service_api_test.cc \ - -ALTS_HANDSHAKER_SERVICE_API_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(ALTS_HANDSHAKER_SERVICE_API_TEST_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/alts_handshaker_service_api_test: openssl_dep_error - -else - - - - -ifeq ($(NO_PROTOBUF),true) - -# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. - -$(BINDIR)/$(CONFIG)/alts_handshaker_service_api_test: protobuf_dep_error - -else - -$(BINDIR)/$(CONFIG)/alts_handshaker_service_api_test: $(PROTOBUF_DEP) $(ALTS_HANDSHAKER_SERVICE_API_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libalts_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(ALTS_HANDSHAKER_SERVICE_API_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libalts_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/alts_handshaker_service_api_test - -endif - -endif - -$(OBJDIR)/$(CONFIG)/test/core/tsi/alts/handshaker/alts_handshaker_service_api_test.o: $(LIBDIR)/$(CONFIG)/libalts_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a - -deps_alts_handshaker_service_api_test: $(ALTS_HANDSHAKER_SERVICE_API_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(ALTS_HANDSHAKER_SERVICE_API_TEST_OBJS:.o=.dep) -endif -endif - - ALTS_IOVEC_RECORD_PROTOCOL_TEST_SRC = \ test/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol_test.cc \ @@ -22480,6 +22422,9 @@ src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc: $(OPENSSL_ src/core/ext/transport/cronet/plugin_registry/grpc_cronet_plugin_registry.cc: $(OPENSSL_DEP) src/core/ext/transport/cronet/transport/cronet_api_dummy.cc: $(OPENSSL_DEP) src/core/ext/transport/cronet/transport/cronet_transport.cc: $(OPENSSL_DEP) +src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c: $(OPENSSL_DEP) +src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c: $(OPENSSL_DEP) +src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c: $(OPENSSL_DEP) src/core/lib/http/httpcli_security_connector.cc: $(OPENSSL_DEP) src/core/lib/security/context/security_context.cc: $(OPENSSL_DEP) src/core/lib/security/credentials/alts/alts_credentials.cc: $(OPENSSL_DEP) @@ -22534,14 +22479,9 @@ src/core/tsi/alts/frame_protector/alts_seal_privacy_integrity_crypter.cc: $(OPEN src/core/tsi/alts/frame_protector/alts_unseal_privacy_integrity_crypter.cc: $(OPENSSL_DEP) src/core/tsi/alts/frame_protector/frame_handler.cc: $(OPENSSL_DEP) src/core/tsi/alts/handshaker/alts_handshaker_client.cc: $(OPENSSL_DEP) -src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc: $(OPENSSL_DEP) -src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc: $(OPENSSL_DEP) src/core/tsi/alts/handshaker/alts_shared_resource.cc: $(OPENSSL_DEP) src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc: $(OPENSSL_DEP) src/core/tsi/alts/handshaker/alts_tsi_utils.cc: $(OPENSSL_DEP) -src/core/tsi/alts/handshaker/altscontext.pb.c: $(OPENSSL_DEP) -src/core/tsi/alts/handshaker/handshaker.pb.c: $(OPENSSL_DEP) -src/core/tsi/alts/handshaker/transport_security_common.pb.c: $(OPENSSL_DEP) src/core/tsi/alts/handshaker/transport_security_common_api.cc: $(OPENSSL_DEP) src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc: $(OPENSSL_DEP) src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc: $(OPENSSL_DEP) @@ -22620,9 +22560,6 @@ test/cpp/util/string_ref_helper.cc: $(OPENSSL_DEP) test/cpp/util/subprocess.cc: $(OPENSSL_DEP) test/cpp/util/test_config_cc.cc: $(OPENSSL_DEP) test/cpp/util/test_credentials_provider.cc: $(OPENSSL_DEP) -third_party/nanopb/pb_common.c: $(OPENSSL_DEP) -third_party/nanopb/pb_decode.c: $(OPENSSL_DEP) -third_party/nanopb/pb_encode.c: $(OPENSSL_DEP) endif .PHONY: all strip tools dep_error openssl_dep_error openssl_dep_message git_update stop buildtests buildtests_c buildtests_cxx test test_c test_cxx install install_c install_cxx install-headers install-headers_c install-headers_cxx install-shared install-shared_c install-shared_cxx install-static install-static_c install-static_cxx strip strip-shared strip-static strip_c strip-shared_c strip-static_c strip_cxx strip-shared_cxx strip-static_cxx dep_c dep_cxx bins_dep_c bins_dep_cxx clean diff --git a/build.yaml b/build.yaml index a18b916ec66..0b8c1955d27 100644 --- a/build.yaml +++ b/build.yaml @@ -17,17 +17,6 @@ settings: g_stands_for: ganges version: 1.24.0-dev filegroups: -- name: alts_proto - headers: - - src/core/tsi/alts/handshaker/altscontext.pb.h - - src/core/tsi/alts/handshaker/handshaker.pb.h - - src/core/tsi/alts/handshaker/transport_security_common.pb.h - src: - - src/core/tsi/alts/handshaker/altscontext.pb.c - - src/core/tsi/alts/handshaker/handshaker.pb.c - - src/core/tsi/alts/handshaker/transport_security_common.pb.c - uses: - - nanopb - name: alts_tsi headers: - src/core/tsi/alts/crypt/gsec.h @@ -80,14 +69,14 @@ filegroups: - src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c - src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c - src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c + uses: + - upb - name: alts_util public_headers: - include/grpc/grpc_security.h headers: - src/core/lib/security/credentials/alts/check_gcp_environment.h - src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h - - src/core/tsi/alts/handshaker/alts_handshaker_service_api.h - - src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h - src/core/tsi/alts/handshaker/alts_tsi_utils.h - src/core/tsi/alts/handshaker/transport_security_common_api.h src: @@ -98,14 +87,11 @@ filegroups: - src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc - src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc - src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc - - src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc - - src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc - src/core/tsi/alts/handshaker/alts_tsi_utils.cc - src/core/tsi/alts/handshaker/transport_security_common_api.cc uses: - - alts_proto + - alts_upb - grpc_base - - nanopb - tsi_interface - upb - name: census @@ -202,6 +188,8 @@ filegroups: - src/core/ext/upb-generated/google/protobuf/timestamp.upb.c - src/core/ext/upb-generated/google/protobuf/wrappers.upb.c - src/core/ext/upb-generated/google/rpc/status.upb.c + uses: + - upb - name: gpr_base src: - src/core/lib/gpr/alloc.cc @@ -878,6 +866,7 @@ filegroups: - src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c uses: - google_api_upb + - upb - name: grpc_max_age_filter headers: - src/core/ext/filters/max_age/max_age_filter.h @@ -4027,15 +4016,6 @@ targets: - alts_test_util - gpr - grpc -- name: alts_handshaker_service_api_test - build: test - language: c++ - src: - - test/core/tsi/alts/handshaker/alts_handshaker_service_api_test.cc - deps: - - alts_test_util - - gpr - - grpc - name: alts_iovec_record_protocol_test build: test language: c++ diff --git a/config.m4 b/config.m4 index 1bc581e6b67..72fd381fd53 100644 --- a/config.m4 +++ b/config.m4 @@ -334,23 +334,18 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc \ src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc \ src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc \ - src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc \ - src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc \ src/core/tsi/alts/handshaker/alts_tsi_utils.cc \ src/core/tsi/alts/handshaker/transport_security_common_api.cc \ - src/core/tsi/alts/handshaker/altscontext.pb.c \ - src/core/tsi/alts/handshaker/handshaker.pb.c \ - src/core/tsi/alts/handshaker/transport_security_common.pb.c \ - third_party/nanopb/pb_common.c \ - third_party/nanopb/pb_decode.c \ - third_party/nanopb/pb_encode.c \ - src/core/tsi/transport_security.cc \ + src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c \ + src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c \ + src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c \ third_party/upb/upb/decode.c \ third_party/upb/upb/encode.c \ third_party/upb/upb/msg.c \ third_party/upb/upb/port.c \ third_party/upb/upb/table.c \ third_party/upb/upb/upb.c \ + src/core/tsi/transport_security.cc \ src/core/ext/transport/chttp2/client/insecure/channel_create.cc \ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \ src/core/ext/transport/chttp2/client/authority.cc \ @@ -767,6 +762,7 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/google/api) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/google/protobuf) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/google/rpc) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/src/proto/grpc/gcp) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/src/proto/grpc/health/v1) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/src/proto/grpc/lb/v1) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/validate) @@ -853,6 +849,5 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/x509v3) PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/ssl) PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/third_party/fiat) - PHP_ADD_BUILD_DIR($ext_builddir/third_party/nanopb) PHP_ADD_BUILD_DIR($ext_builddir/third_party/upb/upb) fi diff --git a/config.w32 b/config.w32 index 52553fe5d5f..a2d0d0f6abf 100644 --- a/config.w32 +++ b/config.w32 @@ -307,23 +307,18 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\security\\credentials\\alts\\grpc_alts_credentials_client_options.cc " + "src\\core\\lib\\security\\credentials\\alts\\grpc_alts_credentials_options.cc " + "src\\core\\lib\\security\\credentials\\alts\\grpc_alts_credentials_server_options.cc " + - "src\\core\\tsi\\alts\\handshaker\\alts_handshaker_service_api.cc " + - "src\\core\\tsi\\alts\\handshaker\\alts_handshaker_service_api_util.cc " + "src\\core\\tsi\\alts\\handshaker\\alts_tsi_utils.cc " + "src\\core\\tsi\\alts\\handshaker\\transport_security_common_api.cc " + - "src\\core\\tsi\\alts\\handshaker\\altscontext.pb.c " + - "src\\core\\tsi\\alts\\handshaker\\handshaker.pb.c " + - "src\\core\\tsi\\alts\\handshaker\\transport_security_common.pb.c " + - "third_party\\nanopb\\pb_common.c " + - "third_party\\nanopb\\pb_decode.c " + - "third_party\\nanopb\\pb_encode.c " + - "src\\core\\tsi\\transport_security.cc " + + "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\gcp\\altscontext.upb.c " + + "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\gcp\\handshaker.upb.c " + + "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\gcp\\transport_security_common.upb.c " + "third_party\\upb\\upb\\decode.c " + "third_party\\upb\\upb\\encode.c " + "third_party\\upb\\upb\\msg.c " + "third_party\\upb\\upb\\port.c " + "third_party\\upb\\upb\\table.c " + "third_party\\upb\\upb\\upb.c " + + "src\\core\\tsi\\transport_security.cc " + "src\\core\\ext\\transport\\chttp2\\client\\insecure\\channel_create.cc " + "src\\core\\ext\\transport\\chttp2\\client\\insecure\\channel_create_posix.cc " + "src\\core\\ext\\transport\\chttp2\\client\\authority.cc " + @@ -785,6 +780,7 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\gcp"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\health"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\health\\v1"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\lb"); @@ -883,7 +879,6 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\ssl"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\third_party"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\third_party\\fiat"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\nanopb"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\upb"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\upb\\upb"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\zlib"); diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index e0c8a570d48..5f0b312227e 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -228,6 +228,10 @@ Pod::Spec.new do |s| 'src/cpp/server/health/default_health_check_service.h', 'src/cpp/server/thread_pool_interface.h', 'src/cpp/thread_manager/thread_manager.h', + 'third_party/nanopb/pb.h', + 'third_party/nanopb/pb_common.h', + 'third_party/nanopb/pb_decode.h', + 'third_party/nanopb/pb_encode.h', 'src/cpp/client/insecure_credentials.cc', 'src/cpp/client/secure_credentials.cc', 'src/cpp/common/auth_property_iterator.cc', @@ -380,15 +384,11 @@ Pod::Spec.new do |s| 'src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h', 'src/core/lib/security/credentials/alts/check_gcp_environment.h', 'src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h', - 'src/core/tsi/alts/handshaker/alts_handshaker_service_api.h', - 'src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h', 'src/core/tsi/alts/handshaker/alts_tsi_utils.h', 'src/core/tsi/alts/handshaker/transport_security_common_api.h', - 'src/core/tsi/alts/handshaker/altscontext.pb.h', - 'src/core/tsi/alts/handshaker/handshaker.pb.h', - 'src/core/tsi/alts/handshaker/transport_security_common.pb.h', - 'src/core/tsi/transport_security.h', - 'src/core/tsi/transport_security_interface.h', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h', 'third_party/upb/upb/decode.h', 'third_party/upb/upb/encode.h', 'third_party/upb/upb/generated_util.h', @@ -397,6 +397,8 @@ Pod::Spec.new do |s| 'third_party/upb/upb/port_undef.inc', 'third_party/upb/upb/table.int.h', 'third_party/upb/upb/upb.h', + 'src/core/tsi/transport_security.h', + 'src/core/tsi/transport_security_interface.h', 'src/core/ext/transport/chttp2/client/authority.h', 'src/core/ext/transport/chttp2/client/chttp2_connector.h', 'src/core/ext/filters/client_channel/backup_poller.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 0d6a282a94a..2a35ca35fb5 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -336,15 +336,11 @@ Pod::Spec.new do |s| 'src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h', 'src/core/lib/security/credentials/alts/check_gcp_environment.h', 'src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h', - 'src/core/tsi/alts/handshaker/alts_handshaker_service_api.h', - 'src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h', 'src/core/tsi/alts/handshaker/alts_tsi_utils.h', 'src/core/tsi/alts/handshaker/transport_security_common_api.h', - 'src/core/tsi/alts/handshaker/altscontext.pb.h', - 'src/core/tsi/alts/handshaker/handshaker.pb.h', - 'src/core/tsi/alts/handshaker/transport_security_common.pb.h', - 'src/core/tsi/transport_security.h', - 'src/core/tsi/transport_security_interface.h', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h', 'third_party/upb/upb/decode.h', 'third_party/upb/upb/encode.h', 'third_party/upb/upb/generated_util.h', @@ -353,6 +349,8 @@ Pod::Spec.new do |s| 'third_party/upb/upb/port_undef.inc', 'third_party/upb/upb/table.int.h', 'third_party/upb/upb/upb.h', + 'src/core/tsi/transport_security.h', + 'src/core/tsi/transport_security_interface.h', 'src/core/ext/transport/chttp2/client/authority.h', 'src/core/ext/transport/chttp2/client/chttp2_connector.h', 'src/core/ext/filters/client_channel/backup_poller.h', @@ -834,20 +832,18 @@ Pod::Spec.new do |s| 'src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc', 'src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc', 'src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc', - 'src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc', - 'src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc', 'src/core/tsi/alts/handshaker/alts_tsi_utils.cc', 'src/core/tsi/alts/handshaker/transport_security_common_api.cc', - 'src/core/tsi/alts/handshaker/altscontext.pb.c', - 'src/core/tsi/alts/handshaker/handshaker.pb.c', - 'src/core/tsi/alts/handshaker/transport_security_common.pb.c', - 'src/core/tsi/transport_security.cc', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c', 'third_party/upb/upb/decode.c', 'third_party/upb/upb/encode.c', 'third_party/upb/upb/msg.c', 'third_party/upb/upb/port.c', 'third_party/upb/upb/table.c', 'third_party/upb/upb/upb.c', + 'src/core/tsi/transport_security.cc', 'src/core/ext/transport/chttp2/client/insecure/channel_create.cc', 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc', 'src/core/ext/transport/chttp2/client/authority.cc', @@ -1065,15 +1061,11 @@ Pod::Spec.new do |s| 'src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h', 'src/core/lib/security/credentials/alts/check_gcp_environment.h', 'src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h', - 'src/core/tsi/alts/handshaker/alts_handshaker_service_api.h', - 'src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h', 'src/core/tsi/alts/handshaker/alts_tsi_utils.h', 'src/core/tsi/alts/handshaker/transport_security_common_api.h', - 'src/core/tsi/alts/handshaker/altscontext.pb.h', - 'src/core/tsi/alts/handshaker/handshaker.pb.h', - 'src/core/tsi/alts/handshaker/transport_security_common.pb.h', - 'src/core/tsi/transport_security.h', - 'src/core/tsi/transport_security_interface.h', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h', 'third_party/upb/upb/decode.h', 'third_party/upb/upb/encode.h', 'third_party/upb/upb/generated_util.h', @@ -1082,6 +1074,8 @@ Pod::Spec.new do |s| 'third_party/upb/upb/port_undef.inc', 'third_party/upb/upb/table.int.h', 'third_party/upb/upb/upb.h', + 'src/core/tsi/transport_security.h', + 'src/core/tsi/transport_security_interface.h', 'src/core/ext/transport/chttp2/client/authority.h', 'src/core/ext/transport/chttp2/client/chttp2_connector.h', 'src/core/ext/filters/client_channel/backup_poller.h', @@ -1336,16 +1330,9 @@ Pod::Spec.new do |s| ss.source_files = 'src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc', 'src/core/ext/transport/cronet/transport/cronet_transport.cc', - 'third_party/nanopb/pb_common.c', - 'third_party/nanopb/pb_decode.c', - 'third_party/nanopb/pb_encode.c', 'src/core/ext/transport/cronet/client/secure/cronet_channel_create.h', 'src/core/ext/transport/cronet/transport/cronet_transport.h', - 'third_party/objective_c/Cronet/bidirectional_stream_c.h', - 'third_party/nanopb/pb.h', - 'third_party/nanopb/pb_common.h', - 'third_party/nanopb/pb_decode.h', - 'third_party/nanopb/pb_encode.h' + 'third_party/objective_c/Cronet/bidirectional_stream_c.h' end s.subspec 'Tests' do |ss| diff --git a/grpc.gemspec b/grpc.gemspec index 2c658f48d80..c817006b125 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -265,19 +265,11 @@ Gem::Specification.new do |s| s.files += %w( src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h ) s.files += %w( src/core/lib/security/credentials/alts/check_gcp_environment.h ) s.files += %w( src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h ) - s.files += %w( src/core/tsi/alts/handshaker/alts_handshaker_service_api.h ) - s.files += %w( src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h ) s.files += %w( src/core/tsi/alts/handshaker/alts_tsi_utils.h ) s.files += %w( src/core/tsi/alts/handshaker/transport_security_common_api.h ) - s.files += %w( src/core/tsi/alts/handshaker/altscontext.pb.h ) - s.files += %w( src/core/tsi/alts/handshaker/handshaker.pb.h ) - s.files += %w( src/core/tsi/alts/handshaker/transport_security_common.pb.h ) - s.files += %w( third_party/nanopb/pb.h ) - s.files += %w( third_party/nanopb/pb_common.h ) - s.files += %w( third_party/nanopb/pb_decode.h ) - s.files += %w( third_party/nanopb/pb_encode.h ) - s.files += %w( src/core/tsi/transport_security.h ) - s.files += %w( src/core/tsi/transport_security_interface.h ) + s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h ) + s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h ) + s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h ) s.files += %w( third_party/upb/upb/decode.h ) s.files += %w( third_party/upb/upb/encode.h ) s.files += %w( third_party/upb/upb/generated_util.h ) @@ -286,6 +278,8 @@ Gem::Specification.new do |s| s.files += %w( third_party/upb/upb/port_undef.inc ) s.files += %w( third_party/upb/upb/table.int.h ) s.files += %w( third_party/upb/upb/upb.h ) + s.files += %w( src/core/tsi/transport_security.h ) + s.files += %w( src/core/tsi/transport_security_interface.h ) s.files += %w( src/core/ext/transport/chttp2/client/authority.h ) s.files += %w( src/core/ext/transport/chttp2/client/chttp2_connector.h ) s.files += %w( src/core/ext/filters/client_channel/backup_poller.h ) @@ -767,23 +761,18 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc ) s.files += %w( src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc ) s.files += %w( src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc ) - s.files += %w( src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc ) - s.files += %w( src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc ) s.files += %w( src/core/tsi/alts/handshaker/alts_tsi_utils.cc ) s.files += %w( src/core/tsi/alts/handshaker/transport_security_common_api.cc ) - s.files += %w( src/core/tsi/alts/handshaker/altscontext.pb.c ) - s.files += %w( src/core/tsi/alts/handshaker/handshaker.pb.c ) - s.files += %w( src/core/tsi/alts/handshaker/transport_security_common.pb.c ) - s.files += %w( third_party/nanopb/pb_common.c ) - s.files += %w( third_party/nanopb/pb_decode.c ) - s.files += %w( third_party/nanopb/pb_encode.c ) - s.files += %w( src/core/tsi/transport_security.cc ) + s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c ) + s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c ) + s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c ) s.files += %w( third_party/upb/upb/decode.c ) s.files += %w( third_party/upb/upb/encode.c ) s.files += %w( third_party/upb/upb/msg.c ) s.files += %w( third_party/upb/upb/port.c ) s.files += %w( third_party/upb/upb/table.c ) s.files += %w( third_party/upb/upb/upb.c ) + s.files += %w( src/core/tsi/transport_security.cc ) s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create.cc ) s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc ) s.files += %w( src/core/ext/transport/chttp2/client/authority.cc ) diff --git a/grpc.gyp b/grpc.gyp index 5241a57007a..173aef52a79 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -544,23 +544,18 @@ 'src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc', 'src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc', 'src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc', - 'src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc', - 'src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc', 'src/core/tsi/alts/handshaker/alts_tsi_utils.cc', 'src/core/tsi/alts/handshaker/transport_security_common_api.cc', - 'src/core/tsi/alts/handshaker/altscontext.pb.c', - 'src/core/tsi/alts/handshaker/handshaker.pb.c', - 'src/core/tsi/alts/handshaker/transport_security_common.pb.c', - 'third_party/nanopb/pb_common.c', - 'third_party/nanopb/pb_decode.c', - 'third_party/nanopb/pb_encode.c', - 'src/core/tsi/transport_security.cc', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c', 'third_party/upb/upb/decode.c', 'third_party/upb/upb/encode.c', 'third_party/upb/upb/msg.c', 'third_party/upb/upb/port.c', 'third_party/upb/upb/table.c', 'third_party/upb/upb/upb.c', + 'src/core/tsi/transport_security.cc', 'src/core/ext/transport/chttp2/client/insecure/channel_create.cc', 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc', 'src/core/ext/transport/chttp2/client/authority.cc', diff --git a/package.xml b/package.xml index 1e1bc3d4176..979bc465a75 100644 --- a/package.xml +++ b/package.xml @@ -270,19 +270,11 @@ - - - - - - - - - - - + + + @@ -291,6 +283,8 @@ + + @@ -772,23 +766,18 @@ - - - - - - - - - + + + + diff --git a/src/core/tsi/alts/handshaker/alts_handshaker_client.cc b/src/core/tsi/alts/handshaker/alts_handshaker_client.cc index 464de9e00d0..55fd066dba5 100644 --- a/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +++ b/src/core/tsi/alts/handshaker/alts_handshaker_client.cc @@ -27,7 +27,6 @@ #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/call.h" #include "src/core/lib/surface/channel.h" -#include "src/core/tsi/alts/handshaker/alts_handshaker_service_api.h" #include "src/core/tsi/alts/handshaker/alts_shared_resource.h" #include "src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h" #include "src/core/tsi/alts/handshaker/alts_tsi_utils.h" @@ -91,9 +90,9 @@ static void handshaker_client_send_buffer_destroy( client->send_buffer = nullptr; } -static bool is_handshake_finished_properly(grpc_gcp_handshaker_resp* resp) { +static bool is_handshake_finished_properly(grpc_gcp_HandshakerResp* resp) { GPR_ASSERT(resp != nullptr); - if (resp->has_result) { + if (grpc_gcp_HandshakerResp_result(resp)) { return true; } return false; @@ -140,8 +139,9 @@ void alts_handshaker_client_handle_response(alts_handshaker_client* c, cb(TSI_INTERNAL_ERROR, user_data, nullptr, 0, nullptr); return; } - grpc_gcp_handshaker_resp* resp = - alts_tsi_utils_deserialize_response(recv_buffer); + upb::Arena arena; + grpc_gcp_HandshakerResp* resp = + alts_tsi_utils_deserialize_response(recv_buffer, arena.ptr()); grpc_byte_buffer_destroy(client->recv_buffer); client->recv_buffer = nullptr; /* Invalid handshaker response check. */ @@ -150,35 +150,44 @@ void alts_handshaker_client_handle_response(alts_handshaker_client* c, cb(TSI_DATA_CORRUPTED, user_data, nullptr, 0, nullptr); return; } - grpc_slice* slice = static_cast(resp->out_frames.arg); + const grpc_gcp_HandshakerStatus* resp_status = + grpc_gcp_HandshakerResp_status(resp); + if (resp_status == nullptr) { + gpr_log(GPR_ERROR, "No status in HandshakerResp"); + cb(TSI_DATA_CORRUPTED, user_data, nullptr, 0, nullptr); + return; + } + upb_strview out_frames = grpc_gcp_HandshakerResp_out_frames(resp); unsigned char* bytes_to_send = nullptr; size_t bytes_to_send_size = 0; - if (slice != nullptr) { - bytes_to_send_size = GRPC_SLICE_LENGTH(*slice); + if (out_frames.size > 0) { + bytes_to_send_size = out_frames.size; while (bytes_to_send_size > client->buffer_size) { client->buffer_size *= 2; client->buffer = static_cast( gpr_realloc(client->buffer, client->buffer_size)); } - memcpy(client->buffer, GRPC_SLICE_START_PTR(*slice), bytes_to_send_size); + memcpy(client->buffer, out_frames.data, bytes_to_send_size); bytes_to_send = client->buffer; } tsi_handshaker_result* result = nullptr; if (is_handshake_finished_properly(resp)) { alts_tsi_handshaker_result_create(resp, client->is_client, &result); - alts_tsi_handshaker_result_set_unused_bytes(result, &client->recv_bytes, - resp->bytes_consumed); + alts_tsi_handshaker_result_set_unused_bytes( + result, &client->recv_bytes, + grpc_gcp_HandshakerResp_bytes_consumed(resp)); } - grpc_status_code code = static_cast(resp->status.code); + grpc_status_code code = static_cast( + grpc_gcp_HandshakerStatus_code(resp_status)); if (code != GRPC_STATUS_OK) { - grpc_slice* details = static_cast(resp->status.details.arg); - if (details != nullptr) { - char* error_details = grpc_slice_to_c_string(*details); + upb_strview details = grpc_gcp_HandshakerStatus_details(resp_status); + if (details.size > 0) { + char* error_details = (char*)gpr_zalloc(details.size + 1); + memcpy(error_details, details.data, details.size); gpr_log(GPR_ERROR, "Error from handshaker service:%s", error_details); gpr_free(error_details); } } - grpc_gcp_handshaker_resp_destroy(resp); cb(alts_tsi_utils_convert_to_tsi_result(code), user_data, bytes_to_send, bytes_to_send_size, result); } @@ -223,43 +232,59 @@ static tsi_result make_grpc_call(alts_handshaker_client* c, bool is_start) { return TSI_OK; } +/* Serializes a grpc_gcp_HandshakerReq message into a buffer and returns newly + * grpc_byte_buffer holding it. */ +static grpc_byte_buffer* get_serialized_handshaker_req( + grpc_gcp_HandshakerReq* req, upb_arena* arena) { + size_t buf_length; + char* buf = grpc_gcp_HandshakerReq_serialize(req, arena, &buf_length); + if (buf == nullptr) { + return nullptr; + } + grpc_slice slice = grpc_slice_from_copied_buffer(buf, buf_length); + grpc_byte_buffer* byte_buffer = grpc_raw_byte_buffer_create(&slice, 1); + grpc_slice_unref_internal(slice); + return byte_buffer; +} + /* Create and populate a client_start handshaker request, then serialize it. */ static grpc_byte_buffer* get_serialized_start_client( alts_handshaker_client* c) { GPR_ASSERT(c != nullptr); alts_grpc_handshaker_client* client = reinterpret_cast(c); - bool ok = true; - grpc_gcp_handshaker_req* req = - grpc_gcp_handshaker_req_create(CLIENT_START_REQ); - ok &= grpc_gcp_handshaker_req_set_handshake_protocol( - req, grpc_gcp_HandshakeProtocol_ALTS); - ok &= grpc_gcp_handshaker_req_add_application_protocol( - req, ALTS_APPLICATION_PROTOCOL); - ok &= grpc_gcp_handshaker_req_add_record_protocol(req, ALTS_RECORD_PROTOCOL); - grpc_gcp_rpc_protocol_versions* versions = &client->options->rpc_versions; - ok &= grpc_gcp_handshaker_req_set_rpc_versions( - req, versions->max_rpc_version.major, versions->max_rpc_version.minor, - versions->min_rpc_version.major, versions->min_rpc_version.minor); - char* target_name = grpc_slice_to_c_string(client->target_name); - ok &= grpc_gcp_handshaker_req_set_target_name(req, target_name); + upb::Arena arena; + grpc_gcp_HandshakerReq* req = grpc_gcp_HandshakerReq_new(arena.ptr()); + grpc_gcp_StartClientHandshakeReq* start_client = + grpc_gcp_HandshakerReq_mutable_client_start(req, arena.ptr()); + grpc_gcp_StartClientHandshakeReq_set_handshake_security_protocol( + start_client, grpc_gcp_ALTS); + grpc_gcp_StartClientHandshakeReq_add_application_protocols( + start_client, upb_strview_makez(ALTS_APPLICATION_PROTOCOL), arena.ptr()); + grpc_gcp_StartClientHandshakeReq_add_record_protocols( + start_client, upb_strview_makez(ALTS_RECORD_PROTOCOL), arena.ptr()); + grpc_gcp_RpcProtocolVersions* client_version = + grpc_gcp_StartClientHandshakeReq_mutable_rpc_versions(start_client, + arena.ptr()); + grpc_gcp_RpcProtocolVersions_assign_from_struct( + client_version, arena.ptr(), &client->options->rpc_versions); + grpc_gcp_StartClientHandshakeReq_set_target_name( + start_client, + upb_strview_make(reinterpret_cast( + GRPC_SLICE_START_PTR(client->target_name)), + GRPC_SLICE_LENGTH(client->target_name))); target_service_account* ptr = (reinterpret_cast(client->options)) ->target_account_list_head; while (ptr != nullptr) { - grpc_gcp_handshaker_req_add_target_identity_service_account(req, ptr->data); + grpc_gcp_Identity* target_identity = + grpc_gcp_StartClientHandshakeReq_add_target_identities(start_client, + arena.ptr()); + grpc_gcp_Identity_set_service_account(target_identity, + upb_strview_makez(ptr->data)); ptr = ptr->next; } - grpc_slice slice; - ok &= grpc_gcp_handshaker_req_encode(req, &slice); - grpc_byte_buffer* buffer = nullptr; - if (ok) { - buffer = grpc_raw_byte_buffer_create(&slice, 1 /* number of slices */); - } - grpc_slice_unref_internal(slice); - gpr_free(target_name); - grpc_gcp_handshaker_req_destroy(req); - return buffer; + return get_serialized_handshaker_req(req, arena.ptr()); } static tsi_result handshaker_client_start_client(alts_handshaker_client* c) { @@ -290,28 +315,35 @@ static grpc_byte_buffer* get_serialized_start_server( GPR_ASSERT(bytes_received != nullptr); alts_grpc_handshaker_client* client = reinterpret_cast(c); - grpc_gcp_handshaker_req* req = - grpc_gcp_handshaker_req_create(SERVER_START_REQ); - bool ok = grpc_gcp_handshaker_req_add_application_protocol( - req, ALTS_APPLICATION_PROTOCOL); - ok &= grpc_gcp_handshaker_req_param_add_record_protocol( - req, grpc_gcp_HandshakeProtocol_ALTS, ALTS_RECORD_PROTOCOL); - ok &= grpc_gcp_handshaker_req_set_in_bytes( - req, reinterpret_cast GRPC_SLICE_START_PTR(*bytes_received), - GRPC_SLICE_LENGTH(*bytes_received)); - grpc_gcp_rpc_protocol_versions* versions = &client->options->rpc_versions; - ok &= grpc_gcp_handshaker_req_set_rpc_versions( - req, versions->max_rpc_version.major, versions->max_rpc_version.minor, - versions->min_rpc_version.major, versions->min_rpc_version.minor); - grpc_slice req_slice; - ok &= grpc_gcp_handshaker_req_encode(req, &req_slice); - grpc_byte_buffer* buffer = nullptr; - if (ok) { - buffer = grpc_raw_byte_buffer_create(&req_slice, 1 /* number of slices */); - } - grpc_slice_unref_internal(req_slice); - grpc_gcp_handshaker_req_destroy(req); - return buffer; + + upb::Arena arena; + grpc_gcp_HandshakerReq* req = grpc_gcp_HandshakerReq_new(arena.ptr()); + + grpc_gcp_StartServerHandshakeReq* start_server = + grpc_gcp_HandshakerReq_mutable_server_start(req, arena.ptr()); + grpc_gcp_StartServerHandshakeReq_add_application_protocols( + start_server, upb_strview_makez(ALTS_APPLICATION_PROTOCOL), arena.ptr()); + grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry* param = + grpc_gcp_StartServerHandshakeReq_add_handshake_parameters(start_server, + arena.ptr()); + grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_set_key( + param, grpc_gcp_ALTS); + grpc_gcp_ServerHandshakeParameters* value = + grpc_gcp_ServerHandshakeParameters_new(arena.ptr()); + grpc_gcp_ServerHandshakeParameters_add_record_protocols( + value, upb_strview_makez(ALTS_RECORD_PROTOCOL), arena.ptr()); + grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_set_value(param, + value); + grpc_gcp_StartServerHandshakeReq_set_in_bytes( + start_server, upb_strview_make(reinterpret_cast( + GRPC_SLICE_START_PTR(*bytes_received)), + GRPC_SLICE_LENGTH(*bytes_received))); + grpc_gcp_RpcProtocolVersions* server_version = + grpc_gcp_StartServerHandshakeReq_mutable_rpc_versions(start_server, + arena.ptr()); + grpc_gcp_RpcProtocolVersions_assign_from_struct( + server_version, arena.ptr(), &client->options->rpc_versions); + return get_serialized_handshaker_req(req, arena.ptr()); } static tsi_result handshaker_client_start_server(alts_handshaker_client* c, @@ -339,19 +371,15 @@ static tsi_result handshaker_client_start_server(alts_handshaker_client* c, /* Create and populate a next handshaker request, then serialize it. */ static grpc_byte_buffer* get_serialized_next(grpc_slice* bytes_received) { GPR_ASSERT(bytes_received != nullptr); - grpc_gcp_handshaker_req* req = grpc_gcp_handshaker_req_create(NEXT_REQ); - bool ok = grpc_gcp_handshaker_req_set_in_bytes( - req, reinterpret_cast GRPC_SLICE_START_PTR(*bytes_received), - GRPC_SLICE_LENGTH(*bytes_received)); - grpc_slice req_slice; - ok &= grpc_gcp_handshaker_req_encode(req, &req_slice); - grpc_byte_buffer* buffer = nullptr; - if (ok) { - buffer = grpc_raw_byte_buffer_create(&req_slice, 1 /* number of slices */); - } - grpc_slice_unref_internal(req_slice); - grpc_gcp_handshaker_req_destroy(req); - return buffer; + upb::Arena arena; + grpc_gcp_HandshakerReq* req = grpc_gcp_HandshakerReq_new(arena.ptr()); + grpc_gcp_NextHandshakeMessageReq* next = + grpc_gcp_HandshakerReq_mutable_next(req, arena.ptr()); + grpc_gcp_NextHandshakeMessageReq_set_in_bytes( + next, upb_strview_make(reinterpret_cast GRPC_SLICE_START_PTR( + *bytes_received), + GRPC_SLICE_LENGTH(*bytes_received))); + return get_serialized_handshaker_req(req, arena.ptr()); } static tsi_result handshaker_client_next(alts_handshaker_client* c, diff --git a/src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc b/src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc deleted file mode 100644 index 256e414ae43..00000000000 --- a/src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc +++ /dev/null @@ -1,520 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/tsi/alts/handshaker/alts_handshaker_service_api.h" - -#include -#include - -#include "src/core/tsi/alts/handshaker/transport_security_common_api.h" - -/* HandshakerReq */ -grpc_gcp_handshaker_req* grpc_gcp_handshaker_req_create( - grpc_gcp_handshaker_req_type type) { - grpc_gcp_handshaker_req* req = - static_cast(gpr_zalloc(sizeof(*req))); - switch (type) { - case CLIENT_START_REQ: - req->has_client_start = true; - break; - case SERVER_START_REQ: - req->has_server_start = true; - break; - case NEXT_REQ: - req->has_next = true; - break; - } - return req; -} - -void grpc_gcp_handshaker_req_destroy(grpc_gcp_handshaker_req* req) { - if (req == nullptr) { - return; - } - if (req->has_client_start) { - /* Destroy client_start request. */ - destroy_repeated_field_list_identity( - static_cast(req->client_start.target_identities.arg)); - destroy_repeated_field_list_string(static_cast( - req->client_start.application_protocols.arg)); - destroy_repeated_field_list_string( - static_cast(req->client_start.record_protocols.arg)); - if (req->client_start.has_local_identity) { - destroy_slice(static_cast( - req->client_start.local_identity.hostname.arg)); - destroy_slice(static_cast( - req->client_start.local_identity.service_account.arg)); - } - if (req->client_start.has_local_endpoint) { - destroy_slice(static_cast( - req->client_start.local_endpoint.ip_address.arg)); - } - if (req->client_start.has_remote_endpoint) { - destroy_slice(static_cast( - req->client_start.remote_endpoint.ip_address.arg)); - } - destroy_slice(static_cast(req->client_start.target_name.arg)); - } else if (req->has_server_start) { - /* Destroy server_start request. */ - size_t i = 0; - for (i = 0; i < req->server_start.handshake_parameters_count; i++) { - destroy_repeated_field_list_identity( - static_cast(req->server_start.handshake_parameters[i] - .value.local_identities.arg)); - destroy_repeated_field_list_string( - static_cast(req->server_start.handshake_parameters[i] - .value.record_protocols.arg)); - } - destroy_repeated_field_list_string(static_cast( - req->server_start.application_protocols.arg)); - if (req->server_start.has_local_endpoint) { - destroy_slice(static_cast( - req->server_start.local_endpoint.ip_address.arg)); - } - if (req->server_start.has_remote_endpoint) { - destroy_slice(static_cast( - req->server_start.remote_endpoint.ip_address.arg)); - } - destroy_slice(static_cast(req->server_start.in_bytes.arg)); - } else { - /* Destroy next request. */ - destroy_slice(static_cast(req->next.in_bytes.arg)); - } - gpr_free(req); -} - -bool grpc_gcp_handshaker_req_set_handshake_protocol( - grpc_gcp_handshaker_req* req, - grpc_gcp_handshake_protocol handshake_protocol) { - if (req == nullptr || !req->has_client_start) { - gpr_log(GPR_ERROR, - "Invalid arguments to " - "grpc_gcp_handshaker_req_set_handshake_protocol()."); - return false; - } - req->client_start.has_handshake_security_protocol = true; - req->client_start.handshake_security_protocol = handshake_protocol; - return true; -} - -bool grpc_gcp_handshaker_req_set_target_name(grpc_gcp_handshaker_req* req, - const char* target_name) { - if (req == nullptr || target_name == nullptr || !req->has_client_start) { - gpr_log(GPR_ERROR, - "Invalid arguments to " - "grpc_gcp_handshaker_req_set_target_name()."); - return false; - } - grpc_slice* slice = create_slice(target_name, strlen(target_name)); - req->client_start.target_name.arg = slice; - req->client_start.target_name.funcs.encode = encode_string_or_bytes_cb; - return true; -} - -bool grpc_gcp_handshaker_req_add_application_protocol( - grpc_gcp_handshaker_req* req, const char* application_protocol) { - if (req == nullptr || application_protocol == nullptr || req->has_next) { - gpr_log(GPR_ERROR, - "Invalid arguments to " - "grpc_gcp_handshaker_req_add_application_protocol()."); - return false; - } - grpc_slice* slice = - create_slice(application_protocol, strlen(application_protocol)); - if (req->has_client_start) { - add_repeated_field(reinterpret_cast( - &req->client_start.application_protocols.arg), - slice); - req->client_start.application_protocols.funcs.encode = - encode_repeated_string_cb; - } else { - add_repeated_field(reinterpret_cast( - &req->server_start.application_protocols.arg), - slice); - req->server_start.application_protocols.funcs.encode = - encode_repeated_string_cb; - } - return true; -} - -bool grpc_gcp_handshaker_req_add_record_protocol(grpc_gcp_handshaker_req* req, - const char* record_protocol) { - if (req == nullptr || record_protocol == nullptr || !req->has_client_start) { - gpr_log(GPR_ERROR, - "Invalid arguments to " - "grpc_gcp_handshaker_req_add_record_protocol()."); - return false; - } - grpc_slice* slice = create_slice(record_protocol, strlen(record_protocol)); - add_repeated_field(reinterpret_cast( - &req->client_start.record_protocols.arg), - slice); - req->client_start.record_protocols.funcs.encode = encode_repeated_string_cb; - return true; -} - -static void set_identity_hostname(grpc_gcp_identity* identity, - const char* hostname) { - grpc_slice* slice = create_slice(hostname, strlen(hostname)); - identity->hostname.arg = slice; - identity->hostname.funcs.encode = encode_string_or_bytes_cb; -} - -static void set_identity_service_account(grpc_gcp_identity* identity, - const char* service_account) { - grpc_slice* slice = create_slice(service_account, strlen(service_account)); - identity->service_account.arg = slice; - identity->service_account.funcs.encode = encode_string_or_bytes_cb; -} - -bool grpc_gcp_handshaker_req_add_target_identity_hostname( - grpc_gcp_handshaker_req* req, const char* hostname) { - if (req == nullptr || hostname == nullptr || !req->has_client_start) { - gpr_log(GPR_ERROR, - "Invalid nullptr arguments to " - "grpc_gcp_handshaker_req_add_target_identity_hostname()."); - return false; - } - grpc_gcp_identity* target_identity = - static_cast(gpr_zalloc(sizeof(*target_identity))); - set_identity_hostname(target_identity, hostname); - req->client_start.target_identities.funcs.encode = - encode_repeated_identity_cb; - add_repeated_field(reinterpret_cast( - &req->client_start.target_identities.arg), - target_identity); - return true; -} - -bool grpc_gcp_handshaker_req_add_target_identity_service_account( - grpc_gcp_handshaker_req* req, const char* service_account) { - if (req == nullptr || service_account == nullptr || !req->has_client_start) { - gpr_log(GPR_ERROR, - "Invalid nullptr arguments to " - "grpc_gcp_handshaker_req_add_target_identity_service_account()."); - return false; - } - grpc_gcp_identity* target_identity = - static_cast(gpr_zalloc(sizeof(*target_identity))); - set_identity_service_account(target_identity, service_account); - req->client_start.target_identities.funcs.encode = - encode_repeated_identity_cb; - add_repeated_field(reinterpret_cast( - &req->client_start.target_identities.arg), - target_identity); - return true; -} - -bool grpc_gcp_handshaker_req_set_local_identity_hostname( - grpc_gcp_handshaker_req* req, const char* hostname) { - if (req == nullptr || hostname == nullptr || !req->has_client_start) { - gpr_log(GPR_ERROR, - "Invalid nullptr arguments to " - "grpc_gcp_handshaker_req_set_local_identity_hostname()."); - return false; - } - req->client_start.has_local_identity = true; - set_identity_hostname(&req->client_start.local_identity, hostname); - return true; -} - -bool grpc_gcp_handshaker_req_set_local_identity_service_account( - grpc_gcp_handshaker_req* req, const char* service_account) { - if (req == nullptr || service_account == nullptr || !req->has_client_start) { - gpr_log(GPR_ERROR, - "Invalid nullptr arguments to " - "grpc_gcp_handshaker_req_set_local_identity_service_account()."); - return false; - } - req->client_start.has_local_identity = true; - set_identity_service_account(&req->client_start.local_identity, - service_account); - return true; -} - -static void set_endpoint(grpc_gcp_endpoint* endpoint, const char* ip_address, - size_t port, grpc_gcp_network_protocol protocol) { - grpc_slice* slice = create_slice(ip_address, strlen(ip_address)); - endpoint->ip_address.arg = slice; - endpoint->ip_address.funcs.encode = encode_string_or_bytes_cb; - endpoint->has_port = true; - endpoint->port = static_cast(port); - endpoint->has_protocol = true; - endpoint->protocol = protocol; -} - -bool grpc_gcp_handshaker_req_set_rpc_versions(grpc_gcp_handshaker_req* req, - uint32_t max_major, - uint32_t max_minor, - uint32_t min_major, - uint32_t min_minor) { - if (req == nullptr || req->has_next) { - gpr_log(GPR_ERROR, - "Invalid arguments to " - "grpc_gcp_handshaker_req_set_rpc_versions()."); - return false; - } - if (req->has_client_start) { - req->client_start.has_rpc_versions = true; - grpc_gcp_rpc_protocol_versions_set_max(&req->client_start.rpc_versions, - max_major, max_minor); - grpc_gcp_rpc_protocol_versions_set_min(&req->client_start.rpc_versions, - min_major, min_minor); - } else { - req->server_start.has_rpc_versions = true; - grpc_gcp_rpc_protocol_versions_set_max(&req->server_start.rpc_versions, - max_major, max_minor); - grpc_gcp_rpc_protocol_versions_set_min(&req->server_start.rpc_versions, - min_major, min_minor); - } - return true; -} - -bool grpc_gcp_handshaker_req_set_local_endpoint( - grpc_gcp_handshaker_req* req, const char* ip_address, size_t port, - grpc_gcp_network_protocol protocol) { - if (req == nullptr || ip_address == nullptr || port > 65535 || - req->has_next) { - gpr_log(GPR_ERROR, - "Invalid arguments to " - "grpc_gcp_handshaker_req_set_local_endpoint()."); - return false; - } - if (req->has_client_start) { - req->client_start.has_local_endpoint = true; - set_endpoint(&req->client_start.local_endpoint, ip_address, port, protocol); - } else { - req->server_start.has_local_endpoint = true; - set_endpoint(&req->server_start.local_endpoint, ip_address, port, protocol); - } - return true; -} - -bool grpc_gcp_handshaker_req_set_remote_endpoint( - grpc_gcp_handshaker_req* req, const char* ip_address, size_t port, - grpc_gcp_network_protocol protocol) { - if (req == nullptr || ip_address == nullptr || port > 65535 || - req->has_next) { - gpr_log(GPR_ERROR, - "Invalid arguments to " - "grpc_gcp_handshaker_req_set_remote_endpoint()."); - return false; - } - if (req->has_client_start) { - req->client_start.has_remote_endpoint = true; - set_endpoint(&req->client_start.remote_endpoint, ip_address, port, - protocol); - } else { - req->server_start.has_remote_endpoint = true; - set_endpoint(&req->server_start.remote_endpoint, ip_address, port, - protocol); - } - return true; -} - -bool grpc_gcp_handshaker_req_set_in_bytes(grpc_gcp_handshaker_req* req, - const char* in_bytes, size_t size) { - if (req == nullptr || in_bytes == nullptr || req->has_client_start) { - gpr_log(GPR_ERROR, - "Invalid arguments to " - "grpc_gcp_handshaker_req_set_in_bytes()."); - return false; - } - grpc_slice* slice = create_slice(in_bytes, size); - if (req->has_next) { - req->next.in_bytes.arg = slice; - req->next.in_bytes.funcs.encode = &encode_string_or_bytes_cb; - } else { - req->server_start.in_bytes.arg = slice; - req->server_start.in_bytes.funcs.encode = &encode_string_or_bytes_cb; - } - return true; -} - -static grpc_gcp_server_handshake_parameters* server_start_find_param( - grpc_gcp_handshaker_req* req, int32_t key) { - size_t i = 0; - for (i = 0; i < req->server_start.handshake_parameters_count; i++) { - if (req->server_start.handshake_parameters[i].key == key) { - return &req->server_start.handshake_parameters[i].value; - } - } - req->server_start - .handshake_parameters[req->server_start.handshake_parameters_count] - .has_key = true; - req->server_start - .handshake_parameters[req->server_start.handshake_parameters_count] - .has_value = true; - req->server_start - .handshake_parameters[req->server_start.handshake_parameters_count++] - .key = key; - return &req->server_start - .handshake_parameters - [req->server_start.handshake_parameters_count - 1] - .value; -} - -bool grpc_gcp_handshaker_req_param_add_record_protocol( - grpc_gcp_handshaker_req* req, grpc_gcp_handshake_protocol key, - const char* record_protocol) { - if (req == nullptr || record_protocol == nullptr || !req->has_server_start) { - gpr_log(GPR_ERROR, - "Invalid arguments to " - "grpc_gcp_handshaker_req_param_add_record_protocol()."); - return false; - } - grpc_gcp_server_handshake_parameters* param = - server_start_find_param(req, key); - grpc_slice* slice = create_slice(record_protocol, strlen(record_protocol)); - add_repeated_field( - reinterpret_cast(¶m->record_protocols.arg), slice); - param->record_protocols.funcs.encode = &encode_repeated_string_cb; - return true; -} - -bool grpc_gcp_handshaker_req_param_add_local_identity_hostname( - grpc_gcp_handshaker_req* req, grpc_gcp_handshake_protocol key, - const char* hostname) { - if (req == nullptr || hostname == nullptr || !req->has_server_start) { - gpr_log(GPR_ERROR, - "Invalid arguments to " - "grpc_gcp_handshaker_req_param_add_local_identity_hostname()."); - return false; - } - grpc_gcp_server_handshake_parameters* param = - server_start_find_param(req, key); - grpc_gcp_identity* local_identity = - static_cast(gpr_zalloc(sizeof(*local_identity))); - set_identity_hostname(local_identity, hostname); - add_repeated_field( - reinterpret_cast(¶m->local_identities.arg), - local_identity); - param->local_identities.funcs.encode = &encode_repeated_identity_cb; - return true; -} - -bool grpc_gcp_handshaker_req_param_add_local_identity_service_account( - grpc_gcp_handshaker_req* req, grpc_gcp_handshake_protocol key, - const char* service_account) { - if (req == nullptr || service_account == nullptr || !req->has_server_start) { - gpr_log( - GPR_ERROR, - "Invalid arguments to " - "grpc_gcp_handshaker_req_param_add_local_identity_service_account()."); - return false; - } - grpc_gcp_server_handshake_parameters* param = - server_start_find_param(req, key); - grpc_gcp_identity* local_identity = - static_cast(gpr_zalloc(sizeof(*local_identity))); - set_identity_service_account(local_identity, service_account); - add_repeated_field( - reinterpret_cast(¶m->local_identities.arg), - local_identity); - param->local_identities.funcs.encode = &encode_repeated_identity_cb; - return true; -} - -bool grpc_gcp_handshaker_req_encode(grpc_gcp_handshaker_req* req, - grpc_slice* slice) { - if (req == nullptr || slice == nullptr) { - gpr_log(GPR_ERROR, - "Invalid nullptr arguments to grpc_gcp_handshaker_req_encode()."); - return false; - } - pb_ostream_t size_stream; - memset(&size_stream, 0, sizeof(pb_ostream_t)); - if (!pb_encode(&size_stream, grpc_gcp_HandshakerReq_fields, req)) { - gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&size_stream)); - return false; - } - size_t encoded_length = size_stream.bytes_written; - *slice = grpc_slice_malloc(encoded_length); - pb_ostream_t output_stream = - pb_ostream_from_buffer(GRPC_SLICE_START_PTR(*slice), encoded_length); - if (!pb_encode(&output_stream, grpc_gcp_HandshakerReq_fields, req) != 0) { - gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&output_stream)); - return false; - } - return true; -} - -/* HandshakerResp. */ -grpc_gcp_handshaker_resp* grpc_gcp_handshaker_resp_create(void) { - grpc_gcp_handshaker_resp* resp = - static_cast(gpr_zalloc(sizeof(*resp))); - return resp; -} - -void grpc_gcp_handshaker_resp_destroy(grpc_gcp_handshaker_resp* resp) { - if (resp != nullptr) { - destroy_slice(static_cast(resp->out_frames.arg)); - if (resp->has_status) { - destroy_slice(static_cast(resp->status.details.arg)); - } - if (resp->has_result) { - destroy_slice( - static_cast(resp->result.application_protocol.arg)); - destroy_slice(static_cast(resp->result.record_protocol.arg)); - destroy_slice(static_cast(resp->result.key_data.arg)); - if (resp->result.has_local_identity) { - destroy_slice( - static_cast(resp->result.local_identity.hostname.arg)); - destroy_slice(static_cast( - resp->result.local_identity.service_account.arg)); - } - if (resp->result.has_peer_identity) { - destroy_slice( - static_cast(resp->result.peer_identity.hostname.arg)); - destroy_slice(static_cast( - resp->result.peer_identity.service_account.arg)); - } - } - gpr_free(resp); - } -} - -bool grpc_gcp_handshaker_resp_decode(grpc_slice encoded_handshaker_resp, - grpc_gcp_handshaker_resp* resp) { - if (resp == nullptr) { - gpr_log(GPR_ERROR, - "Invalid nullptr argument to grpc_gcp_handshaker_resp_decode()."); - return false; - } - pb_istream_t stream = - pb_istream_from_buffer(GRPC_SLICE_START_PTR(encoded_handshaker_resp), - GRPC_SLICE_LENGTH(encoded_handshaker_resp)); - resp->out_frames.funcs.decode = decode_string_or_bytes_cb; - resp->status.details.funcs.decode = decode_string_or_bytes_cb; - resp->result.application_protocol.funcs.decode = decode_string_or_bytes_cb; - resp->result.record_protocol.funcs.decode = decode_string_or_bytes_cb; - resp->result.key_data.funcs.decode = decode_string_or_bytes_cb; - resp->result.peer_identity.hostname.funcs.decode = decode_string_or_bytes_cb; - resp->result.peer_identity.service_account.funcs.decode = - decode_string_or_bytes_cb; - resp->result.local_identity.hostname.funcs.decode = decode_string_or_bytes_cb; - resp->result.local_identity.service_account.funcs.decode = - decode_string_or_bytes_cb; - if (!pb_decode(&stream, grpc_gcp_HandshakerResp_fields, resp)) { - gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&stream)); - return false; - } - return true; -} diff --git a/src/core/tsi/alts/handshaker/alts_handshaker_service_api.h b/src/core/tsi/alts/handshaker/alts_handshaker_service_api.h deleted file mode 100644 index 5df56a86fae..00000000000 --- a/src/core/tsi/alts/handshaker/alts_handshaker_service_api.h +++ /dev/null @@ -1,323 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_H -#define GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_H - -#include - -#include "src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h" - -/** - * An implementation of nanopb thin wrapper used to set/get and - * serialize/de-serialize of ALTS handshake requests and responses. - * - * All APIs in the header are thread-compatible. A typical usage of this API at - * the client side is as follows: - * - * ----------------------------------------------------------------------------- - * // Create, populate, and serialize an ALTS client_start handshake request to - * // send to the server. - * grpc_gcp_handshaker_req* req = - * grpc_gcp_handshaker_req_create(CLIENT_START_REQ); - * grpc_gcp_handshaker_req_set_handshake_protocol( - req, grpc_gcp_HandshakeProtocol_ALTS); - * grpc_gcp_handshaker_req_add_application_protocol(req, "grpc"); - * grpc_gcp_handshaker_req_add_record_protocol(req, "ALTSRP_GCM_AES128"); - * grpc_slice client_slice; - * if (!grpc_gcp_handshaker_req_encode(req, &client_slice)) { - * fprintf(stderr, "ALTS handshake request encoding failed."; - * } - * - * // De-serialize a data stream received from the server, and store the result - * // at ALTS handshake response. - * grpc_gcp_handshaker_resp* resp = grpc_gcp_handshaker_resp_create(); - * if (!grpc_gcp_handshaker_resp_decode(server_slice, resp)) { - * fprintf(stderr, "ALTS handshake response decoding failed."); - * } - * // To access a variable-length datatype field (i.e., pb_callback_t), - * // access its "arg" subfield (if it has been set). - * if (resp->out_frames.arg != nullptr) { - * grpc_slice* slice = resp->out_frames.arg; - * } - * // To access a fixed-length datatype field (i.e., not pb_calback_t), - * // access the field directly (if it has been set). - * if (resp->has_status && resp->status->has_code) { - * uint32_t code = resp->status->code; - * } - *------------------------------------------------------------------------------ - */ - -/** - * This method creates an ALTS handshake request. - * - * - type: an enum type value that can be either CLIENT_START_REQ, - * SERVER_START_REQ, or NEXT_REQ to indicate the created instance will be - * client_start, server_start, and next handshake request message - * respectively. - * - * The method returns a pointer to the created instance. - */ -grpc_gcp_handshaker_req* grpc_gcp_handshaker_req_create( - grpc_gcp_handshaker_req_type type); - -/** - * This method sets the value for handshake_security_protocol field of ALTS - * client_start handshake request. - * - * - req: an ALTS handshake request. - * - handshake_protocol: a enum type value representing the handshake security - * protocol. - * - * The method returns true on success and false otherwise. - */ -bool grpc_gcp_handshaker_req_set_handshake_protocol( - grpc_gcp_handshaker_req* req, - grpc_gcp_handshake_protocol handshake_protocol); - -/** - * This method sets the value for target_name field of ALTS client_start - * handshake request. - * - * - req: an ALTS handshake request. - * - target_name: a target name to be set. - * - * The method returns true on success and false otherwise. - */ -bool grpc_gcp_handshaker_req_set_target_name(grpc_gcp_handshaker_req* req, - const char* target_name); - -/** - * This method adds an application protocol supported by the server (or - * client) to ALTS server_start (or client_start) handshake request. - * - * - req: an ALTS handshake request. - * - application_protocol: an application protocol (e.g., grpc) to be added. - * - * The method returns true on success and false otherwise. - */ -bool grpc_gcp_handshaker_req_add_application_protocol( - grpc_gcp_handshaker_req* req, const char* application_protocol); - -/** - * This method adds a record protocol supported by the client to ALTS - * client_start handshake request. - * - * - req: an ALTS handshake request. - * - record_protocol: a record protocol (e.g., ALTSRP_GCM_AES128) to be - * added. - * - * The method returns true on success and false otherwise. - */ -bool grpc_gcp_handshaker_req_add_record_protocol(grpc_gcp_handshaker_req* req, - const char* record_protocol); - -/** - * This method adds a target server identity represented as hostname and - * acceptable by a client to ALTS client_start handshake request. - * - * - req: an ALTS handshake request. - * - hostname: a string representation of hostname at the connection - * endpoint to be added. - * - * The method returns true on success and false otherwise. - */ -bool grpc_gcp_handshaker_req_add_target_identity_hostname( - grpc_gcp_handshaker_req* req, const char* hostname); - -/** - * This method adds a target server identity represented as service account and - * acceptable by a client to ALTS client_start handshake request. - * - * - req: an ALTS handshake request. - * - service_account: a string representation of service account at the - * connection endpoint to be added. - * - * The method returns true on success and false otherwise. - */ -bool grpc_gcp_handshaker_req_add_target_identity_service_account( - grpc_gcp_handshaker_req* req, const char* service_account); - -/** - * This method sets the hostname for local_identity field of ALTS client_start - * handshake request. - * - * - req: an ALTS handshake request. - * - hostname: a string representation of hostname. - * - * The method returns true on success and false otherwise. - */ -bool grpc_gcp_handshaker_req_set_local_identity_hostname( - grpc_gcp_handshaker_req* req, const char* hostname); - -/** - * This method sets the service account for local_identity field of ALTS - * client_start handshake request. - * - * - req: an ALTS handshake request. - * - service_account: a string representation of service account. - * - * The method returns true on success and false otherwise. - */ -bool grpc_gcp_handshaker_req_set_local_identity_service_account( - grpc_gcp_handshaker_req* req, const char* service_account); - -/** - * This method sets the value for local_endpoint field of either ALTS - * client_start or server_start handshake request. - * - * - req: an ALTS handshake request. - * - ip_address: a string representation of ip address associated with the - * local endpoint, that could be either IPv4 or IPv6. - * - port: a port number associated with the local endpoint. - * - protocol: a network protocol (e.g., TCP or UDP) associated with the - * local endpoint. - * - * The method returns true on success and false otherwise. - */ -bool grpc_gcp_handshaker_req_set_local_endpoint( - grpc_gcp_handshaker_req* req, const char* ip_address, size_t port, - grpc_gcp_network_protocol protocol); - -/** - * This method sets the value for remote_endpoint field of either ALTS - * client_start or server_start handshake request. - * - * - req: an ALTS handshake request. - * - ip_address: a string representation of ip address associated with the - * remote endpoint, that could be either IPv4 or IPv6. - * - port: a port number associated with the remote endpoint. - * - protocol: a network protocol (e.g., TCP or UDP) associated with the - * remote endpoint. - * - * The method returns true on success and false otherwise. - */ -bool grpc_gcp_handshaker_req_set_remote_endpoint( - grpc_gcp_handshaker_req* req, const char* ip_address, size_t port, - grpc_gcp_network_protocol protocol); - -/** - * This method sets the value for in_bytes field of either ALTS server_start or - * next handshake request. - * - * - req: an ALTS handshake request. - * - in_bytes: a buffer containing bytes taken from out_frames of the peer's - * ALTS handshake response. It is possible that the peer's out_frames are - * split into multiple handshake request messages. - * - size: size of in_bytes buffer. - * - * The method returns true on success and false otherwise. - */ -bool grpc_gcp_handshaker_req_set_in_bytes(grpc_gcp_handshaker_req* req, - const char* in_bytes, size_t size); - -/** - * This method adds a record protocol to handshake parameters mapped by the - * handshake protocol for ALTS server_start handshake request. - * - * - req: an ALTS handshake request. - * - key: an enum type value representing a handshake security protocol. - * - record_protocol: a record protocol to be added. - * - * The method returns true on success and false otherwise. - */ -bool grpc_gcp_handshaker_req_param_add_record_protocol( - grpc_gcp_handshaker_req* req, grpc_gcp_handshake_protocol key, - const char* record_protocol); - -/** - * This method adds a local identity represented as hostname to handshake - * parameters mapped by the handshake protocol for ALTS server_start handshake - * request. - * - * - req: an ALTS handshake request. - * - key: an enum type value representing a handshake security protocol. - * - hostname: a string representation of hostname to be added. - * - * The method returns true on success and false otherwise. - */ -bool grpc_gcp_handshaker_req_param_add_local_identity_hostname( - grpc_gcp_handshaker_req* req, grpc_gcp_handshake_protocol key, - const char* hostname); - -/** - * This method adds a local identity represented as service account to handshake - * parameters mapped by the handshake protocol for ALTS server_start handshake - * request. - * - * - req: an ALTS handshake request. - * - key: an enum type value representing a handshake security protocol. - * - service_account: a string representation of service account to be added. - * - * The method returns true on success and false otherwise. - */ -bool grpc_gcp_handshaker_req_param_add_local_identity_service_account( - grpc_gcp_handshaker_req* req, grpc_gcp_handshake_protocol key, - const char* service_account); - -/** - * This method sets the value for rpc_versions field of either ALTS - * client_start or server_start handshake request. - * - * - req: an ALTS handshake request. - * - max_major: a major version of maximum supported RPC version. - * - max_minor: a minor version of maximum supported RPC version. - * - min_major: a major version of minimum supported RPC version. - * - min_minor: a minor version of minimum supported RPC version. - * - * The method returns true on success and false otherwise. - */ -bool grpc_gcp_handshaker_req_set_rpc_versions(grpc_gcp_handshaker_req* req, - uint32_t max_major, - uint32_t max_minor, - uint32_t min_major, - uint32_t min_minor); - -/** - * This method serializes an ALTS handshake request and returns a data stream. - * - * - req: an ALTS handshake request. - * - slice: a data stream where the serialized result will be written. - * - * The method returns true on success and false otherwise. - */ -bool grpc_gcp_handshaker_req_encode(grpc_gcp_handshaker_req* req, - grpc_slice* slice); - -/* This method destroys an ALTS handshake request. */ -void grpc_gcp_handshaker_req_destroy(grpc_gcp_handshaker_req* req); - -/* This method creates an ALTS handshake response. */ -grpc_gcp_handshaker_resp* grpc_gcp_handshaker_resp_create(void); - -/** - * This method de-serializes a data stream and stores the result - * in an ALTS handshake response. - * - * - slice: a data stream containing a serialized ALTS handshake response. - * - resp: an ALTS handshake response used to hold de-serialized result. - * - * The method returns true on success and false otherwise. - */ -bool grpc_gcp_handshaker_resp_decode(grpc_slice slice, - grpc_gcp_handshaker_resp* resp); - -/* This method destroys an ALTS handshake response. */ -void grpc_gcp_handshaker_resp_destroy(grpc_gcp_handshaker_resp* resp); - -#endif /* GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_H */ diff --git a/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc b/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc deleted file mode 100644 index d63d3538c56..00000000000 --- a/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc +++ /dev/null @@ -1,145 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h" - -#include "src/core/lib/slice/slice_internal.h" - -void add_repeated_field(repeated_field** head, const void* data) { - repeated_field* field = - static_cast(gpr_zalloc(sizeof(*field))); - field->data = data; - if (*head == nullptr) { - *head = field; - (*head)->next = nullptr; - } else { - field->next = *head; - *head = field; - } -} - -void destroy_repeated_field_list_identity(repeated_field* head) { - repeated_field* field = head; - while (field != nullptr) { - repeated_field* next_field = field->next; - const grpc_gcp_identity* identity = - static_cast(field->data); - destroy_slice(static_cast(identity->hostname.arg)); - destroy_slice(static_cast(identity->service_account.arg)); - gpr_free((void*)identity); - gpr_free(field); - field = next_field; - } -} - -void destroy_repeated_field_list_string(repeated_field* head) { - repeated_field* field = head; - while (field != nullptr) { - repeated_field* next_field = field->next; - destroy_slice((grpc_slice*)field->data); - gpr_free(field); - field = next_field; - } -} - -grpc_slice* create_slice(const char* data, size_t size) { - grpc_slice slice = grpc_slice_from_copied_buffer(data, size); - grpc_slice* cb_slice = - static_cast(gpr_zalloc(sizeof(*cb_slice))); - memcpy(cb_slice, &slice, sizeof(*cb_slice)); - return cb_slice; -} - -void destroy_slice(grpc_slice* slice) { - if (slice != nullptr) { - grpc_slice_unref_internal(*slice); - gpr_free(slice); - } -} - -bool encode_string_or_bytes_cb(pb_ostream_t* stream, const pb_field_t* field, - void* const* arg) { - grpc_slice* slice = static_cast(*arg); - if (!pb_encode_tag_for_field(stream, field)) return false; - return pb_encode_string(stream, GRPC_SLICE_START_PTR(*slice), - GRPC_SLICE_LENGTH(*slice)); -} - -bool encode_repeated_identity_cb(pb_ostream_t* stream, const pb_field_t* field, - void* const* arg) { - repeated_field* var = static_cast(*arg); - while (var != nullptr) { - if (!pb_encode_tag_for_field(stream, field)) return false; - if (!pb_encode_submessage(stream, grpc_gcp_Identity_fields, - (grpc_gcp_identity*)var->data)) - return false; - var = var->next; - } - return true; -} - -bool encode_repeated_string_cb(pb_ostream_t* stream, const pb_field_t* field, - void* const* arg) { - repeated_field* var = static_cast(*arg); - while (var != nullptr) { - if (!pb_encode_tag_for_field(stream, field)) return false; - const grpc_slice* slice = static_cast(var->data); - if (!pb_encode_string(stream, GRPC_SLICE_START_PTR(*slice), - GRPC_SLICE_LENGTH(*slice))) - return false; - var = var->next; - } - return true; -} - -bool decode_string_or_bytes_cb(pb_istream_t* stream, const pb_field_t* field, - void** arg) { - grpc_slice slice = grpc_slice_malloc(stream->bytes_left); - grpc_slice* cb_slice = - static_cast(gpr_zalloc(sizeof(*cb_slice))); - memcpy(cb_slice, &slice, sizeof(*cb_slice)); - if (!pb_read(stream, GRPC_SLICE_START_PTR(*cb_slice), stream->bytes_left)) - return false; - *arg = cb_slice; - return true; -} - -bool decode_repeated_identity_cb(pb_istream_t* stream, const pb_field_t* field, - void** arg) { - grpc_gcp_identity* identity = - static_cast(gpr_zalloc(sizeof(*identity))); - identity->hostname.funcs.decode = decode_string_or_bytes_cb; - identity->service_account.funcs.decode = decode_string_or_bytes_cb; - add_repeated_field(reinterpret_cast(arg), identity); - if (!pb_decode(stream, grpc_gcp_Identity_fields, identity)) return false; - return true; -} - -bool decode_repeated_string_cb(pb_istream_t* stream, const pb_field_t* field, - void** arg) { - grpc_slice slice = grpc_slice_malloc(stream->bytes_left); - grpc_slice* cb_slice = - static_cast(gpr_zalloc(sizeof(*cb_slice))); - memcpy(cb_slice, &slice, sizeof(grpc_slice)); - if (!pb_read(stream, GRPC_SLICE_START_PTR(*cb_slice), stream->bytes_left)) - return false; - add_repeated_field(reinterpret_cast(arg), cb_slice); - return true; -} diff --git a/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h b/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h deleted file mode 100644 index 966ea45617e..00000000000 --- a/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_UTIL_H -#define GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_UTIL_H - -#include - -#include "pb_decode.h" -#include "pb_encode.h" - -#include -#include -#include -#include - -#include "src/core/tsi/alts/handshaker/handshaker.pb.h" - -/** - * An implementation of utility functions used to serialize/ - * de-serialize ALTS handshake requests/responses. All APIs in the header - * are thread-compatible. - */ - -/* Renaming of message/field structs generated by nanopb compiler. */ -typedef grpc_gcp_HandshakeProtocol grpc_gcp_handshake_protocol; -typedef grpc_gcp_NetworkProtocol grpc_gcp_network_protocol; -typedef grpc_gcp_Identity grpc_gcp_identity; -typedef grpc_gcp_NextHandshakeMessageReq grpc_gcp_next_handshake_message_req; -typedef grpc_gcp_ServerHandshakeParameters grpc_gcp_server_handshake_parameters; -typedef grpc_gcp_Endpoint grpc_gcp_endpoint; -typedef grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry - grpc_gcp_handshake_parameters_entry; -typedef grpc_gcp_StartClientHandshakeReq grpc_gcp_start_client_handshake_req; -typedef grpc_gcp_StartServerHandshakeReq grpc_gcp_start_server_handshake_req; -typedef grpc_gcp_HandshakerReq grpc_gcp_handshaker_req; -typedef grpc_gcp_HandshakerResult grpc_gcp_handshaker_result; -typedef grpc_gcp_HandshakerStatus grpc_gcp_handshaker_status; -typedef grpc_gcp_HandshakerResp grpc_gcp_handshaker_resp; - -typedef enum { - CLIENT_START_REQ = 0, /* StartClientHandshakeReq. */ - SERVER_START_REQ = 1, /* StartServerHandshakeReq. */ - NEXT_REQ = 2, /* NextHandshakeMessageReq. */ -} grpc_gcp_handshaker_req_type; - -/** - * A struct representing a repeated field. The struct is used to organize all - * instances of a specific repeated field into a linked list, which then will - * be used at encode/decode phase. For instance at the encode phase, the encode - * function will iterate through the list, encode each field, and then output - * the result to the stream. - */ -typedef struct repeated_field_ { - struct repeated_field_* next; - const void* data; -} repeated_field; - -/** - * This method adds a repeated field to the head of repeated field list. - * - * - head: a head of repeated field list. - * - field: a repeated field to be added to the list. - */ -void add_repeated_field(repeated_field** head, const void* field); - -/** - * This method destroys a repeated field list that consists of string type - * fields. - * - * - head: a head of repeated field list. - */ -void destroy_repeated_field_list_string(repeated_field* head); - -/** - * This method destroys a repeated field list that consists of - * grpc_gcp_identity type fields. - * - * - head: a head of repeated field list. - */ -void destroy_repeated_field_list_identity(repeated_field* head); - -/** - * This method creates a grpc_slice instance by copying a data buffer. It is - * similar to grpc_slice_from_copied_buffer() except that it returns an instance - * allocated from the heap. - * - * - data: a data buffer to be copied to grpc_slice instance. - * - size: size of data buffer. - */ -grpc_slice* create_slice(const char* data, size_t size); - -/* This method destroys a grpc_slice instance. */ -void destroy_slice(grpc_slice* slice); - -/** - * The following encode/decode functions will be assigned to encode/decode - * function pointers of pb_callback_t struct (defined in - * //third_party/nanopb/pb.h), that represent a repeated field with a dynamic - * length (e.g., a string type or repeated field). - */ - -/* This method is an encode callback function for a string or byte array. */ -bool encode_string_or_bytes_cb(pb_ostream_t* stream, const pb_field_t* field, - void* const* arg); - -/** - * This method is an encode callback function for a repeated grpc_gcp_identity - * field. - */ -bool encode_repeated_identity_cb(pb_ostream_t* stream, const pb_field_t* field, - void* const* arg); - -/* This method is an encode callback function for a repeated string field. */ -bool encode_repeated_string_cb(pb_ostream_t* stream, const pb_field_t* field, - void* const* arg); - -/** - * This method is a decode callback function for a string or byte array field. - */ -bool decode_string_or_bytes_cb(pb_istream_t* stream, const pb_field_t* field, - void** arg); -/** - * This method is a decode callback function for a repeated grpc_gcp_identity - * field. - */ -bool decode_repeated_identity_cb(pb_istream_t* stream, const pb_field_t* field, - void** arg); - -/* This method is a decode callback function for a repeated string field. */ -bool decode_repeated_string_cb(pb_istream_t* stream, const pb_field_t* field, - void** arg); - -#endif /* GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_UTIL_H */ diff --git a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc index 0d28303e7dd..917d375fd82 100644 --- a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +++ b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc @@ -192,38 +192,49 @@ static const tsi_handshaker_result_vtable result_vtable = { handshaker_result_create_frame_protector, handshaker_result_get_unused_bytes, handshaker_result_destroy}; -tsi_result alts_tsi_handshaker_result_create(grpc_gcp_handshaker_resp* resp, +tsi_result alts_tsi_handshaker_result_create(grpc_gcp_HandshakerResp* resp, bool is_client, tsi_handshaker_result** self) { if (self == nullptr || resp == nullptr) { gpr_log(GPR_ERROR, "Invalid arguments to create_handshaker_result()"); return TSI_INVALID_ARGUMENT; } - grpc_slice* key = static_cast(resp->result.key_data.arg); - GPR_ASSERT(key != nullptr); - grpc_slice* identity = - static_cast(resp->result.peer_identity.service_account.arg); + const grpc_gcp_HandshakerResult* hresult = + grpc_gcp_HandshakerResp_result(resp); + const grpc_gcp_Identity* identity = + grpc_gcp_HandshakerResult_peer_identity(hresult); if (identity == nullptr) { + gpr_log(GPR_ERROR, "Invalid identity"); + return TSI_FAILED_PRECONDITION; + } + upb_strview service_account = grpc_gcp_Identity_service_account(identity); + if (service_account.size == 0) { gpr_log(GPR_ERROR, "Invalid service account"); return TSI_FAILED_PRECONDITION; } - if (GRPC_SLICE_LENGTH(*key) < kAltsAes128GcmRekeyKeyLength) { + upb_strview key_data = grpc_gcp_HandshakerResult_key_data(hresult); + if (key_data.size < kAltsAes128GcmRekeyKeyLength) { gpr_log(GPR_ERROR, "Bad key length"); return TSI_FAILED_PRECONDITION; } + const grpc_gcp_RpcProtocolVersions* peer_rpc_version = + grpc_gcp_HandshakerResult_peer_rpc_versions(hresult); + if (peer_rpc_version == nullptr) { + gpr_log(GPR_ERROR, "Peer does not set RPC protocol versions."); + return TSI_FAILED_PRECONDITION; + } alts_tsi_handshaker_result* result = static_cast(gpr_zalloc(sizeof(*result))); result->key_data = static_cast(gpr_zalloc(kAltsAes128GcmRekeyKeyLength)); - memcpy(result->key_data, GRPC_SLICE_START_PTR(*key), - kAltsAes128GcmRekeyKeyLength); - result->peer_identity = grpc_slice_to_c_string(*identity); - if (!resp->result.has_peer_rpc_versions) { - gpr_log(GPR_ERROR, "Peer does not set RPC protocol versions."); - return TSI_FAILED_PRECONDITION; - } - if (!grpc_gcp_rpc_protocol_versions_encode(&resp->result.peer_rpc_versions, - &result->rpc_versions)) { + memcpy(result->key_data, key_data.data, kAltsAes128GcmRekeyKeyLength); + result->peer_identity = + static_cast(gpr_zalloc(service_account.size + 1)); + memcpy(result->peer_identity, service_account.data, service_account.size); + upb::Arena arena; + bool serialized = grpc_gcp_rpc_protocol_versions_encode( + peer_rpc_version, arena.ptr(), &result->rpc_versions); + if (!serialized) { gpr_log(GPR_ERROR, "Failed to serialize peer's RPC protocol versions."); return TSI_FAILED_PRECONDITION; } diff --git a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h index 32f94bc9d3f..6be45d7b447 100644 --- a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +++ b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h @@ -26,9 +26,9 @@ #include "src/core/lib/iomgr/pollset_set.h" #include "src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h" #include "src/core/tsi/alts/handshaker/alts_handshaker_client.h" -#include "src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h" #include "src/core/tsi/transport_security.h" #include "src/core/tsi/transport_security_interface.h" +#include "src/proto/grpc/gcp/handshaker.upb.h" #define TSI_ALTS_SERVICE_ACCOUNT_PEER_PROPERTY "service_accont" #define TSI_ALTS_CERTIFICATE_TYPE "ALTS" @@ -70,7 +70,7 @@ tsi_result alts_tsi_handshaker_create( * client or not. * - result: address of ALTS TSI handshaker result instance. */ -tsi_result alts_tsi_handshaker_result_create(grpc_gcp_handshaker_resp* resp, +tsi_result alts_tsi_handshaker_result_create(grpc_gcp_HandshakerResp* resp, bool is_client, tsi_handshaker_result** result); diff --git a/src/core/tsi/alts/handshaker/alts_tsi_utils.cc b/src/core/tsi/alts/handshaker/alts_tsi_utils.cc index 1747f1ad04f..f80498db990 100644 --- a/src/core/tsi/alts/handshaker/alts_tsi_utils.cc +++ b/src/core/tsi/alts/handshaker/alts_tsi_utils.cc @@ -41,18 +41,22 @@ tsi_result alts_tsi_utils_convert_to_tsi_result(grpc_status_code code) { } } -grpc_gcp_handshaker_resp* alts_tsi_utils_deserialize_response( - grpc_byte_buffer* resp_buffer) { +grpc_gcp_HandshakerResp* alts_tsi_utils_deserialize_response( + grpc_byte_buffer* resp_buffer, upb_arena* arena) { GPR_ASSERT(resp_buffer != nullptr); + GPR_ASSERT(arena != nullptr); grpc_byte_buffer_reader bbr; grpc_byte_buffer_reader_init(&bbr, resp_buffer); grpc_slice slice = grpc_byte_buffer_reader_readall(&bbr); - grpc_gcp_handshaker_resp* resp = grpc_gcp_handshaker_resp_create(); - bool ok = grpc_gcp_handshaker_resp_decode(slice, resp); + size_t buf_size = GPR_SLICE_LENGTH(slice); + void* buf = upb_arena_malloc(arena, buf_size); + memcpy(buf, reinterpret_cast(GPR_SLICE_START_PTR(slice)), + buf_size); + grpc_gcp_HandshakerResp* resp = grpc_gcp_HandshakerResp_parse( + reinterpret_cast(buf), buf_size, arena); grpc_slice_unref_internal(slice); grpc_byte_buffer_reader_destroy(&bbr); - if (!ok) { - grpc_gcp_handshaker_resp_destroy(resp); + if (resp == nullptr) { gpr_log(GPR_ERROR, "grpc_gcp_handshaker_resp_decode() failed"); return nullptr; } diff --git a/src/core/tsi/alts/handshaker/alts_tsi_utils.h b/src/core/tsi/alts/handshaker/alts_tsi_utils.h index 9ef649de2b9..a20e5e9cd99 100644 --- a/src/core/tsi/alts/handshaker/alts_tsi_utils.h +++ b/src/core/tsi/alts/handshaker/alts_tsi_utils.h @@ -24,8 +24,8 @@ #include #include -#include "src/core/tsi/alts/handshaker/alts_handshaker_service_api.h" #include "src/core/tsi/transport_security_interface.h" +#include "src/proto/grpc/gcp/handshaker.upb.h" /** * This method converts grpc_status_code code to the corresponding tsi_result @@ -42,11 +42,12 @@ tsi_result alts_tsi_utils_convert_to_tsi_result(grpc_status_code code); * service. * * - bytes_received: data returned from ALTS handshaker service. + * - arena: upb arena. * * It returns a deserialized handshaker response on success and nullptr on * failure. */ -grpc_gcp_handshaker_resp* alts_tsi_utils_deserialize_response( - grpc_byte_buffer* resp_buffer); +grpc_gcp_HandshakerResp* alts_tsi_utils_deserialize_response( + grpc_byte_buffer* resp_buffer, upb_arena* arena); #endif /* GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_TSI_UTILS_H */ diff --git a/src/core/tsi/alts/handshaker/altscontext.pb.c b/src/core/tsi/alts/handshaker/altscontext.pb.c deleted file mode 100644 index 5fb152a558e..00000000000 --- a/src/core/tsi/alts/handshaker/altscontext.pb.c +++ /dev/null @@ -1,47 +0,0 @@ -/* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.7-dev */ - -#include "src/core/tsi/alts/handshaker/altscontext.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 -#error Regenerate this file with the current version of nanopb generator. -#endif - - - -const pb_field_t grpc_gcp_AltsContext_fields[7] = { - PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, grpc_gcp_AltsContext, application_protocol, application_protocol, 0), - PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, grpc_gcp_AltsContext, record_protocol, application_protocol, 0), - PB_FIELD( 3, UENUM , OPTIONAL, STATIC , OTHER, grpc_gcp_AltsContext, security_level, record_protocol, 0), - PB_FIELD( 4, STRING , OPTIONAL, CALLBACK, OTHER, grpc_gcp_AltsContext, peer_service_account, security_level, 0), - PB_FIELD( 5, STRING , OPTIONAL, CALLBACK, OTHER, grpc_gcp_AltsContext, local_service_account, peer_service_account, 0), - PB_FIELD( 6, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_AltsContext, peer_rpc_versions, local_service_account, &grpc_gcp_RpcProtocolVersions_fields), - PB_LAST_FIELD -}; - - -/* Check that field information fits in pb_field_t */ -#if !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_32BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in 8 or 16 bit - * field descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(grpc_gcp_AltsContext, peer_rpc_versions) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_grpc_gcp_AltsContext) -#endif - -#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_16BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in the default - * 8 bit descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(grpc_gcp_AltsContext, peer_rpc_versions) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_grpc_gcp_AltsContext) -#endif - - -/* @@protoc_insertion_point(eof) */ diff --git a/src/core/tsi/alts/handshaker/altscontext.pb.h b/src/core/tsi/alts/handshaker/altscontext.pb.h deleted file mode 100644 index 632b20c0e2a..00000000000 --- a/src/core/tsi/alts/handshaker/altscontext.pb.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.7-dev */ - -#ifndef PB_GRPC_GCP_ALTSCONTEXT_PB_H_INCLUDED -#define PB_GRPC_GCP_ALTSCONTEXT_PB_H_INCLUDED -#include "pb.h" -#include "src/core/tsi/alts/handshaker/transport_security_common.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 -#error Regenerate this file with the current version of nanopb generator. -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Struct definitions */ -typedef struct _grpc_gcp_AltsContext { - pb_callback_t application_protocol; - pb_callback_t record_protocol; - bool has_security_level; - grpc_gcp_SecurityLevel security_level; - pb_callback_t peer_service_account; - pb_callback_t local_service_account; - bool has_peer_rpc_versions; - grpc_gcp_RpcProtocolVersions peer_rpc_versions; -/* @@protoc_insertion_point(struct:grpc_gcp_AltsContext) */ -} grpc_gcp_AltsContext; - -/* Default values for struct fields */ - -/* Initializer values for message structs */ -#define grpc_gcp_AltsContext_init_default {{{NULL}, NULL}, {{NULL}, NULL}, false, (grpc_gcp_SecurityLevel)0, {{NULL}, NULL}, {{NULL}, NULL}, false, grpc_gcp_RpcProtocolVersions_init_default} -#define grpc_gcp_AltsContext_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, false, (grpc_gcp_SecurityLevel)0, {{NULL}, NULL}, {{NULL}, NULL}, false, grpc_gcp_RpcProtocolVersions_init_zero} - -/* Field tags (for use in manual encoding/decoding) */ -#define grpc_gcp_AltsContext_application_protocol_tag 1 -#define grpc_gcp_AltsContext_record_protocol_tag 2 -#define grpc_gcp_AltsContext_security_level_tag 3 -#define grpc_gcp_AltsContext_peer_service_account_tag 4 -#define grpc_gcp_AltsContext_local_service_account_tag 5 -#define grpc_gcp_AltsContext_peer_rpc_versions_tag 6 - -/* Struct field encoding specification for nanopb */ -extern const pb_field_t grpc_gcp_AltsContext_fields[7]; - -/* Maximum encoded size of messages (where known) */ -/* grpc_gcp_AltsContext_size depends on runtime parameters */ - -/* Message IDs (where set with "msgid" option) */ -#ifdef PB_MSGID - -#define ALTSCONTEXT_MESSAGES \ - - -#endif - -#ifdef __cplusplus -} /* extern "C" */ -#endif -/* @@protoc_insertion_point(eof) */ - -#endif diff --git a/src/core/tsi/alts/handshaker/handshaker.pb.c b/src/core/tsi/alts/handshaker/handshaker.pb.c deleted file mode 100644 index 5450b1602d4..00000000000 --- a/src/core/tsi/alts/handshaker/handshaker.pb.c +++ /dev/null @@ -1,122 +0,0 @@ -/* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.7-dev */ - -#include "src/core/tsi/alts/handshaker/handshaker.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 -#error Regenerate this file with the current version of nanopb generator. -#endif - - - -const pb_field_t grpc_gcp_Endpoint_fields[4] = { - PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, grpc_gcp_Endpoint, ip_address, ip_address, 0), - PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, grpc_gcp_Endpoint, port, ip_address, 0), - PB_FIELD( 3, UENUM , OPTIONAL, STATIC , OTHER, grpc_gcp_Endpoint, protocol, port, 0), - PB_LAST_FIELD -}; - -const pb_field_t grpc_gcp_Identity_fields[3] = { - PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, grpc_gcp_Identity, service_account, service_account, 0), - PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, grpc_gcp_Identity, hostname, service_account, 0), - PB_LAST_FIELD -}; - -const pb_field_t grpc_gcp_StartClientHandshakeReq_fields[10] = { - PB_FIELD( 1, UENUM , OPTIONAL, STATIC , FIRST, grpc_gcp_StartClientHandshakeReq, handshake_security_protocol, handshake_security_protocol, 0), - PB_FIELD( 2, STRING , REPEATED, CALLBACK, OTHER, grpc_gcp_StartClientHandshakeReq, application_protocols, handshake_security_protocol, 0), - PB_FIELD( 3, STRING , REPEATED, CALLBACK, OTHER, grpc_gcp_StartClientHandshakeReq, record_protocols, application_protocols, 0), - PB_FIELD( 4, MESSAGE , REPEATED, CALLBACK, OTHER, grpc_gcp_StartClientHandshakeReq, target_identities, record_protocols, &grpc_gcp_Identity_fields), - PB_FIELD( 5, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_StartClientHandshakeReq, local_identity, target_identities, &grpc_gcp_Identity_fields), - PB_FIELD( 6, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_StartClientHandshakeReq, local_endpoint, local_identity, &grpc_gcp_Endpoint_fields), - PB_FIELD( 7, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_StartClientHandshakeReq, remote_endpoint, local_endpoint, &grpc_gcp_Endpoint_fields), - PB_FIELD( 8, STRING , OPTIONAL, CALLBACK, OTHER, grpc_gcp_StartClientHandshakeReq, target_name, remote_endpoint, 0), - PB_FIELD( 9, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_StartClientHandshakeReq, rpc_versions, target_name, &grpc_gcp_RpcProtocolVersions_fields), - PB_LAST_FIELD -}; - -const pb_field_t grpc_gcp_ServerHandshakeParameters_fields[3] = { - PB_FIELD( 1, STRING , REPEATED, CALLBACK, FIRST, grpc_gcp_ServerHandshakeParameters, record_protocols, record_protocols, 0), - PB_FIELD( 2, MESSAGE , REPEATED, CALLBACK, OTHER, grpc_gcp_ServerHandshakeParameters, local_identities, record_protocols, &grpc_gcp_Identity_fields), - PB_LAST_FIELD -}; - -const pb_field_t grpc_gcp_StartServerHandshakeReq_fields[7] = { - PB_FIELD( 1, STRING , REPEATED, CALLBACK, FIRST, grpc_gcp_StartServerHandshakeReq, application_protocols, application_protocols, 0), - PB_FIELD( 2, MESSAGE , REPEATED, STATIC , OTHER, grpc_gcp_StartServerHandshakeReq, handshake_parameters, application_protocols, &grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_fields), - PB_FIELD( 3, BYTES , OPTIONAL, CALLBACK, OTHER, grpc_gcp_StartServerHandshakeReq, in_bytes, handshake_parameters, 0), - PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_StartServerHandshakeReq, local_endpoint, in_bytes, &grpc_gcp_Endpoint_fields), - PB_FIELD( 5, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_StartServerHandshakeReq, remote_endpoint, local_endpoint, &grpc_gcp_Endpoint_fields), - PB_FIELD( 6, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_StartServerHandshakeReq, rpc_versions, remote_endpoint, &grpc_gcp_RpcProtocolVersions_fields), - PB_LAST_FIELD -}; - -const pb_field_t grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_fields[3] = { - PB_FIELD( 1, INT32 , OPTIONAL, STATIC , FIRST, grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry, key, key, 0), - PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry, value, key, &grpc_gcp_ServerHandshakeParameters_fields), - PB_LAST_FIELD -}; - -const pb_field_t grpc_gcp_NextHandshakeMessageReq_fields[2] = { - PB_FIELD( 1, BYTES , OPTIONAL, CALLBACK, FIRST, grpc_gcp_NextHandshakeMessageReq, in_bytes, in_bytes, 0), - PB_LAST_FIELD -}; - -const pb_field_t grpc_gcp_HandshakerReq_fields[4] = { - PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, grpc_gcp_HandshakerReq, client_start, client_start, &grpc_gcp_StartClientHandshakeReq_fields), - PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_HandshakerReq, server_start, client_start, &grpc_gcp_StartServerHandshakeReq_fields), - PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_HandshakerReq, next, server_start, &grpc_gcp_NextHandshakeMessageReq_fields), - PB_LAST_FIELD -}; - -const pb_field_t grpc_gcp_HandshakerResult_fields[8] = { - PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, grpc_gcp_HandshakerResult, application_protocol, application_protocol, 0), - PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, grpc_gcp_HandshakerResult, record_protocol, application_protocol, 0), - PB_FIELD( 3, BYTES , OPTIONAL, CALLBACK, OTHER, grpc_gcp_HandshakerResult, key_data, record_protocol, 0), - PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_HandshakerResult, peer_identity, key_data, &grpc_gcp_Identity_fields), - PB_FIELD( 5, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_HandshakerResult, local_identity, peer_identity, &grpc_gcp_Identity_fields), - PB_FIELD( 6, BOOL , OPTIONAL, STATIC , OTHER, grpc_gcp_HandshakerResult, keep_channel_open, local_identity, 0), - PB_FIELD( 7, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_HandshakerResult, peer_rpc_versions, keep_channel_open, &grpc_gcp_RpcProtocolVersions_fields), - PB_LAST_FIELD -}; - -const pb_field_t grpc_gcp_HandshakerStatus_fields[3] = { - PB_FIELD( 1, UINT32 , OPTIONAL, STATIC , FIRST, grpc_gcp_HandshakerStatus, code, code, 0), - PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, grpc_gcp_HandshakerStatus, details, code, 0), - PB_LAST_FIELD -}; - -const pb_field_t grpc_gcp_HandshakerResp_fields[5] = { - PB_FIELD( 1, BYTES , OPTIONAL, CALLBACK, FIRST, grpc_gcp_HandshakerResp, out_frames, out_frames, 0), - PB_FIELD( 2, UINT32 , OPTIONAL, STATIC , OTHER, grpc_gcp_HandshakerResp, bytes_consumed, out_frames, 0), - PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_HandshakerResp, result, bytes_consumed, &grpc_gcp_HandshakerResult_fields), - PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_HandshakerResp, status, result, &grpc_gcp_HandshakerStatus_fields), - PB_LAST_FIELD -}; - - -/* Check that field information fits in pb_field_t */ -#if !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_32BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in 8 or 16 bit - * field descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(grpc_gcp_StartClientHandshakeReq, target_identities) < 65536 && pb_membersize(grpc_gcp_StartClientHandshakeReq, local_identity) < 65536 && pb_membersize(grpc_gcp_StartClientHandshakeReq, local_endpoint) < 65536 && pb_membersize(grpc_gcp_StartClientHandshakeReq, remote_endpoint) < 65536 && pb_membersize(grpc_gcp_StartClientHandshakeReq, rpc_versions) < 65536 && pb_membersize(grpc_gcp_ServerHandshakeParameters, local_identities) < 65536 && pb_membersize(grpc_gcp_StartServerHandshakeReq, handshake_parameters[0]) < 65536 && pb_membersize(grpc_gcp_StartServerHandshakeReq, local_endpoint) < 65536 && pb_membersize(grpc_gcp_StartServerHandshakeReq, remote_endpoint) < 65536 && pb_membersize(grpc_gcp_StartServerHandshakeReq, rpc_versions) < 65536 && pb_membersize(grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry, value) < 65536 && pb_membersize(grpc_gcp_HandshakerReq, client_start) < 65536 && pb_membersize(grpc_gcp_HandshakerReq, server_start) < 65536 && pb_membersize(grpc_gcp_HandshakerReq, next) < 65536 && pb_membersize(grpc_gcp_HandshakerResult, peer_identity) < 65536 && pb_membersize(grpc_gcp_HandshakerResult, local_identity) < 65536 && pb_membersize(grpc_gcp_HandshakerResult, peer_rpc_versions) < 65536 && pb_membersize(grpc_gcp_HandshakerResp, result) < 65536 && pb_membersize(grpc_gcp_HandshakerResp, status) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_grpc_gcp_Endpoint_grpc_gcp_Identity_grpc_gcp_StartClientHandshakeReq_grpc_gcp_ServerHandshakeParameters_grpc_gcp_StartServerHandshakeReq_grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_grpc_gcp_NextHandshakeMessageReq_grpc_gcp_HandshakerReq_grpc_gcp_HandshakerResult_grpc_gcp_HandshakerStatus_grpc_gcp_HandshakerResp) -#endif - -#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_16BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in the default - * 8 bit descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(grpc_gcp_StartClientHandshakeReq, target_identities) < 256 && pb_membersize(grpc_gcp_StartClientHandshakeReq, local_identity) < 256 && pb_membersize(grpc_gcp_StartClientHandshakeReq, local_endpoint) < 256 && pb_membersize(grpc_gcp_StartClientHandshakeReq, remote_endpoint) < 256 && pb_membersize(grpc_gcp_StartClientHandshakeReq, rpc_versions) < 256 && pb_membersize(grpc_gcp_ServerHandshakeParameters, local_identities) < 256 && pb_membersize(grpc_gcp_StartServerHandshakeReq, handshake_parameters[0]) < 256 && pb_membersize(grpc_gcp_StartServerHandshakeReq, local_endpoint) < 256 && pb_membersize(grpc_gcp_StartServerHandshakeReq, remote_endpoint) < 256 && pb_membersize(grpc_gcp_StartServerHandshakeReq, rpc_versions) < 256 && pb_membersize(grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry, value) < 256 && pb_membersize(grpc_gcp_HandshakerReq, client_start) < 256 && pb_membersize(grpc_gcp_HandshakerReq, server_start) < 256 && pb_membersize(grpc_gcp_HandshakerReq, next) < 256 && pb_membersize(grpc_gcp_HandshakerResult, peer_identity) < 256 && pb_membersize(grpc_gcp_HandshakerResult, local_identity) < 256 && pb_membersize(grpc_gcp_HandshakerResult, peer_rpc_versions) < 256 && pb_membersize(grpc_gcp_HandshakerResp, result) < 256 && pb_membersize(grpc_gcp_HandshakerResp, status) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_grpc_gcp_Endpoint_grpc_gcp_Identity_grpc_gcp_StartClientHandshakeReq_grpc_gcp_ServerHandshakeParameters_grpc_gcp_StartServerHandshakeReq_grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_grpc_gcp_NextHandshakeMessageReq_grpc_gcp_HandshakerReq_grpc_gcp_HandshakerResult_grpc_gcp_HandshakerStatus_grpc_gcp_HandshakerResp) -#endif - - -/* @@protoc_insertion_point(eof) */ diff --git a/src/core/tsi/alts/handshaker/handshaker.pb.h b/src/core/tsi/alts/handshaker/handshaker.pb.h deleted file mode 100644 index 5ee42a3c69f..00000000000 --- a/src/core/tsi/alts/handshaker/handshaker.pb.h +++ /dev/null @@ -1,254 +0,0 @@ -/* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.7-dev */ - -#ifndef PB_GRPC_GCP_HANDSHAKER_PB_H_INCLUDED -#define PB_GRPC_GCP_HANDSHAKER_PB_H_INCLUDED -#include "pb.h" -#include "src/core/tsi/alts/handshaker/transport_security_common.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 -#error Regenerate this file with the current version of nanopb generator. -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Enum definitions */ -typedef enum _grpc_gcp_HandshakeProtocol { - grpc_gcp_HandshakeProtocol_HANDSHAKE_PROTOCOL_UNSPECIFIED = 0, - grpc_gcp_HandshakeProtocol_TLS = 1, - grpc_gcp_HandshakeProtocol_ALTS = 2 -} grpc_gcp_HandshakeProtocol; -#define _grpc_gcp_HandshakeProtocol_MIN grpc_gcp_HandshakeProtocol_HANDSHAKE_PROTOCOL_UNSPECIFIED -#define _grpc_gcp_HandshakeProtocol_MAX grpc_gcp_HandshakeProtocol_ALTS -#define _grpc_gcp_HandshakeProtocol_ARRAYSIZE ((grpc_gcp_HandshakeProtocol)(grpc_gcp_HandshakeProtocol_ALTS+1)) - -typedef enum _grpc_gcp_NetworkProtocol { - grpc_gcp_NetworkProtocol_NETWORK_PROTOCOL_UNSPECIFIED = 0, - grpc_gcp_NetworkProtocol_TCP = 1, - grpc_gcp_NetworkProtocol_UDP = 2 -} grpc_gcp_NetworkProtocol; -#define _grpc_gcp_NetworkProtocol_MIN grpc_gcp_NetworkProtocol_NETWORK_PROTOCOL_UNSPECIFIED -#define _grpc_gcp_NetworkProtocol_MAX grpc_gcp_NetworkProtocol_UDP -#define _grpc_gcp_NetworkProtocol_ARRAYSIZE ((grpc_gcp_NetworkProtocol)(grpc_gcp_NetworkProtocol_UDP+1)) - -/* Struct definitions */ -typedef struct _grpc_gcp_Identity { - pb_callback_t service_account; - pb_callback_t hostname; -/* @@protoc_insertion_point(struct:grpc_gcp_Identity) */ -} grpc_gcp_Identity; - -typedef struct _grpc_gcp_NextHandshakeMessageReq { - pb_callback_t in_bytes; -/* @@protoc_insertion_point(struct:grpc_gcp_NextHandshakeMessageReq) */ -} grpc_gcp_NextHandshakeMessageReq; - -typedef struct _grpc_gcp_ServerHandshakeParameters { - pb_callback_t record_protocols; - pb_callback_t local_identities; -/* @@protoc_insertion_point(struct:grpc_gcp_ServerHandshakeParameters) */ -} grpc_gcp_ServerHandshakeParameters; - -typedef struct _grpc_gcp_Endpoint { - pb_callback_t ip_address; - bool has_port; - int32_t port; - bool has_protocol; - grpc_gcp_NetworkProtocol protocol; -/* @@protoc_insertion_point(struct:grpc_gcp_Endpoint) */ -} grpc_gcp_Endpoint; - -typedef struct _grpc_gcp_HandshakerResult { - pb_callback_t application_protocol; - pb_callback_t record_protocol; - pb_callback_t key_data; - bool has_peer_identity; - grpc_gcp_Identity peer_identity; - bool has_local_identity; - grpc_gcp_Identity local_identity; - bool has_keep_channel_open; - bool keep_channel_open; - bool has_peer_rpc_versions; - grpc_gcp_RpcProtocolVersions peer_rpc_versions; -/* @@protoc_insertion_point(struct:grpc_gcp_HandshakerResult) */ -} grpc_gcp_HandshakerResult; - -typedef struct _grpc_gcp_HandshakerStatus { - bool has_code; - uint32_t code; - pb_callback_t details; -/* @@protoc_insertion_point(struct:grpc_gcp_HandshakerStatus) */ -} grpc_gcp_HandshakerStatus; - -typedef struct _grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry { - bool has_key; - int32_t key; - bool has_value; - grpc_gcp_ServerHandshakeParameters value; -/* @@protoc_insertion_point(struct:grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry) */ -} grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry; - -typedef struct _grpc_gcp_HandshakerResp { - pb_callback_t out_frames; - bool has_bytes_consumed; - uint32_t bytes_consumed; - bool has_result; - grpc_gcp_HandshakerResult result; - bool has_status; - grpc_gcp_HandshakerStatus status; -/* @@protoc_insertion_point(struct:grpc_gcp_HandshakerResp) */ -} grpc_gcp_HandshakerResp; - -typedef struct _grpc_gcp_StartClientHandshakeReq { - bool has_handshake_security_protocol; - grpc_gcp_HandshakeProtocol handshake_security_protocol; - pb_callback_t application_protocols; - pb_callback_t record_protocols; - pb_callback_t target_identities; - bool has_local_identity; - grpc_gcp_Identity local_identity; - bool has_local_endpoint; - grpc_gcp_Endpoint local_endpoint; - bool has_remote_endpoint; - grpc_gcp_Endpoint remote_endpoint; - pb_callback_t target_name; - bool has_rpc_versions; - grpc_gcp_RpcProtocolVersions rpc_versions; -/* @@protoc_insertion_point(struct:grpc_gcp_StartClientHandshakeReq) */ -} grpc_gcp_StartClientHandshakeReq; - -typedef struct _grpc_gcp_StartServerHandshakeReq { - pb_callback_t application_protocols; - pb_size_t handshake_parameters_count; - grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry handshake_parameters[3]; - pb_callback_t in_bytes; - bool has_local_endpoint; - grpc_gcp_Endpoint local_endpoint; - bool has_remote_endpoint; - grpc_gcp_Endpoint remote_endpoint; - bool has_rpc_versions; - grpc_gcp_RpcProtocolVersions rpc_versions; -/* @@protoc_insertion_point(struct:grpc_gcp_StartServerHandshakeReq) */ -} grpc_gcp_StartServerHandshakeReq; - -typedef struct _grpc_gcp_HandshakerReq { - bool has_client_start; - grpc_gcp_StartClientHandshakeReq client_start; - bool has_server_start; - grpc_gcp_StartServerHandshakeReq server_start; - bool has_next; - grpc_gcp_NextHandshakeMessageReq next; -/* @@protoc_insertion_point(struct:grpc_gcp_HandshakerReq) */ -} grpc_gcp_HandshakerReq; - -/* Default values for struct fields */ - -/* Initializer values for message structs */ -#define grpc_gcp_Endpoint_init_default {{{NULL}, NULL}, false, 0, false, (grpc_gcp_NetworkProtocol)0} -#define grpc_gcp_Identity_init_default {{{NULL}, NULL}, {{NULL}, NULL}} -#define grpc_gcp_StartClientHandshakeReq_init_default {false, (grpc_gcp_HandshakeProtocol)0, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, false, grpc_gcp_Identity_init_default, false, grpc_gcp_Endpoint_init_default, false, grpc_gcp_Endpoint_init_default, {{NULL}, NULL}, false, grpc_gcp_RpcProtocolVersions_init_default} -#define grpc_gcp_ServerHandshakeParameters_init_default {{{NULL}, NULL}, {{NULL}, NULL}} -#define grpc_gcp_StartServerHandshakeReq_init_default {{{NULL}, NULL}, 0, {grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_init_default, grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_init_default, grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_init_default}, {{NULL}, NULL}, false, grpc_gcp_Endpoint_init_default, false, grpc_gcp_Endpoint_init_default, false, grpc_gcp_RpcProtocolVersions_init_default} -#define grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_init_default {false, 0, false, grpc_gcp_ServerHandshakeParameters_init_default} -#define grpc_gcp_NextHandshakeMessageReq_init_default {{{NULL}, NULL}} -#define grpc_gcp_HandshakerReq_init_default {false, grpc_gcp_StartClientHandshakeReq_init_default, false, grpc_gcp_StartServerHandshakeReq_init_default, false, grpc_gcp_NextHandshakeMessageReq_init_default} -#define grpc_gcp_HandshakerResult_init_default {{{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, false, grpc_gcp_Identity_init_default, false, grpc_gcp_Identity_init_default, false, 0, false, grpc_gcp_RpcProtocolVersions_init_default} -#define grpc_gcp_HandshakerStatus_init_default {false, 0, {{NULL}, NULL}} -#define grpc_gcp_HandshakerResp_init_default {{{NULL}, NULL}, false, 0, false, grpc_gcp_HandshakerResult_init_default, false, grpc_gcp_HandshakerStatus_init_default} -#define grpc_gcp_Endpoint_init_zero {{{NULL}, NULL}, false, 0, false, (grpc_gcp_NetworkProtocol)0} -#define grpc_gcp_Identity_init_zero {{{NULL}, NULL}, {{NULL}, NULL}} -#define grpc_gcp_StartClientHandshakeReq_init_zero {false, (grpc_gcp_HandshakeProtocol)0, {{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, false, grpc_gcp_Identity_init_zero, false, grpc_gcp_Endpoint_init_zero, false, grpc_gcp_Endpoint_init_zero, {{NULL}, NULL}, false, grpc_gcp_RpcProtocolVersions_init_zero} -#define grpc_gcp_ServerHandshakeParameters_init_zero {{{NULL}, NULL}, {{NULL}, NULL}} -#define grpc_gcp_StartServerHandshakeReq_init_zero {{{NULL}, NULL}, 0, {grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_init_zero, grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_init_zero, grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_init_zero}, {{NULL}, NULL}, false, grpc_gcp_Endpoint_init_zero, false, grpc_gcp_Endpoint_init_zero, false, grpc_gcp_RpcProtocolVersions_init_zero} -#define grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_init_zero {false, 0, false, grpc_gcp_ServerHandshakeParameters_init_zero} -#define grpc_gcp_NextHandshakeMessageReq_init_zero {{{NULL}, NULL}} -#define grpc_gcp_HandshakerReq_init_zero {false, grpc_gcp_StartClientHandshakeReq_init_zero, false, grpc_gcp_StartServerHandshakeReq_init_zero, false, grpc_gcp_NextHandshakeMessageReq_init_zero} -#define grpc_gcp_HandshakerResult_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, false, grpc_gcp_Identity_init_zero, false, grpc_gcp_Identity_init_zero, false, 0, false, grpc_gcp_RpcProtocolVersions_init_zero} -#define grpc_gcp_HandshakerStatus_init_zero {false, 0, {{NULL}, NULL}} -#define grpc_gcp_HandshakerResp_init_zero {{{NULL}, NULL}, false, 0, false, grpc_gcp_HandshakerResult_init_zero, false, grpc_gcp_HandshakerStatus_init_zero} - -/* Field tags (for use in manual encoding/decoding) */ -#define grpc_gcp_Identity_service_account_tag 1 -#define grpc_gcp_Identity_hostname_tag 2 -#define grpc_gcp_NextHandshakeMessageReq_in_bytes_tag 1 -#define grpc_gcp_ServerHandshakeParameters_record_protocols_tag 1 -#define grpc_gcp_ServerHandshakeParameters_local_identities_tag 2 -#define grpc_gcp_Endpoint_ip_address_tag 1 -#define grpc_gcp_Endpoint_port_tag 2 -#define grpc_gcp_Endpoint_protocol_tag 3 -#define grpc_gcp_HandshakerResult_application_protocol_tag 1 -#define grpc_gcp_HandshakerResult_record_protocol_tag 2 -#define grpc_gcp_HandshakerResult_key_data_tag 3 -#define grpc_gcp_HandshakerResult_peer_identity_tag 4 -#define grpc_gcp_HandshakerResult_local_identity_tag 5 -#define grpc_gcp_HandshakerResult_keep_channel_open_tag 6 -#define grpc_gcp_HandshakerResult_peer_rpc_versions_tag 7 -#define grpc_gcp_HandshakerStatus_code_tag 1 -#define grpc_gcp_HandshakerStatus_details_tag 2 -#define grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_key_tag 1 -#define grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_value_tag 2 -#define grpc_gcp_HandshakerResp_out_frames_tag 1 -#define grpc_gcp_HandshakerResp_bytes_consumed_tag 2 -#define grpc_gcp_HandshakerResp_result_tag 3 -#define grpc_gcp_HandshakerResp_status_tag 4 -#define grpc_gcp_StartClientHandshakeReq_handshake_security_protocol_tag 1 -#define grpc_gcp_StartClientHandshakeReq_application_protocols_tag 2 -#define grpc_gcp_StartClientHandshakeReq_record_protocols_tag 3 -#define grpc_gcp_StartClientHandshakeReq_target_identities_tag 4 -#define grpc_gcp_StartClientHandshakeReq_local_identity_tag 5 -#define grpc_gcp_StartClientHandshakeReq_local_endpoint_tag 6 -#define grpc_gcp_StartClientHandshakeReq_remote_endpoint_tag 7 -#define grpc_gcp_StartClientHandshakeReq_target_name_tag 8 -#define grpc_gcp_StartClientHandshakeReq_rpc_versions_tag 9 -#define grpc_gcp_StartServerHandshakeReq_application_protocols_tag 1 -#define grpc_gcp_StartServerHandshakeReq_handshake_parameters_tag 2 -#define grpc_gcp_StartServerHandshakeReq_in_bytes_tag 3 -#define grpc_gcp_StartServerHandshakeReq_local_endpoint_tag 4 -#define grpc_gcp_StartServerHandshakeReq_remote_endpoint_tag 5 -#define grpc_gcp_StartServerHandshakeReq_rpc_versions_tag 6 -#define grpc_gcp_HandshakerReq_client_start_tag 1 -#define grpc_gcp_HandshakerReq_server_start_tag 2 -#define grpc_gcp_HandshakerReq_next_tag 3 - -/* Struct field encoding specification for nanopb */ -extern const pb_field_t grpc_gcp_Endpoint_fields[4]; -extern const pb_field_t grpc_gcp_Identity_fields[3]; -extern const pb_field_t grpc_gcp_StartClientHandshakeReq_fields[10]; -extern const pb_field_t grpc_gcp_ServerHandshakeParameters_fields[3]; -extern const pb_field_t grpc_gcp_StartServerHandshakeReq_fields[7]; -extern const pb_field_t grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_fields[3]; -extern const pb_field_t grpc_gcp_NextHandshakeMessageReq_fields[2]; -extern const pb_field_t grpc_gcp_HandshakerReq_fields[4]; -extern const pb_field_t grpc_gcp_HandshakerResult_fields[8]; -extern const pb_field_t grpc_gcp_HandshakerStatus_fields[3]; -extern const pb_field_t grpc_gcp_HandshakerResp_fields[5]; - -/* Maximum encoded size of messages (where known) */ -/* grpc_gcp_Endpoint_size depends on runtime parameters */ -/* grpc_gcp_Identity_size depends on runtime parameters */ -/* grpc_gcp_StartClientHandshakeReq_size depends on runtime parameters */ -/* grpc_gcp_ServerHandshakeParameters_size depends on runtime parameters */ -/* grpc_gcp_StartServerHandshakeReq_size depends on runtime parameters */ -#define grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_size (17 + grpc_gcp_ServerHandshakeParameters_size) -/* grpc_gcp_NextHandshakeMessageReq_size depends on runtime parameters */ -#define grpc_gcp_HandshakerReq_size (18 + grpc_gcp_StartClientHandshakeReq_size + grpc_gcp_StartServerHandshakeReq_size + grpc_gcp_NextHandshakeMessageReq_size) -/* grpc_gcp_HandshakerResult_size depends on runtime parameters */ -/* grpc_gcp_HandshakerStatus_size depends on runtime parameters */ -/* grpc_gcp_HandshakerResp_size depends on runtime parameters */ - -/* Message IDs (where set with "msgid" option) */ -#ifdef PB_MSGID - -#define HANDSHAKER_MESSAGES \ - - -#endif - -#ifdef __cplusplus -} /* extern "C" */ -#endif -/* @@protoc_insertion_point(eof) */ - -#endif diff --git a/src/core/tsi/alts/handshaker/transport_security_common.pb.c b/src/core/tsi/alts/handshaker/transport_security_common.pb.c deleted file mode 100644 index 326b1b10ab7..00000000000 --- a/src/core/tsi/alts/handshaker/transport_security_common.pb.c +++ /dev/null @@ -1,49 +0,0 @@ -/* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.7-dev */ - -#include "src/core/tsi/alts/handshaker/transport_security_common.pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 -#error Regenerate this file with the current version of nanopb generator. -#endif - - - -const pb_field_t grpc_gcp_RpcProtocolVersions_fields[3] = { - PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, grpc_gcp_RpcProtocolVersions, max_rpc_version, max_rpc_version, &grpc_gcp_RpcProtocolVersions_Version_fields), - PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_gcp_RpcProtocolVersions, min_rpc_version, max_rpc_version, &grpc_gcp_RpcProtocolVersions_Version_fields), - PB_LAST_FIELD -}; - -const pb_field_t grpc_gcp_RpcProtocolVersions_Version_fields[3] = { - PB_FIELD( 1, UINT32 , OPTIONAL, STATIC , FIRST, grpc_gcp_RpcProtocolVersions_Version, major, major, 0), - PB_FIELD( 2, UINT32 , OPTIONAL, STATIC , OTHER, grpc_gcp_RpcProtocolVersions_Version, minor, major, 0), - PB_LAST_FIELD -}; - - -/* Check that field information fits in pb_field_t */ -#if !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_32BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in 8 or 16 bit - * field descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(grpc_gcp_RpcProtocolVersions, max_rpc_version) < 65536 && pb_membersize(grpc_gcp_RpcProtocolVersions, min_rpc_version) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_grpc_gcp_RpcProtocolVersions_grpc_gcp_RpcProtocolVersions_Version) -#endif - -#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_16BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in the default - * 8 bit descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(grpc_gcp_RpcProtocolVersions, max_rpc_version) < 256 && pb_membersize(grpc_gcp_RpcProtocolVersions, min_rpc_version) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_grpc_gcp_RpcProtocolVersions_grpc_gcp_RpcProtocolVersions_Version) -#endif - - -/* @@protoc_insertion_point(eof) */ diff --git a/src/core/tsi/alts/handshaker/transport_security_common.pb.h b/src/core/tsi/alts/handshaker/transport_security_common.pb.h deleted file mode 100644 index 87d9abf149f..00000000000 --- a/src/core/tsi/alts/handshaker/transport_security_common.pb.h +++ /dev/null @@ -1,78 +0,0 @@ -/* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.7-dev */ - -#ifndef PB_GRPC_GCP_TRANSPORT_SECURITY_COMMON_PB_H_INCLUDED -#define PB_GRPC_GCP_TRANSPORT_SECURITY_COMMON_PB_H_INCLUDED -#include "pb.h" -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 -#error Regenerate this file with the current version of nanopb generator. -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Enum definitions */ -typedef enum _grpc_gcp_SecurityLevel { - grpc_gcp_SecurityLevel_SECURITY_NONE = 0, - grpc_gcp_SecurityLevel_INTEGRITY_ONLY = 1, - grpc_gcp_SecurityLevel_INTEGRITY_AND_PRIVACY = 2 -} grpc_gcp_SecurityLevel; -#define _grpc_gcp_SecurityLevel_MIN grpc_gcp_SecurityLevel_SECURITY_NONE -#define _grpc_gcp_SecurityLevel_MAX grpc_gcp_SecurityLevel_INTEGRITY_AND_PRIVACY -#define _grpc_gcp_SecurityLevel_ARRAYSIZE ((grpc_gcp_SecurityLevel)(grpc_gcp_SecurityLevel_INTEGRITY_AND_PRIVACY+1)) - -/* Struct definitions */ -typedef struct _grpc_gcp_RpcProtocolVersions_Version { - bool has_major; - uint32_t major; - bool has_minor; - uint32_t minor; -/* @@protoc_insertion_point(struct:grpc_gcp_RpcProtocolVersions_Version) */ -} grpc_gcp_RpcProtocolVersions_Version; - -typedef struct _grpc_gcp_RpcProtocolVersions { - bool has_max_rpc_version; - grpc_gcp_RpcProtocolVersions_Version max_rpc_version; - bool has_min_rpc_version; - grpc_gcp_RpcProtocolVersions_Version min_rpc_version; -/* @@protoc_insertion_point(struct:grpc_gcp_RpcProtocolVersions) */ -} grpc_gcp_RpcProtocolVersions; - -/* Default values for struct fields */ - -/* Initializer values for message structs */ -#define grpc_gcp_RpcProtocolVersions_init_default {false, grpc_gcp_RpcProtocolVersions_Version_init_default, false, grpc_gcp_RpcProtocolVersions_Version_init_default} -#define grpc_gcp_RpcProtocolVersions_Version_init_default {false, 0, false, 0} -#define grpc_gcp_RpcProtocolVersions_init_zero {false, grpc_gcp_RpcProtocolVersions_Version_init_zero, false, grpc_gcp_RpcProtocolVersions_Version_init_zero} -#define grpc_gcp_RpcProtocolVersions_Version_init_zero {false, 0, false, 0} - -/* Field tags (for use in manual encoding/decoding) */ -#define grpc_gcp_RpcProtocolVersions_Version_major_tag 1 -#define grpc_gcp_RpcProtocolVersions_Version_minor_tag 2 -#define grpc_gcp_RpcProtocolVersions_max_rpc_version_tag 1 -#define grpc_gcp_RpcProtocolVersions_min_rpc_version_tag 2 - -/* Struct field encoding specification for nanopb */ -extern const pb_field_t grpc_gcp_RpcProtocolVersions_fields[3]; -extern const pb_field_t grpc_gcp_RpcProtocolVersions_Version_fields[3]; - -/* Maximum encoded size of messages (where known) */ -#define grpc_gcp_RpcProtocolVersions_size 28 -#define grpc_gcp_RpcProtocolVersions_Version_size 12 - -/* Message IDs (where set with "msgid" option) */ -#ifdef PB_MSGID - -#define TRANSPORT_SECURITY_COMMON_MESSAGES \ - - -#endif - -#ifdef __cplusplus -} /* extern "C" */ -#endif -/* @@protoc_insertion_point(eof) */ - -#endif diff --git a/src/core/tsi/alts/handshaker/transport_security_common_api.cc b/src/core/tsi/alts/handshaker/transport_security_common_api.cc index 6c518c1ff31..c7b9fafd935 100644 --- a/src/core/tsi/alts/handshaker/transport_security_common_api.cc +++ b/src/core/tsi/alts/handshaker/transport_security_common_api.cc @@ -29,9 +29,6 @@ bool grpc_gcp_rpc_protocol_versions_set_max( "grpc_gcp_rpc_protocol_versions_set_max()."); return false; } - versions->has_max_rpc_version = true; - versions->max_rpc_version.has_major = true; - versions->max_rpc_version.has_minor = true; versions->max_rpc_version.major = max_major; versions->max_rpc_version.minor = max_minor; return true; @@ -46,49 +43,11 @@ bool grpc_gcp_rpc_protocol_versions_set_min( "grpc_gcp_rpc_protocol_versions_set_min()."); return false; } - versions->has_min_rpc_version = true; - versions->min_rpc_version.has_major = true; - versions->min_rpc_version.has_minor = true; versions->min_rpc_version.major = min_major; versions->min_rpc_version.minor = min_minor; return true; } -size_t grpc_gcp_rpc_protocol_versions_encode_length( - const grpc_gcp_rpc_protocol_versions* versions) { - if (versions == nullptr) { - gpr_log(GPR_ERROR, - "Invalid nullptr arguments to " - "grpc_gcp_rpc_protocol_versions_encode_length()."); - return 0; - } - pb_ostream_t size_stream; - memset(&size_stream, 0, sizeof(pb_ostream_t)); - if (!pb_encode(&size_stream, grpc_gcp_RpcProtocolVersions_fields, versions)) { - gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&size_stream)); - return 0; - } - return size_stream.bytes_written; -} - -bool grpc_gcp_rpc_protocol_versions_encode_to_raw_bytes( - const grpc_gcp_rpc_protocol_versions* versions, uint8_t* bytes, - size_t bytes_length) { - if (versions == nullptr || bytes == nullptr || bytes_length == 0) { - gpr_log(GPR_ERROR, - "Invalid nullptr arguments to " - "grpc_gcp_rpc_protocol_versions_encode_to_raw_bytes()."); - return false; - } - pb_ostream_t output_stream = pb_ostream_from_buffer(bytes, bytes_length); - if (!pb_encode(&output_stream, grpc_gcp_RpcProtocolVersions_fields, - versions)) { - gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&output_stream)); - return false; - } - return true; -} - bool grpc_gcp_rpc_protocol_versions_encode( const grpc_gcp_rpc_protocol_versions* versions, grpc_slice* slice) { if (versions == nullptr || slice == nullptr) { @@ -97,12 +56,32 @@ bool grpc_gcp_rpc_protocol_versions_encode( "grpc_gcp_rpc_protocol_versions_encode()."); return false; } - size_t encoded_length = - grpc_gcp_rpc_protocol_versions_encode_length(versions); - if (encoded_length == 0) return false; - *slice = grpc_slice_malloc(encoded_length); - return grpc_gcp_rpc_protocol_versions_encode_to_raw_bytes( - versions, GRPC_SLICE_START_PTR(*slice), encoded_length); + upb::Arena arena; + grpc_gcp_RpcProtocolVersions* versions_msg = + grpc_gcp_RpcProtocolVersions_new(arena.ptr()); + grpc_gcp_RpcProtocolVersions_assign_from_struct(versions_msg, arena.ptr(), + versions); + return grpc_gcp_rpc_protocol_versions_encode(versions_msg, arena.ptr(), + slice); +} + +bool grpc_gcp_rpc_protocol_versions_encode( + const grpc_gcp_RpcProtocolVersions* versions, upb_arena* arena, + grpc_slice* slice) { + if (versions == nullptr || arena == nullptr || slice == nullptr) { + gpr_log(GPR_ERROR, + "Invalid nullptr arguments to " + "grpc_gcp_rpc_protocol_versions_encode()."); + return false; + } + size_t buf_length; + char* buf = + grpc_gcp_RpcProtocolVersions_serialize(versions, arena, &buf_length); + if (buf == nullptr) { + return false; + } + *slice = grpc_slice_from_copied_buffer(buf, buf_length); + return true; } bool grpc_gcp_rpc_protocol_versions_decode( @@ -113,16 +92,63 @@ bool grpc_gcp_rpc_protocol_versions_decode( "grpc_gcp_rpc_protocol_versions_decode()."); return false; } - pb_istream_t stream = - pb_istream_from_buffer(const_cast(GRPC_SLICE_START_PTR(slice)), - GRPC_SLICE_LENGTH(slice)); - if (!pb_decode(&stream, grpc_gcp_RpcProtocolVersions_fields, versions)) { - gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&stream)); + upb::Arena arena; + grpc_gcp_RpcProtocolVersions* versions_msg = + grpc_gcp_RpcProtocolVersions_parse( + reinterpret_cast(GRPC_SLICE_START_PTR(slice)), + GRPC_SLICE_LENGTH(slice), arena.ptr()); + if (versions_msg == nullptr) { + gpr_log(GPR_ERROR, "cannot deserialize RpcProtocolVersions message"); return false; } + grpc_gcp_rpc_protocol_versions_assign_from_upb(versions, versions_msg); return true; } +void grpc_gcp_rpc_protocol_versions_assign_from_upb( + grpc_gcp_rpc_protocol_versions* versions, + const grpc_gcp_RpcProtocolVersions* value) { + const grpc_gcp_RpcProtocolVersions_Version* max_version_msg = + grpc_gcp_RpcProtocolVersions_max_rpc_version(value); + if (max_version_msg != nullptr) { + versions->max_rpc_version.major = + grpc_gcp_RpcProtocolVersions_Version_major(max_version_msg); + versions->max_rpc_version.minor = + grpc_gcp_RpcProtocolVersions_Version_minor(max_version_msg); + } else { + versions->max_rpc_version.major = 0; + versions->max_rpc_version.minor = 0; + } + const grpc_gcp_RpcProtocolVersions_Version* min_version_msg = + grpc_gcp_RpcProtocolVersions_min_rpc_version(value); + if (min_version_msg != nullptr) { + versions->min_rpc_version.major = + grpc_gcp_RpcProtocolVersions_Version_major(min_version_msg); + versions->min_rpc_version.minor = + grpc_gcp_RpcProtocolVersions_Version_minor(min_version_msg); + } else { + versions->min_rpc_version.major = 0; + versions->min_rpc_version.minor = 0; + } +} + +void grpc_gcp_RpcProtocolVersions_assign_from_struct( + grpc_gcp_RpcProtocolVersions* versions, upb_arena* arena, + const grpc_gcp_rpc_protocol_versions* value) { + grpc_gcp_RpcProtocolVersions_Version* max_version_msg = + grpc_gcp_RpcProtocolVersions_mutable_max_rpc_version(versions, arena); + grpc_gcp_RpcProtocolVersions_Version_set_major(max_version_msg, + value->max_rpc_version.major); + grpc_gcp_RpcProtocolVersions_Version_set_minor(max_version_msg, + value->max_rpc_version.minor); + grpc_gcp_RpcProtocolVersions_Version* min_version_msg = + grpc_gcp_RpcProtocolVersions_mutable_min_rpc_version(versions, arena); + grpc_gcp_RpcProtocolVersions_Version_set_major(min_version_msg, + value->min_rpc_version.major); + grpc_gcp_RpcProtocolVersions_Version_set_minor(min_version_msg, + value->min_rpc_version.minor); +} + bool grpc_gcp_rpc_protocol_versions_copy( const grpc_gcp_rpc_protocol_versions* src, grpc_gcp_rpc_protocol_versions* dst) { diff --git a/src/core/tsi/alts/handshaker/transport_security_common_api.h b/src/core/tsi/alts/handshaker/transport_security_common_api.h index 27942c8ae4c..75739e4fe76 100644 --- a/src/core/tsi/alts/handshaker/transport_security_common_api.h +++ b/src/core/tsi/alts/handshaker/transport_security_common_api.h @@ -21,20 +21,24 @@ #include -#include "pb_decode.h" -#include "pb_encode.h" - #include #include #include #include -#include "src/core/tsi/alts/handshaker/transport_security_common.pb.h" +#include "src/proto/grpc/gcp/transport_security_common.upb.h" -typedef grpc_gcp_RpcProtocolVersions grpc_gcp_rpc_protocol_versions; +// C struct coresponding to protobuf message RpcProtocolVersions.Version +typedef struct _grpc_gcp_RpcProtocolVersions_Version { + uint32_t major; + uint32_t minor; +} grpc_gcp_rpc_protocol_versions_version; -typedef grpc_gcp_RpcProtocolVersions_Version - grpc_gcp_rpc_protocol_versions_version; +// C struct coresponding to protobuf message RpcProtocolVersions +typedef struct _grpc_gcp_RpcProtocolVersions { + grpc_gcp_rpc_protocol_versions_version max_rpc_version; + grpc_gcp_rpc_protocol_versions_version min_rpc_version; +} grpc_gcp_rpc_protocol_versions; /** * This method sets the value for max_rpc_versions field of rpc protocol @@ -64,31 +68,6 @@ bool grpc_gcp_rpc_protocol_versions_set_min( grpc_gcp_rpc_protocol_versions* versions, uint32_t min_major, uint32_t min_minor); -/** - * This method computes serialized byte length of rpc protocol versions. - * - * - versions: an rpc protocol versions instance. - * - * The method returns serialized byte length. It returns 0 on failure. - */ -size_t grpc_gcp_rpc_protocol_versions_encode_length( - const grpc_gcp_rpc_protocol_versions* versions); - -/** - * This method serializes rpc protocol versions and writes the result to - * the memory buffer provided by the caller. Caller is responsible for - * allocating sufficient memory to store the serialized data. - * - * - versions: an rpc protocol versions instance. - * - bytes: bytes buffer where the result will be written to. - * - bytes_length: length of the bytes buffer. - * - * The method returns true on success and false otherwise. - */ -bool grpc_gcp_rpc_protocol_versions_encode_to_raw_bytes( - const grpc_gcp_rpc_protocol_versions* versions, uint8_t* bytes, - size_t bytes_length); - /** * This method serializes an rpc protocol version and returns serialized rpc * versions in grpc slice. @@ -101,6 +80,20 @@ bool grpc_gcp_rpc_protocol_versions_encode_to_raw_bytes( bool grpc_gcp_rpc_protocol_versions_encode( const grpc_gcp_rpc_protocol_versions* versions, grpc_slice* slice); +/** + * This method serializes an rpc protocol version and returns serialized rpc + * versions in grpc slice. + * + * - versions: an rpc protocol versions instance. + * - arena: upb arena. + * - slice: grpc slice where the serialized result will be written. + * + * The method returns true on success and false otherwise. + */ +bool grpc_gcp_rpc_protocol_versions_encode( + const grpc_gcp_RpcProtocolVersions* versions, upb_arena* arena, + grpc_slice* slice); + /** * This method de-serializes input in grpc slice form and stores the result * in rpc protocol versions. @@ -114,6 +107,21 @@ bool grpc_gcp_rpc_protocol_versions_encode( bool grpc_gcp_rpc_protocol_versions_decode( const grpc_slice& slice, grpc_gcp_rpc_protocol_versions* versions); +/** + * Assigns value of upb RpcProtocolVersions to grpc_gcp_rpc_protocol_versions. + */ +void grpc_gcp_rpc_protocol_versions_assign_from_upb( + grpc_gcp_rpc_protocol_versions* versions, + const grpc_gcp_RpcProtocolVersions* value); + +/** + * Assigns value of struct grpc_gcp_rpc_protocol_versions to + * RpcProtocolVersions. + */ +void grpc_gcp_RpcProtocolVersions_assign_from_struct( + grpc_gcp_RpcProtocolVersions* versions, upb_arena* arena, + const grpc_gcp_rpc_protocol_versions* value); + /** * This method performs a deep copy operation on rpc protocol versions * instance. diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index f1c1a72765b..58c1fd3daba 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -306,23 +306,18 @@ CORE_SOURCE_FILES = [ 'src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc', 'src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc', 'src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc', - 'src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc', - 'src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc', 'src/core/tsi/alts/handshaker/alts_tsi_utils.cc', 'src/core/tsi/alts/handshaker/transport_security_common_api.cc', - 'src/core/tsi/alts/handshaker/altscontext.pb.c', - 'src/core/tsi/alts/handshaker/handshaker.pb.c', - 'src/core/tsi/alts/handshaker/transport_security_common.pb.c', - 'third_party/nanopb/pb_common.c', - 'third_party/nanopb/pb_decode.c', - 'third_party/nanopb/pb_encode.c', - 'src/core/tsi/transport_security.cc', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c', + 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c', 'third_party/upb/upb/decode.c', 'third_party/upb/upb/encode.c', 'third_party/upb/upb/msg.c', 'third_party/upb/upb/port.c', 'third_party/upb/upb/table.c', 'third_party/upb/upb/upb.c', + 'src/core/tsi/transport_security.cc', 'src/core/ext/transport/chttp2/client/insecure/channel_create.cc', 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc', 'src/core/ext/transport/chttp2/client/authority.cc', diff --git a/test/core/tsi/alts/handshaker/BUILD b/test/core/tsi/alts/handshaker/BUILD index 61ba16ad6db..ed97056c003 100644 --- a/test/core/tsi/alts/handshaker/BUILD +++ b/test/core/tsi/alts/handshaker/BUILD @@ -41,17 +41,6 @@ grpc_cc_test( ], ) -grpc_cc_test( - name = "alts_handshaker_service_api_test", - srcs = ["alts_handshaker_service_api_test.cc"], - language = "C++", - deps = [ - ":alts_handshaker_service_api_test_lib", - "//:grpc", - "//test/core/util:grpc_test_util", - ], -) - grpc_cc_test( name = "alts_tsi_handshaker_test", srcs = ["alts_tsi_handshaker_test.cc"], diff --git a/test/core/tsi/alts/handshaker/alts_handshaker_client_test.cc b/test/core/tsi/alts/handshaker/alts_handshaker_client_test.cc index 9a4541bb7d1..4d36c24d910 100644 --- a/test/core/tsi/alts/handshaker/alts_handshaker_client_test.cc +++ b/test/core/tsi/alts/handshaker/alts_handshaker_client_test.cc @@ -54,34 +54,34 @@ typedef struct alts_handshaker_client_test_config { } alts_handshaker_client_test_config; static void validate_rpc_protocol_versions( - grpc_gcp_rpc_protocol_versions* versions) { + const grpc_gcp_RpcProtocolVersions* versions) { GPR_ASSERT(versions != nullptr); - GPR_ASSERT(versions->max_rpc_version.major == kMaxRpcVersionMajor); - GPR_ASSERT(versions->max_rpc_version.minor == kMaxRpcVersionMinor); - GPR_ASSERT(versions->min_rpc_version.major == kMinRpcVersionMajor); - GPR_ASSERT(versions->min_rpc_version.minor == kMinRpcVersionMinor); + const grpc_gcp_RpcProtocolVersions_Version* max_version = + grpc_gcp_RpcProtocolVersions_max_rpc_version(versions); + const grpc_gcp_RpcProtocolVersions_Version* min_version = + grpc_gcp_RpcProtocolVersions_min_rpc_version(versions); + GPR_ASSERT(grpc_gcp_RpcProtocolVersions_Version_major(max_version) == + kMaxRpcVersionMajor); + GPR_ASSERT(grpc_gcp_RpcProtocolVersions_Version_minor(max_version) == + kMaxRpcVersionMinor); + GPR_ASSERT(grpc_gcp_RpcProtocolVersions_Version_major(min_version) == + kMinRpcVersionMajor); + GPR_ASSERT(grpc_gcp_RpcProtocolVersions_Version_minor(min_version) == + kMinRpcVersionMinor); } static void validate_target_identities( - const repeated_field* target_identity_head) { - grpc_gcp_identity* target_identity1 = static_cast( - const_cast(target_identity_head->next->data)); - grpc_gcp_identity* target_identity2 = static_cast( - const_cast(target_identity_head->data)); - grpc_slice* service_account1 = - static_cast(target_identity1->service_account.arg); - grpc_slice* service_account2 = - static_cast(target_identity2->service_account.arg); - GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(*service_account1), - ALTS_HANDSHAKER_CLIENT_TEST_TARGET_SERVICE_ACCOUNT1, - GRPC_SLICE_LENGTH(*service_account1)) == 0); - GPR_ASSERT(strlen(ALTS_HANDSHAKER_CLIENT_TEST_TARGET_SERVICE_ACCOUNT1) == - GRPC_SLICE_LENGTH(*service_account1)); - GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(*service_account2), - ALTS_HANDSHAKER_CLIENT_TEST_TARGET_SERVICE_ACCOUNT2, - GRPC_SLICE_LENGTH(*service_account2)) == 0); - GPR_ASSERT(strlen(ALTS_HANDSHAKER_CLIENT_TEST_TARGET_SERVICE_ACCOUNT2) == - GRPC_SLICE_LENGTH(*service_account2)); + const grpc_gcp_Identity* const* target_identities, + size_t target_identities_count) { + GPR_ASSERT(target_identities_count == 2); + const grpc_gcp_Identity* identity1 = target_identities[1]; + const grpc_gcp_Identity* identity2 = target_identities[0]; + GPR_ASSERT(upb_strview_eql( + grpc_gcp_Identity_service_account(identity1), + upb_strview_makez(ALTS_HANDSHAKER_CLIENT_TEST_TARGET_SERVICE_ACCOUNT1))); + GPR_ASSERT(upb_strview_eql( + grpc_gcp_Identity_service_account(identity2), + upb_strview_makez(ALTS_HANDSHAKER_CLIENT_TEST_TARGET_SERVICE_ACCOUNT2))); } /** @@ -117,14 +117,14 @@ static bool validate_op(alts_handshaker_client* c, const grpc_op* op, return ok; } -static grpc_gcp_handshaker_req* deserialize_handshaker_req( - grpc_gcp_handshaker_req_type type, grpc_byte_buffer* buffer) { +static grpc_gcp_HandshakerReq* deserialize_handshaker_req( + grpc_byte_buffer* buffer, upb_arena* arena) { GPR_ASSERT(buffer != nullptr); - grpc_gcp_handshaker_req* req = grpc_gcp_handshaker_decoded_req_create(type); grpc_byte_buffer_reader bbr; GPR_ASSERT(grpc_byte_buffer_reader_init(&bbr, buffer)); grpc_slice slice = grpc_byte_buffer_reader_readall(&bbr); - GPR_ASSERT(grpc_gcp_handshaker_req_decode(slice, req)); + grpc_gcp_HandshakerReq* req = grpc_gcp_handshaker_req_decode(slice, arena); + GPR_ASSERT(req != nullptr); grpc_slice_unref(slice); grpc_byte_buffer_reader_destroy(&bbr); return req; @@ -150,40 +150,38 @@ static grpc_call_error check_client_start_success(grpc_call* call, const grpc_op* op, size_t nops, grpc_closure* closure) { + upb::Arena arena; alts_handshaker_client* client = static_cast(closure->cb_arg); GPR_ASSERT(alts_handshaker_client_get_closure_for_testing(client) == closure); - grpc_gcp_handshaker_req* req = deserialize_handshaker_req( - CLIENT_START_REQ, - alts_handshaker_client_get_send_buffer_for_testing(client)); - GPR_ASSERT(req->client_start.handshake_security_protocol == - grpc_gcp_HandshakeProtocol_ALTS); - const void* data = (static_cast( - req->client_start.application_protocols.arg)) - ->data; - GPR_ASSERT(data != nullptr); - grpc_slice* application_protocol = (grpc_slice*)data; - data = (static_cast(req->client_start.record_protocols.arg)) - ->data; - grpc_slice* record_protocol = (grpc_slice*)data; - GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(*application_protocol), - ALTS_APPLICATION_PROTOCOL, - GRPC_SLICE_LENGTH(*application_protocol)) == 0); - GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(*record_protocol), - ALTS_RECORD_PROTOCOL, - GRPC_SLICE_LENGTH(*record_protocol)) == 0); - validate_rpc_protocol_versions(&req->client_start.rpc_versions); - validate_target_identities( - static_cast(req->client_start.target_identities.arg)); - grpc_slice* target_name = - static_cast(req->client_start.target_name.arg); - GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(*target_name), - ALTS_HANDSHAKER_CLIENT_TEST_TARGET_NAME, - GRPC_SLICE_LENGTH(*target_name)) == 0); - GPR_ASSERT(GRPC_SLICE_LENGTH(*target_name) == - strlen(ALTS_HANDSHAKER_CLIENT_TEST_TARGET_NAME)); + grpc_gcp_HandshakerReq* req = deserialize_handshaker_req( + alts_handshaker_client_get_send_buffer_for_testing(client), arena.ptr()); + const grpc_gcp_StartClientHandshakeReq* client_start = + grpc_gcp_HandshakerReq_client_start(req); + GPR_ASSERT(grpc_gcp_StartClientHandshakeReq_handshake_security_protocol( + client_start) == grpc_gcp_ALTS); + upb_strview const* application_protocols = + grpc_gcp_StartClientHandshakeReq_application_protocols(client_start, + nullptr); + GPR_ASSERT(upb_strview_eql(application_protocols[0], + upb_strview_makez(ALTS_APPLICATION_PROTOCOL))); + upb_strview const* record_protocols = + grpc_gcp_StartClientHandshakeReq_record_protocols(client_start, nullptr); + GPR_ASSERT(upb_strview_eql(record_protocols[0], + upb_strview_makez(ALTS_RECORD_PROTOCOL))); + const grpc_gcp_RpcProtocolVersions* rpc_protocol_versions = + grpc_gcp_StartClientHandshakeReq_rpc_versions(client_start); + validate_rpc_protocol_versions(rpc_protocol_versions); + size_t target_identities_count; + const grpc_gcp_Identity* const* target_identities = + grpc_gcp_StartClientHandshakeReq_target_identities( + client_start, &target_identities_count); + validate_target_identities(target_identities, target_identities_count); + GPR_ASSERT(upb_strview_eql( + grpc_gcp_StartClientHandshakeReq_target_name(client_start), + upb_strview_makez(ALTS_HANDSHAKER_CLIENT_TEST_TARGET_NAME))); + GPR_ASSERT(validate_op(client, op, nops, true /* is_start */)); - grpc_gcp_handshaker_req_destroy(req); return GRPC_CALL_OK; } @@ -197,34 +195,37 @@ static grpc_call_error check_server_start_success(grpc_call* call, const grpc_op* op, size_t nops, grpc_closure* closure) { + upb::Arena arena; alts_handshaker_client* client = static_cast(closure->cb_arg); GPR_ASSERT(alts_handshaker_client_get_closure_for_testing(client) == closure); - grpc_gcp_handshaker_req* req = deserialize_handshaker_req( - SERVER_START_REQ, - alts_handshaker_client_get_send_buffer_for_testing(client)); - const void* data = (static_cast( - req->server_start.application_protocols.arg)) - ->data; - GPR_ASSERT(data != nullptr); - grpc_slice* application_protocol = (grpc_slice*)data; - GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(*application_protocol), - ALTS_APPLICATION_PROTOCOL, - GRPC_SLICE_LENGTH(*application_protocol)) == 0); - GPR_ASSERT(req->server_start.handshake_parameters_count == 1); - GPR_ASSERT(req->server_start.handshake_parameters[0].key == - grpc_gcp_HandshakeProtocol_ALTS); - data = (static_cast(req->server_start.handshake_parameters[0] - .value.record_protocols.arg)) - ->data; - GPR_ASSERT(data != nullptr); - grpc_slice* record_protocol = (grpc_slice*)data; - GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(*record_protocol), - ALTS_RECORD_PROTOCOL, - GRPC_SLICE_LENGTH(*record_protocol)) == 0); - validate_rpc_protocol_versions(&req->server_start.rpc_versions); + grpc_gcp_HandshakerReq* req = deserialize_handshaker_req( + alts_handshaker_client_get_send_buffer_for_testing(client), arena.ptr()); + const grpc_gcp_StartServerHandshakeReq* server_start = + grpc_gcp_HandshakerReq_server_start(req); + upb_strview const* application_protocols = + grpc_gcp_StartServerHandshakeReq_application_protocols(server_start, + nullptr); + GPR_ASSERT(upb_strview_eql(application_protocols[0], + upb_strview_makez(ALTS_APPLICATION_PROTOCOL))); + size_t handshake_parameters_count; + const grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry* const* + handshake_parameters = + grpc_gcp_StartServerHandshakeReq_handshake_parameters( + server_start, &handshake_parameters_count); + GPR_ASSERT(handshake_parameters_count == 1); + GPR_ASSERT(grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_key( + handshake_parameters[0]) == grpc_gcp_ALTS); + const grpc_gcp_ServerHandshakeParameters* value = + grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_value( + handshake_parameters[0]); + upb_strview const* record_protocols = + grpc_gcp_ServerHandshakeParameters_record_protocols(value, nullptr); + GPR_ASSERT(upb_strview_eql(record_protocols[0], + upb_strview_makez(ALTS_RECORD_PROTOCOL))); + validate_rpc_protocol_versions( + grpc_gcp_StartServerHandshakeReq_rpc_versions(server_start)); GPR_ASSERT(validate_op(client, op, nops, true /* is_start */)); - grpc_gcp_handshaker_req_destroy(req); return GRPC_CALL_OK; } @@ -235,20 +236,21 @@ static grpc_call_error check_server_start_success(grpc_call* call, */ static grpc_call_error check_next_success(grpc_call* call, const grpc_op* op, size_t nops, grpc_closure* closure) { + upb::Arena arena; alts_handshaker_client* client = static_cast(closure->cb_arg); GPR_ASSERT(alts_handshaker_client_get_closure_for_testing(client) == closure); - grpc_gcp_handshaker_req* req = deserialize_handshaker_req( - NEXT_REQ, alts_handshaker_client_get_send_buffer_for_testing(client)); - grpc_slice* in_bytes = static_cast(req->next.in_bytes.arg); - GPR_ASSERT(in_bytes != nullptr); - GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(*in_bytes), - ALTS_HANDSHAKER_CLIENT_TEST_OUT_FRAME, - GRPC_SLICE_LENGTH(*in_bytes)) == 0); + grpc_gcp_HandshakerReq* req = deserialize_handshaker_req( + alts_handshaker_client_get_send_buffer_for_testing(client), arena.ptr()); + const grpc_gcp_NextHandshakeMessageReq* next = + grpc_gcp_HandshakerReq_next(req); + GPR_ASSERT(upb_strview_eql( + grpc_gcp_NextHandshakeMessageReq_in_bytes(next), + upb_strview_makez(ALTS_HANDSHAKER_CLIENT_TEST_OUT_FRAME))); GPR_ASSERT(validate_op(client, op, nops, false /* is_start */)); - grpc_gcp_handshaker_req_destroy(req); return GRPC_CALL_OK; } + /** * A mock grpc_caller used to check if client_start, server_start, and next * operations correctly handle the situation when the grpc call made to the diff --git a/test/core/tsi/alts/handshaker/alts_handshaker_service_api_test.cc b/test/core/tsi/alts/handshaker/alts_handshaker_service_api_test.cc deleted file mode 100644 index 3506264f528..00000000000 --- a/test/core/tsi/alts/handshaker/alts_handshaker_service_api_test.cc +++ /dev/null @@ -1,149 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include -#include - -#include "test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.h" - -int main(int argc, char** argv) { - const char in_bytes[] = "HELLO GOOGLE!"; - const char out_frames[] = "HELLO WORLD!"; - const char key_data[] = "THIS IS KEY DATA."; - const char details[] = "DETAILS NEED TO BE POPULATED"; - const uint32_t max_rpc_version_major = 3; - const uint32_t max_rpc_version_minor = 2; - const uint32_t min_rpc_version_major = 2; - const uint32_t min_rpc_version_minor = 1; - - /* handshaker_req_next. */ - grpc_gcp_handshaker_req* req = grpc_gcp_handshaker_req_create(NEXT_REQ); - grpc_gcp_handshaker_req* decoded_req = - grpc_gcp_handshaker_decoded_req_create(NEXT_REQ); - GPR_ASSERT( - grpc_gcp_handshaker_req_set_in_bytes(req, in_bytes, strlen(in_bytes))); - grpc_slice encoded_req; - GPR_ASSERT(grpc_gcp_handshaker_req_encode(req, &encoded_req)); - GPR_ASSERT(grpc_gcp_handshaker_req_decode(encoded_req, decoded_req)); - GPR_ASSERT(grpc_gcp_handshaker_req_equals(req, decoded_req)); - grpc_gcp_handshaker_req_destroy(req); - grpc_gcp_handshaker_req_destroy(decoded_req); - grpc_slice_unref(encoded_req); - - /* handshaker_req_client_start. */ - req = grpc_gcp_handshaker_req_create(CLIENT_START_REQ); - decoded_req = grpc_gcp_handshaker_decoded_req_create(CLIENT_START_REQ); - GPR_ASSERT(grpc_gcp_handshaker_req_set_handshake_protocol( - req, grpc_gcp_HandshakeProtocol_TLS)); - GPR_ASSERT(grpc_gcp_handshaker_req_set_local_identity_hostname( - req, "www.google.com")); - GPR_ASSERT(grpc_gcp_handshaker_req_set_local_endpoint( - req, "2001:db8::8:800:200C:417a", 9876, grpc_gcp_NetworkProtocol_TCP)); - GPR_ASSERT(grpc_gcp_handshaker_req_set_remote_endpoint( - req, "2001:db8::bac5::fed0:84a2", 1234, grpc_gcp_NetworkProtocol_TCP)); - GPR_ASSERT(grpc_gcp_handshaker_req_add_application_protocol(req, "grpc")); - GPR_ASSERT(grpc_gcp_handshaker_req_add_application_protocol(req, "http2")); - GPR_ASSERT( - grpc_gcp_handshaker_req_add_record_protocol(req, "ALTSRP_GCM_AES256")); - GPR_ASSERT( - grpc_gcp_handshaker_req_add_record_protocol(req, "ALTSRP_GCM_AES384")); - GPR_ASSERT(grpc_gcp_handshaker_req_add_target_identity_service_account( - req, "foo@google.com")); - GPR_ASSERT(grpc_gcp_handshaker_req_set_target_name( - req, "google.example.library.service")); - GPR_ASSERT(grpc_gcp_handshaker_req_set_rpc_versions( - req, max_rpc_version_major, max_rpc_version_minor, min_rpc_version_major, - min_rpc_version_minor)); - GPR_ASSERT(grpc_gcp_handshaker_req_encode(req, &encoded_req)); - GPR_ASSERT(grpc_gcp_handshaker_req_decode(encoded_req, decoded_req)); - GPR_ASSERT(grpc_gcp_handshaker_req_equals(req, decoded_req)); - grpc_gcp_handshaker_req_destroy(req); - grpc_gcp_handshaker_req_destroy(decoded_req); - grpc_slice_unref(encoded_req); - - /* handshaker_req_server_start. */ - req = grpc_gcp_handshaker_req_create(SERVER_START_REQ); - decoded_req = grpc_gcp_handshaker_decoded_req_create(SERVER_START_REQ); - GPR_ASSERT(grpc_gcp_handshaker_req_add_application_protocol(req, "grpc")); - GPR_ASSERT(grpc_gcp_handshaker_req_add_application_protocol(req, "http2")); - GPR_ASSERT(grpc_gcp_handshaker_req_set_local_endpoint( - req, "2001:db8::8:800:200C:417a", 9876, grpc_gcp_NetworkProtocol_TCP)); - GPR_ASSERT(grpc_gcp_handshaker_req_set_remote_endpoint( - req, "2001:db8::bac5::fed0:84a2", 1234, grpc_gcp_NetworkProtocol_UDP)); - GPR_ASSERT( - grpc_gcp_handshaker_req_set_in_bytes(req, in_bytes, strlen(in_bytes))); - GPR_ASSERT(grpc_gcp_handshaker_req_param_add_record_protocol( - req, grpc_gcp_HandshakeProtocol_TLS, "ALTSRP_GCM_AES128")); - GPR_ASSERT(grpc_gcp_handshaker_req_param_add_local_identity_service_account( - req, grpc_gcp_HandshakeProtocol_TLS, "foo@google.com")); - GPR_ASSERT(grpc_gcp_handshaker_req_param_add_local_identity_hostname( - req, grpc_gcp_HandshakeProtocol_TLS, "yihuaz0.mtv.corp.google.com")); - GPR_ASSERT(grpc_gcp_handshaker_req_param_add_record_protocol( - req, grpc_gcp_HandshakeProtocol_ALTS, "ALTSRP_GCM_AES128")); - GPR_ASSERT(grpc_gcp_handshaker_req_param_add_local_identity_hostname( - req, grpc_gcp_HandshakeProtocol_ALTS, "www.amazon.com")); - GPR_ASSERT(grpc_gcp_handshaker_req_set_rpc_versions( - req, max_rpc_version_major, max_rpc_version_minor, min_rpc_version_major, - min_rpc_version_minor)); - - GPR_ASSERT(grpc_gcp_handshaker_req_encode(req, &encoded_req)); - GPR_ASSERT(grpc_gcp_handshaker_req_decode(encoded_req, decoded_req)); - GPR_ASSERT(grpc_gcp_handshaker_req_equals(req, decoded_req)); - grpc_gcp_handshaker_req_destroy(req); - grpc_gcp_handshaker_req_destroy(decoded_req); - grpc_slice_unref(encoded_req); - - /* handshaker_resp. */ - grpc_gcp_handshaker_resp* resp = grpc_gcp_handshaker_resp_create(); - grpc_gcp_handshaker_resp* decoded_resp = grpc_gcp_handshaker_resp_create(); - GPR_ASSERT(grpc_gcp_handshaker_resp_set_out_frames(resp, out_frames, - strlen(out_frames))); - GPR_ASSERT(grpc_gcp_handshaker_resp_set_bytes_consumed(resp, 1024)); - GPR_ASSERT(grpc_gcp_handshaker_resp_set_application_protocol(resp, "http")); - GPR_ASSERT( - grpc_gcp_handshaker_resp_set_record_protocol(resp, "ALTSRP_GCM_AES128")); - GPR_ASSERT( - grpc_gcp_handshaker_resp_set_key_data(resp, key_data, strlen(key_data))); - GPR_ASSERT(grpc_gcp_handshaker_resp_set_local_identity_hostname( - resp, "www.faceboook.com")); - GPR_ASSERT(grpc_gcp_handshaker_resp_set_peer_identity_hostname( - resp, "www.amazon.com")); - GPR_ASSERT(grpc_gcp_handshaker_resp_set_channel_open( - resp, false /* channel_open */)); - GPR_ASSERT(grpc_gcp_handshaker_resp_set_code(resp, 1023)); - GPR_ASSERT(grpc_gcp_handshaker_resp_set_details(resp, details)); - GPR_ASSERT(grpc_gcp_handshaker_resp_set_peer_rpc_versions( - resp, max_rpc_version_major, max_rpc_version_minor, min_rpc_version_major, - min_rpc_version_minor)); - grpc_slice encoded_resp; - GPR_ASSERT(grpc_gcp_handshaker_resp_encode(resp, &encoded_resp)); - GPR_ASSERT(grpc_gcp_handshaker_resp_decode(encoded_resp, decoded_resp)); - GPR_ASSERT(grpc_gcp_handshaker_resp_equals(resp, decoded_resp)); - grpc_gcp_handshaker_resp_destroy(resp); - grpc_gcp_handshaker_resp_destroy(decoded_resp); - grpc_slice_unref(encoded_resp); - /* Test invalid arguments. */ - GPR_ASSERT(!grpc_gcp_handshaker_req_set_in_bytes(nullptr, in_bytes, - strlen(in_bytes))); - GPR_ASSERT(!grpc_gcp_handshaker_req_param_add_record_protocol( - req, grpc_gcp_HandshakeProtocol_TLS, nullptr)); - GPR_ASSERT(!grpc_gcp_handshaker_req_param_add_local_identity_service_account( - nullptr, grpc_gcp_HandshakeProtocol_TLS, nullptr)); - GPR_ASSERT(!grpc_gcp_handshaker_resp_set_record_protocol(nullptr, nullptr)); -} diff --git a/test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc b/test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc index ecca04defa5..2ab73a26ff5 100644 --- a/test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc +++ b/test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc @@ -18,625 +18,146 @@ #include "test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.h" -const size_t kHandshakeProtocolNum = 3; - -grpc_gcp_handshaker_req* grpc_gcp_handshaker_decoded_req_create( - grpc_gcp_handshaker_req_type type) { - grpc_gcp_handshaker_req* req = - static_cast(gpr_zalloc(sizeof(*req))); - switch (type) { - case CLIENT_START_REQ: - req->has_client_start = true; - req->client_start.target_identities.funcs.decode = - decode_repeated_identity_cb; - req->client_start.application_protocols.funcs.decode = - decode_repeated_string_cb; - req->client_start.record_protocols.funcs.decode = - decode_repeated_string_cb; - req->client_start.local_identity.hostname.funcs.decode = - decode_string_or_bytes_cb; - req->client_start.local_identity.service_account.funcs.decode = - decode_string_or_bytes_cb; - req->client_start.local_endpoint.ip_address.funcs.decode = - decode_string_or_bytes_cb; - req->client_start.remote_endpoint.ip_address.funcs.decode = - decode_string_or_bytes_cb; - req->client_start.target_name.funcs.decode = decode_string_or_bytes_cb; - break; - case SERVER_START_REQ: - req->has_server_start = true; - req->server_start.application_protocols.funcs.decode = - &decode_repeated_string_cb; - for (size_t i = 0; i < kHandshakeProtocolNum; i++) { - req->server_start.handshake_parameters[i] - .value.local_identities.funcs.decode = &decode_repeated_identity_cb; - req->server_start.handshake_parameters[i] - .value.record_protocols.funcs.decode = &decode_repeated_string_cb; - } - req->server_start.in_bytes.funcs.decode = decode_string_or_bytes_cb; - req->server_start.local_endpoint.ip_address.funcs.decode = - decode_string_or_bytes_cb; - req->server_start.remote_endpoint.ip_address.funcs.decode = - decode_string_or_bytes_cb; - break; - case NEXT_REQ: - req->has_next = true; - break; - } - return req; -} - -bool grpc_gcp_handshaker_resp_set_application_protocol( - grpc_gcp_handshaker_resp* resp, const char* application_protocol) { - if (resp == nullptr || application_protocol == nullptr) { - gpr_log(GPR_ERROR, - "Invalid nullptr arguments to " - "handshaker_resp_set_application_protocol()."); - return false; - } - resp->has_result = true; - grpc_slice* slice = - create_slice(application_protocol, strlen(application_protocol)); - resp->result.application_protocol.arg = slice; - resp->result.application_protocol.funcs.encode = encode_string_or_bytes_cb; - return true; -} - -bool grpc_gcp_handshaker_resp_set_record_protocol( - grpc_gcp_handshaker_resp* resp, const char* record_protocol) { - if (resp == nullptr || record_protocol == nullptr) { - gpr_log(GPR_ERROR, - "Invalid nullptr arguments to " - "handshaker_resp_set_record_protocol()."); - return false; - } - resp->has_result = true; - grpc_slice* slice = create_slice(record_protocol, strlen(record_protocol)); - resp->result.record_protocol.arg = slice; - resp->result.record_protocol.funcs.encode = encode_string_or_bytes_cb; - return true; -} - -bool grpc_gcp_handshaker_resp_set_key_data(grpc_gcp_handshaker_resp* resp, - const char* key_data, size_t size) { - if (resp == nullptr || key_data == nullptr) { - gpr_log(GPR_ERROR, - "Invalid nullptr arguments to handshaker_resp_set_key_data()."); - return false; - } - resp->has_result = true; - grpc_slice* slice = create_slice(key_data, size); - resp->result.key_data.arg = slice; - resp->result.key_data.funcs.encode = encode_string_or_bytes_cb; - return true; -} - -static void set_identity_hostname(grpc_gcp_identity* identity, - const char* hostname) { - grpc_slice* slice = create_slice(hostname, strlen(hostname)); - identity->hostname.arg = slice; - identity->hostname.funcs.encode = encode_string_or_bytes_cb; -} - -static void set_identity_service_account(grpc_gcp_identity* identity, - const char* service_account) { - grpc_slice* slice = create_slice(service_account, strlen(service_account)); - identity->service_account.arg = slice; - identity->service_account.funcs.encode = encode_string_or_bytes_cb; -} - -bool grpc_gcp_handshaker_resp_set_local_identity_hostname( - grpc_gcp_handshaker_resp* resp, const char* hostname) { - if (resp == nullptr || hostname == nullptr) { - gpr_log(GPR_ERROR, - "Invalid nullptr arguments to " - "grpc_gcp_handshaker_resp_set_local_identity_hostname()."); - return false; - } - resp->has_result = true; - resp->result.has_local_identity = true; - set_identity_hostname(&resp->result.local_identity, hostname); - return true; -} - -bool grpc_gcp_handshaker_resp_set_local_identity_service_account( - grpc_gcp_handshaker_resp* resp, const char* service_account) { - if (resp == nullptr || service_account == nullptr) { - gpr_log(GPR_ERROR, - "Invalid nullptr arguments to " - "grpc_gcp_handshaker_resp_set_local_identity_service_account()."); - return false; - } - resp->has_result = true; - resp->result.has_local_identity = true; - set_identity_service_account(&resp->result.local_identity, service_account); - return true; -} - -bool grpc_gcp_handshaker_resp_set_peer_identity_hostname( - grpc_gcp_handshaker_resp* resp, const char* hostname) { - if (resp == nullptr || hostname == nullptr) { - gpr_log(GPR_ERROR, - "Invalid nullptr arguments to " - "grpc_gcp_handshaker_resp_set_peer_identity_hostname()."); - return false; - } - resp->has_result = true; - resp->result.has_peer_identity = true; - set_identity_hostname(&resp->result.peer_identity, hostname); - return true; -} - -bool grpc_gcp_handshaker_resp_set_peer_identity_service_account( - grpc_gcp_handshaker_resp* resp, const char* service_account) { - if (resp == nullptr || service_account == nullptr) { - gpr_log(GPR_ERROR, - "Invalid nullptr arguments to " - "grpc_gcp_handshaker_resp_set_peer_identity_service_account()."); - return false; - } - resp->has_result = true; - resp->result.has_peer_identity = true; - set_identity_service_account(&resp->result.peer_identity, service_account); - return true; -} - -bool grpc_gcp_handshaker_resp_set_channel_open(grpc_gcp_handshaker_resp* resp, - bool keep_channel_open) { - if (resp == nullptr) { - gpr_log(GPR_ERROR, - "Invalid nullptr argument to " - "grpc_gcp_handshaker_resp_set_channel_open()."); - return false; - } - resp->has_result = true; - resp->result.has_keep_channel_open = true; - resp->result.keep_channel_open = keep_channel_open; - return true; -} - -bool grpc_gcp_handshaker_resp_set_code(grpc_gcp_handshaker_resp* resp, - uint32_t code) { - if (resp == nullptr) { - gpr_log(GPR_ERROR, - "Invalid nullptr argument to grpc_gcp_handshaker_resp_set_code()."); - return false; - } - resp->has_status = true; - resp->status.has_code = true; - resp->status.code = code; - return true; -} - -bool grpc_gcp_handshaker_resp_set_details(grpc_gcp_handshaker_resp* resp, - const char* details) { - if (resp == nullptr || details == nullptr) { - gpr_log( - GPR_ERROR, - "Invalid nullptr arguments to grpc_gcp_handshaker_resp_set_details()."); - return false; - } - resp->has_status = true; - grpc_slice* slice = create_slice(details, strlen(details)); - resp->status.details.arg = slice; - resp->status.details.funcs.encode = encode_string_or_bytes_cb; - return true; -} - -bool grpc_gcp_handshaker_resp_set_out_frames(grpc_gcp_handshaker_resp* resp, - const char* out_frames, - size_t size) { - if (resp == nullptr || out_frames == nullptr) { - gpr_log(GPR_ERROR, - "Invalid nullptr arguments to " - "grpc_gcp_handshaker_resp_set_out_frames()."); - return false; - } - grpc_slice* slice = create_slice(out_frames, size); - resp->out_frames.arg = slice; - resp->out_frames.funcs.encode = encode_string_or_bytes_cb; - return true; -} - -bool grpc_gcp_handshaker_resp_set_bytes_consumed(grpc_gcp_handshaker_resp* resp, - int32_t bytes_consumed) { - if (resp == nullptr) { - gpr_log(GPR_ERROR, - "Invalid nullptr argument to " - "grpc_gcp_handshaker_resp_set_bytes_consumed()."); - return false; - } - resp->has_bytes_consumed = true; - resp->bytes_consumed = bytes_consumed; - return true; -} - bool grpc_gcp_handshaker_resp_set_peer_rpc_versions( - grpc_gcp_handshaker_resp* resp, uint32_t max_major, uint32_t max_minor, - uint32_t min_major, uint32_t min_minor) { + grpc_gcp_HandshakerResp* resp, upb_arena* arena, uint32_t max_major, + uint32_t max_minor, uint32_t min_major, uint32_t min_minor) { if (resp == nullptr) { gpr_log(GPR_ERROR, "Invalid nullptr argument to " "grpc_gcp_handshaker_resp_set_peer_rpc_versions()."); return false; } - resp->has_result = true; - resp->result.has_peer_rpc_versions = true; - grpc_gcp_rpc_protocol_versions* versions = &resp->result.peer_rpc_versions; - versions->has_max_rpc_version = true; - versions->has_min_rpc_version = true; - versions->max_rpc_version.has_major = true; - versions->max_rpc_version.has_minor = true; - versions->min_rpc_version.has_major = true; - versions->min_rpc_version.has_minor = true; - versions->max_rpc_version.major = max_major; - versions->max_rpc_version.minor = max_minor; - versions->min_rpc_version.major = min_major; - versions->min_rpc_version.minor = min_minor; + grpc_gcp_rpc_protocol_versions versions; + versions.max_rpc_version.major = max_major; + versions.max_rpc_version.minor = max_minor; + versions.min_rpc_version.major = min_major; + versions.min_rpc_version.minor = min_minor; + grpc_gcp_HandshakerResult* result = + grpc_gcp_HandshakerResp_mutable_result(resp, arena); + grpc_gcp_RpcProtocolVersions* upb_versions = + grpc_gcp_HandshakerResult_mutable_peer_rpc_versions(result, arena); + grpc_gcp_RpcProtocolVersions_assign_from_struct(upb_versions, arena, + &versions); return true; } -bool grpc_gcp_handshaker_resp_encode(grpc_gcp_handshaker_resp* resp, - grpc_slice* slice) { - if (resp == nullptr || slice == nullptr) { - gpr_log(GPR_ERROR, - "Invalid nullptr arguments to grpc_gcp_handshaker_resp_encode()."); - return false; +grpc_gcp_HandshakerReq* grpc_gcp_handshaker_req_decode(grpc_slice slice, + upb_arena* arena) { + size_t buf_size = GPR_SLICE_LENGTH(slice); + void* buf = upb_arena_malloc(arena, buf_size); + memcpy(buf, reinterpret_cast(GPR_SLICE_START_PTR(slice)), + buf_size); + grpc_gcp_HandshakerReq* resp = grpc_gcp_HandshakerReq_parse( + reinterpret_cast(buf), buf_size, arena); + if (!resp) { + gpr_log(GPR_ERROR, "grpc_gcp_HandshakerReq decode error"); + return nullptr; } - pb_ostream_t size_stream; - memset(&size_stream, 0, sizeof(pb_ostream_t)); - if (!pb_encode(&size_stream, grpc_gcp_HandshakerResp_fields, resp)) { - gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&size_stream)); - return false; - } - size_t encoded_length = size_stream.bytes_written; - *slice = grpc_slice_malloc(encoded_length); - pb_ostream_t output_stream = - pb_ostream_from_buffer(GRPC_SLICE_START_PTR(*slice), encoded_length); - if (!pb_encode(&output_stream, grpc_gcp_HandshakerResp_fields, resp)) { - gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&size_stream)); - return false; - } - return true; -} - -bool grpc_gcp_handshaker_req_decode(grpc_slice slice, - grpc_gcp_handshaker_req* req) { - if (req == nullptr) { - gpr_log(GPR_ERROR, - "Invalid nullptr argument to grpc_gcp_handshaker_req_decode()."); - return false; - } - pb_istream_t stream = pb_istream_from_buffer(GRPC_SLICE_START_PTR(slice), - GRPC_SLICE_LENGTH(slice)); - req->next.in_bytes.funcs.decode = decode_string_or_bytes_cb; - if (!pb_decode(&stream, grpc_gcp_HandshakerReq_fields, req)) { - gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&stream)); - return false; - } - return true; -} - -/* Check equality of a pair of grpc_slice fields. */ -static bool slice_equals(grpc_slice* l_slice, grpc_slice* r_slice) { - if (l_slice == nullptr && r_slice == nullptr) { - return true; - } - if (l_slice != nullptr && r_slice != nullptr) { - return grpc_slice_eq(*l_slice, *r_slice); - } - return false; + return resp; } /* Check equality of a pair of grpc_gcp_identity fields. */ -static bool handshaker_identity_equals(const grpc_gcp_identity* l_id, - const grpc_gcp_identity* r_id) { - if (!((l_id->hostname.arg != nullptr) != (r_id->hostname.arg != nullptr))) { - if (l_id->hostname.arg != nullptr) { - return slice_equals(static_cast(l_id->hostname.arg), - static_cast(r_id->hostname.arg)); - } - } else { +static bool handshaker_identity_equals(const grpc_gcp_Identity* l_id, + const grpc_gcp_Identity* r_id) { + if ((grpc_gcp_Identity_has_service_account(l_id) != + grpc_gcp_Identity_has_service_account(r_id)) || + (grpc_gcp_Identity_has_hostname(l_id) != + grpc_gcp_Identity_has_hostname(r_id))) { return false; } - if (!((l_id->service_account.arg != nullptr) != - (r_id->service_account.arg != nullptr))) { - if (l_id->service_account.arg != nullptr) { - return slice_equals(static_cast(l_id->service_account.arg), - static_cast(r_id->service_account.arg)); + + if (grpc_gcp_Identity_has_service_account(l_id)) { + if (!upb_strview_eql(grpc_gcp_Identity_service_account(l_id), + grpc_gcp_Identity_service_account(r_id))) { + return false; + } + } else if (grpc_gcp_Identity_has_hostname(l_id)) { + if (!upb_strview_eql(grpc_gcp_Identity_hostname(l_id), + grpc_gcp_Identity_hostname(r_id))) { + return false; } - } else { - return false; } return true; } static bool handshaker_rpc_versions_equals( - const grpc_gcp_rpc_protocol_versions* l_version, - const grpc_gcp_rpc_protocol_versions* r_version) { - bool result = true; - result &= - (l_version->max_rpc_version.major == r_version->max_rpc_version.major); - result &= - (l_version->max_rpc_version.minor == r_version->max_rpc_version.minor); - result &= - (l_version->min_rpc_version.major == r_version->min_rpc_version.major); - result &= - (l_version->min_rpc_version.minor == r_version->min_rpc_version.minor); - return result; -} - -/* Check equality of a pair of grpc_gcp_endpoint fields. */ -static bool handshaker_endpoint_equals(const grpc_gcp_endpoint* l_end, - const grpc_gcp_endpoint* r_end) { - bool result = true; - result &= (l_end->port == r_end->port); - result &= (l_end->protocol == r_end->protocol); - if (!((l_end->ip_address.arg != nullptr) != - (r_end->ip_address.arg != nullptr))) { - if (l_end->ip_address.arg != nullptr) { - result &= slice_equals(static_cast(l_end->ip_address.arg), - static_cast(r_end->ip_address.arg)); - } - } else { - return false; - } - return result; -} -/** - * Check if a specific repeated field (i.e., target) is contained in a repeated - * field list (i.e., head). - */ -static bool repeated_field_list_contains_identity( - const repeated_field* head, const repeated_field* target) { - repeated_field* field = const_cast(head); - while (field != nullptr) { - if (handshaker_identity_equals( - static_cast(field->data), - static_cast(target->data))) { - return true; - } - field = field->next; - } - return false; -} - -static bool repeated_field_list_contains_string(const repeated_field* head, - const repeated_field* target) { - repeated_field* field = const_cast(head); - while (field != nullptr) { - if (slice_equals((grpc_slice*)field->data, (grpc_slice*)target->data)) { - return true; - } - field = field->next; - } - return false; -} - -/* Return a length of repeated field list. */ -static size_t repeated_field_list_get_length(const repeated_field* head) { - repeated_field* field = const_cast(head); - size_t len = 0; - while (field != nullptr) { - len++; - field = field->next; - } - return len; -} - -/** - * Check if a pair of repeated field lists contain the same set of repeated - * fields. - */ -static bool repeated_field_list_equals_identity(const repeated_field* l_head, - const repeated_field* r_head) { - if (repeated_field_list_get_length(l_head) != - repeated_field_list_get_length(r_head)) { - return false; - } - repeated_field* field = const_cast(l_head); - repeated_field* head = const_cast(r_head); - while (field != nullptr) { - if (!repeated_field_list_contains_identity(head, field)) { - return false; - } - field = field->next; - } - return true; -} - -static bool repeated_field_list_equals_string(const repeated_field* l_head, - const repeated_field* r_head) { - if (repeated_field_list_get_length(l_head) != - repeated_field_list_get_length(r_head)) { - return false; - } - repeated_field* field = const_cast(l_head); - repeated_field* head = const_cast(r_head); - while (field != nullptr) { - if (!repeated_field_list_contains_string(head, field)) { - return false; - } - field = field->next; - } - return true; -} - -/* Check equality of a pair of ALTS client_start handshake requests. */ -bool grpc_gcp_handshaker_client_start_req_equals( - grpc_gcp_start_client_handshake_req* l_req, - grpc_gcp_start_client_handshake_req* r_req) { - bool result = true; - /* Compare handshake_security_protocol. */ - result &= - l_req->handshake_security_protocol == r_req->handshake_security_protocol; - /* Compare application_protocols, record_protocols, and target_identities. */ - result &= repeated_field_list_equals_string( - static_cast(l_req->application_protocols.arg), - static_cast(r_req->application_protocols.arg)); - result &= repeated_field_list_equals_string( - static_cast(l_req->record_protocols.arg), - static_cast(r_req->record_protocols.arg)); - result &= repeated_field_list_equals_identity( - static_cast(l_req->target_identities.arg), - static_cast(r_req->target_identities.arg)); - if ((l_req->has_local_identity ^ r_req->has_local_identity) | - (l_req->has_local_endpoint ^ r_req->has_local_endpoint) | - ((l_req->has_remote_endpoint ^ r_req->has_remote_endpoint)) | - (l_req->has_rpc_versions ^ r_req->has_rpc_versions)) { - return false; - } - /* Compare local_identity, local_endpoint, and remote_endpoint. */ - if (l_req->has_local_identity) { - result &= handshaker_identity_equals(&l_req->local_identity, - &r_req->local_identity); - } - if (l_req->has_local_endpoint) { - result &= handshaker_endpoint_equals(&l_req->local_endpoint, - &r_req->local_endpoint); - } - if (l_req->has_remote_endpoint) { - result &= handshaker_endpoint_equals(&l_req->remote_endpoint, - &r_req->remote_endpoint); - } - if (l_req->has_rpc_versions) { - result &= handshaker_rpc_versions_equals(&l_req->rpc_versions, - &r_req->rpc_versions); - } - return result; -} - -/* Check equality of a pair of ALTS server_start handshake requests. */ -bool grpc_gcp_handshaker_server_start_req_equals( - grpc_gcp_start_server_handshake_req* l_req, - grpc_gcp_start_server_handshake_req* r_req) { - bool result = true; - /* Compare application_protocols. */ - result &= repeated_field_list_equals_string( - static_cast(l_req->application_protocols.arg), - static_cast(r_req->application_protocols.arg)); - /* Compare handshake_parameters. */ - size_t i = 0, j = 0; - result &= - (l_req->handshake_parameters_count == r_req->handshake_parameters_count); - for (i = 0; i < l_req->handshake_parameters_count; i++) { - bool found = false; - for (j = 0; j < r_req->handshake_parameters_count; j++) { - if (l_req->handshake_parameters[i].key == - r_req->handshake_parameters[j].key) { - found = true; - result &= repeated_field_list_equals_string( - static_cast( - l_req->handshake_parameters[i].value.record_protocols.arg), - static_cast( - r_req->handshake_parameters[j].value.record_protocols.arg)); - result &= repeated_field_list_equals_identity( - static_cast( - l_req->handshake_parameters[i].value.local_identities.arg), - static_cast( - r_req->handshake_parameters[j].value.local_identities.arg)); - } - } - if (!found) { - return false; - } - } - /* Compare in_bytes, local_endpoint, remote_endpoint. */ - result &= slice_equals(static_cast(l_req->in_bytes.arg), - static_cast(r_req->in_bytes.arg)); - if ((l_req->has_local_endpoint ^ r_req->has_local_endpoint) | - (l_req->has_remote_endpoint ^ r_req->has_remote_endpoint) | - (l_req->has_rpc_versions ^ r_req->has_rpc_versions)) - return false; - if (l_req->has_local_endpoint) { - result &= handshaker_endpoint_equals(&l_req->local_endpoint, - &r_req->local_endpoint); - } - if (l_req->has_remote_endpoint) { - result &= handshaker_endpoint_equals(&l_req->remote_endpoint, - &r_req->remote_endpoint); - } - if (l_req->has_rpc_versions) { - result &= handshaker_rpc_versions_equals(&l_req->rpc_versions, - &r_req->rpc_versions); - } - return result; -} - -/* Check equality of a pair of ALTS handshake requests. */ -bool grpc_gcp_handshaker_req_equals(grpc_gcp_handshaker_req* l_req, - grpc_gcp_handshaker_req* r_req) { - if (l_req->has_next && r_req->has_next) { - return slice_equals(static_cast(l_req->next.in_bytes.arg), - static_cast(r_req->next.in_bytes.arg)); - } else if (l_req->has_client_start && r_req->has_client_start) { - return grpc_gcp_handshaker_client_start_req_equals(&l_req->client_start, - &r_req->client_start); - } else if (l_req->has_server_start && r_req->has_server_start) { - return grpc_gcp_handshaker_server_start_req_equals(&l_req->server_start, - &r_req->server_start); - } - return false; -} - -/* Check equality of a pair of ALTS handshake results. */ -bool grpc_gcp_handshaker_resp_result_equals( - grpc_gcp_handshaker_result* l_result, - grpc_gcp_handshaker_result* r_result) { - bool result = true; - /* Compare application_protocol, record_protocol, and key_data. */ - result &= slice_equals( - static_cast(l_result->application_protocol.arg), - static_cast(r_result->application_protocol.arg)); - result &= - slice_equals(static_cast(l_result->record_protocol.arg), - static_cast(r_result->record_protocol.arg)); - result &= slice_equals(static_cast(l_result->key_data.arg), - static_cast(r_result->key_data.arg)); - /* Compare local_identity, peer_identity, and keep_channel_open. */ - if ((l_result->has_local_identity ^ r_result->has_local_identity) | - (l_result->has_peer_identity ^ r_result->has_peer_identity) | - (l_result->has_peer_rpc_versions ^ r_result->has_peer_rpc_versions)) { - return false; - } - if (l_result->has_local_identity) { - result &= handshaker_identity_equals(&l_result->local_identity, - &r_result->local_identity); - } - if (l_result->has_peer_identity) { - result &= handshaker_identity_equals(&l_result->peer_identity, - &r_result->peer_identity); - } - if (l_result->has_peer_rpc_versions) { - result &= handshaker_rpc_versions_equals(&l_result->peer_rpc_versions, - &r_result->peer_rpc_versions); - } - result &= (l_result->keep_channel_open == r_result->keep_channel_open); - return result; + const grpc_gcp_RpcProtocolVersions* l_version, + const grpc_gcp_RpcProtocolVersions* r_version) { + const grpc_gcp_RpcProtocolVersions_Version* l_maxver = + grpc_gcp_RpcProtocolVersions_max_rpc_version(l_version); + const grpc_gcp_RpcProtocolVersions_Version* r_maxver = + grpc_gcp_RpcProtocolVersions_max_rpc_version(r_version); + const grpc_gcp_RpcProtocolVersions_Version* l_minver = + grpc_gcp_RpcProtocolVersions_min_rpc_version(l_version); + const grpc_gcp_RpcProtocolVersions_Version* r_minver = + grpc_gcp_RpcProtocolVersions_min_rpc_version(r_version); + return (grpc_gcp_RpcProtocolVersions_Version_major(l_maxver) == + grpc_gcp_RpcProtocolVersions_Version_major(r_maxver)) && + (grpc_gcp_RpcProtocolVersions_Version_minor(l_maxver) == + grpc_gcp_RpcProtocolVersions_Version_minor(r_maxver)) && + (grpc_gcp_RpcProtocolVersions_Version_major(l_minver) == + grpc_gcp_RpcProtocolVersions_Version_major(r_minver)) && + (grpc_gcp_RpcProtocolVersions_Version_minor(l_minver) == + grpc_gcp_RpcProtocolVersions_Version_minor(r_minver)); } /* Check equality of a pair of ALTS handshake responses. */ -bool grpc_gcp_handshaker_resp_equals(grpc_gcp_handshaker_resp* l_resp, - grpc_gcp_handshaker_resp* r_resp) { - bool result = true; - /* Compare out_frames and bytes_consumed. */ - result &= slice_equals(static_cast(l_resp->out_frames.arg), - static_cast(r_resp->out_frames.arg)); - result &= (l_resp->bytes_consumed == r_resp->bytes_consumed); - /* Compare result and status. */ - if ((l_resp->has_result ^ r_resp->has_result) | - (l_resp->has_status ^ r_resp->has_status)) { +bool grpc_gcp_handshaker_resp_equals(const grpc_gcp_HandshakerResp* l_resp, + const grpc_gcp_HandshakerResp* r_resp) { + return upb_strview_eql(grpc_gcp_HandshakerResp_out_frames(l_resp), + grpc_gcp_HandshakerResp_out_frames(r_resp)) && + (grpc_gcp_HandshakerResp_bytes_consumed(l_resp) == + grpc_gcp_HandshakerResp_bytes_consumed(l_resp)) && + grpc_gcp_handshaker_resp_result_equals( + grpc_gcp_HandshakerResp_result(l_resp), + grpc_gcp_HandshakerResp_result(r_resp)) && + grpc_gcp_handshaker_resp_status_equals( + grpc_gcp_HandshakerResp_status(l_resp), + grpc_gcp_HandshakerResp_status(r_resp)); +} + +/* This method checks equality of two handshaker response results. */ +bool grpc_gcp_handshaker_resp_result_equals( + const grpc_gcp_HandshakerResult* l_result, + const grpc_gcp_HandshakerResult* r_result) { + if (l_result == nullptr && r_result == nullptr) { + return true; + } else if ((l_result != nullptr && r_result == nullptr) || + (l_result == nullptr && r_result != nullptr)) { return false; } - if (l_resp->has_result) { - result &= grpc_gcp_handshaker_resp_result_equals(&l_resp->result, - &r_resp->result); - } - if (l_resp->has_status) { - result &= (l_resp->status.code == r_resp->status.code); - result &= - slice_equals(static_cast(l_resp->status.details.arg), - static_cast(r_resp->status.details.arg)); - } - return result; + return upb_strview_eql( + grpc_gcp_HandshakerResult_application_protocol(l_result), + grpc_gcp_HandshakerResult_application_protocol(r_result)) && + upb_strview_eql(grpc_gcp_HandshakerResult_record_protocol(l_result), + grpc_gcp_HandshakerResult_record_protocol(r_result)) && + upb_strview_eql(grpc_gcp_HandshakerResult_key_data(l_result), + grpc_gcp_HandshakerResult_key_data(r_result)) && + handshaker_identity_equals( + grpc_gcp_HandshakerResult_peer_identity(l_result), + grpc_gcp_HandshakerResult_peer_identity(r_result)) && + handshaker_identity_equals( + grpc_gcp_HandshakerResult_local_identity(l_result), + grpc_gcp_HandshakerResult_local_identity(r_result)) && + (grpc_gcp_HandshakerResult_keep_channel_open(l_result) == + grpc_gcp_HandshakerResult_keep_channel_open(r_result)) && + handshaker_rpc_versions_equals( + grpc_gcp_HandshakerResult_peer_rpc_versions(l_result), + grpc_gcp_HandshakerResult_peer_rpc_versions(r_result)); +} + +/* This method checks equality of two handshaker response statuses. */ +bool grpc_gcp_handshaker_resp_status_equals( + const grpc_gcp_HandshakerStatus* l_status, + const grpc_gcp_HandshakerStatus* r_status) { + if (l_status == nullptr && r_status == nullptr) { + return true; + } else if ((l_status != nullptr && r_status == nullptr) || + (l_status == nullptr && r_status != nullptr)) { + return false; + } + return (grpc_gcp_HandshakerStatus_code(l_status) == + grpc_gcp_HandshakerStatus_code(r_status)) && + upb_strview_eql(grpc_gcp_HandshakerStatus_details(l_status), + grpc_gcp_HandshakerStatus_details(r_status)); } diff --git a/test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.h b/test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.h index 2fcbb4ea99a..d0a7cc836cd 100644 --- a/test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.h +++ b/test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.h @@ -19,9 +19,8 @@ #ifndef GRPC_TEST_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_TEST_LIB_H #define GRPC_TEST_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_TEST_LIB_H -#include "src/core/tsi/alts/handshaker/alts_handshaker_service_api.h" -#include "src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h" #include "src/core/tsi/alts/handshaker/transport_security_common_api.h" +#include "src/proto/grpc/gcp/handshaker.upb.h" /** * The first part of this file contains function signatures for de-serializing @@ -30,114 +29,27 @@ * service. */ -/** - * This method creates a ALTS handshaker request that is used to hold - * de-serialized result. - */ -grpc_gcp_handshaker_req* grpc_gcp_handshaker_decoded_req_create( - grpc_gcp_handshaker_req_type type); - -/* This method de-serializes a ALTS handshaker request. */ -bool grpc_gcp_handshaker_req_decode(grpc_slice slice, - grpc_gcp_handshaker_req* req); - -/* This method serializes a ALTS handshaker response. */ -bool grpc_gcp_handshaker_resp_encode(grpc_gcp_handshaker_resp* resp, - grpc_slice* slice); - -/* This method sets application protocol of ALTS handshaker response. */ -bool grpc_gcp_handshaker_resp_set_application_protocol( - grpc_gcp_handshaker_resp* resp, const char* application_protocol); - -/* This method sets record protocol of ALTS handshaker response. */ -bool grpc_gcp_handshaker_resp_set_record_protocol( - grpc_gcp_handshaker_resp* resp, const char* record_protocol); - -/* This method sets key_data of ALTS handshaker response. */ -bool grpc_gcp_handshaker_resp_set_key_data(grpc_gcp_handshaker_resp* resp, - const char* key_data, size_t size); - -/* This method sets local identity's hostname for ALTS handshaker response. */ -bool grpc_gcp_handshaker_resp_set_local_identity_hostname( - grpc_gcp_handshaker_resp* resp, const char* hostname); - -/** - * This method sets local identity's service account for ALTS handshaker - * response. - */ -bool grpc_gcp_handshaker_resp_set_local_identity_service_account( - grpc_gcp_handshaker_resp* resp, const char* service_account); - -/* This method sets peer identity's hostname for ALTS handshaker response. */ -bool grpc_gcp_handshaker_resp_set_peer_identity_hostname( - grpc_gcp_handshaker_resp* resp, const char* hostname); - -/** - * This method sets peer identity's service account for ALTS handshaker - * response. - */ -bool grpc_gcp_handshaker_resp_set_peer_identity_service_account( - grpc_gcp_handshaker_resp* resp, const char* service_account); - -/* This method sets keep_channel_open for ALTS handshaker response. */ -bool grpc_gcp_handshaker_resp_set_channel_open(grpc_gcp_handshaker_resp* resp, - bool keep_channel_open); - -/* This method sets code for ALTS handshaker response. */ -bool grpc_gcp_handshaker_resp_set_code(grpc_gcp_handshaker_resp* resp, - uint32_t code); - -/* This method sets details for ALTS handshaker response. */ -bool grpc_gcp_handshaker_resp_set_details(grpc_gcp_handshaker_resp* resp, - const char* details); - -/* This method sets out_frames for ALTS handshaker response. */ -bool grpc_gcp_handshaker_resp_set_out_frames(grpc_gcp_handshaker_resp* resp, - const char* out_frames, - size_t size); - /* This method sets peer_rpc_versions for ALTS handshaker response. */ bool grpc_gcp_handshaker_resp_set_peer_rpc_versions( - grpc_gcp_handshaker_resp* resp, uint32_t max_major, uint32_t max_minor, - uint32_t min_major, uint32_t min_minor); - -/* This method sets bytes_consumed for ALTS handshaker response. */ -bool grpc_gcp_handshaker_resp_set_bytes_consumed(grpc_gcp_handshaker_resp* resp, - int32_t bytes_consumed); - -/* This method serializes ALTS handshaker response. */ -bool grpc_gcp_handshaker_resp_encode(grpc_gcp_handshaker_resp* resp, - grpc_slice* slice); + grpc_gcp_HandshakerResp* resp, upb_arena* arena, uint32_t max_major, + uint32_t max_minor, uint32_t min_major, uint32_t min_minor); /* This method de-serializes ALTS handshaker request. */ -bool grpc_gcp_handshaker_req_decode(grpc_slice slice, - grpc_gcp_handshaker_req* req); +grpc_gcp_HandshakerReq* grpc_gcp_handshaker_req_decode(grpc_slice slice, + upb_arena* arena); -/** - * The second part contains function signatures for checking equality of a pair - * of ALTS handshake requests/responses. - */ - -/* This method checks equality of two client_start handshaker requests. */ -bool grpc_gcp_handshaker_client_start_req_equals( - grpc_gcp_start_client_handshake_req* l_req, - grpc_gcp_start_client_handshake_req* r_req); - -/* This method checks equality of two server_start handshaker requests. */ -bool grpc_gcp_handshaker_server_start_req_equals( - grpc_gcp_start_server_handshake_req* l_req, - grpc_gcp_start_server_handshake_req* r_req); - -/* This method checks equality of two ALTS handshaker requests. */ -bool grpc_gcp_handshaker_req_equals(grpc_gcp_handshaker_req* l_req, - grpc_gcp_handshaker_req* r_req); +/* This method checks equality of two ALTS handshaker responses. */ +bool grpc_gcp_handshaker_resp_equals(const grpc_gcp_HandshakerResp* l_resp, + const grpc_gcp_HandshakerResp* r_resp); /* This method checks equality of two handshaker response results. */ bool grpc_gcp_handshaker_resp_result_equals( - grpc_gcp_handshaker_result* l_result, grpc_gcp_handshaker_result* r_result); + const grpc_gcp_HandshakerResult* l_result, + const grpc_gcp_HandshakerResult* r_result); -/* This method checks equality of two ALTS handshaker responses. */ -bool grpc_gcp_handshaker_resp_equals(grpc_gcp_handshaker_resp* l_resp, - grpc_gcp_handshaker_resp* r_resp); +/* This method checks equality of two handshaker response statuses. */ +bool grpc_gcp_handshaker_resp_status_equals( + const grpc_gcp_HandshakerStatus* l_status, + const grpc_gcp_HandshakerStatus* r_status); #endif // GRPC_TEST_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_TEST_LIB_H diff --git a/test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc b/test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc index 316ff138160..37731379f22 100644 --- a/test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc +++ b/test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc @@ -110,55 +110,64 @@ static void wait(notification* n) { */ static grpc_byte_buffer* generate_handshaker_response( alts_handshaker_response_type type) { - grpc_gcp_handshaker_resp* resp = grpc_gcp_handshaker_resp_create(); - GPR_ASSERT(grpc_gcp_handshaker_resp_set_code(resp, 0)); + upb::Arena arena; + grpc_gcp_HandshakerResult* result; + grpc_gcp_Identity* peer_identity; + grpc_gcp_HandshakerResp* resp = grpc_gcp_HandshakerResp_new(arena.ptr()); + grpc_gcp_HandshakerStatus* status = + grpc_gcp_HandshakerResp_mutable_status(resp, arena.ptr()); + grpc_gcp_HandshakerStatus_set_code(status, 0); switch (type) { case INVALID: break; case CLIENT_START: case SERVER_START: - GPR_ASSERT(grpc_gcp_handshaker_resp_set_out_frames( - resp, ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME, - strlen(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME))); + grpc_gcp_HandshakerResp_set_out_frames( + resp, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME)); break; case CLIENT_NEXT: - GPR_ASSERT(grpc_gcp_handshaker_resp_set_out_frames( - resp, ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME, - strlen(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME))); - GPR_ASSERT(grpc_gcp_handshaker_resp_set_peer_identity_service_account( - resp, ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY)); - GPR_ASSERT(grpc_gcp_handshaker_resp_set_bytes_consumed( - resp, strlen(ALTS_TSI_HANDSHAKER_TEST_CONSUMED_BYTES))); - GPR_ASSERT(grpc_gcp_handshaker_resp_set_key_data( - resp, ALTS_TSI_HANDSHAKER_TEST_KEY_DATA, - strlen(ALTS_TSI_HANDSHAKER_TEST_KEY_DATA))); + grpc_gcp_HandshakerResp_set_out_frames( + resp, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME)); + grpc_gcp_HandshakerResp_set_bytes_consumed( + resp, strlen(ALTS_TSI_HANDSHAKER_TEST_CONSUMED_BYTES)); + result = grpc_gcp_HandshakerResp_mutable_result(resp, arena.ptr()); + peer_identity = + grpc_gcp_HandshakerResult_mutable_peer_identity(result, arena.ptr()); + grpc_gcp_Identity_set_service_account( + peer_identity, + upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY)); + grpc_gcp_HandshakerResult_set_key_data( + result, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_KEY_DATA)); GPR_ASSERT(grpc_gcp_handshaker_resp_set_peer_rpc_versions( - resp, ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MAJOR, + resp, arena.ptr(), ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MAJOR, ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MINOR, ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MAJOR, ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MINOR)); break; case SERVER_NEXT: - GPR_ASSERT(grpc_gcp_handshaker_resp_set_peer_identity_service_account( - resp, ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY)); - GPR_ASSERT(grpc_gcp_handshaker_resp_set_bytes_consumed( - resp, strlen(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME))); - GPR_ASSERT(grpc_gcp_handshaker_resp_set_key_data( - resp, ALTS_TSI_HANDSHAKER_TEST_KEY_DATA, - strlen(ALTS_TSI_HANDSHAKER_TEST_KEY_DATA))); + grpc_gcp_HandshakerResp_set_bytes_consumed( + resp, strlen(ALTS_TSI_HANDSHAKER_TEST_OUT_FRAME)); + result = grpc_gcp_HandshakerResp_mutable_result(resp, arena.ptr()); + peer_identity = + grpc_gcp_HandshakerResult_mutable_peer_identity(result, arena.ptr()); + grpc_gcp_Identity_set_service_account( + peer_identity, + upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_PEER_IDENTITY)); + grpc_gcp_HandshakerResult_set_key_data( + result, upb_strview_makez(ALTS_TSI_HANDSHAKER_TEST_KEY_DATA)); GPR_ASSERT(grpc_gcp_handshaker_resp_set_peer_rpc_versions( - resp, ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MAJOR, + resp, arena.ptr(), ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MAJOR, ALTS_TSI_HANDSHAKER_TEST_MAX_RPC_VERSION_MINOR, ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MAJOR, ALTS_TSI_HANDSHAKER_TEST_MIN_RPC_VERSION_MINOR)); break; case FAILED: - GPR_ASSERT( - grpc_gcp_handshaker_resp_set_code(resp, 3 /* INVALID ARGUMENT */)); + grpc_gcp_HandshakerStatus_set_code(status, 3 /* INVALID ARGUMENT */); break; } - grpc_slice slice; - GPR_ASSERT(grpc_gcp_handshaker_resp_encode(resp, &slice)); + size_t buf_len; + char* buf = grpc_gcp_HandshakerResp_serialize(resp, arena.ptr(), &buf_len); + grpc_slice slice = gpr_slice_from_copied_buffer(buf, buf_len); if (type == INVALID) { grpc_slice bad_slice = grpc_slice_split_head(&slice, GRPC_SLICE_LENGTH(slice) - 1); @@ -169,7 +178,6 @@ static grpc_byte_buffer* generate_handshaker_response( grpc_byte_buffer* buffer = grpc_raw_byte_buffer_create(&slice, 1 /* number of slices */); grpc_slice_unref(slice); - grpc_gcp_handshaker_resp_destroy(resp); return buffer; } diff --git a/test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc b/test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc index 8d75d35368d..9b4c9f87d3e 100644 --- a/test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc +++ b/test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc @@ -36,18 +36,20 @@ static void convert_to_tsi_result_test() { } static void deserialize_response_test() { - grpc_gcp_handshaker_resp* resp = grpc_gcp_handshaker_resp_create(); - GPR_ASSERT(grpc_gcp_handshaker_resp_set_out_frames( - resp, ALTS_TSI_UTILS_TEST_OUT_FRAME, - strlen(ALTS_TSI_UTILS_TEST_OUT_FRAME))); - grpc_slice slice; - GPR_ASSERT(grpc_gcp_handshaker_resp_encode(resp, &slice)); + upb::Arena arena; + grpc_gcp_HandshakerResp* resp = grpc_gcp_HandshakerResp_new(arena.ptr()); + grpc_gcp_HandshakerResp_set_out_frames( + resp, upb_strview_makez(ALTS_TSI_UTILS_TEST_OUT_FRAME)); + size_t buf_len; + char* buf = grpc_gcp_HandshakerResp_serialize(resp, arena.ptr(), &buf_len); + grpc_slice slice = grpc_slice_from_copied_buffer(buf, buf_len); /* Valid serialization. */ + upb::Arena arena2; grpc_byte_buffer* buffer = grpc_raw_byte_buffer_create(&slice, 1 /* number of slices */); - grpc_gcp_handshaker_resp* decoded_resp = - alts_tsi_utils_deserialize_response(buffer); + grpc_gcp_HandshakerResp* decoded_resp = + alts_tsi_utils_deserialize_response(buffer, arena2.ptr()); GPR_ASSERT(grpc_gcp_handshaker_resp_equals(resp, decoded_resp)); grpc_byte_buffer_destroy(buffer); @@ -55,14 +57,13 @@ static void deserialize_response_test() { grpc_slice bad_slice = grpc_slice_split_head(&slice, GRPC_SLICE_LENGTH(slice) - 1); buffer = grpc_raw_byte_buffer_create(&bad_slice, 1 /* number of slices */); - GPR_ASSERT(alts_tsi_utils_deserialize_response(buffer) == nullptr); + GPR_ASSERT(alts_tsi_utils_deserialize_response(buffer, arena2.ptr()) == + nullptr); /* Clean up. */ grpc_slice_unref(slice); grpc_slice_unref(bad_slice); grpc_byte_buffer_destroy(buffer); - grpc_gcp_handshaker_resp_destroy(resp); - grpc_gcp_handshaker_resp_destroy(decoded_resp); } int main(int argc, char** argv) { diff --git a/test/core/tsi/alts/handshaker/transport_security_common_api_test.cc b/test/core/tsi/alts/handshaker/transport_security_common_api_test.cc index 6ff1357c270..a2c3d48ca53 100644 --- a/test/core/tsi/alts/handshaker/transport_security_common_api_test.cc +++ b/test/core/tsi/alts/handshaker/transport_security_common_api_test.cc @@ -31,25 +31,17 @@ static bool grpc_gcp_rpc_protocol_versions_equal( grpc_gcp_rpc_protocol_versions* l_versions, grpc_gcp_rpc_protocol_versions* r_versions) { GPR_ASSERT(l_versions != nullptr && r_versions != nullptr); - if ((l_versions->has_max_rpc_version ^ r_versions->has_max_rpc_version) | - (l_versions->has_min_rpc_version ^ r_versions->has_min_rpc_version)) { + if ((l_versions->max_rpc_version.major != + r_versions->max_rpc_version.major) || + (l_versions->max_rpc_version.minor != + r_versions->max_rpc_version.minor)) { return false; } - if (l_versions->has_max_rpc_version) { - if ((l_versions->max_rpc_version.major != - r_versions->max_rpc_version.major) || - (l_versions->max_rpc_version.minor != - r_versions->max_rpc_version.minor)) { - return false; - } - } - if (l_versions->has_min_rpc_version) { - if ((l_versions->min_rpc_version.major != - r_versions->min_rpc_version.major) || - (l_versions->min_rpc_version.minor != - r_versions->min_rpc_version.minor)) { - return false; - } + if ((l_versions->min_rpc_version.major != + r_versions->min_rpc_version.major) || + (l_versions->min_rpc_version.minor != + r_versions->min_rpc_version.minor)) { + return false; } return true; } @@ -61,25 +53,14 @@ static void test_success() { &version, kMaxRpcVersionMajor, kMaxRpcVersionMinor)); GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_min( &version, kMinRpcVersionMajor, kMinRpcVersionMinor)); - /* Serializes to raw bytes. */ - size_t encoded_length = - grpc_gcp_rpc_protocol_versions_encode_length(&version); - uint8_t* encoded_bytes = static_cast(gpr_malloc(encoded_length)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_encode_to_raw_bytes( - &version, encoded_bytes, encoded_length)); - grpc_slice encoded_slice; /* Serializes to grpc slice. */ + grpc_slice encoded_slice; GPR_ASSERT(grpc_gcp_rpc_protocol_versions_encode(&version, &encoded_slice)); - /* Checks serialized raw bytes and serialized grpc slice have same content. */ - GPR_ASSERT(encoded_length == GRPC_SLICE_LENGTH(encoded_slice)); - GPR_ASSERT(memcmp(encoded_bytes, GRPC_SLICE_START_PTR(encoded_slice), - encoded_length) == 0); /* Deserializes and compares with the original version. */ GPR_ASSERT( grpc_gcp_rpc_protocol_versions_decode(encoded_slice, &decoded_version)); GPR_ASSERT(grpc_gcp_rpc_protocol_versions_equal(&version, &decoded_version)); grpc_slice_unref(encoded_slice); - gpr_free(encoded_bytes); } static void test_failure() { @@ -90,24 +71,14 @@ static void test_failure() { nullptr, kMaxRpcVersionMajor, kMaxRpcVersionMinor)); GPR_ASSERT(!grpc_gcp_rpc_protocol_versions_set_min( nullptr, kMinRpcVersionMajor, kMinRpcVersionMinor)); - GPR_ASSERT(grpc_gcp_rpc_protocol_versions_encode_length(nullptr) == 0); GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_max( &version, kMaxRpcVersionMajor, kMaxRpcVersionMinor)); GPR_ASSERT(grpc_gcp_rpc_protocol_versions_set_min( &version, kMinRpcVersionMajor, kMinRpcVersionMinor)); - size_t encoded_length = - grpc_gcp_rpc_protocol_versions_encode_length(&version); - uint8_t* encoded_bytes = static_cast(gpr_malloc(encoded_length)); - GPR_ASSERT(!grpc_gcp_rpc_protocol_versions_encode_to_raw_bytes( - nullptr, encoded_bytes, encoded_length)); - GPR_ASSERT(!grpc_gcp_rpc_protocol_versions_encode_to_raw_bytes( - &version, nullptr, encoded_length)); - GPR_ASSERT(!grpc_gcp_rpc_protocol_versions_encode_to_raw_bytes( - &version, encoded_bytes, 0)); GPR_ASSERT(!grpc_gcp_rpc_protocol_versions_encode(nullptr, &encoded_slice)); GPR_ASSERT(!grpc_gcp_rpc_protocol_versions_encode(&version, nullptr)); GPR_ASSERT(!grpc_gcp_rpc_protocol_versions_decode(encoded_slice, nullptr)); - /* Test for nanopb decode. */ + /* Test for upb decode. */ GPR_ASSERT(grpc_gcp_rpc_protocol_versions_encode(&version, &encoded_slice)); grpc_slice bad_slice = grpc_slice_split_head( &encoded_slice, GRPC_SLICE_LENGTH(encoded_slice) - 1); @@ -115,7 +86,6 @@ static void test_failure() { GPR_ASSERT( !grpc_gcp_rpc_protocol_versions_decode(bad_slice, &decoded_version)); grpc_slice_unref(bad_slice); - gpr_free(encoded_bytes); } static void test_copy() { diff --git a/tools/distrib/check_nanopb_output.sh b/tools/distrib/check_nanopb_output.sh index 7317e842b89..573e02e98ff 100755 --- a/tools/distrib/check_nanopb_output.sh +++ b/tools/distrib/check_nanopb_output.sh @@ -15,7 +15,6 @@ set -ex -readonly NANOPB_ALTS_TMP_OUTPUT="$(mktemp -d)" readonly NANOPB_HEALTH_TMP_OUTPUT="$(mktemp -d)" readonly NANOPB_TMP_OUTPUT="$(mktemp -d)" readonly PROTOBUF_INSTALL_PREFIX="$(mktemp -d)" @@ -58,29 +57,3 @@ for NANOPB_OUTPUT_FILE in $NANOPB_HEALTH_TMP_OUTPUT/*.pb.*; do exit 2 fi done - -# -# Checks for handshaker.proto and transport_security_common.proto -# -readonly HANDSHAKER_GRPC_OUTPUT_PATH='src/core/tsi/alts/handshaker' -# nanopb-compile the proto to a temp location -./tools/codegen/core/gen_nano_proto.sh \ - src/core/tsi/alts/handshaker/proto/handshaker.proto \ - "$NANOPB_ALTS_TMP_OUTPUT" \ - "$HANDSHAKER_GRPC_OUTPUT_PATH" -./tools/codegen/core/gen_nano_proto.sh \ - src/core/tsi/alts/handshaker/proto/transport_security_common.proto \ - "$NANOPB_ALTS_TMP_OUTPUT" \ - "$HANDSHAKER_GRPC_OUTPUT_PATH" -./tools/codegen/core/gen_nano_proto.sh \ - src/core/tsi/alts/handshaker/proto/altscontext.proto \ - "$NANOPB_ALTS_TMP_OUTPUT" \ - "$HANDSHAKER_GRPC_OUTPUT_PATH" - -# compare outputs to checked compiled code -for NANOPB_OUTPUT_FILE in $NANOPB_ALTS_TMP_OUTPUT/*.pb.*; do - if ! diff "$NANOPB_OUTPUT_FILE" "src/core/tsi/alts/handshaker/$(basename $NANOPB_OUTPUT_FILE)"; then - echo "Outputs differ: $NANOPB_ALTS_TMP_OUTPUT vs $HANDSHAKER_GRPC_OUTPUT_PATH" - exit 2 - fi -done diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 4579af50ee9..5180fab8635 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1116,6 +1116,12 @@ src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ src/core/ext/upb-generated/google/protobuf/wrappers.upb.h \ src/core/ext/upb-generated/google/rpc/status.upb.c \ src/core/ext/upb-generated/google/rpc/status.upb.h \ +src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c \ +src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h \ +src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c \ +src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h \ +src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c \ +src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h \ src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h \ src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ @@ -1598,10 +1604,6 @@ src/core/tsi/alts/frame_protector/frame_handler.cc \ src/core/tsi/alts/frame_protector/frame_handler.h \ src/core/tsi/alts/handshaker/alts_handshaker_client.cc \ src/core/tsi/alts/handshaker/alts_handshaker_client.h \ -src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc \ -src/core/tsi/alts/handshaker/alts_handshaker_service_api.h \ -src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc \ -src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h \ src/core/tsi/alts/handshaker/alts_shared_resource.cc \ src/core/tsi/alts/handshaker/alts_shared_resource.h \ src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc \ @@ -1609,12 +1611,6 @@ src/core/tsi/alts/handshaker/alts_tsi_handshaker.h \ src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h \ src/core/tsi/alts/handshaker/alts_tsi_utils.cc \ src/core/tsi/alts/handshaker/alts_tsi_utils.h \ -src/core/tsi/alts/handshaker/altscontext.pb.c \ -src/core/tsi/alts/handshaker/altscontext.pb.h \ -src/core/tsi/alts/handshaker/handshaker.pb.c \ -src/core/tsi/alts/handshaker/handshaker.pb.h \ -src/core/tsi/alts/handshaker/transport_security_common.pb.c \ -src/core/tsi/alts/handshaker/transport_security_common.pb.h \ src/core/tsi/alts/handshaker/transport_security_common_api.cc \ src/core/tsi/alts/handshaker/transport_security_common_api.h \ src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc \ @@ -1646,13 +1642,6 @@ src/core/tsi/transport_security.h \ src/core/tsi/transport_security_grpc.cc \ src/core/tsi/transport_security_grpc.h \ src/core/tsi/transport_security_interface.h \ -third_party/nanopb/pb.h \ -third_party/nanopb/pb_common.c \ -third_party/nanopb/pb_common.h \ -third_party/nanopb/pb_decode.c \ -third_party/nanopb/pb_decode.h \ -third_party/nanopb/pb_encode.c \ -third_party/nanopb/pb_encode.h \ third_party/upb/upb/decode.c \ third_party/upb/upb/decode.h \ third_party/upb/upb/encode.c \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 60ba4d7fa18..36e6ef1d48c 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -2575,22 +2575,6 @@ "third_party": false, "type": "target" }, - { - "deps": [ - "alts_test_util", - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "alts_handshaker_service_api_test", - "src": [ - "test/core/tsi/alts/handshaker/alts_handshaker_service_api_test.cc" - ], - "third_party": false, - "type": "target" - }, { "deps": [ "alts_test_util", @@ -8112,29 +8096,6 @@ "third_party": false, "type": "lib" }, - { - "deps": [ - "nanopb" - ], - "headers": [ - "src/core/tsi/alts/handshaker/altscontext.pb.h", - "src/core/tsi/alts/handshaker/handshaker.pb.h", - "src/core/tsi/alts/handshaker/transport_security_common.pb.h" - ], - "is_filegroup": true, - "language": "c", - "name": "alts_proto", - "src": [ - "src/core/tsi/alts/handshaker/altscontext.pb.c", - "src/core/tsi/alts/handshaker/altscontext.pb.h", - "src/core/tsi/alts/handshaker/handshaker.pb.c", - "src/core/tsi/alts/handshaker/handshaker.pb.h", - "src/core/tsi/alts/handshaker/transport_security_common.pb.c", - "src/core/tsi/alts/handshaker/transport_security_common.pb.h" - ], - "third_party": false, - "type": "filegroup" - }, { "deps": [ "alts_util", @@ -8205,7 +8166,9 @@ "type": "filegroup" }, { - "deps": [], + "deps": [ + "upb" + ], "headers": [ "src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h", "src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h", @@ -8227,10 +8190,9 @@ }, { "deps": [ - "alts_proto", + "alts_upb", "gpr", "grpc_base", - "nanopb", "tsi_interface", "upb" ], @@ -8238,8 +8200,6 @@ "include/grpc/grpc_security.h", "src/core/lib/security/credentials/alts/check_gcp_environment.h", "src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h", - "src/core/tsi/alts/handshaker/alts_handshaker_service_api.h", - "src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h", "src/core/tsi/alts/handshaker/alts_tsi_utils.h", "src/core/tsi/alts/handshaker/transport_security_common_api.h" ], @@ -8257,10 +8217,6 @@ "src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc", "src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h", "src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc", - "src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc", - "src/core/tsi/alts/handshaker/alts_handshaker_service_api.h", - "src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc", - "src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h", "src/core/tsi/alts/handshaker/alts_tsi_utils.cc", "src/core/tsi/alts/handshaker/alts_tsi_utils.h", "src/core/tsi/alts/handshaker/transport_security_common_api.cc", @@ -8407,7 +8363,9 @@ "type": "filegroup" }, { - "deps": [], + "deps": [ + "upb" + ], "headers": [ "src/core/ext/upb-generated/google/api/annotations.upb.h", "src/core/ext/upb-generated/google/api/http.upb.h", @@ -9586,7 +9544,8 @@ }, { "deps": [ - "google_api_upb" + "google_api_upb", + "upb" ], "headers": [ "src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h" diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 255db94a179..cb5093d586f 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -3251,30 +3251,6 @@ ], "uses_polling": true }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": false, - "language": "c++", - "name": "alts_handshaker_service_api_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "uses_polling": true - }, { "args": [], "benchmark": false, From e00d7fc179a6eabaf7febe6e1468bff5a0078a98 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Thu, 8 Aug 2019 17:53:27 -0700 Subject: [PATCH 1163/1555] Run executable from bazel instead of bazel run (which did not seem to work) Increased timout limit because no interop_server was make'd b4 hand --- src/objective-c/tests/run_one_test.sh | 10 ++++++++-- src/objective-c/tests/run_one_test_bazel.sh | 12 ++++++++---- src/objective-c/tests/run_tests.sh | 19 +++++++++++++++++-- tools/run_tests/run_tests.py | 4 ++-- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/objective-c/tests/run_one_test.sh b/src/objective-c/tests/run_one_test.sh index 8fb26d75b72..2453072a9d5 100755 --- a/src/objective-c/tests/run_one_test.sh +++ b/src/objective-c/tests/run_one_test.sh @@ -22,10 +22,16 @@ cd $(dirname $0) BAZEL=../../../tools/bazel +INTEROP=../../../bazel-out/darwin-fastbuild/bin/test/cpp/interop/interop_server + [ -d Tests.xcworkspace ] || { ./build_tests.sh } +[ -f $INTEROP ] || { + BAZEL build //test/cpp/interop:interop_server +} + [ -z "$(ps aux |egrep 'port_server\.py.*-p\s32766')" ] && { echo >&2 "Can't find the port server. Start port server with tools/run_tests/start_port_server.py." exit 1 @@ -34,8 +40,8 @@ BAZEL=../../../tools/bazel PLAIN_PORT=$(curl localhost:32766/get) TLS_PORT=$(curl localhost:32766/get) -BAZEL run -- //test/cpp/interop:interop_server --port=$PLAIN_PORT --max_send_message_size=8388608 & -BAZEL run -- //test/cpp/interop:interop_server --port=$TLS_PORT --max_send_message_size=8388608 --use_tls & +$INTEROP --port=$PLAIN_PORT --max_send_message_size=8388608 & +$INTEROP --port=$TLS_PORT --max_send_message_size=8388608 --use_tls & trap 'kill -9 `jobs -p` ; echo "EXIT TIME: $(date)"' EXIT diff --git a/src/objective-c/tests/run_one_test_bazel.sh b/src/objective-c/tests/run_one_test_bazel.sh index 39c28fb28a5..97065e8545a 100755 --- a/src/objective-c/tests/run_one_test_bazel.sh +++ b/src/objective-c/tests/run_one_test_bazel.sh @@ -20,14 +20,18 @@ set -ev cd $(dirname $0) -BINDIR=../../../bins/$CONFIG - BAZEL=../../../tools/bazel +INTEROP=../../../bazel-out/darwin-fastbuild/bin/test/cpp/interop/interop_server + [ -d Tests.xcworkspace ] || { ./build_tests.sh } +[ -f $INTEROP ] || { + BAZEL build //test/cpp/interop:interop_server +} + [ -z "$(ps aux |egrep 'port_server\.py.*-p\s32766')" ] && { echo >&2 "Can't find the port server. Start port server with tools/run_tests/start_port_server.py." exit 1 @@ -36,8 +40,8 @@ BAZEL=../../../tools/bazel PLAIN_PORT=$(curl localhost:32766/get) TLS_PORT=$(curl localhost:32766/get) -BAZEL run -- //test/cpp/interop:interop_server --port=$PLAIN_PORT --max_send_message_size=8388608 & -BAZEL run -- //test/cpp/interop:interop_server --port=$TLS_PORT --max_send_message_size=8388608 --use_tls & +$INTEROP --port=$PLAIN_PORT --max_send_message_size=8388608 & +$INTEROP --port=$TLS_PORT --max_send_message_size=8388608 --use_tls & trap 'kill -9 `jobs -p` ; echo "EXIT TIME: $(date)"' EXIT diff --git a/src/objective-c/tests/run_tests.sh b/src/objective-c/tests/run_tests.sh index 916ca15b39f..4ffb0e072d9 100755 --- a/src/objective-c/tests/run_tests.sh +++ b/src/objective-c/tests/run_tests.sh @@ -24,11 +24,26 @@ cd $(dirname $0) BAZEL=../../../tools/bazel +INTEROP=../../../bazel-out/darwin-fastbuild/bin/test/cpp/interop/interop_server + [ -d Tests.xcworkspace ] || { ./build_tests.sh } -BAZEL run -- //test/cpp/interop:interop_server --port=5050 --max_send_message_size=8388608 & -BAZEL run -- //test/cpp/interop:interop_server --port=5051 --max_send_message_size=8388608 --use_tls & + +[ -f $INTEROP ] || { + BAZEL build //test/cpp/interop:interop_server +} + +[ -z "$(ps aux |egrep 'port_server\.py.*-p\s32766')" ] && { + echo >&2 "Can't find the port server. Start port server with tools/run_tests/start_port_server.py." + exit 1 +} + +PLAIN_PORT=$(curl localhost:32766/get) +TLS_PORT=$(curl localhost:32766/get) + +$INTEROP --port=$PLAIN_PORT --max_send_message_size=8388608 & +$INTEROP --port=$TLS_PORT --max_send_message_size=8388608 --use_tls & # Kill them when this script exits. trap 'kill -9 `jobs -p` ; echo "EXIT TIME: $(date)"' EXIT diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 0c3ef0bd57f..c0b87d38087 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1072,7 +1072,7 @@ class ObjCLanguage(object): out.append( self.config.job_spec( ['src/objective-c/tests/build_one_example.sh'], - timeout_seconds=10 * 60, + timeout_seconds=20 * 60, shortname='ios-buildtest-example-sample-frameworks', cpu_cost=1e6, environ={ @@ -1083,7 +1083,7 @@ class ObjCLanguage(object): out.append( self.config.job_spec( ['src/objective-c/tests/build_one_example.sh'], - timeout_seconds=10 * 60, + timeout_seconds=20 * 60, shortname='ios-buildtest-example-switftsample', cpu_cost=1e6, environ={ From f789cffec6bd83d7de60f26a40c1f1ef9883c198 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Thu, 8 Aug 2019 23:44:44 -0700 Subject: [PATCH 1164/1555] Comment deprecated macros --- src/core/lib/gprpp/memory.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/lib/gprpp/memory.h b/src/core/lib/gprpp/memory.h index 2e7658e4866..be158d118a1 100644 --- a/src/core/lib/gprpp/memory.h +++ b/src/core/lib/gprpp/memory.h @@ -30,6 +30,9 @@ // Add this to a class that want to use Delete(), but has a private or // protected destructor. +// Should not be used in new code. +// TODO(juanlishen): Remove this macro, and instead comment that the public dtor +// should not be used directly. #define GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE \ template \ friend void ::grpc_core::Delete(_Delete_T*); \ @@ -38,6 +41,9 @@ // Add this to a class that want to use New(), but has a private or // protected constructor. +// Should not be used in new code. +// TODO(juanlishen): Remove this macro, and instead comment that the public dtor +// should not be used directly. #define GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW \ template \ friend _New_T* grpc_core::New(_New_Args&&...); From 78a01a5782924d29254ad5f7fed80a1d438b5cd5 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 9 Aug 2019 09:12:18 -0700 Subject: [PATCH 1165/1555] Update upb to the latest --- bazel/grpc_deps.bzl | 6 +++--- third_party/upb | 2 +- tools/run_tests/sanity/check_submodules.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 7752ab814e5..da7fba2bb45 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -208,9 +208,9 @@ def grpc_deps(): if "upb" not in native.existing_rules(): http_archive( name = "upb", - sha256 = "6e3c81c9e6c609d918b399110a88d10efeab73b2c8eb3131de15658b1ec86141", - strip_prefix = "upb-b70f68269a7d51c5ce372a93742bf6960215ffef", - url = "https://github.com/protocolbuffers/upb/archive/b70f68269a7d51c5ce372a93742bf6960215ffef.tar.gz", + sha256 = "95150db57b51b65f3422c38953956e0f786945d842d76f8ab685fbcd93ab5caa", + strip_prefix = "upb-931bbecbd3230ae7f22efa5d203639facc47f719", + url = "https://github.com/protocolbuffers/upb/archive/931bbecbd3230ae7f22efa5d203639facc47f719.tar.gz", ) if "envoy_api" not in native.existing_rules(): http_archive( diff --git a/third_party/upb b/third_party/upb index b70f68269a7..931bbecbd32 160000 --- a/third_party/upb +++ b/third_party/upb @@ -1 +1 @@ -Subproject commit b70f68269a7d51c5ce372a93742bf6960215ffef +Subproject commit 931bbecbd3230ae7f22efa5d203639facc47f719 diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index 3ed6ebc40ef..d5eb6677796 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -40,7 +40,7 @@ cat << EOF | awk '{ print $1 }' | sort > "$want_submodules" 9245d481eb3e890f708ff2d7dadf2a10c04748ba third_party/libcxxabi (heads/release_60) 09745575a923640154bcf307fba8aedff47f240a third_party/protobuf (v3.7.0-rc.2-247-g09745575) e143189bf6f37b3957fb31743df6a1bcf4a8c685 third_party/protoc-gen-validate (v0.0.10) - b70f68269a7d51c5ce372a93742bf6960215ffef third_party/upb (heads/master) + 931bbecbd3230ae7f22efa5d203639facc47f719 third_party/upb (heads/master) cacf7f1d4e3d44d871b605da3b647f07d718623f third_party/zlib (v1.2.11) EOF From 9d7703710668edf3f04e2363b7c3f6a9a3b063d0 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 9 Aug 2019 10:02:00 -0700 Subject: [PATCH 1166/1555] clang-format --- gRPC-ProtoRPC.podspec | 2 +- src/compiler/objective_c_plugin.cc | 4 +--- src/objective-c/BUILD | 3 --- src/objective-c/GRPCClient/GRPCCallOptions.h | 13 ------------- src/objective-c/GRPCClient/GRPCTypes.h | 13 +++++++++++++ src/objective-c/ProtoRPC/ProtoService.h | 13 +++++++++++++ src/objective-c/ProtoRPC/ProtoServiceLegacy.h | 13 ------------- src/objective-c/ProtoRPC/ProtoServiceLegacy.m | 2 +- templates/gRPC-ProtoRPC.podspec.template | 2 +- 9 files changed, 30 insertions(+), 35 deletions(-) diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 4a4e5beb9ca..723180be19b 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -69,7 +69,7 @@ Pod::Spec.new do |s| ss.dependency 'Protobuf', '~> 3.0' ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.m", - "src/objective-c/ProtoRPC/ProtoServiceLegacy.{h,m}" + "src/objective-c/ProtoRPC/ProtoServiceLegacy.m" end # CFStream is now default. Leaving this subspec only for compatibility purpose. diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index 682cc28b739..a08064a08bd 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -138,9 +138,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { } ::grpc::string system_imports = - (generator_params.no_v1_compatibility - ? SystemImport("ProtoRPC/ProtoService.h") - : SystemImport("ProtoRPC/ProtoServiceLegacy.h")) + + SystemImport("ProtoRPC/ProtoService.h") + (generator_params.no_v1_compatibility ? SystemImport("ProtoRPC/ProtoRPC.h") : SystemImport("ProtoRPC/ProtoRPCLegacy.h")); diff --git a/src/objective-c/BUILD b/src/objective-c/BUILD index 9e0181d9e98..2af1d85f290 100644 --- a/src/objective-c/BUILD +++ b/src/objective-c/BUILD @@ -168,9 +168,6 @@ grpc_objc_library( "ProtoRPC/ProtoRPCLegacy.m", "ProtoRPC/ProtoServiceLegacy.m", ], - hdrs = [ - "ProtoRPC/ProtoServiceLegacy.h", - ], deps = [ ":rx_library", ":proto_objc_rpc_v2", diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.h b/src/objective-c/GRPCClient/GRPCCallOptions.h index d4a60a2a1c7..d01c8285662 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.h +++ b/src/objective-c/GRPCClient/GRPCCallOptions.h @@ -24,19 +24,6 @@ NS_ASSUME_NONNULL_BEGIN @protocol GRPCInterceptorFactory; -/** - * Implement this protocol to provide a token to gRPC when a call is initiated. - */ -@protocol GRPCAuthorizationProtocol - -/** - * This method is called when gRPC is about to start the call. When OAuth token is acquired, - * \a handler is expected to be called with \a token being the new token to be used for this call. - */ -- (void)getTokenWithHandler:(void (^)(NSString *_Nullable token))handler; - -@end - @interface GRPCCallOptions : NSObject // Call parameters diff --git a/src/objective-c/GRPCClient/GRPCTypes.h b/src/objective-c/GRPCClient/GRPCTypes.h index 0aacf0f9d15..8e66d3d3acb 100644 --- a/src/objective-c/GRPCClient/GRPCTypes.h +++ b/src/objective-c/GRPCClient/GRPCTypes.h @@ -172,3 +172,16 @@ extern NSString* const kGRPCTrailersKey; /** The id of a transport implementation. */ typedef char* GRPCTransportId; + +/** + * Implement this protocol to provide a token to gRPC when a call is initiated. + */ +@protocol GRPCAuthorizationProtocol + +/** + * This method is called when gRPC is about to start the call. When OAuth token is acquired, + * \a handler is expected to be called with \a token being the new token to be used for this call. + */ +- (void)getTokenWithHandler:(void (^)(NSString* _Nullable token))handler; + +@end diff --git a/src/objective-c/ProtoRPC/ProtoService.h b/src/objective-c/ProtoRPC/ProtoService.h index 34aea380668..8543f5dee43 100644 --- a/src/objective-c/ProtoRPC/ProtoService.h +++ b/src/objective-c/ProtoRPC/ProtoService.h @@ -26,6 +26,7 @@ @class GRPCUnaryProtoCall; @class GRPCStreamingProtoCall; @protocol GRPCProtoResponseHandler; +@protocol GRXWriteable; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnullability-completeness" @@ -49,6 +50,18 @@ __attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoServ callOptions:(nullable GRPCCallOptions *)callOptions responseClass:(nonnull Class)responseClass; +@end + + @interface ProtoService(Legacy) + + - (instancetype)initWithHost : (NSString *)host packageName + : (NSString *)packageName serviceName : (NSString *)serviceName; + +- (GRPCProtoCall *)RPCToMethod:(NSString *)method + requestsWriter:(GRXWriter *)requestsWriter + responseClass:(Class)responseClass + responsesWriteable:(id)responsesWriteable; + @end #pragma clang diagnostic pop diff --git a/src/objective-c/ProtoRPC/ProtoServiceLegacy.h b/src/objective-c/ProtoRPC/ProtoServiceLegacy.h index 28686f51e37..7b0b7a4de7e 100644 --- a/src/objective-c/ProtoRPC/ProtoServiceLegacy.h +++ b/src/objective-c/ProtoRPC/ProtoServiceLegacy.h @@ -21,16 +21,3 @@ @class GRPCProtoCall; @class GRXWriter; @protocol GRXWriteable; - -@interface ProtoService (Legacy) - -- (instancetype)initWithHost:(NSString *)host - packageName:(NSString *)packageName - serviceName:(NSString *)serviceName; - -- (GRPCProtoCall *)RPCToMethod:(NSString *)method - requestsWriter:(GRXWriter *)requestsWriter - responseClass:(Class)responseClass - responsesWriteable:(id)responsesWriteable; - -@end diff --git a/src/objective-c/ProtoRPC/ProtoServiceLegacy.m b/src/objective-c/ProtoRPC/ProtoServiceLegacy.m index b8b2766cdb0..6aa64955381 100644 --- a/src/objective-c/ProtoRPC/ProtoServiceLegacy.m +++ b/src/objective-c/ProtoRPC/ProtoServiceLegacy.m @@ -20,7 +20,7 @@ #import "ProtoMethod.h" #import "ProtoRPCLegacy.h" -#import "ProtoServiceLegacy.h" +#import "ProtoService.h" #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-implementations" diff --git a/templates/gRPC-ProtoRPC.podspec.template b/templates/gRPC-ProtoRPC.podspec.template index b8a881c06a9..6222ea5611a 100644 --- a/templates/gRPC-ProtoRPC.podspec.template +++ b/templates/gRPC-ProtoRPC.podspec.template @@ -71,7 +71,7 @@ ss.dependency 'Protobuf', '~> 3.0' ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.m", - "src/objective-c/ProtoRPC/ProtoServiceLegacy.{h,m}" + "src/objective-c/ProtoRPC/ProtoServiceLegacy.m" end # CFStream is now default. Leaving this subspec only for compatibility purpose. From 3e8e0373d080c676e62efbb3040c3091e919937f Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 9 Aug 2019 10:41:30 -0700 Subject: [PATCH 1167/1555] add nullability annotation --- src/objective-c/GRPCClient/GRPCTypes.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCTypes.h b/src/objective-c/GRPCClient/GRPCTypes.h index 8e66d3d3acb..c804bca4eaa 100644 --- a/src/objective-c/GRPCClient/GRPCTypes.h +++ b/src/objective-c/GRPCClient/GRPCTypes.h @@ -161,17 +161,17 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { }; /** Domain of NSError objects produced by gRPC. */ -extern NSString* const kGRPCErrorDomain; +extern NSString* _Nonnull const kGRPCErrorDomain; /** * Keys used in |NSError|'s |userInfo| dictionary to store the response headers * and trailers sent by the server. */ -extern NSString* const kGRPCHeadersKey; -extern NSString* const kGRPCTrailersKey; +extern NSString* _Nonnull const kGRPCHeadersKey; +extern NSString* _Nonnull const kGRPCTrailersKey; /** The id of a transport implementation. */ -typedef char* GRPCTransportId; +typedef char* _Nonnull GRPCTransportId; /** * Implement this protocol to provide a token to gRPC when a call is initiated. @@ -182,6 +182,6 @@ typedef char* GRPCTransportId; * This method is called when gRPC is about to start the call. When OAuth token is acquired, * \a handler is expected to be called with \a token being the new token to be used for this call. */ -- (void)getTokenWithHandler:(void (^)(NSString* _Nullable token))handler; +- (void)getTokenWithHandler:(void (^_Nonnull)(NSString* _Nullable token))handler; @end From eaf26b7ac3f089d3ae75b72ee56a15fb57051ff4 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Fri, 9 Aug 2019 10:47:16 -0700 Subject: [PATCH 1168/1555] Added missing configs for tvos tests --- src/objective-c/tests/Podfile | 2 +- src/objective-c/tests/run_one_test.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile index 442f3599bb1..be935732935 100644 --- a/src/objective-c/tests/Podfile +++ b/src/objective-c/tests/Podfile @@ -103,7 +103,7 @@ post_install do |installer| # the test target 'InteropTestsRemoteWithCronet' # Activate GRPCCall+InternalTests functions for the dedicated build configuration 'Test', which will # be used by all test targets using it. - if /gRPC-(mac|i)OS/.match(target.name) + if /gRPC-(mac|i|tv)OS/.match(target.name) target.build_configurations.each do |config| if config.name == 'Cronet' config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_COMPILE_WITH_CRONET=1 GRPC_TEST_OBJC=1' diff --git a/src/objective-c/tests/run_one_test.sh b/src/objective-c/tests/run_one_test.sh index b74107e4a66..ee83c67a72e 100755 --- a/src/objective-c/tests/run_one_test.sh +++ b/src/objective-c/tests/run_one_test.sh @@ -51,6 +51,8 @@ elif [ $PLATFORM == ios ]; then DESTINATION='name=iPhone 8' elif [ $PLATFORM == macos ]; then DESTINATION='platform=macOS' +elif [ $PLATFORM == tvos ]; then +DESTINATION='platform=tvOS Simulator,name=Apple TV' fi xcodebuild \ From 45dd8be4421b7f1311aea91a5d9628ddeb3d6d53 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Fri, 9 Aug 2019 11:43:21 -0700 Subject: [PATCH 1169/1555] Use LRS in xds policy --- BUILD | 2 - CMakeLists.txt | 17 +- Makefile | 33 +- build.yaml | 5 +- .../filters/client_channel/client_channel.cc | 6 +- .../ext/filters/client_channel/lb_policy.h | 5 +- .../client_channel/lb_policy/xds/xds.cc | 1257 +++++++++++------ .../lb_policy/xds/xds_client_stats.cc | 199 ++- .../lb_policy/xds/xds_client_stats.h | 214 ++- .../lb_policy/xds/xds_load_balancer_api.cc | 194 ++- .../lb_policy/xds/xds_load_balancer_api.h | 66 +- src/core/lib/gprpp/atomic.h | 4 + src/core/lib/gprpp/map.h | 2 +- src/core/lib/transport/static_metadata.cc | 614 ++++---- src/core/lib/transport/static_metadata.h | 151 +- src/proto/grpc/lb/v2/BUILD | 14 +- ...{xds_for_test.proto => eds_for_test.proto} | 0 src/proto/grpc/lb/v2/lrs_for_test.proto | 180 +++ test/core/end2end/fuzzers/hpack.dictionary | 1 + test/core/util/test_lb_policies.cc | 2 +- test/cpp/end2end/BUILD | 4 +- test/cpp/end2end/xds_end2end_test.cc | 906 ++++++++---- tools/codegen/core/gen_static_metadata.py | 1 + .../generated/sources_and_headers.json | 11 +- 24 files changed, 2587 insertions(+), 1301 deletions(-) rename src/proto/grpc/lb/v2/{xds_for_test.proto => eds_for_test.proto} (100%) create mode 100644 src/proto/grpc/lb/v2/lrs_for_test.proto diff --git a/BUILD b/BUILD index 7d5be55a332..d5e863c552d 100644 --- a/BUILD +++ b/BUILD @@ -1262,7 +1262,6 @@ grpc_cc_library( "envoy_ads_upb", "grpc_base", "grpc_client_channel", - "grpc_lb_upb", "grpc_resolver_fake", ], ) @@ -1286,7 +1285,6 @@ grpc_cc_library( "envoy_ads_upb", "grpc_base", "grpc_client_channel", - "grpc_lb_upb", "grpc_resolver_fake", "grpc_secure", ], diff --git a/CMakeLists.txt b/CMakeLists.txt index 70aaedd08a4..21511bb9738 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17674,17 +17674,24 @@ endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(xds_end2end_test - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/xds_for_test.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/xds_for_test.grpc.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/xds_for_test.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/xds_for_test.grpc.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/eds_for_test.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/eds_for_test.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/eds_for_test.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/eds_for_test.grpc.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/lrs_for_test.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/lrs_for_test.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/lrs_for_test.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/lrs_for_test.grpc.pb.h test/cpp/end2end/xds_end2end_test.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc ) protobuf_generate_grpc_cpp( - src/proto/grpc/lb/v2/xds_for_test.proto + src/proto/grpc/lb/v2/eds_for_test.proto +) +protobuf_generate_grpc_cpp( + src/proto/grpc/lb/v2/lrs_for_test.proto ) target_include_directories(xds_end2end_test diff --git a/Makefile b/Makefile index ef5963dc441..df0dfa30b40 100644 --- a/Makefile +++ b/Makefile @@ -2700,16 +2700,32 @@ $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc: src/proto/grpc/lb/v1/lo endif ifeq ($(NO_PROTOC),true) -$(GENDIR)/src/proto/grpc/lb/v2/xds_for_test.pb.cc: protoc_dep_error -$(GENDIR)/src/proto/grpc/lb/v2/xds_for_test.grpc.pb.cc: protoc_dep_error +$(GENDIR)/src/proto/grpc/lb/v2/eds_for_test.pb.cc: protoc_dep_error +$(GENDIR)/src/proto/grpc/lb/v2/eds_for_test.grpc.pb.cc: protoc_dep_error else -$(GENDIR)/src/proto/grpc/lb/v2/xds_for_test.pb.cc: src/proto/grpc/lb/v2/xds_for_test.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) +$(GENDIR)/src/proto/grpc/lb/v2/eds_for_test.pb.cc: src/proto/grpc/lb/v2/eds_for_test.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(E) "[PROTOC] Generating protobuf CC file from $<" $(Q) mkdir -p `dirname $@` $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --cpp_out=$(GENDIR) $< -$(GENDIR)/src/proto/grpc/lb/v2/xds_for_test.grpc.pb.cc: src/proto/grpc/lb/v2/xds_for_test.proto $(GENDIR)/src/proto/grpc/lb/v2/xds_for_test.pb.cc $(PROTOBUF_DEP) $(PROTOC_PLUGINS) +$(GENDIR)/src/proto/grpc/lb/v2/eds_for_test.grpc.pb.cc: src/proto/grpc/lb/v2/eds_for_test.proto $(GENDIR)/src/proto/grpc/lb/v2/eds_for_test.pb.cc $(PROTOBUF_DEP) $(PROTOC_PLUGINS) + $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<" + $(Q) mkdir -p `dirname $@` + $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin$(EXECUTABLE_SUFFIX) $< +endif + +ifeq ($(NO_PROTOC),true) +$(GENDIR)/src/proto/grpc/lb/v2/lrs_for_test.pb.cc: protoc_dep_error +$(GENDIR)/src/proto/grpc/lb/v2/lrs_for_test.grpc.pb.cc: protoc_dep_error +else + +$(GENDIR)/src/proto/grpc/lb/v2/lrs_for_test.pb.cc: src/proto/grpc/lb/v2/lrs_for_test.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/lb/v2/eds_for_test.pb.cc + $(E) "[PROTOC] Generating protobuf CC file from $<" + $(Q) mkdir -p `dirname $@` + $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --cpp_out=$(GENDIR) $< + +$(GENDIR)/src/proto/grpc/lb/v2/lrs_for_test.grpc.pb.cc: src/proto/grpc/lb/v2/lrs_for_test.proto $(GENDIR)/src/proto/grpc/lb/v2/lrs_for_test.pb.cc $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/lb/v2/eds_for_test.pb.cc $(GENDIR)/src/proto/grpc/lb/v2/eds_for_test.grpc.pb.cc $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<" $(Q) mkdir -p `dirname $@` $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin$(EXECUTABLE_SUFFIX) $< @@ -19744,7 +19760,8 @@ endif XDS_END2END_TEST_SRC = \ - $(GENDIR)/src/proto/grpc/lb/v2/xds_for_test.pb.cc $(GENDIR)/src/proto/grpc/lb/v2/xds_for_test.grpc.pb.cc \ + $(GENDIR)/src/proto/grpc/lb/v2/eds_for_test.pb.cc $(GENDIR)/src/proto/grpc/lb/v2/eds_for_test.grpc.pb.cc \ + $(GENDIR)/src/proto/grpc/lb/v2/lrs_for_test.pb.cc $(GENDIR)/src/proto/grpc/lb/v2/lrs_for_test.grpc.pb.cc \ test/cpp/end2end/xds_end2end_test.cc \ XDS_END2END_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(XDS_END2END_TEST_SRC)))) @@ -19776,7 +19793,9 @@ endif endif -$(OBJDIR)/$(CONFIG)/src/proto/grpc/lb/v2/xds_for_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(OBJDIR)/$(CONFIG)/src/proto/grpc/lb/v2/eds_for_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + +$(OBJDIR)/$(CONFIG)/src/proto/grpc/lb/v2/lrs_for_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OBJDIR)/$(CONFIG)/test/cpp/end2end/xds_end2end_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -19787,7 +19806,7 @@ ifneq ($(NO_DEPS),true) -include $(XDS_END2END_TEST_OBJS:.o=.dep) endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/end2end/xds_end2end_test.o: $(GENDIR)/src/proto/grpc/lb/v2/xds_for_test.pb.cc $(GENDIR)/src/proto/grpc/lb/v2/xds_for_test.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/end2end/xds_end2end_test.o: $(GENDIR)/src/proto/grpc/lb/v2/eds_for_test.pb.cc $(GENDIR)/src/proto/grpc/lb/v2/eds_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/lb/v2/lrs_for_test.pb.cc $(GENDIR)/src/proto/grpc/lb/v2/lrs_for_test.grpc.pb.cc PUBLIC_HEADERS_MUST_BE_C89_SRC = \ diff --git a/build.yaml b/build.yaml index 0b8c1955d27..4bb2e401457 100644 --- a/build.yaml +++ b/build.yaml @@ -833,7 +833,6 @@ filegroups: - grpc_base - grpc_client_channel - grpc_resolver_fake - - grpc_lb_upb - name: grpc_lb_policy_xds_secure headers: - src/core/ext/filters/client_channel/lb_policy/xds/xds.h @@ -852,7 +851,6 @@ filegroups: - grpc_client_channel - grpc_resolver_fake - grpc_secure - - grpc_lb_upb - name: grpc_lb_subchannel_list headers: - src/core/ext/filters/client_channel/lb_policy/subchannel_list.h @@ -6027,7 +6025,8 @@ targets: build: test language: c++ src: - - src/proto/grpc/lb/v2/xds_for_test.proto + - src/proto/grpc/lb/v2/eds_for_test.proto + - src/proto/grpc/lb/v2/lrs_for_test.proto - test/cpp/end2end/xds_end2end_test.cc deps: - grpc++_test_util diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index ac79ae92d5a..767a22e9e59 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -708,7 +708,7 @@ class CallData { LbCallState lb_call_state_; RefCountedPtr connected_subchannel_; void (*lb_recv_trailing_metadata_ready_)( - void* user_data, + void* user_data, grpc_error* error, LoadBalancingPolicy::MetadataInterface* recv_trailing_metadata, LoadBalancingPolicy::CallState* call_state) = nullptr; void* lb_recv_trailing_metadata_ready_user_data_ = nullptr; @@ -2160,8 +2160,8 @@ void CallData::RecvTrailingMetadataReadyForLoadBalancingPolicy( // Invoke callback to LB policy. Metadata trailing_metadata(calld, calld->recv_trailing_metadata_); calld->lb_recv_trailing_metadata_ready_( - calld->lb_recv_trailing_metadata_ready_user_data_, &trailing_metadata, - &calld->lb_call_state_); + calld->lb_recv_trailing_metadata_ready_user_data_, error, + &trailing_metadata, &calld->lb_call_state_); // Chain to original callback. GRPC_CLOSURE_RUN(calld->original_recv_trailing_metadata_ready_, GRPC_ERROR_REF(error)); diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h index a205d333ae8..ea4962cdb77 100644 --- a/src/core/ext/filters/client_channel/lb_policy.h +++ b/src/core/ext/filters/client_channel/lb_policy.h @@ -174,8 +174,11 @@ class LoadBalancingPolicy : public InternallyRefCounted { /// modified by the callback. The callback does not take ownership, /// however, so any data that needs to be used after returning must /// be copied. + // TODO(roth): Replace grpc_error with something better before we allow + // people outside of gRPC team to use this API. void (*recv_trailing_metadata_ready)( - void* user_data, MetadataInterface* recv_trailing_metadata, + void* user_data, grpc_error* error, + MetadataInterface* recv_trailing_metadata, CallState* call_state) = nullptr; void* recv_trailing_metadata_ready_user_data = nullptr; }; diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index 851b84b2a71..58c1ebad39e 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -108,6 +108,7 @@ #define GRPC_XDS_RECONNECT_MAX_BACKOFF_SECONDS 120 #define GRPC_XDS_RECONNECT_JITTER 0.2 #define GRPC_XDS_DEFAULT_FALLBACK_TIMEOUT_MS 10000 +#define GRPC_XDS_MIN_CLIENT_LOAD_REPORTING_INTERVAL_MS 1000 namespace grpc_core { @@ -154,95 +155,192 @@ class XdsLb : public LoadBalancingPolicy { void ResetBackoffLocked() override; private: - /// Contains a channel to the LB server and all the data related to the - /// channel. - class BalancerChannelState - : public InternallyRefCounted { + // Contains a channel to the LB server and all the data related to the + // channel. Holds a ref to the xds policy. + class LbChannelState : public InternallyRefCounted { public: - /// Contains a call to the LB server and all the data related to the call. - class BalancerCallState : public InternallyRefCounted { + // An LB call wrapper that can restart a call upon failure. Holds a ref to + // the LB channel. The template parameter is the kind of wrapped LB call. + template + class RetryableLbCall : public InternallyRefCounted> { public: - explicit BalancerCallState(RefCountedPtr lb_chand); + explicit RetryableLbCall(RefCountedPtr lb_chand); - // It's the caller's responsibility to ensure that Orphan() is called from - // inside the combiner. void Orphan() override; - void StartQuery(); + void OnCallFinishedLocked(); - RefCountedPtr client_stats() const { - return client_stats_; - } + T* lb_calld() const { return lb_calld_.get(); } + LbChannelState* lb_chand() const { return lb_chand_.get(); } + private: + void StartNewCallLocked(); + void StartRetryTimerLocked(); + static void OnRetryTimerLocked(void* arg, grpc_error* error); + + // The wrapped LB call that talks to the LB server. It's instantiated + // every time we start a new call. It's null during call retry backoff. + OrphanablePtr lb_calld_; + // The owing LB channel. + RefCountedPtr lb_chand_; + + // Retry state. + BackOff backoff_; + grpc_timer retry_timer_; + grpc_closure on_retry_timer_; + bool retry_timer_callback_pending_ = false; + + bool shutting_down_ = false; + }; + + // Contains an EDS call to the LB server. + class EdsCallState : public InternallyRefCounted { + public: + // The ctor and dtor should not be used directly. + explicit EdsCallState( + RefCountedPtr> parent); + ~EdsCallState() override; + + void Orphan() override; + + RetryableLbCall* parent() const { return parent_.get(); } + LbChannelState* lb_chand() const { return parent_->lb_chand(); } + XdsLb* xdslb_policy() const { return lb_chand()->xdslb_policy(); } bool seen_response() const { return seen_response_; } private: - GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE + static void OnResponseReceivedLocked(void* arg, grpc_error* error); + static void OnStatusReceivedLocked(void* arg, grpc_error* error); - ~BalancerCallState(); + bool IsCurrentCallOnChannel() const; - XdsLb* xdslb_policy() const { return lb_chand_->xdslb_policy_.get(); } + // The owning RetryableLbCall<>. + RefCountedPtr> parent_; + bool seen_response_ = false; - bool IsCurrentCallOnChannel() const { - return this == lb_chand_->lb_calld_.get(); - } - - void ScheduleNextClientLoadReportLocked(); - void SendClientLoadReportLocked(); - - static bool LoadReportCountersAreZero(xds_grpclb_request* request); - - static void MaybeSendClientLoadReportLocked(void* arg, grpc_error* error); - static void OnInitialRequestSentLocked(void* arg, grpc_error* error); - static void OnBalancerMessageReceivedLocked(void* arg, grpc_error* error); - static void OnBalancerStatusReceivedLocked(void* arg, grpc_error* error); - - // The owning LB channel. - RefCountedPtr lb_chand_; - - // The streaming call to the LB server. Always non-NULL. - grpc_call* lb_call_ = nullptr; + // Always non-NULL. + grpc_call* lb_call_; // recv_initial_metadata - grpc_metadata_array lb_initial_metadata_recv_; + grpc_metadata_array initial_metadata_recv_; // send_message grpc_byte_buffer* send_message_payload_ = nullptr; - grpc_closure lb_on_initial_request_sent_; // recv_message grpc_byte_buffer* recv_message_payload_ = nullptr; - grpc_closure lb_on_balancer_message_received_; - bool seen_response_ = false; + grpc_closure on_response_received_; // recv_trailing_metadata - grpc_closure lb_on_balancer_status_received_; - grpc_metadata_array lb_trailing_metadata_recv_; - grpc_status_code lb_call_status_; - grpc_slice lb_call_status_details_; - - // The stats for client-side load reporting associated with this LB call. - // Created after the first serverlist is received. - RefCountedPtr client_stats_; - grpc_millis client_stats_report_interval_ = 0; - grpc_timer client_load_report_timer_; - bool client_load_report_timer_callback_pending_ = false; - bool last_client_load_report_counters_were_zero_ = false; - bool client_load_report_is_due_ = false; - // The closure used for either the load report timer or the callback for - // completion of sending the load report. - grpc_closure client_load_report_closure_; + grpc_metadata_array trailing_metadata_recv_; + grpc_status_code status_code_; + grpc_slice status_details_; + grpc_closure on_status_received_; }; - BalancerChannelState(const char* balancer_name, - const grpc_channel_args& args, - RefCountedPtr parent_xdslb_policy); - ~BalancerChannelState(); + // Contains an LRS call to the LB server. + class LrsCallState : public InternallyRefCounted { + public: + // The ctor and dtor should not be used directly. + explicit LrsCallState( + RefCountedPtr> parent); + ~LrsCallState() override; + + void Orphan() override; + + void MaybeStartReportingLocked(); + + RetryableLbCall* parent() { return parent_.get(); } + LbChannelState* lb_chand() const { return parent_->lb_chand(); } + XdsLb* xdslb_policy() const { return lb_chand()->xdslb_policy(); } + bool seen_response() const { return seen_response_; } + + private: + // Reports client-side load stats according to a fixed interval. + class Reporter : public InternallyRefCounted { + public: + Reporter(RefCountedPtr parent, + grpc_millis report_interval) + : parent_(std::move(parent)), report_interval_(report_interval) { + GRPC_CLOSURE_INIT( + &on_next_report_timer_, OnNextReportTimerLocked, this, + grpc_combiner_scheduler(xdslb_policy()->combiner())); + GRPC_CLOSURE_INIT( + &on_report_done_, OnReportDoneLocked, this, + grpc_combiner_scheduler(xdslb_policy()->combiner())); + ScheduleNextReportLocked(); + } + + void Orphan() override; + + private: + void ScheduleNextReportLocked(); + static void OnNextReportTimerLocked(void* arg, grpc_error* error); + void SendReportLocked(); + static void OnReportDoneLocked(void* arg, grpc_error* error); + + bool IsCurrentReporterOnCall() const { + return this == parent_->reporter_.get(); + } + XdsLb* xdslb_policy() const { return parent_->xdslb_policy(); } + + // The owning LRS call. + RefCountedPtr parent_; + + // The load reporting state. + const grpc_millis report_interval_; + bool last_report_counters_were_zero_ = false; + bool next_report_timer_callback_pending_ = false; + grpc_timer next_report_timer_; + grpc_closure on_next_report_timer_; + grpc_closure on_report_done_; + }; + + static void OnInitialRequestSentLocked(void* arg, grpc_error* error); + static void OnResponseReceivedLocked(void* arg, grpc_error* error); + static void OnStatusReceivedLocked(void* arg, grpc_error* error); + + bool IsCurrentCallOnChannel() const; + + // The owning RetryableLbCall<>. + RefCountedPtr> parent_; + bool seen_response_ = false; + + // Always non-NULL. + grpc_call* lb_call_; + + // recv_initial_metadata + grpc_metadata_array initial_metadata_recv_; + + // send_message + grpc_byte_buffer* send_message_payload_ = nullptr; + grpc_closure on_initial_request_sent_; + + // recv_message + grpc_byte_buffer* recv_message_payload_ = nullptr; + grpc_closure on_response_received_; + + // recv_trailing_metadata + grpc_metadata_array trailing_metadata_recv_; + grpc_status_code status_code_; + grpc_slice status_details_; + grpc_closure on_status_received_; + + // Load reporting state. + grpc_millis load_reporting_interval_ = 0; + OrphanablePtr reporter_; + }; + + LbChannelState(RefCountedPtr xdslb_policy, const char* balancer_name, + const grpc_channel_args& args); + ~LbChannelState(); void Orphan() override; grpc_channel* channel() const { return channel_; } - BalancerCallState* lb_calld() const { return lb_calld_.get(); } + XdsLb* xdslb_policy() const { return xdslb_policy_.get(); } + EdsCallState* eds_calld() const { return eds_calld_->lb_calld(); } + LrsCallState* lrs_calld() const { return lrs_calld_->lb_calld(); } bool IsCurrentChannel() const { return this == xdslb_policy_->lb_chand_.get(); @@ -250,11 +348,7 @@ class XdsLb : public LoadBalancingPolicy { bool IsPendingChannel() const { return this == xdslb_policy_->pending_lb_chand_.get(); } - bool HasActiveCall() const { return lb_calld_ != nullptr; } - - void StartCallRetryTimerLocked(); - static void OnCallRetryTimerLocked(void* arg, grpc_error* error); - void StartCallLocked(); + bool HasActiveEdsCall() const { return eds_calld_->lb_calld() != nullptr; } void StartConnectivityWatchLocked(); void CancelConnectivityWatchLocked(); @@ -270,29 +364,35 @@ class XdsLb : public LoadBalancingPolicy { grpc_connectivity_state connectivity_ = GRPC_CHANNEL_IDLE; grpc_closure on_connectivity_changed_; - // The data associated with the current LB call. It holds a ref to this LB - // channel. It's instantiated every time we query for backends. It's reset - // whenever the current LB call is no longer needed (e.g., the LB policy is - // shutting down, or the LB call has ended). A non-NULL lb_calld_ always - // contains a non-NULL lb_call_. - OrphanablePtr lb_calld_; - BackOff lb_call_backoff_; - grpc_timer lb_call_retry_timer_; - grpc_closure lb_on_call_retry_; - bool retry_timer_callback_pending_ = false; + // The retryable XDS calls to the LB server. + OrphanablePtr> eds_calld_; + OrphanablePtr> lrs_calld_; }; - // Since pickers are UniquePtrs we use this RefCounted wrapper - // to control references to it by the xds picker and the locality - // entry - class PickerRef : public RefCounted { + // We need this wrapper for the following reasons: + // 1. To process per-locality load reporting. + // 2. Since pickers are UniquePtrs we use this RefCounted wrapper to control + // references to it by the xds picker and the locality entry. + class PickerWrapper : public RefCounted { public: - explicit PickerRef(UniquePtr picker) - : picker_(std::move(picker)) {} - PickResult Pick(PickArgs args) { return picker_->Pick(args); } + PickerWrapper(UniquePtr picker, + RefCountedPtr locality_stats) + : picker_(std::move(picker)), + locality_stats_(std::move(locality_stats)) { + locality_stats_->RefByPicker(); + } + ~PickerWrapper() { locality_stats_->UnrefByPicker(); } + + PickResult Pick(PickArgs args); private: + static void RecordCallCompletion( + void* arg, grpc_error* error, + LoadBalancingPolicy::MetadataInterface* recv_trailing_metadata, + LoadBalancingPolicy::CallState* call_state); + UniquePtr picker_; + RefCountedPtr locality_stats_; }; // The picker will use a stateless weighting algorithm to pick the locality to @@ -304,17 +404,15 @@ class XdsLb : public LoadBalancingPolicy { // proportional to the locality's weight. The start of the range is the // previous value in the vector and is 0 for the first element. using PickerList = - InlinedVector>, 1>; - Picker(RefCountedPtr client_stats, PickerList pickers) - : client_stats_(std::move(client_stats)), - pickers_(std::move(pickers)) {} + InlinedVector>, 1>; + explicit Picker(PickerList pickers) : pickers_(std::move(pickers)) {} PickResult Pick(PickArgs args) override; private: - // Calls the picker of the locality that the key falls within + // Calls the picker of the locality that the key falls within. PickResult PickFromLocality(const uint32_t key, PickArgs args); - RefCountedPtr client_stats_; + PickerList pickers_; }; @@ -386,6 +484,7 @@ class XdsLb : public LoadBalancingPolicy { RefCountedPtr entry_; LoadBalancingPolicy* child_ = nullptr; }; + // Methods for dealing with the child policy. OrphanablePtr CreateChildPolicyLocked( const char* name, const grpc_channel_args* args); @@ -396,7 +495,7 @@ class XdsLb : public LoadBalancingPolicy { RefCountedPtr name_; OrphanablePtr child_policy_; OrphanablePtr pending_child_policy_; - RefCountedPtr picker_ref_; + RefCountedPtr picker_wrapper_; grpc_connectivity_state connectivity_state_; uint32_t locality_weight_; }; @@ -409,6 +508,7 @@ class XdsLb : public LoadBalancingPolicy { private: void PruneLocalities(const XdsLocalityList& locality_list); + Map, OrphanablePtr, XdsLocalityName::Less> map_; @@ -428,7 +528,7 @@ class XdsLb : public LoadBalancingPolicy { // found. Does nothing upon failure. void ParseLbConfig(const ParsedXdsConfig* xds_config); - BalancerChannelState* LatestLbChannel() const { + LbChannelState* LatestLbChannel() const { return pending_lb_chand_ != nullptr ? pending_lb_chand_.get() : lb_chand_.get(); } @@ -454,8 +554,8 @@ class XdsLb : public LoadBalancingPolicy { bool shutting_down_ = false; // The channel for communicating with the LB server. - OrphanablePtr lb_chand_; - OrphanablePtr pending_lb_chand_; + OrphanablePtr lb_chand_; + OrphanablePtr pending_lb_chand_; // Timeout in milliseconds for the LB call. 0 means no deadline. int lb_call_timeout_ms_ = 0; @@ -493,8 +593,45 @@ class XdsLb : public LoadBalancingPolicy { // TODO(mhaidry) : Add a pending locality map that may be swapped with the // the current one when new localities in the pending map are ready // to accept connections + + // The stats for client-side load reporting. + XdsClientStats client_stats_; }; +// +// XdsLb::PickerWrapper::Pick +// + +LoadBalancingPolicy::PickResult XdsLb::PickerWrapper::Pick( + LoadBalancingPolicy::PickArgs args) { + // Forward the pick to the picker returned from the child policy. + PickResult result = picker_->Pick(args); + if (result.type != PickResult::PICK_COMPLETE || + result.subchannel == nullptr || locality_stats_ == nullptr) { + return result; + } + // Record a call started. + locality_stats_->AddCallStarted(); + // Intercept the recv_trailing_metadata op to record call completion. + result.recv_trailing_metadata_ready = RecordCallCompletion; + result.recv_trailing_metadata_ready_user_data = + locality_stats_->Ref(DEBUG_LOCATION, "LocalityStats+call").release(); + return result; +} + +// Note that the following callback does not run in either the control plane +// combiner or the data plane combiner. +void XdsLb::PickerWrapper::RecordCallCompletion( + void* arg, grpc_error* error, + LoadBalancingPolicy::MetadataInterface* recv_trailing_metadata, + LoadBalancingPolicy::CallState* call_state) { + XdsClientStats::LocalityStats* locality_stats = + static_cast(arg); + const bool call_failed = error != GRPC_ERROR_NONE; + locality_stats->AddCallFinished(call_failed); + locality_stats->Unref(DEBUG_LOCATION, "LocalityStats+call"); +} + // // XdsLb::Picker // @@ -506,13 +643,7 @@ XdsLb::PickResult XdsLb::Picker::Pick(PickArgs args) { (rand() * pickers_[pickers_.size() - 1].first) / RAND_MAX; // Forward pick to whichever locality maps to the range in which the // random number falls in. - PickResult result = PickFromLocality(key, args); - // If pick succeeded, add client stats. - if (result.type == PickResult::PICK_COMPLETE && - result.subchannel != nullptr && client_stats_ != nullptr) { - // TODO(roth): Add support for client stats. - } - return result; + return PickFromLocality(key, args); } XdsLb::PickResult XdsLb::Picker::PickFromLocality(const uint32_t key, @@ -620,99 +751,46 @@ void XdsLb::FallbackHelper::AddTraceEvent(TraceSeverity severity, } // -// XdsLb::BalancerChannelState +// XdsLb::LbChannelState // -XdsLb::BalancerChannelState::BalancerChannelState( - const char* balancer_name, const grpc_channel_args& args, - RefCountedPtr parent_xdslb_policy) - : InternallyRefCounted(&grpc_lb_xds_trace), - xdslb_policy_(std::move(parent_xdslb_policy)), - lb_call_backoff_( - BackOff::Options() - .set_initial_backoff(GRPC_XDS_INITIAL_CONNECT_BACKOFF_SECONDS * - 1000) - .set_multiplier(GRPC_XDS_RECONNECT_BACKOFF_MULTIPLIER) - .set_jitter(GRPC_XDS_RECONNECT_JITTER) - .set_max_backoff(GRPC_XDS_RECONNECT_MAX_BACKOFF_SECONDS * 1000)) { - GRPC_CLOSURE_INIT(&on_connectivity_changed_, - &XdsLb::BalancerChannelState::OnConnectivityChangedLocked, +XdsLb::LbChannelState::LbChannelState(RefCountedPtr xdslb_policy, + const char* balancer_name, + const grpc_channel_args& args) + : InternallyRefCounted(&grpc_lb_xds_trace), + xdslb_policy_(std::move(xdslb_policy)) { + GRPC_CLOSURE_INIT(&on_connectivity_changed_, OnConnectivityChangedLocked, this, grpc_combiner_scheduler(xdslb_policy_->combiner())); channel_ = xdslb_policy_->channel_control_helper()->CreateChannel( balancer_name, args); GPR_ASSERT(channel_ != nullptr); - StartCallLocked(); + eds_calld_.reset(New>( + Ref(DEBUG_LOCATION, "LbChannelState+eds"))); + lrs_calld_.reset(New>( + Ref(DEBUG_LOCATION, "LbChannelState+lrs"))); } -XdsLb::BalancerChannelState::~BalancerChannelState() { - xdslb_policy_.reset(DEBUG_LOCATION, "BalancerChannelState"); +XdsLb::LbChannelState::~LbChannelState() { + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { + gpr_log(GPR_INFO, "[xdslb %p] Destroying LB channel %p", xdslb_policy(), + this); + } grpc_channel_destroy(channel_); } -void XdsLb::BalancerChannelState::Orphan() { +void XdsLb::LbChannelState::Orphan() { shutting_down_ = true; - lb_calld_.reset(); - if (retry_timer_callback_pending_) grpc_timer_cancel(&lb_call_retry_timer_); - Unref(DEBUG_LOCATION, "lb_channel_orphaned"); + eds_calld_.reset(); + lrs_calld_.reset(); + Unref(DEBUG_LOCATION, "LbChannelState+orphaned"); } -void XdsLb::BalancerChannelState::StartCallRetryTimerLocked() { - grpc_millis next_try = lb_call_backoff_.NextAttemptTime(); - if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { - gpr_log(GPR_INFO, - "[xdslb %p] Failed to connect to LB server (lb_chand: %p)...", - xdslb_policy_.get(), this); - grpc_millis timeout = next_try - ExecCtx::Get()->Now(); - if (timeout > 0) { - gpr_log(GPR_INFO, "[xdslb %p] ... retry_timer_active in %" PRId64 "ms.", - xdslb_policy_.get(), timeout); - } else { - gpr_log(GPR_INFO, "[xdslb %p] ... retry_timer_active immediately.", - xdslb_policy_.get()); - } - } - Ref(DEBUG_LOCATION, "on_balancer_call_retry_timer").release(); - GRPC_CLOSURE_INIT(&lb_on_call_retry_, &OnCallRetryTimerLocked, this, - grpc_combiner_scheduler(xdslb_policy_->combiner())); - grpc_timer_init(&lb_call_retry_timer_, next_try, &lb_on_call_retry_); - retry_timer_callback_pending_ = true; -} - -void XdsLb::BalancerChannelState::OnCallRetryTimerLocked(void* arg, - grpc_error* error) { - BalancerChannelState* lb_chand = static_cast(arg); - lb_chand->retry_timer_callback_pending_ = false; - if (!lb_chand->shutting_down_ && error == GRPC_ERROR_NONE && - lb_chand->lb_calld_ == nullptr) { - if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { - gpr_log(GPR_INFO, - "[xdslb %p] Restarting call to LB server (lb_chand: %p)", - lb_chand->xdslb_policy_.get(), lb_chand); - } - lb_chand->StartCallLocked(); - } - lb_chand->Unref(DEBUG_LOCATION, "on_balancer_call_retry_timer"); -} - -void XdsLb::BalancerChannelState::StartCallLocked() { - if (shutting_down_) return; - GPR_ASSERT(channel_ != nullptr); - GPR_ASSERT(lb_calld_ == nullptr); - lb_calld_ = MakeOrphanable(Ref()); - if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { - gpr_log(GPR_INFO, - "[xdslb %p] Query for backends (lb_chand: %p, lb_calld: %p)", - xdslb_policy_.get(), this, lb_calld_.get()); - } - lb_calld_->StartQuery(); -} - -void XdsLb::BalancerChannelState::StartConnectivityWatchLocked() { +void XdsLb::LbChannelState::StartConnectivityWatchLocked() { grpc_channel_element* client_channel_elem = grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel_)); GPR_ASSERT(client_channel_elem->filter == &grpc_client_channel_filter); // Ref held by callback. - Ref(DEBUG_LOCATION, "watch_lb_channel_connectivity").release(); + Ref(DEBUG_LOCATION, "LbChannelState+start_watch").release(); grpc_client_channel_watch_connectivity_state( client_channel_elem, grpc_polling_entity_create_from_pollset_set( @@ -720,7 +798,7 @@ void XdsLb::BalancerChannelState::StartConnectivityWatchLocked() { &connectivity_, &on_connectivity_changed_, nullptr); } -void XdsLb::BalancerChannelState::CancelConnectivityWatchLocked() { +void XdsLb::LbChannelState::CancelConnectivityWatchLocked() { grpc_channel_element* client_channel_elem = grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel_)); GPR_ASSERT(client_channel_elem->filter == &grpc_client_channel_filter); @@ -731,9 +809,9 @@ void XdsLb::BalancerChannelState::CancelConnectivityWatchLocked() { nullptr, &on_connectivity_changed_, nullptr); } -void XdsLb::BalancerChannelState::OnConnectivityChangedLocked( - void* arg, grpc_error* error) { - BalancerChannelState* self = static_cast(arg); +void XdsLb::LbChannelState::OnConnectivityChangedLocked(void* arg, + grpc_error* error) { + LbChannelState* self = static_cast(arg); if (!self->shutting_down_ && self->xdslb_policy_->fallback_at_startup_checks_pending_) { if (self->connectivity_ != GRPC_CHANNEL_TRANSIENT_FAILURE) { @@ -760,22 +838,113 @@ void XdsLb::BalancerChannelState::OnConnectivityChangedLocked( self->xdslb_policy_->UpdateFallbackPolicyLocked(); } // Done watching connectivity state, so drop ref. - self->Unref(DEBUG_LOCATION, "watch_lb_channel_connectivity"); + self->Unref(DEBUG_LOCATION, "LbChannelState+watch_done"); } // -// XdsLb::BalancerChannelState::BalancerCallState +// XdsLb::LbChannelState::RetryableLbCall<> // -XdsLb::BalancerChannelState::BalancerCallState::BalancerCallState( - RefCountedPtr lb_chand) - : InternallyRefCounted(&grpc_lb_xds_trace), - lb_chand_(std::move(lb_chand)) { - GPR_ASSERT(xdslb_policy() != nullptr); - GPR_ASSERT(!xdslb_policy()->shutting_down_); +template +XdsLb::LbChannelState::RetryableLbCall::RetryableLbCall( + RefCountedPtr lb_chand) + : lb_chand_(std::move(lb_chand)), + backoff_( + BackOff::Options() + .set_initial_backoff(GRPC_XDS_INITIAL_CONNECT_BACKOFF_SECONDS * + 1000) + .set_multiplier(GRPC_XDS_RECONNECT_BACKOFF_MULTIPLIER) + .set_jitter(GRPC_XDS_RECONNECT_JITTER) + .set_max_backoff(GRPC_XDS_RECONNECT_MAX_BACKOFF_SECONDS * 1000)) { + GRPC_CLOSURE_INIT( + &on_retry_timer_, OnRetryTimerLocked, this, + grpc_combiner_scheduler(lb_chand_->xdslb_policy()->combiner())); + StartNewCallLocked(); +} + +template +void XdsLb::LbChannelState::RetryableLbCall::Orphan() { + shutting_down_ = true; + lb_calld_.reset(); + if (retry_timer_callback_pending_) grpc_timer_cancel(&retry_timer_); + this->Unref(DEBUG_LOCATION, "RetryableLbCall+orphaned"); +} + +template +void XdsLb::LbChannelState::RetryableLbCall::OnCallFinishedLocked() { + const bool seen_response = lb_calld_->seen_response(); + lb_calld_.reset(); + if (seen_response) { + // If we lost connection to the LB server, reset backoff and restart the LB + // call immediately. + backoff_.Reset(); + StartNewCallLocked(); + } else { + // If we failed to connect to the LB server, retry later. + StartRetryTimerLocked(); + } +} + +template +void XdsLb::LbChannelState::RetryableLbCall::StartNewCallLocked() { + if (shutting_down_) return; + GPR_ASSERT(lb_chand_->channel_ != nullptr); + GPR_ASSERT(lb_calld_ == nullptr); + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { + gpr_log(GPR_INFO, + "[xdslb %p] Start new call from retryable call (lb_chand: %p, " + "retryable call: %p)", + lb_chand()->xdslb_policy(), lb_chand(), this); + } + lb_calld_ = MakeOrphanable( + this->Ref(DEBUG_LOCATION, "RetryableLbCall+start_new_call")); +} + +template +void XdsLb::LbChannelState::RetryableLbCall::StartRetryTimerLocked() { + if (shutting_down_) return; + const grpc_millis next_attempt_time = backoff_.NextAttemptTime(); + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { + grpc_millis timeout = GPR_MAX(next_attempt_time - ExecCtx::Get()->Now(), 0); + gpr_log(GPR_INFO, + "[xdslb %p] Failed to connect to LB server (lb_chand: %p) " + "retry timer will fire in %" PRId64 "ms.", + lb_chand()->xdslb_policy(), lb_chand(), timeout); + } + this->Ref(DEBUG_LOCATION, "RetryableLbCall+retry_timer_start").release(); + grpc_timer_init(&retry_timer_, next_attempt_time, &on_retry_timer_); + retry_timer_callback_pending_ = true; +} + +template +void XdsLb::LbChannelState::RetryableLbCall::OnRetryTimerLocked( + void* arg, grpc_error* error) { + RetryableLbCall* lb_calld = static_cast(arg); + lb_calld->retry_timer_callback_pending_ = false; + if (!lb_calld->shutting_down_ && error == GRPC_ERROR_NONE) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { + gpr_log(GPR_INFO, + "[xdslb %p] Retry timer fires (lb_chand: %p, retryable call: %p)", + lb_calld->lb_chand()->xdslb_policy(), lb_calld->lb_chand(), + lb_calld); + } + lb_calld->StartNewCallLocked(); + } + lb_calld->Unref(DEBUG_LOCATION, "RetryableLbCall+retry_timer_done"); +} + +// +// XdsLb::LbChannelState::EdsCallState +// + +XdsLb::LbChannelState::EdsCallState::EdsCallState( + RefCountedPtr> parent) + : InternallyRefCounted(&grpc_lb_xds_trace), + parent_(std::move(parent)) { // Init the LB call. Note that the LB call will progress every time there's - // activity in xdslb_policy_->interested_parties(), which is comprised of + // activity in xdslb_policy()->interested_parties(), which is comprised of // the polling entities from client_channel. + GPR_ASSERT(xdslb_policy() != nullptr); GPR_ASSERT(xdslb_policy()->server_name_ != nullptr); GPR_ASSERT(xdslb_policy()->server_name_[0] != '\0'); const grpc_millis deadline = @@ -784,10 +953,11 @@ XdsLb::BalancerChannelState::BalancerCallState::BalancerCallState( : ExecCtx::Get()->Now() + xdslb_policy()->lb_call_timeout_ms_; // Create an LB call with the specified method name. lb_call_ = grpc_channel_create_pollset_set_call( - lb_chand_->channel_, nullptr, GRPC_PROPAGATE_DEFAULTS, + lb_chand()->channel_, nullptr, GRPC_PROPAGATE_DEFAULTS, xdslb_policy()->interested_parties(), GRPC_MDSTR_SLASH_ENVOY_DOT_API_DOT_V2_DOT_ENDPOINTDISCOVERYSERVICE_SLASH_STREAMENDPOINTS, nullptr, deadline, nullptr); + GPR_ASSERT(lb_call_ != nullptr); // Init the LB call request payload. grpc_slice request_payload_slice = XdsEdsRequestCreateAndEncode(xdslb_policy()->server_name_); @@ -795,48 +965,18 @@ XdsLb::BalancerChannelState::BalancerCallState::BalancerCallState( grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_slice_unref_internal(request_payload_slice); // Init other data associated with the LB call. - grpc_metadata_array_init(&lb_initial_metadata_recv_); - grpc_metadata_array_init(&lb_trailing_metadata_recv_); - GRPC_CLOSURE_INIT(&lb_on_initial_request_sent_, OnInitialRequestSentLocked, - this, grpc_combiner_scheduler(xdslb_policy()->combiner())); - GRPC_CLOSURE_INIT(&lb_on_balancer_message_received_, - OnBalancerMessageReceivedLocked, this, + grpc_metadata_array_init(&initial_metadata_recv_); + grpc_metadata_array_init(&trailing_metadata_recv_); + GRPC_CLOSURE_INIT(&on_response_received_, OnResponseReceivedLocked, this, grpc_combiner_scheduler(xdslb_policy()->combiner())); - GRPC_CLOSURE_INIT(&lb_on_balancer_status_received_, - OnBalancerStatusReceivedLocked, this, + GRPC_CLOSURE_INIT(&on_status_received_, OnStatusReceivedLocked, this, grpc_combiner_scheduler(xdslb_policy()->combiner())); -} - -XdsLb::BalancerChannelState::BalancerCallState::~BalancerCallState() { - GPR_ASSERT(lb_call_ != nullptr); - grpc_call_unref(lb_call_); - grpc_metadata_array_destroy(&lb_initial_metadata_recv_); - grpc_metadata_array_destroy(&lb_trailing_metadata_recv_); - grpc_byte_buffer_destroy(send_message_payload_); - grpc_byte_buffer_destroy(recv_message_payload_); - grpc_slice_unref_internal(lb_call_status_details_); -} - -void XdsLb::BalancerChannelState::BalancerCallState::Orphan() { - GPR_ASSERT(lb_call_ != nullptr); - // If we are here because xdslb_policy wants to cancel the call, - // lb_on_balancer_status_received_ will complete the cancellation and clean - // up. Otherwise, we are here because xdslb_policy has to orphan a failed - // call, then the following cancellation will be a no-op. - grpc_call_cancel(lb_call_, nullptr); - if (client_load_report_timer_callback_pending_) { - grpc_timer_cancel(&client_load_report_timer_); - } - // Note that the initial ref is hold by lb_on_balancer_status_received_ - // instead of the caller of this function. So the corresponding unref happens - // in lb_on_balancer_status_received_ instead of here. -} - -void XdsLb::BalancerChannelState::BalancerCallState::StartQuery() { - GPR_ASSERT(lb_call_ != nullptr); + // Start the call. if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { - gpr_log(GPR_INFO, "[xdslb %p] Starting LB call (lb_calld: %p, lb_call: %p)", - xdslb_policy(), this, lb_call_); + gpr_log(GPR_INFO, + "[xdslb %p] Starting EDS call (lb_chand: %p, lb_calld: %p, " + "lb_call: %p)", + xdslb_policy(), lb_chand(), this, lb_call_); } // Create the ops. grpc_call_error call_error; @@ -856,19 +996,14 @@ void XdsLb::BalancerChannelState::BalancerCallState::StartQuery() { op->flags = 0; op->reserved = nullptr; op++; - // TODO(roth): We currently track this ref manually. Once the - // ClosureRef API is ready, we should pass the RefCountedPtr<> along - // with the callback. - auto self = Ref(DEBUG_LOCATION, "on_initial_request_sent"); - self.release(); - call_error = grpc_call_start_batch_and_execute( - lb_call_, ops, (size_t)(op - ops), &lb_on_initial_request_sent_); + call_error = grpc_call_start_batch_and_execute(lb_call_, ops, + (size_t)(op - ops), nullptr); GPR_ASSERT(GRPC_CALL_OK == call_error); // Op: recv initial metadata. op = ops; op->op = GRPC_OP_RECV_INITIAL_METADATA; op->data.recv_initial_metadata.recv_initial_metadata = - &lb_initial_metadata_recv_; + &initial_metadata_recv_; op->flags = 0; op->reserved = nullptr; op++; @@ -878,21 +1013,16 @@ void XdsLb::BalancerChannelState::BalancerCallState::StartQuery() { op->flags = 0; op->reserved = nullptr; op++; - // TODO(roth): We currently track this ref manually. Once the - // ClosureRef API is ready, we should pass the RefCountedPtr<> along - // with the callback. - self = Ref(DEBUG_LOCATION, "on_message_received"); - self.release(); + Ref(DEBUG_LOCATION, "EDS+OnResponseReceivedLocked").release(); call_error = grpc_call_start_batch_and_execute( - lb_call_, ops, (size_t)(op - ops), &lb_on_balancer_message_received_); + lb_call_, ops, (size_t)(op - ops), &on_response_received_); GPR_ASSERT(GRPC_CALL_OK == call_error); // Op: recv server status. op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; - op->data.recv_status_on_client.trailing_metadata = - &lb_trailing_metadata_recv_; - op->data.recv_status_on_client.status = &lb_call_status_; - op->data.recv_status_on_client.status_details = &lb_call_status_details_; + op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv_; + op->data.recv_status_on_client.status = &status_code_; + op->data.recv_status_on_client.status_details = &status_details_; op->flags = 0; op->reserved = nullptr; op++; @@ -900,113 +1030,49 @@ void XdsLb::BalancerChannelState::BalancerCallState::StartQuery() { // ref instead of a new ref. When it's invoked, it's the initial ref that is // unreffed. call_error = grpc_call_start_batch_and_execute( - lb_call_, ops, (size_t)(op - ops), &lb_on_balancer_status_received_); + lb_call_, ops, (size_t)(op - ops), &on_status_received_); GPR_ASSERT(GRPC_CALL_OK == call_error); } -void XdsLb::BalancerChannelState::BalancerCallState:: - ScheduleNextClientLoadReportLocked() { - const grpc_millis next_client_load_report_time = - ExecCtx::Get()->Now() + client_stats_report_interval_; - GRPC_CLOSURE_INIT(&client_load_report_closure_, - MaybeSendClientLoadReportLocked, this, - grpc_combiner_scheduler(xdslb_policy()->combiner())); - grpc_timer_init(&client_load_report_timer_, next_client_load_report_time, - &client_load_report_closure_); - client_load_report_timer_callback_pending_ = true; +XdsLb::LbChannelState::EdsCallState::~EdsCallState() { + grpc_metadata_array_destroy(&initial_metadata_recv_); + grpc_metadata_array_destroy(&trailing_metadata_recv_); + grpc_byte_buffer_destroy(send_message_payload_); + grpc_byte_buffer_destroy(recv_message_payload_); + grpc_slice_unref_internal(status_details_); + GPR_ASSERT(lb_call_ != nullptr); + grpc_call_unref(lb_call_); } -void XdsLb::BalancerChannelState::BalancerCallState:: - MaybeSendClientLoadReportLocked(void* arg, grpc_error* error) { - BalancerCallState* lb_calld = static_cast(arg); - lb_calld->client_load_report_timer_callback_pending_ = false; - if (error != GRPC_ERROR_NONE || !lb_calld->IsCurrentCallOnChannel()) { - lb_calld->Unref(DEBUG_LOCATION, "client_load_report"); - return; - } - // If we've already sent the initial request, then we can go ahead and send - // the load report. Otherwise, we need to wait until the initial request has - // been sent to send this (see OnInitialRequestSentLocked()). - if (lb_calld->send_message_payload_ == nullptr) { - lb_calld->SendClientLoadReportLocked(); - } else { - lb_calld->client_load_report_is_due_ = true; - } +void XdsLb::LbChannelState::EdsCallState::Orphan() { + GPR_ASSERT(lb_call_ != nullptr); + // If we are here because xdslb_policy wants to cancel the call, + // on_status_received_ will complete the cancellation and clean up. Otherwise, + // we are here because xdslb_policy has to orphan a failed call, then the + // following cancellation will be a no-op. + grpc_call_cancel(lb_call_, nullptr); + // Note that the initial ref is hold by on_status_received_. So the + // corresponding unref happens in on_status_received_ instead of here. } -bool XdsLb::BalancerChannelState::BalancerCallState::LoadReportCountersAreZero( - xds_grpclb_request* request) { - const grpc_lb_v1_ClientStats* cstats = - grpc_lb_v1_LoadBalanceRequest_client_stats(request); - if (cstats == nullptr) { - return true; - } - size_t drop_count; - grpc_lb_v1_ClientStats_calls_finished_with_drop(cstats, &drop_count); - return grpc_lb_v1_ClientStats_num_calls_started(cstats) == 0 && - grpc_lb_v1_ClientStats_num_calls_finished(cstats) == 0 && - grpc_lb_v1_ClientStats_num_calls_finished_with_client_failed_to_send( - cstats) == 0 && - grpc_lb_v1_ClientStats_num_calls_finished_known_received(cstats) == - 0 && - drop_count == 0; -} - -// TODO(vpowar): Use LRS to send the client Load Report. -void XdsLb::BalancerChannelState::BalancerCallState:: - SendClientLoadReportLocked() { - // Construct message payload. - GPR_ASSERT(send_message_payload_ == nullptr); - upb::Arena arena; - xds_grpclb_request* request = xds_grpclb_load_report_request_create_locked( - client_stats_.get(), arena.ptr()); - // Skip client load report if the counters were all zero in the last - // report and they are still zero in this one. - if (LoadReportCountersAreZero(request)) { - if (last_client_load_report_counters_were_zero_) { - ScheduleNextClientLoadReportLocked(); - return; - } - last_client_load_report_counters_were_zero_ = true; - } else { - last_client_load_report_counters_were_zero_ = false; - } - // TODO(vpowar): Send the report on LRS stream. -} - -void XdsLb::BalancerChannelState::BalancerCallState::OnInitialRequestSentLocked( +void XdsLb::LbChannelState::EdsCallState::OnResponseReceivedLocked( void* arg, grpc_error* error) { - BalancerCallState* lb_calld = static_cast(arg); - grpc_byte_buffer_destroy(lb_calld->send_message_payload_); - lb_calld->send_message_payload_ = nullptr; - // If we attempted to send a client load report before the initial request was - // sent (and this lb_calld is still in use), send the load report now. - if (lb_calld->client_load_report_is_due_ && - lb_calld->IsCurrentCallOnChannel()) { - lb_calld->SendClientLoadReportLocked(); - lb_calld->client_load_report_is_due_ = false; - } - lb_calld->Unref(DEBUG_LOCATION, "on_initial_request_sent"); -} - -void XdsLb::BalancerChannelState::BalancerCallState:: - OnBalancerMessageReceivedLocked(void* arg, grpc_error* error) { - BalancerCallState* lb_calld = static_cast(arg); - XdsLb* xdslb_policy = lb_calld->xdslb_policy(); + EdsCallState* eds_calld = static_cast(arg); + LbChannelState* lb_chand = eds_calld->lb_chand(); + XdsLb* xdslb_policy = eds_calld->xdslb_policy(); // Empty payload means the LB call was cancelled. - if (!lb_calld->IsCurrentCallOnChannel() || - lb_calld->recv_message_payload_ == nullptr) { - lb_calld->Unref(DEBUG_LOCATION, "on_message_received"); + if (!eds_calld->IsCurrentCallOnChannel() || + eds_calld->recv_message_payload_ == nullptr) { + eds_calld->Unref(DEBUG_LOCATION, "EDS+OnResponseReceivedLocked"); return; } - lb_calld->seen_response_ = true; // Read the response. grpc_byte_buffer_reader bbr; - grpc_byte_buffer_reader_init(&bbr, lb_calld->recv_message_payload_); + grpc_byte_buffer_reader_init(&bbr, eds_calld->recv_message_payload_); grpc_slice response_slice = grpc_byte_buffer_reader_readall(&bbr); grpc_byte_buffer_reader_destroy(&bbr); - grpc_byte_buffer_destroy(lb_calld->recv_message_payload_); - lb_calld->recv_message_payload_ = nullptr; + grpc_byte_buffer_destroy(eds_calld->recv_message_payload_); + eds_calld->recv_message_payload_ = nullptr; // TODO(juanlishen): When we convert this to use the xds protocol, the // balancer will send us a fallback timeout such that we should go into // fallback mode if we have lost contact with the balancer after a certain @@ -1037,6 +1103,7 @@ void XdsLb::BalancerChannelState::BalancerCallState:: gpr_free(response_slice_str); return; } + eds_calld->seen_response_ = true; if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { gpr_log(GPR_INFO, "[xdslb %p] EDS response with %" PRIuPTR " localities received", @@ -1066,25 +1133,21 @@ void XdsLb::BalancerChannelState::BalancerCallState:: // Note that this call can't be on a discarded pending channel, because // such channels don't have any current call but we have checked this call // is a current call. - if (!lb_calld->lb_chand_->IsCurrentChannel()) { + if (!lb_chand->IsCurrentChannel()) { if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { gpr_log(GPR_INFO, - "[xdslb %p] Promoting pending LB channel %p to replace " - "current LB channel %p", - xdslb_policy, lb_calld->lb_chand_.get(), - lb_calld->xdslb_policy()->lb_chand_.get()); + "[xdslb %p] Pending LB channel %p receives EDS response; " + "promoting it to replace current LB channel %p", + xdslb_policy, lb_chand, xdslb_policy->lb_chand_.get()); } - lb_calld->xdslb_policy()->lb_chand_ = - std::move(lb_calld->xdslb_policy()->pending_lb_chand_); - } - // Start sending client load report only after we start using the - // serverlist returned from the current LB call. - if (lb_calld->client_stats_report_interval_ > 0 && - lb_calld->client_stats_ == nullptr) { - lb_calld->client_stats_ = MakeRefCounted(); - lb_calld->Ref(DEBUG_LOCATION, "client_load_report").release(); - lb_calld->ScheduleNextClientLoadReportLocked(); + // TODO(juanlishen): Maybe promote the pending LB channel when the + // response results a READY locality map. + xdslb_policy->lb_chand_ = std::move(xdslb_policy->pending_lb_chand_); } + // At this point, lb_chand must be the current LB channel, so try to start + // load reporting. + LrsCallState* lrs_calld = lb_chand->lrs_calld_->lb_calld(); + if (lrs_calld != nullptr) lrs_calld->MaybeStartReportingLocked(); // Ignore identical update. if (xdslb_policy->locality_list_ == update.locality_list) { if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { @@ -1111,45 +1174,43 @@ void XdsLb::BalancerChannelState::BalancerCallState:: }(); grpc_slice_unref_internal(response_slice); if (xdslb_policy->shutting_down_) { - lb_calld->Unref(DEBUG_LOCATION, "on_message_received+xds_shutdown"); + eds_calld->Unref(DEBUG_LOCATION, + "EDS+OnResponseReceivedLocked+xds_shutdown"); return; } // Keep listening for serverlist updates. grpc_op op; memset(&op, 0, sizeof(op)); op.op = GRPC_OP_RECV_MESSAGE; - op.data.recv_message.recv_message = &lb_calld->recv_message_payload_; + op.data.recv_message.recv_message = &eds_calld->recv_message_payload_; op.flags = 0; op.reserved = nullptr; - GPR_ASSERT(lb_calld->lb_call_ != nullptr); - // Reuse the "OnBalancerMessageReceivedLocked" ref taken in StartQuery(). + GPR_ASSERT(eds_calld->lb_call_ != nullptr); + // Reuse the "EDS+OnResponseReceivedLocked" ref taken in ctor. const grpc_call_error call_error = grpc_call_start_batch_and_execute( - lb_calld->lb_call_, &op, 1, &lb_calld->lb_on_balancer_message_received_); + eds_calld->lb_call_, &op, 1, &eds_calld->on_response_received_); GPR_ASSERT(GRPC_CALL_OK == call_error); } -void XdsLb::BalancerChannelState::BalancerCallState:: - OnBalancerStatusReceivedLocked(void* arg, grpc_error* error) { - BalancerCallState* lb_calld = static_cast(arg); - XdsLb* xdslb_policy = lb_calld->xdslb_policy(); - BalancerChannelState* lb_chand = lb_calld->lb_chand_.get(); - GPR_ASSERT(lb_calld->lb_call_ != nullptr); +void XdsLb::LbChannelState::EdsCallState::OnStatusReceivedLocked( + void* arg, grpc_error* error) { + EdsCallState* eds_calld = static_cast(arg); + LbChannelState* lb_chand = eds_calld->lb_chand(); + XdsLb* xdslb_policy = eds_calld->xdslb_policy(); if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { - char* status_details = - grpc_slice_to_c_string(lb_calld->lb_call_status_details_); + char* status_details = grpc_slice_to_c_string(eds_calld->status_details_); gpr_log(GPR_INFO, - "[xdslb %p] Status from LB server received. Status = %d, details " - "= '%s', (lb_chand: %p, lb_calld: %p, lb_call: %p), error '%s'", - xdslb_policy, lb_calld->lb_call_status_, status_details, lb_chand, - lb_calld, lb_calld->lb_call_, grpc_error_string(error)); + "[xdslb %p] EDS call status received. Status = %d, details " + "= '%s', (lb_chand: %p, eds_calld: %p, lb_call: %p), error '%s'", + xdslb_policy, eds_calld->status_code_, status_details, lb_chand, + eds_calld, eds_calld->lb_call_, grpc_error_string(error)); gpr_free(status_details); } // Ignore status from a stale call. - if (lb_calld->IsCurrentCallOnChannel()) { + if (eds_calld->IsCurrentCallOnChannel()) { // Because this call is the current one on the channel, the channel can't // have been swapped out; otherwise, the call should have been reset. GPR_ASSERT(lb_chand->IsCurrentChannel() || lb_chand->IsPendingChannel()); - GPR_ASSERT(!xdslb_policy->shutting_down_); if (lb_chand != xdslb_policy->LatestLbChannel()) { // This channel must be the current one and there is a pending one. Swap // in the pending one and we are done. @@ -1157,23 +1218,13 @@ void XdsLb::BalancerChannelState::BalancerCallState:: gpr_log(GPR_INFO, "[xdslb %p] Promoting pending LB channel %p to replace " "current LB channel %p", - xdslb_policy, lb_calld->lb_chand_.get(), - lb_calld->xdslb_policy()->lb_chand_.get()); + xdslb_policy, lb_chand, xdslb_policy->lb_chand_.get()); } xdslb_policy->lb_chand_ = std::move(xdslb_policy->pending_lb_chand_); } else { // This channel is the most recently created one. Try to restart the call // and reresolve. - lb_chand->lb_calld_.reset(); - if (lb_calld->seen_response_) { - // If we lost connection to the LB server, reset the backoff and restart - // the LB call immediately. - lb_chand->lb_call_backoff_.Reset(); - lb_chand->StartCallLocked(); - } else { - // If we failed to connect to the LB server, retry later. - lb_chand->StartCallRetryTimerLocked(); - } + eds_calld->parent_->OnCallFinishedLocked(); xdslb_policy->channel_control_helper()->RequestReresolution(); // If the fallback-at-startup checks are pending, go into fallback mode // immediately. This short-circuits the timeout for the @@ -1189,7 +1240,369 @@ void XdsLb::BalancerChannelState::BalancerCallState:: } } } - lb_calld->Unref(DEBUG_LOCATION, "lb_call_ended"); + eds_calld->Unref(DEBUG_LOCATION, "EDS+OnStatusReceivedLocked"); +} + +bool XdsLb::LbChannelState::EdsCallState::IsCurrentCallOnChannel() const { + // If the retryable EDS call is null (which only happens when the LB channel + // is shutting down), all the EDS calls are stale. + if (lb_chand()->eds_calld_ == nullptr) return false; + return this == lb_chand()->eds_calld_->lb_calld(); +} + +// +// XdsLb::LbChannelState::LrsCallState::Reporter +// + +void XdsLb::LbChannelState::LrsCallState::Reporter::Orphan() { + if (next_report_timer_callback_pending_) { + grpc_timer_cancel(&next_report_timer_); + } +} + +void XdsLb::LbChannelState::LrsCallState::Reporter::ScheduleNextReportLocked() { + const grpc_millis next_report_time = ExecCtx::Get()->Now() + report_interval_; + grpc_timer_init(&next_report_timer_, next_report_time, + &on_next_report_timer_); + next_report_timer_callback_pending_ = true; +} + +void XdsLb::LbChannelState::LrsCallState::Reporter::OnNextReportTimerLocked( + void* arg, grpc_error* error) { + Reporter* self = static_cast(arg); + self->next_report_timer_callback_pending_ = false; + if (error != GRPC_ERROR_NONE || !self->IsCurrentReporterOnCall()) { + self->Unref(DEBUG_LOCATION, "Reporter+timer"); + return; + } + self->SendReportLocked(); +} + +void XdsLb::LbChannelState::LrsCallState::Reporter::SendReportLocked() { + // Create a request that contains the load report. + grpc_slice request_payload_slice = XdsLrsRequestCreateAndEncode( + xdslb_policy()->server_name_, &xdslb_policy()->client_stats_); + // Skip client load report if the counters were all zero in the last + // report and they are still zero in this one. + const bool old_val = last_report_counters_were_zero_; + last_report_counters_were_zero_ = static_cast( + grpc_slice_eq(request_payload_slice, grpc_empty_slice())); + if (old_val && last_report_counters_were_zero_) { + ScheduleNextReportLocked(); + return; + } + parent_->send_message_payload_ = + grpc_raw_byte_buffer_create(&request_payload_slice, 1); + grpc_slice_unref_internal(request_payload_slice); + // Send the report. + grpc_op op; + memset(&op, 0, sizeof(op)); + op.op = GRPC_OP_SEND_MESSAGE; + op.data.send_message.send_message = parent_->send_message_payload_; + grpc_call_error call_error = grpc_call_start_batch_and_execute( + parent_->lb_call_, &op, 1, &on_report_done_); + if (GPR_UNLIKELY(call_error != GRPC_CALL_OK)) { + gpr_log(GPR_ERROR, + "[xdslb %p] lb_calld=%p call_error=%d sending client load report", + xdslb_policy(), this, call_error); + GPR_ASSERT(GRPC_CALL_OK == call_error); + } +} + +void XdsLb::LbChannelState::LrsCallState::Reporter::OnReportDoneLocked( + void* arg, grpc_error* error) { + Reporter* self = static_cast(arg); + grpc_byte_buffer_destroy(self->parent_->send_message_payload_); + self->parent_->send_message_payload_ = nullptr; + if (error != GRPC_ERROR_NONE || !self->IsCurrentReporterOnCall()) { + // If this reporter is no longer the current one on the call, the reason + // might be that it was orphaned for a new one due to config update. + if (!self->IsCurrentReporterOnCall()) { + self->parent_->MaybeStartReportingLocked(); + } + self->Unref(DEBUG_LOCATION, "Reporter+report_done"); + return; + } + self->ScheduleNextReportLocked(); +} + +// +// XdsLb::LbChannelState::LrsCallState +// + +XdsLb::LbChannelState::LrsCallState::LrsCallState( + RefCountedPtr> parent) + : InternallyRefCounted(&grpc_lb_xds_trace), + parent_(std::move(parent)) { + // Init the LB call. Note that the LB call will progress every time there's + // activity in xdslb_policy()->interested_parties(), which is comprised of + // the polling entities from client_channel. + GPR_ASSERT(xdslb_policy() != nullptr); + GPR_ASSERT(xdslb_policy()->server_name_ != nullptr); + GPR_ASSERT(xdslb_policy()->server_name_[0] != '\0'); + const grpc_millis deadline = + xdslb_policy()->lb_call_timeout_ms_ == 0 + ? GRPC_MILLIS_INF_FUTURE + : ExecCtx::Get()->Now() + xdslb_policy()->lb_call_timeout_ms_; + lb_call_ = grpc_channel_create_pollset_set_call( + lb_chand()->channel_, nullptr, GRPC_PROPAGATE_DEFAULTS, + xdslb_policy()->interested_parties(), + GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_LOAD_STATS_DOT_V2_DOT_LOADREPORTINGSERVICE_SLASH_STREAMLOADSTATS, + nullptr, deadline, nullptr); + GPR_ASSERT(lb_call_ != nullptr); + // Init the LB call request payload. + grpc_slice request_payload_slice = + XdsLrsRequestCreateAndEncode(xdslb_policy()->server_name_); + send_message_payload_ = + grpc_raw_byte_buffer_create(&request_payload_slice, 1); + grpc_slice_unref_internal(request_payload_slice); + // Init other data associated with the LRS call. + grpc_metadata_array_init(&initial_metadata_recv_); + grpc_metadata_array_init(&trailing_metadata_recv_); + GRPC_CLOSURE_INIT(&on_initial_request_sent_, OnInitialRequestSentLocked, this, + grpc_combiner_scheduler(xdslb_policy()->combiner())); + GRPC_CLOSURE_INIT(&on_response_received_, OnResponseReceivedLocked, this, + grpc_combiner_scheduler(xdslb_policy()->combiner())); + GRPC_CLOSURE_INIT(&on_status_received_, OnStatusReceivedLocked, this, + grpc_combiner_scheduler(xdslb_policy()->combiner())); + // Start the call. + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { + gpr_log(GPR_INFO, + "[xdslb %p] Starting LRS call (lb_chand: %p, lb_calld: %p, " + "lb_call: %p)", + xdslb_policy(), lb_chand(), this, lb_call_); + } + // Create the ops. + grpc_call_error call_error; + grpc_op ops[3]; + memset(ops, 0, sizeof(ops)); + // Op: send initial metadata. + grpc_op* op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op->reserved = nullptr; + op++; + // Op: send request message. + GPR_ASSERT(send_message_payload_ != nullptr); + op->op = GRPC_OP_SEND_MESSAGE; + op->data.send_message.send_message = send_message_payload_; + op->flags = 0; + op->reserved = nullptr; + op++; + Ref(DEBUG_LOCATION, "LRS+OnInitialRequestSentLocked").release(); + call_error = grpc_call_start_batch_and_execute( + lb_call_, ops, (size_t)(op - ops), &on_initial_request_sent_); + GPR_ASSERT(GRPC_CALL_OK == call_error); + // Op: recv initial metadata. + op = ops; + op->op = GRPC_OP_RECV_INITIAL_METADATA; + op->data.recv_initial_metadata.recv_initial_metadata = + &initial_metadata_recv_; + op->flags = 0; + op->reserved = nullptr; + op++; + // Op: recv response. + op->op = GRPC_OP_RECV_MESSAGE; + op->data.recv_message.recv_message = &recv_message_payload_; + op->flags = 0; + op->reserved = nullptr; + op++; + Ref(DEBUG_LOCATION, "LRS+OnResponseReceivedLocked").release(); + call_error = grpc_call_start_batch_and_execute( + lb_call_, ops, (size_t)(op - ops), &on_response_received_); + GPR_ASSERT(GRPC_CALL_OK == call_error); + // Op: recv server status. + op = ops; + op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; + op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv_; + op->data.recv_status_on_client.status = &status_code_; + op->data.recv_status_on_client.status_details = &status_details_; + op->flags = 0; + op->reserved = nullptr; + op++; + // This callback signals the end of the LB call, so it relies on the initial + // ref instead of a new ref. When it's invoked, it's the initial ref that is + // unreffed. + call_error = grpc_call_start_batch_and_execute( + lb_call_, ops, (size_t)(op - ops), &on_status_received_); + GPR_ASSERT(GRPC_CALL_OK == call_error); +} + +XdsLb::LbChannelState::LrsCallState::~LrsCallState() { + grpc_metadata_array_destroy(&initial_metadata_recv_); + grpc_metadata_array_destroy(&trailing_metadata_recv_); + grpc_byte_buffer_destroy(send_message_payload_); + grpc_byte_buffer_destroy(recv_message_payload_); + grpc_slice_unref_internal(status_details_); + GPR_ASSERT(lb_call_ != nullptr); + grpc_call_unref(lb_call_); +} + +void XdsLb::LbChannelState::LrsCallState::Orphan() { + reporter_.reset(); + GPR_ASSERT(lb_call_ != nullptr); + // If we are here because xdslb_policy wants to cancel the call, + // on_status_received_ will complete the cancellation and clean up. Otherwise, + // we are here because xdslb_policy has to orphan a failed call, then the + // following cancellation will be a no-op. + grpc_call_cancel(lb_call_, nullptr); + // Note that the initial ref is hold by on_status_received_. So the + // corresponding unref happens in on_status_received_ instead of here. +} + +void XdsLb::LbChannelState::LrsCallState::MaybeStartReportingLocked() { + // Don't start if this is not the current call on the current channel. + if (!IsCurrentCallOnChannel() || !lb_chand()->IsCurrentChannel()) return; + // Don't start again if already started. + if (reporter_ != nullptr) return; + // Don't start if the previous send_message op (of the initial request or the + // last report of the previous reporter) hasn't completed. + if (send_message_payload_ != nullptr) return; + // Don't start if no LRS response has arrived. + if (!seen_response()) return; + // Don't start if the EDS call hasn't received any valid response. Note that + // this must be the first channel because it is the current channel but its + // EDS call hasn't seen any response. + EdsCallState* eds_calld = lb_chand()->eds_calld_->lb_calld(); + if (eds_calld == nullptr || !eds_calld->seen_response()) return; + // Start reporting. + lb_chand()->xdslb_policy_->client_stats_.MaybeInitLastReportTime(); + reporter_ = MakeOrphanable( + Ref(DEBUG_LOCATION, "LRS+load_report+start"), load_reporting_interval_); +} + +void XdsLb::LbChannelState::LrsCallState::OnInitialRequestSentLocked( + void* arg, grpc_error* error) { + LrsCallState* lrs_calld = static_cast(arg); + // Clear the send_message_payload_. + grpc_byte_buffer_destroy(lrs_calld->send_message_payload_); + lrs_calld->send_message_payload_ = nullptr; + lrs_calld->MaybeStartReportingLocked(); + lrs_calld->Unref(DEBUG_LOCATION, "LRS+OnInitialRequestSentLocked"); +} + +void XdsLb::LbChannelState::LrsCallState::OnResponseReceivedLocked( + void* arg, grpc_error* error) { + LrsCallState* lrs_calld = static_cast(arg); + XdsLb* xdslb_policy = lrs_calld->xdslb_policy(); + // Empty payload means the LB call was cancelled. + if (!lrs_calld->IsCurrentCallOnChannel() || + lrs_calld->recv_message_payload_ == nullptr) { + lrs_calld->Unref(DEBUG_LOCATION, "LRS+OnResponseReceivedLocked"); + return; + } + // Read the response. + grpc_byte_buffer_reader bbr; + grpc_byte_buffer_reader_init(&bbr, lrs_calld->recv_message_payload_); + grpc_slice response_slice = grpc_byte_buffer_reader_readall(&bbr); + grpc_byte_buffer_reader_destroy(&bbr); + grpc_byte_buffer_destroy(lrs_calld->recv_message_payload_); + lrs_calld->recv_message_payload_ = nullptr; + // This anonymous lambda is a hack to avoid the usage of goto. + [&]() { + // Parse the response. + grpc_millis new_load_reporting_interval; + grpc_error* parse_error = XdsLrsResponseDecodeAndParse( + response_slice, &new_load_reporting_interval, + xdslb_policy->server_name_); + if (parse_error != GRPC_ERROR_NONE) { + gpr_log(GPR_ERROR, "[xdslb %p] LRS response parsing failed. error=%s", + xdslb_policy, grpc_error_string(parse_error)); + GRPC_ERROR_UNREF(parse_error); + return; + } + lrs_calld->seen_response_ = true; + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { + gpr_log(GPR_INFO, + "[xdslb %p] LRS response received, load_report_interval=%" PRId64 + "ms", + xdslb_policy, new_load_reporting_interval); + } + if (new_load_reporting_interval < + GRPC_XDS_MIN_CLIENT_LOAD_REPORTING_INTERVAL_MS) { + new_load_reporting_interval = + GRPC_XDS_MIN_CLIENT_LOAD_REPORTING_INTERVAL_MS; + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { + gpr_log( + GPR_INFO, + "[xdslb %p] Increased load_report_interval to minimum value %dms", + xdslb_policy, GRPC_XDS_MIN_CLIENT_LOAD_REPORTING_INTERVAL_MS); + } + } + // Ignore identical update. + if (lrs_calld->load_reporting_interval_ == new_load_reporting_interval) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { + gpr_log(GPR_INFO, + "[xdslb %p] Incoming LRS response identical to current, " + "ignoring.", + xdslb_policy); + } + return; + } + // Stop current load reporting (if any) to adopt the new reporting interval. + lrs_calld->reporter_.reset(); + // Record the new config. + lrs_calld->load_reporting_interval_ = new_load_reporting_interval; + // Try starting sending load report. + lrs_calld->MaybeStartReportingLocked(); + }(); + grpc_slice_unref_internal(response_slice); + if (xdslb_policy->shutting_down_) { + lrs_calld->Unref(DEBUG_LOCATION, + "LRS+OnResponseReceivedLocked+xds_shutdown"); + return; + } + // Keep listening for LRS config updates. + grpc_op op; + memset(&op, 0, sizeof(op)); + op.op = GRPC_OP_RECV_MESSAGE; + op.data.recv_message.recv_message = &lrs_calld->recv_message_payload_; + op.flags = 0; + op.reserved = nullptr; + GPR_ASSERT(lrs_calld->lb_call_ != nullptr); + // Reuse the "OnResponseReceivedLocked" ref taken in ctor. + const grpc_call_error call_error = grpc_call_start_batch_and_execute( + lrs_calld->lb_call_, &op, 1, &lrs_calld->on_response_received_); + GPR_ASSERT(GRPC_CALL_OK == call_error); +} + +void XdsLb::LbChannelState::LrsCallState::OnStatusReceivedLocked( + void* arg, grpc_error* error) { + LrsCallState* lrs_calld = static_cast(arg); + XdsLb* xdslb_policy = lrs_calld->xdslb_policy(); + LbChannelState* lb_chand = lrs_calld->lb_chand(); + GPR_ASSERT(lrs_calld->lb_call_ != nullptr); + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { + char* status_details = grpc_slice_to_c_string(lrs_calld->status_details_); + gpr_log(GPR_INFO, + "[xdslb %p] LRS call status received. Status = %d, details " + "= '%s', (lb_chand: %p, lb_calld: %p, lb_call: %p), error '%s'", + xdslb_policy, lrs_calld->status_code_, status_details, lb_chand, + lrs_calld, lrs_calld->lb_call_, grpc_error_string(error)); + gpr_free(status_details); + } + // Ignore status from a stale call. + if (lrs_calld->IsCurrentCallOnChannel()) { + // Because this call is the current one on the channel, the channel can't + // have been swapped out; otherwise, the call should have been reset. + GPR_ASSERT(lb_chand->IsCurrentChannel() || lb_chand->IsPendingChannel()); + GPR_ASSERT(!xdslb_policy->shutting_down_); + if (lb_chand == xdslb_policy->LatestLbChannel()) { + // This channel is the most recently created one. Try to restart the call + // and reresolve. + lrs_calld->parent_->OnCallFinishedLocked(); + xdslb_policy->channel_control_helper()->RequestReresolution(); + } + } + lrs_calld->Unref(DEBUG_LOCATION, "LRS+OnStatusReceivedLocked"); +} + +bool XdsLb::LbChannelState::LrsCallState::IsCurrentCallOnChannel() const { + // If the retryable LRS call is null (which only happens when the LB channel + // is shutting down), all the LRS calls are stale. + if (lb_chand()->lrs_calld_ == nullptr) return false; + return this == lb_chand()->lrs_calld_->lb_calld(); } // @@ -1249,8 +1662,7 @@ grpc_channel_args* BuildBalancerChannelArgs(const grpc_channel_args* args) { // ctor and dtor // -XdsLb::XdsLb(Args args) - : LoadBalancingPolicy(std::move(args)), locality_map_(), locality_list_() { +XdsLb::XdsLb(Args args) : LoadBalancingPolicy(std::move(args)) { // Record server name. const grpc_arg* arg = grpc_channel_args_find(args.args, GRPC_ARG_SERVER_URI); const char* server_uri = grpc_channel_arg_get_string(arg); @@ -1351,11 +1763,10 @@ void XdsLb::ProcessAddressesAndChannelArgsLocked( strcmp(last_balancer_name.get(), balancer_name_.get()) != 0; } if (create_lb_channel) { - OrphanablePtr lb_chand = - MakeOrphanable( - balancer_name_.get(), *lb_channel_args, - Ref(DEBUG_LOCATION, "BalancerChannelState")); - if (lb_chand_ == nullptr || !lb_chand_->HasActiveCall()) { + OrphanablePtr lb_chand = MakeOrphanable( + Ref(DEBUG_LOCATION, "XdsLb+LbChannelState"), balancer_name_.get(), + *lb_channel_args); + if (lb_chand_ == nullptr || !lb_chand_->HasActiveEdsCall()) { GPR_ASSERT(pending_lb_chand_ == nullptr); // If we do not have a working LB channel yet, use the newly created one. lb_chand_ = std::move(lb_chand); @@ -1604,15 +2015,15 @@ void XdsLb::LocalityMap::UpdateLocked( const grpc_channel_args* args, XdsLb* parent) { if (parent->shutting_down_) return; for (size_t i = 0; i < locality_list.size(); i++) { - auto iter = map_.find(locality_list[i].locality_name); + auto& locality_name = locality_list[i].locality_name; + auto iter = map_.find(locality_name); // Add a new entry in the locality map if a new locality is received in the // locality list. if (iter == map_.end()) { OrphanablePtr new_entry = MakeOrphanable( - parent->Ref(DEBUG_LOCATION, "LocalityEntry"), - locality_list[i].locality_name, locality_list[i].lb_weight); - iter = map_.emplace(locality_list[i].locality_name, std::move(new_entry)) - .first; + parent->Ref(DEBUG_LOCATION, "LocalityEntry"), locality_name, + locality_list[i].lb_weight); + iter = map_.emplace(locality_name, std::move(new_entry)).first; } // Keep a copy of serverlist in locality_list_ so that we can compare it // with the future ones. @@ -1834,7 +2245,7 @@ void XdsLb::LocalityMap::LocalityEntry::ShutdownLocked() { } // Drop our ref to the child's picker, in case it's holding a ref to // the child. - picker_ref_.reset(); + picker_wrapper_.reset(); } void XdsLb::LocalityMap::LocalityEntry::ResetBackoffLocked() { @@ -1911,12 +2322,10 @@ void XdsLb::LocalityMap::LocalityEntry::Helper::UpdateState( // If we are in fallback mode, ignore update request from the child policy. if (entry_->parent_->fallback_policy_ != nullptr) return; GPR_ASSERT(entry_->parent_->lb_chand_ != nullptr); - RefCountedPtr client_stats = - entry_->parent_->lb_chand_->lb_calld() == nullptr - ? nullptr - : entry_->parent_->lb_chand_->lb_calld()->client_stats(); - // Cache the picker and its state in the entry - entry_->picker_ref_ = MakeRefCounted(std::move(picker)); + // Cache the picker and its state in the entry. + entry_->picker_wrapper_ = MakeRefCounted( + std::move(picker), + entry_->parent_->client_stats_.FindLocalityStats(entry_->name_)); entry_->connectivity_state_ = state; // Construct a new xds picker which maintains a map of all locality pickers // that are ready. Each locality is represented by a portion of the range @@ -1926,15 +2335,30 @@ void XdsLb::LocalityMap::LocalityEntry::Helper::UpdateState( size_t num_connecting = 0; size_t num_idle = 0; size_t num_transient_failures = 0; - auto& locality_map = this->entry_->parent_->locality_map_.map_; Picker::PickerList pickers; - for (auto& p : locality_map) { + for (auto& p : entry_->parent_->locality_map_.map_) { + // TODO(juanlishen): We should prune a locality (and kill its stats) after + // we know we won't pick from it. We need to improve our update logic to + // make that easier. Consider the following situation: the current map has + // two READY localities A and B, and the update only contains B with the + // same addresses as before. Without the following hack, we will generate + // the same picker containing A and B because we haven't pruned A when the + // update happens. Remove the for loop below once we implement the locality + // map update. + bool in_locality_list = false; + for (size_t i = 0; i < entry_->parent_->locality_list_.size(); ++i) { + if (*entry_->parent_->locality_list_[i].locality_name == *p.first) { + in_locality_list = true; + break; + } + } + if (!in_locality_list) continue; const LocalityEntry* entry = p.second.get(); grpc_connectivity_state connectivity_state = entry->connectivity_state_; switch (connectivity_state) { case GRPC_CHANNEL_READY: { end += entry->locality_weight_; - pickers.push_back(MakePair(end, entry->picker_ref_)); + pickers.push_back(MakePair(end, entry->picker_wrapper_)); break; } case GRPC_CHANNEL_CONNECTING: { @@ -1959,29 +2383,30 @@ void XdsLb::LocalityMap::LocalityEntry::Helper::UpdateState( // otherwise pass a QueuePicker if any of the locality pickers are in a // connecting or idle state, finally return a transient failure picker if all // locality pickers are in transient failure - if (pickers.size() > 0) { + if (!pickers.empty()) { entry_->parent_->channel_control_helper()->UpdateState( - GRPC_CHANNEL_READY, - UniquePtr( - New(std::move(client_stats), std::move(pickers)))); + GRPC_CHANNEL_READY, UniquePtr( + New(std::move(pickers)))); } else if (num_connecting > 0) { entry_->parent_->channel_control_helper()->UpdateState( GRPC_CHANNEL_CONNECTING, UniquePtr(New( - this->entry_->parent_->Ref(DEBUG_LOCATION, "QueuePicker")))); + entry_->parent_->Ref(DEBUG_LOCATION, "QueuePicker")))); } else if (num_idle > 0) { entry_->parent_->channel_control_helper()->UpdateState( GRPC_CHANNEL_IDLE, UniquePtr(New( - this->entry_->parent_->Ref(DEBUG_LOCATION, "QueuePicker")))); + entry_->parent_->Ref(DEBUG_LOCATION, "QueuePicker")))); } else { - GPR_ASSERT(num_transient_failures == locality_map.size()); + GPR_ASSERT(num_transient_failures == + entry_->parent_->locality_map_.map_.size()); grpc_error* error = grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING( "connections to all localities failing"), GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE); entry_->parent_->channel_control_helper()->UpdateState( - state, UniquePtr(New(error))); + GRPC_CHANNEL_TRANSIENT_FAILURE, + UniquePtr(New(error))); } } @@ -2003,8 +2428,8 @@ void XdsLb::LocalityMap::LocalityEntry::Helper::RequestReresolution() { // from the balancer, so we can ignore the re-resolution request from // the child policy. Otherwise, pass the re-resolution request up to the // channel. - if (entry_->parent_->lb_chand_->lb_calld() == nullptr || - !entry_->parent_->lb_chand_->lb_calld()->seen_response()) { + if (entry_->parent_->lb_chand_->eds_calld() == nullptr || + !entry_->parent_->lb_chand_->eds_calld()->seen_response()) { entry_->parent_->channel_control_helper()->RequestReresolution(); } } diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc index cdf5408be36..5057e614c68 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc @@ -26,60 +26,163 @@ namespace grpc_core { -void XdsLbClientStats::AddCallStarted() { - gpr_atm_full_fetch_add(&num_calls_started_, (gpr_atm)1); -} - -void XdsLbClientStats::AddCallFinished(bool finished_with_client_failed_to_send, - bool finished_known_received) { - gpr_atm_full_fetch_add(&num_calls_finished_, (gpr_atm)1); - if (finished_with_client_failed_to_send) { - gpr_atm_full_fetch_add(&num_calls_finished_with_client_failed_to_send_, - (gpr_atm)1); - } - if (finished_known_received) { - gpr_atm_full_fetch_add(&num_calls_finished_known_received_, (gpr_atm)1); - } -} - -void XdsLbClientStats::AddCallDroppedLocked(char* token) { - // Increment num_calls_started and num_calls_finished. - gpr_atm_full_fetch_add(&num_calls_started_, (gpr_atm)1); - gpr_atm_full_fetch_add(&num_calls_finished_, (gpr_atm)1); - // Record the drop. - if (drop_token_counts_ == nullptr) { - drop_token_counts_.reset(New()); - } - for (size_t i = 0; i < drop_token_counts_->size(); ++i) { - if (strcmp((*drop_token_counts_)[i].token.get(), token) == 0) { - ++(*drop_token_counts_)[i].count; - return; - } - } - // Not found, so add a new entry. - drop_token_counts_->emplace_back(UniquePtr(gpr_strdup(token)), 1); -} - namespace { -void AtomicGetAndResetCounter(int64_t* value, gpr_atm* counter) { - *value = static_cast(gpr_atm_full_xchg(counter, (gpr_atm)0)); +template +T GetAndResetCounter(Atomic* from) { + return from->Exchange(0, MemoryOrder::RELAXED); } } // namespace -void XdsLbClientStats::GetLocked( - int64_t* num_calls_started, int64_t* num_calls_finished, - int64_t* num_calls_finished_with_client_failed_to_send, - int64_t* num_calls_finished_known_received, - UniquePtr* drop_token_counts) { - AtomicGetAndResetCounter(num_calls_started, &num_calls_started_); - AtomicGetAndResetCounter(num_calls_finished, &num_calls_finished_); - AtomicGetAndResetCounter(num_calls_finished_with_client_failed_to_send, - &num_calls_finished_with_client_failed_to_send_); - AtomicGetAndResetCounter(num_calls_finished_known_received, - &num_calls_finished_known_received_); - *drop_token_counts = std::move(drop_token_counts_); +// +// XdsClientStats::LocalityStats::LoadMetric::Snapshot +// + +bool XdsClientStats::LocalityStats::LoadMetric::Snapshot::IsAllZero() const { + return total_metric_value == 0 && num_requests_finished_with_metric == 0; +} + +// +// XdsClientStats::LocalityStats::LoadMetric +// + +XdsClientStats::LocalityStats::LoadMetric::Snapshot +XdsClientStats::LocalityStats::LoadMetric::GetSnapshotAndReset() { + Snapshot metric = {num_requests_finished_with_metric_, total_metric_value_}; + num_requests_finished_with_metric_ = 0; + total_metric_value_ = 0; + return metric; +} + +// +// XdsClientStats::LocalityStats::Snapshot +// + +bool XdsClientStats::LocalityStats::Snapshot::IsAllZero() { + if (total_successful_requests != 0 || total_requests_in_progress != 0 || + total_error_requests != 0 || total_issued_requests != 0) { + return false; + } + for (auto& p : load_metric_stats) { + const LoadMetric::Snapshot& metric_value = p.second; + if (!metric_value.IsAllZero()) return false; + } + return true; +} + +// +// XdsClientStats::LocalityStats +// + +XdsClientStats::LocalityStats::Snapshot +XdsClientStats::LocalityStats::GetSnapshotAndReset() { + Snapshot snapshot = { + GetAndResetCounter(&total_successful_requests_), + // Don't reset total_requests_in_progress because it's not + // related to a single reporting interval. + total_requests_in_progress_.Load(MemoryOrder::RELAXED), + GetAndResetCounter(&total_error_requests_), + GetAndResetCounter(&total_issued_requests_)}; + { + MutexLock lock(&load_metric_stats_mu_); + for (auto& p : load_metric_stats_) { + const char* metric_name = p.first.get(); + LoadMetric& metric_value = p.second; + snapshot.load_metric_stats.emplace( + UniquePtr(gpr_strdup(metric_name)), + metric_value.GetSnapshotAndReset()); + } + } + return snapshot; +} + +void XdsClientStats::LocalityStats::AddCallStarted() { + total_issued_requests_.FetchAdd(1, MemoryOrder::RELAXED); + total_requests_in_progress_.FetchAdd(1, MemoryOrder::RELAXED); +} + +void XdsClientStats::LocalityStats::AddCallFinished(bool fail) { + Atomic& to_increment = + fail ? total_error_requests_ : total_successful_requests_; + to_increment.FetchAdd(1, MemoryOrder::RELAXED); + total_requests_in_progress_.FetchAdd(-1, MemoryOrder::ACQ_REL); +} + +// +// XdsClientStats::Snapshot +// + +bool XdsClientStats::Snapshot::IsAllZero() { + for (auto& p : upstream_locality_stats) { + if (!p.second.IsAllZero()) return false; + } + for (auto& p : dropped_requests) { + if (p.second != 0) return false; + } + return total_dropped_requests == 0; +} + +// +// XdsClientStats +// + +XdsClientStats::Snapshot XdsClientStats::GetSnapshotAndReset() { + grpc_millis now = ExecCtx::Get()->Now(); + // Record total_dropped_requests and reporting interval in the snapshot. + Snapshot snapshot; + snapshot.total_dropped_requests = + GetAndResetCounter(&total_dropped_requests_); + snapshot.load_report_interval = now - last_report_time_; + // Update last report time. + last_report_time_ = now; + // Snapshot all the other stats. + for (auto& p : upstream_locality_stats_) { + snapshot.upstream_locality_stats.emplace(p.first, + p.second->GetSnapshotAndReset()); + } + { + MutexLock lock(&dropped_requests_mu_); + snapshot.dropped_requests = std::move(dropped_requests_); + } + return snapshot; +} + +void XdsClientStats::MaybeInitLastReportTime() { + if (last_report_time_ == -1) last_report_time_ = ExecCtx::Get()->Now(); +} + +RefCountedPtr XdsClientStats::FindLocalityStats( + const RefCountedPtr& locality_name) { + auto iter = upstream_locality_stats_.find(locality_name); + if (iter == upstream_locality_stats_.end()) { + iter = upstream_locality_stats_ + .emplace(locality_name, MakeRefCounted()) + .first; + } + return iter->second; +} + +void XdsClientStats::PruneLocalityStats() { + auto iter = upstream_locality_stats_.begin(); + while (iter != upstream_locality_stats_.end()) { + if (iter->second->IsSafeToDelete()) { + iter = upstream_locality_stats_.erase(iter); + } else { + ++iter; + } + } +} + +void XdsClientStats::AddCallDropped(UniquePtr category) { + total_dropped_requests_.FetchAdd(1, MemoryOrder::RELAXED); + MutexLock lock(&dropped_requests_mu_); + auto iter = dropped_requests_.find(category); + if (iter == dropped_requests_.end()) { + dropped_requests_.emplace(UniquePtr(gpr_strdup(category.get())), 1); + } else { + ++iter->second; + } } } // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h b/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h index fa0b9f4b635..445675a4dcf 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h @@ -21,49 +21,207 @@ #include -#include +#include +#include "src/core/lib/gprpp/atomic.h" #include "src/core/lib/gprpp/inlined_vector.h" +#include "src/core/lib/gprpp/map.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/ref_counted.h" +#include "src/core/lib/gprpp/sync.h" +#include "src/core/lib/iomgr/exec_ctx.h" namespace grpc_core { -class XdsLbClientStats : public RefCounted { +class XdsLocalityName : public RefCounted { public: - struct DropTokenCount { - UniquePtr token; - int64_t count; - - DropTokenCount(UniquePtr token, int64_t count) - : token(std::move(token)), count(count) {} + struct Less { + bool operator()(const RefCountedPtr& lhs, + const RefCountedPtr& rhs) { + int cmp_result = strcmp(lhs->region_.get(), rhs->region_.get()); + if (cmp_result != 0) return cmp_result < 0; + cmp_result = strcmp(lhs->zone_.get(), rhs->zone_.get()); + if (cmp_result != 0) return cmp_result < 0; + return strcmp(lhs->sub_zone_.get(), rhs->sub_zone_.get()) < 0; + } }; - typedef InlinedVector DroppedCallCounts; + XdsLocalityName(UniquePtr region, UniquePtr zone, + UniquePtr subzone) + : region_(std::move(region)), + zone_(std::move(zone)), + sub_zone_(std::move(subzone)) {} - XdsLbClientStats() {} + bool operator==(const XdsLocalityName& other) const { + return strcmp(region_.get(), other.region_.get()) == 0 && + strcmp(zone_.get(), other.zone_.get()) == 0 && + strcmp(sub_zone_.get(), other.sub_zone_.get()) == 0; + } - void AddCallStarted(); - void AddCallFinished(bool finished_with_client_failed_to_send, - bool finished_known_received); + const char* region() const { return region_.get(); } + const char* zone() const { return zone_.get(); } + const char* sub_zone() const { return sub_zone_.get(); } - // This method is not thread-safe; caller must synchronize. - void AddCallDroppedLocked(char* token); - - // This method is not thread-safe; caller must synchronize. - void GetLocked(int64_t* num_calls_started, int64_t* num_calls_finished, - int64_t* num_calls_finished_with_client_failed_to_send, - int64_t* num_calls_finished_known_received, - UniquePtr* drop_token_counts); + const char* AsHumanReadableString() { + if (human_readable_string_ == nullptr) { + char* tmp; + gpr_asprintf(&tmp, "{region=\"%s\", zone=\"%s\", sub_zone=\"%s\"}", + region_.get(), zone_.get(), sub_zone_.get()); + human_readable_string_.reset(tmp); + } + return human_readable_string_.get(); + } private: - // This field must only be accessed via *_locked() methods. - UniquePtr drop_token_counts_; - // These fields may be accessed from multiple threads at a time. - gpr_atm num_calls_started_ = 0; - gpr_atm num_calls_finished_ = 0; - gpr_atm num_calls_finished_with_client_failed_to_send_ = 0; - gpr_atm num_calls_finished_known_received_ = 0; + UniquePtr region_; + UniquePtr zone_; + UniquePtr sub_zone_; + UniquePtr human_readable_string_; +}; + +// The stats classes (i.e., XdsClientStats, LocalityStats, and LoadMetric) can +// be taken a snapshot (and reset) to populate the load report. The snapshots +// are contained in the respective Snapshot structs. The Snapshot structs have +// no synchronization. The stats classes use several different synchronization +// methods. 1. Most of the counters are Atomic<>s for performance. 2. Some of +// the Map<>s are protected by Mutex if we are not guaranteed that the accesses +// to them are synchronized by the callers. 3. The Map<>s to which the accesses +// are already synchronized by the callers do not have additional +// synchronization here. Note that the Map<>s we mentioned in 2 and 3 refer to +// the map's tree structure rather than the content in each tree node. +class XdsClientStats { + public: + class LocalityStats : public RefCounted { + public: + class LoadMetric { + public: + struct Snapshot { + bool IsAllZero() const; + + uint64_t num_requests_finished_with_metric; + double total_metric_value; + }; + + // Returns a snapshot of this instance and reset all the accumulative + // counters. + Snapshot GetSnapshotAndReset(); + + private: + uint64_t num_requests_finished_with_metric_{0}; + double total_metric_value_{0}; + }; + + using LoadMetricMap = Map, LoadMetric, StringLess>; + using LoadMetricSnapshotMap = + Map, LoadMetric::Snapshot, StringLess>; + + struct Snapshot { + // TODO(juanlishen): Change this to const method when const_iterator is + // added to Map<>. + bool IsAllZero(); + + uint64_t total_successful_requests; + uint64_t total_requests_in_progress; + uint64_t total_error_requests; + uint64_t total_issued_requests; + LoadMetricSnapshotMap load_metric_stats; + }; + + // Returns a snapshot of this instance and reset all the accumulative + // counters. + Snapshot GetSnapshotAndReset(); + + // Each XdsLb::PickerWrapper holds a ref to the perspective LocalityStats. + // If the refcount is 0, there won't be new calls recorded to the + // LocalityStats, so the LocalityStats can be safely deleted when all the + // in-progress calls have finished. + // Only be called from the control plane combiner. + void RefByPicker() { picker_refcount_.FetchAdd(1, MemoryOrder::ACQ_REL); } + // Might be called from the control plane combiner or the data plane + // combiner. + // TODO(juanlishen): Once https://github.com/grpc/grpc/pull/19390 is merged, + // this method will also only be invoked in the control plane combiner. + // We may then be able to simplify the LocalityStats' lifetime by making it + // RefCounted<> and populating the protobuf in its dtor. + void UnrefByPicker() { picker_refcount_.FetchSub(1, MemoryOrder::ACQ_REL); } + // Only be called from the control plane combiner. + // The only place where the picker_refcount_ can be increased is + // RefByPicker(), which also can only be called from the control plane + // combiner. Also, if the picker_refcount_ is 0, total_requests_in_progress_ + // can't be increased from 0. So it's safe to delete the LocalityStats right + // after this method returns true. + bool IsSafeToDelete() { + return picker_refcount_.FetchAdd(0, MemoryOrder::ACQ_REL) == 0 && + total_requests_in_progress_.FetchAdd(0, MemoryOrder::ACQ_REL) == 0; + } + + void AddCallStarted(); + void AddCallFinished(bool fail = false); + + private: + Atomic total_successful_requests_{0}; + Atomic total_requests_in_progress_{0}; + // Requests that were issued (not dropped) but failed. + Atomic total_error_requests_{0}; + Atomic total_issued_requests_{0}; + // Protects load_metric_stats_. A mutex is necessary because the length of + // load_metric_stats_ can be accessed by both the callback intercepting the + // call's recv_trailing_metadata (not from any combiner) and the load + // reporting thread (from the control plane combiner). + Mutex load_metric_stats_mu_; + LoadMetricMap load_metric_stats_; + // Can be accessed from either the control plane combiner or the data plane + // combiner. + Atomic picker_refcount_{0}; + }; + + // TODO(juanlishen): The value type of Map<> must be movable in current + // implementation. To avoid making LocalityStats movable, we wrap it by + // UniquePtr<>. We should remove this wrapper if the value type of Map<> + // doesn't have to be movable. + using LocalityStatsMap = + Map, RefCountedPtr, + XdsLocalityName::Less>; + using LocalityStatsSnapshotMap = + Map, LocalityStats::Snapshot, + XdsLocalityName::Less>; + using DroppedRequestsMap = Map, uint64_t, StringLess>; + using DroppedRequestsSnapshotMap = DroppedRequestsMap; + + struct Snapshot { + // TODO(juanlishen): Change this to const method when const_iterator is + // added to Map<>. + bool IsAllZero(); + + LocalityStatsSnapshotMap upstream_locality_stats; + uint64_t total_dropped_requests; + DroppedRequestsSnapshotMap dropped_requests; + // The actual load report interval. + grpc_millis load_report_interval; + }; + + // Returns a snapshot of this instance and reset all the accumulative + // counters. + Snapshot GetSnapshotAndReset(); + + void MaybeInitLastReportTime(); + RefCountedPtr FindLocalityStats( + const RefCountedPtr& locality_name); + void PruneLocalityStats(); + void AddCallDropped(UniquePtr category); + + private: + // The stats for each locality. + LocalityStatsMap upstream_locality_stats_; + Atomic total_dropped_requests_{0}; + // Protects dropped_requests_. A mutex is necessary because the length of + // dropped_requests_ can be accessed by both the picker (from data plane + // combiner) and the load reporting thread (from the control plane combiner). + Mutex dropped_requests_mu_; + DroppedRequestsMap dropped_requests_; + // The timestamp of last reporting. For the LB-policy-wide first report, the + // last_report_time is the time we scheduled the first reporting timer. + grpc_millis last_report_time_ = -1; }; } // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc index 8ae6a5e7590..b2615f319b9 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc @@ -33,7 +33,10 @@ #include "envoy/api/v2/discovery.upb.h" #include "envoy/api/v2/eds.upb.h" #include "envoy/api/v2/endpoint/endpoint.upb.h" +#include "envoy/api/v2/endpoint/load_report.upb.h" +#include "envoy/service/load_stats/v2/lrs.upb.h" #include "google/protobuf/any.upb.h" +#include "google/protobuf/duration.upb.h" #include "google/protobuf/struct.upb.h" #include "google/protobuf/timestamp.upb.h" #include "google/protobuf/wrappers.upb.h" @@ -209,54 +212,163 @@ grpc_error* XdsEdsResponseDecodeAndParse(const grpc_slice& encoded_response, namespace { -void google_protobuf_Timestamp_assign(google_protobuf_Timestamp* timestamp, - const gpr_timespec& value) { - google_protobuf_Timestamp_set_seconds(timestamp, value.tv_sec); - google_protobuf_Timestamp_set_nanos(timestamp, value.tv_nsec); +grpc_slice LrsRequestEncode( + const envoy_service_load_stats_v2_LoadStatsRequest* request, + upb_arena* arena) { + size_t output_length; + char* output = envoy_service_load_stats_v2_LoadStatsRequest_serialize( + request, arena, &output_length); + return grpc_slice_from_copied_buffer(output, output_length); } } // namespace -xds_grpclb_request* xds_grpclb_load_report_request_create_locked( - grpc_core::XdsLbClientStats* client_stats, upb_arena* arena) { - xds_grpclb_request* req = grpc_lb_v1_LoadBalanceRequest_new(arena); - grpc_lb_v1_ClientStats* req_stats = - grpc_lb_v1_LoadBalanceRequest_mutable_client_stats(req, arena); - google_protobuf_Timestamp_assign( - grpc_lb_v1_ClientStats_mutable_timestamp(req_stats, arena), - gpr_now(GPR_CLOCK_REALTIME)); +grpc_slice XdsLrsRequestCreateAndEncode(const char* server_name) { + upb::Arena arena; + // Create a request. + envoy_service_load_stats_v2_LoadStatsRequest* request = + envoy_service_load_stats_v2_LoadStatsRequest_new(arena.ptr()); + // Add cluster stats. There is only one because we only use one server name in + // one channel. + envoy_api_v2_endpoint_ClusterStats* cluster_stats = + envoy_service_load_stats_v2_LoadStatsRequest_add_cluster_stats( + request, arena.ptr()); + // Set the cluster name. + envoy_api_v2_endpoint_ClusterStats_set_cluster_name( + cluster_stats, upb_strview_makez(server_name)); + return LrsRequestEncode(request, arena.ptr()); +} - int64_t num_calls_started; - int64_t num_calls_finished; - int64_t num_calls_finished_with_client_failed_to_send; - int64_t num_calls_finished_known_received; - UniquePtr drop_token_counts; - client_stats->GetLocked(&num_calls_started, &num_calls_finished, - &num_calls_finished_with_client_failed_to_send, - &num_calls_finished_known_received, - &drop_token_counts); - grpc_lb_v1_ClientStats_set_num_calls_started(req_stats, num_calls_started); - grpc_lb_v1_ClientStats_set_num_calls_finished(req_stats, num_calls_finished); - grpc_lb_v1_ClientStats_set_num_calls_finished_with_client_failed_to_send( - req_stats, num_calls_finished_with_client_failed_to_send); - grpc_lb_v1_ClientStats_set_num_calls_finished_known_received( - req_stats, num_calls_finished_known_received); - if (drop_token_counts != nullptr) { - for (size_t i = 0; i < drop_token_counts->size(); ++i) { - XdsLbClientStats::DropTokenCount& cur = (*drop_token_counts)[i]; - grpc_lb_v1_ClientStatsPerToken* cur_msg = - grpc_lb_v1_ClientStats_add_calls_finished_with_drop(req_stats, arena); +namespace { - const size_t token_len = strlen(cur.token.get()); - char* token = reinterpret_cast(upb_arena_malloc(arena, token_len)); - memcpy(token, cur.token.get(), token_len); - - grpc_lb_v1_ClientStatsPerToken_set_load_balance_token( - cur_msg, upb_strview_make(token, token_len)); - grpc_lb_v1_ClientStatsPerToken_set_num_calls(cur_msg, cur.count); - } +void LocalityStatsPopulate(envoy_api_v2_endpoint_UpstreamLocalityStats* output, + Pair, + XdsClientStats::LocalityStats::Snapshot>& input, + upb_arena* arena) { + // Set sub_zone. + envoy_api_v2_core_Locality* locality = + envoy_api_v2_endpoint_UpstreamLocalityStats_mutable_locality(output, + arena); + envoy_api_v2_core_Locality_set_sub_zone( + locality, upb_strview_makez(input.first->sub_zone())); + // Set total counts. + XdsClientStats::LocalityStats::Snapshot& snapshot = input.second; + envoy_api_v2_endpoint_UpstreamLocalityStats_set_total_successful_requests( + output, snapshot.total_successful_requests); + envoy_api_v2_endpoint_UpstreamLocalityStats_set_total_requests_in_progress( + output, snapshot.total_requests_in_progress); + envoy_api_v2_endpoint_UpstreamLocalityStats_set_total_error_requests( + output, snapshot.total_error_requests); + envoy_api_v2_endpoint_UpstreamLocalityStats_set_total_issued_requests( + output, snapshot.total_issued_requests); + // Add load metric stats. + for (auto& p : snapshot.load_metric_stats) { + const char* metric_name = p.first.get(); + const XdsClientStats::LocalityStats::LoadMetric::Snapshot& metric_value = + p.second; + envoy_api_v2_endpoint_EndpointLoadMetricStats* load_metric = + envoy_api_v2_endpoint_UpstreamLocalityStats_add_load_metric_stats( + output, arena); + envoy_api_v2_endpoint_EndpointLoadMetricStats_set_metric_name( + load_metric, upb_strview_makez(metric_name)); + envoy_api_v2_endpoint_EndpointLoadMetricStats_set_num_requests_finished_with_metric( + load_metric, metric_value.num_requests_finished_with_metric); + envoy_api_v2_endpoint_EndpointLoadMetricStats_set_total_metric_value( + load_metric, metric_value.total_metric_value); } - return req; +} + +} // namespace + +grpc_slice XdsLrsRequestCreateAndEncode(const char* server_name, + XdsClientStats* client_stats) { + upb::Arena arena; + XdsClientStats::Snapshot snapshot = client_stats->GetSnapshotAndReset(); + // Prune unused locality stats. + client_stats->PruneLocalityStats(); + // When all the counts are zero, return empty slice. + if (snapshot.IsAllZero()) return grpc_empty_slice(); + // Create a request. + envoy_service_load_stats_v2_LoadStatsRequest* request = + envoy_service_load_stats_v2_LoadStatsRequest_new(arena.ptr()); + // Add cluster stats. There is only one because we only use one server name in + // one channel. + envoy_api_v2_endpoint_ClusterStats* cluster_stats = + envoy_service_load_stats_v2_LoadStatsRequest_add_cluster_stats( + request, arena.ptr()); + // Set the cluster name. + envoy_api_v2_endpoint_ClusterStats_set_cluster_name( + cluster_stats, upb_strview_makez(server_name)); + // Add locality stats. + for (auto& p : snapshot.upstream_locality_stats) { + envoy_api_v2_endpoint_UpstreamLocalityStats* locality_stats = + envoy_api_v2_endpoint_ClusterStats_add_upstream_locality_stats( + cluster_stats, arena.ptr()); + LocalityStatsPopulate(locality_stats, p, arena.ptr()); + } + // Add dropped requests. + for (auto& p : snapshot.dropped_requests) { + const char* category = p.first.get(); + const uint64_t count = p.second; + envoy_api_v2_endpoint_ClusterStats_DroppedRequests* dropped_requests = + envoy_api_v2_endpoint_ClusterStats_add_dropped_requests(cluster_stats, + arena.ptr()); + envoy_api_v2_endpoint_ClusterStats_DroppedRequests_set_category( + dropped_requests, upb_strview_makez(category)); + envoy_api_v2_endpoint_ClusterStats_DroppedRequests_set_dropped_count( + dropped_requests, count); + } + // Set total dropped requests. + envoy_api_v2_endpoint_ClusterStats_set_total_dropped_requests( + cluster_stats, snapshot.total_dropped_requests); + // Set real load report interval. + gpr_timespec timespec = + grpc_millis_to_timespec(snapshot.load_report_interval, GPR_TIMESPAN); + google_protobuf_Duration* load_report_interval = + envoy_api_v2_endpoint_ClusterStats_mutable_load_report_interval( + cluster_stats, arena.ptr()); + google_protobuf_Duration_set_seconds(load_report_interval, timespec.tv_sec); + google_protobuf_Duration_set_nanos(load_report_interval, timespec.tv_nsec); + return LrsRequestEncode(request, arena.ptr()); +} + +grpc_error* XdsLrsResponseDecodeAndParse(const grpc_slice& encoded_response, + grpc_millis* load_reporting_interval, + const char* expected_server_name) { + upb::Arena arena; + // Decode the response. + const envoy_service_load_stats_v2_LoadStatsResponse* decoded_response = + envoy_service_load_stats_v2_LoadStatsResponse_parse( + reinterpret_cast(GRPC_SLICE_START_PTR(encoded_response)), + GRPC_SLICE_LENGTH(encoded_response), arena.ptr()); + // Parse the response. + if (decoded_response == nullptr) { + return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No response found."); + } + // Check the cluster size in the response. + size_t size; + const upb_strview* clusters = + envoy_service_load_stats_v2_LoadStatsResponse_clusters(decoded_response, + &size); + if (size != 1) { + return GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "The number of clusters (server names) is not 1."); + } + // Check the cluster name in the response + if (strncmp(expected_server_name, clusters[0].data, clusters[0].size) != 0) { + return GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "Unexpected cluster (server name)."); + } + // Get the load report interval. + const google_protobuf_Duration* load_reporting_interval_duration = + envoy_service_load_stats_v2_LoadStatsResponse_load_reporting_interval( + decoded_response); + gpr_timespec timespec{ + google_protobuf_Duration_seconds(load_reporting_interval_duration), + google_protobuf_Duration_nanos(load_reporting_interval_duration), + GPR_TIMESPAN}; + *load_reporting_interval = gpr_time_to_millis(timespec); + return GRPC_ERROR_NONE; } } // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h index 8e31584e257..ed3b49ff836 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h @@ -25,58 +25,9 @@ #include "src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h" #include "src/core/ext/filters/client_channel/server_address.h" -#include "src/proto/grpc/lb/v1/load_balancer.upb.h" namespace grpc_core { -typedef grpc_lb_v1_LoadBalanceRequest xds_grpclb_request; - -class XdsLocalityName : public RefCounted { - public: - struct Less { - bool operator()(const RefCountedPtr& lhs, - const RefCountedPtr& rhs) { - int cmp_result = strcmp(lhs->region_.get(), rhs->region_.get()); - if (cmp_result != 0) return cmp_result < 0; - cmp_result = strcmp(lhs->zone_.get(), rhs->zone_.get()); - if (cmp_result != 0) return cmp_result < 0; - return strcmp(lhs->sub_zone_.get(), rhs->sub_zone_.get()) < 0; - } - }; - - XdsLocalityName(UniquePtr region, UniquePtr zone, - UniquePtr sub_zone) - : region_(std::move(region)), - zone_(std::move(zone)), - sub_zone_(std::move(sub_zone)) {} - - bool operator==(const XdsLocalityName& other) const { - return strcmp(region_.get(), other.region_.get()) == 0 && - strcmp(zone_.get(), other.zone_.get()) == 0 && - strcmp(sub_zone_.get(), other.sub_zone_.get()) == 0; - } - - const char* region() const { return region_.get(); } - const char* zone() const { return zone_.get(); } - const char* sub_zone() const { return sub_zone_.get(); } - - const char* AsHumanReadableString() { - if (human_readable_string_ == nullptr) { - char* tmp; - gpr_asprintf(&tmp, "{region=\"%s\", zone=\"%s\", sub_zone=\"%s\"}", - region_.get(), zone_.get(), sub_zone_.get()); - human_readable_string_.reset(tmp); - } - return human_readable_string_.get(); - } - - private: - UniquePtr region_; - UniquePtr zone_; - UniquePtr sub_zone_; - UniquePtr human_readable_string_; -}; - struct XdsLocalityInfo { bool operator==(const XdsLocalityInfo& other) const { return *locality_name == *other.locality_name && @@ -112,9 +63,20 @@ grpc_slice XdsEdsRequestCreateAndEncode(const char* service_name); grpc_error* XdsEdsResponseDecodeAndParse(const grpc_slice& encoded_response, XdsUpdate* update); -// TODO(juanlishen): Delete these when LRS is added. -xds_grpclb_request* xds_grpclb_load_report_request_create_locked( - grpc_core::XdsLbClientStats* client_stats, upb_arena* arena); +// Creates an LRS request querying \a server_name. +grpc_slice XdsLrsRequestCreateAndEncode(const char* server_name); + +// Creates an LRS request sending client-side load reports. If all the counters +// in \a client_stats are zero, returns empty slice. +grpc_slice XdsLrsRequestCreateAndEncode(const char* server_name, + XdsClientStats* client_stats); + +// Parses the LRS response and returns the client-side load reporting interval. +// If there is any error (e.g., the found server name doesn't match \a +// expected_server_name), the output config is invalid. +grpc_error* XdsLrsResponseDecodeAndParse(const grpc_slice& encoded_response, + grpc_millis* load_reporting_interval, + const char* expected_server_name); } // namespace grpc_core diff --git a/src/core/lib/gprpp/atomic.h b/src/core/lib/gprpp/atomic.h index 80412ef9583..095ebf12565 100644 --- a/src/core/lib/gprpp/atomic.h +++ b/src/core/lib/gprpp/atomic.h @@ -49,6 +49,10 @@ class Atomic { storage_.store(val, static_cast(order)); } + T Exchange(T desired, MemoryOrder order) { + return storage_.exchange(desired, static_cast(order)); + } + bool CompareExchangeWeak(T* expected, T desired, MemoryOrder success, MemoryOrder failure) { return GPR_ATM_INC_CAS_THEN(storage_.compare_exchange_weak( diff --git a/src/core/lib/gprpp/map.h b/src/core/lib/gprpp/map.h index 5238f43469f..d133a89fb43 100644 --- a/src/core/lib/gprpp/map.h +++ b/src/core/lib/gprpp/map.h @@ -89,7 +89,7 @@ class Map { // Removes the current entry and points to the next one iterator erase(iterator iter); - size_t size() { return size_; } + size_t size() const { return size_; } template Pair emplace(Args&&... args); diff --git a/src/core/lib/transport/static_metadata.cc b/src/core/lib/transport/static_metadata.cc index d72ea3f63ae..e2e618726f1 100644 --- a/src/core/lib/transport/static_metadata.cc +++ b/src/core/lib/transport/static_metadata.cc @@ -63,61 +63,66 @@ static uint8_t g_bytes[] = { 116, 101, 115, 47, 103, 114, 112, 99, 46, 108, 98, 46, 118, 49, 46, 76, 111, 97, 100, 66, 97, 108, 97, 110, 99, 101, 114, 47, 66, 97, 108, 97, 110, 99, 101, 76, 111, 97, 100, 47, 101, 110, 118, 111, 121, - 46, 97, 112, 105, 46, 118, 50, 46, 69, 110, 100, 112, 111, 105, 110, - 116, 68, 105, 115, 99, 111, 118, 101, 114, 121, 83, 101, 114, 118, 105, - 99, 101, 47, 83, 116, 114, 101, 97, 109, 69, 110, 100, 112, 111, 105, - 110, 116, 115, 47, 103, 114, 112, 99, 46, 104, 101, 97, 108, 116, 104, - 46, 118, 49, 46, 72, 101, 97, 108, 116, 104, 47, 87, 97, 116, 99, - 104, 47, 101, 110, 118, 111, 121, 46, 115, 101, 114, 118, 105, 99, 101, - 46, 100, 105, 115, 99, 111, 118, 101, 114, 121, 46, 118, 50, 46, 65, - 103, 103, 114, 101, 103, 97, 116, 101, 100, 68, 105, 115, 99, 111, 118, - 101, 114, 121, 83, 101, 114, 118, 105, 99, 101, 47, 83, 116, 114, 101, - 97, 109, 65, 103, 103, 114, 101, 103, 97, 116, 101, 100, 82, 101, 115, - 111, 117, 114, 99, 101, 115, 100, 101, 102, 108, 97, 116, 101, 103, 122, - 105, 112, 115, 116, 114, 101, 97, 109, 47, 103, 122, 105, 112, 71, 69, - 84, 80, 79, 83, 84, 47, 47, 105, 110, 100, 101, 120, 46, 104, 116, - 109, 108, 104, 116, 116, 112, 104, 116, 116, 112, 115, 50, 48, 48, 50, - 48, 52, 50, 48, 54, 51, 48, 52, 52, 48, 48, 52, 48, 52, 53, - 48, 48, 97, 99, 99, 101, 112, 116, 45, 99, 104, 97, 114, 115, 101, - 116, 103, 122, 105, 112, 44, 32, 100, 101, 102, 108, 97, 116, 101, 97, - 99, 99, 101, 112, 116, 45, 108, 97, 110, 103, 117, 97, 103, 101, 97, - 99, 99, 101, 112, 116, 45, 114, 97, 110, 103, 101, 115, 97, 99, 99, - 101, 112, 116, 97, 99, 99, 101, 115, 115, 45, 99, 111, 110, 116, 114, - 111, 108, 45, 97, 108, 108, 111, 119, 45, 111, 114, 105, 103, 105, 110, - 97, 103, 101, 97, 108, 108, 111, 119, 97, 117, 116, 104, 111, 114, 105, - 122, 97, 116, 105, 111, 110, 99, 97, 99, 104, 101, 45, 99, 111, 110, - 116, 114, 111, 108, 99, 111, 110, 116, 101, 110, 116, 45, 100, 105, 115, - 112, 111, 115, 105, 116, 105, 111, 110, 99, 111, 110, 116, 101, 110, 116, - 45, 108, 97, 110, 103, 117, 97, 103, 101, 99, 111, 110, 116, 101, 110, - 116, 45, 108, 101, 110, 103, 116, 104, 99, 111, 110, 116, 101, 110, 116, - 45, 108, 111, 99, 97, 116, 105, 111, 110, 99, 111, 110, 116, 101, 110, - 116, 45, 114, 97, 110, 103, 101, 99, 111, 111, 107, 105, 101, 100, 97, - 116, 101, 101, 116, 97, 103, 101, 120, 112, 101, 99, 116, 101, 120, 112, - 105, 114, 101, 115, 102, 114, 111, 109, 105, 102, 45, 109, 97, 116, 99, - 104, 105, 102, 45, 109, 111, 100, 105, 102, 105, 101, 100, 45, 115, 105, - 110, 99, 101, 105, 102, 45, 110, 111, 110, 101, 45, 109, 97, 116, 99, - 104, 105, 102, 45, 114, 97, 110, 103, 101, 105, 102, 45, 117, 110, 109, - 111, 100, 105, 102, 105, 101, 100, 45, 115, 105, 110, 99, 101, 108, 97, - 115, 116, 45, 109, 111, 100, 105, 102, 105, 101, 100, 108, 105, 110, 107, - 108, 111, 99, 97, 116, 105, 111, 110, 109, 97, 120, 45, 102, 111, 114, - 119, 97, 114, 100, 115, 112, 114, 111, 120, 121, 45, 97, 117, 116, 104, - 101, 110, 116, 105, 99, 97, 116, 101, 112, 114, 111, 120, 121, 45, 97, - 117, 116, 104, 111, 114, 105, 122, 97, 116, 105, 111, 110, 114, 97, 110, - 103, 101, 114, 101, 102, 101, 114, 101, 114, 114, 101, 102, 114, 101, 115, - 104, 114, 101, 116, 114, 121, 45, 97, 102, 116, 101, 114, 115, 101, 114, - 118, 101, 114, 115, 101, 116, 45, 99, 111, 111, 107, 105, 101, 115, 116, - 114, 105, 99, 116, 45, 116, 114, 97, 110, 115, 112, 111, 114, 116, 45, - 115, 101, 99, 117, 114, 105, 116, 121, 116, 114, 97, 110, 115, 102, 101, - 114, 45, 101, 110, 99, 111, 100, 105, 110, 103, 118, 97, 114, 121, 118, - 105, 97, 119, 119, 119, 45, 97, 117, 116, 104, 101, 110, 116, 105, 99, - 97, 116, 101, 48, 105, 100, 101, 110, 116, 105, 116, 121, 116, 114, 97, - 105, 108, 101, 114, 115, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, - 110, 47, 103, 114, 112, 99, 103, 114, 112, 99, 80, 85, 84, 108, 98, - 45, 99, 111, 115, 116, 45, 98, 105, 110, 105, 100, 101, 110, 116, 105, - 116, 121, 44, 100, 101, 102, 108, 97, 116, 101, 105, 100, 101, 110, 116, - 105, 116, 121, 44, 103, 122, 105, 112, 100, 101, 102, 108, 97, 116, 101, - 44, 103, 122, 105, 112, 105, 100, 101, 110, 116, 105, 116, 121, 44, 100, - 101, 102, 108, 97, 116, 101, 44, 103, 122, 105, 112}; + 46, 115, 101, 114, 118, 105, 99, 101, 46, 108, 111, 97, 100, 95, 115, + 116, 97, 116, 115, 46, 118, 50, 46, 76, 111, 97, 100, 82, 101, 112, + 111, 114, 116, 105, 110, 103, 83, 101, 114, 118, 105, 99, 101, 47, 83, + 116, 114, 101, 97, 109, 76, 111, 97, 100, 83, 116, 97, 116, 115, 47, + 101, 110, 118, 111, 121, 46, 97, 112, 105, 46, 118, 50, 46, 69, 110, + 100, 112, 111, 105, 110, 116, 68, 105, 115, 99, 111, 118, 101, 114, 121, + 83, 101, 114, 118, 105, 99, 101, 47, 83, 116, 114, 101, 97, 109, 69, + 110, 100, 112, 111, 105, 110, 116, 115, 47, 103, 114, 112, 99, 46, 104, + 101, 97, 108, 116, 104, 46, 118, 49, 46, 72, 101, 97, 108, 116, 104, + 47, 87, 97, 116, 99, 104, 47, 101, 110, 118, 111, 121, 46, 115, 101, + 114, 118, 105, 99, 101, 46, 100, 105, 115, 99, 111, 118, 101, 114, 121, + 46, 118, 50, 46, 65, 103, 103, 114, 101, 103, 97, 116, 101, 100, 68, + 105, 115, 99, 111, 118, 101, 114, 121, 83, 101, 114, 118, 105, 99, 101, + 47, 83, 116, 114, 101, 97, 109, 65, 103, 103, 114, 101, 103, 97, 116, + 101, 100, 82, 101, 115, 111, 117, 114, 99, 101, 115, 100, 101, 102, 108, + 97, 116, 101, 103, 122, 105, 112, 115, 116, 114, 101, 97, 109, 47, 103, + 122, 105, 112, 71, 69, 84, 80, 79, 83, 84, 47, 47, 105, 110, 100, + 101, 120, 46, 104, 116, 109, 108, 104, 116, 116, 112, 104, 116, 116, 112, + 115, 50, 48, 48, 50, 48, 52, 50, 48, 54, 51, 48, 52, 52, 48, + 48, 52, 48, 52, 53, 48, 48, 97, 99, 99, 101, 112, 116, 45, 99, + 104, 97, 114, 115, 101, 116, 103, 122, 105, 112, 44, 32, 100, 101, 102, + 108, 97, 116, 101, 97, 99, 99, 101, 112, 116, 45, 108, 97, 110, 103, + 117, 97, 103, 101, 97, 99, 99, 101, 112, 116, 45, 114, 97, 110, 103, + 101, 115, 97, 99, 99, 101, 112, 116, 97, 99, 99, 101, 115, 115, 45, + 99, 111, 110, 116, 114, 111, 108, 45, 97, 108, 108, 111, 119, 45, 111, + 114, 105, 103, 105, 110, 97, 103, 101, 97, 108, 108, 111, 119, 97, 117, + 116, 104, 111, 114, 105, 122, 97, 116, 105, 111, 110, 99, 97, 99, 104, + 101, 45, 99, 111, 110, 116, 114, 111, 108, 99, 111, 110, 116, 101, 110, + 116, 45, 100, 105, 115, 112, 111, 115, 105, 116, 105, 111, 110, 99, 111, + 110, 116, 101, 110, 116, 45, 108, 97, 110, 103, 117, 97, 103, 101, 99, + 111, 110, 116, 101, 110, 116, 45, 108, 101, 110, 103, 116, 104, 99, 111, + 110, 116, 101, 110, 116, 45, 108, 111, 99, 97, 116, 105, 111, 110, 99, + 111, 110, 116, 101, 110, 116, 45, 114, 97, 110, 103, 101, 99, 111, 111, + 107, 105, 101, 100, 97, 116, 101, 101, 116, 97, 103, 101, 120, 112, 101, + 99, 116, 101, 120, 112, 105, 114, 101, 115, 102, 114, 111, 109, 105, 102, + 45, 109, 97, 116, 99, 104, 105, 102, 45, 109, 111, 100, 105, 102, 105, + 101, 100, 45, 115, 105, 110, 99, 101, 105, 102, 45, 110, 111, 110, 101, + 45, 109, 97, 116, 99, 104, 105, 102, 45, 114, 97, 110, 103, 101, 105, + 102, 45, 117, 110, 109, 111, 100, 105, 102, 105, 101, 100, 45, 115, 105, + 110, 99, 101, 108, 97, 115, 116, 45, 109, 111, 100, 105, 102, 105, 101, + 100, 108, 105, 110, 107, 108, 111, 99, 97, 116, 105, 111, 110, 109, 97, + 120, 45, 102, 111, 114, 119, 97, 114, 100, 115, 112, 114, 111, 120, 121, + 45, 97, 117, 116, 104, 101, 110, 116, 105, 99, 97, 116, 101, 112, 114, + 111, 120, 121, 45, 97, 117, 116, 104, 111, 114, 105, 122, 97, 116, 105, + 111, 110, 114, 97, 110, 103, 101, 114, 101, 102, 101, 114, 101, 114, 114, + 101, 102, 114, 101, 115, 104, 114, 101, 116, 114, 121, 45, 97, 102, 116, + 101, 114, 115, 101, 114, 118, 101, 114, 115, 101, 116, 45, 99, 111, 111, + 107, 105, 101, 115, 116, 114, 105, 99, 116, 45, 116, 114, 97, 110, 115, + 112, 111, 114, 116, 45, 115, 101, 99, 117, 114, 105, 116, 121, 116, 114, + 97, 110, 115, 102, 101, 114, 45, 101, 110, 99, 111, 100, 105, 110, 103, + 118, 97, 114, 121, 118, 105, 97, 119, 119, 119, 45, 97, 117, 116, 104, + 101, 110, 116, 105, 99, 97, 116, 101, 48, 105, 100, 101, 110, 116, 105, + 116, 121, 116, 114, 97, 105, 108, 101, 114, 115, 97, 112, 112, 108, 105, + 99, 97, 116, 105, 111, 110, 47, 103, 114, 112, 99, 103, 114, 112, 99, + 80, 85, 84, 108, 98, 45, 99, 111, 115, 116, 45, 98, 105, 110, 105, + 100, 101, 110, 116, 105, 116, 121, 44, 100, 101, 102, 108, 97, 116, 101, + 105, 100, 101, 110, 116, 105, 116, 121, 44, 103, 122, 105, 112, 100, 101, + 102, 108, 97, 116, 101, 44, 103, 122, 105, 112, 105, 100, 101, 110, 116, + 105, 116, 121, 44, 100, 101, 102, 108, 97, 116, 101, 44, 103, 122, 105, + 112}; grpc_slice_refcount grpc_core::StaticSliceRefcount::kStaticSubRefcount; grpc_core::StaticSliceRefcount @@ -229,6 +234,7 @@ grpc_core::StaticSliceRefcount grpc_core::StaticSliceRefcount(104), grpc_core::StaticSliceRefcount(105), grpc_core::StaticSliceRefcount(106), + grpc_core::StaticSliceRefcount(107), }; const grpc_core::StaticMetadataSlice @@ -302,151 +308,153 @@ const grpc_core::StaticMetadataSlice grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[33].base, 36, g_bytes + 438), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[34].base, - 54, g_bytes + 474), + 65, g_bytes + 474), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[35].base, - 28, g_bytes + 528), + 54, g_bytes + 539), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[36].base, - 80, g_bytes + 556), + 28, g_bytes + 593), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37].base, - 7, g_bytes + 636), + 80, g_bytes + 621), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[38].base, - 4, g_bytes + 643), + 7, g_bytes + 701), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[39].base, - 11, g_bytes + 647), + 4, g_bytes + 708), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[40].base, - 3, g_bytes + 658), + 11, g_bytes + 712), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[41].base, - 4, g_bytes + 661), + 3, g_bytes + 723), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[42].base, - 1, g_bytes + 665), + 4, g_bytes + 726), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[43].base, - 11, g_bytes + 666), + 1, g_bytes + 730), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[44].base, - 4, g_bytes + 677), + 11, g_bytes + 731), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[45].base, - 5, g_bytes + 681), + 4, g_bytes + 742), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[46].base, - 3, g_bytes + 686), + 5, g_bytes + 746), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[47].base, - 3, g_bytes + 689), + 3, g_bytes + 751), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[48].base, - 3, g_bytes + 692), + 3, g_bytes + 754), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[49].base, - 3, g_bytes + 695), + 3, g_bytes + 757), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[50].base, - 3, g_bytes + 698), + 3, g_bytes + 760), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[51].base, - 3, g_bytes + 701), + 3, g_bytes + 763), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[52].base, - 3, g_bytes + 704), + 3, g_bytes + 766), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[53].base, - 14, g_bytes + 707), + 3, g_bytes + 769), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[54].base, - 13, g_bytes + 721), + 14, g_bytes + 772), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[55].base, - 15, g_bytes + 734), + 13, g_bytes + 786), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[56].base, - 13, g_bytes + 749), + 15, g_bytes + 799), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[57].base, - 6, g_bytes + 762), + 13, g_bytes + 814), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[58].base, - 27, g_bytes + 768), + 6, g_bytes + 827), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[59].base, - 3, g_bytes + 795), + 27, g_bytes + 833), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[60].base, - 5, g_bytes + 798), + 3, g_bytes + 860), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[61].base, - 13, g_bytes + 803), + 5, g_bytes + 863), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[62].base, - 13, g_bytes + 816), + 13, g_bytes + 868), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[63].base, - 19, g_bytes + 829), + 13, g_bytes + 881), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[64].base, - 16, g_bytes + 848), + 19, g_bytes + 894), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[65].base, - 14, g_bytes + 864), + 16, g_bytes + 913), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[66].base, - 16, g_bytes + 878), + 14, g_bytes + 929), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[67].base, - 13, g_bytes + 894), + 16, g_bytes + 943), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[68].base, - 6, g_bytes + 907), + 13, g_bytes + 959), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[69].base, - 4, g_bytes + 913), + 6, g_bytes + 972), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[70].base, - 4, g_bytes + 917), + 4, g_bytes + 978), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[71].base, - 6, g_bytes + 921), + 4, g_bytes + 982), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[72].base, - 7, g_bytes + 927), + 6, g_bytes + 986), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[73].base, - 4, g_bytes + 934), + 7, g_bytes + 992), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[74].base, - 8, g_bytes + 938), + 4, g_bytes + 999), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[75].base, - 17, g_bytes + 946), + 8, g_bytes + 1003), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[76].base, - 13, g_bytes + 963), + 17, g_bytes + 1011), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[77].base, - 8, g_bytes + 976), + 13, g_bytes + 1028), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[78].base, - 19, g_bytes + 984), + 8, g_bytes + 1041), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[79].base, - 13, g_bytes + 1003), + 19, g_bytes + 1049), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[80].base, - 4, g_bytes + 1016), + 13, g_bytes + 1068), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[81].base, - 8, g_bytes + 1020), + 4, g_bytes + 1081), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[82].base, - 12, g_bytes + 1028), + 8, g_bytes + 1085), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[83].base, - 18, g_bytes + 1040), + 12, g_bytes + 1093), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[84].base, - 19, g_bytes + 1058), + 18, g_bytes + 1105), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[85].base, - 5, g_bytes + 1077), + 19, g_bytes + 1123), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[86].base, - 7, g_bytes + 1082), + 5, g_bytes + 1142), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[87].base, - 7, g_bytes + 1089), + 7, g_bytes + 1147), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[88].base, - 11, g_bytes + 1096), + 7, g_bytes + 1154), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[89].base, - 6, g_bytes + 1107), + 11, g_bytes + 1161), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[90].base, - 10, g_bytes + 1113), + 6, g_bytes + 1172), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[91].base, - 25, g_bytes + 1123), + 10, g_bytes + 1178), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[92].base, - 17, g_bytes + 1148), + 25, g_bytes + 1188), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[93].base, - 4, g_bytes + 1165), + 17, g_bytes + 1213), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[94].base, - 3, g_bytes + 1169), + 4, g_bytes + 1230), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[95].base, - 16, g_bytes + 1172), + 3, g_bytes + 1234), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96].base, - 1, g_bytes + 1188), + 16, g_bytes + 1237), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97].base, - 8, g_bytes + 1189), + 1, g_bytes + 1253), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98].base, - 8, g_bytes + 1197), + 8, g_bytes + 1254), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[99].base, - 16, g_bytes + 1205), + 8, g_bytes + 1262), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[100].base, 4, g_bytes + 1221), + &grpc_static_metadata_refcounts[100].base, 16, g_bytes + 1270), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[101].base, 3, g_bytes + 1225), + &grpc_static_metadata_refcounts[101].base, 4, g_bytes + 1286), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[102].base, 11, g_bytes + 1228), + &grpc_static_metadata_refcounts[102].base, 3, g_bytes + 1290), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[103].base, 16, g_bytes + 1239), + &grpc_static_metadata_refcounts[103].base, 11, g_bytes + 1293), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[104].base, 13, g_bytes + 1255), + &grpc_static_metadata_refcounts[104].base, 16, g_bytes + 1304), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[105].base, 12, g_bytes + 1268), + &grpc_static_metadata_refcounts[105].base, 13, g_bytes + 1320), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[106].base, 21, g_bytes + 1280), + &grpc_static_metadata_refcounts[106].base, 12, g_bytes + 1333), + grpc_core::StaticMetadataSlice( + &grpc_static_metadata_refcounts[107].base, 21, g_bytes + 1345), }; /* Warning: the core static metadata currently operates under the soft @@ -892,17 +900,17 @@ uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 4, 6, 6, 8, 8, 2, 4, 4}; static const int8_t elems_r[] = { - 15, 10, -8, 0, 2, -43, -81, -43, 0, 4, -8, 0, 0, 0, 8, - -2, -9, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, -64, 0, -67, -68, -69, -51, -72, - 0, 32, 31, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, - 19, 18, 17, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, - 5, 4, 3, 4, 3, 3, 8, 0, 0, 0, 0, 0, 0, -5, 0}; + 15, 10, -8, 0, 2, -43, -80, -44, 0, 4, -8, 0, 0, 0, 6, -1, + -8, 0, 0, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -65, 0, -68, -69, -50, -72, -73, 0, 32, 31, + 30, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 17, + 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 4, 3, + 3, 7, 0, 0, 0, 0, 0, 0, -5, 0}; static uint32_t elems_phash(uint32_t i) { - i -= 42; - uint32_t x = i % 105; - uint32_t y = i / 105; + i -= 43; + uint32_t x = i % 106; + uint32_t y = i / 106; uint32_t h = x; if (y < GPR_ARRAY_SIZE(elems_r)) { uint32_t delta = (uint32_t)elems_r[y]; @@ -912,29 +920,29 @@ static uint32_t elems_phash(uint32_t i) { } static const uint16_t elem_keys[] = { - 260, 261, 262, 263, 264, 265, 266, 1107, 1108, 1740, 147, 148, - 472, 473, 1633, 42, 43, 1000, 1001, 1750, 773, 774, 1526, 633, - 1643, 845, 2061, 2168, 5699, 5913, 6020, 6127, 6341, 6448, 6555, 1766, - 6662, 6769, 6876, 6983, 7090, 7197, 7304, 7411, 7518, 7625, 7732, 7839, - 7946, 8053, 8160, 6234, 8267, 8374, 8481, 8588, 8695, 8802, 8909, 9016, - 9123, 9230, 9337, 9444, 9551, 9658, 9765, 1167, 528, 9872, 9979, 208, - 10086, 1173, 1174, 1175, 1176, 1060, 1809, 10193, 10942, 0, 0, 1702, - 0, 1816, 0, 0, 0, 349, 0, 0, 0, 1597, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0}; + 263, 264, 265, 266, 267, 268, 269, 1118, 1119, 1756, 149, 150, + 477, 478, 1648, 43, 44, 1010, 1011, 1540, 1767, 780, 781, 639, + 853, 1659, 2080, 2188, 5860, 6076, 6184, 6400, 6508, 6616, 6724, 6832, + 1783, 6940, 7048, 7156, 7264, 7372, 7480, 7588, 7696, 7804, 7912, 8020, + 8128, 8236, 8344, 6292, 8452, 8560, 8668, 8776, 8884, 8992, 9100, 9208, + 9316, 9424, 9532, 9640, 9748, 9856, 9964, 1178, 533, 10072, 10180, 210, + 10288, 1184, 1185, 1186, 1187, 1070, 10396, 1826, 11152, 0, 0, 0, + 1718, 0, 1833, 0, 0, 352, 0, 1612, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0}; static const uint8_t elem_idxs[] = { - 7, 8, 9, 10, 11, 12, 13, 76, 78, 71, 1, 2, 5, 6, 25, 3, - 4, 66, 65, 83, 62, 63, 30, 67, 73, 61, 57, 37, 14, 16, 17, 18, - 20, 21, 22, 15, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34, 35, 36, - 38, 39, 40, 19, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 75, 69, 56, 58, 70, 59, 77, 79, 80, 81, 64, 82, 60, - 74, 255, 255, 72, 255, 84, 255, 255, 255, 0, 255, 255, 255, 68}; + 7, 8, 9, 10, 11, 12, 13, 76, 78, 71, 1, 2, 5, 6, 25, 3, + 4, 66, 65, 30, 83, 62, 63, 67, 61, 73, 57, 37, 14, 16, 17, 19, + 20, 21, 22, 23, 15, 24, 26, 27, 28, 29, 31, 32, 33, 34, 35, 36, + 38, 39, 40, 18, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 75, 69, 56, 58, 70, 59, 77, 79, 80, 81, 64, 60, 82, + 74, 255, 255, 255, 72, 255, 84, 255, 255, 0, 255, 68}; grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b) { if (a == -1 || b == -1) return GRPC_MDNULL; - uint32_t k = static_cast(a * 107 + b); + uint32_t k = static_cast(a * 108 + b); uint32_t h = elems_phash(k); return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k && elem_idxs[h] != 255 @@ -953,144 +961,144 @@ grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1].base, 7, g_bytes + 5), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[40].base, - 3, g_bytes + 658), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[41].base, + 3, g_bytes + 723), 1), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1].base, 7, g_bytes + 5), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[41].base, - 4, g_bytes + 661), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[42].base, + 4, g_bytes + 726), 2), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[0].base, 5, g_bytes + 0), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[42].base, - 1, g_bytes + 665), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[43].base, + 1, g_bytes + 730), 3), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[0].base, 5, g_bytes + 0), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[43].base, - 11, g_bytes + 666), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[44].base, + 11, g_bytes + 731), 4), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4].base, 7, g_bytes + 29), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[44].base, - 4, g_bytes + 677), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[45].base, + 4, g_bytes + 742), 5), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4].base, 7, g_bytes + 29), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[45].base, - 5, g_bytes + 681), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[46].base, + 5, g_bytes + 746), 6), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[46].base, - 3, g_bytes + 686), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[47].base, + 3, g_bytes + 751), 7), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[47].base, - 3, g_bytes + 689), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[48].base, + 3, g_bytes + 754), 8), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[48].base, - 3, g_bytes + 692), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[49].base, + 3, g_bytes + 757), 9), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[49].base, - 3, g_bytes + 695), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[50].base, + 3, g_bytes + 760), 10), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[50].base, - 3, g_bytes + 698), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[51].base, + 3, g_bytes + 763), 11), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[51].base, - 3, g_bytes + 701), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[52].base, + 3, g_bytes + 766), 12), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[52].base, - 3, g_bytes + 704), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[53].base, + 3, g_bytes + 769), 13), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[53].base, - 14, g_bytes + 707), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[54].base, + 14, g_bytes + 772), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 14), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, 15, g_bytes + 186), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[54].base, - 13, g_bytes + 721), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[55].base, + 13, g_bytes + 786), 15), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[55].base, - 15, g_bytes + 734), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[56].base, + 15, g_bytes + 799), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 16), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[56].base, - 13, g_bytes + 749), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[57].base, + 13, g_bytes + 814), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 17), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[57].base, - 6, g_bytes + 762), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[58].base, + 6, g_bytes + 827), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 18), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[58].base, - 27, g_bytes + 768), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[59].base, + 27, g_bytes + 833), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 19), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[59].base, - 3, g_bytes + 795), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[60].base, + 3, g_bytes + 860), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 20), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[60].base, - 5, g_bytes + 798), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[61].base, + 5, g_bytes + 863), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 21), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[61].base, - 13, g_bytes + 803), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[62].base, + 13, g_bytes + 868), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 22), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[62].base, - 13, g_bytes + 816), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[63].base, + 13, g_bytes + 881), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 23), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[63].base, - 19, g_bytes + 829), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[64].base, + 19, g_bytes + 894), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 24), @@ -1101,26 +1109,26 @@ grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { 0, g_bytes + 346), 25), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[64].base, - 16, g_bytes + 848), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[65].base, + 16, g_bytes + 913), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 26), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[65].base, - 14, g_bytes + 864), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[66].base, + 14, g_bytes + 929), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 27), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[66].base, - 16, g_bytes + 878), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[67].base, + 16, g_bytes + 943), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 28), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[67].base, - 13, g_bytes + 894), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[68].base, + 13, g_bytes + 959), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 29), @@ -1131,38 +1139,38 @@ grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { 0, g_bytes + 346), 30), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[68].base, - 6, g_bytes + 907), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[69].base, + 6, g_bytes + 972), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 31), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[69].base, - 4, g_bytes + 913), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[70].base, + 4, g_bytes + 978), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 32), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[70].base, - 4, g_bytes + 917), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[71].base, + 4, g_bytes + 982), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 33), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[71].base, - 6, g_bytes + 921), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[72].base, + 6, g_bytes + 986), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 34), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[72].base, - 7, g_bytes + 927), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[73].base, + 7, g_bytes + 992), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 35), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[73].base, - 4, g_bytes + 934), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[74].base, + 4, g_bytes + 999), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 36), @@ -1173,116 +1181,116 @@ grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { 0, g_bytes + 346), 37), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[74].base, - 8, g_bytes + 938), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[75].base, + 8, g_bytes + 1003), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 38), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[75].base, - 17, g_bytes + 946), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[76].base, + 17, g_bytes + 1011), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 39), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[76].base, - 13, g_bytes + 963), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[77].base, + 13, g_bytes + 1028), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 40), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[77].base, - 8, g_bytes + 976), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[78].base, + 8, g_bytes + 1041), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 41), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[78].base, - 19, g_bytes + 984), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[79].base, + 19, g_bytes + 1049), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 42), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[79].base, - 13, g_bytes + 1003), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[80].base, + 13, g_bytes + 1068), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 43), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[80].base, - 4, g_bytes + 1016), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[81].base, + 4, g_bytes + 1081), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 44), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[81].base, - 8, g_bytes + 1020), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[82].base, + 8, g_bytes + 1085), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 45), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[82].base, - 12, g_bytes + 1028), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[83].base, + 12, g_bytes + 1093), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 46), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[83].base, - 18, g_bytes + 1040), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[84].base, + 18, g_bytes + 1105), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 47), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[84].base, - 19, g_bytes + 1058), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[85].base, + 19, g_bytes + 1123), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 48), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[85].base, - 5, g_bytes + 1077), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[86].base, + 5, g_bytes + 1142), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 49), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[86].base, - 7, g_bytes + 1082), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[87].base, + 7, g_bytes + 1147), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 50), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[87].base, - 7, g_bytes + 1089), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[88].base, + 7, g_bytes + 1154), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 51), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[88].base, - 11, g_bytes + 1096), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[89].base, + 11, g_bytes + 1161), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 52), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[89].base, - 6, g_bytes + 1107), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[90].base, + 6, g_bytes + 1172), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 53), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[90].base, - 10, g_bytes + 1113), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[91].base, + 10, g_bytes + 1178), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 54), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[91].base, - 25, g_bytes + 1123), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[92].base, + 25, g_bytes + 1188), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 55), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[92].base, - 17, g_bytes + 1148), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[93].base, + 17, g_bytes + 1213), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 56), @@ -1293,28 +1301,28 @@ grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { 0, g_bytes + 346), 57), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[93].base, - 4, g_bytes + 1165), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[94].base, + 4, g_bytes + 1230), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 58), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[94].base, - 3, g_bytes + 1169), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[95].base, + 3, g_bytes + 1234), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 59), grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[95].base, - 16, g_bytes + 1172), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96].base, + 16, g_bytes + 1237), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 60), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7].base, 11, g_bytes + 50), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96].base, - 1, g_bytes + 1188), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97].base, + 1, g_bytes + 1253), 61), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7].base, @@ -1331,44 +1339,44 @@ grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9].base, 13, g_bytes + 77), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97].base, - 8, g_bytes + 1189), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98].base, + 8, g_bytes + 1254), 64), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9].base, 13, g_bytes + 77), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[38].base, - 4, g_bytes + 643), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[39].base, + 4, g_bytes + 708), 65), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9].base, 13, g_bytes + 77), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37].base, - 7, g_bytes + 636), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[38].base, + 7, g_bytes + 701), 66), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[5].base, 2, g_bytes + 36), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98].base, - 8, g_bytes + 1197), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[99].base, + 8, g_bytes + 1262), 67), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[14].base, 12, g_bytes + 158), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[99].base, - 16, g_bytes + 1205), + grpc_core::StaticMetadataSlice( + &grpc_static_metadata_refcounts[100].base, 16, g_bytes + 1270), 68), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4].base, 7, g_bytes + 29), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[100].base, 4, g_bytes + 1221), + &grpc_static_metadata_refcounts[101].base, 4, g_bytes + 1286), 69), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1].base, 7, g_bytes + 5), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[101].base, 3, g_bytes + 1225), + &grpc_static_metadata_refcounts[102].base, 3, g_bytes + 1290), 70), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, @@ -1379,80 +1387,80 @@ grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15].base, 16, g_bytes + 170), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97].base, - 8, g_bytes + 1189), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98].base, + 8, g_bytes + 1254), 72), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15].base, 16, g_bytes + 170), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[38].base, - 4, g_bytes + 643), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[39].base, + 4, g_bytes + 708), 73), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[102].base, 11, g_bytes + 1228), + &grpc_static_metadata_refcounts[103].base, 11, g_bytes + 1293), grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, 0, g_bytes + 346), 74), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, 20, g_bytes + 90), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97].base, - 8, g_bytes + 1189), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98].base, + 8, g_bytes + 1254), 75), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, 20, g_bytes + 90), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37].base, - 7, g_bytes + 636), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[38].base, + 7, g_bytes + 701), 76), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, 20, g_bytes + 90), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[103].base, 16, g_bytes + 1239), + &grpc_static_metadata_refcounts[104].base, 16, g_bytes + 1304), 77), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, 20, g_bytes + 90), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[38].base, - 4, g_bytes + 643), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[39].base, + 4, g_bytes + 708), 78), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, 20, g_bytes + 90), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[104].base, 13, g_bytes + 1255), + &grpc_static_metadata_refcounts[105].base, 13, g_bytes + 1320), 79), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, 20, g_bytes + 90), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[105].base, 12, g_bytes + 1268), + &grpc_static_metadata_refcounts[106].base, 12, g_bytes + 1333), 80), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, 20, g_bytes + 90), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[106].base, 21, g_bytes + 1280), + &grpc_static_metadata_refcounts[107].base, 21, g_bytes + 1345), 81), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, 15, g_bytes + 186), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97].base, - 8, g_bytes + 1189), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98].base, + 8, g_bytes + 1254), 82), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, 15, g_bytes + 186), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[38].base, - 4, g_bytes + 643), + grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[39].base, + 4, g_bytes + 708), 83), grpc_core::StaticMetadata( grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, 15, g_bytes + 186), grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[104].base, 13, g_bytes + 1255), + &grpc_static_metadata_refcounts[105].base, 13, g_bytes + 1320), 84), }; const uint8_t grpc_static_accept_encoding_metadata[8] = {0, 75, 76, 77, diff --git a/src/core/lib/transport/static_metadata.h b/src/core/lib/transport/static_metadata.h index 787bae7ede5..7ea000e1066 100644 --- a/src/core/lib/transport/static_metadata.h +++ b/src/core/lib/transport/static_metadata.h @@ -36,7 +36,7 @@ static_assert( std::is_trivially_destructible::value, "grpc_core::StaticMetadataSlice must be trivially destructible."); -#define GRPC_STATIC_MDSTR_COUNT 107 +#define GRPC_STATIC_MDSTR_COUNT 108 extern const grpc_core::StaticMetadataSlice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT]; /* ":path" */ @@ -111,157 +111,160 @@ extern const grpc_core::StaticMetadataSlice /* "/grpc.lb.v1.LoadBalancer/BalanceLoad" */ #define GRPC_MDSTR_SLASH_GRPC_DOT_LB_DOT_V1_DOT_LOADBALANCER_SLASH_BALANCELOAD \ (grpc_static_slice_table[33]) +/* "/envoy.service.load_stats.v2.LoadReportingService/StreamLoadStats" */ +#define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_LOAD_STATS_DOT_V2_DOT_LOADREPORTINGSERVICE_SLASH_STREAMLOADSTATS \ + (grpc_static_slice_table[34]) /* "/envoy.api.v2.EndpointDiscoveryService/StreamEndpoints" */ #define GRPC_MDSTR_SLASH_ENVOY_DOT_API_DOT_V2_DOT_ENDPOINTDISCOVERYSERVICE_SLASH_STREAMENDPOINTS \ - (grpc_static_slice_table[34]) + (grpc_static_slice_table[35]) /* "/grpc.health.v1.Health/Watch" */ #define GRPC_MDSTR_SLASH_GRPC_DOT_HEALTH_DOT_V1_DOT_HEALTH_SLASH_WATCH \ - (grpc_static_slice_table[35]) + (grpc_static_slice_table[36]) /* "/envoy.service.discovery.v2.AggregatedDiscoveryService/StreamAggregatedResources" */ #define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_DISCOVERY_DOT_V2_DOT_AGGREGATEDDISCOVERYSERVICE_SLASH_STREAMAGGREGATEDRESOURCES \ - (grpc_static_slice_table[36]) + (grpc_static_slice_table[37]) /* "deflate" */ -#define GRPC_MDSTR_DEFLATE (grpc_static_slice_table[37]) +#define GRPC_MDSTR_DEFLATE (grpc_static_slice_table[38]) /* "gzip" */ -#define GRPC_MDSTR_GZIP (grpc_static_slice_table[38]) +#define GRPC_MDSTR_GZIP (grpc_static_slice_table[39]) /* "stream/gzip" */ -#define GRPC_MDSTR_STREAM_SLASH_GZIP (grpc_static_slice_table[39]) +#define GRPC_MDSTR_STREAM_SLASH_GZIP (grpc_static_slice_table[40]) /* "GET" */ -#define GRPC_MDSTR_GET (grpc_static_slice_table[40]) +#define GRPC_MDSTR_GET (grpc_static_slice_table[41]) /* "POST" */ -#define GRPC_MDSTR_POST (grpc_static_slice_table[41]) +#define GRPC_MDSTR_POST (grpc_static_slice_table[42]) /* "/" */ -#define GRPC_MDSTR_SLASH (grpc_static_slice_table[42]) +#define GRPC_MDSTR_SLASH (grpc_static_slice_table[43]) /* "/index.html" */ -#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (grpc_static_slice_table[43]) +#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (grpc_static_slice_table[44]) /* "http" */ -#define GRPC_MDSTR_HTTP (grpc_static_slice_table[44]) +#define GRPC_MDSTR_HTTP (grpc_static_slice_table[45]) /* "https" */ -#define GRPC_MDSTR_HTTPS (grpc_static_slice_table[45]) +#define GRPC_MDSTR_HTTPS (grpc_static_slice_table[46]) /* "200" */ -#define GRPC_MDSTR_200 (grpc_static_slice_table[46]) +#define GRPC_MDSTR_200 (grpc_static_slice_table[47]) /* "204" */ -#define GRPC_MDSTR_204 (grpc_static_slice_table[47]) +#define GRPC_MDSTR_204 (grpc_static_slice_table[48]) /* "206" */ -#define GRPC_MDSTR_206 (grpc_static_slice_table[48]) +#define GRPC_MDSTR_206 (grpc_static_slice_table[49]) /* "304" */ -#define GRPC_MDSTR_304 (grpc_static_slice_table[49]) +#define GRPC_MDSTR_304 (grpc_static_slice_table[50]) /* "400" */ -#define GRPC_MDSTR_400 (grpc_static_slice_table[50]) +#define GRPC_MDSTR_400 (grpc_static_slice_table[51]) /* "404" */ -#define GRPC_MDSTR_404 (grpc_static_slice_table[51]) +#define GRPC_MDSTR_404 (grpc_static_slice_table[52]) /* "500" */ -#define GRPC_MDSTR_500 (grpc_static_slice_table[52]) +#define GRPC_MDSTR_500 (grpc_static_slice_table[53]) /* "accept-charset" */ -#define GRPC_MDSTR_ACCEPT_CHARSET (grpc_static_slice_table[53]) +#define GRPC_MDSTR_ACCEPT_CHARSET (grpc_static_slice_table[54]) /* "gzip, deflate" */ -#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (grpc_static_slice_table[54]) +#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (grpc_static_slice_table[55]) /* "accept-language" */ -#define GRPC_MDSTR_ACCEPT_LANGUAGE (grpc_static_slice_table[55]) +#define GRPC_MDSTR_ACCEPT_LANGUAGE (grpc_static_slice_table[56]) /* "accept-ranges" */ -#define GRPC_MDSTR_ACCEPT_RANGES (grpc_static_slice_table[56]) +#define GRPC_MDSTR_ACCEPT_RANGES (grpc_static_slice_table[57]) /* "accept" */ -#define GRPC_MDSTR_ACCEPT (grpc_static_slice_table[57]) +#define GRPC_MDSTR_ACCEPT (grpc_static_slice_table[58]) /* "access-control-allow-origin" */ -#define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN (grpc_static_slice_table[58]) +#define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN (grpc_static_slice_table[59]) /* "age" */ -#define GRPC_MDSTR_AGE (grpc_static_slice_table[59]) +#define GRPC_MDSTR_AGE (grpc_static_slice_table[60]) /* "allow" */ -#define GRPC_MDSTR_ALLOW (grpc_static_slice_table[60]) +#define GRPC_MDSTR_ALLOW (grpc_static_slice_table[61]) /* "authorization" */ -#define GRPC_MDSTR_AUTHORIZATION (grpc_static_slice_table[61]) +#define GRPC_MDSTR_AUTHORIZATION (grpc_static_slice_table[62]) /* "cache-control" */ -#define GRPC_MDSTR_CACHE_CONTROL (grpc_static_slice_table[62]) +#define GRPC_MDSTR_CACHE_CONTROL (grpc_static_slice_table[63]) /* "content-disposition" */ -#define GRPC_MDSTR_CONTENT_DISPOSITION (grpc_static_slice_table[63]) +#define GRPC_MDSTR_CONTENT_DISPOSITION (grpc_static_slice_table[64]) /* "content-language" */ -#define GRPC_MDSTR_CONTENT_LANGUAGE (grpc_static_slice_table[64]) +#define GRPC_MDSTR_CONTENT_LANGUAGE (grpc_static_slice_table[65]) /* "content-length" */ -#define GRPC_MDSTR_CONTENT_LENGTH (grpc_static_slice_table[65]) +#define GRPC_MDSTR_CONTENT_LENGTH (grpc_static_slice_table[66]) /* "content-location" */ -#define GRPC_MDSTR_CONTENT_LOCATION (grpc_static_slice_table[66]) +#define GRPC_MDSTR_CONTENT_LOCATION (grpc_static_slice_table[67]) /* "content-range" */ -#define GRPC_MDSTR_CONTENT_RANGE (grpc_static_slice_table[67]) +#define GRPC_MDSTR_CONTENT_RANGE (grpc_static_slice_table[68]) /* "cookie" */ -#define GRPC_MDSTR_COOKIE (grpc_static_slice_table[68]) +#define GRPC_MDSTR_COOKIE (grpc_static_slice_table[69]) /* "date" */ -#define GRPC_MDSTR_DATE (grpc_static_slice_table[69]) +#define GRPC_MDSTR_DATE (grpc_static_slice_table[70]) /* "etag" */ -#define GRPC_MDSTR_ETAG (grpc_static_slice_table[70]) +#define GRPC_MDSTR_ETAG (grpc_static_slice_table[71]) /* "expect" */ -#define GRPC_MDSTR_EXPECT (grpc_static_slice_table[71]) +#define GRPC_MDSTR_EXPECT (grpc_static_slice_table[72]) /* "expires" */ -#define GRPC_MDSTR_EXPIRES (grpc_static_slice_table[72]) +#define GRPC_MDSTR_EXPIRES (grpc_static_slice_table[73]) /* "from" */ -#define GRPC_MDSTR_FROM (grpc_static_slice_table[73]) +#define GRPC_MDSTR_FROM (grpc_static_slice_table[74]) /* "if-match" */ -#define GRPC_MDSTR_IF_MATCH (grpc_static_slice_table[74]) +#define GRPC_MDSTR_IF_MATCH (grpc_static_slice_table[75]) /* "if-modified-since" */ -#define GRPC_MDSTR_IF_MODIFIED_SINCE (grpc_static_slice_table[75]) +#define GRPC_MDSTR_IF_MODIFIED_SINCE (grpc_static_slice_table[76]) /* "if-none-match" */ -#define GRPC_MDSTR_IF_NONE_MATCH (grpc_static_slice_table[76]) +#define GRPC_MDSTR_IF_NONE_MATCH (grpc_static_slice_table[77]) /* "if-range" */ -#define GRPC_MDSTR_IF_RANGE (grpc_static_slice_table[77]) +#define GRPC_MDSTR_IF_RANGE (grpc_static_slice_table[78]) /* "if-unmodified-since" */ -#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (grpc_static_slice_table[78]) +#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (grpc_static_slice_table[79]) /* "last-modified" */ -#define GRPC_MDSTR_LAST_MODIFIED (grpc_static_slice_table[79]) +#define GRPC_MDSTR_LAST_MODIFIED (grpc_static_slice_table[80]) /* "link" */ -#define GRPC_MDSTR_LINK (grpc_static_slice_table[80]) +#define GRPC_MDSTR_LINK (grpc_static_slice_table[81]) /* "location" */ -#define GRPC_MDSTR_LOCATION (grpc_static_slice_table[81]) +#define GRPC_MDSTR_LOCATION (grpc_static_slice_table[82]) /* "max-forwards" */ -#define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table[82]) +#define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table[83]) /* "proxy-authenticate" */ -#define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table[83]) +#define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table[84]) /* "proxy-authorization" */ -#define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table[84]) +#define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table[85]) /* "range" */ -#define GRPC_MDSTR_RANGE (grpc_static_slice_table[85]) +#define GRPC_MDSTR_RANGE (grpc_static_slice_table[86]) /* "referer" */ -#define GRPC_MDSTR_REFERER (grpc_static_slice_table[86]) +#define GRPC_MDSTR_REFERER (grpc_static_slice_table[87]) /* "refresh" */ -#define GRPC_MDSTR_REFRESH (grpc_static_slice_table[87]) +#define GRPC_MDSTR_REFRESH (grpc_static_slice_table[88]) /* "retry-after" */ -#define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table[88]) +#define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table[89]) /* "server" */ -#define GRPC_MDSTR_SERVER (grpc_static_slice_table[89]) +#define GRPC_MDSTR_SERVER (grpc_static_slice_table[90]) /* "set-cookie" */ -#define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table[90]) +#define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table[91]) /* "strict-transport-security" */ -#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table[91]) +#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table[92]) /* "transfer-encoding" */ -#define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table[92]) +#define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table[93]) /* "vary" */ -#define GRPC_MDSTR_VARY (grpc_static_slice_table[93]) +#define GRPC_MDSTR_VARY (grpc_static_slice_table[94]) /* "via" */ -#define GRPC_MDSTR_VIA (grpc_static_slice_table[94]) +#define GRPC_MDSTR_VIA (grpc_static_slice_table[95]) /* "www-authenticate" */ -#define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table[95]) +#define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table[96]) /* "0" */ -#define GRPC_MDSTR_0 (grpc_static_slice_table[96]) +#define GRPC_MDSTR_0 (grpc_static_slice_table[97]) /* "identity" */ -#define GRPC_MDSTR_IDENTITY (grpc_static_slice_table[97]) +#define GRPC_MDSTR_IDENTITY (grpc_static_slice_table[98]) /* "trailers" */ -#define GRPC_MDSTR_TRAILERS (grpc_static_slice_table[98]) +#define GRPC_MDSTR_TRAILERS (grpc_static_slice_table[99]) /* "application/grpc" */ -#define GRPC_MDSTR_APPLICATION_SLASH_GRPC (grpc_static_slice_table[99]) +#define GRPC_MDSTR_APPLICATION_SLASH_GRPC (grpc_static_slice_table[100]) /* "grpc" */ -#define GRPC_MDSTR_GRPC (grpc_static_slice_table[100]) +#define GRPC_MDSTR_GRPC (grpc_static_slice_table[101]) /* "PUT" */ -#define GRPC_MDSTR_PUT (grpc_static_slice_table[101]) +#define GRPC_MDSTR_PUT (grpc_static_slice_table[102]) /* "lb-cost-bin" */ -#define GRPC_MDSTR_LB_COST_BIN (grpc_static_slice_table[102]) +#define GRPC_MDSTR_LB_COST_BIN (grpc_static_slice_table[103]) /* "identity,deflate" */ -#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (grpc_static_slice_table[103]) +#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (grpc_static_slice_table[104]) /* "identity,gzip" */ -#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (grpc_static_slice_table[104]) +#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (grpc_static_slice_table[105]) /* "deflate,gzip" */ -#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (grpc_static_slice_table[105]) +#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (grpc_static_slice_table[106]) /* "identity,deflate,gzip" */ #define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \ - (grpc_static_slice_table[106]) + (grpc_static_slice_table[107]) namespace grpc_core { struct StaticSliceRefcount; diff --git a/src/proto/grpc/lb/v2/BUILD b/src/proto/grpc/lb/v2/BUILD index bf0f1a78b1c..0b46b2892ed 100644 --- a/src/proto/grpc/lb/v2/BUILD +++ b/src/proto/grpc/lb/v2/BUILD @@ -22,10 +22,20 @@ grpc_package( ) grpc_proto_library( - name = "xds_for_test_proto", + name = "eds_for_test_proto", srcs = [ - "xds_for_test.proto", + "eds_for_test.proto", ], has_services = True, well_known_protos = True, ) + +grpc_proto_library( + name = "lrs_for_test_proto", + srcs = [ + "lrs_for_test.proto", + ], + has_services = True, + well_known_protos = True, + deps = [":eds_for_test_proto"], +) diff --git a/src/proto/grpc/lb/v2/xds_for_test.proto b/src/proto/grpc/lb/v2/eds_for_test.proto similarity index 100% rename from src/proto/grpc/lb/v2/xds_for_test.proto rename to src/proto/grpc/lb/v2/eds_for_test.proto diff --git a/src/proto/grpc/lb/v2/lrs_for_test.proto b/src/proto/grpc/lb/v2/lrs_for_test.proto new file mode 100644 index 00000000000..76c560a99cf --- /dev/null +++ b/src/proto/grpc/lb/v2/lrs_for_test.proto @@ -0,0 +1,180 @@ +// Copyright 2019 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This file contains the eds protocol and its dependency. +// +// TODO(juanlishen): It's a workaround and should be removed once we have a +// clean solution to the circular dependency between the envoy data plane APIs +// and gRPC. We can't check in this file due to conflict with internal code. + +syntax = "proto3"; + +package envoy.service.load_stats.v2; + +import "google/protobuf/duration.proto"; +import "src/proto/grpc/lb/v2/eds_for_test.proto"; + +// [#not-implemented-hide:] Not configuration. TBD how to doc proto APIs. +message EndpointLoadMetricStats { + // Name of the metric; may be empty. + string metric_name = 1; + + // Number of calls that finished and included this metric. + uint64 num_requests_finished_with_metric = 2; + + // Sum of metric values across all calls that finished with this metric for + // load_reporting_interval. + double total_metric_value = 3; +} + +message UpstreamLocalityStats { + // Name of zone, region and optionally endpoint group these metrics were + // collected from. Zone and region names could be empty if unknown. + envoy.api.v2.Locality locality = 1; + + // The total number of requests successfully completed by the endpoints in the + // locality. + uint64 total_successful_requests = 2; + + // The total number of unfinished requests + uint64 total_requests_in_progress = 3; + + // The total number of requests that failed due to errors at the endpoint, + // aggregated over all endpoints in the locality. + uint64 total_error_requests = 4; + + // The total number of requests that were issued by this Envoy since + // the last report. This information is aggregated over all the + // upstream endpoints in the locality. + uint64 total_issued_requests = 8; + + // Stats for multi-dimensional load balancing. + repeated EndpointLoadMetricStats load_metric_stats = 5; + +// // Endpoint granularity stats information for this locality. This information +// // is populated if the Server requests it by setting +// // :ref:`LoadStatsResponse.report_endpoint_granularity`. +// repeated UpstreamEndpointStats upstream_endpoint_stats = 7; + + // [#not-implemented-hide:] The priority of the endpoint group these metrics + // were collected from. + uint32 priority = 6; +} + +// Per cluster load stats. Envoy reports these stats a management server in a +// :ref:`LoadStatsRequest` +// [#not-implemented-hide:] Not configuration. TBD how to doc proto APIs. +// Next ID: 7 +message ClusterStats { + // The name of the cluster. + string cluster_name = 1; + + // The eds_cluster_config service_name of the cluster. + // It's possible that two clusters send the same service_name to EDS, + // in that case, the management server is supposed to do aggregation on the load reports. + string cluster_service_name = 6; + + // Need at least one. + repeated UpstreamLocalityStats upstream_locality_stats = 2; + + // Cluster-level stats such as total_successful_requests may be computed by + // summing upstream_locality_stats. In addition, below there are additional + // cluster-wide stats. + // + // The total number of dropped requests. This covers requests + // deliberately dropped by the drop_overload policy and circuit breaking. + uint64 total_dropped_requests = 3; + + message DroppedRequests { + // Identifier for the policy specifying the drop. + string category = 1; + // Total number of deliberately dropped requests for the category. + uint64 dropped_count = 2; + } + // Information about deliberately dropped requests for each category specified + // in the DropOverload policy. + repeated DroppedRequests dropped_requests = 5; + + // Period over which the actual load report occurred. This will be guaranteed to include every + // request reported. Due to system load and delays between the *LoadStatsRequest* sent from Envoy + // and the *LoadStatsResponse* message sent from the management server, this may be longer than + // the requested load reporting interval in the *LoadStatsResponse*. + google.protobuf.Duration load_report_interval = 4; +} + +// [#protodoc-title: Load reporting service] + +service LoadReportingService { + // Advanced API to allow for multi-dimensional load balancing by remote + // server. For receiving LB assignments, the steps are: + // 1, The management server is configured with per cluster/zone/load metric + // capacity configuration. The capacity configuration definition is + // outside of the scope of this document. + // 2. Envoy issues a standard {Stream,Fetch}Endpoints request for the clusters + // to balance. + // + // Independently, Envoy will initiate a StreamLoadStats bidi stream with a + // management server: + // 1. Once a connection establishes, the management server publishes a + // LoadStatsResponse for all clusters it is interested in learning load + // stats about. + // 2. For each cluster, Envoy load balances incoming traffic to upstream hosts + // based on per-zone weights and/or per-instance weights (if specified) + // based on intra-zone LbPolicy. This information comes from the above + // {Stream,Fetch}Endpoints. + // 3. When upstream hosts reply, they optionally add header with ASCII representation of EndpointLoadMetricStats. + // 4. Envoy aggregates load reports over the period of time given to it in + // LoadStatsResponse.load_reporting_interval. This includes aggregation + // stats Envoy maintains by itself (total_requests, rpc_errors etc.) as + // well as load metrics from upstream hosts. + // 5. When the timer of load_reporting_interval expires, Envoy sends new + // LoadStatsRequest filled with load reports for each cluster. + // 6. The management server uses the load reports from all reported Envoys + // from around the world, computes global assignment and prepares traffic + // assignment destined for each zone Envoys are located in. Goto 2. + rpc StreamLoadStats(stream LoadStatsRequest) returns (stream LoadStatsResponse) { + } +} + +// A load report Envoy sends to the management server. +// [#not-implemented-hide:] Not configuration. TBD how to doc proto APIs. +message LoadStatsRequest { + // Node identifier for Envoy instance. + envoy.api.v2.Node node = 1; + + // A list of load stats to report. + repeated ClusterStats cluster_stats = 2; +} + +// The management server sends envoy a LoadStatsResponse with all clusters it +// is interested in learning load stats about. +// [#not-implemented-hide:] Not configuration. TBD how to doc proto APIs. +message LoadStatsResponse { + // Clusters to report stats for. + repeated string clusters = 1; + + // The minimum interval of time to collect stats over. This is only a minimum for two reasons: + // 1. There may be some delay from when the timer fires until stats sampling occurs. + // 2. For clusters that were already feature in the previous *LoadStatsResponse*, any traffic + // that is observed in between the corresponding previous *LoadStatsRequest* and this + // *LoadStatsResponse* will also be accumulated and billed to the cluster. This avoids a period + // of inobservability that might otherwise exists between the messages. New clusters are not + // subject to this consideration. + google.protobuf.Duration load_reporting_interval = 2; + + // Set to *true* if the management server supports endpoint granularity + // report. + bool report_endpoint_granularity = 3; +} diff --git a/test/core/end2end/fuzzers/hpack.dictionary b/test/core/end2end/fuzzers/hpack.dictionary index 24e3320dd71..921018db7f8 100644 --- a/test/core/end2end/fuzzers/hpack.dictionary +++ b/test/core/end2end/fuzzers/hpack.dictionary @@ -33,6 +33,7 @@ "\x1Egrpc.max_request_message_bytes" "\x1Fgrpc.max_response_message_bytes" "$/grpc.lb.v1.LoadBalancer/BalanceLoad" +"A/envoy.service.load_stats.v2.LoadReportingService/StreamLoadStats" "6/envoy.api.v2.EndpointDiscoveryService/StreamEndpoints" "\x1C/grpc.health.v1.Health/Watch" "P/envoy.service.discovery.v2.AggregatedDiscoveryService/StreamAggregatedResources" diff --git a/test/core/util/test_lb_policies.cc b/test/core/util/test_lb_policies.cc index 12a042ab827..5ee2f5fe049 100644 --- a/test/core/util/test_lb_policies.cc +++ b/test/core/util/test_lb_policies.cc @@ -188,7 +188,7 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy private: static void RecordRecvTrailingMetadata( - void* arg, MetadataInterface* recv_trailing_metadata, + void* arg, grpc_error* error, MetadataInterface* recv_trailing_metadata, CallState* call_state) { TrailingMetadataHandler* self = static_cast(arg); diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD index 4b83d0615af..f3cc14cb848 100644 --- a/test/cpp/end2end/BUILD +++ b/test/cpp/end2end/BUILD @@ -491,8 +491,8 @@ grpc_cc_test( "//:grpc", "//:grpc++", "//:grpc_resolver_fake", - "//src/proto/grpc/lb/v1:load_balancer_proto", - "//src/proto/grpc/lb/v2:xds_for_test_proto", + "//src/proto/grpc/lb/v2:eds_for_test_proto", + "//src/proto/grpc/lb/v2:lrs_for_test_proto", "//src/proto/grpc/testing:echo_messages_proto", "//src/proto/grpc/testing:echo_proto", "//src/proto/grpc/testing/duplicate:echo_duplicate_proto", diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index 5aa20e27a49..d62dc828818 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -38,7 +38,9 @@ #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gprpp/map.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" +#include "src/core/lib/gprpp/sync.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "src/cpp/client/secure_credentials.h" @@ -48,7 +50,8 @@ #include "test/core/util/test_config.h" #include "test/cpp/end2end/test_service_impl.h" -#include "src/proto/grpc/lb/v2/xds_for_test.grpc.pb.h" +#include "src/proto/grpc/lb/v2/eds_for_test.grpc.pb.h" +#include "src/proto/grpc/lb/v2/lrs_for_test.grpc.pb.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" #include @@ -81,6 +84,11 @@ using ::envoy::api::v2::ClusterLoadAssignment; using ::envoy::api::v2::DiscoveryRequest; using ::envoy::api::v2::DiscoveryResponse; using ::envoy::api::v2::EndpointDiscoveryService; +using ::envoy::service::load_stats::v2::ClusterStats; +using ::envoy::service::load_stats::v2::LoadReportingService; +using ::envoy::service::load_stats::v2::LoadStatsRequest; +using ::envoy::service::load_stats::v2::LoadStatsResponse; +using ::envoy::service::load_stats::v2::UpstreamLocalityStats; constexpr char kEdsTypeUrl[] = "type.googleapis.com/envoy.api.v2.ClusterLoadAssignment"; @@ -92,32 +100,32 @@ template class CountedService : public ServiceType { public: size_t request_count() { - grpc::internal::MutexLock lock(&mu_); + grpc_core::MutexLock lock(&mu_); return request_count_; } size_t response_count() { - grpc::internal::MutexLock lock(&mu_); + grpc_core::MutexLock lock(&mu_); return response_count_; } void IncreaseResponseCount() { - grpc::internal::MutexLock lock(&mu_); + grpc_core::MutexLock lock(&mu_); ++response_count_; } void IncreaseRequestCount() { - grpc::internal::MutexLock lock(&mu_); + grpc_core::MutexLock lock(&mu_); ++request_count_; } void ResetCounters() { - grpc::internal::MutexLock lock(&mu_); + grpc_core::MutexLock lock(&mu_); request_count_ = 0; response_count_ = 0; } protected: - grpc::internal::Mutex mu_; + grpc_core::Mutex mu_; private: size_t request_count_ = 0; @@ -125,7 +133,8 @@ class CountedService : public ServiceType { }; using BackendService = CountedService; -using BalancerService = CountedService; +using EdsService = CountedService; +using LrsService = CountedService; const char g_kCallCredsMdKey[] = "Balancer should not ..."; const char g_kCallCredsMdValue[] = "... receive me"; @@ -150,130 +159,169 @@ class BackendServiceImpl : public BackendService { return status; } + void Start() {} void Shutdown() {} std::set clients() { - grpc::internal::MutexLock lock(&clients_mu_); + grpc_core::MutexLock lock(&clients_mu_); return clients_; } private: void AddClient(const grpc::string& client) { - grpc::internal::MutexLock lock(&clients_mu_); + grpc_core::MutexLock lock(&clients_mu_); clients_.insert(client); } - grpc::internal::Mutex mu_; - grpc::internal::Mutex clients_mu_; + grpc_core::Mutex mu_; + grpc_core::Mutex clients_mu_; std::set clients_; }; -struct ClientStats { - size_t num_calls_started = 0; - size_t num_calls_finished = 0; - size_t num_calls_finished_with_client_failed_to_send = 0; - size_t num_calls_finished_known_received = 0; - std::map drop_token_counts; +class ClientStats { + public: + struct LocalityStats { + // Converts from proto message class. + LocalityStats(const UpstreamLocalityStats& upstream_locality_stats) + : total_successful_requests( + upstream_locality_stats.total_successful_requests()), + total_requests_in_progress( + upstream_locality_stats.total_requests_in_progress()), + total_error_requests(upstream_locality_stats.total_error_requests()), + total_issued_requests( + upstream_locality_stats.total_issued_requests()) {} - ClientStats& operator+=(const ClientStats& other) { - num_calls_started += other.num_calls_started; - num_calls_finished += other.num_calls_finished; - num_calls_finished_with_client_failed_to_send += - other.num_calls_finished_with_client_failed_to_send; - num_calls_finished_known_received += - other.num_calls_finished_known_received; - for (const auto& p : other.drop_token_counts) { - drop_token_counts[p.first] += p.second; + uint64_t total_successful_requests; + uint64_t total_requests_in_progress; + uint64_t total_error_requests; + uint64_t total_issued_requests; + }; + + // Converts from proto message class. + ClientStats(const ClusterStats& cluster_stats) + : total_dropped_requests_(cluster_stats.total_dropped_requests()) { + for (const auto& input_locality_stats : + cluster_stats.upstream_locality_stats()) { + locality_stats_.emplace(input_locality_stats.locality().sub_zone(), + LocalityStats(input_locality_stats)); } - return *this; } - void Reset() { - num_calls_started = 0; - num_calls_finished = 0; - num_calls_finished_with_client_failed_to_send = 0; - num_calls_finished_known_received = 0; - drop_token_counts.clear(); + uint64_t total_successful_requests() const { + uint64_t sum = 0; + for (auto& p : locality_stats_) { + sum += p.second.total_successful_requests; + } + return sum; } + uint64_t total_requests_in_progress() const { + uint64_t sum = 0; + for (auto& p : locality_stats_) { + sum += p.second.total_requests_in_progress; + } + return sum; + } + uint64_t total_error_requests() const { + uint64_t sum = 0; + for (auto& p : locality_stats_) { + sum += p.second.total_error_requests; + } + return sum; + } + uint64_t total_issued_requests() const { + uint64_t sum = 0; + for (auto& p : locality_stats_) { + sum += p.second.total_issued_requests; + } + return sum; + } + uint64_t total_dropped_requests() const { return total_dropped_requests_; } + + private: + std::map locality_stats_; + uint64_t total_dropped_requests_; }; -class BalancerServiceImpl : public BalancerService { +class EdsServiceImpl : public EdsService { public: using Stream = ServerReaderWriter; using ResponseDelayPair = std::pair; - explicit BalancerServiceImpl(int client_load_reporting_interval_seconds) - : client_load_reporting_interval_seconds_( - client_load_reporting_interval_seconds) {} - Status StreamEndpoints(ServerContext* context, Stream* stream) override { - // TODO(juanlishen): Clean up the scoping. - gpr_log(GPR_INFO, "LB[%p]: EDS starts", this); - { - grpc::internal::MutexLock lock(&mu_); - if (serverlist_done_) goto done; - } - { + gpr_log(GPR_INFO, "LB[%p]: EDS StreamEndpoints starts", this); + [&]() { + { + grpc_core::MutexLock lock(&eds_mu_); + if (eds_done_) return; + } // Balancer shouldn't receive the call credentials metadata. EXPECT_EQ(context->client_metadata().find(g_kCallCredsMdKey), context->client_metadata().end()); + // Read request. DiscoveryRequest request; - std::vector responses_and_delays; - if (!stream->Read(&request)) goto done; + if (!stream->Read(&request)) return; IncreaseRequestCount(); gpr_log(GPR_INFO, "LB[%p]: received initial message '%s'", this, request.DebugString().c_str()); + // Send response. + std::vector responses_and_delays; { - grpc::internal::MutexLock lock(&mu_); + grpc_core::MutexLock lock(&eds_mu_); responses_and_delays = responses_and_delays_; } for (const auto& response_and_delay : responses_and_delays) { SendResponse(stream, response_and_delay.first, response_and_delay.second); } - { - grpc::internal::MutexLock lock(&mu_); - serverlist_cond_.WaitUntil(&mu_, [this] { return serverlist_done_; }); - } - if (client_load_reporting_interval_seconds_ > 0) { - // TODO(juanlishen): Use LRS to receive load report. - } - } - done: - gpr_log(GPR_INFO, "LB[%p]: done", this); + // Wait until notified done. + grpc_core::MutexLock lock(&eds_mu_); + eds_cond_.WaitUntil(&eds_mu_, [this] { return eds_done_; }); + }(); + gpr_log(GPR_INFO, "LB[%p]: EDS StreamEndpoints done", this); return Status::OK; } void add_response(const DiscoveryResponse& response, int send_after_ms) { - grpc::internal::MutexLock lock(&mu_); + grpc_core::MutexLock lock(&eds_mu_); responses_and_delays_.push_back(std::make_pair(response, send_after_ms)); } - void Shutdown() { - grpc::internal::MutexLock lock(&mu_); - NotifyDoneWithServerlistsLocked(); + void Start() { + grpc_core::MutexLock lock(&eds_mu_); + eds_done_ = false; responses_and_delays_.clear(); + } + + void Shutdown() { + { + grpc_core::MutexLock lock(&eds_mu_); + NotifyDoneWithEdsCallLocked(); + responses_and_delays_.clear(); + } gpr_log(GPR_INFO, "LB[%p]: shut down", this); } static DiscoveryResponse BuildResponseForBackends( - const std::vector& backend_ports, - const std::map& drop_token_counts) { + const std::vector>& backend_ports) { ClusterLoadAssignment assignment; assignment.set_cluster_name("service name"); - auto* endpoints = assignment.add_endpoints(); - endpoints->mutable_load_balancing_weight()->set_value(3); - endpoints->set_priority(0); - endpoints->mutable_locality()->set_region(kDefaultLocalityRegion); - endpoints->mutable_locality()->set_zone(kDefaultLocalityZone); - endpoints->mutable_locality()->set_sub_zone(kDefaultLocalitySubzone); - for (const int& backend_port : backend_ports) { - auto* lb_endpoints = endpoints->add_lb_endpoints(); - auto* endpoint = lb_endpoints->mutable_endpoint(); - auto* address = endpoint->mutable_address(); - auto* socket_address = address->mutable_socket_address(); - socket_address->set_address("127.0.0.1"); - socket_address->set_port_value(backend_port); + for (size_t i = 0; i < backend_ports.size(); ++i) { + auto* endpoints = assignment.add_endpoints(); + endpoints->mutable_load_balancing_weight()->set_value(3); + endpoints->set_priority(0); + endpoints->mutable_locality()->set_region(kDefaultLocalityRegion); + endpoints->mutable_locality()->set_zone(kDefaultLocalityZone); + std::ostringstream sub_zone; + sub_zone << kDefaultLocalitySubzone << '_' << i; + endpoints->mutable_locality()->set_sub_zone(sub_zone.str()); + for (const int& backend_port : backend_ports[i]) { + auto* lb_endpoints = endpoints->add_lb_endpoints(); + auto* endpoint = lb_endpoints->mutable_endpoint(); + auto* address = endpoint->mutable_address(); + auto* socket_address = address->mutable_socket_address(); + socket_address->set_address("127.0.0.1"); + socket_address->set_port_value(backend_port); + } } DiscoveryResponse response; response.set_type_url(kEdsTypeUrl); @@ -281,15 +329,15 @@ class BalancerServiceImpl : public BalancerService { return response; } - void NotifyDoneWithServerlists() { - grpc::internal::MutexLock lock(&mu_); - NotifyDoneWithServerlistsLocked(); + void NotifyDoneWithEdsCall() { + grpc_core::MutexLock lock(&eds_mu_); + NotifyDoneWithEdsCallLocked(); } - void NotifyDoneWithServerlistsLocked() { - if (!serverlist_done_) { - serverlist_done_ = true; - serverlist_cond_.Broadcast(); + void NotifyDoneWithEdsCallLocked() { + if (!eds_done_) { + eds_done_ = true; + eds_cond_.Broadcast(); } } @@ -306,11 +354,108 @@ class BalancerServiceImpl : public BalancerService { stream->Write(response); } - const int client_load_reporting_interval_seconds_; + grpc_core::CondVar eds_cond_; + // Protect the members below. + grpc_core::Mutex eds_mu_; + bool eds_done_ = false; std::vector responses_and_delays_; - grpc::internal::Mutex mu_; - grpc::internal::CondVar serverlist_cond_; - bool serverlist_done_ = false; +}; + +class LrsServiceImpl : public LrsService { + public: + using Stream = ServerReaderWriter; + + explicit LrsServiceImpl(int client_load_reporting_interval_seconds) + : client_load_reporting_interval_seconds_( + client_load_reporting_interval_seconds) {} + + Status StreamLoadStats(ServerContext* context, Stream* stream) override { + gpr_log(GPR_INFO, "LB[%p]: LRS StreamLoadStats starts", this); + // Read request. + LoadStatsRequest request; + if (stream->Read(&request)) { + if (client_load_reporting_interval_seconds_ > 0) { + IncreaseRequestCount(); + // Send response. + LoadStatsResponse response; + auto server_name = request.cluster_stats()[0].cluster_name(); + GPR_ASSERT(server_name != ""); + response.add_clusters(server_name); + response.mutable_load_reporting_interval()->set_seconds( + client_load_reporting_interval_seconds_); + stream->Write(response); + IncreaseResponseCount(); + // Wait for report. + request.Clear(); + if (stream->Read(&request)) { + gpr_log(GPR_INFO, "LB[%p]: received client load report message '%s'", + this, request.DebugString().c_str()); + GPR_ASSERT(request.cluster_stats().size() == 1); + const ClusterStats& cluster_stats = request.cluster_stats()[0]; + // We need to acquire the lock here in order to prevent the notify_one + // below from firing before its corresponding wait is executed. + grpc_core::MutexLock lock(&load_report_mu_); + GPR_ASSERT(client_stats_ == nullptr); + client_stats_.reset(new ClientStats(cluster_stats)); + load_report_ready_ = true; + load_report_cond_.Signal(); + } + } + // Wait until notified done. + grpc_core::MutexLock lock(&lrs_mu_); + lrs_cv_.WaitUntil(&lrs_mu_, [this] { return lrs_done; }); + } + gpr_log(GPR_INFO, "LB[%p]: LRS done", this); + return Status::OK; + } + + void Start() { + lrs_done = false; + load_report_ready_ = false; + client_stats_.reset(); + } + + void Shutdown() { + { + grpc_core::MutexLock lock(&lrs_mu_); + NotifyDoneWithLrsCallLocked(); + } + gpr_log(GPR_INFO, "LB[%p]: shut down", this); + } + + ClientStats* WaitForLoadReport() { + grpc_core::MutexLock lock(&load_report_mu_); + load_report_cond_.WaitUntil(&load_report_mu_, + [this] { return load_report_ready_; }); + load_report_ready_ = false; + return client_stats_.get(); + } + + void NotifyDoneWithLrsCall() { + grpc_core::MutexLock lock(&lrs_mu_); + NotifyDoneWithLrsCallLocked(); + } + + void NotifyDoneWithLrsCallLocked() { + if (!lrs_done) { + lrs_done = true; + lrs_cv_.Broadcast(); + } + } + + private: + const int client_load_reporting_interval_seconds_; + + grpc_core::CondVar lrs_cv_; + // Protect lrs_done. + grpc_core::Mutex lrs_mu_; + bool lrs_done = false; + + grpc_core::CondVar load_report_cond_; + // Protect the members below. + grpc_core::Mutex load_report_mu_; + std::unique_ptr client_stats_; + bool load_report_ready_ = false; }; class XdsEnd2endTest : public ::testing::Test { @@ -339,13 +484,13 @@ class XdsEnd2endTest : public ::testing::Test { grpc_core::MakeRefCounted(); // Start the backends. for (size_t i = 0; i < num_backends_; ++i) { - backends_.emplace_back(new ServerThread("backend")); + backends_.emplace_back(new BackendServerThread); backends_.back()->Start(server_host_); } // Start the load balancers. for (size_t i = 0; i < num_balancers_; ++i) { - balancers_.emplace_back(new ServerThread( - "balancer", client_load_reporting_interval_seconds_)); + balancers_.emplace_back( + new BalancerServerThread(client_load_reporting_interval_seconds_)); balancers_.back()->Start(server_host_); } ResetStub(); @@ -398,19 +543,13 @@ class XdsEnd2endTest : public ::testing::Test { } void ResetBackendCounters() { - for (auto& backend : backends_) backend->service_.ResetCounters(); - } - - ClientStats WaitForLoadReports() { - ClientStats client_stats; - // TODO(juanlishen): Wait in LRS. - return client_stats; + for (auto& backend : backends_) backend->backend_service()->ResetCounters(); } bool SeenAllBackends(size_t start_index = 0, size_t stop_index = 0) { if (stop_index == 0) stop_index = backends_.size(); for (size_t i = start_index; i < stop_index; ++i) { - if (backends_[i]->service_.request_count() == 0) return false; + if (backends_[i]->backend_service()->request_count() == 0) return false; } return true; } @@ -455,7 +594,7 @@ class XdsEnd2endTest : public ::testing::Test { void WaitForBackend(size_t backend_idx) { do { (void)SendRpc(); - } while (backends_[backend_idx]->service_.request_count() == 0); + } while (backends_[backend_idx]->backend_service()->request_count() == 0); ResetBackendCounters(); } @@ -506,7 +645,7 @@ class XdsEnd2endTest : public ::testing::Test { nullptr) { std::vector ports; for (size_t i = 0; i < balancers_.size(); ++i) { - ports.emplace_back(balancers_[i]->port_); + ports.emplace_back(balancers_[i]->port()); } SetNextResolutionForLbChannel(ports, service_config_json, lb_channel_response_generator); @@ -543,14 +682,32 @@ class XdsEnd2endTest : public ::testing::Test { if (stop_index == 0) stop_index = backends_.size(); std::vector backend_ports; for (size_t i = start_index; i < stop_index; ++i) { - backend_ports.push_back(backends_[i]->port_); + backend_ports.push_back(backends_[i]->port()); + } + return backend_ports; + } + + const std::vector> GetBackendPortsInGroups( + size_t start_index = 0, size_t stop_index = 0, + size_t num_group = 1) const { + if (stop_index == 0) stop_index = backends_.size(); + size_t group_size = (stop_index - start_index) / num_group; + std::vector> backend_ports; + for (size_t i = 0; i < num_group; ++i) { + backend_ports.emplace_back(); + size_t group_start = group_size * i + start_index; + size_t group_stop = + i == num_group - 1 ? stop_index : group_start + group_size; + for (size_t j = group_start; j < group_stop; ++j) { + backend_ports[i].push_back(backends_[j]->port()); + } } return backend_ports; } void ScheduleResponseForBalancer(size_t i, const DiscoveryResponse& response, int delay_ms) { - balancers_[i]->service_.add_response(response, delay_ms); + balancers_[i]->eds_service()->add_response(response, delay_ms); } Status SendRpc(EchoResponse* response = nullptr, int timeout_ms = 1000, @@ -583,71 +740,124 @@ class XdsEnd2endTest : public ::testing::Test { EXPECT_FALSE(status.ok()); } - template - struct ServerThread { - template - explicit ServerThread(const grpc::string& type, Args&&... args) - : port_(grpc_pick_unused_port_or_die()), - type_(type), - service_(std::forward(args)...) {} + class ServerThread { + public: + ServerThread() : port_(grpc_pick_unused_port_or_die()) {} + virtual ~ServerThread(){}; void Start(const grpc::string& server_host) { - gpr_log(GPR_INFO, "starting %s server on port %d", type_.c_str(), port_); + gpr_log(GPR_INFO, "starting %s server on port %d", Type(), port_); GPR_ASSERT(!running_); running_ = true; - grpc::internal::Mutex mu; + StartAllServices(); + grpc_core::Mutex mu; // We need to acquire the lock here in order to prevent the notify_one // by ServerThread::Serve from firing before the wait below is hit. - grpc::internal::MutexLock lock(&mu); - grpc::internal::CondVar cond; + grpc_core::MutexLock lock(&mu); + grpc_core::CondVar cond; thread_.reset(new std::thread( std::bind(&ServerThread::Serve, this, server_host, &mu, &cond))); cond.Wait(&mu); - gpr_log(GPR_INFO, "%s server startup complete", type_.c_str()); + gpr_log(GPR_INFO, "%s server startup complete", Type()); } - void Serve(const grpc::string& server_host, grpc::internal::Mutex* mu, - grpc::internal::CondVar* cond) { + void Serve(const grpc::string& server_host, grpc_core::Mutex* mu, + grpc_core::CondVar* cond) { // We need to acquire the lock here in order to prevent the notify_one // below from firing before its corresponding wait is executed. - grpc::internal::MutexLock lock(mu); + grpc_core::MutexLock lock(mu); std::ostringstream server_address; server_address << server_host << ":" << port_; ServerBuilder builder; std::shared_ptr creds(new SecureServerCredentials( grpc_fake_transport_security_server_credentials_create())); builder.AddListeningPort(server_address.str(), creds); - builder.RegisterService(&service_); + RegisterAllServices(&builder); server_ = builder.BuildAndStart(); cond->Signal(); } void Shutdown() { if (!running_) return; - gpr_log(GPR_INFO, "%s about to shutdown", type_.c_str()); - service_.Shutdown(); + gpr_log(GPR_INFO, "%s about to shutdown", Type()); + ShutdownAllServices(); server_->Shutdown(grpc_timeout_milliseconds_to_deadline(0)); thread_->join(); - gpr_log(GPR_INFO, "%s shutdown completed", type_.c_str()); + gpr_log(GPR_INFO, "%s shutdown completed", Type()); running_ = false; } + int port() const { return port_; } + + private: + virtual void RegisterAllServices(ServerBuilder* builder) = 0; + virtual void StartAllServices() = 0; + virtual void ShutdownAllServices() = 0; + + virtual const char* Type() = 0; + const int port_; - grpc::string type_; - T service_; std::unique_ptr server_; std::unique_ptr thread_; bool running_ = false; }; + class BackendServerThread : public ServerThread { + public: + BackendServiceImpl* backend_service() { return &backend_service_; } + + private: + void RegisterAllServices(ServerBuilder* builder) override { + builder->RegisterService(&backend_service_); + } + + void StartAllServices() override { backend_service_.Start(); } + + void ShutdownAllServices() override { backend_service_.Shutdown(); } + + const char* Type() override { return "Backend"; } + + BackendServiceImpl backend_service_; + }; + + class BalancerServerThread : public ServerThread { + public: + explicit BalancerServerThread(int client_load_reporting_interval = 0) + : lrs_service_(client_load_reporting_interval) {} + + EdsServiceImpl* eds_service() { return &eds_service_; } + LrsServiceImpl* lrs_service() { return &lrs_service_; } + + private: + void RegisterAllServices(ServerBuilder* builder) override { + builder->RegisterService(&eds_service_); + builder->RegisterService(&lrs_service_); + } + + void StartAllServices() override { + eds_service_.Start(); + lrs_service_.Start(); + } + + void ShutdownAllServices() override { + eds_service_.Shutdown(); + lrs_service_.Shutdown(); + } + + const char* Type() override { return "Balancer"; } + + EdsServiceImpl eds_service_; + LrsServiceImpl lrs_service_; + }; + const grpc::string server_host_; const size_t num_backends_; const size_t num_balancers_; const int client_load_reporting_interval_seconds_; std::shared_ptr channel_; std::unique_ptr stub_; - std::vector>> backends_; - std::vector>> balancers_; + std::vector> backends_; + std::vector> balancers_; grpc_core::RefCountedPtr response_generator_; grpc_core::RefCountedPtr @@ -673,7 +883,7 @@ TEST_F(SingleBalancerTest, Vanilla) { SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcsPerAddress = 100; ScheduleResponseForBalancer( - 0, BalancerServiceImpl::BuildResponseForBackends(GetBackendPorts(), {}), + 0, EdsServiceImpl::BuildResponseForBackends(GetBackendPortsInGroups()), 0); // Make sure that trying to connect works without a call. channel_->GetState(true /* try_to_connect */); @@ -683,14 +893,13 @@ TEST_F(SingleBalancerTest, Vanilla) { CheckRpcSendOk(kNumRpcsPerAddress * num_backends_); // Each backend should have gotten 100 requests. for (size_t i = 0; i < backends_.size(); ++i) { - EXPECT_EQ(kNumRpcsPerAddress, backends_[i]->service_.request_count()); + EXPECT_EQ(kNumRpcsPerAddress, + backends_[i]->backend_service()->request_count()); } - balancers_[0]->service_.NotifyDoneWithServerlists(); - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - + balancers_[0]->eds_service()->NotifyDoneWithEdsCall(); + // The EDS service got a single request, and sent a single response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); // Check LB policy name for the channel. EXPECT_EQ("xds_experimental", channel_->GetLoadBalancingPolicyName()); } @@ -700,31 +909,32 @@ TEST_F(SingleBalancerTest, SameBackendListedMultipleTimes) { SetNextResolutionForLbChannelAllBalancers(); // Same backend listed twice. std::vector ports; - ports.push_back(backends_[0]->port_); - ports.push_back(backends_[0]->port_); + ports.push_back(backends_[0]->port()); + ports.push_back(backends_[0]->port()); const size_t kNumRpcsPerAddress = 10; ScheduleResponseForBalancer( - 0, BalancerServiceImpl::BuildResponseForBackends(ports, {}), 0); + 0, EdsServiceImpl::BuildResponseForBackends({ports}), 0); // We need to wait for the backend to come online. WaitForBackend(0); // Send kNumRpcsPerAddress RPCs per server. CheckRpcSendOk(kNumRpcsPerAddress * ports.size()); // Backend should have gotten 20 requests. - EXPECT_EQ(kNumRpcsPerAddress * 2, backends_[0]->service_.request_count()); + EXPECT_EQ(kNumRpcsPerAddress * 2, + backends_[0]->backend_service()->request_count()); // And they should have come from a single client port, because of // subchannel sharing. - EXPECT_EQ(1UL, backends_[0]->service_.clients().size()); - balancers_[0]->service_.NotifyDoneWithServerlists(); + EXPECT_EQ(1UL, backends_[0]->backend_service()->clients().size()); + balancers_[0]->eds_service()->NotifyDoneWithEdsCall(); } TEST_F(SingleBalancerTest, SecureNaming) { // TODO(juanlishen): Use separate fake creds for the balancer channel. ResetStub(0, kApplicationTargetName_ + ";lb"); SetNextResolution({}, kDefaultServiceConfig_.c_str()); - SetNextResolutionForLbChannel({balancers_[0]->port_}); + SetNextResolutionForLbChannel({balancers_[0]->port()}); const size_t kNumRpcsPerAddress = 100; ScheduleResponseForBalancer( - 0, BalancerServiceImpl::BuildResponseForBackends(GetBackendPorts(), {}), + 0, EdsServiceImpl::BuildResponseForBackends(GetBackendPortsInGroups()), 0); // Make sure that trying to connect works without a call. channel_->GetState(true /* try_to_connect */); @@ -735,12 +945,12 @@ TEST_F(SingleBalancerTest, SecureNaming) { // Each backend should have gotten 100 requests. for (size_t i = 0; i < backends_.size(); ++i) { - EXPECT_EQ(kNumRpcsPerAddress, backends_[i]->service_.request_count()); + EXPECT_EQ(kNumRpcsPerAddress, + backends_[i]->backend_service()->request_count()); } - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); + // The EDS service got a single request, and sent a single response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } TEST_F(SingleBalancerTest, SecureNamingDeathTest) { @@ -758,7 +968,7 @@ TEST_F(SingleBalancerTest, SecureNamingDeathTest) { "\"fake:///wrong_lb\" } }\n" " ]\n" "}"); - SetNextResolutionForLbChannel({balancers_[0]->port_}); + SetNextResolutionForLbChannel({balancers_[0]->port()}); channel_->WaitForConnected(grpc_timeout_seconds_to_deadline(1)); }, ""); @@ -770,11 +980,11 @@ TEST_F(SingleBalancerTest, InitiallyEmptyServerlist) { const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor(); const int kCallDeadlineMs = kServerlistDelayMs * 2; // First response is an empty serverlist, sent right away. - ScheduleResponseForBalancer( - 0, BalancerServiceImpl::BuildResponseForBackends({}, {}), 0); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponseForBackends({{}}), + 0); // Send non-empty serverlist only after kServerlistDelayMs ScheduleResponseForBalancer( - 0, BalancerServiceImpl::BuildResponseForBackends(GetBackendPorts(), {}), + 0, EdsServiceImpl::BuildResponseForBackends(GetBackendPortsInGroups()), kServerlistDelayMs); const auto t0 = system_clock::now(); // Client will block: LB will initially send empty serverlist. @@ -787,11 +997,11 @@ TEST_F(SingleBalancerTest, InitiallyEmptyServerlist) { // populated serverlist but under the call's deadline (which is enforced by // the call's deadline). EXPECT_GT(ellapsed_ms.count(), kServerlistDelayMs); - balancers_[0]->service_.NotifyDoneWithServerlists(); - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); + balancers_[0]->eds_service()->NotifyDoneWithEdsCall(); + // The EDS service got a single request. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); // and sent two responses. - EXPECT_EQ(2U, balancers_[0]->service_.response_count()); + EXPECT_EQ(2U, balancers_[0]->eds_service()->response_count()); } TEST_F(SingleBalancerTest, AllServersUnreachableFailFast) { @@ -803,15 +1013,14 @@ TEST_F(SingleBalancerTest, AllServersUnreachableFailFast) { ports.push_back(grpc_pick_unused_port_or_die()); } ScheduleResponseForBalancer( - 0, BalancerServiceImpl::BuildResponseForBackends(ports, {}), 0); + 0, EdsServiceImpl::BuildResponseForBackends({ports}), 0); const Status status = SendRpc(); // The error shouldn't be DEADLINE_EXCEEDED. EXPECT_EQ(StatusCode::UNAVAILABLE, status.error_code()); - balancers_[0]->service_.NotifyDoneWithServerlists(); - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); + balancers_[0]->eds_service()->NotifyDoneWithEdsCall(); + // The EDS service got a single request, and sent a single response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } TEST_F(SingleBalancerTest, Fallback) { @@ -825,8 +1034,8 @@ TEST_F(SingleBalancerTest, Fallback) { // Send non-empty serverlist only after kServerlistDelayMs. ScheduleResponseForBalancer( 0, - BalancerServiceImpl::BuildResponseForBackends( - GetBackendPorts(kNumBackendsInResolution /* start_index */), {}), + EdsServiceImpl::BuildResponseForBackends( + GetBackendPortsInGroups(kNumBackendsInResolution /* start_index */)), kServerlistDelayMs); // Wait until all the fallback backends are reachable. WaitForAllBackends(1 /* num_requests_multiple_of */, 0 /* start_index */, @@ -837,10 +1046,10 @@ TEST_F(SingleBalancerTest, Fallback) { // Fallback is used: each backend returned by the resolver should have // gotten one request. for (size_t i = 0; i < kNumBackendsInResolution; ++i) { - EXPECT_EQ(1U, backends_[i]->service_.request_count()); + EXPECT_EQ(1U, backends_[i]->backend_service()->request_count()); } for (size_t i = kNumBackendsInResolution; i < backends_.size(); ++i) { - EXPECT_EQ(0U, backends_[i]->service_.request_count()); + EXPECT_EQ(0U, backends_[i]->backend_service()->request_count()); } // Wait until the serverlist reception has been processed and all backends // in the serverlist are reachable. @@ -852,15 +1061,14 @@ TEST_F(SingleBalancerTest, Fallback) { // Serverlist is used: each backend returned by the balancer should // have gotten one request. for (size_t i = 0; i < kNumBackendsInResolution; ++i) { - EXPECT_EQ(0U, backends_[i]->service_.request_count()); + EXPECT_EQ(0U, backends_[i]->backend_service()->request_count()); } for (size_t i = kNumBackendsInResolution; i < backends_.size(); ++i) { - EXPECT_EQ(1U, backends_[i]->service_.request_count()); + EXPECT_EQ(1U, backends_[i]->backend_service()->request_count()); } - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); + // The EDS service got a single request, and sent a single response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } TEST_F(SingleBalancerTest, FallbackUpdate) { @@ -875,10 +1083,9 @@ TEST_F(SingleBalancerTest, FallbackUpdate) { // Send non-empty serverlist only after kServerlistDelayMs. ScheduleResponseForBalancer( 0, - BalancerServiceImpl::BuildResponseForBackends( - GetBackendPorts(kNumBackendsInResolution + - kNumBackendsInResolutionUpdate /* start_index */), - {}), + EdsServiceImpl::BuildResponseForBackends(GetBackendPortsInGroups( + kNumBackendsInResolution + + kNumBackendsInResolutionUpdate /* start_index */)), kServerlistDelayMs); // Wait until all the fallback backends are reachable. WaitForAllBackends(1 /* num_requests_multiple_of */, 0 /* start_index */, @@ -889,10 +1096,10 @@ TEST_F(SingleBalancerTest, FallbackUpdate) { // Fallback is used: each backend returned by the resolver should have // gotten one request. for (size_t i = 0; i < kNumBackendsInResolution; ++i) { - EXPECT_EQ(1U, backends_[i]->service_.request_count()); + EXPECT_EQ(1U, backends_[i]->backend_service()->request_count()); } for (size_t i = kNumBackendsInResolution; i < backends_.size(); ++i) { - EXPECT_EQ(0U, backends_[i]->service_.request_count()); + EXPECT_EQ(0U, backends_[i]->backend_service()->request_count()); } SetNextResolution(GetBackendPorts(kNumBackendsInResolution, kNumBackendsInResolution + @@ -910,15 +1117,15 @@ TEST_F(SingleBalancerTest, FallbackUpdate) { // The resolution update is used: each backend in the resolution update should // have gotten one request. for (size_t i = 0; i < kNumBackendsInResolution; ++i) { - EXPECT_EQ(0U, backends_[i]->service_.request_count()); + EXPECT_EQ(0U, backends_[i]->backend_service()->request_count()); } for (size_t i = kNumBackendsInResolution; i < kNumBackendsInResolution + kNumBackendsInResolutionUpdate; ++i) { - EXPECT_EQ(1U, backends_[i]->service_.request_count()); + EXPECT_EQ(1U, backends_[i]->backend_service()->request_count()); } for (size_t i = kNumBackendsInResolution + kNumBackendsInResolutionUpdate; i < backends_.size(); ++i) { - EXPECT_EQ(0U, backends_[i]->service_.request_count()); + EXPECT_EQ(0U, backends_[i]->backend_service()->request_count()); } // Wait until the serverlist reception has been processed and all backends // in the serverlist are reachable. @@ -933,23 +1140,22 @@ TEST_F(SingleBalancerTest, FallbackUpdate) { // have gotten one request. for (size_t i = 0; i < kNumBackendsInResolution + kNumBackendsInResolutionUpdate; ++i) { - EXPECT_EQ(0U, backends_[i]->service_.request_count()); + EXPECT_EQ(0U, backends_[i]->backend_service()->request_count()); } for (size_t i = kNumBackendsInResolution + kNumBackendsInResolutionUpdate; i < backends_.size(); ++i) { - EXPECT_EQ(1U, backends_[i]->service_.request_count()); + EXPECT_EQ(1U, backends_[i]->backend_service()->request_count()); } - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); + // The EDS service got a single request, and sent a single response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } TEST_F(SingleBalancerTest, FallbackEarlyWhenBalancerChannelFails) { const int kFallbackTimeoutMs = 10000 * grpc_test_slowdown_factor(); ResetStub(kFallbackTimeoutMs); // Return an unreachable balancer and one fallback backend. - SetNextResolution({backends_[0]->port_}, kDefaultServiceConfig_.c_str()); + SetNextResolution({backends_[0]->port()}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannel({grpc_pick_unused_port_or_die()}); // Send RPC with deadline less than the fallback timeout and make sure it // succeeds. @@ -961,10 +1167,10 @@ TEST_F(SingleBalancerTest, FallbackEarlyWhenBalancerCallFails) { const int kFallbackTimeoutMs = 10000 * grpc_test_slowdown_factor(); ResetStub(kFallbackTimeoutMs); // Return one balancer and one fallback backend. - SetNextResolution({backends_[0]->port_}, kDefaultServiceConfig_.c_str()); + SetNextResolution({backends_[0]->port()}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); // Balancer drops call without sending a serverlist. - balancers_[0]->service_.NotifyDoneWithServerlists(); + balancers_[0]->eds_service()->NotifyDoneWithEdsCall(); // Send RPC with deadline less than the fallback timeout and make sure it // succeeds. CheckRpcSendOk(/* times */ 1, /* timeout_ms */ 1000, @@ -974,13 +1180,13 @@ TEST_F(SingleBalancerTest, FallbackEarlyWhenBalancerCallFails) { TEST_F(SingleBalancerTest, FallbackIfResponseReceivedButChildNotReady) { const int kFallbackTimeoutMs = 500 * grpc_test_slowdown_factor(); ResetStub(kFallbackTimeoutMs); - SetNextResolution({backends_[0]->port_}, kDefaultServiceConfig_.c_str()); + SetNextResolution({backends_[0]->port()}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); // Send a serverlist that only contains an unreachable backend before fallback // timeout. ScheduleResponseForBalancer(0, - BalancerServiceImpl::BuildResponseForBackends( - {grpc_pick_unused_port_or_die()}, {}), + EdsServiceImpl::BuildResponseForBackends( + {{grpc_pick_unused_port_or_die()}}), 0); // Because no child policy is ready before fallback timeout, we enter fallback // mode. @@ -989,13 +1195,13 @@ TEST_F(SingleBalancerTest, FallbackIfResponseReceivedButChildNotReady) { TEST_F(SingleBalancerTest, FallbackModeIsExitedWhenBalancerSaysToDropAllCalls) { // Return an unreachable balancer and one fallback backend. - SetNextResolution({backends_[0]->port_}, kDefaultServiceConfig_.c_str()); + SetNextResolution({backends_[0]->port()}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannel({grpc_pick_unused_port_or_die()}); // Enter fallback mode because the LB channel fails to connect. WaitForBackend(0); // Return a new balancer that sends an empty serverlist. - ScheduleResponseForBalancer( - 0, BalancerServiceImpl::BuildResponseForBackends({}, {}), 0); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponseForBackends({{}}), + 0); SetNextResolutionForLbChannelAllBalancers(); // Send RPCs until failure. gpr_timespec deadline = gpr_time_add( @@ -1009,16 +1215,14 @@ TEST_F(SingleBalancerTest, FallbackModeIsExitedWhenBalancerSaysToDropAllCalls) { TEST_F(SingleBalancerTest, FallbackModeIsExitedAfterChildRready) { // Return an unreachable balancer and one fallback backend. - SetNextResolution({backends_[0]->port_}, kDefaultServiceConfig_.c_str()); + SetNextResolution({backends_[0]->port()}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannel({grpc_pick_unused_port_or_die()}); // Enter fallback mode because the LB channel fails to connect. WaitForBackend(0); // Return a new balancer that sends a dead backend. ShutdownBackend(1); ScheduleResponseForBalancer( - 0, - BalancerServiceImpl::BuildResponseForBackends({backends_[1]->port_}, {}), - 0); + 0, EdsServiceImpl::BuildResponseForBackends({{backends_[1]->port()}}), 0); SetNextResolutionForLbChannelAllBalancers(); // The state (TRANSIENT_FAILURE) update from the child policy will be ignored // because we are still in fallback mode. @@ -1035,15 +1239,15 @@ TEST_F(SingleBalancerTest, FallbackModeIsExitedAfterChildRready) { // We have exited fallback mode, so calls will go to the child policy // exclusively. CheckRpcSendOk(100); - EXPECT_EQ(0U, backends_[0]->service_.request_count()); - EXPECT_EQ(100U, backends_[1]->service_.request_count()); + EXPECT_EQ(0U, backends_[0]->backend_service()->request_count()); + EXPECT_EQ(100U, backends_[1]->backend_service()->request_count()); } TEST_F(SingleBalancerTest, BackendsRestart) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); ScheduleResponseForBalancer( - 0, BalancerServiceImpl::BuildResponseForBackends(GetBackendPorts(), {}), + 0, EdsServiceImpl::BuildResponseForBackends(GetBackendPortsInGroups()), 0); WaitForAllBackends(); // Stop backends. RPCs should fail. @@ -1063,12 +1267,12 @@ class UpdatesTest : public XdsEnd2endTest { TEST_F(UpdatesTest, UpdateBalancersButKeepUsingOriginalBalancer) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); - const std::vector first_backend{GetBackendPorts()[0]}; - const std::vector second_backend{GetBackendPorts()[1]}; + auto first_backend = GetBackendPortsInGroups(0, 1); + auto second_backend = GetBackendPortsInGroups(1, 2); ScheduleResponseForBalancer( - 0, BalancerServiceImpl::BuildResponseForBackends(first_backend, {}), 0); + 0, EdsServiceImpl::BuildResponseForBackends(first_backend), 0); ScheduleResponseForBalancer( - 1, BalancerServiceImpl::BuildResponseForBackends(second_backend, {}), 0); + 1, EdsServiceImpl::BuildResponseForBackends(second_backend), 0); // Wait until the first backend is ready. WaitForBackend(0); @@ -1079,22 +1283,22 @@ TEST_F(UpdatesTest, UpdateBalancersButKeepUsingOriginalBalancer) { gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); // All 10 requests should have gone to the first backend. - EXPECT_EQ(10U, backends_[0]->service_.request_count()); + EXPECT_EQ(10U, backends_[0]->backend_service()->request_count()); - // Balancer 0 got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - EXPECT_EQ(0U, balancers_[1]->service_.request_count()); - EXPECT_EQ(0U, balancers_[1]->service_.response_count()); - EXPECT_EQ(0U, balancers_[2]->service_.request_count()); - EXPECT_EQ(0U, balancers_[2]->service_.response_count()); + // The EDS service of balancer 0 got a single request, and sent a single + // response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); + EXPECT_EQ(0U, balancers_[1]->eds_service()->request_count()); + EXPECT_EQ(0U, balancers_[1]->eds_service()->response_count()); + EXPECT_EQ(0U, balancers_[2]->eds_service()->request_count()); + EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 1 =========="); - SetNextResolutionForLbChannel({balancers_[1]->port_}); + SetNextResolutionForLbChannel({balancers_[1]->port()}); gpr_log(GPR_INFO, "========= UPDATE 1 DONE =========="); - EXPECT_EQ(0U, backends_[1]->service_.request_count()); + EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); gpr_timespec deadline = gpr_time_add( gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(10000, GPR_TIMESPAN)); // Send 10 seconds worth of RPCs @@ -1103,25 +1307,25 @@ TEST_F(UpdatesTest, UpdateBalancersButKeepUsingOriginalBalancer) { } while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0); // The current LB call is still working, so xds continued using it to the // first balancer, which doesn't assign the second backend. - EXPECT_EQ(0U, backends_[1]->service_.request_count()); + EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - EXPECT_EQ(0U, balancers_[1]->service_.request_count()); - EXPECT_EQ(0U, balancers_[1]->service_.response_count()); - EXPECT_EQ(0U, balancers_[2]->service_.request_count()); - EXPECT_EQ(0U, balancers_[2]->service_.response_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); + EXPECT_EQ(0U, balancers_[1]->eds_service()->request_count()); + EXPECT_EQ(0U, balancers_[1]->eds_service()->response_count()); + EXPECT_EQ(0U, balancers_[2]->eds_service()->request_count()); + EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); } TEST_F(UpdatesTest, UpdateBalancerName) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); - const std::vector first_backend{GetBackendPorts()[0]}; - const std::vector second_backend{GetBackendPorts()[1]}; + auto first_backend = GetBackendPortsInGroups(0, 1); + auto second_backend = GetBackendPortsInGroups(1, 2); ScheduleResponseForBalancer( - 0, BalancerServiceImpl::BuildResponseForBackends(first_backend, {}), 0); + 0, EdsServiceImpl::BuildResponseForBackends(first_backend), 0); ScheduleResponseForBalancer( - 1, BalancerServiceImpl::BuildResponseForBackends(second_backend, {}), 0); + 1, EdsServiceImpl::BuildResponseForBackends(second_backend), 0); // Wait until the first backend is ready. WaitForBackend(0); @@ -1132,19 +1336,19 @@ TEST_F(UpdatesTest, UpdateBalancerName) { gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); // All 10 requests should have gone to the first backend. - EXPECT_EQ(10U, backends_[0]->service_.request_count()); + EXPECT_EQ(10U, backends_[0]->backend_service()->request_count()); - // Balancer 0 got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - EXPECT_EQ(0U, balancers_[1]->service_.request_count()); - EXPECT_EQ(0U, balancers_[1]->service_.response_count()); - EXPECT_EQ(0U, balancers_[2]->service_.request_count()); - EXPECT_EQ(0U, balancers_[2]->service_.response_count()); + // The EDS service of balancer 0 got a single request, and sent a single + // response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); + EXPECT_EQ(0U, balancers_[1]->eds_service()->request_count()); + EXPECT_EQ(0U, balancers_[1]->eds_service()->response_count()); + EXPECT_EQ(0U, balancers_[2]->eds_service()->request_count()); + EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); std::vector ports; - ports.emplace_back(balancers_[1]->port_); + ports.emplace_back(balancers_[1]->port()); auto new_lb_channel_response_generator = grpc_core::MakeRefCounted(); SetNextResolutionForLbChannel(ports, nullptr, @@ -1163,22 +1367,22 @@ TEST_F(UpdatesTest, UpdateBalancerName) { // Wait until update has been processed, as signaled by the second backend // receiving a request. - EXPECT_EQ(0U, backends_[1]->service_.request_count()); + EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); WaitForBackend(1); - backends_[1]->service_.ResetCounters(); + backends_[1]->backend_service()->ResetCounters(); gpr_log(GPR_INFO, "========= BEFORE SECOND BATCH =========="); CheckRpcSendOk(10); gpr_log(GPR_INFO, "========= DONE WITH SECOND BATCH =========="); // All 10 requests should have gone to the second backend. - EXPECT_EQ(10U, backends_[1]->service_.request_count()); + EXPECT_EQ(10U, backends_[1]->backend_service()->request_count()); - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - EXPECT_EQ(1U, balancers_[1]->service_.request_count()); - EXPECT_EQ(1U, balancers_[1]->service_.response_count()); - EXPECT_EQ(0U, balancers_[2]->service_.request_count()); - EXPECT_EQ(0U, balancers_[2]->service_.response_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); + EXPECT_EQ(1U, balancers_[1]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[1]->eds_service()->response_count()); + EXPECT_EQ(0U, balancers_[2]->eds_service()->request_count()); + EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); } // Send an update with the same set of LBs as the one in SetUp() in order to @@ -1187,13 +1391,12 @@ TEST_F(UpdatesTest, UpdateBalancerName) { TEST_F(UpdatesTest, UpdateBalancersRepeated) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); - const std::vector first_backend{GetBackendPorts()[0]}; - const std::vector second_backend{GetBackendPorts()[0]}; - + auto first_backend = GetBackendPortsInGroups(0, 1); + auto second_backend = GetBackendPortsInGroups(1, 2); ScheduleResponseForBalancer( - 0, BalancerServiceImpl::BuildResponseForBackends(first_backend, {}), 0); + 0, EdsServiceImpl::BuildResponseForBackends(first_backend), 0); ScheduleResponseForBalancer( - 1, BalancerServiceImpl::BuildResponseForBackends(second_backend, {}), 0); + 1, EdsServiceImpl::BuildResponseForBackends(second_backend), 0); // Wait until the first backend is ready. WaitForBackend(0); @@ -1204,26 +1407,26 @@ TEST_F(UpdatesTest, UpdateBalancersRepeated) { gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); // All 10 requests should have gone to the first backend. - EXPECT_EQ(10U, backends_[0]->service_.request_count()); + EXPECT_EQ(10U, backends_[0]->backend_service()->request_count()); - // Balancer 0 got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - EXPECT_EQ(0U, balancers_[1]->service_.request_count()); - EXPECT_EQ(0U, balancers_[1]->service_.response_count()); - EXPECT_EQ(0U, balancers_[2]->service_.request_count()); - EXPECT_EQ(0U, balancers_[2]->service_.response_count()); + // The EDS service of balancer 0 got a single request, and sent a single + // response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); + EXPECT_EQ(0U, balancers_[1]->eds_service()->request_count()); + EXPECT_EQ(0U, balancers_[1]->eds_service()->response_count()); + EXPECT_EQ(0U, balancers_[2]->eds_service()->request_count()); + EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); std::vector ports; - ports.emplace_back(balancers_[0]->port_); - ports.emplace_back(balancers_[1]->port_); - ports.emplace_back(balancers_[2]->port_); + ports.emplace_back(balancers_[0]->port()); + ports.emplace_back(balancers_[1]->port()); + ports.emplace_back(balancers_[2]->port()); gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 1 =========="); SetNextResolutionForLbChannel(ports); gpr_log(GPR_INFO, "========= UPDATE 1 DONE =========="); - EXPECT_EQ(0U, backends_[1]->service_.request_count()); + EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); gpr_timespec deadline = gpr_time_add( gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(10000, GPR_TIMESPAN)); // Send 10 seconds worth of RPCs @@ -1232,16 +1435,16 @@ TEST_F(UpdatesTest, UpdateBalancersRepeated) { } while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0); // xds continued using the original LB call to the first balancer, which // doesn't assign the second backend. - EXPECT_EQ(0U, backends_[1]->service_.request_count()); + EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); ports.clear(); - ports.emplace_back(balancers_[0]->port_); - ports.emplace_back(balancers_[1]->port_); + ports.emplace_back(balancers_[0]->port()); + ports.emplace_back(balancers_[1]->port()); gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 2 =========="); SetNextResolutionForLbChannel(ports); gpr_log(GPR_INFO, "========= UPDATE 2 DONE =========="); - EXPECT_EQ(0U, backends_[1]->service_.request_count()); + EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(10000, GPR_TIMESPAN)); // Send 10 seconds worth of RPCs @@ -1250,26 +1453,25 @@ TEST_F(UpdatesTest, UpdateBalancersRepeated) { } while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0); // xds continued using the original LB call to the first balancer, which // doesn't assign the second backend. - EXPECT_EQ(0U, backends_[1]->service_.request_count()); + EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); } TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); - SetNextResolutionForLbChannel({balancers_[0]->port_}); - const std::vector first_backend{GetBackendPorts()[0]}; - const std::vector second_backend{GetBackendPorts()[1]}; - + SetNextResolutionForLbChannel({balancers_[0]->port()}); + auto first_backend = GetBackendPortsInGroups(0, 1); + auto second_backend = GetBackendPortsInGroups(1, 2); ScheduleResponseForBalancer( - 0, BalancerServiceImpl::BuildResponseForBackends(first_backend, {}), 0); + 0, EdsServiceImpl::BuildResponseForBackends(first_backend), 0); ScheduleResponseForBalancer( - 1, BalancerServiceImpl::BuildResponseForBackends(second_backend, {}), 0); + 1, EdsServiceImpl::BuildResponseForBackends(second_backend), 0); // Start servers and send 10 RPCs per server. gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); CheckRpcSendOk(10); gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); // All 10 requests should have gone to the first backend. - EXPECT_EQ(10U, backends_[0]->service_.request_count()); + EXPECT_EQ(10U, backends_[0]->backend_service()->request_count()); // Kill balancer 0 gpr_log(GPR_INFO, "********** ABOUT TO KILL BALANCER 0 *************"); @@ -1281,48 +1483,48 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { CheckRpcSendOk(10); gpr_log(GPR_INFO, "========= DONE WITH SECOND BATCH =========="); // All 10 requests should again have gone to the first backend. - EXPECT_EQ(20U, backends_[0]->service_.request_count()); - EXPECT_EQ(0U, backends_[1]->service_.request_count()); + EXPECT_EQ(20U, backends_[0]->backend_service()->request_count()); + EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); - // Balancer 0 got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - EXPECT_EQ(0U, balancers_[1]->service_.request_count()); - EXPECT_EQ(0U, balancers_[1]->service_.response_count()); - EXPECT_EQ(0U, balancers_[2]->service_.request_count()); - EXPECT_EQ(0U, balancers_[2]->service_.response_count()); + // The EDS service of balancer 0 got a single request, and sent a single + // response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); + EXPECT_EQ(0U, balancers_[1]->eds_service()->request_count()); + EXPECT_EQ(0U, balancers_[1]->eds_service()->response_count()); + EXPECT_EQ(0U, balancers_[2]->eds_service()->request_count()); + EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 1 =========="); - SetNextResolutionForLbChannel({balancers_[1]->port_}); + SetNextResolutionForLbChannel({balancers_[1]->port()}); gpr_log(GPR_INFO, "========= UPDATE 1 DONE =========="); // Wait until update has been processed, as signaled by the second backend // receiving a request. In the meantime, the client continues to be serviced // (by the first backend) without interruption. - EXPECT_EQ(0U, backends_[1]->service_.request_count()); + EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); WaitForBackend(1); // This is serviced by the updated RR policy - backends_[1]->service_.ResetCounters(); + backends_[1]->backend_service()->ResetCounters(); gpr_log(GPR_INFO, "========= BEFORE THIRD BATCH =========="); CheckRpcSendOk(10); gpr_log(GPR_INFO, "========= DONE WITH THIRD BATCH =========="); // All 10 requests should have gone to the second backend. - EXPECT_EQ(10U, backends_[1]->service_.request_count()); + EXPECT_EQ(10U, backends_[1]->backend_service()->request_count()); - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); // The second balancer, published as part of the first update, may end up // getting two requests (that is, 1 <= #req <= 2) if the LB call retry timer // firing races with the arrival of the update containing the second // balancer. - EXPECT_GE(balancers_[1]->service_.request_count(), 1U); - EXPECT_GE(balancers_[1]->service_.response_count(), 1U); - EXPECT_LE(balancers_[1]->service_.request_count(), 2U); - EXPECT_LE(balancers_[1]->service_.response_count(), 2U); - EXPECT_EQ(0U, balancers_[2]->service_.request_count()); - EXPECT_EQ(0U, balancers_[2]->service_.response_count()); + EXPECT_GE(balancers_[1]->eds_service()->request_count(), 1U); + EXPECT_GE(balancers_[1]->eds_service()->response_count(), 1U); + EXPECT_LE(balancers_[1]->eds_service()->request_count(), 2U); + EXPECT_LE(balancers_[1]->eds_service()->response_count(), 2U); + EXPECT_EQ(0U, balancers_[2]->eds_service()->request_count()); + EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); } // The re-resolution tests are deferred because they rely on the fallback mode, @@ -1346,15 +1548,105 @@ class SingleBalancerWithClientLoadReportingTest : public XdsEnd2endTest { SingleBalancerWithClientLoadReportingTest() : XdsEnd2endTest(4, 1, 3) {} }; -// The client load reporting tests are deferred because the client load -// reporting hasn't been supported yet. +TEST_F(SingleBalancerWithClientLoadReportingTest, Vanilla) { + SetNextResolution({}, kDefaultServiceConfig_.c_str()); + SetNextResolutionForLbChannel({balancers_[0]->port()}); + const size_t kNumRpcsPerAddress = 100; + // TODO(juanlishen): Partition the backends after multiple localities is + // tested. + ScheduleResponseForBalancer(0, + EdsServiceImpl::BuildResponseForBackends( + GetBackendPortsInGroups(0, backends_.size())), + 0); + // Wait until all backends are ready. + int num_ok = 0; + int num_failure = 0; + int num_drops = 0; + std::tie(num_ok, num_failure, num_drops) = WaitForAllBackends(); + // Send kNumRpcsPerAddress RPCs per server. + CheckRpcSendOk(kNumRpcsPerAddress * num_backends_); + // Each backend should have gotten 100 requests. + for (size_t i = 0; i < backends_.size(); ++i) { + EXPECT_EQ(kNumRpcsPerAddress, + backends_[i]->backend_service()->request_count()); + } + // The EDS service got a single request, and sent a single response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); + // The LRS service got a single request, and sent a single response. + EXPECT_EQ(1U, balancers_[0]->lrs_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->lrs_service()->response_count()); + // The load report received at the balancer should be correct. + ClientStats* client_stats = balancers_[0]->lrs_service()->WaitForLoadReport(); + EXPECT_EQ(kNumRpcsPerAddress * num_backends_ + num_ok, + client_stats->total_successful_requests()); + EXPECT_EQ(0U, client_stats->total_requests_in_progress()); + EXPECT_EQ(kNumRpcsPerAddress * num_backends_ + num_ok, + client_stats->total_issued_requests()); + EXPECT_EQ(0U, client_stats->total_error_requests()); + EXPECT_EQ(0U, client_stats->total_dropped_requests()); +} -// TODO(vpowar): Add TEST_F(SingleBalancerWithClientLoadReportingTest, Vanilla) +TEST_F(SingleBalancerWithClientLoadReportingTest, BalancerRestart) { + SetNextResolution({}, kDefaultServiceConfig_.c_str()); + SetNextResolutionForLbChannel({balancers_[0]->port()}); + const size_t kNumBackendsFirstPass = backends_.size() / 2; + const size_t kNumBackendsSecondPass = + backends_.size() - kNumBackendsFirstPass; + ScheduleResponseForBalancer( + 0, + EdsServiceImpl::BuildResponseForBackends( + GetBackendPortsInGroups(0, kNumBackendsFirstPass)), + 0); + // Wait until all backends returned by the balancer are ready. + int num_ok = 0; + int num_failure = 0; + int num_drops = 0; + std::tie(num_ok, num_failure, num_drops) = + WaitForAllBackends(/* num_requests_multiple_of */ 1, /* start_index */ 0, + /* stop_index */ kNumBackendsFirstPass); + ClientStats* client_stats = balancers_[0]->lrs_service()->WaitForLoadReport(); + EXPECT_EQ(static_cast(num_ok), + client_stats->total_successful_requests()); + EXPECT_EQ(0U, client_stats->total_requests_in_progress()); + EXPECT_EQ(0U, client_stats->total_error_requests()); + EXPECT_EQ(0U, client_stats->total_dropped_requests()); + // Shut down the balancer. + balancers_[0]->Shutdown(); + // Send 1 more request per backend. This will continue using the + // last serverlist we received from the balancer before it was shut down. + ResetBackendCounters(); + CheckRpcSendOk(kNumBackendsFirstPass); + int num_started = kNumBackendsFirstPass; + // Each backend should have gotten 1 request. + for (size_t i = 0; i < kNumBackendsFirstPass; ++i) { + EXPECT_EQ(1UL, backends_[i]->backend_service()->request_count()); + } + // Now restart the balancer, this time pointing to the new backends. + balancers_[0]->Start(server_host_); + ScheduleResponseForBalancer( + 0, + EdsServiceImpl::BuildResponseForBackends( + GetBackendPortsInGroups(kNumBackendsFirstPass)), + 0); + // Wait for queries to start going to one of the new backends. + // This tells us that we're now using the new serverlist. + std::tie(num_ok, num_failure, num_drops) = + WaitForAllBackends(/* num_requests_multiple_of */ 1, + /* start_index */ kNumBackendsFirstPass); + num_started += num_ok + num_failure + num_drops; + // Send one RPC per backend. + CheckRpcSendOk(kNumBackendsSecondPass); + num_started += kNumBackendsSecondPass; + // Check client stats. + client_stats = balancers_[0]->lrs_service()->WaitForLoadReport(); + EXPECT_EQ(num_started, client_stats->total_successful_requests()); + EXPECT_EQ(0U, client_stats->total_requests_in_progress()); + EXPECT_EQ(0U, client_stats->total_error_requests()); + EXPECT_EQ(0U, client_stats->total_dropped_requests()); +} -// TODO(roth): Add TEST_F(SingleBalancerWithClientLoadReportingTest, -// BalancerRestart) - -// TODO(roth): Add TEST_F(SingleBalancerWithClientLoadReportingTest, Drop) +// TODO(juanlishen): Add TEST_F(SingleBalancerWithClientLoadReportingTest, Drop) } // namespace } // namespace testing diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py index f0f94c00466..fc1bfe99934 100755 --- a/tools/codegen/core/gen_static_metadata.py +++ b/tools/codegen/core/gen_static_metadata.py @@ -63,6 +63,7 @@ CONFIG = [ 'grpc.max_response_message_bytes', # well known method names '/grpc.lb.v1.LoadBalancer/BalanceLoad', + '/envoy.service.load_stats.v2.LoadReportingService/StreamLoadStats', '/envoy.api.v2.EndpointDiscoveryService/StreamEndpoints', '/grpc.health.v1.Health/Watch', '/envoy.service.discovery.v2.AggregatedDiscoveryService/StreamAggregatedResources', diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 36e6ef1d48c..f39c72c4d5e 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -5307,9 +5307,12 @@ "grpc_test_util" ], "headers": [ - "src/proto/grpc/lb/v2/xds_for_test.grpc.pb.h", - "src/proto/grpc/lb/v2/xds_for_test.pb.h", - "src/proto/grpc/lb/v2/xds_for_test_mock.grpc.pb.h" + "src/proto/grpc/lb/v2/eds_for_test.grpc.pb.h", + "src/proto/grpc/lb/v2/eds_for_test.pb.h", + "src/proto/grpc/lb/v2/eds_for_test_mock.grpc.pb.h", + "src/proto/grpc/lb/v2/lrs_for_test.grpc.pb.h", + "src/proto/grpc/lb/v2/lrs_for_test.pb.h", + "src/proto/grpc/lb/v2/lrs_for_test_mock.grpc.pb.h" ], "is_filegroup": false, "language": "c++", @@ -9467,7 +9470,6 @@ "gpr", "grpc_base", "grpc_client_channel", - "grpc_lb_upb", "grpc_resolver_fake" ], "headers": [ @@ -9498,7 +9500,6 @@ "gpr", "grpc_base", "grpc_client_channel", - "grpc_lb_upb", "grpc_resolver_fake", "grpc_secure" ], From 13896f8bd184b91327cbb532c8d93076d0169376 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Wed, 5 Jun 2019 23:37:11 -0400 Subject: [PATCH 1170/1555] Mandate static string for host and method passed to grpc_channel_register_call This is for the gRFC being prepared. Bump the major version of core to 8.0.0. --- Makefile | 34 ++++++++++++++-------------- build.yaml | 2 +- build_config.rb | 2 +- include/grpc/grpc.h | 4 +++- src/core/lib/surface/channel.cc | 4 ++-- src/core/lib/surface/version.cc | 2 +- src/objective-c/tests/version.h | 2 +- tools/doxygen/Doxyfile.core | 2 +- tools/doxygen/Doxyfile.core.internal | 2 +- 9 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index ef5963dc441..083790f4b5b 100644 --- a/Makefile +++ b/Makefile @@ -454,7 +454,7 @@ E = @echo Q = @ endif -CORE_VERSION = 7.0.0 +CORE_VERSION = 8.0.0 CPP_VERSION = 1.24.0-dev CSHARP_VERSION = 2.24.0-dev @@ -504,7 +504,7 @@ SHARED_EXT_CORE = dll SHARED_EXT_CPP = dll SHARED_EXT_CSHARP = dll SHARED_PREFIX = -SHARED_VERSION_CORE = -7 +SHARED_VERSION_CORE = -8 SHARED_VERSION_CPP = -1 SHARED_VERSION_CSHARP = -2 else ifeq ($(SYSTEM),Darwin) @@ -3104,7 +3104,7 @@ install-shared_c: shared_c strip-shared_c install-pkg-config_c ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE)-dll.a $(prefix)/lib/libaddress_sorting.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libaddress_sorting.so.7 + $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libaddress_sorting.so.8 $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libaddress_sorting.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)" @@ -3113,7 +3113,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE)-dll.a $(prefix)/lib/libgpr.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgpr.so.7 + $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgpr.so.8 $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgpr.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)" @@ -3122,7 +3122,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE)-dll.a $(prefix)/lib/libgrpc.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc.so.7 + $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc.so.8 $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)" @@ -3131,7 +3131,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE)-dll.a $(prefix)/lib/libgrpc_cronet.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_cronet.so.7 + $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_cronet.so.8 $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_cronet.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)" @@ -3140,7 +3140,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE)-dll.a $(prefix)/lib/libgrpc_unsecure.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_unsecure.so.7 + $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_unsecure.so.8 $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_unsecure.so endif ifneq ($(SYSTEM),MINGW32) @@ -3301,8 +3301,8 @@ $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): ifeq ($(SYSTEM),Darwin) $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libaddress_sorting.so.7 -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).so.7 + $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libaddress_sorting.so.8 -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).so.8 $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).so endif endif @@ -3497,8 +3497,8 @@ $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGPR_OB ifeq ($(SYSTEM),Darwin) $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgpr.so.7 -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so.7 + $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgpr.so.8 -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so.8 $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so endif endif @@ -3954,8 +3954,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_ ifeq ($(SYSTEM),Darwin) $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.7 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so.7 + $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.8 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so.8 $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so endif endif @@ -4338,8 +4338,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(L ifeq ($(SYSTEM),Darwin) $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_cronet.so.7 -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).so.7 + $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_cronet.so.8 -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).so.8 $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).so endif endif @@ -5348,8 +5348,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $ ifeq ($(SYSTEM),Darwin) $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_unsecure.so.7 -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so.7 + $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_unsecure.so.8 -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so.8 $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so endif endif diff --git a/build.yaml b/build.yaml index 0b8c1955d27..122e3dceb4c 100644 --- a/build.yaml +++ b/build.yaml @@ -12,7 +12,7 @@ settings: '#08': Use "-preN" suffixes to identify pre-release versions '#09': Per-language overrides are possible with (eg) ruby_version tag here '#10': See the expand_version.py for all the quirks here - core_version: 7.0.0 + core_version: 8.0.0 csharp_major_version: 2 g_stands_for: ganges version: 1.24.0-dev diff --git a/build_config.rb b/build_config.rb index ab06a137473..7bd312cd2b6 100644 --- a/build_config.rb +++ b/build_config.rb @@ -13,5 +13,5 @@ # limitations under the License. module GrpcBuildConfig - CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-7.dll' + CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-8.dll' end diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 9a99e016a93..cb46477c19d 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -224,7 +224,9 @@ GRPCAPI grpc_call* grpc_channel_create_call( GRPCAPI void grpc_channel_ping(grpc_channel* channel, grpc_completion_queue* cq, void* tag, void* reserved); -/** Pre-register a method/host pair on a channel. */ +/** Pre-register a method/host pair on a channel. + method and host are not owned and must remain alive while the server is + running. */ GRPCAPI void* grpc_channel_register_call(grpc_channel* channel, const char* method, const char* host, void* reserved); diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 942af37a830..24813407e28 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -417,10 +417,10 @@ void* grpc_channel_register_call(grpc_channel* channel, const char* method, grpc_core::ExecCtx exec_ctx; rc->path = grpc_mdelem_from_slices(GRPC_MDSTR_PATH, - grpc_core::ManagedMemorySlice(method)); + grpc_core::ExternallyManagedSlice(method)); rc->authority = host ? grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY, - grpc_core::ManagedMemorySlice(host)) + grpc_core::ExternallyManagedSlice(host)) : GRPC_MDNULL; gpr_mu_lock(&channel->registered_call_mu); rc->next = channel->registered_calls; diff --git a/src/core/lib/surface/version.cc b/src/core/lib/surface/version.cc index 182eed2ced2..71eb89a1b42 100644 --- a/src/core/lib/surface/version.cc +++ b/src/core/lib/surface/version.cc @@ -23,6 +23,6 @@ #include -const char* grpc_version_string(void) { return "7.0.0"; } +const char* grpc_version_string(void) { return "8.0.0"; } const char* grpc_g_stands_for(void) { return "ganges"; } diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index d724fdd8e07..9182189f4c8 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -23,4 +23,4 @@ // `tools/buildgen/generate_projects.sh`. #define GRPC_OBJC_VERSION_STRING @"1.24.0-dev" -#define GRPC_C_VERSION_STRING @"7.0.0" +#define GRPC_C_VERSION_STRING @"8.0.0" diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index 2836412b031..f4533f240bd 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC Core" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 7.0.0 +PROJECT_NUMBER = 8.0.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 5180fab8635..e9bd8e463ba 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC Core" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 7.0.0 +PROJECT_NUMBER = 8.0.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From 422a7773aeb60e5847e1964089d842a1c93db6e2 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Fri, 9 Aug 2019 12:27:39 -0700 Subject: [PATCH 1171/1555] Replace making protoc and plugins with bazel build Fixed templates and plugin-tests --- .../!ProtoCompiler-gRPCCppPlugin.podspec | 12 +-- .../!ProtoCompiler-gRPCPlugin.podspec | 12 +-- src/objective-c/!ProtoCompiler.podspec | 17 +--- .../RemoteTestClient/RemoteTest.podspec | 6 +- .../tests/RemoteTestClient/RemoteTest.podspec | 34 +++---- src/objective-c/tests/run_plugin_tests.sh | 12 ++- ...otoCompiler-gRPCCppPlugin.podspec.template | 12 +-- ...!ProtoCompiler-gRPCPlugin.podspec.template | 12 +-- .../RemoteTestClientCpp/RemoteTestCpp.podspec | 89 ++++++------------- 9 files changed, 58 insertions(+), 148 deletions(-) diff --git a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec index 56ca7ce6ae4..67faaeb2567 100644 --- a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec @@ -94,6 +94,7 @@ Pod::Spec.new do |s| } repo_root = '../..' + bazel = "#{repo_root}/tools/bazel" plugin = 'grpc_cpp_plugin' s.preserve_paths = plugin @@ -111,15 +112,6 @@ Pod::Spec.new do |s| # present in this pod's directory. We use that knowledge to check for the existence of the file # and, if absent, compile the plugin from the local sources. s.prepare_command = <<-CMD - if [ ! -f #{plugin} ]; then - cd #{repo_root} - # This will build the plugin and put it in #{repo_root}/bins/opt. - # - # TODO(jcanizales): I reckon make will try to use locally-installed libprotoc (headers and - # library binary) if found, which _we do not want_. Find a way for this to always use the - # sources in the repo. - make #{plugin} - cd - - fi + #{bazel} build //src/compiler:grpc_cpp_plugin CMD end diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 8509d465901..f65086b6df5 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -96,6 +96,7 @@ Pod::Spec.new do |s| } repo_root = '../..' + bazel = "#{repo_root}/tools/bazel" plugin = 'grpc_objective_c_plugin' s.preserve_paths = plugin @@ -115,15 +116,6 @@ Pod::Spec.new do |s| # present in this pod's directory. We use that knowledge to check for the existence of the file # and, if absent, compile the plugin from the local sources. s.prepare_command = <<-CMD - if [ ! -f #{plugin} ]; then - cd #{repo_root} - # This will build the plugin and put it in #{repo_root}/bins/opt. - # - # TODO(jcanizales): I reckon make will try to use locally-installed libprotoc (headers and - # library binary) if found, which _we do not want_. Find a way for this to always use the - # sources in the repo. - make #{plugin} - cd - - fi + #{bazel} build //src/compiler:grpc_objective_c_plugin CMD end diff --git a/src/objective-c/!ProtoCompiler.podspec b/src/objective-c/!ProtoCompiler.podspec index b75d93a58be..9d036ac0b5b 100644 --- a/src/objective-c/!ProtoCompiler.podspec +++ b/src/objective-c/!ProtoCompiler.podspec @@ -120,20 +120,9 @@ Pod::Spec.new do |s| # present in this pod's directory. We use that knowledge to check for the existence of the file # and, if absent, build it from the local sources. repo_root = '../..' - plugin = 'grpc_objective_c_plugin' + bazel = "#{repo_root}/tools/bazel" + s.prepare_command = <<-CMD - if [ ! -f bin/protoc ]; then - cd #{repo_root} - # This will build protoc from the Protobuf submodule of gRPC, and put it in - # #{repo_root}/bins/opt/protobuf. - # - # TODO(jcanizales): Make won't build protoc from sources if one's locally installed, which - # _we do not want_. Find a way for this to always build from source. - make #{plugin} - cd - - else - mv bin/protoc . - mv include/google . - fi + #{bazel} build @com_google_protobuf//:protoc CMD end diff --git a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec index e3dbf4fe7ef..ca45fd063bd 100644 --- a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec +++ b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec @@ -16,11 +16,11 @@ Pod::Spec.new do |s| s.dependency "!ProtoCompiler-gRPCPlugin" repo_root = '../../../..' - bin_dir = "#{repo_root}/bins/$CONFIG" + bazel_exec_root = "#{repo_root}/bazel-out/darwin-fastbuild/bin" - protoc = "#{bin_dir}/protobuf/protoc" + protoc = "#{bazel_exec_root}/external/com_google_protobuf/protoc" well_known_types_dir = "#{repo_root}/third_party/protobuf/src" - plugin = "#{bin_dir}/grpc_objective_c_plugin" + plugin = "#{bazel_exec_root}/src/compiler/grpc_objective_c_plugin" # Since we switched to importing full path, -I needs to be set to the directory # from which the imported file can be found, which is the grpc's root here diff --git a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec index d772163e117..4a35328f73f 100644 --- a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec +++ b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec @@ -16,34 +16,20 @@ Pod::Spec.new do |s| s.dependency "!ProtoCompiler-gRPCPlugin" repo_root = '../../../..' - config = ENV['CONFIG'] || 'opt' - bin_dir = "#{repo_root}/bins/#{config}" + bazel_exec_root = "#{repo_root}/bazel-out/darwin-fastbuild/bin" - protoc = "#{bin_dir}/protobuf/protoc" + protoc = "#{bazel_exec_root}/external/com_google_protobuf/protoc" well_known_types_dir = "#{repo_root}/third_party/protobuf/src" - plugin = "#{bin_dir}/grpc_objective_c_plugin" + plugin = "#{bazel_exec_root}/src/compiler/grpc_objective_c_plugin" s.prepare_command = <<-CMD - if [ -f #{protoc} ]; then - #{protoc} \ - --plugin=protoc-gen-grpc=#{plugin} \ - --objc_out=. \ - --grpc_out=. \ - -I #{repo_root} \ - -I #{well_known_types_dir} \ - #{repo_root}/src/objective-c/tests/RemoteTestClient/*.proto - else - # protoc was not found bin_dir, use installed version instead - (>&2 echo "\nWARNING: Using installed version of protoc. It might be incompatible with gRPC") - - protoc \ - --plugin=protoc-gen-grpc=#{plugin} \ - --objc_out=. \ - --grpc_out=. \ - -I #{repo_root} \ - -I #{well_known_types_dir} \ - #{repo_root}/src/objective-c/tests/RemoteTestClient/*.proto - fi + #{protoc} \ + --plugin=protoc-gen-grpc=#{plugin} \ + --objc_out=. \ + --grpc_out=. \ + -I #{repo_root} \ + -I #{well_known_types_dir} \ + #{repo_root}/src/objective-c/tests/RemoteTestClient/*.proto CMD s.subspec "Messages" do |ms| diff --git a/src/objective-c/tests/run_plugin_tests.sh b/src/objective-c/tests/run_plugin_tests.sh index bcab3bb9cff..760103eb7cd 100755 --- a/src/objective-c/tests/run_plugin_tests.sh +++ b/src/objective-c/tests/run_plugin_tests.sh @@ -22,9 +22,15 @@ cd $(dirname $0) # Run the tests server. -BINDIR=../../../bins/$CONFIG -PROTOC=$BINDIR/protobuf/protoc -PLUGIN=$BINDIR/grpc_objective_c_plugin +ROOT_DIR=../../.. +BAZEL=$ROOT_DIR/tools/bazel +BAZEL_EXEC_ROOT=$ROOT_DIR/bazel-out/darwin-fastbuild/bin +PROTOC=$BAZEL_EXEC_ROOT/external/com_google_protobuf/protoc +PLUGIN=$BAZEL_EXEC_ROOT/src/compiler/grpc_objective_c_plugin + +[ -f $PROTOC ] && [ -f $PLUGIN ] || { + BAZEL build @com_google_protobuf//:protoc //src/compiler:grpc_objective_c_plugin +} rm -rf PluginTest/*pb* diff --git a/templates/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec.template b/templates/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec.template index 259a5c54f24..072a59657da 100644 --- a/templates/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec.template +++ b/templates/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec.template @@ -96,6 +96,7 @@ } repo_root = '../..' + bazel = "#{repo_root}/tools/bazel" plugin = 'grpc_cpp_plugin' s.preserve_paths = plugin @@ -113,15 +114,6 @@ # present in this pod's directory. We use that knowledge to check for the existence of the file # and, if absent, compile the plugin from the local sources. s.prepare_command = <<-CMD - if [ ! -f #{plugin} ]; then - cd #{repo_root} - # This will build the plugin and put it in #{repo_root}/bins/opt. - # - # TODO(jcanizales): I reckon make will try to use locally-installed libprotoc (headers and - # library binary) if found, which _we do not want_. Find a way for this to always use the - # sources in the repo. - make #{plugin} - cd - - fi + #{bazel} build //src/compiler:grpc_cpp_plugin CMD end diff --git a/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template b/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template index f612bd56cff..6286e3369e2 100644 --- a/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template +++ b/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template @@ -98,6 +98,7 @@ } repo_root = '../..' + bazel = "#{repo_root}/tools/bazel" plugin = 'grpc_objective_c_plugin' s.preserve_paths = plugin @@ -117,15 +118,6 @@ # present in this pod's directory. We use that knowledge to check for the existence of the file # and, if absent, compile the plugin from the local sources. s.prepare_command = <<-CMD - if [ ! -f #{plugin} ]; then - cd #{repo_root} - # This will build the plugin and put it in #{repo_root}/bins/opt. - # - # TODO(jcanizales): I reckon make will try to use locally-installed libprotoc (headers and - # library binary) if found, which _we do not want_. Find a way for this to always use the - # sources in the repo. - make #{plugin} - cd - - fi + #{bazel} build //src/compiler:grpc_objective_c_plugin CMD end diff --git a/test/cpp/ios/RemoteTestClientCpp/RemoteTestCpp.podspec b/test/cpp/ios/RemoteTestClientCpp/RemoteTestCpp.podspec index 0d51fdab31e..a0f0e2e436a 100644 --- a/test/cpp/ios/RemoteTestClientCpp/RemoteTestCpp.podspec +++ b/test/cpp/ios/RemoteTestClientCpp/RemoteTestCpp.podspec @@ -15,78 +15,39 @@ Pod::Spec.new do |s| s.dependency "Protobuf-C++" s.dependency "gRPC-C++" s.source_files = "src/proto/grpc/testing/*.pb.{h,cc}" - s.header_mappings_dir = "RemoteTestCpp" + s.header_mappings_dir = "." s.requires_arc = false repo_root = '../../../..' - config = ENV['CONFIG'] || 'opt' - bin_dir = "#{repo_root}/bins/#{config}" + bazel_exec_root = "#{repo_root}/bazel-out/darwin-fastbuild/bin" - protoc = "#{bin_dir}/protobuf/protoc" + protoc = "#{bazel_exec_root}/external/com_google_protobuf/protoc" well_known_types_dir = "#{repo_root}/third_party/protobuf/src" - plugin = "#{bin_dir}/grpc_cpp_plugin" + plugin = "#{bazel_exec_root}/src/compiler/grpc_cpp_plugin" proto_dir = "#{repo_root}/src/proto/grpc/testing" s.prepare_command = <<-CMD - if [ -f #{protoc} ]; then - #{protoc} \ - --plugin=protoc-gen-grpc=#{plugin} \ - --cpp_out=. \ - --grpc_out=. \ - -I #{repo_root} \ - -I #{proto_dir} \ - -I #{well_known_types_dir} \ - #{proto_dir}/echo.proto - #{protoc} \ - --plugin=protoc-gen-grpc=#{plugin} \ - --cpp_out=. \ - --grpc_out=. \ - -I #{repo_root} \ - -I #{proto_dir} \ - -I #{well_known_types_dir} \ - #{proto_dir}/echo_messages.proto - #{protoc} \ - --plugin=protoc-gen-grpc=#{plugin} \ - --cpp_out=. \ - --grpc_out=. \ - -I #{repo_root} \ - -I #{proto_dir} \ - -I #{well_known_types_dir} \ - #{proto_dir}/simple_messages.proto - else - # protoc was not found bin_dir, use installed version instead - - if ! [ -x "$(command -v protoc)" ]; then - (>&2 echo "\nERROR: protoc not found") - exit 1 - fi - (>&2 echo "\nWARNING: Using installed version of protoc. It might be incompatible with gRPC") - - protoc \ - --plugin=protoc-gen-grpc=#{plugin} \ - --cpp_out=. \ - --grpc_out=. \ - -I #{repo_root} \ - -I #{proto_dir} \ - -I #{well_known_types_dir} \ - #{proto_dir}/echo.proto - protoc \ - --plugin=protoc-gen-grpc=#{plugin} \ - --cpp_out=. \ - --grpc_out=. \ - -I #{repo_root} \ - -I #{proto_dir} \ - -I #{well_known_types_dir} \ - #{proto_dir}/echo_messages.proto - protoc \ - --plugin=protoc-gen-grpc=#{plugin} \ - --cpp_out=. \ - --grpc_out=. \ - -I #{repo_root} \ - -I #{proto_dir} \ - -I #{well_known_types_dir} \ - #{proto_dir}/simple_messages.proto - fi + #{protoc} \ + --plugin=protoc-gen-grpc=#{plugin} \ + --cpp_out=. \ + --grpc_out=. \ + -I #{repo_root} \ + -I #{well_known_types_dir} \ + #{proto_dir}/echo.proto + #{protoc} \ + --plugin=protoc-gen-grpc=#{plugin} \ + --cpp_out=. \ + --grpc_out=. \ + -I #{repo_root} \ + -I #{well_known_types_dir} \ + #{proto_dir}/echo_messages.proto + #{protoc} \ + --plugin=protoc-gen-grpc=#{plugin} \ + --cpp_out=. \ + --grpc_out=. \ + -I #{repo_root} \ + -I #{well_known_types_dir} \ + #{proto_dir}/simple_messages.proto CMD s.pod_target_xcconfig = { From 988ca514b9cd87c7010bfafe329b9495603e9b7b Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 29 Jul 2019 18:53:00 -0700 Subject: [PATCH 1172/1555] serialization to IBufferWriter attempt 1 --- .../Grpc.Core.Api/SerializationContext.cs | 18 +++++ .../Internal/DefaultSerializationContext.cs | 74 +++++++++++++++++-- .../Internal/NativeMethods.Generated.cs | 33 +++++++++ src/csharp/ext/grpc_csharp_ext.c | 61 +++++++++++++++ .../runtimes/grpc_csharp_ext_dummy_stubs.c | 12 +++ .../Grpc.Core/Internal/native_methods.include | 3 + 6 files changed, 196 insertions(+), 5 deletions(-) diff --git a/src/csharp/Grpc.Core.Api/SerializationContext.cs b/src/csharp/Grpc.Core.Api/SerializationContext.cs index 9aef2adbcd5..79107040411 100644 --- a/src/csharp/Grpc.Core.Api/SerializationContext.cs +++ b/src/csharp/Grpc.Core.Api/SerializationContext.cs @@ -17,6 +17,7 @@ #endregion using System; +using System.Buffers; namespace Grpc.Core { @@ -35,5 +36,22 @@ namespace Grpc.Core { throw new NotImplementedException(); } + + /// + /// Expose serializer as buffer writer + /// + public virtual IBufferWriter GetBufferWriter() + { + throw new NotImplementedException(); + } + + /// + /// Complete the payload written so far. + /// + public virtual void Complete() + { + throw new NotImplementedException(); + + } } } diff --git a/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs b/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs index cceb194879e..9098850a52e 100644 --- a/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs +++ b/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs @@ -17,6 +17,8 @@ #endregion using Grpc.Core.Utils; +using System; +using System.Buffers; using System.Threading; namespace Grpc.Core.Internal @@ -27,7 +29,8 @@ namespace Grpc.Core.Internal new ThreadLocal(() => new DefaultSerializationContext(), false); bool isComplete; - byte[] payload; + //byte[] payload; + NativeBufferWriter bufferWriter; public DefaultSerializationContext() { @@ -38,18 +41,48 @@ namespace Grpc.Core.Internal { GrpcPreconditions.CheckState(!isComplete); this.isComplete = true; - this.payload = payload; + + GetBufferWriter(); + var destSpan = bufferWriter.GetSpan(payload.Length); + payload.AsSpan().CopyTo(destSpan); + bufferWriter.Advance(payload.Length); + bufferWriter.Complete(); + //this.payload = payload; } - internal byte[] GetPayload() + /// + /// Expose serializer as buffer writer + /// + public override IBufferWriter GetBufferWriter() { - return this.payload; + if (bufferWriter == null) + { + // TODO: avoid allocation.. + bufferWriter = new NativeBufferWriter(); + } + return bufferWriter; + } + + /// + /// Complete the payload written so far. + /// + public override void Complete() + { + GrpcPreconditions.CheckState(!isComplete); + bufferWriter.Complete(); + this.isComplete = true; + } + + internal SliceBufferSafeHandle GetPayload() + { + return bufferWriter.GetSliceBuffer(); } public void Reset() { this.isComplete = false; - this.payload = null; + //this.payload = null; + this.bufferWriter = null; } public static DefaultSerializationContext GetInitializedThreadLocal() @@ -58,5 +91,36 @@ namespace Grpc.Core.Internal instance.Reset(); return instance; } + + private class NativeBufferWriter : IBufferWriter + { + private SliceBufferSafeHandle sliceBuffer = SliceBufferSafeHandle.Create(); + + public void Advance(int count) + { + sliceBuffer.Advance(count); + } + + public Memory GetMemory(int sizeHint = 0) + { + // TODO: implement + throw new NotImplementedException(); + } + + public Span GetSpan(int sizeHint = 0) + { + return sliceBuffer.GetSpan(sizeHint); + } + + public void Complete() + { + sliceBuffer.Complete(); + } + + public SliceBufferSafeHandle GetSliceBuffer() + { + return sliceBuffer; + } + } } } diff --git a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs index ca3dfe97ce1..b23170376d4 100644 --- a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs +++ b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs @@ -122,6 +122,9 @@ namespace Grpc.Core.Internal public readonly Delegates.grpcsharp_auth_context_property_iterator_delegate grpcsharp_auth_context_property_iterator; public readonly Delegates.grpcsharp_auth_property_iterator_next_delegate grpcsharp_auth_property_iterator_next; public readonly Delegates.grpcsharp_auth_context_release_delegate grpcsharp_auth_context_release; + public readonly Delegates.grpcsharp_slice_buffer_create_delegate grpcsharp_slice_buffer_create; + public readonly Delegates.grpcsharp_slice_buffer_adjust_tail_space_delegate grpcsharp_slice_buffer_adjust_tail_space; + public readonly Delegates.grpcsharp_slice_buffer_destroy_delegate grpcsharp_slice_buffer_destroy; public readonly Delegates.gprsharp_now_delegate gprsharp_now; public readonly Delegates.gprsharp_inf_future_delegate gprsharp_inf_future; public readonly Delegates.gprsharp_inf_past_delegate gprsharp_inf_past; @@ -224,6 +227,9 @@ namespace Grpc.Core.Internal this.grpcsharp_auth_context_property_iterator = GetMethodDelegate(library); this.grpcsharp_auth_property_iterator_next = GetMethodDelegate(library); this.grpcsharp_auth_context_release = GetMethodDelegate(library); + this.grpcsharp_slice_buffer_create = GetMethodDelegate(library); + this.grpcsharp_slice_buffer_adjust_tail_space = GetMethodDelegate(library); + this.grpcsharp_slice_buffer_destroy = GetMethodDelegate(library); this.gprsharp_now = GetMethodDelegate(library); this.gprsharp_inf_future = GetMethodDelegate(library); this.gprsharp_inf_past = GetMethodDelegate(library); @@ -325,6 +331,9 @@ namespace Grpc.Core.Internal this.grpcsharp_auth_context_property_iterator = DllImportsFromStaticLib.grpcsharp_auth_context_property_iterator; this.grpcsharp_auth_property_iterator_next = DllImportsFromStaticLib.grpcsharp_auth_property_iterator_next; this.grpcsharp_auth_context_release = DllImportsFromStaticLib.grpcsharp_auth_context_release; + this.grpcsharp_slice_buffer_create = DllImportsFromStaticLib.grpcsharp_slice_buffer_create; + this.grpcsharp_slice_buffer_adjust_tail_space = DllImportsFromStaticLib.grpcsharp_slice_buffer_adjust_tail_space; + this.grpcsharp_slice_buffer_destroy = DllImportsFromStaticLib.grpcsharp_slice_buffer_destroy; this.gprsharp_now = DllImportsFromStaticLib.gprsharp_now; this.gprsharp_inf_future = DllImportsFromStaticLib.gprsharp_inf_future; this.gprsharp_inf_past = DllImportsFromStaticLib.gprsharp_inf_past; @@ -426,6 +435,9 @@ namespace Grpc.Core.Internal this.grpcsharp_auth_context_property_iterator = DllImportsFromSharedLib.grpcsharp_auth_context_property_iterator; this.grpcsharp_auth_property_iterator_next = DllImportsFromSharedLib.grpcsharp_auth_property_iterator_next; this.grpcsharp_auth_context_release = DllImportsFromSharedLib.grpcsharp_auth_context_release; + this.grpcsharp_slice_buffer_create = DllImportsFromSharedLib.grpcsharp_slice_buffer_create; + this.grpcsharp_slice_buffer_adjust_tail_space = DllImportsFromSharedLib.grpcsharp_slice_buffer_adjust_tail_space; + this.grpcsharp_slice_buffer_destroy = DllImportsFromSharedLib.grpcsharp_slice_buffer_destroy; this.gprsharp_now = DllImportsFromSharedLib.gprsharp_now; this.gprsharp_inf_future = DllImportsFromSharedLib.gprsharp_inf_future; this.gprsharp_inf_past = DllImportsFromSharedLib.gprsharp_inf_past; @@ -530,6 +542,9 @@ namespace Grpc.Core.Internal public delegate AuthContextSafeHandle.NativeAuthPropertyIterator grpcsharp_auth_context_property_iterator_delegate(AuthContextSafeHandle authContext); public delegate IntPtr grpcsharp_auth_property_iterator_next_delegate(ref AuthContextSafeHandle.NativeAuthPropertyIterator iterator); // returns const auth_property* public delegate void grpcsharp_auth_context_release_delegate(IntPtr authContext); + public delegate SliceBufferSafeHandle grpcsharp_slice_buffer_create_delegate(); + public delegate IntPtr grpcsharp_slice_buffer_adjust_tail_space_delegate(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace); + public delegate void grpcsharp_slice_buffer_destroy_delegate(IntPtr sliceBuffer); public delegate Timespec gprsharp_now_delegate(ClockType clockType); public delegate Timespec gprsharp_inf_future_delegate(ClockType clockType); public delegate Timespec gprsharp_inf_past_delegate(ClockType clockType); @@ -812,6 +827,15 @@ namespace Grpc.Core.Internal [DllImport(ImportName)] public static extern void grpcsharp_auth_context_release(IntPtr authContext); + [DllImport(ImportName)] + public static extern SliceBufferSafeHandle grpcsharp_slice_buffer_create(); + + [DllImport(ImportName)] + public static extern IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace); + + [DllImport(ImportName)] + public static extern void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer); + [DllImport(ImportName)] public static extern Timespec gprsharp_now(ClockType clockType); @@ -1111,6 +1135,15 @@ namespace Grpc.Core.Internal [DllImport(ImportName)] public static extern void grpcsharp_auth_context_release(IntPtr authContext); + [DllImport(ImportName)] + public static extern SliceBufferSafeHandle grpcsharp_slice_buffer_create(); + + [DllImport(ImportName)] + public static extern IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace); + + [DllImport(ImportName)] + public static extern void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer); + [DllImport(ImportName)] public static extern Timespec gprsharp_now(ClockType clockType); diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 02e219ead87..e271494c942 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -1182,6 +1182,67 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_redirect_log(grpcsharp_log_func func) { typedef void(GPR_CALLTYPE* test_callback_funcptr)(int32_t success); +/* Slice buffer functionality */ +GPR_EXPORT grpc_slice_buffer* GPR_CALLTYPE +grpcsharp_slice_buffer_create() { + grpc_slice_buffer* slice_buffer = (grpc_slice_buffer*)gpr_malloc(sizeof(grpc_slice_buffer)); + grpc_slice_buffer_init(slice_buffer); + return slice_buffer; +} + +GPR_EXPORT void GPR_CALLTYPE +grpcsharp_slice_buffer_destroy(grpc_slice_buffer* buffer) { + grpc_slice_buffer_destroy(buffer); + gpr_free(buffer); +} + +GPR_EXPORT grpc_byte_buffer* GPR_CALLTYPE +grpcsharp_create_byte_buffer_from_stolen_slices(grpc_slice_buffer* slice_buffer) { + grpc_byte_buffer* bb = + (grpc_byte_buffer*)gpr_malloc(sizeof(grpc_byte_buffer)); + memset(bb, 0, sizeof(grpc_byte_buffer)); + bb->type = GRPC_BB_RAW; + bb->data.raw.compression = GRPC_COMPRESS_NONE; + bb->data.raw.slice_buffer = *slice_buffer; + // TODO: just use move slice_buffer... + + // we transferred the ownership of members from the slice buffer to the + // the internals of byte buffer, so we just overwrite the original slice buffer with + // default values. + grpc_slice_buffer_init(slice_buffer); // TODO: need to reset available_tail_space after this.. + return bb; +} + +GPR_EXPORT void* GPR_CALLTYPE +grpcsharp_slice_buffer_adjust_tail_space(grpc_slice_buffer* buffer, size_t available_tail_space, + size_t requested_tail_space) { + + // TODO: what if available_tail_space == requested_tail_space == 0 + + if (available_tail_space >= requested_tail_space) + { + // TODO: should this be allowed at all? + grpc_slice_buffer garbage; + grpc_slice_buffer_trim_end(buffer, available_tail_space - requested_tail_space, &garbage); + grpc_slice_buffer_reset_and_unref(&garbage); + } + else + { + if (available_tail_space > 0) + { + grpc_slice_buffer garbage; + grpc_slice_buffer_trim_end(buffer, available_tail_space, &garbage); + grpc_slice_buffer_reset_and_unref(&garbage); + } + + grpc_slice new_slice = grpc_slice_malloc(requested_tail_space); + grpc_slice_buffer_add(buffer, new_slice); + } + + grpc_slice* last_slice = &(buffer->slices[buffer->count - 1]); + return GRPC_SLICE_END_PTR(*last_slice) - requested_tail_space; +} + /* Version info */ GPR_EXPORT const char* GPR_CALLTYPE grpcsharp_version_string() { return grpc_version_string(); diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c index 8ff26e4ca4d..bc312bc6daf 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c @@ -374,6 +374,18 @@ void grpcsharp_auth_context_release() { fprintf(stderr, "Should never reach here"); abort(); } +void grpcsharp_slice_buffer_create() { + fprintf(stderr, "Should never reach here"); + abort(); +} +void grpcsharp_slice_buffer_adjust_tail_space() { + fprintf(stderr, "Should never reach here"); + abort(); +} +void grpcsharp_slice_buffer_destroy() { + fprintf(stderr, "Should never reach here"); + abort(); +} void gprsharp_now() { fprintf(stderr, "Should never reach here"); abort(); diff --git a/templates/src/csharp/Grpc.Core/Internal/native_methods.include b/templates/src/csharp/Grpc.Core/Internal/native_methods.include index ed7c93a7479..d8f94744723 100644 --- a/templates/src/csharp/Grpc.Core/Internal/native_methods.include +++ b/templates/src/csharp/Grpc.Core/Internal/native_methods.include @@ -88,6 +88,9 @@ native_method_signatures = [ 'AuthContextSafeHandle.NativeAuthPropertyIterator grpcsharp_auth_context_property_iterator(AuthContextSafeHandle authContext)', 'IntPtr grpcsharp_auth_property_iterator_next(ref AuthContextSafeHandle.NativeAuthPropertyIterator iterator) // returns const auth_property*', 'void grpcsharp_auth_context_release(IntPtr authContext)', + 'SliceBufferSafeHandle grpcsharp_slice_buffer_create()', + 'IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace)', + 'void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer)', 'Timespec gprsharp_now(ClockType clockType)', 'Timespec gprsharp_inf_future(ClockType clockType)', 'Timespec gprsharp_inf_past(ClockType clockType)', From 36e46234f72f0de72602931a546b8f8495072ddd Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 29 Jul 2019 19:57:08 -0700 Subject: [PATCH 1173/1555] IBufferWriter: tests now passing with a hack --- .../Grpc.Core/Internal/AsyncCallBase.cs | 2 +- .../Internal/NativeMethods.Generated.cs | 22 +++++++++++++++++++ src/csharp/ext/grpc_csharp_ext.c | 17 ++++++++++++++ .../runtimes/grpc_csharp_ext_dummy_stubs.c | 8 +++++++ .../Grpc.Core/Internal/native_methods.include | 2 ++ 5 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs index ac1f9066516..23cb5ccffc7 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs @@ -220,7 +220,7 @@ namespace Grpc.Core.Internal { context = DefaultSerializationContext.GetInitializedThreadLocal(); serializer(msg, context); - return context.GetPayload(); + return context.GetPayload().GetPayload(); } finally { diff --git a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs index b23170376d4..dcb0f84649c 100644 --- a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs +++ b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs @@ -124,6 +124,8 @@ namespace Grpc.Core.Internal public readonly Delegates.grpcsharp_auth_context_release_delegate grpcsharp_auth_context_release; public readonly Delegates.grpcsharp_slice_buffer_create_delegate grpcsharp_slice_buffer_create; public readonly Delegates.grpcsharp_slice_buffer_adjust_tail_space_delegate grpcsharp_slice_buffer_adjust_tail_space; + public readonly Delegates.grpcsharp_slice_buffer_slice_count_delegate grpcsharp_slice_buffer_slice_count; + public readonly Delegates.grpcsharp_slice_buffer_slice_peek_delegate grpcsharp_slice_buffer_slice_peek; public readonly Delegates.grpcsharp_slice_buffer_destroy_delegate grpcsharp_slice_buffer_destroy; public readonly Delegates.gprsharp_now_delegate gprsharp_now; public readonly Delegates.gprsharp_inf_future_delegate gprsharp_inf_future; @@ -229,6 +231,8 @@ namespace Grpc.Core.Internal this.grpcsharp_auth_context_release = GetMethodDelegate(library); this.grpcsharp_slice_buffer_create = GetMethodDelegate(library); this.grpcsharp_slice_buffer_adjust_tail_space = GetMethodDelegate(library); + this.grpcsharp_slice_buffer_slice_count = GetMethodDelegate(library); + this.grpcsharp_slice_buffer_slice_peek = GetMethodDelegate(library); this.grpcsharp_slice_buffer_destroy = GetMethodDelegate(library); this.gprsharp_now = GetMethodDelegate(library); this.gprsharp_inf_future = GetMethodDelegate(library); @@ -333,6 +337,8 @@ namespace Grpc.Core.Internal this.grpcsharp_auth_context_release = DllImportsFromStaticLib.grpcsharp_auth_context_release; this.grpcsharp_slice_buffer_create = DllImportsFromStaticLib.grpcsharp_slice_buffer_create; this.grpcsharp_slice_buffer_adjust_tail_space = DllImportsFromStaticLib.grpcsharp_slice_buffer_adjust_tail_space; + this.grpcsharp_slice_buffer_slice_count = DllImportsFromStaticLib.grpcsharp_slice_buffer_slice_count; + this.grpcsharp_slice_buffer_slice_peek = DllImportsFromStaticLib.grpcsharp_slice_buffer_slice_peek; this.grpcsharp_slice_buffer_destroy = DllImportsFromStaticLib.grpcsharp_slice_buffer_destroy; this.gprsharp_now = DllImportsFromStaticLib.gprsharp_now; this.gprsharp_inf_future = DllImportsFromStaticLib.gprsharp_inf_future; @@ -437,6 +443,8 @@ namespace Grpc.Core.Internal this.grpcsharp_auth_context_release = DllImportsFromSharedLib.grpcsharp_auth_context_release; this.grpcsharp_slice_buffer_create = DllImportsFromSharedLib.grpcsharp_slice_buffer_create; this.grpcsharp_slice_buffer_adjust_tail_space = DllImportsFromSharedLib.grpcsharp_slice_buffer_adjust_tail_space; + this.grpcsharp_slice_buffer_slice_count = DllImportsFromSharedLib.grpcsharp_slice_buffer_slice_count; + this.grpcsharp_slice_buffer_slice_peek = DllImportsFromSharedLib.grpcsharp_slice_buffer_slice_peek; this.grpcsharp_slice_buffer_destroy = DllImportsFromSharedLib.grpcsharp_slice_buffer_destroy; this.gprsharp_now = DllImportsFromSharedLib.gprsharp_now; this.gprsharp_inf_future = DllImportsFromSharedLib.gprsharp_inf_future; @@ -544,6 +552,8 @@ namespace Grpc.Core.Internal public delegate void grpcsharp_auth_context_release_delegate(IntPtr authContext); public delegate SliceBufferSafeHandle grpcsharp_slice_buffer_create_delegate(); public delegate IntPtr grpcsharp_slice_buffer_adjust_tail_space_delegate(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace); + public delegate UIntPtr grpcsharp_slice_buffer_slice_count_delegate(SliceBufferSafeHandle sliceBuffer); + public delegate void grpcsharp_slice_buffer_slice_peek_delegate(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr); public delegate void grpcsharp_slice_buffer_destroy_delegate(IntPtr sliceBuffer); public delegate Timespec gprsharp_now_delegate(ClockType clockType); public delegate Timespec gprsharp_inf_future_delegate(ClockType clockType); @@ -833,6 +843,12 @@ namespace Grpc.Core.Internal [DllImport(ImportName)] public static extern IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace); + [DllImport(ImportName)] + public static extern UIntPtr grpcsharp_slice_buffer_slice_count(SliceBufferSafeHandle sliceBuffer); + + [DllImport(ImportName)] + public static extern void grpcsharp_slice_buffer_slice_peek(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr); + [DllImport(ImportName)] public static extern void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer); @@ -1141,6 +1157,12 @@ namespace Grpc.Core.Internal [DllImport(ImportName)] public static extern IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace); + [DllImport(ImportName)] + public static extern UIntPtr grpcsharp_slice_buffer_slice_count(SliceBufferSafeHandle sliceBuffer); + + [DllImport(ImportName)] + public static extern void grpcsharp_slice_buffer_slice_peek(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr); + [DllImport(ImportName)] public static extern void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer); diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index e271494c942..1f115b1caf2 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -1196,6 +1196,19 @@ grpcsharp_slice_buffer_destroy(grpc_slice_buffer* buffer) { gpr_free(buffer); } +GPR_EXPORT size_t GPR_CALLTYPE +grpcsharp_slice_buffer_slice_count(grpc_slice_buffer* buffer) { + return buffer->count; +} + +GPR_EXPORT void GPR_CALLTYPE +grpcsharp_slice_buffer_slice_peek(grpc_slice_buffer* buffer, size_t index, size_t* slice_len, uint8_t** slice_data_ptr) { + GPR_ASSERT(buffer->count > index); + grpc_slice* slice_ptr = &buffer->slices[index]; + *slice_len = GRPC_SLICE_LENGTH(*slice_ptr); + *slice_data_ptr = GRPC_SLICE_START_PTR(*slice_ptr); +} + GPR_EXPORT grpc_byte_buffer* GPR_CALLTYPE grpcsharp_create_byte_buffer_from_stolen_slices(grpc_slice_buffer* slice_buffer) { grpc_byte_buffer* bb = @@ -1217,6 +1230,10 @@ GPR_EXPORT void* GPR_CALLTYPE grpcsharp_slice_buffer_adjust_tail_space(grpc_slice_buffer* buffer, size_t available_tail_space, size_t requested_tail_space) { + if (available_tail_space == 0 && requested_tail_space == 0) + { + return NULL; + } // TODO: what if available_tail_space == requested_tail_space == 0 if (available_tail_space >= requested_tail_space) diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c index bc312bc6daf..9007d7f3ad0 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c @@ -382,6 +382,14 @@ void grpcsharp_slice_buffer_adjust_tail_space() { fprintf(stderr, "Should never reach here"); abort(); } +void grpcsharp_slice_buffer_slice_count() { + fprintf(stderr, "Should never reach here"); + abort(); +} +void grpcsharp_slice_buffer_slice_peek() { + fprintf(stderr, "Should never reach here"); + abort(); +} void grpcsharp_slice_buffer_destroy() { fprintf(stderr, "Should never reach here"); abort(); diff --git a/templates/src/csharp/Grpc.Core/Internal/native_methods.include b/templates/src/csharp/Grpc.Core/Internal/native_methods.include index d8f94744723..055af4a7a27 100644 --- a/templates/src/csharp/Grpc.Core/Internal/native_methods.include +++ b/templates/src/csharp/Grpc.Core/Internal/native_methods.include @@ -90,6 +90,8 @@ native_method_signatures = [ 'void grpcsharp_auth_context_release(IntPtr authContext)', 'SliceBufferSafeHandle grpcsharp_slice_buffer_create()', 'IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace)', + 'UIntPtr grpcsharp_slice_buffer_slice_count(SliceBufferSafeHandle sliceBuffer)', + 'void grpcsharp_slice_buffer_slice_peek(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr)', 'void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer)', 'Timespec gprsharp_now(ClockType clockType)', 'Timespec gprsharp_inf_future(ClockType clockType)', From 1154c2d17ea07d0b95dd6f4ac8776c4f3841570e Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 29 Jul 2019 19:58:36 -0700 Subject: [PATCH 1174/1555] fixup: add SliceBufferSafeHandle --- .../Internal/SliceBufferSafeHandle.cs | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs diff --git a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs new file mode 100644 index 00000000000..ef9e7fbce37 --- /dev/null +++ b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs @@ -0,0 +1,122 @@ +#region Copyright notice and license + +// Copyright 2019 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using System.Runtime.InteropServices; +using Grpc.Core; +using Grpc.Core.Logging; +using Grpc.Core.Utils; + +namespace Grpc.Core.Internal +{ + /// + /// grpc_slice_buffer + /// + internal class SliceBufferSafeHandle : SafeHandleZeroIsInvalid + { + static readonly NativeMethods Native = NativeMethods.Get(); + static readonly ILogger Logger = GrpcEnvironment.Logger.ForType(); + + private IntPtr tailSpacePtr; + private UIntPtr tailSpaceLen; + + + private SliceBufferSafeHandle() + { + } + + public static SliceBufferSafeHandle Create() + { + return Native.grpcsharp_slice_buffer_create(); + } + + public IntPtr Handle + { + get + { + return handle; + } + } + + public void Advance(int count) + { + GrpcPreconditions.CheckArgument(count >= 0); + GrpcPreconditions.CheckArgument(tailSpacePtr != IntPtr.Zero || count == 0); + GrpcPreconditions.CheckArgument(tailSpaceLen.ToUInt64() >= (ulong)count); + tailSpaceLen = new UIntPtr(tailSpaceLen.ToUInt64() - (ulong)count); + tailSpacePtr += count; + } + + public unsafe Span GetSpan(int sizeHint) + { + GrpcPreconditions.CheckArgument(sizeHint >= 0); + if (tailSpaceLen.ToUInt64() < (ulong) sizeHint) + { + // TODO: should we ignore the hint sometimes when + // available tail space is close enough to the sizeHint? + AdjustTailSpace(sizeHint); + } + return new Span(tailSpacePtr.ToPointer(), (int) tailSpaceLen.ToUInt64()); + } + + public void Complete() + { + AdjustTailSpace(0); + } + + public byte[] GetPayload() + { + ulong sliceCount = Native.grpcsharp_slice_buffer_slice_count(this).ToUInt64(); + + Slice[] slices = new Slice[sliceCount]; + int totalLen = 0; + for (int i = 0; i < (int) sliceCount; i++) + { + Native.grpcsharp_slice_buffer_slice_peek(this, new UIntPtr((ulong) i), out UIntPtr sliceLen, out IntPtr dataPtr); + slices[i] = new Slice(dataPtr, (int) sliceLen.ToUInt64()); + totalLen += (int) sliceLen.ToUInt64(); + + } + var result = new byte[totalLen]; + int offset = 0; + for (int i = 0; i < (int) sliceCount; i++) + { + slices[i].ToSpanUnsafe().CopyTo(result.AsSpan(offset, slices[i].Length)); + offset += slices[i].Length; + } + GrpcPreconditions.CheckState(totalLen == offset); + return result; + } + // TODO: converting contents to byte[] + + // Gets data of server_rpc_new completion. + private void AdjustTailSpace(int requestedSize) + { + GrpcPreconditions.CheckArgument(requestedSize >= 0); + var requestedTailSpaceLen = new UIntPtr((ulong) requestedSize); + tailSpacePtr = Native.grpcsharp_slice_buffer_adjust_tail_space(this, tailSpaceLen, requestedTailSpaceLen); + tailSpaceLen = requestedTailSpaceLen; + } + + protected override bool ReleaseHandle() + { + Native.grpcsharp_slice_buffer_destroy(handle); + return true; + } + } +} From b9183153211d109ba57598812ee8d90a12236443 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 30 Jul 2019 16:16:56 -0700 Subject: [PATCH 1175/1555] a bit of refactor --- src/csharp/Grpc.Core/Internal/AsyncCallBase.cs | 2 +- src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs index 23cb5ccffc7..b26b7921955 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs @@ -220,7 +220,7 @@ namespace Grpc.Core.Internal { context = DefaultSerializationContext.GetInitializedThreadLocal(); serializer(msg, context); - return context.GetPayload().GetPayload(); + return context.GetPayload().ToByteArray(); } finally { diff --git a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs index ef9e7fbce37..5b540c69d44 100644 --- a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs @@ -79,7 +79,9 @@ namespace Grpc.Core.Internal AdjustTailSpace(0); } - public byte[] GetPayload() + // copies the content of the slice buffer to a newly allocated byte array + // due to its overhead, this method should only be used for testing. + public byte[] ToByteArray() { ulong sliceCount = Native.grpcsharp_slice_buffer_slice_count(this).ToUInt64(); @@ -102,7 +104,6 @@ namespace Grpc.Core.Internal GrpcPreconditions.CheckState(totalLen == offset); return result; } - // TODO: converting contents to byte[] // Gets data of server_rpc_new completion. private void AdjustTailSpace(int requestedSize) @@ -112,7 +113,6 @@ namespace Grpc.Core.Internal tailSpacePtr = Native.grpcsharp_slice_buffer_adjust_tail_space(this, tailSpaceLen, requestedTailSpaceLen); tailSpaceLen = requestedTailSpaceLen; } - protected override bool ReleaseHandle() { Native.grpcsharp_slice_buffer_destroy(handle); From 31eff3e679f12f3db28c80527f7f376c1beb8efd Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 30 Jul 2019 17:16:49 -0700 Subject: [PATCH 1176/1555] stuff builds but tests crash --- .../Internal/FakeNativeCall.cs | 10 +-- src/csharp/Grpc.Core/Internal/AsyncCall.cs | 6 +- .../Grpc.Core/Internal/AsyncCallBase.cs | 6 +- .../Grpc.Core/Internal/AsyncCallServer.cs | 2 +- .../Grpc.Core/Internal/CallSafeHandle.cs | 26 +++---- src/csharp/Grpc.Core/Internal/INativeCall.cs | 10 +-- .../Internal/NativeMethods.Generated.cs | 30 ++++----- .../SendMessageBenchmark.cs | 5 +- .../UnaryCallOverheadBenchmark.cs | 4 +- src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs | 2 +- src/csharp/ext/grpc_csharp_ext.c | 67 ++++++++++--------- .../Grpc.Core/Internal/native_methods.include | 10 +-- 12 files changed, 91 insertions(+), 87 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/Internal/FakeNativeCall.cs b/src/csharp/Grpc.Core.Tests/Internal/FakeNativeCall.cs index ef67918dabb..c16b55ca941 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/FakeNativeCall.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/FakeNativeCall.cs @@ -101,13 +101,13 @@ namespace Grpc.Core.Internal.Tests return "PEER"; } - public void StartUnary(IUnaryResponseClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) + public void StartUnary(IUnaryResponseClientCallback callback, SliceBufferSafeHandle payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { StartCallMaybeFail(); UnaryResponseClientCallback = callback; } - public void StartUnary(BatchContextSafeHandle ctx, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) + public void StartUnary(BatchContextSafeHandle ctx, SliceBufferSafeHandle payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { StartCallMaybeFail(); throw new NotImplementedException(); @@ -119,7 +119,7 @@ namespace Grpc.Core.Internal.Tests UnaryResponseClientCallback = callback; } - public void StartServerStreaming(IReceivedStatusOnClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) + public void StartServerStreaming(IReceivedStatusOnClientCallback callback, SliceBufferSafeHandle payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { StartCallMaybeFail(); ReceivedStatusOnClientCallback = callback; @@ -146,7 +146,7 @@ namespace Grpc.Core.Internal.Tests SendCompletionCallback = callback; } - public void StartSendMessage(ISendCompletionCallback callback, byte[] payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata) + public void StartSendMessage(ISendCompletionCallback callback, SliceBufferSafeHandle payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata) { SendCompletionCallback = callback; } @@ -157,7 +157,7 @@ namespace Grpc.Core.Internal.Tests } public void StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, - byte[] optionalPayload, WriteFlags writeFlags) + SliceBufferSafeHandle payload, WriteFlags writeFlags) { SendStatusFromServerCallback = callback; } diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs index ce3508d398e..aefa58a0cee 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs @@ -95,7 +95,7 @@ namespace Grpc.Core.Internal readingDone = true; } - byte[] payload = UnsafeSerialize(msg); + var payload = UnsafeSerialize(msg); using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) { @@ -160,7 +160,7 @@ namespace Grpc.Core.Internal halfcloseRequested = true; readingDone = true; - byte[] payload = UnsafeSerialize(msg); + var payload = UnsafeSerialize(msg); unaryResponseTcs = new TaskCompletionSource(); using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) @@ -235,7 +235,7 @@ namespace Grpc.Core.Internal halfcloseRequested = true; - byte[] payload = UnsafeSerialize(msg); + var payload = UnsafeSerialize(msg); streamingResponseCallFinishedTcs = new TaskCompletionSource(); using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs index b26b7921955..07f9ecf23e9 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs @@ -115,7 +115,7 @@ namespace Grpc.Core.Internal /// protected Task SendMessageInternalAsync(TWrite msg, WriteFlags writeFlags) { - byte[] payload = UnsafeSerialize(msg); + var payload = UnsafeSerialize(msg); lock (myLock) { @@ -213,14 +213,14 @@ namespace Grpc.Core.Internal /// protected abstract Task CheckSendAllowedOrEarlyResult(); - protected byte[] UnsafeSerialize(TWrite msg) + protected SliceBufferSafeHandle UnsafeSerialize(TWrite msg) { DefaultSerializationContext context = null; try { context = DefaultSerializationContext.GetInitializedThreadLocal(); serializer(msg, context); - return context.GetPayload().ToByteArray(); + return context.GetPayload(); } finally { diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs index 0bf1fb3b7dd..e1c3a215422 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs @@ -129,7 +129,7 @@ namespace Grpc.Core.Internal /// public Task SendStatusFromServerAsync(Status status, Metadata trailers, ResponseWithFlags? optionalWrite) { - byte[] payload = optionalWrite.HasValue ? UnsafeSerialize(optionalWrite.Value.Response) : null; + var payload = optionalWrite.HasValue ? UnsafeSerialize(optionalWrite.Value.Response) : null; var writeFlags = optionalWrite.HasValue ? optionalWrite.Value.WriteFlags : default(WriteFlags); lock (myLock) diff --git a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs index 2e637c9704b..6208f45a00a 100644 --- a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs @@ -67,19 +67,19 @@ namespace Grpc.Core.Internal Native.grpcsharp_call_set_credentials(this, credentials).CheckOk(); } - public void StartUnary(IUnaryResponseClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) + public void StartUnary(IUnaryResponseClientCallback callback, SliceBufferSafeHandle payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { using (completionQueue.NewScope()) { var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_IUnaryResponseClientCallback, callback); - Native.grpcsharp_call_start_unary(this, ctx, payload, new UIntPtr((ulong)payload.Length), writeFlags, metadataArray, callFlags) + Native.grpcsharp_call_start_unary(this, ctx, payload, writeFlags, metadataArray, callFlags) .CheckOk(); } } - public void StartUnary(BatchContextSafeHandle ctx, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) + public void StartUnary(BatchContextSafeHandle ctx, SliceBufferSafeHandle payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { - Native.grpcsharp_call_start_unary(this, ctx, payload, new UIntPtr((ulong)payload.Length), writeFlags, metadataArray, callFlags) + Native.grpcsharp_call_start_unary(this, ctx, payload, writeFlags, metadataArray, callFlags) .CheckOk(); } @@ -92,12 +92,12 @@ namespace Grpc.Core.Internal } } - public void StartServerStreaming(IReceivedStatusOnClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) + public void StartServerStreaming(IReceivedStatusOnClientCallback callback, SliceBufferSafeHandle payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { using (completionQueue.NewScope()) { var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_IReceivedStatusOnClientCallback, callback); - Native.grpcsharp_call_start_server_streaming(this, ctx, payload, new UIntPtr((ulong)payload.Length), writeFlags, metadataArray, callFlags).CheckOk(); + Native.grpcsharp_call_start_server_streaming(this, ctx, payload, writeFlags, metadataArray, callFlags).CheckOk(); } } @@ -110,12 +110,12 @@ namespace Grpc.Core.Internal } } - public void StartSendMessage(ISendCompletionCallback callback, byte[] payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata) + public void StartSendMessage(ISendCompletionCallback callback, SliceBufferSafeHandle payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata) { using (completionQueue.NewScope()) { var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_ISendCompletionCallback, callback); - Native.grpcsharp_call_send_message(this, ctx, payload, new UIntPtr((ulong)payload.Length), writeFlags, sendEmptyInitialMetadata ? 1 : 0).CheckOk(); + Native.grpcsharp_call_send_message(this, ctx, payload, writeFlags, sendEmptyInitialMetadata ? 1 : 0).CheckOk(); } } @@ -129,13 +129,13 @@ namespace Grpc.Core.Internal } public void StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, - byte[] optionalPayload, WriteFlags writeFlags) + SliceBufferSafeHandle optionalPayload, WriteFlags writeFlags) { + // TODO: optionalPayload == null -> pass null SliceBufferSafeHandle using (completionQueue.NewScope()) { var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_ISendStatusFromServerCompletionCallback, callback); - var optionalPayloadLength = optionalPayload != null ? new UIntPtr((ulong)optionalPayload.Length) : UIntPtr.Zero; - + const int MaxStackAllocBytes = 256; int maxBytes = MarshalUtils.GetMaxByteCountUTF8(status.Detail); if (maxBytes > MaxStackAllocBytes) @@ -156,7 +156,7 @@ namespace Grpc.Core.Internal byte* ptr = stackalloc byte[maxBytes]; int statusBytes = MarshalUtils.GetBytesUTF8(status.Detail, ptr, maxBytes); Native.grpcsharp_call_send_status_from_server(this, ctx, status.StatusCode, new IntPtr(ptr), new UIntPtr((ulong)statusBytes), metadataArray, sendEmptyInitialMetadata ? 1 : 0, - optionalPayload, optionalPayloadLength, writeFlags).CheckOk(); + optionalPayload, writeFlags).CheckOk(); } else { // for larger status (rare), rent a buffer from the pool and @@ -168,7 +168,7 @@ namespace Grpc.Core.Internal { int statusBytes = MarshalUtils.GetBytesUTF8(status.Detail, ptr, maxBytes); Native.grpcsharp_call_send_status_from_server(this, ctx, status.StatusCode, new IntPtr(ptr), new UIntPtr((ulong)statusBytes), metadataArray, sendEmptyInitialMetadata ? 1 : 0, - optionalPayload, optionalPayloadLength, writeFlags).CheckOk(); + optionalPayload, writeFlags).CheckOk(); } } finally diff --git a/src/csharp/Grpc.Core/Internal/INativeCall.cs b/src/csharp/Grpc.Core/Internal/INativeCall.cs index 98117c6988a..70e98bfc9af 100644 --- a/src/csharp/Grpc.Core/Internal/INativeCall.cs +++ b/src/csharp/Grpc.Core/Internal/INativeCall.cs @@ -67,13 +67,13 @@ namespace Grpc.Core.Internal string GetPeer(); - void StartUnary(IUnaryResponseClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags); + void StartUnary(IUnaryResponseClientCallback callback, SliceBufferSafeHandle payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags); - void StartUnary(BatchContextSafeHandle ctx, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags); + void StartUnary(BatchContextSafeHandle ctx, SliceBufferSafeHandle payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags); void StartClientStreaming(IUnaryResponseClientCallback callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags); - void StartServerStreaming(IReceivedStatusOnClientCallback callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags); + void StartServerStreaming(IReceivedStatusOnClientCallback callback, SliceBufferSafeHandle payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags); void StartDuplexStreaming(IReceivedStatusOnClientCallback callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags); @@ -83,11 +83,11 @@ namespace Grpc.Core.Internal void StartSendInitialMetadata(ISendCompletionCallback callback, MetadataArraySafeHandle metadataArray); - void StartSendMessage(ISendCompletionCallback callback, byte[] payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata); + void StartSendMessage(ISendCompletionCallback callback, SliceBufferSafeHandle payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata); void StartSendCloseFromClient(ISendCompletionCallback callback); - void StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, byte[] optionalPayload, WriteFlags writeFlags); + void StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, SliceBufferSafeHandle optionalPayload, WriteFlags writeFlags); void StartServerSide(IReceivedCloseOnServerCallback callback); } diff --git a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs index dcb0f84649c..d492d0c9525 100644 --- a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs +++ b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs @@ -487,13 +487,13 @@ namespace Grpc.Core.Internal public delegate void grpcsharp_call_credentials_release_delegate(IntPtr credentials); public delegate CallError grpcsharp_call_cancel_delegate(CallSafeHandle call); public delegate CallError grpcsharp_call_cancel_with_status_delegate(CallSafeHandle call, StatusCode status, string description); - public delegate CallError grpcsharp_call_start_unary_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); + public delegate CallError grpcsharp_call_start_unary_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); public delegate CallError grpcsharp_call_start_client_streaming_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); - public delegate CallError grpcsharp_call_start_server_streaming_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); + public delegate CallError grpcsharp_call_start_server_streaming_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); public delegate CallError grpcsharp_call_start_duplex_streaming_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); - public delegate CallError grpcsharp_call_send_message_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, int sendEmptyInitialMetadata); + public delegate CallError grpcsharp_call_send_message_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, int sendEmptyInitialMetadata); public delegate CallError grpcsharp_call_send_close_from_client_delegate(CallSafeHandle call, BatchContextSafeHandle ctx); - public delegate CallError grpcsharp_call_send_status_from_server_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); + public delegate CallError grpcsharp_call_send_status_from_server_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, SliceBufferSafeHandle optionalSendBuffer, WriteFlags writeFlags); public delegate CallError grpcsharp_call_recv_message_delegate(CallSafeHandle call, BatchContextSafeHandle ctx); public delegate CallError grpcsharp_call_recv_initial_metadata_delegate(CallSafeHandle call, BatchContextSafeHandle ctx); public delegate CallError grpcsharp_call_start_serverside_delegate(CallSafeHandle call, BatchContextSafeHandle ctx); @@ -563,7 +563,7 @@ namespace Grpc.Core.Internal public delegate CallError grpcsharp_test_callback_delegate([MarshalAs(UnmanagedType.FunctionPtr)] NativeCallbackTestDelegate callback); public delegate IntPtr grpcsharp_test_nop_delegate(IntPtr ptr); public delegate void grpcsharp_test_override_method_delegate(string methodName, string variant); - public delegate CallError grpcsharp_test_call_start_unary_echo_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); + public delegate CallError grpcsharp_test_call_start_unary_echo_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); } /// @@ -649,25 +649,25 @@ namespace Grpc.Core.Internal public static extern CallError grpcsharp_call_cancel_with_status(CallSafeHandle call, StatusCode status, string description); [DllImport(ImportName)] - public static extern CallError grpcsharp_call_start_unary(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); + public static extern CallError grpcsharp_call_start_unary(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); [DllImport(ImportName)] public static extern CallError grpcsharp_call_start_client_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); [DllImport(ImportName)] - public static extern CallError grpcsharp_call_start_server_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); + public static extern CallError grpcsharp_call_start_server_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); [DllImport(ImportName)] public static extern CallError grpcsharp_call_start_duplex_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); [DllImport(ImportName)] - public static extern CallError grpcsharp_call_send_message(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, int sendEmptyInitialMetadata); + public static extern CallError grpcsharp_call_send_message(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, int sendEmptyInitialMetadata); [DllImport(ImportName)] public static extern CallError grpcsharp_call_send_close_from_client(CallSafeHandle call, BatchContextSafeHandle ctx); [DllImport(ImportName)] - public static extern CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); + public static extern CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, SliceBufferSafeHandle optionalSendBuffer, WriteFlags writeFlags); [DllImport(ImportName)] public static extern CallError grpcsharp_call_recv_message(CallSafeHandle call, BatchContextSafeHandle ctx); @@ -877,7 +877,7 @@ namespace Grpc.Core.Internal public static extern void grpcsharp_test_override_method(string methodName, string variant); [DllImport(ImportName)] - public static extern CallError grpcsharp_test_call_start_unary_echo(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); + public static extern CallError grpcsharp_test_call_start_unary_echo(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); } /// @@ -963,25 +963,25 @@ namespace Grpc.Core.Internal public static extern CallError grpcsharp_call_cancel_with_status(CallSafeHandle call, StatusCode status, string description); [DllImport(ImportName)] - public static extern CallError grpcsharp_call_start_unary(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); + public static extern CallError grpcsharp_call_start_unary(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); [DllImport(ImportName)] public static extern CallError grpcsharp_call_start_client_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); [DllImport(ImportName)] - public static extern CallError grpcsharp_call_start_server_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); + public static extern CallError grpcsharp_call_start_server_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); [DllImport(ImportName)] public static extern CallError grpcsharp_call_start_duplex_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); [DllImport(ImportName)] - public static extern CallError grpcsharp_call_send_message(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, int sendEmptyInitialMetadata); + public static extern CallError grpcsharp_call_send_message(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, int sendEmptyInitialMetadata); [DllImport(ImportName)] public static extern CallError grpcsharp_call_send_close_from_client(CallSafeHandle call, BatchContextSafeHandle ctx); [DllImport(ImportName)] - public static extern CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); + public static extern CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, SliceBufferSafeHandle optionalSendBuffer, WriteFlags writeFlags); [DllImport(ImportName)] public static extern CallError grpcsharp_call_recv_message(CallSafeHandle call, BatchContextSafeHandle ctx); @@ -1191,7 +1191,7 @@ namespace Grpc.Core.Internal public static extern void grpcsharp_test_override_method(string methodName, string variant); [DllImport(ImportName)] - public static extern CallError grpcsharp_test_call_start_unary_echo(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); + public static extern CallError grpcsharp_test_call_start_unary_echo(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); } } } diff --git a/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs index 8496813efb0..76c59ca579c 100644 --- a/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs @@ -50,11 +50,14 @@ namespace Grpc.Microbenchmarks var call = CreateFakeCall(cq); var sendCompletionCallback = new NopSendCompletionCallback(); - var payload = new byte[PayloadSize]; + var payload = SliceBufferSafeHandle.Create(); + payload.GetSpan(PayloadSize); + payload.Advance(PayloadSize); var writeFlags = default(WriteFlags); for (int i = 0; i < Iterations; i++) { + // TODO: sending for the first time actually steals the slices... call.StartSendMessage(sendCompletionCallback, payload, writeFlags, false); var callback = completionRegistry.Extract(completionRegistry.LastRegisteredKey); callback.OnComplete(true); diff --git a/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs index 8448f03dd62..177a49d9223 100644 --- a/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs @@ -70,8 +70,8 @@ namespace Grpc.Microbenchmarks var native = NativeMethods.Get(); // replace the implementation of a native method with a fake - NativeMethods.Delegates.grpcsharp_call_start_unary_delegate fakeCallStartUnary = (CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags) => { - return native.grpcsharp_test_call_start_unary_echo(call, ctx, sendBuffer, sendBufferLen, writeFlags, metadataArray, metadataFlags); + NativeMethods.Delegates.grpcsharp_call_start_unary_delegate fakeCallStartUnary = (CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags) => { + return native.grpcsharp_test_call_start_unary_echo(call, ctx, sendBuffer, writeFlags, metadataArray, metadataFlags); }; native.GetType().GetField(nameof(native.grpcsharp_call_start_unary)).SetValue(native, fakeCallStartUnary); diff --git a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs index a59afa19118..e5bac1967c9 100644 --- a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs +++ b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs @@ -61,7 +61,7 @@ namespace Grpc.Microbenchmarks var native = NativeMethods.Get(); // nop the native-call via reflection - NativeMethods.Delegates.grpcsharp_call_send_status_from_server_delegate nop = (CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags) => { + NativeMethods.Delegates.grpcsharp_call_send_status_from_server_delegate nop = (CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, SliceBufferSafeHandle optionalSendBuffer, WriteFlags writeFlags) => { completionRegistry.Extract(ctx.Handle).OnComplete(true); // drain the dictionary as we go return CallError.OK; }; diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 1f115b1caf2..abddbc0e7a1 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -41,10 +41,26 @@ #define GPR_CALLTYPE #endif -grpc_byte_buffer* string_to_byte_buffer(const char* buffer, size_t len) { - grpc_slice slice = grpc_slice_from_copied_buffer(buffer, len); - grpc_byte_buffer* bb = grpc_raw_byte_buffer_create(&slice, 1); - grpc_slice_unref(slice); +//grpc_byte_buffer* string_to_byte_buffer(const char* buffer, size_t len) { +// grpc_slice slice = grpc_slice_from_copied_buffer(buffer, len); +// grpc_byte_buffer* bb = grpc_raw_byte_buffer_create(&slice, 1); +// grpc_slice_unref(slice); +// return bb; +//} + +static grpc_byte_buffer* grpcsharp_create_byte_buffer_from_stolen_slices(grpc_slice_buffer* slice_buffer) { + grpc_byte_buffer* bb = + (grpc_byte_buffer*)gpr_malloc(sizeof(grpc_byte_buffer)); + memset(bb, 0, sizeof(grpc_byte_buffer)); + bb->type = GRPC_BB_RAW; + bb->data.raw.compression = GRPC_COMPRESS_NONE; + bb->data.raw.slice_buffer = *slice_buffer; + // TODO: just use move slice_buffer... + + // we transferred the ownership of members from the slice buffer to the + // the internals of byte buffer, so we just overwrite the original slice buffer with + // default values. + grpc_slice_buffer_init(slice_buffer); // TODO: need to reset available_tail_space after this.. return bb; } @@ -582,8 +598,8 @@ static grpc_call_error grpcsharp_call_start_batch(grpc_call* call, } GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_unary( - grpc_call* call, grpcsharp_batch_context* ctx, const char* send_buffer, - size_t send_buffer_len, uint32_t write_flags, + grpc_call* call, grpcsharp_batch_context* ctx, grpc_slice_buffer* send_buffer, + uint32_t write_flags, grpc_metadata_array* initial_metadata, uint32_t initial_metadata_flags) { /* TODO: don't use magic number */ grpc_op ops[6]; @@ -598,7 +614,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_unary( ops[0].reserved = NULL; ops[1].op = GRPC_OP_SEND_MESSAGE; - ctx->send_message = string_to_byte_buffer(send_buffer, send_buffer_len); + ctx->send_message = grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); ops[1].data.send_message.send_message = ctx->send_message; ops[1].flags = write_flags; ops[1].reserved = NULL; @@ -635,12 +651,12 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_unary( /* Only for testing. Shortcircuits the unary call logic and only echoes the message as if it was received from the server */ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_test_call_start_unary_echo( - grpc_call* call, grpcsharp_batch_context* ctx, const char* send_buffer, - size_t send_buffer_len, uint32_t write_flags, + grpc_call* call, grpcsharp_batch_context* ctx, grpc_slice_buffer* send_buffer, + uint32_t write_flags, grpc_metadata_array* initial_metadata, uint32_t initial_metadata_flags) { // prepare as if we were performing a normal RPC. grpc_byte_buffer* send_message = - string_to_byte_buffer(send_buffer, send_buffer_len); + grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); ctx->recv_message = send_message; // echo message sent by the client as if // received from server. @@ -693,8 +709,8 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_client_streaming( } GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_server_streaming( - grpc_call* call, grpcsharp_batch_context* ctx, const char* send_buffer, - size_t send_buffer_len, uint32_t write_flags, + grpc_call* call, grpcsharp_batch_context* ctx, grpc_slice_buffer* send_buffer, + uint32_t write_flags, grpc_metadata_array* initial_metadata, uint32_t initial_metadata_flags) { /* TODO: don't use magic number */ grpc_op ops[4]; @@ -709,7 +725,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_server_streaming( ops[0].reserved = NULL; ops[1].op = GRPC_OP_SEND_MESSAGE; - ctx->send_message = string_to_byte_buffer(send_buffer, send_buffer_len); + ctx->send_message = grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); ops[1].data.send_message.send_message = ctx->send_message; ops[1].flags = write_flags; ops[1].reserved = NULL; @@ -776,15 +792,15 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_recv_initial_metadata( } GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_message( - grpc_call* call, grpcsharp_batch_context* ctx, const char* send_buffer, - size_t send_buffer_len, uint32_t write_flags, + grpc_call* call, grpcsharp_batch_context* ctx, grpc_slice_buffer* send_buffer, + uint32_t write_flags, int32_t send_empty_initial_metadata) { /* TODO: don't use magic number */ grpc_op ops[2]; memset(ops, 0, sizeof(ops)); size_t nops = send_empty_initial_metadata ? 2 : 1; ops[0].op = GRPC_OP_SEND_MESSAGE; - ctx->send_message = string_to_byte_buffer(send_buffer, send_buffer_len); + ctx->send_message = grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); ops[0].data.send_message.send_message = ctx->send_message; ops[0].flags = write_flags; ops[0].reserved = NULL; @@ -811,7 +827,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_status_from_server( grpc_call* call, grpcsharp_batch_context* ctx, grpc_status_code status_code, const char* status_details, size_t status_details_len, grpc_metadata_array* trailing_metadata, int32_t send_empty_initial_metadata, - const char* optional_send_buffer, size_t optional_send_buffer_len, + grpc_slice_buffer* optional_send_buffer, uint32_t write_flags) { /* TODO: don't use magic number */ grpc_op ops[3]; @@ -833,7 +849,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_status_from_server( if (optional_send_buffer) { ops[nops].op = GRPC_OP_SEND_MESSAGE; ctx->send_message = - string_to_byte_buffer(optional_send_buffer, optional_send_buffer_len); + grpcsharp_create_byte_buffer_from_stolen_slices(optional_send_buffer); ops[nops].data.send_message.send_message = ctx->send_message; ops[nops].flags = write_flags; ops[nops].reserved = NULL; @@ -1209,22 +1225,7 @@ grpcsharp_slice_buffer_slice_peek(grpc_slice_buffer* buffer, size_t index, size_ *slice_data_ptr = GRPC_SLICE_START_PTR(*slice_ptr); } -GPR_EXPORT grpc_byte_buffer* GPR_CALLTYPE -grpcsharp_create_byte_buffer_from_stolen_slices(grpc_slice_buffer* slice_buffer) { - grpc_byte_buffer* bb = - (grpc_byte_buffer*)gpr_malloc(sizeof(grpc_byte_buffer)); - memset(bb, 0, sizeof(grpc_byte_buffer)); - bb->type = GRPC_BB_RAW; - bb->data.raw.compression = GRPC_COMPRESS_NONE; - bb->data.raw.slice_buffer = *slice_buffer; - // TODO: just use move slice_buffer... - // we transferred the ownership of members from the slice buffer to the - // the internals of byte buffer, so we just overwrite the original slice buffer with - // default values. - grpc_slice_buffer_init(slice_buffer); // TODO: need to reset available_tail_space after this.. - return bb; -} GPR_EXPORT void* GPR_CALLTYPE grpcsharp_slice_buffer_adjust_tail_space(grpc_slice_buffer* buffer, size_t available_tail_space, diff --git a/templates/src/csharp/Grpc.Core/Internal/native_methods.include b/templates/src/csharp/Grpc.Core/Internal/native_methods.include index 055af4a7a27..4f5f61d332c 100644 --- a/templates/src/csharp/Grpc.Core/Internal/native_methods.include +++ b/templates/src/csharp/Grpc.Core/Internal/native_methods.include @@ -25,13 +25,13 @@ native_method_signatures = [ 'void grpcsharp_call_credentials_release(IntPtr credentials)', 'CallError grpcsharp_call_cancel(CallSafeHandle call)', 'CallError grpcsharp_call_cancel_with_status(CallSafeHandle call, StatusCode status, string description)', - 'CallError grpcsharp_call_start_unary(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', + 'CallError grpcsharp_call_start_unary(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', 'CallError grpcsharp_call_start_client_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', - 'CallError grpcsharp_call_start_server_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', + 'CallError grpcsharp_call_start_server_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', 'CallError grpcsharp_call_start_duplex_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', - 'CallError grpcsharp_call_send_message(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, int sendEmptyInitialMetadata)', + 'CallError grpcsharp_call_send_message(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, int sendEmptyInitialMetadata)', 'CallError grpcsharp_call_send_close_from_client(CallSafeHandle call, BatchContextSafeHandle ctx)', - 'CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags)', + 'CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, IntPtr statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, SliceBufferSafeHandle optionalSendBuffer, WriteFlags writeFlags)', 'CallError grpcsharp_call_recv_message(CallSafeHandle call, BatchContextSafeHandle ctx)', 'CallError grpcsharp_call_recv_initial_metadata(CallSafeHandle call, BatchContextSafeHandle ctx)', 'CallError grpcsharp_call_start_serverside(CallSafeHandle call, BatchContextSafeHandle ctx)', @@ -101,7 +101,7 @@ native_method_signatures = [ 'CallError grpcsharp_test_callback([MarshalAs(UnmanagedType.FunctionPtr)] NativeCallbackTestDelegate callback)', 'IntPtr grpcsharp_test_nop(IntPtr ptr)', 'void grpcsharp_test_override_method(string methodName, string variant)', - 'CallError grpcsharp_test_call_start_unary_echo(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', + 'CallError grpcsharp_test_call_start_unary_echo(CallSafeHandle call, BatchContextSafeHandle ctx, SliceBufferSafeHandle sendBuffer, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', ] import re From 8ad2b146ed5caa995c89726de59c375935145cb4 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 30 Jul 2019 17:38:08 -0700 Subject: [PATCH 1177/1555] fix grpcsharp_create_byte_buffer_from_stolen_slices --- src/csharp/ext/grpc_csharp_ext.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index abddbc0e7a1..82fa81abf7d 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -41,26 +41,15 @@ #define GPR_CALLTYPE #endif -//grpc_byte_buffer* string_to_byte_buffer(const char* buffer, size_t len) { -// grpc_slice slice = grpc_slice_from_copied_buffer(buffer, len); -// grpc_byte_buffer* bb = grpc_raw_byte_buffer_create(&slice, 1); -// grpc_slice_unref(slice); -// return bb; -//} - static grpc_byte_buffer* grpcsharp_create_byte_buffer_from_stolen_slices(grpc_slice_buffer* slice_buffer) { grpc_byte_buffer* bb = - (grpc_byte_buffer*)gpr_malloc(sizeof(grpc_byte_buffer)); + (grpc_byte_buffer*)gpr_malloc(sizeof(grpc_byte_buffer)); memset(bb, 0, sizeof(grpc_byte_buffer)); bb->type = GRPC_BB_RAW; bb->data.raw.compression = GRPC_COMPRESS_NONE; - bb->data.raw.slice_buffer = *slice_buffer; - // TODO: just use move slice_buffer... + grpc_slice_buffer_init(&bb->data.raw.slice_buffer); - // we transferred the ownership of members from the slice buffer to the - // the internals of byte buffer, so we just overwrite the original slice buffer with - // default values. - grpc_slice_buffer_init(slice_buffer); // TODO: need to reset available_tail_space after this.. + grpc_slice_buffer_swap(&bb->data.raw.slice_buffer, slice_buffer); return bb; } From 70c7aa162354188f25aa790bdc7a7443c00f2af1 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 30 Jul 2019 18:07:12 -0700 Subject: [PATCH 1178/1555] stuff now works --- src/csharp/Grpc.Core/Internal/CallSafeHandle.cs | 6 ++++++ src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs index 6208f45a00a..cfcab5dc692 100644 --- a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs @@ -132,6 +132,12 @@ namespace Grpc.Core.Internal SliceBufferSafeHandle optionalPayload, WriteFlags writeFlags) { // TODO: optionalPayload == null -> pass null SliceBufferSafeHandle + // do this properly + if (optionalPayload == null) + { + optionalPayload = SliceBufferSafeHandle.NullInstance; + } + using (completionQueue.NewScope()) { var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_ISendStatusFromServerCompletionCallback, callback); diff --git a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs index 5b540c69d44..5ea4432684c 100644 --- a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs @@ -32,6 +32,8 @@ namespace Grpc.Core.Internal static readonly NativeMethods Native = NativeMethods.Get(); static readonly ILogger Logger = GrpcEnvironment.Logger.ForType(); + public static readonly SliceBufferSafeHandle NullInstance = new SliceBufferSafeHandle(); + private IntPtr tailSpacePtr; private UIntPtr tailSpaceLen; From 1c177fff1e9cba4fc3632e12d39572a31fa2704f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 31 Jul 2019 16:22:50 -0700 Subject: [PATCH 1179/1555] refactoring and simplifications --- .../Internal/DefaultSerializationContext.cs | 51 ++++--------------- .../Internal/NativeMethods.Generated.cs | 11 ++++ .../Internal/SliceBufferSafeHandle.cs | 44 +++++++++++----- src/csharp/ext/grpc_csharp_ext.c | 7 ++- .../runtimes/grpc_csharp_ext_dummy_stubs.c | 4 ++ .../Grpc.Core/Internal/native_methods.include | 1 + 6 files changed, 63 insertions(+), 55 deletions(-) diff --git a/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs b/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs index 9098850a52e..db5e78a608d 100644 --- a/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs +++ b/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs @@ -30,7 +30,7 @@ namespace Grpc.Core.Internal bool isComplete; //byte[] payload; - NativeBufferWriter bufferWriter; + SliceBufferSafeHandle sliceBuffer; public DefaultSerializationContext() { @@ -43,10 +43,10 @@ namespace Grpc.Core.Internal this.isComplete = true; GetBufferWriter(); - var destSpan = bufferWriter.GetSpan(payload.Length); + var destSpan = sliceBuffer.GetSpan(payload.Length); payload.AsSpan().CopyTo(destSpan); - bufferWriter.Advance(payload.Length); - bufferWriter.Complete(); + sliceBuffer.Advance(payload.Length); + sliceBuffer.Complete(); //this.payload = payload; } @@ -55,12 +55,12 @@ namespace Grpc.Core.Internal /// public override IBufferWriter GetBufferWriter() { - if (bufferWriter == null) + if (sliceBuffer == null) { // TODO: avoid allocation.. - bufferWriter = new NativeBufferWriter(); + sliceBuffer = SliceBufferSafeHandle.Create(); } - return bufferWriter; + return sliceBuffer; } /// @@ -69,20 +69,20 @@ namespace Grpc.Core.Internal public override void Complete() { GrpcPreconditions.CheckState(!isComplete); - bufferWriter.Complete(); + sliceBuffer.Complete(); this.isComplete = true; } internal SliceBufferSafeHandle GetPayload() { - return bufferWriter.GetSliceBuffer(); + return sliceBuffer; } public void Reset() { this.isComplete = false; //this.payload = null; - this.bufferWriter = null; + this.sliceBuffer = null; // reset instead... } public static DefaultSerializationContext GetInitializedThreadLocal() @@ -92,35 +92,6 @@ namespace Grpc.Core.Internal return instance; } - private class NativeBufferWriter : IBufferWriter - { - private SliceBufferSafeHandle sliceBuffer = SliceBufferSafeHandle.Create(); - - public void Advance(int count) - { - sliceBuffer.Advance(count); - } - - public Memory GetMemory(int sizeHint = 0) - { - // TODO: implement - throw new NotImplementedException(); - } - - public Span GetSpan(int sizeHint = 0) - { - return sliceBuffer.GetSpan(sizeHint); - } - - public void Complete() - { - sliceBuffer.Complete(); - } - - public SliceBufferSafeHandle GetSliceBuffer() - { - return sliceBuffer; - } - } + } } diff --git a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs index d492d0c9525..c724b30ca8f 100644 --- a/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs +++ b/src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs @@ -126,6 +126,7 @@ namespace Grpc.Core.Internal public readonly Delegates.grpcsharp_slice_buffer_adjust_tail_space_delegate grpcsharp_slice_buffer_adjust_tail_space; public readonly Delegates.grpcsharp_slice_buffer_slice_count_delegate grpcsharp_slice_buffer_slice_count; public readonly Delegates.grpcsharp_slice_buffer_slice_peek_delegate grpcsharp_slice_buffer_slice_peek; + public readonly Delegates.grpcsharp_slice_buffer_reset_and_unref_delegate grpcsharp_slice_buffer_reset_and_unref; public readonly Delegates.grpcsharp_slice_buffer_destroy_delegate grpcsharp_slice_buffer_destroy; public readonly Delegates.gprsharp_now_delegate gprsharp_now; public readonly Delegates.gprsharp_inf_future_delegate gprsharp_inf_future; @@ -233,6 +234,7 @@ namespace Grpc.Core.Internal this.grpcsharp_slice_buffer_adjust_tail_space = GetMethodDelegate(library); this.grpcsharp_slice_buffer_slice_count = GetMethodDelegate(library); this.grpcsharp_slice_buffer_slice_peek = GetMethodDelegate(library); + this.grpcsharp_slice_buffer_reset_and_unref = GetMethodDelegate(library); this.grpcsharp_slice_buffer_destroy = GetMethodDelegate(library); this.gprsharp_now = GetMethodDelegate(library); this.gprsharp_inf_future = GetMethodDelegate(library); @@ -339,6 +341,7 @@ namespace Grpc.Core.Internal this.grpcsharp_slice_buffer_adjust_tail_space = DllImportsFromStaticLib.grpcsharp_slice_buffer_adjust_tail_space; this.grpcsharp_slice_buffer_slice_count = DllImportsFromStaticLib.grpcsharp_slice_buffer_slice_count; this.grpcsharp_slice_buffer_slice_peek = DllImportsFromStaticLib.grpcsharp_slice_buffer_slice_peek; + this.grpcsharp_slice_buffer_reset_and_unref = DllImportsFromStaticLib.grpcsharp_slice_buffer_reset_and_unref; this.grpcsharp_slice_buffer_destroy = DllImportsFromStaticLib.grpcsharp_slice_buffer_destroy; this.gprsharp_now = DllImportsFromStaticLib.gprsharp_now; this.gprsharp_inf_future = DllImportsFromStaticLib.gprsharp_inf_future; @@ -445,6 +448,7 @@ namespace Grpc.Core.Internal this.grpcsharp_slice_buffer_adjust_tail_space = DllImportsFromSharedLib.grpcsharp_slice_buffer_adjust_tail_space; this.grpcsharp_slice_buffer_slice_count = DllImportsFromSharedLib.grpcsharp_slice_buffer_slice_count; this.grpcsharp_slice_buffer_slice_peek = DllImportsFromSharedLib.grpcsharp_slice_buffer_slice_peek; + this.grpcsharp_slice_buffer_reset_and_unref = DllImportsFromSharedLib.grpcsharp_slice_buffer_reset_and_unref; this.grpcsharp_slice_buffer_destroy = DllImportsFromSharedLib.grpcsharp_slice_buffer_destroy; this.gprsharp_now = DllImportsFromSharedLib.gprsharp_now; this.gprsharp_inf_future = DllImportsFromSharedLib.gprsharp_inf_future; @@ -554,6 +558,7 @@ namespace Grpc.Core.Internal public delegate IntPtr grpcsharp_slice_buffer_adjust_tail_space_delegate(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace); public delegate UIntPtr grpcsharp_slice_buffer_slice_count_delegate(SliceBufferSafeHandle sliceBuffer); public delegate void grpcsharp_slice_buffer_slice_peek_delegate(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr); + public delegate void grpcsharp_slice_buffer_reset_and_unref_delegate(SliceBufferSafeHandle sliceBuffer); public delegate void grpcsharp_slice_buffer_destroy_delegate(IntPtr sliceBuffer); public delegate Timespec gprsharp_now_delegate(ClockType clockType); public delegate Timespec gprsharp_inf_future_delegate(ClockType clockType); @@ -849,6 +854,9 @@ namespace Grpc.Core.Internal [DllImport(ImportName)] public static extern void grpcsharp_slice_buffer_slice_peek(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr); + [DllImport(ImportName)] + public static extern void grpcsharp_slice_buffer_reset_and_unref(SliceBufferSafeHandle sliceBuffer); + [DllImport(ImportName)] public static extern void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer); @@ -1163,6 +1171,9 @@ namespace Grpc.Core.Internal [DllImport(ImportName)] public static extern void grpcsharp_slice_buffer_slice_peek(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr); + [DllImport(ImportName)] + public static extern void grpcsharp_slice_buffer_reset_and_unref(SliceBufferSafeHandle sliceBuffer); + [DllImport(ImportName)] public static extern void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer); diff --git a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs index 5ea4432684c..76a97f4a0a2 100644 --- a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs @@ -17,6 +17,7 @@ #endregion using System; +using System.Buffers; using System.Runtime.InteropServices; using Grpc.Core; using Grpc.Core.Logging; @@ -25,9 +26,10 @@ using Grpc.Core.Utils; namespace Grpc.Core.Internal { /// - /// grpc_slice_buffer + /// Represents grpc_slice_buffer with some extra utility functions to allow + /// writing data to it using the IBufferWriter interface. /// - internal class SliceBufferSafeHandle : SafeHandleZeroIsInvalid + internal class SliceBufferSafeHandle : SafeHandleZeroIsInvalid, IBufferWriter { static readonly NativeMethods Native = NativeMethods.Get(); static readonly ILogger Logger = GrpcEnvironment.Logger.ForType(); @@ -35,8 +37,7 @@ namespace Grpc.Core.Internal public static readonly SliceBufferSafeHandle NullInstance = new SliceBufferSafeHandle(); private IntPtr tailSpacePtr; - private UIntPtr tailSpaceLen; - + private int tailSpaceLen; private SliceBufferSafeHandle() { @@ -59,21 +60,30 @@ namespace Grpc.Core.Internal { GrpcPreconditions.CheckArgument(count >= 0); GrpcPreconditions.CheckArgument(tailSpacePtr != IntPtr.Zero || count == 0); - GrpcPreconditions.CheckArgument(tailSpaceLen.ToUInt64() >= (ulong)count); - tailSpaceLen = new UIntPtr(tailSpaceLen.ToUInt64() - (ulong)count); + GrpcPreconditions.CheckArgument(tailSpaceLen >= count); + tailSpaceLen = tailSpaceLen - count; tailSpacePtr += count; } - public unsafe Span GetSpan(int sizeHint) + // provides access to the "tail space" of this buffer. + // Use GetSpan when possible for better efficiency. + public Memory GetMemory(int sizeHint = 0) + { + // TODO: implement + throw new NotImplementedException(); + } + + // provides access to the "tail space" of this buffer. + public unsafe Span GetSpan(int sizeHint = 0) { GrpcPreconditions.CheckArgument(sizeHint >= 0); - if (tailSpaceLen.ToUInt64() < (ulong) sizeHint) + if (tailSpaceLen < sizeHint) { // TODO: should we ignore the hint sometimes when // available tail space is close enough to the sizeHint? AdjustTailSpace(sizeHint); } - return new Span(tailSpacePtr.ToPointer(), (int) tailSpaceLen.ToUInt64()); + return new Span(tailSpacePtr.ToPointer(), tailSpaceLen); } public void Complete() @@ -81,8 +91,17 @@ namespace Grpc.Core.Internal AdjustTailSpace(0); } + // resets the data contained by this slice buffer + public void Reset() + { + // deletes all the data in the slice buffer + tailSpacePtr = IntPtr.Zero; + tailSpaceLen = 0; + Native.grpcsharp_slice_buffer_reset_and_unref(this); + } + // copies the content of the slice buffer to a newly allocated byte array - // due to its overhead, this method should only be used for testing. + // Note that this method has a relatively high overhead and should maily be used for testing. public byte[] ToByteArray() { ulong sliceCount = Native.grpcsharp_slice_buffer_slice_count(this).ToUInt64(); @@ -111,9 +130,8 @@ namespace Grpc.Core.Internal private void AdjustTailSpace(int requestedSize) { GrpcPreconditions.CheckArgument(requestedSize >= 0); - var requestedTailSpaceLen = new UIntPtr((ulong) requestedSize); - tailSpacePtr = Native.grpcsharp_slice_buffer_adjust_tail_space(this, tailSpaceLen, requestedTailSpaceLen); - tailSpaceLen = requestedTailSpaceLen; + tailSpacePtr = Native.grpcsharp_slice_buffer_adjust_tail_space(this, new UIntPtr((ulong) tailSpaceLen), new UIntPtr((ulong) requestedSize)); + tailSpaceLen = requestedSize; } protected override bool ReleaseHandle() { diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 82fa81abf7d..78027d270dc 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -1195,6 +1195,11 @@ grpcsharp_slice_buffer_create() { return slice_buffer; } +GPR_EXPORT void GPR_CALLTYPE +grpcsharp_slice_buffer_reset_and_unref(grpc_slice_buffer* buffer) { + grpc_slice_buffer_reset_and_unref(buffer); +} + GPR_EXPORT void GPR_CALLTYPE grpcsharp_slice_buffer_destroy(grpc_slice_buffer* buffer) { grpc_slice_buffer_destroy(buffer); @@ -1214,8 +1219,6 @@ grpcsharp_slice_buffer_slice_peek(grpc_slice_buffer* buffer, size_t index, size_ *slice_data_ptr = GRPC_SLICE_START_PTR(*slice_ptr); } - - GPR_EXPORT void* GPR_CALLTYPE grpcsharp_slice_buffer_adjust_tail_space(grpc_slice_buffer* buffer, size_t available_tail_space, size_t requested_tail_space) { diff --git a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c index 9007d7f3ad0..58a7c58e91a 100644 --- a/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c +++ b/src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c @@ -390,6 +390,10 @@ void grpcsharp_slice_buffer_slice_peek() { fprintf(stderr, "Should never reach here"); abort(); } +void grpcsharp_slice_buffer_reset_and_unref() { + fprintf(stderr, "Should never reach here"); + abort(); +} void grpcsharp_slice_buffer_destroy() { fprintf(stderr, "Should never reach here"); abort(); diff --git a/templates/src/csharp/Grpc.Core/Internal/native_methods.include b/templates/src/csharp/Grpc.Core/Internal/native_methods.include index 4f5f61d332c..f2b3a165a3b 100644 --- a/templates/src/csharp/Grpc.Core/Internal/native_methods.include +++ b/templates/src/csharp/Grpc.Core/Internal/native_methods.include @@ -92,6 +92,7 @@ native_method_signatures = [ 'IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace)', 'UIntPtr grpcsharp_slice_buffer_slice_count(SliceBufferSafeHandle sliceBuffer)', 'void grpcsharp_slice_buffer_slice_peek(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr)', + 'void grpcsharp_slice_buffer_reset_and_unref(SliceBufferSafeHandle sliceBuffer)', 'void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer)', 'Timespec gprsharp_now(ClockType clockType)', 'Timespec gprsharp_inf_future(ClockType clockType)', From aaddd42c00647a0fea619d7dfda090c038f6d7fa Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 31 Jul 2019 17:29:04 -0700 Subject: [PATCH 1180/1555] add serializationScope and refactoring for efficiency --- .../ContextualMarshallerTest.cs | 2 + src/csharp/Grpc.Core/Internal/AsyncCall.cs | 15 ++++-- .../Grpc.Core/Internal/AsyncCallBase.cs | 46 ++++++++----------- .../Grpc.Core/Internal/AsyncCallServer.cs | 39 ++++++++-------- .../Internal/DefaultSerializationContext.cs | 40 ++++++++++------ 5 files changed, 79 insertions(+), 63 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/ContextualMarshallerTest.cs b/src/csharp/Grpc.Core.Tests/ContextualMarshallerTest.cs index c3aee726f26..99f92e12628 100644 --- a/src/csharp/Grpc.Core.Tests/ContextualMarshallerTest.cs +++ b/src/csharp/Grpc.Core.Tests/ContextualMarshallerTest.cs @@ -52,6 +52,8 @@ namespace Grpc.Core.Tests } if (str == "SERIALIZE_TO_NULL") { + // TODO: test for not calling complete Complete() (that resulted in null payload before...) + // TODO: test for calling Complete(null byte array) return; } var bytes = System.Text.Encoding.UTF8.GetBytes(str); diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs index aefa58a0cee..4111c5347ce 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs @@ -95,10 +95,10 @@ namespace Grpc.Core.Internal readingDone = true; } - var payload = UnsafeSerialize(msg); - + using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope()) using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) { + var payload = UnsafeSerialize(msg, serializationScope.Context); // do before metadata array? var ctx = details.Channel.Environment.BatchContextPool.Lease(); try { @@ -160,11 +160,14 @@ namespace Grpc.Core.Internal halfcloseRequested = true; readingDone = true; - var payload = UnsafeSerialize(msg); + //var payload = UnsafeSerialize(msg); unaryResponseTcs = new TaskCompletionSource(); + using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope()) using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) { + var payload = UnsafeSerialize(msg, serializationScope.Context); // do before metadata array? + call.StartUnary(UnaryResponseClientCallback, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags); callStartedOk = true; } @@ -235,11 +238,15 @@ namespace Grpc.Core.Internal halfcloseRequested = true; - var payload = UnsafeSerialize(msg); + //var payload = UnsafeSerialize(msg); streamingResponseCallFinishedTcs = new TaskCompletionSource(); + + using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope()) using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) { + var payload = UnsafeSerialize(msg, serializationScope.Context); // do before metadata array? + call.StartServerStreaming(ReceivedStatusOnClientCallback, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags); callStartedOk = true; } diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs index 07f9ecf23e9..bd4b0d81832 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs @@ -115,23 +115,25 @@ namespace Grpc.Core.Internal /// protected Task SendMessageInternalAsync(TWrite msg, WriteFlags writeFlags) { - var payload = UnsafeSerialize(msg); - - lock (myLock) + using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope()) { - GrpcPreconditions.CheckState(started); - var earlyResult = CheckSendAllowedOrEarlyResult(); - if (earlyResult != null) + var payload = UnsafeSerialize(msg, serializationScope.Context); // do before metadata array? + lock (myLock) { - return earlyResult; + GrpcPreconditions.CheckState(started); + var earlyResult = CheckSendAllowedOrEarlyResult(); + if (earlyResult != null) + { + return earlyResult; + } + + call.StartSendMessage(SendCompletionCallback, payload, writeFlags, !initialMetadataSent); + + initialMetadataSent = true; + streamingWritesCounter++; + streamingWriteTcs = new TaskCompletionSource(); + return streamingWriteTcs.Task; } - - call.StartSendMessage(SendCompletionCallback, payload, writeFlags, !initialMetadataSent); - - initialMetadataSent = true; - streamingWritesCounter++; - streamingWriteTcs = new TaskCompletionSource(); - return streamingWriteTcs.Task; } } @@ -213,19 +215,11 @@ namespace Grpc.Core.Internal /// protected abstract Task CheckSendAllowedOrEarlyResult(); - protected SliceBufferSafeHandle UnsafeSerialize(TWrite msg) + // runs the serializer, propagating any exceptions being thrown without modifying them + protected SliceBufferSafeHandle UnsafeSerialize(TWrite msg, DefaultSerializationContext context) { - DefaultSerializationContext context = null; - try - { - context = DefaultSerializationContext.GetInitializedThreadLocal(); - serializer(msg, context); - return context.GetPayload(); - } - finally - { - context?.Reset(); - } + serializer(msg, context); + return context.GetPayload(); } protected Exception TryDeserialize(IBufferReader reader, out TRead msg) diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs index e1c3a215422..e0bb41e15dc 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs @@ -129,28 +129,31 @@ namespace Grpc.Core.Internal /// public Task SendStatusFromServerAsync(Status status, Metadata trailers, ResponseWithFlags? optionalWrite) { - var payload = optionalWrite.HasValue ? UnsafeSerialize(optionalWrite.Value.Response) : null; - var writeFlags = optionalWrite.HasValue ? optionalWrite.Value.WriteFlags : default(WriteFlags); - - lock (myLock) + using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope()) { - GrpcPreconditions.CheckState(started); - GrpcPreconditions.CheckState(!disposed); - GrpcPreconditions.CheckState(!halfcloseRequested, "Can only send status from server once."); + var payload = optionalWrite.HasValue ? UnsafeSerialize(optionalWrite.Value.Response, serializationScope.Context) : null; + var writeFlags = optionalWrite.HasValue ? optionalWrite.Value.WriteFlags : default(WriteFlags); - using (var metadataArray = MetadataArraySafeHandle.Create(trailers)) + lock (myLock) { - call.StartSendStatusFromServer(SendStatusFromServerCompletionCallback, status, metadataArray, !initialMetadataSent, - payload, writeFlags); + GrpcPreconditions.CheckState(started); + GrpcPreconditions.CheckState(!disposed); + GrpcPreconditions.CheckState(!halfcloseRequested, "Can only send status from server once."); + + using (var metadataArray = MetadataArraySafeHandle.Create(trailers)) + { + call.StartSendStatusFromServer(SendStatusFromServerCompletionCallback, status, metadataArray, !initialMetadataSent, + payload, writeFlags); + } + halfcloseRequested = true; + initialMetadataSent = true; + sendStatusFromServerTcs = new TaskCompletionSource(); + if (optionalWrite.HasValue) + { + streamingWritesCounter++; + } + return sendStatusFromServerTcs.Task; } - halfcloseRequested = true; - initialMetadataSent = true; - sendStatusFromServerTcs = new TaskCompletionSource(); - if (optionalWrite.HasValue) - { - streamingWritesCounter++; - } - return sendStatusFromServerTcs.Task; } } diff --git a/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs b/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs index db5e78a608d..6bf9da56264 100644 --- a/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs +++ b/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs @@ -29,8 +29,7 @@ namespace Grpc.Core.Internal new ThreadLocal(() => new DefaultSerializationContext(), false); bool isComplete; - //byte[] payload; - SliceBufferSafeHandle sliceBuffer; + SliceBufferSafeHandle sliceBuffer = SliceBufferSafeHandle.Create(); public DefaultSerializationContext() { @@ -42,12 +41,10 @@ namespace Grpc.Core.Internal GrpcPreconditions.CheckState(!isComplete); this.isComplete = true; - GetBufferWriter(); var destSpan = sliceBuffer.GetSpan(payload.Length); payload.AsSpan().CopyTo(destSpan); sliceBuffer.Advance(payload.Length); sliceBuffer.Complete(); - //this.payload = payload; } /// @@ -55,11 +52,6 @@ namespace Grpc.Core.Internal /// public override IBufferWriter GetBufferWriter() { - if (sliceBuffer == null) - { - // TODO: avoid allocation.. - sliceBuffer = SliceBufferSafeHandle.Create(); - } return sliceBuffer; } @@ -81,17 +73,35 @@ namespace Grpc.Core.Internal public void Reset() { this.isComplete = false; - //this.payload = null; - this.sliceBuffer = null; // reset instead... + this.sliceBuffer.Reset(); } - public static DefaultSerializationContext GetInitializedThreadLocal() + // Get a cached thread local instance of deserialization context + // and wrap it in a disposable struct that allows easy resetting + // via "using" statement. + public static UsageScope GetInitializedThreadLocalScope() { var instance = threadLocalInstance.Value; - instance.Reset(); - return instance; + return new UsageScope(instance); } - + public struct UsageScope : IDisposable + { + readonly DefaultSerializationContext context; + + public UsageScope(DefaultSerializationContext context) + { + this.context = context; + } + + public DefaultSerializationContext Context => context; + + // TODO: add Serialize method... + + public void Dispose() + { + context.Reset(); + } + } } } From 74dcdbb3c39619c1a725dc9a7e62c2cb5b62eda4 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 7 Aug 2019 12:57:38 -0700 Subject: [PATCH 1181/1555] fix adjust_tail_space --- src/csharp/ext/grpc_csharp_ext.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 78027d270dc..89391e67e15 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -1223,32 +1223,30 @@ GPR_EXPORT void* GPR_CALLTYPE grpcsharp_slice_buffer_adjust_tail_space(grpc_slice_buffer* buffer, size_t available_tail_space, size_t requested_tail_space) { - if (available_tail_space == 0 && requested_tail_space == 0) - { - return NULL; + if (available_tail_space == requested_tail_space) { + // nothing to do } - // TODO: what if available_tail_space == requested_tail_space == 0 - - if (available_tail_space >= requested_tail_space) + else if (available_tail_space >= requested_tail_space) { - // TODO: should this be allowed at all? - grpc_slice_buffer garbage; - grpc_slice_buffer_trim_end(buffer, available_tail_space - requested_tail_space, &garbage); - grpc_slice_buffer_reset_and_unref(&garbage); + grpc_slice_buffer_trim_end(buffer, available_tail_space - requested_tail_space, NULL); } else { if (available_tail_space > 0) { - grpc_slice_buffer garbage; - grpc_slice_buffer_trim_end(buffer, available_tail_space, &garbage); - grpc_slice_buffer_reset_and_unref(&garbage); + grpc_slice_buffer_trim_end(buffer, available_tail_space, NULL); } grpc_slice new_slice = grpc_slice_malloc(requested_tail_space); - grpc_slice_buffer_add(buffer, new_slice); + // TODO: this always adds as a new slice entry into the sb, but it doesn't have the problem of + // sometimes splitting the continguous new_slice across two different slices (like grpc_slice_buffer_add would) + grpc_slice_buffer_add_indexed(buffer, new_slice); } + if (buffer->count == 0) + { + return NULL; + } grpc_slice* last_slice = &(buffer->slices[buffer->count - 1]); return GRPC_SLICE_END_PTR(*last_slice) - requested_tail_space; } From f32bd8b091669f2ce1056d2ddbae694dbb54cb18 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 7 Aug 2019 12:59:57 -0700 Subject: [PATCH 1182/1555] add default serialization context test --- .../DefaultSerializationContextTest.cs | 144 ++++++++++++++++++ src/csharp/tests.json | 1 + 2 files changed, 145 insertions(+) create mode 100644 src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs diff --git a/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs b/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs new file mode 100644 index 00000000000..4d09d80bb72 --- /dev/null +++ b/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs @@ -0,0 +1,144 @@ +#region Copyright notice and license + +// Copyright 2019 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using Grpc.Core; +using Grpc.Core.Internal; +using Grpc.Core.Utils; +using NUnit.Framework; + +namespace Grpc.Core.Internal.Tests +{ + public class DefaultSerializationContextTest + { + [TestCase] + public void CompleteAllowedOnlyOnce() + { + var context = new DefaultSerializationContext(); + var buffer = GetTestBuffer(10); + + context.Complete(buffer); + Assert.Throws(typeof(InvalidOperationException), () => context.Complete(buffer)); + Assert.Throws(typeof(InvalidOperationException), () => context.Complete()); + } + + [TestCase] + public void CompleteAllowedOnlyOnce2() + { + var context = new DefaultSerializationContext(); + + context.Complete(); + Assert.Throws(typeof(InvalidOperationException), () => context.Complete(GetTestBuffer(10))); + Assert.Throws(typeof(InvalidOperationException), () => context.Complete()); + } + + [TestCase(0)] + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + [TestCase(1000)] + public void ByteArrayPayload(int payloadSize) + { + var context = new DefaultSerializationContext(); + var origPayload = GetTestBuffer(payloadSize); + + context.Complete(origPayload); + + var nativePayload = context.GetPayload().ToByteArray(); + CollectionAssert.AreEqual(origPayload, nativePayload); + } + + [TestCase(0)] + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + [TestCase(1000)] + public void BufferWriter_OneSegment(int payloadSize) + { + var context = new DefaultSerializationContext(); + var origPayload = GetTestBuffer(payloadSize); + + var bufferWriter = context.GetBufferWriter(); + origPayload.AsSpan().CopyTo(bufferWriter.GetSpan(payloadSize)); + bufferWriter.Advance(payloadSize); + // TODO: test that call to Complete() is required. + + var nativePayload = context.GetPayload().ToByteArray(); + CollectionAssert.AreEqual(origPayload, nativePayload); + } + + [TestCase(1, 4)] // small slice size tests grpc_slice with inline data + [TestCase(10, 4)] + [TestCase(100, 4)] + [TestCase(1000, 4)] + [TestCase(1, 64)] // larger slice size tests allocated grpc_slices + [TestCase(10, 64)] + [TestCase(1000, 50)] + [TestCase(1000, 64)] + public void BufferWriter_MultipleSegments(int payloadSize, int maxSliceSize) + { + var context = new DefaultSerializationContext(); + var origPayload = GetTestBuffer(payloadSize); + + var bufferWriter = context.GetBufferWriter(); + for (int offset = 0; offset < payloadSize; offset += maxSliceSize) + { + var sliceSize = Math.Min(maxSliceSize, payloadSize - offset); + // we allocate last slice as too big intentionally to test that shrinking works + var dest = bufferWriter.GetSpan(maxSliceSize); + + origPayload.AsSpan(offset, sliceSize).CopyTo(dest); + bufferWriter.Advance(sliceSize); + } + context.Complete(); + + var nativePayload = context.GetPayload().ToByteArray(); + CollectionAssert.AreEqual(origPayload, nativePayload); + + context.GetPayload().Dispose(); // TODO: do it better.. (use the scope...) + } + + // AdjustTailSpace(0) if previous tail size is 0.... + + // test that context.Complete() call is required... + + // BufferWriter.GetMemory... (add refs to the original memory?) + + // TODO: set payload and then get IBufferWriter should throw? + + // TODO: test Reset()... + + // TODO: destroy SliceBufferSafeHandles... (use usagescope...) + + + + + private byte[] GetTestBuffer(int length) + { + var testBuffer = new byte[length]; + for (int i = 0; i < testBuffer.Length; i++) + { + testBuffer[i] = (byte) i; + } + return testBuffer; + } + } +} diff --git a/src/csharp/tests.json b/src/csharp/tests.json index 2eb786e0983..75bda4c25ea 100644 --- a/src/csharp/tests.json +++ b/src/csharp/tests.json @@ -9,6 +9,7 @@ "Grpc.Core.Internal.Tests.CompletionQueueSafeHandleTest", "Grpc.Core.Internal.Tests.DefaultDeserializationContextTest", "Grpc.Core.Internal.Tests.DefaultObjectPoolTest", + "Grpc.Core.Internal.Tests.DefaultSerializationContextTest", "Grpc.Core.Internal.Tests.FakeBufferReaderManagerTest", "Grpc.Core.Internal.Tests.MetadataArraySafeHandleTest", "Grpc.Core.Internal.Tests.ReusableSliceBufferTest", From d57dec1c7dc19a245ddc74971781b53610bda4cc Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 14:03:18 -0700 Subject: [PATCH 1183/1555] improve DefaultSerializationContextTest --- .../DefaultSerializationContextTest.cs | 159 ++++++++++++------ 1 file changed, 108 insertions(+), 51 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs b/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs index 4d09d80bb72..aa7631587be 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs @@ -17,9 +17,6 @@ #endregion using System; -using System.Buffers; -using System.Collections.Generic; -using System.Runtime.InteropServices; using Grpc.Core; using Grpc.Core.Internal; using Grpc.Core.Utils; @@ -32,22 +29,28 @@ namespace Grpc.Core.Internal.Tests [TestCase] public void CompleteAllowedOnlyOnce() { - var context = new DefaultSerializationContext(); - var buffer = GetTestBuffer(10); + using (var scope = NewDefaultSerializationContextScope()) + { + var context = scope.Context; + var buffer = GetTestBuffer(10); - context.Complete(buffer); - Assert.Throws(typeof(InvalidOperationException), () => context.Complete(buffer)); - Assert.Throws(typeof(InvalidOperationException), () => context.Complete()); + context.Complete(buffer); + Assert.Throws(typeof(InvalidOperationException), () => context.Complete(buffer)); + Assert.Throws(typeof(InvalidOperationException), () => context.Complete()); + } } [TestCase] public void CompleteAllowedOnlyOnce2() { - var context = new DefaultSerializationContext(); + using (var scope = NewDefaultSerializationContextScope()) + { + var context = scope.Context; - context.Complete(); - Assert.Throws(typeof(InvalidOperationException), () => context.Complete(GetTestBuffer(10))); - Assert.Throws(typeof(InvalidOperationException), () => context.Complete()); + context.Complete(); + Assert.Throws(typeof(InvalidOperationException), () => context.Complete(GetTestBuffer(10))); + Assert.Throws(typeof(InvalidOperationException), () => context.Complete()); + } } [TestCase(0)] @@ -57,13 +60,16 @@ namespace Grpc.Core.Internal.Tests [TestCase(1000)] public void ByteArrayPayload(int payloadSize) { - var context = new DefaultSerializationContext(); - var origPayload = GetTestBuffer(payloadSize); + using (var scope = NewDefaultSerializationContextScope()) + { + var context = scope.Context; + var origPayload = GetTestBuffer(payloadSize); - context.Complete(origPayload); + context.Complete(origPayload); - var nativePayload = context.GetPayload().ToByteArray(); - CollectionAssert.AreEqual(origPayload, nativePayload); + var nativePayload = context.GetPayload().ToByteArray(); + CollectionAssert.AreEqual(origPayload, nativePayload); + } } [TestCase(0)] @@ -73,16 +79,40 @@ namespace Grpc.Core.Internal.Tests [TestCase(1000)] public void BufferWriter_OneSegment(int payloadSize) { - var context = new DefaultSerializationContext(); - var origPayload = GetTestBuffer(payloadSize); + using (var scope = NewDefaultSerializationContextScope()) + { + var context = scope.Context; + var origPayload = GetTestBuffer(payloadSize); - var bufferWriter = context.GetBufferWriter(); - origPayload.AsSpan().CopyTo(bufferWriter.GetSpan(payloadSize)); - bufferWriter.Advance(payloadSize); - // TODO: test that call to Complete() is required. + var bufferWriter = context.GetBufferWriter(); + origPayload.AsSpan().CopyTo(bufferWriter.GetSpan(payloadSize)); + bufferWriter.Advance(payloadSize); + // TODO: test that call to Complete() is required. - var nativePayload = context.GetPayload().ToByteArray(); - CollectionAssert.AreEqual(origPayload, nativePayload); + var nativePayload = context.GetPayload().ToByteArray(); + CollectionAssert.AreEqual(origPayload, nativePayload); + } + } + + [TestCase(0)] + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + [TestCase(1000)] + public void BufferWriter_OneSegment_GetMemory(int payloadSize) + { + using (var scope = NewDefaultSerializationContextScope()) + { + var context = scope.Context; + var origPayload = GetTestBuffer(payloadSize); + + var bufferWriter = context.GetBufferWriter(); + origPayload.AsSpan().CopyTo(bufferWriter.GetMemory(payloadSize).Span); + bufferWriter.Advance(payloadSize); + + var nativePayload = context.GetPayload().ToByteArray(); + CollectionAssert.AreEqual(origPayload, nativePayload); + } } [TestCase(1, 4)] // small slice size tests grpc_slice with inline data @@ -95,41 +125,68 @@ namespace Grpc.Core.Internal.Tests [TestCase(1000, 64)] public void BufferWriter_MultipleSegments(int payloadSize, int maxSliceSize) { - var context = new DefaultSerializationContext(); - var origPayload = GetTestBuffer(payloadSize); - - var bufferWriter = context.GetBufferWriter(); - for (int offset = 0; offset < payloadSize; offset += maxSliceSize) + using (var scope = NewDefaultSerializationContextScope()) { - var sliceSize = Math.Min(maxSliceSize, payloadSize - offset); - // we allocate last slice as too big intentionally to test that shrinking works - var dest = bufferWriter.GetSpan(maxSliceSize); - - origPayload.AsSpan(offset, sliceSize).CopyTo(dest); - bufferWriter.Advance(sliceSize); - } - context.Complete(); - - var nativePayload = context.GetPayload().ToByteArray(); - CollectionAssert.AreEqual(origPayload, nativePayload); + var context = scope.Context; + var origPayload = GetTestBuffer(payloadSize); - context.GetPayload().Dispose(); // TODO: do it better.. (use the scope...) + var bufferWriter = context.GetBufferWriter(); + for (int offset = 0; offset < payloadSize; offset += maxSliceSize) + { + var sliceSize = Math.Min(maxSliceSize, payloadSize - offset); + // we allocate last slice as too big intentionally to test that shrinking works + var dest = bufferWriter.GetSpan(maxSliceSize); + + origPayload.AsSpan(offset, sliceSize).CopyTo(dest); + bufferWriter.Advance(sliceSize); + } + context.Complete(); + + var nativePayload = context.GetPayload().ToByteArray(); + CollectionAssert.AreEqual(origPayload, nativePayload); + } } - // AdjustTailSpace(0) if previous tail size is 0.... + [TestCase] + public void ContextIsReusable() + { + using (var scope = NewDefaultSerializationContextScope()) + { + var context = scope.Context; + + var origPayload1 = GetTestBuffer(10); + context.Complete(origPayload1); + CollectionAssert.AreEqual(origPayload1, context.GetPayload().ToByteArray()); + + context.Reset(); + + var origPayload2 = GetTestBuffer(20); + + var bufferWriter = context.GetBufferWriter(); + origPayload2.AsSpan().CopyTo(bufferWriter.GetMemory(origPayload2.Length).Span); + bufferWriter.Advance(origPayload2.Length); + CollectionAssert.AreEqual(origPayload2, context.GetPayload().ToByteArray()); + + context.Reset(); + + // TODO: that's should be a null payload... + CollectionAssert.AreEqual(new byte[0], context.GetPayload().ToByteArray()); + } + } + + //test ideas: // test that context.Complete() call is required... - // BufferWriter.GetMemory... (add refs to the original memory?) - - // TODO: set payload and then get IBufferWriter should throw? - - // TODO: test Reset()... - - // TODO: destroy SliceBufferSafeHandles... (use usagescope...) - + // set payload with Complete([]) and then get IBufferWriter should throw (because it's been completed already?) + // other ideas: + // AdjustTailSpace(0) if previous tail size is 0... (better for SliceBufferSafeHandle) + private DefaultSerializationContext.UsageScope NewDefaultSerializationContextScope() + { + return new DefaultSerializationContext.UsageScope(new DefaultSerializationContext()); + } private byte[] GetTestBuffer(int length) { From 389d759344a58e8ae2be85623905b11da0b8e969 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 14:19:33 -0700 Subject: [PATCH 1184/1555] improve doc comments for SerializationContext --- src/csharp/Grpc.Core.Api/SerializationContext.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/csharp/Grpc.Core.Api/SerializationContext.cs b/src/csharp/Grpc.Core.Api/SerializationContext.cs index 79107040411..76f1951b68e 100644 --- a/src/csharp/Grpc.Core.Api/SerializationContext.cs +++ b/src/csharp/Grpc.Core.Api/SerializationContext.cs @@ -28,7 +28,7 @@ namespace Grpc.Core { /// /// Use the byte array as serialized form of current message and mark serialization process as complete. - /// Complete() can only be called once. By calling this method the caller gives up the ownership of the + /// Complete() can only be called once. By calling this method the caller gives up the ownership of the /// payload which must not be accessed afterwards. /// /// the serialized form of current message @@ -38,7 +38,8 @@ namespace Grpc.Core } /// - /// Expose serializer as buffer writer + /// Gets buffer writer that can be used to write the serialized data. Once serialization is finished, + /// Complete() needs to be called. /// public virtual IBufferWriter GetBufferWriter() { @@ -46,7 +47,7 @@ namespace Grpc.Core } /// - /// Complete the payload written so far. + /// Complete the payload written to the buffer writer. Complete() can only be called once. /// public virtual void Complete() { From 891dc61d8e238fa07e5323164bf00189bff42d3f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 14:28:29 -0700 Subject: [PATCH 1185/1555] move slice memory manager --- .../Grpc.Core/Internal/ReusableSliceBuffer.cs | 41 +-------- .../Grpc.Core/Internal/SliceMemoryManager.cs | 87 +++++++++++++++++++ 2 files changed, 88 insertions(+), 40 deletions(-) create mode 100644 src/csharp/Grpc.Core/Internal/SliceMemoryManager.cs diff --git a/src/csharp/Grpc.Core/Internal/ReusableSliceBuffer.cs b/src/csharp/Grpc.Core/Internal/ReusableSliceBuffer.cs index 078e59e9d1b..eed6ba4ae15 100644 --- a/src/csharp/Grpc.Core/Internal/ReusableSliceBuffer.cs +++ b/src/csharp/Grpc.Core/Internal/ReusableSliceBuffer.cs @@ -101,45 +101,6 @@ namespace Grpc.Core.Internal { Next = next; } - } - - // Allow creating instances of Memory from Slice. - // Represents a chunk of native memory, but doesn't manage its lifetime. - // Instances of this class are reuseable - they can be reset to point to a different memory chunk. - // That is important to make the instances cacheable (rather then creating new instances - // the old ones will be reused to reduce GC pressure). - private class SliceMemoryManager : MemoryManager - { - private Slice slice; - - public void Reset(Slice slice) - { - this.slice = slice; - } - - public void Reset() - { - Reset(new Slice(IntPtr.Zero, 0)); - } - - public override Span GetSpan() - { - return slice.ToSpanUnsafe(); - } - - public override MemoryHandle Pin(int elementIndex = 0) - { - throw new NotSupportedException(); - } - - public override void Unpin() - { - } - - protected override void Dispose(bool disposing) - { - // NOP - } - } + } } } diff --git a/src/csharp/Grpc.Core/Internal/SliceMemoryManager.cs b/src/csharp/Grpc.Core/Internal/SliceMemoryManager.cs new file mode 100644 index 00000000000..342d90df36c --- /dev/null +++ b/src/csharp/Grpc.Core/Internal/SliceMemoryManager.cs @@ -0,0 +1,87 @@ +#region Copyright notice and license + +// Copyright 2019 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using Grpc.Core.Utils; +using System; +using System.Threading; + +using System.Buffers; + +namespace Grpc.Core.Internal +{ + internal class ReusableSliceBuffer + { + public const int MaxCachedSegments = 1024; // ~4MB payload for 4K slices + + readonly SliceSegment[] cachedSegments = new SliceSegment[MaxCachedSegments]; + int populatedSegmentCount; + + public ReadOnlySequence PopulateFrom(IBufferReader bufferReader) + { + populatedSegmentCount = 0; + long offset = 0; + SliceSegment prevSegment = null; + while (bufferReader.TryGetNextSlice(out Slice slice)) + { + // Initialize cached segment if still null or just allocate a new segment if we already reached MaxCachedSegments + var current = populatedSegmentCount < cachedSegments.Length ? cachedSegments[populatedSegmentCount] : new SliceSegment(); + if (current == null) + { + current = cachedSegments[populatedSegmentCount] = new SliceSegment(); + } + + current.Reset(slice, offset); + prevSegment?.SetNext(current); + + populatedSegmentCount ++; + offset += slice.Length; + prevSegment = current; + } + + // Not necessary for ending the ReadOnlySequence, but for making sure we + // don't keep more than MaxCachedSegments alive. + prevSegment?.SetNext(null); + + if (populatedSegmentCount == 0) + { + return ReadOnlySequence.Empty; + } + + var firstSegment = cachedSegments[0]; + var lastSegment = prevSegment; + return new ReadOnlySequence(firstSegment, 0, lastSegment, lastSegment.Memory.Length); + } + + public void Invalidate() + { + if (populatedSegmentCount == 0) + { + return; + } + var segment = cachedSegments[0]; + while (segment != null) + { + segment.Reset(new Slice(IntPtr.Zero, 0), 0); + var nextSegment = (SliceSegment) segment.Next; + segment.SetNext(null); + segment = nextSegment; + } + populatedSegmentCount = 0; + } + } +} From fb5411fba9d91f73814b6c107a268c374ad58721 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 14:30:28 -0700 Subject: [PATCH 1186/1555] support GetMemory() --- .../Grpc.Core/Internal/SliceBufferSafeHandle.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs index 76a97f4a0a2..0ce37317f1a 100644 --- a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs @@ -39,6 +39,8 @@ namespace Grpc.Core.Internal private IntPtr tailSpacePtr; private int tailSpaceLen; + private SliceMemoryManager memoryManagerLazy; + private SliceBufferSafeHandle() { } @@ -63,14 +65,20 @@ namespace Grpc.Core.Internal GrpcPreconditions.CheckArgument(tailSpaceLen >= count); tailSpaceLen = tailSpaceLen - count; tailSpacePtr += count; + memoryManagerLazy?.Reset(); } // provides access to the "tail space" of this buffer. // Use GetSpan when possible for better efficiency. public Memory GetMemory(int sizeHint = 0) { - // TODO: implement - throw new NotImplementedException(); + GetSpan(sizeHint); + if (memoryManagerLazy == null) + { + memoryManagerLazy = new SliceMemoryManager(); + } + memoryManagerLazy.Reset(new Slice(tailSpacePtr, tailSpaceLen)); + return memoryManagerLazy.Memory; } // provides access to the "tail space" of this buffer. @@ -97,6 +105,7 @@ namespace Grpc.Core.Internal // deletes all the data in the slice buffer tailSpacePtr = IntPtr.Zero; tailSpaceLen = 0; + memoryManagerLazy?.Reset(); Native.grpcsharp_slice_buffer_reset_and_unref(this); } From 66cd7cbb8fce6136ead7fd05fe79356c2cf072c9 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 14:31:01 -0700 Subject: [PATCH 1187/1555] improve default serialization context tests --- .../DefaultSerializationContextTest.cs | 23 +++++++++++++------ .../Internal/DefaultSerializationContext.cs | 9 +++++--- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs b/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs index aa7631587be..fcb12ae6656 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs @@ -87,7 +87,7 @@ namespace Grpc.Core.Internal.Tests var bufferWriter = context.GetBufferWriter(); origPayload.AsSpan().CopyTo(bufferWriter.GetSpan(payloadSize)); bufferWriter.Advance(payloadSize); - // TODO: test that call to Complete() is required. + context.Complete(); var nativePayload = context.GetPayload().ToByteArray(); CollectionAssert.AreEqual(origPayload, nativePayload); @@ -109,6 +109,7 @@ namespace Grpc.Core.Internal.Tests var bufferWriter = context.GetBufferWriter(); origPayload.AsSpan().CopyTo(bufferWriter.GetMemory(payloadSize).Span); bufferWriter.Advance(payloadSize); + context.Complete(); var nativePayload = context.GetPayload().ToByteArray(); CollectionAssert.AreEqual(origPayload, nativePayload); @@ -154,6 +155,8 @@ namespace Grpc.Core.Internal.Tests { var context = scope.Context; + Assert.Throws(typeof(NullReferenceException), () => context.GetPayload()); + var origPayload1 = GetTestBuffer(10); context.Complete(origPayload1); CollectionAssert.AreEqual(origPayload1, context.GetPayload().ToByteArray()); @@ -165,20 +168,26 @@ namespace Grpc.Core.Internal.Tests var bufferWriter = context.GetBufferWriter(); origPayload2.AsSpan().CopyTo(bufferWriter.GetMemory(origPayload2.Length).Span); bufferWriter.Advance(origPayload2.Length); + context.Complete(); CollectionAssert.AreEqual(origPayload2, context.GetPayload().ToByteArray()); context.Reset(); - // TODO: that's should be a null payload... - CollectionAssert.AreEqual(new byte[0], context.GetPayload().ToByteArray()); + Assert.Throws(typeof(NullReferenceException), () => context.GetPayload()); } } - //test ideas: + [TestCase] + public void GetBufferWriterThrowsForCompletedContext() + { + using (var scope = NewDefaultSerializationContextScope()) + { + var context = scope.Context; + context.Complete(GetTestBuffer(10)); - // test that context.Complete() call is required... - - // set payload with Complete([]) and then get IBufferWriter should throw (because it's been completed already?) + Assert.Throws(typeof(InvalidOperationException), () => context.GetBufferWriter()); + } + } // other ideas: // AdjustTailSpace(0) if previous tail size is 0... (better for SliceBufferSafeHandle) diff --git a/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs b/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs index 6bf9da56264..4d45b5c684f 100644 --- a/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs +++ b/src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs @@ -52,6 +52,7 @@ namespace Grpc.Core.Internal /// public override IBufferWriter GetBufferWriter() { + GrpcPreconditions.CheckState(!isComplete); return sliceBuffer; } @@ -67,6 +68,11 @@ namespace Grpc.Core.Internal internal SliceBufferSafeHandle GetPayload() { + if (!isComplete) + { + // mimic the legacy behavior when byte[] was used to represent the payload. + throw new NullReferenceException("No payload was set. Complete() needs to be called before payload can be used."); + } return sliceBuffer; } @@ -95,9 +101,6 @@ namespace Grpc.Core.Internal } public DefaultSerializationContext Context => context; - - // TODO: add Serialize method... - public void Dispose() { context.Reset(); From 532bdf7cd29f613fdfe2184b4c7035398def5353 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 14:35:00 -0700 Subject: [PATCH 1188/1555] fixup SliceMemoryManager --- .../Grpc.Core/Internal/SliceMemoryManager.cs | 82 +++++++------------ 1 file changed, 30 insertions(+), 52 deletions(-) diff --git a/src/csharp/Grpc.Core/Internal/SliceMemoryManager.cs b/src/csharp/Grpc.Core/Internal/SliceMemoryManager.cs index 342d90df36c..dad2d96bd75 100644 --- a/src/csharp/Grpc.Core/Internal/SliceMemoryManager.cs +++ b/src/csharp/Grpc.Core/Internal/SliceMemoryManager.cs @@ -24,64 +24,42 @@ using System.Buffers; namespace Grpc.Core.Internal { - internal class ReusableSliceBuffer + // Allow creating instances of Memory from Slice. + // Represents a chunk of native memory, but doesn't manage its lifetime. + // Instances of this class are reuseable - they can be reset to point to a different memory chunk. + // That is important to make the instances cacheable (rather then creating new instances + // the old ones will be reused to reduce GC pressure). + internal class SliceMemoryManager : MemoryManager { - public const int MaxCachedSegments = 1024; // ~4MB payload for 4K slices + private Slice slice; - readonly SliceSegment[] cachedSegments = new SliceSegment[MaxCachedSegments]; - int populatedSegmentCount; - - public ReadOnlySequence PopulateFrom(IBufferReader bufferReader) + public void Reset(Slice slice) { - populatedSegmentCount = 0; - long offset = 0; - SliceSegment prevSegment = null; - while (bufferReader.TryGetNextSlice(out Slice slice)) - { - // Initialize cached segment if still null or just allocate a new segment if we already reached MaxCachedSegments - var current = populatedSegmentCount < cachedSegments.Length ? cachedSegments[populatedSegmentCount] : new SliceSegment(); - if (current == null) - { - current = cachedSegments[populatedSegmentCount] = new SliceSegment(); - } - - current.Reset(slice, offset); - prevSegment?.SetNext(current); - - populatedSegmentCount ++; - offset += slice.Length; - prevSegment = current; - } - - // Not necessary for ending the ReadOnlySequence, but for making sure we - // don't keep more than MaxCachedSegments alive. - prevSegment?.SetNext(null); - - if (populatedSegmentCount == 0) - { - return ReadOnlySequence.Empty; - } - - var firstSegment = cachedSegments[0]; - var lastSegment = prevSegment; - return new ReadOnlySequence(firstSegment, 0, lastSegment, lastSegment.Memory.Length); + this.slice = slice; } - public void Invalidate() + public void Reset() { - if (populatedSegmentCount == 0) - { - return; - } - var segment = cachedSegments[0]; - while (segment != null) - { - segment.Reset(new Slice(IntPtr.Zero, 0), 0); - var nextSegment = (SliceSegment) segment.Next; - segment.SetNext(null); - segment = nextSegment; - } - populatedSegmentCount = 0; + Reset(new Slice(IntPtr.Zero, 0)); + } + + public override Span GetSpan() + { + return slice.ToSpanUnsafe(); + } + + public override MemoryHandle Pin(int elementIndex = 0) + { + throw new NotSupportedException(); + } + + public override void Unpin() + { + } + + protected override void Dispose(bool disposing) + { + // NOP } } } From 79c9aa081d7ee9cc6368edc66be8428fe54f0dc6 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 14:38:45 -0700 Subject: [PATCH 1189/1555] add slice buffer safe handle tests --- .../Internal/SliceBufferSafeHandleTest.cs | 38 +++++++++++++++++++ src/csharp/tests.json | 1 + 2 files changed, 39 insertions(+) create mode 100644 src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs diff --git a/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs new file mode 100644 index 00000000000..563187948d2 --- /dev/null +++ b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs @@ -0,0 +1,38 @@ +#region Copyright notice and license + +// Copyright 2019 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using Grpc.Core; +using Grpc.Core.Internal; +using Grpc.Core.Utils; +using NUnit.Framework; + +namespace Grpc.Core.Internal.Tests +{ + public class SliceBufferSafeHandleTest + { + [TestCase] + public void BasicTest() + { + + } + + // other ideas: + // AdjustTailSpace(0) if previous tail size is 0... (better for SliceBufferSafeHandle) + } +} diff --git a/src/csharp/tests.json b/src/csharp/tests.json index 75bda4c25ea..e18266ab9d7 100644 --- a/src/csharp/tests.json +++ b/src/csharp/tests.json @@ -13,6 +13,7 @@ "Grpc.Core.Internal.Tests.FakeBufferReaderManagerTest", "Grpc.Core.Internal.Tests.MetadataArraySafeHandleTest", "Grpc.Core.Internal.Tests.ReusableSliceBufferTest", + "Grpc.Core.Internal.Tests.SliceBufferSafeHandleTest", "Grpc.Core.Internal.Tests.SliceTest", "Grpc.Core.Internal.Tests.TimespecTest", "Grpc.Core.Internal.Tests.WellKnownStringsTest", From ec14872fc283ac36b6898ab1f9d0fad758d6329e Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 14:48:36 -0700 Subject: [PATCH 1190/1555] address TODO" --- src/csharp/Grpc.Core.Tests/ContextualMarshallerTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/ContextualMarshallerTest.cs b/src/csharp/Grpc.Core.Tests/ContextualMarshallerTest.cs index 99f92e12628..dbceb27baf9 100644 --- a/src/csharp/Grpc.Core.Tests/ContextualMarshallerTest.cs +++ b/src/csharp/Grpc.Core.Tests/ContextualMarshallerTest.cs @@ -52,8 +52,8 @@ namespace Grpc.Core.Tests } if (str == "SERIALIZE_TO_NULL") { - // TODO: test for not calling complete Complete() (that resulted in null payload before...) - // TODO: test for calling Complete(null byte array) + // for contextual marshaller, serializing to null payload corresponds + // to not calling the Complete() method in the serializer. return; } var bytes = System.Text.Encoding.UTF8.GetBytes(str); From ded29be883e888081174a9be88de4ce2618303af Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 15:43:57 -0700 Subject: [PATCH 1191/1555] slice buffer improvements --- .../Internal/SliceBufferSafeHandleTest.cs | 95 ++++++++++++++++++- .../Internal/SliceBufferSafeHandle.cs | 33 +++++-- 2 files changed, 115 insertions(+), 13 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs index 563187948d2..61c817dafc9 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs @@ -27,12 +27,99 @@ namespace Grpc.Core.Internal.Tests public class SliceBufferSafeHandleTest { [TestCase] - public void BasicTest() + public void Complete_EmptyBuffer() { - + using (var sliceBuffer = SliceBufferSafeHandle.Create()) + { + sliceBuffer.Complete(); + CollectionAssert.AreEqual(new byte[0], sliceBuffer.ToByteArray()); + } } - // other ideas: - // AdjustTailSpace(0) if previous tail size is 0... (better for SliceBufferSafeHandle) + [TestCase] + public void Complete_TailSizeZero() + { + using (var sliceBuffer = SliceBufferSafeHandle.Create()) + { + var origPayload = GetTestBuffer(10); + origPayload.AsSpan().CopyTo(sliceBuffer.GetSpan(origPayload.Length)); + sliceBuffer.Advance(origPayload.Length); + // call complete where tail space size == 0 + sliceBuffer.Complete(); + CollectionAssert.AreEqual(origPayload, sliceBuffer.ToByteArray()); + } + } + + [TestCase] + public void Complete_TruncateTailSpace() + { + using (var sliceBuffer = SliceBufferSafeHandle.Create()) + { + var origPayload = GetTestBuffer(10); + var dest = sliceBuffer.GetSpan(origPayload.Length + 10); + origPayload.AsSpan().CopyTo(dest); + sliceBuffer.Advance(origPayload.Length); + // call complete where tail space needs to be truncated + sliceBuffer.Complete(); + CollectionAssert.AreEqual(origPayload, sliceBuffer.ToByteArray()); + } + } + + [TestCase] + public void SliceBufferIsReusable() + { + using (var sliceBuffer = SliceBufferSafeHandle.Create()) + { + var origPayload = GetTestBuffer(10); + origPayload.AsSpan().CopyTo(sliceBuffer.GetSpan(origPayload.Length)); + sliceBuffer.Advance(origPayload.Length); + sliceBuffer.Complete(); + CollectionAssert.AreEqual(origPayload, sliceBuffer.ToByteArray()); + + sliceBuffer.Reset(); + + var origPayload2 = GetTestBuffer(20); + origPayload2.AsSpan().CopyTo(sliceBuffer.GetSpan(origPayload2.Length)); + sliceBuffer.Advance(origPayload2.Length); + sliceBuffer.Complete(); + CollectionAssert.AreEqual(origPayload2, sliceBuffer.ToByteArray()); + + sliceBuffer.Reset(); + + CollectionAssert.AreEqual(new byte[0], sliceBuffer.ToByteArray()); + } + } + + [TestCase] + public void SliceBuffer_SizeHintZero() + { + using (var sliceBuffer = SliceBufferSafeHandle.Create()) + { + var destSpan = sliceBuffer.GetSpan(0); + Assert.IsTrue(destSpan.Length > 0); // some non-zero size memory is made available + + sliceBuffer.Reset(); + + var destMemory = sliceBuffer.GetMemory(0); + Assert.IsTrue(destMemory.Length > 0); + } + } + + // Advance() - multiple chunks... + + // other TODOS: + + // -- provide a null instance of SliceBufferSafeHandle + //-- order of UnsafeSerialize in AsyncCall methods... + + private byte[] GetTestBuffer(int length) + { + var testBuffer = new byte[length]; + for (int i = 0; i < testBuffer.Length; i++) + { + testBuffer[i] = (byte) i; + } + return testBuffer; + } } } diff --git a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs index 0ce37317f1a..77c14f1d9fb 100644 --- a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs @@ -31,6 +31,7 @@ namespace Grpc.Core.Internal /// internal class SliceBufferSafeHandle : SafeHandleZeroIsInvalid, IBufferWriter { + const int DefaultTailSpaceSize = 4096; // default buffer to allocate if no size hint is provided static readonly NativeMethods Native = NativeMethods.Get(); static readonly ILogger Logger = GrpcEnvironment.Logger.ForType(); @@ -72,7 +73,7 @@ namespace Grpc.Core.Internal // Use GetSpan when possible for better efficiency. public Memory GetMemory(int sizeHint = 0) { - GetSpan(sizeHint); + EnsureBufferSpace(sizeHint); if (memoryManagerLazy == null) { memoryManagerLazy = new SliceMemoryManager(); @@ -84,13 +85,7 @@ namespace Grpc.Core.Internal // provides access to the "tail space" of this buffer. public unsafe Span GetSpan(int sizeHint = 0) { - GrpcPreconditions.CheckArgument(sizeHint >= 0); - if (tailSpaceLen < sizeHint) - { - // TODO: should we ignore the hint sometimes when - // available tail space is close enough to the sizeHint? - AdjustTailSpace(sizeHint); - } + EnsureBufferSpace(sizeHint); return new Span(tailSpacePtr.ToPointer(), tailSpaceLen); } @@ -135,7 +130,27 @@ namespace Grpc.Core.Internal return result; } - // Gets data of server_rpc_new completion. + private void EnsureBufferSpace(int sizeHint) + { + GrpcPreconditions.CheckArgument(sizeHint >= 0); + if (sizeHint == 0) + { + // if no hint is provided, keep the available space within some "reasonable" boundaries. + // This is quite a naive approach which could use some fine-tuning, but currently in most case we know + // the required buffer size in advance anyway, so this approach seems good enough for now. + if (tailSpaceLen < DefaultTailSpaceSize /2 ) + { + AdjustTailSpace(DefaultTailSpaceSize); + } + } + else if (tailSpaceLen < sizeHint) + { + // if hint is provided, always make sure we provide at least that much space + AdjustTailSpace(sizeHint); + } + } + + // make sure there's exactly requestedSize bytes of continguous buffer space at the end of this slice buffer private void AdjustTailSpace(int requestedSize) { GrpcPreconditions.CheckArgument(requestedSize >= 0); From 127d69383abc0c442625038be6d57522b35f20c6 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 9 Aug 2019 16:00:41 -0700 Subject: [PATCH 1192/1555] better tests --- .../Internal/SliceBufferSafeHandleTest.cs | 46 ++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs index 61c817dafc9..5feb9a711da 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs @@ -105,10 +105,52 @@ namespace Grpc.Core.Internal.Tests } } - // Advance() - multiple chunks... + [TestCase(0)] + [TestCase(1000)] + public void SliceBuffer_BigPayload(int sizeHint) + { + using (var sliceBuffer = SliceBufferSafeHandle.Create()) + { + var bigPayload = GetTestBuffer(4 * 1024 * 1024); - // other TODOS: + int offset = 0; + while (offset < bigPayload.Length) + { + var destSpan = sliceBuffer.GetSpan(sizeHint); + int copySize = Math.Min(destSpan.Length, bigPayload.Length - offset); + bigPayload.AsSpan(offset, copySize).CopyTo(destSpan); + sliceBuffer.Advance(copySize); + offset += copySize; + } + + sliceBuffer.Complete(); + CollectionAssert.AreEqual(bigPayload, sliceBuffer.ToByteArray()); + } + } + [TestCase] + public void SliceBuffer_NegativeSizeHint() + { + using (var sliceBuffer = SliceBufferSafeHandle.Create()) + { + Assert.Throws(typeof(ArgumentException), () => sliceBuffer.GetSpan(-1)); + Assert.Throws(typeof(ArgumentException), () => sliceBuffer.GetMemory(-1)); + } + } + + [TestCase] + public void SliceBuffer_AdvanceBadArg() + { + using (var sliceBuffer = SliceBufferSafeHandle.Create()) + { + int size = 10; + var destSpan = sliceBuffer.GetSpan(size); + Assert.Throws(typeof(ArgumentException), () => sliceBuffer.Advance(size + 1)); + Assert.Throws(typeof(ArgumentException), () => sliceBuffer.Advance(-1)); + } + } + + // TODO: other TODOs // -- provide a null instance of SliceBufferSafeHandle //-- order of UnsafeSerialize in AsyncCall methods... From 0f1a8a84b5ae12a3a201a0d477614073e448e85a Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Fri, 9 Aug 2019 16:51:52 -0700 Subject: [PATCH 1193/1555] Don't use : prefix --- src/proto/grpc/lb/v2/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proto/grpc/lb/v2/BUILD b/src/proto/grpc/lb/v2/BUILD index 0b46b2892ed..e47f170e14b 100644 --- a/src/proto/grpc/lb/v2/BUILD +++ b/src/proto/grpc/lb/v2/BUILD @@ -37,5 +37,5 @@ grpc_proto_library( ], has_services = True, well_known_protos = True, - deps = [":eds_for_test_proto"], + deps = ["eds_for_test_proto"], ) From 47d95ef26626a81cfe2b96acf372764a08e12b36 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 9 Aug 2019 12:45:08 -0700 Subject: [PATCH 1194/1555] address comments --- gRPC.podspec | 6 +++-- src/compiler/objective_c_generator.cc | 2 +- src/objective-c/BUILD | 3 +-- src/objective-c/GRPCClient/GRPCCallLegacy.m | 9 +++---- src/objective-c/GRPCClient/GRPCInterceptor.m | 5 +--- .../GRPCClient/private/GRPCCore/GRPCChannel.m | 2 +- .../private/GRPCCore/GRPCChannelPool.m | 1 - .../GRPCClient/private/GRPCCore/GRPCHost.m | 11 ++++++-- .../GRPCClient/private/GRPCCore/version.h | 25 ------------------- .../GRPCClient/{private => }/version.h | 2 +- .../tests/InteropTests/InteropTestsLocalSSL.m | 4 --- src/objective-c/tests/UnitTests/APIv2Tests.m | 2 +- .../tests/UnitTests/GRPCClientTests.m | 3 +-- templates/gRPC.podspec.template | 6 +++-- .../{private => }/version.h.template | 2 +- 15 files changed, 28 insertions(+), 55 deletions(-) delete mode 100644 src/objective-c/GRPCClient/private/GRPCCore/version.h rename src/objective-c/GRPCClient/{private => }/version.h (96%) rename templates/src/objective-c/GRPCClient/{private => }/version.h.template (96%) diff --git a/gRPC.podspec b/gRPC.podspec index f329f3b3333..a44f207ed54 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -77,7 +77,8 @@ Pod::Spec.new do |s| 'src/objective-c/GRPCClient/GRPCCallOptions.h', 'src/objective-c/GRPCClient/GRPCInterceptor.h', 'src/objective-c/GRPCClient/GRPCTransport.h', - 'src/objective-c/GRPCClient/GRPCDispatchable.h' + 'src/objective-c/GRPCClient/GRPCDispatchable.h', + 'src/objective-c/GRPCClient/version.h' ss.source_files = 'src/objective-c/GRPCClient/GRPCCall.h', 'src/objective-c/GRPCClient/GRPCCall.m', @@ -92,7 +93,8 @@ Pod::Spec.new do |s| 'src/objective-c/GRPCClient/GRPCTransport.m', 'src/objective-c/GRPCClient/internal/*.h', 'src/objective-c/GRPCClient/private/GRPCTransport+Private.h', - 'src/objective-c/GRPCClient/private/GRPCTransport+Private.m' + 'src/objective-c/GRPCClient/private/GRPCTransport+Private.m', + 'src/objective-c/GRPCClient/version.h' ss.dependency "#{s.name}/Interface-Legacy", version end diff --git a/src/compiler/objective_c_generator.cc b/src/compiler/objective_c_generator.cc index 122ea3c3b69..ed262308aba 100644 --- a/src/compiler/objective_c_generator.cc +++ b/src/compiler/objective_c_generator.cc @@ -297,7 +297,7 @@ void PrintMethodImplementations(Printer* printer, "that have been deprecated. They do not\n" " * recognize call options provided in the initializer. Using " "the v2 protocol is recommended.\n" - " */\n\n"); + " */\n"); printer.Print(vars, "@protocol $service_class$ \n\n"); for (int i = 0; i < service->method_count(); i++) { PrintMethodDeclarations(&printer, service->method(i)); diff --git a/src/objective-c/BUILD b/src/objective-c/BUILD index 2af1d85f290..322c84bb9bb 100644 --- a/src/objective-c/BUILD +++ b/src/objective-c/BUILD @@ -28,7 +28,6 @@ grpc_objc_library( name = "rx_library_headers", hdrs = glob([ "RxLibrary/*.h", - "RxLibrary/transformations/*.h", ]), includes = ["."], ) @@ -37,7 +36,6 @@ grpc_objc_library( name = "rx_library", srcs = glob([ "RxLibrary/*.m", - "RxLibrary/transformations/*.m", ]), includes = ["."], deps = [ @@ -83,6 +81,7 @@ grpc_objc_library( "GRPCClient/GRPCTransport.h", "GRPCClient/GRPCDispatchable.h", "GRPCClient/internal/GRPCCallOptions+Internal.h", + "GRPCClient/version.h", ], srcs = [ "GRPCClient/GRPCCall.m", diff --git a/src/objective-c/GRPCClient/GRPCCallLegacy.m b/src/objective-c/GRPCClient/GRPCCallLegacy.m index b1220999741..d06048c3a89 100644 --- a/src/objective-c/GRPCClient/GRPCCallLegacy.m +++ b/src/objective-c/GRPCClient/GRPCCallLegacy.m @@ -18,7 +18,6 @@ #import "GRPCCallLegacy.h" -#import "GRPCCall+Cronet.h" #import "GRPCCall+OAuth2.h" #import "GRPCCallOptions.h" #import "GRPCTypes.h" @@ -588,13 +587,11 @@ static NSString *const kBearerPrefix = @"Bearer "; // retain cycle. _retainSelf = self; + // If _callOptions is nil, people must be using the deprecated v1 interface. In this case, + // generate the call options from the corresponding GRPCHost configs and apply other options + // that are not covered by GRPCHost. if (_callOptions == nil) { GRPCMutableCallOptions *callOptions = [[GRPCHost callOptionsForHost:_host] mutableCopy]; - // By v1 API logic, insecure channel precedes Cronet channel; Cronet channel preceeds default - // channel. We maintain backwards compatibility here with v1 API by keep this logic. - if (callOptions.transport == GRPCTransportTypeDefault && [GRPCCall isUsingCronet]) { - callOptions.transport = gGRPCCoreCronetId; - } if (_serverName.length != 0) { callOptions.serverAuthority = _serverName; } diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.m b/src/objective-c/GRPCClient/GRPCInterceptor.m index b18f7550260..9a41c395148 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.m +++ b/src/objective-c/GRPCClient/GRPCInterceptor.m @@ -174,10 +174,7 @@ /** Forward initial metadata to the previous interceptor in the chain */ - (void)forwardPreviousInterceptorWithInitialMetadata:(NSDictionary *)initialMetadata { - if (_nextInterceptor == nil && !_shutDown) { - [self createNextInterceptor]; - } - if (_nextInterceptor == nil) { + if (_previousInterceptor == nil) { return; } id copiedPreviousInterceptor = _previousInterceptor; diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m index e0fd4c18e78..cd2b4313acd 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m @@ -29,10 +29,10 @@ #import "GRPCCoreFactory.h" #import "GRPCInsecureChannelFactory.h" #import "GRPCSecureChannelFactory.h" -#import "version.h" #import #import +#import @implementation GRPCChannelConfiguration diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.m index faabb3ae336..92f52e67b75 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.m @@ -27,7 +27,6 @@ #import "GRPCInsecureChannelFactory.h" #import "GRPCSecureChannelFactory.h" #import "GRPCWrappedCall.h" -#import "version.h" #include diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m index 98f46062786..04f91e494a7 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m @@ -31,7 +31,6 @@ #import "GRPCCompletionQueue.h" #import "GRPCSecureChannelFactory.h" #import "NSDictionary+GRPC.h" -#import "version.h" NS_ASSUME_NONNULL_BEGIN @@ -115,6 +114,8 @@ static NSMutableDictionary *gHostCache; options.hostNameOverride = _hostNameOverride; if (_transportType == GRPCTransportTypeInsecure) { options.transport = GRPCDefaultTransportImplList.core_insecure; + } else if ([GRPCCall isUsingCronet]){ + options.transport = gGRPCCoreCronetId; } else { options.transport = GRPCDefaultTransportImplList.core_secure; } @@ -132,9 +133,15 @@ static NSMutableDictionary *gHostCache; GRPCCallOptions *callOptions = nil; @synchronized(gHostCache) { - callOptions = [gHostCache[host] callOptions]; + GRPCHost *hostConfig = gHostCache[host]; + if (hostConfig == nil) { + hostConfig = [GRPCHost hostWithAddress:host]; + } + callOptions = [hostConfig callOptions]; } + NSAssert(callOptions != nil, @"Unable to create call options object"); if (callOptions == nil) { + NSLog(@"Unable to create call options object"); callOptions = [[GRPCCallOptions alloc] init]; } return callOptions; diff --git a/src/objective-c/GRPCClient/private/GRPCCore/version.h b/src/objective-c/GRPCClient/private/GRPCCore/version.h deleted file mode 100644 index 3b248db0148..00000000000 --- a/src/objective-c/GRPCClient/private/GRPCCore/version.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// This file is autogenerated from a template file. Please make -// modifications to -// `templates/src/objective-c/GRPCClient/private/version.h.template` -// instead. This file can be regenerated from the template by running -// `tools/buildgen/generate_projects.sh`. - -#define GRPC_OBJC_VERSION_STRING @"1.23.0-dev" diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/version.h similarity index 96% rename from src/objective-c/GRPCClient/private/version.h rename to src/objective-c/GRPCClient/version.h index fc6982c55d6..64781185ac7 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/version.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015 gRPC authors. + * Copyright 2019 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m b/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m index 1c1c1ddeb1e..30d8f4c34af 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m +++ b/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m @@ -57,10 +57,6 @@ static int32_t kLocalInteropServerOverhead = 10; return kLocalInteropServerOverhead; // bytes } -+ (GRPCTransportType)transportType { - return GRPCTransportTypeDefault; -} - + (GRPCTransportId)transport { return GRPCDefaultTransportImplList.core_secure; } diff --git a/src/objective-c/tests/UnitTests/APIv2Tests.m b/src/objective-c/tests/UnitTests/APIv2Tests.m index 86d4e8b3619..6d99f3be44f 100644 --- a/src/objective-c/tests/UnitTests/APIv2Tests.m +++ b/src/objective-c/tests/UnitTests/APIv2Tests.m @@ -17,6 +17,7 @@ */ #import +#import #import #import #import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" @@ -24,7 +25,6 @@ #include #include -#import "../version.h" // The server address is derived from preprocessor macro, which is // in turn derived from environment variable of the same name. diff --git a/src/objective-c/tests/UnitTests/GRPCClientTests.m b/src/objective-c/tests/UnitTests/GRPCClientTests.m index 3d144c33b06..5dbea09ca85 100644 --- a/src/objective-c/tests/UnitTests/GRPCClientTests.m +++ b/src/objective-c/tests/UnitTests/GRPCClientTests.m @@ -25,6 +25,7 @@ #import #import #import +#import #import #import #import @@ -33,8 +34,6 @@ #include -#import "../version.h" - #define TEST_TIMEOUT 16 // The server address is derived from preprocessor macro, which is diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index 6bea89d93a4..a9b6dc63738 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -79,7 +79,8 @@ 'src/objective-c/GRPCClient/GRPCCallOptions.h', 'src/objective-c/GRPCClient/GRPCInterceptor.h', 'src/objective-c/GRPCClient/GRPCTransport.h', - 'src/objective-c/GRPCClient/GRPCDispatchable.h' + 'src/objective-c/GRPCClient/GRPCDispatchable.h', + 'src/objective-c/GRPCClient/version.h' ss.source_files = 'src/objective-c/GRPCClient/GRPCCall.h', 'src/objective-c/GRPCClient/GRPCCall.m', @@ -94,7 +95,8 @@ 'src/objective-c/GRPCClient/GRPCTransport.m', 'src/objective-c/GRPCClient/internal/*.h', 'src/objective-c/GRPCClient/private/GRPCTransport+Private.h', - 'src/objective-c/GRPCClient/private/GRPCTransport+Private.m' + 'src/objective-c/GRPCClient/private/GRPCTransport+Private.m', + 'src/objective-c/GRPCClient/version.h' ss.dependency "#{s.name}/Interface-Legacy", version end diff --git a/templates/src/objective-c/GRPCClient/private/version.h.template b/templates/src/objective-c/GRPCClient/version.h.template similarity index 96% rename from templates/src/objective-c/GRPCClient/private/version.h.template rename to templates/src/objective-c/GRPCClient/version.h.template index 22b3bb25d48..5623dddb502 100644 --- a/templates/src/objective-c/GRPCClient/private/version.h.template +++ b/templates/src/objective-c/GRPCClient/version.h.template @@ -2,7 +2,7 @@ --- | /* * - * Copyright 2015 gRPC authors. + * Copyright 2019 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 1291ece848880ed64c712c557dd1d03430beeb1c Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Fri, 9 Aug 2019 19:55:11 -0700 Subject: [PATCH 1195/1555] Add drop in xds policy --- .../client_channel/lb_policy/xds/xds.cc | 250 ++++++---- .../lb_policy/xds/xds_client_stats.cc | 2 +- .../lb_policy/xds/xds_client_stats.h | 2 +- .../lb_policy/xds/xds_load_balancer_api.cc | 68 +++ .../lb_policy/xds/xds_load_balancer_api.h | 44 +- test/cpp/end2end/xds_end2end_test.cc | 438 +++++++++++++++--- 6 files changed, 648 insertions(+), 156 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index 279f480946f..4f119edefce 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -405,7 +405,10 @@ class XdsLb : public LoadBalancingPolicy { // previous value in the vector and is 0 for the first element. using PickerList = InlinedVector>, 1>; - explicit Picker(PickerList pickers) : pickers_(std::move(pickers)) {} + Picker(RefCountedPtr xds_policy, PickerList pickers) + : xds_policy_(std::move(xds_policy)), + pickers_(std::move(pickers)), + drop_config_(xds_policy_->drop_config_) {} PickResult Pick(PickArgs args) override; @@ -413,7 +416,9 @@ class XdsLb : public LoadBalancingPolicy { // Calls the picker of the locality that the key falls within. PickResult PickFromLocality(const uint32_t key, PickArgs args); + RefCountedPtr xds_policy_; PickerList pickers_; + RefCountedPtr drop_config_; }; class FallbackHelper : public ChannelControlHelper { @@ -458,6 +463,14 @@ class XdsLb : public LoadBalancingPolicy { void ResetBackoffLocked(); void Orphan() override; + grpc_connectivity_state connectivity_state() const { + return connectivity_state_; + } + uint32_t locality_weight() const { return locality_weight_; } + RefCountedPtr picker_wrapper() const { + return picker_wrapper_; + } + private: class Helper : public ChannelControlHelper { public: @@ -500,15 +513,19 @@ class XdsLb : public LoadBalancingPolicy { uint32_t locality_weight_; }; + explicit LocalityMap(XdsLb* xds_policy) : xds_policy_(xds_policy) {} + void UpdateLocked(const XdsLocalityList& locality_list, LoadBalancingPolicy::Config* child_policy_config, const grpc_channel_args* args, XdsLb* parent); + void UpdateXdsPickerLocked(); void ShutdownLocked(); void ResetBackoffLocked(); private: void PruneLocalities(const XdsLocalityList& locality_list); + XdsLb* xds_policy_; Map, OrphanablePtr, XdsLocalityName::Less> map_; @@ -594,6 +611,9 @@ class XdsLb : public LoadBalancingPolicy { // the current one when new localities in the pending map are ready // to accept connections + // The config for dropping calls. + RefCountedPtr drop_config_; + // The stats for client-side load reporting. XdsClientStats client_stats_; }; @@ -637,7 +657,14 @@ void XdsLb::PickerWrapper::RecordCallCompletion( // XdsLb::PickResult XdsLb::Picker::Pick(PickArgs args) { - // TODO(roth): Add support for drop handling. + // Handle drop. + const UniquePtr* drop_category; + if (drop_config_->ShouldDrop(&drop_category)) { + xds_policy_->client_stats_.AddCallDropped(*drop_category); + PickResult result; + result.type = PickResult::PICK_COMPLETE; + return result; + } // Generate a random number in [0, total weight). const uint32_t key = rand() % pickers_[pickers_.size() - 1].first; // Forward pick to whichever locality maps to the range in which the @@ -1092,12 +1119,12 @@ void XdsLb::LbChannelState::EdsCallState::OnResponseReceivedLocked( GRPC_ERROR_UNREF(parse_error); return; } - if (update.locality_list.empty()) { + if (update.locality_list.empty() && !update.drop_all) { char* response_slice_str = grpc_dump_slice(response_slice, GPR_DUMP_ASCII | GPR_DUMP_HEX); gpr_log(GPR_ERROR, "[xdslb %p] EDS response '%s' doesn't contain any valid locality " - "update. Ignoring.", + "but doesn't require to drop all calls. Ignoring.", xdslb_policy, response_slice_str); gpr_free(response_slice_str); return; @@ -1105,8 +1132,11 @@ void XdsLb::LbChannelState::EdsCallState::OnResponseReceivedLocked( eds_calld->seen_response_ = true; if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { gpr_log(GPR_INFO, - "[xdslb %p] EDS response with %" PRIuPTR " localities received", - xdslb_policy, update.locality_list.size()); + "[xdslb %p] EDS response with %" PRIuPTR + " localities and %" PRIuPTR + " drop categories received (drop_all=%d)", + xdslb_policy, update.locality_list.size(), + update.drop_config->drop_category_list().size(), update.drop_all); for (size_t i = 0; i < update.locality_list.size(); ++i) { const XdsLocalityInfo& locality = update.locality_list[i]; gpr_log(GPR_INFO, @@ -1127,8 +1157,17 @@ void XdsLb::LbChannelState::EdsCallState::OnResponseReceivedLocked( gpr_free(ipport); } } + for (size_t i = 0; i < update.drop_config->drop_category_list().size(); + ++i) { + const XdsDropConfig::DropCategory& drop_category = + update.drop_config->drop_category_list()[i]; + gpr_log(GPR_INFO, + "[xdslb %p] Drop category %s has drop rate %d per million", + xdslb_policy, drop_category.name.get(), + drop_category.parts_per_million); + } } - // Pending LB channel receives a serverlist; promote it. + // Pending LB channel receives a response; promote it. // Note that this call can't be on a discarded pending channel, because // such channels don't have any current call but we have checked this call // is a current call. @@ -1147,23 +1186,27 @@ void XdsLb::LbChannelState::EdsCallState::OnResponseReceivedLocked( // load reporting. LrsCallState* lrs_calld = lb_chand->lrs_calld_->lb_calld(); if (lrs_calld != nullptr) lrs_calld->MaybeStartReportingLocked(); - // Ignore identical update. + // If the balancer tells us to drop all the calls, we should exit fallback + // mode immediately. + if (update.drop_all) xdslb_policy->MaybeExitFallbackMode(); + // Update the drop config. + const bool drop_config_changed = + xdslb_policy->drop_config_ == nullptr || + *xdslb_policy->drop_config_ != *update.drop_config; + xdslb_policy->drop_config_ = std::move(update.drop_config); + // Ignore identical locality update. if (xdslb_policy->locality_list_ == update.locality_list) { if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { gpr_log(GPR_INFO, - "[xdslb %p] Incoming server list identical to current, " - "ignoring.", - xdslb_policy); + "[xdslb %p] Incoming locality list identical to current, " + "ignoring. (drop_config_changed=%d)", + xdslb_policy, drop_config_changed); + } + if (drop_config_changed) { + xdslb_policy->locality_map_.UpdateXdsPickerLocked(); } return; } - // If the balancer tells us to drop all the calls, we should exit fallback - // mode immediately. - // TODO(juanlishen): When we add EDS drop, we should change to check - // drop_percentage. - if (update.locality_list[0].serverlist.empty()) { - xdslb_policy->MaybeExitFallbackMode(); - } // Update the locality list. xdslb_policy->locality_list_ = std::move(update.locality_list); // Update the locality map. @@ -1661,7 +1704,8 @@ grpc_channel_args* BuildBalancerChannelArgs(const grpc_channel_args* args) { // ctor and dtor // -XdsLb::XdsLb(Args args) : LoadBalancingPolicy(std::move(args)) { +XdsLb::XdsLb(Args args) + : LoadBalancingPolicy(std::move(args)), locality_map_(this) { // Record server name. const grpc_arg* arg = grpc_channel_args_find(args.args, GRPC_ARG_SERVER_URI); const char* server_uri = grpc_channel_arg_get_string(arg); @@ -2032,6 +2076,91 @@ void XdsLb::LocalityMap::UpdateLocked( PruneLocalities(locality_list); } +void XdsLb::LocalityMap::UpdateXdsPickerLocked() { + // Construct a new xds picker which maintains a map of all locality pickers + // that are ready. Each locality is represented by a portion of the range + // proportional to its weight, such that the total range is the sum of the + // weights of all localities. + uint32_t end = 0; + size_t num_connecting = 0; + size_t num_idle = 0; + size_t num_transient_failures = 0; + Picker::PickerList pickers; + for (auto& p : map_) { + // TODO(juanlishen): We should prune a locality (and kill its stats) after + // we know we won't pick from it. We need to improve our update logic to + // make that easier. Consider the following situation: the current map has + // two READY localities A and B, and the update only contains B with the + // same addresses as before. Without the following hack, we will generate + // the same picker containing A and B because we haven't pruned A when the + // update happens. Remove the for loop below once we implement the locality + // map update. + bool in_locality_list = false; + for (size_t i = 0; i < xds_policy_->locality_list_.size(); ++i) { + if (*xds_policy_->locality_list_[i].locality_name == *p.first) { + in_locality_list = true; + break; + } + } + if (!in_locality_list) continue; + const LocalityEntry* entry = p.second.get(); + switch (entry->connectivity_state()) { + case GRPC_CHANNEL_READY: { + end += entry->locality_weight(); + pickers.push_back(MakePair(end, entry->picker_wrapper())); + break; + } + case GRPC_CHANNEL_CONNECTING: { + num_connecting++; + break; + } + case GRPC_CHANNEL_IDLE: { + num_idle++; + break; + } + case GRPC_CHANNEL_TRANSIENT_FAILURE: { + num_transient_failures++; + break; + } + default: { + gpr_log(GPR_ERROR, "Invalid locality connectivity state - %d", + entry->connectivity_state()); + } + } + } + // Pass on the constructed xds picker if it has any ready pickers in their map + // otherwise pass a QueuePicker if any of the locality pickers are in a + // connecting or idle state, finally return a transient failure picker if all + // locality pickers are in transient failure. + if (!pickers.empty()) { + xds_policy_->channel_control_helper()->UpdateState( + GRPC_CHANNEL_READY, + UniquePtr( + New(xds_policy_->Ref(DEBUG_LOCATION, "XdsLb+Picker"), + std::move(pickers)))); + } else if (num_connecting > 0) { + xds_policy_->channel_control_helper()->UpdateState( + GRPC_CHANNEL_CONNECTING, + UniquePtr( + New(xds_policy_->Ref(DEBUG_LOCATION, "QueuePicker")))); + } else if (num_idle > 0) { + xds_policy_->channel_control_helper()->UpdateState( + GRPC_CHANNEL_IDLE, + UniquePtr( + New(xds_policy_->Ref(DEBUG_LOCATION, "QueuePicker")))); + } else { + GPR_ASSERT(num_transient_failures == + xds_policy_->locality_map_.map_.size()); + grpc_error* error = + grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "connections to all localities failing"), + GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE); + xds_policy_->channel_control_helper()->UpdateState( + GRPC_CHANNEL_TRANSIENT_FAILURE, + UniquePtr(New(error))); + } +} + void XdsLb::LocalityMap::ShutdownLocked() { map_.clear(); } void XdsLb::LocalityMap::ResetBackoffLocked() { @@ -2326,87 +2455,8 @@ void XdsLb::LocalityMap::LocalityEntry::Helper::UpdateState( std::move(picker), entry_->parent_->client_stats_.FindLocalityStats(entry_->name_)); entry_->connectivity_state_ = state; - // Construct a new xds picker which maintains a map of all locality pickers - // that are ready. Each locality is represented by a portion of the range - // proportional to its weight, such that the total range is the sum of the - // weights of all localities - uint32_t end = 0; - size_t num_connecting = 0; - size_t num_idle = 0; - size_t num_transient_failures = 0; - Picker::PickerList pickers; - for (auto& p : entry_->parent_->locality_map_.map_) { - // TODO(juanlishen): We should prune a locality (and kill its stats) after - // we know we won't pick from it. We need to improve our update logic to - // make that easier. Consider the following situation: the current map has - // two READY localities A and B, and the update only contains B with the - // same addresses as before. Without the following hack, we will generate - // the same picker containing A and B because we haven't pruned A when the - // update happens. Remove the for loop below once we implement the locality - // map update. - bool in_locality_list = false; - for (size_t i = 0; i < entry_->parent_->locality_list_.size(); ++i) { - if (*entry_->parent_->locality_list_[i].locality_name == *p.first) { - in_locality_list = true; - break; - } - } - if (!in_locality_list) continue; - const LocalityEntry* entry = p.second.get(); - grpc_connectivity_state connectivity_state = entry->connectivity_state_; - switch (connectivity_state) { - case GRPC_CHANNEL_READY: { - end += entry->locality_weight_; - pickers.push_back(MakePair(end, entry->picker_wrapper_)); - break; - } - case GRPC_CHANNEL_CONNECTING: { - num_connecting++; - break; - } - case GRPC_CHANNEL_IDLE: { - num_idle++; - break; - } - case GRPC_CHANNEL_TRANSIENT_FAILURE: { - num_transient_failures++; - break; - } - default: { - gpr_log(GPR_ERROR, "Invalid locality connectivity state - %d", - connectivity_state); - } - } - } - // Pass on the constructed xds picker if it has any ready pickers in their map - // otherwise pass a QueuePicker if any of the locality pickers are in a - // connecting or idle state, finally return a transient failure picker if all - // locality pickers are in transient failure - if (!pickers.empty()) { - entry_->parent_->channel_control_helper()->UpdateState( - GRPC_CHANNEL_READY, UniquePtr( - New(std::move(pickers)))); - } else if (num_connecting > 0) { - entry_->parent_->channel_control_helper()->UpdateState( - GRPC_CHANNEL_CONNECTING, - UniquePtr(New( - entry_->parent_->Ref(DEBUG_LOCATION, "QueuePicker")))); - } else if (num_idle > 0) { - entry_->parent_->channel_control_helper()->UpdateState( - GRPC_CHANNEL_IDLE, - UniquePtr(New( - entry_->parent_->Ref(DEBUG_LOCATION, "QueuePicker")))); - } else { - GPR_ASSERT(num_transient_failures == - entry_->parent_->locality_map_.map_.size()); - grpc_error* error = - grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "connections to all localities failing"), - GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE); - entry_->parent_->channel_control_helper()->UpdateState( - GRPC_CHANNEL_TRANSIENT_FAILURE, - UniquePtr(New(error))); - } + // Construct a new xds picker and pass it to the channel. + entry_->parent_->locality_map_.UpdateXdsPickerLocked(); } void XdsLb::LocalityMap::LocalityEntry::Helper::RequestReresolution() { diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc index 5057e614c68..85f7d669ec0 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc @@ -174,7 +174,7 @@ void XdsClientStats::PruneLocalityStats() { } } -void XdsClientStats::AddCallDropped(UniquePtr category) { +void XdsClientStats::AddCallDropped(const UniquePtr& category) { total_dropped_requests_.FetchAdd(1, MemoryOrder::RELAXED); MutexLock lock(&dropped_requests_mu_); auto iter = dropped_requests_.find(category); diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h b/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h index 445675a4dcf..8f04272da75 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h @@ -208,7 +208,7 @@ class XdsClientStats { RefCountedPtr FindLocalityStats( const RefCountedPtr& locality_name); void PruneLocalityStats(); - void AddCallDropped(UniquePtr category); + void AddCallDropped(const UniquePtr& category); private: // The stats for each locality. diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc index b2615f319b9..bd8a7142e38 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc @@ -35,6 +35,7 @@ #include "envoy/api/v2/endpoint/endpoint.upb.h" #include "envoy/api/v2/endpoint/load_report.upb.h" #include "envoy/service/load_stats/v2/lrs.upb.h" +#include "envoy/type/percent.upb.h" #include "google/protobuf/any.upb.h" #include "google/protobuf/duration.upb.h" #include "google/protobuf/struct.upb.h" @@ -52,6 +53,19 @@ constexpr char kEndpointRequired[] = "endpointRequired"; } // namespace +bool XdsDropConfig::ShouldDrop(const UniquePtr** category_name) const { + for (size_t i = 0; i < drop_category_list_.size(); ++i) { + const auto& drop_category = drop_category_list_[i]; + // Generate a random number in [0, 1000000). + const int random = rand() % 1000000; + if (random < drop_category.parts_per_million) { + *category_name = &drop_category.name; + return true; + } + } + return false; +} + grpc_slice XdsEdsRequestCreateAndEncode(const char* service_name) { upb::Arena arena; // Create a request. @@ -153,6 +167,44 @@ grpc_error* LocalityParse( return GRPC_ERROR_NONE; } +grpc_error* DropParseAndAppend( + const envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload* drop_overload, + XdsDropConfig* drop_config, bool* drop_all) { + // Get the category. + upb_strview category = + envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_category( + drop_overload); + if (category.size == 0) { + return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty drop category name"); + } + // Get the drop rate (per million). + const envoy_type_FractionalPercent* drop_percentage = + envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_drop_percentage( + drop_overload); + uint32_t numerator = envoy_type_FractionalPercent_numerator(drop_percentage); + const auto denominator = + static_cast( + envoy_type_FractionalPercent_denominator(drop_percentage)); + // Normalize to million. + switch (denominator) { + case envoy_type_FractionalPercent_HUNDRED: + numerator *= 10000; + break; + case envoy_type_FractionalPercent_TEN_THOUSAND: + numerator *= 100; + break; + case envoy_type_FractionalPercent_MILLION: + break; + default: + return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unknown denominator type"); + } + // Cap numerator to 1000000. + numerator = GPR_MIN(numerator, 1000000); + if (numerator == 1000000) *drop_all = true; + drop_config->AddCategory(StringCopy(category), numerator); + return GRPC_ERROR_NONE; +} + } // namespace grpc_error* XdsEdsResponseDecodeAndParse(const grpc_slice& encoded_response, @@ -193,6 +245,7 @@ grpc_error* XdsEdsResponseDecodeAndParse(const grpc_slice& encoded_response, envoy_api_v2_ClusterLoadAssignment_parse( encoded_cluster_load_assignment.data, encoded_cluster_load_assignment.size, arena.ptr()); + // Get the endpoints. const envoy_api_v2_endpoint_LocalityLbEndpoints* const* endpoints = envoy_api_v2_ClusterLoadAssignment_endpoints(cluster_load_assignment, &size); @@ -207,6 +260,21 @@ grpc_error* XdsEdsResponseDecodeAndParse(const grpc_slice& encoded_response, std::sort(update->locality_list.data(), update->locality_list.data() + update->locality_list.size(), XdsLocalityInfo::Less()); + // Get the drop config. + update->drop_config = MakeRefCounted(); + const envoy_api_v2_ClusterLoadAssignment_Policy* policy = + envoy_api_v2_ClusterLoadAssignment_policy(cluster_load_assignment); + if (policy != nullptr) { + const envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload* const* + drop_overload = + envoy_api_v2_ClusterLoadAssignment_Policy_drop_overloads(policy, + &size); + for (size_t i = 0; i < size; ++i) { + grpc_error* error = DropParseAndAppend( + drop_overload[i], update->drop_config.get(), &update->drop_all); + if (error != GRPC_ERROR_NONE) return error; + } + } return GRPC_ERROR_NONE; } diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h index ed3b49ff836..cea5b50b9ba 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h @@ -50,9 +50,51 @@ struct XdsLocalityInfo { using XdsLocalityList = InlinedVector; +// There are two phases of accessing this class's content: +// 1. to initialize in the control plane combiner; +// 2. to use in the data plane combiner. +// So no additional synchronization is needed. +class XdsDropConfig : public RefCounted { + public: + struct DropCategory { + bool operator==(const DropCategory& other) const { + return strcmp(name.get(), other.name.get()) == 0 && + parts_per_million == other.parts_per_million; + } + + UniquePtr name; + const uint32_t parts_per_million; + }; + + using DropCategoryList = InlinedVector; + + void AddCategory(UniquePtr name, uint32_t parts_per_million) { + drop_category_list_.emplace_back( + DropCategory{std::move(name), parts_per_million}); + } + + // The only method invoked from the data plane combiner. + bool ShouldDrop(const UniquePtr** category_name) const; + + const DropCategoryList& drop_category_list() const { + return drop_category_list_; + } + + bool operator==(const XdsDropConfig& other) const { + return drop_category_list_ == other.drop_category_list_; + } + bool operator!=(const XdsDropConfig& other) const { + return !(*this == other); + } + + private: + DropCategoryList drop_category_list_; +}; + struct XdsUpdate { XdsLocalityList locality_list; - // TODO(juanlishen): Pass drop_per_million when adding drop support. + RefCountedPtr drop_config; + bool drop_all = false; }; // Creates an EDS request querying \a service_name. diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index d62dc828818..5d114c0ef2b 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -84,6 +84,7 @@ using ::envoy::api::v2::ClusterLoadAssignment; using ::envoy::api::v2::DiscoveryRequest; using ::envoy::api::v2::DiscoveryResponse; using ::envoy::api::v2::EndpointDiscoveryService; +using ::envoy::api::v2::FractionalPercent; using ::envoy::service::load_stats::v2::ClusterStats; using ::envoy::service::load_stats::v2::LoadReportingService; using ::envoy::service::load_stats::v2::LoadStatsRequest; @@ -95,6 +96,8 @@ constexpr char kEdsTypeUrl[] = constexpr char kDefaultLocalityRegion[] = "xds_default_locality_region"; constexpr char kDefaultLocalityZone[] = "xds_default_locality_zone"; constexpr char kDefaultLocalitySubzone[] = "xds_default_locality_subzone"; +constexpr char kLbDropType[] = "lb"; +constexpr char kThrottleDropType[] = "throttle"; template class CountedService : public ServiceType { @@ -205,6 +208,11 @@ class ClientStats { locality_stats_.emplace(input_locality_stats.locality().sub_zone(), LocalityStats(input_locality_stats)); } + for (const auto& input_dropped_requests : + cluster_stats.dropped_requests()) { + dropped_requests_.emplace(input_dropped_requests.category(), + input_dropped_requests.dropped_count()); + } } uint64_t total_successful_requests() const { @@ -236,10 +244,16 @@ class ClientStats { return sum; } uint64_t total_dropped_requests() const { return total_dropped_requests_; } + uint64_t dropped_requests(const grpc::string& category) const { + auto iter = dropped_requests_.find(category); + GPR_ASSERT(iter != dropped_requests_.end()); + return iter->second; + } private: std::map locality_stats_; uint64_t total_dropped_requests_; + std::map dropped_requests_; }; class EdsServiceImpl : public EdsService { @@ -301,8 +315,11 @@ class EdsServiceImpl : public EdsService { gpr_log(GPR_INFO, "LB[%p]: shut down", this); } - static DiscoveryResponse BuildResponseForBackends( - const std::vector>& backend_ports) { + static DiscoveryResponse BuildResponse( + const std::vector>& backend_ports, + const std::map& drop_categories = {}, + const FractionalPercent::DenominatorType denominator = + FractionalPercent::MILLION) { ClusterLoadAssignment assignment; assignment.set_cluster_name("service name"); for (size_t i = 0; i < backend_ports.size(); ++i) { @@ -323,6 +340,18 @@ class EdsServiceImpl : public EdsService { socket_address->set_port_value(backend_port); } } + if (!drop_categories.empty()) { + auto* policy = assignment.mutable_policy(); + for (const auto& p : drop_categories) { + const grpc::string& name = p.first; + const uint32_t parts_per_million = p.second; + auto* drop_overload = policy->add_drop_overloads(); + drop_overload->set_category(name); + auto* drop_percentage = drop_overload->mutable_drop_percentage(); + drop_percentage->set_numerator(parts_per_million); + drop_percentage->set_denominator(denominator); + } + } DiscoveryResponse response; response.set_type_url(kEdsTypeUrl); response.add_resources()->PackFrom(assignment); @@ -883,8 +912,7 @@ TEST_F(SingleBalancerTest, Vanilla) { SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcsPerAddress = 100; ScheduleResponseForBalancer( - 0, EdsServiceImpl::BuildResponseForBackends(GetBackendPortsInGroups()), - 0); + 0, EdsServiceImpl::BuildResponse(GetBackendPortsInGroups()), 0); // Make sure that trying to connect works without a call. channel_->GetState(true /* try_to_connect */); // We need to wait for all backends to come online. @@ -912,8 +940,7 @@ TEST_F(SingleBalancerTest, SameBackendListedMultipleTimes) { ports.push_back(backends_[0]->port()); ports.push_back(backends_[0]->port()); const size_t kNumRpcsPerAddress = 10; - ScheduleResponseForBalancer( - 0, EdsServiceImpl::BuildResponseForBackends({ports}), 0); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse({ports}), 0); // We need to wait for the backend to come online. WaitForBackend(0); // Send kNumRpcsPerAddress RPCs per server. @@ -934,8 +961,7 @@ TEST_F(SingleBalancerTest, SecureNaming) { SetNextResolutionForLbChannel({balancers_[0]->port()}); const size_t kNumRpcsPerAddress = 100; ScheduleResponseForBalancer( - 0, EdsServiceImpl::BuildResponseForBackends(GetBackendPortsInGroups()), - 0); + 0, EdsServiceImpl::BuildResponse(GetBackendPortsInGroups()), 0); // Make sure that trying to connect works without a call. channel_->GetState(true /* try_to_connect */); // We need to wait for all backends to come online. @@ -980,11 +1006,10 @@ TEST_F(SingleBalancerTest, InitiallyEmptyServerlist) { const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor(); const int kCallDeadlineMs = kServerlistDelayMs * 2; // First response is an empty serverlist, sent right away. - ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponseForBackends({{}}), - 0); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse({{}}), 0); // Send non-empty serverlist only after kServerlistDelayMs ScheduleResponseForBalancer( - 0, EdsServiceImpl::BuildResponseForBackends(GetBackendPortsInGroups()), + 0, EdsServiceImpl::BuildResponse(GetBackendPortsInGroups()), kServerlistDelayMs); const auto t0 = system_clock::now(); // Client will block: LB will initially send empty serverlist. @@ -1012,8 +1037,7 @@ TEST_F(SingleBalancerTest, AllServersUnreachableFailFast) { for (size_t i = 0; i < kNumUnreachableServers; ++i) { ports.push_back(grpc_pick_unused_port_or_die()); } - ScheduleResponseForBalancer( - 0, EdsServiceImpl::BuildResponseForBackends({ports}), 0); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse({ports}), 0); const Status status = SendRpc(); // The error shouldn't be DEADLINE_EXCEEDED. EXPECT_EQ(StatusCode::UNAVAILABLE, status.error_code()); @@ -1023,6 +1047,254 @@ TEST_F(SingleBalancerTest, AllServersUnreachableFailFast) { EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } +TEST_F(SingleBalancerTest, Drop) { + SetNextResolution({}, kDefaultServiceConfig_.c_str()); + SetNextResolutionForLbChannelAllBalancers(); + const size_t kNumRpcs = 5000; + const uint32_t kDropPerMillionForLb = 100000; + const uint32_t kDropPerMillionForThrottle = 200000; + const double kDropRateForLb = kDropPerMillionForLb / 1000000.0; + const double kDropRateForThrottle = kDropPerMillionForThrottle / 1000000.0; + const double KDropRateForLbAndThrottle = + kDropRateForLb + (1 - kDropRateForLb) * kDropRateForThrottle; + // The EDS response contains two drop categories. + ScheduleResponseForBalancer( + 0, + EdsServiceImpl::BuildResponse( + GetBackendPortsInGroups(), + {{kLbDropType, kDropPerMillionForLb}, + {kThrottleDropType, kDropPerMillionForThrottle}}), + 0); + WaitForAllBackends(); + // Send kNumRpcs RPCs and count the drops. + size_t num_drops = 0; + for (size_t i = 0; i < kNumRpcs; ++i) { + EchoResponse response; + const Status status = SendRpc(&response); + if (!status.ok() && + status.error_message() == "Call dropped by load balancing policy") { + ++num_drops; + } else { + EXPECT_TRUE(status.ok()) << "code=" << status.error_code() + << " message=" << status.error_message(); + EXPECT_EQ(response.message(), kRequestMessage_); + } + } + // The drop rate should be roughly equal to the expectation. + const double seen_drop_rate = static_cast(num_drops) / kNumRpcs; + const double kErrorTolerance = 0.2; + EXPECT_THAT( + seen_drop_rate, + ::testing::AllOf( + ::testing::Ge(KDropRateForLbAndThrottle * (1 - kErrorTolerance)), + ::testing::Le(KDropRateForLbAndThrottle * (1 + kErrorTolerance)))); + // The EDS service got a single request, and sent a single response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); +} + +TEST_F(SingleBalancerTest, DropPerHundred) { + SetNextResolution({}, kDefaultServiceConfig_.c_str()); + SetNextResolutionForLbChannelAllBalancers(); + const size_t kNumRpcs = 5000; + const uint32_t kDropPerHundredForLb = 10; + const double kDropRateForLb = kDropPerHundredForLb / 100.0; + // The EDS response contains one drop category. + ScheduleResponseForBalancer( + 0, + EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), + {{kLbDropType, kDropPerHundredForLb}}, + FractionalPercent::HUNDRED), + 0); + WaitForAllBackends(); + // Send kNumRpcs RPCs and count the drops. + size_t num_drops = 0; + for (size_t i = 0; i < kNumRpcs; ++i) { + EchoResponse response; + const Status status = SendRpc(&response); + if (!status.ok() && + status.error_message() == "Call dropped by load balancing policy") { + ++num_drops; + } else { + EXPECT_TRUE(status.ok()) << "code=" << status.error_code() + << " message=" << status.error_message(); + EXPECT_EQ(response.message(), kRequestMessage_); + } + } + // The drop rate should be roughly equal to the expectation. + const double seen_drop_rate = static_cast(num_drops) / kNumRpcs; + const double kErrorTolerance = 0.2; + EXPECT_THAT( + seen_drop_rate, + ::testing::AllOf(::testing::Ge(kDropRateForLb * (1 - kErrorTolerance)), + ::testing::Le(kDropRateForLb * (1 + kErrorTolerance)))); + // The EDS service got a single request, and sent a single response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); +} + +TEST_F(SingleBalancerTest, DropPerTenThousand) { + SetNextResolution({}, kDefaultServiceConfig_.c_str()); + SetNextResolutionForLbChannelAllBalancers(); + const size_t kNumRpcs = 5000; + const uint32_t kDropPerTenThousandForLb = 1000; + const double kDropRateForLb = kDropPerTenThousandForLb / 10000.0; + // The EDS response contains one drop category. + ScheduleResponseForBalancer( + 0, + EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), + {{kLbDropType, kDropPerTenThousandForLb}}, + FractionalPercent::TEN_THOUSAND), + 0); + WaitForAllBackends(); + // Send kNumRpcs RPCs and count the drops. + size_t num_drops = 0; + for (size_t i = 0; i < kNumRpcs; ++i) { + EchoResponse response; + const Status status = SendRpc(&response); + if (!status.ok() && + status.error_message() == "Call dropped by load balancing policy") { + ++num_drops; + } else { + EXPECT_TRUE(status.ok()) << "code=" << status.error_code() + << " message=" << status.error_message(); + EXPECT_EQ(response.message(), kRequestMessage_); + } + } + // The drop rate should be roughly equal to the expectation. + const double seen_drop_rate = static_cast(num_drops) / kNumRpcs; + const double kErrorTolerance = 0.2; + EXPECT_THAT( + seen_drop_rate, + ::testing::AllOf(::testing::Ge(kDropRateForLb * (1 - kErrorTolerance)), + ::testing::Le(kDropRateForLb * (1 + kErrorTolerance)))); + // The EDS service got a single request, and sent a single response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); +} + +TEST_F(SingleBalancerTest, DropUpdate) { + SetNextResolution({}, kDefaultServiceConfig_.c_str()); + SetNextResolutionForLbChannelAllBalancers(); + const size_t kNumRpcs = 5000; + const uint32_t kDropPerMillionForLb = 100000; + const uint32_t kDropPerMillionForThrottle = 200000; + const double kDropRateForLb = kDropPerMillionForLb / 1000000.0; + const double kDropRateForThrottle = kDropPerMillionForThrottle / 1000000.0; + const double KDropRateForLbAndThrottle = + kDropRateForLb + (1 - kDropRateForLb) * kDropRateForThrottle; + // The first EDS response contains one drop category. + ScheduleResponseForBalancer( + 0, + EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), + {{kLbDropType, kDropPerMillionForLb}}), + 0); + // The second EDS response contains two drop categories. + ScheduleResponseForBalancer( + 0, + EdsServiceImpl::BuildResponse( + GetBackendPortsInGroups(), + {{kLbDropType, kDropPerMillionForLb}, + {kThrottleDropType, kDropPerMillionForThrottle}}), + 5000); + WaitForAllBackends(); + // Send kNumRpcs RPCs and count the drops. + size_t num_drops = 0; + gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); + for (size_t i = 0; i < kNumRpcs; ++i) { + EchoResponse response; + const Status status = SendRpc(&response); + if (!status.ok() && + status.error_message() == "Call dropped by load balancing policy") { + ++num_drops; + } else { + EXPECT_TRUE(status.ok()) << "code=" << status.error_code() + << " message=" << status.error_message(); + EXPECT_EQ(response.message(), kRequestMessage_); + } + } + gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); + // The drop rate should be roughly equal to the expectation. + double seen_drop_rate = static_cast(num_drops) / kNumRpcs; + const double kErrorTolerance = 0.2; + EXPECT_THAT( + seen_drop_rate, + ::testing::AllOf(::testing::Ge(kDropRateForLb * (1 - kErrorTolerance)), + ::testing::Le(kDropRateForLb * (1 + kErrorTolerance)))); + // Wait until the drop rate increases to the middle of the two configs, which + // implies that the update has been in effect. + const double kDropRateThreshold = + (kDropRateForLb + KDropRateForLbAndThrottle) / 2; + size_t num_rpcs = kNumRpcs; + while (seen_drop_rate < kDropRateThreshold) { + EchoResponse response; + const Status status = SendRpc(&response); + ++num_rpcs; + if (!status.ok() && + status.error_message() == "Call dropped by load balancing policy") { + ++num_drops; + } else { + EXPECT_TRUE(status.ok()) << "code=" << status.error_code() + << " message=" << status.error_message(); + EXPECT_EQ(response.message(), kRequestMessage_); + } + seen_drop_rate = static_cast(num_drops) / num_rpcs; + } + // Send kNumRpcs RPCs and count the drops. + num_drops = 0; + gpr_log(GPR_INFO, "========= BEFORE SECOND BATCH =========="); + for (size_t i = 0; i < kNumRpcs; ++i) { + EchoResponse response; + const Status status = SendRpc(&response); + if (!status.ok() && + status.error_message() == "Call dropped by load balancing policy") { + ++num_drops; + } else { + EXPECT_TRUE(status.ok()) << "code=" << status.error_code() + << " message=" << status.error_message(); + EXPECT_EQ(response.message(), kRequestMessage_); + } + } + gpr_log(GPR_INFO, "========= DONE WITH SECOND BATCH =========="); + // The new drop rate should be roughly equal to the expectation. + seen_drop_rate = static_cast(num_drops) / kNumRpcs; + EXPECT_THAT( + seen_drop_rate, + ::testing::AllOf( + ::testing::Ge(KDropRateForLbAndThrottle * (1 - kErrorTolerance)), + ::testing::Le(KDropRateForLbAndThrottle * (1 + kErrorTolerance)))); + // The EDS service got a single request, + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + // and sent two responses + EXPECT_EQ(2U, balancers_[0]->eds_service()->response_count()); +} + +TEST_F(SingleBalancerTest, DropAll) { + SetNextResolution({}, kDefaultServiceConfig_.c_str()); + SetNextResolutionForLbChannelAllBalancers(); + const size_t kNumRpcs = 1000; + const uint32_t kDropPerMillionForLb = 100000; + const uint32_t kDropPerMillionForThrottle = 1000000; + // The EDS response contains two drop categories. + ScheduleResponseForBalancer( + 0, + EdsServiceImpl::BuildResponse( + GetBackendPortsInGroups(), + {{kLbDropType, kDropPerMillionForLb}, + {kThrottleDropType, kDropPerMillionForThrottle}}), + 0); + // Send kNumRpcs RPCs and all of them are dropped. + for (size_t i = 0; i < kNumRpcs; ++i) { + EchoResponse response; + const Status status = SendRpc(&response); + EXPECT_TRUE(!status.ok() && status.error_message() == + "Call dropped by load balancing policy"); + } + // The EDS service got a single request, and sent a single response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); +} + TEST_F(SingleBalancerTest, Fallback) { const int kFallbackTimeoutMs = 200 * grpc_test_slowdown_factor(); const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor(); @@ -1034,7 +1306,7 @@ TEST_F(SingleBalancerTest, Fallback) { // Send non-empty serverlist only after kServerlistDelayMs. ScheduleResponseForBalancer( 0, - EdsServiceImpl::BuildResponseForBackends( + EdsServiceImpl::BuildResponse( GetBackendPortsInGroups(kNumBackendsInResolution /* start_index */)), kServerlistDelayMs); // Wait until all the fallback backends are reachable. @@ -1083,7 +1355,7 @@ TEST_F(SingleBalancerTest, FallbackUpdate) { // Send non-empty serverlist only after kServerlistDelayMs. ScheduleResponseForBalancer( 0, - EdsServiceImpl::BuildResponseForBackends(GetBackendPortsInGroups( + EdsServiceImpl::BuildResponse(GetBackendPortsInGroups( kNumBackendsInResolution + kNumBackendsInResolutionUpdate /* start_index */)), kServerlistDelayMs); @@ -1184,10 +1456,8 @@ TEST_F(SingleBalancerTest, FallbackIfResponseReceivedButChildNotReady) { SetNextResolutionForLbChannelAllBalancers(); // Send a serverlist that only contains an unreachable backend before fallback // timeout. - ScheduleResponseForBalancer(0, - EdsServiceImpl::BuildResponseForBackends( - {{grpc_pick_unused_port_or_die()}}), - 0); + ScheduleResponseForBalancer( + 0, EdsServiceImpl::BuildResponse({{grpc_pick_unused_port_or_die()}}), 0); // Because no child policy is ready before fallback timeout, we enter fallback // mode. WaitForBackend(0); @@ -1199,9 +1469,12 @@ TEST_F(SingleBalancerTest, FallbackModeIsExitedWhenBalancerSaysToDropAllCalls) { SetNextResolutionForLbChannel({grpc_pick_unused_port_or_die()}); // Enter fallback mode because the LB channel fails to connect. WaitForBackend(0); - // Return a new balancer that sends an empty serverlist. - ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponseForBackends({{}}), - 0); + // Return a new balancer that sends a response to drop all calls. + ScheduleResponseForBalancer( + 0, + EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), + {{kLbDropType, 1000000}}), + 0); SetNextResolutionForLbChannelAllBalancers(); // Send RPCs until failure. gpr_timespec deadline = gpr_time_add( @@ -1222,7 +1495,7 @@ TEST_F(SingleBalancerTest, FallbackModeIsExitedAfterChildRready) { // Return a new balancer that sends a dead backend. ShutdownBackend(1); ScheduleResponseForBalancer( - 0, EdsServiceImpl::BuildResponseForBackends({{backends_[1]->port()}}), 0); + 0, EdsServiceImpl::BuildResponse({{backends_[1]->port()}}), 0); SetNextResolutionForLbChannelAllBalancers(); // The state (TRANSIENT_FAILURE) update from the child policy will be ignored // because we are still in fallback mode. @@ -1247,8 +1520,7 @@ TEST_F(SingleBalancerTest, BackendsRestart) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); ScheduleResponseForBalancer( - 0, EdsServiceImpl::BuildResponseForBackends(GetBackendPortsInGroups()), - 0); + 0, EdsServiceImpl::BuildResponse(GetBackendPortsInGroups()), 0); WaitForAllBackends(); // Stop backends. RPCs should fail. ShutdownAllBackends(); @@ -1269,10 +1541,10 @@ TEST_F(UpdatesTest, UpdateBalancersButKeepUsingOriginalBalancer) { SetNextResolutionForLbChannelAllBalancers(); auto first_backend = GetBackendPortsInGroups(0, 1); auto second_backend = GetBackendPortsInGroups(1, 2); - ScheduleResponseForBalancer( - 0, EdsServiceImpl::BuildResponseForBackends(first_backend), 0); - ScheduleResponseForBalancer( - 1, EdsServiceImpl::BuildResponseForBackends(second_backend), 0); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(first_backend), + 0); + ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(second_backend), + 0); // Wait until the first backend is ready. WaitForBackend(0); @@ -1322,10 +1594,10 @@ TEST_F(UpdatesTest, UpdateBalancerName) { SetNextResolutionForLbChannelAllBalancers(); auto first_backend = GetBackendPortsInGroups(0, 1); auto second_backend = GetBackendPortsInGroups(1, 2); - ScheduleResponseForBalancer( - 0, EdsServiceImpl::BuildResponseForBackends(first_backend), 0); - ScheduleResponseForBalancer( - 1, EdsServiceImpl::BuildResponseForBackends(second_backend), 0); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(first_backend), + 0); + ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(second_backend), + 0); // Wait until the first backend is ready. WaitForBackend(0); @@ -1393,10 +1665,10 @@ TEST_F(UpdatesTest, UpdateBalancersRepeated) { SetNextResolutionForLbChannelAllBalancers(); auto first_backend = GetBackendPortsInGroups(0, 1); auto second_backend = GetBackendPortsInGroups(1, 2); - ScheduleResponseForBalancer( - 0, EdsServiceImpl::BuildResponseForBackends(first_backend), 0); - ScheduleResponseForBalancer( - 1, EdsServiceImpl::BuildResponseForBackends(second_backend), 0); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(first_backend), + 0); + ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(second_backend), + 0); // Wait until the first backend is ready. WaitForBackend(0); @@ -1461,10 +1733,10 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { SetNextResolutionForLbChannel({balancers_[0]->port()}); auto first_backend = GetBackendPortsInGroups(0, 1); auto second_backend = GetBackendPortsInGroups(1, 2); - ScheduleResponseForBalancer( - 0, EdsServiceImpl::BuildResponseForBackends(first_backend), 0); - ScheduleResponseForBalancer( - 1, EdsServiceImpl::BuildResponseForBackends(second_backend), 0); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(first_backend), + 0); + ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(second_backend), + 0); // Start servers and send 10 RPCs per server. gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); @@ -1535,14 +1807,6 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { // TODO(juanlishen): Add TEST_F(UpdatesWithClientLoadReportingTest, // ReresolveDeadBalancer) -// The drop tests are deferred because the drop handling hasn't been added yet. - -// TODO(roth): Add TEST_F(SingleBalancerTest, Drop) - -// TODO(roth): Add TEST_F(SingleBalancerTest, DropAllFirst) - -// TODO(roth): Add TEST_F(SingleBalancerTest, DropAll) - class SingleBalancerWithClientLoadReportingTest : public XdsEnd2endTest { public: SingleBalancerWithClientLoadReportingTest() : XdsEnd2endTest(4, 1, 3) {} @@ -1555,7 +1819,7 @@ TEST_F(SingleBalancerWithClientLoadReportingTest, Vanilla) { // TODO(juanlishen): Partition the backends after multiple localities is // tested. ScheduleResponseForBalancer(0, - EdsServiceImpl::BuildResponseForBackends( + EdsServiceImpl::BuildResponse( GetBackendPortsInGroups(0, backends_.size())), 0); // Wait until all backends are ready. @@ -1595,7 +1859,7 @@ TEST_F(SingleBalancerWithClientLoadReportingTest, BalancerRestart) { backends_.size() - kNumBackendsFirstPass; ScheduleResponseForBalancer( 0, - EdsServiceImpl::BuildResponseForBackends( + EdsServiceImpl::BuildResponse( GetBackendPortsInGroups(0, kNumBackendsFirstPass)), 0); // Wait until all backends returned by the balancer are ready. @@ -1626,7 +1890,7 @@ TEST_F(SingleBalancerWithClientLoadReportingTest, BalancerRestart) { balancers_[0]->Start(server_host_); ScheduleResponseForBalancer( 0, - EdsServiceImpl::BuildResponseForBackends( + EdsServiceImpl::BuildResponse( GetBackendPortsInGroups(kNumBackendsFirstPass)), 0); // Wait for queries to start going to one of the new backends. @@ -1646,7 +1910,75 @@ TEST_F(SingleBalancerWithClientLoadReportingTest, BalancerRestart) { EXPECT_EQ(0U, client_stats->total_dropped_requests()); } -// TODO(juanlishen): Add TEST_F(SingleBalancerWithClientLoadReportingTest, Drop) +class SingleBalancerWithClientLoadReportingAndDropTest : public XdsEnd2endTest { + public: + SingleBalancerWithClientLoadReportingAndDropTest() + : XdsEnd2endTest(4, 1, 20) {} +}; + +TEST_F(SingleBalancerWithClientLoadReportingAndDropTest, Vanilla) { + SetNextResolution({}, kDefaultServiceConfig_.c_str()); + SetNextResolutionForLbChannelAllBalancers(); + const size_t kNumRpcs = 3000; + const uint32_t kDropPerMillionForLb = 100000; + const uint32_t kDropPerMillionForThrottle = 200000; + const double kDropRateForLb = kDropPerMillionForLb / 1000000.0; + const double kDropRateForThrottle = kDropPerMillionForThrottle / 1000000.0; + const double KDropRateForLbAndThrottle = + kDropRateForLb + (1 - kDropRateForLb) * kDropRateForThrottle; + // The EDS response contains two drop categories. + ScheduleResponseForBalancer( + 0, + EdsServiceImpl::BuildResponse( + GetBackendPortsInGroups(), + {{kLbDropType, kDropPerMillionForLb}, + {kThrottleDropType, kDropPerMillionForThrottle}}), + 0); + int num_ok = 0; + int num_failure = 0; + int num_drops = 0; + std::tie(num_ok, num_failure, num_drops) = WaitForAllBackends(); + const size_t num_warmup = num_ok + num_failure + num_drops; + // Send kNumRpcs RPCs and count the drops. + for (size_t i = 0; i < kNumRpcs; ++i) { + EchoResponse response; + const Status status = SendRpc(&response); + if (!status.ok() && + status.error_message() == "Call dropped by load balancing policy") { + ++num_drops; + } else { + EXPECT_TRUE(status.ok()) << "code=" << status.error_code() + << " message=" << status.error_message(); + EXPECT_EQ(response.message(), kRequestMessage_); + } + } + // The drop rate should be roughly equal to the expectation. + const double seen_drop_rate = static_cast(num_drops) / kNumRpcs; + const double kErrorTolerance = 0.2; + EXPECT_THAT( + seen_drop_rate, + ::testing::AllOf( + ::testing::Ge(KDropRateForLbAndThrottle * (1 - kErrorTolerance)), + ::testing::Le(KDropRateForLbAndThrottle * (1 + kErrorTolerance)))); + // Check client stats. + ClientStats* client_stats = balancers_[0]->lrs_service()->WaitForLoadReport(); + EXPECT_EQ(num_drops, client_stats->total_dropped_requests()); + const size_t total_rpc = num_warmup + kNumRpcs; + EXPECT_THAT( + client_stats->dropped_requests(kLbDropType), + ::testing::AllOf( + ::testing::Ge(total_rpc * kDropRateForLb * (1 - kErrorTolerance)), + ::testing::Le(total_rpc * kDropRateForLb * (1 + kErrorTolerance)))); + EXPECT_THAT(client_stats->dropped_requests(kThrottleDropType), + ::testing::AllOf( + ::testing::Ge(total_rpc * (1 - kDropRateForLb) * + kDropRateForThrottle * (1 - kErrorTolerance)), + ::testing::Le(total_rpc * (1 - kDropRateForLb) * + kDropRateForThrottle * (1 + kErrorTolerance)))); + // The EDS service got a single request, and sent a single response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); +} } // namespace } // namespace testing From 58ef8943a597bd19ebb568a1a18f73f8113225ab Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Sat, 10 Aug 2019 13:45:13 -0700 Subject: [PATCH 1196/1555] Added missing resources --- src/objective-c/tests/Podfile | 2 +- src/objective-c/tests/Tests.xcodeproj/project.pbxproj | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile index be935732935..c2297aa00fd 100644 --- a/src/objective-c/tests/Podfile +++ b/src/objective-c/tests/Podfile @@ -114,7 +114,7 @@ post_install do |installer| end # Enable NSAssert on gRPC - if /(gRPC|ProtoRPC|RxLibrary)-(mac|i)OS/.match(target.name) + if /(gRPC|ProtoRPC|RxLibrary)-(mac|i|tv)OS/.match(target.name) target.build_configurations.each do |config| if config.name != 'Release' config.build_settings['ENABLE_NS_ASSERTIONS'] = 'YES' diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index 8548620522d..a54dca59b9c 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -37,6 +37,7 @@ 65EB19E418B39A8374D407BB /* libPods-CronetTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B1511C20E16A8422B58D61A /* libPods-CronetTests.a */; }; 903163C7FE885838580AEC7A /* libPods-InteropTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D457AD9797664CFA191C3280 /* libPods-InteropTests.a */; }; 953CD2942A3A6D6CE695BE87 /* libPods-MacTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 276873A05AC5479B60DF6079 /* libPods-MacTests.a */; }; + ABA946DC22FF62FC00577AEF /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; ABCB3EE422F23BEF00F0FECE /* InteropTestsRemote.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F488822778B04006656AD /* InteropTestsRemote.m */; }; ABCB3EE522F23BEF00F0FECE /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F488222778A88006656AD /* InteropTests.m */; }; ABCB3EE622F23BEF00F0FECE /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; @@ -644,6 +645,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + ABA946DC22FF62FC00577AEF /* TestCertificates.bundle in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; From 7a6c4213128b81639f6e0c68c55a5a332d1ddbe8 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Sat, 10 Aug 2019 13:45:32 -0700 Subject: [PATCH 1197/1555] Clarified exception --- src/objective-c/GRPCClient/GRPCCall+Tests.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall+Tests.m b/src/objective-c/GRPCClient/GRPCCall+Tests.m index ac3b6a658f9..20f5cba4178 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Tests.m +++ b/src/objective-c/GRPCClient/GRPCCall+Tests.m @@ -27,8 +27,14 @@ + (void)useTestCertsPath:(NSString *)certsPath testName:(NSString *)testName forHost:(NSString *)host { - if (!host || !certsPath || !testName) { - [NSException raise:NSInvalidArgumentException format:@"host, path and name must be provided."]; + if (!host) { + [NSException raise:NSInvalidArgumentException format:@"host must be provided."]; + } + if (!certsPath) { + [NSException raise:NSInvalidArgumentException format:@"certpath be provided."]; + } + if (!testName) { + [NSException raise:NSInvalidArgumentException format:@"testname must be provided."]; } NSError *error = nil; NSString *certs = From 249f793a7b600644f7e31c2df50f3fbe06effbd0 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Sat, 10 Aug 2019 21:20:10 -0700 Subject: [PATCH 1198/1555] fix unit tests --- src/objective-c/tests/UnitTests/APIv2Tests.m | 2 +- src/objective-c/tests/UnitTests/GRPCClientTests.m | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/objective-c/tests/UnitTests/APIv2Tests.m b/src/objective-c/tests/UnitTests/APIv2Tests.m index 6d99f3be44f..86d4e8b3619 100644 --- a/src/objective-c/tests/UnitTests/APIv2Tests.m +++ b/src/objective-c/tests/UnitTests/APIv2Tests.m @@ -17,7 +17,6 @@ */ #import -#import #import #import #import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" @@ -25,6 +24,7 @@ #include #include +#import "../version.h" // The server address is derived from preprocessor macro, which is // in turn derived from environment variable of the same name. diff --git a/src/objective-c/tests/UnitTests/GRPCClientTests.m b/src/objective-c/tests/UnitTests/GRPCClientTests.m index 5dbea09ca85..3d144c33b06 100644 --- a/src/objective-c/tests/UnitTests/GRPCClientTests.m +++ b/src/objective-c/tests/UnitTests/GRPCClientTests.m @@ -25,7 +25,6 @@ #import #import #import -#import #import #import #import @@ -34,6 +33,8 @@ #include +#import "../version.h" + #define TEST_TIMEOUT 16 // The server address is derived from preprocessor macro, which is From 955a74925ac094757f5da207deb5ddadccb4fd72 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Sat, 10 Aug 2019 22:24:58 -0700 Subject: [PATCH 1199/1555] Bug fix --- src/objective-c/BUILD | 4 ++-- src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m | 10 +--------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/objective-c/BUILD b/src/objective-c/BUILD index 322c84bb9bb..a79f73c265f 100644 --- a/src/objective-c/BUILD +++ b/src/objective-c/BUILD @@ -109,7 +109,7 @@ grpc_objc_library( "GRPCClient/GRPCCall+Tests.h", "GRPCClient/GRPCCall+ChannelArg.h", ], - textual_hdrs = native.glob(["GRPCClient/private/GRPCCore/*.h"]), + textual_hdrs = glob(["GRPCClient/private/GRPCCore/*.h"]), srcs = [ "GRPCClient/GRPCCall+ChannelArg.m", "GRPCClient/GRPCCall+ChannelCredentials.m", @@ -117,7 +117,7 @@ grpc_objc_library( "GRPCClient/GRPCCall+OAuth2.m", "GRPCClient/GRPCCall+Tests.m", "GRPCClient/GRPCCallLegacy.m", - ] + native.glob(["GRPCClient/private/GRPCCore/*.m"]), + ] + glob(["GRPCClient/private/GRPCCore/*.m"]), data = [":gRPCCertificates"], includes = ["."], deps = [ diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m index 04f91e494a7..691521ae7bb 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m @@ -126,17 +126,9 @@ static NSMutableDictionary *gHostCache; + (GRPCCallOptions *)callOptionsForHost:(NSString *)host { // TODO (mxyan): Remove when old API is deprecated - NSURL *hostURL = [NSURL URLWithString:[@"https://" stringByAppendingString:host]]; - if (hostURL.host && hostURL.port == nil) { - host = [hostURL.host stringByAppendingString:@":443"]; - } - GRPCCallOptions *callOptions = nil; @synchronized(gHostCache) { - GRPCHost *hostConfig = gHostCache[host]; - if (hostConfig == nil) { - hostConfig = [GRPCHost hostWithAddress:host]; - } + GRPCHost *hostConfig = [GRPCHost hostWithAddress:host]; callOptions = [hostConfig callOptions]; } NSAssert(callOptions != nil, @"Unable to create call options object"); From c8225c461bde8fb3bfa0853af4135dc00cb920fe Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Sat, 10 Aug 2019 22:47:44 -0700 Subject: [PATCH 1200/1555] Build fix --- src/objective-c/BUILD | 4 ++++ src/objective-c/ProtoRPC/ProtoRPCLegacy.h | 1 + 2 files changed, 5 insertions(+) diff --git a/src/objective-c/BUILD b/src/objective-c/BUILD index a79f73c265f..8fb253ca4c0 100644 --- a/src/objective-c/BUILD +++ b/src/objective-c/BUILD @@ -167,6 +167,10 @@ grpc_objc_library( "ProtoRPC/ProtoRPCLegacy.m", "ProtoRPC/ProtoServiceLegacy.m", ], + hdrs = [ + "ProtoRPC/ProtoRPCLegacy.h", + "ProtoRPC/ProtoService.h", + ], deps = [ ":rx_library", ":proto_objc_rpc_v2", diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.h b/src/objective-c/ProtoRPC/ProtoRPCLegacy.h index 54823ab90db..b8d4003f695 100644 --- a/src/objective-c/ProtoRPC/ProtoRPCLegacy.h +++ b/src/objective-c/ProtoRPC/ProtoRPCLegacy.h @@ -24,6 +24,7 @@ #import #import #import +#import @class GRPCProtoMethod; @class GRXWriter; From dd2dc23d63b0050d6ec51ceeeae5c09b66edaf2a Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Sun, 11 Aug 2019 11:38:45 -0700 Subject: [PATCH 1201/1555] swift build fix --- src/objective-c/BUILD | 1 + 1 file changed, 1 insertion(+) diff --git a/src/objective-c/BUILD b/src/objective-c/BUILD index 8fb253ca4c0..296f5255732 100644 --- a/src/objective-c/BUILD +++ b/src/objective-c/BUILD @@ -168,6 +168,7 @@ grpc_objc_library( "ProtoRPC/ProtoServiceLegacy.m", ], hdrs = [ + "ProtoRPC/ProtoMethod.h", "ProtoRPC/ProtoRPCLegacy.h", "ProtoRPC/ProtoService.h", ], From 68d61994435d80b70fcb43a7779d615d6224f839 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Sun, 11 Aug 2019 19:04:52 -0700 Subject: [PATCH 1202/1555] Fix samples --- .../examples/tvOS-sample/tvOS-sample/ViewController.m | 2 ++ .../watchOS-sample/WatchKit-Extension/InterfaceController.m | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m index c94ee8c2569..3081b28f0ea 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m @@ -25,6 +25,8 @@ #import "src/objective-c/examples/RemoteTestClient/Messages.pbobjc.h" #import "src/objective-c/examples/RemoteTestClient/Test.pbrpc.h" #endif +#import +#import @interface ViewController () diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m index 3e97767cf0c..050234cb947 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m +++ b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m @@ -24,6 +24,8 @@ #import "src/objective-c/examples/RemoteTestClient/Messages.pbobjc.h" #import "src/objective-c/examples/RemoteTestClient/Test.pbrpc.h" #endif +#import +#import @interface InterfaceController () From 1c9fb855d7134a196c9d5e8b65f8be2abe277a73 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Sun, 11 Aug 2019 19:12:28 -0700 Subject: [PATCH 1203/1555] Add locality map tests --- .../client_channel/lb_policy/xds/xds.cc | 2 +- test/cpp/end2end/xds_end2end_test.cc | 98 ++++++++++++++++--- 2 files changed, 88 insertions(+), 12 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index 4f119edefce..468c9d84591 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -509,7 +509,7 @@ class XdsLb : public LoadBalancingPolicy { OrphanablePtr child_policy_; OrphanablePtr pending_child_policy_; RefCountedPtr picker_wrapper_; - grpc_connectivity_state connectivity_state_; + grpc_connectivity_state connectivity_state_ = GRPC_CHANNEL_IDLE; uint32_t locality_weight_; }; diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index 5d114c0ef2b..dda5bdf58d0 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -98,6 +98,7 @@ constexpr char kDefaultLocalityZone[] = "xds_default_locality_zone"; constexpr char kDefaultLocalitySubzone[] = "xds_default_locality_subzone"; constexpr char kLbDropType[] = "lb"; constexpr char kThrottleDropType[] = "throttle"; +constexpr int kDefaultLocalityWeight = 3; template class CountedService : public ServiceType { @@ -317,6 +318,7 @@ class EdsServiceImpl : public EdsService { static DiscoveryResponse BuildResponse( const std::vector>& backend_ports, + const std::vector& lb_weights = {}, const std::map& drop_categories = {}, const FractionalPercent::DenominatorType denominator = FractionalPercent::MILLION) { @@ -324,7 +326,9 @@ class EdsServiceImpl : public EdsService { assignment.set_cluster_name("service name"); for (size_t i = 0; i < backend_ports.size(); ++i) { auto* endpoints = assignment.add_endpoints(); - endpoints->mutable_load_balancing_weight()->set_value(3); + const int lb_weight = + lb_weights.empty() ? kDefaultLocalityWeight : lb_weights[i]; + endpoints->mutable_load_balancing_weight()->set_value(lb_weight); endpoints->set_priority(0); endpoints->mutable_locality()->set_region(kDefaultLocalityRegion); endpoints->mutable_locality()->set_zone(kDefaultLocalityZone); @@ -620,11 +624,14 @@ class XdsEnd2endTest : public ::testing::Test { return std::make_tuple(num_ok, num_failure, num_drops); } - void WaitForBackend(size_t backend_idx) { + void WaitForBackend(size_t backend_idx, bool reset_counters = true) { + gpr_log(GPR_INFO, + "========= WAITING FOR BACKEND %lu ==========", backend_idx); do { (void)SendRpc(); } while (backends_[backend_idx]->backend_service()->request_count() == 0); - ResetBackendCounters(); + if (reset_counters) ResetBackendCounters(); + gpr_log(GPR_INFO, "========= BACKEND %lu READY ==========", backend_idx); } grpc_core::ServerAddressList CreateLbAddressesFromPortList( @@ -1047,6 +1054,75 @@ TEST_F(SingleBalancerTest, AllServersUnreachableFailFast) { EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } +TEST_F(SingleBalancerTest, LocalityMapWeightedRoundRobin) { + SetNextResolution({}, kDefaultServiceConfig_.c_str()); + SetNextResolutionForLbChannelAllBalancers(); + const size_t kNumRpcs = 5000; + const int kLocalityWeight0 = 2; + const int kLocalityWeight1 = 8; + const int kTotalLocalityWeight = kLocalityWeight0 + kLocalityWeight1; + const double kLocalityWeightRate0 = + static_cast(kLocalityWeight0) / kTotalLocalityWeight; + const double kLocalityWeightRate1 = + static_cast(kLocalityWeight1) / kTotalLocalityWeight; + // EDS response contains 2 localities, each of which contains 1 backend. + ScheduleResponseForBalancer( + 0, + EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(0, 2, 2), + {kLocalityWeight0, kLocalityWeight1}), + 0); + // Wait for both backends to be ready. + WaitForAllBackends(1, 0, 2); + // Send kNumRpcs RPCs. + CheckRpcSendOk(kNumRpcs); + // The locality picking rates should be roughly equal to the expectation. + const double locality_picked_rate_0 = + static_cast(backends_[0]->backend_service()->request_count()) / + kNumRpcs; + const double locality_picked_rate_1 = + static_cast(backends_[1]->backend_service()->request_count()) / + kNumRpcs; + const double kErrorTolerance = 0.2; + EXPECT_THAT(locality_picked_rate_0, + ::testing::AllOf( + ::testing::Ge(kLocalityWeightRate0 * (1 - kErrorTolerance)), + ::testing::Le(kLocalityWeightRate0 * (1 + kErrorTolerance)))); + EXPECT_THAT(locality_picked_rate_1, + ::testing::AllOf( + ::testing::Ge(kLocalityWeightRate1 * (1 - kErrorTolerance)), + ::testing::Le(kLocalityWeightRate1 * (1 + kErrorTolerance)))); + // The EDS service got a single request, and sent a single response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); +} + +TEST_F(SingleBalancerTest, LocalityMapStressTest) { + SetNextResolution({}, kDefaultServiceConfig_.c_str()); + SetNextResolutionForLbChannelAllBalancers(); + const size_t kNumLocalities = 100; + // The first EDS response contains kNumLocalities localities, each of which + // contains backend 0. + const std::vector> locality_list_0(kNumLocalities, + {backends_[0]->port()}); + // The second EDS response contains 1 locality, which contains backend 1. + const std::vector> locality_list_1 = + GetBackendPortsInGroups(1, 2); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(locality_list_0), + 0); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(locality_list_1), + 60 * 1000); + // Wait until backend 0 is ready, before which kNumLocalities localities are + // received and handled by the xds policy. + WaitForBackend(0, /*reset_counters=*/false); + EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); + // Wait until backend 1 is ready, before which kNumLocalities localities are + // removed by the xds policy. + WaitForBackend(1); + // The EDS service got a single request, and sent a single response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(2U, balancers_[0]->eds_service()->response_count()); +} + TEST_F(SingleBalancerTest, Drop) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); @@ -1061,7 +1137,7 @@ TEST_F(SingleBalancerTest, Drop) { ScheduleResponseForBalancer( 0, EdsServiceImpl::BuildResponse( - GetBackendPortsInGroups(), + GetBackendPortsInGroups(), {}, {{kLbDropType, kDropPerMillionForLb}, {kThrottleDropType, kDropPerMillionForThrottle}}), 0); @@ -1102,7 +1178,7 @@ TEST_F(SingleBalancerTest, DropPerHundred) { // The EDS response contains one drop category. ScheduleResponseForBalancer( 0, - EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), + EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), {}, {{kLbDropType, kDropPerHundredForLb}}, FractionalPercent::HUNDRED), 0); @@ -1142,7 +1218,7 @@ TEST_F(SingleBalancerTest, DropPerTenThousand) { // The EDS response contains one drop category. ScheduleResponseForBalancer( 0, - EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), + EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), {}, {{kLbDropType, kDropPerTenThousandForLb}}, FractionalPercent::TEN_THOUSAND), 0); @@ -1186,14 +1262,14 @@ TEST_F(SingleBalancerTest, DropUpdate) { // The first EDS response contains one drop category. ScheduleResponseForBalancer( 0, - EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), + EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), {}, {{kLbDropType, kDropPerMillionForLb}}), 0); // The second EDS response contains two drop categories. ScheduleResponseForBalancer( 0, EdsServiceImpl::BuildResponse( - GetBackendPortsInGroups(), + GetBackendPortsInGroups(), {}, {{kLbDropType, kDropPerMillionForLb}, {kThrottleDropType, kDropPerMillionForThrottle}}), 5000); @@ -1279,7 +1355,7 @@ TEST_F(SingleBalancerTest, DropAll) { ScheduleResponseForBalancer( 0, EdsServiceImpl::BuildResponse( - GetBackendPortsInGroups(), + GetBackendPortsInGroups(), {}, {{kLbDropType, kDropPerMillionForLb}, {kThrottleDropType, kDropPerMillionForThrottle}}), 0); @@ -1472,7 +1548,7 @@ TEST_F(SingleBalancerTest, FallbackModeIsExitedWhenBalancerSaysToDropAllCalls) { // Return a new balancer that sends a response to drop all calls. ScheduleResponseForBalancer( 0, - EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), + EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), {}, {{kLbDropType, 1000000}}), 0); SetNextResolutionForLbChannelAllBalancers(); @@ -1930,7 +2006,7 @@ TEST_F(SingleBalancerWithClientLoadReportingAndDropTest, Vanilla) { ScheduleResponseForBalancer( 0, EdsServiceImpl::BuildResponse( - GetBackendPortsInGroups(), + GetBackendPortsInGroups(), {}, {{kLbDropType, kDropPerMillionForLb}, {kThrottleDropType, kDropPerMillionForThrottle}}), 0); From fd2122c6e34063981d43af4d5423d57334658e5c Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 12 Aug 2019 10:57:37 -0700 Subject: [PATCH 1204/1555] Add gnossen and remove vjpai as bazel/** owner. --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1fcdb6ba53c..be1a1329780 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -2,7 +2,7 @@ # Uses OWNERS files in different modules throughout the # repository as the source of truth for module ownership. /**/OWNERS @markdroth @nicolasnoble @a11r -/bazel/** @nicolasnoble @jtattermusch @a11r @vjpai +/bazel/** @nicolasnoble @jtattermusch @a11r @gnossen /cmake/** @jtattermusch @nicolasnoble @apolcyn /src/core/ext/filters/client_channel/** @markdroth @apolcyn @AspirinSJL /tools/dockerfile/** @jtattermusch @apolcyn @nicolasnoble From 4509af86d71782404d30c385c2cbff59d8bc5e64 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 12 Aug 2019 11:19:28 -0700 Subject: [PATCH 1205/1555] Update source of truth. --- bazel/OWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazel/OWNERS b/bazel/OWNERS index 30813d1e7a8..aac9668bbd1 100644 --- a/bazel/OWNERS +++ b/bazel/OWNERS @@ -2,5 +2,5 @@ set noparent @nicolasnoble @jtattermusch @a11r -@vjpai +@gnossen From 6c0acf733094f53b86b2ff13a36b0d0b9bfdb17d Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 12 Aug 2019 12:20:20 -0700 Subject: [PATCH 1206/1555] Swap a11r with veblush. --- .github/CODEOWNERS | 2 +- bazel/OWNERS | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index be1a1329780..f491176bf88 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -2,7 +2,7 @@ # Uses OWNERS files in different modules throughout the # repository as the source of truth for module ownership. /**/OWNERS @markdroth @nicolasnoble @a11r -/bazel/** @nicolasnoble @jtattermusch @a11r @gnossen +/bazel/** @nicolasnoble @jtattermusch @veblush @gnossen /cmake/** @jtattermusch @nicolasnoble @apolcyn /src/core/ext/filters/client_channel/** @markdroth @apolcyn @AspirinSJL /tools/dockerfile/** @jtattermusch @apolcyn @nicolasnoble diff --git a/bazel/OWNERS b/bazel/OWNERS index aac9668bbd1..b6e63d63996 100644 --- a/bazel/OWNERS +++ b/bazel/OWNERS @@ -1,6 +1,6 @@ set noparent @nicolasnoble @jtattermusch -@a11r +@veblush @gnossen From 8d101f1071fe1e25f41d89e06be54f55ed7fe7a0 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Mon, 12 Aug 2019 12:35:58 -0700 Subject: [PATCH 1207/1555] Wait longer before sending the drop update --- test/cpp/end2end/xds_end2end_test.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index 5d114c0ef2b..94f4af0b173 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -1190,13 +1190,16 @@ TEST_F(SingleBalancerTest, DropUpdate) { {{kLbDropType, kDropPerMillionForLb}}), 0); // The second EDS response contains two drop categories. + // TODO(juanlishen): Change the EDS response sending to deterministic style + // (e.g., by using condition variable) so that we can shorten the test + // duration. ScheduleResponseForBalancer( 0, EdsServiceImpl::BuildResponse( GetBackendPortsInGroups(), {{kLbDropType, kDropPerMillionForLb}, {kThrottleDropType, kDropPerMillionForThrottle}}), - 5000); + 10000); WaitForAllBackends(); // Send kNumRpcs RPCs and count the drops. size_t num_drops = 0; From 70eb692a0b525fb53b3dc516bc36a55f1d9f77ed Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 12 Aug 2019 13:19:33 -0700 Subject: [PATCH 1208/1555] Update copyright --- src/objective-c/GRPCClient/version.h | 2 +- templates/src/objective-c/GRPCClient/version.h.template | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/objective-c/GRPCClient/version.h b/src/objective-c/GRPCClient/version.h index 64781185ac7..fc6982c55d6 100644 --- a/src/objective-c/GRPCClient/version.h +++ b/src/objective-c/GRPCClient/version.h @@ -1,6 +1,6 @@ /* * - * Copyright 2019 gRPC authors. + * Copyright 2015 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/templates/src/objective-c/GRPCClient/version.h.template b/templates/src/objective-c/GRPCClient/version.h.template index 5623dddb502..22b3bb25d48 100644 --- a/templates/src/objective-c/GRPCClient/version.h.template +++ b/templates/src/objective-c/GRPCClient/version.h.template @@ -2,7 +2,7 @@ --- | /* * - * Copyright 2019 gRPC authors. + * Copyright 2015 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From ae863630d5f96c9581d050c08ad47dd58562b16f Mon Sep 17 00:00:00 2001 From: Yihua Zhang Date: Mon, 12 Aug 2019 14:12:13 -0700 Subject: [PATCH 1209/1555] Add spiffe client-side credential reload --- CMakeLists.txt | 44 +++ Makefile | 48 +++ build.yaml | 14 + grpc.def | 2 + include/grpc/grpc_security.h | 24 +- .../tls/grpc_tls_credentials_options.cc | 23 ++ .../tls/grpc_tls_credentials_options.h | 3 + .../credentials/tls/spiffe_credentials.cc | 6 +- .../security/security_connector/ssl_utils.h | 12 +- .../tls/spiffe_security_connector.cc | 210 ++++++++++--- .../tls/spiffe_security_connector.h | 35 ++- src/ruby/ext/grpc/rb_grpc_imports.generated.c | 4 + src/ruby/ext/grpc/rb_grpc_imports.generated.h | 6 + test/core/end2end/fixtures/h2_spiffe.cc | 8 + test/core/security/BUILD | 16 + .../spiffe_security_connector_test.cc | 282 ++++++++++++++++++ .../core/surface/public_headers_must_be_c89.c | 2 + .../generated/sources_and_headers.json | 19 ++ tools/run_tests/generated/tests.json | 24 ++ 19 files changed, 722 insertions(+), 60 deletions(-) create mode 100644 test/core/security/spiffe_security_connector_test.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 21511bb9738..678ad9bdbb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -641,6 +641,7 @@ add_dependencies(buildtests_cxx grpc_cli) add_dependencies(buildtests_cxx grpc_core_map_test) add_dependencies(buildtests_cxx grpc_fetch_oauth2) add_dependencies(buildtests_cxx grpc_linux_system_roots_test) +add_dependencies(buildtests_cxx grpc_spiffe_security_connector_test) add_dependencies(buildtests_cxx grpc_tool_test) add_dependencies(buildtests_cxx grpclb_api_test) add_dependencies(buildtests_cxx grpclb_end2end_test) @@ -14722,6 +14723,49 @@ endif() endif (gRPC_BUILD_CODEGEN) if (gRPC_BUILD_TESTS) +add_executable(grpc_spiffe_security_connector_test + test/core/security/spiffe_security_connector_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(grpc_spiffe_security_connector_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(grpc_spiffe_security_connector_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + grpc++_test_util + grpc++ + grpc + gpr + ${_gRPC_GFLAGS_LIBRARIES} +) + + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + add_executable(grpc_tool_test ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.grpc.pb.cc diff --git a/Makefile b/Makefile index 268e454761c..66c4f4489ed 100644 --- a/Makefile +++ b/Makefile @@ -1222,6 +1222,7 @@ grpc_objective_c_plugin: $(BINDIR)/$(CONFIG)/grpc_objective_c_plugin grpc_php_plugin: $(BINDIR)/$(CONFIG)/grpc_php_plugin grpc_python_plugin: $(BINDIR)/$(CONFIG)/grpc_python_plugin grpc_ruby_plugin: $(BINDIR)/$(CONFIG)/grpc_ruby_plugin +grpc_spiffe_security_connector_test: $(BINDIR)/$(CONFIG)/grpc_spiffe_security_connector_test grpc_tool_test: $(BINDIR)/$(CONFIG)/grpc_tool_test grpclb_api_test: $(BINDIR)/$(CONFIG)/grpclb_api_test grpclb_end2end_test: $(BINDIR)/$(CONFIG)/grpclb_end2end_test @@ -1695,6 +1696,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/grpc_core_map_test \ $(BINDIR)/$(CONFIG)/grpc_fetch_oauth2 \ $(BINDIR)/$(CONFIG)/grpc_linux_system_roots_test \ + $(BINDIR)/$(CONFIG)/grpc_spiffe_security_connector_test \ $(BINDIR)/$(CONFIG)/grpc_tool_test \ $(BINDIR)/$(CONFIG)/grpclb_api_test \ $(BINDIR)/$(CONFIG)/grpclb_end2end_test \ @@ -1862,6 +1864,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/grpc_core_map_test \ $(BINDIR)/$(CONFIG)/grpc_fetch_oauth2 \ $(BINDIR)/$(CONFIG)/grpc_linux_system_roots_test \ + $(BINDIR)/$(CONFIG)/grpc_spiffe_security_connector_test \ $(BINDIR)/$(CONFIG)/grpc_tool_test \ $(BINDIR)/$(CONFIG)/grpclb_api_test \ $(BINDIR)/$(CONFIG)/grpclb_end2end_test \ @@ -2370,6 +2373,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/grpc_core_map_test || ( echo test grpc_core_map_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_linux_system_roots_test" $(Q) $(BINDIR)/$(CONFIG)/grpc_linux_system_roots_test || ( echo test grpc_linux_system_roots_test failed ; exit 1 ) + $(E) "[RUN] Testing grpc_spiffe_security_connector_test" + $(Q) $(BINDIR)/$(CONFIG)/grpc_spiffe_security_connector_test || ( echo test grpc_spiffe_security_connector_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_tool_test" $(Q) $(BINDIR)/$(CONFIG)/grpc_tool_test || ( echo test grpc_tool_test failed ; exit 1 ) $(E) "[RUN] Testing grpclb_api_test" @@ -16944,6 +16949,49 @@ ifneq ($(NO_DEPS),true) endif +GRPC_SPIFFE_SECURITY_CONNECTOR_TEST_SRC = \ + test/core/security/spiffe_security_connector_test.cc \ + +GRPC_SPIFFE_SECURITY_CONNECTOR_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_SPIFFE_SECURITY_CONNECTOR_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/grpc_spiffe_security_connector_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/grpc_spiffe_security_connector_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/grpc_spiffe_security_connector_test: $(PROTOBUF_DEP) $(GRPC_SPIFFE_SECURITY_CONNECTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_SPIFFE_SECURITY_CONNECTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/grpc_spiffe_security_connector_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/core/security/spiffe_security_connector_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_grpc_spiffe_security_connector_test: $(GRPC_SPIFFE_SECURITY_CONNECTOR_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(GRPC_SPIFFE_SECURITY_CONNECTOR_TEST_OBJS:.o=.dep) +endif +endif + + GRPC_TOOL_TEST_SRC = \ $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc \ $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc \ diff --git a/build.yaml b/build.yaml index f8375eaf61f..c7f638495f8 100644 --- a/build.yaml +++ b/build.yaml @@ -5112,6 +5112,20 @@ targets: deps: - grpc_plugin_support secure: false +- name: grpc_spiffe_security_connector_test + gtest: true + build: test + language: c++ + src: + - test/core/security/spiffe_security_connector_test.cc + deps: + - grpc_test_util + - grpc++_test_util + - grpc++ + - grpc + - gpr + uses: + - grpc++_test - name: grpc_tool_test gtest: true build: test diff --git a/grpc.def b/grpc.def index f451775dba6..fa4d73c9252 100644 --- a/grpc.def +++ b/grpc.def @@ -141,6 +141,8 @@ EXPORTS grpc_tls_credentials_options_set_server_authorization_check_config grpc_tls_key_materials_config_create grpc_tls_key_materials_config_set_key_materials + grpc_tls_key_materials_config_set_version + grpc_tls_key_materials_config_get_version grpc_tls_credential_reload_config_create grpc_tls_server_authorization_check_config_create grpc_raw_byte_buffer_create diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h index 777142f38c6..794900b3b16 100644 --- a/include/grpc/grpc_security.h +++ b/include/grpc/grpc_security.h @@ -778,6 +778,21 @@ GRPCAPI int grpc_tls_key_materials_config_set_key_materials( const grpc_ssl_pem_key_cert_pair** pem_key_cert_pairs, size_t num_key_cert_pairs); +/** Set grpc_tls_key_materials_config instance with a provided version number, + which is used to keep track of the version of key materials. + It returns 1 on success and 0 on failure. It is used for + experimental purpose for now and subject to change. + */ +GRPCAPI int grpc_tls_key_materials_config_set_version( + grpc_tls_key_materials_config* config, int version); + +/** Get the version number of a grpc_tls_key_materials_config instance. + It returns the version number on success and -1 on failure. + It is used for experimental purpose for now and subject to change. + */ +GRPCAPI int grpc_tls_key_materials_config_get_version( + grpc_tls_key_materials_config* config); + /** --- TLS credential reload config. --- It is used for experimental purpose for now and subject to change.*/ @@ -793,10 +808,11 @@ typedef void (*grpc_tls_on_credential_reload_done_cb)( /** A struct containing all information necessary to schedule/cancel a credential reload request. cb and cb_user_data represent a gRPC-provided callback and an argument passed to it. key_materials is an in/output - parameter containing currently used/newly reloaded credentials. status and - error_details are used to hold information about errors occurred when a - credential reload request is scheduled/cancelled. It is used for - experimental purpose for now and subject to change. */ + parameter containing currently used/newly reloaded credentials. If + credential reload does not result in a new credential, key_materials should + not be modified. status and error_details are used to hold information about + errors occurred when a credential reload request is scheduled/cancelled. It + is used for experimental purpose for now and subject to change. */ struct grpc_tls_credential_reload_arg { grpc_tls_on_credential_reload_done_cb cb; void* cb_user_data; diff --git a/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc b/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc index a6169a1b586..7e0af3dcc17 100644 --- a/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +++ b/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc @@ -157,6 +157,29 @@ int grpc_tls_key_materials_config_set_key_materials( return 1; } +int grpc_tls_key_materials_config_set_version( + grpc_tls_key_materials_config* config, int version) { + if (config == nullptr) { + gpr_log(GPR_ERROR, + "Invalid arguments to " + "grpc_tls_key_materials_config_set_version()"); + return 0; + } + config->set_version(version); + return 1; +} + +int grpc_tls_key_materials_config_get_version( + grpc_tls_key_materials_config* config) { + if (config == nullptr) { + gpr_log(GPR_ERROR, + "Invalid arguments to " + "grpc_tls_key_materials_config_get_version()"); + return -1; + } + return config->version(); +} + grpc_tls_credential_reload_config* grpc_tls_credential_reload_config_create( const void* config_user_data, int (*schedule)(void* config_user_data, diff --git a/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h b/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h index aee9292acb8..af4074138cf 100644 --- a/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +++ b/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h @@ -39,12 +39,15 @@ struct grpc_tls_key_materials_config const PemKeyCertPairList& pem_key_cert_pair_list() const { return pem_key_cert_pair_list_; } + int version() const { return version_; } /** Setters for member fields. **/ void set_key_materials(grpc_core::UniquePtr pem_root_certs, PemKeyCertPairList pem_key_cert_pair_list); + void set_version(int version) { version_ = version; } private: + int version_ = 0; PemKeyCertPairList pem_key_cert_pair_list_; grpc_core::UniquePtr pem_root_certs_; }; diff --git a/src/core/lib/security/credentials/tls/spiffe_credentials.cc b/src/core/lib/security/credentials/tls/spiffe_credentials.cc index da764936c76..e8433bf09b8 100644 --- a/src/core/lib/security/credentials/tls/spiffe_credentials.cc +++ b/src/core/lib/security/credentials/tls/spiffe_credentials.cc @@ -84,7 +84,7 @@ SpiffeCredentials::create_security_connector( static_cast(arg->value.pointer.p); } } - grpc_core::RefCountedPtr sc = + grpc_core::RefCountedPtr sc = grpc_core:: SpiffeChannelSecurityConnector::CreateSpiffeChannelSecurityConnector( this->Ref(), std::move(call_creds), target_name, overridden_target_name, ssl_session_cache); @@ -106,8 +106,8 @@ SpiffeServerCredentials::~SpiffeServerCredentials() {} grpc_core::RefCountedPtr SpiffeServerCredentials::create_security_connector() { - return SpiffeServerSecurityConnector::CreateSpiffeServerSecurityConnector( - this->Ref()); + return grpc_core::SpiffeServerSecurityConnector:: + CreateSpiffeServerSecurityConnector(this->Ref()); } grpc_channel_credentials* grpc_tls_spiffe_credentials_create( diff --git a/src/core/lib/security/security_connector/ssl_utils.h b/src/core/lib/security/security_connector/ssl_utils.h index bf8c1de3aae..29366b309e8 100644 --- a/src/core/lib/security/security_connector/ssl_utils.h +++ b/src/core/lib/security/security_connector/ssl_utils.h @@ -149,9 +149,15 @@ class PemKeyCertPair { return *this; } - // Not copyable. - PemKeyCertPair(const PemKeyCertPair&) = delete; - PemKeyCertPair& operator=(const PemKeyCertPair&) = delete; + // Copyable. + PemKeyCertPair(const PemKeyCertPair& other) + : private_key_(gpr_strdup(other.private_key())), + cert_chain_(gpr_strdup(other.cert_chain())) {} + PemKeyCertPair& operator=(const PemKeyCertPair& other) { + private_key_ = grpc_core::UniquePtr(gpr_strdup(other.private_key())); + cert_chain_ = grpc_core::UniquePtr(gpr_strdup(other.cert_chain())); + return *this; + } char* private_key() const { return private_key_.get(); } char* cert_chain() const { return cert_chain_.get(); } diff --git a/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc b/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc index 5853de4fc13..be20b60645b 100644 --- a/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +++ b/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc @@ -38,6 +38,8 @@ #include "src/core/tsi/ssl_transport_security.h" #include "src/core/tsi/transport_security.h" +namespace grpc_core { + namespace { tsi_ssl_pem_key_cert_pair* ConvertToTsiPemKeyCertPair( @@ -58,42 +60,55 @@ tsi_ssl_pem_key_cert_pair* ConvertToTsiPemKeyCertPair( return tsi_pairs; } -/** -- Util function to populate SPIFFE server/channel credentials. -- */ -grpc_core::RefCountedPtr -PopulateSpiffeCredentials(const grpc_tls_credentials_options& options) { - GPR_ASSERT(options.credential_reload_config() != nullptr || - options.key_materials_config() != nullptr); - grpc_core::RefCountedPtr key_materials_config; +} // namespace + +/** -- Util function to fetch SPIFFE server/channel credentials. -- */ +grpc_status_code TlsFetchKeyMaterials( + const grpc_core::RefCountedPtr& + key_materials_config, + const grpc_tls_credentials_options& options, + grpc_ssl_certificate_config_reload_status* reload_status) { + GPR_ASSERT(key_materials_config != nullptr); + bool is_key_materials_empty = + key_materials_config->pem_key_cert_pair_list().empty(); + if (options.credential_reload_config() == nullptr && is_key_materials_empty) { + gpr_log(GPR_ERROR, + "Either credential reload config or key materials should be " + "provisioned."); + return GRPC_STATUS_FAILED_PRECONDITION; + } + grpc_status_code status = GRPC_STATUS_OK; /* Use credential reload config to fetch credentials. */ if (options.credential_reload_config() != nullptr) { grpc_tls_credential_reload_arg* arg = grpc_core::New(); - key_materials_config = grpc_tls_key_materials_config_create()->Ref(); arg->key_materials_config = key_materials_config.get(); int result = options.credential_reload_config()->Schedule(arg); if (result) { /* Do not support async credential reload. */ gpr_log(GPR_ERROR, "Async credential reload is unsupported now."); + status = + is_key_materials_empty ? GRPC_STATUS_UNIMPLEMENTED : GRPC_STATUS_OK; } else { - grpc_ssl_certificate_config_reload_status status = arg->status; - if (status == GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED) { + GPR_ASSERT(reload_status != nullptr); + *reload_status = arg->status; + if (arg->status == GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED) { + /* Key materials is not empty. */ gpr_log(GPR_DEBUG, "Credential does not change after reload."); - } else if (status == GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL) { - gpr_log(GPR_ERROR, "Credential reload failed with an error: %s", - arg->error_details); + } else if (arg->status == GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL) { + gpr_log(GPR_ERROR, "Credential reload failed with an error:"); + if (arg->error_details != nullptr) { + gpr_log(GPR_ERROR, "%s", arg->error_details); + } + status = is_key_materials_empty ? GRPC_STATUS_INTERNAL : GRPC_STATUS_OK; } } gpr_free((void*)arg->error_details); grpc_core::Delete(arg); - /* Use existing key materials config. */ - } else { - key_materials_config = options.key_materials_config()->Ref(); } - return key_materials_config; + return status; } -} // namespace - SpiffeChannelSecurityConnector::SpiffeChannelSecurityConnector( grpc_core::RefCountedPtr channel_creds, grpc_core::RefCountedPtr request_metadata_creds, @@ -104,6 +119,7 @@ SpiffeChannelSecurityConnector::SpiffeChannelSecurityConnector( overridden_target_name_(overridden_target_name == nullptr ? nullptr : gpr_strdup(overridden_target_name)) { + key_materials_config_ = grpc_tls_key_materials_config_create()->Ref(); check_arg_ = ServerAuthorizationCheckArgCreate(this); grpc_core::StringView host; grpc_core::StringView port; @@ -115,12 +131,19 @@ SpiffeChannelSecurityConnector::~SpiffeChannelSecurityConnector() { if (client_handshaker_factory_ != nullptr) { tsi_ssl_client_handshaker_factory_unref(client_handshaker_factory_); } + if (key_materials_config_.get() != nullptr) { + key_materials_config_.get()->Unref(); + } ServerAuthorizationCheckArgDestroy(check_arg_); } void SpiffeChannelSecurityConnector::add_handshakers( grpc_pollset_set* interested_parties, grpc_core::HandshakeManager* handshake_mgr) { + if (RefreshHandshakerFactory() != GRPC_SECURITY_OK) { + gpr_log(GPR_ERROR, "Handshaker factory refresh failed."); + return; + } // Instantiate TSI handshaker. tsi_handshaker* tsi_hs = nullptr; tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker( @@ -239,30 +262,73 @@ SpiffeChannelSecurityConnector::CreateSpiffeChannelSecurityConnector( std::move(channel_creds), std::move(request_metadata_creds), target_name, overridden_target_name); if (c->InitializeHandshakerFactory(ssl_session_cache) != GRPC_SECURITY_OK) { + gpr_log(GPR_ERROR, "Could not initialize client handshaker factory."); return nullptr; } return c; } +grpc_security_status SpiffeChannelSecurityConnector::ReplaceHandshakerFactory( + tsi_ssl_session_cache* ssl_session_cache) { + /* Free the client handshaker factory if exists. */ + if (client_handshaker_factory_) { + tsi_ssl_client_handshaker_factory_unref(client_handshaker_factory_); + } + GPR_ASSERT(!key_materials_config_->pem_key_cert_pair_list().empty()); + tsi_ssl_pem_key_cert_pair* pem_key_cert_pair = ConvertToTsiPemKeyCertPair( + key_materials_config_->pem_key_cert_pair_list()); + grpc_security_status status = grpc_ssl_tsi_client_handshaker_factory_init( + pem_key_cert_pair, key_materials_config_->pem_root_certs(), + ssl_session_cache, &client_handshaker_factory_); + /* Free memory. */ + grpc_tsi_ssl_pem_key_cert_pairs_destroy(pem_key_cert_pair, 1); + return status; +} + grpc_security_status SpiffeChannelSecurityConnector::InitializeHandshakerFactory( tsi_ssl_session_cache* ssl_session_cache) { + grpc_core::MutexLock lock(&mu_); const SpiffeCredentials* creds = static_cast(channel_creds()); - auto key_materials_config = PopulateSpiffeCredentials(creds->options()); - if (key_materials_config->pem_key_cert_pair_list().empty()) { - key_materials_config->Unref(); + grpc_tls_key_materials_config* key_materials_config = + creds->options().key_materials_config(); + /* Copy key materials config from credential options. */ + if (key_materials_config != nullptr) { + grpc_tls_key_materials_config::PemKeyCertPairList cert_pair_list = + key_materials_config->pem_key_cert_pair_list(); + auto pem_root_certs = grpc_core::UniquePtr( + gpr_strdup(key_materials_config->pem_root_certs())); + key_materials_config_->set_key_materials(std::move(pem_root_certs), + std::move(cert_pair_list)); + } + grpc_ssl_certificate_config_reload_status reload_status = + GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED; + if (TlsFetchKeyMaterials(key_materials_config_, creds->options(), + &reload_status) != GRPC_STATUS_OK) { + /* Raise an error if key materials are not populated. */ return GRPC_SECURITY_ERROR; } - tsi_ssl_pem_key_cert_pair* pem_key_cert_pair = ConvertToTsiPemKeyCertPair( - key_materials_config->pem_key_cert_pair_list()); - grpc_security_status status = grpc_ssl_tsi_client_handshaker_factory_init( - pem_key_cert_pair, key_materials_config->pem_root_certs(), - ssl_session_cache, &client_handshaker_factory_); - // Free memory. - key_materials_config->Unref(); - grpc_tsi_ssl_pem_key_cert_pairs_destroy(pem_key_cert_pair, 1); - return status; + return ReplaceHandshakerFactory(ssl_session_cache); +} + +grpc_security_status +SpiffeChannelSecurityConnector::RefreshHandshakerFactory() { + grpc_core::MutexLock lock(&mu_); + const SpiffeCredentials* creds = + static_cast(channel_creds()); + grpc_ssl_certificate_config_reload_status reload_status = + GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED; + if (TlsFetchKeyMaterials(key_materials_config_, creds->options(), + &reload_status) != GRPC_STATUS_OK) { + return GRPC_SECURITY_ERROR; + } + if (reload_status != GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW) { + // Re-use existing handshaker factory. + return GRPC_SECURITY_OK; + } else { + return ReplaceHandshakerFactory(nullptr); + } } void SpiffeChannelSecurityConnector::ServerAuthorizationCheckDone( @@ -332,19 +398,28 @@ void SpiffeChannelSecurityConnector::ServerAuthorizationCheckArgDestroy( SpiffeServerSecurityConnector::SpiffeServerSecurityConnector( grpc_core::RefCountedPtr server_creds) : grpc_server_security_connector(GRPC_SSL_URL_SCHEME, - std::move(server_creds)) {} + std::move(server_creds)) { + key_materials_config_ = grpc_tls_key_materials_config_create()->Ref(); +} SpiffeServerSecurityConnector::~SpiffeServerSecurityConnector() { if (server_handshaker_factory_ != nullptr) { tsi_ssl_server_handshaker_factory_unref(server_handshaker_factory_); } + if (key_materials_config_.get() != nullptr) { + key_materials_config_.get()->Unref(); + } } void SpiffeServerSecurityConnector::add_handshakers( grpc_pollset_set* interested_parties, grpc_core::HandshakeManager* handshake_mgr) { + /* Refresh handshaker factory if needed. */ + if (RefreshHandshakerFactory() != GRPC_SECURITY_OK) { + gpr_log(GPR_ERROR, "Handshaker factory refresh failed."); + return; + } /* Create a TLS SPIFFE TSI handshaker for server. */ - RefreshServerHandshakerFactory(); tsi_handshaker* tsi_hs = nullptr; tsi_result result = tsi_ssl_server_handshaker_factory_create_handshaker( server_handshaker_factory_, &tsi_hs); @@ -384,39 +459,76 @@ SpiffeServerSecurityConnector::CreateSpiffeServerSecurityConnector( grpc_core::RefCountedPtr c = grpc_core::MakeRefCounted( std::move(server_creds)); - if (c->RefreshServerHandshakerFactory() != GRPC_SECURITY_OK) { + if (c->InitializeHandshakerFactory() != GRPC_SECURITY_OK) { + gpr_log(GPR_ERROR, "Could not initialize server handshaker factory."); return nullptr; } return c; } -grpc_security_status -SpiffeServerSecurityConnector::RefreshServerHandshakerFactory() { +grpc_security_status SpiffeServerSecurityConnector::ReplaceHandshakerFactory() { const SpiffeServerCredentials* creds = static_cast(server_creds()); - auto key_materials_config = PopulateSpiffeCredentials(creds->options()); - /* Credential reload does NOT take effect and we need to keep using - * the existing handshaker factory. */ - if (key_materials_config->pem_key_cert_pair_list().empty()) { - key_materials_config->Unref(); - return GRPC_SECURITY_ERROR; - } - /* Credential reload takes effect and we need to free the existing - * handshaker library. */ + /* Free the server handshaker factory if exists. */ if (server_handshaker_factory_) { tsi_ssl_server_handshaker_factory_unref(server_handshaker_factory_); } + GPR_ASSERT(!key_materials_config_->pem_key_cert_pair_list().empty()); tsi_ssl_pem_key_cert_pair* pem_key_cert_pairs = ConvertToTsiPemKeyCertPair( - key_materials_config->pem_key_cert_pair_list()); + key_materials_config_->pem_key_cert_pair_list()); size_t num_key_cert_pairs = - key_materials_config->pem_key_cert_pair_list().size(); + key_materials_config_->pem_key_cert_pair_list().size(); grpc_security_status status = grpc_ssl_tsi_server_handshaker_factory_init( pem_key_cert_pairs, num_key_cert_pairs, - key_materials_config->pem_root_certs(), + key_materials_config_->pem_root_certs(), creds->options().cert_request_type(), &server_handshaker_factory_); - // Free memory. - key_materials_config->Unref(); + /* Free memory. */ grpc_tsi_ssl_pem_key_cert_pairs_destroy(pem_key_cert_pairs, num_key_cert_pairs); return status; } + +grpc_security_status +SpiffeServerSecurityConnector::InitializeHandshakerFactory() { + grpc_core::MutexLock lock(&mu_); + const SpiffeServerCredentials* creds = + static_cast(server_creds()); + grpc_tls_key_materials_config* key_materials_config = + creds->options().key_materials_config(); + if (key_materials_config != nullptr) { + grpc_tls_key_materials_config::PemKeyCertPairList cert_pair_list = + key_materials_config->pem_key_cert_pair_list(); + auto pem_root_certs = grpc_core::UniquePtr( + gpr_strdup(key_materials_config->pem_root_certs())); + key_materials_config_->set_key_materials(std::move(pem_root_certs), + std::move(cert_pair_list)); + } + grpc_ssl_certificate_config_reload_status reload_status = + GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED; + if (TlsFetchKeyMaterials(key_materials_config_, creds->options(), + &reload_status) != GRPC_STATUS_OK) { + /* Raise an error if key materials are not populated. */ + return GRPC_SECURITY_ERROR; + } + return ReplaceHandshakerFactory(); +} + +grpc_security_status SpiffeServerSecurityConnector::RefreshHandshakerFactory() { + grpc_core::MutexLock lock(&mu_); + const SpiffeServerCredentials* creds = + static_cast(server_creds()); + grpc_ssl_certificate_config_reload_status reload_status = + GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED; + if (TlsFetchKeyMaterials(key_materials_config_, creds->options(), + &reload_status) != GRPC_STATUS_OK) { + return GRPC_SECURITY_ERROR; + } + if (reload_status != GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW) { + /* At this point, we should have key materials populated. */ + return GRPC_SECURITY_OK; + } else { + return ReplaceHandshakerFactory(); + } +} + +} // namespace grpc_core diff --git a/src/core/lib/security/security_connector/tls/spiffe_security_connector.h b/src/core/lib/security/security_connector/tls/spiffe_security_connector.h index 5ea00ee85b6..3739b463159 100644 --- a/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +++ b/src/core/lib/security/security_connector/tls/spiffe_security_connector.h @@ -21,11 +21,14 @@ #include +#include "src/core/lib/gprpp/sync.h" #include "src/core/lib/security/context/security_context.h" #include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h" #define GRPC_TLS_SPIFFE_TRANSPORT_SECURITY_TYPE "spiffe" +namespace grpc_core { + // Spiffe channel security connector. class SpiffeChannelSecurityConnector final : public grpc_channel_security_connector { @@ -66,6 +69,11 @@ class SpiffeChannelSecurityConnector final grpc_security_status InitializeHandshakerFactory( tsi_ssl_session_cache* ssl_session_cache); + // A util function to create a new client handshaker factory to replace + // the existing one if exists. + grpc_security_status ReplaceHandshakerFactory( + tsi_ssl_session_cache* ssl_session_cache); + // gRPC-provided callback executed by application, which servers to bring the // control back to gRPC core. static void ServerAuthorizationCheckDone( @@ -83,11 +91,17 @@ class SpiffeChannelSecurityConnector final static void ServerAuthorizationCheckArgDestroy( grpc_tls_server_authorization_check_arg* arg); + // A util function to refresh SSL TSI client handshaker factory with a valid + // credential. + grpc_security_status RefreshHandshakerFactory(); + + grpc_core::Mutex mu_; grpc_closure* on_peer_checked_; grpc_core::UniquePtr target_name_; grpc_core::UniquePtr overridden_target_name_; tsi_ssl_client_handshaker_factory* client_handshaker_factory_ = nullptr; grpc_tls_server_authorization_check_arg* check_arg_; + grpc_core::RefCountedPtr key_materials_config_; }; // Spiffe server security connector. @@ -113,11 +127,30 @@ class SpiffeServerSecurityConnector final int cmp(const grpc_security_connector* other) const override; private: + // Initialize SSL TSI server handshaker factory. + grpc_security_status InitializeHandshakerFactory(); + + // A util function to create a new server handshaker factory to replace the + // existing once if exists. + grpc_security_status ReplaceHandshakerFactory(); + // A util function to refresh SSL TSI server handshaker factory with a valid // credential. - grpc_security_status RefreshServerHandshakerFactory(); + grpc_security_status RefreshHandshakerFactory(); + + grpc_core::Mutex mu_; tsi_ssl_server_handshaker_factory* server_handshaker_factory_ = nullptr; + grpc_core::RefCountedPtr key_materials_config_; }; +// Exposed for testing only. +grpc_status_code TlsFetchKeyMaterials( + const grpc_core::RefCountedPtr& + key_materials_config, + const grpc_tls_credentials_options& options, + grpc_ssl_certificate_config_reload_status* status); + +} // namespace grpc_core + #endif /* GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_TLS_SPIFFE_SECURITY_CONNECTOR_H \ */ diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index fa275c75419..6cb10c9126c 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -164,6 +164,8 @@ grpc_tls_credentials_options_set_credential_reload_config_type grpc_tls_credenti grpc_tls_credentials_options_set_server_authorization_check_config_type grpc_tls_credentials_options_set_server_authorization_check_config_import; grpc_tls_key_materials_config_create_type grpc_tls_key_materials_config_create_import; grpc_tls_key_materials_config_set_key_materials_type grpc_tls_key_materials_config_set_key_materials_import; +grpc_tls_key_materials_config_set_version_type grpc_tls_key_materials_config_set_version_import; +grpc_tls_key_materials_config_get_version_type grpc_tls_key_materials_config_get_version_import; grpc_tls_credential_reload_config_create_type grpc_tls_credential_reload_config_create_import; grpc_tls_server_authorization_check_config_create_type grpc_tls_server_authorization_check_config_create_import; grpc_raw_byte_buffer_create_type grpc_raw_byte_buffer_create_import; @@ -435,6 +437,8 @@ void grpc_rb_load_imports(HMODULE library) { grpc_tls_credentials_options_set_server_authorization_check_config_import = (grpc_tls_credentials_options_set_server_authorization_check_config_type) GetProcAddress(library, "grpc_tls_credentials_options_set_server_authorization_check_config"); grpc_tls_key_materials_config_create_import = (grpc_tls_key_materials_config_create_type) GetProcAddress(library, "grpc_tls_key_materials_config_create"); grpc_tls_key_materials_config_set_key_materials_import = (grpc_tls_key_materials_config_set_key_materials_type) GetProcAddress(library, "grpc_tls_key_materials_config_set_key_materials"); + grpc_tls_key_materials_config_set_version_import = (grpc_tls_key_materials_config_set_version_type) GetProcAddress(library, "grpc_tls_key_materials_config_set_version"); + grpc_tls_key_materials_config_get_version_import = (grpc_tls_key_materials_config_get_version_type) GetProcAddress(library, "grpc_tls_key_materials_config_get_version"); grpc_tls_credential_reload_config_create_import = (grpc_tls_credential_reload_config_create_type) GetProcAddress(library, "grpc_tls_credential_reload_config_create"); grpc_tls_server_authorization_check_config_create_import = (grpc_tls_server_authorization_check_config_create_type) GetProcAddress(library, "grpc_tls_server_authorization_check_config_create"); grpc_raw_byte_buffer_create_import = (grpc_raw_byte_buffer_create_type) GetProcAddress(library, "grpc_raw_byte_buffer_create"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index 1389c301728..46912af5f5a 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -467,6 +467,12 @@ extern grpc_tls_key_materials_config_create_type grpc_tls_key_materials_config_c typedef int(*grpc_tls_key_materials_config_set_key_materials_type)(grpc_tls_key_materials_config* config, const char* pem_root_certs, const grpc_ssl_pem_key_cert_pair** pem_key_cert_pairs, size_t num_key_cert_pairs); extern grpc_tls_key_materials_config_set_key_materials_type grpc_tls_key_materials_config_set_key_materials_import; #define grpc_tls_key_materials_config_set_key_materials grpc_tls_key_materials_config_set_key_materials_import +typedef int(*grpc_tls_key_materials_config_set_version_type)(grpc_tls_key_materials_config* config, int version); +extern grpc_tls_key_materials_config_set_version_type grpc_tls_key_materials_config_set_version_import; +#define grpc_tls_key_materials_config_set_version grpc_tls_key_materials_config_set_version_import +typedef int(*grpc_tls_key_materials_config_get_version_type)(grpc_tls_key_materials_config* config); +extern grpc_tls_key_materials_config_get_version_type grpc_tls_key_materials_config_get_version_import; +#define grpc_tls_key_materials_config_get_version grpc_tls_key_materials_config_get_version_import typedef grpc_tls_credential_reload_config*(*grpc_tls_credential_reload_config_create_type)(const void* config_user_data, int (*schedule)(void* config_user_data, grpc_tls_credential_reload_arg* arg), void (*cancel)(void* config_user_data, grpc_tls_credential_reload_arg* arg), void (*destruct)(void* config_user_data)); extern grpc_tls_credential_reload_config_create_type grpc_tls_credential_reload_config_create_import; #define grpc_tls_credential_reload_config_create grpc_tls_credential_reload_config_create_import diff --git a/test/core/end2end/fixtures/h2_spiffe.cc b/test/core/end2end/fixtures/h2_spiffe.cc index 4352ef640cd..37fb44b5ad6 100644 --- a/test/core/end2end/fixtures/h2_spiffe.cc +++ b/test/core/end2end/fixtures/h2_spiffe.cc @@ -138,6 +138,10 @@ static int server_authz_check_async( // grpc_tls_credentials_options instance. static int client_cred_reload_sync(void* config_user_data, grpc_tls_credential_reload_arg* arg) { + if (!arg->key_materials_config->pem_key_cert_pair_list().empty()) { + arg->status = GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED; + return 0; + } grpc_ssl_pem_key_cert_pair** key_cert_pair = static_cast( gpr_zalloc(sizeof(grpc_ssl_pem_key_cert_pair*))); @@ -160,6 +164,10 @@ static int client_cred_reload_sync(void* config_user_data, // grpc_tls_credentials_options instance. static int server_cred_reload_sync(void* config_user_data, grpc_tls_credential_reload_arg* arg) { + if (!arg->key_materials_config->pem_key_cert_pair_list().empty()) { + arg->status = GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED; + return 0; + } grpc_ssl_pem_key_cert_pair** key_cert_pair = static_cast( gpr_zalloc(sizeof(grpc_ssl_pem_key_cert_pair*))); diff --git a/test/core/security/BUILD b/test/core/security/BUILD index d430ccfe215..b6d43c62722 100644 --- a/test/core/security/BUILD +++ b/test/core/security/BUILD @@ -252,3 +252,19 @@ grpc_cc_test( "//test/core/util:grpc_test_util", ], ) + +grpc_cc_test( + name = "spiffe_security_connector_test", + srcs = ["spiffe_security_connector_test.cc"], + language = "C++", + external_deps = [ + "gtest", + ], + deps = [ + "//:gpr", + "//:grpc", + "//:grpc_secure", + "//test/core/util:grpc_test_util", + "//test/core/end2end:ssl_test_data", + ], +) diff --git a/test/core/security/spiffe_security_connector_test.cc b/test/core/security/spiffe_security_connector_test.cc new file mode 100644 index 00000000000..785ae1b8128 --- /dev/null +++ b/test/core/security/spiffe_security_connector_test.cc @@ -0,0 +1,282 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +#include +#include +#include +#include +#include + +#include "src/core/lib/security/security_connector/tls/spiffe_security_connector.h" +#include "test/core/end2end/data/ssl_test_data.h" +#include "test/core/util/test_config.h" + +namespace { + +enum CredReloadResult { FAIL, SUCCESS, UNCHANGED, ASYNC }; + +void SetKeyMaterials(grpc_tls_key_materials_config* config) { + grpc_ssl_pem_key_cert_pair** key_cert_pair = + static_cast( + gpr_zalloc(sizeof(grpc_ssl_pem_key_cert_pair*))); + key_cert_pair[0] = static_cast( + gpr_zalloc(sizeof(grpc_ssl_pem_key_cert_pair))); + key_cert_pair[0]->private_key = gpr_strdup(test_server1_key); + key_cert_pair[0]->cert_chain = gpr_strdup(test_server1_cert); + grpc_tls_key_materials_config_set_key_materials( + config, gpr_strdup(test_root_cert), + (const grpc_ssl_pem_key_cert_pair**)key_cert_pair, 1); +} + +int CredReloadSuccess(void* config_user_data, + grpc_tls_credential_reload_arg* arg) { + SetKeyMaterials(arg->key_materials_config); + arg->status = GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW; + return 0; +} + +int CredReloadFail(void* config_user_data, + grpc_tls_credential_reload_arg* arg) { + arg->status = GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL; + return 0; +} + +int CredReloadUnchanged(void* config_user_data, + grpc_tls_credential_reload_arg* arg) { + arg->status = GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED; + return 0; +} + +int CredReloadAsync(void* config_user_data, + grpc_tls_credential_reload_arg* arg) { + return 1; +} + +} // namespace + +namespace grpc { +namespace testing { + +class SpiffeSecurityConnectorTest : public ::testing::Test { + protected: + SpiffeSecurityConnectorTest() {} + void SetUp() override { + options_ = grpc_tls_credentials_options_create()->Ref(); + config_ = grpc_tls_key_materials_config_create()->Ref(); + } + void TearDown() override { config_->Unref(); } + // Set credential reload config in options. + void SetOptions(CredReloadResult type) { + grpc_tls_credential_reload_config* reload_config = nullptr; + switch (type) { + case SUCCESS: + reload_config = grpc_tls_credential_reload_config_create( + nullptr, CredReloadSuccess, nullptr, nullptr); + break; + case FAIL: + reload_config = grpc_tls_credential_reload_config_create( + nullptr, CredReloadFail, nullptr, nullptr); + break; + case UNCHANGED: + reload_config = grpc_tls_credential_reload_config_create( + nullptr, CredReloadUnchanged, nullptr, nullptr); + break; + case ASYNC: + reload_config = grpc_tls_credential_reload_config_create( + nullptr, CredReloadAsync, nullptr, nullptr); + break; + default: + break; + } + grpc_tls_credentials_options_set_credential_reload_config(options_.get(), + reload_config); + } + // Set key materials config. + void SetKeyMaterialsConfig() { SetKeyMaterials(config_.get()); } + grpc_core::RefCountedPtr options_; + grpc_core::RefCountedPtr config_; +}; + +TEST_F(SpiffeSecurityConnectorTest, NoKeysAndConfig) { + grpc_ssl_certificate_config_reload_status reload_status; + grpc_status_code status = + TlsFetchKeyMaterials(config_, *options_, &reload_status); + EXPECT_EQ(status, GRPC_STATUS_FAILED_PRECONDITION); + options_->Unref(); +} + +TEST_F(SpiffeSecurityConnectorTest, NoKeySuccessReload) { + grpc_ssl_certificate_config_reload_status reload_status; + SetOptions(SUCCESS); + grpc_status_code status = + TlsFetchKeyMaterials(config_, *options_, &reload_status); + EXPECT_EQ(status, GRPC_STATUS_OK); + EXPECT_EQ(reload_status, GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW); + options_->Unref(); +} + +TEST_F(SpiffeSecurityConnectorTest, NoKeyFailReload) { + grpc_ssl_certificate_config_reload_status reload_status; + SetOptions(FAIL); + grpc_status_code status = + TlsFetchKeyMaterials(config_, *options_, &reload_status); + EXPECT_EQ(status, GRPC_STATUS_INTERNAL); + EXPECT_EQ(reload_status, GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL); + options_->Unref(); +} + +TEST_F(SpiffeSecurityConnectorTest, NoKeyAsyncReload) { + grpc_ssl_certificate_config_reload_status reload_status = + GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED; + SetOptions(ASYNC); + grpc_status_code status = + TlsFetchKeyMaterials(config_, *options_, &reload_status); + EXPECT_EQ(status, GRPC_STATUS_UNIMPLEMENTED); + EXPECT_EQ(reload_status, GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED); + options_->Unref(); +} + +TEST_F(SpiffeSecurityConnectorTest, NoKeyUnchangedReload) { + grpc_ssl_certificate_config_reload_status reload_status = + GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED; + SetOptions(UNCHANGED); + grpc_status_code status = + TlsFetchKeyMaterials(config_, *options_, &reload_status); + EXPECT_EQ(status, GRPC_STATUS_OK); + EXPECT_EQ(reload_status, GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED); + options_->Unref(); +} + +TEST_F(SpiffeSecurityConnectorTest, WithKeyNoReload) { + grpc_ssl_certificate_config_reload_status reload_status = + GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED; + SetKeyMaterialsConfig(); + grpc_status_code status = + TlsFetchKeyMaterials(config_, *options_, &reload_status); + EXPECT_EQ(status, GRPC_STATUS_OK); + options_->Unref(); +} + +TEST_F(SpiffeSecurityConnectorTest, WithKeySuccessReload) { + grpc_ssl_certificate_config_reload_status reload_status; + SetOptions(SUCCESS); + SetKeyMaterialsConfig(); + grpc_status_code status = + TlsFetchKeyMaterials(config_, *options_, &reload_status); + EXPECT_EQ(status, GRPC_STATUS_OK); + EXPECT_EQ(reload_status, GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW); + options_->Unref(); +} + +TEST_F(SpiffeSecurityConnectorTest, WithKeyFailReload) { + grpc_ssl_certificate_config_reload_status reload_status; + SetOptions(FAIL); + SetKeyMaterialsConfig(); + grpc_status_code status = + TlsFetchKeyMaterials(config_, *options_, &reload_status); + EXPECT_EQ(status, GRPC_STATUS_OK); + EXPECT_EQ(reload_status, GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL); + options_->Unref(); +} + +TEST_F(SpiffeSecurityConnectorTest, WithKeyAsyncReload) { + grpc_ssl_certificate_config_reload_status reload_status = + GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED; + SetOptions(ASYNC); + SetKeyMaterialsConfig(); + grpc_status_code status = + TlsFetchKeyMaterials(config_, *options_, &reload_status); + EXPECT_EQ(status, GRPC_STATUS_OK); + EXPECT_EQ(reload_status, GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED); + options_->Unref(); +} + +TEST_F(SpiffeSecurityConnectorTest, WithKeyUnchangedReload) { + grpc_ssl_certificate_config_reload_status reload_status = + GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED; + SetOptions(UNCHANGED); + SetKeyMaterialsConfig(); + grpc_status_code status = + TlsFetchKeyMaterials(config_, *options_, &reload_status); + EXPECT_EQ(status, GRPC_STATUS_OK); + EXPECT_EQ(reload_status, GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED); + options_->Unref(); +} + +TEST_F(SpiffeSecurityConnectorTest, CreateChannelSecurityConnectorSuccess) { + SetOptions(SUCCESS); + auto cred = grpc_core::UniquePtr( + grpc_tls_spiffe_credentials_create(options_.get())); + const char* target_name = "some_target"; + grpc_channel_args* new_args = nullptr; + auto connector = + cred->create_security_connector(nullptr, target_name, nullptr, &new_args); + EXPECT_NE(connector, nullptr); + grpc_channel_args_destroy(new_args); +} + +TEST_F(SpiffeSecurityConnectorTest, + CreateChannelSecurityConnectorFailNoTargetName) { + SetOptions(SUCCESS); + auto cred = grpc_core::UniquePtr( + grpc_tls_spiffe_credentials_create(options_.get())); + grpc_channel_args* new_args = nullptr; + auto connector = + cred->create_security_connector(nullptr, nullptr, nullptr, &new_args); + EXPECT_EQ(connector, nullptr); +} + +TEST_F(SpiffeSecurityConnectorTest, CreateChannelSecurityConnectorFailInit) { + SetOptions(FAIL); + auto cred = grpc_core::UniquePtr( + grpc_tls_spiffe_credentials_create(options_.get())); + grpc_channel_args* new_args = nullptr; + auto connector = + cred->create_security_connector(nullptr, nullptr, nullptr, &new_args); + EXPECT_EQ(connector, nullptr); +} + +TEST_F(SpiffeSecurityConnectorTest, CreateServerSecurityConnectorSuccess) { + SetOptions(SUCCESS); + auto cred = grpc_core::UniquePtr( + grpc_tls_spiffe_server_credentials_create(options_.get())); + auto connector = cred->create_security_connector(); + EXPECT_NE(connector, nullptr); +} + +TEST_F(SpiffeSecurityConnectorTest, CreateServerSecurityConnectorFailInit) { + SetOptions(FAIL); + auto cred = grpc_core::UniquePtr( + grpc_tls_spiffe_server_credentials_create(options_.get())); + auto connector = cred->create_security_connector(); + EXPECT_EQ(connector, nullptr); +} + +} // namespace testing +} // namespace grpc + +int main(int argc, char** argv) { + grpc_init(); + ::testing::InitGoogleTest(&argc, argv); + int ret = RUN_ALL_TESTS(); + grpc_shutdown(); + return ret; +} diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c index e537e482936..f1f3c7a2745 100644 --- a/test/core/surface/public_headers_must_be_c89.c +++ b/test/core/surface/public_headers_must_be_c89.c @@ -201,6 +201,8 @@ int main(int argc, char **argv) { printf("%lx", (unsigned long) grpc_tls_credentials_options_set_server_authorization_check_config); printf("%lx", (unsigned long) grpc_tls_key_materials_config_create); printf("%lx", (unsigned long) grpc_tls_key_materials_config_set_key_materials); + printf("%lx", (unsigned long) grpc_tls_key_materials_config_set_version); + printf("%lx", (unsigned long) grpc_tls_key_materials_config_get_version); printf("%lx", (unsigned long) grpc_tls_credential_reload_config_create); printf("%lx", (unsigned long) grpc_tls_server_authorization_check_config_create); printf("%lx", (unsigned long) grpc_raw_byte_buffer_create); diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index f39c72c4d5e..b54404bbd0d 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -4020,6 +4020,25 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "grpc", + "grpc++", + "grpc++_test", + "grpc++_test_util", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "grpc_spiffe_security_connector_test", + "src": [ + "test/core/security/spiffe_security_connector_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index cb5093d586f..6dd3f1422e5 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -4811,6 +4811,30 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "grpc_spiffe_security_connector_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": true + }, { "args": [], "benchmark": false, From 0968147c14b38d52c2503876789d38db998757d5 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 12 Aug 2019 14:50:50 -0700 Subject: [PATCH 1210/1555] clang-format --- src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m index 691521ae7bb..1f6a25ff78f 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m @@ -114,7 +114,7 @@ static NSMutableDictionary *gHostCache; options.hostNameOverride = _hostNameOverride; if (_transportType == GRPCTransportTypeInsecure) { options.transport = GRPCDefaultTransportImplList.core_insecure; - } else if ([GRPCCall isUsingCronet]){ + } else if ([GRPCCall isUsingCronet]) { options.transport = gGRPCCoreCronetId; } else { options.transport = GRPCDefaultTransportImplList.core_secure; From d091480eefbccaa0317891ea131f830e5b8f8c03 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 12 Aug 2019 15:05:20 -0700 Subject: [PATCH 1211/1555] Remove unused code as comment --- tools/run_tests/run_tests.py | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index d3b028d4590..c26f8fba812 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1101,17 +1101,6 @@ class ObjCLanguage(object): 'EXAMPLE_PATH': 'src/objective-c/examples/tvOS-sample', 'FRAMEWORKS': 'NO' })) - # out.append( - # self.config.job_spec( - # ['src/objective-c/tests/build_one_example.sh'], - # timeout_seconds=10 * 60, - # shortname='ios-buildtest-example-tvOS-sample-framework', - # cpu_cost=1e6, - # environ={ - # 'SCHEME': 'tvOS-sample', - # 'EXAMPLE_PATH': 'src/objective-c/examples/tvOS-sample', - # 'FRAMEWORKS': 'YES' - # })) out.append( self.config.job_spec( ['src/objective-c/tests/build_one_example.sh'], @@ -1123,17 +1112,6 @@ class ObjCLanguage(object): 'EXAMPLE_PATH': 'src/objective-c/examples/watchOS-sample', 'FRAMEWORKS': 'NO' })) - # out.append( - # self.config.job_spec( - # ['src/objective-c/tests/build_one_example.sh'], - # timeout_seconds=20 * 60, - # shortname='ios-buildtest-example-watchOS-sample-framework', - # cpu_cost=1e6, - # environ={ - # 'SCHEME': 'watchOS-sample-WatchKit-App', - # 'EXAMPLE_PATH': 'src/objective-c/examples/watchOS-sample', - # 'FRAMEWORKS': 'YES' - # })) out.append( self.config.job_spec( ['src/objective-c/tests/run_plugin_tests.sh'], From 19d576fbb3031ea8fda4ec1956c5f78251bd2fe3 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 12 Aug 2019 15:58:13 -0700 Subject: [PATCH 1212/1555] update gitignore for files generated by tvOS and watchOS builds --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4a400b4e3b4..dfb7054bfeb 100644 --- a/.gitignore +++ b/.gitignore @@ -94,6 +94,7 @@ DerivedData # Objective-C generated files *.pbobjc.* *.pbrpc.* +src/objective-c/**/Build # Cocoapods artifacts Pods/ @@ -148,4 +149,4 @@ bm_*.json cmake-build-debug/ # Benchmark outputs -BenchmarkDotNet.Artifacts/ \ No newline at end of file +BenchmarkDotNet.Artifacts/ From 43aacf02a7331278164a5e74a2c0da103dca67e6 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 12 Aug 2019 16:21:00 -0700 Subject: [PATCH 1213/1555] Fix dependency issue and move InteropTestsMultipleChannels to CronetTests --- gRPC-RxLibrary.podspec | 17 ++++++++++++ gRPC.podspec | 1 + .../tvOS-sample/tvOS-sample/ViewController.m | 2 +- .../WatchKit-Extension/InterfaceController.m | 2 +- src/objective-c/tests/Podfile | 20 +++++++------- .../tests/Tests.xcodeproj/project.pbxproj | 27 +++---------------- .../xcschemes/InteropTests.xcscheme | 8 +++--- templates/gRPC-RxLibrary.podspec.template | 17 ++++++++++++ templates/gRPC.podspec.template | 1 + 9 files changed, 55 insertions(+), 40 deletions(-) diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 9666c3c1b98..2e412cf67d6 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -42,6 +42,23 @@ Pod::Spec.new do |s| s.module_name = name s.header_dir = name + s.default_subspec = 'Interface', 'Implementation' + + src_dir = 'src/objective-c/RxLibrary' + s.subspec 'Interface' do |ss| + ss.header_mappings_dir = "#{src_dir}" + ss.source_files = "#{src_dir}/*.h" + ss.public_header_files = "#{src_dir}/*.h" + end + + s.subspec 'Implementation' do |ss| + ss.header_mappings_dir = "#{src_dir}" + ss.source_files = "#{src_dir}/*.m", "#{src_dir}/**/*.{h,m}" + ss.private_header_files = "#{src_dir}/**/*.h" + + ss.dependency "#{s.name}/Interface" + end + src_dir = 'src/objective-c/RxLibrary' s.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}" s.private_header_files = "#{src_dir}/private/*.h" diff --git a/gRPC.podspec b/gRPC.podspec index a44f207ed54..e18adcd276e 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -67,6 +67,7 @@ Pod::Spec.new do |s| "GRPCClient/GRPCCall+Tests.h", "src/objective-c/GRPCClient/GRPCCallLegacy.h", "src/objective-c/GRPCClient/GRPCTypes.h" + ss.dependency "gRPC-RxLibrary/Interface", version end s.subspec 'Interface' do |ss| diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m index 3081b28f0ea..9c466260121 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m @@ -25,8 +25,8 @@ #import "src/objective-c/examples/RemoteTestClient/Messages.pbobjc.h" #import "src/objective-c/examples/RemoteTestClient/Test.pbrpc.h" #endif -#import #import +#import @interface ViewController () diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m index 050234cb947..ce204a9c146 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m +++ b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m @@ -24,8 +24,8 @@ #import "src/objective-c/examples/RemoteTestClient/Messages.pbobjc.h" #import "src/objective-c/examples/RemoteTestClient/Test.pbrpc.h" #endif -#import #import +#import @interface InterfaceController () diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile index d9087c3c83a..c83e8861e93 100644 --- a/src/objective-c/tests/Podfile +++ b/src/objective-c/tests/Podfile @@ -30,25 +30,25 @@ target 'MacTests' do grpc_deps end -target 'UnitTests' do - platform :ios, '8.0' - grpc_deps -end - %w( + UnitTests InteropTests - CronetTests ).each do |target_name| target target_name do platform :ios, '8.0' grpc_deps - - pod 'gRPC/GRPCCoreCronet', :path => GRPC_LOCAL_SRC - pod 'CronetFramework', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" - pod 'gRPC-Core/Tests', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true end end +target 'CronetTests' do + platform :ios, '8.0' + grpc_deps + + pod 'gRPC/GRPCCoreCronet', :path => GRPC_LOCAL_SRC + pod 'CronetFramework', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" + pod 'gRPC-Core/Tests', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true +end + # gRPC-Core.podspec needs to be modified to be successfully used for local development. A Podfile's # pre_install hook lets us do that. The block passed to it runs after the podspecs are downloaded # and before they are installed in the user project. diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index 4a469dc622f..1220714819e 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -8,15 +8,14 @@ /* Begin PBXBuildFile section */ 5E0282E9215AA697007AC99D /* NSErrorUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E0282E8215AA697007AC99D /* NSErrorUnitTests.m */; }; + 5E08D07023021E3B006D76EA /* InteropTestsMultipleChannels.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487722778226006656AD /* InteropTestsMultipleChannels.m */; }; 5E3F14842278B461007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; 5E3F14852278BF5D007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; 5E3F14862278BFFF007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; 5E3F148D22792856007C6D90 /* ConfigureCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F1487227918AA007C6D90 /* ConfigureCronet.m */; }; - 5E3F148E22792AF5007C6D90 /* ConfigureCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F1487227918AA007C6D90 /* ConfigureCronet.m */; }; 5E7F486422775B37006656AD /* InteropTestsRemoteWithCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE84BF31D4717E40050C6CC /* InteropTestsRemoteWithCronet.m */; }; 5E7F486522775B41006656AD /* CronetUnitTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5EAD6D261E27047400002378 /* CronetUnitTests.mm */; }; 5E7F486E22778086006656AD /* CoreCronetEnd2EndTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F486D22778086006656AD /* CoreCronetEnd2EndTests.mm */; }; - 5E7F487922778226006656AD /* InteropTestsMultipleChannels.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487722778226006656AD /* InteropTestsMultipleChannels.m */; }; 5E7F487D22778256006656AD /* ChannelPoolTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487B22778256006656AD /* ChannelPoolTest.m */; }; 5E7F487E22778256006656AD /* ChannelTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487C22778256006656AD /* ChannelTests.m */; }; 5E7F4880227782C1006656AD /* APIv2Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487F227782C1006656AD /* APIv2Tests.m */; }; @@ -514,7 +513,6 @@ 5EA476F12272816A000F72FC /* Frameworks */, 5EA476F22272816A000F72FC /* Resources */, D11CB94CF56A1E53760D29D8 /* [CP] Copy Pods Resources */, - 0FEFD5FC6B323AC95549AE4A /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -676,24 +674,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 0FEFD5FC6B323AC95549AE4A /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-frameworks.sh", - "${PODS_ROOT}/CronetFramework/Cronet.framework", - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; 292EA42A76AC7933A37235FD /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -827,7 +807,7 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC.default-GRPCCoreCronet/gRPCCertificates.bundle", + "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; outputPaths = ( @@ -896,6 +876,7 @@ files = ( 5E3F14852278BF5D007C6D90 /* InteropTestsBlockCallbacks.m in Sources */, 5E3F148D22792856007C6D90 /* ConfigureCronet.m in Sources */, + 5E08D07023021E3B006D76EA /* InteropTestsMultipleChannels.m in Sources */, 5E7F486E22778086006656AD /* CoreCronetEnd2EndTests.mm in Sources */, 5E7F488522778A88006656AD /* InteropTests.m in Sources */, 5E7F486422775B37006656AD /* InteropTestsRemoteWithCronet.m in Sources */, @@ -908,9 +889,7 @@ buildActionMask = 2147483647; files = ( 5E3F14842278B461007C6D90 /* InteropTestsBlockCallbacks.m in Sources */, - 5E3F148E22792AF5007C6D90 /* ConfigureCronet.m in Sources */, 5E7F488922778B04006656AD /* InteropTestsRemote.m in Sources */, - 5E7F487922778226006656AD /* InteropTestsMultipleChannels.m in Sources */, 5EA477042273617B000F72FC /* InteropTestsLocalCleartext.m in Sources */, 5EA4770322736178000F72FC /* InteropTestsLocalSSL.m in Sources */, 5E7F488422778A88006656AD /* InteropTests.m in Sources */, diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme index adb3c366af2..cbde360a338 100644 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme +++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme @@ -23,7 +23,7 @@ @@ -48,7 +48,7 @@ + buildConfiguration = "Test"> Date: Mon, 12 Aug 2019 17:00:12 -0700 Subject: [PATCH 1214/1555] reorder UnsafeSerialize --- .../Internal/SliceBufferSafeHandleTest.cs | 1 - src/csharp/Grpc.Core/Internal/AsyncCall.cs | 31 +++++++++---------- .../Grpc.Core/Internal/AsyncCallBase.cs | 2 +- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs index 5feb9a711da..89d5f187a22 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs @@ -152,7 +152,6 @@ namespace Grpc.Core.Internal.Tests // TODO: other TODOs // -- provide a null instance of SliceBufferSafeHandle - //-- order of UnsafeSerialize in AsyncCall methods... private byte[] GetTestBuffer(int length) { diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs index 4111c5347ce..830a1f4edc6 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs @@ -160,16 +160,15 @@ namespace Grpc.Core.Internal halfcloseRequested = true; readingDone = true; - //var payload = UnsafeSerialize(msg); - - unaryResponseTcs = new TaskCompletionSource(); using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope()) - using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) { - var payload = UnsafeSerialize(msg, serializationScope.Context); // do before metadata array? - - call.StartUnary(UnaryResponseClientCallback, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags); - callStartedOk = true; + var payload = UnsafeSerialize(msg, serializationScope.Context); + unaryResponseTcs = new TaskCompletionSource(); + using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) + { + call.StartUnary(UnaryResponseClientCallback, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags); + callStartedOk = true; + } } return unaryResponseTcs.Task; @@ -238,17 +237,15 @@ namespace Grpc.Core.Internal halfcloseRequested = true; - //var payload = UnsafeSerialize(msg); - - streamingResponseCallFinishedTcs = new TaskCompletionSource(); - using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope()) - using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) { - var payload = UnsafeSerialize(msg, serializationScope.Context); // do before metadata array? - - call.StartServerStreaming(ReceivedStatusOnClientCallback, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags); - callStartedOk = true; + var payload = UnsafeSerialize(msg, serializationScope.Context); + streamingResponseCallFinishedTcs = new TaskCompletionSource(); + using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) + { + call.StartServerStreaming(ReceivedStatusOnClientCallback, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags); + callStartedOk = true; + } } call.StartReceiveInitialMetadata(ReceivedResponseHeadersCallback); } diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs index bd4b0d81832..252fe114506 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs @@ -117,7 +117,7 @@ namespace Grpc.Core.Internal { using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope()) { - var payload = UnsafeSerialize(msg, serializationScope.Context); // do before metadata array? + var payload = UnsafeSerialize(msg, serializationScope.Context); lock (myLock) { GrpcPreconditions.CheckState(started); From 36dcea650dc333ca0ba19942f01742f4bec602f9 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 12 Aug 2019 17:03:33 -0700 Subject: [PATCH 1215/1555] address a TODO --- src/csharp/ext/grpc_csharp_ext.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 89391e67e15..9ffc5591d8b 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -1238,8 +1238,9 @@ grpcsharp_slice_buffer_adjust_tail_space(grpc_slice_buffer* buffer, size_t avail } grpc_slice new_slice = grpc_slice_malloc(requested_tail_space); - // TODO: this always adds as a new slice entry into the sb, but it doesn't have the problem of - // sometimes splitting the continguous new_slice across two different slices (like grpc_slice_buffer_add would) + // grpc_slice_buffer_add_indexed always adds as a new slice entry into the sb (which is suboptimal in some cases) + // but it doesn't have the problem of sometimes splitting the continguous new_slice across two different slices + // (like grpc_slice_buffer_add would) grpc_slice_buffer_add_indexed(buffer, new_slice); } From dd5515870747ecdc5cfd92398aa02fd47b667132 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 12 Aug 2019 17:20:27 -0700 Subject: [PATCH 1216/1555] address TODO in SendMessageBenchmark --- .../Grpc.Microbenchmarks/SendMessageBenchmark.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs index 76c59ca579c..f850a0a006f 100644 --- a/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/SendMessageBenchmark.cs @@ -50,18 +50,21 @@ namespace Grpc.Microbenchmarks var call = CreateFakeCall(cq); var sendCompletionCallback = new NopSendCompletionCallback(); - var payload = SliceBufferSafeHandle.Create(); - payload.GetSpan(PayloadSize); - payload.Advance(PayloadSize); + var sliceBuffer = SliceBufferSafeHandle.Create(); var writeFlags = default(WriteFlags); for (int i = 0; i < Iterations; i++) { - // TODO: sending for the first time actually steals the slices... - call.StartSendMessage(sendCompletionCallback, payload, writeFlags, false); + // SendMessage steals the slices from the slice buffer, so we need to repopulate in each iteration. + sliceBuffer.Reset(); + sliceBuffer.GetSpan(PayloadSize); + sliceBuffer.Advance(PayloadSize); + + call.StartSendMessage(sendCompletionCallback, sliceBuffer, writeFlags, false); var callback = completionRegistry.Extract(completionRegistry.LastRegisteredKey); callback.OnComplete(true); } + sliceBuffer.Dispose(); cq.Dispose(); } From 9ae5c5df245a2ed683de6028e3aa55bb88723269 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 12 Aug 2019 17:35:00 -0700 Subject: [PATCH 1217/1555] address a TODO --- .../Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs | 3 --- src/csharp/Grpc.Core/Internal/AsyncCallServer.cs | 2 +- src/csharp/Grpc.Core/Internal/CallSafeHandle.cs | 7 ------- src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs | 2 +- 4 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs index 89d5f187a22..76387478312 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs @@ -150,9 +150,6 @@ namespace Grpc.Core.Internal.Tests } } - // TODO: other TODOs - // -- provide a null instance of SliceBufferSafeHandle - private byte[] GetTestBuffer(int length) { var testBuffer = new byte[length]; diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs index e0bb41e15dc..58bc40b0ace 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs @@ -131,7 +131,7 @@ namespace Grpc.Core.Internal { using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope()) { - var payload = optionalWrite.HasValue ? UnsafeSerialize(optionalWrite.Value.Response, serializationScope.Context) : null; + var payload = optionalWrite.HasValue ? UnsafeSerialize(optionalWrite.Value.Response, serializationScope.Context) : SliceBufferSafeHandle.NullInstance; var writeFlags = optionalWrite.HasValue ? optionalWrite.Value.WriteFlags : default(WriteFlags); lock (myLock) diff --git a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs index cfcab5dc692..7fadc1d8b47 100644 --- a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs @@ -131,13 +131,6 @@ namespace Grpc.Core.Internal public void StartSendStatusFromServer(ISendStatusFromServerCompletionCallback callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, SliceBufferSafeHandle optionalPayload, WriteFlags writeFlags) { - // TODO: optionalPayload == null -> pass null SliceBufferSafeHandle - // do this properly - if (optionalPayload == null) - { - optionalPayload = SliceBufferSafeHandle.NullInstance; - } - using (completionQueue.NewScope()) { var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(CompletionHandler_ISendStatusFromServerCompletionCallback, callback); diff --git a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs index e5bac1967c9..8aa2e96832a 100644 --- a/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs +++ b/src/csharp/Grpc.Microbenchmarks/Utf8Encode.cs @@ -117,7 +117,7 @@ namespace Grpc.Microbenchmarks { for (int i = 0; i < Iterations; i++) { - call.StartSendStatusFromServer(this, status, metadata, false, null, WriteFlags.NoCompress); + call.StartSendStatusFromServer(this, status, metadata, false, SliceBufferSafeHandle.NullInstance, WriteFlags.NoCompress); } } From 2f5464754516f2922e1a1d2711b0a90f3dc25070 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 12 Aug 2019 20:38:49 -0400 Subject: [PATCH 1218/1555] clang format --- src/csharp/ext/grpc_csharp_ext.c | 93 ++++++++++++++++---------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 9ffc5591d8b..2360c9e1d5f 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -41,9 +41,10 @@ #define GPR_CALLTYPE #endif -static grpc_byte_buffer* grpcsharp_create_byte_buffer_from_stolen_slices(grpc_slice_buffer* slice_buffer) { +static grpc_byte_buffer* grpcsharp_create_byte_buffer_from_stolen_slices( + grpc_slice_buffer* slice_buffer) { grpc_byte_buffer* bb = - (grpc_byte_buffer*)gpr_malloc(sizeof(grpc_byte_buffer)); + (grpc_byte_buffer*)gpr_malloc(sizeof(grpc_byte_buffer)); memset(bb, 0, sizeof(grpc_byte_buffer)); bb->type = GRPC_BB_RAW; bb->data.raw.compression = GRPC_COMPRESS_NONE; @@ -587,8 +588,8 @@ static grpc_call_error grpcsharp_call_start_batch(grpc_call* call, } GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_unary( - grpc_call* call, grpcsharp_batch_context* ctx, grpc_slice_buffer* send_buffer, - uint32_t write_flags, + grpc_call* call, grpcsharp_batch_context* ctx, + grpc_slice_buffer* send_buffer, uint32_t write_flags, grpc_metadata_array* initial_metadata, uint32_t initial_metadata_flags) { /* TODO: don't use magic number */ grpc_op ops[6]; @@ -603,7 +604,8 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_unary( ops[0].reserved = NULL; ops[1].op = GRPC_OP_SEND_MESSAGE; - ctx->send_message = grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); + ctx->send_message = + grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); ops[1].data.send_message.send_message = ctx->send_message; ops[1].flags = write_flags; ops[1].reserved = NULL; @@ -640,8 +642,8 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_unary( /* Only for testing. Shortcircuits the unary call logic and only echoes the message as if it was received from the server */ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_test_call_start_unary_echo( - grpc_call* call, grpcsharp_batch_context* ctx, grpc_slice_buffer* send_buffer, - uint32_t write_flags, + grpc_call* call, grpcsharp_batch_context* ctx, + grpc_slice_buffer* send_buffer, uint32_t write_flags, grpc_metadata_array* initial_metadata, uint32_t initial_metadata_flags) { // prepare as if we were performing a normal RPC. grpc_byte_buffer* send_message = @@ -698,8 +700,8 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_client_streaming( } GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_server_streaming( - grpc_call* call, grpcsharp_batch_context* ctx, grpc_slice_buffer* send_buffer, - uint32_t write_flags, + grpc_call* call, grpcsharp_batch_context* ctx, + grpc_slice_buffer* send_buffer, uint32_t write_flags, grpc_metadata_array* initial_metadata, uint32_t initial_metadata_flags) { /* TODO: don't use magic number */ grpc_op ops[4]; @@ -714,7 +716,8 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_server_streaming( ops[0].reserved = NULL; ops[1].op = GRPC_OP_SEND_MESSAGE; - ctx->send_message = grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); + ctx->send_message = + grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); ops[1].data.send_message.send_message = ctx->send_message; ops[1].flags = write_flags; ops[1].reserved = NULL; @@ -781,15 +784,16 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_recv_initial_metadata( } GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_message( - grpc_call* call, grpcsharp_batch_context* ctx, grpc_slice_buffer* send_buffer, - uint32_t write_flags, + grpc_call* call, grpcsharp_batch_context* ctx, + grpc_slice_buffer* send_buffer, uint32_t write_flags, int32_t send_empty_initial_metadata) { /* TODO: don't use magic number */ grpc_op ops[2]; memset(ops, 0, sizeof(ops)); size_t nops = send_empty_initial_metadata ? 2 : 1; ops[0].op = GRPC_OP_SEND_MESSAGE; - ctx->send_message = grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); + ctx->send_message = + grpcsharp_create_byte_buffer_from_stolen_slices(send_buffer); ops[0].data.send_message.send_message = ctx->send_message; ops[0].flags = write_flags; ops[0].reserved = NULL; @@ -816,8 +820,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_status_from_server( grpc_call* call, grpcsharp_batch_context* ctx, grpc_status_code status_code, const char* status_details, size_t status_details_len, grpc_metadata_array* trailing_metadata, int32_t send_empty_initial_metadata, - grpc_slice_buffer* optional_send_buffer, - uint32_t write_flags) { + grpc_slice_buffer* optional_send_buffer, uint32_t write_flags) { /* TODO: don't use magic number */ grpc_op ops[3]; memset(ops, 0, sizeof(ops)); @@ -1188,9 +1191,9 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_redirect_log(grpcsharp_log_func func) { typedef void(GPR_CALLTYPE* test_callback_funcptr)(int32_t success); /* Slice buffer functionality */ -GPR_EXPORT grpc_slice_buffer* GPR_CALLTYPE -grpcsharp_slice_buffer_create() { - grpc_slice_buffer* slice_buffer = (grpc_slice_buffer*)gpr_malloc(sizeof(grpc_slice_buffer)); +GPR_EXPORT grpc_slice_buffer* GPR_CALLTYPE grpcsharp_slice_buffer_create() { + grpc_slice_buffer* slice_buffer = + (grpc_slice_buffer*)gpr_malloc(sizeof(grpc_slice_buffer)); grpc_slice_buffer_init(slice_buffer); return slice_buffer; } @@ -1212,44 +1215,40 @@ grpcsharp_slice_buffer_slice_count(grpc_slice_buffer* buffer) { } GPR_EXPORT void GPR_CALLTYPE -grpcsharp_slice_buffer_slice_peek(grpc_slice_buffer* buffer, size_t index, size_t* slice_len, uint8_t** slice_data_ptr) { +grpcsharp_slice_buffer_slice_peek(grpc_slice_buffer* buffer, size_t index, + size_t* slice_len, uint8_t** slice_data_ptr) { GPR_ASSERT(buffer->count > index); grpc_slice* slice_ptr = &buffer->slices[index]; *slice_len = GRPC_SLICE_LENGTH(*slice_ptr); *slice_data_ptr = GRPC_SLICE_START_PTR(*slice_ptr); } -GPR_EXPORT void* GPR_CALLTYPE -grpcsharp_slice_buffer_adjust_tail_space(grpc_slice_buffer* buffer, size_t available_tail_space, +GPR_EXPORT void* GPR_CALLTYPE grpcsharp_slice_buffer_adjust_tail_space( + grpc_slice_buffer* buffer, size_t available_tail_space, size_t requested_tail_space) { + if (available_tail_space == requested_tail_space) { + // nothing to do + } else if (available_tail_space >= requested_tail_space) { + grpc_slice_buffer_trim_end( + buffer, available_tail_space - requested_tail_space, NULL); + } else { + if (available_tail_space > 0) { + grpc_slice_buffer_trim_end(buffer, available_tail_space, NULL); + } - if (available_tail_space == requested_tail_space) { - // nothing to do - } - else if (available_tail_space >= requested_tail_space) - { - grpc_slice_buffer_trim_end(buffer, available_tail_space - requested_tail_space, NULL); - } - else - { - if (available_tail_space > 0) - { - grpc_slice_buffer_trim_end(buffer, available_tail_space, NULL); - } + grpc_slice new_slice = grpc_slice_malloc(requested_tail_space); + // grpc_slice_buffer_add_indexed always adds as a new slice entry into the + // sb (which is suboptimal in some cases) but it doesn't have the problem of + // sometimes splitting the continguous new_slice across two different slices + // (like grpc_slice_buffer_add would) + grpc_slice_buffer_add_indexed(buffer, new_slice); + } - grpc_slice new_slice = grpc_slice_malloc(requested_tail_space); - // grpc_slice_buffer_add_indexed always adds as a new slice entry into the sb (which is suboptimal in some cases) - // but it doesn't have the problem of sometimes splitting the continguous new_slice across two different slices - // (like grpc_slice_buffer_add would) - grpc_slice_buffer_add_indexed(buffer, new_slice); - } - - if (buffer->count == 0) - { - return NULL; - } - grpc_slice* last_slice = &(buffer->slices[buffer->count - 1]); - return GRPC_SLICE_END_PTR(*last_slice) - requested_tail_space; + if (buffer->count == 0) { + return NULL; + } + grpc_slice* last_slice = &(buffer->slices[buffer->count - 1]); + return GRPC_SLICE_END_PTR(*last_slice) - requested_tail_space; } /* Version info */ From eadd5ea11093a3c3811b47dd15005df031719f79 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Mon, 12 Aug 2019 22:44:56 -0400 Subject: [PATCH 1219/1555] Directly use the ZeroCopyInputStream for grpc::GenericDeserialize. There is no need to use CodedInputStream, wrapping a ZeroCopyInputStream. Suggested by: Gerben Stavenga --- include/grpcpp/impl/codegen/proto_utils.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/include/grpcpp/impl/codegen/proto_utils.h b/include/grpcpp/impl/codegen/proto_utils.h index f9a7d3c0b34..2cf4cdcc9b5 100644 --- a/include/grpcpp/impl/codegen/proto_utils.h +++ b/include/grpcpp/impl/codegen/proto_utils.h @@ -83,14 +83,9 @@ Status GenericDeserialize(ByteBuffer* buffer, if (!reader.status().ok()) { return reader.status(); } - ::grpc::protobuf::io::CodedInputStream decoder(&reader); - decoder.SetTotalBytesLimit(INT_MAX, INT_MAX); - if (!msg->ParseFromCodedStream(&decoder)) { + if (!msg->ParseFromZeroCopyStream(&reader)) { result = Status(StatusCode::INTERNAL, msg->InitializationErrorString()); } - if (!decoder.ConsumedEntireMessage()) { - result = Status(StatusCode::INTERNAL, "Did not read entire message"); - } } buffer->Clear(); return result; From 3c28c5f06850c140399654f55b76157cdcea360f Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Mon, 12 Aug 2019 23:11:32 -0700 Subject: [PATCH 1220/1555] Remove unnecessary notification --- test/cpp/end2end/xds_end2end_test.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index 5d114c0ef2b..ecff1d58585 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -924,7 +924,6 @@ TEST_F(SingleBalancerTest, Vanilla) { EXPECT_EQ(kNumRpcsPerAddress, backends_[i]->backend_service()->request_count()); } - balancers_[0]->eds_service()->NotifyDoneWithEdsCall(); // The EDS service got a single request, and sent a single response. EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); @@ -951,7 +950,6 @@ TEST_F(SingleBalancerTest, SameBackendListedMultipleTimes) { // And they should have come from a single client port, because of // subchannel sharing. EXPECT_EQ(1UL, backends_[0]->backend_service()->clients().size()); - balancers_[0]->eds_service()->NotifyDoneWithEdsCall(); } TEST_F(SingleBalancerTest, SecureNaming) { @@ -1022,7 +1020,6 @@ TEST_F(SingleBalancerTest, InitiallyEmptyServerlist) { // populated serverlist but under the call's deadline (which is enforced by // the call's deadline). EXPECT_GT(ellapsed_ms.count(), kServerlistDelayMs); - balancers_[0]->eds_service()->NotifyDoneWithEdsCall(); // The EDS service got a single request. EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); // and sent two responses. @@ -1041,7 +1038,6 @@ TEST_F(SingleBalancerTest, AllServersUnreachableFailFast) { const Status status = SendRpc(); // The error shouldn't be DEADLINE_EXCEEDED. EXPECT_EQ(StatusCode::UNAVAILABLE, status.error_code()); - balancers_[0]->eds_service()->NotifyDoneWithEdsCall(); // The EDS service got a single request, and sent a single response. EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); From 12ca64d2c323a1a81ec0aa923aeaa6f72250828d Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 13 Aug 2019 08:25:32 -0700 Subject: [PATCH 1221/1555] Add TestCertificates.bundle to CronetTests too --- src/objective-c/tests/Tests.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index 9d84fffa9d4..9c3d8ac4c7a 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -33,6 +33,7 @@ 5EA4770322736178000F72FC /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; 5EA477042273617B000F72FC /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; 5EA4770522736AC4000F72FC /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; + 5ECFED8623030DCC00626501 /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; 65EB19E418B39A8374D407BB /* libPods-CronetTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B1511C20E16A8422B58D61A /* libPods-CronetTests.a */; }; 903163C7FE885838580AEC7A /* libPods-InteropTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D457AD9797664CFA191C3280 /* libPods-InteropTests.a */; }; 953CD2942A3A6D6CE695BE87 /* libPods-MacTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 276873A05AC5479B60DF6079 /* libPods-MacTests.a */; }; @@ -628,6 +629,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 5ECFED8623030DCC00626501 /* TestCertificates.bundle in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; From 69f3e27b9935c204b64bd5753956d44a4f046471 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 13 Aug 2019 09:02:28 -0700 Subject: [PATCH 1222/1555] Fix managers' thread safety issue --- src/objective-c/GRPCClient/GRPCInterceptor.m | 10 ++++++---- .../GRPCClient/private/GRPCTransport+Private.m | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.m b/src/objective-c/GRPCClient/GRPCInterceptor.m index 9a41c395148..a7ffe05bddc 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.m +++ b/src/objective-c/GRPCClient/GRPCInterceptor.m @@ -68,10 +68,12 @@ } - (void)shutDown { - _nextInterceptor = nil; - _previousInterceptor = nil; - _thisInterceptor = nil; - _shutDown = YES; + dispatch_async(_dispatchQueue, ^{ + self->_nextInterceptor = nil; + self->_previousInterceptor = nil; + self->_thisInterceptor = nil; + self->_shutDown = YES; + }); } - (void)createNextInterceptor { diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m index 0daf127d150..9072f7afbe2 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m @@ -47,8 +47,10 @@ } - (void)shutDown { - _transport = nil; - _previousInterceptor = nil; + dispatch_async(_dispatchQueue, ^{ + self->_transport = nil; + self->_previousInterceptor = nil; + }); } - (dispatch_queue_t)dispatchQueue { From d1b64c3a3e6fe44c4588fb8f6be553eebf180264 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Wed, 14 Aug 2019 00:25:48 +0800 Subject: [PATCH 1223/1555] add en example which easy start grpc by 4 kinds method of service with python --- examples/python/easy_start_demo/LICENSE | 373 ++++++++++++++++++ examples/python/easy_start_demo/PyClient.py | 93 +++++ examples/python/easy_start_demo/PyServer.py | 87 ++++ examples/python/easy_start_demo/README.md | 37 ++ .../customGrpcPackages/demo_pb2.py | 174 ++++++++ .../customGrpcPackages/demo_pb2_grpc.py | 99 +++++ examples/python/easy_start_demo/demo.proto | 51 +++ examples/python/easy_start_demo/notes | 3 + 8 files changed, 917 insertions(+) create mode 100644 examples/python/easy_start_demo/LICENSE create mode 100644 examples/python/easy_start_demo/PyClient.py create mode 100644 examples/python/easy_start_demo/PyServer.py create mode 100644 examples/python/easy_start_demo/README.md create mode 100644 examples/python/easy_start_demo/customGrpcPackages/demo_pb2.py create mode 100644 examples/python/easy_start_demo/customGrpcPackages/demo_pb2_grpc.py create mode 100644 examples/python/easy_start_demo/demo.proto create mode 100644 examples/python/easy_start_demo/notes diff --git a/examples/python/easy_start_demo/LICENSE b/examples/python/easy_start_demo/LICENSE new file mode 100644 index 00000000000..a612ad9813b --- /dev/null +++ b/examples/python/easy_start_demo/LICENSE @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/examples/python/easy_start_demo/PyClient.py b/examples/python/easy_start_demo/PyClient.py new file mode 100644 index 00000000000..257c817e06f --- /dev/null +++ b/examples/python/easy_start_demo/PyClient.py @@ -0,0 +1,93 @@ +""" +Author: Zhongying Wang +Email: kerbalwzy@gmail.com +License: MPL2 +DateTime: 2019-08-13T23:30:00Z +PythonVersion: Python3.6.3 +""" +import grpc +import time +from customGrpcPackages import demo_pb2, demo_pb2_grpc + +# Constants +PyGrpcServerAddress = "127.0.0.1:23334" +ClientId = 1 + + +# 简单模式 +# Unary +def simple_method(stub): + print("--------------Call SimpleMethod Begin--------------") + req = demo_pb2.Request(Cid=ClientId, ReqMsg="called by Python client") + resp = stub.SimpleMethod(req) + print(f"resp from server({resp.Sid}), the message={resp.RespMsg}") + print("--------------Call SimpleMethod Over---------------") + + +# 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) +# Client Streaming (In a single call, the client can transfer data to the server several times, +# but the server can only return a response once.) +def c_stream_method(stub): + print("--------------Call CStreamMethod Begin--------------") + + # 创建一个生成器 + # create a generator + def req_msgs(): + for i in range(5): + req = demo_pb2.Request(Cid=ClientId, ReqMsg=f"called by Python client, message: {i}") + yield req + + resp = stub.CStreamMethod(req_msgs()) + print(f"resp from server({resp.Sid}), the message={resp.RespMsg}") + print("--------------Call CStreamMethod Over---------------") + + +# 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) +# Server Streaming (In a single call, the client can only transmit data to the server at one time, +# but the server can return the response many times.) +def s_stream_method(stub): + print("--------------Call SStreamMethod Begin--------------") + req = demo_pb2.Request(Cid=ClientId, ReqMsg="called by Python client") + resp_s = stub.SStreamMethod(req) + for resp in resp_s: + print(f"recv from server({resp.Sid}, message={resp.RespMsg})") + + print("--------------Call SStreamMethod Over---------------") + + +# 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) +# Bidirectional Streaming (In a single call, both client and server can send and receive data +# to each other multiple times.) +def twf_method(stub): + print("--------------Call TWFMethod Begin---------------") + + # 创建一个生成器 + # create a generator + def req_msgs(): + for i in range(5): + req = demo_pb2.Request(Cid=ClientId, ReqMsg=f"called by Python client, message: {i}") + yield req + time.sleep(1) + + resp_s = stub.TWFMethod(req_msgs()) + for resp in resp_s: + print(f"recv from server({resp.Sid}, message={resp.RespMsg})") + + print("--------------Call TWFMethod Over---------------") + + +def main(): + with grpc.insecure_channel(PyGrpcServerAddress) as channel: + stub = demo_pb2_grpc.GRPCDemoStub(channel) + + simple_method(stub) + + c_stream_method(stub) + + s_stream_method(stub) + + twf_method(stub) + + +if __name__ == '__main__': + main() diff --git a/examples/python/easy_start_demo/PyServer.py b/examples/python/easy_start_demo/PyServer.py new file mode 100644 index 00000000000..a814205d0d1 --- /dev/null +++ b/examples/python/easy_start_demo/PyServer.py @@ -0,0 +1,87 @@ +""" +Author: Zhongying Wang +Email: kerbalwzy@gmail.com +License: MPL2 +DateTime: 2019-08-13T23:30:00Z +PythonVersion: Python3.6.3 +""" +import time + +import grpc +from threading import Thread +from concurrent import futures +from customGrpcPackages import demo_pb2, demo_pb2_grpc + +# Constants +ServerAddress = '127.0.0.1:23334' +ServerId = 1 + + +class DemoServer(demo_pb2_grpc.GRPCDemoServicer): + + # 简单模式 + # Unary + def SimpleMethod(self, request, context): + print(f"SimpleMethod called by client({request.Cid}) the message: {request.ReqMsg}") + resp = demo_pb2.Response(Sid=ServerId, RespMsg="Python server SimpleMethod Ok!!!!") + return resp + + # 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) + # Client Streaming (In a single call, the client can transfer data to the server several times, + # but the server can only return a response once.) + def CStreamMethod(self, request_iterator, context): + print("CStreamMethod called by client...") + for req in request_iterator: + print(f"recv from client({req.Cid}), message={req.ReqMsg}") + resp = demo_pb2.Response(Sid=ServerId, RespMsg="Python server CStreamMethod ok") + return resp + + # 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) + # Server Streaming (In a single call, the client can only transmit data to the server at one time, + # but the server can return the response many times.) + def SStreamMethod(self, request, context): + print(f"SStreamMethod called by client({request.Cid}), message={request.ReqMsg}") + + # 创建一个生成器 + def resp_msgs(): + for i in range(5): + resp = demo_pb2.Response(Sid=ServerId, RespMsg=f"send by Python server, message={i}") + yield resp + + return resp_msgs() + + # 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) + # Bidirectional Streaming (In a single call, both client and server can send and receive data + # to each other multiple times.) + def TWFMethod(self, request_iterator, context): + # 开启一个子线程去接收数据 + # Open a sub thread to receive data + def parse_req(): + for req in request_iterator: + print(f"recv from client{req.Cid}, message={req.ReqMsg}") + + t = Thread(target=parse_req) + t.start() + + for i in range(5): + yield demo_pb2.Response(Sid=ServerId, RespMsg=f"send by Python server, message={i}") + + t.join() + + +def main(): + server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) + + demo_pb2_grpc.add_GRPCDemoServicer_to_server(DemoServer(), server) + + server.add_insecure_port(ServerAddress) + print("------------------start Python GRPC server") + server.start() + + # In python3, `server` have no attribute `wait_for_termination` + while 1: + time.sleep(10) + + +if __name__ == '__main__': + main() diff --git a/examples/python/easy_start_demo/README.md b/examples/python/easy_start_demo/README.md new file mode 100644 index 00000000000..2bb9059bc90 --- /dev/null +++ b/examples/python/easy_start_demo/README.md @@ -0,0 +1,37 @@ +## easyDemo for using GRPC in Python +###主要是介绍了在Python中使用GRPC时, 进行数据传输的四种方式。 +###This paper mainly introduces four ways of data transmission when GRPC is used in Python. + +- ####简单模式 (Unary) +```text +没啥好说的,跟调普通方法没差 +There's nothing to say. It's no different from the usual way. +``` +- ####客户端流模式 (Client Streaming) +```text +在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应. +In a single call, the client can transfer data to the server several times, +but the server can only return a response once. +``` +- ####服务端流模式 (Server Streaming) +```text +在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应 +In a single call, the client can only transmit data to the server at one time, +but the server can return the response many times. +``` +- ####双向流模式 (Bidirectional Streaming) +```text +在一次调用中, 客户端和服务器都可以向对方多次收发数据 +In a single call, both client and server can send and receive data +to each other multiple times. +``` +---- +Author: Zhongying Wang + +Email: kerbalwzy@gmail.com + +License: MPL2 + +DateTime: 2019-08-13T23:30:00Z + +PythonVersion: Python3.6.3 \ No newline at end of file diff --git a/examples/python/easy_start_demo/customGrpcPackages/demo_pb2.py b/examples/python/easy_start_demo/customGrpcPackages/demo_pb2.py new file mode 100644 index 00000000000..4df1dad0b43 --- /dev/null +++ b/examples/python/easy_start_demo/customGrpcPackages/demo_pb2.py @@ -0,0 +1,174 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: demo.proto + +import sys +_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='demo.proto', + package='demo', + syntax='proto3', + serialized_options=None, + serialized_pb=_b('\n\ndemo.proto\x12\x04\x64\x65mo\"&\n\x07Request\x12\x0b\n\x03\x43id\x18\x01 \x01(\x03\x12\x0e\n\x06ReqMsg\x18\x02 \x01(\t\"(\n\x08Response\x12\x0b\n\x03Sid\x18\x01 \x01(\x03\x12\x0f\n\x07RespMsg\x18\x02 \x01(\t2\xcd\x01\n\x08GRPCDemo\x12-\n\x0cSimpleMethod\x12\r.demo.Request\x1a\x0e.demo.Response\x12\x30\n\rCStreamMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x12\x30\n\rSStreamMethod\x12\r.demo.Request\x1a\x0e.demo.Response0\x01\x12.\n\tTWFMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x30\x01\x62\x06proto3') +) + + + + +_REQUEST = _descriptor.Descriptor( + name='Request', + full_name='demo.Request', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='Cid', full_name='demo.Request.Cid', index=0, + number=1, type=3, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='ReqMsg', full_name='demo.Request.ReqMsg', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=20, + serialized_end=58, +) + + +_RESPONSE = _descriptor.Descriptor( + name='Response', + full_name='demo.Response', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='Sid', full_name='demo.Response.Sid', index=0, + number=1, type=3, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='RespMsg', full_name='demo.Response.RespMsg', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=60, + serialized_end=100, +) + +DESCRIPTOR.message_types_by_name['Request'] = _REQUEST +DESCRIPTOR.message_types_by_name['Response'] = _RESPONSE +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +Request = _reflection.GeneratedProtocolMessageType('Request', (_message.Message,), { + 'DESCRIPTOR' : _REQUEST, + '__module__' : 'demo_pb2' + # @@protoc_insertion_point(class_scope:demo.Request) + }) +_sym_db.RegisterMessage(Request) + +Response = _reflection.GeneratedProtocolMessageType('Response', (_message.Message,), { + 'DESCRIPTOR' : _RESPONSE, + '__module__' : 'demo_pb2' + # @@protoc_insertion_point(class_scope:demo.Response) + }) +_sym_db.RegisterMessage(Response) + + + +_GRPCDEMO = _descriptor.ServiceDescriptor( + name='GRPCDemo', + full_name='demo.GRPCDemo', + file=DESCRIPTOR, + index=0, + serialized_options=None, + serialized_start=103, + serialized_end=308, + methods=[ + _descriptor.MethodDescriptor( + name='SimpleMethod', + full_name='demo.GRPCDemo.SimpleMethod', + index=0, + containing_service=None, + input_type=_REQUEST, + output_type=_RESPONSE, + serialized_options=None, + ), + _descriptor.MethodDescriptor( + name='CStreamMethod', + full_name='demo.GRPCDemo.CStreamMethod', + index=1, + containing_service=None, + input_type=_REQUEST, + output_type=_RESPONSE, + serialized_options=None, + ), + _descriptor.MethodDescriptor( + name='SStreamMethod', + full_name='demo.GRPCDemo.SStreamMethod', + index=2, + containing_service=None, + input_type=_REQUEST, + output_type=_RESPONSE, + serialized_options=None, + ), + _descriptor.MethodDescriptor( + name='TWFMethod', + full_name='demo.GRPCDemo.TWFMethod', + index=3, + containing_service=None, + input_type=_REQUEST, + output_type=_RESPONSE, + serialized_options=None, + ), +]) +_sym_db.RegisterServiceDescriptor(_GRPCDEMO) + +DESCRIPTOR.services_by_name['GRPCDemo'] = _GRPCDEMO + +# @@protoc_insertion_point(module_scope) diff --git a/examples/python/easy_start_demo/customGrpcPackages/demo_pb2_grpc.py b/examples/python/easy_start_demo/customGrpcPackages/demo_pb2_grpc.py new file mode 100644 index 00000000000..4aaccf1144a --- /dev/null +++ b/examples/python/easy_start_demo/customGrpcPackages/demo_pb2_grpc.py @@ -0,0 +1,99 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + +from . import demo_pb2 as demo__pb2 + + +class GRPCDemoStub(object): + """服务service是用来gRPC的方法的, 格式固定 + 类似于Python中定义一个类, 类似于Golang中定义一个接口 + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.SimpleMethod = channel.unary_unary( + '/demo.GRPCDemo/SimpleMethod', + request_serializer=demo__pb2.Request.SerializeToString, + response_deserializer=demo__pb2.Response.FromString, + ) + self.CStreamMethod = channel.stream_unary( + '/demo.GRPCDemo/CStreamMethod', + request_serializer=demo__pb2.Request.SerializeToString, + response_deserializer=demo__pb2.Response.FromString, + ) + self.SStreamMethod = channel.unary_stream( + '/demo.GRPCDemo/SStreamMethod', + request_serializer=demo__pb2.Request.SerializeToString, + response_deserializer=demo__pb2.Response.FromString, + ) + self.TWFMethod = channel.stream_stream( + '/demo.GRPCDemo/TWFMethod', + request_serializer=demo__pb2.Request.SerializeToString, + response_deserializer=demo__pb2.Response.FromString, + ) + + +class GRPCDemoServicer(object): + """服务service是用来gRPC的方法的, 格式固定 + 类似于Python中定义一个类, 类似于Golang中定义一个接口 + """ + + def SimpleMethod(self, request, context): + """简单模式 + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def CStreamMethod(self, request_iterator, context): + """客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def SStreamMethod(self, request, context): + """服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def TWFMethod(self, request_iterator, context): + """双向流模式 (在一次调用中, 客户端和服务器都可以向对象多次收发数据) + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_GRPCDemoServicer_to_server(servicer, server): + rpc_method_handlers = { + 'SimpleMethod': grpc.unary_unary_rpc_method_handler( + servicer.SimpleMethod, + request_deserializer=demo__pb2.Request.FromString, + response_serializer=demo__pb2.Response.SerializeToString, + ), + 'CStreamMethod': grpc.stream_unary_rpc_method_handler( + servicer.CStreamMethod, + request_deserializer=demo__pb2.Request.FromString, + response_serializer=demo__pb2.Response.SerializeToString, + ), + 'SStreamMethod': grpc.unary_stream_rpc_method_handler( + servicer.SStreamMethod, + request_deserializer=demo__pb2.Request.FromString, + response_serializer=demo__pb2.Response.SerializeToString, + ), + 'TWFMethod': grpc.stream_stream_rpc_method_handler( + servicer.TWFMethod, + request_deserializer=demo__pb2.Request.FromString, + response_serializer=demo__pb2.Response.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'demo.GRPCDemo', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) diff --git a/examples/python/easy_start_demo/demo.proto b/examples/python/easy_start_demo/demo.proto new file mode 100644 index 00000000000..4fb76bce752 --- /dev/null +++ b/examples/python/easy_start_demo/demo.proto @@ -0,0 +1,51 @@ +// 语法版本声明,必须放在非注释的第一行 +// Syntax version declaration, Must be placed on the first line of non-commentary +syntax = "proto3"; + +// 包名定义, Python中使用时可以省略不写(PS:我还要再Go中使用,所以留在这里了) +// Package name definition, which can be omitted in Python (PS: I'll use it again in Go, so stay here) +package demo; + +/* +`message`是用来定义传输的数据的格式的, 等号后面的是字段编号 +消息定义中的每个字段都有唯一的编号 +总体格式类似于Python中定义一个类或者Golang中定义一个结构体 +*/ +/* +`message` is used to define the structure of the data to be transmitted, After the equal sign is the field number. +Each field in the message definition has a unique number. +The overall format is similar to defining a class in Python or a structure in Golang. +*/ +message Request { + int64 Cid = 1; + string ReqMsg = 2; +} + +message Response { + int64 Sid = 1; + string RespMsg = 2; +} + +// service是用来给GRPC服务定义方法的, 格式固定, 类似于Golang中定义一个接口 +// `service` is used to define methods for GRPC services in a fixed format, similar to defining an interface in Golang +service GRPCDemo { + // 简单模式 + // Unary + rpc SimpleMethod (Request) returns (Response); + + // 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) + // Client Streaming (In a single call, the client can transfer data to the server several times, + // but the server can only return a response once.) + rpc CStreamMethod (stream Request) returns (Response); + + // 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) + // Server Streaming (In a single call, the client can only transmit data to the server at one time, + // but the server can return the response many times.) + rpc SStreamMethod (Request) returns (stream Response); + + // 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) + // Bidirectional Streaming (In a single call, both client and server can send and receive data + // to each other multiple times.) + rpc TWFMethod (stream Request) returns (stream Response); +} + diff --git a/examples/python/easy_start_demo/notes b/examples/python/easy_start_demo/notes new file mode 100644 index 00000000000..f0518fc1746 --- /dev/null +++ b/examples/python/easy_start_demo/notes @@ -0,0 +1,3 @@ +//自动生成代码 +//Automatic code generation +>>> python -m grpc_tools.protoc -I ./ ./demo.proto --python_out=./customGrpcPackages --grpc_python_out=./customGrpcPackages \ No newline at end of file From b132c34c61a82ccbf6833a03631cab228cb64062 Mon Sep 17 00:00:00 2001 From: Mike Moore Date: Thu, 8 Aug 2019 17:18:38 -0600 Subject: [PATCH 1224/1555] Allow loading grpc/errors before grpc --- .../end2end/errors_load_before_grpc_lib.rb | 31 ++++ .../end2end/logger_load_before_grpc_lib.rb | 33 +++++ .../status_codes_load_before_grpc_lib.rb | 32 +++++ src/ruby/ext/grpc/rb_grpc.c | 40 ------ src/ruby/lib/grpc.rb | 1 + src/ruby/lib/grpc/core/status_codes.rb | 135 ++++++++++++++++++ src/ruby/lib/grpc/errors.rb | 2 +- .../helper_scripts/run_ruby_end2end_tests.sh | 3 + 8 files changed, 236 insertions(+), 41 deletions(-) create mode 100755 src/ruby/end2end/errors_load_before_grpc_lib.rb create mode 100755 src/ruby/end2end/logger_load_before_grpc_lib.rb create mode 100755 src/ruby/end2end/status_codes_load_before_grpc_lib.rb create mode 100644 src/ruby/lib/grpc/core/status_codes.rb diff --git a/src/ruby/end2end/errors_load_before_grpc_lib.rb b/src/ruby/end2end/errors_load_before_grpc_lib.rb new file mode 100755 index 00000000000..7e6ff7696fa --- /dev/null +++ b/src/ruby/end2end/errors_load_before_grpc_lib.rb @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby + +# Copyright 2018 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +this_dir = File.expand_path(File.dirname(__FILE__)) +grpc_lib_dir = File.join(File.dirname(this_dir), 'lib') +$LOAD_PATH.unshift(grpc_lib_dir) unless $LOAD_PATH.include?(grpc_lib_dir) + +def main + fail('GRPC constant loaded before expected') if Object.const_defined?(:GRPC) + require 'grpc/errors' + fail('GRPC constant not loaded when expected') unless Object.const_defined?(:GRPC) + fail('GRPC BadStatus not loaded after required') unless GRPC.const_defined?(:BadStatus) + fail('GRPC library loaded before required') if GRPC::Core.const_defined?(:Channel) + require 'grpc' + fail('GRPC library not loaded after required') unless GRPC::Core.const_defined?(:Channel) +end + +main diff --git a/src/ruby/end2end/logger_load_before_grpc_lib.rb b/src/ruby/end2end/logger_load_before_grpc_lib.rb new file mode 100755 index 00000000000..76c37875040 --- /dev/null +++ b/src/ruby/end2end/logger_load_before_grpc_lib.rb @@ -0,0 +1,33 @@ +#!/usr/bin/env ruby + +# Copyright 2018 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +this_dir = File.expand_path(File.dirname(__FILE__)) +grpc_lib_dir = File.join(File.dirname(this_dir), 'lib') +$LOAD_PATH.unshift(grpc_lib_dir) unless $LOAD_PATH.include?(grpc_lib_dir) + +def main + fail('GRPC constant loaded before expected') if Object.const_defined?(:GRPC) + require 'grpc/logconfig' + fail('GRPC constant not loaded when expected') unless Object.const_defined?(:GRPC) + fail('GRPC DefaultLogger not loaded after required') unless GRPC.const_defined?(:DefaultLogger) + fail('GRPC logger not included after required') unless GRPC.methods.include?(:logger) + fail('GRPC Core loaded before required') if GRPC.const_defined?(:Core) + require 'grpc' + fail('GRPC Core not loaded after required') unless GRPC.const_defined?(:Core) + fail('GRPC library not loaded after required') unless GRPC::Core.const_defined?(:Channel) +end + +main diff --git a/src/ruby/end2end/status_codes_load_before_grpc_lib.rb b/src/ruby/end2end/status_codes_load_before_grpc_lib.rb new file mode 100755 index 00000000000..010c94cb91b --- /dev/null +++ b/src/ruby/end2end/status_codes_load_before_grpc_lib.rb @@ -0,0 +1,32 @@ +#!/usr/bin/env ruby + +# Copyright 2018 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +this_dir = File.expand_path(File.dirname(__FILE__)) +grpc_lib_dir = File.join(File.dirname(this_dir), 'lib') +$LOAD_PATH.unshift(grpc_lib_dir) unless $LOAD_PATH.include?(grpc_lib_dir) + +def main + fail('GRPC constant loaded before expected') if Object.const_defined?(:GRPC) + require 'grpc/core/status_codes' + fail('GRPC constant not loaded when expected') unless Object.const_defined?(:GRPC) + fail('GRPC Core not loaded after required') unless GRPC.const_defined?(:Core) + fail('GRPC StatusCodes not loaded after required') unless GRPC::Core.const_defined?(:StatusCodes) + fail('GRPC library loaded before required') if GRPC::Core.const_defined?(:Channel) + require 'grpc' + fail('GRPC library not loaded after required') unless GRPC::Core.const_defined?(:Channel) +end + +main diff --git a/src/ruby/ext/grpc/rb_grpc.c b/src/ruby/ext/grpc/rb_grpc.c index 4aa41217251..147ab4ad087 100644 --- a/src/ruby/ext/grpc/rb_grpc.c +++ b/src/ruby/ext/grpc/rb_grpc.c @@ -155,45 +155,6 @@ gpr_timespec grpc_rb_time_timeval(VALUE time, int interval) { return t; } -static void Init_grpc_status_codes() { - /* Constants representing the status codes or grpc_status_code in status.h */ - VALUE grpc_rb_mStatusCodes = - rb_define_module_under(grpc_rb_mGrpcCore, "StatusCodes"); - rb_define_const(grpc_rb_mStatusCodes, "OK", INT2NUM(GRPC_STATUS_OK)); - rb_define_const(grpc_rb_mStatusCodes, "CANCELLED", - INT2NUM(GRPC_STATUS_CANCELLED)); - rb_define_const(grpc_rb_mStatusCodes, "UNKNOWN", - INT2NUM(GRPC_STATUS_UNKNOWN)); - rb_define_const(grpc_rb_mStatusCodes, "INVALID_ARGUMENT", - INT2NUM(GRPC_STATUS_INVALID_ARGUMENT)); - rb_define_const(grpc_rb_mStatusCodes, "DEADLINE_EXCEEDED", - INT2NUM(GRPC_STATUS_DEADLINE_EXCEEDED)); - rb_define_const(grpc_rb_mStatusCodes, "NOT_FOUND", - INT2NUM(GRPC_STATUS_NOT_FOUND)); - rb_define_const(grpc_rb_mStatusCodes, "ALREADY_EXISTS", - INT2NUM(GRPC_STATUS_ALREADY_EXISTS)); - rb_define_const(grpc_rb_mStatusCodes, "PERMISSION_DENIED", - INT2NUM(GRPC_STATUS_PERMISSION_DENIED)); - rb_define_const(grpc_rb_mStatusCodes, "UNAUTHENTICATED", - INT2NUM(GRPC_STATUS_UNAUTHENTICATED)); - rb_define_const(grpc_rb_mStatusCodes, "RESOURCE_EXHAUSTED", - INT2NUM(GRPC_STATUS_RESOURCE_EXHAUSTED)); - rb_define_const(grpc_rb_mStatusCodes, "FAILED_PRECONDITION", - INT2NUM(GRPC_STATUS_FAILED_PRECONDITION)); - rb_define_const(grpc_rb_mStatusCodes, "ABORTED", - INT2NUM(GRPC_STATUS_ABORTED)); - rb_define_const(grpc_rb_mStatusCodes, "OUT_OF_RANGE", - INT2NUM(GRPC_STATUS_OUT_OF_RANGE)); - rb_define_const(grpc_rb_mStatusCodes, "UNIMPLEMENTED", - INT2NUM(GRPC_STATUS_UNIMPLEMENTED)); - rb_define_const(grpc_rb_mStatusCodes, "INTERNAL", - INT2NUM(GRPC_STATUS_INTERNAL)); - rb_define_const(grpc_rb_mStatusCodes, "UNAVAILABLE", - INT2NUM(GRPC_STATUS_UNAVAILABLE)); - rb_define_const(grpc_rb_mStatusCodes, "DATA_LOSS", - INT2NUM(GRPC_STATUS_DATA_LOSS)); -} - /* id_at is the constructor method of the ruby standard Time class. */ static ID id_at; @@ -363,7 +324,6 @@ void Init_grpc_c() { Init_grpc_channel_credentials(); Init_grpc_server(); Init_grpc_server_credentials(); - Init_grpc_status_codes(); Init_grpc_time_consts(); Init_grpc_compression_options(); } diff --git a/src/ruby/lib/grpc.rb b/src/ruby/lib/grpc.rb index 37b03920727..66b1b8db39f 100644 --- a/src/ruby/lib/grpc.rb +++ b/src/ruby/lib/grpc.rb @@ -19,6 +19,7 @@ require_relative 'grpc/grpc' require_relative 'grpc/logconfig' require_relative 'grpc/notifier' require_relative 'grpc/version' +require_relative 'grpc/core/status_codes' require_relative 'grpc/core/time_consts' require_relative 'grpc/generic/active_call' require_relative 'grpc/generic/client_stub' diff --git a/src/ruby/lib/grpc/core/status_codes.rb b/src/ruby/lib/grpc/core/status_codes.rb new file mode 100644 index 00000000000..e7e7a0b1e4a --- /dev/null +++ b/src/ruby/lib/grpc/core/status_codes.rb @@ -0,0 +1,135 @@ +# Copyright 2015 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# GRPC contains the General RPC module. +module GRPC + module Core + # StatusCodes defines the canonical error codes used by gRPC for the RPC + # API. + module StatusCodes + # OK is returned on success. + OK = 0 + + # Canceled indicates the operation was canceled (typically by the caller). + CANCELLED = 1 + + # Unknown error. An example of where this error may be returned is if a + # Status value received from another address space belongs to an + # error-space that is not known in this address space. Also errors raised + # by APIs that do not return enough error information may be converted to + # this error. + UNKNOWN = 2 + + # InvalidArgument indicates client specified an invalid argument. Note + # that this differs from FailedPrecondition. It indicates arguments that + # are problematic regardless of the state of the system (e.g., a malformed + # file name). + INVALID_ARGUMENT = 3 + + # DeadlineExceeded means operation expired before completion. For + # operations that change the state of the system, this error may be + # returned even if the operation has completed successfully. For example, + # a successful response from a server could have been delayed long enough + # for the deadline to expire. + DEADLINE_EXCEEDED = 4 + + # NotFound means some requested entity (e.g., file or directory) was not + # found. + NOT_FOUND = 5 + + # AlreadyExists means an attempt to create an entity failed because one + # already exists. + ALREADY_EXISTS = 6 + + # PermissionDenied indicates the caller does not have permission to + # execute the specified operation. It must not be used for rejections + # caused by exhausting some resource (use ResourceExhausted instead for + # those errors). It must not be used if the caller cannot be identified + # (use Unauthenticated instead for those errors). + PERMISSION_DENIED = 7 + + # ResourceExhausted indicates some resource has been exhausted, perhaps a + # per-user quota, or perhaps the entire file system is out of space. + RESOURCE_EXHAUSTED = 8 + + # FailedPrecondition indicates operation was rejected because the system + # is not in a state required for the operation's execution. For example, + # directory to be deleted may be non-empty, an rmdir operation is applied + # to a non-directory, etc. + # + # A litmus test that may help a service implementor in deciding between + # FailedPrecondition, Aborted, and Unavailable: + # (a) Use Unavailable if the client can retry just the failing call. + # (b) Use Aborted if the client should retry at a higher-level (e.g., + # restarting a read-modify-write sequence). + # (c) Use FailedPrecondition if the client should not retry until the + # system state has been explicitly fixed. E.g., if an "rmdir" fails + # because the directory is non-empty, FailedPrecondition should be + # returned since the client should not retry unless they have first + # fixed up the directory by deleting files from it. + # (d) Use FailedPrecondition if the client performs conditional REST + # Get/Update/Delete on a resource and the resource on the server does + # not match the condition. E.g., conflicting read-modify-write on the + # same resource. + FAILED_PRECONDITION = 9 + + # Aborted indicates the operation was aborted, typically due to a + # concurrency issue like sequencer check failures, transaction aborts, + # etc. + # + # See litmus test above for deciding between FailedPrecondition, Aborted, + # and Unavailable. + ABORTED = 10 + + # OutOfRange means operation was attempted past the valid range. E.g., + # seeking or reading past end of file. + # + # Unlike InvalidArgument, this error indicates a problem that may be fixed + # if the system state changes. For example, a 32-bit file system will + # generate InvalidArgument if asked to read at an offset that is not in + # the range [0,2^32-1], but it will generate OutOfRange if asked to read + # from an offset past the current file size. + # + # There is a fair bit of overlap between FailedPrecondition and + # OutOfRange. We recommend using OutOfRange (the more specific error) when + # it applies so that callers who are iterating through a space can easily + # look for an OutOfRange error to detect when they are done. + OUT_OF_RANGE = 11 + + # Unimplemented indicates operation is not implemented or not + # supported/enabled in this service. + UNIMPLEMENTED = 12 + + # Internal errors. Means some invariants expected by underlying system has + # been broken. If you see one of these errors, something is very broken. + INTERNAL = 13 + + # Unavailable indicates the service is currently unavailable. This is a + # most likely a transient condition and may be corrected by retrying with + # a backoff. Note that it is not always safe to retry non-idempotent + # operations. + # + # See litmus test above for deciding between FailedPrecondition, Aborted, + # and Unavailable. + UNAVAILABLE = 14 + + # DataLoss indicates unrecoverable data loss or corruption. + DATA_LOSS = 15 + + # Unauthenticated indicates the request does not have valid authentication + # credentials for the operation. + UNAUTHENTICATED = 16 + end + end +end diff --git a/src/ruby/lib/grpc/errors.rb b/src/ruby/lib/grpc/errors.rb index 0b27bee1b9c..e44043f3199 100644 --- a/src/ruby/lib/grpc/errors.rb +++ b/src/ruby/lib/grpc/errors.rb @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require_relative './grpc' +require_relative './core/status_codes' # GRPC contains the General RPC module. module GRPC diff --git a/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh b/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh index 1c48ed20ba6..fc0759fc836 100755 --- a/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh +++ b/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh @@ -32,4 +32,7 @@ time ruby src/ruby/end2end/client_memory_usage_driver.rb || EXIT_CODE=1 time ruby src/ruby/end2end/package_with_underscore_checker.rb || EXIT_CODE=1 time ruby src/ruby/end2end/graceful_sig_handling_driver.rb || EXIT_CODE=1 time ruby src/ruby/end2end/graceful_sig_stop_driver.rb || EXIT_CODE=1 +time ruby src/ruby/end2end/errors_load_before_grpc_lib.rb || EXIT_CODE=1 +time ruby src/ruby/end2end/logger_load_before_grpc_lib.rb || EXIT_CODE=1 +time ruby src/ruby/end2end/status_codes_load_before_grpc_lib.rb || EXIT_CODE=1 exit $EXIT_CODE From 1713c3689252dce4515006c4a1c5c9fe707495d4 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 13 Aug 2019 10:06:04 -0700 Subject: [PATCH 1225/1555] Prevent HTTP2 parser from queueing a lot of induced frames - SETTINGS ACK, PING ACK, RST_STREAM --- .../chttp2/transport/chttp2_transport.cc | 55 +++++++++++++------ .../transport/chttp2/transport/frame_ping.cc | 1 + .../chttp2/transport/frame_rst_stream.cc | 8 +++ .../chttp2/transport/frame_rst_stream.h | 7 +++ .../chttp2/transport/frame_settings.cc | 1 + .../chttp2/transport/hpack_parser.cc | 5 +- .../ext/transport/chttp2/transport/internal.h | 7 +++ .../ext/transport/chttp2/transport/parsing.cc | 14 ++--- .../ext/transport/chttp2/transport/writing.cc | 1 + 9 files changed, 71 insertions(+), 28 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index d4ecc37fcc5..029d96c95fe 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -74,6 +74,8 @@ #define DEFAULT_MAX_PINGS_BETWEEN_DATA 2 #define DEFAULT_MAX_PING_STRIKES 2 +#define DEFAULT_MAX_PENDING_INDUCED_FRAMES 10000 + static int g_default_client_keepalive_time_ms = DEFAULT_CLIENT_KEEPALIVE_TIME_MS; static int g_default_client_keepalive_timeout_ms = @@ -105,6 +107,7 @@ static void write_action(void* t, grpc_error* error); static void write_action_end_locked(void* t, grpc_error* error); static void read_action_locked(void* t, grpc_error* error); +static void continue_read_action_locked(grpc_chttp2_transport* t); static void complete_fetch_locked(void* gs, grpc_error* error); /** Set a transport level setting, and push it to our peer */ @@ -797,10 +800,8 @@ grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_chttp2_transport* t, !grpc_resource_user_safe_alloc(t->resource_user, GRPC_RESOURCE_QUOTA_CALL_SIZE)) { gpr_log(GPR_ERROR, "Memory exhausted, rejecting the stream."); - grpc_slice_buffer_add( - &t->qbuf, - grpc_chttp2_rst_stream_create( - id, static_cast(GRPC_HTTP2_REFUSED_STREAM), nullptr)); + grpc_chttp2_add_rst_stream_to_next_write(t, id, GRPC_HTTP2_REFUSED_STREAM, + nullptr); grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_RST_STREAM); return nullptr; } @@ -1045,6 +1046,19 @@ static void write_action_begin_locked(void* gt, grpc_error* error_ignored) { GRPC_CLOSURE_SCHED( GRPC_CLOSURE_INIT(&t->write_action, write_action, t, scheduler), GRPC_ERROR_NONE); + if (t->reading_paused_on_pending_induced_frames) { + GPR_ASSERT(t->num_pending_induced_frames == 0); + /* We had paused reading, because we had many induced frames (SETTINGS + * ACK, RST_STREAMS) pending in t->qbuf. Now that we have been able to + * flush qbuf, we can resume reading. */ + GRPC_CHTTP2_IF_TRACING(gpr_log( + GPR_INFO, + "transport %p : Resuming reading after being paused due to too " + "many unwritten SETTINGS ACK and RST_STREAM frames", + t)); + t->reading_paused_on_pending_induced_frames = false; + continue_read_action_locked(t); + } } else { GRPC_STATS_INC_HTTP2_SPURIOUS_WRITES_BEGUN(); set_write_state(t, GRPC_CHTTP2_WRITE_STATE_IDLE, "begin writing nothing"); @@ -1114,7 +1128,6 @@ static void write_action_end_locked(void* tp, grpc_error* error) { } grpc_chttp2_end_write(t, GRPC_ERROR_REF(error)); - GRPC_CHTTP2_UNREF_TRANSPORT(t, "writing"); } @@ -1160,7 +1173,6 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t, gpr_log(GPR_INFO, "%s: Got goaway [%d] err=%s", t->peer_string, goaway_error, grpc_error_string(t->goaway_error)); } - /* When a client receives a GOAWAY with error code ENHANCE_YOUR_CALM and debug * data equal to "too_many_pings", it should log the occurrence at a log level * that is enabled by default and double the configured KEEPALIVE_TIME used @@ -2110,10 +2122,8 @@ void grpc_chttp2_cancel_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s, grpc_http2_error_code http_error; grpc_error_get_status(due_to_error, s->deadline, nullptr, nullptr, &http_error, nullptr); - grpc_slice_buffer_add( - &t->qbuf, - grpc_chttp2_rst_stream_create( - s->id, static_cast(http_error), &s->stats.outgoing)); + grpc_chttp2_add_rst_stream_to_next_write( + t, s->id, static_cast(http_error), &s->stats.outgoing); grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_RST_STREAM); } } @@ -2424,9 +2434,8 @@ static void close_from_api(grpc_chttp2_transport* t, grpc_chttp2_stream* s, grpc_slice_buffer_add(&t->qbuf, status_hdr); grpc_slice_buffer_add(&t->qbuf, message_pfx); grpc_slice_buffer_add(&t->qbuf, grpc_slice_ref_internal(slice)); - grpc_slice_buffer_add( - &t->qbuf, grpc_chttp2_rst_stream_create(s->id, GRPC_HTTP2_NO_ERROR, - &s->stats.outgoing)); + grpc_chttp2_add_rst_stream_to_next_write(t, s->id, GRPC_HTTP2_NO_ERROR, + &s->stats.outgoing); grpc_chttp2_mark_stream_closed(t, s, 1, 1, error); grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_CLOSE_FROM_API); @@ -2596,10 +2605,16 @@ static void read_action_locked(void* tp, grpc_error* error) { grpc_slice_buffer_reset_and_unref_internal(&t->read_buffer); if (keep_reading) { - const bool urgent = t->goaway_error != GRPC_ERROR_NONE; - grpc_endpoint_read(t->ep, &t->read_buffer, &t->read_action_locked, urgent); - grpc_chttp2_act_on_flowctl_action(t->flow_control->MakeAction(), t, - nullptr); + if (t->num_pending_induced_frames >= DEFAULT_MAX_PENDING_INDUCED_FRAMES) { + t->reading_paused_on_pending_induced_frames = true; + GRPC_CHTTP2_IF_TRACING( + gpr_log(GPR_INFO, + "transport %p : Pausing reading due to too " + "many unwritten SETTINGS ACK and RST_STREAM frames", + t)); + } else { + continue_read_action_locked(t); + } } else { GRPC_CHTTP2_UNREF_TRANSPORT(t, "reading_action"); } @@ -2607,6 +2622,12 @@ static void read_action_locked(void* tp, grpc_error* error) { GRPC_ERROR_UNREF(error); } +static void continue_read_action_locked(grpc_chttp2_transport* t) { + const bool urgent = t->goaway_error != GRPC_ERROR_NONE; + grpc_endpoint_read(t->ep, &t->read_buffer, &t->read_action_locked, urgent); + grpc_chttp2_act_on_flowctl_action(t->flow_control->MakeAction(), t, nullptr); +} + // t is reffed prior to calling the first time, and once the callback chain // that kicks off finishes, it's unreffed static void schedule_bdp_ping_locked(grpc_chttp2_transport* t) { diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.cc b/src/core/ext/transport/chttp2/transport/frame_ping.cc index 9a56bf093f4..87c92dffc38 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.cc +++ b/src/core/ext/transport/chttp2/transport/frame_ping.cc @@ -118,6 +118,7 @@ grpc_error* grpc_chttp2_ping_parser_parse(void* parser, t->ping_acks = static_cast(gpr_realloc( t->ping_acks, t->ping_ack_capacity * sizeof(*t->ping_acks))); } + t->num_pending_induced_frames++; t->ping_acks[t->ping_ack_count++] = p->opaque_8bytes; grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_PING_RESPONSE); } diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc b/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc index cda09c3dea1..1350a967b9f 100644 --- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc @@ -58,6 +58,14 @@ grpc_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code, return slice; } +void grpc_chttp2_add_rst_stream_to_next_write( + grpc_chttp2_transport* t, uint32_t id, uint32_t code, + grpc_transport_one_way_stats* stats) { + t->num_pending_induced_frames++; + grpc_slice_buffer_add(&t->qbuf, + grpc_chttp2_rst_stream_create(id, code, stats)); +} + grpc_error* grpc_chttp2_rst_stream_parser_begin_frame( grpc_chttp2_rst_stream_parser* parser, uint32_t length, uint8_t flags) { if (length != 4) { diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h index 64707666181..d61e62394a4 100644 --- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h @@ -33,6 +33,13 @@ typedef struct { grpc_slice grpc_chttp2_rst_stream_create(uint32_t stream_id, uint32_t code, grpc_transport_one_way_stats* stats); +// Adds RST_STREAM frame to t->qbuf (buffer for the next write). Should be +// called when we want to add RST_STREAM and we are not in +// write_action_begin_locked. +void grpc_chttp2_add_rst_stream_to_next_write( + grpc_chttp2_transport* t, uint32_t id, uint32_t code, + grpc_transport_one_way_stats* stats); + grpc_error* grpc_chttp2_rst_stream_parser_begin_frame( grpc_chttp2_rst_stream_parser* parser, uint32_t length, uint8_t flags); grpc_error* grpc_chttp2_rst_stream_parser_parse(void* parser, diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.cc b/src/core/ext/transport/chttp2/transport/frame_settings.cc index 3f84679ec31..ba57afa74b9 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.cc +++ b/src/core/ext/transport/chttp2/transport/frame_settings.cc @@ -132,6 +132,7 @@ grpc_error* grpc_chttp2_settings_parser_parse(void* p, grpc_chttp2_transport* t, if (is_last) { memcpy(parser->target_settings, parser->incoming_settings, GRPC_CHTTP2_NUM_SETTINGS * sizeof(uint32_t)); + t->num_pending_induced_frames++; grpc_slice_buffer_add(&t->qbuf, grpc_chttp2_settings_ack_create()); if (t->notify_on_receive_settings != nullptr) { GRPC_CLOSURE_SCHED(t->notify_on_receive_settings, diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index be52d62be3a..7414fd7fff8 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -1671,9 +1671,8 @@ static void force_client_rst_stream(void* sp, grpc_error* error) { grpc_chttp2_stream* s = static_cast(sp); grpc_chttp2_transport* t = s->t; if (!s->write_closed) { - grpc_slice_buffer_add( - &t->qbuf, grpc_chttp2_rst_stream_create(s->id, GRPC_HTTP2_NO_ERROR, - &s->stats.outgoing)); + grpc_chttp2_add_rst_stream_to_next_write(t, s->id, GRPC_HTTP2_NO_ERROR, + &s->stats.outgoing); grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_FORCE_RST_STREAM); grpc_chttp2_mark_stream_closed(t, s, true, true, GRPC_ERROR_NONE); } diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 2204691726a..b00576cadd5 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -493,6 +493,13 @@ struct grpc_chttp2_transport { grpc_core::ContextList* cl = nullptr; grpc_core::RefCountedPtr channelz_socket; uint32_t num_messages_in_next_write = 0; + /** The number of pending induced frames (SETTINGS_ACK and RST_STREAM) in the + * outgoing buffer (t->qbuf). If this number goes beyond + * DEFAULT_MAX_PENDING_INDUCED_FRAMES, we pause reading new frames. We would + * only continue reading when we are able to write to the socket again, + * thereby reducing the number of induced frames. */ + uint32_t num_pending_induced_frames = 0; + bool reading_paused_on_pending_induced_frames = false; }; typedef enum { diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index c1b226c5fb3..2a2a8206cb6 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -382,10 +382,9 @@ error_handler: if (s != nullptr) { grpc_chttp2_mark_stream_closed(t, s, true, false, err); } - grpc_slice_buffer_add( - &t->qbuf, grpc_chttp2_rst_stream_create(t->incoming_stream_id, - GRPC_HTTP2_PROTOCOL_ERROR, - &s->stats.outgoing)); + grpc_chttp2_add_rst_stream_to_next_write(t, t->incoming_stream_id, + GRPC_HTTP2_PROTOCOL_ERROR, + &s->stats.outgoing); return init_skip_frame_parser(t, 0); } else { return err; @@ -763,10 +762,9 @@ static grpc_error* parse_frame_slice(grpc_chttp2_transport* t, grpc_chttp2_parsing_become_skip_parser(t); if (s) { s->forced_close_error = err; - grpc_slice_buffer_add( - &t->qbuf, grpc_chttp2_rst_stream_create(t->incoming_stream_id, - GRPC_HTTP2_PROTOCOL_ERROR, - &s->stats.outgoing)); + grpc_chttp2_add_rst_stream_to_next_write(t, t->incoming_stream_id, + GRPC_HTTP2_PROTOCOL_ERROR, + &s->stats.outgoing); } else { GRPC_ERROR_UNREF(err); } diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc index f3cb390dc7a..d6d9e4521f6 100644 --- a/src/core/ext/transport/chttp2/transport/writing.cc +++ b/src/core/ext/transport/chttp2/transport/writing.cc @@ -219,6 +219,7 @@ class WriteContext { void FlushQueuedBuffers() { /* simple writes are queued to qbuf, and flushed here */ grpc_slice_buffer_move_into(&t_->qbuf, &t_->outbuf); + t_->num_pending_induced_frames = 0; GPR_ASSERT(t_->qbuf.count == 0); } From eceb4db63ed13d0f3df8019048b95a25fbb9de97 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 13 Aug 2019 10:37:43 -0700 Subject: [PATCH 1226/1555] Reviewer comments --- src/core/ext/transport/chttp2/transport/chttp2_transport.cc | 6 +++--- src/core/ext/transport/chttp2/transport/internal.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 029d96c95fe..f4b0f694142 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -1049,12 +1049,12 @@ static void write_action_begin_locked(void* gt, grpc_error* error_ignored) { if (t->reading_paused_on_pending_induced_frames) { GPR_ASSERT(t->num_pending_induced_frames == 0); /* We had paused reading, because we had many induced frames (SETTINGS - * ACK, RST_STREAMS) pending in t->qbuf. Now that we have been able to - * flush qbuf, we can resume reading. */ + * ACK, PINGS ACK and RST_STREAMS) pending in t->qbuf. Now that we have + * been able to flush qbuf, we can resume reading. */ GRPC_CHTTP2_IF_TRACING(gpr_log( GPR_INFO, "transport %p : Resuming reading after being paused due to too " - "many unwritten SETTINGS ACK and RST_STREAM frames", + "many unwritten SETTINGS ACK, PINGS ACK and RST_STREAM frames", t)); t->reading_paused_on_pending_induced_frames = false; continue_read_action_locked(t); diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index b00576cadd5..6e1db8a5707 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -493,8 +493,8 @@ struct grpc_chttp2_transport { grpc_core::ContextList* cl = nullptr; grpc_core::RefCountedPtr channelz_socket; uint32_t num_messages_in_next_write = 0; - /** The number of pending induced frames (SETTINGS_ACK and RST_STREAM) in the - * outgoing buffer (t->qbuf). If this number goes beyond + /** The number of pending induced frames (SETTINGS_ACK, PINGS_ACK and + * RST_STREAM) in the outgoing buffer (t->qbuf). If this number goes beyond * DEFAULT_MAX_PENDING_INDUCED_FRAMES, we pause reading new frames. We would * only continue reading when we are able to write to the socket again, * thereby reducing the number of induced frames. */ From 1d981068475d6b938b6df0132e14e3a0f0e93229 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Tue, 13 Aug 2019 10:45:52 -0700 Subject: [PATCH 1227/1555] Renaming the correct files --- test/cpp/ios/build_and_run_tests.sh | 31 +++++++++---------- test/cpp/ios/{run_tests.sh => build_tests.sh} | 31 ++++++++++--------- 2 files changed, 31 insertions(+), 31 deletions(-) rename test/cpp/ios/{run_tests.sh => build_tests.sh} (61%) diff --git a/test/cpp/ios/build_and_run_tests.sh b/test/cpp/ios/build_and_run_tests.sh index ead0159dcc9..83db83fd199 100755 --- a/test/cpp/ios/build_and_run_tests.sh +++ b/test/cpp/ios/build_and_run_tests.sh @@ -14,27 +14,26 @@ # limitations under the License. # Don't run this script standalone. Instead, run from the repository root: -# ./tools/run_tests/run_tests.py -l objc +# ./tools/run_tests/run_tests.py -l c++ -set -e - -# CocoaPods requires the terminal to be using UTF-8 encoding. -export LANG=en_US.UTF-8 +set -ev cd "$(dirname "$0")" -hash pod 2>/dev/null || { echo >&2 "Cocoapods needs to be installed."; exit 1; } -hash xcodebuild 2>/dev/null || { - echo >&2 "XCode command-line tools need to be installed." - exit 1 -} +echo "TIME: $(date)" -# clean the directory -rm -rf Pods -rm -rf Tests.xcworkspace -rm -f Podfile.lock -rm -rf RemoteTestClientCpp/src +./build_tests.sh echo "TIME: $(date)" -pod install +set -o pipefail + +XCODEBUILD_FILTER='(^CompileC |^Ld |^ *[^ ]*clang |^ *cd |^ *export |^Libtool |^ *[^ ]*libtool |^CpHeader |^ *builtin-copy )' + +xcodebuild \ + -workspace Tests.xcworkspace \ + -scheme CronetTests \ + -destination name="iPhone 8" \ + test \ + | egrep -v "$XCODEBUILD_FILTER" \ + | egrep -v '^$' - diff --git a/test/cpp/ios/run_tests.sh b/test/cpp/ios/build_tests.sh similarity index 61% rename from test/cpp/ios/run_tests.sh rename to test/cpp/ios/build_tests.sh index 83db83fd199..ead0159dcc9 100755 --- a/test/cpp/ios/run_tests.sh +++ b/test/cpp/ios/build_tests.sh @@ -14,26 +14,27 @@ # limitations under the License. # Don't run this script standalone. Instead, run from the repository root: -# ./tools/run_tests/run_tests.py -l c++ +# ./tools/run_tests/run_tests.py -l objc -set -ev +set -e + +# CocoaPods requires the terminal to be using UTF-8 encoding. +export LANG=en_US.UTF-8 cd "$(dirname "$0")" -echo "TIME: $(date)" +hash pod 2>/dev/null || { echo >&2 "Cocoapods needs to be installed."; exit 1; } +hash xcodebuild 2>/dev/null || { + echo >&2 "XCode command-line tools need to be installed." + exit 1 +} -./build_tests.sh +# clean the directory +rm -rf Pods +rm -rf Tests.xcworkspace +rm -f Podfile.lock +rm -rf RemoteTestClientCpp/src echo "TIME: $(date)" +pod install -set -o pipefail - -XCODEBUILD_FILTER='(^CompileC |^Ld |^ *[^ ]*clang |^ *cd |^ *export |^Libtool |^ *[^ ]*libtool |^CpHeader |^ *builtin-copy )' - -xcodebuild \ - -workspace Tests.xcworkspace \ - -scheme CronetTests \ - -destination name="iPhone 8" \ - test \ - | egrep -v "$XCODEBUILD_FILTER" \ - | egrep -v '^$' - From 4c893d8cdc279c8d460a53ed4dd809761588361d Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Tue, 13 Aug 2019 11:04:18 -0700 Subject: [PATCH 1228/1555] Changed dev languages and bundle ids --- src/objective-c/examples/BUILD | 12 +++---- .../Sample/Sample.xcodeproj/project.pbxproj | 4 +-- .../examples/Sample/Sample/Info.plist | 2 +- .../tvOS-sample.xcodeproj/project.pbxproj | 6 ++-- .../tvOS-sample/tvOS-sample/Info.plist | 2 +- .../watchOS-sample/WatchKit-App/Info.plist | 4 +-- .../WatchKit-Extension/Info.plist | 4 +-- .../watchOS-sample.xcodeproj/project.pbxproj | 36 ++++--------------- .../watchOS-sample/watchOS-sample/Info.plist | 2 +- 9 files changed, 24 insertions(+), 48 deletions(-) diff --git a/src/objective-c/examples/BUILD b/src/objective-c/examples/BUILD index 5e3e4f9badd..4f333cd7502 100644 --- a/src/objective-c/examples/BUILD +++ b/src/objective-c/examples/BUILD @@ -63,7 +63,7 @@ objc_library( ios_application( name = "Sample", - bundle_id = "grpc.objc.examples.Sample", + bundle_id = "io.grpc.Sample", minimum_os_version = "8.0", infoplists = ["Sample/Sample/Info.plist"], families = [ @@ -87,7 +87,7 @@ objc_library( ios_application( name = "InterceptorSample", - bundle_id = "grpc.objc.examples.InterceptorSample", + bundle_id = "io.grpc.InterceptorSample", minimum_os_version = "9.0", # Safe Area Layout Guide used infoplists = ["InterceptorSample/InterceptorSample/Info.plist"], families = [ @@ -111,7 +111,7 @@ objc_library( # c-ares does not support tvOS CPU architecture with Bazel yet tvos_application( name = "tvOS-sample", - bundle_id = "grpc.objc.examples.tvOS-sample", + bundle_id = "io.grpc.tvOS-sample", minimum_os_version = "10.0", infoplists = ["tvOS-sample/tvOS-sample/Info.plist"], deps = [":tvOS-sample-lib"], @@ -141,7 +141,7 @@ objc_library( ios_application( name = "watchOS-sample", - bundle_id = "com.google.watchOS-sample", + bundle_id = "io.grpc.watchOS-sample", minimum_os_version = "9.0", # Safe Area Layout Guide used families = ["iphone"], infoplists = ["watchOS-sample/watchOS-sample/Info.plist"], @@ -152,7 +152,7 @@ ios_application( # c-ares does not support watchOS CPU architecture with Bazel yet watchos_application( name = "watchOS-sample-watchApp", - bundle_id = "com.google.watchOS-sample.watchkitapp", + bundle_id = "io.grpc.watchOS-sample.watchkitapp", minimum_os_version = "4.0", storyboards = ["watchOS-sample/WatchKit-App/Base.lproj/Interface.storyboard"], infoplists = ["watchOS-sample/WatchKit-App/Info.plist"], @@ -161,7 +161,7 @@ watchos_application( watchos_extension( name = "watchOS-sample-extension", - bundle_id = "com.google.watchOS-sample.watchkitapp.watchkitextension", + bundle_id = "io.grpc.watchOS-sample.watchkitapp.watchkitextension", minimum_os_version = "4.0", infoplists = ["watchOS-sample/WatchKit-Extension/Info.plist"], deps = [":watchOS-sample-extension-lib"], diff --git a/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj b/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj index cdd1c6c8f7e..2c8156de1e3 100644 --- a/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj @@ -327,7 +327,7 @@ INFOPLIST_FILE = Sample/Info.plist; LD_GENERATE_MAP_FILE = YES; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "org.grpc.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.Sample; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -340,7 +340,7 @@ INFOPLIST_FILE = Sample/Info.plist; LD_GENERATE_MAP_FILE = YES; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "org.grpc.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.Sample; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; diff --git a/src/objective-c/examples/Sample/Sample/Info.plist b/src/objective-c/examples/Sample/Sample/Info.plist index 2cdf09dc2fc..943e942ae83 100644 --- a/src/objective-c/examples/Sample/Sample/Info.plist +++ b/src/objective-c/examples/Sample/Sample/Info.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - en + en_US CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj b/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj index 84eafed2608..be6863f9f3f 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample.xcodeproj/project.pbxproj @@ -214,7 +214,7 @@ ); inputPaths = ( "${SRCROOT}/Pods/Target Support Files/Pods-tvOS-sample/Pods-tvOS-sample-resources.sh", - "$PODS_CONFIGURATION_BUILD_DIR/gRPC/gRPCCertificates.bundle", + $PODS_CONFIGURATION_BUILD_DIR/gRPC/gRPCCertificates.bundle, ); name = "[CP] Copy Pods Resources"; outputPaths = ( @@ -365,7 +365,7 @@ DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "tvOS-sample/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.google.tvOS-sample"; + PRODUCT_BUNDLE_IDENTIFIER = "io.grpc.tvOS-sample"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; TARGETED_DEVICE_FAMILY = 3; @@ -384,7 +384,7 @@ DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "tvOS-sample/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.google.tvOS-sample"; + PRODUCT_BUNDLE_IDENTIFIER = "io.grpc.tvOS-sample"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; TARGETED_DEVICE_FAMILY = 3; diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/Info.plist b/src/objective-c/examples/tvOS-sample/tvOS-sample/Info.plist index 63dcd6c1d26..33fbde9c63c 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/Info.plist +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/Info.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - en + en_US CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-App/Info.plist b/src/objective-c/examples/watchOS-sample/WatchKit-App/Info.plist index 6dbcfe04d53..72c83c2794f 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-App/Info.plist +++ b/src/objective-c/examples/watchOS-sample/WatchKit-App/Info.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - en + en_US CFBundleDisplayName WatchKit-App CFBundleExecutable @@ -26,7 +26,7 @@ UIInterfaceOrientationPortraitUpsideDown WKCompanionAppBundleIdentifier - com.google.watchOS-sample + io.grpc.watchOS-sample WKWatchKitApp diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Info.plist b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Info.plist index 4a0a252b854..8d8373ba3e5 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Info.plist +++ b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/Info.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - en + en_US CFBundleDisplayName watchOS-sample WatchKit Extension CFBundleExecutable @@ -25,7 +25,7 @@ NSExtensionAttributes WKAppBundleIdentifier - com.google.watchOS-sample.watchkitapp + io.grpc.watchOS-sample.watchkitapp NSExtensionPointIdentifier com.apple.watchkit diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj index ddd91170243..8042b5c4a0d 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample.xcodeproj/project.pbxproj @@ -342,15 +342,11 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${SRCROOT}/Pods/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-resources.sh", "$PODS_CONFIGURATION_BUILD_DIR/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - ); outputPaths = ( "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}", ); @@ -364,8 +360,6 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${SRCROOT}/Pods/Target Support Files/Pods-watchOS-sample/Pods-watchOS-sample-frameworks.sh", "${BUILT_PRODUCTS_DIR}/BoringSSL-GRPC-iOS/openssl_grpc.framework", @@ -378,8 +372,6 @@ "${BUILT_PRODUCTS_DIR}/nanopb-iOS/nanopb.framework", ); name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - ); outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/openssl_grpc.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework", @@ -400,15 +392,11 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${PODS_PODFILE_DIR_PATH}/Podfile.lock", "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); outputPaths = ( "$(DERIVED_FILE_DIR)/Pods-watchOS-sample-checkManifestLockResult.txt", ); @@ -422,15 +410,11 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${PODS_PODFILE_DIR_PATH}/Podfile.lock", "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); outputPaths = ( "$(DERIVED_FILE_DIR)/Pods-watchOS-sample WatchKit Extension-checkManifestLockResult.txt", ); @@ -444,15 +428,11 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${SRCROOT}/Pods/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-resources.sh", "$PODS_CONFIGURATION_BUILD_DIR/gRPC-watchOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - ); outputPaths = ( "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}", ); @@ -466,8 +446,6 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${SRCROOT}/Pods/Target Support Files/Pods-watchOS-sample WatchKit Extension/Pods-watchOS-sample WatchKit Extension-frameworks.sh", "${BUILT_PRODUCTS_DIR}/BoringSSL-GRPC-watchOS/openssl_grpc.framework", @@ -480,8 +458,6 @@ "${BUILT_PRODUCTS_DIR}/nanopb-watchOS/nanopb.framework", ); name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - ); outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/openssl_grpc.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework", @@ -675,7 +651,7 @@ DEVELOPMENT_TEAM = 6T98ZJNPG5; INFOPLIST_FILE = "$(SRCROOT)/WatchKit-Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-sample.watchkitapp.watchkitextension"; + PRODUCT_BUNDLE_IDENTIFIER = "io.grpc.watchOS-sample.watchkitapp.watchkitextension"; PRODUCT_NAME = "${TARGET_NAME}"; SDKROOT = watchos; SKIP_INSTALL = YES; @@ -693,7 +669,7 @@ DEVELOPMENT_TEAM = 6T98ZJNPG5; INFOPLIST_FILE = "$(SRCROOT)/WatchKit-Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-sample.watchkitapp.watchkitextension"; + PRODUCT_BUNDLE_IDENTIFIER = "io.grpc.watchOS-sample.watchkitapp.watchkitextension"; PRODUCT_NAME = "${TARGET_NAME}"; SDKROOT = watchos; SKIP_INSTALL = YES; @@ -710,7 +686,7 @@ DEVELOPMENT_TEAM = 6T98ZJNPG5; IBSC_MODULE = watchOS_sample_WatchKit_Extension; INFOPLIST_FILE = "$(SRCROOT)/WatchKit-App/Info.plist"; - PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-sample.watchkitapp"; + PRODUCT_BUNDLE_IDENTIFIER = "io.grpc.watchOS-sample.watchkitapp"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = watchos; SKIP_INSTALL = YES; @@ -727,7 +703,7 @@ DEVELOPMENT_TEAM = 6T98ZJNPG5; IBSC_MODULE = watchOS_sample_WatchKit_Extension; INFOPLIST_FILE = "$(SRCROOT)/WatchKit-App/Info.plist"; - PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-sample.watchkitapp"; + PRODUCT_BUNDLE_IDENTIFIER = "io.grpc.watchOS-sample.watchkitapp"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = watchos; SKIP_INSTALL = YES; @@ -745,7 +721,7 @@ DEVELOPMENT_TEAM = 6T98ZJNPG5; INFOPLIST_FILE = "watchOS-sample/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-sample"; + PRODUCT_BUNDLE_IDENTIFIER = "io.grpc.watchOS-sample"; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -760,7 +736,7 @@ DEVELOPMENT_TEAM = 6T98ZJNPG5; INFOPLIST_FILE = "watchOS-sample/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.google.watchOS-sample"; + PRODUCT_BUNDLE_IDENTIFIER = "io.grpc.watchOS-sample"; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; }; diff --git a/src/objective-c/examples/watchOS-sample/watchOS-sample/Info.plist b/src/objective-c/examples/watchOS-sample/watchOS-sample/Info.plist index d0524738680..e5d82108923 100644 --- a/src/objective-c/examples/watchOS-sample/watchOS-sample/Info.plist +++ b/src/objective-c/examples/watchOS-sample/watchOS-sample/Info.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - en + en_US CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier From 2a070b853d4cb178c9aa3e8b86ee86003dbf6ea9 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Tue, 13 Aug 2019 11:06:59 -0700 Subject: [PATCH 1229/1555] Reverting changes --- .../tests/InteropTests/InteropTestsMultipleChannels.m | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m index c363e523250..98893a466bd 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m +++ b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m @@ -86,9 +86,7 @@ dispatch_once_t initCronet; self.continueAfterFailure = NO; _remoteService = [RMTTestService serviceWithHost:kRemoteSSLHost callOptions:nil]; -#ifdef GRPC_COMPILE_WITH_CRONET configureCronet(); -#endif // Default stack with remote host GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; From 0ad64536edefdb80eff20180717806f4a2694373 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Tue, 13 Aug 2019 11:15:38 -0700 Subject: [PATCH 1230/1555] Added some comments and TODOs --- .../tests/build_one_example_bazel.sh | 4 +- src/objective-c/tests/run_one_test_bazel.sh | 3 + src/objective-c/tests/run_tests.sh | 111 ------------------ tools/run_tests/run_tests.py | 2 + 4 files changed, 7 insertions(+), 113 deletions(-) delete mode 100755 src/objective-c/tests/run_tests.sh diff --git a/src/objective-c/tests/build_one_example_bazel.sh b/src/objective-c/tests/build_one_example_bazel.sh index c3fb3f232b5..b547ac157f0 100755 --- a/src/objective-c/tests/build_one_example_bazel.sh +++ b/src/objective-c/tests/build_one_example_bazel.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2016 gRPC authors. +# Copyright 2019 gRPC authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,4 +32,4 @@ cd $EXAMPLE_PATH/.. if [ "$SCHEME" == "watchOS-sample-WatchKit-App" ]; then SCHEME="watchOS-sample watchOS-sample-watchApp" fi -../../../tools/bazel build $SCHEME \ No newline at end of file +../../../tools/bazel build $SCHEME diff --git a/src/objective-c/tests/run_one_test_bazel.sh b/src/objective-c/tests/run_one_test_bazel.sh index 97065e8545a..8f920d955fd 100755 --- a/src/objective-c/tests/run_one_test_bazel.sh +++ b/src/objective-c/tests/run_one_test_bazel.sh @@ -16,6 +16,9 @@ # Don't run this script standalone. Instead, run from the repository root: # ./tools/run_tests/run_tests.py -l objc +# TODO(tonyzhehaolu): +# For future use when Xcode is upgraded and tvos_unit_test is fully functional + set -ev cd $(dirname $0) diff --git a/src/objective-c/tests/run_tests.sh b/src/objective-c/tests/run_tests.sh deleted file mode 100755 index 4ffb0e072d9..00000000000 --- a/src/objective-c/tests/run_tests.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/bash -# Copyright 2015 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Don't run this script standalone. Instead, run from the repository root: -# ./tools/run_tests/run_tests.py -l objc - -set -ev - -cd $(dirname $0) - -# Run the tests server. - -BAZEL=../../../tools/bazel - -INTEROP=../../../bazel-out/darwin-fastbuild/bin/test/cpp/interop/interop_server - -[ -d Tests.xcworkspace ] || { - ./build_tests.sh -} - -[ -f $INTEROP ] || { - BAZEL build //test/cpp/interop:interop_server -} - -[ -z "$(ps aux |egrep 'port_server\.py.*-p\s32766')" ] && { - echo >&2 "Can't find the port server. Start port server with tools/run_tests/start_port_server.py." - exit 1 -} - -PLAIN_PORT=$(curl localhost:32766/get) -TLS_PORT=$(curl localhost:32766/get) - -$INTEROP --port=$PLAIN_PORT --max_send_message_size=8388608 & -$INTEROP --port=$TLS_PORT --max_send_message_size=8388608 --use_tls & - -# Kill them when this script exits. -trap 'kill -9 `jobs -p` ; echo "EXIT TIME: $(date)"' EXIT - -set -o pipefail - -# xcodebuild is very verbose. We filter its output and tell Bash to fail if any -# element of the pipe fails. -# TODO(jcanizales): Use xctool instead? Issue #2540. -XCODEBUILD_FILTER='(^CompileC |^Ld |^ *[^ ]*clang |^ *cd |^ *export |^Libtool |^ *[^ ]*libtool |^CpHeader |^ *builtin-copy )' - -echo "TIME: $(date)" - -xcodebuild \ - -workspace Tests.xcworkspace \ - -scheme InteropTests \ - -destination name="iPhone 8" \ - HOST_PORT_LOCALSSL=localhost:5051 \ - HOST_PORT_LOCAL=localhost:5050 \ - HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ - test \ - | egrep -v "$XCODEBUILD_FILTER" \ - | egrep -v '^$' \ - | egrep -v "(GPBDictionary|GPBArray)" - - -echo "TIME: $(date)" -xcodebuild \ - -workspace Tests.xcworkspace \ - -scheme UnitTests \ - -destination name="iPhone 8" \ - HOST_PORT_LOCALSSL=localhost:5051 \ - HOST_PORT_LOCAL=localhost:5050 \ - HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ - test \ - | egrep -v "$XCODEBUILD_FILTER" \ - | egrep -v '^$' \ - | egrep -v "(GPBDictionary|GPBArray)" - - -echo "TIME: $(date)" -xcodebuild \ - -workspace Tests.xcworkspace \ - -scheme CronetTests \ - -destination name="iPhone 8" \ - HOST_PORT_LOCALSSL=localhost:5051 \ - HOST_PORT_LOCAL=localhost:5050 \ - HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ - test \ - | egrep -v "$XCODEBUILD_FILTER" \ - | egrep -v '^$' \ - | egrep -v "(GPBDictionary|GPBArray)" - - -echo "TIME: $(date)" -xcodebuild \ - -workspace Tests.xcworkspace \ - -scheme MacTests \ - -destination platform=macOS \ - HOST_PORT_LOCALSSL=localhost:5051 \ - HOST_PORT_LOCAL=localhost:5050 \ - HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ - test \ - | egrep -v "$XCODEBUILD_FILTER" \ - | egrep -v '^$' \ - | egrep -v "(GPBDictionary|GPBArray)" - - -exit 0 diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index c0b87d38087..95c3d8ed1dd 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1069,6 +1069,7 @@ class ObjCLanguage(object): 'EXAMPLE_PATH': 'src/objective-c/examples/Sample', 'FRAMEWORKS': 'NO' })) + # Currently not supporting compiling as frameworks in Bazel out.append( self.config.job_spec( ['src/objective-c/tests/build_one_example.sh'], @@ -1126,6 +1127,7 @@ class ObjCLanguage(object): shortname='ios-test-cfstream-tests', cpu_cost=1e6, environ=_FORCE_ENVIRON_FOR_WRAPPERS)) + # TODO: replace with run_one_test_bazel.sh when Bazel is stable out.append( self.config.job_spec( ['src/objective-c/tests/run_one_test.sh'], From ae99e81e40c2676b96dc7fc64069f2b2f0229ed6 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 13 Aug 2019 13:32:00 -0700 Subject: [PATCH 1231/1555] Move kGRPCErrorDomain to interface rather than Core implementation --- src/objective-c/GRPCClient/GRPCCall.m | 2 ++ src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 26f42032537..73ee530ef2c 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -27,6 +27,8 @@ NSString *const kGRPCHeadersKey = @"io.grpc.HeadersKey"; NSString *const kGRPCTrailersKey = @"io.grpc.TrailersKey"; +NSString *const kGRPCErrorDomain = @"io.grpc"; + /** * The response dispatcher creates its own serial dispatch queue and target the queue to the * dispatch queue of a user provided response handler. It removes the requirement of having to use diff --git a/src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m b/src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m index 3eefed88d63..a1441221b15 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m @@ -19,8 +19,7 @@ #import "NSError+GRPC.h" #include - -NSString *const kGRPCErrorDomain = @"io.grpc"; +#import @implementation NSError (GRPC) + (instancetype)grpc_errorFromStatusCode:(grpc_status_code)statusCode From e82886db208ac20c6ab464d26b3ebe4ff852214c Mon Sep 17 00:00:00 2001 From: ZHANG Dapeng Date: Tue, 13 Aug 2019 14:22:22 -0700 Subject: [PATCH 1232/1555] Update client_matrix.py for java releases --- tools/interop_matrix/client_matrix.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index 585734283a7..a0401898699 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -161,7 +161,7 @@ LANG_RELEASE_MATRIX = { ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.6.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.7.0', + ('v1.7.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.8.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), @@ -171,24 +171,26 @@ LANG_RELEASE_MATRIX = { ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.11.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.12.0', + ('v1.12.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.13.1', + ('v1.13.2', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.14.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.15.0', + ('v1.15.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.16.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.17.1', + ('v1.17.2', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.18.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.19.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.20.0', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.21.0', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.21.1', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.22.2', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.23.0', ReleaseInfo(runtimes=['java_oracle8'])), ]), 'python': OrderedDict([ From 313b7c593ae050e9d900640525edc1a5a0d78977 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 13 Aug 2019 14:42:48 -0700 Subject: [PATCH 1233/1555] Backport #19924 to v1.23.x --- .../chttp2/transport/chttp2_transport.cc | 54 +++++++++++++------ .../transport/chttp2/transport/frame_ping.cc | 1 + .../chttp2/transport/frame_rst_stream.cc | 8 +++ .../chttp2/transport/frame_rst_stream.h | 7 +++ .../chttp2/transport/frame_settings.cc | 1 + .../chttp2/transport/hpack_parser.cc | 5 +- .../ext/transport/chttp2/transport/internal.h | 7 +++ .../ext/transport/chttp2/transport/parsing.cc | 14 +++-- .../ext/transport/chttp2/transport/writing.cc | 1 + 9 files changed, 71 insertions(+), 27 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 16146569886..8e81e0a5c2b 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -74,6 +74,8 @@ #define DEFAULT_MAX_PINGS_BETWEEN_DATA 2 #define DEFAULT_MAX_PING_STRIKES 2 +#define DEFAULT_MAX_PENDING_INDUCED_FRAMES 10000 + static int g_default_client_keepalive_time_ms = DEFAULT_CLIENT_KEEPALIVE_TIME_MS; static int g_default_client_keepalive_timeout_ms = @@ -105,6 +107,7 @@ static void write_action(void* t, grpc_error* error); static void write_action_end_locked(void* t, grpc_error* error); static void read_action_locked(void* t, grpc_error* error); +static void continue_read_action_locked(grpc_chttp2_transport* t); static void complete_fetch_locked(void* gs, grpc_error* error); /** Set a transport level setting, and push it to our peer */ @@ -797,10 +800,8 @@ grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_chttp2_transport* t, !grpc_resource_user_safe_alloc(t->resource_user, GRPC_RESOURCE_QUOTA_CALL_SIZE)) { gpr_log(GPR_ERROR, "Memory exhausted, rejecting the stream."); - grpc_slice_buffer_add( - &t->qbuf, - grpc_chttp2_rst_stream_create( - id, static_cast(GRPC_HTTP2_REFUSED_STREAM), nullptr)); + grpc_chttp2_add_rst_stream_to_next_write(t, id, GRPC_HTTP2_REFUSED_STREAM, + nullptr); grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_RST_STREAM); return nullptr; } @@ -1045,6 +1046,19 @@ static void write_action_begin_locked(void* gt, grpc_error* error_ignored) { GRPC_CLOSURE_SCHED( GRPC_CLOSURE_INIT(&t->write_action, write_action, t, scheduler), GRPC_ERROR_NONE); + if (t->reading_paused_on_pending_induced_frames) { + GPR_ASSERT(t->num_pending_induced_frames == 0); + /* We had paused reading, because we had many induced frames (SETTINGS + * ACK, PINGS ACK and RST_STREAMS) pending in t->qbuf. Now that we have + * been able to flush qbuf, we can resume reading. */ + GRPC_CHTTP2_IF_TRACING(gpr_log( + GPR_INFO, + "transport %p : Resuming reading after being paused due to too " + "many unwritten SETTINGS ACK, PINGS ACK and RST_STREAM frames", + t)); + t->reading_paused_on_pending_induced_frames = false; + continue_read_action_locked(t); + } } else { GRPC_STATS_INC_HTTP2_SPURIOUS_WRITES_BEGUN(); set_write_state(t, GRPC_CHTTP2_WRITE_STATE_IDLE, "begin writing nothing"); @@ -1114,7 +1128,6 @@ static void write_action_end_locked(void* tp, grpc_error* error) { } grpc_chttp2_end_write(t, GRPC_ERROR_REF(error)); - GRPC_CHTTP2_UNREF_TRANSPORT(t, "writing"); } @@ -2113,10 +2126,8 @@ void grpc_chttp2_cancel_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s, grpc_http2_error_code http_error; grpc_error_get_status(due_to_error, s->deadline, nullptr, nullptr, &http_error, nullptr); - grpc_slice_buffer_add( - &t->qbuf, - grpc_chttp2_rst_stream_create( - s->id, static_cast(http_error), &s->stats.outgoing)); + grpc_chttp2_add_rst_stream_to_next_write( + t, s->id, static_cast(http_error), &s->stats.outgoing); grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_RST_STREAM); } } @@ -2427,9 +2438,8 @@ static void close_from_api(grpc_chttp2_transport* t, grpc_chttp2_stream* s, grpc_slice_buffer_add(&t->qbuf, status_hdr); grpc_slice_buffer_add(&t->qbuf, message_pfx); grpc_slice_buffer_add(&t->qbuf, grpc_slice_ref_internal(slice)); - grpc_slice_buffer_add( - &t->qbuf, grpc_chttp2_rst_stream_create(s->id, GRPC_HTTP2_NO_ERROR, - &s->stats.outgoing)); + grpc_chttp2_add_rst_stream_to_next_write(t, s->id, GRPC_HTTP2_NO_ERROR, + &s->stats.outgoing); grpc_chttp2_mark_stream_closed(t, s, 1, 1, error); grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_CLOSE_FROM_API); @@ -2600,10 +2610,16 @@ static void read_action_locked(void* tp, grpc_error* error) { grpc_slice_buffer_reset_and_unref_internal(&t->read_buffer); if (keep_reading) { - const bool urgent = t->goaway_error != GRPC_ERROR_NONE; - grpc_endpoint_read(t->ep, &t->read_buffer, &t->read_action_locked, urgent); - grpc_chttp2_act_on_flowctl_action(t->flow_control->MakeAction(), t, - nullptr); + if (t->num_pending_induced_frames >= DEFAULT_MAX_PENDING_INDUCED_FRAMES) { + t->reading_paused_on_pending_induced_frames = true; + GRPC_CHTTP2_IF_TRACING( + gpr_log(GPR_INFO, + "transport %p : Pausing reading due to too " + "many unwritten SETTINGS ACK and RST_STREAM frames", + t)); + } else { + continue_read_action_locked(t); + } GRPC_CHTTP2_UNREF_TRANSPORT(t, "keep_reading"); } else { GRPC_CHTTP2_UNREF_TRANSPORT(t, "reading_action"); @@ -2612,6 +2628,12 @@ static void read_action_locked(void* tp, grpc_error* error) { GRPC_ERROR_UNREF(error); } +static void continue_read_action_locked(grpc_chttp2_transport* t) { + const bool urgent = t->goaway_error != GRPC_ERROR_NONE; + grpc_endpoint_read(t->ep, &t->read_buffer, &t->read_action_locked, urgent); + grpc_chttp2_act_on_flowctl_action(t->flow_control->MakeAction(), t, nullptr); +} + // t is reffed prior to calling the first time, and once the callback chain // that kicks off finishes, it's unreffed static void schedule_bdp_ping_locked(grpc_chttp2_transport* t) { diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.cc b/src/core/ext/transport/chttp2/transport/frame_ping.cc index 9a56bf093f4..87c92dffc38 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.cc +++ b/src/core/ext/transport/chttp2/transport/frame_ping.cc @@ -118,6 +118,7 @@ grpc_error* grpc_chttp2_ping_parser_parse(void* parser, t->ping_acks = static_cast(gpr_realloc( t->ping_acks, t->ping_ack_capacity * sizeof(*t->ping_acks))); } + t->num_pending_induced_frames++; t->ping_acks[t->ping_ack_count++] = p->opaque_8bytes; grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_PING_RESPONSE); } diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc b/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc index cda09c3dea1..1350a967b9f 100644 --- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc @@ -58,6 +58,14 @@ grpc_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code, return slice; } +void grpc_chttp2_add_rst_stream_to_next_write( + grpc_chttp2_transport* t, uint32_t id, uint32_t code, + grpc_transport_one_way_stats* stats) { + t->num_pending_induced_frames++; + grpc_slice_buffer_add(&t->qbuf, + grpc_chttp2_rst_stream_create(id, code, stats)); +} + grpc_error* grpc_chttp2_rst_stream_parser_begin_frame( grpc_chttp2_rst_stream_parser* parser, uint32_t length, uint8_t flags) { if (length != 4) { diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h index 64707666181..d61e62394a4 100644 --- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h @@ -33,6 +33,13 @@ typedef struct { grpc_slice grpc_chttp2_rst_stream_create(uint32_t stream_id, uint32_t code, grpc_transport_one_way_stats* stats); +// Adds RST_STREAM frame to t->qbuf (buffer for the next write). Should be +// called when we want to add RST_STREAM and we are not in +// write_action_begin_locked. +void grpc_chttp2_add_rst_stream_to_next_write( + grpc_chttp2_transport* t, uint32_t id, uint32_t code, + grpc_transport_one_way_stats* stats); + grpc_error* grpc_chttp2_rst_stream_parser_begin_frame( grpc_chttp2_rst_stream_parser* parser, uint32_t length, uint8_t flags); grpc_error* grpc_chttp2_rst_stream_parser_parse(void* parser, diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.cc b/src/core/ext/transport/chttp2/transport/frame_settings.cc index 3f84679ec31..ba57afa74b9 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.cc +++ b/src/core/ext/transport/chttp2/transport/frame_settings.cc @@ -132,6 +132,7 @@ grpc_error* grpc_chttp2_settings_parser_parse(void* p, grpc_chttp2_transport* t, if (is_last) { memcpy(parser->target_settings, parser->incoming_settings, GRPC_CHTTP2_NUM_SETTINGS * sizeof(uint32_t)); + t->num_pending_induced_frames++; grpc_slice_buffer_add(&t->qbuf, grpc_chttp2_settings_ack_create()); if (t->notify_on_receive_settings != nullptr) { GRPC_CLOSURE_SCHED(t->notify_on_receive_settings, diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index 724c6c1bffc..22c0962cd49 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -1668,9 +1668,8 @@ static void force_client_rst_stream(void* sp, grpc_error* error) { grpc_chttp2_stream* s = static_cast(sp); grpc_chttp2_transport* t = s->t; if (!s->write_closed) { - grpc_slice_buffer_add( - &t->qbuf, grpc_chttp2_rst_stream_create(s->id, GRPC_HTTP2_NO_ERROR, - &s->stats.outgoing)); + grpc_chttp2_add_rst_stream_to_next_write(t, s->id, GRPC_HTTP2_NO_ERROR, + &s->stats.outgoing); grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_FORCE_RST_STREAM); grpc_chttp2_mark_stream_closed(t, s, true, true, GRPC_ERROR_NONE); } diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 643cd25b8bd..e6fc3b599e0 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -493,6 +493,13 @@ struct grpc_chttp2_transport { grpc_core::ContextList* cl = nullptr; grpc_core::RefCountedPtr channelz_socket; uint32_t num_messages_in_next_write = 0; + /** The number of pending induced frames (SETTINGS_ACK, PINGS_ACK and + * RST_STREAM) in the outgoing buffer (t->qbuf). If this number goes beyond + * DEFAULT_MAX_PENDING_INDUCED_FRAMES, we pause reading new frames. We would + * only continue reading when we are able to write to the socket again, + * thereby reducing the number of induced frames. */ + uint32_t num_pending_induced_frames = 0; + bool reading_paused_on_pending_induced_frames = false; }; typedef enum { diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index 4e6ff60caf8..119a5941d38 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -382,10 +382,9 @@ error_handler: if (s != nullptr) { grpc_chttp2_mark_stream_closed(t, s, true, false, err); } - grpc_slice_buffer_add( - &t->qbuf, grpc_chttp2_rst_stream_create(t->incoming_stream_id, - GRPC_HTTP2_PROTOCOL_ERROR, - &s->stats.outgoing)); + grpc_chttp2_add_rst_stream_to_next_write(t, t->incoming_stream_id, + GRPC_HTTP2_PROTOCOL_ERROR, + &s->stats.outgoing); return init_skip_frame_parser(t, 0); } else { return err; @@ -765,10 +764,9 @@ static grpc_error* parse_frame_slice(grpc_chttp2_transport* t, grpc_chttp2_parsing_become_skip_parser(t); if (s) { s->forced_close_error = err; - grpc_slice_buffer_add( - &t->qbuf, grpc_chttp2_rst_stream_create(t->incoming_stream_id, - GRPC_HTTP2_PROTOCOL_ERROR, - &s->stats.outgoing)); + grpc_chttp2_add_rst_stream_to_next_write(t, t->incoming_stream_id, + GRPC_HTTP2_PROTOCOL_ERROR, + &s->stats.outgoing); } else { GRPC_ERROR_UNREF(err); } diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc index f3cb390dc7a..d6d9e4521f6 100644 --- a/src/core/ext/transport/chttp2/transport/writing.cc +++ b/src/core/ext/transport/chttp2/transport/writing.cc @@ -219,6 +219,7 @@ class WriteContext { void FlushQueuedBuffers() { /* simple writes are queued to qbuf, and flushed here */ grpc_slice_buffer_move_into(&t_->qbuf, &t_->outbuf); + t_->num_pending_induced_frames = 0; GPR_ASSERT(t_->qbuf.count == 0); } From de6d4978e0aeffcc89127d587ed9f38da052ad11 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Tue, 13 Aug 2019 15:47:19 -0700 Subject: [PATCH 1234/1555] Merge test_objc_grpc_library into local_... with a testing BOOL flag --- .../grpc_objc_internal_library.bzl | 66 +++---------------- src/objective-c/tests/BUILD | 7 +- 2 files changed, 12 insertions(+), 61 deletions(-) diff --git a/src/objective-c/grpc_objc_internal_library.bzl b/src/objective-c/grpc_objc_internal_library.bzl index b043a0f6880..51206c1e903 100644 --- a/src/objective-c/grpc_objc_internal_library.bzl +++ b/src/objective-c/grpc_objc_internal_library.bzl @@ -73,7 +73,7 @@ def grpc_objc_testing_library( deps = deps + additional_deps, ) -def local_objc_grpc_library(name, deps, srcs = [], use_well_known_protos = False, **kwargs): +def local_objc_grpc_library(name, deps, testing = True, srcs = [], use_well_known_protos = False, **kwargs): """!!For local targets within the gRPC repository only!! Will not work outside of the repo """ objc_grpc_library_name = "_" + name + "_objc_grpc_library" @@ -104,55 +104,11 @@ def local_objc_grpc_library(name, deps, srcs = [], use_well_known_protos = False ) arc_srcs = [":" + objc_grpc_library_name + "_srcs"] - native.objc_library( - name = name, - hdrs = [":" + objc_grpc_library_name + "_hdrs"], - non_arc_srcs = [":" + objc_grpc_library_name + "_non_arc_srcs"], - srcs = arc_srcs, - defines = [ - "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0", - "GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO=0", - ], - includes = [ - "_generated_protos", - "src/objective-c", - ], - deps = [ - "//src/objective-c:proto_objc_rpc", - "@com_google_protobuf//:protobuf_objc", - ], - ) - -def testing_objc_grpc_library(name, deps, srcs = [], use_well_known_protos = False, **kwargs): - """!!For testing within the gRPC repository only!! Will not work outside of the repo - """ - objc_grpc_library_name = "_" + name + "_objc_grpc_library" - - generate_objc( - name = objc_grpc_library_name, - srcs = srcs, - deps = deps, - use_well_known_protos = use_well_known_protos, - **kwargs - ) - - generate_objc_hdrs( - name = objc_grpc_library_name + "_hdrs", - src = ":" + objc_grpc_library_name, - ) - - generate_objc_non_arc_srcs( - name = objc_grpc_library_name + "_non_arc_srcs", - src = ":" + objc_grpc_library_name, - ) - - arc_srcs = None - if len(srcs) > 0: - generate_objc_srcs( - name = objc_grpc_library_name + "_srcs", - src = ":" + objc_grpc_library_name, - ) - arc_srcs = [":" + objc_grpc_library_name + "_srcs"] + library_deps = ["@com_google_protobuf//:protobuf_objc"] + if testing: + library_deps += ["//src/objective-c:grpc_objc_client_internal_testing"] + else: + library_deps += ["//src/objective-c:proto_objc_rpc"] native.objc_library( name = name, @@ -163,12 +119,6 @@ def testing_objc_grpc_library(name, deps, srcs = [], use_well_known_protos = Fal "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0", "GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO=0", ], - includes = [ - "_generated_protos", - "src/objective-c", - ], - deps = [ - "//src/objective-c:grpc_objc_client_internal_testing", - "@com_google_protobuf//:protobuf_objc", - ], + includes = ["_generated_protos"], + deps = library_deps, ) diff --git a/src/objective-c/tests/BUILD b/src/objective-c/tests/BUILD index 5d8042ca20a..80c12fba548 100644 --- a/src/objective-c/tests/BUILD +++ b/src/objective-c/tests/BUILD @@ -21,7 +21,7 @@ package(default_visibility = ["//visibility:private"]) load( "//src/objective-c:grpc_objc_internal_library.bzl", "grpc_objc_testing_library", - "testing_objc_grpc_library" + "local_objc_grpc_library" ) load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle") load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application", "ios_unit_test") @@ -41,10 +41,11 @@ proto_library( deps = [":messages_proto"], ) -testing_objc_grpc_library( +local_objc_grpc_library( name = "RemoteTest", srcs = ["RemoteTestClient/test.proto"], use_well_known_protos = True, + testing = True, deps = [":test_proto"], ) @@ -232,4 +233,4 @@ tvos_unit_test( ":InteropTestsLocalCleartext-lib", ], test_host = ":tvos-host", -) \ No newline at end of file +) From 08422e7e9a118916bce0601986777ff1cffcba84 Mon Sep 17 00:00:00 2001 From: "Penn (Dapeng) Zhang" Date: Tue, 13 Aug 2019 16:06:21 -0700 Subject: [PATCH 1235/1555] upload images --- tools/interop_matrix/client_matrix.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index a0401898699..6bcac56f149 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -162,7 +162,7 @@ LANG_RELEASE_MATRIX = { ('v1.6.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.7.1', - ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ReleaseInfo(testcases_file='java__v1.0.3')), ('v1.8.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.9.1', @@ -172,25 +172,25 @@ LANG_RELEASE_MATRIX = { ('v1.11.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.12.1', - ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ReleaseInfo(testcases_file='java__v1.0.3')), ('v1.13.2', - ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ReleaseInfo(testcases_file='java__v1.0.3')), ('v1.14.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.15.1', - ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ReleaseInfo(testcases_file='java__v1.0.3')), ('v1.16.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.17.2', - ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), + ReleaseInfo(testcases_file='java__v1.0.3')), ('v1.18.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.19.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.20.0', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.21.1', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.22.2', ReleaseInfo(runtimes=['java_oracle8'])), - ('v1.23.0', ReleaseInfo(runtimes=['java_oracle8'])), + ('v1.21.1', ReleaseInfo()), + ('v1.22.2', ReleaseInfo()), + ('v1.23.0', ReleaseInfo()), ]), 'python': OrderedDict([ From 40584c792255e88a99607808cbd2e159eb11368f Mon Sep 17 00:00:00 2001 From: "Penn (Dapeng) Zhang" Date: Tue, 13 Aug 2019 16:53:29 -0700 Subject: [PATCH 1236/1555] fix format --- tools/interop_matrix/client_matrix.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index 6bcac56f149..4c21b7aafce 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -161,8 +161,7 @@ LANG_RELEASE_MATRIX = { ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.6.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.7.1', - ReleaseInfo(testcases_file='java__v1.0.3')), + ('v1.7.1', ReleaseInfo(testcases_file='java__v1.0.3')), ('v1.8.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.9.1', @@ -171,18 +170,14 @@ LANG_RELEASE_MATRIX = { ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.11.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.12.1', - ReleaseInfo(testcases_file='java__v1.0.3')), - ('v1.13.2', - ReleaseInfo(testcases_file='java__v1.0.3')), + ('v1.12.1', ReleaseInfo(testcases_file='java__v1.0.3')), + ('v1.13.2', ReleaseInfo(testcases_file='java__v1.0.3')), ('v1.14.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.15.1', - ReleaseInfo(testcases_file='java__v1.0.3')), + ('v1.15.1', ReleaseInfo(testcases_file='java__v1.0.3')), ('v1.16.1', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), - ('v1.17.2', - ReleaseInfo(testcases_file='java__v1.0.3')), + ('v1.17.2', ReleaseInfo(testcases_file='java__v1.0.3')), ('v1.18.0', ReleaseInfo(runtimes=['java_oracle8'], testcases_file='java__v1.0.3')), ('v1.19.0', From d33d30a595ddbe84f41fa8e3ef9755678f4cf8d5 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Wed, 14 Aug 2019 09:20:57 +0800 Subject: [PATCH 1237/1555] update notes --- examples/python/easy_start_demo/PyClient.py | 6 +++--- examples/python/easy_start_demo/PyServer.py | 6 +++--- examples/python/easy_start_demo/README.md | 6 +++--- examples/python/easy_start_demo/demo.proto | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/python/easy_start_demo/PyClient.py b/examples/python/easy_start_demo/PyClient.py index 257c817e06f..383cdb5afed 100644 --- a/examples/python/easy_start_demo/PyClient.py +++ b/examples/python/easy_start_demo/PyClient.py @@ -15,7 +15,7 @@ ClientId = 1 # 简单模式 -# Unary +# Simple def simple_method(stub): print("--------------Call SimpleMethod Begin--------------") req = demo_pb2.Request(Cid=ClientId, ReqMsg="called by Python client") @@ -25,7 +25,7 @@ def simple_method(stub): # 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) -# Client Streaming (In a single call, the client can transfer data to the server several times, +# Request-streaming (In a single call, the client can transfer data to the server several times, # but the server can only return a response once.) def c_stream_method(stub): print("--------------Call CStreamMethod Begin--------------") @@ -43,7 +43,7 @@ def c_stream_method(stub): # 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) -# Server Streaming (In a single call, the client can only transmit data to the server at one time, +# Response-streaming (In a single call, the client can only transmit data to the server at one time, # but the server can return the response many times.) def s_stream_method(stub): print("--------------Call SStreamMethod Begin--------------") diff --git a/examples/python/easy_start_demo/PyServer.py b/examples/python/easy_start_demo/PyServer.py index a814205d0d1..cfef6bf516a 100644 --- a/examples/python/easy_start_demo/PyServer.py +++ b/examples/python/easy_start_demo/PyServer.py @@ -20,14 +20,14 @@ ServerId = 1 class DemoServer(demo_pb2_grpc.GRPCDemoServicer): # 简单模式 - # Unary + # Simple def SimpleMethod(self, request, context): print(f"SimpleMethod called by client({request.Cid}) the message: {request.ReqMsg}") resp = demo_pb2.Response(Sid=ServerId, RespMsg="Python server SimpleMethod Ok!!!!") return resp # 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) - # Client Streaming (In a single call, the client can transfer data to the server several times, + # Request-streaming (In a single call, the client can transfer data to the server several times, # but the server can only return a response once.) def CStreamMethod(self, request_iterator, context): print("CStreamMethod called by client...") @@ -37,7 +37,7 @@ class DemoServer(demo_pb2_grpc.GRPCDemoServicer): return resp # 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) - # Server Streaming (In a single call, the client can only transmit data to the server at one time, + # Response-streaming (In a single call, the client can only transmit data to the server at one time, # but the server can return the response many times.) def SStreamMethod(self, request, context): print(f"SStreamMethod called by client({request.Cid}), message={request.ReqMsg}") diff --git a/examples/python/easy_start_demo/README.md b/examples/python/easy_start_demo/README.md index 2bb9059bc90..5b8ee8c5b3e 100644 --- a/examples/python/easy_start_demo/README.md +++ b/examples/python/easy_start_demo/README.md @@ -2,18 +2,18 @@ ###主要是介绍了在Python中使用GRPC时, 进行数据传输的四种方式。 ###This paper mainly introduces four ways of data transmission when GRPC is used in Python. -- ####简单模式 (Unary) +- ####简单模式 (Simple) ```text 没啥好说的,跟调普通方法没差 There's nothing to say. It's no different from the usual way. ``` -- ####客户端流模式 (Client Streaming) +- ####客户端流模式 (Request-streaming) ```text 在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应. In a single call, the client can transfer data to the server several times, but the server can only return a response once. ``` -- ####服务端流模式 (Server Streaming) +- ####服务端流模式 (Response-streaming) ```text 在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应 In a single call, the client can only transmit data to the server at one time, diff --git a/examples/python/easy_start_demo/demo.proto b/examples/python/easy_start_demo/demo.proto index 4fb76bce752..a9506cf92a1 100644 --- a/examples/python/easy_start_demo/demo.proto +++ b/examples/python/easy_start_demo/demo.proto @@ -30,21 +30,21 @@ message Response { // `service` is used to define methods for GRPC services in a fixed format, similar to defining an interface in Golang service GRPCDemo { // 简单模式 - // Unary + // Simple rpc SimpleMethod (Request) returns (Response); // 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) - // Client Streaming (In a single call, the client can transfer data to the server several times, + // Request-streaming (In a single call, the client can transfer data to the server several times, // but the server can only return a response once.) rpc CStreamMethod (stream Request) returns (Response); // 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) - // Server Streaming (In a single call, the client can only transmit data to the server at one time, + // Response-streaming (In a single call, the client can only transmit data to the server at one time, // but the server can return the response many times.) rpc SStreamMethod (Request) returns (stream Response); // 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) - // Bidirectional Streaming (In a single call, both client and server can send and receive data + // Bidirectional streaming (In a single call, both client and server can send and receive data // to each other multiple times.) rpc TWFMethod (stream Request) returns (stream Response); } From 6eb8adf91d05ee19592fc12b8a9e2da8f4c90628 Mon Sep 17 00:00:00 2001 From: Doug Fawley Date: Wed, 14 Aug 2019 09:16:35 -0700 Subject: [PATCH 1238/1555] Add v1.21.3 and v1.22.2 releases of grpc-go to interop matrix --- tools/interop_matrix/client_matrix.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index 51a47d92f97..1d15de1fdf1 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -142,8 +142,8 @@ LANG_RELEASE_MATRIX = { ('v1.19.0', ReleaseInfo(runtimes=['go1.11'], testcases_file='go__v1.0.5')), ('v1.20.0', ReleaseInfo(runtimes=['go1.11'])), - ('v1.21.2', ReleaseInfo(runtimes=['go1.11'])), - ('v1.22.1', ReleaseInfo(runtimes=['go1.11'])), + ('v1.21.3', ReleaseInfo(runtimes=['go1.11'])), + ('v1.22.2', ReleaseInfo(runtimes=['go1.11'])), ]), 'java': OrderedDict([ From 15f8ae71ddbc60330069d642beda63150c051cae Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 14 Aug 2019 09:30:26 -0700 Subject: [PATCH 1239/1555] Change cc to c++ --- CMakeLists.txt | 178 ++++++------- Makefile | 235 ++++++++++-------- build.yaml | 44 ++-- .../generated/sources_and_headers.json | 78 +++--- 4 files changed, 287 insertions(+), 248 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 678ad9bdbb9..8e1cdd3fc5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -238,13 +238,13 @@ add_custom_target(tools_c grpc_create_jwt grpc_print_google_default_creds_token grpc_verify_jwt - gen_hpack_tables - gen_legal_metadata_characters - gen_percent_encoding_tables ) add_custom_target(tools_cxx DEPENDS + gen_hpack_tables + gen_legal_metadata_characters + gen_percent_encoding_tables ) add_custom_target(tools @@ -14046,6 +14046,95 @@ target_link_libraries(filter_end2end_test endif (gRPC_BUILD_TESTS) + +add_executable(gen_hpack_tables + tools/codegen/core/gen_hpack_tables.cc +) + + +target_include_directories(gen_hpack_tables + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(gen_hpack_tables + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + gpr + grpc +) + + + +add_executable(gen_legal_metadata_characters + tools/codegen/core/gen_legal_metadata_characters.cc +) + + +target_include_directories(gen_legal_metadata_characters + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(gen_legal_metadata_characters + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} +) + + + +add_executable(gen_percent_encoding_tables + tools/codegen/core/gen_percent_encoding_tables.cc +) + + +target_include_directories(gen_percent_encoding_tables + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(gen_percent_encoding_tables + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} +) + + if (gRPC_BUILD_TESTS) add_executable(generic_end2end_test @@ -17803,89 +17892,6 @@ target_link_libraries(public_headers_must_be_c89 endif (gRPC_BUILD_TESTS) - -add_executable(gen_hpack_tables - tools/codegen/core/gen_hpack_tables.cc -) - - -target_include_directories(gen_hpack_tables - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_UPB_GENERATED_DIR} - PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} - PRIVATE ${_gRPC_UPB_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} -) - -target_link_libraries(gen_hpack_tables - ${_gRPC_ALLTARGETS_LIBRARIES} - gpr - grpc -) - - - -add_executable(gen_legal_metadata_characters - tools/codegen/core/gen_legal_metadata_characters.cc -) - - -target_include_directories(gen_legal_metadata_characters - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_UPB_GENERATED_DIR} - PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} - PRIVATE ${_gRPC_UPB_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} -) - -target_link_libraries(gen_legal_metadata_characters - ${_gRPC_ALLTARGETS_LIBRARIES} -) - - - -add_executable(gen_percent_encoding_tables - tools/codegen/core/gen_percent_encoding_tables.cc -) - - -target_include_directories(gen_percent_encoding_tables - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_UPB_GENERATED_DIR} - PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} - PRIVATE ${_gRPC_UPB_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} -) - -target_link_libraries(gen_percent_encoding_tables - ${_gRPC_ALLTARGETS_LIBRARIES} -) - - if (gRPC_BUILD_TESTS) add_executable(bad_streaming_id_bad_client_test diff --git a/Makefile b/Makefile index 66c4f4489ed..8080efcc41a 100644 --- a/Makefile +++ b/Makefile @@ -1206,6 +1206,9 @@ end2end_test: $(BINDIR)/$(CONFIG)/end2end_test error_details_test: $(BINDIR)/$(CONFIG)/error_details_test exception_test: $(BINDIR)/$(CONFIG)/exception_test filter_end2end_test: $(BINDIR)/$(CONFIG)/filter_end2end_test +gen_hpack_tables: $(BINDIR)/$(CONFIG)/gen_hpack_tables +gen_legal_metadata_characters: $(BINDIR)/$(CONFIG)/gen_legal_metadata_characters +gen_percent_encoding_tables: $(BINDIR)/$(CONFIG)/gen_percent_encoding_tables generic_end2end_test: $(BINDIR)/$(CONFIG)/generic_end2end_test global_config_env_test: $(BINDIR)/$(CONFIG)/global_config_env_test global_config_test: $(BINDIR)/$(CONFIG)/global_config_test @@ -1289,9 +1292,6 @@ transport_security_common_api_test: $(BINDIR)/$(CONFIG)/transport_security_commo writes_per_rpc_test: $(BINDIR)/$(CONFIG)/writes_per_rpc_test xds_end2end_test: $(BINDIR)/$(CONFIG)/xds_end2end_test public_headers_must_be_c89: $(BINDIR)/$(CONFIG)/public_headers_must_be_c89 -gen_hpack_tables: $(BINDIR)/$(CONFIG)/gen_hpack_tables -gen_legal_metadata_characters: $(BINDIR)/$(CONFIG)/gen_legal_metadata_characters -gen_percent_encoding_tables: $(BINDIR)/$(CONFIG)/gen_percent_encoding_tables boringssl_ssl_test: $(BINDIR)/$(CONFIG)/boringssl_ssl_test boringssl_crypto_test: $(BINDIR)/$(CONFIG)/boringssl_crypto_test bad_streaming_id_bad_client_test: $(BINDIR)/$(CONFIG)/bad_streaming_id_bad_client_test @@ -2530,9 +2530,9 @@ test_python: static_c tools: tools_c tools_cxx -tools_c: privatelibs_c $(BINDIR)/$(CONFIG)/check_epollexclusive $(BINDIR)/$(CONFIG)/grpc_create_jwt $(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token $(BINDIR)/$(CONFIG)/grpc_verify_jwt $(BINDIR)/$(CONFIG)/gen_hpack_tables $(BINDIR)/$(CONFIG)/gen_legal_metadata_characters $(BINDIR)/$(CONFIG)/gen_percent_encoding_tables +tools_c: privatelibs_c $(BINDIR)/$(CONFIG)/check_epollexclusive $(BINDIR)/$(CONFIG)/grpc_create_jwt $(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token $(BINDIR)/$(CONFIG)/grpc_verify_jwt -tools_cxx: privatelibs_cxx +tools_cxx: privatelibs_cxx $(BINDIR)/$(CONFIG)/gen_hpack_tables $(BINDIR)/$(CONFIG)/gen_legal_metadata_characters $(BINDIR)/$(CONFIG)/gen_percent_encoding_tables buildbenchmarks: privatelibs $(BINDIR)/$(CONFIG)/low_level_ping_pong_benchmark @@ -16341,6 +16341,135 @@ endif endif +GEN_HPACK_TABLES_SRC = \ + tools/codegen/core/gen_hpack_tables.cc \ + +GEN_HPACK_TABLES_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GEN_HPACK_TABLES_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/gen_hpack_tables: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/gen_hpack_tables: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/gen_hpack_tables: $(PROTOBUF_DEP) $(GEN_HPACK_TABLES_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(GEN_HPACK_TABLES_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gen_hpack_tables + +endif + +endif + +$(OBJDIR)/$(CONFIG)/tools/codegen/core/gen_hpack_tables.o: $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a + +deps_gen_hpack_tables: $(GEN_HPACK_TABLES_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(GEN_HPACK_TABLES_OBJS:.o=.dep) +endif +endif + + +GEN_LEGAL_METADATA_CHARACTERS_SRC = \ + tools/codegen/core/gen_legal_metadata_characters.cc \ + +GEN_LEGAL_METADATA_CHARACTERS_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GEN_LEGAL_METADATA_CHARACTERS_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/gen_legal_metadata_characters: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/gen_legal_metadata_characters: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/gen_legal_metadata_characters: $(PROTOBUF_DEP) $(GEN_LEGAL_METADATA_CHARACTERS_OBJS) + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(GEN_LEGAL_METADATA_CHARACTERS_OBJS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gen_legal_metadata_characters + +endif + +endif + +$(OBJDIR)/$(CONFIG)/tools/codegen/core/gen_legal_metadata_characters.o: + +deps_gen_legal_metadata_characters: $(GEN_LEGAL_METADATA_CHARACTERS_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(GEN_LEGAL_METADATA_CHARACTERS_OBJS:.o=.dep) +endif +endif + + +GEN_PERCENT_ENCODING_TABLES_SRC = \ + tools/codegen/core/gen_percent_encoding_tables.cc \ + +GEN_PERCENT_ENCODING_TABLES_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GEN_PERCENT_ENCODING_TABLES_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/gen_percent_encoding_tables: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/gen_percent_encoding_tables: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/gen_percent_encoding_tables: $(PROTOBUF_DEP) $(GEN_PERCENT_ENCODING_TABLES_OBJS) + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(GEN_PERCENT_ENCODING_TABLES_OBJS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gen_percent_encoding_tables + +endif + +endif + +$(OBJDIR)/$(CONFIG)/tools/codegen/core/gen_percent_encoding_tables.o: + +deps_gen_percent_encoding_tables: $(GEN_PERCENT_ENCODING_TABLES_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(GEN_PERCENT_ENCODING_TABLES_OBJS:.o=.dep) +endif +endif + + GENERIC_END2END_TEST_SRC = \ test/cpp/end2end/generic_end2end_test.cc \ @@ -19893,102 +20022,6 @@ endif endif -GEN_HPACK_TABLES_SRC = \ - tools/codegen/core/gen_hpack_tables.cc \ - -GEN_HPACK_TABLES_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GEN_HPACK_TABLES_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/gen_hpack_tables: openssl_dep_error - -else - - - -$(BINDIR)/$(CONFIG)/gen_hpack_tables: $(GEN_HPACK_TABLES_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GEN_HPACK_TABLES_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gen_hpack_tables - -endif - -$(OBJDIR)/$(CONFIG)/tools/codegen/core/gen_hpack_tables.o: $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a - -deps_gen_hpack_tables: $(GEN_HPACK_TABLES_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(GEN_HPACK_TABLES_OBJS:.o=.dep) -endif -endif - - -GEN_LEGAL_METADATA_CHARACTERS_SRC = \ - tools/codegen/core/gen_legal_metadata_characters.cc \ - -GEN_LEGAL_METADATA_CHARACTERS_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GEN_LEGAL_METADATA_CHARACTERS_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/gen_legal_metadata_characters: openssl_dep_error - -else - - - -$(BINDIR)/$(CONFIG)/gen_legal_metadata_characters: $(GEN_LEGAL_METADATA_CHARACTERS_OBJS) - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GEN_LEGAL_METADATA_CHARACTERS_OBJS) $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gen_legal_metadata_characters - -endif - -$(OBJDIR)/$(CONFIG)/tools/codegen/core/gen_legal_metadata_characters.o: - -deps_gen_legal_metadata_characters: $(GEN_LEGAL_METADATA_CHARACTERS_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(GEN_LEGAL_METADATA_CHARACTERS_OBJS:.o=.dep) -endif -endif - - -GEN_PERCENT_ENCODING_TABLES_SRC = \ - tools/codegen/core/gen_percent_encoding_tables.cc \ - -GEN_PERCENT_ENCODING_TABLES_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GEN_PERCENT_ENCODING_TABLES_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/gen_percent_encoding_tables: openssl_dep_error - -else - - - -$(BINDIR)/$(CONFIG)/gen_percent_encoding_tables: $(GEN_PERCENT_ENCODING_TABLES_OBJS) - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GEN_PERCENT_ENCODING_TABLES_OBJS) $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gen_percent_encoding_tables - -endif - -$(OBJDIR)/$(CONFIG)/tools/codegen/core/gen_percent_encoding_tables.o: - -deps_gen_percent_encoding_tables: $(GEN_PERCENT_ENCODING_TABLES_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(GEN_PERCENT_ENCODING_TABLES_OBJS:.o=.dep) -endif -endif - - BORINGSSL_SSL_TEST_SRC = \ third_party/boringssl/crypto/test/gtest_main.cc \ third_party/boringssl/ssl/span_test.cc \ diff --git a/build.yaml b/build.yaml index c7f638495f8..e63f375bd8a 100644 --- a/build.yaml +++ b/build.yaml @@ -4953,6 +4953,28 @@ targets: - grpc++ - grpc - gpr +- name: gen_hpack_tables + build: tool + language: c++ + src: + - tools/codegen/core/gen_hpack_tables.cc + deps: + - gpr + - grpc + uses_polling: false +- name: gen_legal_metadata_characters + build: tool + language: c++ + src: + - tools/codegen/core/gen_legal_metadata_characters.cc + deps: [] +- name: gen_percent_encoding_tables + build: tool + language: c++ + src: + - tools/codegen/core/gen_percent_encoding_tables.cc + deps: [] + uses_polling: false - name: generic_end2end_test gtest: true build: test @@ -6056,28 +6078,6 @@ targets: deps: - grpc - gpr -- name: gen_hpack_tables - build: tool - language: cc - src: - - tools/codegen/core/gen_hpack_tables.cc - deps: - - gpr - - grpc - uses_polling: false -- name: gen_legal_metadata_characters - build: tool - language: cc - src: - - tools/codegen/core/gen_legal_metadata_characters.cc - deps: [] -- name: gen_percent_encoding_tables - build: tool - language: cc - src: - - tools/codegen/core/gen_percent_encoding_tables.cc - deps: [] - uses_polling: false vspackages: - linkage: static name: grpc.dependencies.zlib diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index b54404bbd0d..eeb66a585ee 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -3765,6 +3765,45 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "grpc" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "gen_hpack_tables", + "src": [ + "tools/codegen/core/gen_hpack_tables.cc" + ], + "third_party": false, + "type": "target" + }, + { + "deps": [], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "gen_legal_metadata_characters", + "src": [ + "tools/codegen/core/gen_legal_metadata_characters.cc" + ], + "third_party": false, + "type": "target" + }, + { + "deps": [], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "gen_percent_encoding_tables", + "src": [ + "tools/codegen/core/gen_percent_encoding_tables.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", @@ -5357,45 +5396,6 @@ "third_party": false, "type": "target" }, - { - "deps": [ - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "cc", - "name": "gen_hpack_tables", - "src": [ - "tools/codegen/core/gen_hpack_tables.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [], - "headers": [], - "is_filegroup": false, - "language": "cc", - "name": "gen_legal_metadata_characters", - "src": [ - "tools/codegen/core/gen_legal_metadata_characters.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [], - "headers": [], - "is_filegroup": false, - "language": "cc", - "name": "gen_percent_encoding_tables", - "src": [ - "tools/codegen/core/gen_percent_encoding_tables.cc" - ], - "third_party": false, - "type": "target" - }, { "deps": [ "boringssl", From c8dc36bb477573bb4f3dd5140153502a067463e1 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Tue, 13 Aug 2019 16:10:37 -0700 Subject: [PATCH 1240/1555] Change xds args to const --- .../client_channel/lb_policy/xds/xds.cc | 19 +++++++++---------- src/core/lib/channel/channel_args.cc | 19 +++++++++++++++++++ src/core/lib/channel/channel_args.h | 18 ++++++++++++++++-- 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index 468c9d84591..85d1b012696 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -575,7 +575,7 @@ class XdsLb : public LoadBalancingPolicy { OrphanablePtr pending_lb_chand_; // Timeout in milliseconds for the LB call. 0 means no deadline. - int lb_call_timeout_ms_ = 0; + const grpc_millis lb_call_timeout_ms_; // Whether the checks for fallback at startup are ALL pending. There are // several cases where this can be reset: @@ -587,7 +587,7 @@ class XdsLb : public LoadBalancingPolicy { bool fallback_at_startup_checks_pending_ = false; // Timeout in milliseconds for before using fallback backend addresses. // 0 means not using fallback. - int lb_fallback_timeout_ms_ = 0; + const grpc_millis lb_fallback_timeout_ms_; // The backend addresses from the resolver. ServerAddressList fallback_backend_addresses_; // Fallback timer. @@ -1705,7 +1705,13 @@ grpc_channel_args* BuildBalancerChannelArgs(const grpc_channel_args* args) { // XdsLb::XdsLb(Args args) - : LoadBalancingPolicy(std::move(args)), locality_map_(this) { + : LoadBalancingPolicy(std::move(args)), + lb_call_timeout_ms_(grpc_channel_args_find_integer( + args.args, GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS, {0, 0, INT_MAX})), + lb_fallback_timeout_ms_(grpc_channel_args_find_integer( + args.args, GRPC_ARG_XDS_FALLBACK_TIMEOUT_MS, + {GRPC_XDS_DEFAULT_FALLBACK_TIMEOUT_MS, 0, INT_MAX})), + locality_map_(this) { // Record server name. const grpc_arg* arg = grpc_channel_args_find(args.args, GRPC_ARG_SERVER_URI); const char* server_uri = grpc_channel_arg_get_string(arg); @@ -1719,13 +1725,6 @@ XdsLb::XdsLb(Args args) server_name_); } grpc_uri_destroy(uri); - // Record LB call timeout. - arg = grpc_channel_args_find(args.args, GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS); - lb_call_timeout_ms_ = grpc_channel_arg_get_integer(arg, {0, 0, INT_MAX}); - // Record fallback timeout. - arg = grpc_channel_args_find(args.args, GRPC_ARG_XDS_FALLBACK_TIMEOUT_MS); - lb_fallback_timeout_ms_ = grpc_channel_arg_get_integer( - arg, {GRPC_XDS_DEFAULT_FALLBACK_TIMEOUT_MS, 0, INT_MAX}); } XdsLb::~XdsLb() { diff --git a/src/core/lib/channel/channel_args.cc b/src/core/lib/channel/channel_args.cc index b629ac0e107..60248f9d8fc 100644 --- a/src/core/lib/channel/channel_args.cc +++ b/src/core/lib/channel/channel_args.cc @@ -257,6 +257,13 @@ int grpc_channel_arg_get_integer(const grpc_arg* arg, return arg->value.integer; } +int grpc_channel_args_find_integer(const grpc_channel_args* args, + const char* name, + const grpc_integer_options options) { + const grpc_arg* arg = grpc_channel_args_find(args, name); + return grpc_channel_arg_get_integer(arg, options); +} + char* grpc_channel_arg_get_string(const grpc_arg* arg) { if (arg == nullptr) return nullptr; if (arg->type != GRPC_ARG_STRING) { @@ -266,6 +273,12 @@ char* grpc_channel_arg_get_string(const grpc_arg* arg) { return arg->value.string; } +char* grpc_channel_args_find_string(const grpc_channel_args* args, + const char* name) { + const grpc_arg* arg = grpc_channel_args_find(args, name); + return grpc_channel_arg_get_string(arg); +} + bool grpc_channel_arg_get_bool(const grpc_arg* arg, bool default_value) { if (arg == nullptr) return default_value; if (arg->type != GRPC_ARG_INTEGER) { @@ -284,6 +297,12 @@ bool grpc_channel_arg_get_bool(const grpc_arg* arg, bool default_value) { } } +bool grpc_channel_args_find_bool(const grpc_channel_args* args, + const char* name, bool default_value) { + const grpc_arg* arg = grpc_channel_args_find(args, name); + return grpc_channel_arg_get_bool(arg, default_value); +} + bool grpc_channel_args_want_minimal_stack(const grpc_channel_args* args) { return grpc_channel_arg_get_bool( grpc_channel_args_find(args, GRPC_ARG_MINIMAL_STACK), false); diff --git a/src/core/lib/channel/channel_args.h b/src/core/lib/channel/channel_args.h index 2b698a66cfb..5928802f288 100644 --- a/src/core/lib/channel/channel_args.h +++ b/src/core/lib/channel/channel_args.h @@ -73,16 +73,30 @@ typedef struct grpc_integer_options { int max_value; } grpc_integer_options; -/** Returns the value of \a arg, subject to the contraints in \a options. */ +/** Returns the value of \a arg, subject to the constraints in \a options. */ int grpc_channel_arg_get_integer(const grpc_arg* arg, const grpc_integer_options options); +/** Similar to the above, but needs to find the arg from \a args by the name + * first. */ +int grpc_channel_args_find_integer(const grpc_channel_args* args, + const char* name, + const grpc_integer_options options); /** Returns the value of \a arg if \a arg is of type GRPC_ARG_STRING. Otherwise, emits a warning log, and returns nullptr. If arg is nullptr, returns nullptr, and does not emit a warning. */ char* grpc_channel_arg_get_string(const grpc_arg* arg); - +/** Similar to the above, but needs to find the arg from \a args by the name + * first. */ +char* grpc_channel_args_find_string(const grpc_channel_args* args, + const char* name); +/** If \a arg is of type GRPC_ARG_INTEGER, returns true if it's non-zero. + * Returns \a default_value if \a arg is of other types. */ bool grpc_channel_arg_get_bool(const grpc_arg* arg, bool default_value); +/** Similar to the above, but needs to find the arg from \a args by the name + * first. */ +bool grpc_channel_args_find_bool(const grpc_channel_args* args, + const char* name, bool default_value); // Helpers for creating channel args. grpc_arg grpc_channel_arg_string_create(char* name, char* value); From 03ec155a22fe0177f58d59efd50e8440824b2559 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 14 Aug 2019 10:26:22 -0700 Subject: [PATCH 1241/1555] Bump version to v1.23.0 --- BUILD | 2 +- build.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index c708318ecbf..6607963fd3e 100644 --- a/BUILD +++ b/BUILD @@ -78,7 +78,7 @@ g_stands_for = "gangnam" core_version = "7.0.0" -version = "1.23.0-pre1" +version = "1.23.0" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index 1ba055c65dd..bf64faad540 100644 --- a/build.yaml +++ b/build.yaml @@ -15,7 +15,7 @@ settings: core_version: 7.0.0 csharp_major_version: 2 g_stands_for: gangnam - version: 1.23.0-pre1 + version: 1.23.0 filegroups: - name: alts_proto headers: From 136d3daf53adb7e4b41e0d1e2174665694948c13 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 14 Aug 2019 10:27:19 -0700 Subject: [PATCH 1242/1555] Regenerate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 6 +++--- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 8 ++++---- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 2 +- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 30 files changed, 36 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a5b4b5cd8a..5ee805b4852 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 3.5.1) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.23.0-pre1") +set(PACKAGE_VERSION "1.23.0") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index d4d82581cef..2d8b2d64e52 100644 --- a/Makefile +++ b/Makefile @@ -461,8 +461,8 @@ Q = @ endif CORE_VERSION = 7.0.0 -CPP_VERSION = 1.23.0-pre1 -CSHARP_VERSION = 2.23.0-pre1 +CPP_VERSION = 1.23.0 +CSHARP_VERSION = 2.23.0 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 304ae372101..340783d2674 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,15 +23,15 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.23.0-pre1' - version = '0.0.9-pre1' + # version = '1.23.0' + version = '0.0.9' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.23.0-pre1' + grpc_version = '1.23.0' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index d3a82b572dc..ab6738339b2 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.23.0-pre1' + version = '1.23.0' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index c90445baae2..363d600f73c 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.23.0-pre1' + version = '1.23.0' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 87bd9e7c481..f348874284a 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.23.0-pre1' + version = '1.23.0' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index dc05dc86ba2..aa81a45d5f3 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.23.0-pre1' + version = '1.23.0' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index 7d2cb708925..22869666b78 100644 --- a/package.xml +++ b/package.xml @@ -13,12 +13,12 @@ 2018-01-19 - 1.23.0RC1 - 1.23.0RC1 + 1.23.0 + 1.23.0 - beta - beta + stable + stable Apache 2.0 diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 751cbfa1c22..8427f517b99 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.23.0-pre1"; } +grpc::string Version() { return "1.23.0"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index ca9e88f268d..835bc3c9860 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -38,6 +38,6 @@ namespace Grpc.Core /// /// Current version of gRPC C# /// - public const string CurrentVersion = "2.23.0-pre1"; + public const string CurrentVersion = "2.23.0"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index 00ff3ccb780..28a0ef6e8a1 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 2.23.0-pre1 + 2.23.0 3.8.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index 1906f266e20..dc9bcf4c8bb 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=2.23.0-pre1 +set VERSION=2.23.0 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec index 6dc9d4a3f13..730abd861cb 100644 --- a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCCppPlugin' - v = '1.23.0-pre1' + v = '1.23.0' s.version = v s.summary = 'The gRPC ProtoC plugin generates C++ files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 98b4ef0dc12..86d2d2d4018 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.23.0-pre1' + v = '1.23.0' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index bf467558d31..29c669e2648 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.23.0-pre1" +#define GRPC_OBJC_VERSION_STRING @"1.23.0" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index f5d7ec747af..43998fc84ea 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.23.0-pre1" +#define GRPC_OBJC_VERSION_STRING @"1.23.0" #define GRPC_C_VERSION_STRING @"7.0.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 038ca5c1b25..119d554177c 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.23.0RC1" +#define PHP_GRPC_VERSION "1.23.0" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index d8f04ec88f3..dd1e72ed2cc 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.23.0rc1""" +__version__ = """1.23.0""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index 2215172be39..9139a633d1e 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.23.0rc1' +VERSION = '1.23.0' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index d7b9e92800b..1fbb2c7a889 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.23.0rc1' +VERSION = '1.23.0' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index 04a5cd79401..91530bc84b0 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.23.0rc1' +VERSION = '1.23.0' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 8f47ca23c9b..9c2e33224cc 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.23.0rc1' +VERSION = '1.23.0' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index 42aad42fa57..c5ce683cf32 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.23.0rc1' +VERSION = '1.23.0' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 71930c6730f..9bb8917c6dd 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.23.0rc1' +VERSION = '1.23.0' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index aab9f1b57ab..b3d03a317a6 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.23.0rc1' +VERSION = '1.23.0' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index fa31c144282..5ca1f443cf0 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.23.0.pre1' + VERSION = '1.23.0' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index e5e7a16717c..a70b4789a46 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.23.0.pre1' + VERSION = '1.23.0' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 2b4e8218b50..46bdd9b7df1 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.23.0rc1' +VERSION = '1.23.0' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index d508459f0fd..013ab911a13 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.23.0-pre1 +PROJECT_NUMBER = 1.23.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index ec0c30b0e79..c72f0485275 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.23.0-pre1 +PROJECT_NUMBER = 1.23.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From 6cf05561cedffd7111a94b86c80060deb86c7efa Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Mon, 22 Jul 2019 12:24:16 -0700 Subject: [PATCH 1243/1555] Added overloads for metadata add/remove operations when static index is known. In several cases, we wish to add or remove metadata when we already know what kind of metadata it is (e.g. we know we're dealing with the path, or the authority, or the user agent, etc.). In these cases, we do not need to re-compute the metadata batch callout index since we know it a-priori. This saves us some branches and ALU ops spent pointlessly re-computing these indices in several hot-path filters. We do need the original methods where we do compute the indices in cases where we're operating over a collection of metadata, but this is relatively uncommon. --- .../filters/client_channel/client_channel.cc | 5 +- .../health/health_check_client.cc | 3 +- .../filters/http/client/http_client_filter.cc | 18 ++-- .../filters/http/client_authority_filter.cc | 2 +- .../message_compress_filter.cc | 17 ++-- .../filters/http/server/http_server_filter.cc | 78 ++++++++++------ src/core/lib/surface/call.cc | 12 +-- src/core/lib/surface/server.cc | 11 ++- src/core/lib/transport/metadata_batch.cc | 88 +++++++++++++++---- src/core/lib/transport/metadata_batch.h | 38 ++++++++ src/cpp/ext/filters/census/client_filter.cc | 6 +- src/cpp/ext/filters/census/server_filter.cc | 7 +- 12 files changed, 206 insertions(+), 79 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 767a22e9e59..63bd737e931 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -3186,8 +3186,7 @@ void CallData::AddRetriableSendInitialMetadataOp( if (GPR_UNLIKELY(retry_state->send_initial_metadata.idx.named .grpc_previous_rpc_attempts != nullptr)) { grpc_metadata_batch_remove(&retry_state->send_initial_metadata, - retry_state->send_initial_metadata.idx.named - .grpc_previous_rpc_attempts); + GRPC_BATCH_GRPC_PREVIOUS_RPC_ATTEMPTS); } if (GPR_UNLIKELY(num_attempts_completed_ > 0)) { grpc_mdelem retry_md = grpc_mdelem_create( @@ -3197,7 +3196,7 @@ void CallData::AddRetriableSendInitialMetadataOp( &retry_state->send_initial_metadata, &retry_state ->send_initial_metadata_storage[send_initial_metadata_.list.count], - retry_md); + retry_md, GRPC_BATCH_GRPC_PREVIOUS_RPC_ATTEMPTS); if (GPR_UNLIKELY(error != GRPC_ERROR_NONE)) { gpr_log(GPR_ERROR, "error adding retry metadata: %s", grpc_error_string(error)); diff --git a/src/core/ext/filters/client_channel/health/health_check_client.cc b/src/core/ext/filters/client_channel/health/health_check_client.cc index 63a0a455fc1..026831645c0 100644 --- a/src/core/ext/filters/client_channel/health/health_check_client.cc +++ b/src/core/ext/filters/client_channel/health/health_check_client.cc @@ -346,7 +346,8 @@ void HealthCheckClient::CallState::StartCall() { &send_initial_metadata_, &path_metadata_storage_, grpc_mdelem_from_slices( GRPC_MDSTR_PATH, - GRPC_MDSTR_SLASH_GRPC_DOT_HEALTH_DOT_V1_DOT_HEALTH_SLASH_WATCH)); + GRPC_MDSTR_SLASH_GRPC_DOT_HEALTH_DOT_V1_DOT_HEALTH_SLASH_WATCH), + GRPC_BATCH_PATH); GPR_ASSERT(error == GRPC_ERROR_NONE); payload_.send_initial_metadata.send_initial_metadata = &send_initial_metadata_; diff --git a/src/core/ext/filters/http/client/http_client_filter.cc b/src/core/ext/filters/http/client/http_client_filter.cc index 9ec7aaf4ec8..b16d26b1f24 100644 --- a/src/core/ext/filters/http/client/http_client_filter.cc +++ b/src/core/ext/filters/http/client/http_client_filter.cc @@ -109,7 +109,7 @@ static grpc_error* client_filter_incoming_metadata(grpc_call_element* elem, if (b->idx.named.grpc_status != nullptr || grpc_mdelem_static_value_eq(b->idx.named.status->md, GRPC_MDELEM_STATUS_200)) { - grpc_metadata_batch_remove(b, b->idx.named.status); + grpc_metadata_batch_remove(b, GRPC_BATCH_STATUS); } else { char* val = grpc_dump_slice(GRPC_MDVALUE(b->idx.named.status->md), GPR_DUMP_ASCII); @@ -167,7 +167,7 @@ static grpc_error* client_filter_incoming_metadata(grpc_call_element* elem, gpr_free(val); } } - grpc_metadata_batch_remove(b, b->idx.named.content_type); + grpc_metadata_batch_remove(b, GRPC_BATCH_CONTENT_TYPE); } return GRPC_ERROR_NONE; @@ -336,7 +336,7 @@ static grpc_error* update_path_for_get(grpc_call_element* elem, static void remove_if_present(grpc_metadata_batch* batch, grpc_metadata_batch_callouts_index idx) { if (batch->idx.array[idx] != nullptr) { - grpc_metadata_batch_remove(batch, batch->idx.array[idx]); + grpc_metadata_batch_remove(batch, idx); } } @@ -433,23 +433,25 @@ static void hc_start_transport_stream_op_batch( layer headers. */ error = grpc_metadata_batch_add_head( batch->payload->send_initial_metadata.send_initial_metadata, - &calld->method, method); + &calld->method, method, GRPC_BATCH_METHOD); if (error != GRPC_ERROR_NONE) goto done; error = grpc_metadata_batch_add_head( batch->payload->send_initial_metadata.send_initial_metadata, - &calld->scheme, channeld->static_scheme); + &calld->scheme, channeld->static_scheme, GRPC_BATCH_SCHEME); if (error != GRPC_ERROR_NONE) goto done; error = grpc_metadata_batch_add_tail( batch->payload->send_initial_metadata.send_initial_metadata, - &calld->te_trailers, GRPC_MDELEM_TE_TRAILERS); + &calld->te_trailers, GRPC_MDELEM_TE_TRAILERS, GRPC_BATCH_TE); if (error != GRPC_ERROR_NONE) goto done; error = grpc_metadata_batch_add_tail( batch->payload->send_initial_metadata.send_initial_metadata, - &calld->content_type, GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC); + &calld->content_type, GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC, + GRPC_BATCH_CONTENT_TYPE); if (error != GRPC_ERROR_NONE) goto done; error = grpc_metadata_batch_add_tail( batch->payload->send_initial_metadata.send_initial_metadata, - &calld->user_agent, GRPC_MDELEM_REF(channeld->user_agent)); + &calld->user_agent, GRPC_MDELEM_REF(channeld->user_agent), + GRPC_BATCH_USER_AGENT); if (error != GRPC_ERROR_NONE) goto done; } diff --git a/src/core/ext/filters/http/client_authority_filter.cc b/src/core/ext/filters/http/client_authority_filter.cc index 13c6ce58fec..dc8beb986fc 100644 --- a/src/core/ext/filters/http/client_authority_filter.cc +++ b/src/core/ext/filters/http/client_authority_filter.cc @@ -60,7 +60,7 @@ void authority_start_transport_stream_op_batch( initial_metadata->idx.named.authority == nullptr) { grpc_error* error = grpc_metadata_batch_add_head( initial_metadata, &calld->authority_storage, - GRPC_MDELEM_REF(chand->default_authority_mdelem)); + GRPC_MDELEM_REF(chand->default_authority_mdelem), GRPC_BATCH_AUTHORITY); if (error != GRPC_ERROR_NONE) { grpc_transport_stream_op_batch_finish_with_failure(batch, error, calld->call_combiner); diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.cc b/src/core/ext/filters/http/message_compress/message_compress_filter.cc index 0e0be6e9cff..9ef8e6a1990 100644 --- a/src/core/ext/filters/http/message_compress/message_compress_filter.cc +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.cc @@ -137,9 +137,8 @@ static grpc_compression_algorithm find_compression_algorithm( &compression_algorithm)); // Remove this metadata since it's an internal one (i.e., it won't be // transmitted out). - grpc_metadata_batch_remove( - initial_metadata, - initial_metadata->idx.named.grpc_internal_encoding_request); + grpc_metadata_batch_remove(initial_metadata, + GRPC_BATCH_GRPC_INTERNAL_ENCODING_REQUEST); // Check if that algorithm is enabled. Note that GRPC_COMPRESS_NONE is always // enabled. // TODO(juanlishen): Maybe use channel default or abort() if the algorithm @@ -195,19 +194,22 @@ static grpc_error* process_send_initial_metadata( error = grpc_metadata_batch_add_tail( initial_metadata, &calld->message_compression_algorithm_storage, grpc_message_compression_encoding_mdelem( - calld->message_compression_algorithm)); + calld->message_compression_algorithm), + GRPC_BATCH_GRPC_ENCODING); } else if (stream_compression_algorithm != GRPC_STREAM_COMPRESS_NONE) { initialize_state(elem, calld); error = grpc_metadata_batch_add_tail( initial_metadata, &calld->stream_compression_algorithm_storage, - grpc_stream_compression_encoding_mdelem(stream_compression_algorithm)); + grpc_stream_compression_encoding_mdelem(stream_compression_algorithm), + GRPC_BATCH_CONTENT_ENCODING); } if (error != GRPC_ERROR_NONE) return error; // Convey supported compression algorithms. error = grpc_metadata_batch_add_tail( initial_metadata, &calld->accept_encoding_storage, GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS( - channeld->enabled_message_compression_algorithms_bitset)); + channeld->enabled_message_compression_algorithms_bitset), + GRPC_BATCH_GRPC_ACCEPT_ENCODING); if (error != GRPC_ERROR_NONE) return error; // Do not overwrite accept-encoding header if it already presents (e.g., added // by some proxy). @@ -215,7 +217,8 @@ static grpc_error* process_send_initial_metadata( error = grpc_metadata_batch_add_tail( initial_metadata, &calld->accept_stream_encoding_storage, GRPC_MDELEM_ACCEPT_STREAM_ENCODING_FOR_ALGORITHMS( - channeld->enabled_stream_compression_algorithms_bitset)); + channeld->enabled_stream_compression_algorithms_bitset), + GRPC_BATCH_ACCEPT_ENCODING); } return error; } diff --git a/src/core/ext/filters/http/server/http_server_filter.cc b/src/core/ext/filters/http/server/http_server_filter.cc index 028d268c7b3..99f6b65e424 100644 --- a/src/core/ext/filters/http/server/http_server_filter.cc +++ b/src/core/ext/filters/http/server/http_server_filter.cc @@ -124,6 +124,32 @@ static void hs_add_error(const char* error_name, grpc_error** cumulative, *cumulative = grpc_error_add_child(*cumulative, new_err); } +// Metadata equality within this filter leverages the fact that the sender was +// likely using the gRPC chttp2 transport, in which case the encoder would emit +// indexed values, in which case the local hpack parser would intern the +// relevant metadata, allowing a simple pointer comparison. +// +// That said, if the header was transmitted sans indexing/encoding, we still +// need to do the right thing. +// +// Assumptions: +// 1) The keys for a and b_static must match +// 2) b_static must be a statically allocated metadata object. +// 3) It is assumed that the remote end is indexing, but not necessary. +// TODO(arjunroy): Revisit this method when grpc_mdelem is strongly typed. +static bool md_strict_equal(grpc_mdelem a, grpc_mdelem b_static) { + // Hpack encoder on the remote side should emit indexed values, in which case + // hpack parser on this end should pick up interned values, in which case the + // pointer comparison alone is enough. + // + if (GPR_LIKELY(GRPC_MDELEM_IS_INTERNED(a))) { + return a.payload == b_static.payload; + } else { + return grpc_slice_eq_static_interned(GRPC_MDVALUE(a), + GRPC_MDVALUE(b_static)); + } +} + static grpc_error* hs_filter_incoming_metadata(grpc_call_element* elem, grpc_metadata_batch* b) { call_data* calld = static_cast(elem->call_data); @@ -131,19 +157,18 @@ static grpc_error* hs_filter_incoming_metadata(grpc_call_element* elem, static const char* error_name = "Failed processing incoming headers"; if (b->idx.named.method != nullptr) { - if (grpc_mdelem_static_value_eq(b->idx.named.method->md, - GRPC_MDELEM_METHOD_POST)) { + if (md_strict_equal(b->idx.named.method->md, GRPC_MDELEM_METHOD_POST)) { *calld->recv_initial_metadata_flags &= ~(GRPC_INITIAL_METADATA_CACHEABLE_REQUEST | GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST); - } else if (grpc_mdelem_static_value_eq(b->idx.named.method->md, - GRPC_MDELEM_METHOD_PUT)) { + } else if (md_strict_equal(b->idx.named.method->md, + GRPC_MDELEM_METHOD_PUT)) { *calld->recv_initial_metadata_flags &= ~GRPC_INITIAL_METADATA_CACHEABLE_REQUEST; *calld->recv_initial_metadata_flags |= GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST; - } else if (grpc_mdelem_static_value_eq(b->idx.named.method->md, - GRPC_MDELEM_METHOD_GET)) { + } else if (md_strict_equal(b->idx.named.method->md, + GRPC_MDELEM_METHOD_GET)) { *calld->recv_initial_metadata_flags |= GRPC_INITIAL_METADATA_CACHEABLE_REQUEST; *calld->recv_initial_metadata_flags &= @@ -154,7 +179,7 @@ static grpc_error* hs_filter_incoming_metadata(grpc_call_element* elem, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"), b->idx.named.method->md)); } - grpc_metadata_batch_remove(b, b->idx.named.method); + grpc_metadata_batch_remove(b, GRPC_BATCH_METHOD); } else { hs_add_error( error_name, &error, @@ -171,7 +196,7 @@ static grpc_error* hs_filter_incoming_metadata(grpc_call_element* elem, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"), b->idx.named.te->md)); } - grpc_metadata_batch_remove(b, b->idx.named.te); + grpc_metadata_batch_remove(b, GRPC_BATCH_TE); } else { hs_add_error(error_name, &error, grpc_error_set_str( @@ -180,10 +205,8 @@ static grpc_error* hs_filter_incoming_metadata(grpc_call_element* elem, } if (b->idx.named.scheme != nullptr) { - if (!grpc_mdelem_static_value_eq(b->idx.named.scheme->md, - GRPC_MDELEM_SCHEME_HTTP) && - !grpc_mdelem_static_value_eq(b->idx.named.scheme->md, - GRPC_MDELEM_SCHEME_HTTPS) && + if (!md_strict_equal(b->idx.named.scheme->md, GRPC_MDELEM_SCHEME_HTTP) && + !md_strict_equal(b->idx.named.scheme->md, GRPC_MDELEM_SCHEME_HTTPS) && !grpc_mdelem_static_value_eq(b->idx.named.scheme->md, GRPC_MDELEM_SCHEME_GRPC)) { hs_add_error(error_name, &error, @@ -191,7 +214,7 @@ static grpc_error* hs_filter_incoming_metadata(grpc_call_element* elem, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"), b->idx.named.scheme->md)); } - grpc_metadata_batch_remove(b, b->idx.named.scheme); + grpc_metadata_batch_remove(b, GRPC_BATCH_SCHEME); } else { hs_add_error( error_name, &error, @@ -227,7 +250,7 @@ static grpc_error* hs_filter_incoming_metadata(grpc_call_element* elem, gpr_free(val); } } - grpc_metadata_batch_remove(b, b->idx.named.content_type); + grpc_metadata_batch_remove(b, GRPC_BATCH_CONTENT_TYPE); } if (b->idx.named.path == nullptr) { @@ -282,12 +305,13 @@ static grpc_error* hs_filter_incoming_metadata(grpc_call_element* elem, grpc_linked_mdelem* el = b->idx.named.host; grpc_mdelem md = GRPC_MDELEM_REF(el->md); grpc_metadata_batch_remove(b, el); - hs_add_error(error_name, &error, - grpc_metadata_batch_add_head( - b, el, - grpc_mdelem_from_slices( - GRPC_MDSTR_AUTHORITY, - grpc_slice_ref_internal(GRPC_MDVALUE(md))))); + hs_add_error( + error_name, &error, + grpc_metadata_batch_add_head( + b, el, + grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY, + grpc_slice_ref_internal(GRPC_MDVALUE(md))), + GRPC_BATCH_AUTHORITY)); GRPC_MDELEM_UNREF(md); } @@ -301,7 +325,7 @@ static grpc_error* hs_filter_incoming_metadata(grpc_call_element* elem, channel_data* chand = static_cast(elem->channel_data); if (!chand->surface_user_agent && b->idx.named.user_agent != nullptr) { - grpc_metadata_batch_remove(b, b->idx.named.user_agent); + grpc_metadata_batch_remove(b, GRPC_BATCH_USER_AGENT); } return error; @@ -392,15 +416,17 @@ static grpc_error* hs_mutate_op(grpc_call_element* elem, if (op->send_initial_metadata) { grpc_error* error = GRPC_ERROR_NONE; static const char* error_name = "Failed sending initial metadata"; - hs_add_error(error_name, &error, - grpc_metadata_batch_add_head( - op->payload->send_initial_metadata.send_initial_metadata, - &calld->status, GRPC_MDELEM_STATUS_200)); + hs_add_error( + error_name, &error, + grpc_metadata_batch_add_head( + op->payload->send_initial_metadata.send_initial_metadata, + &calld->status, GRPC_MDELEM_STATUS_200, GRPC_BATCH_STATUS)); hs_add_error(error_name, &error, grpc_metadata_batch_add_tail( op->payload->send_initial_metadata.send_initial_metadata, &calld->content_type, - GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC)); + GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC, + GRPC_BATCH_CONTENT_TYPE)); hs_add_error( error_name, &error, hs_filter_outgoing_metadata( diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 378d148c674..1331e57ab0c 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -1007,13 +1007,13 @@ static void recv_initial_filter(grpc_call* call, grpc_metadata_batch* b) { GPR_TIMER_SCOPE("incoming_stream_compression_algorithm", 0); set_incoming_stream_compression_algorithm( call, decode_stream_compression(b->idx.named.content_encoding->md)); - grpc_metadata_batch_remove(b, b->idx.named.content_encoding); + grpc_metadata_batch_remove(b, GRPC_BATCH_CONTENT_ENCODING); } if (b->idx.named.grpc_encoding != nullptr) { GPR_TIMER_SCOPE("incoming_message_compression_algorithm", 0); set_incoming_message_compression_algorithm( call, decode_message_compression(b->idx.named.grpc_encoding->md)); - grpc_metadata_batch_remove(b, b->idx.named.grpc_encoding); + grpc_metadata_batch_remove(b, GRPC_BATCH_GRPC_ENCODING); } uint32_t message_encodings_accepted_by_peer = 1u; uint32_t stream_encodings_accepted_by_peer = 1u; @@ -1021,13 +1021,13 @@ static void recv_initial_filter(grpc_call* call, grpc_metadata_batch* b) { GPR_TIMER_SCOPE("encodings_accepted_by_peer", 0); set_encodings_accepted_by_peer(call, b->idx.named.grpc_accept_encoding->md, &message_encodings_accepted_by_peer, false); - grpc_metadata_batch_remove(b, b->idx.named.grpc_accept_encoding); + grpc_metadata_batch_remove(b, GRPC_BATCH_GRPC_ACCEPT_ENCODING); } if (b->idx.named.accept_encoding != nullptr) { GPR_TIMER_SCOPE("stream_encodings_accepted_by_peer", 0); set_encodings_accepted_by_peer(call, b->idx.named.accept_encoding->md, &stream_encodings_accepted_by_peer, true); - grpc_metadata_batch_remove(b, b->idx.named.accept_encoding); + grpc_metadata_batch_remove(b, GRPC_BATCH_ACCEPT_ENCODING); } call->encodings_accepted_by_peer = grpc_compression_bitset_from_message_stream_compression_bitset( @@ -1059,13 +1059,13 @@ static void recv_trailing_filter(void* args, grpc_metadata_batch* b, error = grpc_error_set_str( error, GRPC_ERROR_STR_GRPC_MESSAGE, grpc_slice_ref_internal(GRPC_MDVALUE(b->idx.named.grpc_message->md))); - grpc_metadata_batch_remove(b, b->idx.named.grpc_message); + grpc_metadata_batch_remove(b, GRPC_BATCH_GRPC_MESSAGE); } else if (error != GRPC_ERROR_NONE) { error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, grpc_empty_slice()); } set_final_status(call, GRPC_ERROR_REF(error)); - grpc_metadata_batch_remove(b, b->idx.named.grpc_status); + grpc_metadata_batch_remove(b, GRPC_BATCH_GRPC_STATUS); GRPC_ERROR_UNREF(error); } else if (!call->is_client) { set_final_status(call, GRPC_ERROR_NONE); diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index f344b32d7a6..2cc7e88cab4 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -744,19 +744,18 @@ static void server_on_recv_initial_metadata(void* ptr, grpc_error* error) { grpc_millis op_deadline; if (error == GRPC_ERROR_NONE) { - GPR_ASSERT(calld->recv_initial_metadata->idx.named.path != nullptr); - GPR_ASSERT(calld->recv_initial_metadata->idx.named.authority != nullptr); + GPR_DEBUG_ASSERT(calld->recv_initial_metadata->idx.named.path != nullptr); + GPR_DEBUG_ASSERT(calld->recv_initial_metadata->idx.named.authority != + nullptr); calld->path = grpc_slice_ref_internal( GRPC_MDVALUE(calld->recv_initial_metadata->idx.named.path->md)); calld->host = grpc_slice_ref_internal( GRPC_MDVALUE(calld->recv_initial_metadata->idx.named.authority->md)); calld->path_set = true; calld->host_set = true; + grpc_metadata_batch_remove(calld->recv_initial_metadata, GRPC_BATCH_PATH); grpc_metadata_batch_remove(calld->recv_initial_metadata, - calld->recv_initial_metadata->idx.named.path); - grpc_metadata_batch_remove( - calld->recv_initial_metadata, - calld->recv_initial_metadata->idx.named.authority); + GRPC_BATCH_AUTHORITY); } else { GRPC_ERROR_REF(error); } diff --git a/src/core/lib/transport/metadata_batch.cc b/src/core/lib/transport/metadata_batch.cc index 74356b2caf2..560342cecc6 100644 --- a/src/core/lib/transport/metadata_batch.cc +++ b/src/core/lib/transport/metadata_batch.cc @@ -93,6 +93,23 @@ grpc_error* grpc_attach_md_to_error(grpc_error* src, grpc_mdelem md) { return out; } +static grpc_error* GPR_ATTRIBUTE_NOINLINE error_with_md(grpc_mdelem md) { + return grpc_attach_md_to_error( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unallowed duplicate metadata"), md); +} + +static grpc_error* link_callout(grpc_metadata_batch* batch, + grpc_linked_mdelem* storage, + grpc_metadata_batch_callouts_index idx) { + GPR_DEBUG_ASSERT(idx >= 0 && idx < GRPC_BATCH_CALLOUTS_COUNT); + if (GPR_LIKELY(batch->idx.array[idx] == nullptr)) { + ++batch->list.default_count; + batch->idx.array[idx] = storage; + return GRPC_ERROR_NONE; + } + return error_with_md(storage->md); +} + static grpc_error* maybe_link_callout(grpc_metadata_batch* batch, grpc_linked_mdelem* storage) GRPC_MUST_USE_RESULT; @@ -104,14 +121,7 @@ static grpc_error* maybe_link_callout(grpc_metadata_batch* batch, if (idx == GRPC_BATCH_CALLOUTS_COUNT) { return GRPC_ERROR_NONE; } - if (GPR_LIKELY(batch->idx.array[idx] == nullptr)) { - ++batch->list.default_count; - batch->idx.array[idx] = storage; - return GRPC_ERROR_NONE; - } - return grpc_attach_md_to_error( - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unallowed duplicate metadata"), - storage->md); + return link_callout(batch, storage, idx); } static void maybe_unlink_callout(grpc_metadata_batch* batch, @@ -122,21 +132,21 @@ static void maybe_unlink_callout(grpc_metadata_batch* batch, return; } --batch->list.default_count; - GPR_ASSERT(batch->idx.array[idx] != nullptr); + GPR_DEBUG_ASSERT(batch->idx.array[idx] != nullptr); batch->idx.array[idx] = nullptr; } grpc_error* grpc_metadata_batch_add_head(grpc_metadata_batch* batch, grpc_linked_mdelem* storage, grpc_mdelem elem_to_add) { - GPR_ASSERT(!GRPC_MDISNULL(elem_to_add)); + GPR_DEBUG_ASSERT(!GRPC_MDISNULL(elem_to_add)); storage->md = elem_to_add; return grpc_metadata_batch_link_head(batch, storage); } static void link_head(grpc_mdelem_list* list, grpc_linked_mdelem* storage) { assert_valid_list(list); - GPR_ASSERT(!GRPC_MDISNULL(storage->md)); + GPR_DEBUG_ASSERT(!GRPC_MDISNULL(storage->md)); storage->prev = nullptr; storage->next = list->head; storage->reserved = nullptr; @@ -163,17 +173,35 @@ grpc_error* grpc_metadata_batch_link_head(grpc_metadata_batch* batch, return GRPC_ERROR_NONE; } +// TODO(arjunroy): Need to revisit this and see what guarantees exist between +// C-core and the internal-metadata subsystem. E.g. can we ensure a particular +// metadata is never added twice, even in the presence of user supplied data? +grpc_error* grpc_metadata_batch_link_head( + grpc_metadata_batch* batch, grpc_linked_mdelem* storage, + grpc_metadata_batch_callouts_index idx) { + GPR_DEBUG_ASSERT(GRPC_BATCH_INDEX_OF(GRPC_MDKEY(storage->md)) == idx); + assert_valid_callouts(batch); + grpc_error* err = link_callout(batch, storage, idx); + if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) { + assert_valid_callouts(batch); + return err; + } + link_head(&batch->list, storage); + assert_valid_callouts(batch); + return GRPC_ERROR_NONE; +} + grpc_error* grpc_metadata_batch_add_tail(grpc_metadata_batch* batch, grpc_linked_mdelem* storage, grpc_mdelem elem_to_add) { - GPR_ASSERT(!GRPC_MDISNULL(elem_to_add)); + GPR_DEBUG_ASSERT(!GRPC_MDISNULL(elem_to_add)); storage->md = elem_to_add; return grpc_metadata_batch_link_tail(batch, storage); } static void link_tail(grpc_mdelem_list* list, grpc_linked_mdelem* storage) { assert_valid_list(list); - GPR_ASSERT(!GRPC_MDISNULL(storage->md)); + GPR_DEBUG_ASSERT(!GRPC_MDISNULL(storage->md)); storage->prev = list->tail; storage->next = nullptr; storage->reserved = nullptr; @@ -200,6 +228,21 @@ grpc_error* grpc_metadata_batch_link_tail(grpc_metadata_batch* batch, return GRPC_ERROR_NONE; } +grpc_error* grpc_metadata_batch_link_tail( + grpc_metadata_batch* batch, grpc_linked_mdelem* storage, + grpc_metadata_batch_callouts_index idx) { + GPR_DEBUG_ASSERT(GRPC_BATCH_INDEX_OF(GRPC_MDKEY(storage->md)) == idx); + assert_valid_callouts(batch); + grpc_error* err = link_callout(batch, storage, idx); + if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) { + assert_valid_callouts(batch); + return err; + } + link_tail(&batch->list, storage); + assert_valid_callouts(batch); + return GRPC_ERROR_NONE; +} + static void unlink_storage(grpc_mdelem_list* list, grpc_linked_mdelem* storage) { assert_valid_list(list); @@ -226,6 +269,18 @@ void grpc_metadata_batch_remove(grpc_metadata_batch* batch, assert_valid_callouts(batch); } +void grpc_metadata_batch_remove(grpc_metadata_batch* batch, + grpc_metadata_batch_callouts_index idx) { + assert_valid_callouts(batch); + grpc_linked_mdelem* storage = batch->idx.array[idx]; + GPR_DEBUG_ASSERT(storage != nullptr); + --batch->list.default_count; + batch->idx.array[idx] = nullptr; + unlink_storage(&batch->list, storage); + GRPC_MDELEM_UNREF(storage->md); + assert_valid_callouts(batch); +} + void grpc_metadata_batch_set_value(grpc_linked_mdelem* storage, const grpc_slice& value) { grpc_mdelem old_mdelem = storage->md; @@ -313,13 +368,14 @@ void grpc_metadata_batch_copy(grpc_metadata_batch* src, size_t i = 0; for (grpc_linked_mdelem* elem = src->list.head; elem != nullptr; elem = elem->next) { - grpc_error* error = grpc_metadata_batch_add_tail(dst, &storage[i++], - GRPC_MDELEM_REF(elem->md)); + // Error unused in non-debug builds. + grpc_error* GRPC_UNUSED error = grpc_metadata_batch_add_tail( + dst, &storage[i++], GRPC_MDELEM_REF(elem->md)); // The only way that grpc_metadata_batch_add_tail() can fail is if // there's a duplicate entry for a callout. However, that can't be // the case here, because we would not have been allowed to create // a source batch that had that kind of conflict. - GPR_ASSERT(error == GRPC_ERROR_NONE); + GPR_DEBUG_ASSERT(error == GRPC_ERROR_NONE); } } diff --git a/src/core/lib/transport/metadata_batch.h b/src/core/lib/transport/metadata_batch.h index d87a8b0886d..46a437e4f1b 100644 --- a/src/core/lib/transport/metadata_batch.h +++ b/src/core/lib/transport/metadata_batch.h @@ -67,6 +67,8 @@ size_t grpc_metadata_batch_size(grpc_metadata_batch* batch); /** Remove \a storage from the batch, unreffing the mdelem contained */ void grpc_metadata_batch_remove(grpc_metadata_batch* batch, grpc_linked_mdelem* storage); +void grpc_metadata_batch_remove(grpc_metadata_batch* batch, + grpc_metadata_batch_callouts_index idx); /** Substitute a new mdelem for an old value */ grpc_error* grpc_metadata_batch_substitute(grpc_metadata_batch* batch, @@ -84,6 +86,9 @@ void grpc_metadata_batch_set_value(grpc_linked_mdelem* storage, grpc_error* grpc_metadata_batch_link_head(grpc_metadata_batch* batch, grpc_linked_mdelem* storage) GRPC_MUST_USE_RESULT; +grpc_error* grpc_metadata_batch_link_head( + grpc_metadata_batch* batch, grpc_linked_mdelem* storage, + grpc_metadata_batch_callouts_index idx) GRPC_MUST_USE_RESULT; /** Add \a storage to the end of \a batch. storage->md is assumed to be valid. @@ -93,6 +98,9 @@ grpc_error* grpc_metadata_batch_link_head(grpc_metadata_batch* batch, grpc_error* grpc_metadata_batch_link_tail(grpc_metadata_batch* batch, grpc_linked_mdelem* storage) GRPC_MUST_USE_RESULT; +grpc_error* grpc_metadata_batch_link_tail( + grpc_metadata_batch* batch, grpc_linked_mdelem* storage, + grpc_metadata_batch_callouts_index idx) GRPC_MUST_USE_RESULT; /** Add \a elem_to_add as the first element in \a batch, using \a storage as backing storage for the linked list element. @@ -104,6 +112,22 @@ grpc_error* grpc_metadata_batch_add_head( grpc_metadata_batch* batch, grpc_linked_mdelem* storage, grpc_mdelem elem_to_add) GRPC_MUST_USE_RESULT; +// TODO(arjunroy, roth): Remove redundant methods. +// add/link_head/tail are almost identical. +inline grpc_error* GRPC_MUST_USE_RESULT grpc_metadata_batch_add_head( + grpc_metadata_batch* batch, grpc_linked_mdelem* storage, + grpc_metadata_batch_callouts_index idx) { + return grpc_metadata_batch_link_head(batch, storage, idx); +} + +inline grpc_error* GRPC_MUST_USE_RESULT grpc_metadata_batch_add_head( + grpc_metadata_batch* batch, grpc_linked_mdelem* storage, + grpc_mdelem elem_to_add, grpc_metadata_batch_callouts_index idx) { + GPR_DEBUG_ASSERT(!GRPC_MDISNULL(elem_to_add)); + storage->md = elem_to_add; + return grpc_metadata_batch_add_head(batch, storage, idx); +} + /** Add \a elem_to_add as the last element in \a batch, using \a storage as backing storage for the linked list element. \a storage is owned by the caller and must survive for the @@ -114,6 +138,20 @@ grpc_error* grpc_metadata_batch_add_tail( grpc_metadata_batch* batch, grpc_linked_mdelem* storage, grpc_mdelem elem_to_add) GRPC_MUST_USE_RESULT; +inline grpc_error* GRPC_MUST_USE_RESULT grpc_metadata_batch_add_tail( + grpc_metadata_batch* batch, grpc_linked_mdelem* storage, + grpc_metadata_batch_callouts_index idx) { + return grpc_metadata_batch_link_tail(batch, storage, idx); +} + +inline grpc_error* GRPC_MUST_USE_RESULT grpc_metadata_batch_add_tail( + grpc_metadata_batch* batch, grpc_linked_mdelem* storage, + grpc_mdelem elem_to_add, grpc_metadata_batch_callouts_index idx) { + GPR_DEBUG_ASSERT(!GRPC_MDISNULL(elem_to_add)); + storage->md = elem_to_add; + return grpc_metadata_batch_add_tail(batch, storage, idx); +} + grpc_error* grpc_attach_md_to_error(grpc_error* src, grpc_mdelem md); typedef struct { diff --git a/src/cpp/ext/filters/census/client_filter.cc b/src/cpp/ext/filters/census/client_filter.cc index 0f69e793551..45a883c45b8 100644 --- a/src/cpp/ext/filters/census/client_filter.cc +++ b/src/cpp/ext/filters/census/client_filter.cc @@ -94,7 +94,8 @@ void CensusClientCallData::StartTransportStreamOpBatch( op->send_initial_metadata()->batch(), &tracing_bin_, grpc_mdelem_from_slices( GRPC_MDSTR_GRPC_TRACE_BIN, - grpc_core::UnmanagedMemorySlice(tracing_buf_, tracing_len)))); + grpc_core::UnmanagedMemorySlice(tracing_buf_, tracing_len)), + GRPC_BATCH_GRPC_TRACE_BIN)); } grpc_slice tags = grpc_empty_slice(); // TODO: Add in tagging serialization. @@ -104,7 +105,8 @@ void CensusClientCallData::StartTransportStreamOpBatch( "census grpc_filter", grpc_metadata_batch_add_tail( op->send_initial_metadata()->batch(), &stats_bin_, - grpc_mdelem_from_slices(GRPC_MDSTR_GRPC_TAGS_BIN, tags))); + grpc_mdelem_from_slices(GRPC_MDSTR_GRPC_TAGS_BIN, tags), + GRPC_BATCH_GRPC_TAGS_BIN)); } } diff --git a/src/cpp/ext/filters/census/server_filter.cc b/src/cpp/ext/filters/census/server_filter.cc index 603d1f90bbb..09ceb9f1da8 100644 --- a/src/cpp/ext/filters/census/server_filter.cc +++ b/src/cpp/ext/filters/census/server_filter.cc @@ -50,12 +50,12 @@ void FilterInitialMetadata(grpc_metadata_batch* b, if (b->idx.named.grpc_trace_bin != nullptr) { sml->tracing_slice = grpc_slice_ref_internal(GRPC_MDVALUE(b->idx.named.grpc_trace_bin->md)); - grpc_metadata_batch_remove(b, b->idx.named.grpc_trace_bin); + grpc_metadata_batch_remove(b, GRPC_BATCH_GRPC_TRACE_BIN); } if (b->idx.named.grpc_tags_bin != nullptr) { sml->census_proto = grpc_slice_ref_internal(GRPC_MDVALUE(b->idx.named.grpc_tags_bin->md)); - grpc_metadata_batch_remove(b, b->idx.named.grpc_tags_bin); + grpc_metadata_batch_remove(b, GRPC_BATCH_GRPC_TAGS_BIN); } } @@ -155,7 +155,8 @@ void CensusServerCallData::StartTransportStreamOpBatch( op->send_trailing_metadata()->batch(), &census_bin_, grpc_mdelem_from_slices( GRPC_MDSTR_GRPC_SERVER_STATS_BIN, - grpc_core::UnmanagedMemorySlice(stats_buf_, len)))); + grpc_core::UnmanagedMemorySlice(stats_buf_, len)), + GRPC_BATCH_GRPC_SERVER_STATS_BIN)); } } // Call next op. From 43bf44469dd022503a9c79525d6cbb4ea572e486 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 13 Aug 2019 13:11:02 -0700 Subject: [PATCH 1244/1555] Make map's compare to use const --- .../lb_policy/xds/xds_client_stats.h | 2 +- src/core/lib/gprpp/map.h | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h b/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h index 8f04272da75..6e8dd961ea9 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h @@ -37,7 +37,7 @@ class XdsLocalityName : public RefCounted { public: struct Less { bool operator()(const RefCountedPtr& lhs, - const RefCountedPtr& rhs) { + const RefCountedPtr& rhs) const { int cmp_result = strcmp(lhs->region_.get(), rhs->region_.get()); if (cmp_result != 0) return cmp_result < 0; cmp_result = strcmp(lhs->zone_.get(), rhs->zone_.get()); diff --git a/src/core/lib/gprpp/map.h b/src/core/lib/gprpp/map.h index d133a89fb43..8f0a26146b1 100644 --- a/src/core/lib/gprpp/map.h +++ b/src/core/lib/gprpp/map.h @@ -37,14 +37,15 @@ struct StringLess { bool operator()(const char* a, const char* b) const { return strcmp(a, b) < 0; } - bool operator()(const UniquePtr& k1, const UniquePtr& k2) { + bool operator()(const UniquePtr& k1, const UniquePtr& k2) const { return strcmp(k1.get(), k2.get()) < 0; } }; template struct RefCountedPtrLess { - bool operator()(const RefCountedPtr& p1, const RefCountedPtr& p2) { + bool operator()(const RefCountedPtr& p1, + const RefCountedPtr& p2) const { return p1.get() < p2.get(); } }; @@ -117,7 +118,11 @@ class Map { iterator end() { return iterator(this, nullptr); } iterator lower_bound(const Key& k) { - key_compare compare; + // This is a workaround for "const key_compare compare;" + // because some versions of compilers cannot build this by requiring + // a user-provided constructor. (ref: https://stackoverflow.com/q/7411515) + key_compare compare_tmp; + const key_compare& compare = compare_tmp; return std::find_if(begin(), end(), [&k, &compare](const value_type& v) { return !compare(v.first, k); }); @@ -448,7 +453,11 @@ Map::RemoveRecursive(Entry* root, const key_type& k) { template int Map::CompareKeys(const key_type& lhs, const key_type& rhs) { - key_compare compare; + // This is a workaround for "const key_compare compare;" + // because some versions of compilers cannot build this by requiring + // a user-provided constructor. (ref: https://stackoverflow.com/q/7411515) + key_compare compare_tmp; + const key_compare& compare = compare_tmp; bool left_comparison = compare(lhs, rhs); bool right_comparison = compare(rhs, lhs); // Both values are equal From fd106bf1ac940625795b221fa0a039a6bd1d31d5 Mon Sep 17 00:00:00 2001 From: yang-g Date: Wed, 14 Aug 2019 12:38:59 -0700 Subject: [PATCH 1245/1555] Add accessor declaration for ClientContext --- include/grpcpp/impl/codegen/client_context_impl.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/grpcpp/impl/codegen/client_context_impl.h b/include/grpcpp/impl/codegen/client_context_impl.h index 638ea641bed..7a543055b4b 100644 --- a/include/grpcpp/impl/codegen/client_context_impl.h +++ b/include/grpcpp/impl/codegen/client_context_impl.h @@ -85,6 +85,7 @@ class ClientCallbackReaderImpl; template class ClientCallbackWriterImpl; class ClientCallbackUnaryImpl; +class ClientContextAccessor; } // namespace internal class CallCredentials; @@ -424,6 +425,7 @@ class ClientContext { template friend class ::grpc_impl::internal::ClientCallbackWriterImpl; friend class ::grpc_impl::internal::ClientCallbackUnaryImpl; + friend class ::grpc_impl::internal::ClientContextAccessor; // Used by friend class CallOpClientRecvStatus void set_debug_error_string(const grpc::string& debug_error_string) { From cb6a8ae0d2d03bd2fe3e288b54d6ca4731237b13 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 14 Aug 2019 13:31:36 -0700 Subject: [PATCH 1246/1555] Added experimental wrappers for importing to Google3 --- src/objective-c/examples/BUILD | 11 ++++++++--- .../grpc_objc_internal_library.bzl | 19 ++++++++++++++++--- src/objective-c/tests/BUILD | 8 +++++--- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/objective-c/examples/BUILD b/src/objective-c/examples/BUILD index 4f333cd7502..6689a5a28b8 100644 --- a/src/objective-c/examples/BUILD +++ b/src/objective-c/examples/BUILD @@ -15,20 +15,25 @@ # limitations under the License. -load("//src/objective-c:grpc_objc_internal_library.bzl", "local_objc_grpc_library") +load( + "//src/objective-c:grpc_objc_internal_library.bzl", + "local_objc_grpc_library", + "proto_library_objc_wrapper", +) load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application") load("@build_bazel_rules_apple//apple:tvos.bzl", "tvos_application") load("@build_bazel_rules_apple//apple:watchos.bzl", "watchos_application", "watchos_extension") -proto_library( +proto_library_objc_wrapper( name = "messages_proto", srcs = ["RemoteTestClient/messages.proto"], ) -proto_library( +proto_library_objc_wrapper( name = "test_proto", srcs = ["RemoteTestClient/test.proto"], deps = [":messages_proto"], + use_well_known_protos = True, ) # use objc_grpc_library in bazel:objc_grpc_library.bzl when developing outside the repo diff --git a/src/objective-c/grpc_objc_internal_library.bzl b/src/objective-c/grpc_objc_internal_library.bzl index 51206c1e903..7035e963b94 100644 --- a/src/objective-c/grpc_objc_internal_library.bzl +++ b/src/objective-c/grpc_objc_internal_library.bzl @@ -30,7 +30,20 @@ load( "generate_objc_srcs", "generate_objc_non_arc_srcs" ) -load("//bazel:protobuf.bzl", "well_known_proto_libs") + +def proto_library_objc_wrapper( + name, + srcs, + deps = [], + use_well_known_protos = False): + """proto_library for adding dependencies to google/protobuf protos + use_well_known_protos - ignored in open source version + """ + native.proto_library( + name = name, + srcs = srcs, + deps = deps, + ) def grpc_objc_testing_library( name, @@ -53,7 +66,7 @@ def grpc_objc_testing_library( includes: added to search path, always [the path to objc directory] deps: dependencies """ - + additional_deps = [ ":RemoteTest", "//src/objective-c:grpc_objc_client_internal_testing", @@ -61,7 +74,7 @@ def grpc_objc_testing_library( if not name == "TestConfigs": additional_deps += [":TestConfigs"] - + native.objc_library( name = name, hdrs = hdrs, diff --git a/src/objective-c/tests/BUILD b/src/objective-c/tests/BUILD index 80c12fba548..2d0a57ac21d 100644 --- a/src/objective-c/tests/BUILD +++ b/src/objective-c/tests/BUILD @@ -21,7 +21,8 @@ package(default_visibility = ["//visibility:private"]) load( "//src/objective-c:grpc_objc_internal_library.bzl", "grpc_objc_testing_library", - "local_objc_grpc_library" + "local_objc_grpc_library", + "proto_library_objc_wrapper", ) load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle") load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application", "ios_unit_test") @@ -30,15 +31,16 @@ load("@build_bazel_rules_apple//apple:tvos.bzl", "tvos_application", "tvos_unit_ exports_files(["LICENSE"]) -proto_library( +proto_library_objc_wrapper( name = "messages_proto", srcs = ["RemoteTestClient/messages.proto"], ) -proto_library( +proto_library_objc_wrapper( name = "test_proto", srcs = ["RemoteTestClient/test.proto"], deps = [":messages_proto"], + use_well_known_protos = True, ) local_objc_grpc_library( From 5de502528f08a7e3d16b9fb3af04eb579d3e86eb Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 14 Aug 2019 15:39:40 -0700 Subject: [PATCH 1247/1555] Add license --- src/objective-c/examples/BUILD | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/objective-c/examples/BUILD b/src/objective-c/examples/BUILD index 6689a5a28b8..3e25c5c7dfa 100644 --- a/src/objective-c/examples/BUILD +++ b/src/objective-c/examples/BUILD @@ -14,6 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +licenses(["notice"]) # 3-clause BSD + +package(default_visibility = ["//visibility:public"]) load( "//src/objective-c:grpc_objc_internal_library.bzl", From a01edec47a8bbb6f34e65af3090a636864a16c8a Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 14 Aug 2019 17:24:51 -0700 Subject: [PATCH 1248/1555] Added helloworld sample with Bazel build --- examples/objective-c/BUILD | 57 ++++++++++++++++++++++++++ examples/objective-c/helloworld/main.m | 4 ++ 2 files changed, 61 insertions(+) create mode 100644 examples/objective-c/BUILD diff --git a/examples/objective-c/BUILD b/examples/objective-c/BUILD new file mode 100644 index 00000000000..5dc61ea970f --- /dev/null +++ b/examples/objective-c/BUILD @@ -0,0 +1,57 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +licenses(["notice"]) # 3-clause BSD + +package(default_visibility = ["//visibility:public"]) + +load("@com_github_grpc_grpc//bazel:objc_grpc_library.bzl", "objc_grpc_library") +load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application") + +objc_grpc_library( + name = "HelloWorld_grpc_proto", + srcs = ["//examples:protos/helloworld.proto"], + deps = ["//examples:helloworld_proto"], +) + +# This one works with import "external/com_github_grpc_grpc/examples/protos/Helloworld.pbrpc.h" +objc_grpc_library( + name = "HelloWorld_grpc_proto_external", + srcs = ["//external/com_github_grpc_grpc/examples:protos/helloworld.proto"], + deps = ["@com_github_grpc_grpc//examples:helloworld_proto"], +) + +objc_library( + name = "HelloWorld-lib", + srcs = glob(["helloworld/**/*.m",]), + hdrs = glob(["helloworld/**/*.h"]), + data = glob([ + "helloworld/HelloWorld/Base.lproj/**", + "helloworld/HelloWorld/Images.xcassets/**", + ]), + includes = ["helloworld/HelloWorld"], + deps = [":HelloWorld_grpc_proto"], +) + +ios_application( + name = "HelloWorld", + bundle_id = "Google.HelloWorld", + families = [ + "iphone", + "ipad", + ], + minimum_os_version = "8.0", + infoplists = ["helloworld/HelloWorld/Info.plist"], + deps = [":HelloWorld-lib"], +) diff --git a/examples/objective-c/helloworld/main.m b/examples/objective-c/helloworld/main.m index 649e65bb5b2..d193af862ba 100644 --- a/examples/objective-c/helloworld/main.m +++ b/examples/objective-c/helloworld/main.m @@ -21,7 +21,11 @@ #import #import +#if COCOAPODS #import +#else +#import "examples/protos/Helloworld.pbrpc.h" +#endif static NSString * const kHostAddress = @"localhost:50051"; From f4037db1fb825c01896471aef32991d683a3ed29 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 14 Aug 2019 17:47:57 -0700 Subject: [PATCH 1249/1555] Added manual tag and buildtest example --- examples/objective-c/BUILD | 4 ++++ test/build_test/BUILD | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 test/build_test/BUILD diff --git a/examples/objective-c/BUILD b/examples/objective-c/BUILD index 5dc61ea970f..9ceaaa9a8b4 100644 --- a/examples/objective-c/BUILD +++ b/examples/objective-c/BUILD @@ -23,6 +23,7 @@ objc_grpc_library( name = "HelloWorld_grpc_proto", srcs = ["//examples:protos/helloworld.proto"], deps = ["//examples:helloworld_proto"], + tags = ["manual"], ) # This one works with import "external/com_github_grpc_grpc/examples/protos/Helloworld.pbrpc.h" @@ -30,6 +31,7 @@ objc_grpc_library( name = "HelloWorld_grpc_proto_external", srcs = ["//external/com_github_grpc_grpc/examples:protos/helloworld.proto"], deps = ["@com_github_grpc_grpc//examples:helloworld_proto"], + tags = ["manual"], ) objc_library( @@ -42,6 +44,7 @@ objc_library( ]), includes = ["helloworld/HelloWorld"], deps = [":HelloWorld_grpc_proto"], + tags = ["manual"], ) ios_application( @@ -54,4 +57,5 @@ ios_application( minimum_os_version = "8.0", infoplists = ["helloworld/HelloWorld/Info.plist"], deps = [":HelloWorld-lib"], + tags = ["manual"], ) diff --git a/test/build_test/BUILD b/test/build_test/BUILD new file mode 100644 index 00000000000..90777266a14 --- /dev/null +++ b/test/build_test/BUILD @@ -0,0 +1,28 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +licenses(["notice"]) + +package(default_visibility = ["//visibility:public"]) + +load("@bazel_skylib//rules:build_test.bzl", "build_test") + +# build test //test/build_test:objective_c_examples_test +build_test( + name = "objective_c_examples_test", + targets = [ + "//examples/objective-c:HelloWorld", + ], + tags = ["manual"], +) \ No newline at end of file From 20b085e3142768e23d60c909a4ddd0971ecd3b94 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 14 Aug 2019 18:42:16 -0700 Subject: [PATCH 1250/1555] Passing kwargs --- bazel/objc_grpc_library.bzl | 1 + 1 file changed, 1 insertion(+) diff --git a/bazel/objc_grpc_library.bzl b/bazel/objc_grpc_library.bzl index 7647ab08053..71538843589 100644 --- a/bazel/objc_grpc_library.bzl +++ b/bazel/objc_grpc_library.bzl @@ -64,5 +64,6 @@ def objc_grpc_library(name, deps, srcs = [], use_well_known_protos = False, **kw "@com_github_grpc_grpc//src/objective-c:proto_objc_rpc", "@com_google_protobuf//:protobuf_objc", ], + **kwargs ) From 141c2d24d1e0031842333d63d66c4c4eeff498a9 Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Wed, 7 Aug 2019 14:28:46 -0700 Subject: [PATCH 1251/1555] Add support for running C++ tests on iOS --- bazel/grpc_build_system.bzl | 34 +++ src/proto/grpc/testing/BUILD | 2 - test/cpp/end2end/BUILD | 16 +- test/cpp/end2end/filter_end2end_test.cc | 11 +- test/cpp/util/BUILD | 4 +- .../objective_c/google_toolbox_for_mac/BUILD | 31 +++ .../UnitTesting/GTMGoogleTestRunner.mm | 233 ++++++++++++++++++ .../macos/grpc_bazel_cpp_ios_tests.cfg | 19 ++ .../macos/grpc_run_bazel_cpp_ios_tests.sh | 39 +++ 9 files changed, 380 insertions(+), 9 deletions(-) create mode 100644 third_party/objective_c/google_toolbox_for_mac/BUILD create mode 100644 third_party/objective_c/google_toolbox_for_mac/UnitTesting/GTMGoogleTestRunner.mm create mode 100644 tools/internal_ci/macos/grpc_bazel_cpp_ios_tests.cfg create mode 100644 tools/internal_ci/macos/grpc_run_bazel_cpp_ios_tests.sh diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 7111b5b8c34..390624f3785 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -26,6 +26,8 @@ load("//bazel:cc_grpc_library.bzl", "cc_grpc_library") load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle") load("@upb//bazel:upb_proto_library.bzl", "upb_proto_library") +load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test") + # The set of pollers to test against if a test exercises polling POLLERS = ["epollex", "epoll1", "poll"] @@ -137,6 +139,32 @@ def grpc_proto_library( use_external = use_external, generate_mocks = generate_mocks, ) +def ios_cc_test( + name, + tags = [], + **kwargs): + ios_test_adapter = "//third_party/objective_c/google_toolbox_for_mac:GTM_GoogleTestRunner_GTM_USING_XCTEST"; + + test_lib_ios = name + "_test_lib_ios" + ios_tags = tags + ["manual", "ios_cc_test"] + if not any([t for t in tags if t.startswith("no_test_ios")]): + native.objc_library( + name = test_lib_ios, + srcs = kwargs.get("srcs"), + deps = kwargs.get("deps"), + copts = kwargs.get("copts"), + tags = ios_tags, + alwayslink = 1, + testonly = 1, + ) + ios_test_deps = [ios_test_adapter, ":" + test_lib_ios] + ios_unit_test( + name = name + "_on_ios", + size = kwargs.get("size"), + tags = ios_tags, + minimum_os_version = "9.0", + deps = ios_test_deps, + ) def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data = [], uses_polling = True, language = "C++", size = "medium", timeout = None, tags = [], exec_compatible_with = []): copts = if_mac(["-DGRPC_CFSTREAM"]) @@ -183,6 +211,12 @@ def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data ) else: native.cc_test(tags = tags, **args) + ios_cc_test( + name = name, + tags = tags, + **args + ) + def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], data = [], language = "C++", testonly = False, linkshared = False, linkopts = [], tags = []): copts = [] diff --git a/src/proto/grpc/testing/BUILD b/src/proto/grpc/testing/BUILD index 15be8227de1..8bea8ed7ca0 100644 --- a/src/proto/grpc/testing/BUILD +++ b/src/proto/grpc/testing/BUILD @@ -50,7 +50,6 @@ grpc_proto_library( grpc_proto_library( name = "echo_messages_proto", srcs = ["echo_messages.proto"], - has_services = False, ) grpc_proto_library( @@ -145,7 +144,6 @@ grpc_proto_library( grpc_proto_library( name = "simple_messages_proto", srcs = ["simple_messages.proto"], - has_services = False, ) grpc_proto_library( diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD index f3cc14cb848..5567170d371 100644 --- a/test/cpp/end2end/BUILD +++ b/test/cpp/end2end/BUILD @@ -78,6 +78,7 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], + tags = ["no_test_ios"], ) grpc_cc_test( @@ -89,7 +90,7 @@ grpc_cc_test( external_deps = [ "gtest", ], - tags = ["no_windows"], + tags = ["no_windows", "no_test_ios"], deps = [ ":test_service_impl", "//:gpr", @@ -121,6 +122,7 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], + tags = ["no_test_ios"], ) grpc_cc_binary( @@ -163,6 +165,7 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], + tags = ["no_test_ios"], ) grpc_cc_test( @@ -437,6 +440,7 @@ grpc_cc_test( "//test/core/util:test_lb_policies", "//test/cpp/util:test_util", ], + tags = ["no_test_ios"], ) grpc_cc_test( @@ -477,6 +481,7 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], + tags = ["no_test_ios"], ) grpc_cc_test( @@ -499,6 +504,7 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], + tags = ["no_test_ios"], ) grpc_cc_test( @@ -561,6 +567,7 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], + tags = ["no_test_ios"], ) grpc_cc_binary( @@ -614,6 +621,7 @@ grpc_cc_test( "//src/proto/grpc/testing:echo_proto", "//test/cpp/util:test_util", ], + tags = ["no_test_ios"], ) grpc_cc_test( @@ -622,7 +630,7 @@ grpc_cc_test( external_deps = [ "gtest", ], - tags = ["manual"], + tags = ["manual", "no_test_ios"], deps = [ ":test_service_impl", "//:gpr", @@ -689,6 +697,7 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], + tags = ["no_test_ios"], ) grpc_cc_test( @@ -697,7 +706,7 @@ grpc_cc_test( external_deps = [ "gtest", ], - tags = ["manual"], # test requires root, won't work with bazel RBE + tags = ["manual", "no_test_ios"], # test requires root, won't work with bazel RBE deps = [ ":test_service_impl", "//:gpr", @@ -746,4 +755,5 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], + tags = ["no_test_ios"], ) diff --git a/test/cpp/end2end/filter_end2end_test.cc b/test/cpp/end2end/filter_end2end_test.cc index e96825c33eb..a224d6596a3 100644 --- a/test/cpp/end2end/filter_end2end_test.cc +++ b/test/cpp/end2end/filter_end2end_test.cc @@ -122,9 +122,14 @@ class FilterEnd2endTest : public ::testing::Test { FilterEnd2endTest() : server_host_("localhost") {} static void SetUpTestCase() { - gpr_log(GPR_ERROR, "In SetUpTestCase"); - grpc::RegisterChannelFilter( - "test-filter", GRPC_SERVER_CHANNEL, INT_MAX, nullptr); + // Workaround for + // https://github.com/google/google-toolbox-for-mac/issues/242 + static bool setup_done = false; + if (!setup_done) { + setup_done = true; + grpc::RegisterChannelFilter( + "test-filter", GRPC_SERVER_CHANNEL, INT_MAX, nullptr); + } } void SetUp() override { diff --git a/test/cpp/util/BUILD b/test/cpp/util/BUILD index d112611ef35..858b88eb01b 100644 --- a/test/cpp/util/BUILD +++ b/test/cpp/util/BUILD @@ -187,7 +187,9 @@ grpc_cc_test( external_deps = [ "gtest", ], - tags = ["nomsan"], # death tests seem to be incompatible with msan + tags = ["nomsan", # death tests seem to be incompatible with msan + "no_test_ios" + ], deps = [ ":grpc_cli_libs", ":test_util", diff --git a/third_party/objective_c/google_toolbox_for_mac/BUILD b/third_party/objective_c/google_toolbox_for_mac/BUILD new file mode 100644 index 00000000000..dc505f30fc3 --- /dev/null +++ b/third_party/objective_c/google_toolbox_for_mac/BUILD @@ -0,0 +1,31 @@ +# gRPC Bazel BUILD file. +# +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +licenses(["notice"]) +native.objc_library( + name = "GTM_GoogleTestRunner_GTM_USING_XCTEST", + testonly = 1, + srcs = [ + "UnitTesting/GTMGoogleTestRunner.mm", + ], + copts = [ + "-DGTM_USING_XCTEST", + ], + deps = [ + "//external:gtest", + ], + visibility = ["//visibility:public"] +) diff --git a/third_party/objective_c/google_toolbox_for_mac/UnitTesting/GTMGoogleTestRunner.mm b/third_party/objective_c/google_toolbox_for_mac/UnitTesting/GTMGoogleTestRunner.mm new file mode 100644 index 00000000000..3e8e9245fd4 --- /dev/null +++ b/third_party/objective_c/google_toolbox_for_mac/UnitTesting/GTMGoogleTestRunner.mm @@ -0,0 +1,233 @@ +// +// GTMGoogleTestRunner.mm +// +// Copyright 2013 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy +// of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. +// + +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + +// This is a SenTest/XCTest based unit test that will run all of the GoogleTest +// https://code.google.com/p/googletest/ +// based tests in the project, and will report results correctly via SenTest so +// that Xcode can pick them up in it's UI. + +// SenTest dynamically creates one SenTest per GoogleTest. +// GoogleTest is set up using a custom event listener (GoogleTestPrinter) +// which knows how to log GoogleTest test results in a manner that SenTest (and +// the Xcode IDE) understand. + +// Note that this does not able you to control individual tests from the Xcode +// UI. You can only turn on/off all of the C++ tests. It does however give +// you output that you can click on in the Xcode UI and immediately jump to a +// test failure. + +// This class is not compiled as part of the standard Google Toolbox For Mac +// project because of it's dependency on https://code.google.com/p/googletest/ + +// To use this: +// - If you are using XCTest (vs SenTest) make sure to define GTM_USING_XCTEST +// in the settings for your testing bundle. +// - Add GTMGoogleTestRunner to your test bundle sources. +// - Add gtest-all.cc from gtest to your test bundle sources. +// - Write some C++ tests and add them to your test bundle sources. +// - Build and run tests. Your C++ tests should just execute. + +// If you are using this with XCTest (as opposed to SenTestingKit) +// make sure to define GTM_USING_XCTEST. +#ifndef GTM_USING_XCTEST +#define GTM_USING_XCTEST 0 +#endif + +#if GTM_USING_XCTEST +#import +#define SenTestCase XCTestCase +#define SenTestSuite XCTestSuite +#else // GTM_USING_XCTEST +#import +#endif // GTM_USING_XCTEST + +#import + +#include + +using ::testing::EmptyTestEventListener; +using ::testing::TestCase; +using ::testing::TestEventListeners; +using ::testing::TestInfo; +using ::testing::TestPartResult; +using ::testing::TestResult; +using ::testing::UnitTest; + +namespace { + +// A gtest printer that takes care of reporting gtest results via the +// SenTest interface. Note that a test suite in SenTest == a test case in gtest +// and a test case in SenTest == a test in gtest. +// This will handle fatal and non-fatal gtests properly. +class GoogleTestPrinter : public EmptyTestEventListener { + public: + GoogleTestPrinter(SenTestCase *test_case) : test_case_(test_case) {} + + virtual ~GoogleTestPrinter() {} + + virtual void OnTestPartResult(const TestPartResult &test_part_result) { + if (!test_part_result.passed()) { + NSString *file = @(test_part_result.file_name()); + int line = test_part_result.line_number(); + NSString *summary = @(test_part_result.summary()); + + // gtest likes to give multi-line summaries. These don't look good in + // the Xcode UI, so we clean them up. + NSString *oneLineSummary = + [summary stringByReplacingOccurrencesOfString:@"\n" withString:@" "]; +#if GTM_USING_XCTEST + BOOL expected = test_part_result.nonfatally_failed(); + [test_case_ recordFailureWithDescription:oneLineSummary + inFile:file + atLine:line + expected:expected]; +#else // GTM_USING_XCTEST + NSException *exception = + [NSException failureInFile:file + atLine:line + withDescription:@"%@", oneLineSummary]; + + // failWithException: will log appropriately. + [test_case_ failWithException:exception]; +#endif // GTM_USING_XCTEST + } + } + + private: + SenTestCase *test_case_; +}; + +NSString *SelectorNameFromGTestName(NSString *testName) { + NSRange dot = [testName rangeOfString:@"."]; + return [NSString stringWithFormat:@"%@::%@", + [testName substringToIndex:dot.location], + [testName substringFromIndex:dot.location + 1]]; +} + +} // namespace + +// GTMGoogleTestRunner is a GTMTestCase that makes a sub test suite populated +// with all of the GoogleTest unit tests. +@interface GTMGoogleTestRunner : SenTestCase { + NSString *testName_; +} + +// The name for a test is the GoogleTest name which is "TestCase.Test" +- (id)initWithName:(NSString *)testName; +@end + +@implementation GTMGoogleTestRunner + ++ (void)initGoogleTest { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSArray *arguments = [NSProcessInfo processInfo].arguments; + int argc = (int)arguments.count; + char **argv = static_cast(alloca((sizeof(char *) * (argc + 1)))); + for (int index = 0; index < argc; index++) { + argv[index] = const_cast ([arguments[index] UTF8String]); + } + argv[argc] = NULL; + + testing::InitGoogleTest(&argc, argv); + }); +} + ++ (id)defaultTestSuite { + [GTMGoogleTestRunner initGoogleTest]; + SenTestSuite *result = + [[SenTestSuite alloc] initWithName:NSStringFromClass(self)]; + UnitTest *test = UnitTest::GetInstance(); + + // Walk the GoogleTest tests, adding sub tests and sub suites as appropriate. + int total_test_case_count = test->total_test_case_count(); + for (int i = 0; i < total_test_case_count; ++i) { + const TestCase *test_case = test->GetTestCase(i); + int total_test_count = test_case->total_test_count(); + SenTestSuite *subSuite = + [[SenTestSuite alloc] initWithName:@(test_case->name())]; + [result addTest:subSuite]; + for (int j = 0; j < total_test_count; ++j) { + const TestInfo *test_info = test_case->GetTestInfo(j); + NSString *testName = [NSString stringWithFormat:@"%s.%s", + test_case->name(), test_info->name()]; + SenTestCase *senTest = [[self alloc] initWithName:testName]; + [subSuite addTest:senTest]; + } + } + return result; +} + +- (id)initWithName:(NSString *)testName { + // Xcode 6.1 started taking the testName from the selector instead of calling + // -name. + // So we will add selectors to GTMGoogleTestRunner. + // They should all be unique because the selectors are named cppclass.method + // Filed as radar 18798444. + Class cls = [self class]; + NSString *selectorTestName = SelectorNameFromGTestName(testName); + SEL selector = sel_registerName([selectorTestName UTF8String]); + Method method = class_getInstanceMethod(cls, @selector(runGoogleTest)); + IMP implementation = method_getImplementation(method); + const char *encoding = method_getTypeEncoding(method); + if (!class_addMethod(cls, selector, implementation, encoding)) { + // If we can't add a method, we should blow up here. + [NSException raise:NSInternalInconsistencyException + format:@"Unable to add %@ to %@.", testName, cls]; + } + if ((self = [super initWithSelector:selector])) { + testName_ = testName; + } + return self; +} + +- (NSString *)name { + // A SenTest name must be "-[foo bar]" or it won't be parsed properly. + NSRange dot = [testName_ rangeOfString:@"."]; + return [NSString stringWithFormat:@"-[%@ %@]", + [testName_ substringToIndex:dot.location], + [testName_ substringFromIndex:dot.location + 1]]; +} + +- (void)runGoogleTest { + [GTMGoogleTestRunner initGoogleTest]; + + // Gets hold of the event listener list. + TestEventListeners& listeners = UnitTest::GetInstance()->listeners(); + + // Adds a listener to the end. Google Test takes the ownership. + listeners.Append(new GoogleTestPrinter(self)); + + // Remove the default printer. + delete listeners.Release(listeners.default_result_printer()); + + // Since there is no way of running a single GoogleTest directly, we use the + // filter mechanism in GoogleTest to simulate it for us. + ::testing::GTEST_FLAG(filter) = [testName_ UTF8String]; + + // Intentionally ignore return value of RUN_ALL_TESTS. We will be printing + // the output appropriately, and there is no reason to mark this test as + // "failed" if RUN_ALL_TESTS returns non-zero. + (void)RUN_ALL_TESTS(); +} + +@end diff --git a/tools/internal_ci/macos/grpc_bazel_cpp_ios_tests.cfg b/tools/internal_ci/macos/grpc_bazel_cpp_ios_tests.cfg new file mode 100644 index 00000000000..ccc27e8fbe5 --- /dev/null +++ b/tools/internal_ci/macos/grpc_bazel_cpp_ios_tests.cfg @@ -0,0 +1,19 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/macos/grpc_run_bazel_cpp_ios_tests.sh" + diff --git a/tools/internal_ci/macos/grpc_run_bazel_cpp_ios_tests.sh b/tools/internal_ci/macos/grpc_run_bazel_cpp_ios_tests.sh new file mode 100644 index 00000000000..bc2a8295521 --- /dev/null +++ b/tools/internal_ci/macos/grpc_run_bazel_cpp_ios_tests.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +# change to grpc repo root +cd $(dirname $0)/../../.. + +# Download bazel +temp_dir="$(mktemp -d)" +wget -q https://github.com/bazelbuild/bazel/releases/download/0.26.0/bazel-0.26.0-darwin-x86_64 -O "${temp_dir}/bazel" +chmod 755 "${temp_dir}/bazel" +export PATH="${temp_dir}:${PATH}" +# This should show ${temp_dir}/bazel +which bazel + +./tools/run_tests/start_port_server.py + +dirs=(end2end server client common codegen util grpclb test) +for dir in ${dirs[*]}; do + echo $dir + out=`bazel query "kind(ios_unit_test, tests(//test/cpp/$dir/...))"` + for test in $out; do + echo "Running: $test" + bazel test --test_summary=detailed --test_output=all $test + done +done From 7422a14a5d95ee637283febdd85fd4ef271b9417 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 14 Aug 2019 16:44:56 -0700 Subject: [PATCH 1252/1555] Added wrapper for objc_library in examples --- src/objective-c/examples/BUILD | 18 ++++------ .../grpc_objc_internal_library.bzl | 35 +++++++++++++++++++ 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/src/objective-c/examples/BUILD b/src/objective-c/examples/BUILD index 3e25c5c7dfa..4d838b17ba0 100644 --- a/src/objective-c/examples/BUILD +++ b/src/objective-c/examples/BUILD @@ -20,6 +20,7 @@ package(default_visibility = ["//visibility:public"]) load( "//src/objective-c:grpc_objc_internal_library.bzl", + "grpc_objc_examples_library", "local_objc_grpc_library", "proto_library_objc_wrapper", ) @@ -41,7 +42,7 @@ proto_library_objc_wrapper( # use objc_grpc_library in bazel:objc_grpc_library.bzl when developing outside the repo local_objc_grpc_library( - name = "test_grpc_objc", + name = "RemoteTest", srcs = ["RemoteTestClient/test.proto"], use_well_known_protos = True, deps = [ @@ -58,7 +59,7 @@ local_objc_grpc_library( ], ) -objc_library( +grpc_objc_examples_library( name = "Sample-lib", srcs = glob(["Sample/Sample/**/*.m"]), hdrs = glob(["Sample/Sample/**/*.h"]), @@ -66,7 +67,6 @@ objc_library( "Sample/Sample/Base.lproj/**", "Sample/Sample/Images.xcassets/**", ]), - deps = [":test_grpc_objc"], ) ios_application( @@ -82,7 +82,7 @@ ios_application( visibility = ["//visibility:public"], ) -objc_library( +grpc_objc_examples_library( name = "InterceptorSample-lib", srcs = glob(["InterceptorSample/InterceptorSample/**/*.m"]), hdrs = glob(["InterceptorSample/InterceptorSample/**/*.h"]), @@ -90,7 +90,6 @@ objc_library( "InterceptorSample/InterceptorSample/Base.lproj/**", "InterceptorSample/InterceptorSample/Images.xcassets/**", ]), - deps = [":test_grpc_objc"], ) ios_application( @@ -105,7 +104,7 @@ ios_application( deps = ["InterceptorSample-lib"], ) -objc_library( +grpc_objc_examples_library( name = "tvOS-sample-lib", srcs = glob(["tvOS-sample/tvOS-sample/**/*.m"]), hdrs = glob(["tvOS-sample/tvOS-sample/**/*.h"]), @@ -113,7 +112,6 @@ objc_library( "tvOS-sample/tvOS-sample/Base.lproj/**", "tvOS-sample/tvOS-sample/Images.xcassets/**", ]), - deps = [":test_grpc_objc"], ) # c-ares does not support tvOS CPU architecture with Bazel yet @@ -125,7 +123,7 @@ tvos_application( deps = [":tvOS-sample-lib"], ) -objc_library( +grpc_objc_examples_library( name = "watchOS-sample-iOS-lib", srcs = glob(["watchOS-sample/watchOS-sample/**/*.m"]), hdrs = glob(["watchOS-sample/watchOS-sample/**/*.h"]), @@ -133,14 +131,12 @@ objc_library( "watchOS-sample/watchOS-sample/Base.lproj/**", "watchOS-sample/watchOS-sample/Images.xcassets/**", ]), - deps = [":test_grpc_objc"], ) -objc_library( +grpc_objc_examples_library( name = "watchOS-sample-extension-lib", srcs = glob(["watchOS-sample/WatchKit-Extention/**/*.m"]), hdrs = glob(["watchOS-sample/WatchKit-Extension/**/*.h"]), - deps = [":test_grpc_objc"], sdk_frameworks = [ "WatchConnectivity", "WatchKit", diff --git a/src/objective-c/grpc_objc_internal_library.bzl b/src/objective-c/grpc_objc_internal_library.bzl index 7035e963b94..c90293d827d 100644 --- a/src/objective-c/grpc_objc_internal_library.bzl +++ b/src/objective-c/grpc_objc_internal_library.bzl @@ -45,6 +45,41 @@ def proto_library_objc_wrapper( deps = deps, ) +def grpc_objc_examples_library( + name, + srcs = [], + hdrs = [], + textual_hdrs = [], + data = [], + deps = [], + defines = [], + sdk_frameworks = [], + includes = []): + """objc_library for testing, only works in //src/objective-c/exmaples + + Args: + name: name of target + hdrs: public headers + srcs: all source files (.m) + textual_hdrs: private headers + data: any other bundle resources + defines: preprocessors + sdk_frameworks: sdks + includes: added to search path, always [the path to objc directory] + deps: dependencies + """ + native.objc_library( + name = name, + srcs = srcs, + hdrs = hdrs, + textual_hdrs = textual_hdrs, + data = data, + defines = defines, + includes = includes, + sdk_frameworks = sdk_frameworks, + deps = deps + [":RemoteTest"], + ) + def grpc_objc_testing_library( name, srcs = [], From b4eefcfc0e4b18c79674c073efa326649f6ec8b3 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 14 Aug 2019 16:47:29 -0700 Subject: [PATCH 1253/1555] Added source of new CPUs --- third_party/cares/cares.BUILD | 2 ++ 1 file changed, 2 insertions(+) diff --git a/third_party/cares/cares.BUILD b/third_party/cares/cares.BUILD index 596dd06f88e..203712b182f 100644 --- a/third_party/cares/cares.BUILD +++ b/third_party/cares/cares.BUILD @@ -44,6 +44,8 @@ config_setting( values = {"cpu": "ios_arm64"}, ) +# The following architectures are found in +# https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/apple/ApplePlatform.java config_setting( name = "tvos_x86_64", values = {"cpu": "tvos_x86_64"}, From eb2ed99a841fd5ec98ed6ad4f9f665cb964e93db Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Wed, 14 Aug 2019 17:07:59 -0700 Subject: [PATCH 1254/1555] Changed visibility to public --- src/objective-c/tests/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/tests/BUILD b/src/objective-c/tests/BUILD index 2d0a57ac21d..d34807f017f 100644 --- a/src/objective-c/tests/BUILD +++ b/src/objective-c/tests/BUILD @@ -16,7 +16,7 @@ licenses(["notice"]) # Apache v2 -package(default_visibility = ["//visibility:private"]) +package(default_visibility = ["//visibility:public"]) load( "//src/objective-c:grpc_objc_internal_library.bzl", From e3f5320ae28c3b73f27a5fd6988ad9d747dcd5b1 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Thu, 15 Aug 2019 16:29:39 +0800 Subject: [PATCH 1255/1555] remove LICENSE and notes file, Modify the identifier name, --- examples/python/easy_start_demo/LICENSE | 373 ------------------ examples/python/easy_start_demo/PyClient.py | 93 ----- examples/python/easy_start_demo/README.md | 2 - examples/python/easy_start_demo/client.py | 98 +++++ examples/python/easy_start_demo/demo.proto | 6 +- .../demo_pb2.py | 16 +- .../demo_pb2_grpc.py | 49 ++- examples/python/easy_start_demo/notes | 3 - .../{PyServer.py => server.py} | 42 +- 9 files changed, 162 insertions(+), 520 deletions(-) delete mode 100644 examples/python/easy_start_demo/LICENSE delete mode 100644 examples/python/easy_start_demo/PyClient.py create mode 100644 examples/python/easy_start_demo/client.py rename examples/python/easy_start_demo/{customGrpcPackages => demo_grpc_pbs}/demo_pb2.py (88%) rename examples/python/easy_start_demo/{customGrpcPackages => demo_grpc_pbs}/demo_pb2_grpc.py (61%) delete mode 100644 examples/python/easy_start_demo/notes rename examples/python/easy_start_demo/{PyServer.py => server.py} (63%) diff --git a/examples/python/easy_start_demo/LICENSE b/examples/python/easy_start_demo/LICENSE deleted file mode 100644 index a612ad9813b..00000000000 --- a/examples/python/easy_start_demo/LICENSE +++ /dev/null @@ -1,373 +0,0 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. diff --git a/examples/python/easy_start_demo/PyClient.py b/examples/python/easy_start_demo/PyClient.py deleted file mode 100644 index 383cdb5afed..00000000000 --- a/examples/python/easy_start_demo/PyClient.py +++ /dev/null @@ -1,93 +0,0 @@ -""" -Author: Zhongying Wang -Email: kerbalwzy@gmail.com -License: MPL2 -DateTime: 2019-08-13T23:30:00Z -PythonVersion: Python3.6.3 -""" -import grpc -import time -from customGrpcPackages import demo_pb2, demo_pb2_grpc - -# Constants -PyGrpcServerAddress = "127.0.0.1:23334" -ClientId = 1 - - -# 简单模式 -# Simple -def simple_method(stub): - print("--------------Call SimpleMethod Begin--------------") - req = demo_pb2.Request(Cid=ClientId, ReqMsg="called by Python client") - resp = stub.SimpleMethod(req) - print(f"resp from server({resp.Sid}), the message={resp.RespMsg}") - print("--------------Call SimpleMethod Over---------------") - - -# 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) -# Request-streaming (In a single call, the client can transfer data to the server several times, -# but the server can only return a response once.) -def c_stream_method(stub): - print("--------------Call CStreamMethod Begin--------------") - - # 创建一个生成器 - # create a generator - def req_msgs(): - for i in range(5): - req = demo_pb2.Request(Cid=ClientId, ReqMsg=f"called by Python client, message: {i}") - yield req - - resp = stub.CStreamMethod(req_msgs()) - print(f"resp from server({resp.Sid}), the message={resp.RespMsg}") - print("--------------Call CStreamMethod Over---------------") - - -# 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) -# Response-streaming (In a single call, the client can only transmit data to the server at one time, -# but the server can return the response many times.) -def s_stream_method(stub): - print("--------------Call SStreamMethod Begin--------------") - req = demo_pb2.Request(Cid=ClientId, ReqMsg="called by Python client") - resp_s = stub.SStreamMethod(req) - for resp in resp_s: - print(f"recv from server({resp.Sid}, message={resp.RespMsg})") - - print("--------------Call SStreamMethod Over---------------") - - -# 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) -# Bidirectional Streaming (In a single call, both client and server can send and receive data -# to each other multiple times.) -def twf_method(stub): - print("--------------Call TWFMethod Begin---------------") - - # 创建一个生成器 - # create a generator - def req_msgs(): - for i in range(5): - req = demo_pb2.Request(Cid=ClientId, ReqMsg=f"called by Python client, message: {i}") - yield req - time.sleep(1) - - resp_s = stub.TWFMethod(req_msgs()) - for resp in resp_s: - print(f"recv from server({resp.Sid}, message={resp.RespMsg})") - - print("--------------Call TWFMethod Over---------------") - - -def main(): - with grpc.insecure_channel(PyGrpcServerAddress) as channel: - stub = demo_pb2_grpc.GRPCDemoStub(channel) - - simple_method(stub) - - c_stream_method(stub) - - s_stream_method(stub) - - twf_method(stub) - - -if __name__ == '__main__': - main() diff --git a/examples/python/easy_start_demo/README.md b/examples/python/easy_start_demo/README.md index 5b8ee8c5b3e..50529c57df5 100644 --- a/examples/python/easy_start_demo/README.md +++ b/examples/python/easy_start_demo/README.md @@ -30,8 +30,6 @@ Author: Zhongying Wang Email: kerbalwzy@gmail.com -License: MPL2 - DateTime: 2019-08-13T23:30:00Z PythonVersion: Python3.6.3 \ No newline at end of file diff --git a/examples/python/easy_start_demo/client.py b/examples/python/easy_start_demo/client.py new file mode 100644 index 00000000000..46d11d05cbf --- /dev/null +++ b/examples/python/easy_start_demo/client.py @@ -0,0 +1,98 @@ +""" +Author: Zhongying Wang +Email: kerbalwzy@gmail.com +DateTime: 2019-08-13T23:30:00Z +PythonVersion: Python3.6.3 +""" +import os +import sys +import time +import grpc + +# add the `demo_grpc_dps` dir into python package search paths +BaseDir = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, os.path.join(BaseDir, "demo_grpc_pbs")) + +from demo_grpc_pbs import demo_pb2, demo_pb2_grpc + +ServerAddress = "127.0.0.1:23334" +ClientId = 1 + + +# 简单模式 +# Simple Method +def simple_method(stub): + print("--------------Call SimpleMethod Begin--------------") + req = demo_pb2.Request(Cid=ClientId, ReqMsg="called by Python client") + resp = stub.SimpleMethod(req) + print("resp from server(%d), the message=%s" % (resp.Sid, resp.RespMsg)) + print("--------------Call SimpleMethod Over---------------") + + +# 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) +# Request-streaming (In a single call, the client can transfer data to the server several times, +# but the server can only return a response once.) +def client_streaming_method(stub): + print("--------------Call ClientStreamingMethod Begin--------------") + + # 创建一个生成器 + # create a generator + def request_messages(): + for i in range(5): + req = demo_pb2.Request(Cid=ClientId, ReqMsg=("called by Python client, message:%d" % i)) + yield req + + resp = stub.ClientStreamingMethod(request_messages()) + print("resp from server(%d), the message=%s" % (resp.Sid, resp.RespMsg)) + print("--------------Call ClientStreamingMethod Over---------------") + + +# 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) +# Response-streaming (In a single call, the client can only transmit data to the server at one time, +# but the server can return the response many times.) +def server_streaming_method(stub): + print("--------------Call ServerStreamingMethod Begin--------------") + req = demo_pb2.Request(Cid=ClientId, ReqMsg="called by Python client") + resp_s = stub.ServerStreamingMethod(req) + for resp in resp_s: + print("recv from server(%d), message=%s" % (resp.Sid, resp.RespMsg)) + + print("--------------Call ServerStreamingMethod Over---------------") + + +# 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) +# Bidirectional Streaming (In a single call, both client and server can send and receive data +# to each other multiple times.) +def bidirectional_streaming_method(stub): + print("--------------Call BidirectionalStreamingMethod Begin---------------") + + # 创建一个生成器 + # create a generator + def req_messages(): + for i in range(5): + req = demo_pb2.Request(Cid=ClientId, ReqMsg=("called by Python client, message: %d" % i)) + yield req + time.sleep(1) + + resp_s = stub.BidirectionalStreamingMethod(req_messages()) + for resp in resp_s: + print("recv from server(%d), message=%s" % (resp.Sid, resp.RespMsg)) + + print("--------------Call BidirectionalStreamingMethod Over---------------") + + +def main(): + with grpc.insecure_channel(ServerAddress) as channel: + stub = demo_pb2_grpc.GRPCDemoStub(channel) + + simple_method(stub) + + client_streaming_method(stub) + + server_streaming_method(stub) + + bidirectional_streaming_method(stub) + + +if __name__ == '__main__': + main() diff --git a/examples/python/easy_start_demo/demo.proto b/examples/python/easy_start_demo/demo.proto index a9506cf92a1..2844ba7b225 100644 --- a/examples/python/easy_start_demo/demo.proto +++ b/examples/python/easy_start_demo/demo.proto @@ -36,16 +36,16 @@ service GRPCDemo { // 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) // Request-streaming (In a single call, the client can transfer data to the server several times, // but the server can only return a response once.) - rpc CStreamMethod (stream Request) returns (Response); + rpc ClientStreamingMethod (stream Request) returns (Response); // 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) // Response-streaming (In a single call, the client can only transmit data to the server at one time, // but the server can return the response many times.) - rpc SStreamMethod (Request) returns (stream Response); + rpc ServerStreamingMethod (Request) returns (stream Response); // 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) // Bidirectional streaming (In a single call, both client and server can send and receive data // to each other multiple times.) - rpc TWFMethod (stream Request) returns (stream Response); + rpc BidirectionalStreamingMethod (stream Request) returns (stream Response); } diff --git a/examples/python/easy_start_demo/customGrpcPackages/demo_pb2.py b/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2.py similarity index 88% rename from examples/python/easy_start_demo/customGrpcPackages/demo_pb2.py rename to examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2.py index 4df1dad0b43..de960c8a6c1 100644 --- a/examples/python/easy_start_demo/customGrpcPackages/demo_pb2.py +++ b/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2.py @@ -20,7 +20,7 @@ DESCRIPTOR = _descriptor.FileDescriptor( package='demo', syntax='proto3', serialized_options=None, - serialized_pb=_b('\n\ndemo.proto\x12\x04\x64\x65mo\"&\n\x07Request\x12\x0b\n\x03\x43id\x18\x01 \x01(\x03\x12\x0e\n\x06ReqMsg\x18\x02 \x01(\t\"(\n\x08Response\x12\x0b\n\x03Sid\x18\x01 \x01(\x03\x12\x0f\n\x07RespMsg\x18\x02 \x01(\t2\xcd\x01\n\x08GRPCDemo\x12-\n\x0cSimpleMethod\x12\r.demo.Request\x1a\x0e.demo.Response\x12\x30\n\rCStreamMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x12\x30\n\rSStreamMethod\x12\r.demo.Request\x1a\x0e.demo.Response0\x01\x12.\n\tTWFMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x30\x01\x62\x06proto3') + serialized_pb=_b('\n\ndemo.proto\x12\x04\x64\x65mo\"&\n\x07Request\x12\x0b\n\x03\x43id\x18\x01 \x01(\x03\x12\x0e\n\x06ReqMsg\x18\x02 \x01(\t\"(\n\x08Response\x12\x0b\n\x03Sid\x18\x01 \x01(\x03\x12\x0f\n\x07RespMsg\x18\x02 \x01(\t2\xf0\x01\n\x08GRPCDemo\x12-\n\x0cSimpleMethod\x12\r.demo.Request\x1a\x0e.demo.Response\x12\x38\n\x15\x43lientStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x12\x38\n\x15ServerStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response0\x01\x12\x41\n\x1c\x42idirectionalStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x30\x01\x62\x06proto3') ) @@ -128,7 +128,7 @@ _GRPCDEMO = _descriptor.ServiceDescriptor( index=0, serialized_options=None, serialized_start=103, - serialized_end=308, + serialized_end=343, methods=[ _descriptor.MethodDescriptor( name='SimpleMethod', @@ -140,8 +140,8 @@ _GRPCDEMO = _descriptor.ServiceDescriptor( serialized_options=None, ), _descriptor.MethodDescriptor( - name='CStreamMethod', - full_name='demo.GRPCDemo.CStreamMethod', + name='ClientStreamingMethod', + full_name='demo.GRPCDemo.ClientStreamingMethod', index=1, containing_service=None, input_type=_REQUEST, @@ -149,8 +149,8 @@ _GRPCDEMO = _descriptor.ServiceDescriptor( serialized_options=None, ), _descriptor.MethodDescriptor( - name='SStreamMethod', - full_name='demo.GRPCDemo.SStreamMethod', + name='ServerStreamingMethod', + full_name='demo.GRPCDemo.ServerStreamingMethod', index=2, containing_service=None, input_type=_REQUEST, @@ -158,8 +158,8 @@ _GRPCDEMO = _descriptor.ServiceDescriptor( serialized_options=None, ), _descriptor.MethodDescriptor( - name='TWFMethod', - full_name='demo.GRPCDemo.TWFMethod', + name='BidirectionalStreamingMethod', + full_name='demo.GRPCDemo.BidirectionalStreamingMethod', index=3, containing_service=None, input_type=_REQUEST, diff --git a/examples/python/easy_start_demo/customGrpcPackages/demo_pb2_grpc.py b/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2_grpc.py similarity index 61% rename from examples/python/easy_start_demo/customGrpcPackages/demo_pb2_grpc.py rename to examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2_grpc.py index 4aaccf1144a..0f7d5dabbd6 100644 --- a/examples/python/easy_start_demo/customGrpcPackages/demo_pb2_grpc.py +++ b/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2_grpc.py @@ -1,12 +1,12 @@ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! import grpc -from . import demo_pb2 as demo__pb2 +import demo_pb2 as demo__pb2 class GRPCDemoStub(object): - """服务service是用来gRPC的方法的, 格式固定 - 类似于Python中定义一个类, 类似于Golang中定义一个接口 + """service是用来给GRPC服务定义方法的, 格式固定, 类似于Golang中定义一个接口 + `service` is used to define methods for GRPC services in a fixed format, similar to defining an interface in Golang """ def __init__(self, channel): @@ -20,51 +20,58 @@ class GRPCDemoStub(object): request_serializer=demo__pb2.Request.SerializeToString, response_deserializer=demo__pb2.Response.FromString, ) - self.CStreamMethod = channel.stream_unary( - '/demo.GRPCDemo/CStreamMethod', + self.ClientStreamingMethod = channel.stream_unary( + '/demo.GRPCDemo/ClientStreamingMethod', request_serializer=demo__pb2.Request.SerializeToString, response_deserializer=demo__pb2.Response.FromString, ) - self.SStreamMethod = channel.unary_stream( - '/demo.GRPCDemo/SStreamMethod', + self.ServerStreamingMethod = channel.unary_stream( + '/demo.GRPCDemo/ServerStreamingMethod', request_serializer=demo__pb2.Request.SerializeToString, response_deserializer=demo__pb2.Response.FromString, ) - self.TWFMethod = channel.stream_stream( - '/demo.GRPCDemo/TWFMethod', + self.BidirectionalStreamingMethod = channel.stream_stream( + '/demo.GRPCDemo/BidirectionalStreamingMethod', request_serializer=demo__pb2.Request.SerializeToString, response_deserializer=demo__pb2.Response.FromString, ) class GRPCDemoServicer(object): - """服务service是用来gRPC的方法的, 格式固定 - 类似于Python中定义一个类, 类似于Golang中定义一个接口 + """service是用来给GRPC服务定义方法的, 格式固定, 类似于Golang中定义一个接口 + `service` is used to define methods for GRPC services in a fixed format, similar to defining an interface in Golang """ def SimpleMethod(self, request, context): """简单模式 + Simple """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') - def CStreamMethod(self, request_iterator, context): + def ClientStreamingMethod(self, request_iterator, context): """客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) + Request-streaming (In a single call, the client can transfer data to the server several times, + but the server can only return a response once.) """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') - def SStreamMethod(self, request, context): + def ServerStreamingMethod(self, request, context): """服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) + Response-streaming (In a single call, the client can only transmit data to the server at one time, + but the server can return the response many times.) """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') - def TWFMethod(self, request_iterator, context): - """双向流模式 (在一次调用中, 客户端和服务器都可以向对象多次收发数据) + def BidirectionalStreamingMethod(self, request_iterator, context): + """双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) + Bidirectional streaming (In a single call, both client and server can send and receive data + to each other multiple times.) """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') @@ -78,18 +85,18 @@ def add_GRPCDemoServicer_to_server(servicer, server): request_deserializer=demo__pb2.Request.FromString, response_serializer=demo__pb2.Response.SerializeToString, ), - 'CStreamMethod': grpc.stream_unary_rpc_method_handler( - servicer.CStreamMethod, + 'ClientStreamingMethod': grpc.stream_unary_rpc_method_handler( + servicer.ClientStreamingMethod, request_deserializer=demo__pb2.Request.FromString, response_serializer=demo__pb2.Response.SerializeToString, ), - 'SStreamMethod': grpc.unary_stream_rpc_method_handler( - servicer.SStreamMethod, + 'ServerStreamingMethod': grpc.unary_stream_rpc_method_handler( + servicer.ServerStreamingMethod, request_deserializer=demo__pb2.Request.FromString, response_serializer=demo__pb2.Response.SerializeToString, ), - 'TWFMethod': grpc.stream_stream_rpc_method_handler( - servicer.TWFMethod, + 'BidirectionalStreamingMethod': grpc.stream_stream_rpc_method_handler( + servicer.BidirectionalStreamingMethod, request_deserializer=demo__pb2.Request.FromString, response_serializer=demo__pb2.Response.SerializeToString, ), diff --git a/examples/python/easy_start_demo/notes b/examples/python/easy_start_demo/notes deleted file mode 100644 index f0518fc1746..00000000000 --- a/examples/python/easy_start_demo/notes +++ /dev/null @@ -1,3 +0,0 @@ -//自动生成代码 -//Automatic code generation ->>> python -m grpc_tools.protoc -I ./ ./demo.proto --python_out=./customGrpcPackages --grpc_python_out=./customGrpcPackages \ No newline at end of file diff --git a/examples/python/easy_start_demo/PyServer.py b/examples/python/easy_start_demo/server.py similarity index 63% rename from examples/python/easy_start_demo/PyServer.py rename to examples/python/easy_start_demo/server.py index cfef6bf516a..a4130719ada 100644 --- a/examples/python/easy_start_demo/PyServer.py +++ b/examples/python/easy_start_demo/server.py @@ -1,18 +1,23 @@ """ Author: Zhongying Wang Email: kerbalwzy@gmail.com -License: MPL2 DateTime: 2019-08-13T23:30:00Z PythonVersion: Python3.6.3 """ +import os +import sys import time - import grpc + from threading import Thread from concurrent import futures -from customGrpcPackages import demo_pb2, demo_pb2_grpc -# Constants +# add the `demo_grpc_dps` dir into python package search paths +BaseDir = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, os.path.join(BaseDir, "demo_grpc_pbs")) + +from demo_grpc_pbs import demo_pb2, demo_pb2_grpc + ServerAddress = '127.0.0.1:23334' ServerId = 1 @@ -22,49 +27,52 @@ class DemoServer(demo_pb2_grpc.GRPCDemoServicer): # 简单模式 # Simple def SimpleMethod(self, request, context): - print(f"SimpleMethod called by client({request.Cid}) the message: {request.ReqMsg}") + print("SimpleMethod called by client(%d) the message: %s" % (request.Cid, request.ReqMsg)) resp = demo_pb2.Response(Sid=ServerId, RespMsg="Python server SimpleMethod Ok!!!!") return resp # 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) # Request-streaming (In a single call, the client can transfer data to the server several times, # but the server can only return a response once.) - def CStreamMethod(self, request_iterator, context): - print("CStreamMethod called by client...") + def ClientStreamingMethod(self, request_iterator, context): + print("ClientStreamingMethod called by client...") for req in request_iterator: - print(f"recv from client({req.Cid}), message={req.ReqMsg}") - resp = demo_pb2.Response(Sid=ServerId, RespMsg="Python server CStreamMethod ok") + print("recv from client(%d), message= %s" % (req.Cid, req.ReqMsg)) + resp = demo_pb2.Response(Sid=ServerId, RespMsg="Python server ClientStreamingMethod ok") return resp # 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) # Response-streaming (In a single call, the client can only transmit data to the server at one time, # but the server can return the response many times.) - def SStreamMethod(self, request, context): - print(f"SStreamMethod called by client({request.Cid}), message={request.ReqMsg}") + def ServerStreamingMethod(self, request, context): + print("ServerStreamingMethod called by client(%d), message= %s" % (request.Cid, request.ReqMsg)) # 创建一个生成器 - def resp_msgs(): + # create a generator + def response_messages(): for i in range(5): - resp = demo_pb2.Response(Sid=ServerId, RespMsg=f"send by Python server, message={i}") + resp = demo_pb2.Response(Sid=ServerId, RespMsg=("send by Python server, message=%d" % i)) yield resp - return resp_msgs() + return response_messages() # 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) # Bidirectional Streaming (In a single call, both client and server can send and receive data # to each other multiple times.) - def TWFMethod(self, request_iterator, context): + def BidirectionalStreamingMethod(self, request_iterator, context): + print("BidirectionalStreamingMethod called by client...") + # 开启一个子线程去接收数据 # Open a sub thread to receive data def parse_req(): for req in request_iterator: - print(f"recv from client{req.Cid}, message={req.ReqMsg}") + print("recv from client(%d), message= %s" % (req.Cid, req.ReqMsg)) t = Thread(target=parse_req) t.start() for i in range(5): - yield demo_pb2.Response(Sid=ServerId, RespMsg=f"send by Python server, message={i}") + yield demo_pb2.Response(Sid=ServerId, RespMsg=("send by Python server, message= %d" % i)) t.join() From f46396508422f3a126d41d66cc98deda7331f404 Mon Sep 17 00:00:00 2001 From: Joe Bolinger Date: Tue, 13 Aug 2019 21:36:25 -0700 Subject: [PATCH 1256/1555] Allow :: in ruby_package --- src/compiler/ruby_generator.cc | 14 +--- src/compiler/ruby_generator_string-inl.h | 23 +++++- .../grpc/testing/package_options_import.proto | 22 ++++++ .../testing/package_options_ruby_style.proto | 34 ++++++++ .../spec/pb/codegen/package_option_spec.rb | 78 ++++++++++++------- 5 files changed, 131 insertions(+), 40 deletions(-) create mode 100644 src/ruby/spec/pb/codegen/grpc/testing/package_options_import.proto create mode 100644 src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto diff --git a/src/compiler/ruby_generator.cc b/src/compiler/ruby_generator.cc index e39d8be5d41..2a71aae32bb 100644 --- a/src/compiler/ruby_generator.cc +++ b/src/compiler/ruby_generator.cc @@ -40,13 +40,11 @@ namespace { // Prints out the method using the ruby gRPC DSL. void PrintMethod(const MethodDescriptor* method, const grpc::string& package, Printer* out) { - grpc::string input_type = - RubyTypeOf(method->input_type()->full_name(), package); + grpc::string input_type = RubyTypeOf(method->input_type(), package); if (method->client_streaming()) { input_type = "stream(" + input_type + ")"; } - grpc::string output_type = - RubyTypeOf(method->output_type()->full_name(), package); + grpc::string output_type = RubyTypeOf(method->output_type(), package); if (method->server_streaming()) { output_type = "stream(" + output_type + ")"; } @@ -160,13 +158,7 @@ grpc::string GetServices(const FileDescriptor* file) { return output; } - std::string package_name; - - if (file->options().has_ruby_package()) { - package_name = file->options().ruby_package(); - } else { - package_name = file->package(); - } + std::string package_name = RubyPackage(file); // Write out a file header. std::map header_comment_vars = ListToDict({ diff --git a/src/compiler/ruby_generator_string-inl.h b/src/compiler/ruby_generator_string-inl.h index ecfe796e7a2..7d6b50a516d 100644 --- a/src/compiler/ruby_generator_string-inl.h +++ b/src/compiler/ruby_generator_string-inl.h @@ -100,10 +100,29 @@ inline grpc::string Modularize(grpc::string s) { return new_string; } +// RubyPackage gets the ruby package in either proto or ruby_package format +inline grpc::string RubyPackage(const grpc::protobuf::FileDescriptor* file) { + grpc::string package_name = file->package(); + if (file->options().has_ruby_package()) { + package_name = file->options().ruby_package(); + + // If :: is in the package convert the Ruby formated name + // -> A::B::C + // to use the dot seperator notation + // -> A.B.C + package_name = ReplaceAll(package_name, "::", "."); + } + return package_name; +} + // RubyTypeOf updates a proto type to the required ruby equivalent. -inline grpc::string RubyTypeOf(const grpc::string& a_type, +inline grpc::string RubyTypeOf(const grpc::protobuf::Descriptor* descriptor, const grpc::string& package) { - grpc::string res(a_type); + std::string proto_type = descriptor->full_name(); + if (descriptor->file()->options().has_ruby_package()) { + proto_type = RubyPackage(descriptor->file()) + "." + descriptor->name(); + } + grpc::string res(proto_type); ReplacePrefix(&res, package, ""); // remove the leading package if present ReplacePrefix(&res, ".", ""); // remove the leading . (no package) if (res.find('.') == grpc::string::npos) { diff --git a/src/ruby/spec/pb/codegen/grpc/testing/package_options_import.proto b/src/ruby/spec/pb/codegen/grpc/testing/package_options_import.proto new file mode 100644 index 00000000000..2205d21b83e --- /dev/null +++ b/src/ruby/spec/pb/codegen/grpc/testing/package_options_import.proto @@ -0,0 +1,22 @@ +// Copyright 2019 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package grpc.testing; + +// For sanity checking package definitions +option ruby_package = "A::Other"; + +message Thing { } diff --git a/src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto b/src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto new file mode 100644 index 00000000000..4bfe61e2f63 --- /dev/null +++ b/src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto @@ -0,0 +1,34 @@ +// Copyright 2019 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package grpc.testing; + +import "grpc/testing/package_options_import.proto"; + +// For sanity checking package definitions +option ruby_package = "RPC::Test::New::Package::Options"; + +message AnotherTestRequest { } + +message AnotherTestResponse { } + +message Foo { } + +service AnotherTestService { + rpc GetTest(AnotherTestRequest) returns (AnotherTestResponse) { } + rpc OtherTest(Thing) returns (Thing) { } + rpc FooTest(Foo) returns (Foo) { } +} diff --git a/src/ruby/spec/pb/codegen/package_option_spec.rb b/src/ruby/spec/pb/codegen/package_option_spec.rb index 0ebd503d79d..870f53ef297 100644 --- a/src/ruby/spec/pb/codegen/package_option_spec.rb +++ b/src/ruby/spec/pb/codegen/package_option_spec.rb @@ -18,35 +18,59 @@ require 'tmpdir' describe 'Code Generation Options' do it 'should generate and respect package options' do - fail 'CONFIG env variable unexpectedly unset' unless ENV['CONFIG'] - bins_sub_dir = ENV['CONFIG'] + with_protos(%w[grpc/testing/package_options.proto]) do + expect { Grpc::Testing::Package::Options::TestService::Service }.to raise_error(NameError) + expect(require('grpc/testing/package_options_services_pb')).to be_truthy + expect { Grpc::Testing::Package::Options::TestService::Service }.to_not raise_error + expect { Grpc::Testing::TestService::Service }.to raise_error(NameError) + end + end - pb_dir = File.dirname(__FILE__) - bins_dir = File.join('..', '..', '..', '..', '..', 'bins', bins_sub_dir) + it 'should generate and respect Ruby style package options' do + with_protos(%w[grpc/testing/package_options_ruby_style.proto grpc/testing/package_options_import.proto]) do + expect { RPC::Test::New::Package::Options::AnotherTestService::Service }.to raise_error(NameError) + expect(require('grpc/testing/package_options_ruby_style_services_pb')).to be_truthy + expect { RPC::Test::New::Package::Options::AnotherTestService::Service }.to_not raise_error + expect { Grpc::Testing::AnotherTestService::Service }.to raise_error(NameError) - plugin = File.join(bins_dir, 'grpc_ruby_plugin') - protoc = File.join(bins_dir, 'protobuf', 'protoc') - - # Generate the service from the proto - Dir.mktmpdir(nil, File.dirname(__FILE__)) do |tmp_dir| - gen_file = system(protoc, - '-I.', - 'grpc/testing/package_options.proto', - "--grpc_out=#{tmp_dir}", # generate the service - "--ruby_out=#{tmp_dir}", # generate the definitions - "--plugin=protoc-gen-grpc=#{plugin}", - chdir: pb_dir, - out: File::NULL) - - expect(gen_file).to be_truthy - begin - $LOAD_PATH.push(tmp_dir) - expect { Grpc::Testing::Package::Options::TestService::Service }.to raise_error(NameError) - expect(require('grpc/testing/package_options_services_pb')).to be_truthy - expect { Grpc::Testing::Package::Options::TestService::Service }.to_not raise_error - ensure - $LOAD_PATH.delete(tmp_dir) - end + services = RPC::Test::New::Package::Options::AnotherTestService::Service.rpc_descs + expect(services[:GetTest].input).to eq(RPC::Test::New::Package::Options::AnotherTestRequest) + expect(services[:GetTest].output).to eq(RPC::Test::New::Package::Options::AnotherTestResponse) + expect(services[:OtherTest].input).to eq(A::Other::Thing) + expect(services[:OtherTest].output).to eq(A::Other::Thing) + expect(services[:FooTest].input).to eq(RPC::Test::New::Package::Options::Foo) + expect(services[:FooTest].output).to eq(RPC::Test::New::Package::Options::Foo) + end + end +end + +def with_protos(file_paths) + fail 'CONFIG env variable unexpectedly unset' unless ENV['CONFIG'] + bins_sub_dir = ENV['CONFIG'] + + pb_dir = File.dirname(__FILE__) + bins_dir = File.join('..', '..', '..', '..', '..', 'bins', bins_sub_dir) + + plugin = File.join(bins_dir, 'grpc_ruby_plugin') + protoc = File.join(bins_dir, 'protobuf', 'protoc') + + # Generate the service from the proto + Dir.mktmpdir(nil, File.dirname(__FILE__)) do |tmp_dir| + gen_file = system(protoc, + '-I.', + *file_paths, + "--grpc_out=#{tmp_dir}", # generate the service + "--ruby_out=#{tmp_dir}", # generate the definitions + "--plugin=protoc-gen-grpc=#{plugin}", + chdir: pb_dir, + out: File::NULL) + + expect(gen_file).to be_truthy + begin + $LOAD_PATH.push(tmp_dir) + yield + ensure + $LOAD_PATH.delete(tmp_dir) end end end From 21c6531bc0df1501cc9188f35b5d4ddedfa6d5fa Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Thu, 15 Aug 2019 11:21:10 -0700 Subject: [PATCH 1257/1555] Added targets for other examples in objective-c examples --- examples/BUILD | 5 ++ examples/objective-c/BUILD | 58 +++++++++++++++++++ .../helloworld_macos/HelloWorld/Info.plist | 2 +- examples/objective-c/helloworld_macos/main.m | 4 ++ .../objective-c/route_guide/ViewControllers.m | 4 ++ test/build_test/BUILD | 2 +- 6 files changed, 73 insertions(+), 2 deletions(-) diff --git a/examples/BUILD b/examples/BUILD index aa9ed945849..6f801963c6e 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -238,3 +238,8 @@ cc_binary( "//:grpc++", ], ) + +proto_library( + name = "route_guide_proto", + srcs = ["protos/route_guide.proto"], +) diff --git a/examples/objective-c/BUILD b/examples/objective-c/BUILD index 9ceaaa9a8b4..4a5eafdf3fb 100644 --- a/examples/objective-c/BUILD +++ b/examples/objective-c/BUILD @@ -18,6 +18,7 @@ package(default_visibility = ["//visibility:public"]) load("@com_github_grpc_grpc//bazel:objc_grpc_library.bzl", "objc_grpc_library") load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application") +load("@build_bazel_rules_apple//apple:macos.bzl", "macos_application") objc_grpc_library( name = "HelloWorld_grpc_proto", @@ -59,3 +60,60 @@ ios_application( deps = [":HelloWorld-lib"], tags = ["manual"], ) + +objc_library( + name = "HelloWorldMacos-lib", + srcs = glob(["helloworld_macos/**/*.m",]), + hdrs = glob(["helloworld_macos/**/*.h"]), + data = glob([ + "helloworld_macos/HelloWorld/Base.lproj/**", + "helloworld_macos/HelloWorld/Images.xcassets/**", + ]), + includes = ["helloworld_macos/HelloWorld"], + deps = [":HelloWorld_grpc_proto"], + tags = ["manual"], +) + +macos_application( + name = "HelloWorldMacos", + bundle_id = "io.grpc.HelloWorld", + minimum_os_version = "10.13", + entitlements = "helloworld_macos/HelloWorld/Helloworld.entitlements", + infoplists = ["helloworld_macos/HelloWorld/Info.plist"], + deps = [":HelloWorldMacos-lib"], + tags = ["manual"], +) + +objc_grpc_library( + name = "RouteGuide", + srcs = ["//examples:protos/route_guide.proto"], + deps = ["//examples:route_guide_proto"], + tags = ["manual"], +) + +objc_library( + name = "RouteGuideClient-lib", + srcs = glob(["route_guide/**/*.m"]), + hdrs = glob(["route_guide/**/*.h"]), + data = glob([ + "route_guide/Misc/Base.lproj/**", + "route_guide/Misc/Images.xcassets/**", + "route_guide/route_guide_db.json", + ]), + includes = ["route_guide/Misc"], + deps = [":RouteGuide"], + tags = ["manual"], +) + +ios_application( + name = "RouteGuideClient", + bundle_id = "gRPC.RouteGuideClient", + families = [ + "iphone", + "ipad", + ], + minimum_os_version = "8.0", + infoplists = ["route_guide/Misc/Info.plist"], + deps = [":RouteGuideClient-lib"], + tags = ["manual"], +) diff --git a/examples/objective-c/helloworld_macos/HelloWorld/Info.plist b/examples/objective-c/helloworld_macos/HelloWorld/Info.plist index f7bfdac9d6f..c76261baef0 100644 --- a/examples/objective-c/helloworld_macos/HelloWorld/Info.plist +++ b/examples/objective-c/helloworld_macos/HelloWorld/Info.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) + en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIconFile diff --git a/examples/objective-c/helloworld_macos/main.m b/examples/objective-c/helloworld_macos/main.m index ce24a9b1466..c0e7ef3c9ab 100644 --- a/examples/objective-c/helloworld_macos/main.m +++ b/examples/objective-c/helloworld_macos/main.m @@ -20,7 +20,11 @@ #import #import +#if COCOAPODS #import +#else +#import "examples/protos/Helloworld.pbrpc.h" +#endif static NSString * const kHostAddress = @"localhost:50051"; diff --git a/examples/objective-c/route_guide/ViewControllers.m b/examples/objective-c/route_guide/ViewControllers.m index 43d2082f585..f36bfe607b5 100644 --- a/examples/objective-c/route_guide/ViewControllers.m +++ b/examples/objective-c/route_guide/ViewControllers.m @@ -17,7 +17,11 @@ */ #import +#if COCOAPODS #import +#else +#import "examples/protos/RouteGuide.pbrpc.h" +#endif static NSString * const kHostAddress = @"localhost:50051"; diff --git a/test/build_test/BUILD b/test/build_test/BUILD index 90777266a14..dd2030ccda6 100644 --- a/test/build_test/BUILD +++ b/test/build_test/BUILD @@ -25,4 +25,4 @@ build_test( "//examples/objective-c:HelloWorld", ], tags = ["manual"], -) \ No newline at end of file +) From f037eac0a96096e41818024303863eaa7719f693 Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Thu, 15 Aug 2019 13:37:14 -0700 Subject: [PATCH 1258/1555] Small fixes --- .../RemoteTestClientCpp/RemoteTestCpp.podspec | 16 +--------------- tools/run_tests/run_tests.py | 2 +- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/test/cpp/ios/RemoteTestClientCpp/RemoteTestCpp.podspec b/test/cpp/ios/RemoteTestClientCpp/RemoteTestCpp.podspec index a0f0e2e436a..debe2943208 100644 --- a/test/cpp/ios/RemoteTestClientCpp/RemoteTestCpp.podspec +++ b/test/cpp/ios/RemoteTestClientCpp/RemoteTestCpp.podspec @@ -33,21 +33,7 @@ Pod::Spec.new do |s| --grpc_out=. \ -I #{repo_root} \ -I #{well_known_types_dir} \ - #{proto_dir}/echo.proto - #{protoc} \ - --plugin=protoc-gen-grpc=#{plugin} \ - --cpp_out=. \ - --grpc_out=. \ - -I #{repo_root} \ - -I #{well_known_types_dir} \ - #{proto_dir}/echo_messages.proto - #{protoc} \ - --plugin=protoc-gen-grpc=#{plugin} \ - --cpp_out=. \ - --grpc_out=. \ - -I #{repo_root} \ - -I #{well_known_types_dir} \ - #{proto_dir}/simple_messages.proto + #{proto_dir}/echo.proto #{proto_dir}/echo_messages.proto #{proto_dir}/simple_messages.proto CMD s.pod_target_xcconfig = { diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 95c3d8ed1dd..1ff37ca85af 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1127,7 +1127,7 @@ class ObjCLanguage(object): shortname='ios-test-cfstream-tests', cpu_cost=1e6, environ=_FORCE_ENVIRON_FOR_WRAPPERS)) - # TODO: replace with run_one_test_bazel.sh when Bazel is stable + # TODO: replace with run_one_test_bazel.sh when Bazel-Xcode is stable out.append( self.config.job_spec( ['src/objective-c/tests/run_one_test.sh'], From 699f810cf234f97fad1d08e8cb57a7b9df10aa37 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 20 Jun 2019 19:51:12 -0700 Subject: [PATCH 1259/1555] Do not create streams after a GOAWAY has been received --- .../chttp2/transport/chttp2_transport.cc | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index f4b0f694142..7d6d6a80745 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -1198,10 +1198,30 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t, static void maybe_start_some_streams(grpc_chttp2_transport* t) { grpc_chttp2_stream* s; + /* cancel out streams that will never be started */ + if (t->goaway_error != GRPC_ERROR_NONE) { + while (grpc_chttp2_list_pop_waiting_for_concurrency(t, &s)) { + grpc_chttp2_cancel_stream( + t, s, + grpc_error_set_int( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("GOAWAY received"), + GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE)); + } + return; + } + if (t->next_stream_id >= MAX_CLIENT_STREAM_ID) { + while (grpc_chttp2_list_pop_waiting_for_concurrency(t, &s)) { + grpc_chttp2_cancel_stream( + t, s, + grpc_error_set_int( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Stream IDs exhausted"), + GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE)); + } + return; + } /* start streams where we have free grpc_chttp2_stream ids and free * concurrency */ - while (t->next_stream_id <= MAX_CLIENT_STREAM_ID && - grpc_chttp2_stream_map_size(&t->stream_map) < + while (grpc_chttp2_stream_map_size(&t->stream_map) < t->settings[GRPC_PEER_SETTINGS] [GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS] && grpc_chttp2_list_pop_waiting_for_concurrency(t, &s)) { @@ -1225,15 +1245,6 @@ static void maybe_start_some_streams(grpc_chttp2_transport* t) { grpc_chttp2_mark_stream_writable(t, s); grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_START_NEW_STREAM); } - /* cancel out streams that will never be started */ - while (t->next_stream_id >= MAX_CLIENT_STREAM_ID && - grpc_chttp2_list_pop_waiting_for_concurrency(t, &s)) { - grpc_chttp2_cancel_stream( - t, s, - grpc_error_set_int( - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Stream IDs exhausted"), - GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE)); - } } /* Flag that this closure barrier may be covering a write in a pollset, and so From 0f8dced6c44642ac53462eacffde1e682a0c8023 Mon Sep 17 00:00:00 2001 From: Mike Moore Date: Tue, 13 Aug 2019 18:21:44 -0600 Subject: [PATCH 1260/1555] Define Struct::Status in Ruby Update error end2end test for loading when calling to_status. Update error end2end test for loading when calling to_rpc_status. --- .../end2end/errors_load_before_grpc_lib.rb | 20 +++++++++++++++++++ src/ruby/ext/grpc/rb_grpc.c | 3 +-- src/ruby/lib/grpc.rb | 1 + src/ruby/lib/grpc/errors.rb | 9 +++------ src/ruby/lib/grpc/google_rpc_status_utils.rb | 13 ++++++++---- src/ruby/lib/grpc/structs.rb | 15 ++++++++++++++ src/ruby/spec/errors_spec.rb | 1 + 7 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 src/ruby/lib/grpc/structs.rb diff --git a/src/ruby/end2end/errors_load_before_grpc_lib.rb b/src/ruby/end2end/errors_load_before_grpc_lib.rb index 7e6ff7696fa..56f7714fc7c 100755 --- a/src/ruby/end2end/errors_load_before_grpc_lib.rb +++ b/src/ruby/end2end/errors_load_before_grpc_lib.rb @@ -18,12 +18,32 @@ this_dir = File.expand_path(File.dirname(__FILE__)) grpc_lib_dir = File.join(File.dirname(this_dir), 'lib') $LOAD_PATH.unshift(grpc_lib_dir) unless $LOAD_PATH.include?(grpc_lib_dir) +def check_to_status(error) + my_status = error.to_status + fail('GRPC BadStatus#to_status not expected to return nil') if my_status.nil? + fail('GRPC BadStatus#to_status code expected to be 2') unless my_status.code == 2 + fail('GRPC BadStatus#to_status details expected to be unknown') unless my_status.details == 'unknown' + fail('GRPC BadStatus#to_status metadata expected to be empty hash') unless my_status.metadata == {} + fail('GRPC library loaded after BadStatus#to_status') if GRPC::Core.const_defined?(:Channel) +end + +def check_to_rpc_status(error) + my_rpc_status = error.to_rpc_status + fail('GRPC BadStatus#to_rpc_status expected to return nil') unless my_rpc_status.nil? + fail('GRPC library loaded after BadStatus#to_rpc_status') if GRPC::Core.const_defined?(:Channel) +end + def main fail('GRPC constant loaded before expected') if Object.const_defined?(:GRPC) require 'grpc/errors' fail('GRPC constant not loaded when expected') unless Object.const_defined?(:GRPC) fail('GRPC BadStatus not loaded after required') unless GRPC.const_defined?(:BadStatus) + fail('GRPC Core not loaded after required') unless GRPC.const_defined?(:Core) + fail('GRPC StatusCodes not loaded after required') unless GRPC::Core.const_defined?(:StatusCodes) fail('GRPC library loaded before required') if GRPC::Core.const_defined?(:Channel) + error = GRPC::BadStatus.new 2, 'unknown' + check_to_status(error) + check_to_rpc_status(error) require 'grpc' fail('GRPC library not loaded after required') unless GRPC::Core.const_defined?(:Channel) end diff --git a/src/ruby/ext/grpc/rb_grpc.c b/src/ruby/ext/grpc/rb_grpc.c index 147ab4ad087..77cabfca814 100644 --- a/src/ruby/ext/grpc/rb_grpc.c +++ b/src/ruby/ext/grpc/rb_grpc.c @@ -312,8 +312,7 @@ void Init_grpc_c() { grpc_rb_mGrpcCore = rb_define_module_under(grpc_rb_mGRPC, "Core"); grpc_rb_sNewServerRpc = rb_struct_define( "NewServerRpc", "method", "host", "deadline", "metadata", "call", NULL); - grpc_rb_sStatus = - rb_struct_define("Status", "code", "details", "metadata", NULL); + grpc_rb_sStatus = rb_const_get(rb_cStruct, rb_intern("Status")); sym_code = ID2SYM(rb_intern("code")); sym_details = ID2SYM(rb_intern("details")); sym_metadata = ID2SYM(rb_intern("metadata")); diff --git a/src/ruby/lib/grpc.rb b/src/ruby/lib/grpc.rb index 66b1b8db39f..e0e1c9cd9b6 100644 --- a/src/ruby/lib/grpc.rb +++ b/src/ruby/lib/grpc.rb @@ -15,6 +15,7 @@ ssl_roots_path = File.expand_path('../../../../etc/roots.pem', __FILE__) require_relative 'grpc/errors' +require_relative 'grpc/structs' require_relative 'grpc/grpc' require_relative 'grpc/logconfig' require_relative 'grpc/notifier' diff --git a/src/ruby/lib/grpc/errors.rb b/src/ruby/lib/grpc/errors.rb index e44043f3199..7a300eb2daa 100644 --- a/src/ruby/lib/grpc/errors.rb +++ b/src/ruby/lib/grpc/errors.rb @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +require_relative './structs' require_relative './core/status_codes' +require_relative './google_rpc_status_utils' # GRPC contains the General RPC module. module GRPC @@ -57,12 +59,7 @@ module GRPC # # @return [Google::Rpc::Status, nil] def to_rpc_status - # Lazily require google_rpc_status_utils to scope - # loading protobuf_c.so to the users of this method. - require_relative './google_rpc_status_utils' - status = to_status - return if status.nil? - GoogleRpcStatusUtils.extract_google_rpc_status(status) + GoogleRpcStatusUtils.extract_google_rpc_status(to_status) rescue Google::Protobuf::ParseError => parse_error GRPC.logger.warn('parse error: to_rpc_status failed') GRPC.logger.warn(parse_error) diff --git a/src/ruby/lib/grpc/google_rpc_status_utils.rb b/src/ruby/lib/grpc/google_rpc_status_utils.rb index f253b082b63..adf6cf615c7 100644 --- a/src/ruby/lib/grpc/google_rpc_status_utils.rb +++ b/src/ruby/lib/grpc/google_rpc_status_utils.rb @@ -12,8 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require_relative './grpc' -require 'google/rpc/status_pb' +require_relative './structs' # GRPC contains the General RPC module. module GRPC @@ -28,8 +27,14 @@ module GRPC def self.extract_google_rpc_status(status) fail ArgumentError, 'bad type' unless status.is_a? Struct::Status grpc_status_details_bin_trailer = 'grpc-status-details-bin' - return nil if status.metadata[grpc_status_details_bin_trailer].nil? - Google::Rpc::Status.decode(status.metadata[grpc_status_details_bin_trailer]) + binstatus = status.metadata[grpc_status_details_bin_trailer] + return nil if binstatus.nil? + + # Lazily load grpc_c and protobuf_c.so for users of this method. + require_relative './grpc' + require 'google/rpc/status_pb' + + Google::Rpc::Status.decode(binstatus) end end end diff --git a/src/ruby/lib/grpc/structs.rb b/src/ruby/lib/grpc/structs.rb new file mode 100644 index 00000000000..e57f1b69619 --- /dev/null +++ b/src/ruby/lib/grpc/structs.rb @@ -0,0 +1,15 @@ +# Copyright 2015 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +Struct.new('Status', :code, :details, :metadata) diff --git a/src/ruby/spec/errors_spec.rb b/src/ruby/spec/errors_spec.rb index bf27a537405..6fb22b15356 100644 --- a/src/ruby/spec/errors_spec.rb +++ b/src/ruby/spec/errors_spec.rb @@ -14,6 +14,7 @@ require 'spec_helper' require 'google/protobuf/well_known_types' +require 'google/rpc/status_pb' require_relative '../pb/src/proto/grpc/testing/messages_pb' describe GRPC::BadStatus do From 4076695969c645e7b487656c9aa61e2359b7e3f7 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 15 Aug 2019 16:48:37 -0700 Subject: [PATCH 1261/1555] Reviewer comments --- .../chttp2/transport/chttp2_transport.cc | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 7d6d6a80745..73235756dfb 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -1198,7 +1198,7 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t, static void maybe_start_some_streams(grpc_chttp2_transport* t) { grpc_chttp2_stream* s; - /* cancel out streams that will never be started */ + /* cancel out streams that haven't yet started if we have received a GOAWAY */ if (t->goaway_error != GRPC_ERROR_NONE) { while (grpc_chttp2_list_pop_waiting_for_concurrency(t, &s)) { grpc_chttp2_cancel_stream( @@ -1209,19 +1209,10 @@ static void maybe_start_some_streams(grpc_chttp2_transport* t) { } return; } - if (t->next_stream_id >= MAX_CLIENT_STREAM_ID) { - while (grpc_chttp2_list_pop_waiting_for_concurrency(t, &s)) { - grpc_chttp2_cancel_stream( - t, s, - grpc_error_set_int( - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Stream IDs exhausted"), - GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE)); - } - return; - } /* start streams where we have free grpc_chttp2_stream ids and free * concurrency */ - while (grpc_chttp2_stream_map_size(&t->stream_map) < + while (t->next_stream_id <= MAX_CLIENT_STREAM_ID && + grpc_chttp2_stream_map_size(&t->stream_map) < t->settings[GRPC_PEER_SETTINGS] [GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS] && grpc_chttp2_list_pop_waiting_for_concurrency(t, &s)) { @@ -1245,6 +1236,16 @@ static void maybe_start_some_streams(grpc_chttp2_transport* t) { grpc_chttp2_mark_stream_writable(t, s); grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_START_NEW_STREAM); } + /* cancel out streams that will never be started */ + if (t->next_stream_id >= MAX_CLIENT_STREAM_ID) { + while (grpc_chttp2_list_pop_waiting_for_concurrency(t, &s)) { + grpc_chttp2_cancel_stream( + t, s, + grpc_error_set_int( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Stream IDs exhausted"), + GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE)); + } + } } /* Flag that this closure barrier may be covering a write in a pollset, and so From 5db1ae34b4a0fd8e0b81ecfc4e1eac5da2c6bba4 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 15 Aug 2019 20:13:39 -0700 Subject: [PATCH 1262/1555] Expose local credentials on Python layer --- .../grpc/_cython/_cygrpc/credentials.pxd.pxi | 5 ++ .../grpc/_cython/_cygrpc/credentials.pyx.pxi | 22 +++++++ .../grpcio/grpc/_cython/_cygrpc/grpc.pxi | 12 ++++ src/python/grpcio/grpc/_local_credentials.py | 57 +++++++++++++++++ src/python/grpcio_tests/tests/tests.json | 1 + .../grpcio_tests/tests/unit/BUILD.bazel | 1 + .../tests/unit/_local_credentials_test.py | 64 +++++++++++++++++++ 7 files changed, 162 insertions(+) create mode 100644 src/python/grpcio/grpc/_local_credentials.py create mode 100644 src/python/grpcio_tests/tests/unit/_local_credentials_test.py diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi index 05892b37324..ec647378a99 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi @@ -97,3 +97,8 @@ cdef class ServerCredentials: cdef object cert_config_fetcher # whether C-core has asked for the initial_cert_config cdef bint initial_cert_config_fetched + + +cdef class LocalChannelCredentials(ChannelCredentials): + + cdef readonly object _local_connect_type diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi index 2ec1c0bc427..ac88bbe7afc 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi @@ -328,3 +328,25 @@ cdef grpc_ssl_certificate_config_reload_status _server_cert_config_fetcher_wrapp cert_config.c_ssl_pem_key_cert_pairs_count) return GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW + +class LocalConnectType: + uds = UDS + local_tcp = LOCAL_TCP + +cdef class LocalChannelCredentials(ChannelCredentials): + + def __cinit__(self, grpc_local_connect_type local_connect_type): + self._local_connect_type = local_connect_type + + cdef grpc_channel_credentials *c(self) except *: + cdef grpc_local_connect_type local_connect_type + local_connect_type = self._local_connect_type + return grpc_local_credentials_create(local_connect_type) + +def channel_credentials_local(grpc_local_connect_type local_connect_type): + return LocalChannelCredentials(local_connect_type) + +def server_credentials_local(grpc_local_connect_type local_connect_type): + cdef ServerCredentials credentials = ServerCredentials() + credentials.c_credentials = grpc_local_server_credentials_create(local_connect_type) + return credentials diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index a674c34bb23..4bfb42026aa 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -584,6 +584,12 @@ cdef extern from "grpc/grpc_security.h": void grpc_auth_context_release(grpc_auth_context *context) + grpc_channel_credentials *grpc_local_credentials_create( + grpc_local_connect_type type) + grpc_server_credentials *grpc_local_server_credentials_create( + grpc_local_connect_type type) + + cdef extern from "grpc/compression.h": ctypedef enum grpc_compression_algorithm: @@ -624,3 +630,9 @@ cdef extern from "grpc/impl/codegen/compression_types.h": const char *_GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY \ "GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY" + + +cdef extern from "grpc/grpc_security_constants.h": + ctypedef enum grpc_local_connect_type: + UDS + LOCAL_TCP diff --git a/src/python/grpcio/grpc/_local_credentials.py b/src/python/grpcio/grpc/_local_credentials.py new file mode 100644 index 00000000000..326820dee39 --- /dev/null +++ b/src/python/grpcio/grpc/_local_credentials.py @@ -0,0 +1,57 @@ + +# Copyright 2019 The gRPC authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""gRPC's local credential API.""" + +import enum +import grpc +from grpc._cython import cygrpc + + +@enum.unique +class LocalConnectType(enum.Enum): + """Type of local connections for which local channel/server credentials will be applied. + + Attributes: + UDS: Unix domain socket connections + LOCAL_TCP: Local TCP connections. + """ + UDS = cygrpc.LocalConnectType.uds + LOCAL_TCP = cygrpc.LocalConnectType.local_tcp + + +def local_channel_credentials(local_connect_type=LocalConnectType.LOCAL_TCP): + """Creates a local ChannelCredentials used for local connections. + + Args: + local_connect_type: Local connection type (either UDS or LOCAL_TCP) + + Returns: + A ChannelCredentials for use with a local Channel + """ + return grpc.ChannelCredentials( + cygrpc.channel_credentials_local(local_connect_type.value)) + + +def local_server_credentials(local_connect_type=LocalConnectType.LOCAL_TCP): + """Creates a local ServerCredentials used for local connections. + + Args: + local_connect_type: Local connection type (either UDS or LOCAL_TCP) + + Returns: + A ServerCredentials for use with a local Server + """ + return grpc.ServerCredentials( + cygrpc.server_credentials_local(local_connect_type.value)) diff --git a/src/python/grpcio_tests/tests/tests.json b/src/python/grpcio_tests/tests/tests.json index ab70943e5ed..c636ee5d4e3 100644 --- a/src/python/grpcio_tests/tests/tests.json +++ b/src/python/grpcio_tests/tests/tests.json @@ -53,6 +53,7 @@ "unit._interceptor_test.InterceptorTest", "unit._invalid_metadata_test.InvalidMetadataTest", "unit._invocation_defects_test.InvocationDefectsTest", + "unit._local_credentials_test.LocalCredentialsTest", "unit._logging_test.LoggingTest", "unit._metadata_code_details_test.MetadataCodeDetailsTest", "unit._metadata_flags_test.MetadataFlagsTest", diff --git a/src/python/grpcio_tests/tests/unit/BUILD.bazel b/src/python/grpcio_tests/tests/unit/BUILD.bazel index aede11e325f..baa8a4a3e6b 100644 --- a/src/python/grpcio_tests/tests/unit/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/BUILD.bazel @@ -19,6 +19,7 @@ GRPCIO_TESTS_UNIT = [ "_interceptor_test.py", "_invalid_metadata_test.py", "_invocation_defects_test.py", + "_local_crednetials_test.py", "_logging_test.py", "_metadata_code_details_test.py", "_metadata_test.py", diff --git a/src/python/grpcio_tests/tests/unit/_local_credentials_test.py b/src/python/grpcio_tests/tests/unit/_local_credentials_test.py new file mode 100644 index 00000000000..838d8129e8c --- /dev/null +++ b/src/python/grpcio_tests/tests/unit/_local_credentials_test.py @@ -0,0 +1,64 @@ +# Copyright 2019 The gRPC authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Test of RPCs made using local credentials.""" + +import unittest +from concurrent.futures import ThreadPoolExecutor +import grpc +from grpc import local_credentials + + +class _GenericHandler(grpc.GenericRpcHandler): + + def service(self, handler_call_details): + return grpc.unary_unary_rpc_method_handler( + lambda request, unused_context: request) + + +class LocalCredentialsTest(unittest.TestCase): + + def _create_server(self): + server = grpc.server(ThreadPoolExecutor()) + server.add_generic_rpc_handlers((_GenericHandler(),)) + return server + + def test_local_tcp(self): + server_addr = '[::1]:{}' + channel_creds = local_credentials.local_channel_credentials( + local_credentials.LocalConnectType.LOCAL_TCP) + server_creds = local_credentials.local_server_credentials( + local_credentials.LocalConnectType.LOCAL_TCP) + server = self._create_server() + port = server.add_secure_port(server_addr.format(0), server_creds) + server.start() + channel = grpc.secure_channel(server_addr.format(port), channel_creds) + self.assertEqual(b'abc', channel.unary_unary('/test/method')(b'abc')) + server.stop(None) + + def test_uds(self): + server_addr = 'unix:/tmp/grpc_fullstack_test' + channel_creds = local_credentials.local_channel_credentials( + local_credentials.LocalConnectType.UDS) + server_creds = local_credentials.local_server_credentials( + local_credentials.LocalConnectType.UDS) + server = self._create_server() + server.add_secure_port(server_addr, server_creds) + server.start() + channel = grpc.secure_channel(server_addr, channel_creds) + self.assertEqual(b'abc', channel.unary_unary('/test/method')(b'abc')) + server.stop(None) + + +if __name__ == '__main__': + unittest.main() From f681fe89af7ba140d0e3e02eeaa9efa03e2332d2 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 15 Aug 2019 20:16:01 -0700 Subject: [PATCH 1263/1555] Make yapf happy --- src/python/grpcio/grpc/_local_credentials.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/python/grpcio/grpc/_local_credentials.py b/src/python/grpcio/grpc/_local_credentials.py index 326820dee39..8d46fa3d3ae 100644 --- a/src/python/grpcio/grpc/_local_credentials.py +++ b/src/python/grpcio/grpc/_local_credentials.py @@ -1,4 +1,3 @@ - # Copyright 2019 The gRPC authors # # Licensed under the Apache License, Version 2.0 (the "License"); From d2a224252d0021699dcc64d44aa301a0d8797314 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Fri, 16 Aug 2019 11:54:31 +0800 Subject: [PATCH 1264/1555] fix:Update notes, with more standard words --- examples/python/easy_start_demo/README.md | 21 +++++++------------ examples/python/easy_start_demo/demo.proto | 20 +++++++++--------- .../easy_start_demo/demo_grpc_pbs/demo_pb2.py | 20 +++++++++--------- .../demo_grpc_pbs/demo_pb2_grpc.py | 8 +++---- 4 files changed, 31 insertions(+), 38 deletions(-) diff --git a/examples/python/easy_start_demo/README.md b/examples/python/easy_start_demo/README.md index 50529c57df5..32ad177af17 100644 --- a/examples/python/easy_start_demo/README.md +++ b/examples/python/easy_start_demo/README.md @@ -1,35 +1,28 @@ -## easyDemo for using GRPC in Python -###主要是介绍了在Python中使用GRPC时, 进行数据传输的四种方式。 -###This paper mainly introduces four ways of data transmission when GRPC is used in Python. +## Demo for using gRPC in Python -- ####简单模式 (Simple) +在Python中使用gRPC时, 进行数据传输的四种方式。(Four ways of data transmission when gRPC is used in Python.) + +- ####简单模式 (unary-unary) ```text 没啥好说的,跟调普通方法没差 There's nothing to say. It's no different from the usual way. ``` -- ####客户端流模式 (Request-streaming) +- ####客户端流模式 (stream-unary) ```text 在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应. In a single call, the client can transfer data to the server several times, but the server can only return a response once. ``` -- ####服务端流模式 (Response-streaming) +- ####服务端流模式 (unary-stream) ```text 在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应 In a single call, the client can only transmit data to the server at one time, but the server can return the response many times. ``` -- ####双向流模式 (Bidirectional Streaming) +- ####双向流模式 (stream-stream) ```text 在一次调用中, 客户端和服务器都可以向对方多次收发数据 In a single call, both client and server can send and receive data to each other multiple times. ``` ----- -Author: Zhongying Wang -Email: kerbalwzy@gmail.com - -DateTime: 2019-08-13T23:30:00Z - -PythonVersion: Python3.6.3 \ No newline at end of file diff --git a/examples/python/easy_start_demo/demo.proto b/examples/python/easy_start_demo/demo.proto index 2844ba7b225..dd29a178d77 100644 --- a/examples/python/easy_start_demo/demo.proto +++ b/examples/python/easy_start_demo/demo.proto @@ -1,9 +1,9 @@ // 语法版本声明,必须放在非注释的第一行 -// Syntax version declaration, Must be placed on the first line of non-commentary +// Syntax version declaration. Must be placed on the first line of non-commentary. syntax = "proto3"; // 包名定义, Python中使用时可以省略不写(PS:我还要再Go中使用,所以留在这里了) -// Package name definition, which can be omitted in Python (PS: I'll use it again in Go, so stay here) +// Package name definition, which can be omitted in Python. (PS: I'll use it again in Go, so stay here) package demo; /* @@ -17,34 +17,34 @@ Each field in the message definition has a unique number. The overall format is similar to defining a class in Python or a structure in Golang. */ message Request { - int64 Cid = 1; - string ReqMsg = 2; + int64 client_id = 1; + string request_data = 2; } message Response { - int64 Sid = 1; - string RespMsg = 2; + int64 server_id = 1; + string response_data = 2; } // service是用来给GRPC服务定义方法的, 格式固定, 类似于Golang中定义一个接口 // `service` is used to define methods for GRPC services in a fixed format, similar to defining an interface in Golang service GRPCDemo { // 简单模式 - // Simple + // unary-unary rpc SimpleMethod (Request) returns (Response); // 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) - // Request-streaming (In a single call, the client can transfer data to the server several times, + // stream-unary (In a single call, the client can transfer data to the server several times, // but the server can only return a response once.) rpc ClientStreamingMethod (stream Request) returns (Response); // 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) - // Response-streaming (In a single call, the client can only transmit data to the server at one time, + // unary-stream (In a single call, the client can only transmit data to the server at one time, // but the server can return the response many times.) rpc ServerStreamingMethod (Request) returns (stream Response); // 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) - // Bidirectional streaming (In a single call, both client and server can send and receive data + // stream-stream (In a single call, both client and server can send and receive data // to each other multiple times.) rpc BidirectionalStreamingMethod (stream Request) returns (stream Response); } diff --git a/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2.py b/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2.py index de960c8a6c1..5dfaf837dfd 100644 --- a/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2.py +++ b/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2.py @@ -20,7 +20,7 @@ DESCRIPTOR = _descriptor.FileDescriptor( package='demo', syntax='proto3', serialized_options=None, - serialized_pb=_b('\n\ndemo.proto\x12\x04\x64\x65mo\"&\n\x07Request\x12\x0b\n\x03\x43id\x18\x01 \x01(\x03\x12\x0e\n\x06ReqMsg\x18\x02 \x01(\t\"(\n\x08Response\x12\x0b\n\x03Sid\x18\x01 \x01(\x03\x12\x0f\n\x07RespMsg\x18\x02 \x01(\t2\xf0\x01\n\x08GRPCDemo\x12-\n\x0cSimpleMethod\x12\r.demo.Request\x1a\x0e.demo.Response\x12\x38\n\x15\x43lientStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x12\x38\n\x15ServerStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response0\x01\x12\x41\n\x1c\x42idirectionalStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x30\x01\x62\x06proto3') + serialized_pb=_b('\n\ndemo.proto\x12\x04\x64\x65mo\"2\n\x07Request\x12\x11\n\tclient_id\x18\x01 \x01(\x03\x12\x14\n\x0crequest_data\x18\x02 \x01(\t\"4\n\x08Response\x12\x11\n\tserver_id\x18\x01 \x01(\x03\x12\x15\n\rresponse_data\x18\x02 \x01(\t2\xf0\x01\n\x08GRPCDemo\x12-\n\x0cSimpleMethod\x12\r.demo.Request\x1a\x0e.demo.Response\x12\x38\n\x15\x43lientStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x12\x38\n\x15ServerStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response0\x01\x12\x41\n\x1c\x42idirectionalStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x30\x01\x62\x06proto3') ) @@ -34,14 +34,14 @@ _REQUEST = _descriptor.Descriptor( containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='Cid', full_name='demo.Request.Cid', index=0, + name='client_id', full_name='demo.Request.client_id', index=0, number=1, type=3, cpp_type=2, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( - name='ReqMsg', full_name='demo.Request.ReqMsg', index=1, + name='request_data', full_name='demo.Request.request_data', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, @@ -60,7 +60,7 @@ _REQUEST = _descriptor.Descriptor( oneofs=[ ], serialized_start=20, - serialized_end=58, + serialized_end=70, ) @@ -72,14 +72,14 @@ _RESPONSE = _descriptor.Descriptor( containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='Sid', full_name='demo.Response.Sid', index=0, + name='server_id', full_name='demo.Response.server_id', index=0, number=1, type=3, cpp_type=2, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( - name='RespMsg', full_name='demo.Response.RespMsg', index=1, + name='response_data', full_name='demo.Response.response_data', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, @@ -97,8 +97,8 @@ _RESPONSE = _descriptor.Descriptor( extension_ranges=[], oneofs=[ ], - serialized_start=60, - serialized_end=100, + serialized_start=72, + serialized_end=124, ) DESCRIPTOR.message_types_by_name['Request'] = _REQUEST @@ -127,8 +127,8 @@ _GRPCDEMO = _descriptor.ServiceDescriptor( file=DESCRIPTOR, index=0, serialized_options=None, - serialized_start=103, - serialized_end=343, + serialized_start=127, + serialized_end=367, methods=[ _descriptor.MethodDescriptor( name='SimpleMethod', diff --git a/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2_grpc.py b/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2_grpc.py index 0f7d5dabbd6..b6d6fc72a13 100644 --- a/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2_grpc.py +++ b/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2_grpc.py @@ -44,7 +44,7 @@ class GRPCDemoServicer(object): def SimpleMethod(self, request, context): """简单模式 - Simple + unary-unary """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') @@ -52,7 +52,7 @@ class GRPCDemoServicer(object): def ClientStreamingMethod(self, request_iterator, context): """客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) - Request-streaming (In a single call, the client can transfer data to the server several times, + stream-unary (In a single call, the client can transfer data to the server several times, but the server can only return a response once.) """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) @@ -61,7 +61,7 @@ class GRPCDemoServicer(object): def ServerStreamingMethod(self, request, context): """服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) - Response-streaming (In a single call, the client can only transmit data to the server at one time, + unary-stream (In a single call, the client can only transmit data to the server at one time, but the server can return the response many times.) """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) @@ -70,7 +70,7 @@ class GRPCDemoServicer(object): def BidirectionalStreamingMethod(self, request_iterator, context): """双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) - Bidirectional streaming (In a single call, both client and server can send and receive data + stream-stream (In a single call, both client and server can send and receive data to each other multiple times.) """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) From 5ca7452c51d4ac87185db1d3025b84c517605397 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Fri, 16 Aug 2019 11:57:35 +0800 Subject: [PATCH 1265/1555] fix:Update the constant name. Replace abbreviations with complete forms of words --- examples/python/easy_start_demo/client.py | 48 +++++++++++------------ examples/python/easy_start_demo/server.py | 44 ++++++++++----------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/examples/python/easy_start_demo/client.py b/examples/python/easy_start_demo/client.py index 46d11d05cbf..b5b994820a3 100644 --- a/examples/python/easy_start_demo/client.py +++ b/examples/python/easy_start_demo/client.py @@ -15,22 +15,22 @@ sys.path.insert(0, os.path.join(BaseDir, "demo_grpc_pbs")) from demo_grpc_pbs import demo_pb2, demo_pb2_grpc -ServerAddress = "127.0.0.1:23334" -ClientId = 1 +SERVER_ADDRESS = "localhost:23334" +CLIENT_ID = 1 # 简单模式 -# Simple Method +# unary-unary def simple_method(stub): print("--------------Call SimpleMethod Begin--------------") - req = demo_pb2.Request(Cid=ClientId, ReqMsg="called by Python client") - resp = stub.SimpleMethod(req) - print("resp from server(%d), the message=%s" % (resp.Sid, resp.RespMsg)) + request = demo_pb2.Request(client_id=CLIENT_ID, request_data="called by Python client") + response = stub.SimpleMethod(request) + print("resp from server(%d), the message=%s" % (response.server_id, response.response_data)) print("--------------Call SimpleMethod Over---------------") # 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) -# Request-streaming (In a single call, the client can transfer data to the server several times, +# stream-unary (In a single call, the client can transfer data to the server several times, # but the server can only return a response once.) def client_streaming_method(stub): print("--------------Call ClientStreamingMethod Begin--------------") @@ -39,50 +39,50 @@ def client_streaming_method(stub): # create a generator def request_messages(): for i in range(5): - req = demo_pb2.Request(Cid=ClientId, ReqMsg=("called by Python client, message:%d" % i)) - yield req + request = demo_pb2.Request(client_id=CLIENT_ID, request_data=("called by Python client, message:%d" % i)) + yield request - resp = stub.ClientStreamingMethod(request_messages()) - print("resp from server(%d), the message=%s" % (resp.Sid, resp.RespMsg)) + response = stub.ClientStreamingMethod(request_messages()) + print("resp from server(%d), the message=%s" % (response.server_id, response.response_data)) print("--------------Call ClientStreamingMethod Over---------------") # 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) -# Response-streaming (In a single call, the client can only transmit data to the server at one time, +# unary-stream (In a single call, the client can only transmit data to the server at one time, # but the server can return the response many times.) def server_streaming_method(stub): print("--------------Call ServerStreamingMethod Begin--------------") - req = demo_pb2.Request(Cid=ClientId, ReqMsg="called by Python client") - resp_s = stub.ServerStreamingMethod(req) - for resp in resp_s: - print("recv from server(%d), message=%s" % (resp.Sid, resp.RespMsg)) + request = demo_pb2.Request(client_id=CLIENT_ID, request_data="called by Python client") + response_iterator = stub.ServerStreamingMethod(request) + for response in response_iterator: + print("recv from server(%d), message=%s" % (response.server_id, response.response_data)) print("--------------Call ServerStreamingMethod Over---------------") # 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) -# Bidirectional Streaming (In a single call, both client and server can send and receive data +# stream-stream (In a single call, both client and server can send and receive data # to each other multiple times.) def bidirectional_streaming_method(stub): print("--------------Call BidirectionalStreamingMethod Begin---------------") # 创建一个生成器 # create a generator - def req_messages(): + def request_messages(): for i in range(5): - req = demo_pb2.Request(Cid=ClientId, ReqMsg=("called by Python client, message: %d" % i)) - yield req + request = demo_pb2.Request(client_id=CLIENT_ID, request_data=("called by Python client, message: %d" % i)) + yield request time.sleep(1) - resp_s = stub.BidirectionalStreamingMethod(req_messages()) - for resp in resp_s: - print("recv from server(%d), message=%s" % (resp.Sid, resp.RespMsg)) + response_iterator = stub.BidirectionalStreamingMethod(request_messages()) + for response in response_iterator: + print("recv from server(%d), message=%s" % (response.server_id, response.response_data)) print("--------------Call BidirectionalStreamingMethod Over---------------") def main(): - with grpc.insecure_channel(ServerAddress) as channel: + with grpc.insecure_channel(SERVER_ADDRESS) as channel: stub = demo_pb2_grpc.GRPCDemoStub(channel) simple_method(stub) diff --git a/examples/python/easy_start_demo/server.py b/examples/python/easy_start_demo/server.py index a4130719ada..60fb84768b7 100644 --- a/examples/python/easy_start_demo/server.py +++ b/examples/python/easy_start_demo/server.py @@ -18,61 +18,61 @@ sys.path.insert(0, os.path.join(BaseDir, "demo_grpc_pbs")) from demo_grpc_pbs import demo_pb2, demo_pb2_grpc -ServerAddress = '127.0.0.1:23334' -ServerId = 1 +SERVER_ADDRESS = 'localhost:23334' +SERVER_ID = 1 class DemoServer(demo_pb2_grpc.GRPCDemoServicer): # 简单模式 - # Simple + # unary-unary def SimpleMethod(self, request, context): - print("SimpleMethod called by client(%d) the message: %s" % (request.Cid, request.ReqMsg)) - resp = demo_pb2.Response(Sid=ServerId, RespMsg="Python server SimpleMethod Ok!!!!") - return resp + print("SimpleMethod called by client(%d) the message: %s" % (request.client_id, request.request_data)) + response = demo_pb2.Response(server_id=SERVER_ID, response_data="Python server SimpleMethod Ok!!!!") + return response # 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) - # Request-streaming (In a single call, the client can transfer data to the server several times, + # stream-unary (In a single call, the client can transfer data to the server several times, # but the server can only return a response once.) def ClientStreamingMethod(self, request_iterator, context): print("ClientStreamingMethod called by client...") - for req in request_iterator: - print("recv from client(%d), message= %s" % (req.Cid, req.ReqMsg)) - resp = demo_pb2.Response(Sid=ServerId, RespMsg="Python server ClientStreamingMethod ok") - return resp + for request in request_iterator: + print("recv from client(%d), message= %s" % (request.client_id, request.request_data)) + response = demo_pb2.Response(server_id=SERVER_ID, response_data="Python server ClientStreamingMethod ok") + return response # 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) - # Response-streaming (In a single call, the client can only transmit data to the server at one time, + # unary-stream (In a single call, the client can only transmit data to the server at one time, # but the server can return the response many times.) def ServerStreamingMethod(self, request, context): - print("ServerStreamingMethod called by client(%d), message= %s" % (request.Cid, request.ReqMsg)) + print("ServerStreamingMethod called by client(%d), message= %s" % (request.client_id, request.request_data)) # 创建一个生成器 # create a generator def response_messages(): for i in range(5): - resp = demo_pb2.Response(Sid=ServerId, RespMsg=("send by Python server, message=%d" % i)) - yield resp + response = demo_pb2.Response(server_id=SERVER_ID, response_data=("send by Python server, message=%d" % i)) + yield response return response_messages() # 双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) - # Bidirectional Streaming (In a single call, both client and server can send and receive data + # stream-stream (In a single call, both client and server can send and receive data # to each other multiple times.) def BidirectionalStreamingMethod(self, request_iterator, context): print("BidirectionalStreamingMethod called by client...") # 开启一个子线程去接收数据 # Open a sub thread to receive data - def parse_req(): - for req in request_iterator: - print("recv from client(%d), message= %s" % (req.Cid, req.ReqMsg)) + def parse_request(): + for request in request_iterator: + print("recv from client(%d), message= %s" % (request.client_id, request.request_data)) - t = Thread(target=parse_req) + t = Thread(target=parse_request) t.start() for i in range(5): - yield demo_pb2.Response(Sid=ServerId, RespMsg=("send by Python server, message= %d" % i)) + yield demo_pb2.Response(server_id=SERVER_ID, response_data=("send by Python server, message= %d" % i)) t.join() @@ -82,7 +82,7 @@ def main(): demo_pb2_grpc.add_GRPCDemoServicer_to_server(DemoServer(), server) - server.add_insecure_port(ServerAddress) + server.add_insecure_port(SERVER_ADDRESS) print("------------------start Python GRPC server") server.start() From 7beba8547eaa94a7eb465e983b8e3f74993feae1 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Fri, 16 Aug 2019 12:08:27 +0800 Subject: [PATCH 1266/1555] fix:Make the title appear properly --- examples/python/easy_start_demo/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/python/easy_start_demo/README.md b/examples/python/easy_start_demo/README.md index 32ad177af17..919b9c5cc61 100644 --- a/examples/python/easy_start_demo/README.md +++ b/examples/python/easy_start_demo/README.md @@ -2,24 +2,24 @@ 在Python中使用gRPC时, 进行数据传输的四种方式。(Four ways of data transmission when gRPC is used in Python.) -- ####简单模式 (unary-unary) +- #### 简单模式 (unary-unary) ```text 没啥好说的,跟调普通方法没差 There's nothing to say. It's no different from the usual way. ``` -- ####客户端流模式 (stream-unary) +- #### 客户端流模式 (stream-unary) ```text 在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应. In a single call, the client can transfer data to the server several times, but the server can only return a response once. ``` -- ####服务端流模式 (unary-stream) +- #### 服务端流模式 (unary-stream) ```text 在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应 In a single call, the client can only transmit data to the server at one time, but the server can return the response many times. ``` -- ####双向流模式 (stream-stream) +- #### 双向流模式 (stream-stream) ```text 在一次调用中, 客户端和服务器都可以向对方多次收发数据 In a single call, both client and server can send and receive data From 6bca0f04a3cf8530c457fae2fb8da5330421f08b Mon Sep 17 00:00:00 2001 From: easy Date: Thu, 15 Aug 2019 11:34:55 +1000 Subject: [PATCH 1267/1555] Use opencensus::tags::TagKey. opencensus::stats::TagKey is deprecated. --- .../registered_opencensus_objects.h | 31 ++++++++++--------- src/cpp/ext/filters/census/grpc_plugin.cc | 17 +++++----- src/cpp/ext/filters/census/grpc_plugin.h | 9 +++--- src/cpp/server/load_reporter/load_reporter.cc | 11 ++++--- src/cpp/server/load_reporter/load_reporter.h | 11 ++++--- 5 files changed, 42 insertions(+), 37 deletions(-) diff --git a/src/core/ext/filters/load_reporting/registered_opencensus_objects.h b/src/core/ext/filters/load_reporting/registered_opencensus_objects.h index 4eacda7c02a..ed11ff42239 100644 --- a/src/core/ext/filters/load_reporting/registered_opencensus_objects.h +++ b/src/core/ext/filters/load_reporting/registered_opencensus_objects.h @@ -22,6 +22,7 @@ #include #include "opencensus/stats/stats.h" +#include "opencensus/tags/tag_key.h" #include "src/cpp/server/load_reporter/constants.h" @@ -80,33 +81,33 @@ inline ::opencensus::stats::MeasureDouble MeasureOtherCallMetric() { // Tags. -inline ::opencensus::stats::TagKey TagKeyToken() { - static const ::opencensus::stats::TagKey token = - opencensus::stats::TagKey::Register(kTagKeyToken); +inline ::opencensus::tags::TagKey TagKeyToken() { + static const ::opencensus::tags::TagKey token = + opencensus::tags::TagKey::Register(kTagKeyToken); return token; } -inline ::opencensus::stats::TagKey TagKeyHost() { - static const ::opencensus::stats::TagKey token = - opencensus::stats::TagKey::Register(kTagKeyHost); +inline ::opencensus::tags::TagKey TagKeyHost() { + static const ::opencensus::tags::TagKey token = + opencensus::tags::TagKey::Register(kTagKeyHost); return token; } -inline ::opencensus::stats::TagKey TagKeyUserId() { - static const ::opencensus::stats::TagKey token = - opencensus::stats::TagKey::Register(kTagKeyUserId); +inline ::opencensus::tags::TagKey TagKeyUserId() { + static const ::opencensus::tags::TagKey token = + opencensus::tags::TagKey::Register(kTagKeyUserId); return token; } -inline ::opencensus::stats::TagKey TagKeyStatus() { - static const ::opencensus::stats::TagKey token = - opencensus::stats::TagKey::Register(kTagKeyStatus); +inline ::opencensus::tags::TagKey TagKeyStatus() { + static const ::opencensus::tags::TagKey token = + opencensus::tags::TagKey::Register(kTagKeyStatus); return token; } -inline ::opencensus::stats::TagKey TagKeyMetricName() { - static const ::opencensus::stats::TagKey token = - opencensus::stats::TagKey::Register(kTagKeyMetricName); +inline ::opencensus::tags::TagKey TagKeyMetricName() { + static const ::opencensus::tags::TagKey token = + opencensus::tags::TagKey::Register(kTagKeyMetricName); return token; } diff --git a/src/cpp/ext/filters/census/grpc_plugin.cc b/src/cpp/ext/filters/census/grpc_plugin.cc index c5018f0673a..63d6f1bde48 100644 --- a/src/cpp/ext/filters/census/grpc_plugin.cc +++ b/src/cpp/ext/filters/census/grpc_plugin.cc @@ -22,6 +22,7 @@ #include +#include "opencensus/tags/tag_key.h" #include "opencensus/trace/span.h" #include "src/cpp/ext/filters/census/channel_filter.h" #include "src/cpp/ext/filters/census/client_filter.h" @@ -33,27 +34,27 @@ namespace grpc { // These measure definitions should be kept in sync across opencensus // implementations--see // https://github.com/census-instrumentation/opencensus-java/blob/master/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcMeasureConstants.java. -::opencensus::stats::TagKey ClientMethodTagKey() { +::opencensus::tags::TagKey ClientMethodTagKey() { static const auto method_tag_key = - ::opencensus::stats::TagKey::Register("grpc_client_method"); + ::opencensus::tags::TagKey::Register("grpc_client_method"); return method_tag_key; } -::opencensus::stats::TagKey ClientStatusTagKey() { +::opencensus::tags::TagKey ClientStatusTagKey() { static const auto status_tag_key = - ::opencensus::stats::TagKey::Register("grpc_client_status"); + ::opencensus::tags::TagKey::Register("grpc_client_status"); return status_tag_key; } -::opencensus::stats::TagKey ServerMethodTagKey() { +::opencensus::tags::TagKey ServerMethodTagKey() { static const auto method_tag_key = - ::opencensus::stats::TagKey::Register("grpc_server_method"); + ::opencensus::tags::TagKey::Register("grpc_server_method"); return method_tag_key; } -::opencensus::stats::TagKey ServerStatusTagKey() { +::opencensus::tags::TagKey ServerStatusTagKey() { static const auto status_tag_key = - ::opencensus::stats::TagKey::Register("grpc_server_status"); + ::opencensus::tags::TagKey::Register("grpc_server_status"); return status_tag_key; } diff --git a/src/cpp/ext/filters/census/grpc_plugin.h b/src/cpp/ext/filters/census/grpc_plugin.h index 13176759e37..14f2481681d 100644 --- a/src/cpp/ext/filters/census/grpc_plugin.h +++ b/src/cpp/ext/filters/census/grpc_plugin.h @@ -24,6 +24,7 @@ #include "absl/strings/string_view.h" #include "include/grpcpp/opencensus.h" #include "opencensus/stats/stats.h" +#include "opencensus/tags/tag_key.h" namespace grpc_impl { class ServerContext; @@ -32,10 +33,10 @@ class ServerContext; namespace grpc { // The tag keys set when recording RPC stats. -::opencensus::stats::TagKey ClientMethodTagKey(); -::opencensus::stats::TagKey ClientStatusTagKey(); -::opencensus::stats::TagKey ServerMethodTagKey(); -::opencensus::stats::TagKey ServerStatusTagKey(); +::opencensus::tags::TagKey ClientMethodTagKey(); +::opencensus::tags::TagKey ClientStatusTagKey(); +::opencensus::tags::TagKey ServerMethodTagKey(); +::opencensus::tags::TagKey ServerStatusTagKey(); // Names of measures used by the plugin--users can create views on these // measures but should not record data for them. diff --git a/src/cpp/server/load_reporter/load_reporter.cc b/src/cpp/server/load_reporter/load_reporter.cc index 422ea62efd5..b4c5e57c354 100644 --- a/src/cpp/server/load_reporter/load_reporter.cc +++ b/src/cpp/server/load_reporter/load_reporter.cc @@ -29,6 +29,7 @@ #include "src/cpp/server/load_reporter/load_reporter.h" #include "opencensus/stats/internal/set_aggregation_window.h" +#include "opencensus/tags/tag_key.h" namespace grpc { namespace load_reporter { @@ -38,12 +39,12 @@ CpuStatsProvider::CpuStatsSample CpuStatsProviderDefaultImpl::GetCpuStats() { } CensusViewProvider::CensusViewProvider() - : tag_key_token_(::opencensus::stats::TagKey::Register(kTagKeyToken)), - tag_key_host_(::opencensus::stats::TagKey::Register(kTagKeyHost)), - tag_key_user_id_(::opencensus::stats::TagKey::Register(kTagKeyUserId)), - tag_key_status_(::opencensus::stats::TagKey::Register(kTagKeyStatus)), + : tag_key_token_(::opencensus::tags::TagKey::Register(kTagKeyToken)), + tag_key_host_(::opencensus::tags::TagKey::Register(kTagKeyHost)), + tag_key_user_id_(::opencensus::tags::TagKey::Register(kTagKeyUserId)), + tag_key_status_(::opencensus::tags::TagKey::Register(kTagKeyStatus)), tag_key_metric_name_( - ::opencensus::stats::TagKey::Register(kTagKeyMetricName)) { + ::opencensus::tags::TagKey::Register(kTagKeyMetricName)) { // One view related to starting a call. auto vd_start_count = ::opencensus::stats::ViewDescriptor() diff --git a/src/cpp/server/load_reporter/load_reporter.h b/src/cpp/server/load_reporter/load_reporter.h index 766e02a407a..44767ee841e 100644 --- a/src/cpp/server/load_reporter/load_reporter.h +++ b/src/cpp/server/load_reporter/load_reporter.h @@ -34,6 +34,7 @@ #include "src/proto/grpc/lb/v1/load_reporter.grpc.pb.h" #include "opencensus/stats/stats.h" +#include "opencensus/tags/tag_key.h" namespace grpc { namespace load_reporter { @@ -75,11 +76,11 @@ class CensusViewProvider { private: ViewDescriptorMap view_descriptor_map_; // Tag keys. - ::opencensus::stats::TagKey tag_key_token_; - ::opencensus::stats::TagKey tag_key_host_; - ::opencensus::stats::TagKey tag_key_user_id_; - ::opencensus::stats::TagKey tag_key_status_; - ::opencensus::stats::TagKey tag_key_metric_name_; + ::opencensus::tags::TagKey tag_key_token_; + ::opencensus::tags::TagKey tag_key_host_; + ::opencensus::tags::TagKey tag_key_user_id_; + ::opencensus::tags::TagKey tag_key_status_; + ::opencensus::tags::TagKey tag_key_metric_name_; }; // The default implementation fetches the real stats from Census. From c1713800e047c4ca2da558b259d5e8abc19f5f30 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Fri, 16 Aug 2019 09:06:06 -0700 Subject: [PATCH 1268/1555] Handle EDS response update in locality map --- include/grpc/impl/codegen/grpc_types.h | 5 + .../client_channel/lb_policy/xds/xds.cc | 144 +++++++++++------- .../lb_policy/xds/xds_load_balancer_api.cc | 21 ++- test/cpp/end2end/xds_end2end_test.cc | 116 ++++++++++++-- 4 files changed, 210 insertions(+), 76 deletions(-) diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index ab29e917ed8..68ae3606e80 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -330,6 +330,11 @@ typedef struct { balancer before using fallback backend addresses from the resolver. If 0, enter fallback mode immediately. Default value is 10000. */ #define GRPC_ARG_XDS_FALLBACK_TIMEOUT_MS "grpc.xds_fallback_timeout_ms" +/* Time in milliseconds to wait before a locality is deleted after it's removed + from the received EDS update. If 0, delete the locality immediately. Default + value is 15 minutes. */ +#define GRPC_ARG_LOCALITY_RETENTION_INTERVAL_MS \ + "grpc.xds_locality_retention_interval_ms" /** If non-zero, grpc server's cronet compression workaround will be enabled */ #define GRPC_ARG_WORKAROUND_CRONET_COMPRESSION \ "grpc.workaround.cronet_compression" diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index 85d1b012696..11bbb72a367 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -109,6 +109,7 @@ #define GRPC_XDS_RECONNECT_JITTER 0.2 #define GRPC_XDS_DEFAULT_FALLBACK_TIMEOUT_MS 10000 #define GRPC_XDS_MIN_CLIENT_LOAD_REPORTING_INTERVAL_MS 1000 +#define GRPC_XDS_DEFAULT_LOCALITY_RETENTION_INTERVAL_MS (15 * 60 * 1000) namespace grpc_core { @@ -452,15 +453,15 @@ class XdsLb : public LoadBalancingPolicy { class LocalityEntry : public InternallyRefCounted { public: LocalityEntry(RefCountedPtr parent, - RefCountedPtr name, - uint32_t locality_weight); + RefCountedPtr name); ~LocalityEntry(); - void UpdateLocked(ServerAddressList serverlist, + void UpdateLocked(uint32_t locality_weight, ServerAddressList serverlist, LoadBalancingPolicy::Config* child_policy_config, const grpc_channel_args* args); void ShutdownLocked(); void ResetBackoffLocked(); + void DeactivateLocked(); void Orphan() override; grpc_connectivity_state connectivity_state() const { @@ -504,6 +505,8 @@ class XdsLb : public LoadBalancingPolicy { grpc_channel_args* CreateChildPolicyArgsLocked( const grpc_channel_args* args); + static void OnDelayedRemovalTimerLocked(void* arg, grpc_error* error); + RefCountedPtr parent_; RefCountedPtr name_; OrphanablePtr child_policy_; @@ -511,20 +514,22 @@ class XdsLb : public LoadBalancingPolicy { RefCountedPtr picker_wrapper_; grpc_connectivity_state connectivity_state_ = GRPC_CHANNEL_IDLE; uint32_t locality_weight_; + grpc_closure on_delayed_removal_timer_; + grpc_timer delayed_removal_timer_; + bool delayed_removal_timer_callback_pending_ = false; }; explicit LocalityMap(XdsLb* xds_policy) : xds_policy_(xds_policy) {} void UpdateLocked(const XdsLocalityList& locality_list, LoadBalancingPolicy::Config* child_policy_config, - const grpc_channel_args* args, XdsLb* parent); + const grpc_channel_args* args, XdsLb* parent, + bool is_initial_update = false); void UpdateXdsPickerLocked(); void ShutdownLocked(); void ResetBackoffLocked(); private: - void PruneLocalities(const XdsLocalityList& locality_list); - XdsLb* xds_policy_; Map, OrphanablePtr, XdsLocalityName::Less> @@ -602,6 +607,7 @@ class XdsLb : public LoadBalancingPolicy { // The policy to use for the backends. RefCountedPtr child_policy_config_; + const grpc_millis locality_retention_interval_ms_; // Map of policies to use in the backend LocalityMap locality_map_; // TODO(mhaidry) : Add support for multiple maps of localities @@ -1711,6 +1717,9 @@ XdsLb::XdsLb(Args args) lb_fallback_timeout_ms_(grpc_channel_args_find_integer( args.args, GRPC_ARG_XDS_FALLBACK_TIMEOUT_MS, {GRPC_XDS_DEFAULT_FALLBACK_TIMEOUT_MS, 0, INT_MAX})), + locality_retention_interval_ms_(grpc_channel_args_find_integer( + args.args, GRPC_ARG_LOCALITY_RETENTION_INTERVAL_MS, + {GRPC_XDS_DEFAULT_LOCALITY_RETENTION_INTERVAL_MS, 0, INT_MAX})), locality_map_(this) { // Record server name. const grpc_arg* arg = grpc_channel_args_find(args.args, GRPC_ARG_SERVER_URI); @@ -1837,7 +1846,7 @@ void XdsLb::UpdateLocked(UpdateArgs args) { } ProcessAddressesAndChannelArgsLocked(std::move(args.addresses), *args.args); locality_map_.UpdateLocked(locality_list_, child_policy_config_.get(), args_, - this); + this, is_initial_update); // Update the existing fallback policy. The fallback policy config and/or the // fallback addresses may be new. if (fallback_policy_ != nullptr) UpdateFallbackPolicyLocked(); @@ -2035,27 +2044,12 @@ void XdsLb::MaybeExitFallbackMode() { // XdsLb::LocalityMap // -void XdsLb::LocalityMap::PruneLocalities(const XdsLocalityList& locality_list) { - for (auto iter = map_.begin(); iter != map_.end();) { - bool found = false; - for (size_t i = 0; i < locality_list.size(); i++) { - if (*locality_list[i].locality_name == *iter->first) { - found = true; - break; - } - } - if (!found) { // Remove entries not present in the locality list. - iter = map_.erase(iter); - } else - iter++; - } -} - void XdsLb::LocalityMap::UpdateLocked( const XdsLocalityList& locality_list, LoadBalancingPolicy::Config* child_policy_config, - const grpc_channel_args* args, XdsLb* parent) { + const grpc_channel_args* args, XdsLb* parent, bool is_initial_update) { if (parent->shutting_down_) return; + // Add or update the localities in locality_list. for (size_t i = 0; i < locality_list.size(); i++) { auto& locality_name = locality_list[i].locality_name; auto iter = map_.find(locality_name); @@ -2063,19 +2057,35 @@ void XdsLb::LocalityMap::UpdateLocked( // locality list. if (iter == map_.end()) { OrphanablePtr new_entry = MakeOrphanable( - parent->Ref(DEBUG_LOCATION, "LocalityEntry"), locality_name, - locality_list[i].lb_weight); + parent->Ref(DEBUG_LOCATION, "LocalityEntry"), locality_name); iter = map_.emplace(locality_name, std::move(new_entry)).first; } // Keep a copy of serverlist in locality_list_ so that we can compare it // with the future ones. - iter->second->UpdateLocked(locality_list[i].serverlist, child_policy_config, + iter->second->UpdateLocked(locality_list[i].lb_weight, + locality_list[i].serverlist, child_policy_config, args); } - PruneLocalities(locality_list); + // Remove (later) the localities not in locality_list. + for (auto& p : map_) { + const XdsLocalityName* locality_name = p.first.get(); + LocalityEntry* locality_entry = p.second.get(); + bool in_locality_list = false; + for (size_t i = 0; i < locality_list.size(); ++i) { + if (*locality_list[i].locality_name == *locality_name) { + in_locality_list = true; + break; + } + } + if (!in_locality_list) locality_entry->DeactivateLocked(); + } + // Generate a new xds picker immediately. + if (!is_initial_update) UpdateXdsPickerLocked(); } void XdsLb::LocalityMap::UpdateXdsPickerLocked() { + // If we are in fallback mode, don't generate an xds picker from localities. + if (xds_policy_->fallback_policy_ != nullptr) return; // Construct a new xds picker which maintains a map of all locality pickers // that are ready. Each locality is represented by a portion of the range // proportional to its weight, such that the total range is the sum of the @@ -2086,23 +2096,8 @@ void XdsLb::LocalityMap::UpdateXdsPickerLocked() { size_t num_transient_failures = 0; Picker::PickerList pickers; for (auto& p : map_) { - // TODO(juanlishen): We should prune a locality (and kill its stats) after - // we know we won't pick from it. We need to improve our update logic to - // make that easier. Consider the following situation: the current map has - // two READY localities A and B, and the update only contains B with the - // same addresses as before. Without the following hack, we will generate - // the same picker containing A and B because we haven't pruned A when the - // update happens. Remove the for loop below once we implement the locality - // map update. - bool in_locality_list = false; - for (size_t i = 0; i < xds_policy_->locality_list_.size(); ++i) { - if (*xds_policy_->locality_list_[i].locality_name == *p.first) { - in_locality_list = true; - break; - } - } - if (!in_locality_list) continue; const LocalityEntry* entry = p.second.get(); + if (entry->locality_weight() == 0) continue; switch (entry->connectivity_state()) { case GRPC_CHANNEL_READY: { end += entry->locality_weight(); @@ -2121,10 +2116,8 @@ void XdsLb::LocalityMap::UpdateXdsPickerLocked() { num_transient_failures++; break; } - default: { - gpr_log(GPR_ERROR, "Invalid locality connectivity state - %d", - entry->connectivity_state()); - } + default: + GPR_UNREACHABLE_CODE(return ); } } // Pass on the constructed xds picker if it has any ready pickers in their map @@ -2148,11 +2141,9 @@ void XdsLb::LocalityMap::UpdateXdsPickerLocked() { UniquePtr( New(xds_policy_->Ref(DEBUG_LOCATION, "QueuePicker")))); } else { - GPR_ASSERT(num_transient_failures == - xds_policy_->locality_map_.map_.size()); grpc_error* error = grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "connections to all localities failing"), + "connections to all active localities failing"), GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE); xds_policy_->channel_control_helper()->UpdateState( GRPC_CHANNEL_TRANSIENT_FAILURE, @@ -2173,15 +2164,14 @@ void XdsLb::LocalityMap::ResetBackoffLocked() { // XdsLb::LocalityMap::LocalityEntry::LocalityEntry( - RefCountedPtr parent, RefCountedPtr name, - uint32_t locality_weight) - : parent_(std::move(parent)), - name_(std::move(name)), - locality_weight_(locality_weight) { + RefCountedPtr parent, RefCountedPtr name) + : parent_(std::move(parent)), name_(std::move(name)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) { gpr_log(GPR_INFO, "[xdslb %p] created LocalityEntry %p for %s", parent_.get(), this, name_->AsHumanReadableString()); } + GRPC_CLOSURE_INIT(&on_delayed_removal_timer_, OnDelayedRemovalTimerLocked, + this, grpc_combiner_scheduler(parent_->combiner())); } XdsLb::LocalityMap::LocalityEntry::~LocalityEntry() { @@ -2245,10 +2235,15 @@ XdsLb::LocalityMap::LocalityEntry::CreateChildPolicyLocked( } void XdsLb::LocalityMap::LocalityEntry::UpdateLocked( - ServerAddressList serverlist, + uint32_t locality_weight, ServerAddressList serverlist, LoadBalancingPolicy::Config* child_policy_config, const grpc_channel_args* args_in) { if (parent_->shutting_down_) return; + // Update locality weight. + locality_weight_ = locality_weight; + if (delayed_removal_timer_callback_pending_) { + grpc_timer_cancel(&delayed_removal_timer_); + } // Construct update args. UpdateArgs update_args; update_args.addresses = std::move(serverlist); @@ -2373,6 +2368,9 @@ void XdsLb::LocalityMap::LocalityEntry::ShutdownLocked() { // Drop our ref to the child's picker, in case it's holding a ref to // the child. picker_wrapper_.reset(); + if (delayed_removal_timer_callback_pending_) { + grpc_timer_cancel(&delayed_removal_timer_); + } } void XdsLb::LocalityMap::LocalityEntry::ResetBackoffLocked() { @@ -2387,6 +2385,36 @@ void XdsLb::LocalityMap::LocalityEntry::Orphan() { Unref(); } +void XdsLb::LocalityMap::LocalityEntry::DeactivateLocked() { + // If locality retaining is disabled, delete the locality immediately. + if (parent_->locality_retention_interval_ms_ == 0) { + parent_->locality_map_.map_.erase(name_); + return; + } + // If already deactivated, don't do that again. + if (locality_weight_ == 0) return; + // Set the locality weight to 0 so that future xds picker won't contain this + // locality. + locality_weight_ = 0; + // Start a timer to delete the locality. + Ref(DEBUG_LOCATION, "LocalityEntry+timer").release(); + grpc_timer_init( + &delayed_removal_timer_, + ExecCtx::Get()->Now() + parent_->locality_retention_interval_ms_, + &on_delayed_removal_timer_); + delayed_removal_timer_callback_pending_ = true; +} + +void XdsLb::LocalityMap::LocalityEntry::OnDelayedRemovalTimerLocked( + void* arg, grpc_error* error) { + LocalityEntry* self = static_cast(arg); + self->delayed_removal_timer_callback_pending_ = false; + if (error == GRPC_ERROR_NONE && self->locality_weight_ == 0) { + self->parent_->locality_map_.map_.erase(self->name_); + } + self->Unref(DEBUG_LOCATION, "LocalityEntry+timer"); +} + // // XdsLb::LocalityEntry::Helper // @@ -2446,8 +2474,6 @@ void XdsLb::LocalityMap::LocalityEntry::Helper::UpdateState( entry_->parent_->MaybeCancelFallbackAtStartupChecks(); entry_->parent_->MaybeExitFallbackMode(); } - // If we are in fallback mode, ignore update request from the child policy. - if (entry_->parent_->fallback_policy_ != nullptr) return; GPR_ASSERT(entry_->parent_->lb_chand_ != nullptr); // Cache the picker and its state in the entry. entry_->picker_wrapper_ = MakeRefCounted( diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc index bd8a7142e38..ac87053d47f 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc @@ -137,6 +137,16 @@ UniquePtr StringCopy(const upb_strview& strview) { grpc_error* LocalityParse( const envoy_api_v2_endpoint_LocalityLbEndpoints* locality_lb_endpoints, XdsLocalityInfo* locality_info) { + // Parse LB weight. + const google_protobuf_UInt32Value* lb_weight = + envoy_api_v2_endpoint_LocalityLbEndpoints_load_balancing_weight( + locality_lb_endpoints); + // If LB weight is not specified, it means this locality is assigned no load. + // TODO(juanlishen): When we support CDS to configure the inter-locality + // policy, we should change the LB weight handling. + locality_info->lb_weight = + lb_weight != nullptr ? google_protobuf_UInt32Value_value(lb_weight) : 0; + if (locality_info->lb_weight == 0) return GRPC_ERROR_NONE; // Parse locality name. const envoy_api_v2_core_Locality* locality = envoy_api_v2_endpoint_LocalityLbEndpoints_locality(locality_lb_endpoints); @@ -154,14 +164,7 @@ grpc_error* LocalityParse( &locality_info->serverlist); if (error != GRPC_ERROR_NONE) return error; } - // Parse the lb_weight and priority. - const google_protobuf_UInt32Value* lb_weight = - envoy_api_v2_endpoint_LocalityLbEndpoints_load_balancing_weight( - locality_lb_endpoints); - // If LB weight is not specified, the default weight 0 is used, which means - // this locality is assigned no load. - locality_info->lb_weight = - lb_weight != nullptr ? google_protobuf_UInt32Value_value(lb_weight) : 0; + // Parse the priority. locality_info->priority = envoy_api_v2_endpoint_LocalityLbEndpoints_priority(locality_lb_endpoints); return GRPC_ERROR_NONE; @@ -253,6 +256,8 @@ grpc_error* XdsEdsResponseDecodeAndParse(const grpc_slice& encoded_response, XdsLocalityInfo locality_info; grpc_error* error = LocalityParse(endpoints[i], &locality_info); if (error != GRPC_ERROR_NONE) return error; + // Filter out locality with weight 0. + if (locality_info.lb_weight == 0) continue; update->locality_list.push_back(std::move(locality_info)); } // The locality list is sorted here into deterministic order so that it's diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index 9afa141ae21..0a5c3740096 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -316,9 +317,11 @@ class EdsServiceImpl : public EdsService { gpr_log(GPR_INFO, "LB[%p]: shut down", this); } + // TODO(juanlishen): Put the args into a struct. static DiscoveryResponse BuildResponse( const std::vector>& backend_ports, const std::vector& lb_weights = {}, + size_t first_locality_name_index = 0, const std::map& drop_categories = {}, const FractionalPercent::DenominatorType denominator = FractionalPercent::MILLION) { @@ -333,7 +336,8 @@ class EdsServiceImpl : public EdsService { endpoints->mutable_locality()->set_region(kDefaultLocalityRegion); endpoints->mutable_locality()->set_zone(kDefaultLocalityZone); std::ostringstream sub_zone; - sub_zone << kDefaultLocalitySubzone << '_' << i; + sub_zone << kDefaultLocalitySubzone << '_' + << first_locality_name_index + i; endpoints->mutable_locality()->set_sub_zone(sub_zone.str()); for (const int& backend_port : backend_ports[i]) { auto* lb_endpoints = endpoints->add_lb_endpoints(); @@ -1114,8 +1118,102 @@ TEST_F(SingleBalancerTest, LocalityMapStressTest) { // Wait until backend 1 is ready, before which kNumLocalities localities are // removed by the xds policy. WaitForBackend(1); + // The EDS service got a single request. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + // and sent two responses. + EXPECT_EQ(2U, balancers_[0]->eds_service()->response_count()); +} + +TEST_F(SingleBalancerTest, LocalityMapUpdate) { + SetNextResolution({}, kDefaultServiceConfig_.c_str()); + SetNextResolutionForLbChannelAllBalancers(); + const size_t kNumRpcs = 1000; + // The locality weight for the first 3 localities. + const std::vector kLocalityWeights0 = {2, 3, 4}; + const double kTotalLocalityWeight0 = + std::accumulate(kLocalityWeights0.begin(), kLocalityWeights0.end(), 0); + std::vector locality_weight_rate_0; + for (int weight : kLocalityWeights0) { + locality_weight_rate_0.push_back(weight / kTotalLocalityWeight0); + } + // Delete the first locality, keep the second locality, change the third + // locality's weight from 4 to 2, and add a new locality with weight 6. + const std::vector kLocalityWeights1 = {3, 2, 6}; + const double kTotalLocalityWeight1 = + std::accumulate(kLocalityWeights1.begin(), kLocalityWeights1.end(), 0); + std::vector locality_weight_rate_1 = { + 0 /* placeholder for locality 0 */}; + for (int weight : kLocalityWeights1) { + locality_weight_rate_1.push_back(weight / kTotalLocalityWeight1); + } + ScheduleResponseForBalancer( + 0, + EdsServiceImpl::BuildResponse( + GetBackendPortsInGroups(0 /*start_index*/, 3 /*stop_index*/, + 3 /*num_group*/), + kLocalityWeights0), + 0); + ScheduleResponseForBalancer( + 0, + EdsServiceImpl::BuildResponse( + GetBackendPortsInGroups(1 /*start_index*/, 4 /*stop_index*/, + 3 /*num_group*/), + kLocalityWeights1, 1 /*first_locality_name_index*/), + 5000); + // Wait for the first 3 backends to be ready. + WaitForAllBackends(1, 0, 3); + gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); + // Send kNumRpcs RPCs. + CheckRpcSendOk(kNumRpcs); + gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); + // The picking rates of the first 3 backends should be roughly equal to the + // expectation. + std::vector locality_picked_rates; + for (size_t i = 0; i < 3; ++i) { + locality_picked_rates.push_back( + static_cast(backends_[i]->backend_service()->request_count()) / + kNumRpcs); + } + const double kErrorTolerance = 0.2; + for (size_t i = 0; i < 3; ++i) { + EXPECT_THAT( + locality_picked_rates[i], + ::testing::AllOf( + ::testing::Ge(locality_weight_rate_0[i] * (1 - kErrorTolerance)), + ::testing::Le(locality_weight_rate_0[i] * (1 + kErrorTolerance)))); + } + // Backend 3 hasn't received any request. + EXPECT_EQ(0U, backends_[3]->backend_service()->request_count()); // The EDS service got a single request, and sent a single response. EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); + // Wait until the locality update has been processed, as signaled by backend 3 + // receiving a request. + WaitForBackend(3); + gpr_log(GPR_INFO, "========= BEFORE SECOND BATCH =========="); + // Send kNumRpcs RPCs. + CheckRpcSendOk(kNumRpcs); + gpr_log(GPR_INFO, "========= DONE WITH SECOND BATCH =========="); + // Backend 0 no longer receives any request. + EXPECT_EQ(0U, backends_[0]->backend_service()->request_count()); + // The picking rates of the last 3 backends should be roughly equal to the + // expectation. + locality_picked_rates = {0 /* placeholder for backend 0 */}; + for (size_t i = 1; i < 4; ++i) { + locality_picked_rates.push_back( + static_cast(backends_[i]->backend_service()->request_count()) / + kNumRpcs); + } + for (size_t i = 1; i < 4; ++i) { + EXPECT_THAT( + locality_picked_rates[i], + ::testing::AllOf( + ::testing::Ge(locality_weight_rate_1[i] * (1 - kErrorTolerance)), + ::testing::Le(locality_weight_rate_1[i] * (1 + kErrorTolerance)))); + } + // The EDS service got a single request. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + // and sent two responses. EXPECT_EQ(2U, balancers_[0]->eds_service()->response_count()); } @@ -1133,7 +1231,7 @@ TEST_F(SingleBalancerTest, Drop) { ScheduleResponseForBalancer( 0, EdsServiceImpl::BuildResponse( - GetBackendPortsInGroups(), {}, + GetBackendPortsInGroups(), {}, 0, {{kLbDropType, kDropPerMillionForLb}, {kThrottleDropType, kDropPerMillionForThrottle}}), 0); @@ -1174,7 +1272,7 @@ TEST_F(SingleBalancerTest, DropPerHundred) { // The EDS response contains one drop category. ScheduleResponseForBalancer( 0, - EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), {}, + EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), {}, 0, {{kLbDropType, kDropPerHundredForLb}}, FractionalPercent::HUNDRED), 0); @@ -1214,7 +1312,7 @@ TEST_F(SingleBalancerTest, DropPerTenThousand) { // The EDS response contains one drop category. ScheduleResponseForBalancer( 0, - EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), {}, + EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), {}, 0, {{kLbDropType, kDropPerTenThousandForLb}}, FractionalPercent::TEN_THOUSAND), 0); @@ -1258,7 +1356,7 @@ TEST_F(SingleBalancerTest, DropUpdate) { // The first EDS response contains one drop category. ScheduleResponseForBalancer( 0, - EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), {}, + EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), {}, 0, {{kLbDropType, kDropPerMillionForLb}}), 0); // The second EDS response contains two drop categories. @@ -1268,7 +1366,7 @@ TEST_F(SingleBalancerTest, DropUpdate) { ScheduleResponseForBalancer( 0, EdsServiceImpl::BuildResponse( - GetBackendPortsInGroups(), {}, + GetBackendPortsInGroups(), {}, 0, {{kLbDropType, kDropPerMillionForLb}, {kThrottleDropType, kDropPerMillionForThrottle}}), 10000); @@ -1354,7 +1452,7 @@ TEST_F(SingleBalancerTest, DropAll) { ScheduleResponseForBalancer( 0, EdsServiceImpl::BuildResponse( - GetBackendPortsInGroups(), {}, + GetBackendPortsInGroups(), {}, 0, {{kLbDropType, kDropPerMillionForLb}, {kThrottleDropType, kDropPerMillionForThrottle}}), 0); @@ -1547,7 +1645,7 @@ TEST_F(SingleBalancerTest, FallbackModeIsExitedWhenBalancerSaysToDropAllCalls) { // Return a new balancer that sends a response to drop all calls. ScheduleResponseForBalancer( 0, - EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), {}, + EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), {}, 0, {{kLbDropType, 1000000}}), 0); SetNextResolutionForLbChannelAllBalancers(); @@ -2005,7 +2103,7 @@ TEST_F(SingleBalancerWithClientLoadReportingAndDropTest, Vanilla) { ScheduleResponseForBalancer( 0, EdsServiceImpl::BuildResponse( - GetBackendPortsInGroups(), {}, + GetBackendPortsInGroups(), {}, 0, {{kLbDropType, kDropPerMillionForLb}, {kThrottleDropType, kDropPerMillionForThrottle}}), 0); From fff51d3842f4c9d5b3386e5a08dacd715e358fd8 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 14 Aug 2019 11:13:54 -0700 Subject: [PATCH 1269/1555] Remove sources_and_headers.json --- .../sources_and_headers.json.template | 72 - .../generated/sources_and_headers.json | 11052 ---------------- 2 files changed, 11124 deletions(-) delete mode 100644 templates/tools/run_tests/generated/sources_and_headers.json.template delete mode 100644 tools/run_tests/generated/sources_and_headers.json diff --git a/templates/tools/run_tests/generated/sources_and_headers.json.template b/templates/tools/run_tests/generated/sources_and_headers.json.template deleted file mode 100644 index c7dc3c837d1..00000000000 --- a/templates/tools/run_tests/generated/sources_and_headers.json.template +++ /dev/null @@ -1,72 +0,0 @@ -%YAML 1.2 ---- | - <%! - import json - import os - - def proto_headers(src): - out = [] - for f in src: - name, ext = os.path.splitext(f) - if ext == '.proto': - out.extend(fmt % name for fmt in ['%s.grpc.pb.h', '%s.pb.h', '%s_mock.grpc.pb.h']) - return out - - def all_targets(targets, libs, filegroups): - for tgt in targets: - yield ('target', tgt) - for tgt in libs: - yield ('lib', tgt) - for tgt in filegroups: - yield ('filegroup', tgt) - - def no_protos_filter(src): - return os.path.splitext(src)[1] != '.proto' - - def no_third_party_filter(src): - return not src.startswith('third_party/') - - def filter_srcs(srcs, filters): - out = [] - for s in srcs: - filter_passes = (f(s) for f in filters) - if all(filter_passes): - out.append(s) - return out - %> - - ${json.dumps([{"name": tgt.name, - "type": typ, - "is_filegroup": False, - "language": tgt.language, - "third_party": tgt.boringssl or tgt.zlib, - "src": sorted( - filter_srcs(tgt.own_src, (no_protos_filter, no_third_party_filter)) + - filter_srcs(tgt.own_public_headers, (no_protos_filter, no_third_party_filter)) + - filter_srcs(tgt.own_headers, (no_third_party_filter,))), - "headers": sorted( - tgt.own_public_headers + - tgt.own_headers + - proto_headers(tgt.own_src)), - "deps": sorted(tgt.get('deps', []) + - tgt.get('uses', []) + - tgt.get('filegroups', []))} - for typ, tgt in all_targets(targets, libs, [])] + - [{"name": tgt.name, - "type": typ, - "is_filegroup": True, - "language": tgt.language, - "third_party": tgt.boringssl or tgt.zlib, - "src": sorted( - filter_srcs(tgt.own_src, (no_protos_filter, no_third_party_filter)) + - filter_srcs(tgt.own_public_headers, (no_protos_filter, no_third_party_filter)) + - filter_srcs(tgt.own_headers, (no_third_party_filter,))), - "headers": sorted( - tgt.own_public_headers + - tgt.own_headers + - proto_headers(tgt.own_src)), - "deps": sorted(tgt.get('deps', []) + - tgt.get('uses', []) + - tgt.get('filegroups', []))} - for typ, tgt in all_targets([], [], filegroups)], - sort_keys=True, indent=2)} diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json deleted file mode 100644 index eeb66a585ee..00000000000 --- a/tools/run_tests/generated/sources_and_headers.json +++ /dev/null @@ -1,11052 +0,0 @@ - - -[ - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "algorithm_test", - "src": [ - "test/core/compression/algorithm_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "alloc_test", - "src": [ - "test/core/gpr/alloc_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "alpn_test", - "src": [ - "test/core/transport/chttp2/alpn_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "alts_credentials_fuzzer", - "src": [ - "test/core/security/alts_credentials_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "api_fuzzer", - "src": [ - "test/core/end2end/fuzzers/api_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "arena_test", - "src": [ - "test/core/gpr/arena_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "avl_test", - "src": [ - "test/core/avl/avl_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util", - "test_tcp_server" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "bad_server_response_test", - "src": [ - "test/core/end2end/bad_server_response_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "bin_decoder_test", - "src": [ - "test/core/transport/chttp2/bin_decoder_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "bin_encoder_test", - "src": [ - "test/core/transport/chttp2/bin_encoder_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "buffer_list_test", - "src": [ - "test/core/iomgr/buffer_list_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "channel_create_test", - "src": [ - "test/core/surface/channel_create_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "check_epollexclusive", - "src": [ - "test/build/check_epollexclusive.c" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "chttp2_hpack_encoder_test", - "src": [ - "test/core/transport/chttp2/hpack_encoder_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "chttp2_stream_map_test", - "src": [ - "test/core/transport/chttp2/stream_map_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "chttp2_varint_test", - "src": [ - "test/core/transport/chttp2/varint_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "client_fuzzer", - "src": [ - "test/core/end2end/fuzzers/client_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "close_fd_test", - "src": [ - "test/core/bad_connection/close_fd_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "cmdline_test", - "src": [ - "test/core/util/cmdline_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "combiner_test", - "src": [ - "test/core/iomgr/combiner_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "compression_test", - "src": [ - "test/core/compression/compression_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "concurrent_connectivity_test", - "src": [ - "test/core/surface/concurrent_connectivity_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "connection_refused_test", - "src": [ - "test/core/end2end/connection_refused_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "dns_resolver_connectivity_test", - "src": [ - "test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "dns_resolver_cooldown_using_ares_resolver_test", - "src": [ - "test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "dns_resolver_cooldown_using_native_resolver_test", - "src": [ - "test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "dns_resolver_test", - "src": [ - "test/core/client_channel/resolvers/dns_resolver_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "dualstack_socket_test", - "src": [ - "test/core/end2end/dualstack_socket_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "endpoint_pair_test", - "src": [ - "test/core/iomgr/endpoint_pair_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "error_test", - "src": [ - "test/core/iomgr/error_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "ev_epollex_linux_test", - "src": [ - "test/core/iomgr/ev_epollex_linux_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "fake_resolver_test", - "src": [ - "test/core/client_channel/resolvers/fake_resolver_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util", - "transport_security_test_lib" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "fake_transport_security_test", - "src": [ - "test/core/tsi/fake_transport_security_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "fd_conservation_posix_test", - "src": [ - "test/core/iomgr/fd_conservation_posix_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "fd_posix_test", - "src": [ - "test/core/iomgr/fd_posix_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "fling_client", - "src": [ - "test/core/fling/client.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "fling_server", - "src": [ - "test/core/fling/server.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "fling_stream_test", - "src": [ - "test/core/fling/fling_stream_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "fling_test", - "src": [ - "test/core/fling/fling_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "fork_test", - "src": [ - "test/core/gprpp/fork_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "goaway_server_test", - "src": [ - "test/core/end2end/goaway_server_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "gpr_cpu_test", - "src": [ - "test/core/gpr/cpu_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "gpr_env_test", - "src": [ - "test/core/gpr/env_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "gpr_host_port_test", - "src": [ - "test/core/gprpp/host_port_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "gpr_log_test", - "src": [ - "test/core/gpr/log_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "gpr_manual_constructor_test", - "src": [ - "test/core/gprpp/manual_constructor_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "gpr_mpscq_test", - "src": [ - "test/core/gpr/mpscq_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "gpr_spinlock_test", - "src": [ - "test/core/gpr/spinlock_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "gpr_string_test", - "src": [ - "test/core/gpr/string_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "gpr_sync_test", - "src": [ - "test/core/gpr/sync_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "gpr_thd_test", - "src": [ - "test/core/gprpp/thd_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "gpr_time_test", - "src": [ - "test/core/gpr/time_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "gpr_tls_test", - "src": [ - "test/core/gpr/tls_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "gpr_useful_test", - "src": [ - "test/core/gpr/useful_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_auth_context_test", - "src": [ - "test/core/security/auth_context_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_b64_test", - "src": [ - "test/core/slice/b64_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_byte_buffer_reader_test", - "src": [ - "test/core/surface/byte_buffer_reader_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_channel_args_test", - "src": [ - "test/core/channel/channel_args_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_channel_stack_builder_test", - "src": [ - "test/core/channel/channel_stack_builder_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_channel_stack_test", - "src": [ - "test/core/channel/channel_stack_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_completion_queue_test", - "src": [ - "test/core/surface/completion_queue_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_completion_queue_threading_test", - "src": [ - "test/core/surface/completion_queue_threading_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_control_plane_credentials_test", - "src": [ - "test/core/security/control_plane_credentials_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "cmdline", - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_create_jwt", - "src": [ - "test/core/security/create_jwt.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_credentials_test", - "src": [ - "test/core/security/credentials_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_ipv6_loopback_available_test", - "src": [ - "test/core/iomgr/grpc_ipv6_loopback_available_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_json_token_test", - "src": [ - "test/core/security/json_token_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_jwt_verifier_test", - "src": [ - "test/core/security/jwt_verifier_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "cmdline", - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_print_google_default_creds_token", - "src": [ - "test/core/security/print_google_default_creds_token.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_security_connector_test", - "src": [ - "test/core/security/security_connector_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_ssl_credentials_test", - "src": [ - "test/core/security/ssl_credentials_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "cmdline", - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_verify_jwt", - "src": [ - "test/core/security/verify_jwt.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "handshake_client_ssl", - "src": [ - "test/core/handshake/client_ssl.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [ - "test/core/handshake/server_ssl_common.h" - ], - "is_filegroup": false, - "language": "c", - "name": "handshake_server_ssl", - "src": [ - "test/core/handshake/server_ssl.cc", - "test/core/handshake/server_ssl_common.cc", - "test/core/handshake/server_ssl_common.h" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [ - "test/core/handshake/server_ssl_common.h" - ], - "is_filegroup": false, - "language": "c", - "name": "handshake_server_with_readahead_handshaker", - "src": [ - "test/core/handshake/readahead_handshaker_server_ssl.cc", - "test/core/handshake/server_ssl_common.cc", - "test/core/handshake/server_ssl_common.h" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "handshake_verify_peer_options", - "src": [ - "test/core/handshake/verify_peer_options.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "histogram_test", - "src": [ - "test/core/util/histogram_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "hpack_parser_fuzzer_test", - "src": [ - "test/core/transport/chttp2/hpack_parser_fuzzer_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "hpack_parser_test", - "src": [ - "test/core/transport/chttp2/hpack_parser_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "hpack_table_test", - "src": [ - "test/core/transport/chttp2/hpack_table_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "http_parser_test", - "src": [ - "test/core/http/parser_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "http_request_fuzzer_test", - "src": [ - "test/core/http/request_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "http_response_fuzzer_test", - "src": [ - "test/core/http/response_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "httpcli_format_request_test", - "src": [ - "test/core/http/format_request_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "httpcli_test", - "src": [ - "test/core/http/httpcli_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "httpscli_test", - "src": [ - "test/core/http/httpscli_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "init_test", - "src": [ - "test/core/surface/init_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [ - "test/core/end2end/end2end_tests.h" - ], - "is_filegroup": false, - "language": "c", - "name": "inproc_callback_test", - "src": [ - "test/core/end2end/end2end_tests.h", - "test/core/end2end/inproc_callback_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "invalid_call_argument_test", - "src": [ - "test/core/end2end/invalid_call_argument_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "json_fuzzer_test", - "src": [ - "test/core/json/fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "json_rewrite", - "src": [ - "test/core/json/json_rewrite.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "json_rewrite_test", - "src": [ - "test/core/json/json_rewrite_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "json_stream_error_test", - "src": [ - "test/core/json/json_stream_error_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "json_test", - "src": [ - "test/core/json/json_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "lame_client_test", - "src": [ - "test/core/surface/lame_client_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "load_file_test", - "src": [ - "test/core/iomgr/load_file_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "low_level_ping_pong_benchmark", - "src": [ - "test/core/network_benchmarks/low_level_ping_pong.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "memory_usage_client", - "src": [ - "test/core/memory_usage/client.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "memory_usage_server", - "src": [ - "test/core/memory_usage/server.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "memory_usage_test", - "src": [ - "test/core/memory_usage/memory_usage_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "message_compress_test", - "src": [ - "test/core/compression/message_compress_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "minimal_stack_is_minimal_test", - "src": [ - "test/core/channel/minimal_stack_is_minimal_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "mpmcqueue_test", - "src": [ - "test/core/iomgr/mpmcqueue_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "multiple_server_queues_test", - "src": [ - "test/core/end2end/multiple_server_queues_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "murmur_hash_test", - "src": [ - "test/core/gpr/murmur_hash_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "nanopb_fuzzer_response_test", - "src": [ - "test/core/nanopb/fuzzer_response.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "nanopb_fuzzer_serverlist_test", - "src": [ - "test/core/nanopb/fuzzer_serverlist.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "no_server_test", - "src": [ - "test/core/end2end/no_server_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "num_external_connectivity_watchers_test", - "src": [ - "test/core/surface/num_external_connectivity_watchers_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "parse_address_test", - "src": [ - "test/core/client_channel/parse_address_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "parse_address_with_named_scope_id_test", - "src": [ - "test/core/client_channel/parse_address_with_named_scope_id_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "percent_decode_fuzzer", - "src": [ - "test/core/slice/percent_decode_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "percent_encode_fuzzer", - "src": [ - "test/core/slice/percent_encode_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "percent_encoding_test", - "src": [ - "test/core/slice/percent_encoding_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "resolve_address_using_ares_resolver_posix_test", - "src": [ - "test/core/iomgr/resolve_address_posix_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "resolve_address_using_ares_resolver_test", - "src": [ - "test/core/iomgr/resolve_address_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "resolve_address_using_native_resolver_posix_test", - "src": [ - "test/core/iomgr/resolve_address_posix_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "resolve_address_using_native_resolver_test", - "src": [ - "test/core/iomgr/resolve_address_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "resource_quota_test", - "src": [ - "test/core/iomgr/resource_quota_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "secure_channel_create_test", - "src": [ - "test/core/surface/secure_channel_create_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "secure_endpoint_test", - "src": [ - "test/core/security/secure_endpoint_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "sequential_connectivity_test", - "src": [ - "test/core/surface/sequential_connectivity_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "server_chttp2_test", - "src": [ - "test/core/surface/server_chttp2_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "server_fuzzer", - "src": [ - "test/core/end2end/fuzzers/server_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "server_test", - "src": [ - "test/core/surface/server_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "slice_buffer_test", - "src": [ - "test/core/slice/slice_buffer_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "slice_string_helpers_test", - "src": [ - "test/core/slice/slice_string_helpers_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "slice_test", - "src": [ - "test/core/slice/slice_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "sockaddr_resolver_test", - "src": [ - "test/core/client_channel/resolvers/sockaddr_resolver_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "sockaddr_utils_test", - "src": [ - "test/core/iomgr/sockaddr_utils_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "socket_utils_test", - "src": [ - "test/core/iomgr/socket_utils_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "ssl_server_fuzzer", - "src": [ - "test/core/security/ssl_server_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util", - "transport_security_test_lib" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "ssl_transport_security_test", - "src": [ - "test/core/tsi/ssl_transport_security_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "status_conversion_test", - "src": [ - "test/core/transport/status_conversion_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "stream_compression_test", - "src": [ - "test/core/compression/stream_compression_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "stream_owned_slice_test", - "src": [ - "test/core/transport/stream_owned_slice_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "tcp_client_posix_test", - "src": [ - "test/core/iomgr/tcp_client_posix_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "tcp_client_uv_test", - "src": [ - "test/core/iomgr/tcp_client_uv_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "tcp_posix_test", - "src": [ - "test/core/iomgr/tcp_posix_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "tcp_server_posix_test", - "src": [ - "test/core/iomgr/tcp_server_posix_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "tcp_server_uv_test", - "src": [ - "test/core/iomgr/tcp_server_uv_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "threadpool_test", - "src": [ - "test/core/iomgr/threadpool_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "time_averaged_stats_test", - "src": [ - "test/core/iomgr/time_averaged_stats_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "timeout_encoding_test", - "src": [ - "test/core/transport/timeout_encoding_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "timer_heap_test", - "src": [ - "test/core/iomgr/timer_heap_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "timer_list_test", - "src": [ - "test/core/iomgr/timer_list_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "transport_connectivity_state_test", - "src": [ - "test/core/transport/connectivity_state_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "transport_metadata_test", - "src": [ - "test/core/transport/metadata_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "transport_security_test", - "src": [ - "test/core/tsi/transport_security_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "udp_server_test", - "src": [ - "test/core/iomgr/udp_server_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "uri_fuzzer_test", - "src": [ - "test/core/client_channel/uri_fuzzer_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "uri_parser_test", - "src": [ - "test/core/client_channel/uri_parser_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "alarm_test", - "src": [ - "test/cpp/common/alarm_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "alts_test_util", - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "alts_counter_test", - "src": [ - "test/core/tsi/alts/frame_protector/alts_counter_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "alts_test_util", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "alts_crypt_test", - "src": [ - "test/core/tsi/alts/crypt/aes_gcm_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "alts_test_util", - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "alts_crypter_test", - "src": [ - "test/core/tsi/alts/frame_protector/alts_crypter_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "alts_test_util", - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "alts_frame_handler_test", - "src": [ - "test/core/tsi/alts/frame_protector/frame_handler_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "alts_test_util", - "gpr", - "grpc", - "transport_security_test_lib" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "alts_frame_protector_test", - "src": [ - "test/core/tsi/alts/frame_protector/alts_frame_protector_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "alts_test_util", - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "alts_grpc_record_protocol_test", - "src": [ - "test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "alts_test_util", - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "alts_handshaker_client_test", - "src": [ - "test/core/tsi/alts/handshaker/alts_handshaker_client_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "alts_test_util", - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "alts_iovec_record_protocol_test", - "src": [ - "test/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "alts_security_connector_test", - "src": [ - "test/core/security/alts_security_connector_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "alts_test_util", - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "alts_tsi_handshaker_test", - "src": [ - "test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "alts_test_util", - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "alts_tsi_utils_test", - "src": [ - "test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "alts_test_util", - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "alts_zero_copy_grpc_protector_test", - "src": [ - "test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "async_end2end_test", - "src": [ - "test/cpp/end2end/async_end2end_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "auth_property_iterator_test", - "src": [ - "test/cpp/common/auth_property_iterator_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "backoff_test", - "src": [ - "test/core/backoff/backoff_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "bdp_estimator_test", - "src": [ - "test/core/transport/bdp_estimator_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "bm_alarm", - "src": [ - "test/cpp/microbenchmarks/bm_alarm.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "bm_arena", - "src": [ - "test/cpp/microbenchmarks/bm_arena.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "bm_byte_buffer", - "src": [ - "test/cpp/microbenchmarks/bm_byte_buffer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "bm_call_create", - "src": [ - "test/cpp/microbenchmarks/bm_call_create.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "bm_callback_test_service_impl", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [ - "test/cpp/microbenchmarks/callback_streaming_ping_pong.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "bm_callback_streaming_ping_pong", - "src": [ - "test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc", - "test/cpp/microbenchmarks/callback_streaming_ping_pong.h" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "bm_callback_test_service_impl", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [ - "test/cpp/microbenchmarks/callback_unary_ping_pong.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "bm_callback_unary_ping_pong", - "src": [ - "test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc", - "test/cpp/microbenchmarks/callback_unary_ping_pong.h" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "bm_channel", - "src": [ - "test/cpp/microbenchmarks/bm_channel.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "bm_chttp2_hpack", - "src": [ - "test/cpp/microbenchmarks/bm_chttp2_hpack.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "bm_chttp2_transport", - "src": [ - "test/cpp/microbenchmarks/bm_chttp2_transport.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "bm_closure", - "src": [ - "test/cpp/microbenchmarks/bm_closure.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "bm_cq", - "src": [ - "test/cpp/microbenchmarks/bm_cq.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "bm_cq_multiple_threads", - "src": [ - "test/cpp/microbenchmarks/bm_cq_multiple_threads.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "bm_error", - "src": [ - "test/cpp/microbenchmarks/bm_error.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [ - "test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "bm_fullstack_streaming_ping_pong", - "src": [ - "test/cpp/microbenchmarks/bm_fullstack_streaming_ping_pong.cc", - "test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [ - "test/cpp/microbenchmarks/fullstack_streaming_pump.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "bm_fullstack_streaming_pump", - "src": [ - "test/cpp/microbenchmarks/bm_fullstack_streaming_pump.cc", - "test/cpp/microbenchmarks/fullstack_streaming_pump.h" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "bm_fullstack_trickle", - "src": [ - "test/cpp/microbenchmarks/bm_fullstack_trickle.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [ - "test/cpp/microbenchmarks/fullstack_unary_ping_pong.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "bm_fullstack_unary_ping_pong", - "src": [ - "test/cpp/microbenchmarks/bm_fullstack_unary_ping_pong.cc", - "test/cpp/microbenchmarks/fullstack_unary_ping_pong.h" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "bm_metadata", - "src": [ - "test/cpp/microbenchmarks/bm_metadata.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "bm_pollset", - "src": [ - "test/cpp/microbenchmarks/bm_pollset.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "bm_threadpool", - "src": [ - "test/cpp/microbenchmarks/bm_threadpool.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "bm_timer", - "src": [ - "test/cpp/microbenchmarks/bm_timer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "byte_stream_test", - "src": [ - "test/core/transport/byte_stream_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "channel_arguments_test", - "src": [ - "test/cpp/common/channel_arguments_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "channel_filter_test", - "src": [ - "test/cpp/common/channel_filter_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test", - "grpc++_test_util", - "grpc_test_util", - "grpcpp_channelz_proto" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "channel_trace_test", - "src": [ - "test/core/channel/channel_trace_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "channelz_registry_test", - "src": [ - "test/core/channel/channelz_registry_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util", - "grpcpp_channelz", - "grpcpp_channelz_proto" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "channelz_service_test", - "src": [ - "test/cpp/end2end/channelz_service_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test", - "grpc++_test_util", - "grpc_test_util", - "grpcpp_channelz_proto" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "channelz_test", - "src": [ - "test/core/channel/channelz_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "check_gcp_environment_linux_test", - "src": [ - "test/core/security/check_gcp_environment_linux_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "check_gcp_environment_windows_test", - "src": [ - "test/core/security/check_gcp_environment_windows_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "chttp2_settings_timeout_test", - "src": [ - "test/core/transport/chttp2/settings_timeout_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_cli_libs", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "cli_call_test", - "src": [ - "test/cpp/util/cli_call_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "client_callback_end2end_test", - "src": [ - "test/cpp/end2end/client_callback_end2end_test.cc", - "test/cpp/end2end/interceptors_util.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [ - "src/proto/grpc/lb/v1/load_balancer.grpc.pb.h", - "src/proto/grpc/lb/v1/load_balancer.pb.h", - "src/proto/grpc/lb/v1/load_balancer_mock.grpc.pb.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "client_channel_stress_test", - "src": [ - "test/cpp/client/client_channel_stress_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "client_crash_test", - "src": [ - "test/cpp/end2end/client_crash_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "client_crash_test_server", - "src": [ - "test/cpp/end2end/client_crash_test_server.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [ - "test/cpp/end2end/interceptors_util.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "client_interceptors_end2end_test", - "src": [ - "test/cpp/end2end/client_interceptors_end2end_test.cc", - "test/cpp/end2end/interceptors_util.cc", - "test/cpp/end2end/interceptors_util.h" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "client_lb_end2end_test", - "src": [ - "test/cpp/end2end/client_lb_end2end_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_codegen_base", - "grpc++_core_stats" - ], - "headers": [ - "src/proto/grpc/testing/benchmark_service.grpc.pb.h", - "src/proto/grpc/testing/benchmark_service.pb.h", - "src/proto/grpc/testing/benchmark_service_mock.grpc.pb.h", - "src/proto/grpc/testing/control.grpc.pb.h", - "src/proto/grpc/testing/control.pb.h", - "src/proto/grpc/testing/control_mock.grpc.pb.h", - "src/proto/grpc/testing/messages.grpc.pb.h", - "src/proto/grpc/testing/messages.pb.h", - "src/proto/grpc/testing/messages_mock.grpc.pb.h", - "src/proto/grpc/testing/payloads.grpc.pb.h", - "src/proto/grpc/testing/payloads.pb.h", - "src/proto/grpc/testing/payloads_mock.grpc.pb.h", - "src/proto/grpc/testing/report_qps_scenario_service.grpc.pb.h", - "src/proto/grpc/testing/report_qps_scenario_service.pb.h", - "src/proto/grpc/testing/report_qps_scenario_service_mock.grpc.pb.h", - "src/proto/grpc/testing/stats.grpc.pb.h", - "src/proto/grpc/testing/stats.pb.h", - "src/proto/grpc/testing/stats_mock.grpc.pb.h", - "src/proto/grpc/testing/worker_service.grpc.pb.h", - "src/proto/grpc/testing/worker_service.pb.h", - "src/proto/grpc/testing/worker_service_mock.grpc.pb.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "codegen_test_full", - "src": [ - "test/cpp/codegen/codegen_test_full.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++_codegen_base", - "grpc++_codegen_base_src", - "grpc++_core_stats" - ], - "headers": [ - "src/proto/grpc/testing/benchmark_service.grpc.pb.h", - "src/proto/grpc/testing/benchmark_service.pb.h", - "src/proto/grpc/testing/benchmark_service_mock.grpc.pb.h", - "src/proto/grpc/testing/control.grpc.pb.h", - "src/proto/grpc/testing/control.pb.h", - "src/proto/grpc/testing/control_mock.grpc.pb.h", - "src/proto/grpc/testing/messages.grpc.pb.h", - "src/proto/grpc/testing/messages.pb.h", - "src/proto/grpc/testing/messages_mock.grpc.pb.h", - "src/proto/grpc/testing/payloads.grpc.pb.h", - "src/proto/grpc/testing/payloads.pb.h", - "src/proto/grpc/testing/payloads_mock.grpc.pb.h", - "src/proto/grpc/testing/report_qps_scenario_service.grpc.pb.h", - "src/proto/grpc/testing/report_qps_scenario_service.pb.h", - "src/proto/grpc/testing/report_qps_scenario_service_mock.grpc.pb.h", - "src/proto/grpc/testing/stats.grpc.pb.h", - "src/proto/grpc/testing/stats.pb.h", - "src/proto/grpc/testing/stats_mock.grpc.pb.h", - "src/proto/grpc/testing/worker_service.grpc.pb.h", - "src/proto/grpc/testing/worker_service.pb.h", - "src/proto/grpc/testing/worker_service_mock.grpc.pb.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "codegen_test_minimal", - "src": [ - "test/cpp/codegen/codegen_test_minimal.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "context_list_test", - "src": [ - "test/core/transport/chttp2/context_list_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "credentials_test", - "src": [ - "test/cpp/client/credentials_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "cxx_byte_buffer_test", - "src": [ - "test/cpp/util/byte_buffer_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "cxx_slice_test", - "src": [ - "test/cpp/util/slice_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "grpc", - "grpc++" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "cxx_string_ref_test", - "src": [ - "test/cpp/util/string_ref_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "cxx_time_test", - "src": [ - "test/cpp/util/time_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "delegating_channel_test", - "src": [ - "test/cpp/end2end/delegating_channel_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [ - "test/cpp/end2end/interceptors_util.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "end2end_test", - "src": [ - "test/cpp/end2end/end2end_test.cc", - "test/cpp/end2end/interceptors_util.cc", - "test/cpp/end2end/interceptors_util.h" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "grpc++", - "grpc++_error_details" - ], - "headers": [ - "src/proto/grpc/testing/echo_messages.grpc.pb.h", - "src/proto/grpc/testing/echo_messages.pb.h", - "src/proto/grpc/testing/echo_messages_mock.grpc.pb.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "error_details_test", - "src": [ - "test/cpp/util/error_details_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "exception_test", - "src": [ - "test/cpp/end2end/exception_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "filter_end2end_test", - "src": [ - "test/cpp/end2end/filter_end2end_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "gen_hpack_tables", - "src": [ - "tools/codegen/core/gen_hpack_tables.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "gen_legal_metadata_characters", - "src": [ - "tools/codegen/core/gen_legal_metadata_characters.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "gen_percent_encoding_tables", - "src": [ - "tools/codegen/core/gen_percent_encoding_tables.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "generic_end2end_test", - "src": [ - "test/cpp/end2end/generic_end2end_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "global_config_env_test", - "src": [ - "test/core/gprpp/global_config_env_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "global_config_test", - "src": [ - "test/core/gprpp/global_config_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_config" - ], - "headers": [ - "src/proto/grpc/testing/compiler_test.grpc.pb.h", - "src/proto/grpc/testing/compiler_test.pb.h", - "src/proto/grpc/testing/compiler_test_mock.grpc.pb.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "golden_file_test", - "src": [ - "test/cpp/codegen/golden_file_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "grpc_alts_credentials_options_test", - "src": [ - "test/core/security/grpc_alts_credentials_options_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_proto_reflection_desc_db", - "grpc++_test_config", - "grpc_cli_libs" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "grpc_cli", - "src": [ - "test/cpp/util/grpc_cli.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test", - "grpc_test_util" - ], - "headers": [ - "test/core/gprpp/map_tester.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "grpc_core_map_test", - "src": [ - "test/core/gprpp/map_test.cc", - "test/core/gprpp/map_tester.h" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "grpc_plugin_support" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "grpc_cpp_plugin", - "src": [ - "src/compiler/cpp_plugin.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "grpc_plugin_support" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "grpc_csharp_plugin", - "src": [ - "src/compiler/csharp_plugin.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "grpc_fetch_oauth2", - "src": [ - "test/core/security/fetch_oauth2.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "grpc_linux_system_roots_test", - "src": [ - "test/core/security/linux_system_roots_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "grpc_plugin_support" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "grpc_node_plugin", - "src": [ - "src/compiler/node_plugin.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "grpc_plugin_support" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "grpc_objective_c_plugin", - "src": [ - "src/compiler/objective_c_plugin.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "grpc_plugin_support" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "grpc_php_plugin", - "src": [ - "src/compiler/php_plugin.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "grpc_plugin_support" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "grpc_python_plugin", - "src": [ - "src/compiler/python_plugin.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "grpc_plugin_support" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "grpc_ruby_plugin", - "src": [ - "src/compiler/ruby_plugin.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "grpc_spiffe_security_connector_test", - "src": [ - "test/core/security/spiffe_security_connector_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_codegen_proto", - "grpc++_proto_reflection_desc_db", - "grpc++_reflection", - "grpc++_test_util", - "grpc_cli_libs", - "grpc_test_util" - ], - "headers": [ - "src/proto/grpc/testing/echo.grpc.pb.h", - "src/proto/grpc/testing/echo.pb.h", - "src/proto/grpc/testing/echo_messages.grpc.pb.h", - "src/proto/grpc/testing/echo_messages.pb.h", - "src/proto/grpc/testing/echo_messages_mock.grpc.pb.h", - "src/proto/grpc/testing/echo_mock.grpc.pb.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "grpc_tool_test", - "src": [ - "test/cpp/util/grpc_tool_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [ - "src/proto/grpc/lb/v1/load_balancer.grpc.pb.h", - "src/proto/grpc/lb/v1/load_balancer.pb.h", - "src/proto/grpc/lb/v1/load_balancer_mock.grpc.pb.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "grpclb_api_test", - "src": [ - "test/cpp/grpclb/grpclb_api_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [ - "src/proto/grpc/lb/v1/load_balancer.grpc.pb.h", - "src/proto/grpc/lb/v1/load_balancer.pb.h", - "src/proto/grpc/lb/v1/load_balancer_mock.grpc.pb.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "grpclb_end2end_test", - "src": [ - "test/cpp/end2end/grpclb_end2end_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [ - "src/proto/grpc/testing/empty.grpc.pb.h", - "src/proto/grpc/testing/empty.pb.h", - "src/proto/grpc/testing/empty_mock.grpc.pb.h", - "src/proto/grpc/testing/messages.grpc.pb.h", - "src/proto/grpc/testing/messages.pb.h", - "src/proto/grpc/testing/messages_mock.grpc.pb.h", - "src/proto/grpc/testing/test.grpc.pb.h", - "src/proto/grpc/testing/test.pb.h", - "src/proto/grpc/testing/test_mock.grpc.pb.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "grpclb_fallback_test", - "src": [ - "test/cpp/interop/grpclb_fallback_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test", - "grpc_test_util" - ], - "headers": [ - "test/core/end2end/end2end_tests.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "h2_ssl_cert_test", - "src": [ - "test/core/end2end/end2end_tests.h", - "test/core/end2end/h2_ssl_cert_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test", - "grpc_test_util" - ], - "headers": [ - "test/core/end2end/end2end_tests.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "h2_ssl_session_reuse_test", - "src": [ - "test/core/end2end/end2end_tests.h", - "test/core/end2end/h2_ssl_session_reuse_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "health_service_end2end_test", - "src": [ - "test/cpp/end2end/health_service_end2end_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "grpc", - "grpc++", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util", - "http2_client_main" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "http2_client", - "src": [], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "hybrid_end2end_test", - "src": [ - "test/cpp/end2end/hybrid_end2end_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "inlined_vector_test", - "src": [ - "test/core/gprpp/inlined_vector_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_core_stats", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util", - "qps" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "inproc_sync_unary_ping_pong_test", - "src": [ - "test/cpp/qps/inproc_sync_unary_ping_pong_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util", - "interop_client_helper", - "interop_client_main" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "interop_client", - "src": [], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util", - "interop_server_helper", - "interop_server_lib", - "interop_server_main" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "interop_server", - "src": [], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++_test_config", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "interop_test", - "src": [ - "test/cpp/interop/interop_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "json_run_localhost", - "src": [ - "test/cpp/qps/json_run_localhost.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "memory_test", - "src": [ - "test/core/gprpp/memory_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "message_allocator_end2end_test", - "src": [ - "test/cpp/end2end/message_allocator_end2end_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_config" - ], - "headers": [ - "src/proto/grpc/testing/metrics.grpc.pb.h", - "src/proto/grpc/testing/metrics.pb.h", - "src/proto/grpc/testing/metrics_mock.grpc.pb.h", - "test/cpp/util/metrics_server.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "metrics_client", - "src": [ - "test/cpp/interop/metrics_client.cc", - "test/cpp/util/metrics_server.h" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [ - "include/grpc++/test/mock_stream.h", - "include/grpcpp/test/mock_stream.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "mock_test", - "src": [ - "include/grpc++/test/mock_stream.h", - "include/grpcpp/test/mock_stream.h", - "test/cpp/end2end/mock_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "nonblocking_test", - "src": [ - "test/cpp/end2end/nonblocking_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "benchmark" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "noop-benchmark", - "src": [ - "test/cpp/microbenchmarks/noop-benchmark.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "optional_test", - "src": [ - "test/core/gprpp/optional_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "orphanable_test", - "src": [ - "test/core/gprpp/orphanable_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util", - "test_tcp_server" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "port_sharing_end2end_test", - "src": [ - "test/cpp/end2end/port_sharing_end2end_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_proto_reflection_desc_db", - "grpc++_reflection", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "proto_server_reflection_test", - "src": [ - "test/cpp/end2end/proto_server_reflection_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "grpc", - "grpc++", - "grpc++_codegen_base", - "grpc++_codegen_proto" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "proto_utils_test", - "src": [ - "test/cpp/codegen/proto_utils_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util", - "qps" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "qps_interarrival_test", - "src": [ - "test/cpp/qps/qps_interarrival_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_core_stats", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util", - "qps" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "qps_json_driver", - "src": [ - "test/cpp/qps/qps_json_driver.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_core_stats", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util", - "qps" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "qps_openloop_test", - "src": [ - "test/cpp/qps/qps_openloop_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_core_stats", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util", - "qps" - ], - "headers": [ - "test/cpp/qps/client.h", - "test/cpp/qps/server.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "qps_worker", - "src": [ - "test/cpp/qps/client.h", - "test/cpp/qps/server.h", - "test/cpp/qps/worker.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "raw_end2end_test", - "src": [ - "test/cpp/end2end/raw_end2end_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [ - "src/proto/grpc/testing/empty.grpc.pb.h", - "src/proto/grpc/testing/empty.pb.h", - "src/proto/grpc/testing/empty_mock.grpc.pb.h", - "src/proto/grpc/testing/messages.grpc.pb.h", - "src/proto/grpc/testing/messages.pb.h", - "src/proto/grpc/testing/messages_mock.grpc.pb.h", - "src/proto/grpc/testing/test.grpc.pb.h", - "src/proto/grpc/testing/test.pb.h", - "src/proto/grpc/testing/test_mock.grpc.pb.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "reconnect_interop_client", - "src": [ - "test/cpp/interop/reconnect_interop_client.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util", - "reconnect_server", - "test_tcp_server" - ], - "headers": [ - "src/proto/grpc/testing/empty.grpc.pb.h", - "src/proto/grpc/testing/empty.pb.h", - "src/proto/grpc/testing/empty_mock.grpc.pb.h", - "src/proto/grpc/testing/messages.grpc.pb.h", - "src/proto/grpc/testing/messages.pb.h", - "src/proto/grpc/testing/messages_mock.grpc.pb.h", - "src/proto/grpc/testing/test.grpc.pb.h", - "src/proto/grpc/testing/test.pb.h", - "src/proto/grpc/testing/test_mock.grpc.pb.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "reconnect_interop_server", - "src": [ - "test/cpp/interop/reconnect_interop_server.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "ref_counted_ptr_test", - "src": [ - "test/core/gprpp/ref_counted_ptr_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "ref_counted_test", - "src": [ - "test/core/gprpp/ref_counted_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "retry_throttle_test", - "src": [ - "test/core/client_channel/retry_throttle_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "secure_auth_context_test", - "src": [ - "test/cpp/common/secure_auth_context_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_core_stats", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util", - "qps" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "secure_sync_unary_ping_pong_test", - "src": [ - "test/cpp/qps/secure_sync_unary_ping_pong_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "server_builder_plugin_test", - "src": [ - "test/cpp/end2end/server_builder_plugin_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [ - "src/proto/grpc/testing/echo.grpc.pb.h", - "src/proto/grpc/testing/echo.pb.h", - "src/proto/grpc/testing/echo_messages.grpc.pb.h", - "src/proto/grpc/testing/echo_messages.pb.h", - "src/proto/grpc/testing/echo_messages_mock.grpc.pb.h", - "src/proto/grpc/testing/echo_mock.grpc.pb.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "server_builder_test", - "src": [ - "test/cpp/server/server_builder_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [ - "src/proto/grpc/testing/echo.grpc.pb.h", - "src/proto/grpc/testing/echo.pb.h", - "src/proto/grpc/testing/echo_messages.grpc.pb.h", - "src/proto/grpc/testing/echo_messages.pb.h", - "src/proto/grpc/testing/echo_messages_mock.grpc.pb.h", - "src/proto/grpc/testing/echo_mock.grpc.pb.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "server_builder_with_socket_mutator_test", - "src": [ - "test/cpp/server/server_builder_with_socket_mutator_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "server_context_test_spouse_test", - "src": [ - "test/cpp/test/server_context_test_spouse_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "server_crash_test", - "src": [ - "test/cpp/end2end/server_crash_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "server_crash_test_client", - "src": [ - "test/cpp/end2end/server_crash_test_client.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "server_early_return_test", - "src": [ - "test/cpp/end2end/server_early_return_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [ - "test/cpp/end2end/interceptors_util.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "server_interceptors_end2end_test", - "src": [ - "test/cpp/end2end/interceptors_util.cc", - "test/cpp/end2end/interceptors_util.h", - "test/cpp/end2end/server_interceptors_end2end_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [ - "src/proto/grpc/testing/echo.grpc.pb.h", - "src/proto/grpc/testing/echo.pb.h", - "src/proto/grpc/testing/echo_messages.grpc.pb.h", - "src/proto/grpc/testing/echo_messages.pb.h", - "src/proto/grpc/testing/echo_messages_mock.grpc.pb.h", - "src/proto/grpc/testing/echo_mock.grpc.pb.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "server_request_call_test", - "src": [ - "test/cpp/server/server_request_call_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "service_config_end2end_test", - "src": [ - "test/cpp/end2end/service_config_end2end_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "service_config_test", - "src": [ - "test/core/client_channel/service_config_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "shutdown_test", - "src": [ - "test/cpp/end2end/shutdown_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "slice_hash_table_test", - "src": [ - "test/core/slice/slice_hash_table_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "slice_weak_hash_table_test", - "src": [ - "test/core/slice/slice_weak_hash_table_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "stats_test", - "src": [ - "test/core/debug/stats_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "status_metadata_test", - "src": [ - "test/core/transport/status_metadata_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "status_util_test", - "src": [ - "test/core/channel/status_util_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "streaming_throughput_test", - "src": [ - "test/cpp/end2end/streaming_throughput_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [ - "src/proto/grpc/testing/empty.grpc.pb.h", - "src/proto/grpc/testing/empty.pb.h", - "src/proto/grpc/testing/empty_mock.grpc.pb.h", - "src/proto/grpc/testing/messages.grpc.pb.h", - "src/proto/grpc/testing/messages.pb.h", - "src/proto/grpc/testing/messages_mock.grpc.pb.h", - "src/proto/grpc/testing/metrics.grpc.pb.h", - "src/proto/grpc/testing/metrics.pb.h", - "src/proto/grpc/testing/metrics_mock.grpc.pb.h", - "src/proto/grpc/testing/test.grpc.pb.h", - "src/proto/grpc/testing/test.pb.h", - "src/proto/grpc/testing/test_mock.grpc.pb.h", - "test/cpp/interop/client_helper.h", - "test/cpp/interop/interop_client.h", - "test/cpp/interop/stress_interop_client.h", - "test/cpp/util/create_test_channel.h", - "test/cpp/util/metrics_server.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "stress_test", - "src": [ - "test/cpp/interop/client_helper.h", - "test/cpp/interop/interop_client.cc", - "test/cpp/interop/interop_client.h", - "test/cpp/interop/stress_interop_client.cc", - "test/cpp/interop/stress_interop_client.h", - "test/cpp/interop/stress_test.cc", - "test/cpp/util/create_test_channel.h", - "test/cpp/util/metrics_server.cc", - "test/cpp/util/metrics_server.h" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "string_view_test", - "src": [ - "test/core/gprpp/string_view_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc++_test_config", - "grpc++_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "thread_manager_test", - "src": [ - "test/cpp/thread_manager/thread_manager_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "thread_stress_test", - "src": [ - "test/cpp/end2end/thread_stress_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "time_change_test", - "src": [ - "test/cpp/end2end/time_change_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "transport_pid_controller_test", - "src": [ - "test/core/transport/pid_controller_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "alts_test_util", - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "transport_security_common_api_test", - "src": [ - "test/core/tsi/alts/handshaker/transport_security_common_api_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "writes_per_rpc_test", - "src": [ - "test/cpp/performance/writes_per_rpc_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [ - "src/proto/grpc/lb/v2/eds_for_test.grpc.pb.h", - "src/proto/grpc/lb/v2/eds_for_test.pb.h", - "src/proto/grpc/lb/v2/eds_for_test_mock.grpc.pb.h", - "src/proto/grpc/lb/v2/lrs_for_test.grpc.pb.h", - "src/proto/grpc/lb/v2/lrs_for_test.pb.h", - "src/proto/grpc/lb/v2/lrs_for_test_mock.grpc.pb.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "xds_end2end_test", - "src": [ - "test/cpp/end2end/xds_end2end_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "c89", - "name": "public_headers_must_be_c89", - "src": [ - "test/core/surface/public_headers_must_be_c89.c" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "boringssl", - "boringssl_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "boringssl_ssl_test", - "src": [], - "third_party": true, - "type": "target" - }, - { - "deps": [ - "boringssl", - "boringssl_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "boringssl_crypto_test", - "src": [ - "src/boringssl/crypto_test_data.cc" - ], - "third_party": true, - "type": "target" - }, - { - "deps": [ - "bad_client_test", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "bad_streaming_id_bad_client_test", - "src": [ - "test/core/bad_client/tests/bad_streaming_id.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "bad_client_test", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "badreq_bad_client_test", - "src": [ - "test/core/bad_client/tests/badreq.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "bad_client_test", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "connection_prefix_bad_client_test", - "src": [ - "test/core/bad_client/tests/connection_prefix.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "bad_client_test", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "duplicate_header_bad_client_test", - "src": [ - "test/core/bad_client/tests/duplicate_header.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "bad_client_test", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "head_of_line_blocking_bad_client_test", - "src": [ - "test/core/bad_client/tests/head_of_line_blocking.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "bad_client_test", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "headers_bad_client_test", - "src": [ - "test/core/bad_client/tests/headers.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "bad_client_test", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "initial_settings_frame_bad_client_test", - "src": [ - "test/core/bad_client/tests/initial_settings_frame.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "bad_client_test", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "large_metadata_bad_client_test", - "src": [ - "test/core/bad_client/tests/large_metadata.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "bad_client_test", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "out_of_bounds_bad_client_test", - "src": [ - "test/core/bad_client/tests/out_of_bounds.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "bad_client_test", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "server_registered_method_bad_client_test", - "src": [ - "test/core/bad_client/tests/server_registered_method.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "bad_client_test", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "simple_request_bad_client_test", - "src": [ - "test/core/bad_client/tests/simple_request.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "bad_client_test", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "unknown_frame_bad_client_test", - "src": [ - "test/core/bad_client/tests/unknown_frame.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "bad_client_test", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "window_overflow_bad_client_test", - "src": [ - "test/core/bad_client/tests/window_overflow.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "bad_ssl_test_server", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "bad_ssl_cert_server", - "src": [ - "test/core/bad_ssl/servers/cert.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "bad_ssl_cert_test", - "src": [ - "test/core/bad_ssl/bad_ssl_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_census_test", - "src": [ - "test/core/end2end/fixtures/h2_census.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_compress_test", - "src": [ - "test/core/end2end/fixtures/h2_compress.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_fakesec_test", - "src": [ - "test/core/end2end/fixtures/h2_fakesec.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_fd_test", - "src": [ - "test/core/end2end/fixtures/h2_fd.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_full_test", - "src": [ - "test/core/end2end/fixtures/h2_full.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_full+pipe_test", - "src": [ - "test/core/end2end/fixtures/h2_full+pipe.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_full+trace_test", - "src": [ - "test/core/end2end/fixtures/h2_full+trace.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_full+workarounds_test", - "src": [ - "test/core/end2end/fixtures/h2_full+workarounds.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_http_proxy_test", - "src": [ - "test/core/end2end/fixtures/h2_http_proxy.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_local_ipv4_test", - "src": [ - "test/core/end2end/fixtures/h2_local_ipv4.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_local_ipv6_test", - "src": [ - "test/core/end2end/fixtures/h2_local_ipv6.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_local_uds_test", - "src": [ - "test/core/end2end/fixtures/h2_local_uds.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_oauth2_test", - "src": [ - "test/core/end2end/fixtures/h2_oauth2.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_proxy_test", - "src": [ - "test/core/end2end/fixtures/h2_proxy.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_sockpair_test", - "src": [ - "test/core/end2end/fixtures/h2_sockpair.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_sockpair+trace_test", - "src": [ - "test/core/end2end/fixtures/h2_sockpair+trace.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_sockpair_1byte_test", - "src": [ - "test/core/end2end/fixtures/h2_sockpair_1byte.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_spiffe_test", - "src": [ - "test/core/end2end/fixtures/h2_spiffe.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_ssl_test", - "src": [ - "test/core/end2end/fixtures/h2_ssl.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_ssl_cred_reload_test", - "src": [ - "test/core/end2end/fixtures/h2_ssl_cred_reload.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_ssl_proxy_test", - "src": [ - "test/core/end2end/fixtures/h2_ssl_proxy.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_uds_test", - "src": [ - "test/core/end2end/fixtures/h2_uds.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_tests", - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "inproc_test", - "src": [ - "test/core/end2end/fixtures/inproc.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_nosec_tests", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_census_nosec_test", - "src": [ - "test/core/end2end/fixtures/h2_census.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_nosec_tests", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_compress_nosec_test", - "src": [ - "test/core/end2end/fixtures/h2_compress.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_nosec_tests", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_fd_nosec_test", - "src": [ - "test/core/end2end/fixtures/h2_fd.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_nosec_tests", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_full_nosec_test", - "src": [ - "test/core/end2end/fixtures/h2_full.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_nosec_tests", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_full+pipe_nosec_test", - "src": [ - "test/core/end2end/fixtures/h2_full+pipe.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_nosec_tests", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_full+trace_nosec_test", - "src": [ - "test/core/end2end/fixtures/h2_full+trace.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_nosec_tests", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_full+workarounds_nosec_test", - "src": [ - "test/core/end2end/fixtures/h2_full+workarounds.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_nosec_tests", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_http_proxy_nosec_test", - "src": [ - "test/core/end2end/fixtures/h2_http_proxy.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_nosec_tests", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_proxy_nosec_test", - "src": [ - "test/core/end2end/fixtures/h2_proxy.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_nosec_tests", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_sockpair_nosec_test", - "src": [ - "test/core/end2end/fixtures/h2_sockpair.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_nosec_tests", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_sockpair+trace_nosec_test", - "src": [ - "test/core/end2end/fixtures/h2_sockpair+trace.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_nosec_tests", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_sockpair_1byte_nosec_test", - "src": [ - "test/core/end2end/fixtures/h2_sockpair_1byte.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "end2end_nosec_tests", - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_uds_nosec_test", - "src": [ - "test/core/end2end/fixtures/h2_uds.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "dns_test_util", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "resolver_component_test_unsecure", - "src": [ - "test/cpp/naming/resolver_component_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "dns_test_util", - "gpr", - "grpc", - "grpc++", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "resolver_component_test", - "src": [ - "test/cpp/naming/resolver_component_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "resolver_component_tests_runner_invoker_unsecure", - "src": [ - "test/cpp/naming/resolver_component_tests_runner_invoker.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "resolver_component_tests_runner_invoker", - "src": [ - "test/cpp/naming/resolver_component_tests_runner_invoker.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "address_sorting_test_unsecure", - "src": [ - "test/cpp/naming/address_sorting_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "address_sorting_test", - "src": [ - "test/cpp/naming/address_sorting_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "dns_test_util", - "gpr", - "grpc", - "grpc++", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "cancel_ares_query_test", - "src": [ - "test/cpp/naming/cancel_ares_query_test.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "alts_credentials_fuzzer_one_entry", - "src": [ - "test/core/security/alts_credentials_fuzzer.cc", - "test/core/util/one_corpus_entry_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "api_fuzzer_one_entry", - "src": [ - "test/core/end2end/fuzzers/api_fuzzer.cc", - "test/core/util/one_corpus_entry_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "client_fuzzer_one_entry", - "src": [ - "test/core/end2end/fuzzers/client_fuzzer.cc", - "test/core/util/one_corpus_entry_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "hpack_parser_fuzzer_test_one_entry", - "src": [ - "test/core/transport/chttp2/hpack_parser_fuzzer_test.cc", - "test/core/util/one_corpus_entry_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "http_request_fuzzer_test_one_entry", - "src": [ - "test/core/http/request_fuzzer.cc", - "test/core/util/one_corpus_entry_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "http_response_fuzzer_test_one_entry", - "src": [ - "test/core/http/response_fuzzer.cc", - "test/core/util/one_corpus_entry_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "json_fuzzer_test_one_entry", - "src": [ - "test/core/json/fuzzer.cc", - "test/core/util/one_corpus_entry_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "nanopb_fuzzer_response_test_one_entry", - "src": [ - "test/core/nanopb/fuzzer_response.cc", - "test/core/util/one_corpus_entry_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "nanopb_fuzzer_serverlist_test_one_entry", - "src": [ - "test/core/nanopb/fuzzer_serverlist.cc", - "test/core/util/one_corpus_entry_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "percent_decode_fuzzer_one_entry", - "src": [ - "test/core/slice/percent_decode_fuzzer.cc", - "test/core/util/one_corpus_entry_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "percent_encode_fuzzer_one_entry", - "src": [ - "test/core/slice/percent_encode_fuzzer.cc", - "test/core/util/one_corpus_entry_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "server_fuzzer_one_entry", - "src": [ - "test/core/end2end/fuzzers/server_fuzzer.cc", - "test/core/util/one_corpus_entry_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "ssl_server_fuzzer_one_entry", - "src": [ - "test/core/security/ssl_server_fuzzer.cc", - "test/core/util/one_corpus_entry_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "uri_fuzzer_test_one_entry", - "src": [ - "test/core/client_channel/uri_fuzzer_test.cc", - "test/core/util/one_corpus_entry_fuzzer.cc" - ], - "third_party": false, - "type": "target" - }, - { - "deps": [], - "headers": [ - "third_party/address_sorting/address_sorting_internal.h", - "third_party/address_sorting/include/address_sorting/address_sorting.h" - ], - "is_filegroup": false, - "language": "c", - "name": "address_sorting", - "src": [], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "grpc" - ], - "headers": [ - "test/core/tsi/alts/crypt/gsec_test_util.h", - "test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.h" - ], - "is_filegroup": false, - "language": "c", - "name": "alts_test_util", - "src": [ - "test/core/tsi/alts/crypt/gsec_test_util.cc", - "test/core/tsi/alts/crypt/gsec_test_util.h", - "test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.cc", - "test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "cxxabi", - "src": [], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "gpr_base" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "gpr", - "src": [], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "census", - "gpr", - "grpc_base", - "grpc_client_authority_filter", - "grpc_client_idle_filter", - "grpc_deadline_filter", - "grpc_lb_policy_grpclb_secure", - "grpc_lb_policy_pick_first", - "grpc_lb_policy_round_robin", - "grpc_lb_policy_xds_secure", - "grpc_max_age_filter", - "grpc_message_size_filter", - "grpc_resolver_dns_ares", - "grpc_resolver_dns_native", - "grpc_resolver_fake", - "grpc_resolver_sockaddr", - "grpc_secure", - "grpc_server_backward_compatibility", - "grpc_transport_chttp2_client_insecure", - "grpc_transport_chttp2_client_secure", - "grpc_transport_chttp2_server_insecure", - "grpc_transport_chttp2_server_secure", - "grpc_transport_inproc", - "grpc_workaround_cronet_compression_filter" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc", - "src": [ - "src/core/lib/surface/init.cc" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_transport_chttp2_client_secure", - "grpc_transport_cronet_client_secure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_cronet", - "src": [ - "src/core/ext/transport/cronet/plugin_registry/grpc_cronet_plugin_registry.cc", - "src/core/lib/surface/init.cc" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util_base" - ], - "headers": [ - "test/core/end2end/data/ssl_test_data.h", - "test/core/security/oauth2_utils.h" - ], - "is_filegroup": false, - "language": "c", - "name": "grpc_test_util", - "src": [ - "test/core/end2end/data/client_certs.cc", - "test/core/end2end/data/server1_cert.cc", - "test/core/end2end/data/server1_key.cc", - "test/core/end2end/data/ssl_test_data.h", - "test/core/end2end/data/test_root_cert.cc", - "test/core/security/oauth2_utils.cc", - "test/core/security/oauth2_utils.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "gpr", - "grpc_test_util_base", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_test_util_unsecure", - "src": [], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "census", - "gpr", - "grpc_base", - "grpc_client_authority_filter", - "grpc_client_idle_filter", - "grpc_deadline_filter", - "grpc_lb_policy_grpclb", - "grpc_lb_policy_pick_first", - "grpc_lb_policy_round_robin", - "grpc_lb_policy_xds", - "grpc_max_age_filter", - "grpc_message_size_filter", - "grpc_resolver_dns_ares", - "grpc_resolver_dns_native", - "grpc_resolver_fake", - "grpc_resolver_sockaddr", - "grpc_server_backward_compatibility", - "grpc_transport_chttp2_client_insecure", - "grpc_transport_chttp2_server_insecure", - "grpc_transport_inproc", - "grpc_workaround_cronet_compression_filter" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_unsecure", - "src": [ - "src/core/lib/surface/init.cc", - "src/core/lib/surface/init_unsecure.cc" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util", - "test_tcp_server" - ], - "headers": [ - "test/core/util/reconnect_server.h" - ], - "is_filegroup": false, - "language": "c", - "name": "reconnect_server", - "src": [ - "test/core/util/reconnect_server.cc", - "test/core/util/reconnect_server.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [ - "test/core/util/test_tcp_server.h" - ], - "is_filegroup": false, - "language": "c", - "name": "test_tcp_server", - "src": [ - "test/core/util/test_tcp_server.cc", - "test/core/util/test_tcp_server.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "benchmark", - "gpr", - "grpc++_test_config", - "grpc++_test_util_unsecure", - "grpc++_unsecure", - "grpc_benchmark", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [ - "src/proto/grpc/testing/echo.grpc.pb.h", - "src/proto/grpc/testing/echo.pb.h", - "src/proto/grpc/testing/echo_mock.grpc.pb.h", - "test/cpp/microbenchmarks/callback_test_service.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "bm_callback_test_service_impl", - "src": [ - "test/cpp/microbenchmarks/callback_test_service.cc", - "test/cpp/microbenchmarks/callback_test_service.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [], - "headers": [ - "test/cpp/naming/dns_test_util.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "dns_test_util", - "src": [ - "test/cpp/naming/dns_test_util.cc", - "test/cpp/naming/dns_test_util.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++_base", - "grpc++_codegen_base", - "grpc++_codegen_base_src", - "grpc++_codegen_proto" - ], - "headers": [ - "include/grpc++/impl/codegen/core_codegen.h", - "include/grpcpp/impl/codegen/core_codegen.h", - "src/cpp/client/secure_credentials.h", - "src/cpp/common/secure_auth_context.h", - "src/cpp/server/secure_server_credentials.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "grpc++", - "src": [ - "include/grpc++/impl/codegen/core_codegen.h", - "include/grpcpp/impl/codegen/core_codegen.h", - "src/cpp/client/insecure_credentials.cc", - "src/cpp/client/secure_credentials.cc", - "src/cpp/client/secure_credentials.h", - "src/cpp/common/auth_property_iterator.cc", - "src/cpp/common/secure_auth_context.cc", - "src/cpp/common/secure_auth_context.h", - "src/cpp/common/secure_channel_arguments.cc", - "src/cpp/common/secure_create_auth_context.cc", - "src/cpp/server/insecure_server_credentials.cc", - "src/cpp/server/secure_server_credentials.cc", - "src/cpp/server/secure_server_credentials.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "grpc++" - ], - "headers": [ - "src/cpp/util/core_stats.h", - "src/proto/grpc/core/stats.grpc.pb.h", - "src/proto/grpc/core/stats.pb.h", - "src/proto/grpc/core/stats_mock.grpc.pb.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "grpc++_core_stats", - "src": [ - "src/cpp/util/core_stats.cc", - "src/cpp/util/core_stats.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "grpc++" - ], - "headers": [ - "include/grpc++/support/error_details.h", - "include/grpcpp/support/error_details.h", - "include/grpcpp/support/error_details_impl.h", - "src/proto/grpc/status/status.grpc.pb.h", - "src/proto/grpc/status/status.pb.h", - "src/proto/grpc/status/status_mock.grpc.pb.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "grpc++_error_details", - "src": [ - "include/grpc++/support/error_details.h", - "include/grpcpp/support/error_details.h", - "include/grpcpp/support/error_details_impl.h", - "src/cpp/util/error_details.cc" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "grpc", - "grpc++", - "grpc++_config_proto", - "grpc++_reflection_proto" - ], - "headers": [ - "test/cpp/util/proto_reflection_descriptor_database.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "grpc++_proto_reflection_desc_db", - "src": [ - "test/cpp/util/proto_reflection_descriptor_database.cc", - "test/cpp/util/proto_reflection_descriptor_database.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "grpc", - "grpc++", - "grpc++_reflection_proto" - ], - "headers": [ - "include/grpc++/ext/proto_server_reflection_plugin.h", - "include/grpcpp/ext/proto_server_reflection_plugin.h", - "include/grpcpp/ext/proto_server_reflection_plugin_impl.h", - "src/cpp/ext/proto_server_reflection.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "grpc++_reflection", - "src": [ - "include/grpc++/ext/proto_server_reflection_plugin.h", - "include/grpcpp/ext/proto_server_reflection_plugin.h", - "include/grpcpp/ext/proto_server_reflection_plugin_impl.h", - "src/cpp/ext/proto_server_reflection.cc", - "src/cpp/ext/proto_server_reflection.h", - "src/cpp/ext/proto_server_reflection_plugin.cc" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [], - "headers": [ - "test/cpp/util/test_config.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "grpc++_test_config", - "src": [ - "test/cpp/util/test_config.h", - "test/cpp/util/test_config_cc.cc" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "grpc", - "grpc++", - "grpc++_codegen_base", - "grpc++_codegen_base_src", - "grpc++_codegen_proto", - "grpc++_config_proto", - "grpc_test_util" - ], - "headers": [ - "src/proto/grpc/channelz/channelz.grpc.pb.h", - "src/proto/grpc/channelz/channelz.pb.h", - "src/proto/grpc/channelz/channelz_mock.grpc.pb.h", - "src/proto/grpc/health/v1/health.grpc.pb.h", - "src/proto/grpc/health/v1/health.pb.h", - "src/proto/grpc/health/v1/health_mock.grpc.pb.h", - "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h", - "src/proto/grpc/testing/duplicate/echo_duplicate.pb.h", - "src/proto/grpc/testing/duplicate/echo_duplicate_mock.grpc.pb.h", - "src/proto/grpc/testing/echo.grpc.pb.h", - "src/proto/grpc/testing/echo.pb.h", - "src/proto/grpc/testing/echo_messages.grpc.pb.h", - "src/proto/grpc/testing/echo_messages.pb.h", - "src/proto/grpc/testing/echo_messages_mock.grpc.pb.h", - "src/proto/grpc/testing/echo_mock.grpc.pb.h", - "src/proto/grpc/testing/simple_messages.grpc.pb.h", - "src/proto/grpc/testing/simple_messages.pb.h", - "src/proto/grpc/testing/simple_messages_mock.grpc.pb.h", - "test/cpp/end2end/test_health_check_service_impl.h", - "test/cpp/end2end/test_service_impl.h", - "test/cpp/util/byte_buffer_proto_helper.h", - "test/cpp/util/channel_trace_proto_helper.h", - "test/cpp/util/create_test_channel.h", - "test/cpp/util/string_ref_helper.h", - "test/cpp/util/subprocess.h", - "test/cpp/util/test_credentials_provider.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "grpc++_test_util", - "src": [ - "test/cpp/end2end/test_health_check_service_impl.cc", - "test/cpp/end2end/test_health_check_service_impl.h", - "test/cpp/end2end/test_service_impl.cc", - "test/cpp/end2end/test_service_impl.h", - "test/cpp/util/byte_buffer_proto_helper.cc", - "test/cpp/util/byte_buffer_proto_helper.h", - "test/cpp/util/channel_trace_proto_helper.cc", - "test/cpp/util/channel_trace_proto_helper.h", - "test/cpp/util/create_test_channel.cc", - "test/cpp/util/create_test_channel.h", - "test/cpp/util/string_ref_helper.cc", - "test/cpp/util/string_ref_helper.h", - "test/cpp/util/subprocess.cc", - "test/cpp/util/subprocess.h", - "test/cpp/util/test_credentials_provider.cc", - "test/cpp/util/test_credentials_provider.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "grpc++_codegen_base", - "grpc++_codegen_base_src", - "grpc++_codegen_proto", - "grpc++_config_proto", - "grpc++_unsecure", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [ - "src/proto/grpc/health/v1/health.grpc.pb.h", - "src/proto/grpc/health/v1/health.pb.h", - "src/proto/grpc/health/v1/health_mock.grpc.pb.h", - "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h", - "src/proto/grpc/testing/duplicate/echo_duplicate.pb.h", - "src/proto/grpc/testing/duplicate/echo_duplicate_mock.grpc.pb.h", - "src/proto/grpc/testing/echo.grpc.pb.h", - "src/proto/grpc/testing/echo.pb.h", - "src/proto/grpc/testing/echo_messages.grpc.pb.h", - "src/proto/grpc/testing/echo_messages.pb.h", - "src/proto/grpc/testing/echo_messages_mock.grpc.pb.h", - "src/proto/grpc/testing/echo_mock.grpc.pb.h", - "src/proto/grpc/testing/simple_messages.grpc.pb.h", - "src/proto/grpc/testing/simple_messages.pb.h", - "src/proto/grpc/testing/simple_messages_mock.grpc.pb.h", - "test/cpp/end2end/test_health_check_service_impl.h", - "test/cpp/end2end/test_service_impl.h", - "test/cpp/util/byte_buffer_proto_helper.h", - "test/cpp/util/string_ref_helper.h", - "test/cpp/util/subprocess.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "grpc++_test_util_unsecure", - "src": [ - "test/cpp/end2end/test_health_check_service_impl.cc", - "test/cpp/end2end/test_health_check_service_impl.h", - "test/cpp/end2end/test_service_impl.cc", - "test/cpp/end2end/test_service_impl.h", - "test/cpp/util/byte_buffer_proto_helper.cc", - "test/cpp/util/byte_buffer_proto_helper.h", - "test/cpp/util/string_ref_helper.cc", - "test/cpp/util/string_ref_helper.h", - "test/cpp/util/subprocess.cc", - "test/cpp/util/subprocess.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "gpr", - "grpc++_base_unsecure", - "grpc++_codegen_base", - "grpc++_codegen_base_src", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "grpc++_unsecure", - "src": [ - "src/cpp/client/insecure_credentials.cc", - "src/cpp/common/insecure_create_auth_context.cc", - "src/cpp/server/insecure_server_credentials.cc" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "benchmark", - "grpc++_unsecure", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [ - "test/cpp/microbenchmarks/fullstack_context_mutators.h", - "test/cpp/microbenchmarks/fullstack_fixtures.h", - "test/cpp/microbenchmarks/helpers.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "grpc_benchmark", - "src": [ - "test/cpp/microbenchmarks/fullstack_context_mutators.h", - "test/cpp/microbenchmarks/fullstack_fixtures.h", - "test/cpp/microbenchmarks/helpers.cc", - "test/cpp/microbenchmarks/helpers.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "grpc", - "grpc++", - "grpc++_config_proto", - "grpc++_proto_reflection_desc_db", - "grpc++_reflection_proto" - ], - "headers": [ - "test/cpp/util/cli_call.h", - "test/cpp/util/cli_credentials.h", - "test/cpp/util/config_grpc_cli.h", - "test/cpp/util/grpc_tool.h", - "test/cpp/util/proto_file_parser.h", - "test/cpp/util/service_describer.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "grpc_cli_libs", - "src": [ - "test/cpp/util/cli_call.cc", - "test/cpp/util/cli_call.h", - "test/cpp/util/cli_credentials.cc", - "test/cpp/util/cli_credentials.h", - "test/cpp/util/config_grpc_cli.h", - "test/cpp/util/grpc_tool.cc", - "test/cpp/util/grpc_tool.h", - "test/cpp/util/proto_file_parser.cc", - "test/cpp/util/proto_file_parser.h", - "test/cpp/util/service_describer.cc", - "test/cpp/util/service_describer.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "grpc++_config_proto" - ], - "headers": [ - "src/compiler/config.h", - "src/compiler/config_protobuf.h", - "src/compiler/cpp_generator.h", - "src/compiler/cpp_generator_helpers.h", - "src/compiler/csharp_generator.h", - "src/compiler/csharp_generator_helpers.h", - "src/compiler/generator_helpers.h", - "src/compiler/node_generator.h", - "src/compiler/node_generator_helpers.h", - "src/compiler/objective_c_generator.h", - "src/compiler/objective_c_generator_helpers.h", - "src/compiler/php_generator.h", - "src/compiler/php_generator_helpers.h", - "src/compiler/protobuf_plugin.h", - "src/compiler/python_generator.h", - "src/compiler/python_generator_helpers.h", - "src/compiler/python_private_generator.h", - "src/compiler/ruby_generator.h", - "src/compiler/ruby_generator_helpers-inl.h", - "src/compiler/ruby_generator_map-inl.h", - "src/compiler/ruby_generator_string-inl.h", - "src/compiler/schema_interface.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "grpc_plugin_support", - "src": [ - "src/compiler/config.h", - "src/compiler/config_protobuf.h", - "src/compiler/cpp_generator.cc", - "src/compiler/cpp_generator.h", - "src/compiler/cpp_generator_helpers.h", - "src/compiler/csharp_generator.cc", - "src/compiler/csharp_generator.h", - "src/compiler/csharp_generator_helpers.h", - "src/compiler/generator_helpers.h", - "src/compiler/node_generator.cc", - "src/compiler/node_generator.h", - "src/compiler/node_generator_helpers.h", - "src/compiler/objective_c_generator.cc", - "src/compiler/objective_c_generator.h", - "src/compiler/objective_c_generator_helpers.h", - "src/compiler/php_generator.cc", - "src/compiler/php_generator.h", - "src/compiler/php_generator_helpers.h", - "src/compiler/protobuf_plugin.h", - "src/compiler/python_generator.cc", - "src/compiler/python_generator.h", - "src/compiler/python_generator_helpers.h", - "src/compiler/python_private_generator.h", - "src/compiler/ruby_generator.cc", - "src/compiler/ruby_generator.h", - "src/compiler/ruby_generator_helpers-inl.h", - "src/compiler/ruby_generator_map-inl.h", - "src/compiler/ruby_generator_string-inl.h", - "src/compiler/schema_interface.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "grpc", - "grpc++", - "grpcpp_channelz_proto" - ], - "headers": [ - "include/grpcpp/ext/channelz_service_plugin.h", - "include/grpcpp/ext/channelz_service_plugin_impl.h", - "src/cpp/server/channelz/channelz_service.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "grpcpp_channelz", - "src": [ - "include/grpcpp/ext/channelz_service_plugin.h", - "include/grpcpp/ext/channelz_service_plugin_impl.h", - "src/cpp/server/channelz/channelz_service.cc", - "src/cpp/server/channelz/channelz_service.h", - "src/cpp/server/channelz/channelz_service_plugin.cc" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "grpc", - "grpc++", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [ - "src/proto/grpc/testing/empty.grpc.pb.h", - "src/proto/grpc/testing/empty.pb.h", - "src/proto/grpc/testing/empty_mock.grpc.pb.h", - "src/proto/grpc/testing/messages.grpc.pb.h", - "src/proto/grpc/testing/messages.pb.h", - "src/proto/grpc/testing/messages_mock.grpc.pb.h", - "src/proto/grpc/testing/test.grpc.pb.h", - "src/proto/grpc/testing/test.pb.h", - "src/proto/grpc/testing/test_mock.grpc.pb.h", - "test/cpp/interop/http2_client.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "http2_client_main", - "src": [ - "test/cpp/interop/http2_client.cc", - "test/cpp/interop/http2_client.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [ - "src/proto/grpc/testing/messages.grpc.pb.h", - "src/proto/grpc/testing/messages.pb.h", - "src/proto/grpc/testing/messages_mock.grpc.pb.h", - "test/cpp/interop/client_helper.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "interop_client_helper", - "src": [ - "test/cpp/interop/client_helper.cc", - "test/cpp/interop/client_helper.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util", - "interop_client_helper" - ], - "headers": [ - "src/proto/grpc/testing/empty.grpc.pb.h", - "src/proto/grpc/testing/empty.pb.h", - "src/proto/grpc/testing/empty_mock.grpc.pb.h", - "src/proto/grpc/testing/messages.grpc.pb.h", - "src/proto/grpc/testing/messages.pb.h", - "src/proto/grpc/testing/messages_mock.grpc.pb.h", - "src/proto/grpc/testing/test.grpc.pb.h", - "src/proto/grpc/testing/test.pb.h", - "src/proto/grpc/testing/test_mock.grpc.pb.h", - "test/cpp/interop/interop_client.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "interop_client_main", - "src": [ - "test/cpp/interop/client.cc", - "test/cpp/interop/interop_client.cc", - "test/cpp/interop/interop_client.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [ - "test/cpp/interop/server_helper.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "interop_server_helper", - "src": [ - "test/cpp/interop/server_helper.cc", - "test/cpp/interop/server_helper.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++", - "grpc++_test_config", - "grpc++_test_util", - "grpc_test_util", - "interop_server_helper" - ], - "headers": [ - "src/proto/grpc/testing/empty.grpc.pb.h", - "src/proto/grpc/testing/empty.pb.h", - "src/proto/grpc/testing/empty_mock.grpc.pb.h", - "src/proto/grpc/testing/messages.grpc.pb.h", - "src/proto/grpc/testing/messages.pb.h", - "src/proto/grpc/testing/messages_mock.grpc.pb.h", - "src/proto/grpc/testing/test.grpc.pb.h", - "src/proto/grpc/testing/test.pb.h", - "src/proto/grpc/testing/test_mock.grpc.pb.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "interop_server_lib", - "src": [ - "test/cpp/interop/interop_server.cc" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "interop_server_lib" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "interop_server_main", - "src": [ - "test/cpp/interop/interop_server_bootstrap.cc" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "grpc", - "grpc++", - "grpc++_core_stats", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [ - "src/proto/grpc/testing/benchmark_service.grpc.pb.h", - "src/proto/grpc/testing/benchmark_service.pb.h", - "src/proto/grpc/testing/benchmark_service_mock.grpc.pb.h", - "src/proto/grpc/testing/control.grpc.pb.h", - "src/proto/grpc/testing/control.pb.h", - "src/proto/grpc/testing/control_mock.grpc.pb.h", - "src/proto/grpc/testing/messages.grpc.pb.h", - "src/proto/grpc/testing/messages.pb.h", - "src/proto/grpc/testing/messages_mock.grpc.pb.h", - "src/proto/grpc/testing/payloads.grpc.pb.h", - "src/proto/grpc/testing/payloads.pb.h", - "src/proto/grpc/testing/payloads_mock.grpc.pb.h", - "src/proto/grpc/testing/report_qps_scenario_service.grpc.pb.h", - "src/proto/grpc/testing/report_qps_scenario_service.pb.h", - "src/proto/grpc/testing/report_qps_scenario_service_mock.grpc.pb.h", - "src/proto/grpc/testing/stats.grpc.pb.h", - "src/proto/grpc/testing/stats.pb.h", - "src/proto/grpc/testing/stats_mock.grpc.pb.h", - "src/proto/grpc/testing/worker_service.grpc.pb.h", - "src/proto/grpc/testing/worker_service.pb.h", - "src/proto/grpc/testing/worker_service_mock.grpc.pb.h", - "test/cpp/qps/benchmark_config.h", - "test/cpp/qps/client.h", - "test/cpp/qps/driver.h", - "test/cpp/qps/histogram.h", - "test/cpp/qps/interarrival.h", - "test/cpp/qps/parse_json.h", - "test/cpp/qps/qps_server_builder.h", - "test/cpp/qps/qps_worker.h", - "test/cpp/qps/report.h", - "test/cpp/qps/server.h", - "test/cpp/qps/stats.h", - "test/cpp/qps/usage_timer.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "qps", - "src": [ - "test/cpp/qps/benchmark_config.cc", - "test/cpp/qps/benchmark_config.h", - "test/cpp/qps/client.h", - "test/cpp/qps/client_async.cc", - "test/cpp/qps/client_callback.cc", - "test/cpp/qps/client_sync.cc", - "test/cpp/qps/driver.cc", - "test/cpp/qps/driver.h", - "test/cpp/qps/histogram.h", - "test/cpp/qps/interarrival.h", - "test/cpp/qps/parse_json.cc", - "test/cpp/qps/parse_json.h", - "test/cpp/qps/qps_server_builder.cc", - "test/cpp/qps/qps_server_builder.h", - "test/cpp/qps/qps_worker.cc", - "test/cpp/qps/qps_worker.h", - "test/cpp/qps/report.cc", - "test/cpp/qps/report.h", - "test/cpp/qps/server.h", - "test/cpp/qps/server_async.cc", - "test/cpp/qps/server_callback.cc", - "test/cpp/qps/server_sync.cc", - "test/cpp/qps/stats.h", - "test/cpp/qps/usage_timer.cc", - "test/cpp/qps/usage_timer.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "gpr", - "grpc" - ], - "headers": [], - "is_filegroup": false, - "language": "csharp", - "name": "grpc_csharp_ext", - "src": [ - "src/csharp/ext/grpc_csharp_ext.c" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [], - "headers": [ - "third_party/boringssl/crypto/asn1/asn1_locl.h", - "third_party/boringssl/crypto/bio/internal.h", - "third_party/boringssl/crypto/bytestring/internal.h", - "third_party/boringssl/crypto/cipher_extra/internal.h", - "third_party/boringssl/crypto/conf/conf_def.h", - "third_party/boringssl/crypto/conf/internal.h", - "third_party/boringssl/crypto/err/internal.h", - "third_party/boringssl/crypto/evp/internal.h", - "third_party/boringssl/crypto/fipsmodule/aes/aes.c", - "third_party/boringssl/crypto/fipsmodule/aes/internal.h", - "third_party/boringssl/crypto/fipsmodule/aes/key_wrap.c", - "third_party/boringssl/crypto/fipsmodule/aes/mode_wrappers.c", - "third_party/boringssl/crypto/fipsmodule/bn/add.c", - "third_party/boringssl/crypto/fipsmodule/bn/asm/x86_64-gcc.c", - "third_party/boringssl/crypto/fipsmodule/bn/bn.c", - "third_party/boringssl/crypto/fipsmodule/bn/bytes.c", - "third_party/boringssl/crypto/fipsmodule/bn/cmp.c", - "third_party/boringssl/crypto/fipsmodule/bn/ctx.c", - "third_party/boringssl/crypto/fipsmodule/bn/div.c", - "third_party/boringssl/crypto/fipsmodule/bn/exponentiation.c", - "third_party/boringssl/crypto/fipsmodule/bn/gcd.c", - "third_party/boringssl/crypto/fipsmodule/bn/generic.c", - "third_party/boringssl/crypto/fipsmodule/bn/internal.h", - "third_party/boringssl/crypto/fipsmodule/bn/jacobi.c", - "third_party/boringssl/crypto/fipsmodule/bn/montgomery.c", - "third_party/boringssl/crypto/fipsmodule/bn/montgomery_inv.c", - "third_party/boringssl/crypto/fipsmodule/bn/mul.c", - "third_party/boringssl/crypto/fipsmodule/bn/prime.c", - "third_party/boringssl/crypto/fipsmodule/bn/random.c", - "third_party/boringssl/crypto/fipsmodule/bn/rsaz_exp.c", - "third_party/boringssl/crypto/fipsmodule/bn/rsaz_exp.h", - "third_party/boringssl/crypto/fipsmodule/bn/shift.c", - "third_party/boringssl/crypto/fipsmodule/bn/sqrt.c", - "third_party/boringssl/crypto/fipsmodule/cipher/aead.c", - "third_party/boringssl/crypto/fipsmodule/cipher/cipher.c", - "third_party/boringssl/crypto/fipsmodule/cipher/e_aes.c", - "third_party/boringssl/crypto/fipsmodule/cipher/e_des.c", - "third_party/boringssl/crypto/fipsmodule/cipher/internal.h", - "third_party/boringssl/crypto/fipsmodule/delocate.h", - "third_party/boringssl/crypto/fipsmodule/des/des.c", - "third_party/boringssl/crypto/fipsmodule/des/internal.h", - "third_party/boringssl/crypto/fipsmodule/digest/digest.c", - "third_party/boringssl/crypto/fipsmodule/digest/digests.c", - "third_party/boringssl/crypto/fipsmodule/digest/internal.h", - "third_party/boringssl/crypto/fipsmodule/digest/md32_common.h", - "third_party/boringssl/crypto/fipsmodule/ec/ec.c", - "third_party/boringssl/crypto/fipsmodule/ec/ec_key.c", - "third_party/boringssl/crypto/fipsmodule/ec/ec_montgomery.c", - "third_party/boringssl/crypto/fipsmodule/ec/internal.h", - "third_party/boringssl/crypto/fipsmodule/ec/oct.c", - "third_party/boringssl/crypto/fipsmodule/ec/p224-64.c", - "third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64-table.h", - "third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.c", - "third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.h", - "third_party/boringssl/crypto/fipsmodule/ec/simple.c", - "third_party/boringssl/crypto/fipsmodule/ec/util.c", - "third_party/boringssl/crypto/fipsmodule/ec/wnaf.c", - "third_party/boringssl/crypto/fipsmodule/ecdsa/ecdsa.c", - "third_party/boringssl/crypto/fipsmodule/hmac/hmac.c", - "third_party/boringssl/crypto/fipsmodule/md4/md4.c", - "third_party/boringssl/crypto/fipsmodule/md5/md5.c", - "third_party/boringssl/crypto/fipsmodule/modes/cbc.c", - "third_party/boringssl/crypto/fipsmodule/modes/ccm.c", - "third_party/boringssl/crypto/fipsmodule/modes/cfb.c", - "third_party/boringssl/crypto/fipsmodule/modes/ctr.c", - "third_party/boringssl/crypto/fipsmodule/modes/gcm.c", - "third_party/boringssl/crypto/fipsmodule/modes/internal.h", - "third_party/boringssl/crypto/fipsmodule/modes/ofb.c", - "third_party/boringssl/crypto/fipsmodule/modes/polyval.c", - "third_party/boringssl/crypto/fipsmodule/rand/ctrdrbg.c", - "third_party/boringssl/crypto/fipsmodule/rand/internal.h", - "third_party/boringssl/crypto/fipsmodule/rand/rand.c", - "third_party/boringssl/crypto/fipsmodule/rand/urandom.c", - "third_party/boringssl/crypto/fipsmodule/rsa/blinding.c", - "third_party/boringssl/crypto/fipsmodule/rsa/internal.h", - "third_party/boringssl/crypto/fipsmodule/rsa/padding.c", - "third_party/boringssl/crypto/fipsmodule/rsa/rsa.c", - "third_party/boringssl/crypto/fipsmodule/rsa/rsa_impl.c", - "third_party/boringssl/crypto/fipsmodule/self_check/self_check.c", - "third_party/boringssl/crypto/fipsmodule/sha/sha1-altivec.c", - "third_party/boringssl/crypto/fipsmodule/sha/sha1.c", - "third_party/boringssl/crypto/fipsmodule/sha/sha256.c", - "third_party/boringssl/crypto/fipsmodule/sha/sha512.c", - "third_party/boringssl/crypto/fipsmodule/tls/internal.h", - "third_party/boringssl/crypto/fipsmodule/tls/kdf.c", - "third_party/boringssl/crypto/internal.h", - "third_party/boringssl/crypto/obj/obj_dat.h", - "third_party/boringssl/crypto/pkcs7/internal.h", - "third_party/boringssl/crypto/pkcs8/internal.h", - "third_party/boringssl/crypto/poly1305/internal.h", - "third_party/boringssl/crypto/pool/internal.h", - "third_party/boringssl/crypto/x509/charmap.h", - "third_party/boringssl/crypto/x509/internal.h", - "third_party/boringssl/crypto/x509/vpm_int.h", - "third_party/boringssl/crypto/x509v3/ext_dat.h", - "third_party/boringssl/crypto/x509v3/pcy_int.h", - "third_party/boringssl/include/openssl/aead.h", - "third_party/boringssl/include/openssl/aes.h", - "third_party/boringssl/include/openssl/arm_arch.h", - "third_party/boringssl/include/openssl/asn1.h", - "third_party/boringssl/include/openssl/asn1_mac.h", - "third_party/boringssl/include/openssl/asn1t.h", - "third_party/boringssl/include/openssl/base.h", - "third_party/boringssl/include/openssl/base64.h", - "third_party/boringssl/include/openssl/bio.h", - "third_party/boringssl/include/openssl/blowfish.h", - "third_party/boringssl/include/openssl/bn.h", - "third_party/boringssl/include/openssl/buf.h", - "third_party/boringssl/include/openssl/buffer.h", - "third_party/boringssl/include/openssl/bytestring.h", - "third_party/boringssl/include/openssl/cast.h", - "third_party/boringssl/include/openssl/chacha.h", - "third_party/boringssl/include/openssl/cipher.h", - "third_party/boringssl/include/openssl/cmac.h", - "third_party/boringssl/include/openssl/conf.h", - "third_party/boringssl/include/openssl/cpu.h", - "third_party/boringssl/include/openssl/crypto.h", - "third_party/boringssl/include/openssl/curve25519.h", - "third_party/boringssl/include/openssl/des.h", - "third_party/boringssl/include/openssl/dh.h", - "third_party/boringssl/include/openssl/digest.h", - "third_party/boringssl/include/openssl/dsa.h", - "third_party/boringssl/include/openssl/dtls1.h", - "third_party/boringssl/include/openssl/ec.h", - "third_party/boringssl/include/openssl/ec_key.h", - "third_party/boringssl/include/openssl/ecdh.h", - "third_party/boringssl/include/openssl/ecdsa.h", - "third_party/boringssl/include/openssl/engine.h", - "third_party/boringssl/include/openssl/err.h", - "third_party/boringssl/include/openssl/evp.h", - "third_party/boringssl/include/openssl/ex_data.h", - "third_party/boringssl/include/openssl/hkdf.h", - "third_party/boringssl/include/openssl/hmac.h", - "third_party/boringssl/include/openssl/is_boringssl.h", - "third_party/boringssl/include/openssl/lhash.h", - "third_party/boringssl/include/openssl/lhash_macros.h", - "third_party/boringssl/include/openssl/md4.h", - "third_party/boringssl/include/openssl/md5.h", - "third_party/boringssl/include/openssl/mem.h", - "third_party/boringssl/include/openssl/nid.h", - "third_party/boringssl/include/openssl/obj.h", - "third_party/boringssl/include/openssl/obj_mac.h", - "third_party/boringssl/include/openssl/objects.h", - "third_party/boringssl/include/openssl/opensslconf.h", - "third_party/boringssl/include/openssl/opensslv.h", - "third_party/boringssl/include/openssl/ossl_typ.h", - "third_party/boringssl/include/openssl/pem.h", - "third_party/boringssl/include/openssl/pkcs12.h", - "third_party/boringssl/include/openssl/pkcs7.h", - "third_party/boringssl/include/openssl/pkcs8.h", - "third_party/boringssl/include/openssl/poly1305.h", - "third_party/boringssl/include/openssl/pool.h", - "third_party/boringssl/include/openssl/rand.h", - "third_party/boringssl/include/openssl/rc4.h", - "third_party/boringssl/include/openssl/ripemd.h", - "third_party/boringssl/include/openssl/rsa.h", - "third_party/boringssl/include/openssl/safestack.h", - "third_party/boringssl/include/openssl/sha.h", - "third_party/boringssl/include/openssl/span.h", - "third_party/boringssl/include/openssl/srtp.h", - "third_party/boringssl/include/openssl/ssl.h", - "third_party/boringssl/include/openssl/ssl3.h", - "third_party/boringssl/include/openssl/stack.h", - "third_party/boringssl/include/openssl/thread.h", - "third_party/boringssl/include/openssl/tls1.h", - "third_party/boringssl/include/openssl/type_check.h", - "third_party/boringssl/include/openssl/x509.h", - "third_party/boringssl/include/openssl/x509_vfy.h", - "third_party/boringssl/include/openssl/x509v3.h", - "third_party/boringssl/ssl/internal.h", - "third_party/boringssl/third_party/fiat/curve25519_tables.h", - "third_party/boringssl/third_party/fiat/internal.h", - "third_party/boringssl/third_party/fiat/p256.c" - ], - "is_filegroup": false, - "language": "c", - "name": "boringssl", - "src": [ - "src/boringssl/err_data.c" - ], - "third_party": true, - "type": "lib" - }, - { - "deps": [], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "boringssl_test_util", - "src": [], - "third_party": true, - "type": "lib" - }, - { - "deps": [], - "headers": [ - "third_party/benchmark/include/benchmark/benchmark.h", - "third_party/benchmark/src/arraysize.h", - "third_party/benchmark/src/benchmark_api_internal.h", - "third_party/benchmark/src/benchmark_register.h", - "third_party/benchmark/src/check.h", - "third_party/benchmark/src/colorprint.h", - "third_party/benchmark/src/commandlineflags.h", - "third_party/benchmark/src/complexity.h", - "third_party/benchmark/src/counter.h", - "third_party/benchmark/src/cycleclock.h", - "third_party/benchmark/src/internal_macros.h", - "third_party/benchmark/src/log.h", - "third_party/benchmark/src/mutex.h", - "third_party/benchmark/src/re.h", - "third_party/benchmark/src/sleep.h", - "third_party/benchmark/src/statistics.h", - "third_party/benchmark/src/string_util.h", - "third_party/benchmark/src/thread_manager.h", - "third_party/benchmark/src/thread_timer.h", - "third_party/benchmark/src/timers.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "benchmark", - "src": [], - "third_party": false, - "type": "lib" - }, - { - "deps": [], - "headers": [ - "third_party/zlib/crc32.h", - "third_party/zlib/deflate.h", - "third_party/zlib/gzguts.h", - "third_party/zlib/inffast.h", - "third_party/zlib/inffixed.h", - "third_party/zlib/inflate.h", - "third_party/zlib/inftrees.h", - "third_party/zlib/trees.h", - "third_party/zlib/zconf.h", - "third_party/zlib/zlib.h", - "third_party/zlib/zutil.h" - ], - "is_filegroup": false, - "language": "c", - "name": "z", - "src": [], - "third_party": true, - "type": "lib" - }, - { - "deps": [], - "headers": [ - "third_party/cares/ares_build.h", - "third_party/cares/cares/ares.h", - "third_party/cares/cares/ares_data.h", - "third_party/cares/cares/ares_dns.h", - "third_party/cares/cares/ares_getenv.h", - "third_party/cares/cares/ares_getopt.h", - "third_party/cares/cares/ares_inet_net_pton.h", - "third_party/cares/cares/ares_iphlpapi.h", - "third_party/cares/cares/ares_ipv6.h", - "third_party/cares/cares/ares_library_init.h", - "third_party/cares/cares/ares_llist.h", - "third_party/cares/cares/ares_nowarn.h", - "third_party/cares/cares/ares_platform.h", - "third_party/cares/cares/ares_private.h", - "third_party/cares/cares/ares_rules.h", - "third_party/cares/cares/ares_setup.h", - "third_party/cares/cares/ares_strcasecmp.h", - "third_party/cares/cares/ares_strdup.h", - "third_party/cares/cares/ares_strsplit.h", - "third_party/cares/cares/ares_version.h", - "third_party/cares/cares/bitncmp.h", - "third_party/cares/cares/config-win32.h", - "third_party/cares/cares/setup_once.h", - "third_party/cares/config_darwin/ares_config.h", - "third_party/cares/config_freebsd/ares_config.h", - "third_party/cares/config_linux/ares_config.h", - "third_party/cares/config_openbsd/ares_config.h" - ], - "is_filegroup": false, - "language": "c", - "name": "ares", - "src": [], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [ - "test/core/bad_client/bad_client.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "bad_client_test", - "src": [ - "test/core/bad_client/bad_client.cc", - "test/core/bad_client/bad_client.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [ - "test/core/bad_ssl/server_common.h" - ], - "is_filegroup": false, - "language": "c", - "name": "bad_ssl_test_server", - "src": [ - "test/core/bad_ssl/server_common.cc", - "test/core/bad_ssl/server_common.h" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc_test_util" - ], - "headers": [ - "test/core/end2end/end2end_tests.h", - "test/core/end2end/tests/cancel_test_helpers.h" - ], - "is_filegroup": false, - "language": "c", - "name": "end2end_tests", - "src": [ - "test/core/end2end/end2end_test_utils.cc", - "test/core/end2end/end2end_tests.cc", - "test/core/end2end/end2end_tests.h", - "test/core/end2end/tests/authority_not_supported.cc", - "test/core/end2end/tests/bad_hostname.cc", - "test/core/end2end/tests/bad_ping.cc", - "test/core/end2end/tests/binary_metadata.cc", - "test/core/end2end/tests/call_creds.cc", - "test/core/end2end/tests/call_host_override.cc", - "test/core/end2end/tests/cancel_after_accept.cc", - "test/core/end2end/tests/cancel_after_client_done.cc", - "test/core/end2end/tests/cancel_after_invoke.cc", - "test/core/end2end/tests/cancel_after_round_trip.cc", - "test/core/end2end/tests/cancel_before_invoke.cc", - "test/core/end2end/tests/cancel_in_a_vacuum.cc", - "test/core/end2end/tests/cancel_test_helpers.h", - "test/core/end2end/tests/cancel_with_status.cc", - "test/core/end2end/tests/channelz.cc", - "test/core/end2end/tests/compressed_payload.cc", - "test/core/end2end/tests/connectivity.cc", - "test/core/end2end/tests/default_host.cc", - "test/core/end2end/tests/disappearing_server.cc", - "test/core/end2end/tests/empty_batch.cc", - "test/core/end2end/tests/filter_call_init_fails.cc", - "test/core/end2end/tests/filter_causes_close.cc", - "test/core/end2end/tests/filter_context.cc", - "test/core/end2end/tests/filter_latency.cc", - "test/core/end2end/tests/filter_status_code.cc", - "test/core/end2end/tests/graceful_server_shutdown.cc", - "test/core/end2end/tests/high_initial_seqno.cc", - "test/core/end2end/tests/hpack_size.cc", - "test/core/end2end/tests/idempotent_request.cc", - "test/core/end2end/tests/invoke_large_request.cc", - "test/core/end2end/tests/keepalive_timeout.cc", - "test/core/end2end/tests/large_metadata.cc", - "test/core/end2end/tests/max_concurrent_streams.cc", - "test/core/end2end/tests/max_connection_age.cc", - "test/core/end2end/tests/max_connection_idle.cc", - "test/core/end2end/tests/max_message_length.cc", - "test/core/end2end/tests/negative_deadline.cc", - "test/core/end2end/tests/no_error_on_hotpath.cc", - "test/core/end2end/tests/no_logging.cc", - "test/core/end2end/tests/no_op.cc", - "test/core/end2end/tests/payload.cc", - "test/core/end2end/tests/ping.cc", - "test/core/end2end/tests/ping_pong_streaming.cc", - "test/core/end2end/tests/proxy_auth.cc", - "test/core/end2end/tests/registered_call.cc", - "test/core/end2end/tests/request_with_flags.cc", - "test/core/end2end/tests/request_with_payload.cc", - "test/core/end2end/tests/resource_quota_server.cc", - "test/core/end2end/tests/retry.cc", - "test/core/end2end/tests/retry_cancellation.cc", - "test/core/end2end/tests/retry_disabled.cc", - "test/core/end2end/tests/retry_exceeds_buffer_size_in_initial_batch.cc", - "test/core/end2end/tests/retry_exceeds_buffer_size_in_subsequent_batch.cc", - "test/core/end2end/tests/retry_non_retriable_status.cc", - "test/core/end2end/tests/retry_non_retriable_status_before_recv_trailing_metadata_started.cc", - "test/core/end2end/tests/retry_recv_initial_metadata.cc", - "test/core/end2end/tests/retry_recv_message.cc", - "test/core/end2end/tests/retry_server_pushback_delay.cc", - "test/core/end2end/tests/retry_server_pushback_disabled.cc", - "test/core/end2end/tests/retry_streaming.cc", - "test/core/end2end/tests/retry_streaming_after_commit.cc", - "test/core/end2end/tests/retry_streaming_succeeds_before_replay_finished.cc", - "test/core/end2end/tests/retry_throttled.cc", - "test/core/end2end/tests/retry_too_many_attempts.cc", - "test/core/end2end/tests/server_finishes_request.cc", - "test/core/end2end/tests/shutdown_finishes_calls.cc", - "test/core/end2end/tests/shutdown_finishes_tags.cc", - "test/core/end2end/tests/simple_cacheable_request.cc", - "test/core/end2end/tests/simple_delayed_request.cc", - "test/core/end2end/tests/simple_metadata.cc", - "test/core/end2end/tests/simple_request.cc", - "test/core/end2end/tests/stream_compression_compressed_payload.cc", - "test/core/end2end/tests/stream_compression_payload.cc", - "test/core/end2end/tests/stream_compression_ping_pong_streaming.cc", - "test/core/end2end/tests/streaming_error_response.cc", - "test/core/end2end/tests/trailing_metadata.cc", - "test/core/end2end/tests/workaround_cronet_compression.cc", - "test/core/end2end/tests/write_buffering.cc", - "test/core/end2end/tests/write_buffering_at_end.cc" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "gpr", - "grpc_test_util_unsecure", - "grpc_unsecure" - ], - "headers": [ - "test/core/end2end/end2end_tests.h", - "test/core/end2end/tests/cancel_test_helpers.h" - ], - "is_filegroup": false, - "language": "c", - "name": "end2end_nosec_tests", - "src": [ - "test/core/end2end/end2end_nosec_tests.cc", - "test/core/end2end/end2end_test_utils.cc", - "test/core/end2end/end2end_tests.h", - "test/core/end2end/tests/authority_not_supported.cc", - "test/core/end2end/tests/bad_hostname.cc", - "test/core/end2end/tests/bad_ping.cc", - "test/core/end2end/tests/binary_metadata.cc", - "test/core/end2end/tests/call_host_override.cc", - "test/core/end2end/tests/cancel_after_accept.cc", - "test/core/end2end/tests/cancel_after_client_done.cc", - "test/core/end2end/tests/cancel_after_invoke.cc", - "test/core/end2end/tests/cancel_after_round_trip.cc", - "test/core/end2end/tests/cancel_before_invoke.cc", - "test/core/end2end/tests/cancel_in_a_vacuum.cc", - "test/core/end2end/tests/cancel_test_helpers.h", - "test/core/end2end/tests/cancel_with_status.cc", - "test/core/end2end/tests/channelz.cc", - "test/core/end2end/tests/compressed_payload.cc", - "test/core/end2end/tests/connectivity.cc", - "test/core/end2end/tests/default_host.cc", - "test/core/end2end/tests/disappearing_server.cc", - "test/core/end2end/tests/empty_batch.cc", - "test/core/end2end/tests/filter_call_init_fails.cc", - "test/core/end2end/tests/filter_causes_close.cc", - "test/core/end2end/tests/filter_context.cc", - "test/core/end2end/tests/filter_latency.cc", - "test/core/end2end/tests/filter_status_code.cc", - "test/core/end2end/tests/graceful_server_shutdown.cc", - "test/core/end2end/tests/high_initial_seqno.cc", - "test/core/end2end/tests/hpack_size.cc", - "test/core/end2end/tests/idempotent_request.cc", - "test/core/end2end/tests/invoke_large_request.cc", - "test/core/end2end/tests/keepalive_timeout.cc", - "test/core/end2end/tests/large_metadata.cc", - "test/core/end2end/tests/max_concurrent_streams.cc", - "test/core/end2end/tests/max_connection_age.cc", - "test/core/end2end/tests/max_connection_idle.cc", - "test/core/end2end/tests/max_message_length.cc", - "test/core/end2end/tests/negative_deadline.cc", - "test/core/end2end/tests/no_error_on_hotpath.cc", - "test/core/end2end/tests/no_logging.cc", - "test/core/end2end/tests/no_op.cc", - "test/core/end2end/tests/payload.cc", - "test/core/end2end/tests/ping.cc", - "test/core/end2end/tests/ping_pong_streaming.cc", - "test/core/end2end/tests/proxy_auth.cc", - "test/core/end2end/tests/registered_call.cc", - "test/core/end2end/tests/request_with_flags.cc", - "test/core/end2end/tests/request_with_payload.cc", - "test/core/end2end/tests/resource_quota_server.cc", - "test/core/end2end/tests/retry.cc", - "test/core/end2end/tests/retry_cancellation.cc", - "test/core/end2end/tests/retry_disabled.cc", - "test/core/end2end/tests/retry_exceeds_buffer_size_in_initial_batch.cc", - "test/core/end2end/tests/retry_exceeds_buffer_size_in_subsequent_batch.cc", - "test/core/end2end/tests/retry_non_retriable_status.cc", - "test/core/end2end/tests/retry_non_retriable_status_before_recv_trailing_metadata_started.cc", - "test/core/end2end/tests/retry_recv_initial_metadata.cc", - "test/core/end2end/tests/retry_recv_message.cc", - "test/core/end2end/tests/retry_server_pushback_delay.cc", - "test/core/end2end/tests/retry_server_pushback_disabled.cc", - "test/core/end2end/tests/retry_streaming.cc", - "test/core/end2end/tests/retry_streaming_after_commit.cc", - "test/core/end2end/tests/retry_streaming_succeeds_before_replay_finished.cc", - "test/core/end2end/tests/retry_throttled.cc", - "test/core/end2end/tests/retry_too_many_attempts.cc", - "test/core/end2end/tests/server_finishes_request.cc", - "test/core/end2end/tests/shutdown_finishes_calls.cc", - "test/core/end2end/tests/shutdown_finishes_tags.cc", - "test/core/end2end/tests/simple_cacheable_request.cc", - "test/core/end2end/tests/simple_delayed_request.cc", - "test/core/end2end/tests/simple_metadata.cc", - "test/core/end2end/tests/simple_request.cc", - "test/core/end2end/tests/stream_compression_compressed_payload.cc", - "test/core/end2end/tests/stream_compression_payload.cc", - "test/core/end2end/tests/stream_compression_ping_pong_streaming.cc", - "test/core/end2end/tests/streaming_error_response.cc", - "test/core/end2end/tests/trailing_metadata.cc", - "test/core/end2end/tests/workaround_cronet_compression.cc", - "test/core/end2end/tests/write_buffering.cc", - "test/core/end2end/tests/write_buffering_at_end.cc" - ], - "third_party": false, - "type": "lib" - }, - { - "deps": [ - "alts_util", - "gpr", - "grpc_base", - "grpc_shadow_boringssl", - "grpc_transport_chttp2_client_insecure", - "tsi", - "tsi_interface" - ], - "headers": [ - "src/core/tsi/alts/crypt/gsec.h", - "src/core/tsi/alts/frame_protector/alts_counter.h", - "src/core/tsi/alts/frame_protector/alts_crypter.h", - "src/core/tsi/alts/frame_protector/alts_frame_protector.h", - "src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.h", - "src/core/tsi/alts/frame_protector/frame_handler.h", - "src/core/tsi/alts/handshaker/alts_handshaker_client.h", - "src/core/tsi/alts/handshaker/alts_shared_resource.h", - "src/core/tsi/alts/handshaker/alts_tsi_handshaker.h", - "src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h", - "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h", - "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.h", - "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol.h", - "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h", - "src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h", - "src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h" - ], - "is_filegroup": true, - "language": "c", - "name": "alts_tsi", - "src": [ - "src/core/tsi/alts/crypt/aes_gcm.cc", - "src/core/tsi/alts/crypt/gsec.cc", - "src/core/tsi/alts/crypt/gsec.h", - "src/core/tsi/alts/frame_protector/alts_counter.cc", - "src/core/tsi/alts/frame_protector/alts_counter.h", - "src/core/tsi/alts/frame_protector/alts_crypter.cc", - "src/core/tsi/alts/frame_protector/alts_crypter.h", - "src/core/tsi/alts/frame_protector/alts_frame_protector.cc", - "src/core/tsi/alts/frame_protector/alts_frame_protector.h", - "src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.cc", - "src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.h", - "src/core/tsi/alts/frame_protector/alts_seal_privacy_integrity_crypter.cc", - "src/core/tsi/alts/frame_protector/alts_unseal_privacy_integrity_crypter.cc", - "src/core/tsi/alts/frame_protector/frame_handler.cc", - "src/core/tsi/alts/frame_protector/frame_handler.h", - "src/core/tsi/alts/handshaker/alts_handshaker_client.cc", - "src/core/tsi/alts/handshaker/alts_handshaker_client.h", - "src/core/tsi/alts/handshaker/alts_shared_resource.cc", - "src/core/tsi/alts/handshaker/alts_shared_resource.h", - "src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc", - "src/core/tsi/alts/handshaker/alts_tsi_handshaker.h", - "src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h", - "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc", - "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h", - "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc", - "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.h", - "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol.h", - "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc", - "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h", - "src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc", - "src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h", - "src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc", - "src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "upb" - ], - "headers": [ - "src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h", - "src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h", - "src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h" - ], - "is_filegroup": true, - "language": "c", - "name": "alts_upb", - "src": [ - "src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c", - "src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h", - "src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c", - "src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h", - "src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c", - "src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "alts_upb", - "gpr", - "grpc_base", - "tsi_interface", - "upb" - ], - "headers": [ - "include/grpc/grpc_security.h", - "src/core/lib/security/credentials/alts/check_gcp_environment.h", - "src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h", - "src/core/tsi/alts/handshaker/alts_tsi_utils.h", - "src/core/tsi/alts/handshaker/transport_security_common_api.h" - ], - "is_filegroup": true, - "language": "c", - "name": "alts_util", - "src": [ - "include/grpc/grpc_security.h", - "src/core/lib/security/credentials/alts/check_gcp_environment.cc", - "src/core/lib/security/credentials/alts/check_gcp_environment.h", - "src/core/lib/security/credentials/alts/check_gcp_environment_linux.cc", - "src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc", - "src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc", - "src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc", - "src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc", - "src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h", - "src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc", - "src/core/tsi/alts/handshaker/alts_tsi_utils.cc", - "src/core/tsi/alts/handshaker/alts_tsi_utils.h", - "src/core/tsi/alts/handshaker/transport_security_common_api.cc", - "src/core/tsi/alts/handshaker/transport_security_common_api.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base" - ], - "headers": [ - "include/grpc/census.h" - ], - "is_filegroup": true, - "language": "c", - "name": "census", - "src": [ - "include/grpc/census.h", - "src/core/ext/filters/census/grpc_context.cc" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr_base_headers" - ], - "headers": [ - "test/core/util/cmdline.h" - ], - "is_filegroup": true, - "language": "c", - "name": "cmdline", - "src": [ - "test/core/util/cmdline.cc", - "test/core/util/cmdline.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "envoy_core_upb", - "envoy_type_upb", - "google_api_upb", - "proto_gen_validate_upb" - ], - "headers": [ - "src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/cds.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/eds.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h", - "src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h", - "src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h" - ], - "is_filegroup": true, - "language": "c", - "name": "envoy_ads_upb", - "src": [ - "src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/cds.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/cds.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/eds.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/eds.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h", - "src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c", - "src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h", - "src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c", - "src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "envoy_type_upb", - "google_api_upb", - "proto_gen_validate_upb" - ], - "headers": [ - "src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h" - ], - "is_filegroup": true, - "language": "c", - "name": "envoy_core_upb", - "src": [ - "src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h", - "src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c", - "src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "google_api_upb", - "proto_gen_validate_upb" - ], - "headers": [ - "src/core/ext/upb-generated/envoy/type/percent.upb.h", - "src/core/ext/upb-generated/envoy/type/range.upb.h" - ], - "is_filegroup": true, - "language": "c", - "name": "envoy_type_upb", - "src": [ - "src/core/ext/upb-generated/envoy/type/percent.upb.c", - "src/core/ext/upb-generated/envoy/type/percent.upb.h", - "src/core/ext/upb-generated/envoy/type/range.upb.c", - "src/core/ext/upb-generated/envoy/type/range.upb.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "upb" - ], - "headers": [ - "src/core/ext/upb-generated/google/api/annotations.upb.h", - "src/core/ext/upb-generated/google/api/http.upb.h", - "src/core/ext/upb-generated/google/protobuf/any.upb.h", - "src/core/ext/upb-generated/google/protobuf/descriptor.upb.h", - "src/core/ext/upb-generated/google/protobuf/duration.upb.h", - "src/core/ext/upb-generated/google/protobuf/empty.upb.h", - "src/core/ext/upb-generated/google/protobuf/struct.upb.h", - "src/core/ext/upb-generated/google/protobuf/timestamp.upb.h", - "src/core/ext/upb-generated/google/protobuf/wrappers.upb.h", - "src/core/ext/upb-generated/google/rpc/status.upb.h" - ], - "is_filegroup": true, - "language": "c", - "name": "google_api_upb", - "src": [ - "src/core/ext/upb-generated/google/api/annotations.upb.c", - "src/core/ext/upb-generated/google/api/annotations.upb.h", - "src/core/ext/upb-generated/google/api/http.upb.c", - "src/core/ext/upb-generated/google/api/http.upb.h", - "src/core/ext/upb-generated/google/protobuf/any.upb.c", - "src/core/ext/upb-generated/google/protobuf/any.upb.h", - "src/core/ext/upb-generated/google/protobuf/descriptor.upb.c", - "src/core/ext/upb-generated/google/protobuf/descriptor.upb.h", - "src/core/ext/upb-generated/google/protobuf/duration.upb.c", - "src/core/ext/upb-generated/google/protobuf/duration.upb.h", - "src/core/ext/upb-generated/google/protobuf/empty.upb.c", - "src/core/ext/upb-generated/google/protobuf/empty.upb.h", - "src/core/ext/upb-generated/google/protobuf/struct.upb.c", - "src/core/ext/upb-generated/google/protobuf/struct.upb.h", - "src/core/ext/upb-generated/google/protobuf/timestamp.upb.c", - "src/core/ext/upb-generated/google/protobuf/timestamp.upb.h", - "src/core/ext/upb-generated/google/protobuf/wrappers.upb.c", - "src/core/ext/upb-generated/google/protobuf/wrappers.upb.h", - "src/core/ext/upb-generated/google/rpc/status.upb.c", - "src/core/ext/upb-generated/google/rpc/status.upb.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr_base_headers" - ], - "headers": [], - "is_filegroup": true, - "language": "c", - "name": "gpr_base", - "src": [ - "src/core/lib/gpr/alloc.cc", - "src/core/lib/gpr/atm.cc", - "src/core/lib/gpr/cpu_iphone.cc", - "src/core/lib/gpr/cpu_linux.cc", - "src/core/lib/gpr/cpu_posix.cc", - "src/core/lib/gpr/cpu_windows.cc", - "src/core/lib/gpr/env_linux.cc", - "src/core/lib/gpr/env_posix.cc", - "src/core/lib/gpr/env_windows.cc", - "src/core/lib/gpr/log.cc", - "src/core/lib/gpr/log_android.cc", - "src/core/lib/gpr/log_linux.cc", - "src/core/lib/gpr/log_posix.cc", - "src/core/lib/gpr/log_windows.cc", - "src/core/lib/gpr/mpscq.cc", - "src/core/lib/gpr/murmur_hash.cc", - "src/core/lib/gpr/string.cc", - "src/core/lib/gpr/string_posix.cc", - "src/core/lib/gpr/string_util_windows.cc", - "src/core/lib/gpr/string_windows.cc", - "src/core/lib/gpr/sync.cc", - "src/core/lib/gpr/sync_posix.cc", - "src/core/lib/gpr/sync_windows.cc", - "src/core/lib/gpr/time.cc", - "src/core/lib/gpr/time_posix.cc", - "src/core/lib/gpr/time_precise.cc", - "src/core/lib/gpr/time_windows.cc", - "src/core/lib/gpr/tls_pthread.cc", - "src/core/lib/gpr/tmpfile_msys.cc", - "src/core/lib/gpr/tmpfile_posix.cc", - "src/core/lib/gpr/tmpfile_windows.cc", - "src/core/lib/gpr/wrap_memcpy.cc", - "src/core/lib/gprpp/arena.cc", - "src/core/lib/gprpp/fork.cc", - "src/core/lib/gprpp/global_config_env.cc", - "src/core/lib/gprpp/host_port.cc", - "src/core/lib/gprpp/thd_posix.cc", - "src/core/lib/gprpp/thd_windows.cc", - "src/core/lib/profiling/basic_timers.cc", - "src/core/lib/profiling/stap_timers.cc" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr_codegen" - ], - "headers": [ - "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_windows.h", - "include/grpc/support/cpu.h", - "include/grpc/support/log.h", - "include/grpc/support/log_windows.h", - "include/grpc/support/port_platform.h", - "include/grpc/support/string_util.h", - "include/grpc/support/sync.h", - "include/grpc/support/sync_custom.h", - "include/grpc/support/sync_generic.h", - "include/grpc/support/sync_posix.h", - "include/grpc/support/sync_windows.h", - "include/grpc/support/thd_id.h", - "include/grpc/support/time.h", - "src/core/lib/gpr/alloc.h", - "src/core/lib/gpr/arena.h", - "src/core/lib/gpr/env.h", - "src/core/lib/gpr/mpscq.h", - "src/core/lib/gpr/murmur_hash.h", - "src/core/lib/gpr/spinlock.h", - "src/core/lib/gpr/string.h", - "src/core/lib/gpr/string_windows.h", - "src/core/lib/gpr/time_precise.h", - "src/core/lib/gpr/tls.h", - "src/core/lib/gpr/tls_gcc.h", - "src/core/lib/gpr/tls_msvc.h", - "src/core/lib/gpr/tls_pthread.h", - "src/core/lib/gpr/tmpfile.h", - "src/core/lib/gpr/useful.h", - "src/core/lib/gprpp/abstract.h", - "src/core/lib/gprpp/arena.h", - "src/core/lib/gprpp/atomic.h", - "src/core/lib/gprpp/fork.h", - "src/core/lib/gprpp/global_config.h", - "src/core/lib/gprpp/global_config_custom.h", - "src/core/lib/gprpp/global_config_env.h", - "src/core/lib/gprpp/global_config_generic.h", - "src/core/lib/gprpp/host_port.h", - "src/core/lib/gprpp/manual_constructor.h", - "src/core/lib/gprpp/map.h", - "src/core/lib/gprpp/memory.h", - "src/core/lib/gprpp/pair.h", - "src/core/lib/gprpp/sync.h", - "src/core/lib/gprpp/thd.h", - "src/core/lib/profiling/timers.h" - ], - "is_filegroup": true, - "language": "c", - "name": "gpr_base_headers", - "src": [ - "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_windows.h", - "include/grpc/support/cpu.h", - "include/grpc/support/log.h", - "include/grpc/support/log_windows.h", - "include/grpc/support/port_platform.h", - "include/grpc/support/string_util.h", - "include/grpc/support/sync.h", - "include/grpc/support/sync_custom.h", - "include/grpc/support/sync_generic.h", - "include/grpc/support/sync_posix.h", - "include/grpc/support/sync_windows.h", - "include/grpc/support/thd_id.h", - "include/grpc/support/time.h", - "src/core/lib/gpr/alloc.h", - "src/core/lib/gpr/arena.h", - "src/core/lib/gpr/env.h", - "src/core/lib/gpr/mpscq.h", - "src/core/lib/gpr/murmur_hash.h", - "src/core/lib/gpr/spinlock.h", - "src/core/lib/gpr/string.h", - "src/core/lib/gpr/string_windows.h", - "src/core/lib/gpr/time_precise.h", - "src/core/lib/gpr/tls.h", - "src/core/lib/gpr/tls_gcc.h", - "src/core/lib/gpr/tls_msvc.h", - "src/core/lib/gpr/tls_pthread.h", - "src/core/lib/gpr/tmpfile.h", - "src/core/lib/gpr/useful.h", - "src/core/lib/gprpp/abstract.h", - "src/core/lib/gprpp/arena.h", - "src/core/lib/gprpp/atomic.h", - "src/core/lib/gprpp/fork.h", - "src/core/lib/gprpp/global_config.h", - "src/core/lib/gprpp/global_config_custom.h", - "src/core/lib/gprpp/global_config_env.h", - "src/core/lib/gprpp/global_config_generic.h", - "src/core/lib/gprpp/host_port.h", - "src/core/lib/gprpp/manual_constructor.h", - "src/core/lib/gprpp/map.h", - "src/core/lib/gprpp/memory.h", - "src/core/lib/gprpp/pair.h", - "src/core/lib/gprpp/sync.h", - "src/core/lib/gprpp/thd.h", - "src/core/lib/profiling/timers.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [], - "headers": [ - "include/grpc/impl/codegen/atm.h", - "include/grpc/impl/codegen/atm_gcc_atomic.h", - "include/grpc/impl/codegen/atm_gcc_sync.h", - "include/grpc/impl/codegen/atm_windows.h", - "include/grpc/impl/codegen/fork.h", - "include/grpc/impl/codegen/gpr_slice.h", - "include/grpc/impl/codegen/gpr_types.h", - "include/grpc/impl/codegen/log.h", - "include/grpc/impl/codegen/port_platform.h", - "include/grpc/impl/codegen/sync.h", - "include/grpc/impl/codegen/sync_custom.h", - "include/grpc/impl/codegen/sync_generic.h", - "include/grpc/impl/codegen/sync_posix.h", - "include/grpc/impl/codegen/sync_windows.h" - ], - "is_filegroup": true, - "language": "c", - "name": "gpr_codegen", - "src": [ - "include/grpc/impl/codegen/atm.h", - "include/grpc/impl/codegen/atm_gcc_atomic.h", - "include/grpc/impl/codegen/atm_gcc_sync.h", - "include/grpc/impl/codegen/atm_windows.h", - "include/grpc/impl/codegen/fork.h", - "include/grpc/impl/codegen/gpr_slice.h", - "include/grpc/impl/codegen/gpr_types.h", - "include/grpc/impl/codegen/log.h", - "include/grpc/impl/codegen/port_platform.h", - "include/grpc/impl/codegen/sync.h", - "include/grpc/impl/codegen/sync_custom.h", - "include/grpc/impl/codegen/sync_generic.h", - "include/grpc/impl/codegen/sync_posix.h", - "include/grpc/impl/codegen/sync_windows.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc", - "grpc++_codegen_base", - "grpc++_common" - ], - "headers": [], - "is_filegroup": true, - "language": "c", - "name": "grpc++_base", - "src": [], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc++_codegen_base", - "grpc++_common", - "grpc_unsecure" - ], - "headers": [], - "is_filegroup": true, - "language": "c", - "name": "grpc++_base_unsecure", - "src": [], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base_headers", - "grpc_codegen", - "grpc_trace" - ], - "headers": [], - "is_filegroup": true, - "language": "c", - "name": "grpc_base", - "src": [ - "src/core/lib/avl/avl.cc", - "src/core/lib/backoff/backoff.cc", - "src/core/lib/channel/channel_args.cc", - "src/core/lib/channel/channel_stack.cc", - "src/core/lib/channel/channel_stack_builder.cc", - "src/core/lib/channel/channel_trace.cc", - "src/core/lib/channel/channelz.cc", - "src/core/lib/channel/channelz_registry.cc", - "src/core/lib/channel/connected_channel.cc", - "src/core/lib/channel/handshaker.cc", - "src/core/lib/channel/handshaker_registry.cc", - "src/core/lib/channel/status_util.cc", - "src/core/lib/compression/compression.cc", - "src/core/lib/compression/compression_args.cc", - "src/core/lib/compression/compression_internal.cc", - "src/core/lib/compression/message_compress.cc", - "src/core/lib/compression/stream_compression.cc", - "src/core/lib/compression/stream_compression_gzip.cc", - "src/core/lib/compression/stream_compression_identity.cc", - "src/core/lib/debug/stats.cc", - "src/core/lib/debug/stats_data.cc", - "src/core/lib/http/format_request.cc", - "src/core/lib/http/httpcli.cc", - "src/core/lib/http/parser.cc", - "src/core/lib/iomgr/buffer_list.cc", - "src/core/lib/iomgr/call_combiner.cc", - "src/core/lib/iomgr/cfstream_handle.cc", - "src/core/lib/iomgr/combiner.cc", - "src/core/lib/iomgr/endpoint.cc", - "src/core/lib/iomgr/endpoint_cfstream.cc", - "src/core/lib/iomgr/endpoint_pair_posix.cc", - "src/core/lib/iomgr/endpoint_pair_uv.cc", - "src/core/lib/iomgr/endpoint_pair_windows.cc", - "src/core/lib/iomgr/error.cc", - "src/core/lib/iomgr/error_cfstream.cc", - "src/core/lib/iomgr/ev_epoll1_linux.cc", - "src/core/lib/iomgr/ev_epollex_linux.cc", - "src/core/lib/iomgr/ev_poll_posix.cc", - "src/core/lib/iomgr/ev_posix.cc", - "src/core/lib/iomgr/ev_windows.cc", - "src/core/lib/iomgr/exec_ctx.cc", - "src/core/lib/iomgr/executor.cc", - "src/core/lib/iomgr/executor/mpmcqueue.cc", - "src/core/lib/iomgr/executor/threadpool.cc", - "src/core/lib/iomgr/fork_posix.cc", - "src/core/lib/iomgr/fork_windows.cc", - "src/core/lib/iomgr/gethostname_fallback.cc", - "src/core/lib/iomgr/gethostname_host_name_max.cc", - "src/core/lib/iomgr/gethostname_sysconf.cc", - "src/core/lib/iomgr/grpc_if_nametoindex_posix.cc", - "src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc", - "src/core/lib/iomgr/internal_errqueue.cc", - "src/core/lib/iomgr/iocp_windows.cc", - "src/core/lib/iomgr/iomgr.cc", - "src/core/lib/iomgr/iomgr_custom.cc", - "src/core/lib/iomgr/iomgr_internal.cc", - "src/core/lib/iomgr/iomgr_posix.cc", - "src/core/lib/iomgr/iomgr_posix_cfstream.cc", - "src/core/lib/iomgr/iomgr_uv.cc", - "src/core/lib/iomgr/iomgr_windows.cc", - "src/core/lib/iomgr/is_epollexclusive_available.cc", - "src/core/lib/iomgr/load_file.cc", - "src/core/lib/iomgr/lockfree_event.cc", - "src/core/lib/iomgr/polling_entity.cc", - "src/core/lib/iomgr/pollset.cc", - "src/core/lib/iomgr/pollset_custom.cc", - "src/core/lib/iomgr/pollset_set.cc", - "src/core/lib/iomgr/pollset_set_custom.cc", - "src/core/lib/iomgr/pollset_set_windows.cc", - "src/core/lib/iomgr/pollset_uv.cc", - "src/core/lib/iomgr/pollset_windows.cc", - "src/core/lib/iomgr/resolve_address.cc", - "src/core/lib/iomgr/resolve_address_custom.cc", - "src/core/lib/iomgr/resolve_address_posix.cc", - "src/core/lib/iomgr/resolve_address_windows.cc", - "src/core/lib/iomgr/resource_quota.cc", - "src/core/lib/iomgr/sockaddr_utils.cc", - "src/core/lib/iomgr/socket_factory_posix.cc", - "src/core/lib/iomgr/socket_mutator.cc", - "src/core/lib/iomgr/socket_utils_common_posix.cc", - "src/core/lib/iomgr/socket_utils_linux.cc", - "src/core/lib/iomgr/socket_utils_posix.cc", - "src/core/lib/iomgr/socket_utils_uv.cc", - "src/core/lib/iomgr/socket_utils_windows.cc", - "src/core/lib/iomgr/socket_windows.cc", - "src/core/lib/iomgr/tcp_client.cc", - "src/core/lib/iomgr/tcp_client_cfstream.cc", - "src/core/lib/iomgr/tcp_client_custom.cc", - "src/core/lib/iomgr/tcp_client_posix.cc", - "src/core/lib/iomgr/tcp_client_windows.cc", - "src/core/lib/iomgr/tcp_custom.cc", - "src/core/lib/iomgr/tcp_posix.cc", - "src/core/lib/iomgr/tcp_server.cc", - "src/core/lib/iomgr/tcp_server_custom.cc", - "src/core/lib/iomgr/tcp_server_posix.cc", - "src/core/lib/iomgr/tcp_server_utils_posix_common.cc", - "src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc", - "src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc", - "src/core/lib/iomgr/tcp_server_windows.cc", - "src/core/lib/iomgr/tcp_uv.cc", - "src/core/lib/iomgr/tcp_windows.cc", - "src/core/lib/iomgr/time_averaged_stats.cc", - "src/core/lib/iomgr/timer.cc", - "src/core/lib/iomgr/timer_custom.cc", - "src/core/lib/iomgr/timer_generic.cc", - "src/core/lib/iomgr/timer_heap.cc", - "src/core/lib/iomgr/timer_manager.cc", - "src/core/lib/iomgr/timer_uv.cc", - "src/core/lib/iomgr/udp_server.cc", - "src/core/lib/iomgr/unix_sockets_posix.cc", - "src/core/lib/iomgr/unix_sockets_posix_noop.cc", - "src/core/lib/iomgr/wakeup_fd_eventfd.cc", - "src/core/lib/iomgr/wakeup_fd_nospecial.cc", - "src/core/lib/iomgr/wakeup_fd_pipe.cc", - "src/core/lib/iomgr/wakeup_fd_posix.cc", - "src/core/lib/json/json.cc", - "src/core/lib/json/json_reader.cc", - "src/core/lib/json/json_string.cc", - "src/core/lib/json/json_writer.cc", - "src/core/lib/slice/b64.cc", - "src/core/lib/slice/percent_encoding.cc", - "src/core/lib/slice/slice.cc", - "src/core/lib/slice/slice_buffer.cc", - "src/core/lib/slice/slice_intern.cc", - "src/core/lib/slice/slice_string_helpers.cc", - "src/core/lib/surface/api_trace.cc", - "src/core/lib/surface/byte_buffer.cc", - "src/core/lib/surface/byte_buffer_reader.cc", - "src/core/lib/surface/call.cc", - "src/core/lib/surface/call_details.cc", - "src/core/lib/surface/call_log_batch.cc", - "src/core/lib/surface/channel.cc", - "src/core/lib/surface/channel_init.cc", - "src/core/lib/surface/channel_ping.cc", - "src/core/lib/surface/channel_stack_type.cc", - "src/core/lib/surface/completion_queue.cc", - "src/core/lib/surface/completion_queue_factory.cc", - "src/core/lib/surface/event_string.cc", - "src/core/lib/surface/lame_client.cc", - "src/core/lib/surface/metadata_array.cc", - "src/core/lib/surface/server.cc", - "src/core/lib/surface/validate_metadata.cc", - "src/core/lib/surface/version.cc", - "src/core/lib/transport/bdp_estimator.cc", - "src/core/lib/transport/byte_stream.cc", - "src/core/lib/transport/connectivity_state.cc", - "src/core/lib/transport/error_utils.cc", - "src/core/lib/transport/metadata.cc", - "src/core/lib/transport/metadata_batch.cc", - "src/core/lib/transport/pid_controller.cc", - "src/core/lib/transport/static_metadata.cc", - "src/core/lib/transport/status_conversion.cc", - "src/core/lib/transport/status_metadata.cc", - "src/core/lib/transport/timeout_encoding.cc", - "src/core/lib/transport/transport.cc", - "src/core/lib/transport/transport_op_string.cc", - "src/core/lib/uri/uri_parser.cc" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_codegen", - "grpc_trace_headers" - ], - "headers": [ - "include/grpc/byte_buffer.h", - "include/grpc/byte_buffer_reader.h", - "include/grpc/compression.h", - "include/grpc/fork.h", - "include/grpc/grpc.h", - "include/grpc/grpc_posix.h", - "include/grpc/grpc_security_constants.h", - "include/grpc/load_reporting.h", - "include/grpc/slice.h", - "include/grpc/slice_buffer.h", - "include/grpc/status.h", - "include/grpc/support/workaround_list.h", - "src/core/lib/avl/avl.h", - "src/core/lib/backoff/backoff.h", - "src/core/lib/channel/channel_args.h", - "src/core/lib/channel/channel_stack.h", - "src/core/lib/channel/channel_stack_builder.h", - "src/core/lib/channel/channel_trace.h", - "src/core/lib/channel/channelz.h", - "src/core/lib/channel/channelz_registry.h", - "src/core/lib/channel/connected_channel.h", - "src/core/lib/channel/context.h", - "src/core/lib/channel/handshaker.h", - "src/core/lib/channel/handshaker_factory.h", - "src/core/lib/channel/handshaker_registry.h", - "src/core/lib/channel/status_util.h", - "src/core/lib/compression/algorithm_metadata.h", - "src/core/lib/compression/compression_args.h", - "src/core/lib/compression/compression_internal.h", - "src/core/lib/compression/message_compress.h", - "src/core/lib/compression/stream_compression.h", - "src/core/lib/compression/stream_compression_gzip.h", - "src/core/lib/compression/stream_compression_identity.h", - "src/core/lib/debug/stats.h", - "src/core/lib/debug/stats_data.h", - "src/core/lib/gprpp/debug_location.h", - "src/core/lib/gprpp/inlined_vector.h", - "src/core/lib/gprpp/optional.h", - "src/core/lib/gprpp/orphanable.h", - "src/core/lib/gprpp/ref_counted.h", - "src/core/lib/gprpp/ref_counted_ptr.h", - "src/core/lib/gprpp/string_view.h", - "src/core/lib/http/format_request.h", - "src/core/lib/http/httpcli.h", - "src/core/lib/http/parser.h", - "src/core/lib/iomgr/block_annotate.h", - "src/core/lib/iomgr/buffer_list.h", - "src/core/lib/iomgr/call_combiner.h", - "src/core/lib/iomgr/cfstream_handle.h", - "src/core/lib/iomgr/closure.h", - "src/core/lib/iomgr/combiner.h", - "src/core/lib/iomgr/dynamic_annotations.h", - "src/core/lib/iomgr/endpoint.h", - "src/core/lib/iomgr/endpoint_cfstream.h", - "src/core/lib/iomgr/endpoint_pair.h", - "src/core/lib/iomgr/error.h", - "src/core/lib/iomgr/error_cfstream.h", - "src/core/lib/iomgr/error_internal.h", - "src/core/lib/iomgr/ev_epoll1_linux.h", - "src/core/lib/iomgr/ev_epollex_linux.h", - "src/core/lib/iomgr/ev_poll_posix.h", - "src/core/lib/iomgr/ev_posix.h", - "src/core/lib/iomgr/exec_ctx.h", - "src/core/lib/iomgr/executor.h", - "src/core/lib/iomgr/executor/mpmcqueue.h", - "src/core/lib/iomgr/executor/threadpool.h", - "src/core/lib/iomgr/gethostname.h", - "src/core/lib/iomgr/grpc_if_nametoindex.h", - "src/core/lib/iomgr/internal_errqueue.h", - "src/core/lib/iomgr/iocp_windows.h", - "src/core/lib/iomgr/iomgr.h", - "src/core/lib/iomgr/iomgr_custom.h", - "src/core/lib/iomgr/iomgr_internal.h", - "src/core/lib/iomgr/iomgr_posix.h", - "src/core/lib/iomgr/is_epollexclusive_available.h", - "src/core/lib/iomgr/load_file.h", - "src/core/lib/iomgr/lockfree_event.h", - "src/core/lib/iomgr/nameser.h", - "src/core/lib/iomgr/polling_entity.h", - "src/core/lib/iomgr/pollset.h", - "src/core/lib/iomgr/pollset_custom.h", - "src/core/lib/iomgr/pollset_set.h", - "src/core/lib/iomgr/pollset_set_custom.h", - "src/core/lib/iomgr/pollset_set_windows.h", - "src/core/lib/iomgr/pollset_windows.h", - "src/core/lib/iomgr/port.h", - "src/core/lib/iomgr/resolve_address.h", - "src/core/lib/iomgr/resolve_address_custom.h", - "src/core/lib/iomgr/resource_quota.h", - "src/core/lib/iomgr/sockaddr.h", - "src/core/lib/iomgr/sockaddr_custom.h", - "src/core/lib/iomgr/sockaddr_posix.h", - "src/core/lib/iomgr/sockaddr_utils.h", - "src/core/lib/iomgr/sockaddr_windows.h", - "src/core/lib/iomgr/socket_factory_posix.h", - "src/core/lib/iomgr/socket_mutator.h", - "src/core/lib/iomgr/socket_utils.h", - "src/core/lib/iomgr/socket_utils_posix.h", - "src/core/lib/iomgr/socket_windows.h", - "src/core/lib/iomgr/sys_epoll_wrapper.h", - "src/core/lib/iomgr/tcp_client.h", - "src/core/lib/iomgr/tcp_client_posix.h", - "src/core/lib/iomgr/tcp_custom.h", - "src/core/lib/iomgr/tcp_posix.h", - "src/core/lib/iomgr/tcp_server.h", - "src/core/lib/iomgr/tcp_server_utils_posix.h", - "src/core/lib/iomgr/tcp_windows.h", - "src/core/lib/iomgr/time_averaged_stats.h", - "src/core/lib/iomgr/timer.h", - "src/core/lib/iomgr/timer_custom.h", - "src/core/lib/iomgr/timer_heap.h", - "src/core/lib/iomgr/timer_manager.h", - "src/core/lib/iomgr/udp_server.h", - "src/core/lib/iomgr/unix_sockets_posix.h", - "src/core/lib/iomgr/wakeup_fd_pipe.h", - "src/core/lib/iomgr/wakeup_fd_posix.h", - "src/core/lib/json/json.h", - "src/core/lib/json/json_common.h", - "src/core/lib/json/json_reader.h", - "src/core/lib/json/json_writer.h", - "src/core/lib/slice/b64.h", - "src/core/lib/slice/percent_encoding.h", - "src/core/lib/slice/slice_hash_table.h", - "src/core/lib/slice/slice_internal.h", - "src/core/lib/slice/slice_string_helpers.h", - "src/core/lib/slice/slice_utils.h", - "src/core/lib/slice/slice_weak_hash_table.h", - "src/core/lib/surface/api_trace.h", - "src/core/lib/surface/call.h", - "src/core/lib/surface/call_test_only.h", - "src/core/lib/surface/channel.h", - "src/core/lib/surface/channel_init.h", - "src/core/lib/surface/channel_stack_type.h", - "src/core/lib/surface/completion_queue.h", - "src/core/lib/surface/completion_queue_factory.h", - "src/core/lib/surface/event_string.h", - "src/core/lib/surface/init.h", - "src/core/lib/surface/lame_client.h", - "src/core/lib/surface/server.h", - "src/core/lib/surface/validate_metadata.h", - "src/core/lib/transport/bdp_estimator.h", - "src/core/lib/transport/byte_stream.h", - "src/core/lib/transport/connectivity_state.h", - "src/core/lib/transport/error_utils.h", - "src/core/lib/transport/http2_errors.h", - "src/core/lib/transport/metadata.h", - "src/core/lib/transport/metadata_batch.h", - "src/core/lib/transport/pid_controller.h", - "src/core/lib/transport/static_metadata.h", - "src/core/lib/transport/status_conversion.h", - "src/core/lib/transport/status_metadata.h", - "src/core/lib/transport/timeout_encoding.h", - "src/core/lib/transport/transport.h", - "src/core/lib/transport/transport_impl.h", - "src/core/lib/uri/uri_parser.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_base_headers", - "src": [ - "include/grpc/byte_buffer.h", - "include/grpc/byte_buffer_reader.h", - "include/grpc/compression.h", - "include/grpc/fork.h", - "include/grpc/grpc.h", - "include/grpc/grpc_posix.h", - "include/grpc/grpc_security_constants.h", - "include/grpc/load_reporting.h", - "include/grpc/slice.h", - "include/grpc/slice_buffer.h", - "include/grpc/status.h", - "include/grpc/support/workaround_list.h", - "src/core/lib/avl/avl.h", - "src/core/lib/backoff/backoff.h", - "src/core/lib/channel/channel_args.h", - "src/core/lib/channel/channel_stack.h", - "src/core/lib/channel/channel_stack_builder.h", - "src/core/lib/channel/channel_trace.h", - "src/core/lib/channel/channelz.h", - "src/core/lib/channel/channelz_registry.h", - "src/core/lib/channel/connected_channel.h", - "src/core/lib/channel/context.h", - "src/core/lib/channel/handshaker.h", - "src/core/lib/channel/handshaker_factory.h", - "src/core/lib/channel/handshaker_registry.h", - "src/core/lib/channel/status_util.h", - "src/core/lib/compression/algorithm_metadata.h", - "src/core/lib/compression/compression_args.h", - "src/core/lib/compression/compression_internal.h", - "src/core/lib/compression/message_compress.h", - "src/core/lib/compression/stream_compression.h", - "src/core/lib/compression/stream_compression_gzip.h", - "src/core/lib/compression/stream_compression_identity.h", - "src/core/lib/debug/stats.h", - "src/core/lib/debug/stats_data.h", - "src/core/lib/gprpp/debug_location.h", - "src/core/lib/gprpp/inlined_vector.h", - "src/core/lib/gprpp/optional.h", - "src/core/lib/gprpp/orphanable.h", - "src/core/lib/gprpp/ref_counted.h", - "src/core/lib/gprpp/ref_counted_ptr.h", - "src/core/lib/gprpp/string_view.h", - "src/core/lib/http/format_request.h", - "src/core/lib/http/httpcli.h", - "src/core/lib/http/parser.h", - "src/core/lib/iomgr/block_annotate.h", - "src/core/lib/iomgr/buffer_list.h", - "src/core/lib/iomgr/call_combiner.h", - "src/core/lib/iomgr/cfstream_handle.h", - "src/core/lib/iomgr/closure.h", - "src/core/lib/iomgr/combiner.h", - "src/core/lib/iomgr/dynamic_annotations.h", - "src/core/lib/iomgr/endpoint.h", - "src/core/lib/iomgr/endpoint_cfstream.h", - "src/core/lib/iomgr/endpoint_pair.h", - "src/core/lib/iomgr/error.h", - "src/core/lib/iomgr/error_cfstream.h", - "src/core/lib/iomgr/error_internal.h", - "src/core/lib/iomgr/ev_epoll1_linux.h", - "src/core/lib/iomgr/ev_epollex_linux.h", - "src/core/lib/iomgr/ev_poll_posix.h", - "src/core/lib/iomgr/ev_posix.h", - "src/core/lib/iomgr/exec_ctx.h", - "src/core/lib/iomgr/executor.h", - "src/core/lib/iomgr/executor/mpmcqueue.h", - "src/core/lib/iomgr/executor/threadpool.h", - "src/core/lib/iomgr/gethostname.h", - "src/core/lib/iomgr/grpc_if_nametoindex.h", - "src/core/lib/iomgr/internal_errqueue.h", - "src/core/lib/iomgr/iocp_windows.h", - "src/core/lib/iomgr/iomgr.h", - "src/core/lib/iomgr/iomgr_custom.h", - "src/core/lib/iomgr/iomgr_internal.h", - "src/core/lib/iomgr/iomgr_posix.h", - "src/core/lib/iomgr/is_epollexclusive_available.h", - "src/core/lib/iomgr/load_file.h", - "src/core/lib/iomgr/lockfree_event.h", - "src/core/lib/iomgr/nameser.h", - "src/core/lib/iomgr/polling_entity.h", - "src/core/lib/iomgr/pollset.h", - "src/core/lib/iomgr/pollset_custom.h", - "src/core/lib/iomgr/pollset_set.h", - "src/core/lib/iomgr/pollset_set_custom.h", - "src/core/lib/iomgr/pollset_set_windows.h", - "src/core/lib/iomgr/pollset_windows.h", - "src/core/lib/iomgr/port.h", - "src/core/lib/iomgr/resolve_address.h", - "src/core/lib/iomgr/resolve_address_custom.h", - "src/core/lib/iomgr/resource_quota.h", - "src/core/lib/iomgr/sockaddr.h", - "src/core/lib/iomgr/sockaddr_custom.h", - "src/core/lib/iomgr/sockaddr_posix.h", - "src/core/lib/iomgr/sockaddr_utils.h", - "src/core/lib/iomgr/sockaddr_windows.h", - "src/core/lib/iomgr/socket_factory_posix.h", - "src/core/lib/iomgr/socket_mutator.h", - "src/core/lib/iomgr/socket_utils.h", - "src/core/lib/iomgr/socket_utils_posix.h", - "src/core/lib/iomgr/socket_windows.h", - "src/core/lib/iomgr/sys_epoll_wrapper.h", - "src/core/lib/iomgr/tcp_client.h", - "src/core/lib/iomgr/tcp_client_posix.h", - "src/core/lib/iomgr/tcp_custom.h", - "src/core/lib/iomgr/tcp_posix.h", - "src/core/lib/iomgr/tcp_server.h", - "src/core/lib/iomgr/tcp_server_utils_posix.h", - "src/core/lib/iomgr/tcp_windows.h", - "src/core/lib/iomgr/time_averaged_stats.h", - "src/core/lib/iomgr/timer.h", - "src/core/lib/iomgr/timer_custom.h", - "src/core/lib/iomgr/timer_heap.h", - "src/core/lib/iomgr/timer_manager.h", - "src/core/lib/iomgr/udp_server.h", - "src/core/lib/iomgr/unix_sockets_posix.h", - "src/core/lib/iomgr/wakeup_fd_pipe.h", - "src/core/lib/iomgr/wakeup_fd_posix.h", - "src/core/lib/json/json.h", - "src/core/lib/json/json_common.h", - "src/core/lib/json/json_reader.h", - "src/core/lib/json/json_writer.h", - "src/core/lib/slice/b64.h", - "src/core/lib/slice/percent_encoding.h", - "src/core/lib/slice/slice_hash_table.h", - "src/core/lib/slice/slice_internal.h", - "src/core/lib/slice/slice_string_helpers.h", - "src/core/lib/slice/slice_utils.h", - "src/core/lib/slice/slice_weak_hash_table.h", - "src/core/lib/surface/api_trace.h", - "src/core/lib/surface/call.h", - "src/core/lib/surface/call_test_only.h", - "src/core/lib/surface/channel.h", - "src/core/lib/surface/channel_init.h", - "src/core/lib/surface/channel_stack_type.h", - "src/core/lib/surface/completion_queue.h", - "src/core/lib/surface/completion_queue_factory.h", - "src/core/lib/surface/event_string.h", - "src/core/lib/surface/init.h", - "src/core/lib/surface/lame_client.h", - "src/core/lib/surface/server.h", - "src/core/lib/surface/validate_metadata.h", - "src/core/lib/transport/bdp_estimator.h", - "src/core/lib/transport/byte_stream.h", - "src/core/lib/transport/connectivity_state.h", - "src/core/lib/transport/error_utils.h", - "src/core/lib/transport/http2_errors.h", - "src/core/lib/transport/metadata.h", - "src/core/lib/transport/metadata_batch.h", - "src/core/lib/transport/pid_controller.h", - "src/core/lib/transport/static_metadata.h", - "src/core/lib/transport/status_conversion.h", - "src/core/lib/transport/status_metadata.h", - "src/core/lib/transport/timeout_encoding.h", - "src/core/lib/transport/transport.h", - "src/core/lib/transport/transport_impl.h", - "src/core/lib/uri/uri_parser.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base" - ], - "headers": [ - "src/core/ext/filters/http/client_authority_filter.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_client_authority_filter", - "src": [ - "src/core/ext/filters/http/client_authority_filter.cc", - "src/core/ext/filters/http/client_authority_filter.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_deadline_filter", - "grpc_health_upb" - ], - "headers": [ - "src/core/ext/filters/client_channel/backup_poller.h", - "src/core/ext/filters/client_channel/client_channel.h", - "src/core/ext/filters/client_channel/client_channel_channelz.h", - "src/core/ext/filters/client_channel/client_channel_factory.h", - "src/core/ext/filters/client_channel/connector.h", - "src/core/ext/filters/client_channel/global_subchannel_pool.h", - "src/core/ext/filters/client_channel/health/health_check_client.h", - "src/core/ext/filters/client_channel/http_connect_handshaker.h", - "src/core/ext/filters/client_channel/http_proxy.h", - "src/core/ext/filters/client_channel/lb_policy.h", - "src/core/ext/filters/client_channel/lb_policy_factory.h", - "src/core/ext/filters/client_channel/lb_policy_registry.h", - "src/core/ext/filters/client_channel/local_subchannel_pool.h", - "src/core/ext/filters/client_channel/parse_address.h", - "src/core/ext/filters/client_channel/proxy_mapper.h", - "src/core/ext/filters/client_channel/proxy_mapper_registry.h", - "src/core/ext/filters/client_channel/resolver.h", - "src/core/ext/filters/client_channel/resolver_factory.h", - "src/core/ext/filters/client_channel/resolver_registry.h", - "src/core/ext/filters/client_channel/resolver_result_parsing.h", - "src/core/ext/filters/client_channel/resolving_lb_policy.h", - "src/core/ext/filters/client_channel/retry_throttle.h", - "src/core/ext/filters/client_channel/server_address.h", - "src/core/ext/filters/client_channel/service_config.h", - "src/core/ext/filters/client_channel/subchannel.h", - "src/core/ext/filters/client_channel/subchannel_interface.h", - "src/core/ext/filters/client_channel/subchannel_pool_interface.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_client_channel", - "src": [ - "src/core/ext/filters/client_channel/backup_poller.cc", - "src/core/ext/filters/client_channel/backup_poller.h", - "src/core/ext/filters/client_channel/channel_connectivity.cc", - "src/core/ext/filters/client_channel/client_channel.cc", - "src/core/ext/filters/client_channel/client_channel.h", - "src/core/ext/filters/client_channel/client_channel_channelz.cc", - "src/core/ext/filters/client_channel/client_channel_channelz.h", - "src/core/ext/filters/client_channel/client_channel_factory.cc", - "src/core/ext/filters/client_channel/client_channel_factory.h", - "src/core/ext/filters/client_channel/client_channel_plugin.cc", - "src/core/ext/filters/client_channel/connector.cc", - "src/core/ext/filters/client_channel/connector.h", - "src/core/ext/filters/client_channel/global_subchannel_pool.cc", - "src/core/ext/filters/client_channel/global_subchannel_pool.h", - "src/core/ext/filters/client_channel/health/health_check_client.cc", - "src/core/ext/filters/client_channel/health/health_check_client.h", - "src/core/ext/filters/client_channel/http_connect_handshaker.cc", - "src/core/ext/filters/client_channel/http_connect_handshaker.h", - "src/core/ext/filters/client_channel/http_proxy.cc", - "src/core/ext/filters/client_channel/http_proxy.h", - "src/core/ext/filters/client_channel/lb_policy.cc", - "src/core/ext/filters/client_channel/lb_policy.h", - "src/core/ext/filters/client_channel/lb_policy_factory.h", - "src/core/ext/filters/client_channel/lb_policy_registry.cc", - "src/core/ext/filters/client_channel/lb_policy_registry.h", - "src/core/ext/filters/client_channel/local_subchannel_pool.cc", - "src/core/ext/filters/client_channel/local_subchannel_pool.h", - "src/core/ext/filters/client_channel/parse_address.cc", - "src/core/ext/filters/client_channel/parse_address.h", - "src/core/ext/filters/client_channel/proxy_mapper.cc", - "src/core/ext/filters/client_channel/proxy_mapper.h", - "src/core/ext/filters/client_channel/proxy_mapper_registry.cc", - "src/core/ext/filters/client_channel/proxy_mapper_registry.h", - "src/core/ext/filters/client_channel/resolver.cc", - "src/core/ext/filters/client_channel/resolver.h", - "src/core/ext/filters/client_channel/resolver_factory.h", - "src/core/ext/filters/client_channel/resolver_registry.cc", - "src/core/ext/filters/client_channel/resolver_registry.h", - "src/core/ext/filters/client_channel/resolver_result_parsing.cc", - "src/core/ext/filters/client_channel/resolver_result_parsing.h", - "src/core/ext/filters/client_channel/resolving_lb_policy.cc", - "src/core/ext/filters/client_channel/resolving_lb_policy.h", - "src/core/ext/filters/client_channel/retry_throttle.cc", - "src/core/ext/filters/client_channel/retry_throttle.h", - "src/core/ext/filters/client_channel/server_address.cc", - "src/core/ext/filters/client_channel/server_address.h", - "src/core/ext/filters/client_channel/service_config.cc", - "src/core/ext/filters/client_channel/service_config.h", - "src/core/ext/filters/client_channel/subchannel.cc", - "src/core/ext/filters/client_channel/subchannel.h", - "src/core/ext/filters/client_channel/subchannel_interface.h", - "src/core/ext/filters/client_channel/subchannel_pool_interface.cc", - "src/core/ext/filters/client_channel/subchannel_pool_interface.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base" - ], - "headers": [], - "is_filegroup": true, - "language": "c", - "name": "grpc_client_idle_filter", - "src": [ - "src/core/ext/filters/client_idle/client_idle_filter.cc" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr_codegen" - ], - "headers": [ - "include/grpc/impl/codegen/byte_buffer.h", - "include/grpc/impl/codegen/byte_buffer_reader.h", - "include/grpc/impl/codegen/compression_types.h", - "include/grpc/impl/codegen/connectivity_state.h", - "include/grpc/impl/codegen/grpc_types.h", - "include/grpc/impl/codegen/propagation_bits.h", - "include/grpc/impl/codegen/slice.h", - "include/grpc/impl/codegen/status.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_codegen", - "src": [ - "include/grpc/impl/codegen/byte_buffer.h", - "include/grpc/impl/codegen/byte_buffer_reader.h", - "include/grpc/impl/codegen/compression_types.h", - "include/grpc/impl/codegen/connectivity_state.h", - "include/grpc/impl/codegen/grpc_types.h", - "include/grpc/impl/codegen/propagation_bits.h", - "include/grpc/impl/codegen/slice.h", - "include/grpc/impl/codegen/status.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base" - ], - "headers": [ - "src/core/ext/filters/deadline/deadline_filter.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_deadline_filter", - "src": [ - "src/core/ext/filters/deadline/deadline_filter.cc", - "src/core/ext/filters/deadline/deadline_filter.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "upb" - ], - "headers": [ - "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_health_upb", - "src": [ - "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c", - "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base" - ], - "headers": [ - "src/core/ext/filters/http/client/http_client_filter.h", - "src/core/ext/filters/http/message_compress/message_compress_filter.h", - "src/core/ext/filters/http/server/http_server_filter.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_http_filters", - "src": [ - "src/core/ext/filters/http/client/http_client_filter.cc", - "src/core/ext/filters/http/client/http_client_filter.h", - "src/core/ext/filters/http/http_filters_plugin.cc", - "src/core/ext/filters/http/message_compress/message_compress_filter.cc", - "src/core/ext/filters/http/message_compress/message_compress_filter.h", - "src/core/ext/filters/http/server/http_server_filter.cc", - "src/core/ext/filters/http/server/http_server_filter.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_client_channel", - "grpc_lb_upb", - "grpc_resolver_fake", - "upb" - ], - "headers": [ - "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_lb_policy_grpclb", - "src": [ - "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc", - "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc", - "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_client_channel", - "grpc_lb_upb", - "grpc_resolver_fake", - "grpc_secure", - "upb" - ], - "headers": [ - "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_lb_policy_grpclb_secure", - "src": [ - "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc", - "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc", - "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_client_channel", - "grpc_lb_subchannel_list" - ], - "headers": [], - "is_filegroup": true, - "language": "c", - "name": "grpc_lb_policy_pick_first", - "src": [ - "src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_client_channel", - "grpc_lb_subchannel_list" - ], - "headers": [], - "is_filegroup": true, - "language": "c", - "name": "grpc_lb_policy_round_robin", - "src": [ - "src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "envoy_ads_upb", - "gpr", - "grpc_base", - "grpc_client_channel", - "grpc_resolver_fake" - ], - "headers": [ - "src/core/ext/filters/client_channel/lb_policy/xds/xds.h", - "src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h", - "src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h", - "src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_lb_policy_xds", - "src": [ - "src/core/ext/filters/client_channel/lb_policy/xds/xds.cc", - "src/core/ext/filters/client_channel/lb_policy/xds/xds.h", - "src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc", - "src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h", - "src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc", - "src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h", - "src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc", - "src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "envoy_ads_upb", - "gpr", - "grpc_base", - "grpc_client_channel", - "grpc_resolver_fake", - "grpc_secure" - ], - "headers": [ - "src/core/ext/filters/client_channel/lb_policy/xds/xds.h", - "src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h", - "src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h", - "src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_lb_policy_xds_secure", - "src": [ - "src/core/ext/filters/client_channel/lb_policy/xds/xds.cc", - "src/core/ext/filters/client_channel/lb_policy/xds/xds.h", - "src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h", - "src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc", - "src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc", - "src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h", - "src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc", - "src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_client_channel" - ], - "headers": [ - "src/core/ext/filters/client_channel/lb_policy/subchannel_list.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_lb_subchannel_list", - "src": [ - "src/core/ext/filters/client_channel/lb_policy/subchannel_list.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "google_api_upb", - "upb" - ], - "headers": [ - "src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_lb_upb", - "src": [ - "src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c", - "src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base" - ], - "headers": [ - "src/core/ext/filters/max_age/max_age_filter.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_max_age_filter", - "src": [ - "src/core/ext/filters/max_age/max_age_filter.cc", - "src/core/ext/filters/max_age/max_age_filter.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base" - ], - "headers": [ - "src/core/ext/filters/message_size/message_size_filter.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_message_size_filter", - "src": [ - "src/core/ext/filters/message_size/message_size_filter.cc", - "src/core/ext/filters/message_size/message_size_filter.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_client_channel", - "grpc_resolver_dns_selection" - ], - "headers": [ - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_resolver_dns_ares", - "src": [ - "src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc", - "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_client_channel", - "grpc_resolver_dns_selection" - ], - "headers": [], - "is_filegroup": true, - "language": "c", - "name": "grpc_resolver_dns_native", - "src": [ - "src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base" - ], - "headers": [ - "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_resolver_dns_selection", - "src": [ - "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc", - "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_client_channel" - ], - "headers": [ - "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_resolver_fake", - "src": [ - "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc", - "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_client_channel" - ], - "headers": [], - "is_filegroup": true, - "language": "c", - "name": "grpc_resolver_sockaddr", - "src": [ - "src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "alts_tsi", - "gpr", - "grpc_base", - "grpc_shadow_boringssl", - "grpc_transport_chttp2_alpn", - "tsi" - ], - "headers": [ - "include/grpc/grpc_security.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h", - "src/core/ext/filters/client_channel/lb_policy/xds/xds.h", - "src/core/lib/security/context/security_context.h", - "src/core/lib/security/credentials/alts/alts_credentials.h", - "src/core/lib/security/credentials/composite/composite_credentials.h", - "src/core/lib/security/credentials/credentials.h", - "src/core/lib/security/credentials/fake/fake_credentials.h", - "src/core/lib/security/credentials/google_default/google_default_credentials.h", - "src/core/lib/security/credentials/iam/iam_credentials.h", - "src/core/lib/security/credentials/jwt/json_token.h", - "src/core/lib/security/credentials/jwt/jwt_credentials.h", - "src/core/lib/security/credentials/jwt/jwt_verifier.h", - "src/core/lib/security/credentials/local/local_credentials.h", - "src/core/lib/security/credentials/oauth2/oauth2_credentials.h", - "src/core/lib/security/credentials/plugin/plugin_credentials.h", - "src/core/lib/security/credentials/ssl/ssl_credentials.h", - "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h", - "src/core/lib/security/credentials/tls/spiffe_credentials.h", - "src/core/lib/security/security_connector/alts/alts_security_connector.h", - "src/core/lib/security/security_connector/fake/fake_security_connector.h", - "src/core/lib/security/security_connector/load_system_roots.h", - "src/core/lib/security/security_connector/load_system_roots_linux.h", - "src/core/lib/security/security_connector/local/local_security_connector.h", - "src/core/lib/security/security_connector/security_connector.h", - "src/core/lib/security/security_connector/ssl/ssl_security_connector.h", - "src/core/lib/security/security_connector/ssl_utils.h", - "src/core/lib/security/security_connector/tls/spiffe_security_connector.h", - "src/core/lib/security/transport/auth_filters.h", - "src/core/lib/security/transport/secure_endpoint.h", - "src/core/lib/security/transport/security_handshaker.h", - "src/core/lib/security/transport/target_authority_table.h", - "src/core/lib/security/transport/tsi_error.h", - "src/core/lib/security/util/json_util.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_secure", - "src": [ - "include/grpc/grpc_security.h", - "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h", - "src/core/ext/filters/client_channel/lb_policy/xds/xds.h", - "src/core/lib/http/httpcli_security_connector.cc", - "src/core/lib/security/context/security_context.cc", - "src/core/lib/security/context/security_context.h", - "src/core/lib/security/credentials/alts/alts_credentials.cc", - "src/core/lib/security/credentials/alts/alts_credentials.h", - "src/core/lib/security/credentials/composite/composite_credentials.cc", - "src/core/lib/security/credentials/composite/composite_credentials.h", - "src/core/lib/security/credentials/credentials.cc", - "src/core/lib/security/credentials/credentials.h", - "src/core/lib/security/credentials/credentials_metadata.cc", - "src/core/lib/security/credentials/fake/fake_credentials.cc", - "src/core/lib/security/credentials/fake/fake_credentials.h", - "src/core/lib/security/credentials/google_default/credentials_generic.cc", - "src/core/lib/security/credentials/google_default/google_default_credentials.cc", - "src/core/lib/security/credentials/google_default/google_default_credentials.h", - "src/core/lib/security/credentials/iam/iam_credentials.cc", - "src/core/lib/security/credentials/iam/iam_credentials.h", - "src/core/lib/security/credentials/jwt/json_token.cc", - "src/core/lib/security/credentials/jwt/json_token.h", - "src/core/lib/security/credentials/jwt/jwt_credentials.cc", - "src/core/lib/security/credentials/jwt/jwt_credentials.h", - "src/core/lib/security/credentials/jwt/jwt_verifier.cc", - "src/core/lib/security/credentials/jwt/jwt_verifier.h", - "src/core/lib/security/credentials/local/local_credentials.cc", - "src/core/lib/security/credentials/local/local_credentials.h", - "src/core/lib/security/credentials/oauth2/oauth2_credentials.cc", - "src/core/lib/security/credentials/oauth2/oauth2_credentials.h", - "src/core/lib/security/credentials/plugin/plugin_credentials.cc", - "src/core/lib/security/credentials/plugin/plugin_credentials.h", - "src/core/lib/security/credentials/ssl/ssl_credentials.cc", - "src/core/lib/security/credentials/ssl/ssl_credentials.h", - "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc", - "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h", - "src/core/lib/security/credentials/tls/spiffe_credentials.cc", - "src/core/lib/security/credentials/tls/spiffe_credentials.h", - "src/core/lib/security/security_connector/alts/alts_security_connector.cc", - "src/core/lib/security/security_connector/alts/alts_security_connector.h", - "src/core/lib/security/security_connector/fake/fake_security_connector.cc", - "src/core/lib/security/security_connector/fake/fake_security_connector.h", - "src/core/lib/security/security_connector/load_system_roots.h", - "src/core/lib/security/security_connector/load_system_roots_fallback.cc", - "src/core/lib/security/security_connector/load_system_roots_linux.cc", - "src/core/lib/security/security_connector/load_system_roots_linux.h", - "src/core/lib/security/security_connector/local/local_security_connector.cc", - "src/core/lib/security/security_connector/local/local_security_connector.h", - "src/core/lib/security/security_connector/security_connector.cc", - "src/core/lib/security/security_connector/security_connector.h", - "src/core/lib/security/security_connector/ssl/ssl_security_connector.cc", - "src/core/lib/security/security_connector/ssl/ssl_security_connector.h", - "src/core/lib/security/security_connector/ssl_utils.cc", - "src/core/lib/security/security_connector/ssl_utils.h", - "src/core/lib/security/security_connector/tls/spiffe_security_connector.cc", - "src/core/lib/security/security_connector/tls/spiffe_security_connector.h", - "src/core/lib/security/transport/auth_filters.h", - "src/core/lib/security/transport/client_auth_filter.cc", - "src/core/lib/security/transport/secure_endpoint.cc", - "src/core/lib/security/transport/secure_endpoint.h", - "src/core/lib/security/transport/security_handshaker.cc", - "src/core/lib/security/transport/security_handshaker.h", - "src/core/lib/security/transport/server_auth_filter.cc", - "src/core/lib/security/transport/target_authority_table.cc", - "src/core/lib/security/transport/target_authority_table.h", - "src/core/lib/security/transport/tsi_error.cc", - "src/core/lib/security/transport/tsi_error.h", - "src/core/lib/security/util/json_util.cc", - "src/core/lib/security/util/json_util.h", - "src/core/lib/surface/init_secure.cc" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base" - ], - "headers": [ - "src/core/ext/filters/workarounds/workaround_utils.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_server_backward_compatibility", - "src": [ - "src/core/ext/filters/workarounds/workaround_utils.cc", - "src/core/ext/filters/workarounds/workaround_utils.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [], - "headers": [ - "src/core/tsi/grpc_shadow_boringssl.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_shadow_boringssl", - "src": [ - "src/core/tsi/grpc_shadow_boringssl.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "cmdline", - "gpr", - "grpc_base", - "grpc_client_channel", - "grpc_transport_chttp2" - ], - "headers": [ - "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h", - "test/core/end2end/cq_verifier.h", - "test/core/end2end/fixtures/http_proxy_fixture.h", - "test/core/end2end/fixtures/local_util.h", - "test/core/end2end/fixtures/proxy.h", - "test/core/iomgr/endpoint_tests.h", - "test/core/util/debugger_macros.h", - "test/core/util/fuzzer_util.h", - "test/core/util/grpc_profiler.h", - "test/core/util/histogram.h", - "test/core/util/memory_counters.h", - "test/core/util/mock_endpoint.h", - "test/core/util/parse_hexstring.h", - "test/core/util/passthru_endpoint.h", - "test/core/util/port.h", - "test/core/util/port_server_client.h", - "test/core/util/slice_splitter.h", - "test/core/util/subprocess.h", - "test/core/util/test_config.h", - "test/core/util/test_lb_policies.h", - "test/core/util/tracer_util.h", - "test/core/util/trickle_endpoint.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_test_util_base", - "src": [ - "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc", - "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h", - "test/core/end2end/cq_verifier.cc", - "test/core/end2end/cq_verifier.h", - "test/core/end2end/fixtures/http_proxy_fixture.cc", - "test/core/end2end/fixtures/http_proxy_fixture.h", - "test/core/end2end/fixtures/local_util.cc", - "test/core/end2end/fixtures/local_util.h", - "test/core/end2end/fixtures/proxy.cc", - "test/core/end2end/fixtures/proxy.h", - "test/core/iomgr/endpoint_tests.cc", - "test/core/iomgr/endpoint_tests.h", - "test/core/util/debugger_macros.cc", - "test/core/util/debugger_macros.h", - "test/core/util/fuzzer_util.cc", - "test/core/util/fuzzer_util.h", - "test/core/util/grpc_profiler.cc", - "test/core/util/grpc_profiler.h", - "test/core/util/histogram.cc", - "test/core/util/histogram.h", - "test/core/util/memory_counters.cc", - "test/core/util/memory_counters.h", - "test/core/util/mock_endpoint.cc", - "test/core/util/mock_endpoint.h", - "test/core/util/parse_hexstring.cc", - "test/core/util/parse_hexstring.h", - "test/core/util/passthru_endpoint.cc", - "test/core/util/passthru_endpoint.h", - "test/core/util/port.cc", - "test/core/util/port.h", - "test/core/util/port_isolated_runtime_environment.cc", - "test/core/util/port_server_client.cc", - "test/core/util/port_server_client.h", - "test/core/util/slice_splitter.cc", - "test/core/util/slice_splitter.h", - "test/core/util/subprocess.h", - "test/core/util/subprocess_posix.cc", - "test/core/util/subprocess_windows.cc", - "test/core/util/test_config.cc", - "test/core/util/test_config.h", - "test/core/util/test_lb_policies.cc", - "test/core/util/test_lb_policies.h", - "test/core/util/tracer_util.cc", - "test/core/util/tracer_util.h", - "test/core/util/trickle_endpoint.cc", - "test/core/util/trickle_endpoint.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base_headers", - "grpc_trace_headers" - ], - "headers": [], - "is_filegroup": true, - "language": "c", - "name": "grpc_trace", - "src": [ - "src/core/lib/debug/trace.cc" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr" - ], - "headers": [ - "src/core/lib/debug/trace.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_trace_headers", - "src": [ - "src/core/lib/debug/trace.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_http_filters", - "grpc_transport_chttp2_alpn" - ], - "headers": [ - "src/core/ext/transport/chttp2/transport/bin_decoder.h", - "src/core/ext/transport/chttp2/transport/bin_encoder.h", - "src/core/ext/transport/chttp2/transport/chttp2_transport.h", - "src/core/ext/transport/chttp2/transport/context_list.h", - "src/core/ext/transport/chttp2/transport/flow_control.h", - "src/core/ext/transport/chttp2/transport/frame.h", - "src/core/ext/transport/chttp2/transport/frame_data.h", - "src/core/ext/transport/chttp2/transport/frame_goaway.h", - "src/core/ext/transport/chttp2/transport/frame_ping.h", - "src/core/ext/transport/chttp2/transport/frame_rst_stream.h", - "src/core/ext/transport/chttp2/transport/frame_settings.h", - "src/core/ext/transport/chttp2/transport/frame_window_update.h", - "src/core/ext/transport/chttp2/transport/hpack_encoder.h", - "src/core/ext/transport/chttp2/transport/hpack_parser.h", - "src/core/ext/transport/chttp2/transport/hpack_table.h", - "src/core/ext/transport/chttp2/transport/http2_settings.h", - "src/core/ext/transport/chttp2/transport/huffsyms.h", - "src/core/ext/transport/chttp2/transport/incoming_metadata.h", - "src/core/ext/transport/chttp2/transport/internal.h", - "src/core/ext/transport/chttp2/transport/stream_map.h", - "src/core/ext/transport/chttp2/transport/varint.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_transport_chttp2", - "src": [ - "src/core/ext/transport/chttp2/transport/bin_decoder.cc", - "src/core/ext/transport/chttp2/transport/bin_decoder.h", - "src/core/ext/transport/chttp2/transport/bin_encoder.cc", - "src/core/ext/transport/chttp2/transport/bin_encoder.h", - "src/core/ext/transport/chttp2/transport/chttp2_plugin.cc", - "src/core/ext/transport/chttp2/transport/chttp2_transport.cc", - "src/core/ext/transport/chttp2/transport/chttp2_transport.h", - "src/core/ext/transport/chttp2/transport/context_list.cc", - "src/core/ext/transport/chttp2/transport/context_list.h", - "src/core/ext/transport/chttp2/transport/flow_control.cc", - "src/core/ext/transport/chttp2/transport/flow_control.h", - "src/core/ext/transport/chttp2/transport/frame.h", - "src/core/ext/transport/chttp2/transport/frame_data.cc", - "src/core/ext/transport/chttp2/transport/frame_data.h", - "src/core/ext/transport/chttp2/transport/frame_goaway.cc", - "src/core/ext/transport/chttp2/transport/frame_goaway.h", - "src/core/ext/transport/chttp2/transport/frame_ping.cc", - "src/core/ext/transport/chttp2/transport/frame_ping.h", - "src/core/ext/transport/chttp2/transport/frame_rst_stream.cc", - "src/core/ext/transport/chttp2/transport/frame_rst_stream.h", - "src/core/ext/transport/chttp2/transport/frame_settings.cc", - "src/core/ext/transport/chttp2/transport/frame_settings.h", - "src/core/ext/transport/chttp2/transport/frame_window_update.cc", - "src/core/ext/transport/chttp2/transport/frame_window_update.h", - "src/core/ext/transport/chttp2/transport/hpack_encoder.cc", - "src/core/ext/transport/chttp2/transport/hpack_encoder.h", - "src/core/ext/transport/chttp2/transport/hpack_parser.cc", - "src/core/ext/transport/chttp2/transport/hpack_parser.h", - "src/core/ext/transport/chttp2/transport/hpack_table.cc", - "src/core/ext/transport/chttp2/transport/hpack_table.h", - "src/core/ext/transport/chttp2/transport/http2_settings.cc", - "src/core/ext/transport/chttp2/transport/http2_settings.h", - "src/core/ext/transport/chttp2/transport/huffsyms.cc", - "src/core/ext/transport/chttp2/transport/huffsyms.h", - "src/core/ext/transport/chttp2/transport/incoming_metadata.cc", - "src/core/ext/transport/chttp2/transport/incoming_metadata.h", - "src/core/ext/transport/chttp2/transport/internal.h", - "src/core/ext/transport/chttp2/transport/parsing.cc", - "src/core/ext/transport/chttp2/transport/stream_lists.cc", - "src/core/ext/transport/chttp2/transport/stream_map.cc", - "src/core/ext/transport/chttp2/transport/stream_map.h", - "src/core/ext/transport/chttp2/transport/varint.cc", - "src/core/ext/transport/chttp2/transport/varint.h", - "src/core/ext/transport/chttp2/transport/writing.cc" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr" - ], - "headers": [ - "src/core/ext/transport/chttp2/alpn/alpn.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_transport_chttp2_alpn", - "src": [ - "src/core/ext/transport/chttp2/alpn/alpn.cc", - "src/core/ext/transport/chttp2/alpn/alpn.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_client_channel", - "grpc_transport_chttp2" - ], - "headers": [ - "src/core/ext/transport/chttp2/client/authority.h", - "src/core/ext/transport/chttp2/client/chttp2_connector.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_transport_chttp2_client_connector", - "src": [ - "src/core/ext/transport/chttp2/client/authority.cc", - "src/core/ext/transport/chttp2/client/authority.h", - "src/core/ext/transport/chttp2/client/chttp2_connector.cc", - "src/core/ext/transport/chttp2/client/chttp2_connector.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_client_channel", - "grpc_transport_chttp2", - "grpc_transport_chttp2_client_connector" - ], - "headers": [], - "is_filegroup": true, - "language": "c", - "name": "grpc_transport_chttp2_client_insecure", - "src": [ - "src/core/ext/transport/chttp2/client/insecure/channel_create.cc", - "src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_client_channel", - "grpc_secure", - "grpc_transport_chttp2", - "grpc_transport_chttp2_client_connector" - ], - "headers": [], - "is_filegroup": true, - "language": "c", - "name": "grpc_transport_chttp2_client_secure", - "src": [ - "src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_transport_chttp2" - ], - "headers": [ - "src/core/ext/transport/chttp2/server/chttp2_server.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_transport_chttp2_server", - "src": [ - "src/core/ext/transport/chttp2/server/chttp2_server.cc", - "src/core/ext/transport/chttp2/server/chttp2_server.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_transport_chttp2", - "grpc_transport_chttp2_server" - ], - "headers": [], - "is_filegroup": true, - "language": "c", - "name": "grpc_transport_chttp2_server_insecure", - "src": [ - "src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc", - "src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_secure", - "grpc_transport_chttp2", - "grpc_transport_chttp2_server" - ], - "headers": [], - "is_filegroup": true, - "language": "c", - "name": "grpc_transport_chttp2_server_secure", - "src": [ - "src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "grpc_base", - "grpc_http_filters", - "grpc_transport_chttp2" - ], - "headers": [ - "include/grpc/grpc_cronet.h", - "include/grpc/grpc_security.h", - "include/grpc/grpc_security_constants.h", - "src/core/ext/transport/cronet/client/secure/cronet_channel_create.h", - "src/core/ext/transport/cronet/transport/cronet_transport.h", - "third_party/objective_c/Cronet/bidirectional_stream_c.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_transport_cronet_client_secure", - "src": [ - "include/grpc/grpc_cronet.h", - "include/grpc/grpc_security.h", - "include/grpc/grpc_security_constants.h", - "src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc", - "src/core/ext/transport/cronet/client/secure/cronet_channel_create.h", - "src/core/ext/transport/cronet/transport/cronet_api_dummy.cc", - "src/core/ext/transport/cronet/transport/cronet_transport.cc", - "src/core/ext/transport/cronet/transport/cronet_transport.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_transport_inproc_headers" - ], - "headers": [], - "is_filegroup": true, - "language": "c", - "name": "grpc_transport_inproc", - "src": [ - "src/core/ext/transport/inproc/inproc_plugin.cc", - "src/core/ext/transport/inproc/inproc_transport.cc" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base_headers" - ], - "headers": [ - "src/core/ext/transport/inproc/inproc_transport.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_transport_inproc_headers", - "src": [ - "src/core/ext/transport/inproc/inproc_transport.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_server_backward_compatibility" - ], - "headers": [ - "src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_workaround_cronet_compression_filter", - "src": [ - "src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc", - "src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "nanopb_headers" - ], - "headers": [], - "is_filegroup": true, - "language": "c", - "name": "nanopb", - "src": [], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [], - "headers": [ - "third_party/nanopb/pb.h", - "third_party/nanopb/pb_common.h", - "third_party/nanopb/pb_decode.h", - "third_party/nanopb/pb_encode.h" - ], - "is_filegroup": true, - "language": "c", - "name": "nanopb_headers", - "src": [], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "google_api_upb" - ], - "headers": [ - "src/core/ext/upb-generated/gogoproto/gogo.upb.h", - "src/core/ext/upb-generated/validate/validate.upb.h" - ], - "is_filegroup": true, - "language": "c", - "name": "proto_gen_validate_upb", - "src": [ - "src/core/ext/upb-generated/gogoproto/gogo.upb.c", - "src/core/ext/upb-generated/gogoproto/gogo.upb.h", - "src/core/ext/upb-generated/validate/validate.upb.c", - "src/core/ext/upb-generated/validate/validate.upb.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "grpc" - ], - "headers": [ - "test/core/tsi/transport_security_test_lib.h" - ], - "is_filegroup": true, - "language": "c", - "name": "transport_security_test_lib", - "src": [ - "test/core/tsi/transport_security_test_lib.cc", - "test/core/tsi/transport_security_test_lib.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_shadow_boringssl", - "grpc_trace", - "tsi_interface" - ], - "headers": [ - "src/core/tsi/fake_transport_security.h", - "src/core/tsi/local_transport_security.h", - "src/core/tsi/ssl/session_cache/ssl_session.h", - "src/core/tsi/ssl/session_cache/ssl_session_cache.h", - "src/core/tsi/ssl_transport_security.h", - "src/core/tsi/ssl_types.h", - "src/core/tsi/transport_security_grpc.h" - ], - "is_filegroup": true, - "language": "c", - "name": "tsi", - "src": [ - "src/core/tsi/fake_transport_security.cc", - "src/core/tsi/fake_transport_security.h", - "src/core/tsi/local_transport_security.cc", - "src/core/tsi/local_transport_security.h", - "src/core/tsi/ssl/session_cache/ssl_session.h", - "src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc", - "src/core/tsi/ssl/session_cache/ssl_session_cache.cc", - "src/core/tsi/ssl/session_cache/ssl_session_cache.h", - "src/core/tsi/ssl/session_cache/ssl_session_openssl.cc", - "src/core/tsi/ssl_transport_security.cc", - "src/core/tsi/ssl_transport_security.h", - "src/core/tsi/ssl_types.h", - "src/core/tsi/transport_security_grpc.cc", - "src/core/tsi/transport_security_grpc.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "grpc_trace" - ], - "headers": [ - "src/core/tsi/transport_security.h", - "src/core/tsi/transport_security_interface.h" - ], - "is_filegroup": true, - "language": "c", - "name": "tsi_interface", - "src": [ - "src/core/tsi/transport_security.cc", - "src/core/tsi/transport_security.h", - "src/core/tsi/transport_security_interface.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "grpc++_internal_hdrs_only", - "grpc_codegen" - ], - "headers": [ - "include/grpc++/impl/codegen/async_stream.h", - "include/grpc++/impl/codegen/async_unary_call.h", - "include/grpc++/impl/codegen/byte_buffer.h", - "include/grpc++/impl/codegen/call.h", - "include/grpc++/impl/codegen/call_hook.h", - "include/grpc++/impl/codegen/channel_interface.h", - "include/grpc++/impl/codegen/client_context.h", - "include/grpc++/impl/codegen/client_unary_call.h", - "include/grpc++/impl/codegen/completion_queue.h", - "include/grpc++/impl/codegen/completion_queue_tag.h", - "include/grpc++/impl/codegen/config.h", - "include/grpc++/impl/codegen/core_codegen_interface.h", - "include/grpc++/impl/codegen/create_auth_context.h", - "include/grpc++/impl/codegen/grpc_library.h", - "include/grpc++/impl/codegen/metadata_map.h", - "include/grpc++/impl/codegen/method_handler_impl.h", - "include/grpc++/impl/codegen/rpc_method.h", - "include/grpc++/impl/codegen/rpc_service_method.h", - "include/grpc++/impl/codegen/security/auth_context.h", - "include/grpc++/impl/codegen/serialization_traits.h", - "include/grpc++/impl/codegen/server_context.h", - "include/grpc++/impl/codegen/server_interface.h", - "include/grpc++/impl/codegen/service_type.h", - "include/grpc++/impl/codegen/slice.h", - "include/grpc++/impl/codegen/status.h", - "include/grpc++/impl/codegen/status_code_enum.h", - "include/grpc++/impl/codegen/string_ref.h", - "include/grpc++/impl/codegen/stub_options.h", - "include/grpc++/impl/codegen/sync_stream.h", - "include/grpc++/impl/codegen/time.h", - "include/grpcpp/impl/codegen/async_generic_service.h", - "include/grpcpp/impl/codegen/async_stream.h", - "include/grpcpp/impl/codegen/async_stream_impl.h", - "include/grpcpp/impl/codegen/async_unary_call.h", - "include/grpcpp/impl/codegen/async_unary_call_impl.h", - "include/grpcpp/impl/codegen/byte_buffer.h", - "include/grpcpp/impl/codegen/call.h", - "include/grpcpp/impl/codegen/call_hook.h", - "include/grpcpp/impl/codegen/call_op_set.h", - "include/grpcpp/impl/codegen/call_op_set_interface.h", - "include/grpcpp/impl/codegen/callback_common.h", - "include/grpcpp/impl/codegen/channel_interface.h", - "include/grpcpp/impl/codegen/client_callback.h", - "include/grpcpp/impl/codegen/client_callback_impl.h", - "include/grpcpp/impl/codegen/client_context.h", - "include/grpcpp/impl/codegen/client_context_impl.h", - "include/grpcpp/impl/codegen/client_interceptor.h", - "include/grpcpp/impl/codegen/client_unary_call.h", - "include/grpcpp/impl/codegen/completion_queue.h", - "include/grpcpp/impl/codegen/completion_queue_impl.h", - "include/grpcpp/impl/codegen/completion_queue_tag.h", - "include/grpcpp/impl/codegen/config.h", - "include/grpcpp/impl/codegen/core_codegen_interface.h", - "include/grpcpp/impl/codegen/create_auth_context.h", - "include/grpcpp/impl/codegen/delegating_channel.h", - "include/grpcpp/impl/codegen/grpc_library.h", - "include/grpcpp/impl/codegen/intercepted_channel.h", - "include/grpcpp/impl/codegen/interceptor.h", - "include/grpcpp/impl/codegen/interceptor_common.h", - "include/grpcpp/impl/codegen/message_allocator.h", - "include/grpcpp/impl/codegen/metadata_map.h", - "include/grpcpp/impl/codegen/method_handler_impl.h", - "include/grpcpp/impl/codegen/rpc_method.h", - "include/grpcpp/impl/codegen/rpc_service_method.h", - "include/grpcpp/impl/codegen/security/auth_context.h", - "include/grpcpp/impl/codegen/serialization_traits.h", - "include/grpcpp/impl/codegen/server_callback.h", - "include/grpcpp/impl/codegen/server_callback_impl.h", - "include/grpcpp/impl/codegen/server_context.h", - "include/grpcpp/impl/codegen/server_context_impl.h", - "include/grpcpp/impl/codegen/server_interceptor.h", - "include/grpcpp/impl/codegen/server_interface.h", - "include/grpcpp/impl/codegen/service_type.h", - "include/grpcpp/impl/codegen/slice.h", - "include/grpcpp/impl/codegen/status.h", - "include/grpcpp/impl/codegen/status_code_enum.h", - "include/grpcpp/impl/codegen/string_ref.h", - "include/grpcpp/impl/codegen/stub_options.h", - "include/grpcpp/impl/codegen/sync_stream.h", - "include/grpcpp/impl/codegen/sync_stream_impl.h", - "include/grpcpp/impl/codegen/time.h" - ], - "is_filegroup": true, - "language": "c++", - "name": "grpc++_codegen_base", - "src": [ - "include/grpc++/impl/codegen/async_stream.h", - "include/grpc++/impl/codegen/async_unary_call.h", - "include/grpc++/impl/codegen/byte_buffer.h", - "include/grpc++/impl/codegen/call.h", - "include/grpc++/impl/codegen/call_hook.h", - "include/grpc++/impl/codegen/channel_interface.h", - "include/grpc++/impl/codegen/client_context.h", - "include/grpc++/impl/codegen/client_unary_call.h", - "include/grpc++/impl/codegen/completion_queue.h", - "include/grpc++/impl/codegen/completion_queue_tag.h", - "include/grpc++/impl/codegen/config.h", - "include/grpc++/impl/codegen/core_codegen_interface.h", - "include/grpc++/impl/codegen/create_auth_context.h", - "include/grpc++/impl/codegen/grpc_library.h", - "include/grpc++/impl/codegen/metadata_map.h", - "include/grpc++/impl/codegen/method_handler_impl.h", - "include/grpc++/impl/codegen/rpc_method.h", - "include/grpc++/impl/codegen/rpc_service_method.h", - "include/grpc++/impl/codegen/security/auth_context.h", - "include/grpc++/impl/codegen/serialization_traits.h", - "include/grpc++/impl/codegen/server_context.h", - "include/grpc++/impl/codegen/server_interface.h", - "include/grpc++/impl/codegen/service_type.h", - "include/grpc++/impl/codegen/slice.h", - "include/grpc++/impl/codegen/status.h", - "include/grpc++/impl/codegen/status_code_enum.h", - "include/grpc++/impl/codegen/string_ref.h", - "include/grpc++/impl/codegen/stub_options.h", - "include/grpc++/impl/codegen/sync_stream.h", - "include/grpc++/impl/codegen/time.h", - "include/grpcpp/impl/codegen/async_generic_service.h", - "include/grpcpp/impl/codegen/async_stream.h", - "include/grpcpp/impl/codegen/async_stream_impl.h", - "include/grpcpp/impl/codegen/async_unary_call.h", - "include/grpcpp/impl/codegen/async_unary_call_impl.h", - "include/grpcpp/impl/codegen/byte_buffer.h", - "include/grpcpp/impl/codegen/call.h", - "include/grpcpp/impl/codegen/call_hook.h", - "include/grpcpp/impl/codegen/call_op_set.h", - "include/grpcpp/impl/codegen/call_op_set_interface.h", - "include/grpcpp/impl/codegen/callback_common.h", - "include/grpcpp/impl/codegen/channel_interface.h", - "include/grpcpp/impl/codegen/client_callback.h", - "include/grpcpp/impl/codegen/client_callback_impl.h", - "include/grpcpp/impl/codegen/client_context.h", - "include/grpcpp/impl/codegen/client_context_impl.h", - "include/grpcpp/impl/codegen/client_interceptor.h", - "include/grpcpp/impl/codegen/client_unary_call.h", - "include/grpcpp/impl/codegen/completion_queue.h", - "include/grpcpp/impl/codegen/completion_queue_impl.h", - "include/grpcpp/impl/codegen/completion_queue_tag.h", - "include/grpcpp/impl/codegen/config.h", - "include/grpcpp/impl/codegen/core_codegen_interface.h", - "include/grpcpp/impl/codegen/create_auth_context.h", - "include/grpcpp/impl/codegen/delegating_channel.h", - "include/grpcpp/impl/codegen/grpc_library.h", - "include/grpcpp/impl/codegen/intercepted_channel.h", - "include/grpcpp/impl/codegen/interceptor.h", - "include/grpcpp/impl/codegen/interceptor_common.h", - "include/grpcpp/impl/codegen/message_allocator.h", - "include/grpcpp/impl/codegen/metadata_map.h", - "include/grpcpp/impl/codegen/method_handler_impl.h", - "include/grpcpp/impl/codegen/rpc_method.h", - "include/grpcpp/impl/codegen/rpc_service_method.h", - "include/grpcpp/impl/codegen/security/auth_context.h", - "include/grpcpp/impl/codegen/serialization_traits.h", - "include/grpcpp/impl/codegen/server_callback.h", - "include/grpcpp/impl/codegen/server_callback_impl.h", - "include/grpcpp/impl/codegen/server_context.h", - "include/grpcpp/impl/codegen/server_context_impl.h", - "include/grpcpp/impl/codegen/server_interceptor.h", - "include/grpcpp/impl/codegen/server_interface.h", - "include/grpcpp/impl/codegen/service_type.h", - "include/grpcpp/impl/codegen/slice.h", - "include/grpcpp/impl/codegen/status.h", - "include/grpcpp/impl/codegen/status_code_enum.h", - "include/grpcpp/impl/codegen/string_ref.h", - "include/grpcpp/impl/codegen/stub_options.h", - "include/grpcpp/impl/codegen/sync_stream.h", - "include/grpcpp/impl/codegen/sync_stream_impl.h", - "include/grpcpp/impl/codegen/time.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "grpc++_codegen_base" - ], - "headers": [], - "is_filegroup": true, - "language": "c++", - "name": "grpc++_codegen_base_src", - "src": [ - "src/cpp/codegen/codegen_init.cc" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "grpc++_codegen_base", - "grpc++_config_proto" - ], - "headers": [ - "include/grpc++/impl/codegen/proto_utils.h", - "include/grpcpp/impl/codegen/proto_buffer_reader.h", - "include/grpcpp/impl/codegen/proto_buffer_writer.h", - "include/grpcpp/impl/codegen/proto_utils.h" - ], - "is_filegroup": true, - "language": "c++", - "name": "grpc++_codegen_proto", - "src": [ - "include/grpc++/impl/codegen/proto_utils.h", - "include/grpcpp/impl/codegen/proto_buffer_reader.h", - "include/grpcpp/impl/codegen/proto_buffer_writer.h", - "include/grpcpp/impl/codegen/proto_utils.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "gpr", - "gpr_base_headers", - "grpc++_codegen_base", - "grpc++_internal_hdrs_only", - "grpc_base_headers", - "grpc_health_upb", - "grpc_transport_inproc_headers", - "nanopb_headers" - ], - "headers": [ - "include/grpc++/alarm.h", - "include/grpc++/channel.h", - "include/grpc++/client_context.h", - "include/grpc++/completion_queue.h", - "include/grpc++/create_channel.h", - "include/grpc++/create_channel_posix.h", - "include/grpc++/ext/health_check_service_server_builder_option.h", - "include/grpc++/generic/async_generic_service.h", - "include/grpc++/generic/generic_stub.h", - "include/grpc++/grpc++.h", - "include/grpc++/health_check_service_interface.h", - "include/grpc++/impl/call.h", - "include/grpc++/impl/channel_argument_option.h", - "include/grpc++/impl/client_unary_call.h", - "include/grpc++/impl/codegen/core_codegen.h", - "include/grpc++/impl/grpc_library.h", - "include/grpc++/impl/method_handler_impl.h", - "include/grpc++/impl/rpc_method.h", - "include/grpc++/impl/rpc_service_method.h", - "include/grpc++/impl/serialization_traits.h", - "include/grpc++/impl/server_builder_option.h", - "include/grpc++/impl/server_builder_plugin.h", - "include/grpc++/impl/server_initializer.h", - "include/grpc++/impl/service_type.h", - "include/grpc++/resource_quota.h", - "include/grpc++/security/auth_context.h", - "include/grpc++/security/auth_metadata_processor.h", - "include/grpc++/security/credentials.h", - "include/grpc++/security/server_credentials.h", - "include/grpc++/server.h", - "include/grpc++/server_builder.h", - "include/grpc++/server_context.h", - "include/grpc++/server_posix.h", - "include/grpc++/support/async_stream.h", - "include/grpc++/support/async_unary_call.h", - "include/grpc++/support/byte_buffer.h", - "include/grpc++/support/channel_arguments.h", - "include/grpc++/support/config.h", - "include/grpc++/support/slice.h", - "include/grpc++/support/status.h", - "include/grpc++/support/status_code_enum.h", - "include/grpc++/support/string_ref.h", - "include/grpc++/support/stub_options.h", - "include/grpc++/support/sync_stream.h", - "include/grpc++/support/time.h", - "include/grpcpp/alarm.h", - "include/grpcpp/alarm_impl.h", - "include/grpcpp/channel.h", - "include/grpcpp/channel_impl.h", - "include/grpcpp/client_context.h", - "include/grpcpp/completion_queue.h", - "include/grpcpp/completion_queue_impl.h", - "include/grpcpp/create_channel.h", - "include/grpcpp/create_channel_impl.h", - "include/grpcpp/create_channel_posix.h", - "include/grpcpp/create_channel_posix_impl.h", - "include/grpcpp/ext/health_check_service_server_builder_option.h", - "include/grpcpp/generic/async_generic_service.h", - "include/grpcpp/generic/generic_stub.h", - "include/grpcpp/generic/generic_stub_impl.h", - "include/grpcpp/grpcpp.h", - "include/grpcpp/health_check_service_interface.h", - "include/grpcpp/health_check_service_interface_impl.h", - "include/grpcpp/impl/call.h", - "include/grpcpp/impl/channel_argument_option.h", - "include/grpcpp/impl/client_unary_call.h", - "include/grpcpp/impl/codegen/core_codegen.h", - "include/grpcpp/impl/grpc_library.h", - "include/grpcpp/impl/method_handler_impl.h", - "include/grpcpp/impl/rpc_method.h", - "include/grpcpp/impl/rpc_service_method.h", - "include/grpcpp/impl/serialization_traits.h", - "include/grpcpp/impl/server_builder_option.h", - "include/grpcpp/impl/server_builder_option_impl.h", - "include/grpcpp/impl/server_builder_plugin.h", - "include/grpcpp/impl/server_initializer.h", - "include/grpcpp/impl/server_initializer_impl.h", - "include/grpcpp/impl/service_type.h", - "include/grpcpp/resource_quota.h", - "include/grpcpp/resource_quota_impl.h", - "include/grpcpp/security/auth_context.h", - "include/grpcpp/security/auth_metadata_processor.h", - "include/grpcpp/security/auth_metadata_processor_impl.h", - "include/grpcpp/security/credentials.h", - "include/grpcpp/security/credentials_impl.h", - "include/grpcpp/security/server_credentials.h", - "include/grpcpp/security/server_credentials_impl.h", - "include/grpcpp/server.h", - "include/grpcpp/server_builder.h", - "include/grpcpp/server_builder_impl.h", - "include/grpcpp/server_context.h", - "include/grpcpp/server_impl.h", - "include/grpcpp/server_posix.h", - "include/grpcpp/server_posix_impl.h", - "include/grpcpp/support/async_stream.h", - "include/grpcpp/support/async_stream_impl.h", - "include/grpcpp/support/async_unary_call.h", - "include/grpcpp/support/async_unary_call_impl.h", - "include/grpcpp/support/byte_buffer.h", - "include/grpcpp/support/channel_arguments.h", - "include/grpcpp/support/channel_arguments_impl.h", - "include/grpcpp/support/client_callback.h", - "include/grpcpp/support/client_callback_impl.h", - "include/grpcpp/support/client_interceptor.h", - "include/grpcpp/support/config.h", - "include/grpcpp/support/interceptor.h", - "include/grpcpp/support/message_allocator.h", - "include/grpcpp/support/proto_buffer_reader.h", - "include/grpcpp/support/proto_buffer_writer.h", - "include/grpcpp/support/server_callback.h", - "include/grpcpp/support/server_callback_impl.h", - "include/grpcpp/support/server_interceptor.h", - "include/grpcpp/support/slice.h", - "include/grpcpp/support/status.h", - "include/grpcpp/support/status_code_enum.h", - "include/grpcpp/support/string_ref.h", - "include/grpcpp/support/stub_options.h", - "include/grpcpp/support/sync_stream.h", - "include/grpcpp/support/sync_stream_impl.h", - "include/grpcpp/support/time.h", - "include/grpcpp/support/validate_service_config.h", - "src/cpp/client/create_channel_internal.h", - "src/cpp/common/channel_filter.h", - "src/cpp/server/dynamic_thread_pool.h", - "src/cpp/server/external_connection_acceptor_impl.h", - "src/cpp/server/health/default_health_check_service.h", - "src/cpp/server/thread_pool_interface.h", - "src/cpp/thread_manager/thread_manager.h" - ], - "is_filegroup": true, - "language": "c++", - "name": "grpc++_common", - "src": [ - "include/grpc++/alarm.h", - "include/grpc++/channel.h", - "include/grpc++/client_context.h", - "include/grpc++/completion_queue.h", - "include/grpc++/create_channel.h", - "include/grpc++/create_channel_posix.h", - "include/grpc++/ext/health_check_service_server_builder_option.h", - "include/grpc++/generic/async_generic_service.h", - "include/grpc++/generic/generic_stub.h", - "include/grpc++/grpc++.h", - "include/grpc++/health_check_service_interface.h", - "include/grpc++/impl/call.h", - "include/grpc++/impl/channel_argument_option.h", - "include/grpc++/impl/client_unary_call.h", - "include/grpc++/impl/codegen/core_codegen.h", - "include/grpc++/impl/grpc_library.h", - "include/grpc++/impl/method_handler_impl.h", - "include/grpc++/impl/rpc_method.h", - "include/grpc++/impl/rpc_service_method.h", - "include/grpc++/impl/serialization_traits.h", - "include/grpc++/impl/server_builder_option.h", - "include/grpc++/impl/server_builder_plugin.h", - "include/grpc++/impl/server_initializer.h", - "include/grpc++/impl/service_type.h", - "include/grpc++/resource_quota.h", - "include/grpc++/security/auth_context.h", - "include/grpc++/security/auth_metadata_processor.h", - "include/grpc++/security/credentials.h", - "include/grpc++/security/server_credentials.h", - "include/grpc++/server.h", - "include/grpc++/server_builder.h", - "include/grpc++/server_context.h", - "include/grpc++/server_posix.h", - "include/grpc++/support/async_stream.h", - "include/grpc++/support/async_unary_call.h", - "include/grpc++/support/byte_buffer.h", - "include/grpc++/support/channel_arguments.h", - "include/grpc++/support/config.h", - "include/grpc++/support/slice.h", - "include/grpc++/support/status.h", - "include/grpc++/support/status_code_enum.h", - "include/grpc++/support/string_ref.h", - "include/grpc++/support/stub_options.h", - "include/grpc++/support/sync_stream.h", - "include/grpc++/support/time.h", - "include/grpcpp/alarm.h", - "include/grpcpp/alarm_impl.h", - "include/grpcpp/channel.h", - "include/grpcpp/channel_impl.h", - "include/grpcpp/client_context.h", - "include/grpcpp/completion_queue.h", - "include/grpcpp/completion_queue_impl.h", - "include/grpcpp/create_channel.h", - "include/grpcpp/create_channel_impl.h", - "include/grpcpp/create_channel_posix.h", - "include/grpcpp/create_channel_posix_impl.h", - "include/grpcpp/ext/health_check_service_server_builder_option.h", - "include/grpcpp/generic/async_generic_service.h", - "include/grpcpp/generic/generic_stub.h", - "include/grpcpp/generic/generic_stub_impl.h", - "include/grpcpp/grpcpp.h", - "include/grpcpp/health_check_service_interface.h", - "include/grpcpp/health_check_service_interface_impl.h", - "include/grpcpp/impl/call.h", - "include/grpcpp/impl/channel_argument_option.h", - "include/grpcpp/impl/client_unary_call.h", - "include/grpcpp/impl/codegen/core_codegen.h", - "include/grpcpp/impl/grpc_library.h", - "include/grpcpp/impl/method_handler_impl.h", - "include/grpcpp/impl/rpc_method.h", - "include/grpcpp/impl/rpc_service_method.h", - "include/grpcpp/impl/serialization_traits.h", - "include/grpcpp/impl/server_builder_option.h", - "include/grpcpp/impl/server_builder_option_impl.h", - "include/grpcpp/impl/server_builder_plugin.h", - "include/grpcpp/impl/server_initializer.h", - "include/grpcpp/impl/server_initializer_impl.h", - "include/grpcpp/impl/service_type.h", - "include/grpcpp/resource_quota.h", - "include/grpcpp/resource_quota_impl.h", - "include/grpcpp/security/auth_context.h", - "include/grpcpp/security/auth_metadata_processor.h", - "include/grpcpp/security/auth_metadata_processor_impl.h", - "include/grpcpp/security/credentials.h", - "include/grpcpp/security/credentials_impl.h", - "include/grpcpp/security/server_credentials.h", - "include/grpcpp/security/server_credentials_impl.h", - "include/grpcpp/server.h", - "include/grpcpp/server_builder.h", - "include/grpcpp/server_builder_impl.h", - "include/grpcpp/server_context.h", - "include/grpcpp/server_impl.h", - "include/grpcpp/server_posix.h", - "include/grpcpp/server_posix_impl.h", - "include/grpcpp/support/async_stream.h", - "include/grpcpp/support/async_stream_impl.h", - "include/grpcpp/support/async_unary_call.h", - "include/grpcpp/support/async_unary_call_impl.h", - "include/grpcpp/support/byte_buffer.h", - "include/grpcpp/support/channel_arguments.h", - "include/grpcpp/support/channel_arguments_impl.h", - "include/grpcpp/support/client_callback.h", - "include/grpcpp/support/client_callback_impl.h", - "include/grpcpp/support/client_interceptor.h", - "include/grpcpp/support/config.h", - "include/grpcpp/support/interceptor.h", - "include/grpcpp/support/message_allocator.h", - "include/grpcpp/support/proto_buffer_reader.h", - "include/grpcpp/support/proto_buffer_writer.h", - "include/grpcpp/support/server_callback.h", - "include/grpcpp/support/server_callback_impl.h", - "include/grpcpp/support/server_interceptor.h", - "include/grpcpp/support/slice.h", - "include/grpcpp/support/status.h", - "include/grpcpp/support/status_code_enum.h", - "include/grpcpp/support/string_ref.h", - "include/grpcpp/support/stub_options.h", - "include/grpcpp/support/sync_stream.h", - "include/grpcpp/support/sync_stream_impl.h", - "include/grpcpp/support/time.h", - "include/grpcpp/support/validate_service_config.h", - "src/cpp/client/channel_cc.cc", - "src/cpp/client/client_context.cc", - "src/cpp/client/client_interceptor.cc", - "src/cpp/client/create_channel.cc", - "src/cpp/client/create_channel_internal.cc", - "src/cpp/client/create_channel_internal.h", - "src/cpp/client/create_channel_posix.cc", - "src/cpp/client/credentials_cc.cc", - "src/cpp/client/generic_stub.cc", - "src/cpp/common/alarm.cc", - "src/cpp/common/channel_arguments.cc", - "src/cpp/common/channel_filter.cc", - "src/cpp/common/channel_filter.h", - "src/cpp/common/completion_queue_cc.cc", - "src/cpp/common/core_codegen.cc", - "src/cpp/common/resource_quota_cc.cc", - "src/cpp/common/rpc_method.cc", - "src/cpp/common/validate_service_config.cc", - "src/cpp/common/version_cc.cc", - "src/cpp/server/async_generic_service.cc", - "src/cpp/server/channel_argument_option.cc", - "src/cpp/server/create_default_thread_pool.cc", - "src/cpp/server/dynamic_thread_pool.cc", - "src/cpp/server/dynamic_thread_pool.h", - "src/cpp/server/external_connection_acceptor_impl.cc", - "src/cpp/server/external_connection_acceptor_impl.h", - "src/cpp/server/health/default_health_check_service.cc", - "src/cpp/server/health/default_health_check_service.h", - "src/cpp/server/health/health_check_service.cc", - "src/cpp/server/health/health_check_service_server_builder_option.cc", - "src/cpp/server/server_builder.cc", - "src/cpp/server/server_cc.cc", - "src/cpp/server/server_context.cc", - "src/cpp/server/server_credentials.cc", - "src/cpp/server/server_posix.cc", - "src/cpp/server/thread_pool_interface.h", - "src/cpp/thread_manager/thread_manager.cc", - "src/cpp/thread_manager/thread_manager.h", - "src/cpp/util/byte_buffer_cc.cc", - "src/cpp/util/status.cc", - "src/cpp/util/string_ref.cc", - "src/cpp/util/time_cc.cc" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [], - "headers": [ - "include/grpc++/impl/codegen/config_protobuf.h", - "include/grpcpp/impl/codegen/config_protobuf.h" - ], - "is_filegroup": true, - "language": "c++", - "name": "grpc++_config_proto", - "src": [ - "include/grpc++/impl/codegen/config_protobuf.h", - "include/grpcpp/impl/codegen/config_protobuf.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [], - "headers": [ - "include/grpcpp/impl/codegen/sync.h" - ], - "is_filegroup": true, - "language": "c++", - "name": "grpc++_internal_hdrs_only", - "src": [ - "include/grpcpp/impl/codegen/sync.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [], - "headers": [ - "src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h", - "src/proto/grpc/reflection/v1alpha/reflection.pb.h", - "src/proto/grpc/reflection/v1alpha/reflection_mock.grpc.pb.h" - ], - "is_filegroup": true, - "language": "c++", - "name": "grpc++_reflection_proto", - "src": [], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "grpc", - "grpc++" - ], - "headers": [ - "include/grpc++/test/mock_stream.h", - "include/grpc++/test/server_context_test_spouse.h", - "include/grpcpp/test/mock_stream.h", - "include/grpcpp/test/server_context_test_spouse.h" - ], - "is_filegroup": true, - "language": "c++", - "name": "grpc++_test", - "src": [ - "include/grpc++/test/mock_stream.h", - "include/grpc++/test/server_context_test_spouse.h", - "include/grpcpp/test/mock_stream.h", - "include/grpcpp/test/server_context_test_spouse.h" - ], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [], - "headers": [ - "src/proto/grpc/channelz/channelz.grpc.pb.h", - "src/proto/grpc/channelz/channelz.pb.h", - "src/proto/grpc/channelz/channelz_mock.grpc.pb.h" - ], - "is_filegroup": true, - "language": "c++", - "name": "grpcpp_channelz_proto", - "src": [], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [ - "upb_headers" - ], - "headers": [], - "is_filegroup": true, - "language": "c", - "name": "upb", - "src": [], - "third_party": false, - "type": "filegroup" - }, - { - "deps": [], - "headers": [ - "third_party/upb/upb/decode.h", - "third_party/upb/upb/encode.h", - "third_party/upb/upb/generated_util.h", - "third_party/upb/upb/msg.h", - "third_party/upb/upb/port_def.inc", - "third_party/upb/upb/port_undef.inc", - "third_party/upb/upb/table.int.h", - "third_party/upb/upb/upb.h" - ], - "is_filegroup": true, - "language": "c", - "name": "upb_headers", - "src": [], - "third_party": false, - "type": "filegroup" - } -] From 0d203d39b821ad80d3ddf828e8395b0f9a40350e Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 16 Aug 2019 11:17:35 -0700 Subject: [PATCH 1270/1555] Adopt reviewers' advice --- src/python/grpcio/grpc/__init__.py | 42 ++++++++++++++ .../grpc/_cython/_cygrpc/credentials.pxd.pxi | 2 +- src/python/grpcio/grpc/_local_credentials.py | 56 ------------------- .../grpcio_tests/tests/unit/BUILD.bazel | 2 +- .../tests/unit/_local_credentials_test.py | 19 +++---- 5 files changed, 53 insertions(+), 68 deletions(-) delete mode 100644 src/python/grpcio/grpc/_local_credentials.py diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index 7dae90c89e8..f96ca270dc0 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -22,6 +22,7 @@ import six from grpc._cython import cygrpc as _cygrpc from grpc import _compression +from grpc import local_credentials logging.getLogger(__name__).addHandler(logging.NullHandler()) @@ -1744,6 +1745,44 @@ def dynamic_ssl_server_credentials(initial_certificate_configuration, certificate_configuration_fetcher, require_client_authentication)) +@enum.unique +class LocalConnectionType(enum.Enum): + """Type of local connections for which local channel/server credentials will be applied. + + Attributes: + UDS: Unix domain socket connections + LOCAL_TCP: Local TCP connections. + """ + UDS = _cygrpc.LocalConnectType.uds + LOCAL_TCP = _cygrpc.LocalConnectType.local_tcp + + +def local_channel_credentials(local_connect_type=LocalConnectionType.LOCAL_TCP): + """Creates a local ChannelCredentials used for local connections. + + Args: + local_connect_type: Local connection type (either UDS or LOCAL_TCP) + + Returns: + A ChannelCredentials for use with a local Channel + """ + return ChannelCredentials( + _cygrpc.channel_credentials_local(local_connect_type.value)) + + +def local_server_credentials(local_connect_type=LocalConnectionType.LOCAL_TCP): + """Creates a local ServerCredentials used for local connections. + + Args: + local_connect_type: Local connection type (either UDS or LOCAL_TCP) + + Returns: + A ServerCredentials for use with a local Server + """ + return ServerCredentials( + _cygrpc.server_credentials_local(local_connect_type.value)) + + def channel_ready_future(channel): """Creates a Future that tracks when a Channel is ready. @@ -1913,6 +1952,7 @@ __all__ = ( 'ClientCallDetails', 'ServerCertificateConfiguration', 'ServerCredentials', + 'LocalConnectionType', 'UnaryUnaryMultiCallable', 'UnaryStreamMultiCallable', 'StreamUnaryMultiCallable', @@ -1939,6 +1979,8 @@ __all__ = ( 'access_token_call_credentials', 'composite_call_credentials', 'composite_channel_credentials', + 'local_channel_credentials', + 'local_server_credentials', 'ssl_server_credentials', 'ssl_server_certificate_configuration', 'dynamic_ssl_server_credentials', diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi index ec647378a99..0631e1cf63c 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi @@ -101,4 +101,4 @@ cdef class ServerCredentials: cdef class LocalChannelCredentials(ChannelCredentials): - cdef readonly object _local_connect_type + cdef grpc_local_connect_type _local_connect_type diff --git a/src/python/grpcio/grpc/_local_credentials.py b/src/python/grpcio/grpc/_local_credentials.py deleted file mode 100644 index 8d46fa3d3ae..00000000000 --- a/src/python/grpcio/grpc/_local_credentials.py +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright 2019 The gRPC authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""gRPC's local credential API.""" - -import enum -import grpc -from grpc._cython import cygrpc - - -@enum.unique -class LocalConnectType(enum.Enum): - """Type of local connections for which local channel/server credentials will be applied. - - Attributes: - UDS: Unix domain socket connections - LOCAL_TCP: Local TCP connections. - """ - UDS = cygrpc.LocalConnectType.uds - LOCAL_TCP = cygrpc.LocalConnectType.local_tcp - - -def local_channel_credentials(local_connect_type=LocalConnectType.LOCAL_TCP): - """Creates a local ChannelCredentials used for local connections. - - Args: - local_connect_type: Local connection type (either UDS or LOCAL_TCP) - - Returns: - A ChannelCredentials for use with a local Channel - """ - return grpc.ChannelCredentials( - cygrpc.channel_credentials_local(local_connect_type.value)) - - -def local_server_credentials(local_connect_type=LocalConnectType.LOCAL_TCP): - """Creates a local ServerCredentials used for local connections. - - Args: - local_connect_type: Local connection type (either UDS or LOCAL_TCP) - - Returns: - A ServerCredentials for use with a local Server - """ - return grpc.ServerCredentials( - cygrpc.server_credentials_local(local_connect_type.value)) diff --git a/src/python/grpcio_tests/tests/unit/BUILD.bazel b/src/python/grpcio_tests/tests/unit/BUILD.bazel index baa8a4a3e6b..49203b7fa16 100644 --- a/src/python/grpcio_tests/tests/unit/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/BUILD.bazel @@ -19,7 +19,7 @@ GRPCIO_TESTS_UNIT = [ "_interceptor_test.py", "_invalid_metadata_test.py", "_invocation_defects_test.py", - "_local_crednetials_test.py", + "_local_credentials_test.py", "_logging_test.py", "_metadata_code_details_test.py", "_metadata_test.py", diff --git a/src/python/grpcio_tests/tests/unit/_local_credentials_test.py b/src/python/grpcio_tests/tests/unit/_local_credentials_test.py index 838d8129e8c..fe7b052482b 100644 --- a/src/python/grpcio_tests/tests/unit/_local_credentials_test.py +++ b/src/python/grpcio_tests/tests/unit/_local_credentials_test.py @@ -1,4 +1,4 @@ -# Copyright 2019 The gRPC authors +# Copyright 2019 The gRPC Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ import unittest from concurrent.futures import ThreadPoolExecutor import grpc -from grpc import local_credentials class _GenericHandler(grpc.GenericRpcHandler): @@ -35,10 +34,10 @@ class LocalCredentialsTest(unittest.TestCase): def test_local_tcp(self): server_addr = '[::1]:{}' - channel_creds = local_credentials.local_channel_credentials( - local_credentials.LocalConnectType.LOCAL_TCP) - server_creds = local_credentials.local_server_credentials( - local_credentials.LocalConnectType.LOCAL_TCP) + channel_creds = grpc.local_channel_credentials( + grpc.LocalConnectionType.LOCAL_TCP) + server_creds = grpc.local_server_credentials( + grpc.LocalConnectionType.LOCAL_TCP) server = self._create_server() port = server.add_secure_port(server_addr.format(0), server_creds) server.start() @@ -48,10 +47,10 @@ class LocalCredentialsTest(unittest.TestCase): def test_uds(self): server_addr = 'unix:/tmp/grpc_fullstack_test' - channel_creds = local_credentials.local_channel_credentials( - local_credentials.LocalConnectType.UDS) - server_creds = local_credentials.local_server_credentials( - local_credentials.LocalConnectType.UDS) + channel_creds = grpc.local_channel_credentials( + grpc.LocalConnectionType.UDS) + server_creds = grpc.local_server_credentials( + grpc.LocalConnectionType.UDS) server = self._create_server() server.add_secure_port(server_addr, server_creds) server.start() From feb263ba6d3c8b17e72b9221e42ab926654ad901 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Thu, 15 Aug 2019 12:56:41 -0700 Subject: [PATCH 1271/1555] Add check_attrs & clean-up build.yaml --- CMakeLists.txt | 13 - build.yaml | 649 +++++++++----------- src/benchmark/gen_build_yaml.py | 2 +- src/boringssl/gen_build_yaml.py | 6 +- src/c-ares/gen_build_yaml.py | 2 +- src/objective-c/tests/run_one_test_bazel.sh | 2 +- src/zlib/gen_build_yaml.py | 2 +- test/core/bad_client/gen_build_yaml.py | 2 +- tools/buildgen/plugins/check_attrs.py | 126 ++++ 9 files changed, 431 insertions(+), 373 deletions(-) create mode 100644 tools/buildgen/plugins/check_attrs.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e1cdd3fc5f..0b6dba6dedb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17923,7 +17923,6 @@ target_include_directories(bad_streaming_id_bad_client_test ) target_link_libraries(bad_streaming_id_bad_client_test - ${_gRPC_SSL_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test @@ -17966,7 +17965,6 @@ target_include_directories(badreq_bad_client_test ) target_link_libraries(badreq_bad_client_test - ${_gRPC_SSL_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test @@ -18009,7 +18007,6 @@ target_include_directories(connection_prefix_bad_client_test ) target_link_libraries(connection_prefix_bad_client_test - ${_gRPC_SSL_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test @@ -18052,7 +18049,6 @@ target_include_directories(duplicate_header_bad_client_test ) target_link_libraries(duplicate_header_bad_client_test - ${_gRPC_SSL_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test @@ -18095,7 +18091,6 @@ target_include_directories(head_of_line_blocking_bad_client_test ) target_link_libraries(head_of_line_blocking_bad_client_test - ${_gRPC_SSL_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test @@ -18138,7 +18133,6 @@ target_include_directories(headers_bad_client_test ) target_link_libraries(headers_bad_client_test - ${_gRPC_SSL_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test @@ -18181,7 +18175,6 @@ target_include_directories(initial_settings_frame_bad_client_test ) target_link_libraries(initial_settings_frame_bad_client_test - ${_gRPC_SSL_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test @@ -18224,7 +18217,6 @@ target_include_directories(large_metadata_bad_client_test ) target_link_libraries(large_metadata_bad_client_test - ${_gRPC_SSL_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test @@ -18267,7 +18259,6 @@ target_include_directories(out_of_bounds_bad_client_test ) target_link_libraries(out_of_bounds_bad_client_test - ${_gRPC_SSL_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test @@ -18310,7 +18301,6 @@ target_include_directories(server_registered_method_bad_client_test ) target_link_libraries(server_registered_method_bad_client_test - ${_gRPC_SSL_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test @@ -18353,7 +18343,6 @@ target_include_directories(simple_request_bad_client_test ) target_link_libraries(simple_request_bad_client_test - ${_gRPC_SSL_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test @@ -18396,7 +18385,6 @@ target_include_directories(unknown_frame_bad_client_test ) target_link_libraries(unknown_frame_bad_client_test - ${_gRPC_SSL_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test @@ -18439,7 +18427,6 @@ target_include_directories(window_overflow_bad_client_test ) target_link_libraries(window_overflow_bad_client_test - ${_gRPC_SSL_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} bad_client_test diff --git a/build.yaml b/build.yaml index e63f375bd8a..87ca412d12f 100644 --- a/build.yaml +++ b/build.yaml @@ -315,6 +315,300 @@ filegroups: uses: - grpc++_common - grpc++_codegen_base +- name: grpc++_codegen_base + public_headers: + - include/grpc++/impl/codegen/async_stream.h + - include/grpc++/impl/codegen/async_unary_call.h + - include/grpc++/impl/codegen/byte_buffer.h + - include/grpc++/impl/codegen/call.h + - include/grpc++/impl/codegen/call_hook.h + - include/grpc++/impl/codegen/channel_interface.h + - include/grpc++/impl/codegen/client_context.h + - include/grpc++/impl/codegen/client_unary_call.h + - include/grpc++/impl/codegen/completion_queue.h + - include/grpc++/impl/codegen/completion_queue_tag.h + - include/grpc++/impl/codegen/config.h + - include/grpc++/impl/codegen/core_codegen_interface.h + - include/grpc++/impl/codegen/create_auth_context.h + - include/grpc++/impl/codegen/grpc_library.h + - include/grpc++/impl/codegen/metadata_map.h + - include/grpc++/impl/codegen/method_handler_impl.h + - include/grpc++/impl/codegen/rpc_method.h + - include/grpc++/impl/codegen/rpc_service_method.h + - include/grpc++/impl/codegen/security/auth_context.h + - include/grpc++/impl/codegen/serialization_traits.h + - include/grpc++/impl/codegen/server_context.h + - include/grpc++/impl/codegen/server_interface.h + - include/grpc++/impl/codegen/service_type.h + - include/grpc++/impl/codegen/slice.h + - include/grpc++/impl/codegen/status.h + - include/grpc++/impl/codegen/status_code_enum.h + - include/grpc++/impl/codegen/string_ref.h + - include/grpc++/impl/codegen/stub_options.h + - include/grpc++/impl/codegen/sync_stream.h + - include/grpc++/impl/codegen/time.h + - include/grpcpp/impl/codegen/async_generic_service.h + - include/grpcpp/impl/codegen/async_stream.h + - include/grpcpp/impl/codegen/async_stream_impl.h + - include/grpcpp/impl/codegen/async_unary_call.h + - include/grpcpp/impl/codegen/async_unary_call_impl.h + - include/grpcpp/impl/codegen/byte_buffer.h + - include/grpcpp/impl/codegen/call.h + - include/grpcpp/impl/codegen/call_hook.h + - include/grpcpp/impl/codegen/call_op_set.h + - include/grpcpp/impl/codegen/call_op_set_interface.h + - include/grpcpp/impl/codegen/callback_common.h + - include/grpcpp/impl/codegen/channel_interface.h + - include/grpcpp/impl/codegen/client_callback.h + - include/grpcpp/impl/codegen/client_callback_impl.h + - include/grpcpp/impl/codegen/client_context.h + - include/grpcpp/impl/codegen/client_context_impl.h + - include/grpcpp/impl/codegen/client_interceptor.h + - include/grpcpp/impl/codegen/client_unary_call.h + - include/grpcpp/impl/codegen/completion_queue.h + - include/grpcpp/impl/codegen/completion_queue_impl.h + - include/grpcpp/impl/codegen/completion_queue_tag.h + - include/grpcpp/impl/codegen/config.h + - include/grpcpp/impl/codegen/core_codegen_interface.h + - include/grpcpp/impl/codegen/create_auth_context.h + - include/grpcpp/impl/codegen/delegating_channel.h + - include/grpcpp/impl/codegen/grpc_library.h + - include/grpcpp/impl/codegen/intercepted_channel.h + - include/grpcpp/impl/codegen/interceptor.h + - include/grpcpp/impl/codegen/interceptor_common.h + - include/grpcpp/impl/codegen/message_allocator.h + - include/grpcpp/impl/codegen/metadata_map.h + - include/grpcpp/impl/codegen/method_handler_impl.h + - include/grpcpp/impl/codegen/rpc_method.h + - include/grpcpp/impl/codegen/rpc_service_method.h + - include/grpcpp/impl/codegen/security/auth_context.h + - include/grpcpp/impl/codegen/serialization_traits.h + - include/grpcpp/impl/codegen/server_callback.h + - include/grpcpp/impl/codegen/server_callback_impl.h + - include/grpcpp/impl/codegen/server_context.h + - include/grpcpp/impl/codegen/server_context_impl.h + - include/grpcpp/impl/codegen/server_interceptor.h + - include/grpcpp/impl/codegen/server_interface.h + - include/grpcpp/impl/codegen/service_type.h + - include/grpcpp/impl/codegen/slice.h + - include/grpcpp/impl/codegen/status.h + - include/grpcpp/impl/codegen/status_code_enum.h + - include/grpcpp/impl/codegen/string_ref.h + - include/grpcpp/impl/codegen/stub_options.h + - include/grpcpp/impl/codegen/sync_stream.h + - include/grpcpp/impl/codegen/sync_stream_impl.h + - include/grpcpp/impl/codegen/time.h + uses: + - grpc_codegen + - grpc++_internal_hdrs_only +- name: grpc++_codegen_base_src + src: + - src/cpp/codegen/codegen_init.cc + uses: + - grpc++_codegen_base +- name: grpc++_codegen_proto + public_headers: + - include/grpc++/impl/codegen/proto_utils.h + - include/grpcpp/impl/codegen/proto_buffer_reader.h + - include/grpcpp/impl/codegen/proto_buffer_writer.h + - include/grpcpp/impl/codegen/proto_utils.h + uses: + - grpc++_codegen_base + - grpc++_config_proto +- name: grpc++_common + public_headers: + - include/grpc++/alarm.h + - include/grpc++/channel.h + - include/grpc++/client_context.h + - include/grpc++/completion_queue.h + - include/grpc++/create_channel.h + - include/grpc++/create_channel_posix.h + - include/grpc++/ext/health_check_service_server_builder_option.h + - include/grpc++/generic/async_generic_service.h + - include/grpc++/generic/generic_stub.h + - include/grpc++/grpc++.h + - include/grpc++/health_check_service_interface.h + - include/grpc++/impl/call.h + - include/grpc++/impl/channel_argument_option.h + - include/grpc++/impl/client_unary_call.h + - include/grpc++/impl/codegen/core_codegen.h + - include/grpc++/impl/grpc_library.h + - include/grpc++/impl/method_handler_impl.h + - include/grpc++/impl/rpc_method.h + - include/grpc++/impl/rpc_service_method.h + - include/grpc++/impl/serialization_traits.h + - include/grpc++/impl/server_builder_option.h + - include/grpc++/impl/server_builder_plugin.h + - include/grpc++/impl/server_initializer.h + - include/grpc++/impl/service_type.h + - include/grpc++/resource_quota.h + - include/grpc++/security/auth_context.h + - include/grpc++/security/auth_metadata_processor.h + - include/grpc++/security/credentials.h + - include/grpc++/security/server_credentials.h + - include/grpc++/server.h + - include/grpc++/server_builder.h + - include/grpc++/server_context.h + - include/grpc++/server_posix.h + - include/grpc++/support/async_stream.h + - include/grpc++/support/async_unary_call.h + - include/grpc++/support/byte_buffer.h + - include/grpc++/support/channel_arguments.h + - include/grpc++/support/config.h + - include/grpc++/support/slice.h + - include/grpc++/support/status.h + - include/grpc++/support/status_code_enum.h + - include/grpc++/support/string_ref.h + - include/grpc++/support/stub_options.h + - include/grpc++/support/sync_stream.h + - include/grpc++/support/time.h + - include/grpcpp/alarm.h + - include/grpcpp/alarm_impl.h + - include/grpcpp/channel.h + - include/grpcpp/channel_impl.h + - include/grpcpp/client_context.h + - include/grpcpp/completion_queue.h + - include/grpcpp/completion_queue_impl.h + - include/grpcpp/create_channel.h + - include/grpcpp/create_channel_impl.h + - include/grpcpp/create_channel_posix.h + - include/grpcpp/create_channel_posix_impl.h + - include/grpcpp/ext/health_check_service_server_builder_option.h + - include/grpcpp/generic/async_generic_service.h + - include/grpcpp/generic/generic_stub.h + - include/grpcpp/generic/generic_stub_impl.h + - include/grpcpp/grpcpp.h + - include/grpcpp/health_check_service_interface.h + - include/grpcpp/health_check_service_interface_impl.h + - include/grpcpp/impl/call.h + - include/grpcpp/impl/channel_argument_option.h + - include/grpcpp/impl/client_unary_call.h + - include/grpcpp/impl/codegen/core_codegen.h + - include/grpcpp/impl/grpc_library.h + - include/grpcpp/impl/method_handler_impl.h + - include/grpcpp/impl/rpc_method.h + - include/grpcpp/impl/rpc_service_method.h + - include/grpcpp/impl/serialization_traits.h + - include/grpcpp/impl/server_builder_option.h + - include/grpcpp/impl/server_builder_option_impl.h + - include/grpcpp/impl/server_builder_plugin.h + - include/grpcpp/impl/server_initializer.h + - include/grpcpp/impl/server_initializer_impl.h + - include/grpcpp/impl/service_type.h + - include/grpcpp/resource_quota.h + - include/grpcpp/resource_quota_impl.h + - include/grpcpp/security/auth_context.h + - include/grpcpp/security/auth_metadata_processor.h + - include/grpcpp/security/auth_metadata_processor_impl.h + - include/grpcpp/security/credentials.h + - include/grpcpp/security/credentials_impl.h + - include/grpcpp/security/server_credentials.h + - include/grpcpp/security/server_credentials_impl.h + - include/grpcpp/server.h + - include/grpcpp/server_builder.h + - include/grpcpp/server_builder_impl.h + - include/grpcpp/server_context.h + - include/grpcpp/server_impl.h + - include/grpcpp/server_posix.h + - include/grpcpp/server_posix_impl.h + - include/grpcpp/support/async_stream.h + - include/grpcpp/support/async_stream_impl.h + - include/grpcpp/support/async_unary_call.h + - include/grpcpp/support/async_unary_call_impl.h + - include/grpcpp/support/byte_buffer.h + - include/grpcpp/support/channel_arguments.h + - include/grpcpp/support/channel_arguments_impl.h + - include/grpcpp/support/client_callback.h + - include/grpcpp/support/client_callback_impl.h + - include/grpcpp/support/client_interceptor.h + - include/grpcpp/support/config.h + - include/grpcpp/support/interceptor.h + - include/grpcpp/support/message_allocator.h + - include/grpcpp/support/proto_buffer_reader.h + - include/grpcpp/support/proto_buffer_writer.h + - include/grpcpp/support/server_callback.h + - include/grpcpp/support/server_callback_impl.h + - include/grpcpp/support/server_interceptor.h + - include/grpcpp/support/slice.h + - include/grpcpp/support/status.h + - include/grpcpp/support/status_code_enum.h + - include/grpcpp/support/string_ref.h + - include/grpcpp/support/stub_options.h + - include/grpcpp/support/sync_stream.h + - include/grpcpp/support/sync_stream_impl.h + - include/grpcpp/support/time.h + - include/grpcpp/support/validate_service_config.h + headers: + - src/cpp/client/create_channel_internal.h + - src/cpp/common/channel_filter.h + - src/cpp/server/dynamic_thread_pool.h + - src/cpp/server/external_connection_acceptor_impl.h + - src/cpp/server/health/default_health_check_service.h + - src/cpp/server/thread_pool_interface.h + - src/cpp/thread_manager/thread_manager.h + src: + - src/cpp/client/channel_cc.cc + - src/cpp/client/client_context.cc + - src/cpp/client/client_interceptor.cc + - src/cpp/client/create_channel.cc + - src/cpp/client/create_channel_internal.cc + - src/cpp/client/create_channel_posix.cc + - src/cpp/client/credentials_cc.cc + - src/cpp/client/generic_stub.cc + - src/cpp/common/alarm.cc + - src/cpp/common/channel_arguments.cc + - src/cpp/common/channel_filter.cc + - src/cpp/common/completion_queue_cc.cc + - src/cpp/common/core_codegen.cc + - src/cpp/common/resource_quota_cc.cc + - src/cpp/common/rpc_method.cc + - src/cpp/common/validate_service_config.cc + - src/cpp/common/version_cc.cc + - src/cpp/server/async_generic_service.cc + - src/cpp/server/channel_argument_option.cc + - src/cpp/server/create_default_thread_pool.cc + - src/cpp/server/dynamic_thread_pool.cc + - src/cpp/server/external_connection_acceptor_impl.cc + - src/cpp/server/health/default_health_check_service.cc + - src/cpp/server/health/health_check_service.cc + - src/cpp/server/health/health_check_service_server_builder_option.cc + - src/cpp/server/server_builder.cc + - src/cpp/server/server_cc.cc + - src/cpp/server/server_context.cc + - src/cpp/server/server_credentials.cc + - src/cpp/server/server_posix.cc + - src/cpp/thread_manager/thread_manager.cc + - src/cpp/util/byte_buffer_cc.cc + - src/cpp/util/status.cc + - src/cpp/util/string_ref.cc + - src/cpp/util/time_cc.cc + uses: + - gpr_base_headers + - grpc_base_headers + - grpc_health_upb + - grpc_transport_inproc_headers + - grpc++_codegen_base + - grpc++_internal_hdrs_only + - nanopb_headers +- name: grpc++_config_proto + public_headers: + - include/grpc++/impl/codegen/config_protobuf.h + - include/grpcpp/impl/codegen/config_protobuf.h +- name: grpc++_internal_hdrs_only + public_headers: + - include/grpcpp/impl/codegen/sync.h +- name: grpc++_reflection_proto + src: + - src/proto/grpc/reflection/v1alpha/reflection.proto +- name: grpc++_test + public_headers: + - include/grpc++/test/mock_stream.h + - include/grpc++/test/server_context_test_spouse.h + - include/grpcpp/test/mock_stream.h + - include/grpcpp/test/server_context_test_spouse.h + deps: + - grpc++ + - grpc - name: grpc_base src: - src/core/lib/avl/avl.cc @@ -476,8 +770,6 @@ filegroups: - src/core/lib/uri/uri_parser.cc deps: - gpr - filegroups: - - grpc_base_headers uses: - grpc_codegen - grpc_trace @@ -1006,7 +1298,6 @@ filegroups: - src/core/lib/security/transport/tsi_error.cc - src/core/lib/security/util/json_util.cc - src/core/lib/surface/init_secure.cc - secure: true uses: - alts_tsi - grpc_base @@ -1024,7 +1315,6 @@ filegroups: headers: - src/core/tsi/grpc_shadow_boringssl.h - name: grpc_test_util_base - build: test headers: - src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h - test/core/end2end/cq_verifier.h @@ -1085,9 +1375,6 @@ filegroups: - src/core/lib/debug/trace.cc deps: - gpr - filegroups: - - grpc_trace_headers - - grpc_base_headers - name: grpc_trace_headers headers: - src/core/lib/debug/trace.h @@ -1218,10 +1505,6 @@ filegroups: - src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc - src/core/ext/transport/cronet/transport/cronet_api_dummy.cc - src/core/ext/transport/cronet/transport/cronet_transport.cc - filegroups: - - grpc_base - - grpc_transport_chttp2 - - grpc_http_filters - name: grpc_transport_inproc src: - src/core/ext/transport/inproc/inproc_plugin.cc @@ -1244,6 +1527,9 @@ filegroups: uses: - grpc_base - grpc_server_backward_compatibility +- name: grpcpp_channelz_proto + src: + - src/proto/grpc/channelz/channelz.proto - name: nanopb src: - third_party/nanopb/pb_common.c @@ -1267,7 +1553,6 @@ filegroups: uses: - google_api_upb - name: transport_security_test_lib - build: test headers: - test/core/tsi/transport_security_test_lib.h src: @@ -1293,7 +1578,6 @@ filegroups: - src/core/tsi/transport_security_grpc.cc deps: - gpr - secure: true uses: - tsi_interface - grpc_base @@ -1307,315 +1591,8 @@ filegroups: - src/core/tsi/transport_security.cc deps: - gpr - secure: true uses: - grpc_trace -- name: grpc++_codegen_base - language: c++ - public_headers: - - include/grpc++/impl/codegen/async_stream.h - - include/grpc++/impl/codegen/async_unary_call.h - - include/grpc++/impl/codegen/byte_buffer.h - - include/grpc++/impl/codegen/call.h - - include/grpc++/impl/codegen/call_hook.h - - include/grpc++/impl/codegen/channel_interface.h - - include/grpc++/impl/codegen/client_context.h - - include/grpc++/impl/codegen/client_unary_call.h - - include/grpc++/impl/codegen/completion_queue.h - - include/grpc++/impl/codegen/completion_queue_tag.h - - include/grpc++/impl/codegen/config.h - - include/grpc++/impl/codegen/core_codegen_interface.h - - include/grpc++/impl/codegen/create_auth_context.h - - include/grpc++/impl/codegen/grpc_library.h - - include/grpc++/impl/codegen/metadata_map.h - - include/grpc++/impl/codegen/method_handler_impl.h - - include/grpc++/impl/codegen/rpc_method.h - - include/grpc++/impl/codegen/rpc_service_method.h - - include/grpc++/impl/codegen/security/auth_context.h - - include/grpc++/impl/codegen/serialization_traits.h - - include/grpc++/impl/codegen/server_context.h - - include/grpc++/impl/codegen/server_interface.h - - include/grpc++/impl/codegen/service_type.h - - include/grpc++/impl/codegen/slice.h - - include/grpc++/impl/codegen/status.h - - include/grpc++/impl/codegen/status_code_enum.h - - include/grpc++/impl/codegen/string_ref.h - - include/grpc++/impl/codegen/stub_options.h - - include/grpc++/impl/codegen/sync_stream.h - - include/grpc++/impl/codegen/time.h - - include/grpcpp/impl/codegen/async_generic_service.h - - include/grpcpp/impl/codegen/async_stream.h - - include/grpcpp/impl/codegen/async_stream_impl.h - - include/grpcpp/impl/codegen/async_unary_call.h - - include/grpcpp/impl/codegen/async_unary_call_impl.h - - include/grpcpp/impl/codegen/byte_buffer.h - - include/grpcpp/impl/codegen/call.h - - include/grpcpp/impl/codegen/call_hook.h - - include/grpcpp/impl/codegen/call_op_set.h - - include/grpcpp/impl/codegen/call_op_set_interface.h - - include/grpcpp/impl/codegen/callback_common.h - - include/grpcpp/impl/codegen/channel_interface.h - - include/grpcpp/impl/codegen/client_callback.h - - include/grpcpp/impl/codegen/client_callback_impl.h - - include/grpcpp/impl/codegen/client_context.h - - include/grpcpp/impl/codegen/client_context_impl.h - - include/grpcpp/impl/codegen/client_interceptor.h - - include/grpcpp/impl/codegen/client_unary_call.h - - include/grpcpp/impl/codegen/completion_queue.h - - include/grpcpp/impl/codegen/completion_queue_impl.h - - include/grpcpp/impl/codegen/completion_queue_tag.h - - include/grpcpp/impl/codegen/config.h - - include/grpcpp/impl/codegen/core_codegen_interface.h - - include/grpcpp/impl/codegen/create_auth_context.h - - include/grpcpp/impl/codegen/delegating_channel.h - - include/grpcpp/impl/codegen/grpc_library.h - - include/grpcpp/impl/codegen/intercepted_channel.h - - include/grpcpp/impl/codegen/interceptor.h - - include/grpcpp/impl/codegen/interceptor_common.h - - include/grpcpp/impl/codegen/message_allocator.h - - include/grpcpp/impl/codegen/metadata_map.h - - include/grpcpp/impl/codegen/method_handler_impl.h - - include/grpcpp/impl/codegen/rpc_method.h - - include/grpcpp/impl/codegen/rpc_service_method.h - - include/grpcpp/impl/codegen/security/auth_context.h - - include/grpcpp/impl/codegen/serialization_traits.h - - include/grpcpp/impl/codegen/server_callback.h - - include/grpcpp/impl/codegen/server_callback_impl.h - - include/grpcpp/impl/codegen/server_context.h - - include/grpcpp/impl/codegen/server_context_impl.h - - include/grpcpp/impl/codegen/server_interceptor.h - - include/grpcpp/impl/codegen/server_interface.h - - include/grpcpp/impl/codegen/service_type.h - - include/grpcpp/impl/codegen/slice.h - - include/grpcpp/impl/codegen/status.h - - include/grpcpp/impl/codegen/status_code_enum.h - - include/grpcpp/impl/codegen/string_ref.h - - include/grpcpp/impl/codegen/stub_options.h - - include/grpcpp/impl/codegen/sync_stream.h - - include/grpcpp/impl/codegen/sync_stream_impl.h - - include/grpcpp/impl/codegen/time.h - uses: - - grpc_codegen - - grpc++_internal_hdrs_only -- name: grpc++_codegen_base_src - language: c++ - src: - - src/cpp/codegen/codegen_init.cc - uses: - - grpc++_codegen_base -- name: grpc++_codegen_proto - language: c++ - public_headers: - - include/grpc++/impl/codegen/proto_utils.h - - include/grpcpp/impl/codegen/proto_buffer_reader.h - - include/grpcpp/impl/codegen/proto_buffer_writer.h - - include/grpcpp/impl/codegen/proto_utils.h - uses: - - grpc++_codegen_base - - grpc++_config_proto -- name: grpc++_common - language: c++ - public_headers: - - include/grpc++/alarm.h - - include/grpc++/channel.h - - include/grpc++/client_context.h - - include/grpc++/completion_queue.h - - include/grpc++/create_channel.h - - include/grpc++/create_channel_posix.h - - include/grpc++/ext/health_check_service_server_builder_option.h - - include/grpc++/generic/async_generic_service.h - - include/grpc++/generic/generic_stub.h - - include/grpc++/grpc++.h - - include/grpc++/health_check_service_interface.h - - include/grpc++/impl/call.h - - include/grpc++/impl/channel_argument_option.h - - include/grpc++/impl/client_unary_call.h - - include/grpc++/impl/codegen/core_codegen.h - - include/grpc++/impl/grpc_library.h - - include/grpc++/impl/method_handler_impl.h - - include/grpc++/impl/rpc_method.h - - include/grpc++/impl/rpc_service_method.h - - include/grpc++/impl/serialization_traits.h - - include/grpc++/impl/server_builder_option.h - - include/grpc++/impl/server_builder_plugin.h - - include/grpc++/impl/server_initializer.h - - include/grpc++/impl/service_type.h - - include/grpc++/resource_quota.h - - include/grpc++/security/auth_context.h - - include/grpc++/security/auth_metadata_processor.h - - include/grpc++/security/credentials.h - - include/grpc++/security/server_credentials.h - - include/grpc++/server.h - - include/grpc++/server_builder.h - - include/grpc++/server_context.h - - include/grpc++/server_posix.h - - include/grpc++/support/async_stream.h - - include/grpc++/support/async_unary_call.h - - include/grpc++/support/byte_buffer.h - - include/grpc++/support/channel_arguments.h - - include/grpc++/support/config.h - - include/grpc++/support/slice.h - - include/grpc++/support/status.h - - include/grpc++/support/status_code_enum.h - - include/grpc++/support/string_ref.h - - include/grpc++/support/stub_options.h - - include/grpc++/support/sync_stream.h - - include/grpc++/support/time.h - - include/grpcpp/alarm.h - - include/grpcpp/alarm_impl.h - - include/grpcpp/channel.h - - include/grpcpp/channel_impl.h - - include/grpcpp/client_context.h - - include/grpcpp/completion_queue.h - - include/grpcpp/completion_queue_impl.h - - include/grpcpp/create_channel.h - - include/grpcpp/create_channel_impl.h - - include/grpcpp/create_channel_posix.h - - include/grpcpp/create_channel_posix_impl.h - - include/grpcpp/ext/health_check_service_server_builder_option.h - - include/grpcpp/generic/async_generic_service.h - - include/grpcpp/generic/generic_stub.h - - include/grpcpp/generic/generic_stub_impl.h - - include/grpcpp/grpcpp.h - - include/grpcpp/health_check_service_interface.h - - include/grpcpp/health_check_service_interface_impl.h - - include/grpcpp/impl/call.h - - include/grpcpp/impl/channel_argument_option.h - - include/grpcpp/impl/client_unary_call.h - - include/grpcpp/impl/codegen/core_codegen.h - - include/grpcpp/impl/grpc_library.h - - include/grpcpp/impl/method_handler_impl.h - - include/grpcpp/impl/rpc_method.h - - include/grpcpp/impl/rpc_service_method.h - - include/grpcpp/impl/serialization_traits.h - - include/grpcpp/impl/server_builder_option.h - - include/grpcpp/impl/server_builder_option_impl.h - - include/grpcpp/impl/server_builder_plugin.h - - include/grpcpp/impl/server_initializer.h - - include/grpcpp/impl/server_initializer_impl.h - - include/grpcpp/impl/service_type.h - - include/grpcpp/resource_quota.h - - include/grpcpp/resource_quota_impl.h - - include/grpcpp/security/auth_context.h - - include/grpcpp/security/auth_metadata_processor.h - - include/grpcpp/security/auth_metadata_processor_impl.h - - include/grpcpp/security/credentials.h - - include/grpcpp/security/credentials_impl.h - - include/grpcpp/security/server_credentials.h - - include/grpcpp/security/server_credentials_impl.h - - include/grpcpp/server.h - - include/grpcpp/server_builder.h - - include/grpcpp/server_builder_impl.h - - include/grpcpp/server_context.h - - include/grpcpp/server_impl.h - - include/grpcpp/server_posix.h - - include/grpcpp/server_posix_impl.h - - include/grpcpp/support/async_stream.h - - include/grpcpp/support/async_stream_impl.h - - include/grpcpp/support/async_unary_call.h - - include/grpcpp/support/async_unary_call_impl.h - - include/grpcpp/support/byte_buffer.h - - include/grpcpp/support/channel_arguments.h - - include/grpcpp/support/channel_arguments_impl.h - - include/grpcpp/support/client_callback.h - - include/grpcpp/support/client_callback_impl.h - - include/grpcpp/support/client_interceptor.h - - include/grpcpp/support/config.h - - include/grpcpp/support/interceptor.h - - include/grpcpp/support/message_allocator.h - - include/grpcpp/support/proto_buffer_reader.h - - include/grpcpp/support/proto_buffer_writer.h - - include/grpcpp/support/server_callback.h - - include/grpcpp/support/server_callback_impl.h - - include/grpcpp/support/server_interceptor.h - - include/grpcpp/support/slice.h - - include/grpcpp/support/status.h - - include/grpcpp/support/status_code_enum.h - - include/grpcpp/support/string_ref.h - - include/grpcpp/support/stub_options.h - - include/grpcpp/support/sync_stream.h - - include/grpcpp/support/sync_stream_impl.h - - include/grpcpp/support/time.h - - include/grpcpp/support/validate_service_config.h - headers: - - src/cpp/client/create_channel_internal.h - - src/cpp/common/channel_filter.h - - src/cpp/server/dynamic_thread_pool.h - - src/cpp/server/external_connection_acceptor_impl.h - - src/cpp/server/health/default_health_check_service.h - - src/cpp/server/thread_pool_interface.h - - src/cpp/thread_manager/thread_manager.h - src: - - src/cpp/client/channel_cc.cc - - src/cpp/client/client_context.cc - - src/cpp/client/client_interceptor.cc - - src/cpp/client/create_channel.cc - - src/cpp/client/create_channel_internal.cc - - src/cpp/client/create_channel_posix.cc - - src/cpp/client/credentials_cc.cc - - src/cpp/client/generic_stub.cc - - src/cpp/common/alarm.cc - - src/cpp/common/channel_arguments.cc - - src/cpp/common/channel_filter.cc - - src/cpp/common/completion_queue_cc.cc - - src/cpp/common/core_codegen.cc - - src/cpp/common/resource_quota_cc.cc - - src/cpp/common/rpc_method.cc - - src/cpp/common/validate_service_config.cc - - src/cpp/common/version_cc.cc - - src/cpp/server/async_generic_service.cc - - src/cpp/server/channel_argument_option.cc - - src/cpp/server/create_default_thread_pool.cc - - src/cpp/server/dynamic_thread_pool.cc - - src/cpp/server/external_connection_acceptor_impl.cc - - src/cpp/server/health/default_health_check_service.cc - - src/cpp/server/health/health_check_service.cc - - src/cpp/server/health/health_check_service_server_builder_option.cc - - src/cpp/server/server_builder.cc - - src/cpp/server/server_cc.cc - - src/cpp/server/server_context.cc - - src/cpp/server/server_credentials.cc - - src/cpp/server/server_posix.cc - - src/cpp/thread_manager/thread_manager.cc - - src/cpp/util/byte_buffer_cc.cc - - src/cpp/util/status.cc - - src/cpp/util/string_ref.cc - - src/cpp/util/time_cc.cc - uses: - - gpr_base_headers - - grpc_base_headers - - grpc_health_upb - - grpc_transport_inproc_headers - - grpc++_codegen_base - - grpc++_internal_hdrs_only - - nanopb_headers -- name: grpc++_config_proto - language: c++ - public_headers: - - include/grpc++/impl/codegen/config_protobuf.h - - include/grpcpp/impl/codegen/config_protobuf.h -- name: grpc++_internal_hdrs_only - language: c++ - public_headers: - - include/grpcpp/impl/codegen/sync.h -- name: grpc++_reflection_proto - language: c++ - src: - - src/proto/grpc/reflection/v1alpha/reflection.proto -- name: grpc++_test - language: c++ - public_headers: - - include/grpc++/test/mock_stream.h - - include/grpc++/test/server_context_test_spouse.h - - include/grpcpp/test/mock_stream.h - - include/grpcpp/test/server_context_test_spouse.h - deps: - - grpc++ - - grpc -- name: grpcpp_channelz_proto - language: c++ - src: - - src/proto/grpc/channelz/channelz.proto libs: - name: address_sorting build: all @@ -4608,8 +4585,6 @@ targets: - gpr filegroups: - grpcpp_channelz_proto - uses: - - grpc++_test - name: channelz_registry_test gtest: true build: test @@ -4622,8 +4597,6 @@ targets: - grpc++ - grpc - gpr - uses: - - grpc++_test uses_polling: false - name: channelz_service_test gtest: true @@ -4654,8 +4627,6 @@ targets: - gpr filegroups: - grpcpp_channelz_proto - uses: - - grpc++_test - name: check_gcp_environment_linux_test build: test language: c++ @@ -5054,8 +5025,6 @@ targets: - grpc++ - grpc - gpr - uses: - - grpc++_test uses_polling: false - name: grpc_cpp_plugin build: protoc @@ -5146,8 +5115,6 @@ targets: - grpc++ - grpc - gpr - uses: - - grpc++_test - name: grpc_tool_test gtest: true build: test @@ -5222,8 +5189,6 @@ targets: - grpc++ - grpc - gpr - uses: - - grpc++_test - name: h2_ssl_session_reuse_test gtest: true build: test @@ -5237,8 +5202,6 @@ targets: - grpc++ - grpc - gpr - uses: - - grpc++_test - name: health_service_end2end_test gtest: true build: test @@ -5290,8 +5253,6 @@ targets: - grpc++ - grpc - gpr - uses: - - grpc++_test - name: inproc_sync_unary_ping_pong_test build: test language: c++ @@ -5390,8 +5351,6 @@ targets: - grpc++ - grpc - gpr - uses: - - grpc++_test uses_polling: false - name: message_allocator_end2end_test gtest: true @@ -5466,8 +5425,6 @@ targets: - grpc++ - grpc - gpr - uses: - - grpc++_test - name: orphanable_test gtest: true build: test @@ -5479,8 +5436,6 @@ targets: - grpc++ - grpc - gpr - uses: - - grpc++_test - name: port_sharing_end2end_test gtest: true build: test @@ -5649,8 +5604,6 @@ targets: - grpc++ - grpc - gpr - uses: - - grpc++_test - name: ref_counted_test gtest: true build: test @@ -5662,8 +5615,6 @@ targets: - grpc++ - grpc - gpr - uses: - - grpc++_test - name: retry_throttle_test gtest: true build: test @@ -5758,8 +5709,6 @@ targets: - grpc++ - grpc - gpr - uses: - - grpc++_test - name: server_crash_test gtest: true cpu_cost: 0.1 @@ -5855,8 +5804,6 @@ targets: - grpc++ - grpc - gpr - uses: - - grpc++_test - name: shutdown_test gtest: true build: test @@ -5978,8 +5925,6 @@ targets: - grpc++ - grpc - gpr - uses: - - grpc++_test - name: thread_manager_test build: test language: c++ diff --git a/src/benchmark/gen_build_yaml.py b/src/benchmark/gen_build_yaml.py index 4d9391a91f5..a1f777d6c2b 100755 --- a/src/benchmark/gen_build_yaml.py +++ b/src/benchmark/gen_build_yaml.py @@ -27,7 +27,7 @@ out['libs'] = [{ 'name': 'benchmark', 'build': 'private', 'language': 'c++', - 'secure': 'no', + 'secure': False, 'defaults': 'benchmark', 'src': sorted(glob.glob('third_party/benchmark/src/*.cc')), 'headers': sorted( diff --git a/src/boringssl/gen_build_yaml.py b/src/boringssl/gen_build_yaml.py index c25a4ed3c94..145cc67b0d1 100755 --- a/src/boringssl/gen_build_yaml.py +++ b/src/boringssl/gen_build_yaml.py @@ -61,7 +61,7 @@ class Grpc(object): 'name': 'boringssl', 'build': 'private', 'language': 'c', - 'secure': 'no', + 'secure': False, 'src': sorted( map_dir(f) for f in files['ssl'] + files['crypto'] @@ -79,7 +79,7 @@ class Grpc(object): 'name': 'boringssl_test_util', 'build': 'private', 'language': 'c++', - 'secure': 'no', + 'secure': False, 'boringssl': True, 'defaults': 'boringssl', 'src': [ @@ -93,7 +93,7 @@ class Grpc(object): 'name': 'boringssl_%s' % test, 'build': 'test', 'run': False, - 'secure': 'no', + 'secure': False, 'language': 'c++', 'src': sorted(map_dir(f) for f in files[test]), 'vs_proj_dir': 'test/boringssl', diff --git a/src/c-ares/gen_build_yaml.py b/src/c-ares/gen_build_yaml.py index 6e832edcea3..fe2ecb462c3 100755 --- a/src/c-ares/gen_build_yaml.py +++ b/src/c-ares/gen_build_yaml.py @@ -53,7 +53,7 @@ try: 'defaults': 'ares', 'build': 'private', 'language': 'c', - 'secure': 'no', + 'secure': False, 'src': [ "third_party/cares/cares/ares__close_sockets.c", "third_party/cares/cares/ares__get_hostent.c", diff --git a/src/objective-c/tests/run_one_test_bazel.sh b/src/objective-c/tests/run_one_test_bazel.sh index 8f920d955fd..09da7bfbd59 100755 --- a/src/objective-c/tests/run_one_test_bazel.sh +++ b/src/objective-c/tests/run_one_test_bazel.sh @@ -48,4 +48,4 @@ $INTEROP --port=$TLS_PORT --max_send_message_size=8388608 --use_tls & trap 'kill -9 `jobs -p` ; echo "EXIT TIME: $(date)"' EXIT -../../../tools/bazel run $SCHEME \ No newline at end of file +../../../tools/bazel run $SCHEME diff --git a/src/zlib/gen_build_yaml.py b/src/zlib/gen_build_yaml.py index d0912b9cb62..ee347e0b1f3 100755 --- a/src/zlib/gen_build_yaml.py +++ b/src/zlib/gen_build_yaml.py @@ -42,7 +42,7 @@ try: 'defaults': 'zlib', 'build': 'private', 'language': 'c', - 'secure': 'no', + 'secure': False, 'src': sorted(cmvar('ZLIB_SRCS')), 'headers': sorted(cmvar('ZLIB_PUBLIC_HDRS') + cmvar('ZLIB_PRIVATE_HDRS')), }] diff --git a/test/core/bad_client/gen_build_yaml.py b/test/core/bad_client/gen_build_yaml.py index e390db90e15..3224dfe3877 100755 --- a/test/core/bad_client/gen_build_yaml.py +++ b/test/core/bad_client/gen_build_yaml.py @@ -68,7 +68,7 @@ def main(): 'cpu_cost': BAD_CLIENT_TESTS[t].cpu_cost, 'build': 'test', 'language': 'c++', - 'secure': 'no', + 'secure': False, 'src': ['test/core/bad_client/tests/%s.cc' % t], 'vs_proj_dir': 'test', 'exclude_iomgrs': ['uv'], diff --git a/tools/buildgen/plugins/check_attrs.py b/tools/buildgen/plugins/check_attrs.py new file mode 100644 index 00000000000..0730f8a1bbb --- /dev/null +++ b/tools/buildgen/plugins/check_attrs.py @@ -0,0 +1,126 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Buildgen attribute validation plugin.""" + + +def anything(): + return lambda v: None + + +def one_of(values): + return lambda v: ('{0} is not in [{1}]'.format(v, values) if v not in values else None) + + +def subset_of(values): + return lambda v: ('{0} is not subset of [{1}]'.format(v, values) + if not all(e in values for e in v) else None) + + +VALID_ATTRIBUTE_KEYS_MAP = { + 'filegroup': { + 'deps': anything(), + 'headers': anything(), + 'plugin': anything(), + 'public_headers': anything(), + 'src': anything(), + 'uses': anything(), + }, + 'lib': { + 'baselib': anything(), + 'boringssl': one_of((True,)), + 'build_system': anything(), + 'build': anything(), + 'defaults': anything(), + 'deps_linkage': one_of(('static',)), + 'deps': anything(), + 'dll': one_of((True, 'only')), + 'filegroups': anything(), + 'generate_plugin_registry': anything(), + 'headers': anything(), + 'language': one_of(('c', 'c++', 'csharp')), + 'LDFLAGS': anything(), + 'platforms': subset_of(('linux', 'mac', 'posix', 'windows')), + 'public_headers': anything(), + 'secure': one_of(('check', True, False)), + 'src': anything(), + 'vs_proj_dir': anything(), + 'zlib': one_of((True,)), + }, + 'target': { + 'args': anything(), + 'benchmark': anything(), + 'boringssl': one_of((True,)), + 'build': anything(), + 'ci_platforms': anything(), + 'corpus_dirs': anything(), + 'cpu_cost': anything(), + 'defaults': anything(), + 'deps': anything(), + 'dict': anything(), + 'exclude_configs': anything(), + 'exclude_iomgrs': anything(), + 'excluded_poll_engines': anything(), + 'filegroups': anything(), + 'flaky': one_of((True, False)), + 'gtest': one_of((True, False)), + 'headers': anything(), + 'language': one_of(('c', 'c89', 'c++', 'csharp')), + 'maxlen': anything(), + 'platforms': subset_of(('linux', 'mac', 'posix', 'windows')), + 'run': one_of((True, False)), + 'secure': one_of(('check', True, False)), + 'src': anything(), + 'timeout_seconds': anything(), + 'uses_polling': anything(), + 'vs_proj_dir': anything(), + 'zlib': one_of((True,)), + }, +} + + +def check_attributes(entity, kind, errors): + attributes = VALID_ATTRIBUTE_KEYS_MAP[kind] + name = entity.get('name', anything()) + for key, value in entity.items(): + if key == 'name': + continue + validator = attributes.get(key) + if validator: + error = validator(value) + if error: + errors.append( + "{0}({1}) has an invalid value for '{2}': {3}".format( + name, kind, key, error)) + else: + errors.append("{0}({1}) has an invalid attribute '{2}'".format( + name, kind, key)) + + +def mako_plugin(dictionary): + """The exported plugin code for check_attr. + + This validates that filegroups, libs, and target can have only valid + attributes. This is mainly for preventing build.yaml from having + unnecessary and misleading attributes accidently. + """ + + errors = [] + for filegroup in dictionary.get('filegroups', {}): + check_attributes(filegroup, 'filegroup', errors) + for lib in dictionary.get('libs', {}): + check_attributes(lib, 'lib', errors) + for target in dictionary.get('targets', {}): + check_attributes(target, 'target', errors) + if errors: + raise Exception('\n'.join(errors)) From 1391c93a95cc8efeca80ecefe69697418dcb3354 Mon Sep 17 00:00:00 2001 From: Qiancheng Zhao Date: Fri, 16 Aug 2019 14:15:21 -0700 Subject: [PATCH 1272/1555] atomic client idle filter --- include/grpc/impl/codegen/grpc_types.h | 6 +- .../filters/client_idle/client_idle_filter.cc | 234 +++++++++++++++--- .../channel/minimal_stack_is_minimal_test.cc | 4 +- test/cpp/end2end/client_lb_end2end_test.cc | 4 +- 4 files changed, 210 insertions(+), 38 deletions(-) diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 68ae3606e80..8108b853fca 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -169,11 +169,7 @@ typedef struct { #define GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS "grpc.max_connection_age_grace_ms" /** Timeout after the last RPC finishes on the client channel at which the * channel goes back into IDLE state. Int valued, milliseconds. INT_MAX means - * unlimited. */ -/** TODO(qianchengz): Currently the default value is INT_MAX, which means the - * client idle filter is disabled by default. After the client idle filter - * proves no perfomance issue, we will change the default value to a reasonable - * value. */ + * unlimited. The default value is 30 minutes and the min value is 1 second. */ #define GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS "grpc.client_idle_timeout_ms" /** Enable/disable support for per-message compression. Defaults to 1, unless GRPC_ARG_MINIMAL_STACK is enabled, in which case it defaults to 0. */ diff --git a/src/core/ext/filters/client_idle/client_idle_filter.cc b/src/core/ext/filters/client_idle/client_idle_filter.cc index d2b23a9d20f..13c35ae3730 100644 --- a/src/core/ext/filters/client_idle/client_idle_filter.cc +++ b/src/core/ext/filters/client_idle/client_idle_filter.cc @@ -27,12 +27,12 @@ #include "src/core/lib/surface/channel_init.h" #include "src/core/lib/transport/http2_errors.h" -// The idle filter is disabled in client channel by default. -// To enable the idle filte, set GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS to [0, INT_MAX) -// in channel args. -// TODO(qianchengz): Find a reasonable default value. Maybe check what deault -// value Java uses. -#define DEFAULT_IDLE_TIMEOUT_MS INT_MAX +// The idle filter is enabled in client channel by default. +// Set GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS to [1000, INT_MAX) in channel args to +// configure the idle timeout. +#define DEFAULT_IDLE_TIMEOUT_MS (30 /*minutes*/ * 60 * 1000) +// The user input idle timeout smaller than this would be capped to it. +#define MIN_IDLE_TIMEOUT_MS (1 /*second*/ * 1000) namespace grpc_core { @@ -47,10 +47,82 @@ TraceFlag grpc_trace_client_idle_filter(false, "client_idle_filter"); namespace { +/* + client_idle_filter maintains a state tracking if there are active calls in the + channel and its internal idle_timer_. The states are specified as following: + + +--------------------------------------------+-------------+---------+ + | ChannelState | idle_timer_ | channel | + +--------------------------------------------+-------------+---------+ + | IDLE | unset | idle | + | CALLS_ACTIVE | unset | busy | + | TIMER_PENDING | set-valid | idle | + | TIMER_PENDING_CALLS_ACTIVE | set-invalid | busy | + | TIMER_PENDING_CALLS_SEEN_SINCE_TIMER_START | set-invalid | idle | + +--------------------------------------------+-------------+---------+ + + IDLE: The initial state of the client_idle_filter, indicating the channel is + in IDLE. + + CALLS_ACTIVE: The channel has 1 or 1+ active calls and the timer is not set. + + TIMER_PENDING: The state after the timer is set and no calls have arrived + after the timer is set. The channel must have 0 active call in this state. If + the timer is fired in this state, the channel will go into IDLE state. + + TIMER_PENDING_CALLS_ACTIVE: The state after the timer is set and at least one + call has arrived after the timer is set. The channel must have 1 or 1+ active + calls in this state. If the timer is fired in this state, we won't reschedule + it. + + TIMER_PENDING_CALLS_SEEN_SINCE_TIMER_START: The state after the timer is set + and at least one call has arrived after the timer is set, BUT the channel + currently has 0 active call. If the timer is fired in this state, we will + reschedule it according to the finish time of the latest call. + + PROCESSING: The state set to block other threads when the setting thread is + doing some work to keep state consistency. + + idle_timer_ will not be cancelled (unless the channel is shutting down). + If the timer callback is called when the idle_timer_ is valid (i.e. idle_state + is TIMER_PENDING), the channel will enter IDLE, otherwise the channel won't be + changed. + + State transitions: + IDLE + | ^ + --------------------------------- * + | * + v * + CALLS_ACTIVE =================> TIMER_PENDING + ^ | ^ + * ------------------------------ * + * | * + * v * +TIMER_PENDING_CALLS_ACTIVE ===> TIMER_PENDING_CALLS_SEEN_SINCE_TIMER_START + ^ | + | | + --------------------------------- + + ---> Triggered by IncreaseCallCount() + ===> Triggered by DecreaseCallCount() + ***> Triggered by IdleTimerCallback() +*/ +enum ChannelState { + IDLE, + CALLS_ACTIVE, + TIMER_PENDING, + TIMER_PENDING_CALLS_ACTIVE, + TIMER_PENDING_CALLS_SEEN_SINCE_TIMER_START, + PROCESSING +}; + grpc_millis GetClientIdleTimeout(const grpc_channel_args* args) { - return grpc_channel_arg_get_integer( - grpc_channel_args_find(args, GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS), - {DEFAULT_IDLE_TIMEOUT_MS, 0, INT_MAX}); + return GPR_MAX( + grpc_channel_arg_get_integer( + grpc_channel_args_find(args, GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS), + {DEFAULT_IDLE_TIMEOUT_MS, 0, INT_MAX}), + MIN_IDLE_TIMEOUT_MS); } class ChannelData { @@ -86,8 +158,9 @@ class ChannelData { const grpc_millis client_idle_timeout_; // Member data used to track the state of channel. - Mutex call_count_mu_; - size_t call_count_; + grpc_millis last_idle_time_; + Atomic call_count_{0}; + Atomic state_{IDLE}; // Idle timer and its callback closure. grpc_timer idle_timer_; @@ -115,37 +188,105 @@ void ChannelData::StartTransportOp(grpc_channel_element* elem, ChannelData* chand = static_cast(elem->channel_data); // Catch the disconnect_with_error transport op. if (op->disconnect_with_error != nullptr) { - // Disconnect. Cancel the timer if we set it before. - // IncreaseCallCount() introduces a dummy call. It will cancel the timer and - // prevent the timer from being reset by other threads. + // IncreaseCallCount() introduces a dummy call and prevent the timer from + // being reset by other threads. chand->IncreaseCallCount(); + // If the timer has been set, cancel the timer. + // No synchronization issues here. grpc_timer_cancel() is valid as long as + // the timer has been init()ed before. + grpc_timer_cancel(&chand->idle_timer_); } // Pass the op to the next filter. grpc_channel_next_op(elem, op); } void ChannelData::IncreaseCallCount() { - MutexLock lock(&call_count_mu_); - if (call_count_++ == 0) { - grpc_timer_cancel(&idle_timer_); + const intptr_t previous_value = call_count_.FetchAdd(1, MemoryOrder::RELAXED); + GRPC_IDLE_FILTER_LOG("call counter has increased to %" PRIuPTR, + previous_value + 1); + if (previous_value == 0) { + // This call is the one that makes the channel busy. + // Loop here to make sure the previous decrease operation has finished. + ChannelState state = state_.Load(MemoryOrder::RELAXED); + while (true) { + switch (state) { + // Timer has not been set. Switch to CALLS_ACTIVE. + case IDLE: + // In this case, no other threads will modify the state, so we can + // just store the value. + state_.Store(CALLS_ACTIVE, MemoryOrder::RELAXED); + return; + // Timer has been set. Switch to TIMER_PENDING_CALLS_ACTIVE. + case TIMER_PENDING: + case TIMER_PENDING_CALLS_SEEN_SINCE_TIMER_START: + // At this point, the state may have been switched to IDLE by the + // idle timer callback. Therefore, use CAS operation to change the + // state atomically. + // Use MemoryOrder::ACQUIRE on success to ensure last_idle_time_ has + // been properly set in DecreaseCallCount(). + if (state_.CompareExchangeWeak(&state, TIMER_PENDING_CALLS_ACTIVE, + MemoryOrder::ACQUIRE, + MemoryOrder::RELAXED)) { + return; + } + break; + default: + // The state has not been switched to desired value yet, try again. + state = state_.Load(MemoryOrder::RELAXED); + break; + } + } } - GRPC_IDLE_FILTER_LOG("call counter has increased to %" PRIuPTR, call_count_); } void ChannelData::DecreaseCallCount() { - MutexLock lock(&call_count_mu_); - if (call_count_-- == 1) { - StartIdleTimer(); + const intptr_t previous_value = call_count_.FetchSub(1, MemoryOrder::RELAXED); + GRPC_IDLE_FILTER_LOG("call counter has decreased to %" PRIuPTR, + previous_value - 1); + if (previous_value == 1) { + // This call is the one that makes the channel idle. + // last_idle_time_ does not need to be Atomic<> because busy-loops in + // IncreaseCallCount(), DecreaseCallCount() and IdleTimerCallback() will + // prevent multiple threads from simultaneously accessing this variable. + last_idle_time_ = ExecCtx::Get()->Now(); + ChannelState state = state_.Load(MemoryOrder::RELAXED); + while (true) { + switch (state) { + // Timer has not been set. Set the timer and switch to TIMER_PENDING + case CALLS_ACTIVE: + // Release store here to make other threads see the updated value of + // last_idle_time_. + StartIdleTimer(); + state_.Store(TIMER_PENDING, MemoryOrder::RELEASE); + return; + // Timer has been set. Switch to + // TIMER_PENDING_CALLS_SEEN_SINCE_TIMER_START + case TIMER_PENDING_CALLS_ACTIVE: + // At this point, the state may have been switched to CALLS_ACTIVE by + // the idle timer callback. Therefore, use CAS operation to change the + // state atomically. + // Release store here to make the idle timer callback see the updated + // value of last_idle_time_ to properly reset the idle timer. + if (state_.CompareExchangeWeak( + &state, TIMER_PENDING_CALLS_SEEN_SINCE_TIMER_START, + MemoryOrder::RELEASE, MemoryOrder::RELAXED)) { + return; + } + break; + default: + // The state has not been switched to desired value yet, try again. + state = state_.Load(MemoryOrder::RELAXED); + break; + } + } } - GRPC_IDLE_FILTER_LOG("call counter has decreased to %" PRIuPTR, call_count_); } ChannelData::ChannelData(grpc_channel_element* elem, grpc_channel_element_args* args, grpc_error** error) : elem_(elem), channel_stack_(args->channel_stack), - client_idle_timeout_(GetClientIdleTimeout(args->channel_args)), - call_count_(0) { + client_idle_timeout_(GetClientIdleTimeout(args->channel_args)) { // If the idle filter is explicitly disabled in channel args, this ctor should // not get called. GPR_ASSERT(client_idle_timeout_ != GRPC_MILLIS_INF_FUTURE); @@ -165,10 +306,45 @@ ChannelData::ChannelData(grpc_channel_element* elem, void ChannelData::IdleTimerCallback(void* arg, grpc_error* error) { GRPC_IDLE_FILTER_LOG("timer alarms"); ChannelData* chand = static_cast(arg); - { - MutexLock lock(&chand->call_count_mu_); - if (error == GRPC_ERROR_NONE && chand->call_count_ == 0) { - chand->EnterIdle(); + if (error != GRPC_ERROR_NONE) { + GRPC_IDLE_FILTER_LOG("timer canceled"); + GRPC_CHANNEL_STACK_UNREF(chand->channel_stack_, "max idle timer callback"); + return; + } + bool finished = false; + ChannelState state = chand->state_.Load(MemoryOrder::RELAXED); + while (!finished) { + switch (state) { + case TIMER_PENDING: + // Change the state to PROCESSING to block IncreaseCallCout() until the + // EnterIdle() operation finishes, preventing mistakenly entering IDLE + // when active RPC exists. + finished = chand->state_.CompareExchangeWeak( + &state, PROCESSING, MemoryOrder::RELAXED, MemoryOrder::RELAXED); + if (finished) { + chand->EnterIdle(); + chand->state_.Store(IDLE, MemoryOrder::RELAXED); + } + break; + case TIMER_PENDING_CALLS_ACTIVE: + finished = chand->state_.CompareExchangeWeak( + &state, CALLS_ACTIVE, MemoryOrder::RELAXED, MemoryOrder::RELAXED); + break; + case TIMER_PENDING_CALLS_SEEN_SINCE_TIMER_START: + // Change the state to PROCESSING to block IncreaseCallCount() until the + // StartIdleTimer() operation finishes, preventing mistakenly restarting + // the timer after grpc_timer_cancel() when shutdown. + finished = chand->state_.CompareExchangeWeak( + &state, PROCESSING, MemoryOrder::ACQUIRE, MemoryOrder::RELAXED); + if (finished) { + chand->StartIdleTimer(); + chand->state_.Store(TIMER_PENDING, MemoryOrder::RELAXED); + } + break; + default: + // The state has not been switched to desired value yet, try again. + state = chand->state_.Load(MemoryOrder::RELAXED); + break; } } GRPC_IDLE_FILTER_LOG("timer finishes"); @@ -185,7 +361,7 @@ void ChannelData::StartIdleTimer() { GRPC_IDLE_FILTER_LOG("timer has started"); // Hold a ref to the channel stack for the timer callback. GRPC_CHANNEL_STACK_REF(channel_stack_, "max idle timer callback"); - grpc_timer_init(&idle_timer_, ExecCtx::Get()->Now() + client_idle_timeout_, + grpc_timer_init(&idle_timer_, last_idle_time_ + client_idle_timeout_, &idle_timer_callback_); } diff --git a/test/core/channel/minimal_stack_is_minimal_test.cc b/test/core/channel/minimal_stack_is_minimal_test.cc index bee0bfb41f2..3ca1992195b 100644 --- a/test/core/channel/minimal_stack_is_minimal_test.cc +++ b/test/core/channel/minimal_stack_is_minimal_test.cc @@ -100,8 +100,8 @@ int main(int argc, char** argv) { errors += CHECK_STACK("chttp2", nullptr, GRPC_SERVER_CHANNEL, "server", "message_size", "deadline", "http-server", "message_compress", "connected", NULL); - errors += CHECK_STACK(nullptr, nullptr, GRPC_CLIENT_CHANNEL, "client-channel", - NULL); + errors += CHECK_STACK(nullptr, nullptr, GRPC_CLIENT_CHANNEL, + "client_idle, client-channel", NULL); GPR_ASSERT(errors == 0); grpc_shutdown(); diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index dac7860141c..ceab7506729 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -1471,7 +1471,7 @@ TEST_F(ClientLbEnd2endTest, ChannelIdleness) { StartServers(kNumServers); // Set max idle time and build the channel. ChannelArguments args; - args.SetInt(GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS, 100); + args.SetInt(GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS, 1000); auto response_generator = BuildResolverResponseGenerator(); auto channel = BuildChannel("", response_generator, args); auto stub = BuildStub(channel); @@ -1483,7 +1483,7 @@ TEST_F(ClientLbEnd2endTest, ChannelIdleness) { EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); // After a period time not using the channel, the channel state should switch // to IDLE. - gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(120)); + gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(1200)); EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_IDLE); // Sending a new RPC should awake the IDLE channel. response_generator.SetNextResolution(GetServersPorts()); From 40fe76ad307626c441563b4d12640ce683da01c4 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 16 Aug 2019 14:17:05 -0700 Subject: [PATCH 1273/1555] Fix import --- src/python/grpcio/grpc/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index f96ca270dc0..aa47316b448 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -22,7 +22,6 @@ import six from grpc._cython import cygrpc as _cygrpc from grpc import _compression -from grpc import local_credentials logging.getLogger(__name__).addHandler(logging.NullHandler()) From 96a7b68edc49166b23d6ab743bd69fd8afda1328 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 16 Aug 2019 14:20:20 -0700 Subject: [PATCH 1274/1555] Ignore Visual Studio Code configurations --- .gitignore | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.gitignore b/.gitignore index 4a400b4e3b4..63ba8f53705 100644 --- a/.gitignore +++ b/.gitignore @@ -139,10 +139,6 @@ bm_*.json # Visual Studio Code artifacts .vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json # Clion artifacts cmake-build-debug/ From 64dd53273252db24662b93d4e3408c58bfc000f4 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 16 Aug 2019 14:55:48 -0700 Subject: [PATCH 1275/1555] Make _api_test.py happy --- src/python/grpcio_tests/tests/unit/_api_test.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/python/grpcio_tests/tests/unit/_api_test.py b/src/python/grpcio_tests/tests/unit/_api_test.py index 127dab336bf..cc0daba2098 100644 --- a/src/python/grpcio_tests/tests/unit/_api_test.py +++ b/src/python/grpcio_tests/tests/unit/_api_test.py @@ -60,6 +60,9 @@ class AllTest(unittest.TestCase): 'ServiceRpcHandler', 'Server', 'ServerInterceptor', + 'LocalConnectionType', + 'local_channel_credentials', + 'local_server_credentials', 'unary_unary_rpc_method_handler', 'unary_stream_rpc_method_handler', 'stream_unary_rpc_method_handler', From a802b14be6d8ed0fabfbf7a1df1607116a238f64 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Fri, 16 Aug 2019 15:09:32 -0700 Subject: [PATCH 1276/1555] Add xds resolver --- BUILD | 13 +++ BUILD.gn | 1 + CMakeLists.txt | 2 + Makefile | 2 + build.yaml | 9 ++ config.m4 | 2 + config.w32 | 2 + gRPC-Core.podspec | 1 + grpc.gemspec | 1 + grpc.gyp | 2 + package.xml | 1 + .../client_channel/lb_policy/xds/xds.cc | 5 +- .../resolver/xds/xds_resolver.cc | 89 +++++++++++++++++++ .../plugin_registry/grpc_plugin_registry.cc | 4 + .../grpc_unsecure_plugin_registry.cc | 4 + src/python/grpcio/grpc_core_dependencies.py | 1 + .../client_channel/service_config_test.cc | 22 ----- test/cpp/end2end/xds_end2end_test.cc | 20 ++++- tools/doxygen/Doxyfile.core.internal | 1 + 19 files changed, 154 insertions(+), 28 deletions(-) create mode 100644 src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc diff --git a/BUILD b/BUILD index d5e863c552d..c510757c35d 100644 --- a/BUILD +++ b/BUILD @@ -991,6 +991,7 @@ grpc_cc_library( "grpc_resolver_fake", "grpc_resolver_dns_native", "grpc_resolver_sockaddr", + "grpc_resolver_xds", "grpc_transport_chttp2_client_insecure", "grpc_transport_chttp2_server_insecure", "grpc_transport_inproc", @@ -1527,6 +1528,18 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "grpc_resolver_xds", + srcs = [ + "src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc", + ], + language = "c++", + deps = [ + "grpc_base", + "grpc_client_channel", + ], +) + grpc_cc_library( name = "grpc_secure", srcs = [ diff --git a/BUILD.gn b/BUILD.gn index 18204a17c33..1b157427087 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -305,6 +305,7 @@ config("grpc_config") { "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc", "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h", "src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc", + "src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc", "src/core/ext/filters/client_channel/resolver_factory.h", "src/core/ext/filters/client_channel/resolver_registry.cc", "src/core/ext/filters/client_channel/resolver_registry.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b6dba6dedb..86a77c95663 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1368,6 +1368,7 @@ add_library(grpc src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc + src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc src/core/ext/filters/census/grpc_context.cc src/core/ext/filters/client_idle/client_idle_filter.cc src/core/ext/filters/max_age/max_age_filter.cc @@ -2808,6 +2809,7 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc + src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc diff --git a/Makefile b/Makefile index 8080efcc41a..a0692f38d20 100644 --- a/Makefile +++ b/Makefile @@ -3891,6 +3891,7 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ + src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc \ src/core/ext/filters/census/grpc_context.cc \ src/core/ext/filters/client_idle/client_idle_filter.cc \ src/core/ext/filters/max_age/max_age_filter.cc \ @@ -5255,6 +5256,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ + src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc \ diff --git a/build.yaml b/build.yaml index 87ca412d12f..7431dbb2a53 100644 --- a/build.yaml +++ b/build.yaml @@ -1224,6 +1224,13 @@ filegroups: uses: - grpc_base - grpc_client_channel +- name: grpc_resolver_xds + src: + - src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc + plugin: grpc_resolver_xds + uses: + - grpc_base + - grpc_client_channel - name: grpc_secure public_headers: - include/grpc/grpc_security.h @@ -1672,6 +1679,7 @@ libs: - grpc_resolver_dns_native - grpc_resolver_sockaddr - grpc_resolver_fake + - grpc_resolver_xds - grpc_secure - census - grpc_client_idle_filter @@ -1743,6 +1751,7 @@ libs: - grpc_resolver_dns_native - grpc_resolver_sockaddr - grpc_resolver_fake + - grpc_resolver_xds - grpc_lb_policy_grpclb - grpc_lb_policy_xds - grpc_lb_policy_pick_first diff --git a/config.m4 b/config.m4 index 72fd381fd53..2a074768f57 100644 --- a/config.m4 +++ b/config.m4 @@ -447,6 +447,7 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ + src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc \ src/core/ext/filters/census/grpc_context.cc \ src/core/ext/filters/client_idle/client_idle_filter.cc \ src/core/ext/filters/max_age/max_age_filter.cc \ @@ -732,6 +733,7 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns/native) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/fake) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/sockaddr) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/xds) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_idle) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/deadline) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http) diff --git a/config.w32 b/config.w32 index a2d0d0f6abf..065da74bfb9 100644 --- a/config.w32 +++ b/config.w32 @@ -420,6 +420,7 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\dns_resolver_selection.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\native\\dns_resolver.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\sockaddr\\sockaddr_resolver.cc " + + "src\\core\\ext\\filters\\client_channel\\resolver\\xds\\xds_resolver.cc " + "src\\core\\ext\\filters\\census\\grpc_context.cc " + "src\\core\\ext\\filters\\client_idle\\client_idle_filter.cc " + "src\\core\\ext\\filters\\max_age\\max_age_filter.cc " + @@ -738,6 +739,7 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\resolver\\dns\\native"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\resolver\\fake"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\resolver\\sockaddr"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\resolver\\xds"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_idle"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\deadline"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\http"); diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 2a35ca35fb5..3244e9d08f9 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -945,6 +945,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', + 'src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc', 'src/core/ext/filters/census/grpc_context.cc', 'src/core/ext/filters/client_idle/client_idle_filter.cc', 'src/core/ext/filters/max_age/max_age_filter.cc', diff --git a/grpc.gemspec b/grpc.gemspec index c817006b125..5a29165c92d 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -874,6 +874,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc ) + s.files += %w( src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc ) s.files += %w( src/core/ext/filters/census/grpc_context.cc ) s.files += %w( src/core/ext/filters/client_idle/client_idle_filter.cc ) s.files += %w( src/core/ext/filters/max_age/max_age_filter.cc ) diff --git a/grpc.gyp b/grpc.gyp index 173aef52a79..ba847d99548 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -657,6 +657,7 @@ 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', + 'src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc', 'src/core/ext/filters/census/grpc_context.cc', 'src/core/ext/filters/client_idle/client_idle_filter.cc', 'src/core/ext/filters/max_age/max_age_filter.cc', @@ -1434,6 +1435,7 @@ 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', + 'src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc', diff --git a/package.xml b/package.xml index 979bc465a75..196c6a6d7db 100644 --- a/package.xml +++ b/package.xml @@ -879,6 +879,7 @@ + diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index 11bbb72a367..75fa544c80a 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -1832,6 +1832,7 @@ void XdsLb::ProcessAddressesAndChannelArgsLocked( void XdsLb::ParseLbConfig(const ParsedXdsConfig* xds_config) { if (xds_config == nullptr || xds_config->balancer_name() == nullptr) return; // TODO(yashykt) : does this need to be a gpr_strdup + // TODO(juanlishen): Read balancer name from bootstrap file. balancer_name_ = UniquePtr(gpr_strdup(xds_config->balancer_name())); child_policy_config_ = xds_config->child_policy(); fallback_policy_config_ = xds_config->fallback_policy(); @@ -2588,10 +2589,6 @@ class XdsFactory : public LoadBalancingPolicyFactory { } } } - if (balancer_name == nullptr) { - error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "field:balancerName error:not found")); - } if (error_list.empty()) { return RefCountedPtr(New( balancer_name, std::move(child_policy), std::move(fallback_policy))); diff --git a/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc b/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc new file mode 100644 index 00000000000..8be1b89eee0 --- /dev/null +++ b/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc @@ -0,0 +1,89 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/ext/filters/client_channel/resolver_registry.h" + +namespace grpc_core { + +namespace { + +class XdsResolver : public Resolver { + public: + explicit XdsResolver(ResolverArgs args) + : Resolver(args.combiner, std::move(args.result_handler)), + args_(grpc_channel_args_copy(args.args)) {} + ~XdsResolver() override { grpc_channel_args_destroy(args_); } + + void StartLocked() override; + + void ShutdownLocked() override{}; + + private: + const grpc_channel_args* args_; +}; + +void XdsResolver::StartLocked() { + static const char* service_config = + "{\n" + " \"loadBalancingConfig\":[\n" + " { \"xds_experimental\":{} }\n" + " ]\n" + "}"; + Result result; + result.args = args_; + args_ = nullptr; + grpc_error* error = GRPC_ERROR_NONE; + result.service_config = ServiceConfig::Create(service_config, &error); + result_handler()->ReturnResult(std::move(result)); +} + +// +// Factory +// + +class XdsResolverFactory : public ResolverFactory { + public: + bool IsValidUri(const grpc_uri* uri) const override { + if (GPR_UNLIKELY(0 != strcmp(uri->authority, ""))) { + gpr_log(GPR_ERROR, "URI authority not supported"); + return false; + } + return true; + } + + OrphanablePtr CreateResolver(ResolverArgs args) const override { + if (!IsValidUri(args.uri)) return nullptr; + return OrphanablePtr(New(std::move(args))); + } + + const char* scheme() const override { return "xds-experimental"; } +}; + +} // namespace + +} // namespace grpc_core + +void grpc_resolver_xds_init() { + grpc_core::ResolverRegistry::Builder::RegisterResolverFactory( + grpc_core::UniquePtr( + grpc_core::New())); +} + +void grpc_resolver_xds_shutdown() {} diff --git a/src/core/plugin_registry/grpc_plugin_registry.cc b/src/core/plugin_registry/grpc_plugin_registry.cc index 9b011d8df0f..ebe3def245a 100644 --- a/src/core/plugin_registry/grpc_plugin_registry.cc +++ b/src/core/plugin_registry/grpc_plugin_registry.cc @@ -46,6 +46,8 @@ void grpc_resolver_dns_native_init(void); void grpc_resolver_dns_native_shutdown(void); void grpc_resolver_sockaddr_init(void); void grpc_resolver_sockaddr_shutdown(void); +void grpc_resolver_xds_init(void); +void grpc_resolver_xds_shutdown(void); void grpc_client_idle_filter_init(void); void grpc_client_idle_filter_shutdown(void); void grpc_max_age_filter_init(void); @@ -84,6 +86,8 @@ void grpc_register_built_in_plugins(void) { grpc_resolver_dns_native_shutdown); grpc_register_plugin(grpc_resolver_sockaddr_init, grpc_resolver_sockaddr_shutdown); + grpc_register_plugin(grpc_resolver_xds_init, + grpc_resolver_xds_shutdown); grpc_register_plugin(grpc_client_idle_filter_init, grpc_client_idle_filter_shutdown); grpc_register_plugin(grpc_max_age_filter_init, diff --git a/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc b/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc index 055c3ccc134..6668836f02f 100644 --- a/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc +++ b/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc @@ -38,6 +38,8 @@ void grpc_resolver_sockaddr_init(void); void grpc_resolver_sockaddr_shutdown(void); void grpc_resolver_fake_init(void); void grpc_resolver_fake_shutdown(void); +void grpc_resolver_xds_init(void); +void grpc_resolver_xds_shutdown(void); void grpc_lb_policy_grpclb_init(void); void grpc_lb_policy_grpclb_shutdown(void); void grpc_lb_policy_xds_init(void); @@ -76,6 +78,8 @@ void grpc_register_built_in_plugins(void) { grpc_resolver_sockaddr_shutdown); grpc_register_plugin(grpc_resolver_fake_init, grpc_resolver_fake_shutdown); + grpc_register_plugin(grpc_resolver_xds_init, + grpc_resolver_xds_shutdown); grpc_register_plugin(grpc_lb_policy_grpclb_init, grpc_lb_policy_grpclb_shutdown); grpc_register_plugin(grpc_lb_policy_xds_init, diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 58c1fd3daba..607235556e3 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -419,6 +419,7 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', + 'src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc', 'src/core/ext/filters/census/grpc_context.cc', 'src/core/ext/filters/client_idle/client_idle_filter.cc', 'src/core/ext/filters/max_age/max_age_filter.cc', diff --git a/test/core/client_channel/service_config_test.cc b/test/core/client_channel/service_config_test.cc index 919441d706a..79dde6bcabe 100644 --- a/test/core/client_channel/service_config_test.cc +++ b/test/core/client_channel/service_config_test.cc @@ -457,28 +457,6 @@ TEST_F(ClientChannelParserTest, InvalidGrpclbLoadBalancingConfig) { VerifyRegexMatch(error, e); } -TEST_F(ClientChannelParserTest, InalidLoadBalancingConfigXds) { - const char* test_json = - "{\n" - " \"loadBalancingConfig\":[\n" - " { \"does_not_exist\":{} },\n" - " { \"xds_experimental\":{} }\n" - " ]\n" - "}"; - grpc_error* error = GRPC_ERROR_NONE; - auto svc_cfg = ServiceConfig::Create(test_json, &error); - gpr_log(GPR_ERROR, "%s", grpc_error_string(error)); - ASSERT_TRUE(error != GRPC_ERROR_NONE); - std::regex e( - std::string("(Service config parsing " - "error)(.*)(referenced_errors)(.*)(Global " - "Params)(.*)(referenced_errors)(.*)(Client channel global " - "parser)(.*)(referenced_errors)(.*)(Xds " - "Parser)(.*)(referenced_errors)(.*)(field:balancerName " - "error:not found)")); - VerifyRegexMatch(error, e); -} - TEST_F(ClientChannelParserTest, ValidLoadBalancingPolicy) { const char* test_json = "{\"loadBalancingPolicy\":\"pick_first\"}"; grpc_error* error = GRPC_ERROR_NONE; diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index 0a5c3740096..9bc7efe957f 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -551,7 +551,8 @@ class XdsEnd2endTest : public ::testing::Test { void ShutdownBackend(size_t index) { backends_[index]->Shutdown(); } void ResetStub(int fallback_timeout = 0, - const grpc::string& expected_targets = "") { + const grpc::string& expected_targets = "", + grpc::string scheme = "") { ChannelArguments args; // TODO(juanlishen): Add setter to ChannelArguments. if (fallback_timeout > 0) { @@ -562,8 +563,9 @@ class XdsEnd2endTest : public ::testing::Test { if (!expected_targets.empty()) { args.SetString(GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS, expected_targets); } + if (scheme.empty()) scheme = "fake"; std::ostringstream uri; - uri << "fake:///" << kApplicationTargetName_; + uri << scheme << ":///" << kApplicationTargetName_; // TODO(dgq): templatize tests to run everything using both secure and // insecure channel credentials. grpc_channel_credentials* channel_creds = @@ -913,6 +915,20 @@ class XdsEnd2endTest : public ::testing::Test { "}"; }; +class XdsResolverTest : public XdsEnd2endTest { + public: + XdsResolverTest() : XdsEnd2endTest(0, 0, 0) {} +}; + +TEST_F(XdsResolverTest, XdsResolverIsUsed) { + // Use xds-experimental scheme in URI. + ResetStub(0, "", "xds-experimental"); + // Send an RPC to trigger resolution. + SendRpc(); + // Xds resolver returns xds_experimental as the LB policy. + EXPECT_EQ("xds_experimental", channel_->GetLoadBalancingPolicyName()); +} + class SingleBalancerTest : public XdsEnd2endTest { public: SingleBalancerTest() : XdsEnd2endTest(4, 1, 0) {} diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index e9bd8e463ba..e2900b2e701 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -952,6 +952,7 @@ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h \ src/core/ext/filters/client_channel/resolver/sockaddr/README.md \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ +src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc \ src/core/ext/filters/client_channel/resolver_factory.h \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/resolver_registry.h \ From 5a4d46d19bc190e49feccc9879f2df57ab51dbb0 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 16 Aug 2019 15:16:29 -0700 Subject: [PATCH 1277/1555] Add wait_for_ready attempt to fix gevent issue --- .../grpcio_tests/tests/unit/_local_credentials_test.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/python/grpcio_tests/tests/unit/_local_credentials_test.py b/src/python/grpcio_tests/tests/unit/_local_credentials_test.py index fe7b052482b..7fb2520d48d 100644 --- a/src/python/grpcio_tests/tests/unit/_local_credentials_test.py +++ b/src/python/grpcio_tests/tests/unit/_local_credentials_test.py @@ -42,7 +42,9 @@ class LocalCredentialsTest(unittest.TestCase): port = server.add_secure_port(server_addr.format(0), server_creds) server.start() channel = grpc.secure_channel(server_addr.format(port), channel_creds) - self.assertEqual(b'abc', channel.unary_unary('/test/method')(b'abc')) + self.assertEqual(b'abc', + channel.unary_unary('/test/method')( + b'abc', wait_for_ready=True)) server.stop(None) def test_uds(self): @@ -55,7 +57,9 @@ class LocalCredentialsTest(unittest.TestCase): server.add_secure_port(server_addr, server_creds) server.start() channel = grpc.secure_channel(server_addr, channel_creds) - self.assertEqual(b'abc', channel.unary_unary('/test/method')(b'abc')) + self.assertEqual(b'abc', + channel.unary_unary('/test/method')( + b'abc', wait_for_ready=True)) server.stop(None) From 227a7cb47b14b135989897aa49d98b6abede9023 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 16 Aug 2019 15:43:06 -0700 Subject: [PATCH 1278/1555] Adopt reviewer's suggestion --- src/python/grpcio/grpc/__init__.py | 26 +++++++++++++++---- .../grpc/_cython/_cygrpc/credentials.pyx.pxi | 2 +- .../tests/unit/_local_credentials_test.py | 21 ++++++++------- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index aa47316b448..3852b40c971 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -1746,21 +1746,29 @@ def dynamic_ssl_server_credentials(initial_certificate_configuration, @enum.unique class LocalConnectionType(enum.Enum): - """Type of local connections for which local channel/server credentials will be applied. + """Types of local connection for local credential creation. Attributes: UDS: Unix domain socket connections LOCAL_TCP: Local TCP connections. """ - UDS = _cygrpc.LocalConnectType.uds - LOCAL_TCP = _cygrpc.LocalConnectType.local_tcp + UDS = _cygrpc.LocalConnectionType.uds + LOCAL_TCP = _cygrpc.LocalConnectionType.local_tcp def local_channel_credentials(local_connect_type=LocalConnectionType.LOCAL_TCP): """Creates a local ChannelCredentials used for local connections. + Local credentials are used by local TCP endpoints (e.g. localhost:10000) + also UDS connections. It allows them to create secure channel, hence + transmitting call credentials become possible. + + It is useful for 1) eliminating insecure_channel usage; 2) enable unit + testing for call credentials without setting up secrets. + Args: - local_connect_type: Local connection type (either UDS or LOCAL_TCP) + local_connect_type: Local connection type (either + grpc.LocalConnectionType.UDS or grpc.LocalConnectionType.LOCAL_TCP) Returns: A ChannelCredentials for use with a local Channel @@ -1772,8 +1780,16 @@ def local_channel_credentials(local_connect_type=LocalConnectionType.LOCAL_TCP): def local_server_credentials(local_connect_type=LocalConnectionType.LOCAL_TCP): """Creates a local ServerCredentials used for local connections. + Local credentials are used by local TCP endpoints (e.g. localhost:10000) + also UDS connections. It allows them to create secure channel, hence + transmitting call credentials become possible. + + It is useful for 1) eliminating insecure_channel usage; 2) enable unit + testing for call credentials without setting up secrets. + Args: - local_connect_type: Local connection type (either UDS or LOCAL_TCP) + local_connect_type: Local connection type (either + grpc.LocalConnectionType.UDS or grpc.LocalConnectionType.LOCAL_TCP) Returns: A ServerCredentials for use with a local Server diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi index ac88bbe7afc..b2aa7800295 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi @@ -329,7 +329,7 @@ cdef grpc_ssl_certificate_config_reload_status _server_cert_config_fetcher_wrapp return GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW -class LocalConnectType: +class LocalConnectionType: uds = UDS local_tcp = LOCAL_TCP diff --git a/src/python/grpcio_tests/tests/unit/_local_credentials_test.py b/src/python/grpcio_tests/tests/unit/_local_credentials_test.py index 7fb2520d48d..80a21af1cef 100644 --- a/src/python/grpcio_tests/tests/unit/_local_credentials_test.py +++ b/src/python/grpcio_tests/tests/unit/_local_credentials_test.py @@ -33,18 +33,20 @@ class LocalCredentialsTest(unittest.TestCase): return server def test_local_tcp(self): - server_addr = '[::1]:{}' + server_addr = 'localhost:{}' channel_creds = grpc.local_channel_credentials( grpc.LocalConnectionType.LOCAL_TCP) server_creds = grpc.local_server_credentials( grpc.LocalConnectionType.LOCAL_TCP) + server = self._create_server() port = server.add_secure_port(server_addr.format(0), server_creds) server.start() - channel = grpc.secure_channel(server_addr.format(port), channel_creds) - self.assertEqual(b'abc', - channel.unary_unary('/test/method')( - b'abc', wait_for_ready=True)) + with grpc.secure_channel(server_addr.format(port), + channel_creds) as channel: + self.assertEqual(b'abc', + channel.unary_unary('/test/method')( + b'abc', wait_for_ready=True)) server.stop(None) def test_uds(self): @@ -53,13 +55,14 @@ class LocalCredentialsTest(unittest.TestCase): grpc.LocalConnectionType.UDS) server_creds = grpc.local_server_credentials( grpc.LocalConnectionType.UDS) + server = self._create_server() server.add_secure_port(server_addr, server_creds) server.start() - channel = grpc.secure_channel(server_addr, channel_creds) - self.assertEqual(b'abc', - channel.unary_unary('/test/method')( - b'abc', wait_for_ready=True)) + with grpc.secure_channel(server_addr, channel_creds) as channel: + self.assertEqual(b'abc', + channel.unary_unary('/test/method')( + b'abc', wait_for_ready=True)) server.stop(None) From 4bd0ee17bcd7e9b9276680f5a308ba2a3aa24fff Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 16 Aug 2019 16:42:33 -0700 Subject: [PATCH 1279/1555] GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS is based on data frames being received --- doc/keepalive.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/keepalive.md b/doc/keepalive.md index 20449fc273b..a54a4fa033c 100644 --- a/doc/keepalive.md +++ b/doc/keepalive.md @@ -18,9 +18,9 @@ The above two channel arguments should be sufficient for most users, but the fol * **GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA** * This channel argument controls the maximum number of pings that can be sent when there is no other data (data frame or header frame) to be sent. GRPC Core will not continue sending pings if we run over the limit. Setting it to 0 allows sending pings without sending data. * **GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS** - * If there is no data being sent on the transport, this channel argument controls the minimum time (in milliseconds) gRPC Core will wait between successive pings. + * If there are no data frames being received on the transport, this channel argument controls the minimum time (in milliseconds) gRPC Core will wait between successive pings. * **GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS** - * If there is no data being sent on the transport, this channel argument on the server side controls the minimum time (in milliseconds) that gRPC Core would expect between receiving successive pings. If the time between successive pings is less that than this time, then the ping will be considered a bad ping from the peer. Such a ping counts as a ‘ping strike’. + * If there are no data frames being sent on the transport, this channel argument on the server side controls the minimum time (in milliseconds) that gRPC Core would expect between receiving successive pings. If the time between successive pings is less that than this time, then the ping will be considered a bad ping from the peer. Such a ping counts as a ‘ping strike’. On the client side, this does not have any effect. * **GRPC_ARG_HTTP2_MAX_PING_STRIKES** * This arg controls the maximum number of bad pings that the server will tolerate before sending an HTTP2 GOAWAY frame and closing the transport. Setting it to 0 allows the server to accept any number of bad pings. From c45fb12ffb21966307888ef9c87dbd7ba70a0683 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 16 Aug 2019 17:33:19 -0700 Subject: [PATCH 1280/1555] Add experimental API note. --- src/python/grpcio/grpc/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index 3852b40c971..aa1a20c58db 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -1759,6 +1759,8 @@ class LocalConnectionType(enum.Enum): def local_channel_credentials(local_connect_type=LocalConnectionType.LOCAL_TCP): """Creates a local ChannelCredentials used for local connections. + This is an EXPERIMENTAL API. + Local credentials are used by local TCP endpoints (e.g. localhost:10000) also UDS connections. It allows them to create secure channel, hence transmitting call credentials become possible. @@ -1780,6 +1782,8 @@ def local_channel_credentials(local_connect_type=LocalConnectionType.LOCAL_TCP): def local_server_credentials(local_connect_type=LocalConnectionType.LOCAL_TCP): """Creates a local ServerCredentials used for local connections. + This is an EXPERIMENTAL API. + Local credentials are used by local TCP endpoints (e.g. localhost:10000) also UDS connections. It allows them to create secure channel, hence transmitting call credentials become possible. From 43bedf0007eb4945a3c8252494f84f7edd2263b9 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 19 Aug 2019 11:56:44 -0700 Subject: [PATCH 1281/1555] Fix internal lint warnings. --- src/benchmark/gen_build_yaml.py | 3 ++- src/boringssl/gen_build_yaml.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/benchmark/gen_build_yaml.py b/src/benchmark/gen_build_yaml.py index a1f777d6c2b..35c9244e6fa 100755 --- a/src/benchmark/gen_build_yaml.py +++ b/src/benchmark/gen_build_yaml.py @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import print_function import os import sys import glob @@ -35,4 +36,4 @@ out['libs'] = [{ glob.glob('third_party/benchmark/include/benchmark/*.h')), }] -print yaml.dump(out) +print(yaml.dump(out)) diff --git a/src/boringssl/gen_build_yaml.py b/src/boringssl/gen_build_yaml.py index 145cc67b0d1..3b259c32c5d 100755 --- a/src/boringssl/gen_build_yaml.py +++ b/src/boringssl/gen_build_yaml.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import print_function import shutil import sys import os @@ -28,7 +29,7 @@ sys.path.append(os.path.join(boring_ssl_root, 'util')) try: import generate_build_files except ImportError: - print yaml.dump({}) + print(yaml.dump({})) sys.exit() def map_dir(filename): @@ -135,7 +136,7 @@ try: g = Grpc() generate_build_files.main([g]) - print yaml.dump(g.yaml) + print(yaml.dump(g.yaml)) finally: shutil.rmtree('src') From 2a9998bc13d4aae9e0288efa1f7676f706a91073 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 19 Aug 2019 13:19:04 -0700 Subject: [PATCH 1282/1555] Properly handle exceptions in signal handlers for in-flight outgoing RPCs --- .../grpc/_cython/_cygrpc/channel.pyx.pxi | 27 +++++++--- .../grpcio_tests/tests/unit/_signal_client.py | 38 ++++++++++++-- .../tests/unit/_signal_handling_test.py | 49 +++++++++++++++++++ 3 files changed, 103 insertions(+), 11 deletions(-) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi index ca637094353..5b47d356d6f 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi @@ -146,12 +146,17 @@ cdef _cancel( cdef _next_call_event( _ChannelState channel_state, grpc_completion_queue *c_completion_queue, - on_success, deadline): - tag, event = _latent_event(c_completion_queue, deadline) - with channel_state.condition: - on_success(tag) - channel_state.condition.notify_all() - return event + on_success, on_failure, deadline): + try: + tag, event = _latent_event(c_completion_queue, deadline) + except: + on_failure() + raise + else: + with channel_state.condition: + on_success(tag) + channel_state.condition.notify_all() + return event # TODO(https://github.com/grpc/grpc/issues/14569): This could be a lot simpler. @@ -307,8 +312,14 @@ cdef class SegregatedCall: def on_success(tag): _process_segregated_call_tag( self._channel_state, self._call_state, self._c_completion_queue, tag) + def on_failure(): + self._call_state.due.clear() + grpc_call_unref(self._call_state.c_call) + self._call_state.c_call = NULL + self._channel_state.segregated_call_states.remove(self._call_state) + _destroy_c_completion_queue(self._c_completion_queue) return _next_call_event( - self._channel_state, self._c_completion_queue, on_success, None) + self._channel_state, self._c_completion_queue, on_success, on_failure, None) cdef SegregatedCall _segregated_call( @@ -462,7 +473,7 @@ cdef class Channel: else: queue_deadline = None return _next_call_event(self._state, self._state.c_call_completion_queue, - on_success, queue_deadline) + on_success, None, queue_deadline) def segregated_call( self, int flags, method, host, object deadline, object metadata, diff --git a/src/python/grpcio_tests/tests/unit/_signal_client.py b/src/python/grpcio_tests/tests/unit/_signal_client.py index 65ddd6d858e..a2234623a76 100644 --- a/src/python/grpcio_tests/tests/unit/_signal_client.py +++ b/src/python/grpcio_tests/tests/unit/_signal_client.py @@ -45,6 +45,7 @@ def handle_sigint(unused_signum, unused_frame): if per_process_rpc_future is not None: per_process_rpc_future.cancel() sys.stderr.flush() + # This sys.exit(0) avoids an exception caused by the cancelled RPC. sys.exit(0) @@ -72,13 +73,44 @@ def main_streaming(server_target): assert False, _ASSERTION_MESSAGE +def main_unary_with_exception(server_target): + """Initiate an RPC with wait_for_ready set and no server backing the RPC.""" + channel = grpc.insecure_channel(server_target) + try: + channel.unary_unary(UNARY_UNARY)(_MESSAGE, wait_for_ready=True) + except KeyboardInterrupt: + sys.stderr.write("Running signal handler.\n"); sys.stderr.flush() + + sys.stderr.write("Calling Channel.close()"); sys.stderr.flush() + # This call should not hang. + channel.close() + +def main_streaming_with_exception(server_target): + """Initiate an RPC with wait_for_ready set and no server backing the RPC.""" + channel = grpc.insecure_channel(server_target) + try: + channel.unary_stream(UNARY_STREAM)(_MESSAGE, wait_for_ready=True) + except KeyboardInterrupt: + sys.stderr.write("Running signal handler.\n"); sys.stderr.flush() + + sys.stderr.write("Calling Channel.close()"); sys.stderr.flush() + # This call should not hang. + channel.close() + if __name__ == '__main__': parser = argparse.ArgumentParser(description='Signal test client.') parser.add_argument('server', help='Server target') parser.add_argument( - 'arity', help='RPC arity', choices=('unary', 'streaming')) + 'arity', help='Arity', choices=('unary', 'streaming')) + parser.add_argument( + '--exception', help='Whether the signal throws an exception', + action='store_true') args = parser.parse_args() - if args.arity == 'unary': + if args.arity == 'unary' and not args.exception: main_unary(args.server) - else: + elif args.arity == 'streaming' and not args.exception: main_streaming(args.server) + elif args.arity == 'unary' and args.exception: + main_unary_with_exception(args.server) + else: + main_streaming_with_exception(args.server) diff --git a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py index 8ef156c596d..fbb1280e9d4 100644 --- a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py +++ b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py @@ -13,6 +13,7 @@ # limitations under the License. """Test of responsiveness to signals.""" +import contextlib import logging import os import signal @@ -20,6 +21,7 @@ import subprocess import tempfile import threading import unittest +import socket import sys import grpc @@ -167,6 +169,53 @@ class SignalHandlingTest(unittest.TestCase): client_stdout.read()) +@contextlib.contextmanager +def _get_free_loopback_tcp_port(): + sock = socket.socket(socket.AF_INET6) + sock.bind(('', 0)) + address_tuple = sock.getsockname() + try: + yield "[::1]:%s" % (address_tuple[1]) + finally: + sock.close() + + +# TODO(gnossen): Consider combining classes. +class SignalHandlingTestWithoutServer(unittest.TestCase): + + @unittest.skipIf(os.name == 'nt', 'SIGINT not supported on windows') + def testUnaryHandlerWithException(self): + with _get_free_loopback_tcp_port() as server_target: + with tempfile.TemporaryFile(mode='r') as client_stdout: + with tempfile.TemporaryFile(mode='r') as client_stderr: + client = _start_client(('--exception', server_target, 'unary'), + client_stdout, client_stderr) + # TODO(rbellevi): Figure out a way to determininstically hook + # in here. + import time; time.sleep(1) + client.send_signal(signal.SIGINT) + client.wait() + print(_read_stream(client_stderr)) + self.assertEqual(0, client.returncode) + + @unittest.skipIf(os.name == 'nt', 'SIGINT not supported on windows') + def testStreamingHandlerWithException(self): + with _get_free_loopback_tcp_port() as server_target: + with tempfile.TemporaryFile(mode='r') as client_stdout: + with tempfile.TemporaryFile(mode='r') as client_stderr: + client = _start_client(('--exception', server_target, 'streaming'), + client_stdout, client_stderr) + # TODO(rbellevi): Figure out a way to deterministically hook + # in here. + import time; time.sleep(1) + client.send_signal(signal.SIGINT) + client.wait() + print(_read_stream(client_stderr)) + self.assertEqual(0, client.returncode) + + + + if __name__ == '__main__': logging.basicConfig() unittest.main(verbosity=2) From b4eaccf754cd9fdd53efe41e2de13ba5fc0678c8 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 19 Aug 2019 13:22:58 -0700 Subject: [PATCH 1283/1555] Make tests deterministic --- .../tests/unit/_signal_handling_test.py | 67 ++++++------------- 1 file changed, 20 insertions(+), 47 deletions(-) diff --git a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py index fbb1280e9d4..837a385be0d 100644 --- a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py +++ b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py @@ -168,54 +168,27 @@ class SignalHandlingTest(unittest.TestCase): self.assertIn(_signal_client.SIGTERM_MESSAGE, client_stdout.read()) - -@contextlib.contextmanager -def _get_free_loopback_tcp_port(): - sock = socket.socket(socket.AF_INET6) - sock.bind(('', 0)) - address_tuple = sock.getsockname() - try: - yield "[::1]:%s" % (address_tuple[1]) - finally: - sock.close() - - -# TODO(gnossen): Consider combining classes. -class SignalHandlingTestWithoutServer(unittest.TestCase): - @unittest.skipIf(os.name == 'nt', 'SIGINT not supported on windows') - def testUnaryHandlerWithException(self): - with _get_free_loopback_tcp_port() as server_target: - with tempfile.TemporaryFile(mode='r') as client_stdout: - with tempfile.TemporaryFile(mode='r') as client_stderr: - client = _start_client(('--exception', server_target, 'unary'), - client_stdout, client_stderr) - # TODO(rbellevi): Figure out a way to determininstically hook - # in here. - import time; time.sleep(1) - client.send_signal(signal.SIGINT) - client.wait() - print(_read_stream(client_stderr)) - self.assertEqual(0, client.returncode) + def testUnaryWithException(self): + server_target = '{}:{}'.format(_HOST, self._port) + with tempfile.TemporaryFile(mode='r') as client_stdout: + with tempfile.TemporaryFile(mode='r') as client_stderr: + client = _start_client(('--exception', server_target, 'unary'), + client_stdout, client_stderr) + self._handler.await_connected_client() + client.send_signal(signal.SIGINT) + client.wait() + self.assertEqual(0, client.returncode) @unittest.skipIf(os.name == 'nt', 'SIGINT not supported on windows') def testStreamingHandlerWithException(self): - with _get_free_loopback_tcp_port() as server_target: - with tempfile.TemporaryFile(mode='r') as client_stdout: - with tempfile.TemporaryFile(mode='r') as client_stderr: - client = _start_client(('--exception', server_target, 'streaming'), - client_stdout, client_stderr) - # TODO(rbellevi): Figure out a way to deterministically hook - # in here. - import time; time.sleep(1) - client.send_signal(signal.SIGINT) - client.wait() - print(_read_stream(client_stderr)) - self.assertEqual(0, client.returncode) - - - - -if __name__ == '__main__': - logging.basicConfig() - unittest.main(verbosity=2) + server_target = '{}:{}'.format(_HOST, self._port) + with tempfile.TemporaryFile(mode='r') as client_stdout: + with tempfile.TemporaryFile(mode='r') as client_stderr: + client = _start_client(('--exception', server_target, 'streaming'), + client_stdout, client_stderr) + self._handler.await_connected_client() + client.send_signal(signal.SIGINT) + client.wait() + print(_read_stream(client_stderr)) + self.assertEqual(0, client.returncode) From 4f04a80a69f48d8971098fd658ae76c0bb686a0b Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 19 Aug 2019 13:27:56 -0700 Subject: [PATCH 1284/1555] Add note about something seemingly suspect. --- src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi index 5b47d356d6f..53abdc5ec15 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi @@ -472,6 +472,9 @@ cdef class Channel: queue_deadline = time.time() + 1.0 else: queue_deadline = None + # NOTE(gnossen): It is acceptable for on_failure to be None here because + # failure conditions can only ever happen on the main thread and this + # method is only ever invoked on the channel spin thread. return _next_call_event(self._state, self._state.c_call_completion_queue, on_success, None, queue_deadline) From ca2fcd647ac2f5603d21c19217b8b065d8f968d7 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 19 Aug 2019 13:36:53 -0700 Subject: [PATCH 1285/1555] Add docstring --- .../grpc/_cython/_cygrpc/channel.pyx.pxi | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi index 53abdc5ec15..c83ff00fedf 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi @@ -147,10 +147,27 @@ cdef _cancel( cdef _next_call_event( _ChannelState channel_state, grpc_completion_queue *c_completion_queue, on_success, on_failure, deadline): + """Block on the next event out of the completion queue. + + On success, `on_success` will be invoked with the tag taken from the CQ. + In the case of a failure due to an exception raised in a signal handler, + `on_failure` will be invoked with no arguments. Note that this situation + can only occur on the main thread. + + Args: + channel_state: The state for the channel on which the RPC is running. + c_completion_queue: The CQ which will be polled. + on_success: A callable object to be invoked upon successful receipt of a + tag from the CQ. + on_failure: A callable object to be invoked in case a Python exception is + raised from a signal handler during polling. + deadline: The point after which the RPC will time out. + """ try: tag, event = _latent_event(c_completion_queue, deadline) except: - on_failure() + if on_failure is not None: + on_failure() raise else: with channel_state.condition: From 84855a18a9bcb0ea6b83ed1dd23999354bf7fe71 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 19 Aug 2019 13:44:32 -0700 Subject: [PATCH 1286/1555] Yapf --- .../grpcio_tests/tests/unit/_signal_client.py | 16 +++++++++------- .../tests/unit/_signal_handling_test.py | 7 +++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/python/grpcio_tests/tests/unit/_signal_client.py b/src/python/grpcio_tests/tests/unit/_signal_client.py index a2234623a76..9aa37854a23 100644 --- a/src/python/grpcio_tests/tests/unit/_signal_client.py +++ b/src/python/grpcio_tests/tests/unit/_signal_client.py @@ -79,31 +79,33 @@ def main_unary_with_exception(server_target): try: channel.unary_unary(UNARY_UNARY)(_MESSAGE, wait_for_ready=True) except KeyboardInterrupt: - sys.stderr.write("Running signal handler.\n"); sys.stderr.flush() + sys.stderr.write("Running signal handler.\n") + sys.stderr.flush() - sys.stderr.write("Calling Channel.close()"); sys.stderr.flush() # This call should not hang. channel.close() + def main_streaming_with_exception(server_target): """Initiate an RPC with wait_for_ready set and no server backing the RPC.""" channel = grpc.insecure_channel(server_target) try: channel.unary_stream(UNARY_STREAM)(_MESSAGE, wait_for_ready=True) except KeyboardInterrupt: - sys.stderr.write("Running signal handler.\n"); sys.stderr.flush() + sys.stderr.write("Running signal handler.\n") + sys.stderr.flush() - sys.stderr.write("Calling Channel.close()"); sys.stderr.flush() # This call should not hang. channel.close() + if __name__ == '__main__': parser = argparse.ArgumentParser(description='Signal test client.') parser.add_argument('server', help='Server target') + parser.add_argument('arity', help='Arity', choices=('unary', 'streaming')) parser.add_argument( - 'arity', help='Arity', choices=('unary', 'streaming')) - parser.add_argument( - '--exception', help='Whether the signal throws an exception', + '--exception', + help='Whether the signal throws an exception', action='store_true') args = parser.parse_args() if args.arity == 'unary' and not args.exception: diff --git a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py index 837a385be0d..3c46860fcc5 100644 --- a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py +++ b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py @@ -13,7 +13,6 @@ # limitations under the License. """Test of responsiveness to signals.""" -import contextlib import logging import os import signal @@ -21,7 +20,6 @@ import subprocess import tempfile import threading import unittest -import socket import sys import grpc @@ -185,8 +183,9 @@ class SignalHandlingTest(unittest.TestCase): server_target = '{}:{}'.format(_HOST, self._port) with tempfile.TemporaryFile(mode='r') as client_stdout: with tempfile.TemporaryFile(mode='r') as client_stderr: - client = _start_client(('--exception', server_target, 'streaming'), - client_stdout, client_stderr) + client = _start_client( + ('--exception', server_target, 'streaming'), client_stdout, + client_stderr) self._handler.await_connected_client() client.send_signal(signal.SIGINT) client.wait() From 235b27257c90f1773af8628964bb1c453e478b2b Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 19 Aug 2019 14:05:54 -0700 Subject: [PATCH 1287/1555] Re-add unittest.main. --- src/python/grpcio_tests/tests/unit/_signal_handling_test.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py index 3c46860fcc5..6f81e0b2d34 100644 --- a/src/python/grpcio_tests/tests/unit/_signal_handling_test.py +++ b/src/python/grpcio_tests/tests/unit/_signal_handling_test.py @@ -191,3 +191,8 @@ class SignalHandlingTest(unittest.TestCase): client.wait() print(_read_stream(client_stderr)) self.assertEqual(0, client.returncode) + + +if __name__ == '__main__': + logging.basicConfig() + unittest.main(verbosity=2) From 967f55efd633055c1e5419ffd00c51282238d265 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 19 Aug 2019 14:20:01 -0700 Subject: [PATCH 1288/1555] Add explanatory comment. --- src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi index c83ff00fedf..1799780fce4 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi @@ -165,6 +165,8 @@ cdef _next_call_event( """ try: tag, event = _latent_event(c_completion_queue, deadline) + # NOTE(rbellevi): This broad except enables us to clean up resources before + # propagating any exceptions raised by signal handlers to the application. except: if on_failure is not None: on_failure() From 3d56c83a5f86d7930a99392bc1ee7dc5d2c12f1f Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 19 Aug 2019 14:24:45 -0700 Subject: [PATCH 1289/1555] Correct out-of-date docstrings --- src/python/grpcio_tests/tests/unit/_signal_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/python/grpcio_tests/tests/unit/_signal_client.py b/src/python/grpcio_tests/tests/unit/_signal_client.py index 9aa37854a23..97e432d5360 100644 --- a/src/python/grpcio_tests/tests/unit/_signal_client.py +++ b/src/python/grpcio_tests/tests/unit/_signal_client.py @@ -74,7 +74,7 @@ def main_streaming(server_target): def main_unary_with_exception(server_target): - """Initiate an RPC with wait_for_ready set and no server backing the RPC.""" + """Initiate a unary RPC with a signal handler that will raise.""" channel = grpc.insecure_channel(server_target) try: channel.unary_unary(UNARY_UNARY)(_MESSAGE, wait_for_ready=True) @@ -87,7 +87,7 @@ def main_unary_with_exception(server_target): def main_streaming_with_exception(server_target): - """Initiate an RPC with wait_for_ready set and no server backing the RPC.""" + """Initiate a streaming RPC with a signal handler that will raise.""" channel = grpc.insecure_channel(server_target) try: channel.unary_stream(UNARY_STREAM)(_MESSAGE, wait_for_ready=True) From 1abba74225fef9e7968526b87ac115880bcd12e4 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Mon, 19 Aug 2019 14:40:27 -0700 Subject: [PATCH 1290/1555] Fix unused result error --- test/cpp/end2end/xds_end2end_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index 9bc7efe957f..480680c9a32 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -924,7 +924,7 @@ TEST_F(XdsResolverTest, XdsResolverIsUsed) { // Use xds-experimental scheme in URI. ResetStub(0, "", "xds-experimental"); // Send an RPC to trigger resolution. - SendRpc(); + auto unused_result = SendRpc(); // Xds resolver returns xds_experimental as the LB policy. EXPECT_EQ("xds_experimental", channel_->GetLoadBalancingPolicyName()); } From e45bea777eb662951bafc506ea9383e940247269 Mon Sep 17 00:00:00 2001 From: Qiancheng Zhao Date: Mon, 19 Aug 2019 15:43:12 -0700 Subject: [PATCH 1291/1555] use acquire instead of relaxed in IdleTimerCallback() --- src/core/ext/filters/client_idle/client_idle_filter.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/ext/filters/client_idle/client_idle_filter.cc b/src/core/ext/filters/client_idle/client_idle_filter.cc index 13c35ae3730..9da098d6d6d 100644 --- a/src/core/ext/filters/client_idle/client_idle_filter.cc +++ b/src/core/ext/filters/client_idle/client_idle_filter.cc @@ -320,7 +320,7 @@ void ChannelData::IdleTimerCallback(void* arg, grpc_error* error) { // EnterIdle() operation finishes, preventing mistakenly entering IDLE // when active RPC exists. finished = chand->state_.CompareExchangeWeak( - &state, PROCESSING, MemoryOrder::RELAXED, MemoryOrder::RELAXED); + &state, PROCESSING, MemoryOrder::ACQUIRE, MemoryOrder::RELAXED); if (finished) { chand->EnterIdle(); chand->state_.Store(IDLE, MemoryOrder::RELAXED); From 4e61956ef4320176ae555b567829c6a87a407543 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Mon, 19 Aug 2019 16:08:57 -0700 Subject: [PATCH 1292/1555] Add run: false to grpclb_fallback_test --- Makefile | 2 -- build.yaml | 1 + tools/run_tests/generated/tests.json | 18 ------------------ 3 files changed, 1 insertion(+), 20 deletions(-) diff --git a/Makefile b/Makefile index a0692f38d20..37df0d6c809 100644 --- a/Makefile +++ b/Makefile @@ -2381,8 +2381,6 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/grpclb_api_test || ( echo test grpclb_api_test failed ; exit 1 ) $(E) "[RUN] Testing grpclb_end2end_test" $(Q) $(BINDIR)/$(CONFIG)/grpclb_end2end_test || ( echo test grpclb_end2end_test failed ; exit 1 ) - $(E) "[RUN] Testing grpclb_fallback_test" - $(Q) $(BINDIR)/$(CONFIG)/grpclb_fallback_test || ( echo test grpclb_fallback_test failed ; exit 1 ) $(E) "[RUN] Testing h2_ssl_cert_test" $(Q) $(BINDIR)/$(CONFIG)/h2_ssl_cert_test || ( echo test h2_ssl_cert_test failed ; exit 1 ) $(E) "[RUN] Testing h2_ssl_session_reuse_test" diff --git a/build.yaml b/build.yaml index 7431dbb2a53..e0862c116e5 100644 --- a/build.yaml +++ b/build.yaml @@ -5170,6 +5170,7 @@ targets: - gpr - name: grpclb_fallback_test build: test + run: false language: c++ src: - src/proto/grpc/testing/empty.proto diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 6dd3f1422e5..f28b1335a6c 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -4907,24 +4907,6 @@ ], "uses_polling": true }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": false, - "language": "c++", - "name": "grpclb_fallback_test", - "platforms": [ - "linux" - ], - "uses_polling": true - }, { "args": [], "benchmark": false, From f03ae6d493493b5e2c61822a8c10ee7bbf627bf7 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 19 Aug 2019 16:58:56 -0700 Subject: [PATCH 1293/1555] Fix streaming test case --- src/python/grpcio_tests/tests/unit/_signal_client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/python/grpcio_tests/tests/unit/_signal_client.py b/src/python/grpcio_tests/tests/unit/_signal_client.py index 97e432d5360..3e13146d9e2 100644 --- a/src/python/grpcio_tests/tests/unit/_signal_client.py +++ b/src/python/grpcio_tests/tests/unit/_signal_client.py @@ -90,7 +90,8 @@ def main_streaming_with_exception(server_target): """Initiate a streaming RPC with a signal handler that will raise.""" channel = grpc.insecure_channel(server_target) try: - channel.unary_stream(UNARY_STREAM)(_MESSAGE, wait_for_ready=True) + for _ in channel.unary_stream(UNARY_STREAM)(_MESSAGE, wait_for_ready=True): + pass except KeyboardInterrupt: sys.stderr.write("Running signal handler.\n") sys.stderr.flush() From 76aba16cf4f0296f0af617adbe4e7f4f4468221e Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Mon, 19 Aug 2019 17:00:40 -0700 Subject: [PATCH 1294/1555] Add issue/pr templates --- .../bug_report.md} | 33 +++++++++++-------- .github/ISSUE_TEMPLATE/cleanup_request.md | 18 ++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 29 ++++++++++++++++ .github/pull_request_template.md | 5 +++ 4 files changed, 72 insertions(+), 13 deletions(-) rename .github/{ISSUE_TEMPLATE.md => ISSUE_TEMPLATE/bug_report.md} (90%) mode change 100755 => 100644 create mode 100644 .github/ISSUE_TEMPLATE/cleanup_request.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/pull_request_template.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE/bug_report.md old mode 100755 new mode 100644 similarity index 90% rename from .github/ISSUE_TEMPLATE.md rename to .github/ISSUE_TEMPLATE/bug_report.md index acfcdc14845..6eafaacd034 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,3 +1,11 @@ +--- +name: Report a bug +about: Create a report to help us improve +labels: kind/bug +assignees: AspirinSJL + +--- + - + ### What version of gRPC and what language are you using? - - + + ### What operating system (Linux, Windows,...) and version? - - + + ### What runtime / compiler are you using (e.g. python version or version of gcc) - - + + ### What did you do? If possible, provide a recipe for reproducing the error. Try being specific and include code snippets if helpful. - + ### What did you expect to see? - - + + ### What did you see instead? - + Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs). See [TROUBLESHOOTING.md](https://github.com/grpc/grpc/blob/master/TROUBLESHOOTING.md) for how to diagnose problems better. - -### Anything else we should know about your project / environment? +### Anything else we should know about your project / environment? diff --git a/.github/ISSUE_TEMPLATE/cleanup_request.md b/.github/ISSUE_TEMPLATE/cleanup_request.md new file mode 100644 index 00000000000..65e56772541 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/cleanup_request.md @@ -0,0 +1,18 @@ +--- +name: Request a cleanup +about: Suggest a cleanup in our repository +labels: kind/internal cleanup +assignees: AspirinSJL + +--- + + + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000000..2be15ac785c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,29 @@ +--- +name: Request a feature +about: Suggest an idea for this project +labels: kind/enhancement +assignees: AspirinSJL + +--- + + + +### Is your feature request related to a problem? Please describe. +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +### Describe the solution you'd like +A clear and concise description of what you want to happen. + +### Describe alternatives you've considered +A clear and concise description of any alternative solutions or features you've considered. + +### Additional context +Add any other context about the feature request here. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000000..31f574ef60d --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,5 @@ + + + + +@AspirinSJL \ No newline at end of file From 5d7766153fe9e307cb3694d21f53a5c6d41eed02 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Mon, 19 Aug 2019 17:37:55 -0700 Subject: [PATCH 1295/1555] Disable local tcp test for gevent --- src/python/grpcio_tests/commands.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/python/grpcio_tests/commands.py b/src/python/grpcio_tests/commands.py index 166cea101a4..a3912cda712 100644 --- a/src/python/grpcio_tests/commands.py +++ b/src/python/grpcio_tests/commands.py @@ -155,6 +155,8 @@ class TestGevent(setuptools.Command): 'channelz._channelz_servicer_test.ChannelzServicerTest.test_streaming_rpc', # TODO(https://github.com/grpc/grpc/issues/15411) enable this test 'unit._cython._channel_test.ChannelTest.test_negative_deadline_connectivity' + # TODO(https://github.com/grpc/grpc/issues/15411) enable this test + 'unit._local_credentials_test.LocalCredentialsTest.test_local_tcp', ) BANNED_WINDOWS_TESTS = ( # TODO(https://github.com/grpc/grpc/pull/15411) enable this test From e0d04c9a9e64797d0016a176be4f28dd8305a44a Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 19 Aug 2019 18:09:19 -0700 Subject: [PATCH 1296/1555] Yapf. --- src/python/grpcio_tests/tests/unit/_signal_client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/python/grpcio_tests/tests/unit/_signal_client.py b/src/python/grpcio_tests/tests/unit/_signal_client.py index 3e13146d9e2..075fe7f7177 100644 --- a/src/python/grpcio_tests/tests/unit/_signal_client.py +++ b/src/python/grpcio_tests/tests/unit/_signal_client.py @@ -90,7 +90,8 @@ def main_streaming_with_exception(server_target): """Initiate a streaming RPC with a signal handler that will raise.""" channel = grpc.insecure_channel(server_target) try: - for _ in channel.unary_stream(UNARY_STREAM)(_MESSAGE, wait_for_ready=True): + for _ in channel.unary_stream(UNARY_STREAM)( + _MESSAGE, wait_for_ready=True): pass except KeyboardInterrupt: sys.stderr.write("Running signal handler.\n") From df7ad5f91c0a32356e7648f88091e55e04a6f8a1 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Mon, 19 Aug 2019 14:58:01 -0700 Subject: [PATCH 1297/1555] Repo stats tracking --- tools/gcp/github_stats_tracking/app.yaml | 13 +++ .../github_stats_tracking/appengine_config.py | 19 ++++ tools/gcp/github_stats_tracking/cron.yaml | 4 + tools/gcp/github_stats_tracking/fetch_data.py | 94 +++++++++++++++++++ tools/gcp/github_stats_tracking/main.py | 29 ++++++ 5 files changed, 159 insertions(+) create mode 100644 tools/gcp/github_stats_tracking/app.yaml create mode 100644 tools/gcp/github_stats_tracking/appengine_config.py create mode 100644 tools/gcp/github_stats_tracking/cron.yaml create mode 100644 tools/gcp/github_stats_tracking/fetch_data.py create mode 100644 tools/gcp/github_stats_tracking/main.py diff --git a/tools/gcp/github_stats_tracking/app.yaml b/tools/gcp/github_stats_tracking/app.yaml new file mode 100644 index 00000000000..b0fa5573649 --- /dev/null +++ b/tools/gcp/github_stats_tracking/app.yaml @@ -0,0 +1,13 @@ +runtime: python27 +api_version: 1 +threadsafe: true + +service: github-stats-tracking + +handlers: +- url: /.* + script: main.app + +libraries: +- name: ssl + version: latest diff --git a/tools/gcp/github_stats_tracking/appengine_config.py b/tools/gcp/github_stats_tracking/appengine_config.py new file mode 100644 index 00000000000..086be2aefff --- /dev/null +++ b/tools/gcp/github_stats_tracking/appengine_config.py @@ -0,0 +1,19 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# appengine_config.py +from google.appengine.ext import vendor + +# Add any libraries install in the "lib" folder. +vendor.add('lib') diff --git a/tools/gcp/github_stats_tracking/cron.yaml b/tools/gcp/github_stats_tracking/cron.yaml new file mode 100644 index 00000000000..b5b36be92c6 --- /dev/null +++ b/tools/gcp/github_stats_tracking/cron.yaml @@ -0,0 +1,4 @@ +cron: +- description: "daily github stats tracking job" + url: /daily + schedule: every 24 hours diff --git a/tools/gcp/github_stats_tracking/fetch_data.py b/tools/gcp/github_stats_tracking/fetch_data.py new file mode 100644 index 00000000000..ed183a15a25 --- /dev/null +++ b/tools/gcp/github_stats_tracking/fetch_data.py @@ -0,0 +1,94 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from github import Github, Label +from datetime import datetime, timedelta +from time import time +from google.cloud import bigquery + +ACCESS_TOKEN = "" + + +def get_stats_from_github(): + # Please set the access token properly before deploying. + assert ACCESS_TOKEN + g = Github(ACCESS_TOKEN) + print g.rate_limiting + repo = g.get_repo('grpc/grpc') + + LABEL_LANG = set(label for label in repo.get_labels() + if label.name.split('/')[0] == 'lang') + LABEL_KIND_BUG = repo.get_label('kind/bug') + LABEL_PRIORITY_P0 = repo.get_label('priority/P0') + LABEL_PRIORITY_P1 = repo.get_label('priority/P1') + LABEL_PRIORITY_P2 = repo.get_label('priority/P2') + + def is_untriaged(issue): + key_labels = set() + for label in issue.labels: + label_kind = label.name.split('/')[0] + if label_kind in ('lang', 'kind', 'priority'): + key_labels.add(label_kind) + return len(key_labels) < 3 + + untriaged_open_issues = [ + issue for issue in repo.get_issues(state='open') + if issue.pull_request is None and is_untriaged(issue) + ] + total_bugs = [ + issue + for issue in repo.get_issues(state='all', labels=[LABEL_KIND_BUG]) + if issue.pull_request is None + ] + + lang_to_stats = {} + for lang in LABEL_LANG: + lang_bugs = filter(lambda bug: lang in bug.labels, total_bugs) + closed_bugs = filter(lambda bug: bug.state == 'closed', lang_bugs) + open_bugs = filter(lambda bug: bug.state == 'open', lang_bugs) + open_p0_bugs = filter(lambda bug: LABEL_PRIORITY_P0 in bug.labels, + open_bugs) + open_p1_bugs = filter(lambda bug: LABEL_PRIORITY_P1 in bug.labels, + open_bugs) + open_p2_bugs = filter(lambda bug: LABEL_PRIORITY_P2 in bug.labels, + open_bugs) + lang_to_stats[lang] = [ + len(lang_bugs), + len(closed_bugs), + len(open_bugs), + len(open_p0_bugs), + len(open_p1_bugs), + len(open_p2_bugs) + ] + return len(untriaged_open_issues), lang_to_stats + + +def insert_stats_to_db(untriaged_open_issues, lang_to_stats): + timestamp = time() + client = bigquery.Client() + dataset_ref = client.dataset('github_issues') + table_ref = dataset_ref.table('untriaged_issues') + table = client.get_table(table_ref) + errors = client.insert_rows(table, [(timestamp, untriaged_open_issues)]) + table_ref = dataset_ref.table('bug_stats') + table = client.get_table(table_ref) + rows = [] + for lang, stats in lang_to_stats.iteritems(): + rows.append((timestamp, lang.name[5:]) + tuple(stats)) + errors = client.insert_rows(table, rows) + + +def fetch(): + untriaged_open_issues, lang_to_stats = get_stats_from_github() + insert_stats_to_db(untriaged_open_issues, lang_to_stats) diff --git a/tools/gcp/github_stats_tracking/main.py b/tools/gcp/github_stats_tracking/main.py new file mode 100644 index 00000000000..f1e7ca6d981 --- /dev/null +++ b/tools/gcp/github_stats_tracking/main.py @@ -0,0 +1,29 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import webapp2 +from fetch_data import fetch + + +class DailyCron(webapp2.RequestHandler): + + def get(self): + fetch() + self.response.status = 204 + + +app = webapp2.WSGIApplication( + [ + ('/daily', DailyCron), + ], debug=True) From a08f043b59fe2820f25d296629cac3948a1b67c4 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 20 Aug 2019 08:05:27 -0700 Subject: [PATCH 1298/1555] add missing build deps --- BUILD | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/BUILD b/BUILD index c510757c35d..1ce579812d1 100644 --- a/BUILD +++ b/BUILD @@ -1215,6 +1215,7 @@ grpc_cc_library( "grpc_client_channel", "grpc_lb_upb", "grpc_resolver_fake", + "grpc_transport_chttp2_client_insecure", ], ) @@ -1241,6 +1242,7 @@ grpc_cc_library( "grpc_lb_upb", "grpc_resolver_fake", "grpc_secure", + "grpc_transport_chttp2_client_secure", ], ) @@ -1264,6 +1266,7 @@ grpc_cc_library( "grpc_base", "grpc_client_channel", "grpc_resolver_fake", + "grpc_transport_chttp2_client_insecure", ], ) @@ -1288,6 +1291,7 @@ grpc_cc_library( "grpc_client_channel", "grpc_resolver_fake", "grpc_secure", + "grpc_transport_chttp2_client_secure", ], ) From 66675437aaa13ff3b46042835c61d6e056f47886 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Tue, 20 Aug 2019 08:37:26 -0700 Subject: [PATCH 1299/1555] Bump YAPF to use Python 3 --- tools/distrib/yapf_code.sh | 2 +- tools/run_tests/sanity/check_bazel_workspace.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/distrib/yapf_code.sh b/tools/distrib/yapf_code.sh index 27c5e3129dd..1fddb706498 100755 --- a/tools/distrib/yapf_code.sh +++ b/tools/distrib/yapf_code.sh @@ -30,7 +30,7 @@ EXCLUSIONS=( VIRTUALENV=yapf_virtual_environment -python -m virtualenv $VIRTUALENV +python3 -m virtualenv $VIRTUALENV PYTHON=${VIRTUALENV}/bin/python "$PYTHON" -m pip install --upgrade pip==10.0.1 "$PYTHON" -m pip install --upgrade futures diff --git a/tools/run_tests/sanity/check_bazel_workspace.py b/tools/run_tests/sanity/check_bazel_workspace.py index d7634bd611b..73b13a883d8 100755 --- a/tools/run_tests/sanity/check_bazel_workspace.py +++ b/tools/run_tests/sanity/check_bazel_workspace.py @@ -136,7 +136,7 @@ build_rules = { 'git_repository': lambda **args: eval_state.git_repository(**args), 'grpc_python_deps': lambda: None, } -exec (bazel_file) in build_rules +exec(bazel_file) in build_rules for name in _GRPC_DEP_NAMES: assert name in names_and_urls.keys() assert len(_GRPC_DEP_NAMES) == len(names_and_urls.keys()) @@ -179,7 +179,7 @@ for name in _GRPC_DEP_NAMES: 'git_repository': lambda **args: state.git_repository(**args), 'grpc_python_deps': lambda *args, **kwargs: None, } - exec (bazel_file) in rules + exec(bazel_file) in rules assert name not in names_and_urls_with_overridden_name.keys() sys.exit(0) From 853a6318b439b4bed1ea0707831b5d726ce286f1 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Tue, 20 Aug 2019 08:43:32 -0700 Subject: [PATCH 1300/1555] Correct the disable pattern --- src/python/grpcio_tests/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/grpcio_tests/commands.py b/src/python/grpcio_tests/commands.py index a3912cda712..aa947329230 100644 --- a/src/python/grpcio_tests/commands.py +++ b/src/python/grpcio_tests/commands.py @@ -156,7 +156,7 @@ class TestGevent(setuptools.Command): # TODO(https://github.com/grpc/grpc/issues/15411) enable this test 'unit._cython._channel_test.ChannelTest.test_negative_deadline_connectivity' # TODO(https://github.com/grpc/grpc/issues/15411) enable this test - 'unit._local_credentials_test.LocalCredentialsTest.test_local_tcp', + 'unit._local_credentials_test.LocalCredentialsTest', ) BANNED_WINDOWS_TESTS = ( # TODO(https://github.com/grpc/grpc/pull/15411) enable this test From 17bc1cecf4f53874d765d482032704e41ecd3e6f Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 20 Aug 2019 09:26:14 -0700 Subject: [PATCH 1301/1555] Increase timeout for macos/grpc-node test to 120 minutes --- tools/internal_ci/macos/grpc_basictests_node.cfg | 2 +- tools/internal_ci/macos/pull_request/grpc_basictests_node.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/internal_ci/macos/grpc_basictests_node.cfg b/tools/internal_ci/macos/grpc_basictests_node.cfg index 9dfd6a7b9e8..b2ea7bc505c 100644 --- a/tools/internal_ci/macos/grpc_basictests_node.cfg +++ b/tools/internal_ci/macos/grpc_basictests_node.cfg @@ -17,7 +17,7 @@ # Location of the continuous shell script in repository. build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" -timeout_mins: 60 +timeout_mins: 120 action { define_artifacts { regex: "**/*sponge_log.*" diff --git a/tools/internal_ci/macos/pull_request/grpc_basictests_node.cfg b/tools/internal_ci/macos/pull_request/grpc_basictests_node.cfg index ed729ef5a91..e0eed76f4bb 100644 --- a/tools/internal_ci/macos/pull_request/grpc_basictests_node.cfg +++ b/tools/internal_ci/macos/pull_request/grpc_basictests_node.cfg @@ -17,7 +17,7 @@ # Location of the continuous shell script in repository. build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" -timeout_mins: 60 +timeout_mins: 120 action { define_artifacts { regex: "**/*sponge_log.*" From 5877f2e56b0b7c2c65cc0cda213cc4becb815418 Mon Sep 17 00:00:00 2001 From: Nicolas Noble Date: Tue, 20 Aug 2019 10:54:48 -0700 Subject: [PATCH 1302/1555] Fixing gcc8's no-unknown-warning-option issue. Before gcc8, it was ignoring any unknown -Wno-* command, leaving clang's -Wno-unknown-warning-option to mix. That's no longer the case. --- Makefile | 8 +++++++- build.yaml | 2 +- grpc.gyp | 6 +++--- templates/Makefile.template | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index a0692f38d20..ec88bd3926c 100644 --- a/Makefile +++ b/Makefile @@ -330,6 +330,12 @@ ifeq ($(HAS_WORKING_NO_MAYBE_UNINITIALIZED),true) W_NO_MAYBE_UNINITIALIZED=-Wno-maybe-uninitialized NO_W_NO_MAYBE_UNINITIALIZED=-Wmaybe-uninitialized endif +CHECK_NO_UNKNOWN_WARNING_OPTION_WORKS_CMD = $(CC) -std=c99 -Werror -Wno-unknown-warning-option -o $(TMPOUT) -c test/build/no-unknown-warning-option.c +HAS_WORKING_NO_UNKNOWN_WARNING_OPTION = $(shell $(CHECK_NO_UNKNOWN_WARNING_OPTION_WORKS_CMD) 2> /dev/null && echo true || echo false) +ifeq ($(HAS_WORKING_NO_UNKNOWN_WARNING_OPTION),true) +W_NO_UNKNOWN_WARNING_OPTION=-Wno-unknown-warning-option +NO_W_NO_UNKNOWN_WARNING_OPTION=-Wunknown-warning-option +endif # The HOST compiler settings are used to compile the protoc plugins. # In most cases, you won't have to change anything, but if you are @@ -348,7 +354,7 @@ CXXFLAGS += -stdlib=libc++ LDFLAGS += -framework CoreFoundation endif CXXFLAGS += -Wnon-virtual-dtor -CPPFLAGS += -g -Wall -Wextra -Werror -Wno-unknown-warning-option -Wno-long-long -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-maybe-uninitialized -DPB_FIELD_32BIT -DOSATOMIC_USE_INLINED=1 -Ithird_party/nanopb -Ithird_party/upb -Isrc/core/ext/upb-generated +CPPFLAGS += -g -Wall -Wextra -Werror $(W_NO_UNKNOWN_WARNING_OPTION) -Wno-long-long -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-maybe-uninitialized -DPB_FIELD_32BIT -DOSATOMIC_USE_INLINED=1 -Ithird_party/nanopb -Ithird_party/upb -Isrc/core/ext/upb-generated COREFLAGS += -fno-rtti -fno-exceptions LDFLAGS += -g diff --git a/build.yaml b/build.yaml index 7431dbb2a53..f43964408d4 100644 --- a/build.yaml +++ b/build.yaml @@ -6199,7 +6199,7 @@ defaults: CXXFLAGS: $(W_NO_CXX14_COMPAT) global: COREFLAGS: -fno-rtti -fno-exceptions - CPPFLAGS: -g -Wall -Wextra -Werror -Wno-unknown-warning-option -Wno-long-long + CPPFLAGS: -g -Wall -Wextra -Werror $(W_NO_UNKNOWN_WARNING_OPTION) -Wno-long-long -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-maybe-uninitialized -DPB_FIELD_32BIT -DOSATOMIC_USE_INLINED=1 -Ithird_party/nanopb diff --git a/grpc.gyp b/grpc.gyp index ba847d99548..1e0a0f766ee 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -55,7 +55,7 @@ '-Wall', '-Wextra', '-Werror', - '-Wno-unknown-warning-option', + '$(W_NO_UNKNOWN_WARNING_OPTION)', '-Wno-long-long', '-Wno-unused-parameter', '-Wno-deprecated-declarations', @@ -146,7 +146,7 @@ '-Wall', '-Wextra', '-Werror', - '-Wno-unknown-warning-option', + '$(W_NO_UNKNOWN_WARNING_OPTION)', '-Wno-long-long', '-Wno-unused-parameter', '-Wno-deprecated-declarations', @@ -168,7 +168,7 @@ '-Wall', '-Wextra', '-Werror', - '-Wno-unknown-warning-option', + '$(W_NO_UNKNOWN_WARNING_OPTION)', '-Wno-long-long', '-Wno-unused-parameter', '-Wno-deprecated-declarations', diff --git a/templates/Makefile.template b/templates/Makefile.template index c7f8a05739e..89415fa69b5 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -37,7 +37,7 @@ # warnings we'd like, but that dont exist in all compilers PREFERRED_WARNINGS=['extra-semi'] - CHECK_WARNINGS=PREFERRED_WARNINGS + ['no-shift-negative-value', 'no-unused-but-set-variable', 'no-maybe-uninitialized'] + CHECK_WARNINGS=PREFERRED_WARNINGS + ['no-shift-negative-value', 'no-unused-but-set-variable', 'no-maybe-uninitialized', 'no-unknown-warning-option'] def warning_var(fmt, warning): return fmt % warning.replace('-', '_').replace('+', 'X').upper() From 257737f2c63b85ec760e0375f430dccb6e71420d Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Tue, 20 Aug 2019 11:18:45 -0700 Subject: [PATCH 1303/1555] Fix warning in client_idle_filter.cc to support gcc8 --- src/core/ext/filters/client_idle/client_idle_filter.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/ext/filters/client_idle/client_idle_filter.cc b/src/core/ext/filters/client_idle/client_idle_filter.cc index 13c35ae3730..0e598b0649a 100644 --- a/src/core/ext/filters/client_idle/client_idle_filter.cc +++ b/src/core/ext/filters/client_idle/client_idle_filter.cc @@ -370,7 +370,7 @@ void ChannelData::EnterIdle() { // Hold a ref to the channel stack for the transport op. GRPC_CHANNEL_STACK_REF(channel_stack_, "idle transport op"); // Initialize the transport op. - memset(&idle_transport_op_, 0, sizeof(idle_transport_op_)); + idle_transport_op_ = {}; idle_transport_op_.disconnect_with_error = grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("enter idle"), GRPC_ERROR_INT_CHANNEL_CONNECTIVITY_STATE, GRPC_CHANNEL_IDLE); From 5bf71fa4b77083bf4c48155bcddaf73e33b5b650 Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Tue, 20 Aug 2019 11:50:58 -0700 Subject: [PATCH 1304/1555] Add a developer trick to the installation doc, reorganize a bit --- BUILDING.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/BUILDING.md b/BUILDING.md index 615b371db6e..e4269a25956 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -14,6 +14,7 @@ If you plan to build from source and run tests, install the following as well: $ [sudo] apt-get install libgflags-dev libgtest-dev $ [sudo] apt-get install clang libc++-dev ``` +Lastly, see the Protoc section below if you do not yet have the protoc compiler installed. ## MacOS @@ -46,6 +47,7 @@ installed by `brew` is being used: ```sh $ LIBTOOL=glibtool LIBTOOLIZE=glibtoolize make ``` +Lastly, see the Protoc section below if you do not yet have the protoc compiler. ## Windows @@ -112,6 +114,12 @@ From the grpc repository root ```sh $ make ``` +NOTE: if you get an error on linux such as 'aclocal-1.15: command not found', which can happen if you ran 'make' before installing the pre-reqs, try the following: +```sh +$ git clean -f -d -x && git submodule foreach --recursive git clean -f -d -x +$ [sudo] apt-get install build-essential autoconf libtool pkg-config +$ make +``` ## bazel From b49ba51f84c24b46b7ab4c42c3fb160c6cd94df5 Mon Sep 17 00:00:00 2001 From: Nicolas Noble Date: Tue, 20 Aug 2019 12:38:18 -0700 Subject: [PATCH 1305/1555] Forgot one file. --- test/build/no-unknown-warning-option.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test/build/no-unknown-warning-option.c diff --git a/test/build/no-unknown-warning-option.c b/test/build/no-unknown-warning-option.c new file mode 100644 index 00000000000..0c1771c7bbd --- /dev/null +++ b/test/build/no-unknown-warning-option.c @@ -0,0 +1,19 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +int main(void) {} From eabc64d1967bba0e70d0def189167d42d68bdf43 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 20 Aug 2019 13:13:49 -0700 Subject: [PATCH 1306/1555] Add v1.23.0 to interop matrix --- tools/interop_matrix/client_matrix.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index 51a47d92f97..a98440b3109 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -99,6 +99,7 @@ LANG_RELEASE_MATRIX = { ('v1.20.0', ReleaseInfo()), ('v1.21.4', ReleaseInfo()), ('v1.22.0', ReleaseInfo()), + ('v1.23.0', ReleaseInfo()), ]), 'go': OrderedDict( @@ -214,6 +215,7 @@ LANG_RELEASE_MATRIX = { ('v1.20.0', ReleaseInfo()), ('v1.21.4', ReleaseInfo()), ('v1.22.0', ReleaseInfo()), + ('v1.23.0', ReleaseInfo()), ]), 'node': OrderedDict([ @@ -264,6 +266,7 @@ LANG_RELEASE_MATRIX = { ('v1.20.0', ReleaseInfo()), ('v1.21.4', ReleaseInfo()), ('v1.22.0', ReleaseInfo()), + ('v1.23.0', ReleaseInfo()), # TODO: https://github.com/grpc/grpc/issues/18262. # If you are not encountering the error in above issue # go ahead and upload the docker image for new releases. @@ -292,6 +295,7 @@ LANG_RELEASE_MATRIX = { # See https://github.com/grpc/grpc/issues/18264 ('v1.21.4', ReleaseInfo()), ('v1.22.0', ReleaseInfo()), + ('v1.23.0', ReleaseInfo()), ]), 'csharp': OrderedDict([ @@ -323,5 +327,6 @@ LANG_RELEASE_MATRIX = { ('v1.20.0', ReleaseInfo()), ('v1.21.4', ReleaseInfo()), ('v1.22.0', ReleaseInfo()), + ('v1.23.0', ReleaseInfo()), ]), } From 09c55da6c2a2de682fa31acd0d2d313109cdb353 Mon Sep 17 00:00:00 2001 From: Christopher Warrington Date: Tue, 7 May 2019 12:14:40 -0700 Subject: [PATCH 1307/1555] Update Google Benchmark v1.5.0 to get CMake < 3.6 fix Google Benchmark v1.4.1 uses a CMake feature that is only in version >= 3.6. This was an inadvertent change in Google Benchmark (too high of a version) that has been [fixed upstream][1] in v1.5.0. Google Benchmark v1.5.0 now requires CMake >= 3.5.1. [Another PR][2] will bump gRPC's minimum version as well. [1]: https://github.com/google/benchmark/commit/505be96ab23056580a3a2315abba048f4428b04e [2]: https://github.com/grpc/grpc/pull/19467 --- third_party/benchmark | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/benchmark b/third_party/benchmark index e776aa0275e..090faecb454 160000 --- a/third_party/benchmark +++ b/third_party/benchmark @@ -1 +1 @@ -Subproject commit e776aa0275e293707b6a0901e0e8d8a8a3679508 +Subproject commit 090faecb454fbd6e6e17a75ef8146acb037118d4 From 09a270d6ad5632538b4f0e11a9cda9898b3491d1 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 20 Aug 2019 13:38:55 -0700 Subject: [PATCH 1308/1555] Gracefully handle errors from callbacks. In https://github.com/grpc/grpc/issues/19910, it was pointed out that raising an exception from a Future callback would cause the channel spin thread to terminate. If there are outstanding events on the channel, this will cause calls to Channel.close() to block indefinitely. This commit ensures that the channel spin thread does not die. Instead, exceptions will be logged at ERROR level. --- src/python/grpcio/grpc/__init__.py | 3 + src/python/grpcio/grpc/_channel.py | 11 ++- .../tests/unit/_channel_close_test.py | 67 ++++++++++++++++--- 3 files changed, 71 insertions(+), 10 deletions(-) diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index 7dae90c89e8..e14db7906da 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -192,6 +192,9 @@ class Future(six.with_metaclass(abc.ABCMeta)): If the computation has already completed, the callback will be called immediately. + Exceptions raised in the callback will be logged at ERROR level, but + will not terminate any threads of execution. + Args: fn: A callable taking this Future object as its single parameter. """ diff --git a/src/python/grpcio/grpc/_channel.py b/src/python/grpcio/grpc/_channel.py index 0bf8e03b5ce..b19c64d3a6e 100644 --- a/src/python/grpcio/grpc/_channel.py +++ b/src/python/grpcio/grpc/_channel.py @@ -159,7 +159,14 @@ def _event_handler(state, response_deserializer): state.condition.notify_all() done = not state.due for callback in callbacks: - callback() + # TODO(gnossen): Are these *only* user callbacks? + try: + callback() + except Exception as e: # pylint: disable=broad-except + # NOTE(rbellevi): We suppress but log errors here so as not to + # kill the channel spin thread. + logging.error('Exception in callback %s: %s', repr( + callback.func), repr(e)) return done and state.fork_epoch >= cygrpc.get_fork_epoch() return handle_event @@ -338,7 +345,7 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call): # pylint: disable=too def add_done_callback(self, fn): with self._state.condition: if self._state.code is None: - self._state.callbacks.append(lambda: fn(self)) + self._state.callbacks.append(functools.partial(fn, self)) return fn(self) diff --git a/src/python/grpcio_tests/tests/unit/_channel_close_test.py b/src/python/grpcio_tests/tests/unit/_channel_close_test.py index 82fa1657109..571504c6e3f 100644 --- a/src/python/grpcio_tests/tests/unit/_channel_close_test.py +++ b/src/python/grpcio_tests/tests/unit/_channel_close_test.py @@ -27,8 +27,11 @@ _BEAT = 0.5 _SOME_TIME = 5 _MORE_TIME = 10 +_STREAM_URI = 'Meffod' +_UNARY_URI = 'MeffodMan' -class _MethodHandler(grpc.RpcMethodHandler): + +class _StreamingMethodHandler(grpc.RpcMethodHandler): request_streaming = True response_streaming = True @@ -40,13 +43,28 @@ class _MethodHandler(grpc.RpcMethodHandler): yield request * 2 -_METHOD_HANDLER = _MethodHandler() +class _UnaryMethodHandler(grpc.RpcMethodHandler): + + request_streaming = False + response_streaming = False + request_deserializer = None + response_serializer = None + + def unary_unary(self, request, servicer_context): + return request * 2 + + +_STREAMING_METHOD_HANDLER = _StreamingMethodHandler() +_UNARY_METHOD_HANDLER = _UnaryMethodHandler() class _GenericHandler(grpc.GenericRpcHandler): def service(self, handler_call_details): - return _METHOD_HANDLER + if handler_call_details.method == _STREAM_URI: + return _STREAMING_METHOD_HANDLER + else: + return _UNARY_METHOD_HANDLER _GENERIC_HANDLER = _GenericHandler() @@ -94,6 +112,24 @@ class _Pipe(object): self.close() +class EndlessIterator(object): + + def __init__(self, msg): + self._msg = msg + + def __iter__(self): + return self + + def _next(self): + return self._msg + + def __next__(self): + return self._next() + + def next(self): + return self._next() + + class ChannelCloseTest(unittest.TestCase): def setUp(self): @@ -108,7 +144,7 @@ class ChannelCloseTest(unittest.TestCase): def test_close_immediately_after_call_invocation(self): channel = grpc.insecure_channel('localhost:{}'.format(self._port)) - multi_callable = channel.stream_stream('Meffod') + multi_callable = channel.stream_stream(_STREAM_URI) request_iterator = _Pipe(()) response_iterator = multi_callable(request_iterator) channel.close() @@ -118,7 +154,7 @@ class ChannelCloseTest(unittest.TestCase): def test_close_while_call_active(self): channel = grpc.insecure_channel('localhost:{}'.format(self._port)) - multi_callable = channel.stream_stream('Meffod') + multi_callable = channel.stream_stream(_STREAM_URI) request_iterator = _Pipe((b'abc',)) response_iterator = multi_callable(request_iterator) next(response_iterator) @@ -130,7 +166,7 @@ class ChannelCloseTest(unittest.TestCase): def test_context_manager_close_while_call_active(self): with grpc.insecure_channel('localhost:{}'.format( self._port)) as channel: # pylint: disable=bad-continuation - multi_callable = channel.stream_stream('Meffod') + multi_callable = channel.stream_stream(_STREAM_URI) request_iterator = _Pipe((b'abc',)) response_iterator = multi_callable(request_iterator) next(response_iterator) @@ -141,7 +177,7 @@ class ChannelCloseTest(unittest.TestCase): def test_context_manager_close_while_many_calls_active(self): with grpc.insecure_channel('localhost:{}'.format( self._port)) as channel: # pylint: disable=bad-continuation - multi_callable = channel.stream_stream('Meffod') + multi_callable = channel.stream_stream(_STREAM_URI) request_iterators = tuple( _Pipe((b'abc',)) for _ in range(test_constants.THREAD_CONCURRENCY)) @@ -158,7 +194,7 @@ class ChannelCloseTest(unittest.TestCase): def test_many_concurrent_closes(self): channel = grpc.insecure_channel('localhost:{}'.format(self._port)) - multi_callable = channel.stream_stream('Meffod') + multi_callable = channel.stream_stream(_STREAM_URI) request_iterator = _Pipe((b'abc',)) response_iterator = multi_callable(request_iterator) next(response_iterator) @@ -181,6 +217,21 @@ class ChannelCloseTest(unittest.TestCase): self.assertIs(response_iterator.code(), grpc.StatusCode.CANCELLED) + def test_exception_in_callback(self): + with grpc.insecure_channel('localhost:{}'.format( + self._port)) as channel: + stream_multi_callable = channel.stream_stream(_STREAM_URI) + request_iterator = (str(i).encode('ascii') for i in range(9999)) + endless_iterator = EndlessIterator(b'abc') + stream_response_iterator = stream_multi_callable(endless_iterator) + future = channel.unary_unary(_UNARY_URI).future(b'abc') + + def on_done_callback(future): + raise Exception("This should not cause a deadlock.") + + future.add_done_callback(on_done_callback) + future.result() + if __name__ == '__main__': logging.basicConfig() From ee99f9aa4c45e9d29c7649ac5a4e0690c26534f8 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 20 Aug 2019 14:25:14 -0700 Subject: [PATCH 1309/1555] Remove TODO --- src/python/grpcio/grpc/_channel.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/python/grpcio/grpc/_channel.py b/src/python/grpcio/grpc/_channel.py index b19c64d3a6e..f1584940a86 100644 --- a/src/python/grpcio/grpc/_channel.py +++ b/src/python/grpcio/grpc/_channel.py @@ -159,7 +159,6 @@ def _event_handler(state, response_deserializer): state.condition.notify_all() done = not state.due for callback in callbacks: - # TODO(gnossen): Are these *only* user callbacks? try: callback() except Exception as e: # pylint: disable=broad-except From d273fdf41d557f126fe227a0c8858397c0effca7 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 20 Aug 2019 14:26:22 -0700 Subject: [PATCH 1310/1555] Remove line of dead code --- src/python/grpcio_tests/tests/unit/_channel_close_test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/python/grpcio_tests/tests/unit/_channel_close_test.py b/src/python/grpcio_tests/tests/unit/_channel_close_test.py index 571504c6e3f..6004c25cc30 100644 --- a/src/python/grpcio_tests/tests/unit/_channel_close_test.py +++ b/src/python/grpcio_tests/tests/unit/_channel_close_test.py @@ -221,7 +221,6 @@ class ChannelCloseTest(unittest.TestCase): with grpc.insecure_channel('localhost:{}'.format( self._port)) as channel: stream_multi_callable = channel.stream_stream(_STREAM_URI) - request_iterator = (str(i).encode('ascii') for i in range(9999)) endless_iterator = EndlessIterator(b'abc') stream_response_iterator = stream_multi_callable(endless_iterator) future = channel.unary_unary(_UNARY_URI).future(b'abc') From 090b4f30ed80cbfac06fcbb7da18c3c1cfacde78 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 20 Aug 2019 14:35:31 -0700 Subject: [PATCH 1311/1555] Add version 1.22.1 to interop test matrix --- tools/interop_matrix/client_matrix.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index a98440b3109..6129b658793 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -99,6 +99,7 @@ LANG_RELEASE_MATRIX = { ('v1.20.0', ReleaseInfo()), ('v1.21.4', ReleaseInfo()), ('v1.22.0', ReleaseInfo()), + ('v1.22.1', ReleaseInfo()), ('v1.23.0', ReleaseInfo()), ]), 'go': @@ -215,6 +216,7 @@ LANG_RELEASE_MATRIX = { ('v1.20.0', ReleaseInfo()), ('v1.21.4', ReleaseInfo()), ('v1.22.0', ReleaseInfo()), + ('v1.22.1', ReleaseInfo()), ('v1.23.0', ReleaseInfo()), ]), 'node': @@ -266,6 +268,7 @@ LANG_RELEASE_MATRIX = { ('v1.20.0', ReleaseInfo()), ('v1.21.4', ReleaseInfo()), ('v1.22.0', ReleaseInfo()), + ('v1.22.1', ReleaseInfo()), ('v1.23.0', ReleaseInfo()), # TODO: https://github.com/grpc/grpc/issues/18262. # If you are not encountering the error in above issue @@ -295,6 +298,7 @@ LANG_RELEASE_MATRIX = { # See https://github.com/grpc/grpc/issues/18264 ('v1.21.4', ReleaseInfo()), ('v1.22.0', ReleaseInfo()), + ('v1.22.1', ReleaseInfo()), ('v1.23.0', ReleaseInfo()), ]), 'csharp': @@ -327,6 +331,7 @@ LANG_RELEASE_MATRIX = { ('v1.20.0', ReleaseInfo()), ('v1.21.4', ReleaseInfo()), ('v1.22.0', ReleaseInfo()), + ('v1.22.1', ReleaseInfo()), ('v1.23.0', ReleaseInfo()), ]), } From 662919cf901287618c5d56f2a216cb386607d831 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 20 Aug 2019 14:49:57 -0700 Subject: [PATCH 1312/1555] Simplify with itertools --- .../tests/unit/_channel_close_test.py | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/src/python/grpcio_tests/tests/unit/_channel_close_test.py b/src/python/grpcio_tests/tests/unit/_channel_close_test.py index 6004c25cc30..47f52b4890e 100644 --- a/src/python/grpcio_tests/tests/unit/_channel_close_test.py +++ b/src/python/grpcio_tests/tests/unit/_channel_close_test.py @@ -13,6 +13,7 @@ # limitations under the License. """Tests server and client side compression.""" +import itertools import logging import threading import time @@ -112,24 +113,6 @@ class _Pipe(object): self.close() -class EndlessIterator(object): - - def __init__(self, msg): - self._msg = msg - - def __iter__(self): - return self - - def _next(self): - return self._msg - - def __next__(self): - return self._next() - - def next(self): - return self._next() - - class ChannelCloseTest(unittest.TestCase): def setUp(self): @@ -221,7 +204,7 @@ class ChannelCloseTest(unittest.TestCase): with grpc.insecure_channel('localhost:{}'.format( self._port)) as channel: stream_multi_callable = channel.stream_stream(_STREAM_URI) - endless_iterator = EndlessIterator(b'abc') + endless_iterator = itertools.repeat(b'abc') stream_response_iterator = stream_multi_callable(endless_iterator) future = channel.unary_unary(_UNARY_URI).future(b'abc') From 2c9cff30a1efc6abc689a7205467dbf251903ec2 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Tue, 20 Aug 2019 14:52:20 -0700 Subject: [PATCH 1313/1555] Fix typo in the ignore list... --- src/python/grpcio_tests/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/grpcio_tests/commands.py b/src/python/grpcio_tests/commands.py index aa947329230..61d8bdc1f7b 100644 --- a/src/python/grpcio_tests/commands.py +++ b/src/python/grpcio_tests/commands.py @@ -154,7 +154,7 @@ class TestGevent(setuptools.Command): 'channelz._channelz_servicer_test.ChannelzServicerTest.test_many_subchannels_and_sockets', 'channelz._channelz_servicer_test.ChannelzServicerTest.test_streaming_rpc', # TODO(https://github.com/grpc/grpc/issues/15411) enable this test - 'unit._cython._channel_test.ChannelTest.test_negative_deadline_connectivity' + 'unit._cython._channel_test.ChannelTest.test_negative_deadline_connectivity', # TODO(https://github.com/grpc/grpc/issues/15411) enable this test 'unit._local_credentials_test.LocalCredentialsTest', ) From f276b89f1163ea10d6de270ea1b69eee18a106d2 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Tue, 20 Aug 2019 15:16:32 -0700 Subject: [PATCH 1314/1555] Fix issue/PR template --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/pull_request_template.md | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 6eafaacd034..f3ed8399dc2 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,7 +1,7 @@ --- name: Report a bug about: Create a report to help us improve -labels: kind/bug +labels: kind/bug, priority/P2 assignees: AspirinSJL --- diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 31f574ef60d..fba14a5db00 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,5 +1,11 @@ - + + @AspirinSJL \ No newline at end of file From 25f21d4824d57e77d43990b243b1a74ccbc18cfc Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Tue, 20 Aug 2019 09:13:22 -0700 Subject: [PATCH 1315/1555] Make default vtable for pointer argumnet a constant --- .../grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi | 2 +- .../grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi | 8 ++++---- src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi | 4 ++-- .../grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi | 1 - .../grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi | 4 +--- src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi | 1 - src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi | 5 ++--- src/python/grpcio/grpc/_cython/_cygrpc/tag.pxd.pxi | 1 - src/python/grpcio/grpc/_cython/_cygrpc/tag.pyx.pxi | 5 ++--- src/python/grpcio/grpc/_cython/_cygrpc/vtable.pxd.pxi | 5 +---- src/python/grpcio/grpc/_cython/_cygrpc/vtable.pyx.pxi | 11 ++++------- 11 files changed, 17 insertions(+), 30 deletions(-) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi index 9415b16344a..251efe15b39 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi @@ -23,7 +23,7 @@ cdef class _ChannelArg: cdef grpc_arg c_argument - cdef void c(self, argument, _VTable vtable, references) except * + cdef void c(self, argument, references) except * cdef class _ChannelArgs: diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi index 9211354b1ca..e121ea60395 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi @@ -33,7 +33,7 @@ cdef grpc_arg _unwrap_grpc_arg(tuple wrapped_arg): cdef class _ChannelArg: - cdef void c(self, argument, _VTable vtable, references) except *: + cdef void c(self, argument, references) except *: key, value = argument cdef bytes encoded_key = _encode(key) if encoded_key is not key: @@ -56,7 +56,7 @@ cdef class _ChannelArg: # lifecycle of the pointer is fixed to the lifecycle of the # python object wrapping it. self.c_argument.type = GRPC_ARG_POINTER - self.c_argument.value.pointer.vtable = &vtable.c_vtable + self.c_argument.value.pointer.vtable = &default_vtable self.c_argument.value.pointer.address = (int(value)) else: raise TypeError( @@ -65,7 +65,7 @@ cdef class _ChannelArg: cdef class _ChannelArgs: - def __cinit__(self, arguments, _VTable vtable not None): + def __cinit__(self, arguments): self._arguments = () if arguments is None else tuple(arguments) self._channel_args = [] self._references = [] @@ -75,7 +75,7 @@ cdef class _ChannelArgs: self._c_arguments.arguments_length * sizeof(grpc_arg)) for index, argument in enumerate(self._arguments): channel_arg = _ChannelArg() - channel_arg.c(argument, vtable, self._references) + channel_arg.c(argument, self._references) self._c_arguments.arguments[index] = channel_arg.c_argument self._channel_args.append(channel_arg) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi index 84934db4d60..6e4574af8d5 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi @@ -17,11 +17,11 @@ cimport cpython cdef class Call: - def __cinit__(self, _VTable vtable not None): + def __cinit__(self): # Create an *empty* call fork_handlers_and_grpc_init() self.c_call = NULL - self.references = [vtable] + self.references = [] def _start_batch(self, operations, tag, retain_self): if not self.is_valid: diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi index 13c0c02ab21..eb27f2df7ad 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi @@ -69,7 +69,6 @@ cdef class SegregatedCall: cdef class Channel: cdef _ChannelState _state - cdef _VTable _vtable # TODO(https://github.com/grpc/grpc/issues/15662): Eliminate this. cdef tuple _arguments diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi index 1799780fce4..70bc8dbed7e 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi @@ -455,9 +455,7 @@ cdef class Channel: self._state.c_connectivity_completion_queue = ( grpc_completion_queue_create_for_next(NULL)) self._arguments = arguments - self._vtable = _VTable() - cdef _ChannelArgs channel_args = _ChannelArgs( - arguments, self._vtable) + cdef _ChannelArgs channel_args = _ChannelArgs(arguments) if channel_credentials is None: self._state.c_channel = grpc_insecure_channel_create( target, channel_args.c_args(), NULL) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi index b3fadcdc62d..b89ed99d97b 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi @@ -16,7 +16,6 @@ cdef class Server: cdef grpc_server *c_server - cdef _VTable _vtable cdef bint is_started # start has been called cdef bint is_shutting_down # shutdown has been called cdef bint is_shutdown # notification of complete shutdown received diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi index 2369371cabe..67b2e9d4e88 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi @@ -31,8 +31,7 @@ cdef class Server: self.is_shutting_down = False self.is_shutdown = False self.c_server = NULL - self._vtable = _VTable() - cdef _ChannelArgs channel_args = _ChannelArgs(arguments, self._vtable) + cdef _ChannelArgs channel_args = _ChannelArgs(arguments) self.c_server = grpc_server_create(channel_args.c_args(), NULL) self.references.append(arguments) @@ -43,7 +42,7 @@ cdef class Server: raise ValueError("server must be started and not shutting down") if server_queue not in self.registered_completion_queues: raise ValueError("server_queue must be a registered completion queue") - cdef _RequestCallTag request_call_tag = _RequestCallTag(tag, self._vtable) + cdef _RequestCallTag request_call_tag = _RequestCallTag(tag) request_call_tag.prepare() cpython.Py_INCREF(request_call_tag) return grpc_server_request_call( diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/tag.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/tag.pxd.pxi index c77beb28194..d8ba1ea9bd5 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/tag.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/tag.pxd.pxi @@ -29,7 +29,6 @@ cdef class _RequestCallTag(_Tag): cdef readonly object _user_tag cdef Call call - cdef _VTable _vtable cdef CallDetails call_details cdef grpc_metadata_array c_invocation_metadata diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/tag.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/tag.pyx.pxi index d1280ef4948..e80dc88767e 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/tag.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/tag.pyx.pxi @@ -30,14 +30,13 @@ cdef class _ConnectivityTag(_Tag): cdef class _RequestCallTag(_Tag): - def __cinit__(self, user_tag, _VTable vtable not None): + def __cinit__(self, user_tag): self._user_tag = user_tag self.call = None self.call_details = None - self._vtable = vtable cdef void prepare(self) except *: - self.call = Call(self._vtable) + self.call = Call() self.call_details = CallDetails() grpc_metadata_array_init(&self.c_invocation_metadata) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/vtable.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/vtable.pxd.pxi index 1799b6e1f14..c96e5cb6696 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/vtable.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/vtable.pxd.pxi @@ -15,12 +15,9 @@ cdef void* _copy_pointer(void* pointer) - cdef void _destroy_pointer(void* pointer) - cdef int _compare_pointer(void* first_pointer, void* second_pointer) -cdef class _VTable: - cdef grpc_arg_pointer_vtable c_vtable +cdef grpc_arg_pointer_vtable default_vtable diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/vtable.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/vtable.pyx.pxi index 98cb60c10e3..da4b81bd97e 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/vtable.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/vtable.pyx.pxi @@ -30,10 +30,7 @@ cdef int _compare_pointer(void* first_pointer, void* second_pointer): else: return 0 - -cdef class _VTable: - def __cinit__(self): - self.c_vtable.copy = &_copy_pointer - self.c_vtable.destroy = &_destroy_pointer - self.c_vtable.cmp = &_compare_pointer - +cdef grpc_arg_pointer_vtable default_vtable +default_vtable.copy = &_copy_pointer +default_vtable.destroy = &_destroy_pointer +default_vtable.cmp = &_compare_pointer From 41986e8ed8c9da70ad6909ac376280512f386e3b Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Wed, 14 Aug 2019 12:08:24 -0700 Subject: [PATCH 1316/1555] Added test for timer wakeups --- CMakeLists.txt | 43 ++++++++ Makefile | 48 +++++++++ build.yaml | 11 ++ src/core/lib/iomgr/timer_manager.cc | 9 +- src/core/lib/iomgr/timer_manager.h | 2 + test/cpp/common/BUILD | 13 ++- test/cpp/common/timer_test.cc | 150 +++++++++++++++++++++++++++ tools/run_tests/generated/tests.json | 24 +++++ 8 files changed, 298 insertions(+), 2 deletions(-) create mode 100644 test/cpp/common/timer_test.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 86a77c95663..ce632d9e1fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -731,6 +731,7 @@ add_dependencies(buildtests_cxx thread_stress_test) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx time_change_test) endif() +add_dependencies(buildtests_cxx timer_test) add_dependencies(buildtests_cxx transport_pid_controller_test) add_dependencies(buildtests_cxx transport_security_common_api_test) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) @@ -17679,6 +17680,48 @@ endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) +add_executable(timer_test + test/cpp/common/timer_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(timer_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(timer_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + grpc++ + grpc + gpr + ${_gRPC_GFLAGS_LIBRARIES} +) + + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + add_executable(transport_pid_controller_test test/core/transport/pid_controller_test.cc third_party/googletest/googletest/src/gtest-all.cc diff --git a/Makefile b/Makefile index a0692f38d20..2f86c96d379 100644 --- a/Makefile +++ b/Makefile @@ -1287,6 +1287,7 @@ string_view_test: $(BINDIR)/$(CONFIG)/string_view_test thread_manager_test: $(BINDIR)/$(CONFIG)/thread_manager_test thread_stress_test: $(BINDIR)/$(CONFIG)/thread_stress_test time_change_test: $(BINDIR)/$(CONFIG)/time_change_test +timer_test: $(BINDIR)/$(CONFIG)/timer_test transport_pid_controller_test: $(BINDIR)/$(CONFIG)/transport_pid_controller_test transport_security_common_api_test: $(BINDIR)/$(CONFIG)/transport_security_common_api_test writes_per_rpc_test: $(BINDIR)/$(CONFIG)/writes_per_rpc_test @@ -1758,6 +1759,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/thread_manager_test \ $(BINDIR)/$(CONFIG)/thread_stress_test \ $(BINDIR)/$(CONFIG)/time_change_test \ + $(BINDIR)/$(CONFIG)/timer_test \ $(BINDIR)/$(CONFIG)/transport_pid_controller_test \ $(BINDIR)/$(CONFIG)/transport_security_common_api_test \ $(BINDIR)/$(CONFIG)/writes_per_rpc_test \ @@ -1926,6 +1928,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/thread_manager_test \ $(BINDIR)/$(CONFIG)/thread_stress_test \ $(BINDIR)/$(CONFIG)/time_change_test \ + $(BINDIR)/$(CONFIG)/timer_test \ $(BINDIR)/$(CONFIG)/transport_pid_controller_test \ $(BINDIR)/$(CONFIG)/transport_security_common_api_test \ $(BINDIR)/$(CONFIG)/writes_per_rpc_test \ @@ -2471,6 +2474,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/thread_stress_test || ( echo test thread_stress_test failed ; exit 1 ) $(E) "[RUN] Testing time_change_test" $(Q) $(BINDIR)/$(CONFIG)/time_change_test || ( echo test time_change_test failed ; exit 1 ) + $(E) "[RUN] Testing timer_test" + $(Q) $(BINDIR)/$(CONFIG)/timer_test || ( echo test timer_test failed ; exit 1 ) $(E) "[RUN] Testing transport_pid_controller_test" $(Q) $(BINDIR)/$(CONFIG)/transport_pid_controller_test || ( echo test transport_pid_controller_test failed ; exit 1 ) $(E) "[RUN] Testing transport_security_common_api_test" @@ -19809,6 +19814,49 @@ endif endif +TIMER_TEST_SRC = \ + test/cpp/common/timer_test.cc \ + +TIMER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(TIMER_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/timer_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/timer_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/timer_test: $(PROTOBUF_DEP) $(TIMER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(TIMER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/timer_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/cpp/common/timer_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_timer_test: $(TIMER_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(TIMER_TEST_OBJS:.o=.dep) +endif +endif + + TRANSPORT_PID_CONTROLLER_TEST_SRC = \ test/core/transport/pid_controller_test.cc \ diff --git a/build.yaml b/build.yaml index 7431dbb2a53..7cebdd3c78d 100644 --- a/build.yaml +++ b/build.yaml @@ -5973,6 +5973,17 @@ targets: - mac - linux - posix +- name: timer_test + gtest: true + build: test + language: c++ + src: + - test/cpp/common/timer_test.cc + deps: + - grpc_test_util + - grpc++ + - grpc + - gpr - name: transport_pid_controller_test build: test language: c++ diff --git a/src/core/lib/iomgr/timer_manager.cc b/src/core/lib/iomgr/timer_manager.cc index 17cae5cd4c3..96d502c5108 100644 --- a/src/core/lib/iomgr/timer_manager.cc +++ b/src/core/lib/iomgr/timer_manager.cc @@ -18,6 +18,8 @@ #include +#include "src/core/lib/iomgr/timer_manager.h" + #include #include @@ -26,7 +28,6 @@ #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/timer.h" -#include "src/core/lib/iomgr/timer_manager.h" struct completed_thread { grpc_core::Thread thd; @@ -58,6 +59,8 @@ static bool g_has_timed_waiter; static grpc_millis g_timed_waiter_deadline; // generation counter to track which thread is waiting for the next timer static uint64_t g_timed_waiter_generation; +// number of timer wakeups +static uint64_t g_wakeups; static void timer_thread(void* completed_thread_ptr); @@ -206,6 +209,7 @@ static bool wait_until(grpc_millis next) { // that there's now no timed waiter... we'll look for a replacement if // there's work to do after checking timers (code above) if (my_timed_waiter_generation == g_timed_waiter_generation) { + ++g_wakeups; g_has_timed_waiter = false; g_timed_waiter_deadline = GRPC_MILLIS_INF_FUTURE; } @@ -326,6 +330,7 @@ static void stop_threads(void) { gc_completed_threads(); } } + g_wakeups = 0; gpr_mu_unlock(&g_mu); } @@ -354,3 +359,5 @@ void grpc_kick_poller(void) { gpr_cv_signal(&g_cv_wait); gpr_mu_unlock(&g_mu); } + +uint64_t grpc_timer_manager_get_wakeups_testonly(void) { return g_wakeups; } diff --git a/src/core/lib/iomgr/timer_manager.h b/src/core/lib/iomgr/timer_manager.h index 00dcdc461b5..d407cbbc2b7 100644 --- a/src/core/lib/iomgr/timer_manager.h +++ b/src/core/lib/iomgr/timer_manager.h @@ -35,5 +35,7 @@ void grpc_timer_manager_set_threading(bool enabled); /* explicitly perform one tick of the timer system - for when threading is * disabled */ void grpc_timer_manager_tick(void); +/* get global counter that tracks timer wakeups */ +uint64_t grpc_timer_manager_get_wakeups_testonly(void); #endif /* GRPC_CORE_LIB_IOMGR_TIMER_MANAGER_H */ diff --git a/test/cpp/common/BUILD b/test/cpp/common/BUILD index b67c1995ff7..f0d0e9a6223 100644 --- a/test/cpp/common/BUILD +++ b/test/cpp/common/BUILD @@ -28,7 +28,18 @@ grpc_cc_test( "//:grpc++_unsecure", "//test/core/util:grpc_test_util_unsecure", ], - tags = ["no_windows"], +) + +grpc_cc_test( + name = "timer_test", + srcs = ["timer_test.cc"], + external_deps = [ + "gtest", + ], + deps = [ + "//:grpc++", + "//test/core/util:grpc_test_util", + ], ) grpc_cc_test( diff --git a/test/cpp/common/timer_test.cc b/test/cpp/common/timer_test.cc new file mode 100644 index 00000000000..f5083d66e76 --- /dev/null +++ b/test/cpp/common/timer_test.cc @@ -0,0 +1,150 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include + +#include "src/core/lib/iomgr/closure.h" +#include "src/core/lib/iomgr/error.h" +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/timer.h" +#include "src/core/lib/iomgr/timer_manager.h" +#include "test/core/util/test_config.h" + +// MAYBE_SKIP_TEST is a macro to determine if this particular test configuration +// should be skipped based on a decision made at SetUp time. +#define MAYBE_SKIP_TEST \ + do { \ + if (do_not_test_) { \ + return; \ + } \ + } while (0) + +class TimerTest : public ::testing::Test { + protected: + void SetUp() override { + // Skip test if slowdown factor > 1. + do_not_test_ = (grpc_test_slowdown_factor() != 1); + grpc_init(); + } + + void TearDown() override { grpc_shutdown_blocking(); } + + bool do_not_test_{false}; +}; + +TEST_F(TimerTest, NoTimers) { + MAYBE_SKIP_TEST; + grpc_core::ExecCtx exec_ctx; + gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(1500)); + + // We expect to get 1 wakeup per second. Sometimes we also get a wakeup + // during initialization, so in 1.5 seconds we expect to get 1 or 2 wakeups. + int64_t wakeups = grpc_timer_manager_get_wakeups_testonly(); + GPR_ASSERT(wakeups == 1 || wakeups == 2); +} + +TEST_F(TimerTest, OneTimerExpires) { + MAYBE_SKIP_TEST; + grpc_core::ExecCtx exec_ctx; + grpc_timer timer; + int timer_fired = 0; + grpc_timer_init(&timer, 500, + GRPC_CLOSURE_CREATE( + [](void* arg, grpc_error*) { + int* timer_fired = static_cast(arg); + ++*timer_fired; + }, + &timer_fired, grpc_schedule_on_exec_ctx)); + gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(1500)); + GPR_ASSERT(1 == timer_fired); + + // We expect to get 1 wakeup/second + 1 wakeup for the expired timer + maybe 1 + // wakeup during initialization. i.e. in 1.5 seconds we expect 2 or 3 wakeups. + // Actual number of wakeups is more due to bug + // https://github.com/grpc/grpc/issues/19947 + int64_t wakeups = grpc_timer_manager_get_wakeups_testonly(); + gpr_log(GPR_DEBUG, "wakeups: %" PRId64 "", wakeups); +} + +TEST_F(TimerTest, MultipleTimersExpire) { + MAYBE_SKIP_TEST; + grpc_core::ExecCtx exec_ctx; + const int kNumTimers = 10; + grpc_timer timers[kNumTimers]; + int timer_fired = 0; + for (int i = 0; i < kNumTimers; ++i) { + grpc_timer_init(&timers[i], 500 + i, + GRPC_CLOSURE_CREATE( + [](void* arg, grpc_error*) { + int* timer_fired = static_cast(arg); + ++*timer_fired; + }, + &timer_fired, grpc_schedule_on_exec_ctx)); + } + + gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(1500)); + GPR_ASSERT(kNumTimers == timer_fired); + + // We expect to get 1 wakeup/second + 1 wakeup for per timer fired + maybe 1 + // wakeup during initialization. i.e. in 1.5 seconds we expect 11 or 12 + // wakeups. Actual number of wakeups is more due to bug + // https://github.com/grpc/grpc/issues/19947 + int64_t wakeups = grpc_timer_manager_get_wakeups_testonly(); + gpr_log(GPR_DEBUG, "wakeups: %" PRId64 "", wakeups); +} + +TEST_F(TimerTest, CancelSomeTimers) { + MAYBE_SKIP_TEST; + grpc_core::ExecCtx exec_ctx; + const int kNumTimers = 10; + grpc_timer timers[kNumTimers]; + int timer_fired = 0; + for (int i = 0; i < kNumTimers; ++i) { + grpc_timer_init(&timers[i], 500 + i, + GRPC_CLOSURE_CREATE( + [](void* arg, grpc_error* error) { + if (error == GRPC_ERROR_CANCELLED) { + return; + } + int* timer_fired = static_cast(arg); + ++*timer_fired; + }, + &timer_fired, grpc_schedule_on_exec_ctx)); + } + for (int i = 0; i < kNumTimers / 2; ++i) { + grpc_timer_cancel(&timers[i]); + } + + gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(1500)); + GPR_ASSERT(kNumTimers / 2 == timer_fired); + + // We expect to get 1 wakeup/second + 1 wakeup per timer fired + maybe 1 + // wakeup during initialization. i.e. in 1.5 seconds we expect 6 or 7 wakeups. + // Actual number of wakeups is more due to bug + // https://github.com/grpc/grpc/issues/19947 + int64_t wakeups = grpc_timer_manager_get_wakeups_testonly(); + gpr_log(GPR_DEBUG, "wakeups: %" PRId64 "", wakeups); +} + +int main(int argc, char** argv) { + grpc::testing::TestEnvironment env(argc, argv); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 6dd3f1422e5..a6efca9014b 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -5988,6 +5988,30 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "timer_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": true + }, { "args": [], "benchmark": false, From 59564ebd9628c8e0159894427c614a13e8dd56e5 Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Tue, 20 Aug 2019 16:02:53 -0700 Subject: [PATCH 1317/1555] Fix warnings to unblock gcc8 support --- test/core/http/httpcli_test.cc | 4 ++-- test/core/http/httpscli_test.cc | 4 ++-- test/core/http/parser_test.cc | 4 ++-- test/core/http/response_fuzzer.cc | 2 +- test/core/security/credentials_test.cc | 8 ++++---- test/core/security/jwt_verifier_test.cc | 2 +- test/core/security/oauth2_utils.cc | 2 +- test/core/transport/chttp2/hpack_encoder_test.cc | 4 ++-- test/cpp/microbenchmarks/bm_call_create.cc | 2 +- test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 4 ++-- test/cpp/microbenchmarks/bm_chttp2_transport.cc | 10 +++++----- 11 files changed, 23 insertions(+), 23 deletions(-) diff --git a/test/core/http/httpcli_test.cc b/test/core/http/httpcli_test.cc index bfd75f86491..423cb700c6a 100644 --- a/test/core/http/httpcli_test.cc +++ b/test/core/http/httpcli_test.cc @@ -77,7 +77,7 @@ static void test_get(int port) { req.handshaker = &grpc_httpcli_plaintext; grpc_http_response response; - memset(&response, 0, sizeof(response)); + response = {}; grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_get"); grpc_httpcli_get( &g_context, &g_pops, resource_quota, &req, n_seconds_time(15), @@ -116,7 +116,7 @@ static void test_post(int port) { req.handshaker = &grpc_httpcli_plaintext; grpc_http_response response; - memset(&response, 0, sizeof(response)); + response = {}; grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_post"); grpc_httpcli_post( &g_context, &g_pops, resource_quota, &req, "hello", 5, n_seconds_time(15), diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc index e7250c206d8..eb63367d750 100644 --- a/test/core/http/httpscli_test.cc +++ b/test/core/http/httpscli_test.cc @@ -81,7 +81,7 @@ static void test_get(int port) { req.handshaker = &grpc_httpcli_ssl; grpc_http_response response; - memset(&response, 0, sizeof(response)); + response = {}; grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_get"); grpc_httpcli_get( &g_context, &g_pops, resource_quota, &req, n_seconds_time(15), @@ -121,7 +121,7 @@ static void test_post(int port) { req.handshaker = &grpc_httpcli_ssl; grpc_http_response response; - memset(&response, 0, sizeof(response)); + response = {}; grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_post"); grpc_httpcli_post( &g_context, &g_pops, resource_quota, &req, "hello", 5, n_seconds_time(15), diff --git a/test/core/http/parser_test.cc b/test/core/http/parser_test.cc index d105b40bcd6..d3b2cb4060c 100644 --- a/test/core/http/parser_test.cc +++ b/test/core/http/parser_test.cc @@ -101,7 +101,7 @@ static void test_succeeds(grpc_slice_split_mode split_mode, grpc_slice* slices; va_list args; grpc_http_response response; - memset(&response, 0, sizeof(response)); + response = {}; grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices); grpc_slice_unref(input_slice); @@ -155,7 +155,7 @@ static void test_fails(grpc_slice_split_mode split_mode, grpc_slice* slices; grpc_error* error = GRPC_ERROR_NONE; grpc_http_response response; - memset(&response, 0, sizeof(response)); + response = {}; grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices); grpc_slice_unref(input_slice); diff --git a/test/core/http/response_fuzzer.cc b/test/core/http/response_fuzzer.cc index fc0904b1db7..cf82ccfe2ce 100644 --- a/test/core/http/response_fuzzer.cc +++ b/test/core/http/response_fuzzer.cc @@ -31,7 +31,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_http_parser parser; grpc_http_response response; grpc_init(); - memset(&response, 0, sizeof(response)); + response = {}; grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response); grpc_slice slice = grpc_slice_from_copied_buffer((const char*)data, size); GRPC_ERROR_UNREF(grpc_http_parser_parse(&parser, slice, nullptr)); diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc index cbce595c354..525953978c2 100644 --- a/test/core/security/credentials_test.cc +++ b/test/core/security/credentials_test.cc @@ -149,7 +149,7 @@ static char* test_json_key_str(void) { static grpc_httpcli_response http_response(int status, const char* body) { grpc_httpcli_response response; - memset(&response, 0, sizeof(grpc_httpcli_response)); + response = {}; response.status = status; response.body = gpr_strdup(const_cast(body)); response.body_length = strlen(body); @@ -161,7 +161,7 @@ static grpc_httpcli_response http_response(int status, const char* body) { static void test_empty_md_array(void) { grpc_core::ExecCtx exec_ctx; grpc_credentials_mdelem_array md_array; - memset(&md_array, 0, sizeof(md_array)); + md_array = {}; GPR_ASSERT(md_array.md == nullptr); GPR_ASSERT(md_array.size == 0); grpc_credentials_mdelem_array_destroy(&md_array); @@ -170,7 +170,7 @@ static void test_empty_md_array(void) { static void test_add_to_empty_md_array(void) { grpc_core::ExecCtx exec_ctx; grpc_credentials_mdelem_array md_array; - memset(&md_array, 0, sizeof(md_array)); + md_array = {}; const char* key = "hello"; const char* value = "there blah blah blah blah blah blah blah"; grpc_mdelem md = grpc_mdelem_from_slices( @@ -185,7 +185,7 @@ static void test_add_to_empty_md_array(void) { static void test_add_abunch_to_md_array(void) { grpc_core::ExecCtx exec_ctx; grpc_credentials_mdelem_array md_array; - memset(&md_array, 0, sizeof(md_array)); + md_array = {}; const char* key = "hello"; const char* value = "there blah blah blah blah blah blah blah"; grpc_mdelem md = grpc_mdelem_from_slices( diff --git a/test/core/security/jwt_verifier_test.cc b/test/core/security/jwt_verifier_test.cc index 21a7aa47b9d..43a70f6955e 100644 --- a/test/core/security/jwt_verifier_test.cc +++ b/test/core/security/jwt_verifier_test.cc @@ -310,7 +310,7 @@ static char* good_google_email_keys(void) { static grpc_httpcli_response http_response(int status, char* body) { grpc_httpcli_response response; - memset(&response, 0, sizeof(grpc_httpcli_response)); + response = {}; response.status = status; response.body = body; response.body_length = strlen(body); diff --git a/test/core/security/oauth2_utils.cc b/test/core/security/oauth2_utils.cc index b24e7c180e1..8b4c795a9ff 100644 --- a/test/core/security/oauth2_utils.cc +++ b/test/core/security/oauth2_utils.cc @@ -71,7 +71,7 @@ static void destroy_after_shutdown(void* pollset, grpc_error* error) { char* grpc_test_fetch_oauth2_token_with_credentials( grpc_call_credentials* creds) { oauth2_request request; - memset(&request, 0, sizeof(request)); + request = {}; grpc_core::ExecCtx exec_ctx; grpc_closure destroy_after_shutdown_closure; grpc_auth_metadata_context null_ctx = {"", "", nullptr, nullptr}; diff --git a/test/core/transport/chttp2/hpack_encoder_test.cc b/test/core/transport/chttp2/hpack_encoder_test.cc index 6cbc914c7fa..707091bc129 100644 --- a/test/core/transport/chttp2/hpack_encoder_test.cc +++ b/test/core/transport/chttp2/hpack_encoder_test.cc @@ -97,7 +97,7 @@ static void verify(const verify_params params, const char* expected, grpc_slice_buffer_init(&output); grpc_transport_one_way_stats stats; - memset(&stats, 0, sizeof(stats)); + stats = {}; grpc_encode_header_options hopt = { 0xdeadbeef, /* stream_id */ params.eof, /* is_eof */ @@ -217,7 +217,7 @@ static void verify_table_size_change_match_elem_size(const char* key, grpc_slice_buffer_init(&output); grpc_transport_one_way_stats stats; - memset(&stats, 0, sizeof(stats)); + stats = {}; grpc_encode_header_options hopt = { 0xdeadbeef, /* stream_id */ false, /* is_eof */ diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index aad94afca5b..e6c9fe699c3 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -456,7 +456,7 @@ class NoOp { class SendEmptyMetadata { public: SendEmptyMetadata() : op_payload_(nullptr) { - memset(&op_, 0, sizeof(op_)); + op_ = {}; op_.on_complete = GRPC_CLOSURE_INIT(&closure_, DoNothing, nullptr, grpc_schedule_on_exec_ctx); op_.send_initial_metadata = true; diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index 1d2ddf13f6a..4950e7f7768 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -77,7 +77,7 @@ static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) { new grpc_chttp2_hpack_compressor); grpc_chttp2_hpack_compressor_init(c.get()); grpc_transport_one_way_stats stats; - memset(&stats, 0, sizeof(stats)); + stats = {}; grpc_slice_buffer outbuf; grpc_slice_buffer_init(&outbuf); while (state.KeepRunning()) { @@ -127,7 +127,7 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State& state) { new grpc_chttp2_hpack_compressor); grpc_chttp2_hpack_compressor_init(c.get()); grpc_transport_one_way_stats stats; - memset(&stats, 0, sizeof(stats)); + stats = {}; grpc_slice_buffer outbuf; grpc_slice_buffer_init(&outbuf); while (state.KeepRunning()) { diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc index 3df979e8ddb..da3357304ba 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc @@ -262,7 +262,7 @@ static void BM_StreamCreateDestroy(benchmark::State& state) { auto* s = new Stream(&f); grpc_transport_stream_op_batch op; grpc_transport_stream_op_batch_payload op_payload(nullptr); - memset(&op, 0, sizeof(op)); + op = {}; op.cancel_stream = true; op.payload = &op_payload; op_payload.cancel_stream.cancel_error = GRPC_ERROR_CANCELLED; @@ -315,7 +315,7 @@ static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State& state) { std::unique_ptr done; auto reset_op = [&]() { - memset(&op, 0, sizeof(op)); + op = {}; op.payload = &op_payload; }; @@ -366,7 +366,7 @@ static void BM_TransportEmptyOp(benchmark::State& state) { grpc_transport_stream_op_batch op; grpc_transport_stream_op_batch_payload op_payload(nullptr); auto reset_op = [&]() { - memset(&op, 0, sizeof(op)); + op = {}; op.payload = &op_payload; }; std::unique_ptr c = MakeClosure([&](grpc_error* error) { @@ -398,7 +398,7 @@ static void BM_TransportStreamSend(benchmark::State& state) { grpc_transport_stream_op_batch op; grpc_transport_stream_op_batch_payload op_payload(nullptr); auto reset_op = [&]() { - memset(&op, 0, sizeof(op)); + op = {}; op.payload = &op_payload; }; // Create the send_message payload slice. @@ -533,7 +533,7 @@ static void BM_TransportStreamRecv(benchmark::State& state) { grpc_slice incoming_data = CreateIncomingDataSlice(state.range(0), 16384); auto reset_op = [&]() { - memset(&op, 0, sizeof(op)); + op = {}; op.payload = &op_payload; }; From e0b94db1b9c9059e2a64a8a98d89c3982b29f377 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Mon, 19 Aug 2019 08:47:46 -0700 Subject: [PATCH 1318/1555] Enforce abstract class rule --- test/core/channel/channelz_registry_test.cc | 31 +++++++++---------- .../resolvers/dns_resolver_test.cc | 18 ++++++++--- test/core/util/test_lb_policies.cc | 5 +++ 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/test/core/channel/channelz_registry_test.cc b/test/core/channel/channelz_registry_test.cc index 995182da249..39d3b1d5eeb 100644 --- a/test/core/channel/channelz_registry_test.cc +++ b/test/core/channel/channelz_registry_test.cc @@ -24,6 +24,7 @@ #include #include +#include #include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/channel/channelz.h" @@ -33,7 +34,6 @@ #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/json/json.h" #include "src/core/lib/surface/channel.h" - #include "test/core/util/test_config.h" #include @@ -51,9 +51,13 @@ class ChannelzRegistryTest : public ::testing::Test { void TearDown() override { ChannelzRegistry::Shutdown(); } }; +static RefCountedPtr CreateTestNode() { + return MakeRefCounted(UniquePtr(gpr_strdup("test")), + UniquePtr(gpr_strdup("test"))); +} + TEST_F(ChannelzRegistryTest, UuidStartsAboveZeroTest) { - RefCountedPtr channelz_channel = - MakeRefCounted(BaseNode::EntityType::kTopLevelChannel, nullptr); + RefCountedPtr channelz_channel = CreateTestNode(); intptr_t uuid = channelz_channel->uuid(); EXPECT_GT(uuid, 0) << "First uuid chose must be greater than zero. Zero if " "reserved according to " @@ -65,8 +69,7 @@ TEST_F(ChannelzRegistryTest, UuidsAreIncreasing) { std::vector> channelz_channels; channelz_channels.reserve(10); for (int i = 0; i < 10; ++i) { - channelz_channels.push_back(MakeRefCounted( - BaseNode::EntityType::kTopLevelChannel, nullptr)); + channelz_channels.push_back(CreateTestNode()); } for (size_t i = 1; i < channelz_channels.size(); ++i) { EXPECT_LT(channelz_channels[i - 1]->uuid(), channelz_channels[i]->uuid()) @@ -75,8 +78,7 @@ TEST_F(ChannelzRegistryTest, UuidsAreIncreasing) { } TEST_F(ChannelzRegistryTest, RegisterGetTest) { - RefCountedPtr channelz_channel = - MakeRefCounted(BaseNode::EntityType::kTopLevelChannel, nullptr); + RefCountedPtr channelz_channel = CreateTestNode(); RefCountedPtr retrieved = ChannelzRegistry::Get(channelz_channel->uuid()); EXPECT_EQ(channelz_channel, retrieved); @@ -85,8 +87,7 @@ TEST_F(ChannelzRegistryTest, RegisterGetTest) { TEST_F(ChannelzRegistryTest, RegisterManyItems) { std::vector> channelz_channels; for (int i = 0; i < 100; i++) { - channelz_channels.push_back(MakeRefCounted( - BaseNode::EntityType::kTopLevelChannel, nullptr)); + channelz_channels.push_back(CreateTestNode()); RefCountedPtr retrieved = ChannelzRegistry::Get(channelz_channels[i]->uuid()); EXPECT_EQ(channelz_channels[i], retrieved); @@ -94,8 +95,7 @@ TEST_F(ChannelzRegistryTest, RegisterManyItems) { } TEST_F(ChannelzRegistryTest, NullIfNotPresentTest) { - RefCountedPtr channelz_channel = - MakeRefCounted(BaseNode::EntityType::kTopLevelChannel, nullptr); + RefCountedPtr channelz_channel = CreateTestNode(); // try to pull out a uuid that does not exist. RefCountedPtr nonexistant = ChannelzRegistry::Get(channelz_channel->uuid() + 1); @@ -117,10 +117,8 @@ TEST_F(ChannelzRegistryTest, TestUnregistration) { std::vector> odd_channels; odd_channels.reserve(kLoopIterations); for (int i = 0; i < kLoopIterations; i++) { - even_channels.push_back(MakeRefCounted( - BaseNode::EntityType::kTopLevelChannel, nullptr)); - odd_channels.push_back(MakeRefCounted( - BaseNode::EntityType::kTopLevelChannel, nullptr)); + even_channels.push_back(CreateTestNode()); + odd_channels.push_back(CreateTestNode()); odd_uuids.push_back(odd_channels[i]->uuid()); } } @@ -137,8 +135,7 @@ TEST_F(ChannelzRegistryTest, TestUnregistration) { std::vector> more_channels; more_channels.reserve(kLoopIterations); for (int i = 0; i < kLoopIterations; i++) { - more_channels.push_back(MakeRefCounted( - BaseNode::EntityType::kTopLevelChannel, nullptr)); + more_channels.push_back(CreateTestNode()); RefCountedPtr retrieved = ChannelzRegistry::Get(more_channels[i]->uuid()); EXPECT_EQ(more_channels[i], retrieved); diff --git a/test/core/client_channel/resolvers/dns_resolver_test.cc b/test/core/client_channel/resolvers/dns_resolver_test.cc index 129866b7d7f..ce44fd51b82 100644 --- a/test/core/client_channel/resolvers/dns_resolver_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_test.cc @@ -24,11 +24,23 @@ #include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/combiner.h" #include "test/core/util/test_config.h" static grpc_combiner* g_combiner; +class TestResultHandler : public grpc_core::Resolver::ResultHandler { + void ReturnResult(grpc_core::Resolver::Result result) override {} + void ReturnError(grpc_error* error) override {} +}; + +static grpc_core::UniquePtr +create_test_result_handler() { + return grpc_core::UniquePtr( + grpc_core::New()); +} + static void test_succeeds(grpc_core::ResolverFactory* factory, const char* string) { gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, @@ -39,8 +51,7 @@ static void test_succeeds(grpc_core::ResolverFactory* factory, grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; - args.result_handler = - grpc_core::MakeUnique(); + args.result_handler = create_test_result_handler(); grpc_core::OrphanablePtr resolver = factory->CreateResolver(std::move(args)); GPR_ASSERT(resolver != nullptr); @@ -57,8 +68,7 @@ static void test_fails(grpc_core::ResolverFactory* factory, grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; - args.result_handler = - grpc_core::MakeUnique(); + args.result_handler = create_test_result_handler(); grpc_core::OrphanablePtr resolver = factory->CreateResolver(std::move(args)); GPR_ASSERT(resolver == nullptr); diff --git a/test/core/util/test_lb_policies.cc b/test/core/util/test_lb_policies.cc index 5ee2f5fe049..77e186c6d49 100644 --- a/test/core/util/test_lb_policies.cc +++ b/test/core/util/test_lb_policies.cc @@ -233,6 +233,11 @@ class InterceptTrailingFactory : public LoadBalancingPolicyFactory { return kInterceptRecvTrailingMetadataLbPolicyName; } + RefCountedPtr ParseLoadBalancingConfig( + const grpc_json* json, grpc_error** error) const override { + return nullptr; + } + private: InterceptRecvTrailingMetadataCallback cb_; void* user_data_; From 7ec6e8a4de6eba4eb3a8298ceb5aa82c0209b3a1 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 16 Aug 2019 18:11:41 -0700 Subject: [PATCH 1319/1555] Remove nanopb from gRPC --- .clang_complete | 1 - BUILD.gn | 27 - CMakeLists.txt | 401 --- Makefile | 2 +- PYTHON-MANIFEST.in | 1 - bazel/grpc_deps.bzl | 14 - build.yaml | 18 +- cmake/nanopb.cmake | 15 - config.m4 | 1 - config.w32 | 1 - gRPC-C++.podspec | 364 +-- gRPC-Core.podspec | 2 - grpc.gyp | 4 - setup.py | 2 - .../SwiftSample.xcodeproj/project.pbxproj | 2 - .../tvOS-sample.xcodeproj/project.pbxproj | 2 - .../watchOS-sample.xcodeproj/project.pbxproj | 4 - templates/BUILD.gn.template | 17 +- templates/CMakeLists.txt.template | 3 - templates/config.m4.template | 1 - templates/config.w32.template | 1 - templates/gRPC-C++.podspec.template | 11 - templates/gRPC-Core.podspec.template | 6 +- templates/grpc.gyp.template | 1 - .../GRPCCppTests.xcodeproj/project.pbxproj | 2 - third_party/nanopb.BUILD | 19 - third_party/nanopb/.gitignore | 28 - third_party/nanopb/.travis.yml | 54 - third_party/nanopb/AUTHORS | 24 - third_party/nanopb/BUILD | 24 - third_party/nanopb/CHANGELOG.txt | 241 -- third_party/nanopb/CONTRIBUTING.md | 32 - third_party/nanopb/LICENSE.txt | 20 - third_party/nanopb/README.md | 71 - third_party/nanopb/docs/Makefile | 9 - third_party/nanopb/docs/concepts.rst | 392 --- third_party/nanopb/docs/generator_flow.svg | 2869 ----------------- third_party/nanopb/docs/index.rst | 127 - third_party/nanopb/docs/logo/logo.png | Bin 14973 -> 0 bytes third_party/nanopb/docs/logo/logo.svg | 1470 --------- third_party/nanopb/docs/logo/logo16px.png | Bin 854 -> 0 bytes third_party/nanopb/docs/logo/logo48px.png | Bin 2577 -> 0 bytes third_party/nanopb/docs/lsr.css | 240 -- third_party/nanopb/docs/menu.rst | 13 - third_party/nanopb/docs/migration.rst | 276 -- third_party/nanopb/docs/reference.rst | 770 ----- third_party/nanopb/docs/security.rst | 84 - .../examples/cmake_simple/CMakeLists.txt | 16 - .../nanopb/examples/cmake_simple/README.txt | 18 - .../nanopb/examples/cmake_simple/simple.c | 71 - .../nanopb/examples/cmake_simple/simple.proto | 9 - .../nanopb/examples/network_server/Makefile | 17 - .../nanopb/examples/network_server/README.txt | 60 - .../nanopb/examples/network_server/client.c | 142 - .../nanopb/examples/network_server/common.c | 40 - .../nanopb/examples/network_server/common.h | 9 - .../examples/network_server/fileproto.options | 13 - .../examples/network_server/fileproto.proto | 20 - .../nanopb/examples/network_server/server.c | 158 - third_party/nanopb/examples/simple/Makefile | 22 - third_party/nanopb/examples/simple/README.txt | 29 - third_party/nanopb/examples/simple/simple.c | 71 - .../nanopb/examples/simple/simple.proto | 9 - .../examples/using_double_on_avr/Makefile | 24 - .../examples/using_double_on_avr/README.txt | 25 - .../using_double_on_avr/decode_double.c | 33 - .../using_double_on_avr/double_conversion.c | 123 - .../using_double_on_avr/double_conversion.h | 26 - .../using_double_on_avr/doubleproto.proto | 15 - .../using_double_on_avr/encode_double.c | 25 - .../using_double_on_avr/test_conversions.c | 56 - .../examples/using_union_messages/Makefile | 20 - .../examples/using_union_messages/README.txt | 52 - .../examples/using_union_messages/decode.c | 96 - .../examples/using_union_messages/encode.c | 85 - .../using_union_messages/unionproto.proto | 32 - third_party/nanopb/extra/FindNanopb.cmake | 274 -- third_party/nanopb/extra/nanopb.mk | 37 - third_party/nanopb/extra/pb_syshdr.h | 112 - .../nanopb/generator/nanopb_generator.py | 1602 --------- third_party/nanopb/generator/proto/Makefile | 4 - .../nanopb/generator/proto/__init__.py | 0 .../proto/google/protobuf/descriptor.proto | 714 ---- .../nanopb/generator/proto/nanopb.proto | 98 - .../nanopb/generator/proto/plugin.proto | 148 - .../nanopb/generator/protoc-gen-nanopb | 13 - .../nanopb/generator/protoc-gen-nanopb.bat | 12 - third_party/nanopb/library.json | 22 - third_party/nanopb/pb.h | 579 ---- third_party/nanopb/pb_common.c | 97 - third_party/nanopb/pb_common.h | 42 - third_party/nanopb/pb_decode.c | 1347 -------- third_party/nanopb/pb_decode.h | 149 - third_party/nanopb/pb_encode.c | 696 ---- third_party/nanopb/pb_encode.h | 154 - third_party/nanopb/tests/Makefile | 21 - third_party/nanopb/tests/SConstruct | 155 - third_party/nanopb/tests/alltypes/SConscript | 35 - .../nanopb/tests/alltypes/alltypes.options | 3 - .../nanopb/tests/alltypes/alltypes.proto | 123 - .../nanopb/tests/alltypes/decode_alltypes.c | 221 -- .../nanopb/tests/alltypes/encode_alltypes.c | 149 - .../nanopb/tests/alltypes_callback/SConscript | 23 - .../tests/alltypes_callback/alltypes.options | 4 - .../decode_alltypes_callback.c | 429 --- .../encode_alltypes_callback.c | 402 --- .../nanopb/tests/alltypes_pointer/SConscript | 40 - .../tests/alltypes_pointer/alltypes.options | 3 - .../decode_alltypes_pointer.c | 180 -- .../encode_alltypes_pointer.c | 194 -- .../nanopb/tests/anonymous_oneof/SConscript | 30 - .../tests/anonymous_oneof/decode_oneof.c | 88 - .../nanopb/tests/anonymous_oneof/oneof.proto | 23 - .../tests/backwards_compatibility/SConscript | 11 - .../backwards_compatibility/alltypes_legacy.c | 153 - .../backwards_compatibility/alltypes_legacy.h | 274 -- .../alltypes_legacy.options | 3 - .../alltypes_legacy.proto | 110 - .../backwards_compatibility/decode_legacy.c | 199 -- .../backwards_compatibility/encode_legacy.c | 135 - .../nanopb/tests/basic_buffer/SConscript | 12 - .../nanopb/tests/basic_buffer/decode_buffer.c | 88 - .../nanopb/tests/basic_buffer/encode_buffer.c | 38 - .../nanopb/tests/basic_stream/SConscript | 12 - .../nanopb/tests/basic_stream/decode_stream.c | 84 - .../nanopb/tests/basic_stream/encode_stream.c | 40 - .../nanopb/tests/buffer_only/SConscript | 28 - third_party/nanopb/tests/callbacks/SConscript | 14 - .../nanopb/tests/callbacks/callbacks.proto | 18 - .../nanopb/tests/callbacks/decode_callbacks.c | 97 - .../nanopb/tests/callbacks/encode_callbacks.c | 92 - third_party/nanopb/tests/common/SConscript | 48 - .../nanopb/tests/common/malloc_wrappers.c | 54 - .../nanopb/tests/common/malloc_wrappers.h | 7 - .../tests/common/malloc_wrappers_syshdr.h | 15 - third_party/nanopb/tests/common/person.proto | 22 - .../nanopb/tests/common/test_helpers.h | 17 - .../nanopb/tests/common/unittestproto.proto | 43 - third_party/nanopb/tests/common/unittests.h | 14 - .../nanopb/tests/cxx_main_program/SConscript | 25 - .../nanopb/tests/cyclic_messages/SConscript | 11 - .../nanopb/tests/cyclic_messages/cyclic.proto | 27 - .../cyclic_messages/cyclic_callback.options | 7 - .../cyclic_messages/encode_cyclic_callback.c | 148 - .../nanopb/tests/decode_unittests/SConscript | 4 - .../tests/decode_unittests/decode_unittests.c | 344 -- .../nanopb/tests/encode_unittests/SConscript | 5 - .../tests/encode_unittests/encode_unittests.c | 355 -- .../nanopb/tests/enum_sizes/SConscript | 12 - .../nanopb/tests/enum_sizes/enumsizes.proto | 86 - .../tests/enum_sizes/enumsizes_unittests.c | 72 - .../nanopb/tests/extensions/SConscript | 16 - .../tests/extensions/decode_extensions.c | 60 - .../tests/extensions/encode_extensions.c | 54 - .../tests/extensions/extensions.options | 1 - .../nanopb/tests/extensions/extensions.proto | 19 - .../nanopb/tests/extra_fields/SConscript | 16 - .../person_with_extra_field.expected | 14 - .../nanopb/tests/field_size_16/SConscript | 29 - .../tests/field_size_16/alltypes.options | 3 - .../nanopb/tests/field_size_16/alltypes.proto | 121 - .../nanopb/tests/field_size_32/SConscript | 29 - .../tests/field_size_32/alltypes.options | 3 - .../nanopb/tests/field_size_32/alltypes.proto | 121 - third_party/nanopb/tests/fuzztest/SConscript | 43 - .../tests/fuzztest/alltypes_pointer.options | 3 - .../tests/fuzztest/alltypes_static.options | 3 - third_party/nanopb/tests/fuzztest/fuzzstub.c | 189 -- third_party/nanopb/tests/fuzztest/fuzztest.c | 432 --- .../nanopb/tests/fuzztest/generate_message.c | 101 - .../nanopb/tests/fuzztest/run_radamsa.sh | 12 - third_party/nanopb/tests/inline/SConscript | 16 - .../nanopb/tests/inline/inline.expected | 3 - third_party/nanopb/tests/inline/inline.proto | 17 - .../nanopb/tests/inline/inline_unittests.c | 73 - third_party/nanopb/tests/intsizes/SConscript | 12 - .../nanopb/tests/intsizes/intsizes.proto | 41 - .../tests/intsizes/intsizes_unittests.c | 122 - third_party/nanopb/tests/io_errors/SConscript | 15 - .../nanopb/tests/io_errors/alltypes.options | 3 - .../nanopb/tests/io_errors/io_errors.c | 140 - .../tests/io_errors_pointers/SConscript | 26 - .../tests/io_errors_pointers/alltypes.options | 3 - .../nanopb/tests/mem_release/SConscript | 13 - .../nanopb/tests/mem_release/mem_release.c | 187 -- .../tests/mem_release/mem_release.proto | 35 - .../nanopb/tests/message_sizes/SConscript | 11 - .../nanopb/tests/message_sizes/dummy.c | 9 - .../tests/message_sizes/messages1.proto | 29 - .../tests/message_sizes/messages2.proto | 10 - .../nanopb/tests/missing_fields/SConscript | 8 - .../tests/missing_fields/missing_fields.c | 53 - .../tests/missing_fields/missing_fields.proto | 140 - .../nanopb/tests/multiple_files/SConscript | 16 - .../tests/multiple_files/multifile1.options | 1 - .../tests/multiple_files/multifile1.proto | 34 - .../tests/multiple_files/multifile2.proto | 22 - .../multiple_files/subdir/multifile2.proto | 25 - .../multiple_files/test_multiple_files.c | 30 - third_party/nanopb/tests/no_errmsg/SConscript | 28 - .../nanopb/tests/no_messages/SConscript | 7 - .../tests/no_messages/no_messages.proto | 9 - third_party/nanopb/tests/oneof/SConscript | 33 - third_party/nanopb/tests/oneof/decode_oneof.c | 131 - third_party/nanopb/tests/oneof/encode_oneof.c | 64 - third_party/nanopb/tests/oneof/oneof.proto | 32 - third_party/nanopb/tests/options/SConscript | 9 - .../nanopb/tests/options/options.expected | 18 - .../nanopb/tests/options/options.proto | 91 - .../nanopb/tests/package_name/SConscript | 38 - .../tests/regression/issue_118/SConscript | 12 - .../tests/regression/issue_118/enumdef.proto | 8 - .../tests/regression/issue_118/enumuse.proto | 7 - .../tests/regression/issue_125/SConscript | 9 - .../issue_125/extensionbug.expected | 3 - .../regression/issue_125/extensionbug.options | 4 - .../regression/issue_125/extensionbug.proto | 18 - .../tests/regression/issue_141/SConscript | 8 - .../regression/issue_141/testproto.expected | 7 - .../regression/issue_141/testproto.proto | 52 - .../tests/regression/issue_145/SConscript | 9 - .../regression/issue_145/comments.expected | 3 - .../regression/issue_145/comments.options | 6 - .../tests/regression/issue_145/comments.proto | 7 - .../tests/regression/issue_166/SConscript | 13 - .../regression/issue_166/enum_encoded_size.c | 43 - .../tests/regression/issue_166/enums.proto | 18 - .../tests/regression/issue_172/SConscript | 16 - .../tests/regression/issue_172/msg_size.c | 9 - .../issue_172/submessage/submessage.options | 1 - .../issue_172/submessage/submessage.proto | 4 - .../tests/regression/issue_172/test.proto | 6 - .../tests/regression/issue_188/SConscript | 6 - .../tests/regression/issue_188/oneof.proto | 29 - .../tests/regression/issue_195/SConscript | 10 - .../tests/regression/issue_195/test.expected | 1 - .../tests/regression/issue_195/test.proto | 8 - .../tests/regression/issue_203/SConscript | 9 - .../tests/regression/issue_203/file1.proto | 10 - .../tests/regression/issue_203/file2.proto | 10 - .../tests/regression/issue_205/SConscript | 14 - .../regression/issue_205/size_corruption.c | 12 - .../issue_205/size_corruption.proto | 11 - .../nanopb/tests/site_scons/site_init.py | 109 - .../tests/site_scons/site_tools/nanopb.py | 126 - .../tests/special_characters/SConscript | 6 - .../funny-proto+name has.characters.proto | 1 - third_party/nanopb/tests/splint/SConscript | 16 - third_party/nanopb/tests/splint/splint.rc | 37 - .../nanopb/tools/make_linux_package.sh | 47 - third_party/nanopb/tools/make_mac_package.sh | 49 - .../nanopb/tools/make_windows_package.sh | 55 - third_party/nanopb/tools/set_version.sh | 10 - tools/codegen/core/gen_nano_proto.sh | 83 - tools/distrib/check_copyright.py | 12 - tools/doxygen/Doxyfile.c++.internal | 4 - .../run_tests/sanity/check_bazel_workspace.py | 4 - 257 files changed, 7 insertions(+), 23687 deletions(-) delete mode 100644 cmake/nanopb.cmake delete mode 100644 third_party/nanopb.BUILD delete mode 100644 third_party/nanopb/.gitignore delete mode 100644 third_party/nanopb/.travis.yml delete mode 100644 third_party/nanopb/AUTHORS delete mode 100644 third_party/nanopb/BUILD delete mode 100644 third_party/nanopb/CHANGELOG.txt delete mode 100644 third_party/nanopb/CONTRIBUTING.md delete mode 100644 third_party/nanopb/LICENSE.txt delete mode 100644 third_party/nanopb/README.md delete mode 100644 third_party/nanopb/docs/Makefile delete mode 100644 third_party/nanopb/docs/concepts.rst delete mode 100644 third_party/nanopb/docs/generator_flow.svg delete mode 100644 third_party/nanopb/docs/index.rst delete mode 100644 third_party/nanopb/docs/logo/logo.png delete mode 100644 third_party/nanopb/docs/logo/logo.svg delete mode 100644 third_party/nanopb/docs/logo/logo16px.png delete mode 100644 third_party/nanopb/docs/logo/logo48px.png delete mode 100644 third_party/nanopb/docs/lsr.css delete mode 100644 third_party/nanopb/docs/menu.rst delete mode 100644 third_party/nanopb/docs/migration.rst delete mode 100644 third_party/nanopb/docs/reference.rst delete mode 100644 third_party/nanopb/docs/security.rst delete mode 100644 third_party/nanopb/examples/cmake_simple/CMakeLists.txt delete mode 100644 third_party/nanopb/examples/cmake_simple/README.txt delete mode 100644 third_party/nanopb/examples/cmake_simple/simple.c delete mode 100644 third_party/nanopb/examples/cmake_simple/simple.proto delete mode 100644 third_party/nanopb/examples/network_server/Makefile delete mode 100644 third_party/nanopb/examples/network_server/README.txt delete mode 100644 third_party/nanopb/examples/network_server/client.c delete mode 100644 third_party/nanopb/examples/network_server/common.c delete mode 100644 third_party/nanopb/examples/network_server/common.h delete mode 100644 third_party/nanopb/examples/network_server/fileproto.options delete mode 100644 third_party/nanopb/examples/network_server/fileproto.proto delete mode 100644 third_party/nanopb/examples/network_server/server.c delete mode 100644 third_party/nanopb/examples/simple/Makefile delete mode 100644 third_party/nanopb/examples/simple/README.txt delete mode 100644 third_party/nanopb/examples/simple/simple.c delete mode 100644 third_party/nanopb/examples/simple/simple.proto delete mode 100644 third_party/nanopb/examples/using_double_on_avr/Makefile delete mode 100644 third_party/nanopb/examples/using_double_on_avr/README.txt delete mode 100644 third_party/nanopb/examples/using_double_on_avr/decode_double.c delete mode 100644 third_party/nanopb/examples/using_double_on_avr/double_conversion.c delete mode 100644 third_party/nanopb/examples/using_double_on_avr/double_conversion.h delete mode 100644 third_party/nanopb/examples/using_double_on_avr/doubleproto.proto delete mode 100644 third_party/nanopb/examples/using_double_on_avr/encode_double.c delete mode 100644 third_party/nanopb/examples/using_double_on_avr/test_conversions.c delete mode 100644 third_party/nanopb/examples/using_union_messages/Makefile delete mode 100644 third_party/nanopb/examples/using_union_messages/README.txt delete mode 100644 third_party/nanopb/examples/using_union_messages/decode.c delete mode 100644 third_party/nanopb/examples/using_union_messages/encode.c delete mode 100644 third_party/nanopb/examples/using_union_messages/unionproto.proto delete mode 100644 third_party/nanopb/extra/FindNanopb.cmake delete mode 100644 third_party/nanopb/extra/nanopb.mk delete mode 100644 third_party/nanopb/extra/pb_syshdr.h delete mode 100755 third_party/nanopb/generator/nanopb_generator.py delete mode 100644 third_party/nanopb/generator/proto/Makefile delete mode 100644 third_party/nanopb/generator/proto/__init__.py delete mode 100644 third_party/nanopb/generator/proto/google/protobuf/descriptor.proto delete mode 100644 third_party/nanopb/generator/proto/nanopb.proto delete mode 100644 third_party/nanopb/generator/proto/plugin.proto delete mode 100755 third_party/nanopb/generator/protoc-gen-nanopb delete mode 100644 third_party/nanopb/generator/protoc-gen-nanopb.bat delete mode 100644 third_party/nanopb/library.json delete mode 100644 third_party/nanopb/pb.h delete mode 100644 third_party/nanopb/pb_common.c delete mode 100644 third_party/nanopb/pb_common.h delete mode 100644 third_party/nanopb/pb_decode.c delete mode 100644 third_party/nanopb/pb_decode.h delete mode 100644 third_party/nanopb/pb_encode.c delete mode 100644 third_party/nanopb/pb_encode.h delete mode 100644 third_party/nanopb/tests/Makefile delete mode 100644 third_party/nanopb/tests/SConstruct delete mode 100644 third_party/nanopb/tests/alltypes/SConscript delete mode 100644 third_party/nanopb/tests/alltypes/alltypes.options delete mode 100644 third_party/nanopb/tests/alltypes/alltypes.proto delete mode 100644 third_party/nanopb/tests/alltypes/decode_alltypes.c delete mode 100644 third_party/nanopb/tests/alltypes/encode_alltypes.c delete mode 100644 third_party/nanopb/tests/alltypes_callback/SConscript delete mode 100644 third_party/nanopb/tests/alltypes_callback/alltypes.options delete mode 100644 third_party/nanopb/tests/alltypes_callback/decode_alltypes_callback.c delete mode 100644 third_party/nanopb/tests/alltypes_callback/encode_alltypes_callback.c delete mode 100644 third_party/nanopb/tests/alltypes_pointer/SConscript delete mode 100644 third_party/nanopb/tests/alltypes_pointer/alltypes.options delete mode 100644 third_party/nanopb/tests/alltypes_pointer/decode_alltypes_pointer.c delete mode 100644 third_party/nanopb/tests/alltypes_pointer/encode_alltypes_pointer.c delete mode 100644 third_party/nanopb/tests/anonymous_oneof/SConscript delete mode 100644 third_party/nanopb/tests/anonymous_oneof/decode_oneof.c delete mode 100644 third_party/nanopb/tests/anonymous_oneof/oneof.proto delete mode 100644 third_party/nanopb/tests/backwards_compatibility/SConscript delete mode 100644 third_party/nanopb/tests/backwards_compatibility/alltypes_legacy.c delete mode 100644 third_party/nanopb/tests/backwards_compatibility/alltypes_legacy.h delete mode 100644 third_party/nanopb/tests/backwards_compatibility/alltypes_legacy.options delete mode 100644 third_party/nanopb/tests/backwards_compatibility/alltypes_legacy.proto delete mode 100644 third_party/nanopb/tests/backwards_compatibility/decode_legacy.c delete mode 100644 third_party/nanopb/tests/backwards_compatibility/encode_legacy.c delete mode 100644 third_party/nanopb/tests/basic_buffer/SConscript delete mode 100644 third_party/nanopb/tests/basic_buffer/decode_buffer.c delete mode 100644 third_party/nanopb/tests/basic_buffer/encode_buffer.c delete mode 100644 third_party/nanopb/tests/basic_stream/SConscript delete mode 100644 third_party/nanopb/tests/basic_stream/decode_stream.c delete mode 100644 third_party/nanopb/tests/basic_stream/encode_stream.c delete mode 100644 third_party/nanopb/tests/buffer_only/SConscript delete mode 100644 third_party/nanopb/tests/callbacks/SConscript delete mode 100644 third_party/nanopb/tests/callbacks/callbacks.proto delete mode 100644 third_party/nanopb/tests/callbacks/decode_callbacks.c delete mode 100644 third_party/nanopb/tests/callbacks/encode_callbacks.c delete mode 100644 third_party/nanopb/tests/common/SConscript delete mode 100644 third_party/nanopb/tests/common/malloc_wrappers.c delete mode 100644 third_party/nanopb/tests/common/malloc_wrappers.h delete mode 100644 third_party/nanopb/tests/common/malloc_wrappers_syshdr.h delete mode 100644 third_party/nanopb/tests/common/person.proto delete mode 100644 third_party/nanopb/tests/common/test_helpers.h delete mode 100644 third_party/nanopb/tests/common/unittestproto.proto delete mode 100644 third_party/nanopb/tests/common/unittests.h delete mode 100644 third_party/nanopb/tests/cxx_main_program/SConscript delete mode 100644 third_party/nanopb/tests/cyclic_messages/SConscript delete mode 100644 third_party/nanopb/tests/cyclic_messages/cyclic.proto delete mode 100644 third_party/nanopb/tests/cyclic_messages/cyclic_callback.options delete mode 100644 third_party/nanopb/tests/cyclic_messages/encode_cyclic_callback.c delete mode 100644 third_party/nanopb/tests/decode_unittests/SConscript delete mode 100644 third_party/nanopb/tests/decode_unittests/decode_unittests.c delete mode 100644 third_party/nanopb/tests/encode_unittests/SConscript delete mode 100644 third_party/nanopb/tests/encode_unittests/encode_unittests.c delete mode 100644 third_party/nanopb/tests/enum_sizes/SConscript delete mode 100644 third_party/nanopb/tests/enum_sizes/enumsizes.proto delete mode 100644 third_party/nanopb/tests/enum_sizes/enumsizes_unittests.c delete mode 100644 third_party/nanopb/tests/extensions/SConscript delete mode 100644 third_party/nanopb/tests/extensions/decode_extensions.c delete mode 100644 third_party/nanopb/tests/extensions/encode_extensions.c delete mode 100644 third_party/nanopb/tests/extensions/extensions.options delete mode 100644 third_party/nanopb/tests/extensions/extensions.proto delete mode 100644 third_party/nanopb/tests/extra_fields/SConscript delete mode 100644 third_party/nanopb/tests/extra_fields/person_with_extra_field.expected delete mode 100644 third_party/nanopb/tests/field_size_16/SConscript delete mode 100644 third_party/nanopb/tests/field_size_16/alltypes.options delete mode 100644 third_party/nanopb/tests/field_size_16/alltypes.proto delete mode 100644 third_party/nanopb/tests/field_size_32/SConscript delete mode 100644 third_party/nanopb/tests/field_size_32/alltypes.options delete mode 100644 third_party/nanopb/tests/field_size_32/alltypes.proto delete mode 100644 third_party/nanopb/tests/fuzztest/SConscript delete mode 100644 third_party/nanopb/tests/fuzztest/alltypes_pointer.options delete mode 100644 third_party/nanopb/tests/fuzztest/alltypes_static.options delete mode 100644 third_party/nanopb/tests/fuzztest/fuzzstub.c delete mode 100644 third_party/nanopb/tests/fuzztest/fuzztest.c delete mode 100644 third_party/nanopb/tests/fuzztest/generate_message.c delete mode 100755 third_party/nanopb/tests/fuzztest/run_radamsa.sh delete mode 100644 third_party/nanopb/tests/inline/SConscript delete mode 100644 third_party/nanopb/tests/inline/inline.expected delete mode 100644 third_party/nanopb/tests/inline/inline.proto delete mode 100644 third_party/nanopb/tests/inline/inline_unittests.c delete mode 100644 third_party/nanopb/tests/intsizes/SConscript delete mode 100644 third_party/nanopb/tests/intsizes/intsizes.proto delete mode 100644 third_party/nanopb/tests/intsizes/intsizes_unittests.c delete mode 100644 third_party/nanopb/tests/io_errors/SConscript delete mode 100644 third_party/nanopb/tests/io_errors/alltypes.options delete mode 100644 third_party/nanopb/tests/io_errors/io_errors.c delete mode 100644 third_party/nanopb/tests/io_errors_pointers/SConscript delete mode 100644 third_party/nanopb/tests/io_errors_pointers/alltypes.options delete mode 100644 third_party/nanopb/tests/mem_release/SConscript delete mode 100644 third_party/nanopb/tests/mem_release/mem_release.c delete mode 100644 third_party/nanopb/tests/mem_release/mem_release.proto delete mode 100644 third_party/nanopb/tests/message_sizes/SConscript delete mode 100644 third_party/nanopb/tests/message_sizes/dummy.c delete mode 100644 third_party/nanopb/tests/message_sizes/messages1.proto delete mode 100644 third_party/nanopb/tests/message_sizes/messages2.proto delete mode 100644 third_party/nanopb/tests/missing_fields/SConscript delete mode 100644 third_party/nanopb/tests/missing_fields/missing_fields.c delete mode 100644 third_party/nanopb/tests/missing_fields/missing_fields.proto delete mode 100644 third_party/nanopb/tests/multiple_files/SConscript delete mode 100644 third_party/nanopb/tests/multiple_files/multifile1.options delete mode 100644 third_party/nanopb/tests/multiple_files/multifile1.proto delete mode 100644 third_party/nanopb/tests/multiple_files/multifile2.proto delete mode 100644 third_party/nanopb/tests/multiple_files/subdir/multifile2.proto delete mode 100644 third_party/nanopb/tests/multiple_files/test_multiple_files.c delete mode 100644 third_party/nanopb/tests/no_errmsg/SConscript delete mode 100644 third_party/nanopb/tests/no_messages/SConscript delete mode 100644 third_party/nanopb/tests/no_messages/no_messages.proto delete mode 100644 third_party/nanopb/tests/oneof/SConscript delete mode 100644 third_party/nanopb/tests/oneof/decode_oneof.c delete mode 100644 third_party/nanopb/tests/oneof/encode_oneof.c delete mode 100644 third_party/nanopb/tests/oneof/oneof.proto delete mode 100644 third_party/nanopb/tests/options/SConscript delete mode 100644 third_party/nanopb/tests/options/options.expected delete mode 100644 third_party/nanopb/tests/options/options.proto delete mode 100644 third_party/nanopb/tests/package_name/SConscript delete mode 100644 third_party/nanopb/tests/regression/issue_118/SConscript delete mode 100644 third_party/nanopb/tests/regression/issue_118/enumdef.proto delete mode 100644 third_party/nanopb/tests/regression/issue_118/enumuse.proto delete mode 100644 third_party/nanopb/tests/regression/issue_125/SConscript delete mode 100644 third_party/nanopb/tests/regression/issue_125/extensionbug.expected delete mode 100644 third_party/nanopb/tests/regression/issue_125/extensionbug.options delete mode 100644 third_party/nanopb/tests/regression/issue_125/extensionbug.proto delete mode 100644 third_party/nanopb/tests/regression/issue_141/SConscript delete mode 100644 third_party/nanopb/tests/regression/issue_141/testproto.expected delete mode 100644 third_party/nanopb/tests/regression/issue_141/testproto.proto delete mode 100644 third_party/nanopb/tests/regression/issue_145/SConscript delete mode 100644 third_party/nanopb/tests/regression/issue_145/comments.expected delete mode 100644 third_party/nanopb/tests/regression/issue_145/comments.options delete mode 100644 third_party/nanopb/tests/regression/issue_145/comments.proto delete mode 100644 third_party/nanopb/tests/regression/issue_166/SConscript delete mode 100644 third_party/nanopb/tests/regression/issue_166/enum_encoded_size.c delete mode 100644 third_party/nanopb/tests/regression/issue_166/enums.proto delete mode 100644 third_party/nanopb/tests/regression/issue_172/SConscript delete mode 100644 third_party/nanopb/tests/regression/issue_172/msg_size.c delete mode 100644 third_party/nanopb/tests/regression/issue_172/submessage/submessage.options delete mode 100644 third_party/nanopb/tests/regression/issue_172/submessage/submessage.proto delete mode 100644 third_party/nanopb/tests/regression/issue_172/test.proto delete mode 100644 third_party/nanopb/tests/regression/issue_188/SConscript delete mode 100644 third_party/nanopb/tests/regression/issue_188/oneof.proto delete mode 100644 third_party/nanopb/tests/regression/issue_195/SConscript delete mode 100644 third_party/nanopb/tests/regression/issue_195/test.expected delete mode 100644 third_party/nanopb/tests/regression/issue_195/test.proto delete mode 100644 third_party/nanopb/tests/regression/issue_203/SConscript delete mode 100644 third_party/nanopb/tests/regression/issue_203/file1.proto delete mode 100644 third_party/nanopb/tests/regression/issue_203/file2.proto delete mode 100644 third_party/nanopb/tests/regression/issue_205/SConscript delete mode 100644 third_party/nanopb/tests/regression/issue_205/size_corruption.c delete mode 100644 third_party/nanopb/tests/regression/issue_205/size_corruption.proto delete mode 100644 third_party/nanopb/tests/site_scons/site_init.py delete mode 100644 third_party/nanopb/tests/site_scons/site_tools/nanopb.py delete mode 100644 third_party/nanopb/tests/special_characters/SConscript delete mode 100644 third_party/nanopb/tests/special_characters/funny-proto+name has.characters.proto delete mode 100644 third_party/nanopb/tests/splint/SConscript delete mode 100644 third_party/nanopb/tests/splint/splint.rc delete mode 100755 third_party/nanopb/tools/make_linux_package.sh delete mode 100755 third_party/nanopb/tools/make_mac_package.sh delete mode 100755 third_party/nanopb/tools/make_windows_package.sh delete mode 100755 third_party/nanopb/tools/set_version.sh delete mode 100755 tools/codegen/core/gen_nano_proto.sh diff --git a/.clang_complete b/.clang_complete index f789455ea95..b198443c633 100644 --- a/.clang_complete +++ b/.clang_complete @@ -13,7 +13,6 @@ -Ithird_party/googletest/googlemock/include -Ithird_party/googletest/googletest/include -Ithird_party/googletest/include --Ithird_party/nanopb -Ithird_party/protobuf/src -Ithird_party/upb -Ithird_party/zlib diff --git a/BUILD.gn b/BUILD.gn index 1b157427087..eea022eac51 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -31,29 +31,6 @@ config("grpc_config") { ] } - - - source_set("nanopb") { - sources = [ - "third_party/nanopb/pb.h", - "third_party/nanopb/pb_common.c", - "third_party/nanopb/pb_common.h", - "third_party/nanopb/pb_decode.c", - "third_party/nanopb/pb_decode.h", - "third_party/nanopb/pb_encode.c", - "third_party/nanopb/pb_encode.h", - ] - deps = [ - ] - - public_configs = [ - ":grpc_config", - ] - include_dirs = [ - "third_party/nanopb", - ] - } - source_set("address_sorting") { @@ -939,7 +916,6 @@ config("grpc_config") { include_dirs = [ "third_party/cares", "third_party/address_sorting/include", - "third_party/nanopb", ] } @@ -1466,9 +1442,6 @@ config("grpc_config") { public_configs = [ ":grpc_config", ] - include_dirs = [ - "third_party/nanopb", - ] } # Only compile the plugin for the host architecture. diff --git a/CMakeLists.txt b/CMakeLists.txt index 86a77c95663..c6a54571868 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,7 +141,6 @@ include(cmake/address_sorting.cmake) include(cmake/benchmark.cmake) include(cmake/cares.cmake) include(cmake/gflags.cmake) -include(cmake/nanopb.cmake) include(cmake/protobuf.cmake) include(cmake/ssl.cmake) include(cmake/upb.cmake) @@ -792,7 +791,6 @@ target_include_directories(address_sorting PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -847,7 +845,6 @@ target_include_directories(alts_test_util PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -932,7 +929,6 @@ target_include_directories(gpr PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -1398,7 +1394,6 @@ target_include_directories(grpc PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -1805,7 +1800,6 @@ target_include_directories(grpc_cronet PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -2149,7 +2143,6 @@ target_include_directories(grpc_test_util PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -2490,7 +2483,6 @@ target_include_directories(grpc_test_util_unsecure PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -2881,7 +2873,6 @@ target_include_directories(grpc_unsecure PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -2985,7 +2976,6 @@ target_include_directories(reconnect_server PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -3034,7 +3024,6 @@ target_include_directories(test_tcp_server PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -3091,7 +3080,6 @@ target_include_directories(bm_callback_test_service_impl PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -3146,7 +3134,6 @@ target_include_directories(dns_test_util PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -3241,7 +3228,6 @@ target_include_directories(grpc++ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -3570,7 +3556,6 @@ target_include_directories(grpc++_core_stats PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -3625,7 +3610,6 @@ target_include_directories(grpc++_error_details PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -3698,7 +3682,6 @@ target_include_directories(grpc++_proto_reflection_desc_db PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -3765,7 +3748,6 @@ target_include_directories(grpc++_reflection PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -3830,7 +3812,6 @@ target_include_directories(grpc++_test_config PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -3928,7 +3909,6 @@ target_include_directories(grpc++_test_util PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -4138,7 +4118,6 @@ target_include_directories(grpc++_test_util_unsecure PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -4350,7 +4329,6 @@ target_include_directories(grpc++_unsecure PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -4664,7 +4642,6 @@ target_include_directories(grpc_benchmark PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -4726,7 +4703,6 @@ target_include_directories(grpc_cli_libs PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -4791,7 +4767,6 @@ target_include_directories(grpc_plugin_support PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -4859,7 +4834,6 @@ target_include_directories(grpcpp_channelz PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -4945,7 +4919,6 @@ target_include_directories(http2_client_main PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -5005,7 +4978,6 @@ target_include_directories(interop_client_helper PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -5080,7 +5052,6 @@ target_include_directories(interop_client_main PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -5134,7 +5105,6 @@ target_include_directories(interop_server_helper PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -5207,7 +5177,6 @@ target_include_directories(interop_server_lib PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -5261,7 +5230,6 @@ target_include_directories(interop_server_main PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -5370,7 +5338,6 @@ target_include_directories(qps PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -5422,7 +5389,6 @@ target_include_directories(grpc_csharp_ext PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -5478,7 +5444,6 @@ target_include_directories(bad_client_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -5527,7 +5492,6 @@ target_include_directories(bad_ssl_test_server PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -5654,7 +5618,6 @@ target_include_directories(end2end_tests PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -5781,7 +5744,6 @@ target_include_directories(end2end_nosec_tests PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -5819,7 +5781,6 @@ target_include_directories(algorithm_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -5856,7 +5817,6 @@ target_include_directories(alloc_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -5893,7 +5853,6 @@ target_include_directories(alpn_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -5930,7 +5889,6 @@ target_include_directories(arena_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -5967,7 +5925,6 @@ target_include_directories(avl_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6004,7 +5961,6 @@ target_include_directories(bad_server_response_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6042,7 +5998,6 @@ target_include_directories(bin_decoder_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6078,7 +6033,6 @@ target_include_directories(bin_encoder_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6115,7 +6069,6 @@ target_include_directories(buffer_list_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6153,7 +6106,6 @@ target_include_directories(channel_create_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6189,7 +6141,6 @@ target_include_directories(check_epollexclusive PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6224,7 +6175,6 @@ target_include_directories(chttp2_hpack_encoder_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6261,7 +6211,6 @@ target_include_directories(chttp2_stream_map_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6298,7 +6247,6 @@ target_include_directories(chttp2_varint_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6336,7 +6284,6 @@ target_include_directories(close_fd_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6374,7 +6321,6 @@ target_include_directories(cmdline_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6411,7 +6357,6 @@ target_include_directories(combiner_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6448,7 +6393,6 @@ target_include_directories(compression_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6485,7 +6429,6 @@ target_include_directories(concurrent_connectivity_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6522,7 +6465,6 @@ target_include_directories(connection_refused_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6559,7 +6501,6 @@ target_include_directories(dns_resolver_connectivity_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6596,7 +6537,6 @@ target_include_directories(dns_resolver_cooldown_using_ares_resolver_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6633,7 +6573,6 @@ target_include_directories(dns_resolver_cooldown_using_native_resolver_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6670,7 +6609,6 @@ target_include_directories(dns_resolver_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6708,7 +6646,6 @@ target_include_directories(dualstack_socket_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6746,7 +6683,6 @@ target_include_directories(endpoint_pair_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6783,7 +6719,6 @@ target_include_directories(error_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6821,7 +6756,6 @@ target_include_directories(ev_epollex_linux_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6859,7 +6793,6 @@ target_include_directories(fake_resolver_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6898,7 +6831,6 @@ target_include_directories(fake_transport_security_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6937,7 +6869,6 @@ target_include_directories(fd_conservation_posix_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -6976,7 +6907,6 @@ target_include_directories(fd_posix_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7014,7 +6944,6 @@ target_include_directories(fling_client PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7051,7 +6980,6 @@ target_include_directories(fling_server PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7089,7 +7017,6 @@ target_include_directories(fling_stream_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7128,7 +7055,6 @@ target_include_directories(fling_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7167,7 +7093,6 @@ target_include_directories(fork_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7206,7 +7131,6 @@ target_include_directories(goaway_server_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7244,7 +7168,6 @@ target_include_directories(gpr_cpu_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7281,7 +7204,6 @@ target_include_directories(gpr_env_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7318,7 +7240,6 @@ target_include_directories(gpr_host_port_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7355,7 +7276,6 @@ target_include_directories(gpr_log_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7392,7 +7312,6 @@ target_include_directories(gpr_manual_constructor_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7429,7 +7348,6 @@ target_include_directories(gpr_mpscq_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7466,7 +7384,6 @@ target_include_directories(gpr_spinlock_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7503,7 +7420,6 @@ target_include_directories(gpr_string_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7540,7 +7456,6 @@ target_include_directories(gpr_sync_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7577,7 +7492,6 @@ target_include_directories(gpr_thd_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7614,7 +7528,6 @@ target_include_directories(gpr_time_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7651,7 +7564,6 @@ target_include_directories(gpr_tls_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7688,7 +7600,6 @@ target_include_directories(gpr_useful_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7725,7 +7636,6 @@ target_include_directories(grpc_auth_context_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7762,7 +7672,6 @@ target_include_directories(grpc_b64_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7799,7 +7708,6 @@ target_include_directories(grpc_byte_buffer_reader_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7836,7 +7744,6 @@ target_include_directories(grpc_channel_args_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7873,7 +7780,6 @@ target_include_directories(grpc_channel_stack_builder_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7910,7 +7816,6 @@ target_include_directories(grpc_channel_stack_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7947,7 +7852,6 @@ target_include_directories(grpc_completion_queue_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -7984,7 +7888,6 @@ target_include_directories(grpc_completion_queue_threading_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8021,7 +7924,6 @@ target_include_directories(grpc_control_plane_credentials_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8058,7 +7960,6 @@ target_include_directories(grpc_create_jwt PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8094,7 +7995,6 @@ target_include_directories(grpc_credentials_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8131,7 +8031,6 @@ target_include_directories(grpc_ipv6_loopback_available_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8169,7 +8068,6 @@ target_include_directories(grpc_json_token_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8207,7 +8105,6 @@ target_include_directories(grpc_jwt_verifier_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8244,7 +8141,6 @@ target_include_directories(grpc_print_google_default_creds_token PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8279,7 +8175,6 @@ target_include_directories(grpc_security_connector_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8316,7 +8211,6 @@ target_include_directories(grpc_ssl_credentials_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8353,7 +8247,6 @@ target_include_directories(grpc_verify_jwt PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8389,7 +8282,6 @@ target_include_directories(handshake_client_ssl PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8430,7 +8322,6 @@ target_include_directories(handshake_server_ssl PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8471,7 +8362,6 @@ target_include_directories(handshake_server_with_readahead_handshaker PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8511,7 +8401,6 @@ target_include_directories(handshake_verify_peer_options PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8550,7 +8439,6 @@ target_include_directories(histogram_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8586,7 +8474,6 @@ target_include_directories(hpack_parser_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8623,7 +8510,6 @@ target_include_directories(hpack_table_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8660,7 +8546,6 @@ target_include_directories(http_parser_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8697,7 +8582,6 @@ target_include_directories(httpcli_format_request_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8735,7 +8619,6 @@ target_include_directories(httpcli_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8774,7 +8657,6 @@ target_include_directories(httpscli_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8812,7 +8694,6 @@ target_include_directories(init_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8849,7 +8730,6 @@ target_include_directories(inproc_callback_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8886,7 +8766,6 @@ target_include_directories(invalid_call_argument_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8923,7 +8802,6 @@ target_include_directories(json_rewrite PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8960,7 +8838,6 @@ target_include_directories(json_rewrite_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -8997,7 +8874,6 @@ target_include_directories(json_stream_error_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9034,7 +8910,6 @@ target_include_directories(json_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9071,7 +8946,6 @@ target_include_directories(lame_client_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9108,7 +8982,6 @@ target_include_directories(load_file_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9145,7 +9018,6 @@ target_include_directories(memory_usage_client PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9182,7 +9054,6 @@ target_include_directories(memory_usage_server PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9220,7 +9091,6 @@ target_include_directories(memory_usage_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9258,7 +9128,6 @@ target_include_directories(message_compress_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9295,7 +9164,6 @@ target_include_directories(minimal_stack_is_minimal_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9332,7 +9200,6 @@ target_include_directories(mpmcqueue_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9369,7 +9236,6 @@ target_include_directories(multiple_server_queues_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9406,7 +9272,6 @@ target_include_directories(murmur_hash_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9443,7 +9308,6 @@ target_include_directories(no_server_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9480,7 +9344,6 @@ target_include_directories(num_external_connectivity_watchers_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9517,7 +9380,6 @@ target_include_directories(parse_address_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9555,7 +9417,6 @@ target_include_directories(parse_address_with_named_scope_id_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9593,7 +9454,6 @@ target_include_directories(percent_encoding_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9631,7 +9491,6 @@ target_include_directories(resolve_address_using_ares_resolver_posix_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9669,7 +9528,6 @@ target_include_directories(resolve_address_using_ares_resolver_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9707,7 +9565,6 @@ target_include_directories(resolve_address_using_native_resolver_posix_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9745,7 +9602,6 @@ target_include_directories(resolve_address_using_native_resolver_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9782,7 +9638,6 @@ target_include_directories(resource_quota_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9819,7 +9674,6 @@ target_include_directories(secure_channel_create_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9856,7 +9710,6 @@ target_include_directories(secure_endpoint_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9893,7 +9746,6 @@ target_include_directories(sequential_connectivity_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9930,7 +9782,6 @@ target_include_directories(server_chttp2_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -9967,7 +9818,6 @@ target_include_directories(server_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10004,7 +9854,6 @@ target_include_directories(slice_buffer_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10041,7 +9890,6 @@ target_include_directories(slice_string_helpers_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10078,7 +9926,6 @@ target_include_directories(slice_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10115,7 +9962,6 @@ target_include_directories(sockaddr_resolver_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10152,7 +9998,6 @@ target_include_directories(sockaddr_utils_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10190,7 +10035,6 @@ target_include_directories(socket_utils_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10230,7 +10074,6 @@ target_include_directories(ssl_transport_security_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10268,7 +10111,6 @@ target_include_directories(status_conversion_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10305,7 +10147,6 @@ target_include_directories(stream_compression_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10342,7 +10183,6 @@ target_include_directories(stream_owned_slice_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10380,7 +10220,6 @@ target_include_directories(tcp_client_posix_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10418,7 +10257,6 @@ target_include_directories(tcp_client_uv_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10456,7 +10294,6 @@ target_include_directories(tcp_posix_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10495,7 +10332,6 @@ target_include_directories(tcp_server_posix_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10533,7 +10369,6 @@ target_include_directories(tcp_server_uv_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10570,7 +10405,6 @@ target_include_directories(threadpool_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10607,7 +10441,6 @@ target_include_directories(time_averaged_stats_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10644,7 +10477,6 @@ target_include_directories(timeout_encoding_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10681,7 +10513,6 @@ target_include_directories(timer_heap_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10718,7 +10549,6 @@ target_include_directories(timer_list_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10755,7 +10585,6 @@ target_include_directories(transport_connectivity_state_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10792,7 +10621,6 @@ target_include_directories(transport_metadata_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10830,7 +10658,6 @@ target_include_directories(transport_security_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10869,7 +10696,6 @@ target_include_directories(udp_server_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10907,7 +10733,6 @@ target_include_directories(uri_parser_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10946,7 +10771,6 @@ target_include_directories(alarm_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -10989,7 +10813,6 @@ target_include_directories(alts_counter_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11030,7 +10853,6 @@ target_include_directories(alts_crypt_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11072,7 +10894,6 @@ target_include_directories(alts_crypter_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11113,7 +10934,6 @@ target_include_directories(alts_frame_handler_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11155,7 +10975,6 @@ target_include_directories(alts_frame_protector_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11196,7 +11015,6 @@ target_include_directories(alts_grpc_record_protocol_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11237,7 +11055,6 @@ target_include_directories(alts_handshaker_client_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11278,7 +11095,6 @@ target_include_directories(alts_iovec_record_protocol_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11319,7 +11135,6 @@ target_include_directories(alts_security_connector_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11359,7 +11174,6 @@ target_include_directories(alts_tsi_handshaker_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11400,7 +11214,6 @@ target_include_directories(alts_tsi_utils_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11441,7 +11254,6 @@ target_include_directories(alts_zero_copy_grpc_protector_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11482,7 +11294,6 @@ target_include_directories(async_end2end_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11525,7 +11336,6 @@ target_include_directories(auth_property_iterator_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11568,7 +11378,6 @@ target_include_directories(backoff_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11609,7 +11418,6 @@ target_include_directories(bdp_estimator_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11653,7 +11461,6 @@ target_include_directories(bm_alarm PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11701,7 +11508,6 @@ target_include_directories(bm_arena PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11749,7 +11555,6 @@ target_include_directories(bm_byte_buffer PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11797,7 +11602,6 @@ target_include_directories(bm_call_create PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11845,7 +11649,6 @@ target_include_directories(bm_callback_streaming_ping_pong PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11894,7 +11697,6 @@ target_include_directories(bm_callback_unary_ping_pong PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11943,7 +11745,6 @@ target_include_directories(bm_channel PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -11991,7 +11792,6 @@ target_include_directories(bm_chttp2_hpack PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12039,7 +11839,6 @@ target_include_directories(bm_chttp2_transport PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12087,7 +11886,6 @@ target_include_directories(bm_closure PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12135,7 +11933,6 @@ target_include_directories(bm_cq PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12183,7 +11980,6 @@ target_include_directories(bm_cq_multiple_threads PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12231,7 +12027,6 @@ target_include_directories(bm_error PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12279,7 +12074,6 @@ target_include_directories(bm_fullstack_streaming_ping_pong PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12327,7 +12121,6 @@ target_include_directories(bm_fullstack_streaming_pump PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12375,7 +12168,6 @@ target_include_directories(bm_fullstack_trickle PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12423,7 +12215,6 @@ target_include_directories(bm_fullstack_unary_ping_pong PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12471,7 +12262,6 @@ target_include_directories(bm_metadata PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12519,7 +12309,6 @@ target_include_directories(bm_pollset PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12567,7 +12356,6 @@ target_include_directories(bm_threadpool PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12615,7 +12403,6 @@ target_include_directories(bm_timer PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12662,7 +12449,6 @@ target_include_directories(byte_stream_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12703,7 +12489,6 @@ target_include_directories(channel_arguments_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12744,7 +12529,6 @@ target_include_directories(channel_filter_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12792,7 +12576,6 @@ target_include_directories(channel_trace_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12835,7 +12618,6 @@ target_include_directories(channelz_registry_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12885,7 +12667,6 @@ target_include_directories(channelz_service_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12936,7 +12717,6 @@ target_include_directories(channelz_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -12979,7 +12759,6 @@ target_include_directories(check_gcp_environment_linux_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13019,7 +12798,6 @@ target_include_directories(check_gcp_environment_windows_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13059,7 +12837,6 @@ target_include_directories(chttp2_settings_timeout_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13100,7 +12877,6 @@ target_include_directories(cli_call_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13145,7 +12921,6 @@ target_include_directories(client_callback_end2end_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13195,7 +12970,6 @@ target_include_directories(client_channel_stress_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13239,7 +13013,6 @@ target_include_directories(client_crash_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13283,7 +13056,6 @@ target_include_directories(client_crash_test_server PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13328,7 +13100,6 @@ target_include_directories(client_interceptors_end2end_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13371,7 +13142,6 @@ target_include_directories(client_lb_end2end_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13463,7 +13233,6 @@ target_include_directories(codegen_test_full PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13555,7 +13324,6 @@ target_include_directories(codegen_test_minimal PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13596,7 +13364,6 @@ target_include_directories(context_list_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13637,7 +13404,6 @@ target_include_directories(credentials_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13678,7 +13444,6 @@ target_include_directories(cxx_byte_buffer_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13720,7 +13485,6 @@ target_include_directories(cxx_slice_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13762,7 +13526,6 @@ target_include_directories(cxx_string_ref_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13802,7 +13565,6 @@ target_include_directories(cxx_time_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13844,7 +13606,6 @@ target_include_directories(delegating_channel_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13888,7 +13649,6 @@ target_include_directories(end2end_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13938,7 +13698,6 @@ target_include_directories(error_details_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -13978,7 +13737,6 @@ target_include_directories(exception_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14021,7 +13779,6 @@ target_include_directories(filter_end2end_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14061,7 +13818,6 @@ target_include_directories(gen_hpack_tables PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14092,7 +13848,6 @@ target_include_directories(gen_legal_metadata_characters PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14121,7 +13876,6 @@ target_include_directories(gen_percent_encoding_tables PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14153,7 +13907,6 @@ target_include_directories(generic_end2end_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14196,7 +13949,6 @@ target_include_directories(global_config_env_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14236,7 +13988,6 @@ target_include_directories(global_config_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14283,7 +14034,6 @@ target_include_directories(golden_file_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14325,7 +14075,6 @@ target_include_directories(grpc_alts_credentials_options_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14365,7 +14114,6 @@ target_include_directories(grpc_cli PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14409,7 +14157,6 @@ target_include_directories(grpc_core_map_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14449,7 +14196,6 @@ target_include_directories(grpc_cpp_plugin PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14491,7 +14237,6 @@ target_include_directories(grpc_csharp_plugin PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14535,7 +14280,6 @@ target_include_directories(grpc_fetch_oauth2 PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14577,7 +14321,6 @@ target_include_directories(grpc_linux_system_roots_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14616,7 +14359,6 @@ target_include_directories(grpc_node_plugin PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14658,7 +14400,6 @@ target_include_directories(grpc_objective_c_plugin PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14700,7 +14441,6 @@ target_include_directories(grpc_php_plugin PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14742,7 +14482,6 @@ target_include_directories(grpc_python_plugin PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14784,7 +14523,6 @@ target_include_directories(grpc_ruby_plugin PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14828,7 +14566,6 @@ target_include_directories(grpc_spiffe_security_connector_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14885,7 +14622,6 @@ target_include_directories(grpc_tool_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14938,7 +14674,6 @@ target_include_directories(grpclb_api_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -14987,7 +14722,6 @@ target_include_directories(grpclb_end2end_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15052,7 +14786,6 @@ target_include_directories(grpclb_fallback_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15097,7 +14830,6 @@ target_include_directories(h2_ssl_cert_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15139,7 +14871,6 @@ target_include_directories(h2_ssl_session_reuse_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15181,7 +14912,6 @@ target_include_directories(health_service_end2end_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15224,7 +14954,6 @@ target_include_directories(http2_client PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15269,7 +14998,6 @@ target_include_directories(hybrid_end2end_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15312,7 +15040,6 @@ target_include_directories(inlined_vector_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15355,7 +15082,6 @@ target_include_directories(inproc_sync_unary_ping_pong_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15402,7 +15128,6 @@ target_include_directories(interop_client PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15449,7 +15174,6 @@ target_include_directories(interop_server PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15498,7 +15222,6 @@ target_include_directories(interop_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15542,7 +15265,6 @@ target_include_directories(json_run_localhost PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15587,7 +15309,6 @@ target_include_directories(memory_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15629,7 +15350,6 @@ target_include_directories(message_allocator_end2end_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15679,7 +15399,6 @@ target_include_directories(metrics_client PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15721,7 +15440,6 @@ target_include_directories(mock_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15764,7 +15482,6 @@ target_include_directories(nonblocking_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15807,7 +15524,6 @@ target_include_directories(noop-benchmark PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15846,7 +15562,6 @@ target_include_directories(optional_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15888,7 +15603,6 @@ target_include_directories(orphanable_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15930,7 +15644,6 @@ target_include_directories(port_sharing_end2end_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -15974,7 +15687,6 @@ target_include_directories(proto_server_reflection_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16019,7 +15731,6 @@ target_include_directories(proto_utils_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16060,7 +15771,6 @@ target_include_directories(qps_interarrival_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16106,7 +15816,6 @@ target_include_directories(qps_json_driver PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16153,7 +15862,6 @@ target_include_directories(qps_openloop_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16200,7 +15908,6 @@ target_include_directories(qps_worker PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16246,7 +15953,6 @@ target_include_directories(raw_end2end_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16310,7 +16016,6 @@ target_include_directories(reconnect_interop_client PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16375,7 +16080,6 @@ target_include_directories(reconnect_interop_server PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16421,7 +16125,6 @@ target_include_directories(ref_counted_ptr_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16463,7 +16166,6 @@ target_include_directories(ref_counted_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16505,7 +16207,6 @@ target_include_directories(retry_throttle_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16546,7 +16247,6 @@ target_include_directories(secure_auth_context_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16590,7 +16290,6 @@ target_include_directories(secure_sync_unary_ping_pong_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16637,7 +16336,6 @@ target_include_directories(server_builder_plugin_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16694,7 +16392,6 @@ target_include_directories(server_builder_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16752,7 +16449,6 @@ target_include_directories(server_builder_with_socket_mutator_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16796,7 +16492,6 @@ target_include_directories(server_context_test_spouse_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16839,7 +16534,6 @@ target_include_directories(server_crash_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16883,7 +16577,6 @@ target_include_directories(server_crash_test_client PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16927,7 +16620,6 @@ target_include_directories(server_early_return_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -16971,7 +16663,6 @@ target_include_directories(server_interceptors_end2end_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17028,7 +16719,6 @@ target_include_directories(server_request_call_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17071,7 +16761,6 @@ target_include_directories(service_config_end2end_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17114,7 +16803,6 @@ target_include_directories(service_config_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17156,7 +16844,6 @@ target_include_directories(shutdown_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17199,7 +16886,6 @@ target_include_directories(slice_hash_table_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17240,7 +16926,6 @@ target_include_directories(slice_weak_hash_table_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17281,7 +16966,6 @@ target_include_directories(stats_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17323,7 +17007,6 @@ target_include_directories(status_metadata_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17362,7 +17045,6 @@ target_include_directories(status_util_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17402,7 +17084,6 @@ target_include_directories(streaming_throughput_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17477,7 +17158,6 @@ target_include_directories(stress_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17521,7 +17201,6 @@ target_include_directories(string_view_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17563,7 +17242,6 @@ target_include_directories(thread_manager_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17605,7 +17283,6 @@ target_include_directories(thread_stress_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17649,7 +17326,6 @@ target_include_directories(time_change_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17693,7 +17369,6 @@ target_include_directories(transport_pid_controller_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17736,7 +17411,6 @@ target_include_directories(transport_security_common_api_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17778,7 +17452,6 @@ target_include_directories(writes_per_rpc_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17836,7 +17509,6 @@ target_include_directories(xds_end2end_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17877,7 +17549,6 @@ target_include_directories(public_headers_must_be_c89 PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17910,7 +17581,6 @@ target_include_directories(bad_streaming_id_bad_client_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17952,7 +17622,6 @@ target_include_directories(badreq_bad_client_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -17994,7 +17663,6 @@ target_include_directories(connection_prefix_bad_client_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18036,7 +17704,6 @@ target_include_directories(duplicate_header_bad_client_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18078,7 +17745,6 @@ target_include_directories(head_of_line_blocking_bad_client_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18120,7 +17786,6 @@ target_include_directories(headers_bad_client_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18162,7 +17827,6 @@ target_include_directories(initial_settings_frame_bad_client_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18204,7 +17868,6 @@ target_include_directories(large_metadata_bad_client_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18246,7 +17909,6 @@ target_include_directories(out_of_bounds_bad_client_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18288,7 +17950,6 @@ target_include_directories(server_registered_method_bad_client_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18330,7 +17991,6 @@ target_include_directories(simple_request_bad_client_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18372,7 +18032,6 @@ target_include_directories(unknown_frame_bad_client_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18414,7 +18073,6 @@ target_include_directories(window_overflow_bad_client_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18455,7 +18113,6 @@ target_include_directories(bad_ssl_cert_server PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18495,7 +18152,6 @@ target_include_directories(bad_ssl_cert_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18533,7 +18189,6 @@ target_include_directories(h2_census_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18571,7 +18226,6 @@ target_include_directories(h2_compress_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18609,7 +18263,6 @@ target_include_directories(h2_fakesec_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18648,7 +18301,6 @@ target_include_directories(h2_fd_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18687,7 +18339,6 @@ target_include_directories(h2_full_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18726,7 +18377,6 @@ target_include_directories(h2_full+pipe_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18765,7 +18415,6 @@ target_include_directories(h2_full+trace_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18803,7 +18452,6 @@ target_include_directories(h2_full+workarounds_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18841,7 +18489,6 @@ target_include_directories(h2_http_proxy_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18880,7 +18527,6 @@ target_include_directories(h2_local_ipv4_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18920,7 +18566,6 @@ target_include_directories(h2_local_ipv6_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18960,7 +18605,6 @@ target_include_directories(h2_local_uds_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -18999,7 +18643,6 @@ target_include_directories(h2_oauth2_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19037,7 +18680,6 @@ target_include_directories(h2_proxy_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19075,7 +18717,6 @@ target_include_directories(h2_sockpair_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19113,7 +18754,6 @@ target_include_directories(h2_sockpair+trace_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19151,7 +18791,6 @@ target_include_directories(h2_sockpair_1byte_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19189,7 +18828,6 @@ target_include_directories(h2_spiffe_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19227,7 +18865,6 @@ target_include_directories(h2_ssl_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19265,7 +18902,6 @@ target_include_directories(h2_ssl_cred_reload_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19303,7 +18939,6 @@ target_include_directories(h2_ssl_proxy_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19342,7 +18977,6 @@ target_include_directories(h2_uds_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19381,7 +19015,6 @@ target_include_directories(inproc_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19419,7 +19052,6 @@ target_include_directories(h2_census_nosec_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19457,7 +19089,6 @@ target_include_directories(h2_compress_nosec_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19496,7 +19127,6 @@ target_include_directories(h2_fd_nosec_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19535,7 +19165,6 @@ target_include_directories(h2_full_nosec_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19574,7 +19203,6 @@ target_include_directories(h2_full+pipe_nosec_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19613,7 +19241,6 @@ target_include_directories(h2_full+trace_nosec_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19651,7 +19278,6 @@ target_include_directories(h2_full+workarounds_nosec_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19689,7 +19315,6 @@ target_include_directories(h2_http_proxy_nosec_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19727,7 +19352,6 @@ target_include_directories(h2_proxy_nosec_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19765,7 +19389,6 @@ target_include_directories(h2_sockpair_nosec_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19803,7 +19426,6 @@ target_include_directories(h2_sockpair+trace_nosec_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19841,7 +19463,6 @@ target_include_directories(h2_sockpair_1byte_nosec_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19880,7 +19501,6 @@ target_include_directories(h2_uds_nosec_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19921,7 +19541,6 @@ target_include_directories(resolver_component_test_unsecure PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -19966,7 +19585,6 @@ target_include_directories(resolver_component_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -20012,7 +19630,6 @@ target_include_directories(resolver_component_tests_runner_invoker_unsecure PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -20058,7 +19675,6 @@ target_include_directories(resolver_component_tests_runner_invoker PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -20103,7 +19719,6 @@ target_include_directories(address_sorting_test_unsecure PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -20147,7 +19762,6 @@ target_include_directories(address_sorting_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -20191,7 +19805,6 @@ target_include_directories(cancel_ares_query_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -20235,7 +19848,6 @@ target_include_directories(alts_credentials_fuzzer_one_entry PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -20273,7 +19885,6 @@ target_include_directories(api_fuzzer_one_entry PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -20311,7 +19922,6 @@ target_include_directories(client_fuzzer_one_entry PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -20349,7 +19959,6 @@ target_include_directories(hpack_parser_fuzzer_test_one_entry PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -20387,7 +19996,6 @@ target_include_directories(http_request_fuzzer_test_one_entry PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -20425,7 +20033,6 @@ target_include_directories(http_response_fuzzer_test_one_entry PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -20463,7 +20070,6 @@ target_include_directories(json_fuzzer_test_one_entry PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -20501,7 +20107,6 @@ target_include_directories(nanopb_fuzzer_response_test_one_entry PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -20539,7 +20144,6 @@ target_include_directories(nanopb_fuzzer_serverlist_test_one_entry PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -20577,7 +20181,6 @@ target_include_directories(percent_decode_fuzzer_one_entry PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -20615,7 +20218,6 @@ target_include_directories(percent_encode_fuzzer_one_entry PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -20653,7 +20255,6 @@ target_include_directories(server_fuzzer_one_entry PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -20691,7 +20292,6 @@ target_include_directories(ssl_server_fuzzer_one_entry PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} @@ -20729,7 +20329,6 @@ target_include_directories(uri_fuzzer_test_one_entry PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} diff --git a/Makefile b/Makefile index ec88bd3926c..5b809a28866 100644 --- a/Makefile +++ b/Makefile @@ -354,7 +354,7 @@ CXXFLAGS += -stdlib=libc++ LDFLAGS += -framework CoreFoundation endif CXXFLAGS += -Wnon-virtual-dtor -CPPFLAGS += -g -Wall -Wextra -Werror $(W_NO_UNKNOWN_WARNING_OPTION) -Wno-long-long -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-maybe-uninitialized -DPB_FIELD_32BIT -DOSATOMIC_USE_INLINED=1 -Ithird_party/nanopb -Ithird_party/upb -Isrc/core/ext/upb-generated +CPPFLAGS += -g -Wall -Wextra -Werror $(W_NO_UNKNOWN_WARNING_OPTION) -Wno-long-long -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-maybe-uninitialized -DPB_FIELD_32BIT -DOSATOMIC_USE_INLINED=1 -Ithird_party/upb -Isrc/core/ext/upb-generated COREFLAGS += -fno-rtti -fno-exceptions LDFLAGS += -g diff --git a/PYTHON-MANIFEST.in b/PYTHON-MANIFEST.in index aa044d84074..003b26a7d36 100644 --- a/PYTHON-MANIFEST.in +++ b/PYTHON-MANIFEST.in @@ -7,7 +7,6 @@ graft include/grpc graft third_party/address_sorting graft third_party/boringssl graft third_party/cares -graft third_party/nanopb graft third_party/upb graft third_party/zlib include src/python/grpcio/_parallel_compile_patch.py diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index b226f15aa2a..06307b844cb 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -8,11 +8,6 @@ load("@com_github_grpc_grpc//bazel:grpc_python_deps.bzl", "grpc_python_deps") def grpc_deps(): """Loads dependencies need to compile and test the grpc library.""" - native.bind( - name = "nanopb", - actual = "@com_github_nanopb_nanopb//:nanopb", - ) - native.bind( name = "upb_lib", actual = "@upb//:upb", @@ -129,15 +124,6 @@ def grpc_deps(): url = "https://github.com/google/protobuf/archive/09745575a923640154bcf307fba8aedff47f240a.tar.gz", ) - if "com_github_nanopb_nanopb" not in native.existing_rules(): - http_archive( - name = "com_github_nanopb_nanopb", - build_file = "@com_github_grpc_grpc//third_party:nanopb.BUILD", - sha256 = "8bbbb1e78d4ddb0a1919276924ab10d11b631df48b657d960e0c795a25515735", - strip_prefix = "nanopb-f8ac463766281625ad710900479130c7fcb4d63b", - url = "https://github.com/nanopb/nanopb/archive/f8ac463766281625ad710900479130c7fcb4d63b.tar.gz", - ) - if "com_github_google_googletest" not in native.existing_rules(): http_archive( name = "com_github_google_googletest", diff --git a/build.yaml b/build.yaml index f43964408d4..f06a2b99d87 100644 --- a/build.yaml +++ b/build.yaml @@ -589,7 +589,6 @@ filegroups: - grpc_transport_inproc_headers - grpc++_codegen_base - grpc++_internal_hdrs_only - - nanopb_headers - name: grpc++_config_proto public_headers: - include/grpc++/impl/codegen/config_protobuf.h @@ -1537,19 +1536,6 @@ filegroups: - name: grpcpp_channelz_proto src: - src/proto/grpc/channelz/channelz.proto -- name: nanopb - src: - - third_party/nanopb/pb_common.c - - third_party/nanopb/pb_decode.c - - third_party/nanopb/pb_encode.c - uses: - - nanopb_headers -- name: nanopb_headers - headers: - - third_party/nanopb/pb.h - - third_party/nanopb/pb_common.h - - third_party/nanopb/pb_decode.h - - third_party/nanopb/pb_encode.h - name: proto_gen_validate_upb headers: - src/core/ext/upb-generated/gogoproto/gogo.upb.h @@ -6202,8 +6188,8 @@ defaults: CPPFLAGS: -g -Wall -Wextra -Werror $(W_NO_UNKNOWN_WARNING_OPTION) -Wno-long-long -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers - -Wno-maybe-uninitialized -DPB_FIELD_32BIT -DOSATOMIC_USE_INLINED=1 -Ithird_party/nanopb - -Ithird_party/upb -Isrc/core/ext/upb-generated + -Wno-maybe-uninitialized -DPB_FIELD_32BIT -DOSATOMIC_USE_INLINED=1 -Ithird_party/upb + -Isrc/core/ext/upb-generated CXXFLAGS: -Wnon-virtual-dtor LDFLAGS: -g zlib: diff --git a/cmake/nanopb.cmake b/cmake/nanopb.cmake deleted file mode 100644 index cebf6da27cd..00000000000 --- a/cmake/nanopb.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2018 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set(_gRPC_NANOPB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/nanopb") diff --git a/config.m4 b/config.m4 index 2a074768f57..d78bdfc75ac 100644 --- a/config.m4 +++ b/config.m4 @@ -10,7 +10,6 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/php/ext/grpc) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/address_sorting/include) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/boringssl/include) - PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/nanopb) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/upb) LIBS="-lpthread $LIBS" diff --git a/config.w32 b/config.w32 index 065da74bfb9..176ba2f340b 100644 --- a/config.w32 +++ b/config.w32 @@ -713,7 +713,6 @@ if (PHP_GRPC != "no") { "/I"+configure_module_dirname+"\\src\\php\\ext\\grpc "+ "/I"+configure_module_dirname+"\\third_party\\address_sorting\\include "+ "/I"+configure_module_dirname+"\\third_party\\boringssl\\include "+ - "/I"+configure_module_dirname+"\\third_party\\nanopb "+ "/I"+configure_module_dirname+"\\third_party\\upb "+ "/I"+configure_module_dirname+"\\third_party\\zlib "); diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 391eed9942f..d71773a7361 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -215,7 +215,6 @@ Pod::Spec.new do |s| ss.header_mappings_dir = '.' ss.dependency "#{s.name}/Interface", version ss.dependency 'gRPC-Core', grpc_version - ss.dependency 'nanopb', '~> 0.3' ss.source_files = 'include/grpcpp/impl/codegen/core_codegen.h', 'src/cpp/client/secure_credentials.h', @@ -228,10 +227,6 @@ Pod::Spec.new do |s| 'src/cpp/server/health/default_health_check_service.h', 'src/cpp/server/thread_pool_interface.h', 'src/cpp/thread_manager/thread_manager.h', - 'third_party/nanopb/pb.h', - 'third_party/nanopb/pb_common.h', - 'third_party/nanopb/pb_decode.h', - 'third_party/nanopb/pb_encode.h', 'src/cpp/client/insecure_credentials.cc', 'src/cpp/client/secure_credentials.cc', 'src/cpp/common/auth_property_iterator.cc', @@ -276,362 +271,7 @@ Pod::Spec.new do |s| 'src/cpp/util/string_ref.cc', 'src/cpp/util/time_cc.cc', 'src/cpp/codegen/codegen_init.cc', - 'src/cpp/client/cronet_credentials.cc', - 'src/core/lib/gpr/alloc.h', - 'src/core/lib/gpr/arena.h', - 'src/core/lib/gpr/env.h', - 'src/core/lib/gpr/mpscq.h', - 'src/core/lib/gpr/murmur_hash.h', - 'src/core/lib/gpr/spinlock.h', - 'src/core/lib/gpr/string.h', - 'src/core/lib/gpr/string_windows.h', - 'src/core/lib/gpr/time_precise.h', - 'src/core/lib/gpr/tls.h', - 'src/core/lib/gpr/tls_gcc.h', - 'src/core/lib/gpr/tls_msvc.h', - 'src/core/lib/gpr/tls_pthread.h', - 'src/core/lib/gpr/tmpfile.h', - 'src/core/lib/gpr/useful.h', - 'src/core/lib/gprpp/abstract.h', - 'src/core/lib/gprpp/arena.h', - 'src/core/lib/gprpp/atomic.h', - 'src/core/lib/gprpp/fork.h', - 'src/core/lib/gprpp/global_config.h', - 'src/core/lib/gprpp/global_config_custom.h', - 'src/core/lib/gprpp/global_config_env.h', - 'src/core/lib/gprpp/global_config_generic.h', - 'src/core/lib/gprpp/host_port.h', - 'src/core/lib/gprpp/manual_constructor.h', - 'src/core/lib/gprpp/map.h', - 'src/core/lib/gprpp/memory.h', - 'src/core/lib/gprpp/pair.h', - 'src/core/lib/gprpp/sync.h', - 'src/core/lib/gprpp/thd.h', - 'src/core/lib/profiling/timers.h', - 'src/core/ext/transport/chttp2/transport/bin_decoder.h', - 'src/core/ext/transport/chttp2/transport/bin_encoder.h', - 'src/core/ext/transport/chttp2/transport/chttp2_transport.h', - 'src/core/ext/transport/chttp2/transport/context_list.h', - 'src/core/ext/transport/chttp2/transport/flow_control.h', - 'src/core/ext/transport/chttp2/transport/frame.h', - 'src/core/ext/transport/chttp2/transport/frame_data.h', - 'src/core/ext/transport/chttp2/transport/frame_goaway.h', - 'src/core/ext/transport/chttp2/transport/frame_ping.h', - 'src/core/ext/transport/chttp2/transport/frame_rst_stream.h', - 'src/core/ext/transport/chttp2/transport/frame_settings.h', - 'src/core/ext/transport/chttp2/transport/frame_window_update.h', - 'src/core/ext/transport/chttp2/transport/hpack_encoder.h', - 'src/core/ext/transport/chttp2/transport/hpack_parser.h', - 'src/core/ext/transport/chttp2/transport/hpack_table.h', - 'src/core/ext/transport/chttp2/transport/http2_settings.h', - 'src/core/ext/transport/chttp2/transport/huffsyms.h', - 'src/core/ext/transport/chttp2/transport/incoming_metadata.h', - 'src/core/ext/transport/chttp2/transport/internal.h', - 'src/core/ext/transport/chttp2/transport/stream_map.h', - 'src/core/ext/transport/chttp2/transport/varint.h', - 'src/core/ext/transport/chttp2/alpn/alpn.h', - 'src/core/ext/filters/http/client/http_client_filter.h', - 'src/core/ext/filters/http/message_compress/message_compress_filter.h', - 'src/core/ext/filters/http/server/http_server_filter.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h', - 'src/core/ext/filters/client_channel/lb_policy/xds/xds.h', - 'src/core/lib/security/context/security_context.h', - 'src/core/lib/security/credentials/alts/alts_credentials.h', - 'src/core/lib/security/credentials/composite/composite_credentials.h', - 'src/core/lib/security/credentials/credentials.h', - 'src/core/lib/security/credentials/fake/fake_credentials.h', - 'src/core/lib/security/credentials/google_default/google_default_credentials.h', - 'src/core/lib/security/credentials/iam/iam_credentials.h', - 'src/core/lib/security/credentials/jwt/json_token.h', - 'src/core/lib/security/credentials/jwt/jwt_credentials.h', - 'src/core/lib/security/credentials/jwt/jwt_verifier.h', - 'src/core/lib/security/credentials/local/local_credentials.h', - 'src/core/lib/security/credentials/oauth2/oauth2_credentials.h', - 'src/core/lib/security/credentials/plugin/plugin_credentials.h', - 'src/core/lib/security/credentials/ssl/ssl_credentials.h', - 'src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h', - 'src/core/lib/security/credentials/tls/spiffe_credentials.h', - 'src/core/lib/security/security_connector/alts/alts_security_connector.h', - 'src/core/lib/security/security_connector/fake/fake_security_connector.h', - 'src/core/lib/security/security_connector/load_system_roots.h', - 'src/core/lib/security/security_connector/load_system_roots_linux.h', - 'src/core/lib/security/security_connector/local/local_security_connector.h', - 'src/core/lib/security/security_connector/security_connector.h', - 'src/core/lib/security/security_connector/ssl/ssl_security_connector.h', - 'src/core/lib/security/security_connector/ssl_utils.h', - 'src/core/lib/security/security_connector/tls/spiffe_security_connector.h', - 'src/core/lib/security/transport/auth_filters.h', - 'src/core/lib/security/transport/secure_endpoint.h', - 'src/core/lib/security/transport/security_handshaker.h', - 'src/core/lib/security/transport/target_authority_table.h', - 'src/core/lib/security/transport/tsi_error.h', - 'src/core/lib/security/util/json_util.h', - 'src/core/tsi/alts/crypt/gsec.h', - 'src/core/tsi/alts/frame_protector/alts_counter.h', - 'src/core/tsi/alts/frame_protector/alts_crypter.h', - 'src/core/tsi/alts/frame_protector/alts_frame_protector.h', - 'src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.h', - 'src/core/tsi/alts/frame_protector/frame_handler.h', - 'src/core/tsi/alts/handshaker/alts_handshaker_client.h', - 'src/core/tsi/alts/handshaker/alts_shared_resource.h', - 'src/core/tsi/alts/handshaker/alts_tsi_handshaker.h', - 'src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h', - 'src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h', - 'src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.h', - 'src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol.h', - 'src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h', - 'src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h', - 'src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h', - 'src/core/lib/security/credentials/alts/check_gcp_environment.h', - 'src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h', - 'src/core/tsi/alts/handshaker/alts_tsi_utils.h', - 'src/core/tsi/alts/handshaker/transport_security_common_api.h', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h', - 'third_party/upb/upb/decode.h', - 'third_party/upb/upb/encode.h', - 'third_party/upb/upb/generated_util.h', - 'third_party/upb/upb/msg.h', - 'third_party/upb/upb/port_def.inc', - 'third_party/upb/upb/port_undef.inc', - 'third_party/upb/upb/table.int.h', - 'third_party/upb/upb/upb.h', - 'src/core/tsi/transport_security.h', - 'src/core/tsi/transport_security_interface.h', - 'src/core/ext/transport/chttp2/client/authority.h', - 'src/core/ext/transport/chttp2/client/chttp2_connector.h', - 'src/core/ext/filters/client_channel/backup_poller.h', - 'src/core/ext/filters/client_channel/client_channel.h', - 'src/core/ext/filters/client_channel/client_channel_channelz.h', - 'src/core/ext/filters/client_channel/client_channel_factory.h', - 'src/core/ext/filters/client_channel/connector.h', - 'src/core/ext/filters/client_channel/global_subchannel_pool.h', - 'src/core/ext/filters/client_channel/health/health_check_client.h', - 'src/core/ext/filters/client_channel/http_connect_handshaker.h', - 'src/core/ext/filters/client_channel/http_proxy.h', - 'src/core/ext/filters/client_channel/lb_policy.h', - 'src/core/ext/filters/client_channel/lb_policy_factory.h', - 'src/core/ext/filters/client_channel/lb_policy_registry.h', - 'src/core/ext/filters/client_channel/local_subchannel_pool.h', - 'src/core/ext/filters/client_channel/parse_address.h', - 'src/core/ext/filters/client_channel/proxy_mapper.h', - 'src/core/ext/filters/client_channel/proxy_mapper_registry.h', - 'src/core/ext/filters/client_channel/resolver.h', - 'src/core/ext/filters/client_channel/resolver_factory.h', - 'src/core/ext/filters/client_channel/resolver_registry.h', - 'src/core/ext/filters/client_channel/resolver_result_parsing.h', - 'src/core/ext/filters/client_channel/resolving_lb_policy.h', - 'src/core/ext/filters/client_channel/retry_throttle.h', - 'src/core/ext/filters/client_channel/server_address.h', - 'src/core/ext/filters/client_channel/service_config.h', - 'src/core/ext/filters/client_channel/subchannel.h', - 'src/core/ext/filters/client_channel/subchannel_interface.h', - 'src/core/ext/filters/client_channel/subchannel_pool_interface.h', - 'src/core/ext/filters/deadline/deadline_filter.h', - 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h', - 'src/core/tsi/fake_transport_security.h', - 'src/core/tsi/local_transport_security.h', - 'src/core/tsi/ssl/session_cache/ssl_session.h', - 'src/core/tsi/ssl/session_cache/ssl_session_cache.h', - 'src/core/tsi/ssl_transport_security.h', - 'src/core/tsi/ssl_types.h', - 'src/core/tsi/transport_security_grpc.h', - 'src/core/tsi/grpc_shadow_boringssl.h', - 'src/core/ext/transport/chttp2/server/chttp2_server.h', - 'src/core/ext/transport/inproc/inproc_transport.h', - 'src/core/lib/avl/avl.h', - 'src/core/lib/backoff/backoff.h', - 'src/core/lib/channel/channel_args.h', - 'src/core/lib/channel/channel_stack.h', - 'src/core/lib/channel/channel_stack_builder.h', - 'src/core/lib/channel/channel_trace.h', - 'src/core/lib/channel/channelz.h', - 'src/core/lib/channel/channelz_registry.h', - 'src/core/lib/channel/connected_channel.h', - 'src/core/lib/channel/context.h', - 'src/core/lib/channel/handshaker.h', - 'src/core/lib/channel/handshaker_factory.h', - 'src/core/lib/channel/handshaker_registry.h', - 'src/core/lib/channel/status_util.h', - 'src/core/lib/compression/algorithm_metadata.h', - 'src/core/lib/compression/compression_args.h', - 'src/core/lib/compression/compression_internal.h', - 'src/core/lib/compression/message_compress.h', - 'src/core/lib/compression/stream_compression.h', - 'src/core/lib/compression/stream_compression_gzip.h', - 'src/core/lib/compression/stream_compression_identity.h', - 'src/core/lib/debug/stats.h', - 'src/core/lib/debug/stats_data.h', - 'src/core/lib/gprpp/debug_location.h', - 'src/core/lib/gprpp/inlined_vector.h', - 'src/core/lib/gprpp/optional.h', - 'src/core/lib/gprpp/orphanable.h', - 'src/core/lib/gprpp/ref_counted.h', - 'src/core/lib/gprpp/ref_counted_ptr.h', - 'src/core/lib/gprpp/string_view.h', - 'src/core/lib/http/format_request.h', - 'src/core/lib/http/httpcli.h', - 'src/core/lib/http/parser.h', - 'src/core/lib/iomgr/block_annotate.h', - 'src/core/lib/iomgr/buffer_list.h', - 'src/core/lib/iomgr/call_combiner.h', - 'src/core/lib/iomgr/cfstream_handle.h', - 'src/core/lib/iomgr/closure.h', - 'src/core/lib/iomgr/combiner.h', - 'src/core/lib/iomgr/dynamic_annotations.h', - 'src/core/lib/iomgr/endpoint.h', - 'src/core/lib/iomgr/endpoint_cfstream.h', - 'src/core/lib/iomgr/endpoint_pair.h', - 'src/core/lib/iomgr/error.h', - 'src/core/lib/iomgr/error_cfstream.h', - 'src/core/lib/iomgr/error_internal.h', - 'src/core/lib/iomgr/ev_epoll1_linux.h', - 'src/core/lib/iomgr/ev_epollex_linux.h', - 'src/core/lib/iomgr/ev_poll_posix.h', - 'src/core/lib/iomgr/ev_posix.h', - 'src/core/lib/iomgr/exec_ctx.h', - 'src/core/lib/iomgr/executor.h', - 'src/core/lib/iomgr/executor/mpmcqueue.h', - 'src/core/lib/iomgr/executor/threadpool.h', - 'src/core/lib/iomgr/gethostname.h', - 'src/core/lib/iomgr/grpc_if_nametoindex.h', - 'src/core/lib/iomgr/internal_errqueue.h', - 'src/core/lib/iomgr/iocp_windows.h', - 'src/core/lib/iomgr/iomgr.h', - 'src/core/lib/iomgr/iomgr_custom.h', - 'src/core/lib/iomgr/iomgr_internal.h', - 'src/core/lib/iomgr/iomgr_posix.h', - 'src/core/lib/iomgr/is_epollexclusive_available.h', - 'src/core/lib/iomgr/load_file.h', - 'src/core/lib/iomgr/lockfree_event.h', - 'src/core/lib/iomgr/nameser.h', - 'src/core/lib/iomgr/polling_entity.h', - 'src/core/lib/iomgr/pollset.h', - 'src/core/lib/iomgr/pollset_custom.h', - 'src/core/lib/iomgr/pollset_set.h', - 'src/core/lib/iomgr/pollset_set_custom.h', - 'src/core/lib/iomgr/pollset_set_windows.h', - 'src/core/lib/iomgr/pollset_windows.h', - 'src/core/lib/iomgr/port.h', - 'src/core/lib/iomgr/resolve_address.h', - 'src/core/lib/iomgr/resolve_address_custom.h', - 'src/core/lib/iomgr/resource_quota.h', - 'src/core/lib/iomgr/sockaddr.h', - 'src/core/lib/iomgr/sockaddr_custom.h', - 'src/core/lib/iomgr/sockaddr_posix.h', - 'src/core/lib/iomgr/sockaddr_utils.h', - 'src/core/lib/iomgr/sockaddr_windows.h', - 'src/core/lib/iomgr/socket_factory_posix.h', - 'src/core/lib/iomgr/socket_mutator.h', - 'src/core/lib/iomgr/socket_utils.h', - 'src/core/lib/iomgr/socket_utils_posix.h', - 'src/core/lib/iomgr/socket_windows.h', - 'src/core/lib/iomgr/sys_epoll_wrapper.h', - 'src/core/lib/iomgr/tcp_client.h', - 'src/core/lib/iomgr/tcp_client_posix.h', - 'src/core/lib/iomgr/tcp_custom.h', - 'src/core/lib/iomgr/tcp_posix.h', - 'src/core/lib/iomgr/tcp_server.h', - 'src/core/lib/iomgr/tcp_server_utils_posix.h', - 'src/core/lib/iomgr/tcp_windows.h', - 'src/core/lib/iomgr/time_averaged_stats.h', - 'src/core/lib/iomgr/timer.h', - 'src/core/lib/iomgr/timer_custom.h', - 'src/core/lib/iomgr/timer_heap.h', - 'src/core/lib/iomgr/timer_manager.h', - 'src/core/lib/iomgr/udp_server.h', - 'src/core/lib/iomgr/unix_sockets_posix.h', - 'src/core/lib/iomgr/wakeup_fd_pipe.h', - 'src/core/lib/iomgr/wakeup_fd_posix.h', - 'src/core/lib/json/json.h', - 'src/core/lib/json/json_common.h', - 'src/core/lib/json/json_reader.h', - 'src/core/lib/json/json_writer.h', - 'src/core/lib/slice/b64.h', - 'src/core/lib/slice/percent_encoding.h', - 'src/core/lib/slice/slice_hash_table.h', - 'src/core/lib/slice/slice_internal.h', - 'src/core/lib/slice/slice_string_helpers.h', - 'src/core/lib/slice/slice_utils.h', - 'src/core/lib/slice/slice_weak_hash_table.h', - 'src/core/lib/surface/api_trace.h', - 'src/core/lib/surface/call.h', - 'src/core/lib/surface/call_test_only.h', - 'src/core/lib/surface/channel.h', - 'src/core/lib/surface/channel_init.h', - 'src/core/lib/surface/channel_stack_type.h', - 'src/core/lib/surface/completion_queue.h', - 'src/core/lib/surface/completion_queue_factory.h', - 'src/core/lib/surface/event_string.h', - 'src/core/lib/surface/init.h', - 'src/core/lib/surface/lame_client.h', - 'src/core/lib/surface/server.h', - 'src/core/lib/surface/validate_metadata.h', - 'src/core/lib/transport/bdp_estimator.h', - 'src/core/lib/transport/byte_stream.h', - 'src/core/lib/transport/connectivity_state.h', - 'src/core/lib/transport/error_utils.h', - 'src/core/lib/transport/http2_errors.h', - 'src/core/lib/transport/metadata.h', - 'src/core/lib/transport/metadata_batch.h', - 'src/core/lib/transport/pid_controller.h', - 'src/core/lib/transport/static_metadata.h', - 'src/core/lib/transport/status_conversion.h', - 'src/core/lib/transport/status_metadata.h', - 'src/core/lib/transport/timeout_encoding.h', - 'src/core/lib/transport/transport.h', - 'src/core/lib/transport/transport_impl.h', - 'src/core/lib/uri/uri_parser.h', - 'src/core/lib/debug/trace.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h', - 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h', - 'src/core/ext/upb-generated/google/api/annotations.upb.h', - 'src/core/ext/upb-generated/google/api/http.upb.h', - 'src/core/ext/upb-generated/google/protobuf/any.upb.h', - 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.h', - 'src/core/ext/upb-generated/google/protobuf/duration.upb.h', - 'src/core/ext/upb-generated/google/protobuf/empty.upb.h', - 'src/core/ext/upb-generated/google/protobuf/struct.upb.h', - 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.h', - 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.h', - 'src/core/ext/upb-generated/google/rpc/status.upb.h', - 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', - 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h', - 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h', - 'src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h', - 'src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h', - 'src/core/ext/upb-generated/envoy/api/v2/cds.upb.h', - 'src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h', - 'src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h', - 'src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h', - 'src/core/ext/upb-generated/envoy/api/v2/eds.upb.h', - 'src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h', - 'src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h', - 'src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h', - 'src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h', - 'src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h', - 'src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h', - 'src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h', - 'src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h', - 'src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h', - 'src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h', - 'src/core/ext/upb-generated/envoy/type/percent.upb.h', - 'src/core/ext/upb-generated/envoy/type/range.upb.h', - 'src/core/ext/upb-generated/gogoproto/gogo.upb.h', - 'src/core/ext/upb-generated/validate/validate.upb.h', - 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', - 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', - 'src/core/ext/filters/max_age/max_age_filter.h', - 'src/core/ext/filters/message_size/message_size_filter.h', - 'src/core/ext/filters/http/client_authority_filter.h', - 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h', - 'src/core/ext/filters/workarounds/workaround_utils.h' + 'src/cpp/client/cronet_credentials.cc' ss.private_header_files = 'include/grpcpp/impl/codegen/core_codegen.h', 'src/cpp/client/secure_credentials.h', @@ -843,8 +483,6 @@ Pod::Spec.new do |s| end s.prepare_command = <<-END_OF_COMMAND - sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS==1\\\n #include \\\n#else\\\n #include "\\1"\\\n#endif;g' $(find src/core -type f -print | xargs grep -H -c '#include \\\n#else\\\n #include "\\1"\\\n#endif;g' $(find src/cpp -type f -print | xargs grep -H -c '#include 0.3' ss.compiler_flags = '-DGRPC_SHADOW_BORINGSSL_SYMBOLS' # To save you from scrolling, this is the last part of the podspec. @@ -1480,7 +1479,6 @@ Pod::Spec.new do |s| # TODO (mxyan): Instead of this hack, add include path "third_party" to C core's include path? s.prepare_command = <<-END_OF_COMMAND - sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS==1\\\n #include \\\n#else\\\n #include "\\1"\\\n#endif;g' $(find src/core -type f -print | xargs grep -H -c '#include ;#if COCOAPODS==1\\\n #include \\\n#else\\\n #include \\\n#endif;g' $(find src/core -type f \\( -path '*.h' -or -path '*.cc' \\) -print | xargs grep -H -c '#include <%! - def needs_nanopb(srcs): - return any(f.startswith("third_party/nanopb") - or f.endswith(".pb.h") - or f.endswith(".pb.c") - or f.endswith(".pb.cc") - or f.endswith("load_balancer_api.h") - or f.endswith("load_balancer_api.c") - for f in srcs) - %><%! def needs_address_sorting(sources): return needs_ares(sources) or any("address_sorting" in s for s in sources) @@ -87,15 +75,12 @@ dirs = ["third_party/cares"] if needs_address_sorting(sources): dirs.append("third_party/address_sorting/include") - if needs_nanopb(sources): - dirs.append("third_party/nanopb") return dirs %><%! def strip_sources(sources, name): return [f for f in sources if "ruby_generator" not in f - and ("third_party/nanopb" not in f or name == "nanopb") and ("health.pb" not in f or name == "health_proto")] %><%! @@ -126,7 +111,7 @@ %> % for lib in filegroups: - % if lib.name in ("nanopb", "health_proto"): + % if lib.name in ("health_proto"): ${cc_library(lib)} %endif %endfor diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index 8d01540453c..bcdd5f152ce 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -190,7 +190,6 @@ include(cmake/benchmark.cmake) include(cmake/cares.cmake) include(cmake/gflags.cmake) - include(cmake/nanopb.cmake) include(cmake/protobuf.cmake) include(cmake/ssl.cmake) include(cmake/upb.cmake) @@ -431,7 +430,6 @@ PRIVATE <%text>${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE <%text>${_gRPC_CARES_INCLUDE_DIR} PRIVATE <%text>${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE <%text>${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE <%text>${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE <%text>${_gRPC_SSL_INCLUDE_DIR} PRIVATE <%text>${_gRPC_UPB_GENERATED_DIR} @@ -530,7 +528,6 @@ PRIVATE <%text>${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE <%text>${_gRPC_CARES_INCLUDE_DIR} PRIVATE <%text>${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE <%text>${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE <%text>${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE <%text>${_gRPC_SSL_INCLUDE_DIR} PRIVATE <%text>${_gRPC_UPB_GENERATED_DIR} diff --git a/templates/config.m4.template b/templates/config.m4.template index 677c7ddf63a..794c6f3e86b 100644 --- a/templates/config.m4.template +++ b/templates/config.m4.template @@ -12,7 +12,6 @@ PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/php/ext/grpc) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/address_sorting/include) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/boringssl/include) - PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/nanopb) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/upb) LIBS="-lpthread $LIBS" diff --git a/templates/config.w32.template b/templates/config.w32.template index 70920f3527d..2515863516c 100644 --- a/templates/config.w32.template +++ b/templates/config.w32.template @@ -30,7 +30,6 @@ "/I"+configure_module_dirname+"\\src\\php\\ext\\grpc "+ "/I"+configure_module_dirname+"\\third_party\\address_sorting\\include "+ "/I"+configure_module_dirname+"\\third_party\\boringssl\\include "+ - "/I"+configure_module_dirname+"\\third_party\\nanopb "+ "/I"+configure_module_dirname+"\\third_party\\upb "+ "/I"+configure_module_dirname+"\\third_party\\zlib "); <% diff --git a/templates/gRPC-C++.podspec.template b/templates/gRPC-C++.podspec.template index 6ee6798f95e..1e7771f29b1 100644 --- a/templates/gRPC-C++.podspec.template +++ b/templates/gRPC-C++.podspec.template @@ -67,10 +67,6 @@ excl_files += grpcpp_proto_files(filegroups) out = [file for file in out if file not in excl_files] - # Since some C++ source files directly included private headers in C core, we include all the - # C core headers in C++ Implementation subspec as well. - out += [file for file in grpc_private_headers(libs) if not file.startswith("third_party/nanopb/")] - out = filter_grpcpp(out) return out @@ -81,10 +77,6 @@ excl_files = grpcpp_proto_files(filegroups) out = [file for file in out if file not in excl_files] - # Since some C++ source files directly included private headers in C core, we intentionally - # keep the C core headers in \a out. But we should exclude nanopb headers. - out = [file for file in out if not file.startswith("third_party/nanopb/")] - out = filter_grpcpp(out) return out @@ -208,7 +200,6 @@ ss.header_mappings_dir = '.' ss.dependency "#{s.name}/Interface", version ss.dependency 'gRPC-Core', grpc_version - ss.dependency 'nanopb', '~> 0.3' ss.source_files = ${ruby_multiline_list(grpcpp_private_files(libs, filegroups), 22)} @@ -223,8 +214,6 @@ end s.prepare_command = <<-END_OF_COMMAND - sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS==1\\\n #include \\\n#else\\\n #include "\\1"\\\n#endif;g' $(find src/core -type f -print | xargs grep -H -c '#include \\\n#else\\\n #include "\\1"\\\n#endif;g' $(find src/cpp -type f -print | xargs grep -H -c '#include 0.3' ss.compiler_flags = '-DGRPC_SHADOW_BORINGSSL_SYMBOLS' # To save you from scrolling, this is the last part of the podspec. @@ -213,7 +212,6 @@ # TODO (mxyan): Instead of this hack, add include path "third_party" to C core's include path? s.prepare_command = <<-END_OF_COMMAND - sed -E -i '' 's;#include "(pb(_.*)?\\.h)";#if COCOAPODS==1\\\n #include \\\n#else\\\n #include "\\1"\\\n#endif;g' $(find src/core -type f -print | xargs grep -H -c '#include ;#if COCOAPODS==1\\\n #include \\\n#else\\\n #include \\\n#endif;g' $(find src/core -type f \\( -path '*.h' -or -path '*.cc' \\) -print | xargs grep -H -c '#include -Michael Poole -Daniel Kan -Stan Hu -dch -Steffen Siering -Jens Steinhauser -Pavel Ilin -Kent Ryhorchuk -Martin Donath -Oliver Lee -Michael Haberler -Nicolas Colomer -Ivan Kravets -Kyle Manna -Benjamin Kamath -Andrew Ruder -Kenshi Kawaguchi -isotes -Maxim Khitrov -Yaniv Mordekhay -Ming Zhao -Google, Inc. -Tom Roeder diff --git a/third_party/nanopb/BUILD b/third_party/nanopb/BUILD deleted file mode 100644 index 1dc830eb018..00000000000 --- a/third_party/nanopb/BUILD +++ /dev/null @@ -1,24 +0,0 @@ -licenses(["notice"]) - -exports_files(["LICENSE.txt"]) - -package(default_visibility = ["//visibility:public"]) - -cc_library( - name = "nanopb", - srcs = [ - "pb_common.c", - "pb_decode.c", - "pb_encode.c", - ], - hdrs = [ - "pb.h", - "pb_common.h", - "pb_decode.h", - "pb_encode.h", - ], - defines = [ - "PB_FIELD_32BIT=1", - ], - visibility = ["//visibility:public"], -) diff --git a/third_party/nanopb/CHANGELOG.txt b/third_party/nanopb/CHANGELOG.txt deleted file mode 100644 index 8437688fc52..00000000000 --- a/third_party/nanopb/CHANGELOG.txt +++ /dev/null @@ -1,241 +0,0 @@ -nanopb-0.3.6 (2016-06-19) - Protect against corrupted _count fields in pb_release (#205) - Fix error in STATIC_ASSERT with multiple files (#203) - Add -D option to specify output directory (#193) - Generate MIN/MAX/ARRAYSIZE defines for enums (#194) - Generate comments about uncalculable message sizes (#195) - Documentation updates (#196, #201) - Improvements to test cases. - -nanopb-0.3.5 (2016-02-13) - NOTE: If you are using pb_syshdr.h, you will need to add uint_least8_t - definition. See docs/migration.rst for details. - - Fix generator crash with Enum inside Oneof (#188) - Fix some generator regressions related to .options file path (#172) - Add support for platforms without uint8_t (#191) - Allow const parameter to pb_istream_from_buffer (#152) - Ignore null pointers in pb_release() (#183) - Add support for anonymous unions (#184) - Add Python3 support to the generator (#169) - Add code generator insertion points to generated files (#178) - Improvements to CMake script (#181) - Improvements to test cases. - -nanopb-0.3.4 (2015-09-26) - Fix handling of unsigned 8- and 16-bit enums (issue 164) - Fix generator on systems where python = python3. (issue 155) - Fix compiler warning on GCC 5.x (issue 171) - Make the generator better handle imported .protos (issue 165) - Add packed_enum option to generator. - Add syntax= line to .proto files (issue 167) - Add PlatformIO registry manifest file. (pr 156) - -nanopb-0.3.3 (2015-04-10) - Fix missing files in Linux binary package (issue 146) - Fix generator bug when oneof is first field in a message. (issue 142) - Fix generator error when long_names:false is combined with Oneofs. (issue 147) - Fix oneof submessage initialization bug. (issue 149) - Fix problem with plugin options on Python 2.7.2 and older. (issue 153) - Fix crash when callback is inside oneof field. (issue 148) - Switch to .tar.gz format for Mac OS X packages. (issue 154) - Always define enum long names so that cross-file references work. (issue 118) - Add msgid generator option. (issue 151) - Improve comment support in .options files. (issue 145) - Updates for the CMake rule file, add cmake example. - Better error messages for syntax errors in .options file - -nanopb-0.3.2 (2015-01-24) - Fix memory leaks with PB_ENABLE_MALLOC with some submessage hierarchies (issue 138) - Implement support for oneofs (C unions). (issues 131, 141) - Add int_size option for generator (issue 139) - Add compilation option to disable struct packing. (issue 136) - Change PB_RETURN_ERROR() macro to avoid compiler warnings (issue 140) - Fix build problems with protoc 3.0.0 - Add support for POINTER type in extensions - Initialize also extension fields to defaults in pb_decode(). - Detect too large varint values when decoding. - -nanopb-0.3.1 (2014-09-11) - Fix security issue due to size_t overflows. (issue 132) - Fix memory leak with duplicated fields and PB_ENABLE_MALLOC - Fix crash if pb_release() is called twice. - Fix cyclic message support (issue 130) - Fix error in generated initializers for repeated pointer fields. - Improve tests (issues 113, 126) - -nanopb-0.3.0 (2014-08-26) - NOTE: See docs/migration.html or online at - http://koti.kapsi.fi/~jpa/nanopb/docs/migration.html - for changes in this version. Most importantly, you need to add - pb_common.c to the list of files to compile. - - Separated field iterator logic to pb_common.c (issue 128) - Change the _count fields to use pb_size_t datatype (issue 82) - Added PB_ prefix to macro names (issue 106) - Added #if version guard to generated files (issue 129) - Added migration document - -nanopb-0.2.9 (2014-08-09) - NOTE: If you are using the -e option with the generator, you have - to prepend . to the argument to get the same behaviour as before. - - Do not automatically add a dot with generator -e option. (issue 122) - Fix problem with .options file and extension fields. (issue 125) - Don't use SIZE_MAX macro, as it is not in C89. (issue 120) - Generate #defines for initializing message structures. (issue 79) - Add skip_message option to generator. (issue 121) - Add PB_PACKED_STRUCT support for Keil MDK-ARM toolchain (issue 119) - Give better messages about the .options file path. (issue 124) - Improved tests - -nanopb-0.2.8 (2014-05-20) - Fix security issue with PB_ENABLE_MALLOC. (issue 117) - Add option to not add timestamps to .pb.h and .pb.c preambles. (issue 115) - Documentation updates - Improved tests - -nanopb-0.2.7 (2014-04-07) - Fix bug with default values for extension fields (issue 111) - Fix some MISRA-C warnings (issue 91) - Implemented optional malloc() support (issue 80) - Changed pointer-type bytes field datatype - Add a "found" field to pb_extension_t (issue 112) - Add convenience function pb_get_encoded_size() (issue 16) - -nanopb-0.2.6 (2014-02-15) - Fix generator error with bytes callback fields (issue 99) - Fix warnings about large integer constants (issue 102) - Add comments to where STATIC_ASSERT is used (issue 96) - Add warning about unknown field names on .options (issue 105) - Move descriptor.proto to google/protobuf subdirectory (issue 104) - Improved tests - -nanopb-0.2.5 (2014-01-01) - Fix a bug with encoding negative values in int32 fields (issue 97) - Create binary packages of the generator + dependencies (issue 47) - Add support for pointer-type fields to the encoder (part of issue 80) - Fixed path in FindNanopb.cmake (issue 94) - Improved tests - -nanopb-0.2.4 (2013-11-07) - Remove the deprecated NANOPB_INTERNALS functions from public API. - Document the security model. - Check array and bytes max sizes when encoding (issue 90) - Add #defines for maximum encoded message size (issue 89) - Add #define tags for extension fields (issue 93) - Fix MISRA C violations (issue 91) - Clean up pb_field_t definition with typedefs. - -nanopb-0.2.3 (2013-09-18) - Improve compatibility by removing ternary operator from initializations (issue 88) - Fix build error on Visual C++ (issue 84, patch by Markus Schwarzenberg) - Don't stop on unsupported extension fields (issue 83) - Add an example pb_syshdr.h file for non-C99 compilers - Reorganize tests and examples into subfolders (issue 63) - Switch from Makefiles to scons for building the tests - Make the tests buildable on Windows - -nanopb-0.2.2 (2013-08-18) - Add support for extension fields (issue 17) - Fix unknown fields in empty message (issue 78) - Include the field tags in the generated .pb.h file. - Add pb_decode_delimited and pb_encode_delimited wrapper functions (issue 74) - Add a section in top of pb.h for changing compilation settings (issue 76) - Documentation improvements (issues 12, 77 and others) - Improved tests - -nanopb-0.2.1 (2013-04-14) - NOTE: The default callback function signature has changed. - If you don't want to update your code, define PB_OLD_CALLBACK_STYLE. - - Change the callback function to use void** (issue 69) - Add support for defining the nanopb options in a separate file (issue 12) - Add support for packed structs in IAR and MSVC (in addition to GCC) (issue 66) - Implement error message support for the encoder side (issue 7) - Handle unterminated strings when encoding (issue 68) - Fix bug with empty strings in repeated string callbacks (issue 73) - Fix regression in 0.2.0 with optional callback fields (issue 70) - Fix bugs with empty message types (issues 64, 65) - Fix some compiler warnings on clang (issue 67) - Some portability improvements (issues 60, 62) - Various new generator options - Improved tests - -nanopb-0.2.0 (2013-03-02) - NOTE: This release requires you to regenerate all .pb.c - files. Files generated by older versions will not - compile anymore. - - Reformat generated .pb.c files using macros (issue 58) - Rename PB_HTYPE_ARRAY -> PB_HTYPE_REPEATED - Separate PB_HTYPE to PB_ATYPE and PB_HTYPE - Move STATIC_ASSERTs to .pb.c file - Added CMake file (by Pavel Ilin) - Add option to give file extension to generator (by Michael Haberler) - Documentation updates - -nanopb-0.1.9 (2013-02-13) - Fixed error message bugs (issues 52, 56) - Sanitize #ifndef filename (issue 50) - Performance improvements - Add compile-time option PB_BUFFER_ONLY - Add Java package name to nanopb.proto - Check for sizeof(double) == 8 (issue 54) - Added generator option to ignore some fields. (issue 51) - Added generator option to make message structs packed. (issue 49) - Add more test cases. - -nanopb-0.1.8 (2012-12-13) - Fix bugs in the enum short names introduced in 0.1.7 (issues 42, 43) - Fix STATIC_ASSERT macro when using multiple .proto files. (issue 41) - Fix missing initialization of istream.errmsg - Make tests/Makefile work for non-gcc compilers (issue 40) - -nanopb-0.1.7 (2012-11-11) - Remove "skip" mode from pb_istream_t callbacks. Example implementation had a bug. (issue 37) - Add option to use shorter names for enum values (issue 38) - Improve options support in generator (issues 12, 30) - Add nanopb version number to generated files (issue 36) - Add extern "C" to generated headers (issue 35) - Add names for structs to allow forward declaration (issue 39) - Add buffer size check in example (issue 34) - Fix build warnings on MS compilers (issue 33) - -nanopb-0.1.6 (2012-09-02) - Reorganize the field decoder interface (issue 2) - Improve performance in submessage decoding (issue 28) - Implement error messages in the decoder side (issue 7) - Extended testcases (alltypes test is now complete). - Fix some compiler warnings (issues 25, 26, 27, 32). - -nanopb-0.1.5 (2012-08-04) - Fix bug in decoder with packed arrays (issue 23). - Extended testcases. - Fix some compiler warnings. - -nanopb-0.1.4 (2012-07-05) - Add compile-time options for easy-to-use >255 field support. - Improve the detection of missing required fields. - Added example on how to handle union messages. - Fix generator error with .proto without messages. - Fix problems that stopped the code from compiling with some compilers. - Fix some compiler warnings. - -nanopb-0.1.3 (2012-06-12) - Refactor the field encoder interface. - Improve generator error messages (issue 5) - Add descriptor.proto into the #include exclusion list - Fix some compiler warnings. - -nanopb-0.1.2 (2012-02-15) - Make the generator to generate include for other .proto files (issue 4). - Fixed generator not working on Windows (issue 3) - -nanopb-0.1.1 (2012-01-14) - Fixed bug in encoder with 'bytes' fields (issue 1). - Fixed a bug in the generator that caused a compiler error on sfixed32 and sfixed64 fields. - Extended testcases. - -nanopb-0.1.0 (2012-01-06) - First stable release. diff --git a/third_party/nanopb/CONTRIBUTING.md b/third_party/nanopb/CONTRIBUTING.md deleted file mode 100644 index 4041bc3caf7..00000000000 --- a/third_party/nanopb/CONTRIBUTING.md +++ /dev/null @@ -1,32 +0,0 @@ -Contributing to Nanopb development -================================== - -Reporting issues and requesting features ----------------------------------------- - -Feel free to report any issues you see or features you would like -to see in the future to the Github issue tracker. Using the templates -below is preferred: - -* [Report a bug](https://github.com/nanopb/nanopb/issues/new?body=**Steps%20to%20reproduce%20the%20issue**%0a%0a1.%0a2.%0a3.%0a%0a**What%20happens?**%0A%0A**What%20should%20happen?**&labels=Type-Defect) -* [Request a feature](https://github.com/nanopb/nanopb/issues/new?body=**What%20should%20the%20feature%20do?**%0A%0A**In%20what%20situation%20would%20the%20feature%20be%20useful?**&labels=Type-Enhancement) - -Requesting help ---------------- - -If there is something strange going on, but you do not know if -it is actually a bug in nanopb, try asking first on the -[discussion forum](https://groups.google.com/forum/#!forum/nanopb). - -Pull requests -------------- - -Pull requests are welcome! - -If it is not obvious from the commit message, please indicate the -same information as you would for an issue report: - -* What functionality it fixes/adds. -* How can the problem be reproduced / when would the feature be useful. - - diff --git a/third_party/nanopb/LICENSE.txt b/third_party/nanopb/LICENSE.txt deleted file mode 100644 index d11c9af1d7e..00000000000 --- a/third_party/nanopb/LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2011 Petteri Aimonen - -This software is provided 'as-is', without any express or -implied warranty. In no event will the authors be held liable -for any damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you - must not claim that you wrote the original software. If you use - this software in a product, an acknowledgment in the product - documentation would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and - must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source - distribution. diff --git a/third_party/nanopb/README.md b/third_party/nanopb/README.md deleted file mode 100644 index 2d35e85df24..00000000000 --- a/third_party/nanopb/README.md +++ /dev/null @@ -1,71 +0,0 @@ -Nanopb - Protocol Buffers for Embedded Systems -============================================== - -[![Build Status](https://travis-ci.org/nanopb/nanopb.svg?branch=master)](https://travis-ci.org/nanopb/nanopb) - -Nanopb is a small code-size Protocol Buffers implementation in ansi C. It is -especially suitable for use in microcontrollers, but fits any memory -restricted system. - -* **Homepage:** http://kapsi.fi/~jpa/nanopb/ -* **Documentation:** http://kapsi.fi/~jpa/nanopb/docs/ -* **Downloads:** http://kapsi.fi/~jpa/nanopb/download/ -* **Forum:** https://groups.google.com/forum/#!forum/nanopb - - - -Using the nanopb library ------------------------- -To use the nanopb library, you need to do two things: - -1. Compile your .proto files for nanopb, using protoc. -2. Include pb_encode.c and pb_decode.c in your project. - -The easiest way to get started is to study the project in "examples/simple". -It contains a Makefile, which should work directly under most Linux systems. -However, for any other kind of build system, see the manual steps in -README.txt in that folder. - - - -Using the Protocol Buffers compiler (protoc) --------------------------------------------- -The nanopb generator is implemented as a plugin for the Google's own protoc -compiler. This has the advantage that there is no need to reimplement the -basic parsing of .proto files. However, it does mean that you need the -Google's protobuf library in order to run the generator. - -If you have downloaded a binary package for nanopb (either Windows, Linux or -Mac OS X version), the 'protoc' binary is included in the 'generator-bin' -folder. In this case, you are ready to go. Simply run this command: - - generator-bin/protoc --nanopb_out=. myprotocol.proto - -However, if you are using a git checkout or a plain source distribution, you -need to provide your own version of protoc and the Google's protobuf library. -On Linux, the necessary packages are protobuf-compiler and python-protobuf. -On Windows, you can either build Google's protobuf library from source or use -one of the binary distributions of it. In either case, if you use a separate -protoc, you need to manually give the path to nanopb generator: - - protoc --plugin=protoc-gen-nanopb=nanopb/generator/protoc-gen-nanopb ... - - - -Running the tests ------------------ -If you want to perform further development of the nanopb core, or to verify -its functionality using your compiler and platform, you'll want to run the -test suite. The build rules for the test suite are implemented using Scons, -so you need to have that installed. To run the tests: - - cd tests - scons - -This will show the progress of various test cases. If the output does not -end in an error, the test cases were successful. - -Note: Mac OS X by default aliases 'clang' as 'gcc', while not actually -supporting the same command line options as gcc does. To run tests on -Mac OS X, use: "scons CC=clang CXX=clang". Same way can be used to run -tests with different compilers on any platform. diff --git a/third_party/nanopb/docs/Makefile b/third_party/nanopb/docs/Makefile deleted file mode 100644 index 0dbd97cfec3..00000000000 --- a/third_party/nanopb/docs/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -all: index.html concepts.html reference.html security.html migration.html \ - generator_flow.png - -%.png: %.svg - rsvg $< $@ - -%.html: %.rst - rst2html --stylesheet=lsr.css --link-stylesheet $< $@ - sed -i 's!!\n!' $@ diff --git a/third_party/nanopb/docs/concepts.rst b/third_party/nanopb/docs/concepts.rst deleted file mode 100644 index c43d829999e..00000000000 --- a/third_party/nanopb/docs/concepts.rst +++ /dev/null @@ -1,392 +0,0 @@ -====================== -Nanopb: Basic concepts -====================== - -.. include :: menu.rst - -The things outlined here are the underlying concepts of the nanopb design. - -.. contents:: - -Proto files -=========== -All Protocol Buffers implementations use .proto files to describe the message -format. The point of these files is to be a portable interface description -language. - -Compiling .proto files for nanopb ---------------------------------- -Nanopb uses the Google's protoc compiler to parse the .proto file, and then a -python script to generate the C header and source code from it:: - - user@host:~$ protoc -omessage.pb message.proto - user@host:~$ python ../generator/nanopb_generator.py message.pb - Writing to message.h and message.c - user@host:~$ - -Modifying generator behaviour ------------------------------ -Using generator options, you can set maximum sizes for fields in order to -allocate them statically. The preferred way to do this is to create an .options -file with the same name as your .proto file:: - - # Foo.proto - message Foo { - required string name = 1; - } - -:: - - # Foo.options - Foo.name max_size:16 - -For more information on this, see the `Proto file options`_ section in the -reference manual. - -.. _`Proto file options`: reference.html#proto-file-options - -Streams -======= - -Nanopb uses streams for accessing the data in encoded format. -The stream abstraction is very lightweight, and consists of a structure (*pb_ostream_t* or *pb_istream_t*) which contains a pointer to a callback function. - -There are a few generic rules for callback functions: - -#) Return false on IO errors. The encoding or decoding process will abort immediately. -#) Use state to store your own data, such as a file descriptor. -#) *bytes_written* and *bytes_left* are updated by pb_write and pb_read. -#) Your callback may be used with substreams. In this case *bytes_left*, *bytes_written* and *max_size* have smaller values than the original stream. Don't use these values to calculate pointers. -#) Always read or write the full requested length of data. For example, POSIX *recv()* needs the *MSG_WAITALL* parameter to accomplish this. - -Output streams --------------- - -:: - - struct _pb_ostream_t - { - bool (*callback)(pb_ostream_t *stream, const uint8_t *buf, size_t count); - void *state; - size_t max_size; - size_t bytes_written; - }; - -The *callback* for output stream may be NULL, in which case the stream simply counts the number of bytes written. In this case, *max_size* is ignored. - -Otherwise, if *bytes_written* + bytes_to_be_written is larger than *max_size*, pb_write returns false before doing anything else. If you don't want to limit the size of the stream, pass SIZE_MAX. - -**Example 1:** - -This is the way to get the size of the message without storing it anywhere:: - - Person myperson = ...; - pb_ostream_t sizestream = {0}; - pb_encode(&sizestream, Person_fields, &myperson); - printf("Encoded size is %d\n", sizestream.bytes_written); - -**Example 2:** - -Writing to stdout:: - - bool callback(pb_ostream_t *stream, const uint8_t *buf, size_t count) - { - FILE *file = (FILE*) stream->state; - return fwrite(buf, 1, count, file) == count; - } - - pb_ostream_t stdoutstream = {&callback, stdout, SIZE_MAX, 0}; - -Input streams -------------- -For input streams, there is one extra rule: - -#) You don't need to know the length of the message in advance. After getting EOF error when reading, set bytes_left to 0 and return false. Pb_decode will detect this and if the EOF was in a proper position, it will return true. - -Here is the structure:: - - struct _pb_istream_t - { - bool (*callback)(pb_istream_t *stream, uint8_t *buf, size_t count); - void *state; - size_t bytes_left; - }; - -The *callback* must always be a function pointer. *Bytes_left* is an upper limit on the number of bytes that will be read. You can use SIZE_MAX if your callback handles EOF as described above. - -**Example:** - -This function binds an input stream to stdin: - -:: - - bool callback(pb_istream_t *stream, uint8_t *buf, size_t count) - { - FILE *file = (FILE*)stream->state; - bool status; - - if (buf == NULL) - { - while (count-- && fgetc(file) != EOF); - return count == 0; - } - - status = (fread(buf, 1, count, file) == count); - - if (feof(file)) - stream->bytes_left = 0; - - return status; - } - - pb_istream_t stdinstream = {&callback, stdin, SIZE_MAX}; - -Data types -========== - -Most Protocol Buffers datatypes have directly corresponding C datatypes, such as int32 is int32_t, float is float and bool is bool. However, the variable-length datatypes are more complex: - -1) Strings, bytes and repeated fields of any type map to callback functions by default. -2) If there is a special option *(nanopb).max_size* specified in the .proto file, string maps to null-terminated char array and bytes map to a structure containing a char array and a size field. -3) If *(nanopb).type* is set to *FT_INLINE* and *(nanopb).max_size* is also set, then bytes map to an inline byte array of fixed size. -3) If there is a special option *(nanopb).max_count* specified on a repeated field, it maps to an array of whatever type is being repeated. Another field will be created for the actual number of entries stored. - -=============================================================================== ======================= - field in .proto autogenerated in .h -=============================================================================== ======================= -required string name = 1; pb_callback_t name; -required string name = 1 [(nanopb).max_size = 40]; char name[40]; -repeated string name = 1 [(nanopb).max_size = 40]; pb_callback_t name; -repeated string name = 1 [(nanopb).max_size = 40, (nanopb).max_count = 5]; | size_t name_count; - | char name[5][40]; -required bytes data = 1 [(nanopb).max_size = 40]; | typedef struct { - | size_t size; - | pb_byte_t bytes[40]; - | } Person_data_t; - | Person_data_t data; -required bytes data = 1 [(nanopb).max_size = 40, (nanopb.type) = FT_INLINE]; | pb_byte_t data[40]; -=============================================================================== ======================= - -The maximum lengths are checked in runtime. If string/bytes/array exceeds the allocated length, *pb_decode* will return false. - -Note: for the *bytes* datatype, the field length checking may not be exact. -The compiler may add some padding to the *pb_bytes_t* structure, and the nanopb runtime doesn't know how much of the structure size is padding. Therefore it uses the whole length of the structure for storing data, which is not very smart but shouldn't cause problems. In practise, this means that if you specify *(nanopb).max_size=5* on a *bytes* field, you may be able to store 6 bytes there. For the *string* field type, the length limit is exact. - -Field callbacks -=============== -When a field has dynamic length, nanopb cannot statically allocate storage for it. Instead, it allows you to handle the field in whatever way you want, using a callback function. - -The `pb_callback_t`_ structure contains a function pointer and a *void* pointer called *arg* you can use for passing data to the callback. If the function pointer is NULL, the field will be skipped. A pointer to the *arg* is passed to the function, so that it can modify it and retrieve the value. - -The actual behavior of the callback function is different in encoding and decoding modes. In encoding mode, the callback is called once and should write out everything, including field tags. In decoding mode, the callback is called repeatedly for every data item. - -.. _`pb_callback_t`: reference.html#pb-callback-t - -Encoding callbacks ------------------- -:: - - bool (*encode)(pb_ostream_t *stream, const pb_field_t *field, void * const *arg); - -When encoding, the callback should write out complete fields, including the wire type and field number tag. It can write as many or as few fields as it likes. For example, if you want to write out an array as *repeated* field, you should do it all in a single call. - -Usually you can use `pb_encode_tag_for_field`_ to encode the wire type and tag number of the field. However, if you want to encode a repeated field as a packed array, you must call `pb_encode_tag`_ instead to specify a wire type of *PB_WT_STRING*. - -If the callback is used in a submessage, it will be called multiple times during a single call to `pb_encode`_. In this case, it must produce the same amount of data every time. If the callback is directly in the main message, it is called only once. - -.. _`pb_encode`: reference.html#pb-encode -.. _`pb_encode_tag_for_field`: reference.html#pb-encode-tag-for-field -.. _`pb_encode_tag`: reference.html#pb-encode-tag - -This callback writes out a dynamically sized string:: - - bool write_string(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) - { - char *str = get_string_from_somewhere(); - if (!pb_encode_tag_for_field(stream, field)) - return false; - - return pb_encode_string(stream, (uint8_t*)str, strlen(str)); - } - -Decoding callbacks ------------------- -:: - - bool (*decode)(pb_istream_t *stream, const pb_field_t *field, void **arg); - -When decoding, the callback receives a length-limited substring that reads the contents of a single field. The field tag has already been read. For *string* and *bytes*, the length value has already been parsed, and is available at *stream->bytes_left*. - -The callback will be called multiple times for repeated fields. For packed fields, you can either read multiple values until the stream ends, or leave it to `pb_decode`_ to call your function over and over until all values have been read. - -.. _`pb_decode`: reference.html#pb-decode - -This callback reads multiple integers and prints them:: - - bool read_ints(pb_istream_t *stream, const pb_field_t *field, void **arg) - { - while (stream->bytes_left) - { - uint64_t value; - if (!pb_decode_varint(stream, &value)) - return false; - printf("%lld\n", value); - } - return true; - } - -Field description array -======================= - -For using the *pb_encode* and *pb_decode* functions, you need an array of pb_field_t constants describing the structure you wish to encode. This description is usually autogenerated from .proto file. - -For example this submessage in the Person.proto file:: - - message Person { - message PhoneNumber { - required string number = 1 [(nanopb).max_size = 40]; - optional PhoneType type = 2 [default = HOME]; - } - } - -generates this field description array for the structure *Person_PhoneNumber*:: - - const pb_field_t Person_PhoneNumber_fields[3] = { - PB_FIELD( 1, STRING , REQUIRED, STATIC, Person_PhoneNumber, number, number, 0), - PB_FIELD( 2, ENUM , OPTIONAL, STATIC, Person_PhoneNumber, type, number, &Person_PhoneNumber_type_default), - PB_LAST_FIELD - }; - -Oneof -===== -Protocol Buffers supports `oneof`_ sections. Here is an example of ``oneof`` usage:: - - message MsgType1 { - required int32 value = 1; - } - - message MsgType2 { - required bool value = 1; - } - - message MsgType3 { - required int32 value1 = 1; - required int32 value2 = 2; - } - - message MyMessage { - required uint32 uid = 1; - required uint32 pid = 2; - required uint32 utime = 3; - - oneof payload { - MsgType1 msg1 = 4; - MsgType2 msg2 = 5; - MsgType3 msg3 = 6; - } - } - -Nanopb will generate ``payload`` as a C union and add an additional field ``which_payload``:: - - typedef struct _MyMessage { - uint32_t uid; - uint32_t pid; - uint32_t utime; - pb_size_t which_payload; - union { - MsgType1 msg1; - MsgType2 msg2; - MsgType3 msg3; - } payload; - /* @@protoc_insertion_point(struct:MyMessage) */ - } MyMessage; - -``which_payload`` indicates which of the ``oneof`` fields is actually set. -The user is expected to set the filed manually using the correct field tag:: - - MyMessage msg = MyMessage_init_zero; - msg.payload.msg2.value = true; - msg.which_payload = MyMessage_msg2_tag; - -Notice that neither ``which_payload`` field nor the unused fileds in ``payload`` -will consume any space in the resulting encoded message. - -.. _`oneof`: https://developers.google.com/protocol-buffers/docs/reference/proto2-spec#oneof_and_oneof_field - -Extension fields -================ -Protocol Buffers supports a concept of `extension fields`_, which are -additional fields to a message, but defined outside the actual message. -The definition can even be in a completely separate .proto file. - -The base message is declared as extensible by keyword *extensions* in -the .proto file:: - - message MyMessage { - .. fields .. - extensions 100 to 199; - } - -For each extensible message, *nanopb_generator.py* declares an additional -callback field called *extensions*. The field and associated datatype -*pb_extension_t* forms a linked list of handlers. When an unknown field is -encountered, the decoder calls each handler in turn until either one of them -handles the field, or the list is exhausted. - -The actual extensions are declared using the *extend* keyword in the .proto, -and are in the global namespace:: - - extend MyMessage { - optional int32 myextension = 100; - } - -For each extension, *nanopb_generator.py* creates a constant of type -*pb_extension_type_t*. To link together the base message and the extension, -you have to: - -1. Allocate storage for your field, matching the datatype in the .proto. - For example, for a *int32* field, you need a *int32_t* variable to store - the value. -2. Create a *pb_extension_t* constant, with pointers to your variable and - to the generated *pb_extension_type_t*. -3. Set the *message.extensions* pointer to point to the *pb_extension_t*. - -An example of this is available in *tests/test_encode_extensions.c* and -*tests/test_decode_extensions.c*. - -.. _`extension fields`: https://developers.google.com/protocol-buffers/docs/proto#extensions - -Message framing -=============== -Protocol Buffers does not specify a method of framing the messages for transmission. -This is something that must be provided by the library user, as there is no one-size-fits-all -solution. Typical needs for a framing format are to: - -1. Encode the message length. -2. Encode the message type. -3. Perform any synchronization and error checking that may be needed depending on application. - -For example UDP packets already fullfill all the requirements, and TCP streams typically only -need a way to identify the message length and type. Lower level interfaces such as serial ports -may need a more robust frame format, such as HDLC (high-level data link control). - -Nanopb provides a few helpers to facilitate implementing framing formats: - -1. Functions *pb_encode_delimited* and *pb_decode_delimited* prefix the message data with a varint-encoded length. -2. Union messages and oneofs are supported in order to implement top-level container messages. -3. Message IDs can be specified using the *(nanopb_msgopt).msgid* option and can then be accessed from the header. - -Return values and error handling -================================ - -Most functions in nanopb return bool: *true* means success, *false* means failure. There is also some support for error messages for debugging purposes: the error messages go in *stream->errmsg*. - -The error messages help in guessing what is the underlying cause of the error. The most common error conditions are: - -1) Running out of memory, i.e. stack overflow. -2) Invalid field descriptors (would usually mean a bug in the generator). -3) IO errors in your own stream callbacks. -4) Errors that happen in your callback functions. -5) Exceeding the max_size or bytes_left of a stream. -6) Exceeding the max_size of a string or array field -7) Invalid protocol buffers binary message. diff --git a/third_party/nanopb/docs/generator_flow.svg b/third_party/nanopb/docs/generator_flow.svg deleted file mode 100644 index e30277a75f0..00000000000 --- a/third_party/nanopb/docs/generator_flow.svg +++ /dev/null @@ -1,2869 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MyMessage.proto - - - pb_encode( ); - pb_decode( ); - - - nanopb_generator.py - - - - - - - - - - - - - - - - - - MyMessage.pb.c - MyMessage.pb.h - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - c - - Nanopb library - - - - Protocol Buffersmessages - - - - - - - - - - - - - - - - - - - - - Data structures - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - User application - - - diff --git a/third_party/nanopb/docs/index.rst b/third_party/nanopb/docs/index.rst deleted file mode 100644 index afc7ee4fbfd..00000000000 --- a/third_party/nanopb/docs/index.rst +++ /dev/null @@ -1,127 +0,0 @@ -============================================= -Nanopb: Protocol Buffers with small code size -============================================= - -.. include :: menu.rst - -Nanopb is an ANSI-C library for encoding and decoding messages in Google's `Protocol Buffers`__ format with minimal requirements for RAM and code space. -It is primarily suitable for 32-bit microcontrollers. - -__ https://developers.google.com/protocol-buffers/docs/reference/overview - -Overall structure -================= - -For the runtime program, you always need *pb.h* for type declarations. -Depending on whether you want to encode, decode, or both, you also need *pb_encode.h/c* or *pb_decode.h/c*. - -The high-level encoding and decoding functions take an array of *pb_field_t* structures, which describes the fields of a message structure. Usually you want these autogenerated from a *.proto* file. The tool script *nanopb_generator.py* accomplishes this. - -.. image:: generator_flow.png - -So a typical project might include these files: - -1) Nanopb runtime library: - - pb.h - - pb_common.h and pb_common.c (always needed) - - pb_decode.h and pb_decode.c (needed for decoding messages) - - pb_encode.h and pb_encode.c (needed for encoding messages) -2) Protocol description (you can have many): - - person.proto (just an example) - - person.pb.c (autogenerated, contains initializers for const arrays) - - person.pb.h (autogenerated, contains type declarations) - -Features and limitations -======================== - -**Features** - -#) Pure C runtime -#) Small code size (2–10 kB depending on processor, plus any message definitions) -#) Small ram usage (typically ~300 bytes, plus any message structs) -#) Allows specifying maximum size for strings and arrays, so that they can be allocated statically. -#) No malloc needed: everything can be allocated statically or on the stack. Optional malloc support available. -#) You can use either encoder or decoder alone to cut the code size in half. -#) Support for most protobuf features, including: all data types, nested submessages, default values, repeated and optional fields, oneofs, packed arrays, extension fields. -#) Callback mechanism for handling messages larger than can fit in available RAM. -#) Extensive set of tests. - -**Limitations** - -#) Some speed has been sacrificed for code size. -#) Encoding is focused on writing to streams. For memory buffers only it could be made more efficient. -#) The deprecated Protocol Buffers feature called "groups" is not supported. -#) Fields in the generated structs are ordered by the tag number, instead of the natural ordering in .proto file. -#) Unknown fields are not preserved when decoding and re-encoding a message. -#) Reflection (runtime introspection) is not supported. E.g. you can't request a field by giving its name in a string. -#) Numeric arrays are always encoded as packed, even if not marked as packed in .proto. -#) Cyclic references between messages are supported only in callback and malloc mode. - -Getting started -=============== - -For starters, consider this simple message:: - - message Example { - required int32 value = 1; - } - -Save this in *message.proto* and compile it:: - - user@host:~$ protoc -omessage.pb message.proto - user@host:~$ python nanopb/generator/nanopb_generator.py message.pb - -You should now have in *message.pb.h*:: - - typedef struct { - int32_t value; - } Example; - - extern const pb_field_t Example_fields[2]; - -Now in your main program do this to encode a message:: - - Example mymessage = {42}; - uint8_t buffer[10]; - pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - pb_encode(&stream, Example_fields, &mymessage); - -After that, buffer will contain the encoded message. -The number of bytes in the message is stored in *stream.bytes_written*. -You can feed the message to *protoc --decode=Example message.proto* to verify its validity. - -For a complete example of the simple case, see *example/simple.c*. -For a more complex example with network interface, see the *example/network_server* subdirectory. - -Compiler requirements -===================== -Nanopb should compile with most ansi-C compatible compilers. It however -requires a few header files to be available: - -#) *string.h*, with these functions: *strlen*, *memcpy*, *memset* -#) *stdint.h*, for definitions of *int32_t* etc. -#) *stddef.h*, for definition of *size_t* -#) *stdbool.h*, for definition of *bool* - -If these header files do not come with your compiler, you can use the -file *extra/pb_syshdr.h* instead. It contains an example of how to provide -the dependencies. You may have to edit it a bit to suit your custom platform. - -To use the pb_syshdr.h, define *PB_SYSTEM_HEADER* as *"pb_syshdr.h"* (including the quotes). -Similarly, you can provide a custom include file, which should provide all the dependencies -listed above. - -Running the test cases -====================== -Extensive unittests and test cases are included under the *tests* folder. - -To build the tests, you will need the `scons`__ build system. The tests should -be runnable on most platforms. Windows and Linux builds are regularly tested. - -__ http://www.scons.org/ - -In addition to the build system, you will also need a working Google Protocol -Buffers *protoc* compiler, and the Python bindings for Protocol Buffers. On -Debian-based systems, install the following packages: *protobuf-compiler*, -*python-protobuf* and *libprotobuf-dev*. - diff --git a/third_party/nanopb/docs/logo/logo.png b/third_party/nanopb/docs/logo/logo.png deleted file mode 100644 index 0d9534fa165cda53a29a848848c2e0a4c5ead3e5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14973 zcmZvDby!qi)b$-g1`ruKM7pF?x`siz1f)X&LApBz1PMv$F6kIRLK;QMpEL|2DIne5 z@AZA3@4s&zhGBSS?m1`QefC~^t$m`jG!zN&sPO;*AW&99yZ~Rj|2?4(z~3+C9B{xF zEO)rFE);wOK&>Ld_qZ-fhVB3$V*2k1p+Y_f{{W~w6bw9coZonOzjCt%yuH17-a6U4 zTfTC!=5cnj$=Z{o1^{|M86l_Zlf4`0n{J}ea(Atlv+(BQz&GZk3@$;ECRsQJw8n?G z3>V7mzzD@KBhu=|kB;6@Fw~Wm`_5Ttf*89{GqGrV8fYGnhxQ{C0GmpZb25 zR=7Ctf9G@Vgyx+AzLt`-d09%#e`lJcCS0?hGiCx7oJjTT<2WVeqf}TSiLAG=v9auX z0GpDNtY39RKVJRu#NJQ3;PbY{9G?-X^MC*s7nh6`(TFcK#%y8qz4ZYMgRErmRS~pj zL3>`0*di%jIBhI~vCAr^0|sO4HXzA2DX@9J{pDzo^Ko9_*{}H1^K-hS0jmX;FenL8 z7|bF@4w^_20QkQ0HWleY576(|aaBg}pZTzpUJ_k(5Ma(AF@nHc|)Q9Z?PG*jc+)Xr5)yQ0)N z6V`gW2+bq&AC%Y1pjApT=~%lj5RFhRm9;VKJWlisD(JLwzAt zI*x8u45eho(02X5RCwX7-!K(yUp2%ZU2A6qABJ-Th(Wfl9Rcv_y^-cpHS%xCs zzn7+nLKtw7%Y#2c)C$bRa-uZP*-1mK4M(RKT9nV(fT9qS`laYs+{czNYq;#j1s>v3 z+=)t(pIw%}-BZuA;qm2aE8|;4|JKGf*YiC3-H0}8JGYFN@?t~YGA2Ud1+Z_+E^Y`v__7@)bLx zxv}v!)V(u}G|2Q65-riF3u$)zodi^HSiJ}t^wsBWla*#7{~-0saC$s{aVaNctU}hT zu`3GeA<%W$``89$(sJbW^u{fzv8%PbMl(MFb`?|=da0|YI?t9gz!JAIC(TMoP&=W` z{a99tm+|ZIhzwoZ{oQr&8^f1H6^p7*%=h%3n1`EjX6e$*{}7|@_dj(jtH^+1L?QlU zhvQQOy_zJ%<8$JpChONcN6%*mSXj_|{KwyS^WAfv1YC7uVx_kiB)l_7@5iA|aQjJc zMqcZA=v`YH$ExTf(RB@V^`CX1pZmT3M90^CA;-dv)OU!#dTiX}@QXq)<3HT-nbV2$ zH8Tov(=VR-rD;PG9(&lRYY#m&;^`*GTs78x(+1nIPU|2PumZE>=T^ym*hlNXGxodL z`94&+OF!_&tg*^2Ak)sD1Xs;Yi=`q_1FLbTT(^QJLruEVcC2t#McM#q8j(nxpWGw0 zhcMo-*Z#~V*c30iHu&YK*&$Mb)a>Ua;RjYpYT`6p#@(g`EYWyx+TN3S>Jv8K} zg>;QboCSgw=!82X=v==OQ4kUm26NIpVxo>^qsc8XY)XUdn z(x7y z0;w-gmca3u^g`O-yzU>FskNJ`KoO5I8@6pfuX6m|tFG^_d#ZR2Y&N=d^6Bk76kOX> zc%ZytCEz<3ijDt>_Ou6c$3u4w7fsFr30Tc19P^_79N=LrzG4gbo;JfQ5eZJH6RiTu09nJdl z+rmvXf66dQx32|aH^0#MY~BZ9ooxHNm{JG}3vZ*VjnU$T;PqT=FwS z_wA~fn(4pwI4{u+JPF}pwWKIhyNKnr)^Z+f#9s9k&v6pl$bWZ+`oahC!mIfEpkpOY zVySiS^=+#;`#b%BF0a3j5v7t5D*>g_2^(GAd_aOg?=ei!|7_gJ?taNwRYhT`QDUGuYQ3;>(Zo0=T^74n2HK5 zTI|qg#knYH^vI*peMo+Vyt|iC0cH%fo?vK{t%?(&g~wR>m6=Qpxmtx@OD-Ksowp12 z`ppzRZT?mn9wd^T*+1BtfQSFZ^4LC=s!zF05mC_ToeAfdP)RtU7MZRBHeN(elGwVZ zpU>wgn7BuZO_g@dsK2QQZs*-Fu+-|bqT!PRkQH)Zl~q>Shx~zjWJ=V)fqurva$wDIZ*aoozJ z{>it0Hwz9hQcq-zb8#B0{ceI-4S+j{Pe>>XmxOgSitoh*Zs${>o=;c(w>1twFk)!+ z7?3NXk9$=BFphH#4H5=UdLHclZtiiVK@@2lq^>Dr$&7rg*effTvD^8Wwud_R8WM`B z%dH5C1S~@!@1N788MYpqnXKOkMTV4LPLufgXb_N6MDBsdpRf^+(bwyBRDu$vSDI znZ7AFuLlnvBn()=VxJSmK0iJt^yRMpguZecvJ%Mc;Z?s2YE(1&Z=xw$Mi$Ahs0XDF zbFmrD{>2-Xt{Z#9JPA2HG9WYY<#7zP62L`!CJtB~367Re@N991=z3aJqqc5JXw7}| zT0!h0V_k@dgBn*{a%030RJ3TgpkS{xgdHK}{;Eor24rea%ShNX5a#CQ3tHriZEi7d z&)!~Uaon^H7D@L_ZUO9eiIZepQMNi$(g-BKyfE&lBXP2dE<*=->SvV=j+nW=*ZiMe zlw)Yd{ipaOqlBcJbJDQ$o$`fVdZZj8rzq&~-@ai2EO!(Dy2N$XWf9zXI=N32&+)3O zOg)MF+wJY`@uBn+%F8e18#|^+6MQerWv(O!1qN@phlmj;CM}CR-8J%4q01)d4ppn= za(KGM3&F`*Q@n<9mIR&3A#PHlUw#;iiC#w1?% zWE|o}T_G+ZL?l&%E)gFj5@L}NgE(r_#7(YGDLh-v#Psy^^nItF7vIl(Q6i95bX~cY zd`fLvm z=*(y?b$A4$ytQ`Iwb&c1=UY7;nQpxxUIY~?NP@@D+IL#_9?Z+@)MPHBIY3JnD!Yb+ z8a2zZL?aj#&X8zEzhVc#@azRWqd_WJ73Js01+&~h`R6w^kr!yOn@j6$aFPXGW--5FCiX4p=(y#bx+{V7KGI|Bo^7)2pd%s5_IwHyfMd-H@20#g zNnbZU;Xh8H{0!Z#p4%^g&RyaA5nCg`^D!;$bAb%5t)1~}99_nKmrXZEAirUcS7fLj z3>>S@``8EP14(RoGUSWTWIeS9CL=p%Z1Mv8U9&~PVAmPb7!NqI9)$D1f2vbLiq%@a zf_(y8pUcjf=?s*3|Ni~a=1JxP>S4uT(V09LPneUGrD%+RFCwIPIVACYN!A^@$ecKS zCIHy^JRcDtyKvvuh0_D8E$*g*4hdhOj3_;B9!){fg3@C zhq!6OMRV&@Uuz)Xb7|>%E1tA9lEbnTW^s3O2^L`oEPbwzAphxnN-K)<$-!qB9UVnx zW@bv_>OyoaLq3T!kE|Suj&C-g(iG{ghs656N09{2qS0)WmK0j#zWSA&Xx*-B?xCyI zCdc0xZ5A{Zr7!?EoA+LPJ7DG3xZSES@!r3MMwM#7?^jl4ChWrxyj066<@_`Dp<~D2 zO$e!kO2*%4084z;m!y|jbVY>nybRq6x2EbDB)zy_{?}j@LJBdUr0Mvrl zPa$DdGx#oMUWwnTe~*;Zk6KcQ)a3||i+l8G;;p4~-GUBRe9tmpiDsS|AJiO9c4xqK zrp8X1iT?FVtg1wrH3=ma=bo_L8eg^#_{4`Y6?Q~!5Kfe+w-s*DiOc?)dCQRyt?+?d z!O!2HPNVn*9ppxjp4Yr%Q(8G4Oj<%BA{5mxo<_VBkJCXA|87cDDXs-A7Rrz;)~KkK z&bQoDQ&aOnrNbCB8#-#ku9s3j_6-okF?I{CE(t{Dggc=*F{W@JO3eN5T(%N34-q_} zh9~{GeMa1r{gzY`tNOPp!_U!B`fyG2WMdXNN!pPS89T$5Z@z`$QuMAIN(=^~W@l#! ziN>6%Ed9%wwTww{6{h^c`I{VmH#vrw){@kz;sO9SH+LR2Ep6vi(=K&>0&wJp-XtDOCI?o#gQ>1k#qj+&t9t5f?{gWqhfnqOk?;P8F2TnAr? zzC#R%!Rp_Qpy~7VR#fb>FA79~)*BWx*Fe~8Fpo|#Vp9Q&b4`xMqvo|Fd^}M4x)JH? zhKB?Mw~~oUH>E40pPC=ALe4)EF@tW;=XZJ;e7Rk0gxlKrn+>-QC@F^H9piaAGJmG&Oa4+uCl}fCZbZ=SkY0;h{kEsU?su z=FYmcwH57v@ymQk4wz}0UlScx6c-nNsduCSW~5Tsm?=Vc8%>x?1&`DLE7>y-mXSvmym(06`D`;%Q|EY1kM<<=F!c^bd!9ErwoSQai}xDv5;?w! z=}TYn~{kVdb00| z4ws5cNbJ`%(CCz?wd6*27CxBpZBa>qqVvH0`1SA4tQ?g*ItxM;008e=ujqQb%W(V) z-27%NyD#D6)X+ZH&goyjd;^Qu(j|S5ej!eDdJS}0kX-NfS_V_L`O%)5yE{8H6(^Ve z;%5dJfGmiJK!S;X_%e8dIib-x3L-88n&A&<99`YVni&FXw}=ye#>^70>2j~=S1&&V zx74&X6ct&zTbsWc>7`W%09!}LoNlq;Z1+1z2id4{J_!SwQSy)I@LRAxFE4xcFB3Qb zny@j+oR}BFIusZEo{zj*Yy1O>d1j@kB!sCwBnvw_0!N#6<7b<02~pM`KOJluYbeF9 zWXnv<%oqp_zhd6l-QD$|SvLiabT}&tW?H2Z{O=rwFU_;EvfeGH7JaAH1OS7spj!}z ze*o(`4Z@ zVB_gF?1MMO*T%+1_)Zst-tGFujAJ-EJ@S2OYAWCQ4LbW+r#)=gSu1Wu^l6{#@GlTH zNTsA&U!833|IL=^r_3r)Y}h)cS8lG}Zar_Q@%K_xRD4YuU*+NWdtM_QgG{OC>U4V| zZYBH8?=#a@aos`Ien+C-nRx;N0`r;%u0x+2g+AAX-Bzcpx9_F8%Tfbl-0vo{#oSBM zE-7C;L)ou>P8qZ}VX}otj?T@gWgpYI4f8(peGQP7%Rgw`=!;vq0l8&w1*h@NiBiq~ zPHE_RgwbWQ&IJT?j@~ruGjVZoA`cBSu_iwq`QX;)jc#F5--m9uDiV*8GFD(}VbbpqHKZ-BKYQGr0DCP99aBW`zK0jk)tGk$ z&7BxyVX>2dbPI*+@O>KpbHD%M#I^bqpZE>AW?TCE`!7~CaK*;Pmbwn_zm8Ejc_i4# zqP3C{21A4J$-LUia`Ki?=H}qtzreM)>2alm_RONR{G`FMLe^LjgxN&^MA~v9OSy+y zKQ}df~)^`IK|aMqjPY5{4a%4 zVqkyJs;OL;|2a0#r+$6()druOOSHAC>s~NJ?QbAh##X*>H1W{-C<|xl+Pn?<(}-Rb z&UltK@*BuyDr^I{{JwFAU!&<}GZiidMhpye`cjwS;GdNESpi4lxDUDI#$B^NUteAA z{ol~nuETWJF}u|tyX&hkJeB5wo3+4w|HY?6X}pV_Aieoxetur2*3sX&@731RzE#W z-=&+m`J#GCYH?kit5FSVDR3*y-0nVH{HuXe7i*#tGss}c36L6-1^oJ`w5*Q{>=@9g zli8h80h2HLW-!uAI<%WaA~))r7yP!zRJt^uf}^lxW@S;h4AWW0{5+b7QvIUr>`Aje z9ug7~oq5~a+goOB*tMFSS4aY`tG!!1?p;9v12ge2X#vmdkk+)uV36TuCLUx zR7}GAbZ(q%&$&9@C5y;22kDkBj!WqvC{zmqj$$LwOKTm&t-A|JdR0{^KX_;kF6g4W zyL%ch8cry60&BbY^Py{q^16`Y=EW0g8k+A*OBS606$C~2GV7A&$BISTV7U|ua^0>c z8shJEwS_#UR0+oQ*crk&!+av$?=Bnd(OxePV*jJ#p_jEz7qroMVz~q9or&=D?2pGX zvakK&Ij@8B;6X0k^2%wh(N4$t0tFs})8A}&L;Lgdb0!d~hHGzh%(y)a&E^#*j-scI z{hL-WE-$Cco5XX%ijf{>w&?$h2p$OmY#N)JWempXN`kwQK#JvXwirY2OioOl=GIn1 z#dT^ezChfH$um*Wi!N*FCZ&tDLy(<|Q!Rec#auZ1_3PJ<%a2*-Wxx^0KdkA|cQhMv zcbTv#2GX^lv5jt7IjGdop1&2K%TR_IJ7?$nY1{kC!gxwpzMrj=)7>-69ecB9AvJ7S zI~ZusU@#l{Mj^gcuFsGLGpz`wOD=jZ20A~cq!i7H>?aj}^&-S-m)9OduJ2t$O&UhO zC?7NqVB#%koS&kJ8%_Ab@IFgUHle7SUWkw=>Goe)8s> zY3;0Qc2d&7su8!p&X-V9Ka6e=(q0yT1SyDKBvT_}I(~q1L5~|HInuU zGHJe3`ioJ=@|^mpnJuMAwXJ?sJu~{^vOEOhG0|V|Dm88k>4w~eb1JS?PZiZIsY^D| z@?49}CS`G0UCs!^2NSeomW21-GSg+S2k73I9v&W&JEFshHQT*<^ZMaeeOtjU8l$ZI zy|gh1Mzm2X3-*%(sLtJZTBp$Ig8%+)spD^K%jk}0Bt*I+@h5jm6lG@8^GTn&(j;jK zP9)nqNsteKk)Jsd=Q7Vv>9IIQ(_f$M{Bn=lU|1EI2Eo|EwI$w#PHBoh1)b2(dPhF1<3-td|F2e$ zDcjYgV(Q+3q-wM4r+e*Dj2H$G@hrNTo_D|_aXNGvTFxsr-M;ys92^`BffZszVeOd> zU;xH`RPn)exnxQ1Yu}%ruFBr33%8ZO*IyjtHEJ;NX?&0=-jKH4s!8k84N0sQ9A=>J zru~v!i-q?W%)hI60QtNZHc*m!$ zqF#~=Nu!dEN4(zawptHx|AOCGj1^i$0uqp{XO6@BNV=p><5!Itg-C1YA z)m84KneXDKBr|Vb)4>(2FY)bp<-PycRYtvBwlJ7Yb93{3eRg{&xdodgSh1m^cUr$` zUin7cOfn3MnV@qP=jTm9@iD;OSBJJ@G ziu-4uH;?2iM;D{9rC}&d4(>hd%Ma3chX3TRrd6f{1C#Io6RryazVl z{6ShllikxCyjTo)vHNk)d8RN}&YE9@2P2FKtl0SY__Sabe~XWYGR>l(fzSP~np(Cf5vV9!(wceN7Lf)~trWG2clZ@fQ7>-K6-7MD^A?_> zPm+3dr6H#0WY0{Tar-yRnVL!Q9l6B~68PTs$aF*yR5x+dirN9- z{_eahFZ#!8&5G960lw+=eOFTv=LU>$dBNh*%HHbPqRJ+$l9ylYN81LrSJrSVNX=G{ zd>33xKBR8GMjm3LJr|!uA&$0UJv=e`@q?L(A(mCLUCoYmx%K%pQ$4= z9!*nhjOadsp#*!K6Wf*p#zg)2&kXZ7hM(W4&wg>W?DCVM@4i5abGJy60~_B-G#xBr z8eN8u-|rk8@PX6-KpMtf$<#(^3Ccy~x_Ds0ZwFN{n;Mf+-Wq*ApD$c4%u3wvFPQO= zI0_4_rfaPRh^tK7$a8Y0GN!)kvhx0xSGEDcKLc`mvK@qDGNk`aborfbX$tm!+4+iH zZ;w;@qP+cDdv|S$Neq<94h~%II**4X2*CpJP{@qMYI}5I;$2M*&-WEqhlO@3&X-k4 zFwT!8p0g6;f?Ur(TF__2f8kwGoH$;@6EDh0sQKlf{&RIe#@kNp8>)SK01D-EDrmyE zw2xb%;SD^ipHRsK8DvJ{4XNJxXBwVSJovvn8M?kF-X>pT2xVVdfPq^M zQHDY(3Q==kNTsMOhf|n!PiV@-+T{8^5TGOkKxpK8I;C&9(C&-fduH%;v3L1D$L z4i9<=gQ;Z=%#wv$PcE|xMb#6;gT!+{n)g5NEy>18n4nu12K%ztx;;8Q{nBM* zEzLac*JqpcAp~Nksk(5}54b?z73^W2gj=m_fIaW&n`&AI8`89zXq3uFJ6~&l#>uMZCdD>4%e^X~q(rR`7HPY(WUG zL_HH0PTAS`c=@|2hj11|lh_MfUH(&+yeUekOM*|#XitiPqzeBK_G>aFsCLR0GI9%o z0368Rx(y38ig)cF1ESa;F1Y|WnCUnc(C$ir76yN)rzIqZXspoMEa-zr-q`YVWsX?U zt1=99^u$Hjol}r19dalzhU*;kH{#q_{C@UvfEnDPe@F7-Q&Y*+vYruu3BaJyjtsmD zuqXuHpak((UhBu~`>n9wyr$>@Eg|0lvh@J)8qy21H@D zjqS*lGqC@l7W!**ALwQ+d<2|heldj>Xwp>vJ!AlEFfIV(K0ZTqZ^Ykm6X=o;Z903#{3hUMd&?I9m@W{TQpE^H4@{nz6auT5{mjLJV_np}E z=$vLN4DcukyDC*>Ec1o1XI_10zS$Cf>%Y_C{q+<1#?H=3&T|mRDzR*G5$2u!HW=&0<^KDaK~BP<+n6u*_!9~Oh|dRv^xtWcbB~@ zhqa>?;0g$6nG|&Moy7R^usaPpqU*87_BjV%mJQNDU`o&W|0+&`uAS#f&lVbA~OfSPRZ-AyPN6J#j_hxR}(1iXKp zhq2B}U{+)IOZ^V+{vaB+eugh6Sl_>J|H2rEb4U><{rpInZ8u%`vUQii;v}#li zF$CODcasD97+)wQ>~?u!V~z00-5^5xLU}+EBcI>99J9L)9;u%qqzM?{BQbq?O0C5x zB*KEB-FeB9a9|H`dATR`?C;=*IVpYm-)27F_vfF(;;;rG~8jLxZNT^*;UtmC_VyglwwOD3j#zn z$$|*n%16k7ywf3(v~!z=UnsvqJx7Pbg+*uDET5=1U@H5PvWR&C3>&5ON*DV&EN%x^F# zOk5zKkWIe`ieJn2=GR6GLoBGYHeag4!Sig^<0nrcW-z$Nn)KdX|JI5O<^dH$m^^|A zpwk=g+Ool1wVPP4mCt_<$z}|jDJ-s(YkHG*P~mikDcj+e>s%eVvEAZ*SqA$vFt=7b zBgX;w43t)ZIe{GcFwR#Nx-4>SkmlC@o$X2FhLDvp3mLhV=&xiCO+1F9YGlmmnBHU0 z$+V{xIx?yM%bIU*Ya1JXpb~tulpz1;YrXZ5%k^&a%5nr<@2iL>shVweQyeB9V+tFa zn}_~VKsP8k#R}U`la?tbXSG`Y%oP3t@&))|K49JyJsFjcy=pK2d+rv#b-p%y91gmA zq%9FJHS5dg-9c-ZvWCkLCcbsY)W5Y)%zM2mg>PsoRb_IQ4f`W3fAkqp8+g(N`!{Cku8q<3s#K_3k{Y@Tqb1aVyI~EBSb>q%YRS<}4#@_-tMP^_# zLB|zaWiG96&B#j8IaL|j<94pHw-d}nF=!T0bUOGKJ)+ohyQ9fC2jdRS+q|mzt7$k7 z202mr)zt(bFV#y1Ogf|KR z*`IP`YzC7fxq$e>TKzpIhVO3jvoIuzJ?)Mq%;$GPT*G=7eb@#=p*Q3Ues>DEvp6>G zwG9LbF$~^v@FMLY|LG6!Q@|aLl<*n-M3587suPmq3XnPcB{2rX*Z+Fqks|JIk1z=H zyC<0JeajzQ`l?R`VaUvRqD?opw}%L8m6?etK`mF37UW@Z{v7&*i0kp(=raGx>Ik@W zGYP&uy}XOVB$U(|ekaaIR;J5|L*K>h_!NUnC(fJ%Ud2#YnRuE>!$T_5EO$TLy~IDb zJZnNr+ygdHk>x@7^u>bzW13$EGLw(5qiivdZ4gP0u+hpU%i5ynILL@F*i)$q6Prne z*|is(VhfSqM*jx;e`=#L)EpPM#rfT&KXeg1WzK6a?#nZu$DyoSkanK@0aTI6?a_XI z=|hZTO8Flz^X_kKz2lbd$_(65t#=%?H?A@3nQ(G$qhHZV-|Bj|## zQ0x9K3063gu#aUmpTp6~7RGKg&s6GXQf?aby{KQInhZ(D$QhX@@CiMY=Pz}1EAF*% zE8B#9WHKUxjz5&!J+hN;ok$RlyH|yd72GeN(P*YHr2%qTzfgd*OtRif$kQ&?yDU_t zC91;;RU5;jr@YUyQ)EjuJ%A}APKU~o!Cy)P_DJFBc3!5phs0&qwLR*%Ko;QhbMwx3 z=im{1+T<4Nw-cv&x8~Dhuru?>cc5=Kji(y2_mR#I`Y>z zPw(iU3_<%TiLloOcnxXMMUMg!*ZsH+29G~;=BFv7I&V)`Up_Sg-BvPu9sxzY?9M0t z%gHQ*QN~H?B=>UB8weO<>QF&GL>9`VMru58Y4ExfXF!Z)ei2)4Gikd?=L<7{jd|Dh zBw+!Z37+x`^kElS1yyty`NJf~3G5zeDp`Nh*oDSJs+-oz%>){qmL`WHx8Sc2{`lPr5W!=( z+e*A+-)-+Ml0yh4>hb43FUUHgTO^D7)?I);e1=xlRZPHii>`e5dx`w+ z(+APY^_=W;Tcs2rg#jnUrg!SQ8G&ZdG1RB5_f<=GWZg8Ref8J_ht|eQ+_p}A^4!lc zLscgqZ&Nrwk6PC;J`UFmqdZmT5n6HyiJ72L3X0wbe?IWO?s-q3ARZ(J&h_E#ZIo?C zX2}Nrs)uyHh)`N zXlY)MIEbV`(0h=zc+>m&ugH_i5y2GsQ2sOHQxP4q1E(G68_arXosqRSk!9H7dn3VX zHTw}&=S4)_iLVv=#$=Kk?AD2a8>nH2e@6cqf0^)Urb*{SqF(WtLet`_y4;BVaC;wF ziY2n-AD8`pK6}rbia&lK54Rh=R?B$tto>?uZnLPrLd!UT<;EFkA5sh#Dl9E6HE$x1 zskExuFMiCxT(NZFgfCdcipfzp^S&}enm03SZ0Xy5;$AsZf8DoXN*Iam0mCQ(9P;xkK zSr@mGIIyDY-3LxEeJJWXW>E|hKv~6ch>(!be;}c=?Msf$KveH68;A1}HDthmYq*^U zDuG}n$w1Cy5^2Eorh)K9IjNc7CX0u+_e$sWp1h)>wu~u}hnO1;>o?=<$Dobv}o$ z!{7x0)u8U{2P$tx1qBe0?CcpGh0z9{Xx|*h2O}60`S991X)|i>l*-^J?li2SdZ)d; zJsy{pET{{1eQxF{5XAk^Nt48_@lQtoRfjVLyox>XPQJf_kKgL_Krx(LEK@LY1l|N|#miHfGERPtL|E`^8cA8Da)Q!wZWtn_~JQw7UT`{ar^n*~KH$m}Py2j5&aF%0#K^|kvR*WTYeu7y76P)#=gq4bB^XM%Klx` z-kB;;2K}bA!hbb_p-Ti(@^^CVq^$_NR*nNue_K&9$y+PoR(v@r)EZP%$?4~~x4wHw z95ny;@C7!Nibt&_y8;hM+t_S(1aUQI_m*_u# zMs*K#QwlyZ!81b6V}TV2uiG#on&KO+I-9<*c&|#!;~|!iC?E*k-d|QJWu%($CwqT> zYD$mv8?9PgTUK||E-zniE(x3uHH$LQ{XEX8zXrBx?rS_HP7gEJ4_vK-Nj&dSHc0h! zmZTMlTZDq6K;8fT=li|B%JNi?u~NGzZLnu#W-7kJE?5UAl>%37f!6fGy5-g`xOWC1 z687@;e!On`Z*tHkNAp3-Yd&OT)vi^nKCYEn5WC`9qCf9cUp!E3cl)9`*XX)(@tyl! zl8@w`n4IA##?Bj1RvYFOU0*L-$hT|6koC2UP!HveS7f>|L#t3NKhV_t+PswQeR_8G z3`)m92#)d))LVxT9>kVa8gXeUw-{?sR2ao86<>d~_2L*)-X65G%!_68BAdRP$u`@K zEI3ALItcS)vyX>PQvMWEYsIMu8pY`DQbiqXZ=S3xZ%79N3Z22jzW(0c=W~Tw!dTqh zP9XbscnUVnBtaS~zU7}isHDWDYCjr1KB~N(a_3z>i{2BOx+8c|Sx*<;!pu)^-G|M$H#ZHn1`qUzU`tPsB_$<`BxAVZU_;)F?uW{QB+M?! zL9!s!qKXtK00oG5wu-IefHQIHHQMi&q3_;{zq;}Rk4B(?+U`j_rB{__$DEa8rsPMiryf)4YET5c{ar!x$v6{}2o=Lj1iif%He|5)JK2S}HTQajK12 zC6*I{dg*q7fL}n@%}?BL__{OLHKgJ0bO(hVJc7&1%i~)|r2e%znV!!qK3k)Sw=#G7 zP?S2QxvPy5>?O`V#s>?5U#iArQiAl|68Ji$8nN$tmKDQcS0?J%-^zN4H@nKO-B2k> z@tZUUO@YWyL|a+<7CohFPi4SJ*Tw@bxG z7aRAL;jsH(6B9aal=cHQI9NXGg#`u6pqxM$2HR>^R^W(^!YU#Z@>C+uAhA^oZxcg}bQbN#8;fO#_N(*>?wNV(mWBrD5_ioWlZO+V9vGz&YH3OGnbGAZ!uo3eFJpA?? zJje$H<1G$jmp=IMe=UN> z50}W%p6hZ+A#OYG-170-!bm+D|Dq=Vz_KdM{q7dT9Q(Se=yN#uc}no}*U7LyMrcnP z$U=39k^gpA8h#E`!2DFCcLr>tS%3HLUD_i;!t0t}Cfrz9Gd*$$U32r`8rUCDNG2qM zPeR^+p2!!yzS;M7_%aJ|QoAB5at1#979<})p)h(v#zL^MHXCaxfZ_Xc&9(+amSyj$ zC~pLNOdS?chYI2xy!c|K60;;ub-XYJ2G#+>)O0>E`&cy`7JXU0Hj5_;Q#;t diff --git a/third_party/nanopb/docs/logo/logo.svg b/third_party/nanopb/docs/logo/logo.svg deleted file mode 100644 index 91ab28b6780..00000000000 --- a/third_party/nanopb/docs/logo/logo.svg +++ /dev/null @@ -1,1470 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - Pb - Pb - - - - - - - - - - - - - - - - - - nano - nano - - - - - diff --git a/third_party/nanopb/docs/logo/logo16px.png b/third_party/nanopb/docs/logo/logo16px.png deleted file mode 100644 index 8db0e2ef3f472f50b2c0b9ee4c545453f865ad2c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 854 zcmV-c1F8IpP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L017Dp017DqCuavK00007bV*G`2iyS# z5(76cq%NcY00P!YL_t(I%UzN`Xe?C}#=m>#&fb}woynSPOtNmWEG%KgLhvbA2sW_` zcELhIDpQz7o}eJeLLgQ?tZZDcu(nV6NcAkN0)pvGB*kWjgk*MS=Fa_dY_dz92Tpg+ zcfQ{_hcy}vktB&rl7zI@0szXg{4|c^@1>L-Yc0)YvwyVK7o78-FE1}&;Ysi;%goWy z5tU`R1mIg^%&SJD@%z@+*1Ib!D=SeHwc-{koVa;ZfE2X~bbUH7RB*D_s z61KOuQ4|HzG{x=hE%H2vwRU0KT8rs)`qS0b)pK5})s{Wa8>DH9<>h7c`+XEefxEjq zWLbu)s^FZ%YuubeN_n)ox%m+f!|=0uz5Yd#B$%T)=b*L5!@~nO=NJx$i)JE%wHDUe zT2)ow2qDDo#>NJeQn{F5Ezfg&|0I_YP}|4jDb=L#+Y|F=llbu6gcP5 zTI1~O3`!~N?d_r4?P4?Yse;?LbR8=(>c#9ijxYiohS`ZPObI9`?qtOVb zr>D5TzsGbs#mUJDdc7XB)=)~#cf&+gRsTvU-yk9Y0AmdGdL4&{hX8=p)z!tsvMd*A zt%VRG86&PdiJnw?F+wBjd zD0(S`2=Kp{BWbNsmL-a!fKm!X1SzHUeg6|iMCf!nFM=R=PDGfa%+G0zSs+wZ1tNm) z`v`*Ix5;F3z=#NpG1hLk|0JUKoO6rGkN1W#X7Nly2n0cJk*4X}L`3}2DqUY+KeN{U zVy)Fr7p9bga}J*8K}u=DF#L5gnGERBDtl@f0M^&nKh|1*XN(zGYu^L_&+~4C5Pu6H gei)C(XHV<@1J&fBKi_@Vod5s;07*qoM6N<$g0TRKQUCw| diff --git a/third_party/nanopb/docs/logo/logo48px.png b/third_party/nanopb/docs/logo/logo48px.png deleted file mode 100644 index b598c01186356d10ef4d4959690d0f792556ca9c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2577 zcmV+s3hwoZP)Px#24YJ`L;wH)0002_L%V+f000SaNLh0L01ejw01ejxLMWSf00007bV*G`2iyS# z5ikgE@7VAF011&vL_t(&-sM_-j2vYd|2^}uGqZcUz1!Q{-q(6uOCixldQCt%N-IGG z3LM4i1;R%V>S0qfVk4F0Dosd>^-?W~wW4T3BA6Hw#MmkY5kCl32(|*2_6&FJ-L~7i z>v6X?yE|X+JpSR#X6|T{M!nk_pJbBF%$u3#_rAa9dCkVjy%}yX&sI zt{NU5-c3Z8c%BExao~9#eBTE%!}GiXGjBY4^yn`x1OVa8tH+KVOK#er*<#fpQeRH{qUGys6>y0C2OZ zno&rW*XGxMMbe@P%EEdtw(11)P1Iw~7Gc!}oK6B$k*YyK6TYO zbw)kUgJoH;EDMQ50@-Z#L#Z_cKtygLk$Ab*?erI2*L7Uih2uEYLN-1=4rWF&nM7k_ zV>SDP&P$R6MN!mzKL30wm1?XRfWg7Rw_Ml#o@H6EZ5x$J1?6%X)6>&9b?Ov|24RSvxW^ zQmF}mvsqhPTfDBW?xlD<-tGH7Ow%lsN~PNhg~GvbOgf!@TvgSF6N!Wb;7_jW-a0Ze zGP#hO`g2-7pD#~NPTpXe<|{!EHyeiWyQZe5JHs)Plar4y^Ubd7PAZDBO4s$*T3T8z zI?E<%?lu1_5ZdzP%VU*F7tKKP(N97pFaeEdV71*@4ox)^_FF=5<)B$LJax7|7t82+dnikG&S!40?tcImMqz$s_K_~ z-$$iVfoYo0PfbnT&CDeLNTpJlhK7b;CK8D&0hqRJKW$mo=Ve*WWV2a`h^mcYP#k^N zbw`8{j|~qG|9D;jgx1;FxlK`&M?(;$Qt42!SnOfu5di4v>50Gh-g`e2LiD(<3r*9I zOeWFV+6o~AEXzWGRTYL|tf;H2`-`fo zR|1fShK5#ImbE&p=&4i+ot>RXr_-pbt3xangDlG+B1n=1Ns^$dDl|>IDHe+z>Fn%W zGp_&u;KYd&-*+76IsjveqCnU6=2$HDN_~C(y~SejX-(7WlgVVYugYXHP*oK~G;609 zZRZt5fu?C$Ns^w<<#NWn0sw%~(a~4RheG-pXSLI_BbbXEZ&XysoY85!wTurS7{R4Ufk*oc{#8EBe@8+cq>! zgRbk?zkfg0u3d{#sf4|I_u`E=-oT+lhp=wlI`sGV&zk*En+@s&OOkYv6e&da1?t+B zMARR--%3PJ5YZkYS`*ycOhgGHx`Bwk92vWXh+ZP1Z_H`UuNOk7<#HLm?^lD?w(aVy zGBXYyJczEYE-*6|FJ6q@yLV&r=FQMFZI=2GT;w=TuM~VZ2H+6@R{>ZB;QrwLWdL3T z@GSs~0HlbhDR|xupclYbg0Xi1xDCL~0J?}Md`A~EcZ4FDZQIohBZL3|^!N8;>(;Hf z_~MJPW5cqfY$&RL{tahQ2?8n*(Rbk00km?9Kd7D>_nApMNvRR)hshGFo5al=_;`1=4K?5 zNfe7k?Ao;p0|Nt9;Vf)3f^2jkq|k!^3e3DA5T$+s;2r==06ZHwcLKoW06q)gMP}X< z0Dcm{?Eo$U@H!DC04xP?2Y~09xm+j|{?5!(;fzNMR;YZ>l`N;GrmBG7fB$_rjx(#h z0N{;{jqM9pU{UZv0B`}^1mJ4{rM?5;DFBxN_zVCGz|P3nUI1Hycl;259^4xa`yXcJ z&d$zbilST*&OQM2_4R?7v0=jo?Af!YdT25}J`TrmuzUAz6bc3G+_@9BZCB4Fg4rKq zW_O|L06IE4zN_o{SEI6I2xP8QAF6&)RV1v?01&h%zZx4GyJey30Fue%mQtzILqtoW z{6Aa&6P4?u)L~}GvJ6#KrxS_9-3wWX0RXvNZjCI8cE`6z(snMB|`D~fW@ z#Kgo;7aTyKay$v3FDlK?o&D$))(u&fA%<>aPZEZEY((&wI{w-Ogw=o_l~O%Q6&2Ij!sZoui|p zzn%9j<-f5STZ9nT_`ZLs@B7UFbY^xWNh(N^^bbjrUd!cjkG=Wko9=?_iT_h;Y;644 nQyVO&=00000NkvXXu0mjf@tD#T diff --git a/third_party/nanopb/docs/lsr.css b/third_party/nanopb/docs/lsr.css deleted file mode 100644 index 429bce51f6e..00000000000 --- a/third_party/nanopb/docs/lsr.css +++ /dev/null @@ -1,240 +0,0 @@ -/* -Author: Peter Parente -Date: 2008/01/22 -Version: 1.0 (modified) -Copyright: This stylesheet has been placed in the public domain - free to edit and use for all uses. -*/ - -body { - font: 100% sans-serif; - background: #ffffff; - color: black; - margin: 2em; - padding: 0em 2em; -} - -p.topic-title { - font-weight: bold; -} - -table.docinfo { - text-align: left; - margin: 2em 0em; -} - -a[href] { - color: #436976; - background-color: transparent; -} - -a.toc-backref { - text-decoration: none; -} - -h1 a[href] { - color: #003a6b; - text-decoration: none; - background-color: transparent; -} - -a.strong { - font-weight: bold; -} - -img { - margin: 0; - border: 0; -} - -p { - margin: 0.5em 0 1em 0; - line-height: 1.5em; -} - -p a:visited { - color: purple; - background-color: transparent; -} - -p a:active { - color: red; - background-color: transparent; -} - -a:hover { - text-decoration: none; -} - -p img { - border: 0; - margin: 0; -} - -p.rubric { - font-weight: bold; - font-style: italic; -} - -em { - font-style: normal; - font-family: monospace; - font-weight: bold; -} - -pre { - border-left: 3px double #aaa; - padding: 5px 10px; - background-color: #f6f6f6; -} - -h1.title { - color: #003a6b; - font-size: 180%; - margin-bottom: 0em; -} - -h2.subtitle { - color: #003a6b; - border-bottom: 0px; -} - -h1, h2, h3, h4, h5, h6 { - color: #555; - background-color: transparent; - margin: 0em; - padding-top: 0.5em; -} - -h1 { - font-size: 150%; - margin-bottom: 0.5em; - border-bottom: 2px solid #aaa; -} - -h2 { - font-size: 130%; - margin-bottom: 0.5em; - border-bottom: 1px solid #aaa; -} - -h3 { - font-size: 120%; - margin-bottom: 0.5em; -} - -h4 { - font-size: 110%; - font-weight: bold; - margin-bottom: 0.5em; -} - -h5 { - font-size: 105%; - font-weight: bold; - margin-bottom: 0.5em; -} - -h6 { - font-size: 100%; - font-weight: bold; - margin-bottom: 0.5em; -} - -dt { - font-style: italic; -} - -dd { - margin-bottom: 1.5em; -} - -div.admonition, div.note, div.tip, div.caution, div.important { - margin: 2em 2em; - padding: 0em 1em; - border-top: 1px solid #aaa; - border-left: 1px solid #aaa; - border-bottom: 2px solid #555; - border-right: 2px solid #555; -} - -div.important { - background: transparent url('../images/important.png') 10px 2px no-repeat; -} - -div.caution { - background: transparent url('../images/caution.png') 10px 2px no-repeat; -} - -div.note { - background: transparent url('../images/note.png') 10px 2px no-repeat; -} - -div.tip { - background: transparent url('../images/tip.png') 10px 2px no-repeat; -} - -div.admonition-example { - background: transparent url('../images/tip.png') 10px 2px no-repeat; -} - -div.admonition-critical-example { - background: transparent url('../images/important.png') 10px 2px no-repeat; -} - -p.admonition-title { - font-weight: bold; - border-bottom: 1px solid #aaa; - padding-left: 30px; -} - -table.docutils { - text-align: left; - border: 1px solid gray; - border-collapse: collapse; - margin: 1.5em 0em; -} - -table.docutils caption { - font-style: italic; -} - -table.docutils td, table.docutils th { - padding: 0.25em 0.5em; -} - -th.field-name { - text-align: right; - width: 15em; -} - -table.docutils th { - font-family: monospace; - background-color: #f6f6f6; - vertical-align: middle; -} - -table.field-list { - border: none; -} - -div.sidebar { - margin: 2em 2em 2em 0em; - padding: 0em 1em; - border-top: 1px solid #aaa; - border-left: 1px solid #aaa; - border-bottom: 2px solid #555; - border-right: 2px solid #555; -} - -p.sidebar-title { - margin-bottom: 0em; - color: #003a6b; - border-bottom: 1px solid #aaa; - font-weight: bold; -} - -p.sidebar-subtitle { - margin-top: 0em; - font-style: italic; - color: #003a6b; -} diff --git a/third_party/nanopb/docs/menu.rst b/third_party/nanopb/docs/menu.rst deleted file mode 100644 index 2c110defc4e..00000000000 --- a/third_party/nanopb/docs/menu.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. sidebar :: Documentation index - - 1) `Overview`_ - 2) `Concepts`_ - 3) `API reference`_ - 4) `Security model`_ - 5) `Migration from older versions`_ - -.. _`Overview`: index.html -.. _`Concepts`: concepts.html -.. _`API reference`: reference.html -.. _`Security model`: security.html -.. _`Migration from older versions`: migration.html diff --git a/third_party/nanopb/docs/migration.rst b/third_party/nanopb/docs/migration.rst deleted file mode 100644 index cd5911f5714..00000000000 --- a/third_party/nanopb/docs/migration.rst +++ /dev/null @@ -1,276 +0,0 @@ -===================================== -Nanopb: Migration from older versions -===================================== - -.. include :: menu.rst - -This document details all the breaking changes that have been made to nanopb -since its initial release. For each change, the rationale and required -modifications of user applications are explained. Also any error indications -are included, in order to make it easier to find this document. - -.. contents :: - -Nanopb-0.3.5 (2016-02-13) -========================= - -Add support for platforms without uint8_t ------------------------------------------ -**Rationale:** Some platforms cannot access 8-bit sized values directly, and -do not define *uint8_t*. Nanopb previously didn't support these platforms. - -**Changes:** References to *uint8_t* were replaced with several alternatives, -one of them being a new *pb_byte_t* typedef. This in turn uses *uint_least8_t* -which means the smallest available type. - -**Required actions:** If your platform does not have a standards-compliant -*stdint.h*, it may lack the definition for *[u]int_least8_t*. This must be -added manually, example can be found in *extra/pb_syshdr.h*. - -**Error indications:** Compiler error: "unknown type name 'uint_least8_t'". - -Nanopb-0.3.2 (2015-01-24) -========================= - -Add support for OneOfs ----------------------- -**Rationale:** Previously nanopb did not support the *oneof* construct in -*.proto* files. Those fields were generated as regular *optional* fields. - -**Changes:** OneOfs are now generated as C unions. Callback fields are not -supported inside oneof and generator gives an error. - -**Required actions:** The generator option *no_unions* can be used to restore old -behaviour and to allow callbacks to be used. To use unions, one change is -needed: use *which_xxxx* field to detect which field is present, instead -of *has_xxxx*. Compare the value against *MyStruct_myfield_tag*. - -**Error indications:** Generator error: "Callback fields inside of oneof are -not supported". Compiler error: "Message" has no member named "has_xxxx". - -Nanopb-0.3.0 (2014-08-26) -========================= - -Separate field iterator logic to pb_common.c --------------------------------------------- -**Rationale:** Originally, the field iteration logic was simple enough to be -duplicated in *pb_decode.c* and *pb_encode.c*. New field types have made the -logic more complex, which required the creation of a new file to contain the -common functionality. - -**Changes:** There is a new file, *pb_common.c*, which must be included in -builds. - -**Required actions:** Add *pb_common.c* to build rules. This file is always -required. Either *pb_decode.c* or *pb_encode.c* can still be left out if some -functionality is not needed. - -**Error indications:** Linker error: undefined reference to -*pb_field_iter_begin*, *pb_field_iter_next* or similar. - -Change data type of field counts to pb_size_t ---------------------------------------------- -**Rationale:** Often nanopb is used with small arrays, such as 255 items or -less. Using a full *size_t* field to store the array count wastes memory if -there are many arrays. There already exists parameters *PB_FIELD_16BIT* and -*PB_FIELD_32BIT* which tell nanopb what is the maximum size of arrays in use. - -**Changes:** Generator will now use *pb_size_t* for the array *_count* fields. -The size of the type will be controlled by the *PB_FIELD_16BIT* and -*PB_FIELD_32BIT* compilation time options. - -**Required actions:** Regenerate all *.pb.h* files. In some cases casts to the -*pb_size_t* type may need to be added in the user code when accessing the -*_count* fields. - -**Error indications:** Incorrect data at runtime, crashes. But note that other -changes in the same version already require regenerating the files and have -better indications of errors, so this is only an issue for development -versions. - -Renamed some macros and identifiers ------------------------------------ -**Rationale:** Some names in nanopb core were badly chosen and conflicted with -ISO C99 reserved names or lacked a prefix. While they haven't caused trouble -so far, it is reasonable to switch to non-conflicting names as these are rarely -used from user code. - -**Changes:** The following identifier names have changed: - - * Macros: - - * STATIC_ASSERT(x) -> PB_STATIC_ASSERT(x) - * UNUSED(x) -> PB_UNUSED(x) - - * Include guards: - - * _PB_filename_ -> PB_filename_INCLUDED - - * Structure forward declaration tags: - - * _pb_field_t -> pb_field_s - * _pb_bytes_array_t -> pb_bytes_array_s - * _pb_callback_t -> pb_callback_s - * _pb_extension_type_t -> pb_extension_type_s - * _pb_extension_t -> pb_extension_s - * _pb_istream_t -> pb_istream_s - * _pb_ostream_t -> pb_ostream_s - -**Required actions:** Regenerate all *.pb.c* files. If you use any of the above -identifiers in your application code, perform search-replace to the new name. - -**Error indications:** Compiler errors on lines with the macro/type names. - -Nanopb-0.2.9 (2014-08-09) -========================= - -Change semantics of generator -e option ---------------------------------------- -**Rationale:** Some compilers do not accept filenames with two dots (like -in default extension .pb.c). The *-e* option to the generator allowed changing -the extension, but not skipping the extra dot. - -**Changes:** The *-e* option in generator will no longer add the prepending -dot. The default value has been adjusted accordingly to *.pb.c* to keep the -default behaviour the same as before. - -**Required actions:** Only if using the generator -e option. Add dot before -the parameter value on the command line. - -**Error indications:** File not found when trying to compile generated files. - -Nanopb-0.2.7 (2014-04-07) -========================= - -Changed pointer-type bytes field datatype ------------------------------------------ -**Rationale:** In the initial pointer encoding support since nanopb-0.2.5, -the bytes type used a separate *pb_bytes_ptr_t* type to represent *bytes* -fields. This made it easy to encode data from a separate, user-allocated -buffer. However, it made the internal logic more complex and was inconsistent -with the other types. - -**Changes:** Dynamically allocated bytes fields now have the *pb_bytes_array_t* -type, just like statically allocated ones. - -**Required actions:** Only if using pointer-type fields with the bytes datatype. -Change any access to *msg->field.size* to *msg->field->size*. Change any -allocation to reserve space of amount *PB_BYTES_ARRAY_T_ALLOCSIZE(n)*. If the -data pointer was begin assigned from external source, implement the field using -a callback function instead. - -**Error indications:** Compiler error: unknown type name *pb_bytes_ptr_t*. - -Nanopb-0.2.4 (2013-11-07) -========================= - -Remove the NANOPB_INTERNALS compilation option ----------------------------------------------- -**Rationale:** Having the option in the headers required the functions to -be non-static, even if the option is not used. This caused errors on some -static analysis tools. - -**Changes:** The *#ifdef* and associated functions were removed from the -header. - -**Required actions:** Only if the *NANOPB_INTERNALS* option was previously -used. Actions are as listed under nanopb-0.1.3 and nanopb-0.1.6. - -**Error indications:** Compiler warning: implicit declaration of function -*pb_dec_string*, *pb_enc_string*, or similar. - -Nanopb-0.2.1 (2013-04-14) -========================= - -Callback function signature ---------------------------- -**Rationale:** Previously the auxilary data to field callbacks was passed -as *void\**. This allowed passing of any data, but made it unnecessarily -complex to return a pointer from callback. - -**Changes:** The callback function parameter was changed to *void\*\**. - -**Required actions:** You can continue using the old callback style by -defining *PB_OLD_CALLBACK_STYLE*. Recommended action is to: - - * Change the callback signatures to contain *void\*\** for decoders and - *void \* const \** for encoders. - * Change the callback function body to use *\*arg* instead of *arg*. - -**Error indications:** Compiler warning: assignment from incompatible -pointer type, when initializing *funcs.encode* or *funcs.decode*. - -Nanopb-0.2.0 (2013-03-02) -========================= - -Reformatted generated .pb.c file using macros ---------------------------------------------- -**Rationale:** Previously the generator made a list of C *pb_field_t* -initializers in the .pb.c file. This led to a need to regenerate all .pb.c -files after even small changes to the *pb_field_t* definition. - -**Changes:** Macros were added to pb.h which allow for cleaner definition -of the .pb.c contents. By changing the macro definitions, changes to the -field structure are possible without breaking compatibility with old .pb.c -files. - -**Required actions:** Regenerate all .pb.c files from the .proto sources. - -**Error indications:** Compiler warning: implicit declaration of function -*pb_delta_end*. - -Changed pb_type_t definitions ------------------------------ -**Rationale:** The *pb_type_t* was previously an enumeration type. This -caused warnings on some compilers when using bitwise operations to set flags -inside the values. - -**Changes:** The *pb_type_t* was changed to *typedef uint8_t*. The values -were changed to *#define*. Some value names were changed for consistency. - -**Required actions:** Only if you directly access the `pb_field_t` contents -in your own code, something which is not usually done. Needed changes: - - * Change *PB_HTYPE_ARRAY* to *PB_HTYPE_REPEATED*. - * Change *PB_HTYPE_CALLBACK* to *PB_ATYPE()* and *PB_ATYPE_CALLBACK*. - -**Error indications:** Compiler error: *PB_HTYPE_ARRAY* or *PB_HTYPE_CALLBACK* -undeclared. - -Nanopb-0.1.6 (2012-09-02) -========================= - -Refactored field decoder interface ----------------------------------- -**Rationale:** Similarly to field encoders in nanopb-0.1.3. - -**Changes:** New functions with names *pb_decode_\** were added. - -**Required actions:** By defining NANOPB_INTERNALS, you can still keep using -the old functions. Recommended action is to replace any calls with the newer -*pb_decode_\** equivalents. - -**Error indications:** Compiler warning: implicit declaration of function -*pb_dec_string*, *pb_dec_varint*, *pb_dec_submessage* or similar. - -Nanopb-0.1.3 (2012-06-12) -========================= - -Refactored field encoder interface ----------------------------------- -**Rationale:** The old *pb_enc_\** functions were designed mostly for the -internal use by the core. Because they are internally accessed through -function pointers, their signatures had to be common. This led to a confusing -interface for external users. - -**Changes:** New functions with names *pb_encode_\** were added. These have -easier to use interfaces. The old functions are now only thin wrappers for -the new interface. - -**Required actions:** By defining NANOPB_INTERNALS, you can still keep using -the old functions. Recommended action is to replace any calls with the newer -*pb_encode_\** equivalents. - -**Error indications:** Compiler warning: implicit declaration of function -*pb_enc_string*, *pb_enc_varint, *pb_enc_submessage* or similar. - diff --git a/third_party/nanopb/docs/reference.rst b/third_party/nanopb/docs/reference.rst deleted file mode 100644 index ef3867a1172..00000000000 --- a/third_party/nanopb/docs/reference.rst +++ /dev/null @@ -1,770 +0,0 @@ -===================== -Nanopb: API reference -===================== - -.. include :: menu.rst - -.. contents :: - - - - -Compilation options -=================== -The following options can be specified in one of two ways: - -1. Using the -D switch on the C compiler command line. -2. By #defining them at the top of pb.h. - -You must have the same settings for the nanopb library and all code that -includes pb.h. - -============================ ================================================ -PB_NO_PACKED_STRUCTS Disable packed structs. Increases RAM usage but - is necessary on some platforms that do not - support unaligned memory access. -PB_ENABLE_MALLOC Set this to enable dynamic allocation support - in the decoder. -PB_MAX_REQUIRED_FIELDS Maximum number of required fields to check for - presence. Default value is 64. Increases stack - usage 1 byte per every 8 fields. Compiler - warning will tell if you need this. -PB_FIELD_16BIT Add support for tag numbers > 255 and fields - larger than 255 bytes or 255 array entries. - Increases code size 3 bytes per each field. - Compiler error will tell if you need this. -PB_FIELD_32BIT Add support for tag numbers > 65535 and fields - larger than 65535 bytes or 65535 array entries. - Increases code size 9 bytes per each field. - Compiler error will tell if you need this. -PB_NO_ERRMSG Disables the support for error messages; only - error information is the true/false return - value. Decreases the code size by a few hundred - bytes. -PB_BUFFER_ONLY Disables the support for custom streams. Only - supports encoding and decoding with memory - buffers. Speeds up execution and decreases code - size slightly. -PB_OLD_CALLBACK_STYLE Use the old function signature (void\* instead - of void\*\*) for callback fields. This was the - default until nanopb-0.2.1. -PB_SYSTEM_HEADER Replace the standard header files with a single - header file. It should define all the required - functions and typedefs listed on the - `overview page`_. Value must include quotes, - for example *#define PB_SYSTEM_HEADER "foo.h"*. -============================ ================================================ - -The PB_MAX_REQUIRED_FIELDS, PB_FIELD_16BIT and PB_FIELD_32BIT settings allow -raising some datatype limits to suit larger messages. Their need is recognized -automatically by C-preprocessor #if-directives in the generated .pb.h files. -The default setting is to use the smallest datatypes (least resources used). - -.. _`overview page`: index.html#compiler-requirements - - -Proto file options -================== -The generator behaviour can be adjusted using these options, defined in the -'nanopb.proto' file in the generator folder: - -============================ ================================================ -max_size Allocated size for *bytes* and *string* fields. -max_count Allocated number of entries in arrays - (*repeated* fields). -int_size Override the integer type of a field. - (To use e.g. uint8_t to save RAM.) -type Type of the generated field. Default value - is *FT_DEFAULT*, which selects automatically. - You can use *FT_CALLBACK*, *FT_POINTER*, - *FT_STATIC*, *FT_IGNORE*, or *FT_INLINE* to - force a callback field, a dynamically - allocated field, a static field, to - completely ignore the field or to - generate an inline bytes field. -long_names Prefix the enum name to the enum value in - definitions, i.e. *EnumName_EnumValue*. Enabled - by default. -packed_struct Make the generated structures packed. - NOTE: This cannot be used on CPUs that break - on unaligned accesses to variables. -skip_message Skip the whole message from generation. -no_unions Generate 'oneof' fields as optional fields - instead of C unions. -msgid Specifies a unique id for this message type. - Can be used by user code as an identifier. -anonymous_oneof Generate 'oneof' fields as anonymous unions. -============================ ================================================ - -These options can be defined for the .proto files before they are converted -using the nanopb-generatory.py. There are three ways to define the options: - -1. Using a separate .options file. - This is the preferred way as of nanopb-0.2.1, because it has the best - compatibility with other protobuf libraries. -2. Defining the options on the command line of nanopb_generator.py. - This only makes sense for settings that apply to a whole file. -3. Defining the options in the .proto file using the nanopb extensions. - This is the way used in nanopb-0.1, and will remain supported in the - future. It however sometimes causes trouble when using the .proto file - with other protobuf libraries. - -The effect of the options is the same no matter how they are given. The most -common purpose is to define maximum size for string fields in order to -statically allocate them. - -Defining the options in a .options file ---------------------------------------- -The preferred way to define options is to have a separate file -'myproto.options' in the same directory as the 'myproto.proto'. :: - - # myproto.proto - message MyMessage { - required string name = 1; - repeated int32 ids = 4; - } - -:: - - # myproto.options - MyMessage.name max_size:40 - MyMessage.ids max_count:5 - -The generator will automatically search for this file and read the -options from it. The file format is as follows: - -* Lines starting with '#' or '//' are regarded as comments. -* Blank lines are ignored. -* All other lines should start with a field name pattern, followed by one or - more options. For example: *"MyMessage.myfield max_size:5 max_count:10"*. -* The field name pattern is matched against a string of form *'Message.field'*. - For nested messages, the string is *'Message.SubMessage.field'*. -* The field name pattern may use the notation recognized by Python fnmatch(): - - - *\** matches any part of string, like 'Message.\*' for all fields - - *\?* matches any single character - - *[seq]* matches any of characters 's', 'e' and 'q' - - *[!seq]* matches any other character - -* The options are written as *'option_name:option_value'* and several options - can be defined on same line, separated by whitespace. -* Options defined later in the file override the ones specified earlier, so - it makes sense to define wildcard options first in the file and more specific - ones later. - -If preferred, the name of the options file can be set using the command line -switch *-f* to nanopb_generator.py. - -Defining the options on command line ------------------------------------- -The nanopb_generator.py has a simple command line option *-s OPTION:VALUE*. -The setting applies to the whole file that is being processed. - -Defining the options in the .proto file ---------------------------------------- -The .proto file format allows defining custom options for the fields. -The nanopb library comes with *nanopb.proto* which does exactly that, allowing -you do define the options directly in the .proto file:: - - import "nanopb.proto"; - - message MyMessage { - required string name = 1 [(nanopb).max_size = 40]; - repeated int32 ids = 4 [(nanopb).max_count = 5]; - } - -A small complication is that you have to set the include path of protoc so that -nanopb.proto can be found. This file, in turn, requires the file -*google/protobuf/descriptor.proto*. This is usually installed under -*/usr/include*. Therefore, to compile a .proto file which uses options, use a -protoc command similar to:: - - protoc -I/usr/include -Inanopb/generator -I. -omessage.pb message.proto - -The options can be defined in file, message and field scopes:: - - option (nanopb_fileopt).max_size = 20; // File scope - message Message - { - option (nanopb_msgopt).max_size = 30; // Message scope - required string fieldsize = 1 [(nanopb).max_size = 40]; // Field scope - } - - - - - - - - - -pb.h -==== - -pb_byte_t ---------- -Type used for storing byte-sized data, such as raw binary input and bytes-type fields. :: - - typedef uint_least8_t pb_byte_t; - -For most platforms this is equivalent to `uint8_t`. Some platforms however do not support -8-bit variables, and on those platforms 16 or 32 bits need to be used for each byte. - -pb_type_t ---------- -Type used to store the type of each field, to control the encoder/decoder behaviour. :: - - typedef uint_least8_t pb_type_t; - -The low-order nibble of the enumeration values defines the function that can be used for encoding and decoding the field data: - -=========================== ===== ================================================ -LTYPE identifier Value Storage format -=========================== ===== ================================================ -PB_LTYPE_VARINT 0x00 Integer. -PB_LTYPE_UVARINT 0x01 Unsigned integer. -PB_LTYPE_SVARINT 0x02 Integer, zigzag encoded. -PB_LTYPE_FIXED32 0x03 32-bit integer or floating point. -PB_LTYPE_FIXED64 0x04 64-bit integer or floating point. -PB_LTYPE_BYTES 0x05 Structure with *size_t* field and byte array. -PB_LTYPE_STRING 0x06 Null-terminated string. -PB_LTYPE_SUBMESSAGE 0x07 Submessage structure. -PB_LTYPE_EXTENSION 0x08 Point to *pb_extension_t*. -PB_LTYPE_FIXED_LENGTH_BYTES 0x09 Inline *pb_byte_t* array of fixed size. -=========================== ===== ================================================ - -The bits 4-5 define whether the field is required, optional or repeated: - -==================== ===== ================================================ -HTYPE identifier Value Field handling -==================== ===== ================================================ -PB_HTYPE_REQUIRED 0x00 Verify that field exists in decoded message. -PB_HTYPE_OPTIONAL 0x10 Use separate *has_* boolean to specify - whether the field is present. - (Unless it is a callback) -PB_HTYPE_REPEATED 0x20 A repeated field with preallocated array. - Separate *_count* for number of items. - (Unless it is a callback) -==================== ===== ================================================ - -The bits 6-7 define the how the storage for the field is allocated: - -==================== ===== ================================================ -ATYPE identifier Value Allocation method -==================== ===== ================================================ -PB_ATYPE_STATIC 0x00 Statically allocated storage in the structure. -PB_ATYPE_CALLBACK 0x40 A field with dynamic storage size. Struct field - actually contains a pointer to a callback - function. -==================== ===== ================================================ - - -pb_field_t ----------- -Describes a single structure field with memory position in relation to others. The descriptions are usually autogenerated. :: - - typedef struct pb_field_s pb_field_t; - struct pb_field_s { - pb_size_t tag; - pb_type_t type; - pb_size_t data_offset; - pb_ssize_t size_offset; - pb_size_t data_size; - pb_size_t array_size; - const void *ptr; - } pb_packed; - -:tag: Tag number of the field or 0 to terminate a list of fields. -:type: LTYPE, HTYPE and ATYPE of the field. -:data_offset: Offset of field data, relative to the end of the previous field. -:size_offset: Offset of *bool* flag for optional fields or *size_t* count for arrays, relative to field data. -:data_size: Size of a single data entry, in bytes. For PB_LTYPE_BYTES, the size of the byte array inside the containing structure. For PB_HTYPE_CALLBACK, size of the C data type if known. -:array_size: Maximum number of entries in an array, if it is an array type. -:ptr: Pointer to default value for optional fields, or to submessage description for PB_LTYPE_SUBMESSAGE. - -The *uint8_t* datatypes limit the maximum size of a single item to 255 bytes and arrays to 255 items. Compiler will give error if the values are too large. The types can be changed to larger ones by defining *PB_FIELD_16BIT*. - -pb_bytes_array_t ----------------- -An byte array with a field for storing the length:: - - typedef struct { - pb_size_t size; - pb_byte_t bytes[1]; - } pb_bytes_array_t; - -In an actual array, the length of *bytes* may be different. - -pb_callback_t -------------- -Part of a message structure, for fields with type PB_HTYPE_CALLBACK:: - - typedef struct _pb_callback_t pb_callback_t; - struct _pb_callback_t { - union { - bool (*decode)(pb_istream_t *stream, const pb_field_t *field, void **arg); - bool (*encode)(pb_ostream_t *stream, const pb_field_t *field, void * const *arg); - } funcs; - - void *arg; - }; - -A pointer to the *arg* is passed to the callback when calling. It can be used to store any information that the callback might need. - -Previously the function received just the value of *arg* instead of a pointer to it. This old behaviour can be enabled by defining *PB_OLD_CALLBACK_STYLE*. - -When calling `pb_encode`_, *funcs.encode* is used, and similarly when calling `pb_decode`_, *funcs.decode* is used. The function pointers are stored in the same memory location but are of incompatible types. You can set the function pointer to NULL to skip the field. - -pb_wire_type_t --------------- -Protocol Buffers wire types. These are used with `pb_encode_tag`_. :: - - typedef enum { - PB_WT_VARINT = 0, - PB_WT_64BIT = 1, - PB_WT_STRING = 2, - PB_WT_32BIT = 5 - } pb_wire_type_t; - -pb_extension_type_t -------------------- -Defines the handler functions and auxiliary data for a field that extends -another message. Usually autogenerated by *nanopb_generator.py*:: - - typedef struct { - bool (*decode)(pb_istream_t *stream, pb_extension_t *extension, - uint32_t tag, pb_wire_type_t wire_type); - bool (*encode)(pb_ostream_t *stream, const pb_extension_t *extension); - const void *arg; - } pb_extension_type_t; - -In the normal case, the function pointers are *NULL* and the decoder and -encoder use their internal implementations. The internal implementations -assume that *arg* points to a *pb_field_t* that describes the field in question. - -To implement custom processing of unknown fields, you can provide pointers -to your own functions. Their functionality is mostly the same as for normal -callback fields, except that they get called for any unknown field when decoding. - -pb_extension_t --------------- -Ties together the extension field type and the storage for the field value:: - - typedef struct { - const pb_extension_type_t *type; - void *dest; - pb_extension_t *next; - bool found; - } pb_extension_t; - -:type: Pointer to the structure that defines the callback functions. -:dest: Pointer to the variable that stores the field value - (as used by the default extension callback functions.) -:next: Pointer to the next extension handler, or *NULL*. -:found: Decoder sets this to true if the extension was found. - -PB_GET_ERROR ------------- -Get the current error message from a stream, or a placeholder string if -there is no error message:: - - #define PB_GET_ERROR(stream) (string expression) - -This should be used for printing errors, for example:: - - if (!pb_decode(...)) - { - printf("Decode failed: %s\n", PB_GET_ERROR(stream)); - } - -The macro only returns pointers to constant strings (in code memory), -so that there is no need to release the returned pointer. - -PB_RETURN_ERROR ---------------- -Set the error message and return false:: - - #define PB_RETURN_ERROR(stream,msg) (sets error and returns false) - -This should be used to handle error conditions inside nanopb functions -and user callback functions:: - - if (error_condition) - { - PB_RETURN_ERROR(stream, "something went wrong"); - } - -The *msg* parameter must be a constant string. - - - -pb_encode.h -=========== - -pb_ostream_from_buffer ----------------------- -Constructs an output stream for writing into a memory buffer. This is just a helper function, it doesn't do anything you couldn't do yourself in a callback function. It uses an internal callback that stores the pointer in stream *state* field. :: - - pb_ostream_t pb_ostream_from_buffer(pb_byte_t *buf, size_t bufsize); - -:buf: Memory buffer to write into. -:bufsize: Maximum number of bytes to write. -:returns: An output stream. - -After writing, you can check *stream.bytes_written* to find out how much valid data there is in the buffer. - -pb_write --------- -Writes data to an output stream. Always use this function, instead of trying to call stream callback manually. :: - - bool pb_write(pb_ostream_t *stream, const pb_byte_t *buf, size_t count); - -:stream: Output stream to write to. -:buf: Pointer to buffer with the data to be written. -:count: Number of bytes to write. -:returns: True on success, false if maximum length is exceeded or an IO error happens. - -If an error happens, *bytes_written* is not incremented. Depending on the callback used, calling pb_write again after it has failed once may be dangerous. Nanopb itself never does this, instead it returns the error to user application. The builtin pb_ostream_from_buffer is safe to call again after failed write. - -pb_encode ---------- -Encodes the contents of a structure as a protocol buffers message and writes it to output stream. :: - - bool pb_encode(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct); - -:stream: Output stream to write to. -:fields: A field description array, usually autogenerated. -:src_struct: Pointer to the data that will be serialized. -:returns: True on success, false on IO error, on detectable errors in field description, or if a field encoder returns false. - -Normally pb_encode simply walks through the fields description array and serializes each field in turn. However, submessages must be serialized twice: first to calculate their size and then to actually write them to output. This causes some constraints for callback fields, which must return the same data on every call. - -pb_encode_delimited -------------------- -Calculates the length of the message, encodes it as varint and then encodes the message. :: - - bool pb_encode_delimited(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct); - -(parameters are the same as for `pb_encode`_.) - -A common way to indicate the message length in Protocol Buffers is to prefix it with a varint. -This function does this, and it is compatible with *parseDelimitedFrom* in Google's protobuf library. - -.. sidebar:: Encoding fields manually - - The functions with names *pb_encode_\** are used when dealing with callback fields. The typical reason for using callbacks is to have an array of unlimited size. In that case, `pb_encode`_ will call your callback function, which in turn will call *pb_encode_\** functions repeatedly to write out values. - - The tag of a field must be encoded separately with `pb_encode_tag_for_field`_. After that, you can call exactly one of the content-writing functions to encode the payload of the field. For repeated fields, you can repeat this process multiple times. - - Writing packed arrays is a little bit more involved: you need to use `pb_encode_tag` and specify `PB_WT_STRING` as the wire type. Then you need to know exactly how much data you are going to write, and use `pb_encode_varint`_ to write out the number of bytes before writing the actual data. Substreams can be used to determine the number of bytes beforehand; see `pb_encode_submessage`_ source code for an example. - -pb_get_encoded_size -------------------- -Calculates the length of the encoded message. :: - - bool pb_get_encoded_size(size_t *size, const pb_field_t fields[], const void *src_struct); - -:size: Calculated size of the encoded message. -:fields: A field description array, usually autogenerated. -:src_struct: Pointer to the data that will be serialized. -:returns: True on success, false on detectable errors in field description or if a field encoder returns false. - -pb_encode_tag -------------- -Starts a field in the Protocol Buffers binary format: encodes the field number and the wire type of the data. :: - - bool pb_encode_tag(pb_ostream_t *stream, pb_wire_type_t wiretype, uint32_t field_number); - -:stream: Output stream to write to. 1-5 bytes will be written. -:wiretype: PB_WT_VARINT, PB_WT_64BIT, PB_WT_STRING or PB_WT_32BIT -:field_number: Identifier for the field, defined in the .proto file. You can get it from field->tag. -:returns: True on success, false on IO error. - -pb_encode_tag_for_field ------------------------ -Same as `pb_encode_tag`_, except takes the parameters from a *pb_field_t* structure. :: - - bool pb_encode_tag_for_field(pb_ostream_t *stream, const pb_field_t *field); - -:stream: Output stream to write to. 1-5 bytes will be written. -:field: Field description structure. Usually autogenerated. -:returns: True on success, false on IO error or unknown field type. - -This function only considers the LTYPE of the field. You can use it from your field callbacks, because the source generator writes correct LTYPE also for callback type fields. - -Wire type mapping is as follows: - -============================================= ============ -LTYPEs Wire type -============================================= ============ -VARINT, UVARINT, SVARINT PB_WT_VARINT -FIXED64 PB_WT_64BIT -STRING, BYTES, SUBMESSAGE, FIXED_LENGTH_BYTES PB_WT_STRING -FIXED32 PB_WT_32BIT -============================================= ============ - -pb_encode_varint ----------------- -Encodes a signed or unsigned integer in the varint_ format. Works for fields of type `bool`, `enum`, `int32`, `int64`, `uint32` and `uint64`:: - - bool pb_encode_varint(pb_ostream_t *stream, uint64_t value); - -:stream: Output stream to write to. 1-10 bytes will be written. -:value: Value to encode. Just cast e.g. int32_t directly to uint64_t. -:returns: True on success, false on IO error. - -.. _varint: http://code.google.com/apis/protocolbuffers/docs/encoding.html#varints - -pb_encode_svarint ------------------ -Encodes a signed integer in the 'zig-zagged' format. Works for fields of type `sint32` and `sint64`:: - - bool pb_encode_svarint(pb_ostream_t *stream, int64_t value); - -(parameters are the same as for `pb_encode_varint`_ - -pb_encode_string ----------------- -Writes the length of a string as varint and then contents of the string. Works for fields of type `bytes` and `string`:: - - bool pb_encode_string(pb_ostream_t *stream, const pb_byte_t *buffer, size_t size); - -:stream: Output stream to write to. -:buffer: Pointer to string data. -:size: Number of bytes in the string. Pass `strlen(s)` for strings. -:returns: True on success, false on IO error. - -pb_encode_fixed32 ------------------ -Writes 4 bytes to stream and swaps bytes on big-endian architectures. Works for fields of type `fixed32`, `sfixed32` and `float`:: - - bool pb_encode_fixed32(pb_ostream_t *stream, const void *value); - -:stream: Output stream to write to. -:value: Pointer to a 4-bytes large C variable, for example `uint32_t foo;`. -:returns: True on success, false on IO error. - -pb_encode_fixed64 ------------------ -Writes 8 bytes to stream and swaps bytes on big-endian architecture. Works for fields of type `fixed64`, `sfixed64` and `double`:: - - bool pb_encode_fixed64(pb_ostream_t *stream, const void *value); - -:stream: Output stream to write to. -:value: Pointer to a 8-bytes large C variable, for example `uint64_t foo;`. -:returns: True on success, false on IO error. - -pb_encode_submessage --------------------- -Encodes a submessage field, including the size header for it. Works for fields of any message type:: - - bool pb_encode_submessage(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct); - -:stream: Output stream to write to. -:fields: Pointer to the autogenerated field description array for the submessage type, e.g. `MyMessage_fields`. -:src: Pointer to the structure where submessage data is. -:returns: True on success, false on IO errors, pb_encode errors or if submessage size changes between calls. - -In Protocol Buffers format, the submessage size must be written before the submessage contents. Therefore, this function has to encode the submessage twice in order to know the size beforehand. - -If the submessage contains callback fields, the callback function might misbehave and write out a different amount of data on the second call. This situation is recognized and *false* is returned, but garbage will be written to the output before the problem is detected. - - - - - - - - - - - - -pb_decode.h -=========== - -pb_istream_from_buffer ----------------------- -Helper function for creating an input stream that reads data from a memory buffer. :: - - pb_istream_t pb_istream_from_buffer(const pb_byte_t *buf, size_t bufsize); - -:buf: Pointer to byte array to read from. -:bufsize: Size of the byte array. -:returns: An input stream ready to use. - -pb_read -------- -Read data from input stream. Always use this function, don't try to call the stream callback directly. :: - - bool pb_read(pb_istream_t *stream, pb_byte_t *buf, size_t count); - -:stream: Input stream to read from. -:buf: Buffer to store the data to, or NULL to just read data without storing it anywhere. -:count: Number of bytes to read. -:returns: True on success, false if *stream->bytes_left* is less than *count* or if an IO error occurs. - -End of file is signalled by *stream->bytes_left* being zero after pb_read returns false. - -pb_decode ---------- -Read and decode all fields of a structure. Reads until EOF on input stream. :: - - bool pb_decode(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct); - -:stream: Input stream to read from. -:fields: A field description array. Usually autogenerated. -:dest_struct: Pointer to structure where data will be stored. -:returns: True on success, false on IO error, on detectable errors in field description, if a field encoder returns false or if a required field is missing. - -In Protocol Buffers binary format, EOF is only allowed between fields. If it happens anywhere else, pb_decode will return *false*. If pb_decode returns false, you cannot trust any of the data in the structure. - -In addition to EOF, the pb_decode implementation supports terminating a message with a 0 byte. This is compatible with the official Protocol Buffers because 0 is never a valid field tag. - -For optional fields, this function applies the default value and sets *has_* to false if the field is not present. - -If *PB_ENABLE_MALLOC* is defined, this function may allocate storage for any pointer type fields. -In this case, you have to call `pb_release`_ to release the memory after you are done with the message. -On error return `pb_decode` will release the memory itself. - -pb_decode_noinit ----------------- -Same as `pb_decode`_, except does not apply the default values to fields. :: - - bool pb_decode_noinit(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct); - -(parameters are the same as for `pb_decode`_.) - -The destination structure should be filled with zeros before calling this function. Doing a *memset* manually can be slightly faster than using `pb_decode`_ if you don't need any default values. - -In addition to decoding a single message, this function can be used to merge two messages, so that -values from previous message will remain if the new message does not contain a field. - -This function *will not* release the message even on error return. If you use *PB_ENABLE_MALLOC*, -you will need to call `pb_release`_ yourself. - -pb_decode_delimited -------------------- -Same as `pb_decode`_, except that it first reads a varint with the length of the message. :: - - bool pb_decode_delimited(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct); - -(parameters are the same as for `pb_decode`_.) - -A common method to indicate message size in Protocol Buffers is to prefix it with a varint. -This function is compatible with *writeDelimitedTo* in the Google's Protocol Buffers library. - -pb_release ----------- -Releases any dynamically allocated fields:: - - void pb_release(const pb_field_t fields[], void *dest_struct); - -:fields: A field description array. Usually autogenerated. -:dest_struct: Pointer to structure where data is stored. If NULL, function does nothing. - -This function is only available if *PB_ENABLE_MALLOC* is defined. It will release any -pointer type fields in the structure and set the pointers to NULL. - -pb_decode_tag -------------- -Decode the tag that comes before field in the protobuf encoding:: - - bool pb_decode_tag(pb_istream_t *stream, pb_wire_type_t *wire_type, uint32_t *tag, bool *eof); - -:stream: Input stream to read from. -:wire_type: Pointer to variable where to store the wire type of the field. -:tag: Pointer to variable where to store the tag of the field. -:eof: Pointer to variable where to store end-of-file status. -:returns: True on success, false on error or EOF. - -When the message (stream) ends, this function will return false and set *eof* to true. On other -errors, *eof* will be set to false. - -pb_skip_field -------------- -Remove the data for a field from the stream, without actually decoding it:: - - bool pb_skip_field(pb_istream_t *stream, pb_wire_type_t wire_type); - -:stream: Input stream to read from. -:wire_type: Type of field to skip. -:returns: True on success, false on IO error. - -.. sidebar:: Decoding fields manually - - The functions with names beginning with *pb_decode_* are used when dealing with callback fields. The typical reason for using callbacks is to have an array of unlimited size. In that case, `pb_decode`_ will call your callback function repeatedly, which can then store the values into e.g. filesystem in the order received in. - - For decoding numeric (including enumerated and boolean) values, use `pb_decode_varint`_, `pb_decode_svarint`_, `pb_decode_fixed32`_ and `pb_decode_fixed64`_. They take a pointer to a 32- or 64-bit C variable, which you may then cast to smaller datatype for storage. - - For decoding strings and bytes fields, the length has already been decoded. You can therefore check the total length in *stream->bytes_left* and read the data using `pb_read`_. - - Finally, for decoding submessages in a callback, simply use `pb_decode`_ and pass it the *SubMessage_fields* descriptor array. - -pb_decode_varint ----------------- -Read and decode a varint_ encoded integer. :: - - bool pb_decode_varint(pb_istream_t *stream, uint64_t *dest); - -:stream: Input stream to read from. 1-10 bytes will be read. -:dest: Storage for the decoded integer. Value is undefined on error. -:returns: True on success, false if value exceeds uint64_t range or an IO error happens. - -pb_decode_svarint ------------------ -Similar to `pb_decode_varint`_, except that it performs zigzag-decoding on the value. This corresponds to the Protocol Buffers *sint32* and *sint64* datatypes. :: - - bool pb_decode_svarint(pb_istream_t *stream, int64_t *dest); - -(parameters are the same as `pb_decode_varint`_) - -pb_decode_fixed32 ------------------ -Decode a *fixed32*, *sfixed32* or *float* value. :: - - bool pb_decode_fixed32(pb_istream_t *stream, void *dest); - -:stream: Input stream to read from. 4 bytes will be read. -:dest: Pointer to destination *int32_t*, *uint32_t* or *float*. -:returns: True on success, false on IO errors. - -This function reads 4 bytes from the input stream. -On big endian architectures, it then reverses the order of the bytes. -Finally, it writes the bytes to *dest*. - -pb_decode_fixed64 ------------------ -Decode a *fixed64*, *sfixed64* or *double* value. :: - - bool pb_decode_fixed64(pb_istream_t *stream, void *dest); - -:stream: Input stream to read from. 8 bytes will be read. -:dest: Pointer to destination *int64_t*, *uint64_t* or *double*. -:returns: True on success, false on IO errors. - -Same as `pb_decode_fixed32`_, except this reads 8 bytes. - -pb_make_string_substream ------------------------- -Decode the length for a field with wire type *PB_WT_STRING* and create a substream for reading the data. :: - - bool pb_make_string_substream(pb_istream_t *stream, pb_istream_t *substream); - -:stream: Original input stream to read the length and data from. -:substream: New substream that has limited length. Filled in by the function. -:returns: True on success, false if reading the length fails. - -This function uses `pb_decode_varint`_ to read an integer from the stream. This is interpreted as a number of bytes, and the substream is set up so that its `bytes_left` is initially the same as the length, and its callback function and state the same as the parent stream. - -pb_close_string_substream -------------------------- -Close the substream created with `pb_make_string_substream`_. :: - - void pb_close_string_substream(pb_istream_t *stream, pb_istream_t *substream); - -:stream: Original input stream to read the length and data from. -:substream: Substream to close - -This function copies back the state from the substream to the parent stream. -It must be called after done with the substream. diff --git a/third_party/nanopb/docs/security.rst b/third_party/nanopb/docs/security.rst deleted file mode 100644 index d85461229d0..00000000000 --- a/third_party/nanopb/docs/security.rst +++ /dev/null @@ -1,84 +0,0 @@ -====================== -Nanopb: Security model -====================== - -.. include :: menu.rst - -.. contents :: - - - -Importance of security in a Protocol Buffers library -==================================================== -In the context of protocol buffers, security comes into play when decoding -untrusted data. Naturally, if the attacker can modify the contents of a -protocol buffers message, he can feed the application any values possible. -Therefore the application itself must be prepared to receive untrusted values. - -Where nanopb plays a part is preventing the attacker from running arbitrary -code on the target system. Mostly this means that there must not be any -possibility to cause buffer overruns, memory corruption or invalid pointers -by the means of crafting a malicious message. - -Division of trusted and untrusted data -====================================== -The following data is regarded as **trusted**. It must be under the control of -the application writer. Malicious data in these structures could cause -security issues, such as execution of arbitrary code: - -1. Callback, pointer and extension fields in message structures given to - pb_encode() and pb_decode(). These fields are memory pointers, and are - generated depending on the message definition in the .proto file. -2. The automatically generated field definitions, i.e. *pb_field_t* lists. -3. Contents of the *pb_istream_t* and *pb_ostream_t* structures (this does not - mean the contents of the stream itself, just the stream definition). - -The following data is regarded as **untrusted**. Invalid/malicious data in -these will cause "garbage in, garbage out" behaviour. It will not cause -buffer overflows, information disclosure or other security problems: - -1. All data read from *pb_istream_t*. -2. All fields in message structures, except: - - - callbacks (*pb_callback_t* structures) - - pointer fields (malloc support) and *_count* fields for pointers - - extensions (*pb_extension_t* structures) - -Invariants -========== -The following invariants are maintained during operation, even if the -untrusted data has been maliciously crafted: - -1. Nanopb will never read more than *bytes_left* bytes from *pb_istream_t*. -2. Nanopb will never write more than *max_size* bytes to *pb_ostream_t*. -3. Nanopb will never access memory out of bounds of the message structure. -4. After pb_decode() returns successfully, the message structure will be - internally consistent: - - - The *count* fields of arrays will not exceed the array size. - - The *size* field of bytes will not exceed the allocated size. - - All string fields will have null terminator. - -5. After pb_encode() returns successfully, the resulting message is a valid - protocol buffers message. (Except if user-defined callbacks write incorrect - data.) - -Further considerations -====================== -Even if the nanopb library is free of any security issues, there are still -several possible attack vectors that the application author must consider. -The following list is not comprehensive: - -1. Stack usage may depend on the contents of the message. The message - definition places an upper bound on how much stack will be used. Tests - should be run with all fields present, to record the maximum possible - stack usage. -2. Callbacks can do anything. The code for the callbacks must be carefully - checked if they are used with untrusted data. -3. If using stream input, a maximum size should be set in *pb_istream_t* to - stop a denial of service attack from using an infinite message. -4. If using network sockets as streams, a timeout should be set to stop - denial of service attacks. -5. If using *malloc()* support, some method of limiting memory use should be - employed. This can be done by defining custom *pb_realloc()* function. - Nanopb will properly detect and handle failed memory allocations. diff --git a/third_party/nanopb/examples/cmake_simple/CMakeLists.txt b/third_party/nanopb/examples/cmake_simple/CMakeLists.txt deleted file mode 100644 index e5f33a028eb..00000000000 --- a/third_party/nanopb/examples/cmake_simple/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -project(NANOPB_CMAKE_SIMPLE C) - -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../extra) -find_package(Nanopb REQUIRED) -include_directories(${NANOPB_INCLUDE_DIRS}) - -nanopb_generate_cpp(PROTO_SRCS PROTO_HDRS simple.proto) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) -#add_custom_target(generate_proto_sources DEPENDS ${PROTO_SRCS} ${PROTO_HDRS}) -set_source_files_properties(${PROTO_SRCS} ${PROTO_HDRS} - PROPERTIES GENERATED TRUE) - -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -g -O0") - -add_executable(simple simple.c ${PROTO_SRCS} ${PROTO_HDRS}) diff --git a/third_party/nanopb/examples/cmake_simple/README.txt b/third_party/nanopb/examples/cmake_simple/README.txt deleted file mode 100644 index aa0f3f3a771..00000000000 --- a/third_party/nanopb/examples/cmake_simple/README.txt +++ /dev/null @@ -1,18 +0,0 @@ -Nanopb example "simple" using CMake -======================= - -This example is the same as the simple nanopb example but built using CMake. - -Example usage -------------- - -On Linux, create a build directory and then call cmake: - - nanopb/examples/cmake_simple$ mkdir build - nanopb/examples/cmake_simple$ cd build/ - nanopb/examples/cmake_simple/build$ cmake .. - nanopb/examples/cmake_simple/build$ make - -After that, you can run it with the command: ./simple - -On other platforms supported by CMake, refer to CMake instructions. diff --git a/third_party/nanopb/examples/cmake_simple/simple.c b/third_party/nanopb/examples/cmake_simple/simple.c deleted file mode 100644 index 1f6b137351c..00000000000 --- a/third_party/nanopb/examples/cmake_simple/simple.c +++ /dev/null @@ -1,71 +0,0 @@ -#include -#include -#include -#include "simple.pb.h" - -int main() -{ - /* This is the buffer where we will store our message. */ - uint8_t buffer[128]; - size_t message_length; - bool status; - - /* Encode our message */ - { - /* Allocate space on the stack to store the message data. - * - * Nanopb generates simple struct definitions for all the messages. - * - check out the contents of simple.pb.h! - * It is a good idea to always initialize your structures - * so that you do not have garbage data from RAM in there. - */ - SimpleMessage message = SimpleMessage_init_zero; - - /* Create a stream that will write to our buffer. */ - pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - - /* Fill in the lucky number */ - message.lucky_number = 13; - - /* Now we are ready to encode the message! */ - status = pb_encode(&stream, SimpleMessage_fields, &message); - message_length = stream.bytes_written; - - /* Then just check for any errors.. */ - if (!status) - { - printf("Encoding failed: %s\n", PB_GET_ERROR(&stream)); - return 1; - } - } - - /* Now we could transmit the message over network, store it in a file or - * wrap it to a pigeon's leg. - */ - - /* But because we are lazy, we will just decode it immediately. */ - - { - /* Allocate space for the decoded message. */ - SimpleMessage message = SimpleMessage_init_zero; - - /* Create a stream that reads from the buffer. */ - pb_istream_t stream = pb_istream_from_buffer(buffer, message_length); - - /* Now we are ready to decode the message. */ - status = pb_decode(&stream, SimpleMessage_fields, &message); - - /* Check for errors... */ - if (!status) - { - printf("Decoding failed: %s\n", PB_GET_ERROR(&stream)); - return 1; - } - - /* Print the data contained in the message. */ - printf("Your lucky number was %d!\n", message.lucky_number); - } - - return 0; -} - diff --git a/third_party/nanopb/examples/cmake_simple/simple.proto b/third_party/nanopb/examples/cmake_simple/simple.proto deleted file mode 100644 index 5c73a3b229e..00000000000 --- a/third_party/nanopb/examples/cmake_simple/simple.proto +++ /dev/null @@ -1,9 +0,0 @@ -// A very simple protocol definition, consisting of only -// one message. - -syntax = "proto2"; - -message SimpleMessage { - required int32 lucky_number = 1; -} - diff --git a/third_party/nanopb/examples/network_server/Makefile b/third_party/nanopb/examples/network_server/Makefile deleted file mode 100644 index 2c7639a15db..00000000000 --- a/third_party/nanopb/examples/network_server/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# Include the nanopb provided Makefile rules -include ../../extra/nanopb.mk - -# Compiler flags to enable all warnings & debug info -CFLAGS = -ansi -Wall -Werror -g -O0 -CFLAGS += -I$(NANOPB_DIR) - -all: server client - -.SUFFIXES: - -clean: - rm -f server client fileproto.pb.c fileproto.pb.h - -%: %.c common.c fileproto.pb.c - $(CC) $(CFLAGS) -o $@ $^ $(NANOPB_CORE) - diff --git a/third_party/nanopb/examples/network_server/README.txt b/third_party/nanopb/examples/network_server/README.txt deleted file mode 100644 index 7bdcbed5db3..00000000000 --- a/third_party/nanopb/examples/network_server/README.txt +++ /dev/null @@ -1,60 +0,0 @@ -Nanopb example "network_server" -=============================== - -This example demonstrates the use of nanopb to communicate over network -connections. It consists of a server that sends file listings, and of -a client that requests the file list from the server. - -Example usage -------------- - -user@host:~/nanopb/examples/network_server$ make # Build the example -protoc -ofileproto.pb fileproto.proto -python ../../generator/nanopb_generator.py fileproto.pb -Writing to fileproto.pb.h and fileproto.pb.c -cc -ansi -Wall -Werror -I .. -g -O0 -I../.. -o server server.c - ../../pb_decode.c ../../pb_encode.c fileproto.pb.c common.c -cc -ansi -Wall -Werror -I .. -g -O0 -I../.. -o client client.c - ../../pb_decode.c ../../pb_encode.c fileproto.pb.c common.c - -user@host:~/nanopb/examples/network_server$ ./server & # Start the server on background -[1] 24462 - -petteri@oddish:~/nanopb/examples/network_server$ ./client /bin # Request the server to list /bin -Got connection. -Listing directory: /bin -1327119 bzdiff -1327126 bzless -1327147 ps -1327178 ntfsmove -1327271 mv -1327187 mount -1327259 false -1327266 tempfile -1327285 zfgrep -1327165 gzexe -1327204 nc.openbsd -1327260 uname - - -Details of implementation -------------------------- -fileproto.proto contains the portable Google Protocol Buffers protocol definition. -It could be used as-is to implement a server or a client in any other language, for -example Python or Java. - -fileproto.options contains the nanopb-specific options for the protocol file. This -sets the amount of space allocated for file names when decoding messages. - -common.c/h contains functions that allow nanopb to read and write directly from -network socket. This way there is no need to allocate a separate buffer to store -the message. - -server.c contains the code to open a listening socket, to respond to clients and -to list directory contents. - -client.c contains the code to connect to a server, to send a request and to print -the response message. - -The code is implemented using the POSIX socket api, but it should be easy enough -to port into any other socket api, such as lwip. diff --git a/third_party/nanopb/examples/network_server/client.c b/third_party/nanopb/examples/network_server/client.c deleted file mode 100644 index 00f6dab855e..00000000000 --- a/third_party/nanopb/examples/network_server/client.c +++ /dev/null @@ -1,142 +0,0 @@ -/* This is a simple TCP client that connects to port 1234 and prints a list - * of files in a given directory. - * - * It directly deserializes and serializes messages from network, minimizing - * memory use. - * - * For flexibility, this example is implemented using posix api. - * In a real embedded system you would typically use some other kind of - * a communication and filesystem layer. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "fileproto.pb.h" -#include "common.h" - -/* This callback function will be called once for each filename received - * from the server. The filenames will be printed out immediately, so that - * no memory has to be allocated for them. - */ -bool printfile_callback(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - FileInfo fileinfo = {}; - - if (!pb_decode(stream, FileInfo_fields, &fileinfo)) - return false; - - printf("%-10lld %s\n", (long long)fileinfo.inode, fileinfo.name); - - return true; -} - -/* This function sends a request to socket 'fd' to list the files in - * directory given in 'path'. The results received from server will - * be printed to stdout. - */ -bool listdir(int fd, char *path) -{ - /* Construct and send the request to server */ - { - ListFilesRequest request = {}; - pb_ostream_t output = pb_ostream_from_socket(fd); - uint8_t zero = 0; - - /* In our protocol, path is optional. If it is not given, - * the server will list the root directory. */ - if (path == NULL) - { - request.has_path = false; - } - else - { - request.has_path = true; - if (strlen(path) + 1 > sizeof(request.path)) - { - fprintf(stderr, "Too long path.\n"); - return false; - } - - strcpy(request.path, path); - } - - /* Encode the request. It is written to the socket immediately - * through our custom stream. */ - if (!pb_encode(&output, ListFilesRequest_fields, &request)) - { - fprintf(stderr, "Encoding failed: %s\n", PB_GET_ERROR(&output)); - return false; - } - - /* We signal the end of request with a 0 tag. */ - pb_write(&output, &zero, 1); - } - - /* Read back the response from server */ - { - ListFilesResponse response = {}; - pb_istream_t input = pb_istream_from_socket(fd); - - /* Give a pointer to our callback function, which will handle the - * filenames as they arrive. */ - response.file.funcs.decode = &printfile_callback; - - if (!pb_decode(&input, ListFilesResponse_fields, &response)) - { - fprintf(stderr, "Decode failed: %s\n", PB_GET_ERROR(&input)); - return false; - } - - /* If the message from server decodes properly, but directory was - * not found on server side, we get path_error == true. */ - if (response.path_error) - { - fprintf(stderr, "Server reported error.\n"); - return false; - } - } - - return true; -} - -int main(int argc, char **argv) -{ - int sockfd; - struct sockaddr_in servaddr; - char *path = NULL; - - if (argc > 1) - path = argv[1]; - - sockfd = socket(AF_INET, SOCK_STREAM, 0); - - /* Connect to server running on localhost:1234 */ - memset(&servaddr, 0, sizeof(servaddr)); - servaddr.sin_family = AF_INET; - servaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - servaddr.sin_port = htons(1234); - - if (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) != 0) - { - perror("connect"); - return 1; - } - - /* Send the directory listing request */ - if (!listdir(sockfd, path)) - return 2; - - /* Close connection */ - close(sockfd); - - return 0; -} diff --git a/third_party/nanopb/examples/network_server/common.c b/third_party/nanopb/examples/network_server/common.c deleted file mode 100644 index 04a5aa85c0b..00000000000 --- a/third_party/nanopb/examples/network_server/common.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Simple binding of nanopb streams to TCP sockets. - */ - -#include -#include -#include -#include - -#include "common.h" - -static bool write_callback(pb_ostream_t *stream, const uint8_t *buf, size_t count) -{ - int fd = (intptr_t)stream->state; - return send(fd, buf, count, 0) == count; -} - -static bool read_callback(pb_istream_t *stream, uint8_t *buf, size_t count) -{ - int fd = (intptr_t)stream->state; - int result; - - result = recv(fd, buf, count, MSG_WAITALL); - - if (result == 0) - stream->bytes_left = 0; /* EOF */ - - return result == count; -} - -pb_ostream_t pb_ostream_from_socket(int fd) -{ - pb_ostream_t stream = {&write_callback, (void*)(intptr_t)fd, SIZE_MAX, 0}; - return stream; -} - -pb_istream_t pb_istream_from_socket(int fd) -{ - pb_istream_t stream = {&read_callback, (void*)(intptr_t)fd, SIZE_MAX}; - return stream; -} diff --git a/third_party/nanopb/examples/network_server/common.h b/third_party/nanopb/examples/network_server/common.h deleted file mode 100644 index 8dab3b7c38c..00000000000 --- a/third_party/nanopb/examples/network_server/common.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _PB_EXAMPLE_COMMON_H_ -#define _PB_EXAMPLE_COMMON_H_ - -#include - -pb_ostream_t pb_ostream_from_socket(int fd); -pb_istream_t pb_istream_from_socket(int fd); - -#endif \ No newline at end of file diff --git a/third_party/nanopb/examples/network_server/fileproto.options b/third_party/nanopb/examples/network_server/fileproto.options deleted file mode 100644 index 29a2ab0e4a5..00000000000 --- a/third_party/nanopb/examples/network_server/fileproto.options +++ /dev/null @@ -1,13 +0,0 @@ -# This file defines the nanopb-specific options for the messages defined -# in fileproto.proto. -# -# If you come from high-level programming background, the hardcoded -# maximum lengths may disgust you. However, if your microcontroller only -# has a few kB of ram to begin with, setting reasonable limits for -# filenames is ok. -# -# On the other hand, using the callback interface, it is not necessary -# to set a limit on the number of files in the response. - -ListFilesRequest.path max_size:128 -FileInfo.name max_size:128 diff --git a/third_party/nanopb/examples/network_server/fileproto.proto b/third_party/nanopb/examples/network_server/fileproto.proto deleted file mode 100644 index 5640b8d5010..00000000000 --- a/third_party/nanopb/examples/network_server/fileproto.proto +++ /dev/null @@ -1,20 +0,0 @@ -// This defines protocol for a simple server that lists files. -// -// See also the nanopb-specific options in fileproto.options. - -syntax = "proto2"; - -message ListFilesRequest { - optional string path = 1 [default = "/"]; -} - -message FileInfo { - required uint64 inode = 1; - required string name = 2; -} - -message ListFilesResponse { - optional bool path_error = 1 [default = false]; - repeated FileInfo file = 2; -} - diff --git a/third_party/nanopb/examples/network_server/server.c b/third_party/nanopb/examples/network_server/server.c deleted file mode 100644 index 46a5f38d1d9..00000000000 --- a/third_party/nanopb/examples/network_server/server.c +++ /dev/null @@ -1,158 +0,0 @@ -/* This is a simple TCP server that listens on port 1234 and provides lists - * of files to clients, using a protocol defined in file_server.proto. - * - * It directly deserializes and serializes messages from network, minimizing - * memory use. - * - * For flexibility, this example is implemented using posix api. - * In a real embedded system you would typically use some other kind of - * a communication and filesystem layer. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "fileproto.pb.h" -#include "common.h" - -/* This callback function will be called once during the encoding. - * It will write out any number of FileInfo entries, without consuming unnecessary memory. - * This is accomplished by fetching the filenames one at a time and encoding them - * immediately. - */ -bool listdir_callback(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - DIR *dir = (DIR*) *arg; - struct dirent *file; - FileInfo fileinfo = {}; - - while ((file = readdir(dir)) != NULL) - { - fileinfo.inode = file->d_ino; - strncpy(fileinfo.name, file->d_name, sizeof(fileinfo.name)); - fileinfo.name[sizeof(fileinfo.name) - 1] = '\0'; - - /* This encodes the header for the field, based on the constant info - * from pb_field_t. */ - if (!pb_encode_tag_for_field(stream, field)) - return false; - - /* This encodes the data for the field, based on our FileInfo structure. */ - if (!pb_encode_submessage(stream, FileInfo_fields, &fileinfo)) - return false; - } - - return true; -} - -/* Handle one arriving client connection. - * Clients are expected to send a ListFilesRequest, terminated by a '0'. - * Server will respond with a ListFilesResponse message. - */ -void handle_connection(int connfd) -{ - DIR *directory = NULL; - - /* Decode the message from the client and open the requested directory. */ - { - ListFilesRequest request = {}; - pb_istream_t input = pb_istream_from_socket(connfd); - - if (!pb_decode(&input, ListFilesRequest_fields, &request)) - { - printf("Decode failed: %s\n", PB_GET_ERROR(&input)); - return; - } - - directory = opendir(request.path); - printf("Listing directory: %s\n", request.path); - } - - /* List the files in the directory and transmit the response to client */ - { - ListFilesResponse response = {}; - pb_ostream_t output = pb_ostream_from_socket(connfd); - - if (directory == NULL) - { - perror("opendir"); - - /* Directory was not found, transmit error status */ - response.has_path_error = true; - response.path_error = true; - response.file.funcs.encode = NULL; - } - else - { - /* Directory was found, transmit filenames */ - response.has_path_error = false; - response.file.funcs.encode = &listdir_callback; - response.file.arg = directory; - } - - if (!pb_encode(&output, ListFilesResponse_fields, &response)) - { - printf("Encoding failed: %s\n", PB_GET_ERROR(&output)); - } - } - - if (directory != NULL) - closedir(directory); -} - -int main(int argc, char **argv) -{ - int listenfd, connfd; - struct sockaddr_in servaddr; - int reuse = 1; - - /* Listen on localhost:1234 for TCP connections */ - listenfd = socket(AF_INET, SOCK_STREAM, 0); - setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)); - - memset(&servaddr, 0, sizeof(servaddr)); - servaddr.sin_family = AF_INET; - servaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - servaddr.sin_port = htons(1234); - if (bind(listenfd, (struct sockaddr*)&servaddr, sizeof(servaddr)) != 0) - { - perror("bind"); - return 1; - } - - if (listen(listenfd, 5) != 0) - { - perror("listen"); - return 1; - } - - for(;;) - { - /* Wait for a client */ - connfd = accept(listenfd, NULL, NULL); - - if (connfd < 0) - { - perror("accept"); - return 1; - } - - printf("Got connection.\n"); - - handle_connection(connfd); - - printf("Closing connection.\n"); - - close(connfd); - } - - return 0; -} diff --git a/third_party/nanopb/examples/simple/Makefile b/third_party/nanopb/examples/simple/Makefile deleted file mode 100644 index 970a865009a..00000000000 --- a/third_party/nanopb/examples/simple/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -# Include the nanopb provided Makefile rules -include ../../extra/nanopb.mk - -# Compiler flags to enable all warnings & debug info -CFLAGS = -Wall -Werror -g -O0 -CFLAGS += -I$(NANOPB_DIR) - -# C source code files that are required -CSRC = simple.c # The main program -CSRC += simple.pb.c # The compiled protocol definition -CSRC += $(NANOPB_DIR)/pb_encode.c # The nanopb encoder -CSRC += $(NANOPB_DIR)/pb_decode.c # The nanopb decoder -CSRC += $(NANOPB_DIR)/pb_common.c # The nanopb common parts - -# Build rule for the main program -simple: $(CSRC) - $(CC) $(CFLAGS) -osimple $(CSRC) - -# Build rule for the protocol -simple.pb.c: simple.proto - $(PROTOC) $(PROTOC_OPTS) --nanopb_out=. simple.proto - diff --git a/third_party/nanopb/examples/simple/README.txt b/third_party/nanopb/examples/simple/README.txt deleted file mode 100644 index ee77bfc70c5..00000000000 --- a/third_party/nanopb/examples/simple/README.txt +++ /dev/null @@ -1,29 +0,0 @@ -Nanopb example "simple" -======================= - -This example demonstrates the very basic use of nanopb. It encodes and -decodes a simple message. - -The code uses four different API functions: - - * pb_ostream_from_buffer() to declare the output buffer that is to be used - * pb_encode() to encode a message - * pb_istream_from_buffer() to declare the input buffer that is to be used - * pb_decode() to decode a message - -Example usage -------------- - -On Linux, simply type "make" to build the example. After that, you can -run it with the command: ./simple - -On other platforms, you first have to compile the protocol definition using -the following command:: - - ../../generator-bin/protoc --nanopb_out=. simple.proto - -After that, add the following four files to your project and compile: - - simple.c simple.pb.c pb_encode.c pb_decode.c - - diff --git a/third_party/nanopb/examples/simple/simple.c b/third_party/nanopb/examples/simple/simple.c deleted file mode 100644 index 1f6b137351c..00000000000 --- a/third_party/nanopb/examples/simple/simple.c +++ /dev/null @@ -1,71 +0,0 @@ -#include -#include -#include -#include "simple.pb.h" - -int main() -{ - /* This is the buffer where we will store our message. */ - uint8_t buffer[128]; - size_t message_length; - bool status; - - /* Encode our message */ - { - /* Allocate space on the stack to store the message data. - * - * Nanopb generates simple struct definitions for all the messages. - * - check out the contents of simple.pb.h! - * It is a good idea to always initialize your structures - * so that you do not have garbage data from RAM in there. - */ - SimpleMessage message = SimpleMessage_init_zero; - - /* Create a stream that will write to our buffer. */ - pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - - /* Fill in the lucky number */ - message.lucky_number = 13; - - /* Now we are ready to encode the message! */ - status = pb_encode(&stream, SimpleMessage_fields, &message); - message_length = stream.bytes_written; - - /* Then just check for any errors.. */ - if (!status) - { - printf("Encoding failed: %s\n", PB_GET_ERROR(&stream)); - return 1; - } - } - - /* Now we could transmit the message over network, store it in a file or - * wrap it to a pigeon's leg. - */ - - /* But because we are lazy, we will just decode it immediately. */ - - { - /* Allocate space for the decoded message. */ - SimpleMessage message = SimpleMessage_init_zero; - - /* Create a stream that reads from the buffer. */ - pb_istream_t stream = pb_istream_from_buffer(buffer, message_length); - - /* Now we are ready to decode the message. */ - status = pb_decode(&stream, SimpleMessage_fields, &message); - - /* Check for errors... */ - if (!status) - { - printf("Decoding failed: %s\n", PB_GET_ERROR(&stream)); - return 1; - } - - /* Print the data contained in the message. */ - printf("Your lucky number was %d!\n", message.lucky_number); - } - - return 0; -} - diff --git a/third_party/nanopb/examples/simple/simple.proto b/third_party/nanopb/examples/simple/simple.proto deleted file mode 100644 index 5c73a3b229e..00000000000 --- a/third_party/nanopb/examples/simple/simple.proto +++ /dev/null @@ -1,9 +0,0 @@ -// A very simple protocol definition, consisting of only -// one message. - -syntax = "proto2"; - -message SimpleMessage { - required int32 lucky_number = 1; -} - diff --git a/third_party/nanopb/examples/using_double_on_avr/Makefile b/third_party/nanopb/examples/using_double_on_avr/Makefile deleted file mode 100644 index 874a64bdc98..00000000000 --- a/third_party/nanopb/examples/using_double_on_avr/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -# Include the nanopb provided Makefile rules -include ../../extra/nanopb.mk - -# Compiler flags to enable all warnings & debug info -CFLAGS = -Wall -Werror -g -O0 -CFLAGS += -I$(NANOPB_DIR) - -all: run_tests - -.SUFFIXES: - -clean: - rm -f test_conversions encode_double decode_double doubleproto.pb.c doubleproto.pb.h - -test_conversions: test_conversions.c double_conversion.c - $(CC) $(CFLAGS) -o $@ $^ - -%: %.c double_conversion.c doubleproto.pb.c - $(CC) $(CFLAGS) -o $@ $^ $(NANOPB_CORE) - -run_tests: test_conversions encode_double decode_double - ./test_conversions - ./encode_double | ./decode_double - diff --git a/third_party/nanopb/examples/using_double_on_avr/README.txt b/third_party/nanopb/examples/using_double_on_avr/README.txt deleted file mode 100644 index d9fcdfc66d7..00000000000 --- a/third_party/nanopb/examples/using_double_on_avr/README.txt +++ /dev/null @@ -1,25 +0,0 @@ -Nanopb example "using_double_on_avr" -==================================== - -Some processors/compilers, such as AVR-GCC, do not support the double -datatype. Instead, they have sizeof(double) == 4. Because protocol -binary format uses the double encoding directly, this causes trouble -if the protocol in .proto requires double fields. - -This directory contains a solution to this problem. It uses uint64_t -to store the raw wire values, because its size is correct on all -platforms. The file double_conversion.c provides functions that -convert these values to/from floats, without relying on compiler -support. - -To use this method, you need to make some modifications to your code: - -1) Change all 'double' fields into 'fixed64' in the .proto. - -2) Whenever writing to a 'double' field, use float_to_double(). - -3) Whenever reading a 'double' field, use double_to_float(). - -The conversion routines are as accurate as the float datatype can -be. Furthermore, they should handle all special values (NaN, inf, denormalized -numbers) correctly. There are testcases in test_conversions.c. diff --git a/third_party/nanopb/examples/using_double_on_avr/decode_double.c b/third_party/nanopb/examples/using_double_on_avr/decode_double.c deleted file mode 100644 index 5802eca79e9..00000000000 --- a/third_party/nanopb/examples/using_double_on_avr/decode_double.c +++ /dev/null @@ -1,33 +0,0 @@ -/* Decodes a double value into a float variable. - * Used to read double values with AVR code, which doesn't support double directly. - */ - -#include -#include -#include "double_conversion.h" -#include "doubleproto.pb.h" - -int main() -{ - uint8_t buffer[32]; - size_t count = fread(buffer, 1, sizeof(buffer), stdin); - pb_istream_t stream = pb_istream_from_buffer(buffer, count); - - AVRDoubleMessage message; - pb_decode(&stream, AVRDoubleMessage_fields, &message); - - float v1 = double_to_float(message.field1); - float v2 = double_to_float(message.field2); - - printf("Values: %f %f\n", v1, v2); - - if (v1 == 1234.5678f && - v2 == 0.00001f) - { - return 0; - } - else - { - return 1; - } -} diff --git a/third_party/nanopb/examples/using_double_on_avr/double_conversion.c b/third_party/nanopb/examples/using_double_on_avr/double_conversion.c deleted file mode 100644 index cf79b9a00da..00000000000 --- a/third_party/nanopb/examples/using_double_on_avr/double_conversion.c +++ /dev/null @@ -1,123 +0,0 @@ -/* Conversion routines for platforms that do not support 'double' directly. */ - -#include "double_conversion.h" -#include - -typedef union { - float f; - uint32_t i; -} conversion_t; - -/* Note: IEE 754 standard specifies float formats as follows: - * Single precision: sign, 8-bit exp, 23-bit frac. - * Double precision: sign, 11-bit exp, 52-bit frac. - */ - -uint64_t float_to_double(float value) -{ - conversion_t in; - in.f = value; - uint8_t sign; - int16_t exponent; - uint64_t mantissa; - - /* Decompose input value */ - sign = (in.i >> 31) & 1; - exponent = ((in.i >> 23) & 0xFF) - 127; - mantissa = in.i & 0x7FFFFF; - - if (exponent == 128) - { - /* Special value (NaN etc.) */ - exponent = 1024; - } - else if (exponent == -127) - { - if (!mantissa) - { - /* Zero */ - exponent = -1023; - } - else - { - /* Denormalized */ - mantissa <<= 1; - while (!(mantissa & 0x800000)) - { - mantissa <<= 1; - exponent--; - } - mantissa &= 0x7FFFFF; - } - } - - /* Combine fields */ - mantissa <<= 29; - mantissa |= (uint64_t)(exponent + 1023) << 52; - mantissa |= (uint64_t)sign << 63; - - return mantissa; -} - -float double_to_float(uint64_t value) -{ - uint8_t sign; - int16_t exponent; - uint32_t mantissa; - conversion_t out; - - /* Decompose input value */ - sign = (value >> 63) & 1; - exponent = ((value >> 52) & 0x7FF) - 1023; - mantissa = (value >> 28) & 0xFFFFFF; /* Highest 24 bits */ - - /* Figure if value is in range representable by floats. */ - if (exponent == 1024) - { - /* Special value */ - exponent = 128; - } - else if (exponent > 127) - { - /* Too large */ - if (sign) - return -INFINITY; - else - return INFINITY; - } - else if (exponent < -150) - { - /* Too small */ - if (sign) - return -0.0f; - else - return 0.0f; - } - else if (exponent < -126) - { - /* Denormalized */ - mantissa |= 0x1000000; - mantissa >>= (-126 - exponent); - exponent = -127; - } - - /* Round off mantissa */ - mantissa = (mantissa + 1) >> 1; - - /* Check if mantissa went over 2.0 */ - if (mantissa & 0x800000) - { - exponent += 1; - mantissa &= 0x7FFFFF; - mantissa >>= 1; - } - - /* Combine fields */ - out.i = mantissa; - out.i |= (uint32_t)(exponent + 127) << 23; - out.i |= (uint32_t)sign << 31; - - return out.f; -} - - diff --git a/third_party/nanopb/examples/using_double_on_avr/double_conversion.h b/third_party/nanopb/examples/using_double_on_avr/double_conversion.h deleted file mode 100644 index 62b6a8ae8d3..00000000000 --- a/third_party/nanopb/examples/using_double_on_avr/double_conversion.h +++ /dev/null @@ -1,26 +0,0 @@ -/* AVR-GCC does not have real double datatype. Instead its double - * is equal to float, i.e. 32 bit value. If you need to communicate - * with other systems that use double in their .proto files, you - * need to do some conversion. - * - * These functions use bitwise operations to mangle floats into doubles - * and then store them in uint64_t datatype. - */ - -#ifndef DOUBLE_CONVERSION -#define DOUBLE_CONVERSION - -#include - -/* Convert native 4-byte float into a 8-byte double. */ -extern uint64_t float_to_double(float value); - -/* Convert 8-byte double into native 4-byte float. - * Values are rounded to nearest, 0.5 away from zero. - * Overflowing values are converted to Inf or -Inf. - */ -extern float double_to_float(uint64_t value); - - -#endif - diff --git a/third_party/nanopb/examples/using_double_on_avr/doubleproto.proto b/third_party/nanopb/examples/using_double_on_avr/doubleproto.proto deleted file mode 100644 index 72d3f9c127f..00000000000 --- a/third_party/nanopb/examples/using_double_on_avr/doubleproto.proto +++ /dev/null @@ -1,15 +0,0 @@ -// A message containing doubles, as used by other applications. -syntax = "proto2"; - -message DoubleMessage { - required double field1 = 1; - required double field2 = 2; -} - -// A message containing doubles, but redefined using uint64_t. -// For use in AVR code. -message AVRDoubleMessage { - required fixed64 field1 = 1; - required fixed64 field2 = 2; -} - diff --git a/third_party/nanopb/examples/using_double_on_avr/encode_double.c b/third_party/nanopb/examples/using_double_on_avr/encode_double.c deleted file mode 100644 index cd532d4659c..00000000000 --- a/third_party/nanopb/examples/using_double_on_avr/encode_double.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Encodes a float value into a double on the wire. - * Used to emit doubles from AVR code, which doesn't support double directly. - */ - -#include -#include -#include "double_conversion.h" -#include "doubleproto.pb.h" - -int main() -{ - AVRDoubleMessage message = { - float_to_double(1234.5678f), - float_to_double(0.00001f) - }; - - uint8_t buffer[32]; - pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - - pb_encode(&stream, AVRDoubleMessage_fields, &message); - fwrite(buffer, 1, stream.bytes_written, stdout); - - return 0; -} - diff --git a/third_party/nanopb/examples/using_double_on_avr/test_conversions.c b/third_party/nanopb/examples/using_double_on_avr/test_conversions.c deleted file mode 100644 index 22620a6ae94..00000000000 --- a/third_party/nanopb/examples/using_double_on_avr/test_conversions.c +++ /dev/null @@ -1,56 +0,0 @@ -#include "double_conversion.h" -#include -#include - -static const double testvalues[] = { - 0.0, -0.0, 0.1, -0.1, - M_PI, -M_PI, 123456.789, -123456.789, - INFINITY, -INFINITY, NAN, INFINITY - INFINITY, - 1e38, -1e38, 1e39, -1e39, - 1e-38, -1e-38, 1e-39, -1e-39, - 3.14159e-37,-3.14159e-37, 3.14159e-43, -3.14159e-43, - 1e-60, -1e-60, 1e-45, -1e-45, - 0.99999999999999, -0.99999999999999, 127.999999999999, -127.999999999999 -}; - -#define TESTVALUES_COUNT (sizeof(testvalues)/sizeof(testvalues[0])) - -int main() -{ - int status = 0; - int i; - for (i = 0; i < TESTVALUES_COUNT; i++) - { - double orig = testvalues[i]; - float expected_float = (float)orig; - double expected_double = (double)expected_float; - - float got_float = double_to_float(*(uint64_t*)&orig); - uint64_t got_double = float_to_double(got_float); - - uint32_t e1 = *(uint32_t*)&expected_float; - uint32_t g1 = *(uint32_t*)&got_float; - uint64_t e2 = *(uint64_t*)&expected_double; - uint64_t g2 = got_double; - - if (g1 != e1) - { - printf("%3d double_to_float fail: %08x != %08x\n", i, g1, e1); - status = 1; - } - - if (g2 != e2) - { - printf("%3d float_to_double fail: %016llx != %016llx\n", i, - (unsigned long long)g2, - (unsigned long long)e2); - status = 1; - } - } - - return status; -} - - - - diff --git a/third_party/nanopb/examples/using_union_messages/Makefile b/third_party/nanopb/examples/using_union_messages/Makefile deleted file mode 100644 index 66396a02eea..00000000000 --- a/third_party/nanopb/examples/using_union_messages/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# Include the nanopb provided Makefile rules -include ../../extra/nanopb.mk - -# Compiler flags to enable all warnings & debug info -CFLAGS = -ansi -Wall -Werror -g -O0 -CFLAGS += -I$(NANOPB_DIR) - -all: encode decode - ./encode 1 | ./decode - ./encode 2 | ./decode - ./encode 3 | ./decode - -.SUFFIXES: - -clean: - rm -f encode unionproto.pb.h unionproto.pb.c - -%: %.c unionproto.pb.c - $(CC) $(CFLAGS) -o $@ $^ $(NANOPB_CORE) - diff --git a/third_party/nanopb/examples/using_union_messages/README.txt b/third_party/nanopb/examples/using_union_messages/README.txt deleted file mode 100644 index 7a1e75d4116..00000000000 --- a/third_party/nanopb/examples/using_union_messages/README.txt +++ /dev/null @@ -1,52 +0,0 @@ -Nanopb example "using_union_messages" -===================================== - -Union messages is a common technique in Google Protocol Buffers used to -represent a group of messages, only one of which is passed at a time. -It is described in Google's documentation: -https://developers.google.com/protocol-buffers/docs/techniques#union - -This directory contains an example on how to encode and decode union messages -with minimal memory usage. Usually, nanopb would allocate space to store -all of the possible messages at the same time, even though at most one of -them will be used at a time. - -By using some of the lower level nanopb APIs, we can manually generate the -top level message, so that we only need to allocate the one submessage that -we actually want. Similarly when decoding, we can manually read the tag of -the top level message, and only then allocate the memory for the submessage -after we already know its type. - - -Example usage -------------- - -Type `make` to run the example. It will build it and run commands like -following: - -./encode 1 | ./decode -Got MsgType1: 42 -./encode 2 | ./decode -Got MsgType2: true -./encode 3 | ./decode -Got MsgType3: 3 1415 - -This simply demonstrates that the "decode" program has correctly identified -the type of the received message, and managed to decode it. - - -Details of implementation -------------------------- - -unionproto.proto contains the protocol used in the example. It consists of -three messages: MsgType1, MsgType2 and MsgType3, which are collected together -into UnionMessage. - -encode.c takes one command line argument, which should be a number 1-3. It -then fills in and encodes the corresponding message, and writes it to stdout. - -decode.c reads a UnionMessage from stdin. Then it calls the function -decode_unionmessage_type() to determine the type of the message. After that, -the corresponding message is decoded and the contents of it printed to the -screen. - diff --git a/third_party/nanopb/examples/using_union_messages/decode.c b/third_party/nanopb/examples/using_union_messages/decode.c deleted file mode 100644 index b9f4af55c50..00000000000 --- a/third_party/nanopb/examples/using_union_messages/decode.c +++ /dev/null @@ -1,96 +0,0 @@ -/* This program reads a message from stdin, detects its type and decodes it. - */ - -#include -#include -#include - -#include -#include "unionproto.pb.h" - -/* This function reads manually the first tag from the stream and finds the - * corresponding message type. It doesn't yet decode the actual message. - * - * Returns a pointer to the MsgType_fields array, as an identifier for the - * message type. Returns null if the tag is of unknown type or an error occurs. - */ -const pb_field_t* decode_unionmessage_type(pb_istream_t *stream) -{ - pb_wire_type_t wire_type; - uint32_t tag; - bool eof; - - while (pb_decode_tag(stream, &wire_type, &tag, &eof)) - { - if (wire_type == PB_WT_STRING) - { - const pb_field_t *field; - for (field = UnionMessage_fields; field->tag != 0; field++) - { - if (field->tag == tag && (field->type & PB_LTYPE_SUBMESSAGE)) - { - /* Found our field. */ - return field->ptr; - } - } - } - - /* Wasn't our field.. */ - pb_skip_field(stream, wire_type); - } - - return NULL; -} - -bool decode_unionmessage_contents(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct) -{ - pb_istream_t substream; - bool status; - if (!pb_make_string_substream(stream, &substream)) - return false; - - status = pb_decode(&substream, fields, dest_struct); - pb_close_string_substream(stream, &substream); - return status; -} - -int main() -{ - /* Read the data into buffer */ - uint8_t buffer[512]; - size_t count = fread(buffer, 1, sizeof(buffer), stdin); - pb_istream_t stream = pb_istream_from_buffer(buffer, count); - - const pb_field_t *type = decode_unionmessage_type(&stream); - bool status = false; - - if (type == MsgType1_fields) - { - MsgType1 msg = {}; - status = decode_unionmessage_contents(&stream, MsgType1_fields, &msg); - printf("Got MsgType1: %d\n", msg.value); - } - else if (type == MsgType2_fields) - { - MsgType2 msg = {}; - status = decode_unionmessage_contents(&stream, MsgType2_fields, &msg); - printf("Got MsgType2: %s\n", msg.value ? "true" : "false"); - } - else if (type == MsgType3_fields) - { - MsgType3 msg = {}; - status = decode_unionmessage_contents(&stream, MsgType3_fields, &msg); - printf("Got MsgType3: %d %d\n", msg.value1, msg.value2); - } - - if (!status) - { - printf("Decode failed: %s\n", PB_GET_ERROR(&stream)); - return 1; - } - - return 0; -} - - - diff --git a/third_party/nanopb/examples/using_union_messages/encode.c b/third_party/nanopb/examples/using_union_messages/encode.c deleted file mode 100644 index e124bf91fa3..00000000000 --- a/third_party/nanopb/examples/using_union_messages/encode.c +++ /dev/null @@ -1,85 +0,0 @@ -/* This program takes a command line argument and encodes a message in - * one of MsgType1, MsgType2 or MsgType3. - */ - -#include -#include -#include - -#include -#include "unionproto.pb.h" - -/* This function is the core of the union encoding process. It handles - * the top-level pb_field_t array manually, in order to encode a correct - * field tag before the message. The pointer to MsgType_fields array is - * used as an unique identifier for the message type. - */ -bool encode_unionmessage(pb_ostream_t *stream, const pb_field_t messagetype[], const void *message) -{ - const pb_field_t *field; - for (field = UnionMessage_fields; field->tag != 0; field++) - { - if (field->ptr == messagetype) - { - /* This is our field, encode the message using it. */ - if (!pb_encode_tag_for_field(stream, field)) - return false; - - return pb_encode_submessage(stream, messagetype, message); - } - } - - /* Didn't find the field for messagetype */ - return false; -} - -int main(int argc, char **argv) -{ - if (argc != 2) - { - fprintf(stderr, "Usage: %s (1|2|3)\n", argv[0]); - return 1; - } - - uint8_t buffer[512]; - pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - - bool status = false; - int msgtype = atoi(argv[1]); - if (msgtype == 1) - { - /* Send message of type 1 */ - MsgType1 msg = {42}; - status = encode_unionmessage(&stream, MsgType1_fields, &msg); - } - else if (msgtype == 2) - { - /* Send message of type 2 */ - MsgType2 msg = {true}; - status = encode_unionmessage(&stream, MsgType2_fields, &msg); - } - else if (msgtype == 3) - { - /* Send message of type 3 */ - MsgType3 msg = {3, 1415}; - status = encode_unionmessage(&stream, MsgType3_fields, &msg); - } - else - { - fprintf(stderr, "Unknown message type: %d\n", msgtype); - return 2; - } - - if (!status) - { - fprintf(stderr, "Encoding failed!\n"); - return 3; - } - else - { - fwrite(buffer, 1, stream.bytes_written, stdout); - return 0; /* Success */ - } -} - - diff --git a/third_party/nanopb/examples/using_union_messages/unionproto.proto b/third_party/nanopb/examples/using_union_messages/unionproto.proto deleted file mode 100644 index 209df0d27a0..00000000000 --- a/third_party/nanopb/examples/using_union_messages/unionproto.proto +++ /dev/null @@ -1,32 +0,0 @@ -// This is an example of how to handle 'union' style messages -// with nanopb, without allocating memory for all the message types. -// -// There is no official type in Protocol Buffers for describing unions, -// but they are commonly implemented by filling out exactly one of -// several optional fields. - -syntax = "proto2"; - -message MsgType1 -{ - required int32 value = 1; -} - -message MsgType2 -{ - required bool value = 1; -} - -message MsgType3 -{ - required int32 value1 = 1; - required int32 value2 = 2; -} - -message UnionMessage -{ - optional MsgType1 msg1 = 1; - optional MsgType2 msg2 = 2; - optional MsgType3 msg3 = 3; -} - diff --git a/third_party/nanopb/extra/FindNanopb.cmake b/third_party/nanopb/extra/FindNanopb.cmake deleted file mode 100644 index 9afb21d0b1f..00000000000 --- a/third_party/nanopb/extra/FindNanopb.cmake +++ /dev/null @@ -1,274 +0,0 @@ -# This is an example script for use with CMake projects for locating and configuring -# the nanopb library. -# -# The following variables can be set and are optional: -# -# -# PROTOBUF_SRC_ROOT_FOLDER - When compiling with MSVC, if this cache variable is set -# the protobuf-default VS project build locations -# (vsprojects/Debug & vsprojects/Release) will be searched -# for libraries and binaries. -# -# NANOPB_IMPORT_DIRS - List of additional directories to be searched for -# imported .proto files. -# -# NANOPB_GENERATE_CPP_APPEND_PATH - By default -I will be passed to protoc -# for each directory where a proto file is referenced. -# Set to FALSE if you want to disable this behaviour. -# -# Defines the following variables: -# -# NANOPB_FOUND - Found the nanopb library (source&header files, generator tool, protoc compiler tool) -# NANOPB_INCLUDE_DIRS - Include directories for Google Protocol Buffers -# -# The following cache variables are also available to set or use: -# PROTOBUF_PROTOC_EXECUTABLE - The protoc compiler -# NANOPB_GENERATOR_SOURCE_DIR - The nanopb generator source -# -# ==================================================================== -# -# NANOPB_GENERATE_CPP (public function) -# SRCS = Variable to define with autogenerated -# source files -# HDRS = Variable to define with autogenerated -# header files -# ARGN = proto files -# -# ==================================================================== -# Example: -# -# set(NANOPB_SRC_ROOT_FOLDER "/path/to/nanopb") -# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${NANOPB_SRC_ROOT_FOLDER}/cmake) -# find_package( Nanopb REQUIRED ) -# include_directories(${NANOPB_INCLUDE_DIRS}) -# -# NANOPB_GENERATE_CPP(PROTO_SRCS PROTO_HDRS foo.proto) -# -# include_directories(${CMAKE_CURRENT_BINARY_DIR}) -# add_executable(bar bar.cc ${PROTO_SRCS} ${PROTO_HDRS}) -# -# ==================================================================== - -#============================================================================= -# Copyright 2009 Kitware, Inc. -# Copyright 2009-2011 Philip Lowman -# Copyright 2008 Esben Mose Hansen, Ange Optimization ApS -# -# 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 names of Kitware, Inc., the Insight Software Consortium, -# nor the names of their 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 -# HOLDER 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. -# -#============================================================================= -# -# Changes -# 2013.01.31 - Pavlo Ilin - used Modules/FindProtobuf.cmake from cmake 2.8.10 to -# write FindNanopb.cmake -# -#============================================================================= - - -function(NANOPB_GENERATE_CPP SRCS HDRS) - if(NOT ARGN) - return() - endif() - - if(NANOPB_GENERATE_CPP_APPEND_PATH) - # Create an include path for each file specified - foreach(FIL ${ARGN}) - get_filename_component(ABS_FIL ${FIL} ABSOLUTE) - get_filename_component(ABS_PATH ${ABS_FIL} PATH) - - list(FIND _nanobp_include_path ${ABS_PATH} _contains_already) - if(${_contains_already} EQUAL -1) - list(APPEND _nanobp_include_path -I ${ABS_PATH}) - endif() - endforeach() - else() - set(_nanobp_include_path -I ${CMAKE_CURRENT_SOURCE_DIR}) - endif() - - if(DEFINED NANOPB_IMPORT_DIRS) - foreach(DIR ${NANOPB_IMPORT_DIRS}) - get_filename_component(ABS_PATH ${DIR} ABSOLUTE) - list(FIND _nanobp_include_path ${ABS_PATH} _contains_already) - if(${_contains_already} EQUAL -1) - list(APPEND _nanobp_include_path -I ${ABS_PATH}) - endif() - endforeach() - endif() - - set(${SRCS}) - set(${HDRS}) - - set(GENERATOR_PATH ${CMAKE_BINARY_DIR}/nanopb/generator) - - set(NANOPB_GENERATOR_EXECUTABLE ${GENERATOR_PATH}/nanopb_generator.py) - - set(GENERATOR_CORE_DIR ${GENERATOR_PATH}/proto) - set(GENERATOR_CORE_SRC - ${GENERATOR_CORE_DIR}/nanopb.proto - ${GENERATOR_CORE_DIR}/plugin.proto) - - # Treat the source diretory as immutable. - # - # Copy the generator directory to the build directory before - # compiling python and proto files. Fixes issues when using the - # same build directory with different python/protobuf versions - # as the binary build directory is discarded across builds. - # - add_custom_command( - OUTPUT ${NANOPB_GENERATOR_EXECUTABLE} ${GENERATOR_CORE_SRC} - COMMAND ${CMAKE_COMMAND} -E copy_directory - ARGS ${NANOPB_GENERATOR_SOURCE_DIR} ${GENERATOR_PATH} - VERBATIM) - - set(GENERATOR_CORE_PYTHON_SRC) - foreach(FIL ${GENERATOR_CORE_SRC}) - get_filename_component(ABS_FIL ${FIL} ABSOLUTE) - get_filename_component(FIL_WE ${FIL} NAME_WE) - - set(output "${GENERATOR_CORE_DIR}/${FIL_WE}_pb2.py") - set(GENERATOR_CORE_PYTHON_SRC ${GENERATOR_CORE_PYTHON_SRC} ${output}) - add_custom_command( - OUTPUT ${output} - COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} - ARGS -I${GENERATOR_PATH}/proto - --python_out=${GENERATOR_CORE_DIR} ${ABS_FIL} - DEPENDS ${ABS_FIL} - VERBATIM) - endforeach() - - foreach(FIL ${ARGN}) - get_filename_component(ABS_FIL ${FIL} ABSOLUTE) - get_filename_component(FIL_WE ${FIL} NAME_WE) - get_filename_component(FIL_DIR ${FIL} PATH) - set(NANOPB_OPTIONS_FILE ${FIL_DIR}/${FIL_WE}.options) - set(NANOPB_OPTIONS) - if(EXISTS ${NANOPB_OPTIONS_FILE}) - set(NANOPB_OPTIONS -f ${NANOPB_OPTIONS_FILE}) - endif() - - list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.c") - list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h") - - add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb" - COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} - ARGS -I${GENERATOR_PATH} -I${GENERATOR_CORE_DIR} - -I${CMAKE_CURRENT_BINARY_DIR} ${_nanobp_include_path} - -o${FIL_WE}.pb ${ABS_FIL} - DEPENDS ${ABS_FIL} ${GENERATOR_CORE_PYTHON_SRC} - COMMENT "Running C++ protocol buffer compiler on ${FIL}" - VERBATIM ) - - add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.c" - "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h" - COMMAND ${PYTHON_EXECUTABLE} - ARGS ${NANOPB_GENERATOR_EXECUTABLE} ${FIL_WE}.pb ${NANOPB_OPTIONS} - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb" - COMMENT "Running nanopb generator on ${FIL_WE}.pb" - VERBATIM ) - endforeach() - - set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE) - set(${SRCS} ${${SRCS}} ${NANOPB_SRCS} PARENT_SCOPE) - set(${HDRS} ${${HDRS}} ${NANOPB_HDRS} PARENT_SCOPE) - -endfunction() - - - -# -# Main. -# - -# By default have NANOPB_GENERATE_CPP macro pass -I to protoc -# for each directory where a proto file is referenced. -if(NOT DEFINED NANOPB_GENERATE_CPP_APPEND_PATH) - set(NANOPB_GENERATE_CPP_APPEND_PATH TRUE) -endif() - -# Make a really good guess regarding location of NANOPB_SRC_ROOT_FOLDER -if(NOT DEFINED NANOPB_SRC_ROOT_FOLDER) - get_filename_component(NANOPB_SRC_ROOT_FOLDER - ${CMAKE_CURRENT_LIST_DIR}/.. ABSOLUTE) -endif() - -# Find the include directory -find_path(NANOPB_INCLUDE_DIRS - pb.h - PATHS ${NANOPB_SRC_ROOT_FOLDER} -) -mark_as_advanced(NANOPB_INCLUDE_DIRS) - -# Find nanopb source files -set(NANOPB_SRCS) -set(NANOPB_HDRS) -list(APPEND _nanopb_srcs pb_decode.c pb_encode.c pb_common.c) -list(APPEND _nanopb_hdrs pb_decode.h pb_encode.h pb_common.h pb.h) - -foreach(FIL ${_nanopb_srcs}) - find_file(${FIL}__nano_pb_file NAMES ${FIL} PATHS ${NANOPB_SRC_ROOT_FOLDER} ${NANOPB_INCLUDE_DIRS}) - list(APPEND NANOPB_SRCS "${${FIL}__nano_pb_file}") - mark_as_advanced(${FIL}__nano_pb_file) -endforeach() - -foreach(FIL ${_nanopb_hdrs}) - find_file(${FIL}__nano_pb_file NAMES ${FIL} PATHS ${NANOPB_INCLUDE_DIRS}) - mark_as_advanced(${FIL}__nano_pb_file) - list(APPEND NANOPB_HDRS "${${FIL}__nano_pb_file}") -endforeach() - -# Find the protoc Executable -find_program(PROTOBUF_PROTOC_EXECUTABLE - NAMES protoc - DOC "The Google Protocol Buffers Compiler" - PATHS - ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/Release - ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/Debug -) -mark_as_advanced(PROTOBUF_PROTOC_EXECUTABLE) - -# Find nanopb generator source dir -find_path(NANOPB_GENERATOR_SOURCE_DIR - NAMES nanopb_generator.py - DOC "nanopb generator source" - PATHS - ${NANOPB_SRC_ROOT_FOLDER}/generator -) -mark_as_advanced(NANOPB_GENERATOR_SOURCE_DIR) - -find_package(PythonInterp REQUIRED) - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(NANOPB DEFAULT_MSG - NANOPB_INCLUDE_DIRS - NANOPB_SRCS NANOPB_HDRS - NANOPB_GENERATOR_SOURCE_DIR - PROTOBUF_PROTOC_EXECUTABLE - ) diff --git a/third_party/nanopb/extra/nanopb.mk b/third_party/nanopb/extra/nanopb.mk deleted file mode 100644 index 5c2cff560c5..00000000000 --- a/third_party/nanopb/extra/nanopb.mk +++ /dev/null @@ -1,37 +0,0 @@ -# This is an include file for Makefiles. It provides rules for building -# .pb.c and .pb.h files out of .proto, as well the path to nanopb core. - -# Path to the nanopb root directory -NANOPB_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))../) - -# Files for the nanopb core -NANOPB_CORE = $(NANOPB_DIR)/pb_encode.c $(NANOPB_DIR)/pb_decode.c $(NANOPB_DIR)/pb_common.c - -# Check if we are running on Windows -ifdef windir -WINDOWS = 1 -endif -ifdef WINDIR -WINDOWS = 1 -endif - -# Check whether to use binary version of nanopb_generator or the -# system-supplied python interpreter. -ifneq "$(wildcard $(NANOPB_DIR)/generator-bin)" "" - # Binary package - PROTOC = $(NANOPB_DIR)/generator-bin/protoc - PROTOC_OPTS = -else - # Source only or git checkout - PROTOC = protoc - ifdef WINDOWS - PROTOC_OPTS = --plugin=protoc-gen-nanopb=$(NANOPB_DIR)/generator/protoc-gen-nanopb.bat - else - PROTOC_OPTS = --plugin=protoc-gen-nanopb=$(NANOPB_DIR)/generator/protoc-gen-nanopb - endif -endif - -# Rule for building .pb.c and .pb.h -%.pb.c %.pb.h: %.proto $(wildcard %.options) - $(PROTOC) $(PROTOC_OPTS) --nanopb_out=. $< - diff --git a/third_party/nanopb/extra/pb_syshdr.h b/third_party/nanopb/extra/pb_syshdr.h deleted file mode 100644 index 55d06a3acc0..00000000000 --- a/third_party/nanopb/extra/pb_syshdr.h +++ /dev/null @@ -1,112 +0,0 @@ -/* This is an example of a header file for platforms/compilers that do - * not come with stdint.h/stddef.h/stdbool.h/string.h. To use it, define - * PB_SYSTEM_HEADER as "pb_syshdr.h", including the quotes, and add the - * extra folder to your include path. - * - * It is very likely that you will need to customize this file to suit - * your platform. For any compiler that supports C99, this file should - * not be necessary. - */ - -#ifndef _PB_SYSHDR_H_ -#define _PB_SYSHDR_H_ - -/* stdint.h subset */ -#ifdef HAVE_STDINT_H -#include -#else -/* You will need to modify these to match the word size of your platform. */ -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef signed long long int64_t; -typedef unsigned long long uint64_t; - -/* These are ok for most platforms, unless uint8_t is actually not available, - * in which case you should give the smallest available type. */ -typedef int8_t int_least8_t; -typedef uint8_t uint_least8_t; -typedef uint8_t uint_fast8_t; -typedef int16_t int_least16_t; -typedef uint16_t uint_least16_t; -#endif - -/* stddef.h subset */ -#ifdef HAVE_STDDEF_H -#include -#else - -typedef uint32_t size_t; -#define offsetof(st, m) ((size_t)(&((st *)0)->m)) - -#ifndef NULL -#define NULL 0 -#endif - -#endif - -/* stdbool.h subset */ -#ifdef HAVE_STDBOOL_H -#include -#else - -#ifndef __cplusplus -typedef int bool; -#define false 0 -#define true 1 -#endif - -#endif - -/* stdlib.h subset */ -#ifdef PB_ENABLE_MALLOC -#ifdef HAVE_STDLIB_H -#include -#else -void *realloc(void *ptr, size_t size); -void free(void *ptr); -#endif -#endif - -/* string.h subset */ -#ifdef HAVE_STRING_H -#include -#else - -/* Implementations are from the Public Domain C Library (PDCLib). */ -static size_t strlen( const char * s ) -{ - size_t rc = 0; - while ( s[rc] ) - { - ++rc; - } - return rc; -} - -static void * memcpy( void *s1, const void *s2, size_t n ) -{ - char * dest = (char *) s1; - const char * src = (const char *) s2; - while ( n-- ) - { - *dest++ = *src++; - } - return s1; -} - -static void * memset( void * s, int c, size_t n ) -{ - unsigned char * p = (unsigned char *) s; - while ( n-- ) - { - *p++ = (unsigned char) c; - } - return s; -} -#endif - -#endif diff --git a/third_party/nanopb/generator/nanopb_generator.py b/third_party/nanopb/generator/nanopb_generator.py deleted file mode 100755 index 973c7610fbe..00000000000 --- a/third_party/nanopb/generator/nanopb_generator.py +++ /dev/null @@ -1,1602 +0,0 @@ -#!/usr/bin/env python - -from __future__ import unicode_literals - -'''Generate header file for nanopb from a ProtoBuf FileDescriptorSet.''' -nanopb_version = "nanopb-0.3.7-dev" - -import sys -import re -from functools import reduce - -try: - # Add some dummy imports to keep packaging tools happy. - import google, distutils.util # bbfreeze seems to need these - import pkg_resources # pyinstaller / protobuf 2.5 seem to need these -except: - # Don't care, we will error out later if it is actually important. - pass - -try: - import google.protobuf.text_format as text_format - import google.protobuf.descriptor_pb2 as descriptor -except: - sys.stderr.write(''' - ************************************************************* - *** Could not import the Google protobuf Python libraries *** - *** Try installing package 'python-protobuf' or similar. *** - ************************************************************* - ''' + '\n') - raise - -try: - import proto.nanopb_pb2 as nanopb_pb2 - import proto.plugin_pb2 as plugin_pb2 -except: - sys.stderr.write(''' - ******************************************************************** - *** Failed to import the protocol definitions for generator. *** - *** You have to run 'make' in the nanopb/generator/proto folder. *** - ******************************************************************** - ''' + '\n') - raise - -# --------------------------------------------------------------------------- -# Generation of single fields -# --------------------------------------------------------------------------- - -import time -import os.path - -# Values are tuple (c type, pb type, encoded size, int_size_allowed) -FieldD = descriptor.FieldDescriptorProto -datatypes = { - FieldD.TYPE_BOOL: ('bool', 'BOOL', 1, False), - FieldD.TYPE_DOUBLE: ('double', 'DOUBLE', 8, False), - FieldD.TYPE_FIXED32: ('uint32_t', 'FIXED32', 4, False), - FieldD.TYPE_FIXED64: ('uint64_t', 'FIXED64', 8, False), - FieldD.TYPE_FLOAT: ('float', 'FLOAT', 4, False), - FieldD.TYPE_INT32: ('int32_t', 'INT32', 10, True), - FieldD.TYPE_INT64: ('int64_t', 'INT64', 10, True), - FieldD.TYPE_SFIXED32: ('int32_t', 'SFIXED32', 4, False), - FieldD.TYPE_SFIXED64: ('int64_t', 'SFIXED64', 8, False), - FieldD.TYPE_SINT32: ('int32_t', 'SINT32', 5, True), - FieldD.TYPE_SINT64: ('int64_t', 'SINT64', 10, True), - FieldD.TYPE_UINT32: ('uint32_t', 'UINT32', 5, True), - FieldD.TYPE_UINT64: ('uint64_t', 'UINT64', 10, True) -} - -# Integer size overrides (from .proto settings) -intsizes = { - nanopb_pb2.IS_8: 'int8_t', - nanopb_pb2.IS_16: 'int16_t', - nanopb_pb2.IS_32: 'int32_t', - nanopb_pb2.IS_64: 'int64_t', -} - -# String types (for python 2 / python 3 compatibility) -try: - strtypes = (unicode, str) -except NameError: - strtypes = (str, ) - -class Names: - '''Keeps a set of nested names and formats them to C identifier.''' - def __init__(self, parts = ()): - if isinstance(parts, Names): - parts = parts.parts - self.parts = tuple(parts) - - def __str__(self): - return '_'.join(self.parts) - - def __add__(self, other): - if isinstance(other, strtypes): - return Names(self.parts + (other,)) - elif isinstance(other, tuple): - return Names(self.parts + other) - else: - raise ValueError("Name parts should be of type str") - - def __eq__(self, other): - return isinstance(other, Names) and self.parts == other.parts - -def names_from_type_name(type_name): - '''Parse Names() from FieldDescriptorProto type_name''' - if type_name[0] != '.': - raise NotImplementedError("Lookup of non-absolute type names is not supported") - return Names(type_name[1:].split('.')) - -def varint_max_size(max_value): - '''Returns the maximum number of bytes a varint can take when encoded.''' - if max_value < 0: - max_value = 2**64 - max_value - for i in range(1, 11): - if (max_value >> (i * 7)) == 0: - return i - raise ValueError("Value too large for varint: " + str(max_value)) - -assert varint_max_size(-1) == 10 -assert varint_max_size(0) == 1 -assert varint_max_size(127) == 1 -assert varint_max_size(128) == 2 - -class EncodedSize: - '''Class used to represent the encoded size of a field or a message. - Consists of a combination of symbolic sizes and integer sizes.''' - def __init__(self, value = 0, symbols = []): - if isinstance(value, EncodedSize): - self.value = value.value - self.symbols = value.symbols - elif isinstance(value, strtypes + (Names,)): - self.symbols = [str(value)] - self.value = 0 - else: - self.value = value - self.symbols = symbols - - def __add__(self, other): - if isinstance(other, int): - return EncodedSize(self.value + other, self.symbols) - elif isinstance(other, strtypes + (Names,)): - return EncodedSize(self.value, self.symbols + [str(other)]) - elif isinstance(other, EncodedSize): - return EncodedSize(self.value + other.value, self.symbols + other.symbols) - else: - raise ValueError("Cannot add size: " + repr(other)) - - def __mul__(self, other): - if isinstance(other, int): - return EncodedSize(self.value * other, [str(other) + '*' + s for s in self.symbols]) - else: - raise ValueError("Cannot multiply size: " + repr(other)) - - def __str__(self): - if not self.symbols: - return str(self.value) - else: - return '(' + str(self.value) + ' + ' + ' + '.join(self.symbols) + ')' - - def upperlimit(self): - if not self.symbols: - return self.value - else: - return 2**32 - 1 - -class Enum: - def __init__(self, names, desc, enum_options): - '''desc is EnumDescriptorProto''' - - self.options = enum_options - self.names = names + desc.name - - if enum_options.long_names: - self.values = [(self.names + x.name, x.number) for x in desc.value] - else: - self.values = [(names + x.name, x.number) for x in desc.value] - - self.value_longnames = [self.names + x.name for x in desc.value] - self.packed = enum_options.packed_enum - - def has_negative(self): - for n, v in self.values: - if v < 0: - return True - return False - - def encoded_size(self): - return max([varint_max_size(v) for n,v in self.values]) - - def __str__(self): - result = 'typedef enum _%s {\n' % self.names - result += ',\n'.join([" %s = %d" % x for x in self.values]) - result += '\n}' - - if self.packed: - result += ' pb_packed' - - result += ' %s;' % self.names - - result += '\n#define _%s_MIN %s' % (self.names, self.values[0][0]) - result += '\n#define _%s_MAX %s' % (self.names, self.values[-1][0]) - result += '\n#define _%s_ARRAYSIZE ((%s)(%s+1))' % (self.names, self.names, self.values[-1][0]) - - if not self.options.long_names: - # Define the long names always so that enum value references - # from other files work properly. - for i, x in enumerate(self.values): - result += '\n#define %s %s' % (self.value_longnames[i], x[0]) - - return result - -class FieldMaxSize: - def __init__(self, worst = 0, checks = [], field_name = 'undefined'): - if isinstance(worst, list): - self.worst = max(i for i in worst if i is not None) - else: - self.worst = worst - - self.worst_field = field_name - self.checks = list(checks) - - def extend(self, extend, field_name = None): - self.worst = max(self.worst, extend.worst) - - if self.worst == extend.worst: - self.worst_field = extend.worst_field - - self.checks.extend(extend.checks) - -class Field: - def __init__(self, struct_name, desc, field_options): - '''desc is FieldDescriptorProto''' - self.tag = desc.number - self.struct_name = struct_name - self.union_name = None - self.name = desc.name - self.default = None - self.max_size = None - self.max_count = None - self.array_decl = "" - self.enc_size = None - self.ctype = None - - self.inline = None - if field_options.type == nanopb_pb2.FT_INLINE: - field_options.type = nanopb_pb2.FT_STATIC - self.inline = nanopb_pb2.FT_INLINE - - # Parse field options - if field_options.HasField("max_size"): - self.max_size = field_options.max_size - - if field_options.HasField("max_count"): - self.max_count = field_options.max_count - - if desc.HasField('default_value'): - self.default = desc.default_value - - # Check field rules, i.e. required/optional/repeated. - can_be_static = True - if desc.label == FieldD.LABEL_REQUIRED: - self.rules = 'REQUIRED' - elif desc.label == FieldD.LABEL_OPTIONAL: - self.rules = 'OPTIONAL' - elif desc.label == FieldD.LABEL_REPEATED: - self.rules = 'REPEATED' - if self.max_count is None: - can_be_static = False - else: - self.array_decl = '[%d]' % self.max_count - else: - raise NotImplementedError(desc.label) - - # Check if the field can be implemented with static allocation - # i.e. whether the data size is known. - if desc.type == FieldD.TYPE_STRING and self.max_size is None: - can_be_static = False - - if desc.type == FieldD.TYPE_BYTES and self.max_size is None: - can_be_static = False - - # Decide how the field data will be allocated - if field_options.type == nanopb_pb2.FT_DEFAULT: - if can_be_static: - field_options.type = nanopb_pb2.FT_STATIC - else: - field_options.type = nanopb_pb2.FT_CALLBACK - - if field_options.type == nanopb_pb2.FT_STATIC and not can_be_static: - raise Exception("Field %s is defined as static, but max_size or " - "max_count is not given." % self.name) - - if field_options.type == nanopb_pb2.FT_STATIC: - self.allocation = 'STATIC' - elif field_options.type == nanopb_pb2.FT_POINTER: - self.allocation = 'POINTER' - elif field_options.type == nanopb_pb2.FT_CALLBACK: - self.allocation = 'CALLBACK' - else: - raise NotImplementedError(field_options.type) - - # Decide the C data type to use in the struct. - if desc.type in datatypes: - self.ctype, self.pbtype, self.enc_size, isa = datatypes[desc.type] - - # Override the field size if user wants to use smaller integers - if isa and field_options.int_size != nanopb_pb2.IS_DEFAULT: - self.ctype = intsizes[field_options.int_size] - if desc.type == FieldD.TYPE_UINT32 or desc.type == FieldD.TYPE_UINT64: - self.ctype = 'u' + self.ctype; - elif desc.type == FieldD.TYPE_ENUM: - self.pbtype = 'ENUM' - self.ctype = names_from_type_name(desc.type_name) - if self.default is not None: - self.default = self.ctype + self.default - self.enc_size = None # Needs to be filled in when enum values are known - elif desc.type == FieldD.TYPE_STRING: - self.pbtype = 'STRING' - self.ctype = 'char' - if self.allocation == 'STATIC': - self.ctype = 'char' - self.array_decl += '[%d]' % self.max_size - self.enc_size = varint_max_size(self.max_size) + self.max_size - elif desc.type == FieldD.TYPE_BYTES: - self.pbtype = 'BYTES' - if self.allocation == 'STATIC': - # Inline STATIC for BYTES is like STATIC for STRING. - if self.inline: - self.ctype = 'pb_byte_t' - self.array_decl += '[%d]' % self.max_size - else: - self.ctype = self.struct_name + self.name + 't' - self.enc_size = varint_max_size(self.max_size) + self.max_size - elif self.allocation == 'POINTER': - self.ctype = 'pb_bytes_array_t' - elif desc.type == FieldD.TYPE_MESSAGE: - self.pbtype = 'MESSAGE' - self.ctype = self.submsgname = names_from_type_name(desc.type_name) - self.enc_size = None # Needs to be filled in after the message type is available - else: - raise NotImplementedError(desc.type) - - def __lt__(self, other): - return self.tag < other.tag - - def __str__(self): - result = '' - if self.allocation == 'POINTER': - if self.rules == 'REPEATED': - result += ' pb_size_t ' + self.name + '_count;\n' - - if self.pbtype == 'MESSAGE': - # Use struct definition, so recursive submessages are possible - result += ' struct _%s *%s;' % (self.ctype, self.name) - elif self.rules == 'REPEATED' and self.pbtype in ['STRING', 'BYTES']: - # String/bytes arrays need to be defined as pointers to pointers - result += ' %s **%s;' % (self.ctype, self.name) - else: - result += ' %s *%s;' % (self.ctype, self.name) - elif self.allocation == 'CALLBACK': - result += ' pb_callback_t %s;' % self.name - else: - if self.rules == 'OPTIONAL' and self.allocation == 'STATIC': - result += ' bool has_' + self.name + ';\n' - elif self.rules == 'REPEATED' and self.allocation == 'STATIC': - result += ' pb_size_t ' + self.name + '_count;\n' - result += ' %s %s%s;' % (self.ctype, self.name, self.array_decl) - return result - - def types(self): - '''Return definitions for any special types this field might need.''' - if self.pbtype == 'BYTES' and self.allocation == 'STATIC' and not self.inline: - result = 'typedef PB_BYTES_ARRAY_T(%d) %s;\n' % (self.max_size, self.ctype) - else: - result = '' - return result - - def get_dependencies(self): - '''Get list of type names used by this field.''' - if self.allocation == 'STATIC': - return [str(self.ctype)] - else: - return [] - - def get_initializer(self, null_init, inner_init_only = False): - '''Return literal expression for this field's default value. - null_init: If True, initialize to a 0 value instead of default from .proto - inner_init_only: If True, exclude initialization for any count/has fields - ''' - - inner_init = None - if self.pbtype == 'MESSAGE': - if null_init: - inner_init = '%s_init_zero' % self.ctype - else: - inner_init = '%s_init_default' % self.ctype - elif self.default is None or null_init: - if self.pbtype == 'STRING': - inner_init = '""' - elif self.pbtype == 'BYTES': - if self.inline: - inner_init = '{0}' - else: - inner_init = '{0, {0}}' - elif self.pbtype in ('ENUM', 'UENUM'): - inner_init = '(%s)0' % self.ctype - else: - inner_init = '0' - else: - if self.pbtype == 'STRING': - inner_init = self.default.replace('"', '\\"') - inner_init = '"' + inner_init + '"' - elif self.pbtype == 'BYTES': - data = ['0x%02x' % ord(c) for c in self.default] - if len(data) == 0: - if self.inline: - inner_init = '{0}' - else: - inner_init = '{0, {0}}' - else: - if self.inline: - inner_init = '{%s}' % ','.join(data) - else: - inner_init = '{%d, {%s}}' % (len(data), ','.join(data)) - elif self.pbtype in ['FIXED32', 'UINT32']: - inner_init = str(self.default) + 'u' - elif self.pbtype in ['FIXED64', 'UINT64']: - inner_init = str(self.default) + 'ull' - elif self.pbtype in ['SFIXED64', 'INT64']: - inner_init = str(self.default) + 'll' - else: - inner_init = str(self.default) - - if inner_init_only: - return inner_init - - outer_init = None - if self.allocation == 'STATIC': - if self.rules == 'REPEATED': - outer_init = '0, {' - outer_init += ', '.join([inner_init] * self.max_count) - outer_init += '}' - elif self.rules == 'OPTIONAL': - outer_init = 'false, ' + inner_init - else: - outer_init = inner_init - elif self.allocation == 'POINTER': - if self.rules == 'REPEATED': - outer_init = '0, NULL' - else: - outer_init = 'NULL' - elif self.allocation == 'CALLBACK': - if self.pbtype == 'EXTENSION': - outer_init = 'NULL' - else: - outer_init = '{{NULL}, NULL}' - - return outer_init - - def default_decl(self, declaration_only = False): - '''Return definition for this field's default value.''' - if self.default is None: - return None - - ctype = self.ctype - default = self.get_initializer(False, True) - array_decl = '' - - if self.pbtype == 'STRING': - if self.allocation != 'STATIC': - return None # Not implemented - array_decl = '[%d]' % self.max_size - elif self.pbtype == 'BYTES': - if self.allocation != 'STATIC': - return None # Not implemented - if self.inline: - array_decl = '[%d]' % self.max_size - - if declaration_only: - return 'extern const %s %s_default%s;' % (ctype, self.struct_name + self.name, array_decl) - else: - return 'const %s %s_default%s = %s;' % (ctype, self.struct_name + self.name, array_decl, default) - - def tags(self): - '''Return the #define for the tag number of this field.''' - identifier = '%s_%s_tag' % (self.struct_name, self.name) - return '#define %-40s %d\n' % (identifier, self.tag) - - def pb_field_t(self, prev_field_name): - '''Return the pb_field_t initializer to use in the constant array. - prev_field_name is the name of the previous field or None. - ''' - - if self.rules == 'ONEOF': - if self.anonymous: - result = ' PB_ANONYMOUS_ONEOF_FIELD(%s, ' % self.union_name - else: - result = ' PB_ONEOF_FIELD(%s, ' % self.union_name - else: - result = ' PB_FIELD(' - - result += '%3d, ' % self.tag - result += '%-8s, ' % self.pbtype - result += '%s, ' % self.rules - result += '%-8s, ' % (self.allocation if not self.inline else "INLINE") - result += '%s, ' % ("FIRST" if not prev_field_name else "OTHER") - result += '%s, ' % self.struct_name - result += '%s, ' % self.name - result += '%s, ' % (prev_field_name or self.name) - - if self.pbtype == 'MESSAGE': - result += '&%s_fields)' % self.submsgname - elif self.default is None: - result += '0)' - elif self.pbtype in ['BYTES', 'STRING'] and self.allocation != 'STATIC': - result += '0)' # Arbitrary size default values not implemented - elif self.rules == 'OPTEXT': - result += '0)' # Default value for extensions is not implemented - else: - result += '&%s_default)' % (self.struct_name + self.name) - - return result - - def get_last_field_name(self): - return self.name - - def largest_field_value(self): - '''Determine if this field needs 16bit or 32bit pb_field_t structure to compile properly. - Returns numeric value or a C-expression for assert.''' - check = [] - if self.pbtype == 'MESSAGE': - if self.rules == 'REPEATED' and self.allocation == 'STATIC': - check.append('pb_membersize(%s, %s[0])' % (self.struct_name, self.name)) - elif self.rules == 'ONEOF': - if self.anonymous: - check.append('pb_membersize(%s, %s)' % (self.struct_name, self.name)) - else: - check.append('pb_membersize(%s, %s.%s)' % (self.struct_name, self.union_name, self.name)) - else: - check.append('pb_membersize(%s, %s)' % (self.struct_name, self.name)) - - return FieldMaxSize([self.tag, self.max_size, self.max_count], - check, - ('%s.%s' % (self.struct_name, self.name))) - - def encoded_size(self, dependencies): - '''Return the maximum size that this field can take when encoded, - including the field tag. If the size cannot be determined, returns - None.''' - - if self.allocation != 'STATIC': - return None - - if self.pbtype == 'MESSAGE': - encsize = None - if str(self.submsgname) in dependencies: - submsg = dependencies[str(self.submsgname)] - encsize = submsg.encoded_size(dependencies) - if encsize is not None: - # Include submessage length prefix - encsize += varint_max_size(encsize.upperlimit()) - - if encsize is None: - # Submessage or its size cannot be found. - # This can occur if submessage is defined in different - # file, and it or its .options could not be found. - # Instead of direct numeric value, reference the size that - # has been #defined in the other file. - encsize = EncodedSize(self.submsgname + 'size') - - # We will have to make a conservative assumption on the length - # prefix size, though. - encsize += 5 - - elif self.pbtype in ['ENUM', 'UENUM']: - if str(self.ctype) in dependencies: - enumtype = dependencies[str(self.ctype)] - encsize = enumtype.encoded_size() - else: - # Conservative assumption - encsize = 10 - - elif self.enc_size is None: - raise RuntimeError("Could not determine encoded size for %s.%s" - % (self.struct_name, self.name)) - else: - encsize = EncodedSize(self.enc_size) - - encsize += varint_max_size(self.tag << 3) # Tag + wire type - - if self.rules == 'REPEATED': - # Decoders must be always able to handle unpacked arrays. - # Therefore we have to reserve space for it, even though - # we emit packed arrays ourselves. - encsize *= self.max_count - - return encsize - - -class ExtensionRange(Field): - def __init__(self, struct_name, range_start, field_options): - '''Implements a special pb_extension_t* field in an extensible message - structure. The range_start signifies the index at which the extensions - start. Not necessarily all tags above this are extensions, it is merely - a speed optimization. - ''' - self.tag = range_start - self.struct_name = struct_name - self.name = 'extensions' - self.pbtype = 'EXTENSION' - self.rules = 'OPTIONAL' - self.allocation = 'CALLBACK' - self.ctype = 'pb_extension_t' - self.array_decl = '' - self.default = None - self.max_size = 0 - self.max_count = 0 - self.inline = None - - def __str__(self): - return ' pb_extension_t *extensions;' - - def types(self): - return '' - - def tags(self): - return '' - - def encoded_size(self, dependencies): - # We exclude extensions from the count, because they cannot be known - # until runtime. Other option would be to return None here, but this - # way the value remains useful if extensions are not used. - return EncodedSize(0) - -class ExtensionField(Field): - def __init__(self, struct_name, desc, field_options): - self.fullname = struct_name + desc.name - self.extendee_name = names_from_type_name(desc.extendee) - Field.__init__(self, self.fullname + 'struct', desc, field_options) - - if self.rules != 'OPTIONAL': - self.skip = True - else: - self.skip = False - self.rules = 'OPTEXT' - - def tags(self): - '''Return the #define for the tag number of this field.''' - identifier = '%s_tag' % self.fullname - return '#define %-40s %d\n' % (identifier, self.tag) - - def extension_decl(self): - '''Declaration of the extension type in the .pb.h file''' - if self.skip: - msg = '/* Extension field %s was skipped because only "optional"\n' % self.fullname - msg +=' type of extension fields is currently supported. */\n' - return msg - - return ('extern const pb_extension_type_t %s; /* field type: %s */\n' % - (self.fullname, str(self).strip())) - - def extension_def(self): - '''Definition of the extension type in the .pb.c file''' - - if self.skip: - return '' - - result = 'typedef struct {\n' - result += str(self) - result += '\n} %s;\n\n' % self.struct_name - result += ('static const pb_field_t %s_field = \n %s;\n\n' % - (self.fullname, self.pb_field_t(None))) - result += 'const pb_extension_type_t %s = {\n' % self.fullname - result += ' NULL,\n' - result += ' NULL,\n' - result += ' &%s_field\n' % self.fullname - result += '};\n' - return result - - -# --------------------------------------------------------------------------- -# Generation of oneofs (unions) -# --------------------------------------------------------------------------- - -class OneOf(Field): - def __init__(self, struct_name, oneof_desc): - self.struct_name = struct_name - self.name = oneof_desc.name - self.ctype = 'union' - self.pbtype = 'oneof' - self.fields = [] - self.allocation = 'ONEOF' - self.default = None - self.rules = 'ONEOF' - self.anonymous = False - self.inline = None - - def add_field(self, field): - if field.allocation == 'CALLBACK': - raise Exception("Callback fields inside of oneof are not supported" - + " (field %s)" % field.name) - - field.union_name = self.name - field.rules = 'ONEOF' - field.anonymous = self.anonymous - self.fields.append(field) - self.fields.sort(key = lambda f: f.tag) - - # Sort by the lowest tag number inside union - self.tag = min([f.tag for f in self.fields]) - - def __str__(self): - result = '' - if self.fields: - result += ' pb_size_t which_' + self.name + ";\n" - result += ' union {\n' - for f in self.fields: - result += ' ' + str(f).replace('\n', '\n ') + '\n' - if self.anonymous: - result += ' };' - else: - result += ' } ' + self.name + ';' - return result - - def types(self): - return ''.join([f.types() for f in self.fields]) - - def get_dependencies(self): - deps = [] - for f in self.fields: - deps += f.get_dependencies() - return deps - - def get_initializer(self, null_init): - return '0, {' + self.fields[0].get_initializer(null_init) + '}' - - def default_decl(self, declaration_only = False): - return None - - def tags(self): - return ''.join([f.tags() for f in self.fields]) - - def pb_field_t(self, prev_field_name): - result = ',\n'.join([f.pb_field_t(prev_field_name) for f in self.fields]) - return result - - def get_last_field_name(self): - if self.anonymous: - return self.fields[-1].name - else: - return self.name + '.' + self.fields[-1].name - - def largest_field_value(self): - largest = FieldMaxSize() - for f in self.fields: - largest.extend(f.largest_field_value()) - return largest - - def encoded_size(self, dependencies): - '''Returns the size of the largest oneof field.''' - largest = EncodedSize(0) - for f in self.fields: - size = EncodedSize(f.encoded_size(dependencies)) - if size.value is None: - return None - elif size.symbols: - return None # Cannot resolve maximum of symbols - elif size.value > largest.value: - largest = size - - return largest - -# --------------------------------------------------------------------------- -# Generation of messages (structures) -# --------------------------------------------------------------------------- - - -class Message: - def __init__(self, names, desc, message_options): - self.name = names - self.fields = [] - self.oneofs = {} - no_unions = [] - - if message_options.msgid: - self.msgid = message_options.msgid - - if hasattr(desc, 'oneof_decl'): - for i, f in enumerate(desc.oneof_decl): - oneof_options = get_nanopb_suboptions(desc, message_options, self.name + f.name) - if oneof_options.no_unions: - no_unions.append(i) # No union, but add fields normally - elif oneof_options.type == nanopb_pb2.FT_IGNORE: - pass # No union and skip fields also - else: - oneof = OneOf(self.name, f) - if oneof_options.anonymous_oneof: - oneof.anonymous = True - self.oneofs[i] = oneof - self.fields.append(oneof) - - for f in desc.field: - field_options = get_nanopb_suboptions(f, message_options, self.name + f.name) - if field_options.type == nanopb_pb2.FT_IGNORE: - continue - - field = Field(self.name, f, field_options) - if (hasattr(f, 'oneof_index') and - f.HasField('oneof_index') and - f.oneof_index not in no_unions): - if f.oneof_index in self.oneofs: - self.oneofs[f.oneof_index].add_field(field) - else: - self.fields.append(field) - - if len(desc.extension_range) > 0: - field_options = get_nanopb_suboptions(desc, message_options, self.name + 'extensions') - range_start = min([r.start for r in desc.extension_range]) - if field_options.type != nanopb_pb2.FT_IGNORE: - self.fields.append(ExtensionRange(self.name, range_start, field_options)) - - self.packed = message_options.packed_struct - self.ordered_fields = self.fields[:] - self.ordered_fields.sort() - - def get_dependencies(self): - '''Get list of type names that this structure refers to.''' - deps = [] - for f in self.fields: - deps += f.get_dependencies() - return deps - - def __str__(self): - result = 'typedef struct _%s {\n' % self.name - - if not self.ordered_fields: - # Empty structs are not allowed in C standard. - # Therefore add a dummy field if an empty message occurs. - result += ' char dummy_field;' - - result += '\n'.join([str(f) for f in self.ordered_fields]) - result += '\n/* @@protoc_insertion_point(struct:%s) */' % self.name - result += '\n}' - - if self.packed: - result += ' pb_packed' - - result += ' %s;' % self.name - - if self.packed: - result = 'PB_PACKED_STRUCT_START\n' + result - result += '\nPB_PACKED_STRUCT_END' - - return result - - def types(self): - return ''.join([f.types() for f in self.fields]) - - def get_initializer(self, null_init): - if not self.ordered_fields: - return '{0}' - - parts = [] - for field in self.ordered_fields: - parts.append(field.get_initializer(null_init)) - return '{' + ', '.join(parts) + '}' - - def default_decl(self, declaration_only = False): - result = "" - for field in self.fields: - default = field.default_decl(declaration_only) - if default is not None: - result += default + '\n' - return result - - def count_required_fields(self): - '''Returns number of required fields inside this message''' - count = 0 - for f in self.fields: - if not isinstance(f, OneOf): - if f.rules == 'REQUIRED': - count += 1 - return count - - def count_all_fields(self): - count = 0 - for f in self.fields: - if isinstance(f, OneOf): - count += len(f.fields) - else: - count += 1 - return count - - def fields_declaration(self): - result = 'extern const pb_field_t %s_fields[%d];' % (self.name, self.count_all_fields() + 1) - return result - - def fields_definition(self): - result = 'const pb_field_t %s_fields[%d] = {\n' % (self.name, self.count_all_fields() + 1) - - prev = None - for field in self.ordered_fields: - result += field.pb_field_t(prev) - result += ',\n' - prev = field.get_last_field_name() - - result += ' PB_LAST_FIELD\n};' - return result - - def encoded_size(self, dependencies): - '''Return the maximum size that this message can take when encoded. - If the size cannot be determined, returns None. - ''' - size = EncodedSize(0) - for field in self.fields: - fsize = field.encoded_size(dependencies) - if fsize is None: - return None - size += fsize - - return size - - -# --------------------------------------------------------------------------- -# Processing of entire .proto files -# --------------------------------------------------------------------------- - -def iterate_messages(desc, names = Names()): - '''Recursively find all messages. For each, yield name, DescriptorProto.''' - if hasattr(desc, 'message_type'): - submsgs = desc.message_type - else: - submsgs = desc.nested_type - - for submsg in submsgs: - sub_names = names + submsg.name - yield sub_names, submsg - - for x in iterate_messages(submsg, sub_names): - yield x - -def iterate_extensions(desc, names = Names()): - '''Recursively find all extensions. - For each, yield name, FieldDescriptorProto. - ''' - for extension in desc.extension: - yield names, extension - - for subname, subdesc in iterate_messages(desc, names): - for extension in subdesc.extension: - yield subname, extension - -def toposort2(data): - '''Topological sort. - From http://code.activestate.com/recipes/577413-topological-sort/ - This function is under the MIT license. - ''' - for k, v in list(data.items()): - v.discard(k) # Ignore self dependencies - extra_items_in_deps = reduce(set.union, list(data.values()), set()) - set(data.keys()) - data.update(dict([(item, set()) for item in extra_items_in_deps])) - while True: - ordered = set(item for item,dep in list(data.items()) if not dep) - if not ordered: - break - for item in sorted(ordered): - yield item - data = dict([(item, (dep - ordered)) for item,dep in list(data.items()) - if item not in ordered]) - assert not data, "A cyclic dependency exists amongst %r" % data - -def sort_dependencies(messages): - '''Sort a list of Messages based on dependencies.''' - dependencies = {} - message_by_name = {} - for message in messages: - dependencies[str(message.name)] = set(message.get_dependencies()) - message_by_name[str(message.name)] = message - - for msgname in toposort2(dependencies): - if msgname in message_by_name: - yield message_by_name[msgname] - -def make_identifier(headername): - '''Make #ifndef identifier that contains uppercase A-Z and digits 0-9''' - result = "" - for c in headername.upper(): - if c.isalnum(): - result += c - else: - result += '_' - return result - -class ProtoFile: - def __init__(self, fdesc, file_options): - '''Takes a FileDescriptorProto and parses it.''' - self.fdesc = fdesc - self.file_options = file_options - self.dependencies = {} - self.parse() - - # Some of types used in this file probably come from the file itself. - # Thus it has implicit dependency on itself. - self.add_dependency(self) - - def parse(self): - self.enums = [] - self.messages = [] - self.extensions = [] - - if self.fdesc.package: - base_name = Names(self.fdesc.package.split('.')) - else: - base_name = Names() - - for enum in self.fdesc.enum_type: - enum_options = get_nanopb_suboptions(enum, self.file_options, base_name + enum.name) - self.enums.append(Enum(base_name, enum, enum_options)) - - for names, message in iterate_messages(self.fdesc, base_name): - message_options = get_nanopb_suboptions(message, self.file_options, names) - - if message_options.skip_message: - continue - - self.messages.append(Message(names, message, message_options)) - for enum in message.enum_type: - enum_options = get_nanopb_suboptions(enum, message_options, names + enum.name) - self.enums.append(Enum(names, enum, enum_options)) - - for names, extension in iterate_extensions(self.fdesc, base_name): - field_options = get_nanopb_suboptions(extension, self.file_options, names + extension.name) - if field_options.type != nanopb_pb2.FT_IGNORE: - self.extensions.append(ExtensionField(names, extension, field_options)) - - def add_dependency(self, other): - for enum in other.enums: - self.dependencies[str(enum.names)] = enum - - for msg in other.messages: - self.dependencies[str(msg.name)] = msg - - # Fix field default values where enum short names are used. - for enum in other.enums: - if not enum.options.long_names: - for message in self.messages: - for field in message.fields: - if field.default in enum.value_longnames: - idx = enum.value_longnames.index(field.default) - field.default = enum.values[idx][0] - - # Fix field data types where enums have negative values. - for enum in other.enums: - if not enum.has_negative(): - for message in self.messages: - for field in message.fields: - if field.pbtype == 'ENUM' and field.ctype == enum.names: - field.pbtype = 'UENUM' - - def generate_header(self, includes, headername, options): - '''Generate content for a header file. - Generates strings, which should be concatenated and stored to file. - ''' - - yield '/* Automatically generated nanopb header */\n' - if options.notimestamp: - yield '/* Generated by %s */\n\n' % (nanopb_version) - else: - yield '/* Generated by %s at %s. */\n\n' % (nanopb_version, time.asctime()) - - if self.fdesc.package: - symbol = make_identifier(self.fdesc.package + '_' + headername) - else: - symbol = make_identifier(headername) - yield '#ifndef PB_%s_INCLUDED\n' % symbol - yield '#define PB_%s_INCLUDED\n' % symbol - try: - yield options.libformat % ('pb.h') - except TypeError: - # no %s specified - use whatever was passed in as options.libformat - yield options.libformat - yield '\n' - - for incfile in includes: - noext = os.path.splitext(incfile)[0] - yield options.genformat % (noext + options.extension + '.h') - yield '\n' - - yield '/* @@protoc_insertion_point(includes) */\n' - - yield '#if PB_PROTO_HEADER_VERSION != 30\n' - yield '#error Regenerate this file with the current version of nanopb generator.\n' - yield '#endif\n' - yield '\n' - - yield '#ifdef __cplusplus\n' - yield 'extern "C" {\n' - yield '#endif\n\n' - - if self.enums: - yield '/* Enum definitions */\n' - for enum in self.enums: - yield str(enum) + '\n\n' - - if self.messages: - yield '/* Struct definitions */\n' - for msg in sort_dependencies(self.messages): - yield msg.types() - yield str(msg) + '\n\n' - - if self.extensions: - yield '/* Extensions */\n' - for extension in self.extensions: - yield extension.extension_decl() - yield '\n' - - if self.messages: - yield '/* Default values for struct fields */\n' - for msg in self.messages: - yield msg.default_decl(True) - yield '\n' - - yield '/* Initializer values for message structs */\n' - for msg in self.messages: - identifier = '%s_init_default' % msg.name - yield '#define %-40s %s\n' % (identifier, msg.get_initializer(False)) - for msg in self.messages: - identifier = '%s_init_zero' % msg.name - yield '#define %-40s %s\n' % (identifier, msg.get_initializer(True)) - yield '\n' - - yield '/* Field tags (for use in manual encoding/decoding) */\n' - for msg in sort_dependencies(self.messages): - for field in msg.fields: - yield field.tags() - for extension in self.extensions: - yield extension.tags() - yield '\n' - - yield '/* Struct field encoding specification for nanopb */\n' - for msg in self.messages: - yield msg.fields_declaration() + '\n' - yield '\n' - - yield '/* Maximum encoded size of messages (where known) */\n' - for msg in self.messages: - msize = msg.encoded_size(self.dependencies) - identifier = '%s_size' % msg.name - if msize is not None: - yield '#define %-40s %s\n' % (identifier, msize) - else: - yield '/* %s depends on runtime parameters */\n' % identifier - yield '\n' - - yield '/* Message IDs (where set with "msgid" option) */\n' - - yield '#ifdef PB_MSGID\n' - for msg in self.messages: - if hasattr(msg,'msgid'): - yield '#define PB_MSG_%d %s\n' % (msg.msgid, msg.name) - yield '\n' - - symbol = make_identifier(headername.split('.')[0]) - yield '#define %s_MESSAGES \\\n' % symbol - - for msg in self.messages: - m = "-1" - msize = msg.encoded_size(self.dependencies) - if msize is not None: - m = msize - if hasattr(msg,'msgid'): - yield '\tPB_MSG(%d,%s,%s) \\\n' % (msg.msgid, m, msg.name) - yield '\n' - - for msg in self.messages: - if hasattr(msg,'msgid'): - yield '#define %s_msgid %d\n' % (msg.name, msg.msgid) - yield '\n' - - yield '#endif\n\n' - - yield '#ifdef __cplusplus\n' - yield '} /* extern "C" */\n' - yield '#endif\n' - - # End of header - yield '/* @@protoc_insertion_point(eof) */\n' - yield '\n#endif\n' - - def generate_source(self, headername, options): - '''Generate content for a source file.''' - - yield '/* Automatically generated nanopb constant definitions */\n' - if options.notimestamp: - yield '/* Generated by %s */\n\n' % (nanopb_version) - else: - yield '/* Generated by %s at %s. */\n\n' % (nanopb_version, time.asctime()) - yield options.genformat % (headername) - yield '\n' - yield '/* @@protoc_insertion_point(includes) */\n' - - yield '#if PB_PROTO_HEADER_VERSION != 30\n' - yield '#error Regenerate this file with the current version of nanopb generator.\n' - yield '#endif\n' - yield '\n' - - for msg in self.messages: - yield msg.default_decl(False) - - yield '\n\n' - - for msg in self.messages: - yield msg.fields_definition() + '\n\n' - - for ext in self.extensions: - yield ext.extension_def() + '\n' - - # Add checks for numeric limits - if self.messages: - largest_msg = max(self.messages, key = lambda m: m.count_required_fields()) - largest_count = largest_msg.count_required_fields() - if largest_count > 64: - yield '\n/* Check that missing required fields will be properly detected */\n' - yield '#if PB_MAX_REQUIRED_FIELDS < %d\n' % largest_count - yield '#error Properly detecting missing required fields in %s requires \\\n' % largest_msg.name - yield ' setting PB_MAX_REQUIRED_FIELDS to %d or more.\n' % largest_count - yield '#endif\n' - - max_field = FieldMaxSize() - checks_msgnames = [] - for msg in self.messages: - checks_msgnames.append(msg.name) - for field in msg.fields: - max_field.extend(field.largest_field_value()) - - worst = max_field.worst - worst_field = max_field.worst_field - checks = max_field.checks - - if worst > 255 or checks: - yield '\n/* Check that field information fits in pb_field_t */\n' - - if worst > 65535 or checks: - yield '#if !defined(PB_FIELD_32BIT)\n' - if worst > 65535: - yield '#error Field descriptor for %s is too large. Define PB_FIELD_32BIT to fix this.\n' % worst_field - else: - assertion = ' && '.join(str(c) + ' < 65536' for c in checks) - msgs = '_'.join(str(n) for n in checks_msgnames) - yield '/* If you get an error here, it means that you need to define PB_FIELD_32BIT\n' - yield ' * compile-time option. You can do that in pb.h or on compiler command line.\n' - yield ' * \n' - yield ' * The reason you need to do this is that some of your messages contain tag\n' - yield ' * numbers or field sizes that are larger than what can fit in 8 or 16 bit\n' - yield ' * field descriptors.\n' - yield ' */\n' - yield 'PB_STATIC_ASSERT((%s), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_%s)\n'%(assertion,msgs) - yield '#endif\n\n' - - if worst < 65536: - yield '#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT)\n' - if worst > 255: - yield '#error Field descriptor for %s is too large. Define PB_FIELD_16BIT to fix this.\n' % worst_field - else: - assertion = ' && '.join(str(c) + ' < 256' for c in checks) - msgs = '_'.join(str(n) for n in checks_msgnames) - yield '/* If you get an error here, it means that you need to define PB_FIELD_16BIT\n' - yield ' * compile-time option. You can do that in pb.h or on compiler command line.\n' - yield ' * \n' - yield ' * The reason you need to do this is that some of your messages contain tag\n' - yield ' * numbers or field sizes that are larger than what can fit in the default\n' - yield ' * 8 bit descriptors.\n' - yield ' */\n' - yield 'PB_STATIC_ASSERT((%s), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_%s)\n'%(assertion,msgs) - yield '#endif\n\n' - - # Add check for sizeof(double) - has_double = False - for msg in self.messages: - for field in msg.fields: - if field.ctype == 'double': - has_double = True - - if has_double: - yield '\n' - yield '/* On some platforms (such as AVR), double is really float.\n' - yield ' * These are not directly supported by nanopb, but see example_avr_double.\n' - yield ' * To get rid of this error, remove any double fields from your .proto.\n' - yield ' */\n' - yield 'PB_STATIC_ASSERT(sizeof(double) == 8, DOUBLE_MUST_BE_8_BYTES)\n' - - yield '\n' - yield '/* @@protoc_insertion_point(eof) */\n' - -# --------------------------------------------------------------------------- -# Options parsing for the .proto files -# --------------------------------------------------------------------------- - -from fnmatch import fnmatch - -def read_options_file(infile): - '''Parse a separate options file to list: - [(namemask, options), ...] - ''' - results = [] - data = infile.read() - data = re.sub('/\*.*?\*/', '', data, flags = re.MULTILINE) - data = re.sub('//.*?$', '', data, flags = re.MULTILINE) - data = re.sub('#.*?$', '', data, flags = re.MULTILINE) - for i, line in enumerate(data.split('\n')): - line = line.strip() - if not line: - continue - - parts = line.split(None, 1) - - if len(parts) < 2: - sys.stderr.write("%s:%d: " % (infile.name, i + 1) + - "Option lines should have space between field name and options. " + - "Skipping line: '%s'\n" % line) - continue - - opts = nanopb_pb2.NanoPBOptions() - - try: - text_format.Merge(parts[1], opts) - except Exception as e: - sys.stderr.write("%s:%d: " % (infile.name, i + 1) + - "Unparseable option line: '%s'. " % line + - "Error: %s\n" % str(e)) - continue - results.append((parts[0], opts)) - - return results - -class Globals: - '''Ugly global variables, should find a good way to pass these.''' - verbose_options = False - separate_options = [] - matched_namemasks = set() - -def get_nanopb_suboptions(subdesc, options, name): - '''Get copy of options, and merge information from subdesc.''' - new_options = nanopb_pb2.NanoPBOptions() - new_options.CopyFrom(options) - - # Handle options defined in a separate file - dotname = '.'.join(name.parts) - for namemask, options in Globals.separate_options: - if fnmatch(dotname, namemask): - Globals.matched_namemasks.add(namemask) - new_options.MergeFrom(options) - - # Handle options defined in .proto - if isinstance(subdesc.options, descriptor.FieldOptions): - ext_type = nanopb_pb2.nanopb - elif isinstance(subdesc.options, descriptor.FileOptions): - ext_type = nanopb_pb2.nanopb_fileopt - elif isinstance(subdesc.options, descriptor.MessageOptions): - ext_type = nanopb_pb2.nanopb_msgopt - elif isinstance(subdesc.options, descriptor.EnumOptions): - ext_type = nanopb_pb2.nanopb_enumopt - else: - raise Exception("Unknown options type") - - if subdesc.options.HasExtension(ext_type): - ext = subdesc.options.Extensions[ext_type] - new_options.MergeFrom(ext) - - if Globals.verbose_options: - sys.stderr.write("Options for " + dotname + ": ") - sys.stderr.write(text_format.MessageToString(new_options) + "\n") - - return new_options - - -# --------------------------------------------------------------------------- -# Command line interface -# --------------------------------------------------------------------------- - -import sys -import os.path -from optparse import OptionParser - -optparser = OptionParser( - usage = "Usage: nanopb_generator.py [options] file.pb ...", - epilog = "Compile file.pb from file.proto by: 'protoc -ofile.pb file.proto'. " + - "Output will be written to file.pb.h and file.pb.c.") -optparser.add_option("-x", dest="exclude", metavar="FILE", action="append", default=[], - help="Exclude file from generated #include list.") -optparser.add_option("-e", "--extension", dest="extension", metavar="EXTENSION", default=".pb", - help="Set extension to use instead of '.pb' for generated files. [default: %default]") -optparser.add_option("-f", "--options-file", dest="options_file", metavar="FILE", default="%s.options", - help="Set name of a separate generator options file.") -optparser.add_option("-I", "--options-path", dest="options_path", metavar="DIR", - action="append", default = [], - help="Search for .options files additionally in this path") -optparser.add_option("-D", "--output-dir", dest="output_dir", - metavar="OUTPUTDIR", default=None, - help="Output directory of .pb.h and .pb.c files") -optparser.add_option("-Q", "--generated-include-format", dest="genformat", - metavar="FORMAT", default='#include "%s"\n', - help="Set format string to use for including other .pb.h files. [default: %default]") -optparser.add_option("-L", "--library-include-format", dest="libformat", - metavar="FORMAT", default='#include <%s>\n', - help="Set format string to use for including the nanopb pb.h header. [default: %default]") -optparser.add_option("-T", "--no-timestamp", dest="notimestamp", action="store_true", default=False, - help="Don't add timestamp to .pb.h and .pb.c preambles") -optparser.add_option("-q", "--quiet", dest="quiet", action="store_true", default=False, - help="Don't print anything except errors.") -optparser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False, - help="Print more information.") -optparser.add_option("-s", dest="settings", metavar="OPTION:VALUE", action="append", default=[], - help="Set generator option (max_size, max_count etc.).") - -def parse_file(filename, fdesc, options): - '''Parse a single file. Returns a ProtoFile instance.''' - toplevel_options = nanopb_pb2.NanoPBOptions() - for s in options.settings: - text_format.Merge(s, toplevel_options) - - if not fdesc: - data = open(filename, 'rb').read() - fdesc = descriptor.FileDescriptorSet.FromString(data).file[0] - - # Check if there is a separate .options file - had_abspath = False - try: - optfilename = options.options_file % os.path.splitext(filename)[0] - except TypeError: - # No %s specified, use the filename as-is - optfilename = options.options_file - had_abspath = True - - paths = ['.'] + options.options_path - for p in paths: - if os.path.isfile(os.path.join(p, optfilename)): - optfilename = os.path.join(p, optfilename) - if options.verbose: - sys.stderr.write('Reading options from ' + optfilename + '\n') - Globals.separate_options = read_options_file(open(optfilename, "rU")) - break - else: - # If we are given a full filename and it does not exist, give an error. - # However, don't give error when we automatically look for .options file - # with the same name as .proto. - if options.verbose or had_abspath: - sys.stderr.write('Options file not found: ' + optfilename + '\n') - Globals.separate_options = [] - - Globals.matched_namemasks = set() - - # Parse the file - file_options = get_nanopb_suboptions(fdesc, toplevel_options, Names([filename])) - f = ProtoFile(fdesc, file_options) - f.optfilename = optfilename - - return f - -def process_file(filename, fdesc, options, other_files = {}): - '''Process a single file. - filename: The full path to the .proto or .pb source file, as string. - fdesc: The loaded FileDescriptorSet, or None to read from the input file. - options: Command line options as they come from OptionsParser. - - Returns a dict: - {'headername': Name of header file, - 'headerdata': Data for the .h header file, - 'sourcename': Name of the source code file, - 'sourcedata': Data for the .c source code file - } - ''' - f = parse_file(filename, fdesc, options) - - # Provide dependencies if available - for dep in f.fdesc.dependency: - if dep in other_files: - f.add_dependency(other_files[dep]) - - # Decide the file names - noext = os.path.splitext(filename)[0] - headername = noext + options.extension + '.h' - sourcename = noext + options.extension + '.c' - headerbasename = os.path.basename(headername) - - # List of .proto files that should not be included in the C header file - # even if they are mentioned in the source .proto. - excludes = ['nanopb.proto', 'google/protobuf/descriptor.proto'] + options.exclude - includes = [d for d in f.fdesc.dependency if d not in excludes] - - headerdata = ''.join(f.generate_header(includes, headerbasename, options)) - sourcedata = ''.join(f.generate_source(headerbasename, options)) - - # Check if there were any lines in .options that did not match a member - unmatched = [n for n,o in Globals.separate_options if n not in Globals.matched_namemasks] - if unmatched and not options.quiet: - sys.stderr.write("Following patterns in " + f.optfilename + " did not match any fields: " - + ', '.join(unmatched) + "\n") - if not Globals.verbose_options: - sys.stderr.write("Use protoc --nanopb-out=-v:. to see a list of the field names.\n") - - return {'headername': headername, 'headerdata': headerdata, - 'sourcename': sourcename, 'sourcedata': sourcedata} - -def main_cli(): - '''Main function when invoked directly from the command line.''' - - options, filenames = optparser.parse_args() - - if not filenames: - optparser.print_help() - sys.exit(1) - - if options.quiet: - options.verbose = False - - if options.output_dir and not os.path.exists(options.output_dir): - optparser.print_help() - sys.stderr.write("\noutput_dir does not exist: %s\n" % options.output_dir) - sys.exit(1) - - - Globals.verbose_options = options.verbose - for filename in filenames: - results = process_file(filename, None, options) - - base_dir = options.output_dir or '' - to_write = [ - (os.path.join(base_dir, results['headername']), results['headerdata']), - (os.path.join(base_dir, results['sourcename']), results['sourcedata']), - ] - - if not options.quiet: - paths = " and ".join([x[0] for x in to_write]) - sys.stderr.write("Writing to %s\n" % paths) - - for path, data in to_write: - with open(path, 'w') as f: - f.write(data) - -def main_plugin(): - '''Main function when invoked as a protoc plugin.''' - - import io, sys - if sys.platform == "win32": - import os, msvcrt - # Set stdin and stdout to binary mode - msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) - msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) - - data = io.open(sys.stdin.fileno(), "rb").read() - - request = plugin_pb2.CodeGeneratorRequest.FromString(data) - - try: - # Versions of Python prior to 2.7.3 do not support unicode - # input to shlex.split(). Try to convert to str if possible. - params = str(request.parameter) - except UnicodeEncodeError: - params = request.parameter - - import shlex - args = shlex.split(params) - options, dummy = optparser.parse_args(args) - - Globals.verbose_options = options.verbose - - response = plugin_pb2.CodeGeneratorResponse() - - # Google's protoc does not currently indicate the full path of proto files. - # Instead always add the main file path to the search dirs, that works for - # the common case. - import os.path - options.options_path.append(os.path.dirname(request.file_to_generate[0])) - - # Process any include files first, in order to have them - # available as dependencies - other_files = {} - for fdesc in request.proto_file: - other_files[fdesc.name] = parse_file(fdesc.name, fdesc, options) - - for filename in request.file_to_generate: - for fdesc in request.proto_file: - if fdesc.name == filename: - results = process_file(filename, fdesc, options, other_files) - - f = response.file.add() - f.name = results['headername'] - f.content = results['headerdata'] - - f = response.file.add() - f.name = results['sourcename'] - f.content = results['sourcedata'] - - io.open(sys.stdout.fileno(), "wb").write(response.SerializeToString()) - -if __name__ == '__main__': - # Check if we are running as a plugin under protoc - if 'protoc-gen-' in sys.argv[0] or '--protoc-plugin' in sys.argv: - main_plugin() - else: - main_cli() diff --git a/third_party/nanopb/generator/proto/Makefile b/third_party/nanopb/generator/proto/Makefile deleted file mode 100644 index 89bfe52864e..00000000000 --- a/third_party/nanopb/generator/proto/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: nanopb_pb2.py plugin_pb2.py - -%_pb2.py: %.proto - protoc --python_out=. $< diff --git a/third_party/nanopb/generator/proto/__init__.py b/third_party/nanopb/generator/proto/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/third_party/nanopb/generator/proto/google/protobuf/descriptor.proto b/third_party/nanopb/generator/proto/google/protobuf/descriptor.proto deleted file mode 100644 index e17c0cc8abb..00000000000 --- a/third_party/nanopb/generator/proto/google/protobuf/descriptor.proto +++ /dev/null @@ -1,714 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// 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. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// The messages in this file describe the definitions found in .proto files. -// A valid .proto file can be translated directly to a FileDescriptorProto -// without any other information (e.g. without reading its imports). - - -syntax = "proto2"; - -package google.protobuf; -option java_package = "com.google.protobuf"; -option java_outer_classname = "DescriptorProtos"; - -// descriptor.proto must be optimized for speed because reflection-based -// algorithms don't work during bootstrapping. -option optimize_for = SPEED; - -// The protocol compiler can output a FileDescriptorSet containing the .proto -// files it parses. -message FileDescriptorSet { - repeated FileDescriptorProto file = 1; -} - -// Describes a complete .proto file. -message FileDescriptorProto { - optional string name = 1; // file name, relative to root of source tree - optional string package = 2; // e.g. "foo", "foo.bar", etc. - - // Names of files imported by this file. - repeated string dependency = 3; - // Indexes of the public imported files in the dependency list above. - repeated int32 public_dependency = 10; - // Indexes of the weak imported files in the dependency list. - // For Google-internal migration only. Do not use. - repeated int32 weak_dependency = 11; - - // All top-level definitions in this file. - repeated DescriptorProto message_type = 4; - repeated EnumDescriptorProto enum_type = 5; - repeated ServiceDescriptorProto service = 6; - repeated FieldDescriptorProto extension = 7; - - optional FileOptions options = 8; - - // This field contains optional information about the original source code. - // You may safely remove this entire field without harming runtime - // functionality of the descriptors -- the information is needed only by - // development tools. - optional SourceCodeInfo source_code_info = 9; - - // The syntax of the proto file. - // The supported values are "proto2" and "proto3". - optional string syntax = 12; -} - -// Describes a message type. -message DescriptorProto { - optional string name = 1; - - repeated FieldDescriptorProto field = 2; - repeated FieldDescriptorProto extension = 6; - - repeated DescriptorProto nested_type = 3; - repeated EnumDescriptorProto enum_type = 4; - - message ExtensionRange { - optional int32 start = 1; - optional int32 end = 2; - } - repeated ExtensionRange extension_range = 5; - - repeated OneofDescriptorProto oneof_decl = 8; - - optional MessageOptions options = 7; -} - -// Describes a field within a message. -message FieldDescriptorProto { - enum Type { - // 0 is reserved for errors. - // Order is weird for historical reasons. - TYPE_DOUBLE = 1; - TYPE_FLOAT = 2; - // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if - // negative values are likely. - TYPE_INT64 = 3; - TYPE_UINT64 = 4; - // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if - // negative values are likely. - TYPE_INT32 = 5; - TYPE_FIXED64 = 6; - TYPE_FIXED32 = 7; - TYPE_BOOL = 8; - TYPE_STRING = 9; - TYPE_GROUP = 10; // Tag-delimited aggregate. - TYPE_MESSAGE = 11; // Length-delimited aggregate. - - // New in version 2. - TYPE_BYTES = 12; - TYPE_UINT32 = 13; - TYPE_ENUM = 14; - TYPE_SFIXED32 = 15; - TYPE_SFIXED64 = 16; - TYPE_SINT32 = 17; // Uses ZigZag encoding. - TYPE_SINT64 = 18; // Uses ZigZag encoding. - }; - - enum Label { - // 0 is reserved for errors - LABEL_OPTIONAL = 1; - LABEL_REQUIRED = 2; - LABEL_REPEATED = 3; - // TODO(sanjay): Should we add LABEL_MAP? - }; - - optional string name = 1; - optional int32 number = 3; - optional Label label = 4; - - // If type_name is set, this need not be set. If both this and type_name - // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. - optional Type type = 5; - - // For message and enum types, this is the name of the type. If the name - // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping - // rules are used to find the type (i.e. first the nested types within this - // message are searched, then within the parent, on up to the root - // namespace). - optional string type_name = 6; - - // For extensions, this is the name of the type being extended. It is - // resolved in the same manner as type_name. - optional string extendee = 2; - - // For numeric types, contains the original text representation of the value. - // For booleans, "true" or "false". - // For strings, contains the default text contents (not escaped in any way). - // For bytes, contains the C escaped value. All bytes >= 128 are escaped. - // TODO(kenton): Base-64 encode? - optional string default_value = 7; - - // If set, gives the index of a oneof in the containing type's oneof_decl - // list. This field is a member of that oneof. Extensions of a oneof should - // not set this since the oneof to which they belong will be inferred based - // on the extension range containing the extension's field number. - optional int32 oneof_index = 9; - - optional FieldOptions options = 8; -} - -// Describes a oneof. -message OneofDescriptorProto { - optional string name = 1; -} - -// Describes an enum type. -message EnumDescriptorProto { - optional string name = 1; - - repeated EnumValueDescriptorProto value = 2; - - optional EnumOptions options = 3; -} - -// Describes a value within an enum. -message EnumValueDescriptorProto { - optional string name = 1; - optional int32 number = 2; - - optional EnumValueOptions options = 3; -} - -// Describes a service. -message ServiceDescriptorProto { - optional string name = 1; - repeated MethodDescriptorProto method = 2; - - optional ServiceOptions options = 3; -} - -// Describes a method of a service. -message MethodDescriptorProto { - optional string name = 1; - - // Input and output type names. These are resolved in the same way as - // FieldDescriptorProto.type_name, but must refer to a message type. - optional string input_type = 2; - optional string output_type = 3; - - optional MethodOptions options = 4; - - // Identifies if client streams multiple client messages - optional bool client_streaming = 5 [default=false]; - // Identifies if server streams multiple server messages - optional bool server_streaming = 6 [default=false]; -} - - -// =================================================================== -// Options - -// Each of the definitions above may have "options" attached. These are -// just annotations which may cause code to be generated slightly differently -// or may contain hints for code that manipulates protocol messages. -// -// Clients may define custom options as extensions of the *Options messages. -// These extensions may not yet be known at parsing time, so the parser cannot -// store the values in them. Instead it stores them in a field in the *Options -// message called uninterpreted_option. This field must have the same name -// across all *Options messages. We then use this field to populate the -// extensions when we build a descriptor, at which point all protos have been -// parsed and so all extensions are known. -// -// Extension numbers for custom options may be chosen as follows: -// * For options which will only be used within a single application or -// organization, or for experimental options, use field numbers 50000 -// through 99999. It is up to you to ensure that you do not use the -// same number for multiple options. -// * For options which will be published and used publicly by multiple -// independent entities, e-mail protobuf-global-extension-registry@google.com -// to reserve extension numbers. Simply provide your project name (e.g. -// Object-C plugin) and your porject website (if available) -- there's no need -// to explain how you intend to use them. Usually you only need one extension -// number. You can declare multiple options with only one extension number by -// putting them in a sub-message. See the Custom Options section of the docs -// for examples: -// https://developers.google.com/protocol-buffers/docs/proto#options -// If this turns out to be popular, a web service will be set up -// to automatically assign option numbers. - - -message FileOptions { - - // Sets the Java package where classes generated from this .proto will be - // placed. By default, the proto package is used, but this is often - // inappropriate because proto packages do not normally start with backwards - // domain names. - optional string java_package = 1; - - - // If set, all the classes from the .proto file are wrapped in a single - // outer class with the given name. This applies to both Proto1 - // (equivalent to the old "--one_java_file" option) and Proto2 (where - // a .proto always translates to a single class, but you may want to - // explicitly choose the class name). - optional string java_outer_classname = 8; - - // If set true, then the Java code generator will generate a separate .java - // file for each top-level message, enum, and service defined in the .proto - // file. Thus, these types will *not* be nested inside the outer class - // named by java_outer_classname. However, the outer class will still be - // generated to contain the file's getDescriptor() method as well as any - // top-level extensions defined in the file. - optional bool java_multiple_files = 10 [default=false]; - - // If set true, then the Java code generator will generate equals() and - // hashCode() methods for all messages defined in the .proto file. - // - In the full runtime, this is purely a speed optimization, as the - // AbstractMessage base class includes reflection-based implementations of - // these methods. - //- In the lite runtime, setting this option changes the semantics of - // equals() and hashCode() to more closely match those of the full runtime; - // the generated methods compute their results based on field values rather - // than object identity. (Implementations should not assume that hashcodes - // will be consistent across runtimes or versions of the protocol compiler.) - optional bool java_generate_equals_and_hash = 20 [default=false]; - - // If set true, then the Java2 code generator will generate code that - // throws an exception whenever an attempt is made to assign a non-UTF-8 - // byte sequence to a string field. - // Message reflection will do the same. - // However, an extension field still accepts non-UTF-8 byte sequences. - // This option has no effect on when used with the lite runtime. - optional bool java_string_check_utf8 = 27 [default=false]; - - - // Generated classes can be optimized for speed or code size. - enum OptimizeMode { - SPEED = 1; // Generate complete code for parsing, serialization, - // etc. - CODE_SIZE = 2; // Use ReflectionOps to implement these methods. - LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime. - } - optional OptimizeMode optimize_for = 9 [default=SPEED]; - - // Sets the Go package where structs generated from this .proto will be - // placed. If omitted, the Go package will be derived from the following: - // - The basename of the package import path, if provided. - // - Otherwise, the package statement in the .proto file, if present. - // - Otherwise, the basename of the .proto file, without extension. - optional string go_package = 11; - - - - // Should generic services be generated in each language? "Generic" services - // are not specific to any particular RPC system. They are generated by the - // main code generators in each language (without additional plugins). - // Generic services were the only kind of service generation supported by - // early versions of google.protobuf. - // - // Generic services are now considered deprecated in favor of using plugins - // that generate code specific to your particular RPC system. Therefore, - // these default to false. Old code which depends on generic services should - // explicitly set them to true. - optional bool cc_generic_services = 16 [default=false]; - optional bool java_generic_services = 17 [default=false]; - optional bool py_generic_services = 18 [default=false]; - - // Is this file deprecated? - // Depending on the target platform, this can emit Deprecated annotations - // for everything in the file, or it will be completely ignored; in the very - // least, this is a formalization for deprecating files. - optional bool deprecated = 23 [default=false]; - - - // Enables the use of arenas for the proto messages in this file. This applies - // only to generated classes for C++. - optional bool cc_enable_arenas = 31 [default=false]; - - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message MessageOptions { - // Set true to use the old proto1 MessageSet wire format for extensions. - // This is provided for backwards-compatibility with the MessageSet wire - // format. You should not use this for any other reason: It's less - // efficient, has fewer features, and is more complicated. - // - // The message must be defined exactly as follows: - // message Foo { - // option message_set_wire_format = true; - // extensions 4 to max; - // } - // Note that the message cannot have any defined fields; MessageSets only - // have extensions. - // - // All extensions of your type must be singular messages; e.g. they cannot - // be int32s, enums, or repeated messages. - // - // Because this is an option, the above two restrictions are not enforced by - // the protocol compiler. - optional bool message_set_wire_format = 1 [default=false]; - - // Disables the generation of the standard "descriptor()" accessor, which can - // conflict with a field of the same name. This is meant to make migration - // from proto1 easier; new code should avoid fields named "descriptor". - optional bool no_standard_descriptor_accessor = 2 [default=false]; - - // Is this message deprecated? - // Depending on the target platform, this can emit Deprecated annotations - // for the message, or it will be completely ignored; in the very least, - // this is a formalization for deprecating messages. - optional bool deprecated = 3 [default=false]; - - // Whether the message is an automatically generated map entry type for the - // maps field. - // - // For maps fields: - // map map_field = 1; - // The parsed descriptor looks like: - // message MapFieldEntry { - // option map_entry = true; - // optional KeyType key = 1; - // optional ValueType value = 2; - // } - // repeated MapFieldEntry map_field = 1; - // - // Implementations may choose not to generate the map_entry=true message, but - // use a native map in the target language to hold the keys and values. - // The reflection APIs in such implementions still need to work as - // if the field is a repeated message field. - // - // NOTE: Do not set the option in .proto files. Always use the maps syntax - // instead. The option should only be implicitly set by the proto compiler - // parser. - optional bool map_entry = 7; - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message FieldOptions { - // The ctype option instructs the C++ code generator to use a different - // representation of the field than it normally would. See the specific - // options below. This option is not yet implemented in the open source - // release -- sorry, we'll try to include it in a future version! - optional CType ctype = 1 [default = STRING]; - enum CType { - // Default mode. - STRING = 0; - - CORD = 1; - - STRING_PIECE = 2; - } - // The packed option can be enabled for repeated primitive fields to enable - // a more efficient representation on the wire. Rather than repeatedly - // writing the tag and type for each element, the entire array is encoded as - // a single length-delimited blob. - optional bool packed = 2; - - - - // Should this field be parsed lazily? Lazy applies only to message-type - // fields. It means that when the outer message is initially parsed, the - // inner message's contents will not be parsed but instead stored in encoded - // form. The inner message will actually be parsed when it is first accessed. - // - // This is only a hint. Implementations are free to choose whether to use - // eager or lazy parsing regardless of the value of this option. However, - // setting this option true suggests that the protocol author believes that - // using lazy parsing on this field is worth the additional bookkeeping - // overhead typically needed to implement it. - // - // This option does not affect the public interface of any generated code; - // all method signatures remain the same. Furthermore, thread-safety of the - // interface is not affected by this option; const methods remain safe to - // call from multiple threads concurrently, while non-const methods continue - // to require exclusive access. - // - // - // Note that implementations may choose not to check required fields within - // a lazy sub-message. That is, calling IsInitialized() on the outher message - // may return true even if the inner message has missing required fields. - // This is necessary because otherwise the inner message would have to be - // parsed in order to perform the check, defeating the purpose of lazy - // parsing. An implementation which chooses not to check required fields - // must be consistent about it. That is, for any particular sub-message, the - // implementation must either *always* check its required fields, or *never* - // check its required fields, regardless of whether or not the message has - // been parsed. - optional bool lazy = 5 [default=false]; - - // Is this field deprecated? - // Depending on the target platform, this can emit Deprecated annotations - // for accessors, or it will be completely ignored; in the very least, this - // is a formalization for deprecating fields. - optional bool deprecated = 3 [default=false]; - - // For Google-internal migration only. Do not use. - optional bool weak = 10 [default=false]; - - - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message EnumOptions { - - // Set this option to true to allow mapping different tag names to the same - // value. - optional bool allow_alias = 2; - - // Is this enum deprecated? - // Depending on the target platform, this can emit Deprecated annotations - // for the enum, or it will be completely ignored; in the very least, this - // is a formalization for deprecating enums. - optional bool deprecated = 3 [default=false]; - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message EnumValueOptions { - // Is this enum value deprecated? - // Depending on the target platform, this can emit Deprecated annotations - // for the enum value, or it will be completely ignored; in the very least, - // this is a formalization for deprecating enum values. - optional bool deprecated = 1 [default=false]; - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message ServiceOptions { - - // Note: Field numbers 1 through 32 are reserved for Google's internal RPC - // framework. We apologize for hoarding these numbers to ourselves, but - // we were already using them long before we decided to release Protocol - // Buffers. - - // Is this service deprecated? - // Depending on the target platform, this can emit Deprecated annotations - // for the service, or it will be completely ignored; in the very least, - // this is a formalization for deprecating services. - optional bool deprecated = 33 [default=false]; - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message MethodOptions { - - // Note: Field numbers 1 through 32 are reserved for Google's internal RPC - // framework. We apologize for hoarding these numbers to ourselves, but - // we were already using them long before we decided to release Protocol - // Buffers. - - // Is this method deprecated? - // Depending on the target platform, this can emit Deprecated annotations - // for the method, or it will be completely ignored; in the very least, - // this is a formalization for deprecating methods. - optional bool deprecated = 33 [default=false]; - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - - -// A message representing a option the parser does not recognize. This only -// appears in options protos created by the compiler::Parser class. -// DescriptorPool resolves these when building Descriptor objects. Therefore, -// options protos in descriptor objects (e.g. returned by Descriptor::options(), -// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions -// in them. -message UninterpretedOption { - // The name of the uninterpreted option. Each string represents a segment in - // a dot-separated name. is_extension is true iff a segment represents an - // extension (denoted with parentheses in options specs in .proto files). - // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents - // "foo.(bar.baz).qux". - message NamePart { - required string name_part = 1; - required bool is_extension = 2; - } - repeated NamePart name = 2; - - // The value of the uninterpreted option, in whatever type the tokenizer - // identified it as during parsing. Exactly one of these should be set. - optional string identifier_value = 3; - optional uint64 positive_int_value = 4; - optional int64 negative_int_value = 5; - optional double double_value = 6; - optional bytes string_value = 7; - optional string aggregate_value = 8; -} - -// =================================================================== -// Optional source code info - -// Encapsulates information about the original source file from which a -// FileDescriptorProto was generated. -message SourceCodeInfo { - // A Location identifies a piece of source code in a .proto file which - // corresponds to a particular definition. This information is intended - // to be useful to IDEs, code indexers, documentation generators, and similar - // tools. - // - // For example, say we have a file like: - // message Foo { - // optional string foo = 1; - // } - // Let's look at just the field definition: - // optional string foo = 1; - // ^ ^^ ^^ ^ ^^^ - // a bc de f ghi - // We have the following locations: - // span path represents - // [a,i) [ 4, 0, 2, 0 ] The whole field definition. - // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). - // [c,d) [ 4, 0, 2, 0, 5 ] The type (string). - // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). - // [g,h) [ 4, 0, 2, 0, 3 ] The number (1). - // - // Notes: - // - A location may refer to a repeated field itself (i.e. not to any - // particular index within it). This is used whenever a set of elements are - // logically enclosed in a single code segment. For example, an entire - // extend block (possibly containing multiple extension definitions) will - // have an outer location whose path refers to the "extensions" repeated - // field without an index. - // - Multiple locations may have the same path. This happens when a single - // logical declaration is spread out across multiple places. The most - // obvious example is the "extend" block again -- there may be multiple - // extend blocks in the same scope, each of which will have the same path. - // - A location's span is not always a subset of its parent's span. For - // example, the "extendee" of an extension declaration appears at the - // beginning of the "extend" block and is shared by all extensions within - // the block. - // - Just because a location's span is a subset of some other location's span - // does not mean that it is a descendent. For example, a "group" defines - // both a type and a field in a single declaration. Thus, the locations - // corresponding to the type and field and their components will overlap. - // - Code which tries to interpret locations should probably be designed to - // ignore those that it doesn't understand, as more types of locations could - // be recorded in the future. - repeated Location location = 1; - message Location { - // Identifies which part of the FileDescriptorProto was defined at this - // location. - // - // Each element is a field number or an index. They form a path from - // the root FileDescriptorProto to the place where the definition. For - // example, this path: - // [ 4, 3, 2, 7, 1 ] - // refers to: - // file.message_type(3) // 4, 3 - // .field(7) // 2, 7 - // .name() // 1 - // This is because FileDescriptorProto.message_type has field number 4: - // repeated DescriptorProto message_type = 4; - // and DescriptorProto.field has field number 2: - // repeated FieldDescriptorProto field = 2; - // and FieldDescriptorProto.name has field number 1: - // optional string name = 1; - // - // Thus, the above path gives the location of a field name. If we removed - // the last element: - // [ 4, 3, 2, 7 ] - // this path refers to the whole field declaration (from the beginning - // of the label to the terminating semicolon). - repeated int32 path = 1 [packed=true]; - - // Always has exactly three or four elements: start line, start column, - // end line (optional, otherwise assumed same as start line), end column. - // These are packed into a single field for efficiency. Note that line - // and column numbers are zero-based -- typically you will want to add - // 1 to each before displaying to a user. - repeated int32 span = 2 [packed=true]; - - // If this SourceCodeInfo represents a complete declaration, these are any - // comments appearing before and after the declaration which appear to be - // attached to the declaration. - // - // A series of line comments appearing on consecutive lines, with no other - // tokens appearing on those lines, will be treated as a single comment. - // - // Only the comment content is provided; comment markers (e.g. //) are - // stripped out. For block comments, leading whitespace and an asterisk - // will be stripped from the beginning of each line other than the first. - // Newlines are included in the output. - // - // Examples: - // - // optional int32 foo = 1; // Comment attached to foo. - // // Comment attached to bar. - // optional int32 bar = 2; - // - // optional string baz = 3; - // // Comment attached to baz. - // // Another line attached to baz. - // - // // Comment attached to qux. - // // - // // Another line attached to qux. - // optional double qux = 4; - // - // optional string corge = 5; - // /* Block comment attached - // * to corge. Leading asterisks - // * will be removed. */ - // /* Block comment attached to - // * grault. */ - // optional int32 grault = 6; - optional string leading_comments = 3; - optional string trailing_comments = 4; - } -} diff --git a/third_party/nanopb/generator/proto/nanopb.proto b/third_party/nanopb/generator/proto/nanopb.proto deleted file mode 100644 index 8aab19a1b5e..00000000000 --- a/third_party/nanopb/generator/proto/nanopb.proto +++ /dev/null @@ -1,98 +0,0 @@ -// Custom options for defining: -// - Maximum size of string/bytes -// - Maximum number of elements in array -// -// These are used by nanopb to generate statically allocable structures -// for memory-limited environments. - -syntax = "proto2"; -import "google/protobuf/descriptor.proto"; - -option java_package = "fi.kapsi.koti.jpa.nanopb"; - -enum FieldType { - FT_DEFAULT = 0; // Automatically decide field type, generate static field if possible. - FT_CALLBACK = 1; // Always generate a callback field. - FT_POINTER = 4; // Always generate a dynamically allocated field. - FT_STATIC = 2; // Generate a static field or raise an exception if not possible. - FT_IGNORE = 3; // Ignore the field completely. - FT_INLINE = 5; // Always generate an inline array of fixed size. -} - -enum IntSize { - IS_DEFAULT = 0; // Default, 32/64bit based on type in .proto - IS_8 = 8; - IS_16 = 16; - IS_32 = 32; - IS_64 = 64; -} - -// This is the inner options message, which basically defines options for -// a field. When it is used in message or file scope, it applies to all -// fields. -message NanoPBOptions { - // Allocated size for 'bytes' and 'string' fields. - optional int32 max_size = 1; - - // Allocated number of entries in arrays ('repeated' fields) - optional int32 max_count = 2; - - // Size of integer fields. Can save some memory if you don't need - // full 32 bits for the value. - optional IntSize int_size = 7 [default = IS_DEFAULT]; - - // Force type of field (callback or static allocation) - optional FieldType type = 3 [default = FT_DEFAULT]; - - // Use long names for enums, i.e. EnumName_EnumValue. - optional bool long_names = 4 [default = true]; - - // Add 'packed' attribute to generated structs. - // Note: this cannot be used on CPUs that break on unaligned - // accesses to variables. - optional bool packed_struct = 5 [default = false]; - - // Add 'packed' attribute to generated enums. - optional bool packed_enum = 10 [default = false]; - - // Skip this message - optional bool skip_message = 6 [default = false]; - - // Generate oneof fields as normal optional fields instead of union. - optional bool no_unions = 8 [default = false]; - - // integer type tag for a message - optional uint32 msgid = 9; - - // decode oneof as anonymous union - optional bool anonymous_oneof = 11 [default = false]; -} - -// Extensions to protoc 'Descriptor' type in order to define options -// inside a .proto file. -// -// Protocol Buffers extension number registry -// -------------------------------- -// Project: Nanopb -// Contact: Petteri Aimonen -// Web site: http://kapsi.fi/~jpa/nanopb -// Extensions: 1010 (all types) -// -------------------------------- - -extend google.protobuf.FileOptions { - optional NanoPBOptions nanopb_fileopt = 1010; -} - -extend google.protobuf.MessageOptions { - optional NanoPBOptions nanopb_msgopt = 1010; -} - -extend google.protobuf.EnumOptions { - optional NanoPBOptions nanopb_enumopt = 1010; -} - -extend google.protobuf.FieldOptions { - optional NanoPBOptions nanopb = 1010; -} - - diff --git a/third_party/nanopb/generator/proto/plugin.proto b/third_party/nanopb/generator/proto/plugin.proto deleted file mode 100644 index e627289b53e..00000000000 --- a/third_party/nanopb/generator/proto/plugin.proto +++ /dev/null @@ -1,148 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// 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. - -// Author: kenton@google.com (Kenton Varda) -// -// WARNING: The plugin interface is currently EXPERIMENTAL and is subject to -// change. -// -// protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is -// just a program that reads a CodeGeneratorRequest from stdin and writes a -// CodeGeneratorResponse to stdout. -// -// Plugins written using C++ can use google/protobuf/compiler/plugin.h instead -// of dealing with the raw protocol defined here. -// -// A plugin executable needs only to be placed somewhere in the path. The -// plugin should be named "protoc-gen-$NAME", and will then be used when the -// flag "--${NAME}_out" is passed to protoc. - -syntax = "proto2"; -package google.protobuf.compiler; -option java_package = "com.google.protobuf.compiler"; -option java_outer_classname = "PluginProtos"; - -import "google/protobuf/descriptor.proto"; - -// An encoded CodeGeneratorRequest is written to the plugin's stdin. -message CodeGeneratorRequest { - // The .proto files that were explicitly listed on the command-line. The - // code generator should generate code only for these files. Each file's - // descriptor will be included in proto_file, below. - repeated string file_to_generate = 1; - - // The generator parameter passed on the command-line. - optional string parameter = 2; - - // FileDescriptorProtos for all files in files_to_generate and everything - // they import. The files will appear in topological order, so each file - // appears before any file that imports it. - // - // protoc guarantees that all proto_files will be written after - // the fields above, even though this is not technically guaranteed by the - // protobuf wire format. This theoretically could allow a plugin to stream - // in the FileDescriptorProtos and handle them one by one rather than read - // the entire set into memory at once. However, as of this writing, this - // is not similarly optimized on protoc's end -- it will store all fields in - // memory at once before sending them to the plugin. - repeated FileDescriptorProto proto_file = 15; -} - -// The plugin writes an encoded CodeGeneratorResponse to stdout. -message CodeGeneratorResponse { - // Error message. If non-empty, code generation failed. The plugin process - // should exit with status code zero even if it reports an error in this way. - // - // This should be used to indicate errors in .proto files which prevent the - // code generator from generating correct code. Errors which indicate a - // problem in protoc itself -- such as the input CodeGeneratorRequest being - // unparseable -- should be reported by writing a message to stderr and - // exiting with a non-zero status code. - optional string error = 1; - - // Represents a single generated file. - message File { - // The file name, relative to the output directory. The name must not - // contain "." or ".." components and must be relative, not be absolute (so, - // the file cannot lie outside the output directory). "/" must be used as - // the path separator, not "\". - // - // If the name is omitted, the content will be appended to the previous - // file. This allows the generator to break large files into small chunks, - // and allows the generated text to be streamed back to protoc so that large - // files need not reside completely in memory at one time. Note that as of - // this writing protoc does not optimize for this -- it will read the entire - // CodeGeneratorResponse before writing files to disk. - optional string name = 1; - - // If non-empty, indicates that the named file should already exist, and the - // content here is to be inserted into that file at a defined insertion - // point. This feature allows a code generator to extend the output - // produced by another code generator. The original generator may provide - // insertion points by placing special annotations in the file that look - // like: - // @@protoc_insertion_point(NAME) - // The annotation can have arbitrary text before and after it on the line, - // which allows it to be placed in a comment. NAME should be replaced with - // an identifier naming the point -- this is what other generators will use - // as the insertion_point. Code inserted at this point will be placed - // immediately above the line containing the insertion point (thus multiple - // insertions to the same point will come out in the order they were added). - // The double-@ is intended to make it unlikely that the generated code - // could contain things that look like insertion points by accident. - // - // For example, the C++ code generator places the following line in the - // .pb.h files that it generates: - // // @@protoc_insertion_point(namespace_scope) - // This line appears within the scope of the file's package namespace, but - // outside of any particular class. Another plugin can then specify the - // insertion_point "namespace_scope" to generate additional classes or - // other declarations that should be placed in this scope. - // - // Note that if the line containing the insertion point begins with - // whitespace, the same whitespace will be added to every line of the - // inserted text. This is useful for languages like Python, where - // indentation matters. In these languages, the insertion point comment - // should be indented the same amount as any inserted code will need to be - // in order to work correctly in that context. - // - // The code generator that generates the initial file and the one which - // inserts into it must both run as part of a single invocation of protoc. - // Code generators are executed in the order in which they appear on the - // command line. - // - // If |insertion_point| is present, |name| must also be present. - optional string insertion_point = 2; - - // The file contents. - optional string content = 15; - } - repeated File file = 15; -} diff --git a/third_party/nanopb/generator/protoc-gen-nanopb b/third_party/nanopb/generator/protoc-gen-nanopb deleted file mode 100755 index 358f97cf2ae..00000000000 --- a/third_party/nanopb/generator/protoc-gen-nanopb +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -# This file is used to invoke nanopb_generator.py as a plugin -# to protoc on Linux and other *nix-style systems. -# Use it like this: -# protoc --plugin=nanopb=..../protoc-gen-nanopb --nanopb_out=dir foo.proto -# -# Note that if you use the binary package of nanopb, the protoc -# path is already set up properly and there is no need to give -# --plugin= on the command line. - -MYPATH=$(dirname "$0") -exec "$MYPATH/nanopb_generator.py" --protoc-plugin diff --git a/third_party/nanopb/generator/protoc-gen-nanopb.bat b/third_party/nanopb/generator/protoc-gen-nanopb.bat deleted file mode 100644 index 7624984e588..00000000000 --- a/third_party/nanopb/generator/protoc-gen-nanopb.bat +++ /dev/null @@ -1,12 +0,0 @@ -@echo off -:: This file is used to invoke nanopb_generator.py as a plugin -:: to protoc on Windows. -:: Use it like this: -:: protoc --plugin=nanopb=..../protoc-gen-nanopb.bat --nanopb_out=dir foo.proto -:: -:: Note that if you use the binary package of nanopb, the protoc -:: path is already set up properly and there is no need to give -:: --plugin= on the command line. - -set mydir=%~dp0 -python "%mydir%\nanopb_generator.py" --protoc-plugin diff --git a/third_party/nanopb/library.json b/third_party/nanopb/library.json deleted file mode 100644 index 30a56c94df2..00000000000 --- a/third_party/nanopb/library.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "Nanopb", - "keywords": "protocol buffers, protobuf, google", - "description": "Nanopb is a plain-C implementation of Google's Protocol Buffers data format. It is targeted at 32 bit microcontrollers, but is also fit for other embedded systems with tight (2-10 kB ROM, <1 kB RAM) memory constraints.", - "repository": { - "type": "git", - "url": "https://github.com/nanopb/nanopb.git" - }, - "authors": [{ - "name": "Petteri Aimonen", - "email": "jpa@nanopb.mail.kapsi.fi", - "url": "http://koti.kapsi.fi/jpa/nanopb/" - }], - "include": [ - "*.c", - "*.cpp", - "*.h" - ], - "examples": "examples/*/*.c", - "frameworks": "*", - "platforms": "*" -} diff --git a/third_party/nanopb/pb.h b/third_party/nanopb/pb.h deleted file mode 100644 index 62dca73f4fd..00000000000 --- a/third_party/nanopb/pb.h +++ /dev/null @@ -1,579 +0,0 @@ -/* Common parts of the nanopb library. Most of these are quite low-level - * stuff. For the high-level interface, see pb_encode.h and pb_decode.h. - */ - -#ifndef PB_H_INCLUDED -#define PB_H_INCLUDED - -/***************************************************************** - * Nanopb compilation time options. You can change these here by * - * uncommenting the lines, or on the compiler command line. * - *****************************************************************/ - -/* Enable support for dynamically allocated fields */ -/* #define PB_ENABLE_MALLOC 1 */ - -/* Define this if your CPU / compiler combination does not support - * unaligned memory access to packed structures. */ -/* #define PB_NO_PACKED_STRUCTS 1 */ - -/* Increase the number of required fields that are tracked. - * A compiler warning will tell if you need this. */ -/* #define PB_MAX_REQUIRED_FIELDS 256 */ - -/* Add support for tag numbers > 255 and fields larger than 255 bytes. */ -/* #define PB_FIELD_16BIT 1 */ - -/* Add support for tag numbers > 65536 and fields larger than 65536 bytes. */ -/* #define PB_FIELD_32BIT 1 */ - -/* Disable support for error messages in order to save some code space. */ -/* #define PB_NO_ERRMSG 1 */ - -/* Disable support for custom streams (support only memory buffers). */ -/* #define PB_BUFFER_ONLY 1 */ - -/* Switch back to the old-style callback function signature. - * This was the default until nanopb-0.2.1. */ -/* #define PB_OLD_CALLBACK_STYLE */ - - -/****************************************************************** - * You usually don't need to change anything below this line. * - * Feel free to look around and use the defined macros, though. * - ******************************************************************/ - - -/* Version of the nanopb library. Just in case you want to check it in - * your own program. */ -#define NANOPB_VERSION nanopb-0.3.7-dev - -/* Include all the system headers needed by nanopb. You will need the - * definitions of the following: - * - strlen, memcpy, memset functions - * - [u]int_least8_t, uint_fast8_t, [u]int_least16_t, [u]int32_t, [u]int64_t - * - size_t - * - bool - * - * If you don't have the standard header files, you can instead provide - * a custom header that defines or includes all this. In that case, - * define PB_SYSTEM_HEADER to the path of this file. - */ -#ifdef PB_SYSTEM_HEADER -#include PB_SYSTEM_HEADER -#else -#include -#include -#include -#include - -#ifdef PB_ENABLE_MALLOC -#include -#endif -#endif - -/* Macro for defining packed structures (compiler dependent). - * This just reduces memory requirements, but is not required. - */ -#if defined(PB_NO_PACKED_STRUCTS) - /* Disable struct packing */ -# define PB_PACKED_STRUCT_START -# define PB_PACKED_STRUCT_END -# define pb_packed -#elif defined(__GNUC__) || defined(__clang__) - /* For GCC and clang */ -# define PB_PACKED_STRUCT_START -# define PB_PACKED_STRUCT_END -# define pb_packed __attribute__((packed)) -#elif defined(__ICCARM__) || defined(__CC_ARM) - /* For IAR ARM and Keil MDK-ARM compilers */ -# define PB_PACKED_STRUCT_START _Pragma("pack(push, 1)") -# define PB_PACKED_STRUCT_END _Pragma("pack(pop)") -# define pb_packed -#elif defined(_MSC_VER) && (_MSC_VER >= 1500) - /* For Microsoft Visual C++ */ -# define PB_PACKED_STRUCT_START __pragma(pack(push, 1)) -# define PB_PACKED_STRUCT_END __pragma(pack(pop)) -# define pb_packed -#else - /* Unknown compiler */ -# define PB_PACKED_STRUCT_START -# define PB_PACKED_STRUCT_END -# define pb_packed -#endif - -/* Handly macro for suppressing unreferenced-parameter compiler warnings. */ -#ifndef PB_UNUSED -#define PB_UNUSED(x) (void)(x) -#endif - -/* Compile-time assertion, used for checking compatible compilation options. - * If this does not work properly on your compiler, use - * #define PB_NO_STATIC_ASSERT to disable it. - * - * But before doing that, check carefully the error message / place where it - * comes from to see if the error has a real cause. Unfortunately the error - * message is not always very clear to read, but you can see the reason better - * in the place where the PB_STATIC_ASSERT macro was called. - */ -#ifndef PB_NO_STATIC_ASSERT -#ifndef PB_STATIC_ASSERT -#define PB_STATIC_ASSERT(COND,MSG) typedef char PB_STATIC_ASSERT_MSG(MSG, __LINE__, __COUNTER__)[(COND)?1:-1]; -#define PB_STATIC_ASSERT_MSG(MSG, LINE, COUNTER) PB_STATIC_ASSERT_MSG_(MSG, LINE, COUNTER) -#define PB_STATIC_ASSERT_MSG_(MSG, LINE, COUNTER) pb_static_assertion_##MSG##LINE##COUNTER -#endif -#else -#define PB_STATIC_ASSERT(COND,MSG) -#endif - -/* Number of required fields to keep track of. */ -#ifndef PB_MAX_REQUIRED_FIELDS -#define PB_MAX_REQUIRED_FIELDS 64 -#endif - -#if PB_MAX_REQUIRED_FIELDS < 64 -#error You should not lower PB_MAX_REQUIRED_FIELDS from the default value (64). -#endif - -/* List of possible field types. These are used in the autogenerated code. - * Least-significant 4 bits tell the scalar type - * Most-significant 4 bits specify repeated/required/packed etc. - */ - -typedef uint_least8_t pb_type_t; - -/**** Field data types ****/ - -/* Numeric types */ -#define PB_LTYPE_VARINT 0x00 /* int32, int64, enum, bool */ -#define PB_LTYPE_UVARINT 0x01 /* uint32, uint64 */ -#define PB_LTYPE_SVARINT 0x02 /* sint32, sint64 */ -#define PB_LTYPE_FIXED32 0x03 /* fixed32, sfixed32, float */ -#define PB_LTYPE_FIXED64 0x04 /* fixed64, sfixed64, double */ - -/* Marker for last packable field type. */ -#define PB_LTYPE_LAST_PACKABLE 0x04 - -/* Byte array with pre-allocated buffer. - * data_size is the length of the allocated PB_BYTES_ARRAY structure. */ -#define PB_LTYPE_BYTES 0x05 - -/* String with pre-allocated buffer. - * data_size is the maximum length. */ -#define PB_LTYPE_STRING 0x06 - -/* Submessage - * submsg_fields is pointer to field descriptions */ -#define PB_LTYPE_SUBMESSAGE 0x07 - -/* Extension pseudo-field - * The field contains a pointer to pb_extension_t */ -#define PB_LTYPE_EXTENSION 0x08 - -/* Byte array with inline, pre-allocated byffer. - * data_size is the length of the inline, allocated buffer. - * This differs from PB_LTYPE_BYTES by defining the element as - * pb_byte_t[data_size] rather than pb_bytes_array_t. */ -#define PB_LTYPE_FIXED_LENGTH_BYTES 0x09 - -/* Number of declared LTYPES */ -#define PB_LTYPES_COUNT 0x0A -#define PB_LTYPE_MASK 0x0F - -/**** Field repetition rules ****/ - -#define PB_HTYPE_REQUIRED 0x00 -#define PB_HTYPE_OPTIONAL 0x10 -#define PB_HTYPE_REPEATED 0x20 -#define PB_HTYPE_ONEOF 0x30 -#define PB_HTYPE_MASK 0x30 - -/**** Field allocation types ****/ - -#define PB_ATYPE_STATIC 0x00 -#define PB_ATYPE_POINTER 0x80 -#define PB_ATYPE_CALLBACK 0x40 -#define PB_ATYPE_MASK 0xC0 - -#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK) -#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK) -#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK) - -/* Data type used for storing sizes of struct fields - * and array counts. - */ -#if defined(PB_FIELD_32BIT) - typedef uint32_t pb_size_t; - typedef int32_t pb_ssize_t; -#elif defined(PB_FIELD_16BIT) - typedef uint_least16_t pb_size_t; - typedef int_least16_t pb_ssize_t; -#else - typedef uint_least8_t pb_size_t; - typedef int_least8_t pb_ssize_t; -#endif -#define PB_SIZE_MAX ((pb_size_t)-1) - -/* Data type for storing encoded data and other byte streams. - * This typedef exists to support platforms where uint8_t does not exist. - * You can regard it as equivalent on uint8_t on other platforms. - */ -typedef uint_least8_t pb_byte_t; - -/* This structure is used in auto-generated constants - * to specify struct fields. - * You can change field sizes if you need structures - * larger than 256 bytes or field tags larger than 256. - * The compiler should complain if your .proto has such - * structures. Fix that by defining PB_FIELD_16BIT or - * PB_FIELD_32BIT. - */ -PB_PACKED_STRUCT_START -typedef struct pb_field_s pb_field_t; -struct pb_field_s { - pb_size_t tag; - pb_type_t type; - pb_size_t data_offset; /* Offset of field data, relative to previous field. */ - pb_ssize_t size_offset; /* Offset of array size or has-boolean, relative to data */ - pb_size_t data_size; /* Data size in bytes for a single item */ - pb_size_t array_size; /* Maximum number of entries in array */ - - /* Field definitions for submessage - * OR default value for all other non-array, non-callback types - * If null, then field will zeroed. */ - const void *ptr; -} pb_packed; -PB_PACKED_STRUCT_END - -/* Make sure that the standard integer types are of the expected sizes. - * Otherwise fixed32/fixed64 fields can break. - * - * If you get errors here, it probably means that your stdint.h is not - * correct for your platform. - */ -PB_STATIC_ASSERT(sizeof(int64_t) == 2 * sizeof(int32_t), INT64_T_WRONG_SIZE) -PB_STATIC_ASSERT(sizeof(uint64_t) == 2 * sizeof(uint32_t), UINT64_T_WRONG_SIZE) - -/* This structure is used for 'bytes' arrays. - * It has the number of bytes in the beginning, and after that an array. - * Note that actual structs used will have a different length of bytes array. - */ -#define PB_BYTES_ARRAY_T(n) struct { pb_size_t size; pb_byte_t bytes[n]; } -#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes)) - -struct pb_bytes_array_s { - pb_size_t size; - pb_byte_t bytes[1]; -}; -typedef struct pb_bytes_array_s pb_bytes_array_t; - -/* This structure is used for giving the callback function. - * It is stored in the message structure and filled in by the method that - * calls pb_decode. - * - * The decoding callback will be given a limited-length stream - * If the wire type was string, the length is the length of the string. - * If the wire type was a varint/fixed32/fixed64, the length is the length - * of the actual value. - * The function may be called multiple times (especially for repeated types, - * but also otherwise if the message happens to contain the field multiple - * times.) - * - * The encoding callback will receive the actual output stream. - * It should write all the data in one call, including the field tag and - * wire type. It can write multiple fields. - * - * The callback can be null if you want to skip a field. - */ -typedef struct pb_istream_s pb_istream_t; -typedef struct pb_ostream_s pb_ostream_t; -typedef struct pb_callback_s pb_callback_t; -struct pb_callback_s { -#ifdef PB_OLD_CALLBACK_STYLE - /* Deprecated since nanopb-0.2.1 */ - union { - bool (*decode)(pb_istream_t *stream, const pb_field_t *field, void *arg); - bool (*encode)(pb_ostream_t *stream, const pb_field_t *field, const void *arg); - } funcs; -#else - /* New function signature, which allows modifying arg contents in callback. */ - union { - bool (*decode)(pb_istream_t *stream, const pb_field_t *field, void **arg); - bool (*encode)(pb_ostream_t *stream, const pb_field_t *field, void * const *arg); - } funcs; -#endif - - /* Free arg for use by callback */ - void *arg; -}; - -/* Wire types. Library user needs these only in encoder callbacks. */ -typedef enum { - PB_WT_VARINT = 0, - PB_WT_64BIT = 1, - PB_WT_STRING = 2, - PB_WT_32BIT = 5 -} pb_wire_type_t; - -/* Structure for defining the handling of unknown/extension fields. - * Usually the pb_extension_type_t structure is automatically generated, - * while the pb_extension_t structure is created by the user. However, - * if you want to catch all unknown fields, you can also create a custom - * pb_extension_type_t with your own callback. - */ -typedef struct pb_extension_type_s pb_extension_type_t; -typedef struct pb_extension_s pb_extension_t; -struct pb_extension_type_s { - /* Called for each unknown field in the message. - * If you handle the field, read off all of its data and return true. - * If you do not handle the field, do not read anything and return true. - * If you run into an error, return false. - * Set to NULL for default handler. - */ - bool (*decode)(pb_istream_t *stream, pb_extension_t *extension, - uint32_t tag, pb_wire_type_t wire_type); - - /* Called once after all regular fields have been encoded. - * If you have something to write, do so and return true. - * If you do not have anything to write, just return true. - * If you run into an error, return false. - * Set to NULL for default handler. - */ - bool (*encode)(pb_ostream_t *stream, const pb_extension_t *extension); - - /* Free field for use by the callback. */ - const void *arg; -}; - -struct pb_extension_s { - /* Type describing the extension field. Usually you'll initialize - * this to a pointer to the automatically generated structure. */ - const pb_extension_type_t *type; - - /* Destination for the decoded data. This must match the datatype - * of the extension field. */ - void *dest; - - /* Pointer to the next extension handler, or NULL. - * If this extension does not match a field, the next handler is - * automatically called. */ - pb_extension_t *next; - - /* The decoder sets this to true if the extension was found. - * Ignored for encoding. */ - bool found; -}; - -/* Memory allocation functions to use. You can define pb_realloc and - * pb_free to custom functions if you want. */ -#ifdef PB_ENABLE_MALLOC -# ifndef pb_realloc -# define pb_realloc(ptr, size) realloc(ptr, size) -# endif -# ifndef pb_free -# define pb_free(ptr) free(ptr) -# endif -#endif - -/* This is used to inform about need to regenerate .pb.h/.pb.c files. */ -#define PB_PROTO_HEADER_VERSION 30 - -/* These macros are used to declare pb_field_t's in the constant array. */ -/* Size of a structure member, in bytes. */ -#define pb_membersize(st, m) (sizeof ((st*)0)->m) -/* Number of entries in an array. */ -#define pb_arraysize(st, m) (pb_membersize(st, m) / pb_membersize(st, m[0])) -/* Delta from start of one member to the start of another member. */ -#define pb_delta(st, m1, m2) ((int)offsetof(st, m1) - (int)offsetof(st, m2)) -/* Marks the end of the field list */ -#define PB_LAST_FIELD {0,(pb_type_t) 0,0,0,0,0,0} - -/* Macros for filling in the data_offset field */ -/* data_offset for first field in a message */ -#define PB_DATAOFFSET_FIRST(st, m1, m2) (offsetof(st, m1)) -/* data_offset for subsequent fields */ -#define PB_DATAOFFSET_OTHER(st, m1, m2) (offsetof(st, m1) - offsetof(st, m2) - pb_membersize(st, m2)) -/* Choose first/other based on m1 == m2 (deprecated, remains for backwards compatibility) */ -#define PB_DATAOFFSET_CHOOSE(st, m1, m2) (int)(offsetof(st, m1) == offsetof(st, m2) \ - ? PB_DATAOFFSET_FIRST(st, m1, m2) \ - : PB_DATAOFFSET_OTHER(st, m1, m2)) - -/* Required fields are the simplest. They just have delta (padding) from - * previous field end, and the size of the field. Pointer is used for - * submessages and default values. - */ -#define PB_REQUIRED_STATIC(tag, st, m, fd, ltype, ptr) \ - {tag, PB_ATYPE_STATIC | PB_HTYPE_REQUIRED | ltype, \ - fd, 0, pb_membersize(st, m), 0, ptr} - -/* Optional fields add the delta to the has_ variable. */ -#define PB_OPTIONAL_STATIC(tag, st, m, fd, ltype, ptr) \ - {tag, PB_ATYPE_STATIC | PB_HTYPE_OPTIONAL | ltype, \ - fd, \ - pb_delta(st, has_ ## m, m), \ - pb_membersize(st, m), 0, ptr} - -/* Repeated fields have a _count field and also the maximum number of entries. */ -#define PB_REPEATED_STATIC(tag, st, m, fd, ltype, ptr) \ - {tag, PB_ATYPE_STATIC | PB_HTYPE_REPEATED | ltype, \ - fd, \ - pb_delta(st, m ## _count, m), \ - pb_membersize(st, m[0]), \ - pb_arraysize(st, m), ptr} - -#define PB_REQUIRED_INLINE(tag, st, m, fd, ltype, ptr) \ - {tag, PB_ATYPE_STATIC | PB_HTYPE_REQUIRED | PB_LTYPE_FIXED_LENGTH_BYTES, \ - fd, 0, pb_membersize(st, m), 0, ptr} - -/* Optional fields add the delta to the has_ variable. */ -#define PB_OPTIONAL_INLINE(tag, st, m, fd, ltype, ptr) \ - {tag, PB_ATYPE_STATIC | PB_HTYPE_OPTIONAL | PB_LTYPE_FIXED_LENGTH_BYTES, \ - fd, \ - pb_delta(st, has_ ## m, m), \ - pb_membersize(st, m), 0, ptr} - -/* INLINE does not support REPEATED fields. */ - -/* Allocated fields carry the size of the actual data, not the pointer */ -#define PB_REQUIRED_POINTER(tag, st, m, fd, ltype, ptr) \ - {tag, PB_ATYPE_POINTER | PB_HTYPE_REQUIRED | ltype, \ - fd, 0, pb_membersize(st, m[0]), 0, ptr} - -/* Optional fields don't need a has_ variable, as information would be redundant */ -#define PB_OPTIONAL_POINTER(tag, st, m, fd, ltype, ptr) \ - {tag, PB_ATYPE_POINTER | PB_HTYPE_OPTIONAL | ltype, \ - fd, 0, pb_membersize(st, m[0]), 0, ptr} - -/* Repeated fields have a _count field and a pointer to array of pointers */ -#define PB_REPEATED_POINTER(tag, st, m, fd, ltype, ptr) \ - {tag, PB_ATYPE_POINTER | PB_HTYPE_REPEATED | ltype, \ - fd, pb_delta(st, m ## _count, m), \ - pb_membersize(st, m[0]), 0, ptr} - -/* Callbacks are much like required fields except with special datatype. */ -#define PB_REQUIRED_CALLBACK(tag, st, m, fd, ltype, ptr) \ - {tag, PB_ATYPE_CALLBACK | PB_HTYPE_REQUIRED | ltype, \ - fd, 0, pb_membersize(st, m), 0, ptr} - -#define PB_OPTIONAL_CALLBACK(tag, st, m, fd, ltype, ptr) \ - {tag, PB_ATYPE_CALLBACK | PB_HTYPE_OPTIONAL | ltype, \ - fd, 0, pb_membersize(st, m), 0, ptr} - -#define PB_REPEATED_CALLBACK(tag, st, m, fd, ltype, ptr) \ - {tag, PB_ATYPE_CALLBACK | PB_HTYPE_REPEATED | ltype, \ - fd, 0, pb_membersize(st, m), 0, ptr} - -/* Optional extensions don't have the has_ field, as that would be redundant. */ -#define PB_OPTEXT_STATIC(tag, st, m, fd, ltype, ptr) \ - {tag, PB_ATYPE_STATIC | PB_HTYPE_OPTIONAL | ltype, \ - 0, \ - 0, \ - pb_membersize(st, m), 0, ptr} - -#define PB_OPTEXT_POINTER(tag, st, m, fd, ltype, ptr) \ - PB_OPTIONAL_POINTER(tag, st, m, fd, ltype, ptr) - -/* INLINE does not support OPTEXT. */ - -#define PB_OPTEXT_CALLBACK(tag, st, m, fd, ltype, ptr) \ - PB_OPTIONAL_CALLBACK(tag, st, m, fd, ltype, ptr) - -/* The mapping from protobuf types to LTYPEs is done using these macros. */ -#define PB_LTYPE_MAP_BOOL PB_LTYPE_VARINT -#define PB_LTYPE_MAP_BYTES PB_LTYPE_BYTES -#define PB_LTYPE_MAP_DOUBLE PB_LTYPE_FIXED64 -#define PB_LTYPE_MAP_ENUM PB_LTYPE_VARINT -#define PB_LTYPE_MAP_UENUM PB_LTYPE_UVARINT -#define PB_LTYPE_MAP_FIXED32 PB_LTYPE_FIXED32 -#define PB_LTYPE_MAP_FIXED64 PB_LTYPE_FIXED64 -#define PB_LTYPE_MAP_FLOAT PB_LTYPE_FIXED32 -#define PB_LTYPE_MAP_INT32 PB_LTYPE_VARINT -#define PB_LTYPE_MAP_INT64 PB_LTYPE_VARINT -#define PB_LTYPE_MAP_MESSAGE PB_LTYPE_SUBMESSAGE -#define PB_LTYPE_MAP_SFIXED32 PB_LTYPE_FIXED32 -#define PB_LTYPE_MAP_SFIXED64 PB_LTYPE_FIXED64 -#define PB_LTYPE_MAP_SINT32 PB_LTYPE_SVARINT -#define PB_LTYPE_MAP_SINT64 PB_LTYPE_SVARINT -#define PB_LTYPE_MAP_STRING PB_LTYPE_STRING -#define PB_LTYPE_MAP_UINT32 PB_LTYPE_UVARINT -#define PB_LTYPE_MAP_UINT64 PB_LTYPE_UVARINT -#define PB_LTYPE_MAP_EXTENSION PB_LTYPE_EXTENSION - -/* This is the actual macro used in field descriptions. - * It takes these arguments: - * - Field tag number - * - Field type: BOOL, BYTES, DOUBLE, ENUM, UENUM, FIXED32, FIXED64, - * FLOAT, INT32, INT64, MESSAGE, SFIXED32, SFIXED64 - * SINT32, SINT64, STRING, UINT32, UINT64 or EXTENSION - * - Field rules: REQUIRED, OPTIONAL or REPEATED - * - Allocation: STATIC, INLINE, or CALLBACK - * - Placement: FIRST or OTHER, depending on if this is the first field in structure. - * - Message name - * - Field name - * - Previous field name (or field name again for first field) - * - Pointer to default value or submsg fields. - */ - -#define PB_FIELD(tag, type, rules, allocation, placement, message, field, prevfield, ptr) \ - PB_ ## rules ## _ ## allocation(tag, message, field, \ - PB_DATAOFFSET_ ## placement(message, field, prevfield), \ - PB_LTYPE_MAP_ ## type, ptr) - -/* Field description for oneof fields. This requires taking into account the - * union name also, that's why a separate set of macros is needed. - */ -#define PB_ONEOF_STATIC(u, tag, st, m, fd, ltype, ptr) \ - {tag, PB_ATYPE_STATIC | PB_HTYPE_ONEOF | ltype, \ - fd, pb_delta(st, which_ ## u, u.m), \ - pb_membersize(st, u.m), 0, ptr} - -#define PB_ONEOF_POINTER(u, tag, st, m, fd, ltype, ptr) \ - {tag, PB_ATYPE_POINTER | PB_HTYPE_ONEOF | ltype, \ - fd, pb_delta(st, which_ ## u, u.m), \ - pb_membersize(st, u.m[0]), 0, ptr} - -/* INLINE does not support ONEOF. */ - -#define PB_ONEOF_FIELD(union_name, tag, type, rules, allocation, placement, message, field, prevfield, ptr) \ - PB_ONEOF_ ## allocation(union_name, tag, message, field, \ - PB_DATAOFFSET_ ## placement(message, union_name.field, prevfield), \ - PB_LTYPE_MAP_ ## type, ptr) - -#define PB_ANONYMOUS_ONEOF_STATIC(u, tag, st, m, fd, ltype, ptr) \ - {tag, PB_ATYPE_STATIC | PB_HTYPE_ONEOF | ltype, \ - fd, pb_delta(st, which_ ## u, m), \ - pb_membersize(st, m), 0, ptr} - -#define PB_ANONYMOUS_ONEOF_POINTER(u, tag, st, m, fd, ltype, ptr) \ - {tag, PB_ATYPE_POINTER | PB_HTYPE_ONEOF | ltype, \ - fd, pb_delta(st, which_ ## u, m), \ - pb_membersize(st, m[0]), 0, ptr} - -#define PB_ANONYMOUS_ONEOF_FIELD(union_name, tag, type, rules, allocation, placement, message, field, prevfield, ptr) \ - PB_ANONYMOUS_ONEOF_ ## allocation(union_name, tag, message, field, \ - PB_DATAOFFSET_ ## placement(message, field, prevfield), \ - PB_LTYPE_MAP_ ## type, ptr) - -/* These macros are used for giving out error messages. - * They are mostly a debugging aid; the main error information - * is the true/false return value from functions. - * Some code space can be saved by disabling the error - * messages if not used. - * - * PB_SET_ERROR() sets the error message if none has been set yet. - * msg must be a constant string literal. - * PB_GET_ERROR() always returns a pointer to a string. - * PB_RETURN_ERROR() sets the error and returns false from current - * function. - */ -#ifdef PB_NO_ERRMSG -#define PB_SET_ERROR(stream, msg) PB_UNUSED(stream) -#define PB_GET_ERROR(stream) "(errmsg disabled)" -#else -#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg)) -#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)") -#endif - -#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false - -#endif diff --git a/third_party/nanopb/pb_common.c b/third_party/nanopb/pb_common.c deleted file mode 100644 index 385c0193f8a..00000000000 --- a/third_party/nanopb/pb_common.c +++ /dev/null @@ -1,97 +0,0 @@ -/* pb_common.c: Common support functions for pb_encode.c and pb_decode.c. - * - * 2014 Petteri Aimonen - */ - -#include "pb_common.h" - -bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *dest_struct) -{ - iter->start = fields; - iter->pos = fields; - iter->required_field_index = 0; - iter->dest_struct = dest_struct; - iter->pData = (char*)dest_struct + iter->pos->data_offset; - iter->pSize = (char*)iter->pData + iter->pos->size_offset; - - return (iter->pos->tag != 0); -} - -bool pb_field_iter_next(pb_field_iter_t *iter) -{ - const pb_field_t *prev_field = iter->pos; - - if (prev_field->tag == 0) - { - /* Handle empty message types, where the first field is already the terminator. - * In other cases, the iter->pos never points to the terminator. */ - return false; - } - - iter->pos++; - - if (iter->pos->tag == 0) - { - /* Wrapped back to beginning, reinitialize */ - (void)pb_field_iter_begin(iter, iter->start, iter->dest_struct); - return false; - } - else - { - /* Increment the pointers based on previous field size */ - size_t prev_size = prev_field->data_size; - - if (PB_HTYPE(prev_field->type) == PB_HTYPE_ONEOF && - PB_HTYPE(iter->pos->type) == PB_HTYPE_ONEOF) - { - /* Don't advance pointers inside unions */ - prev_size = 0; - iter->pData = (char*)iter->pData - prev_field->data_offset; - } - else if (PB_ATYPE(prev_field->type) == PB_ATYPE_STATIC && - PB_HTYPE(prev_field->type) == PB_HTYPE_REPEATED) - { - /* In static arrays, the data_size tells the size of a single entry and - * array_size is the number of entries */ - prev_size *= prev_field->array_size; - } - else if (PB_ATYPE(prev_field->type) == PB_ATYPE_POINTER) - { - /* Pointer fields always have a constant size in the main structure. - * The data_size only applies to the dynamically allocated area. */ - prev_size = sizeof(void*); - } - - if (PB_HTYPE(prev_field->type) == PB_HTYPE_REQUIRED) - { - /* Count the required fields, in order to check their presence in the - * decoder. */ - iter->required_field_index++; - } - - iter->pData = (char*)iter->pData + prev_size + iter->pos->data_offset; - iter->pSize = (char*)iter->pData + iter->pos->size_offset; - return true; - } -} - -bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag) -{ - const pb_field_t *start = iter->pos; - - do { - if (iter->pos->tag == tag && - PB_LTYPE(iter->pos->type) != PB_LTYPE_EXTENSION) - { - /* Found the wanted field */ - return true; - } - - (void)pb_field_iter_next(iter); - } while (iter->pos != start); - - /* Searched all the way back to start, and found nothing. */ - return false; -} - - diff --git a/third_party/nanopb/pb_common.h b/third_party/nanopb/pb_common.h deleted file mode 100644 index 60b3d374914..00000000000 --- a/third_party/nanopb/pb_common.h +++ /dev/null @@ -1,42 +0,0 @@ -/* pb_common.h: Common support functions for pb_encode.c and pb_decode.c. - * These functions are rarely needed by applications directly. - */ - -#ifndef PB_COMMON_H_INCLUDED -#define PB_COMMON_H_INCLUDED - -#include "pb.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Iterator for pb_field_t list */ -struct pb_field_iter_s { - const pb_field_t *start; /* Start of the pb_field_t array */ - const pb_field_t *pos; /* Current position of the iterator */ - unsigned required_field_index; /* Zero-based index that counts only the required fields */ - void *dest_struct; /* Pointer to start of the structure */ - void *pData; /* Pointer to current field value */ - void *pSize; /* Pointer to count/has field */ -}; -typedef struct pb_field_iter_s pb_field_iter_t; - -/* Initialize the field iterator structure to beginning. - * Returns false if the message type is empty. */ -bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *dest_struct); - -/* Advance the iterator to the next field. - * Returns false when the iterator wraps back to the first field. */ -bool pb_field_iter_next(pb_field_iter_t *iter); - -/* Advance the iterator until it points at a field with the given tag. - * Returns false if no such field exists. */ -bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif - diff --git a/third_party/nanopb/pb_decode.c b/third_party/nanopb/pb_decode.c deleted file mode 100644 index 7a4e29a8fda..00000000000 --- a/third_party/nanopb/pb_decode.c +++ /dev/null @@ -1,1347 +0,0 @@ -/* pb_decode.c -- decode a protobuf using minimal resources - * - * 2011 Petteri Aimonen - */ - -/* Use the GCC warn_unused_result attribute to check that all return values - * are propagated correctly. On other compilers and gcc before 3.4.0 just - * ignore the annotation. - */ -#if !defined(__GNUC__) || ( __GNUC__ < 3) || (__GNUC__ == 3 && __GNUC_MINOR__ < 4) - #define checkreturn -#else - #define checkreturn __attribute__((warn_unused_result)) -#endif - -#include "pb.h" -#include "pb_decode.h" -#include "pb_common.h" - -/************************************** - * Declarations internal to this file * - **************************************/ - -typedef bool (*pb_decoder_t)(pb_istream_t *stream, const pb_field_t *field, void *dest) checkreturn; - -static bool checkreturn buf_read(pb_istream_t *stream, pb_byte_t *buf, size_t count); -static bool checkreturn pb_decode_varint32(pb_istream_t *stream, uint32_t *dest); -static bool checkreturn read_raw_value(pb_istream_t *stream, pb_wire_type_t wire_type, pb_byte_t *buf, size_t *size); -static bool checkreturn decode_static_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter); -static bool checkreturn decode_callback_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter); -static bool checkreturn decode_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter); -static void iter_from_extension(pb_field_iter_t *iter, pb_extension_t *extension); -static bool checkreturn default_extension_decoder(pb_istream_t *stream, pb_extension_t *extension, uint32_t tag, pb_wire_type_t wire_type); -static bool checkreturn decode_extension(pb_istream_t *stream, uint32_t tag, pb_wire_type_t wire_type, pb_field_iter_t *iter); -static bool checkreturn find_extension_field(pb_field_iter_t *iter); -static void pb_field_set_to_default(pb_field_iter_t *iter); -static void pb_message_set_to_defaults(const pb_field_t fields[], void *dest_struct); -static bool checkreturn pb_dec_varint(pb_istream_t *stream, const pb_field_t *field, void *dest); -static bool checkreturn pb_dec_uvarint(pb_istream_t *stream, const pb_field_t *field, void *dest); -static bool checkreturn pb_dec_svarint(pb_istream_t *stream, const pb_field_t *field, void *dest); -static bool checkreturn pb_dec_fixed32(pb_istream_t *stream, const pb_field_t *field, void *dest); -static bool checkreturn pb_dec_fixed64(pb_istream_t *stream, const pb_field_t *field, void *dest); -static bool checkreturn pb_dec_bytes(pb_istream_t *stream, const pb_field_t *field, void *dest); -static bool checkreturn pb_dec_string(pb_istream_t *stream, const pb_field_t *field, void *dest); -static bool checkreturn pb_dec_submessage(pb_istream_t *stream, const pb_field_t *field, void *dest); -static bool checkreturn pb_skip_varint(pb_istream_t *stream); -static bool checkreturn pb_skip_string(pb_istream_t *stream); - -#ifdef PB_ENABLE_MALLOC -static bool checkreturn allocate_field(pb_istream_t *stream, void *pData, size_t data_size, size_t array_size); -static bool checkreturn pb_release_union_field(pb_istream_t *stream, pb_field_iter_t *iter); -static void pb_release_single_field(const pb_field_iter_t *iter); -#endif - -/* --- Function pointers to field decoders --- - * Order in the array must match pb_action_t LTYPE numbering. - */ -static const pb_decoder_t PB_DECODERS[PB_LTYPES_COUNT] = { - &pb_dec_varint, - &pb_dec_uvarint, - &pb_dec_svarint, - &pb_dec_fixed32, - &pb_dec_fixed64, - - &pb_dec_bytes, - &pb_dec_string, - &pb_dec_submessage, - NULL, /* extensions */ - &pb_dec_bytes /* PB_LTYPE_FIXED_LENGTH_BYTES */ -}; - -/******************************* - * pb_istream_t implementation * - *******************************/ - -static bool checkreturn buf_read(pb_istream_t *stream, pb_byte_t *buf, size_t count) -{ - const pb_byte_t *source = (const pb_byte_t*)stream->state; - stream->state = (pb_byte_t*)stream->state + count; - - if (buf != NULL) - { - while (count--) - *buf++ = *source++; - } - - return true; -} - -bool checkreturn pb_read(pb_istream_t *stream, pb_byte_t *buf, size_t count) -{ -#ifndef PB_BUFFER_ONLY - if (buf == NULL && stream->callback != buf_read) - { - /* Skip input bytes */ - pb_byte_t tmp[16]; - while (count > 16) - { - if (!pb_read(stream, tmp, 16)) - return false; - - count -= 16; - } - - return pb_read(stream, tmp, count); - } -#endif - - if (stream->bytes_left < count) - PB_RETURN_ERROR(stream, "end-of-stream"); - -#ifndef PB_BUFFER_ONLY - if (!stream->callback(stream, buf, count)) - PB_RETURN_ERROR(stream, "io error"); -#else - if (!buf_read(stream, buf, count)) - return false; -#endif - - stream->bytes_left -= count; - return true; -} - -/* Read a single byte from input stream. buf may not be NULL. - * This is an optimization for the varint decoding. */ -static bool checkreturn pb_readbyte(pb_istream_t *stream, pb_byte_t *buf) -{ - if (stream->bytes_left == 0) - PB_RETURN_ERROR(stream, "end-of-stream"); - -#ifndef PB_BUFFER_ONLY - if (!stream->callback(stream, buf, 1)) - PB_RETURN_ERROR(stream, "io error"); -#else - *buf = *(const pb_byte_t*)stream->state; - stream->state = (pb_byte_t*)stream->state + 1; -#endif - - stream->bytes_left--; - - return true; -} - -pb_istream_t pb_istream_from_buffer(const pb_byte_t *buf, size_t bufsize) -{ - pb_istream_t stream; - /* Cast away the const from buf without a compiler error. We are - * careful to use it only in a const manner in the callbacks. - */ - union { - void *state; - const void *c_state; - } state; -#ifdef PB_BUFFER_ONLY - stream.callback = NULL; -#else - stream.callback = &buf_read; -#endif - state.c_state = buf; - stream.state = state.state; - stream.bytes_left = bufsize; -#ifndef PB_NO_ERRMSG - stream.errmsg = NULL; -#endif - return stream; -} - -/******************** - * Helper functions * - ********************/ - -static bool checkreturn pb_decode_varint32(pb_istream_t *stream, uint32_t *dest) -{ - pb_byte_t byte; - uint32_t result; - - if (!pb_readbyte(stream, &byte)) - return false; - - if ((byte & 0x80) == 0) - { - /* Quick case, 1 byte value */ - result = byte; - } - else - { - /* Multibyte case */ - uint_fast8_t bitpos = 7; - result = byte & 0x7F; - - do - { - if (bitpos >= 32) - PB_RETURN_ERROR(stream, "varint overflow"); - - if (!pb_readbyte(stream, &byte)) - return false; - - result |= (uint32_t)(byte & 0x7F) << bitpos; - bitpos = (uint_fast8_t)(bitpos + 7); - } while (byte & 0x80); - } - - *dest = result; - return true; -} - -bool checkreturn pb_decode_varint(pb_istream_t *stream, uint64_t *dest) -{ - pb_byte_t byte; - uint_fast8_t bitpos = 0; - uint64_t result = 0; - - do - { - if (bitpos >= 64) - PB_RETURN_ERROR(stream, "varint overflow"); - - if (!pb_readbyte(stream, &byte)) - return false; - - result |= (uint64_t)(byte & 0x7F) << bitpos; - bitpos = (uint_fast8_t)(bitpos + 7); - } while (byte & 0x80); - - *dest = result; - return true; -} - -bool checkreturn pb_skip_varint(pb_istream_t *stream) -{ - pb_byte_t byte; - do - { - if (!pb_read(stream, &byte, 1)) - return false; - } while (byte & 0x80); - return true; -} - -bool checkreturn pb_skip_string(pb_istream_t *stream) -{ - uint32_t length; - if (!pb_decode_varint32(stream, &length)) - return false; - - return pb_read(stream, NULL, length); -} - -bool checkreturn pb_decode_tag(pb_istream_t *stream, pb_wire_type_t *wire_type, uint32_t *tag, bool *eof) -{ - uint32_t temp; - *eof = false; - *wire_type = (pb_wire_type_t) 0; - *tag = 0; - - if (!pb_decode_varint32(stream, &temp)) - { - if (stream->bytes_left == 0) - *eof = true; - - return false; - } - - if (temp == 0) - { - *eof = true; /* Special feature: allow 0-terminated messages. */ - return false; - } - - *tag = temp >> 3; - *wire_type = (pb_wire_type_t)(temp & 7); - return true; -} - -bool checkreturn pb_skip_field(pb_istream_t *stream, pb_wire_type_t wire_type) -{ - switch (wire_type) - { - case PB_WT_VARINT: return pb_skip_varint(stream); - case PB_WT_64BIT: return pb_read(stream, NULL, 8); - case PB_WT_STRING: return pb_skip_string(stream); - case PB_WT_32BIT: return pb_read(stream, NULL, 4); - default: PB_RETURN_ERROR(stream, "invalid wire_type"); - } -} - -/* Read a raw value to buffer, for the purpose of passing it to callback as - * a substream. Size is maximum size on call, and actual size on return. - */ -static bool checkreturn read_raw_value(pb_istream_t *stream, pb_wire_type_t wire_type, pb_byte_t *buf, size_t *size) -{ - size_t max_size = *size; - switch (wire_type) - { - case PB_WT_VARINT: - *size = 0; - do - { - (*size)++; - if (*size > max_size) return false; - if (!pb_read(stream, buf, 1)) return false; - } while (*buf++ & 0x80); - return true; - - case PB_WT_64BIT: - *size = 8; - return pb_read(stream, buf, 8); - - case PB_WT_32BIT: - *size = 4; - return pb_read(stream, buf, 4); - - default: PB_RETURN_ERROR(stream, "invalid wire_type"); - } -} - -/* Decode string length from stream and return a substream with limited length. - * Remember to close the substream using pb_close_string_substream(). - */ -bool checkreturn pb_make_string_substream(pb_istream_t *stream, pb_istream_t *substream) -{ - uint32_t size; - if (!pb_decode_varint32(stream, &size)) - return false; - - *substream = *stream; - if (substream->bytes_left < size) - PB_RETURN_ERROR(stream, "parent stream too short"); - - substream->bytes_left = size; - stream->bytes_left -= size; - return true; -} - -void pb_close_string_substream(pb_istream_t *stream, pb_istream_t *substream) -{ - stream->state = substream->state; - -#ifndef PB_NO_ERRMSG - stream->errmsg = substream->errmsg; -#endif -} - -/************************* - * Decode a single field * - *************************/ - -static bool checkreturn decode_static_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter) -{ - pb_type_t type; - pb_decoder_t func; - - type = iter->pos->type; - func = PB_DECODERS[PB_LTYPE(type)]; - - switch (PB_HTYPE(type)) - { - case PB_HTYPE_REQUIRED: - return func(stream, iter->pos, iter->pData); - - case PB_HTYPE_OPTIONAL: - *(bool*)iter->pSize = true; - return func(stream, iter->pos, iter->pData); - - case PB_HTYPE_REPEATED: - if (wire_type == PB_WT_STRING - && PB_LTYPE(type) <= PB_LTYPE_LAST_PACKABLE) - { - /* Packed array */ - bool status = true; - pb_size_t *size = (pb_size_t*)iter->pSize; - pb_istream_t substream; - if (!pb_make_string_substream(stream, &substream)) - return false; - - while (substream.bytes_left > 0 && *size < iter->pos->array_size) - { - void *pItem = (char*)iter->pData + iter->pos->data_size * (*size); - if (!func(&substream, iter->pos, pItem)) - { - status = false; - break; - } - (*size)++; - } - pb_close_string_substream(stream, &substream); - - if (substream.bytes_left != 0) - PB_RETURN_ERROR(stream, "array overflow"); - - return status; - } - else - { - /* Repeated field */ - pb_size_t *size = (pb_size_t*)iter->pSize; - void *pItem = (char*)iter->pData + iter->pos->data_size * (*size); - if (*size >= iter->pos->array_size) - PB_RETURN_ERROR(stream, "array overflow"); - - (*size)++; - return func(stream, iter->pos, pItem); - } - - case PB_HTYPE_ONEOF: - *(pb_size_t*)iter->pSize = iter->pos->tag; - if (PB_LTYPE(type) == PB_LTYPE_SUBMESSAGE) - { - /* We memset to zero so that any callbacks are set to NULL. - * Then set any default values. */ - memset(iter->pData, 0, iter->pos->data_size); - pb_message_set_to_defaults((const pb_field_t*)iter->pos->ptr, iter->pData); - } - return func(stream, iter->pos, iter->pData); - - default: - PB_RETURN_ERROR(stream, "invalid field type"); - } -} - -#ifdef PB_ENABLE_MALLOC -/* Allocate storage for the field and store the pointer at iter->pData. - * array_size is the number of entries to reserve in an array. - * Zero size is not allowed, use pb_free() for releasing. - */ -static bool checkreturn allocate_field(pb_istream_t *stream, void *pData, size_t data_size, size_t array_size) -{ - void *ptr = *(void**)pData; - - if (data_size == 0 || array_size == 0) - PB_RETURN_ERROR(stream, "invalid size"); - - /* Check for multiplication overflows. - * This code avoids the costly division if the sizes are small enough. - * Multiplication is safe as long as only half of bits are set - * in either multiplicand. - */ - { - const size_t check_limit = (size_t)1 << (sizeof(size_t) * 4); - if (data_size >= check_limit || array_size >= check_limit) - { - const size_t size_max = (size_t)-1; - if (size_max / array_size < data_size) - { - PB_RETURN_ERROR(stream, "size too large"); - } - } - } - - /* Allocate new or expand previous allocation */ - /* Note: on failure the old pointer will remain in the structure, - * the message must be freed by caller also on error return. */ - ptr = pb_realloc(ptr, array_size * data_size); - if (ptr == NULL) - PB_RETURN_ERROR(stream, "realloc failed"); - - *(void**)pData = ptr; - return true; -} - -/* Clear a newly allocated item in case it contains a pointer, or is a submessage. */ -static void initialize_pointer_field(void *pItem, pb_field_iter_t *iter) -{ - if (PB_LTYPE(iter->pos->type) == PB_LTYPE_STRING || - PB_LTYPE(iter->pos->type) == PB_LTYPE_BYTES) - { - *(void**)pItem = NULL; - } - else if (PB_LTYPE(iter->pos->type) == PB_LTYPE_SUBMESSAGE) - { - pb_message_set_to_defaults((const pb_field_t *) iter->pos->ptr, pItem); - } -} -#endif - -static bool checkreturn decode_pointer_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter) -{ -#ifndef PB_ENABLE_MALLOC - PB_UNUSED(wire_type); - PB_UNUSED(iter); - PB_RETURN_ERROR(stream, "no malloc support"); -#else - pb_type_t type; - pb_decoder_t func; - - type = iter->pos->type; - func = PB_DECODERS[PB_LTYPE(type)]; - - switch (PB_HTYPE(type)) - { - case PB_HTYPE_REQUIRED: - case PB_HTYPE_OPTIONAL: - case PB_HTYPE_ONEOF: - if (PB_LTYPE(type) == PB_LTYPE_SUBMESSAGE && - *(void**)iter->pData != NULL) - { - /* Duplicate field, have to release the old allocation first. */ - pb_release_single_field(iter); - } - - if (PB_HTYPE(type) == PB_HTYPE_ONEOF) - { - *(pb_size_t*)iter->pSize = iter->pos->tag; - } - - if (PB_LTYPE(type) == PB_LTYPE_STRING || - PB_LTYPE(type) == PB_LTYPE_BYTES) - { - return func(stream, iter->pos, iter->pData); - } - else - { - if (!allocate_field(stream, iter->pData, iter->pos->data_size, 1)) - return false; - - initialize_pointer_field(*(void**)iter->pData, iter); - return func(stream, iter->pos, *(void**)iter->pData); - } - - case PB_HTYPE_REPEATED: - if (wire_type == PB_WT_STRING - && PB_LTYPE(type) <= PB_LTYPE_LAST_PACKABLE) - { - /* Packed array, multiple items come in at once. */ - bool status = true; - pb_size_t *size = (pb_size_t*)iter->pSize; - size_t allocated_size = *size; - void *pItem; - pb_istream_t substream; - - if (!pb_make_string_substream(stream, &substream)) - return false; - - while (substream.bytes_left) - { - if ((size_t)*size + 1 > allocated_size) - { - /* Allocate more storage. This tries to guess the - * number of remaining entries. Round the division - * upwards. */ - allocated_size += (substream.bytes_left - 1) / iter->pos->data_size + 1; - - if (!allocate_field(&substream, iter->pData, iter->pos->data_size, allocated_size)) - { - status = false; - break; - } - } - - /* Decode the array entry */ - pItem = *(char**)iter->pData + iter->pos->data_size * (*size); - initialize_pointer_field(pItem, iter); - if (!func(&substream, iter->pos, pItem)) - { - status = false; - break; - } - - if (*size == PB_SIZE_MAX) - { -#ifndef PB_NO_ERRMSG - stream->errmsg = "too many array entries"; -#endif - status = false; - break; - } - - (*size)++; - } - pb_close_string_substream(stream, &substream); - - return status; - } - else - { - /* Normal repeated field, i.e. only one item at a time. */ - pb_size_t *size = (pb_size_t*)iter->pSize; - void *pItem; - - if (*size == PB_SIZE_MAX) - PB_RETURN_ERROR(stream, "too many array entries"); - - (*size)++; - if (!allocate_field(stream, iter->pData, iter->pos->data_size, *size)) - return false; - - pItem = *(char**)iter->pData + iter->pos->data_size * (*size - 1); - initialize_pointer_field(pItem, iter); - return func(stream, iter->pos, pItem); - } - - default: - PB_RETURN_ERROR(stream, "invalid field type"); - } -#endif -} - -static bool checkreturn decode_callback_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter) -{ - pb_callback_t *pCallback = (pb_callback_t*)iter->pData; - -#ifdef PB_OLD_CALLBACK_STYLE - void *arg = pCallback->arg; -#else - void **arg = &(pCallback->arg); -#endif - - if (pCallback->funcs.decode == NULL) - return pb_skip_field(stream, wire_type); - - if (wire_type == PB_WT_STRING) - { - pb_istream_t substream; - - if (!pb_make_string_substream(stream, &substream)) - return false; - - do - { - if (!pCallback->funcs.decode(&substream, iter->pos, arg)) - PB_RETURN_ERROR(stream, "callback failed"); - } while (substream.bytes_left); - - pb_close_string_substream(stream, &substream); - return true; - } - else - { - /* Copy the single scalar value to stack. - * This is required so that we can limit the stream length, - * which in turn allows to use same callback for packed and - * not-packed fields. */ - pb_istream_t substream; - pb_byte_t buffer[10]; - size_t size = sizeof(buffer); - - if (!read_raw_value(stream, wire_type, buffer, &size)) - return false; - substream = pb_istream_from_buffer(buffer, size); - - return pCallback->funcs.decode(&substream, iter->pos, arg); - } -} - -static bool checkreturn decode_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter) -{ -#ifdef PB_ENABLE_MALLOC - /* When decoding an oneof field, check if there is old data that must be - * released first. */ - if (PB_HTYPE(iter->pos->type) == PB_HTYPE_ONEOF) - { - if (!pb_release_union_field(stream, iter)) - return false; - } -#endif - - switch (PB_ATYPE(iter->pos->type)) - { - case PB_ATYPE_STATIC: - return decode_static_field(stream, wire_type, iter); - - case PB_ATYPE_POINTER: - return decode_pointer_field(stream, wire_type, iter); - - case PB_ATYPE_CALLBACK: - return decode_callback_field(stream, wire_type, iter); - - default: - PB_RETURN_ERROR(stream, "invalid field type"); - } -} - -static void iter_from_extension(pb_field_iter_t *iter, pb_extension_t *extension) -{ - /* Fake a field iterator for the extension field. - * It is not actually safe to advance this iterator, but decode_field - * will not even try to. */ - const pb_field_t *field = (const pb_field_t*)extension->type->arg; - (void)pb_field_iter_begin(iter, field, extension->dest); - iter->pData = extension->dest; - iter->pSize = &extension->found; - - if (PB_ATYPE(field->type) == PB_ATYPE_POINTER) - { - /* For pointer extensions, the pointer is stored directly - * in the extension structure. This avoids having an extra - * indirection. */ - iter->pData = &extension->dest; - } -} - -/* Default handler for extension fields. Expects a pb_field_t structure - * in extension->type->arg. */ -static bool checkreturn default_extension_decoder(pb_istream_t *stream, - pb_extension_t *extension, uint32_t tag, pb_wire_type_t wire_type) -{ - const pb_field_t *field = (const pb_field_t*)extension->type->arg; - pb_field_iter_t iter; - - if (field->tag != tag) - return true; - - iter_from_extension(&iter, extension); - extension->found = true; - return decode_field(stream, wire_type, &iter); -} - -/* Try to decode an unknown field as an extension field. Tries each extension - * decoder in turn, until one of them handles the field or loop ends. */ -static bool checkreturn decode_extension(pb_istream_t *stream, - uint32_t tag, pb_wire_type_t wire_type, pb_field_iter_t *iter) -{ - pb_extension_t *extension = *(pb_extension_t* const *)iter->pData; - size_t pos = stream->bytes_left; - - while (extension != NULL && pos == stream->bytes_left) - { - bool status; - if (extension->type->decode) - status = extension->type->decode(stream, extension, tag, wire_type); - else - status = default_extension_decoder(stream, extension, tag, wire_type); - - if (!status) - return false; - - extension = extension->next; - } - - return true; -} - -/* Step through the iterator until an extension field is found or until all - * entries have been checked. There can be only one extension field per - * message. Returns false if no extension field is found. */ -static bool checkreturn find_extension_field(pb_field_iter_t *iter) -{ - const pb_field_t *start = iter->pos; - - do { - if (PB_LTYPE(iter->pos->type) == PB_LTYPE_EXTENSION) - return true; - (void)pb_field_iter_next(iter); - } while (iter->pos != start); - - return false; -} - -/* Initialize message fields to default values, recursively */ -static void pb_field_set_to_default(pb_field_iter_t *iter) -{ - pb_type_t type; - type = iter->pos->type; - - if (PB_LTYPE(type) == PB_LTYPE_EXTENSION) - { - pb_extension_t *ext = *(pb_extension_t* const *)iter->pData; - while (ext != NULL) - { - pb_field_iter_t ext_iter; - ext->found = false; - iter_from_extension(&ext_iter, ext); - pb_field_set_to_default(&ext_iter); - ext = ext->next; - } - } - else if (PB_ATYPE(type) == PB_ATYPE_STATIC) - { - bool init_data = true; - if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL) - { - /* Set has_field to false. Still initialize the optional field - * itself also. */ - *(bool*)iter->pSize = false; - } - else if (PB_HTYPE(type) == PB_HTYPE_REPEATED || - PB_HTYPE(type) == PB_HTYPE_ONEOF) - { - /* REPEATED: Set array count to 0, no need to initialize contents. - ONEOF: Set which_field to 0. */ - *(pb_size_t*)iter->pSize = 0; - init_data = false; - } - - if (init_data) - { - if (PB_LTYPE(iter->pos->type) == PB_LTYPE_SUBMESSAGE) - { - /* Initialize submessage to defaults */ - pb_message_set_to_defaults((const pb_field_t *) iter->pos->ptr, iter->pData); - } - else if (iter->pos->ptr != NULL) - { - /* Initialize to default value */ - memcpy(iter->pData, iter->pos->ptr, iter->pos->data_size); - } - else - { - /* Initialize to zeros */ - memset(iter->pData, 0, iter->pos->data_size); - } - } - } - else if (PB_ATYPE(type) == PB_ATYPE_POINTER) - { - /* Initialize the pointer to NULL. */ - *(void**)iter->pData = NULL; - - /* Initialize array count to 0. */ - if (PB_HTYPE(type) == PB_HTYPE_REPEATED || - PB_HTYPE(type) == PB_HTYPE_ONEOF) - { - *(pb_size_t*)iter->pSize = 0; - } - } - else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK) - { - /* Don't overwrite callback */ - } -} - -static void pb_message_set_to_defaults(const pb_field_t fields[], void *dest_struct) -{ - pb_field_iter_t iter; - - if (!pb_field_iter_begin(&iter, fields, dest_struct)) - return; /* Empty message type */ - - do - { - pb_field_set_to_default(&iter); - } while (pb_field_iter_next(&iter)); -} - -/********************* - * Decode all fields * - *********************/ - -bool checkreturn pb_decode_noinit(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct) -{ - uint32_t fields_seen[(PB_MAX_REQUIRED_FIELDS + 31) / 32] = {0, 0}; - const uint32_t allbits = ~(uint32_t)0; - uint32_t extension_range_start = 0; - pb_field_iter_t iter; - - /* Return value ignored, as empty message types will be correctly handled by - * pb_field_iter_find() anyway. */ - (void)pb_field_iter_begin(&iter, fields, dest_struct); - - while (stream->bytes_left) - { - uint32_t tag; - pb_wire_type_t wire_type; - bool eof; - - if (!pb_decode_tag(stream, &wire_type, &tag, &eof)) - { - if (eof) - break; - else - return false; - } - - if (!pb_field_iter_find(&iter, tag)) - { - /* No match found, check if it matches an extension. */ - if (tag >= extension_range_start) - { - if (!find_extension_field(&iter)) - extension_range_start = (uint32_t)-1; - else - extension_range_start = iter.pos->tag; - - if (tag >= extension_range_start) - { - size_t pos = stream->bytes_left; - - if (!decode_extension(stream, tag, wire_type, &iter)) - return false; - - if (pos != stream->bytes_left) - { - /* The field was handled */ - continue; - } - } - } - - /* No match found, skip data */ - if (!pb_skip_field(stream, wire_type)) - return false; - continue; - } - - if (PB_HTYPE(iter.pos->type) == PB_HTYPE_REQUIRED - && iter.required_field_index < PB_MAX_REQUIRED_FIELDS) - { - uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31)); - fields_seen[iter.required_field_index >> 5] |= tmp; - } - - if (!decode_field(stream, wire_type, &iter)) - return false; - } - - /* Check that all required fields were present. */ - { - /* First figure out the number of required fields by - * seeking to the end of the field array. Usually we - * are already close to end after decoding. - */ - unsigned req_field_count; - pb_type_t last_type; - unsigned i; - do { - req_field_count = iter.required_field_index; - last_type = iter.pos->type; - } while (pb_field_iter_next(&iter)); - - /* Fixup if last field was also required. */ - if (PB_HTYPE(last_type) == PB_HTYPE_REQUIRED && iter.pos->tag != 0) - req_field_count++; - - if (req_field_count > 0) - { - /* Check the whole words */ - for (i = 0; i < (req_field_count >> 5); i++) - { - if (fields_seen[i] != allbits) - PB_RETURN_ERROR(stream, "missing required field"); - } - - /* Check the remaining bits */ - if (fields_seen[req_field_count >> 5] != (allbits >> (32 - (req_field_count & 31)))) - PB_RETURN_ERROR(stream, "missing required field"); - } - } - - return true; -} - -bool checkreturn pb_decode(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct) -{ - bool status; - pb_message_set_to_defaults(fields, dest_struct); - status = pb_decode_noinit(stream, fields, dest_struct); - -#ifdef PB_ENABLE_MALLOC - if (!status) - pb_release(fields, dest_struct); -#endif - - return status; -} - -bool pb_decode_delimited(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct) -{ - pb_istream_t substream; - bool status; - - if (!pb_make_string_substream(stream, &substream)) - return false; - - status = pb_decode(&substream, fields, dest_struct); - pb_close_string_substream(stream, &substream); - return status; -} - -#ifdef PB_ENABLE_MALLOC -/* Given an oneof field, if there has already been a field inside this oneof, - * release it before overwriting with a different one. */ -static bool pb_release_union_field(pb_istream_t *stream, pb_field_iter_t *iter) -{ - pb_size_t old_tag = *(pb_size_t*)iter->pSize; /* Previous which_ value */ - pb_size_t new_tag = iter->pos->tag; /* New which_ value */ - - if (old_tag == 0) - return true; /* Ok, no old data in union */ - - if (old_tag == new_tag) - return true; /* Ok, old data is of same type => merge */ - - /* Release old data. The find can fail if the message struct contains - * invalid data. */ - if (!pb_field_iter_find(iter, old_tag)) - PB_RETURN_ERROR(stream, "invalid union tag"); - - pb_release_single_field(iter); - - /* Restore iterator to where it should be. - * This shouldn't fail unless the pb_field_t structure is corrupted. */ - if (!pb_field_iter_find(iter, new_tag)) - PB_RETURN_ERROR(stream, "iterator error"); - - return true; -} - -static void pb_release_single_field(const pb_field_iter_t *iter) -{ - pb_type_t type; - type = iter->pos->type; - - if (PB_HTYPE(type) == PB_HTYPE_ONEOF) - { - if (*(pb_size_t*)iter->pSize != iter->pos->tag) - return; /* This is not the current field in the union */ - } - - /* Release anything contained inside an extension or submsg. - * This has to be done even if the submsg itself is statically - * allocated. */ - if (PB_LTYPE(type) == PB_LTYPE_EXTENSION) - { - /* Release fields from all extensions in the linked list */ - pb_extension_t *ext = *(pb_extension_t**)iter->pData; - while (ext != NULL) - { - pb_field_iter_t ext_iter; - iter_from_extension(&ext_iter, ext); - pb_release_single_field(&ext_iter); - ext = ext->next; - } - } - else if (PB_LTYPE(type) == PB_LTYPE_SUBMESSAGE) - { - /* Release fields in submessage or submsg array */ - void *pItem = iter->pData; - pb_size_t count = 1; - - if (PB_ATYPE(type) == PB_ATYPE_POINTER) - { - pItem = *(void**)iter->pData; - } - - if (PB_HTYPE(type) == PB_HTYPE_REPEATED) - { - count = *(pb_size_t*)iter->pSize; - - if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > iter->pos->array_size) - { - /* Protect against corrupted _count fields */ - count = iter->pos->array_size; - } - } - - if (pItem) - { - while (count--) - { - pb_release((const pb_field_t*)iter->pos->ptr, pItem); - pItem = (char*)pItem + iter->pos->data_size; - } - } - } - - if (PB_ATYPE(type) == PB_ATYPE_POINTER) - { - if (PB_HTYPE(type) == PB_HTYPE_REPEATED && - (PB_LTYPE(type) == PB_LTYPE_STRING || - PB_LTYPE(type) == PB_LTYPE_BYTES)) - { - /* Release entries in repeated string or bytes array */ - void **pItem = *(void***)iter->pData; - pb_size_t count = *(pb_size_t*)iter->pSize; - while (count--) - { - pb_free(*pItem); - *pItem++ = NULL; - } - } - - if (PB_HTYPE(type) == PB_HTYPE_REPEATED) - { - /* We are going to release the array, so set the size to 0 */ - *(pb_size_t*)iter->pSize = 0; - } - - /* Release main item */ - pb_free(*(void**)iter->pData); - *(void**)iter->pData = NULL; - } -} - -void pb_release(const pb_field_t fields[], void *dest_struct) -{ - pb_field_iter_t iter; - - if (!dest_struct) - return; /* Ignore NULL pointers, similar to free() */ - - if (!pb_field_iter_begin(&iter, fields, dest_struct)) - return; /* Empty message type */ - - do - { - pb_release_single_field(&iter); - } while (pb_field_iter_next(&iter)); -} -#endif - -/* Field decoders */ - -bool pb_decode_svarint(pb_istream_t *stream, int64_t *dest) -{ - uint64_t value; - if (!pb_decode_varint(stream, &value)) - return false; - - if (value & 1) - *dest = (int64_t)(~(value >> 1)); - else - *dest = (int64_t)(value >> 1); - - return true; -} - -bool pb_decode_fixed32(pb_istream_t *stream, void *dest) -{ - pb_byte_t bytes[4]; - - if (!pb_read(stream, bytes, 4)) - return false; - - *(uint32_t*)dest = ((uint32_t)bytes[0] << 0) | - ((uint32_t)bytes[1] << 8) | - ((uint32_t)bytes[2] << 16) | - ((uint32_t)bytes[3] << 24); - return true; -} - -bool pb_decode_fixed64(pb_istream_t *stream, void *dest) -{ - pb_byte_t bytes[8]; - - if (!pb_read(stream, bytes, 8)) - return false; - - *(uint64_t*)dest = ((uint64_t)bytes[0] << 0) | - ((uint64_t)bytes[1] << 8) | - ((uint64_t)bytes[2] << 16) | - ((uint64_t)bytes[3] << 24) | - ((uint64_t)bytes[4] << 32) | - ((uint64_t)bytes[5] << 40) | - ((uint64_t)bytes[6] << 48) | - ((uint64_t)bytes[7] << 56); - - return true; -} - -static bool checkreturn pb_dec_varint(pb_istream_t *stream, const pb_field_t *field, void *dest) -{ - uint64_t value; - int64_t svalue; - int64_t clamped; - if (!pb_decode_varint(stream, &value)) - return false; - - /* See issue 97: Google's C++ protobuf allows negative varint values to - * be cast as int32_t, instead of the int64_t that should be used when - * encoding. Previous nanopb versions had a bug in encoding. In order to - * not break decoding of such messages, we cast <=32 bit fields to - * int32_t first to get the sign correct. - */ - if (field->data_size == sizeof(int64_t)) - svalue = (int64_t)value; - else - svalue = (int32_t)value; - - /* Cast to the proper field size, while checking for overflows */ - if (field->data_size == sizeof(int64_t)) - clamped = *(int64_t*)dest = svalue; - else if (field->data_size == sizeof(int32_t)) - clamped = *(int32_t*)dest = (int32_t)svalue; - else if (field->data_size == sizeof(int_least16_t)) - clamped = *(int_least16_t*)dest = (int_least16_t)svalue; - else if (field->data_size == sizeof(int_least8_t)) - clamped = *(int_least8_t*)dest = (int_least8_t)svalue; - else - PB_RETURN_ERROR(stream, "invalid data_size"); - - if (clamped != svalue) - PB_RETURN_ERROR(stream, "integer too large"); - - return true; -} - -static bool checkreturn pb_dec_uvarint(pb_istream_t *stream, const pb_field_t *field, void *dest) -{ - uint64_t value, clamped; - if (!pb_decode_varint(stream, &value)) - return false; - - /* Cast to the proper field size, while checking for overflows */ - if (field->data_size == sizeof(uint64_t)) - clamped = *(uint64_t*)dest = value; - else if (field->data_size == sizeof(uint32_t)) - clamped = *(uint32_t*)dest = (uint32_t)value; - else if (field->data_size == sizeof(uint_least16_t)) - clamped = *(uint_least16_t*)dest = (uint_least16_t)value; - else if (field->data_size == sizeof(uint_least8_t)) - clamped = *(uint_least8_t*)dest = (uint_least8_t)value; - else - PB_RETURN_ERROR(stream, "invalid data_size"); - - if (clamped != value) - PB_RETURN_ERROR(stream, "integer too large"); - - return true; -} - -static bool checkreturn pb_dec_svarint(pb_istream_t *stream, const pb_field_t *field, void *dest) -{ - int64_t value, clamped; - if (!pb_decode_svarint(stream, &value)) - return false; - - /* Cast to the proper field size, while checking for overflows */ - if (field->data_size == sizeof(int64_t)) - clamped = *(int64_t*)dest = value; - else if (field->data_size == sizeof(int32_t)) - clamped = *(int32_t*)dest = (int32_t)value; - else if (field->data_size == sizeof(int_least16_t)) - clamped = *(int_least16_t*)dest = (int_least16_t)value; - else if (field->data_size == sizeof(int_least8_t)) - clamped = *(int_least8_t*)dest = (int_least8_t)value; - else - PB_RETURN_ERROR(stream, "invalid data_size"); - - if (clamped != value) - PB_RETURN_ERROR(stream, "integer too large"); - - return true; -} - -static bool checkreturn pb_dec_fixed32(pb_istream_t *stream, const pb_field_t *field, void *dest) -{ - PB_UNUSED(field); - return pb_decode_fixed32(stream, dest); -} - -static bool checkreturn pb_dec_fixed64(pb_istream_t *stream, const pb_field_t *field, void *dest) -{ - PB_UNUSED(field); - return pb_decode_fixed64(stream, dest); -} - -static bool checkreturn pb_dec_bytes(pb_istream_t *stream, const pb_field_t *field, void *dest) -{ - uint32_t size; - size_t alloc_size; - pb_bytes_array_t *bdest; - - if (!pb_decode_varint32(stream, &size)) - return false; - - if (size > PB_SIZE_MAX) - PB_RETURN_ERROR(stream, "bytes overflow"); - - alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size); - if (size > alloc_size) - PB_RETURN_ERROR(stream, "size too large"); - - if (PB_ATYPE(field->type) == PB_ATYPE_POINTER) - { -#ifndef PB_ENABLE_MALLOC - PB_RETURN_ERROR(stream, "no malloc support"); -#else - if (!allocate_field(stream, dest, alloc_size, 1)) - return false; - bdest = *(pb_bytes_array_t**)dest; -#endif - } - else - { - if (PB_LTYPE(field->type) == PB_LTYPE_FIXED_LENGTH_BYTES) { - if (size != field->data_size) - PB_RETURN_ERROR(stream, "incorrect inline bytes size"); - return pb_read(stream, (pb_byte_t*)dest, field->data_size); - } - - if (alloc_size > field->data_size) - PB_RETURN_ERROR(stream, "bytes overflow"); - bdest = (pb_bytes_array_t*)dest; - } - - bdest->size = (pb_size_t)size; - return pb_read(stream, bdest->bytes, size); -} - -static bool checkreturn pb_dec_string(pb_istream_t *stream, const pb_field_t *field, void *dest) -{ - uint32_t size; - size_t alloc_size; - bool status; - if (!pb_decode_varint32(stream, &size)) - return false; - - /* Space for null terminator */ - alloc_size = size + 1; - - if (alloc_size < size) - PB_RETURN_ERROR(stream, "size too large"); - - if (PB_ATYPE(field->type) == PB_ATYPE_POINTER) - { -#ifndef PB_ENABLE_MALLOC - PB_RETURN_ERROR(stream, "no malloc support"); -#else - if (!allocate_field(stream, dest, alloc_size, 1)) - return false; - dest = *(void**)dest; -#endif - } - else - { - if (alloc_size > field->data_size) - PB_RETURN_ERROR(stream, "string overflow"); - } - - status = pb_read(stream, (pb_byte_t*)dest, size); - *((pb_byte_t*)dest + size) = 0; - return status; -} - -static bool checkreturn pb_dec_submessage(pb_istream_t *stream, const pb_field_t *field, void *dest) -{ - bool status; - pb_istream_t substream; - const pb_field_t* submsg_fields = (const pb_field_t*)field->ptr; - - if (!pb_make_string_substream(stream, &substream)) - return false; - - if (field->ptr == NULL) - PB_RETURN_ERROR(stream, "invalid field descriptor"); - - /* New array entries need to be initialized, while required and optional - * submessages have already been initialized in the top-level pb_decode. */ - if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED) - status = pb_decode(&substream, submsg_fields, dest); - else - status = pb_decode_noinit(&substream, submsg_fields, dest); - - pb_close_string_substream(stream, &substream); - return status; -} diff --git a/third_party/nanopb/pb_decode.h b/third_party/nanopb/pb_decode.h deleted file mode 100644 index 1d9bb1945c1..00000000000 --- a/third_party/nanopb/pb_decode.h +++ /dev/null @@ -1,149 +0,0 @@ -/* pb_decode.h: Functions to decode protocol buffers. Depends on pb_decode.c. - * The main function is pb_decode. You also need an input stream, and the - * field descriptions created by nanopb_generator.py. - */ - -#ifndef PB_DECODE_H_INCLUDED -#define PB_DECODE_H_INCLUDED - -#include "pb.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Structure for defining custom input streams. You will need to provide - * a callback function to read the bytes from your storage, which can be - * for example a file or a network socket. - * - * The callback must conform to these rules: - * - * 1) Return false on IO errors. This will cause decoding to abort. - * 2) You can use state to store your own data (e.g. buffer pointer), - * and rely on pb_read to verify that no-body reads past bytes_left. - * 3) Your callback may be used with substreams, in which case bytes_left - * is different than from the main stream. Don't use bytes_left to compute - * any pointers. - */ -struct pb_istream_s -{ -#ifdef PB_BUFFER_ONLY - /* Callback pointer is not used in buffer-only configuration. - * Having an int pointer here allows binary compatibility but - * gives an error if someone tries to assign callback function. - */ - int *callback; -#else - bool (*callback)(pb_istream_t *stream, pb_byte_t *buf, size_t count); -#endif - - void *state; /* Free field for use by callback implementation */ - size_t bytes_left; - -#ifndef PB_NO_ERRMSG - const char *errmsg; -#endif -}; - -/*************************** - * Main decoding functions * - ***************************/ - -/* Decode a single protocol buffers message from input stream into a C structure. - * Returns true on success, false on any failure. - * The actual struct pointed to by dest must match the description in fields. - * Callback fields of the destination structure must be initialized by caller. - * All other fields will be initialized by this function. - * - * Example usage: - * MyMessage msg = {}; - * uint8_t buffer[64]; - * pb_istream_t stream; - * - * // ... read some data into buffer ... - * - * stream = pb_istream_from_buffer(buffer, count); - * pb_decode(&stream, MyMessage_fields, &msg); - */ -bool pb_decode(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct); - -/* Same as pb_decode, except does not initialize the destination structure - * to default values. This is slightly faster if you need no default values - * and just do memset(struct, 0, sizeof(struct)) yourself. - * - * This can also be used for 'merging' two messages, i.e. update only the - * fields that exist in the new message. - * - * Note: If this function returns with an error, it will not release any - * dynamically allocated fields. You will need to call pb_release() yourself. - */ -bool pb_decode_noinit(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct); - -/* Same as pb_decode, except expects the stream to start with the message size - * encoded as varint. Corresponds to parseDelimitedFrom() in Google's - * protobuf API. - */ -bool pb_decode_delimited(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct); - -#ifdef PB_ENABLE_MALLOC -/* Release any allocated pointer fields. If you use dynamic allocation, you should - * call this for any successfully decoded message when you are done with it. If - * pb_decode() returns with an error, the message is already released. - */ -void pb_release(const pb_field_t fields[], void *dest_struct); -#endif - - -/************************************** - * Functions for manipulating streams * - **************************************/ - -/* Create an input stream for reading from a memory buffer. - * - * Alternatively, you can use a custom stream that reads directly from e.g. - * a file or a network socket. - */ -pb_istream_t pb_istream_from_buffer(const pb_byte_t *buf, size_t bufsize); - -/* Function to read from a pb_istream_t. You can use this if you need to - * read some custom header data, or to read data in field callbacks. - */ -bool pb_read(pb_istream_t *stream, pb_byte_t *buf, size_t count); - - -/************************************************ - * Helper functions for writing field callbacks * - ************************************************/ - -/* Decode the tag for the next field in the stream. Gives the wire type and - * field tag. At end of the message, returns false and sets eof to true. */ -bool pb_decode_tag(pb_istream_t *stream, pb_wire_type_t *wire_type, uint32_t *tag, bool *eof); - -/* Skip the field payload data, given the wire type. */ -bool pb_skip_field(pb_istream_t *stream, pb_wire_type_t wire_type); - -/* Decode an integer in the varint format. This works for bool, enum, int32, - * int64, uint32 and uint64 field types. */ -bool pb_decode_varint(pb_istream_t *stream, uint64_t *dest); - -/* Decode an integer in the zig-zagged svarint format. This works for sint32 - * and sint64. */ -bool pb_decode_svarint(pb_istream_t *stream, int64_t *dest); - -/* Decode a fixed32, sfixed32 or float value. You need to pass a pointer to - * a 4-byte wide C variable. */ -bool pb_decode_fixed32(pb_istream_t *stream, void *dest); - -/* Decode a fixed64, sfixed64 or double value. You need to pass a pointer to - * a 8-byte wide C variable. */ -bool pb_decode_fixed64(pb_istream_t *stream, void *dest); - -/* Make a limited-length substream for reading a PB_WT_STRING field. */ -bool pb_make_string_substream(pb_istream_t *stream, pb_istream_t *substream); -void pb_close_string_substream(pb_istream_t *stream, pb_istream_t *substream); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif diff --git a/third_party/nanopb/pb_encode.c b/third_party/nanopb/pb_encode.c deleted file mode 100644 index 4685614cf70..00000000000 --- a/third_party/nanopb/pb_encode.c +++ /dev/null @@ -1,696 +0,0 @@ -/* pb_encode.c -- encode a protobuf using minimal resources - * - * 2011 Petteri Aimonen - */ - -#include "pb.h" -#include "pb_encode.h" -#include "pb_common.h" - -/* Use the GCC warn_unused_result attribute to check that all return values - * are propagated correctly. On other compilers and gcc before 3.4.0 just - * ignore the annotation. - */ -#if !defined(__GNUC__) || ( __GNUC__ < 3) || (__GNUC__ == 3 && __GNUC_MINOR__ < 4) - #define checkreturn -#else - #define checkreturn __attribute__((warn_unused_result)) -#endif - -/************************************** - * Declarations internal to this file * - **************************************/ -typedef bool (*pb_encoder_t)(pb_ostream_t *stream, const pb_field_t *field, const void *src) checkreturn; - -static bool checkreturn buf_write(pb_ostream_t *stream, const pb_byte_t *buf, size_t count); -static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *field, const void *pData, size_t count, pb_encoder_t func); -static bool checkreturn encode_field(pb_ostream_t *stream, const pb_field_t *field, const void *pData); -static bool checkreturn default_extension_encoder(pb_ostream_t *stream, const pb_extension_t *extension); -static bool checkreturn encode_extension_field(pb_ostream_t *stream, const pb_field_t *field, const void *pData); -static bool checkreturn pb_enc_varint(pb_ostream_t *stream, const pb_field_t *field, const void *src); -static bool checkreturn pb_enc_uvarint(pb_ostream_t *stream, const pb_field_t *field, const void *src); -static bool checkreturn pb_enc_svarint(pb_ostream_t *stream, const pb_field_t *field, const void *src); -static bool checkreturn pb_enc_fixed32(pb_ostream_t *stream, const pb_field_t *field, const void *src); -static bool checkreturn pb_enc_fixed64(pb_ostream_t *stream, const pb_field_t *field, const void *src); -static bool checkreturn pb_enc_bytes(pb_ostream_t *stream, const pb_field_t *field, const void *src); -static bool checkreturn pb_enc_string(pb_ostream_t *stream, const pb_field_t *field, const void *src); -static bool checkreturn pb_enc_submessage(pb_ostream_t *stream, const pb_field_t *field, const void *src); - -/* --- Function pointers to field encoders --- - * Order in the array must match pb_action_t LTYPE numbering. - */ -static const pb_encoder_t PB_ENCODERS[PB_LTYPES_COUNT] = { - &pb_enc_varint, - &pb_enc_uvarint, - &pb_enc_svarint, - &pb_enc_fixed32, - &pb_enc_fixed64, - - &pb_enc_bytes, - &pb_enc_string, - &pb_enc_submessage, - NULL, /* extensions */ - &pb_enc_bytes /* PB_LTYPE_FIXED_LENGTH_BYTES */ -}; - -/******************************* - * pb_ostream_t implementation * - *******************************/ - -static bool checkreturn buf_write(pb_ostream_t *stream, const pb_byte_t *buf, size_t count) -{ - pb_byte_t *dest = (pb_byte_t*)stream->state; - stream->state = dest + count; - - while (count--) - *dest++ = *buf++; - - return true; -} - -pb_ostream_t pb_ostream_from_buffer(pb_byte_t *buf, size_t bufsize) -{ - pb_ostream_t stream; -#ifdef PB_BUFFER_ONLY - stream.callback = (void*)1; /* Just a marker value */ -#else - stream.callback = &buf_write; -#endif - stream.state = buf; - stream.max_size = bufsize; - stream.bytes_written = 0; -#ifndef PB_NO_ERRMSG - stream.errmsg = NULL; -#endif - return stream; -} - -bool checkreturn pb_write(pb_ostream_t *stream, const pb_byte_t *buf, size_t count) -{ - if (stream->callback != NULL) - { - if (stream->bytes_written + count > stream->max_size) - PB_RETURN_ERROR(stream, "stream full"); - -#ifdef PB_BUFFER_ONLY - if (!buf_write(stream, buf, count)) - PB_RETURN_ERROR(stream, "io error"); -#else - if (!stream->callback(stream, buf, count)) - PB_RETURN_ERROR(stream, "io error"); -#endif - } - - stream->bytes_written += count; - return true; -} - -/************************* - * Encode a single field * - *************************/ - -/* Encode a static array. Handles the size calculations and possible packing. */ -static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *field, - const void *pData, size_t count, pb_encoder_t func) -{ - size_t i; - const void *p; - size_t size; - - if (count == 0) - return true; - - if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size) - PB_RETURN_ERROR(stream, "array max size exceeded"); - - /* We always pack arrays if the datatype allows it. */ - if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE) - { - if (!pb_encode_tag(stream, PB_WT_STRING, field->tag)) - return false; - - /* Determine the total size of packed array. */ - if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32) - { - size = 4 * count; - } - else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64) - { - size = 8 * count; - } - else - { - pb_ostream_t sizestream = PB_OSTREAM_SIZING; - p = pData; - for (i = 0; i < count; i++) - { - if (!func(&sizestream, field, p)) - return false; - p = (const char*)p + field->data_size; - } - size = sizestream.bytes_written; - } - - if (!pb_encode_varint(stream, (uint64_t)size)) - return false; - - if (stream->callback == NULL) - return pb_write(stream, NULL, size); /* Just sizing.. */ - - /* Write the data */ - p = pData; - for (i = 0; i < count; i++) - { - if (!func(stream, field, p)) - return false; - p = (const char*)p + field->data_size; - } - } - else - { - p = pData; - for (i = 0; i < count; i++) - { - if (!pb_encode_tag_for_field(stream, field)) - return false; - - /* Normally the data is stored directly in the array entries, but - * for pointer-type string and bytes fields, the array entries are - * actually pointers themselves also. So we have to dereference once - * more to get to the actual data. */ - if (PB_ATYPE(field->type) == PB_ATYPE_POINTER && - (PB_LTYPE(field->type) == PB_LTYPE_STRING || - PB_LTYPE(field->type) == PB_LTYPE_BYTES)) - { - if (!func(stream, field, *(const void* const*)p)) - return false; - } - else - { - if (!func(stream, field, p)) - return false; - } - p = (const char*)p + field->data_size; - } - } - - return true; -} - -/* Encode a field with static or pointer allocation, i.e. one whose data - * is available to the encoder directly. */ -static bool checkreturn encode_basic_field(pb_ostream_t *stream, - const pb_field_t *field, const void *pData) -{ - pb_encoder_t func; - const void *pSize; - bool implicit_has = true; - - func = PB_ENCODERS[PB_LTYPE(field->type)]; - - if (field->size_offset) - pSize = (const char*)pData + field->size_offset; - else - pSize = &implicit_has; - - if (PB_ATYPE(field->type) == PB_ATYPE_POINTER) - { - /* pData is a pointer to the field, which contains pointer to - * the data. If the 2nd pointer is NULL, it is interpreted as if - * the has_field was false. - */ - - pData = *(const void* const*)pData; - implicit_has = (pData != NULL); - } - - switch (PB_HTYPE(field->type)) - { - case PB_HTYPE_REQUIRED: - if (!pData) - PB_RETURN_ERROR(stream, "missing required field"); - if (!pb_encode_tag_for_field(stream, field)) - return false; - if (!func(stream, field, pData)) - return false; - break; - - case PB_HTYPE_OPTIONAL: - if (*(const bool*)pSize) - { - if (!pb_encode_tag_for_field(stream, field)) - return false; - - if (!func(stream, field, pData)) - return false; - } - break; - - case PB_HTYPE_REPEATED: - if (!encode_array(stream, field, pData, *(const pb_size_t*)pSize, func)) - return false; - break; - - case PB_HTYPE_ONEOF: - if (*(const pb_size_t*)pSize == field->tag) - { - if (!pb_encode_tag_for_field(stream, field)) - return false; - - if (!func(stream, field, pData)) - return false; - } - break; - - default: - PB_RETURN_ERROR(stream, "invalid field type"); - } - - return true; -} - -/* Encode a field with callback semantics. This means that a user function is - * called to provide and encode the actual data. */ -static bool checkreturn encode_callback_field(pb_ostream_t *stream, - const pb_field_t *field, const void *pData) -{ - const pb_callback_t *callback = (const pb_callback_t*)pData; - -#ifdef PB_OLD_CALLBACK_STYLE - const void *arg = callback->arg; -#else - void * const *arg = &(callback->arg); -#endif - - if (callback->funcs.encode != NULL) - { - if (!callback->funcs.encode(stream, field, arg)) - PB_RETURN_ERROR(stream, "callback error"); - } - return true; -} - -/* Encode a single field of any callback or static type. */ -static bool checkreturn encode_field(pb_ostream_t *stream, - const pb_field_t *field, const void *pData) -{ - switch (PB_ATYPE(field->type)) - { - case PB_ATYPE_STATIC: - case PB_ATYPE_POINTER: - return encode_basic_field(stream, field, pData); - - case PB_ATYPE_CALLBACK: - return encode_callback_field(stream, field, pData); - - default: - PB_RETURN_ERROR(stream, "invalid field type"); - } -} - -/* Default handler for extension fields. Expects to have a pb_field_t - * pointer in the extension->type->arg field. */ -static bool checkreturn default_extension_encoder(pb_ostream_t *stream, - const pb_extension_t *extension) -{ - const pb_field_t *field = (const pb_field_t*)extension->type->arg; - - if (PB_ATYPE(field->type) == PB_ATYPE_POINTER) - { - /* For pointer extensions, the pointer is stored directly - * in the extension structure. This avoids having an extra - * indirection. */ - return encode_field(stream, field, &extension->dest); - } - else - { - return encode_field(stream, field, extension->dest); - } -} - -/* Walk through all the registered extensions and give them a chance - * to encode themselves. */ -static bool checkreturn encode_extension_field(pb_ostream_t *stream, - const pb_field_t *field, const void *pData) -{ - const pb_extension_t *extension = *(const pb_extension_t* const *)pData; - PB_UNUSED(field); - - while (extension) - { - bool status; - if (extension->type->encode) - status = extension->type->encode(stream, extension); - else - status = default_extension_encoder(stream, extension); - - if (!status) - return false; - - extension = extension->next; - } - - return true; -} - -/********************* - * Encode all fields * - *********************/ - -static void *remove_const(const void *p) -{ - /* Note: this casts away const, in order to use the common field iterator - * logic for both encoding and decoding. */ - union { - void *p1; - const void *p2; - } t; - t.p2 = p; - return t.p1; -} - -bool checkreturn pb_encode(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct) -{ - pb_field_iter_t iter; - if (!pb_field_iter_begin(&iter, fields, remove_const(src_struct))) - return true; /* Empty message type */ - - do { - if (PB_LTYPE(iter.pos->type) == PB_LTYPE_EXTENSION) - { - /* Special case for the extension field placeholder */ - if (!encode_extension_field(stream, iter.pos, iter.pData)) - return false; - } - else - { - /* Regular field */ - if (!encode_field(stream, iter.pos, iter.pData)) - return false; - } - } while (pb_field_iter_next(&iter)); - - return true; -} - -bool pb_encode_delimited(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct) -{ - return pb_encode_submessage(stream, fields, src_struct); -} - -bool pb_get_encoded_size(size_t *size, const pb_field_t fields[], const void *src_struct) -{ - pb_ostream_t stream = PB_OSTREAM_SIZING; - - if (!pb_encode(&stream, fields, src_struct)) - return false; - - *size = stream.bytes_written; - return true; -} - -/******************** - * Helper functions * - ********************/ -bool checkreturn pb_encode_varint(pb_ostream_t *stream, uint64_t value) -{ - pb_byte_t buffer[10]; - size_t i = 0; - - if (value <= 0x7F) - { - pb_byte_t v = (pb_byte_t)value; - return pb_write(stream, &v, 1); - } - - while (value) - { - buffer[i] = (pb_byte_t)((value & 0x7F) | 0x80); - value >>= 7; - i++; - } - buffer[i-1] &= 0x7F; /* Unset top bit on last byte */ - - return pb_write(stream, buffer, i); -} - -bool checkreturn pb_encode_svarint(pb_ostream_t *stream, int64_t value) -{ - uint64_t zigzagged; - if (value < 0) - zigzagged = ~((uint64_t)value << 1); - else - zigzagged = (uint64_t)value << 1; - - return pb_encode_varint(stream, zigzagged); -} - -bool checkreturn pb_encode_fixed32(pb_ostream_t *stream, const void *value) -{ - uint32_t val = *(const uint32_t*)value; - pb_byte_t bytes[4]; - bytes[0] = (pb_byte_t)(val & 0xFF); - bytes[1] = (pb_byte_t)((val >> 8) & 0xFF); - bytes[2] = (pb_byte_t)((val >> 16) & 0xFF); - bytes[3] = (pb_byte_t)((val >> 24) & 0xFF); - return pb_write(stream, bytes, 4); -} - -bool checkreturn pb_encode_fixed64(pb_ostream_t *stream, const void *value) -{ - uint64_t val = *(const uint64_t*)value; - pb_byte_t bytes[8]; - bytes[0] = (pb_byte_t)(val & 0xFF); - bytes[1] = (pb_byte_t)((val >> 8) & 0xFF); - bytes[2] = (pb_byte_t)((val >> 16) & 0xFF); - bytes[3] = (pb_byte_t)((val >> 24) & 0xFF); - bytes[4] = (pb_byte_t)((val >> 32) & 0xFF); - bytes[5] = (pb_byte_t)((val >> 40) & 0xFF); - bytes[6] = (pb_byte_t)((val >> 48) & 0xFF); - bytes[7] = (pb_byte_t)((val >> 56) & 0xFF); - return pb_write(stream, bytes, 8); -} - -bool checkreturn pb_encode_tag(pb_ostream_t *stream, pb_wire_type_t wiretype, uint32_t field_number) -{ - uint64_t tag = ((uint64_t)field_number << 3) | wiretype; - return pb_encode_varint(stream, tag); -} - -bool checkreturn pb_encode_tag_for_field(pb_ostream_t *stream, const pb_field_t *field) -{ - pb_wire_type_t wiretype; - switch (PB_LTYPE(field->type)) - { - case PB_LTYPE_VARINT: - case PB_LTYPE_UVARINT: - case PB_LTYPE_SVARINT: - wiretype = PB_WT_VARINT; - break; - - case PB_LTYPE_FIXED32: - wiretype = PB_WT_32BIT; - break; - - case PB_LTYPE_FIXED64: - wiretype = PB_WT_64BIT; - break; - - case PB_LTYPE_BYTES: - case PB_LTYPE_STRING: - case PB_LTYPE_SUBMESSAGE: - case PB_LTYPE_FIXED_LENGTH_BYTES: - wiretype = PB_WT_STRING; - break; - - default: - PB_RETURN_ERROR(stream, "invalid field type"); - } - - return pb_encode_tag(stream, wiretype, field->tag); -} - -bool checkreturn pb_encode_string(pb_ostream_t *stream, const pb_byte_t *buffer, size_t size) -{ - if (!pb_encode_varint(stream, (uint64_t)size)) - return false; - - return pb_write(stream, buffer, size); -} - -bool checkreturn pb_encode_submessage(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct) -{ - /* First calculate the message size using a non-writing substream. */ - pb_ostream_t substream = PB_OSTREAM_SIZING; - size_t size; - bool status; - - if (!pb_encode(&substream, fields, src_struct)) - { -#ifndef PB_NO_ERRMSG - stream->errmsg = substream.errmsg; -#endif - return false; - } - - size = substream.bytes_written; - - if (!pb_encode_varint(stream, (uint64_t)size)) - return false; - - if (stream->callback == NULL) - return pb_write(stream, NULL, size); /* Just sizing */ - - if (stream->bytes_written + size > stream->max_size) - PB_RETURN_ERROR(stream, "stream full"); - - /* Use a substream to verify that a callback doesn't write more than - * what it did the first time. */ - substream.callback = stream->callback; - substream.state = stream->state; - substream.max_size = size; - substream.bytes_written = 0; -#ifndef PB_NO_ERRMSG - substream.errmsg = NULL; -#endif - - status = pb_encode(&substream, fields, src_struct); - - stream->bytes_written += substream.bytes_written; - stream->state = substream.state; -#ifndef PB_NO_ERRMSG - stream->errmsg = substream.errmsg; -#endif - - if (substream.bytes_written != size) - PB_RETURN_ERROR(stream, "submsg size changed"); - - return status; -} - -/* Field encoders */ - -static bool checkreturn pb_enc_varint(pb_ostream_t *stream, const pb_field_t *field, const void *src) -{ - int64_t value = 0; - - if (field->data_size == sizeof(int_least8_t)) - value = *(const int_least8_t*)src; - else if (field->data_size == sizeof(int_least16_t)) - value = *(const int_least16_t*)src; - else if (field->data_size == sizeof(int32_t)) - value = *(const int32_t*)src; - else if (field->data_size == sizeof(int64_t)) - value = *(const int64_t*)src; - else - PB_RETURN_ERROR(stream, "invalid data_size"); - - return pb_encode_varint(stream, (uint64_t)value); -} - -static bool checkreturn pb_enc_uvarint(pb_ostream_t *stream, const pb_field_t *field, const void *src) -{ - uint64_t value = 0; - - if (field->data_size == sizeof(uint_least8_t)) - value = *(const uint_least8_t*)src; - else if (field->data_size == sizeof(uint_least16_t)) - value = *(const uint_least16_t*)src; - else if (field->data_size == sizeof(uint32_t)) - value = *(const uint32_t*)src; - else if (field->data_size == sizeof(uint64_t)) - value = *(const uint64_t*)src; - else - PB_RETURN_ERROR(stream, "invalid data_size"); - - return pb_encode_varint(stream, value); -} - -static bool checkreturn pb_enc_svarint(pb_ostream_t *stream, const pb_field_t *field, const void *src) -{ - int64_t value = 0; - - if (field->data_size == sizeof(int_least8_t)) - value = *(const int_least8_t*)src; - else if (field->data_size == sizeof(int_least16_t)) - value = *(const int_least16_t*)src; - else if (field->data_size == sizeof(int32_t)) - value = *(const int32_t*)src; - else if (field->data_size == sizeof(int64_t)) - value = *(const int64_t*)src; - else - PB_RETURN_ERROR(stream, "invalid data_size"); - - return pb_encode_svarint(stream, value); -} - -static bool checkreturn pb_enc_fixed64(pb_ostream_t *stream, const pb_field_t *field, const void *src) -{ - PB_UNUSED(field); - return pb_encode_fixed64(stream, src); -} - -static bool checkreturn pb_enc_fixed32(pb_ostream_t *stream, const pb_field_t *field, const void *src) -{ - PB_UNUSED(field); - return pb_encode_fixed32(stream, src); -} - -static bool checkreturn pb_enc_bytes(pb_ostream_t *stream, const pb_field_t *field, const void *src) -{ - const pb_bytes_array_t *bytes = NULL; - - if (PB_LTYPE(field->type) == PB_LTYPE_FIXED_LENGTH_BYTES) - return pb_encode_string(stream, (const pb_byte_t*)src, field->data_size); - - bytes = (const pb_bytes_array_t*)src; - - if (src == NULL) - { - /* Treat null pointer as an empty bytes field */ - return pb_encode_string(stream, NULL, 0); - } - - if (PB_ATYPE(field->type) == PB_ATYPE_STATIC && - PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) > field->data_size) - { - PB_RETURN_ERROR(stream, "bytes size exceeded"); - } - - return pb_encode_string(stream, bytes->bytes, bytes->size); -} - -static bool checkreturn pb_enc_string(pb_ostream_t *stream, const pb_field_t *field, const void *src) -{ - size_t size = 0; - size_t max_size = field->data_size; - const char *p = (const char*)src; - - if (PB_ATYPE(field->type) == PB_ATYPE_POINTER) - max_size = (size_t)-1; - - if (src == NULL) - { - size = 0; /* Treat null pointer as an empty string */ - } - else - { - /* strnlen() is not always available, so just use a loop */ - while (size < max_size && *p != '\0') - { - size++; - p++; - } - } - - return pb_encode_string(stream, (const pb_byte_t*)src, size); -} - -static bool checkreturn pb_enc_submessage(pb_ostream_t *stream, const pb_field_t *field, const void *src) -{ - if (field->ptr == NULL) - PB_RETURN_ERROR(stream, "invalid field descriptor"); - - return pb_encode_submessage(stream, (const pb_field_t*)field->ptr, src); -} - diff --git a/third_party/nanopb/pb_encode.h b/third_party/nanopb/pb_encode.h deleted file mode 100644 index d9909fb0137..00000000000 --- a/third_party/nanopb/pb_encode.h +++ /dev/null @@ -1,154 +0,0 @@ -/* pb_encode.h: Functions to encode protocol buffers. Depends on pb_encode.c. - * The main function is pb_encode. You also need an output stream, and the - * field descriptions created by nanopb_generator.py. - */ - -#ifndef PB_ENCODE_H_INCLUDED -#define PB_ENCODE_H_INCLUDED - -#include "pb.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Structure for defining custom output streams. You will need to provide - * a callback function to write the bytes to your storage, which can be - * for example a file or a network socket. - * - * The callback must conform to these rules: - * - * 1) Return false on IO errors. This will cause encoding to abort. - * 2) You can use state to store your own data (e.g. buffer pointer). - * 3) pb_write will update bytes_written after your callback runs. - * 4) Substreams will modify max_size and bytes_written. Don't use them - * to calculate any pointers. - */ -struct pb_ostream_s -{ -#ifdef PB_BUFFER_ONLY - /* Callback pointer is not used in buffer-only configuration. - * Having an int pointer here allows binary compatibility but - * gives an error if someone tries to assign callback function. - * Also, NULL pointer marks a 'sizing stream' that does not - * write anything. - */ - int *callback; -#else - bool (*callback)(pb_ostream_t *stream, const pb_byte_t *buf, size_t count); -#endif - void *state; /* Free field for use by callback implementation. */ - size_t max_size; /* Limit number of output bytes written (or use SIZE_MAX). */ - size_t bytes_written; /* Number of bytes written so far. */ - -#ifndef PB_NO_ERRMSG - const char *errmsg; -#endif -}; - -/*************************** - * Main encoding functions * - ***************************/ - -/* Encode a single protocol buffers message from C structure into a stream. - * Returns true on success, false on any failure. - * The actual struct pointed to by src_struct must match the description in fields. - * All required fields in the struct are assumed to have been filled in. - * - * Example usage: - * MyMessage msg = {}; - * uint8_t buffer[64]; - * pb_ostream_t stream; - * - * msg.field1 = 42; - * stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - * pb_encode(&stream, MyMessage_fields, &msg); - */ -bool pb_encode(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct); - -/* Same as pb_encode, but prepends the length of the message as a varint. - * Corresponds to writeDelimitedTo() in Google's protobuf API. - */ -bool pb_encode_delimited(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct); - -/* Encode the message to get the size of the encoded data, but do not store - * the data. */ -bool pb_get_encoded_size(size_t *size, const pb_field_t fields[], const void *src_struct); - -/************************************** - * Functions for manipulating streams * - **************************************/ - -/* Create an output stream for writing into a memory buffer. - * The number of bytes written can be found in stream.bytes_written after - * encoding the message. - * - * Alternatively, you can use a custom stream that writes directly to e.g. - * a file or a network socket. - */ -pb_ostream_t pb_ostream_from_buffer(pb_byte_t *buf, size_t bufsize); - -/* Pseudo-stream for measuring the size of a message without actually storing - * the encoded data. - * - * Example usage: - * MyMessage msg = {}; - * pb_ostream_t stream = PB_OSTREAM_SIZING; - * pb_encode(&stream, MyMessage_fields, &msg); - * printf("Message size is %d\n", stream.bytes_written); - */ -#ifndef PB_NO_ERRMSG -#define PB_OSTREAM_SIZING {0,0,0,0,0} -#else -#define PB_OSTREAM_SIZING {0,0,0,0} -#endif - -/* Function to write into a pb_ostream_t stream. You can use this if you need - * to append or prepend some custom headers to the message. - */ -bool pb_write(pb_ostream_t *stream, const pb_byte_t *buf, size_t count); - - -/************************************************ - * Helper functions for writing field callbacks * - ************************************************/ - -/* Encode field header based on type and field number defined in the field - * structure. Call this from the callback before writing out field contents. */ -bool pb_encode_tag_for_field(pb_ostream_t *stream, const pb_field_t *field); - -/* Encode field header by manually specifing wire type. You need to use this - * if you want to write out packed arrays from a callback field. */ -bool pb_encode_tag(pb_ostream_t *stream, pb_wire_type_t wiretype, uint32_t field_number); - -/* Encode an integer in the varint format. - * This works for bool, enum, int32, int64, uint32 and uint64 field types. */ -bool pb_encode_varint(pb_ostream_t *stream, uint64_t value); - -/* Encode an integer in the zig-zagged svarint format. - * This works for sint32 and sint64. */ -bool pb_encode_svarint(pb_ostream_t *stream, int64_t value); - -/* Encode a string or bytes type field. For strings, pass strlen(s) as size. */ -bool pb_encode_string(pb_ostream_t *stream, const pb_byte_t *buffer, size_t size); - -/* Encode a fixed32, sfixed32 or float value. - * You need to pass a pointer to a 4-byte wide C variable. */ -bool pb_encode_fixed32(pb_ostream_t *stream, const void *value); - -/* Encode a fixed64, sfixed64 or double value. - * You need to pass a pointer to a 8-byte wide C variable. */ -bool pb_encode_fixed64(pb_ostream_t *stream, const void *value); - -/* Encode a submessage field. - * You need to pass the pb_field_t array and pointer to struct, just like - * with pb_encode(). This internally encodes the submessage twice, first to - * calculate message size and then to actually write it out. - */ -bool pb_encode_submessage(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif diff --git a/third_party/nanopb/tests/Makefile b/third_party/nanopb/tests/Makefile deleted file mode 100644 index cee6bf67eb6..00000000000 --- a/third_party/nanopb/tests/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -all: - scons - -clean: - scons -c - -coverage: - rm -rf build coverage - - # LCOV does not like the newer gcov format - scons CC=gcc-4.6 CXX=gcc-4.6 - - # Collect the data - mkdir build/coverage - lcov --base-directory . --directory build/ --gcov-tool gcov-4.6 -c -o build/coverage/nanopb.info - - # Remove the test code from results - lcov -r build/coverage/nanopb.info '*tests*' -o build/coverage/nanopb.info - - # Generate HTML - genhtml -o build/coverage build/coverage/nanopb.info diff --git a/third_party/nanopb/tests/SConstruct b/third_party/nanopb/tests/SConstruct deleted file mode 100644 index d8ab9ab0ac9..00000000000 --- a/third_party/nanopb/tests/SConstruct +++ /dev/null @@ -1,155 +0,0 @@ -Help(''' -Type 'scons' to build and run all the available test cases. -It will automatically detect your platform and C compiler and -build appropriately. - -You can modify the behavious using following options: -CC Name of C compiler -CXX Name of C++ compiler -CCFLAGS Flags to pass to the C compiler -CXXFLAGS Flags to pass to the C++ compiler - -For example, for a clang build, use: -scons CC=clang CXX=clang++ -''') - -import os -env = Environment(ENV = os.environ, tools = ['default', 'nanopb']) - -# Allow overriding the compiler with scons CC=??? -if 'CC' in ARGUMENTS: env.Replace(CC = ARGUMENTS['CC']) -if 'CXX' in ARGUMENTS: env.Replace(CXX = ARGUMENTS['CXX']) -if 'CCFLAGS' in ARGUMENTS: env.Append(CCFLAGS = ARGUMENTS['CCFLAGS']) -if 'CXXFLAGS' in ARGUMENTS: env.Append(CXXFLAGS = ARGUMENTS['CXXFLAGS']) - -# Add the builders defined in site_init.py -add_nanopb_builders(env) - -# Path to the files shared by tests, and to the nanopb core. -env.Append(CPPPATH = ["#../", "$COMMON"]) - -# Path for finding nanopb.proto -env.Append(PROTOCPATH = '#../generator') - -# Check the compilation environment, unless we are just cleaning up. -if not env.GetOption('clean'): - def check_ccflags(context, flags, linkflags = ''): - '''Check if given CCFLAGS are supported''' - context.Message('Checking support for CCFLAGS="%s"... ' % flags) - oldflags = context.env['CCFLAGS'] - oldlinkflags = context.env['CCFLAGS'] - context.env.Append(CCFLAGS = flags) - context.env.Append(LINKFLAGS = linkflags) - result = context.TryCompile("int main() {return 0;}", '.c') - context.env.Replace(CCFLAGS = oldflags) - context.env.Replace(LINKFLAGS = oldlinkflags) - context.Result(result) - return result - - conf = Configure(env, custom_tests = {'CheckCCFLAGS': check_ccflags}) - - # If the platform doesn't support C99, use our own header file instead. - stdbool = conf.CheckCHeader('stdbool.h') - stdint = conf.CheckCHeader('stdint.h') - stddef = conf.CheckCHeader('stddef.h') - string = conf.CheckCHeader('string.h') - stdlib = conf.CheckCHeader('stdlib.h') - if not stdbool or not stdint or not stddef or not string: - conf.env.Append(CPPDEFINES = {'PB_SYSTEM_HEADER': '\\"pb_syshdr.h\\"'}) - conf.env.Append(CPPPATH = "#../extra") - conf.env.Append(SYSHDR = '\\"pb_syshdr.h\\"') - - if stdbool: conf.env.Append(CPPDEFINES = {'HAVE_STDBOOL_H': 1}) - if stdint: conf.env.Append(CPPDEFINES = {'HAVE_STDINT_H': 1}) - if stddef: conf.env.Append(CPPDEFINES = {'HAVE_STDDEF_H': 1}) - if string: conf.env.Append(CPPDEFINES = {'HAVE_STRING_H': 1}) - if stdlib: conf.env.Append(CPPDEFINES = {'HAVE_STDLIB_H': 1}) - - # Check if we can use pkg-config to find protobuf include path - status, output = conf.TryAction('pkg-config protobuf --variable=includedir > $TARGET') - if status: - conf.env.Append(PROTOCPATH = output.strip()) - else: - conf.env.Append(PROTOCPATH = '/usr/include') - - # Check protoc version - status, output = conf.TryAction('$PROTOC --version > $TARGET') - if status: - conf.env['PROTOC_VERSION'] = output - - # Check if libmudflap is available (only with GCC) - if 'gcc' in env['CC']: - if conf.CheckLib('mudflap'): - conf.env.Append(CCFLAGS = '-fmudflap') - conf.env.Append(LINKFLAGS = '-fmudflap') - - # Check if we can use extra strict warning flags (only with GCC) - extra = '-Wcast-qual -Wlogical-op -Wconversion' - extra += ' -fstrict-aliasing -Wstrict-aliasing=1' - extra += ' -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls' - extra += ' -Wstack-protector ' - if 'gcc' in env['CC']: - if conf.CheckCCFLAGS(extra): - conf.env.Append(CORECFLAGS = extra) - - # Check if we can use undefined behaviour sanitizer (only with clang) - extra = '-fsanitize=undefined ' - if 'clang' in env['CC']: - if conf.CheckCCFLAGS(extra, linkflags = extra): - conf.env.Append(CORECFLAGS = extra) - conf.env.Append(LINKFLAGS = extra) - - # End the config stuff - env = conf.Finish() - -# Initialize the CCFLAGS according to the compiler -if 'gcc' in env['CC']: - # GNU Compiler Collection - - # Debug info, warnings as errors - env.Append(CFLAGS = '-ansi -pedantic -g -Wall -Werror -fprofile-arcs -ftest-coverage ') - env.Append(CORECFLAGS = '-Wextra') - env.Append(LINKFLAGS = '-g --coverage') - - # We currently need uint64_t anyway, even though ANSI C90 otherwise.. - env.Append(CFLAGS = '-Wno-long-long') -elif 'clang' in env['CC']: - # CLang - env.Append(CFLAGS = '-ansi -g -Wall -Werror') - env.Append(CORECFLAGS = ' -Wextra -Wcast-qual -Wconversion') -elif 'cl' in env['CC']: - # Microsoft Visual C++ - - # Debug info on, warning level 2 for tests, warnings as errors - env.Append(CFLAGS = '/Zi /W2 /WX') - env.Append(LINKFLAGS = '/DEBUG') - - # More strict checks on the nanopb core - env.Append(CORECFLAGS = '/W4') -elif 'tcc' in env['CC']: - # Tiny C Compiler - env.Append(CFLAGS = '-Wall -Werror -g') - -env.SetDefault(CORECFLAGS = '') - -if 'clang' in env['CXX']: - env.Append(CXXFLAGS = '-g -Wall -Werror -Wextra -Wno-missing-field-initializers') -elif 'g++' in env['CXX'] or 'gcc' in env['CXX']: - env.Append(CXXFLAGS = '-g -Wall -Werror -Wextra -Wno-missing-field-initializers') -elif 'cl' in env['CXX']: - env.Append(CXXFLAGS = '/Zi /W2 /WX') - -# Now include the SConscript files from all subdirectories -import os.path -env['VARIANT_DIR'] = 'build' -env['BUILD'] = '#' + env['VARIANT_DIR'] -env['COMMON'] = '#' + env['VARIANT_DIR'] + '/common' - -# Include common/SConscript first to make sure its exports are available -# to other SConscripts. -SConscript("common/SConscript", exports = 'env', variant_dir = env['VARIANT_DIR'] + '/common') - -for subdir in Glob('*/SConscript') + Glob('regression/*/SConscript'): - if str(subdir).startswith("common"): continue - SConscript(subdir, exports = 'env', variant_dir = env['VARIANT_DIR'] + '/' + os.path.dirname(str(subdir))) - diff --git a/third_party/nanopb/tests/alltypes/SConscript b/third_party/nanopb/tests/alltypes/SConscript deleted file mode 100644 index 6c6238c681e..00000000000 --- a/third_party/nanopb/tests/alltypes/SConscript +++ /dev/null @@ -1,35 +0,0 @@ -# Build and run a test that encodes and decodes a message that contains -# all of the Protocol Buffers data types. - -Import("env") - -env.NanopbProto(["alltypes", "alltypes.options"]) -enc = env.Program(["encode_alltypes.c", "alltypes.pb.c", "$COMMON/pb_encode.o", "$COMMON/pb_common.o"]) -dec = env.Program(["decode_alltypes.c", "alltypes.pb.c", "$COMMON/pb_decode.o", "$COMMON/pb_common.o"]) - -# Test the round-trip from nanopb encoder to nanopb decoder -env.RunTest(enc) -env.RunTest([dec, "encode_alltypes.output"]) - -# Re-encode the data using protoc, and check that the results from nanopb -# match byte-per-byte to the protoc output. -env.Decode("encode_alltypes.output.decoded", - ["encode_alltypes.output", "alltypes.proto"], - MESSAGE='AllTypes') -env.Encode("encode_alltypes.output.recoded", - ["encode_alltypes.output.decoded", "alltypes.proto"], - MESSAGE='AllTypes') -env.Compare(["encode_alltypes.output", "encode_alltypes.output.recoded"]) - -# Do the same checks with the optional fields present. -env.RunTest("optionals.output", enc, ARGS = ['1']) -env.RunTest("optionals.decout", [dec, "optionals.output"], ARGS = ['1']) -env.Decode("optionals.output.decoded", - ["optionals.output", "alltypes.proto"], - MESSAGE='AllTypes') -env.Encode("optionals.output.recoded", - ["optionals.output.decoded", "alltypes.proto"], - MESSAGE='AllTypes') -env.Compare(["optionals.output", "optionals.output.recoded"]) - - diff --git a/third_party/nanopb/tests/alltypes/alltypes.options b/third_party/nanopb/tests/alltypes/alltypes.options deleted file mode 100644 index b31e3cf0a9d..00000000000 --- a/third_party/nanopb/tests/alltypes/alltypes.options +++ /dev/null @@ -1,3 +0,0 @@ -* max_size:16 -* max_count:5 - diff --git a/third_party/nanopb/tests/alltypes/alltypes.proto b/third_party/nanopb/tests/alltypes/alltypes.proto deleted file mode 100644 index 3995c552972..00000000000 --- a/third_party/nanopb/tests/alltypes/alltypes.proto +++ /dev/null @@ -1,123 +0,0 @@ -syntax = "proto2"; -// package name placeholder - -message SubMessage { - required string substuff1 = 1 [default = "1"]; - required int32 substuff2 = 2 [default = 2]; - optional fixed32 substuff3 = 3 [default = 3]; -} - -message EmptyMessage { - -} - -enum HugeEnum { - Negative = -2147483647; /* protoc doesn't accept -2147483648 here */ - Positive = 2147483647; -} - -message Limits { - required int32 int32_min = 1 [default = 2147483647]; - required int32 int32_max = 2 [default = -2147483647]; - required uint32 uint32_min = 3 [default = 4294967295]; - required uint32 uint32_max = 4 [default = 0]; - required int64 int64_min = 5 [default = 9223372036854775807]; - required int64 int64_max = 6 [default = -9223372036854775807]; - required uint64 uint64_min = 7 [default = 18446744073709551615]; - required uint64 uint64_max = 8 [default = 0]; - required HugeEnum enum_min = 9 [default = Positive]; - required HugeEnum enum_max = 10 [default = Negative]; -} - -enum MyEnum { - Zero = 0; - First = 1; - Second = 2; - Truth = 42; -} - -message AllTypes { - required int32 req_int32 = 1; - required int64 req_int64 = 2; - required uint32 req_uint32 = 3; - required uint64 req_uint64 = 4; - required sint32 req_sint32 = 5; - required sint64 req_sint64 = 6; - required bool req_bool = 7; - - required fixed32 req_fixed32 = 8; - required sfixed32 req_sfixed32= 9; - required float req_float = 10; - - required fixed64 req_fixed64 = 11; - required sfixed64 req_sfixed64= 12; - required double req_double = 13; - - required string req_string = 14; - required bytes req_bytes = 15; - required SubMessage req_submsg = 16; - required MyEnum req_enum = 17; - required EmptyMessage req_emptymsg = 18; - - - repeated int32 rep_int32 = 21 [packed = true]; - repeated int64 rep_int64 = 22 [packed = true]; - repeated uint32 rep_uint32 = 23 [packed = true]; - repeated uint64 rep_uint64 = 24 [packed = true]; - repeated sint32 rep_sint32 = 25 [packed = true]; - repeated sint64 rep_sint64 = 26 [packed = true]; - repeated bool rep_bool = 27 [packed = true]; - - repeated fixed32 rep_fixed32 = 28 [packed = true]; - repeated sfixed32 rep_sfixed32= 29 [packed = true]; - repeated float rep_float = 30 [packed = true]; - - repeated fixed64 rep_fixed64 = 31 [packed = true]; - repeated sfixed64 rep_sfixed64= 32 [packed = true]; - repeated double rep_double = 33 [packed = true]; - - repeated string rep_string = 34; - repeated bytes rep_bytes = 35; - repeated SubMessage rep_submsg = 36; - repeated MyEnum rep_enum = 37 [packed = true]; - repeated EmptyMessage rep_emptymsg = 38; - - optional int32 opt_int32 = 41 [default = 4041]; - optional int64 opt_int64 = 42 [default = 4042]; - optional uint32 opt_uint32 = 43 [default = 4043]; - optional uint64 opt_uint64 = 44 [default = 4044]; - optional sint32 opt_sint32 = 45 [default = 4045]; - optional sint64 opt_sint64 = 46 [default = 4046]; - optional bool opt_bool = 47 [default = false]; - - optional fixed32 opt_fixed32 = 48 [default = 4048]; - optional sfixed32 opt_sfixed32= 49 [default = 4049]; - optional float opt_float = 50 [default = 4050]; - - optional fixed64 opt_fixed64 = 51 [default = 4051]; - optional sfixed64 opt_sfixed64= 52 [default = 4052]; - optional double opt_double = 53 [default = 4053]; - - optional string opt_string = 54 [default = "4054"]; - optional bytes opt_bytes = 55 [default = "4055"]; - optional SubMessage opt_submsg = 56; - optional MyEnum opt_enum = 57 [default = Second]; - optional EmptyMessage opt_emptymsg = 58; - - oneof oneof - { - SubMessage oneof_msg1 = 59; - EmptyMessage oneof_msg2 = 60; - } - - // Check that extreme integer values are handled correctly - required Limits req_limits = 98; - - // Just to make sure that the size of the fields has been calculated - // properly, i.e. otherwise a bug in last field might not be detected. - required int32 end = 99; - - - extensions 200 to 255; -} - diff --git a/third_party/nanopb/tests/alltypes/decode_alltypes.c b/third_party/nanopb/tests/alltypes/decode_alltypes.c deleted file mode 100644 index 458e51122ab..00000000000 --- a/third_party/nanopb/tests/alltypes/decode_alltypes.c +++ /dev/null @@ -1,221 +0,0 @@ -/* Tests the decoding of all types. - * This is the counterpart of test_encode3. - * Run e.g. ./test_encode3 | ./test_decode3 - */ - -#include -#include -#include -#include -#include "alltypes.pb.h" -#include "test_helpers.h" - -#define TEST(x) if (!(x)) { \ - printf("Test " #x " failed.\n"); \ - return false; \ - } - -/* This function is called once from main(), it handles - the decoding and checks the fields. */ -bool check_alltypes(pb_istream_t *stream, int mode) -{ - /* Uses _init_default to just make sure that it works. */ - AllTypes alltypes = AllTypes_init_default; - - /* Fill with garbage to better detect initialization errors */ - memset(&alltypes, 0xAA, sizeof(alltypes)); - alltypes.extensions = 0; - - if (!pb_decode(stream, AllTypes_fields, &alltypes)) - return false; - - TEST(alltypes.req_int32 == -1001); - TEST(alltypes.req_int64 == -1002); - TEST(alltypes.req_uint32 == 1003); - TEST(alltypes.req_uint64 == 1004); - TEST(alltypes.req_sint32 == -1005); - TEST(alltypes.req_sint64 == -1006); - TEST(alltypes.req_bool == true); - - TEST(alltypes.req_fixed32 == 1008); - TEST(alltypes.req_sfixed32 == -1009); - TEST(alltypes.req_float == 1010.0f); - - TEST(alltypes.req_fixed64 == 1011); - TEST(alltypes.req_sfixed64 == -1012); - TEST(alltypes.req_double == 1013.0f); - - TEST(strcmp(alltypes.req_string, "1014") == 0); - TEST(alltypes.req_bytes.size == 4); - TEST(memcmp(alltypes.req_bytes.bytes, "1015", 4) == 0); - TEST(strcmp(alltypes.req_submsg.substuff1, "1016") == 0); - TEST(alltypes.req_submsg.substuff2 == 1016); - TEST(alltypes.req_submsg.substuff3 == 3); - TEST(alltypes.req_enum == MyEnum_Truth); - - TEST(alltypes.rep_int32_count == 5 && alltypes.rep_int32[4] == -2001 && alltypes.rep_int32[0] == 0); - TEST(alltypes.rep_int64_count == 5 && alltypes.rep_int64[4] == -2002 && alltypes.rep_int64[0] == 0); - TEST(alltypes.rep_uint32_count == 5 && alltypes.rep_uint32[4] == 2003 && alltypes.rep_uint32[0] == 0); - TEST(alltypes.rep_uint64_count == 5 && alltypes.rep_uint64[4] == 2004 && alltypes.rep_uint64[0] == 0); - TEST(alltypes.rep_sint32_count == 5 && alltypes.rep_sint32[4] == -2005 && alltypes.rep_sint32[0] == 0); - TEST(alltypes.rep_sint64_count == 5 && alltypes.rep_sint64[4] == -2006 && alltypes.rep_sint64[0] == 0); - TEST(alltypes.rep_bool_count == 5 && alltypes.rep_bool[4] == true && alltypes.rep_bool[0] == false); - - TEST(alltypes.rep_fixed32_count == 5 && alltypes.rep_fixed32[4] == 2008 && alltypes.rep_fixed32[0] == 0); - TEST(alltypes.rep_sfixed32_count == 5 && alltypes.rep_sfixed32[4] == -2009 && alltypes.rep_sfixed32[0] == 0); - TEST(alltypes.rep_float_count == 5 && alltypes.rep_float[4] == 2010.0f && alltypes.rep_float[0] == 0.0f); - - TEST(alltypes.rep_fixed64_count == 5 && alltypes.rep_fixed64[4] == 2011 && alltypes.rep_fixed64[0] == 0); - TEST(alltypes.rep_sfixed64_count == 5 && alltypes.rep_sfixed64[4] == -2012 && alltypes.rep_sfixed64[0] == 0); - TEST(alltypes.rep_double_count == 5 && alltypes.rep_double[4] == 2013.0 && alltypes.rep_double[0] == 0.0); - - TEST(alltypes.rep_string_count == 5 && strcmp(alltypes.rep_string[4], "2014") == 0 && alltypes.rep_string[0][0] == '\0'); - TEST(alltypes.rep_bytes_count == 5 && alltypes.rep_bytes[4].size == 4 && alltypes.rep_bytes[0].size == 0); - TEST(memcmp(alltypes.rep_bytes[4].bytes, "2015", 4) == 0); - - TEST(alltypes.rep_submsg_count == 5); - TEST(strcmp(alltypes.rep_submsg[4].substuff1, "2016") == 0 && alltypes.rep_submsg[0].substuff1[0] == '\0'); - TEST(alltypes.rep_submsg[4].substuff2 == 2016 && alltypes.rep_submsg[0].substuff2 == 0); - TEST(alltypes.rep_submsg[4].substuff3 == 2016 && alltypes.rep_submsg[0].substuff3 == 3); - - TEST(alltypes.rep_enum_count == 5 && alltypes.rep_enum[4] == MyEnum_Truth && alltypes.rep_enum[0] == MyEnum_Zero); - TEST(alltypes.rep_emptymsg_count == 5); - - if (mode == 0) - { - /* Expect default values */ - TEST(alltypes.has_opt_int32 == false); - TEST(alltypes.opt_int32 == 4041); - TEST(alltypes.has_opt_int64 == false); - TEST(alltypes.opt_int64 == 4042); - TEST(alltypes.has_opt_uint32 == false); - TEST(alltypes.opt_uint32 == 4043); - TEST(alltypes.has_opt_uint64 == false); - TEST(alltypes.opt_uint64 == 4044); - TEST(alltypes.has_opt_sint32 == false); - TEST(alltypes.opt_sint32 == 4045); - TEST(alltypes.has_opt_sint64 == false); - TEST(alltypes.opt_sint64 == 4046); - TEST(alltypes.has_opt_bool == false); - TEST(alltypes.opt_bool == false); - - TEST(alltypes.has_opt_fixed32 == false); - TEST(alltypes.opt_fixed32 == 4048); - TEST(alltypes.has_opt_sfixed32 == false); - TEST(alltypes.opt_sfixed32 == 4049); - TEST(alltypes.has_opt_float == false); - TEST(alltypes.opt_float == 4050.0f); - - TEST(alltypes.has_opt_fixed64 == false); - TEST(alltypes.opt_fixed64 == 4051); - TEST(alltypes.has_opt_sfixed64 == false); - TEST(alltypes.opt_sfixed64 == 4052); - TEST(alltypes.has_opt_double == false); - TEST(alltypes.opt_double == 4053.0); - - TEST(alltypes.has_opt_string == false); - TEST(strcmp(alltypes.opt_string, "4054") == 0); - TEST(alltypes.has_opt_bytes == false); - TEST(alltypes.opt_bytes.size == 4); - TEST(memcmp(alltypes.opt_bytes.bytes, "4055", 4) == 0); - TEST(alltypes.has_opt_submsg == false); - TEST(strcmp(alltypes.opt_submsg.substuff1, "1") == 0); - TEST(alltypes.opt_submsg.substuff2 == 2); - TEST(alltypes.opt_submsg.substuff3 == 3); - TEST(alltypes.has_opt_enum == false); - TEST(alltypes.opt_enum == MyEnum_Second); - TEST(alltypes.has_opt_emptymsg == false); - - TEST(alltypes.which_oneof == 0); - } - else - { - /* Expect filled-in values */ - TEST(alltypes.has_opt_int32 == true); - TEST(alltypes.opt_int32 == 3041); - TEST(alltypes.has_opt_int64 == true); - TEST(alltypes.opt_int64 == 3042); - TEST(alltypes.has_opt_uint32 == true); - TEST(alltypes.opt_uint32 == 3043); - TEST(alltypes.has_opt_uint64 == true); - TEST(alltypes.opt_uint64 == 3044); - TEST(alltypes.has_opt_sint32 == true); - TEST(alltypes.opt_sint32 == 3045); - TEST(alltypes.has_opt_sint64 == true); - TEST(alltypes.opt_sint64 == 3046); - TEST(alltypes.has_opt_bool == true); - TEST(alltypes.opt_bool == true); - - TEST(alltypes.has_opt_fixed32 == true); - TEST(alltypes.opt_fixed32 == 3048); - TEST(alltypes.has_opt_sfixed32 == true); - TEST(alltypes.opt_sfixed32 == 3049); - TEST(alltypes.has_opt_float == true); - TEST(alltypes.opt_float == 3050.0f); - - TEST(alltypes.has_opt_fixed64 == true); - TEST(alltypes.opt_fixed64 == 3051); - TEST(alltypes.has_opt_sfixed64 == true); - TEST(alltypes.opt_sfixed64 == 3052); - TEST(alltypes.has_opt_double == true); - TEST(alltypes.opt_double == 3053.0); - - TEST(alltypes.has_opt_string == true); - TEST(strcmp(alltypes.opt_string, "3054") == 0); - TEST(alltypes.has_opt_bytes == true); - TEST(alltypes.opt_bytes.size == 4); - TEST(memcmp(alltypes.opt_bytes.bytes, "3055", 4) == 0); - TEST(alltypes.has_opt_submsg == true); - TEST(strcmp(alltypes.opt_submsg.substuff1, "3056") == 0); - TEST(alltypes.opt_submsg.substuff2 == 3056); - TEST(alltypes.opt_submsg.substuff3 == 3); - TEST(alltypes.has_opt_enum == true); - TEST(alltypes.opt_enum == MyEnum_Truth); - TEST(alltypes.has_opt_emptymsg == true); - - TEST(alltypes.which_oneof == AllTypes_oneof_msg1_tag); - TEST(strcmp(alltypes.oneof.oneof_msg1.substuff1, "4059") == 0); - TEST(alltypes.oneof.oneof_msg1.substuff2 == 4059); - } - - TEST(alltypes.req_limits.int32_min == INT32_MIN); - TEST(alltypes.req_limits.int32_max == INT32_MAX); - TEST(alltypes.req_limits.uint32_min == 0); - TEST(alltypes.req_limits.uint32_max == UINT32_MAX); - TEST(alltypes.req_limits.int64_min == INT64_MIN); - TEST(alltypes.req_limits.int64_max == INT64_MAX); - TEST(alltypes.req_limits.uint64_min == 0); - TEST(alltypes.req_limits.uint64_max == UINT64_MAX); - TEST(alltypes.req_limits.enum_min == HugeEnum_Negative); - TEST(alltypes.req_limits.enum_max == HugeEnum_Positive); - - TEST(alltypes.end == 1099); - - return true; -} - -int main(int argc, char **argv) -{ - uint8_t buffer[1024]; - size_t count; - pb_istream_t stream; - - /* Whether to expect the optional values or the default values. */ - int mode = (argc > 1) ? atoi(argv[1]) : 0; - - /* Read the data into buffer */ - SET_BINARY_MODE(stdin); - count = fread(buffer, 1, sizeof(buffer), stdin); - - /* Construct a pb_istream_t for reading from the buffer */ - stream = pb_istream_from_buffer(buffer, count); - - /* Decode and print out the stuff */ - if (!check_alltypes(&stream, mode)) - { - printf("Parsing failed: %s\n", PB_GET_ERROR(&stream)); - return 1; - } else { - return 0; - } -} diff --git a/third_party/nanopb/tests/alltypes/encode_alltypes.c b/third_party/nanopb/tests/alltypes/encode_alltypes.c deleted file mode 100644 index 16f4b29893b..00000000000 --- a/third_party/nanopb/tests/alltypes/encode_alltypes.c +++ /dev/null @@ -1,149 +0,0 @@ -/* Attempts to test all the datatypes supported by ProtoBuf. - */ - -#include -#include -#include -#include -#include "alltypes.pb.h" -#include "test_helpers.h" - -int main(int argc, char **argv) -{ - int mode = (argc > 1) ? atoi(argv[1]) : 0; - - /* Initialize the structure with constants */ - AllTypes alltypes = AllTypes_init_zero; - - alltypes.req_int32 = -1001; - alltypes.req_int64 = -1002; - alltypes.req_uint32 = 1003; - alltypes.req_uint64 = 1004; - alltypes.req_sint32 = -1005; - alltypes.req_sint64 = -1006; - alltypes.req_bool = true; - - alltypes.req_fixed32 = 1008; - alltypes.req_sfixed32 = -1009; - alltypes.req_float = 1010.0f; - - alltypes.req_fixed64 = 1011; - alltypes.req_sfixed64 = -1012; - alltypes.req_double = 1013.0; - - strcpy(alltypes.req_string, "1014"); - alltypes.req_bytes.size = 4; - memcpy(alltypes.req_bytes.bytes, "1015", 4); - strcpy(alltypes.req_submsg.substuff1, "1016"); - alltypes.req_submsg.substuff2 = 1016; - alltypes.req_enum = MyEnum_Truth; - - alltypes.rep_int32_count = 5; alltypes.rep_int32[4] = -2001; - alltypes.rep_int64_count = 5; alltypes.rep_int64[4] = -2002; - alltypes.rep_uint32_count = 5; alltypes.rep_uint32[4] = 2003; - alltypes.rep_uint64_count = 5; alltypes.rep_uint64[4] = 2004; - alltypes.rep_sint32_count = 5; alltypes.rep_sint32[4] = -2005; - alltypes.rep_sint64_count = 5; alltypes.rep_sint64[4] = -2006; - alltypes.rep_bool_count = 5; alltypes.rep_bool[4] = true; - - alltypes.rep_fixed32_count = 5; alltypes.rep_fixed32[4] = 2008; - alltypes.rep_sfixed32_count = 5; alltypes.rep_sfixed32[4] = -2009; - alltypes.rep_float_count = 5; alltypes.rep_float[4] = 2010.0f; - - alltypes.rep_fixed64_count = 5; alltypes.rep_fixed64[4] = 2011; - alltypes.rep_sfixed64_count = 5; alltypes.rep_sfixed64[4] = -2012; - alltypes.rep_double_count = 5; alltypes.rep_double[4] = 2013.0; - - alltypes.rep_string_count = 5; strcpy(alltypes.rep_string[4], "2014"); - alltypes.rep_bytes_count = 5; alltypes.rep_bytes[4].size = 4; - memcpy(alltypes.rep_bytes[4].bytes, "2015", 4); - - alltypes.rep_submsg_count = 5; - strcpy(alltypes.rep_submsg[4].substuff1, "2016"); - alltypes.rep_submsg[4].substuff2 = 2016; - alltypes.rep_submsg[4].has_substuff3 = true; - alltypes.rep_submsg[4].substuff3 = 2016; - - alltypes.rep_enum_count = 5; alltypes.rep_enum[4] = MyEnum_Truth; - alltypes.rep_emptymsg_count = 5; - - alltypes.req_limits.int32_min = INT32_MIN; - alltypes.req_limits.int32_max = INT32_MAX; - alltypes.req_limits.uint32_min = 0; - alltypes.req_limits.uint32_max = UINT32_MAX; - alltypes.req_limits.int64_min = INT64_MIN; - alltypes.req_limits.int64_max = INT64_MAX; - alltypes.req_limits.uint64_min = 0; - alltypes.req_limits.uint64_max = UINT64_MAX; - alltypes.req_limits.enum_min = HugeEnum_Negative; - alltypes.req_limits.enum_max = HugeEnum_Positive; - - if (mode != 0) - { - /* Fill in values for optional fields */ - alltypes.has_opt_int32 = true; - alltypes.opt_int32 = 3041; - alltypes.has_opt_int64 = true; - alltypes.opt_int64 = 3042; - alltypes.has_opt_uint32 = true; - alltypes.opt_uint32 = 3043; - alltypes.has_opt_uint64 = true; - alltypes.opt_uint64 = 3044; - alltypes.has_opt_sint32 = true; - alltypes.opt_sint32 = 3045; - alltypes.has_opt_sint64 = true; - alltypes.opt_sint64 = 3046; - alltypes.has_opt_bool = true; - alltypes.opt_bool = true; - - alltypes.has_opt_fixed32 = true; - alltypes.opt_fixed32 = 3048; - alltypes.has_opt_sfixed32 = true; - alltypes.opt_sfixed32 = 3049; - alltypes.has_opt_float = true; - alltypes.opt_float = 3050.0f; - - alltypes.has_opt_fixed64 = true; - alltypes.opt_fixed64 = 3051; - alltypes.has_opt_sfixed64 = true; - alltypes.opt_sfixed64 = 3052; - alltypes.has_opt_double = true; - alltypes.opt_double = 3053.0; - - alltypes.has_opt_string = true; - strcpy(alltypes.opt_string, "3054"); - alltypes.has_opt_bytes = true; - alltypes.opt_bytes.size = 4; - memcpy(alltypes.opt_bytes.bytes, "3055", 4); - alltypes.has_opt_submsg = true; - strcpy(alltypes.opt_submsg.substuff1, "3056"); - alltypes.opt_submsg.substuff2 = 3056; - alltypes.has_opt_enum = true; - alltypes.opt_enum = MyEnum_Truth; - alltypes.has_opt_emptymsg = true; - - alltypes.which_oneof = AllTypes_oneof_msg1_tag; - strcpy(alltypes.oneof.oneof_msg1.substuff1, "4059"); - alltypes.oneof.oneof_msg1.substuff2 = 4059; - } - - alltypes.end = 1099; - - { - uint8_t buffer[AllTypes_size]; - pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - - /* Now encode it and check if we succeeded. */ - if (pb_encode(&stream, AllTypes_fields, &alltypes)) - { - SET_BINARY_MODE(stdout); - fwrite(buffer, 1, stream.bytes_written, stdout); - return 0; /* Success */ - } - else - { - fprintf(stderr, "Encoding failed: %s\n", PB_GET_ERROR(&stream)); - return 1; /* Failure */ - } - } -} diff --git a/third_party/nanopb/tests/alltypes_callback/SConscript b/third_party/nanopb/tests/alltypes_callback/SConscript deleted file mode 100644 index a241f24ee11..00000000000 --- a/third_party/nanopb/tests/alltypes_callback/SConscript +++ /dev/null @@ -1,23 +0,0 @@ -# Test the AllTypes encoding & decoding using callbacks for all fields. - -Import("env") - -c = Copy("$TARGET", "$SOURCE") -env.Command("alltypes.proto", "#alltypes/alltypes.proto", c) - -env.NanopbProto(["alltypes", "alltypes.options"]) -enc = env.Program(["encode_alltypes_callback.c", "alltypes.pb.c", "$COMMON/pb_encode.o", "$COMMON/pb_common.o"]) -dec = env.Program(["decode_alltypes_callback.c", "alltypes.pb.c", "$COMMON/pb_decode.o", "$COMMON/pb_common.o"]) - -refdec = "$BUILD/alltypes/decode_alltypes$PROGSUFFIX" - -# Encode and compare results -env.RunTest(enc) -env.RunTest("decode_alltypes.output", [refdec, "encode_alltypes_callback.output"]) -env.RunTest("decode_alltypes_callback.output", [dec, "encode_alltypes_callback.output"]) - -# Do the same thing with the optional fields present -env.RunTest("optionals.output", enc, ARGS = ['1']) -env.RunTest("optionals.refdecout", [refdec, "optionals.output"], ARGS = ['1']) -env.RunTest("optionals.decout", [dec, "optionals.output"], ARGS = ['1']) - diff --git a/third_party/nanopb/tests/alltypes_callback/alltypes.options b/third_party/nanopb/tests/alltypes_callback/alltypes.options deleted file mode 100644 index daee5224d25..00000000000 --- a/third_party/nanopb/tests/alltypes_callback/alltypes.options +++ /dev/null @@ -1,4 +0,0 @@ -# Generate all fields as callbacks. -AllTypes.* type:FT_CALLBACK -SubMessage.substuff1 max_size:16 -AllTypes.oneof no_unions:true diff --git a/third_party/nanopb/tests/alltypes_callback/decode_alltypes_callback.c b/third_party/nanopb/tests/alltypes_callback/decode_alltypes_callback.c deleted file mode 100644 index c53ab6ed6dc..00000000000 --- a/third_party/nanopb/tests/alltypes_callback/decode_alltypes_callback.c +++ /dev/null @@ -1,429 +0,0 @@ -/* Attempts to test all the datatypes supported by ProtoBuf when used as callback fields. - * Note that normally there would be no reason to use callback fields for this, - * because each encoder defined here only gives a single field. - */ - -#include -#include -#include -#include -#include "alltypes.pb.h" -#include "test_helpers.h" - -#define TEST(x) if (!(x)) { \ - printf("Test " #x " failed (in field %d).\n", field->tag); \ - return false; \ - } - -static bool read_varint(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - uint64_t value; - if (!pb_decode_varint(stream, &value)) - return false; - - TEST((int64_t)value == (long)*arg); - return true; -} - -static bool read_svarint(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - int64_t value; - if (!pb_decode_svarint(stream, &value)) - return false; - - TEST(value == (long)*arg); - return true; -} - -static bool read_fixed32(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - uint32_t value; - if (!pb_decode_fixed32(stream, &value)) - return false; - - TEST(value == *(uint32_t*)*arg); - return true; -} - -static bool read_fixed64(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - uint64_t value; - if (!pb_decode_fixed64(stream, &value)) - return false; - - TEST(value == *(uint64_t*)*arg); - return true; -} - -static bool read_string(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - uint8_t buf[16] = {0}; - size_t len = stream->bytes_left; - - if (len > sizeof(buf) - 1 || !pb_read(stream, buf, len)) - return false; - - TEST(strcmp((char*)buf, *arg) == 0); - return true; -} - -static bool read_submsg(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - SubMessage submsg = {""}; - - if (!pb_decode(stream, SubMessage_fields, &submsg)) - return false; - - TEST(memcmp(&submsg, *arg, sizeof(submsg))); - return true; -} - -static bool read_emptymsg(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - EmptyMessage emptymsg = {0}; - return pb_decode(stream, EmptyMessage_fields, &emptymsg); -} - -static bool read_repeated_varint(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - int32_t** expected = (int32_t**)arg; - uint64_t value; - if (!pb_decode_varint(stream, &value)) - return false; - - TEST(*(*expected)++ == value); - return true; -} - -static bool read_repeated_svarint(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - int32_t** expected = (int32_t**)arg; - int64_t value; - if (!pb_decode_svarint(stream, &value)) - return false; - - TEST(*(*expected)++ == value); - return true; -} - -static bool read_repeated_fixed32(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - uint32_t** expected = (uint32_t**)arg; - uint32_t value; - if (!pb_decode_fixed32(stream, &value)) - return false; - - TEST(*(*expected)++ == value); - return true; -} - -static bool read_repeated_fixed64(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - uint64_t** expected = (uint64_t**)arg; - uint64_t value; - if (!pb_decode_fixed64(stream, &value)) - return false; - - TEST(*(*expected)++ == value); - return true; -} - -static bool read_repeated_string(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - uint8_t*** expected = (uint8_t***)arg; - uint8_t buf[16] = {0}; - size_t len = stream->bytes_left; - - if (len > sizeof(buf) - 1 || !pb_read(stream, buf, len)) - return false; - - TEST(strcmp((char*)*(*expected)++, (char*)buf) == 0); - return true; -} - -static bool read_repeated_submsg(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - SubMessage** expected = (SubMessage**)arg; - SubMessage decoded = {""}; - if (!pb_decode(stream, SubMessage_fields, &decoded)) - return false; - - TEST(memcmp((*expected)++, &decoded, sizeof(decoded)) == 0); - return true; -} - -static bool read_limits(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - Limits decoded = {0}; - if (!pb_decode(stream, Limits_fields, &decoded)) - return false; - - TEST(decoded.int32_min == INT32_MIN); - TEST(decoded.int32_max == INT32_MAX); - TEST(decoded.uint32_min == 0); - TEST(decoded.uint32_max == UINT32_MAX); - TEST(decoded.int64_min == INT64_MIN); - TEST(decoded.int64_max == INT64_MAX); - TEST(decoded.uint64_min == 0); - TEST(decoded.uint64_max == UINT64_MAX); - TEST(decoded.enum_min == HugeEnum_Negative); - TEST(decoded.enum_max == HugeEnum_Positive); - - return true; -} - -/* This function is called once from main(), it handles - the decoding and checks the fields. */ -bool check_alltypes(pb_istream_t *stream, int mode) -{ - /* Values for use from callbacks through pointers. */ - uint32_t req_fixed32 = 1008; - int32_t req_sfixed32 = -1009; - float req_float = 1010.0f; - uint64_t req_fixed64 = 1011; - int64_t req_sfixed64 = -1012; - double req_double = 1013.0; - SubMessage req_submsg = {"1016", 1016}; - - int32_t rep_int32[5] = {0, 0, 0, 0, -2001}; - int32_t rep_int64[5] = {0, 0, 0, 0, -2002}; - int32_t rep_uint32[5] = {0, 0, 0, 0, 2003}; - int32_t rep_uint64[5] = {0, 0, 0, 0, 2004}; - int32_t rep_sint32[5] = {0, 0, 0, 0, -2005}; - int32_t rep_sint64[5] = {0, 0, 0, 0, -2006}; - int32_t rep_bool[5] = {false, false, false, false, true}; - uint32_t rep_fixed32[5] = {0, 0, 0, 0, 2008}; - int32_t rep_sfixed32[5] = {0, 0, 0, 0, -2009}; - float rep_float[5] = {0, 0, 0, 0, 2010.0f}; - uint64_t rep_fixed64[5] = {0, 0, 0, 0, 2011}; - int64_t rep_sfixed64[5] = {0, 0, 0, 0, -2012}; - double rep_double[5] = {0, 0, 0, 0, 2013.0}; - char* rep_string[5] = {"", "", "", "", "2014"}; - char* rep_bytes[5] = {"", "", "", "", "2015"}; - SubMessage rep_submsg[5] = {{"", 0, 0, 3}, - {"", 0, 0, 3}, - {"", 0, 0, 3}, - {"", 0, 0, 3}, - {"2016", 2016, true, 2016}}; - int32_t rep_enum[5] = {0, 0, 0, 0, MyEnum_Truth}; - - uint32_t opt_fixed32 = 3048; - int32_t opt_sfixed32 = 3049; - float opt_float = 3050.0f; - uint64_t opt_fixed64 = 3051; - int64_t opt_sfixed64 = 3052; - double opt_double = 3053.0f; - SubMessage opt_submsg = {"3056", 3056}; - - SubMessage oneof_msg1 = {"4059", 4059}; - - /* Bind callbacks for required fields */ - AllTypes alltypes; - - /* Fill with garbage to better detect initialization errors */ - memset(&alltypes, 0xAA, sizeof(alltypes)); - alltypes.extensions = 0; - - alltypes.req_int32.funcs.decode = &read_varint; - alltypes.req_int32.arg = (void*)-1001; - - alltypes.req_int64.funcs.decode = &read_varint; - alltypes.req_int64.arg = (void*)-1002; - - alltypes.req_uint32.funcs.decode = &read_varint; - alltypes.req_uint32.arg = (void*)1003; - - alltypes.req_uint32.funcs.decode = &read_varint; - alltypes.req_uint32.arg = (void*)1003; - - alltypes.req_uint64.funcs.decode = &read_varint; - alltypes.req_uint64.arg = (void*)1004; - - alltypes.req_sint32.funcs.decode = &read_svarint; - alltypes.req_sint32.arg = (void*)-1005; - - alltypes.req_sint64.funcs.decode = &read_svarint; - alltypes.req_sint64.arg = (void*)-1006; - - alltypes.req_bool.funcs.decode = &read_varint; - alltypes.req_bool.arg = (void*)true; - - alltypes.req_fixed32.funcs.decode = &read_fixed32; - alltypes.req_fixed32.arg = &req_fixed32; - - alltypes.req_sfixed32.funcs.decode = &read_fixed32; - alltypes.req_sfixed32.arg = &req_sfixed32; - - alltypes.req_float.funcs.decode = &read_fixed32; - alltypes.req_float.arg = &req_float; - - alltypes.req_fixed64.funcs.decode = &read_fixed64; - alltypes.req_fixed64.arg = &req_fixed64; - - alltypes.req_sfixed64.funcs.decode = &read_fixed64; - alltypes.req_sfixed64.arg = &req_sfixed64; - - alltypes.req_double.funcs.decode = &read_fixed64; - alltypes.req_double.arg = &req_double; - - alltypes.req_string.funcs.decode = &read_string; - alltypes.req_string.arg = "1014"; - - alltypes.req_bytes.funcs.decode = &read_string; - alltypes.req_bytes.arg = "1015"; - - alltypes.req_submsg.funcs.decode = &read_submsg; - alltypes.req_submsg.arg = &req_submsg; - - alltypes.req_enum.funcs.decode = &read_varint; - alltypes.req_enum.arg = (void*)MyEnum_Truth; - - alltypes.req_emptymsg.funcs.decode = &read_emptymsg; - - /* Bind callbacks for repeated fields */ - alltypes.rep_int32.funcs.decode = &read_repeated_varint; - alltypes.rep_int32.arg = rep_int32; - - alltypes.rep_int64.funcs.decode = &read_repeated_varint; - alltypes.rep_int64.arg = rep_int64; - - alltypes.rep_uint32.funcs.decode = &read_repeated_varint; - alltypes.rep_uint32.arg = rep_uint32; - - alltypes.rep_uint64.funcs.decode = &read_repeated_varint; - alltypes.rep_uint64.arg = rep_uint64; - - alltypes.rep_sint32.funcs.decode = &read_repeated_svarint; - alltypes.rep_sint32.arg = rep_sint32; - - alltypes.rep_sint64.funcs.decode = &read_repeated_svarint; - alltypes.rep_sint64.arg = rep_sint64; - - alltypes.rep_bool.funcs.decode = &read_repeated_varint; - alltypes.rep_bool.arg = rep_bool; - - alltypes.rep_fixed32.funcs.decode = &read_repeated_fixed32; - alltypes.rep_fixed32.arg = rep_fixed32; - - alltypes.rep_sfixed32.funcs.decode = &read_repeated_fixed32; - alltypes.rep_sfixed32.arg = rep_sfixed32; - - alltypes.rep_float.funcs.decode = &read_repeated_fixed32; - alltypes.rep_float.arg = rep_float; - - alltypes.rep_fixed64.funcs.decode = &read_repeated_fixed64; - alltypes.rep_fixed64.arg = rep_fixed64; - - alltypes.rep_sfixed64.funcs.decode = &read_repeated_fixed64; - alltypes.rep_sfixed64.arg = rep_sfixed64; - - alltypes.rep_double.funcs.decode = &read_repeated_fixed64; - alltypes.rep_double.arg = rep_double; - - alltypes.rep_string.funcs.decode = &read_repeated_string; - alltypes.rep_string.arg = rep_string; - - alltypes.rep_bytes.funcs.decode = &read_repeated_string; - alltypes.rep_bytes.arg = rep_bytes; - - alltypes.rep_submsg.funcs.decode = &read_repeated_submsg; - alltypes.rep_submsg.arg = rep_submsg; - - alltypes.rep_enum.funcs.decode = &read_repeated_varint; - alltypes.rep_enum.arg = rep_enum; - - alltypes.rep_emptymsg.funcs.decode = &read_emptymsg; - - alltypes.req_limits.funcs.decode = &read_limits; - - alltypes.end.funcs.decode = &read_varint; - alltypes.end.arg = (void*)1099; - - /* Bind callbacks for optional fields */ - if (mode == 1) - { - alltypes.opt_int32.funcs.decode = &read_varint; - alltypes.opt_int32.arg = (void*)3041; - - alltypes.opt_int64.funcs.decode = &read_varint; - alltypes.opt_int64.arg = (void*)3042; - - alltypes.opt_uint32.funcs.decode = &read_varint; - alltypes.opt_uint32.arg = (void*)3043; - - alltypes.opt_uint64.funcs.decode = &read_varint; - alltypes.opt_uint64.arg = (void*)3044; - - alltypes.opt_sint32.funcs.decode = &read_svarint; - alltypes.opt_sint32.arg = (void*)3045; - - alltypes.opt_sint64.funcs.decode = &read_svarint; - alltypes.opt_sint64.arg = (void*)3046; - - alltypes.opt_bool.funcs.decode = &read_varint; - alltypes.opt_bool.arg = (void*)true; - - alltypes.opt_fixed32.funcs.decode = &read_fixed32; - alltypes.opt_fixed32.arg = &opt_fixed32; - - alltypes.opt_sfixed32.funcs.decode = &read_fixed32; - alltypes.opt_sfixed32.arg = &opt_sfixed32; - - alltypes.opt_float.funcs.decode = &read_fixed32; - alltypes.opt_float.arg = &opt_float; - - alltypes.opt_fixed64.funcs.decode = &read_fixed64; - alltypes.opt_fixed64.arg = &opt_fixed64; - - alltypes.opt_sfixed64.funcs.decode = &read_fixed64; - alltypes.opt_sfixed64.arg = &opt_sfixed64; - - alltypes.opt_double.funcs.decode = &read_fixed64; - alltypes.opt_double.arg = &opt_double; - - alltypes.opt_string.funcs.decode = &read_string; - alltypes.opt_string.arg = "3054"; - - alltypes.opt_bytes.funcs.decode = &read_string; - alltypes.opt_bytes.arg = "3055"; - - alltypes.opt_submsg.funcs.decode = &read_submsg; - alltypes.opt_submsg.arg = &opt_submsg; - - alltypes.opt_enum.funcs.decode = &read_varint; - alltypes.opt_enum.arg = (void*)MyEnum_Truth; - - alltypes.opt_emptymsg.funcs.decode = &read_emptymsg; - - alltypes.oneof_msg1.funcs.decode = &read_submsg; - alltypes.oneof_msg1.arg = &oneof_msg1; - } - - return pb_decode(stream, AllTypes_fields, &alltypes); -} - -int main(int argc, char **argv) -{ - uint8_t buffer[1024]; - size_t count; - pb_istream_t stream; - - /* Whether to expect the optional values or the default values. */ - int mode = (argc > 1) ? atoi(argv[1]) : 0; - - /* Read the data into buffer */ - SET_BINARY_MODE(stdin); - count = fread(buffer, 1, sizeof(buffer), stdin); - - /* Construct a pb_istream_t for reading from the buffer */ - stream = pb_istream_from_buffer(buffer, count); - - /* Decode and print out the stuff */ - if (!check_alltypes(&stream, mode)) - { - printf("Parsing failed: %s\n", PB_GET_ERROR(&stream)); - return 1; - } else { - return 0; - } -} diff --git a/third_party/nanopb/tests/alltypes_callback/encode_alltypes_callback.c b/third_party/nanopb/tests/alltypes_callback/encode_alltypes_callback.c deleted file mode 100644 index abc43f5800e..00000000000 --- a/third_party/nanopb/tests/alltypes_callback/encode_alltypes_callback.c +++ /dev/null @@ -1,402 +0,0 @@ -/* Attempts to test all the datatypes supported by ProtoBuf when used as callback fields. - * Note that normally there would be no reason to use callback fields for this, - * because each encoder defined here only gives a single field. - */ - -#include -#include -#include -#include -#include "alltypes.pb.h" -#include "test_helpers.h" - -static bool write_varint(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - return pb_encode_tag_for_field(stream, field) && - pb_encode_varint(stream, (long)*arg); -} - -static bool write_svarint(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - return pb_encode_tag_for_field(stream, field) && - pb_encode_svarint(stream, (long)*arg); -} - -static bool write_fixed32(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - return pb_encode_tag_for_field(stream, field) && - pb_encode_fixed32(stream, *arg); -} - -static bool write_fixed64(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - return pb_encode_tag_for_field(stream, field) && - pb_encode_fixed64(stream, *arg); -} - -static bool write_string(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - return pb_encode_tag_for_field(stream, field) && - pb_encode_string(stream, *arg, strlen(*arg)); -} - -static bool write_submsg(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - - return pb_encode_tag_for_field(stream, field) && - pb_encode_submessage(stream, SubMessage_fields, *arg); -} - -static bool write_emptymsg(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - EmptyMessage emptymsg = {0}; - return pb_encode_tag_for_field(stream, field) && - pb_encode_submessage(stream, EmptyMessage_fields, &emptymsg); -} - -static bool write_repeated_varint(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - return pb_encode_tag_for_field(stream, field) && - pb_encode_varint(stream, 0) && - pb_encode_tag_for_field(stream, field) && - pb_encode_varint(stream, 0) && - pb_encode_tag_for_field(stream, field) && - pb_encode_varint(stream, 0) && - pb_encode_tag_for_field(stream, field) && - pb_encode_varint(stream, 0) && - pb_encode_tag_for_field(stream, field) && - pb_encode_varint(stream, (long)*arg); -} - -static bool write_repeated_svarint(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - return pb_encode_tag_for_field(stream, field) && - pb_encode_svarint(stream, 0) && - pb_encode_tag_for_field(stream, field) && - pb_encode_svarint(stream, 0) && - pb_encode_tag_for_field(stream, field) && - pb_encode_svarint(stream, 0) && - pb_encode_tag_for_field(stream, field) && - pb_encode_svarint(stream, 0) && - pb_encode_tag_for_field(stream, field) && - pb_encode_svarint(stream, (long)*arg); -} - -static bool write_repeated_fixed32(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - uint32_t dummy = 0; - - /* Make it a packed field */ - return pb_encode_tag(stream, PB_WT_STRING, field->tag) && - pb_encode_varint(stream, 5 * 4) && /* Number of bytes */ - pb_encode_fixed32(stream, &dummy) && - pb_encode_fixed32(stream, &dummy) && - pb_encode_fixed32(stream, &dummy) && - pb_encode_fixed32(stream, &dummy) && - pb_encode_fixed32(stream, *arg); -} - -static bool write_repeated_fixed64(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - uint64_t dummy = 0; - - /* Make it a packed field */ - return pb_encode_tag(stream, PB_WT_STRING, field->tag) && - pb_encode_varint(stream, 5 * 8) && /* Number of bytes */ - pb_encode_fixed64(stream, &dummy) && - pb_encode_fixed64(stream, &dummy) && - pb_encode_fixed64(stream, &dummy) && - pb_encode_fixed64(stream, &dummy) && - pb_encode_fixed64(stream, *arg); -} - -static bool write_repeated_string(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - return pb_encode_tag_for_field(stream, field) && - pb_encode_string(stream, 0, 0) && - pb_encode_tag_for_field(stream, field) && - pb_encode_string(stream, 0, 0) && - pb_encode_tag_for_field(stream, field) && - pb_encode_string(stream, 0, 0) && - pb_encode_tag_for_field(stream, field) && - pb_encode_string(stream, 0, 0) && - pb_encode_tag_for_field(stream, field) && - pb_encode_string(stream, *arg, strlen(*arg)); -} - -static bool write_repeated_submsg(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - SubMessage dummy = {""}; - - return pb_encode_tag_for_field(stream, field) && - pb_encode_submessage(stream, SubMessage_fields, &dummy) && - pb_encode_tag_for_field(stream, field) && - pb_encode_submessage(stream, SubMessage_fields, &dummy) && - pb_encode_tag_for_field(stream, field) && - pb_encode_submessage(stream, SubMessage_fields, &dummy) && - pb_encode_tag_for_field(stream, field) && - pb_encode_submessage(stream, SubMessage_fields, &dummy) && - pb_encode_tag_for_field(stream, field) && - pb_encode_submessage(stream, SubMessage_fields, *arg); -} - -static bool write_limits(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - Limits limits = {0}; - limits.int32_min = INT32_MIN; - limits.int32_max = INT32_MAX; - limits.uint32_min = 0; - limits.uint32_max = UINT32_MAX; - limits.int64_min = INT64_MIN; - limits.int64_max = INT64_MAX; - limits.uint64_min = 0; - limits.uint64_max = UINT64_MAX; - limits.enum_min = HugeEnum_Negative; - limits.enum_max = HugeEnum_Positive; - - return pb_encode_tag_for_field(stream, field) && - pb_encode_submessage(stream, Limits_fields, &limits); -} - -static bool write_repeated_emptymsg(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - EmptyMessage emptymsg = {0}; - return pb_encode_tag_for_field(stream, field) && - pb_encode_submessage(stream, EmptyMessage_fields, &emptymsg) && - pb_encode_tag_for_field(stream, field) && - pb_encode_submessage(stream, EmptyMessage_fields, &emptymsg) && - pb_encode_tag_for_field(stream, field) && - pb_encode_submessage(stream, EmptyMessage_fields, &emptymsg) && - pb_encode_tag_for_field(stream, field) && - pb_encode_submessage(stream, EmptyMessage_fields, &emptymsg) && - pb_encode_tag_for_field(stream, field) && - pb_encode_submessage(stream, EmptyMessage_fields, &emptymsg); -} - -int main(int argc, char **argv) -{ - int mode = (argc > 1) ? atoi(argv[1]) : 0; - - /* Values for use from callbacks through pointers. */ - uint32_t req_fixed32 = 1008; - int32_t req_sfixed32 = -1009; - float req_float = 1010.0f; - uint64_t req_fixed64 = 1011; - int64_t req_sfixed64 = -1012; - double req_double = 1013.0; - SubMessage req_submsg = {"1016", 1016}; - - uint32_t rep_fixed32 = 2008; - int32_t rep_sfixed32 = -2009; - float rep_float = 2010.0f; - uint64_t rep_fixed64 = 2011; - int64_t rep_sfixed64 = -2012; - double rep_double = 2013.0; - SubMessage rep_submsg = {"2016", 2016, true, 2016}; - - uint32_t opt_fixed32 = 3048; - int32_t opt_sfixed32 = 3049; - float opt_float = 3050.0f; - uint64_t opt_fixed64 = 3051; - int64_t opt_sfixed64 = 3052; - double opt_double = 3053.0f; - SubMessage opt_submsg = {"3056", 3056}; - - SubMessage oneof_msg1 = {"4059", 4059}; - - /* Bind callbacks for required fields */ - AllTypes alltypes = {{{0}}}; - - alltypes.req_int32.funcs.encode = &write_varint; - alltypes.req_int32.arg = (void*)-1001; - - alltypes.req_int64.funcs.encode = &write_varint; - alltypes.req_int64.arg = (void*)-1002; - - alltypes.req_uint32.funcs.encode = &write_varint; - alltypes.req_uint32.arg = (void*)1003; - - alltypes.req_uint32.funcs.encode = &write_varint; - alltypes.req_uint32.arg = (void*)1003; - - alltypes.req_uint64.funcs.encode = &write_varint; - alltypes.req_uint64.arg = (void*)1004; - - alltypes.req_sint32.funcs.encode = &write_svarint; - alltypes.req_sint32.arg = (void*)-1005; - - alltypes.req_sint64.funcs.encode = &write_svarint; - alltypes.req_sint64.arg = (void*)-1006; - - alltypes.req_bool.funcs.encode = &write_varint; - alltypes.req_bool.arg = (void*)true; - - alltypes.req_fixed32.funcs.encode = &write_fixed32; - alltypes.req_fixed32.arg = &req_fixed32; - - alltypes.req_sfixed32.funcs.encode = &write_fixed32; - alltypes.req_sfixed32.arg = &req_sfixed32; - - alltypes.req_float.funcs.encode = &write_fixed32; - alltypes.req_float.arg = &req_float; - - alltypes.req_fixed64.funcs.encode = &write_fixed64; - alltypes.req_fixed64.arg = &req_fixed64; - - alltypes.req_sfixed64.funcs.encode = &write_fixed64; - alltypes.req_sfixed64.arg = &req_sfixed64; - - alltypes.req_double.funcs.encode = &write_fixed64; - alltypes.req_double.arg = &req_double; - - alltypes.req_string.funcs.encode = &write_string; - alltypes.req_string.arg = "1014"; - - alltypes.req_bytes.funcs.encode = &write_string; - alltypes.req_bytes.arg = "1015"; - - alltypes.req_submsg.funcs.encode = &write_submsg; - alltypes.req_submsg.arg = &req_submsg; - - alltypes.req_enum.funcs.encode = &write_varint; - alltypes.req_enum.arg = (void*)MyEnum_Truth; - - alltypes.req_emptymsg.funcs.encode = &write_emptymsg; - - /* Bind callbacks for repeated fields */ - alltypes.rep_int32.funcs.encode = &write_repeated_varint; - alltypes.rep_int32.arg = (void*)-2001; - - alltypes.rep_int64.funcs.encode = &write_repeated_varint; - alltypes.rep_int64.arg = (void*)-2002; - - alltypes.rep_uint32.funcs.encode = &write_repeated_varint; - alltypes.rep_uint32.arg = (void*)2003; - - alltypes.rep_uint64.funcs.encode = &write_repeated_varint; - alltypes.rep_uint64.arg = (void*)2004; - - alltypes.rep_sint32.funcs.encode = &write_repeated_svarint; - alltypes.rep_sint32.arg = (void*)-2005; - - alltypes.rep_sint64.funcs.encode = &write_repeated_svarint; - alltypes.rep_sint64.arg = (void*)-2006; - - alltypes.rep_bool.funcs.encode = &write_repeated_varint; - alltypes.rep_bool.arg = (void*)true; - - alltypes.rep_fixed32.funcs.encode = &write_repeated_fixed32; - alltypes.rep_fixed32.arg = &rep_fixed32; - - alltypes.rep_sfixed32.funcs.encode = &write_repeated_fixed32; - alltypes.rep_sfixed32.arg = &rep_sfixed32; - - alltypes.rep_float.funcs.encode = &write_repeated_fixed32; - alltypes.rep_float.arg = &rep_float; - - alltypes.rep_fixed64.funcs.encode = &write_repeated_fixed64; - alltypes.rep_fixed64.arg = &rep_fixed64; - - alltypes.rep_sfixed64.funcs.encode = &write_repeated_fixed64; - alltypes.rep_sfixed64.arg = &rep_sfixed64; - - alltypes.rep_double.funcs.encode = &write_repeated_fixed64; - alltypes.rep_double.arg = &rep_double; - - alltypes.rep_string.funcs.encode = &write_repeated_string; - alltypes.rep_string.arg = "2014"; - - alltypes.rep_bytes.funcs.encode = &write_repeated_string; - alltypes.rep_bytes.arg = "2015"; - - alltypes.rep_submsg.funcs.encode = &write_repeated_submsg; - alltypes.rep_submsg.arg = &rep_submsg; - - alltypes.rep_enum.funcs.encode = &write_repeated_varint; - alltypes.rep_enum.arg = (void*)MyEnum_Truth; - - alltypes.rep_emptymsg.funcs.encode = &write_repeated_emptymsg; - - alltypes.req_limits.funcs.encode = &write_limits; - - /* Bind callbacks for optional fields */ - if (mode != 0) - { - alltypes.opt_int32.funcs.encode = &write_varint; - alltypes.opt_int32.arg = (void*)3041; - - alltypes.opt_int64.funcs.encode = &write_varint; - alltypes.opt_int64.arg = (void*)3042; - - alltypes.opt_uint32.funcs.encode = &write_varint; - alltypes.opt_uint32.arg = (void*)3043; - - alltypes.opt_uint64.funcs.encode = &write_varint; - alltypes.opt_uint64.arg = (void*)3044; - - alltypes.opt_sint32.funcs.encode = &write_svarint; - alltypes.opt_sint32.arg = (void*)3045; - - alltypes.opt_sint64.funcs.encode = &write_svarint; - alltypes.opt_sint64.arg = (void*)3046; - - alltypes.opt_bool.funcs.encode = &write_varint; - alltypes.opt_bool.arg = (void*)true; - - alltypes.opt_fixed32.funcs.encode = &write_fixed32; - alltypes.opt_fixed32.arg = &opt_fixed32; - - alltypes.opt_sfixed32.funcs.encode = &write_fixed32; - alltypes.opt_sfixed32.arg = &opt_sfixed32; - - alltypes.opt_float.funcs.encode = &write_fixed32; - alltypes.opt_float.arg = &opt_float; - - alltypes.opt_fixed64.funcs.encode = &write_fixed64; - alltypes.opt_fixed64.arg = &opt_fixed64; - - alltypes.opt_sfixed64.funcs.encode = &write_fixed64; - alltypes.opt_sfixed64.arg = &opt_sfixed64; - - alltypes.opt_double.funcs.encode = &write_fixed64; - alltypes.opt_double.arg = &opt_double; - - alltypes.opt_string.funcs.encode = &write_string; - alltypes.opt_string.arg = "3054"; - - alltypes.opt_bytes.funcs.encode = &write_string; - alltypes.opt_bytes.arg = "3055"; - - alltypes.opt_submsg.funcs.encode = &write_submsg; - alltypes.opt_submsg.arg = &opt_submsg; - - alltypes.opt_enum.funcs.encode = &write_varint; - alltypes.opt_enum.arg = (void*)MyEnum_Truth; - - alltypes.opt_emptymsg.funcs.encode = &write_emptymsg; - - alltypes.oneof_msg1.funcs.encode = &write_submsg; - alltypes.oneof_msg1.arg = &oneof_msg1; - } - - alltypes.end.funcs.encode = &write_varint; - alltypes.end.arg = (void*)1099; - - { - uint8_t buffer[2048]; - pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - - /* Now encode it and check if we succeeded. */ - if (pb_encode(&stream, AllTypes_fields, &alltypes)) - { - SET_BINARY_MODE(stdout); - fwrite(buffer, 1, stream.bytes_written, stdout); - return 0; /* Success */ - } - else - { - fprintf(stderr, "Encoding failed: %s\n", PB_GET_ERROR(&stream)); - return 1; /* Failure */ - } - } -} diff --git a/third_party/nanopb/tests/alltypes_pointer/SConscript b/third_party/nanopb/tests/alltypes_pointer/SConscript deleted file mode 100644 index b095ae037fc..00000000000 --- a/third_party/nanopb/tests/alltypes_pointer/SConscript +++ /dev/null @@ -1,40 +0,0 @@ -# Encode the AllTypes message using pointers for all fields, and verify the -# output against the normal AllTypes test case. - -Import("env", "malloc_env") - -c = Copy("$TARGET", "$SOURCE") -env.Command("alltypes.proto", "#alltypes/alltypes.proto", c) - -env.NanopbProto(["alltypes", "alltypes.options"]) -enc = malloc_env.Program(["encode_alltypes_pointer.c", - "alltypes.pb.c", - "$COMMON/pb_encode_with_malloc.o", - "$COMMON/pb_common_with_malloc.o", - "$COMMON/malloc_wrappers.o"]) -dec = malloc_env.Program(["decode_alltypes_pointer.c", - "alltypes.pb.c", - "$COMMON/pb_decode_with_malloc.o", - "$COMMON/pb_common_with_malloc.o", - "$COMMON/malloc_wrappers.o"]) - -# Encode and compare results to non-pointer alltypes test case -env.RunTest(enc) -env.Compare(["encode_alltypes_pointer.output", "$BUILD/alltypes/encode_alltypes.output"]) - -# Decode (under valgrind if available) -valgrind = env.WhereIs('valgrind') -kwargs = {} -if valgrind: - kwargs['COMMAND'] = valgrind - kwargs['ARGS'] = ["-q", "--error-exitcode=99", dec[0].abspath] - -env.RunTest("decode_alltypes.output", [dec, "encode_alltypes_pointer.output"], **kwargs) - -# Do the same thing with the optional fields present -env.RunTest("optionals.output", enc, ARGS = ['1']) -env.Compare(["optionals.output", "$BUILD/alltypes/optionals.output"]) - -kwargs['ARGS'] = kwargs.get('ARGS', []) + ['1'] -env.RunTest("optionals.decout", [dec, "optionals.output"], **kwargs) - diff --git a/third_party/nanopb/tests/alltypes_pointer/alltypes.options b/third_party/nanopb/tests/alltypes_pointer/alltypes.options deleted file mode 100644 index 52abeb7fec9..00000000000 --- a/third_party/nanopb/tests/alltypes_pointer/alltypes.options +++ /dev/null @@ -1,3 +0,0 @@ -# Generate all fields as pointers. -* type:FT_POINTER - diff --git a/third_party/nanopb/tests/alltypes_pointer/decode_alltypes_pointer.c b/third_party/nanopb/tests/alltypes_pointer/decode_alltypes_pointer.c deleted file mode 100644 index 1dbb6c55d16..00000000000 --- a/third_party/nanopb/tests/alltypes_pointer/decode_alltypes_pointer.c +++ /dev/null @@ -1,180 +0,0 @@ -#include -#include -#include -#include -#include "alltypes.pb.h" -#include "test_helpers.h" - -#define TEST(x) if (!(x)) { \ - fprintf(stderr, "Test " #x " failed.\n"); \ - status = false; \ - } - -/* This function is called once from main(), it handles - the decoding and checks the fields. */ -bool check_alltypes(pb_istream_t *stream, int mode) -{ - bool status = true; - AllTypes alltypes; - - /* Fill with garbage to better detect initialization errors */ - memset(&alltypes, 0xAA, sizeof(alltypes)); - alltypes.extensions = 0; - - if (!pb_decode(stream, AllTypes_fields, &alltypes)) - return false; - - TEST(alltypes.req_int32 && *alltypes.req_int32 == -1001); - TEST(alltypes.req_int64 && *alltypes.req_int64 == -1002); - TEST(alltypes.req_uint32 && *alltypes.req_uint32 == 1003); - TEST(alltypes.req_uint64 && *alltypes.req_uint64 == 1004); - TEST(alltypes.req_sint32 && *alltypes.req_sint32 == -1005); - TEST(alltypes.req_sint64 && *alltypes.req_sint64 == -1006); - TEST(alltypes.req_bool && *alltypes.req_bool == true); - - TEST(alltypes.req_fixed32 && *alltypes.req_fixed32 == 1008); - TEST(alltypes.req_sfixed32 && *alltypes.req_sfixed32 == -1009); - TEST(alltypes.req_float && *alltypes.req_float == 1010.0f); - - TEST(alltypes.req_fixed64 && *alltypes.req_fixed64 == 1011); - TEST(alltypes.req_sfixed64 && *alltypes.req_sfixed64 == -1012); - TEST(alltypes.req_double && *alltypes.req_double == 1013.0f); - - TEST(alltypes.req_string && strcmp(alltypes.req_string, "1014") == 0); - TEST(alltypes.req_bytes && alltypes.req_bytes->size == 4); - TEST(alltypes.req_bytes && memcmp(&alltypes.req_bytes->bytes, "1015", 4) == 0); - TEST(alltypes.req_submsg && alltypes.req_submsg->substuff1 - && strcmp(alltypes.req_submsg->substuff1, "1016") == 0); - TEST(alltypes.req_submsg && alltypes.req_submsg->substuff2 - && *alltypes.req_submsg->substuff2 == 1016); - TEST(*alltypes.req_enum == MyEnum_Truth); - - TEST(alltypes.rep_int32_count == 5 && alltypes.rep_int32[4] == -2001 && alltypes.rep_int32[0] == 0); - TEST(alltypes.rep_int64_count == 5 && alltypes.rep_int64[4] == -2002 && alltypes.rep_int64[0] == 0); - TEST(alltypes.rep_uint32_count == 5 && alltypes.rep_uint32[4] == 2003 && alltypes.rep_uint32[0] == 0); - TEST(alltypes.rep_uint64_count == 5 && alltypes.rep_uint64[4] == 2004 && alltypes.rep_uint64[0] == 0); - TEST(alltypes.rep_sint32_count == 5 && alltypes.rep_sint32[4] == -2005 && alltypes.rep_sint32[0] == 0); - TEST(alltypes.rep_sint64_count == 5 && alltypes.rep_sint64[4] == -2006 && alltypes.rep_sint64[0] == 0); - TEST(alltypes.rep_bool_count == 5 && alltypes.rep_bool[4] == true && alltypes.rep_bool[0] == false); - - TEST(alltypes.rep_fixed32_count == 5 && alltypes.rep_fixed32[4] == 2008 && alltypes.rep_fixed32[0] == 0); - TEST(alltypes.rep_sfixed32_count == 5 && alltypes.rep_sfixed32[4] == -2009 && alltypes.rep_sfixed32[0] == 0); - TEST(alltypes.rep_float_count == 5 && alltypes.rep_float[4] == 2010.0f && alltypes.rep_float[0] == 0.0f); - - TEST(alltypes.rep_fixed64_count == 5 && alltypes.rep_fixed64[4] == 2011 && alltypes.rep_fixed64[0] == 0); - TEST(alltypes.rep_sfixed64_count == 5 && alltypes.rep_sfixed64[4] == -2012 && alltypes.rep_sfixed64[0] == 0); - TEST(alltypes.rep_double_count == 5 && alltypes.rep_double[4] == 2013.0 && alltypes.rep_double[0] == 0.0); - - TEST(alltypes.rep_string_count == 5 && strcmp(alltypes.rep_string[4], "2014") == 0 && alltypes.rep_string[0][0] == '\0'); - TEST(alltypes.rep_bytes_count == 5 && alltypes.rep_bytes[4]->size == 4 && alltypes.rep_bytes[0]->size == 0); - TEST(memcmp(&alltypes.rep_bytes[4]->bytes, "2015", 4) == 0); - - TEST(alltypes.rep_submsg_count == 5); - TEST(strcmp(alltypes.rep_submsg[4].substuff1, "2016") == 0 && alltypes.rep_submsg[0].substuff1[0] == '\0'); - TEST(*alltypes.rep_submsg[4].substuff2 == 2016 && *alltypes.rep_submsg[0].substuff2 == 0); - TEST(*alltypes.rep_submsg[4].substuff3 == 2016 && alltypes.rep_submsg[0].substuff3 == NULL); - - TEST(alltypes.rep_enum_count == 5 && alltypes.rep_enum[4] == MyEnum_Truth && alltypes.rep_enum[0] == MyEnum_Zero); - TEST(alltypes.rep_emptymsg_count == 5); - - if (mode == 0) - { - /* Expect that optional values are not present */ - TEST(alltypes.opt_int32 == NULL); - TEST(alltypes.opt_int64 == NULL); - TEST(alltypes.opt_uint32 == NULL); - TEST(alltypes.opt_uint64 == NULL); - TEST(alltypes.opt_sint32 == NULL); - TEST(alltypes.opt_sint64 == NULL); - TEST(alltypes.opt_bool == NULL); - - TEST(alltypes.opt_fixed32 == NULL); - TEST(alltypes.opt_sfixed32 == NULL); - TEST(alltypes.opt_float == NULL); - TEST(alltypes.opt_fixed64 == NULL); - TEST(alltypes.opt_sfixed64 == NULL); - TEST(alltypes.opt_double == NULL); - - TEST(alltypes.opt_string == NULL); - TEST(alltypes.opt_bytes == NULL); - TEST(alltypes.opt_submsg == NULL); - TEST(alltypes.opt_enum == NULL); - - TEST(alltypes.which_oneof == 0); - } - else - { - /* Expect filled-in values */ - TEST(alltypes.opt_int32 && *alltypes.opt_int32 == 3041); - TEST(alltypes.opt_int64 && *alltypes.opt_int64 == 3042); - TEST(alltypes.opt_uint32 && *alltypes.opt_uint32 == 3043); - TEST(alltypes.opt_uint64 && *alltypes.opt_uint64 == 3044); - TEST(alltypes.opt_sint32 && *alltypes.opt_sint32 == 3045); - TEST(alltypes.opt_sint64 && *alltypes.opt_sint64 == 3046); - TEST(alltypes.opt_bool && *alltypes.opt_bool == true); - - TEST(alltypes.opt_fixed32 && *alltypes.opt_fixed32 == 3048); - TEST(alltypes.opt_sfixed32 && *alltypes.opt_sfixed32== 3049); - TEST(alltypes.opt_float && *alltypes.opt_float == 3050.0f); - TEST(alltypes.opt_fixed64 && *alltypes.opt_fixed64 == 3051); - TEST(alltypes.opt_sfixed64 && *alltypes.opt_sfixed64== 3052); - TEST(alltypes.opt_double && *alltypes.opt_double == 3053.0); - - TEST(alltypes.opt_string && strcmp(alltypes.opt_string, "3054") == 0); - TEST(alltypes.opt_bytes && alltypes.opt_bytes->size == 4); - TEST(alltypes.opt_bytes && memcmp(&alltypes.opt_bytes->bytes, "3055", 4) == 0); - TEST(alltypes.opt_submsg && strcmp(alltypes.opt_submsg->substuff1, "3056") == 0); - TEST(alltypes.opt_submsg && *alltypes.opt_submsg->substuff2 == 3056); - TEST(alltypes.opt_enum && *alltypes.opt_enum == MyEnum_Truth); - TEST(alltypes.opt_emptymsg); - - TEST(alltypes.which_oneof == AllTypes_oneof_msg1_tag); - TEST(alltypes.oneof.oneof_msg1 && strcmp(alltypes.oneof.oneof_msg1->substuff1, "4059") == 0); - TEST(alltypes.oneof.oneof_msg1->substuff2 && *alltypes.oneof.oneof_msg1->substuff2 == 4059); - } - - TEST(alltypes.req_limits->int32_min && *alltypes.req_limits->int32_min == INT32_MIN); - TEST(alltypes.req_limits->int32_max && *alltypes.req_limits->int32_max == INT32_MAX); - TEST(alltypes.req_limits->uint32_min && *alltypes.req_limits->uint32_min == 0); - TEST(alltypes.req_limits->uint32_max && *alltypes.req_limits->uint32_max == UINT32_MAX); - TEST(alltypes.req_limits->int64_min && *alltypes.req_limits->int64_min == INT64_MIN); - TEST(alltypes.req_limits->int64_max && *alltypes.req_limits->int64_max == INT64_MAX); - TEST(alltypes.req_limits->uint64_min && *alltypes.req_limits->uint64_min == 0); - TEST(alltypes.req_limits->uint64_max && *alltypes.req_limits->uint64_max == UINT64_MAX); - TEST(alltypes.req_limits->enum_min && *alltypes.req_limits->enum_min == HugeEnum_Negative); - TEST(alltypes.req_limits->enum_max && *alltypes.req_limits->enum_max == HugeEnum_Positive); - - TEST(alltypes.end && *alltypes.end == 1099); - - pb_release(AllTypes_fields, &alltypes); - - return status; -} - -int main(int argc, char **argv) -{ - uint8_t buffer[1024]; - size_t count; - pb_istream_t stream; - - /* Whether to expect the optional values or the default values. */ - int mode = (argc > 1) ? atoi(argv[1]) : 0; - - /* Read the data into buffer */ - SET_BINARY_MODE(stdin); - count = fread(buffer, 1, sizeof(buffer), stdin); - - /* Construct a pb_istream_t for reading from the buffer */ - stream = pb_istream_from_buffer(buffer, count); - - /* Decode and verify the message */ - if (!check_alltypes(&stream, mode)) - { - fprintf(stderr, "Test failed: %s\n", PB_GET_ERROR(&stream)); - return 1; - } - else - { - return 0; - } -} diff --git a/third_party/nanopb/tests/alltypes_pointer/encode_alltypes_pointer.c b/third_party/nanopb/tests/alltypes_pointer/encode_alltypes_pointer.c deleted file mode 100644 index 7b52662f702..00000000000 --- a/third_party/nanopb/tests/alltypes_pointer/encode_alltypes_pointer.c +++ /dev/null @@ -1,194 +0,0 @@ -/* Attempts to test all the datatypes supported by ProtoBuf. - */ - -#include -#include -#include -#include -#include "alltypes.pb.h" -#include "test_helpers.h" - -int main(int argc, char **argv) -{ - int mode = (argc > 1) ? atoi(argv[1]) : 0; - - /* Values for required fields */ - int32_t req_int32 = -1001; - int64_t req_int64 = -1002; - uint32_t req_uint32 = 1003; - uint64_t req_uint64 = 1004; - int32_t req_sint32 = -1005; - int64_t req_sint64 = -1006; - bool req_bool = true; - uint32_t req_fixed32 = 1008; - int32_t req_sfixed32 = -1009; - float req_float = 1010.0f; - uint64_t req_fixed64 = 1011; - int64_t req_sfixed64 = -1012; - double req_double = 1013.0; - char* req_string = "1014"; - PB_BYTES_ARRAY_T(4) req_bytes = {4, {'1', '0', '1', '5'}}; - static int32_t req_substuff = 1016; - SubMessage req_submsg = {"1016", &req_substuff}; - MyEnum req_enum = MyEnum_Truth; - EmptyMessage req_emptymsg = {0}; - - int32_t end = 1099; - - /* Values for repeated fields */ - int32_t rep_int32[5] = {0, 0, 0, 0, -2001}; - int64_t rep_int64[5] = {0, 0, 0, 0, -2002}; - uint32_t rep_uint32[5] = {0, 0, 0, 0, 2003}; - uint64_t rep_uint64[5] = {0, 0, 0, 0, 2004}; - int32_t rep_sint32[5] = {0, 0, 0, 0, -2005}; - int64_t rep_sint64[5] = {0, 0, 0, 0, -2006}; - bool rep_bool[5] = {false, false, false, false, true}; - uint32_t rep_fixed32[5] = {0, 0, 0, 0, 2008}; - int32_t rep_sfixed32[5] = {0, 0, 0, 0, -2009}; - float rep_float[5] = {0, 0, 0, 0, 2010.0f}; - uint64_t rep_fixed64[5] = {0, 0, 0, 0, 2011}; - int64_t rep_sfixed64[5] = {0, 0, 0, 0, -2012}; - double rep_double[5] = {0, 0, 0, 0, 2013.0f}; - char* rep_string[5] = {"", "", "", "", "2014"}; - static PB_BYTES_ARRAY_T(4) rep_bytes_4 = {4, {'2', '0', '1', '5'}}; - pb_bytes_array_t *rep_bytes[5]= {NULL, NULL, NULL, NULL, (pb_bytes_array_t*)&rep_bytes_4}; - static int32_t rep_sub2zero = 0; - static int32_t rep_substuff2 = 2016; - static uint32_t rep_substuff3 = 2016; - SubMessage rep_submsg[5] = {{"", &rep_sub2zero}, - {"", &rep_sub2zero}, - {"", &rep_sub2zero}, - {"", &rep_sub2zero}, - {"2016", &rep_substuff2, &rep_substuff3}}; - MyEnum rep_enum[5] = {0, 0, 0, 0, MyEnum_Truth}; - EmptyMessage rep_emptymsg[5] = {{0}, {0}, {0}, {0}, {0}}; - - /* Values for optional fields */ - int32_t opt_int32 = 3041; - int64_t opt_int64 = 3042; - uint32_t opt_uint32 = 3043; - uint64_t opt_uint64 = 3044; - int32_t opt_sint32 = 3045; - int64_t opt_sint64 = 3046; - bool opt_bool = true; - uint32_t opt_fixed32 = 3048; - int32_t opt_sfixed32 = 3049; - float opt_float = 3050.0f; - uint64_t opt_fixed64 = 3051; - int64_t opt_sfixed64 = 3052; - double opt_double = 3053.0; - char* opt_string = "3054"; - PB_BYTES_ARRAY_T(4) opt_bytes = {4, {'3', '0', '5', '5'}}; - static int32_t opt_substuff = 3056; - SubMessage opt_submsg = {"3056", &opt_substuff}; - MyEnum opt_enum = MyEnum_Truth; - EmptyMessage opt_emptymsg = {0}; - - static int32_t oneof_substuff = 4059; - SubMessage oneof_msg1 = {"4059", &oneof_substuff}; - - /* Values for the Limits message. */ - static int32_t int32_min = INT32_MIN; - static int32_t int32_max = INT32_MAX; - static uint32_t uint32_min = 0; - static uint32_t uint32_max = UINT32_MAX; - static int64_t int64_min = INT64_MIN; - static int64_t int64_max = INT64_MAX; - static uint64_t uint64_min = 0; - static uint64_t uint64_max = UINT64_MAX; - static HugeEnum enum_min = HugeEnum_Negative; - static HugeEnum enum_max = HugeEnum_Positive; - Limits req_limits = {&int32_min, &int32_max, - &uint32_min, &uint32_max, - &int64_min, &int64_max, - &uint64_min, &uint64_max, - &enum_min, &enum_max}; - - /* Initialize the message struct with pointers to the fields. */ - AllTypes alltypes = {0}; - - alltypes.req_int32 = &req_int32; - alltypes.req_int64 = &req_int64; - alltypes.req_uint32 = &req_uint32; - alltypes.req_uint64 = &req_uint64; - alltypes.req_sint32 = &req_sint32; - alltypes.req_sint64 = &req_sint64; - alltypes.req_bool = &req_bool; - alltypes.req_fixed32 = &req_fixed32; - alltypes.req_sfixed32 = &req_sfixed32; - alltypes.req_float = &req_float; - alltypes.req_fixed64 = &req_fixed64; - alltypes.req_sfixed64 = &req_sfixed64; - alltypes.req_double = &req_double; - alltypes.req_string = req_string; - alltypes.req_bytes = (pb_bytes_array_t*)&req_bytes; - alltypes.req_submsg = &req_submsg; - alltypes.req_enum = &req_enum; - alltypes.req_emptymsg = &req_emptymsg; - alltypes.req_limits = &req_limits; - - alltypes.rep_int32_count = 5; alltypes.rep_int32 = rep_int32; - alltypes.rep_int64_count = 5; alltypes.rep_int64 = rep_int64; - alltypes.rep_uint32_count = 5; alltypes.rep_uint32 = rep_uint32; - alltypes.rep_uint64_count = 5; alltypes.rep_uint64 = rep_uint64; - alltypes.rep_sint32_count = 5; alltypes.rep_sint32 = rep_sint32; - alltypes.rep_sint64_count = 5; alltypes.rep_sint64 = rep_sint64; - alltypes.rep_bool_count = 5; alltypes.rep_bool = rep_bool; - alltypes.rep_fixed32_count = 5; alltypes.rep_fixed32 = rep_fixed32; - alltypes.rep_sfixed32_count = 5; alltypes.rep_sfixed32 = rep_sfixed32; - alltypes.rep_float_count = 5; alltypes.rep_float = rep_float; - alltypes.rep_fixed64_count = 5; alltypes.rep_fixed64 = rep_fixed64; - alltypes.rep_sfixed64_count = 5; alltypes.rep_sfixed64 = rep_sfixed64; - alltypes.rep_double_count = 5; alltypes.rep_double = rep_double; - alltypes.rep_string_count = 5; alltypes.rep_string = rep_string; - alltypes.rep_bytes_count = 5; alltypes.rep_bytes = rep_bytes; - alltypes.rep_submsg_count = 5; alltypes.rep_submsg = rep_submsg; - alltypes.rep_enum_count = 5; alltypes.rep_enum = rep_enum; - alltypes.rep_emptymsg_count = 5; alltypes.rep_emptymsg = rep_emptymsg; - - if (mode != 0) - { - /* Fill in values for optional fields */ - alltypes.opt_int32 = &opt_int32; - alltypes.opt_int64 = &opt_int64; - alltypes.opt_uint32 = &opt_uint32; - alltypes.opt_uint64 = &opt_uint64; - alltypes.opt_sint32 = &opt_sint32; - alltypes.opt_sint64 = &opt_sint64; - alltypes.opt_bool = &opt_bool; - alltypes.opt_fixed32 = &opt_fixed32; - alltypes.opt_sfixed32 = &opt_sfixed32; - alltypes.opt_float = &opt_float; - alltypes.opt_fixed64 = &opt_fixed64; - alltypes.opt_sfixed64 = &opt_sfixed64; - alltypes.opt_double = &opt_double; - alltypes.opt_string = opt_string; - alltypes.opt_bytes = (pb_bytes_array_t*)&opt_bytes; - alltypes.opt_submsg = &opt_submsg; - alltypes.opt_enum = &opt_enum; - alltypes.opt_emptymsg = &opt_emptymsg; - - alltypes.which_oneof = AllTypes_oneof_msg1_tag; - alltypes.oneof.oneof_msg1 = &oneof_msg1; - } - - alltypes.end = &end; - - { - uint8_t buffer[4096]; - pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - - /* Now encode it and check if we succeeded. */ - if (pb_encode(&stream, AllTypes_fields, &alltypes)) - { - SET_BINARY_MODE(stdout); - fwrite(buffer, 1, stream.bytes_written, stdout); - return 0; /* Success */ - } - else - { - fprintf(stderr, "Encoding failed: %s\n", PB_GET_ERROR(&stream)); - return 1; /* Failure */ - } - } -} diff --git a/third_party/nanopb/tests/anonymous_oneof/SConscript b/third_party/nanopb/tests/anonymous_oneof/SConscript deleted file mode 100644 index 106722875fd..00000000000 --- a/third_party/nanopb/tests/anonymous_oneof/SConscript +++ /dev/null @@ -1,30 +0,0 @@ -# Test anonymous_oneof generator option - -Import('env') - -import re - -match = None -if 'PROTOC_VERSION' in env: - match = re.search('([0-9]+).([0-9]+).([0-9]+)', env['PROTOC_VERSION']) - -if match: - version = map(int, match.groups()) - -# Oneof is supported by protoc >= 2.6.0 -if env.GetOption('clean') or (match and (version[0] > 2 or (version[0] == 2 and version[1] >= 6))): - # Anonymous oneofs are supported by clang and gcc - if 'clang' in env['CC'] or 'gcc' in env['CC']: - env2 = env.Clone() - if '-pedantic' in env2['CFLAGS']: - env2['CFLAGS'].remove('-pedantic') - env2.NanopbProto('oneof') - - dec = env2.Program(['decode_oneof.c', - 'oneof.pb.c', - '$COMMON/pb_decode.o', - '$COMMON/pb_common.o']) - - env2.RunTest("message1.txt", [dec, '$BUILD/oneof/message1.pb'], ARGS = ['1']) - env2.RunTest("message2.txt", [dec, '$BUILD/oneof/message2.pb'], ARGS = ['2']) - env2.RunTest("message3.txt", [dec, '$BUILD/oneof/message3.pb'], ARGS = ['3']) diff --git a/third_party/nanopb/tests/anonymous_oneof/decode_oneof.c b/third_party/nanopb/tests/anonymous_oneof/decode_oneof.c deleted file mode 100644 index 0f774dbc906..00000000000 --- a/third_party/nanopb/tests/anonymous_oneof/decode_oneof.c +++ /dev/null @@ -1,88 +0,0 @@ -/* Decode a message using oneof fields */ - -#include -#include -#include -#include -#include "oneof.pb.h" -#include "test_helpers.h" -#include "unittests.h" - -/* Test the 'AnonymousOneOfMessage' */ -int test_oneof_1(pb_istream_t *stream, int option) -{ - AnonymousOneOfMessage msg; - int status = 0; - - /* To better catch initialization errors */ - memset(&msg, 0xAA, sizeof(msg)); - - if (!pb_decode(stream, AnonymousOneOfMessage_fields, &msg)) - { - printf("Decoding failed: %s\n", PB_GET_ERROR(stream)); - return 1; - } - - /* Check that the basic fields work normally */ - TEST(msg.prefix == 123); - TEST(msg.suffix == 321); - - /* Check that we got the right oneof according to command line */ - if (option == 1) - { - TEST(msg.which_values == AnonymousOneOfMessage_first_tag); - TEST(msg.first == 999); - } - else if (option == 2) - { - TEST(msg.which_values == AnonymousOneOfMessage_second_tag); - TEST(strcmp(msg.second, "abcd") == 0); - } - else if (option == 3) - { - TEST(msg.which_values == AnonymousOneOfMessage_third_tag); - TEST(msg.third.array[0] == 1); - TEST(msg.third.array[1] == 2); - TEST(msg.third.array[2] == 3); - TEST(msg.third.array[3] == 4); - TEST(msg.third.array[4] == 5); - } - - return status; -} - -int main(int argc, char **argv) -{ - uint8_t buffer[AnonymousOneOfMessage_size]; - size_t count; - int option; - - if (argc != 2) - { - fprintf(stderr, "Usage: decode_oneof [number]\n"); - return 1; - } - option = atoi(argv[1]); - - SET_BINARY_MODE(stdin); - count = fread(buffer, 1, sizeof(buffer), stdin); - - if (!feof(stdin)) - { - printf("Message does not fit in buffer\n"); - return 1; - } - - { - int status = 0; - pb_istream_t stream; - - stream = pb_istream_from_buffer(buffer, count); - status = test_oneof_1(&stream, option); - - if (status != 0) - return status; - } - - return 0; -} diff --git a/third_party/nanopb/tests/anonymous_oneof/oneof.proto b/third_party/nanopb/tests/anonymous_oneof/oneof.proto deleted file mode 100644 index d56285c04d6..00000000000 --- a/third_party/nanopb/tests/anonymous_oneof/oneof.proto +++ /dev/null @@ -1,23 +0,0 @@ -syntax = "proto2"; - -import 'nanopb.proto'; - -message SubMessage -{ - repeated int32 array = 1 [(nanopb).max_count = 8]; -} - -/* Oneof in a message with other fields */ -message AnonymousOneOfMessage -{ - option (nanopb_msgopt).anonymous_oneof = true; - required int32 prefix = 1; - oneof values - { - int32 first = 5; - string second = 6 [(nanopb).max_size = 8]; - SubMessage third = 7; - } - required int32 suffix = 99; -} - diff --git a/third_party/nanopb/tests/backwards_compatibility/SConscript b/third_party/nanopb/tests/backwards_compatibility/SConscript deleted file mode 100644 index 81b031827b0..00000000000 --- a/third_party/nanopb/tests/backwards_compatibility/SConscript +++ /dev/null @@ -1,11 +0,0 @@ -# Check that the old generated .pb.c/.pb.h files are still compatible with the -# current version of nanopb. - -Import("env") - -enc = env.Program(["encode_legacy.c", "alltypes_legacy.c", "$COMMON/pb_encode.o", "$COMMON/pb_common.o"]) -dec = env.Program(["decode_legacy.c", "alltypes_legacy.c", "$COMMON/pb_decode.o", "$COMMON/pb_common.o"]) - -env.RunTest(enc) -env.RunTest([dec, "encode_legacy.output"]) - diff --git a/third_party/nanopb/tests/backwards_compatibility/alltypes_legacy.c b/third_party/nanopb/tests/backwards_compatibility/alltypes_legacy.c deleted file mode 100644 index 7311fd45715..00000000000 --- a/third_party/nanopb/tests/backwards_compatibility/alltypes_legacy.c +++ /dev/null @@ -1,153 +0,0 @@ -/* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.0-dev at Tue Aug 19 17:53:24 2014. */ - -#include "alltypes_legacy.h" - -#if PB_PROTO_HEADER_VERSION != 30 -#error Regenerate this file with the current version of nanopb generator. -#endif - -const char SubMessage_substuff1_default[16] = "1"; -const int32_t SubMessage_substuff2_default = 2; -const uint32_t SubMessage_substuff3_default = 3u; -const int32_t Limits_int32_min_default = 2147483647; -const int32_t Limits_int32_max_default = -2147483647; -const uint32_t Limits_uint32_min_default = 4294967295u; -const uint32_t Limits_uint32_max_default = 0u; -const int64_t Limits_int64_min_default = 9223372036854775807ll; -const int64_t Limits_int64_max_default = -9223372036854775807ll; -const uint64_t Limits_uint64_min_default = 18446744073709551615ull; -const uint64_t Limits_uint64_max_default = 0ull; -const HugeEnum Limits_enum_min_default = HugeEnum_Positive; -const HugeEnum Limits_enum_max_default = HugeEnum_Negative; -const int32_t AllTypes_opt_int32_default = 4041; -const int64_t AllTypes_opt_int64_default = 4042ll; -const uint32_t AllTypes_opt_uint32_default = 4043u; -const uint64_t AllTypes_opt_uint64_default = 4044ull; -const int32_t AllTypes_opt_sint32_default = 4045; -const int64_t AllTypes_opt_sint64_default = 4046; -const bool AllTypes_opt_bool_default = false; -const uint32_t AllTypes_opt_fixed32_default = 4048u; -const int32_t AllTypes_opt_sfixed32_default = 4049; -const float AllTypes_opt_float_default = 4050; -const uint64_t AllTypes_opt_fixed64_default = 4051ull; -const int64_t AllTypes_opt_sfixed64_default = 4052ll; -const double AllTypes_opt_double_default = 4053; -const char AllTypes_opt_string_default[16] = "4054"; -const AllTypes_opt_bytes_t AllTypes_opt_bytes_default = {4, {0x34,0x30,0x35,0x35}}; -const MyEnum AllTypes_opt_enum_default = MyEnum_Second; - - -const pb_field_t SubMessage_fields[4] = { - PB_FIELD( 1, STRING , REQUIRED, STATIC , FIRST, SubMessage, substuff1, substuff1, &SubMessage_substuff1_default), - PB_FIELD( 2, INT32 , REQUIRED, STATIC , OTHER, SubMessage, substuff2, substuff1, &SubMessage_substuff2_default), - PB_FIELD( 3, FIXED32 , OPTIONAL, STATIC , OTHER, SubMessage, substuff3, substuff2, &SubMessage_substuff3_default), - PB_LAST_FIELD -}; - -const pb_field_t EmptyMessage_fields[1] = { - PB_LAST_FIELD -}; - -const pb_field_t Limits_fields[11] = { - PB_FIELD( 1, INT32 , REQUIRED, STATIC , FIRST, Limits, int32_min, int32_min, &Limits_int32_min_default), - PB_FIELD( 2, INT32 , REQUIRED, STATIC , OTHER, Limits, int32_max, int32_min, &Limits_int32_max_default), - PB_FIELD( 3, UINT32 , REQUIRED, STATIC , OTHER, Limits, uint32_min, int32_max, &Limits_uint32_min_default), - PB_FIELD( 4, UINT32 , REQUIRED, STATIC , OTHER, Limits, uint32_max, uint32_min, &Limits_uint32_max_default), - PB_FIELD( 5, INT64 , REQUIRED, STATIC , OTHER, Limits, int64_min, uint32_max, &Limits_int64_min_default), - PB_FIELD( 6, INT64 , REQUIRED, STATIC , OTHER, Limits, int64_max, int64_min, &Limits_int64_max_default), - PB_FIELD( 7, UINT64 , REQUIRED, STATIC , OTHER, Limits, uint64_min, int64_max, &Limits_uint64_min_default), - PB_FIELD( 8, UINT64 , REQUIRED, STATIC , OTHER, Limits, uint64_max, uint64_min, &Limits_uint64_max_default), - PB_FIELD( 9, ENUM , REQUIRED, STATIC , OTHER, Limits, enum_min, uint64_max, &Limits_enum_min_default), - PB_FIELD( 10, ENUM , REQUIRED, STATIC , OTHER, Limits, enum_max, enum_min, &Limits_enum_max_default), - PB_LAST_FIELD -}; - -const pb_field_t AllTypes_fields[54] = { - PB_FIELD( 1, INT32 , REQUIRED, STATIC , FIRST, AllTypes, req_int32, req_int32, 0), - PB_FIELD( 2, INT64 , REQUIRED, STATIC , OTHER, AllTypes, req_int64, req_int32, 0), - PB_FIELD( 3, UINT32 , REQUIRED, STATIC , OTHER, AllTypes, req_uint32, req_int64, 0), - PB_FIELD( 4, UINT64 , REQUIRED, STATIC , OTHER, AllTypes, req_uint64, req_uint32, 0), - PB_FIELD( 5, SINT32 , REQUIRED, STATIC , OTHER, AllTypes, req_sint32, req_uint64, 0), - PB_FIELD( 6, SINT64 , REQUIRED, STATIC , OTHER, AllTypes, req_sint64, req_sint32, 0), - PB_FIELD( 7, BOOL , REQUIRED, STATIC , OTHER, AllTypes, req_bool, req_sint64, 0), - PB_FIELD( 8, FIXED32 , REQUIRED, STATIC , OTHER, AllTypes, req_fixed32, req_bool, 0), - PB_FIELD( 9, SFIXED32, REQUIRED, STATIC , OTHER, AllTypes, req_sfixed32, req_fixed32, 0), - PB_FIELD( 10, FLOAT , REQUIRED, STATIC , OTHER, AllTypes, req_float, req_sfixed32, 0), - PB_FIELD( 11, FIXED64 , REQUIRED, STATIC , OTHER, AllTypes, req_fixed64, req_float, 0), - PB_FIELD( 12, SFIXED64, REQUIRED, STATIC , OTHER, AllTypes, req_sfixed64, req_fixed64, 0), - PB_FIELD( 13, DOUBLE , REQUIRED, STATIC , OTHER, AllTypes, req_double, req_sfixed64, 0), - PB_FIELD( 14, STRING , REQUIRED, STATIC , OTHER, AllTypes, req_string, req_double, 0), - PB_FIELD( 15, BYTES , REQUIRED, STATIC , OTHER, AllTypes, req_bytes, req_string, 0), - PB_FIELD( 16, MESSAGE , REQUIRED, STATIC , OTHER, AllTypes, req_submsg, req_bytes, &SubMessage_fields), - PB_FIELD( 17, ENUM , REQUIRED, STATIC , OTHER, AllTypes, req_enum, req_submsg, 0), - PB_FIELD( 21, INT32 , REPEATED, STATIC , OTHER, AllTypes, rep_int32, req_enum, 0), - PB_FIELD( 22, INT64 , REPEATED, STATIC , OTHER, AllTypes, rep_int64, rep_int32, 0), - PB_FIELD( 23, UINT32 , REPEATED, STATIC , OTHER, AllTypes, rep_uint32, rep_int64, 0), - PB_FIELD( 24, UINT64 , REPEATED, STATIC , OTHER, AllTypes, rep_uint64, rep_uint32, 0), - PB_FIELD( 25, SINT32 , REPEATED, STATIC , OTHER, AllTypes, rep_sint32, rep_uint64, 0), - PB_FIELD( 26, SINT64 , REPEATED, STATIC , OTHER, AllTypes, rep_sint64, rep_sint32, 0), - PB_FIELD( 27, BOOL , REPEATED, STATIC , OTHER, AllTypes, rep_bool, rep_sint64, 0), - PB_FIELD( 28, FIXED32 , REPEATED, STATIC , OTHER, AllTypes, rep_fixed32, rep_bool, 0), - PB_FIELD( 29, SFIXED32, REPEATED, STATIC , OTHER, AllTypes, rep_sfixed32, rep_fixed32, 0), - PB_FIELD( 30, FLOAT , REPEATED, STATIC , OTHER, AllTypes, rep_float, rep_sfixed32, 0), - PB_FIELD( 31, FIXED64 , REPEATED, STATIC , OTHER, AllTypes, rep_fixed64, rep_float, 0), - PB_FIELD( 32, SFIXED64, REPEATED, STATIC , OTHER, AllTypes, rep_sfixed64, rep_fixed64, 0), - PB_FIELD( 33, DOUBLE , REPEATED, STATIC , OTHER, AllTypes, rep_double, rep_sfixed64, 0), - PB_FIELD( 34, STRING , REPEATED, STATIC , OTHER, AllTypes, rep_string, rep_double, 0), - PB_FIELD( 35, BYTES , REPEATED, STATIC , OTHER, AllTypes, rep_bytes, rep_string, 0), - PB_FIELD( 36, MESSAGE , REPEATED, STATIC , OTHER, AllTypes, rep_submsg, rep_bytes, &SubMessage_fields), - PB_FIELD( 37, ENUM , REPEATED, STATIC , OTHER, AllTypes, rep_enum, rep_submsg, 0), - PB_FIELD( 41, INT32 , OPTIONAL, STATIC , OTHER, AllTypes, opt_int32, rep_enum, &AllTypes_opt_int32_default), - PB_FIELD( 42, INT64 , OPTIONAL, STATIC , OTHER, AllTypes, opt_int64, opt_int32, &AllTypes_opt_int64_default), - PB_FIELD( 43, UINT32 , OPTIONAL, STATIC , OTHER, AllTypes, opt_uint32, opt_int64, &AllTypes_opt_uint32_default), - PB_FIELD( 44, UINT64 , OPTIONAL, STATIC , OTHER, AllTypes, opt_uint64, opt_uint32, &AllTypes_opt_uint64_default), - PB_FIELD( 45, SINT32 , OPTIONAL, STATIC , OTHER, AllTypes, opt_sint32, opt_uint64, &AllTypes_opt_sint32_default), - PB_FIELD( 46, SINT64 , OPTIONAL, STATIC , OTHER, AllTypes, opt_sint64, opt_sint32, &AllTypes_opt_sint64_default), - PB_FIELD( 47, BOOL , OPTIONAL, STATIC , OTHER, AllTypes, opt_bool, opt_sint64, &AllTypes_opt_bool_default), - PB_FIELD( 48, FIXED32 , OPTIONAL, STATIC , OTHER, AllTypes, opt_fixed32, opt_bool, &AllTypes_opt_fixed32_default), - PB_FIELD( 49, SFIXED32, OPTIONAL, STATIC , OTHER, AllTypes, opt_sfixed32, opt_fixed32, &AllTypes_opt_sfixed32_default), - PB_FIELD( 50, FLOAT , OPTIONAL, STATIC , OTHER, AllTypes, opt_float, opt_sfixed32, &AllTypes_opt_float_default), - PB_FIELD( 51, FIXED64 , OPTIONAL, STATIC , OTHER, AllTypes, opt_fixed64, opt_float, &AllTypes_opt_fixed64_default), - PB_FIELD( 52, SFIXED64, OPTIONAL, STATIC , OTHER, AllTypes, opt_sfixed64, opt_fixed64, &AllTypes_opt_sfixed64_default), - PB_FIELD( 53, DOUBLE , OPTIONAL, STATIC , OTHER, AllTypes, opt_double, opt_sfixed64, &AllTypes_opt_double_default), - PB_FIELD( 54, STRING , OPTIONAL, STATIC , OTHER, AllTypes, opt_string, opt_double, &AllTypes_opt_string_default), - PB_FIELD( 55, BYTES , OPTIONAL, STATIC , OTHER, AllTypes, opt_bytes, opt_string, &AllTypes_opt_bytes_default), - PB_FIELD( 56, MESSAGE , OPTIONAL, STATIC , OTHER, AllTypes, opt_submsg, opt_bytes, &SubMessage_fields), - PB_FIELD( 57, ENUM , OPTIONAL, STATIC , OTHER, AllTypes, opt_enum, opt_submsg, &AllTypes_opt_enum_default), - PB_FIELD( 99, INT32 , REQUIRED, STATIC , OTHER, AllTypes, end, opt_enum, 0), - PB_FIELD(200, EXTENSION, OPTIONAL, CALLBACK, OTHER, AllTypes, extensions, end, 0), - PB_LAST_FIELD -}; - - -/* Check that field information fits in pb_field_t */ -#if !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_32BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in 8 or 16 bit - * field descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(AllTypes, req_submsg) < 65536 && pb_membersize(AllTypes, rep_submsg[0]) < 65536 && pb_membersize(AllTypes, opt_submsg) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_SubMessage_EmptyMessage_Limits_AllTypes) -#endif - -#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_16BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in the default - * 8 bit descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(AllTypes, req_submsg) < 256 && pb_membersize(AllTypes, rep_submsg[0]) < 256 && pb_membersize(AllTypes, opt_submsg) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_SubMessage_EmptyMessage_Limits_AllTypes) -#endif - - -/* On some platforms (such as AVR), double is really float. - * These are not directly supported by nanopb, but see example_avr_double. - * To get rid of this error, remove any double fields from your .proto. - */ -PB_STATIC_ASSERT(sizeof(double) == 8, DOUBLE_MUST_BE_8_BYTES) - diff --git a/third_party/nanopb/tests/backwards_compatibility/alltypes_legacy.h b/third_party/nanopb/tests/backwards_compatibility/alltypes_legacy.h deleted file mode 100644 index 4e0a63be465..00000000000 --- a/third_party/nanopb/tests/backwards_compatibility/alltypes_legacy.h +++ /dev/null @@ -1,274 +0,0 @@ -/* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.0-dev at Tue Aug 19 17:53:24 2014. */ - -#ifndef PB_ALLTYPES_LEGACY_H_INCLUDED -#define PB_ALLTYPES_LEGACY_H_INCLUDED -#include - -#if PB_PROTO_HEADER_VERSION != 30 -#error Regenerate this file with the current version of nanopb generator. -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Enum definitions */ -typedef enum _HugeEnum { - HugeEnum_Negative = -2147483647, - HugeEnum_Positive = 2147483647 -} HugeEnum; - -typedef enum _MyEnum { - MyEnum_Zero = 0, - MyEnum_First = 1, - MyEnum_Second = 2, - MyEnum_Truth = 42 -} MyEnum; - -/* Struct definitions */ -typedef struct _EmptyMessage { - uint8_t dummy_field; -} EmptyMessage; - -typedef struct _Limits { - int32_t int32_min; - int32_t int32_max; - uint32_t uint32_min; - uint32_t uint32_max; - int64_t int64_min; - int64_t int64_max; - uint64_t uint64_min; - uint64_t uint64_max; - HugeEnum enum_min; - HugeEnum enum_max; -} Limits; - -typedef struct _SubMessage { - char substuff1[16]; - int32_t substuff2; - bool has_substuff3; - uint32_t substuff3; -} SubMessage; - -typedef PB_BYTES_ARRAY_T(16) AllTypes_req_bytes_t; - -typedef PB_BYTES_ARRAY_T(16) AllTypes_rep_bytes_t; - -typedef PB_BYTES_ARRAY_T(16) AllTypes_opt_bytes_t; - -typedef struct _AllTypes { - int32_t req_int32; - int64_t req_int64; - uint32_t req_uint32; - uint64_t req_uint64; - int32_t req_sint32; - int64_t req_sint64; - bool req_bool; - uint32_t req_fixed32; - int32_t req_sfixed32; - float req_float; - uint64_t req_fixed64; - int64_t req_sfixed64; - double req_double; - char req_string[16]; - AllTypes_req_bytes_t req_bytes; - SubMessage req_submsg; - MyEnum req_enum; - pb_size_t rep_int32_count; - int32_t rep_int32[5]; - pb_size_t rep_int64_count; - int64_t rep_int64[5]; - pb_size_t rep_uint32_count; - uint32_t rep_uint32[5]; - pb_size_t rep_uint64_count; - uint64_t rep_uint64[5]; - pb_size_t rep_sint32_count; - int32_t rep_sint32[5]; - pb_size_t rep_sint64_count; - int64_t rep_sint64[5]; - pb_size_t rep_bool_count; - bool rep_bool[5]; - pb_size_t rep_fixed32_count; - uint32_t rep_fixed32[5]; - pb_size_t rep_sfixed32_count; - int32_t rep_sfixed32[5]; - pb_size_t rep_float_count; - float rep_float[5]; - pb_size_t rep_fixed64_count; - uint64_t rep_fixed64[5]; - pb_size_t rep_sfixed64_count; - int64_t rep_sfixed64[5]; - pb_size_t rep_double_count; - double rep_double[5]; - pb_size_t rep_string_count; - char rep_string[5][16]; - pb_size_t rep_bytes_count; - AllTypes_rep_bytes_t rep_bytes[5]; - pb_size_t rep_submsg_count; - SubMessage rep_submsg[5]; - pb_size_t rep_enum_count; - MyEnum rep_enum[5]; - bool has_opt_int32; - int32_t opt_int32; - bool has_opt_int64; - int64_t opt_int64; - bool has_opt_uint32; - uint32_t opt_uint32; - bool has_opt_uint64; - uint64_t opt_uint64; - bool has_opt_sint32; - int32_t opt_sint32; - bool has_opt_sint64; - int64_t opt_sint64; - bool has_opt_bool; - bool opt_bool; - bool has_opt_fixed32; - uint32_t opt_fixed32; - bool has_opt_sfixed32; - int32_t opt_sfixed32; - bool has_opt_float; - float opt_float; - bool has_opt_fixed64; - uint64_t opt_fixed64; - bool has_opt_sfixed64; - int64_t opt_sfixed64; - bool has_opt_double; - double opt_double; - bool has_opt_string; - char opt_string[16]; - bool has_opt_bytes; - AllTypes_opt_bytes_t opt_bytes; - bool has_opt_submsg; - SubMessage opt_submsg; - bool has_opt_enum; - MyEnum opt_enum; - int32_t end; - pb_extension_t *extensions; -} AllTypes; - -/* Default values for struct fields */ -extern const char SubMessage_substuff1_default[16]; -extern const int32_t SubMessage_substuff2_default; -extern const uint32_t SubMessage_substuff3_default; -extern const int32_t Limits_int32_min_default; -extern const int32_t Limits_int32_max_default; -extern const uint32_t Limits_uint32_min_default; -extern const uint32_t Limits_uint32_max_default; -extern const int64_t Limits_int64_min_default; -extern const int64_t Limits_int64_max_default; -extern const uint64_t Limits_uint64_min_default; -extern const uint64_t Limits_uint64_max_default; -extern const HugeEnum Limits_enum_min_default; -extern const HugeEnum Limits_enum_max_default; -extern const int32_t AllTypes_opt_int32_default; -extern const int64_t AllTypes_opt_int64_default; -extern const uint32_t AllTypes_opt_uint32_default; -extern const uint64_t AllTypes_opt_uint64_default; -extern const int32_t AllTypes_opt_sint32_default; -extern const int64_t AllTypes_opt_sint64_default; -extern const bool AllTypes_opt_bool_default; -extern const uint32_t AllTypes_opt_fixed32_default; -extern const int32_t AllTypes_opt_sfixed32_default; -extern const float AllTypes_opt_float_default; -extern const uint64_t AllTypes_opt_fixed64_default; -extern const int64_t AllTypes_opt_sfixed64_default; -extern const double AllTypes_opt_double_default; -extern const char AllTypes_opt_string_default[16]; -extern const AllTypes_opt_bytes_t AllTypes_opt_bytes_default; -extern const MyEnum AllTypes_opt_enum_default; - -/* Initializer values for message structs */ -#define SubMessage_init_default {"1", 2, false, 3u} -#define EmptyMessage_init_default {0} -#define Limits_init_default {2147483647, -2147483647, 4294967295u, 0u, 9223372036854775807ll, -9223372036854775807ll, 18446744073709551615ull, 0ull, HugeEnum_Positive, HugeEnum_Negative} -#define AllTypes_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", {0, {0}}, SubMessage_init_default, (MyEnum)0, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {"", "", "", "", ""}, 0, {{0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}}, 0, {SubMessage_init_default, SubMessage_init_default, SubMessage_init_default, SubMessage_init_default, SubMessage_init_default}, 0, {(MyEnum)0, (MyEnum)0, (MyEnum)0, (MyEnum)0, (MyEnum)0}, false, 4041, false, 4042ll, false, 4043u, false, 4044ull, false, 4045, false, 4046, false, false, false, 4048u, false, 4049, false, 4050, false, 4051ull, false, 4052ll, false, 4053, false, "4054", false, {4, {0x34,0x30,0x35,0x35}}, false, SubMessage_init_default, false, MyEnum_Second, 0, NULL} -#define SubMessage_init_zero {"", 0, false, 0} -#define EmptyMessage_init_zero {0} -#define Limits_init_zero {0, 0, 0, 0, 0, 0, 0, 0, (HugeEnum)0, (HugeEnum)0} -#define AllTypes_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", {0, {0}}, SubMessage_init_zero, (MyEnum)0, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0}, 0, {"", "", "", "", ""}, 0, {{0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}}, 0, {SubMessage_init_zero, SubMessage_init_zero, SubMessage_init_zero, SubMessage_init_zero, SubMessage_init_zero}, 0, {(MyEnum)0, (MyEnum)0, (MyEnum)0, (MyEnum)0, (MyEnum)0}, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, "", false, {0, {0}}, false, SubMessage_init_zero, false, (MyEnum)0, 0, NULL} - -/* Field tags (for use in manual encoding/decoding) */ -#define Limits_int32_min_tag 1 -#define Limits_int32_max_tag 2 -#define Limits_uint32_min_tag 3 -#define Limits_uint32_max_tag 4 -#define Limits_int64_min_tag 5 -#define Limits_int64_max_tag 6 -#define Limits_uint64_min_tag 7 -#define Limits_uint64_max_tag 8 -#define Limits_enum_min_tag 9 -#define Limits_enum_max_tag 10 -#define SubMessage_substuff1_tag 1 -#define SubMessage_substuff2_tag 2 -#define SubMessage_substuff3_tag 3 -#define AllTypes_req_int32_tag 1 -#define AllTypes_req_int64_tag 2 -#define AllTypes_req_uint32_tag 3 -#define AllTypes_req_uint64_tag 4 -#define AllTypes_req_sint32_tag 5 -#define AllTypes_req_sint64_tag 6 -#define AllTypes_req_bool_tag 7 -#define AllTypes_req_fixed32_tag 8 -#define AllTypes_req_sfixed32_tag 9 -#define AllTypes_req_float_tag 10 -#define AllTypes_req_fixed64_tag 11 -#define AllTypes_req_sfixed64_tag 12 -#define AllTypes_req_double_tag 13 -#define AllTypes_req_string_tag 14 -#define AllTypes_req_bytes_tag 15 -#define AllTypes_req_submsg_tag 16 -#define AllTypes_req_enum_tag 17 -#define AllTypes_rep_int32_tag 21 -#define AllTypes_rep_int64_tag 22 -#define AllTypes_rep_uint32_tag 23 -#define AllTypes_rep_uint64_tag 24 -#define AllTypes_rep_sint32_tag 25 -#define AllTypes_rep_sint64_tag 26 -#define AllTypes_rep_bool_tag 27 -#define AllTypes_rep_fixed32_tag 28 -#define AllTypes_rep_sfixed32_tag 29 -#define AllTypes_rep_float_tag 30 -#define AllTypes_rep_fixed64_tag 31 -#define AllTypes_rep_sfixed64_tag 32 -#define AllTypes_rep_double_tag 33 -#define AllTypes_rep_string_tag 34 -#define AllTypes_rep_bytes_tag 35 -#define AllTypes_rep_submsg_tag 36 -#define AllTypes_rep_enum_tag 37 -#define AllTypes_opt_int32_tag 41 -#define AllTypes_opt_int64_tag 42 -#define AllTypes_opt_uint32_tag 43 -#define AllTypes_opt_uint64_tag 44 -#define AllTypes_opt_sint32_tag 45 -#define AllTypes_opt_sint64_tag 46 -#define AllTypes_opt_bool_tag 47 -#define AllTypes_opt_fixed32_tag 48 -#define AllTypes_opt_sfixed32_tag 49 -#define AllTypes_opt_float_tag 50 -#define AllTypes_opt_fixed64_tag 51 -#define AllTypes_opt_sfixed64_tag 52 -#define AllTypes_opt_double_tag 53 -#define AllTypes_opt_string_tag 54 -#define AllTypes_opt_bytes_tag 55 -#define AllTypes_opt_submsg_tag 56 -#define AllTypes_opt_enum_tag 57 -#define AllTypes_end_tag 99 - -/* Struct field encoding specification for nanopb */ -extern const pb_field_t SubMessage_fields[4]; -extern const pb_field_t EmptyMessage_fields[1]; -extern const pb_field_t Limits_fields[11]; -extern const pb_field_t AllTypes_fields[54]; - -/* Maximum encoded size of messages (where known) */ -#define SubMessage_size 34 -#define EmptyMessage_size 0 -#define Limits_size 90 -#define AllTypes_size 1362 - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif diff --git a/third_party/nanopb/tests/backwards_compatibility/alltypes_legacy.options b/third_party/nanopb/tests/backwards_compatibility/alltypes_legacy.options deleted file mode 100644 index b31e3cf0a9d..00000000000 --- a/third_party/nanopb/tests/backwards_compatibility/alltypes_legacy.options +++ /dev/null @@ -1,3 +0,0 @@ -* max_size:16 -* max_count:5 - diff --git a/third_party/nanopb/tests/backwards_compatibility/alltypes_legacy.proto b/third_party/nanopb/tests/backwards_compatibility/alltypes_legacy.proto deleted file mode 100644 index f5bc35ce40a..00000000000 --- a/third_party/nanopb/tests/backwards_compatibility/alltypes_legacy.proto +++ /dev/null @@ -1,110 +0,0 @@ -syntax = "proto2"; - -message SubMessage { - required string substuff1 = 1 [default = "1"]; - required int32 substuff2 = 2 [default = 2]; - optional fixed32 substuff3 = 3 [default = 3]; -} - -message EmptyMessage { - -} - -enum HugeEnum { - Negative = -2147483647; /* protoc doesn't accept -2147483648 here */ - Positive = 2147483647; -} - -message Limits { - required int32 int32_min = 1 [default = 2147483647]; - required int32 int32_max = 2 [default = -2147483647]; - required uint32 uint32_min = 3 [default = 4294967295]; - required uint32 uint32_max = 4 [default = 0]; - required int64 int64_min = 5 [default = 9223372036854775807]; - required int64 int64_max = 6 [default = -9223372036854775807]; - required uint64 uint64_min = 7 [default = 18446744073709551615]; - required uint64 uint64_max = 8 [default = 0]; - required HugeEnum enum_min = 9 [default = Positive]; - required HugeEnum enum_max = 10 [default = Negative]; -} - -enum MyEnum { - Zero = 0; - First = 1; - Second = 2; - Truth = 42; -} - -message AllTypes { - required int32 req_int32 = 1; - required int64 req_int64 = 2; - required uint32 req_uint32 = 3; - required uint64 req_uint64 = 4; - required sint32 req_sint32 = 5; - required sint64 req_sint64 = 6; - required bool req_bool = 7; - - required fixed32 req_fixed32 = 8; - required sfixed32 req_sfixed32= 9; - required float req_float = 10; - - required fixed64 req_fixed64 = 11; - required sfixed64 req_sfixed64= 12; - required double req_double = 13; - - required string req_string = 14; - required bytes req_bytes = 15; - required SubMessage req_submsg = 16; - required MyEnum req_enum = 17; - - - repeated int32 rep_int32 = 21 [packed = true]; - repeated int64 rep_int64 = 22 [packed = true]; - repeated uint32 rep_uint32 = 23 [packed = true]; - repeated uint64 rep_uint64 = 24 [packed = true]; - repeated sint32 rep_sint32 = 25 [packed = true]; - repeated sint64 rep_sint64 = 26 [packed = true]; - repeated bool rep_bool = 27 [packed = true]; - - repeated fixed32 rep_fixed32 = 28 [packed = true]; - repeated sfixed32 rep_sfixed32= 29 [packed = true]; - repeated float rep_float = 30 [packed = true]; - - repeated fixed64 rep_fixed64 = 31 [packed = true]; - repeated sfixed64 rep_sfixed64= 32 [packed = true]; - repeated double rep_double = 33 [packed = true]; - - repeated string rep_string = 34; - repeated bytes rep_bytes = 35; - repeated SubMessage rep_submsg = 36; - repeated MyEnum rep_enum = 37 [packed = true]; - - optional int32 opt_int32 = 41 [default = 4041]; - optional int64 opt_int64 = 42 [default = 4042]; - optional uint32 opt_uint32 = 43 [default = 4043]; - optional uint64 opt_uint64 = 44 [default = 4044]; - optional sint32 opt_sint32 = 45 [default = 4045]; - optional sint64 opt_sint64 = 46 [default = 4046]; - optional bool opt_bool = 47 [default = false]; - - optional fixed32 opt_fixed32 = 48 [default = 4048]; - optional sfixed32 opt_sfixed32= 49 [default = 4049]; - optional float opt_float = 50 [default = 4050]; - - optional fixed64 opt_fixed64 = 51 [default = 4051]; - optional sfixed64 opt_sfixed64= 52 [default = 4052]; - optional double opt_double = 53 [default = 4053]; - - optional string opt_string = 54 [default = "4054"]; - optional bytes opt_bytes = 55 [default = "4055"]; - optional SubMessage opt_submsg = 56; - optional MyEnum opt_enum = 57 [default = Second]; - - // Just to make sure that the size of the fields has been calculated - // properly, i.e. otherwise a bug in last field might not be detected. - required int32 end = 99; - - - extensions 200 to 255; -} - diff --git a/third_party/nanopb/tests/backwards_compatibility/decode_legacy.c b/third_party/nanopb/tests/backwards_compatibility/decode_legacy.c deleted file mode 100644 index 5f5b6bbe76b..00000000000 --- a/third_party/nanopb/tests/backwards_compatibility/decode_legacy.c +++ /dev/null @@ -1,199 +0,0 @@ -/* Tests the decoding of all types. - * This is a backwards-compatibility test, using alltypes_legacy.h. - * It is similar to decode_alltypes, but duplicated in order to allow - * decode_alltypes to test any new features introduced later. - * - * Run e.g. ./encode_legacy | ./decode_legacy - */ - -#include -#include -#include -#include -#include "alltypes_legacy.h" -#include "test_helpers.h" - -#define TEST(x) if (!(x)) { \ - printf("Test " #x " failed.\n"); \ - return false; \ - } - -/* This function is called once from main(), it handles - the decoding and checks the fields. */ -bool check_alltypes(pb_istream_t *stream, int mode) -{ - AllTypes alltypes = {0}; - - if (!pb_decode(stream, AllTypes_fields, &alltypes)) - return false; - - TEST(alltypes.req_int32 == -1001); - TEST(alltypes.req_int64 == -1002); - TEST(alltypes.req_uint32 == 1003); - TEST(alltypes.req_uint64 == 1004); - TEST(alltypes.req_sint32 == -1005); - TEST(alltypes.req_sint64 == -1006); - TEST(alltypes.req_bool == true); - - TEST(alltypes.req_fixed32 == 1008); - TEST(alltypes.req_sfixed32 == -1009); - TEST(alltypes.req_float == 1010.0f); - - TEST(alltypes.req_fixed64 == 1011); - TEST(alltypes.req_sfixed64 == -1012); - TEST(alltypes.req_double == 1013.0f); - - TEST(strcmp(alltypes.req_string, "1014") == 0); - TEST(alltypes.req_bytes.size == 4); - TEST(memcmp(alltypes.req_bytes.bytes, "1015", 4) == 0); - TEST(strcmp(alltypes.req_submsg.substuff1, "1016") == 0); - TEST(alltypes.req_submsg.substuff2 == 1016); - TEST(alltypes.req_submsg.substuff3 == 3); - TEST(alltypes.req_enum == MyEnum_Truth); - - TEST(alltypes.rep_int32_count == 5 && alltypes.rep_int32[4] == -2001 && alltypes.rep_int32[0] == 0); - TEST(alltypes.rep_int64_count == 5 && alltypes.rep_int64[4] == -2002 && alltypes.rep_int64[0] == 0); - TEST(alltypes.rep_uint32_count == 5 && alltypes.rep_uint32[4] == 2003 && alltypes.rep_uint32[0] == 0); - TEST(alltypes.rep_uint64_count == 5 && alltypes.rep_uint64[4] == 2004 && alltypes.rep_uint64[0] == 0); - TEST(alltypes.rep_sint32_count == 5 && alltypes.rep_sint32[4] == -2005 && alltypes.rep_sint32[0] == 0); - TEST(alltypes.rep_sint64_count == 5 && alltypes.rep_sint64[4] == -2006 && alltypes.rep_sint64[0] == 0); - TEST(alltypes.rep_bool_count == 5 && alltypes.rep_bool[4] == true && alltypes.rep_bool[0] == false); - - TEST(alltypes.rep_fixed32_count == 5 && alltypes.rep_fixed32[4] == 2008 && alltypes.rep_fixed32[0] == 0); - TEST(alltypes.rep_sfixed32_count == 5 && alltypes.rep_sfixed32[4] == -2009 && alltypes.rep_sfixed32[0] == 0); - TEST(alltypes.rep_float_count == 5 && alltypes.rep_float[4] == 2010.0f && alltypes.rep_float[0] == 0.0f); - - TEST(alltypes.rep_fixed64_count == 5 && alltypes.rep_fixed64[4] == 2011 && alltypes.rep_fixed64[0] == 0); - TEST(alltypes.rep_sfixed64_count == 5 && alltypes.rep_sfixed64[4] == -2012 && alltypes.rep_sfixed64[0] == 0); - TEST(alltypes.rep_double_count == 5 && alltypes.rep_double[4] == 2013.0 && alltypes.rep_double[0] == 0.0); - - TEST(alltypes.rep_string_count == 5 && strcmp(alltypes.rep_string[4], "2014") == 0 && alltypes.rep_string[0][0] == '\0'); - TEST(alltypes.rep_bytes_count == 5 && alltypes.rep_bytes[4].size == 4 && alltypes.rep_bytes[0].size == 0); - TEST(memcmp(alltypes.rep_bytes[4].bytes, "2015", 4) == 0); - - TEST(alltypes.rep_submsg_count == 5); - TEST(strcmp(alltypes.rep_submsg[4].substuff1, "2016") == 0 && alltypes.rep_submsg[0].substuff1[0] == '\0'); - TEST(alltypes.rep_submsg[4].substuff2 == 2016 && alltypes.rep_submsg[0].substuff2 == 0); - TEST(alltypes.rep_submsg[4].substuff3 == 2016 && alltypes.rep_submsg[0].substuff3 == 3); - - TEST(alltypes.rep_enum_count == 5 && alltypes.rep_enum[4] == MyEnum_Truth && alltypes.rep_enum[0] == MyEnum_Zero); - - if (mode == 0) - { - /* Expect default values */ - TEST(alltypes.has_opt_int32 == false); - TEST(alltypes.opt_int32 == 4041); - TEST(alltypes.has_opt_int64 == false); - TEST(alltypes.opt_int64 == 4042); - TEST(alltypes.has_opt_uint32 == false); - TEST(alltypes.opt_uint32 == 4043); - TEST(alltypes.has_opt_uint64 == false); - TEST(alltypes.opt_uint64 == 4044); - TEST(alltypes.has_opt_sint32 == false); - TEST(alltypes.opt_sint32 == 4045); - TEST(alltypes.has_opt_sint64 == false); - TEST(alltypes.opt_sint64 == 4046); - TEST(alltypes.has_opt_bool == false); - TEST(alltypes.opt_bool == false); - - TEST(alltypes.has_opt_fixed32 == false); - TEST(alltypes.opt_fixed32 == 4048); - TEST(alltypes.has_opt_sfixed32 == false); - TEST(alltypes.opt_sfixed32 == 4049); - TEST(alltypes.has_opt_float == false); - TEST(alltypes.opt_float == 4050.0f); - - TEST(alltypes.has_opt_fixed64 == false); - TEST(alltypes.opt_fixed64 == 4051); - TEST(alltypes.has_opt_sfixed64 == false); - TEST(alltypes.opt_sfixed64 == 4052); - TEST(alltypes.has_opt_double == false); - TEST(alltypes.opt_double == 4053.0); - - TEST(alltypes.has_opt_string == false); - TEST(strcmp(alltypes.opt_string, "4054") == 0); - TEST(alltypes.has_opt_bytes == false); - TEST(alltypes.opt_bytes.size == 4); - TEST(memcmp(alltypes.opt_bytes.bytes, "4055", 4) == 0); - TEST(alltypes.has_opt_submsg == false); - TEST(strcmp(alltypes.opt_submsg.substuff1, "1") == 0); - TEST(alltypes.opt_submsg.substuff2 == 2); - TEST(alltypes.opt_submsg.substuff3 == 3); - TEST(alltypes.has_opt_enum == false); - TEST(alltypes.opt_enum == MyEnum_Second); - } - else - { - /* Expect filled-in values */ - TEST(alltypes.has_opt_int32 == true); - TEST(alltypes.opt_int32 == 3041); - TEST(alltypes.has_opt_int64 == true); - TEST(alltypes.opt_int64 == 3042); - TEST(alltypes.has_opt_uint32 == true); - TEST(alltypes.opt_uint32 == 3043); - TEST(alltypes.has_opt_uint64 == true); - TEST(alltypes.opt_uint64 == 3044); - TEST(alltypes.has_opt_sint32 == true); - TEST(alltypes.opt_sint32 == 3045); - TEST(alltypes.has_opt_sint64 == true); - TEST(alltypes.opt_sint64 == 3046); - TEST(alltypes.has_opt_bool == true); - TEST(alltypes.opt_bool == true); - - TEST(alltypes.has_opt_fixed32 == true); - TEST(alltypes.opt_fixed32 == 3048); - TEST(alltypes.has_opt_sfixed32 == true); - TEST(alltypes.opt_sfixed32 == 3049); - TEST(alltypes.has_opt_float == true); - TEST(alltypes.opt_float == 3050.0f); - - TEST(alltypes.has_opt_fixed64 == true); - TEST(alltypes.opt_fixed64 == 3051); - TEST(alltypes.has_opt_sfixed64 == true); - TEST(alltypes.opt_sfixed64 == 3052); - TEST(alltypes.has_opt_double == true); - TEST(alltypes.opt_double == 3053.0); - - TEST(alltypes.has_opt_string == true); - TEST(strcmp(alltypes.opt_string, "3054") == 0); - TEST(alltypes.has_opt_bytes == true); - TEST(alltypes.opt_bytes.size == 4); - TEST(memcmp(alltypes.opt_bytes.bytes, "3055", 4) == 0); - TEST(alltypes.has_opt_submsg == true); - TEST(strcmp(alltypes.opt_submsg.substuff1, "3056") == 0); - TEST(alltypes.opt_submsg.substuff2 == 3056); - TEST(alltypes.opt_submsg.substuff3 == 3); - TEST(alltypes.has_opt_enum == true); - TEST(alltypes.opt_enum == MyEnum_Truth); - } - - TEST(alltypes.end == 1099); - - return true; -} - -int main(int argc, char **argv) -{ - uint8_t buffer[1024]; - size_t count; - pb_istream_t stream; - - /* Whether to expect the optional values or the default values. */ - int mode = (argc > 1) ? atoi(argv[1]) : 0; - - /* Read the data into buffer */ - SET_BINARY_MODE(stdin); - count = fread(buffer, 1, sizeof(buffer), stdin); - - /* Construct a pb_istream_t for reading from the buffer */ - stream = pb_istream_from_buffer(buffer, count); - - /* Decode and print out the stuff */ - if (!check_alltypes(&stream, mode)) - { - printf("Parsing failed: %s\n", PB_GET_ERROR(&stream)); - return 1; - } else { - return 0; - } -} diff --git a/third_party/nanopb/tests/backwards_compatibility/encode_legacy.c b/third_party/nanopb/tests/backwards_compatibility/encode_legacy.c deleted file mode 100644 index 5c9d41b3d6c..00000000000 --- a/third_party/nanopb/tests/backwards_compatibility/encode_legacy.c +++ /dev/null @@ -1,135 +0,0 @@ -/* Attempts to test all the datatypes supported by ProtoBuf. - * This is a backwards-compatibility test, using alltypes_legacy.h. - * It is similar to encode_alltypes, but duplicated in order to allow - * encode_alltypes to test any new features introduced later. - */ - -#include -#include -#include -#include -#include "alltypes_legacy.h" -#include "test_helpers.h" - -int main(int argc, char **argv) -{ - int mode = (argc > 1) ? atoi(argv[1]) : 0; - - /* Initialize the structure with constants */ - AllTypes alltypes = {0}; - - alltypes.req_int32 = -1001; - alltypes.req_int64 = -1002; - alltypes.req_uint32 = 1003; - alltypes.req_uint64 = 1004; - alltypes.req_sint32 = -1005; - alltypes.req_sint64 = -1006; - alltypes.req_bool = true; - - alltypes.req_fixed32 = 1008; - alltypes.req_sfixed32 = -1009; - alltypes.req_float = 1010.0f; - - alltypes.req_fixed64 = 1011; - alltypes.req_sfixed64 = -1012; - alltypes.req_double = 1013.0; - - strcpy(alltypes.req_string, "1014"); - alltypes.req_bytes.size = 4; - memcpy(alltypes.req_bytes.bytes, "1015", 4); - strcpy(alltypes.req_submsg.substuff1, "1016"); - alltypes.req_submsg.substuff2 = 1016; - alltypes.req_enum = MyEnum_Truth; - - alltypes.rep_int32_count = 5; alltypes.rep_int32[4] = -2001; - alltypes.rep_int64_count = 5; alltypes.rep_int64[4] = -2002; - alltypes.rep_uint32_count = 5; alltypes.rep_uint32[4] = 2003; - alltypes.rep_uint64_count = 5; alltypes.rep_uint64[4] = 2004; - alltypes.rep_sint32_count = 5; alltypes.rep_sint32[4] = -2005; - alltypes.rep_sint64_count = 5; alltypes.rep_sint64[4] = -2006; - alltypes.rep_bool_count = 5; alltypes.rep_bool[4] = true; - - alltypes.rep_fixed32_count = 5; alltypes.rep_fixed32[4] = 2008; - alltypes.rep_sfixed32_count = 5; alltypes.rep_sfixed32[4] = -2009; - alltypes.rep_float_count = 5; alltypes.rep_float[4] = 2010.0f; - - alltypes.rep_fixed64_count = 5; alltypes.rep_fixed64[4] = 2011; - alltypes.rep_sfixed64_count = 5; alltypes.rep_sfixed64[4] = -2012; - alltypes.rep_double_count = 5; alltypes.rep_double[4] = 2013.0; - - alltypes.rep_string_count = 5; strcpy(alltypes.rep_string[4], "2014"); - alltypes.rep_bytes_count = 5; alltypes.rep_bytes[4].size = 4; - memcpy(alltypes.rep_bytes[4].bytes, "2015", 4); - - alltypes.rep_submsg_count = 5; - strcpy(alltypes.rep_submsg[4].substuff1, "2016"); - alltypes.rep_submsg[4].substuff2 = 2016; - alltypes.rep_submsg[4].has_substuff3 = true; - alltypes.rep_submsg[4].substuff3 = 2016; - - alltypes.rep_enum_count = 5; alltypes.rep_enum[4] = MyEnum_Truth; - - if (mode != 0) - { - /* Fill in values for optional fields */ - alltypes.has_opt_int32 = true; - alltypes.opt_int32 = 3041; - alltypes.has_opt_int64 = true; - alltypes.opt_int64 = 3042; - alltypes.has_opt_uint32 = true; - alltypes.opt_uint32 = 3043; - alltypes.has_opt_uint64 = true; - alltypes.opt_uint64 = 3044; - alltypes.has_opt_sint32 = true; - alltypes.opt_sint32 = 3045; - alltypes.has_opt_sint64 = true; - alltypes.opt_sint64 = 3046; - alltypes.has_opt_bool = true; - alltypes.opt_bool = true; - - alltypes.has_opt_fixed32 = true; - alltypes.opt_fixed32 = 3048; - alltypes.has_opt_sfixed32 = true; - alltypes.opt_sfixed32 = 3049; - alltypes.has_opt_float = true; - alltypes.opt_float = 3050.0f; - - alltypes.has_opt_fixed64 = true; - alltypes.opt_fixed64 = 3051; - alltypes.has_opt_sfixed64 = true; - alltypes.opt_sfixed64 = 3052; - alltypes.has_opt_double = true; - alltypes.opt_double = 3053.0; - - alltypes.has_opt_string = true; - strcpy(alltypes.opt_string, "3054"); - alltypes.has_opt_bytes = true; - alltypes.opt_bytes.size = 4; - memcpy(alltypes.opt_bytes.bytes, "3055", 4); - alltypes.has_opt_submsg = true; - strcpy(alltypes.opt_submsg.substuff1, "3056"); - alltypes.opt_submsg.substuff2 = 3056; - alltypes.has_opt_enum = true; - alltypes.opt_enum = MyEnum_Truth; - } - - alltypes.end = 1099; - - { - uint8_t buffer[1024]; - pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - - /* Now encode it and check if we succeeded. */ - if (pb_encode(&stream, AllTypes_fields, &alltypes)) - { - SET_BINARY_MODE(stdout); - fwrite(buffer, 1, stream.bytes_written, stdout); - return 0; /* Success */ - } - else - { - fprintf(stderr, "Encoding failed!\n"); - return 1; /* Failure */ - } - } -} diff --git a/third_party/nanopb/tests/basic_buffer/SConscript b/third_party/nanopb/tests/basic_buffer/SConscript deleted file mode 100644 index acaf5ffa27e..00000000000 --- a/third_party/nanopb/tests/basic_buffer/SConscript +++ /dev/null @@ -1,12 +0,0 @@ -# Build and run a basic round-trip test using memory buffer encoding. - -Import("env") - -enc = env.Program(["encode_buffer.c", "$COMMON/person.pb.c", "$COMMON/pb_encode.o", "$COMMON/pb_common.o"]) -dec = env.Program(["decode_buffer.c", "$COMMON/person.pb.c", "$COMMON/pb_decode.o", "$COMMON/pb_common.o"]) - -env.RunTest(enc) -env.RunTest([dec, "encode_buffer.output"]) -env.Decode(["encode_buffer.output", "$COMMON/person.proto"], MESSAGE = "Person") -env.Compare(["decode_buffer.output", "encode_buffer.decoded"]) - diff --git a/third_party/nanopb/tests/basic_buffer/decode_buffer.c b/third_party/nanopb/tests/basic_buffer/decode_buffer.c deleted file mode 100644 index 291d164ca3e..00000000000 --- a/third_party/nanopb/tests/basic_buffer/decode_buffer.c +++ /dev/null @@ -1,88 +0,0 @@ -/* A very simple decoding test case, using person.proto. - * Produces output compatible with protoc --decode. - * Reads the encoded data from stdin and prints the values - * to stdout as text. - * - * Run e.g. ./test_encode1 | ./test_decode1 - */ - -#include -#include -#include "person.pb.h" -#include "test_helpers.h" - -/* This function is called once from main(), it handles - the decoding and printing. */ -bool print_person(pb_istream_t *stream) -{ - int i; - Person person = Person_init_zero; - - if (!pb_decode(stream, Person_fields, &person)) - return false; - - /* Now the decoding is done, rest is just to print stuff out. */ - - printf("name: \"%s\"\n", person.name); - printf("id: %ld\n", (long)person.id); - - if (person.has_email) - printf("email: \"%s\"\n", person.email); - - for (i = 0; i < person.phone_count; i++) - { - Person_PhoneNumber *phone = &person.phone[i]; - printf("phone {\n"); - printf(" number: \"%s\"\n", phone->number); - - if (phone->has_type) - { - switch (phone->type) - { - case Person_PhoneType_WORK: - printf(" type: WORK\n"); - break; - - case Person_PhoneType_HOME: - printf(" type: HOME\n"); - break; - - case Person_PhoneType_MOBILE: - printf(" type: MOBILE\n"); - break; - } - } - printf("}\n"); - } - - return true; -} - -int main() -{ - uint8_t buffer[Person_size]; - pb_istream_t stream; - size_t count; - - /* Read the data into buffer */ - SET_BINARY_MODE(stdin); - count = fread(buffer, 1, sizeof(buffer), stdin); - - if (!feof(stdin)) - { - printf("Message does not fit in buffer\n"); - return 1; - } - - /* Construct a pb_istream_t for reading from the buffer */ - stream = pb_istream_from_buffer(buffer, count); - - /* Decode and print out the stuff */ - if (!print_person(&stream)) - { - printf("Parsing failed: %s\n", PB_GET_ERROR(&stream)); - return 1; - } else { - return 0; - } -} diff --git a/third_party/nanopb/tests/basic_buffer/encode_buffer.c b/third_party/nanopb/tests/basic_buffer/encode_buffer.c deleted file mode 100644 index c412c14e7ae..00000000000 --- a/third_party/nanopb/tests/basic_buffer/encode_buffer.c +++ /dev/null @@ -1,38 +0,0 @@ -/* A very simple encoding test case using person.proto. - * Just puts constant data in the fields and encodes into - * buffer, which is then written to stdout. - */ - -#include -#include -#include "person.pb.h" -#include "test_helpers.h" - -int main() -{ - uint8_t buffer[Person_size]; - pb_ostream_t stream; - - /* Initialize the structure with constants */ - Person person = {"Test Person 99", 99, true, "test@person.com", - 3, {{"555-12345678", true, Person_PhoneType_MOBILE}, - {"99-2342", false, 0}, - {"1234-5678", true, Person_PhoneType_WORK}, - }}; - - stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - - /* Now encode it and check if we succeeded. */ - if (pb_encode(&stream, Person_fields, &person)) - { - /* Write the result data to stdout */ - SET_BINARY_MODE(stdout); - fwrite(buffer, 1, stream.bytes_written, stdout); - return 0; /* Success */ - } - else - { - fprintf(stderr, "Encoding failed: %s\n", PB_GET_ERROR(&stream)); - return 1; /* Failure */ - } -} diff --git a/third_party/nanopb/tests/basic_stream/SConscript b/third_party/nanopb/tests/basic_stream/SConscript deleted file mode 100644 index 7d6685623fe..00000000000 --- a/third_party/nanopb/tests/basic_stream/SConscript +++ /dev/null @@ -1,12 +0,0 @@ -# Build and run a basic round-trip test using direct stream encoding. - -Import("env") - -enc = env.Program(["encode_stream.c", "$COMMON/person.pb.c", "$COMMON/pb_encode.o", "$COMMON/pb_common.o"]) -dec = env.Program(["decode_stream.c", "$COMMON/person.pb.c", "$COMMON/pb_decode.o", "$COMMON/pb_common.o"]) - -env.RunTest(enc) -env.RunTest([dec, "encode_stream.output"]) -env.Decode(["encode_stream.output", "$COMMON/person.proto"], MESSAGE = "Person") -env.Compare(["decode_stream.output", "encode_stream.decoded"]) - diff --git a/third_party/nanopb/tests/basic_stream/decode_stream.c b/third_party/nanopb/tests/basic_stream/decode_stream.c deleted file mode 100644 index 798dcc506f3..00000000000 --- a/third_party/nanopb/tests/basic_stream/decode_stream.c +++ /dev/null @@ -1,84 +0,0 @@ -/* Same as test_decode1 but reads from stdin directly. - */ - -#include -#include -#include "person.pb.h" -#include "test_helpers.h" - -/* This function is called once from main(), it handles - the decoding and printing. - Ugly copy-paste from test_decode1.c. */ -bool print_person(pb_istream_t *stream) -{ - int i; - Person person = Person_init_zero; - - if (!pb_decode(stream, Person_fields, &person)) - return false; - - /* Now the decoding is done, rest is just to print stuff out. */ - - printf("name: \"%s\"\n", person.name); - printf("id: %ld\n", (long)person.id); - - if (person.has_email) - printf("email: \"%s\"\n", person.email); - - for (i = 0; i < person.phone_count; i++) - { - Person_PhoneNumber *phone = &person.phone[i]; - printf("phone {\n"); - printf(" number: \"%s\"\n", phone->number); - - if (phone->has_type) - { - switch (phone->type) - { - case Person_PhoneType_WORK: - printf(" type: WORK\n"); - break; - - case Person_PhoneType_HOME: - printf(" type: HOME\n"); - break; - - case Person_PhoneType_MOBILE: - printf(" type: MOBILE\n"); - break; - } - } - printf("}\n"); - } - - return true; -} - -/* This binds the pb_istream_t to stdin */ -bool callback(pb_istream_t *stream, uint8_t *buf, size_t count) -{ - FILE *file = (FILE*)stream->state; - bool status; - - status = (fread(buf, 1, count, file) == count); - - if (feof(file)) - stream->bytes_left = 0; - - return status; -} - -int main() -{ - pb_istream_t stream = {&callback, NULL, SIZE_MAX}; - stream.state = stdin; - SET_BINARY_MODE(stdin); - - if (!print_person(&stream)) - { - printf("Parsing failed: %s\n", PB_GET_ERROR(&stream)); - return 1; - } else { - return 0; - } -} diff --git a/third_party/nanopb/tests/basic_stream/encode_stream.c b/third_party/nanopb/tests/basic_stream/encode_stream.c deleted file mode 100644 index 7f571c4127d..00000000000 --- a/third_party/nanopb/tests/basic_stream/encode_stream.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Same as test_encode1.c, except writes directly to stdout. - */ - -#include -#include -#include "person.pb.h" -#include "test_helpers.h" - -/* This binds the pb_ostream_t into the stdout stream */ -bool streamcallback(pb_ostream_t *stream, const uint8_t *buf, size_t count) -{ - FILE *file = (FILE*) stream->state; - return fwrite(buf, 1, count, file) == count; -} - -int main() -{ - /* Initialize the structure with constants */ - Person person = {"Test Person 99", 99, true, "test@person.com", - 3, {{"555-12345678", true, Person_PhoneType_MOBILE}, - {"99-2342", false, 0}, - {"1234-5678", true, Person_PhoneType_WORK}, - }}; - - /* Prepare the stream, output goes directly to stdout */ - pb_ostream_t stream = {&streamcallback, NULL, SIZE_MAX, 0}; - stream.state = stdout; - SET_BINARY_MODE(stdout); - - /* Now encode it and check if we succeeded. */ - if (pb_encode(&stream, Person_fields, &person)) - { - return 0; /* Success */ - } - else - { - fprintf(stderr, "Encoding failed: %s\n", PB_GET_ERROR(&stream)); - return 1; /* Failure */ - } -} diff --git a/third_party/nanopb/tests/buffer_only/SConscript b/third_party/nanopb/tests/buffer_only/SConscript deleted file mode 100644 index 55b747b000d..00000000000 --- a/third_party/nanopb/tests/buffer_only/SConscript +++ /dev/null @@ -1,28 +0,0 @@ -# Run the alltypes test case, but compile with PB_BUFFER_ONLY=1 - -Import("env") - -# Take copy of the files for custom build. -c = Copy("$TARGET", "$SOURCE") -env.Command("alltypes.pb.h", "$BUILD/alltypes/alltypes.pb.h", c) -env.Command("alltypes.pb.c", "$BUILD/alltypes/alltypes.pb.c", c) -env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c) -env.Command("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c) - -# Define the compilation options -opts = env.Clone() -opts.Append(CPPDEFINES = {'PB_BUFFER_ONLY': 1}) - -# Build new version of core -strict = opts.Clone() -strict.Append(CFLAGS = strict['CORECFLAGS']) -strict.Object("pb_decode_bufonly.o", "$NANOPB/pb_decode.c") -strict.Object("pb_encode_bufonly.o", "$NANOPB/pb_encode.c") -strict.Object("pb_common_bufonly.o", "$NANOPB/pb_common.c") - -# Now build and run the test normally. -enc = opts.Program(["encode_alltypes.c", "alltypes.pb.c", "pb_encode_bufonly.o", "pb_common_bufonly.o"]) -dec = opts.Program(["decode_alltypes.c", "alltypes.pb.c", "pb_decode_bufonly.o", "pb_common_bufonly.o"]) - -env.RunTest(enc) -env.RunTest([dec, "encode_alltypes.output"]) diff --git a/third_party/nanopb/tests/callbacks/SConscript b/third_party/nanopb/tests/callbacks/SConscript deleted file mode 100644 index 445214397d6..00000000000 --- a/third_party/nanopb/tests/callbacks/SConscript +++ /dev/null @@ -1,14 +0,0 @@ -# Test the functionality of the callback fields. - -Import("env") - -env.NanopbProto("callbacks") -enc = env.Program(["encode_callbacks.c", "callbacks.pb.c", "$COMMON/pb_encode.o", "$COMMON/pb_common.o"]) -dec = env.Program(["decode_callbacks.c", "callbacks.pb.c", "$COMMON/pb_decode.o", "$COMMON/pb_common.o"]) - -env.RunTest(enc) -env.RunTest([dec, "encode_callbacks.output"]) - -env.Decode(["encode_callbacks.output", "callbacks.proto"], MESSAGE = "TestMessage") -env.Compare(["decode_callbacks.output", "encode_callbacks.decoded"]) - diff --git a/third_party/nanopb/tests/callbacks/callbacks.proto b/third_party/nanopb/tests/callbacks/callbacks.proto deleted file mode 100644 index 96ac744d53d..00000000000 --- a/third_party/nanopb/tests/callbacks/callbacks.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto2"; - -message SubMessage { - optional string stringvalue = 1; - repeated int32 int32value = 2; - repeated fixed32 fixed32value = 3; - repeated fixed64 fixed64value = 4; -} - -message TestMessage { - optional string stringvalue = 1; - repeated int32 int32value = 2; - repeated fixed32 fixed32value = 3; - repeated fixed64 fixed64value = 4; - optional SubMessage submsg = 5; - repeated string repeatedstring = 6; -} - diff --git a/third_party/nanopb/tests/callbacks/decode_callbacks.c b/third_party/nanopb/tests/callbacks/decode_callbacks.c deleted file mode 100644 index 45724d0be01..00000000000 --- a/third_party/nanopb/tests/callbacks/decode_callbacks.c +++ /dev/null @@ -1,97 +0,0 @@ -/* Decoding testcase for callback fields. - * Run e.g. ./test_encode_callbacks | ./test_decode_callbacks - */ - -#include -#include -#include "callbacks.pb.h" -#include "test_helpers.h" - -bool print_string(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - uint8_t buffer[1024] = {0}; - - /* We could read block-by-block to avoid the large buffer... */ - if (stream->bytes_left > sizeof(buffer) - 1) - return false; - - if (!pb_read(stream, buffer, stream->bytes_left)) - return false; - - /* Print the string, in format comparable with protoc --decode. - * Format comes from the arg defined in main(). - */ - printf((char*)*arg, buffer); - return true; -} - -bool print_int32(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - uint64_t value; - if (!pb_decode_varint(stream, &value)) - return false; - - printf((char*)*arg, (long)value); - return true; -} - -bool print_fixed32(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - uint32_t value; - if (!pb_decode_fixed32(stream, &value)) - return false; - - printf((char*)*arg, (long)value); - return true; -} - -bool print_fixed64(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - uint64_t value; - if (!pb_decode_fixed64(stream, &value)) - return false; - - printf((char*)*arg, (long)value); - return true; -} - -int main() -{ - uint8_t buffer[1024]; - size_t length; - pb_istream_t stream; - /* Note: empty initializer list initializes the struct with all-0. - * This is recommended so that unused callbacks are set to NULL instead - * of crashing at runtime. - */ - TestMessage testmessage = {{{NULL}}}; - - SET_BINARY_MODE(stdin); - length = fread(buffer, 1, 1024, stdin); - stream = pb_istream_from_buffer(buffer, length); - - testmessage.submsg.stringvalue.funcs.decode = &print_string; - testmessage.submsg.stringvalue.arg = "submsg {\n stringvalue: \"%s\"\n"; - testmessage.submsg.int32value.funcs.decode = &print_int32; - testmessage.submsg.int32value.arg = " int32value: %ld\n"; - testmessage.submsg.fixed32value.funcs.decode = &print_fixed32; - testmessage.submsg.fixed32value.arg = " fixed32value: %ld\n"; - testmessage.submsg.fixed64value.funcs.decode = &print_fixed64; - testmessage.submsg.fixed64value.arg = " fixed64value: %ld\n}\n"; - - testmessage.stringvalue.funcs.decode = &print_string; - testmessage.stringvalue.arg = "stringvalue: \"%s\"\n"; - testmessage.int32value.funcs.decode = &print_int32; - testmessage.int32value.arg = "int32value: %ld\n"; - testmessage.fixed32value.funcs.decode = &print_fixed32; - testmessage.fixed32value.arg = "fixed32value: %ld\n"; - testmessage.fixed64value.funcs.decode = &print_fixed64; - testmessage.fixed64value.arg = "fixed64value: %ld\n"; - testmessage.repeatedstring.funcs.decode = &print_string; - testmessage.repeatedstring.arg = "repeatedstring: \"%s\"\n"; - - if (!pb_decode(&stream, TestMessage_fields, &testmessage)) - return 1; - - return 0; -} diff --git a/third_party/nanopb/tests/callbacks/encode_callbacks.c b/third_party/nanopb/tests/callbacks/encode_callbacks.c deleted file mode 100644 index 6cb67b1e64d..00000000000 --- a/third_party/nanopb/tests/callbacks/encode_callbacks.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Encoding testcase for callback fields */ - -#include -#include -#include -#include "callbacks.pb.h" -#include "test_helpers.h" - -bool encode_string(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - char *str = "Hello world!"; - - if (!pb_encode_tag_for_field(stream, field)) - return false; - - return pb_encode_string(stream, (uint8_t*)str, strlen(str)); -} - -bool encode_int32(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - if (!pb_encode_tag_for_field(stream, field)) - return false; - - return pb_encode_varint(stream, 42); -} - -bool encode_fixed32(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - uint32_t value = 42; - - if (!pb_encode_tag_for_field(stream, field)) - return false; - - return pb_encode_fixed32(stream, &value); -} - -bool encode_fixed64(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - uint64_t value = 42; - - if (!pb_encode_tag_for_field(stream, field)) - return false; - - return pb_encode_fixed64(stream, &value); -} - -bool encode_repeatedstring(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - char *str[4] = {"Hello world!", "", "Test", "Test2"}; - int i; - - for (i = 0; i < 4; i++) - { - if (!pb_encode_tag_for_field(stream, field)) - return false; - - if (!pb_encode_string(stream, (uint8_t*)str[i], strlen(str[i]))) - return false; - } - return true; -} - -int main() -{ - uint8_t buffer[1024]; - pb_ostream_t stream; - TestMessage testmessage = {{{NULL}}}; - - stream = pb_ostream_from_buffer(buffer, 1024); - - testmessage.stringvalue.funcs.encode = &encode_string; - testmessage.int32value.funcs.encode = &encode_int32; - testmessage.fixed32value.funcs.encode = &encode_fixed32; - testmessage.fixed64value.funcs.encode = &encode_fixed64; - - testmessage.has_submsg = true; - testmessage.submsg.stringvalue.funcs.encode = &encode_string; - testmessage.submsg.int32value.funcs.encode = &encode_int32; - testmessage.submsg.fixed32value.funcs.encode = &encode_fixed32; - testmessage.submsg.fixed64value.funcs.encode = &encode_fixed64; - - testmessage.repeatedstring.funcs.encode = &encode_repeatedstring; - - if (!pb_encode(&stream, TestMessage_fields, &testmessage)) - return 1; - - SET_BINARY_MODE(stdout); - if (fwrite(buffer, stream.bytes_written, 1, stdout) != 1) - return 2; - - return 0; -} diff --git a/third_party/nanopb/tests/common/SConscript b/third_party/nanopb/tests/common/SConscript deleted file mode 100644 index 05e2f852e8d..00000000000 --- a/third_party/nanopb/tests/common/SConscript +++ /dev/null @@ -1,48 +0,0 @@ -# Build the common files needed by multiple test cases - -Import('env') - -# Protocol definitions for the encode/decode_unittests -env.NanopbProto("unittestproto") - -# Protocol definitions for basic_buffer/stream tests -env.NanopbProto("person") - -#-------------------------------------------- -# Binaries of the pb_decode.c and pb_encode.c -# These are built using more strict warning flags. -strict = env.Clone() -strict.Append(CFLAGS = strict['CORECFLAGS']) -strict.Object("pb_decode.o", "$NANOPB/pb_decode.c") -strict.Object("pb_encode.o", "$NANOPB/pb_encode.c") -strict.Object("pb_common.o", "$NANOPB/pb_common.c") - -#----------------------------------------------- -# Binaries of pb_decode etc. with malloc support -# Uses malloc_wrappers.c to count allocations. -malloc_env = env.Clone() -malloc_env.Append(CPPDEFINES = {'PB_ENABLE_MALLOC': 1, - 'PB_SYSTEM_HEADER': '\\"malloc_wrappers_syshdr.h\\"'}) -malloc_env.Append(CPPPATH = ["$COMMON"]) - -if 'SYSHDR' in malloc_env: - malloc_env.Append(CPPDEFINES = {'PB_OLD_SYSHDR': malloc_env['SYSHDR']}) - -# Disable libmudflap, because it will confuse valgrind -# and other memory leak detection tools. -if '-fmudflap' in env["CCFLAGS"]: - malloc_env["CCFLAGS"].remove("-fmudflap") - malloc_env["LINKFLAGS"].remove("-fmudflap") - malloc_env["LIBS"].remove("mudflap") - -malloc_strict = malloc_env.Clone() -malloc_strict.Append(CFLAGS = malloc_strict['CORECFLAGS']) -malloc_strict.Object("pb_decode_with_malloc.o", "$NANOPB/pb_decode.c") -malloc_strict.Object("pb_encode_with_malloc.o", "$NANOPB/pb_encode.c") -malloc_strict.Object("pb_common_with_malloc.o", "$NANOPB/pb_common.c") - -malloc_env.Object("malloc_wrappers.o", "malloc_wrappers.c") -malloc_env.Depends("$NANOPB/pb.h", ["malloc_wrappers_syshdr.h", "malloc_wrappers.h"]) - -Export("malloc_env") - diff --git a/third_party/nanopb/tests/common/malloc_wrappers.c b/third_party/nanopb/tests/common/malloc_wrappers.c deleted file mode 100644 index ad69f1cef6e..00000000000 --- a/third_party/nanopb/tests/common/malloc_wrappers.c +++ /dev/null @@ -1,54 +0,0 @@ -#include "malloc_wrappers.h" -#include -#include -#include - -static size_t alloc_count = 0; - -/* Allocate memory and place check values before and after. */ -void* malloc_with_check(size_t size) -{ - size_t size32 = (size + 3) / 4 + 3; - uint32_t *buf = malloc(size32 * sizeof(uint32_t)); - buf[0] = size32; - buf[1] = 0xDEADBEEF; - buf[size32 - 1] = 0xBADBAD; - return buf + 2; -} - -/* Free memory allocated with malloc_with_check() and do the checks. */ -void free_with_check(void *mem) -{ - uint32_t *buf = (uint32_t*)mem - 2; - assert(buf[1] == 0xDEADBEEF); - assert(buf[buf[0] - 1] == 0xBADBAD); - free(buf); -} - -/* Track memory usage */ -void* counting_realloc(void *ptr, size_t size) -{ - /* Don't allocate crazy amounts of RAM when fuzzing */ - if (size > 1000000) - return NULL; - - if (!ptr && size) - alloc_count++; - - return realloc(ptr, size); -} - -void counting_free(void *ptr) -{ - if (ptr) - { - assert(alloc_count > 0); - alloc_count--; - free(ptr); - } -} - -size_t get_alloc_count() -{ - return alloc_count; -} diff --git a/third_party/nanopb/tests/common/malloc_wrappers.h b/third_party/nanopb/tests/common/malloc_wrappers.h deleted file mode 100644 index 7eec7952711..00000000000 --- a/third_party/nanopb/tests/common/malloc_wrappers.h +++ /dev/null @@ -1,7 +0,0 @@ -#include - -void* malloc_with_check(size_t size); -void free_with_check(void *mem); -void* counting_realloc(void *ptr, size_t size); -void counting_free(void *ptr); -size_t get_alloc_count(); diff --git a/third_party/nanopb/tests/common/malloc_wrappers_syshdr.h b/third_party/nanopb/tests/common/malloc_wrappers_syshdr.h deleted file mode 100644 index d295d9ed0b3..00000000000 --- a/third_party/nanopb/tests/common/malloc_wrappers_syshdr.h +++ /dev/null @@ -1,15 +0,0 @@ -/* This is just a wrapper in order to get our own malloc wrappers into nanopb core. */ - -#define pb_realloc(ptr,size) counting_realloc(ptr,size) -#define pb_free(ptr) counting_free(ptr) - -#ifdef PB_OLD_SYSHDR -#include PB_OLD_SYSHDR -#else -#include -#include -#include -#include -#endif - -#include diff --git a/third_party/nanopb/tests/common/person.proto b/third_party/nanopb/tests/common/person.proto deleted file mode 100644 index becefdf3f2e..00000000000 --- a/third_party/nanopb/tests/common/person.proto +++ /dev/null @@ -1,22 +0,0 @@ -syntax = "proto2"; - -import "nanopb.proto"; - -message Person { - required string name = 1 [(nanopb).max_size = 40]; - required int32 id = 2; - optional string email = 3 [(nanopb).max_size = 40]; - - enum PhoneType { - MOBILE = 0; - HOME = 1; - WORK = 2; - } - - message PhoneNumber { - required string number = 1 [(nanopb).max_size = 40]; - optional PhoneType type = 2 [default = HOME]; - } - - repeated PhoneNumber phone = 4 [(nanopb).max_count = 5]; -} diff --git a/third_party/nanopb/tests/common/test_helpers.h b/third_party/nanopb/tests/common/test_helpers.h deleted file mode 100644 index f77760a521b..00000000000 --- a/third_party/nanopb/tests/common/test_helpers.h +++ /dev/null @@ -1,17 +0,0 @@ -/* Compatibility helpers for the test programs. */ - -#ifndef _TEST_HELPERS_H_ -#define _TEST_HELPERS_H_ - -#ifdef _WIN32 -#include -#include -#define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) - -#else -#define SET_BINARY_MODE(file) - -#endif - - -#endif diff --git a/third_party/nanopb/tests/common/unittestproto.proto b/third_party/nanopb/tests/common/unittestproto.proto deleted file mode 100644 index 23b5b97f877..00000000000 --- a/third_party/nanopb/tests/common/unittestproto.proto +++ /dev/null @@ -1,43 +0,0 @@ -syntax = "proto2"; - -import 'nanopb.proto'; - -message IntegerArray { - repeated int32 data = 1 [(nanopb).max_count = 10]; -} - -message FloatArray { - repeated float data = 1 [(nanopb).max_count = 10]; -} - -message StringMessage { - required string data = 1 [(nanopb).max_size = 10]; -} - -message BytesMessage { - required bytes data = 1 [(nanopb).max_size = 16]; -} - -message CallbackArray { - // We cheat a bit and use this message for testing other types, too. - // Nanopb does not care about the actual defined data type for callback - // fields. - repeated int32 data = 1; -} - -message IntegerContainer { - required IntegerArray submsg = 1; -} - -message CallbackContainer { - required CallbackArray submsg = 1; -} - -message CallbackContainerContainer { - required CallbackContainer submsg = 1; -} - -message StringPointerContainer { - repeated string rep_str = 1 [(nanopb).type = FT_POINTER]; -} - diff --git a/third_party/nanopb/tests/common/unittests.h b/third_party/nanopb/tests/common/unittests.h deleted file mode 100644 index c2b470aded7..00000000000 --- a/third_party/nanopb/tests/common/unittests.h +++ /dev/null @@ -1,14 +0,0 @@ -#include - -#define COMMENT(x) printf("\n----" x "----\n"); -#define STR(x) #x -#define STR2(x) STR(x) -#define TEST(x) \ - if (!(x)) { \ - fprintf(stderr, "\033[31;1mFAILED:\033[22;39m " __FILE__ ":" STR2(__LINE__) " " #x "\n"); \ - status = 1; \ - } else { \ - printf("\033[32;1mOK:\033[22;39m " #x "\n"); \ - } - - diff --git a/third_party/nanopb/tests/cxx_main_program/SConscript b/third_party/nanopb/tests/cxx_main_program/SConscript deleted file mode 100644 index edb88127190..00000000000 --- a/third_party/nanopb/tests/cxx_main_program/SConscript +++ /dev/null @@ -1,25 +0,0 @@ -# Run the alltypes test case, but compile it as C++ instead. -# In fact, compile the entire nanopb using C++ compiler. - -Import("env") - -# This is needed to get INT32_MIN etc. macros defined -env = env.Clone() -env.Append(CPPDEFINES = ['__STDC_LIMIT_MACROS']) - -# Copy the files to .cxx extension in order to force C++ build. -c = Copy("$TARGET", "$SOURCE") -env.Command("pb_encode.cxx", "#../pb_encode.c", c) -env.Command("pb_decode.cxx", "#../pb_decode.c", c) -env.Command("pb_common.cxx", "#../pb_common.c", c) -env.Command("alltypes.pb.h", "$BUILD/alltypes/alltypes.pb.h", c) -env.Command("alltypes.pb.cxx", "$BUILD/alltypes/alltypes.pb.c", c) -env.Command("encode_alltypes.cxx", "$BUILD/alltypes/encode_alltypes.c", c) -env.Command("decode_alltypes.cxx", "$BUILD/alltypes/decode_alltypes.c", c) - -# Now build and run the test normally. -enc = env.Program(["encode_alltypes.cxx", "alltypes.pb.cxx", "pb_encode.cxx", "pb_common.cxx"]) -dec = env.Program(["decode_alltypes.cxx", "alltypes.pb.cxx", "pb_decode.cxx", "pb_common.cxx"]) - -env.RunTest(enc) -env.RunTest([dec, "encode_alltypes.output"]) diff --git a/third_party/nanopb/tests/cyclic_messages/SConscript b/third_party/nanopb/tests/cyclic_messages/SConscript deleted file mode 100644 index c782001c95d..00000000000 --- a/third_party/nanopb/tests/cyclic_messages/SConscript +++ /dev/null @@ -1,11 +0,0 @@ -Import("env") - -# Encode cyclic messages with callback fields - -c = Copy("$TARGET", "$SOURCE") -env.Command("cyclic_callback.proto", "cyclic.proto", c) -env.NanopbProto(["cyclic_callback", "cyclic_callback.options"]) - -enc_callback = env.Program(["encode_cyclic_callback.c", "cyclic_callback.pb.c", "$COMMON/pb_encode.o", "$COMMON/pb_common.o"]) - - diff --git a/third_party/nanopb/tests/cyclic_messages/cyclic.proto b/third_party/nanopb/tests/cyclic_messages/cyclic.proto deleted file mode 100644 index 8cab0b142e3..00000000000 --- a/third_party/nanopb/tests/cyclic_messages/cyclic.proto +++ /dev/null @@ -1,27 +0,0 @@ -// Test structures with cyclic references. -// These can only be handled in pointer/callback mode, -// see associated .options files. - -syntax = "proto2"; - -message TreeNode -{ - optional int32 leaf = 1; - optional TreeNode left = 2; - optional TreeNode right = 3; -} - -message Dictionary -{ - repeated KeyValuePair dictItem = 1; -} - -message KeyValuePair -{ - required string key = 1; - optional string stringValue = 2; - optional int32 intValue = 3; - optional Dictionary dictValue = 4; - optional TreeNode treeValue = 5; -} - diff --git a/third_party/nanopb/tests/cyclic_messages/cyclic_callback.options b/third_party/nanopb/tests/cyclic_messages/cyclic_callback.options deleted file mode 100644 index fd4e1e1c46e..00000000000 --- a/third_party/nanopb/tests/cyclic_messages/cyclic_callback.options +++ /dev/null @@ -1,7 +0,0 @@ -TreeNode.left type:FT_CALLBACK -TreeNode.right type:FT_CALLBACK - -Dictionary.data type:FT_CALLBACK -KeyValuePair.key max_size:8 -KeyValuePair.stringValue max_size:8 -KeyValuePair.treeValue type:FT_CALLBACK diff --git a/third_party/nanopb/tests/cyclic_messages/encode_cyclic_callback.c b/third_party/nanopb/tests/cyclic_messages/encode_cyclic_callback.c deleted file mode 100644 index 7f67e70c632..00000000000 --- a/third_party/nanopb/tests/cyclic_messages/encode_cyclic_callback.c +++ /dev/null @@ -1,148 +0,0 @@ -/* This program parses an input string in a format a bit like JSON: - * {'foobar': 1234, 'xyz': 'abc', 'tree': [[[1, 2], 3], [4, 5]]} - * and encodes it as protobuf - * - * Note: The string parsing here is not in any way intended to be robust - * nor safe against buffer overflows. It is just for this test. - */ - -#include -#include -#include -#include -#include "cyclic_callback.pb.h" - -static char *find_end_of_item(char *p) -{ - int depth = 0; - do { - if (*p == '[' || *p == '{') depth++; - if (*p == ']' || *p == '}') depth--; - p++; - } while (depth > 0 || (*p != ',' && *p != '}')); - - if (*p == '}') - return p; /* End of parent dict */ - - p++; - while (*p == ' ') p++; - return p; -} - -/* Parse a tree in format [[1 2] 3] and encode it directly to protobuf */ -static bool encode_tree(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - TreeNode tree = TreeNode_init_zero; - char *p = (char*)*arg; - - if (*p == '[') - { - /* This is a tree branch */ - p++; - tree.left.funcs.encode = encode_tree; - tree.left.arg = p; - - p = find_end_of_item(p); - tree.right.funcs.encode = encode_tree; - tree.right.arg = p; - } - else - { - /* This is a leaf node */ - tree.has_leaf = true; - tree.leaf = atoi(p); - } - - return pb_encode_tag_for_field(stream, field) && - pb_encode_submessage(stream, TreeNode_fields, &tree); -} - -/* Parse a dictionary in format {'name': value} and encode it directly to protobuf */ -static bool encode_dictionary(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - int textlen; - char *p = (char*)*arg; - if (*p == '{') p++; - while (*p != '}') - { - KeyValuePair pair = KeyValuePair_init_zero; - - if (*p != '\'') - PB_RETURN_ERROR(stream, "invalid key, missing quote"); - - p++; /* Starting quote of key */ - textlen = strchr(p, '\'') - p; - strncpy(pair.key, p, textlen); - pair.key[textlen] = 0; - p += textlen + 2; - - while (*p == ' ') p++; - - if (*p == '[') - { - /* Value is a tree */ - pair.treeValue.funcs.encode = encode_tree; - pair.treeValue.arg = p; - } - else if (*p == '\'') - { - /* Value is a string */ - pair.has_stringValue = true; - p++; - textlen = strchr(p, '\'') - p; - strncpy(pair.stringValue, p, textlen); - pair.stringValue[textlen] = 0; - } - else if (*p == '{') - { - /* Value is a dictionary */ - pair.has_dictValue = true; - pair.dictValue.dictItem.funcs.encode = encode_dictionary; - pair.dictValue.dictItem.arg = p; - } - else - { - /* Value is integer */ - pair.has_intValue = true; - pair.intValue = atoi(p); - } - - p = find_end_of_item(p); - - if (!pb_encode_tag_for_field(stream, field)) - return false; - - if (!pb_encode_submessage(stream, KeyValuePair_fields, &pair)) - return false; - } - - return true; -} - - -int main(int argc, char *argv[]) -{ - uint8_t buffer[256]; - pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - Dictionary dict = Dictionary_init_zero; - - if (argc <= 1) - { - fprintf(stderr, "Usage: %s \"{'foobar': 1234, ...}\"\n", argv[0]); - return 1; - } - - dict.dictItem.funcs.encode = encode_dictionary; - dict.dictItem.arg = argv[1]; - - if (!pb_encode(&stream, Dictionary_fields, &dict)) - { - fprintf(stderr, "Encoding error: %s\n", PB_GET_ERROR(&stream)); - return 1; - } - - fwrite(buffer, 1, stream.bytes_written, stdout); - return 0; -} - - diff --git a/third_party/nanopb/tests/decode_unittests/SConscript b/third_party/nanopb/tests/decode_unittests/SConscript deleted file mode 100644 index 369b9dc71fc..00000000000 --- a/third_party/nanopb/tests/decode_unittests/SConscript +++ /dev/null @@ -1,4 +0,0 @@ -Import('env') -p = env.Program(["decode_unittests.c", "$COMMON/unittestproto.pb.c"]) -env.RunTest(p) - diff --git a/third_party/nanopb/tests/decode_unittests/decode_unittests.c b/third_party/nanopb/tests/decode_unittests/decode_unittests.c deleted file mode 100644 index 47f0fbdbd8a..00000000000 --- a/third_party/nanopb/tests/decode_unittests/decode_unittests.c +++ /dev/null @@ -1,344 +0,0 @@ -/* This includes the whole .c file to get access to static functions. */ -#define PB_ENABLE_MALLOC -#include "pb_common.c" -#include "pb_decode.c" - -#include -#include -#include "unittests.h" -#include "unittestproto.pb.h" - -#define S(x) pb_istream_from_buffer((uint8_t*)x, sizeof(x) - 1) - -bool stream_callback(pb_istream_t *stream, uint8_t *buf, size_t count) -{ - if (stream->state != NULL) - return false; /* Simulate error */ - - if (buf != NULL) - memset(buf, 'x', count); - return true; -} - -/* Verifies that the stream passed to callback matches the byte array pointed to by arg. */ -bool callback_check(pb_istream_t *stream, const pb_field_t *field, void **arg) -{ - int i; - uint8_t byte; - pb_bytes_array_t *ref = (pb_bytes_array_t*) *arg; - - for (i = 0; i < ref->size; i++) - { - if (!pb_read(stream, &byte, 1)) - return false; - - if (byte != ref->bytes[i]) - return false; - } - - return true; -} - -int main() -{ - int status = 0; - - { - uint8_t buffer1[] = "foobartest1234"; - uint8_t buffer2[sizeof(buffer1)]; - pb_istream_t stream = pb_istream_from_buffer(buffer1, sizeof(buffer1)); - - COMMENT("Test pb_read and pb_istream_t"); - TEST(pb_read(&stream, buffer2, 6)) - TEST(memcmp(buffer2, "foobar", 6) == 0) - TEST(stream.bytes_left == sizeof(buffer1) - 6) - TEST(pb_read(&stream, buffer2 + 6, stream.bytes_left)) - TEST(memcmp(buffer1, buffer2, sizeof(buffer1)) == 0) - TEST(stream.bytes_left == 0) - TEST(!pb_read(&stream, buffer2, 1)) - } - - { - uint8_t buffer[20]; - pb_istream_t stream = {&stream_callback, NULL, 20}; - - COMMENT("Test pb_read with custom callback"); - TEST(pb_read(&stream, buffer, 5)) - TEST(memcmp(buffer, "xxxxx", 5) == 0) - TEST(!pb_read(&stream, buffer, 50)) - stream.state = (void*)1; /* Simulated error return from callback */ - TEST(!pb_read(&stream, buffer, 5)) - stream.state = NULL; - TEST(pb_read(&stream, buffer, 15)) - } - - { - pb_istream_t s; - uint64_t u; - int64_t i; - - COMMENT("Test pb_decode_varint"); - TEST((s = S("\x00"), pb_decode_varint(&s, &u) && u == 0)); - TEST((s = S("\x01"), pb_decode_varint(&s, &u) && u == 1)); - TEST((s = S("\xAC\x02"), pb_decode_varint(&s, &u) && u == 300)); - TEST((s = S("\xFF\xFF\xFF\xFF\x0F"), pb_decode_varint(&s, &u) && u == UINT32_MAX)); - TEST((s = S("\xFF\xFF\xFF\xFF\x0F"), pb_decode_varint(&s, (uint64_t*)&i) && i == UINT32_MAX)); - TEST((s = S("\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x01"), - pb_decode_varint(&s, (uint64_t*)&i) && i == -1)); - TEST((s = S("\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x01"), - pb_decode_varint(&s, &u) && u == UINT64_MAX)); - TEST((s = S("\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x01"), - !pb_decode_varint(&s, &u))); - } - - { - pb_istream_t s; - uint32_t u; - - COMMENT("Test pb_decode_varint32"); - TEST((s = S("\x00"), pb_decode_varint32(&s, &u) && u == 0)); - TEST((s = S("\x01"), pb_decode_varint32(&s, &u) && u == 1)); - TEST((s = S("\xAC\x02"), pb_decode_varint32(&s, &u) && u == 300)); - TEST((s = S("\xFF\xFF\xFF\xFF\x0F"), pb_decode_varint32(&s, &u) && u == UINT32_MAX)); - TEST((s = S("\xFF\xFF\xFF\xFF\xFF\x01"), !pb_decode_varint32(&s, &u))); - } - - { - pb_istream_t s; - COMMENT("Test pb_skip_varint"); - TEST((s = S("\x00""foobar"), pb_skip_varint(&s) && s.bytes_left == 6)) - TEST((s = S("\xAC\x02""foobar"), pb_skip_varint(&s) && s.bytes_left == 6)) - TEST((s = S("\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x01""foobar"), - pb_skip_varint(&s) && s.bytes_left == 6)) - TEST((s = S("\xFF"), !pb_skip_varint(&s))) - } - - { - pb_istream_t s; - COMMENT("Test pb_skip_string") - TEST((s = S("\x00""foobar"), pb_skip_string(&s) && s.bytes_left == 6)) - TEST((s = S("\x04""testfoobar"), pb_skip_string(&s) && s.bytes_left == 6)) - TEST((s = S("\x04"), !pb_skip_string(&s))) - TEST((s = S("\xFF"), !pb_skip_string(&s))) - } - - { - pb_istream_t s = S("\x01\x00"); - pb_field_t f = {1, PB_LTYPE_VARINT, 0, 0, 4, 0, 0}; - uint32_t d; - COMMENT("Test pb_dec_varint using uint32_t") - TEST(pb_dec_varint(&s, &f, &d) && d == 1) - - /* Verify that no more than data_size is written. */ - d = 0xFFFFFFFF; - f.data_size = 1; - TEST(pb_dec_varint(&s, &f, &d) && (d == 0xFFFFFF00 || d == 0x00FFFFFF)) - } - - { - pb_istream_t s; - pb_field_t f = {1, PB_LTYPE_SVARINT, 0, 0, 4, 0, 0}; - int32_t d; - - COMMENT("Test pb_dec_svarint using int32_t") - TEST((s = S("\x01"), pb_dec_svarint(&s, &f, &d) && d == -1)) - TEST((s = S("\x02"), pb_dec_svarint(&s, &f, &d) && d == 1)) - TEST((s = S("\xfe\xff\xff\xff\x0f"), pb_dec_svarint(&s, &f, &d) && d == INT32_MAX)) - TEST((s = S("\xff\xff\xff\xff\x0f"), pb_dec_svarint(&s, &f, &d) && d == INT32_MIN)) - } - - { - pb_istream_t s; - pb_field_t f = {1, PB_LTYPE_SVARINT, 0, 0, 8, 0, 0}; - uint64_t d; - - COMMENT("Test pb_dec_svarint using uint64_t") - TEST((s = S("\x01"), pb_dec_svarint(&s, &f, &d) && d == -1)) - TEST((s = S("\x02"), pb_dec_svarint(&s, &f, &d) && d == 1)) - TEST((s = S("\xFE\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x01"), pb_dec_svarint(&s, &f, &d) && d == INT64_MAX)) - TEST((s = S("\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x01"), pb_dec_svarint(&s, &f, &d) && d == INT64_MIN)) - } - - { - pb_istream_t s; - pb_field_t f = {1, PB_LTYPE_FIXED32, 0, 0, 4, 0, 0}; - float d; - - COMMENT("Test pb_dec_fixed32 using float (failures here may be caused by imperfect rounding)") - TEST((s = S("\x00\x00\x00\x00"), pb_dec_fixed32(&s, &f, &d) && d == 0.0f)) - TEST((s = S("\x00\x00\xc6\x42"), pb_dec_fixed32(&s, &f, &d) && d == 99.0f)) - TEST((s = S("\x4e\x61\x3c\xcb"), pb_dec_fixed32(&s, &f, &d) && d == -12345678.0f)) - TEST((s = S("\x00"), !pb_dec_fixed32(&s, &f, &d) && d == -12345678.0f)) - } - - { - pb_istream_t s; - pb_field_t f = {1, PB_LTYPE_FIXED64, 0, 0, 8, 0, 0}; - double d; - - COMMENT("Test pb_dec_fixed64 using double (failures here may be caused by imperfect rounding)") - TEST((s = S("\x00\x00\x00\x00\x00\x00\x00\x00"), pb_dec_fixed64(&s, &f, &d) && d == 0.0)) - TEST((s = S("\x00\x00\x00\x00\x00\xc0\x58\x40"), pb_dec_fixed64(&s, &f, &d) && d == 99.0)) - TEST((s = S("\x00\x00\x00\xc0\x29\x8c\x67\xc1"), pb_dec_fixed64(&s, &f, &d) && d == -12345678.0f)) - } - - { - pb_istream_t s; - struct { pb_size_t size; uint8_t bytes[5]; } d; - pb_field_t f = {1, PB_LTYPE_BYTES, 0, 0, sizeof(d), 0, 0}; - - COMMENT("Test pb_dec_bytes") - TEST((s = S("\x00"), pb_dec_bytes(&s, &f, &d) && d.size == 0)) - TEST((s = S("\x01\xFF"), pb_dec_bytes(&s, &f, &d) && d.size == 1 && d.bytes[0] == 0xFF)) - TEST((s = S("\x05xxxxx"), pb_dec_bytes(&s, &f, &d) && d.size == 5)) - TEST((s = S("\x05xxxx"), !pb_dec_bytes(&s, &f, &d))) - - /* Note: the size limit on bytes-fields is not strictly obeyed, as - * the compiler may add some padding to the struct. Using this padding - * is not a very good thing to do, but it is difficult to avoid when - * we use only a single uint8_t to store the size of the field. - * Therefore this tests against a 10-byte string, while otherwise even - * 6 bytes should error out. - */ - TEST((s = S("\x10xxxxxxxxxx"), !pb_dec_bytes(&s, &f, &d))) - } - - { - pb_istream_t s; - pb_field_t f = {1, PB_LTYPE_STRING, 0, 0, 5, 0, 0}; - char d[5]; - - COMMENT("Test pb_dec_string") - TEST((s = S("\x00"), pb_dec_string(&s, &f, &d) && d[0] == '\0')) - TEST((s = S("\x04xyzz"), pb_dec_string(&s, &f, &d) && strcmp(d, "xyzz") == 0)) - TEST((s = S("\x05xyzzy"), !pb_dec_string(&s, &f, &d))) - } - - { - pb_istream_t s; - IntegerArray dest; - - COMMENT("Testing pb_decode with repeated int32 field") - TEST((s = S(""), pb_decode(&s, IntegerArray_fields, &dest) && dest.data_count == 0)) - TEST((s = S("\x08\x01\x08\x02"), pb_decode(&s, IntegerArray_fields, &dest) - && dest.data_count == 2 && dest.data[0] == 1 && dest.data[1] == 2)) - s = S("\x08\x01\x08\x02\x08\x03\x08\x04\x08\x05\x08\x06\x08\x07\x08\x08\x08\x09\x08\x0A"); - TEST(pb_decode(&s, IntegerArray_fields, &dest) && dest.data_count == 10 && dest.data[9] == 10) - s = S("\x08\x01\x08\x02\x08\x03\x08\x04\x08\x05\x08\x06\x08\x07\x08\x08\x08\x09\x08\x0A\x08\x0B"); - TEST(!pb_decode(&s, IntegerArray_fields, &dest)) - } - - { - pb_istream_t s; - IntegerArray dest; - - COMMENT("Testing pb_decode with packed int32 field") - TEST((s = S("\x0A\x00"), pb_decode(&s, IntegerArray_fields, &dest) - && dest.data_count == 0)) - TEST((s = S("\x0A\x01\x01"), pb_decode(&s, IntegerArray_fields, &dest) - && dest.data_count == 1 && dest.data[0] == 1)) - TEST((s = S("\x0A\x0A\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A"), pb_decode(&s, IntegerArray_fields, &dest) - && dest.data_count == 10 && dest.data[0] == 1 && dest.data[9] == 10)) - TEST((s = S("\x0A\x0B\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B"), !pb_decode(&s, IntegerArray_fields, &dest))) - - /* Test invalid wire data */ - TEST((s = S("\x0A\xFF"), !pb_decode(&s, IntegerArray_fields, &dest))) - TEST((s = S("\x0A\x01"), !pb_decode(&s, IntegerArray_fields, &dest))) - } - - { - pb_istream_t s; - IntegerArray dest; - - COMMENT("Testing pb_decode with unknown fields") - TEST((s = S("\x18\x0F\x08\x01"), pb_decode(&s, IntegerArray_fields, &dest) - && dest.data_count == 1 && dest.data[0] == 1)) - TEST((s = S("\x19\x00\x00\x00\x00\x00\x00\x00\x00\x08\x01"), pb_decode(&s, IntegerArray_fields, &dest) - && dest.data_count == 1 && dest.data[0] == 1)) - TEST((s = S("\x1A\x00\x08\x01"), pb_decode(&s, IntegerArray_fields, &dest) - && dest.data_count == 1 && dest.data[0] == 1)) - TEST((s = S("\x1B\x08\x01"), !pb_decode(&s, IntegerArray_fields, &dest))) - TEST((s = S("\x1D\x00\x00\x00\x00\x08\x01"), pb_decode(&s, IntegerArray_fields, &dest) - && dest.data_count == 1 && dest.data[0] == 1)) - } - - { - pb_istream_t s; - CallbackArray dest; - struct { pb_size_t size; uint8_t bytes[10]; } ref; - dest.data.funcs.decode = &callback_check; - dest.data.arg = &ref; - - COMMENT("Testing pb_decode with callbacks") - /* Single varint */ - ref.size = 1; ref.bytes[0] = 0x55; - TEST((s = S("\x08\x55"), pb_decode(&s, CallbackArray_fields, &dest))) - /* Packed varint */ - ref.size = 3; ref.bytes[0] = ref.bytes[1] = ref.bytes[2] = 0x55; - TEST((s = S("\x0A\x03\x55\x55\x55"), pb_decode(&s, CallbackArray_fields, &dest))) - /* Packed varint with loop */ - ref.size = 1; ref.bytes[0] = 0x55; - TEST((s = S("\x0A\x03\x55\x55\x55"), pb_decode(&s, CallbackArray_fields, &dest))) - /* Single fixed32 */ - ref.size = 4; ref.bytes[0] = ref.bytes[1] = ref.bytes[2] = ref.bytes[3] = 0xAA; - TEST((s = S("\x0D\xAA\xAA\xAA\xAA"), pb_decode(&s, CallbackArray_fields, &dest))) - /* Single fixed64 */ - ref.size = 8; memset(ref.bytes, 0xAA, 8); - TEST((s = S("\x09\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"), pb_decode(&s, CallbackArray_fields, &dest))) - /* Unsupported field type */ - TEST((s = S("\x0B\x00"), !pb_decode(&s, CallbackArray_fields, &dest))) - - /* Just make sure that our test function works */ - ref.size = 1; ref.bytes[0] = 0x56; - TEST((s = S("\x08\x55"), !pb_decode(&s, CallbackArray_fields, &dest))) - } - - { - pb_istream_t s; - IntegerArray dest; - - COMMENT("Testing pb_decode message termination") - TEST((s = S(""), pb_decode(&s, IntegerArray_fields, &dest))) - TEST((s = S("\x00"), pb_decode(&s, IntegerArray_fields, &dest))) - TEST((s = S("\x08\x01"), pb_decode(&s, IntegerArray_fields, &dest))) - TEST((s = S("\x08\x01\x00"), pb_decode(&s, IntegerArray_fields, &dest))) - TEST((s = S("\x08"), !pb_decode(&s, IntegerArray_fields, &dest))) - } - - { - pb_istream_t s; - IntegerContainer dest = {{0}}; - - COMMENT("Testing pb_decode_delimited") - TEST((s = S("\x09\x0A\x07\x0A\x05\x01\x02\x03\x04\x05"), - pb_decode_delimited(&s, IntegerContainer_fields, &dest)) && - dest.submsg.data_count == 5) - } - - { - pb_istream_t s = {0}; - void *data = NULL; - - COMMENT("Testing allocate_field") - TEST(allocate_field(&s, &data, 10, 10) && data != NULL); - TEST(allocate_field(&s, &data, 10, 20) && data != NULL); - - { - void *oldvalue = data; - size_t very_big = (size_t)-1; - size_t somewhat_big = very_big / 2 + 1; - size_t not_so_big = (size_t)1 << (4 * sizeof(size_t)); - - TEST(!allocate_field(&s, &data, very_big, 2) && data == oldvalue); - TEST(!allocate_field(&s, &data, somewhat_big, 2) && data == oldvalue); - TEST(!allocate_field(&s, &data, not_so_big, not_so_big) && data == oldvalue); - } - - pb_free(data); - } - - if (status != 0) - fprintf(stdout, "\n\nSome tests FAILED!\n"); - - return status; -} diff --git a/third_party/nanopb/tests/encode_unittests/SConscript b/third_party/nanopb/tests/encode_unittests/SConscript deleted file mode 100644 index bf6d1404c31..00000000000 --- a/third_party/nanopb/tests/encode_unittests/SConscript +++ /dev/null @@ -1,5 +0,0 @@ -# Build and run the stand-alone unit tests for the nanopb encoder part. - -Import('env') -p = env.Program(["encode_unittests.c", "$COMMON/unittestproto.pb.c"]) -env.RunTest(p) diff --git a/third_party/nanopb/tests/encode_unittests/encode_unittests.c b/third_party/nanopb/tests/encode_unittests/encode_unittests.c deleted file mode 100644 index 583af5c6c46..00000000000 --- a/third_party/nanopb/tests/encode_unittests/encode_unittests.c +++ /dev/null @@ -1,355 +0,0 @@ -/* This includes the whole .c file to get access to static functions. */ -#include "pb_common.c" -#include "pb_encode.c" - -#include -#include -#include "unittests.h" -#include "unittestproto.pb.h" - -bool streamcallback(pb_ostream_t *stream, const uint8_t *buf, size_t count) -{ - /* Allow only 'x' to be written */ - while (count--) - { - if (*buf++ != 'x') - return false; - } - return true; -} - -bool fieldcallback(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - int value = 0x55; - if (!pb_encode_tag_for_field(stream, field)) - return false; - return pb_encode_varint(stream, value); -} - -bool crazyfieldcallback(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) -{ - /* This callback writes different amount of data the second time. */ - uint32_t *state = (uint32_t*)arg; - *state <<= 8; - if (!pb_encode_tag_for_field(stream, field)) - return false; - return pb_encode_varint(stream, *state); -} - -/* Check that expression x writes data y. - * Y is a string, which may contain null bytes. Null terminator is ignored. - */ -#define WRITES(x, y) \ -memset(buffer, 0xAA, sizeof(buffer)), \ -s = pb_ostream_from_buffer(buffer, sizeof(buffer)), \ -(x) && \ -memcmp(buffer, y, sizeof(y) - 1) == 0 && \ -buffer[sizeof(y) - 1] == 0xAA - -int main() -{ - int status = 0; - - { - uint8_t buffer1[] = "foobartest1234"; - uint8_t buffer2[sizeof(buffer1)]; - pb_ostream_t stream = pb_ostream_from_buffer(buffer2, sizeof(buffer1)); - - COMMENT("Test pb_write and pb_ostream_t"); - TEST(pb_write(&stream, buffer1, sizeof(buffer1))); - TEST(memcmp(buffer1, buffer2, sizeof(buffer1)) == 0); - TEST(!pb_write(&stream, buffer1, 1)); - TEST(stream.bytes_written == sizeof(buffer1)); - } - - { - uint8_t buffer1[] = "xxxxxxx"; - pb_ostream_t stream = {&streamcallback, 0, SIZE_MAX, 0}; - - COMMENT("Test pb_write with custom callback"); - TEST(pb_write(&stream, buffer1, 5)); - buffer1[0] = 'a'; - TEST(!pb_write(&stream, buffer1, 5)); - } - - { - uint8_t buffer[30]; - pb_ostream_t s; - - COMMENT("Test pb_encode_varint") - TEST(WRITES(pb_encode_varint(&s, 0), "\0")); - TEST(WRITES(pb_encode_varint(&s, 1), "\1")); - TEST(WRITES(pb_encode_varint(&s, 0x7F), "\x7F")); - TEST(WRITES(pb_encode_varint(&s, 0x80), "\x80\x01")); - TEST(WRITES(pb_encode_varint(&s, UINT32_MAX), "\xFF\xFF\xFF\xFF\x0F")); - TEST(WRITES(pb_encode_varint(&s, UINT64_MAX), "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x01")); - } - - { - uint8_t buffer[30]; - pb_ostream_t s; - - COMMENT("Test pb_encode_tag") - TEST(WRITES(pb_encode_tag(&s, PB_WT_STRING, 5), "\x2A")); - TEST(WRITES(pb_encode_tag(&s, PB_WT_VARINT, 99), "\x98\x06")); - } - - { - uint8_t buffer[30]; - pb_ostream_t s; - pb_field_t field = {10, PB_LTYPE_SVARINT}; - - COMMENT("Test pb_encode_tag_for_field") - TEST(WRITES(pb_encode_tag_for_field(&s, &field), "\x50")); - - field.type = PB_LTYPE_FIXED64; - TEST(WRITES(pb_encode_tag_for_field(&s, &field), "\x51")); - - field.type = PB_LTYPE_STRING; - TEST(WRITES(pb_encode_tag_for_field(&s, &field), "\x52")); - - field.type = PB_LTYPE_FIXED32; - TEST(WRITES(pb_encode_tag_for_field(&s, &field), "\x55")); - } - - { - uint8_t buffer[30]; - pb_ostream_t s; - - COMMENT("Test pb_encode_string") - TEST(WRITES(pb_encode_string(&s, (const uint8_t*)"abcd", 4), "\x04""abcd")); - TEST(WRITES(pb_encode_string(&s, (const uint8_t*)"abcd\x00", 5), "\x05""abcd\x00")); - TEST(WRITES(pb_encode_string(&s, (const uint8_t*)"", 0), "\x00")); - } - - { - uint8_t buffer[30]; - pb_ostream_t s; - uint8_t value = 1; - int32_t max = INT32_MAX; - int32_t min = INT32_MIN; - int64_t lmax = INT64_MAX; - int64_t lmin = INT64_MIN; - pb_field_t field = {1, PB_LTYPE_VARINT, 0, 0, sizeof(value)}; - - COMMENT("Test pb_enc_varint and pb_enc_svarint") - TEST(WRITES(pb_enc_varint(&s, &field, &value), "\x01")); - - field.data_size = sizeof(max); - TEST(WRITES(pb_enc_svarint(&s, &field, &max), "\xfe\xff\xff\xff\x0f")); - TEST(WRITES(pb_enc_svarint(&s, &field, &min), "\xff\xff\xff\xff\x0f")); - - field.data_size = sizeof(lmax); - TEST(WRITES(pb_enc_svarint(&s, &field, &lmax), "\xFE\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x01")); - TEST(WRITES(pb_enc_svarint(&s, &field, &lmin), "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x01")); - } - - { - uint8_t buffer[30]; - pb_ostream_t s; - float fvalue; - double dvalue; - - COMMENT("Test pb_enc_fixed32 using float") - fvalue = 0.0f; - TEST(WRITES(pb_enc_fixed32(&s, NULL, &fvalue), "\x00\x00\x00\x00")) - fvalue = 99.0f; - TEST(WRITES(pb_enc_fixed32(&s, NULL, &fvalue), "\x00\x00\xc6\x42")) - fvalue = -12345678.0f; - TEST(WRITES(pb_enc_fixed32(&s, NULL, &fvalue), "\x4e\x61\x3c\xcb")) - - COMMENT("Test pb_enc_fixed64 using double") - dvalue = 0.0; - TEST(WRITES(pb_enc_fixed64(&s, NULL, &dvalue), "\x00\x00\x00\x00\x00\x00\x00\x00")) - dvalue = 99.0; - TEST(WRITES(pb_enc_fixed64(&s, NULL, &dvalue), "\x00\x00\x00\x00\x00\xc0\x58\x40")) - dvalue = -12345678.0; - TEST(WRITES(pb_enc_fixed64(&s, NULL, &dvalue), "\x00\x00\x00\xc0\x29\x8c\x67\xc1")) - } - - { - uint8_t buffer[30]; - pb_ostream_t s; - struct { pb_size_t size; uint8_t bytes[5]; } value = {5, {'x', 'y', 'z', 'z', 'y'}}; - - COMMENT("Test pb_enc_bytes") - TEST(WRITES(pb_enc_bytes(&s, &BytesMessage_fields[0], &value), "\x05xyzzy")) - value.size = 0; - TEST(WRITES(pb_enc_bytes(&s, &BytesMessage_fields[0], &value), "\x00")) - } - - { - uint8_t buffer[30]; - pb_ostream_t s; - char value[30] = "xyzzy"; - - COMMENT("Test pb_enc_string") - TEST(WRITES(pb_enc_string(&s, &StringMessage_fields[0], &value), "\x05xyzzy")) - value[0] = '\0'; - TEST(WRITES(pb_enc_string(&s, &StringMessage_fields[0], &value), "\x00")) - memset(value, 'x', 30); - TEST(WRITES(pb_enc_string(&s, &StringMessage_fields[0], &value), "\x0Axxxxxxxxxx")) - } - - { - uint8_t buffer[10]; - pb_ostream_t s; - IntegerArray msg = {5, {1, 2, 3, 4, 5}}; - - COMMENT("Test pb_encode with int32 array") - - TEST(WRITES(pb_encode(&s, IntegerArray_fields, &msg), "\x0A\x05\x01\x02\x03\x04\x05")) - - msg.data_count = 0; - TEST(WRITES(pb_encode(&s, IntegerArray_fields, &msg), "")) - - msg.data_count = 10; - TEST(!pb_encode(&s, IntegerArray_fields, &msg)) - } - - { - uint8_t buffer[10]; - pb_ostream_t s; - FloatArray msg = {1, {99.0f}}; - - COMMENT("Test pb_encode with float array") - - TEST(WRITES(pb_encode(&s, FloatArray_fields, &msg), - "\x0A\x04\x00\x00\xc6\x42")) - - msg.data_count = 0; - TEST(WRITES(pb_encode(&s, FloatArray_fields, &msg), "")) - - msg.data_count = 3; - TEST(!pb_encode(&s, FloatArray_fields, &msg)) - } - - { - uint8_t buffer[50]; - pb_ostream_t s; - FloatArray msg = {1, {99.0f}}; - - COMMENT("Test array size limit in pb_encode") - - s = pb_ostream_from_buffer(buffer, sizeof(buffer)); - TEST((msg.data_count = 10) && pb_encode(&s, FloatArray_fields, &msg)) - - s = pb_ostream_from_buffer(buffer, sizeof(buffer)); - TEST((msg.data_count = 11) && !pb_encode(&s, FloatArray_fields, &msg)) - } - - { - uint8_t buffer[10]; - pb_ostream_t s; - CallbackArray msg; - - msg.data.funcs.encode = &fieldcallback; - - COMMENT("Test pb_encode with callback field.") - TEST(WRITES(pb_encode(&s, CallbackArray_fields, &msg), "\x08\x55")) - } - - { - uint8_t buffer[10]; - pb_ostream_t s; - IntegerContainer msg = {{5, {1,2,3,4,5}}}; - - COMMENT("Test pb_encode with packed array in a submessage.") - TEST(WRITES(pb_encode(&s, IntegerContainer_fields, &msg), - "\x0A\x07\x0A\x05\x01\x02\x03\x04\x05")) - } - - { - uint8_t buffer[32]; - pb_ostream_t s; - BytesMessage msg = {{3, "xyz"}}; - - COMMENT("Test pb_encode with bytes message.") - TEST(WRITES(pb_encode(&s, BytesMessage_fields, &msg), - "\x0A\x03xyz")) - - msg.data.size = 17; /* More than maximum */ - TEST(!pb_encode(&s, BytesMessage_fields, &msg)) - } - - - { - uint8_t buffer[20]; - pb_ostream_t s; - IntegerContainer msg = {{5, {1,2,3,4,5}}}; - - COMMENT("Test pb_encode_delimited.") - TEST(WRITES(pb_encode_delimited(&s, IntegerContainer_fields, &msg), - "\x09\x0A\x07\x0A\x05\x01\x02\x03\x04\x05")) - } - - { - IntegerContainer msg = {{5, {1,2,3,4,5}}}; - size_t size; - - COMMENT("Test pb_get_encoded_size.") - TEST(pb_get_encoded_size(&size, IntegerContainer_fields, &msg) && - size == 9); - } - - { - uint8_t buffer[10]; - pb_ostream_t s; - CallbackContainer msg; - CallbackContainerContainer msg2; - uint32_t state = 1; - - msg.submsg.data.funcs.encode = &fieldcallback; - msg2.submsg.submsg.data.funcs.encode = &fieldcallback; - - COMMENT("Test pb_encode with callback field in a submessage.") - TEST(WRITES(pb_encode(&s, CallbackContainer_fields, &msg), "\x0A\x02\x08\x55")) - TEST(WRITES(pb_encode(&s, CallbackContainerContainer_fields, &msg2), - "\x0A\x04\x0A\x02\x08\x55")) - - /* Misbehaving callback: varying output between calls */ - msg.submsg.data.funcs.encode = &crazyfieldcallback; - msg.submsg.data.arg = &state; - msg2.submsg.submsg.data.funcs.encode = &crazyfieldcallback; - msg2.submsg.submsg.data.arg = &state; - - TEST(!pb_encode(&s, CallbackContainer_fields, &msg)) - state = 1; - TEST(!pb_encode(&s, CallbackContainerContainer_fields, &msg2)) - } - - { - uint8_t buffer[StringMessage_size]; - pb_ostream_t s; - StringMessage msg = {"0123456789"}; - - s = pb_ostream_from_buffer(buffer, sizeof(buffer)); - - COMMENT("Test that StringMessage_size is correct") - - TEST(pb_encode(&s, StringMessage_fields, &msg)); - TEST(s.bytes_written == StringMessage_size); - } - - { - uint8_t buffer[128]; - pb_ostream_t s; - StringPointerContainer msg = StringPointerContainer_init_zero; - char *strs[1] = {NULL}; - char zstr[] = "Z"; - - COMMENT("Test string pointer encoding."); - - msg.rep_str = strs; - msg.rep_str_count = 1; - TEST(WRITES(pb_encode(&s, StringPointerContainer_fields, &msg), "\x0a\x00")) - - strs[0] = zstr; - TEST(WRITES(pb_encode(&s, StringPointerContainer_fields, &msg), "\x0a\x01Z")) - } - - if (status != 0) - fprintf(stdout, "\n\nSome tests FAILED!\n"); - - return status; -} diff --git a/third_party/nanopb/tests/enum_sizes/SConscript b/third_party/nanopb/tests/enum_sizes/SConscript deleted file mode 100644 index 048592ed838..00000000000 --- a/third_party/nanopb/tests/enum_sizes/SConscript +++ /dev/null @@ -1,12 +0,0 @@ -# Test that different sizes of enum fields are properly encoded and decoded. - -Import('env') - -env.NanopbProto('enumsizes') - -p = env.Program(["enumsizes_unittests.c", - "enumsizes.pb.c", - "$COMMON/pb_encode.o", - "$COMMON/pb_decode.o", - "$COMMON/pb_common.o"]) -env.RunTest(p) diff --git a/third_party/nanopb/tests/enum_sizes/enumsizes.proto b/third_party/nanopb/tests/enum_sizes/enumsizes.proto deleted file mode 100644 index a85d4160135..00000000000 --- a/third_party/nanopb/tests/enum_sizes/enumsizes.proto +++ /dev/null @@ -1,86 +0,0 @@ -/* Test handling of enums with different value ranges. - * Depending on compiler and the packed_enum setting, the datatypes - * for enums can be either signed or unsigned. In past this has caused - * a bit of a problem for the encoder/decoder (issue #164). - */ - -syntax = "proto2"; - -import 'nanopb.proto'; - -option (nanopb_fileopt).long_names = false; - -enum UnpackedUint8 { - option (nanopb_enumopt).packed_enum = false; - UU8_MIN = 0; - UU8_MAX = 255; -} - -enum PackedUint8 { - option (nanopb_enumopt).packed_enum = true; - PU8_MIN = 0; - PU8_MAX = 255; -} - -enum UnpackedInt8 { - option (nanopb_enumopt).packed_enum = false; - UI8_MIN = -128; - UI8_MAX = 127; -} - -enum PackedInt8 { - option (nanopb_enumopt).packed_enum = true; - PI8_MIN = -128; - PI8_MAX = 127; -} - -enum UnpackedUint16 { - option (nanopb_enumopt).packed_enum = false; - UU16_MIN = 0; - UU16_MAX = 65535; -} - -enum PackedUint16 { - option (nanopb_enumopt).packed_enum = true; - PU16_MIN = 0; - PU16_MAX = 65535; -} - -enum UnpackedInt16 { - option (nanopb_enumopt).packed_enum = false; - UI16_MIN = -32768; - UI16_MAX = 32767; -} - -enum PackedInt16 { - option (nanopb_enumopt).packed_enum = true; - PI16_MIN = -32768; - PI16_MAX = 32767; -} - -/* Protobuf supports enums up to 32 bits. - * The 32 bit case is covered by HugeEnum in the alltypes test. - */ - -message PackedEnums { - required PackedUint8 u8_min = 1; - required PackedUint8 u8_max = 2; - required PackedInt8 i8_min = 3; - required PackedInt8 i8_max = 4; - required PackedUint16 u16_min = 5; - required PackedUint16 u16_max = 6; - required PackedInt16 i16_min = 7; - required PackedInt16 i16_max = 8; -} - -message UnpackedEnums { - required UnpackedUint8 u8_min = 1; - required UnpackedUint8 u8_max = 2; - required UnpackedInt8 i8_min = 3; - required UnpackedInt8 i8_max = 4; - required UnpackedUint16 u16_min = 5; - required UnpackedUint16 u16_max = 6; - required UnpackedInt16 i16_min = 7; - required UnpackedInt16 i16_max = 8; -} - diff --git a/third_party/nanopb/tests/enum_sizes/enumsizes_unittests.c b/third_party/nanopb/tests/enum_sizes/enumsizes_unittests.c deleted file mode 100644 index 5606895a66a..00000000000 --- a/third_party/nanopb/tests/enum_sizes/enumsizes_unittests.c +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include -#include -#include -#include "unittests.h" -#include "enumsizes.pb.h" - -int main() -{ - int status = 0; - - UnpackedEnums msg1 = { - UU8_MIN, UU8_MAX, - UI8_MIN, UI8_MAX, - UU16_MIN, UU16_MAX, - UI16_MIN, UI16_MAX, - }; - - PackedEnums msg2; - UnpackedEnums msg3; - uint8_t buf[256]; - size_t msgsize; - - COMMENT("Step 1: unpacked enums -> protobuf"); - { - pb_ostream_t s = pb_ostream_from_buffer(buf, sizeof(buf)); - TEST(pb_encode(&s, UnpackedEnums_fields, &msg1)); - msgsize = s.bytes_written; - } - - COMMENT("Step 2: protobuf -> packed enums"); - { - pb_istream_t s = pb_istream_from_buffer(buf, msgsize); - TEST(pb_decode(&s, PackedEnums_fields, &msg2)); - - TEST(msg1.u8_min == (int)msg2.u8_min); - TEST(msg1.u8_max == (int)msg2.u8_max); - TEST(msg1.i8_min == (int)msg2.i8_min); - TEST(msg1.i8_max == (int)msg2.i8_max); - TEST(msg1.u16_min == (int)msg2.u16_min); - TEST(msg1.u16_max == (int)msg2.u16_max); - TEST(msg1.i16_min == (int)msg2.i16_min); - TEST(msg1.i16_max == (int)msg2.i16_max); - } - - COMMENT("Step 3: packed enums -> protobuf"); - { - pb_ostream_t s = pb_ostream_from_buffer(buf, sizeof(buf)); - TEST(pb_encode(&s, PackedEnums_fields, &msg2)); - msgsize = s.bytes_written; - } - - COMMENT("Step 4: protobuf -> unpacked enums"); - { - pb_istream_t s = pb_istream_from_buffer(buf, msgsize); - TEST(pb_decode(&s, UnpackedEnums_fields, &msg3)); - - TEST(msg1.u8_min == (int)msg3.u8_min); - TEST(msg1.u8_max == (int)msg3.u8_max); - TEST(msg1.i8_min == (int)msg3.i8_min); - TEST(msg1.i8_max == (int)msg3.i8_max); - TEST(msg1.u16_min == (int)msg2.u16_min); - TEST(msg1.u16_max == (int)msg2.u16_max); - TEST(msg1.i16_min == (int)msg2.i16_min); - TEST(msg1.i16_max == (int)msg2.i16_max); - } - - if (status != 0) - fprintf(stdout, "\n\nSome tests FAILED!\n"); - - return status; -} diff --git a/third_party/nanopb/tests/extensions/SConscript b/third_party/nanopb/tests/extensions/SConscript deleted file mode 100644 index a2c87428289..00000000000 --- a/third_party/nanopb/tests/extensions/SConscript +++ /dev/null @@ -1,16 +0,0 @@ -# Test the support for extension fields. - -Import("env") - -# We use the files from the alltypes test case -incpath = env.Clone() -incpath.Append(PROTOCPATH = '$BUILD/alltypes') -incpath.Append(CPPPATH = '$BUILD/alltypes') - -incpath.NanopbProto(["extensions", "extensions.options"]) -enc = incpath.Program(["encode_extensions.c", "extensions.pb.c", "$BUILD/alltypes/alltypes.pb$OBJSUFFIX", "$COMMON/pb_encode.o", "$COMMON/pb_common.o"]) -dec = incpath.Program(["decode_extensions.c", "extensions.pb.c", "$BUILD/alltypes/alltypes.pb$OBJSUFFIX", "$COMMON/pb_decode.o", "$COMMON/pb_common.o"]) - -env.RunTest(enc) -env.RunTest([dec, "encode_extensions.output"]) - diff --git a/third_party/nanopb/tests/extensions/decode_extensions.c b/third_party/nanopb/tests/extensions/decode_extensions.c deleted file mode 100644 index e43743804ad..00000000000 --- a/third_party/nanopb/tests/extensions/decode_extensions.c +++ /dev/null @@ -1,60 +0,0 @@ -/* Test decoding of extension fields. */ - -#include -#include -#include -#include -#include "alltypes.pb.h" -#include "extensions.pb.h" -#include "test_helpers.h" - -#define TEST(x) if (!(x)) { \ - printf("Test " #x " failed.\n"); \ - return 2; \ - } - -int main(int argc, char **argv) -{ - uint8_t buffer[1024]; - size_t count; - pb_istream_t stream; - - AllTypes alltypes = {0}; - int32_t extensionfield1; - pb_extension_t ext1; - ExtensionMessage extensionfield2; - pb_extension_t ext2; - - /* Read the message data */ - SET_BINARY_MODE(stdin); - count = fread(buffer, 1, sizeof(buffer), stdin); - stream = pb_istream_from_buffer(buffer, count); - - /* Add the extensions */ - alltypes.extensions = &ext1; - - ext1.type = &AllTypes_extensionfield1; - ext1.dest = &extensionfield1; - ext1.next = &ext2; - - ext2.type = &ExtensionMessage_AllTypes_extensionfield2; - ext2.dest = &extensionfield2; - ext2.next = NULL; - - /* Decode the message */ - if (!pb_decode(&stream, AllTypes_fields, &alltypes)) - { - printf("Parsing failed: %s\n", PB_GET_ERROR(&stream)); - return 1; - } - - /* Check that the extensions decoded properly */ - TEST(ext1.found) - TEST(extensionfield1 == 12345) - TEST(ext2.found) - TEST(strcmp(extensionfield2.test1, "test") == 0) - TEST(extensionfield2.test2 == 54321) - - return 0; -} - diff --git a/third_party/nanopb/tests/extensions/encode_extensions.c b/third_party/nanopb/tests/extensions/encode_extensions.c deleted file mode 100644 index 00745826f4d..00000000000 --- a/third_party/nanopb/tests/extensions/encode_extensions.c +++ /dev/null @@ -1,54 +0,0 @@ -/* Tests extension fields. - */ - -#include -#include -#include -#include -#include "alltypes.pb.h" -#include "extensions.pb.h" -#include "test_helpers.h" - -int main(int argc, char **argv) -{ - uint8_t buffer[1024]; - pb_ostream_t stream; - - AllTypes alltypes = {0}; - int32_t extensionfield1 = 12345; - pb_extension_t ext1; - ExtensionMessage extensionfield2 = {"test", 54321}; - pb_extension_t ext2; - - /* Set up the extensions */ - alltypes.extensions = &ext1; - - ext1.type = &AllTypes_extensionfield1; - ext1.dest = &extensionfield1; - ext1.next = &ext2; - - ext2.type = &ExtensionMessage_AllTypes_extensionfield2; - ext2.dest = &extensionfield2; - ext2.next = NULL; - - /* Set up the output stream */ - stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - - /* Now encode the message and check if we succeeded. */ - if (pb_encode(&stream, AllTypes_fields, &alltypes)) - { - SET_BINARY_MODE(stdout); - fwrite(buffer, 1, stream.bytes_written, stdout); - return 0; /* Success */ - } - else - { - fprintf(stderr, "Encoding failed: %s\n", PB_GET_ERROR(&stream)); - return 1; /* Failure */ - } - - /* Check that the field tags are properly generated */ - (void)AllTypes_extensionfield1_tag; - (void)ExtensionMessage_AllTypes_extensionfield2_tag; -} - diff --git a/third_party/nanopb/tests/extensions/extensions.options b/third_party/nanopb/tests/extensions/extensions.options deleted file mode 100644 index a5cd61dd35b..00000000000 --- a/third_party/nanopb/tests/extensions/extensions.options +++ /dev/null @@ -1 +0,0 @@ -* max_size:16 diff --git a/third_party/nanopb/tests/extensions/extensions.proto b/third_party/nanopb/tests/extensions/extensions.proto deleted file mode 100644 index fcd5b43bdbd..00000000000 --- a/third_party/nanopb/tests/extensions/extensions.proto +++ /dev/null @@ -1,19 +0,0 @@ -syntax = "proto2"; - -import 'alltypes.proto'; - -extend AllTypes { - optional int32 AllTypes_extensionfield1 = 255 [default = 5]; -} - -message ExtensionMessage { - extend AllTypes { - optional ExtensionMessage AllTypes_extensionfield2 = 254; - // required ExtensionMessage AllTypes_extensionfield3 = 253; // No longer allowed by protobuf 3 - repeated ExtensionMessage AllTypes_extensionfield4 = 252; - } - - required string test1 = 1; - required int32 test2 = 2; -} - diff --git a/third_party/nanopb/tests/extra_fields/SConscript b/third_party/nanopb/tests/extra_fields/SConscript deleted file mode 100644 index 75ac5c5e761..00000000000 --- a/third_party/nanopb/tests/extra_fields/SConscript +++ /dev/null @@ -1,16 +0,0 @@ -# Test that the decoder properly handles unknown fields in the input. - -Import("env") - -dec = env.GetBuildPath('$BUILD/basic_buffer/${PROGPREFIX}decode_buffer${PROGSUFFIX}') -env.RunTest('person_with_extra_field.output', [dec, "person_with_extra_field.pb"]) -env.Compare(["person_with_extra_field.output", "person_with_extra_field.expected"]) - -dec = env.GetBuildPath('$BUILD/basic_stream/${PROGPREFIX}decode_stream${PROGSUFFIX}') -env.RunTest('person_with_extra_field_stream.output', [dec, "person_with_extra_field.pb"]) -env.Compare(["person_with_extra_field_stream.output", "person_with_extra_field.expected"]) - -# This uses the backwards compatibility alltypes test, so that -# alltypes_with_extra_fields.pb doesn't have to be remade so often. -dec2 = env.GetBuildPath('$BUILD/backwards_compatibility/${PROGPREFIX}decode_legacy${PROGSUFFIX}') -env.RunTest('alltypes_with_extra_fields.output', [dec2, 'alltypes_with_extra_fields.pb']) diff --git a/third_party/nanopb/tests/extra_fields/person_with_extra_field.expected b/third_party/nanopb/tests/extra_fields/person_with_extra_field.expected deleted file mode 100644 index da9c32df655..00000000000 --- a/third_party/nanopb/tests/extra_fields/person_with_extra_field.expected +++ /dev/null @@ -1,14 +0,0 @@ -name: "Test Person 99" -id: 99 -email: "test@person.com" -phone { - number: "555-12345678" - type: MOBILE -} -phone { - number: "99-2342" -} -phone { - number: "1234-5678" - type: WORK -} diff --git a/third_party/nanopb/tests/field_size_16/SConscript b/third_party/nanopb/tests/field_size_16/SConscript deleted file mode 100644 index ffb29c4e1a3..00000000000 --- a/third_party/nanopb/tests/field_size_16/SConscript +++ /dev/null @@ -1,29 +0,0 @@ -# Run the alltypes test case, but compile with PB_FIELD_16BIT=1. -# Also the .proto file has been modified to have high indexes. - -Import("env") - -# Take copy of the files for custom build. -c = Copy("$TARGET", "$SOURCE") -env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c) -env.Command("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c) - -env.NanopbProto(["alltypes", "alltypes.options"]) - -# Define the compilation options -opts = env.Clone() -opts.Append(CPPDEFINES = {'PB_FIELD_16BIT': 1}) - -# Build new version of core -strict = opts.Clone() -strict.Append(CFLAGS = strict['CORECFLAGS']) -strict.Object("pb_decode_fields16.o", "$NANOPB/pb_decode.c") -strict.Object("pb_encode_fields16.o", "$NANOPB/pb_encode.c") -strict.Object("pb_common_fields16.o", "$NANOPB/pb_common.c") - -# Now build and run the test normally. -enc = opts.Program(["encode_alltypes.c", "alltypes.pb.c", "pb_encode_fields16.o", "pb_common_fields16.o"]) -dec = opts.Program(["decode_alltypes.c", "alltypes.pb.c", "pb_decode_fields16.o", "pb_common_fields16.o"]) - -env.RunTest(enc) -env.RunTest([dec, "encode_alltypes.output"]) diff --git a/third_party/nanopb/tests/field_size_16/alltypes.options b/third_party/nanopb/tests/field_size_16/alltypes.options deleted file mode 100644 index b31e3cf0a9d..00000000000 --- a/third_party/nanopb/tests/field_size_16/alltypes.options +++ /dev/null @@ -1,3 +0,0 @@ -* max_size:16 -* max_count:5 - diff --git a/third_party/nanopb/tests/field_size_16/alltypes.proto b/third_party/nanopb/tests/field_size_16/alltypes.proto deleted file mode 100644 index ba1ec383c9a..00000000000 --- a/third_party/nanopb/tests/field_size_16/alltypes.proto +++ /dev/null @@ -1,121 +0,0 @@ -syntax = "proto2"; - -message SubMessage { - required string substuff1 = 1 [default = "1"]; - required int32 substuff2 = 2 [default = 2]; - optional fixed32 substuff3 = 65535 [default = 3]; -} - -message EmptyMessage { - -} - -enum HugeEnum { - Negative = -2147483647; /* protoc doesn't accept -2147483648 here */ - Positive = 2147483647; -} - -message Limits { - required int32 int32_min = 1; - required int32 int32_max = 2; - required uint32 uint32_min = 3; - required uint32 uint32_max = 4; - required int64 int64_min = 5; - required int64 int64_max = 6; - required uint64 uint64_min = 7; - required uint64 uint64_max = 8; - required HugeEnum enum_min = 9; - required HugeEnum enum_max = 10; -} - -enum MyEnum { - Zero = 0; - First = 1; - Second = 2; - Truth = 42; -} - -message AllTypes { - required int32 req_int32 = 1; - required int64 req_int64 = 2; - required uint32 req_uint32 = 3; - required uint64 req_uint64 = 4; - required sint32 req_sint32 = 5; - required sint64 req_sint64 = 6; - required bool req_bool = 7; - - required fixed32 req_fixed32 = 8; - required sfixed32 req_sfixed32= 9; - required float req_float = 10; - - required fixed64 req_fixed64 = 11; - required sfixed64 req_sfixed64= 12; - required double req_double = 13; - - required string req_string = 14; - required bytes req_bytes = 15; - required SubMessage req_submsg = 16; - required MyEnum req_enum = 17; - required EmptyMessage req_emptymsg = 18; - - - repeated int32 rep_int32 = 21; - repeated int64 rep_int64 = 22; - repeated uint32 rep_uint32 = 23; - repeated uint64 rep_uint64 = 24; - repeated sint32 rep_sint32 = 25; - repeated sint64 rep_sint64 = 26; - repeated bool rep_bool = 27; - - repeated fixed32 rep_fixed32 = 28; - repeated sfixed32 rep_sfixed32= 29; - repeated float rep_float = 30; - - repeated fixed64 rep_fixed64 = 10031; - repeated sfixed64 rep_sfixed64= 10032; - repeated double rep_double = 10033; - - repeated string rep_string = 10034; - repeated bytes rep_bytes = 10035; - repeated SubMessage rep_submsg = 10036; - repeated MyEnum rep_enum = 10037; - repeated EmptyMessage rep_emptymsg = 10038; - - optional int32 opt_int32 = 10041 [default = 4041]; - optional int64 opt_int64 = 10042 [default = 4042]; - optional uint32 opt_uint32 = 10043 [default = 4043]; - optional uint64 opt_uint64 = 10044 [default = 4044]; - optional sint32 opt_sint32 = 10045 [default = 4045]; - optional sint64 opt_sint64 = 10046 [default = 4046]; - optional bool opt_bool = 10047 [default = false]; - - optional fixed32 opt_fixed32 = 10048 [default = 4048]; - optional sfixed32 opt_sfixed32= 10049 [default = 4049]; - optional float opt_float = 10050 [default = 4050]; - - optional fixed64 opt_fixed64 = 10051 [default = 4051]; - optional sfixed64 opt_sfixed64= 10052 [default = 4052]; - optional double opt_double = 10053 [default = 4053]; - - optional string opt_string = 10054 [default = "4054"]; - optional bytes opt_bytes = 10055 [default = "4055"]; - optional SubMessage opt_submsg = 10056; - optional MyEnum opt_enum = 10057 [default = Second]; - optional EmptyMessage opt_emptymsg = 10058; - - oneof oneof - { - SubMessage oneof_msg1 = 10059; - EmptyMessage oneof_msg2 = 10060; - } - - // Check that extreme integer values are handled correctly - required Limits req_limits = 98; - - // Just to make sure that the size of the fields has been calculated - // properly, i.e. otherwise a bug in last field might not be detected. - required int32 end = 10099; - - extensions 200 to 255; -} - diff --git a/third_party/nanopb/tests/field_size_32/SConscript b/third_party/nanopb/tests/field_size_32/SConscript deleted file mode 100644 index 0b8dc0e3a6b..00000000000 --- a/third_party/nanopb/tests/field_size_32/SConscript +++ /dev/null @@ -1,29 +0,0 @@ -# Run the alltypes test case, but compile with PB_FIELD_32BIT=1. -# Also the .proto file has been modified to have high indexes. - -Import("env") - -# Take copy of the files for custom build. -c = Copy("$TARGET", "$SOURCE") -env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c) -env.Command("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c) - -env.NanopbProto(["alltypes", "alltypes.options"]) - -# Define the compilation options -opts = env.Clone() -opts.Append(CPPDEFINES = {'PB_FIELD_32BIT': 1}) - -# Build new version of core -strict = opts.Clone() -strict.Append(CFLAGS = strict['CORECFLAGS']) -strict.Object("pb_decode_fields32.o", "$NANOPB/pb_decode.c") -strict.Object("pb_encode_fields32.o", "$NANOPB/pb_encode.c") -strict.Object("pb_common_fields32.o", "$NANOPB/pb_common.c") - -# Now build and run the test normally. -enc = opts.Program(["encode_alltypes.c", "alltypes.pb.c", "pb_encode_fields32.o", "pb_common_fields32.o"]) -dec = opts.Program(["decode_alltypes.c", "alltypes.pb.c", "pb_decode_fields32.o", "pb_common_fields32.o"]) - -env.RunTest(enc) -env.RunTest([dec, "encode_alltypes.output"]) diff --git a/third_party/nanopb/tests/field_size_32/alltypes.options b/third_party/nanopb/tests/field_size_32/alltypes.options deleted file mode 100644 index b31e3cf0a9d..00000000000 --- a/third_party/nanopb/tests/field_size_32/alltypes.options +++ /dev/null @@ -1,3 +0,0 @@ -* max_size:16 -* max_count:5 - diff --git a/third_party/nanopb/tests/field_size_32/alltypes.proto b/third_party/nanopb/tests/field_size_32/alltypes.proto deleted file mode 100644 index 02ee1a6a7fd..00000000000 --- a/third_party/nanopb/tests/field_size_32/alltypes.proto +++ /dev/null @@ -1,121 +0,0 @@ -syntax = "proto2"; - -message SubMessage { - required string substuff1 = 1 [default = "1"]; - required int32 substuff2 = 2 [default = 2]; - optional fixed32 substuff3 = 12365535 [default = 3]; -} - -message EmptyMessage { - -} - -enum HugeEnum { - Negative = -2147483647; /* protoc doesn't accept -2147483648 here */ - Positive = 2147483647; -} - -message Limits { - required int32 int32_min = 1; - required int32 int32_max = 2; - required uint32 uint32_min = 3; - required uint32 uint32_max = 4; - required int64 int64_min = 5; - required int64 int64_max = 6; - required uint64 uint64_min = 7; - required uint64 uint64_max = 8; - required HugeEnum enum_min = 9; - required HugeEnum enum_max = 10; -} - -enum MyEnum { - Zero = 0; - First = 1; - Second = 2; - Truth = 42; -} - -message AllTypes { - required int32 req_int32 = 1; - required int64 req_int64 = 2; - required uint32 req_uint32 = 3; - required uint64 req_uint64 = 4; - required sint32 req_sint32 = 5; - required sint64 req_sint64 = 6; - required bool req_bool = 7; - - required fixed32 req_fixed32 = 8; - required sfixed32 req_sfixed32= 9; - required float req_float = 10; - - required fixed64 req_fixed64 = 11; - required sfixed64 req_sfixed64= 12; - required double req_double = 13; - - required string req_string = 14; - required bytes req_bytes = 15; - required SubMessage req_submsg = 16; - required MyEnum req_enum = 17; - required EmptyMessage req_emptymsg = 18; - - - repeated int32 rep_int32 = 21; - repeated int64 rep_int64 = 22; - repeated uint32 rep_uint32 = 23; - repeated uint64 rep_uint64 = 24; - repeated sint32 rep_sint32 = 25; - repeated sint64 rep_sint64 = 26; - repeated bool rep_bool = 27; - - repeated fixed32 rep_fixed32 = 28; - repeated sfixed32 rep_sfixed32= 29; - repeated float rep_float = 30; - - repeated fixed64 rep_fixed64 = 10031; - repeated sfixed64 rep_sfixed64= 10032; - repeated double rep_double = 10033; - - repeated string rep_string = 10034; - repeated bytes rep_bytes = 10035; - repeated SubMessage rep_submsg = 10036; - repeated MyEnum rep_enum = 10037; - repeated EmptyMessage rep_emptymsg = 10038; - - optional int32 opt_int32 = 10041 [default = 4041]; - optional int64 opt_int64 = 10042 [default = 4042]; - optional uint32 opt_uint32 = 10043 [default = 4043]; - optional uint64 opt_uint64 = 10044 [default = 4044]; - optional sint32 opt_sint32 = 10045 [default = 4045]; - optional sint64 opt_sint64 = 10046 [default = 4046]; - optional bool opt_bool = 10047 [default = false]; - - optional fixed32 opt_fixed32 = 10048 [default = 4048]; - optional sfixed32 opt_sfixed32= 10049 [default = 4049]; - optional float opt_float = 10050 [default = 4050]; - - optional fixed64 opt_fixed64 = 10051 [default = 4051]; - optional sfixed64 opt_sfixed64= 10052 [default = 4052]; - optional double opt_double = 10053 [default = 4053]; - - optional string opt_string = 10054 [default = "4054"]; - optional bytes opt_bytes = 10055 [default = "4055"]; - optional SubMessage opt_submsg = 10056; - optional MyEnum opt_enum = 10057 [default = Second]; - optional EmptyMessage opt_emptymsg = 10058; - - oneof oneof - { - SubMessage oneof_msg1 = 10059; - EmptyMessage oneof_msg2 = 10060; - } - - // Check that extreme integer values are handled correctly - required Limits req_limits = 98; - - // Just to make sure that the size of the fields has been calculated - // properly, i.e. otherwise a bug in last field might not be detected. - required int32 end = 13432099; - - extensions 200 to 255; -} - diff --git a/third_party/nanopb/tests/fuzztest/SConscript b/third_party/nanopb/tests/fuzztest/SConscript deleted file mode 100644 index d2fb689c39f..00000000000 --- a/third_party/nanopb/tests/fuzztest/SConscript +++ /dev/null @@ -1,43 +0,0 @@ -# Run a fuzz test to verify robustness against corrupted/malicious data. - -Import("env", "malloc_env") - -def set_pkgname(src, dst, pkgname): - data = open(str(src)).read() - placeholder = '// package name placeholder' - assert placeholder in data - data = data.replace(placeholder, 'package %s;' % pkgname) - open(str(dst), 'w').write(data) - -# We want both pointer and static versions of the AllTypes message -# Prefix them with package name. -env.Command("alltypes_static.proto", "#alltypes/alltypes.proto", - lambda target, source, env: set_pkgname(source[0], target[0], 'alltypes_static')) -env.Command("alltypes_pointer.proto", "#alltypes/alltypes.proto", - lambda target, source, env: set_pkgname(source[0], target[0], 'alltypes_pointer')) - -p1 = env.NanopbProto(["alltypes_pointer", "alltypes_pointer.options"]) -p2 = env.NanopbProto(["alltypes_static", "alltypes_static.options"]) -fuzz = malloc_env.Program(["fuzztest.c", - "alltypes_pointer.pb.c", - "alltypes_static.pb.c", - "$COMMON/pb_encode_with_malloc.o", - "$COMMON/pb_decode_with_malloc.o", - "$COMMON/pb_common_with_malloc.o", - "$COMMON/malloc_wrappers.o"]) - -env.RunTest(fuzz) - -fuzzstub = malloc_env.Program(["fuzzstub.c", - "alltypes_pointer.pb.c", - "alltypes_static.pb.c", - "$COMMON/pb_encode_with_malloc.o", - "$COMMON/pb_decode_with_malloc.o", - "$COMMON/pb_common_with_malloc.o", - "$COMMON/malloc_wrappers.o"]) - -generate_message = malloc_env.Program(["generate_message.c", - "alltypes_static.pb.c", - "$COMMON/pb_encode.o", - "$COMMON/pb_common.o"]) - diff --git a/third_party/nanopb/tests/fuzztest/alltypes_pointer.options b/third_party/nanopb/tests/fuzztest/alltypes_pointer.options deleted file mode 100644 index 52abeb7fec9..00000000000 --- a/third_party/nanopb/tests/fuzztest/alltypes_pointer.options +++ /dev/null @@ -1,3 +0,0 @@ -# Generate all fields as pointers. -* type:FT_POINTER - diff --git a/third_party/nanopb/tests/fuzztest/alltypes_static.options b/third_party/nanopb/tests/fuzztest/alltypes_static.options deleted file mode 100644 index 1c10637c31b..00000000000 --- a/third_party/nanopb/tests/fuzztest/alltypes_static.options +++ /dev/null @@ -1,3 +0,0 @@ -* max_size:32 -* max_count:8 -*.extensions type:FT_IGNORE diff --git a/third_party/nanopb/tests/fuzztest/fuzzstub.c b/third_party/nanopb/tests/fuzztest/fuzzstub.c deleted file mode 100644 index ec9e2afefb0..00000000000 --- a/third_party/nanopb/tests/fuzztest/fuzzstub.c +++ /dev/null @@ -1,189 +0,0 @@ -/* Fuzz testing for the nanopb core. - * This can be used with external fuzzers, e.g. radamsa. - * It performs most of the same checks as fuzztest, but does not feature data generation. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "alltypes_static.pb.h" -#include "alltypes_pointer.pb.h" - -#define BUFSIZE 4096 - -static bool do_static_decode(uint8_t *buffer, size_t msglen, bool assert_success) -{ - pb_istream_t stream; - bool status; - - alltypes_static_AllTypes *msg = malloc_with_check(sizeof(alltypes_static_AllTypes)); - stream = pb_istream_from_buffer(buffer, msglen); - status = pb_decode(&stream, alltypes_static_AllTypes_fields, msg); - - if (!status && assert_success) - { - /* Anything that was successfully encoded, should be decodeable. - * One exception: strings without null terminator are encoded up - * to end of buffer, but refused on decode because the terminator - * would not fit. */ - if (strcmp(stream.errmsg, "string overflow") != 0) - assert(status); - } - - free_with_check(msg); - return status; -} - -static bool do_pointer_decode(uint8_t *buffer, size_t msglen, bool assert_success) -{ - pb_istream_t stream; - bool status; - alltypes_pointer_AllTypes *msg; - - msg = malloc_with_check(sizeof(alltypes_pointer_AllTypes)); - memset(msg, 0, sizeof(alltypes_pointer_AllTypes)); - stream = pb_istream_from_buffer(buffer, msglen); - - assert(get_alloc_count() == 0); - status = pb_decode(&stream, alltypes_pointer_AllTypes_fields, msg); - - if (assert_success) - assert(status); - - pb_release(alltypes_pointer_AllTypes_fields, msg); - assert(get_alloc_count() == 0); - - free_with_check(msg); - - return status; -} - -/* Do a decode -> encode -> decode -> encode roundtrip */ -static void do_static_roundtrip(uint8_t *buffer, size_t msglen) -{ - bool status; - uint8_t *buf2 = malloc_with_check(BUFSIZE); - uint8_t *buf3 = malloc_with_check(BUFSIZE); - size_t msglen2, msglen3; - alltypes_static_AllTypes *msg1 = malloc_with_check(sizeof(alltypes_static_AllTypes)); - alltypes_static_AllTypes *msg2 = malloc_with_check(sizeof(alltypes_static_AllTypes)); - memset(msg1, 0, sizeof(alltypes_static_AllTypes)); - memset(msg2, 0, sizeof(alltypes_static_AllTypes)); - - { - pb_istream_t stream = pb_istream_from_buffer(buffer, msglen); - status = pb_decode(&stream, alltypes_static_AllTypes_fields, msg1); - assert(status); - } - - { - pb_ostream_t stream = pb_ostream_from_buffer(buf2, BUFSIZE); - status = pb_encode(&stream, alltypes_static_AllTypes_fields, msg1); - assert(status); - msglen2 = stream.bytes_written; - } - - { - pb_istream_t stream = pb_istream_from_buffer(buf2, msglen2); - status = pb_decode(&stream, alltypes_static_AllTypes_fields, msg2); - assert(status); - } - - { - pb_ostream_t stream = pb_ostream_from_buffer(buf3, BUFSIZE); - status = pb_encode(&stream, alltypes_static_AllTypes_fields, msg2); - assert(status); - msglen3 = stream.bytes_written; - } - - assert(msglen2 == msglen3); - assert(memcmp(buf2, buf3, msglen2) == 0); - - free_with_check(msg1); - free_with_check(msg2); - free_with_check(buf2); - free_with_check(buf3); -} - -/* Do decode -> encode -> decode -> encode roundtrip */ -static void do_pointer_roundtrip(uint8_t *buffer, size_t msglen) -{ - bool status; - uint8_t *buf2 = malloc_with_check(BUFSIZE); - uint8_t *buf3 = malloc_with_check(BUFSIZE); - size_t msglen2, msglen3; - alltypes_pointer_AllTypes *msg1 = malloc_with_check(sizeof(alltypes_pointer_AllTypes)); - alltypes_pointer_AllTypes *msg2 = malloc_with_check(sizeof(alltypes_pointer_AllTypes)); - memset(msg1, 0, sizeof(alltypes_pointer_AllTypes)); - memset(msg2, 0, sizeof(alltypes_pointer_AllTypes)); - - { - pb_istream_t stream = pb_istream_from_buffer(buffer, msglen); - status = pb_decode(&stream, alltypes_pointer_AllTypes_fields, msg1); - assert(status); - } - - { - pb_ostream_t stream = pb_ostream_from_buffer(buf2, BUFSIZE); - status = pb_encode(&stream, alltypes_pointer_AllTypes_fields, msg1); - assert(status); - msglen2 = stream.bytes_written; - } - - { - pb_istream_t stream = pb_istream_from_buffer(buf2, msglen2); - status = pb_decode(&stream, alltypes_pointer_AllTypes_fields, msg2); - assert(status); - } - - { - pb_ostream_t stream = pb_ostream_from_buffer(buf3, BUFSIZE); - status = pb_encode(&stream, alltypes_pointer_AllTypes_fields, msg2); - assert(status); - msglen3 = stream.bytes_written; - } - - assert(msglen2 == msglen3); - assert(memcmp(buf2, buf3, msglen2) == 0); - - pb_release(alltypes_pointer_AllTypes_fields, msg1); - pb_release(alltypes_pointer_AllTypes_fields, msg2); - free_with_check(msg1); - free_with_check(msg2); - free_with_check(buf2); - free_with_check(buf3); -} - -static void run_iteration() -{ - uint8_t *buffer = malloc_with_check(BUFSIZE); - size_t msglen; - bool status; - - msglen = fread(buffer, 1, BUFSIZE, stdin); - - status = do_static_decode(buffer, msglen, false); - - if (status) - do_static_roundtrip(buffer, msglen); - - status = do_pointer_decode(buffer, msglen, false); - - if (status) - do_pointer_roundtrip(buffer, msglen); - - free_with_check(buffer); -} - -int main(int argc, char **argv) -{ - run_iteration(); - - return 0; -} - diff --git a/third_party/nanopb/tests/fuzztest/fuzztest.c b/third_party/nanopb/tests/fuzztest/fuzztest.c deleted file mode 100644 index ee851ec0892..00000000000 --- a/third_party/nanopb/tests/fuzztest/fuzztest.c +++ /dev/null @@ -1,432 +0,0 @@ -/* Fuzz testing for the nanopb core. - * Attempts to verify all the properties defined in the security model document. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "alltypes_static.pb.h" -#include "alltypes_pointer.pb.h" - -static uint64_t random_seed; - -/* Uses xorshift64 here instead of rand() for both speed and - * reproducibility across platforms. */ -static uint32_t rand_word() -{ - random_seed ^= random_seed >> 12; - random_seed ^= random_seed << 25; - random_seed ^= random_seed >> 27; - return random_seed * 2685821657736338717ULL; -} - -/* Get a random integer in range, with approximately flat distribution. */ -static int rand_int(int min, int max) -{ - return rand_word() % (max + 1 - min) + min; -} - -static bool rand_bool() -{ - return rand_word() & 1; -} - -/* Get a random byte, with skewed distribution. - * Important corner cases like 0xFF, 0x00 and 0xFE occur more - * often than other values. */ -static uint8_t rand_byte() -{ - uint32_t w = rand_word(); - uint8_t b = w & 0xFF; - if (w & 0x100000) - b >>= (w >> 8) & 7; - if (w & 0x200000) - b <<= (w >> 12) & 7; - if (w & 0x400000) - b ^= 0xFF; - return b; -} - -/* Get a random length, with skewed distribution. - * Favors the shorter lengths, but always atleast 1. */ -static size_t rand_len(size_t max) -{ - uint32_t w = rand_word(); - size_t s; - if (w & 0x800000) - w &= 3; - else if (w & 0x400000) - w &= 15; - else if (w & 0x200000) - w &= 255; - - s = (w % max); - if (s == 0) - s = 1; - - return s; -} - -/* Fills a buffer with random data with skewed distribution. */ -static void rand_fill(uint8_t *buf, size_t count) -{ - while (count--) - *buf++ = rand_byte(); -} - -/* Fill with random protobuf-like data */ -static size_t rand_fill_protobuf(uint8_t *buf, size_t min_bytes, size_t max_bytes, int min_tag) -{ - pb_ostream_t stream = pb_ostream_from_buffer(buf, max_bytes); - - while(stream.bytes_written < min_bytes) - { - pb_wire_type_t wt = rand_int(0, 3); - if (wt == 3) wt = 5; /* Gap in values */ - - if (!pb_encode_tag(&stream, wt, rand_int(min_tag, min_tag + 512))) - break; - - if (wt == PB_WT_VARINT) - { - uint64_t value; - rand_fill((uint8_t*)&value, sizeof(value)); - pb_encode_varint(&stream, value); - } - else if (wt == PB_WT_64BIT) - { - uint64_t value; - rand_fill((uint8_t*)&value, sizeof(value)); - pb_encode_fixed64(&stream, &value); - } - else if (wt == PB_WT_32BIT) - { - uint32_t value; - rand_fill((uint8_t*)&value, sizeof(value)); - pb_encode_fixed32(&stream, &value); - } - else if (wt == PB_WT_STRING) - { - size_t len; - uint8_t *buf; - - if (min_bytes > stream.bytes_written) - len = rand_len(min_bytes - stream.bytes_written); - else - len = 0; - - buf = malloc(len); - pb_encode_varint(&stream, len); - rand_fill(buf, len); - pb_write(&stream, buf, len); - free(buf); - } - } - - return stream.bytes_written; -} - -/* Given a buffer of data, mess it up a bit */ -static void rand_mess(uint8_t *buf, size_t count) -{ - int m = rand_int(0, 3); - - if (m == 0) - { - /* Replace random substring */ - int s = rand_int(0, count - 1); - int l = rand_len(count - s); - rand_fill(buf + s, l); - } - else if (m == 1) - { - /* Swap random bytes */ - int a = rand_int(0, count - 1); - int b = rand_int(0, count - 1); - int x = buf[a]; - buf[a] = buf[b]; - buf[b] = x; - } - else if (m == 2) - { - /* Duplicate substring */ - int s = rand_int(0, count - 2); - int l = rand_len((count - s) / 2); - memcpy(buf + s + l, buf + s, l); - } - else if (m == 3) - { - /* Add random protobuf noise */ - int s = rand_int(0, count - 1); - int l = rand_len(count - s); - rand_fill_protobuf(buf + s, l, count - s, 1); - } -} - -/* Some default data to put in the message */ -static const alltypes_static_AllTypes initval = alltypes_static_AllTypes_init_default; - -#define BUFSIZE 4096 - -static bool do_static_encode(uint8_t *buffer, size_t *msglen) -{ - pb_ostream_t stream; - bool status; - - /* Allocate a message and fill it with defaults */ - alltypes_static_AllTypes *msg = malloc_with_check(sizeof(alltypes_static_AllTypes)); - memcpy(msg, &initval, sizeof(initval)); - - /* Apply randomness to the data before encoding */ - while (rand_int(0, 7)) - rand_mess((uint8_t*)msg, sizeof(alltypes_static_AllTypes)); - - stream = pb_ostream_from_buffer(buffer, BUFSIZE); - status = pb_encode(&stream, alltypes_static_AllTypes_fields, msg); - assert(stream.bytes_written <= BUFSIZE); - assert(stream.bytes_written <= alltypes_static_AllTypes_size); - - *msglen = stream.bytes_written; - pb_release(alltypes_static_AllTypes_fields, msg); - free_with_check(msg); - - return status; -} - -/* Append or prepend protobuf noise */ -static void do_protobuf_noise(uint8_t *buffer, size_t *msglen) -{ - int m = rand_int(0, 2); - size_t max_size = BUFSIZE - 32 - *msglen; - if (m == 1) - { - /* Prepend */ - uint8_t *tmp = malloc_with_check(BUFSIZE); - size_t s = rand_fill_protobuf(tmp, rand_len(max_size), BUFSIZE - *msglen, 512); - memmove(buffer + s, buffer, *msglen); - memcpy(buffer, tmp, s); - free_with_check(tmp); - *msglen += s; - } - else if (m == 2) - { - /* Append */ - size_t s = rand_fill_protobuf(buffer + *msglen, rand_len(max_size), BUFSIZE - *msglen, 512); - *msglen += s; - } -} - -static bool do_static_decode(uint8_t *buffer, size_t msglen, bool assert_success) -{ - pb_istream_t stream; - bool status; - - alltypes_static_AllTypes *msg = malloc_with_check(sizeof(alltypes_static_AllTypes)); - rand_fill((uint8_t*)msg, sizeof(alltypes_static_AllTypes)); - stream = pb_istream_from_buffer(buffer, msglen); - status = pb_decode(&stream, alltypes_static_AllTypes_fields, msg); - - if (!status && assert_success) - { - /* Anything that was successfully encoded, should be decodeable. - * One exception: strings without null terminator are encoded up - * to end of buffer, but refused on decode because the terminator - * would not fit. */ - if (strcmp(stream.errmsg, "string overflow") != 0) - assert(status); - } - - free_with_check(msg); - return status; -} - -static bool do_pointer_decode(uint8_t *buffer, size_t msglen, bool assert_success) -{ - pb_istream_t stream; - bool status; - alltypes_pointer_AllTypes *msg; - - msg = malloc_with_check(sizeof(alltypes_pointer_AllTypes)); - memset(msg, 0, sizeof(alltypes_pointer_AllTypes)); - stream = pb_istream_from_buffer(buffer, msglen); - - assert(get_alloc_count() == 0); - status = pb_decode(&stream, alltypes_pointer_AllTypes_fields, msg); - - if (assert_success) - assert(status); - - pb_release(alltypes_pointer_AllTypes_fields, msg); - assert(get_alloc_count() == 0); - - free_with_check(msg); - - return status; -} - -/* Do a decode -> encode -> decode -> encode roundtrip */ -static void do_static_roundtrip(uint8_t *buffer, size_t msglen) -{ - bool status; - uint8_t *buf2 = malloc_with_check(BUFSIZE); - uint8_t *buf3 = malloc_with_check(BUFSIZE); - size_t msglen2, msglen3; - alltypes_static_AllTypes *msg1 = malloc_with_check(sizeof(alltypes_static_AllTypes)); - alltypes_static_AllTypes *msg2 = malloc_with_check(sizeof(alltypes_static_AllTypes)); - memset(msg1, 0, sizeof(alltypes_static_AllTypes)); - memset(msg2, 0, sizeof(alltypes_static_AllTypes)); - - { - pb_istream_t stream = pb_istream_from_buffer(buffer, msglen); - status = pb_decode(&stream, alltypes_static_AllTypes_fields, msg1); - assert(status); - } - - { - pb_ostream_t stream = pb_ostream_from_buffer(buf2, BUFSIZE); - status = pb_encode(&stream, alltypes_static_AllTypes_fields, msg1); - assert(status); - msglen2 = stream.bytes_written; - } - - { - pb_istream_t stream = pb_istream_from_buffer(buf2, msglen2); - status = pb_decode(&stream, alltypes_static_AllTypes_fields, msg2); - assert(status); - } - - { - pb_ostream_t stream = pb_ostream_from_buffer(buf3, BUFSIZE); - status = pb_encode(&stream, alltypes_static_AllTypes_fields, msg2); - assert(status); - msglen3 = stream.bytes_written; - } - - assert(msglen2 == msglen3); - assert(memcmp(buf2, buf3, msglen2) == 0); - - free_with_check(msg1); - free_with_check(msg2); - free_with_check(buf2); - free_with_check(buf3); -} - -/* Do decode -> encode -> decode -> encode roundtrip */ -static void do_pointer_roundtrip(uint8_t *buffer, size_t msglen) -{ - bool status; - uint8_t *buf2 = malloc_with_check(BUFSIZE); - uint8_t *buf3 = malloc_with_check(BUFSIZE); - size_t msglen2, msglen3; - alltypes_pointer_AllTypes *msg1 = malloc_with_check(sizeof(alltypes_pointer_AllTypes)); - alltypes_pointer_AllTypes *msg2 = malloc_with_check(sizeof(alltypes_pointer_AllTypes)); - memset(msg1, 0, sizeof(alltypes_pointer_AllTypes)); - memset(msg2, 0, sizeof(alltypes_pointer_AllTypes)); - - { - pb_istream_t stream = pb_istream_from_buffer(buffer, msglen); - status = pb_decode(&stream, alltypes_pointer_AllTypes_fields, msg1); - assert(status); - } - - { - pb_ostream_t stream = pb_ostream_from_buffer(buf2, BUFSIZE); - status = pb_encode(&stream, alltypes_pointer_AllTypes_fields, msg1); - assert(status); - msglen2 = stream.bytes_written; - } - - { - pb_istream_t stream = pb_istream_from_buffer(buf2, msglen2); - status = pb_decode(&stream, alltypes_pointer_AllTypes_fields, msg2); - assert(status); - } - - { - pb_ostream_t stream = pb_ostream_from_buffer(buf3, BUFSIZE); - status = pb_encode(&stream, alltypes_pointer_AllTypes_fields, msg2); - assert(status); - msglen3 = stream.bytes_written; - } - - assert(msglen2 == msglen3); - assert(memcmp(buf2, buf3, msglen2) == 0); - - pb_release(alltypes_pointer_AllTypes_fields, msg1); - pb_release(alltypes_pointer_AllTypes_fields, msg2); - free_with_check(msg1); - free_with_check(msg2); - free_with_check(buf2); - free_with_check(buf3); -} - -static void run_iteration() -{ - uint8_t *buffer = malloc_with_check(BUFSIZE); - size_t msglen; - bool status; - - rand_fill(buffer, BUFSIZE); - - if (do_static_encode(buffer, &msglen)) - { - do_protobuf_noise(buffer, &msglen); - - status = do_static_decode(buffer, msglen, true); - - if (status) - do_static_roundtrip(buffer, msglen); - - status = do_pointer_decode(buffer, msglen, true); - - if (status) - do_pointer_roundtrip(buffer, msglen); - - /* Apply randomness to the encoded data */ - while (rand_bool()) - rand_mess(buffer, BUFSIZE); - - /* Apply randomness to encoded data length */ - if (rand_bool()) - msglen = rand_int(0, BUFSIZE); - - status = do_static_decode(buffer, msglen, false); - do_pointer_decode(buffer, msglen, status); - - if (status) - { - do_static_roundtrip(buffer, msglen); - do_pointer_roundtrip(buffer, msglen); - } - } - - free_with_check(buffer); -} - -int main(int argc, char **argv) -{ - int i; - if (argc > 1) - { - random_seed = atol(argv[1]); - } - else - { - random_seed = time(NULL); - } - - fprintf(stderr, "Random seed: %llu\n", (long long unsigned)random_seed); - - for (i = 0; i < 10000; i++) - { - run_iteration(); - } - - return 0; -} - diff --git a/third_party/nanopb/tests/fuzztest/generate_message.c b/third_party/nanopb/tests/fuzztest/generate_message.c deleted file mode 100644 index 6e49299056e..00000000000 --- a/third_party/nanopb/tests/fuzztest/generate_message.c +++ /dev/null @@ -1,101 +0,0 @@ -/* Generates a random, valid protobuf message. Useful to seed - * external fuzzers such as afl-fuzz. - */ - -#include -#include -#include -#include -#include -#include -#include -#include "alltypes_static.pb.h" - -static uint64_t random_seed; - -/* Uses xorshift64 here instead of rand() for both speed and - * reproducibility across platforms. */ -static uint32_t rand_word() -{ - random_seed ^= random_seed >> 12; - random_seed ^= random_seed << 25; - random_seed ^= random_seed >> 27; - return random_seed * 2685821657736338717ULL; -} - -/* Fills a buffer with random data. */ -static void rand_fill(uint8_t *buf, size_t count) -{ - while (count--) - { - *buf++ = rand_word() & 0xff; - } -} - -/* Check that size/count fields do not exceed their max size. - * Otherwise we would have to loop pretty long in generate_message(). - * Note that there may still be a few encoding errors from submessages. - */ -static void limit_sizes(alltypes_static_AllTypes *msg) -{ - pb_field_iter_t iter; - pb_field_iter_begin(&iter, alltypes_static_AllTypes_fields, msg); - while (pb_field_iter_next(&iter)) - { - if (PB_LTYPE(iter.pos->type) == PB_LTYPE_BYTES) - { - ((pb_bytes_array_t*)iter.pData)->size %= iter.pos->data_size - PB_BYTES_ARRAY_T_ALLOCSIZE(0); - } - - if (PB_HTYPE(iter.pos->type) == PB_HTYPE_REPEATED) - { - *((pb_size_t*)iter.pSize) %= iter.pos->array_size; - } - - if (PB_HTYPE(iter.pos->type) == PB_HTYPE_ONEOF) - { - /* Set the oneof to this message type with 50% chance. */ - if (rand_word() & 1) - { - *((pb_size_t*)iter.pSize) = iter.pos->tag; - } - } - } -} - -static void generate_message() -{ - alltypes_static_AllTypes msg; - uint8_t buf[8192]; - pb_ostream_t stream = {0}; - - do { - if (stream.errmsg) - fprintf(stderr, "Encoder error: %s\n", stream.errmsg); - - stream = pb_ostream_from_buffer(buf, sizeof(buf)); - rand_fill((void*)&msg, sizeof(msg)); - limit_sizes(&msg); - } while (!pb_encode(&stream, alltypes_static_AllTypes_fields, &msg)); - - fwrite(buf, 1, stream.bytes_written, stdout); -} - -int main(int argc, char **argv) -{ - if (argc > 1) - { - random_seed = atol(argv[1]); - } - else - { - random_seed = time(NULL); - } - - fprintf(stderr, "Random seed: %llu\n", (long long unsigned)random_seed); - - generate_message(); - - return 0; -} - diff --git a/third_party/nanopb/tests/fuzztest/run_radamsa.sh b/third_party/nanopb/tests/fuzztest/run_radamsa.sh deleted file mode 100755 index 52cd40a8690..00000000000 --- a/third_party/nanopb/tests/fuzztest/run_radamsa.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -TMP=`tempfile` - -echo $TMP -while true -do - radamsa sample_data/* > $TMP - $1 < $TMP - test $? -gt 127 && break -done - diff --git a/third_party/nanopb/tests/inline/SConscript b/third_party/nanopb/tests/inline/SConscript deleted file mode 100644 index 34371fda18d..00000000000 --- a/third_party/nanopb/tests/inline/SConscript +++ /dev/null @@ -1,16 +0,0 @@ -# Test that inlined bytes fields work. - -Import("env") - -env.NanopbProto("inline") -env.Object("inline.pb.c") - -env.Match(["inline.pb.h", "inline.expected"]) - -p = env.Program(["inline_unittests.c", - "inline.pb.c", - "$COMMON/pb_encode.o", - "$COMMON/pb_decode.o", - "$COMMON/pb_common.o"]) - -env.RunTest(p) diff --git a/third_party/nanopb/tests/inline/inline.expected b/third_party/nanopb/tests/inline/inline.expected deleted file mode 100644 index 593e972bac9..00000000000 --- a/third_party/nanopb/tests/inline/inline.expected +++ /dev/null @@ -1,3 +0,0 @@ -pb_byte_t data\[32\]; -bool has_data; -pb_byte_t data\[64\]; diff --git a/third_party/nanopb/tests/inline/inline.proto b/third_party/nanopb/tests/inline/inline.proto deleted file mode 100644 index 6e511f0a256..00000000000 --- a/third_party/nanopb/tests/inline/inline.proto +++ /dev/null @@ -1,17 +0,0 @@ -/* Test nanopb option parsing. - * options.expected lists the patterns that are searched for in the output. - */ - -syntax = "proto2"; - -import "nanopb.proto"; - -message Message1 -{ - required bytes data = 1 [(nanopb).type = FT_INLINE, (nanopb).max_size = 32]; -} - -message Message2 -{ - optional bytes data = 1 [(nanopb).type = FT_INLINE, (nanopb).max_size = 64]; -} diff --git a/third_party/nanopb/tests/inline/inline_unittests.c b/third_party/nanopb/tests/inline/inline_unittests.c deleted file mode 100644 index b5834c7e029..00000000000 --- a/third_party/nanopb/tests/inline/inline_unittests.c +++ /dev/null @@ -1,73 +0,0 @@ -#include -#include -#include -#include -#include "unittests.h" -#include "inline.pb.h" - -int main() -{ - int status = 0; - int i = 0; - COMMENT("Test inline byte fields"); - - { - Message1 msg1 = Message1_init_zero; - TEST(sizeof(msg1.data) == 32); - } - - { - Message1 msg1 = Message1_init_zero; - pb_byte_t msg1_buffer[Message1_size]; - pb_ostream_t ostream = pb_ostream_from_buffer(msg1_buffer, Message1_size); - Message1 msg1_deserialized = Message1_init_zero; - pb_istream_t istream = pb_istream_from_buffer(msg1_buffer, Message1_size); - - for (i = 0; i < 32; i++) { - msg1.data[i] = i; - } - - TEST(pb_encode(&ostream, Message1_fields, &msg1)); - TEST(ostream.bytes_written == Message1_size); - - TEST(pb_decode(&istream, Message1_fields, &msg1_deserialized)); - - TEST(istream.bytes_left == 0); - TEST(memcmp(&msg1_deserialized, &msg1, sizeof(msg1)) == 0); - } - - { - Message2 msg2 = {true, {0}}; - Message2 msg2_no_data = {false, {1}}; - pb_byte_t msg2_buffer[Message2_size]; - pb_ostream_t ostream = pb_ostream_from_buffer(msg2_buffer, Message2_size); - Message2 msg2_deserialized = Message2_init_zero; - pb_istream_t istream = pb_istream_from_buffer(msg2_buffer, Message2_size); - - for (i = 0; i < 64; i++) { - msg2.data[i] = i; - } - - TEST(pb_encode(&ostream, Message2_fields, &msg2)); - TEST(ostream.bytes_written == Message2_size); - - TEST(pb_decode(&istream, Message2_fields, &msg2_deserialized)); - - TEST(istream.bytes_left == 0); - TEST(memcmp(&msg2_deserialized, &msg2, sizeof(msg2)) == 0); - TEST(msg2_deserialized.has_data); - - memset(msg2_buffer, 0, sizeof(msg2_buffer)); - ostream = pb_ostream_from_buffer(msg2_buffer, Message2_size); - TEST(pb_encode(&ostream, Message2_fields, &msg2_no_data)); - istream = pb_istream_from_buffer(msg2_buffer, Message2_size); - TEST(pb_decode(&istream, Message2_fields, &msg2_deserialized)); - TEST(!msg2_deserialized.has_data); - TEST(memcmp(&msg2_deserialized, &msg2, sizeof(msg2)) != 0); - } - - if (status != 0) - fprintf(stdout, "\n\nSome tests FAILED!\n"); - - return status; -} diff --git a/third_party/nanopb/tests/intsizes/SConscript b/third_party/nanopb/tests/intsizes/SConscript deleted file mode 100644 index a90680bcfc0..00000000000 --- a/third_party/nanopb/tests/intsizes/SConscript +++ /dev/null @@ -1,12 +0,0 @@ -# Test that the int_size option in .proto works. - -Import('env') - -env.NanopbProto('intsizes') - -p = env.Program(["intsizes_unittests.c", - "intsizes.pb.c", - "$COMMON/pb_encode.o", - "$COMMON/pb_decode.o", - "$COMMON/pb_common.o"]) -env.RunTest(p) diff --git a/third_party/nanopb/tests/intsizes/intsizes.proto b/third_party/nanopb/tests/intsizes/intsizes.proto deleted file mode 100644 index 91444d41d68..00000000000 --- a/third_party/nanopb/tests/intsizes/intsizes.proto +++ /dev/null @@ -1,41 +0,0 @@ -/* Test the integer size overriding in nanopb options. - * This allows to use 8- and 16-bit integer variables, which are not supported - * directly by Google Protobuf. - * - * The int_size setting will override the number of bits, but keep the type - * otherwise. E.g. uint32 + IS_8 => uint8_t - */ - -syntax = "proto2"; - -import 'nanopb.proto'; - -message IntSizes { - required int32 req_int8 = 1 [(nanopb).int_size = IS_8]; - required uint32 req_uint8 = 2 [(nanopb).int_size = IS_8]; - required sint32 req_sint8 = 3 [(nanopb).int_size = IS_8]; - required int32 req_int16 = 4 [(nanopb).int_size = IS_16]; - required uint32 req_uint16 = 5 [(nanopb).int_size = IS_16]; - required sint32 req_sint16 = 6 [(nanopb).int_size = IS_16]; - required int32 req_int32 = 7 [(nanopb).int_size = IS_32]; - required uint32 req_uint32 = 8 [(nanopb).int_size = IS_32]; - required sint32 req_sint32 = 9 [(nanopb).int_size = IS_32]; - required int32 req_int64 = 10 [(nanopb).int_size = IS_64]; - required uint32 req_uint64 = 11 [(nanopb).int_size = IS_64]; - required sint32 req_sint64 = 12 [(nanopb).int_size = IS_64]; -} - -message DefaultSizes { - required int32 req_int8 = 1 ; - required uint32 req_uint8 = 2 ; - required sint32 req_sint8 = 3 ; - required int32 req_int16 = 4 ; - required uint32 req_uint16 = 5 ; - required sint32 req_sint16 = 6 ; - required int32 req_int32 = 7 ; - required uint32 req_uint32 = 8 ; - required sint32 req_sint32 = 9 ; - required int64 req_int64 = 10; - required uint64 req_uint64 = 11; - required sint64 req_sint64 = 12; -} diff --git a/third_party/nanopb/tests/intsizes/intsizes_unittests.c b/third_party/nanopb/tests/intsizes/intsizes_unittests.c deleted file mode 100644 index 79ef0369672..00000000000 --- a/third_party/nanopb/tests/intsizes/intsizes_unittests.c +++ /dev/null @@ -1,122 +0,0 @@ -#include -#include -#include -#include -#include "unittests.h" -#include "intsizes.pb.h" - -#define S(x) pb_istream_from_buffer((uint8_t*)x, sizeof(x) - 1) - -/* This is a macro instead of function in order to get the actual values - * into the TEST() lines in output */ -#define TEST_ROUNDTRIP(int8, uint8, sint8, \ - int16, uint16, sint16, \ - int32, uint32, sint32, \ - int64, uint64, sint64, expected_result) \ -{ \ - uint8_t buffer1[128], buffer2[128]; \ - size_t msgsize; \ - DefaultSizes msg1 = DefaultSizes_init_zero; \ - IntSizes msg2 = IntSizes_init_zero; \ - \ - msg1.req_int8 = int8; \ - msg1.req_uint8 = uint8; \ - msg1.req_sint8 = sint8; \ - msg1.req_int16 = int16; \ - msg1.req_uint16 = uint16; \ - msg1.req_sint16 = sint16; \ - msg1.req_int32 = int32; \ - msg1.req_uint32 = uint32; \ - msg1.req_sint32 = sint32; \ - msg1.req_int64 = int64; \ - msg1.req_uint64 = uint64; \ - msg1.req_sint64 = sint64; \ - \ - { \ - pb_ostream_t s = pb_ostream_from_buffer(buffer1, sizeof(buffer1)); \ - TEST(pb_encode(&s, DefaultSizes_fields, &msg1)); \ - msgsize = s.bytes_written; \ - } \ - \ - { \ - pb_istream_t s = pb_istream_from_buffer(buffer1, msgsize); \ - TEST(pb_decode(&s, IntSizes_fields, &msg2) == expected_result); \ - if (expected_result) \ - { \ - TEST( (int64_t)msg2.req_int8 == int8); \ - TEST((uint64_t)msg2.req_uint8 == uint8); \ - TEST( (int64_t)msg2.req_sint8 == sint8); \ - TEST( (int64_t)msg2.req_int16 == int16); \ - TEST((uint64_t)msg2.req_uint16 == uint16); \ - TEST( (int64_t)msg2.req_sint16 == sint16); \ - TEST( (int64_t)msg2.req_int32 == int32); \ - TEST((uint64_t)msg2.req_uint32 == uint32); \ - TEST( (int64_t)msg2.req_sint32 == sint32); \ - TEST( (int64_t)msg2.req_int64 == int64); \ - TEST((uint64_t)msg2.req_uint64 == uint64); \ - TEST( (int64_t)msg2.req_sint64 == sint64); \ - } \ - } \ - \ - if (expected_result) \ - { \ - pb_ostream_t s = pb_ostream_from_buffer(buffer2, sizeof(buffer2)); \ - TEST(pb_encode(&s, IntSizes_fields, &msg2)); \ - TEST(s.bytes_written == msgsize); \ - TEST(memcmp(buffer1, buffer2, msgsize) == 0); \ - } \ -} - -int main() -{ - int status = 0; - - { - IntSizes msg = IntSizes_init_zero; - - COMMENT("Test field sizes"); - TEST(sizeof(msg.req_int8) == 1); - TEST(sizeof(msg.req_uint8) == 1); - TEST(sizeof(msg.req_sint8) == 1); - TEST(sizeof(msg.req_int16) == 2); - TEST(sizeof(msg.req_uint16) == 2); - TEST(sizeof(msg.req_sint16) == 2); - TEST(sizeof(msg.req_int32) == 4); - TEST(sizeof(msg.req_uint32) == 4); - TEST(sizeof(msg.req_sint32) == 4); - TEST(sizeof(msg.req_int64) == 8); - TEST(sizeof(msg.req_uint64) == 8); - TEST(sizeof(msg.req_sint64) == 8); - } - - COMMENT("Test roundtrip at maximum value"); - TEST_ROUNDTRIP(127, 255, 127, - 32767, 65535, 32767, - INT32_MAX, UINT32_MAX, INT32_MAX, - INT64_MAX, UINT64_MAX, INT64_MAX, true); - - COMMENT("Test roundtrip at minimum value"); - TEST_ROUNDTRIP(-128, 0, -128, - -32768, 0, -32768, - INT32_MIN, 0, INT32_MIN, - INT64_MIN, 0, INT64_MIN, true); - - COMMENT("Test overflow detection"); - TEST_ROUNDTRIP(-129, 0, -128, - -32768, 0, -32768, - INT32_MIN, 0, INT32_MIN, - INT64_MIN, 0, INT64_MIN, false); - TEST_ROUNDTRIP(127, 256, 127, - 32767, 65535, 32767, - INT32_MAX, UINT32_MAX, INT32_MAX, - INT64_MAX, UINT64_MAX, INT64_MAX, false); - TEST_ROUNDTRIP(-128, 0, -128, - -32768, 0, -32769, - INT32_MIN, 0, INT32_MIN, - INT64_MIN, 0, INT64_MIN, false); - - if (status != 0) - fprintf(stdout, "\n\nSome tests FAILED!\n"); - - return status; -} \ No newline at end of file diff --git a/third_party/nanopb/tests/io_errors/SConscript b/third_party/nanopb/tests/io_errors/SConscript deleted file mode 100644 index 60146cc09bb..00000000000 --- a/third_party/nanopb/tests/io_errors/SConscript +++ /dev/null @@ -1,15 +0,0 @@ -# Simulate io errors when encoding and decoding - -Import("env") - -c = Copy("$TARGET", "$SOURCE") -env.Command("alltypes.proto", "#alltypes/alltypes.proto", c) - -env.NanopbProto(["alltypes", "alltypes.options"]) - -ioerr = env.Program(["io_errors.c", "alltypes.pb.c", - "$COMMON/pb_encode.o", "$COMMON/pb_decode.o", "$COMMON/pb_common.o"]) - -env.RunTest("io_errors.output", [ioerr, "$BUILD/alltypes/encode_alltypes.output"]) - - diff --git a/third_party/nanopb/tests/io_errors/alltypes.options b/third_party/nanopb/tests/io_errors/alltypes.options deleted file mode 100644 index b31e3cf0a9d..00000000000 --- a/third_party/nanopb/tests/io_errors/alltypes.options +++ /dev/null @@ -1,3 +0,0 @@ -* max_size:16 -* max_count:5 - diff --git a/third_party/nanopb/tests/io_errors/io_errors.c b/third_party/nanopb/tests/io_errors/io_errors.c deleted file mode 100644 index 76f35b08381..00000000000 --- a/third_party/nanopb/tests/io_errors/io_errors.c +++ /dev/null @@ -1,140 +0,0 @@ -/* Simulate IO errors after each byte in a stream. - * Verifies proper error propagation. - */ - -#include -#include -#include -#include "alltypes.pb.h" -#include "test_helpers.h" - -typedef struct -{ - uint8_t *buffer; - size_t fail_after; -} faulty_stream_t; - -bool read_callback(pb_istream_t *stream, uint8_t *buf, size_t count) -{ - faulty_stream_t *state = stream->state; - - while (count--) - { - if (state->fail_after == 0) - PB_RETURN_ERROR(stream, "simulated"); - state->fail_after--; - *buf++ = *state->buffer++; - } - - return true; -} -bool write_callback(pb_ostream_t *stream, const uint8_t *buf, size_t count) -{ - faulty_stream_t *state = stream->state; - - while (count--) - { - if (state->fail_after == 0) - PB_RETURN_ERROR(stream, "simulated"); - state->fail_after--; - *state->buffer++ = *buf++; - } - - return true; -} - -int main() -{ - uint8_t buffer[2048]; - size_t msglen; - AllTypes msg = AllTypes_init_zero; - - /* Get some base data to run the tests with */ - SET_BINARY_MODE(stdin); - msglen = fread(buffer, 1, sizeof(buffer), stdin); - - /* Test IO errors on decoding */ - { - bool status; - pb_istream_t stream = {&read_callback, NULL, SIZE_MAX}; - faulty_stream_t fs; - size_t i; - - for (i = 0; i < msglen; i++) - { - stream.bytes_left = msglen; - stream.state = &fs; - fs.buffer = buffer; - fs.fail_after = i; - - status = pb_decode(&stream, AllTypes_fields, &msg); - if (status != false) - { - fprintf(stderr, "Unexpected success in decode\n"); - return 2; - } - else if (strcmp(stream.errmsg, "simulated") != 0) - { - fprintf(stderr, "Wrong error in decode: %s\n", stream.errmsg); - return 3; - } - } - - stream.bytes_left = msglen; - stream.state = &fs; - fs.buffer = buffer; - fs.fail_after = msglen; - status = pb_decode(&stream, AllTypes_fields, &msg); - - if (!status) - { - fprintf(stderr, "Decoding failed: %s\n", stream.errmsg); - return 4; - } - } - - /* Test IO errors on encoding */ - { - bool status; - pb_ostream_t stream = {&write_callback, NULL, SIZE_MAX, 0}; - faulty_stream_t fs; - size_t i; - - for (i = 0; i < msglen; i++) - { - stream.max_size = msglen; - stream.bytes_written = 0; - stream.state = &fs; - fs.buffer = buffer; - fs.fail_after = i; - - status = pb_encode(&stream, AllTypes_fields, &msg); - if (status != false) - { - fprintf(stderr, "Unexpected success in encode\n"); - return 5; - } - else if (strcmp(stream.errmsg, "simulated") != 0) - { - fprintf(stderr, "Wrong error in encode: %s\n", stream.errmsg); - return 6; - } - } - - stream.max_size = msglen; - stream.bytes_written = 0; - stream.state = &fs; - fs.buffer = buffer; - fs.fail_after = msglen; - status = pb_encode(&stream, AllTypes_fields, &msg); - - if (!status) - { - fprintf(stderr, "Encoding failed: %s\n", stream.errmsg); - return 7; - } - } - - return 0; -} - diff --git a/third_party/nanopb/tests/io_errors_pointers/SConscript b/third_party/nanopb/tests/io_errors_pointers/SConscript deleted file mode 100644 index 03727df9c9f..00000000000 --- a/third_party/nanopb/tests/io_errors_pointers/SConscript +++ /dev/null @@ -1,26 +0,0 @@ -# Simulate io errors when encoding and decoding - -Import("env", "malloc_env") - -c = Copy("$TARGET", "$SOURCE") -env.Command("alltypes.proto", "#alltypes/alltypes.proto", c) -env.Command("io_errors.c", "#io_errors/io_errors.c", c) - -env.NanopbProto(["alltypes", "alltypes.options"]) - -ioerr = env.Program(["io_errors.c", "alltypes.pb.c", - "$COMMON/pb_encode_with_malloc.o", - "$COMMON/pb_decode_with_malloc.o", - "$COMMON/pb_common_with_malloc.o", - "$COMMON/malloc_wrappers.o"]) - -# Run tests under valgrind if available -valgrind = env.WhereIs('valgrind') -kwargs = {} -if valgrind: - kwargs['COMMAND'] = valgrind - kwargs['ARGS'] = ["-q", "--error-exitcode=99", ioerr[0].abspath] - -env.RunTest("io_errors.output", [ioerr, "$BUILD/alltypes/encode_alltypes.output"], **kwargs) - - diff --git a/third_party/nanopb/tests/io_errors_pointers/alltypes.options b/third_party/nanopb/tests/io_errors_pointers/alltypes.options deleted file mode 100644 index 52abeb7fec9..00000000000 --- a/third_party/nanopb/tests/io_errors_pointers/alltypes.options +++ /dev/null @@ -1,3 +0,0 @@ -# Generate all fields as pointers. -* type:FT_POINTER - diff --git a/third_party/nanopb/tests/mem_release/SConscript b/third_party/nanopb/tests/mem_release/SConscript deleted file mode 100644 index 6754e28509a..00000000000 --- a/third_party/nanopb/tests/mem_release/SConscript +++ /dev/null @@ -1,13 +0,0 @@ -Import("env", "malloc_env") - -env.NanopbProto("mem_release.proto") - -test = malloc_env.Program(["mem_release.c", - "mem_release.pb.c", - "$COMMON/pb_encode_with_malloc.o", - "$COMMON/pb_decode_with_malloc.o", - "$COMMON/pb_common_with_malloc.o", - "$COMMON/malloc_wrappers.o"]) - -env.RunTest(test) - diff --git a/third_party/nanopb/tests/mem_release/mem_release.c b/third_party/nanopb/tests/mem_release/mem_release.c deleted file mode 100644 index dc6f87dea47..00000000000 --- a/third_party/nanopb/tests/mem_release/mem_release.c +++ /dev/null @@ -1,187 +0,0 @@ -/* Make sure that all fields are freed in various scenarios. */ - -#include -#include -#include -#include -#include -#include "mem_release.pb.h" - -#define TEST(x) if (!(x)) { \ - fprintf(stderr, "Test " #x " on line %d failed.\n", __LINE__); \ - return false; \ - } - -static char *test_str_arr[] = {"1", "2", ""}; -static SubMessage test_msg_arr[] = {SubMessage_init_zero, SubMessage_init_zero}; -static pb_extension_t ext1, ext2; - -static void fill_TestMessage(TestMessage *msg) -{ - msg->static_req_submsg.dynamic_str = "12345"; - msg->static_req_submsg.dynamic_str_arr_count = 3; - msg->static_req_submsg.dynamic_str_arr = test_str_arr; - msg->static_req_submsg.dynamic_submsg_count = 2; - msg->static_req_submsg.dynamic_submsg = test_msg_arr; - msg->static_req_submsg.dynamic_submsg[1].dynamic_str = "abc"; - msg->static_opt_submsg.dynamic_str = "abc"; - msg->static_rep_submsg_count = 2; - msg->static_rep_submsg[1].dynamic_str = "abc"; - msg->has_static_opt_submsg = true; - msg->dynamic_submsg = &msg->static_req_submsg; - - msg->extensions = &ext1; - ext1.type = &dynamic_ext; - ext1.dest = &msg->static_req_submsg; - ext1.next = &ext2; - ext2.type = &static_ext; - ext2.dest = &msg->static_req_submsg; - ext2.next = NULL; -} - -/* Basic fields, nested submessages, extensions */ -static bool test_TestMessage() -{ - uint8_t buffer[256]; - size_t msgsize; - - /* Construct a message with various fields filled in */ - { - TestMessage msg = TestMessage_init_zero; - pb_ostream_t stream; - - fill_TestMessage(&msg); - - stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - if (!pb_encode(&stream, TestMessage_fields, &msg)) - { - fprintf(stderr, "Encode failed: %s\n", PB_GET_ERROR(&stream)); - return false; - } - msgsize = stream.bytes_written; - } - - /* Output encoded message for debug */ - SET_BINARY_MODE(stdout); - fwrite(buffer, 1, msgsize, stdout); - - /* Decode memory using dynamic allocation */ - { - TestMessage msg = TestMessage_init_zero; - pb_istream_t stream; - SubMessage ext2_dest; - - msg.extensions = &ext1; - ext1.type = &dynamic_ext; - ext1.dest = NULL; - ext1.next = &ext2; - ext2.type = &static_ext; - ext2.dest = &ext2_dest; - ext2.next = NULL; - - stream = pb_istream_from_buffer(buffer, msgsize); - if (!pb_decode(&stream, TestMessage_fields, &msg)) - { - fprintf(stderr, "Decode failed: %s\n", PB_GET_ERROR(&stream)); - return false; - } - - /* Make sure it encodes back to same data */ - { - uint8_t buffer2[256]; - pb_ostream_t ostream = pb_ostream_from_buffer(buffer2, sizeof(buffer2)); - TEST(pb_encode(&ostream, TestMessage_fields, &msg)); - TEST(ostream.bytes_written == msgsize); - TEST(memcmp(buffer, buffer2, msgsize) == 0); - } - - /* Make sure that malloc counters work */ - TEST(get_alloc_count() > 0); - - /* Make sure that pb_release releases everything */ - pb_release(TestMessage_fields, &msg); - TEST(get_alloc_count() == 0); - - /* Check that double-free is a no-op */ - pb_release(TestMessage_fields, &msg); - TEST(get_alloc_count() == 0); - } - - return true; -} - -/* Oneofs */ -static bool test_OneofMessage() -{ - uint8_t buffer[256]; - size_t msgsize; - - { - pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - - /* Encode first with TestMessage */ - { - OneofMessage msg = OneofMessage_init_zero; - msg.which_msgs = OneofMessage_msg1_tag; - - fill_TestMessage(&msg.msgs.msg1); - - if (!pb_encode(&stream, OneofMessage_fields, &msg)) - { - fprintf(stderr, "Encode failed: %s\n", PB_GET_ERROR(&stream)); - return false; - } - } - - /* Encode second with SubMessage, invoking 'merge' behaviour */ - { - OneofMessage msg = OneofMessage_init_zero; - msg.which_msgs = OneofMessage_msg2_tag; - - msg.first = 999; - msg.msgs.msg2.dynamic_str = "ABCD"; - msg.last = 888; - - if (!pb_encode(&stream, OneofMessage_fields, &msg)) - { - fprintf(stderr, "Encode failed: %s\n", PB_GET_ERROR(&stream)); - return false; - } - } - msgsize = stream.bytes_written; - } - - { - OneofMessage msg = OneofMessage_init_zero; - pb_istream_t stream = pb_istream_from_buffer(buffer, msgsize); - if (!pb_decode(&stream, OneofMessage_fields, &msg)) - { - fprintf(stderr, "Decode failed: %s\n", PB_GET_ERROR(&stream)); - return false; - } - - TEST(msg.first == 999); - TEST(msg.which_msgs == OneofMessage_msg2_tag); - TEST(msg.msgs.msg2.dynamic_str); - TEST(strcmp(msg.msgs.msg2.dynamic_str, "ABCD") == 0); - TEST(msg.msgs.msg2.dynamic_str_arr == NULL); - TEST(msg.msgs.msg2.dynamic_submsg == NULL); - TEST(msg.last == 888); - - pb_release(OneofMessage_fields, &msg); - TEST(get_alloc_count() == 0); - pb_release(OneofMessage_fields, &msg); - TEST(get_alloc_count() == 0); - } - - return true; -} - -int main() -{ - if (test_TestMessage() && test_OneofMessage()) - return 0; - else - return 1; -} - diff --git a/third_party/nanopb/tests/mem_release/mem_release.proto b/third_party/nanopb/tests/mem_release/mem_release.proto deleted file mode 100644 index 0816dc22d61..00000000000 --- a/third_party/nanopb/tests/mem_release/mem_release.proto +++ /dev/null @@ -1,35 +0,0 @@ -syntax = "proto2"; -import "nanopb.proto"; - -message SubMessage -{ - optional string dynamic_str = 1 [(nanopb).type = FT_POINTER]; - repeated string dynamic_str_arr = 2 [(nanopb).type = FT_POINTER]; - repeated SubMessage dynamic_submsg = 3 [(nanopb).type = FT_POINTER]; -} - -message TestMessage -{ - required SubMessage static_req_submsg = 1 [(nanopb).type = FT_STATIC]; - optional SubMessage dynamic_submsg = 2 [(nanopb).type = FT_POINTER]; - optional SubMessage static_opt_submsg = 3 [(nanopb).type = FT_STATIC]; - repeated SubMessage static_rep_submsg = 4 [(nanopb).type = FT_STATIC, (nanopb).max_count=2]; - extensions 100 to 200; -} - -extend TestMessage -{ - optional SubMessage dynamic_ext = 100 [(nanopb).type = FT_POINTER]; - optional SubMessage static_ext = 101 [(nanopb).type = FT_STATIC]; -} - -message OneofMessage -{ - required int32 first = 1; - oneof msgs - { - TestMessage msg1 = 2; - SubMessage msg2 = 3; - } - required int32 last = 4; -} diff --git a/third_party/nanopb/tests/message_sizes/SConscript b/third_party/nanopb/tests/message_sizes/SConscript deleted file mode 100644 index e7524e02589..00000000000 --- a/third_party/nanopb/tests/message_sizes/SConscript +++ /dev/null @@ -1,11 +0,0 @@ -# Test the generation of message size #defines - -Import('env') - -incpath = env.Clone() -incpath.Append(PROTOCPATH = '#message_sizes') - -incpath.NanopbProto("messages1") -incpath.NanopbProto("messages2") - -incpath.Program(['dummy.c', 'messages1.pb.c', 'messages2.pb.c']) diff --git a/third_party/nanopb/tests/message_sizes/dummy.c b/third_party/nanopb/tests/message_sizes/dummy.c deleted file mode 100644 index 767ad463b8a..00000000000 --- a/third_party/nanopb/tests/message_sizes/dummy.c +++ /dev/null @@ -1,9 +0,0 @@ -/* Just test that the file can be compiled successfully. */ - -#include "messages2.pb.h" - -int main() -{ - return xmit_size; -} - diff --git a/third_party/nanopb/tests/message_sizes/messages1.proto b/third_party/nanopb/tests/message_sizes/messages1.proto deleted file mode 100644 index b66fad71f4c..00000000000 --- a/third_party/nanopb/tests/message_sizes/messages1.proto +++ /dev/null @@ -1,29 +0,0 @@ -syntax = "proto2"; - -enum MessageStatus { - FAIL = 0; - OK = 1; -}; - -message MessageInfo { - required fixed32 msg_id = 1; - optional fixed32 interface_id = 2; -} - -message MessageResponseInfo { - required fixed64 interface_id = 1; - required fixed32 seq = 2; - required fixed32 msg_id = 3; -} - -message MessageHeader { - required MessageInfo info = 1; - optional MessageResponseInfo response_info = 2; - optional MessageResponse response = 3; -} - -message MessageResponse { - required MessageStatus status = 1; - required fixed32 seq = 2; -} - diff --git a/third_party/nanopb/tests/message_sizes/messages2.proto b/third_party/nanopb/tests/message_sizes/messages2.proto deleted file mode 100644 index 6761408073e..00000000000 --- a/third_party/nanopb/tests/message_sizes/messages2.proto +++ /dev/null @@ -1,10 +0,0 @@ -syntax = "proto2"; - -import 'nanopb.proto'; -import 'messages1.proto'; - -message xmit { - required MessageHeader header = 1; - required bytes data = 2 [(nanopb).max_size = 128]; -} - diff --git a/third_party/nanopb/tests/missing_fields/SConscript b/third_party/nanopb/tests/missing_fields/SConscript deleted file mode 100644 index 86ba0833a25..00000000000 --- a/third_party/nanopb/tests/missing_fields/SConscript +++ /dev/null @@ -1,8 +0,0 @@ -# Check that the decoder properly detects when required fields are missing. - -Import("env") - -env.NanopbProto("missing_fields") -test = env.Program(["missing_fields.c", "missing_fields.pb.c", "$COMMON/pb_encode.o", "$COMMON/pb_decode.o", "$COMMON/pb_common.o"]) -env.RunTest(test) - diff --git a/third_party/nanopb/tests/missing_fields/missing_fields.c b/third_party/nanopb/tests/missing_fields/missing_fields.c deleted file mode 100644 index 8aded82743b..00000000000 --- a/third_party/nanopb/tests/missing_fields/missing_fields.c +++ /dev/null @@ -1,53 +0,0 @@ -/* Checks that missing required fields are detected properly */ - -#include -#include -#include -#include "missing_fields.pb.h" - -int main() -{ - uint8_t buffer[512]; - size_t size; - - /* Create a message with one missing field */ - { - MissingField msg = {0}; - pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - - if (!pb_encode(&stream, MissingField_fields, &msg)) - { - printf("Encode failed.\n"); - return 1; - } - - size = stream.bytes_written; - } - - /* Test that it decodes properly if we don't require that field */ - { - MissingField msg = {0}; - pb_istream_t stream = pb_istream_from_buffer(buffer, size); - - if (!pb_decode(&stream, MissingField_fields, &msg)) - { - printf("Decode failed: %s\n", PB_GET_ERROR(&stream)); - return 2; - } - } - - /* Test that it does *not* decode properly if we require the field */ - { - AllFields msg = {0}; - pb_istream_t stream = pb_istream_from_buffer(buffer, size); - - if (pb_decode(&stream, AllFields_fields, &msg)) - { - printf("Decode didn't detect missing field.\n"); - return 3; - } - } - - return 0; /* All ok */ -} - diff --git a/third_party/nanopb/tests/missing_fields/missing_fields.proto b/third_party/nanopb/tests/missing_fields/missing_fields.proto deleted file mode 100644 index cc5e550b158..00000000000 --- a/third_party/nanopb/tests/missing_fields/missing_fields.proto +++ /dev/null @@ -1,140 +0,0 @@ -/* Test for one missing field among many */ - -syntax = "proto2"; - -message AllFields -{ - required int32 field1 = 1; - required int32 field2 = 2; - required int32 field3 = 3; - required int32 field4 = 4; - required int32 field5 = 5; - required int32 field6 = 6; - required int32 field7 = 7; - required int32 field8 = 8; - required int32 field9 = 9; - required int32 field10 = 10; - required int32 field11 = 11; - required int32 field12 = 12; - required int32 field13 = 13; - required int32 field14 = 14; - required int32 field15 = 15; - required int32 field16 = 16; - required int32 field17 = 17; - required int32 field18 = 18; - required int32 field19 = 19; - required int32 field20 = 20; - required int32 field21 = 21; - required int32 field22 = 22; - required int32 field23 = 23; - required int32 field24 = 24; - required int32 field25 = 25; - required int32 field26 = 26; - required int32 field27 = 27; - required int32 field28 = 28; - required int32 field29 = 29; - required int32 field30 = 30; - required int32 field31 = 31; - required int32 field32 = 32; - required int32 field33 = 33; - required int32 field34 = 34; - required int32 field35 = 35; - required int32 field36 = 36; - required int32 field37 = 37; - required int32 field38 = 38; - required int32 field39 = 39; - required int32 field40 = 40; - required int32 field41 = 41; - required int32 field42 = 42; - required int32 field43 = 43; - required int32 field44 = 44; - required int32 field45 = 45; - required int32 field46 = 46; - required int32 field47 = 47; - required int32 field48 = 48; - required int32 field49 = 49; - required int32 field50 = 50; - required int32 field51 = 51; - required int32 field52 = 52; - required int32 field53 = 53; - required int32 field54 = 54; - required int32 field55 = 55; - required int32 field56 = 56; - required int32 field57 = 57; - required int32 field58 = 58; - required int32 field59 = 59; - required int32 field60 = 60; - required int32 field61 = 61; - required int32 field62 = 62; - required int32 field63 = 63; - required int32 field64 = 64; -} - -message MissingField -{ - required int32 field1 = 1; - required int32 field2 = 2; - required int32 field3 = 3; - required int32 field4 = 4; - required int32 field5 = 5; - required int32 field6 = 6; - required int32 field7 = 7; - required int32 field8 = 8; - required int32 field9 = 9; - required int32 field10 = 10; - required int32 field11 = 11; - required int32 field12 = 12; - required int32 field13 = 13; - required int32 field14 = 14; - required int32 field15 = 15; - required int32 field16 = 16; - required int32 field17 = 17; - required int32 field18 = 18; - required int32 field19 = 19; - required int32 field20 = 20; - required int32 field21 = 21; - required int32 field22 = 22; - required int32 field23 = 23; - required int32 field24 = 24; - required int32 field25 = 25; - required int32 field26 = 26; - required int32 field27 = 27; - required int32 field28 = 28; - required int32 field29 = 29; - required int32 field30 = 30; - required int32 field31 = 31; - required int32 field32 = 32; - required int32 field33 = 33; - required int32 field34 = 34; - required int32 field35 = 35; - required int32 field36 = 36; - required int32 field37 = 37; - required int32 field38 = 38; - required int32 field39 = 39; - required int32 field40 = 40; - required int32 field41 = 41; - required int32 field42 = 42; - required int32 field43 = 43; - required int32 field44 = 44; - required int32 field45 = 45; - required int32 field46 = 46; - required int32 field47 = 47; - required int32 field48 = 48; - required int32 field49 = 49; - required int32 field50 = 50; - required int32 field51 = 51; - required int32 field52 = 52; - required int32 field53 = 53; - required int32 field54 = 54; - required int32 field55 = 55; - required int32 field56 = 56; - required int32 field57 = 57; - required int32 field58 = 58; - required int32 field59 = 59; - required int32 field60 = 60; - required int32 field61 = 61; - required int32 field62 = 62; -/* required int32 field63 = 63; */ - required int32 field64 = 64; -} - diff --git a/third_party/nanopb/tests/multiple_files/SConscript b/third_party/nanopb/tests/multiple_files/SConscript deleted file mode 100644 index b1281e17383..00000000000 --- a/third_party/nanopb/tests/multiple_files/SConscript +++ /dev/null @@ -1,16 +0,0 @@ -# Test that multiple .proto files don't cause name collisions. - -Import("env") - -incpath = env.Clone() -incpath.Append(PROTOCPATH = '#multiple_files') -incpath.Append(CPPPATH = '$BUILD/multiple_files') - -incpath.NanopbProto(["multifile1", "multifile1.options"]) -incpath.NanopbProto("multifile2") -incpath.NanopbProto("subdir/multifile2") -test = incpath.Program(["test_multiple_files.c", "multifile1.pb.c", - "multifile2.pb.c", "subdir/multifile2.pb.c"]) - -env.RunTest(test) - diff --git a/third_party/nanopb/tests/multiple_files/multifile1.options b/third_party/nanopb/tests/multiple_files/multifile1.options deleted file mode 100644 index c44d2669409..00000000000 --- a/third_party/nanopb/tests/multiple_files/multifile1.options +++ /dev/null @@ -1 +0,0 @@ -StaticMessage.repint32 max_count:5 diff --git a/third_party/nanopb/tests/multiple_files/multifile1.proto b/third_party/nanopb/tests/multiple_files/multifile1.proto deleted file mode 100644 index 18f2c672ce0..00000000000 --- a/third_party/nanopb/tests/multiple_files/multifile1.proto +++ /dev/null @@ -1,34 +0,0 @@ -syntax = "proto2"; - -message SubMessage { - optional string stringvalue = 1; - repeated int32 int32value = 2; - repeated fixed32 fixed32value = 3; - repeated fixed64 fixed64value = 4; -} - -message TestMessage { - optional string stringvalue = 1; - repeated int32 int32value = 2; - repeated fixed32 fixed32value = 3; - repeated fixed64 fixed64value = 4; - optional SubMessage submsg = 5; - repeated string repeatedstring = 6; -} - -message StaticMessage { - repeated fixed32 repint32 = 1; -} - -enum SignedEnum { - SE_MIN = -128; - SE_MAX = 127; -} - -enum UnsignedEnum { - UE_MIN = 0; - UE_MAX = 255; -} - - - diff --git a/third_party/nanopb/tests/multiple_files/multifile2.proto b/third_party/nanopb/tests/multiple_files/multifile2.proto deleted file mode 100644 index 4af45fd9acf..00000000000 --- a/third_party/nanopb/tests/multiple_files/multifile2.proto +++ /dev/null @@ -1,22 +0,0 @@ -// Test if including generated header file for this file + implicit include of -// multifile2.pb.h still compiles. Used with test_compiles.c. -syntax = "proto2"; - -import "multifile1.proto"; - -message Callback2Message { - required TestMessage tstmsg = 1; - required SubMessage submsg = 2; -} - -message OneofMessage { - oneof msgs { - StaticMessage tstmsg = 1; - } -} - -message Enums { - required SignedEnum senum = 1; - required UnsignedEnum uenum = 2; -} - diff --git a/third_party/nanopb/tests/multiple_files/subdir/multifile2.proto b/third_party/nanopb/tests/multiple_files/subdir/multifile2.proto deleted file mode 100644 index 847a9290364..00000000000 --- a/third_party/nanopb/tests/multiple_files/subdir/multifile2.proto +++ /dev/null @@ -1,25 +0,0 @@ -syntax = "proto2"; - -package subdir; - -import "multifile1.proto"; - -message Callback2Message { - required TestMessage tstmsg = 1; - required SubMessage submsg = 2; -} - -message OneofMessage { - oneof msgs { - StaticMessage tstmsg = 1; - } -} - -message Enums { - required SignedEnum senum = 1; - required UnsignedEnum uenum = 2; -} - -message SubdirMessage { - required int32 foo = 1 [default = 15]; -} diff --git a/third_party/nanopb/tests/multiple_files/test_multiple_files.c b/third_party/nanopb/tests/multiple_files/test_multiple_files.c deleted file mode 100644 index 70a3e596413..00000000000 --- a/third_party/nanopb/tests/multiple_files/test_multiple_files.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Tests if this still compiles when multiple .proto files are involved. - */ - -#include -#include -#include "unittests.h" -#include "multifile2.pb.h" -#include "subdir/multifile2.pb.h" - -int main() -{ - int status = 0; - - /* Test that included file options are properly loaded */ - TEST(OneofMessage_size == 27); - - /* Check that enum signedness is detected properly */ - TEST(PB_LTYPE(Enums_fields[0].type) == PB_LTYPE_VARINT); - TEST(PB_LTYPE(Enums_fields[1].type) == PB_LTYPE_UVARINT); - - /* Test that subdir file is correctly included */ - { - subdir_SubdirMessage foo = subdir_SubdirMessage_init_default; - TEST(foo.foo == 15); - /* TEST(subdir_OneofMessage_size == 27); */ /* TODO: Issue #172 */ - } - - return status; -} diff --git a/third_party/nanopb/tests/no_errmsg/SConscript b/third_party/nanopb/tests/no_errmsg/SConscript deleted file mode 100644 index 629bfa68433..00000000000 --- a/third_party/nanopb/tests/no_errmsg/SConscript +++ /dev/null @@ -1,28 +0,0 @@ -# Run the alltypes test case, but compile with PB_NO_ERRMSG=1 - -Import("env") - -# Take copy of the files for custom build. -c = Copy("$TARGET", "$SOURCE") -env.Command("alltypes.pb.h", "$BUILD/alltypes/alltypes.pb.h", c) -env.Command("alltypes.pb.c", "$BUILD/alltypes/alltypes.pb.c", c) -env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c) -env.Command("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c) - -# Define the compilation options -opts = env.Clone() -opts.Append(CPPDEFINES = {'PB_NO_ERRMSG': 1}) - -# Build new version of core -strict = opts.Clone() -strict.Append(CFLAGS = strict['CORECFLAGS']) -strict.Object("pb_decode_noerr.o", "$NANOPB/pb_decode.c") -strict.Object("pb_encode_noerr.o", "$NANOPB/pb_encode.c") -strict.Object("pb_common_noerr.o", "$NANOPB/pb_common.c") - -# Now build and run the test normally. -enc = opts.Program(["encode_alltypes.c", "alltypes.pb.c", "pb_encode_noerr.o", "pb_common_noerr.o"]) -dec = opts.Program(["decode_alltypes.c", "alltypes.pb.c", "pb_decode_noerr.o", "pb_common_noerr.o"]) - -env.RunTest(enc) -env.RunTest([dec, "encode_alltypes.output"]) diff --git a/third_party/nanopb/tests/no_messages/SConscript b/third_party/nanopb/tests/no_messages/SConscript deleted file mode 100644 index 6492e2cf9c1..00000000000 --- a/third_party/nanopb/tests/no_messages/SConscript +++ /dev/null @@ -1,7 +0,0 @@ -# Test that a .proto file without any messages compiles fine. - -Import("env") - -env.NanopbProto("no_messages") -env.Object('no_messages.pb.c') - diff --git a/third_party/nanopb/tests/no_messages/no_messages.proto b/third_party/nanopb/tests/no_messages/no_messages.proto deleted file mode 100644 index 45bb2e6660d..00000000000 --- a/third_party/nanopb/tests/no_messages/no_messages.proto +++ /dev/null @@ -1,9 +0,0 @@ -/* Test that a file without any messages works. */ - -syntax = "proto2"; - -enum Test { - First = 1; -} - - diff --git a/third_party/nanopb/tests/oneof/SConscript b/third_party/nanopb/tests/oneof/SConscript deleted file mode 100644 index 22634fb0b20..00000000000 --- a/third_party/nanopb/tests/oneof/SConscript +++ /dev/null @@ -1,33 +0,0 @@ -# Test the 'oneof' feature for generating C unions. - -Import('env') - -import re - -match = None -if 'PROTOC_VERSION' in env: - match = re.search('([0-9]+).([0-9]+).([0-9]+)', env['PROTOC_VERSION']) - -if match: - version = map(int, match.groups()) - -# Oneof is supported by protoc >= 2.6.0 -if env.GetOption('clean') or (match and (version[0] > 2 or (version[0] == 2 and version[1] >= 6))): - env.NanopbProto('oneof') - - enc = env.Program(['encode_oneof.c', - 'oneof.pb.c', - '$COMMON/pb_encode.o', - '$COMMON/pb_common.o']) - - dec = env.Program(['decode_oneof.c', - 'oneof.pb.c', - '$COMMON/pb_decode.o', - '$COMMON/pb_common.o']) - - env.RunTest("message1.pb", enc, ARGS = ['1']) - env.RunTest("message1.txt", [dec, 'message1.pb'], ARGS = ['1']) - env.RunTest("message2.pb", enc, ARGS = ['2']) - env.RunTest("message2.txt", [dec, 'message2.pb'], ARGS = ['2']) - env.RunTest("message3.pb", enc, ARGS = ['3']) - env.RunTest("message3.txt", [dec, 'message3.pb'], ARGS = ['3']) diff --git a/third_party/nanopb/tests/oneof/decode_oneof.c b/third_party/nanopb/tests/oneof/decode_oneof.c deleted file mode 100644 index 37075cd66ef..00000000000 --- a/third_party/nanopb/tests/oneof/decode_oneof.c +++ /dev/null @@ -1,131 +0,0 @@ -/* Decode a message using oneof fields */ - -#include -#include -#include -#include -#include "oneof.pb.h" -#include "test_helpers.h" -#include "unittests.h" - -/* Test the 'OneOfMessage' */ -int test_oneof_1(pb_istream_t *stream, int option) -{ - OneOfMessage msg; - int status = 0; - - /* To better catch initialization errors */ - memset(&msg, 0xAA, sizeof(msg)); - - if (!pb_decode(stream, OneOfMessage_fields, &msg)) - { - printf("Decoding failed: %s\n", PB_GET_ERROR(stream)); - return 1; - } - - /* Check that the basic fields work normally */ - TEST(msg.prefix == 123); - TEST(msg.suffix == 321); - - /* Check that we got the right oneof according to command line */ - if (option == 1) - { - TEST(msg.which_values == OneOfMessage_first_tag); - TEST(msg.values.first == 999); - } - else if (option == 2) - { - TEST(msg.which_values == OneOfMessage_second_tag); - TEST(strcmp(msg.values.second, "abcd") == 0); - } - else if (option == 3) - { - TEST(msg.which_values == OneOfMessage_third_tag); - TEST(msg.values.third.array[0] == 1); - TEST(msg.values.third.array[1] == 2); - TEST(msg.values.third.array[2] == 3); - TEST(msg.values.third.array[3] == 4); - TEST(msg.values.third.array[4] == 5); - } - - return status; -} - - -/* Test the 'PlainOneOfMessage' */ -int test_oneof_2(pb_istream_t *stream, int option) -{ - PlainOneOfMessage msg = PlainOneOfMessage_init_zero; - int status = 0; - - if (!pb_decode(stream, PlainOneOfMessage_fields, &msg)) - { - printf("Decoding failed: %s\n", PB_GET_ERROR(stream)); - return 1; - } - - /* Check that we got the right oneof according to command line */ - if (option == 1) - { - TEST(msg.which_values == OneOfMessage_first_tag); - TEST(msg.values.first == 999); - } - else if (option == 2) - { - TEST(msg.which_values == OneOfMessage_second_tag); - TEST(strcmp(msg.values.second, "abcd") == 0); - } - else if (option == 3) - { - TEST(msg.which_values == OneOfMessage_third_tag); - TEST(msg.values.third.array[0] == 1); - TEST(msg.values.third.array[1] == 2); - TEST(msg.values.third.array[2] == 3); - TEST(msg.values.third.array[3] == 4); - TEST(msg.values.third.array[4] == 5); - } - - return status; -} - -int main(int argc, char **argv) -{ - uint8_t buffer[OneOfMessage_size]; - size_t count; - int option; - - if (argc != 2) - { - fprintf(stderr, "Usage: decode_oneof [number]\n"); - return 1; - } - option = atoi(argv[1]); - - SET_BINARY_MODE(stdin); - count = fread(buffer, 1, sizeof(buffer), stdin); - - if (!feof(stdin)) - { - printf("Message does not fit in buffer\n"); - return 1; - } - - { - int status = 0; - pb_istream_t stream; - - stream = pb_istream_from_buffer(buffer, count); - status = test_oneof_1(&stream, option); - - if (status != 0) - return status; - - stream = pb_istream_from_buffer(buffer, count); - status = test_oneof_2(&stream, option); - - if (status != 0) - return status; - } - - return 0; -} diff --git a/third_party/nanopb/tests/oneof/encode_oneof.c b/third_party/nanopb/tests/oneof/encode_oneof.c deleted file mode 100644 index 913d2d43896..00000000000 --- a/third_party/nanopb/tests/oneof/encode_oneof.c +++ /dev/null @@ -1,64 +0,0 @@ -/* Encode a message using oneof fields */ - -#include -#include -#include -#include "oneof.pb.h" -#include "test_helpers.h" - -int main(int argc, char **argv) -{ - uint8_t buffer[OneOfMessage_size]; - OneOfMessage msg = OneOfMessage_init_zero; - pb_ostream_t stream; - int option; - - if (argc != 2) - { - fprintf(stderr, "Usage: encode_oneof [number]\n"); - return 1; - } - option = atoi(argv[1]); - - /* Prefix and suffix are used to test that the union does not disturb - * other fields in the same message. */ - msg.prefix = 123; - - /* We encode one of the 'values' fields based on command line argument */ - if (option == 1) - { - msg.which_values = OneOfMessage_first_tag; - msg.values.first = 999; - } - else if (option == 2) - { - msg.which_values = OneOfMessage_second_tag; - strcpy(msg.values.second, "abcd"); - } - else if (option == 3) - { - msg.which_values = OneOfMessage_third_tag; - msg.values.third.array_count = 5; - msg.values.third.array[0] = 1; - msg.values.third.array[1] = 2; - msg.values.third.array[2] = 3; - msg.values.third.array[3] = 4; - msg.values.third.array[4] = 5; - } - - msg.suffix = 321; - - stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - - if (pb_encode(&stream, OneOfMessage_fields, &msg)) - { - SET_BINARY_MODE(stdout); - fwrite(buffer, 1, stream.bytes_written, stdout); - return 0; - } - else - { - fprintf(stderr, "Encoding failed: %s\n", PB_GET_ERROR(&stream)); - return 1; - } -} diff --git a/third_party/nanopb/tests/oneof/oneof.proto b/third_party/nanopb/tests/oneof/oneof.proto deleted file mode 100644 index b4fe56f2b64..00000000000 --- a/third_party/nanopb/tests/oneof/oneof.proto +++ /dev/null @@ -1,32 +0,0 @@ -syntax = "proto2"; - -import 'nanopb.proto'; - -message SubMessage -{ - repeated int32 array = 1 [(nanopb).max_count = 8]; -} - -/* Oneof in a message with other fields */ -message OneOfMessage -{ - required int32 prefix = 1; - oneof values - { - int32 first = 5; - string second = 6 [(nanopb).max_size = 8]; - SubMessage third = 7; - } - required int32 suffix = 99; -} - -/* Oneof in a message by itself */ -message PlainOneOfMessage -{ - oneof values - { - int32 first = 5; - string second = 6 [(nanopb).max_size = 8]; - SubMessage third = 7; - } -} \ No newline at end of file diff --git a/third_party/nanopb/tests/options/SConscript b/third_party/nanopb/tests/options/SConscript deleted file mode 100644 index 89a00fa5ecc..00000000000 --- a/third_party/nanopb/tests/options/SConscript +++ /dev/null @@ -1,9 +0,0 @@ -# Test that the generator options work as expected. - -Import("env") - -env.NanopbProto("options") -env.Object('options.pb.c') - -env.Match(['options.pb.h', 'options.expected']) - diff --git a/third_party/nanopb/tests/options/options.expected b/third_party/nanopb/tests/options/options.expected deleted file mode 100644 index 63ba0fd8926..00000000000 --- a/third_party/nanopb/tests/options/options.expected +++ /dev/null @@ -1,18 +0,0 @@ -char filesize\[20\]; -char msgsize\[30\]; -char fieldsize\[40\]; -pb_callback_t int32_callback; -\sEnumValue1 = 1 -Message5_EnumValue1 -} pb_packed my_packed_struct; -! skipped_field -! SkippedMessage -#define PB_MSG_103 Message3 -#define PB_MSG_104 Message4 -#define PB_MSG_105 Message5 -#define OPTIONS_MESSAGES \\ -\s+PB_MSG\(103,[0-9]*,Message3\) \\ -\s+PB_MSG\(104,-1,Message4\) \\ -\s+PB_MSG\(105,[0-9]*,Message5\) \\ -#define Message5_msgid 105 - diff --git a/third_party/nanopb/tests/options/options.proto b/third_party/nanopb/tests/options/options.proto deleted file mode 100644 index aa722b526d6..00000000000 --- a/third_party/nanopb/tests/options/options.proto +++ /dev/null @@ -1,91 +0,0 @@ -/* Test nanopb option parsing. - * options.expected lists the patterns that are searched for in the output. - */ - -syntax = "proto2"; - -import "nanopb.proto"; - -// File level options -option (nanopb_fileopt).max_size = 20; - -message Message1 -{ - required string filesize = 1; -} - -// Message level options -message Message2 -{ - option (nanopb_msgopt).max_size = 30; - required string msgsize = 1; -} - -// Field level options -message Message3 -{ - option (nanopb_msgopt).msgid = 103; - required string fieldsize = 1 [(nanopb).max_size = 40]; -} - -// Forced callback field -message Message4 -{ - option (nanopb_msgopt).msgid = 104; - required int32 int32_callback = 1 [(nanopb).type = FT_CALLBACK]; -} - -// Short enum names -enum Enum1 -{ - option (nanopb_enumopt).long_names = false; - EnumValue1 = 1; - EnumValue2 = 2; -} - -message EnumTest -{ - required Enum1 field = 1 [default = EnumValue2]; -} - -// Short enum names inside message -message Message5 -{ - option (nanopb_msgopt).msgid = 105; - enum Enum2 - { - option (nanopb_enumopt).long_names = false; - EnumValue1 = 1; - } - required Enum2 field = 1 [default = EnumValue1]; -} - -// Packed structure -message my_packed_struct -{ - option (nanopb_msgopt).packed_struct = true; - optional int32 myfield = 1; -} - -// Message with ignored field -message Message6 -{ - required int32 field1 = 1; - optional int32 skipped_field = 2 [(nanopb).type = FT_IGNORE]; -} - -// Message that is skipped -message SkippedMessage -{ - option (nanopb_msgopt).skip_message = true; - required int32 foo = 1; -} - -// Message with oneof field -message OneofMessage -{ - oneof foo { - int32 bar = 1; - } -} - diff --git a/third_party/nanopb/tests/package_name/SConscript b/third_party/nanopb/tests/package_name/SConscript deleted file mode 100644 index 4afc5037378..00000000000 --- a/third_party/nanopb/tests/package_name/SConscript +++ /dev/null @@ -1,38 +0,0 @@ -# Check that alltypes test case works also when the .proto file defines -# a package name. - -Import("env") - -def set_pkgname(src, dst, pkgname): - data = open(str(src)).read() - placeholder = '// package name placeholder' - assert placeholder in data - data = data.replace(placeholder, 'package %s;' % pkgname) - open(str(dst), 'w').write(data) - -# Build a modified alltypes.proto -env.Command("alltypes.proto", "#alltypes/alltypes.proto", - lambda target, source, env: set_pkgname(source[0], target[0], 'test.package')) -env.Command("alltypes.options", "#alltypes/alltypes.options", Copy("$TARGET", "$SOURCE")) -env.NanopbProto(["alltypes", "alltypes.options"]) - -# Build a modified encode_alltypes.c -def modify_c(target, source, env): - '''Add package name to type names in .c file.''' - - data = open(str(source[0]), 'r').read() - - type_names = ['AllTypes', 'MyEnum', 'HugeEnum'] - for name in type_names: - data = data.replace(name, 'test_package_' + name) - - open(str(target[0]), 'w').write(data) - return 0 -env.Command("encode_alltypes.c", "#alltypes/encode_alltypes.c", modify_c) - -# Encode and compare results to original alltypes testcase -enc = env.Program(["encode_alltypes.c", "alltypes.pb.c", "$COMMON/pb_encode.o", "$COMMON/pb_common.o"]) -refdec = "$BUILD/alltypes/decode_alltypes$PROGSUFFIX" -env.RunTest(enc) -env.Compare(["encode_alltypes.output", "$BUILD/alltypes/encode_alltypes.output"]) - diff --git a/third_party/nanopb/tests/regression/issue_118/SConscript b/third_party/nanopb/tests/regression/issue_118/SConscript deleted file mode 100644 index 833d9dec720..00000000000 --- a/third_party/nanopb/tests/regression/issue_118/SConscript +++ /dev/null @@ -1,12 +0,0 @@ -# Regression test for Issue 118: Short enum names in imported proto files are not honoured - -Import("env") -env = env.Clone() -env.Append(PROTOCPATH = "#regression/issue_118") - -env.NanopbProto("enumdef") -env.Object('enumdef.pb.c') - -env.NanopbProto(["enumuse", "enumdef.proto"]) -env.Object('enumuse.pb.c') - diff --git a/third_party/nanopb/tests/regression/issue_118/enumdef.proto b/third_party/nanopb/tests/regression/issue_118/enumdef.proto deleted file mode 100644 index 46845bc9e26..00000000000 --- a/third_party/nanopb/tests/regression/issue_118/enumdef.proto +++ /dev/null @@ -1,8 +0,0 @@ -syntax = "proto2"; - -import 'nanopb.proto'; - -enum MyEnum { - option (nanopb_enumopt).long_names = false; - FOOBAR = 1; -} diff --git a/third_party/nanopb/tests/regression/issue_118/enumuse.proto b/third_party/nanopb/tests/regression/issue_118/enumuse.proto deleted file mode 100644 index 4afc45211ce..00000000000 --- a/third_party/nanopb/tests/regression/issue_118/enumuse.proto +++ /dev/null @@ -1,7 +0,0 @@ -syntax = "proto2"; - -import 'enumdef.proto'; - -message MyMessage { - required MyEnum myenum = 1 [default = FOOBAR]; -} diff --git a/third_party/nanopb/tests/regression/issue_125/SConscript b/third_party/nanopb/tests/regression/issue_125/SConscript deleted file mode 100644 index f2155e634d0..00000000000 --- a/third_party/nanopb/tests/regression/issue_125/SConscript +++ /dev/null @@ -1,9 +0,0 @@ -# Regression test for Issue 125: Wrong identifier name for extension fields - -Import("env") - -env.NanopbProto(["extensionbug", "extensionbug.options"]) -env.Object('extensionbug.pb.c') - -env.Match(['extensionbug.pb.h', 'extensionbug.expected']) - diff --git a/third_party/nanopb/tests/regression/issue_125/extensionbug.expected b/third_party/nanopb/tests/regression/issue_125/extensionbug.expected deleted file mode 100644 index fc213354052..00000000000 --- a/third_party/nanopb/tests/regression/issue_125/extensionbug.expected +++ /dev/null @@ -1,3 +0,0 @@ -pb_extension_type_t Message2_extras -uint32_t field2 - diff --git a/third_party/nanopb/tests/regression/issue_125/extensionbug.options b/third_party/nanopb/tests/regression/issue_125/extensionbug.options deleted file mode 100644 index 30b464a4151..00000000000 --- a/third_party/nanopb/tests/regression/issue_125/extensionbug.options +++ /dev/null @@ -1,4 +0,0 @@ -* type:FT_IGNORE - -Message2.extras type:FT_STATIC -Message2.field2 type:FT_STATIC diff --git a/third_party/nanopb/tests/regression/issue_125/extensionbug.proto b/third_party/nanopb/tests/regression/issue_125/extensionbug.proto deleted file mode 100644 index fd1e74f105c..00000000000 --- a/third_party/nanopb/tests/regression/issue_125/extensionbug.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto2"; - -message Message1 -{ - optional uint32 fieldA = 1; - extensions 30 to max; -} - -message Message2 -{ - extend Message1 - { - optional Message2 extras = 30; - } - - optional uint32 field1 = 1; - optional uint32 field2 = 2; -} diff --git a/third_party/nanopb/tests/regression/issue_141/SConscript b/third_party/nanopb/tests/regression/issue_141/SConscript deleted file mode 100644 index b6526beda56..00000000000 --- a/third_party/nanopb/tests/regression/issue_141/SConscript +++ /dev/null @@ -1,8 +0,0 @@ -# Regression test for issue 141: wrong encoded size #define for oneof messages - -Import("env") - -env.NanopbProto("testproto") -env.Object('testproto.pb.c') -env.Match(['testproto.pb.h', 'testproto.expected']) - diff --git a/third_party/nanopb/tests/regression/issue_141/testproto.expected b/third_party/nanopb/tests/regression/issue_141/testproto.expected deleted file mode 100644 index 75bc195c8d6..00000000000 --- a/third_party/nanopb/tests/regression/issue_141/testproto.expected +++ /dev/null @@ -1,7 +0,0 @@ -define SubMessage_size \s* 88 -define OneOfMessage_size \s* 113 -define topMessage_size \s* 70 -define MyMessage1_size \s* 46 -define MyMessage2_size \s* 8 -define MyMessage3_size \s* 5 -define MyMessage4_size \s* 18 diff --git a/third_party/nanopb/tests/regression/issue_141/testproto.proto b/third_party/nanopb/tests/regression/issue_141/testproto.proto deleted file mode 100644 index a445c68a2a0..00000000000 --- a/third_party/nanopb/tests/regression/issue_141/testproto.proto +++ /dev/null @@ -1,52 +0,0 @@ -syntax = "proto2"; - -import 'nanopb.proto'; - -message SubMessage -{ - repeated int32 array = 1 [(nanopb).max_count = 8]; -} - -message OneOfMessage -{ - required int32 prefix = 1; - oneof values - { - int32 first = 5; - string second = 6 [(nanopb).max_size = 8]; - SubMessage third = 7; - } - required int32 suffix = 99; -} - -message topMessage { - required int32 start = 1; - oneof msg { - MyMessage1 msg1 = 2; - MyMessage2 msg2 = 3; - } - required int32 end = 4; -} - -message MyMessage1 { - required uint32 n1 = 1; - required uint32 n2 = 2; - required string s = 3 [(nanopb).max_size = 32]; -} - -message MyMessage2 { - required uint32 num = 1; - required bool b = 2; -} - -message MyMessage3 { - required bool bbb = 1; - required string ss = 2 [(nanopb).max_size = 1]; -} - -message MyMessage4 { - required bool bbbb = 1; - required string sss = 2 [(nanopb).max_size = 2]; - required uint32 num = 3; - required uint32 num2 = 4; -} diff --git a/third_party/nanopb/tests/regression/issue_145/SConscript b/third_party/nanopb/tests/regression/issue_145/SConscript deleted file mode 100644 index 0b793a7ac49..00000000000 --- a/third_party/nanopb/tests/regression/issue_145/SConscript +++ /dev/null @@ -1,9 +0,0 @@ -# Regression test for Issue 145: Allow /* */ and // comments in .options files - -Import("env") - -env.NanopbProto(["comments", "comments.options"]) -env.Object('comments.pb.c') - -env.Match(['comments.pb.h', 'comments.expected']) - diff --git a/third_party/nanopb/tests/regression/issue_145/comments.expected b/third_party/nanopb/tests/regression/issue_145/comments.expected deleted file mode 100644 index 7f874587b7f..00000000000 --- a/third_party/nanopb/tests/regression/issue_145/comments.expected +++ /dev/null @@ -1,3 +0,0 @@ -char foo\[5\]; -char bar\[16\]; - diff --git a/third_party/nanopb/tests/regression/issue_145/comments.options b/third_party/nanopb/tests/regression/issue_145/comments.options deleted file mode 100644 index 89959ba2358..00000000000 --- a/third_party/nanopb/tests/regression/issue_145/comments.options +++ /dev/null @@ -1,6 +0,0 @@ -/* Block comment */ -# Line comment -// Line comment -DummyMessage.foo /* Block comment */ max_size:5 -DummyMessage.bar max_size:16 # Line comment ### - diff --git a/third_party/nanopb/tests/regression/issue_145/comments.proto b/third_party/nanopb/tests/regression/issue_145/comments.proto deleted file mode 100644 index 621779f54ce..00000000000 --- a/third_party/nanopb/tests/regression/issue_145/comments.proto +++ /dev/null @@ -1,7 +0,0 @@ -syntax = "proto2"; - -message DummyMessage { - required string foo = 1; - required string bar = 2; -} - diff --git a/third_party/nanopb/tests/regression/issue_166/SConscript b/third_party/nanopb/tests/regression/issue_166/SConscript deleted file mode 100644 index c50b91939db..00000000000 --- a/third_party/nanopb/tests/regression/issue_166/SConscript +++ /dev/null @@ -1,13 +0,0 @@ -# Verify that the maximum encoded size is calculated properly -# for enums. - -Import('env') - -env.NanopbProto('enums') - -p = env.Program(["enum_encoded_size.c", - "enums.pb.c", - "$COMMON/pb_encode.o", - "$COMMON/pb_common.o"]) -env.RunTest(p) - diff --git a/third_party/nanopb/tests/regression/issue_166/enum_encoded_size.c b/third_party/nanopb/tests/regression/issue_166/enum_encoded_size.c deleted file mode 100644 index 84e1c7de717..00000000000 --- a/third_party/nanopb/tests/regression/issue_166/enum_encoded_size.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include -#include "unittests.h" -#include "enums.pb.h" - -int main() -{ - int status = 0; - - uint8_t buf[256]; - SignedMsg msg1; - UnsignedMsg msg2; - pb_ostream_t s; - - { - COMMENT("Test negative value of signed enum"); - /* Negative value should take up the maximum size */ - msg1.value = SignedEnum_SE_MIN; - s = pb_ostream_from_buffer(buf, sizeof(buf)); - TEST(pb_encode(&s, SignedMsg_fields, &msg1)); - TEST(s.bytes_written == SignedMsg_size); - - COMMENT("Test positive value of signed enum"); - /* Positive value should be smaller */ - msg1.value = SignedEnum_SE_MAX; - s = pb_ostream_from_buffer(buf, sizeof(buf)); - TEST(pb_encode(&s, SignedMsg_fields, &msg1)); - TEST(s.bytes_written < SignedMsg_size); - } - - { - COMMENT("Test positive value of unsigned enum"); - /* This should take up the maximum size */ - msg2.value = UnsignedEnum_UE_MAX; - s = pb_ostream_from_buffer(buf, sizeof(buf)); - TEST(pb_encode(&s, UnsignedMsg_fields, &msg2)); - TEST(s.bytes_written == UnsignedMsg_size); - } - - return status; -} - diff --git a/third_party/nanopb/tests/regression/issue_166/enums.proto b/third_party/nanopb/tests/regression/issue_166/enums.proto deleted file mode 100644 index 36948044bf9..00000000000 --- a/third_party/nanopb/tests/regression/issue_166/enums.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto2"; - -enum SignedEnum { - SE_MIN = -1; - SE_MAX = 255; -} - -enum UnsignedEnum { - UE_MAX = 65536; -} - -message SignedMsg { - required SignedEnum value = 1; -} - -message UnsignedMsg { - required UnsignedEnum value = 1; -} diff --git a/third_party/nanopb/tests/regression/issue_172/SConscript b/third_party/nanopb/tests/regression/issue_172/SConscript deleted file mode 100644 index 49c919e8059..00000000000 --- a/third_party/nanopb/tests/regression/issue_172/SConscript +++ /dev/null @@ -1,16 +0,0 @@ -# Verify that _size define is generated for messages that have -# includes from another directory. - -Import('env') - -incpath = env.Clone() -incpath.Append(PROTOCPATH="#regression/issue_172/submessage") -incpath.Append(CPPPATH="$BUILD/regression/issue_172/submessage") -incpath.NanopbProto('test') -incpath.NanopbProto(['submessage/submessage', 'submessage/submessage.options']) - -p = incpath.Program(["msg_size.c", - "test.pb.c", - "submessage/submessage.pb.c"]) - - diff --git a/third_party/nanopb/tests/regression/issue_172/msg_size.c b/third_party/nanopb/tests/regression/issue_172/msg_size.c deleted file mode 100644 index be45acb4fb5..00000000000 --- a/third_party/nanopb/tests/regression/issue_172/msg_size.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "test.pb.h" - -PB_STATIC_ASSERT(testmessage_size >= 1+1+1+1+16, TESTMESSAGE_SIZE_IS_WRONG) - -int main() -{ - return 0; -} - diff --git a/third_party/nanopb/tests/regression/issue_172/submessage/submessage.options b/third_party/nanopb/tests/regression/issue_172/submessage/submessage.options deleted file mode 100644 index 12fb1984e90..00000000000 --- a/third_party/nanopb/tests/regression/issue_172/submessage/submessage.options +++ /dev/null @@ -1 +0,0 @@ -submessage.data max_size: 16 diff --git a/third_party/nanopb/tests/regression/issue_172/submessage/submessage.proto b/third_party/nanopb/tests/regression/issue_172/submessage/submessage.proto deleted file mode 100644 index ce6804afa85..00000000000 --- a/third_party/nanopb/tests/regression/issue_172/submessage/submessage.proto +++ /dev/null @@ -1,4 +0,0 @@ -syntax = "proto2"; -message submessage { - required bytes data = 1; -} diff --git a/third_party/nanopb/tests/regression/issue_172/test.proto b/third_party/nanopb/tests/regression/issue_172/test.proto deleted file mode 100644 index fbd97be5b0d..00000000000 --- a/third_party/nanopb/tests/regression/issue_172/test.proto +++ /dev/null @@ -1,6 +0,0 @@ -syntax = "proto2"; -import "submessage.proto"; - -message testmessage { - optional submessage sub = 1; -} diff --git a/third_party/nanopb/tests/regression/issue_188/SConscript b/third_party/nanopb/tests/regression/issue_188/SConscript deleted file mode 100644 index 6bc32712b12..00000000000 --- a/third_party/nanopb/tests/regression/issue_188/SConscript +++ /dev/null @@ -1,6 +0,0 @@ -# Regression test for issue with Enums inside OneOf. - -Import('env') - -env.NanopbProto('oneof') - diff --git a/third_party/nanopb/tests/regression/issue_188/oneof.proto b/third_party/nanopb/tests/regression/issue_188/oneof.proto deleted file mode 100644 index e37f5c02767..00000000000 --- a/third_party/nanopb/tests/regression/issue_188/oneof.proto +++ /dev/null @@ -1,29 +0,0 @@ -syntax = "proto2"; - -message MessageOne -{ - required uint32 one = 1; - required uint32 two = 2; - required uint32 three = 3; - required int32 four = 4; -} - -enum EnumTwo -{ - SOME_ENUM_1 = 1; - SOME_ENUM_2 = 5; - SOME_ENUM_3 = 6; - SOME_ENUM_4 = 9; - SOME_ENUM_5 = 10; - SOME_ENUM_6 = 12; - SOME_ENUM_7 = 39; - SOME_ENUM_8 = 401; -} - -message OneofMessage -{ - oneof payload { - MessageOne message = 1; - EnumTwo enum = 2; - } -} diff --git a/third_party/nanopb/tests/regression/issue_195/SConscript b/third_party/nanopb/tests/regression/issue_195/SConscript deleted file mode 100644 index 78326d325e6..00000000000 --- a/third_party/nanopb/tests/regression/issue_195/SConscript +++ /dev/null @@ -1,10 +0,0 @@ -# Regression test for Issue 195: Message size not calculated if a submessage includes -# bytes. Basically a non-working #define being generated. - -Import("env") - -env.NanopbProto(["test"]) -env.Object('test.pb.c') - -env.Match(['test.pb.h', 'test.expected']) - diff --git a/third_party/nanopb/tests/regression/issue_195/test.expected b/third_party/nanopb/tests/regression/issue_195/test.expected deleted file mode 100644 index 83ea7ab8692..00000000000 --- a/third_party/nanopb/tests/regression/issue_195/test.expected +++ /dev/null @@ -1 +0,0 @@ -/\* TestMessage_size depends diff --git a/third_party/nanopb/tests/regression/issue_195/test.proto b/third_party/nanopb/tests/regression/issue_195/test.proto deleted file mode 100644 index 7a77d69dc51..00000000000 --- a/third_party/nanopb/tests/regression/issue_195/test.proto +++ /dev/null @@ -1,8 +0,0 @@ -message TestMessage { - required uint32 id = 1; - required bytes payload = 2; -} -message EncapsulatedMessage { - required uint32 id = 1; - required TestMessage test = 2; -} diff --git a/third_party/nanopb/tests/regression/issue_203/SConscript b/third_party/nanopb/tests/regression/issue_203/SConscript deleted file mode 100644 index 8b4d6cc702b..00000000000 --- a/third_party/nanopb/tests/regression/issue_203/SConscript +++ /dev/null @@ -1,9 +0,0 @@ -# Regression test for issue with multiple files generated at once - -Import('env') - -env.Command(['file1.pb.c', 'file1.pb.h', 'file2.pb.c', 'file2.pb.h'], ['file1.proto', 'file2.proto'], - env['NANOPB_PROTO_CMD']) - -env.Object('file1.pb.c') -env.Object('file2.pb.c') diff --git a/third_party/nanopb/tests/regression/issue_203/file1.proto b/third_party/nanopb/tests/regression/issue_203/file1.proto deleted file mode 100644 index dae250b8426..00000000000 --- a/third_party/nanopb/tests/regression/issue_203/file1.proto +++ /dev/null @@ -1,10 +0,0 @@ -syntax = "proto2"; - -message SubMessage1 { - required int32 foo = 1; -} - -message Message1 { - required SubMessage1 bar = 1; -} - diff --git a/third_party/nanopb/tests/regression/issue_203/file2.proto b/third_party/nanopb/tests/regression/issue_203/file2.proto deleted file mode 100644 index 513b0f0d778..00000000000 --- a/third_party/nanopb/tests/regression/issue_203/file2.proto +++ /dev/null @@ -1,10 +0,0 @@ -syntax = "proto2"; - -message SubMessage2 { - required int32 foo = 1; -} - -message Message2 { - required SubMessage2 bar = 1; -} - diff --git a/third_party/nanopb/tests/regression/issue_205/SConscript b/third_party/nanopb/tests/regression/issue_205/SConscript deleted file mode 100644 index ed8899ddfc7..00000000000 --- a/third_party/nanopb/tests/regression/issue_205/SConscript +++ /dev/null @@ -1,14 +0,0 @@ -# Check that pb_release() correctly handles corrupted size fields of -# static arrays. - -Import('env', 'malloc_env') - -env.NanopbProto('size_corruption') - -p = malloc_env.Program(["size_corruption.c", - "size_corruption.pb.c", - "$COMMON/pb_decode_with_malloc.o", - "$COMMON/pb_common_with_malloc.o", - "$COMMON/malloc_wrappers.o"]) -env.RunTest(p) - diff --git a/third_party/nanopb/tests/regression/issue_205/size_corruption.c b/third_party/nanopb/tests/regression/issue_205/size_corruption.c deleted file mode 100644 index 08cef45786b..00000000000 --- a/third_party/nanopb/tests/regression/issue_205/size_corruption.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "size_corruption.pb.h" -#include - -int main() -{ - MainMessage msg = MainMessage_init_zero; - msg.bar_count = (pb_size_t)-1; - pb_release(MainMessage_fields, &msg); - - return 0; -} - diff --git a/third_party/nanopb/tests/regression/issue_205/size_corruption.proto b/third_party/nanopb/tests/regression/issue_205/size_corruption.proto deleted file mode 100644 index 6c9c2453abd..00000000000 --- a/third_party/nanopb/tests/regression/issue_205/size_corruption.proto +++ /dev/null @@ -1,11 +0,0 @@ -syntax = "proto2"; -import 'nanopb.proto'; - -message SubMessage { - repeated int32 foo = 1 [(nanopb).type = FT_POINTER]; -} - -message MainMessage { - repeated SubMessage bar = 1 [(nanopb).max_count = 5]; -} - diff --git a/third_party/nanopb/tests/site_scons/site_init.py b/third_party/nanopb/tests/site_scons/site_init.py deleted file mode 100644 index da5f6d65176..00000000000 --- a/third_party/nanopb/tests/site_scons/site_init.py +++ /dev/null @@ -1,109 +0,0 @@ -import subprocess -import sys -import re - -try: - # Make terminal colors work on windows - import colorama - colorama.init() -except ImportError: - pass - -def add_nanopb_builders(env): - '''Add the necessary builder commands for nanopb tests.''' - - # Build command that runs a test program and saves the output - def run_test(target, source, env): - if len(source) > 1: - infile = open(str(source[1])) - else: - infile = None - - if env.has_key("COMMAND"): - args = [env["COMMAND"]] - else: - args = [str(source[0])] - - if env.has_key('ARGS'): - args.extend(env['ARGS']) - - print 'Command line: ' + str(args) - pipe = subprocess.Popen(args, - stdin = infile, - stdout = open(str(target[0]), 'w'), - stderr = sys.stderr) - result = pipe.wait() - if result == 0: - print '\033[32m[ OK ]\033[0m Ran ' + args[0] - else: - print '\033[31m[FAIL]\033[0m Program ' + args[0] + ' returned ' + str(result) - return result - - run_test_builder = Builder(action = run_test, - suffix = '.output') - env.Append(BUILDERS = {'RunTest': run_test_builder}) - - # Build command that decodes a message using protoc - def decode_actions(source, target, env, for_signature): - esc = env['ESCAPE'] - dirs = ' '.join(['-I' + esc(env.GetBuildPath(d)) for d in env['PROTOCPATH']]) - return '$PROTOC $PROTOCFLAGS %s --decode=%s %s <%s >%s' % ( - dirs, env['MESSAGE'], esc(str(source[1])), esc(str(source[0])), esc(str(target[0]))) - - decode_builder = Builder(generator = decode_actions, - suffix = '.decoded') - env.Append(BUILDERS = {'Decode': decode_builder}) - - # Build command that encodes a message using protoc - def encode_actions(source, target, env, for_signature): - esc = env['ESCAPE'] - dirs = ' '.join(['-I' + esc(env.GetBuildPath(d)) for d in env['PROTOCPATH']]) - return '$PROTOC $PROTOCFLAGS %s --encode=%s %s <%s >%s' % ( - dirs, env['MESSAGE'], esc(str(source[1])), esc(str(source[0])), esc(str(target[0]))) - - encode_builder = Builder(generator = encode_actions, - suffix = '.encoded') - env.Append(BUILDERS = {'Encode': encode_builder}) - - # Build command that asserts that two files be equal - def compare_files(target, source, env): - data1 = open(str(source[0]), 'rb').read() - data2 = open(str(source[1]), 'rb').read() - if data1 == data2: - print '\033[32m[ OK ]\033[0m Files equal: ' + str(source[0]) + ' and ' + str(source[1]) - return 0 - else: - print '\033[31m[FAIL]\033[0m Files differ: ' + str(source[0]) + ' and ' + str(source[1]) - return 1 - - compare_builder = Builder(action = compare_files, - suffix = '.equal') - env.Append(BUILDERS = {'Compare': compare_builder}) - - # Build command that checks that each pattern in source2 is found in source1. - def match_files(target, source, env): - data = open(str(source[0]), 'rU').read() - patterns = open(str(source[1])) - for pattern in patterns: - if pattern.strip(): - invert = False - if pattern.startswith('! '): - invert = True - pattern = pattern[2:] - - status = re.search(pattern.strip(), data, re.MULTILINE) - - if not status and not invert: - print '\033[31m[FAIL]\033[0m Pattern not found in ' + str(source[0]) + ': ' + pattern - return 1 - elif status and invert: - print '\033[31m[FAIL]\033[0m Pattern should not exist, but does in ' + str(source[0]) + ': ' + pattern - return 1 - else: - print '\033[32m[ OK ]\033[0m All patterns found in ' + str(source[0]) - return 0 - - match_builder = Builder(action = match_files, suffix = '.matched') - env.Append(BUILDERS = {'Match': match_builder}) - - diff --git a/third_party/nanopb/tests/site_scons/site_tools/nanopb.py b/third_party/nanopb/tests/site_scons/site_tools/nanopb.py deleted file mode 100644 index c72a45d3b4d..00000000000 --- a/third_party/nanopb/tests/site_scons/site_tools/nanopb.py +++ /dev/null @@ -1,126 +0,0 @@ -''' -Scons Builder for nanopb .proto definitions. - -This tool will locate the nanopb generator and use it to generate .pb.c and -.pb.h files from the .proto files. - -Basic example -------------- -# Build myproto.pb.c and myproto.pb.h from myproto.proto -myproto = env.NanopbProto("myproto") - -# Link nanopb core to the program -env.Append(CPPPATH = "$NANOB") -myprog = env.Program(["myprog.c", myproto, "$NANOPB/pb_encode.c", "$NANOPB/pb_decode.c"]) - -Configuration options ---------------------- -Normally, this script is used in the test environment of nanopb and it locates -the nanopb generator by a relative path. If this script is used in another -application, the path to nanopb root directory has to be defined: - -env.SetDefault(NANOPB = "path/to/nanopb") - -Additionally, the path to protoc and the options to give to protoc can be -defined manually: - -env.SetDefault(PROTOC = "path/to/protoc") -env.SetDefault(PROTOCFLAGS = "--plugin=protoc-gen-nanopb=path/to/protoc-gen-nanopb") -''' - -import SCons.Action -import SCons.Builder -import SCons.Util -import os.path - -class NanopbWarning(SCons.Warnings.Warning): - pass -SCons.Warnings.enableWarningClass(NanopbWarning) - -def _detect_nanopb(env): - '''Find the path to nanopb root directory.''' - if env.has_key('NANOPB'): - # Use nanopb dir given by user - return env['NANOPB'] - - p = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')) - if os.path.isdir(p) and os.path.isfile(os.path.join(p, 'pb.h')): - # Assume we are running under tests/site_scons/site_tools - return p - - raise SCons.Errors.StopError(NanopbWarning, - "Could not find the nanopb root directory") - -def _detect_protoc(env): - '''Find the path to the protoc compiler.''' - if env.has_key('PROTOC'): - # Use protoc defined by user - return env['PROTOC'] - - n = _detect_nanopb(env) - p1 = os.path.join(n, 'generator-bin', 'protoc' + env['PROGSUFFIX']) - if os.path.exists(p1): - # Use protoc bundled with binary package - return env['ESCAPE'](p1) - - p = env.WhereIs('protoc') - if p: - # Use protoc from path - return env['ESCAPE'](p) - - raise SCons.Errors.StopError(NanopbWarning, - "Could not find the protoc compiler") - -def _detect_protocflags(env): - '''Find the options to use for protoc.''' - if env.has_key('PROTOCFLAGS'): - return env['PROTOCFLAGS'] - - p = _detect_protoc(env) - n = _detect_nanopb(env) - p1 = os.path.join(n, 'generator-bin', 'protoc' + env['PROGSUFFIX']) - if p == env['ESCAPE'](p1): - # Using the bundled protoc, no options needed - return '' - - e = env['ESCAPE'] - if env['PLATFORM'] == 'win32': - return e('--plugin=protoc-gen-nanopb=' + os.path.join(n, 'generator', 'protoc-gen-nanopb.bat')) - else: - return e('--plugin=protoc-gen-nanopb=' + os.path.join(n, 'generator', 'protoc-gen-nanopb')) - -def _nanopb_proto_actions(source, target, env, for_signature): - esc = env['ESCAPE'] - dirs = ' '.join(['-I' + esc(env.GetBuildPath(d)) for d in env['PROTOCPATH']]) - return '$PROTOC $PROTOCFLAGS %s --nanopb_out=. %s' % (dirs, esc(str(source[0]))) - -def _nanopb_proto_emitter(target, source, env): - basename = os.path.splitext(str(source[0]))[0] - target.append(basename + '.pb.h') - - if os.path.exists(basename + '.options'): - source.append(basename + '.options') - - return target, source - -_nanopb_proto_builder = SCons.Builder.Builder( - generator = _nanopb_proto_actions, - suffix = '.pb.c', - src_suffix = '.proto', - emitter = _nanopb_proto_emitter) - -def generate(env): - '''Add Builder for nanopb protos.''' - - env['NANOPB'] = _detect_nanopb(env) - env['PROTOC'] = _detect_protoc(env) - env['PROTOCFLAGS'] = _detect_protocflags(env) - - env.SetDefault(PROTOCPATH = ['.', os.path.join(env['NANOPB'], 'generator', 'proto')]) - - env.SetDefault(NANOPB_PROTO_CMD = '$PROTOC $PROTOCFLAGS --nanopb_out=. $SOURCES') - env['BUILDERS']['NanopbProto'] = _nanopb_proto_builder - -def exists(env): - return _detect_protoc(env) and _detect_protoc_opts(env) - diff --git a/third_party/nanopb/tests/special_characters/SConscript b/third_party/nanopb/tests/special_characters/SConscript deleted file mode 100644 index 2309cf2ef5b..00000000000 --- a/third_party/nanopb/tests/special_characters/SConscript +++ /dev/null @@ -1,6 +0,0 @@ -# Test that special characters in .proto filenames work. - -Import('env') - -env.NanopbProto("funny-proto+name has.characters.proto") -env.Object("funny-proto+name has.characters.pb.c") diff --git a/third_party/nanopb/tests/special_characters/funny-proto+name has.characters.proto b/third_party/nanopb/tests/special_characters/funny-proto+name has.characters.proto deleted file mode 100644 index 26b2cb1b0af..00000000000 --- a/third_party/nanopb/tests/special_characters/funny-proto+name has.characters.proto +++ /dev/null @@ -1 +0,0 @@ -syntax="proto2"; diff --git a/third_party/nanopb/tests/splint/SConscript b/third_party/nanopb/tests/splint/SConscript deleted file mode 100644 index cd4b5b9df60..00000000000 --- a/third_party/nanopb/tests/splint/SConscript +++ /dev/null @@ -1,16 +0,0 @@ -# Check the nanopb core using splint - -Import('env') - -p = env.WhereIs('splint') - -if p: - env.Command('pb_decode.splint', '$NANOPB/pb_decode.c', - 'splint -f splint/splint.rc $SOURCE 2> $TARGET') - - env.Command('pb_encode.splint', '$NANOPB/pb_encode.c', - 'splint -f splint/splint.rc $SOURCE 2> $TARGET') - - env.Command('pb_common.splint', '$NANOPB/pb_common.c', - 'splint -f splint/splint.rc $SOURCE 2> $TARGET') - diff --git a/third_party/nanopb/tests/splint/splint.rc b/third_party/nanopb/tests/splint/splint.rc deleted file mode 100644 index e47d3c21c0d..00000000000 --- a/third_party/nanopb/tests/splint/splint.rc +++ /dev/null @@ -1,37 +0,0 @@ -+checks -+partial -+matchanyintegral -+strictlib --nullassign --predboolint --predboolptr -+ptrnegate --switchloopbreak -+ignoresigns --infloopsuncon --type - -# splint's memory checks don't quite work without annotations --mustfreeonly --compmempass --nullret --observertrans --statictrans --compdestroy --nullpass --nullstate --compdef --usereleased --temptrans --dependenttrans --kepttrans --branchstate --immediatetrans --mustfreefresh - -# These tests give false positives, compiler typically has -# better warnings for these. --noret --noeffect --usedef - diff --git a/third_party/nanopb/tools/make_linux_package.sh b/third_party/nanopb/tools/make_linux_package.sh deleted file mode 100755 index 6598936a6b2..00000000000 --- a/third_party/nanopb/tools/make_linux_package.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -# Run this script in the top nanopb directory to create a binary package -# for Linux users. - -set -e -set -x - -VERSION=`git describe --always`-linux-x86 -DEST=dist/$VERSION - -rm -rf $DEST -mkdir -p $DEST - -# Export the files from newest commit -git archive HEAD | tar x -C $DEST - -# Rebuild the Python .proto files -make -BC $DEST/generator/proto - -# Make the nanopb generator available as a protoc plugin -cp $DEST/generator/nanopb_generator.py $DEST/generator/protoc-gen-nanopb.py - -# Package the Python libraries -( cd $DEST/generator; bbfreeze nanopb_generator.py protoc-gen-nanopb.py ) -mv $DEST/generator/dist $DEST/generator-bin - -# Remove temp file -rm $DEST/generator/protoc-gen-nanopb.py - -# Package the protoc compiler -cp `which protoc` $DEST/generator-bin/protoc.bin -LIBPROTOC=$(ldd `which protoc` | grep -o '/.*libprotoc[^ ]*') -LIBPROTOBUF=$(ldd `which protoc` | grep -o '/.*libprotobuf[^ ]*') -cp $LIBPROTOC $LIBPROTOBUF $DEST/generator-bin/ -cat > $DEST/generator-bin/protoc << EOF -#!/bin/bash -SCRIPTDIR=\$(dirname "\$0") -export LD_LIBRARY_PATH=\$SCRIPTDIR -export PATH=\$SCRIPTDIR:\$PATH -exec "\$SCRIPTDIR/protoc.bin" "\$@" -EOF -chmod +x $DEST/generator-bin/protoc - -# Tar it all up -( cd dist; tar -czf $VERSION.tar.gz $VERSION ) - diff --git a/third_party/nanopb/tools/make_mac_package.sh b/third_party/nanopb/tools/make_mac_package.sh deleted file mode 100755 index 32bba5cca98..00000000000 --- a/third_party/nanopb/tools/make_mac_package.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -# Run this script in the top nanopb directory to create a binary package -# for Mac OS X users. - -# Requires: protobuf, python-protobuf, pyinstaller - -set -e -set -x - -VERSION=`git describe --always`-macosx-x86 -DEST=dist/$VERSION - -rm -rf $DEST -mkdir -p $DEST - -# Export the files from newest commit -git archive HEAD | tar x -C $DEST - -# Rebuild the Python .proto files -make -BC $DEST/generator/proto - -# Package the Python libraries -( cd $DEST/generator; pyinstaller nanopb_generator.py ) -mv $DEST/generator/dist/nanopb_generator $DEST/generator-bin - -# Remove temp files -rm -rf $DEST/generator/dist $DEST/generator/build $DEST/generator/nanopb_generator.spec - -# Make the nanopb generator available as a protoc plugin -cp $DEST/generator-bin/nanopb_generator $DEST/generator-bin/protoc-gen-nanopb - -# Package the protoc compiler -cp `which protoc` $DEST/generator-bin/protoc.bin -LIBPROTOC=$(otool -L `which protoc` | grep -o '/.*libprotoc[^ ]*') -LIBPROTOBUF=$(otool -L `which protoc` | grep -o '/.*libprotobuf[^ ]*') -cp $LIBPROTOC $LIBPROTOBUF $DEST/generator-bin/ -cat > $DEST/generator-bin/protoc << EOF -#!/bin/bash -SCRIPTDIR=\$(dirname "\$0") -export DYLD_LIBRARY_PATH=\$SCRIPTDIR -export PATH=\$SCRIPTDIR:\$PATH -exec "\$SCRIPTDIR/protoc.bin" "\$@" -EOF -chmod +x $DEST/generator-bin/protoc - -# Tar it all up -( cd dist; tar -czf $VERSION.tar.gz $VERSION ) - diff --git a/third_party/nanopb/tools/make_windows_package.sh b/third_party/nanopb/tools/make_windows_package.sh deleted file mode 100755 index 72de6f3394a..00000000000 --- a/third_party/nanopb/tools/make_windows_package.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash - -# Run this script in the top nanopb directory to create a binary package -# for Windows users. This script is designed to run under MingW/MSYS bash -# and requires the following tools: git, make, zip, unix2dos - -set -e -set -x - -VERSION=`git describe --always`-windows-x86 -DEST=dist/$VERSION - -rm -rf $DEST -mkdir -p $DEST - -# Export the files from newest commit -git archive HEAD | tar x -C $DEST - -# Rebuild the Python .proto files -make -BC $DEST/generator/proto - -# Make the nanopb generator available as a protoc plugin -cp $DEST/generator/nanopb_generator.py $DEST/generator/protoc-gen-nanopb.py - -# Package the Python libraries -( cd $DEST/generator; bbfreeze nanopb_generator.py protoc-gen-nanopb.py ) -mv $DEST/generator/dist $DEST/generator-bin - -# Remove temp file -rm $DEST/generator/protoc-gen-nanopb.py - -# The python interpreter requires MSVCR90.dll. -# FIXME: Find a way around hardcoding this path -cp /c/windows/winsxs/x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4974_none_50940634bcb759cb/MSVCR90.DLL $DEST/generator-bin/ -cat > $DEST/generator-bin/Microsoft.VC90.CRT.manifest < - - - - KSaO8M0iCtPF6YEr79P1dZsnomY= ojDmTgpYMFRKJYkPcM6ckpYkWUU= tVogb8kezDre2mXShlIqpp8ErIg= - -EOF - -# Package the protoc compiler -cp `which protoc.exe` $DEST/generator-bin/ -cp `which MSVCR100.DLL` $DEST/generator-bin/ -cp `which MSVCP100.DLL` $DEST/generator-bin/ - -# Convert line breaks for convenience -find $DEST -name '*.c' -o -name '*.h' -o -name '*.txt' \ - -o -name '*.proto' -o -name '*.py' -o -name '*.options' \ - -exec unix2dos '{}' \; - -# Zip it all up -( cd dist; zip -r $VERSION.zip $VERSION ) diff --git a/third_party/nanopb/tools/set_version.sh b/third_party/nanopb/tools/set_version.sh deleted file mode 100755 index e15a859d8a1..00000000000 --- a/third_party/nanopb/tools/set_version.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -# Run this from the top directory of nanopb tree. -# e.g. user@localhost:~/nanopb$ tools/set_version.sh nanopb-0.1.9-dev -# It sets the version number in pb.h and generator/nanopb_generator.py. - -sed -i -e 's/nanopb_version\s*=\s*"[^"]*"/nanopb_version = "'$1'"/' generator/nanopb_generator.py -sed -i -e 's/#define\s*NANOPB_VERSION\s*.*/#define NANOPB_VERSION '$1'/' pb.h - - diff --git a/tools/codegen/core/gen_nano_proto.sh b/tools/codegen/core/gen_nano_proto.sh deleted file mode 100755 index 15495917467..00000000000 --- a/tools/codegen/core/gen_nano_proto.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/bash - -# Copyright 2016 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Example usage: -# tools/codegen/core/gen_nano_proto.sh \ -# src/proto/grpc/lb/v1/load_balancer.proto \ -# $PWD/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1 \ -# src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1 -# -# Exit statuses: -# 1: Incorrect number of arguments -# 2: Input proto file (1st argument) doesn't exist or is not a regular file. -# 3: Options file for nanopb not found in same dir as the input proto file. -# 4: Output dir not an absolute path. -# 5: Couldn't create output directory (2nd argument). - -set -ex -if [ $# -lt 2 ] || [ $# -gt 3 ]; then - echo "Usage: $0 [grpc path]" - exit 1 -fi - -readonly GRPC_ROOT="$PWD" -readonly INPUT_PROTO="$1" -readonly OUTPUT_DIR="$2" -readonly GRPC_OUTPUT_DIR="${3:-$OUTPUT_DIR}" -readonly EXPECTED_OPTIONS_FILE_PATH="${1%.*}.options" - -if [[ ! -f "$INPUT_PROTO" ]]; then - echo "Input proto file '$INPUT_PROTO' doesn't exist." - exit 2 -fi - -if [[ ! -f "${EXPECTED_OPTIONS_FILE_PATH}" ]]; then - echo "Input proto file may need .options file to be correctly compiled." -fi - -if [[ "${OUTPUT_DIR:0:1}" != '/' ]]; then - echo "The output directory must be an absolute path. Got '$OUTPUT_DIR'" - exit 4 -fi - -mkdir -p "$OUTPUT_DIR" -if [ $? != 0 ]; then - echo "Error creating output directory $OUTPUT_DIR" - exit 5 -fi - -readonly VENV_DIR=$(mktemp -d) -readonly VENV_NAME="nanopb-$(date '+%Y%m%d_%H%M%S_%N')" -pushd $VENV_DIR -virtualenv $VENV_NAME -. $VENV_NAME/bin/activate -popd - -# this should be the same version as the submodule we compile against -# ideally we'd update this as a template to ensure that -pip install protobuf==3.6.0 - -pushd "$(dirname $INPUT_PROTO)" > /dev/null - -protoc \ ---plugin=protoc-gen-nanopb="$GRPC_ROOT/third_party/nanopb/generator/protoc-gen-nanopb" \ ---nanopb_out='-T -Q#include\ \"'"${GRPC_OUTPUT_DIR}"'/%s\" -L#include\ \"pb.h\"'":$OUTPUT_DIR" \ -"$(basename $INPUT_PROTO)" - -deactivate -rm -rf $VENV_DIR - -popd > /dev/null diff --git a/tools/distrib/check_copyright.py b/tools/distrib/check_copyright.py index a67802b2a2c..602a1574a4e 100755 --- a/tools/distrib/check_copyright.py +++ b/tools/distrib/check_copyright.py @@ -75,18 +75,6 @@ _EXEMPT = frozenset(( 'examples/python/multiplex/route_guide_pb2_grpc.py', 'examples/python/route_guide/route_guide_pb2.py', 'examples/python/route_guide/route_guide_pb2_grpc.py', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c', - 'src/core/tsi/alts/handshaker/altscontext.pb.h', - 'src/core/tsi/alts/handshaker/altscontext.pb.c', - 'src/core/tsi/alts/handshaker/handshaker.pb.h', - 'src/core/tsi/alts/handshaker/handshaker.pb.c', - 'src/core/tsi/alts/handshaker/transport_security_common.pb.h', - 'src/core/tsi/alts/handshaker/transport_security_common.pb.c', # An older file originally from outside gRPC. 'src/php/tests/bootstrap.php', diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 3e6b641c8e4..3b7af742baa 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1292,10 +1292,6 @@ src/cpp/util/byte_buffer_cc.cc \ src/cpp/util/status.cc \ src/cpp/util/string_ref.cc \ src/cpp/util/time_cc.cc \ -third_party/nanopb/pb.h \ -third_party/nanopb/pb_common.h \ -third_party/nanopb/pb_decode.h \ -third_party/nanopb/pb_encode.h \ third_party/upb/upb/decode.c \ third_party/upb/upb/decode.h \ third_party/upb/upb/encode.c \ diff --git a/tools/run_tests/sanity/check_bazel_workspace.py b/tools/run_tests/sanity/check_bazel_workspace.py index 73b13a883d8..ea9ad81c1f6 100755 --- a/tools/run_tests/sanity/check_bazel_workspace.py +++ b/tools/run_tests/sanity/check_bazel_workspace.py @@ -49,7 +49,6 @@ _GRPC_DEP_NAMES = [ 'com_google_protobuf', 'com_github_google_googletest', 'com_github_gflags_gflags', - 'com_github_nanopb_nanopb', 'com_github_google_benchmark', 'com_github_cares_cares', 'com_google_absl', @@ -147,12 +146,9 @@ names_without_bazel_only_deps = names_and_urls.keys() for dep_name in _GRPC_BAZEL_ONLY_DEPS: names_without_bazel_only_deps.remove(dep_name) archive_urls = [names_and_urls[name] for name in names_without_bazel_only_deps] -# Exclude nanopb from the check: it's not a submodule for distribution reasons, -# but it's a workspace dependency to enable users to use their own version. workspace_git_hashes = { re.search(git_hash_pattern, url).group() for url in archive_urls - if 'nanopb' not in url } if len(workspace_git_hashes) == 0: print("(Likely) parse error, did not find any bazel git dependencies.") From 8ce740cfe0dea62ab7eeffdfa218b012af6fc9aa Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 21 Aug 2019 14:24:06 -0700 Subject: [PATCH 1320/1555] Switch py_proto_library from using src to deps to conform with google3 --- bazel/python_rules.bzl | 8 ++++---- bazel/test/python_test_repo/BUILD | 6 +++--- src/proto/grpc/testing/BUILD | 6 +++--- src/proto/grpc/testing/proto2/BUILD.bazel | 4 ++-- src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel | 2 +- .../grpcio_health_checking/grpc_health/v1/BUILD.bazel | 2 +- .../grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index 0f00d53b6fb..12f51f8b172 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -61,22 +61,22 @@ _generate_pb2_src = rule( def py_proto_library( name, - srcs, + deps, **kwargs): """Generate python code for a protobuf. Args: name: The name of the target. - srcs: A list of proto_library dependencies. Must contain a single element. + deps: A list of proto_library dependencies. Must contain a single element. """ codegen_target = "_{}_codegen".format(name) - if len(srcs) != 1: + if len(deps) != 1: fail("Can only compile a single proto at a time.") _generate_pb2_src( name = codegen_target, - deps = srcs, + deps = deps, **kwargs ) diff --git a/bazel/test/python_test_repo/BUILD b/bazel/test/python_test_repo/BUILD index 0df3700ec93..8aba6a78528 100644 --- a/bazel/test/python_test_repo/BUILD +++ b/bazel/test/python_test_repo/BUILD @@ -29,7 +29,7 @@ proto_library( py_proto_library( name = "helloworld_py_pb2", - srcs = [":helloworld_proto"], + deps = [":helloworld_proto"], ) py_grpc_library( @@ -40,12 +40,12 @@ py_grpc_library( py_proto_library( name = "duration_py_pb2", - srcs = ["@com_google_protobuf//:duration_proto"], + deps = ["@com_google_protobuf//:duration_proto"], ) py_proto_library( name = "timestamp_py_pb2", - srcs = ["@com_google_protobuf//:timestamp_proto"], + deps = ["@com_google_protobuf//:timestamp_proto"], ) py_test( diff --git a/src/proto/grpc/testing/BUILD b/src/proto/grpc/testing/BUILD index 8bea8ed7ca0..bc481606500 100644 --- a/src/proto/grpc/testing/BUILD +++ b/src/proto/grpc/testing/BUILD @@ -75,7 +75,7 @@ proto_library( py_proto_library( name = "empty_py_pb2", - srcs = [":empty_proto_descriptor"], + deps = [":empty_proto_descriptor"], ) py_grpc_library( @@ -97,7 +97,7 @@ proto_library( py_proto_library( name = "py_messages_proto", - srcs = [":messages_proto_descriptor"], + deps = [":messages_proto_descriptor"], ) py_grpc_library( @@ -206,7 +206,7 @@ proto_library( py_proto_library( name = "py_test_proto", - srcs = [":test_proto_descriptor"], + deps = [":test_proto_descriptor"], ) py_grpc_library( diff --git a/src/proto/grpc/testing/proto2/BUILD.bazel b/src/proto/grpc/testing/proto2/BUILD.bazel index 668d0a484ea..8acb233302a 100644 --- a/src/proto/grpc/testing/proto2/BUILD.bazel +++ b/src/proto/grpc/testing/proto2/BUILD.bazel @@ -10,7 +10,7 @@ proto_library( py_proto_library( name = "empty2_proto", - srcs = [":empty2_proto_descriptor"], + deps = [":empty2_proto_descriptor"], ) proto_library( @@ -23,6 +23,6 @@ proto_library( py_proto_library( name = "empty2_extensions_proto", - srcs = [":empty2_extensions_proto_descriptor"], + deps = [":empty2_extensions_proto_descriptor"], ) diff --git a/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel b/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel index c0a7e3d3026..5f4e512e9f4 100644 --- a/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel +++ b/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel @@ -3,7 +3,7 @@ package(default_visibility = ["//visibility:public"]) py_proto_library( name = "channelz_py_pb2", - srcs = ["//src/proto/grpc/channelz:channelz_proto_descriptors"], + deps = ["//src/proto/grpc/channelz:channelz_proto_descriptors"], ) py_grpc_library( diff --git a/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel b/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel index 0ee176f0506..62a44df7707 100644 --- a/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel +++ b/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel @@ -3,7 +3,7 @@ package(default_visibility = ["//visibility:public"]) py_proto_library( name = "health_py_pb2", - srcs = ["//src/proto/grpc/health/v1:health_proto_descriptor",], + deps = ["//src/proto/grpc/health/v1:health_proto_descriptor",], ) py_grpc_library( diff --git a/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel b/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel index 49bc517caf1..10077fd9568 100644 --- a/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel +++ b/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel @@ -5,7 +5,7 @@ package(default_visibility = ["//visibility:public"]) py_proto_library( name = "reflection_py_pb2", - srcs = ["//src/proto/grpc/reflection/v1alpha:reflection_proto_descriptor",], + deps = ["//src/proto/grpc/reflection/v1alpha:reflection_proto_descriptor",], ) py_grpc_library( From ba04bafede63e1760385f14f40d8d322699e31ed Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 21 Aug 2019 14:39:54 -0700 Subject: [PATCH 1321/1555] And the examples directory --- examples/python/cancellation/BUILD.bazel | 2 +- examples/python/multiprocessing/BUILD | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/python/cancellation/BUILD.bazel b/examples/python/cancellation/BUILD.bazel index 41b394a07a2..17b1b20168e 100644 --- a/examples/python/cancellation/BUILD.bazel +++ b/examples/python/cancellation/BUILD.bazel @@ -26,7 +26,7 @@ proto_library( py_proto_library( name = "hash_name_py_pb2", - srcs = [":hash_name_proto"], + deps = [":hash_name_proto"], ) py_grpc_library( diff --git a/examples/python/multiprocessing/BUILD b/examples/python/multiprocessing/BUILD index 257523f14bb..490aea0c1e6 100644 --- a/examples/python/multiprocessing/BUILD +++ b/examples/python/multiprocessing/BUILD @@ -23,7 +23,7 @@ proto_library( py_proto_library( name = "prime_proto_pb2", - srcs = [":prime_proto"], + deps = [":prime_proto"], ) py_grpc_library( From 013ac94821951e456ff99f0326caba1bb88bf1e1 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 21 Aug 2019 15:10:02 -0700 Subject: [PATCH 1322/1555] And another --- examples/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/BUILD b/examples/BUILD index 6f801963c6e..1455d25dc76 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -67,7 +67,7 @@ proto_library( py_proto_library( name = "helloworld_py_pb2", - srcs = [":protos/helloworld_proto"], + deps = [":protos/helloworld_proto"], ) py_grpc_library( From 28b06712352ed5e264647437fe3fe6f0de1b9d10 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 21 Aug 2019 15:53:56 -0700 Subject: [PATCH 1323/1555] Make MethodHandler and related interfaces generic --- BUILD | 2 + BUILD.gn | 1 + CMakeLists.txt | 5 +- Makefile | 4 + build.yaml | 1 + gRPC-C++.podspec | 1 + include/grpcpp/impl/codegen/byte_buffer.h | 27 +-- .../impl/codegen/completion_queue_impl.h | 33 ++-- include/grpcpp/impl/codegen/method_handler.h | 73 ++++++++ .../grpcpp/impl/codegen/method_handler_impl.h | 174 ++++++++++-------- .../impl/codegen/security/auth_context.h | 6 +- .../grpcpp/impl/codegen/server_context_impl.h | 31 ++-- .../grpcpp/impl/codegen/server_interface.h | 2 + .../grpcpp/impl/codegen/sync_stream_impl.h | 10 +- include/grpcpp/support/method_handler.h | 24 +++ src/compiler/cpp_generator.cc | 4 +- src/cpp/server/server_cc.cc | 2 +- tools/doxygen/Doxyfile.c++ | 1 + tools/doxygen/Doxyfile.c++.internal | 1 + 19 files changed, 267 insertions(+), 135 deletions(-) create mode 100644 include/grpcpp/impl/codegen/method_handler.h create mode 100644 include/grpcpp/support/method_handler.h diff --git a/BUILD b/BUILD index c510757c35d..04f53e18248 100644 --- a/BUILD +++ b/BUILD @@ -280,6 +280,7 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/support/config.h", "include/grpcpp/support/interceptor.h", "include/grpcpp/support/message_allocator.h", + "include/grpcpp/support/method_handler.h", "include/grpcpp/support/proto_buffer_reader.h", "include/grpcpp/support/proto_buffer_writer.h", "include/grpcpp/support/server_callback.h", @@ -2027,6 +2028,7 @@ grpc_cc_library( "include/grpcpp/impl/codegen/interceptor_common.h", "include/grpcpp/impl/codegen/message_allocator.h", "include/grpcpp/impl/codegen/metadata_map.h", + "include/grpcpp/impl/codegen/method_handler.h", "include/grpcpp/impl/codegen/method_handler_impl.h", "include/grpcpp/impl/codegen/rpc_method.h", "include/grpcpp/impl/codegen/rpc_service_method.h", diff --git a/BUILD.gn b/BUILD.gn index eea022eac51..6ee85b19383 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1107,6 +1107,7 @@ config("grpc_config") { "include/grpcpp/impl/codegen/interceptor_common.h", "include/grpcpp/impl/codegen/message_allocator.h", "include/grpcpp/impl/codegen/metadata_map.h", + "include/grpcpp/impl/codegen/method_handler.h", "include/grpcpp/impl/codegen/method_handler_impl.h", "include/grpcpp/impl/codegen/proto_buffer_reader.h", "include/grpcpp/impl/codegen/proto_buffer_writer.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 65aadb7cf1a..d204d3799da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3480,6 +3480,7 @@ foreach(_hdr include/grpcpp/impl/codegen/interceptor_common.h include/grpcpp/impl/codegen/message_allocator.h include/grpcpp/impl/codegen/metadata_map.h + include/grpcpp/impl/codegen/method_handler.h include/grpcpp/impl/codegen/method_handler_impl.h include/grpcpp/impl/codegen/rpc_method.h include/grpcpp/impl/codegen/rpc_service_method.h @@ -3993,6 +3994,7 @@ foreach(_hdr include/grpcpp/impl/codegen/interceptor_common.h include/grpcpp/impl/codegen/message_allocator.h include/grpcpp/impl/codegen/metadata_map.h + include/grpcpp/impl/codegen/method_handler.h include/grpcpp/impl/codegen/method_handler_impl.h include/grpcpp/impl/codegen/rpc_method.h include/grpcpp/impl/codegen/rpc_service_method.h @@ -4202,6 +4204,7 @@ foreach(_hdr include/grpcpp/impl/codegen/interceptor_common.h include/grpcpp/impl/codegen/message_allocator.h include/grpcpp/impl/codegen/metadata_map.h + include/grpcpp/impl/codegen/method_handler.h include/grpcpp/impl/codegen/method_handler_impl.h include/grpcpp/impl/codegen/rpc_method.h include/grpcpp/impl/codegen/rpc_service_method.h @@ -4580,6 +4583,7 @@ foreach(_hdr include/grpcpp/impl/codegen/interceptor_common.h include/grpcpp/impl/codegen/message_allocator.h include/grpcpp/impl/codegen/metadata_map.h + include/grpcpp/impl/codegen/method_handler.h include/grpcpp/impl/codegen/method_handler_impl.h include/grpcpp/impl/codegen/rpc_method.h include/grpcpp/impl/codegen/rpc_service_method.h @@ -17370,7 +17374,6 @@ target_include_directories(timer_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} diff --git a/Makefile b/Makefile index e28b9bb2f45..ef0a86eb36a 100644 --- a/Makefile +++ b/Makefile @@ -5857,6 +5857,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/interceptor_common.h \ include/grpcpp/impl/codegen/message_allocator.h \ include/grpcpp/impl/codegen/metadata_map.h \ + include/grpcpp/impl/codegen/method_handler.h \ include/grpcpp/impl/codegen/method_handler_impl.h \ include/grpcpp/impl/codegen/rpc_method.h \ include/grpcpp/impl/codegen/rpc_service_method.h \ @@ -6328,6 +6329,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/interceptor_common.h \ include/grpcpp/impl/codegen/message_allocator.h \ include/grpcpp/impl/codegen/metadata_map.h \ + include/grpcpp/impl/codegen/method_handler.h \ include/grpcpp/impl/codegen/method_handler_impl.h \ include/grpcpp/impl/codegen/rpc_method.h \ include/grpcpp/impl/codegen/rpc_service_method.h \ @@ -6506,6 +6508,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/interceptor_common.h \ include/grpcpp/impl/codegen/message_allocator.h \ include/grpcpp/impl/codegen/metadata_map.h \ + include/grpcpp/impl/codegen/method_handler.h \ include/grpcpp/impl/codegen/method_handler_impl.h \ include/grpcpp/impl/codegen/rpc_method.h \ include/grpcpp/impl/codegen/rpc_service_method.h \ @@ -6888,6 +6891,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/impl/codegen/interceptor_common.h \ include/grpcpp/impl/codegen/message_allocator.h \ include/grpcpp/impl/codegen/metadata_map.h \ + include/grpcpp/impl/codegen/method_handler.h \ include/grpcpp/impl/codegen/method_handler_impl.h \ include/grpcpp/impl/codegen/rpc_method.h \ include/grpcpp/impl/codegen/rpc_service_method.h \ diff --git a/build.yaml b/build.yaml index ee5a45e26fd..454ce09facc 100644 --- a/build.yaml +++ b/build.yaml @@ -378,6 +378,7 @@ filegroups: - include/grpcpp/impl/codegen/interceptor_common.h - include/grpcpp/impl/codegen/message_allocator.h - include/grpcpp/impl/codegen/metadata_map.h + - include/grpcpp/impl/codegen/method_handler.h - include/grpcpp/impl/codegen/method_handler_impl.h - include/grpcpp/impl/codegen/rpc_method.h - include/grpcpp/impl/codegen/rpc_service_method.h diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index d71773a7361..80ea8c6b30a 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -186,6 +186,7 @@ Pod::Spec.new do |s| 'include/grpcpp/impl/codegen/interceptor_common.h', 'include/grpcpp/impl/codegen/message_allocator.h', 'include/grpcpp/impl/codegen/metadata_map.h', + 'include/grpcpp/impl/codegen/method_handler.h', 'include/grpcpp/impl/codegen/method_handler_impl.h', 'include/grpcpp/impl/codegen/rpc_method.h', 'include/grpcpp/impl/codegen/rpc_service_method.h', diff --git a/include/grpcpp/impl/codegen/byte_buffer.h b/include/grpcpp/impl/codegen/byte_buffer.h index 0b7be6fc753..7fb678d5f7f 100644 --- a/include/grpcpp/impl/codegen/byte_buffer.h +++ b/include/grpcpp/impl/codegen/byte_buffer.h @@ -36,6 +36,12 @@ template class CallbackUnaryHandler; template class CallbackServerStreamingHandler; +template +class RpcMethodHandler; +template +class ServerStreamingHandler; +template <::grpc::StatusCode code> +class ErrorMethodHandler; } // namespace internal } // namespace grpc_impl @@ -51,21 +57,10 @@ class CallOpSendMessage; template class CallOpRecvMessage; class CallOpGenericRecvMessage; -class MethodHandler; -template -class RpcMethodHandler; -template -class ServerStreamingHandler; -template -class ErrorMethodHandler; class ExternalConnectionAcceptorImpl; template class DeserializeFuncType; class GrpcByteBufferPeer; -template -class RpcMethodHandler; -template -class ServerStreamingHandler; } // namespace internal /// A sequence of bytes. @@ -175,19 +170,17 @@ class ByteBuffer final { friend class internal::CallOpRecvMessage; friend class internal::CallOpGenericRecvMessage; template - friend class RpcMethodHandler; + friend class ::grpc_impl::internal::RpcMethodHandler; template - friend class ServerStreamingHandler; + friend class ::grpc_impl::internal::ServerStreamingHandler; template - friend class internal::RpcMethodHandler; - template - friend class internal::ServerStreamingHandler; + friend class ::grpc_impl::internal::RpcMethodHandler; template friend class ::grpc_impl::internal::CallbackUnaryHandler; template friend class ::grpc_impl::internal::CallbackServerStreamingHandler; template - friend class internal::ErrorMethodHandler; + friend class ::grpc_impl::internal::ErrorMethodHandler; template friend class internal::DeserializeFuncType; friend class ProtoBufferReader; diff --git a/include/grpcpp/impl/codegen/completion_queue_impl.h b/include/grpcpp/impl/codegen/completion_queue_impl.h index 7716a57e84a..7cb3d2288c6 100644 --- a/include/grpcpp/impl/codegen/completion_queue_impl.h +++ b/include/grpcpp/impl/codegen/completion_queue_impl.h @@ -60,6 +60,17 @@ class ServerWriter; namespace internal { template class ServerReaderWriterBody; + +template +class RpcMethodHandler; +template +class ClientStreamingHandler; +template +class ServerStreamingHandler; +template +class TemplatedBidiStreamingHandler; +template <::grpc::StatusCode code> +class ErrorMethodHandler; } // namespace internal } // namespace grpc_impl namespace grpc { @@ -70,18 +81,6 @@ class ServerInterface; namespace internal { class CompletionQueueTag; class RpcMethod; -template -class RpcMethodHandler; -template -class ClientStreamingHandler; -template -class ServerStreamingHandler; -template -class BidiStreamingHandler; -template -class TemplatedBidiStreamingHandler; -template -class ErrorMethodHandler; template class BlockingUnaryCallImpl; template @@ -266,15 +265,15 @@ class CompletionQueue : private ::grpc::GrpcLibraryCodegen { template friend class ::grpc_impl::internal::ServerReaderWriterBody; template - friend class ::grpc::internal::RpcMethodHandler; + friend class ::grpc_impl::internal::RpcMethodHandler; template - friend class ::grpc::internal::ClientStreamingHandler; + friend class ::grpc_impl::internal::ClientStreamingHandler; template - friend class ::grpc::internal::ServerStreamingHandler; + friend class ::grpc_impl::internal::ServerStreamingHandler; template - friend class ::grpc::internal::TemplatedBidiStreamingHandler; + friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler; template <::grpc::StatusCode code> - friend class ::grpc::internal::ErrorMethodHandler; + friend class ::grpc_impl::internal::ErrorMethodHandler; friend class ::grpc_impl::Server; friend class ::grpc_impl::ServerContext; friend class ::grpc::ServerInterface; diff --git a/include/grpcpp/impl/codegen/method_handler.h b/include/grpcpp/impl/codegen/method_handler.h new file mode 100644 index 00000000000..4b0f594f237 --- /dev/null +++ b/include/grpcpp/impl/codegen/method_handler.h @@ -0,0 +1,73 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_H +#define GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_H + +#include + +namespace grpc { + +namespace internal { + +template +using BidiStreamingHandler = + ::grpc_impl::internal::BidiStreamingHandler; + +template +using RpcMethodHandler = + ::grpc_impl::internal::RpcMethodHandler; + +template +using ClientStreamingHandler = + ::grpc_impl::internal::ClientStreamingHandler; + +template +using ServerStreamingHandler = + ::grpc_impl::internal::ServerStreamingHandler; + +template +using TemplatedBidiStreamingHandler = + ::grpc_impl::internal::TemplatedBidiStreamingHandler; + +template +using StreamedUnaryHandler = + ::grpc_impl::internal::StreamedUnaryHandler; + +template +using SplitServerStreamingHandler = + ::grpc_impl::internal::SplitServerStreamingHandler; + +template +using ErrorMethodHandler = ::grpc_impl::internal::ErrorMethodHandler; + +using UnknownMethodHandler = ::grpc_impl::internal::UnknownMethodHandler; + +using ResourceExhaustedHandler = + ::grpc_impl::internal::ResourceExhaustedHandler; + +} // namespace internal + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_H diff --git a/include/grpcpp/impl/codegen/method_handler_impl.h b/include/grpcpp/impl/codegen/method_handler_impl.h index 1903f898ba8..c36599800ca 100644 --- a/include/grpcpp/impl/codegen/method_handler_impl.h +++ b/include/grpcpp/impl/codegen/method_handler_impl.h @@ -22,9 +22,9 @@ #include #include #include -#include +#include -namespace grpc { +namespace grpc_impl { namespace internal { @@ -36,12 +36,13 @@ namespace internal { // Additionally, we don't need to return if we caught an exception or not; // the handling is the same in either case. template -Status CatchingFunctionHandler(Callable&& handler) { +::grpc::Status CatchingFunctionHandler(Callable&& handler) { #if GRPC_ALLOW_EXCEPTIONS try { return handler(); } catch (...) { - return Status(StatusCode::UNKNOWN, "Unexpected error in RPC handling"); + return ::grpc::Status(::grpc::StatusCode::UNKNOWN, + "Unexpected error in RPC handling"); } #else // GRPC_ALLOW_EXCEPTIONS return handler(); @@ -50,18 +51,18 @@ Status CatchingFunctionHandler(Callable&& handler) { /// A wrapper class of an application provided rpc method handler. template -class RpcMethodHandler : public MethodHandler { +class RpcMethodHandler : public ::grpc::internal::MethodHandler { public: RpcMethodHandler( - std::function + std::function<::grpc::Status(ServiceType*, ::grpc_impl::ServerContext*, + const RequestType*, ResponseType*)> func, ServiceType* service) : func_(func), service_(service) {} void RunHandler(const HandlerParameter& param) final { ResponseType rsp; - Status status = param.status; + ::grpc::Status status = param.status; if (status.ok()) { status = CatchingFunctionHandler([this, ¶m, &rsp] { return func_(service_, param.server_context, @@ -71,8 +72,9 @@ class RpcMethodHandler : public MethodHandler { } GPR_CODEGEN_ASSERT(!param.server_context->sent_initial_metadata_); - CallOpSet + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> ops; ops.SendInitialMetadata(¶m.server_context->initial_metadata_, param.server_context->initial_metadata_flags()); @@ -87,13 +89,15 @@ class RpcMethodHandler : public MethodHandler { param.call->cq()->Pluck(&ops); } - void* Deserialize(grpc_call* call, grpc_byte_buffer* req, Status* status, - void** handler_data) final { - ByteBuffer buf; + void* Deserialize(grpc_call* call, grpc_byte_buffer* req, + ::grpc::Status* status, void** handler_data) final { + ::grpc::ByteBuffer buf; buf.set_buffer(req); - auto* request = new (g_core_codegen_interface->grpc_call_arena_alloc( - call, sizeof(RequestType))) RequestType(); - *status = SerializationTraits::Deserialize(&buf, request); + auto* request = + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call, sizeof(RequestType))) RequestType(); + *status = + ::grpc::SerializationTraits::Deserialize(&buf, request); buf.Release(); if (status->ok()) { return request; @@ -104,8 +108,8 @@ class RpcMethodHandler : public MethodHandler { private: /// Application provided rpc handler function. - std::function + std::function<::grpc::Status(ServiceType*, ::grpc_impl::ServerContext*, + const RequestType*, ResponseType*)> func_; // The class the above handler function lives in. ServiceType* service_; @@ -113,24 +117,28 @@ class RpcMethodHandler : public MethodHandler { /// A wrapper class of an application provided client streaming handler. template -class ClientStreamingHandler : public MethodHandler { +class ClientStreamingHandler : public ::grpc::internal::MethodHandler { public: ClientStreamingHandler( - std::function*, ResponseType*)> + std::function<::grpc::Status(ServiceType*, ::grpc_impl::ServerContext*, + ::grpc_impl::ServerReader*, + ResponseType*)> func, ServiceType* service) : func_(func), service_(service) {} void RunHandler(const HandlerParameter& param) final { - ServerReader reader(param.call, param.server_context); + ::grpc_impl::ServerReader reader(param.call, + param.server_context); ResponseType rsp; - Status status = CatchingFunctionHandler([this, ¶m, &reader, &rsp] { - return func_(service_, param.server_context, &reader, &rsp); - }); + ::grpc::Status status = + CatchingFunctionHandler([this, ¶m, &reader, &rsp] { + return func_(service_, param.server_context, &reader, &rsp); + }); - CallOpSet + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> ops; if (!param.server_context->sent_initial_metadata_) { ops.SendInitialMetadata(¶m.server_context->initial_metadata_, @@ -148,27 +156,30 @@ class ClientStreamingHandler : public MethodHandler { } private: - std::function*, ResponseType*)> + std::function<::grpc::Status(ServiceType*, ::grpc_impl::ServerContext*, + ::grpc_impl::ServerReader*, + ResponseType*)> func_; ServiceType* service_; }; /// A wrapper class of an application provided server streaming handler. template -class ServerStreamingHandler : public MethodHandler { +class ServerStreamingHandler : public ::grpc::internal::MethodHandler { public: ServerStreamingHandler( - std::function*)> + std::function<::grpc::Status(ServiceType*, ::grpc_impl::ServerContext*, + const RequestType*, + ::grpc_impl::ServerWriter*)> func, ServiceType* service) : func_(func), service_(service) {} void RunHandler(const HandlerParameter& param) final { - Status status = param.status; + ::grpc::Status status = param.status; if (status.ok()) { - ServerWriter writer(param.call, param.server_context); + ::grpc_impl::ServerWriter writer(param.call, + param.server_context); status = CatchingFunctionHandler([this, ¶m, &writer] { return func_(service_, param.server_context, static_cast(param.request), &writer); @@ -176,7 +187,9 @@ class ServerStreamingHandler : public MethodHandler { static_cast(param.request)->~RequestType(); } - CallOpSet ops; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpServerSendStatus> + ops; if (!param.server_context->sent_initial_metadata_) { ops.SendInitialMetadata(¶m.server_context->initial_metadata_, param.server_context->initial_metadata_flags()); @@ -192,13 +205,15 @@ class ServerStreamingHandler : public MethodHandler { param.call->cq()->Pluck(&ops); } - void* Deserialize(grpc_call* call, grpc_byte_buffer* req, Status* status, - void** handler_data) final { - ByteBuffer buf; + void* Deserialize(grpc_call* call, grpc_byte_buffer* req, + ::grpc::Status* status, void** handler_data) final { + ::grpc::ByteBuffer buf; buf.set_buffer(req); - auto* request = new (g_core_codegen_interface->grpc_call_arena_alloc( - call, sizeof(RequestType))) RequestType(); - *status = SerializationTraits::Deserialize(&buf, request); + auto* request = + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call, sizeof(RequestType))) RequestType(); + *status = + ::grpc::SerializationTraits::Deserialize(&buf, request); buf.Release(); if (status->ok()) { return request; @@ -208,8 +223,9 @@ class ServerStreamingHandler : public MethodHandler { } private: - std::function*)> + std::function<::grpc::Status(ServiceType*, ::grpc_impl::ServerContext*, + const RequestType*, + ::grpc_impl::ServerWriter*)> func_; ServiceType* service_; }; @@ -222,19 +238,22 @@ class ServerStreamingHandler : public MethodHandler { /// Instead, it is expected to be an implicitly-captured argument of func /// (through bind or something along those lines) template -class TemplatedBidiStreamingHandler : public MethodHandler { +class TemplatedBidiStreamingHandler : public ::grpc::internal::MethodHandler { public: TemplatedBidiStreamingHandler( - std::function func) + std::function<::grpc::Status(::grpc_impl::ServerContext*, Streamer*)> + func) : func_(func), write_needed_(WriteNeeded) {} void RunHandler(const HandlerParameter& param) final { Streamer stream(param.call, param.server_context); - Status status = CatchingFunctionHandler([this, ¶m, &stream] { + ::grpc::Status status = CatchingFunctionHandler([this, ¶m, &stream] { return func_(param.server_context, &stream); }); - CallOpSet ops; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpServerSendStatus> + ops; if (!param.server_context->sent_initial_metadata_) { ops.SendInitialMetadata(¶m.server_context->initial_metadata_, param.server_context->initial_metadata_flags()); @@ -244,8 +263,8 @@ class TemplatedBidiStreamingHandler : public MethodHandler { if (write_needed_ && status.ok()) { // If we needed a write but never did one, we need to mark the // status as a fail - status = Status(StatusCode::INTERNAL, - "Service did not provide response message"); + status = ::grpc::Status(::grpc::StatusCode::INTERNAL, + "Service did not provide response message"); } } ops.ServerSendStatus(¶m.server_context->trailing_metadata_, status); @@ -257,59 +276,65 @@ class TemplatedBidiStreamingHandler : public MethodHandler { } private: - std::function func_; + std::function<::grpc::Status(::grpc_impl::ServerContext*, Streamer*)> func_; const bool write_needed_; }; template class BidiStreamingHandler : public TemplatedBidiStreamingHandler< - ServerReaderWriter, false> { + ::grpc_impl::ServerReaderWriter, false> { public: BidiStreamingHandler( - std::function*)> + std::function<::grpc::Status( + ServiceType*, ::grpc_impl::ServerContext*, + ::grpc_impl::ServerReaderWriter*)> func, ServiceType* service) : TemplatedBidiStreamingHandler< - ServerReaderWriter, false>(std::bind( - func, service, std::placeholders::_1, std::placeholders::_2)) {} + ::grpc_impl::ServerReaderWriter, false>( + std::bind(func, service, std::placeholders::_1, + std::placeholders::_2)) {} }; template class StreamedUnaryHandler : public TemplatedBidiStreamingHandler< - ServerUnaryStreamer, true> { + ::grpc_impl::ServerUnaryStreamer, true> { public: explicit StreamedUnaryHandler( - std::function*)> + std::function<::grpc::Status( + ::grpc_impl::ServerContext*, + ::grpc_impl::ServerUnaryStreamer*)> func) : TemplatedBidiStreamingHandler< - ServerUnaryStreamer, true>(func) {} + ::grpc_impl::ServerUnaryStreamer, true>( + func) {} }; template class SplitServerStreamingHandler : public TemplatedBidiStreamingHandler< - ServerSplitStreamer, false> { + ::grpc_impl::ServerSplitStreamer, false> { public: explicit SplitServerStreamingHandler( - std::function*)> + std::function<::grpc::Status( + ::grpc_impl::ServerContext*, + ::grpc_impl::ServerSplitStreamer*)> func) : TemplatedBidiStreamingHandler< - ServerSplitStreamer, false>(func) {} + ::grpc_impl::ServerSplitStreamer, false>( + func) {} }; /// General method handler class for errors that prevent real method use /// e.g., handle unknown method by returning UNIMPLEMENTED error. -template -class ErrorMethodHandler : public MethodHandler { +template <::grpc::StatusCode code> +class ErrorMethodHandler : public ::grpc::internal::MethodHandler { public: template static void FillOps(::grpc_impl::ServerContext* context, T* ops) { - Status status(code, ""); + ::grpc::Status status(code, ""); if (!context->sent_initial_metadata_) { ops->SendInitialMetadata(&context->initial_metadata_, context->initial_metadata_flags()); @@ -322,27 +347,30 @@ class ErrorMethodHandler : public MethodHandler { } void RunHandler(const HandlerParameter& param) final { - CallOpSet ops; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpServerSendStatus> + ops; FillOps(param.server_context, &ops); param.call->PerformOps(&ops); param.call->cq()->Pluck(&ops); } - void* Deserialize(grpc_call* call, grpc_byte_buffer* req, Status* status, - void** handler_data) final { + void* Deserialize(grpc_call* call, grpc_byte_buffer* req, + ::grpc::Status* status, void** handler_data) final { // We have to destroy any request payload if (req != nullptr) { - g_core_codegen_interface->grpc_byte_buffer_destroy(req); + ::grpc::g_core_codegen_interface->grpc_byte_buffer_destroy(req); } return nullptr; } }; -typedef ErrorMethodHandler UnknownMethodHandler; -typedef ErrorMethodHandler +typedef ErrorMethodHandler<::grpc::StatusCode::UNIMPLEMENTED> + UnknownMethodHandler; +typedef ErrorMethodHandler<::grpc::StatusCode::RESOURCE_EXHAUSTED> ResourceExhaustedHandler; } // namespace internal -} // namespace grpc +} // namespace grpc_impl #endif // GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_IMPL_H diff --git a/include/grpcpp/impl/codegen/security/auth_context.h b/include/grpcpp/impl/codegen/security/auth_context.h index 0e30f7cc3f4..6c0089ca424 100644 --- a/include/grpcpp/impl/codegen/security/auth_context.h +++ b/include/grpcpp/impl/codegen/security/auth_context.h @@ -32,7 +32,7 @@ struct grpc_auth_property_iterator; namespace grpc { class SecureAuthContext; -typedef std::pair AuthProperty; +typedef std::pair AuthProperty; class AuthPropertyIterator : public std::iterator { @@ -86,8 +86,8 @@ class AuthContext { /// Mutation functions: should only be used by an AuthMetadataProcessor. virtual void AddProperty(const grpc::string& key, - const grpc::string_ref& value) = 0; - virtual bool SetPeerIdentityPropertyName(const grpc::string& name) = 0; + const string_ref& value) = 0; + virtual bool SetPeerIdentityPropertyName(const string& name) = 0; }; } // namespace grpc diff --git a/include/grpcpp/impl/codegen/server_context_impl.h b/include/grpcpp/impl/codegen/server_context_impl.h index 72137f153b1..7e2a5720199 100644 --- a/include/grpcpp/impl/codegen/server_context_impl.h +++ b/include/grpcpp/impl/codegen/server_context_impl.h @@ -68,9 +68,19 @@ template class CallbackServerStreamingHandler; template class CallbackBidiHandler; +template +class ClientStreamingHandler; +template +class RpcMethodHandler; template class ServerReaderWriterBody; +template +class ServerStreamingHandler; class ServerReactor; +template +class TemplatedBidiStreamingHandler; +template <::grpc::StatusCode code> +class ErrorMethodHandler; } // namespace internal } // namespace grpc_impl @@ -79,20 +89,9 @@ class GenericServerContext; class ServerInterface; namespace internal { -template -class ClientStreamingHandler; -template -class ServerStreamingHandler; -template -class RpcMethodHandler; -template -class TemplatedBidiStreamingHandler; -template -class ErrorMethodHandler; class Call; } // namespace internal -class ServerInterface; namespace testing { class InteropServerContextInspector; class ServerContextTestSpouse; @@ -293,13 +292,13 @@ class ServerContext { template friend class ::grpc_impl::internal::ServerReaderWriterBody; template - friend class ::grpc::internal::RpcMethodHandler; + friend class ::grpc_impl::internal::RpcMethodHandler; template - friend class ::grpc::internal::ClientStreamingHandler; + friend class ::grpc_impl::internal::ClientStreamingHandler; template - friend class ::grpc::internal::ServerStreamingHandler; + friend class ::grpc_impl::internal::ServerStreamingHandler; template - friend class ::grpc::internal::TemplatedBidiStreamingHandler; + friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler; template friend class ::grpc_impl::internal::CallbackUnaryHandler; template @@ -309,7 +308,7 @@ class ServerContext { template friend class ::grpc_impl::internal::CallbackBidiHandler; template <::grpc::StatusCode code> - friend class ::grpc::internal::ErrorMethodHandler; + friend class ::grpc_impl::internal::ErrorMethodHandler; friend class ::grpc_impl::ClientContext; friend class ::grpc::GenericServerContext; diff --git a/include/grpcpp/impl/codegen/server_interface.h b/include/grpcpp/impl/codegen/server_interface.h index a375d3c0b4c..46c4ebb11a5 100644 --- a/include/grpcpp/impl/codegen/server_interface.h +++ b/include/grpcpp/impl/codegen/server_interface.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -52,6 +53,7 @@ class ServerAsyncStreamingInterface; namespace experimental { class CallbackGenericService; +class ServerInterceptorFactoryInterface; } // namespace experimental class ServerInterface : public internal::CallHook { diff --git a/include/grpcpp/impl/codegen/sync_stream_impl.h b/include/grpcpp/impl/codegen/sync_stream_impl.h index dc764e0e27b..ec9cf49862d 100644 --- a/include/grpcpp/impl/codegen/sync_stream_impl.h +++ b/include/grpcpp/impl/codegen/sync_stream_impl.h @@ -613,7 +613,7 @@ class ServerReader final : public ServerReaderInterface { ServerContext* const ctx_; template - friend class ::grpc::internal::ClientStreamingHandler; + friend class ::grpc_impl::internal::ClientStreamingHandler; ServerReader(::grpc::internal::Call* call, ::grpc_impl::ServerContext* ctx) : call_(call), ctx_(ctx) {} @@ -688,7 +688,7 @@ class ServerWriter final : public ServerWriterInterface { ::grpc_impl::ServerContext* const ctx_; template - friend class ::grpc::internal::ServerStreamingHandler; + friend class ::grpc_impl::internal::ServerStreamingHandler; ServerWriter(::grpc::internal::Call* call, ::grpc_impl::ServerContext* ctx) : call_(call), ctx_(ctx) {} @@ -800,7 +800,7 @@ class ServerReaderWriter final : public ServerReaderWriterInterface { private: internal::ServerReaderWriterBody body_; - friend class ::grpc::internal::TemplatedBidiStreamingHandler< + friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler< ServerReaderWriter, false>; ServerReaderWriter(::grpc::internal::Call* call, ::grpc_impl::ServerContext* ctx) @@ -870,7 +870,7 @@ class ServerUnaryStreamer final bool read_done_; bool write_done_; - friend class ::grpc::internal::TemplatedBidiStreamingHandler< + friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler< ServerUnaryStreamer, true>; ServerUnaryStreamer(::grpc::internal::Call* call, ::grpc_impl::ServerContext* ctx) @@ -932,7 +932,7 @@ class ServerSplitStreamer final internal::ServerReaderWriterBody body_; bool read_done_; - friend class ::grpc::internal::TemplatedBidiStreamingHandler< + friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler< ServerSplitStreamer, false>; ServerSplitStreamer(::grpc::internal::Call* call, ::grpc_impl::ServerContext* ctx) diff --git a/include/grpcpp/support/method_handler.h b/include/grpcpp/support/method_handler.h new file mode 100644 index 00000000000..038e76c8af8 --- /dev/null +++ b/include/grpcpp/support/method_handler.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_METHOD_HANDLER_H +#define GRPCPP_SUPPORT_METHOD_HANDLER_H + +#include + +#endif // GRPCPP_SUPPORT_METHOD_HANDLER_H diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index 044647d9a81..e63bdf6de98 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -144,7 +144,7 @@ grpc::string GetHeaderIncludes(grpc_generator::File* file, "grpcpp/impl/codegen/client_callback.h", "grpcpp/impl/codegen/client_context.h", "grpcpp/impl/codegen/completion_queue.h", - "grpcpp/impl/codegen/method_handler_impl.h", + "grpcpp/impl/codegen/method_handler.h", "grpcpp/impl/codegen/proto_utils.h", "grpcpp/impl/codegen/rpc_method.h", "grpcpp/impl/codegen/server_callback.h", @@ -1657,7 +1657,7 @@ grpc::string GetSourceIncludes(grpc_generator::File* file, "grpcpp/impl/codegen/channel_interface.h", "grpcpp/impl/codegen/client_unary_call.h", "grpcpp/impl/codegen/client_callback.h", - "grpcpp/impl/codegen/method_handler_impl.h", + "grpcpp/impl/codegen/method_handler.h", "grpcpp/impl/codegen/rpc_service_method.h", "grpcpp/impl/codegen/server_callback.h", "grpcpp/impl/codegen/service_type.h", diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc index 02cfb59c0e6..f7984645c42 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -31,9 +31,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 168e6c8d770..cef7cc20b1d 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -979,6 +979,7 @@ include/grpcpp/impl/codegen/interceptor.h \ include/grpcpp/impl/codegen/interceptor_common.h \ include/grpcpp/impl/codegen/message_allocator.h \ include/grpcpp/impl/codegen/metadata_map.h \ +include/grpcpp/impl/codegen/method_handler.h \ include/grpcpp/impl/codegen/method_handler_impl.h \ include/grpcpp/impl/codegen/proto_buffer_reader.h \ include/grpcpp/impl/codegen/proto_buffer_writer.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 3b7af742baa..6359c45665a 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -981,6 +981,7 @@ include/grpcpp/impl/codegen/interceptor.h \ include/grpcpp/impl/codegen/interceptor_common.h \ include/grpcpp/impl/codegen/message_allocator.h \ include/grpcpp/impl/codegen/metadata_map.h \ +include/grpcpp/impl/codegen/method_handler.h \ include/grpcpp/impl/codegen/method_handler_impl.h \ include/grpcpp/impl/codegen/proto_buffer_reader.h \ include/grpcpp/impl/codegen/proto_buffer_writer.h \ From 6b3bd74e686e65ee7a0ec8913ef2ecacef34cbcf Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 21 Aug 2019 16:17:13 -0700 Subject: [PATCH 1324/1555] Fix CMakeLists.txt --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d204d3799da..40dcf9e3ec4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -792,6 +792,7 @@ target_include_directories(address_sorting PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} From 957a686a70b2cd2c386182eaafd14224e8bc6338 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 21 Aug 2019 16:20:26 -0700 Subject: [PATCH 1325/1555] Fix the nano pb from CMakeLists.txt --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40dcf9e3ec4..d204d3799da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -792,7 +792,6 @@ target_include_directories(address_sorting PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} From 2b8ad5ee56ccd68a9092084e1bcaf760f3eae1f8 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Wed, 21 Aug 2019 16:30:51 -0700 Subject: [PATCH 1326/1555] Fix golden test compilation --- test/cpp/codegen/compiler_test_golden | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index 34fb5bfb53f..2c144f7d003 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include From 66e1a2c92bb78dc522c537ce26a6dd5d535cca3c Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 21 Aug 2019 18:42:07 -0700 Subject: [PATCH 1327/1555] Generate projects --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65aadb7cf1a..28cd26555f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17370,7 +17370,6 @@ target_include_directories(timer_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} From 20e2964ada045d5bb95ef14d105a39f97a4ed1ae Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Wed, 21 Aug 2019 16:12:31 -0700 Subject: [PATCH 1328/1555] cfstream_test: workaround Apple CFStream bug --- CMakeLists.txt | 1 - test/cpp/end2end/cfstream_test.cc | 27 ++++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65aadb7cf1a..28cd26555f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17370,7 +17370,6 @@ target_include_directories(timer_test PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} PRIVATE ${_gRPC_CARES_INCLUDE_DIR} PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR} PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} PRIVATE ${_gRPC_SSL_INCLUDE_DIR} PRIVATE ${_gRPC_UPB_GENERATED_DIR} diff --git a/test/cpp/end2end/cfstream_test.cc b/test/cpp/end2end/cfstream_test.cc index 1c9320861fd..35b5b7b835d 100644 --- a/test/cpp/end2end/cfstream_test.cc +++ b/test/cpp/end2end/cfstream_test.cc @@ -195,7 +195,22 @@ class CFStreamTest : public ::testing::TestWithParam { void ShutdownCQ() { cq_.Shutdown(); } - bool CQNext(void** tag, bool* ok) { return cq_.Next(tag, ok); } + bool CQNext(void** tag, bool* ok) { + auto deadline = std::chrono::system_clock::now() + std::chrono::seconds(10); + auto ret = cq_.AsyncNext(tag, ok, deadline); + if (ret == grpc::CompletionQueue::GOT_EVENT) { + return true; + } else if (ret == grpc::CompletionQueue::SHUTDOWN) { + return false; + } else { + GPR_ASSERT(ret == grpc::CompletionQueue::TIMEOUT); + // This can happen if we hit the Apple CFStream bug which results in the + // read stream hanging. We are ignoring hangs and timeouts, but these + // tests are still useful as they can catch memory memory corruptions, + // crashes and other bugs that don't result in test hang/timeout. + return false; + } + } bool WaitForChannelNotReady(Channel* channel, int timeout_seconds = 5) { const gpr_timespec deadline = @@ -391,7 +406,10 @@ TEST_P(CFStreamTest, NetworkFlapRpcsInFlight) { } delete call; } - EXPECT_EQ(total_completions, rpcs_sent); + // Remove line below and uncomment the following line after Apple CFStream + // bug has been fixed. + (void)rpcs_sent; + // EXPECT_EQ(total_completions, rpcs_sent); }); for (int i = 0; i < 100; ++i) { @@ -432,7 +450,10 @@ TEST_P(CFStreamTest, ConcurrentRpc) { } delete call; } - EXPECT_EQ(total_completions, rpcs_sent); + // Remove line below and uncomment the following line after Apple CFStream + // bug has been fixed. + (void)rpcs_sent; + // EXPECT_EQ(total_completions, rpcs_sent); }); for (int i = 0; i < 10; ++i) { From 69c97800323891d664d6fe738dc21140632bc52b Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 22 Aug 2019 12:08:30 -0700 Subject: [PATCH 1329/1555] clang-format --- src/objective-c/GRPCClient/GRPCCallOptions.h | 2 ++ src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.h b/src/objective-c/GRPCClient/GRPCCallOptions.h index d01c8285662..e4261b5b5f9 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.h +++ b/src/objective-c/GRPCClient/GRPCCallOptions.h @@ -158,6 +158,8 @@ NS_ASSUME_NONNULL_BEGIN * identifier defined in \a GRPCTransport or provided by a non-native transport * implementation. If the option is left to be NULL, gRPC will use its default * transport. + * + * This is currently an experimental option. */ @property(readonly) GRPCTransportId transport; diff --git a/src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m b/src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m index a1441221b15..5b5fc6263c5 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m @@ -18,8 +18,8 @@ #import "NSError+GRPC.h" -#include #import +#include @implementation NSError (GRPC) + (instancetype)grpc_errorFromStatusCode:(grpc_status_code)statusCode From f66f047841cd027b6b86a5149fd5d3375a4b5fea Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Wed, 21 Aug 2019 10:56:08 -0700 Subject: [PATCH 1330/1555] Update googletest version to fix BoringSSL support --- Makefile | 2 +- bazel/grpc_deps.bzl | 16 ++++++++++++---- templates/Makefile.template | 2 +- third_party/googletest | 2 +- tools/run_tests/sanity/check_bazel_workspace.py | 2 ++ tools/run_tests/sanity/check_submodules.sh | 2 +- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index ec88bd3926c..64fd19748ce 100644 --- a/Makefile +++ b/Makefile @@ -451,7 +451,7 @@ USE_BUILT_PROTOC = false endif GTEST_LIB = -Ithird_party/googletest/googletest/include -Ithird_party/googletest/googletest third_party/googletest/googletest/src/gtest-all.cc -Ithird_party/googletest/googlemock/include -Ithird_party/googletest/googlemock third_party/googletest/googlemock/src/gmock-all.cc -GTEST_LIB += -lgflags +GTEST_LIB += -lgflags -std=c++11 ifeq ($(V),1) E = @: Q = diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index b226f15aa2a..d34214b7f37 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -67,7 +67,7 @@ def grpc_deps(): name = "gtest", actual = "@com_github_google_googletest//:gtest", ) - + native.bind( name = "benchmark", actual = "@com_github_google_benchmark//:benchmark", @@ -141,9 +141,17 @@ def grpc_deps(): if "com_github_google_googletest" not in native.existing_rules(): http_archive( name = "com_github_google_googletest", - sha256 = "d0d447b4feeedca837a0d46a289d4223089b32ac2f84545fa4982755cc8919be", - strip_prefix = "googletest-2fe3bd994b3189899d93f1d5a881e725e046fdc2", - url = "https://github.com/google/googletest/archive/2fe3bd994b3189899d93f1d5a881e725e046fdc2.tar.gz", + sha256 = "443d383db648ebb8e391382c0ab63263b7091d03197f304390baac10f178a468", + strip_prefix = "googletest-c9ccac7cb7345901884aabf5d1a786cfa6e2f397", + url = "https://github.com/google/googletest/archive/c9ccac7cb7345901884aabf5d1a786cfa6e2f397.tar.gz", # 2019-08-19 + ) + + if "rules_cc" not in native.existing_rules(): + http_archive( + name = "rules_cc", + sha256 = "35f2fb4ea0b3e61ad64a369de284e4fbbdcdba71836a5555abb5e194cf119509", + strip_prefix = "rules_cc-624b5d59dfb45672d4239422fa1e3de1822ee110", + url = "https://github.com/bazelbuild/rules_cc/archive/624b5d59dfb45672d4239422fa1e3de1822ee110.tar.gz", #2019-08-15 ) if "com_github_gflags_gflags" not in native.existing_rules(): diff --git a/templates/Makefile.template b/templates/Makefile.template index 89415fa69b5..b17423cc4aa 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -321,7 +321,7 @@ endif GTEST_LIB = -Ithird_party/googletest/googletest/include -Ithird_party/googletest/googletest third_party/googletest/googletest/src/gtest-all.cc -Ithird_party/googletest/googlemock/include -Ithird_party/googletest/googlemock third_party/googletest/googlemock/src/gmock-all.cc - GTEST_LIB += -lgflags + GTEST_LIB += -lgflags -std=c++11 ifeq ($(V),1) E = @: Q = diff --git a/third_party/googletest b/third_party/googletest index 2fe3bd994b3..c9ccac7cb73 160000 --- a/third_party/googletest +++ b/third_party/googletest @@ -1 +1 @@ -Subproject commit 2fe3bd994b3189899d93f1d5a881e725e046fdc2 +Subproject commit c9ccac7cb7345901884aabf5d1a786cfa6e2f397 diff --git a/tools/run_tests/sanity/check_bazel_workspace.py b/tools/run_tests/sanity/check_bazel_workspace.py index 73b13a883d8..9100330d256 100755 --- a/tools/run_tests/sanity/check_bazel_workspace.py +++ b/tools/run_tests/sanity/check_bazel_workspace.py @@ -48,6 +48,7 @@ _GRPC_DEP_NAMES = [ 'zlib', 'com_google_protobuf', 'com_github_google_googletest', + 'rules_cc', 'com_github_gflags_gflags', 'com_github_nanopb_nanopb', 'com_github_google_benchmark', @@ -67,6 +68,7 @@ _GRPC_DEP_NAMES = [ ] _GRPC_BAZEL_ONLY_DEPS = [ + 'rules_cc', 'com_google_absl', 'io_opencensus_cpp', _BAZEL_SKYLIB_DEP_NAME, diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index d5eb6677796..39f3e26266c 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -35,7 +35,7 @@ cat << EOF | awk '{ print $1 }' | sort > "$want_submodules" a83394157ad97f4dadbc8ed81f56ad5b3a72e542 third_party/envoy-api (heads/master) 28f50e0fed19872e0fd50dd23ce2ee8cd759338e third_party/gflags (v2.2.0-5-g30dbc81) 80ed4d0bbf65d57cc267dfc63bd2584557f11f9b third_party/googleapis (common-protos-1_3_1-915-g80ed4d0bb) - 2fe3bd994b3189899d93f1d5a881e725e046fdc2 third_party/googletest (release-1.8.1) + c9ccac7cb7345901884aabf5d1a786cfa6e2f397 third_party/googletest (6e2f397) 6599cac0965be8e5a835ab7a5684bbef033d5ad0 third_party/libcxx (heads/release_60) 9245d481eb3e890f708ff2d7dadf2a10c04748ba third_party/libcxxabi (heads/release_60) 09745575a923640154bcf307fba8aedff47f240a third_party/protobuf (v3.7.0-rc.2-247-g09745575) From 9a41e12a4f75b391a78cdd88a254dec99ad87932 Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Thu, 22 Aug 2019 16:00:04 -0700 Subject: [PATCH 1331/1555] Skip timer test when running under event manager --- test/cpp/common/timer_test.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/cpp/common/timer_test.cc b/test/cpp/common/timer_test.cc index f5083d66e76..0ce6633088f 100644 --- a/test/cpp/common/timer_test.cc +++ b/test/cpp/common/timer_test.cc @@ -27,6 +27,10 @@ #include "src/core/lib/iomgr/timer_manager.h" #include "test/core/util/test_config.h" +#ifdef GRPC_POSIX_SOCKET +#include "src/core/lib/iomgr/ev_posix.h" +#endif + // MAYBE_SKIP_TEST is a macro to determine if this particular test configuration // should be skipped based on a decision made at SetUp time. #define MAYBE_SKIP_TEST \ @@ -39,9 +43,17 @@ class TimerTest : public ::testing::Test { protected: void SetUp() override { - // Skip test if slowdown factor > 1. - do_not_test_ = (grpc_test_slowdown_factor() != 1); grpc_init(); + // Skip test if slowdown factor > 1, or we are + // using event manager. +#ifdef GRPC_POSIX_SOCKET + if (grpc_test_slowdown_factor() != 1 || + grpc_event_engine_run_in_background()) { +#else + if (grpc_test_slowdown_factor() != 1) { +#endif + do_not_test_ = true; + } } void TearDown() override { grpc_shutdown_blocking(); } From 5d646ff9ff03712df1ffb6bf135890f3af07caae Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 23 Aug 2019 08:05:46 -0700 Subject: [PATCH 1332/1555] Make Map<> copyable. --- src/core/lib/gprpp/map.h | 71 +++++++++++++++++++++++++++++++++++++ test/core/gprpp/map_test.cc | 29 +++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/src/core/lib/gprpp/map.h b/src/core/lib/gprpp/map.h index 8f0a26146b1..705b605e5b9 100644 --- a/src/core/lib/gprpp/map.h +++ b/src/core/lib/gprpp/map.h @@ -63,6 +63,7 @@ class Map { typedef Pair value_type; typedef Compare key_compare; class iterator; + class const_iterator; Map() = default; ~Map() { clear(); } @@ -83,6 +84,22 @@ class Map { return *this; } + // Copyable. + Map(const Map& other) { + for (const auto& p : other) { + emplace(p); + } + } + Map& operator=(const Map& other) { + if (this != &other) { + clear(); + for (const auto& p : other) { + emplace(p); + } + } + return *this; + } + T& operator[](key_type&& key); T& operator[](const key_type& key); iterator find(const key_type& k); @@ -117,6 +134,13 @@ class Map { iterator end() { return iterator(this, nullptr); } + const_iterator begin() const { + Entry* curr = GetMinEntry(root_); + return const_iterator(this, curr); + } + + const_iterator end() const { return const_iterator(this, nullptr); } + iterator lower_bound(const Key& k) { // This is a workaround for "const key_compare compare;" // because some versions of compilers cannot build this by requiring @@ -209,6 +233,53 @@ class Map::iterator GrpcMap* map_; }; +template +class Map::const_iterator + : public std::iterator, int32_t, + Pair*, Pair&> { + public: + const_iterator(const const_iterator& iter) + : curr_(iter.curr_), map_(iter.map_) {} + bool operator==(const const_iterator& rhs) const { + return (curr_ == rhs.curr_); + } + bool operator!=(const const_iterator& rhs) const { + return (curr_ != rhs.curr_); + } + + const_iterator& operator++() { + curr_ = map_->InOrderSuccessor(curr_); + return *this; + } + + const_iterator operator++(int) { + Entry* prev = curr_; + curr_ = map_->InOrderSuccessor(curr_); + return const_iterator(map_, prev); + } + + const_iterator& operator=(const const_iterator& other) { + if (this != &other) { + this->curr_ = other.curr_; + this->map_ = other.map_; + } + return *this; + } + + // operator*() + const value_type& operator*() const { return curr_->pair; } + + // operator->() + const value_type* operator->() const { return &curr_->pair; } + + private: + friend class Map; + using GrpcMap = typename ::grpc_core::Map; + const_iterator(const GrpcMap* map, Entry* curr) : curr_(curr), map_(map) {} + Entry* curr_; + const GrpcMap* map_; +}; + template T& Map::operator[](key_type&& key) { auto iter = find(key); diff --git a/test/core/gprpp/map_test.cc b/test/core/gprpp/map_test.cc index 21aeee82486..b0be7960b57 100644 --- a/test/core/gprpp/map_test.cc +++ b/test/core/gprpp/map_test.cc @@ -466,6 +466,35 @@ TEST_F(MapTest, MoveAssignment) { EXPECT_EQ(test_map2.end(), test_map2.find("xxx")); } +// Test copy ctor +TEST_F(MapTest, CopyCtor) { + Map test_map; + for (int i = 0; i < 5; i++) { + test_map.emplace(kKeys[i], Payload(i)); + } + Map test_map2 = test_map; + for (int i = 0; i < 5; i++) { + EXPECT_EQ(i, test_map.find(kKeys[i])->second.data()); + EXPECT_EQ(i, test_map2.find(kKeys[i])->second.data()); + } +} + +// Test copy assignment +TEST_F(MapTest, CopyAssignment) { + Map test_map; + for (int i = 0; i < 5; i++) { + test_map.emplace(kKeys[i], Payload(i)); + } + Map test_map2; + test_map2.emplace("xxx", Payload(123)); + test_map2 = test_map; + for (int i = 0; i < 5; i++) { + EXPECT_EQ(i, test_map.find(kKeys[i])->second.data()); + EXPECT_EQ(i, test_map2.find(kKeys[i])->second.data()); + } + EXPECT_EQ(test_map2.end(), test_map2.find("xxx")); +} + } // namespace testing } // namespace grpc_core From 5a9a8a6be80d94a09618285cb3c68b8a88810f05 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 23 Aug 2019 08:33:33 -0700 Subject: [PATCH 1333/1555] Add .history to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 01e7867c20a..ed1669c4ccc 100644 --- a/.gitignore +++ b/.gitignore @@ -140,6 +140,7 @@ bm_*.json # Visual Studio Code artifacts .vscode/* +.history/ # Clion artifacts cmake-build-debug/ From a031f0ffd6f70011f8bd44576fdb31bee09e0aba Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 23 Aug 2019 08:41:35 -0700 Subject: [PATCH 1334/1555] Remove all nanopb defines --- CMakeLists.txt | 2 - Makefile | 2 +- build.yaml | 3 +- config.m4 | 4 +- config.w32 | 1 - gRPC-C++.podspec | 2 +- gRPC-Core.podspec | 4 +- grpc.gyp | 3 - setup.py | 1 - src/objective-c/tests/BUILD | 3 - .../tests/Tests.xcodeproj/project.pbxproj | 3 - templates/CMakeLists.txt.template | 2 - templates/config.m4.template | 4 +- templates/config.w32.template | 1 - templates/gRPC-C++.podspec.template | 2 +- templates/gRPC-Core.podspec.template | 4 +- .../CFStreamTests.xcodeproj/project.pbxproj | 2 - tools/bazel.rc | 1 - tools/distrib/check_nanopb_output.sh | 59 ------------------- 19 files changed, 12 insertions(+), 91 deletions(-) delete mode 100755 tools/distrib/check_nanopb_output.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 28cd26555f2..f1552a56c1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,8 +96,6 @@ endif() set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) -add_definitions(-DPB_FIELD_32BIT) - if (MSVC) include(cmake/msvc_static_runtime.cmake) add_definitions(-D_WIN32_WINNT=0x600 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS) diff --git a/Makefile b/Makefile index 8400bae76bb..5189f704297 100644 --- a/Makefile +++ b/Makefile @@ -354,7 +354,7 @@ CXXFLAGS += -stdlib=libc++ LDFLAGS += -framework CoreFoundation endif CXXFLAGS += -Wnon-virtual-dtor -CPPFLAGS += -g -Wall -Wextra -Werror $(W_NO_UNKNOWN_WARNING_OPTION) -Wno-long-long -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-maybe-uninitialized -DPB_FIELD_32BIT -DOSATOMIC_USE_INLINED=1 -Ithird_party/upb -Isrc/core/ext/upb-generated +CPPFLAGS += -g -Wall -Wextra -Werror $(W_NO_UNKNOWN_WARNING_OPTION) -Wno-long-long -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-maybe-uninitialized -DOSATOMIC_USE_INLINED=1 -Ithird_party/upb -Isrc/core/ext/upb-generated COREFLAGS += -fno-rtti -fno-exceptions LDFLAGS += -g diff --git a/build.yaml b/build.yaml index ee5a45e26fd..cbdbf8a60bc 100644 --- a/build.yaml +++ b/build.yaml @@ -6200,8 +6200,7 @@ defaults: CPPFLAGS: -g -Wall -Wextra -Werror $(W_NO_UNKNOWN_WARNING_OPTION) -Wno-long-long -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers - -Wno-maybe-uninitialized -DPB_FIELD_32BIT -DOSATOMIC_USE_INLINED=1 -Ithird_party/upb - -Isrc/core/ext/upb-generated + -Wno-maybe-uninitialized -DOSATOMIC_USE_INLINED=1 -Ithird_party/upb -Isrc/core/ext/upb-generated CXXFLAGS: -Wnon-virtual-dtor LDFLAGS: -g zlib: diff --git a/config.m4 b/config.m4 index d78bdfc75ac..79f69aa36e4 100644 --- a/config.m4 +++ b/config.m4 @@ -14,8 +14,8 @@ if test "$PHP_GRPC" != "no"; then LIBS="-lpthread $LIBS" - CFLAGS="-Wall -Werror -Wno-parentheses-equality -Wno-unused-value -std=c11 -g -O2 -D PB_FIELD_32BIT=1" - CXXFLAGS="-std=c++11 -fno-exceptions -fno-rtti -g -O2 -D PB_FIELD_32BIT=1" + CFLAGS="-Wall -Werror -Wno-parentheses-equality -Wno-unused-value -std=c11 -g -O2" + CXXFLAGS="-std=c++11 -fno-exceptions -fno-rtti -g -O2" GRPC_SHARED_LIBADD="-lpthread $GRPC_SHARED_LIBADD" PHP_REQUIRE_CXX() PHP_ADD_LIBRARY(pthread) diff --git a/config.w32 b/config.w32 index 176ba2f340b..994363a0f1f 100644 --- a/config.w32 +++ b/config.w32 @@ -706,7 +706,6 @@ if (PHP_GRPC != "no") { EXTENSION("grpc", grpc_source, null, "/DOPENSSL_NO_ASM /D_GNU_SOURCE /DWIN32_LEAN_AND_MEAN "+ "/D_HAS_EXCEPTIONS=0 /DNOMINMAX /DGRPC_ARES=0 /D_WIN32_WINNT=0x600 "+ - "/DPB_FIELD_32BIT "+ "/I"+configure_module_dirname+" "+ "/I"+configure_module_dirname+"\\include "+ "/I"+configure_module_dirname+"\\src\\core\\ext\\upb-generated "+ diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index d71773a7361..881e8959651 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -56,7 +56,7 @@ Pod::Spec.new do |s| s.pod_target_xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(PODS_TARGET_SRCROOT)/include"', 'USER_HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)"', - 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1" "PB_NO_PACKED_STRUCTS=1"', + 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1"', 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO', 'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'NO', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 1d27716a8b8..e6f926ca166 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -91,12 +91,12 @@ Pod::Spec.new do |s| # build. 'USE_HEADERMAP' => 'NO', 'ALWAYS_SEARCH_USER_PATHS' => 'NO', - 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1" "PB_NO_PACKED_STRUCTS=1"', + 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1"', 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO', } s.default_subspecs = 'Interface', 'Implementation' - s.compiler_flags = '-DGRPC_ARES=0', '-DPB_FIELD_32BIT' + s.compiler_flags = '-DGRPC_ARES=0' s.libraries = 'c++' # Like many other C libraries, gRPC-Core has its public headers under `include//` and its diff --git a/grpc.gyp b/grpc.gyp index 3b517e1894a..3b86e613131 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -66,7 +66,6 @@ '-Wno-sign-compare', '-Wno-missing-field-initializers', '-Wno-maybe-uninitialized', - '-DPB_FIELD_32BIT', '-DOSATOMIC_USE_INLINED=1', '-Ithird_party/upb', '-Isrc/core/ext/upb-generated', @@ -155,7 +154,6 @@ '-Wno-sign-compare', '-Wno-missing-field-initializers', '-Wno-maybe-uninitialized', - '-DPB_FIELD_32BIT', '-DOSATOMIC_USE_INLINED=1', '-Ithird_party/upb', '-Isrc/core/ext/upb-generated', @@ -176,7 +174,6 @@ '-Wno-sign-compare', '-Wno-missing-field-initializers', '-Wno-maybe-uninitialized', - '-DPB_FIELD_32BIT', '-DOSATOMIC_USE_INLINED=1', '-Ithird_party/upb', '-Isrc/core/ext/upb-generated', diff --git a/setup.py b/setup.py index 05159d0a7b4..609b18e01b5 100644 --- a/setup.py +++ b/setup.py @@ -161,7 +161,6 @@ if EXTRA_ENV_COMPILE_ARGS is None: EXTRA_ENV_COMPILE_ARGS += ' -std=gnu99 -fvisibility=hidden -fno-wrapv -fno-exceptions' elif "darwin" in sys.platform: EXTRA_ENV_COMPILE_ARGS += ' -stdlib=libc++ -fvisibility=hidden -fno-wrapv -fno-exceptions' -EXTRA_ENV_COMPILE_ARGS += ' -DPB_FIELD_32BIT' if EXTRA_ENV_LINK_ARGS is None: EXTRA_ENV_LINK_ARGS = '' diff --git a/src/objective-c/tests/BUILD b/src/objective-c/tests/BUILD index d34807f017f..fed92596b17 100644 --- a/src/objective-c/tests/BUILD +++ b/src/objective-c/tests/BUILD @@ -63,9 +63,6 @@ grpc_objc_testing_library( data = [":TestCertificates"], defines = [ "DEBUG=1", - "PB_FIELD_32BIT=1", - "PB_NO_PACKED_STRUCTS=1", - "PB_ENABLE_MALLOC=1", "HOST_PORT_LOCALSSL=localhost:5051", "HOST_PORT_LOCAL=localhost:5050", "HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com", diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index a54dca59b9c..a88838fdc8b 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -1721,9 +1721,6 @@ "$(inherited)", "COCOAPODS=1", "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1", - "PB_FIELD_32BIT=1", - "PB_NO_PACKED_STRUCTS=1", - "PB_ENABLE_MALLOC=1", "GRPC_TEST_OBJC=1", ); INFOPLIST_FILE = MacTests/Info.plist; diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index bcdd5f152ce..b6a0e83056f 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -145,8 +145,6 @@ ## Some libraries are shared even with BUILD_SHARED_LIBRARIES=OFF set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) - add_definitions(-DPB_FIELD_32BIT) - if (MSVC) include(cmake/msvc_static_runtime.cmake) add_definitions(-D_WIN32_WINNT=0x600 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS) diff --git a/templates/config.m4.template b/templates/config.m4.template index 794c6f3e86b..4dbeeafb86a 100644 --- a/templates/config.m4.template +++ b/templates/config.m4.template @@ -16,8 +16,8 @@ LIBS="-lpthread $LIBS" - CFLAGS="-Wall -Werror -Wno-parentheses-equality -Wno-unused-value -std=c11 -g -O2 -D PB_FIELD_32BIT=1" - CXXFLAGS="-std=c++11 -fno-exceptions -fno-rtti -g -O2 -D PB_FIELD_32BIT=1" + CFLAGS="-Wall -Werror -Wno-parentheses-equality -Wno-unused-value -std=c11 -g -O2" + CXXFLAGS="-std=c++11 -fno-exceptions -fno-rtti -g -O2" GRPC_SHARED_LIBADD="-lpthread $GRPC_SHARED_LIBADD" PHP_REQUIRE_CXX() PHP_ADD_LIBRARY(pthread) diff --git a/templates/config.w32.template b/templates/config.w32.template index 2515863516c..2a7d5e38c8f 100644 --- a/templates/config.w32.template +++ b/templates/config.w32.template @@ -23,7 +23,6 @@ EXTENSION("grpc", grpc_source, null, "/DOPENSSL_NO_ASM /D_GNU_SOURCE /DWIN32_LEAN_AND_MEAN "+ "/D_HAS_EXCEPTIONS=0 /DNOMINMAX /DGRPC_ARES=0 /D_WIN32_WINNT=0x600 "+ - "/DPB_FIELD_32BIT "+ "/I"+configure_module_dirname+" "+ "/I"+configure_module_dirname+"\\include "+ "/I"+configure_module_dirname+"\\src\\core\\ext\\upb-generated "+ diff --git a/templates/gRPC-C++.podspec.template b/templates/gRPC-C++.podspec.template index 1e7771f29b1..87fd462819f 100644 --- a/templates/gRPC-C++.podspec.template +++ b/templates/gRPC-C++.podspec.template @@ -170,7 +170,7 @@ s.pod_target_xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(PODS_TARGET_SRCROOT)/include"', 'USER_HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)"', - 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1" "PB_NO_PACKED_STRUCTS=1"', + 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1"', 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO', 'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'NO', diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template index 728fc59e692..9b77723a854 100644 --- a/templates/gRPC-Core.podspec.template +++ b/templates/gRPC-Core.podspec.template @@ -144,12 +144,12 @@ # build. 'USE_HEADERMAP' => 'NO', 'ALWAYS_SEARCH_USER_PATHS' => 'NO', - 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1" "PB_NO_PACKED_STRUCTS=1"', + 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1"', 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO', } s.default_subspecs = 'Interface', 'Implementation' - s.compiler_flags = '-DGRPC_ARES=0', '-DPB_FIELD_32BIT' + s.compiler_flags = '-DGRPC_ARES=0' s.libraries = 'c++' # Like many other C libraries, gRPC-Core has its public headers under `include//` and its diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/project.pbxproj b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/project.pbxproj index c24151f0fa7..58f067c9515 100644 --- a/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/project.pbxproj +++ b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/project.pbxproj @@ -271,8 +271,6 @@ "$(inherited)", "COCOAPODS=1", "$(inherited)", - "PB_FIELD_32BIT=1", - "PB_NO_PACKED_STRUCTS=1", "GRPC_CFSTREAM=1", ); INFOPLIST_FILE = Info.plist; diff --git a/tools/bazel.rc b/tools/bazel.rc index e2d49355d8f..b24f603ddda 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -75,7 +75,6 @@ build:ubsan --linkopt=-fsanitize=undefined build:ubsan --action_env=UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1:suppressions=test/core/util/ubsan_suppressions.txt # For some reasons, these two stopped being propagated, so, redeclaring them here. # That's a hack that needs to be removed once we understand what's going on. -build:ubsan --copt=-DPB_FIELD_32BIT=1 build:ubsan --copt=-DGRPC_PORT_ISOLATED_RUNTIME=1 build:basicprof --strip=never diff --git a/tools/distrib/check_nanopb_output.sh b/tools/distrib/check_nanopb_output.sh deleted file mode 100755 index 573e02e98ff..00000000000 --- a/tools/distrib/check_nanopb_output.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -# Copyright 2015 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -ex - -readonly NANOPB_HEALTH_TMP_OUTPUT="$(mktemp -d)" -readonly NANOPB_TMP_OUTPUT="$(mktemp -d)" -readonly PROTOBUF_INSTALL_PREFIX="$(mktemp -d)" - -# install protoc version 3 -pushd third_party/protobuf -./autogen.sh -./configure --prefix="$PROTOBUF_INSTALL_PREFIX" -make -j 8 -make install -#ldconfig -popd - -readonly PROTOC_BIN_PATH="$PROTOBUF_INSTALL_PREFIX/bin" -if [ ! -x "$PROTOBUF_INSTALL_PREFIX/bin/protoc" ]; then - echo "Error: protoc not found in temp install dir '$PROTOBUF_INSTALL_PREFIX'" - exit 1 -fi - -# stack up and change to nanopb's proto generator directory -pushd third_party/nanopb/generator/proto -export PATH="$PROTOC_BIN_PATH:$PATH" -make -j 8 -# back to the root directory -popd - -# -# checks for health.proto -# -readonly HEALTH_GRPC_OUTPUT_PATH='src/core/ext/filters/client_channel/health' -# nanopb-compile the proto to a temp location -./tools/codegen/core/gen_nano_proto.sh \ - src/proto/grpc/health/v1/health.proto \ - "$NANOPB_HEALTH_TMP_OUTPUT" \ - "$HEALTH_GRPC_OUTPUT_PATH" -# compare outputs to checked compiled code -for NANOPB_OUTPUT_FILE in $NANOPB_HEALTH_TMP_OUTPUT/*.pb.*; do - if ! diff "$NANOPB_OUTPUT_FILE" "${HEALTH_GRPC_OUTPUT_PATH}/$(basename $NANOPB_OUTPUT_FILE)"; then - echo "Outputs differ: $NANOPB_HEALTH_TMP_OUTPUT vs $HEALTH_GRPC_OUTPUT_PATH" - exit 2 - fi -done From de6255941a5e1c2fb2d50e57f84e38c09f45023d Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Fri, 23 Aug 2019 08:46:09 -0700 Subject: [PATCH 1335/1555] Fix gettid() naming conflict --- src/core/lib/gpr/log_linux.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/lib/gpr/log_linux.cc b/src/core/lib/gpr/log_linux.cc index 561276f0c20..81026e5689b 100644 --- a/src/core/lib/gpr/log_linux.cc +++ b/src/core/lib/gpr/log_linux.cc @@ -40,7 +40,9 @@ #include #include -static long gettid(void) { return syscall(__NR_gettid); } +// Not naming it as gettid() to avoid duplicate declarations when complied with +// GCC 9.1. +static long local_gettid(void) { return syscall(__NR_gettid); } void gpr_log(const char* file, int line, gpr_log_severity severity, const char* format, ...) { @@ -70,7 +72,7 @@ void gpr_default_log(gpr_log_func_args* args) { gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME); struct tm tm; static __thread long tid = 0; - if (tid == 0) tid = gettid(); + if (tid == 0) tid = local_gettid(); timer = static_cast(now.tv_sec); final_slash = strrchr(args->file, '/'); From 2b9ab6d10cc279000c8f0b5df152ef16c5062f05 Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Fri, 23 Aug 2019 13:54:16 -0700 Subject: [PATCH 1336/1555] timer_test: add test case for grpc shutdown while timer is pending --- test/cpp/common/timer_test.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/cpp/common/timer_test.cc b/test/cpp/common/timer_test.cc index 0ce6633088f..9b23be2885a 100644 --- a/test/cpp/common/timer_test.cc +++ b/test/cpp/common/timer_test.cc @@ -155,6 +155,20 @@ TEST_F(TimerTest, CancelSomeTimers) { gpr_log(GPR_DEBUG, "wakeups: %" PRId64 "", wakeups); } +// Enable the following test after +// https://github.com/grpc/grpc/issues/20049 has been fixed. +#if 0 +TEST_F(TimerTest, TimerNotCanceled) { + grpc_core::ExecCtx exec_ctx; + grpc_timer timer; + grpc_timer_init(&timer, 10000, + GRPC_CLOSURE_CREATE( + [](void*, grpc_error*) { + }, + nullptr, grpc_schedule_on_exec_ctx)); +} +#endif + int main(int argc, char** argv) { grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); From f8286f3c90ecc76980095bf1198d25686e4f77ed Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Fri, 23 Aug 2019 14:01:31 -0700 Subject: [PATCH 1337/1555] Update triage rotation --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/ISSUE_TEMPLATE/cleanup_request.md | 2 +- .github/ISSUE_TEMPLATE/feature_request.md | 2 +- .github/pull_request_template.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index f3ed8399dc2..e44c8966012 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -2,7 +2,7 @@ name: Report a bug about: Create a report to help us improve labels: kind/bug, priority/P2 -assignees: AspirinSJL +assignees: mhaidrygoog --- diff --git a/.github/ISSUE_TEMPLATE/cleanup_request.md b/.github/ISSUE_TEMPLATE/cleanup_request.md index 65e56772541..4fe128984b9 100644 --- a/.github/ISSUE_TEMPLATE/cleanup_request.md +++ b/.github/ISSUE_TEMPLATE/cleanup_request.md @@ -2,7 +2,7 @@ name: Request a cleanup about: Suggest a cleanup in our repository labels: kind/internal cleanup -assignees: AspirinSJL +assignees: mhaidrygoog --- diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 2be15ac785c..499de024dd4 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -2,7 +2,7 @@ name: Request a feature about: Suggest an idea for this project labels: kind/enhancement -assignees: AspirinSJL +assignees: mhaidrygoog --- diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index fba14a5db00..ac8c41a9f26 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -8,4 +8,4 @@ If you know who should review your pull request, please remove the mentioning be --> -@AspirinSJL \ No newline at end of file +@mhaidrygoog \ No newline at end of file From 32f1119d2b1b346ae7727a0f564f6b9a422008ec Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 23 Aug 2019 14:51:05 -0700 Subject: [PATCH 1338/1555] Strict C++ --- .../client_channel/lb_policy/xds/xds_load_balancer_api.h | 3 ++- src/core/ext/filters/client_channel/resolving_lb_policy.cc | 2 ++ src/core/lib/channel/channelz.h | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h index cea5b50b9ba..759c04cd71f 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h @@ -37,7 +37,8 @@ struct XdsLocalityInfo { // This comparator only compares the locality names. struct Less { - bool operator()(const XdsLocalityInfo& lhs, const XdsLocalityInfo& rhs) { + bool operator()(const XdsLocalityInfo& lhs, + const XdsLocalityInfo& rhs) const { return XdsLocalityName::Less()(lhs.locality_name, rhs.locality_name); } }; diff --git a/src/core/ext/filters/client_channel/resolving_lb_policy.cc b/src/core/ext/filters/client_channel/resolving_lb_policy.cc index 4b61df09959..b3b455b0ce8 100644 --- a/src/core/ext/filters/client_channel/resolving_lb_policy.cc +++ b/src/core/ext/filters/client_channel/resolving_lb_policy.cc @@ -160,6 +160,8 @@ class ResolvingLoadBalancingPolicy::ResolvingControlHelper } } + void AddTraceEvent(TraceSeverity severity, const char* message) override {} + void set_child(LoadBalancingPolicy* child) { child_ = child; } private: diff --git a/src/core/lib/channel/channelz.h b/src/core/lib/channel/channelz.h index 2561bff807e..b023a5280e0 100644 --- a/src/core/lib/channel/channelz.h +++ b/src/core/lib/channel/channelz.h @@ -81,7 +81,10 @@ class BaseNode : public RefCounted { kSocket, }; + protected: BaseNode(EntityType type, UniquePtr name); + + public: virtual ~BaseNode(); // All children must implement this function. From 088b67debaf85dadb774c1a4c4f02ca36e73a1bf Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 23 Aug 2019 15:06:39 -0700 Subject: [PATCH 1339/1555] Improve comment --- test/cpp/end2end/client_interceptors_end2end_test.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/cpp/end2end/client_interceptors_end2end_test.cc b/test/cpp/end2end/client_interceptors_end2end_test.cc index 583513edaa4..cf151d7626e 100644 --- a/test/cpp/end2end/client_interceptors_end2end_test.cc +++ b/test/cpp/end2end/client_interceptors_end2end_test.cc @@ -190,8 +190,10 @@ class HijackingInterceptorMakesAnotherCall : public experimental::Interceptor { EXPECT_EQ(resp_.message(), "Hello"); methods->Hijack(); }); - // There isn't going to be any other interesting operation in this batch, - // so it is fine to return + // This is a Unary RPC and we have got nothing interesting to do in the + // PRE_SEND_CLOSE interception hook point for this interceptor, so let's + // return here. (We do not want to call methods->Proceed(). When the new + // RPC returns, we will call methods->Hijack() instead.) return; } if (methods->QueryInterceptionHookPoint( From 5294f49d11d27773904728614a78ee27ee0f10d7 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 23 Aug 2019 15:33:52 -0700 Subject: [PATCH 1340/1555] Init needs to be called in case of bad creds --- src/cpp/client/create_channel.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cpp/client/create_channel.cc b/src/cpp/client/create_channel.cc index ca7038b8893..c6041edcb36 100644 --- a/src/cpp/client/create_channel.cc +++ b/src/cpp/client/create_channel.cc @@ -38,7 +38,7 @@ std::shared_ptr CreateCustomChannelImpl( const std::shared_ptr& creds, const grpc::ChannelArguments& args) { grpc::GrpcLibraryCodegen - init_lib; // We need to call init in case of a bad creds. + init_lib; // We need to call init in case of bad creds. return creds ? creds->CreateChannelImpl(target, args) : grpc::CreateChannelInternal( "", @@ -69,6 +69,8 @@ std::shared_ptr CreateCustomChannelWithInterceptors( std::vector< std::unique_ptr> interceptor_creators) { + grpc::GrpcLibraryCodegen + init_lib; // We need to call init in case of bad creds. return creds ? creds->CreateChannelWithInterceptors( target, args, std::move(interceptor_creators)) : grpc::CreateChannelInternal( From 3728329033f51895ce2603bb65b49be19e3c3129 Mon Sep 17 00:00:00 2001 From: yang-g Date: Fri, 23 Aug 2019 16:15:17 -0700 Subject: [PATCH 1341/1555] return unavailable on transport closed --- .../ext/transport/chttp2/transport/chttp2_transport.cc | 7 +++++++ test/core/end2end/tests/max_connection_age.cc | 2 +- test/core/end2end/tests/shutdown_finishes_calls.cc | 4 +--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 73235756dfb..5f5c480f9dc 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -2465,6 +2465,13 @@ static void cancel_stream_cb(void* user_data, uint32_t key, void* stream) { } static void end_all_the_calls(grpc_chttp2_transport* t, grpc_error* error) { + intptr_t http2_error; + // If there is no explicit grpc or HTTP/2 error, set to UNAVAILABLE on server. + if (!t->is_client && !grpc_error_has_clear_grpc_status(error) && + !grpc_error_get_int(error, GRPC_ERROR_INT_HTTP2_ERROR, &http2_error)) { + error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS, + GRPC_STATUS_UNAVAILABLE); + } cancel_stream_cb_args args = {error, t}; grpc_chttp2_stream_map_for_each(&t->stream_map, cancel_stream_cb, &args); GRPC_ERROR_UNREF(error); diff --git a/test/core/end2end/tests/max_connection_age.cc b/test/core/end2end/tests/max_connection_age.cc index fcb0aaffc4a..50c790d8521 100644 --- a/test/core/end2end/tests/max_connection_age.cc +++ b/test/core/end2end/tests/max_connection_age.cc @@ -204,7 +204,7 @@ static void test_max_age_forcibly_close(grpc_end2end_test_config config) { /* The connection should be closed immediately after the max age grace period, the in-progress RPC should fail. */ - GPR_ASSERT(status == GRPC_STATUS_INTERNAL); + GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE); GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); GPR_ASSERT(was_cancelled == 1); diff --git a/test/core/end2end/tests/shutdown_finishes_calls.cc b/test/core/end2end/tests/shutdown_finishes_calls.cc index 5dd5bb2ad6c..60b738ef9ef 100644 --- a/test/core/end2end/tests/shutdown_finishes_calls.cc +++ b/test/core/end2end/tests/shutdown_finishes_calls.cc @@ -166,9 +166,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( grpc_server_destroy(f.server); - // new code should give INTERNAL, some older code will give UNAVAILABLE - GPR_ASSERT(status == GRPC_STATUS_INTERNAL || - status == GRPC_STATUS_UNAVAILABLE); + GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE); GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); GPR_ASSERT(was_cancelled == 1); From 6e159d3ee38c089c6be7391d18af4c836a38139e Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Fri, 23 Aug 2019 15:04:13 -0700 Subject: [PATCH 1342/1555] Fix hpack parser fuzzer failure. Fix crash when nullptr is passed to ManagedMemorySlice::Equals(). --- src/core/lib/slice/slice_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/slice/slice_utils.h b/src/core/lib/slice/slice_utils.h index 161300abe1e..e80de6d2ece 100644 --- a/src/core/lib/slice/slice_utils.h +++ b/src/core/lib/slice/slice_utils.h @@ -108,7 +108,7 @@ struct ManagedMemorySlice : public grpc_slice { return !grpc_slice_differs_refcounted(other, *this); } bool Equals(const char* buf, const size_t len) const { - return data.refcounted.length == len && + return data.refcounted.length == len && buf != nullptr && memcmp(buf, data.refcounted.bytes, len) == 0; } }; From 6f2f9ae2c362eac6b76da442606b2486623b4d6b Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 23 Aug 2019 10:07:17 -0700 Subject: [PATCH 1343/1555] import ProtoRPC and GRPCCallOptions in ProtoService --- src/objective-c/ProtoRPC/ProtoService.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/objective-c/ProtoRPC/ProtoService.h b/src/objective-c/ProtoRPC/ProtoService.h index 8543f5dee43..45376a94353 100644 --- a/src/objective-c/ProtoRPC/ProtoService.h +++ b/src/objective-c/ProtoRPC/ProtoService.h @@ -18,15 +18,12 @@ #import -@class GRPCProtoCall; +#import "ProtoRPC.h" +#import + @protocol GRXWriteable; @class GRXWriter; @class GRPCCallOptions; -@class GRPCProtoCall; -@class GRPCUnaryProtoCall; -@class GRPCStreamingProtoCall; -@protocol GRPCProtoResponseHandler; -@protocol GRXWriteable; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnullability-completeness" From 25b56ee1dd75597b16ee4f323e4fad4f14f3e1a6 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 23 Aug 2019 16:25:13 -0700 Subject: [PATCH 1344/1555] Add LDXX to Rakefile --- Rakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Rakefile b/Rakefile index 8123dc541dc..f791d7e1c85 100755 --- a/Rakefile +++ b/Rakefile @@ -105,6 +105,7 @@ task 'dlls' do env_comp = "CC=#{opt[:cross]}-gcc " env_comp += "CXX=#{opt[:cross]}-g++ " env_comp += "LD=#{opt[:cross]}-gcc " + env_comp += "LDXX=#{opt[:cross]}-g++ " docker_for_windows "gem update --system --no-document && #{env} #{env_comp} make -j #{out} && #{opt[:cross]}-strip -x -S #{out} && cp #{out} #{opt[:out]}" end From e21ec5d4d5d7f549d65f32535229ed0eb58bd73c Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 23 Aug 2019 16:46:01 -0700 Subject: [PATCH 1345/1555] clang-format --- src/objective-c/ProtoRPC/ProtoService.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/ProtoRPC/ProtoService.h b/src/objective-c/ProtoRPC/ProtoService.h index 45376a94353..fd8a86bb2b2 100644 --- a/src/objective-c/ProtoRPC/ProtoService.h +++ b/src/objective-c/ProtoRPC/ProtoService.h @@ -18,8 +18,8 @@ #import -#import "ProtoRPC.h" #import +#import "ProtoRPC.h" @protocol GRXWriteable; @class GRXWriter; From 4dffd825242d28df4995073d1864ee036f44cbca Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Sat, 24 Aug 2019 11:57:57 -0700 Subject: [PATCH 1346/1555] Fix type unmatch --- src/cpp/client/secure_credentials.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index ebff8af3e5a..d870dca158a 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -407,7 +407,7 @@ int MetadataCredentialsPluginWrapper::GetMetadata( *num_creds_md = 0; *status = GRPC_STATUS_OK; *error_details = nullptr; - return true; + return 1; } if (w->plugin_->IsBlocking()) { // The internals of context may be destroyed if GetMetadata is cancelled. From 3869f43953b9995a46e5ad3210446a78e18eabbb Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 26 Aug 2019 08:56:17 +0200 Subject: [PATCH 1347/1555] only run libuv portability tests as build-only --- tools/run_tests/run_tests_matrix.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index 06a52b0f76e..80c0a7d6455 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -403,13 +403,17 @@ def _create_portability_test_jobs(extra_args=[], extra_args=extra_args, inner_jobs=inner_jobs) + # TODO(jtattermusch): a large portion of the libuv tests is failing, + # which can end up killing the kokoro job due to gigabytes of error logs + # generated. Remove the --build_only flag + # once https://github.com/grpc/grpc/issues/17556 is fixed. test_jobs += _generate_jobs( languages=['c'], configs=['dbg'], platforms=['linux'], iomgr_platforms=['uv'], labels=['portability', 'corelang'], - extra_args=extra_args, + extra_args=extra_args + ['--build_only'], inner_jobs=inner_jobs, timeout_seconds=_CPP_RUNTESTS_TIMEOUT) From 64b8ce5ef2e8987e6a4901bf8f152f3b62532a74 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 26 Aug 2019 10:46:47 -0400 Subject: [PATCH 1348/1555] enable grpc-dotnet client compression interop tests --- tools/run_tests/run_interop_tests.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py index d35723c917e..0ec4478fcc8 100755 --- a/tools/run_tests/run_interop_tests.py +++ b/tools/run_tests/run_interop_tests.py @@ -207,14 +207,13 @@ class AspNetCoreLanguage: return {} def unimplemented_test_cases(self): - return _SKIP_COMPRESSION + \ - ['compute_engine_creds'] + \ + return ['compute_engine_creds'] + \ ['jwt_token_creds'] + \ _SKIP_GOOGLE_DEFAULT_CREDS + \ _SKIP_COMPUTE_ENGINE_CHANNEL_CREDS def unimplemented_test_cases_server(self): - return _SKIP_COMPRESSION + return _SKIP_SERVER_COMPRESSION def __str__(self): return 'aspnetcore' From b804ce974a75a2d32fe186f6abdc3493eb851ee4 Mon Sep 17 00:00:00 2001 From: Neeraj Kashyap Date: Mon, 26 Aug 2019 08:43:46 -0700 Subject: [PATCH 1349/1555] Implemented _abort method on ServicerContext This acquires a lock from the _condition member of the context's _rpc and then aborts the _rpc directly --- .../grpcio_testing/grpc_testing/_server/_servicer_context.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py b/src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py index 63a1b1aec95..0f9c4ed4b00 100644 --- a/src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py +++ b/src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py @@ -74,7 +74,8 @@ class ServicerContext(grpc.ServicerContext): _common.fuss_with_metadata(trailing_metadata)) def abort(self, code, details): - raise NotImplementedError() + self._rpc._condition.acquire() + self._rpc._abort(code, details) def abort_with_status(self, status): raise NotImplementedError() From 57586a1ca7f17b1916aed3dea4ff8de872dbf853 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Fri, 3 May 2019 08:11:00 -0700 Subject: [PATCH 1350/1555] Rename gettid() functions. glibc 2.30 will declare its own gettid; see https://sourceware.org/git/?p=glibc.git;a=commit;h=1d0fc213824eaa2a8f8c4385daaa698ee8fb7c92. Rename the grpc versions to avoid naming conflicts. --- src/core/lib/gpr/log_linux.cc | 6 ++---- src/core/lib/gpr/log_posix.cc | 4 ++-- src/core/lib/iomgr/ev_epollex_linux.cc | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/core/lib/gpr/log_linux.cc b/src/core/lib/gpr/log_linux.cc index 81026e5689b..8b597b4cf2f 100644 --- a/src/core/lib/gpr/log_linux.cc +++ b/src/core/lib/gpr/log_linux.cc @@ -40,9 +40,7 @@ #include #include -// Not naming it as gettid() to avoid duplicate declarations when complied with -// GCC 9.1. -static long local_gettid(void) { return syscall(__NR_gettid); } +static long sys_gettid(void) { return syscall(__NR_gettid); } void gpr_log(const char* file, int line, gpr_log_severity severity, const char* format, ...) { @@ -72,7 +70,7 @@ void gpr_default_log(gpr_log_func_args* args) { gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME); struct tm tm; static __thread long tid = 0; - if (tid == 0) tid = local_gettid(); + if (tid == 0) tid = sys_gettid(); timer = static_cast(now.tv_sec); final_slash = strrchr(args->file, '/'); diff --git a/src/core/lib/gpr/log_posix.cc b/src/core/lib/gpr/log_posix.cc index b6edc14ab6b..2f7c6ce3760 100644 --- a/src/core/lib/gpr/log_posix.cc +++ b/src/core/lib/gpr/log_posix.cc @@ -31,7 +31,7 @@ #include #include -static intptr_t gettid(void) { return (intptr_t)pthread_self(); } +static intptr_t sys_gettid(void) { return (intptr_t)pthread_self(); } void gpr_log(const char* file, int line, gpr_log_severity severity, const char* format, ...) { @@ -86,7 +86,7 @@ void gpr_default_log(gpr_log_func_args* args) { char* prefix; gpr_asprintf(&prefix, "%s%s.%09d %7" PRIdPTR " %s:%d]", gpr_log_severity_string(args->severity), time_buffer, - (int)(now.tv_nsec), gettid(), display_file, args->line); + (int)(now.tv_nsec), sys_gettid(), display_file, args->line); fprintf(stderr, "%-70s %s\n", prefix, args->message); gpr_free(prefix); diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc index c2d80c08ddb..4a83cb6c215 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.cc +++ b/src/core/lib/iomgr/ev_epollex_linux.cc @@ -1077,7 +1077,7 @@ static void end_worker(grpc_pollset* pollset, grpc_pollset_worker* worker, } #ifndef NDEBUG -static long gettid(void) { return syscall(__NR_gettid); } +static long sys_gettid(void) { return syscall(__NR_gettid); } #endif /* pollset->mu lock must be held by the caller before calling this. @@ -1097,7 +1097,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset, #define WORKER_PTR (&worker) #endif #ifndef NDEBUG - WORKER_PTR->originator = gettid(); + WORKER_PTR->originator = sys_gettid(); #endif if (GRPC_TRACE_FLAG_ENABLED(grpc_polling_trace)) { gpr_log(GPR_INFO, From 1ab9225dcef223610cd4992482363bd927f41a5c Mon Sep 17 00:00:00 2001 From: Neeraj Kashyap Date: Mon, 26 Aug 2019 10:57:35 -0700 Subject: [PATCH 1351/1555] Release the lock on the RPC object condition --- .../grpcio_testing/grpc_testing/_server/_servicer_context.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py b/src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py index 0f9c4ed4b00..b1277fa4a42 100644 --- a/src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py +++ b/src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py @@ -76,6 +76,7 @@ class ServicerContext(grpc.ServicerContext): def abort(self, code, details): self._rpc._condition.acquire() self._rpc._abort(code, details) + self._rpc._condition.release() def abort_with_status(self, status): raise NotImplementedError() From 5c173084f8af589a1bad3ba44cabedb1c781470b Mon Sep 17 00:00:00 2001 From: Neeraj Kashyap Date: Mon, 26 Aug 2019 11:07:58 -0700 Subject: [PATCH 1352/1555] condition acquire and release with context manager Was previously unfamiliar with the contex manager wrapper around threading primitives. --- .../grpcio_testing/grpc_testing/_server/_servicer_context.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py b/src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py index b1277fa4a42..6fa8c6b3ba8 100644 --- a/src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py +++ b/src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py @@ -74,9 +74,8 @@ class ServicerContext(grpc.ServicerContext): _common.fuss_with_metadata(trailing_metadata)) def abort(self, code, details): - self._rpc._condition.acquire() - self._rpc._abort(code, details) - self._rpc._condition.release() + with self._rpc._condition: + self._rpc._abort(code, details) def abort_with_status(self, status): raise NotImplementedError() From d9c0d498f224366263b0fc7cff9752eec48172cd Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Mon, 26 Aug 2019 11:33:44 -0700 Subject: [PATCH 1353/1555] Stop the failing tests --- src/python/grpcio_tests/commands.py | 5 ++++- .../grpcio_tests/tests/unit/_local_credentials_test.py | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/python/grpcio_tests/commands.py b/src/python/grpcio_tests/commands.py index 61d8bdc1f7b..d30daacd5ac 100644 --- a/src/python/grpcio_tests/commands.py +++ b/src/python/grpcio_tests/commands.py @@ -160,7 +160,10 @@ class TestGevent(setuptools.Command): ) BANNED_WINDOWS_TESTS = ( # TODO(https://github.com/grpc/grpc/pull/15411) enable this test - 'unit._dns_resolver_test.DNSResolverTest.test_connect_loopback',) + 'unit._dns_resolver_test.DNSResolverTest.test_connect_loopback', + # TODO(https://github.com/grpc/grpc/issues/20078) enable this test + 'unit._local_credentials_test.LocalCredentialsTest', + ) description = 'run tests with gevent. Assumes grpc/gevent are installed' user_options = [] diff --git a/src/python/grpcio_tests/tests/unit/_local_credentials_test.py b/src/python/grpcio_tests/tests/unit/_local_credentials_test.py index 80a21af1cef..14b68cb5907 100644 --- a/src/python/grpcio_tests/tests/unit/_local_credentials_test.py +++ b/src/python/grpcio_tests/tests/unit/_local_credentials_test.py @@ -49,6 +49,8 @@ class LocalCredentialsTest(unittest.TestCase): b'abc', wait_for_ready=True)) server.stop(None) + @unittest.skipIf(os.name == 'nt', + 'Unix Domain Socket is not supported on Windows') def test_uds(self): server_addr = 'unix:/tmp/grpc_fullstack_test' channel_creds = grpc.local_channel_credentials( From 5b1899160a3af87a2f90b9732b9222b156fe3cb5 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Mon, 26 Aug 2019 11:51:28 -0700 Subject: [PATCH 1354/1555] Run auditwheel-show to python artifacts --- .../grpc_artifact_python_manylinux_x64/Dockerfile | 6 +++--- .../grpc_artifact_python_manylinux_x86/Dockerfile | 7 ++++--- tools/run_tests/artifacts/build_artifact_python.sh | 2 ++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile b/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile index 6c2b1cc4740..c36ad6bec58 100644 --- a/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile +++ b/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile @@ -32,7 +32,7 @@ RUN /opt/python/cp37-cp37m/bin/pip install cython #################################################### # Install auditwheel with fix for namespace packages RUN git clone https://github.com/pypa/auditwheel /usr/local/src/auditwheel -RUN cd /usr/local/src/auditwheel && git checkout bf071b38c9fe78b025ea05c78b1cb61d7cb09939 -RUN /opt/python/cp35-cp35m/bin/pip install /usr/local/src/auditwheel +RUN cd /usr/local/src/auditwheel && git checkout 2.1 +RUN /opt/python/cp36-cp36m/bin/pip install /usr/local/src/auditwheel RUN rm /usr/local/bin/auditwheel -RUN cd /usr/local/bin && ln -s /opt/python/cp35-cp35m/bin/auditwheel +RUN cd /usr/local/bin && ln -s /opt/python/cp36-cp36m/bin/auditwheel diff --git a/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile b/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile index 8f409dd2162..a33e0517ae2 100644 --- a/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile +++ b/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile @@ -32,7 +32,8 @@ RUN /opt/python/cp37-cp37m/bin/pip install cython #################################################### # Install auditwheel with fix for namespace packages RUN git clone https://github.com/pypa/auditwheel /usr/local/src/auditwheel -RUN cd /usr/local/src/auditwheel && git checkout bf071b38c9fe78b025ea05c78b1cb61d7cb09939 -RUN /opt/python/cp35-cp35m/bin/pip install /usr/local/src/auditwheel +RUN cd /usr/local/src/auditwheel && git checkout 2.1 +RUN /opt/python/cp36-cp36m/bin/pip install /usr/local/src/auditwheel RUN rm /usr/local/bin/auditwheel -RUN cd /usr/local/bin && ln -s /opt/python/cp35-cp35m/bin/auditwheel +RUN cd /usr/local/bin && ln -s /opt/python/cp36-cp36m/bin/auditwheel + diff --git a/tools/run_tests/artifacts/build_artifact_python.sh b/tools/run_tests/artifacts/build_artifact_python.sh index 55fd4ead04d..7393b88a768 100755 --- a/tools/run_tests/artifacts/build_artifact_python.sh +++ b/tools/run_tests/artifacts/build_artifact_python.sh @@ -79,10 +79,12 @@ ${SETARCH_CMD} "${PYTHON}" tools/distrib/python/grpcio_tools/setup.py bdist_whee if [ "$GRPC_BUILD_MANYLINUX_WHEEL" != "" ] then for wheel in dist/*.whl; do + "${AUDITWHEEL}" show "$wheel" | tee /dev/stderr | grep \"manylinux1 "${AUDITWHEEL}" repair "$wheel" -w "$ARTIFACT_DIR" rm "$wheel" done for wheel in tools/distrib/python/grpcio_tools/dist/*.whl; do + "${AUDITWHEEL}" show "$wheel" | tee /dev/stderr | grep \"manylinux1 "${AUDITWHEEL}" repair "$wheel" -w "$ARTIFACT_DIR" rm "$wheel" done From 750a8ab6ca22e85df38d3d54845ac489c94ac0df Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Mon, 26 Aug 2019 12:05:21 -0700 Subject: [PATCH 1355/1555] Fix import --- src/python/grpcio_tests/tests/unit/_local_credentials_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python/grpcio_tests/tests/unit/_local_credentials_test.py b/src/python/grpcio_tests/tests/unit/_local_credentials_test.py index 14b68cb5907..8690505b861 100644 --- a/src/python/grpcio_tests/tests/unit/_local_credentials_test.py +++ b/src/python/grpcio_tests/tests/unit/_local_credentials_test.py @@ -14,6 +14,7 @@ """Test of RPCs made using local credentials.""" import unittest +import os from concurrent.futures import ThreadPoolExecutor import grpc From 80163ef83b800d9aad1740b1762514a7aca5dddc Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Sat, 24 Aug 2019 10:39:38 -0700 Subject: [PATCH 1356/1555] Update BUILD file accordingly --- src/objective-c/BUILD | 1 + 1 file changed, 1 insertion(+) diff --git a/src/objective-c/BUILD b/src/objective-c/BUILD index e71dd3eed81..5f53486d17e 100644 --- a/src/objective-c/BUILD +++ b/src/objective-c/BUILD @@ -232,6 +232,7 @@ grpc_objc_library( ], hdrs = [ "ProtoRPC/ProtoMethod.h", + "ProtoRPC/ProtoRPC.h", "ProtoRPC/ProtoRPCLegacy.h", "ProtoRPC/ProtoService.h", ], From 8f403431a153b75665f8d737489862e9e1460aff Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Mon, 26 Aug 2019 13:57:20 -0700 Subject: [PATCH 1357/1555] Try to disable it again --- src/python/grpcio_tests/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/grpcio_tests/commands.py b/src/python/grpcio_tests/commands.py index d30daacd5ac..2ea6de28bb7 100644 --- a/src/python/grpcio_tests/commands.py +++ b/src/python/grpcio_tests/commands.py @@ -162,7 +162,7 @@ class TestGevent(setuptools.Command): # TODO(https://github.com/grpc/grpc/pull/15411) enable this test 'unit._dns_resolver_test.DNSResolverTest.test_connect_loopback', # TODO(https://github.com/grpc/grpc/issues/20078) enable this test - 'unit._local_credentials_test.LocalCredentialsTest', + 'unit._local_credentials_test.LocalCredentialsTest.test_local_tcp', ) description = 'run tests with gevent. Assumes grpc/gevent are installed' user_options = [] From 2707fd0bd406488665776dfd89987d95e26e2d51 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 23 Aug 2019 15:47:40 -0700 Subject: [PATCH 1358/1555] Added GRPC_USE_CPP_STD_LIB flag --- BUILD | 5 +++++ bazel/grpc_build_system.bzl | 3 +++ include/grpc/impl/codegen/port_platform.h | 9 +++++++++ .../lb_policy/xds/xds_client_stats.cc | 8 ++++++++ .../lb_policy/xds/xds_load_balancer_api.cc | 8 ++++++++ src/core/lib/gprpp/abstract.h | 10 ++++++++++ src/core/lib/gprpp/map.h | 16 ++++++++++++++++ src/core/lib/security/credentials/credentials.h | 10 ++++++++-- test/core/gprpp/map_test.cc | 9 +++++++++ .../linux/grpc_bazel_build_in_docker.sh | 1 + 10 files changed, 77 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index c510757c35d..6855ad9602e 100644 --- a/BUILD +++ b/BUILD @@ -73,6 +73,11 @@ config_setting( values = {"cpu": "darwin"}, ) +config_setting( + name = "grpc_use_cpp_std_lib", + values = {"define": "GRPC_USE_CPP_STD_LIB=1"}, +) + # This should be updated along with build.yaml g_stands_for = "ganges" diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index f816fe14ff4..23f90d0dc80 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -98,6 +98,9 @@ def grpc_cc_library( "//:grpc_allow_exceptions": ["GRPC_ALLOW_EXCEPTIONS=1"], "//:grpc_disallow_exceptions": ["GRPC_ALLOW_EXCEPTIONS=0"], "//conditions:default": [], + }) + select({ + "//:grpc_use_cpp_std_lib": ["GRPC_USE_CPP_STD_LIB=1"], + "//conditions:default": [], }), hdrs = hdrs + public_hdrs, deps = deps + _get_external_deps(external_deps), diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index dd49a66fe25..bab57657a00 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -27,6 +27,15 @@ * - some syscalls to be made directly */ +/* + * Defines GRPC_USE_CPP_STD_LIB to use standard C++ library instead of + * in-house library if possible. (e.g. std::map) + */ +#ifndef GRPC_USE_CPP_STD_LIB +/* Default value will be 1 once all tests become green. */ +#define GRPC_USE_CPP_STD_LIB 0 +#endif + /* Get windows.h included everywhere (we need it) */ #if defined(_WIN64) || defined(WIN64) || defined(_WIN32) || defined(WIN32) #ifndef WIN32_LEAN_AND_MEAN diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc index 85f7d669ec0..a866d50b3a6 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc @@ -143,7 +143,15 @@ XdsClientStats::Snapshot XdsClientStats::GetSnapshotAndReset() { } { MutexLock lock(&dropped_requests_mu_); +#if GRPC_USE_CPP_STD_LIB + // This is a workaround for the case where some compilers cannot build + // move-assignment of map with non-copyable but movable key. + // https://stackoverflow.com/questions/36475497 + std::swap(snapshot.dropped_requests, dropped_requests_); + dropped_requests_.clear(); +#else snapshot.dropped_requests = std::move(dropped_requests_); +#endif } return snapshot; } diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc index ac87053d47f..16d5f9a1391 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc @@ -315,7 +315,15 @@ grpc_slice XdsLrsRequestCreateAndEncode(const char* server_name) { namespace { void LocalityStatsPopulate(envoy_api_v2_endpoint_UpstreamLocalityStats* output, +#if GRPC_USE_CPP_STD_LIB + // TODO(veblush): Clean up this + // This is to address the difference between + // std::map and Map. #else block will be gone + // once using stdlib is enabled by default. + Pair, +#else Pair, +#endif XdsClientStats::LocalityStats::Snapshot>& input, upb_arena* arena) { // Set sub_zone. diff --git a/src/core/lib/gprpp/abstract.h b/src/core/lib/gprpp/abstract.h index 5b7018e07e0..ea68e3ab041 100644 --- a/src/core/lib/gprpp/abstract.h +++ b/src/core/lib/gprpp/abstract.h @@ -19,6 +19,14 @@ #ifndef GRPC_CORE_LIB_GPRPP_ABSTRACT_H #define GRPC_CORE_LIB_GPRPP_ABSTRACT_H +#if GRPC_USE_CPP_STD_LIB + +#define GRPC_ABSTRACT_BASE_CLASS + +#define GRPC_ABSTRACT = 0 + +#else + // This is needed to support abstract base classes in the c core. Since gRPC // doesn't have a c++ runtime, it will hit a linker error on delete unless // we define a virtual operator delete. See this blog for more info: @@ -34,4 +42,6 @@ GPR_ASSERT(false); \ } +#endif // GRPC_USE_CPP_STD_LIB + #endif /* GRPC_CORE_LIB_GPRPP_ABSTRACT_H */ diff --git a/src/core/lib/gprpp/map.h b/src/core/lib/gprpp/map.h index 705b605e5b9..134625775cf 100644 --- a/src/core/lib/gprpp/map.h +++ b/src/core/lib/gprpp/map.h @@ -27,12 +27,17 @@ #include #include +#if GRPC_USE_CPP_STD_LIB +#include +#endif + #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/pair.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" namespace grpc_core { + struct StringLess { bool operator()(const char* a, const char* b) const { return strcmp(a, b) < 0; @@ -50,6 +55,13 @@ struct RefCountedPtrLess { } }; +#if GRPC_USE_CPP_STD_LIB + +template > +using Map = std::map; + +#else // GRPC_USE_CPP_STD_LIB + namespace testing { class MapTest; } @@ -537,5 +549,9 @@ int Map::CompareKeys(const key_type& lhs, } return left_comparison ? -1 : 1; } + +#endif // GRPC_USE_CPP_STD_LIB + } // namespace grpc_core + #endif /* GRPC_CORE_LIB_GPRPP_MAP_H */ diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h index f3fbe881598..b43405b0861 100644 --- a/src/core/lib/security/credentials/credentials.h +++ b/src/core/lib/security/credentials/credentials.h @@ -110,11 +110,17 @@ struct grpc_channel_credentials create_security_connector( grpc_core::RefCountedPtr call_creds, const char* target, const grpc_channel_args* args, - grpc_channel_args** new_args) { + grpc_channel_args** new_args) +#if GRPC_USE_CPP_STD_LIB + = 0; +#else + { // Tell clang-tidy that call_creds cannot be passed as const-ref. call_creds.reset(); - GRPC_ABSTRACT; + gpr_log(GPR_ERROR, "Function marked GRPC_ABSTRACT was not implemented"); + GPR_ASSERT(false); } +#endif // Creates a version of the channel credentials without any attached call // credentials. This can be used in order to open a channel to a non-trusted diff --git a/test/core/gprpp/map_test.cc b/test/core/gprpp/map_test.cc index b0be7960b57..7dc1ba636f3 100644 --- a/test/core/gprpp/map_test.cc +++ b/test/core/gprpp/map_test.cc @@ -29,6 +29,13 @@ namespace grpc_core { namespace testing { + +#if GRPC_USE_CPP_STD_LIB + +TEST(MapTest, Nop) {} + +#else + class Payload { public: Payload() : data_(-1) {} @@ -495,6 +502,8 @@ TEST_F(MapTest, CopyAssignment) { EXPECT_EQ(test_map2.end(), test_map2.find("xxx")); } +#endif + } // namespace testing } // namespace grpc_core diff --git a/tools/internal_ci/linux/grpc_bazel_build_in_docker.sh b/tools/internal_ci/linux/grpc_bazel_build_in_docker.sh index 24598f43f02..8487ec49bbd 100755 --- a/tools/internal_ci/linux/grpc_bazel_build_in_docker.sh +++ b/tools/internal_ci/linux/grpc_bazel_build_in_docker.sh @@ -25,3 +25,4 @@ git clone /var/local/jenkins/grpc /var/local/git/grpc ${name}') cd /var/local/git/grpc bazel build --spawn_strategy=standalone --genrule_strategy=standalone :all test/... examples/... +bazel build --spawn_strategy=standalone --genrule_strategy=standalone --define=GRPC_USE_CPP_STD_LIB=1 :grpc From 630e6ab2212a99c26f4cda89f1459a0205f70763 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Mon, 26 Aug 2019 15:55:42 -0700 Subject: [PATCH 1359/1555] Use the correct machanism to ignore test in Windows --- src/python/grpcio_tests/commands.py | 4 +--- src/python/grpcio_tests/tests/unit/_local_credentials_test.py | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/python/grpcio_tests/commands.py b/src/python/grpcio_tests/commands.py index 2ea6de28bb7..3758d995a97 100644 --- a/src/python/grpcio_tests/commands.py +++ b/src/python/grpcio_tests/commands.py @@ -161,8 +161,6 @@ class TestGevent(setuptools.Command): BANNED_WINDOWS_TESTS = ( # TODO(https://github.com/grpc/grpc/pull/15411) enable this test 'unit._dns_resolver_test.DNSResolverTest.test_connect_loopback', - # TODO(https://github.com/grpc/grpc/issues/20078) enable this test - 'unit._local_credentials_test.LocalCredentialsTest.test_local_tcp', ) description = 'run tests with gevent. Assumes grpc/gevent are installed' user_options = [] @@ -189,7 +187,7 @@ class TestGevent(setuptools.Command): loader = tests.Loader() loader.loadTestsFromNames(['tests']) runner = tests.Runner() - if sys.platform == 'win32': + if os.name == 'nt': runner.skip_tests(self.BANNED_TESTS + self.BANNED_WINDOWS_TESTS) else: runner.skip_tests(self.BANNED_TESTS) diff --git a/src/python/grpcio_tests/tests/unit/_local_credentials_test.py b/src/python/grpcio_tests/tests/unit/_local_credentials_test.py index 8690505b861..7f3e8cc41c9 100644 --- a/src/python/grpcio_tests/tests/unit/_local_credentials_test.py +++ b/src/python/grpcio_tests/tests/unit/_local_credentials_test.py @@ -33,6 +33,8 @@ class LocalCredentialsTest(unittest.TestCase): server.add_generic_rpc_handlers((_GenericHandler(),)) return server + @unittest.skipIf(os.name == 'nt', + 'TODO(https://github.com/grpc/grpc/issues/20078)') def test_local_tcp(self): server_addr = 'localhost:{}' channel_creds = grpc.local_channel_credentials( From a2990a053cdeb1737062b11188a1357a18441f62 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Mon, 26 Aug 2019 15:57:02 -0700 Subject: [PATCH 1360/1555] Revert changes in src/python/grpcio_tests/commands.py --- src/python/grpcio_tests/commands.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/python/grpcio_tests/commands.py b/src/python/grpcio_tests/commands.py index 3758d995a97..61d8bdc1f7b 100644 --- a/src/python/grpcio_tests/commands.py +++ b/src/python/grpcio_tests/commands.py @@ -160,8 +160,7 @@ class TestGevent(setuptools.Command): ) BANNED_WINDOWS_TESTS = ( # TODO(https://github.com/grpc/grpc/pull/15411) enable this test - 'unit._dns_resolver_test.DNSResolverTest.test_connect_loopback', - ) + 'unit._dns_resolver_test.DNSResolverTest.test_connect_loopback',) description = 'run tests with gevent. Assumes grpc/gevent are installed' user_options = [] @@ -187,7 +186,7 @@ class TestGevent(setuptools.Command): loader = tests.Loader() loader.loadTestsFromNames(['tests']) runner = tests.Runner() - if os.name == 'nt': + if sys.platform == 'win32': runner.skip_tests(self.BANNED_TESTS + self.BANNED_WINDOWS_TESTS) else: runner.skip_tests(self.BANNED_TESTS) From 15b279ab69dc4447ed960673987e4b031441117c Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Mon, 26 Aug 2019 15:09:20 -0700 Subject: [PATCH 1361/1555] Add auditwheel to linux docker --- .../grpc_artifact_linux_x64/Dockerfile | 12 ++++++++++-- .../grpc_artifact_linux_x86/Dockerfile | 16 ++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/tools/dockerfile/grpc_artifact_linux_x64/Dockerfile b/tools/dockerfile/grpc_artifact_linux_x64/Dockerfile index a0fef12d6e1..b3c16951229 100644 --- a/tools/dockerfile/grpc_artifact_linux_x64/Dockerfile +++ b/tools/dockerfile/grpc_artifact_linux_x64/Dockerfile @@ -57,10 +57,10 @@ RUN \curl -sSL https://get.rvm.io | bash -s stable # Install Ruby 2.1 RUN /bin/bash -l -c "rvm install ruby-2.1" RUN /bin/bash -l -c "rvm use --default ruby-2.1" -RUN /bin/bash -l -c "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc" +RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.1' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-ri --no-rdoc" +RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" ################## @@ -79,6 +79,14 @@ RUN echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf RUN sed -i '/deb http:\/\/deb.debian.org\/debian jessie-updates main/d' /etc/apt/sources.list RUN apt-get update && apt-get install -t jessie-backports -y cmake && apt-get clean + +################## +# Python AuditWheel dependencies (needed to check manylinux1 compatibility) + +RUN apt-get install -y python3 python3-pip +RUN pip3 install auditwheel==1.10.0 + + RUN mkdir /var/local/jenkins # Define the default command. diff --git a/tools/dockerfile/grpc_artifact_linux_x86/Dockerfile b/tools/dockerfile/grpc_artifact_linux_x86/Dockerfile index 8709fe0426c..c9054653067 100644 --- a/tools/dockerfile/grpc_artifact_linux_x86/Dockerfile +++ b/tools/dockerfile/grpc_artifact_linux_x86/Dockerfile @@ -14,7 +14,7 @@ # Docker file for building gRPC artifacts. -FROM 32bit/debian:jessie +FROM i386/debian:jessie RUN sed -i '/deb http:\/\/http.debian.net\/debian jessie-updates main/d' /etc/apt/sources.list # Install Git and basic packages. @@ -49,7 +49,6 @@ RUN apt-get update && apt-get install -y \ ################## # Ruby dependencies -# Install rvm # Install rvm RUN apt-get update && apt-get install -y gnupg2 RUN gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB @@ -58,10 +57,11 @@ RUN \curl -sSL https://get.rvm.io | bash -s stable # Install Ruby 2.1 RUN /bin/bash -l -c "rvm install ruby-2.1" RUN /bin/bash -l -c "rvm use --default ruby-2.1" -RUN /bin/bash -l -c "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc" +RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc" RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.1' >> ~/.bashrc" -RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-ri --no-rdoc" +RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document" + ################## # C# dependencies (needed to build grpc_csharp_ext) @@ -72,6 +72,14 @@ RUN echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf RUN sed -i '/deb http:\/\/deb.debian.org\/debian jessie-updates main/d' /etc/apt/sources.list RUN apt-get update && apt-get install -t jessie-backports -y cmake && apt-get clean + +################## +# Python AuditWheel dependencies (needed to check manylinux1 compatibility) + +RUN apt-get install -y python3 python3-pip +RUN pip3 install auditwheel==1.10.0 + + RUN mkdir /var/local/jenkins # Define the default command. From caf64469f0fbfd34c5d4a8ff81eebaa6cce69236 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Tue, 27 Aug 2019 10:08:29 +0800 Subject: [PATCH 1362/1555] Update: rename the folder --- examples/python/{easy_start_demo => data_transmission}/README.md | 0 examples/python/{easy_start_demo => data_transmission}/client.py | 0 examples/python/{easy_start_demo => data_transmission}/demo.proto | 0 .../demo_grpc_pbs/demo_pb2.py | 0 .../demo_grpc_pbs/demo_pb2_grpc.py | 0 examples/python/{easy_start_demo => data_transmission}/server.py | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename examples/python/{easy_start_demo => data_transmission}/README.md (100%) rename examples/python/{easy_start_demo => data_transmission}/client.py (100%) rename examples/python/{easy_start_demo => data_transmission}/demo.proto (100%) rename examples/python/{easy_start_demo => data_transmission}/demo_grpc_pbs/demo_pb2.py (100%) rename examples/python/{easy_start_demo => data_transmission}/demo_grpc_pbs/demo_pb2_grpc.py (100%) rename examples/python/{easy_start_demo => data_transmission}/server.py (100%) diff --git a/examples/python/easy_start_demo/README.md b/examples/python/data_transmission/README.md similarity index 100% rename from examples/python/easy_start_demo/README.md rename to examples/python/data_transmission/README.md diff --git a/examples/python/easy_start_demo/client.py b/examples/python/data_transmission/client.py similarity index 100% rename from examples/python/easy_start_demo/client.py rename to examples/python/data_transmission/client.py diff --git a/examples/python/easy_start_demo/demo.proto b/examples/python/data_transmission/demo.proto similarity index 100% rename from examples/python/easy_start_demo/demo.proto rename to examples/python/data_transmission/demo.proto diff --git a/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2.py b/examples/python/data_transmission/demo_grpc_pbs/demo_pb2.py similarity index 100% rename from examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2.py rename to examples/python/data_transmission/demo_grpc_pbs/demo_pb2.py diff --git a/examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2_grpc.py b/examples/python/data_transmission/demo_grpc_pbs/demo_pb2_grpc.py similarity index 100% rename from examples/python/easy_start_demo/demo_grpc_pbs/demo_pb2_grpc.py rename to examples/python/data_transmission/demo_grpc_pbs/demo_pb2_grpc.py diff --git a/examples/python/easy_start_demo/server.py b/examples/python/data_transmission/server.py similarity index 100% rename from examples/python/easy_start_demo/server.py rename to examples/python/data_transmission/server.py From 151f5960546e5d25a295dd36f8bc99a1b61dd9ee Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Tue, 27 Aug 2019 10:17:08 +0800 Subject: [PATCH 1363/1555] Fix: Cancel the modification of the package search path and Remove useless notes --- examples/python/data_transmission/client.py | 15 ++------------- .../{demo_grpc_pbs => }/demo_pb2.py | 0 .../{demo_grpc_pbs => }/demo_pb2_grpc.py | 0 examples/python/data_transmission/server.py | 18 ++++-------------- 4 files changed, 6 insertions(+), 27 deletions(-) rename examples/python/data_transmission/{demo_grpc_pbs => }/demo_pb2.py (100%) rename examples/python/data_transmission/{demo_grpc_pbs => }/demo_pb2_grpc.py (100%) diff --git a/examples/python/data_transmission/client.py b/examples/python/data_transmission/client.py index b5b994820a3..21c61d6cc6e 100644 --- a/examples/python/data_transmission/client.py +++ b/examples/python/data_transmission/client.py @@ -1,19 +1,8 @@ -""" -Author: Zhongying Wang -Email: kerbalwzy@gmail.com -DateTime: 2019-08-13T23:30:00Z -PythonVersion: Python3.6.3 -""" -import os -import sys import time import grpc -# add the `demo_grpc_dps` dir into python package search paths -BaseDir = os.path.dirname(os.path.abspath(__file__)) -sys.path.insert(0, os.path.join(BaseDir, "demo_grpc_pbs")) - -from demo_grpc_pbs import demo_pb2, demo_pb2_grpc +import demo_pb2_grpc +import demo_pb2 SERVER_ADDRESS = "localhost:23334" CLIENT_ID = 1 diff --git a/examples/python/data_transmission/demo_grpc_pbs/demo_pb2.py b/examples/python/data_transmission/demo_pb2.py similarity index 100% rename from examples/python/data_transmission/demo_grpc_pbs/demo_pb2.py rename to examples/python/data_transmission/demo_pb2.py diff --git a/examples/python/data_transmission/demo_grpc_pbs/demo_pb2_grpc.py b/examples/python/data_transmission/demo_pb2_grpc.py similarity index 100% rename from examples/python/data_transmission/demo_grpc_pbs/demo_pb2_grpc.py rename to examples/python/data_transmission/demo_pb2_grpc.py diff --git a/examples/python/data_transmission/server.py b/examples/python/data_transmission/server.py index 60fb84768b7..1baba78c0f6 100644 --- a/examples/python/data_transmission/server.py +++ b/examples/python/data_transmission/server.py @@ -1,22 +1,11 @@ -""" -Author: Zhongying Wang -Email: kerbalwzy@gmail.com -DateTime: 2019-08-13T23:30:00Z -PythonVersion: Python3.6.3 -""" -import os -import sys import time import grpc from threading import Thread from concurrent import futures -# add the `demo_grpc_dps` dir into python package search paths -BaseDir = os.path.dirname(os.path.abspath(__file__)) -sys.path.insert(0, os.path.join(BaseDir, "demo_grpc_pbs")) - -from demo_grpc_pbs import demo_pb2, demo_pb2_grpc +import demo_pb2_grpc +import demo_pb2 SERVER_ADDRESS = 'localhost:23334' SERVER_ID = 1 @@ -51,7 +40,8 @@ class DemoServer(demo_pb2_grpc.GRPCDemoServicer): # create a generator def response_messages(): for i in range(5): - response = demo_pb2.Response(server_id=SERVER_ID, response_data=("send by Python server, message=%d" % i)) + response = demo_pb2.Response(server_id=SERVER_ID, + response_data=("send by Python server, message=%d" % i)) yield response return response_messages() From 55f1899d78774c073805a4140e81e98ee1e95e10 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Tue, 27 Aug 2019 10:36:35 +0800 Subject: [PATCH 1364/1555] Update:the max_workers argument use default, use 'server.wait_for_termination()' to keep process alive --- examples/python/data_transmission/server.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/python/data_transmission/server.py b/examples/python/data_transmission/server.py index 1baba78c0f6..e6e51e1b733 100644 --- a/examples/python/data_transmission/server.py +++ b/examples/python/data_transmission/server.py @@ -1,4 +1,3 @@ -import time import grpc from threading import Thread @@ -68,17 +67,21 @@ class DemoServer(demo_pb2_grpc.GRPCDemoServicer): def main(): - server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) + server = grpc.server(futures.ThreadPoolExecutor()) demo_pb2_grpc.add_GRPCDemoServicer_to_server(DemoServer(), server) server.add_insecure_port(SERVER_ADDRESS) print("------------------start Python GRPC server") server.start() + server.wait_for_termination() - # In python3, `server` have no attribute `wait_for_termination` - while 1: - time.sleep(10) + # If raise Error: + # AttributeError: '_Server' object has no attribute 'wait_for_termination' + # You can use the following code instead: + # import time + # while 1: + # time.sleep(10) if __name__ == '__main__': From d5810a155b5a58688067c0f9aaf6bb32d0fab4a7 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Tue, 27 Aug 2019 11:14:36 +0800 Subject: [PATCH 1365/1555] Fix: rebuild README files --- .../python/data_transmission/README.cn.md | 36 +++++++++++++++++++ .../python/data_transmission/README.en.md | 36 +++++++++++++++++++ examples/python/data_transmission/README.md | 28 --------------- 3 files changed, 72 insertions(+), 28 deletions(-) create mode 100644 examples/python/data_transmission/README.cn.md create mode 100644 examples/python/data_transmission/README.en.md delete mode 100644 examples/python/data_transmission/README.md diff --git a/examples/python/data_transmission/README.cn.md b/examples/python/data_transmission/README.cn.md new file mode 100644 index 00000000000..500e9bf95de --- /dev/null +++ b/examples/python/data_transmission/README.cn.md @@ -0,0 +1,36 @@ +## Data transmission demo for using gRPC in Python + +在Python中使用gRPC时, 进行数据传输的四种方式。 + +- #### 简单模式 + + 没啥好说的,跟调普通方法没差 + + `client.py - line:13 - simple_method` + + `server.py - line:17 - SimpleMethod` + +- #### 客户端流模式 + + 在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应. + + `clien.py - line:24 - client_streaming_method ` + + `server.py - line:25 - ClientStreamingMethod` + +- #### 服务端流模式 + + 在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应 + + `clien.py - line:42 - server_streaming_method` + + `server.py - line:35 - ServerStreamingMethod` + +- #### 双向流模式 + + 在一次调用中, 客户端和服务器都可以向对方多次收发数据 + + `client.py - line:55 - bidirectional_streaming_method` + + `server.py - line:51 - BidirectionalStreamingMethod` + diff --git a/examples/python/data_transmission/README.en.md b/examples/python/data_transmission/README.en.md new file mode 100644 index 00000000000..7fc527cf51a --- /dev/null +++ b/examples/python/data_transmission/README.en.md @@ -0,0 +1,36 @@ +## Data transmission demo for using gRPC in Python + +Four ways of data transmission when gRPC is used in Python. + +- #### unary-unary + + There's nothing to say. It's no different from the usual way. + + `client.py - line:13 - simple_method` + + `server.py - line:17 - SimpleMethod` +- #### stream-unary + + In a single call, the client can transfer data to the server an arbitrary number of times, but the server can only return a response once. + + `clien.py - line:24 - client_streaming_method` + + `server.py - line:25 - ClientStreamingMethod` + +- #### unary-stream + + In a single call, the client can only transmit data to the server at one time, but the server can return the response many times. + + `clien.py - line:42 - server_streaming_method` + + `server.py - line:35 - ServerStreamingMethod` + +- #### stream-stream + + In a single call, both client and server can send and receive data + to each other multiple times. + + `client.py - line:55 - bidirectional_streaming_method` + + `server.py - line:51 - BidirectionalStreamingMethod` + diff --git a/examples/python/data_transmission/README.md b/examples/python/data_transmission/README.md deleted file mode 100644 index 919b9c5cc61..00000000000 --- a/examples/python/data_transmission/README.md +++ /dev/null @@ -1,28 +0,0 @@ -## Demo for using gRPC in Python - -在Python中使用gRPC时, 进行数据传输的四种方式。(Four ways of data transmission when gRPC is used in Python.) - -- #### 简单模式 (unary-unary) -```text -没啥好说的,跟调普通方法没差 -There's nothing to say. It's no different from the usual way. -``` -- #### 客户端流模式 (stream-unary) -```text -在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应. -In a single call, the client can transfer data to the server several times, -but the server can only return a response once. -``` -- #### 服务端流模式 (unary-stream) -```text -在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应 -In a single call, the client can only transmit data to the server at one time, -but the server can return the response many times. -``` -- #### 双向流模式 (stream-stream) -```text -在一次调用中, 客户端和服务器都可以向对方多次收发数据 -In a single call, both client and server can send and receive data -to each other multiple times. -``` - From cc4b946e3c37c7c7bb672ba92b43ef8708a65013 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 27 Aug 2019 08:35:09 -0700 Subject: [PATCH 1366/1555] Replace 32bit/debian:jessie with i386/debian:jessie --- .../tools/dockerfile/test/cxx_jessie_x86/Dockerfile.template | 2 +- tools/dockerfile/distribtest/csharp_jessie_x86/Dockerfile | 2 +- tools/dockerfile/distribtest/node_jessie_x86/Dockerfile | 2 +- tools/dockerfile/distribtest/python_dev_jessie_x86/Dockerfile | 2 +- tools/dockerfile/distribtest/python_jessie_x86/Dockerfile | 2 +- tools/dockerfile/distribtest/ruby_jessie_x86/Dockerfile | 2 +- tools/dockerfile/test/cxx_jessie_x86/Dockerfile | 2 +- .../helper_scripts/prepare_build_linux_perf_multilang_rc | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/templates/tools/dockerfile/test/cxx_jessie_x86/Dockerfile.template b/templates/tools/dockerfile/test/cxx_jessie_x86/Dockerfile.template index 36f243c3405..8d9012d6acf 100644 --- a/templates/tools/dockerfile/test/cxx_jessie_x86/Dockerfile.template +++ b/templates/tools/dockerfile/test/cxx_jessie_x86/Dockerfile.template @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. - FROM 32bit/debian:jessie + FROM i386/debian:jessie RUN sed -i '/deb http:\/\/http.debian.net\/debian jessie-updates main/d' /etc/apt/sources.list <%include file="../../apt_get_basic.include"/> diff --git a/tools/dockerfile/distribtest/csharp_jessie_x86/Dockerfile b/tools/dockerfile/distribtest/csharp_jessie_x86/Dockerfile index aec936a5b8c..96b318d8ae0 100644 --- a/tools/dockerfile/distribtest/csharp_jessie_x86/Dockerfile +++ b/tools/dockerfile/distribtest/csharp_jessie_x86/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM 32bit/debian:jessie +FROM i386/debian:jessie RUN apt-get update && apt-get install -y apt-transport-https && apt-get clean diff --git a/tools/dockerfile/distribtest/node_jessie_x86/Dockerfile b/tools/dockerfile/distribtest/node_jessie_x86/Dockerfile index 1db31a5d9c6..aa9695e3173 100644 --- a/tools/dockerfile/distribtest/node_jessie_x86/Dockerfile +++ b/tools/dockerfile/distribtest/node_jessie_x86/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM 32bit/debian:jessie +FROM i386/debian:jessie RUN apt-get update && apt-get install -y curl diff --git a/tools/dockerfile/distribtest/python_dev_jessie_x86/Dockerfile b/tools/dockerfile/distribtest/python_dev_jessie_x86/Dockerfile index 5e0b8efe756..b1d1a31061a 100644 --- a/tools/dockerfile/distribtest/python_dev_jessie_x86/Dockerfile +++ b/tools/dockerfile/distribtest/python_dev_jessie_x86/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM 32bit/debian:jessie +FROM i386/debian:jessie RUN apt-get update && apt-get install -y python python-pip diff --git a/tools/dockerfile/distribtest/python_jessie_x86/Dockerfile b/tools/dockerfile/distribtest/python_jessie_x86/Dockerfile index 140c6cb7afa..d5b63421c59 100644 --- a/tools/dockerfile/distribtest/python_jessie_x86/Dockerfile +++ b/tools/dockerfile/distribtest/python_jessie_x86/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM 32bit/debian:jessie +FROM i386/debian:jessie RUN apt-get update && apt-get install -y python python-pip diff --git a/tools/dockerfile/distribtest/ruby_jessie_x86/Dockerfile b/tools/dockerfile/distribtest/ruby_jessie_x86/Dockerfile index b011f837dd5..04cfa51069c 100644 --- a/tools/dockerfile/distribtest/ruby_jessie_x86/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_jessie_x86/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM 32bit/debian:jessie +FROM i386/debian:jessie RUN apt-get update && apt-get install -y ruby-full diff --git a/tools/dockerfile/test/cxx_jessie_x86/Dockerfile b/tools/dockerfile/test/cxx_jessie_x86/Dockerfile index 59b86d7247c..18611e60d23 100644 --- a/tools/dockerfile/test/cxx_jessie_x86/Dockerfile +++ b/tools/dockerfile/test/cxx_jessie_x86/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM 32bit/debian:jessie +FROM i386/debian:jessie RUN sed -i '/deb http:\/\/http.debian.net\/debian jessie-updates main/d' /etc/apt/sources.list # Install Git and basic packages. diff --git a/tools/internal_ci/helper_scripts/prepare_build_linux_perf_multilang_rc b/tools/internal_ci/helper_scripts/prepare_build_linux_perf_multilang_rc index f1031aedf39..bb1287fee51 100644 --- a/tools/internal_ci/helper_scripts/prepare_build_linux_perf_multilang_rc +++ b/tools/internal_ci/helper_scripts/prepare_build_linux_perf_multilang_rc @@ -30,7 +30,7 @@ sudo pip install tabulate export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)" gem list bundler -gem install bundler --no-ri --no-rdoc +gem install bundler --no-document # Allow SSH to Kokoro performance workers without explicit key verification gsutil cp gs://grpc-testing-secrets/grpc_kokoro_performance_ssh_keys/id_rsa ~/.ssh From 18be57b4dfb3b2b6341f2d0903b5fce12282c1fa Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 27 Aug 2019 11:21:06 -0700 Subject: [PATCH 1367/1555] LB policy API changes suggested by Sanjay. --- .../filters/client_channel/client_channel.cc | 10 ++-- .../ext/filters/client_channel/lb_policy.cc | 2 +- .../ext/filters/client_channel/lb_policy.h | 55 ++++++++++--------- .../client_channel/lb_policy/grpclb/grpclb.cc | 5 +- .../client_channel/lb_policy/xds/xds.cc | 9 ++- .../client_channel/resolving_lb_policy.cc | 4 +- test/core/util/test_lb_policies.cc | 2 +- 7 files changed, 43 insertions(+), 44 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 63bd737e931..f88c1228de0 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -1345,11 +1345,11 @@ class ChannelData::ClientChannelControlHelper // No-op -- we should never get this from ResolvingLoadBalancingPolicy. void RequestReresolution() override {} - void AddTraceEvent(TraceSeverity severity, const char* message) override { + void AddTraceEvent(TraceSeverity severity, StringView message) override { if (chand_->channelz_node_ != nullptr) { chand_->channelz_node_->AddTraceEvent( ConvertSeverityEnum(severity), - grpc_slice_from_copied_string(message)); + grpc_slice_from_copied_buffer(message.data(), message.size())); } } @@ -3730,8 +3730,8 @@ const char* PickResultTypeName( return "COMPLETE"; case LoadBalancingPolicy::PickResult::PICK_QUEUE: return "QUEUE"; - case LoadBalancingPolicy::PickResult::PICK_TRANSIENT_FAILURE: - return "TRANSIENT_FAILURE"; + case LoadBalancingPolicy::PickResult::PICK_FAILED: + return "FAILED"; } GPR_UNREACHABLE_CODE(return "UNKNOWN"); } @@ -3792,7 +3792,7 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { result.subchannel.get(), grpc_error_string(result.error)); } switch (result.type) { - case LoadBalancingPolicy::PickResult::PICK_TRANSIENT_FAILURE: { + case LoadBalancingPolicy::PickResult::PICK_FAILED: { // If we're shutting down, fail all RPCs. grpc_error* disconnect_error = chand->disconnect_error(); if (disconnect_error != GRPC_ERROR_NONE) { diff --git a/src/core/ext/filters/client_channel/lb_policy.cc b/src/core/ext/filters/client_channel/lb_policy.cc index 3207f888044..41a7d2d07be 100644 --- a/src/core/ext/filters/client_channel/lb_policy.cc +++ b/src/core/ext/filters/client_channel/lb_policy.cc @@ -129,7 +129,7 @@ void LoadBalancingPolicy::QueuePicker::CallExitIdle(void* arg, LoadBalancingPolicy::PickResult LoadBalancingPolicy::TransientFailurePicker::Pick(PickArgs args) { PickResult result; - result.type = PickResult::PICK_TRANSIENT_FAILURE; + result.type = PickResult::PICK_FAILED; result.error = GRPC_ERROR_REF(error_); return result; } diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h index ea4962cdb77..6e7447dd172 100644 --- a/src/core/ext/filters/client_channel/lb_policy.h +++ b/src/core/ext/filters/client_channel/lb_policy.h @@ -42,15 +42,15 @@ extern DebugOnlyTraceFlag grpc_trace_lb_policy_refcount; /// /// Channel: An abstraction that manages connections to backend servers /// on behalf of a client application. The application creates a channel -/// for a given server name and then sends RPCs on it, and the channel -/// figures out which backend server to send each RPC to. A channel +/// for a given server name and then sends calls (RPCs) on it, and the +/// channel figures out which backend server to send each call to. A channel /// contains a resolver, a load balancing policy (or a tree of LB policies), /// and a set of one or more subchannels. /// /// Subchannel: A subchannel represents a connection to one backend server. /// The LB policy decides which subchannels to create, manages the /// connectivity state of those subchannels, and decides which subchannel -/// to send any given RPC to. +/// to send any given call to. /// /// Resolver: A plugin that takes a gRPC server URI and resolves it to a /// list of one or more addresses and a service config, as described @@ -59,12 +59,12 @@ extern DebugOnlyTraceFlag grpc_trace_lb_policy_refcount; /// /// Load Balancing (LB) Policy: A plugin that takes a list of addresses /// from the resolver, maintains and manages a subchannel for each -/// backend address, and decides which subchannel to send each RPC on. +/// backend address, and decides which subchannel to send each call on. /// An LB policy has two parts: /// - A LoadBalancingPolicy, which deals with the control plane work of /// managing subchannels. /// - A SubchannelPicker, which handles the data plane work of -/// determining which subchannel a given RPC should be sent on. +/// determining which subchannel a given call should be sent on. /// LoadBalacingPolicy API. /// @@ -78,6 +78,7 @@ extern DebugOnlyTraceFlag grpc_trace_lb_policy_refcount; class LoadBalancingPolicy : public InternallyRefCounted { public: /// Interface for accessing per-call state. + /// Implemented by the client channel and used by the SubchannelPicker. class CallState { public: CallState() = default; @@ -93,6 +94,7 @@ class LoadBalancingPolicy : public InternallyRefCounted { }; /// Interface for accessing metadata. + /// Implemented by the client channel and used by the SubchannelPicker. class MetadataInterface { public: // Implementations whose iterators fit in intptr_t may internally @@ -123,7 +125,7 @@ class LoadBalancingPolicy : public InternallyRefCounted { GRPC_ABSTRACT_BASE_CLASS }; - /// Arguments used when picking a subchannel for an RPC. + /// Arguments used when picking a subchannel for a call. struct PickArgs { /// Initial metadata associated with the picking call. /// The LB policy may use the existing metadata to influence its routing @@ -135,24 +137,23 @@ class LoadBalancingPolicy : public InternallyRefCounted { CallState* call_state; }; - /// The result of picking a subchannel for an RPC. + /// The result of picking a subchannel for a call. struct PickResult { enum ResultType { - /// Pick complete. If connected_subchannel is non-null, client channel - /// can immediately proceed with the call on connected_subchannel; - /// otherwise, call should be dropped. + /// Pick complete. If \a subchannel is non-null, the client channel + /// will immediately proceed with the call on that subchannel; + /// otherwise, it will drop the call. PICK_COMPLETE, /// Pick cannot be completed until something changes on the control - /// plane. Client channel will queue the pick and try again the + /// plane. The client channel will queue the pick and try again the /// next time the picker is updated. PICK_QUEUE, - /// LB policy is in transient failure. If the pick is wait_for_ready, - /// client channel will wait for the next picker and try again; - /// otherwise, the call will be failed immediately (although it may - /// be retried if the client channel is configured to do so). - /// The Pick() method will set its error parameter if this value is - /// returned. - PICK_TRANSIENT_FAILURE, + /// Pick failed. If the call is wait_for_ready, the client channel + /// will wait for the next picker and try again; otherwise, it + /// will immediately fail the call with the status indicated via + /// \a error (although the call may be retried if the client channel + /// is configured to do so). + PICK_FAILED, }; ResultType type; @@ -160,14 +161,14 @@ class LoadBalancingPolicy : public InternallyRefCounted { /// subchannel, or nullptr if the LB policy decides to drop the call. RefCountedPtr subchannel; - /// Used only if type is PICK_TRANSIENT_FAILURE. - /// Error to be set when returning a transient failure. + /// Used only if type is PICK_FAILED. + /// Error to be set when returning a failure. // TODO(roth): Replace this with something similar to grpc::Status, // so that we don't expose grpc_error to this API. grpc_error* error = GRPC_ERROR_NONE; /// Used only if type is PICK_COMPLETE. - /// Callback set by lb policy to be notified of trailing metadata. + /// Callback set by LB policy to be notified of trailing metadata. /// The user_data argument will be set to the /// recv_trailing_metadata_ready_user_data field. /// recv_trailing_metadata will be set to the metadata, which may be @@ -184,11 +185,12 @@ class LoadBalancingPolicy : public InternallyRefCounted { }; /// A subchannel picker is the object used to pick the subchannel to - /// use for a given RPC. + /// use for a given call. This is implemented by the LB policy and + /// used by the client channel to perform picks. /// /// Pickers are intended to encapsulate all of the state and logic /// needed on the data plane (i.e., to actually process picks for - /// individual RPCs sent on the channel) while excluding all of the + /// individual calls sent on the channel) while excluding all of the /// state and logic needed on the control plane (i.e., resolver /// updates, connectivity state notifications, etc); the latter should /// live in the LB policy object itself. @@ -206,8 +208,8 @@ class LoadBalancingPolicy : public InternallyRefCounted { GRPC_ABSTRACT_BASE_CLASS }; - /// A proxy object used by the LB policy to communicate with the client - /// channel. + /// A proxy object implemented by the client channel and used by the + /// LB policy to communicate with the channel. // TODO(juanlishen): Consider adding a mid-layer subclass that helps handle // things like swapping in pending policy when it's ready. Currently, we are // duplicating the logic in many subclasses. @@ -235,10 +237,9 @@ class LoadBalancingPolicy : public InternallyRefCounted { virtual void RequestReresolution() GRPC_ABSTRACT; /// Adds a trace message associated with the channel. - /// Does NOT take ownership of \a message. enum TraceSeverity { TRACE_INFO, TRACE_WARNING, TRACE_ERROR }; virtual void AddTraceEvent(TraceSeverity severity, - const char* message) GRPC_ABSTRACT; + StringView message) GRPC_ABSTRACT; GRPC_ABSTRACT_BASE_CLASS }; diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 6a565e057b9..c63717bdb92 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -298,7 +298,7 @@ class GrpcLb : public LoadBalancingPolicy { void UpdateState(grpc_connectivity_state state, UniquePtr picker) override; void RequestReresolution() override; - void AddTraceEvent(TraceSeverity severity, const char* message) override; + void AddTraceEvent(TraceSeverity severity, StringView message) override; void set_child(LoadBalancingPolicy* child) { child_ = child; } @@ -756,8 +756,7 @@ void GrpcLb::Helper::RequestReresolution() { } } -void GrpcLb::Helper::AddTraceEvent(TraceSeverity severity, - const char* message) { +void GrpcLb::Helper::AddTraceEvent(TraceSeverity severity, StringView message) { if (parent_->shutting_down_ || (!CalledByPendingChild() && !CalledByCurrentChild())) { return; diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index 75fa544c80a..f40e58e47c5 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -436,7 +436,7 @@ class XdsLb : public LoadBalancingPolicy { void UpdateState(grpc_connectivity_state state, UniquePtr picker) override; void RequestReresolution() override; - void AddTraceEvent(TraceSeverity severity, const char* message) override; + void AddTraceEvent(TraceSeverity severity, StringView message) override; void set_child(LoadBalancingPolicy* child) { child_ = child; } @@ -487,8 +487,7 @@ class XdsLb : public LoadBalancingPolicy { void UpdateState(grpc_connectivity_state state, UniquePtr picker) override; void RequestReresolution() override; - void AddTraceEvent(TraceSeverity severity, - const char* message) override; + void AddTraceEvent(TraceSeverity severity, StringView message) override; void set_child(LoadBalancingPolicy* child) { child_ = child; } private: @@ -774,7 +773,7 @@ void XdsLb::FallbackHelper::RequestReresolution() { } void XdsLb::FallbackHelper::AddTraceEvent(TraceSeverity severity, - const char* message) { + StringView message) { if (parent_->shutting_down_ || (!CalledByPendingFallback() && !CalledByCurrentFallback())) { return; @@ -2510,7 +2509,7 @@ void XdsLb::LocalityMap::LocalityEntry::Helper::RequestReresolution() { } void XdsLb::LocalityMap::LocalityEntry::Helper::AddTraceEvent( - TraceSeverity severity, const char* message) { + TraceSeverity severity, StringView message) { if (entry_->parent_->shutting_down_ || (!CalledByPendingChild() && !CalledByCurrentChild())) { return; diff --git a/src/core/ext/filters/client_channel/resolving_lb_policy.cc b/src/core/ext/filters/client_channel/resolving_lb_policy.cc index b3b455b0ce8..c85e948a55b 100644 --- a/src/core/ext/filters/client_channel/resolving_lb_policy.cc +++ b/src/core/ext/filters/client_channel/resolving_lb_policy.cc @@ -160,7 +160,7 @@ class ResolvingLoadBalancingPolicy::ResolvingControlHelper } } - void AddTraceEvent(TraceSeverity severity, const char* message) override {} + void AddTraceEvent(TraceSeverity severity, StringView message) override {} void set_child(LoadBalancingPolicy* child) { child_ = child; } @@ -435,7 +435,7 @@ void ResolvingLoadBalancingPolicy::ConcatenateAndAddChannelTraceLocked( size_t len = 0; UniquePtr message(gpr_strvec_flatten(&v, &len)); channel_control_helper()->AddTraceEvent(ChannelControlHelper::TRACE_INFO, - message.get()); + StringView(message.get())); gpr_strvec_destroy(&v); } } diff --git a/test/core/util/test_lb_policies.cc b/test/core/util/test_lb_policies.cc index 77e186c6d49..0539a498965 100644 --- a/test/core/util/test_lb_policies.cc +++ b/test/core/util/test_lb_policies.cc @@ -166,7 +166,7 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy parent_->channel_control_helper()->RequestReresolution(); } - void AddTraceEvent(TraceSeverity severity, const char* message) override { + void AddTraceEvent(TraceSeverity severity, StringView message) override { parent_->channel_control_helper()->AddTraceEvent(severity, message); } From 905f52852e6bfeaa09969bc89c9495da01cd31f7 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 27 Aug 2019 12:03:10 -0400 Subject: [PATCH 1368/1555] make python dockerfiles buildable again --- .../dockerfile/debian_testing_repo.include | 3 -- .../grpc_interop_python/Dockerfile.template | 2 +- .../tools/dockerfile/python_stretch.include | 4 ++- .../Dockerfile.template | 16 ++++++++-- .../Dockerfile.template | 2 +- .../Dockerfile.template | 13 +++++---- .../test/sanity/Dockerfile.template | 2 +- .../grpc_interop_python/Dockerfile | 9 +++--- .../test/python_stretch_2.7_x64/Dockerfile | 7 ++--- .../test/python_stretch_3.5_x64/Dockerfile | 7 ++--- .../test/python_stretch_3.6_x64/Dockerfile | 22 ++++++++++---- .../test/python_stretch_3.7_x64/Dockerfile | 9 +++--- .../test/python_stretch_3.8_x64/Dockerfile | 20 +++++++------ .../python_stretch_3.8_x64/get_cpython.sh | 29 ------------------- tools/dockerfile/test/sanity/Dockerfile | 9 +++--- 15 files changed, 73 insertions(+), 81 deletions(-) delete mode 100644 templates/tools/dockerfile/debian_testing_repo.include delete mode 100644 tools/dockerfile/test/python_stretch_3.8_x64/get_cpython.sh diff --git a/templates/tools/dockerfile/debian_testing_repo.include b/templates/tools/dockerfile/debian_testing_repo.include deleted file mode 100644 index 1a5248e2264..00000000000 --- a/templates/tools/dockerfile/debian_testing_repo.include +++ /dev/null @@ -1,3 +0,0 @@ -# Add Debian 'testing' repository -RUN echo 'deb http://ftp.de.debian.org/debian testing main' >> /etc/apt/sources.list -RUN echo 'APT::Default-Release "stable";' | tee -a /etc/apt/apt.conf.d/00local diff --git a/templates/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile.template b/templates/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile.template index f584a2378eb..ac939620d07 100644 --- a/templates/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile.template +++ b/templates/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile.template @@ -16,5 +16,5 @@ <%include file="../../python_stretch.include"/> - RUN apt-get update && apt-get -t testing install -y python3.7 python3-all-dev + RUN apt-get update && apt-get -t stable install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 diff --git a/templates/tools/dockerfile/python_stretch.include b/templates/tools/dockerfile/python_stretch.include index 45bafe51842..43ba98ae64c 100644 --- a/templates/tools/dockerfile/python_stretch.include +++ b/templates/tools/dockerfile/python_stretch.include @@ -3,7 +3,9 @@ FROM debian:stretch <%include file="./apt_get_basic.include"/> <%include file="./gcp_api_libraries.include"/> <%include file="./apt_get_python_27.include"/> -<%include file="./debian_testing_repo.include"/> +# Add Debian 'buster' repository, we will need it for installing newer versions of python +RUN echo 'deb http://ftp.de.debian.org/debian buster main' >> /etc/apt/sources.list +RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local <%include file="./run_tests_addons.include"/> # Define the default command. CMD ["bash"] diff --git a/templates/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile.template index a5dcf196f2b..2c2cb6de08b 100644 --- a/templates/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile.template @@ -16,5 +16,17 @@ <%include file="../../python_stretch.include"/> - RUN apt-get update && apt-get -t testing install -y python3.6 python3-all-dev - RUN curl https://bootstrap.pypa.io/get-pip.py | python3.6 + RUN apt-get install -y jq zlib1g-dev libssl-dev + + RUN apt-get install -y jq build-essential libffi-dev + + RUN cd /tmp && ${'\\'} + wget -q https://github.com/python/cpython/archive/v3.6.9.tar.gz && ${'\\'} + tar xzvf v3.6.9.tar.gz && ${'\\'} + cd cpython-3.6.9 && ${'\\'} + ./configure && ${'\\'} + make install + + RUN python3.6 -m ensurepip && ${'\\'} + python3.6 -m pip install coverage + diff --git a/templates/tools/dockerfile/test/python_stretch_3.7_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_3.7_x64/Dockerfile.template index c3602f6c512..c4270bdfc89 100644 --- a/templates/tools/dockerfile/test/python_stretch_3.7_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/python_stretch_3.7_x64/Dockerfile.template @@ -16,7 +16,7 @@ <%include file="../../python_stretch.include"/> - RUN apt-get update && apt-get -t testing install -y python3.7 python3-all-dev + RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 # for Python test coverage reporting diff --git a/templates/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile.template index 8f2585a4d59..841a7f51b51 100644 --- a/templates/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile.template @@ -18,11 +18,14 @@ <%include file="../../python_stretch.include"/> RUN apt-get install -y jq zlib1g-dev libssl-dev - COPY get_cpython.sh /tmp - RUN apt-get install -y jq build-essential libffi-dev && ${'\\'} - chmod +x /tmp/get_cpython.sh && ${'\\'} - /tmp/get_cpython.sh && ${'\\'} - rm /tmp/get_cpython.sh + RUN apt-get install -y jq build-essential libffi-dev + + RUN cd /tmp && ${'\\'} + wget -q https://github.com/python/cpython/archive/v3.8.0b3.tar.gz && ${'\\'} + tar xzvf v3.8.0b3.tar.gz && ${'\\'} + cd cpython-3.8.0b3 && ${'\\'} + ./configure && ${'\\'} + make install RUN python3.8 -m ensurepip && ${'\\'} python3.8 -m pip install coverage diff --git a/templates/tools/dockerfile/test/sanity/Dockerfile.template b/templates/tools/dockerfile/test/sanity/Dockerfile.template index 2e4bdf537b7..84a4049be0e 100644 --- a/templates/tools/dockerfile/test/sanity/Dockerfile.template +++ b/templates/tools/dockerfile/test/sanity/Dockerfile.template @@ -18,7 +18,7 @@ <%include file="../../cxx_deps.include"/> #======================== # Sanity test dependencies - RUN apt-get update && apt-get -t testing install -y python3.7 python3-all-dev + RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 # Make Python 3.7 the default Python 3 version RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1 diff --git a/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile index acad500f90c..b11a1a1aa31 100644 --- a/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile +++ b/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile @@ -57,10 +57,9 @@ RUN pip install --upgrade google-api-python-client oauth2client RUN apt-get update && apt-get install -y python2.7 python-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python2.7 -# Add Debian 'testing' repository -RUN echo 'deb http://ftp.de.debian.org/debian testing main' >> /etc/apt/sources.list -RUN echo 'APT::Default-Release "stable";' | tee -a /etc/apt/apt.conf.d/00local - +# Add Debian 'buster' repository, we will need it for installing newer versions of python +RUN echo 'deb http://ftp.de.debian.org/debian buster main' >> /etc/apt/sources.list +RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins @@ -68,5 +67,5 @@ RUN mkdir /var/local/jenkins CMD ["bash"] -RUN apt-get update && apt-get -t testing install -y python3.7 python3-all-dev +RUN apt-get update && apt-get -t stable install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 diff --git a/tools/dockerfile/test/python_stretch_2.7_x64/Dockerfile b/tools/dockerfile/test/python_stretch_2.7_x64/Dockerfile index a7a8174db48..92b18e740da 100644 --- a/tools/dockerfile/test/python_stretch_2.7_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_2.7_x64/Dockerfile @@ -57,10 +57,9 @@ RUN pip install --upgrade google-api-python-client oauth2client RUN apt-get update && apt-get install -y python2.7 python-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python2.7 -# Add Debian 'testing' repository -RUN echo 'deb http://ftp.de.debian.org/debian testing main' >> /etc/apt/sources.list -RUN echo 'APT::Default-Release "stable";' | tee -a /etc/apt/apt.conf.d/00local - +# Add Debian 'buster' repository, we will need it for installing newer versions of python +RUN echo 'deb http://ftp.de.debian.org/debian buster main' >> /etc/apt/sources.list +RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/test/python_stretch_3.5_x64/Dockerfile b/tools/dockerfile/test/python_stretch_3.5_x64/Dockerfile index 0e97e77e2fd..7a256edffb2 100644 --- a/tools/dockerfile/test/python_stretch_3.5_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_3.5_x64/Dockerfile @@ -57,10 +57,9 @@ RUN pip install --upgrade google-api-python-client oauth2client RUN apt-get update && apt-get install -y python2.7 python-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python2.7 -# Add Debian 'testing' repository -RUN echo 'deb http://ftp.de.debian.org/debian testing main' >> /etc/apt/sources.list -RUN echo 'APT::Default-Release "stable";' | tee -a /etc/apt/apt.conf.d/00local - +# Add Debian 'buster' repository, we will need it for installing newer versions of python +RUN echo 'deb http://ftp.de.debian.org/debian buster main' >> /etc/apt/sources.list +RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins diff --git a/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile b/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile index 9b16b2d3a1d..f18af660488 100644 --- a/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile @@ -57,10 +57,9 @@ RUN pip install --upgrade google-api-python-client oauth2client RUN apt-get update && apt-get install -y python2.7 python-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python2.7 -# Add Debian 'testing' repository -RUN echo 'deb http://ftp.de.debian.org/debian testing main' >> /etc/apt/sources.list -RUN echo 'APT::Default-Release "stable";' | tee -a /etc/apt/apt.conf.d/00local - +# Add Debian 'buster' repository, we will need it for installing newer versions of python +RUN echo 'deb http://ftp.de.debian.org/debian buster main' >> /etc/apt/sources.list +RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins @@ -68,5 +67,16 @@ RUN mkdir /var/local/jenkins CMD ["bash"] -RUN apt-get update && apt-get -t testing install -y python3.6 python3-all-dev -RUN curl https://bootstrap.pypa.io/get-pip.py | python3.6 +RUN apt-get install -y jq zlib1g-dev libssl-dev + +RUN apt-get install -y jq build-essential libffi-dev + +RUN cd /tmp && \ + wget -q https://github.com/python/cpython/archive/v3.6.9.tar.gz && \ + tar xzvf v3.6.9.tar.gz && \ + cd cpython-3.6.9 && \ + ./configure && \ + make install + +RUN python3.6 -m ensurepip && \ + python3.6 -m pip install coverage diff --git a/tools/dockerfile/test/python_stretch_3.7_x64/Dockerfile b/tools/dockerfile/test/python_stretch_3.7_x64/Dockerfile index 45291ffdcfc..46b6526dc69 100644 --- a/tools/dockerfile/test/python_stretch_3.7_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_3.7_x64/Dockerfile @@ -57,10 +57,9 @@ RUN pip install --upgrade google-api-python-client oauth2client RUN apt-get update && apt-get install -y python2.7 python-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python2.7 -# Add Debian 'testing' repository -RUN echo 'deb http://ftp.de.debian.org/debian testing main' >> /etc/apt/sources.list -RUN echo 'APT::Default-Release "stable";' | tee -a /etc/apt/apt.conf.d/00local - +# Add Debian 'buster' repository, we will need it for installing newer versions of python +RUN echo 'deb http://ftp.de.debian.org/debian buster main' >> /etc/apt/sources.list +RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins @@ -68,7 +67,7 @@ RUN mkdir /var/local/jenkins CMD ["bash"] -RUN apt-get update && apt-get -t testing install -y python3.7 python3-all-dev +RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 # for Python test coverage reporting diff --git a/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile b/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile index d5ecbc7110a..495d86fd099 100644 --- a/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile @@ -57,10 +57,9 @@ RUN pip install --upgrade google-api-python-client oauth2client RUN apt-get update && apt-get install -y python2.7 python-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python2.7 -# Add Debian 'testing' repository -RUN echo 'deb http://ftp.de.debian.org/debian testing main' >> /etc/apt/sources.list -RUN echo 'APT::Default-Release "stable";' | tee -a /etc/apt/apt.conf.d/00local - +# Add Debian 'buster' repository, we will need it for installing newer versions of python +RUN echo 'deb http://ftp.de.debian.org/debian buster main' >> /etc/apt/sources.list +RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins @@ -69,11 +68,14 @@ CMD ["bash"] RUN apt-get install -y jq zlib1g-dev libssl-dev -COPY get_cpython.sh /tmp -RUN apt-get install -y jq build-essential libffi-dev && \ - chmod +x /tmp/get_cpython.sh && \ - /tmp/get_cpython.sh && \ - rm /tmp/get_cpython.sh +RUN apt-get install -y jq build-essential libffi-dev + +RUN cd /tmp && \ + wget -q https://github.com/python/cpython/archive/v3.8.0b3.tar.gz && \ + tar xzvf v3.8.0b3.tar.gz && \ + cd cpython-3.8.0b3 && \ + ./configure && \ + make install RUN python3.8 -m ensurepip && \ python3.8 -m pip install coverage diff --git a/tools/dockerfile/test/python_stretch_3.8_x64/get_cpython.sh b/tools/dockerfile/test/python_stretch_3.8_x64/get_cpython.sh deleted file mode 100644 index e051e974b38..00000000000 --- a/tools/dockerfile/test/python_stretch_3.8_x64/get_cpython.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -# Copyright 2019 The gRPC Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -VERSION_REGEX="v3.8.*" -REPO="python/cpython" - -LATEST=$(curl -s https://api.github.com/repos/$REPO/tags | \ - jq -r '.[] | select(.name|test("'$VERSION_REGEX'")) | .name' \ - | sort | tail -n1) - -wget https://github.com/$REPO/archive/$LATEST.tar.gz -tar xzvf *.tar.gz -( cd cpython* - ./configure - make install -) diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index ca786e264ed..675378b305b 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -57,10 +57,9 @@ RUN pip install --upgrade google-api-python-client oauth2client RUN apt-get update && apt-get install -y python2.7 python-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python2.7 -# Add Debian 'testing' repository -RUN echo 'deb http://ftp.de.debian.org/debian testing main' >> /etc/apt/sources.list -RUN echo 'APT::Default-Release "stable";' | tee -a /etc/apt/apt.conf.d/00local - +# Add Debian 'buster' repository, we will need it for installing newer versions of python +RUN echo 'deb http://ftp.de.debian.org/debian buster main' >> /etc/apt/sources.list +RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins @@ -73,7 +72,7 @@ RUN apt-get update && apt-get -y install libgflags-dev libgtest-dev libc++-dev c #======================== # Sanity test dependencies -RUN apt-get update && apt-get -t testing install -y python3.7 python3-all-dev +RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 # Make Python 3.7 the default Python 3 version RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1 From 732e2a1e90c30eec5611441b122ab4d17eb1f7fb Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Tue, 27 Aug 2019 15:53:47 -0700 Subject: [PATCH 1369/1555] Tune load reporter test --- test/cpp/server/load_reporter/load_reporter_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cpp/server/load_reporter/load_reporter_test.cc b/test/cpp/server/load_reporter/load_reporter_test.cc index 9d2ebfb0b4f..1866286069e 100644 --- a/test/cpp/server/load_reporter/load_reporter_test.cc +++ b/test/cpp/server/load_reporter/load_reporter_test.cc @@ -172,9 +172,9 @@ class LbFeedbackTest : public LoadReporterTest { // TODO(juanlishen): The error is big because we use sleep(). It should be // much smaller when we use fake clock. ASSERT_THAT(static_cast(lb_feedback.calls_per_second()), - DoubleNear(expected_qps, expected_qps * 0.05)); + DoubleNear(expected_qps, expected_qps * 0.3)); ASSERT_THAT(static_cast(lb_feedback.errors_per_second()), - DoubleNear(expected_eps, expected_eps * 0.05)); + DoubleNear(expected_eps, expected_eps * 0.3)); gpr_log(GPR_INFO, "Verified LB feedback matches the samples of index [%lu, %lu).", start, start + count); From 2767accc1bd0daab44c4199422742e1cd8f56d8f Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Fri, 23 Aug 2019 14:49:26 -0700 Subject: [PATCH 1370/1555] Fixed init-order-fiasco for static slice table. Fixes init-order bug affecting https://github.com/grpc/grpc/issues/19819 which was first exposed by this commit: https://github.com/grpc/grpc/commit/857375a1420df184963ed83f638dd21ea359aa37 --- .../filters/client_channel/client_channel.cc | 4 +- .../transport/chttp2/transport/hpack_table.cc | 2 +- .../transport/chttp2/transport/hpack_table.h | 4 +- src/core/lib/slice/slice_intern.cc | 20 +- src/core/lib/slice/slice_internal.h | 2 +- src/core/lib/slice/slice_utils.h | 8 +- src/core/lib/surface/init.cc | 3 + src/core/lib/transport/metadata.cc | 8 +- src/core/lib/transport/static_metadata.cc | 1648 +++++++---------- src/core/lib/transport/static_metadata.h | 454 ++--- test/core/slice/slice_test.cc | 10 +- test/core/transport/metadata_test.cc | 2 +- test/core/transport/status_metadata_test.cc | 5 +- tools/codegen/core/gen_static_metadata.py | 218 ++- 14 files changed, 1154 insertions(+), 1234 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 429828b0241..60b99c39a7a 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -3163,8 +3163,8 @@ void CallData::AddRetriableSendInitialMetadataOp( SubchannelCallRetryState* retry_state, SubchannelCallBatchData* batch_data) { // Maps the number of retries to the corresponding metadata value slice. - static const grpc_slice* retry_count_strings[] = { - &GRPC_MDSTR_1, &GRPC_MDSTR_2, &GRPC_MDSTR_3, &GRPC_MDSTR_4}; + const grpc_slice* retry_count_strings[] = {&GRPC_MDSTR_1, &GRPC_MDSTR_2, + &GRPC_MDSTR_3, &GRPC_MDSTR_4}; // We need to make a copy of the metadata batch for each attempt, since // the filters in the subchannel stack may modify this batch, and we don't // want those modifications to be passed forward to subsequent attempts. diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.cc b/src/core/ext/transport/chttp2/transport/hpack_table.cc index f86332c6bc3..68d3ec49fda 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_table.cc @@ -189,7 +189,7 @@ grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find( /* See if the string is in the static table */ for (i = 0; i < GRPC_CHTTP2_LAST_STATIC_ENTRY; i++) { - grpc_mdelem ent = grpc_static_mdelem_manifested[i]; + grpc_mdelem ent = grpc_static_mdelem_manifested()[i]; if (!grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDKEY(ent))) continue; r.index = i + 1u; r.has_value = grpc_slice_eq(GRPC_MDVALUE(md), GRPC_MDVALUE(ent)); diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.h b/src/core/ext/transport/chttp2/transport/hpack_table.h index 699b7eccaf2..a1aa77f5446 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.h +++ b/src/core/ext/transport/chttp2/transport/hpack_table.h @@ -104,7 +104,7 @@ inline grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl* tbl, reading the core static metadata table here; at that point we'd need our own singleton static metadata in the correct order. */ return index <= GRPC_CHTTP2_LAST_STATIC_ENTRY - ? grpc_static_mdelem_manifested[index - 1] + ? grpc_static_mdelem_manifested()[index - 1] : grpc_chttp2_hptbl_lookup_dynamic_index(tbl, index); } /* add a table entry to the index */ @@ -120,7 +120,7 @@ size_t grpc_chttp2_get_size_in_hpack_table(grpc_mdelem elem, inline uintptr_t grpc_chttp2_get_static_hpack_table_index(grpc_mdelem md) { uintptr_t index = reinterpret_cast(GRPC_MDELEM_DATA(md)) - - grpc_static_mdelem_table; + grpc_static_mdelem_table(); if (index < GRPC_CHTTP2_LAST_STATIC_ENTRY) { return index + 1; // Hpack static metadata element indices start at 1 } diff --git a/src/core/lib/slice/slice_intern.cc b/src/core/lib/slice/slice_intern.cc index 13fe1ab40e9..d813e5195ad 100644 --- a/src/core/lib/slice/slice_intern.cc +++ b/src/core/lib/slice/slice_intern.cc @@ -138,11 +138,12 @@ grpc_slice grpc_slice_maybe_static_intern(grpc_slice slice, for (uint32_t i = 0; i <= max_static_metadata_hash_probe; i++) { static_metadata_hash_ent ent = static_metadata_hash[(hash + i) % GPR_ARRAY_SIZE(static_metadata_hash)]; + const grpc_core::StaticMetadataSlice* static_slice_table = + grpc_static_slice_table(); if (ent.hash == hash && ent.idx < GRPC_STATIC_MDSTR_COUNT && - grpc_slice_eq_static_interned(slice, - grpc_static_slice_table[ent.idx])) { + grpc_slice_eq_static_interned(slice, static_slice_table[ent.idx])) { *returned_slice_is_different = true; - return grpc_static_slice_table[ent.idx]; + return static_slice_table[ent.idx]; } } @@ -168,10 +169,11 @@ static const grpc_core::StaticMetadataSlice* MatchStaticSlice( for (uint32_t i = 0; i <= max_static_metadata_hash_probe; i++) { static_metadata_hash_ent ent = static_metadata_hash[(hash + i) % GPR_ARRAY_SIZE(static_metadata_hash)]; + const grpc_core::StaticMetadataSlice* static_slice_table = + grpc_static_slice_table(); if (ent.hash == hash && ent.idx < GRPC_STATIC_MDSTR_COUNT && - grpc_static_slice_table[ent.idx].Equals( - std::forward(args)...)) { - return &grpc_static_slice_table[ent.idx]; + static_slice_table[ent.idx].Equals(std::forward(args)...)) { + return &static_slice_table[ent.idx]; } } return nullptr; @@ -318,9 +320,11 @@ void grpc_slice_intern_init(void) { static_metadata_hash[i].idx = GRPC_STATIC_MDSTR_COUNT; } max_static_metadata_hash_probe = 0; + const grpc_core::StaticMetadataSlice* static_slice_table = + grpc_static_slice_table(); for (size_t i = 0; i < GRPC_STATIC_MDSTR_COUNT; i++) { grpc_static_metadata_hash_values[i] = - grpc_slice_default_hash_internal(grpc_static_slice_table[i]); + grpc_slice_default_hash_internal(static_slice_table[i]); for (size_t j = 0; j < GPR_ARRAY_SIZE(static_metadata_hash); j++) { size_t slot = (grpc_static_metadata_hash_values[i] + j) % GPR_ARRAY_SIZE(static_metadata_hash); @@ -336,7 +340,7 @@ void grpc_slice_intern_init(void) { } // Handle KV hash for all static mdelems. for (size_t i = 0; i < GRPC_STATIC_MDELEM_COUNT; ++i) { - grpc_static_mdelem_table[i].HashInit(); + grpc_static_mdelem_table()[i].HashInit(); } } diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index e61f57c01ab..49ad15d5a56 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -182,7 +182,7 @@ struct StaticSliceRefcount { index(index) {} grpc_slice_refcount base; - uint32_t index; + const uint32_t index; }; extern grpc_slice_refcount kNoopRefcount; diff --git a/src/core/lib/slice/slice_utils.h b/src/core/lib/slice/slice_utils.h index e80de6d2ece..a4e19a9a61b 100644 --- a/src/core/lib/slice/slice_utils.h +++ b/src/core/lib/slice/slice_utils.h @@ -153,10 +153,14 @@ struct ExternallyManagedSlice : public UnmanagedMemorySlice { }; struct StaticMetadataSlice : public ManagedMemorySlice { - StaticMetadataSlice(grpc_slice_refcount* ref, size_t length, uint8_t* bytes) { + StaticMetadataSlice(grpc_slice_refcount* ref, size_t length, + const uint8_t* bytes) { refcount = ref; data.refcounted.length = length; - data.refcounted.bytes = bytes; + // NB: grpc_slice may or may not point to a static slice, but we are + // definitely pointing to static data here. Since we are not changing + // the underlying C-type, we need a const_cast here. + data.refcounted.bytes = const_cast(bytes); } }; diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index 2a6d307ddab..c02b4021763 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -134,6 +134,7 @@ void grpc_init(void) { grpc_core::Fork::GlobalInit(); grpc_fork_handlers_auto_register(); grpc_stats_init(); + grpc_init_static_metadata_ctx(); grpc_slice_intern_init(); grpc_mdctx_global_init(); grpc_channel_init_init(); @@ -191,6 +192,8 @@ void grpc_shutdown_internal_locked(void) { grpc_core::ApplicationCallbackExecCtx::GlobalShutdown(); g_shutting_down = false; gpr_cv_broadcast(g_shutting_down_cv); + // Absolute last action will be to delete static metadata context. + grpc_destroy_static_metadata_ctx(); } void grpc_shutdown_internal(void* ignored) { diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc index 4242923283e..76017207d47 100644 --- a/src/core/lib/transport/metadata.cc +++ b/src/core/lib/transport/metadata.cc @@ -269,9 +269,9 @@ void grpc_mdctx_global_shutdown() { #ifndef NDEBUG static int is_mdelem_static(grpc_mdelem e) { return reinterpret_cast(GRPC_MDELEM_DATA(e)) >= - &grpc_static_mdelem_table[0] && + &grpc_static_mdelem_table()[0] && reinterpret_cast(GRPC_MDELEM_DATA(e)) < - &grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT]; + &grpc_static_mdelem_table()[GRPC_STATIC_MDELEM_COUNT]; } #endif @@ -569,7 +569,7 @@ void* grpc_mdelem_get_user_data(grpc_mdelem md, void (*destroy_func)(void*)) { grpc_static_mdelem_user_data [reinterpret_cast( GRPC_MDELEM_DATA(md)) - - grpc_static_mdelem_table]); + grpc_static_mdelem_table()]); case GRPC_MDELEM_STORAGE_ALLOCATED: { auto* am = reinterpret_cast(GRPC_MDELEM_DATA(md)); return get_user_data(am->user_data(), destroy_func); @@ -611,7 +611,7 @@ void* grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void*), grpc_static_mdelem_user_data [reinterpret_cast( GRPC_MDELEM_DATA(md)) - - grpc_static_mdelem_table]); + grpc_static_mdelem_table()]); case GRPC_MDELEM_STORAGE_ALLOCATED: { auto* am = reinterpret_cast(GRPC_MDELEM_DATA(md)); return set_user_data(am->user_data(), destroy_func, data); diff --git a/src/core/lib/transport/static_metadata.cc b/src/core/lib/transport/static_metadata.cc index e2e618726f1..e43c17f1ca5 100644 --- a/src/core/lib/transport/static_metadata.cc +++ b/src/core/lib/transport/static_metadata.cc @@ -30,7 +30,7 @@ #include "src/core/lib/slice/slice_internal.h" -static uint8_t g_bytes[] = { +static constexpr uint8_t g_bytes[] = { 58, 112, 97, 116, 104, 58, 109, 101, 116, 104, 111, 100, 58, 115, 116, 97, 116, 117, 115, 58, 97, 117, 116, 104, 111, 114, 105, 116, 121, 58, 115, 99, 104, 101, 109, 101, 116, 101, 103, 114, 112, 99, 45, 109, 101, @@ -125,774 +125,1055 @@ static uint8_t g_bytes[] = { 112}; grpc_slice_refcount grpc_core::StaticSliceRefcount::kStaticSubRefcount; -grpc_core::StaticSliceRefcount - grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT] = { - grpc_core::StaticSliceRefcount(0), - grpc_core::StaticSliceRefcount(1), - grpc_core::StaticSliceRefcount(2), - grpc_core::StaticSliceRefcount(3), - grpc_core::StaticSliceRefcount(4), - grpc_core::StaticSliceRefcount(5), - grpc_core::StaticSliceRefcount(6), - grpc_core::StaticSliceRefcount(7), - grpc_core::StaticSliceRefcount(8), - grpc_core::StaticSliceRefcount(9), - grpc_core::StaticSliceRefcount(10), - grpc_core::StaticSliceRefcount(11), - grpc_core::StaticSliceRefcount(12), - grpc_core::StaticSliceRefcount(13), - grpc_core::StaticSliceRefcount(14), - grpc_core::StaticSliceRefcount(15), - grpc_core::StaticSliceRefcount(16), - grpc_core::StaticSliceRefcount(17), - grpc_core::StaticSliceRefcount(18), - grpc_core::StaticSliceRefcount(19), - grpc_core::StaticSliceRefcount(20), - grpc_core::StaticSliceRefcount(21), - grpc_core::StaticSliceRefcount(22), - grpc_core::StaticSliceRefcount(23), - grpc_core::StaticSliceRefcount(24), - grpc_core::StaticSliceRefcount(25), - grpc_core::StaticSliceRefcount(26), - grpc_core::StaticSliceRefcount(27), - grpc_core::StaticSliceRefcount(28), - grpc_core::StaticSliceRefcount(29), - grpc_core::StaticSliceRefcount(30), - grpc_core::StaticSliceRefcount(31), - grpc_core::StaticSliceRefcount(32), - grpc_core::StaticSliceRefcount(33), - grpc_core::StaticSliceRefcount(34), - grpc_core::StaticSliceRefcount(35), - grpc_core::StaticSliceRefcount(36), - grpc_core::StaticSliceRefcount(37), - grpc_core::StaticSliceRefcount(38), - grpc_core::StaticSliceRefcount(39), - grpc_core::StaticSliceRefcount(40), - grpc_core::StaticSliceRefcount(41), - grpc_core::StaticSliceRefcount(42), - grpc_core::StaticSliceRefcount(43), - grpc_core::StaticSliceRefcount(44), - grpc_core::StaticSliceRefcount(45), - grpc_core::StaticSliceRefcount(46), - grpc_core::StaticSliceRefcount(47), - grpc_core::StaticSliceRefcount(48), - grpc_core::StaticSliceRefcount(49), - grpc_core::StaticSliceRefcount(50), - grpc_core::StaticSliceRefcount(51), - grpc_core::StaticSliceRefcount(52), - grpc_core::StaticSliceRefcount(53), - grpc_core::StaticSliceRefcount(54), - grpc_core::StaticSliceRefcount(55), - grpc_core::StaticSliceRefcount(56), - grpc_core::StaticSliceRefcount(57), - grpc_core::StaticSliceRefcount(58), - grpc_core::StaticSliceRefcount(59), - grpc_core::StaticSliceRefcount(60), - grpc_core::StaticSliceRefcount(61), - grpc_core::StaticSliceRefcount(62), - grpc_core::StaticSliceRefcount(63), - grpc_core::StaticSliceRefcount(64), - grpc_core::StaticSliceRefcount(65), - grpc_core::StaticSliceRefcount(66), - grpc_core::StaticSliceRefcount(67), - grpc_core::StaticSliceRefcount(68), - grpc_core::StaticSliceRefcount(69), - grpc_core::StaticSliceRefcount(70), - grpc_core::StaticSliceRefcount(71), - grpc_core::StaticSliceRefcount(72), - grpc_core::StaticSliceRefcount(73), - grpc_core::StaticSliceRefcount(74), - grpc_core::StaticSliceRefcount(75), - grpc_core::StaticSliceRefcount(76), - grpc_core::StaticSliceRefcount(77), - grpc_core::StaticSliceRefcount(78), - grpc_core::StaticSliceRefcount(79), - grpc_core::StaticSliceRefcount(80), - grpc_core::StaticSliceRefcount(81), - grpc_core::StaticSliceRefcount(82), - grpc_core::StaticSliceRefcount(83), - grpc_core::StaticSliceRefcount(84), - grpc_core::StaticSliceRefcount(85), - grpc_core::StaticSliceRefcount(86), - grpc_core::StaticSliceRefcount(87), - grpc_core::StaticSliceRefcount(88), - grpc_core::StaticSliceRefcount(89), - grpc_core::StaticSliceRefcount(90), - grpc_core::StaticSliceRefcount(91), - grpc_core::StaticSliceRefcount(92), - grpc_core::StaticSliceRefcount(93), - grpc_core::StaticSliceRefcount(94), - grpc_core::StaticSliceRefcount(95), - grpc_core::StaticSliceRefcount(96), - grpc_core::StaticSliceRefcount(97), - grpc_core::StaticSliceRefcount(98), - grpc_core::StaticSliceRefcount(99), - grpc_core::StaticSliceRefcount(100), - grpc_core::StaticSliceRefcount(101), - grpc_core::StaticSliceRefcount(102), - grpc_core::StaticSliceRefcount(103), - grpc_core::StaticSliceRefcount(104), - grpc_core::StaticSliceRefcount(105), - grpc_core::StaticSliceRefcount(106), - grpc_core::StaticSliceRefcount(107), -}; -const grpc_core::StaticMetadataSlice - grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT] = { - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[0].base, - 5, g_bytes + 0), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1].base, - 7, g_bytes + 5), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, - 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[3].base, - 10, g_bytes + 19), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4].base, - 7, g_bytes + 29), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[5].base, - 2, g_bytes + 36), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[6].base, - 12, g_bytes + 38), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7].base, - 11, g_bytes + 50), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[8].base, - 16, g_bytes + 61), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9].base, - 13, g_bytes + 77), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, - 20, g_bytes + 90), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[11].base, - 21, g_bytes + 110), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[12].base, - 13, g_bytes + 131), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[13].base, - 14, g_bytes + 144), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[14].base, - 12, g_bytes + 158), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15].base, - 16, g_bytes + 170), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, - 15, g_bytes + 186), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[17].base, - 30, g_bytes + 201), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[18].base, - 37, g_bytes + 231), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[19].base, - 10, g_bytes + 268), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[20].base, - 4, g_bytes + 278), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[21].base, - 26, g_bytes + 282), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[22].base, - 22, g_bytes + 308), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[23].base, - 12, g_bytes + 330), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[24].base, - 1, g_bytes + 342), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[25].base, - 1, g_bytes + 343), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[26].base, - 1, g_bytes + 344), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[27].base, - 1, g_bytes + 345), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[29].base, - 19, g_bytes + 346), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[30].base, - 12, g_bytes + 365), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[31].base, - 30, g_bytes + 377), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[32].base, - 31, g_bytes + 407), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[33].base, - 36, g_bytes + 438), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[34].base, - 65, g_bytes + 474), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[35].base, - 54, g_bytes + 539), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[36].base, - 28, g_bytes + 593), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[37].base, - 80, g_bytes + 621), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[38].base, - 7, g_bytes + 701), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[39].base, - 4, g_bytes + 708), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[40].base, - 11, g_bytes + 712), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[41].base, - 3, g_bytes + 723), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[42].base, - 4, g_bytes + 726), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[43].base, - 1, g_bytes + 730), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[44].base, - 11, g_bytes + 731), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[45].base, - 4, g_bytes + 742), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[46].base, - 5, g_bytes + 746), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[47].base, - 3, g_bytes + 751), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[48].base, - 3, g_bytes + 754), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[49].base, - 3, g_bytes + 757), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[50].base, - 3, g_bytes + 760), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[51].base, - 3, g_bytes + 763), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[52].base, - 3, g_bytes + 766), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[53].base, - 3, g_bytes + 769), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[54].base, - 14, g_bytes + 772), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[55].base, - 13, g_bytes + 786), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[56].base, - 15, g_bytes + 799), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[57].base, - 13, g_bytes + 814), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[58].base, - 6, g_bytes + 827), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[59].base, - 27, g_bytes + 833), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[60].base, - 3, g_bytes + 860), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[61].base, - 5, g_bytes + 863), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[62].base, - 13, g_bytes + 868), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[63].base, - 13, g_bytes + 881), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[64].base, - 19, g_bytes + 894), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[65].base, - 16, g_bytes + 913), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[66].base, - 14, g_bytes + 929), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[67].base, - 16, g_bytes + 943), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[68].base, - 13, g_bytes + 959), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[69].base, - 6, g_bytes + 972), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[70].base, - 4, g_bytes + 978), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[71].base, - 4, g_bytes + 982), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[72].base, - 6, g_bytes + 986), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[73].base, - 7, g_bytes + 992), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[74].base, - 4, g_bytes + 999), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[75].base, - 8, g_bytes + 1003), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[76].base, - 17, g_bytes + 1011), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[77].base, - 13, g_bytes + 1028), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[78].base, - 8, g_bytes + 1041), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[79].base, - 19, g_bytes + 1049), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[80].base, - 13, g_bytes + 1068), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[81].base, - 4, g_bytes + 1081), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[82].base, - 8, g_bytes + 1085), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[83].base, - 12, g_bytes + 1093), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[84].base, - 18, g_bytes + 1105), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[85].base, - 19, g_bytes + 1123), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[86].base, - 5, g_bytes + 1142), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[87].base, - 7, g_bytes + 1147), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[88].base, - 7, g_bytes + 1154), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[89].base, - 11, g_bytes + 1161), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[90].base, - 6, g_bytes + 1172), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[91].base, - 10, g_bytes + 1178), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[92].base, - 25, g_bytes + 1188), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[93].base, - 17, g_bytes + 1213), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[94].base, - 4, g_bytes + 1230), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[95].base, - 3, g_bytes + 1234), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96].base, - 16, g_bytes + 1237), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97].base, - 1, g_bytes + 1253), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98].base, - 8, g_bytes + 1254), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[99].base, - 8, g_bytes + 1262), - grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[100].base, 16, g_bytes + 1270), - grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[101].base, 4, g_bytes + 1286), - grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[102].base, 3, g_bytes + 1290), - grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[103].base, 11, g_bytes + 1293), - grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[104].base, 16, g_bytes + 1304), - grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[105].base, 13, g_bytes + 1320), - grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[106].base, 12, g_bytes + 1333), - grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[107].base, 21, g_bytes + 1345), -}; +namespace grpc_core { +struct StaticMetadataCtx { +#ifndef NDEBUG + const uint64_t init_canary = kGrpcStaticMetadataInitCanary; +#endif + StaticSliceRefcount refcounts[GRPC_STATIC_MDSTR_COUNT] = { -/* Warning: the core static metadata currently operates under the soft -constraint that the first GRPC_CHTTP2_LAST_STATIC_ENTRY (61) entries must -contain metadata specified by the http2 hpack standard. The CHTTP2 transport -reads the core metadata with this assumption in mind. If the order of the core -static metadata is to be changed, then the CHTTP2 transport must be changed as -well to stop relying on the core metadata. */ + StaticSliceRefcount(0), StaticSliceRefcount(1), + StaticSliceRefcount(2), StaticSliceRefcount(3), + StaticSliceRefcount(4), StaticSliceRefcount(5), + StaticSliceRefcount(6), StaticSliceRefcount(7), + StaticSliceRefcount(8), StaticSliceRefcount(9), + StaticSliceRefcount(10), StaticSliceRefcount(11), + StaticSliceRefcount(12), StaticSliceRefcount(13), + StaticSliceRefcount(14), StaticSliceRefcount(15), + StaticSliceRefcount(16), StaticSliceRefcount(17), + StaticSliceRefcount(18), StaticSliceRefcount(19), + StaticSliceRefcount(20), StaticSliceRefcount(21), + StaticSliceRefcount(22), StaticSliceRefcount(23), + StaticSliceRefcount(24), StaticSliceRefcount(25), + StaticSliceRefcount(26), StaticSliceRefcount(27), + StaticSliceRefcount(28), StaticSliceRefcount(29), + StaticSliceRefcount(30), StaticSliceRefcount(31), + StaticSliceRefcount(32), StaticSliceRefcount(33), + StaticSliceRefcount(34), StaticSliceRefcount(35), + StaticSliceRefcount(36), StaticSliceRefcount(37), + StaticSliceRefcount(38), StaticSliceRefcount(39), + StaticSliceRefcount(40), StaticSliceRefcount(41), + StaticSliceRefcount(42), StaticSliceRefcount(43), + StaticSliceRefcount(44), StaticSliceRefcount(45), + StaticSliceRefcount(46), StaticSliceRefcount(47), + StaticSliceRefcount(48), StaticSliceRefcount(49), + StaticSliceRefcount(50), StaticSliceRefcount(51), + StaticSliceRefcount(52), StaticSliceRefcount(53), + StaticSliceRefcount(54), StaticSliceRefcount(55), + StaticSliceRefcount(56), StaticSliceRefcount(57), + StaticSliceRefcount(58), StaticSliceRefcount(59), + StaticSliceRefcount(60), StaticSliceRefcount(61), + StaticSliceRefcount(62), StaticSliceRefcount(63), + StaticSliceRefcount(64), StaticSliceRefcount(65), + StaticSliceRefcount(66), StaticSliceRefcount(67), + StaticSliceRefcount(68), StaticSliceRefcount(69), + StaticSliceRefcount(70), StaticSliceRefcount(71), + StaticSliceRefcount(72), StaticSliceRefcount(73), + StaticSliceRefcount(74), StaticSliceRefcount(75), + StaticSliceRefcount(76), StaticSliceRefcount(77), + StaticSliceRefcount(78), StaticSliceRefcount(79), + StaticSliceRefcount(80), StaticSliceRefcount(81), + StaticSliceRefcount(82), StaticSliceRefcount(83), + StaticSliceRefcount(84), StaticSliceRefcount(85), + StaticSliceRefcount(86), StaticSliceRefcount(87), + StaticSliceRefcount(88), StaticSliceRefcount(89), + StaticSliceRefcount(90), StaticSliceRefcount(91), + StaticSliceRefcount(92), StaticSliceRefcount(93), + StaticSliceRefcount(94), StaticSliceRefcount(95), + StaticSliceRefcount(96), StaticSliceRefcount(97), + StaticSliceRefcount(98), StaticSliceRefcount(99), + StaticSliceRefcount(100), StaticSliceRefcount(101), + StaticSliceRefcount(102), StaticSliceRefcount(103), + StaticSliceRefcount(104), StaticSliceRefcount(105), + StaticSliceRefcount(106), StaticSliceRefcount(107), + }; -grpc_mdelem grpc_static_mdelem_manifested[GRPC_STATIC_MDELEM_COUNT] = { - // clang-format off + const StaticMetadataSlice slices[GRPC_STATIC_MDSTR_COUNT] = { + + grpc_core::StaticMetadataSlice(&refcounts[0].base, 5, g_bytes + 0), + grpc_core::StaticMetadataSlice(&refcounts[1].base, 7, g_bytes + 5), + grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12), + grpc_core::StaticMetadataSlice(&refcounts[3].base, 10, g_bytes + 19), + grpc_core::StaticMetadataSlice(&refcounts[4].base, 7, g_bytes + 29), + grpc_core::StaticMetadataSlice(&refcounts[5].base, 2, g_bytes + 36), + grpc_core::StaticMetadataSlice(&refcounts[6].base, 12, g_bytes + 38), + grpc_core::StaticMetadataSlice(&refcounts[7].base, 11, g_bytes + 50), + grpc_core::StaticMetadataSlice(&refcounts[8].base, 16, g_bytes + 61), + grpc_core::StaticMetadataSlice(&refcounts[9].base, 13, g_bytes + 77), + grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90), + grpc_core::StaticMetadataSlice(&refcounts[11].base, 21, g_bytes + 110), + grpc_core::StaticMetadataSlice(&refcounts[12].base, 13, g_bytes + 131), + grpc_core::StaticMetadataSlice(&refcounts[13].base, 14, g_bytes + 144), + grpc_core::StaticMetadataSlice(&refcounts[14].base, 12, g_bytes + 158), + grpc_core::StaticMetadataSlice(&refcounts[15].base, 16, g_bytes + 170), + grpc_core::StaticMetadataSlice(&refcounts[16].base, 15, g_bytes + 186), + grpc_core::StaticMetadataSlice(&refcounts[17].base, 30, g_bytes + 201), + grpc_core::StaticMetadataSlice(&refcounts[18].base, 37, g_bytes + 231), + grpc_core::StaticMetadataSlice(&refcounts[19].base, 10, g_bytes + 268), + grpc_core::StaticMetadataSlice(&refcounts[20].base, 4, g_bytes + 278), + grpc_core::StaticMetadataSlice(&refcounts[21].base, 26, g_bytes + 282), + grpc_core::StaticMetadataSlice(&refcounts[22].base, 22, g_bytes + 308), + grpc_core::StaticMetadataSlice(&refcounts[23].base, 12, g_bytes + 330), + grpc_core::StaticMetadataSlice(&refcounts[24].base, 1, g_bytes + 342), + grpc_core::StaticMetadataSlice(&refcounts[25].base, 1, g_bytes + 343), + grpc_core::StaticMetadataSlice(&refcounts[26].base, 1, g_bytes + 344), + grpc_core::StaticMetadataSlice(&refcounts[27].base, 1, g_bytes + 345), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 19, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[30].base, 12, g_bytes + 365), + grpc_core::StaticMetadataSlice(&refcounts[31].base, 30, g_bytes + 377), + grpc_core::StaticMetadataSlice(&refcounts[32].base, 31, g_bytes + 407), + grpc_core::StaticMetadataSlice(&refcounts[33].base, 36, g_bytes + 438), + grpc_core::StaticMetadataSlice(&refcounts[34].base, 65, g_bytes + 474), + grpc_core::StaticMetadataSlice(&refcounts[35].base, 54, g_bytes + 539), + grpc_core::StaticMetadataSlice(&refcounts[36].base, 28, g_bytes + 593), + grpc_core::StaticMetadataSlice(&refcounts[37].base, 80, g_bytes + 621), + grpc_core::StaticMetadataSlice(&refcounts[38].base, 7, g_bytes + 701), + grpc_core::StaticMetadataSlice(&refcounts[39].base, 4, g_bytes + 708), + grpc_core::StaticMetadataSlice(&refcounts[40].base, 11, g_bytes + 712), + grpc_core::StaticMetadataSlice(&refcounts[41].base, 3, g_bytes + 723), + grpc_core::StaticMetadataSlice(&refcounts[42].base, 4, g_bytes + 726), + grpc_core::StaticMetadataSlice(&refcounts[43].base, 1, g_bytes + 730), + grpc_core::StaticMetadataSlice(&refcounts[44].base, 11, g_bytes + 731), + grpc_core::StaticMetadataSlice(&refcounts[45].base, 4, g_bytes + 742), + grpc_core::StaticMetadataSlice(&refcounts[46].base, 5, g_bytes + 746), + grpc_core::StaticMetadataSlice(&refcounts[47].base, 3, g_bytes + 751), + grpc_core::StaticMetadataSlice(&refcounts[48].base, 3, g_bytes + 754), + grpc_core::StaticMetadataSlice(&refcounts[49].base, 3, g_bytes + 757), + grpc_core::StaticMetadataSlice(&refcounts[50].base, 3, g_bytes + 760), + grpc_core::StaticMetadataSlice(&refcounts[51].base, 3, g_bytes + 763), + grpc_core::StaticMetadataSlice(&refcounts[52].base, 3, g_bytes + 766), + grpc_core::StaticMetadataSlice(&refcounts[53].base, 3, g_bytes + 769), + grpc_core::StaticMetadataSlice(&refcounts[54].base, 14, g_bytes + 772), + grpc_core::StaticMetadataSlice(&refcounts[55].base, 13, g_bytes + 786), + grpc_core::StaticMetadataSlice(&refcounts[56].base, 15, g_bytes + 799), + grpc_core::StaticMetadataSlice(&refcounts[57].base, 13, g_bytes + 814), + grpc_core::StaticMetadataSlice(&refcounts[58].base, 6, g_bytes + 827), + grpc_core::StaticMetadataSlice(&refcounts[59].base, 27, g_bytes + 833), + grpc_core::StaticMetadataSlice(&refcounts[60].base, 3, g_bytes + 860), + grpc_core::StaticMetadataSlice(&refcounts[61].base, 5, g_bytes + 863), + grpc_core::StaticMetadataSlice(&refcounts[62].base, 13, g_bytes + 868), + grpc_core::StaticMetadataSlice(&refcounts[63].base, 13, g_bytes + 881), + grpc_core::StaticMetadataSlice(&refcounts[64].base, 19, g_bytes + 894), + grpc_core::StaticMetadataSlice(&refcounts[65].base, 16, g_bytes + 913), + grpc_core::StaticMetadataSlice(&refcounts[66].base, 14, g_bytes + 929), + grpc_core::StaticMetadataSlice(&refcounts[67].base, 16, g_bytes + 943), + grpc_core::StaticMetadataSlice(&refcounts[68].base, 13, g_bytes + 959), + grpc_core::StaticMetadataSlice(&refcounts[69].base, 6, g_bytes + 972), + grpc_core::StaticMetadataSlice(&refcounts[70].base, 4, g_bytes + 978), + grpc_core::StaticMetadataSlice(&refcounts[71].base, 4, g_bytes + 982), + grpc_core::StaticMetadataSlice(&refcounts[72].base, 6, g_bytes + 986), + grpc_core::StaticMetadataSlice(&refcounts[73].base, 7, g_bytes + 992), + grpc_core::StaticMetadataSlice(&refcounts[74].base, 4, g_bytes + 999), + grpc_core::StaticMetadataSlice(&refcounts[75].base, 8, g_bytes + 1003), + grpc_core::StaticMetadataSlice(&refcounts[76].base, 17, g_bytes + 1011), + grpc_core::StaticMetadataSlice(&refcounts[77].base, 13, g_bytes + 1028), + grpc_core::StaticMetadataSlice(&refcounts[78].base, 8, g_bytes + 1041), + grpc_core::StaticMetadataSlice(&refcounts[79].base, 19, g_bytes + 1049), + grpc_core::StaticMetadataSlice(&refcounts[80].base, 13, g_bytes + 1068), + grpc_core::StaticMetadataSlice(&refcounts[81].base, 4, g_bytes + 1081), + grpc_core::StaticMetadataSlice(&refcounts[82].base, 8, g_bytes + 1085), + grpc_core::StaticMetadataSlice(&refcounts[83].base, 12, g_bytes + 1093), + grpc_core::StaticMetadataSlice(&refcounts[84].base, 18, g_bytes + 1105), + grpc_core::StaticMetadataSlice(&refcounts[85].base, 19, g_bytes + 1123), + grpc_core::StaticMetadataSlice(&refcounts[86].base, 5, g_bytes + 1142), + grpc_core::StaticMetadataSlice(&refcounts[87].base, 7, g_bytes + 1147), + grpc_core::StaticMetadataSlice(&refcounts[88].base, 7, g_bytes + 1154), + grpc_core::StaticMetadataSlice(&refcounts[89].base, 11, g_bytes + 1161), + grpc_core::StaticMetadataSlice(&refcounts[90].base, 6, g_bytes + 1172), + grpc_core::StaticMetadataSlice(&refcounts[91].base, 10, g_bytes + 1178), + grpc_core::StaticMetadataSlice(&refcounts[92].base, 25, g_bytes + 1188), + grpc_core::StaticMetadataSlice(&refcounts[93].base, 17, g_bytes + 1213), + grpc_core::StaticMetadataSlice(&refcounts[94].base, 4, g_bytes + 1230), + grpc_core::StaticMetadataSlice(&refcounts[95].base, 3, g_bytes + 1234), + grpc_core::StaticMetadataSlice(&refcounts[96].base, 16, g_bytes + 1237), + grpc_core::StaticMetadataSlice(&refcounts[97].base, 1, g_bytes + 1253), + grpc_core::StaticMetadataSlice(&refcounts[98].base, 8, g_bytes + 1254), + grpc_core::StaticMetadataSlice(&refcounts[99].base, 8, g_bytes + 1262), + grpc_core::StaticMetadataSlice(&refcounts[100].base, 16, g_bytes + 1270), + grpc_core::StaticMetadataSlice(&refcounts[101].base, 4, g_bytes + 1286), + grpc_core::StaticMetadataSlice(&refcounts[102].base, 3, g_bytes + 1290), + grpc_core::StaticMetadataSlice(&refcounts[103].base, 11, g_bytes + 1293), + grpc_core::StaticMetadataSlice(&refcounts[104].base, 16, g_bytes + 1304), + grpc_core::StaticMetadataSlice(&refcounts[105].base, 13, g_bytes + 1320), + grpc_core::StaticMetadataSlice(&refcounts[106].base, 12, g_bytes + 1333), + grpc_core::StaticMetadataSlice(&refcounts[107].base, 21, g_bytes + 1345), + }; + StaticMetadata static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[3].base, 10, g_bytes + 19), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 0), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[1].base, 7, g_bytes + 5), + grpc_core::StaticMetadataSlice(&refcounts[41].base, 3, g_bytes + 723), + 1), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[1].base, 7, g_bytes + 5), + grpc_core::StaticMetadataSlice(&refcounts[42].base, 4, g_bytes + 726), + 2), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[0].base, 5, g_bytes + 0), + grpc_core::StaticMetadataSlice(&refcounts[43].base, 1, g_bytes + 730), + 3), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[0].base, 5, g_bytes + 0), + grpc_core::StaticMetadataSlice(&refcounts[44].base, 11, + g_bytes + 731), + 4), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[4].base, 7, g_bytes + 29), + grpc_core::StaticMetadataSlice(&refcounts[45].base, 4, g_bytes + 742), + 5), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[4].base, 7, g_bytes + 29), + grpc_core::StaticMetadataSlice(&refcounts[46].base, 5, g_bytes + 746), + 6), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12), + grpc_core::StaticMetadataSlice(&refcounts[47].base, 3, g_bytes + 751), + 7), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12), + grpc_core::StaticMetadataSlice(&refcounts[48].base, 3, g_bytes + 754), + 8), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12), + grpc_core::StaticMetadataSlice(&refcounts[49].base, 3, g_bytes + 757), + 9), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12), + grpc_core::StaticMetadataSlice(&refcounts[50].base, 3, g_bytes + 760), + 10), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12), + grpc_core::StaticMetadataSlice(&refcounts[51].base, 3, g_bytes + 763), + 11), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12), + grpc_core::StaticMetadataSlice(&refcounts[52].base, 3, g_bytes + 766), + 12), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12), + grpc_core::StaticMetadataSlice(&refcounts[53].base, 3, g_bytes + 769), + 13), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[54].base, 14, + g_bytes + 772), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 14), + StaticMetadata(grpc_core::StaticMetadataSlice(&refcounts[16].base, 15, + g_bytes + 186), + grpc_core::StaticMetadataSlice(&refcounts[55].base, 13, + g_bytes + 786), + 15), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[56].base, 15, + g_bytes + 799), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 16), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[57].base, 13, + g_bytes + 814), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 17), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[58].base, 6, g_bytes + 827), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 18), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[59].base, 27, + g_bytes + 833), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 19), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[60].base, 3, g_bytes + 860), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 20), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[61].base, 5, g_bytes + 863), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 21), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[62].base, 13, + g_bytes + 868), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 22), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[63].base, 13, + g_bytes + 881), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 23), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[64].base, 19, + g_bytes + 894), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 24), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[15].base, 16, + g_bytes + 170), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 25), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[65].base, 16, + g_bytes + 913), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 26), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[66].base, 14, + g_bytes + 929), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 27), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[67].base, 16, + g_bytes + 943), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 28), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[68].base, 13, + g_bytes + 959), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 29), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[14].base, 12, + g_bytes + 158), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 30), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[69].base, 6, g_bytes + 972), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 31), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[70].base, 4, g_bytes + 978), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 32), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[71].base, 4, g_bytes + 982), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 33), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[72].base, 6, g_bytes + 986), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 34), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[73].base, 7, g_bytes + 992), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 35), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[74].base, 4, g_bytes + 999), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 36), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[20].base, 4, g_bytes + 278), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 37), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[75].base, 8, + g_bytes + 1003), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 38), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[76].base, 17, + g_bytes + 1011), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 39), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[77].base, 13, + g_bytes + 1028), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 40), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[78].base, 8, + g_bytes + 1041), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 41), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[79].base, 19, + g_bytes + 1049), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 42), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[80].base, 13, + g_bytes + 1068), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 43), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[81].base, 4, + g_bytes + 1081), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 44), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[82].base, 8, + g_bytes + 1085), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 45), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[83].base, 12, + g_bytes + 1093), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 46), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[84].base, 18, + g_bytes + 1105), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 47), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[85].base, 19, + g_bytes + 1123), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 48), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[86].base, 5, + g_bytes + 1142), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 49), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[87].base, 7, + g_bytes + 1147), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 50), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[88].base, 7, + g_bytes + 1154), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 51), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[89].base, 11, + g_bytes + 1161), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 52), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[90].base, 6, + g_bytes + 1172), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 53), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[91].base, 10, + g_bytes + 1178), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 54), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[92].base, 25, + g_bytes + 1188), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 55), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[93].base, 17, + g_bytes + 1213), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 56), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[19].base, 10, + g_bytes + 268), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 57), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[94].base, 4, + g_bytes + 1230), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 58), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[95].base, 3, + g_bytes + 1234), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 59), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[96].base, 16, + g_bytes + 1237), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 60), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[7].base, 11, g_bytes + 50), + grpc_core::StaticMetadataSlice(&refcounts[97].base, 1, + g_bytes + 1253), + 61), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[7].base, 11, g_bytes + 50), + grpc_core::StaticMetadataSlice(&refcounts[24].base, 1, g_bytes + 342), + 62), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[7].base, 11, g_bytes + 50), + grpc_core::StaticMetadataSlice(&refcounts[25].base, 1, g_bytes + 343), + 63), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[9].base, 13, g_bytes + 77), + grpc_core::StaticMetadataSlice(&refcounts[98].base, 8, + g_bytes + 1254), + 64), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[9].base, 13, g_bytes + 77), + grpc_core::StaticMetadataSlice(&refcounts[39].base, 4, g_bytes + 708), + 65), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[9].base, 13, g_bytes + 77), + grpc_core::StaticMetadataSlice(&refcounts[38].base, 7, g_bytes + 701), + 66), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[5].base, 2, g_bytes + 36), + grpc_core::StaticMetadataSlice(&refcounts[99].base, 8, + g_bytes + 1262), + 67), + StaticMetadata(grpc_core::StaticMetadataSlice(&refcounts[14].base, 12, + g_bytes + 158), + grpc_core::StaticMetadataSlice(&refcounts[100].base, 16, + g_bytes + 1270), + 68), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[4].base, 7, g_bytes + 29), + grpc_core::StaticMetadataSlice(&refcounts[101].base, 4, + g_bytes + 1286), + 69), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[1].base, 7, g_bytes + 5), + grpc_core::StaticMetadataSlice(&refcounts[102].base, 3, + g_bytes + 1290), + 70), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[16].base, 15, + g_bytes + 186), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 71), + StaticMetadata(grpc_core::StaticMetadataSlice(&refcounts[15].base, 16, + g_bytes + 170), + grpc_core::StaticMetadataSlice(&refcounts[98].base, 8, + g_bytes + 1254), + 72), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[15].base, 16, + g_bytes + 170), + grpc_core::StaticMetadataSlice(&refcounts[39].base, 4, g_bytes + 708), + 73), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[103].base, 11, + g_bytes + 1293), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + 74), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90), + grpc_core::StaticMetadataSlice(&refcounts[98].base, 8, + g_bytes + 1254), + 75), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90), + grpc_core::StaticMetadataSlice(&refcounts[38].base, 7, g_bytes + 701), + 76), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90), + grpc_core::StaticMetadataSlice(&refcounts[104].base, 16, + g_bytes + 1304), + 77), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90), + grpc_core::StaticMetadataSlice(&refcounts[39].base, 4, g_bytes + 708), + 78), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90), + grpc_core::StaticMetadataSlice(&refcounts[105].base, 13, + g_bytes + 1320), + 79), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90), + grpc_core::StaticMetadataSlice(&refcounts[106].base, 12, + g_bytes + 1333), + 80), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90), + grpc_core::StaticMetadataSlice(&refcounts[107].base, 21, + g_bytes + 1345), + 81), + StaticMetadata(grpc_core::StaticMetadataSlice(&refcounts[16].base, 15, + g_bytes + 186), + grpc_core::StaticMetadataSlice(&refcounts[98].base, 8, + g_bytes + 1254), + 82), + StaticMetadata( + grpc_core::StaticMetadataSlice(&refcounts[16].base, 15, + g_bytes + 186), + grpc_core::StaticMetadataSlice(&refcounts[39].base, 4, g_bytes + 708), + 83), + StaticMetadata(grpc_core::StaticMetadataSlice(&refcounts[16].base, 15, + g_bytes + 186), + grpc_core::StaticMetadataSlice(&refcounts[105].base, 13, + g_bytes + 1320), + 84), + }; + + /* Warning: the core static metadata currently operates under the soft + constraint that the first GRPC_CHTTP2_LAST_STATIC_ENTRY (61) entries must + contain metadata specified by the http2 hpack standard. The CHTTP2 transport + reads the core metadata with this assumption in mind. If the order of the core + static metadata is to be changed, then the CHTTP2 transport must be changed as + well to stop relying on the core metadata. */ + + grpc_mdelem static_mdelem_manifested[GRPC_STATIC_MDELEM_COUNT] = { + // clang-format off /* GRPC_MDELEM_AUTHORITY_EMPTY: ":authority": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[0].data(), + &static_mdelem_table[0].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_METHOD_GET: ":method": "GET" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[1].data(), + &static_mdelem_table[1].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_METHOD_POST: ":method": "POST" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[2].data(), + &static_mdelem_table[2].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_PATH_SLASH: ":path": "/" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[3].data(), + &static_mdelem_table[3].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_PATH_SLASH_INDEX_DOT_HTML: ":path": "/index.html" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[4].data(), + &static_mdelem_table[4].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_SCHEME_HTTP: ":scheme": "http" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[5].data(), + &static_mdelem_table[5].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_SCHEME_HTTPS: ":scheme": "https" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[6].data(), + &static_mdelem_table[6].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_STATUS_200: ":status": "200" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[7].data(), + &static_mdelem_table[7].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_STATUS_204: ":status": "204" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[8].data(), + &static_mdelem_table[8].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_STATUS_206: ":status": "206" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[9].data(), + &static_mdelem_table[9].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_STATUS_304: ":status": "304" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[10].data(), + &static_mdelem_table[10].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_STATUS_400: ":status": "400" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[11].data(), + &static_mdelem_table[11].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_STATUS_404: ":status": "404" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[12].data(), + &static_mdelem_table[12].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_STATUS_500: ":status": "500" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[13].data(), + &static_mdelem_table[13].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_ACCEPT_CHARSET_EMPTY: "accept-charset": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[14].data(), + &static_mdelem_table[14].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_ACCEPT_ENCODING_GZIP_COMMA_DEFLATE: "accept-encoding": "gzip, deflate" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[15].data(), + &static_mdelem_table[15].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_ACCEPT_LANGUAGE_EMPTY: "accept-language": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[16].data(), + &static_mdelem_table[16].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_ACCEPT_RANGES_EMPTY: "accept-ranges": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[17].data(), + &static_mdelem_table[17].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_ACCEPT_EMPTY: "accept": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[18].data(), + &static_mdelem_table[18].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_ACCESS_CONTROL_ALLOW_ORIGIN_EMPTY: "access-control-allow-origin": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[19].data(), + &static_mdelem_table[19].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_AGE_EMPTY: "age": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[20].data(), + &static_mdelem_table[20].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_ALLOW_EMPTY: "allow": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[21].data(), + &static_mdelem_table[21].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_AUTHORIZATION_EMPTY: "authorization": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[22].data(), + &static_mdelem_table[22].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_CACHE_CONTROL_EMPTY: "cache-control": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[23].data(), + &static_mdelem_table[23].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_CONTENT_DISPOSITION_EMPTY: "content-disposition": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[24].data(), + &static_mdelem_table[24].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_CONTENT_ENCODING_EMPTY: "content-encoding": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[25].data(), + &static_mdelem_table[25].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_CONTENT_LANGUAGE_EMPTY: "content-language": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[26].data(), + &static_mdelem_table[26].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_CONTENT_LENGTH_EMPTY: "content-length": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[27].data(), + &static_mdelem_table[27].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_CONTENT_LOCATION_EMPTY: "content-location": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[28].data(), + &static_mdelem_table[28].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_CONTENT_RANGE_EMPTY: "content-range": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[29].data(), + &static_mdelem_table[29].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_CONTENT_TYPE_EMPTY: "content-type": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[30].data(), + &static_mdelem_table[30].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_COOKIE_EMPTY: "cookie": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[31].data(), + &static_mdelem_table[31].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_DATE_EMPTY: "date": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[32].data(), + &static_mdelem_table[32].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_ETAG_EMPTY: "etag": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[33].data(), + &static_mdelem_table[33].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_EXPECT_EMPTY: "expect": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[34].data(), + &static_mdelem_table[34].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_EXPIRES_EMPTY: "expires": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[35].data(), + &static_mdelem_table[35].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_FROM_EMPTY: "from": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[36].data(), + &static_mdelem_table[36].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_HOST_EMPTY: "host": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[37].data(), + &static_mdelem_table[37].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_IF_MATCH_EMPTY: "if-match": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[38].data(), + &static_mdelem_table[38].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_IF_MODIFIED_SINCE_EMPTY: "if-modified-since": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[39].data(), + &static_mdelem_table[39].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_IF_NONE_MATCH_EMPTY: "if-none-match": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[40].data(), + &static_mdelem_table[40].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_IF_RANGE_EMPTY: "if-range": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[41].data(), + &static_mdelem_table[41].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_IF_UNMODIFIED_SINCE_EMPTY: "if-unmodified-since": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[42].data(), + &static_mdelem_table[42].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_LAST_MODIFIED_EMPTY: "last-modified": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[43].data(), + &static_mdelem_table[43].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_LINK_EMPTY: "link": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[44].data(), + &static_mdelem_table[44].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_LOCATION_EMPTY: "location": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[45].data(), + &static_mdelem_table[45].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_MAX_FORWARDS_EMPTY: "max-forwards": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[46].data(), + &static_mdelem_table[46].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_PROXY_AUTHENTICATE_EMPTY: "proxy-authenticate": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[47].data(), + &static_mdelem_table[47].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_PROXY_AUTHORIZATION_EMPTY: "proxy-authorization": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[48].data(), + &static_mdelem_table[48].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_RANGE_EMPTY: "range": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[49].data(), + &static_mdelem_table[49].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_REFERER_EMPTY: "referer": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[50].data(), + &static_mdelem_table[50].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_REFRESH_EMPTY: "refresh": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[51].data(), + &static_mdelem_table[51].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_RETRY_AFTER_EMPTY: "retry-after": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[52].data(), + &static_mdelem_table[52].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_SERVER_EMPTY: "server": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[53].data(), + &static_mdelem_table[53].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_SET_COOKIE_EMPTY: "set-cookie": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[54].data(), + &static_mdelem_table[54].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_STRICT_TRANSPORT_SECURITY_EMPTY: "strict-transport-security": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[55].data(), + &static_mdelem_table[55].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_TRANSFER_ENCODING_EMPTY: "transfer-encoding": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[56].data(), + &static_mdelem_table[56].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_USER_AGENT_EMPTY: "user-agent": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[57].data(), + &static_mdelem_table[57].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_VARY_EMPTY: "vary": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[58].data(), + &static_mdelem_table[58].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_VIA_EMPTY: "via": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[59].data(), + &static_mdelem_table[59].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_WWW_AUTHENTICATE_EMPTY: "www-authenticate": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[60].data(), + &static_mdelem_table[60].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_STATUS_0: "grpc-status": "0" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[61].data(), + &static_mdelem_table[61].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_STATUS_1: "grpc-status": "1" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[62].data(), + &static_mdelem_table[62].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_STATUS_2: "grpc-status": "2" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[63].data(), + &static_mdelem_table[63].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_ENCODING_IDENTITY: "grpc-encoding": "identity" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[64].data(), + &static_mdelem_table[64].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_ENCODING_GZIP: "grpc-encoding": "gzip" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[65].data(), + &static_mdelem_table[65].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_ENCODING_DEFLATE: "grpc-encoding": "deflate" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[66].data(), + &static_mdelem_table[66].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_TE_TRAILERS: "te": "trailers" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[67].data(), + &static_mdelem_table[67].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC: "content-type": "application/grpc" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[68].data(), + &static_mdelem_table[68].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_SCHEME_GRPC: ":scheme": "grpc" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[69].data(), + &static_mdelem_table[69].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_METHOD_PUT: ":method": "PUT" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[70].data(), + &static_mdelem_table[70].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_ACCEPT_ENCODING_EMPTY: "accept-encoding": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[71].data(), + &static_mdelem_table[71].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_CONTENT_ENCODING_IDENTITY: "content-encoding": "identity" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[72].data(), + &static_mdelem_table[72].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_CONTENT_ENCODING_GZIP: "content-encoding": "gzip" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[73].data(), + &static_mdelem_table[73].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_LB_COST_BIN_EMPTY: "lb-cost-bin": "" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[74].data(), + &static_mdelem_table[74].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY: "grpc-accept-encoding": "identity" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[75].data(), + &static_mdelem_table[75].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE: "grpc-accept-encoding": "deflate" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[76].data(), + &static_mdelem_table[76].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE: "grpc-accept-encoding": "identity,deflate" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[77].data(), + &static_mdelem_table[77].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_GZIP: "grpc-accept-encoding": "gzip" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[78].data(), + &static_mdelem_table[78].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP: "grpc-accept-encoding": "identity,gzip" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[79].data(), + &static_mdelem_table[79].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE_COMMA_GZIP: "grpc-accept-encoding": "deflate,gzip" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[80].data(), + &static_mdelem_table[80].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP: "grpc-accept-encoding": "identity,deflate,gzip" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[81].data(), + &static_mdelem_table[81].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY: "accept-encoding": "identity" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[82].data(), + &static_mdelem_table[82].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_ACCEPT_ENCODING_GZIP: "accept-encoding": "gzip" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[83].data(), + &static_mdelem_table[83].data(), GRPC_MDELEM_STORAGE_STATIC), /* GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP: "accept-encoding": "identity,gzip" */ GRPC_MAKE_MDELEM( - &grpc_static_mdelem_table[84].data(), + &static_mdelem_table[84].data(), GRPC_MDELEM_STORAGE_STATIC) - // clang-format on + // clang-format on + }; }; +} // namespace grpc_core + +namespace grpc_core { +static StaticMetadataCtx* g_static_metadata_slice_ctx = nullptr; +const StaticMetadataSlice* g_static_metadata_slice_table = nullptr; +StaticSliceRefcount* g_static_metadata_slice_refcounts = nullptr; +StaticMetadata* g_static_mdelem_table = nullptr; +grpc_mdelem* g_static_mdelem_manifested = nullptr; +#ifndef NDEBUG +uint64_t StaticMetadataInitCanary() { + return g_static_metadata_slice_ctx->init_canary; +} +#endif +} // namespace grpc_core + +void grpc_init_static_metadata_ctx(void) { + grpc_core::g_static_metadata_slice_ctx = + grpc_core::New(); + grpc_core::g_static_metadata_slice_table = + grpc_core::g_static_metadata_slice_ctx->slices; + grpc_core::g_static_metadata_slice_refcounts = + grpc_core::g_static_metadata_slice_ctx->refcounts; + grpc_core::g_static_mdelem_table = + grpc_core::g_static_metadata_slice_ctx->static_mdelem_table; + grpc_core::g_static_mdelem_manifested = + grpc_core::g_static_metadata_slice_ctx->static_mdelem_manifested; +} + +void grpc_destroy_static_metadata_ctx(void) { + grpc_core::Delete( + grpc_core::g_static_metadata_slice_ctx); + grpc_core::g_static_metadata_slice_ctx = nullptr; + grpc_core::g_static_metadata_slice_table = nullptr; + grpc_core::g_static_metadata_slice_refcounts = nullptr; + grpc_core::g_static_mdelem_table = nullptr; + grpc_core::g_static_mdelem_manifested = nullptr; +} + uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -946,523 +1227,12 @@ grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b) { uint32_t h = elems_phash(k); return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k && elem_idxs[h] != 255 - ? GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[elem_idxs[h]].data(), - GRPC_MDELEM_STORAGE_STATIC) + ? GRPC_MAKE_MDELEM( + &grpc_static_mdelem_table()[elem_idxs[h]].data(), + GRPC_MDELEM_STORAGE_STATIC) : GRPC_MDNULL; } -grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[3].base, - 10, g_bytes + 19), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 0), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1].base, - 7, g_bytes + 5), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[41].base, - 3, g_bytes + 723), - 1), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1].base, - 7, g_bytes + 5), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[42].base, - 4, g_bytes + 726), - 2), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[0].base, - 5, g_bytes + 0), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[43].base, - 1, g_bytes + 730), - 3), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[0].base, - 5, g_bytes + 0), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[44].base, - 11, g_bytes + 731), - 4), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4].base, - 7, g_bytes + 29), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[45].base, - 4, g_bytes + 742), - 5), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4].base, - 7, g_bytes + 29), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[46].base, - 5, g_bytes + 746), - 6), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, - 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[47].base, - 3, g_bytes + 751), - 7), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, - 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[48].base, - 3, g_bytes + 754), - 8), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, - 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[49].base, - 3, g_bytes + 757), - 9), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, - 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[50].base, - 3, g_bytes + 760), - 10), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, - 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[51].base, - 3, g_bytes + 763), - 11), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, - 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[52].base, - 3, g_bytes + 766), - 12), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[2].base, - 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[53].base, - 3, g_bytes + 769), - 13), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[54].base, - 14, g_bytes + 772), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 14), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, - 15, g_bytes + 186), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[55].base, - 13, g_bytes + 786), - 15), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[56].base, - 15, g_bytes + 799), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 16), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[57].base, - 13, g_bytes + 814), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 17), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[58].base, - 6, g_bytes + 827), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 18), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[59].base, - 27, g_bytes + 833), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 19), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[60].base, - 3, g_bytes + 860), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 20), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[61].base, - 5, g_bytes + 863), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 21), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[62].base, - 13, g_bytes + 868), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 22), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[63].base, - 13, g_bytes + 881), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 23), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[64].base, - 19, g_bytes + 894), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 24), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15].base, - 16, g_bytes + 170), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 25), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[65].base, - 16, g_bytes + 913), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 26), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[66].base, - 14, g_bytes + 929), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 27), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[67].base, - 16, g_bytes + 943), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 28), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[68].base, - 13, g_bytes + 959), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 29), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[14].base, - 12, g_bytes + 158), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 30), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[69].base, - 6, g_bytes + 972), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 31), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[70].base, - 4, g_bytes + 978), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 32), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[71].base, - 4, g_bytes + 982), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 33), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[72].base, - 6, g_bytes + 986), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 34), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[73].base, - 7, g_bytes + 992), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 35), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[74].base, - 4, g_bytes + 999), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 36), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[20].base, - 4, g_bytes + 278), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 37), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[75].base, - 8, g_bytes + 1003), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 38), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[76].base, - 17, g_bytes + 1011), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 39), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[77].base, - 13, g_bytes + 1028), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 40), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[78].base, - 8, g_bytes + 1041), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 41), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[79].base, - 19, g_bytes + 1049), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 42), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[80].base, - 13, g_bytes + 1068), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 43), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[81].base, - 4, g_bytes + 1081), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 44), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[82].base, - 8, g_bytes + 1085), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 45), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[83].base, - 12, g_bytes + 1093), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 46), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[84].base, - 18, g_bytes + 1105), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 47), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[85].base, - 19, g_bytes + 1123), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 48), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[86].base, - 5, g_bytes + 1142), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 49), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[87].base, - 7, g_bytes + 1147), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 50), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[88].base, - 7, g_bytes + 1154), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 51), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[89].base, - 11, g_bytes + 1161), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 52), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[90].base, - 6, g_bytes + 1172), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 53), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[91].base, - 10, g_bytes + 1178), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 54), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[92].base, - 25, g_bytes + 1188), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 55), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[93].base, - 17, g_bytes + 1213), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 56), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[19].base, - 10, g_bytes + 268), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 57), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[94].base, - 4, g_bytes + 1230), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 58), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[95].base, - 3, g_bytes + 1234), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 59), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[96].base, - 16, g_bytes + 1237), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 60), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7].base, - 11, g_bytes + 50), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[97].base, - 1, g_bytes + 1253), - 61), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7].base, - 11, g_bytes + 50), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[24].base, - 1, g_bytes + 342), - 62), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[7].base, - 11, g_bytes + 50), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[25].base, - 1, g_bytes + 343), - 63), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9].base, - 13, g_bytes + 77), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98].base, - 8, g_bytes + 1254), - 64), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9].base, - 13, g_bytes + 77), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[39].base, - 4, g_bytes + 708), - 65), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[9].base, - 13, g_bytes + 77), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[38].base, - 7, g_bytes + 701), - 66), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[5].base, - 2, g_bytes + 36), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[99].base, - 8, g_bytes + 1262), - 67), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[14].base, - 12, g_bytes + 158), - grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[100].base, 16, g_bytes + 1270), - 68), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[4].base, - 7, g_bytes + 29), - grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[101].base, 4, g_bytes + 1286), - 69), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[1].base, - 7, g_bytes + 5), - grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[102].base, 3, g_bytes + 1290), - 70), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, - 15, g_bytes + 186), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 71), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15].base, - 16, g_bytes + 170), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98].base, - 8, g_bytes + 1254), - 72), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[15].base, - 16, g_bytes + 170), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[39].base, - 4, g_bytes + 708), - 73), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[103].base, 11, g_bytes + 1293), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[28].base, - 0, g_bytes + 346), - 74), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, - 20, g_bytes + 90), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98].base, - 8, g_bytes + 1254), - 75), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, - 20, g_bytes + 90), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[38].base, - 7, g_bytes + 701), - 76), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, - 20, g_bytes + 90), - grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[104].base, 16, g_bytes + 1304), - 77), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, - 20, g_bytes + 90), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[39].base, - 4, g_bytes + 708), - 78), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, - 20, g_bytes + 90), - grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[105].base, 13, g_bytes + 1320), - 79), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, - 20, g_bytes + 90), - grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[106].base, 12, g_bytes + 1333), - 80), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[10].base, - 20, g_bytes + 90), - grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[107].base, 21, g_bytes + 1345), - 81), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, - 15, g_bytes + 186), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[98].base, - 8, g_bytes + 1254), - 82), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, - 15, g_bytes + 186), - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[39].base, - 4, g_bytes + 708), - 83), - grpc_core::StaticMetadata( - grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[16].base, - 15, g_bytes + 186), - grpc_core::StaticMetadataSlice( - &grpc_static_metadata_refcounts[105].base, 13, g_bytes + 1320), - 84), -}; const uint8_t grpc_static_accept_encoding_metadata[8] = {0, 75, 76, 77, 78, 79, 80, 81}; diff --git a/src/core/lib/transport/static_metadata.h b/src/core/lib/transport/static_metadata.h index 7ea000e1066..c465a2f37b7 100644 --- a/src/core/lib/transport/static_metadata.h +++ b/src/core/lib/transport/static_metadata.h @@ -37,240 +37,262 @@ static_assert( std::is_trivially_destructible::value, "grpc_core::StaticMetadataSlice must be trivially destructible."); #define GRPC_STATIC_MDSTR_COUNT 108 -extern const grpc_core::StaticMetadataSlice - grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT]; + +void grpc_init_static_metadata_ctx(void); +void grpc_destroy_static_metadata_ctx(void); +namespace grpc_core { +#ifndef NDEBUG +constexpr uint64_t kGrpcStaticMetadataInitCanary = 0xCAFEF00DC0FFEE11L; +uint64_t StaticMetadataInitCanary(); +#endif +extern const StaticMetadataSlice* g_static_metadata_slice_table; +} +inline const grpc_core::StaticMetadataSlice* grpc_static_slice_table() { + GPR_DEBUG_ASSERT(grpc_core::StaticMetadataInitCanary() == + grpc_core::kGrpcStaticMetadataInitCanary); + GPR_DEBUG_ASSERT(grpc_core::g_static_metadata_slice_table != nullptr); + return grpc_core::g_static_metadata_slice_table; +} + /* ":path" */ -#define GRPC_MDSTR_PATH (grpc_static_slice_table[0]) +#define GRPC_MDSTR_PATH (grpc_static_slice_table()[0]) /* ":method" */ -#define GRPC_MDSTR_METHOD (grpc_static_slice_table[1]) +#define GRPC_MDSTR_METHOD (grpc_static_slice_table()[1]) /* ":status" */ -#define GRPC_MDSTR_STATUS (grpc_static_slice_table[2]) +#define GRPC_MDSTR_STATUS (grpc_static_slice_table()[2]) /* ":authority" */ -#define GRPC_MDSTR_AUTHORITY (grpc_static_slice_table[3]) +#define GRPC_MDSTR_AUTHORITY (grpc_static_slice_table()[3]) /* ":scheme" */ -#define GRPC_MDSTR_SCHEME (grpc_static_slice_table[4]) +#define GRPC_MDSTR_SCHEME (grpc_static_slice_table()[4]) /* "te" */ -#define GRPC_MDSTR_TE (grpc_static_slice_table[5]) +#define GRPC_MDSTR_TE (grpc_static_slice_table()[5]) /* "grpc-message" */ -#define GRPC_MDSTR_GRPC_MESSAGE (grpc_static_slice_table[6]) +#define GRPC_MDSTR_GRPC_MESSAGE (grpc_static_slice_table()[6]) /* "grpc-status" */ -#define GRPC_MDSTR_GRPC_STATUS (grpc_static_slice_table[7]) +#define GRPC_MDSTR_GRPC_STATUS (grpc_static_slice_table()[7]) /* "grpc-payload-bin" */ -#define GRPC_MDSTR_GRPC_PAYLOAD_BIN (grpc_static_slice_table[8]) +#define GRPC_MDSTR_GRPC_PAYLOAD_BIN (grpc_static_slice_table()[8]) /* "grpc-encoding" */ -#define GRPC_MDSTR_GRPC_ENCODING (grpc_static_slice_table[9]) +#define GRPC_MDSTR_GRPC_ENCODING (grpc_static_slice_table()[9]) /* "grpc-accept-encoding" */ -#define GRPC_MDSTR_GRPC_ACCEPT_ENCODING (grpc_static_slice_table[10]) +#define GRPC_MDSTR_GRPC_ACCEPT_ENCODING (grpc_static_slice_table()[10]) /* "grpc-server-stats-bin" */ -#define GRPC_MDSTR_GRPC_SERVER_STATS_BIN (grpc_static_slice_table[11]) +#define GRPC_MDSTR_GRPC_SERVER_STATS_BIN (grpc_static_slice_table()[11]) /* "grpc-tags-bin" */ -#define GRPC_MDSTR_GRPC_TAGS_BIN (grpc_static_slice_table[12]) +#define GRPC_MDSTR_GRPC_TAGS_BIN (grpc_static_slice_table()[12]) /* "grpc-trace-bin" */ -#define GRPC_MDSTR_GRPC_TRACE_BIN (grpc_static_slice_table[13]) +#define GRPC_MDSTR_GRPC_TRACE_BIN (grpc_static_slice_table()[13]) /* "content-type" */ -#define GRPC_MDSTR_CONTENT_TYPE (grpc_static_slice_table[14]) +#define GRPC_MDSTR_CONTENT_TYPE (grpc_static_slice_table()[14]) /* "content-encoding" */ -#define GRPC_MDSTR_CONTENT_ENCODING (grpc_static_slice_table[15]) +#define GRPC_MDSTR_CONTENT_ENCODING (grpc_static_slice_table()[15]) /* "accept-encoding" */ -#define GRPC_MDSTR_ACCEPT_ENCODING (grpc_static_slice_table[16]) +#define GRPC_MDSTR_ACCEPT_ENCODING (grpc_static_slice_table()[16]) /* "grpc-internal-encoding-request" */ -#define GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST (grpc_static_slice_table[17]) +#define GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST \ + (grpc_static_slice_table()[17]) /* "grpc-internal-stream-encoding-request" */ #define GRPC_MDSTR_GRPC_INTERNAL_STREAM_ENCODING_REQUEST \ - (grpc_static_slice_table[18]) + (grpc_static_slice_table()[18]) /* "user-agent" */ -#define GRPC_MDSTR_USER_AGENT (grpc_static_slice_table[19]) +#define GRPC_MDSTR_USER_AGENT (grpc_static_slice_table()[19]) /* "host" */ -#define GRPC_MDSTR_HOST (grpc_static_slice_table[20]) +#define GRPC_MDSTR_HOST (grpc_static_slice_table()[20]) /* "grpc-previous-rpc-attempts" */ -#define GRPC_MDSTR_GRPC_PREVIOUS_RPC_ATTEMPTS (grpc_static_slice_table[21]) +#define GRPC_MDSTR_GRPC_PREVIOUS_RPC_ATTEMPTS (grpc_static_slice_table()[21]) /* "grpc-retry-pushback-ms" */ -#define GRPC_MDSTR_GRPC_RETRY_PUSHBACK_MS (grpc_static_slice_table[22]) +#define GRPC_MDSTR_GRPC_RETRY_PUSHBACK_MS (grpc_static_slice_table()[22]) /* "grpc-timeout" */ -#define GRPC_MDSTR_GRPC_TIMEOUT (grpc_static_slice_table[23]) +#define GRPC_MDSTR_GRPC_TIMEOUT (grpc_static_slice_table()[23]) /* "1" */ -#define GRPC_MDSTR_1 (grpc_static_slice_table[24]) +#define GRPC_MDSTR_1 (grpc_static_slice_table()[24]) /* "2" */ -#define GRPC_MDSTR_2 (grpc_static_slice_table[25]) +#define GRPC_MDSTR_2 (grpc_static_slice_table()[25]) /* "3" */ -#define GRPC_MDSTR_3 (grpc_static_slice_table[26]) +#define GRPC_MDSTR_3 (grpc_static_slice_table()[26]) /* "4" */ -#define GRPC_MDSTR_4 (grpc_static_slice_table[27]) +#define GRPC_MDSTR_4 (grpc_static_slice_table()[27]) /* "" */ -#define GRPC_MDSTR_EMPTY (grpc_static_slice_table[28]) +#define GRPC_MDSTR_EMPTY (grpc_static_slice_table()[28]) /* "grpc.wait_for_ready" */ -#define GRPC_MDSTR_GRPC_DOT_WAIT_FOR_READY (grpc_static_slice_table[29]) +#define GRPC_MDSTR_GRPC_DOT_WAIT_FOR_READY (grpc_static_slice_table()[29]) /* "grpc.timeout" */ -#define GRPC_MDSTR_GRPC_DOT_TIMEOUT (grpc_static_slice_table[30]) +#define GRPC_MDSTR_GRPC_DOT_TIMEOUT (grpc_static_slice_table()[30]) /* "grpc.max_request_message_bytes" */ #define GRPC_MDSTR_GRPC_DOT_MAX_REQUEST_MESSAGE_BYTES \ - (grpc_static_slice_table[31]) + (grpc_static_slice_table()[31]) /* "grpc.max_response_message_bytes" */ #define GRPC_MDSTR_GRPC_DOT_MAX_RESPONSE_MESSAGE_BYTES \ - (grpc_static_slice_table[32]) + (grpc_static_slice_table()[32]) /* "/grpc.lb.v1.LoadBalancer/BalanceLoad" */ #define GRPC_MDSTR_SLASH_GRPC_DOT_LB_DOT_V1_DOT_LOADBALANCER_SLASH_BALANCELOAD \ - (grpc_static_slice_table[33]) + (grpc_static_slice_table()[33]) /* "/envoy.service.load_stats.v2.LoadReportingService/StreamLoadStats" */ #define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_LOAD_STATS_DOT_V2_DOT_LOADREPORTINGSERVICE_SLASH_STREAMLOADSTATS \ - (grpc_static_slice_table[34]) + (grpc_static_slice_table()[34]) /* "/envoy.api.v2.EndpointDiscoveryService/StreamEndpoints" */ #define GRPC_MDSTR_SLASH_ENVOY_DOT_API_DOT_V2_DOT_ENDPOINTDISCOVERYSERVICE_SLASH_STREAMENDPOINTS \ - (grpc_static_slice_table[35]) + (grpc_static_slice_table()[35]) /* "/grpc.health.v1.Health/Watch" */ #define GRPC_MDSTR_SLASH_GRPC_DOT_HEALTH_DOT_V1_DOT_HEALTH_SLASH_WATCH \ - (grpc_static_slice_table[36]) + (grpc_static_slice_table()[36]) /* "/envoy.service.discovery.v2.AggregatedDiscoveryService/StreamAggregatedResources" */ #define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_DISCOVERY_DOT_V2_DOT_AGGREGATEDDISCOVERYSERVICE_SLASH_STREAMAGGREGATEDRESOURCES \ - (grpc_static_slice_table[37]) + (grpc_static_slice_table()[37]) /* "deflate" */ -#define GRPC_MDSTR_DEFLATE (grpc_static_slice_table[38]) +#define GRPC_MDSTR_DEFLATE (grpc_static_slice_table()[38]) /* "gzip" */ -#define GRPC_MDSTR_GZIP (grpc_static_slice_table[39]) +#define GRPC_MDSTR_GZIP (grpc_static_slice_table()[39]) /* "stream/gzip" */ -#define GRPC_MDSTR_STREAM_SLASH_GZIP (grpc_static_slice_table[40]) +#define GRPC_MDSTR_STREAM_SLASH_GZIP (grpc_static_slice_table()[40]) /* "GET" */ -#define GRPC_MDSTR_GET (grpc_static_slice_table[41]) +#define GRPC_MDSTR_GET (grpc_static_slice_table()[41]) /* "POST" */ -#define GRPC_MDSTR_POST (grpc_static_slice_table[42]) +#define GRPC_MDSTR_POST (grpc_static_slice_table()[42]) /* "/" */ -#define GRPC_MDSTR_SLASH (grpc_static_slice_table[43]) +#define GRPC_MDSTR_SLASH (grpc_static_slice_table()[43]) /* "/index.html" */ -#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (grpc_static_slice_table[44]) +#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (grpc_static_slice_table()[44]) /* "http" */ -#define GRPC_MDSTR_HTTP (grpc_static_slice_table[45]) +#define GRPC_MDSTR_HTTP (grpc_static_slice_table()[45]) /* "https" */ -#define GRPC_MDSTR_HTTPS (grpc_static_slice_table[46]) +#define GRPC_MDSTR_HTTPS (grpc_static_slice_table()[46]) /* "200" */ -#define GRPC_MDSTR_200 (grpc_static_slice_table[47]) +#define GRPC_MDSTR_200 (grpc_static_slice_table()[47]) /* "204" */ -#define GRPC_MDSTR_204 (grpc_static_slice_table[48]) +#define GRPC_MDSTR_204 (grpc_static_slice_table()[48]) /* "206" */ -#define GRPC_MDSTR_206 (grpc_static_slice_table[49]) +#define GRPC_MDSTR_206 (grpc_static_slice_table()[49]) /* "304" */ -#define GRPC_MDSTR_304 (grpc_static_slice_table[50]) +#define GRPC_MDSTR_304 (grpc_static_slice_table()[50]) /* "400" */ -#define GRPC_MDSTR_400 (grpc_static_slice_table[51]) +#define GRPC_MDSTR_400 (grpc_static_slice_table()[51]) /* "404" */ -#define GRPC_MDSTR_404 (grpc_static_slice_table[52]) +#define GRPC_MDSTR_404 (grpc_static_slice_table()[52]) /* "500" */ -#define GRPC_MDSTR_500 (grpc_static_slice_table[53]) +#define GRPC_MDSTR_500 (grpc_static_slice_table()[53]) /* "accept-charset" */ -#define GRPC_MDSTR_ACCEPT_CHARSET (grpc_static_slice_table[54]) +#define GRPC_MDSTR_ACCEPT_CHARSET (grpc_static_slice_table()[54]) /* "gzip, deflate" */ -#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (grpc_static_slice_table[55]) +#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (grpc_static_slice_table()[55]) /* "accept-language" */ -#define GRPC_MDSTR_ACCEPT_LANGUAGE (grpc_static_slice_table[56]) +#define GRPC_MDSTR_ACCEPT_LANGUAGE (grpc_static_slice_table()[56]) /* "accept-ranges" */ -#define GRPC_MDSTR_ACCEPT_RANGES (grpc_static_slice_table[57]) +#define GRPC_MDSTR_ACCEPT_RANGES (grpc_static_slice_table()[57]) /* "accept" */ -#define GRPC_MDSTR_ACCEPT (grpc_static_slice_table[58]) +#define GRPC_MDSTR_ACCEPT (grpc_static_slice_table()[58]) /* "access-control-allow-origin" */ -#define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN (grpc_static_slice_table[59]) +#define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN (grpc_static_slice_table()[59]) /* "age" */ -#define GRPC_MDSTR_AGE (grpc_static_slice_table[60]) +#define GRPC_MDSTR_AGE (grpc_static_slice_table()[60]) /* "allow" */ -#define GRPC_MDSTR_ALLOW (grpc_static_slice_table[61]) +#define GRPC_MDSTR_ALLOW (grpc_static_slice_table()[61]) /* "authorization" */ -#define GRPC_MDSTR_AUTHORIZATION (grpc_static_slice_table[62]) +#define GRPC_MDSTR_AUTHORIZATION (grpc_static_slice_table()[62]) /* "cache-control" */ -#define GRPC_MDSTR_CACHE_CONTROL (grpc_static_slice_table[63]) +#define GRPC_MDSTR_CACHE_CONTROL (grpc_static_slice_table()[63]) /* "content-disposition" */ -#define GRPC_MDSTR_CONTENT_DISPOSITION (grpc_static_slice_table[64]) +#define GRPC_MDSTR_CONTENT_DISPOSITION (grpc_static_slice_table()[64]) /* "content-language" */ -#define GRPC_MDSTR_CONTENT_LANGUAGE (grpc_static_slice_table[65]) +#define GRPC_MDSTR_CONTENT_LANGUAGE (grpc_static_slice_table()[65]) /* "content-length" */ -#define GRPC_MDSTR_CONTENT_LENGTH (grpc_static_slice_table[66]) +#define GRPC_MDSTR_CONTENT_LENGTH (grpc_static_slice_table()[66]) /* "content-location" */ -#define GRPC_MDSTR_CONTENT_LOCATION (grpc_static_slice_table[67]) +#define GRPC_MDSTR_CONTENT_LOCATION (grpc_static_slice_table()[67]) /* "content-range" */ -#define GRPC_MDSTR_CONTENT_RANGE (grpc_static_slice_table[68]) +#define GRPC_MDSTR_CONTENT_RANGE (grpc_static_slice_table()[68]) /* "cookie" */ -#define GRPC_MDSTR_COOKIE (grpc_static_slice_table[69]) +#define GRPC_MDSTR_COOKIE (grpc_static_slice_table()[69]) /* "date" */ -#define GRPC_MDSTR_DATE (grpc_static_slice_table[70]) +#define GRPC_MDSTR_DATE (grpc_static_slice_table()[70]) /* "etag" */ -#define GRPC_MDSTR_ETAG (grpc_static_slice_table[71]) +#define GRPC_MDSTR_ETAG (grpc_static_slice_table()[71]) /* "expect" */ -#define GRPC_MDSTR_EXPECT (grpc_static_slice_table[72]) +#define GRPC_MDSTR_EXPECT (grpc_static_slice_table()[72]) /* "expires" */ -#define GRPC_MDSTR_EXPIRES (grpc_static_slice_table[73]) +#define GRPC_MDSTR_EXPIRES (grpc_static_slice_table()[73]) /* "from" */ -#define GRPC_MDSTR_FROM (grpc_static_slice_table[74]) +#define GRPC_MDSTR_FROM (grpc_static_slice_table()[74]) /* "if-match" */ -#define GRPC_MDSTR_IF_MATCH (grpc_static_slice_table[75]) +#define GRPC_MDSTR_IF_MATCH (grpc_static_slice_table()[75]) /* "if-modified-since" */ -#define GRPC_MDSTR_IF_MODIFIED_SINCE (grpc_static_slice_table[76]) +#define GRPC_MDSTR_IF_MODIFIED_SINCE (grpc_static_slice_table()[76]) /* "if-none-match" */ -#define GRPC_MDSTR_IF_NONE_MATCH (grpc_static_slice_table[77]) +#define GRPC_MDSTR_IF_NONE_MATCH (grpc_static_slice_table()[77]) /* "if-range" */ -#define GRPC_MDSTR_IF_RANGE (grpc_static_slice_table[78]) +#define GRPC_MDSTR_IF_RANGE (grpc_static_slice_table()[78]) /* "if-unmodified-since" */ -#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (grpc_static_slice_table[79]) +#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (grpc_static_slice_table()[79]) /* "last-modified" */ -#define GRPC_MDSTR_LAST_MODIFIED (grpc_static_slice_table[80]) +#define GRPC_MDSTR_LAST_MODIFIED (grpc_static_slice_table()[80]) /* "link" */ -#define GRPC_MDSTR_LINK (grpc_static_slice_table[81]) +#define GRPC_MDSTR_LINK (grpc_static_slice_table()[81]) /* "location" */ -#define GRPC_MDSTR_LOCATION (grpc_static_slice_table[82]) +#define GRPC_MDSTR_LOCATION (grpc_static_slice_table()[82]) /* "max-forwards" */ -#define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table[83]) +#define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table()[83]) /* "proxy-authenticate" */ -#define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table[84]) +#define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table()[84]) /* "proxy-authorization" */ -#define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table[85]) +#define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table()[85]) /* "range" */ -#define GRPC_MDSTR_RANGE (grpc_static_slice_table[86]) +#define GRPC_MDSTR_RANGE (grpc_static_slice_table()[86]) /* "referer" */ -#define GRPC_MDSTR_REFERER (grpc_static_slice_table[87]) +#define GRPC_MDSTR_REFERER (grpc_static_slice_table()[87]) /* "refresh" */ -#define GRPC_MDSTR_REFRESH (grpc_static_slice_table[88]) +#define GRPC_MDSTR_REFRESH (grpc_static_slice_table()[88]) /* "retry-after" */ -#define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table[89]) +#define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table()[89]) /* "server" */ -#define GRPC_MDSTR_SERVER (grpc_static_slice_table[90]) +#define GRPC_MDSTR_SERVER (grpc_static_slice_table()[90]) /* "set-cookie" */ -#define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table[91]) +#define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table()[91]) /* "strict-transport-security" */ -#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table[92]) +#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table()[92]) /* "transfer-encoding" */ -#define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table[93]) +#define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table()[93]) /* "vary" */ -#define GRPC_MDSTR_VARY (grpc_static_slice_table[94]) +#define GRPC_MDSTR_VARY (grpc_static_slice_table()[94]) /* "via" */ -#define GRPC_MDSTR_VIA (grpc_static_slice_table[95]) +#define GRPC_MDSTR_VIA (grpc_static_slice_table()[95]) /* "www-authenticate" */ -#define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table[96]) +#define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table()[96]) /* "0" */ -#define GRPC_MDSTR_0 (grpc_static_slice_table[97]) +#define GRPC_MDSTR_0 (grpc_static_slice_table()[97]) /* "identity" */ -#define GRPC_MDSTR_IDENTITY (grpc_static_slice_table[98]) +#define GRPC_MDSTR_IDENTITY (grpc_static_slice_table()[98]) /* "trailers" */ -#define GRPC_MDSTR_TRAILERS (grpc_static_slice_table[99]) +#define GRPC_MDSTR_TRAILERS (grpc_static_slice_table()[99]) /* "application/grpc" */ -#define GRPC_MDSTR_APPLICATION_SLASH_GRPC (grpc_static_slice_table[100]) +#define GRPC_MDSTR_APPLICATION_SLASH_GRPC (grpc_static_slice_table()[100]) /* "grpc" */ -#define GRPC_MDSTR_GRPC (grpc_static_slice_table[101]) +#define GRPC_MDSTR_GRPC (grpc_static_slice_table()[101]) /* "PUT" */ -#define GRPC_MDSTR_PUT (grpc_static_slice_table[102]) +#define GRPC_MDSTR_PUT (grpc_static_slice_table()[102]) /* "lb-cost-bin" */ -#define GRPC_MDSTR_LB_COST_BIN (grpc_static_slice_table[103]) +#define GRPC_MDSTR_LB_COST_BIN (grpc_static_slice_table()[103]) /* "identity,deflate" */ -#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (grpc_static_slice_table[104]) +#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (grpc_static_slice_table()[104]) /* "identity,gzip" */ -#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (grpc_static_slice_table[105]) +#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (grpc_static_slice_table()[105]) /* "deflate,gzip" */ -#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (grpc_static_slice_table[106]) +#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (grpc_static_slice_table()[106]) /* "identity,deflate,gzip" */ #define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \ - (grpc_static_slice_table[107]) + (grpc_static_slice_table()[107]) namespace grpc_core { struct StaticSliceRefcount; +extern StaticSliceRefcount* g_static_metadata_slice_refcounts; +} // namespace grpc_core +inline grpc_core::StaticSliceRefcount* grpc_static_metadata_refcounts() { + GPR_DEBUG_ASSERT(grpc_core::StaticMetadataInitCanary() == + grpc_core::kGrpcStaticMetadataInitCanary); + GPR_DEBUG_ASSERT(grpc_core::g_static_metadata_slice_refcounts != nullptr); + return grpc_core::g_static_metadata_slice_refcounts; } -extern grpc_core::StaticSliceRefcount - grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT]; + #define GRPC_IS_STATIC_METADATA_STRING(slice) \ ((slice).refcount != NULL && \ (slice).refcount->GetType() == grpc_slice_refcount::Type::STATIC) @@ -280,196 +302,216 @@ extern grpc_core::StaticSliceRefcount ->index) #define GRPC_STATIC_MDELEM_COUNT 85 -extern grpc_core::StaticMetadata - grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT]; + +namespace grpc_core { +extern StaticMetadata* g_static_mdelem_table; +extern grpc_mdelem* g_static_mdelem_manifested; +} // namespace grpc_core +inline grpc_core::StaticMetadata* grpc_static_mdelem_table() { + GPR_DEBUG_ASSERT(grpc_core::StaticMetadataInitCanary() == + grpc_core::kGrpcStaticMetadataInitCanary); + GPR_DEBUG_ASSERT(grpc_core::g_static_mdelem_table != nullptr); + return grpc_core::g_static_mdelem_table; +} +inline grpc_mdelem* grpc_static_mdelem_manifested() { + GPR_DEBUG_ASSERT(grpc_core::StaticMetadataInitCanary() == + grpc_core::kGrpcStaticMetadataInitCanary); + GPR_DEBUG_ASSERT(grpc_core::g_static_mdelem_manifested != nullptr); + return grpc_core::g_static_mdelem_manifested; +} + extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT]; -extern grpc_mdelem grpc_static_mdelem_manifested[GRPC_STATIC_MDELEM_COUNT]; /* ":authority": "" */ -#define GRPC_MDELEM_AUTHORITY_EMPTY (grpc_static_mdelem_manifested[0]) +#define GRPC_MDELEM_AUTHORITY_EMPTY (grpc_static_mdelem_manifested()[0]) /* ":method": "GET" */ -#define GRPC_MDELEM_METHOD_GET (grpc_static_mdelem_manifested[1]) +#define GRPC_MDELEM_METHOD_GET (grpc_static_mdelem_manifested()[1]) /* ":method": "POST" */ -#define GRPC_MDELEM_METHOD_POST (grpc_static_mdelem_manifested[2]) +#define GRPC_MDELEM_METHOD_POST (grpc_static_mdelem_manifested()[2]) /* ":path": "/" */ -#define GRPC_MDELEM_PATH_SLASH (grpc_static_mdelem_manifested[3]) +#define GRPC_MDELEM_PATH_SLASH (grpc_static_mdelem_manifested()[3]) /* ":path": "/index.html" */ -#define GRPC_MDELEM_PATH_SLASH_INDEX_DOT_HTML (grpc_static_mdelem_manifested[4]) +#define GRPC_MDELEM_PATH_SLASH_INDEX_DOT_HTML \ + (grpc_static_mdelem_manifested()[4]) /* ":scheme": "http" */ -#define GRPC_MDELEM_SCHEME_HTTP (grpc_static_mdelem_manifested[5]) +#define GRPC_MDELEM_SCHEME_HTTP (grpc_static_mdelem_manifested()[5]) /* ":scheme": "https" */ -#define GRPC_MDELEM_SCHEME_HTTPS (grpc_static_mdelem_manifested[6]) +#define GRPC_MDELEM_SCHEME_HTTPS (grpc_static_mdelem_manifested()[6]) /* ":status": "200" */ -#define GRPC_MDELEM_STATUS_200 (grpc_static_mdelem_manifested[7]) +#define GRPC_MDELEM_STATUS_200 (grpc_static_mdelem_manifested()[7]) /* ":status": "204" */ -#define GRPC_MDELEM_STATUS_204 (grpc_static_mdelem_manifested[8]) +#define GRPC_MDELEM_STATUS_204 (grpc_static_mdelem_manifested()[8]) /* ":status": "206" */ -#define GRPC_MDELEM_STATUS_206 (grpc_static_mdelem_manifested[9]) +#define GRPC_MDELEM_STATUS_206 (grpc_static_mdelem_manifested()[9]) /* ":status": "304" */ -#define GRPC_MDELEM_STATUS_304 (grpc_static_mdelem_manifested[10]) +#define GRPC_MDELEM_STATUS_304 (grpc_static_mdelem_manifested()[10]) /* ":status": "400" */ -#define GRPC_MDELEM_STATUS_400 (grpc_static_mdelem_manifested[11]) +#define GRPC_MDELEM_STATUS_400 (grpc_static_mdelem_manifested()[11]) /* ":status": "404" */ -#define GRPC_MDELEM_STATUS_404 (grpc_static_mdelem_manifested[12]) +#define GRPC_MDELEM_STATUS_404 (grpc_static_mdelem_manifested()[12]) /* ":status": "500" */ -#define GRPC_MDELEM_STATUS_500 (grpc_static_mdelem_manifested[13]) +#define GRPC_MDELEM_STATUS_500 (grpc_static_mdelem_manifested()[13]) /* "accept-charset": "" */ -#define GRPC_MDELEM_ACCEPT_CHARSET_EMPTY (grpc_static_mdelem_manifested[14]) +#define GRPC_MDELEM_ACCEPT_CHARSET_EMPTY (grpc_static_mdelem_manifested()[14]) /* "accept-encoding": "gzip, deflate" */ #define GRPC_MDELEM_ACCEPT_ENCODING_GZIP_COMMA_DEFLATE \ - (grpc_static_mdelem_manifested[15]) + (grpc_static_mdelem_manifested()[15]) /* "accept-language": "" */ -#define GRPC_MDELEM_ACCEPT_LANGUAGE_EMPTY (grpc_static_mdelem_manifested[16]) +#define GRPC_MDELEM_ACCEPT_LANGUAGE_EMPTY (grpc_static_mdelem_manifested()[16]) /* "accept-ranges": "" */ -#define GRPC_MDELEM_ACCEPT_RANGES_EMPTY (grpc_static_mdelem_manifested[17]) +#define GRPC_MDELEM_ACCEPT_RANGES_EMPTY (grpc_static_mdelem_manifested()[17]) /* "accept": "" */ -#define GRPC_MDELEM_ACCEPT_EMPTY (grpc_static_mdelem_manifested[18]) +#define GRPC_MDELEM_ACCEPT_EMPTY (grpc_static_mdelem_manifested()[18]) /* "access-control-allow-origin": "" */ #define GRPC_MDELEM_ACCESS_CONTROL_ALLOW_ORIGIN_EMPTY \ - (grpc_static_mdelem_manifested[19]) + (grpc_static_mdelem_manifested()[19]) /* "age": "" */ -#define GRPC_MDELEM_AGE_EMPTY (grpc_static_mdelem_manifested[20]) +#define GRPC_MDELEM_AGE_EMPTY (grpc_static_mdelem_manifested()[20]) /* "allow": "" */ -#define GRPC_MDELEM_ALLOW_EMPTY (grpc_static_mdelem_manifested[21]) +#define GRPC_MDELEM_ALLOW_EMPTY (grpc_static_mdelem_manifested()[21]) /* "authorization": "" */ -#define GRPC_MDELEM_AUTHORIZATION_EMPTY (grpc_static_mdelem_manifested[22]) +#define GRPC_MDELEM_AUTHORIZATION_EMPTY (grpc_static_mdelem_manifested()[22]) /* "cache-control": "" */ -#define GRPC_MDELEM_CACHE_CONTROL_EMPTY (grpc_static_mdelem_manifested[23]) +#define GRPC_MDELEM_CACHE_CONTROL_EMPTY (grpc_static_mdelem_manifested()[23]) /* "content-disposition": "" */ #define GRPC_MDELEM_CONTENT_DISPOSITION_EMPTY \ - (grpc_static_mdelem_manifested[24]) + (grpc_static_mdelem_manifested()[24]) /* "content-encoding": "" */ -#define GRPC_MDELEM_CONTENT_ENCODING_EMPTY (grpc_static_mdelem_manifested[25]) +#define GRPC_MDELEM_CONTENT_ENCODING_EMPTY (grpc_static_mdelem_manifested()[25]) /* "content-language": "" */ -#define GRPC_MDELEM_CONTENT_LANGUAGE_EMPTY (grpc_static_mdelem_manifested[26]) +#define GRPC_MDELEM_CONTENT_LANGUAGE_EMPTY (grpc_static_mdelem_manifested()[26]) /* "content-length": "" */ -#define GRPC_MDELEM_CONTENT_LENGTH_EMPTY (grpc_static_mdelem_manifested[27]) +#define GRPC_MDELEM_CONTENT_LENGTH_EMPTY (grpc_static_mdelem_manifested()[27]) /* "content-location": "" */ -#define GRPC_MDELEM_CONTENT_LOCATION_EMPTY (grpc_static_mdelem_manifested[28]) +#define GRPC_MDELEM_CONTENT_LOCATION_EMPTY (grpc_static_mdelem_manifested()[28]) /* "content-range": "" */ -#define GRPC_MDELEM_CONTENT_RANGE_EMPTY (grpc_static_mdelem_manifested[29]) +#define GRPC_MDELEM_CONTENT_RANGE_EMPTY (grpc_static_mdelem_manifested()[29]) /* "content-type": "" */ -#define GRPC_MDELEM_CONTENT_TYPE_EMPTY (grpc_static_mdelem_manifested[30]) +#define GRPC_MDELEM_CONTENT_TYPE_EMPTY (grpc_static_mdelem_manifested()[30]) /* "cookie": "" */ -#define GRPC_MDELEM_COOKIE_EMPTY (grpc_static_mdelem_manifested[31]) +#define GRPC_MDELEM_COOKIE_EMPTY (grpc_static_mdelem_manifested()[31]) /* "date": "" */ -#define GRPC_MDELEM_DATE_EMPTY (grpc_static_mdelem_manifested[32]) +#define GRPC_MDELEM_DATE_EMPTY (grpc_static_mdelem_manifested()[32]) /* "etag": "" */ -#define GRPC_MDELEM_ETAG_EMPTY (grpc_static_mdelem_manifested[33]) +#define GRPC_MDELEM_ETAG_EMPTY (grpc_static_mdelem_manifested()[33]) /* "expect": "" */ -#define GRPC_MDELEM_EXPECT_EMPTY (grpc_static_mdelem_manifested[34]) +#define GRPC_MDELEM_EXPECT_EMPTY (grpc_static_mdelem_manifested()[34]) /* "expires": "" */ -#define GRPC_MDELEM_EXPIRES_EMPTY (grpc_static_mdelem_manifested[35]) +#define GRPC_MDELEM_EXPIRES_EMPTY (grpc_static_mdelem_manifested()[35]) /* "from": "" */ -#define GRPC_MDELEM_FROM_EMPTY (grpc_static_mdelem_manifested[36]) +#define GRPC_MDELEM_FROM_EMPTY (grpc_static_mdelem_manifested()[36]) /* "host": "" */ -#define GRPC_MDELEM_HOST_EMPTY (grpc_static_mdelem_manifested[37]) +#define GRPC_MDELEM_HOST_EMPTY (grpc_static_mdelem_manifested()[37]) /* "if-match": "" */ -#define GRPC_MDELEM_IF_MATCH_EMPTY (grpc_static_mdelem_manifested[38]) +#define GRPC_MDELEM_IF_MATCH_EMPTY (grpc_static_mdelem_manifested()[38]) /* "if-modified-since": "" */ -#define GRPC_MDELEM_IF_MODIFIED_SINCE_EMPTY (grpc_static_mdelem_manifested[39]) +#define GRPC_MDELEM_IF_MODIFIED_SINCE_EMPTY \ + (grpc_static_mdelem_manifested()[39]) /* "if-none-match": "" */ -#define GRPC_MDELEM_IF_NONE_MATCH_EMPTY (grpc_static_mdelem_manifested[40]) +#define GRPC_MDELEM_IF_NONE_MATCH_EMPTY (grpc_static_mdelem_manifested()[40]) /* "if-range": "" */ -#define GRPC_MDELEM_IF_RANGE_EMPTY (grpc_static_mdelem_manifested[41]) +#define GRPC_MDELEM_IF_RANGE_EMPTY (grpc_static_mdelem_manifested()[41]) /* "if-unmodified-since": "" */ #define GRPC_MDELEM_IF_UNMODIFIED_SINCE_EMPTY \ - (grpc_static_mdelem_manifested[42]) + (grpc_static_mdelem_manifested()[42]) /* "last-modified": "" */ -#define GRPC_MDELEM_LAST_MODIFIED_EMPTY (grpc_static_mdelem_manifested[43]) +#define GRPC_MDELEM_LAST_MODIFIED_EMPTY (grpc_static_mdelem_manifested()[43]) /* "link": "" */ -#define GRPC_MDELEM_LINK_EMPTY (grpc_static_mdelem_manifested[44]) +#define GRPC_MDELEM_LINK_EMPTY (grpc_static_mdelem_manifested()[44]) /* "location": "" */ -#define GRPC_MDELEM_LOCATION_EMPTY (grpc_static_mdelem_manifested[45]) +#define GRPC_MDELEM_LOCATION_EMPTY (grpc_static_mdelem_manifested()[45]) /* "max-forwards": "" */ -#define GRPC_MDELEM_MAX_FORWARDS_EMPTY (grpc_static_mdelem_manifested[46]) +#define GRPC_MDELEM_MAX_FORWARDS_EMPTY (grpc_static_mdelem_manifested()[46]) /* "proxy-authenticate": "" */ -#define GRPC_MDELEM_PROXY_AUTHENTICATE_EMPTY (grpc_static_mdelem_manifested[47]) +#define GRPC_MDELEM_PROXY_AUTHENTICATE_EMPTY \ + (grpc_static_mdelem_manifested()[47]) /* "proxy-authorization": "" */ #define GRPC_MDELEM_PROXY_AUTHORIZATION_EMPTY \ - (grpc_static_mdelem_manifested[48]) + (grpc_static_mdelem_manifested()[48]) /* "range": "" */ -#define GRPC_MDELEM_RANGE_EMPTY (grpc_static_mdelem_manifested[49]) +#define GRPC_MDELEM_RANGE_EMPTY (grpc_static_mdelem_manifested()[49]) /* "referer": "" */ -#define GRPC_MDELEM_REFERER_EMPTY (grpc_static_mdelem_manifested[50]) +#define GRPC_MDELEM_REFERER_EMPTY (grpc_static_mdelem_manifested()[50]) /* "refresh": "" */ -#define GRPC_MDELEM_REFRESH_EMPTY (grpc_static_mdelem_manifested[51]) +#define GRPC_MDELEM_REFRESH_EMPTY (grpc_static_mdelem_manifested()[51]) /* "retry-after": "" */ -#define GRPC_MDELEM_RETRY_AFTER_EMPTY (grpc_static_mdelem_manifested[52]) +#define GRPC_MDELEM_RETRY_AFTER_EMPTY (grpc_static_mdelem_manifested()[52]) /* "server": "" */ -#define GRPC_MDELEM_SERVER_EMPTY (grpc_static_mdelem_manifested[53]) +#define GRPC_MDELEM_SERVER_EMPTY (grpc_static_mdelem_manifested()[53]) /* "set-cookie": "" */ -#define GRPC_MDELEM_SET_COOKIE_EMPTY (grpc_static_mdelem_manifested[54]) +#define GRPC_MDELEM_SET_COOKIE_EMPTY (grpc_static_mdelem_manifested()[54]) /* "strict-transport-security": "" */ #define GRPC_MDELEM_STRICT_TRANSPORT_SECURITY_EMPTY \ - (grpc_static_mdelem_manifested[55]) + (grpc_static_mdelem_manifested()[55]) /* "transfer-encoding": "" */ -#define GRPC_MDELEM_TRANSFER_ENCODING_EMPTY (grpc_static_mdelem_manifested[56]) +#define GRPC_MDELEM_TRANSFER_ENCODING_EMPTY \ + (grpc_static_mdelem_manifested()[56]) /* "user-agent": "" */ -#define GRPC_MDELEM_USER_AGENT_EMPTY (grpc_static_mdelem_manifested[57]) +#define GRPC_MDELEM_USER_AGENT_EMPTY (grpc_static_mdelem_manifested()[57]) /* "vary": "" */ -#define GRPC_MDELEM_VARY_EMPTY (grpc_static_mdelem_manifested[58]) +#define GRPC_MDELEM_VARY_EMPTY (grpc_static_mdelem_manifested()[58]) /* "via": "" */ -#define GRPC_MDELEM_VIA_EMPTY (grpc_static_mdelem_manifested[59]) +#define GRPC_MDELEM_VIA_EMPTY (grpc_static_mdelem_manifested()[59]) /* "www-authenticate": "" */ -#define GRPC_MDELEM_WWW_AUTHENTICATE_EMPTY (grpc_static_mdelem_manifested[60]) +#define GRPC_MDELEM_WWW_AUTHENTICATE_EMPTY (grpc_static_mdelem_manifested()[60]) /* "grpc-status": "0" */ -#define GRPC_MDELEM_GRPC_STATUS_0 (grpc_static_mdelem_manifested[61]) +#define GRPC_MDELEM_GRPC_STATUS_0 (grpc_static_mdelem_manifested()[61]) /* "grpc-status": "1" */ -#define GRPC_MDELEM_GRPC_STATUS_1 (grpc_static_mdelem_manifested[62]) +#define GRPC_MDELEM_GRPC_STATUS_1 (grpc_static_mdelem_manifested()[62]) /* "grpc-status": "2" */ -#define GRPC_MDELEM_GRPC_STATUS_2 (grpc_static_mdelem_manifested[63]) +#define GRPC_MDELEM_GRPC_STATUS_2 (grpc_static_mdelem_manifested()[63]) /* "grpc-encoding": "identity" */ -#define GRPC_MDELEM_GRPC_ENCODING_IDENTITY (grpc_static_mdelem_manifested[64]) +#define GRPC_MDELEM_GRPC_ENCODING_IDENTITY (grpc_static_mdelem_manifested()[64]) /* "grpc-encoding": "gzip" */ -#define GRPC_MDELEM_GRPC_ENCODING_GZIP (grpc_static_mdelem_manifested[65]) +#define GRPC_MDELEM_GRPC_ENCODING_GZIP (grpc_static_mdelem_manifested()[65]) /* "grpc-encoding": "deflate" */ -#define GRPC_MDELEM_GRPC_ENCODING_DEFLATE (grpc_static_mdelem_manifested[66]) +#define GRPC_MDELEM_GRPC_ENCODING_DEFLATE (grpc_static_mdelem_manifested()[66]) /* "te": "trailers" */ -#define GRPC_MDELEM_TE_TRAILERS (grpc_static_mdelem_manifested[67]) +#define GRPC_MDELEM_TE_TRAILERS (grpc_static_mdelem_manifested()[67]) /* "content-type": "application/grpc" */ #define GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC \ - (grpc_static_mdelem_manifested[68]) + (grpc_static_mdelem_manifested()[68]) /* ":scheme": "grpc" */ -#define GRPC_MDELEM_SCHEME_GRPC (grpc_static_mdelem_manifested[69]) +#define GRPC_MDELEM_SCHEME_GRPC (grpc_static_mdelem_manifested()[69]) /* ":method": "PUT" */ -#define GRPC_MDELEM_METHOD_PUT (grpc_static_mdelem_manifested[70]) +#define GRPC_MDELEM_METHOD_PUT (grpc_static_mdelem_manifested()[70]) /* "accept-encoding": "" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_EMPTY (grpc_static_mdelem_manifested[71]) +#define GRPC_MDELEM_ACCEPT_ENCODING_EMPTY (grpc_static_mdelem_manifested()[71]) /* "content-encoding": "identity" */ #define GRPC_MDELEM_CONTENT_ENCODING_IDENTITY \ - (grpc_static_mdelem_manifested[72]) + (grpc_static_mdelem_manifested()[72]) /* "content-encoding": "gzip" */ -#define GRPC_MDELEM_CONTENT_ENCODING_GZIP (grpc_static_mdelem_manifested[73]) +#define GRPC_MDELEM_CONTENT_ENCODING_GZIP (grpc_static_mdelem_manifested()[73]) /* "lb-cost-bin": "" */ -#define GRPC_MDELEM_LB_COST_BIN_EMPTY (grpc_static_mdelem_manifested[74]) +#define GRPC_MDELEM_LB_COST_BIN_EMPTY (grpc_static_mdelem_manifested()[74]) /* "grpc-accept-encoding": "identity" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY \ - (grpc_static_mdelem_manifested[75]) + (grpc_static_mdelem_manifested()[75]) /* "grpc-accept-encoding": "deflate" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE \ - (grpc_static_mdelem_manifested[76]) + (grpc_static_mdelem_manifested()[76]) /* "grpc-accept-encoding": "identity,deflate" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE \ - (grpc_static_mdelem_manifested[77]) + (grpc_static_mdelem_manifested()[77]) /* "grpc-accept-encoding": "gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_GZIP \ - (grpc_static_mdelem_manifested[78]) + (grpc_static_mdelem_manifested()[78]) /* "grpc-accept-encoding": "identity,gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \ - (grpc_static_mdelem_manifested[79]) + (grpc_static_mdelem_manifested()[79]) /* "grpc-accept-encoding": "deflate,gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE_COMMA_GZIP \ - (grpc_static_mdelem_manifested[80]) + (grpc_static_mdelem_manifested()[80]) /* "grpc-accept-encoding": "identity,deflate,gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \ - (grpc_static_mdelem_manifested[81]) + (grpc_static_mdelem_manifested()[81]) /* "accept-encoding": "identity" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY (grpc_static_mdelem_manifested[82]) +#define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY \ + (grpc_static_mdelem_manifested()[82]) /* "accept-encoding": "gzip" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP (grpc_static_mdelem_manifested[83]) +#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP (grpc_static_mdelem_manifested()[83]) /* "accept-encoding": "identity,gzip" */ #define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \ - (grpc_static_mdelem_manifested[84]) + (grpc_static_mdelem_manifested()[84]) grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b); typedef enum { @@ -539,15 +581,15 @@ typedef union { : GRPC_BATCH_CALLOUTS_COUNT) extern const uint8_t grpc_static_accept_encoding_metadata[8]; -#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) \ - (GRPC_MAKE_MDELEM( \ - &grpc_static_mdelem_table[grpc_static_accept_encoding_metadata[(algs)]] \ - .data(), \ - GRPC_MDELEM_STORAGE_STATIC)) +#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table() \ + [grpc_static_accept_encoding_metadata[(algs)]] \ + .data(), \ + GRPC_MDELEM_STORAGE_STATIC)) extern const uint8_t grpc_static_accept_stream_encoding_metadata[4]; #define GRPC_MDELEM_ACCEPT_STREAM_ENCODING_FOR_ALGORITHMS(algs) \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table() \ [grpc_static_accept_stream_encoding_metadata[(algs)]] \ .data(), \ GRPC_MDELEM_STORAGE_STATIC)) diff --git a/test/core/slice/slice_test.cc b/test/core/slice/slice_test.cc index 4f824cbd5ad..fedda5f493f 100644 --- a/test/core/slice/slice_test.cc +++ b/test/core/slice/slice_test.cc @@ -265,8 +265,8 @@ static void test_static_slice_interning(void) { for (size_t i = 0; i < GRPC_STATIC_MDSTR_COUNT; i++) { GPR_ASSERT(grpc_slice_is_equivalent( - grpc_static_slice_table[i], - grpc_slice_intern(grpc_static_slice_table[i]))); + grpc_static_slice_table()[i], + grpc_slice_intern(grpc_static_slice_table()[i]))); } } @@ -276,9 +276,9 @@ static void test_static_slice_copy_interning(void) { grpc_init(); for (size_t i = 0; i < GRPC_STATIC_MDSTR_COUNT; i++) { - grpc_slice copy = grpc_slice_dup(grpc_static_slice_table[i]); - GPR_ASSERT(grpc_static_slice_table[i].refcount != copy.refcount); - GPR_ASSERT(grpc_static_slice_table[i].refcount == + grpc_slice copy = grpc_slice_dup(grpc_static_slice_table()[i]); + GPR_ASSERT(grpc_static_slice_table()[i].refcount != copy.refcount); + GPR_ASSERT(grpc_static_slice_table()[i].refcount == grpc_slice_intern(copy).refcount); grpc_slice_unref(copy); } diff --git a/test/core/transport/metadata_test.cc b/test/core/transport/metadata_test.cc index e6b73de2de5..0786d78d7f9 100644 --- a/test/core/transport/metadata_test.cc +++ b/test/core/transport/metadata_test.cc @@ -373,7 +373,7 @@ static void test_copied_static_metadata(bool dup_key, bool dup_value) { grpc_core::ExecCtx exec_ctx; for (size_t i = 0; i < GRPC_STATIC_MDELEM_COUNT; i++) { - grpc_mdelem p = GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[i], + grpc_mdelem p = GRPC_MAKE_MDELEM(&grpc_static_mdelem_table()[i], GRPC_MDELEM_STORAGE_STATIC); grpc_mdelem q = grpc_mdelem_from_slices(maybe_dup(GRPC_MDKEY(p), dup_key), diff --git a/test/core/transport/status_metadata_test.cc b/test/core/transport/status_metadata_test.cc index a96f11c1ea3..d5723a4313f 100644 --- a/test/core/transport/status_metadata_test.cc +++ b/test/core/transport/status_metadata_test.cc @@ -57,5 +57,8 @@ TEST(GetStatusCodeFromMetadata, Unparseable) { int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + grpc_init(); + int ret = RUN_ALL_TESTS(); + grpc_shutdown(); + return ret; } diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py index fc1bfe99934..d79759f541c 100755 --- a/tools/codegen/core/gen_static_metadata.py +++ b/tools/codegen/core/gen_static_metadata.py @@ -393,12 +393,24 @@ for i, elem in enumerate(all_strs): str_ofs += len(elem) +def slice_def_for_ctx(i): + return ( + 'grpc_core::StaticMetadataSlice(&refcounts[%d].base, %d, g_bytes+%d)' + ) % (i, len(all_strs[i]), id2strofs[i]) + + def slice_def(i): return ( - 'grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts[%d].base, %d, g_bytes+%d)' + 'grpc_core::StaticMetadataSlice(&grpc_static_metadata_refcounts()[%d].base, %d, g_bytes+%d)' ) % (i, len(all_strs[i]), id2strofs[i]) +def str_idx(s): + for i, s2 in enumerate(all_strs): + if s == s2: + return i + + # validate configuration for elem in METADATA_BATCH_CALLOUTS: assert elem in all_strs @@ -408,36 +420,139 @@ static_slice_dest_assert = ( '"grpc_core::StaticMetadataSlice must be trivially destructible.");') print >> H, static_slice_dest_assert print >> H, '#define GRPC_STATIC_MDSTR_COUNT %d' % len(all_strs) -print >> H, ('extern const grpc_core::StaticMetadataSlice ' - 'grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT];') +print >> H, ''' +void grpc_init_static_metadata_ctx(void); +void grpc_destroy_static_metadata_ctx(void); +namespace grpc_core { +#ifndef NDEBUG +constexpr uint64_t kGrpcStaticMetadataInitCanary = 0xCAFEF00DC0FFEE11L; +uint64_t StaticMetadataInitCanary(); +#endif +extern const StaticMetadataSlice* g_static_metadata_slice_table; +} +inline const grpc_core::StaticMetadataSlice* grpc_static_slice_table() { + GPR_DEBUG_ASSERT(grpc_core::StaticMetadataInitCanary() + == grpc_core::kGrpcStaticMetadataInitCanary); + GPR_DEBUG_ASSERT(grpc_core::g_static_metadata_slice_table != nullptr); + return grpc_core::g_static_metadata_slice_table; +} +''' for i, elem in enumerate(all_strs): print >> H, '/* "%s" */' % elem - print >> H, '#define %s (grpc_static_slice_table[%d])' % ( + print >> H, '#define %s (grpc_static_slice_table()[%d])' % ( mangle(elem).upper(), i) print >> H -print >> C, 'static uint8_t g_bytes[] = {%s};' % (','.join( +print >> C, 'static constexpr uint8_t g_bytes[] = {%s};' % (','.join( '%d' % ord(c) for c in ''.join(all_strs))) print >> C -print >> H, ('namespace grpc_core { struct StaticSliceRefcount; }') -print >> H, ('extern grpc_core::StaticSliceRefcount ' - 'grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT];') +print >> H, ''' +namespace grpc_core { +struct StaticSliceRefcount; +extern StaticSliceRefcount* g_static_metadata_slice_refcounts; +} +inline grpc_core::StaticSliceRefcount* grpc_static_metadata_refcounts() { + GPR_DEBUG_ASSERT(grpc_core::StaticMetadataInitCanary() + == grpc_core::kGrpcStaticMetadataInitCanary); + GPR_DEBUG_ASSERT(grpc_core::g_static_metadata_slice_refcounts != nullptr); + return grpc_core::g_static_metadata_slice_refcounts; +} +''' print >> C, 'grpc_slice_refcount grpc_core::StaticSliceRefcount::kStaticSubRefcount;' -print >> C, ('grpc_core::StaticSliceRefcount ' - 'grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT] = {') +print >> C, ''' +namespace grpc_core { +struct StaticMetadataCtx { +#ifndef NDEBUG + const uint64_t init_canary = kGrpcStaticMetadataInitCanary; +#endif + StaticSliceRefcount + refcounts[GRPC_STATIC_MDSTR_COUNT] = { +''' for i, elem in enumerate(all_strs): - print >> C, ' grpc_core::StaticSliceRefcount(%d), ' % i -print >> C, '};' + print >> C, ' StaticSliceRefcount(%d), ' % i +print >> C, '};' # static slice refcounts +print >> C +print >> C, ''' + const StaticMetadataSlice + slices[GRPC_STATIC_MDSTR_COUNT] = { +''' +for i, elem in enumerate(all_strs): + print >> C, slice_def_for_ctx(i) + ',' +print >> C, '};' # static slices +print >> C, 'StaticMetadata static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = {' +for idx, (a, b) in enumerate(all_elems): + print >> C, 'StaticMetadata(%s,%s, %d),' % (slice_def_for_ctx(str_idx(a)), + slice_def_for_ctx(str_idx(b)), + idx) +print >> C, '};' # static_mdelem_table +print >> C, (''' +/* Warning: the core static metadata currently operates under the soft constraint +that the first GRPC_CHTTP2_LAST_STATIC_ENTRY (61) entries must contain +metadata specified by the http2 hpack standard. The CHTTP2 transport reads the +core metadata with this assumption in mind. If the order of the core static +metadata is to be changed, then the CHTTP2 transport must be changed as well to +stop relying on the core metadata. */ +''') +print >> C, ('grpc_mdelem ' + 'static_mdelem_manifested[GRPC_STATIC_MDELEM_COUNT] = {') +print >> C, '// clang-format off' +static_mds = [] +for i, elem in enumerate(all_elems): + md_name = mangle(elem).upper() + md_human_readable = '"%s": "%s"' % elem + md_spec = ' /* %s: \n %s */\n' % (md_name, md_human_readable) + md_spec += ' GRPC_MAKE_MDELEM(\n' + md_spec += ((' &static_mdelem_table[%d].data(),\n' % i) + + ' GRPC_MDELEM_STORAGE_STATIC)') + static_mds.append(md_spec) +print >> C, ',\n'.join(static_mds) +print >> C, '// clang-format on' +print >> C, ('};') # static_mdelem_manifested +print >> C, '};' # struct StaticMetadataCtx +print >> C, '}' # namespace grpc_core +print >> C, ''' +namespace grpc_core { +static StaticMetadataCtx* g_static_metadata_slice_ctx = nullptr; +const StaticMetadataSlice* g_static_metadata_slice_table = nullptr; +StaticSliceRefcount* g_static_metadata_slice_refcounts = nullptr; +StaticMetadata* g_static_mdelem_table = nullptr; +grpc_mdelem* g_static_mdelem_manifested = nullptr; +#ifndef NDEBUG +uint64_t StaticMetadataInitCanary() { + return g_static_metadata_slice_ctx->init_canary; +} +#endif +} + +void grpc_init_static_metadata_ctx(void) { + grpc_core::g_static_metadata_slice_ctx + = grpc_core::New(); + grpc_core::g_static_metadata_slice_table + = grpc_core::g_static_metadata_slice_ctx->slices; + grpc_core::g_static_metadata_slice_refcounts + = grpc_core::g_static_metadata_slice_ctx->refcounts; + grpc_core::g_static_mdelem_table + = grpc_core::g_static_metadata_slice_ctx->static_mdelem_table; + grpc_core::g_static_mdelem_manifested = + grpc_core::g_static_metadata_slice_ctx->static_mdelem_manifested; +} + +void grpc_destroy_static_metadata_ctx(void) { + grpc_core::Delete( + grpc_core::g_static_metadata_slice_ctx); + grpc_core::g_static_metadata_slice_ctx = nullptr; + grpc_core::g_static_metadata_slice_table = nullptr; + grpc_core::g_static_metadata_slice_refcounts = nullptr; + grpc_core::g_static_mdelem_table = nullptr; + grpc_core::g_static_mdelem_manifested = nullptr; +} + +''' + print >> C print >> H, '#define GRPC_IS_STATIC_METADATA_STRING(slice) \\' print >> H, (' ((slice).refcount != NULL && (slice).refcount->GetType() == ' 'grpc_slice_refcount::Type::STATIC)') print >> H -print >> C, ( - 'const grpc_core::StaticMetadataSlice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT]' - ' = {') -for i, elem in enumerate(all_strs): - print >> C, slice_def(i) + ',' -print >> C, '};' print >> C print >> H, '#define GRPC_STATIC_METADATA_INDEX(static_slice) \\' print >> H, '(reinterpret_cast((static_slice).refcount)->index)' @@ -451,41 +566,32 @@ for i, elem in enumerate(all_elems): [len(elem[1])] + [ord(c) for c in elem[1]])) print >> H, '#define GRPC_STATIC_MDELEM_COUNT %d' % len(all_elems) -print >> H, ('extern grpc_core::StaticMetadata ' - 'grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];') +print >> H, ''' +namespace grpc_core { +extern StaticMetadata* g_static_mdelem_table; +extern grpc_mdelem* g_static_mdelem_manifested; +} +inline grpc_core::StaticMetadata* grpc_static_mdelem_table() { + GPR_DEBUG_ASSERT(grpc_core::StaticMetadataInitCanary() + == grpc_core::kGrpcStaticMetadataInitCanary); + GPR_DEBUG_ASSERT(grpc_core::g_static_mdelem_table != nullptr); + return grpc_core::g_static_mdelem_table; +} +inline grpc_mdelem* grpc_static_mdelem_manifested() { + GPR_DEBUG_ASSERT(grpc_core::StaticMetadataInitCanary() + == grpc_core::kGrpcStaticMetadataInitCanary); + GPR_DEBUG_ASSERT(grpc_core::g_static_mdelem_manifested != nullptr); + return grpc_core::g_static_mdelem_manifested; +} +''' print >> H, ('extern uintptr_t ' 'grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT];') -print >> H, ('extern grpc_mdelem ' - 'grpc_static_mdelem_manifested[GRPC_STATIC_MDELEM_COUNT];') -print >> C, (''' -/* Warning: the core static metadata currently operates under the soft constraint -that the first GRPC_CHTTP2_LAST_STATIC_ENTRY (61) entries must contain -metadata specified by the http2 hpack standard. The CHTTP2 transport reads the -core metadata with this assumption in mind. If the order of the core static -metadata is to be changed, then the CHTTP2 transport must be changed as well to -stop relying on the core metadata. */ -''') -print >> C, ('grpc_mdelem ' - 'grpc_static_mdelem_manifested[GRPC_STATIC_MDELEM_COUNT] = {') -print >> C, '// clang-format off' -static_mds = [] -for i, elem in enumerate(all_elems): - md_name = mangle(elem).upper() - md_human_readable = '"%s": "%s"' % elem - md_spec = ' /* %s: \n %s */\n' % (md_name, md_human_readable) - md_spec += ' GRPC_MAKE_MDELEM(\n' - md_spec += ((' &grpc_static_mdelem_table[%d].data(),\n' % i) + - ' GRPC_MDELEM_STORAGE_STATIC)') - static_mds.append(md_spec) -print >> C, ',\n'.join(static_mds) -print >> C, '// clang-format on' -print >> C, ('};') for i, elem in enumerate(all_elems): md_name = mangle(elem).upper() print >> H, '/* "%s": "%s" */' % elem - print >> H, ('#define %s (grpc_static_mdelem_manifested[%d])' % (md_name, - i)) + print >> H, ('#define %s (grpc_static_mdelem_manifested()[%d])' % (md_name, + i)) print >> H print >> C, ('uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] ' @@ -496,12 +602,6 @@ print >> C, '};' print >> C -def str_idx(s): - for i, s2 in enumerate(all_strs): - if s == s2: - return i - - def md_idx(m): for i, m2 in enumerate(all_elems): if m == m2: @@ -575,16 +675,10 @@ print >> C, 'grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intpt print >> C, ' if (a == -1 || b == -1) return GRPC_MDNULL;' print >> C, ' uint32_t k = static_cast(a * %d + b);' % len(all_strs) print >> C, ' uint32_t h = elems_phash(k);' -print >> C, ' return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k && elem_idxs[h] != 255 ? GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[elem_idxs[h]].data(), GRPC_MDELEM_STORAGE_STATIC) : GRPC_MDNULL;' +print >> C, ' return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k && elem_idxs[h] != 255 ? GRPC_MAKE_MDELEM(&grpc_static_mdelem_table()[elem_idxs[h]].data(), GRPC_MDELEM_STORAGE_STATIC) : GRPC_MDNULL;' print >> C, '}' print >> C -print >> C, 'grpc_core::StaticMetadata grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = {' -for idx, (a, b) in enumerate(all_elems): - print >> C, 'grpc_core::StaticMetadata(%s,%s, %d),' % ( - slice_def(str_idx(a)), slice_def(str_idx(b)), idx) -print >> C, '};' - print >> H, 'typedef enum {' for elem in METADATA_BATCH_CALLOUTS: print >> H, ' %s,' % mangle(elem, 'batch').upper() @@ -629,7 +723,7 @@ print >> C, '0,%s' % ','.join('%d' % md_idx(elem) for elem in compression_elems) print >> C, '};' print >> C -print >> H, '#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[grpc_static_accept_encoding_metadata[(algs)]].data(), GRPC_MDELEM_STORAGE_STATIC))' +print >> H, '#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table()[grpc_static_accept_encoding_metadata[(algs)]].data(), GRPC_MDELEM_STORAGE_STATIC))' print >> H print >> H, 'extern const uint8_t grpc_static_accept_stream_encoding_metadata[%d];' % ( @@ -640,7 +734,7 @@ print >> C, '0,%s' % ','.join( '%d' % md_idx(elem) for elem in stream_compression_elems) print >> C, '};' -print >> H, '#define GRPC_MDELEM_ACCEPT_STREAM_ENCODING_FOR_ALGORITHMS(algs) (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[grpc_static_accept_stream_encoding_metadata[(algs)]].data(), GRPC_MDELEM_STORAGE_STATIC))' +print >> H, '#define GRPC_MDELEM_ACCEPT_STREAM_ENCODING_FOR_ALGORITHMS(algs) (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table()[grpc_static_accept_stream_encoding_metadata[(algs)]].data(), GRPC_MDELEM_STORAGE_STATIC))' print >> H, '#endif /* GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H */' From 426450cd82b9cc0edc7983049791904e327d49e8 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Fri, 2 Aug 2019 11:04:28 -0700 Subject: [PATCH 1371/1555] Implement dual testing --- BUILD | 2 +- bazel/grpc_python_deps.bzl | 9 ++ bazel/python_rules.bzl | 26 ++++++ .../grpcio_tests/tests/unit/BUILD.bazel | 4 +- third_party/py/BUILD.tpl | 49 +++++----- third_party/py/python_configure.bzl | 92 +++++++++++-------- third_party/py/remote.BUILD.tpl | 10 -- third_party/py/variety.tpl | 26 ++++++ tools/bazel.rc | 4 - 9 files changed, 142 insertions(+), 80 deletions(-) delete mode 100644 third_party/py/remote.BUILD.tpl create mode 100644 third_party/py/variety.tpl diff --git a/BUILD b/BUILD index f2a6f67f69f..74e1849629d 100644 --- a/BUILD +++ b/BUILD @@ -65,7 +65,7 @@ config_setting( config_setting( name = "python3", - values = {"python_path": "python3"}, + flag_values = {"@bazel_tools//tools/python:python_version": "PY3"}, ) config_setting( diff --git a/bazel/grpc_python_deps.bzl b/bazel/grpc_python_deps.bzl index 4e7cc1537fa..2a439bdf226 100644 --- a/bazel/grpc_python_deps.bzl +++ b/bazel/grpc_python_deps.bzl @@ -47,6 +47,15 @@ def grpc_python_deps(): remote = "https://github.com/bazelbuild/rules_python.git", ) + + if "rules_python" not in native.existing_rules(): + http_archive( + name = "rules_python", + url = "https://github.com/bazelbuild/rules_python/archive/9d68f24659e8ce8b736590ba1e4418af06ec2552.zip", + sha256 = "f7402f11691d657161f871e11968a984e5b48b023321935f5a55d7e56cf4758a", + strip_prefix = "rules_python-9d68f24659e8ce8b736590ba1e4418af06ec2552", + ) + python_configure(name = "local_config_python") native.bind( diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index 12f51f8b172..e7e9e597b05 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -178,3 +178,29 @@ def py_grpc_library( deps = [Label("//src/python/grpcio/grpc:grpcio")] + deps, **kwargs ) + + +def py2and3_test(name, + py_test = native.py_test, + **kwargs): + if "python_version" in kwargs: + fail("Cannot specify 'python_version' in py2and3_test.") + + names = [name + suffix for suffix in (".python2", ".python3")] + python_versions = ["PY2", "PY3"] + for case_name, python_version in zip(names, python_versions): + py_test( + name = case_name, + python_version = python_version, + **kwargs + ) + + suite_kwargs = {} + if "visibility" in kwargs: + suite_kwargs["visibility"] = kwargs["visibility"] + + native.test_suite( + name = name, + tests = names, + **suite_kwargs + ) diff --git a/src/python/grpcio_tests/tests/unit/BUILD.bazel b/src/python/grpcio_tests/tests/unit/BUILD.bazel index 49203b7fa16..587d8cb246f 100644 --- a/src/python/grpcio_tests/tests/unit/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/BUILD.bazel @@ -1,3 +1,5 @@ +load("//bazel:python_rules.bzl", "py2and3_test") + package(default_visibility = ["//visibility:public"]) GRPCIO_TESTS_UNIT = [ @@ -80,7 +82,7 @@ py_library( ) [ - py_test( + py2and3_test( name=test_file_name[:-3], size="small", srcs=[test_file_name], diff --git a/third_party/py/BUILD.tpl b/third_party/py/BUILD.tpl index 2283c573bc3..8f010f85a03 100644 --- a/third_party/py/BUILD.tpl +++ b/third_party/py/BUILD.tpl @@ -2,35 +2,36 @@ package(default_visibility=["//visibility:public"]) -# To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib -# See https://docs.python.org/3/extending/windows.html -cc_import( - name="python_lib", - interface_library=select({ - ":windows": ":python_import_lib", - # A placeholder for Unix platforms which makes --no_build happy. - "//conditions:default": "not-existing.lib", - }), - system_provided=1, -) - -cc_library( - name="python_headers", - hdrs=[":python_include"], - deps=select({ - ":windows": [":python_lib"], - "//conditions:default": [], - }), - includes=["python_include"], -) - config_setting( name="windows", values={"cpu": "x64_windows"}, visibility=["//visibility:public"], ) -%{PYTHON_INCLUDE_GENRULE} -%{PYTHON_IMPORT_LIB_GENRULE} +config_setting( + name="python2", + flag_values = {"@rules_python//python:python_version": "PY2"} +) +config_setting( + name="python3", + flag_values = {"@rules_python//python:python_version": "PY3"} +) +cc_library( + name = "python_lib", + deps = select({ + ":python2": ["//_python2:_python2_lib"], + ":python3": ["//_python3:_python3_lib"], + "//conditions:default": ["not-existing.lib"], + }) +) + +cc_library( + name = "python_headers", + deps = select({ + ":python2": ["//_python2:_python2_headers"], + ":python3": ["//_python3:_python3_headers"], + "//conditions:default": ["not-existing.headers"], + }) +) diff --git a/third_party/py/python_configure.bzl b/third_party/py/python_configure.bzl index e6fa5ed10e9..a2f0c7918d2 100644 --- a/third_party/py/python_configure.bzl +++ b/third_party/py/python_configure.bzl @@ -3,14 +3,15 @@ `python_configure` depends on the following environment variables: - * `PYTHON_BIN_PATH`: location of python binary. - * `PYTHON_LIB_PATH`: Location of python libraries. + * `PYTHON2_BIN_PATH`: location of python binary. + * `PYTHON2_LIB_PATH`: Location of python libraries. """ _BAZEL_SH = "BAZEL_SH" -_PYTHON_BIN_PATH = "PYTHON_BIN_PATH" -_PYTHON_LIB_PATH = "PYTHON_LIB_PATH" -_PYTHON_CONFIG_REPO = "PYTHON_CONFIG_REPO" +_PYTHON2_BIN_PATH = "PYTHON2_BIN_PATH" +_PYTHON2_LIB_PATH = "PYTHON2_LIB_PATH" +_PYTHON3_BIN_PATH = "PYTHON3_BIN_PATH" +_PYTHON3_LIB_PATH = "PYTHON3_LIB_PATH" def _tpl(repository_ctx, tpl, substitutions={}, out=None): @@ -136,9 +137,9 @@ def _symlink_genrule_for_dir(repository_ctx, "\n".join(outs)) -def _get_python_bin(repository_ctx): +def _get_python_bin(repository_ctx, bin_path_key, default_bin_path): """Gets the python bin path.""" - python_bin = repository_ctx.os.environ.get(_PYTHON_BIN_PATH, 'python') + python_bin = repository_ctx.os.environ.get(bin_path_key, default_bin_path) if not repository_ctx.path(python_bin).exists: # It's a command, use 'which' to find its path. python_bin_path = repository_ctx.which(python_bin) @@ -150,7 +151,7 @@ def _get_python_bin(repository_ctx): _fail("Cannot find python in PATH, please make sure " + "python is installed and add its directory in PATH, or --define " + "%s='/something/else'.\nPATH=%s" % - (_PYTHON_BIN_PATH, repository_ctx.os.environ.get("PATH", ""))) + (bin_path_key, repository_ctx.os.environ.get("PATH", ""))) def _get_bash_bin(repository_ctx): @@ -170,9 +171,9 @@ def _get_bash_bin(repository_ctx): (_BAZEL_SH, repository_ctx.os.environ.get("PATH", ""))) -def _get_python_lib(repository_ctx, python_bin): +def _get_python_lib(repository_ctx, python_bin, lib_path_key): """Gets the python lib path.""" - python_lib = repository_ctx.os.environ.get(_PYTHON_LIB_PATH) + python_lib = repository_ctx.os.environ.get(lib_path_key) if python_lib != None: return python_lib print_lib = ( @@ -202,13 +203,13 @@ def _check_python_lib(repository_ctx, python_lib): _fail("Invalid python library path: %s" % python_lib) -def _check_python_bin(repository_ctx, python_bin): +def _check_python_bin(repository_ctx, python_bin, bin_path_key): """Checks the python bin path.""" cmd = '[[ -x "%s" ]] && [[ ! -d "%s" ]]' % (python_bin, python_bin) result = repository_ctx.execute([_get_bash_bin(repository_ctx), "-c", cmd]) if result.return_code == 1: _fail("--define %s='%s' is not executable. Is it the python binary?" % - (_PYTHON_BIN_PATH, python_bin)) + (bin_path_key, python_bin)) def _get_python_include(repository_ctx, python_bin): @@ -222,11 +223,11 @@ def _get_python_include(repository_ctx, python_bin): error_msg="Problem getting python include path.", error_details=( "Is the Python binary path set up right? " + "(See ./configure or " - + _PYTHON_BIN_PATH + ".) " + "Is distutils installed?")) + + _PYTHON2_BIN_PATH + ".) " + "Is distutils installed?")) return result.stdout.splitlines()[0] -def _get_python_import_lib_name(repository_ctx, python_bin): +def _get_python_import_lib_name(repository_ctx, python_bin, bin_path_key): """Get Python import library name (pythonXY.lib) on Windows.""" result = _execute( repository_ctx, [ @@ -236,66 +237,77 @@ def _get_python_import_lib_name(repository_ctx, python_bin): ], error_msg="Problem getting python import library.", error_details=("Is the Python binary path set up right? " + - "(See ./configure or " + _PYTHON_BIN_PATH + ".) ")) + "(See ./configure or " + bin_path_key + ".) ")) return result.stdout.splitlines()[0] -def _create_local_python_repository(repository_ctx): +# TODO(rbellevi): Rename. +def _create_local_python_repository(repository_ctx, + variety_name, + bin_path_key, + default_bin_path, + lib_path_key): """Creates the repository containing files set up to build with Python.""" - python_bin = _get_python_bin(repository_ctx) - _check_python_bin(repository_ctx, python_bin) - python_lib = _get_python_lib(repository_ctx, python_bin) + python_bin = _get_python_bin(repository_ctx, bin_path_key, default_bin_path) + _check_python_bin(repository_ctx, python_bin, bin_path_key) + python_lib = _get_python_lib(repository_ctx, python_bin, lib_path_key) _check_python_lib(repository_ctx, python_lib) python_include = _get_python_include(repository_ctx, python_bin) python_include_rule = _symlink_genrule_for_dir( - repository_ctx, python_include, 'python_include', 'python_include') + repository_ctx, python_include, '{}_include'.format(variety_name), + '{}_include'.format(variety_name)) python_import_lib_genrule = "" # To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib # See https://docs.python.org/3/extending/windows.html if _is_windows(repository_ctx): python_include = _normalize_path(python_include) - python_import_lib_name = _get_python_import_lib_name( + python_import_lib_name = _get_python_import_lib_name, bin_path_key( repository_ctx, python_bin) python_import_lib_src = python_include.rsplit( '/', 1)[0] + "/libs/" + python_import_lib_name python_import_lib_genrule = _symlink_genrule_for_dir( - repository_ctx, None, '', 'python_import_lib', + repository_ctx, None, '', '{}_import_lib'.format(variety_name), [python_import_lib_src], [python_import_lib_name]) _tpl( - repository_ctx, "BUILD", { + repository_ctx, "variety", { "%{PYTHON_INCLUDE_GENRULE}": python_include_rule, "%{PYTHON_IMPORT_LIB_GENRULE}": python_import_lib_genrule, - }) - - -def _create_remote_python_repository(repository_ctx, remote_config_repo): - """Creates pointers to a remotely configured repo set up to build with Python. - """ - _tpl(repository_ctx, "remote.BUILD", { - "%{REMOTE_PYTHON_REPO}": remote_config_repo, - }, "BUILD") + "%{VARIETY_NAME}": variety_name, + }, + out="{}/BUILD".format(variety_name)) +# TODO(rbellevi): Remove def _python_autoconf_impl(repository_ctx): """Implementation of the python_autoconf repository rule.""" - if _PYTHON_CONFIG_REPO in repository_ctx.os.environ: - _create_remote_python_repository( - repository_ctx, repository_ctx.os.environ[_PYTHON_CONFIG_REPO]) - else: - _create_local_python_repository(repository_ctx) + _create_local_python_repository(repository_ctx, + "_python2", + _PYTHON2_BIN_PATH, + "python", + _PYTHON2_LIB_PATH) + _create_local_python_repository(repository_ctx, + "_python3", + _PYTHON3_BIN_PATH, + "python3", + _PYTHON3_LIB_PATH) + _tpl(repository_ctx, "BUILD") python_configure = repository_rule( implementation=_python_autoconf_impl, environ=[ _BAZEL_SH, - _PYTHON_BIN_PATH, - _PYTHON_LIB_PATH, - _PYTHON_CONFIG_REPO, + _PYTHON2_BIN_PATH, + _PYTHON2_LIB_PATH, + _PYTHON3_BIN_PATH, + _PYTHON3_LIB_PATH, ], ) """Detects and configures the local Python. +It is expected that the system have both a working Python 2 and python 3 +installation + Add the following to your WORKSPACE FILE: ```python diff --git a/third_party/py/remote.BUILD.tpl b/third_party/py/remote.BUILD.tpl deleted file mode 100644 index 1bfe1f0bf65..00000000000 --- a/third_party/py/remote.BUILD.tpl +++ /dev/null @@ -1,10 +0,0 @@ -# Adapted with modifications from tensorflow/third_party/py/ - -package(default_visibility=["//visibility:public"]) - -alias( - name="python_headers", - actual="%{REMOTE_PYTHON_REPO}:python_headers", -) - - diff --git a/third_party/py/variety.tpl b/third_party/py/variety.tpl new file mode 100644 index 00000000000..0c466d6d8f0 --- /dev/null +++ b/third_party/py/variety.tpl @@ -0,0 +1,26 @@ +package(default_visibility=["//visibility:public"]) + +# To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib +# See https://docs.python.org/3/extending/windows.html +cc_import( + name="%{VARIETY_NAME}_lib", + interface_library=select({ + "//:windows": ":%{VARIETY_NAME}_import_lib", + # A placeholder for Unix platforms which makes --no_build happy. + "//conditions:default": "not-existing.lib", + }), + system_provided=1, +) + +cc_library( + name="%{VARIETY_NAME}_headers", + hdrs=[":%{VARIETY_NAME}_include"], + deps=select({ + "//:windows": [":%{VARIETY_NAME}_lib"], + "//conditions:default": [], + }), + includes=["%{VARIETY_NAME}_include"], +) + +%{PYTHON_INCLUDE_GENRULE} +%{PYTHON_IMPORT_LIB_GENRULE} diff --git a/tools/bazel.rc b/tools/bazel.rc index b24f603ddda..fcbe9337b9f 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -82,7 +82,3 @@ build:basicprof --copt=-DNDEBUG build:basicprof --copt=-O2 build:basicprof --copt=-DGRPC_BASIC_PROFILER build:basicprof --copt=-DGRPC_TIMERS_RDTSC - -build:python3 --python_path=python3 -build:python3 --python_version=PY3 -build:python3 --action_env=PYTHON_BIN_PATH=python3 From b7667478cf18cfbfb907f71b31aa12e8c7f97371 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 25 Jun 2019 10:13:21 -0400 Subject: [PATCH 1372/1555] bump bazel version to 0.27 --- bazel/grpc_deps.bzl | 8 ++++---- templates/tools/dockerfile/bazel.include | 2 +- tools/bazel | 2 +- tools/dockerfile/test/bazel/Dockerfile | 2 +- tools/dockerfile/test/sanity/Dockerfile | 2 +- tools/remote_build/kokoro.bazelrc | 7 +++---- tools/remote_build/manual.bazelrc | 7 +++---- tools/remote_build/rbe_common.bazelrc | 2 +- 8 files changed, 15 insertions(+), 17 deletions(-) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 06323ff3f24..57021924725 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -176,11 +176,11 @@ def grpc_deps(): if "bazel_toolchains" not in native.existing_rules(): http_archive( name = "bazel_toolchains", - sha256 = "d968b414b32aa99c86977e1171645d31da2b52ac88060de3ac1e49932d5dcbf1", - strip_prefix = "bazel-toolchains-4bd5df80d77aa7f4fb943dfdfad5c9056a62fb47", + sha256 = "872955b658113924eb1a3594b04d43238da47f4f90c17b76e8785709490dc041", + strip_prefix = "bazel-toolchains-1083686fde6032378d52b4c98044922cebde364e", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/4bd5df80d77aa7f4fb943dfdfad5c9056a62fb47.tar.gz", - "https://github.com/bazelbuild/bazel-toolchains/archive/4bd5df80d77aa7f4fb943dfdfad5c9056a62fb47.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/1083686fde6032378d52b4c98044922cebde364e.tar.gz", + "https://github.com/bazelbuild/bazel-toolchains/archive/1083686fde6032378d52b4c98044922cebde364e.tar.gz", ], ) diff --git a/templates/tools/dockerfile/bazel.include b/templates/tools/dockerfile/bazel.include index adde6ed4787..12a22785623 100644 --- a/templates/tools/dockerfile/bazel.include +++ b/templates/tools/dockerfile/bazel.include @@ -2,7 +2,7 @@ # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.26.0 +ENV BAZEL_VERSION 0.28.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/bazel b/tools/bazel index 4f08d18c656..4d1d57f60d9 100755 --- a/tools/bazel +++ b/tools/bazel @@ -32,7 +32,7 @@ then exec -a "$0" "${BAZEL_REAL}" "$@" fi -VERSION=0.26.0 +VERSION=0.28.1 echo "INFO: Running bazel wrapper (see //tools/bazel for details), bazel version $VERSION will be used instead of system-wide bazel installation." diff --git a/tools/dockerfile/test/bazel/Dockerfile b/tools/dockerfile/test/bazel/Dockerfile index 7e7903359e7..7141fb9c5f1 100644 --- a/tools/dockerfile/test/bazel/Dockerfile +++ b/tools/dockerfile/test/bazel/Dockerfile @@ -52,7 +52,7 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.2.post1 six==1.10.0 t # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.26.0 +ENV BAZEL_VERSION 0.28.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index ca786e264ed..e9c1b4bee12 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -98,7 +98,7 @@ ENV CLANG_TIDY=clang-tidy # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.26.0 +ENV BAZEL_VERSION 0.28.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/remote_build/kokoro.bazelrc b/tools/remote_build/kokoro.bazelrc index 064e94b2e15..5c1b061bce3 100644 --- a/tools/remote_build/kokoro.bazelrc +++ b/tools/remote_build/kokoro.bazelrc @@ -16,13 +16,12 @@ import %workspace%/tools/remote_build/rbe_common.bazelrc -build --remote_cache=remotebuildexecution.googleapis.com -build --remote_executor=remotebuildexecution.googleapis.com -build --tls_enabled=true +build --remote_cache=grpcs://remotebuildexecution.googleapis.com +build --remote_executor=grpcs://remotebuildexecution.googleapis.com build --auth_enabled=true -build --bes_backend=buildeventservice.googleapis.com +build --bes_backend=grpcs://buildeventservice.googleapis.com build --bes_timeout=600s build --project_id=grpc-testing diff --git a/tools/remote_build/manual.bazelrc b/tools/remote_build/manual.bazelrc index fcd41f57521..c3c6af42877 100644 --- a/tools/remote_build/manual.bazelrc +++ b/tools/remote_build/manual.bazelrc @@ -17,9 +17,8 @@ import %workspace%/tools/remote_build/rbe_common.bazelrc -build --remote_cache=remotebuildexecution.googleapis.com -build --remote_executor=remotebuildexecution.googleapis.com -build --tls_enabled=true +build --remote_cache=grpcs://remotebuildexecution.googleapis.com +build --remote_executor=grpcs://remotebuildexecution.googleapis.com # Enable authentication. This will pick up application default credentials by # default. You can use --auth_credentials=some_file.json to use a service @@ -30,7 +29,7 @@ build --auth_enabled=true # Set flags for uploading to BES in order to view results in the Bazel Build # Results UI. -build --bes_backend="buildeventservice.googleapis.com" +build --bes_backend=grpcs://buildeventservice.googleapis.com build --bes_timeout=60s build --bes_results_url="https://source.cloud.google.com/results/invocations/" build --project_id=grpc-testing diff --git a/tools/remote_build/rbe_common.bazelrc b/tools/remote_build/rbe_common.bazelrc index 6baaf24732c..6236003fe17 100644 --- a/tools/remote_build/rbe_common.bazelrc +++ b/tools/remote_build/rbe_common.bazelrc @@ -87,4 +87,4 @@ build:ubsan --test_timeout=3600 # how to update the bazel toolchain for ubsan: # - check for the latest released version in https://github.com/bazelbuild/bazel-toolchains/tree/master/configs/experimental/ubuntu16_04_clang # - you might need to update the bazel_toolchains dependency in grpc_deps.bzl -build:ubsan --crosstool_top=@bazel_toolchains//configs/experimental/ubuntu16_04_clang/1.2/bazel_0.23.0/ubsan:toolchain +build:ubsan --crosstool_top=@bazel_toolchains//configs/experimental/ubuntu16_04_clang/1.2/bazel_0.28.0/ubsan:toolchain From 27990a5541db08d8cf63c433119b9744d8007b80 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 27 Aug 2019 17:47:52 -0700 Subject: [PATCH 1373/1555] Explicitly add python versions to examples. --- examples/python/auth/BUILD.bazel | 3 +++ examples/python/cancellation/BUILD.bazel | 3 +++ examples/python/compression/BUILD.bazel | 3 +++ examples/python/debug/BUILD.bazel | 3 +++ examples/python/errors/BUILD.bazel | 1 + examples/python/multiprocessing/BUILD | 3 +++ examples/python/wait_for_ready/BUILD.bazel | 1 + 7 files changed, 17 insertions(+) diff --git a/examples/python/auth/BUILD.bazel b/examples/python/auth/BUILD.bazel index cc454fdfdfe..72620ee46c5 100644 --- a/examples/python/auth/BUILD.bazel +++ b/examples/python/auth/BUILD.bazel @@ -39,6 +39,7 @@ py_binary( "//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2_grpc", ], + python_version = "PY3", ) py_binary( @@ -51,6 +52,7 @@ py_binary( "//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2_grpc", ], + python_version = "PY3", ) py_test( @@ -63,4 +65,5 @@ py_test( ":customized_auth_server", ":_credentials", ], + python_version = "PY3", ) diff --git a/examples/python/cancellation/BUILD.bazel b/examples/python/cancellation/BUILD.bazel index 17b1b20168e..b4451f60711 100644 --- a/examples/python/cancellation/BUILD.bazel +++ b/examples/python/cancellation/BUILD.bazel @@ -45,6 +45,7 @@ py_binary( "//external:six" ], srcs_version = "PY2AND3", + python_version = "PY3", ) py_library( @@ -68,6 +69,7 @@ py_binary( "//:python3": [], }), srcs_version = "PY2AND3", + python_version = "PY3", ) py_test( @@ -78,4 +80,5 @@ py_test( ":server" ], size = "small", + python_version = "PY3", ) diff --git a/examples/python/compression/BUILD.bazel b/examples/python/compression/BUILD.bazel index 9d5f6bb83ed..4141eda2ffd 100644 --- a/examples/python/compression/BUILD.bazel +++ b/examples/python/compression/BUILD.bazel @@ -21,6 +21,7 @@ py_binary( "//examples:helloworld_py_pb2_grpc", ], srcs_version = "PY2AND3", + python_version = "PY3", ) py_binary( @@ -32,6 +33,7 @@ py_binary( "//examples:helloworld_py_pb2_grpc", ], srcs_version = "PY2AND3", + python_version = "PY3", ) py_test( @@ -43,4 +45,5 @@ py_test( ":server", ], size = "small", + python_version = "PY3", ) diff --git a/examples/python/debug/BUILD.bazel b/examples/python/debug/BUILD.bazel index 657ae860ae3..332991332f8 100644 --- a/examples/python/debug/BUILD.bazel +++ b/examples/python/debug/BUILD.bazel @@ -35,6 +35,7 @@ py_binary( "//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2_grpc", ], + python_version = "PY3", ) py_binary( @@ -45,6 +46,7 @@ py_binary( "//src/python/grpcio/grpc:grpcio", "//src/python/grpcio_channelz/grpc_channelz/v1:grpc_channelz", ], + python_version = "PY3", ) py_test( @@ -59,4 +61,5 @@ py_test( ":send_message", ":get_stats", ], + python_version = "PY3", ) diff --git a/examples/python/errors/BUILD.bazel b/examples/python/errors/BUILD.bazel index 4b779ddfcf1..367bd81925f 100644 --- a/examples/python/errors/BUILD.bazel +++ b/examples/python/errors/BUILD.bazel @@ -55,4 +55,5 @@ py_test( "../../../src/python/grpcio_status", "../../../src/python/grpcio_tests", ], + python_version = "PY3", ) diff --git a/examples/python/multiprocessing/BUILD b/examples/python/multiprocessing/BUILD index 490aea0c1e6..2503970bc80 100644 --- a/examples/python/multiprocessing/BUILD +++ b/examples/python/multiprocessing/BUILD @@ -42,6 +42,7 @@ py_binary( ":prime_proto_pb2_grpc", ], srcs_version = "PY3", + python_version = "PY3", ) py_binary( @@ -57,6 +58,7 @@ py_binary( "//:python3": [], }), srcs_version = "PY3", + python_version = "PY3", ) py_test( @@ -67,4 +69,5 @@ py_test( ":server" ], size = "small", + python_version = "PY3", ) diff --git a/examples/python/wait_for_ready/BUILD.bazel b/examples/python/wait_for_ready/BUILD.bazel index f074ae7bb7f..9cbddd1a6e3 100644 --- a/examples/python/wait_for_ready/BUILD.bazel +++ b/examples/python/wait_for_ready/BUILD.bazel @@ -30,4 +30,5 @@ py_test( srcs = ["test/_wait_for_ready_example_test.py"], deps = [":wait_for_ready_example",], size = "small", + python_version = "PY3", ) From 1b69538d58f037732a4a359b878b8ae8e8d296f1 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 27 Aug 2019 17:51:45 -0700 Subject: [PATCH 1374/1555] Switch all tests to py2and3_test --- src/python/grpcio_tests/tests/channelz/BUILD.bazel | 4 +++- src/python/grpcio_tests/tests/health_check/BUILD.bazel | 3 ++- src/python/grpcio_tests/tests/interop/BUILD.bazel | 5 +++-- src/python/grpcio_tests/tests/reflection/BUILD.bazel | 3 ++- src/python/grpcio_tests/tests/status/BUILD.bazel | 3 ++- src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel | 3 ++- .../grpcio_tests/tests/unit/framework/foundation/BUILD.bazel | 3 ++- 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/python/grpcio_tests/tests/channelz/BUILD.bazel b/src/python/grpcio_tests/tests/channelz/BUILD.bazel index 63513616e77..f4d246847f7 100644 --- a/src/python/grpcio_tests/tests/channelz/BUILD.bazel +++ b/src/python/grpcio_tests/tests/channelz/BUILD.bazel @@ -1,6 +1,8 @@ package(default_visibility = ["//visibility:public"]) -py_test( +load("//bazel:python_rules.bzl", "py2and3_test") + +py2and3_test( name = "channelz_servicer_test", srcs = ["_channelz_servicer_test.py"], main = "_channelz_servicer_test.py", diff --git a/src/python/grpcio_tests/tests/health_check/BUILD.bazel b/src/python/grpcio_tests/tests/health_check/BUILD.bazel index 49f076be9a1..797b6a48e91 100644 --- a/src/python/grpcio_tests/tests/health_check/BUILD.bazel +++ b/src/python/grpcio_tests/tests/health_check/BUILD.bazel @@ -1,6 +1,7 @@ package(default_visibility = ["//visibility:public"]) +load("//bazel:python_rules.bzl", "py2and3_test") -py_test( +py2and3_test( name = "health_servicer_test", srcs = ["_health_servicer_test.py"], main = "_health_servicer_test.py", diff --git a/src/python/grpcio_tests/tests/interop/BUILD.bazel b/src/python/grpcio_tests/tests/interop/BUILD.bazel index 8ac3f7d52d5..4685852162b 100644 --- a/src/python/grpcio_tests/tests/interop/BUILD.bazel +++ b/src/python/grpcio_tests/tests/interop/BUILD.bazel @@ -1,4 +1,5 @@ load("@grpc_python_dependencies//:requirements.bzl", "requirement") +load("//bazel:python_rules.bzl", "py2and3_test") package(default_visibility = ["//visibility:public"]) @@ -80,7 +81,7 @@ py_library( ], ) -py_test( +py2and3_test( name = "_insecure_intraop_test", size = "small", srcs = ["_insecure_intraop_test.py"], @@ -99,7 +100,7 @@ py_test( ], ) -py_test( +py2and3_test( name = "_secure_intraop_test", size = "small", srcs = ["_secure_intraop_test.py"], diff --git a/src/python/grpcio_tests/tests/reflection/BUILD.bazel b/src/python/grpcio_tests/tests/reflection/BUILD.bazel index e9b56191df8..65a08c2a435 100644 --- a/src/python/grpcio_tests/tests/reflection/BUILD.bazel +++ b/src/python/grpcio_tests/tests/reflection/BUILD.bazel @@ -1,8 +1,9 @@ load("@grpc_python_dependencies//:requirements.bzl", "requirement") +load("//bazel:python_rules.bzl", "py2and3_test") package(default_visibility = ["//visibility:public"]) -py_test( +py2and3_test( name="_reflection_servicer_test", size="small", timeout="moderate", diff --git a/src/python/grpcio_tests/tests/status/BUILD.bazel b/src/python/grpcio_tests/tests/status/BUILD.bazel index b163fe3975e..0868de01acf 100644 --- a/src/python/grpcio_tests/tests/status/BUILD.bazel +++ b/src/python/grpcio_tests/tests/status/BUILD.bazel @@ -1,8 +1,9 @@ load("@grpc_python_dependencies//:requirements.bzl", "requirement") +load("//bazel:python_rules.bzl", "py2and3_test") package(default_visibility = ["//visibility:public"]) -py_test( +py2and3_test( name = "grpc_status_test", srcs = ["_grpc_status_test.py"], main = "_grpc_status_test.py", diff --git a/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel b/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel index 458a6b1fb8a..867649a6a50 100644 --- a/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel @@ -1,4 +1,5 @@ load("@grpc_python_dependencies//:requirements.bzl", "requirement") +load("//bazel:python_rules.bzl", "py2and3_test") package(default_visibility = ["//visibility:public"]) @@ -23,7 +24,7 @@ py_library( ) [ - py_test( + py2and3_test( name=test_file_name[:-3], size="small", srcs=[test_file_name], diff --git a/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel b/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel index d69186e1fde..a93249301c4 100644 --- a/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel @@ -1,11 +1,12 @@ package(default_visibility = ["//visibility:public"]) +load("//bazel:python_rules.bzl", "py2and3_test") py_library( name = "stream_testing", srcs = ["stream_testing.py"], ) -py_test( +py2and3_test( name = "logging_pool_test", srcs = ["_logging_pool_test.py"], main = "_logging_pool_test.py", From 6dfa96524df73c5dd00ad2bf1aef1279aeb8944d Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 27 Aug 2019 17:59:39 -0700 Subject: [PATCH 1375/1555] Fix failing CPP test --- bazel/grpc_build_system.bzl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 23f90d0dc80..54398b66d82 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -262,13 +262,22 @@ def grpc_sh_binary(name, srcs, data = []): data = data, ) -def grpc_py_binary(name, srcs, data = [], deps = [], external_deps = [], testonly = False): +def grpc_py_binary(name, + srcs, + data = [], + deps = [], + external_deps = [], + testonly = False, + python_version = "PY2", + **kwargs): native.py_binary( name = name, srcs = srcs, testonly = testonly, data = data, deps = deps + _get_external_deps(external_deps), + python_version = python_version, + **kwargs, ) def grpc_package(name, visibility = "private", features = []): From 544ead769ddb7f2a579719953e310d088c92a376 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 27 Aug 2019 18:02:02 -0700 Subject: [PATCH 1376/1555] Remove explicit Python 3 testing --- tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh b/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh index f725eb7a3d7..4a48760aab1 100755 --- a/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh +++ b/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh @@ -26,9 +26,6 @@ ${name}') cd /var/local/git/grpc/test bazel test --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //src/python/... bazel test --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //examples/python/... -bazel clean --expunge -bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //src/python/... -bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //examples/python/... # TODO(https://github.com/grpc/grpc/issues/19854): Move this to a new Kokoro # job. From 3207e623282b07c70ad07d1c9b3fbc46d2d4c394 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 27 Aug 2019 18:07:13 -0700 Subject: [PATCH 1377/1555] Finish todo --- third_party/py/python_configure.bzl | 1 - 1 file changed, 1 deletion(-) diff --git a/third_party/py/python_configure.bzl b/third_party/py/python_configure.bzl index a2f0c7918d2..123f0b11865 100644 --- a/third_party/py/python_configure.bzl +++ b/third_party/py/python_configure.bzl @@ -277,7 +277,6 @@ def _create_local_python_repository(repository_ctx, out="{}/BUILD".format(variety_name)) -# TODO(rbellevi): Remove def _python_autoconf_impl(repository_ctx): """Implementation of the python_autoconf repository rule.""" _create_local_python_repository(repository_ctx, From abc384164ae9414dbd35507b0d06c62b83c798b1 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 28 Aug 2019 05:52:38 -0400 Subject: [PATCH 1378/1555] fix kwargs syntax error --- bazel/grpc_build_system.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 54398b66d82..c123a2e627d 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -277,7 +277,7 @@ def grpc_py_binary(name, data = data, deps = deps + _get_external_deps(external_deps), python_version = python_version, - **kwargs, + **kwargs ) def grpc_package(name, visibility = "private", features = []): From 1ee329187f9fdc6614a1ce1150f53dfc1bca79be Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 28 Aug 2019 08:34:39 -0400 Subject: [PATCH 1379/1555] enable compute_enging_creds and jwt_token_creds interop tests for managed dotnet client --- tools/run_tests/run_interop_tests.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py index d35723c917e..066097dca59 100755 --- a/tools/run_tests/run_interop_tests.py +++ b/tools/run_tests/run_interop_tests.py @@ -208,8 +208,6 @@ class AspNetCoreLanguage: def unimplemented_test_cases(self): return _SKIP_COMPRESSION + \ - ['compute_engine_creds'] + \ - ['jwt_token_creds'] + \ _SKIP_GOOGLE_DEFAULT_CREDS + \ _SKIP_COMPUTE_ENGINE_CHANNEL_CREDS From c8430023a5c137289905e66191897ed88d7ea3e0 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 28 Aug 2019 09:05:59 -0700 Subject: [PATCH 1380/1555] Apply health check service name changes to existing subchannels. --- .../filters/client_channel/client_channel.cc | 90 ++++++++++++++++--- test/cpp/end2end/client_lb_end2end_test.cc | 43 ++++++++- 2 files changed, 119 insertions(+), 14 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index db5ddcb46b9..00d21987777 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -273,6 +273,12 @@ class ChannelData { bool received_first_resolver_result_ = false; // The number of SubchannelWrapper instances referencing a given Subchannel. Map subchannel_refcount_map_; + // The set of SubchannelWrappers that currently exist. + // No need to hold a ref, since the map is updated in the control-plane + // combiner when the SubchannelWrappers are created and destroyed. + // TODO(roth): We really want to use a set here, not a map. Since we don't + // currently have a set implementation, we use a map and ignore the value. + Map subchannel_wrappers_; // Pending ConnectedSubchannel updates for each SubchannelWrapper. // Updates are queued here in the control plane combiner and then applied // in the data plane combiner when the picker is updated. @@ -799,14 +805,14 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "SubchannelWrapper"); auto* subchannel_node = subchannel_->channelz_node(); if (subchannel_node != nullptr) { - intptr_t subchannel_uuid = subchannel_node->uuid(); auto it = chand_->subchannel_refcount_map_.find(subchannel_); if (it == chand_->subchannel_refcount_map_.end()) { - chand_->channelz_node_->AddChildSubchannel(subchannel_uuid); + chand_->channelz_node_->AddChildSubchannel(subchannel_node->uuid()); it = chand_->subchannel_refcount_map_.emplace(subchannel_, 0).first; } ++it->second; } + chand_->subchannel_wrappers_[this] = true; } ~SubchannelWrapper() { @@ -815,14 +821,14 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { "chand=%p: destroying subchannel wrapper %p for subchannel %p", chand_, this, subchannel_); } + chand_->subchannel_wrappers_.erase(this); auto* subchannel_node = subchannel_->channelz_node(); if (subchannel_node != nullptr) { - intptr_t subchannel_uuid = subchannel_node->uuid(); auto it = chand_->subchannel_refcount_map_.find(subchannel_); GPR_ASSERT(it != chand_->subchannel_refcount_map_.end()); --it->second; if (it->second == 0) { - chand_->channelz_node_->RemoveChildSubchannel(subchannel_uuid); + chand_->channelz_node_->RemoveChildSubchannel(subchannel_node->uuid()); chand_->subchannel_refcount_map_.erase(it); } } @@ -844,8 +850,9 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { UniquePtr watcher) override { auto& watcher_wrapper = watcher_map_[watcher.get()]; GPR_ASSERT(watcher_wrapper == nullptr); - watcher_wrapper = New( - std::move(watcher), Ref(DEBUG_LOCATION, "WatcherWrapper")); + watcher_wrapper = New(std::move(watcher), + Ref(DEBUG_LOCATION, "WatcherWrapper"), + initial_state); subchannel_->WatchConnectivityState( initial_state, UniquePtr(gpr_strdup(health_check_service_name_.get())), @@ -870,6 +877,40 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { return subchannel_->channel_args(); } + void UpdateHealthCheckServiceName(UniquePtr health_check_service_name) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { + gpr_log(GPR_INFO, + "chand=%p: subchannel wrapper %p: updating health check service " + "name from \"%s\" to \"%s\"", + chand_, this, health_check_service_name_.get(), + health_check_service_name.get()); + } + for (auto& p : watcher_map_) { + WatcherWrapper*& watcher_wrapper = p.second; + // Cancel the current watcher and create a new one using the new + // health check service name. + // TODO(roth): If there is not already an existing health watch + // call for the new name, then the watcher will initially report + // state CONNECTING. If the LB policy is currently reporting + // state READY, this may cause it to switch to CONNECTING before + // switching back to READY. This could cause a small delay for + // RPCs being started on the channel. If/when this becomes a + // problem, we may be able to handle it by waiting for the new + // watcher to report READY before we use it to replace the old one. + WatcherWrapper* replacement = watcher_wrapper->MakeReplacement(); + subchannel_->CancelConnectivityStateWatch( + health_check_service_name_.get(), watcher_wrapper); + watcher_wrapper = replacement; + subchannel_->WatchConnectivityState( + replacement->last_seen_state(), + UniquePtr(gpr_strdup(health_check_service_name.get())), + OrphanablePtr( + replacement)); + } + // Save the new health check service name. + health_check_service_name_ = std::move(health_check_service_name); + } + // Caller must be holding the control-plane combiner. ConnectedSubchannel* connected_subchannel() const { return connected_subchannel_.get(); @@ -904,8 +945,11 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { WatcherWrapper( UniquePtr watcher, - RefCountedPtr parent) - : watcher_(std::move(watcher)), parent_(std::move(parent)) {} + RefCountedPtr parent, + grpc_connectivity_state initial_state) + : watcher_(std::move(watcher)), + parent_(std::move(parent)), + last_seen_state_(initial_state) {} ~WatcherWrapper() { parent_.reset(DEBUG_LOCATION, "WatcherWrapper"); } @@ -928,9 +972,21 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { } grpc_pollset_set* interested_parties() override { - return watcher_->interested_parties(); + SubchannelInterface::ConnectivityStateWatcherInterface* watcher = + watcher_.get(); + if (watcher_ == nullptr) watcher = replacement_->watcher_.get(); + return watcher->interested_parties(); } + WatcherWrapper* MakeReplacement() { + auto* replacement = + New(std::move(watcher_), parent_, last_seen_state_); + replacement_ = replacement; + return replacement; + } + + grpc_connectivity_state last_seen_state() const { return last_seen_state_; } + private: class Updater { public: @@ -954,12 +1010,17 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { gpr_log(GPR_INFO, "chand=%p: processing connectivity change in combiner " "for subchannel wrapper %p subchannel %p " - "(connected_subchannel=%p state=%s)", + "(connected_subchannel=%p state=%s): watcher=%p", self->parent_->parent_->chand_, self->parent_->parent_.get(), self->parent_->parent_->subchannel_, self->connected_subchannel_.get(), - grpc_connectivity_state_name(self->state_)); + grpc_connectivity_state_name(self->state_), + self->parent_->watcher_.get()); } + // Ignore update if the parent WatcherWrapper has been replaced + // since this callback was scheduled. + if (self->parent_->watcher_ == nullptr) return; + self->parent_->last_seen_state_ = self->state_; self->parent_->parent_->MaybeUpdateConnectedSubchannel( std::move(self->connected_subchannel_)); self->parent_->watcher_->OnConnectivityStateChange(self->state_); @@ -974,6 +1035,8 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { UniquePtr watcher_; RefCountedPtr parent_; + grpc_connectivity_state last_seen_state_; + WatcherWrapper* replacement_ = nullptr; }; void MaybeUpdateConnectedSubchannel( @@ -1655,6 +1718,11 @@ bool ChannelData::ProcessResolverResultLocked( } else { chand->health_check_service_name_.reset(); } + // Update health check service name used by existing subchannel wrappers. + for (const auto& p : chand->subchannel_wrappers_) { + p.first->UpdateHealthCheckServiceName( + UniquePtr(gpr_strdup(chand->health_check_service_name_.get()))); + } // Save service config. chand->saved_service_config_ = std::move(service_config); } diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index ceab7506729..a0af46570d4 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -42,6 +42,7 @@ #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" #include "src/core/ext/filters/client_channel/server_address.h" +#include "src/core/ext/filters/client_channel/service_config.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/debug_location.h" @@ -144,9 +145,11 @@ class FakeResolverResponseGeneratorWrapper { response_generator_ = std::move(other.response_generator_); } - void SetNextResolution(const std::vector& ports) { + void SetNextResolution(const std::vector& ports, + const char* service_config_json = nullptr) { grpc_core::ExecCtx exec_ctx; - response_generator_->SetResponse(BuildFakeResults(ports)); + response_generator_->SetResponse( + BuildFakeResults(ports, service_config_json)); } void SetNextResolutionUponError(const std::vector& ports) { @@ -165,7 +168,8 @@ class FakeResolverResponseGeneratorWrapper { private: static grpc_core::Resolver::Result BuildFakeResults( - const std::vector& ports) { + const std::vector& ports, + const char* service_config_json = nullptr) { grpc_core::Resolver::Result result; for (const int& port : ports) { char* lb_uri_str; @@ -179,6 +183,11 @@ class FakeResolverResponseGeneratorWrapper { grpc_uri_destroy(lb_uri); gpr_free(lb_uri_str); } + if (service_config_json != nullptr) { + result.service_config = grpc_core::ServiceConfig::Create( + service_config_json, &result.service_config_error); + GPR_ASSERT(result.service_config != nullptr); + } return result; } @@ -1465,6 +1474,34 @@ TEST_F(ClientLbEnd2endTest, RoundRobinWithHealthCheckingServiceNamePerChannel) { EnableDefaultHealthCheckService(false); } +TEST_F(ClientLbEnd2endTest, + RoundRobinWithHealthCheckingServiceNameChangesAfterSubchannelsCreated) { + EnableDefaultHealthCheckService(true); + // Start server. + const int kNumServers = 1; + StartServers(kNumServers); + // Create a channel with health-checking enabled. + const char* kServiceConfigJson = + "{\"healthCheckConfig\": " + "{\"serviceName\": \"health_check_service_name\"}}"; + auto response_generator = BuildResolverResponseGenerator(); + auto channel = BuildChannel("round_robin", response_generator); + auto stub = BuildStub(channel); + std::vector ports = GetServersPorts(); + response_generator.SetNextResolution(ports, kServiceConfigJson); + servers_[0]->SetServingStatus("health_check_service_name", true); + EXPECT_TRUE(WaitForChannelReady(channel.get(), 1 /* timeout_seconds */)); + // Send an update on the channel to change it to use a health checking + // service name that is not being reported as healthy. + const char* kServiceConfigJson2 = + "{\"healthCheckConfig\": " + "{\"serviceName\": \"health_check_service_name2\"}}"; + response_generator.SetNextResolution(ports, kServiceConfigJson2); + EXPECT_TRUE(WaitForChannelNotReady(channel.get())); + // Clean up. + EnableDefaultHealthCheckService(false); +} + TEST_F(ClientLbEnd2endTest, ChannelIdleness) { // Start server. const int kNumServers = 1; From 6dfe27ab0823a1dcac2953afdbf404095d7a3320 Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Tue, 27 Aug 2019 15:09:17 -0700 Subject: [PATCH 1381/1555] Fix race in bm_chttp2_transport --- test/cpp/microbenchmarks/BUILD | 8 ++++ .../microbenchmarks/bm_chttp2_transport.cc | 40 +++++++++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD index b8e9b14d4b4..fdae8246c31 100644 --- a/test/cpp/microbenchmarks/BUILD +++ b/test/cpp/microbenchmarks/BUILD @@ -27,6 +27,14 @@ grpc_cc_test( deps = ["//test/core/util:grpc_test_util"], ) +grpc_cc_binary( + name = "bm_chttp2_transport", + testonly = 1, + srcs = ["bm_chttp2_transport.cc"], + tags = ["no_windows"], + deps = [":helpers"], +) + grpc_cc_library( name = "helpers", testonly = 1, diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc index da3357304ba..dc3d76ee38e 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc @@ -239,7 +239,7 @@ class Stream { grpc_transport_destroy_stream(stream->f_->transport(), static_cast(stream->stream_), stream->destroy_closure_); - gpr_event_set(&stream->done_, (void*)1); + gpr_event_set(&stream->done_, (void*)(1)); } Fixture* f_; @@ -254,6 +254,7 @@ class Stream { //////////////////////////////////////////////////////////////////////////////// // Benchmarks // +std::vector> done_events; static void BM_StreamCreateDestroy(benchmark::State& state) { TrackCounters track_counters; @@ -380,15 +381,24 @@ static void BM_TransportEmptyOp(benchmark::State& state) { reset_op(); op.cancel_stream = true; op_payload.cancel_stream.cancel_error = GRPC_ERROR_CANCELLED; + gpr_event* stream_cancel_done = new gpr_event; + gpr_event_init(stream_cancel_done); + std::unique_ptr stream_cancel_closure = + MakeClosure([&](grpc_error* error) { + GPR_ASSERT(error == GRPC_ERROR_NONE); + gpr_event_set(stream_cancel_done, (void*)(1)); + }); + op.on_complete = stream_cancel_closure.get(); s->Op(&op); + f.FlushExecCtx(); + gpr_event_wait(stream_cancel_done, gpr_inf_future(GPR_CLOCK_REALTIME)); + done_events.emplace_back(stream_cancel_done); s->DestroyThen(MakeOnceClosure([s](grpc_error* error) { delete s; })); f.FlushExecCtx(); track_counters.Finish(state); } BENCHMARK(BM_TransportEmptyOp); -std::vector> done_events; - static void BM_TransportStreamSend(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; @@ -424,7 +434,7 @@ static void BM_TransportStreamSend(benchmark::State& state) { std::unique_ptr c = MakeClosure([&](grpc_error* error) { if (!state.KeepRunning()) { - gpr_event_set(bm_done, (void*)1); + gpr_event_set(bm_done, (void*)(1)); return; } grpc_slice_buffer send_buffer; @@ -455,7 +465,18 @@ static void BM_TransportStreamSend(benchmark::State& state) { reset_op(); op.cancel_stream = true; op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED; + gpr_event* stream_cancel_done = new gpr_event; + gpr_event_init(stream_cancel_done); + std::unique_ptr stream_cancel_closure = + MakeClosure([&](grpc_error* error) { + GPR_ASSERT(error == GRPC_ERROR_NONE); + gpr_event_set(stream_cancel_done, (void*)(1)); + }); + op.on_complete = stream_cancel_closure.get(); s->Op(&op); + f.FlushExecCtx(); + gpr_event_wait(stream_cancel_done, gpr_inf_future(GPR_CLOCK_REALTIME)); + done_events.emplace_back(stream_cancel_done); s->DestroyThen(MakeOnceClosure([s](grpc_error* error) { delete s; })); f.FlushExecCtx(); track_counters.Finish(state); @@ -629,7 +650,18 @@ static void BM_TransportStreamRecv(benchmark::State& state) { reset_op(); op.cancel_stream = true; op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED; + gpr_event* stream_cancel_done = new gpr_event; + gpr_event_init(stream_cancel_done); + std::unique_ptr stream_cancel_closure = + MakeClosure([&](grpc_error* error) { + GPR_ASSERT(error == GRPC_ERROR_NONE); + gpr_event_set(stream_cancel_done, (void*)(1)); + }); + op.on_complete = stream_cancel_closure.get(); s->Op(&op); + f.FlushExecCtx(); + gpr_event_wait(stream_cancel_done, gpr_inf_future(GPR_CLOCK_REALTIME)); + done_events.emplace_back(stream_cancel_done); s->DestroyThen(MakeOnceClosure([s](grpc_error* error) { delete s; })); grpc_metadata_batch_destroy(&b); grpc_metadata_batch_destroy(&b_recv); From a451a3a94b09a78d4511dd13500bd9da96696d50 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 28 Aug 2019 10:18:14 -0700 Subject: [PATCH 1382/1555] Rename function --- third_party/py/python_configure.bzl | 31 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/third_party/py/python_configure.bzl b/third_party/py/python_configure.bzl index 123f0b11865..70380e9dde9 100644 --- a/third_party/py/python_configure.bzl +++ b/third_party/py/python_configure.bzl @@ -241,12 +241,11 @@ def _get_python_import_lib_name(repository_ctx, python_bin, bin_path_key): return result.stdout.splitlines()[0] -# TODO(rbellevi): Rename. -def _create_local_python_repository(repository_ctx, - variety_name, - bin_path_key, - default_bin_path, - lib_path_key): +def _create_single_version_package(repository_ctx, + variety_name, + bin_path_key, + default_bin_path, + lib_path_key): """Creates the repository containing files set up to build with Python.""" python_bin = _get_python_bin(repository_ctx, bin_path_key, default_bin_path) _check_python_bin(repository_ctx, python_bin, bin_path_key) @@ -279,16 +278,16 @@ def _create_local_python_repository(repository_ctx, def _python_autoconf_impl(repository_ctx): """Implementation of the python_autoconf repository rule.""" - _create_local_python_repository(repository_ctx, - "_python2", - _PYTHON2_BIN_PATH, - "python", - _PYTHON2_LIB_PATH) - _create_local_python_repository(repository_ctx, - "_python3", - _PYTHON3_BIN_PATH, - "python3", - _PYTHON3_LIB_PATH) + _create_single_version_package(repository_ctx, + "_python2", + _PYTHON2_BIN_PATH, + "python", + _PYTHON2_LIB_PATH) + _create_single_version_package(repository_ctx, + "_python3", + _PYTHON3_BIN_PATH, + "python3", + _PYTHON3_LIB_PATH) _tpl(repository_ctx, "BUILD") From 4edd3ad2a48eb1d0db1e035a55bfbedb5f996117 Mon Sep 17 00:00:00 2001 From: yang-g Date: Wed, 28 Aug 2019 10:30:33 -0700 Subject: [PATCH 1383/1555] Update reflection doc --- doc/server_reflection_tutorial.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/doc/server_reflection_tutorial.md b/doc/server_reflection_tutorial.md index acbb4a6ab2d..ccad06057d6 100644 --- a/doc/server_reflection_tutorial.md +++ b/doc/server_reflection_tutorial.md @@ -178,15 +178,12 @@ descriptor database. desc_pool->FindMethodByName("helloworld.Greeter.SayHello"); ``` - * Get message type descriptors. + * Get message type descriptors and create messages dynamically. ```c++ const google::protobuf::Descriptor* request_desc = desc_pool->FindMessageTypeByName("helloworld.HelloRequest"); + google::protobuf::DynamicMessageFactory dmf; + google::protobuf::Message* request = dmf.GetPrototype(request_desc)->New(); ``` - * Feed [google::protobuf::DynamicMessageFactory](https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.dynamic_message#DynamicMessageFactory). - - ```c++ - google::protobuf::DynamicMessageFactory(&desc_pool); - ``` From d3cd387e03e3cbf99f71c144e371aeade4ad7357 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 28 Aug 2019 10:43:01 -0700 Subject: [PATCH 1384/1555] Bump rules_apple --- bazel/grpc_deps.bzl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 57021924725..6bbb960b6c3 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -221,10 +221,11 @@ def grpc_deps(): ) if "build_bazel_rules_apple" not in native.existing_rules(): - git_repository( + http_archive( name = "build_bazel_rules_apple", - remote = "https://github.com/bazelbuild/rules_apple.git", - tag = "0.17.2", + url = "https://github.com/bazelbuild/rules_apple/archive/b869b0d3868d78a1d4ffd866ccb304fb68aa12c3.tar.gz", + strip_prefix = "rules_apple-b869b0d3868d78a1d4ffd866ccb304fb68aa12c3", + sha256 = "bdc8e66e70b8a75da23b79f1f8c6207356df07d041d96d2189add7ee0780cf4e", ) grpc_python_deps() From d1f4456dc656264c3413dd9596b910cad3539e33 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 28 Aug 2019 11:37:59 -0700 Subject: [PATCH 1385/1555] Revert "Merge pull request #19704 from muxi/isolate-call-implementation-2" This reverts commit ac5f8062dd4e9d903a42f41219b5323eec0908be, reversing changes made to 8ae549431ce2f3c009b3a297570f40339f05f699. --- bazel/grpc_build_system.bzl | 11 +- gRPC-ProtoRPC.podspec | 30 +- gRPC-RxLibrary.podspec | 17 - gRPC.podspec | 116 +-- src/compiler/objective_c_generator.cc | 95 +- src/compiler/objective_c_generator.h | 14 +- src/compiler/objective_c_plugin.cc | 60 +- src/objective-c/BUILD | 244 ++--- .../GRPCClient/GRPCCall+ChannelArg.h | 2 +- .../GRPCClient/GRPCCall+ChannelArg.m | 4 +- .../GRPCClient/GRPCCall+ChannelCredentials.h | 2 +- .../GRPCClient/GRPCCall+ChannelCredentials.m | 2 +- src/objective-c/GRPCClient/GRPCCall+Cronet.h | 13 +- src/objective-c/GRPCClient/GRPCCall+Cronet.m | 4 +- src/objective-c/GRPCClient/GRPCCall+GID.h | 2 +- src/objective-c/GRPCClient/GRPCCall+OAuth2.h | 4 +- src/objective-c/GRPCClient/GRPCCall+Tests.h | 2 +- src/objective-c/GRPCClient/GRPCCall+Tests.m | 2 +- src/objective-c/GRPCClient/GRPCCall.h | 240 ++++- src/objective-c/GRPCClient/GRPCCall.m | 871 +++++++++++++++--- src/objective-c/GRPCClient/GRPCCallLegacy.h | 136 --- src/objective-c/GRPCClient/GRPCCallLegacy.m | 677 -------------- src/objective-c/GRPCClient/GRPCCallOptions.h | 82 +- src/objective-c/GRPCClient/GRPCCallOptions.m | 27 +- src/objective-c/GRPCClient/GRPCDispatchable.h | 30 - src/objective-c/GRPCClient/GRPCInterceptor.h | 32 +- src/objective-c/GRPCClient/GRPCInterceptor.m | 265 ++---- src/objective-c/GRPCClient/GRPCTransport.h | 82 -- src/objective-c/GRPCClient/GRPCTransport.m | 142 --- src/objective-c/GRPCClient/GRPCTypes.h | 187 ---- .../internal_testing/GRPCCall+InternalTests.m | 2 +- .../private/{GRPCCore => }/ChannelArgsUtil.h | 0 .../private/{GRPCCore => }/ChannelArgsUtil.m | 0 .../private/{GRPCCore => }/GRPCCall+V2API.h | 6 + .../private/{GRPCCore => }/GRPCCallInternal.h | 14 +- .../private/{GRPCCore => }/GRPCCallInternal.m | 140 ++- .../private/{GRPCCore => }/GRPCChannel.h | 0 .../private/{GRPCCore => }/GRPCChannel.m | 72 +- .../{GRPCCore => }/GRPCChannelFactory.h | 0 .../{GRPCCore => }/GRPCChannelPool+Test.h | 0 .../private/{GRPCCore => }/GRPCChannelPool.h | 2 + .../private/{GRPCCore => }/GRPCChannelPool.m | 5 +- .../{GRPCCore => }/GRPCCompletionQueue.h | 0 .../{GRPCCore => }/GRPCCompletionQueue.m | 0 .../GRPCCoreCronet/GRPCCoreCronetFactory.h | 32 - .../GRPCCoreCronet/GRPCCoreCronetFactory.m | 54 -- .../private/GRPCCore/GRPCCoreFactory.h | 45 - .../private/GRPCCore/GRPCCoreFactory.m | 90 -- .../GRPCCronetChannelFactory.h | 2 +- .../GRPCCronetChannelFactory.m | 24 +- .../private/{GRPCCore => }/GRPCHost.h | 0 .../private/{GRPCCore => }/GRPCHost.m | 35 +- .../GRPCInsecureChannelFactory.h | 0 .../GRPCInsecureChannelFactory.m | 0 .../private/{GRPCCore => }/GRPCOpBatchLog.h | 0 .../private/{GRPCCore => }/GRPCOpBatchLog.m | 0 .../GRPCReachabilityFlagNames.xmacro.h | 0 .../{GRPCCore => }/GRPCRequestHeaders.h | 2 +- .../{GRPCCore => }/GRPCRequestHeaders.m | 0 .../{GRPCCore => }/GRPCSecureChannelFactory.h | 0 .../{GRPCCore => }/GRPCSecureChannelFactory.m | 0 .../private/GRPCTransport+Private.h | 65 -- .../private/GRPCTransport+Private.m | 131 --- .../private/{GRPCCore => }/GRPCWrappedCall.h | 0 .../private/{GRPCCore => }/GRPCWrappedCall.m | 0 .../private/{GRPCCore => }/NSData+GRPC.h | 0 .../private/{GRPCCore => }/NSData+GRPC.m | 0 .../{GRPCCore => }/NSDictionary+GRPC.h | 0 .../{GRPCCore => }/NSDictionary+GRPC.m | 0 .../private/{GRPCCore => }/NSError+GRPC.h | 0 .../private/{GRPCCore => }/NSError+GRPC.m | 3 +- .../GRPCClient/{ => private}/version.h | 0 src/objective-c/ProtoRPC/ProtoRPC.h | 38 +- src/objective-c/ProtoRPC/ProtoRPC.m | 91 ++ src/objective-c/ProtoRPC/ProtoRPCLegacy.h | 67 -- src/objective-c/ProtoRPC/ProtoRPCLegacy.m | 121 --- src/objective-c/ProtoRPC/ProtoService.h | 29 +- src/objective-c/ProtoRPC/ProtoService.m | 42 +- src/objective-c/ProtoRPC/ProtoServiceLegacy.h | 23 - src/objective-c/ProtoRPC/ProtoServiceLegacy.m | 71 -- .../tvOS-sample/tvOS-sample/ViewController.m | 2 - .../WatchKit-Extension/InterfaceController.m | 2 - src/objective-c/tests/BUILD | 8 + src/objective-c/tests/ConfigureCronet.h | 4 + src/objective-c/tests/ConfigureCronet.m | 4 + .../InteropTestsRemoteWithCronet.m | 12 +- .../tests/InteropTests/InteropTests.h | 13 +- .../tests/InteropTests/InteropTests.m | 268 +++--- .../InteropTests/InteropTestsLocalCleartext.m | 5 +- .../tests/InteropTests/InteropTestsLocalSSL.m | 5 +- .../InteropTestsMultipleChannels.m | 3 +- .../tests/InteropTests/InteropTestsRemote.m | 6 + src/objective-c/tests/Podfile | 24 +- .../tests/Tests.xcodeproj/project.pbxproj | 29 +- .../xcschemes/InteropTests.xcscheme | 8 +- .../tests/UnitTests/ChannelPoolTest.m | 6 +- .../tests/UnitTests/ChannelTests.m | 10 +- .../tests/UnitTests/NSErrorUnitTests.m | 2 +- templates/gRPC-ProtoRPC.podspec.template | 30 +- templates/gRPC-RxLibrary.podspec.template | 17 - templates/gRPC.podspec.template | 116 +-- .../{ => private}/version.h.template | 0 102 files changed, 1923 insertions(+), 3252 deletions(-) delete mode 100644 src/objective-c/GRPCClient/GRPCCallLegacy.h delete mode 100644 src/objective-c/GRPCClient/GRPCCallLegacy.m delete mode 100644 src/objective-c/GRPCClient/GRPCDispatchable.h delete mode 100644 src/objective-c/GRPCClient/GRPCTransport.h delete mode 100644 src/objective-c/GRPCClient/GRPCTransport.m delete mode 100644 src/objective-c/GRPCClient/GRPCTypes.h rename src/objective-c/GRPCClient/private/{GRPCCore => }/ChannelArgsUtil.h (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/ChannelArgsUtil.m (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCCall+V2API.h (79%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCCallInternal.h (70%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCCallInternal.m (69%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCChannel.h (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCChannel.m (78%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCChannelFactory.h (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCChannelPool+Test.h (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCChannelPool.h (98%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCChannelPool.m (98%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCCompletionQueue.h (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCCompletionQueue.m (100%) delete mode 100644 src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h delete mode 100644 src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m delete mode 100644 src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h delete mode 100644 src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m rename src/objective-c/GRPCClient/private/{GRPCCore/GRPCCoreCronet => }/GRPCCronetChannelFactory.h (96%) rename src/objective-c/GRPCClient/private/{GRPCCore/GRPCCoreCronet => }/GRPCCronetChannelFactory.m (76%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCHost.h (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCHost.m (82%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCInsecureChannelFactory.h (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCInsecureChannelFactory.m (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCOpBatchLog.h (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCOpBatchLog.m (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCReachabilityFlagNames.xmacro.h (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCRequestHeaders.h (95%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCRequestHeaders.m (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCSecureChannelFactory.h (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCSecureChannelFactory.m (100%) delete mode 100644 src/objective-c/GRPCClient/private/GRPCTransport+Private.h delete mode 100644 src/objective-c/GRPCClient/private/GRPCTransport+Private.m rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCWrappedCall.h (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/GRPCWrappedCall.m (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/NSData+GRPC.h (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/NSData+GRPC.m (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/NSDictionary+GRPC.h (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/NSDictionary+GRPC.m (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/NSError+GRPC.h (100%) rename src/objective-c/GRPCClient/private/{GRPCCore => }/NSError+GRPC.m (96%) rename src/objective-c/GRPCClient/{ => private}/version.h (100%) delete mode 100644 src/objective-c/ProtoRPC/ProtoRPCLegacy.h delete mode 100644 src/objective-c/ProtoRPC/ProtoRPCLegacy.m delete mode 100644 src/objective-c/ProtoRPC/ProtoServiceLegacy.h delete mode 100644 src/objective-c/ProtoRPC/ProtoServiceLegacy.m rename templates/src/objective-c/GRPCClient/{ => private}/version.h.template (100%) diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 23f90d0dc80..f386b87b583 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -24,6 +24,7 @@ # load("//bazel:cc_grpc_library.bzl", "cc_grpc_library") +load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle") load("@upb//bazel:upb_proto_library.bzl", "upb_proto_library") load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test") @@ -238,13 +239,19 @@ def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], da ) def grpc_generate_one_off_targets(): + apple_resource_bundle( + # The choice of name is signicant here, since it determines the bundle name. + name = "gRPCCertificates", + resources = ["etc/roots.pem"], + ) + # In open-source, grpc_objc* libraries depend directly on //:grpc native.alias( name = "grpc_objc", actual = "//:grpc", ) -def grpc_generate_objc_one_off_targets(): +def grpc_objc_use_cronet_config(): pass def grpc_sh_test(name, srcs, args = [], data = []): @@ -289,7 +296,7 @@ def grpc_package(name, visibility = "private", features = []): def grpc_objc_library( name, - srcs = [], + srcs, hdrs = [], textual_hdrs = [], data = [], diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 4c5ebb36562..57dac5a10e5 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -42,40 +42,22 @@ Pod::Spec.new do |s| s.module_name = name s.header_dir = name - s.default_subspec = 'Main', 'Legacy', 'Legacy-Header' + src_dir = 'src/objective-c/ProtoRPC' - s.subspec 'Legacy-Header' do |ss| - ss.header_mappings_dir = "src/objective-c/ProtoRPC" - ss.public_header_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.h" - ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.h" - end + s.default_subspec = 'Main' s.subspec 'Main' do |ss| - ss.header_mappings_dir = "src/objective-c/ProtoRPC" - ss.dependency "#{s.name}/Legacy-Header", version - ss.dependency 'gRPC/Interface', version - ss.dependency 'Protobuf', '~> 3.0' - - ss.source_files = "src/objective-c/ProtoRPC/ProtoMethod.{h,m}", - "src/objective-c/ProtoRPC/ProtoRPC.{h,m}", - "src/objective-c/ProtoRPC/ProtoService.{h,m}" - end - - s.subspec 'Legacy' do |ss| - ss.header_mappings_dir = "src/objective-c/ProtoRPC" - ss.dependency "#{s.name}/Main", version - ss.dependency "#{s.name}/Legacy-Header", version - ss.dependency 'gRPC/GRPCCore', version + ss.header_mappings_dir = "#{src_dir}" + ss.dependency 'gRPC', version ss.dependency 'gRPC-RxLibrary', version ss.dependency 'Protobuf', '~> 3.0' - ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.m", - "src/objective-c/ProtoRPC/ProtoServiceLegacy.m" + ss.source_files = "#{src_dir}/*.{h,m}" end # CFStream is now default. Leaving this subspec only for compatibility purpose. s.subspec 'CFStream' do |ss| - ss.dependency "#{s.name}/Legacy", version + ss.dependency "#{s.name}/Main", version end s.pod_target_xcconfig = { diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 2e412cf67d6..9666c3c1b98 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -42,23 +42,6 @@ Pod::Spec.new do |s| s.module_name = name s.header_dir = name - s.default_subspec = 'Interface', 'Implementation' - - src_dir = 'src/objective-c/RxLibrary' - s.subspec 'Interface' do |ss| - ss.header_mappings_dir = "#{src_dir}" - ss.source_files = "#{src_dir}/*.h" - ss.public_header_files = "#{src_dir}/*.h" - end - - s.subspec 'Implementation' do |ss| - ss.header_mappings_dir = "#{src_dir}" - ss.source_files = "#{src_dir}/*.m", "#{src_dir}/**/*.{h,m}" - ss.private_header_files = "#{src_dir}/**/*.h" - - ss.dependency "#{s.name}/Interface" - end - src_dir = 'src/objective-c/RxLibrary' s.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}" s.private_header_files = "#{src_dir}/private/*.h" diff --git a/gRPC.podspec b/gRPC.podspec index e18adcd276e..09baf1e3b4b 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -41,7 +41,13 @@ Pod::Spec.new do |s| s.module_name = name s.header_dir = name - s.default_subspec = 'Interface', 'GRPCCore', 'Interface-Legacy' + src_dir = 'src/objective-c/GRPCClient' + + s.dependency 'gRPC-RxLibrary', version + s.default_subspec = 'Main' + + # Certificates, to be able to establish TLS connections: + s.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } s.pod_target_xcconfig = { # This is needed by all pods that depend on gRPC-RxLibrary: @@ -49,103 +55,29 @@ Pod::Spec.new do |s| 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO', } - s.subspec 'Interface-Legacy' do |ss| - ss.header_mappings_dir = 'src/objective-c/GRPCClient' + s.subspec 'Main' do |ss| + ss.header_mappings_dir = "#{src_dir}" - ss.public_header_files = "GRPCClient/GRPCCall+ChannelArg.h", - "GRPCClient/GRPCCall+ChannelCredentials.h", - "GRPCClient/GRPCCall+Cronet.h", - "GRPCClient/GRPCCall+OAuth2.h", - "GRPCClient/GRPCCall+Tests.h", - "src/objective-c/GRPCClient/GRPCCallLegacy.h", - "src/objective-c/GRPCClient/GRPCTypes.h" + ss.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}" + ss.exclude_files = "#{src_dir}/GRPCCall+GID.{h,m}" + ss.private_header_files = "#{src_dir}/private/*.h", "#{src_dir}/internal/*.h" - ss.source_files = "GRPCClient/GRPCCall+ChannelArg.h", - "GRPCClient/GRPCCall+ChannelCredentials.h", - "GRPCClient/GRPCCall+Cronet.h", - "GRPCClient/GRPCCall+OAuth2.h", - "GRPCClient/GRPCCall+Tests.h", - "src/objective-c/GRPCClient/GRPCCallLegacy.h", - "src/objective-c/GRPCClient/GRPCTypes.h" - ss.dependency "gRPC-RxLibrary/Interface", version - end - - s.subspec 'Interface' do |ss| - ss.header_mappings_dir = 'src/objective-c/GRPCClient' - - ss.public_header_files = 'src/objective-c/GRPCClient/GRPCCall.h', - 'src/objective-c/GRPCClient/GRPCCall+Interceptor.h', - 'src/objective-c/GRPCClient/GRPCCallOptions.h', - 'src/objective-c/GRPCClient/GRPCInterceptor.h', - 'src/objective-c/GRPCClient/GRPCTransport.h', - 'src/objective-c/GRPCClient/GRPCDispatchable.h', - 'src/objective-c/GRPCClient/version.h' - - ss.source_files = 'src/objective-c/GRPCClient/GRPCCall.h', - 'src/objective-c/GRPCClient/GRPCCall.m', - 'src/objective-c/GRPCClient/GRPCCall+Interceptor.h', - 'src/objective-c/GRPCClient/GRPCCall+Interceptor.m', - 'src/objective-c/GRPCClient/GRPCCallOptions.h', - 'src/objective-c/GRPCClient/GRPCCallOptions.m', - 'src/objective-c/GRPCClient/GRPCDispatchable.h', - 'src/objective-c/GRPCClient/GRPCInterceptor.h', - 'src/objective-c/GRPCClient/GRPCInterceptor.m', - 'src/objective-c/GRPCClient/GRPCTransport.h', - 'src/objective-c/GRPCClient/GRPCTransport.m', - 'src/objective-c/GRPCClient/internal/*.h', - 'src/objective-c/GRPCClient/private/GRPCTransport+Private.h', - 'src/objective-c/GRPCClient/private/GRPCTransport+Private.m', - 'src/objective-c/GRPCClient/version.h' - - ss.dependency "#{s.name}/Interface-Legacy", version - end - - s.subspec 'GRPCCore' do |ss| - ss.header_mappings_dir = 'src/objective-c/GRPCClient' - - ss.public_header_files = 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', - 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', - 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', - 'src/objective-c/GRPCClient/GRPCCall+Tests.h', - 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', - 'src/objective-c/GRPCClient/internal_testing/*.h' - ss.private_header_files = 'src/objective-c/GRPCClient/private/GRPCCore/*.h' - ss.source_files = 'src/objective-c/GRPCClient/internal_testing/*.{h,m}', - 'src/objective-c/GRPCClient/private/GRPCCore/*.{h,m}', - 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', - 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.m', - 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', - 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m', - 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', - 'src/objective-c/GRPCClient/GRPCCall+Cronet.m', - 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', - 'src/objective-c/GRPCClient/GRPCCall+OAuth2.m', - 'src/objective-c/GRPCClient/GRPCCall+Tests.h', - 'src/objective-c/GRPCClient/GRPCCall+Tests.m', - 'src/objective-c/GRPCClient/GRPCCallLegacy.m' - - # Certificates, to be able to establish TLS connections: - ss.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } - - ss.dependency "#{s.name}/Interface-Legacy", version - ss.dependency "#{s.name}/Interface", version ss.dependency 'gRPC-Core', version - ss.dependency 'gRPC-RxLibrary', version - end - - s.subspec 'GRPCCoreCronet' do |ss| - ss.header_mappings_dir = 'src/objective-c/GRPCClient' - - ss.source_files = 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', - 'src/objective-c/GRPCClient/GRPCCall+Cronet.m', - 'src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/*.{h,m}' - ss.dependency "#{s.name}/GRPCCore", version - ss.dependency 'gRPC-Core/Cronet-Implementation', version - ss.dependency 'CronetFramework' end # CFStream is now default. Leaving this subspec only for compatibility purpose. s.subspec 'CFStream' do |ss| - ss.dependency "#{s.name}/GRPCCore", version + ss.dependency "#{s.name}/Main", version + end + + s.subspec 'GID' do |ss| + ss.ios.deployment_target = '7.0' + + ss.header_mappings_dir = "#{src_dir}" + + ss.source_files = "#{src_dir}/GRPCCall+GID.{h,m}" + + ss.dependency "#{s.name}/Main", version + ss.dependency 'Google/SignIn' end end diff --git a/src/compiler/objective_c_generator.cc b/src/compiler/objective_c_generator.cc index ed262308aba..24845ecdb06 100644 --- a/src/compiler/objective_c_generator.cc +++ b/src/compiler/objective_c_generator.cc @@ -238,21 +238,19 @@ void PrintV2Implementation(Printer* printer, const MethodDescriptor* method, } void PrintMethodImplementations(Printer* printer, - const MethodDescriptor* method, - const Parameters& generator_params) { + const MethodDescriptor* method) { map< ::grpc::string, ::grpc::string> vars = GetMethodVars(method); PrintProtoRpcDeclarationAsPragma(printer, method, vars); - if (!generator_params.no_v1_compatibility) { - // TODO(jcanizales): Print documentation from the method. - PrintSimpleSignature(printer, method, vars); - PrintSimpleImplementation(printer, method, vars); + // TODO(jcanizales): Print documentation from the method. + printer->Print("// Deprecated methods.\n"); + PrintSimpleSignature(printer, method, vars); + PrintSimpleImplementation(printer, method, vars); - printer->Print("// Returns a not-yet-started RPC object.\n"); - PrintAdvancedSignature(printer, method, vars); - PrintAdvancedImplementation(printer, method, vars); - } + printer->Print("// Returns a not-yet-started RPC object.\n"); + PrintAdvancedSignature(printer, method, vars); + PrintAdvancedImplementation(printer, method, vars); PrintV2Signature(printer, method, vars); PrintV2Implementation(printer, method, vars); @@ -278,12 +276,9 @@ void PrintMethodImplementations(Printer* printer, return output; } -::grpc::string GetProtocol(const ServiceDescriptor* service, - const Parameters& generator_params) { +::grpc::string GetProtocol(const ServiceDescriptor* service) { ::grpc::string output; - if (generator_params.no_v1_compatibility) return output; - // Scope the output stream so it closes and finalizes output to the string. grpc::protobuf::io::StringOutputStream output_stream(&output); Printer printer(&output_stream, '$'); @@ -326,8 +321,7 @@ void PrintMethodImplementations(Printer* printer, return output; } -::grpc::string GetInterface(const ServiceDescriptor* service, - const Parameters& generator_params) { +::grpc::string GetInterface(const ServiceDescriptor* service) { ::grpc::string output; // Scope the output stream so it closes and finalizes output to the string. @@ -344,11 +338,7 @@ void PrintMethodImplementations(Printer* printer, " */\n"); printer.Print(vars, "@interface $service_class$ :" - " GRPCProtoService<$service_class$2"); - if (!generator_params.no_v1_compatibility) { - printer.Print(vars, ", $service_class$"); - } - printer.Print(">\n"); + " GRPCProtoService<$service_class$, $service_class$2>\n"); printer.Print( "- (instancetype)initWithHost:(NSString *)host " "callOptions:(GRPCCallOptions " @@ -357,20 +347,17 @@ void PrintMethodImplementations(Printer* printer, printer.Print( "+ (instancetype)serviceWithHost:(NSString *)host " "callOptions:(GRPCCallOptions *_Nullable)callOptions;\n"); - if (!generator_params.no_v1_compatibility) { - printer.Print( - "// The following methods belong to a set of old APIs that have been " - "deprecated.\n"); - printer.Print("- (instancetype)initWithHost:(NSString *)host;\n"); - printer.Print("+ (instancetype)serviceWithHost:(NSString *)host;\n"); - } + printer.Print( + "// The following methods belong to a set of old APIs that have been " + "deprecated.\n"); + printer.Print("- (instancetype)initWithHost:(NSString *)host;\n"); + printer.Print("+ (instancetype)serviceWithHost:(NSString *)host;\n"); printer.Print("@end\n"); return output; } -::grpc::string GetSource(const ServiceDescriptor* service, - const Parameters& generator_params) { +::grpc::string GetSource(const ServiceDescriptor* service) { ::grpc::string output; { // Scope the output stream so it closes and finalizes output to the string. @@ -394,28 +381,22 @@ void PrintMethodImplementations(Printer* printer, " packageName:@\"$package$\"\n" " serviceName:@\"$service_name$\"\n" " callOptions:callOptions];\n" - "}\n\n"); - if (!generator_params.no_v1_compatibility) { - printer.Print(vars, - "- (instancetype)initWithHost:(NSString *)host {\n" - " return [super initWithHost:host\n" - " packageName:@\"$package$\"\n" - " serviceName:@\"$service_name$\"];\n" - "}\n\n"); - } - printer.Print("#pragma clang diagnostic pop\n\n"); + "}\n\n" + "- (instancetype)initWithHost:(NSString *)host {\n" + " return [super initWithHost:host\n" + " packageName:@\"$package$\"\n" + " serviceName:@\"$service_name$\"];\n" + "}\n\n" + "#pragma clang diagnostic pop\n\n"); - if (!generator_params.no_v1_compatibility) { - printer.Print( - "// Override superclass initializer to disallow different" - " package and service names.\n" - "- (instancetype)initWithHost:(NSString *)host\n" - " packageName:(NSString *)packageName\n" - " serviceName:(NSString *)serviceName {\n" - " return [self initWithHost:host];\n" - "}\n\n"); - } printer.Print( + "// Override superclass initializer to disallow different" + " package and service names.\n" + "- (instancetype)initWithHost:(NSString *)host\n" + " packageName:(NSString *)packageName\n" + " serviceName:(NSString *)serviceName {\n" + " return [self initWithHost:host];\n" + "}\n\n" "- (instancetype)initWithHost:(NSString *)host\n" " packageName:(NSString *)packageName\n" " serviceName:(NSString *)serviceName\n" @@ -423,14 +404,11 @@ void PrintMethodImplementations(Printer* printer, " return [self initWithHost:host callOptions:callOptions];\n" "}\n\n"); - printer.Print("#pragma mark - Class Methods\n\n"); - if (!generator_params.no_v1_compatibility) { - printer.Print( - "+ (instancetype)serviceWithHost:(NSString *)host {\n" - " return [[self alloc] initWithHost:host];\n" - "}\n\n"); - } printer.Print( + "#pragma mark - Class Methods\n\n" + "+ (instancetype)serviceWithHost:(NSString *)host {\n" + " return [[self alloc] initWithHost:host];\n" + "}\n\n" "+ (instancetype)serviceWithHost:(NSString *)host " "callOptions:(GRPCCallOptions *_Nullable)callOptions {\n" " return [[self alloc] initWithHost:host callOptions:callOptions];\n" @@ -439,8 +417,7 @@ void PrintMethodImplementations(Printer* printer, printer.Print("#pragma mark - Method Implementations\n\n"); for (int i = 0; i < service->method_count(); i++) { - PrintMethodImplementations(&printer, service->method(i), - generator_params); + PrintMethodImplementations(&printer, service->method(i)); } printer.Print("@end\n"); diff --git a/src/compiler/objective_c_generator.h b/src/compiler/objective_c_generator.h index 518962fceee..c171e5bf772 100644 --- a/src/compiler/objective_c_generator.h +++ b/src/compiler/objective_c_generator.h @@ -23,11 +23,6 @@ namespace grpc_objective_c_generator { -struct Parameters { - // Do not generate V1 interface and implementation - bool no_v1_compatibility; -}; - using ::grpc::protobuf::FileDescriptor; using ::grpc::protobuf::FileDescriptor; using ::grpc::protobuf::ServiceDescriptor; @@ -39,8 +34,7 @@ string GetAllMessageClasses(const FileDescriptor* file); // Returns the content to be included defining the @protocol segment at the // insertion point of the generated implementation file. This interface is // legacy and for backwards compatibility. -string GetProtocol(const ServiceDescriptor* service, - const Parameters& generator_params); +string GetProtocol(const ServiceDescriptor* service); // Returns the content to be included defining the @protocol segment at the // insertion point of the generated implementation file. @@ -48,13 +42,11 @@ string GetV2Protocol(const ServiceDescriptor* service); // Returns the content to be included defining the @interface segment at the // insertion point of the generated implementation file. -string GetInterface(const ServiceDescriptor* service, - const Parameters& generator_params); +string GetInterface(const ServiceDescriptor* service); // Returns the content to be included in the "global_scope" insertion point of // the generated implementation file. -string GetSource(const ServiceDescriptor* service, - const Parameters& generator_params); +string GetSource(const ServiceDescriptor* service); } // namespace grpc_objective_c_generator diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index a08064a08bd..f398033f6db 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -111,22 +111,6 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string file_name = google::protobuf::compiler::objectivec::FilePath(file); - grpc_objective_c_generator::Parameters generator_params; - generator_params.no_v1_compatibility = false; - - if (!parameter.empty()) { - std::vector parameters_list = - grpc_generator::tokenize(parameter, ","); - for (auto parameter_string = parameters_list.begin(); - parameter_string != parameters_list.end(); parameter_string++) { - std::vector param = - grpc_generator::tokenize(*parameter_string, "="); - if (param[0] == "no_v1_compatibility") { - generator_params.no_v1_compatibility = true; - } - } - } - { // Generate .pbrpc.h @@ -137,25 +121,18 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { imports = FrameworkImport(file_name + ".pbobjc.h", framework); } - ::grpc::string system_imports = - SystemImport("ProtoRPC/ProtoService.h") + - (generator_params.no_v1_compatibility - ? SystemImport("ProtoRPC/ProtoRPC.h") - : SystemImport("ProtoRPC/ProtoRPCLegacy.h")); - if (!generator_params.no_v1_compatibility) { - system_imports += SystemImport("RxLibrary/GRXWriteable.h") + - SystemImport("RxLibrary/GRXWriter.h"); - } + ::grpc::string system_imports = SystemImport("ProtoRPC/ProtoService.h") + + SystemImport("ProtoRPC/ProtoRPC.h") + + SystemImport("RxLibrary/GRXWriteable.h") + + SystemImport("RxLibrary/GRXWriter.h"); ::grpc::string forward_declarations = + "@class GRPCProtoCall;\n" "@class GRPCUnaryProtoCall;\n" "@class GRPCStreamingProtoCall;\n" "@class GRPCCallOptions;\n" - "@protocol GRPCProtoResponseHandler;\n"; - if (!generator_params.no_v1_compatibility) { - forward_declarations += "@class GRPCProtoCall;\n"; - } - forward_declarations += "\n"; + "@protocol GRPCProtoResponseHandler;\n" + "\n"; ::grpc::string class_declarations = grpc_objective_c_generator::GetAllMessageClasses(file); @@ -175,15 +152,13 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string protocols; for (int i = 0; i < file->service_count(); i++) { const grpc::protobuf::ServiceDescriptor* service = file->service(i); - protocols += - grpc_objective_c_generator::GetProtocol(service, generator_params); + protocols += grpc_objective_c_generator::GetProtocol(service); } ::grpc::string interfaces; for (int i = 0; i < file->service_count(); i++) { const grpc::protobuf::ServiceDescriptor* service = file->service(i); - interfaces += - grpc_objective_c_generator::GetInterface(service, generator_params); + interfaces += grpc_objective_c_generator::GetInterface(service); } Write(context, file_name + ".pbrpc.h", @@ -203,16 +178,14 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string imports; if (framework.empty()) { imports = LocalImport(file_name + ".pbrpc.h") + - LocalImport(file_name + ".pbobjc.h"); + LocalImport(file_name + ".pbobjc.h") + + SystemImport("ProtoRPC/ProtoRPC.h") + + SystemImport("RxLibrary/GRXWriter+Immediate.h"); } else { imports = FrameworkImport(file_name + ".pbrpc.h", framework) + - FrameworkImport(file_name + ".pbobjc.h", framework); - } - imports += (generator_params.no_v1_compatibility - ? SystemImport("ProtoRPC/ProtoRPC.h") - : SystemImport("ProtoRPC/ProtoRPCLegacy.h")); - if (!generator_params.no_v1_compatibility) { - imports += SystemImport("RxLibrary/GRXWriter+Immediate.h"); + FrameworkImport(file_name + ".pbobjc.h", framework) + + SystemImport("ProtoRPC/ProtoRPC.h") + + SystemImport("RxLibrary/GRXWriter+Immediate.h"); } ::grpc::string class_imports; @@ -223,8 +196,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string definitions; for (int i = 0; i < file->service_count(); i++) { const grpc::protobuf::ServiceDescriptor* service = file->service(i); - definitions += - grpc_objective_c_generator::GetSource(service, generator_params); + definitions += grpc_objective_c_generator::GetSource(service); } Write(context, file_name + ".pbrpc.m", diff --git a/src/objective-c/BUILD b/src/objective-c/BUILD index 5f53486d17e..3a71086f0f6 100644 --- a/src/objective-c/BUILD +++ b/src/objective-c/BUILD @@ -18,30 +18,24 @@ licenses(["notice"]) # Apache v2 package(default_visibility = ["//visibility:public"]) -load("//bazel:grpc_build_system.bzl", "grpc_objc_library", "grpc_generate_objc_one_off_targets") +load("//bazel:grpc_build_system.bzl", "grpc_objc_library", "grpc_objc_use_cronet_config") exports_files(["LICENSE"]) -grpc_generate_objc_one_off_targets() - -grpc_objc_library( - name = "rx_library_headers", - hdrs = glob([ - "RxLibrary/*.h", - ]), - includes = ["."], -) +grpc_objc_use_cronet_config() grpc_objc_library( name = "rx_library", srcs = glob([ "RxLibrary/*.m", + "RxLibrary/transformations/*.m", + ]), + hdrs = glob([ + "RxLibrary/*.h", + "RxLibrary/transformations/*.h", ]), includes = ["."], - deps = [ - ":rx_library_headers", - ":rx_library_private", - ], + deps = [":rx_library_private"], ) grpc_objc_library( @@ -56,196 +50,84 @@ grpc_objc_library( ) grpc_objc_library( - name = "grpc_objc_interface_legacy", - hdrs = [ - "GRPCClient/GRPCCall+ChannelArg.h", - "GRPCClient/GRPCCall+ChannelCredentials.h", - "GRPCClient/GRPCCall+Cronet.h", - "GRPCClient/GRPCCall+OAuth2.h", - "GRPCClient/GRPCCall+Tests.h", - "GRPCClient/GRPCCallLegacy.h", - "GRPCClient/GRPCTypes.h", - ], - deps = [ - "rx_library_headers", - ], -) - -grpc_objc_library( - name = "grpc_objc_interface", - hdrs = [ - "GRPCClient/GRPCCall.h", - "GRPCClient/GRPCCall+Interceptor.h", - "GRPCClient/GRPCCallOptions.h", - "GRPCClient/GRPCInterceptor.h", - "GRPCClient/GRPCTransport.h", - "GRPCClient/GRPCDispatchable.h", - "GRPCClient/internal/GRPCCallOptions+Internal.h", - "GRPCClient/version.h", - ], - srcs = [ - "GRPCClient/GRPCCall.m", - "GRPCClient/GRPCCall+Interceptor.m", - "GRPCClient/GRPCCallOptions.m", - "GRPCClient/GRPCInterceptor.m", - "GRPCClient/GRPCTransport.m", - "GRPCClient/private/GRPCTransport+Private.m", - ], + name = "grpc_objc_client", + srcs = glob( + [ + "GRPCClient/*.m", + "GRPCClient/private/*.m", + ], + exclude = ["GRPCClient/GRPCCall+GID.m"], + ), + hdrs = glob( + [ + "GRPCClient/*.h", + "GRPCClient/internal/*.h", + ], + exclude = ["GRPCClient/GRPCCall+GID.h"], + ), + data = ["//:gRPCCertificates"], includes = ["."], - textual_hdrs = [ - "GRPCClient/private/GRPCTransport+Private.h", - ], + textual_hdrs = glob([ + "GRPCClient/private/*.h", + ]), deps = [ - ":grpc_objc_interface_legacy", - ], -) - -grpc_objc_library( - name = "grpc_objc_client_core", - hdrs = [ - "GRPCClient/GRPCCall+ChannelCredentials.h", - "GRPCClient/GRPCCall+Cronet.h", - "GRPCClient/GRPCCall+OAuth2.h", - "GRPCClient/GRPCCall+Tests.h", - "GRPCClient/GRPCCall+ChannelArg.h", - ], - textual_hdrs = glob(["GRPCClient/private/GRPCCore/*.h"]), - srcs = [ - "GRPCClient/GRPCCall+ChannelArg.m", - "GRPCClient/GRPCCall+ChannelCredentials.m", - "GRPCClient/GRPCCall+Cronet.m", - "GRPCClient/GRPCCall+OAuth2.m", - "GRPCClient/GRPCCall+Tests.m", - "GRPCClient/GRPCCallLegacy.m", - ] + glob(["GRPCClient/private/GRPCCore/*.m"]), - data = [":gRPCCertificates"], - includes = ["."], - deps = [ - ":grpc_objc_interface", - ":grpc_objc_interface_legacy", ":rx_library", "//:grpc_objc", ], ) -alias( - name = "grpc_objc_client", - actual = "grpc_objc_client_core", -) - -grpc_objc_library( - name = "proto_objc_rpc_legacy_header", - hdrs = [ - "ProtoRPC/ProtoRPCLegacy.h", - ], - includes = ["."], -) - -grpc_objc_library( - name = "proto_objc_rpc_v2", - srcs = [ - "ProtoRPC/ProtoMethod.m", - "ProtoRPC/ProtoRPC.m", - "ProtoRPC/ProtoService.m", - ], - hdrs = [ - "ProtoRPC/ProtoMethod.h", - "ProtoRPC/ProtoRPC.h", - "ProtoRPC/ProtoService.h", - ], - includes = ["."], - defines = ["GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0"], - deps = [ - ":grpc_objc_interface", - ":proto_objc_rpc_legacy_header", - "@com_google_protobuf//:protobuf_objc", - ], -) - grpc_objc_library( name = "proto_objc_rpc", - srcs = [ - "ProtoRPC/ProtoRPCLegacy.m", - "ProtoRPC/ProtoServiceLegacy.m", - ], - hdrs = [ - "ProtoRPC/ProtoMethod.h", - "ProtoRPC/ProtoRPCLegacy.h", - "ProtoRPC/ProtoService.h", - ], + srcs = glob( + ["ProtoRPC/*.m"], + ), + hdrs = glob( + ["ProtoRPC/*.h"], + ), + # Different from Cocoapods, do not import as if @com_google_protobuf//:protobuf_objc is a framework, + # use the real paths of @com_google_protobuf//:protobuf_objc instead + defines = ["GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0"], deps = [ + ":grpc_objc_client", ":rx_library", - ":proto_objc_rpc_v2", - ":proto_objc_rpc_legacy_header", - ":grpc_objc_client_core", "@com_google_protobuf//:protobuf_objc", ], ) -load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle") - -apple_resource_bundle( - # The choice of name is signicant here, since it determines the bundle name. - name = "gRPCCertificates", - resources = ["//:etc/roots.pem"], -) - -# Internal target combining grpc_objc_client_core and proto_objc_rpc for testing grpc_objc_library( - name = "grpc_objc_client_core_internal_testing", - hdrs = [ - "GRPCClient/GRPCCall+ChannelCredentials.h", - "GRPCClient/GRPCCall+Cronet.h", - "GRPCClient/GRPCCall+OAuth2.h", - "GRPCClient/GRPCCall+Tests.h", - "GRPCClient/GRPCCall+ChannelArg.h", - "GRPCClient/internal_testing/GRPCCall+InternalTests.h", - ], - textual_hdrs = glob(["GRPCClient/private/GRPCCore/*.h"]), - srcs = [ - "GRPCClient/GRPCCall+ChannelArg.m", - "GRPCClient/GRPCCall+ChannelCredentials.m", - "GRPCClient/GRPCCall+Cronet.m", - "GRPCClient/GRPCCall+OAuth2.m", - "GRPCClient/GRPCCall+Tests.m", - "GRPCClient/GRPCCallLegacy.m", - "GRPCClient/internal_testing/GRPCCall+InternalTests.m", - ] + glob(["GRPCClient/private/GRPCCore/*.m"]), - data = [":gRPCCertificates"], + name = "grpc_objc_client_internal_testing", + srcs = glob( + [ + "GRPCClient/*.m", + "GRPCClient/private/*.m", + "GRPCClient/internal_testing/*.m", + "ProtoRPC/*.m", + ], + exclude = ["GRPCClient/GRPCCall+GID.m"], + ), + hdrs = glob( + [ + "GRPCClient/*.h", + "GRPCClient/internal/*.h", + "GRPCClient/internal_testing/*.h", + "ProtoRPC/*.h", + ], + exclude = ["GRPCClient/GRPCCall+GID.h"], + ), includes = ["."], + data = ["//:gRPCCertificates"], defines = [ "GRPC_TEST_OBJC=1", + "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0", ], + textual_hdrs = glob( + [ + "GRPCClient/private/*.h", + ], + ), deps = [ - ":grpc_objc_interface", - ":grpc_objc_interface_legacy", ":rx_library", "//:grpc_objc", - ], -) - -grpc_objc_library( - name = "proto_objc_rpc_internal_testing", - srcs = [ - "ProtoRPC/ProtoRPCLegacy.m", - "ProtoRPC/ProtoServiceLegacy.m", - ], - hdrs = [ - "ProtoRPC/ProtoMethod.h", - "ProtoRPC/ProtoRPC.h", - "ProtoRPC/ProtoRPCLegacy.h", - "ProtoRPC/ProtoService.h", - ], - deps = [ - ":rx_library", - ":proto_objc_rpc_v2", - ":proto_objc_rpc_legacy_header", - ":grpc_objc_client_core_internal_testing", "@com_google_protobuf//:protobuf_objc", ], ) - -alias( - name = "grpc_objc_client_internal_testing", - actual = "proto_objc_rpc_internal_testing", -) diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h index ff5a153a0f6..2ddd53a5c66 100644 --- a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h @@ -15,7 +15,7 @@ * limitations under the License. * */ -#import "GRPCCallLegacy.h" +#import "GRPCCall.h" #include diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m index aae1b740c71..ae60d6208e1 100644 --- a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m @@ -18,8 +18,8 @@ #import "GRPCCall+ChannelArg.h" -#import "private/GRPCCore/GRPCChannelPool.h" -#import "private/GRPCCore/GRPCHost.h" +#import "private/GRPCChannelPool.h" +#import "private/GRPCHost.h" #import diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h b/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h index c3d194bff94..7d6f79b7655 100644 --- a/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h @@ -16,7 +16,7 @@ * */ -#import "GRPCCallLegacy.h" +#import "GRPCCall.h" // Deprecated interface. Please use GRPCCallOptions instead. @interface GRPCCall (ChannelCredentials) diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m b/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m index aa97ca82bf8..2689ec2effb 100644 --- a/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m @@ -18,7 +18,7 @@ #import "GRPCCall+ChannelCredentials.h" -#import "private/GRPCCore/GRPCHost.h" +#import "private/GRPCHost.h" @implementation GRPCCall (ChannelCredentials) diff --git a/src/objective-c/GRPCClient/GRPCCall+Cronet.h b/src/objective-c/GRPCClient/GRPCCall+Cronet.h index d107ada3672..3059c6f1860 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Cronet.h +++ b/src/objective-c/GRPCClient/GRPCCall+Cronet.h @@ -15,16 +15,12 @@ * limitations under the License. * */ +#ifdef GRPC_COMPILE_WITH_CRONET +#import -#import "GRPCCallLegacy.h" -#import "GRPCTypes.h" +#import "GRPCCall.h" -typedef struct stream_engine stream_engine; - -// Transport id for Cronet transport -extern const GRPCTransportId gGRPCCoreCronetId; - -// Deprecated class. Please use the gGRPCCoreCronetId with GRPCCallOptions.transport instead. +// Deprecated interface. Please use GRPCCallOptions instead. @interface GRPCCall (Cronet) + (void)useCronetWithEngine:(stream_engine*)engine; @@ -32,3 +28,4 @@ extern const GRPCTransportId gGRPCCoreCronetId; + (BOOL)isUsingCronet; @end +#endif diff --git a/src/objective-c/GRPCClient/GRPCCall+Cronet.m b/src/objective-c/GRPCClient/GRPCCall+Cronet.m index a732208e1f6..ba8d2c23db8 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Cronet.m +++ b/src/objective-c/GRPCClient/GRPCCall+Cronet.m @@ -18,8 +18,7 @@ #import "GRPCCall+Cronet.h" -const GRPCTransportId gGRPCCoreCronetId = "io.grpc.transport.core.cronet"; - +#ifdef GRPC_COMPILE_WITH_CRONET static BOOL useCronet = NO; static stream_engine *globalCronetEngine; @@ -39,3 +38,4 @@ static stream_engine *globalCronetEngine; } @end +#endif diff --git a/src/objective-c/GRPCClient/GRPCCall+GID.h b/src/objective-c/GRPCClient/GRPCCall+GID.h index 80e34ea98da..8293e92ebe9 100644 --- a/src/objective-c/GRPCClient/GRPCCall+GID.h +++ b/src/objective-c/GRPCClient/GRPCCall+GID.h @@ -17,7 +17,7 @@ */ #import "GRPCCall+OAuth2.h" -#import "GRPCCallLegacy.h" +#import "GRPCCall.h" #import diff --git a/src/objective-c/GRPCClient/GRPCCall+OAuth2.h b/src/objective-c/GRPCClient/GRPCCall+OAuth2.h index cf60c794f27..60cdc50bfda 100644 --- a/src/objective-c/GRPCClient/GRPCCall+OAuth2.h +++ b/src/objective-c/GRPCClient/GRPCCall+OAuth2.h @@ -16,9 +16,9 @@ * */ -#import "GRPCCallLegacy.h" +#import "GRPCCall.h" -@protocol GRPCAuthorizationProtocol; +#import "GRPCCallOptions.h" // Deprecated interface. Please use GRPCCallOptions instead. @interface GRPCCall (OAuth2) diff --git a/src/objective-c/GRPCClient/GRPCCall+Tests.h b/src/objective-c/GRPCClient/GRPCCall+Tests.h index af81eec6b82..edaa5ed582c 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Tests.h +++ b/src/objective-c/GRPCClient/GRPCCall+Tests.h @@ -16,7 +16,7 @@ * */ -#import "GRPCCallLegacy.h" +#import "GRPCCall.h" // Deprecated interface. Please use GRPCCallOptions instead. @interface GRPCCall (Tests) diff --git a/src/objective-c/GRPCClient/GRPCCall+Tests.m b/src/objective-c/GRPCClient/GRPCCall+Tests.m index 3a1dff38868..20f5cba4178 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Tests.m +++ b/src/objective-c/GRPCClient/GRPCCall+Tests.m @@ -18,7 +18,7 @@ #import "GRPCCall+Tests.h" -#import "private/GRPCCore/GRPCHost.h" +#import "private/GRPCHost.h" #import "GRPCCallOptions.h" diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index 1c7a10048cf..d02ec601727 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -33,19 +33,134 @@ */ #import +#import -#import "GRPCCallOptions.h" -#import "GRPCDispatchable.h" -#import "GRPCTypes.h" +#include -// The legacy header is included for backwards compatibility. Some V1 API users are still using -// GRPCCall by importing GRPCCall.h header so we need this import. -#import "GRPCCallLegacy.h" +#include "GRPCCallOptions.h" NS_ASSUME_NONNULL_BEGIN +#pragma mark gRPC errors + +/** Domain of NSError objects produced by gRPC. */ +extern NSString *const kGRPCErrorDomain; + +/** + * gRPC error codes. + * Note that a few of these are never produced by the gRPC libraries, but are of general utility for + * server applications to produce. + */ +typedef NS_ENUM(NSUInteger, GRPCErrorCode) { + /** The operation was cancelled (typically by the caller). */ + GRPCErrorCodeCancelled = 1, + + /** + * Unknown error. Errors raised by APIs that do not return enough error information may be + * converted to this error. + */ + GRPCErrorCodeUnknown = 2, + + /** + * The client specified an invalid argument. Note that this differs from FAILED_PRECONDITION. + * INVALID_ARGUMENT indicates arguments that are problematic regardless of the state of the + * server (e.g., a malformed file name). + */ + GRPCErrorCodeInvalidArgument = 3, + + /** + * Deadline expired before operation could complete. For operations that change the state of the + * server, this error may be returned even if the operation has completed successfully. For + * example, a successful response from the server could have been delayed long enough for the + * deadline to expire. + */ + GRPCErrorCodeDeadlineExceeded = 4, + + /** Some requested entity (e.g., file or directory) was not found. */ + GRPCErrorCodeNotFound = 5, + + /** Some entity that we attempted to create (e.g., file or directory) already exists. */ + GRPCErrorCodeAlreadyExists = 6, + + /** + * The caller does not have permission to execute the specified operation. PERMISSION_DENIED isn't + * used for rejections caused by exhausting some resource (RESOURCE_EXHAUSTED is used instead for + * those errors). PERMISSION_DENIED doesn't indicate a failure to identify the caller + * (UNAUTHENTICATED is used instead for those errors). + */ + GRPCErrorCodePermissionDenied = 7, + + /** + * The request does not have valid authentication credentials for the operation (e.g. the caller's + * identity can't be verified). + */ + GRPCErrorCodeUnauthenticated = 16, + + /** Some resource has been exhausted, perhaps a per-user quota. */ + GRPCErrorCodeResourceExhausted = 8, + + /** + * The RPC was rejected because the server is not in a state required for the procedure's + * execution. For example, a directory to be deleted may be non-empty, etc. + * The client should not retry until the server state has been explicitly fixed (e.g. by + * performing another RPC). The details depend on the service being called, and should be found in + * the NSError's userInfo. + */ + GRPCErrorCodeFailedPrecondition = 9, + + /** + * The RPC was aborted, typically due to a concurrency issue like sequencer check failures, + * transaction aborts, etc. The client should retry at a higher-level (e.g., restarting a read- + * modify-write sequence). + */ + GRPCErrorCodeAborted = 10, + + /** + * The RPC was attempted past the valid range. E.g., enumerating past the end of a list. + * Unlike INVALID_ARGUMENT, this error indicates a problem that may be fixed if the system state + * changes. For example, an RPC to get elements of a list will generate INVALID_ARGUMENT if asked + * to return the element at a negative index, but it will generate OUT_OF_RANGE if asked to return + * the element at an index past the current size of the list. + */ + GRPCErrorCodeOutOfRange = 11, + + /** The procedure is not implemented or not supported/enabled in this server. */ + GRPCErrorCodeUnimplemented = 12, + + /** + * Internal error. Means some invariant expected by the server application or the gRPC library has + * been broken. + */ + GRPCErrorCodeInternal = 13, + + /** + * The server is currently unavailable. This is most likely a transient condition and may be + * corrected by retrying with a backoff. Note that it is not always safe to retry + * non-idempotent operations. + */ + GRPCErrorCodeUnavailable = 14, + + /** Unrecoverable data loss or corruption. */ + GRPCErrorCodeDataLoss = 15, +}; + +/** + * Keys used in |NSError|'s |userInfo| dictionary to store the response headers and trailers sent by + * the server. + */ +extern NSString *const kGRPCHeadersKey; +extern NSString *const kGRPCTrailersKey; + /** An object can implement this protocol to receive responses from server from a call. */ -@protocol GRPCResponseHandler +@protocol GRPCResponseHandler + +@required + +/** + * All the responses must be issued to a user-provided dispatch queue. This property specifies the + * dispatch queue to be used for issuing the notifications. + */ +@property(atomic, readonly) dispatch_queue_t dispatchQueue; @optional @@ -187,3 +302,114 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnullability-completeness" + +/** + * This interface is deprecated. Please use \a GRPCcall2. + * + * Represents a single gRPC remote call. + */ +@interface GRPCCall : GRXWriter + +- (instancetype)init NS_UNAVAILABLE; + +/** + * The container of the request headers of an RPC conforms to this protocol, which is a subset of + * NSMutableDictionary's interface. It will become a NSMutableDictionary later on. + * The keys of this container are the header names, which per the HTTP standard are case- + * insensitive. They are stored in lowercase (which is how HTTP/2 mandates them on the wire), and + * can only consist of ASCII characters. + * A header value is a NSString object (with only ASCII characters), unless the header name has the + * suffix "-bin", in which case the value has to be a NSData object. + */ +/** + * These HTTP headers will be passed to the server as part of this call. Each HTTP header is a + * name-value pair with string names and either string or binary values. + * + * The passed dictionary has to use NSString keys, corresponding to the header names. The value + * associated to each can be a NSString object or a NSData object. E.g.: + * + * call.requestHeaders = @{@"authorization": @"Bearer ..."}; + * + * call.requestHeaders[@"my-header-bin"] = someData; + * + * After the call is started, trying to modify this property is an error. + * + * The property is initialized to an empty NSMutableDictionary. + */ +@property(atomic, readonly) NSMutableDictionary *requestHeaders; + +/** + * This dictionary is populated with the HTTP headers received from the server. This happens before + * any response message is received from the server. It has the same structure as the request + * headers dictionary: Keys are NSString header names; names ending with the suffix "-bin" have a + * NSData value; the others have a NSString value. + * + * The value of this property is nil until all response headers are received, and will change before + * any of -writeValue: or -writesFinishedWithError: are sent to the writeable. + */ +@property(atomic, readonly) NSDictionary *responseHeaders; + +/** + * Same as responseHeaders, but populated with the HTTP trailers received from the server before the + * call finishes. + * + * The value of this property is nil until all response trailers are received, and will change + * before -writesFinishedWithError: is sent to the writeable. + */ +@property(atomic, readonly) NSDictionary *responseTrailers; + +/** + * The request writer has to write NSData objects into the provided Writeable. The server will + * receive each of those separately and in order as distinct messages. + * A gRPC call might not complete until the request writer finishes. On the other hand, the request + * finishing doesn't necessarily make the call to finish, as the server might continue sending + * messages to the response side of the call indefinitely (depending on the semantics of the + * specific remote method called). + * To finish a call right away, invoke cancel. + * host parameter should not contain the scheme (http:// or https://), only the name or IP addr + * and the port number, for example @"localhost:5050". + */ +- (instancetype)initWithHost:(NSString *)host + path:(NSString *)path + requestsWriter:(GRXWriter *)requestWriter; + +/** + * Finishes the request side of this call, notifies the server that the RPC should be cancelled, and + * finishes the response side of the call with an error of code CANCELED. + */ +- (void)cancel; + +/** + * The following methods are deprecated. + */ ++ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path; +@property(atomic, copy, readwrite) NSString *serverName; +@property NSTimeInterval timeout; +- (void)setResponseDispatchQueue:(dispatch_queue_t)queue; + +@end + +#pragma mark Backwards compatibiity + +/** This protocol is kept for backwards compatibility with existing code. */ +DEPRECATED_MSG_ATTRIBUTE("Use NSDictionary or NSMutableDictionary instead.") +@protocol GRPCRequestHeaders +@property(nonatomic, readonly) NSUInteger count; + +- (id)objectForKeyedSubscript:(id)key; +- (void)setObject:(id)obj forKeyedSubscript:(id)key; + +- (void)removeAllObjects; +- (void)removeObjectForKey:(id)key; +@end + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated" +/** This is only needed for backwards-compatibility. */ +@interface NSMutableDictionary (GRPCRequestHeaders) +@end +#pragma clang diagnostic pop +#pragma clang diagnostic pop diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 73ee530ef2c..cd293cc8e59 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -17,86 +17,56 @@ */ #import "GRPCCall.h" - #import "GRPCCall+Interceptor.h" +#import "GRPCCall+OAuth2.h" #import "GRPCCallOptions.h" #import "GRPCInterceptor.h" -#import "private/GRPCTransport+Private.h" +#import +#import +#import +#import +#include +#include + +#import "private/GRPCCall+V2API.h" +#import "private/GRPCCallInternal.h" +#import "private/GRPCChannelPool.h" +#import "private/GRPCCompletionQueue.h" +#import "private/GRPCHost.h" +#import "private/GRPCRequestHeaders.h" +#import "private/GRPCWrappedCall.h" +#import "private/NSData+GRPC.h" +#import "private/NSDictionary+GRPC.h" +#import "private/NSError+GRPC.h" + +// At most 6 ops can be in an op batch for a client: SEND_INITIAL_METADATA, +// SEND_MESSAGE, SEND_CLOSE_FROM_CLIENT, RECV_INITIAL_METADATA, RECV_MESSAGE, +// and RECV_STATUS_ON_CLIENT. +NSInteger kMaxClientBatch = 6; NSString *const kGRPCHeadersKey = @"io.grpc.HeadersKey"; NSString *const kGRPCTrailersKey = @"io.grpc.TrailersKey"; +static NSMutableDictionary *callFlags; -NSString *const kGRPCErrorDomain = @"io.grpc"; +static NSString *const kAuthorizationHeader = @"authorization"; +static NSString *const kBearerPrefix = @"Bearer "; -/** - * The response dispatcher creates its own serial dispatch queue and target the queue to the - * dispatch queue of a user provided response handler. It removes the requirement of having to use - * serial dispatch queue in the user provided response handler. - */ -@interface GRPCResponseDispatcher : NSObject +const char *kCFStreamVarName = "grpc_cfstream"; -- (nullable instancetype)initWithResponseHandler:(id)responseHandler; +@interface GRPCCall () +// Make them read-write. +@property(atomic, strong) NSDictionary *responseHeaders; +@property(atomic, strong) NSDictionary *responseTrailers; -@end +- (void)receiveNextMessages:(NSUInteger)numberOfMessages; -@implementation GRPCResponseDispatcher { - id _responseHandler; - dispatch_queue_t _dispatchQueue; -} - -- (instancetype)initWithResponseHandler:(id)responseHandler { - if ((self = [super init])) { - _responseHandler = responseHandler; -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 - if (@available(iOS 8.0, macOS 10.10, *)) { - _dispatchQueue = dispatch_queue_create( - NULL, - dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); - } else { -#else - { -#endif - _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); - } - dispatch_set_target_queue(_dispatchQueue, _responseHandler.dispatchQueue); - } - - return self; -} - -- (dispatch_queue_t)dispatchQueue { - return _dispatchQueue; -} - -- (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata { - if ([_responseHandler respondsToSelector:@selector(didReceiveInitialMetadata:)]) { - [_responseHandler didReceiveInitialMetadata:initialMetadata]; - } -} - -- (void)didReceiveData:(id)data { - // For backwards compatibility with didReceiveRawMessage, if the user provided a response handler - // that handles didReceiveRawMesssage, we issue to that method instead - if ([_responseHandler respondsToSelector:@selector(didReceiveRawMessage:)]) { - [_responseHandler didReceiveRawMessage:data]; - } else if ([_responseHandler respondsToSelector:@selector(didReceiveData:)]) { - [_responseHandler didReceiveData:data]; - } -} - -- (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata - error:(nullable NSError *)error { - if ([_responseHandler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { - [_responseHandler didCloseWithTrailingMetadata:trailingMetadata error:error]; - } -} - -- (void)didWriteData { - if ([_responseHandler respondsToSelector:@selector(didWriteData)]) { - [_responseHandler didWriteData]; - } -} +- (instancetype)initWithHost:(NSString *)host + path:(NSString *)path + callSafety:(GRPCCallSafety)safety + requestsWriter:(GRXWriter *)requestsWriter + callOptions:(GRPCCallOptions *)callOptions + writeDone:(void (^)(void))writeDone; @end @@ -170,39 +140,54 @@ NSString *const kGRPCErrorDomain = @"io.grpc"; } _responseHandler = responseHandler; - GRPCResponseDispatcher *dispatcher = - [[GRPCResponseDispatcher alloc] initWithResponseHandler:_responseHandler]; - NSMutableArray> *interceptorFactories; - if (_actualCallOptions.interceptorFactories != nil) { - interceptorFactories = - [NSMutableArray arrayWithArray:_actualCallOptions.interceptorFactories]; - } else { - interceptorFactories = [NSMutableArray array]; - } + // Initialize the interceptor chain + + // First initialize the internal call + GRPCCall2Internal *internalCall = [[GRPCCall2Internal alloc] init]; + id nextInterceptor = internalCall; + GRPCInterceptorManager *nextManager = nil; + + // Then initialize the global interceptor, if applicable id globalInterceptorFactory = [GRPCCall2 globalInterceptorFactory]; - if (globalInterceptorFactory != nil) { - [interceptorFactories addObject:globalInterceptorFactory]; - } - // continuously create interceptor until one is successfully created - while (_firstInterceptor == nil) { - if (interceptorFactories.count == 0) { - _firstInterceptor = [[GRPCTransportManager alloc] initWithTransportId:_callOptions.transport - previousInterceptor:dispatcher]; - break; - } else { - _firstInterceptor = - [[GRPCInterceptorManager alloc] initWithFactories:interceptorFactories - previousInterceptor:dispatcher - transportId:_callOptions.transport]; - if (_firstInterceptor == nil) { - [interceptorFactories removeObjectAtIndex:0]; - } + if (globalInterceptorFactory) { + GRPCInterceptorManager *manager = + [[GRPCInterceptorManager alloc] initWithNextInterceptor:nextInterceptor]; + GRPCInterceptor *interceptor = + [globalInterceptorFactory createInterceptorWithManager:manager]; + if (interceptor != nil) { + [internalCall setResponseHandler:interceptor]; + nextInterceptor = interceptor; + nextManager = manager; } } - NSAssert(_firstInterceptor != nil, @"Failed to create interceptor or transport."); - if (_firstInterceptor == nil) { - NSLog(@"Failed to create interceptor or transport."); + + // Finally initialize the interceptors in the chain + NSArray *interceptorFactories = _actualCallOptions.interceptorFactories; + for (int i = (int)interceptorFactories.count - 1; i >= 0; i--) { + GRPCInterceptorManager *manager = + [[GRPCInterceptorManager alloc] initWithNextInterceptor:nextInterceptor]; + GRPCInterceptor *interceptor = [interceptorFactories[i] createInterceptorWithManager:manager]; + NSAssert(interceptor != nil, @"Failed to create interceptor from factory: %@", + interceptorFactories[i]); + if (interceptor == nil) { + NSLog(@"Failed to create interceptor from factory: %@", interceptorFactories[i]); + continue; + } + if (nextManager == nil) { + [internalCall setResponseHandler:interceptor]; + } else { + [nextManager setPreviousInterceptor:interceptor]; + } + nextInterceptor = interceptor; + nextManager = manager; } + if (nextManager == nil) { + [internalCall setResponseHandler:_responseHandler]; + } else { + [nextManager setPreviousInterceptor:_responseHandler]; + } + + _firstInterceptor = nextInterceptor; } return self; @@ -215,42 +200,696 @@ NSString *const kGRPCErrorDomain = @"io.grpc"; } - (void)start { - id copiedFirstInterceptor = _firstInterceptor; - GRPCRequestOptions *requestOptions = _requestOptions; - GRPCCallOptions *callOptions = _actualCallOptions; - dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ - [copiedFirstInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; - }); + id copiedFirstInterceptor; + @synchronized(self) { + copiedFirstInterceptor = _firstInterceptor; + } + GRPCRequestOptions *requestOptions = [_requestOptions copy]; + GRPCCallOptions *callOptions = [_actualCallOptions copy]; + if ([copiedFirstInterceptor respondsToSelector:@selector(startWithRequestOptions:callOptions:)]) { + dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ + [copiedFirstInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; + }); + } } - (void)cancel { - id copiedFirstInterceptor = _firstInterceptor; - if (copiedFirstInterceptor != nil) { - dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ + id copiedFirstInterceptor; + @synchronized(self) { + copiedFirstInterceptor = _firstInterceptor; + } + if ([copiedFirstInterceptor respondsToSelector:@selector(cancel)]) { + dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ [copiedFirstInterceptor cancel]; }); } } - (void)writeData:(id)data { - id copiedFirstInterceptor = _firstInterceptor; - dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ - [copiedFirstInterceptor writeData:data]; - }); + id copiedFirstInterceptor; + @synchronized(self) { + copiedFirstInterceptor = _firstInterceptor; + } + if ([copiedFirstInterceptor respondsToSelector:@selector(writeData:)]) { + dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ + [copiedFirstInterceptor writeData:data]; + }); + } } - (void)finish { - id copiedFirstInterceptor = _firstInterceptor; - dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ - [copiedFirstInterceptor finish]; + id copiedFirstInterceptor; + @synchronized(self) { + copiedFirstInterceptor = _firstInterceptor; + } + if ([copiedFirstInterceptor respondsToSelector:@selector(finish)]) { + dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ + [copiedFirstInterceptor finish]; + }); + } +} + +- (void)receiveNextMessages:(NSUInteger)numberOfMessages { + id copiedFirstInterceptor; + @synchronized(self) { + copiedFirstInterceptor = _firstInterceptor; + } + if ([copiedFirstInterceptor respondsToSelector:@selector(receiveNextMessages:)]) { + dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ + [copiedFirstInterceptor receiveNextMessages:numberOfMessages]; + }); + } +} + +@end + +// The following methods of a C gRPC call object aren't reentrant, and thus +// calls to them must be serialized: +// - start_batch +// - destroy +// +// start_batch with a SEND_MESSAGE argument can only be called after the +// OP_COMPLETE event for any previous write is received. This is achieved by +// pausing the requests writer immediately every time it writes a value, and +// resuming it again when OP_COMPLETE is received. +// +// Similarly, start_batch with a RECV_MESSAGE argument can only be called after +// the OP_COMPLETE event for any previous read is received.This is easier to +// enforce, as we're writing the received messages into the writeable: +// start_batch is enqueued once upon receiving the OP_COMPLETE event for the +// RECV_METADATA batch, and then once after receiving each OP_COMPLETE event for +// each RECV_MESSAGE batch. +@implementation GRPCCall { + dispatch_queue_t _callQueue; + + NSString *_host; + NSString *_path; + GRPCCallSafety _callSafety; + GRPCCallOptions *_callOptions; + GRPCWrappedCall *_wrappedCall; + + // The C gRPC library has less guarantees on the ordering of events than we + // do. Particularly, in the face of errors, there's no ordering guarantee at + // all. This wrapper over our actual writeable ensures thread-safety and + // correct ordering. + GRXConcurrentWriteable *_responseWriteable; + + // The network thread wants the requestWriter to resume (when the server is ready for more input), + // or to stop (on errors), concurrently with user threads that want to start it, pause it or stop + // it. Because a writer isn't thread-safe, we'll synchronize those operations on it. + // We don't use a dispatch queue for that purpose, because the writer can call writeValue: or + // writesFinishedWithError: on this GRPCCall as part of those operations. We want to be able to + // pause the writer immediately on writeValue:, so we need our locking to be recursive. + GRXWriter *_requestWriter; + + // To create a retain cycle when a call is started, up until it finishes. See + // |startWithWriteable:| and |finishWithError:|. This saves users from having to retain a + // reference to the call object if all they're interested in is the handler being executed when + // the response arrives. + GRPCCall *_retainSelf; + + GRPCRequestHeaders *_requestHeaders; + + // In the case that the call is a unary call (i.e. the writer to GRPCCall is of type + // GRXImmediateSingleWriter), GRPCCall will delay sending ops (not send them to C core + // immediately) and buffer them into a batch _unaryOpBatch. The batch is sent to C core when + // the SendClose op is added. + BOOL _unaryCall; + NSMutableArray *_unaryOpBatch; + + // The dispatch queue to be used for enqueuing responses to user. Defaulted to the main dispatch + // queue + dispatch_queue_t _responseQueue; + + // The OAuth2 token fetched from a token provider. + NSString *_fetchedOauth2AccessToken; + + // The callback to be called when a write message op is done. + void (^_writeDone)(void); + + // Indicate a read request to core is pending. + BOOL _pendingCoreRead; + + // Indicate pending read message request from user. + NSUInteger _pendingReceiveNextMessages; +} + +@synthesize state = _state; + ++ (void)initialize { + // Guarantees the code in {} block is invoked only once. See ref at: + // https://developer.apple.com/documentation/objectivec/nsobject/1418639-initialize?language=objc + if (self == [GRPCCall self]) { + grpc_init(); + callFlags = [NSMutableDictionary dictionary]; + } +} + ++ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path { + if (host.length == 0 || path.length == 0) { + return; + } + NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path]; + @synchronized(callFlags) { + switch (callSafety) { + case GRPCCallSafetyDefault: + callFlags[hostAndPath] = @0; + break; + case GRPCCallSafetyIdempotentRequest: + callFlags[hostAndPath] = @GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST; + break; + case GRPCCallSafetyCacheableRequest: + callFlags[hostAndPath] = @GRPC_INITIAL_METADATA_CACHEABLE_REQUEST; + break; + default: + break; + } + } +} + ++ (uint32_t)callFlagsForHost:(NSString *)host path:(NSString *)path { + NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path]; + @synchronized(callFlags) { + return [callFlags[hostAndPath] intValue]; + } +} + +// Designated initializer +- (instancetype)initWithHost:(NSString *)host + path:(NSString *)path + requestsWriter:(GRXWriter *)requestWriter { + return [self initWithHost:host + path:path + callSafety:GRPCCallSafetyDefault + requestsWriter:requestWriter + callOptions:nil]; +} + +- (instancetype)initWithHost:(NSString *)host + path:(NSString *)path + callSafety:(GRPCCallSafety)safety + requestsWriter:(GRXWriter *)requestsWriter + callOptions:(GRPCCallOptions *)callOptions { + return [self initWithHost:host + path:path + callSafety:safety + requestsWriter:requestsWriter + callOptions:callOptions + writeDone:nil]; +} + +- (instancetype)initWithHost:(NSString *)host + path:(NSString *)path + callSafety:(GRPCCallSafety)safety + requestsWriter:(GRXWriter *)requestsWriter + callOptions:(GRPCCallOptions *)callOptions + writeDone:(void (^)(void))writeDone { + // Purposely using pointer rather than length (host.length == 0) for backwards compatibility. + NSAssert(host != nil && path != nil, @"Neither host nor path can be nil."); + NSAssert(safety <= GRPCCallSafetyCacheableRequest, @"Invalid call safety value."); + NSAssert(requestsWriter.state == GRXWriterStateNotStarted, + @"The requests writer can't be already started."); + if (!host || !path) { + return nil; + } + if (safety > GRPCCallSafetyCacheableRequest) { + return nil; + } + if (requestsWriter.state != GRXWriterStateNotStarted) { + return nil; + } + + if ((self = [super init])) { + _host = [host copy]; + _path = [path copy]; + _callSafety = safety; + _callOptions = [callOptions copy]; + + // Serial queue to invoke the non-reentrant methods of the grpc_call object. + _callQueue = dispatch_queue_create("io.grpc.call", DISPATCH_QUEUE_SERIAL); + + _requestWriter = requestsWriter; + _requestHeaders = [[GRPCRequestHeaders alloc] initWithCall:self]; + _writeDone = writeDone; + + if ([requestsWriter isKindOfClass:[GRXImmediateSingleWriter class]]) { + _unaryCall = YES; + _unaryOpBatch = [NSMutableArray arrayWithCapacity:kMaxClientBatch]; + } + + _responseQueue = dispatch_get_main_queue(); + + // do not start a read until initial metadata is received + _pendingReceiveNextMessages = 0; + _pendingCoreRead = YES; + } + return self; +} + +- (void)setResponseDispatchQueue:(dispatch_queue_t)queue { + @synchronized(self) { + if (_state != GRXWriterStateNotStarted) { + return; + } + _responseQueue = queue; + } +} + +#pragma mark Finish + +// This function should support being called within a @synchronized(self) block in another function +// Should not manipulate _requestWriter for deadlock prevention. +- (void)finishWithError:(NSError *)errorOrNil { + @synchronized(self) { + if (_state == GRXWriterStateFinished) { + return; + } + _state = GRXWriterStateFinished; + + if (errorOrNil) { + [_responseWriteable cancelWithError:errorOrNil]; + } else { + [_responseWriteable enqueueSuccessfulCompletion]; + } + + // If the call isn't retained anywhere else, it can be deallocated now. + _retainSelf = nil; + } +} + +- (void)cancel { + @synchronized(self) { + if (_state == GRXWriterStateFinished) { + return; + } + [self finishWithError:[NSError + errorWithDomain:kGRPCErrorDomain + code:GRPCErrorCodeCancelled + userInfo:@{NSLocalizedDescriptionKey : @"Canceled by app"}]]; + [_wrappedCall cancel]; + } + _requestWriter.state = GRXWriterStateFinished; +} + +- (void)dealloc { + __block GRPCWrappedCall *wrappedCall = _wrappedCall; + dispatch_async(_callQueue, ^{ + wrappedCall = nil; + }); +} + +#pragma mark Read messages + +// Only called from the call queue. +// The handler will be called from the network queue. +- (void)startReadWithHandler:(void (^)(grpc_byte_buffer *))handler { + // TODO(jcanizales): Add error handlers for async failures + [_wrappedCall startBatchWithOperations:@[ [[GRPCOpRecvMessage alloc] initWithHandler:handler] ]]; +} + +// Called initially from the network queue once response headers are received, +// then "recursively" from the responseWriteable queue after each response from the +// server has been written. +// If the call is currently paused, this is a noop. Restarting the call will invoke this +// method. +// TODO(jcanizales): Rename to readResponseIfNotPaused. +- (void)maybeStartNextRead { + @synchronized(self) { + if (_state != GRXWriterStateStarted) { + return; + } + if (_callOptions.flowControlEnabled && (_pendingCoreRead || _pendingReceiveNextMessages == 0)) { + return; + } + _pendingCoreRead = YES; + _pendingReceiveNextMessages--; + } + + dispatch_async(_callQueue, ^{ + __weak GRPCCall *weakSelf = self; + [self startReadWithHandler:^(grpc_byte_buffer *message) { + if (message == NULL) { + // No more messages from the server + return; + } + __strong GRPCCall *strongSelf = weakSelf; + if (strongSelf == nil) { + grpc_byte_buffer_destroy(message); + return; + } + NSData *data = [NSData grpc_dataWithByteBuffer:message]; + grpc_byte_buffer_destroy(message); + if (!data) { + // The app doesn't have enough memory to hold the server response. We + // don't want to throw, because the app shouldn't crash for a behavior + // that's on the hands of any server to have. Instead we finish and ask + // the server to cancel. + @synchronized(strongSelf) { + strongSelf->_pendingCoreRead = NO; + [strongSelf + finishWithError:[NSError errorWithDomain:kGRPCErrorDomain + code:GRPCErrorCodeResourceExhausted + userInfo:@{ + NSLocalizedDescriptionKey : + @"Client does not have enough memory to " + @"hold the server response." + }]]; + [strongSelf->_wrappedCall cancel]; + } + strongSelf->_requestWriter.state = GRXWriterStateFinished; + } else { + @synchronized(strongSelf) { + [strongSelf->_responseWriteable enqueueValue:data + completionHandler:^{ + __strong GRPCCall *strongSelf = weakSelf; + if (strongSelf) { + @synchronized(strongSelf) { + strongSelf->_pendingCoreRead = NO; + [strongSelf maybeStartNextRead]; + } + } + }]; + } + } + }]; + }); +} + +#pragma mark Send headers + +- (void)sendHeaders { + // TODO (mxyan): Remove after deprecated methods are removed + uint32_t callSafetyFlags = 0; + switch (_callSafety) { + case GRPCCallSafetyDefault: + callSafetyFlags = 0; + break; + case GRPCCallSafetyIdempotentRequest: + callSafetyFlags = GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST; + break; + case GRPCCallSafetyCacheableRequest: + callSafetyFlags = GRPC_INITIAL_METADATA_CACHEABLE_REQUEST; + break; + } + + NSMutableDictionary *headers = [_requestHeaders mutableCopy]; + NSString *fetchedOauth2AccessToken; + @synchronized(self) { + fetchedOauth2AccessToken = _fetchedOauth2AccessToken; + } + if (fetchedOauth2AccessToken != nil) { + headers[@"authorization"] = [kBearerPrefix stringByAppendingString:fetchedOauth2AccessToken]; + } else if (_callOptions.oauth2AccessToken != nil) { + headers[@"authorization"] = + [kBearerPrefix stringByAppendingString:_callOptions.oauth2AccessToken]; + } + + // TODO(jcanizales): Add error handlers for async failures + GRPCOpSendMetadata *op = [[GRPCOpSendMetadata alloc] + initWithMetadata:headers + flags:callSafetyFlags + handler:nil]; // No clean-up needed after SEND_INITIAL_METADATA + dispatch_async(_callQueue, ^{ + if (!self->_unaryCall) { + [self->_wrappedCall startBatchWithOperations:@[ op ]]; + } else { + [self->_unaryOpBatch addObject:op]; + } }); } - (void)receiveNextMessages:(NSUInteger)numberOfMessages { - id copiedFirstInterceptor = _firstInterceptor; - dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ - [copiedFirstInterceptor receiveNextMessages:numberOfMessages]; + if (numberOfMessages == 0) { + return; + } + @synchronized(self) { + _pendingReceiveNextMessages += numberOfMessages; + + if (_state != GRXWriterStateStarted || !_callOptions.flowControlEnabled) { + return; + } + [self maybeStartNextRead]; + } +} + +#pragma mark GRXWriteable implementation + +// Only called from the call queue. The error handler will be called from the +// network queue if the write didn't succeed. +// If the call is a unary call, parameter \a errorHandler will be ignored and +// the error handler of GRPCOpSendClose will be executed in case of error. +- (void)writeMessage:(NSData *)message withErrorHandler:(void (^)(void))errorHandler { + __weak GRPCCall *weakSelf = self; + void (^resumingHandler)(void) = ^{ + // Resume the request writer. + GRPCCall *strongSelf = weakSelf; + if (strongSelf) { + strongSelf->_requestWriter.state = GRXWriterStateStarted; + if (strongSelf->_writeDone) { + strongSelf->_writeDone(); + } + } + }; + GRPCOpSendMessage *op = + [[GRPCOpSendMessage alloc] initWithMessage:message handler:resumingHandler]; + if (!_unaryCall) { + [_wrappedCall startBatchWithOperations:@[ op ] errorHandler:errorHandler]; + } else { + // Ignored errorHandler since it is the same as the one for GRPCOpSendClose. + // TODO (mxyan): unify the error handlers of all Ops into a single closure. + [_unaryOpBatch addObject:op]; + } +} + +- (void)writeValue:(id)value { + NSAssert([value isKindOfClass:[NSData class]], @"value must be of type NSData"); + + @synchronized(self) { + if (_state == GRXWriterStateFinished) { + return; + } + } + + // Pause the input and only resume it when the C layer notifies us that writes + // can proceed. + _requestWriter.state = GRXWriterStatePaused; + + dispatch_async(_callQueue, ^{ + // Write error is not processed here. It is handled by op batch of GRPC_OP_RECV_STATUS_ON_CLIENT + [self writeMessage:value withErrorHandler:nil]; }); } +// Only called from the call queue. The error handler will be called from the +// network queue if the requests stream couldn't be closed successfully. +- (void)finishRequestWithErrorHandler:(void (^)(void))errorHandler { + if (!_unaryCall) { + [_wrappedCall startBatchWithOperations:@[ [[GRPCOpSendClose alloc] init] ] + errorHandler:errorHandler]; + } else { + [_unaryOpBatch addObject:[[GRPCOpSendClose alloc] init]]; + [_wrappedCall startBatchWithOperations:_unaryOpBatch errorHandler:errorHandler]; + } +} + +- (void)writesFinishedWithError:(NSError *)errorOrNil { + if (errorOrNil) { + [self cancel]; + } else { + dispatch_async(_callQueue, ^{ + // EOS error is not processed here. It is handled by op batch of GRPC_OP_RECV_STATUS_ON_CLIENT + [self finishRequestWithErrorHandler:nil]; + }); + } +} + +#pragma mark Invoke + +// Both handlers will eventually be called, from the network queue. Writes can start immediately +// after this. +// The first one (headersHandler), when the response headers are received. +// The second one (completionHandler), whenever the RPC finishes for any reason. +- (void)invokeCallWithHeadersHandler:(void (^)(NSDictionary *))headersHandler + completionHandler:(void (^)(NSError *, NSDictionary *))completionHandler { + dispatch_async(_callQueue, ^{ + // TODO(jcanizales): Add error handlers for async failures + [self->_wrappedCall + startBatchWithOperations:@[ [[GRPCOpRecvMetadata alloc] initWithHandler:headersHandler] ]]; + [self->_wrappedCall + startBatchWithOperations:@[ [[GRPCOpRecvStatus alloc] initWithHandler:completionHandler] ]]; + }); +} + +- (void)invokeCall { + __weak GRPCCall *weakSelf = self; + [self invokeCallWithHeadersHandler:^(NSDictionary *headers) { + // Response headers received. + __strong GRPCCall *strongSelf = weakSelf; + if (strongSelf) { + @synchronized(strongSelf) { + // it is ok to set nil because headers are only received once + strongSelf.responseHeaders = nil; + // copy the header so that the GRPCOpRecvMetadata object may be dealloc'ed + NSDictionary *copiedHeaders = + [[NSDictionary alloc] initWithDictionary:headers copyItems:YES]; + strongSelf.responseHeaders = copiedHeaders; + strongSelf->_pendingCoreRead = NO; + [strongSelf maybeStartNextRead]; + } + } + } + completionHandler:^(NSError *error, NSDictionary *trailers) { + __strong GRPCCall *strongSelf = weakSelf; + if (strongSelf) { + strongSelf.responseTrailers = trailers; + + if (error) { + NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; + if (error.userInfo) { + [userInfo addEntriesFromDictionary:error.userInfo]; + } + userInfo[kGRPCTrailersKey] = strongSelf.responseTrailers; + // Since gRPC core does not guarantee the headers block being called before this block, + // responseHeaders might be nil. + userInfo[kGRPCHeadersKey] = strongSelf.responseHeaders; + error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo]; + } + [strongSelf finishWithError:error]; + strongSelf->_requestWriter.state = GRXWriterStateFinished; + } + }]; +} + +#pragma mark GRXWriter implementation + +// Lock acquired inside startWithWriteable: +- (void)startCallWithWriteable:(id)writeable { + @synchronized(self) { + if (_state == GRXWriterStateFinished) { + return; + } + + _responseWriteable = + [[GRXConcurrentWriteable alloc] initWithWriteable:writeable dispatchQueue:_responseQueue]; + + GRPCPooledChannel *channel = + [[GRPCChannelPool sharedInstance] channelWithHost:_host callOptions:_callOptions]; + _wrappedCall = [channel wrappedCallWithPath:_path + completionQueue:[GRPCCompletionQueue completionQueue] + callOptions:_callOptions]; + + if (_wrappedCall == nil) { + [self finishWithError:[NSError errorWithDomain:kGRPCErrorDomain + code:GRPCErrorCodeUnavailable + userInfo:@{ + NSLocalizedDescriptionKey : + @"Failed to create call or channel." + }]]; + return; + } + + [self sendHeaders]; + [self invokeCall]; + } + + // Now that the RPC has been initiated, request writes can start. + [_requestWriter startWithWriteable:self]; +} + +- (void)startWithWriteable:(id)writeable { + id tokenProvider = nil; + @synchronized(self) { + _state = GRXWriterStateStarted; + + // Create a retain cycle so that this instance lives until the RPC finishes (or is cancelled). + // This makes RPCs in which the call isn't externally retained possible (as long as it is + // started before being autoreleased). Care is taken not to retain self strongly in any of the + // blocks used in this implementation, so that the life of the instance is determined by this + // retain cycle. + _retainSelf = self; + + if (_callOptions == nil) { + GRPCMutableCallOptions *callOptions = [[GRPCHost callOptionsForHost:_host] mutableCopy]; + if (_serverName.length != 0) { + callOptions.serverAuthority = _serverName; + } + if (_timeout > 0) { + callOptions.timeout = _timeout; + } + uint32_t callFlags = [GRPCCall callFlagsForHost:_host path:_path]; + if (callFlags != 0) { + if (callFlags == GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) { + _callSafety = GRPCCallSafetyIdempotentRequest; + } else if (callFlags == GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) { + _callSafety = GRPCCallSafetyCacheableRequest; + } + } + + id tokenProvider = self.tokenProvider; + if (tokenProvider != nil) { + callOptions.authTokenProvider = tokenProvider; + } + _callOptions = callOptions; + } + + NSAssert(_callOptions.authTokenProvider == nil || _callOptions.oauth2AccessToken == nil, + @"authTokenProvider and oauth2AccessToken cannot be set at the same time"); + + tokenProvider = _callOptions.authTokenProvider; + } + + if (tokenProvider != nil) { + __weak typeof(self) weakSelf = self; + [tokenProvider getTokenWithHandler:^(NSString *token) { + __strong typeof(self) strongSelf = weakSelf; + if (strongSelf) { + BOOL startCall = NO; + @synchronized(strongSelf) { + if (strongSelf->_state != GRXWriterStateFinished) { + startCall = YES; + if (token) { + strongSelf->_fetchedOauth2AccessToken = [token copy]; + } + } + } + if (startCall) { + [strongSelf startCallWithWriteable:writeable]; + } + } + }]; + } else { + [self startCallWithWriteable:writeable]; + } +} + +- (void)setState:(GRXWriterState)newState { + @synchronized(self) { + // Manual transitions are only allowed from the started or paused states. + if (_state == GRXWriterStateNotStarted || _state == GRXWriterStateFinished) { + return; + } + + switch (newState) { + case GRXWriterStateFinished: + _state = newState; + // Per GRXWriter's contract, setting the state to Finished manually + // means one doesn't wish the writeable to be messaged anymore. + [_responseWriteable cancelSilently]; + _responseWriteable = nil; + return; + case GRXWriterStatePaused: + _state = newState; + return; + case GRXWriterStateStarted: + if (_state == GRXWriterStatePaused) { + _state = newState; + [self maybeStartNextRead]; + } + return; + case GRXWriterStateNotStarted: + return; + } + } +} + @end diff --git a/src/objective-c/GRPCClient/GRPCCallLegacy.h b/src/objective-c/GRPCClient/GRPCCallLegacy.h deleted file mode 100644 index 51dd7da3440..00000000000 --- a/src/objective-c/GRPCClient/GRPCCallLegacy.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/** - * This is the legacy interface of this gRPC library. This API is deprecated and users should use - * the API in GRPCCall.h. This API exists solely for the purpose of backwards compatibility. - */ - -#import -#import "GRPCTypes.h" - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wnullability-completeness" - -/** - * This interface is deprecated. Please use \a GRPCCall2. - * - * Represents a single gRPC remote call. - */ -@interface GRPCCall : GRXWriter - -- (instancetype)init NS_UNAVAILABLE; - -/** - * The container of the request headers of an RPC conforms to this protocol, which is a subset of - * NSMutableDictionary's interface. It will become a NSMutableDictionary later on. - * The keys of this container are the header names, which per the HTTP standard are case- - * insensitive. They are stored in lowercase (which is how HTTP/2 mandates them on the wire), and - * can only consist of ASCII characters. - * A header value is a NSString object (with only ASCII characters), unless the header name has the - * suffix "-bin", in which case the value has to be a NSData object. - */ -/** - * These HTTP headers will be passed to the server as part of this call. Each HTTP header is a - * name-value pair with string names and either string or binary values. - * - * The passed dictionary has to use NSString keys, corresponding to the header names. The value - * associated to each can be a NSString object or a NSData object. E.g.: - * - * call.requestHeaders = @{@"authorization": @"Bearer ..."}; - * - * call.requestHeaders[@"my-header-bin"] = someData; - * - * After the call is started, trying to modify this property is an error. - * - * The property is initialized to an empty NSMutableDictionary. - */ -@property(atomic, readonly) NSMutableDictionary *requestHeaders; - -/** - * This dictionary is populated with the HTTP headers received from the server. This happens before - * any response message is received from the server. It has the same structure as the request - * headers dictionary: Keys are NSString header names; names ending with the suffix "-bin" have a - * NSData value; the others have a NSString value. - * - * The value of this property is nil until all response headers are received, and will change before - * any of -writeValue: or -writesFinishedWithError: are sent to the writeable. - */ -@property(atomic, readonly) NSDictionary *responseHeaders; - -/** - * Same as responseHeaders, but populated with the HTTP trailers received from the server before the - * call finishes. - * - * The value of this property is nil until all response trailers are received, and will change - * before -writesFinishedWithError: is sent to the writeable. - */ -@property(atomic, readonly) NSDictionary *responseTrailers; - -/** - * The request writer has to write NSData objects into the provided Writeable. The server will - * receive each of those separately and in order as distinct messages. - * A gRPC call might not complete until the request writer finishes. On the other hand, the request - * finishing doesn't necessarily make the call to finish, as the server might continue sending - * messages to the response side of the call indefinitely (depending on the semantics of the - * specific remote method called). - * To finish a call right away, invoke cancel. - * host parameter should not contain the scheme (http:// or https://), only the name or IP addr - * and the port number, for example @"localhost:5050". - */ -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - requestsWriter:(GRXWriter *)requestWriter; - -/** - * Finishes the request side of this call, notifies the server that the RPC should be cancelled, and - * finishes the response side of the call with an error of code CANCELED. - */ -- (void)cancel; - -/** - * The following methods are deprecated. - */ -+ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path; -@property(atomic, copy, readwrite) NSString *serverName; -@property NSTimeInterval timeout; -- (void)setResponseDispatchQueue:(dispatch_queue_t)queue; - -@end - -#pragma mark Backwards compatibiity - -/** This protocol is kept for backwards compatibility with existing code. */ -DEPRECATED_MSG_ATTRIBUTE("Use NSDictionary or NSMutableDictionary instead.") -@protocol GRPCRequestHeaders -@property(nonatomic, readonly) NSUInteger count; - -- (id)objectForKeyedSubscript:(id)key; -- (void)setObject:(id)obj forKeyedSubscript:(id)key; - -- (void)removeAllObjects; -- (void)removeObjectForKey:(id)key; -@end - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated" -/** This is only needed for backwards-compatibility. */ -@interface NSMutableDictionary (GRPCRequestHeaders) -@end -#pragma clang diagnostic pop -#pragma clang diagnostic pop diff --git a/src/objective-c/GRPCClient/GRPCCallLegacy.m b/src/objective-c/GRPCClient/GRPCCallLegacy.m deleted file mode 100644 index d06048c3a89..00000000000 --- a/src/objective-c/GRPCClient/GRPCCallLegacy.m +++ /dev/null @@ -1,677 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import "GRPCCallLegacy.h" - -#import "GRPCCall+OAuth2.h" -#import "GRPCCallOptions.h" -#import "GRPCTypes.h" - -#import "private/GRPCCore/GRPCChannelPool.h" -#import "private/GRPCCore/GRPCCompletionQueue.h" -#import "private/GRPCCore/GRPCHost.h" -#import "private/GRPCCore/GRPCWrappedCall.h" -#import "private/GRPCCore/NSData+GRPC.h" - -#import -#import -#import -#import - -#include - -const char *kCFStreamVarName = "grpc_cfstream"; -static NSMutableDictionary *callFlags; - -// At most 6 ops can be in an op batch for a client: SEND_INITIAL_METADATA, -// SEND_MESSAGE, SEND_CLOSE_FROM_CLIENT, RECV_INITIAL_METADATA, RECV_MESSAGE, -// and RECV_STATUS_ON_CLIENT. -NSInteger kMaxClientBatch = 6; - -static NSString *const kAuthorizationHeader = @"authorization"; -static NSString *const kBearerPrefix = @"Bearer "; - -@interface GRPCCall () -// Make them read-write. -@property(atomic, strong) NSDictionary *responseHeaders; -@property(atomic, strong) NSDictionary *responseTrailers; - -- (void)receiveNextMessages:(NSUInteger)numberOfMessages; - -@end - -// The following methods of a C gRPC call object aren't reentrant, and thus -// calls to them must be serialized: -// - start_batch -// - destroy -// -// start_batch with a SEND_MESSAGE argument can only be called after the -// OP_COMPLETE event for any previous write is received. This is achieved by -// pausing the requests writer immediately every time it writes a value, and -// resuming it again when OP_COMPLETE is received. -// -// Similarly, start_batch with a RECV_MESSAGE argument can only be called after -// the OP_COMPLETE event for any previous read is received.This is easier to -// enforce, as we're writing the received messages into the writeable: -// start_batch is enqueued once upon receiving the OP_COMPLETE event for the -// RECV_METADATA batch, and then once after receiving each OP_COMPLETE event for -// each RECV_MESSAGE batch. -@implementation GRPCCall { - dispatch_queue_t _callQueue; - - NSString *_host; - NSString *_path; - GRPCCallSafety _callSafety; - GRPCCallOptions *_callOptions; - GRPCWrappedCall *_wrappedCall; - - // The C gRPC library has less guarantees on the ordering of events than we - // do. Particularly, in the face of errors, there's no ordering guarantee at - // all. This wrapper over our actual writeable ensures thread-safety and - // correct ordering. - GRXConcurrentWriteable *_responseWriteable; - - // The network thread wants the requestWriter to resume (when the server is ready for more input), - // or to stop (on errors), concurrently with user threads that want to start it, pause it or stop - // it. Because a writer isn't thread-safe, we'll synchronize those operations on it. - // We don't use a dispatch queue for that purpose, because the writer can call writeValue: or - // writesFinishedWithError: on this GRPCCall as part of those operations. We want to be able to - // pause the writer immediately on writeValue:, so we need our locking to be recursive. - GRXWriter *_requestWriter; - - // To create a retain cycle when a call is started, up until it finishes. See - // |startWithWriteable:| and |finishWithError:|. This saves users from having to retain a - // reference to the call object if all they're interested in is the handler being executed when - // the response arrives. - GRPCCall *_retainSelf; - - GRPCRequestHeaders *_requestHeaders; - - // In the case that the call is a unary call (i.e. the writer to GRPCCall is of type - // GRXImmediateSingleWriter), GRPCCall will delay sending ops (not send them to C core - // immediately) and buffer them into a batch _unaryOpBatch. The batch is sent to C core when - // the SendClose op is added. - BOOL _unaryCall; - NSMutableArray *_unaryOpBatch; - - // The dispatch queue to be used for enqueuing responses to user. Defaulted to the main dispatch - // queue - dispatch_queue_t _responseQueue; - - // The OAuth2 token fetched from a token provider. - NSString *_fetchedOauth2AccessToken; - - // The callback to be called when a write message op is done. - void (^_writeDone)(void); - - // Indicate a read request to core is pending. - BOOL _pendingCoreRead; - - // Indicate pending read message request from user. - NSUInteger _pendingReceiveNextMessages; -} - -@synthesize state = _state; - -+ (void)initialize { - // Guarantees the code in {} block is invoked only once. See ref at: - // https://developer.apple.com/documentation/objectivec/nsobject/1418639-initialize?language=objc - if (self == [GRPCCall self]) { - grpc_init(); - callFlags = [NSMutableDictionary dictionary]; - } -} - -+ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path { - if (host.length == 0 || path.length == 0) { - return; - } - NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path]; - @synchronized(callFlags) { - switch (callSafety) { - case GRPCCallSafetyDefault: - callFlags[hostAndPath] = @0; - break; - case GRPCCallSafetyIdempotentRequest: - callFlags[hostAndPath] = @GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST; - break; - case GRPCCallSafetyCacheableRequest: - callFlags[hostAndPath] = @GRPC_INITIAL_METADATA_CACHEABLE_REQUEST; - break; - default: - break; - } - } -} - -+ (uint32_t)callFlagsForHost:(NSString *)host path:(NSString *)path { - NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path]; - @synchronized(callFlags) { - return [callFlags[hostAndPath] intValue]; - } -} - -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - requestsWriter:(GRXWriter *)requestWriter { - return [self initWithHost:host - path:path - callSafety:GRPCCallSafetyDefault - requestsWriter:requestWriter - callOptions:nil - writeDone:nil]; -} - -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - callSafety:(GRPCCallSafety)safety - requestsWriter:(GRXWriter *)requestsWriter - callOptions:(GRPCCallOptions *)callOptions - writeDone:(void (^)(void))writeDone { - // Purposely using pointer rather than length (host.length == 0) for backwards compatibility. - NSAssert(host != nil && path != nil, @"Neither host nor path can be nil."); - NSAssert(safety <= GRPCCallSafetyCacheableRequest, @"Invalid call safety value."); - NSAssert(requestsWriter.state == GRXWriterStateNotStarted, - @"The requests writer can't be already started."); - if (!host || !path) { - return nil; - } - if (safety > GRPCCallSafetyCacheableRequest) { - return nil; - } - if (requestsWriter.state != GRXWriterStateNotStarted) { - return nil; - } - - if ((self = [super init])) { - _host = [host copy]; - _path = [path copy]; - _callSafety = safety; - _callOptions = [callOptions copy]; - - // Serial queue to invoke the non-reentrant methods of the grpc_call object. - _callQueue = dispatch_queue_create("io.grpc.call", DISPATCH_QUEUE_SERIAL); - - _requestWriter = requestsWriter; - _requestHeaders = [[GRPCRequestHeaders alloc] initWithCall:self]; - _writeDone = writeDone; - - if ([requestsWriter isKindOfClass:[GRXImmediateSingleWriter class]]) { - _unaryCall = YES; - _unaryOpBatch = [NSMutableArray arrayWithCapacity:kMaxClientBatch]; - } - - _responseQueue = dispatch_get_main_queue(); - - // do not start a read until initial metadata is received - _pendingReceiveNextMessages = 0; - _pendingCoreRead = YES; - } - return self; -} - -- (void)setResponseDispatchQueue:(dispatch_queue_t)queue { - @synchronized(self) { - if (_state != GRXWriterStateNotStarted) { - return; - } - _responseQueue = queue; - } -} - -#pragma mark Finish - -// This function should support being called within a @synchronized(self) block in another function -// Should not manipulate _requestWriter for deadlock prevention. -- (void)finishWithError:(NSError *)errorOrNil { - @synchronized(self) { - if (_state == GRXWriterStateFinished) { - return; - } - _state = GRXWriterStateFinished; - - if (errorOrNil) { - [_responseWriteable cancelWithError:errorOrNil]; - } else { - [_responseWriteable enqueueSuccessfulCompletion]; - } - - // If the call isn't retained anywhere else, it can be deallocated now. - _retainSelf = nil; - } -} - -- (void)cancel { - @synchronized(self) { - if (_state == GRXWriterStateFinished) { - return; - } - [self finishWithError:[NSError - errorWithDomain:kGRPCErrorDomain - code:GRPCErrorCodeCancelled - userInfo:@{NSLocalizedDescriptionKey : @"Canceled by app"}]]; - [_wrappedCall cancel]; - } - _requestWriter.state = GRXWriterStateFinished; -} - -- (void)dealloc { - __block GRPCWrappedCall *wrappedCall = _wrappedCall; - dispatch_async(_callQueue, ^{ - wrappedCall = nil; - }); -} - -#pragma mark Read messages - -// Only called from the call queue. -// The handler will be called from the network queue. -- (void)startReadWithHandler:(void (^)(grpc_byte_buffer *))handler { - // TODO(jcanizales): Add error handlers for async failures - [_wrappedCall startBatchWithOperations:@[ [[GRPCOpRecvMessage alloc] initWithHandler:handler] ]]; -} - -// Called initially from the network queue once response headers are received, -// then "recursively" from the responseWriteable queue after each response from the -// server has been written. -// If the call is currently paused, this is a noop. Restarting the call will invoke this -// method. -// TODO(jcanizales): Rename to readResponseIfNotPaused. -- (void)maybeStartNextRead { - @synchronized(self) { - if (_state != GRXWriterStateStarted) { - return; - } - if (_callOptions.flowControlEnabled && (_pendingCoreRead || _pendingReceiveNextMessages == 0)) { - return; - } - _pendingCoreRead = YES; - _pendingReceiveNextMessages--; - } - - dispatch_async(_callQueue, ^{ - __weak GRPCCall *weakSelf = self; - [self startReadWithHandler:^(grpc_byte_buffer *message) { - if (message == NULL) { - // No more messages from the server - return; - } - __strong GRPCCall *strongSelf = weakSelf; - if (strongSelf == nil) { - grpc_byte_buffer_destroy(message); - return; - } - NSData *data = [NSData grpc_dataWithByteBuffer:message]; - grpc_byte_buffer_destroy(message); - if (!data) { - // The app doesn't have enough memory to hold the server response. We - // don't want to throw, because the app shouldn't crash for a behavior - // that's on the hands of any server to have. Instead we finish and ask - // the server to cancel. - @synchronized(strongSelf) { - strongSelf->_pendingCoreRead = NO; - [strongSelf - finishWithError:[NSError errorWithDomain:kGRPCErrorDomain - code:GRPCErrorCodeResourceExhausted - userInfo:@{ - NSLocalizedDescriptionKey : - @"Client does not have enough memory to " - @"hold the server response." - }]]; - [strongSelf->_wrappedCall cancel]; - } - strongSelf->_requestWriter.state = GRXWriterStateFinished; - } else { - @synchronized(strongSelf) { - [strongSelf->_responseWriteable enqueueValue:data - completionHandler:^{ - __strong GRPCCall *strongSelf = weakSelf; - if (strongSelf) { - @synchronized(strongSelf) { - strongSelf->_pendingCoreRead = NO; - [strongSelf maybeStartNextRead]; - } - } - }]; - } - } - }]; - }); -} - -#pragma mark Send headers - -- (void)sendHeaders { - // TODO (mxyan): Remove after deprecated methods are removed - uint32_t callSafetyFlags = 0; - switch (_callSafety) { - case GRPCCallSafetyDefault: - callSafetyFlags = 0; - break; - case GRPCCallSafetyIdempotentRequest: - callSafetyFlags = GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST; - break; - case GRPCCallSafetyCacheableRequest: - callSafetyFlags = GRPC_INITIAL_METADATA_CACHEABLE_REQUEST; - break; - } - - NSMutableDictionary *headers = [_requestHeaders mutableCopy]; - NSString *fetchedOauth2AccessToken; - @synchronized(self) { - fetchedOauth2AccessToken = _fetchedOauth2AccessToken; - } - if (fetchedOauth2AccessToken != nil) { - headers[@"authorization"] = [kBearerPrefix stringByAppendingString:fetchedOauth2AccessToken]; - } else if (_callOptions.oauth2AccessToken != nil) { - headers[@"authorization"] = - [kBearerPrefix stringByAppendingString:_callOptions.oauth2AccessToken]; - } - - // TODO(jcanizales): Add error handlers for async failures - GRPCOpSendMetadata *op = [[GRPCOpSendMetadata alloc] - initWithMetadata:headers - flags:callSafetyFlags - handler:nil]; // No clean-up needed after SEND_INITIAL_METADATA - dispatch_async(_callQueue, ^{ - if (!self->_unaryCall) { - [self->_wrappedCall startBatchWithOperations:@[ op ]]; - } else { - [self->_unaryOpBatch addObject:op]; - } - }); -} - -- (void)receiveNextMessages:(NSUInteger)numberOfMessages { - if (numberOfMessages == 0) { - return; - } - @synchronized(self) { - _pendingReceiveNextMessages += numberOfMessages; - - if (_state != GRXWriterStateStarted || !_callOptions.flowControlEnabled) { - return; - } - [self maybeStartNextRead]; - } -} - -#pragma mark GRXWriteable implementation - -// Only called from the call queue. The error handler will be called from the -// network queue if the write didn't succeed. -// If the call is a unary call, parameter \a errorHandler will be ignored and -// the error handler of GRPCOpSendClose will be executed in case of error. -- (void)writeMessage:(NSData *)message withErrorHandler:(void (^)(void))errorHandler { - __weak GRPCCall *weakSelf = self; - void (^resumingHandler)(void) = ^{ - // Resume the request writer. - GRPCCall *strongSelf = weakSelf; - if (strongSelf) { - strongSelf->_requestWriter.state = GRXWriterStateStarted; - if (strongSelf->_writeDone) { - strongSelf->_writeDone(); - } - } - }; - GRPCOpSendMessage *op = - [[GRPCOpSendMessage alloc] initWithMessage:message handler:resumingHandler]; - if (!_unaryCall) { - [_wrappedCall startBatchWithOperations:@[ op ] errorHandler:errorHandler]; - } else { - // Ignored errorHandler since it is the same as the one for GRPCOpSendClose. - // TODO (mxyan): unify the error handlers of all Ops into a single closure. - [_unaryOpBatch addObject:op]; - } -} - -- (void)writeValue:(id)value { - NSAssert([value isKindOfClass:[NSData class]], @"value must be of type NSData"); - - @synchronized(self) { - if (_state == GRXWriterStateFinished) { - return; - } - } - - // Pause the input and only resume it when the C layer notifies us that writes - // can proceed. - _requestWriter.state = GRXWriterStatePaused; - - dispatch_async(_callQueue, ^{ - // Write error is not processed here. It is handled by op batch of GRPC_OP_RECV_STATUS_ON_CLIENT - [self writeMessage:value withErrorHandler:nil]; - }); -} - -// Only called from the call queue. The error handler will be called from the -// network queue if the requests stream couldn't be closed successfully. -- (void)finishRequestWithErrorHandler:(void (^)(void))errorHandler { - if (!_unaryCall) { - [_wrappedCall startBatchWithOperations:@[ [[GRPCOpSendClose alloc] init] ] - errorHandler:errorHandler]; - } else { - [_unaryOpBatch addObject:[[GRPCOpSendClose alloc] init]]; - [_wrappedCall startBatchWithOperations:_unaryOpBatch errorHandler:errorHandler]; - } -} - -- (void)writesFinishedWithError:(NSError *)errorOrNil { - if (errorOrNil) { - [self cancel]; - } else { - dispatch_async(_callQueue, ^{ - // EOS error is not processed here. It is handled by op batch of GRPC_OP_RECV_STATUS_ON_CLIENT - [self finishRequestWithErrorHandler:nil]; - }); - } -} - -#pragma mark Invoke - -// Both handlers will eventually be called, from the network queue. Writes can start immediately -// after this. -// The first one (headersHandler), when the response headers are received. -// The second one (completionHandler), whenever the RPC finishes for any reason. -- (void)invokeCallWithHeadersHandler:(void (^)(NSDictionary *))headersHandler - completionHandler:(void (^)(NSError *, NSDictionary *))completionHandler { - dispatch_async(_callQueue, ^{ - // TODO(jcanizales): Add error handlers for async failures - [self->_wrappedCall - startBatchWithOperations:@[ [[GRPCOpRecvMetadata alloc] initWithHandler:headersHandler] ]]; - [self->_wrappedCall - startBatchWithOperations:@[ [[GRPCOpRecvStatus alloc] initWithHandler:completionHandler] ]]; - }); -} - -- (void)invokeCall { - __weak GRPCCall *weakSelf = self; - [self invokeCallWithHeadersHandler:^(NSDictionary *headers) { - // Response headers received. - __strong GRPCCall *strongSelf = weakSelf; - if (strongSelf) { - @synchronized(strongSelf) { - // it is ok to set nil because headers are only received once - strongSelf.responseHeaders = nil; - // copy the header so that the GRPCOpRecvMetadata object may be dealloc'ed - NSDictionary *copiedHeaders = - [[NSDictionary alloc] initWithDictionary:headers copyItems:YES]; - strongSelf.responseHeaders = copiedHeaders; - strongSelf->_pendingCoreRead = NO; - [strongSelf maybeStartNextRead]; - } - } - } - completionHandler:^(NSError *error, NSDictionary *trailers) { - __strong GRPCCall *strongSelf = weakSelf; - if (strongSelf) { - strongSelf.responseTrailers = trailers; - - if (error) { - NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; - if (error.userInfo) { - [userInfo addEntriesFromDictionary:error.userInfo]; - } - userInfo[kGRPCTrailersKey] = strongSelf.responseTrailers; - // Since gRPC core does not guarantee the headers block being called before this block, - // responseHeaders might be nil. - userInfo[kGRPCHeadersKey] = strongSelf.responseHeaders; - error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo]; - } - [strongSelf finishWithError:error]; - strongSelf->_requestWriter.state = GRXWriterStateFinished; - } - }]; -} - -#pragma mark GRXWriter implementation - -// Lock acquired inside startWithWriteable: -- (void)startCallWithWriteable:(id)writeable { - @synchronized(self) { - if (_state == GRXWriterStateFinished) { - return; - } - - _responseWriteable = - [[GRXConcurrentWriteable alloc] initWithWriteable:writeable dispatchQueue:_responseQueue]; - - GRPCPooledChannel *channel = - [[GRPCChannelPool sharedInstance] channelWithHost:_host callOptions:_callOptions]; - _wrappedCall = [channel wrappedCallWithPath:_path - completionQueue:[GRPCCompletionQueue completionQueue] - callOptions:_callOptions]; - - if (_wrappedCall == nil) { - [self finishWithError:[NSError errorWithDomain:kGRPCErrorDomain - code:GRPCErrorCodeUnavailable - userInfo:@{ - NSLocalizedDescriptionKey : - @"Failed to create call or channel." - }]]; - return; - } - - [self sendHeaders]; - [self invokeCall]; - } - - // Now that the RPC has been initiated, request writes can start. - [_requestWriter startWithWriteable:self]; -} - -- (void)startWithWriteable:(id)writeable { - id tokenProvider = nil; - @synchronized(self) { - _state = GRXWriterStateStarted; - - // Create a retain cycle so that this instance lives until the RPC finishes (or is cancelled). - // This makes RPCs in which the call isn't externally retained possible (as long as it is - // started before being autoreleased). Care is taken not to retain self strongly in any of the - // blocks used in this implementation, so that the life of the instance is determined by this - // retain cycle. - _retainSelf = self; - - // If _callOptions is nil, people must be using the deprecated v1 interface. In this case, - // generate the call options from the corresponding GRPCHost configs and apply other options - // that are not covered by GRPCHost. - if (_callOptions == nil) { - GRPCMutableCallOptions *callOptions = [[GRPCHost callOptionsForHost:_host] mutableCopy]; - if (_serverName.length != 0) { - callOptions.serverAuthority = _serverName; - } - if (_timeout > 0) { - callOptions.timeout = _timeout; - } - uint32_t callFlags = [GRPCCall callFlagsForHost:_host path:_path]; - if (callFlags != 0) { - if (callFlags == GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) { - _callSafety = GRPCCallSafetyIdempotentRequest; - } else if (callFlags == GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) { - _callSafety = GRPCCallSafetyCacheableRequest; - } - } - - id tokenProvider = self.tokenProvider; - if (tokenProvider != nil) { - callOptions.authTokenProvider = tokenProvider; - } - _callOptions = callOptions; - } - - NSAssert(_callOptions.authTokenProvider == nil || _callOptions.oauth2AccessToken == nil, - @"authTokenProvider and oauth2AccessToken cannot be set at the same time"); - - tokenProvider = _callOptions.authTokenProvider; - } - - if (tokenProvider != nil) { - __weak typeof(self) weakSelf = self; - [tokenProvider getTokenWithHandler:^(NSString *token) { - __strong typeof(self) strongSelf = weakSelf; - if (strongSelf) { - BOOL startCall = NO; - @synchronized(strongSelf) { - if (strongSelf->_state != GRXWriterStateFinished) { - startCall = YES; - if (token) { - strongSelf->_fetchedOauth2AccessToken = [token copy]; - } - } - } - if (startCall) { - [strongSelf startCallWithWriteable:writeable]; - } - } - }]; - } else { - [self startCallWithWriteable:writeable]; - } -} - -- (void)setState:(GRXWriterState)newState { - @synchronized(self) { - // Manual transitions are only allowed from the started or paused states. - if (_state == GRXWriterStateNotStarted || _state == GRXWriterStateFinished) { - return; - } - - switch (newState) { - case GRXWriterStateFinished: - _state = newState; - // Per GRXWriter's contract, setting the state to Finished manually - // means one doesn't wish the writeable to be messaged anymore. - [_responseWriteable cancelSilently]; - _responseWriteable = nil; - return; - case GRXWriterStatePaused: - _state = newState; - return; - case GRXWriterStateStarted: - if (_state == GRXWriterStatePaused) { - _state = newState; - [self maybeStartNextRead]; - } - return; - case GRXWriterStateNotStarted: - return; - } - } -} - -@end diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.h b/src/objective-c/GRPCClient/GRPCCallOptions.h index e4261b5b5f9..98511e3f5cb 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.h +++ b/src/objective-c/GRPCClient/GRPCCallOptions.h @@ -18,11 +18,57 @@ #import -#import "GRPCTypes.h" - NS_ASSUME_NONNULL_BEGIN -@protocol GRPCInterceptorFactory; +/** + * Safety remark of a gRPC method as defined in RFC 2616 Section 9.1 + */ +typedef NS_ENUM(NSUInteger, GRPCCallSafety) { + /** Signal that there is no guarantees on how the call affects the server state. */ + GRPCCallSafetyDefault = 0, + /** Signal that the call is idempotent. gRPC is free to use PUT verb. */ + GRPCCallSafetyIdempotentRequest = 1, + /** + * Signal that the call is cacheable and will not affect server state. gRPC is free to use GET + * verb. + */ + GRPCCallSafetyCacheableRequest = 2, +}; + +// Compression algorithm to be used by a gRPC call +typedef NS_ENUM(NSUInteger, GRPCCompressionAlgorithm) { + GRPCCompressNone = 0, + GRPCCompressDeflate, + GRPCCompressGzip, + GRPCStreamCompressGzip, +}; + +// GRPCCompressAlgorithm is deprecated; use GRPCCompressionAlgorithm +typedef GRPCCompressionAlgorithm GRPCCompressAlgorithm; + +/** The transport to be used by a gRPC call */ +typedef NS_ENUM(NSUInteger, GRPCTransportType) { + GRPCTransportTypeDefault = 0, + /** gRPC internal HTTP/2 stack with BoringSSL */ + GRPCTransportTypeChttp2BoringSSL = 0, + /** Cronet stack */ + GRPCTransportTypeCronet, + /** Insecure channel. FOR TEST ONLY! */ + GRPCTransportTypeInsecure, +}; + +/** + * Implement this protocol to provide a token to gRPC when a call is initiated. + */ +@protocol GRPCAuthorizationProtocol + +/** + * This method is called when gRPC is about to start the call. When OAuth token is acquired, + * \a handler is expected to be called with \a token being the new token to be used for this call. + */ +- (void)getTokenWithHandler:(void (^)(NSString *_Nullable token))handler; + +@end @interface GRPCCallOptions : NSObject @@ -58,7 +104,7 @@ NS_ASSUME_NONNULL_BEGIN * this array. This parameter should not be modified by any interceptor and will * not take effect if done so. */ -@property(copy, readonly) NSArray> *interceptorFactories; +@property(copy, readonly) NSArray *interceptorFactories; // OAuth2 parameters. Users of gRPC may specify one of the following two parameters. @@ -146,23 +192,10 @@ NS_ASSUME_NONNULL_BEGIN @property(copy, readonly, nullable) NSString *PEMCertificateChain; /** - * Deprecated: this option is deprecated. Please use the property \a transport - * instead. - * * Select the transport type to be used for this call. */ @property(readonly) GRPCTransportType transportType; -/** - * The transport to be used for this call. Users may choose a native transport - * identifier defined in \a GRPCTransport or provided by a non-native transport - * implementation. If the option is left to be NULL, gRPC will use its default - * transport. - * - * This is currently an experimental option. - */ -@property(readonly) GRPCTransportId transport; - /** * Override the hostname during the TLS hostname validation process. */ @@ -234,7 +267,7 @@ NS_ASSUME_NONNULL_BEGIN * this array. This parameter should not be modified by any interceptor and will * not take effect if done so. */ -@property(copy, readwrite) NSArray> *interceptorFactories; +@property(copy, readwrite) NSArray *interceptorFactories; // OAuth2 parameters. Users of gRPC may specify one of the following two parameters. @@ -324,23 +357,10 @@ NS_ASSUME_NONNULL_BEGIN @property(copy, readwrite, nullable) NSString *PEMCertificateChain; /** - * Deprecated: this option is deprecated. Please use the property \a transport - * instead. - * * Select the transport type to be used for this call. */ @property(readwrite) GRPCTransportType transportType; -/** - * The transport to be used for this call. Users may choose a native transport - * identifier defined in \a GRPCTransport or provided by a non-native ttransport - * implementation. If the option is left to be NULL, gRPC will use its default - * transport. - * - * An interceptor must not change the value of this option. - */ -@property(readwrite) GRPCTransportId transport; - /** * Override the hostname during the TLS hostname validation process. */ diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.m b/src/objective-c/GRPCClient/GRPCCallOptions.m index 7f88098eb6f..392e42a9d47 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.m +++ b/src/objective-c/GRPCClient/GRPCCallOptions.m @@ -17,14 +17,13 @@ */ #import "GRPCCallOptions.h" -#import "GRPCTransport.h" #import "internal/GRPCCallOptions+Internal.h" // The default values for the call options. static NSString *const kDefaultServerAuthority = nil; static const NSTimeInterval kDefaultTimeout = 0; static const BOOL kDefaultFlowControlEnabled = NO; -static NSArray> *const kDefaultInterceptorFactories = nil; +static NSArray *const kDefaultInterceptorFactories = nil; static NSDictionary *const kDefaultInitialMetadata = nil; static NSString *const kDefaultUserAgentPrefix = nil; static const NSUInteger kDefaultResponseSizeLimit = 0; @@ -42,7 +41,6 @@ static NSString *const kDefaultPEMCertificateChain = nil; static NSString *const kDefaultOauth2AccessToken = nil; static const id kDefaultAuthTokenProvider = nil; static const GRPCTransportType kDefaultTransportType = GRPCTransportTypeChttp2BoringSSL; -static const GRPCTransportId kDefaultTransport = NULL; static NSString *const kDefaultHostNameOverride = nil; static const id kDefaultLogContext = nil; static NSString *const kDefaultChannelPoolDomain = nil; @@ -64,7 +62,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { NSString *_serverAuthority; NSTimeInterval _timeout; BOOL _flowControlEnabled; - NSArray> *_interceptorFactories; + NSArray *_interceptorFactories; NSString *_oauth2AccessToken; id _authTokenProvider; NSDictionary *_initialMetadata; @@ -82,7 +80,6 @@ static BOOL areObjectsEqual(id obj1, id obj2) { NSString *_PEMPrivateKey; NSString *_PEMCertificateChain; GRPCTransportType _transportType; - GRPCTransportId _transport; NSString *_hostNameOverride; id _logContext; NSString *_channelPoolDomain; @@ -110,7 +107,6 @@ static BOOL areObjectsEqual(id obj1, id obj2) { @synthesize PEMPrivateKey = _PEMPrivateKey; @synthesize PEMCertificateChain = _PEMCertificateChain; @synthesize transportType = _transportType; -@synthesize transport = _transport; @synthesize hostNameOverride = _hostNameOverride; @synthesize logContext = _logContext; @synthesize channelPoolDomain = _channelPoolDomain; @@ -138,7 +134,6 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:kDefaultPEMPrivateKey PEMCertificateChain:kDefaultPEMCertificateChain transportType:kDefaultTransportType - transport:kDefaultTransport hostNameOverride:kDefaultHostNameOverride logContext:kDefaultLogContext channelPoolDomain:kDefaultChannelPoolDomain @@ -148,7 +143,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { - (instancetype)initWithServerAuthority:(NSString *)serverAuthority timeout:(NSTimeInterval)timeout flowControlEnabled:(BOOL)flowControlEnabled - interceptorFactories:(NSArray> *)interceptorFactories + interceptorFactories:(NSArray *)interceptorFactories oauth2AccessToken:(NSString *)oauth2AccessToken authTokenProvider:(id)authTokenProvider initialMetadata:(NSDictionary *)initialMetadata @@ -166,7 +161,6 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:(NSString *)PEMPrivateKey PEMCertificateChain:(NSString *)PEMCertificateChain transportType:(GRPCTransportType)transportType - transport:(GRPCTransportId)transport hostNameOverride:(NSString *)hostNameOverride logContext:(id)logContext channelPoolDomain:(NSString *)channelPoolDomain @@ -199,7 +193,6 @@ static BOOL areObjectsEqual(id obj1, id obj2) { _PEMPrivateKey = [PEMPrivateKey copy]; _PEMCertificateChain = [PEMCertificateChain copy]; _transportType = transportType; - _transport = transport; _hostNameOverride = [hostNameOverride copy]; _logContext = logContext; _channelPoolDomain = [channelPoolDomain copy]; @@ -231,7 +224,6 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:_PEMPrivateKey PEMCertificateChain:_PEMCertificateChain transportType:_transportType - transport:_transport hostNameOverride:_hostNameOverride logContext:_logContext channelPoolDomain:_channelPoolDomain @@ -264,7 +256,6 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:[_PEMPrivateKey copy] PEMCertificateChain:[_PEMCertificateChain copy] transportType:_transportType - transport:_transport hostNameOverride:[_hostNameOverride copy] logContext:_logContext channelPoolDomain:[_channelPoolDomain copy] @@ -289,7 +280,6 @@ static BOOL areObjectsEqual(id obj1, id obj2) { if (!areObjectsEqual(callOptions.PEMCertificateChain, _PEMCertificateChain)) return NO; if (!areObjectsEqual(callOptions.hostNameOverride, _hostNameOverride)) return NO; if (!(callOptions.transportType == _transportType)) return NO; - if (!(TransportIdIsEqual(callOptions.transport, _transport))) return NO; if (!areObjectsEqual(callOptions.logContext, _logContext)) return NO; if (!areObjectsEqual(callOptions.channelPoolDomain, _channelPoolDomain)) return NO; if (!(callOptions.channelID == _channelID)) return NO; @@ -314,7 +304,6 @@ static BOOL areObjectsEqual(id obj1, id obj2) { result ^= _PEMCertificateChain.hash; result ^= _hostNameOverride.hash; result ^= _transportType; - result ^= TransportIdHash(_transport); result ^= _logContext.hash; result ^= _channelPoolDomain.hash; result ^= _channelID; @@ -347,7 +336,6 @@ static BOOL areObjectsEqual(id obj1, id obj2) { @dynamic PEMPrivateKey; @dynamic PEMCertificateChain; @dynamic transportType; -@dynamic transport; @dynamic hostNameOverride; @dynamic logContext; @dynamic channelPoolDomain; @@ -375,7 +363,6 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:kDefaultPEMPrivateKey PEMCertificateChain:kDefaultPEMCertificateChain transportType:kDefaultTransportType - transport:kDefaultTransport hostNameOverride:kDefaultHostNameOverride logContext:kDefaultLogContext channelPoolDomain:kDefaultChannelPoolDomain @@ -405,7 +392,6 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:_PEMPrivateKey PEMCertificateChain:_PEMCertificateChain transportType:_transportType - transport:_transport hostNameOverride:_hostNameOverride logContext:_logContext channelPoolDomain:_channelPoolDomain @@ -436,7 +422,6 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:_PEMPrivateKey PEMCertificateChain:_PEMCertificateChain transportType:_transportType - transport:_transport hostNameOverride:_hostNameOverride logContext:_logContext channelPoolDomain:_channelPoolDomain @@ -460,7 +445,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { _flowControlEnabled = flowControlEnabled; } -- (void)setInterceptorFactories:(NSArray> *)interceptorFactories { +- (void)setInterceptorFactories:(NSArray *)interceptorFactories { _interceptorFactories = interceptorFactories; } @@ -553,10 +538,6 @@ static BOOL areObjectsEqual(id obj1, id obj2) { _transportType = transportType; } -- (void)setTransport:(GRPCTransportId)transport { - _transport = transport; -} - - (void)setHostNameOverride:(NSString *)hostNameOverride { _hostNameOverride = [hostNameOverride copy]; } diff --git a/src/objective-c/GRPCClient/GRPCDispatchable.h b/src/objective-c/GRPCClient/GRPCDispatchable.h deleted file mode 100644 index 650103603d4..00000000000 --- a/src/objective-c/GRPCClient/GRPCDispatchable.h +++ /dev/null @@ -1,30 +0,0 @@ - -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/** - * An object that processes its methods with a dispatch queue. - */ -@protocol GRPCDispatchable - -/** - * The dispatch queue where the object's methods should be run on. - */ -@property(atomic, readonly) dispatch_queue_t dispatchQueue; - -@end diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.h b/src/objective-c/GRPCClient/GRPCInterceptor.h index 509749769b3..3b62c1b3ec0 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.h +++ b/src/objective-c/GRPCClient/GRPCInterceptor.h @@ -106,20 +106,22 @@ */ #import "GRPCCall.h" -#import "GRPCDispatchable.h" NS_ASSUME_NONNULL_BEGIN @class GRPCInterceptorManager; @class GRPCInterceptor; -@class GRPCRequestOptions; -@class GRPCCallOptions; -@protocol GRPCResponseHandler; /** * The GRPCInterceptorInterface defines the request events that can occur to an interceptr. */ -@protocol GRPCInterceptorInterface +@protocol GRPCInterceptorInterface + +/** + * The queue on which all methods of this interceptor should be dispatched on. The queue must be a + * serial queue. + */ +@property(readonly) dispatch_queue_t requestDispatchQueue; /** * To start the call. This method will only be called once for each instance. @@ -169,20 +171,19 @@ NS_ASSUME_NONNULL_BEGIN * invoke shutDown method of its corresponding manager so that references to other interceptors can * be released. */ -@interface GRPCInterceptorManager : NSObject +@interface GRPCInterceptorManager : NSObject - (instancetype)init NS_UNAVAILABLE; + (instancetype) new NS_UNAVAILABLE; -- (nullable instancetype)initWithFactories:(nullable NSArray> *)factories - previousInterceptor:(nullable id)previousInterceptor - transportId:(GRPCTransportId)transportId; +- (nullable instancetype)initWithNextInterceptor:(id)nextInterceptor + NS_DESIGNATED_INITIALIZER; -/** - * Notify the manager that the interceptor has shut down and the manager should release references - * to other interceptors and stop forwarding requests/responses. - */ +/** Set the previous interceptor in the chain. Can only be set once. */ +- (void)setPreviousInterceptor:(id)previousInterceptor; + +/** Indicate shutdown of the interceptor; release the reference to other interceptors */ - (void)shutDown; // Methods to forward GRPCInterceptorInterface calls to the next interceptor @@ -234,6 +235,7 @@ NS_ASSUME_NONNULL_BEGIN @interface GRPCInterceptor : NSObject - (instancetype)init NS_UNAVAILABLE; + + (instancetype) new NS_UNAVAILABLE; /** @@ -241,7 +243,9 @@ NS_ASSUME_NONNULL_BEGIN * that this interceptor's methods are dispatched onto. */ - (nullable instancetype)initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - dispatchQueue:(dispatch_queue_t)dispatchQueue; + requestDispatchQueue:(dispatch_queue_t)requestDispatchQueue + responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue + NS_DESIGNATED_INITIALIZER; // Default implementation of GRPCInterceptorInterface diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.m b/src/objective-c/GRPCClient/GRPCInterceptor.m index a7ffe05bddc..a385ecd7813 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.m +++ b/src/objective-c/GRPCClient/GRPCInterceptor.m @@ -19,253 +19,117 @@ #import #import "GRPCInterceptor.h" -#import "private/GRPCTransport+Private.h" - -@interface GRPCInterceptorManager () - -@end @implementation GRPCInterceptorManager { id _nextInterceptor; id _previousInterceptor; - GRPCInterceptor *_thisInterceptor; - dispatch_queue_t _dispatchQueue; - NSArray> *_factories; - GRPCTransportId _transportId; - BOOL _shutDown; } -- (instancetype)initWithFactories:(NSArray> *)factories - previousInterceptor:(id)previousInterceptor - transportId:(nonnull GRPCTransportId)transportId { +- (instancetype)initWithNextInterceptor:(id)nextInterceptor { if ((self = [super init])) { - if (factories.count == 0) { - [NSException raise:NSInternalInconsistencyException - format:@"Interceptor manager must have factories"]; - } - _thisInterceptor = [factories[0] createInterceptorWithManager:self]; - if (_thisInterceptor == nil) { - return nil; - } - _previousInterceptor = previousInterceptor; - _factories = factories; - // Generate interceptor -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 - if (@available(iOS 8.0, macOS 10.10, *)) { - _dispatchQueue = dispatch_queue_create( - NULL, - dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); - } else { -#else - { -#endif - _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); - } - dispatch_set_target_queue(_dispatchQueue, _thisInterceptor.dispatchQueue); - _transportId = transportId; + _nextInterceptor = nextInterceptor; } + return self; } -- (void)shutDown { - dispatch_async(_dispatchQueue, ^{ - self->_nextInterceptor = nil; - self->_previousInterceptor = nil; - self->_thisInterceptor = nil; - self->_shutDown = YES; - }); +- (void)setPreviousInterceptor:(id)previousInterceptor { + _previousInterceptor = previousInterceptor; } -- (void)createNextInterceptor { - NSAssert(_nextInterceptor == nil, @"Starting the next interceptor more than once"); - NSAssert(_factories.count > 0, @"Interceptor manager of transport cannot start next interceptor"); - if (_nextInterceptor != nil) { - NSLog(@"Starting the next interceptor more than once"); - return; - } - NSMutableArray> *interceptorFactories = [NSMutableArray - arrayWithArray:[_factories subarrayWithRange:NSMakeRange(1, _factories.count - 1)]]; - while (_nextInterceptor == nil) { - if (interceptorFactories.count == 0) { - _nextInterceptor = - [[GRPCTransportManager alloc] initWithTransportId:_transportId previousInterceptor:self]; - break; - } else { - _nextInterceptor = [[GRPCInterceptorManager alloc] initWithFactories:interceptorFactories - previousInterceptor:self - transportId:_transportId]; - if (_nextInterceptor == nil) { - [interceptorFactories removeObjectAtIndex:0]; - } - } - } - NSAssert(_nextInterceptor != nil, @"Failed to create interceptor or transport."); - if (_nextInterceptor == nil) { - NSLog(@"Failed to create interceptor or transport."); - } +- (void)shutDown { + _nextInterceptor = nil; + _previousInterceptor = nil; } - (void)startNextInterceptorWithRequest:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { - if (_nextInterceptor == nil && !_shutDown) { - [self createNextInterceptor]; + if (_nextInterceptor != nil) { + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ + [copiedNextInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; + }); } - if (_nextInterceptor == nil) { - return; - } - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ - [copiedNextInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; - }); } - (void)writeNextInterceptorWithData:(id)data { - if (_nextInterceptor == nil && !_shutDown) { - [self createNextInterceptor]; + if (_nextInterceptor != nil) { + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ + [copiedNextInterceptor writeData:data]; + }); } - if (_nextInterceptor == nil) { - return; - } - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ - [copiedNextInterceptor writeData:data]; - }); } - (void)finishNextInterceptor { - if (_nextInterceptor == nil && !_shutDown) { - [self createNextInterceptor]; + if (_nextInterceptor != nil) { + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ + [copiedNextInterceptor finish]; + }); } - if (_nextInterceptor == nil) { - return; - } - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ - [copiedNextInterceptor finish]; - }); } - (void)cancelNextInterceptor { - if (_nextInterceptor == nil && !_shutDown) { - [self createNextInterceptor]; + if (_nextInterceptor != nil) { + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ + [copiedNextInterceptor cancel]; + }); } - if (_nextInterceptor == nil) { - return; - } - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ - [copiedNextInterceptor cancel]; - }); } /** Notify the next interceptor in the chain to receive more messages */ - (void)receiveNextInterceptorMessages:(NSUInteger)numberOfMessages { - if (_nextInterceptor == nil && !_shutDown) { - [self createNextInterceptor]; + if (_nextInterceptor != nil) { + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ + [copiedNextInterceptor receiveNextMessages:numberOfMessages]; + }); } - if (_nextInterceptor == nil) { - return; - } - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ - [copiedNextInterceptor receiveNextMessages:numberOfMessages]; - }); } // Methods to forward GRPCResponseHandler callbacks to the previous object /** Forward initial metadata to the previous interceptor in the chain */ -- (void)forwardPreviousInterceptorWithInitialMetadata:(NSDictionary *)initialMetadata { - if (_previousInterceptor == nil) { - return; +- (void)forwardPreviousInterceptorWithInitialMetadata:(nullable NSDictionary *)initialMetadata { + if ([_previousInterceptor respondsToSelector:@selector(didReceiveInitialMetadata:)]) { + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didReceiveInitialMetadata:initialMetadata]; + }); } - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didReceiveInitialMetadata:initialMetadata]; - }); } /** Forward a received message to the previous interceptor in the chain */ - (void)forwardPreviousInterceptorWithData:(id)data { - if (_previousInterceptor == nil) { - return; + if ([_previousInterceptor respondsToSelector:@selector(didReceiveData:)]) { + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didReceiveData:data]; + }); } - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didReceiveData:data]; - }); } /** Forward call close and trailing metadata to the previous interceptor in the chain */ -- (void)forwardPreviousInterceptorCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata - error:(NSError *)error { - if (_previousInterceptor == nil) { - return; +- (void)forwardPreviousInterceptorCloseWithTrailingMetadata: + (nullable NSDictionary *)trailingMetadata + error:(nullable NSError *)error { + if ([_previousInterceptor respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; + }); } - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; - }); } /** Forward write completion to the previous interceptor in the chain */ - (void)forwardPreviousInterceptorDidWriteData { - if (_previousInterceptor == nil) { - return; - } - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didWriteData]; - }); -} - -- (dispatch_queue_t)dispatchQueue { - return _dispatchQueue; -} - -- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions - callOptions:(GRPCCallOptions *)callOptions { - [_thisInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; -} - -- (void)writeData:(id)data { - [_thisInterceptor writeData:data]; -} - -- (void)finish { - [_thisInterceptor finish]; -} - -- (void)cancel { - [_thisInterceptor cancel]; -} - -- (void)receiveNextMessages:(NSUInteger)numberOfMessages { - [_thisInterceptor receiveNextMessages:numberOfMessages]; -} - -- (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata { - if ([_thisInterceptor respondsToSelector:@selector(didReceiveInitialMetadata:)]) { - [_thisInterceptor didReceiveInitialMetadata:initialMetadata]; - } -} - -- (void)didReceiveData:(id)data { - if ([_thisInterceptor respondsToSelector:@selector(didReceiveData:)]) { - [_thisInterceptor didReceiveData:data]; - } -} - -- (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata - error:(nullable NSError *)error { - if ([_thisInterceptor respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { - [_thisInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; - } -} - -- (void)didWriteData { - if ([_thisInterceptor respondsToSelector:@selector(didWriteData)]) { - [_thisInterceptor didWriteData]; + if ([_previousInterceptor respondsToSelector:@selector(didWriteData)]) { + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didWriteData]; + }); } } @@ -273,21 +137,28 @@ @implementation GRPCInterceptor { GRPCInterceptorManager *_manager; - dispatch_queue_t _dispatchQueue; + dispatch_queue_t _requestDispatchQueue; + dispatch_queue_t _responseDispatchQueue; } - (instancetype)initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - dispatchQueue:(dispatch_queue_t)dispatchQueue { + requestDispatchQueue:(dispatch_queue_t)requestDispatchQueue + responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue { if ((self = [super init])) { _manager = interceptorManager; - _dispatchQueue = dispatchQueue; + _requestDispatchQueue = requestDispatchQueue; + _responseDispatchQueue = responseDispatchQueue; } return self; } +- (dispatch_queue_t)requestDispatchQueue { + return _requestDispatchQueue; +} + - (dispatch_queue_t)dispatchQueue { - return _dispatchQueue; + return _responseDispatchQueue; } - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions diff --git a/src/objective-c/GRPCClient/GRPCTransport.h b/src/objective-c/GRPCClient/GRPCTransport.h deleted file mode 100644 index d5637922152..00000000000 --- a/src/objective-c/GRPCClient/GRPCTransport.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// The interface for a transport implementation - -#import "GRPCInterceptor.h" - -NS_ASSUME_NONNULL_BEGIN - -#pragma mark Transport ID - -/** - * The default transport implementations available in gRPC. These implementations will be provided - * by gRPC by default unless explicitly excluded. - */ -extern const struct GRPCDefaultTransportImplList { - const GRPCTransportId core_secure; - const GRPCTransportId core_insecure; -} GRPCDefaultTransportImplList; - -/** Returns whether two transport id's are identical. */ -BOOL TransportIdIsEqual(GRPCTransportId lhs, GRPCTransportId rhs); - -/** Returns the hash value of a transport id. */ -NSUInteger TransportIdHash(GRPCTransportId); - -#pragma mark Transport and factory - -@protocol GRPCInterceptorInterface; -@protocol GRPCResponseHandler; -@class GRPCTransportManager; -@class GRPCRequestOptions; -@class GRPCCallOptions; -@class GRPCTransport; - -/** The factory method to create a transport. */ -@protocol GRPCTransportFactory - -- (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager; - -@end - -/** The registry of transport implementations. */ -@interface GRPCTransportRegistry : NSObject - -+ (instancetype)sharedInstance; - -/** - * Register a transport implementation with the registry. All transport implementations to be used - * in a process must register with the registry on process start-up in its +load: class method. - * Parameter \a transportId is the identifier of the implementation, and \a factory is the factory - * object to create the corresponding transport instance. - */ -- (void)registerTransportWithId:(GRPCTransportId)transportId - factory:(id)factory; - -@end - -/** - * Base class for transport implementations. All transport implementation should inherit from this - * class. - */ -@interface GRPCTransport : NSObject - -@end - -NS_ASSUME_NONNULL_END diff --git a/src/objective-c/GRPCClient/GRPCTransport.m b/src/objective-c/GRPCClient/GRPCTransport.m deleted file mode 100644 index 439acfb9cc2..00000000000 --- a/src/objective-c/GRPCClient/GRPCTransport.m +++ /dev/null @@ -1,142 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import "GRPCTransport.h" - -static const GRPCTransportId gGRPCCoreSecureId = "io.grpc.transport.core.secure"; -static const GRPCTransportId gGRPCCoreInsecureId = "io.grpc.transport.core.insecure"; - -const struct GRPCDefaultTransportImplList GRPCDefaultTransportImplList = { - .core_secure = gGRPCCoreSecureId, .core_insecure = gGRPCCoreInsecureId}; - -static const GRPCTransportId gDefaultTransportId = gGRPCCoreSecureId; - -static GRPCTransportRegistry *gTransportRegistry = nil; -static dispatch_once_t initTransportRegistry; - -BOOL TransportIdIsEqual(GRPCTransportId lhs, GRPCTransportId rhs) { - // Directly comparing pointers works because we require users to use the id provided by each - // implementation, not coming up with their own string. - return lhs == rhs; -} - -NSUInteger TransportIdHash(GRPCTransportId transportId) { - if (transportId == NULL) { - transportId = gDefaultTransportId; - } - return [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding].hash; -} - -@implementation GRPCTransportRegistry { - NSMutableDictionary> *_registry; - id _defaultFactory; -} - -+ (instancetype)sharedInstance { - dispatch_once(&initTransportRegistry, ^{ - gTransportRegistry = [[GRPCTransportRegistry alloc] init]; - NSAssert(gTransportRegistry != nil, @"Unable to initialize transport registry."); - if (gTransportRegistry == nil) { - NSLog(@"Unable to initialize transport registry."); - [NSException raise:NSGenericException format:@"Unable to initialize transport registry."]; - } - }); - return gTransportRegistry; -} - -- (instancetype)init { - if ((self = [super init])) { - _registry = [NSMutableDictionary dictionary]; - } - return self; -} - -- (void)registerTransportWithId:(GRPCTransportId)transportId - factory:(id)factory { - NSString *nsTransportId = [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding]; - NSAssert(_registry[nsTransportId] == nil, @"The transport %@ has already been registered.", - nsTransportId); - if (_registry[nsTransportId] != nil) { - NSLog(@"The transport %@ has already been registered.", nsTransportId); - return; - } - _registry[nsTransportId] = factory; - - // if the default transport is registered, mark it. - if (0 == strcmp(transportId, gDefaultTransportId)) { - _defaultFactory = factory; - } -} - -- (id)getTransportFactoryWithId:(GRPCTransportId)transportId { - if (transportId == NULL) { - if (_defaultFactory == nil) { - [NSException raise:NSInvalidArgumentException - format:@"Unable to get default transport factory"]; - return nil; - } - return _defaultFactory; - } - NSString *nsTransportId = [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding]; - id transportFactory = _registry[nsTransportId]; - if (transportFactory == nil) { - // User named a transport id that was not registered with the registry. - [NSException raise:NSInvalidArgumentException - format:@"Unable to get transport factory with id %s", transportId]; - return nil; - } - return transportFactory; -} - -@end - -@implementation GRPCTransport - -- (dispatch_queue_t)dispatchQueue { - [NSException raise:NSGenericException - format:@"Implementations should override the dispatch queue"]; - return nil; -} - -- (void)startWithRequestOptions:(nonnull GRPCRequestOptions *)requestOptions - callOptions:(nonnull GRPCCallOptions *)callOptions { - [NSException raise:NSGenericException - format:@"Implementations should override the methods of GRPCTransport"]; -} - -- (void)writeData:(nonnull id)data { - [NSException raise:NSGenericException - format:@"Implementations should override the methods of GRPCTransport"]; -} - -- (void)cancel { - [NSException raise:NSGenericException - format:@"Implementations should override the methods of GRPCTransport"]; -} - -- (void)finish { - [NSException raise:NSGenericException - format:@"Implementations should override the methods of GRPCTransport"]; -} - -- (void)receiveNextMessages:(NSUInteger)numberOfMessages { - [NSException raise:NSGenericException - format:@"Implementations should override the methods of GRPCTransport"]; -} - -@end diff --git a/src/objective-c/GRPCClient/GRPCTypes.h b/src/objective-c/GRPCClient/GRPCTypes.h deleted file mode 100644 index c804bca4eaa..00000000000 --- a/src/objective-c/GRPCClient/GRPCTypes.h +++ /dev/null @@ -1,187 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/** - * gRPC error codes. - * Note that a few of these are never produced by the gRPC libraries, but are of - * general utility for server applications to produce. - */ -typedef NS_ENUM(NSUInteger, GRPCErrorCode) { - /** The operation was cancelled (typically by the caller). */ - GRPCErrorCodeCancelled = 1, - - /** - * Unknown error. Errors raised by APIs that do not return enough error - * information may be converted to this error. - */ - GRPCErrorCodeUnknown = 2, - - /** - * The client specified an invalid argument. Note that this differs from - * FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments that are - * problematic regardless of the state of the server (e.g., a malformed file - * name). - */ - GRPCErrorCodeInvalidArgument = 3, - - /** - * Deadline expired before operation could complete. For operations that - * change the state of the server, this error may be returned even if the - * operation has completed successfully. For example, a successful response - * from the server could have been delayed long enough for the deadline to - * expire. - */ - GRPCErrorCodeDeadlineExceeded = 4, - - /** Some requested entity (e.g., file or directory) was not found. */ - GRPCErrorCodeNotFound = 5, - - /** Some entity that we attempted to create (e.g., file or directory) already - exists. */ - GRPCErrorCodeAlreadyExists = 6, - - /** - * The caller does not have permission to execute the specified operation. - * PERMISSION_DENIED isn't used for rejections caused by exhausting some - * resource (RESOURCE_EXHAUSTED is used instead for those errors). - * PERMISSION_DENIED doesn't indicate a failure to identify the caller - * (UNAUTHENTICATED is used instead for those errors). - */ - GRPCErrorCodePermissionDenied = 7, - - /** - * The request does not have valid authentication credentials for the - * operation (e.g. the caller's identity can't be verified). - */ - GRPCErrorCodeUnauthenticated = 16, - - /** Some resource has been exhausted, perhaps a per-user quota. */ - GRPCErrorCodeResourceExhausted = 8, - - /** - * The RPC was rejected because the server is not in a state required for the - * procedure's execution. For example, a directory to be deleted may be - * non-empty, etc. The client should not retry until the server state has been - * explicitly fixed (e.g. by performing another RPC). The details depend on - * the service being called, and should be found in the NSError's userInfo. - */ - GRPCErrorCodeFailedPrecondition = 9, - - /** - * The RPC was aborted, typically due to a concurrency issue like sequencer - * check failures, transaction aborts, etc. The client should retry at a - * higher-level (e.g., restarting a read- modify-write sequence). - */ - GRPCErrorCodeAborted = 10, - - /** - * The RPC was attempted past the valid range. E.g., enumerating past the end - * of a list. Unlike INVALID_ARGUMENT, this error indicates a problem that may - * be fixed if the system state changes. For example, an RPC to get elements - * of a list will generate INVALID_ARGUMENT if asked to return the element at - * a negative index, but it will generate OUT_OF_RANGE if asked to return the - * element at an index past the current size of the list. - */ - GRPCErrorCodeOutOfRange = 11, - - /** The procedure is not implemented or not supported/enabled in this server. - */ - GRPCErrorCodeUnimplemented = 12, - - /** - * Internal error. Means some invariant expected by the server application or - * the gRPC library has been broken. - */ - GRPCErrorCodeInternal = 13, - - /** - * The server is currently unavailable. This is most likely a transient - * condition and may be corrected by retrying with a backoff. Note that it is - * not always safe to retry non-idempotent operations. - */ - GRPCErrorCodeUnavailable = 14, - - /** Unrecoverable data loss or corruption. */ - GRPCErrorCodeDataLoss = 15, -}; - -/** - * Safety remark of a gRPC method as defined in RFC 2616 Section 9.1 - */ -typedef NS_ENUM(NSUInteger, GRPCCallSafety) { - /** - * Signal that there is no guarantees on how the call affects the server - * state. - */ - GRPCCallSafetyDefault = 0, - /** Signal that the call is idempotent. gRPC is free to use PUT verb. */ - GRPCCallSafetyIdempotentRequest = 1, - /** - * Signal that the call is cacheable and will not affect server state. gRPC is - * free to use GET verb. - */ - GRPCCallSafetyCacheableRequest = 2, -}; - -// Compression algorithm to be used by a gRPC call -typedef NS_ENUM(NSUInteger, GRPCCompressionAlgorithm) { - GRPCCompressNone = 0, - GRPCCompressDeflate, - GRPCCompressGzip, - GRPCStreamCompressGzip, -}; - -// GRPCCompressAlgorithm is deprecated; use GRPCCompressionAlgorithm -typedef GRPCCompressionAlgorithm GRPCCompressAlgorithm; - -/** The transport to be used by a gRPC call */ -typedef NS_ENUM(NSUInteger, GRPCTransportType) { - GRPCTransportTypeDefault = 0, - /** gRPC internal HTTP/2 stack with BoringSSL */ - GRPCTransportTypeChttp2BoringSSL = 0, - /** Cronet stack */ - GRPCTransportTypeCronet, - /** Insecure channel. FOR TEST ONLY! */ - GRPCTransportTypeInsecure, -}; - -/** Domain of NSError objects produced by gRPC. */ -extern NSString* _Nonnull const kGRPCErrorDomain; - -/** - * Keys used in |NSError|'s |userInfo| dictionary to store the response headers - * and trailers sent by the server. - */ -extern NSString* _Nonnull const kGRPCHeadersKey; -extern NSString* _Nonnull const kGRPCTrailersKey; - -/** The id of a transport implementation. */ -typedef char* _Nonnull GRPCTransportId; - -/** - * Implement this protocol to provide a token to gRPC when a call is initiated. - */ -@protocol GRPCAuthorizationProtocol - -/** - * This method is called when gRPC is about to start the call. When OAuth token is acquired, - * \a handler is expected to be called with \a token being the new token to be used for this call. - */ -- (void)getTokenWithHandler:(void (^_Nonnull)(NSString* _Nullable token))handler; - -@end diff --git a/src/objective-c/GRPCClient/internal_testing/GRPCCall+InternalTests.m b/src/objective-c/GRPCClient/internal_testing/GRPCCall+InternalTests.m index 8f98daa6348..1bb352f0be2 100644 --- a/src/objective-c/GRPCClient/internal_testing/GRPCCall+InternalTests.m +++ b/src/objective-c/GRPCClient/internal_testing/GRPCCall+InternalTests.m @@ -20,7 +20,7 @@ #import "GRPCCall+InternalTests.h" -#import "../private/GRPCCore/GRPCOpBatchLog.h" +#import "../private/GRPCOpBatchLog.h" @implementation GRPCCall (InternalTests) diff --git a/src/objective-c/GRPCClient/private/GRPCCore/ChannelArgsUtil.h b/src/objective-c/GRPCClient/private/ChannelArgsUtil.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/ChannelArgsUtil.h rename to src/objective-c/GRPCClient/private/ChannelArgsUtil.h diff --git a/src/objective-c/GRPCClient/private/GRPCCore/ChannelArgsUtil.m b/src/objective-c/GRPCClient/private/ChannelArgsUtil.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/ChannelArgsUtil.m rename to src/objective-c/GRPCClient/private/ChannelArgsUtil.m diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCall+V2API.h b/src/objective-c/GRPCClient/private/GRPCCall+V2API.h similarity index 79% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCCall+V2API.h rename to src/objective-c/GRPCClient/private/GRPCCall+V2API.h index f6db3023cac..22bf16962c6 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCall+V2API.h +++ b/src/objective-c/GRPCClient/private/GRPCCall+V2API.h @@ -18,6 +18,12 @@ @interface GRPCCall (V2API) +- (instancetype)initWithHost:(NSString *)host + path:(NSString *)path + callSafety:(GRPCCallSafety)safety + requestsWriter:(GRXWriter *)requestsWriter + callOptions:(GRPCCallOptions *)callOptions; + - (instancetype)initWithHost:(NSString *)host path:(NSString *)path callSafety:(GRPCCallSafety)safety diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.h b/src/objective-c/GRPCClient/private/GRPCCallInternal.h similarity index 70% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.h rename to src/objective-c/GRPCClient/private/GRPCCallInternal.h index 641b1fb2e8a..ac2d1cba2ec 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.h +++ b/src/objective-c/GRPCClient/private/GRPCCallInternal.h @@ -16,22 +16,20 @@ * */ -#import +#import NS_ASSUME_NONNULL_BEGIN -@protocol GRPCResponseHandler; -@class GRPCCallOptions; -@protocol GRPCChannelFactory; +@interface GRPCCall2Internal : NSObject -@interface GRPCCall2Internal : GRPCTransport +- (instancetype)init; -- (instancetype)initWithTransportManager:(GRPCTransportManager *)transportManager; +- (void)setResponseHandler:(id)responseHandler; - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions - callOptions:(GRPCCallOptions *)callOptions; + callOptions:(nullable GRPCCallOptions *)callOptions; -- (void)writeData:(id)data; +- (void)writeData:(NSData *)data; - (void)finish; diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m b/src/objective-c/GRPCClient/private/GRPCCallInternal.m similarity index 69% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m rename to src/objective-c/GRPCClient/private/GRPCCallInternal.m index ea01fcaf594..32e38158fad 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m +++ b/src/objective-c/GRPCClient/private/GRPCCallInternal.m @@ -19,10 +19,8 @@ #import "GRPCCallInternal.h" #import -#import #import -#import "../GRPCTransport+Private.h" #import "GRPCCall+V2API.h" @implementation GRPCCall2Internal { @@ -30,8 +28,8 @@ GRPCRequestOptions *_requestOptions; /** Options for the call. */ GRPCCallOptions *_callOptions; - /** The interceptor manager to process responses. */ - GRPCTransportManager *_transportManager; + /** The handler of responses. */ + id _handler; /** * Make use of legacy GRPCCall to make calls. Nullified when call is finished. @@ -53,28 +51,40 @@ NSUInteger _pendingReceiveNextMessages; } -- (instancetype)initWithTransportManager:(GRPCTransportManager *)transportManager { - dispatch_queue_t dispatchQueue; +- (instancetype)init { + if ((self = [super init])) { // Set queue QoS only when iOS version is 8.0 or above and Xcode version is 9.0 or above #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 - if (@available(iOS 8.0, macOS 10.10, *)) { - dispatchQueue = dispatch_queue_create( - NULL, dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); - } else { + if (@available(iOS 8.0, macOS 10.10, *)) { + _dispatchQueue = dispatch_queue_create( + NULL, + dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); + } else { #else - { + { #endif - dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); - } - if ((self = [super init])) { + _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); + } _pipe = [GRXBufferedPipe pipe]; - _transportManager = transportManager; - _dispatchQueue = dispatchQueue; } return self; } -- (dispatch_queue_t)dispatchQueue { +- (void)setResponseHandler:(id)responseHandler { + @synchronized(self) { + NSAssert(!_started, @"Call already started."); + if (_started) { + return; + } + _handler = responseHandler; + _initialMetadataPublished = NO; + _started = NO; + _canceled = NO; + _finished = NO; + } +} + +- (dispatch_queue_t)requestDispatchQueue { return _dispatchQueue; } @@ -92,15 +102,26 @@ return; } - GRPCCall *copiedCall = nil; @synchronized(self) { + NSAssert(_handler != nil, @"Response handler required."); + if (_handler == nil) { + NSLog(@"Invalid response handler."); + return; + } _requestOptions = requestOptions; if (callOptions == nil) { _callOptions = [[GRPCCallOptions alloc] init]; } else { _callOptions = [callOptions copy]; } + } + [self start]; +} + +- (void)start { + GRPCCall *copiedCall = nil; + @synchronized(self) { NSAssert(!_started, @"Call already started."); NSAssert(!_canceled, @"Call already canceled."); if (_started) { @@ -119,7 +140,7 @@ callOptions:_callOptions writeDone:^{ @synchronized(self) { - if (self->_transportManager) { + if (self->_handler) { [self issueDidWriteData]; } } @@ -137,7 +158,7 @@ void (^valueHandler)(id value) = ^(id value) { @synchronized(self) { - if (self->_transportManager) { + if (self->_handler) { if (!self->_initialMetadataPublished) { self->_initialMetadataPublished = YES; [self issueInitialMetadata:self->_call.responseHeaders]; @@ -150,7 +171,7 @@ }; void (^completionHandler)(NSError *errorOrNil) = ^(NSError *errorOrNil) { @synchronized(self) { - if (self->_transportManager) { + if (self->_handler) { if (!self->_initialMetadataPublished) { self->_initialMetadataPublished = YES; [self issueInitialMetadata:self->_call.responseHeaders]; @@ -186,19 +207,20 @@ _call = nil; _pipe = nil; - if (_transportManager != nil) { - [_transportManager - forwardPreviousInterceptorCloseWithTrailingMetadata:nil - error: - [NSError - errorWithDomain:kGRPCErrorDomain - code: - GRPCErrorCodeCancelled - userInfo:@{ - NSLocalizedDescriptionKey : - @"Canceled by app" - }]]; - [_transportManager shutDown]; + if ([_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { + id copiedHandler = _handler; + _handler = nil; + dispatch_async(copiedHandler.dispatchQueue, ^{ + [copiedHandler didCloseWithTrailingMetadata:nil + error:[NSError errorWithDomain:kGRPCErrorDomain + code:GRPCErrorCodeCancelled + userInfo:@{ + NSLocalizedDescriptionKey : + @"Canceled by app" + }]]; + }); + } else { + _handler = nil; } } [copiedCall cancel]; @@ -249,25 +271,59 @@ } - (void)issueInitialMetadata:(NSDictionary *)initialMetadata { - if (initialMetadata != nil) { - [_transportManager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; + @synchronized(self) { + if (initialMetadata != nil && + [_handler respondsToSelector:@selector(didReceiveInitialMetadata:)]) { + id copiedHandler = _handler; + dispatch_async(_handler.dispatchQueue, ^{ + [copiedHandler didReceiveInitialMetadata:initialMetadata]; + }); + } } } - (void)issueMessage:(id)message { - if (message != nil) { - [_transportManager forwardPreviousInterceptorWithData:message]; + @synchronized(self) { + if (message != nil) { + if ([_handler respondsToSelector:@selector(didReceiveData:)]) { + id copiedHandler = _handler; + dispatch_async(_handler.dispatchQueue, ^{ + [copiedHandler didReceiveData:message]; + }); + } else if ([_handler respondsToSelector:@selector(didReceiveRawMessage:)]) { + id copiedHandler = _handler; + dispatch_async(_handler.dispatchQueue, ^{ + [copiedHandler didReceiveRawMessage:message]; + }); + } + } } } - (void)issueClosedWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { - [_transportManager forwardPreviousInterceptorCloseWithTrailingMetadata:trailingMetadata - error:error]; - [_transportManager shutDown]; + @synchronized(self) { + if ([_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { + id copiedHandler = _handler; + // Clean up _handler so that no more responses are reported to the handler. + _handler = nil; + dispatch_async(copiedHandler.dispatchQueue, ^{ + [copiedHandler didCloseWithTrailingMetadata:trailingMetadata error:error]; + }); + } else { + _handler = nil; + } + } } - (void)issueDidWriteData { - [_transportManager forwardPreviousInterceptorDidWriteData]; + @synchronized(self) { + if (_callOptions.flowControlEnabled && [_handler respondsToSelector:@selector(didWriteData)]) { + id copiedHandler = _handler; + dispatch_async(copiedHandler.dispatchQueue, ^{ + [copiedHandler didWriteData]; + }); + } + } } - (void)receiveNextMessages:(NSUInteger)numberOfMessages { diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.h b/src/objective-c/GRPCClient/private/GRPCChannel.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.h rename to src/objective-c/GRPCClient/private/GRPCChannel.h diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m similarity index 78% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m rename to src/objective-c/GRPCClient/private/GRPCChannel.m index cd2b4313acd..1a79fb04a0d 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCChannel.m @@ -20,19 +20,18 @@ #include -#import "../../internal/GRPCCallOptions+Internal.h" -#import "../GRPCTransport+Private.h" +#import "../internal/GRPCCallOptions+Internal.h" #import "ChannelArgsUtil.h" #import "GRPCChannelFactory.h" #import "GRPCChannelPool.h" #import "GRPCCompletionQueue.h" -#import "GRPCCoreFactory.h" +#import "GRPCCronetChannelFactory.h" #import "GRPCInsecureChannelFactory.h" #import "GRPCSecureChannelFactory.h" +#import "version.h" #import #import -#import @implementation GRPCChannelConfiguration @@ -51,48 +50,32 @@ } - (id)channelFactory { - if (_callOptions.transport != NULL) { - id transportFactory = - [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:_callOptions.transport]; - if (! - [transportFactory respondsToSelector:@selector(createCoreChannelFactoryWithCallOptions:)]) { - // impossible because we are using GRPCCore now - [NSException raise:NSInternalInconsistencyException - format:@"Transport factory type is wrong"]; - } - id coreTransportFactory = - (id)transportFactory; - return [coreTransportFactory createCoreChannelFactoryWithCallOptions:_callOptions]; - } else { - // To maintain backwards compatibility with tranportType - GRPCTransportType type = _callOptions.transportType; - switch (type) { - case GRPCTransportTypeChttp2BoringSSL: - // TODO (mxyan): Remove when the API is deprecated - { - NSError *error; - id factory = [GRPCSecureChannelFactory - factoryWithPEMRootCertificates:_callOptions.PEMRootCertificates - privateKey:_callOptions.PEMPrivateKey - certChain:_callOptions.PEMCertificateChain - error:&error]; - NSAssert(factory != nil, @"Failed to create secure channel factory"); - if (factory == nil) { - NSLog(@"Error creating secure channel factory: %@", error); - } - return factory; + GRPCTransportType type = _callOptions.transportType; + switch (type) { + case GRPCTransportTypeChttp2BoringSSL: + // TODO (mxyan): Remove when the API is deprecated +#ifdef GRPC_COMPILE_WITH_CRONET + if (![GRPCCall isUsingCronet]) { +#else + { +#endif + NSError *error; + id factory = [GRPCSecureChannelFactory + factoryWithPEMRootCertificates:_callOptions.PEMRootCertificates + privateKey:_callOptions.PEMPrivateKey + certChain:_callOptions.PEMCertificateChain + error:&error]; + NSAssert(factory != nil, @"Failed to create secure channel factory"); + if (factory == nil) { + NSLog(@"Error creating secure channel factory: %@", error); } - case GRPCTransportTypeCronet: { - id transportFactory = (id)[ - [GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:gGRPCCoreCronetId]; - return [transportFactory createCoreChannelFactoryWithCallOptions:_callOptions]; + return factory; } - case GRPCTransportTypeInsecure: - return [GRPCInsecureChannelFactory sharedInstance]; - default: - NSLog(@"Unrecognized transport type"); - return nil; - } + // fallthrough + case GRPCTransportTypeCronet: + return [GRPCCronetChannelFactory sharedInstance]; + case GRPCTransportTypeInsecure: + return [GRPCInsecureChannelFactory sharedInstance]; } } @@ -215,7 +198,6 @@ } else { channelArgs = channelConfiguration.channelArgs; } - id factory = channelConfiguration.channelFactory; _unmanagedChannel = [factory createChannelWithHost:host channelArgs:channelArgs]; NSAssert(_unmanagedChannel != NULL, @"Failed to create channel"); diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCChannelFactory.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelFactory.h rename to src/objective-c/GRPCClient/private/GRPCChannelFactory.h diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool+Test.h b/src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool+Test.h rename to src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.h b/src/objective-c/GRPCClient/private/GRPCChannelPool.h similarity index 98% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.h rename to src/objective-c/GRPCClient/private/GRPCChannelPool.h index b83a28a2368..e00ee69e63a 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.h +++ b/src/objective-c/GRPCClient/private/GRPCChannelPool.h @@ -18,6 +18,8 @@ #import +#import "GRPCChannelFactory.h" + NS_ASSUME_NONNULL_BEGIN @protocol GRPCChannel; diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.m b/src/objective-c/GRPCClient/private/GRPCChannelPool.m similarity index 98% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.m rename to src/objective-c/GRPCClient/private/GRPCChannelPool.m index 92f52e67b75..d545793fcce 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.m +++ b/src/objective-c/GRPCClient/private/GRPCChannelPool.m @@ -18,16 +18,19 @@ #import -#import "../../internal/GRPCCallOptions+Internal.h" +#import "../internal/GRPCCallOptions+Internal.h" #import "GRPCChannel.h" #import "GRPCChannelFactory.h" #import "GRPCChannelPool+Test.h" #import "GRPCChannelPool.h" #import "GRPCCompletionQueue.h" +#import "GRPCCronetChannelFactory.h" #import "GRPCInsecureChannelFactory.h" #import "GRPCSecureChannelFactory.h" #import "GRPCWrappedCall.h" +#import "version.h" +#import #include extern const char *kCFStreamVarName; diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.h b/src/objective-c/GRPCClient/private/GRPCCompletionQueue.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.h rename to src/objective-c/GRPCClient/private/GRPCCompletionQueue.h diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.m b/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.m rename to src/objective-c/GRPCClient/private/GRPCCompletionQueue.m diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h deleted file mode 100644 index 83d279d2c72..00000000000 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import "../GRPCCoreFactory.h" - -/** - * The factory for gRPC Core + Cronet transport implementation. The - * implementation is not part of the default transports of gRPC and is for - * testing purpose only on Github. - * - * To use this transport, a user must include the GRPCCoreCronet module as a - * dependency of the project and use gGRPCCoreCronetId in call options to - * specify that this is the transport to be used for a call. - */ -@interface GRPCCoreCronetFactory : NSObject - -@end diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m deleted file mode 100644 index 5772694fc54..00000000000 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import "GRPCCoreCronetFactory.h" - -#import -#import - -#import "../GRPCCallInternal.h" -#import "../GRPCCoreFactory.h" -#import "GRPCCronetChannelFactory.h" - -static GRPCCoreCronetFactory *gGRPCCoreCronetFactory = nil; -static dispatch_once_t gInitGRPCCoreCronetFactory; - -@implementation GRPCCoreCronetFactory - -+ (instancetype)sharedInstance { - dispatch_once(&gInitGRPCCoreCronetFactory, ^{ - gGRPCCoreCronetFactory = [[GRPCCoreCronetFactory alloc] init]; - }); - return gGRPCCoreCronetFactory; -} - -+ (void)load { - [[GRPCTransportRegistry sharedInstance] - registerTransportWithId:gGRPCCoreCronetId - factory:[GRPCCoreCronetFactory sharedInstance]]; -} - -- (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager { - return [[GRPCCall2Internal alloc] initWithTransportManager:transportManager]; -} - -- (id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions { - return [GRPCCronetChannelFactory sharedInstance]; -} - -@end diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h deleted file mode 100644 index 3cd312d4ad0..00000000000 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import - -NS_ASSUME_NONNULL_BEGIN - -@protocol GRPCChannelFactory; -@protocol GRPCCallOptions; - -/** The interface for transport implementations that are based on Core. */ -@protocol GRPCCoreTransportFactory - -/** Get the channel factory for GRPCChannel from call options. */ -- (nullable id)createCoreChannelFactoryWithCallOptions: - (GRPCCallOptions *)callOptions; - -@end - -/** The factory for gRPC Core + CFStream + TLS secure channel transport implementation. */ -@interface GRPCCoreSecureFactory : NSObject - -@end - -/** The factory for gRPC Core + CFStream + insecure channel transport implementation. */ -@interface GRPCCoreInsecureFactory : NSObject - -@end - -NS_ASSUME_NONNULL_END diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m deleted file mode 100644 index 19d7231a203..00000000000 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m +++ /dev/null @@ -1,90 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import "GRPCCoreFactory.h" - -#import - -#import "GRPCCallInternal.h" -#import "GRPCInsecureChannelFactory.h" -#import "GRPCSecureChannelFactory.h" - -static GRPCCoreSecureFactory *gGRPCCoreSecureFactory = nil; -static GRPCCoreInsecureFactory *gGRPCCoreInsecureFactory = nil; -static dispatch_once_t gInitGRPCCoreSecureFactory; -static dispatch_once_t gInitGRPCCoreInsecureFactory; - -@implementation GRPCCoreSecureFactory - -+ (instancetype)sharedInstance { - dispatch_once(&gInitGRPCCoreSecureFactory, ^{ - gGRPCCoreSecureFactory = [[GRPCCoreSecureFactory alloc] init]; - }); - return gGRPCCoreSecureFactory; -} - -+ (void)load { - [[GRPCTransportRegistry sharedInstance] - registerTransportWithId:GRPCDefaultTransportImplList.core_secure - factory:[self sharedInstance]]; -} - -- (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager { - return [[GRPCCall2Internal alloc] initWithTransportManager:transportManager]; -} - -- (id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions { - NSError *error; - id factory = - [GRPCSecureChannelFactory factoryWithPEMRootCertificates:callOptions.PEMRootCertificates - privateKey:callOptions.PEMPrivateKey - certChain:callOptions.PEMCertificateChain - error:&error]; - if (error != nil) { - NSLog(@"Unable to create secure channel factory"); - return nil; - } - return factory; -} - -@end - -@implementation GRPCCoreInsecureFactory - -+ (instancetype)sharedInstance { - dispatch_once(&gInitGRPCCoreInsecureFactory, ^{ - gGRPCCoreInsecureFactory = [[GRPCCoreInsecureFactory alloc] init]; - }); - return gGRPCCoreInsecureFactory; -} - -+ (void)load { - [[GRPCTransportRegistry sharedInstance] - registerTransportWithId:GRPCDefaultTransportImplList.core_insecure - factory:[self sharedInstance]]; -} - -- (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager { - return [[GRPCCall2Internal alloc] initWithTransportManager:transportManager]; -} - -- (id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions { - return [GRPCInsecureChannelFactory sharedInstance]; -} - -@end diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h similarity index 96% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.h rename to src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h index 138ddf1f730..738dfdb7370 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.h +++ b/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h @@ -15,7 +15,7 @@ * limitations under the License. * */ -#import "../GRPCChannelFactory.h" +#import "GRPCChannelFactory.h" @class GRPCChannel; typedef struct stream_engine stream_engine; diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m similarity index 76% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.m rename to src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m index da3f3afd855..5bcb021dc4b 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m @@ -18,8 +18,10 @@ #import "GRPCCronetChannelFactory.h" -#import "../ChannelArgsUtil.h" -#import "../GRPCChannel.h" +#import "ChannelArgsUtil.h" +#import "GRPCChannel.h" + +#ifdef GRPC_COMPILE_WITH_CRONET #import #include @@ -57,3 +59,21 @@ } @end + +#else + +@implementation GRPCCronetChannelFactory + ++ (instancetype)sharedInstance { + NSAssert(NO, @"Must enable macro GRPC_COMPILE_WITH_CRONET to build Cronet channel."); + return nil; +} + +- (grpc_channel *)createChannelWithHost:(NSString *)host channelArgs:(NSDictionary *)args { + NSAssert(NO, @"Must enable macro GRPC_COMPILE_WITH_CRONET to build Cronet channel."); + return NULL; +} + +@end + +#endif diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.h b/src/objective-c/GRPCClient/private/GRPCHost.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.h rename to src/objective-c/GRPCClient/private/GRPCHost.h diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m similarity index 82% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m rename to src/objective-c/GRPCClient/private/GRPCHost.m index 1f6a25ff78f..63ffc927411 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCHost.m @@ -21,16 +21,17 @@ #import #import #import -#import #include #include -#import "../../internal/GRPCCallOptions+Internal.h" +#import "../internal/GRPCCallOptions+Internal.h" #import "GRPCChannelFactory.h" #import "GRPCCompletionQueue.h" +#import "GRPCCronetChannelFactory.h" #import "GRPCSecureChannelFactory.h" #import "NSDictionary+GRPC.h" +#import "version.h" NS_ASSUME_NONNULL_BEGIN @@ -112,12 +113,20 @@ static NSMutableDictionary *gHostCache; options.PEMPrivateKey = _PEMPrivateKey; options.PEMCertificateChain = _PEMCertificateChain; options.hostNameOverride = _hostNameOverride; - if (_transportType == GRPCTransportTypeInsecure) { - options.transport = GRPCDefaultTransportImplList.core_insecure; - } else if ([GRPCCall isUsingCronet]) { - options.transport = gGRPCCoreCronetId; - } else { - options.transport = GRPCDefaultTransportImplList.core_secure; +#ifdef GRPC_COMPILE_WITH_CRONET + // By old API logic, insecure channel precedes Cronet channel; Cronet channel preceeds default + // channel. + if ([GRPCCall isUsingCronet]) { + if (_transportType == GRPCTransportTypeInsecure) { + options.transportType = GRPCTransportTypeInsecure; + } else { + NSAssert(_transportType == GRPCTransportTypeDefault, @"Invalid transport type"); + options.transportType = GRPCTransportTypeCronet; + } + } else +#endif + { + options.transportType = _transportType; } options.logContext = _logContext; @@ -126,14 +135,16 @@ static NSMutableDictionary *gHostCache; + (GRPCCallOptions *)callOptionsForHost:(NSString *)host { // TODO (mxyan): Remove when old API is deprecated + NSURL *hostURL = [NSURL URLWithString:[@"https://" stringByAppendingString:host]]; + if (hostURL.host && hostURL.port == nil) { + host = [hostURL.host stringByAppendingString:@":443"]; + } + GRPCCallOptions *callOptions = nil; @synchronized(gHostCache) { - GRPCHost *hostConfig = [GRPCHost hostWithAddress:host]; - callOptions = [hostConfig callOptions]; + callOptions = [gHostCache[host] callOptions]; } - NSAssert(callOptions != nil, @"Unable to create call options object"); if (callOptions == nil) { - NSLog(@"Unable to create call options object"); callOptions = [[GRPCCallOptions alloc] init]; } return callOptions; diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.h rename to src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.h diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.m rename to src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCOpBatchLog.h b/src/objective-c/GRPCClient/private/GRPCOpBatchLog.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCOpBatchLog.h rename to src/objective-c/GRPCClient/private/GRPCOpBatchLog.h diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCOpBatchLog.m b/src/objective-c/GRPCClient/private/GRPCOpBatchLog.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCOpBatchLog.m rename to src/objective-c/GRPCClient/private/GRPCOpBatchLog.m diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCReachabilityFlagNames.xmacro.h b/src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCReachabilityFlagNames.xmacro.h rename to src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.h b/src/objective-c/GRPCClient/private/GRPCRequestHeaders.h similarity index 95% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.h rename to src/objective-c/GRPCClient/private/GRPCRequestHeaders.h index 0fced0c385a..545ff1cea82 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.h +++ b/src/objective-c/GRPCClient/private/GRPCRequestHeaders.h @@ -18,7 +18,7 @@ #import -#import +#import "../GRPCCall.h" @interface GRPCRequestHeaders : NSMutableDictionary diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.m b/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.m rename to src/objective-c/GRPCClient/private/GRPCRequestHeaders.m diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.h rename to src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.h diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.m rename to src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h deleted file mode 100644 index 2dc7357c363..00000000000 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import -#import - -NS_ASSUME_NONNULL_BEGIN - -/** - * Private interfaces of the transport registry. - */ -@interface GRPCTransportRegistry (Private) - -/** - * Get a transport implementation's factory by its transport id. If the transport id was not - * registered with the registry, the default transport factory (core + secure) is returned. If the - * default transport does not exist, an exception is thrown. - */ -- (id)getTransportFactoryWithId:(GRPCTransportId)transportId; - -@end - -@interface GRPCTransportManager : NSObject - -- (instancetype)initWithTransportId:(GRPCTransportId)transportId - previousInterceptor:(id)previousInterceptor; - -/** - * Notify the manager that the transport has shut down and the manager should release references to - * its response handler and stop forwarding requests/responses. - */ -- (void)shutDown; - -/** Forward initial metadata to the previous interceptor in the interceptor chain */ -- (void)forwardPreviousInterceptorWithInitialMetadata:(nullable NSDictionary *)initialMetadata; - -/** Forward a received message to the previous interceptor in the interceptor chain */ -- (void)forwardPreviousInterceptorWithData:(nullable id)data; - -/** Forward call close and trailing metadata to the previous interceptor in the interceptor chain */ -- (void)forwardPreviousInterceptorCloseWithTrailingMetadata: - (nullable NSDictionary *)trailingMetadata - error:(nullable NSError *)error; - -/** Forward write completion to the previous interceptor in the interceptor chain */ -- (void)forwardPreviousInterceptorDidWriteData; - -@end - -NS_ASSUME_NONNULL_END diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m deleted file mode 100644 index 9072f7afbe2..00000000000 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m +++ /dev/null @@ -1,131 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import "GRPCTransport+Private.h" - -#import - -@implementation GRPCTransportManager { - GRPCTransportId _transportId; - GRPCTransport *_transport; - id _previousInterceptor; - dispatch_queue_t _dispatchQueue; -} - -- (instancetype)initWithTransportId:(GRPCTransportId)transportId - previousInterceptor:(id)previousInterceptor { - if ((self = [super init])) { - id factory = - [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:transportId]; - - _transport = [factory createTransportWithManager:self]; - NSAssert(_transport != nil, @"Failed to create transport with id: %s", transportId); - if (_transport == nil) { - NSLog(@"Failed to create transport with id: %s", transportId); - return nil; - } - _previousInterceptor = previousInterceptor; - _dispatchQueue = _transport.dispatchQueue; - _transportId = transportId; - } - return self; -} - -- (void)shutDown { - dispatch_async(_dispatchQueue, ^{ - self->_transport = nil; - self->_previousInterceptor = nil; - }); -} - -- (dispatch_queue_t)dispatchQueue { - return _dispatchQueue; -} - -- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions - callOptions:(GRPCCallOptions *)callOptions { - if (_transportId != callOptions.transport) { - [NSException raise:NSInvalidArgumentException - format:@"Interceptors cannot change the call option 'transport'"]; - return; - } - [_transport startWithRequestOptions:requestOptions callOptions:callOptions]; -} - -- (void)writeData:(id)data { - [_transport writeData:data]; -} - -- (void)finish { - [_transport finish]; -} - -- (void)cancel { - [_transport cancel]; -} - -- (void)receiveNextMessages:(NSUInteger)numberOfMessages { - [_transport receiveNextMessages:numberOfMessages]; -} - -/** Forward initial metadata to the previous interceptor in the chain */ -- (void)forwardPreviousInterceptorWithInitialMetadata:(NSDictionary *)initialMetadata { - if (initialMetadata == nil || _previousInterceptor == nil) { - return; - } - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didReceiveInitialMetadata:initialMetadata]; - }); -} - -/** Forward a received message to the previous interceptor in the chain */ -- (void)forwardPreviousInterceptorWithData:(id)data { - if (data == nil || _previousInterceptor == nil) { - return; - } - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didReceiveData:data]; - }); -} - -/** Forward call close and trailing metadata to the previous interceptor in the chain */ -- (void)forwardPreviousInterceptorCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata - error:(NSError *)error { - if (_previousInterceptor == nil) { - return; - } - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; - }); -} - -/** Forward write completion to the previous interceptor in the chain */ -- (void)forwardPreviousInterceptorDidWriteData { - if (_previousInterceptor == nil) { - return; - } - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didWriteData]; - }); -} - -@end diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.h b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.h rename to src/objective-c/GRPCClient/private/GRPCWrappedCall.h diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.m rename to src/objective-c/GRPCClient/private/GRPCWrappedCall.m diff --git a/src/objective-c/GRPCClient/private/GRPCCore/NSData+GRPC.h b/src/objective-c/GRPCClient/private/NSData+GRPC.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/NSData+GRPC.h rename to src/objective-c/GRPCClient/private/NSData+GRPC.h diff --git a/src/objective-c/GRPCClient/private/GRPCCore/NSData+GRPC.m b/src/objective-c/GRPCClient/private/NSData+GRPC.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/NSData+GRPC.m rename to src/objective-c/GRPCClient/private/NSData+GRPC.m diff --git a/src/objective-c/GRPCClient/private/GRPCCore/NSDictionary+GRPC.h b/src/objective-c/GRPCClient/private/NSDictionary+GRPC.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/NSDictionary+GRPC.h rename to src/objective-c/GRPCClient/private/NSDictionary+GRPC.h diff --git a/src/objective-c/GRPCClient/private/GRPCCore/NSDictionary+GRPC.m b/src/objective-c/GRPCClient/private/NSDictionary+GRPC.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/NSDictionary+GRPC.m rename to src/objective-c/GRPCClient/private/NSDictionary+GRPC.m diff --git a/src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.h b/src/objective-c/GRPCClient/private/NSError+GRPC.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.h rename to src/objective-c/GRPCClient/private/NSError+GRPC.h diff --git a/src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m b/src/objective-c/GRPCClient/private/NSError+GRPC.m similarity index 96% rename from src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m rename to src/objective-c/GRPCClient/private/NSError+GRPC.m index 5b5fc6263c5..3eefed88d63 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m +++ b/src/objective-c/GRPCClient/private/NSError+GRPC.m @@ -18,9 +18,10 @@ #import "NSError+GRPC.h" -#import #include +NSString *const kGRPCErrorDomain = @"io.grpc"; + @implementation NSError (GRPC) + (instancetype)grpc_errorFromStatusCode:(grpc_status_code)statusCode details:(const char *)details diff --git a/src/objective-c/GRPCClient/version.h b/src/objective-c/GRPCClient/private/version.h similarity index 100% rename from src/objective-c/GRPCClient/version.h rename to src/objective-c/GRPCClient/private/version.h diff --git a/src/objective-c/ProtoRPC/ProtoRPC.h b/src/objective-c/ProtoRPC/ProtoRPC.h index c91adc7b7cd..12db46adeda 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.h +++ b/src/objective-c/ProtoRPC/ProtoRPC.h @@ -17,16 +17,12 @@ */ #import - -// import legacy header for compatibility with users using the ProtoRPC interface -#import "ProtoRPCLegacy.h" +#import #import "ProtoMethod.h" NS_ASSUME_NONNULL_BEGIN -@class GRPCRequestOptions; -@class GRPCCallOptions; @class GPBMessage; /** An object can implement this protocol to receive responses from server from a call. */ @@ -164,3 +160,35 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnullability-completeness" + +__attribute__((deprecated("Please use GRPCProtoCall."))) @interface ProtoRPC + : GRPCCall + + /** + * host parameter should not contain the scheme (http:// or https://), only the name or IP + * addr and the port number, for example @"localhost:5050". + */ + - + (instancetype)initWithHost : (NSString *)host method + : (GRPCProtoMethod *)method requestsWriter : (GRXWriter *)requestsWriter responseClass + : (Class)responseClass responsesWriteable + : (id)responsesWriteable NS_DESIGNATED_INITIALIZER; + +- (void)start; +@end + +/** + * This subclass is empty now. Eventually we'll remove ProtoRPC class + * to avoid potential naming conflict + */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + @interface GRPCProtoCall : ProtoRPC +#pragma clang diagnostic pop + + @end + +#pragma clang diagnostic pop diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m index dbfa3c0f23d..4700fdd1124 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.m +++ b/src/objective-c/ProtoRPC/ProtoRPC.m @@ -27,6 +27,24 @@ #import #import +/** + * Generate an NSError object that represents a failure in parsing a proto class. + */ +static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError) { + NSDictionary *info = @{ + NSLocalizedDescriptionKey : @"Unable to parse response from the server", + NSLocalizedRecoverySuggestionErrorKey : + @"If this RPC is idempotent, retry " + @"with exponential backoff. Otherwise, query the server status before " + @"retrying.", + NSUnderlyingErrorKey : parsingError, + @"Expected class" : expectedClass, + @"Received value" : proto, + }; + // TODO(jcanizales): Use kGRPCErrorDomain and GRPCErrorCodeInternal when they're public. + return [NSError errorWithDomain:@"io.grpc" code:13 userInfo:info]; +} + @implementation GRPCUnaryProtoCall { GRPCStreamingProtoCall *_call; GPBMessage *_message; @@ -273,3 +291,76 @@ } @end + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-implementations" +@implementation ProtoRPC { +#pragma clang diagnostic pop + id _responseWriteable; +} + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wobjc-designated-initializers" +- (instancetype)initWithHost:(NSString *)host + path:(NSString *)path + requestsWriter:(GRXWriter *)requestsWriter { + [NSException raise:NSInvalidArgumentException + format:@"Please use ProtoRPC's designated initializer instead."]; + return nil; +} +#pragma clang diagnostic pop + +// Designated initializer +- (instancetype)initWithHost:(NSString *)host + method:(GRPCProtoMethod *)method + requestsWriter:(GRXWriter *)requestsWriter + responseClass:(Class)responseClass + responsesWriteable:(id)responsesWriteable { + // Because we can't tell the type system to constrain the class, we need to check at runtime: + if (![responseClass respondsToSelector:@selector(parseFromData:error:)]) { + [NSException raise:NSInvalidArgumentException + format:@"A protobuf class to parse the responses must be provided."]; + } + // A writer that serializes the proto messages to send. + GRXWriter *bytesWriter = [requestsWriter map:^id(GPBMessage *proto) { + if (![proto isKindOfClass:[GPBMessage class]]) { + [NSException raise:NSInvalidArgumentException + format:@"Request must be a proto message: %@", proto]; + } + return [proto data]; + }]; + if ((self = [super initWithHost:host path:method.HTTPPath requestsWriter:bytesWriter])) { + __weak ProtoRPC *weakSelf = self; + + // A writeable that parses the proto messages received. + _responseWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { + // TODO(jcanizales): This is done in the main thread, and needs to happen in another thread. + NSError *error = nil; + id parsed = [responseClass parseFromData:value error:&error]; + if (parsed) { + [responsesWriteable writeValue:parsed]; + } else { + [weakSelf finishWithError:ErrorForBadProto(value, responseClass, error)]; + } + } + completionHandler:^(NSError *errorOrNil) { + [responsesWriteable writesFinishedWithError:errorOrNil]; + }]; + } + return self; +} + +- (void)start { + [self startWithWriteable:_responseWriteable]; +} + +- (void)startWithWriteable:(id)writeable { + [super startWithWriteable:writeable]; + // Break retain cycles. + _responseWriteable = nil; +} +@end + +@implementation GRPCProtoCall + +@end diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.h b/src/objective-c/ProtoRPC/ProtoRPCLegacy.h deleted file mode 100644 index b8d4003f695..00000000000 --- a/src/objective-c/ProtoRPC/ProtoRPCLegacy.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import - -// Import category headers for Swift build -#import -#import -#import -#import -#import -#import - -@class GRPCProtoMethod; -@class GRXWriter; -@protocol GRXWriteable; - -__attribute__((deprecated("Please use GRPCProtoCall."))) @interface ProtoRPC - : GRPCCall - - /** - * host parameter should not contain the scheme (http:// or https://), only the name or IP - * addr and the port number, for example @"localhost:5050". - */ - - - (instancetype)initWithHost : (NSString *)host method - : (GRPCProtoMethod *)method requestsWriter : (GRXWriter *)requestsWriter responseClass - : (Class)responseClass responsesWriteable - : (id)responsesWriteable NS_DESIGNATED_INITIALIZER; - -- (void)start; - -@end - -/** - * This subclass is empty now. Eventually we'll remove ProtoRPC class - * to avoid potential naming conflict - */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - @interface GRPCProtoCall - : ProtoRPC -#pragma clang diagnostic pop - - @end - - /** - * Generate an NSError object that represents a failure in parsing a proto class. For gRPC - * internal use only. - */ - NSError * - ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError); diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.m b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m deleted file mode 100644 index 4ba93674063..00000000000 --- a/src/objective-c/ProtoRPC/ProtoRPCLegacy.m +++ /dev/null @@ -1,121 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import "ProtoRPCLegacy.h" - -#import "ProtoMethod.h" - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS -#import -#else -#import -#endif -#import -#import -#import - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-implementations" -@implementation ProtoRPC { -#pragma clang diagnostic pop - id _responseWriteable; -} - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wobjc-designated-initializers" -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - requestsWriter:(GRXWriter *)requestsWriter { - [NSException raise:NSInvalidArgumentException - format:@"Please use ProtoRPC's designated initializer instead."]; - return nil; -} -#pragma clang diagnostic pop - -// Designated initializer -- (instancetype)initWithHost:(NSString *)host - method:(GRPCProtoMethod *)method - requestsWriter:(GRXWriter *)requestsWriter - responseClass:(Class)responseClass - responsesWriteable:(id)responsesWriteable { - // Because we can't tell the type system to constrain the class, we need to check at runtime: - if (![responseClass respondsToSelector:@selector(parseFromData:error:)]) { - [NSException raise:NSInvalidArgumentException - format:@"A protobuf class to parse the responses must be provided."]; - } - // A writer that serializes the proto messages to send. - GRXWriter *bytesWriter = [requestsWriter map:^id(GPBMessage *proto) { - if (![proto isKindOfClass:[GPBMessage class]]) { - [NSException raise:NSInvalidArgumentException - format:@"Request must be a proto message: %@", proto]; - } - return [proto data]; - }]; - if ((self = [super initWithHost:host path:method.HTTPPath requestsWriter:bytesWriter])) { - __weak ProtoRPC *weakSelf = self; - - // A writeable that parses the proto messages received. - _responseWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { - // TODO(jcanizales): This is done in the main thread, and needs to happen in another thread. - NSError *error = nil; - id parsed = [responseClass parseFromData:value error:&error]; - if (parsed) { - [responsesWriteable writeValue:parsed]; - } else { - [weakSelf finishWithError:ErrorForBadProto(value, responseClass, error)]; - } - } - completionHandler:^(NSError *errorOrNil) { - [responsesWriteable writesFinishedWithError:errorOrNil]; - }]; - } - return self; -} - -- (void)start { - [self startWithWriteable:_responseWriteable]; -} - -- (void)startWithWriteable:(id)writeable { - [super startWithWriteable:writeable]; - // Break retain cycles. - _responseWriteable = nil; -} -@end - -@implementation GRPCProtoCall - -@end - -/** - * Generate an NSError object that represents a failure in parsing a proto class. - */ -NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError) { - NSDictionary *info = @{ - NSLocalizedDescriptionKey : @"Unable to parse response from the server", - NSLocalizedRecoverySuggestionErrorKey : - @"If this RPC is idempotent, retry " - @"with exponential backoff. Otherwise, query the server status before " - @"retrying.", - NSUnderlyingErrorKey : parsingError, - @"Expected class" : expectedClass, - @"Received value" : proto, - }; - // TODO(jcanizales): Use kGRPCErrorDomain and GRPCErrorCodeInternal when they're public. - return [NSError errorWithDomain:@"io.grpc" code:13 userInfo:info]; -} diff --git a/src/objective-c/ProtoRPC/ProtoService.h b/src/objective-c/ProtoRPC/ProtoService.h index fd8a86bb2b2..900ec8d0e1e 100644 --- a/src/objective-c/ProtoRPC/ProtoService.h +++ b/src/objective-c/ProtoRPC/ProtoService.h @@ -18,12 +18,14 @@ #import -#import -#import "ProtoRPC.h" - +@class GRPCProtoCall; @protocol GRXWriteable; @class GRXWriter; @class GRPCCallOptions; +@class GRPCProtoCall; +@class GRPCUnaryProtoCall; +@class GRPCStreamingProtoCall; +@protocol GRPCProtoResponseHandler; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnullability-completeness" @@ -36,6 +38,15 @@ __attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoServ : (nonnull NSString *)packageName serviceName : (nonnull NSString *)serviceName callOptions : (nullable GRPCCallOptions *)callOptions NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithHost:(NSString *)host + packageName:(NSString *)packageName + serviceName:(NSString *)serviceName; + +- (GRPCProtoCall *)RPCToMethod:(NSString *)method + requestsWriter:(GRXWriter *)requestsWriter + responseClass:(Class)responseClass + responsesWriteable:(id)responsesWriteable; + - (nullable GRPCUnaryProtoCall *)RPCToMethod:(nonnull NSString *)method message:(nonnull id)message responseHandler:(nonnull id)handler @@ -47,18 +58,6 @@ __attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoServ callOptions:(nullable GRPCCallOptions *)callOptions responseClass:(nonnull Class)responseClass; -@end - - @interface ProtoService(Legacy) - - - (instancetype)initWithHost : (NSString *)host packageName - : (NSString *)packageName serviceName : (NSString *)serviceName; - -- (GRPCProtoCall *)RPCToMethod:(NSString *)method - requestsWriter:(GRXWriter *)requestsWriter - responseClass:(Class)responseClass - responsesWriteable:(id)responsesWriteable; - @end #pragma clang diagnostic pop diff --git a/src/objective-c/ProtoRPC/ProtoService.m b/src/objective-c/ProtoRPC/ProtoService.m index e84cab8903f..80a1f2f226c 100644 --- a/src/objective-c/ProtoRPC/ProtoService.m +++ b/src/objective-c/ProtoRPC/ProtoService.m @@ -29,21 +29,15 @@ #pragma clang diagnostic ignored "-Wdeprecated-implementations" @implementation ProtoService { #pragma clang diagnostic pop - - GRPCCallOptions *_callOptions; NSString *_host; NSString *_packageName; NSString *_serviceName; + GRPCCallOptions *_callOptions; } -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wnonnull" -// Do not call the default init method - (instancetype)init { - [NSException raise:NSGenericException format:@"Do not call init method of ProtoService"]; - return [self initWithHost:nil packageName:nil serviceName:nil callOptions:nil]; + return [self initWithHost:nil packageName:nil serviceName:nil]; } -#pragma clang diagnostic pop // Designated initializer - (instancetype)initWithHost:(NSString *)host @@ -64,6 +58,38 @@ return self; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wobjc-designated-initializers" +// Do not call designated initializer here due to nullability incompatibility. This method is from +// old API and does not assert on nullability of the parameters. + +- (instancetype)initWithHost:(NSString *)host + packageName:(NSString *)packageName + serviceName:(NSString *)serviceName { + if ((self = [super init])) { + _host = [host copy]; + _packageName = [packageName copy]; + _serviceName = [serviceName copy]; + _callOptions = nil; + } + return self; +} + +#pragma clang diagnostic pop + +- (GRPCProtoCall *)RPCToMethod:(NSString *)method + requestsWriter:(GRXWriter *)requestsWriter + responseClass:(Class)responseClass + responsesWriteable:(id)responsesWriteable { + GRPCProtoMethod *methodName = + [[GRPCProtoMethod alloc] initWithPackage:_packageName service:_serviceName method:method]; + return [[GRPCProtoCall alloc] initWithHost:_host + method:methodName + requestsWriter:requestsWriter + responseClass:responseClass + responsesWriteable:responsesWriteable]; +} + - (GRPCUnaryProtoCall *)RPCToMethod:(NSString *)method message:(id)message responseHandler:(id)handler diff --git a/src/objective-c/ProtoRPC/ProtoServiceLegacy.h b/src/objective-c/ProtoRPC/ProtoServiceLegacy.h deleted file mode 100644 index 7b0b7a4de7e..00000000000 --- a/src/objective-c/ProtoRPC/ProtoServiceLegacy.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import "ProtoService.h" - -@class GRPCProtoCall; -@class GRXWriter; -@protocol GRXWriteable; diff --git a/src/objective-c/ProtoRPC/ProtoServiceLegacy.m b/src/objective-c/ProtoRPC/ProtoServiceLegacy.m deleted file mode 100644 index 6aa64955381..00000000000 --- a/src/objective-c/ProtoRPC/ProtoServiceLegacy.m +++ /dev/null @@ -1,71 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import - -#import "ProtoMethod.h" -#import "ProtoRPCLegacy.h" -#import "ProtoService.h" - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-implementations" -@implementation ProtoService (Legacy) -#pragma clang diagnostic pop - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wobjc-designated-initializers" -// Do not call designated initializer here due to nullability incompatibility. This method is from -// old API and does not assert on nullability of the parameters. - -- (instancetype)initWithHost:(NSString *)host - packageName:(NSString *)packageName - serviceName:(NSString *)serviceName { - if ((self = [super init])) { - Ivar hostIvar = class_getInstanceVariable([ProtoService class], "_host"); - Ivar packageNameIvar = class_getInstanceVariable([ProtoService class], "_packageName"); - Ivar serviceNameIvar = class_getInstanceVariable([ProtoService class], "_serviceName"); - - object_setIvar(self, hostIvar, [host copy]); - object_setIvar(self, packageNameIvar, [packageName copy]); - object_setIvar(self, serviceNameIvar, [serviceName copy]); - } - return self; -} -#pragma clang diagnostic pop - -- (GRPCProtoCall *)RPCToMethod:(NSString *)method - requestsWriter:(GRXWriter *)requestsWriter - responseClass:(Class)responseClass - responsesWriteable:(id)responsesWriteable { - Ivar hostIvar = class_getInstanceVariable([ProtoService class], "_host"); - Ivar packageNameIvar = class_getInstanceVariable([ProtoService class], "_packageName"); - Ivar serviceNameIvar = class_getInstanceVariable([ProtoService class], "_serviceName"); - NSString *host = object_getIvar(self, hostIvar); - NSString *packageName = object_getIvar(self, packageNameIvar); - NSString *serviceName = object_getIvar(self, serviceNameIvar); - - GRPCProtoMethod *methodName = - [[GRPCProtoMethod alloc] initWithPackage:packageName service:serviceName method:method]; - return [[GRPCProtoCall alloc] initWithHost:host - method:methodName - requestsWriter:requestsWriter - responseClass:responseClass - responsesWriteable:responsesWriteable]; -} - -@end diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m index 9c466260121..c94ee8c2569 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m @@ -25,8 +25,6 @@ #import "src/objective-c/examples/RemoteTestClient/Messages.pbobjc.h" #import "src/objective-c/examples/RemoteTestClient/Test.pbrpc.h" #endif -#import -#import @interface ViewController () diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m index ce204a9c146..3e97767cf0c 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m +++ b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m @@ -24,8 +24,6 @@ #import "src/objective-c/examples/RemoteTestClient/Messages.pbobjc.h" #import "src/objective-c/examples/RemoteTestClient/Test.pbrpc.h" #endif -#import -#import @interface InterfaceController () diff --git a/src/objective-c/tests/BUILD b/src/objective-c/tests/BUILD index 65a32d742a9..fed92596b17 100644 --- a/src/objective-c/tests/BUILD +++ b/src/objective-c/tests/BUILD @@ -95,12 +95,19 @@ tvos_application( deps = ["host-lib"], ) +grpc_objc_testing_library( + name = "CronetConfig", + srcs = ["ConfigureCronet.m"], + hdrs = ["ConfigureCronet.h"], +) + grpc_objc_testing_library( name = "InteropTests-lib", hdrs = ["InteropTests/InteropTests.h"], srcs = ["InteropTests/InteropTests.m"], deps = [ ":InteropTestsBlockCallbacks-lib", + ":CronetConfig", ], ) @@ -193,6 +200,7 @@ ios_unit_test( ":InteropTestsRemote-lib", ":InteropTestsLocalSSL-lib", ":InteropTestsLocalCleartext-lib", + # ":InteropTestsMulitpleChannels-lib", # needs Cronet ], test_host = ":ios-host", ) diff --git a/src/objective-c/tests/ConfigureCronet.h b/src/objective-c/tests/ConfigureCronet.h index ba0efc4df66..cc5c038f3c6 100644 --- a/src/objective-c/tests/ConfigureCronet.h +++ b/src/objective-c/tests/ConfigureCronet.h @@ -16,6 +16,8 @@ * */ +#ifdef GRPC_COMPILE_WITH_CRONET + #ifdef __cplusplus extern "C" { #endif @@ -28,3 +30,5 @@ void configureCronet(void); #ifdef __cplusplus } #endif + +#endif diff --git a/src/objective-c/tests/ConfigureCronet.m b/src/objective-c/tests/ConfigureCronet.m index 6fc7e0ee9f5..ab137e28cad 100644 --- a/src/objective-c/tests/ConfigureCronet.m +++ b/src/objective-c/tests/ConfigureCronet.m @@ -16,6 +16,8 @@ * */ +#ifdef GRPC_COMPILE_WITH_CRONET + #import "ConfigureCronet.h" #import @@ -33,3 +35,5 @@ void configureCronet(void) { [Cronet startNetLogToFile:@"cronet_netlog.json" logBytes:YES]; }); } + +#endif diff --git a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m index aa1af301b96..a2a79c46316 100644 --- a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m +++ b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m @@ -22,7 +22,6 @@ #import #import -#import "../ConfigureCronet.h" #import "InteropTests.h" // The server address is derived from preprocessor macro, which is @@ -41,19 +40,12 @@ static int32_t kRemoteInteropServerOverhead = 12; @implementation InteropTestsRemoteWithCronet -+ (void)setUp { - configureCronet(); - [GRPCCall useCronetWithEngine:[Cronet getGlobalEngine]]; - - [super setUp]; -} - + (NSString *)host { return kRemoteSSLHost; } -+ (GRPCTransportId)transport { - return gGRPCCoreCronetId; ++ (BOOL)useCronet { + return YES; } - (int32_t)encodingOverhead { diff --git a/src/objective-c/tests/InteropTests/InteropTests.h b/src/objective-c/tests/InteropTests/InteropTests.h index a4adecd5415..28fcbff9695 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.h +++ b/src/objective-c/tests/InteropTests/InteropTests.h @@ -48,19 +48,11 @@ - (int32_t)encodingOverhead; /** - * DEPRECATED: \a transportType is a deprecated option. Please use \a transport instead. - * * The type of transport to be used. The base implementation returns default. Subclasses should * override to appropriate settings. */ + (GRPCTransportType)transportType; -/* - * The transport to be used. The base implementation returns NULL. Subclasses should override to - * appropriate settings. - */ -+ (GRPCTransportId)transport; - /** * The root certificates to be used. The base implementation returns nil. Subclasses should override * to appropriate settings. @@ -73,4 +65,9 @@ */ + (NSString *)hostNameOverride; +/** + * Whether to use Cronet for all the v1 API tests in the test suite. + */ ++ (BOOL)useCronet; + @end diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 21198f7bad9..a8f7db7ee93 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -20,6 +20,9 @@ #include +#ifdef GRPC_COMPILE_WITH_CRONET +#import +#endif #import #import #import @@ -35,6 +38,7 @@ #import "src/objective-c/tests/RemoteTestClient/Test.pbobjc.h" #import "src/objective-c/tests/RemoteTestClient/Test.pbrpc.h" +#import "../ConfigureCronet.h" #import "InteropTestsBlockCallbacks.h" #define TEST_TIMEOUT 32 @@ -87,8 +91,9 @@ BOOL isRemoteInteropTest(NSString *host) { - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { dispatch_queue_t queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); - return - [[GRPCInterceptor alloc] initWithInterceptorManager:interceptorManager dispatchQueue:queue]; + return [[GRPCInterceptor alloc] initWithInterceptorManager:interceptorManager + requestDispatchQueue:queue + responseDispatchQueue:queue]; } @end @@ -96,19 +101,21 @@ BOOL isRemoteInteropTest(NSString *host) { @interface HookInterceptorFactory : NSObject - (instancetype) - initWithDispatchQueue:(dispatch_queue_t)dispatchQueue - startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, - GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook - finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook -receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, - GRPCInterceptorManager *manager))receiveNextMessagesHook - responseHeaderHook:(void (^)(NSDictionary *initialMetadata, - GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook - responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, - GRPCInterceptorManager *manager))responseCloseHook - didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook; +initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue + responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue + startHook:(void (^)(GRPCRequestOptions *requestOptions, + GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager))startHook + writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook + finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook + receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, + GRPCInterceptorManager *manager))receiveNextMessagesHook + responseHeaderHook:(void (^)(NSDictionary *initialMetadata, + GRPCInterceptorManager *manager))responseHeaderHook + responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook + responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager))responseCloseHook + didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook; - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager; @@ -118,7 +125,8 @@ receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, - (instancetype) initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - dispatchQueue:(dispatch_queue_t)dispatchQueue + requestDispatchQueue:(dispatch_queue_t)requestDispatchQueue + responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook @@ -147,25 +155,29 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager void (^_responseCloseHook)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager); void (^_didWriteDataHook)(GRPCInterceptorManager *manager); - dispatch_queue_t _dispatchQueue; + dispatch_queue_t _requestDispatchQueue; + dispatch_queue_t _responseDispatchQueue; } - (instancetype) - initWithDispatchQueue:(dispatch_queue_t)dispatchQueue - startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, - GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook - finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook -receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, - GRPCInterceptorManager *manager))receiveNextMessagesHook - responseHeaderHook:(void (^)(NSDictionary *initialMetadata, - GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook - responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, - GRPCInterceptorManager *manager))responseCloseHook - didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { +initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue + responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue + startHook:(void (^)(GRPCRequestOptions *requestOptions, + GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager))startHook + writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook + finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook + receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, + GRPCInterceptorManager *manager))receiveNextMessagesHook + responseHeaderHook:(void (^)(NSDictionary *initialMetadata, + GRPCInterceptorManager *manager))responseHeaderHook + responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook + responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager))responseCloseHook + didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { if ((self = [super init])) { - _dispatchQueue = dispatchQueue; + _requestDispatchQueue = requestDispatchQueue; + _responseDispatchQueue = responseDispatchQueue; _startHook = startHook; _writeDataHook = writeDataHook; _finishHook = finishHook; @@ -180,7 +192,8 @@ receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { return [[HookInterceptor alloc] initWithInterceptorManager:interceptorManager - dispatchQueue:_dispatchQueue + requestDispatchQueue:_requestDispatchQueue + responseDispatchQueue:_responseDispatchQueue startHook:_startHook writeDataHook:_writeDataHook finishHook:_finishHook @@ -205,16 +218,22 @@ receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, GRPCInterceptorManager *manager); void (^_didWriteDataHook)(GRPCInterceptorManager *manager); GRPCInterceptorManager *_manager; - dispatch_queue_t _dispatchQueue; + dispatch_queue_t _requestDispatchQueue; + dispatch_queue_t _responseDispatchQueue; +} + +- (dispatch_queue_t)requestDispatchQueue { + return _requestDispatchQueue; } - (dispatch_queue_t)dispatchQueue { - return _dispatchQueue; + return _responseDispatchQueue; } - (instancetype) initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - dispatchQueue:(dispatch_queue_t)dispatchQueue + requestDispatchQueue:(dispatch_queue_t)requestDispatchQueue + responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook @@ -228,7 +247,9 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager))responseCloseHook didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { - if ((self = [super initWithInterceptorManager:interceptorManager dispatchQueue:dispatchQueue])) { + if ((self = [super initWithInterceptorManager:interceptorManager + requestDispatchQueue:requestDispatchQueue + responseDispatchQueue:responseDispatchQueue])) { _startHook = startHook; _writeDataHook = writeDataHook; _finishHook = finishHook; @@ -237,7 +258,8 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager _responseDataHook = responseDataHook; _responseCloseHook = responseCloseHook; _didWriteDataHook = didWriteDataHook; - _dispatchQueue = dispatchQueue; + _requestDispatchQueue = requestDispatchQueue; + _responseDispatchQueue = responseDispatchQueue; _manager = interceptorManager; } return self; @@ -298,7 +320,8 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager @property BOOL enabled; -- (instancetype)initWithDispatchQueue:(dispatch_queue_t)dispatchQueue; +- (instancetype)initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue + responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue; - (void)setStartHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook @@ -317,23 +340,26 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager @implementation GlobalInterceptorFactory -- (instancetype)initWithDispatchQueue:(dispatch_queue_t)dispatchQueue { +- (instancetype)initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue + responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue { _enabled = NO; - return [super initWithDispatchQueue:dispatchQueue - startHook:nil - writeDataHook:nil - finishHook:nil - receiveNextMessagesHook:nil - responseHeaderHook:nil - responseDataHook:nil - responseCloseHook:nil - didWriteDataHook:nil]; + return [super initWithRequestDispatchQueue:requestDispatchQueue + responseDispatchQueue:responseDispatchQueue + startHook:nil + writeDataHook:nil + finishHook:nil + receiveNextMessagesHook:nil + responseHeaderHook:nil + responseDataHook:nil + responseCloseHook:nil + didWriteDataHook:nil]; } - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { if (_enabled) { return [[HookInterceptor alloc] initWithInterceptorManager:interceptorManager - dispatchQueue:_dispatchQueue + requestDispatchQueue:_requestDispatchQueue + responseDispatchQueue:_responseDispatchQueue startHook:_startHook writeDataHook:_writeDataHook finishHook:_finishHook @@ -399,15 +425,10 @@ static dispatch_once_t initGlobalInterceptorFactory; return 0; } -// For backwards compatibility + (GRPCTransportType)transportType { return GRPCTransportTypeChttp2BoringSSL; } -+ (GRPCTransportId)transport { - return NULL; -} - + (NSString *)PEMRootCertificates { return nil; } @@ -416,11 +437,26 @@ static dispatch_once_t initGlobalInterceptorFactory; return nil; } ++ (BOOL)useCronet { + return NO; +} + + (void)setUp { +#ifdef GRPC_COMPILE_WITH_CRONET + configureCronet(); + if ([self useCronet]) { + [GRPCCall useCronetWithEngine:[Cronet getGlobalEngine]]; + } +#endif +#ifdef GRPC_CFSTREAM + setenv(kCFStreamVarName, "1", 1); +#endif + dispatch_once(&initGlobalInterceptorFactory, ^{ dispatch_queue_t globalInterceptorQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); globalInterceptorFactory = - [[GlobalInterceptorFactory alloc] initWithDispatchQueue:globalInterceptorQueue]; + [[GlobalInterceptorFactory alloc] initWithRequestDispatchQueue:globalInterceptorQueue + responseDispatchQueue:globalInterceptorQueue]; [GRPCCall2 registerGlobalInterceptor:globalInterceptorFactory]; }); } @@ -466,9 +502,7 @@ static dispatch_once_t initGlobalInterceptorFactory; GPBEmpty *request = [GPBEmpty message]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - // For backwards compatibility options.transportType = [[self class] transportType]; - options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -497,9 +531,7 @@ static dispatch_once_t initGlobalInterceptorFactory; GPBEmpty *request = [GPBEmpty message]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - // For backwards compatibility options.transportType = [[self class] transportType]; - options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -576,9 +608,7 @@ static dispatch_once_t initGlobalInterceptorFactory; request.payload.body = [NSMutableData dataWithLength:271828]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - // For backwards compatibility options.transportType = [[self class] transportType]; - options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -626,9 +656,7 @@ static dispatch_once_t initGlobalInterceptorFactory; request.responseStatus.code = GRPC_STATUS_CANCELLED; } GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - // For backwards compatibility options.transportType = [[self class] transportType]; - options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -930,9 +958,7 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - // For backwards compatibility options.transportType = [[self class] transportType]; - options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -984,9 +1010,7 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - // For backwards compatibility options.transportType = [[self class] transportType]; - options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.flowControlEnabled = YES; @@ -1143,9 +1167,7 @@ static dispatch_once_t initGlobalInterceptorFactory; __block BOOL receivedResponse = NO; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - // For backwards compatibility options.transportType = self.class.transportType; - options.transport = [[self class] transport]; options.PEMRootCertificates = self.class.PEMRootCertificates; options.hostNameOverride = [[self class] hostNameOverride]; @@ -1178,9 +1200,7 @@ static dispatch_once_t initGlobalInterceptorFactory; [self expectationWithDescription:@"Call completed."]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - // For backwards compatibility options.transportType = self.class.transportType; - options.transport = [[self class] transport]; options.PEMRootCertificates = self.class.PEMRootCertificates; options.hostNameOverride = [[self class] hostNameOverride]; @@ -1266,47 +1286,48 @@ static dispatch_once_t initGlobalInterceptorFactory; [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; } -- (void)testKeepaliveWithV2API { +#ifndef GRPC_COMPILE_WITH_CRONET +- (void)testKeepalive { XCTAssertNotNil([[self class] host]); - if ([[self class] transport] == gGRPCCoreCronetId) { - // Cronet does not support keepalive - return; - } __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Keepalive"]; - NSNumber *kRequestSize = @27182; - NSNumber *kResponseSize = @31415; + [GRPCCall setKeepaliveWithInterval:1500 timeout:0 forHost:[[self class] host]]; - id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:kRequestSize - requestedResponseSize:kResponseSize]; - GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - options.transportType = [[self class] transportType]; - options.transport = [[self class] transport]; - options.PEMRootCertificates = [[self class] PEMRootCertificates]; - options.hostNameOverride = [[self class] hostNameOverride]; - options.keepaliveInterval = 1.5; - options.keepaliveTimeout = 0; + NSArray *requests = @[ @27182, @8 ]; + NSArray *responses = @[ @31415, @9 ]; - __block GRPCStreamingProtoCall *call = [_service - fullDuplexCallWithResponseHandler: - [[InteropTestsBlockCallbacks alloc] - initWithInitialMetadataCallback:nil - messageCallback:nil - closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { - XCTAssertNotNil(error); - XCTAssertEqual( - error.code, GRPC_STATUS_UNAVAILABLE, - @"Received status %ld instead of UNAVAILABLE (14).", - error.code); - [expectation fulfill]; - }] - callOptions:options]; - [call writeMessage:request]; - [call start]; + GRXBufferedPipe *requestsBuffer = [[GRXBufferedPipe alloc] init]; + + __block int index = 0; + + id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] + requestedResponseSize:responses[index]]; + [requestsBuffer writeValue:request]; + + [_service + fullDuplexCallWithRequestsWriter:requestsBuffer + eventHandler:^(BOOL done, RMTStreamingOutputCallResponse *response, + NSError *error) { + if (index == 0) { + XCTAssertNil(error, @"Finished with unexpected error: %@", error); + XCTAssertTrue(response, @"Event handler called without an event."); + XCTAssertFalse(done); + index++; + } else { + // Keepalive should kick after 1s elapsed and fails the call. + XCTAssertNotNil(error); + XCTAssertEqual(error.code, GRPC_STATUS_UNAVAILABLE); + XCTAssertEqualObjects( + error.localizedDescription, @"keepalive watchdog timeout", + @"Unexpected failure that is not keepalive watchdog timeout."); + XCTAssertTrue(done); + [expectation fulfill]; + } + }]; [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; - [call finish]; } +#endif - (void)testDefaultInterceptor { XCTAssertNotNil([[self class] host]); @@ -1321,9 +1342,7 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - // For backwards compatibility options.transportType = [[self class] transportType]; - options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.interceptorFactories = @[ [[DefaultInterceptorFactory alloc] init] ]; @@ -1378,7 +1397,8 @@ static dispatch_once_t initGlobalInterceptorFactory; __block NSUInteger responseCloseCount = 0; __block NSUInteger didWriteDataCount = 0; id factory = [[HookInterceptorFactory alloc] - initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager) { startCount++; @@ -1426,9 +1446,7 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - // For backwards compatibility options.transportType = [[self class] transportType]; - options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.flowControlEnabled = YES; @@ -1506,7 +1524,8 @@ static dispatch_once_t initGlobalInterceptorFactory; __block NSUInteger responseDataCount = 0; __block NSUInteger responseCloseCount = 0; id factory = [[HookInterceptorFactory alloc] - initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager) { startCount++; @@ -1533,7 +1552,6 @@ static dispatch_once_t initGlobalInterceptorFactory; // finish must happen after the hijacking, so directly reply with a close [manager forwardPreviousInterceptorCloseWithTrailingMetadata:@{@"grpc-status" : @"0"} error:nil]; - [manager shutDown]; } receiveNextMessagesHook:nil responseHeaderHook:^(NSDictionary *initialMetadata, GRPCInterceptorManager *manager) { @@ -1560,9 +1578,7 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - // For backwards compatibility options.transportType = [[self class] transportType]; - options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.interceptorFactories = @[ [[DefaultInterceptorFactory alloc] init], factory ]; @@ -1671,9 +1687,7 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - // For backwards compatibility options.transportType = [[self class] transportType]; - options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.flowControlEnabled = YES; @@ -1728,15 +1742,16 @@ static dispatch_once_t initGlobalInterceptorFactory; - (void)testConflictingGlobalInterceptors { id factory = [[HookInterceptorFactory alloc] - initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - startHook:nil - writeDataHook:nil - finishHook:nil - receiveNextMessagesHook:nil - responseHeaderHook:nil - responseDataHook:nil - responseCloseHook:nil - didWriteDataHook:nil]; + initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + startHook:nil + writeDataHook:nil + finishHook:nil + receiveNextMessagesHook:nil + responseHeaderHook:nil + responseDataHook:nil + responseCloseHook:nil + didWriteDataHook:nil]; @try { [GRPCCall2 registerGlobalInterceptor:factory]; XCTFail(@"Did not receive an exception when registering global interceptor the second time"); @@ -1760,7 +1775,8 @@ static dispatch_once_t initGlobalInterceptorFactory; __block NSUInteger didWriteDataCount = 0; id factory = [[HookInterceptorFactory alloc] - initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager) { startCount++; @@ -1856,9 +1872,7 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; - // For backwards compatibility options.transportType = [[self class] transportType]; - options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.flowControlEnabled = YES; diff --git a/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m b/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m index 2e638099e1e..a9c69183332 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m +++ b/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m @@ -17,7 +17,6 @@ */ #import -#import #import #import "InteropTests.h" @@ -61,8 +60,8 @@ static int32_t kLocalInteropServerOverhead = 10; [GRPCCall useInsecureConnectionsForHost:kLocalCleartextHost]; } -+ (GRPCTransportId)transport { - return GRPCDefaultTransportImplList.core_insecure; ++ (GRPCTransportType)transportType { + return GRPCTransportTypeInsecure; } @end diff --git a/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m b/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m index 30d8f4c34af..e8222f602f4 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m +++ b/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m @@ -17,7 +17,6 @@ */ #import -#import #import #import "InteropTests.h" @@ -57,8 +56,8 @@ static int32_t kLocalInteropServerOverhead = 10; return kLocalInteropServerOverhead; // bytes } -+ (GRPCTransportId)transport { - return GRPCDefaultTransportImplList.core_secure; ++ (GRPCTransportType)transportType { + return GRPCTransportTypeChttp2BoringSSL; } - (void)setUp { diff --git a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m index dc48391cbcc..98893a466bd 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m +++ b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m @@ -18,8 +18,9 @@ #import +#ifdef GRPC_COMPILE_WITH_CRONET #import -#import +#endif #import #import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" #import "src/objective-c/tests/RemoteTestClient/Test.pbobjc.h" diff --git a/src/objective-c/tests/InteropTests/InteropTestsRemote.m b/src/objective-c/tests/InteropTests/InteropTestsRemote.m index 2dd8f0aed89..c1cd9b81efc 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsRemote.m +++ b/src/objective-c/tests/InteropTests/InteropTestsRemote.m @@ -53,8 +53,14 @@ static int32_t kRemoteInteropServerOverhead = 12; return kRemoteInteropServerOverhead; // bytes } +#ifdef GRPC_COMPILE_WITH_CRONET ++ (GRPCTransportType)transportType { + return GRPCTransportTypeCronet; +} +#else + (GRPCTransportType)transportType { return GRPCTransportTypeChttp2BoringSSL; } +#endif @end diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile index c83e8861e93..c2297aa00fd 100644 --- a/src/objective-c/tests/Podfile +++ b/src/objective-c/tests/Podfile @@ -30,25 +30,25 @@ target 'MacTests' do grpc_deps end +target 'UnitTests' do + platform :ios, '8.0' + grpc_deps +end + %w( - UnitTests InteropTests + CronetTests ).each do |target_name| target target_name do platform :ios, '8.0' grpc_deps + + pod 'gRPC-Core/Cronet-Implementation', :path => GRPC_LOCAL_SRC + pod 'CronetFramework', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" + pod 'gRPC-Core/Tests', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true end end -target 'CronetTests' do - platform :ios, '8.0' - grpc_deps - - pod 'gRPC/GRPCCoreCronet', :path => GRPC_LOCAL_SRC - pod 'CronetFramework', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" - pod 'gRPC-Core/Tests', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true -end - # gRPC-Core.podspec needs to be modified to be successfully used for local development. A Podfile's # pre_install hook lets us do that. The block passed to it runs after the podspecs are downloaded # and before they are installed in the user project. @@ -103,7 +103,7 @@ post_install do |installer| # the test target 'InteropTestsRemoteWithCronet' # Activate GRPCCall+InternalTests functions for the dedicated build configuration 'Test', which will # be used by all test targets using it. - if /gRPC(-macOS|-iOS|-tvOS|\.|-[0-9a-f])/.match(target.name) + if /gRPC-(mac|i|tv)OS/.match(target.name) target.build_configurations.each do |config| if config.name == 'Cronet' config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_COMPILE_WITH_CRONET=1 GRPC_TEST_OBJC=1' @@ -114,7 +114,7 @@ post_install do |installer| end # Enable NSAssert on gRPC - if /(gRPC|ProtoRPC|RxLibrary)/.match(target.name) + if /(gRPC|ProtoRPC|RxLibrary)-(mac|i|tv)OS/.match(target.name) target.build_configurations.each do |config| if config.name != 'Release' config.build_settings['ENABLE_NS_ASSERTIONS'] = 'YES' diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index 6cb9f5560b9..a88838fdc8b 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -8,14 +8,15 @@ /* Begin PBXBuildFile section */ 5E0282E9215AA697007AC99D /* NSErrorUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E0282E8215AA697007AC99D /* NSErrorUnitTests.m */; }; - 5E08D07023021E3B006D76EA /* InteropTestsMultipleChannels.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487722778226006656AD /* InteropTestsMultipleChannels.m */; }; 5E3F14842278B461007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; 5E3F14852278BF5D007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; 5E3F14862278BFFF007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; 5E3F148D22792856007C6D90 /* ConfigureCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F1487227918AA007C6D90 /* ConfigureCronet.m */; }; + 5E3F148E22792AF5007C6D90 /* ConfigureCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F1487227918AA007C6D90 /* ConfigureCronet.m */; }; 5E7F486422775B37006656AD /* InteropTestsRemoteWithCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE84BF31D4717E40050C6CC /* InteropTestsRemoteWithCronet.m */; }; 5E7F486522775B41006656AD /* CronetUnitTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5EAD6D261E27047400002378 /* CronetUnitTests.mm */; }; 5E7F486E22778086006656AD /* CoreCronetEnd2EndTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F486D22778086006656AD /* CoreCronetEnd2EndTests.mm */; }; + 5E7F487922778226006656AD /* InteropTestsMultipleChannels.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487722778226006656AD /* InteropTestsMultipleChannels.m */; }; 5E7F487D22778256006656AD /* ChannelPoolTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487B22778256006656AD /* ChannelPoolTest.m */; }; 5E7F487E22778256006656AD /* ChannelTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487C22778256006656AD /* ChannelTests.m */; }; 5E7F4880227782C1006656AD /* APIv2Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487F227782C1006656AD /* APIv2Tests.m */; }; @@ -33,7 +34,6 @@ 5EA4770322736178000F72FC /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; 5EA477042273617B000F72FC /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; 5EA4770522736AC4000F72FC /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; - 5ECFED8623030DCC00626501 /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; 65EB19E418B39A8374D407BB /* libPods-CronetTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B1511C20E16A8422B58D61A /* libPods-CronetTests.a */; }; 903163C7FE885838580AEC7A /* libPods-InteropTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D457AD9797664CFA191C3280 /* libPods-InteropTests.a */; }; 953CD2942A3A6D6CE695BE87 /* libPods-MacTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 276873A05AC5479B60DF6079 /* libPods-MacTests.a */; }; @@ -515,6 +515,7 @@ 5EA476F12272816A000F72FC /* Frameworks */, 5EA476F22272816A000F72FC /* Resources */, D11CB94CF56A1E53760D29D8 /* [CP] Copy Pods Resources */, + 0FEFD5FC6B323AC95549AE4A /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -629,7 +630,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 5ECFED8623030DCC00626501 /* TestCertificates.bundle in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -678,6 +678,24 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + 0FEFD5FC6B323AC95549AE4A /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-frameworks.sh", + "${PODS_ROOT}/CronetFramework/Cronet.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; 292EA42A76AC7933A37235FD /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -703,7 +721,7 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC.default-GRPCCoreCronet/gRPCCertificates.bundle", + "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; outputPaths = ( @@ -880,7 +898,6 @@ files = ( 5E3F14852278BF5D007C6D90 /* InteropTestsBlockCallbacks.m in Sources */, 5E3F148D22792856007C6D90 /* ConfigureCronet.m in Sources */, - 5E08D07023021E3B006D76EA /* InteropTestsMultipleChannels.m in Sources */, 5E7F486E22778086006656AD /* CoreCronetEnd2EndTests.mm in Sources */, 5E7F488522778A88006656AD /* InteropTests.m in Sources */, 5E7F486422775B37006656AD /* InteropTestsRemoteWithCronet.m in Sources */, @@ -893,7 +910,9 @@ buildActionMask = 2147483647; files = ( 5E3F14842278B461007C6D90 /* InteropTestsBlockCallbacks.m in Sources */, + 5E3F148E22792AF5007C6D90 /* ConfigureCronet.m in Sources */, 5E7F488922778B04006656AD /* InteropTestsRemote.m in Sources */, + 5E7F487922778226006656AD /* InteropTestsMultipleChannels.m in Sources */, 5EA477042273617B000F72FC /* InteropTestsLocalCleartext.m in Sources */, 5EA4770322736178000F72FC /* InteropTestsLocalSSL.m in Sources */, 5E7F488422778A88006656AD /* InteropTests.m in Sources */, diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme index cbde360a338..adb3c366af2 100644 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme +++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme @@ -23,7 +23,7 @@ @@ -48,7 +48,7 @@ + buildConfiguration = "Cronet"> -#import "../../GRPCClient/private/GRPCCore/GRPCChannel.h" -#import "../../GRPCClient/private/GRPCCore/GRPCChannelPool+Test.h" -#import "../../GRPCClient/private/GRPCCore/GRPCCompletionQueue.h" +#import "../../GRPCClient/private/GRPCChannel.h" +#import "../../GRPCClient/private/GRPCChannelPool+Test.h" +#import "../../GRPCClient/private/GRPCCompletionQueue.h" #define TEST_TIMEOUT 32 diff --git a/src/objective-c/tests/UnitTests/ChannelTests.m b/src/objective-c/tests/UnitTests/ChannelTests.m index 1ed0f16ecaf..df78e8b1162 100644 --- a/src/objective-c/tests/UnitTests/ChannelTests.m +++ b/src/objective-c/tests/UnitTests/ChannelTests.m @@ -19,11 +19,11 @@ #import #import "../../GRPCClient/GRPCCallOptions.h" -#import "../../GRPCClient/private/GRPCCore/GRPCChannel.h" -#import "../../GRPCClient/private/GRPCCore/GRPCChannelPool+Test.h" -#import "../../GRPCClient/private/GRPCCore/GRPCChannelPool.h" -#import "../../GRPCClient/private/GRPCCore/GRPCCompletionQueue.h" -#import "../../GRPCClient/private/GRPCCore/GRPCWrappedCall.h" +#import "../../GRPCClient/private/GRPCChannel.h" +#import "../../GRPCClient/private/GRPCChannelPool+Test.h" +#import "../../GRPCClient/private/GRPCChannelPool.h" +#import "../../GRPCClient/private/GRPCCompletionQueue.h" +#import "../../GRPCClient/private/GRPCWrappedCall.h" static NSString *kDummyHost = @"dummy.host"; static NSString *kDummyPath = @"/dummy/path"; diff --git a/src/objective-c/tests/UnitTests/NSErrorUnitTests.m b/src/objective-c/tests/UnitTests/NSErrorUnitTests.m index 74e5794c480..8a4f03a4460 100644 --- a/src/objective-c/tests/UnitTests/NSErrorUnitTests.m +++ b/src/objective-c/tests/UnitTests/NSErrorUnitTests.m @@ -20,7 +20,7 @@ #import -#import "../../GRPCClient/private/GRPCCore/NSError+GRPC.h" +#import "../../GRPCClient/private/NSError+GRPC.h" @interface NSErrorUnitTests : XCTestCase diff --git a/templates/gRPC-ProtoRPC.podspec.template b/templates/gRPC-ProtoRPC.podspec.template index e94f149ee4a..457d2988036 100644 --- a/templates/gRPC-ProtoRPC.podspec.template +++ b/templates/gRPC-ProtoRPC.podspec.template @@ -44,40 +44,22 @@ s.module_name = name s.header_dir = name - s.default_subspec = 'Main', 'Legacy', 'Legacy-Header' + src_dir = 'src/objective-c/ProtoRPC' - s.subspec 'Legacy-Header' do |ss| - ss.header_mappings_dir = "src/objective-c/ProtoRPC" - ss.public_header_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.h" - ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.h" - end + s.default_subspec = 'Main' s.subspec 'Main' do |ss| - ss.header_mappings_dir = "src/objective-c/ProtoRPC" - ss.dependency "#{s.name}/Legacy-Header", version - ss.dependency 'gRPC/Interface', version - ss.dependency 'Protobuf', '~> 3.0' - - ss.source_files = "src/objective-c/ProtoRPC/ProtoMethod.{h,m}", - "src/objective-c/ProtoRPC/ProtoRPC.{h,m}", - "src/objective-c/ProtoRPC/ProtoService.{h,m}" - end - - s.subspec 'Legacy' do |ss| - ss.header_mappings_dir = "src/objective-c/ProtoRPC" - ss.dependency "#{s.name}/Main", version - ss.dependency "#{s.name}/Legacy-Header", version - ss.dependency 'gRPC/GRPCCore', version + ss.header_mappings_dir = "#{src_dir}" + ss.dependency 'gRPC', version ss.dependency 'gRPC-RxLibrary', version ss.dependency 'Protobuf', '~> 3.0' - ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.m", - "src/objective-c/ProtoRPC/ProtoServiceLegacy.m" + ss.source_files = "#{src_dir}/*.{h,m}" end # CFStream is now default. Leaving this subspec only for compatibility purpose. s.subspec 'CFStream' do |ss| - ss.dependency "#{s.name}/Legacy", version + ss.dependency "#{s.name}/Main", version end s.pod_target_xcconfig = { diff --git a/templates/gRPC-RxLibrary.podspec.template b/templates/gRPC-RxLibrary.podspec.template index 772265dadda..9389c5ecd8d 100644 --- a/templates/gRPC-RxLibrary.podspec.template +++ b/templates/gRPC-RxLibrary.podspec.template @@ -44,23 +44,6 @@ s.module_name = name s.header_dir = name - s.default_subspec = 'Interface', 'Implementation' - - src_dir = 'src/objective-c/RxLibrary' - s.subspec 'Interface' do |ss| - ss.header_mappings_dir = "#{src_dir}" - ss.source_files = "#{src_dir}/*.h" - ss.public_header_files = "#{src_dir}/*.h" - end - - s.subspec 'Implementation' do |ss| - ss.header_mappings_dir = "#{src_dir}" - ss.source_files = "#{src_dir}/*.m", "#{src_dir}/**/*.{h,m}" - ss.private_header_files = "#{src_dir}/**/*.h" - - ss.dependency "#{s.name}/Interface" - end - src_dir = 'src/objective-c/RxLibrary' s.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}" s.private_header_files = "#{src_dir}/private/*.h" diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index e705edc1748..8cb380ede03 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -43,7 +43,13 @@ s.module_name = name s.header_dir = name - s.default_subspec = 'Interface', 'GRPCCore', 'Interface-Legacy' + src_dir = 'src/objective-c/GRPCClient' + + s.dependency 'gRPC-RxLibrary', version + s.default_subspec = 'Main' + + # Certificates, to be able to establish TLS connections: + s.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } s.pod_target_xcconfig = { # This is needed by all pods that depend on gRPC-RxLibrary: @@ -51,103 +57,29 @@ 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO', } - s.subspec 'Interface-Legacy' do |ss| - ss.header_mappings_dir = 'src/objective-c/GRPCClient' + s.subspec 'Main' do |ss| + ss.header_mappings_dir = "#{src_dir}" - ss.public_header_files = "GRPCClient/GRPCCall+ChannelArg.h", - "GRPCClient/GRPCCall+ChannelCredentials.h", - "GRPCClient/GRPCCall+Cronet.h", - "GRPCClient/GRPCCall+OAuth2.h", - "GRPCClient/GRPCCall+Tests.h", - "src/objective-c/GRPCClient/GRPCCallLegacy.h", - "src/objective-c/GRPCClient/GRPCTypes.h" + ss.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}" + ss.exclude_files = "#{src_dir}/GRPCCall+GID.{h,m}" + ss.private_header_files = "#{src_dir}/private/*.h", "#{src_dir}/internal/*.h" - ss.source_files = "GRPCClient/GRPCCall+ChannelArg.h", - "GRPCClient/GRPCCall+ChannelCredentials.h", - "GRPCClient/GRPCCall+Cronet.h", - "GRPCClient/GRPCCall+OAuth2.h", - "GRPCClient/GRPCCall+Tests.h", - "src/objective-c/GRPCClient/GRPCCallLegacy.h", - "src/objective-c/GRPCClient/GRPCTypes.h" - ss.dependency "gRPC-RxLibrary/Interface", version - end - - s.subspec 'Interface' do |ss| - ss.header_mappings_dir = 'src/objective-c/GRPCClient' - - ss.public_header_files = 'src/objective-c/GRPCClient/GRPCCall.h', - 'src/objective-c/GRPCClient/GRPCCall+Interceptor.h', - 'src/objective-c/GRPCClient/GRPCCallOptions.h', - 'src/objective-c/GRPCClient/GRPCInterceptor.h', - 'src/objective-c/GRPCClient/GRPCTransport.h', - 'src/objective-c/GRPCClient/GRPCDispatchable.h', - 'src/objective-c/GRPCClient/version.h' - - ss.source_files = 'src/objective-c/GRPCClient/GRPCCall.h', - 'src/objective-c/GRPCClient/GRPCCall.m', - 'src/objective-c/GRPCClient/GRPCCall+Interceptor.h', - 'src/objective-c/GRPCClient/GRPCCall+Interceptor.m', - 'src/objective-c/GRPCClient/GRPCCallOptions.h', - 'src/objective-c/GRPCClient/GRPCCallOptions.m', - 'src/objective-c/GRPCClient/GRPCDispatchable.h', - 'src/objective-c/GRPCClient/GRPCInterceptor.h', - 'src/objective-c/GRPCClient/GRPCInterceptor.m', - 'src/objective-c/GRPCClient/GRPCTransport.h', - 'src/objective-c/GRPCClient/GRPCTransport.m', - 'src/objective-c/GRPCClient/internal/*.h', - 'src/objective-c/GRPCClient/private/GRPCTransport+Private.h', - 'src/objective-c/GRPCClient/private/GRPCTransport+Private.m', - 'src/objective-c/GRPCClient/version.h' - - ss.dependency "#{s.name}/Interface-Legacy", version - end - - s.subspec 'GRPCCore' do |ss| - ss.header_mappings_dir = 'src/objective-c/GRPCClient' - - ss.public_header_files = 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', - 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', - 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', - 'src/objective-c/GRPCClient/GRPCCall+Tests.h', - 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', - 'src/objective-c/GRPCClient/internal_testing/*.h' - ss.private_header_files = 'src/objective-c/GRPCClient/private/GRPCCore/*.h' - ss.source_files = 'src/objective-c/GRPCClient/internal_testing/*.{h,m}', - 'src/objective-c/GRPCClient/private/GRPCCore/*.{h,m}', - 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', - 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.m', - 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', - 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m', - 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', - 'src/objective-c/GRPCClient/GRPCCall+Cronet.m', - 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', - 'src/objective-c/GRPCClient/GRPCCall+OAuth2.m', - 'src/objective-c/GRPCClient/GRPCCall+Tests.h', - 'src/objective-c/GRPCClient/GRPCCall+Tests.m', - 'src/objective-c/GRPCClient/GRPCCallLegacy.m' - - # Certificates, to be able to establish TLS connections: - ss.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } - - ss.dependency "#{s.name}/Interface-Legacy", version - ss.dependency "#{s.name}/Interface", version ss.dependency 'gRPC-Core', version - ss.dependency 'gRPC-RxLibrary', version - end - - s.subspec 'GRPCCoreCronet' do |ss| - ss.header_mappings_dir = 'src/objective-c/GRPCClient' - - ss.source_files = 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', - 'src/objective-c/GRPCClient/GRPCCall+Cronet.m', - 'src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/*.{h,m}' - ss.dependency "#{s.name}/GRPCCore", version - ss.dependency 'gRPC-Core/Cronet-Implementation', version - ss.dependency 'CronetFramework' end # CFStream is now default. Leaving this subspec only for compatibility purpose. s.subspec 'CFStream' do |ss| - ss.dependency "#{s.name}/GRPCCore", version + ss.dependency "#{s.name}/Main", version + end + + s.subspec 'GID' do |ss| + ss.ios.deployment_target = '7.0' + + ss.header_mappings_dir = "#{src_dir}" + + ss.source_files = "#{src_dir}/GRPCCall+GID.{h,m}" + + ss.dependency "#{s.name}/Main", version + ss.dependency 'Google/SignIn' end end diff --git a/templates/src/objective-c/GRPCClient/version.h.template b/templates/src/objective-c/GRPCClient/private/version.h.template similarity index 100% rename from templates/src/objective-c/GRPCClient/version.h.template rename to templates/src/objective-c/GRPCClient/private/version.h.template From a1ca6a099d90aa0ff8002b75eeee00119d69f4f0 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Wed, 28 Aug 2019 10:07:18 -0700 Subject: [PATCH 1386/1555] Refactor response building in xds test --- test/cpp/end2end/xds_end2end_test.cc | 390 ++++++++++++++------------- 1 file changed, 203 insertions(+), 187 deletions(-) diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index 480680c9a32..1c073de1b12 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -96,7 +96,6 @@ constexpr char kEdsTypeUrl[] = "type.googleapis.com/envoy.api.v2.ClusterLoadAssignment"; constexpr char kDefaultLocalityRegion[] = "xds_default_locality_region"; constexpr char kDefaultLocalityZone[] = "xds_default_locality_zone"; -constexpr char kDefaultLocalitySubzone[] = "xds_default_locality_subzone"; constexpr char kLbDropType[] = "lb"; constexpr char kThrottleDropType[] = "throttle"; constexpr int kDefaultLocalityWeight = 3; @@ -260,6 +259,31 @@ class ClientStats { class EdsServiceImpl : public EdsService { public: + struct ResponseArgs { + struct Locality { + Locality(const grpc::string& sub_zone, std::vector ports, + int lb_weight = kDefaultLocalityWeight, int priority = 0) + : sub_zone(std::move(sub_zone)), + ports(std::move(ports)), + lb_weight(lb_weight), + priority(priority) {} + + const grpc::string sub_zone; + std::vector ports; + int lb_weight; + int priority; + }; + + ResponseArgs() = default; + explicit ResponseArgs(std::vector locality_list) + : locality_list(std::move(locality_list)) {} + + std::vector locality_list; + std::map drop_categories; + FractionalPercent::DenominatorType drop_denominator = + FractionalPercent::MILLION; + }; + using Stream = ServerReaderWriter; using ResponseDelayPair = std::pair; @@ -317,47 +341,35 @@ class EdsServiceImpl : public EdsService { gpr_log(GPR_INFO, "LB[%p]: shut down", this); } - // TODO(juanlishen): Put the args into a struct. - static DiscoveryResponse BuildResponse( - const std::vector>& backend_ports, - const std::vector& lb_weights = {}, - size_t first_locality_name_index = 0, - const std::map& drop_categories = {}, - const FractionalPercent::DenominatorType denominator = - FractionalPercent::MILLION) { + static DiscoveryResponse BuildResponse(const ResponseArgs& args) { ClusterLoadAssignment assignment; assignment.set_cluster_name("service name"); - for (size_t i = 0; i < backend_ports.size(); ++i) { + for (const auto& locality : args.locality_list) { auto* endpoints = assignment.add_endpoints(); - const int lb_weight = - lb_weights.empty() ? kDefaultLocalityWeight : lb_weights[i]; - endpoints->mutable_load_balancing_weight()->set_value(lb_weight); - endpoints->set_priority(0); + endpoints->mutable_load_balancing_weight()->set_value(locality.lb_weight); + endpoints->set_priority(locality.priority); endpoints->mutable_locality()->set_region(kDefaultLocalityRegion); endpoints->mutable_locality()->set_zone(kDefaultLocalityZone); - std::ostringstream sub_zone; - sub_zone << kDefaultLocalitySubzone << '_' - << first_locality_name_index + i; - endpoints->mutable_locality()->set_sub_zone(sub_zone.str()); - for (const int& backend_port : backend_ports[i]) { + endpoints->mutable_locality()->set_sub_zone(locality.sub_zone); + for (const int& port : locality.ports) { auto* lb_endpoints = endpoints->add_lb_endpoints(); auto* endpoint = lb_endpoints->mutable_endpoint(); auto* address = endpoint->mutable_address(); auto* socket_address = address->mutable_socket_address(); socket_address->set_address("127.0.0.1"); - socket_address->set_port_value(backend_port); + socket_address->set_port_value(port); } } - if (!drop_categories.empty()) { + if (!args.drop_categories.empty()) { auto* policy = assignment.mutable_policy(); - for (const auto& p : drop_categories) { + for (const auto& p : args.drop_categories) { const grpc::string& name = p.first; const uint32_t parts_per_million = p.second; auto* drop_overload = policy->add_drop_overloads(); drop_overload->set_category(name); auto* drop_percentage = drop_overload->mutable_drop_percentage(); drop_percentage->set_numerator(parts_per_million); - drop_percentage->set_denominator(denominator); + drop_percentage->set_denominator(args.drop_denominator); } } DiscoveryResponse response; @@ -729,24 +741,6 @@ class XdsEnd2endTest : public ::testing::Test { return backend_ports; } - const std::vector> GetBackendPortsInGroups( - size_t start_index = 0, size_t stop_index = 0, - size_t num_group = 1) const { - if (stop_index == 0) stop_index = backends_.size(); - size_t group_size = (stop_index - start_index) / num_group; - std::vector> backend_ports; - for (size_t i = 0; i < num_group; ++i) { - backend_ports.emplace_back(); - size_t group_start = group_size * i + start_index; - size_t group_stop = - i == num_group - 1 ? stop_index : group_start + group_size; - for (size_t j = group_start; j < group_stop; ++j) { - backend_ports[i].push_back(backends_[j]->port()); - } - } - return backend_ports; - } - void ScheduleResponseForBalancer(size_t i, const DiscoveryResponse& response, int delay_ms) { balancers_[i]->eds_service()->add_response(response, delay_ms); @@ -938,8 +932,10 @@ TEST_F(SingleBalancerTest, Vanilla) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcsPerAddress = 100; - ScheduleResponseForBalancer( - 0, EdsServiceImpl::BuildResponse(GetBackendPortsInGroups()), 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts()}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); // Make sure that trying to connect works without a call. channel_->GetState(true /* try_to_connect */); // We need to wait for all backends to come online. @@ -962,17 +958,18 @@ TEST_F(SingleBalancerTest, SameBackendListedMultipleTimes) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); // Same backend listed twice. - std::vector ports; - ports.push_back(backends_[0]->port()); - ports.push_back(backends_[0]->port()); + std::vector ports(2, backends_[0]->port()); + EdsServiceImpl::ResponseArgs args({ + {"locality0", ports}, + }); const size_t kNumRpcsPerAddress = 10; - ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse({ports}), 0); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); // We need to wait for the backend to come online. WaitForBackend(0); // Send kNumRpcsPerAddress RPCs per server. CheckRpcSendOk(kNumRpcsPerAddress * ports.size()); // Backend should have gotten 20 requests. - EXPECT_EQ(kNumRpcsPerAddress * 2, + EXPECT_EQ(kNumRpcsPerAddress * ports.size(), backends_[0]->backend_service()->request_count()); // And they should have come from a single client port, because of // subchannel sharing. @@ -985,8 +982,10 @@ TEST_F(SingleBalancerTest, SecureNaming) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannel({balancers_[0]->port()}); const size_t kNumRpcsPerAddress = 100; - ScheduleResponseForBalancer( - 0, EdsServiceImpl::BuildResponse(GetBackendPortsInGroups()), 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts()}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); // Make sure that trying to connect works without a call. channel_->GetState(true /* try_to_connect */); // We need to wait for all backends to come online. @@ -1031,11 +1030,17 @@ TEST_F(SingleBalancerTest, InitiallyEmptyServerlist) { const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor(); const int kCallDeadlineMs = kServerlistDelayMs * 2; // First response is an empty serverlist, sent right away. - ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse({{}}), 0); - // Send non-empty serverlist only after kServerlistDelayMs - ScheduleResponseForBalancer( - 0, EdsServiceImpl::BuildResponse(GetBackendPortsInGroups()), - kServerlistDelayMs); + EdsServiceImpl::ResponseArgs::Locality empty_locality("locality0", {}); + EdsServiceImpl::ResponseArgs args({ + empty_locality, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); + // Send non-empty serverlist only after kServerlistDelayMs. + args = EdsServiceImpl::ResponseArgs({ + {"locality0", GetBackendPorts()}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), + kServerlistDelayMs); const auto t0 = system_clock::now(); // Client will block: LB will initially send empty serverlist. CheckRpcSendOk(1, kCallDeadlineMs, true /* wait_for_ready */); @@ -1061,7 +1066,10 @@ TEST_F(SingleBalancerTest, AllServersUnreachableFailFast) { for (size_t i = 0; i < kNumUnreachableServers; ++i) { ports.push_back(grpc_pick_unused_port_or_die()); } - ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse({ports}), 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", ports}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); const Status status = SendRpc(); // The error shouldn't be DEADLINE_EXCEEDED. EXPECT_EQ(StatusCode::UNAVAILABLE, status.error_code()); @@ -1082,11 +1090,11 @@ TEST_F(SingleBalancerTest, LocalityMapWeightedRoundRobin) { const double kLocalityWeightRate1 = static_cast(kLocalityWeight1) / kTotalLocalityWeight; // EDS response contains 2 localities, each of which contains 1 backend. - ScheduleResponseForBalancer( - 0, - EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(0, 2, 2), - {kLocalityWeight0, kLocalityWeight1}), - 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts(0, 1), kLocalityWeight0}, + {"locality1", GetBackendPorts(1, 2), kLocalityWeight1}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); // Wait for both backends to be ready. WaitForAllBackends(1, 0, 2); // Send kNumRpcs RPCs. @@ -1118,14 +1126,19 @@ TEST_F(SingleBalancerTest, LocalityMapStressTest) { const size_t kNumLocalities = 100; // The first EDS response contains kNumLocalities localities, each of which // contains backend 0. - const std::vector> locality_list_0(kNumLocalities, - {backends_[0]->port()}); + EdsServiceImpl::ResponseArgs args; + for (size_t i = 0; i < kNumLocalities; ++i) { + grpc::string name = "locality" + std::to_string(i); + EdsServiceImpl::ResponseArgs::Locality locality(name, + {backends_[0]->port()}); + args.locality_list.emplace_back(std::move(locality)); + } + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); // The second EDS response contains 1 locality, which contains backend 1. - const std::vector> locality_list_1 = - GetBackendPortsInGroups(1, 2); - ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(locality_list_0), - 0); - ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(locality_list_1), + args = EdsServiceImpl::ResponseArgs({ + {"locality0", GetBackendPorts(1, 2)}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 60 * 1000); // Wait until backend 0 is ready, before which kNumLocalities localities are // received and handled by the xds policy. @@ -1162,20 +1175,18 @@ TEST_F(SingleBalancerTest, LocalityMapUpdate) { for (int weight : kLocalityWeights1) { locality_weight_rate_1.push_back(weight / kTotalLocalityWeight1); } - ScheduleResponseForBalancer( - 0, - EdsServiceImpl::BuildResponse( - GetBackendPortsInGroups(0 /*start_index*/, 3 /*stop_index*/, - 3 /*num_group*/), - kLocalityWeights0), - 0); - ScheduleResponseForBalancer( - 0, - EdsServiceImpl::BuildResponse( - GetBackendPortsInGroups(1 /*start_index*/, 4 /*stop_index*/, - 3 /*num_group*/), - kLocalityWeights1, 1 /*first_locality_name_index*/), - 5000); + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts(0, 1), 2}, + {"locality1", GetBackendPorts(1, 2), 3}, + {"locality2", GetBackendPorts(2, 3), 4}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); + args = EdsServiceImpl::ResponseArgs({ + {"locality1", GetBackendPorts(1, 2), 3}, + {"locality2", GetBackendPorts(2, 3), 2}, + {"locality3", GetBackendPorts(3, 4), 6}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 5000); // Wait for the first 3 backends to be ready. WaitForAllBackends(1, 0, 3); gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); @@ -1244,13 +1255,12 @@ TEST_F(SingleBalancerTest, Drop) { const double KDropRateForLbAndThrottle = kDropRateForLb + (1 - kDropRateForLb) * kDropRateForThrottle; // The EDS response contains two drop categories. - ScheduleResponseForBalancer( - 0, - EdsServiceImpl::BuildResponse( - GetBackendPortsInGroups(), {}, 0, - {{kLbDropType, kDropPerMillionForLb}, - {kThrottleDropType, kDropPerMillionForThrottle}}), - 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts()}, + }); + args.drop_categories = {{kLbDropType, kDropPerMillionForLb}, + {kThrottleDropType, kDropPerMillionForThrottle}}; + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); WaitForAllBackends(); // Send kNumRpcs RPCs and count the drops. size_t num_drops = 0; @@ -1286,12 +1296,12 @@ TEST_F(SingleBalancerTest, DropPerHundred) { const uint32_t kDropPerHundredForLb = 10; const double kDropRateForLb = kDropPerHundredForLb / 100.0; // The EDS response contains one drop category. - ScheduleResponseForBalancer( - 0, - EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), {}, 0, - {{kLbDropType, kDropPerHundredForLb}}, - FractionalPercent::HUNDRED), - 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts()}, + }); + args.drop_categories = {{kLbDropType, kDropPerHundredForLb}}; + args.drop_denominator = FractionalPercent::HUNDRED; + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); WaitForAllBackends(); // Send kNumRpcs RPCs and count the drops. size_t num_drops = 0; @@ -1326,12 +1336,12 @@ TEST_F(SingleBalancerTest, DropPerTenThousand) { const uint32_t kDropPerTenThousandForLb = 1000; const double kDropRateForLb = kDropPerTenThousandForLb / 10000.0; // The EDS response contains one drop category. - ScheduleResponseForBalancer( - 0, - EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), {}, 0, - {{kLbDropType, kDropPerTenThousandForLb}}, - FractionalPercent::TEN_THOUSAND), - 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts()}, + }); + args.drop_categories = {{kLbDropType, kDropPerTenThousandForLb}}; + args.drop_denominator = FractionalPercent::TEN_THOUSAND; + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); WaitForAllBackends(); // Send kNumRpcs RPCs and count the drops. size_t num_drops = 0; @@ -1370,22 +1380,18 @@ TEST_F(SingleBalancerTest, DropUpdate) { const double KDropRateForLbAndThrottle = kDropRateForLb + (1 - kDropRateForLb) * kDropRateForThrottle; // The first EDS response contains one drop category. - ScheduleResponseForBalancer( - 0, - EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), {}, 0, - {{kLbDropType, kDropPerMillionForLb}}), - 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts()}, + }); + args.drop_categories = {{kLbDropType, kDropPerMillionForLb}}; + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); // The second EDS response contains two drop categories. // TODO(juanlishen): Change the EDS response sending to deterministic style // (e.g., by using condition variable) so that we can shorten the test // duration. - ScheduleResponseForBalancer( - 0, - EdsServiceImpl::BuildResponse( - GetBackendPortsInGroups(), {}, 0, - {{kLbDropType, kDropPerMillionForLb}, - {kThrottleDropType, kDropPerMillionForThrottle}}), - 10000); + args.drop_categories = {{kLbDropType, kDropPerMillionForLb}, + {kThrottleDropType, kDropPerMillionForThrottle}}; + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 10000); WaitForAllBackends(); // Send kNumRpcs RPCs and count the drops. size_t num_drops = 0; @@ -1465,13 +1471,12 @@ TEST_F(SingleBalancerTest, DropAll) { const uint32_t kDropPerMillionForLb = 100000; const uint32_t kDropPerMillionForThrottle = 1000000; // The EDS response contains two drop categories. - ScheduleResponseForBalancer( - 0, - EdsServiceImpl::BuildResponse( - GetBackendPortsInGroups(), {}, 0, - {{kLbDropType, kDropPerMillionForLb}, - {kThrottleDropType, kDropPerMillionForThrottle}}), - 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts()}, + }); + args.drop_categories = {{kLbDropType, kDropPerMillionForLb}, + {kThrottleDropType, kDropPerMillionForThrottle}}; + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); // Send kNumRpcs RPCs and all of them are dropped. for (size_t i = 0; i < kNumRpcs; ++i) { EchoResponse response; @@ -1493,11 +1498,11 @@ TEST_F(SingleBalancerTest, Fallback) { kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); // Send non-empty serverlist only after kServerlistDelayMs. - ScheduleResponseForBalancer( - 0, - EdsServiceImpl::BuildResponse( - GetBackendPortsInGroups(kNumBackendsInResolution /* start_index */)), - kServerlistDelayMs); + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts(kNumBackendsInResolution)}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), + kServerlistDelayMs); // Wait until all the fallback backends are reachable. WaitForAllBackends(1 /* num_requests_multiple_of */, 0 /* start_index */, kNumBackendsInResolution /* stop_index */); @@ -1542,12 +1547,12 @@ TEST_F(SingleBalancerTest, FallbackUpdate) { kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); // Send non-empty serverlist only after kServerlistDelayMs. - ScheduleResponseForBalancer( - 0, - EdsServiceImpl::BuildResponse(GetBackendPortsInGroups( - kNumBackendsInResolution + - kNumBackendsInResolutionUpdate /* start_index */)), - kServerlistDelayMs); + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts(kNumBackendsInResolution + + kNumBackendsInResolutionUpdate)}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), + kServerlistDelayMs); // Wait until all the fallback backends are reachable. WaitForAllBackends(1 /* num_requests_multiple_of */, 0 /* start_index */, kNumBackendsInResolution /* stop_index */); @@ -1645,8 +1650,10 @@ TEST_F(SingleBalancerTest, FallbackIfResponseReceivedButChildNotReady) { SetNextResolutionForLbChannelAllBalancers(); // Send a serverlist that only contains an unreachable backend before fallback // timeout. - ScheduleResponseForBalancer( - 0, EdsServiceImpl::BuildResponse({{grpc_pick_unused_port_or_die()}}), 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", {grpc_pick_unused_port_or_die()}}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); // Because no child policy is ready before fallback timeout, we enter fallback // mode. WaitForBackend(0); @@ -1659,11 +1666,11 @@ TEST_F(SingleBalancerTest, FallbackModeIsExitedWhenBalancerSaysToDropAllCalls) { // Enter fallback mode because the LB channel fails to connect. WaitForBackend(0); // Return a new balancer that sends a response to drop all calls. - ScheduleResponseForBalancer( - 0, - EdsServiceImpl::BuildResponse(GetBackendPortsInGroups(), {}, 0, - {{kLbDropType, 1000000}}), - 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts()}, + }); + args.drop_categories = {{kLbDropType, 1000000}}; + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); SetNextResolutionForLbChannelAllBalancers(); // Send RPCs until failure. gpr_timespec deadline = gpr_time_add( @@ -1683,8 +1690,10 @@ TEST_F(SingleBalancerTest, FallbackModeIsExitedAfterChildRready) { WaitForBackend(0); // Return a new balancer that sends a dead backend. ShutdownBackend(1); - ScheduleResponseForBalancer( - 0, EdsServiceImpl::BuildResponse({{backends_[1]->port()}}), 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", {backends_[1]->port()}}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); SetNextResolutionForLbChannelAllBalancers(); // The state (TRANSIENT_FAILURE) update from the child policy will be ignored // because we are still in fallback mode. @@ -1708,8 +1717,10 @@ TEST_F(SingleBalancerTest, FallbackModeIsExitedAfterChildRready) { TEST_F(SingleBalancerTest, BackendsRestart) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); - ScheduleResponseForBalancer( - 0, EdsServiceImpl::BuildResponse(GetBackendPortsInGroups()), 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts()}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); WaitForAllBackends(); // Stop backends. RPCs should fail. ShutdownAllBackends(); @@ -1728,12 +1739,14 @@ class UpdatesTest : public XdsEnd2endTest { TEST_F(UpdatesTest, UpdateBalancersButKeepUsingOriginalBalancer) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); - auto first_backend = GetBackendPortsInGroups(0, 1); - auto second_backend = GetBackendPortsInGroups(1, 2); - ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(first_backend), - 0); - ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(second_backend), - 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", {backends_[0]->port()}}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); + args = EdsServiceImpl::ResponseArgs({ + {"locality0", {backends_[1]->port()}}, + }); + ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(args), 0); // Wait until the first backend is ready. WaitForBackend(0); @@ -1781,12 +1794,14 @@ TEST_F(UpdatesTest, UpdateBalancersButKeepUsingOriginalBalancer) { TEST_F(UpdatesTest, UpdateBalancerName) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); - auto first_backend = GetBackendPortsInGroups(0, 1); - auto second_backend = GetBackendPortsInGroups(1, 2); - ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(first_backend), - 0); - ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(second_backend), - 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", {backends_[0]->port()}}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); + args = EdsServiceImpl::ResponseArgs({ + {"locality0", {backends_[1]->port()}}, + }); + ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(args), 0); // Wait until the first backend is ready. WaitForBackend(0); @@ -1852,12 +1867,14 @@ TEST_F(UpdatesTest, UpdateBalancerName) { TEST_F(UpdatesTest, UpdateBalancersRepeated) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); - auto first_backend = GetBackendPortsInGroups(0, 1); - auto second_backend = GetBackendPortsInGroups(1, 2); - ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(first_backend), - 0); - ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(second_backend), - 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", {backends_[0]->port()}}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); + args = EdsServiceImpl::ResponseArgs({ + {"locality0", {backends_[1]->port()}}, + }); + ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(args), 0); // Wait until the first backend is ready. WaitForBackend(0); @@ -1920,12 +1937,14 @@ TEST_F(UpdatesTest, UpdateBalancersRepeated) { TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannel({balancers_[0]->port()}); - auto first_backend = GetBackendPortsInGroups(0, 1); - auto second_backend = GetBackendPortsInGroups(1, 2); - ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(first_backend), - 0); - ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(second_backend), - 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", {backends_[0]->port()}}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); + args = EdsServiceImpl::ResponseArgs({ + {"locality0", {backends_[1]->port()}}, + }); + ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(args), 0); // Start servers and send 10 RPCs per server. gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); @@ -2007,10 +2026,10 @@ TEST_F(SingleBalancerWithClientLoadReportingTest, Vanilla) { const size_t kNumRpcsPerAddress = 100; // TODO(juanlishen): Partition the backends after multiple localities is // tested. - ScheduleResponseForBalancer(0, - EdsServiceImpl::BuildResponse( - GetBackendPortsInGroups(0, backends_.size())), - 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts()}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); // Wait until all backends are ready. int num_ok = 0; int num_failure = 0; @@ -2046,11 +2065,10 @@ TEST_F(SingleBalancerWithClientLoadReportingTest, BalancerRestart) { const size_t kNumBackendsFirstPass = backends_.size() / 2; const size_t kNumBackendsSecondPass = backends_.size() - kNumBackendsFirstPass; - ScheduleResponseForBalancer( - 0, - EdsServiceImpl::BuildResponse( - GetBackendPortsInGroups(0, kNumBackendsFirstPass)), - 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts(0, kNumBackendsFirstPass)}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); // Wait until all backends returned by the balancer are ready. int num_ok = 0; int num_failure = 0; @@ -2077,11 +2095,10 @@ TEST_F(SingleBalancerWithClientLoadReportingTest, BalancerRestart) { } // Now restart the balancer, this time pointing to the new backends. balancers_[0]->Start(server_host_); - ScheduleResponseForBalancer( - 0, - EdsServiceImpl::BuildResponse( - GetBackendPortsInGroups(kNumBackendsFirstPass)), - 0); + args = EdsServiceImpl::ResponseArgs({ + {"locality0", GetBackendPorts(kNumBackendsFirstPass)}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); // Wait for queries to start going to one of the new backends. // This tells us that we're now using the new serverlist. std::tie(num_ok, num_failure, num_drops) = @@ -2116,13 +2133,12 @@ TEST_F(SingleBalancerWithClientLoadReportingAndDropTest, Vanilla) { const double KDropRateForLbAndThrottle = kDropRateForLb + (1 - kDropRateForLb) * kDropRateForThrottle; // The EDS response contains two drop categories. - ScheduleResponseForBalancer( - 0, - EdsServiceImpl::BuildResponse( - GetBackendPortsInGroups(), {}, 0, - {{kLbDropType, kDropPerMillionForLb}, - {kThrottleDropType, kDropPerMillionForThrottle}}), - 0); + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts()}, + }); + args.drop_categories = {{kLbDropType, kDropPerMillionForLb}, + {kThrottleDropType, kDropPerMillionForThrottle}}; + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); int num_ok = 0; int num_failure = 0; int num_drops = 0; From 21c542447784e698ae388ce12087c27fea70535d Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 28 Aug 2019 12:48:06 -0700 Subject: [PATCH 1387/1555] Add API for accessing per-call backend metric data in LB policies. --- .gitmodules | 3 + BUILD | 30 + BUILD.gn | 8 + CMakeLists.txt | 105 ++- Makefile | 118 ++- build.yaml | 15 + config.m4 | 29 +- config.w32 | 32 +- gRPC-Core.podspec | 84 +- grpc.gemspec | 56 +- grpc.gyp | 84 +- package.xml | 56 +- .../filters/client_channel/backend_metric.cc | 78 ++ .../filters/client_channel/backend_metric.h | 36 + .../filters/client_channel/client_channel.cc | 19 + .../ext/filters/client_channel/lb_policy.h | 26 + .../envoy/api/v2/auth/cert.upb.c | 37 +- .../envoy/api/v2/auth/cert.upb.h | 83 +- .../ext/upb-generated/envoy/api/v2/cds.upb.c | 67 +- .../ext/upb-generated/envoy/api/v2/cds.upb.h | 81 +- .../envoy/api/v2/cluster/filter.upb.c | 34 + .../envoy/api/v2/cluster/filter.upb.h | 69 ++ .../api/v2/cluster/outlier_detection.upb.c | 32 +- .../api/v2/cluster/outlier_detection.upb.h | 87 ++- .../envoy/api/v2/core/base.upb.c | 32 + .../envoy/api/v2/core/base.upb.h | 98 +++ .../envoy/api/v2/core/config_source.upb.c | 15 +- .../envoy/api/v2/core/config_source.upb.h | 32 +- .../envoy/api/v2/core/http_uri.upb.c | 35 + .../envoy/api/v2/core/http_uri.upb.h | 80 ++ .../envoy/api/v2/core/protocol.upb.c | 12 +- .../envoy/api/v2/core/protocol.upb.h | 69 ++ .../udpa/data/orca/v1/orca_load_report.upb.c | 58 ++ .../udpa/data/orca/v1/orca_load_report.upb.h | 144 ++++ src/core/lib/gprpp/map.h | 11 +- src/core/lib/transport/static_metadata.cc | 734 +++++++++--------- src/core/lib/transport/static_metadata.h | 176 +++-- src/proto/grpc/lb/v2/BUILD | 7 + src/proto/grpc/lb/v2/eds_for_test.proto | 8 +- src/proto/grpc/lb/v2/lrs_for_test.proto | 9 +- .../lb/v2/orca_load_report_for_test.proto | 58 ++ src/python/grpcio/grpc_core_dependencies.py | 28 +- test/core/end2end/fuzzers/hpack.dictionary | 1 + test/core/util/test_lb_policies.cc | 2 +- test/core/util/test_lb_policies.h | 5 +- test/cpp/end2end/BUILD | 1 + test/cpp/end2end/client_lb_end2end_test.cc | 97 ++- third_party/envoy-api | 2 +- third_party/udpa | 1 + tools/codegen/core/gen_static_metadata.py | 2 + tools/codegen/core/gen_upb_api.sh | 6 +- tools/doxygen/Doxyfile.core.internal | 8 + tools/run_tests/sanity/check_submodules.sh | 3 +- 53 files changed, 2224 insertions(+), 779 deletions(-) create mode 100644 src/core/ext/filters/client_channel/backend_metric.cc create mode 100644 src/core/ext/filters/client_channel/backend_metric.h create mode 100644 src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c create mode 100644 src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h create mode 100644 src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c create mode 100644 src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h create mode 100644 src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c create mode 100644 src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h create mode 100644 src/proto/grpc/lb/v2/orca_load_report_for_test.proto create mode 160000 third_party/udpa diff --git a/.gitmodules b/.gitmodules index 6443f8362aa..2b085e15059 100644 --- a/.gitmodules +++ b/.gitmodules @@ -54,3 +54,6 @@ [submodule "third_party/upb"] path = third_party/upb url = https://github.com/protocolbuffers/upb.git +[submodule "third_party/udpa"] + path = third_party/udpa + url = https://github.com/cncf/udpa.git diff --git a/BUILD b/BUILD index f2a6f67f69f..9198dd61282 100644 --- a/BUILD +++ b/BUILD @@ -1009,6 +1009,7 @@ grpc_cc_library( name = "grpc_client_channel", srcs = [ "src/core/ext/filters/client_channel/backup_poller.cc", + "src/core/ext/filters/client_channel/backend_metric.cc", "src/core/ext/filters/client_channel/channel_connectivity.cc", "src/core/ext/filters/client_channel/client_channel.cc", "src/core/ext/filters/client_channel/client_channel_channelz.cc", @@ -1037,6 +1038,7 @@ grpc_cc_library( ], hdrs = [ "src/core/ext/filters/client_channel/backup_poller.h", + "src/core/ext/filters/client_channel/backend_metric.h", "src/core/ext/filters/client_channel/client_channel.h", "src/core/ext/filters/client_channel/client_channel_channelz.h", "src/core/ext/filters/client_channel/client_channel_factory.h", @@ -1066,6 +1068,7 @@ grpc_cc_library( ], language = "c++", deps = [ + "envoy_orca_upb", "gpr_base", "grpc_base", "grpc_client_authority_filter", @@ -2278,6 +2281,7 @@ grpc_cc_library( "src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c", "src/core/ext/upb-generated/envoy/api/v2/cds.upb.c", "src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c", "src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c", "src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c", "src/core/ext/upb-generated/envoy/api/v2/eds.upb.c", @@ -2290,6 +2294,7 @@ grpc_cc_library( "src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h", "src/core/ext/upb-generated/envoy/api/v2/cds.upb.h", "src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h", "src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h", "src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h", "src/core/ext/upb-generated/envoy/api/v2/eds.upb.h", @@ -2318,6 +2323,7 @@ grpc_cc_library( "src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c", "src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c", "src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c", "src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c", ], hdrs = [ @@ -2326,6 +2332,7 @@ grpc_cc_library( "src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h", "src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h", "src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h", "src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h", ], external_deps = [ @@ -2378,6 +2385,29 @@ grpc_cc_library( ], ) +# Once upb code-gen issue is resolved, replace envoy_orca_upb with this. +# grpc_upb_proto_library( +# name = "envoy_orca_upb", +# deps = ["@envoy_api//udpa/data/orca/v1:orca_load_report"] +# ) + +grpc_cc_library( + name = "envoy_orca_upb", + srcs = [ + "src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c", + ], + hdrs = [ + "src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h", + ], + external_deps = [ + "upb_lib", + ], + language = "c++", + deps = [ + ":proto_gen_validate_upb", + ], +) + # Once upb code-gen issue is resolved, replace grpc_health_upb with this. # grpc_upb_proto_library( # name = "grpc_health_upb", diff --git a/BUILD.gn b/BUILD.gn index eea022eac51..771e968f366 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -208,6 +208,8 @@ config("grpc_config") { "include/grpc/status.h", "include/grpc/support/workaround_list.h", "src/core/ext/filters/census/grpc_context.cc", + "src/core/ext/filters/client_channel/backend_metric.cc", + "src/core/ext/filters/client_channel/backend_metric.h", "src/core/ext/filters/client_channel/backup_poller.cc", "src/core/ext/filters/client_channel/backup_poller.h", "src/core/ext/filters/client_channel/channel_connectivity.cc", @@ -388,6 +390,8 @@ config("grpc_config") { "src/core/ext/upb-generated/envoy/api/v2/cds.upb.h", "src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c", "src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h", "src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c", "src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h", "src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c", @@ -400,6 +404,8 @@ config("grpc_config") { "src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h", "src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c", "src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h", + "src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c", + "src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h", "src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c", "src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h", "src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c", @@ -450,6 +456,8 @@ config("grpc_config") { "src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h", "src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c", "src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h", + "src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c", + "src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h", "src/core/ext/upb-generated/validate/validate.upb.c", "src/core/ext/upb-generated/validate/validate.upb.h", "src/core/lib/avl/avl.cc", diff --git a/CMakeLists.txt b/CMakeLists.txt index f1552a56c1f..c5cdfff7f56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1266,6 +1266,7 @@ add_library(grpc src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc src/core/ext/transport/chttp2/client/authority.cc src/core/ext/transport/chttp2/client/chttp2_connector.cc + src/core/ext/filters/client_channel/backend_metric.cc src/core/ext/filters/client_channel/backup_poller.cc src/core/ext/filters/client_channel/channel_connectivity.cc src/core/ext/filters/client_channel/client_channel.cc @@ -1294,6 +1295,19 @@ add_library(grpc src/core/ext/filters/client_channel/subchannel_pool_interface.cc src/core/ext/filters/deadline/deadline_filter.cc src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c + src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c + src/core/ext/upb-generated/gogoproto/gogo.upb.c + src/core/ext/upb-generated/validate/validate.upb.c + src/core/ext/upb-generated/google/api/annotations.upb.c + src/core/ext/upb-generated/google/api/http.upb.c + src/core/ext/upb-generated/google/protobuf/any.upb.c + src/core/ext/upb-generated/google/protobuf/descriptor.upb.c + src/core/ext/upb-generated/google/protobuf/duration.upb.c + src/core/ext/upb-generated/google/protobuf/empty.upb.c + src/core/ext/upb-generated/google/protobuf/struct.upb.c + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c + src/core/ext/upb-generated/google/rpc/status.upb.c src/core/tsi/fake_transport_security.cc src/core/tsi/local_transport_security.cc src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc @@ -1313,16 +1327,6 @@ add_library(grpc src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c - src/core/ext/upb-generated/google/api/annotations.upb.c - src/core/ext/upb-generated/google/api/http.upb.c - src/core/ext/upb-generated/google/protobuf/any.upb.c - src/core/ext/upb-generated/google/protobuf/descriptor.upb.c - src/core/ext/upb-generated/google/protobuf/duration.upb.c - src/core/ext/upb-generated/google/protobuf/empty.upb.c - src/core/ext/upb-generated/google/protobuf/struct.upb.c - src/core/ext/upb-generated/google/protobuf/timestamp.upb.c - src/core/ext/upb-generated/google/protobuf/wrappers.upb.c - src/core/ext/upb-generated/google/rpc/status.upb.c src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc src/core/ext/filters/client_channel/lb_policy/xds/xds.cc src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc @@ -1331,6 +1335,7 @@ add_library(grpc src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c src/core/ext/upb-generated/envoy/api/v2/cds.upb.c src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c + src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c src/core/ext/upb-generated/envoy/api/v2/eds.upb.c @@ -1343,11 +1348,10 @@ add_library(grpc src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c + src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c src/core/ext/upb-generated/envoy/type/percent.upb.c src/core/ext/upb-generated/envoy/type/range.upb.c - src/core/ext/upb-generated/gogoproto/gogo.upb.c - src/core/ext/upb-generated/validate/validate.upb.c src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -1667,6 +1671,7 @@ add_library(grpc_cronet src/core/ext/filters/http/http_filters_plugin.cc src/core/ext/filters/http/message_compress/message_compress_filter.cc src/core/ext/filters/http/server/http_server_filter.cc + src/core/ext/filters/client_channel/backend_metric.cc src/core/ext/filters/client_channel/backup_poller.cc src/core/ext/filters/client_channel/channel_connectivity.cc src/core/ext/filters/client_channel/client_channel.cc @@ -1701,6 +1706,19 @@ add_library(grpc_cronet third_party/upb/upb/port.c third_party/upb/upb/table.c third_party/upb/upb/upb.c + src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c + src/core/ext/upb-generated/gogoproto/gogo.upb.c + src/core/ext/upb-generated/validate/validate.upb.c + src/core/ext/upb-generated/google/api/annotations.upb.c + src/core/ext/upb-generated/google/api/http.upb.c + src/core/ext/upb-generated/google/protobuf/any.upb.c + src/core/ext/upb-generated/google/protobuf/descriptor.upb.c + src/core/ext/upb-generated/google/protobuf/duration.upb.c + src/core/ext/upb-generated/google/protobuf/empty.upb.c + src/core/ext/upb-generated/google/protobuf/struct.upb.c + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c + src/core/ext/upb-generated/google/rpc/status.upb.c src/core/lib/http/httpcli_security_connector.cc src/core/lib/security/context/security_context.cc src/core/lib/security/credentials/alts/alts_credentials.cc @@ -2059,6 +2077,7 @@ add_library(grpc_test_util src/core/lib/transport/transport_op_string.cc src/core/lib/uri/uri_parser.cc src/core/lib/debug/trace.cc + src/core/ext/filters/client_channel/backend_metric.cc src/core/ext/filters/client_channel/backup_poller.cc src/core/ext/filters/client_channel/channel_connectivity.cc src/core/ext/filters/client_channel/client_channel.cc @@ -2093,6 +2112,19 @@ add_library(grpc_test_util third_party/upb/upb/port.c third_party/upb/upb/table.c third_party/upb/upb/upb.c + src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c + src/core/ext/upb-generated/gogoproto/gogo.upb.c + src/core/ext/upb-generated/validate/validate.upb.c + src/core/ext/upb-generated/google/api/annotations.upb.c + src/core/ext/upb-generated/google/api/http.upb.c + src/core/ext/upb-generated/google/protobuf/any.upb.c + src/core/ext/upb-generated/google/protobuf/descriptor.upb.c + src/core/ext/upb-generated/google/protobuf/duration.upb.c + src/core/ext/upb-generated/google/protobuf/empty.upb.c + src/core/ext/upb-generated/google/protobuf/struct.upb.c + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c + src/core/ext/upb-generated/google/rpc/status.upb.c src/core/ext/transport/chttp2/transport/bin_decoder.cc src/core/ext/transport/chttp2/transport/bin_encoder.cc src/core/ext/transport/chttp2/transport/chttp2_plugin.cc @@ -2399,6 +2431,7 @@ add_library(grpc_test_util_unsecure src/core/lib/transport/transport_op_string.cc src/core/lib/uri/uri_parser.cc src/core/lib/debug/trace.cc + src/core/ext/filters/client_channel/backend_metric.cc src/core/ext/filters/client_channel/backup_poller.cc src/core/ext/filters/client_channel/channel_connectivity.cc src/core/ext/filters/client_channel/client_channel.cc @@ -2433,6 +2466,19 @@ add_library(grpc_test_util_unsecure third_party/upb/upb/port.c third_party/upb/upb/table.c third_party/upb/upb/upb.c + src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c + src/core/ext/upb-generated/gogoproto/gogo.upb.c + src/core/ext/upb-generated/validate/validate.upb.c + src/core/ext/upb-generated/google/api/annotations.upb.c + src/core/ext/upb-generated/google/api/http.upb.c + src/core/ext/upb-generated/google/protobuf/any.upb.c + src/core/ext/upb-generated/google/protobuf/descriptor.upb.c + src/core/ext/upb-generated/google/protobuf/duration.upb.c + src/core/ext/upb-generated/google/protobuf/empty.upb.c + src/core/ext/upb-generated/google/protobuf/struct.upb.c + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c + src/core/ext/upb-generated/google/rpc/status.upb.c src/core/ext/transport/chttp2/transport/bin_decoder.cc src/core/ext/transport/chttp2/transport/bin_encoder.cc src/core/ext/transport/chttp2/transport/chttp2_plugin.cc @@ -2750,6 +2796,7 @@ add_library(grpc_unsecure src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc src/core/ext/transport/chttp2/client/authority.cc src/core/ext/transport/chttp2/client/chttp2_connector.cc + src/core/ext/filters/client_channel/backend_metric.cc src/core/ext/filters/client_channel/backup_poller.cc src/core/ext/filters/client_channel/channel_connectivity.cc src/core/ext/filters/client_channel/client_channel.cc @@ -2784,6 +2831,19 @@ add_library(grpc_unsecure third_party/upb/upb/port.c third_party/upb/upb/table.c third_party/upb/upb/upb.c + src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c + src/core/ext/upb-generated/gogoproto/gogo.upb.c + src/core/ext/upb-generated/validate/validate.upb.c + src/core/ext/upb-generated/google/api/annotations.upb.c + src/core/ext/upb-generated/google/api/http.upb.c + src/core/ext/upb-generated/google/protobuf/any.upb.c + src/core/ext/upb-generated/google/protobuf/descriptor.upb.c + src/core/ext/upb-generated/google/protobuf/duration.upb.c + src/core/ext/upb-generated/google/protobuf/empty.upb.c + src/core/ext/upb-generated/google/protobuf/struct.upb.c + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c + src/core/ext/upb-generated/google/rpc/status.upb.c src/core/ext/transport/inproc/inproc_plugin.cc src/core/ext/transport/inproc/inproc_transport.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -2807,16 +2867,6 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c - src/core/ext/upb-generated/google/api/annotations.upb.c - src/core/ext/upb-generated/google/api/http.upb.c - src/core/ext/upb-generated/google/protobuf/any.upb.c - src/core/ext/upb-generated/google/protobuf/descriptor.upb.c - src/core/ext/upb-generated/google/protobuf/duration.upb.c - src/core/ext/upb-generated/google/protobuf/empty.upb.c - src/core/ext/upb-generated/google/protobuf/struct.upb.c - src/core/ext/upb-generated/google/protobuf/timestamp.upb.c - src/core/ext/upb-generated/google/protobuf/wrappers.upb.c - src/core/ext/upb-generated/google/rpc/status.upb.c src/core/ext/filters/client_channel/lb_policy/xds/xds.cc src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc @@ -2824,6 +2874,7 @@ add_library(grpc_unsecure src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c src/core/ext/upb-generated/envoy/api/v2/cds.upb.c src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c + src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c src/core/ext/upb-generated/envoy/api/v2/eds.upb.c @@ -2836,11 +2887,10 @@ add_library(grpc_unsecure src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c + src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c src/core/ext/upb-generated/envoy/type/percent.upb.c src/core/ext/upb-generated/envoy/type/range.upb.c - src/core/ext/upb-generated/gogoproto/gogo.upb.c - src/core/ext/upb-generated/validate/validate.upb.c src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc src/core/ext/filters/census/grpc_context.cc @@ -13128,11 +13178,18 @@ endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(client_lb_end2end_test + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/orca_load_report_for_test.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/orca_load_report_for_test.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/orca_load_report_for_test.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v2/orca_load_report_for_test.grpc.pb.h test/cpp/end2end/client_lb_end2end_test.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc ) +protobuf_generate_grpc_cpp( + src/proto/grpc/lb/v2/orca_load_report_for_test.proto +) target_include_directories(client_lb_end2end_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/Makefile b/Makefile index 5189f704297..4ebf5b36cf8 100644 --- a/Makefile +++ b/Makefile @@ -2745,6 +2745,22 @@ $(GENDIR)/src/proto/grpc/lb/v2/lrs_for_test.grpc.pb.cc: src/proto/grpc/lb/v2/lrs $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin$(EXECUTABLE_SUFFIX) $< endif +ifeq ($(NO_PROTOC),true) +$(GENDIR)/src/proto/grpc/lb/v2/orca_load_report_for_test.pb.cc: protoc_dep_error +$(GENDIR)/src/proto/grpc/lb/v2/orca_load_report_for_test.grpc.pb.cc: protoc_dep_error +else + +$(GENDIR)/src/proto/grpc/lb/v2/orca_load_report_for_test.pb.cc: src/proto/grpc/lb/v2/orca_load_report_for_test.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) + $(E) "[PROTOC] Generating protobuf CC file from $<" + $(Q) mkdir -p `dirname $@` + $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --cpp_out=$(GENDIR) $< + +$(GENDIR)/src/proto/grpc/lb/v2/orca_load_report_for_test.grpc.pb.cc: src/proto/grpc/lb/v2/orca_load_report_for_test.proto $(GENDIR)/src/proto/grpc/lb/v2/orca_load_report_for_test.pb.cc $(PROTOBUF_DEP) $(PROTOC_PLUGINS) + $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<" + $(Q) mkdir -p `dirname $@` + $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin$(EXECUTABLE_SUFFIX) $< +endif + ifeq ($(NO_PROTOC),true) $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc: protoc_dep_error @@ -3803,6 +3819,7 @@ LIBGRPC_SRC = \ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \ src/core/ext/transport/chttp2/client/authority.cc \ src/core/ext/transport/chttp2/client/chttp2_connector.cc \ + src/core/ext/filters/client_channel/backend_metric.cc \ src/core/ext/filters/client_channel/backup_poller.cc \ src/core/ext/filters/client_channel/channel_connectivity.cc \ src/core/ext/filters/client_channel/client_channel.cc \ @@ -3831,6 +3848,19 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ + src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c \ + src/core/ext/upb-generated/gogoproto/gogo.upb.c \ + src/core/ext/upb-generated/validate/validate.upb.c \ + src/core/ext/upb-generated/google/api/annotations.upb.c \ + src/core/ext/upb-generated/google/api/http.upb.c \ + src/core/ext/upb-generated/google/protobuf/any.upb.c \ + src/core/ext/upb-generated/google/protobuf/descriptor.upb.c \ + src/core/ext/upb-generated/google/protobuf/duration.upb.c \ + src/core/ext/upb-generated/google/protobuf/empty.upb.c \ + src/core/ext/upb-generated/google/protobuf/struct.upb.c \ + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ + src/core/ext/upb-generated/google/rpc/status.upb.c \ src/core/tsi/fake_transport_security.cc \ src/core/tsi/local_transport_security.cc \ src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc \ @@ -3850,16 +3880,6 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \ src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ - src/core/ext/upb-generated/google/api/annotations.upb.c \ - src/core/ext/upb-generated/google/api/http.upb.c \ - src/core/ext/upb-generated/google/protobuf/any.upb.c \ - src/core/ext/upb-generated/google/protobuf/descriptor.upb.c \ - src/core/ext/upb-generated/google/protobuf/duration.upb.c \ - src/core/ext/upb-generated/google/protobuf/empty.upb.c \ - src/core/ext/upb-generated/google/protobuf/struct.upb.c \ - src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ - src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ - src/core/ext/upb-generated/google/rpc/status.upb.c \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc \ @@ -3868,6 +3888,7 @@ LIBGRPC_SRC = \ src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c \ src/core/ext/upb-generated/envoy/api/v2/cds.upb.c \ src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c \ src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c \ src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c \ src/core/ext/upb-generated/envoy/api/v2/eds.upb.c \ @@ -3880,11 +3901,10 @@ LIBGRPC_SRC = \ src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c \ src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c \ src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c \ src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c \ src/core/ext/upb-generated/envoy/type/percent.upb.c \ src/core/ext/upb-generated/envoy/type/range.upb.c \ - src/core/ext/upb-generated/gogoproto/gogo.upb.c \ - src/core/ext/upb-generated/validate/validate.upb.c \ src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc \ src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc \ @@ -4193,6 +4213,7 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/filters/http/http_filters_plugin.cc \ src/core/ext/filters/http/message_compress/message_compress_filter.cc \ src/core/ext/filters/http/server/http_server_filter.cc \ + src/core/ext/filters/client_channel/backend_metric.cc \ src/core/ext/filters/client_channel/backup_poller.cc \ src/core/ext/filters/client_channel/channel_connectivity.cc \ src/core/ext/filters/client_channel/client_channel.cc \ @@ -4227,6 +4248,19 @@ LIBGRPC_CRONET_SRC = \ third_party/upb/upb/port.c \ third_party/upb/upb/table.c \ third_party/upb/upb/upb.c \ + src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c \ + src/core/ext/upb-generated/gogoproto/gogo.upb.c \ + src/core/ext/upb-generated/validate/validate.upb.c \ + src/core/ext/upb-generated/google/api/annotations.upb.c \ + src/core/ext/upb-generated/google/api/http.upb.c \ + src/core/ext/upb-generated/google/protobuf/any.upb.c \ + src/core/ext/upb-generated/google/protobuf/descriptor.upb.c \ + src/core/ext/upb-generated/google/protobuf/duration.upb.c \ + src/core/ext/upb-generated/google/protobuf/empty.upb.c \ + src/core/ext/upb-generated/google/protobuf/struct.upb.c \ + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ + src/core/ext/upb-generated/google/rpc/status.upb.c \ src/core/lib/http/httpcli_security_connector.cc \ src/core/lib/security/context/security_context.cc \ src/core/lib/security/credentials/alts/alts_credentials.cc \ @@ -4573,6 +4607,7 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/transport/transport_op_string.cc \ src/core/lib/uri/uri_parser.cc \ src/core/lib/debug/trace.cc \ + src/core/ext/filters/client_channel/backend_metric.cc \ src/core/ext/filters/client_channel/backup_poller.cc \ src/core/ext/filters/client_channel/channel_connectivity.cc \ src/core/ext/filters/client_channel/client_channel.cc \ @@ -4607,6 +4642,19 @@ LIBGRPC_TEST_UTIL_SRC = \ third_party/upb/upb/port.c \ third_party/upb/upb/table.c \ third_party/upb/upb/upb.c \ + src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c \ + src/core/ext/upb-generated/gogoproto/gogo.upb.c \ + src/core/ext/upb-generated/validate/validate.upb.c \ + src/core/ext/upb-generated/google/api/annotations.upb.c \ + src/core/ext/upb-generated/google/api/http.upb.c \ + src/core/ext/upb-generated/google/protobuf/any.upb.c \ + src/core/ext/upb-generated/google/protobuf/descriptor.upb.c \ + src/core/ext/upb-generated/google/protobuf/duration.upb.c \ + src/core/ext/upb-generated/google/protobuf/empty.upb.c \ + src/core/ext/upb-generated/google/protobuf/struct.upb.c \ + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ + src/core/ext/upb-generated/google/rpc/status.upb.c \ src/core/ext/transport/chttp2/transport/bin_decoder.cc \ src/core/ext/transport/chttp2/transport/bin_encoder.cc \ src/core/ext/transport/chttp2/transport/chttp2_plugin.cc \ @@ -4895,6 +4943,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/lib/transport/transport_op_string.cc \ src/core/lib/uri/uri_parser.cc \ src/core/lib/debug/trace.cc \ + src/core/ext/filters/client_channel/backend_metric.cc \ src/core/ext/filters/client_channel/backup_poller.cc \ src/core/ext/filters/client_channel/channel_connectivity.cc \ src/core/ext/filters/client_channel/client_channel.cc \ @@ -4929,6 +4978,19 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ third_party/upb/upb/port.c \ third_party/upb/upb/table.c \ third_party/upb/upb/upb.c \ + src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c \ + src/core/ext/upb-generated/gogoproto/gogo.upb.c \ + src/core/ext/upb-generated/validate/validate.upb.c \ + src/core/ext/upb-generated/google/api/annotations.upb.c \ + src/core/ext/upb-generated/google/api/http.upb.c \ + src/core/ext/upb-generated/google/protobuf/any.upb.c \ + src/core/ext/upb-generated/google/protobuf/descriptor.upb.c \ + src/core/ext/upb-generated/google/protobuf/duration.upb.c \ + src/core/ext/upb-generated/google/protobuf/empty.upb.c \ + src/core/ext/upb-generated/google/protobuf/struct.upb.c \ + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ + src/core/ext/upb-generated/google/rpc/status.upb.c \ src/core/ext/transport/chttp2/transport/bin_decoder.cc \ src/core/ext/transport/chttp2/transport/bin_encoder.cc \ src/core/ext/transport/chttp2/transport/chttp2_plugin.cc \ @@ -5215,6 +5277,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \ src/core/ext/transport/chttp2/client/authority.cc \ src/core/ext/transport/chttp2/client/chttp2_connector.cc \ + src/core/ext/filters/client_channel/backend_metric.cc \ src/core/ext/filters/client_channel/backup_poller.cc \ src/core/ext/filters/client_channel/channel_connectivity.cc \ src/core/ext/filters/client_channel/client_channel.cc \ @@ -5249,6 +5312,19 @@ LIBGRPC_UNSECURE_SRC = \ third_party/upb/upb/port.c \ third_party/upb/upb/table.c \ third_party/upb/upb/upb.c \ + src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c \ + src/core/ext/upb-generated/gogoproto/gogo.upb.c \ + src/core/ext/upb-generated/validate/validate.upb.c \ + src/core/ext/upb-generated/google/api/annotations.upb.c \ + src/core/ext/upb-generated/google/api/http.upb.c \ + src/core/ext/upb-generated/google/protobuf/any.upb.c \ + src/core/ext/upb-generated/google/protobuf/descriptor.upb.c \ + src/core/ext/upb-generated/google/protobuf/duration.upb.c \ + src/core/ext/upb-generated/google/protobuf/empty.upb.c \ + src/core/ext/upb-generated/google/protobuf/struct.upb.c \ + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ + src/core/ext/upb-generated/google/rpc/status.upb.c \ src/core/ext/transport/inproc/inproc_plugin.cc \ src/core/ext/transport/inproc/inproc_transport.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc \ @@ -5272,16 +5348,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \ src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ - src/core/ext/upb-generated/google/api/annotations.upb.c \ - src/core/ext/upb-generated/google/api/http.upb.c \ - src/core/ext/upb-generated/google/protobuf/any.upb.c \ - src/core/ext/upb-generated/google/protobuf/descriptor.upb.c \ - src/core/ext/upb-generated/google/protobuf/duration.upb.c \ - src/core/ext/upb-generated/google/protobuf/empty.upb.c \ - src/core/ext/upb-generated/google/protobuf/struct.upb.c \ - src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ - src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ - src/core/ext/upb-generated/google/rpc/status.upb.c \ src/core/ext/filters/client_channel/lb_policy/xds/xds.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc \ @@ -5289,6 +5355,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c \ src/core/ext/upb-generated/envoy/api/v2/cds.upb.c \ src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c \ src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c \ src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c \ src/core/ext/upb-generated/envoy/api/v2/eds.upb.c \ @@ -5301,11 +5368,10 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c \ src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c \ src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c \ src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c \ src/core/ext/upb-generated/envoy/type/percent.upb.c \ src/core/ext/upb-generated/envoy/type/range.upb.c \ - src/core/ext/upb-generated/gogoproto/gogo.upb.c \ - src/core/ext/upb-generated/validate/validate.upb.c \ src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc \ src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc \ src/core/ext/filters/census/grpc_context.cc \ @@ -15696,6 +15762,7 @@ endif CLIENT_LB_END2END_TEST_SRC = \ + $(GENDIR)/src/proto/grpc/lb/v2/orca_load_report_for_test.pb.cc $(GENDIR)/src/proto/grpc/lb/v2/orca_load_report_for_test.grpc.pb.cc \ test/cpp/end2end/client_lb_end2end_test.cc \ CLIENT_LB_END2END_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CLIENT_LB_END2END_TEST_SRC)))) @@ -15727,6 +15794,8 @@ endif endif +$(OBJDIR)/$(CONFIG)/src/proto/grpc/lb/v2/orca_load_report_for_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(OBJDIR)/$(CONFIG)/test/cpp/end2end/client_lb_end2end_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a deps_client_lb_end2end_test: $(CLIENT_LB_END2END_TEST_OBJS:.o=.dep) @@ -15736,6 +15805,7 @@ ifneq ($(NO_DEPS),true) -include $(CLIENT_LB_END2END_TEST_OBJS:.o=.dep) endif endif +$(OBJDIR)/$(CONFIG)/test/cpp/end2end/client_lb_end2end_test.o: $(GENDIR)/src/proto/grpc/lb/v2/orca_load_report_for_test.pb.cc $(GENDIR)/src/proto/grpc/lb/v2/orca_load_report_for_test.grpc.pb.cc CODEGEN_TEST_FULL_SRC = \ diff --git a/build.yaml b/build.yaml index cbdbf8a60bc..9c546246ab0 100644 --- a/build.yaml +++ b/build.yaml @@ -113,6 +113,7 @@ filegroups: - src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h - src/core/ext/upb-generated/envoy/api/v2/cds.upb.h - src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h + - src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h - src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h - src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h - src/core/ext/upb-generated/envoy/api/v2/eds.upb.h @@ -124,6 +125,7 @@ filegroups: - src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c - src/core/ext/upb-generated/envoy/api/v2/cds.upb.c - src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c + - src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c - src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c - src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c - src/core/ext/upb-generated/envoy/api/v2/eds.upb.c @@ -143,6 +145,7 @@ filegroups: - src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h - src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h - src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h + - src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h - src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h src: - src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c @@ -150,11 +153,19 @@ filegroups: - src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c - src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c - src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c + - src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c - src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c uses: - envoy_type_upb - google_api_upb - proto_gen_validate_upb +- name: envoy_orca_upb + headers: + - src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h + src: + - src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c + uses: + - proto_gen_validate_upb - name: envoy_type_upb headers: - src/core/ext/upb-generated/envoy/type/percent.upb.h @@ -945,6 +956,7 @@ filegroups: - grpc_base - name: grpc_client_channel headers: + - src/core/ext/filters/client_channel/backend_metric.h - src/core/ext/filters/client_channel/backup_poller.h - src/core/ext/filters/client_channel/client_channel.h - src/core/ext/filters/client_channel/client_channel_channelz.h @@ -973,6 +985,7 @@ filegroups: - src/core/ext/filters/client_channel/subchannel_interface.h - src/core/ext/filters/client_channel/subchannel_pool_interface.h src: + - src/core/ext/filters/client_channel/backend_metric.cc - src/core/ext/filters/client_channel/backup_poller.cc - src/core/ext/filters/client_channel/channel_connectivity.cc - src/core/ext/filters/client_channel/client_channel.cc @@ -1004,6 +1017,7 @@ filegroups: - grpc_base - grpc_deadline_filter - grpc_health_upb + - envoy_orca_upb - name: grpc_client_idle_filter src: - src/core/ext/filters/client_idle/client_idle_filter.cc @@ -4741,6 +4755,7 @@ targets: build: test language: c++ src: + - src/proto/grpc/lb/v2/orca_load_report_for_test.proto - test/cpp/end2end/client_lb_end2end_test.cc deps: - grpc++_test_util diff --git a/config.m4 b/config.m4 index 79f69aa36e4..effefa9b561 100644 --- a/config.m4 +++ b/config.m4 @@ -349,6 +349,7 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \ src/core/ext/transport/chttp2/client/authority.cc \ src/core/ext/transport/chttp2/client/chttp2_connector.cc \ + src/core/ext/filters/client_channel/backend_metric.cc \ src/core/ext/filters/client_channel/backup_poller.cc \ src/core/ext/filters/client_channel/channel_connectivity.cc \ src/core/ext/filters/client_channel/client_channel.cc \ @@ -377,6 +378,19 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/subchannel_pool_interface.cc \ src/core/ext/filters/deadline/deadline_filter.cc \ src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ + src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c \ + src/core/ext/upb-generated/gogoproto/gogo.upb.c \ + src/core/ext/upb-generated/validate/validate.upb.c \ + src/core/ext/upb-generated/google/api/annotations.upb.c \ + src/core/ext/upb-generated/google/api/http.upb.c \ + src/core/ext/upb-generated/google/protobuf/any.upb.c \ + src/core/ext/upb-generated/google/protobuf/descriptor.upb.c \ + src/core/ext/upb-generated/google/protobuf/duration.upb.c \ + src/core/ext/upb-generated/google/protobuf/empty.upb.c \ + src/core/ext/upb-generated/google/protobuf/struct.upb.c \ + src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ + src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ + src/core/ext/upb-generated/google/rpc/status.upb.c \ src/core/tsi/fake_transport_security.cc \ src/core/tsi/local_transport_security.cc \ src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc \ @@ -396,16 +410,6 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc \ src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ - src/core/ext/upb-generated/google/api/annotations.upb.c \ - src/core/ext/upb-generated/google/api/http.upb.c \ - src/core/ext/upb-generated/google/protobuf/any.upb.c \ - src/core/ext/upb-generated/google/protobuf/descriptor.upb.c \ - src/core/ext/upb-generated/google/protobuf/duration.upb.c \ - src/core/ext/upb-generated/google/protobuf/empty.upb.c \ - src/core/ext/upb-generated/google/protobuf/struct.upb.c \ - src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \ - src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \ - src/core/ext/upb-generated/google/rpc/status.upb.c \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds.cc \ src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc \ @@ -414,6 +418,7 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c \ src/core/ext/upb-generated/envoy/api/v2/cds.upb.c \ src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c \ src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c \ src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c \ src/core/ext/upb-generated/envoy/api/v2/eds.upb.c \ @@ -426,11 +431,10 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c \ src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c \ src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c \ + src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c \ src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c \ src/core/ext/upb-generated/envoy/type/percent.upb.c \ src/core/ext/upb-generated/envoy/type/range.upb.c \ - src/core/ext/upb-generated/gogoproto/gogo.upb.c \ - src/core/ext/upb-generated/validate/validate.upb.c \ src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc \ src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc \ @@ -766,6 +770,7 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/src/proto/grpc/gcp) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/src/proto/grpc/health/v1) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/src/proto/grpc/lb/v1) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/udpa/data/orca/v1) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/upb-generated/validate) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/avl) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/backoff) diff --git a/config.w32 b/config.w32 index 994363a0f1f..13b5f1350f0 100644 --- a/config.w32 +++ b/config.w32 @@ -323,6 +323,7 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\transport\\chttp2\\client\\insecure\\channel_create_posix.cc " + "src\\core\\ext\\transport\\chttp2\\client\\authority.cc " + "src\\core\\ext\\transport\\chttp2\\client\\chttp2_connector.cc " + + "src\\core\\ext\\filters\\client_channel\\backend_metric.cc " + "src\\core\\ext\\filters\\client_channel\\backup_poller.cc " + "src\\core\\ext\\filters\\client_channel\\channel_connectivity.cc " + "src\\core\\ext\\filters\\client_channel\\client_channel.cc " + @@ -351,6 +352,19 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\subchannel_pool_interface.cc " + "src\\core\\ext\\filters\\deadline\\deadline_filter.cc " + "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\health\\v1\\health.upb.c " + + "src\\core\\ext\\upb-generated\\udpa\\data\\orca\\v1\\orca_load_report.upb.c " + + "src\\core\\ext\\upb-generated\\gogoproto\\gogo.upb.c " + + "src\\core\\ext\\upb-generated\\validate\\validate.upb.c " + + "src\\core\\ext\\upb-generated\\google\\api\\annotations.upb.c " + + "src\\core\\ext\\upb-generated\\google\\api\\http.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\any.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\descriptor.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\duration.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\empty.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\struct.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\timestamp.upb.c " + + "src\\core\\ext\\upb-generated\\google\\protobuf\\wrappers.upb.c " + + "src\\core\\ext\\upb-generated\\google\\rpc\\status.upb.c " + "src\\core\\tsi\\fake_transport_security.cc " + "src\\core\\tsi\\local_transport_security.cc " + "src\\core\\tsi\\ssl\\session_cache\\ssl_session_boringssl.cc " + @@ -370,16 +384,6 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\grpclb_client_stats.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\load_balancer_api.cc " + "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\lb\\v1\\load_balancer.upb.c " + - "src\\core\\ext\\upb-generated\\google\\api\\annotations.upb.c " + - "src\\core\\ext\\upb-generated\\google\\api\\http.upb.c " + - "src\\core\\ext\\upb-generated\\google\\protobuf\\any.upb.c " + - "src\\core\\ext\\upb-generated\\google\\protobuf\\descriptor.upb.c " + - "src\\core\\ext\\upb-generated\\google\\protobuf\\duration.upb.c " + - "src\\core\\ext\\upb-generated\\google\\protobuf\\empty.upb.c " + - "src\\core\\ext\\upb-generated\\google\\protobuf\\struct.upb.c " + - "src\\core\\ext\\upb-generated\\google\\protobuf\\timestamp.upb.c " + - "src\\core\\ext\\upb-generated\\google\\protobuf\\wrappers.upb.c " + - "src\\core\\ext\\upb-generated\\google\\rpc\\status.upb.c " + "src\\core\\ext\\filters\\client_channel\\resolver\\fake\\fake_resolver.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\xds\\xds.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\xds\\xds_channel_secure.cc " + @@ -388,6 +392,7 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\auth\\cert.upb.c " + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\cds.upb.c " + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\cluster\\circuit_breaker.upb.c " + + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\cluster\\filter.upb.c " + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\cluster\\outlier_detection.upb.c " + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\discovery.upb.c " + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\eds.upb.c " + @@ -400,11 +405,10 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\core\\config_source.upb.c " + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\core\\grpc_service.upb.c " + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\core\\health_check.upb.c " + + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\core\\http_uri.upb.c " + "src\\core\\ext\\upb-generated\\envoy\\api\\v2\\core\\protocol.upb.c " + "src\\core\\ext\\upb-generated\\envoy\\type\\percent.upb.c " + "src\\core\\ext\\upb-generated\\envoy\\type\\range.upb.c " + - "src\\core\\ext\\upb-generated\\gogoproto\\gogo.upb.c " + - "src\\core\\ext\\upb-generated\\validate\\validate.upb.c " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\pick_first\\pick_first.cc " + "src\\core\\ext\\filters\\client_channel\\lb_policy\\round_robin\\round_robin.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\dns_resolver_ares.cc " + @@ -785,6 +789,10 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\health\\v1"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\lb"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\src\\proto\\grpc\\lb\\v1"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\udpa"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\udpa\\data"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\udpa\\data\\orca"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\udpa\\data\\orca\\v1"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\upb-generated\\validate"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\avl"); diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index e6f926ca166..658a3ad6158 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -352,6 +352,7 @@ Pod::Spec.new do |s| 'src/core/tsi/transport_security_interface.h', 'src/core/ext/transport/chttp2/client/authority.h', 'src/core/ext/transport/chttp2/client/chttp2_connector.h', + 'src/core/ext/filters/client_channel/backend_metric.h', 'src/core/ext/filters/client_channel/backup_poller.h', 'src/core/ext/filters/client_channel/client_channel.h', 'src/core/ext/filters/client_channel/client_channel_channelz.h', @@ -381,6 +382,19 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/subchannel_pool_interface.h', 'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h', + 'src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h', + 'src/core/ext/upb-generated/gogoproto/gogo.upb.h', + 'src/core/ext/upb-generated/validate/validate.upb.h', + 'src/core/ext/upb-generated/google/api/annotations.upb.h', + 'src/core/ext/upb-generated/google/api/http.upb.h', + 'src/core/ext/upb-generated/google/protobuf/any.upb.h', + 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.h', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.h', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.h', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.h', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.h', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.h', + 'src/core/ext/upb-generated/google/rpc/status.upb.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/local_transport_security.h', 'src/core/tsi/ssl/session_cache/ssl_session.h', @@ -540,16 +554,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h', 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h', - 'src/core/ext/upb-generated/google/api/annotations.upb.h', - 'src/core/ext/upb-generated/google/api/http.upb.h', - 'src/core/ext/upb-generated/google/protobuf/any.upb.h', - 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.h', - 'src/core/ext/upb-generated/google/protobuf/duration.upb.h', - 'src/core/ext/upb-generated/google/protobuf/empty.upb.h', - 'src/core/ext/upb-generated/google/protobuf/struct.upb.h', - 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.h', - 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.h', - 'src/core/ext/upb-generated/google/rpc/status.upb.h', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h', @@ -557,6 +561,7 @@ Pod::Spec.new do |s| 'src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h', 'src/core/ext/upb-generated/envoy/api/v2/cds.upb.h', 'src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h', 'src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h', 'src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h', 'src/core/ext/upb-generated/envoy/api/v2/eds.upb.h', @@ -569,11 +574,10 @@ Pod::Spec.new do |s| 'src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h', 'src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h', 'src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h', 'src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h', 'src/core/ext/upb-generated/envoy/type/percent.upb.h', 'src/core/ext/upb-generated/envoy/type/range.upb.h', - 'src/core/ext/upb-generated/gogoproto/gogo.upb.h', - 'src/core/ext/upb-generated/validate/validate.upb.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', @@ -847,6 +851,7 @@ Pod::Spec.new do |s| 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc', 'src/core/ext/transport/chttp2/client/authority.cc', 'src/core/ext/transport/chttp2/client/chttp2_connector.cc', + 'src/core/ext/filters/client_channel/backend_metric.cc', 'src/core/ext/filters/client_channel/backup_poller.cc', 'src/core/ext/filters/client_channel/channel_connectivity.cc', 'src/core/ext/filters/client_channel/client_channel.cc', @@ -875,6 +880,19 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', + 'src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c', + 'src/core/ext/upb-generated/gogoproto/gogo.upb.c', + 'src/core/ext/upb-generated/validate/validate.upb.c', + 'src/core/ext/upb-generated/google/api/annotations.upb.c', + 'src/core/ext/upb-generated/google/api/http.upb.c', + 'src/core/ext/upb-generated/google/protobuf/any.upb.c', + 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.c', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', + 'src/core/ext/upb-generated/google/rpc/status.upb.c', 'src/core/tsi/fake_transport_security.cc', 'src/core/tsi/local_transport_security.cc', 'src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc', @@ -894,16 +912,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c', - 'src/core/ext/upb-generated/google/api/annotations.upb.c', - 'src/core/ext/upb-generated/google/api/http.upb.c', - 'src/core/ext/upb-generated/google/protobuf/any.upb.c', - 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.c', - 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', - 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', - 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', - 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', - 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', - 'src/core/ext/upb-generated/google/rpc/status.upb.c', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc', @@ -912,6 +920,7 @@ Pod::Spec.new do |s| 'src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/cds.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/eds.upb.c', @@ -924,11 +933,10 @@ Pod::Spec.new do |s| 'src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c', 'src/core/ext/upb-generated/envoy/type/percent.upb.c', 'src/core/ext/upb-generated/envoy/type/range.upb.c', - 'src/core/ext/upb-generated/gogoproto/gogo.upb.c', - 'src/core/ext/upb-generated/validate/validate.upb.c', 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc', 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc', @@ -1078,6 +1086,7 @@ Pod::Spec.new do |s| 'src/core/tsi/transport_security_interface.h', 'src/core/ext/transport/chttp2/client/authority.h', 'src/core/ext/transport/chttp2/client/chttp2_connector.h', + 'src/core/ext/filters/client_channel/backend_metric.h', 'src/core/ext/filters/client_channel/backup_poller.h', 'src/core/ext/filters/client_channel/client_channel.h', 'src/core/ext/filters/client_channel/client_channel_channelz.h', @@ -1107,6 +1116,19 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/subchannel_pool_interface.h', 'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h', + 'src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h', + 'src/core/ext/upb-generated/gogoproto/gogo.upb.h', + 'src/core/ext/upb-generated/validate/validate.upb.h', + 'src/core/ext/upb-generated/google/api/annotations.upb.h', + 'src/core/ext/upb-generated/google/api/http.upb.h', + 'src/core/ext/upb-generated/google/protobuf/any.upb.h', + 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.h', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.h', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.h', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.h', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.h', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.h', + 'src/core/ext/upb-generated/google/rpc/status.upb.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/local_transport_security.h', 'src/core/tsi/ssl/session_cache/ssl_session.h', @@ -1266,16 +1288,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h', 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h', - 'src/core/ext/upb-generated/google/api/annotations.upb.h', - 'src/core/ext/upb-generated/google/api/http.upb.h', - 'src/core/ext/upb-generated/google/protobuf/any.upb.h', - 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.h', - 'src/core/ext/upb-generated/google/protobuf/duration.upb.h', - 'src/core/ext/upb-generated/google/protobuf/empty.upb.h', - 'src/core/ext/upb-generated/google/protobuf/struct.upb.h', - 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.h', - 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.h', - 'src/core/ext/upb-generated/google/rpc/status.upb.h', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h', @@ -1283,6 +1295,7 @@ Pod::Spec.new do |s| 'src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h', 'src/core/ext/upb-generated/envoy/api/v2/cds.upb.h', 'src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h', 'src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h', 'src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h', 'src/core/ext/upb-generated/envoy/api/v2/eds.upb.h', @@ -1295,11 +1308,10 @@ Pod::Spec.new do |s| 'src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h', 'src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h', 'src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h', + 'src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h', 'src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h', 'src/core/ext/upb-generated/envoy/type/percent.upb.h', 'src/core/ext/upb-generated/envoy/type/range.upb.h', - 'src/core/ext/upb-generated/gogoproto/gogo.upb.h', - 'src/core/ext/upb-generated/validate/validate.upb.h', 'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', diff --git a/grpc.gemspec b/grpc.gemspec index 5a29165c92d..1b705016cee 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -282,6 +282,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/tsi/transport_security_interface.h ) s.files += %w( src/core/ext/transport/chttp2/client/authority.h ) s.files += %w( src/core/ext/transport/chttp2/client/chttp2_connector.h ) + s.files += %w( src/core/ext/filters/client_channel/backend_metric.h ) s.files += %w( src/core/ext/filters/client_channel/backup_poller.h ) s.files += %w( src/core/ext/filters/client_channel/client_channel.h ) s.files += %w( src/core/ext/filters/client_channel/client_channel_channelz.h ) @@ -311,6 +312,19 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/subchannel_pool_interface.h ) s.files += %w( src/core/ext/filters/deadline/deadline_filter.h ) s.files += %w( src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h ) + s.files += %w( src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h ) + s.files += %w( src/core/ext/upb-generated/gogoproto/gogo.upb.h ) + s.files += %w( src/core/ext/upb-generated/validate/validate.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/api/annotations.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/api/http.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/any.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/descriptor.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/duration.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/empty.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/struct.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/timestamp.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/wrappers.upb.h ) + s.files += %w( src/core/ext/upb-generated/google/rpc/status.upb.h ) s.files += %w( src/core/tsi/fake_transport_security.h ) s.files += %w( src/core/tsi/local_transport_security.h ) s.files += %w( src/core/tsi/ssl/session_cache/ssl_session.h ) @@ -470,16 +484,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h ) s.files += %w( src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h ) - s.files += %w( src/core/ext/upb-generated/google/api/annotations.upb.h ) - s.files += %w( src/core/ext/upb-generated/google/api/http.upb.h ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/any.upb.h ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/descriptor.upb.h ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/duration.upb.h ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/empty.upb.h ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/struct.upb.h ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/timestamp.upb.h ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/wrappers.upb.h ) - s.files += %w( src/core/ext/upb-generated/google/rpc/status.upb.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h ) @@ -487,6 +491,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h ) s.files += %w( src/core/ext/upb-generated/envoy/api/v2/cds.upb.h ) s.files += %w( src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h ) s.files += %w( src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h ) s.files += %w( src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h ) s.files += %w( src/core/ext/upb-generated/envoy/api/v2/eds.upb.h ) @@ -499,11 +504,10 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h ) s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h ) s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h ) s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h ) s.files += %w( src/core/ext/upb-generated/envoy/type/percent.upb.h ) s.files += %w( src/core/ext/upb-generated/envoy/type/range.upb.h ) - s.files += %w( src/core/ext/upb-generated/gogoproto/gogo.upb.h ) - s.files += %w( src/core/ext/upb-generated/validate/validate.upb.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/subchannel_list.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h ) @@ -777,6 +781,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc ) s.files += %w( src/core/ext/transport/chttp2/client/authority.cc ) s.files += %w( src/core/ext/transport/chttp2/client/chttp2_connector.cc ) + s.files += %w( src/core/ext/filters/client_channel/backend_metric.cc ) s.files += %w( src/core/ext/filters/client_channel/backup_poller.cc ) s.files += %w( src/core/ext/filters/client_channel/channel_connectivity.cc ) s.files += %w( src/core/ext/filters/client_channel/client_channel.cc ) @@ -805,6 +810,19 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/subchannel_pool_interface.cc ) s.files += %w( src/core/ext/filters/deadline/deadline_filter.cc ) s.files += %w( src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c ) + s.files += %w( src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c ) + s.files += %w( src/core/ext/upb-generated/gogoproto/gogo.upb.c ) + s.files += %w( src/core/ext/upb-generated/validate/validate.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/api/annotations.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/api/http.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/any.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/descriptor.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/duration.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/empty.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/struct.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/timestamp.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/protobuf/wrappers.upb.c ) + s.files += %w( src/core/ext/upb-generated/google/rpc/status.upb.c ) s.files += %w( src/core/tsi/fake_transport_security.cc ) s.files += %w( src/core/tsi/local_transport_security.cc ) s.files += %w( src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc ) @@ -824,16 +842,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc ) s.files += %w( src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c ) - s.files += %w( src/core/ext/upb-generated/google/api/annotations.upb.c ) - s.files += %w( src/core/ext/upb-generated/google/api/http.upb.c ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/any.upb.c ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/descriptor.upb.c ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/duration.upb.c ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/empty.upb.c ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/struct.upb.c ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/timestamp.upb.c ) - s.files += %w( src/core/ext/upb-generated/google/protobuf/wrappers.upb.c ) - s.files += %w( src/core/ext/upb-generated/google/rpc/status.upb.c ) s.files += %w( src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds.cc ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc ) @@ -842,6 +850,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c ) s.files += %w( src/core/ext/upb-generated/envoy/api/v2/cds.upb.c ) s.files += %w( src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c ) s.files += %w( src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c ) s.files += %w( src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c ) s.files += %w( src/core/ext/upb-generated/envoy/api/v2/eds.upb.c ) @@ -854,11 +863,10 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c ) s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c ) s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c ) + s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c ) s.files += %w( src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c ) s.files += %w( src/core/ext/upb-generated/envoy/type/percent.upb.c ) s.files += %w( src/core/ext/upb-generated/envoy/type/range.upb.c ) - s.files += %w( src/core/ext/upb-generated/gogoproto/gogo.upb.c ) - s.files += %w( src/core/ext/upb-generated/validate/validate.upb.c ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc ) diff --git a/grpc.gyp b/grpc.gyp index 3b86e613131..64481e22df3 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -553,6 +553,7 @@ 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc', 'src/core/ext/transport/chttp2/client/authority.cc', 'src/core/ext/transport/chttp2/client/chttp2_connector.cc', + 'src/core/ext/filters/client_channel/backend_metric.cc', 'src/core/ext/filters/client_channel/backup_poller.cc', 'src/core/ext/filters/client_channel/channel_connectivity.cc', 'src/core/ext/filters/client_channel/client_channel.cc', @@ -581,6 +582,19 @@ 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', + 'src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c', + 'src/core/ext/upb-generated/gogoproto/gogo.upb.c', + 'src/core/ext/upb-generated/validate/validate.upb.c', + 'src/core/ext/upb-generated/google/api/annotations.upb.c', + 'src/core/ext/upb-generated/google/api/http.upb.c', + 'src/core/ext/upb-generated/google/protobuf/any.upb.c', + 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.c', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', + 'src/core/ext/upb-generated/google/rpc/status.upb.c', 'src/core/tsi/fake_transport_security.cc', 'src/core/tsi/local_transport_security.cc', 'src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc', @@ -600,16 +614,6 @@ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c', - 'src/core/ext/upb-generated/google/api/annotations.upb.c', - 'src/core/ext/upb-generated/google/api/http.upb.c', - 'src/core/ext/upb-generated/google/protobuf/any.upb.c', - 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.c', - 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', - 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', - 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', - 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', - 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', - 'src/core/ext/upb-generated/google/rpc/status.upb.c', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc', @@ -618,6 +622,7 @@ 'src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/cds.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/eds.upb.c', @@ -630,11 +635,10 @@ 'src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c', 'src/core/ext/upb-generated/envoy/type/percent.upb.c', 'src/core/ext/upb-generated/envoy/type/range.upb.c', - 'src/core/ext/upb-generated/gogoproto/gogo.upb.c', - 'src/core/ext/upb-generated/validate/validate.upb.c', 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc', 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc', @@ -857,6 +861,7 @@ 'src/core/lib/transport/transport_op_string.cc', 'src/core/lib/uri/uri_parser.cc', 'src/core/lib/debug/trace.cc', + 'src/core/ext/filters/client_channel/backend_metric.cc', 'src/core/ext/filters/client_channel/backup_poller.cc', 'src/core/ext/filters/client_channel/channel_connectivity.cc', 'src/core/ext/filters/client_channel/client_channel.cc', @@ -891,6 +896,19 @@ 'third_party/upb/upb/port.c', 'third_party/upb/upb/table.c', 'third_party/upb/upb/upb.c', + 'src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c', + 'src/core/ext/upb-generated/gogoproto/gogo.upb.c', + 'src/core/ext/upb-generated/validate/validate.upb.c', + 'src/core/ext/upb-generated/google/api/annotations.upb.c', + 'src/core/ext/upb-generated/google/api/http.upb.c', + 'src/core/ext/upb-generated/google/protobuf/any.upb.c', + 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.c', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', + 'src/core/ext/upb-generated/google/rpc/status.upb.c', 'src/core/ext/transport/chttp2/transport/bin_decoder.cc', 'src/core/ext/transport/chttp2/transport/bin_encoder.cc', 'src/core/ext/transport/chttp2/transport/chttp2_plugin.cc', @@ -1112,6 +1130,7 @@ 'src/core/lib/transport/transport_op_string.cc', 'src/core/lib/uri/uri_parser.cc', 'src/core/lib/debug/trace.cc', + 'src/core/ext/filters/client_channel/backend_metric.cc', 'src/core/ext/filters/client_channel/backup_poller.cc', 'src/core/ext/filters/client_channel/channel_connectivity.cc', 'src/core/ext/filters/client_channel/client_channel.cc', @@ -1146,6 +1165,19 @@ 'third_party/upb/upb/port.c', 'third_party/upb/upb/table.c', 'third_party/upb/upb/upb.c', + 'src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c', + 'src/core/ext/upb-generated/gogoproto/gogo.upb.c', + 'src/core/ext/upb-generated/validate/validate.upb.c', + 'src/core/ext/upb-generated/google/api/annotations.upb.c', + 'src/core/ext/upb-generated/google/api/http.upb.c', + 'src/core/ext/upb-generated/google/protobuf/any.upb.c', + 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.c', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', + 'src/core/ext/upb-generated/google/rpc/status.upb.c', 'src/core/ext/transport/chttp2/transport/bin_decoder.cc', 'src/core/ext/transport/chttp2/transport/bin_encoder.cc', 'src/core/ext/transport/chttp2/transport/chttp2_plugin.cc', @@ -1378,6 +1410,7 @@ 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc', 'src/core/ext/transport/chttp2/client/authority.cc', 'src/core/ext/transport/chttp2/client/chttp2_connector.cc', + 'src/core/ext/filters/client_channel/backend_metric.cc', 'src/core/ext/filters/client_channel/backup_poller.cc', 'src/core/ext/filters/client_channel/channel_connectivity.cc', 'src/core/ext/filters/client_channel/client_channel.cc', @@ -1412,6 +1445,19 @@ 'third_party/upb/upb/port.c', 'third_party/upb/upb/table.c', 'third_party/upb/upb/upb.c', + 'src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c', + 'src/core/ext/upb-generated/gogoproto/gogo.upb.c', + 'src/core/ext/upb-generated/validate/validate.upb.c', + 'src/core/ext/upb-generated/google/api/annotations.upb.c', + 'src/core/ext/upb-generated/google/api/http.upb.c', + 'src/core/ext/upb-generated/google/protobuf/any.upb.c', + 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.c', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', + 'src/core/ext/upb-generated/google/rpc/status.upb.c', 'src/core/ext/transport/inproc/inproc_plugin.cc', 'src/core/ext/transport/inproc/inproc_transport.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc', @@ -1435,16 +1481,6 @@ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c', - 'src/core/ext/upb-generated/google/api/annotations.upb.c', - 'src/core/ext/upb-generated/google/api/http.upb.c', - 'src/core/ext/upb-generated/google/protobuf/any.upb.c', - 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.c', - 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', - 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', - 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', - 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', - 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', - 'src/core/ext/upb-generated/google/rpc/status.upb.c', 'src/core/ext/filters/client_channel/lb_policy/xds/xds.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc', @@ -1452,6 +1488,7 @@ 'src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/cds.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/eds.upb.c', @@ -1464,11 +1501,10 @@ 'src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c', 'src/core/ext/upb-generated/envoy/type/percent.upb.c', 'src/core/ext/upb-generated/envoy/type/range.upb.c', - 'src/core/ext/upb-generated/gogoproto/gogo.upb.c', - 'src/core/ext/upb-generated/validate/validate.upb.c', 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc', 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc', 'src/core/ext/filters/census/grpc_context.cc', diff --git a/package.xml b/package.xml index 196c6a6d7db..385a57c77ea 100644 --- a/package.xml +++ b/package.xml @@ -287,6 +287,7 @@ + @@ -316,6 +317,19 @@ + + + + + + + + + + + + + @@ -475,16 +489,6 @@ - - - - - - - - - - @@ -492,6 +496,7 @@ + @@ -504,11 +509,10 @@ + - - @@ -782,6 +786,7 @@ + @@ -810,6 +815,19 @@ + + + + + + + + + + + + + @@ -829,16 +847,6 @@ - - - - - - - - - - @@ -847,6 +855,7 @@ + @@ -859,11 +868,10 @@ + - - diff --git a/src/core/ext/filters/client_channel/backend_metric.cc b/src/core/ext/filters/client_channel/backend_metric.cc new file mode 100644 index 00000000000..0d6aa2f6e2c --- /dev/null +++ b/src/core/ext/filters/client_channel/backend_metric.cc @@ -0,0 +1,78 @@ +// +// Copyright 2019 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include + +#include "src/core/ext/filters/client_channel/backend_metric.h" + +#include "src/core/lib/gprpp/string_view.h" +#include "udpa/data/orca/v1/orca_load_report.upb.h" + +namespace grpc_core { + +namespace { + +template +Map ParseMap( + udpa_data_orca_v1_OrcaLoadReport* msg, + EntryType** (*entry_func)(udpa_data_orca_v1_OrcaLoadReport*, size_t*), + upb_strview (*key_func)(const EntryType*), + double (*value_func)(const EntryType*), Arena* arena) { + Map result; + size_t size; + const auto* const* entries = entry_func(msg, &size); + for (size_t i = 0; i < size; ++i) { + upb_strview key_view = key_func(entries[i]); + char* key = static_cast(arena->Alloc(key_view.size + 1)); + memcpy(key, key_view.data, key_view.size); + result[StringView(key, key_view.size)] = value_func(entries[i]); + } + return result; +} + +} // namespace + +const LoadBalancingPolicy::BackendMetricData* ParseBackendMetricData( + const grpc_slice& serialized_load_report, Arena* arena) { + upb::Arena upb_arena; + udpa_data_orca_v1_OrcaLoadReport* msg = + udpa_data_orca_v1_OrcaLoadReport_parse( + reinterpret_cast( + GRPC_SLICE_START_PTR(serialized_load_report)), + GRPC_SLICE_LENGTH(serialized_load_report), upb_arena.ptr()); + if (msg == nullptr) return nullptr; + LoadBalancingPolicy::BackendMetricData* backend_metric_data = + arena->New(); + backend_metric_data->cpu_utilization = + udpa_data_orca_v1_OrcaLoadReport_cpu_utilization(msg); + backend_metric_data->mem_utilization = + udpa_data_orca_v1_OrcaLoadReport_mem_utilization(msg); + backend_metric_data->requests_per_second = + udpa_data_orca_v1_OrcaLoadReport_rps(msg); + backend_metric_data->request_cost = + ParseMap( + msg, udpa_data_orca_v1_OrcaLoadReport_mutable_request_cost, + udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry_key, + udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry_value, arena); + backend_metric_data->utilization = + ParseMap( + msg, udpa_data_orca_v1_OrcaLoadReport_mutable_utilization, + udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry_key, + udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry_value, arena); + return backend_metric_data; +} + +} // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/backend_metric.h b/src/core/ext/filters/client_channel/backend_metric.h new file mode 100644 index 00000000000..d92b76c8d32 --- /dev/null +++ b/src/core/ext/filters/client_channel/backend_metric.h @@ -0,0 +1,36 @@ +// +// Copyright 2019 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_BACKEND_METRIC_H +#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_BACKEND_METRIC_H + +#include + +#include + +#include "src/core/ext/filters/client_channel/lb_policy.h" +#include "src/core/lib/gprpp/arena.h" + +namespace grpc_core { + +// Parses the serialized load report and allocates a BackendMetricData +// object on the arena. +const LoadBalancingPolicy::BackendMetricData* ParseBackendMetricData( + const grpc_slice& serialized_load_report, Arena* arena); + +} // namespace grpc_core + +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_BACKEND_METRIC_H */ diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index db5ddcb46b9..2482614e8c9 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -31,6 +31,7 @@ #include #include +#include "src/core/ext/filters/client_channel/backend_metric.h" #include "src/core/ext/filters/client_channel/backup_poller.h" #include "src/core/ext/filters/client_channel/global_subchannel_pool.h" #include "src/core/ext/filters/client_channel/http_connect_handshaker.h" @@ -374,6 +375,19 @@ class CallData { void* Alloc(size_t size) override { return calld_->arena_->Alloc(size); } + const LoadBalancingPolicy::BackendMetricData* GetBackendMetricData() + override { + if (calld_->backend_metric_data_ == nullptr) { + grpc_linked_mdelem* md = calld_->recv_trailing_metadata_->idx.named + .x_endpoint_load_metrics_bin; + if (md != nullptr) { + calld_->backend_metric_data_ = + ParseBackendMetricData(GRPC_MDVALUE(md->md), calld_->arena_); + } + } + return calld_->backend_metric_data_; + } + private: CallData* calld_; }; @@ -706,6 +720,7 @@ class CallData { bool service_config_applied_ = false; QueuedPickCanceller* pick_canceller_ = nullptr; LbCallState lb_call_state_; + const LoadBalancingPolicy::BackendMetricData* backend_metric_data_ = nullptr; RefCountedPtr connected_subchannel_; void (*lb_recv_trailing_metadata_ready_)( void* user_data, grpc_error* error, @@ -1927,6 +1942,10 @@ CallData::CallData(grpc_call_element* elem, const ChannelData& chand, CallData::~CallData() { grpc_slice_unref_internal(path_); GRPC_ERROR_UNREF(cancel_error_); + if (backend_metric_data_ != nullptr) { + backend_metric_data_ + ->LoadBalancingPolicy::BackendMetricData::~BackendMetricData(); + } // Make sure there are no remaining pending batches. for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { GPR_ASSERT(pending_batches_[i].batch == nullptr); diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h index 7df581288cc..093d5fc30b8 100644 --- a/src/core/ext/filters/client_channel/lb_policy.h +++ b/src/core/ext/filters/client_channel/lb_policy.h @@ -25,6 +25,7 @@ #include "src/core/ext/filters/client_channel/service_config.h" #include "src/core/ext/filters/client_channel/subchannel_interface.h" #include "src/core/lib/gprpp/abstract.h" +#include "src/core/lib/gprpp/map.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/string_view.h" @@ -77,6 +78,26 @@ extern DebugOnlyTraceFlag grpc_trace_lb_policy_refcount; // interested_parties() hooks from the API. class LoadBalancingPolicy : public InternallyRefCounted { public: + // Represents backend metrics reported by the backend to the client. + struct BackendMetricData { + /// CPU utilization expressed as a fraction of available CPU resources. + double cpu_utilization; + /// Memory utilization expressed as a fraction of available memory + /// resources. + double mem_utilization; + /// Total requests per second being served by the backend. This + /// should include all services that a backend is responsible for. + uint64_t requests_per_second; + /// Application-specific requests cost metrics. Metric names are + /// determined by the application. Each value is an absolute cost + /// (e.g. 3487 bytes of storage) associated with the request. + Map request_cost; + /// Application-specific resource utilization metrics. Metric names + /// are determined by the application. Each value is expressed as a + /// fraction of total resources available. + Map utilization; + }; + /// Interface for accessing per-call state. /// Implemented by the client channel and used by the SubchannelPicker. class CallState { @@ -90,6 +111,10 @@ class LoadBalancingPolicy : public InternallyRefCounted { /// for allocations that need to be made on a per-call basis. virtual void* Alloc(size_t size) GRPC_ABSTRACT; + /// Returns the backend metric data returned by the server for the call, + /// or null if no backend metric data was returned. + virtual const BackendMetricData* GetBackendMetricData() GRPC_ABSTRACT; + GRPC_ABSTRACT_BASE_CLASS }; @@ -175,6 +200,7 @@ class LoadBalancingPolicy : public InternallyRefCounted { /// modified by the callback. The callback does not take ownership, /// however, so any data that needs to be used after returning must /// be copied. + /// call_state can be used to obtain backend metric data. // TODO(roth): Replace grpc_error with something better before we allow // people outside of gRPC team to use this API. void (*recv_trailing_metadata_ready)( diff --git a/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c b/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c index 844ad3d147f..f1deb309a60 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +++ b/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c @@ -11,6 +11,8 @@ #include "envoy/api/v2/auth/cert.upb.h" #include "envoy/api/v2/core/base.upb.h" #include "envoy/api/v2/core/config_source.upb.h" +#include "google/protobuf/any.upb.h" +#include "google/protobuf/struct.upb.h" #include "google/protobuf/wrappers.upb.h" #include "validate/validate.upb.h" #include "gogoproto/gogo.upb.h" @@ -30,22 +32,41 @@ const upb_msglayout envoy_api_v2_auth_TlsParameters_msginit = { UPB_SIZE(24, 32), 4, false, }; -static const upb_msglayout *const envoy_api_v2_auth_TlsCertificate_submsgs[5] = { +static const upb_msglayout *const envoy_api_v2_auth_PrivateKeyProvider_submsgs[2] = { + &google_protobuf_Any_msginit, + &google_protobuf_Struct_msginit, +}; + +static const upb_msglayout_field envoy_api_v2_auth_PrivateKeyProvider__fields[3] = { + {1, UPB_SIZE(0, 0), 0, 0, 9, 1}, + {2, UPB_SIZE(8, 16), UPB_SIZE(-13, -25), 1, 11, 1}, + {3, UPB_SIZE(8, 16), UPB_SIZE(-13, -25), 0, 11, 1}, +}; + +const upb_msglayout envoy_api_v2_auth_PrivateKeyProvider_msginit = { + &envoy_api_v2_auth_PrivateKeyProvider_submsgs[0], + &envoy_api_v2_auth_PrivateKeyProvider__fields[0], + UPB_SIZE(16, 32), 3, false, +}; + +static const upb_msglayout *const envoy_api_v2_auth_TlsCertificate_submsgs[6] = { + &envoy_api_v2_auth_PrivateKeyProvider_msginit, &envoy_api_v2_core_DataSource_msginit, }; -static const upb_msglayout_field envoy_api_v2_auth_TlsCertificate__fields[5] = { - {1, UPB_SIZE(0, 0), 0, 0, 11, 1}, - {2, UPB_SIZE(4, 8), 0, 0, 11, 1}, - {3, UPB_SIZE(8, 16), 0, 0, 11, 1}, - {4, UPB_SIZE(12, 24), 0, 0, 11, 1}, - {5, UPB_SIZE(16, 32), 0, 0, 11, 3}, +static const upb_msglayout_field envoy_api_v2_auth_TlsCertificate__fields[6] = { + {1, UPB_SIZE(0, 0), 0, 1, 11, 1}, + {2, UPB_SIZE(4, 8), 0, 1, 11, 1}, + {3, UPB_SIZE(8, 16), 0, 1, 11, 1}, + {4, UPB_SIZE(12, 24), 0, 1, 11, 1}, + {5, UPB_SIZE(20, 40), 0, 1, 11, 3}, + {6, UPB_SIZE(16, 32), 0, 0, 11, 1}, }; const upb_msglayout envoy_api_v2_auth_TlsCertificate_msginit = { &envoy_api_v2_auth_TlsCertificate_submsgs[0], &envoy_api_v2_auth_TlsCertificate__fields[0], - UPB_SIZE(20, 40), 5, false, + UPB_SIZE(24, 48), 6, false, }; static const upb_msglayout *const envoy_api_v2_auth_TlsSessionTicketKeys_submsgs[1] = { diff --git a/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h b/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h index 89aeaee2fd7..252d9d76e9e 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h @@ -21,6 +21,7 @@ extern "C" { #endif struct envoy_api_v2_auth_TlsParameters; +struct envoy_api_v2_auth_PrivateKeyProvider; struct envoy_api_v2_auth_TlsCertificate; struct envoy_api_v2_auth_TlsSessionTicketKeys; struct envoy_api_v2_auth_CertificateValidationContext; @@ -31,6 +32,7 @@ struct envoy_api_v2_auth_DownstreamTlsContext; struct envoy_api_v2_auth_SdsSecretConfig; struct envoy_api_v2_auth_Secret; typedef struct envoy_api_v2_auth_TlsParameters envoy_api_v2_auth_TlsParameters; +typedef struct envoy_api_v2_auth_PrivateKeyProvider envoy_api_v2_auth_PrivateKeyProvider; typedef struct envoy_api_v2_auth_TlsCertificate envoy_api_v2_auth_TlsCertificate; typedef struct envoy_api_v2_auth_TlsSessionTicketKeys envoy_api_v2_auth_TlsSessionTicketKeys; typedef struct envoy_api_v2_auth_CertificateValidationContext envoy_api_v2_auth_CertificateValidationContext; @@ -41,6 +43,7 @@ typedef struct envoy_api_v2_auth_DownstreamTlsContext envoy_api_v2_auth_Downstre typedef struct envoy_api_v2_auth_SdsSecretConfig envoy_api_v2_auth_SdsSecretConfig; typedef struct envoy_api_v2_auth_Secret envoy_api_v2_auth_Secret; extern const upb_msglayout envoy_api_v2_auth_TlsParameters_msginit; +extern const upb_msglayout envoy_api_v2_auth_PrivateKeyProvider_msginit; extern const upb_msglayout envoy_api_v2_auth_TlsCertificate_msginit; extern const upb_msglayout envoy_api_v2_auth_TlsSessionTicketKeys_msginit; extern const upb_msglayout envoy_api_v2_auth_CertificateValidationContext_msginit; @@ -52,11 +55,15 @@ extern const upb_msglayout envoy_api_v2_auth_SdsSecretConfig_msginit; extern const upb_msglayout envoy_api_v2_auth_Secret_msginit; struct envoy_api_v2_core_ConfigSource; struct envoy_api_v2_core_DataSource; +struct google_protobuf_Any; struct google_protobuf_BoolValue; +struct google_protobuf_Struct; struct google_protobuf_UInt32Value; extern const upb_msglayout envoy_api_v2_core_ConfigSource_msginit; extern const upb_msglayout envoy_api_v2_core_DataSource_msginit; +extern const upb_msglayout google_protobuf_Any_msginit; extern const upb_msglayout google_protobuf_BoolValue_msginit; +extern const upb_msglayout google_protobuf_Struct_msginit; extern const upb_msglayout google_protobuf_UInt32Value_msginit; typedef enum { @@ -114,6 +121,61 @@ UPB_INLINE bool envoy_api_v2_auth_TlsParameters_add_ecdh_curves(envoy_api_v2_aut msg, UPB_SIZE(20, 24), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); } +/* envoy.api.v2.auth.PrivateKeyProvider */ + +UPB_INLINE envoy_api_v2_auth_PrivateKeyProvider *envoy_api_v2_auth_PrivateKeyProvider_new(upb_arena *arena) { + return (envoy_api_v2_auth_PrivateKeyProvider *)upb_msg_new(&envoy_api_v2_auth_PrivateKeyProvider_msginit, arena); +} +UPB_INLINE envoy_api_v2_auth_PrivateKeyProvider *envoy_api_v2_auth_PrivateKeyProvider_parse(const char *buf, size_t size, + upb_arena *arena) { + envoy_api_v2_auth_PrivateKeyProvider *ret = envoy_api_v2_auth_PrivateKeyProvider_new(arena); + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_auth_PrivateKeyProvider_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *envoy_api_v2_auth_PrivateKeyProvider_serialize(const envoy_api_v2_auth_PrivateKeyProvider *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &envoy_api_v2_auth_PrivateKeyProvider_msginit, arena, len); +} + +typedef enum { + envoy_api_v2_auth_PrivateKeyProvider_config_type_config = 2, + envoy_api_v2_auth_PrivateKeyProvider_config_type_typed_config = 3, + envoy_api_v2_auth_PrivateKeyProvider_config_type_NOT_SET = 0 +} envoy_api_v2_auth_PrivateKeyProvider_config_type_oneofcases; +UPB_INLINE envoy_api_v2_auth_PrivateKeyProvider_config_type_oneofcases envoy_api_v2_auth_PrivateKeyProvider_config_type_case(const envoy_api_v2_auth_PrivateKeyProvider* msg) { return (envoy_api_v2_auth_PrivateKeyProvider_config_type_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(12, 24)); } + +UPB_INLINE upb_strview envoy_api_v2_auth_PrivateKeyProvider_provider_name(const envoy_api_v2_auth_PrivateKeyProvider *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } +UPB_INLINE bool envoy_api_v2_auth_PrivateKeyProvider_has_config(const envoy_api_v2_auth_PrivateKeyProvider *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(12, 24), 2); } +UPB_INLINE const struct google_protobuf_Struct* envoy_api_v2_auth_PrivateKeyProvider_config(const envoy_api_v2_auth_PrivateKeyProvider *msg) { return UPB_READ_ONEOF(msg, const struct google_protobuf_Struct*, UPB_SIZE(8, 16), UPB_SIZE(12, 24), 2, NULL); } +UPB_INLINE bool envoy_api_v2_auth_PrivateKeyProvider_has_typed_config(const envoy_api_v2_auth_PrivateKeyProvider *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(12, 24), 3); } +UPB_INLINE const struct google_protobuf_Any* envoy_api_v2_auth_PrivateKeyProvider_typed_config(const envoy_api_v2_auth_PrivateKeyProvider *msg) { return UPB_READ_ONEOF(msg, const struct google_protobuf_Any*, UPB_SIZE(8, 16), UPB_SIZE(12, 24), 3, NULL); } + +UPB_INLINE void envoy_api_v2_auth_PrivateKeyProvider_set_provider_name(envoy_api_v2_auth_PrivateKeyProvider *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE void envoy_api_v2_auth_PrivateKeyProvider_set_config(envoy_api_v2_auth_PrivateKeyProvider *msg, struct google_protobuf_Struct* value) { + UPB_WRITE_ONEOF(msg, struct google_protobuf_Struct*, UPB_SIZE(8, 16), value, UPB_SIZE(12, 24), 2); +} +UPB_INLINE struct google_protobuf_Struct* envoy_api_v2_auth_PrivateKeyProvider_mutable_config(envoy_api_v2_auth_PrivateKeyProvider *msg, upb_arena *arena) { + struct google_protobuf_Struct* sub = (struct google_protobuf_Struct*)envoy_api_v2_auth_PrivateKeyProvider_config(msg); + if (sub == NULL) { + sub = (struct google_protobuf_Struct*)upb_msg_new(&google_protobuf_Struct_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_auth_PrivateKeyProvider_set_config(msg, sub); + } + return sub; +} +UPB_INLINE void envoy_api_v2_auth_PrivateKeyProvider_set_typed_config(envoy_api_v2_auth_PrivateKeyProvider *msg, struct google_protobuf_Any* value) { + UPB_WRITE_ONEOF(msg, struct google_protobuf_Any*, UPB_SIZE(8, 16), value, UPB_SIZE(12, 24), 3); +} +UPB_INLINE struct google_protobuf_Any* envoy_api_v2_auth_PrivateKeyProvider_mutable_typed_config(envoy_api_v2_auth_PrivateKeyProvider *msg, upb_arena *arena) { + struct google_protobuf_Any* sub = (struct google_protobuf_Any*)envoy_api_v2_auth_PrivateKeyProvider_typed_config(msg); + if (sub == NULL) { + sub = (struct google_protobuf_Any*)upb_msg_new(&google_protobuf_Any_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_auth_PrivateKeyProvider_set_typed_config(msg, sub); + } + return sub; +} + /* envoy.api.v2.auth.TlsCertificate */ UPB_INLINE envoy_api_v2_auth_TlsCertificate *envoy_api_v2_auth_TlsCertificate_new(upb_arena *arena) { @@ -132,7 +194,8 @@ UPB_INLINE const struct envoy_api_v2_core_DataSource* envoy_api_v2_auth_TlsCerti UPB_INLINE const struct envoy_api_v2_core_DataSource* envoy_api_v2_auth_TlsCertificate_private_key(const envoy_api_v2_auth_TlsCertificate *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_DataSource*, UPB_SIZE(4, 8)); } UPB_INLINE const struct envoy_api_v2_core_DataSource* envoy_api_v2_auth_TlsCertificate_password(const envoy_api_v2_auth_TlsCertificate *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_DataSource*, UPB_SIZE(8, 16)); } UPB_INLINE const struct envoy_api_v2_core_DataSource* envoy_api_v2_auth_TlsCertificate_ocsp_staple(const envoy_api_v2_auth_TlsCertificate *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_DataSource*, UPB_SIZE(12, 24)); } -UPB_INLINE const struct envoy_api_v2_core_DataSource* const* envoy_api_v2_auth_TlsCertificate_signed_certificate_timestamp(const envoy_api_v2_auth_TlsCertificate *msg, size_t *len) { return (const struct envoy_api_v2_core_DataSource* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len); } +UPB_INLINE const struct envoy_api_v2_core_DataSource* const* envoy_api_v2_auth_TlsCertificate_signed_certificate_timestamp(const envoy_api_v2_auth_TlsCertificate *msg, size_t *len) { return (const struct envoy_api_v2_core_DataSource* const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len); } +UPB_INLINE const envoy_api_v2_auth_PrivateKeyProvider* envoy_api_v2_auth_TlsCertificate_private_key_provider(const envoy_api_v2_auth_TlsCertificate *msg) { return UPB_FIELD_AT(msg, const envoy_api_v2_auth_PrivateKeyProvider*, UPB_SIZE(16, 32)); } UPB_INLINE void envoy_api_v2_auth_TlsCertificate_set_certificate_chain(envoy_api_v2_auth_TlsCertificate *msg, struct envoy_api_v2_core_DataSource* value) { UPB_FIELD_AT(msg, struct envoy_api_v2_core_DataSource*, UPB_SIZE(0, 0)) = value; @@ -183,18 +246,30 @@ UPB_INLINE struct envoy_api_v2_core_DataSource* envoy_api_v2_auth_TlsCertificate return sub; } UPB_INLINE struct envoy_api_v2_core_DataSource** envoy_api_v2_auth_TlsCertificate_mutable_signed_certificate_timestamp(envoy_api_v2_auth_TlsCertificate *msg, size_t *len) { - return (struct envoy_api_v2_core_DataSource**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len); + return (struct envoy_api_v2_core_DataSource**)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 40), len); } UPB_INLINE struct envoy_api_v2_core_DataSource** envoy_api_v2_auth_TlsCertificate_resize_signed_certificate_timestamp(envoy_api_v2_auth_TlsCertificate *msg, size_t len, upb_arena *arena) { - return (struct envoy_api_v2_core_DataSource**)_upb_array_resize_accessor(msg, UPB_SIZE(16, 32), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); + return (struct envoy_api_v2_core_DataSource**)_upb_array_resize_accessor(msg, UPB_SIZE(20, 40), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); } UPB_INLINE struct envoy_api_v2_core_DataSource* envoy_api_v2_auth_TlsCertificate_add_signed_certificate_timestamp(envoy_api_v2_auth_TlsCertificate *msg, upb_arena *arena) { struct envoy_api_v2_core_DataSource* sub = (struct envoy_api_v2_core_DataSource*)upb_msg_new(&envoy_api_v2_core_DataSource_msginit, arena); bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(16, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + msg, UPB_SIZE(20, 40), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); if (!ok) return NULL; return sub; } +UPB_INLINE void envoy_api_v2_auth_TlsCertificate_set_private_key_provider(envoy_api_v2_auth_TlsCertificate *msg, envoy_api_v2_auth_PrivateKeyProvider* value) { + UPB_FIELD_AT(msg, envoy_api_v2_auth_PrivateKeyProvider*, UPB_SIZE(16, 32)) = value; +} +UPB_INLINE struct envoy_api_v2_auth_PrivateKeyProvider* envoy_api_v2_auth_TlsCertificate_mutable_private_key_provider(envoy_api_v2_auth_TlsCertificate *msg, upb_arena *arena) { + struct envoy_api_v2_auth_PrivateKeyProvider* sub = (struct envoy_api_v2_auth_PrivateKeyProvider*)envoy_api_v2_auth_TlsCertificate_private_key_provider(msg); + if (sub == NULL) { + sub = (struct envoy_api_v2_auth_PrivateKeyProvider*)upb_msg_new(&envoy_api_v2_auth_PrivateKeyProvider_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_auth_TlsCertificate_set_private_key_provider(msg, sub); + } + return sub; +} /* envoy.api.v2.auth.TlsSessionTicketKeys */ diff --git a/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c b/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c index f5a7b9195e1..9a0b48a99cc 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c +++ b/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c @@ -17,6 +17,7 @@ #include "envoy/api/v2/core/health_check.upb.h" #include "envoy/api/v2/core/protocol.upb.h" #include "envoy/api/v2/cluster/circuit_breaker.upb.h" +#include "envoy/api/v2/cluster/filter.upb.h" #include "envoy/api/v2/cluster/outlier_detection.upb.h" #include "envoy/api/v2/eds.upb.h" #include "envoy/type/percent.upb.h" @@ -30,7 +31,7 @@ #include "upb/port_def.inc" -static const upb_msglayout *const envoy_api_v2_Cluster_submsgs[28] = { +static const upb_msglayout *const envoy_api_v2_Cluster_submsgs[29] = { &envoy_api_v2_Cluster_CommonLbConfig_msginit, &envoy_api_v2_Cluster_CustomClusterType_msginit, &envoy_api_v2_Cluster_EdsClusterConfig_msginit, @@ -44,6 +45,7 @@ static const upb_msglayout *const envoy_api_v2_Cluster_submsgs[28] = { &envoy_api_v2_UpstreamConnectionOptions_msginit, &envoy_api_v2_auth_UpstreamTlsContext_msginit, &envoy_api_v2_cluster_CircuitBreakers_msginit, + &envoy_api_v2_cluster_Filter_msginit, &envoy_api_v2_cluster_OutlierDetection_msginit, &envoy_api_v2_core_Address_msginit, &envoy_api_v2_core_BindConfig_msginit, @@ -57,49 +59,51 @@ static const upb_msglayout *const envoy_api_v2_Cluster_submsgs[28] = { &google_protobuf_UInt32Value_msginit, }; -static const upb_msglayout_field envoy_api_v2_Cluster__fields[36] = { +static const upb_msglayout_field envoy_api_v2_Cluster__fields[38] = { {1, UPB_SIZE(28, 32), 0, 0, 9, 1}, - {2, UPB_SIZE(144, 256), UPB_SIZE(-153, -265), 0, 14, 1}, + {2, UPB_SIZE(144, 264), UPB_SIZE(-153, -273), 0, 14, 1}, {3, UPB_SIZE(44, 64), 0, 2, 11, 1}, - {4, UPB_SIZE(48, 72), 0, 22, 11, 1}, - {5, UPB_SIZE(52, 80), 0, 23, 11, 1}, + {4, UPB_SIZE(48, 72), 0, 23, 11, 1}, + {5, UPB_SIZE(52, 80), 0, 24, 11, 1}, {6, UPB_SIZE(0, 0), 0, 0, 14, 1}, - {7, UPB_SIZE(120, 216), 0, 14, 11, 3}, - {8, UPB_SIZE(124, 224), 0, 16, 11, 3}, - {9, UPB_SIZE(56, 88), 0, 23, 11, 1}, + {7, UPB_SIZE(120, 216), 0, 15, 11, 3}, + {8, UPB_SIZE(124, 224), 0, 17, 11, 3}, + {9, UPB_SIZE(56, 88), 0, 24, 11, 1}, {10, UPB_SIZE(60, 96), 0, 12, 11, 1}, {11, UPB_SIZE(64, 104), 0, 11, 11, 1}, - {13, UPB_SIZE(68, 112), 0, 17, 11, 1}, - {14, UPB_SIZE(72, 120), 0, 18, 11, 1}, - {16, UPB_SIZE(76, 128), 0, 22, 11, 1}, + {13, UPB_SIZE(68, 112), 0, 18, 11, 1}, + {14, UPB_SIZE(72, 120), 0, 19, 11, 1}, + {16, UPB_SIZE(76, 128), 0, 23, 11, 1}, {17, UPB_SIZE(8, 8), 0, 0, 14, 1}, - {18, UPB_SIZE(128, 232), 0, 14, 11, 3}, - {19, UPB_SIZE(80, 136), 0, 13, 11, 1}, - {20, UPB_SIZE(84, 144), 0, 22, 11, 1}, - {21, UPB_SIZE(88, 152), 0, 15, 11, 1}, + {18, UPB_SIZE(128, 232), 0, 15, 11, 3}, + {19, UPB_SIZE(80, 136), 0, 14, 11, 1}, + {20, UPB_SIZE(84, 144), 0, 23, 11, 1}, + {21, UPB_SIZE(88, 152), 0, 16, 11, 1}, {22, UPB_SIZE(92, 160), 0, 4, 11, 1}, - {23, UPB_SIZE(156, 272), UPB_SIZE(-161, -281), 7, 11, 1}, - {24, UPB_SIZE(96, 168), 0, 21, 11, 1}, - {25, UPB_SIZE(100, 176), 0, 20, 11, 1}, + {23, UPB_SIZE(156, 280), UPB_SIZE(-161, -289), 7, 11, 1}, + {24, UPB_SIZE(96, 168), 0, 22, 11, 1}, + {25, UPB_SIZE(100, 176), 0, 21, 11, 1}, {26, UPB_SIZE(16, 16), 0, 0, 14, 1}, {27, UPB_SIZE(104, 184), 0, 0, 11, 1}, {28, UPB_SIZE(36, 48), 0, 0, 9, 1}, - {29, UPB_SIZE(108, 192), 0, 19, 11, 1}, + {29, UPB_SIZE(108, 192), 0, 20, 11, 1}, {30, UPB_SIZE(112, 200), 0, 10, 11, 1}, {31, UPB_SIZE(24, 24), 0, 0, 8, 1}, {32, UPB_SIZE(25, 25), 0, 0, 8, 1}, {33, UPB_SIZE(116, 208), 0, 9, 11, 1}, - {34, UPB_SIZE(156, 272), UPB_SIZE(-161, -281), 6, 11, 1}, + {34, UPB_SIZE(156, 280), UPB_SIZE(-161, -289), 6, 11, 1}, {35, UPB_SIZE(132, 240), 0, 3, 11, 3}, {36, UPB_SIZE(136, 248), 0, 8, 11, 3}, - {37, UPB_SIZE(156, 272), UPB_SIZE(-161, -281), 5, 11, 1}, - {38, UPB_SIZE(144, 256), UPB_SIZE(-153, -265), 1, 11, 1}, + {37, UPB_SIZE(156, 280), UPB_SIZE(-161, -289), 5, 11, 1}, + {38, UPB_SIZE(144, 264), UPB_SIZE(-153, -273), 1, 11, 1}, + {39, UPB_SIZE(26, 26), 0, 0, 8, 1}, + {40, UPB_SIZE(140, 256), 0, 13, 11, 3}, }; const upb_msglayout envoy_api_v2_Cluster_msginit = { &envoy_api_v2_Cluster_submsgs[0], &envoy_api_v2_Cluster__fields[0], - UPB_SIZE(168, 288), 36, false, + UPB_SIZE(168, 304), 38, false, }; static const upb_msglayout *const envoy_api_v2_Cluster_CustomClusterType_submsgs[1] = { @@ -167,29 +171,31 @@ static const upb_msglayout *const envoy_api_v2_Cluster_LbSubsetConfig_submsgs[2] &google_protobuf_Struct_msginit, }; -static const upb_msglayout_field envoy_api_v2_Cluster_LbSubsetConfig__fields[6] = { +static const upb_msglayout_field envoy_api_v2_Cluster_LbSubsetConfig__fields[7] = { {1, UPB_SIZE(0, 0), 0, 0, 14, 1}, {2, UPB_SIZE(12, 16), 0, 1, 11, 1}, {3, UPB_SIZE(16, 24), 0, 0, 11, 3}, {4, UPB_SIZE(8, 8), 0, 0, 8, 1}, {5, UPB_SIZE(9, 9), 0, 0, 8, 1}, {6, UPB_SIZE(10, 10), 0, 0, 8, 1}, + {7, UPB_SIZE(11, 11), 0, 0, 8, 1}, }; const upb_msglayout envoy_api_v2_Cluster_LbSubsetConfig_msginit = { &envoy_api_v2_Cluster_LbSubsetConfig_submsgs[0], &envoy_api_v2_Cluster_LbSubsetConfig__fields[0], - UPB_SIZE(24, 32), 6, false, + UPB_SIZE(24, 32), 7, false, }; -static const upb_msglayout_field envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector__fields[1] = { - {1, UPB_SIZE(0, 0), 0, 0, 9, 3}, +static const upb_msglayout_field envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector__fields[2] = { + {1, UPB_SIZE(8, 8), 0, 0, 9, 3}, + {2, UPB_SIZE(0, 0), 0, 0, 14, 1}, }; const upb_msglayout envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_msginit = { NULL, &envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector__fields[0], - UPB_SIZE(4, 8), 1, false, + UPB_SIZE(16, 16), 2, false, }; static const upb_msglayout *const envoy_api_v2_Cluster_LeastRequestLbConfig_submsgs[1] = { @@ -239,18 +245,19 @@ static const upb_msglayout *const envoy_api_v2_Cluster_CommonLbConfig_submsgs[4] &google_protobuf_Duration_msginit, }; -static const upb_msglayout_field envoy_api_v2_Cluster_CommonLbConfig__fields[5] = { +static const upb_msglayout_field envoy_api_v2_Cluster_CommonLbConfig__fields[6] = { {1, UPB_SIZE(4, 8), 0, 2, 11, 1}, {2, UPB_SIZE(12, 24), UPB_SIZE(-17, -33), 1, 11, 1}, {3, UPB_SIZE(12, 24), UPB_SIZE(-17, -33), 0, 11, 1}, {4, UPB_SIZE(8, 16), 0, 3, 11, 1}, {5, UPB_SIZE(0, 0), 0, 0, 8, 1}, + {6, UPB_SIZE(1, 1), 0, 0, 8, 1}, }; const upb_msglayout envoy_api_v2_Cluster_CommonLbConfig_msginit = { &envoy_api_v2_Cluster_CommonLbConfig_submsgs[0], &envoy_api_v2_Cluster_CommonLbConfig__fields[0], - UPB_SIZE(20, 40), 5, false, + UPB_SIZE(20, 40), 6, false, }; static const upb_msglayout *const envoy_api_v2_Cluster_CommonLbConfig_ZoneAwareLbConfig_submsgs[2] = { diff --git a/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h b/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h index 2fecf727bcb..5bc331902ee 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h @@ -68,6 +68,7 @@ extern const upb_msglayout envoy_api_v2_UpstreamConnectionOptions_msginit; struct envoy_api_v2_ClusterLoadAssignment; struct envoy_api_v2_auth_UpstreamTlsContext; struct envoy_api_v2_cluster_CircuitBreakers; +struct envoy_api_v2_cluster_Filter; struct envoy_api_v2_cluster_OutlierDetection; struct envoy_api_v2_core_Address; struct envoy_api_v2_core_BindConfig; @@ -88,6 +89,7 @@ struct google_protobuf_UInt64Value; extern const upb_msglayout envoy_api_v2_ClusterLoadAssignment_msginit; extern const upb_msglayout envoy_api_v2_auth_UpstreamTlsContext_msginit; extern const upb_msglayout envoy_api_v2_cluster_CircuitBreakers_msginit; +extern const upb_msglayout envoy_api_v2_cluster_Filter_msginit; extern const upb_msglayout envoy_api_v2_cluster_OutlierDetection_msginit; extern const upb_msglayout envoy_api_v2_core_Address_msginit; extern const upb_msglayout envoy_api_v2_core_BindConfig_msginit; @@ -141,6 +143,13 @@ typedef enum { envoy_api_v2_Cluster_LbSubsetConfig_DEFAULT_SUBSET = 2 } envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetFallbackPolicy; +typedef enum { + envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_NOT_DEFINED = 0, + envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_NO_FALLBACK = 1, + envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_ANY_ENDPOINT = 2, + envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_DEFAULT_SUBSET = 3 +} envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_LbSubsetSelectorFallbackPolicy; + typedef enum { envoy_api_v2_Cluster_RingHashLbConfig_XX_HASH = 0, envoy_api_v2_Cluster_RingHashLbConfig_MURMUR_HASH_2 = 1 @@ -166,7 +175,7 @@ typedef enum { envoy_api_v2_Cluster_cluster_discovery_type_cluster_type = 38, envoy_api_v2_Cluster_cluster_discovery_type_NOT_SET = 0 } envoy_api_v2_Cluster_cluster_discovery_type_oneofcases; -UPB_INLINE envoy_api_v2_Cluster_cluster_discovery_type_oneofcases envoy_api_v2_Cluster_cluster_discovery_type_case(const envoy_api_v2_Cluster* msg) { return (envoy_api_v2_Cluster_cluster_discovery_type_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(152, 264)); } +UPB_INLINE envoy_api_v2_Cluster_cluster_discovery_type_oneofcases envoy_api_v2_Cluster_cluster_discovery_type_case(const envoy_api_v2_Cluster* msg) { return (envoy_api_v2_Cluster_cluster_discovery_type_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(152, 272)); } typedef enum { envoy_api_v2_Cluster_lb_config_ring_hash_lb_config = 23, @@ -174,11 +183,11 @@ typedef enum { envoy_api_v2_Cluster_lb_config_least_request_lb_config = 37, envoy_api_v2_Cluster_lb_config_NOT_SET = 0 } envoy_api_v2_Cluster_lb_config_oneofcases; -UPB_INLINE envoy_api_v2_Cluster_lb_config_oneofcases envoy_api_v2_Cluster_lb_config_case(const envoy_api_v2_Cluster* msg) { return (envoy_api_v2_Cluster_lb_config_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(160, 280)); } +UPB_INLINE envoy_api_v2_Cluster_lb_config_oneofcases envoy_api_v2_Cluster_lb_config_case(const envoy_api_v2_Cluster* msg) { return (envoy_api_v2_Cluster_lb_config_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(160, 288)); } UPB_INLINE upb_strview envoy_api_v2_Cluster_name(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(28, 32)); } -UPB_INLINE bool envoy_api_v2_Cluster_has_type(const envoy_api_v2_Cluster *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(152, 264), 2); } -UPB_INLINE int32_t envoy_api_v2_Cluster_type(const envoy_api_v2_Cluster *msg) { return UPB_READ_ONEOF(msg, int32_t, UPB_SIZE(144, 256), UPB_SIZE(152, 264), 2, envoy_api_v2_Cluster_STATIC); } +UPB_INLINE bool envoy_api_v2_Cluster_has_type(const envoy_api_v2_Cluster *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(152, 272), 2); } +UPB_INLINE int32_t envoy_api_v2_Cluster_type(const envoy_api_v2_Cluster *msg) { return UPB_READ_ONEOF(msg, int32_t, UPB_SIZE(144, 264), UPB_SIZE(152, 272), 2, envoy_api_v2_Cluster_STATIC); } UPB_INLINE const envoy_api_v2_Cluster_EdsClusterConfig* envoy_api_v2_Cluster_eds_cluster_config(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const envoy_api_v2_Cluster_EdsClusterConfig*, UPB_SIZE(44, 64)); } UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_Cluster_connect_timeout(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(48, 72)); } UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_Cluster_per_connection_buffer_limit_bytes(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(52, 80)); } @@ -197,8 +206,8 @@ UPB_INLINE const struct envoy_api_v2_cluster_OutlierDetection* envoy_api_v2_Clus UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_Cluster_cleanup_interval(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(84, 144)); } UPB_INLINE const struct envoy_api_v2_core_BindConfig* envoy_api_v2_Cluster_upstream_bind_config(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_BindConfig*, UPB_SIZE(88, 152)); } UPB_INLINE const envoy_api_v2_Cluster_LbSubsetConfig* envoy_api_v2_Cluster_lb_subset_config(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const envoy_api_v2_Cluster_LbSubsetConfig*, UPB_SIZE(92, 160)); } -UPB_INLINE bool envoy_api_v2_Cluster_has_ring_hash_lb_config(const envoy_api_v2_Cluster *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(160, 280), 23); } -UPB_INLINE const envoy_api_v2_Cluster_RingHashLbConfig* envoy_api_v2_Cluster_ring_hash_lb_config(const envoy_api_v2_Cluster *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_Cluster_RingHashLbConfig*, UPB_SIZE(156, 272), UPB_SIZE(160, 280), 23, NULL); } +UPB_INLINE bool envoy_api_v2_Cluster_has_ring_hash_lb_config(const envoy_api_v2_Cluster *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(160, 288), 23); } +UPB_INLINE const envoy_api_v2_Cluster_RingHashLbConfig* envoy_api_v2_Cluster_ring_hash_lb_config(const envoy_api_v2_Cluster *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_Cluster_RingHashLbConfig*, UPB_SIZE(156, 280), UPB_SIZE(160, 288), 23, NULL); } UPB_INLINE const struct envoy_api_v2_core_TransportSocket* envoy_api_v2_Cluster_transport_socket(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_TransportSocket*, UPB_SIZE(96, 168)); } UPB_INLINE const struct envoy_api_v2_core_Metadata* envoy_api_v2_Cluster_metadata(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Metadata*, UPB_SIZE(100, 176)); } UPB_INLINE int32_t envoy_api_v2_Cluster_protocol_selection(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(16, 16)); } @@ -209,20 +218,22 @@ UPB_INLINE const envoy_api_v2_UpstreamConnectionOptions* envoy_api_v2_Cluster_up UPB_INLINE bool envoy_api_v2_Cluster_close_connections_on_host_health_failure(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(24, 24)); } UPB_INLINE bool envoy_api_v2_Cluster_drain_connections_on_host_removal(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(25, 25)); } UPB_INLINE const struct envoy_api_v2_ClusterLoadAssignment* envoy_api_v2_Cluster_load_assignment(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_ClusterLoadAssignment*, UPB_SIZE(116, 208)); } -UPB_INLINE bool envoy_api_v2_Cluster_has_original_dst_lb_config(const envoy_api_v2_Cluster *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(160, 280), 34); } -UPB_INLINE const envoy_api_v2_Cluster_OriginalDstLbConfig* envoy_api_v2_Cluster_original_dst_lb_config(const envoy_api_v2_Cluster *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_Cluster_OriginalDstLbConfig*, UPB_SIZE(156, 272), UPB_SIZE(160, 280), 34, NULL); } +UPB_INLINE bool envoy_api_v2_Cluster_has_original_dst_lb_config(const envoy_api_v2_Cluster *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(160, 288), 34); } +UPB_INLINE const envoy_api_v2_Cluster_OriginalDstLbConfig* envoy_api_v2_Cluster_original_dst_lb_config(const envoy_api_v2_Cluster *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_Cluster_OriginalDstLbConfig*, UPB_SIZE(156, 280), UPB_SIZE(160, 288), 34, NULL); } UPB_INLINE const envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry* const* envoy_api_v2_Cluster_extension_protocol_options(const envoy_api_v2_Cluster *msg, size_t *len) { return (const envoy_api_v2_Cluster_ExtensionProtocolOptionsEntry* const*)_upb_array_accessor(msg, UPB_SIZE(132, 240), len); } UPB_INLINE const envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry* const* envoy_api_v2_Cluster_typed_extension_protocol_options(const envoy_api_v2_Cluster *msg, size_t *len) { return (const envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry* const*)_upb_array_accessor(msg, UPB_SIZE(136, 248), len); } -UPB_INLINE bool envoy_api_v2_Cluster_has_least_request_lb_config(const envoy_api_v2_Cluster *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(160, 280), 37); } -UPB_INLINE const envoy_api_v2_Cluster_LeastRequestLbConfig* envoy_api_v2_Cluster_least_request_lb_config(const envoy_api_v2_Cluster *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_Cluster_LeastRequestLbConfig*, UPB_SIZE(156, 272), UPB_SIZE(160, 280), 37, NULL); } -UPB_INLINE bool envoy_api_v2_Cluster_has_cluster_type(const envoy_api_v2_Cluster *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(152, 264), 38); } -UPB_INLINE const envoy_api_v2_Cluster_CustomClusterType* envoy_api_v2_Cluster_cluster_type(const envoy_api_v2_Cluster *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_Cluster_CustomClusterType*, UPB_SIZE(144, 256), UPB_SIZE(152, 264), 38, NULL); } +UPB_INLINE bool envoy_api_v2_Cluster_has_least_request_lb_config(const envoy_api_v2_Cluster *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(160, 288), 37); } +UPB_INLINE const envoy_api_v2_Cluster_LeastRequestLbConfig* envoy_api_v2_Cluster_least_request_lb_config(const envoy_api_v2_Cluster *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_Cluster_LeastRequestLbConfig*, UPB_SIZE(156, 280), UPB_SIZE(160, 288), 37, NULL); } +UPB_INLINE bool envoy_api_v2_Cluster_has_cluster_type(const envoy_api_v2_Cluster *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(152, 272), 38); } +UPB_INLINE const envoy_api_v2_Cluster_CustomClusterType* envoy_api_v2_Cluster_cluster_type(const envoy_api_v2_Cluster *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_Cluster_CustomClusterType*, UPB_SIZE(144, 264), UPB_SIZE(152, 272), 38, NULL); } +UPB_INLINE bool envoy_api_v2_Cluster_respect_dns_ttl(const envoy_api_v2_Cluster *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(26, 26)); } +UPB_INLINE const struct envoy_api_v2_cluster_Filter* const* envoy_api_v2_Cluster_filters(const envoy_api_v2_Cluster *msg, size_t *len) { return (const struct envoy_api_v2_cluster_Filter* const*)_upb_array_accessor(msg, UPB_SIZE(140, 256), len); } UPB_INLINE void envoy_api_v2_Cluster_set_name(envoy_api_v2_Cluster *msg, upb_strview value) { UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(28, 32)) = value; } UPB_INLINE void envoy_api_v2_Cluster_set_type(envoy_api_v2_Cluster *msg, int32_t value) { - UPB_WRITE_ONEOF(msg, int32_t, UPB_SIZE(144, 256), value, UPB_SIZE(152, 264), 2); + UPB_WRITE_ONEOF(msg, int32_t, UPB_SIZE(144, 264), value, UPB_SIZE(152, 272), 2); } UPB_INLINE void envoy_api_v2_Cluster_set_eds_cluster_config(envoy_api_v2_Cluster *msg, envoy_api_v2_Cluster_EdsClusterConfig* value) { UPB_FIELD_AT(msg, envoy_api_v2_Cluster_EdsClusterConfig*, UPB_SIZE(44, 64)) = value; @@ -426,7 +437,7 @@ UPB_INLINE struct envoy_api_v2_Cluster_LbSubsetConfig* envoy_api_v2_Cluster_muta return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_ring_hash_lb_config(envoy_api_v2_Cluster *msg, envoy_api_v2_Cluster_RingHashLbConfig* value) { - UPB_WRITE_ONEOF(msg, envoy_api_v2_Cluster_RingHashLbConfig*, UPB_SIZE(156, 272), value, UPB_SIZE(160, 280), 23); + UPB_WRITE_ONEOF(msg, envoy_api_v2_Cluster_RingHashLbConfig*, UPB_SIZE(156, 280), value, UPB_SIZE(160, 288), 23); } UPB_INLINE struct envoy_api_v2_Cluster_RingHashLbConfig* envoy_api_v2_Cluster_mutable_ring_hash_lb_config(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_Cluster_RingHashLbConfig* sub = (struct envoy_api_v2_Cluster_RingHashLbConfig*)envoy_api_v2_Cluster_ring_hash_lb_config(msg); @@ -522,7 +533,7 @@ UPB_INLINE struct envoy_api_v2_ClusterLoadAssignment* envoy_api_v2_Cluster_mutab return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_original_dst_lb_config(envoy_api_v2_Cluster *msg, envoy_api_v2_Cluster_OriginalDstLbConfig* value) { - UPB_WRITE_ONEOF(msg, envoy_api_v2_Cluster_OriginalDstLbConfig*, UPB_SIZE(156, 272), value, UPB_SIZE(160, 280), 34); + UPB_WRITE_ONEOF(msg, envoy_api_v2_Cluster_OriginalDstLbConfig*, UPB_SIZE(156, 280), value, UPB_SIZE(160, 288), 34); } UPB_INLINE struct envoy_api_v2_Cluster_OriginalDstLbConfig* envoy_api_v2_Cluster_mutable_original_dst_lb_config(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_Cluster_OriginalDstLbConfig* sub = (struct envoy_api_v2_Cluster_OriginalDstLbConfig*)envoy_api_v2_Cluster_original_dst_lb_config(msg); @@ -560,7 +571,7 @@ UPB_INLINE struct envoy_api_v2_Cluster_TypedExtensionProtocolOptionsEntry* envoy return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_least_request_lb_config(envoy_api_v2_Cluster *msg, envoy_api_v2_Cluster_LeastRequestLbConfig* value) { - UPB_WRITE_ONEOF(msg, envoy_api_v2_Cluster_LeastRequestLbConfig*, UPB_SIZE(156, 272), value, UPB_SIZE(160, 280), 37); + UPB_WRITE_ONEOF(msg, envoy_api_v2_Cluster_LeastRequestLbConfig*, UPB_SIZE(156, 280), value, UPB_SIZE(160, 288), 37); } UPB_INLINE struct envoy_api_v2_Cluster_LeastRequestLbConfig* envoy_api_v2_Cluster_mutable_least_request_lb_config(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_Cluster_LeastRequestLbConfig* sub = (struct envoy_api_v2_Cluster_LeastRequestLbConfig*)envoy_api_v2_Cluster_least_request_lb_config(msg); @@ -572,7 +583,7 @@ UPB_INLINE struct envoy_api_v2_Cluster_LeastRequestLbConfig* envoy_api_v2_Cluste return sub; } UPB_INLINE void envoy_api_v2_Cluster_set_cluster_type(envoy_api_v2_Cluster *msg, envoy_api_v2_Cluster_CustomClusterType* value) { - UPB_WRITE_ONEOF(msg, envoy_api_v2_Cluster_CustomClusterType*, UPB_SIZE(144, 256), value, UPB_SIZE(152, 264), 38); + UPB_WRITE_ONEOF(msg, envoy_api_v2_Cluster_CustomClusterType*, UPB_SIZE(144, 264), value, UPB_SIZE(152, 272), 38); } UPB_INLINE struct envoy_api_v2_Cluster_CustomClusterType* envoy_api_v2_Cluster_mutable_cluster_type(envoy_api_v2_Cluster *msg, upb_arena *arena) { struct envoy_api_v2_Cluster_CustomClusterType* sub = (struct envoy_api_v2_Cluster_CustomClusterType*)envoy_api_v2_Cluster_cluster_type(msg); @@ -583,6 +594,22 @@ UPB_INLINE struct envoy_api_v2_Cluster_CustomClusterType* envoy_api_v2_Cluster_m } return sub; } +UPB_INLINE void envoy_api_v2_Cluster_set_respect_dns_ttl(envoy_api_v2_Cluster *msg, bool value) { + UPB_FIELD_AT(msg, bool, UPB_SIZE(26, 26)) = value; +} +UPB_INLINE struct envoy_api_v2_cluster_Filter** envoy_api_v2_Cluster_mutable_filters(envoy_api_v2_Cluster *msg, size_t *len) { + return (struct envoy_api_v2_cluster_Filter**)_upb_array_mutable_accessor(msg, UPB_SIZE(140, 256), len); +} +UPB_INLINE struct envoy_api_v2_cluster_Filter** envoy_api_v2_Cluster_resize_filters(envoy_api_v2_Cluster *msg, size_t len, upb_arena *arena) { + return (struct envoy_api_v2_cluster_Filter**)_upb_array_resize_accessor(msg, UPB_SIZE(140, 256), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct envoy_api_v2_cluster_Filter* envoy_api_v2_Cluster_add_filters(envoy_api_v2_Cluster *msg, upb_arena *arena) { + struct envoy_api_v2_cluster_Filter* sub = (struct envoy_api_v2_cluster_Filter*)upb_msg_new(&envoy_api_v2_cluster_Filter_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(140, 256), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} /* envoy.api.v2.Cluster.CustomClusterType */ @@ -736,6 +763,7 @@ UPB_INLINE const envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector* const* en UPB_INLINE bool envoy_api_v2_Cluster_LbSubsetConfig_locality_weight_aware(const envoy_api_v2_Cluster_LbSubsetConfig *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(8, 8)); } UPB_INLINE bool envoy_api_v2_Cluster_LbSubsetConfig_scale_locality_weight(const envoy_api_v2_Cluster_LbSubsetConfig *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(9, 9)); } UPB_INLINE bool envoy_api_v2_Cluster_LbSubsetConfig_panic_mode_any(const envoy_api_v2_Cluster_LbSubsetConfig *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(10, 10)); } +UPB_INLINE bool envoy_api_v2_Cluster_LbSubsetConfig_list_as_any(const envoy_api_v2_Cluster_LbSubsetConfig *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(11, 11)); } UPB_INLINE void envoy_api_v2_Cluster_LbSubsetConfig_set_fallback_policy(envoy_api_v2_Cluster_LbSubsetConfig *msg, int32_t value) { UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)) = value; @@ -774,6 +802,9 @@ UPB_INLINE void envoy_api_v2_Cluster_LbSubsetConfig_set_scale_locality_weight(en UPB_INLINE void envoy_api_v2_Cluster_LbSubsetConfig_set_panic_mode_any(envoy_api_v2_Cluster_LbSubsetConfig *msg, bool value) { UPB_FIELD_AT(msg, bool, UPB_SIZE(10, 10)) = value; } +UPB_INLINE void envoy_api_v2_Cluster_LbSubsetConfig_set_list_as_any(envoy_api_v2_Cluster_LbSubsetConfig *msg, bool value) { + UPB_FIELD_AT(msg, bool, UPB_SIZE(11, 11)) = value; +} /* envoy.api.v2.Cluster.LbSubsetConfig.LbSubsetSelector */ @@ -789,17 +820,21 @@ UPB_INLINE char *envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_serialize( return upb_encode(msg, &envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_msginit, arena, len); } -UPB_INLINE upb_strview const* envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_keys(const envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); } +UPB_INLINE upb_strview const* envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_keys(const envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(8, 8), len); } +UPB_INLINE int32_t envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_fallback_policy(const envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)); } UPB_INLINE upb_strview* envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_mutable_keys(envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector *msg, size_t *len) { - return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len); + return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(8, 8), len); } UPB_INLINE upb_strview* envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_resize_keys(envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector *msg, size_t len, upb_arena *arena) { - return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); + return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(8, 8), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); } UPB_INLINE bool envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_add_keys(envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector *msg, upb_strview val, upb_arena *arena) { return _upb_array_append_accessor( - msg, UPB_SIZE(0, 0), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); + msg, UPB_SIZE(8, 8), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); +} +UPB_INLINE void envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector_set_fallback_policy(envoy_api_v2_Cluster_LbSubsetConfig_LbSubsetSelector *msg, int32_t value) { + UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)) = value; } /* envoy.api.v2.Cluster.LeastRequestLbConfig */ @@ -925,6 +960,7 @@ UPB_INLINE bool envoy_api_v2_Cluster_CommonLbConfig_has_locality_weighted_lb_con UPB_INLINE const envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig* envoy_api_v2_Cluster_CommonLbConfig_locality_weighted_lb_config(const envoy_api_v2_Cluster_CommonLbConfig *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_Cluster_CommonLbConfig_LocalityWeightedLbConfig*, UPB_SIZE(12, 24), UPB_SIZE(16, 32), 3, NULL); } UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_Cluster_CommonLbConfig_update_merge_window(const envoy_api_v2_Cluster_CommonLbConfig *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(8, 16)); } UPB_INLINE bool envoy_api_v2_Cluster_CommonLbConfig_ignore_new_hosts_until_first_hc(const envoy_api_v2_Cluster_CommonLbConfig *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)); } +UPB_INLINE bool envoy_api_v2_Cluster_CommonLbConfig_close_connections_on_host_set_change(const envoy_api_v2_Cluster_CommonLbConfig *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); } UPB_INLINE void envoy_api_v2_Cluster_CommonLbConfig_set_healthy_panic_threshold(envoy_api_v2_Cluster_CommonLbConfig *msg, struct envoy_type_Percent* value) { UPB_FIELD_AT(msg, struct envoy_type_Percent*, UPB_SIZE(4, 8)) = value; @@ -977,6 +1013,9 @@ UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_Cluster_CommonLbConfig_ UPB_INLINE void envoy_api_v2_Cluster_CommonLbConfig_set_ignore_new_hosts_until_first_hc(envoy_api_v2_Cluster_CommonLbConfig *msg, bool value) { UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)) = value; } +UPB_INLINE void envoy_api_v2_Cluster_CommonLbConfig_set_close_connections_on_host_set_change(envoy_api_v2_Cluster_CommonLbConfig *msg, bool value) { + UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value; +} /* envoy.api.v2.Cluster.CommonLbConfig.ZoneAwareLbConfig */ diff --git a/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c b/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c new file mode 100644 index 00000000000..7cd040e39cc --- /dev/null +++ b/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c @@ -0,0 +1,34 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * envoy/api/v2/cluster/filter.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#include +#include "upb/msg.h" +#include "envoy/api/v2/cluster/filter.upb.h" +#include "google/protobuf/any.upb.h" +#include "validate/validate.upb.h" +#include "gogoproto/gogo.upb.h" + +#include "upb/port_def.inc" + +static const upb_msglayout *const envoy_api_v2_cluster_Filter_submsgs[1] = { + &google_protobuf_Any_msginit, +}; + +static const upb_msglayout_field envoy_api_v2_cluster_Filter__fields[2] = { + {1, UPB_SIZE(0, 0), 0, 0, 9, 1}, + {2, UPB_SIZE(8, 16), 0, 0, 11, 1}, +}; + +const upb_msglayout envoy_api_v2_cluster_Filter_msginit = { + &envoy_api_v2_cluster_Filter_submsgs[0], + &envoy_api_v2_cluster_Filter__fields[0], + UPB_SIZE(16, 32), 2, false, +}; + +#include "upb/port_undef.inc" + diff --git a/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h b/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h new file mode 100644 index 00000000000..bd8746cc428 --- /dev/null +++ b/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h @@ -0,0 +1,69 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * envoy/api/v2/cluster/filter.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#ifndef ENVOY_API_V2_CLUSTER_FILTER_PROTO_UPB_H_ +#define ENVOY_API_V2_CLUSTER_FILTER_PROTO_UPB_H_ + +#include "upb/generated_util.h" +#include "upb/msg.h" +#include "upb/decode.h" +#include "upb/encode.h" + +#include "upb/port_def.inc" + +#ifdef __cplusplus +extern "C" { +#endif + +struct envoy_api_v2_cluster_Filter; +typedef struct envoy_api_v2_cluster_Filter envoy_api_v2_cluster_Filter; +extern const upb_msglayout envoy_api_v2_cluster_Filter_msginit; +struct google_protobuf_Any; +extern const upb_msglayout google_protobuf_Any_msginit; + + +/* envoy.api.v2.cluster.Filter */ + +UPB_INLINE envoy_api_v2_cluster_Filter *envoy_api_v2_cluster_Filter_new(upb_arena *arena) { + return (envoy_api_v2_cluster_Filter *)upb_msg_new(&envoy_api_v2_cluster_Filter_msginit, arena); +} +UPB_INLINE envoy_api_v2_cluster_Filter *envoy_api_v2_cluster_Filter_parse(const char *buf, size_t size, + upb_arena *arena) { + envoy_api_v2_cluster_Filter *ret = envoy_api_v2_cluster_Filter_new(arena); + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_cluster_Filter_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *envoy_api_v2_cluster_Filter_serialize(const envoy_api_v2_cluster_Filter *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &envoy_api_v2_cluster_Filter_msginit, arena, len); +} + +UPB_INLINE upb_strview envoy_api_v2_cluster_Filter_name(const envoy_api_v2_cluster_Filter *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } +UPB_INLINE const struct google_protobuf_Any* envoy_api_v2_cluster_Filter_typed_config(const envoy_api_v2_cluster_Filter *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Any*, UPB_SIZE(8, 16)); } + +UPB_INLINE void envoy_api_v2_cluster_Filter_set_name(envoy_api_v2_cluster_Filter *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE void envoy_api_v2_cluster_Filter_set_typed_config(envoy_api_v2_cluster_Filter *msg, struct google_protobuf_Any* value) { + UPB_FIELD_AT(msg, struct google_protobuf_Any*, UPB_SIZE(8, 16)) = value; +} +UPB_INLINE struct google_protobuf_Any* envoy_api_v2_cluster_Filter_mutable_typed_config(envoy_api_v2_cluster_Filter *msg, upb_arena *arena) { + struct google_protobuf_Any* sub = (struct google_protobuf_Any*)envoy_api_v2_cluster_Filter_typed_config(msg); + if (sub == NULL) { + sub = (struct google_protobuf_Any*)upb_msg_new(&google_protobuf_Any_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_cluster_Filter_set_typed_config(msg, sub); + } + return sub; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#include "upb/port_undef.inc" + +#endif /* ENVOY_API_V2_CLUSTER_FILTER_PROTO_UPB_H_ */ diff --git a/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c b/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c index 7158a8b8809..cc3a226529f 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c +++ b/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c @@ -16,29 +16,33 @@ #include "upb/port_def.inc" -static const upb_msglayout *const envoy_api_v2_cluster_OutlierDetection_submsgs[11] = { +static const upb_msglayout *const envoy_api_v2_cluster_OutlierDetection_submsgs[14] = { &google_protobuf_Duration_msginit, &google_protobuf_UInt32Value_msginit, }; -static const upb_msglayout_field envoy_api_v2_cluster_OutlierDetection__fields[11] = { - {1, UPB_SIZE(0, 0), 0, 1, 11, 1}, - {2, UPB_SIZE(4, 8), 0, 0, 11, 1}, - {3, UPB_SIZE(8, 16), 0, 0, 11, 1}, - {4, UPB_SIZE(12, 24), 0, 1, 11, 1}, - {5, UPB_SIZE(16, 32), 0, 1, 11, 1}, - {6, UPB_SIZE(20, 40), 0, 1, 11, 1}, - {7, UPB_SIZE(24, 48), 0, 1, 11, 1}, - {8, UPB_SIZE(28, 56), 0, 1, 11, 1}, - {9, UPB_SIZE(32, 64), 0, 1, 11, 1}, - {10, UPB_SIZE(36, 72), 0, 1, 11, 1}, - {11, UPB_SIZE(40, 80), 0, 1, 11, 1}, +static const upb_msglayout_field envoy_api_v2_cluster_OutlierDetection__fields[15] = { + {1, UPB_SIZE(4, 8), 0, 1, 11, 1}, + {2, UPB_SIZE(8, 16), 0, 0, 11, 1}, + {3, UPB_SIZE(12, 24), 0, 0, 11, 1}, + {4, UPB_SIZE(16, 32), 0, 1, 11, 1}, + {5, UPB_SIZE(20, 40), 0, 1, 11, 1}, + {6, UPB_SIZE(24, 48), 0, 1, 11, 1}, + {7, UPB_SIZE(28, 56), 0, 1, 11, 1}, + {8, UPB_SIZE(32, 64), 0, 1, 11, 1}, + {9, UPB_SIZE(36, 72), 0, 1, 11, 1}, + {10, UPB_SIZE(40, 80), 0, 1, 11, 1}, + {11, UPB_SIZE(44, 88), 0, 1, 11, 1}, + {12, UPB_SIZE(0, 0), 0, 0, 8, 1}, + {13, UPB_SIZE(48, 96), 0, 1, 11, 1}, + {14, UPB_SIZE(52, 104), 0, 1, 11, 1}, + {15, UPB_SIZE(56, 112), 0, 1, 11, 1}, }; const upb_msglayout envoy_api_v2_cluster_OutlierDetection_msginit = { &envoy_api_v2_cluster_OutlierDetection_submsgs[0], &envoy_api_v2_cluster_OutlierDetection__fields[0], - UPB_SIZE(44, 88), 11, false, + UPB_SIZE(60, 120), 15, false, }; #include "upb/port_undef.inc" diff --git a/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h b/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h index cb290de1c0e..ef5592b53fd 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h @@ -43,20 +43,24 @@ UPB_INLINE char *envoy_api_v2_cluster_OutlierDetection_serialize(const envoy_api return upb_encode(msg, &envoy_api_v2_cluster_OutlierDetection_msginit, arena, len); } -UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_consecutive_5xx(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(0, 0)); } -UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_cluster_OutlierDetection_interval(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(4, 8)); } -UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_cluster_OutlierDetection_base_ejection_time(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(8, 16)); } -UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_max_ejection_percent(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(12, 24)); } -UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_enforcing_consecutive_5xx(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(16, 32)); } -UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_enforcing_success_rate(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(20, 40)); } -UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_success_rate_minimum_hosts(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(24, 48)); } -UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_success_rate_request_volume(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(28, 56)); } -UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_success_rate_stdev_factor(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(32, 64)); } -UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_consecutive_gateway_failure(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(36, 72)); } -UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_enforcing_consecutive_gateway_failure(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(40, 80)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_consecutive_5xx(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(4, 8)); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_cluster_OutlierDetection_interval(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(8, 16)); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_cluster_OutlierDetection_base_ejection_time(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(12, 24)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_max_ejection_percent(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(16, 32)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_enforcing_consecutive_5xx(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(20, 40)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_enforcing_success_rate(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(24, 48)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_success_rate_minimum_hosts(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(28, 56)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_success_rate_request_volume(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(32, 64)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_success_rate_stdev_factor(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(36, 72)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_consecutive_gateway_failure(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(40, 80)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_enforcing_consecutive_gateway_failure(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(44, 88)); } +UPB_INLINE bool envoy_api_v2_cluster_OutlierDetection_split_external_local_origin_errors(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_consecutive_local_origin_failure(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(48, 96)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_enforcing_consecutive_local_origin_failure(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(52, 104)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_enforcing_local_origin_success_rate(const envoy_api_v2_cluster_OutlierDetection *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(56, 112)); } UPB_INLINE void envoy_api_v2_cluster_OutlierDetection_set_consecutive_5xx(envoy_api_v2_cluster_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(0, 0)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(4, 8)) = value; } UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_mutable_consecutive_5xx(envoy_api_v2_cluster_OutlierDetection *msg, upb_arena *arena) { struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_cluster_OutlierDetection_consecutive_5xx(msg); @@ -68,7 +72,7 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetec return sub; } UPB_INLINE void envoy_api_v2_cluster_OutlierDetection_set_interval(envoy_api_v2_cluster_OutlierDetection *msg, struct google_protobuf_Duration* value) { - UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(4, 8)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(8, 16)) = value; } UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_cluster_OutlierDetection_mutable_interval(envoy_api_v2_cluster_OutlierDetection *msg, upb_arena *arena) { struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_cluster_OutlierDetection_interval(msg); @@ -80,7 +84,7 @@ UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_cluster_OutlierDetectio return sub; } UPB_INLINE void envoy_api_v2_cluster_OutlierDetection_set_base_ejection_time(envoy_api_v2_cluster_OutlierDetection *msg, struct google_protobuf_Duration* value) { - UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(8, 16)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(12, 24)) = value; } UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_cluster_OutlierDetection_mutable_base_ejection_time(envoy_api_v2_cluster_OutlierDetection *msg, upb_arena *arena) { struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_cluster_OutlierDetection_base_ejection_time(msg); @@ -92,7 +96,7 @@ UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_cluster_OutlierDetectio return sub; } UPB_INLINE void envoy_api_v2_cluster_OutlierDetection_set_max_ejection_percent(envoy_api_v2_cluster_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(12, 24)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(16, 32)) = value; } UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_mutable_max_ejection_percent(envoy_api_v2_cluster_OutlierDetection *msg, upb_arena *arena) { struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_cluster_OutlierDetection_max_ejection_percent(msg); @@ -104,7 +108,7 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetec return sub; } UPB_INLINE void envoy_api_v2_cluster_OutlierDetection_set_enforcing_consecutive_5xx(envoy_api_v2_cluster_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(16, 32)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(20, 40)) = value; } UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_mutable_enforcing_consecutive_5xx(envoy_api_v2_cluster_OutlierDetection *msg, upb_arena *arena) { struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_cluster_OutlierDetection_enforcing_consecutive_5xx(msg); @@ -116,7 +120,7 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetec return sub; } UPB_INLINE void envoy_api_v2_cluster_OutlierDetection_set_enforcing_success_rate(envoy_api_v2_cluster_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(20, 40)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(24, 48)) = value; } UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_mutable_enforcing_success_rate(envoy_api_v2_cluster_OutlierDetection *msg, upb_arena *arena) { struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_cluster_OutlierDetection_enforcing_success_rate(msg); @@ -128,7 +132,7 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetec return sub; } UPB_INLINE void envoy_api_v2_cluster_OutlierDetection_set_success_rate_minimum_hosts(envoy_api_v2_cluster_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(24, 48)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(28, 56)) = value; } UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_mutable_success_rate_minimum_hosts(envoy_api_v2_cluster_OutlierDetection *msg, upb_arena *arena) { struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_cluster_OutlierDetection_success_rate_minimum_hosts(msg); @@ -140,7 +144,7 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetec return sub; } UPB_INLINE void envoy_api_v2_cluster_OutlierDetection_set_success_rate_request_volume(envoy_api_v2_cluster_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(28, 56)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(32, 64)) = value; } UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_mutable_success_rate_request_volume(envoy_api_v2_cluster_OutlierDetection *msg, upb_arena *arena) { struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_cluster_OutlierDetection_success_rate_request_volume(msg); @@ -152,7 +156,7 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetec return sub; } UPB_INLINE void envoy_api_v2_cluster_OutlierDetection_set_success_rate_stdev_factor(envoy_api_v2_cluster_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(32, 64)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(36, 72)) = value; } UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_mutable_success_rate_stdev_factor(envoy_api_v2_cluster_OutlierDetection *msg, upb_arena *arena) { struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_cluster_OutlierDetection_success_rate_stdev_factor(msg); @@ -164,7 +168,7 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetec return sub; } UPB_INLINE void envoy_api_v2_cluster_OutlierDetection_set_consecutive_gateway_failure(envoy_api_v2_cluster_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(36, 72)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(40, 80)) = value; } UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_mutable_consecutive_gateway_failure(envoy_api_v2_cluster_OutlierDetection *msg, upb_arena *arena) { struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_cluster_OutlierDetection_consecutive_gateway_failure(msg); @@ -176,7 +180,7 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetec return sub; } UPB_INLINE void envoy_api_v2_cluster_OutlierDetection_set_enforcing_consecutive_gateway_failure(envoy_api_v2_cluster_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) { - UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(40, 80)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(44, 88)) = value; } UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_mutable_enforcing_consecutive_gateway_failure(envoy_api_v2_cluster_OutlierDetection *msg, upb_arena *arena) { struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_cluster_OutlierDetection_enforcing_consecutive_gateway_failure(msg); @@ -187,6 +191,45 @@ UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetec } return sub; } +UPB_INLINE void envoy_api_v2_cluster_OutlierDetection_set_split_external_local_origin_errors(envoy_api_v2_cluster_OutlierDetection *msg, bool value) { + UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE void envoy_api_v2_cluster_OutlierDetection_set_consecutive_local_origin_failure(envoy_api_v2_cluster_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) { + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(48, 96)) = value; +} +UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_mutable_consecutive_local_origin_failure(envoy_api_v2_cluster_OutlierDetection *msg, upb_arena *arena) { + struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_cluster_OutlierDetection_consecutive_local_origin_failure(msg); + if (sub == NULL) { + sub = (struct google_protobuf_UInt32Value*)upb_msg_new(&google_protobuf_UInt32Value_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_cluster_OutlierDetection_set_consecutive_local_origin_failure(msg, sub); + } + return sub; +} +UPB_INLINE void envoy_api_v2_cluster_OutlierDetection_set_enforcing_consecutive_local_origin_failure(envoy_api_v2_cluster_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) { + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(52, 104)) = value; +} +UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_mutable_enforcing_consecutive_local_origin_failure(envoy_api_v2_cluster_OutlierDetection *msg, upb_arena *arena) { + struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_cluster_OutlierDetection_enforcing_consecutive_local_origin_failure(msg); + if (sub == NULL) { + sub = (struct google_protobuf_UInt32Value*)upb_msg_new(&google_protobuf_UInt32Value_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_cluster_OutlierDetection_set_enforcing_consecutive_local_origin_failure(msg, sub); + } + return sub; +} +UPB_INLINE void envoy_api_v2_cluster_OutlierDetection_set_enforcing_local_origin_success_rate(envoy_api_v2_cluster_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) { + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(56, 112)) = value; +} +UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_cluster_OutlierDetection_mutable_enforcing_local_origin_success_rate(envoy_api_v2_cluster_OutlierDetection *msg, upb_arena *arena) { + struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_cluster_OutlierDetection_enforcing_local_origin_success_rate(msg); + if (sub == NULL) { + sub = (struct google_protobuf_UInt32Value*)upb_msg_new(&google_protobuf_UInt32Value_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_cluster_OutlierDetection_set_enforcing_local_origin_success_rate(msg, sub); + } + return sub; +} #ifdef __cplusplus } /* extern "C" */ diff --git a/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c b/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c index 725b17d7e31..9ecfe106a87 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +++ b/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c @@ -9,6 +9,7 @@ #include #include "upb/msg.h" #include "envoy/api/v2/core/base.upb.h" +#include "envoy/api/v2/core/http_uri.upb.h" #include "google/protobuf/any.upb.h" #include "google/protobuf/struct.upb.h" #include "google/protobuf/wrappers.upb.h" @@ -142,6 +143,37 @@ const upb_msglayout envoy_api_v2_core_DataSource_msginit = { UPB_SIZE(16, 32), 3, false, }; +static const upb_msglayout *const envoy_api_v2_core_RemoteDataSource_submsgs[1] = { + &envoy_api_v2_core_HttpUri_msginit, +}; + +static const upb_msglayout_field envoy_api_v2_core_RemoteDataSource__fields[2] = { + {1, UPB_SIZE(8, 16), 0, 0, 11, 1}, + {2, UPB_SIZE(0, 0), 0, 0, 9, 1}, +}; + +const upb_msglayout envoy_api_v2_core_RemoteDataSource_msginit = { + &envoy_api_v2_core_RemoteDataSource_submsgs[0], + &envoy_api_v2_core_RemoteDataSource__fields[0], + UPB_SIZE(16, 32), 2, false, +}; + +static const upb_msglayout *const envoy_api_v2_core_AsyncDataSource_submsgs[2] = { + &envoy_api_v2_core_DataSource_msginit, + &envoy_api_v2_core_RemoteDataSource_msginit, +}; + +static const upb_msglayout_field envoy_api_v2_core_AsyncDataSource__fields[2] = { + {1, UPB_SIZE(0, 0), UPB_SIZE(-5, -9), 0, 11, 1}, + {2, UPB_SIZE(0, 0), UPB_SIZE(-5, -9), 1, 11, 1}, +}; + +const upb_msglayout envoy_api_v2_core_AsyncDataSource_msginit = { + &envoy_api_v2_core_AsyncDataSource_submsgs[0], + &envoy_api_v2_core_AsyncDataSource__fields[0], + UPB_SIZE(8, 16), 2, false, +}; + static const upb_msglayout *const envoy_api_v2_core_TransportSocket_submsgs[2] = { &google_protobuf_Any_msginit, &google_protobuf_Struct_msginit, diff --git a/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h b/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h index 58e6e5e3f7b..d4c14b1511f 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h @@ -29,6 +29,8 @@ struct envoy_api_v2_core_HeaderValue; struct envoy_api_v2_core_HeaderValueOption; struct envoy_api_v2_core_HeaderMap; struct envoy_api_v2_core_DataSource; +struct envoy_api_v2_core_RemoteDataSource; +struct envoy_api_v2_core_AsyncDataSource; struct envoy_api_v2_core_TransportSocket; struct envoy_api_v2_core_SocketOption; struct envoy_api_v2_core_RuntimeFractionalPercent; @@ -42,6 +44,8 @@ typedef struct envoy_api_v2_core_HeaderValue envoy_api_v2_core_HeaderValue; typedef struct envoy_api_v2_core_HeaderValueOption envoy_api_v2_core_HeaderValueOption; typedef struct envoy_api_v2_core_HeaderMap envoy_api_v2_core_HeaderMap; typedef struct envoy_api_v2_core_DataSource envoy_api_v2_core_DataSource; +typedef struct envoy_api_v2_core_RemoteDataSource envoy_api_v2_core_RemoteDataSource; +typedef struct envoy_api_v2_core_AsyncDataSource envoy_api_v2_core_AsyncDataSource; typedef struct envoy_api_v2_core_TransportSocket envoy_api_v2_core_TransportSocket; typedef struct envoy_api_v2_core_SocketOption envoy_api_v2_core_SocketOption; typedef struct envoy_api_v2_core_RuntimeFractionalPercent envoy_api_v2_core_RuntimeFractionalPercent; @@ -55,14 +59,18 @@ extern const upb_msglayout envoy_api_v2_core_HeaderValue_msginit; extern const upb_msglayout envoy_api_v2_core_HeaderValueOption_msginit; extern const upb_msglayout envoy_api_v2_core_HeaderMap_msginit; extern const upb_msglayout envoy_api_v2_core_DataSource_msginit; +extern const upb_msglayout envoy_api_v2_core_RemoteDataSource_msginit; +extern const upb_msglayout envoy_api_v2_core_AsyncDataSource_msginit; extern const upb_msglayout envoy_api_v2_core_TransportSocket_msginit; extern const upb_msglayout envoy_api_v2_core_SocketOption_msginit; extern const upb_msglayout envoy_api_v2_core_RuntimeFractionalPercent_msginit; extern const upb_msglayout envoy_api_v2_core_ControlPlane_msginit; +struct envoy_api_v2_core_HttpUri; struct envoy_type_FractionalPercent; struct google_protobuf_Any; struct google_protobuf_BoolValue; struct google_protobuf_Struct; +extern const upb_msglayout envoy_api_v2_core_HttpUri_msginit; extern const upb_msglayout envoy_type_FractionalPercent_msginit; extern const upb_msglayout google_protobuf_Any_msginit; extern const upb_msglayout google_protobuf_BoolValue_msginit; @@ -92,6 +100,12 @@ typedef enum { envoy_api_v2_core_SocketOption_STATE_LISTENING = 2 } envoy_api_v2_core_SocketOption_SocketState; +typedef enum { + envoy_api_v2_core_UNSPECIFIED = 0, + envoy_api_v2_core_INBOUND = 1, + envoy_api_v2_core_OUTBOUND = 2 +} envoy_api_v2_core_TrafficDirection; + /* envoy.api.v2.core.Locality */ @@ -397,6 +411,90 @@ UPB_INLINE void envoy_api_v2_core_DataSource_set_inline_string(envoy_api_v2_core UPB_WRITE_ONEOF(msg, upb_strview, UPB_SIZE(0, 0), value, UPB_SIZE(8, 16), 3); } +/* envoy.api.v2.core.RemoteDataSource */ + +UPB_INLINE envoy_api_v2_core_RemoteDataSource *envoy_api_v2_core_RemoteDataSource_new(upb_arena *arena) { + return (envoy_api_v2_core_RemoteDataSource *)upb_msg_new(&envoy_api_v2_core_RemoteDataSource_msginit, arena); +} +UPB_INLINE envoy_api_v2_core_RemoteDataSource *envoy_api_v2_core_RemoteDataSource_parse(const char *buf, size_t size, + upb_arena *arena) { + envoy_api_v2_core_RemoteDataSource *ret = envoy_api_v2_core_RemoteDataSource_new(arena); + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_RemoteDataSource_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *envoy_api_v2_core_RemoteDataSource_serialize(const envoy_api_v2_core_RemoteDataSource *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &envoy_api_v2_core_RemoteDataSource_msginit, arena, len); +} + +UPB_INLINE const struct envoy_api_v2_core_HttpUri* envoy_api_v2_core_RemoteDataSource_http_uri(const envoy_api_v2_core_RemoteDataSource *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_HttpUri*, UPB_SIZE(8, 16)); } +UPB_INLINE upb_strview envoy_api_v2_core_RemoteDataSource_sha256(const envoy_api_v2_core_RemoteDataSource *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } + +UPB_INLINE void envoy_api_v2_core_RemoteDataSource_set_http_uri(envoy_api_v2_core_RemoteDataSource *msg, struct envoy_api_v2_core_HttpUri* value) { + UPB_FIELD_AT(msg, struct envoy_api_v2_core_HttpUri*, UPB_SIZE(8, 16)) = value; +} +UPB_INLINE struct envoy_api_v2_core_HttpUri* envoy_api_v2_core_RemoteDataSource_mutable_http_uri(envoy_api_v2_core_RemoteDataSource *msg, upb_arena *arena) { + struct envoy_api_v2_core_HttpUri* sub = (struct envoy_api_v2_core_HttpUri*)envoy_api_v2_core_RemoteDataSource_http_uri(msg); + if (sub == NULL) { + sub = (struct envoy_api_v2_core_HttpUri*)upb_msg_new(&envoy_api_v2_core_HttpUri_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_core_RemoteDataSource_set_http_uri(msg, sub); + } + return sub; +} +UPB_INLINE void envoy_api_v2_core_RemoteDataSource_set_sha256(envoy_api_v2_core_RemoteDataSource *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; +} + +/* envoy.api.v2.core.AsyncDataSource */ + +UPB_INLINE envoy_api_v2_core_AsyncDataSource *envoy_api_v2_core_AsyncDataSource_new(upb_arena *arena) { + return (envoy_api_v2_core_AsyncDataSource *)upb_msg_new(&envoy_api_v2_core_AsyncDataSource_msginit, arena); +} +UPB_INLINE envoy_api_v2_core_AsyncDataSource *envoy_api_v2_core_AsyncDataSource_parse(const char *buf, size_t size, + upb_arena *arena) { + envoy_api_v2_core_AsyncDataSource *ret = envoy_api_v2_core_AsyncDataSource_new(arena); + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_AsyncDataSource_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *envoy_api_v2_core_AsyncDataSource_serialize(const envoy_api_v2_core_AsyncDataSource *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &envoy_api_v2_core_AsyncDataSource_msginit, arena, len); +} + +typedef enum { + envoy_api_v2_core_AsyncDataSource_specifier_local = 1, + envoy_api_v2_core_AsyncDataSource_specifier_remote = 2, + envoy_api_v2_core_AsyncDataSource_specifier_NOT_SET = 0 +} envoy_api_v2_core_AsyncDataSource_specifier_oneofcases; +UPB_INLINE envoy_api_v2_core_AsyncDataSource_specifier_oneofcases envoy_api_v2_core_AsyncDataSource_specifier_case(const envoy_api_v2_core_AsyncDataSource* msg) { return (envoy_api_v2_core_AsyncDataSource_specifier_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 8)); } + +UPB_INLINE bool envoy_api_v2_core_AsyncDataSource_has_local(const envoy_api_v2_core_AsyncDataSource *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(4, 8), 1); } +UPB_INLINE const envoy_api_v2_core_DataSource* envoy_api_v2_core_AsyncDataSource_local(const envoy_api_v2_core_AsyncDataSource *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_core_DataSource*, UPB_SIZE(0, 0), UPB_SIZE(4, 8), 1, NULL); } +UPB_INLINE bool envoy_api_v2_core_AsyncDataSource_has_remote(const envoy_api_v2_core_AsyncDataSource *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(4, 8), 2); } +UPB_INLINE const envoy_api_v2_core_RemoteDataSource* envoy_api_v2_core_AsyncDataSource_remote(const envoy_api_v2_core_AsyncDataSource *msg) { return UPB_READ_ONEOF(msg, const envoy_api_v2_core_RemoteDataSource*, UPB_SIZE(0, 0), UPB_SIZE(4, 8), 2, NULL); } + +UPB_INLINE void envoy_api_v2_core_AsyncDataSource_set_local(envoy_api_v2_core_AsyncDataSource *msg, envoy_api_v2_core_DataSource* value) { + UPB_WRITE_ONEOF(msg, envoy_api_v2_core_DataSource*, UPB_SIZE(0, 0), value, UPB_SIZE(4, 8), 1); +} +UPB_INLINE struct envoy_api_v2_core_DataSource* envoy_api_v2_core_AsyncDataSource_mutable_local(envoy_api_v2_core_AsyncDataSource *msg, upb_arena *arena) { + struct envoy_api_v2_core_DataSource* sub = (struct envoy_api_v2_core_DataSource*)envoy_api_v2_core_AsyncDataSource_local(msg); + if (sub == NULL) { + sub = (struct envoy_api_v2_core_DataSource*)upb_msg_new(&envoy_api_v2_core_DataSource_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_core_AsyncDataSource_set_local(msg, sub); + } + return sub; +} +UPB_INLINE void envoy_api_v2_core_AsyncDataSource_set_remote(envoy_api_v2_core_AsyncDataSource *msg, envoy_api_v2_core_RemoteDataSource* value) { + UPB_WRITE_ONEOF(msg, envoy_api_v2_core_RemoteDataSource*, UPB_SIZE(0, 0), value, UPB_SIZE(4, 8), 2); +} +UPB_INLINE struct envoy_api_v2_core_RemoteDataSource* envoy_api_v2_core_AsyncDataSource_mutable_remote(envoy_api_v2_core_AsyncDataSource *msg, upb_arena *arena) { + struct envoy_api_v2_core_RemoteDataSource* sub = (struct envoy_api_v2_core_RemoteDataSource*)envoy_api_v2_core_AsyncDataSource_remote(msg); + if (sub == NULL) { + sub = (struct envoy_api_v2_core_RemoteDataSource*)upb_msg_new(&envoy_api_v2_core_RemoteDataSource_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_core_AsyncDataSource_set_remote(msg, sub); + } + return sub; +} + /* envoy.api.v2.core.TransportSocket */ UPB_INLINE envoy_api_v2_core_TransportSocket *envoy_api_v2_core_TransportSocket_new(upb_arena *arena) { diff --git a/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c b/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c index 5fe2a189ce0..afe940435c6 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +++ b/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c @@ -23,19 +23,20 @@ static const upb_msglayout *const envoy_api_v2_core_ApiConfigSource_submsgs[4] = &google_protobuf_Duration_msginit, }; -static const upb_msglayout_field envoy_api_v2_core_ApiConfigSource__fields[6] = { +static const upb_msglayout_field envoy_api_v2_core_ApiConfigSource__fields[7] = { {1, UPB_SIZE(0, 0), 0, 0, 14, 1}, - {2, UPB_SIZE(20, 32), 0, 0, 9, 3}, - {3, UPB_SIZE(8, 8), 0, 2, 11, 1}, - {4, UPB_SIZE(24, 40), 0, 0, 11, 3}, - {5, UPB_SIZE(12, 16), 0, 2, 11, 1}, - {6, UPB_SIZE(16, 24), 0, 1, 11, 1}, + {2, UPB_SIZE(24, 40), 0, 0, 9, 3}, + {3, UPB_SIZE(12, 16), 0, 2, 11, 1}, + {4, UPB_SIZE(28, 48), 0, 0, 11, 3}, + {5, UPB_SIZE(16, 24), 0, 2, 11, 1}, + {6, UPB_SIZE(20, 32), 0, 1, 11, 1}, + {7, UPB_SIZE(8, 8), 0, 0, 8, 1}, }; const upb_msglayout envoy_api_v2_core_ApiConfigSource_msginit = { &envoy_api_v2_core_ApiConfigSource_submsgs[0], &envoy_api_v2_core_ApiConfigSource__fields[0], - UPB_SIZE(32, 48), 6, false, + UPB_SIZE(32, 56), 7, false, }; const upb_msglayout envoy_api_v2_core_AggregatedConfigSource_msginit = { diff --git a/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h b/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h index 27f4779c17f..4c2e832e698 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h @@ -64,27 +64,28 @@ UPB_INLINE char *envoy_api_v2_core_ApiConfigSource_serialize(const envoy_api_v2_ } UPB_INLINE int32_t envoy_api_v2_core_ApiConfigSource_api_type(const envoy_api_v2_core_ApiConfigSource *msg) { return UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)); } -UPB_INLINE upb_strview const* envoy_api_v2_core_ApiConfigSource_cluster_names(const envoy_api_v2_core_ApiConfigSource *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(20, 32), len); } -UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_ApiConfigSource_refresh_delay(const envoy_api_v2_core_ApiConfigSource *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(8, 8)); } -UPB_INLINE const struct envoy_api_v2_core_GrpcService* const* envoy_api_v2_core_ApiConfigSource_grpc_services(const envoy_api_v2_core_ApiConfigSource *msg, size_t *len) { return (const struct envoy_api_v2_core_GrpcService* const*)_upb_array_accessor(msg, UPB_SIZE(24, 40), len); } -UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_ApiConfigSource_request_timeout(const envoy_api_v2_core_ApiConfigSource *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(12, 16)); } -UPB_INLINE const envoy_api_v2_core_RateLimitSettings* envoy_api_v2_core_ApiConfigSource_rate_limit_settings(const envoy_api_v2_core_ApiConfigSource *msg) { return UPB_FIELD_AT(msg, const envoy_api_v2_core_RateLimitSettings*, UPB_SIZE(16, 24)); } +UPB_INLINE upb_strview const* envoy_api_v2_core_ApiConfigSource_cluster_names(const envoy_api_v2_core_ApiConfigSource *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(24, 40), len); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_ApiConfigSource_refresh_delay(const envoy_api_v2_core_ApiConfigSource *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(12, 16)); } +UPB_INLINE const struct envoy_api_v2_core_GrpcService* const* envoy_api_v2_core_ApiConfigSource_grpc_services(const envoy_api_v2_core_ApiConfigSource *msg, size_t *len) { return (const struct envoy_api_v2_core_GrpcService* const*)_upb_array_accessor(msg, UPB_SIZE(28, 48), len); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_ApiConfigSource_request_timeout(const envoy_api_v2_core_ApiConfigSource *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(16, 24)); } +UPB_INLINE const envoy_api_v2_core_RateLimitSettings* envoy_api_v2_core_ApiConfigSource_rate_limit_settings(const envoy_api_v2_core_ApiConfigSource *msg) { return UPB_FIELD_AT(msg, const envoy_api_v2_core_RateLimitSettings*, UPB_SIZE(20, 32)); } +UPB_INLINE bool envoy_api_v2_core_ApiConfigSource_set_node_on_first_message_only(const envoy_api_v2_core_ApiConfigSource *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(8, 8)); } UPB_INLINE void envoy_api_v2_core_ApiConfigSource_set_api_type(envoy_api_v2_core_ApiConfigSource *msg, int32_t value) { UPB_FIELD_AT(msg, int32_t, UPB_SIZE(0, 0)) = value; } UPB_INLINE upb_strview* envoy_api_v2_core_ApiConfigSource_mutable_cluster_names(envoy_api_v2_core_ApiConfigSource *msg, size_t *len) { - return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 32), len); + return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 40), len); } UPB_INLINE upb_strview* envoy_api_v2_core_ApiConfigSource_resize_cluster_names(envoy_api_v2_core_ApiConfigSource *msg, size_t len, upb_arena *arena) { - return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(20, 32), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); + return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(24, 40), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); } UPB_INLINE bool envoy_api_v2_core_ApiConfigSource_add_cluster_names(envoy_api_v2_core_ApiConfigSource *msg, upb_strview val, upb_arena *arena) { return _upb_array_append_accessor( - msg, UPB_SIZE(20, 32), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); + msg, UPB_SIZE(24, 40), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); } UPB_INLINE void envoy_api_v2_core_ApiConfigSource_set_refresh_delay(envoy_api_v2_core_ApiConfigSource *msg, struct google_protobuf_Duration* value) { - UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(8, 8)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(12, 16)) = value; } UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_ApiConfigSource_mutable_refresh_delay(envoy_api_v2_core_ApiConfigSource *msg, upb_arena *arena) { struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_core_ApiConfigSource_refresh_delay(msg); @@ -96,20 +97,20 @@ UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_ApiConfigSource_mu return sub; } UPB_INLINE struct envoy_api_v2_core_GrpcService** envoy_api_v2_core_ApiConfigSource_mutable_grpc_services(envoy_api_v2_core_ApiConfigSource *msg, size_t *len) { - return (struct envoy_api_v2_core_GrpcService**)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 40), len); + return (struct envoy_api_v2_core_GrpcService**)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 48), len); } UPB_INLINE struct envoy_api_v2_core_GrpcService** envoy_api_v2_core_ApiConfigSource_resize_grpc_services(envoy_api_v2_core_ApiConfigSource *msg, size_t len, upb_arena *arena) { - return (struct envoy_api_v2_core_GrpcService**)_upb_array_resize_accessor(msg, UPB_SIZE(24, 40), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); + return (struct envoy_api_v2_core_GrpcService**)_upb_array_resize_accessor(msg, UPB_SIZE(28, 48), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); } UPB_INLINE struct envoy_api_v2_core_GrpcService* envoy_api_v2_core_ApiConfigSource_add_grpc_services(envoy_api_v2_core_ApiConfigSource *msg, upb_arena *arena) { struct envoy_api_v2_core_GrpcService* sub = (struct envoy_api_v2_core_GrpcService*)upb_msg_new(&envoy_api_v2_core_GrpcService_msginit, arena); bool ok = _upb_array_append_accessor( - msg, UPB_SIZE(24, 40), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + msg, UPB_SIZE(28, 48), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); if (!ok) return NULL; return sub; } UPB_INLINE void envoy_api_v2_core_ApiConfigSource_set_request_timeout(envoy_api_v2_core_ApiConfigSource *msg, struct google_protobuf_Duration* value) { - UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(12, 16)) = value; + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(16, 24)) = value; } UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_ApiConfigSource_mutable_request_timeout(envoy_api_v2_core_ApiConfigSource *msg, upb_arena *arena) { struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_core_ApiConfigSource_request_timeout(msg); @@ -121,7 +122,7 @@ UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_ApiConfigSource_mu return sub; } UPB_INLINE void envoy_api_v2_core_ApiConfigSource_set_rate_limit_settings(envoy_api_v2_core_ApiConfigSource *msg, envoy_api_v2_core_RateLimitSettings* value) { - UPB_FIELD_AT(msg, envoy_api_v2_core_RateLimitSettings*, UPB_SIZE(16, 24)) = value; + UPB_FIELD_AT(msg, envoy_api_v2_core_RateLimitSettings*, UPB_SIZE(20, 32)) = value; } UPB_INLINE struct envoy_api_v2_core_RateLimitSettings* envoy_api_v2_core_ApiConfigSource_mutable_rate_limit_settings(envoy_api_v2_core_ApiConfigSource *msg, upb_arena *arena) { struct envoy_api_v2_core_RateLimitSettings* sub = (struct envoy_api_v2_core_RateLimitSettings*)envoy_api_v2_core_ApiConfigSource_rate_limit_settings(msg); @@ -132,6 +133,9 @@ UPB_INLINE struct envoy_api_v2_core_RateLimitSettings* envoy_api_v2_core_ApiConf } return sub; } +UPB_INLINE void envoy_api_v2_core_ApiConfigSource_set_set_node_on_first_message_only(envoy_api_v2_core_ApiConfigSource *msg, bool value) { + UPB_FIELD_AT(msg, bool, UPB_SIZE(8, 8)) = value; +} /* envoy.api.v2.core.AggregatedConfigSource */ diff --git a/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c b/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c new file mode 100644 index 00000000000..f7999c7cd0d --- /dev/null +++ b/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c @@ -0,0 +1,35 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * envoy/api/v2/core/http_uri.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#include +#include "upb/msg.h" +#include "envoy/api/v2/core/http_uri.upb.h" +#include "google/protobuf/duration.upb.h" +#include "gogoproto/gogo.upb.h" +#include "validate/validate.upb.h" + +#include "upb/port_def.inc" + +static const upb_msglayout *const envoy_api_v2_core_HttpUri_submsgs[1] = { + &google_protobuf_Duration_msginit, +}; + +static const upb_msglayout_field envoy_api_v2_core_HttpUri__fields[3] = { + {1, UPB_SIZE(0, 0), 0, 0, 9, 1}, + {2, UPB_SIZE(12, 24), UPB_SIZE(-21, -41), 0, 9, 1}, + {3, UPB_SIZE(8, 16), 0, 0, 11, 1}, +}; + +const upb_msglayout envoy_api_v2_core_HttpUri_msginit = { + &envoy_api_v2_core_HttpUri_submsgs[0], + &envoy_api_v2_core_HttpUri__fields[0], + UPB_SIZE(24, 48), 3, false, +}; + +#include "upb/port_undef.inc" + diff --git a/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h b/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h new file mode 100644 index 00000000000..f0dc22b7a20 --- /dev/null +++ b/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h @@ -0,0 +1,80 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * envoy/api/v2/core/http_uri.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#ifndef ENVOY_API_V2_CORE_HTTP_URI_PROTO_UPB_H_ +#define ENVOY_API_V2_CORE_HTTP_URI_PROTO_UPB_H_ + +#include "upb/generated_util.h" +#include "upb/msg.h" +#include "upb/decode.h" +#include "upb/encode.h" + +#include "upb/port_def.inc" + +#ifdef __cplusplus +extern "C" { +#endif + +struct envoy_api_v2_core_HttpUri; +typedef struct envoy_api_v2_core_HttpUri envoy_api_v2_core_HttpUri; +extern const upb_msglayout envoy_api_v2_core_HttpUri_msginit; +struct google_protobuf_Duration; +extern const upb_msglayout google_protobuf_Duration_msginit; + + +/* envoy.api.v2.core.HttpUri */ + +UPB_INLINE envoy_api_v2_core_HttpUri *envoy_api_v2_core_HttpUri_new(upb_arena *arena) { + return (envoy_api_v2_core_HttpUri *)upb_msg_new(&envoy_api_v2_core_HttpUri_msginit, arena); +} +UPB_INLINE envoy_api_v2_core_HttpUri *envoy_api_v2_core_HttpUri_parse(const char *buf, size_t size, + upb_arena *arena) { + envoy_api_v2_core_HttpUri *ret = envoy_api_v2_core_HttpUri_new(arena); + return (ret && upb_decode(buf, size, ret, &envoy_api_v2_core_HttpUri_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *envoy_api_v2_core_HttpUri_serialize(const envoy_api_v2_core_HttpUri *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &envoy_api_v2_core_HttpUri_msginit, arena, len); +} + +typedef enum { + envoy_api_v2_core_HttpUri_http_upstream_type_cluster = 2, + envoy_api_v2_core_HttpUri_http_upstream_type_NOT_SET = 0 +} envoy_api_v2_core_HttpUri_http_upstream_type_oneofcases; +UPB_INLINE envoy_api_v2_core_HttpUri_http_upstream_type_oneofcases envoy_api_v2_core_HttpUri_http_upstream_type_case(const envoy_api_v2_core_HttpUri* msg) { return (envoy_api_v2_core_HttpUri_http_upstream_type_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(20, 40)); } + +UPB_INLINE upb_strview envoy_api_v2_core_HttpUri_uri(const envoy_api_v2_core_HttpUri *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)); } +UPB_INLINE bool envoy_api_v2_core_HttpUri_has_cluster(const envoy_api_v2_core_HttpUri *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(20, 40), 2); } +UPB_INLINE upb_strview envoy_api_v2_core_HttpUri_cluster(const envoy_api_v2_core_HttpUri *msg) { return UPB_READ_ONEOF(msg, upb_strview, UPB_SIZE(12, 24), UPB_SIZE(20, 40), 2, upb_strview_make("", strlen(""))); } +UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_core_HttpUri_timeout(const envoy_api_v2_core_HttpUri *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(8, 16)); } + +UPB_INLINE void envoy_api_v2_core_HttpUri_set_uri(envoy_api_v2_core_HttpUri *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE void envoy_api_v2_core_HttpUri_set_cluster(envoy_api_v2_core_HttpUri *msg, upb_strview value) { + UPB_WRITE_ONEOF(msg, upb_strview, UPB_SIZE(12, 24), value, UPB_SIZE(20, 40), 2); +} +UPB_INLINE void envoy_api_v2_core_HttpUri_set_timeout(envoy_api_v2_core_HttpUri *msg, struct google_protobuf_Duration* value) { + UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(8, 16)) = value; +} +UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_core_HttpUri_mutable_timeout(envoy_api_v2_core_HttpUri *msg, upb_arena *arena) { + struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_core_HttpUri_timeout(msg); + if (sub == NULL) { + sub = (struct google_protobuf_Duration*)upb_msg_new(&google_protobuf_Duration_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_core_HttpUri_set_timeout(msg, sub); + } + return sub; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#include "upb/port_undef.inc" + +#endif /* ENVOY_API_V2_CORE_HTTP_URI_PROTO_UPB_H_ */ diff --git a/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c b/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c index 896cfe25638..48878df6a69 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +++ b/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c @@ -52,23 +52,29 @@ const upb_msglayout envoy_api_v2_core_Http1ProtocolOptions_msginit = { UPB_SIZE(16, 32), 3, false, }; -static const upb_msglayout *const envoy_api_v2_core_Http2ProtocolOptions_submsgs[4] = { +static const upb_msglayout *const envoy_api_v2_core_Http2ProtocolOptions_submsgs[9] = { &google_protobuf_UInt32Value_msginit, }; -static const upb_msglayout_field envoy_api_v2_core_Http2ProtocolOptions__fields[6] = { +static const upb_msglayout_field envoy_api_v2_core_Http2ProtocolOptions__fields[12] = { {1, UPB_SIZE(4, 8), 0, 0, 11, 1}, {2, UPB_SIZE(8, 16), 0, 0, 11, 1}, {3, UPB_SIZE(12, 24), 0, 0, 11, 1}, {4, UPB_SIZE(16, 32), 0, 0, 11, 1}, {5, UPB_SIZE(0, 0), 0, 0, 8, 1}, {6, UPB_SIZE(1, 1), 0, 0, 8, 1}, + {7, UPB_SIZE(20, 40), 0, 0, 11, 1}, + {8, UPB_SIZE(24, 48), 0, 0, 11, 1}, + {9, UPB_SIZE(28, 56), 0, 0, 11, 1}, + {10, UPB_SIZE(32, 64), 0, 0, 11, 1}, + {11, UPB_SIZE(36, 72), 0, 0, 11, 1}, + {12, UPB_SIZE(2, 2), 0, 0, 8, 1}, }; const upb_msglayout envoy_api_v2_core_Http2ProtocolOptions_msginit = { &envoy_api_v2_core_Http2ProtocolOptions_submsgs[0], &envoy_api_v2_core_Http2ProtocolOptions__fields[0], - UPB_SIZE(20, 40), 6, false, + UPB_SIZE(40, 80), 12, false, }; static const upb_msglayout *const envoy_api_v2_core_GrpcProtocolOptions_submsgs[1] = { diff --git a/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h b/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h index 039b221ef2a..a82cfc16f2f 100644 --- a/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +++ b/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h @@ -145,6 +145,12 @@ UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_core_Http2Prot UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_core_Http2ProtocolOptions_initial_connection_window_size(const envoy_api_v2_core_Http2ProtocolOptions *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(16, 32)); } UPB_INLINE bool envoy_api_v2_core_Http2ProtocolOptions_allow_connect(const envoy_api_v2_core_Http2ProtocolOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)); } UPB_INLINE bool envoy_api_v2_core_Http2ProtocolOptions_allow_metadata(const envoy_api_v2_core_Http2ProtocolOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_core_Http2ProtocolOptions_max_outbound_frames(const envoy_api_v2_core_Http2ProtocolOptions *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(20, 40)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_core_Http2ProtocolOptions_max_outbound_control_frames(const envoy_api_v2_core_Http2ProtocolOptions *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(24, 48)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_core_Http2ProtocolOptions_max_consecutive_inbound_frames_with_empty_payload(const envoy_api_v2_core_Http2ProtocolOptions *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(28, 56)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_core_Http2ProtocolOptions_max_inbound_priority_frames_per_stream(const envoy_api_v2_core_Http2ProtocolOptions *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(32, 64)); } +UPB_INLINE const struct google_protobuf_UInt32Value* envoy_api_v2_core_Http2ProtocolOptions_max_inbound_window_update_frames_per_data_frame_sent(const envoy_api_v2_core_Http2ProtocolOptions *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_UInt32Value*, UPB_SIZE(36, 72)); } +UPB_INLINE bool envoy_api_v2_core_Http2ProtocolOptions_stream_error_on_invalid_http_messaging(const envoy_api_v2_core_Http2ProtocolOptions *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)); } UPB_INLINE void envoy_api_v2_core_Http2ProtocolOptions_set_hpack_table_size(envoy_api_v2_core_Http2ProtocolOptions *msg, struct google_protobuf_UInt32Value* value) { UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(4, 8)) = value; @@ -200,6 +206,69 @@ UPB_INLINE void envoy_api_v2_core_Http2ProtocolOptions_set_allow_connect(envoy_a UPB_INLINE void envoy_api_v2_core_Http2ProtocolOptions_set_allow_metadata(envoy_api_v2_core_Http2ProtocolOptions *msg, bool value) { UPB_FIELD_AT(msg, bool, UPB_SIZE(1, 1)) = value; } +UPB_INLINE void envoy_api_v2_core_Http2ProtocolOptions_set_max_outbound_frames(envoy_api_v2_core_Http2ProtocolOptions *msg, struct google_protobuf_UInt32Value* value) { + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(20, 40)) = value; +} +UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_core_Http2ProtocolOptions_mutable_max_outbound_frames(envoy_api_v2_core_Http2ProtocolOptions *msg, upb_arena *arena) { + struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_core_Http2ProtocolOptions_max_outbound_frames(msg); + if (sub == NULL) { + sub = (struct google_protobuf_UInt32Value*)upb_msg_new(&google_protobuf_UInt32Value_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_core_Http2ProtocolOptions_set_max_outbound_frames(msg, sub); + } + return sub; +} +UPB_INLINE void envoy_api_v2_core_Http2ProtocolOptions_set_max_outbound_control_frames(envoy_api_v2_core_Http2ProtocolOptions *msg, struct google_protobuf_UInt32Value* value) { + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(24, 48)) = value; +} +UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_core_Http2ProtocolOptions_mutable_max_outbound_control_frames(envoy_api_v2_core_Http2ProtocolOptions *msg, upb_arena *arena) { + struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_core_Http2ProtocolOptions_max_outbound_control_frames(msg); + if (sub == NULL) { + sub = (struct google_protobuf_UInt32Value*)upb_msg_new(&google_protobuf_UInt32Value_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_core_Http2ProtocolOptions_set_max_outbound_control_frames(msg, sub); + } + return sub; +} +UPB_INLINE void envoy_api_v2_core_Http2ProtocolOptions_set_max_consecutive_inbound_frames_with_empty_payload(envoy_api_v2_core_Http2ProtocolOptions *msg, struct google_protobuf_UInt32Value* value) { + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(28, 56)) = value; +} +UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_core_Http2ProtocolOptions_mutable_max_consecutive_inbound_frames_with_empty_payload(envoy_api_v2_core_Http2ProtocolOptions *msg, upb_arena *arena) { + struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_core_Http2ProtocolOptions_max_consecutive_inbound_frames_with_empty_payload(msg); + if (sub == NULL) { + sub = (struct google_protobuf_UInt32Value*)upb_msg_new(&google_protobuf_UInt32Value_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_core_Http2ProtocolOptions_set_max_consecutive_inbound_frames_with_empty_payload(msg, sub); + } + return sub; +} +UPB_INLINE void envoy_api_v2_core_Http2ProtocolOptions_set_max_inbound_priority_frames_per_stream(envoy_api_v2_core_Http2ProtocolOptions *msg, struct google_protobuf_UInt32Value* value) { + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(32, 64)) = value; +} +UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_core_Http2ProtocolOptions_mutable_max_inbound_priority_frames_per_stream(envoy_api_v2_core_Http2ProtocolOptions *msg, upb_arena *arena) { + struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_core_Http2ProtocolOptions_max_inbound_priority_frames_per_stream(msg); + if (sub == NULL) { + sub = (struct google_protobuf_UInt32Value*)upb_msg_new(&google_protobuf_UInt32Value_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_core_Http2ProtocolOptions_set_max_inbound_priority_frames_per_stream(msg, sub); + } + return sub; +} +UPB_INLINE void envoy_api_v2_core_Http2ProtocolOptions_set_max_inbound_window_update_frames_per_data_frame_sent(envoy_api_v2_core_Http2ProtocolOptions *msg, struct google_protobuf_UInt32Value* value) { + UPB_FIELD_AT(msg, struct google_protobuf_UInt32Value*, UPB_SIZE(36, 72)) = value; +} +UPB_INLINE struct google_protobuf_UInt32Value* envoy_api_v2_core_Http2ProtocolOptions_mutable_max_inbound_window_update_frames_per_data_frame_sent(envoy_api_v2_core_Http2ProtocolOptions *msg, upb_arena *arena) { + struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_api_v2_core_Http2ProtocolOptions_max_inbound_window_update_frames_per_data_frame_sent(msg); + if (sub == NULL) { + sub = (struct google_protobuf_UInt32Value*)upb_msg_new(&google_protobuf_UInt32Value_msginit, arena); + if (!sub) return NULL; + envoy_api_v2_core_Http2ProtocolOptions_set_max_inbound_window_update_frames_per_data_frame_sent(msg, sub); + } + return sub; +} +UPB_INLINE void envoy_api_v2_core_Http2ProtocolOptions_set_stream_error_on_invalid_http_messaging(envoy_api_v2_core_Http2ProtocolOptions *msg, bool value) { + UPB_FIELD_AT(msg, bool, UPB_SIZE(2, 2)) = value; +} /* envoy.api.v2.core.GrpcProtocolOptions */ diff --git a/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c b/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c new file mode 100644 index 00000000000..05a1c8098a6 --- /dev/null +++ b/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c @@ -0,0 +1,58 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * udpa/data/orca/v1/orca_load_report.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#include +#include "upb/msg.h" +#include "udpa/data/orca/v1/orca_load_report.upb.h" +#include "validate/validate.upb.h" + +#include "upb/port_def.inc" + +static const upb_msglayout *const udpa_data_orca_v1_OrcaLoadReport_submsgs[2] = { + &udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry_msginit, + &udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry_msginit, +}; + +static const upb_msglayout_field udpa_data_orca_v1_OrcaLoadReport__fields[5] = { + {1, UPB_SIZE(0, 0), 0, 0, 1, 1}, + {2, UPB_SIZE(8, 8), 0, 0, 1, 1}, + {3, UPB_SIZE(16, 16), 0, 0, 4, 1}, + {4, UPB_SIZE(24, 24), 0, 0, 11, 3}, + {5, UPB_SIZE(28, 32), 0, 1, 11, 3}, +}; + +const upb_msglayout udpa_data_orca_v1_OrcaLoadReport_msginit = { + &udpa_data_orca_v1_OrcaLoadReport_submsgs[0], + &udpa_data_orca_v1_OrcaLoadReport__fields[0], + UPB_SIZE(32, 40), 5, false, +}; + +static const upb_msglayout_field udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry__fields[2] = { + {1, UPB_SIZE(8, 8), 0, 0, 9, 1}, + {2, UPB_SIZE(0, 0), 0, 0, 1, 1}, +}; + +const upb_msglayout udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry_msginit = { + NULL, + &udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry__fields[0], + UPB_SIZE(16, 32), 2, false, +}; + +static const upb_msglayout_field udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry__fields[2] = { + {1, UPB_SIZE(8, 8), 0, 0, 9, 1}, + {2, UPB_SIZE(0, 0), 0, 0, 1, 1}, +}; + +const upb_msglayout udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry_msginit = { + NULL, + &udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry__fields[0], + UPB_SIZE(16, 32), 2, false, +}; + +#include "upb/port_undef.inc" + diff --git a/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h b/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h new file mode 100644 index 00000000000..279578b5ae4 --- /dev/null +++ b/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h @@ -0,0 +1,144 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * udpa/data/orca/v1/orca_load_report.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#ifndef UDPA_DATA_ORCA_V1_ORCA_LOAD_REPORT_PROTO_UPB_H_ +#define UDPA_DATA_ORCA_V1_ORCA_LOAD_REPORT_PROTO_UPB_H_ + +#include "upb/generated_util.h" +#include "upb/msg.h" +#include "upb/decode.h" +#include "upb/encode.h" + +#include "upb/port_def.inc" + +#ifdef __cplusplus +extern "C" { +#endif + +struct udpa_data_orca_v1_OrcaLoadReport; +struct udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry; +struct udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry; +typedef struct udpa_data_orca_v1_OrcaLoadReport udpa_data_orca_v1_OrcaLoadReport; +typedef struct udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry; +typedef struct udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry; +extern const upb_msglayout udpa_data_orca_v1_OrcaLoadReport_msginit; +extern const upb_msglayout udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry_msginit; +extern const upb_msglayout udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry_msginit; + + +/* udpa.data.orca.v1.OrcaLoadReport */ + +UPB_INLINE udpa_data_orca_v1_OrcaLoadReport *udpa_data_orca_v1_OrcaLoadReport_new(upb_arena *arena) { + return (udpa_data_orca_v1_OrcaLoadReport *)upb_msg_new(&udpa_data_orca_v1_OrcaLoadReport_msginit, arena); +} +UPB_INLINE udpa_data_orca_v1_OrcaLoadReport *udpa_data_orca_v1_OrcaLoadReport_parse(const char *buf, size_t size, + upb_arena *arena) { + udpa_data_orca_v1_OrcaLoadReport *ret = udpa_data_orca_v1_OrcaLoadReport_new(arena); + return (ret && upb_decode(buf, size, ret, &udpa_data_orca_v1_OrcaLoadReport_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *udpa_data_orca_v1_OrcaLoadReport_serialize(const udpa_data_orca_v1_OrcaLoadReport *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &udpa_data_orca_v1_OrcaLoadReport_msginit, arena, len); +} + +UPB_INLINE double udpa_data_orca_v1_OrcaLoadReport_cpu_utilization(const udpa_data_orca_v1_OrcaLoadReport *msg) { return UPB_FIELD_AT(msg, double, UPB_SIZE(0, 0)); } +UPB_INLINE double udpa_data_orca_v1_OrcaLoadReport_mem_utilization(const udpa_data_orca_v1_OrcaLoadReport *msg) { return UPB_FIELD_AT(msg, double, UPB_SIZE(8, 8)); } +UPB_INLINE uint64_t udpa_data_orca_v1_OrcaLoadReport_rps(const udpa_data_orca_v1_OrcaLoadReport *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(16, 16)); } +UPB_INLINE const udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry* const* udpa_data_orca_v1_OrcaLoadReport_request_cost(const udpa_data_orca_v1_OrcaLoadReport *msg, size_t *len) { return (const udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry* const*)_upb_array_accessor(msg, UPB_SIZE(24, 24), len); } +UPB_INLINE const udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry* const* udpa_data_orca_v1_OrcaLoadReport_utilization(const udpa_data_orca_v1_OrcaLoadReport *msg, size_t *len) { return (const udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry* const*)_upb_array_accessor(msg, UPB_SIZE(28, 32), len); } + +UPB_INLINE void udpa_data_orca_v1_OrcaLoadReport_set_cpu_utilization(udpa_data_orca_v1_OrcaLoadReport *msg, double value) { + UPB_FIELD_AT(msg, double, UPB_SIZE(0, 0)) = value; +} +UPB_INLINE void udpa_data_orca_v1_OrcaLoadReport_set_mem_utilization(udpa_data_orca_v1_OrcaLoadReport *msg, double value) { + UPB_FIELD_AT(msg, double, UPB_SIZE(8, 8)) = value; +} +UPB_INLINE void udpa_data_orca_v1_OrcaLoadReport_set_rps(udpa_data_orca_v1_OrcaLoadReport *msg, uint64_t value) { + UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(16, 16)) = value; +} +UPB_INLINE udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry** udpa_data_orca_v1_OrcaLoadReport_mutable_request_cost(udpa_data_orca_v1_OrcaLoadReport *msg, size_t *len) { + return (udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry**)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 24), len); +} +UPB_INLINE udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry** udpa_data_orca_v1_OrcaLoadReport_resize_request_cost(udpa_data_orca_v1_OrcaLoadReport *msg, size_t len, upb_arena *arena) { + return (udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry**)_upb_array_resize_accessor(msg, UPB_SIZE(24, 24), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry* udpa_data_orca_v1_OrcaLoadReport_add_request_cost(udpa_data_orca_v1_OrcaLoadReport *msg, upb_arena *arena) { + struct udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry* sub = (struct udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry*)upb_msg_new(&udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(24, 24), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} +UPB_INLINE udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry** udpa_data_orca_v1_OrcaLoadReport_mutable_utilization(udpa_data_orca_v1_OrcaLoadReport *msg, size_t *len) { + return (udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry**)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 32), len); +} +UPB_INLINE udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry** udpa_data_orca_v1_OrcaLoadReport_resize_utilization(udpa_data_orca_v1_OrcaLoadReport *msg, size_t len, upb_arena *arena) { + return (udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry**)_upb_array_resize_accessor(msg, UPB_SIZE(28, 32), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); +} +UPB_INLINE struct udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry* udpa_data_orca_v1_OrcaLoadReport_add_utilization(udpa_data_orca_v1_OrcaLoadReport *msg, upb_arena *arena) { + struct udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry* sub = (struct udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry*)upb_msg_new(&udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry_msginit, arena); + bool ok = _upb_array_append_accessor( + msg, UPB_SIZE(28, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); + if (!ok) return NULL; + return sub; +} + +/* udpa.data.orca.v1.OrcaLoadReport.RequestCostEntry */ + +UPB_INLINE udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry *udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry_new(upb_arena *arena) { + return (udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry *)upb_msg_new(&udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry_msginit, arena); +} +UPB_INLINE udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry *udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry_parse(const char *buf, size_t size, + upb_arena *arena) { + udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry *ret = udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry_new(arena); + return (ret && upb_decode(buf, size, ret, &udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry_serialize(const udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry_msginit, arena, len); +} + +UPB_INLINE upb_strview udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry_key(const udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)); } +UPB_INLINE double udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry_value(const udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry *msg) { return UPB_FIELD_AT(msg, double, UPB_SIZE(0, 0)); } + +UPB_INLINE void udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry_set_key(udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)) = value; +} +UPB_INLINE void udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry_set_value(udpa_data_orca_v1_OrcaLoadReport_RequestCostEntry *msg, double value) { + UPB_FIELD_AT(msg, double, UPB_SIZE(0, 0)) = value; +} + +/* udpa.data.orca.v1.OrcaLoadReport.UtilizationEntry */ + +UPB_INLINE udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry *udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry_new(upb_arena *arena) { + return (udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry *)upb_msg_new(&udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry_msginit, arena); +} +UPB_INLINE udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry *udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry_parse(const char *buf, size_t size, + upb_arena *arena) { + udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry *ret = udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry_new(arena); + return (ret && upb_decode(buf, size, ret, &udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry_msginit, arena)) ? ret : NULL; +} +UPB_INLINE char *udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry_serialize(const udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry *msg, upb_arena *arena, size_t *len) { + return upb_encode(msg, &udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry_msginit, arena, len); +} + +UPB_INLINE upb_strview udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry_key(const udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)); } +UPB_INLINE double udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry_value(const udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry *msg) { return UPB_FIELD_AT(msg, double, UPB_SIZE(0, 0)); } + +UPB_INLINE void udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry_set_key(udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry *msg, upb_strview value) { + UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)) = value; +} +UPB_INLINE void udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry_set_value(udpa_data_orca_v1_OrcaLoadReport_UtilizationEntry *msg, double value) { + UPB_FIELD_AT(msg, double, UPB_SIZE(0, 0)) = value; +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#include "upb/port_undef.inc" + +#endif /* UDPA_DATA_ORCA_V1_ORCA_LOAD_REPORT_PROTO_UPB_H_ */ diff --git a/src/core/lib/gprpp/map.h b/src/core/lib/gprpp/map.h index 134625775cf..6a41a97bec2 100644 --- a/src/core/lib/gprpp/map.h +++ b/src/core/lib/gprpp/map.h @@ -35,6 +35,7 @@ #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/pair.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" +#include "src/core/lib/gprpp/string_view.h" namespace grpc_core { @@ -42,8 +43,14 @@ struct StringLess { bool operator()(const char* a, const char* b) const { return strcmp(a, b) < 0; } - bool operator()(const UniquePtr& k1, const UniquePtr& k2) const { - return strcmp(k1.get(), k2.get()) < 0; + bool operator()(const UniquePtr& a, const UniquePtr& b) const { + return strcmp(a.get(), b.get()) < 0; + } + bool operator()(const StringView& a, const StringView& b) const { + const size_t min_size = std::min(a.size(), b.size()); + int c = strncmp(a.data(), b.data(), min_size); + if (c != 0) return c < 0; + return a.size() < b.size(); } }; diff --git a/src/core/lib/transport/static_metadata.cc b/src/core/lib/transport/static_metadata.cc index e43c17f1ca5..bd6ff09c80d 100644 --- a/src/core/lib/transport/static_metadata.cc +++ b/src/core/lib/transport/static_metadata.cc @@ -53,76 +53,77 @@ static constexpr uint8_t g_bytes[] = { 99, 45, 112, 114, 101, 118, 105, 111, 117, 115, 45, 114, 112, 99, 45, 97, 116, 116, 101, 109, 112, 116, 115, 103, 114, 112, 99, 45, 114, 101, 116, 114, 121, 45, 112, 117, 115, 104, 98, 97, 99, 107, 45, 109, 115, - 103, 114, 112, 99, 45, 116, 105, 109, 101, 111, 117, 116, 49, 50, 51, - 52, 103, 114, 112, 99, 46, 119, 97, 105, 116, 95, 102, 111, 114, 95, - 114, 101, 97, 100, 121, 103, 114, 112, 99, 46, 116, 105, 109, 101, 111, - 117, 116, 103, 114, 112, 99, 46, 109, 97, 120, 95, 114, 101, 113, 117, - 101, 115, 116, 95, 109, 101, 115, 115, 97, 103, 101, 95, 98, 121, 116, - 101, 115, 103, 114, 112, 99, 46, 109, 97, 120, 95, 114, 101, 115, 112, - 111, 110, 115, 101, 95, 109, 101, 115, 115, 97, 103, 101, 95, 98, 121, - 116, 101, 115, 47, 103, 114, 112, 99, 46, 108, 98, 46, 118, 49, 46, - 76, 111, 97, 100, 66, 97, 108, 97, 110, 99, 101, 114, 47, 66, 97, - 108, 97, 110, 99, 101, 76, 111, 97, 100, 47, 101, 110, 118, 111, 121, - 46, 115, 101, 114, 118, 105, 99, 101, 46, 108, 111, 97, 100, 95, 115, - 116, 97, 116, 115, 46, 118, 50, 46, 76, 111, 97, 100, 82, 101, 112, - 111, 114, 116, 105, 110, 103, 83, 101, 114, 118, 105, 99, 101, 47, 83, - 116, 114, 101, 97, 109, 76, 111, 97, 100, 83, 116, 97, 116, 115, 47, - 101, 110, 118, 111, 121, 46, 97, 112, 105, 46, 118, 50, 46, 69, 110, - 100, 112, 111, 105, 110, 116, 68, 105, 115, 99, 111, 118, 101, 114, 121, - 83, 101, 114, 118, 105, 99, 101, 47, 83, 116, 114, 101, 97, 109, 69, - 110, 100, 112, 111, 105, 110, 116, 115, 47, 103, 114, 112, 99, 46, 104, - 101, 97, 108, 116, 104, 46, 118, 49, 46, 72, 101, 97, 108, 116, 104, - 47, 87, 97, 116, 99, 104, 47, 101, 110, 118, 111, 121, 46, 115, 101, - 114, 118, 105, 99, 101, 46, 100, 105, 115, 99, 111, 118, 101, 114, 121, - 46, 118, 50, 46, 65, 103, 103, 114, 101, 103, 97, 116, 101, 100, 68, - 105, 115, 99, 111, 118, 101, 114, 121, 83, 101, 114, 118, 105, 99, 101, - 47, 83, 116, 114, 101, 97, 109, 65, 103, 103, 114, 101, 103, 97, 116, - 101, 100, 82, 101, 115, 111, 117, 114, 99, 101, 115, 100, 101, 102, 108, - 97, 116, 101, 103, 122, 105, 112, 115, 116, 114, 101, 97, 109, 47, 103, - 122, 105, 112, 71, 69, 84, 80, 79, 83, 84, 47, 47, 105, 110, 100, - 101, 120, 46, 104, 116, 109, 108, 104, 116, 116, 112, 104, 116, 116, 112, - 115, 50, 48, 48, 50, 48, 52, 50, 48, 54, 51, 48, 52, 52, 48, - 48, 52, 48, 52, 53, 48, 48, 97, 99, 99, 101, 112, 116, 45, 99, - 104, 97, 114, 115, 101, 116, 103, 122, 105, 112, 44, 32, 100, 101, 102, - 108, 97, 116, 101, 97, 99, 99, 101, 112, 116, 45, 108, 97, 110, 103, - 117, 97, 103, 101, 97, 99, 99, 101, 112, 116, 45, 114, 97, 110, 103, - 101, 115, 97, 99, 99, 101, 112, 116, 97, 99, 99, 101, 115, 115, 45, - 99, 111, 110, 116, 114, 111, 108, 45, 97, 108, 108, 111, 119, 45, 111, - 114, 105, 103, 105, 110, 97, 103, 101, 97, 108, 108, 111, 119, 97, 117, - 116, 104, 111, 114, 105, 122, 97, 116, 105, 111, 110, 99, 97, 99, 104, - 101, 45, 99, 111, 110, 116, 114, 111, 108, 99, 111, 110, 116, 101, 110, - 116, 45, 100, 105, 115, 112, 111, 115, 105, 116, 105, 111, 110, 99, 111, - 110, 116, 101, 110, 116, 45, 108, 97, 110, 103, 117, 97, 103, 101, 99, - 111, 110, 116, 101, 110, 116, 45, 108, 101, 110, 103, 116, 104, 99, 111, - 110, 116, 101, 110, 116, 45, 108, 111, 99, 97, 116, 105, 111, 110, 99, - 111, 110, 116, 101, 110, 116, 45, 114, 97, 110, 103, 101, 99, 111, 111, - 107, 105, 101, 100, 97, 116, 101, 101, 116, 97, 103, 101, 120, 112, 101, - 99, 116, 101, 120, 112, 105, 114, 101, 115, 102, 114, 111, 109, 105, 102, - 45, 109, 97, 116, 99, 104, 105, 102, 45, 109, 111, 100, 105, 102, 105, - 101, 100, 45, 115, 105, 110, 99, 101, 105, 102, 45, 110, 111, 110, 101, - 45, 109, 97, 116, 99, 104, 105, 102, 45, 114, 97, 110, 103, 101, 105, - 102, 45, 117, 110, 109, 111, 100, 105, 102, 105, 101, 100, 45, 115, 105, - 110, 99, 101, 108, 97, 115, 116, 45, 109, 111, 100, 105, 102, 105, 101, - 100, 108, 105, 110, 107, 108, 111, 99, 97, 116, 105, 111, 110, 109, 97, - 120, 45, 102, 111, 114, 119, 97, 114, 100, 115, 112, 114, 111, 120, 121, - 45, 97, 117, 116, 104, 101, 110, 116, 105, 99, 97, 116, 101, 112, 114, - 111, 120, 121, 45, 97, 117, 116, 104, 111, 114, 105, 122, 97, 116, 105, - 111, 110, 114, 97, 110, 103, 101, 114, 101, 102, 101, 114, 101, 114, 114, - 101, 102, 114, 101, 115, 104, 114, 101, 116, 114, 121, 45, 97, 102, 116, - 101, 114, 115, 101, 114, 118, 101, 114, 115, 101, 116, 45, 99, 111, 111, - 107, 105, 101, 115, 116, 114, 105, 99, 116, 45, 116, 114, 97, 110, 115, - 112, 111, 114, 116, 45, 115, 101, 99, 117, 114, 105, 116, 121, 116, 114, - 97, 110, 115, 102, 101, 114, 45, 101, 110, 99, 111, 100, 105, 110, 103, - 118, 97, 114, 121, 118, 105, 97, 119, 119, 119, 45, 97, 117, 116, 104, - 101, 110, 116, 105, 99, 97, 116, 101, 48, 105, 100, 101, 110, 116, 105, - 116, 121, 116, 114, 97, 105, 108, 101, 114, 115, 97, 112, 112, 108, 105, - 99, 97, 116, 105, 111, 110, 47, 103, 114, 112, 99, 103, 114, 112, 99, - 80, 85, 84, 108, 98, 45, 99, 111, 115, 116, 45, 98, 105, 110, 105, - 100, 101, 110, 116, 105, 116, 121, 44, 100, 101, 102, 108, 97, 116, 101, - 105, 100, 101, 110, 116, 105, 116, 121, 44, 103, 122, 105, 112, 100, 101, - 102, 108, 97, 116, 101, 44, 103, 122, 105, 112, 105, 100, 101, 110, 116, - 105, 116, 121, 44, 100, 101, 102, 108, 97, 116, 101, 44, 103, 122, 105, - 112}; + 120, 45, 101, 110, 100, 112, 111, 105, 110, 116, 45, 108, 111, 97, 100, + 45, 109, 101, 116, 114, 105, 99, 115, 45, 98, 105, 110, 103, 114, 112, + 99, 45, 116, 105, 109, 101, 111, 117, 116, 49, 50, 51, 52, 103, 114, + 112, 99, 46, 119, 97, 105, 116, 95, 102, 111, 114, 95, 114, 101, 97, + 100, 121, 103, 114, 112, 99, 46, 116, 105, 109, 101, 111, 117, 116, 103, + 114, 112, 99, 46, 109, 97, 120, 95, 114, 101, 113, 117, 101, 115, 116, + 95, 109, 101, 115, 115, 97, 103, 101, 95, 98, 121, 116, 101, 115, 103, + 114, 112, 99, 46, 109, 97, 120, 95, 114, 101, 115, 112, 111, 110, 115, + 101, 95, 109, 101, 115, 115, 97, 103, 101, 95, 98, 121, 116, 101, 115, + 47, 103, 114, 112, 99, 46, 108, 98, 46, 118, 49, 46, 76, 111, 97, + 100, 66, 97, 108, 97, 110, 99, 101, 114, 47, 66, 97, 108, 97, 110, + 99, 101, 76, 111, 97, 100, 47, 101, 110, 118, 111, 121, 46, 115, 101, + 114, 118, 105, 99, 101, 46, 108, 111, 97, 100, 95, 115, 116, 97, 116, + 115, 46, 118, 50, 46, 76, 111, 97, 100, 82, 101, 112, 111, 114, 116, + 105, 110, 103, 83, 101, 114, 118, 105, 99, 101, 47, 83, 116, 114, 101, + 97, 109, 76, 111, 97, 100, 83, 116, 97, 116, 115, 47, 101, 110, 118, + 111, 121, 46, 97, 112, 105, 46, 118, 50, 46, 69, 110, 100, 112, 111, + 105, 110, 116, 68, 105, 115, 99, 111, 118, 101, 114, 121, 83, 101, 114, + 118, 105, 99, 101, 47, 83, 116, 114, 101, 97, 109, 69, 110, 100, 112, + 111, 105, 110, 116, 115, 47, 103, 114, 112, 99, 46, 104, 101, 97, 108, + 116, 104, 46, 118, 49, 46, 72, 101, 97, 108, 116, 104, 47, 87, 97, + 116, 99, 104, 47, 101, 110, 118, 111, 121, 46, 115, 101, 114, 118, 105, + 99, 101, 46, 100, 105, 115, 99, 111, 118, 101, 114, 121, 46, 118, 50, + 46, 65, 103, 103, 114, 101, 103, 97, 116, 101, 100, 68, 105, 115, 99, + 111, 118, 101, 114, 121, 83, 101, 114, 118, 105, 99, 101, 47, 83, 116, + 114, 101, 97, 109, 65, 103, 103, 114, 101, 103, 97, 116, 101, 100, 82, + 101, 115, 111, 117, 114, 99, 101, 115, 100, 101, 102, 108, 97, 116, 101, + 103, 122, 105, 112, 115, 116, 114, 101, 97, 109, 47, 103, 122, 105, 112, + 71, 69, 84, 80, 79, 83, 84, 47, 47, 105, 110, 100, 101, 120, 46, + 104, 116, 109, 108, 104, 116, 116, 112, 104, 116, 116, 112, 115, 50, 48, + 48, 50, 48, 52, 50, 48, 54, 51, 48, 52, 52, 48, 48, 52, 48, + 52, 53, 48, 48, 97, 99, 99, 101, 112, 116, 45, 99, 104, 97, 114, + 115, 101, 116, 103, 122, 105, 112, 44, 32, 100, 101, 102, 108, 97, 116, + 101, 97, 99, 99, 101, 112, 116, 45, 108, 97, 110, 103, 117, 97, 103, + 101, 97, 99, 99, 101, 112, 116, 45, 114, 97, 110, 103, 101, 115, 97, + 99, 99, 101, 112, 116, 97, 99, 99, 101, 115, 115, 45, 99, 111, 110, + 116, 114, 111, 108, 45, 97, 108, 108, 111, 119, 45, 111, 114, 105, 103, + 105, 110, 97, 103, 101, 97, 108, 108, 111, 119, 97, 117, 116, 104, 111, + 114, 105, 122, 97, 116, 105, 111, 110, 99, 97, 99, 104, 101, 45, 99, + 111, 110, 116, 114, 111, 108, 99, 111, 110, 116, 101, 110, 116, 45, 100, + 105, 115, 112, 111, 115, 105, 116, 105, 111, 110, 99, 111, 110, 116, 101, + 110, 116, 45, 108, 97, 110, 103, 117, 97, 103, 101, 99, 111, 110, 116, + 101, 110, 116, 45, 108, 101, 110, 103, 116, 104, 99, 111, 110, 116, 101, + 110, 116, 45, 108, 111, 99, 97, 116, 105, 111, 110, 99, 111, 110, 116, + 101, 110, 116, 45, 114, 97, 110, 103, 101, 99, 111, 111, 107, 105, 101, + 100, 97, 116, 101, 101, 116, 97, 103, 101, 120, 112, 101, 99, 116, 101, + 120, 112, 105, 114, 101, 115, 102, 114, 111, 109, 105, 102, 45, 109, 97, + 116, 99, 104, 105, 102, 45, 109, 111, 100, 105, 102, 105, 101, 100, 45, + 115, 105, 110, 99, 101, 105, 102, 45, 110, 111, 110, 101, 45, 109, 97, + 116, 99, 104, 105, 102, 45, 114, 97, 110, 103, 101, 105, 102, 45, 117, + 110, 109, 111, 100, 105, 102, 105, 101, 100, 45, 115, 105, 110, 99, 101, + 108, 97, 115, 116, 45, 109, 111, 100, 105, 102, 105, 101, 100, 108, 105, + 110, 107, 108, 111, 99, 97, 116, 105, 111, 110, 109, 97, 120, 45, 102, + 111, 114, 119, 97, 114, 100, 115, 112, 114, 111, 120, 121, 45, 97, 117, + 116, 104, 101, 110, 116, 105, 99, 97, 116, 101, 112, 114, 111, 120, 121, + 45, 97, 117, 116, 104, 111, 114, 105, 122, 97, 116, 105, 111, 110, 114, + 97, 110, 103, 101, 114, 101, 102, 101, 114, 101, 114, 114, 101, 102, 114, + 101, 115, 104, 114, 101, 116, 114, 121, 45, 97, 102, 116, 101, 114, 115, + 101, 114, 118, 101, 114, 115, 101, 116, 45, 99, 111, 111, 107, 105, 101, + 115, 116, 114, 105, 99, 116, 45, 116, 114, 97, 110, 115, 112, 111, 114, + 116, 45, 115, 101, 99, 117, 114, 105, 116, 121, 116, 114, 97, 110, 115, + 102, 101, 114, 45, 101, 110, 99, 111, 100, 105, 110, 103, 118, 97, 114, + 121, 118, 105, 97, 119, 119, 119, 45, 97, 117, 116, 104, 101, 110, 116, + 105, 99, 97, 116, 101, 48, 105, 100, 101, 110, 116, 105, 116, 121, 116, + 114, 97, 105, 108, 101, 114, 115, 97, 112, 112, 108, 105, 99, 97, 116, + 105, 111, 110, 47, 103, 114, 112, 99, 103, 114, 112, 99, 80, 85, 84, + 108, 98, 45, 99, 111, 115, 116, 45, 98, 105, 110, 105, 100, 101, 110, + 116, 105, 116, 121, 44, 100, 101, 102, 108, 97, 116, 101, 105, 100, 101, + 110, 116, 105, 116, 121, 44, 103, 122, 105, 112, 100, 101, 102, 108, 97, + 116, 101, 44, 103, 122, 105, 112, 105, 100, 101, 110, 116, 105, 116, 121, + 44, 100, 101, 102, 108, 97, 116, 101, 44, 103, 122, 105, 112}; grpc_slice_refcount grpc_core::StaticSliceRefcount::kStaticSubRefcount; @@ -187,6 +188,7 @@ struct StaticMetadataCtx { StaticSliceRefcount(102), StaticSliceRefcount(103), StaticSliceRefcount(104), StaticSliceRefcount(105), StaticSliceRefcount(106), StaticSliceRefcount(107), + StaticSliceRefcount(108), }; const StaticMetadataSlice slices[GRPC_STATIC_MDSTR_COUNT] = { @@ -214,488 +216,494 @@ struct StaticMetadataCtx { grpc_core::StaticMetadataSlice(&refcounts[20].base, 4, g_bytes + 278), grpc_core::StaticMetadataSlice(&refcounts[21].base, 26, g_bytes + 282), grpc_core::StaticMetadataSlice(&refcounts[22].base, 22, g_bytes + 308), - grpc_core::StaticMetadataSlice(&refcounts[23].base, 12, g_bytes + 330), - grpc_core::StaticMetadataSlice(&refcounts[24].base, 1, g_bytes + 342), - grpc_core::StaticMetadataSlice(&refcounts[25].base, 1, g_bytes + 343), - grpc_core::StaticMetadataSlice(&refcounts[26].base, 1, g_bytes + 344), - grpc_core::StaticMetadataSlice(&refcounts[27].base, 1, g_bytes + 345), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), - grpc_core::StaticMetadataSlice(&refcounts[29].base, 19, g_bytes + 346), - grpc_core::StaticMetadataSlice(&refcounts[30].base, 12, g_bytes + 365), - grpc_core::StaticMetadataSlice(&refcounts[31].base, 30, g_bytes + 377), - grpc_core::StaticMetadataSlice(&refcounts[32].base, 31, g_bytes + 407), - grpc_core::StaticMetadataSlice(&refcounts[33].base, 36, g_bytes + 438), - grpc_core::StaticMetadataSlice(&refcounts[34].base, 65, g_bytes + 474), - grpc_core::StaticMetadataSlice(&refcounts[35].base, 54, g_bytes + 539), - grpc_core::StaticMetadataSlice(&refcounts[36].base, 28, g_bytes + 593), - grpc_core::StaticMetadataSlice(&refcounts[37].base, 80, g_bytes + 621), - grpc_core::StaticMetadataSlice(&refcounts[38].base, 7, g_bytes + 701), - grpc_core::StaticMetadataSlice(&refcounts[39].base, 4, g_bytes + 708), - grpc_core::StaticMetadataSlice(&refcounts[40].base, 11, g_bytes + 712), - grpc_core::StaticMetadataSlice(&refcounts[41].base, 3, g_bytes + 723), - grpc_core::StaticMetadataSlice(&refcounts[42].base, 4, g_bytes + 726), - grpc_core::StaticMetadataSlice(&refcounts[43].base, 1, g_bytes + 730), - grpc_core::StaticMetadataSlice(&refcounts[44].base, 11, g_bytes + 731), - grpc_core::StaticMetadataSlice(&refcounts[45].base, 4, g_bytes + 742), - grpc_core::StaticMetadataSlice(&refcounts[46].base, 5, g_bytes + 746), - grpc_core::StaticMetadataSlice(&refcounts[47].base, 3, g_bytes + 751), - grpc_core::StaticMetadataSlice(&refcounts[48].base, 3, g_bytes + 754), - grpc_core::StaticMetadataSlice(&refcounts[49].base, 3, g_bytes + 757), - grpc_core::StaticMetadataSlice(&refcounts[50].base, 3, g_bytes + 760), - grpc_core::StaticMetadataSlice(&refcounts[51].base, 3, g_bytes + 763), - grpc_core::StaticMetadataSlice(&refcounts[52].base, 3, g_bytes + 766), - grpc_core::StaticMetadataSlice(&refcounts[53].base, 3, g_bytes + 769), - grpc_core::StaticMetadataSlice(&refcounts[54].base, 14, g_bytes + 772), - grpc_core::StaticMetadataSlice(&refcounts[55].base, 13, g_bytes + 786), - grpc_core::StaticMetadataSlice(&refcounts[56].base, 15, g_bytes + 799), - grpc_core::StaticMetadataSlice(&refcounts[57].base, 13, g_bytes + 814), - grpc_core::StaticMetadataSlice(&refcounts[58].base, 6, g_bytes + 827), - grpc_core::StaticMetadataSlice(&refcounts[59].base, 27, g_bytes + 833), - grpc_core::StaticMetadataSlice(&refcounts[60].base, 3, g_bytes + 860), - grpc_core::StaticMetadataSlice(&refcounts[61].base, 5, g_bytes + 863), - grpc_core::StaticMetadataSlice(&refcounts[62].base, 13, g_bytes + 868), - grpc_core::StaticMetadataSlice(&refcounts[63].base, 13, g_bytes + 881), - grpc_core::StaticMetadataSlice(&refcounts[64].base, 19, g_bytes + 894), - grpc_core::StaticMetadataSlice(&refcounts[65].base, 16, g_bytes + 913), - grpc_core::StaticMetadataSlice(&refcounts[66].base, 14, g_bytes + 929), - grpc_core::StaticMetadataSlice(&refcounts[67].base, 16, g_bytes + 943), - grpc_core::StaticMetadataSlice(&refcounts[68].base, 13, g_bytes + 959), - grpc_core::StaticMetadataSlice(&refcounts[69].base, 6, g_bytes + 972), - grpc_core::StaticMetadataSlice(&refcounts[70].base, 4, g_bytes + 978), - grpc_core::StaticMetadataSlice(&refcounts[71].base, 4, g_bytes + 982), - grpc_core::StaticMetadataSlice(&refcounts[72].base, 6, g_bytes + 986), - grpc_core::StaticMetadataSlice(&refcounts[73].base, 7, g_bytes + 992), - grpc_core::StaticMetadataSlice(&refcounts[74].base, 4, g_bytes + 999), - grpc_core::StaticMetadataSlice(&refcounts[75].base, 8, g_bytes + 1003), - grpc_core::StaticMetadataSlice(&refcounts[76].base, 17, g_bytes + 1011), - grpc_core::StaticMetadataSlice(&refcounts[77].base, 13, g_bytes + 1028), - grpc_core::StaticMetadataSlice(&refcounts[78].base, 8, g_bytes + 1041), - grpc_core::StaticMetadataSlice(&refcounts[79].base, 19, g_bytes + 1049), - grpc_core::StaticMetadataSlice(&refcounts[80].base, 13, g_bytes + 1068), - grpc_core::StaticMetadataSlice(&refcounts[81].base, 4, g_bytes + 1081), - grpc_core::StaticMetadataSlice(&refcounts[82].base, 8, g_bytes + 1085), - grpc_core::StaticMetadataSlice(&refcounts[83].base, 12, g_bytes + 1093), - grpc_core::StaticMetadataSlice(&refcounts[84].base, 18, g_bytes + 1105), - grpc_core::StaticMetadataSlice(&refcounts[85].base, 19, g_bytes + 1123), - grpc_core::StaticMetadataSlice(&refcounts[86].base, 5, g_bytes + 1142), - grpc_core::StaticMetadataSlice(&refcounts[87].base, 7, g_bytes + 1147), - grpc_core::StaticMetadataSlice(&refcounts[88].base, 7, g_bytes + 1154), - grpc_core::StaticMetadataSlice(&refcounts[89].base, 11, g_bytes + 1161), - grpc_core::StaticMetadataSlice(&refcounts[90].base, 6, g_bytes + 1172), - grpc_core::StaticMetadataSlice(&refcounts[91].base, 10, g_bytes + 1178), - grpc_core::StaticMetadataSlice(&refcounts[92].base, 25, g_bytes + 1188), - grpc_core::StaticMetadataSlice(&refcounts[93].base, 17, g_bytes + 1213), - grpc_core::StaticMetadataSlice(&refcounts[94].base, 4, g_bytes + 1230), - grpc_core::StaticMetadataSlice(&refcounts[95].base, 3, g_bytes + 1234), - grpc_core::StaticMetadataSlice(&refcounts[96].base, 16, g_bytes + 1237), - grpc_core::StaticMetadataSlice(&refcounts[97].base, 1, g_bytes + 1253), - grpc_core::StaticMetadataSlice(&refcounts[98].base, 8, g_bytes + 1254), - grpc_core::StaticMetadataSlice(&refcounts[99].base, 8, g_bytes + 1262), - grpc_core::StaticMetadataSlice(&refcounts[100].base, 16, g_bytes + 1270), - grpc_core::StaticMetadataSlice(&refcounts[101].base, 4, g_bytes + 1286), - grpc_core::StaticMetadataSlice(&refcounts[102].base, 3, g_bytes + 1290), - grpc_core::StaticMetadataSlice(&refcounts[103].base, 11, g_bytes + 1293), - grpc_core::StaticMetadataSlice(&refcounts[104].base, 16, g_bytes + 1304), - grpc_core::StaticMetadataSlice(&refcounts[105].base, 13, g_bytes + 1320), - grpc_core::StaticMetadataSlice(&refcounts[106].base, 12, g_bytes + 1333), - grpc_core::StaticMetadataSlice(&refcounts[107].base, 21, g_bytes + 1345), + grpc_core::StaticMetadataSlice(&refcounts[23].base, 27, g_bytes + 330), + grpc_core::StaticMetadataSlice(&refcounts[24].base, 12, g_bytes + 357), + grpc_core::StaticMetadataSlice(&refcounts[25].base, 1, g_bytes + 369), + grpc_core::StaticMetadataSlice(&refcounts[26].base, 1, g_bytes + 370), + grpc_core::StaticMetadataSlice(&refcounts[27].base, 1, g_bytes + 371), + grpc_core::StaticMetadataSlice(&refcounts[28].base, 1, g_bytes + 372), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), + grpc_core::StaticMetadataSlice(&refcounts[30].base, 19, g_bytes + 373), + grpc_core::StaticMetadataSlice(&refcounts[31].base, 12, g_bytes + 392), + grpc_core::StaticMetadataSlice(&refcounts[32].base, 30, g_bytes + 404), + grpc_core::StaticMetadataSlice(&refcounts[33].base, 31, g_bytes + 434), + grpc_core::StaticMetadataSlice(&refcounts[34].base, 36, g_bytes + 465), + grpc_core::StaticMetadataSlice(&refcounts[35].base, 65, g_bytes + 501), + grpc_core::StaticMetadataSlice(&refcounts[36].base, 54, g_bytes + 566), + grpc_core::StaticMetadataSlice(&refcounts[37].base, 28, g_bytes + 620), + grpc_core::StaticMetadataSlice(&refcounts[38].base, 80, g_bytes + 648), + grpc_core::StaticMetadataSlice(&refcounts[39].base, 7, g_bytes + 728), + grpc_core::StaticMetadataSlice(&refcounts[40].base, 4, g_bytes + 735), + grpc_core::StaticMetadataSlice(&refcounts[41].base, 11, g_bytes + 739), + grpc_core::StaticMetadataSlice(&refcounts[42].base, 3, g_bytes + 750), + grpc_core::StaticMetadataSlice(&refcounts[43].base, 4, g_bytes + 753), + grpc_core::StaticMetadataSlice(&refcounts[44].base, 1, g_bytes + 757), + grpc_core::StaticMetadataSlice(&refcounts[45].base, 11, g_bytes + 758), + grpc_core::StaticMetadataSlice(&refcounts[46].base, 4, g_bytes + 769), + grpc_core::StaticMetadataSlice(&refcounts[47].base, 5, g_bytes + 773), + grpc_core::StaticMetadataSlice(&refcounts[48].base, 3, g_bytes + 778), + grpc_core::StaticMetadataSlice(&refcounts[49].base, 3, g_bytes + 781), + grpc_core::StaticMetadataSlice(&refcounts[50].base, 3, g_bytes + 784), + grpc_core::StaticMetadataSlice(&refcounts[51].base, 3, g_bytes + 787), + grpc_core::StaticMetadataSlice(&refcounts[52].base, 3, g_bytes + 790), + grpc_core::StaticMetadataSlice(&refcounts[53].base, 3, g_bytes + 793), + grpc_core::StaticMetadataSlice(&refcounts[54].base, 3, g_bytes + 796), + grpc_core::StaticMetadataSlice(&refcounts[55].base, 14, g_bytes + 799), + grpc_core::StaticMetadataSlice(&refcounts[56].base, 13, g_bytes + 813), + grpc_core::StaticMetadataSlice(&refcounts[57].base, 15, g_bytes + 826), + grpc_core::StaticMetadataSlice(&refcounts[58].base, 13, g_bytes + 841), + grpc_core::StaticMetadataSlice(&refcounts[59].base, 6, g_bytes + 854), + grpc_core::StaticMetadataSlice(&refcounts[60].base, 27, g_bytes + 860), + grpc_core::StaticMetadataSlice(&refcounts[61].base, 3, g_bytes + 887), + grpc_core::StaticMetadataSlice(&refcounts[62].base, 5, g_bytes + 890), + grpc_core::StaticMetadataSlice(&refcounts[63].base, 13, g_bytes + 895), + grpc_core::StaticMetadataSlice(&refcounts[64].base, 13, g_bytes + 908), + grpc_core::StaticMetadataSlice(&refcounts[65].base, 19, g_bytes + 921), + grpc_core::StaticMetadataSlice(&refcounts[66].base, 16, g_bytes + 940), + grpc_core::StaticMetadataSlice(&refcounts[67].base, 14, g_bytes + 956), + grpc_core::StaticMetadataSlice(&refcounts[68].base, 16, g_bytes + 970), + grpc_core::StaticMetadataSlice(&refcounts[69].base, 13, g_bytes + 986), + grpc_core::StaticMetadataSlice(&refcounts[70].base, 6, g_bytes + 999), + grpc_core::StaticMetadataSlice(&refcounts[71].base, 4, g_bytes + 1005), + grpc_core::StaticMetadataSlice(&refcounts[72].base, 4, g_bytes + 1009), + grpc_core::StaticMetadataSlice(&refcounts[73].base, 6, g_bytes + 1013), + grpc_core::StaticMetadataSlice(&refcounts[74].base, 7, g_bytes + 1019), + grpc_core::StaticMetadataSlice(&refcounts[75].base, 4, g_bytes + 1026), + grpc_core::StaticMetadataSlice(&refcounts[76].base, 8, g_bytes + 1030), + grpc_core::StaticMetadataSlice(&refcounts[77].base, 17, g_bytes + 1038), + grpc_core::StaticMetadataSlice(&refcounts[78].base, 13, g_bytes + 1055), + grpc_core::StaticMetadataSlice(&refcounts[79].base, 8, g_bytes + 1068), + grpc_core::StaticMetadataSlice(&refcounts[80].base, 19, g_bytes + 1076), + grpc_core::StaticMetadataSlice(&refcounts[81].base, 13, g_bytes + 1095), + grpc_core::StaticMetadataSlice(&refcounts[82].base, 4, g_bytes + 1108), + grpc_core::StaticMetadataSlice(&refcounts[83].base, 8, g_bytes + 1112), + grpc_core::StaticMetadataSlice(&refcounts[84].base, 12, g_bytes + 1120), + grpc_core::StaticMetadataSlice(&refcounts[85].base, 18, g_bytes + 1132), + grpc_core::StaticMetadataSlice(&refcounts[86].base, 19, g_bytes + 1150), + grpc_core::StaticMetadataSlice(&refcounts[87].base, 5, g_bytes + 1169), + grpc_core::StaticMetadataSlice(&refcounts[88].base, 7, g_bytes + 1174), + grpc_core::StaticMetadataSlice(&refcounts[89].base, 7, g_bytes + 1181), + grpc_core::StaticMetadataSlice(&refcounts[90].base, 11, g_bytes + 1188), + grpc_core::StaticMetadataSlice(&refcounts[91].base, 6, g_bytes + 1199), + grpc_core::StaticMetadataSlice(&refcounts[92].base, 10, g_bytes + 1205), + grpc_core::StaticMetadataSlice(&refcounts[93].base, 25, g_bytes + 1215), + grpc_core::StaticMetadataSlice(&refcounts[94].base, 17, g_bytes + 1240), + grpc_core::StaticMetadataSlice(&refcounts[95].base, 4, g_bytes + 1257), + grpc_core::StaticMetadataSlice(&refcounts[96].base, 3, g_bytes + 1261), + grpc_core::StaticMetadataSlice(&refcounts[97].base, 16, g_bytes + 1264), + grpc_core::StaticMetadataSlice(&refcounts[98].base, 1, g_bytes + 1280), + grpc_core::StaticMetadataSlice(&refcounts[99].base, 8, g_bytes + 1281), + grpc_core::StaticMetadataSlice(&refcounts[100].base, 8, g_bytes + 1289), + grpc_core::StaticMetadataSlice(&refcounts[101].base, 16, g_bytes + 1297), + grpc_core::StaticMetadataSlice(&refcounts[102].base, 4, g_bytes + 1313), + grpc_core::StaticMetadataSlice(&refcounts[103].base, 3, g_bytes + 1317), + grpc_core::StaticMetadataSlice(&refcounts[104].base, 11, g_bytes + 1320), + grpc_core::StaticMetadataSlice(&refcounts[105].base, 16, g_bytes + 1331), + grpc_core::StaticMetadataSlice(&refcounts[106].base, 13, g_bytes + 1347), + grpc_core::StaticMetadataSlice(&refcounts[107].base, 12, g_bytes + 1360), + grpc_core::StaticMetadataSlice(&refcounts[108].base, 21, g_bytes + 1372), }; StaticMetadata static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[3].base, 10, g_bytes + 19), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 0), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[1].base, 7, g_bytes + 5), - grpc_core::StaticMetadataSlice(&refcounts[41].base, 3, g_bytes + 723), + grpc_core::StaticMetadataSlice(&refcounts[42].base, 3, g_bytes + 750), 1), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[1].base, 7, g_bytes + 5), - grpc_core::StaticMetadataSlice(&refcounts[42].base, 4, g_bytes + 726), + grpc_core::StaticMetadataSlice(&refcounts[43].base, 4, g_bytes + 753), 2), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[0].base, 5, g_bytes + 0), - grpc_core::StaticMetadataSlice(&refcounts[43].base, 1, g_bytes + 730), + grpc_core::StaticMetadataSlice(&refcounts[44].base, 1, g_bytes + 757), 3), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[0].base, 5, g_bytes + 0), - grpc_core::StaticMetadataSlice(&refcounts[44].base, 11, - g_bytes + 731), + grpc_core::StaticMetadataSlice(&refcounts[45].base, 11, + g_bytes + 758), 4), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[4].base, 7, g_bytes + 29), - grpc_core::StaticMetadataSlice(&refcounts[45].base, 4, g_bytes + 742), + grpc_core::StaticMetadataSlice(&refcounts[46].base, 4, g_bytes + 769), 5), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[4].base, 7, g_bytes + 29), - grpc_core::StaticMetadataSlice(&refcounts[46].base, 5, g_bytes + 746), + grpc_core::StaticMetadataSlice(&refcounts[47].base, 5, g_bytes + 773), 6), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&refcounts[47].base, 3, g_bytes + 751), + grpc_core::StaticMetadataSlice(&refcounts[48].base, 3, g_bytes + 778), 7), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&refcounts[48].base, 3, g_bytes + 754), + grpc_core::StaticMetadataSlice(&refcounts[49].base, 3, g_bytes + 781), 8), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&refcounts[49].base, 3, g_bytes + 757), + grpc_core::StaticMetadataSlice(&refcounts[50].base, 3, g_bytes + 784), 9), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&refcounts[50].base, 3, g_bytes + 760), + grpc_core::StaticMetadataSlice(&refcounts[51].base, 3, g_bytes + 787), 10), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&refcounts[51].base, 3, g_bytes + 763), + grpc_core::StaticMetadataSlice(&refcounts[52].base, 3, g_bytes + 790), 11), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&refcounts[52].base, 3, g_bytes + 766), + grpc_core::StaticMetadataSlice(&refcounts[53].base, 3, g_bytes + 793), 12), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[2].base, 7, g_bytes + 12), - grpc_core::StaticMetadataSlice(&refcounts[53].base, 3, g_bytes + 769), + grpc_core::StaticMetadataSlice(&refcounts[54].base, 3, g_bytes + 796), 13), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[54].base, 14, - g_bytes + 772), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[55].base, 14, + g_bytes + 799), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 14), StaticMetadata(grpc_core::StaticMetadataSlice(&refcounts[16].base, 15, g_bytes + 186), - grpc_core::StaticMetadataSlice(&refcounts[55].base, 13, - g_bytes + 786), + grpc_core::StaticMetadataSlice(&refcounts[56].base, 13, + g_bytes + 813), 15), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[56].base, 15, - g_bytes + 799), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[57].base, 15, + g_bytes + 826), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 16), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[57].base, 13, - g_bytes + 814), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[58].base, 13, + g_bytes + 841), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 17), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[58].base, 6, g_bytes + 827), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[59].base, 6, g_bytes + 854), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 18), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[59].base, 27, - g_bytes + 833), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[60].base, 27, + g_bytes + 860), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 19), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[60].base, 3, g_bytes + 860), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[61].base, 3, g_bytes + 887), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 20), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[61].base, 5, g_bytes + 863), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[62].base, 5, g_bytes + 890), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 21), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[62].base, 13, - g_bytes + 868), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[63].base, 13, + g_bytes + 895), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 22), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[63].base, 13, - g_bytes + 881), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[64].base, 13, + g_bytes + 908), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 23), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[64].base, 19, - g_bytes + 894), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[65].base, 19, + g_bytes + 921), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 24), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[15].base, 16, g_bytes + 170), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 25), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[65].base, 16, - g_bytes + 913), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[66].base, 16, + g_bytes + 940), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 26), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[66].base, 14, - g_bytes + 929), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[67].base, 14, + g_bytes + 956), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 27), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[67].base, 16, - g_bytes + 943), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[68].base, 16, + g_bytes + 970), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 28), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[68].base, 13, - g_bytes + 959), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[69].base, 13, + g_bytes + 986), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 29), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[14].base, 12, g_bytes + 158), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 30), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[69].base, 6, g_bytes + 972), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[70].base, 6, g_bytes + 999), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 31), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[70].base, 4, g_bytes + 978), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[71].base, 4, + g_bytes + 1005), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 32), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[71].base, 4, g_bytes + 982), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[72].base, 4, + g_bytes + 1009), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 33), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[72].base, 6, g_bytes + 986), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[73].base, 6, + g_bytes + 1013), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 34), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[73].base, 7, g_bytes + 992), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[74].base, 7, + g_bytes + 1019), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 35), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[74].base, 4, g_bytes + 999), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[75].base, 4, + g_bytes + 1026), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 36), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[20].base, 4, g_bytes + 278), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 37), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[75].base, 8, - g_bytes + 1003), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[76].base, 8, + g_bytes + 1030), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 38), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[76].base, 17, - g_bytes + 1011), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[77].base, 17, + g_bytes + 1038), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 39), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[77].base, 13, - g_bytes + 1028), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[78].base, 13, + g_bytes + 1055), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 40), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[78].base, 8, - g_bytes + 1041), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[79].base, 8, + g_bytes + 1068), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 41), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[79].base, 19, - g_bytes + 1049), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[80].base, 19, + g_bytes + 1076), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 42), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[80].base, 13, - g_bytes + 1068), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[81].base, 13, + g_bytes + 1095), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 43), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[81].base, 4, - g_bytes + 1081), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[82].base, 4, + g_bytes + 1108), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 44), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[82].base, 8, - g_bytes + 1085), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[83].base, 8, + g_bytes + 1112), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 45), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[83].base, 12, - g_bytes + 1093), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[84].base, 12, + g_bytes + 1120), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 46), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[84].base, 18, - g_bytes + 1105), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[85].base, 18, + g_bytes + 1132), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 47), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[85].base, 19, - g_bytes + 1123), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[86].base, 19, + g_bytes + 1150), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 48), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[86].base, 5, - g_bytes + 1142), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[87].base, 5, + g_bytes + 1169), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 49), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[87].base, 7, - g_bytes + 1147), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[88].base, 7, + g_bytes + 1174), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 50), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[88].base, 7, - g_bytes + 1154), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[89].base, 7, + g_bytes + 1181), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 51), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[89].base, 11, - g_bytes + 1161), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[90].base, 11, + g_bytes + 1188), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 52), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[90].base, 6, - g_bytes + 1172), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[91].base, 6, + g_bytes + 1199), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 53), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[91].base, 10, - g_bytes + 1178), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[92].base, 10, + g_bytes + 1205), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 54), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[92].base, 25, - g_bytes + 1188), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[93].base, 25, + g_bytes + 1215), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 55), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[93].base, 17, - g_bytes + 1213), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[94].base, 17, + g_bytes + 1240), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 56), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[19].base, 10, g_bytes + 268), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 57), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[94].base, 4, - g_bytes + 1230), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[95].base, 4, + g_bytes + 1257), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 58), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[95].base, 3, - g_bytes + 1234), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[96].base, 3, + g_bytes + 1261), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 59), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[96].base, 16, - g_bytes + 1237), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[97].base, 16, + g_bytes + 1264), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 60), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[7].base, 11, g_bytes + 50), - grpc_core::StaticMetadataSlice(&refcounts[97].base, 1, - g_bytes + 1253), + grpc_core::StaticMetadataSlice(&refcounts[98].base, 1, + g_bytes + 1280), 61), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[7].base, 11, g_bytes + 50), - grpc_core::StaticMetadataSlice(&refcounts[24].base, 1, g_bytes + 342), + grpc_core::StaticMetadataSlice(&refcounts[25].base, 1, g_bytes + 369), 62), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[7].base, 11, g_bytes + 50), - grpc_core::StaticMetadataSlice(&refcounts[25].base, 1, g_bytes + 343), + grpc_core::StaticMetadataSlice(&refcounts[26].base, 1, g_bytes + 370), 63), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[9].base, 13, g_bytes + 77), - grpc_core::StaticMetadataSlice(&refcounts[98].base, 8, - g_bytes + 1254), + grpc_core::StaticMetadataSlice(&refcounts[99].base, 8, + g_bytes + 1281), 64), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[9].base, 13, g_bytes + 77), - grpc_core::StaticMetadataSlice(&refcounts[39].base, 4, g_bytes + 708), + grpc_core::StaticMetadataSlice(&refcounts[40].base, 4, g_bytes + 735), 65), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[9].base, 13, g_bytes + 77), - grpc_core::StaticMetadataSlice(&refcounts[38].base, 7, g_bytes + 701), + grpc_core::StaticMetadataSlice(&refcounts[39].base, 7, g_bytes + 728), 66), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[5].base, 2, g_bytes + 36), - grpc_core::StaticMetadataSlice(&refcounts[99].base, 8, - g_bytes + 1262), + grpc_core::StaticMetadataSlice(&refcounts[100].base, 8, + g_bytes + 1289), 67), StaticMetadata(grpc_core::StaticMetadataSlice(&refcounts[14].base, 12, g_bytes + 158), - grpc_core::StaticMetadataSlice(&refcounts[100].base, 16, - g_bytes + 1270), + grpc_core::StaticMetadataSlice(&refcounts[101].base, 16, + g_bytes + 1297), 68), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[4].base, 7, g_bytes + 29), - grpc_core::StaticMetadataSlice(&refcounts[101].base, 4, - g_bytes + 1286), + grpc_core::StaticMetadataSlice(&refcounts[102].base, 4, + g_bytes + 1313), 69), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[1].base, 7, g_bytes + 5), - grpc_core::StaticMetadataSlice(&refcounts[102].base, 3, - g_bytes + 1290), + grpc_core::StaticMetadataSlice(&refcounts[103].base, 3, + g_bytes + 1317), 70), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[16].base, 15, g_bytes + 186), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 71), StaticMetadata(grpc_core::StaticMetadataSlice(&refcounts[15].base, 16, g_bytes + 170), - grpc_core::StaticMetadataSlice(&refcounts[98].base, 8, - g_bytes + 1254), + grpc_core::StaticMetadataSlice(&refcounts[99].base, 8, + g_bytes + 1281), 72), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[15].base, 16, g_bytes + 170), - grpc_core::StaticMetadataSlice(&refcounts[39].base, 4, g_bytes + 708), + grpc_core::StaticMetadataSlice(&refcounts[40].base, 4, g_bytes + 735), 73), StaticMetadata( - grpc_core::StaticMetadataSlice(&refcounts[103].base, 11, - g_bytes + 1293), - grpc_core::StaticMetadataSlice(&refcounts[28].base, 0, g_bytes + 346), + grpc_core::StaticMetadataSlice(&refcounts[104].base, 11, + g_bytes + 1320), + grpc_core::StaticMetadataSlice(&refcounts[29].base, 0, g_bytes + 373), 74), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90), - grpc_core::StaticMetadataSlice(&refcounts[98].base, 8, - g_bytes + 1254), + grpc_core::StaticMetadataSlice(&refcounts[99].base, 8, + g_bytes + 1281), 75), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90), - grpc_core::StaticMetadataSlice(&refcounts[38].base, 7, g_bytes + 701), + grpc_core::StaticMetadataSlice(&refcounts[39].base, 7, g_bytes + 728), 76), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90), - grpc_core::StaticMetadataSlice(&refcounts[104].base, 16, - g_bytes + 1304), + grpc_core::StaticMetadataSlice(&refcounts[105].base, 16, + g_bytes + 1331), 77), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90), - grpc_core::StaticMetadataSlice(&refcounts[39].base, 4, g_bytes + 708), + grpc_core::StaticMetadataSlice(&refcounts[40].base, 4, g_bytes + 735), 78), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90), - grpc_core::StaticMetadataSlice(&refcounts[105].base, 13, - g_bytes + 1320), + grpc_core::StaticMetadataSlice(&refcounts[106].base, 13, + g_bytes + 1347), 79), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90), - grpc_core::StaticMetadataSlice(&refcounts[106].base, 12, - g_bytes + 1333), + grpc_core::StaticMetadataSlice(&refcounts[107].base, 12, + g_bytes + 1360), 80), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[10].base, 20, g_bytes + 90), - grpc_core::StaticMetadataSlice(&refcounts[107].base, 21, - g_bytes + 1345), + grpc_core::StaticMetadataSlice(&refcounts[108].base, 21, + g_bytes + 1372), 81), StaticMetadata(grpc_core::StaticMetadataSlice(&refcounts[16].base, 15, g_bytes + 186), - grpc_core::StaticMetadataSlice(&refcounts[98].base, 8, - g_bytes + 1254), + grpc_core::StaticMetadataSlice(&refcounts[99].base, 8, + g_bytes + 1281), 82), StaticMetadata( grpc_core::StaticMetadataSlice(&refcounts[16].base, 15, g_bytes + 186), - grpc_core::StaticMetadataSlice(&refcounts[39].base, 4, g_bytes + 708), + grpc_core::StaticMetadataSlice(&refcounts[40].base, 4, g_bytes + 735), 83), StaticMetadata(grpc_core::StaticMetadataSlice(&refcounts[16].base, 15, g_bytes + 186), - grpc_core::StaticMetadataSlice(&refcounts[105].base, 13, - g_bytes + 1320), + grpc_core::StaticMetadataSlice(&refcounts[106].base, 13, + g_bytes + 1347), 84), }; @@ -1181,17 +1189,17 @@ uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 4, 6, 6, 8, 8, 2, 4, 4}; static const int8_t elems_r[] = { - 15, 10, -8, 0, 2, -43, -80, -44, 0, 4, -8, 0, 0, 0, 6, -1, - -8, 0, 0, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, -65, 0, -68, -69, -50, -72, -73, 0, 32, 31, - 30, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 17, - 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 4, 3, - 3, 7, 0, 0, 0, 0, 0, 0, -5, 0}; + 15, 10, -8, 0, 2, -43, -81, -44, 0, 4, -8, 0, 0, 0, 6, -1, + -8, 0, 0, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -67, 0, -38, -50, -56, -76, 0, 46, 28, + 27, 26, 25, 24, 23, 23, 22, 21, 20, 19, 24, 16, 15, 14, 13, 15, + 14, 14, 13, 12, 11, 10, 9, 8, 7, 6, 6, 5, 4, 3, 2, 3, + 2, 2, 6, 0, 0, 0, 0, 0, 0, -6, 0}; static uint32_t elems_phash(uint32_t i) { - i -= 43; - uint32_t x = i % 106; - uint32_t y = i / 106; + i -= 44; + uint32_t x = i % 107; + uint32_t y = i / 107; uint32_t h = x; if (y < GPR_ARRAY_SIZE(elems_r)) { uint32_t delta = (uint32_t)elems_r[y]; @@ -1201,29 +1209,31 @@ static uint32_t elems_phash(uint32_t i) { } static const uint16_t elem_keys[] = { - 263, 264, 265, 266, 267, 268, 269, 1118, 1119, 1756, 149, 150, - 477, 478, 1648, 43, 44, 1010, 1011, 1540, 1767, 780, 781, 639, - 853, 1659, 2080, 2188, 5860, 6076, 6184, 6400, 6508, 6616, 6724, 6832, - 1783, 6940, 7048, 7156, 7264, 7372, 7480, 7588, 7696, 7804, 7912, 8020, - 8128, 8236, 8344, 6292, 8452, 8560, 8668, 8776, 8884, 8992, 9100, 9208, - 9316, 9424, 9532, 9640, 9748, 9856, 9964, 1178, 533, 10072, 10180, 210, - 10288, 1184, 1185, 1186, 1187, 1070, 10396, 1826, 11152, 0, 0, 0, - 1718, 0, 1833, 0, 0, 352, 0, 1612, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0}; + 266, 267, 268, 269, 270, 271, 272, 1129, 1130, 1773, 151, + 152, 482, 483, 1664, 44, 45, 1020, 1021, 1555, 1784, 788, + 789, 645, 861, 1675, 2100, 2209, 6024, 6569, 6787, 6896, 7005, + 7114, 7223, 7332, 1800, 7441, 7550, 7659, 7768, 7877, 8095, 8204, + 8313, 8422, 6678, 6460, 7986, 8531, 8640, 6351, 8749, 8858, 8967, + 9076, 9185, 9294, 9403, 9512, 9621, 6242, 9730, 9839, 9948, 10057, + 10166, 1189, 538, 10275, 10384, 212, 10493, 1195, 1196, 1197, 1198, + 1080, 10602, 1843, 11365, 0, 0, 0, 1734, 0, 1850, 0, + 0, 0, 356, 1627, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0}; static const uint8_t elem_idxs[] = { - 7, 8, 9, 10, 11, 12, 13, 76, 78, 71, 1, 2, 5, 6, 25, 3, - 4, 66, 65, 30, 83, 62, 63, 67, 61, 73, 57, 37, 14, 16, 17, 19, - 20, 21, 22, 23, 15, 24, 26, 27, 28, 29, 31, 32, 33, 34, 35, 36, - 38, 39, 40, 18, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 75, 69, 56, 58, 70, 59, 77, 79, 80, 81, 64, 60, 82, - 74, 255, 255, 255, 72, 255, 84, 255, 255, 0, 255, 68}; + 7, 8, 9, 10, 11, 12, 13, 76, 78, 71, 1, 2, 5, 6, 25, 3, + 4, 66, 65, 30, 83, 62, 63, 67, 61, 73, 57, 37, 14, 19, 21, 22, + 23, 24, 26, 27, 15, 28, 29, 31, 32, 33, 35, 36, 38, 39, 20, 18, + 34, 40, 41, 17, 42, 43, 44, 45, 46, 47, 48, 49, 50, 16, 51, 52, + 53, 54, 55, 75, 69, 56, 58, 70, 59, 77, 79, 80, 81, 64, 60, 82, + 74, 255, 255, 255, 72, 255, 84, 255, 255, 255, 0, 68}; grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b) { if (a == -1 || b == -1) return GRPC_MDNULL; - uint32_t k = static_cast(a * 108 + b); + uint32_t k = static_cast(a * 109 + b); uint32_t h = elems_phash(k); return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k && elem_idxs[h] != 255 diff --git a/src/core/lib/transport/static_metadata.h b/src/core/lib/transport/static_metadata.h index c465a2f37b7..391c6a7c4ab 100644 --- a/src/core/lib/transport/static_metadata.h +++ b/src/core/lib/transport/static_metadata.h @@ -36,7 +36,7 @@ static_assert( std::is_trivially_destructible::value, "grpc_core::StaticMetadataSlice must be trivially destructible."); -#define GRPC_STATIC_MDSTR_COUNT 108 +#define GRPC_STATIC_MDSTR_COUNT 109 void grpc_init_static_metadata_ctx(void); void grpc_destroy_static_metadata_ctx(void); @@ -102,185 +102,187 @@ inline const grpc_core::StaticMetadataSlice* grpc_static_slice_table() { #define GRPC_MDSTR_GRPC_PREVIOUS_RPC_ATTEMPTS (grpc_static_slice_table()[21]) /* "grpc-retry-pushback-ms" */ #define GRPC_MDSTR_GRPC_RETRY_PUSHBACK_MS (grpc_static_slice_table()[22]) +/* "x-endpoint-load-metrics-bin" */ +#define GRPC_MDSTR_X_ENDPOINT_LOAD_METRICS_BIN (grpc_static_slice_table()[23]) /* "grpc-timeout" */ -#define GRPC_MDSTR_GRPC_TIMEOUT (grpc_static_slice_table()[23]) +#define GRPC_MDSTR_GRPC_TIMEOUT (grpc_static_slice_table()[24]) /* "1" */ -#define GRPC_MDSTR_1 (grpc_static_slice_table()[24]) +#define GRPC_MDSTR_1 (grpc_static_slice_table()[25]) /* "2" */ -#define GRPC_MDSTR_2 (grpc_static_slice_table()[25]) +#define GRPC_MDSTR_2 (grpc_static_slice_table()[26]) /* "3" */ -#define GRPC_MDSTR_3 (grpc_static_slice_table()[26]) +#define GRPC_MDSTR_3 (grpc_static_slice_table()[27]) /* "4" */ -#define GRPC_MDSTR_4 (grpc_static_slice_table()[27]) +#define GRPC_MDSTR_4 (grpc_static_slice_table()[28]) /* "" */ -#define GRPC_MDSTR_EMPTY (grpc_static_slice_table()[28]) +#define GRPC_MDSTR_EMPTY (grpc_static_slice_table()[29]) /* "grpc.wait_for_ready" */ -#define GRPC_MDSTR_GRPC_DOT_WAIT_FOR_READY (grpc_static_slice_table()[29]) +#define GRPC_MDSTR_GRPC_DOT_WAIT_FOR_READY (grpc_static_slice_table()[30]) /* "grpc.timeout" */ -#define GRPC_MDSTR_GRPC_DOT_TIMEOUT (grpc_static_slice_table()[30]) +#define GRPC_MDSTR_GRPC_DOT_TIMEOUT (grpc_static_slice_table()[31]) /* "grpc.max_request_message_bytes" */ #define GRPC_MDSTR_GRPC_DOT_MAX_REQUEST_MESSAGE_BYTES \ - (grpc_static_slice_table()[31]) + (grpc_static_slice_table()[32]) /* "grpc.max_response_message_bytes" */ #define GRPC_MDSTR_GRPC_DOT_MAX_RESPONSE_MESSAGE_BYTES \ - (grpc_static_slice_table()[32]) + (grpc_static_slice_table()[33]) /* "/grpc.lb.v1.LoadBalancer/BalanceLoad" */ #define GRPC_MDSTR_SLASH_GRPC_DOT_LB_DOT_V1_DOT_LOADBALANCER_SLASH_BALANCELOAD \ - (grpc_static_slice_table()[33]) + (grpc_static_slice_table()[34]) /* "/envoy.service.load_stats.v2.LoadReportingService/StreamLoadStats" */ #define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_LOAD_STATS_DOT_V2_DOT_LOADREPORTINGSERVICE_SLASH_STREAMLOADSTATS \ - (grpc_static_slice_table()[34]) + (grpc_static_slice_table()[35]) /* "/envoy.api.v2.EndpointDiscoveryService/StreamEndpoints" */ #define GRPC_MDSTR_SLASH_ENVOY_DOT_API_DOT_V2_DOT_ENDPOINTDISCOVERYSERVICE_SLASH_STREAMENDPOINTS \ - (grpc_static_slice_table()[35]) + (grpc_static_slice_table()[36]) /* "/grpc.health.v1.Health/Watch" */ #define GRPC_MDSTR_SLASH_GRPC_DOT_HEALTH_DOT_V1_DOT_HEALTH_SLASH_WATCH \ - (grpc_static_slice_table()[36]) + (grpc_static_slice_table()[37]) /* "/envoy.service.discovery.v2.AggregatedDiscoveryService/StreamAggregatedResources" */ #define GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_DISCOVERY_DOT_V2_DOT_AGGREGATEDDISCOVERYSERVICE_SLASH_STREAMAGGREGATEDRESOURCES \ - (grpc_static_slice_table()[37]) + (grpc_static_slice_table()[38]) /* "deflate" */ -#define GRPC_MDSTR_DEFLATE (grpc_static_slice_table()[38]) +#define GRPC_MDSTR_DEFLATE (grpc_static_slice_table()[39]) /* "gzip" */ -#define GRPC_MDSTR_GZIP (grpc_static_slice_table()[39]) +#define GRPC_MDSTR_GZIP (grpc_static_slice_table()[40]) /* "stream/gzip" */ -#define GRPC_MDSTR_STREAM_SLASH_GZIP (grpc_static_slice_table()[40]) +#define GRPC_MDSTR_STREAM_SLASH_GZIP (grpc_static_slice_table()[41]) /* "GET" */ -#define GRPC_MDSTR_GET (grpc_static_slice_table()[41]) +#define GRPC_MDSTR_GET (grpc_static_slice_table()[42]) /* "POST" */ -#define GRPC_MDSTR_POST (grpc_static_slice_table()[42]) +#define GRPC_MDSTR_POST (grpc_static_slice_table()[43]) /* "/" */ -#define GRPC_MDSTR_SLASH (grpc_static_slice_table()[43]) +#define GRPC_MDSTR_SLASH (grpc_static_slice_table()[44]) /* "/index.html" */ -#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (grpc_static_slice_table()[44]) +#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (grpc_static_slice_table()[45]) /* "http" */ -#define GRPC_MDSTR_HTTP (grpc_static_slice_table()[45]) +#define GRPC_MDSTR_HTTP (grpc_static_slice_table()[46]) /* "https" */ -#define GRPC_MDSTR_HTTPS (grpc_static_slice_table()[46]) +#define GRPC_MDSTR_HTTPS (grpc_static_slice_table()[47]) /* "200" */ -#define GRPC_MDSTR_200 (grpc_static_slice_table()[47]) +#define GRPC_MDSTR_200 (grpc_static_slice_table()[48]) /* "204" */ -#define GRPC_MDSTR_204 (grpc_static_slice_table()[48]) +#define GRPC_MDSTR_204 (grpc_static_slice_table()[49]) /* "206" */ -#define GRPC_MDSTR_206 (grpc_static_slice_table()[49]) +#define GRPC_MDSTR_206 (grpc_static_slice_table()[50]) /* "304" */ -#define GRPC_MDSTR_304 (grpc_static_slice_table()[50]) +#define GRPC_MDSTR_304 (grpc_static_slice_table()[51]) /* "400" */ -#define GRPC_MDSTR_400 (grpc_static_slice_table()[51]) +#define GRPC_MDSTR_400 (grpc_static_slice_table()[52]) /* "404" */ -#define GRPC_MDSTR_404 (grpc_static_slice_table()[52]) +#define GRPC_MDSTR_404 (grpc_static_slice_table()[53]) /* "500" */ -#define GRPC_MDSTR_500 (grpc_static_slice_table()[53]) +#define GRPC_MDSTR_500 (grpc_static_slice_table()[54]) /* "accept-charset" */ -#define GRPC_MDSTR_ACCEPT_CHARSET (grpc_static_slice_table()[54]) +#define GRPC_MDSTR_ACCEPT_CHARSET (grpc_static_slice_table()[55]) /* "gzip, deflate" */ -#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (grpc_static_slice_table()[55]) +#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (grpc_static_slice_table()[56]) /* "accept-language" */ -#define GRPC_MDSTR_ACCEPT_LANGUAGE (grpc_static_slice_table()[56]) +#define GRPC_MDSTR_ACCEPT_LANGUAGE (grpc_static_slice_table()[57]) /* "accept-ranges" */ -#define GRPC_MDSTR_ACCEPT_RANGES (grpc_static_slice_table()[57]) +#define GRPC_MDSTR_ACCEPT_RANGES (grpc_static_slice_table()[58]) /* "accept" */ -#define GRPC_MDSTR_ACCEPT (grpc_static_slice_table()[58]) +#define GRPC_MDSTR_ACCEPT (grpc_static_slice_table()[59]) /* "access-control-allow-origin" */ -#define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN (grpc_static_slice_table()[59]) +#define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN (grpc_static_slice_table()[60]) /* "age" */ -#define GRPC_MDSTR_AGE (grpc_static_slice_table()[60]) +#define GRPC_MDSTR_AGE (grpc_static_slice_table()[61]) /* "allow" */ -#define GRPC_MDSTR_ALLOW (grpc_static_slice_table()[61]) +#define GRPC_MDSTR_ALLOW (grpc_static_slice_table()[62]) /* "authorization" */ -#define GRPC_MDSTR_AUTHORIZATION (grpc_static_slice_table()[62]) +#define GRPC_MDSTR_AUTHORIZATION (grpc_static_slice_table()[63]) /* "cache-control" */ -#define GRPC_MDSTR_CACHE_CONTROL (grpc_static_slice_table()[63]) +#define GRPC_MDSTR_CACHE_CONTROL (grpc_static_slice_table()[64]) /* "content-disposition" */ -#define GRPC_MDSTR_CONTENT_DISPOSITION (grpc_static_slice_table()[64]) +#define GRPC_MDSTR_CONTENT_DISPOSITION (grpc_static_slice_table()[65]) /* "content-language" */ -#define GRPC_MDSTR_CONTENT_LANGUAGE (grpc_static_slice_table()[65]) +#define GRPC_MDSTR_CONTENT_LANGUAGE (grpc_static_slice_table()[66]) /* "content-length" */ -#define GRPC_MDSTR_CONTENT_LENGTH (grpc_static_slice_table()[66]) +#define GRPC_MDSTR_CONTENT_LENGTH (grpc_static_slice_table()[67]) /* "content-location" */ -#define GRPC_MDSTR_CONTENT_LOCATION (grpc_static_slice_table()[67]) +#define GRPC_MDSTR_CONTENT_LOCATION (grpc_static_slice_table()[68]) /* "content-range" */ -#define GRPC_MDSTR_CONTENT_RANGE (grpc_static_slice_table()[68]) +#define GRPC_MDSTR_CONTENT_RANGE (grpc_static_slice_table()[69]) /* "cookie" */ -#define GRPC_MDSTR_COOKIE (grpc_static_slice_table()[69]) +#define GRPC_MDSTR_COOKIE (grpc_static_slice_table()[70]) /* "date" */ -#define GRPC_MDSTR_DATE (grpc_static_slice_table()[70]) +#define GRPC_MDSTR_DATE (grpc_static_slice_table()[71]) /* "etag" */ -#define GRPC_MDSTR_ETAG (grpc_static_slice_table()[71]) +#define GRPC_MDSTR_ETAG (grpc_static_slice_table()[72]) /* "expect" */ -#define GRPC_MDSTR_EXPECT (grpc_static_slice_table()[72]) +#define GRPC_MDSTR_EXPECT (grpc_static_slice_table()[73]) /* "expires" */ -#define GRPC_MDSTR_EXPIRES (grpc_static_slice_table()[73]) +#define GRPC_MDSTR_EXPIRES (grpc_static_slice_table()[74]) /* "from" */ -#define GRPC_MDSTR_FROM (grpc_static_slice_table()[74]) +#define GRPC_MDSTR_FROM (grpc_static_slice_table()[75]) /* "if-match" */ -#define GRPC_MDSTR_IF_MATCH (grpc_static_slice_table()[75]) +#define GRPC_MDSTR_IF_MATCH (grpc_static_slice_table()[76]) /* "if-modified-since" */ -#define GRPC_MDSTR_IF_MODIFIED_SINCE (grpc_static_slice_table()[76]) +#define GRPC_MDSTR_IF_MODIFIED_SINCE (grpc_static_slice_table()[77]) /* "if-none-match" */ -#define GRPC_MDSTR_IF_NONE_MATCH (grpc_static_slice_table()[77]) +#define GRPC_MDSTR_IF_NONE_MATCH (grpc_static_slice_table()[78]) /* "if-range" */ -#define GRPC_MDSTR_IF_RANGE (grpc_static_slice_table()[78]) +#define GRPC_MDSTR_IF_RANGE (grpc_static_slice_table()[79]) /* "if-unmodified-since" */ -#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (grpc_static_slice_table()[79]) +#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (grpc_static_slice_table()[80]) /* "last-modified" */ -#define GRPC_MDSTR_LAST_MODIFIED (grpc_static_slice_table()[80]) +#define GRPC_MDSTR_LAST_MODIFIED (grpc_static_slice_table()[81]) /* "link" */ -#define GRPC_MDSTR_LINK (grpc_static_slice_table()[81]) +#define GRPC_MDSTR_LINK (grpc_static_slice_table()[82]) /* "location" */ -#define GRPC_MDSTR_LOCATION (grpc_static_slice_table()[82]) +#define GRPC_MDSTR_LOCATION (grpc_static_slice_table()[83]) /* "max-forwards" */ -#define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table()[83]) +#define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table()[84]) /* "proxy-authenticate" */ -#define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table()[84]) +#define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table()[85]) /* "proxy-authorization" */ -#define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table()[85]) +#define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table()[86]) /* "range" */ -#define GRPC_MDSTR_RANGE (grpc_static_slice_table()[86]) +#define GRPC_MDSTR_RANGE (grpc_static_slice_table()[87]) /* "referer" */ -#define GRPC_MDSTR_REFERER (grpc_static_slice_table()[87]) +#define GRPC_MDSTR_REFERER (grpc_static_slice_table()[88]) /* "refresh" */ -#define GRPC_MDSTR_REFRESH (grpc_static_slice_table()[88]) +#define GRPC_MDSTR_REFRESH (grpc_static_slice_table()[89]) /* "retry-after" */ -#define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table()[89]) +#define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table()[90]) /* "server" */ -#define GRPC_MDSTR_SERVER (grpc_static_slice_table()[90]) +#define GRPC_MDSTR_SERVER (grpc_static_slice_table()[91]) /* "set-cookie" */ -#define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table()[91]) +#define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table()[92]) /* "strict-transport-security" */ -#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table()[92]) +#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table()[93]) /* "transfer-encoding" */ -#define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table()[93]) +#define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table()[94]) /* "vary" */ -#define GRPC_MDSTR_VARY (grpc_static_slice_table()[94]) +#define GRPC_MDSTR_VARY (grpc_static_slice_table()[95]) /* "via" */ -#define GRPC_MDSTR_VIA (grpc_static_slice_table()[95]) +#define GRPC_MDSTR_VIA (grpc_static_slice_table()[96]) /* "www-authenticate" */ -#define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table()[96]) +#define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table()[97]) /* "0" */ -#define GRPC_MDSTR_0 (grpc_static_slice_table()[97]) +#define GRPC_MDSTR_0 (grpc_static_slice_table()[98]) /* "identity" */ -#define GRPC_MDSTR_IDENTITY (grpc_static_slice_table()[98]) +#define GRPC_MDSTR_IDENTITY (grpc_static_slice_table()[99]) /* "trailers" */ -#define GRPC_MDSTR_TRAILERS (grpc_static_slice_table()[99]) +#define GRPC_MDSTR_TRAILERS (grpc_static_slice_table()[100]) /* "application/grpc" */ -#define GRPC_MDSTR_APPLICATION_SLASH_GRPC (grpc_static_slice_table()[100]) +#define GRPC_MDSTR_APPLICATION_SLASH_GRPC (grpc_static_slice_table()[101]) /* "grpc" */ -#define GRPC_MDSTR_GRPC (grpc_static_slice_table()[101]) +#define GRPC_MDSTR_GRPC (grpc_static_slice_table()[102]) /* "PUT" */ -#define GRPC_MDSTR_PUT (grpc_static_slice_table()[102]) +#define GRPC_MDSTR_PUT (grpc_static_slice_table()[103]) /* "lb-cost-bin" */ -#define GRPC_MDSTR_LB_COST_BIN (grpc_static_slice_table()[103]) +#define GRPC_MDSTR_LB_COST_BIN (grpc_static_slice_table()[104]) /* "identity,deflate" */ -#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (grpc_static_slice_table()[104]) +#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (grpc_static_slice_table()[105]) /* "identity,gzip" */ -#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (grpc_static_slice_table()[105]) +#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (grpc_static_slice_table()[106]) /* "deflate,gzip" */ -#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (grpc_static_slice_table()[106]) +#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (grpc_static_slice_table()[107]) /* "identity,deflate,gzip" */ #define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \ - (grpc_static_slice_table()[107]) + (grpc_static_slice_table()[108]) namespace grpc_core { struct StaticSliceRefcount; @@ -538,6 +540,7 @@ typedef enum { GRPC_BATCH_HOST, GRPC_BATCH_GRPC_PREVIOUS_RPC_ATTEMPTS, GRPC_BATCH_GRPC_RETRY_PUSHBACK_MS, + GRPC_BATCH_X_ENDPOINT_LOAD_METRICS_BIN, GRPC_BATCH_CALLOUTS_COUNT } grpc_metadata_batch_callouts_index; @@ -567,6 +570,7 @@ typedef union { struct grpc_linked_mdelem* host; struct grpc_linked_mdelem* grpc_previous_rpc_attempts; struct grpc_linked_mdelem* grpc_retry_pushback_ms; + struct grpc_linked_mdelem* x_endpoint_load_metrics_bin; } named; } grpc_metadata_batch_callouts; diff --git a/src/proto/grpc/lb/v2/BUILD b/src/proto/grpc/lb/v2/BUILD index e47f170e14b..25b3dd3644a 100644 --- a/src/proto/grpc/lb/v2/BUILD +++ b/src/proto/grpc/lb/v2/BUILD @@ -39,3 +39,10 @@ grpc_proto_library( well_known_protos = True, deps = ["eds_for_test_proto"], ) + +grpc_proto_library( + name = "orca_load_report_for_test_proto", + srcs = [ + "orca_load_report_for_test.proto", + ], +) diff --git a/src/proto/grpc/lb/v2/eds_for_test.proto b/src/proto/grpc/lb/v2/eds_for_test.proto index 3126095c92d..e5c4f606407 100644 --- a/src/proto/grpc/lb/v2/eds_for_test.proto +++ b/src/proto/grpc/lb/v2/eds_for_test.proto @@ -16,8 +16,12 @@ // the gRPC library; otherwise there can be duplicate definition problems if // users depend on both gRPC and Envoy. It can only be used by gRPC tests. // -// TODO(juanlishen): It's a workaround and should be removed once we have a -// clean solution to use protobuf and external proto files. +// TODO(juanlishen): This file is a hack to avoid a problem we're +// currently having where we can't depend on a proto file in an external +// repo due to bazel limitations. Once that's fixed, this should be +// removed. Until this, it should be used in the gRPC tests only, or else it +// will cause a conflict due to the same proto messages being defined in +// multiple files in the same binary. syntax = "proto3"; diff --git a/src/proto/grpc/lb/v2/lrs_for_test.proto b/src/proto/grpc/lb/v2/lrs_for_test.proto index 76c560a99cf..504b6e752ce 100644 --- a/src/proto/grpc/lb/v2/lrs_for_test.proto +++ b/src/proto/grpc/lb/v2/lrs_for_test.proto @@ -14,9 +14,12 @@ // This file contains the eds protocol and its dependency. // -// TODO(juanlishen): It's a workaround and should be removed once we have a -// clean solution to the circular dependency between the envoy data plane APIs -// and gRPC. We can't check in this file due to conflict with internal code. +// TODO(juanlishen): This file is a hack to avoid a problem we're +// currently having where we can't depend on a proto file in an external +// repo due to bazel limitations. Once that's fixed, this should be +// removed. Until this, it should be used in the gRPC tests only, or else it +// will cause a conflict due to the same proto messages being defined in +// multiple files in the same binary. syntax = "proto3"; diff --git a/src/proto/grpc/lb/v2/orca_load_report_for_test.proto b/src/proto/grpc/lb/v2/orca_load_report_for_test.proto new file mode 100644 index 00000000000..1feaedd6a40 --- /dev/null +++ b/src/proto/grpc/lb/v2/orca_load_report_for_test.proto @@ -0,0 +1,58 @@ +// Copyright 2019 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This file contains a copy of the ORCA load reporting protos, with the +// validation options stripped out to avoid the extra dependency on +// protoc-gen-validate. +// +// TODO(juanlishen): This file is a hack to avoid a problem we're +// currently having where we can't depend on a proto file in an external +// repo due to bazel limitations. Once that's fixed, this should be +// removed. Until this, it should be used in the gRPC tests only, or else it +// will cause a conflict due to the same proto messages being defined in +// multiple files in the same binary. + +syntax = "proto3"; + +package udpa.data.orca.v1; + +option java_outer_classname = "OrcaLoadReportProto"; +option java_multiple_files = true; +option java_package = "io.envoyproxy.udpa.data.orca.v1"; +option go_package = "v1"; + +// See section `ORCA load report format` of the design document in +// :ref:`https://github.com/envoyproxy/envoy/issues/6614`. + +message OrcaLoadReport { + // CPU utilization expressed as a fraction of available CPU resources. This + // should be derived from the latest sample or measurement. + double cpu_utilization = 1; + + // Memory utilization expressed as a fraction of available memory + // resources. This should be derived from the latest sample or measurement. + double mem_utilization = 2; + + // Total RPS being served by an endpoint. This should cover all services that an endpoint is + // responsible for. + uint64 rps = 3; + + // Application specific requests costs. Each value is an absolute cost (e.g. 3487 bytes of + // storage) associated with the request. + map request_cost = 4; + + // Resource utilization values. Each value is expressed as a fraction of total resources + // available, derived from the latest sample or measurement. + map utilization = 5; +} diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 607235556e3..6eb8bc8c9c1 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -322,6 +322,7 @@ CORE_SOURCE_FILES = [ 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc', 'src/core/ext/transport/chttp2/client/authority.cc', 'src/core/ext/transport/chttp2/client/chttp2_connector.cc', + 'src/core/ext/filters/client_channel/backend_metric.cc', 'src/core/ext/filters/client_channel/backup_poller.cc', 'src/core/ext/filters/client_channel/channel_connectivity.cc', 'src/core/ext/filters/client_channel/client_channel.cc', @@ -350,6 +351,19 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/deadline/deadline_filter.cc', 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', + 'src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c', + 'src/core/ext/upb-generated/gogoproto/gogo.upb.c', + 'src/core/ext/upb-generated/validate/validate.upb.c', + 'src/core/ext/upb-generated/google/api/annotations.upb.c', + 'src/core/ext/upb-generated/google/api/http.upb.c', + 'src/core/ext/upb-generated/google/protobuf/any.upb.c', + 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.c', + 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', + 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', + 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', + 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', + 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', + 'src/core/ext/upb-generated/google/rpc/status.upb.c', 'src/core/tsi/fake_transport_security.cc', 'src/core/tsi/local_transport_security.cc', 'src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc', @@ -369,16 +383,6 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c', - 'src/core/ext/upb-generated/google/api/annotations.upb.c', - 'src/core/ext/upb-generated/google/api/http.upb.c', - 'src/core/ext/upb-generated/google/protobuf/any.upb.c', - 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.c', - 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', - 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', - 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', - 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', - 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', - 'src/core/ext/upb-generated/google/rpc/status.upb.c', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds.cc', 'src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc', @@ -387,6 +391,7 @@ CORE_SOURCE_FILES = [ 'src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/cds.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/eds.upb.c', @@ -399,11 +404,10 @@ CORE_SOURCE_FILES = [ 'src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c', + 'src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c', 'src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c', 'src/core/ext/upb-generated/envoy/type/percent.upb.c', 'src/core/ext/upb-generated/envoy/type/range.upb.c', - 'src/core/ext/upb-generated/gogoproto/gogo.upb.c', - 'src/core/ext/upb-generated/validate/validate.upb.c', 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc', 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc', diff --git a/test/core/end2end/fuzzers/hpack.dictionary b/test/core/end2end/fuzzers/hpack.dictionary index 921018db7f8..bc621ca2a11 100644 --- a/test/core/end2end/fuzzers/hpack.dictionary +++ b/test/core/end2end/fuzzers/hpack.dictionary @@ -22,6 +22,7 @@ "\x04host" "\x1Agrpc-previous-rpc-attempts" "\x16grpc-retry-pushback-ms" +"\x1Bx-endpoint-load-metrics-bin" "\x0Cgrpc-timeout" "\x011" "\x012" diff --git a/test/core/util/test_lb_policies.cc b/test/core/util/test_lb_policies.cc index 6225740cde7..d4ce3a27e50 100644 --- a/test/core/util/test_lb_policies.cc +++ b/test/core/util/test_lb_policies.cc @@ -191,7 +191,7 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy gpr_log(GPR_INFO, "trailing metadata:"); InterceptRecvTrailingMetadataLoadBalancingPolicy::LogMetadata( recv_trailing_metadata); - self->cb_(self->user_data_); + self->cb_(self->user_data_, call_state->GetBackendMetricData()); self->~TrailingMetadataHandler(); } diff --git a/test/core/util/test_lb_policies.h b/test/core/util/test_lb_policies.h index 6d2693a0d59..3652515e57e 100644 --- a/test/core/util/test_lb_policies.h +++ b/test/core/util/test_lb_policies.h @@ -19,9 +19,12 @@ #ifndef GRPC_TEST_CORE_UTIL_TEST_LB_POLICIES_H #define GRPC_TEST_CORE_UTIL_TEST_LB_POLICIES_H +#include "src/core/ext/filters/client_channel/lb_policy.h" + namespace grpc_core { -typedef void (*InterceptRecvTrailingMetadataCallback)(void*); +typedef void (*InterceptRecvTrailingMetadataCallback)( + void*, const LoadBalancingPolicy::BackendMetricData*); // Registers an LB policy called "intercept_trailing_metadata_lb" that // invokes cb with argument user_data when trailing metadata is received diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD index 5567170d371..1b487602a7a 100644 --- a/test/cpp/end2end/BUILD +++ b/test/cpp/end2end/BUILD @@ -433,6 +433,7 @@ grpc_cc_test( "//:gpr", "//:grpc", "//:grpc++", + "//src/proto/grpc/lb/v2:orca_load_report_for_test_proto", "//src/proto/grpc/testing:echo_messages_proto", "//src/proto/grpc/testing:echo_proto", "//src/proto/grpc/testing/duplicate:echo_duplicate_proto", diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index ceab7506729..69feb4a5d51 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -51,6 +51,7 @@ #include "src/cpp/client/secure_credentials.h" #include "src/cpp/server/secure_server_credentials.h" +#include "src/proto/grpc/lb/v2/orca_load_report_for_test.pb.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -94,15 +95,21 @@ grpc_tcp_client_vtable delayed_connect = {tcp_client_connect_with_delay}; // every call to the Echo RPC. class MyTestServiceImpl : public TestServiceImpl { public: - MyTestServiceImpl() : request_count_(0) {} - Status Echo(ServerContext* context, const EchoRequest* request, EchoResponse* response) override { + const udpa::data::orca::v1::OrcaLoadReport* load_report = nullptr; { grpc::internal::MutexLock lock(&mu_); ++request_count_; + load_report = load_report_; } AddClient(context->peer()); + if (load_report != nullptr) { + // TODO(roth): Once we provide a more standard server-side API for + // populating this data, use that API here. + context->AddTrailingMetadata("x-endpoint-load-metrics-bin", + load_report->SerializeAsString()); + } return TestServiceImpl::Echo(context, request, response); } @@ -121,6 +128,11 @@ class MyTestServiceImpl : public TestServiceImpl { return clients_; } + void set_load_report(udpa::data::orca::v1::OrcaLoadReport* load_report) { + grpc::internal::MutexLock lock(&mu_); + load_report_ = load_report; + } + private: void AddClient(const grpc::string& client) { grpc::internal::MutexLock lock(&clients_mu_); @@ -128,7 +140,8 @@ class MyTestServiceImpl : public TestServiceImpl { } grpc::internal::Mutex mu_; - int request_count_; + int request_count_ = 0; + const udpa::data::orca::v1::OrcaLoadReport* load_report_ = nullptr; grpc::internal::Mutex clients_mu_; std::set clients_; }; @@ -1506,16 +1519,40 @@ class ClientLbInterceptTrailingMetadataTest : public ClientLbEnd2endTest { return trailers_intercepted_; } + const udpa::data::orca::v1::OrcaLoadReport* backend_load_report() { + grpc::internal::MutexLock lock(&mu_); + return load_report_.get(); + } + private: - static void ReportTrailerIntercepted(void* arg) { + static void ReportTrailerIntercepted( + void* arg, const grpc_core::LoadBalancingPolicy::BackendMetricData* + backend_metric_data) { ClientLbInterceptTrailingMetadataTest* self = static_cast(arg); grpc::internal::MutexLock lock(&self->mu_); self->trailers_intercepted_++; + if (backend_metric_data != nullptr) { + self->load_report_.reset(new udpa::data::orca::v1::OrcaLoadReport); + self->load_report_->set_cpu_utilization( + backend_metric_data->cpu_utilization); + self->load_report_->set_mem_utilization( + backend_metric_data->mem_utilization); + self->load_report_->set_rps(backend_metric_data->requests_per_second); + for (const auto& p : backend_metric_data->request_cost) { + grpc_core::UniquePtr name = p.first.dup(); + (*self->load_report_->mutable_request_cost())[name.get()] = p.second; + } + for (const auto& p : backend_metric_data->utilization) { + grpc_core::UniquePtr name = p.first.dup(); + (*self->load_report_->mutable_utilization())[name.get()] = p.second; + } + } } grpc::internal::Mutex mu_; int trailers_intercepted_ = 0; + std::unique_ptr load_report_; }; TEST_F(ClientLbInterceptTrailingMetadataTest, InterceptsRetriesDisabled) { @@ -1534,6 +1571,7 @@ TEST_F(ClientLbInterceptTrailingMetadataTest, InterceptsRetriesDisabled) { EXPECT_EQ("intercept_trailing_metadata_lb", channel->GetLoadBalancingPolicyName()); EXPECT_EQ(kNumRpcs, trailers_intercepted()); + EXPECT_EQ(nullptr, backend_load_report()); } TEST_F(ClientLbInterceptTrailingMetadataTest, InterceptsRetriesEnabled) { @@ -1568,6 +1606,57 @@ TEST_F(ClientLbInterceptTrailingMetadataTest, InterceptsRetriesEnabled) { EXPECT_EQ("intercept_trailing_metadata_lb", channel->GetLoadBalancingPolicyName()); EXPECT_EQ(kNumRpcs, trailers_intercepted()); + EXPECT_EQ(nullptr, backend_load_report()); +} + +TEST_F(ClientLbInterceptTrailingMetadataTest, BackendMetricData) { + const int kNumServers = 1; + const int kNumRpcs = 10; + StartServers(kNumServers); + udpa::data::orca::v1::OrcaLoadReport load_report; + load_report.set_cpu_utilization(0.5); + load_report.set_mem_utilization(0.75); + load_report.set_rps(25); + auto* request_cost = load_report.mutable_request_cost(); + (*request_cost)["foo"] = 0.8; + (*request_cost)["bar"] = 1.4; + auto* utilization = load_report.mutable_utilization(); + (*utilization)["baz"] = 1.1; + (*utilization)["quux"] = 0.9; + for (const auto& server : servers_) { + server->service_.set_load_report(&load_report); + } + auto response_generator = BuildResolverResponseGenerator(); + auto channel = + BuildChannel("intercept_trailing_metadata_lb", response_generator); + auto stub = BuildStub(channel); + response_generator.SetNextResolution(GetServersPorts()); + for (size_t i = 0; i < kNumRpcs; ++i) { + CheckRpcSendOk(stub, DEBUG_LOCATION); + auto* actual = backend_load_report(); + ASSERT_NE(actual, nullptr); + // TODO(roth): Change this to use EqualsProto() once that becomes + // available in OSS. + EXPECT_EQ(actual->cpu_utilization(), load_report.cpu_utilization()); + EXPECT_EQ(actual->mem_utilization(), load_report.mem_utilization()); + EXPECT_EQ(actual->rps(), load_report.rps()); + EXPECT_EQ(actual->request_cost().size(), load_report.request_cost().size()); + for (const auto& p : actual->request_cost()) { + auto it = load_report.request_cost().find(p.first); + ASSERT_NE(it, load_report.request_cost().end()); + EXPECT_EQ(it->second, p.second); + } + EXPECT_EQ(actual->utilization().size(), load_report.utilization().size()); + for (const auto& p : actual->utilization()) { + auto it = load_report.utilization().find(p.first); + ASSERT_NE(it, load_report.utilization().end()); + EXPECT_EQ(it->second, p.second); + } + } + // Check LB policy name for the channel. + EXPECT_EQ("intercept_trailing_metadata_lb", + channel->GetLoadBalancingPolicyName()); + EXPECT_EQ(kNumRpcs, trailers_intercepted()); } } // namespace diff --git a/third_party/envoy-api b/third_party/envoy-api index a83394157ad..c181f78882e 160000 --- a/third_party/envoy-api +++ b/third_party/envoy-api @@ -1 +1 @@ -Subproject commit a83394157ad97f4dadbc8ed81f56ad5b3a72e542 +Subproject commit c181f78882e54c0e5c63f332562ef6954ee7932f diff --git a/third_party/udpa b/third_party/udpa new file mode 160000 index 00000000000..94324803a49 --- /dev/null +++ b/third_party/udpa @@ -0,0 +1 @@ +Subproject commit 94324803a497c8f76dbc78df393ef629d3a9f3c3 diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py index d79759f541c..4ac8f9dada7 100755 --- a/tools/codegen/core/gen_static_metadata.py +++ b/tools/codegen/core/gen_static_metadata.py @@ -56,6 +56,7 @@ CONFIG = [ '3', '4', '', + 'x-endpoint-load-metrics-bin', # channel arg keys 'grpc.wait_for_ready', 'grpc.timeout', @@ -177,6 +178,7 @@ METADATA_BATCH_CALLOUTS = [ 'host', 'grpc-previous-rpc-attempts', 'grpc-retry-pushback-ms', + 'x-endpoint-load-metrics-bin', ] COMPRESSION_ALGORITHMS = [ diff --git a/tools/codegen/core/gen_upb_api.sh b/tools/codegen/core/gen_upb_api.sh index 4a9239a2828..89e664e6134 100755 --- a/tools/codegen/core/gen_upb_api.sh +++ b/tools/codegen/core/gen_upb_api.sh @@ -41,12 +41,14 @@ proto_files=( \ "envoy/api/v2/auth/cert.proto" \ "envoy/api/v2/cds.proto" \ "envoy/api/v2/cluster/circuit_breaker.proto" \ + "envoy/api/v2/cluster/filter.proto" \ "envoy/api/v2/cluster/outlier_detection.proto" \ "envoy/api/v2/core/address.proto" \ "envoy/api/v2/core/base.proto" \ "envoy/api/v2/core/config_source.proto" \ "envoy/api/v2/core/grpc_service.proto" \ "envoy/api/v2/core/health_check.proto" \ + "envoy/api/v2/core/http_uri.proto" \ "envoy/api/v2/core/protocol.proto" \ "envoy/api/v2/discovery.proto" \ "envoy/api/v2/eds.proto" \ @@ -71,13 +73,15 @@ proto_files=( \ "src/proto/grpc/gcp/handshaker.proto" \ "src/proto/grpc/gcp/transport_security_common.proto" \ "src/proto/grpc/health/v1/health.proto" \ - "src/proto/grpc/health/v1/health.proto" \ "src/proto/grpc/lb/v1/load_balancer.proto" \ + "udpa/data/orca/v1/orca_load_report.proto" \ "validate/validate.proto") for i in "${proto_files[@]}" do + echo "Compiling: ${i}" $PROTOC \ + -I=$PWD/third_party/udpa \ -I=$PWD/third_party/envoy-api \ -I=$PWD/third_party/googleapis \ -I=$PWD/third_party/protobuf/src \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index e2900b2e701..ed6f88dde3c 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -875,6 +875,8 @@ src/core/README.md \ src/core/ext/README.md \ src/core/ext/filters/census/grpc_context.cc \ src/core/ext/filters/client_channel/README.md \ +src/core/ext/filters/client_channel/backend_metric.cc \ +src/core/ext/filters/client_channel/backend_metric.h \ src/core/ext/filters/client_channel/backup_poller.cc \ src/core/ext/filters/client_channel/backup_poller.h \ src/core/ext/filters/client_channel/channel_connectivity.cc \ @@ -1065,6 +1067,8 @@ src/core/ext/upb-generated/envoy/api/v2/cds.upb.c \ src/core/ext/upb-generated/envoy/api/v2/cds.upb.h \ src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c \ src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h \ +src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c \ +src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h \ src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c \ src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h \ src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c \ @@ -1077,6 +1081,8 @@ src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c \ src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h \ src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c \ src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h \ +src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c \ +src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h \ src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c \ src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h \ src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c \ @@ -1127,6 +1133,8 @@ src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \ src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h \ src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \ src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h \ +src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c \ +src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h \ src/core/ext/upb-generated/validate/validate.upb.c \ src/core/ext/upb-generated/validate/validate.upb.h \ src/core/lib/README.md \ diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index 39f3e26266c..8ad552cd399 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -32,7 +32,7 @@ cat << EOF | awk '{ print $1 }' | sort > "$want_submodules" b29b21a81b32ec273f118f589f46d56ad3332420 third_party/boringssl (remotes/origin/chromium-stable) afc30d43eef92979b05776ec0963c9cede5fb80f third_party/boringssl-with-bazel (fips-20180716-116-gafc30d43e) e982924acee7f7313b4baa4ee5ec000c5e373c30 third_party/cares/cares (cares-1_15_0) - a83394157ad97f4dadbc8ed81f56ad5b3a72e542 third_party/envoy-api (heads/master) + c181f78882e54c0e5c63f332562ef6954ee7932f third_party/envoy-api (heads/master) 28f50e0fed19872e0fd50dd23ce2ee8cd759338e third_party/gflags (v2.2.0-5-g30dbc81) 80ed4d0bbf65d57cc267dfc63bd2584557f11f9b third_party/googleapis (common-protos-1_3_1-915-g80ed4d0bb) c9ccac7cb7345901884aabf5d1a786cfa6e2f397 third_party/googletest (6e2f397) @@ -40,6 +40,7 @@ cat << EOF | awk '{ print $1 }' | sort > "$want_submodules" 9245d481eb3e890f708ff2d7dadf2a10c04748ba third_party/libcxxabi (heads/release_60) 09745575a923640154bcf307fba8aedff47f240a third_party/protobuf (v3.7.0-rc.2-247-g09745575) e143189bf6f37b3957fb31743df6a1bcf4a8c685 third_party/protoc-gen-validate (v0.0.10) + 94324803a497c8f76dbc78df393ef629d3a9f3c3 third_party/udpa (heads/master) 931bbecbd3230ae7f22efa5d203639facc47f719 third_party/upb (heads/master) cacf7f1d4e3d44d871b605da3b647f07d718623f third_party/zlib (v1.2.11) EOF From b46e3668d31a014c8ab72fbae63f52990051127a Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Tue, 20 Aug 2019 14:14:16 -0700 Subject: [PATCH 1388/1555] s/branch/tail_call/ for CH2 on_hdr(). on_hdr() checks if a void-return function pointer is null before jumping to it. If it is null, it returns an error; else it executes that function and returns success. This change converts the void-returning function to one that returns a grpc_error* and thus saves a branch in on_hdr() (since we're branching once by following the function pointer anyways, we're effectively coalescing these two branches). --- .../chttp2/transport/hpack_parser.cc | 49 +++++++++---------- .../transport/chttp2/transport/hpack_parser.h | 2 +- .../transport/chttp2/transport/hpack_table.cc | 21 ++++++-- .../transport/chttp2/transport/hpack_table.h | 15 ++++-- .../ext/transport/chttp2/transport/parsing.cc | 13 +++-- .../chttp2/hpack_parser_fuzzer_test.cc | 5 +- .../transport/chttp2/hpack_parser_test.cc | 3 +- test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 11 +++-- 8 files changed, 77 insertions(+), 42 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index 7414fd7fff8..a5142ffd96f 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -655,12 +655,7 @@ static grpc_error* on_hdr(grpc_chttp2_hpack_parser* p, grpc_mdelem md) { grpc_error* err = grpc_chttp2_hptbl_add(&p->table, md); if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) return err; } - if (GPR_UNLIKELY(p->on_header == nullptr)) { - GRPC_MDELEM_UNREF(md); - return GRPC_ERROR_CREATE_FROM_STATIC_STRING("on_header callback not set"); - } - p->on_header(p->on_header_user_data, md); - return GRPC_ERROR_NONE; + return p->on_header(p->on_header_user_data, md); } static grpc_core::UnmanagedMemorySlice take_string_extern( @@ -765,23 +760,26 @@ static grpc_error* parse_stream_dep0(grpc_chttp2_hpack_parser* p, return parse_stream_dep1(p, cur + 1, end); } +static grpc_error* GPR_ATTRIBUTE_NOINLINE +on_invalid_hpack_idx(grpc_chttp2_hpack_parser* p) { + return grpc_error_set_int( + grpc_error_set_int( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Invalid HPACK index received"), + GRPC_ERROR_INT_INDEX, static_cast(p->index)), + GRPC_ERROR_INT_SIZE, static_cast(p->table.num_ents)); +} + /* emit an indexed field; jumps to begin the next field on completion */ static grpc_error* finish_indexed_field(grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end) { - grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index); - if (GRPC_MDISNULL(md)) { - return grpc_error_set_int( - grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "Invalid HPACK index received"), - GRPC_ERROR_INT_INDEX, - static_cast(p->index)), - GRPC_ERROR_INT_SIZE, static_cast(p->table.num_ents)); + grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index); + if (GPR_UNLIKELY(GRPC_MDISNULL(md))) { + return on_invalid_hpack_idx(p); } - GRPC_MDELEM_REF(md); GRPC_STATS_INC_HPACK_RECV_INDEXED(); grpc_error* err = on_hdr(p, md); - if (err != GRPC_ERROR_NONE) return err; + if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) return err; return parse_begin(p, cur, end); } @@ -1557,13 +1555,8 @@ static void set_precomputed_md_idx(grpc_chttp2_hpack_parser* p, static grpc_error* is_binary_indexed_header(grpc_chttp2_hpack_parser* p, bool* is) { grpc_mdelem elem = grpc_chttp2_hptbl_lookup(&p->table, p->index); - if (GRPC_MDISNULL(elem)) { - return grpc_error_set_int( - grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "Invalid HPACK index received"), - GRPC_ERROR_INT_INDEX, - static_cast(p->index)), - GRPC_ERROR_INT_SIZE, static_cast(p->table.num_ents)); + if (GPR_UNLIKELY(GRPC_MDISNULL(elem))) { + return on_invalid_hpack_idx(p); } /* We know that GRPC_MDKEY(elem) points to a reference counted slice since: * 1. elem was a result of grpc_chttp2_hptbl_lookup @@ -1599,10 +1592,16 @@ static grpc_error* parse_value_string_with_literal_key( return parse_value_string(p, cur, end, is_binary_literal_header(p)); } +/* "Uninitialized" header parser to save us a branch in on_hdr(). */ +static grpc_error* on_header_uninitialized(void* user_data, grpc_mdelem md) { + GRPC_MDELEM_UNREF(md); + return GRPC_ERROR_CREATE_FROM_STATIC_STRING("on_header callback not set"); +} + /* PUBLIC INTERFACE */ void grpc_chttp2_hpack_parser_init(grpc_chttp2_hpack_parser* p) { - p->on_header = nullptr; + p->on_header = on_header_uninitialized; p->on_header_user_data = nullptr; p->state = parse_begin; p->key.data.referenced = grpc_empty_slice(); @@ -1750,7 +1749,7 @@ grpc_error* grpc_chttp2_header_parser_parse(void* hpack_parser, grpc_chttp2_mark_stream_closed(t, s, true, false, GRPC_ERROR_NONE); } } - parser->on_header = nullptr; + parser->on_header = on_header_uninitialized; parser->on_header_user_data = nullptr; parser->is_boundary = 0xde; parser->is_eof = 0xde; diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.h b/src/core/ext/transport/chttp2/transport/hpack_parser.h index c5691244028..eb90568920c 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.h +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.h @@ -46,7 +46,7 @@ typedef struct { struct grpc_chttp2_hpack_parser { /* user specified callback for each header output */ - void (*on_header)(void* user_data, grpc_mdelem md); + grpc_error* (*on_header)(void* user_data, grpc_mdelem md); void* on_header_user_data; grpc_error* last_error; diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.cc b/src/core/ext/transport/chttp2/transport/hpack_table.cc index 68d3ec49fda..be03110edcf 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_table.cc @@ -44,19 +44,34 @@ void grpc_chttp2_hptbl_destroy(grpc_chttp2_hptbl* tbl) { tbl->ents = nullptr; } -grpc_mdelem grpc_chttp2_hptbl_lookup_dynamic_index(const grpc_chttp2_hptbl* tbl, - uint32_t tbl_index) { +template +static grpc_mdelem lookup_dynamic_index(const grpc_chttp2_hptbl* tbl, + uint32_t tbl_index) { /* Not static - find the value in the list of valid entries */ tbl_index -= (GRPC_CHTTP2_LAST_STATIC_ENTRY + 1); if (tbl_index < tbl->num_ents) { uint32_t offset = (tbl->num_ents - 1u - tbl_index + tbl->first_ent) % tbl->cap_entries; - return tbl->ents[offset]; + grpc_mdelem md = tbl->ents[offset]; + if (take_ref) { + GRPC_MDELEM_REF(md); + } + return md; } /* Invalid entry: return error */ return GRPC_MDNULL; } +grpc_mdelem grpc_chttp2_hptbl_lookup_dynamic_index(const grpc_chttp2_hptbl* tbl, + uint32_t tbl_index) { + return lookup_dynamic_index(tbl, tbl_index); +} + +grpc_mdelem grpc_chttp2_hptbl_lookup_ref_dynamic_index( + const grpc_chttp2_hptbl* tbl, uint32_t tbl_index) { + return lookup_dynamic_index(tbl, tbl_index); +} + /* Evict one element from the table */ static void evict1(grpc_chttp2_hptbl* tbl) { grpc_mdelem first_ent = tbl->ents[tbl->first_ent]; diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.h b/src/core/ext/transport/chttp2/transport/hpack_table.h index a1aa77f5446..5a6c739f07b 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.h +++ b/src/core/ext/transport/chttp2/transport/hpack_table.h @@ -95,6 +95,9 @@ grpc_error* grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl* tbl, /* lookup a table entry based on its hpack index */ grpc_mdelem grpc_chttp2_hptbl_lookup_dynamic_index(const grpc_chttp2_hptbl* tbl, uint32_t tbl_index); +grpc_mdelem grpc_chttp2_hptbl_lookup_ref_dynamic_index( + const grpc_chttp2_hptbl* tbl, uint32_t tbl_index); +template inline grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl* tbl, uint32_t index) { /* Static table comes first, just return an entry from it. @@ -103,9 +106,15 @@ inline grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl* tbl, must follow the hpack standard. If that changes, we *must* not rely on reading the core static metadata table here; at that point we'd need our own singleton static metadata in the correct order. */ - return index <= GRPC_CHTTP2_LAST_STATIC_ENTRY - ? grpc_static_mdelem_manifested()[index - 1] - : grpc_chttp2_hptbl_lookup_dynamic_index(tbl, index); + if (index <= GRPC_CHTTP2_LAST_STATIC_ENTRY) { + return grpc_static_mdelem_manifested()[index - 1]; + } else { + if (take_ref) { + return grpc_chttp2_hptbl_lookup_ref_dynamic_index(tbl, index); + } else { + return grpc_chttp2_hptbl_lookup_dynamic_index(tbl, index); + } + } } /* add a table entry to the index */ grpc_error* grpc_chttp2_hptbl_add(grpc_chttp2_hptbl* tbl, diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index 2a2a8206cb6..a39f6e83db7 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -318,7 +318,10 @@ static grpc_error* skip_parser(void* parser, grpc_chttp2_transport* t, return GRPC_ERROR_NONE; } -static void skip_header(void* tp, grpc_mdelem md) { GRPC_MDELEM_UNREF(md); } +static grpc_error* skip_header(void* tp, grpc_mdelem md) { + GRPC_MDELEM_UNREF(md); + return GRPC_ERROR_NONE; +} static grpc_error* init_skip_frame_parser(grpc_chttp2_transport* t, int is_header) { @@ -419,7 +422,7 @@ static bool is_nonzero_status(grpc_mdelem md) { !md_cmp(md, GRPC_MDELEM_GRPC_STATUS_0, GRPC_MDSTR_GRPC_STATUS); } -static void on_initial_header(void* tp, grpc_mdelem md) { +static grpc_error* on_initial_header(void* tp, grpc_mdelem md) { GPR_TIMER_SCOPE("on_initial_header", 0); grpc_chttp2_transport* t = static_cast(tp); @@ -465,7 +468,7 @@ static void on_initial_header(void* tp, grpc_mdelem md) { &s->metadata_buffer[0], grpc_core::ExecCtx::Get()->Now() + timeout); } GRPC_MDELEM_UNREF(md); - return; + return GRPC_ERROR_NONE; } const size_t new_size = s->metadata_buffer[0].size + GRPC_MDELEM_LENGTH(md); @@ -496,9 +499,10 @@ static void on_initial_header(void* tp, grpc_mdelem md) { GRPC_MDELEM_UNREF(md); } } + return GRPC_ERROR_NONE; } -static void on_trailing_header(void* tp, grpc_mdelem md) { +static grpc_error* on_trailing_header(void* tp, grpc_mdelem md) { GPR_TIMER_SCOPE("on_trailing_header", 0); grpc_chttp2_transport* t = static_cast(tp); @@ -547,6 +551,7 @@ static void on_trailing_header(void* tp, grpc_mdelem md) { GRPC_MDELEM_UNREF(md); } } + return GRPC_ERROR_NONE; } static grpc_error* init_header_frame_parser(grpc_chttp2_transport* t, diff --git a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc index a8eec1eefd6..9c6ae5da7bb 100644 --- a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc +++ b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc @@ -30,7 +30,10 @@ bool squelch = true; bool leak_check = true; -static void onhdr(void* ud, grpc_mdelem md) { GRPC_MDELEM_UNREF(md); } +static grpc_error* onhdr(void* ud, grpc_mdelem md) { + GRPC_MDELEM_UNREF(md); + return GRPC_ERROR_NONE; +} static void dont_log(gpr_log_func_args* args) {} extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { diff --git a/test/core/transport/chttp2/hpack_parser_test.cc b/test/core/transport/chttp2/hpack_parser_test.cc index 8be7dc17ed1..4782d484d1b 100644 --- a/test/core/transport/chttp2/hpack_parser_test.cc +++ b/test/core/transport/chttp2/hpack_parser_test.cc @@ -34,7 +34,7 @@ typedef struct { va_list args; } test_checker; -static void onhdr(void* ud, grpc_mdelem md) { +static grpc_error* onhdr(void* ud, grpc_mdelem md) { const char *ekey, *evalue; test_checker* chk = static_cast(ud); ekey = va_arg(chk->args, char*); @@ -44,6 +44,7 @@ static void onhdr(void* ud, grpc_mdelem md) { GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDKEY(md), ekey) == 0); GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDVALUE(md), evalue) == 0); GRPC_MDELEM_UNREF(md); + return GRPC_ERROR_NONE; } static void test_vector(grpc_chttp2_hpack_parser* parser, diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index 4950e7f7768..86d5d2de14c 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -450,11 +450,12 @@ static void BM_HpackParserInitDestroy(benchmark::State& state) { } BENCHMARK(BM_HpackParserInitDestroy); -static void UnrefHeader(void* user_data, grpc_mdelem md) { +static grpc_error* UnrefHeader(void* user_data, grpc_mdelem md) { GRPC_MDELEM_UNREF(md); + return GRPC_ERROR_NONE; } -template +template static void BM_HpackParserParseHeader(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; @@ -781,7 +782,7 @@ class RepresentativeServerTrailingMetadata { static void free_timeout(void* p) { gpr_free(p); } // Benchmark the current on_initial_header implementation -static void OnInitialHeader(void* user_data, grpc_mdelem md) { +static grpc_error* OnInitialHeader(void* user_data, grpc_mdelem md) { // Setup for benchmark. This will bloat the absolute values of this benchmark grpc_chttp2_incoming_metadata_buffer buffer( static_cast(user_data)); @@ -827,10 +828,11 @@ static void OnInitialHeader(void* user_data, grpc_mdelem md) { GPR_ASSERT(0); } } + return GRPC_ERROR_NONE; } // Benchmark timeout handling -static void OnHeaderTimeout(void* user_data, grpc_mdelem md) { +static grpc_error* OnHeaderTimeout(void* user_data, grpc_mdelem md) { if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_TIMEOUT)) { grpc_millis* cached_timeout = static_cast(grpc_mdelem_get_user_data(md, free_timeout)); @@ -858,6 +860,7 @@ static void OnHeaderTimeout(void* user_data, grpc_mdelem md) { } else { GPR_ASSERT(0); } + return GRPC_ERROR_NONE; } // Send the same deadline repeatedly From 96c11d153ff2247293bef1896aa5cc9496335950 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 28 Aug 2019 13:35:40 -0700 Subject: [PATCH 1389/1555] Revert "Revert #19704 and #20060" --- bazel/grpc_build_system.bzl | 11 +- gRPC-ProtoRPC.podspec | 30 +- gRPC-RxLibrary.podspec | 17 + gRPC.podspec | 116 ++- src/compiler/objective_c_generator.cc | 95 +- src/compiler/objective_c_generator.h | 14 +- src/compiler/objective_c_plugin.cc | 60 +- src/objective-c/BUILD | 246 +++-- .../GRPCClient/GRPCCall+ChannelArg.h | 2 +- .../GRPCClient/GRPCCall+ChannelArg.m | 4 +- .../GRPCClient/GRPCCall+ChannelCredentials.h | 2 +- .../GRPCClient/GRPCCall+ChannelCredentials.m | 2 +- src/objective-c/GRPCClient/GRPCCall+Cronet.h | 13 +- src/objective-c/GRPCClient/GRPCCall+Cronet.m | 4 +- src/objective-c/GRPCClient/GRPCCall+GID.h | 2 +- src/objective-c/GRPCClient/GRPCCall+OAuth2.h | 4 +- src/objective-c/GRPCClient/GRPCCall+Tests.h | 2 +- src/objective-c/GRPCClient/GRPCCall+Tests.m | 2 +- src/objective-c/GRPCClient/GRPCCall.h | 240 +---- src/objective-c/GRPCClient/GRPCCall.m | 875 +++--------------- src/objective-c/GRPCClient/GRPCCallLegacy.h | 136 +++ src/objective-c/GRPCClient/GRPCCallLegacy.m | 677 ++++++++++++++ src/objective-c/GRPCClient/GRPCCallOptions.h | 82 +- src/objective-c/GRPCClient/GRPCCallOptions.m | 27 +- src/objective-c/GRPCClient/GRPCDispatchable.h | 30 + src/objective-c/GRPCClient/GRPCInterceptor.h | 32 +- src/objective-c/GRPCClient/GRPCInterceptor.m | 265 ++++-- src/objective-c/GRPCClient/GRPCTransport.h | 82 ++ src/objective-c/GRPCClient/GRPCTransport.m | 142 +++ src/objective-c/GRPCClient/GRPCTypes.h | 187 ++++ .../internal_testing/GRPCCall+InternalTests.m | 2 +- .../private/{ => GRPCCore}/ChannelArgsUtil.h | 0 .../private/{ => GRPCCore}/ChannelArgsUtil.m | 0 .../private/{ => GRPCCore}/GRPCCall+V2API.h | 6 - .../private/{ => GRPCCore}/GRPCCallInternal.h | 14 +- .../private/{ => GRPCCore}/GRPCCallInternal.m | 140 +-- .../private/{ => GRPCCore}/GRPCChannel.h | 0 .../private/{ => GRPCCore}/GRPCChannel.m | 72 +- .../{ => GRPCCore}/GRPCChannelFactory.h | 0 .../{ => GRPCCore}/GRPCChannelPool+Test.h | 0 .../private/{ => GRPCCore}/GRPCChannelPool.h | 2 - .../private/{ => GRPCCore}/GRPCChannelPool.m | 5 +- .../{ => GRPCCore}/GRPCCompletionQueue.h | 0 .../{ => GRPCCore}/GRPCCompletionQueue.m | 0 .../GRPCCoreCronet/GRPCCoreCronetFactory.h | 32 + .../GRPCCoreCronet/GRPCCoreCronetFactory.m | 54 ++ .../GRPCCronetChannelFactory.h | 2 +- .../GRPCCronetChannelFactory.m | 24 +- .../private/GRPCCore/GRPCCoreFactory.h | 45 + .../private/GRPCCore/GRPCCoreFactory.m | 90 ++ .../private/{ => GRPCCore}/GRPCHost.h | 0 .../private/{ => GRPCCore}/GRPCHost.m | 35 +- .../GRPCInsecureChannelFactory.h | 0 .../GRPCInsecureChannelFactory.m | 0 .../private/{ => GRPCCore}/GRPCOpBatchLog.h | 0 .../private/{ => GRPCCore}/GRPCOpBatchLog.m | 0 .../GRPCReachabilityFlagNames.xmacro.h | 0 .../{ => GRPCCore}/GRPCRequestHeaders.h | 2 +- .../{ => GRPCCore}/GRPCRequestHeaders.m | 0 .../{ => GRPCCore}/GRPCSecureChannelFactory.h | 0 .../{ => GRPCCore}/GRPCSecureChannelFactory.m | 0 .../private/{ => GRPCCore}/GRPCWrappedCall.h | 0 .../private/{ => GRPCCore}/GRPCWrappedCall.m | 0 .../private/{ => GRPCCore}/NSData+GRPC.h | 0 .../private/{ => GRPCCore}/NSData+GRPC.m | 0 .../{ => GRPCCore}/NSDictionary+GRPC.h | 0 .../{ => GRPCCore}/NSDictionary+GRPC.m | 0 .../private/{ => GRPCCore}/NSError+GRPC.h | 0 .../private/{ => GRPCCore}/NSError+GRPC.m | 3 +- .../private/GRPCTransport+Private.h | 65 ++ .../private/GRPCTransport+Private.m | 131 +++ .../GRPCClient/{private => }/version.h | 0 src/objective-c/ProtoRPC/ProtoRPC.h | 38 +- src/objective-c/ProtoRPC/ProtoRPC.m | 91 -- src/objective-c/ProtoRPC/ProtoRPCLegacy.h | 67 ++ src/objective-c/ProtoRPC/ProtoRPCLegacy.m | 121 +++ src/objective-c/ProtoRPC/ProtoService.h | 29 +- src/objective-c/ProtoRPC/ProtoService.m | 42 +- src/objective-c/ProtoRPC/ProtoServiceLegacy.h | 23 + src/objective-c/ProtoRPC/ProtoServiceLegacy.m | 71 ++ .../tvOS-sample/tvOS-sample/ViewController.m | 2 + .../WatchKit-Extension/InterfaceController.m | 2 + src/objective-c/tests/BUILD | 8 - src/objective-c/tests/ConfigureCronet.h | 4 - src/objective-c/tests/ConfigureCronet.m | 4 - .../InteropTestsRemoteWithCronet.m | 12 +- .../tests/InteropTests/InteropTests.h | 13 +- .../tests/InteropTests/InteropTests.m | 268 +++--- .../InteropTests/InteropTestsLocalCleartext.m | 5 +- .../tests/InteropTests/InteropTestsLocalSSL.m | 5 +- .../InteropTestsMultipleChannels.m | 3 +- .../tests/InteropTests/InteropTestsRemote.m | 6 - src/objective-c/tests/Podfile | 24 +- .../tests/Tests.xcodeproj/project.pbxproj | 29 +- .../xcschemes/InteropTests.xcscheme | 8 +- .../tests/UnitTests/ChannelPoolTest.m | 6 +- .../tests/UnitTests/ChannelTests.m | 10 +- .../tests/UnitTests/NSErrorUnitTests.m | 2 +- templates/gRPC-ProtoRPC.podspec.template | 30 +- templates/gRPC-RxLibrary.podspec.template | 17 + templates/gRPC.podspec.template | 116 ++- .../{private => }/version.h.template | 0 102 files changed, 3255 insertions(+), 1926 deletions(-) create mode 100644 src/objective-c/GRPCClient/GRPCCallLegacy.h create mode 100644 src/objective-c/GRPCClient/GRPCCallLegacy.m create mode 100644 src/objective-c/GRPCClient/GRPCDispatchable.h create mode 100644 src/objective-c/GRPCClient/GRPCTransport.h create mode 100644 src/objective-c/GRPCClient/GRPCTransport.m create mode 100644 src/objective-c/GRPCClient/GRPCTypes.h rename src/objective-c/GRPCClient/private/{ => GRPCCore}/ChannelArgsUtil.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/ChannelArgsUtil.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCCall+V2API.h (79%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCCallInternal.h (70%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCCallInternal.m (69%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCChannel.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCChannel.m (78%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCChannelFactory.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCChannelPool+Test.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCChannelPool.h (98%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCChannelPool.m (98%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCCompletionQueue.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCCompletionQueue.m (100%) create mode 100644 src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h create mode 100644 src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m rename src/objective-c/GRPCClient/private/{ => GRPCCore/GRPCCoreCronet}/GRPCCronetChannelFactory.h (96%) rename src/objective-c/GRPCClient/private/{ => GRPCCore/GRPCCoreCronet}/GRPCCronetChannelFactory.m (76%) create mode 100644 src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h create mode 100644 src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCHost.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCHost.m (82%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCInsecureChannelFactory.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCInsecureChannelFactory.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCOpBatchLog.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCOpBatchLog.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCReachabilityFlagNames.xmacro.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCRequestHeaders.h (95%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCRequestHeaders.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCSecureChannelFactory.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCSecureChannelFactory.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCWrappedCall.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/GRPCWrappedCall.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/NSData+GRPC.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/NSData+GRPC.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/NSDictionary+GRPC.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/NSDictionary+GRPC.m (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/NSError+GRPC.h (100%) rename src/objective-c/GRPCClient/private/{ => GRPCCore}/NSError+GRPC.m (96%) create mode 100644 src/objective-c/GRPCClient/private/GRPCTransport+Private.h create mode 100644 src/objective-c/GRPCClient/private/GRPCTransport+Private.m rename src/objective-c/GRPCClient/{private => }/version.h (100%) create mode 100644 src/objective-c/ProtoRPC/ProtoRPCLegacy.h create mode 100644 src/objective-c/ProtoRPC/ProtoRPCLegacy.m create mode 100644 src/objective-c/ProtoRPC/ProtoServiceLegacy.h create mode 100644 src/objective-c/ProtoRPC/ProtoServiceLegacy.m rename templates/src/objective-c/GRPCClient/{private => }/version.h.template (100%) diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index f386b87b583..23f90d0dc80 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -24,7 +24,6 @@ # load("//bazel:cc_grpc_library.bzl", "cc_grpc_library") -load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle") load("@upb//bazel:upb_proto_library.bzl", "upb_proto_library") load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test") @@ -239,19 +238,13 @@ def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], da ) def grpc_generate_one_off_targets(): - apple_resource_bundle( - # The choice of name is signicant here, since it determines the bundle name. - name = "gRPCCertificates", - resources = ["etc/roots.pem"], - ) - # In open-source, grpc_objc* libraries depend directly on //:grpc native.alias( name = "grpc_objc", actual = "//:grpc", ) -def grpc_objc_use_cronet_config(): +def grpc_generate_objc_one_off_targets(): pass def grpc_sh_test(name, srcs, args = [], data = []): @@ -296,7 +289,7 @@ def grpc_package(name, visibility = "private", features = []): def grpc_objc_library( name, - srcs, + srcs = [], hdrs = [], textual_hdrs = [], data = [], diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 57dac5a10e5..4c5ebb36562 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -42,22 +42,40 @@ Pod::Spec.new do |s| s.module_name = name s.header_dir = name - src_dir = 'src/objective-c/ProtoRPC' + s.default_subspec = 'Main', 'Legacy', 'Legacy-Header' - s.default_subspec = 'Main' + s.subspec 'Legacy-Header' do |ss| + ss.header_mappings_dir = "src/objective-c/ProtoRPC" + ss.public_header_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.h" + ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.h" + end s.subspec 'Main' do |ss| - ss.header_mappings_dir = "#{src_dir}" - ss.dependency 'gRPC', version + ss.header_mappings_dir = "src/objective-c/ProtoRPC" + ss.dependency "#{s.name}/Legacy-Header", version + ss.dependency 'gRPC/Interface', version + ss.dependency 'Protobuf', '~> 3.0' + + ss.source_files = "src/objective-c/ProtoRPC/ProtoMethod.{h,m}", + "src/objective-c/ProtoRPC/ProtoRPC.{h,m}", + "src/objective-c/ProtoRPC/ProtoService.{h,m}" + end + + s.subspec 'Legacy' do |ss| + ss.header_mappings_dir = "src/objective-c/ProtoRPC" + ss.dependency "#{s.name}/Main", version + ss.dependency "#{s.name}/Legacy-Header", version + ss.dependency 'gRPC/GRPCCore', version ss.dependency 'gRPC-RxLibrary', version ss.dependency 'Protobuf', '~> 3.0' - ss.source_files = "#{src_dir}/*.{h,m}" + ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.m", + "src/objective-c/ProtoRPC/ProtoServiceLegacy.m" end # CFStream is now default. Leaving this subspec only for compatibility purpose. s.subspec 'CFStream' do |ss| - ss.dependency "#{s.name}/Main", version + ss.dependency "#{s.name}/Legacy", version end s.pod_target_xcconfig = { diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 9666c3c1b98..2e412cf67d6 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -42,6 +42,23 @@ Pod::Spec.new do |s| s.module_name = name s.header_dir = name + s.default_subspec = 'Interface', 'Implementation' + + src_dir = 'src/objective-c/RxLibrary' + s.subspec 'Interface' do |ss| + ss.header_mappings_dir = "#{src_dir}" + ss.source_files = "#{src_dir}/*.h" + ss.public_header_files = "#{src_dir}/*.h" + end + + s.subspec 'Implementation' do |ss| + ss.header_mappings_dir = "#{src_dir}" + ss.source_files = "#{src_dir}/*.m", "#{src_dir}/**/*.{h,m}" + ss.private_header_files = "#{src_dir}/**/*.h" + + ss.dependency "#{s.name}/Interface" + end + src_dir = 'src/objective-c/RxLibrary' s.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}" s.private_header_files = "#{src_dir}/private/*.h" diff --git a/gRPC.podspec b/gRPC.podspec index 09baf1e3b4b..e18adcd276e 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -41,13 +41,7 @@ Pod::Spec.new do |s| s.module_name = name s.header_dir = name - src_dir = 'src/objective-c/GRPCClient' - - s.dependency 'gRPC-RxLibrary', version - s.default_subspec = 'Main' - - # Certificates, to be able to establish TLS connections: - s.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } + s.default_subspec = 'Interface', 'GRPCCore', 'Interface-Legacy' s.pod_target_xcconfig = { # This is needed by all pods that depend on gRPC-RxLibrary: @@ -55,29 +49,103 @@ Pod::Spec.new do |s| 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO', } - s.subspec 'Main' do |ss| - ss.header_mappings_dir = "#{src_dir}" + s.subspec 'Interface-Legacy' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' - ss.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}" - ss.exclude_files = "#{src_dir}/GRPCCall+GID.{h,m}" - ss.private_header_files = "#{src_dir}/private/*.h", "#{src_dir}/internal/*.h" + ss.public_header_files = "GRPCClient/GRPCCall+ChannelArg.h", + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", + "src/objective-c/GRPCClient/GRPCCallLegacy.h", + "src/objective-c/GRPCClient/GRPCTypes.h" + ss.source_files = "GRPCClient/GRPCCall+ChannelArg.h", + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", + "src/objective-c/GRPCClient/GRPCCallLegacy.h", + "src/objective-c/GRPCClient/GRPCTypes.h" + ss.dependency "gRPC-RxLibrary/Interface", version + end + + s.subspec 'Interface' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' + + ss.public_header_files = 'src/objective-c/GRPCClient/GRPCCall.h', + 'src/objective-c/GRPCClient/GRPCCall+Interceptor.h', + 'src/objective-c/GRPCClient/GRPCCallOptions.h', + 'src/objective-c/GRPCClient/GRPCInterceptor.h', + 'src/objective-c/GRPCClient/GRPCTransport.h', + 'src/objective-c/GRPCClient/GRPCDispatchable.h', + 'src/objective-c/GRPCClient/version.h' + + ss.source_files = 'src/objective-c/GRPCClient/GRPCCall.h', + 'src/objective-c/GRPCClient/GRPCCall.m', + 'src/objective-c/GRPCClient/GRPCCall+Interceptor.h', + 'src/objective-c/GRPCClient/GRPCCall+Interceptor.m', + 'src/objective-c/GRPCClient/GRPCCallOptions.h', + 'src/objective-c/GRPCClient/GRPCCallOptions.m', + 'src/objective-c/GRPCClient/GRPCDispatchable.h', + 'src/objective-c/GRPCClient/GRPCInterceptor.h', + 'src/objective-c/GRPCClient/GRPCInterceptor.m', + 'src/objective-c/GRPCClient/GRPCTransport.h', + 'src/objective-c/GRPCClient/GRPCTransport.m', + 'src/objective-c/GRPCClient/internal/*.h', + 'src/objective-c/GRPCClient/private/GRPCTransport+Private.h', + 'src/objective-c/GRPCClient/private/GRPCTransport+Private.m', + 'src/objective-c/GRPCClient/version.h' + + ss.dependency "#{s.name}/Interface-Legacy", version + end + + s.subspec 'GRPCCore' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' + + ss.public_header_files = 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', + 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', + 'src/objective-c/GRPCClient/GRPCCall+Tests.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', + 'src/objective-c/GRPCClient/internal_testing/*.h' + ss.private_header_files = 'src/objective-c/GRPCClient/private/GRPCCore/*.h' + ss.source_files = 'src/objective-c/GRPCClient/internal_testing/*.{h,m}', + 'src/objective-c/GRPCClient/private/GRPCCore/*.{h,m}', + 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.m', + 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.m', + 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', + 'src/objective-c/GRPCClient/GRPCCall+OAuth2.m', + 'src/objective-c/GRPCClient/GRPCCall+Tests.h', + 'src/objective-c/GRPCClient/GRPCCall+Tests.m', + 'src/objective-c/GRPCClient/GRPCCallLegacy.m' + + # Certificates, to be able to establish TLS connections: + ss.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } + + ss.dependency "#{s.name}/Interface-Legacy", version + ss.dependency "#{s.name}/Interface", version ss.dependency 'gRPC-Core', version + ss.dependency 'gRPC-RxLibrary', version + end + + s.subspec 'GRPCCoreCronet' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' + + ss.source_files = 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.m', + 'src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/*.{h,m}' + ss.dependency "#{s.name}/GRPCCore", version + ss.dependency 'gRPC-Core/Cronet-Implementation', version + ss.dependency 'CronetFramework' end # CFStream is now default. Leaving this subspec only for compatibility purpose. s.subspec 'CFStream' do |ss| - ss.dependency "#{s.name}/Main", version - end - - s.subspec 'GID' do |ss| - ss.ios.deployment_target = '7.0' - - ss.header_mappings_dir = "#{src_dir}" - - ss.source_files = "#{src_dir}/GRPCCall+GID.{h,m}" - - ss.dependency "#{s.name}/Main", version - ss.dependency 'Google/SignIn' + ss.dependency "#{s.name}/GRPCCore", version end end diff --git a/src/compiler/objective_c_generator.cc b/src/compiler/objective_c_generator.cc index 24845ecdb06..ed262308aba 100644 --- a/src/compiler/objective_c_generator.cc +++ b/src/compiler/objective_c_generator.cc @@ -238,19 +238,21 @@ void PrintV2Implementation(Printer* printer, const MethodDescriptor* method, } void PrintMethodImplementations(Printer* printer, - const MethodDescriptor* method) { + const MethodDescriptor* method, + const Parameters& generator_params) { map< ::grpc::string, ::grpc::string> vars = GetMethodVars(method); PrintProtoRpcDeclarationAsPragma(printer, method, vars); - // TODO(jcanizales): Print documentation from the method. - printer->Print("// Deprecated methods.\n"); - PrintSimpleSignature(printer, method, vars); - PrintSimpleImplementation(printer, method, vars); + if (!generator_params.no_v1_compatibility) { + // TODO(jcanizales): Print documentation from the method. + PrintSimpleSignature(printer, method, vars); + PrintSimpleImplementation(printer, method, vars); - printer->Print("// Returns a not-yet-started RPC object.\n"); - PrintAdvancedSignature(printer, method, vars); - PrintAdvancedImplementation(printer, method, vars); + printer->Print("// Returns a not-yet-started RPC object.\n"); + PrintAdvancedSignature(printer, method, vars); + PrintAdvancedImplementation(printer, method, vars); + } PrintV2Signature(printer, method, vars); PrintV2Implementation(printer, method, vars); @@ -276,9 +278,12 @@ void PrintMethodImplementations(Printer* printer, return output; } -::grpc::string GetProtocol(const ServiceDescriptor* service) { +::grpc::string GetProtocol(const ServiceDescriptor* service, + const Parameters& generator_params) { ::grpc::string output; + if (generator_params.no_v1_compatibility) return output; + // Scope the output stream so it closes and finalizes output to the string. grpc::protobuf::io::StringOutputStream output_stream(&output); Printer printer(&output_stream, '$'); @@ -321,7 +326,8 @@ void PrintMethodImplementations(Printer* printer, return output; } -::grpc::string GetInterface(const ServiceDescriptor* service) { +::grpc::string GetInterface(const ServiceDescriptor* service, + const Parameters& generator_params) { ::grpc::string output; // Scope the output stream so it closes and finalizes output to the string. @@ -338,7 +344,11 @@ void PrintMethodImplementations(Printer* printer, " */\n"); printer.Print(vars, "@interface $service_class$ :" - " GRPCProtoService<$service_class$, $service_class$2>\n"); + " GRPCProtoService<$service_class$2"); + if (!generator_params.no_v1_compatibility) { + printer.Print(vars, ", $service_class$"); + } + printer.Print(">\n"); printer.Print( "- (instancetype)initWithHost:(NSString *)host " "callOptions:(GRPCCallOptions " @@ -347,17 +357,20 @@ void PrintMethodImplementations(Printer* printer, printer.Print( "+ (instancetype)serviceWithHost:(NSString *)host " "callOptions:(GRPCCallOptions *_Nullable)callOptions;\n"); - printer.Print( - "// The following methods belong to a set of old APIs that have been " - "deprecated.\n"); - printer.Print("- (instancetype)initWithHost:(NSString *)host;\n"); - printer.Print("+ (instancetype)serviceWithHost:(NSString *)host;\n"); + if (!generator_params.no_v1_compatibility) { + printer.Print( + "// The following methods belong to a set of old APIs that have been " + "deprecated.\n"); + printer.Print("- (instancetype)initWithHost:(NSString *)host;\n"); + printer.Print("+ (instancetype)serviceWithHost:(NSString *)host;\n"); + } printer.Print("@end\n"); return output; } -::grpc::string GetSource(const ServiceDescriptor* service) { +::grpc::string GetSource(const ServiceDescriptor* service, + const Parameters& generator_params) { ::grpc::string output; { // Scope the output stream so it closes and finalizes output to the string. @@ -381,22 +394,28 @@ void PrintMethodImplementations(Printer* printer, " packageName:@\"$package$\"\n" " serviceName:@\"$service_name$\"\n" " callOptions:callOptions];\n" - "}\n\n" - "- (instancetype)initWithHost:(NSString *)host {\n" - " return [super initWithHost:host\n" - " packageName:@\"$package$\"\n" - " serviceName:@\"$service_name$\"];\n" - "}\n\n" - "#pragma clang diagnostic pop\n\n"); + "}\n\n"); + if (!generator_params.no_v1_compatibility) { + printer.Print(vars, + "- (instancetype)initWithHost:(NSString *)host {\n" + " return [super initWithHost:host\n" + " packageName:@\"$package$\"\n" + " serviceName:@\"$service_name$\"];\n" + "}\n\n"); + } + printer.Print("#pragma clang diagnostic pop\n\n"); + if (!generator_params.no_v1_compatibility) { + printer.Print( + "// Override superclass initializer to disallow different" + " package and service names.\n" + "- (instancetype)initWithHost:(NSString *)host\n" + " packageName:(NSString *)packageName\n" + " serviceName:(NSString *)serviceName {\n" + " return [self initWithHost:host];\n" + "}\n\n"); + } printer.Print( - "// Override superclass initializer to disallow different" - " package and service names.\n" - "- (instancetype)initWithHost:(NSString *)host\n" - " packageName:(NSString *)packageName\n" - " serviceName:(NSString *)serviceName {\n" - " return [self initWithHost:host];\n" - "}\n\n" "- (instancetype)initWithHost:(NSString *)host\n" " packageName:(NSString *)packageName\n" " serviceName:(NSString *)serviceName\n" @@ -404,11 +423,14 @@ void PrintMethodImplementations(Printer* printer, " return [self initWithHost:host callOptions:callOptions];\n" "}\n\n"); + printer.Print("#pragma mark - Class Methods\n\n"); + if (!generator_params.no_v1_compatibility) { + printer.Print( + "+ (instancetype)serviceWithHost:(NSString *)host {\n" + " return [[self alloc] initWithHost:host];\n" + "}\n\n"); + } printer.Print( - "#pragma mark - Class Methods\n\n" - "+ (instancetype)serviceWithHost:(NSString *)host {\n" - " return [[self alloc] initWithHost:host];\n" - "}\n\n" "+ (instancetype)serviceWithHost:(NSString *)host " "callOptions:(GRPCCallOptions *_Nullable)callOptions {\n" " return [[self alloc] initWithHost:host callOptions:callOptions];\n" @@ -417,7 +439,8 @@ void PrintMethodImplementations(Printer* printer, printer.Print("#pragma mark - Method Implementations\n\n"); for (int i = 0; i < service->method_count(); i++) { - PrintMethodImplementations(&printer, service->method(i)); + PrintMethodImplementations(&printer, service->method(i), + generator_params); } printer.Print("@end\n"); diff --git a/src/compiler/objective_c_generator.h b/src/compiler/objective_c_generator.h index c171e5bf772..518962fceee 100644 --- a/src/compiler/objective_c_generator.h +++ b/src/compiler/objective_c_generator.h @@ -23,6 +23,11 @@ namespace grpc_objective_c_generator { +struct Parameters { + // Do not generate V1 interface and implementation + bool no_v1_compatibility; +}; + using ::grpc::protobuf::FileDescriptor; using ::grpc::protobuf::FileDescriptor; using ::grpc::protobuf::ServiceDescriptor; @@ -34,7 +39,8 @@ string GetAllMessageClasses(const FileDescriptor* file); // Returns the content to be included defining the @protocol segment at the // insertion point of the generated implementation file. This interface is // legacy and for backwards compatibility. -string GetProtocol(const ServiceDescriptor* service); +string GetProtocol(const ServiceDescriptor* service, + const Parameters& generator_params); // Returns the content to be included defining the @protocol segment at the // insertion point of the generated implementation file. @@ -42,11 +48,13 @@ string GetV2Protocol(const ServiceDescriptor* service); // Returns the content to be included defining the @interface segment at the // insertion point of the generated implementation file. -string GetInterface(const ServiceDescriptor* service); +string GetInterface(const ServiceDescriptor* service, + const Parameters& generator_params); // Returns the content to be included in the "global_scope" insertion point of // the generated implementation file. -string GetSource(const ServiceDescriptor* service); +string GetSource(const ServiceDescriptor* service, + const Parameters& generator_params); } // namespace grpc_objective_c_generator diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index f398033f6db..a08064a08bd 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -111,6 +111,22 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string file_name = google::protobuf::compiler::objectivec::FilePath(file); + grpc_objective_c_generator::Parameters generator_params; + generator_params.no_v1_compatibility = false; + + if (!parameter.empty()) { + std::vector parameters_list = + grpc_generator::tokenize(parameter, ","); + for (auto parameter_string = parameters_list.begin(); + parameter_string != parameters_list.end(); parameter_string++) { + std::vector param = + grpc_generator::tokenize(*parameter_string, "="); + if (param[0] == "no_v1_compatibility") { + generator_params.no_v1_compatibility = true; + } + } + } + { // Generate .pbrpc.h @@ -121,18 +137,25 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { imports = FrameworkImport(file_name + ".pbobjc.h", framework); } - ::grpc::string system_imports = SystemImport("ProtoRPC/ProtoService.h") + - SystemImport("ProtoRPC/ProtoRPC.h") + - SystemImport("RxLibrary/GRXWriteable.h") + - SystemImport("RxLibrary/GRXWriter.h"); + ::grpc::string system_imports = + SystemImport("ProtoRPC/ProtoService.h") + + (generator_params.no_v1_compatibility + ? SystemImport("ProtoRPC/ProtoRPC.h") + : SystemImport("ProtoRPC/ProtoRPCLegacy.h")); + if (!generator_params.no_v1_compatibility) { + system_imports += SystemImport("RxLibrary/GRXWriteable.h") + + SystemImport("RxLibrary/GRXWriter.h"); + } ::grpc::string forward_declarations = - "@class GRPCProtoCall;\n" "@class GRPCUnaryProtoCall;\n" "@class GRPCStreamingProtoCall;\n" "@class GRPCCallOptions;\n" - "@protocol GRPCProtoResponseHandler;\n" - "\n"; + "@protocol GRPCProtoResponseHandler;\n"; + if (!generator_params.no_v1_compatibility) { + forward_declarations += "@class GRPCProtoCall;\n"; + } + forward_declarations += "\n"; ::grpc::string class_declarations = grpc_objective_c_generator::GetAllMessageClasses(file); @@ -152,13 +175,15 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string protocols; for (int i = 0; i < file->service_count(); i++) { const grpc::protobuf::ServiceDescriptor* service = file->service(i); - protocols += grpc_objective_c_generator::GetProtocol(service); + protocols += + grpc_objective_c_generator::GetProtocol(service, generator_params); } ::grpc::string interfaces; for (int i = 0; i < file->service_count(); i++) { const grpc::protobuf::ServiceDescriptor* service = file->service(i); - interfaces += grpc_objective_c_generator::GetInterface(service); + interfaces += + grpc_objective_c_generator::GetInterface(service, generator_params); } Write(context, file_name + ".pbrpc.h", @@ -178,14 +203,16 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string imports; if (framework.empty()) { imports = LocalImport(file_name + ".pbrpc.h") + - LocalImport(file_name + ".pbobjc.h") + - SystemImport("ProtoRPC/ProtoRPC.h") + - SystemImport("RxLibrary/GRXWriter+Immediate.h"); + LocalImport(file_name + ".pbobjc.h"); } else { imports = FrameworkImport(file_name + ".pbrpc.h", framework) + - FrameworkImport(file_name + ".pbobjc.h", framework) + - SystemImport("ProtoRPC/ProtoRPC.h") + - SystemImport("RxLibrary/GRXWriter+Immediate.h"); + FrameworkImport(file_name + ".pbobjc.h", framework); + } + imports += (generator_params.no_v1_compatibility + ? SystemImport("ProtoRPC/ProtoRPC.h") + : SystemImport("ProtoRPC/ProtoRPCLegacy.h")); + if (!generator_params.no_v1_compatibility) { + imports += SystemImport("RxLibrary/GRXWriter+Immediate.h"); } ::grpc::string class_imports; @@ -196,7 +223,8 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string definitions; for (int i = 0; i < file->service_count(); i++) { const grpc::protobuf::ServiceDescriptor* service = file->service(i); - definitions += grpc_objective_c_generator::GetSource(service); + definitions += + grpc_objective_c_generator::GetSource(service, generator_params); } Write(context, file_name + ".pbrpc.m", diff --git a/src/objective-c/BUILD b/src/objective-c/BUILD index 3a71086f0f6..5f53486d17e 100644 --- a/src/objective-c/BUILD +++ b/src/objective-c/BUILD @@ -18,24 +18,30 @@ licenses(["notice"]) # Apache v2 package(default_visibility = ["//visibility:public"]) -load("//bazel:grpc_build_system.bzl", "grpc_objc_library", "grpc_objc_use_cronet_config") +load("//bazel:grpc_build_system.bzl", "grpc_objc_library", "grpc_generate_objc_one_off_targets") exports_files(["LICENSE"]) -grpc_objc_use_cronet_config() +grpc_generate_objc_one_off_targets() + +grpc_objc_library( + name = "rx_library_headers", + hdrs = glob([ + "RxLibrary/*.h", + ]), + includes = ["."], +) grpc_objc_library( name = "rx_library", srcs = glob([ "RxLibrary/*.m", - "RxLibrary/transformations/*.m", - ]), - hdrs = glob([ - "RxLibrary/*.h", - "RxLibrary/transformations/*.h", ]), includes = ["."], - deps = [":rx_library_private"], + deps = [ + ":rx_library_headers", + ":rx_library_private", + ], ) grpc_objc_library( @@ -50,84 +56,196 @@ grpc_objc_library( ) grpc_objc_library( - name = "grpc_objc_client", - srcs = glob( - [ - "GRPCClient/*.m", - "GRPCClient/private/*.m", - ], - exclude = ["GRPCClient/GRPCCall+GID.m"], - ), - hdrs = glob( - [ - "GRPCClient/*.h", - "GRPCClient/internal/*.h", - ], - exclude = ["GRPCClient/GRPCCall+GID.h"], - ), - data = ["//:gRPCCertificates"], - includes = ["."], - textual_hdrs = glob([ - "GRPCClient/private/*.h", - ]), + name = "grpc_objc_interface_legacy", + hdrs = [ + "GRPCClient/GRPCCall+ChannelArg.h", + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", + "GRPCClient/GRPCCallLegacy.h", + "GRPCClient/GRPCTypes.h", + ], deps = [ + "rx_library_headers", + ], +) + +grpc_objc_library( + name = "grpc_objc_interface", + hdrs = [ + "GRPCClient/GRPCCall.h", + "GRPCClient/GRPCCall+Interceptor.h", + "GRPCClient/GRPCCallOptions.h", + "GRPCClient/GRPCInterceptor.h", + "GRPCClient/GRPCTransport.h", + "GRPCClient/GRPCDispatchable.h", + "GRPCClient/internal/GRPCCallOptions+Internal.h", + "GRPCClient/version.h", + ], + srcs = [ + "GRPCClient/GRPCCall.m", + "GRPCClient/GRPCCall+Interceptor.m", + "GRPCClient/GRPCCallOptions.m", + "GRPCClient/GRPCInterceptor.m", + "GRPCClient/GRPCTransport.m", + "GRPCClient/private/GRPCTransport+Private.m", + ], + includes = ["."], + textual_hdrs = [ + "GRPCClient/private/GRPCTransport+Private.h", + ], + deps = [ + ":grpc_objc_interface_legacy", + ], +) + +grpc_objc_library( + name = "grpc_objc_client_core", + hdrs = [ + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", + "GRPCClient/GRPCCall+ChannelArg.h", + ], + textual_hdrs = glob(["GRPCClient/private/GRPCCore/*.h"]), + srcs = [ + "GRPCClient/GRPCCall+ChannelArg.m", + "GRPCClient/GRPCCall+ChannelCredentials.m", + "GRPCClient/GRPCCall+Cronet.m", + "GRPCClient/GRPCCall+OAuth2.m", + "GRPCClient/GRPCCall+Tests.m", + "GRPCClient/GRPCCallLegacy.m", + ] + glob(["GRPCClient/private/GRPCCore/*.m"]), + data = [":gRPCCertificates"], + includes = ["."], + deps = [ + ":grpc_objc_interface", + ":grpc_objc_interface_legacy", ":rx_library", "//:grpc_objc", ], ) +alias( + name = "grpc_objc_client", + actual = "grpc_objc_client_core", +) + +grpc_objc_library( + name = "proto_objc_rpc_legacy_header", + hdrs = [ + "ProtoRPC/ProtoRPCLegacy.h", + ], + includes = ["."], +) + +grpc_objc_library( + name = "proto_objc_rpc_v2", + srcs = [ + "ProtoRPC/ProtoMethod.m", + "ProtoRPC/ProtoRPC.m", + "ProtoRPC/ProtoService.m", + ], + hdrs = [ + "ProtoRPC/ProtoMethod.h", + "ProtoRPC/ProtoRPC.h", + "ProtoRPC/ProtoService.h", + ], + includes = ["."], + defines = ["GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0"], + deps = [ + ":grpc_objc_interface", + ":proto_objc_rpc_legacy_header", + "@com_google_protobuf//:protobuf_objc", + ], +) + grpc_objc_library( name = "proto_objc_rpc", - srcs = glob( - ["ProtoRPC/*.m"], - ), - hdrs = glob( - ["ProtoRPC/*.h"], - ), - # Different from Cocoapods, do not import as if @com_google_protobuf//:protobuf_objc is a framework, - # use the real paths of @com_google_protobuf//:protobuf_objc instead - defines = ["GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0"], + srcs = [ + "ProtoRPC/ProtoRPCLegacy.m", + "ProtoRPC/ProtoServiceLegacy.m", + ], + hdrs = [ + "ProtoRPC/ProtoMethod.h", + "ProtoRPC/ProtoRPCLegacy.h", + "ProtoRPC/ProtoService.h", + ], deps = [ - ":grpc_objc_client", ":rx_library", + ":proto_objc_rpc_v2", + ":proto_objc_rpc_legacy_header", + ":grpc_objc_client_core", "@com_google_protobuf//:protobuf_objc", ], ) +load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle") + +apple_resource_bundle( + # The choice of name is signicant here, since it determines the bundle name. + name = "gRPCCertificates", + resources = ["//:etc/roots.pem"], +) + +# Internal target combining grpc_objc_client_core and proto_objc_rpc for testing grpc_objc_library( - name = "grpc_objc_client_internal_testing", - srcs = glob( - [ - "GRPCClient/*.m", - "GRPCClient/private/*.m", - "GRPCClient/internal_testing/*.m", - "ProtoRPC/*.m", - ], - exclude = ["GRPCClient/GRPCCall+GID.m"], - ), - hdrs = glob( - [ - "GRPCClient/*.h", - "GRPCClient/internal/*.h", - "GRPCClient/internal_testing/*.h", - "ProtoRPC/*.h", - ], - exclude = ["GRPCClient/GRPCCall+GID.h"], - ), + name = "grpc_objc_client_core_internal_testing", + hdrs = [ + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", + "GRPCClient/GRPCCall+ChannelArg.h", + "GRPCClient/internal_testing/GRPCCall+InternalTests.h", + ], + textual_hdrs = glob(["GRPCClient/private/GRPCCore/*.h"]), + srcs = [ + "GRPCClient/GRPCCall+ChannelArg.m", + "GRPCClient/GRPCCall+ChannelCredentials.m", + "GRPCClient/GRPCCall+Cronet.m", + "GRPCClient/GRPCCall+OAuth2.m", + "GRPCClient/GRPCCall+Tests.m", + "GRPCClient/GRPCCallLegacy.m", + "GRPCClient/internal_testing/GRPCCall+InternalTests.m", + ] + glob(["GRPCClient/private/GRPCCore/*.m"]), + data = [":gRPCCertificates"], includes = ["."], - data = ["//:gRPCCertificates"], defines = [ "GRPC_TEST_OBJC=1", - "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0", ], - textual_hdrs = glob( - [ - "GRPCClient/private/*.h", - ], - ), deps = [ + ":grpc_objc_interface", + ":grpc_objc_interface_legacy", ":rx_library", "//:grpc_objc", + ], +) + +grpc_objc_library( + name = "proto_objc_rpc_internal_testing", + srcs = [ + "ProtoRPC/ProtoRPCLegacy.m", + "ProtoRPC/ProtoServiceLegacy.m", + ], + hdrs = [ + "ProtoRPC/ProtoMethod.h", + "ProtoRPC/ProtoRPC.h", + "ProtoRPC/ProtoRPCLegacy.h", + "ProtoRPC/ProtoService.h", + ], + deps = [ + ":rx_library", + ":proto_objc_rpc_v2", + ":proto_objc_rpc_legacy_header", + ":grpc_objc_client_core_internal_testing", "@com_google_protobuf//:protobuf_objc", ], ) + +alias( + name = "grpc_objc_client_internal_testing", + actual = "proto_objc_rpc_internal_testing", +) diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h index 2ddd53a5c66..ff5a153a0f6 100644 --- a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h @@ -15,7 +15,7 @@ * limitations under the License. * */ -#import "GRPCCall.h" +#import "GRPCCallLegacy.h" #include diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m index ae60d6208e1..aae1b740c71 100644 --- a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m @@ -18,8 +18,8 @@ #import "GRPCCall+ChannelArg.h" -#import "private/GRPCChannelPool.h" -#import "private/GRPCHost.h" +#import "private/GRPCCore/GRPCChannelPool.h" +#import "private/GRPCCore/GRPCHost.h" #import diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h b/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h index 7d6f79b7655..c3d194bff94 100644 --- a/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h @@ -16,7 +16,7 @@ * */ -#import "GRPCCall.h" +#import "GRPCCallLegacy.h" // Deprecated interface. Please use GRPCCallOptions instead. @interface GRPCCall (ChannelCredentials) diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m b/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m index 2689ec2effb..aa97ca82bf8 100644 --- a/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m @@ -18,7 +18,7 @@ #import "GRPCCall+ChannelCredentials.h" -#import "private/GRPCHost.h" +#import "private/GRPCCore/GRPCHost.h" @implementation GRPCCall (ChannelCredentials) diff --git a/src/objective-c/GRPCClient/GRPCCall+Cronet.h b/src/objective-c/GRPCClient/GRPCCall+Cronet.h index 3059c6f1860..d107ada3672 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Cronet.h +++ b/src/objective-c/GRPCClient/GRPCCall+Cronet.h @@ -15,12 +15,16 @@ * limitations under the License. * */ -#ifdef GRPC_COMPILE_WITH_CRONET -#import -#import "GRPCCall.h" +#import "GRPCCallLegacy.h" +#import "GRPCTypes.h" -// Deprecated interface. Please use GRPCCallOptions instead. +typedef struct stream_engine stream_engine; + +// Transport id for Cronet transport +extern const GRPCTransportId gGRPCCoreCronetId; + +// Deprecated class. Please use the gGRPCCoreCronetId with GRPCCallOptions.transport instead. @interface GRPCCall (Cronet) + (void)useCronetWithEngine:(stream_engine*)engine; @@ -28,4 +32,3 @@ + (BOOL)isUsingCronet; @end -#endif diff --git a/src/objective-c/GRPCClient/GRPCCall+Cronet.m b/src/objective-c/GRPCClient/GRPCCall+Cronet.m index ba8d2c23db8..a732208e1f6 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Cronet.m +++ b/src/objective-c/GRPCClient/GRPCCall+Cronet.m @@ -18,7 +18,8 @@ #import "GRPCCall+Cronet.h" -#ifdef GRPC_COMPILE_WITH_CRONET +const GRPCTransportId gGRPCCoreCronetId = "io.grpc.transport.core.cronet"; + static BOOL useCronet = NO; static stream_engine *globalCronetEngine; @@ -38,4 +39,3 @@ static stream_engine *globalCronetEngine; } @end -#endif diff --git a/src/objective-c/GRPCClient/GRPCCall+GID.h b/src/objective-c/GRPCClient/GRPCCall+GID.h index 8293e92ebe9..80e34ea98da 100644 --- a/src/objective-c/GRPCClient/GRPCCall+GID.h +++ b/src/objective-c/GRPCClient/GRPCCall+GID.h @@ -17,7 +17,7 @@ */ #import "GRPCCall+OAuth2.h" -#import "GRPCCall.h" +#import "GRPCCallLegacy.h" #import diff --git a/src/objective-c/GRPCClient/GRPCCall+OAuth2.h b/src/objective-c/GRPCClient/GRPCCall+OAuth2.h index 60cdc50bfda..cf60c794f27 100644 --- a/src/objective-c/GRPCClient/GRPCCall+OAuth2.h +++ b/src/objective-c/GRPCClient/GRPCCall+OAuth2.h @@ -16,9 +16,9 @@ * */ -#import "GRPCCall.h" +#import "GRPCCallLegacy.h" -#import "GRPCCallOptions.h" +@protocol GRPCAuthorizationProtocol; // Deprecated interface. Please use GRPCCallOptions instead. @interface GRPCCall (OAuth2) diff --git a/src/objective-c/GRPCClient/GRPCCall+Tests.h b/src/objective-c/GRPCClient/GRPCCall+Tests.h index edaa5ed582c..af81eec6b82 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Tests.h +++ b/src/objective-c/GRPCClient/GRPCCall+Tests.h @@ -16,7 +16,7 @@ * */ -#import "GRPCCall.h" +#import "GRPCCallLegacy.h" // Deprecated interface. Please use GRPCCallOptions instead. @interface GRPCCall (Tests) diff --git a/src/objective-c/GRPCClient/GRPCCall+Tests.m b/src/objective-c/GRPCClient/GRPCCall+Tests.m index 20f5cba4178..3a1dff38868 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Tests.m +++ b/src/objective-c/GRPCClient/GRPCCall+Tests.m @@ -18,7 +18,7 @@ #import "GRPCCall+Tests.h" -#import "private/GRPCHost.h" +#import "private/GRPCCore/GRPCHost.h" #import "GRPCCallOptions.h" diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index d02ec601727..1c7a10048cf 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -33,134 +33,19 @@ */ #import -#import -#include +#import "GRPCCallOptions.h" +#import "GRPCDispatchable.h" +#import "GRPCTypes.h" -#include "GRPCCallOptions.h" +// The legacy header is included for backwards compatibility. Some V1 API users are still using +// GRPCCall by importing GRPCCall.h header so we need this import. +#import "GRPCCallLegacy.h" NS_ASSUME_NONNULL_BEGIN -#pragma mark gRPC errors - -/** Domain of NSError objects produced by gRPC. */ -extern NSString *const kGRPCErrorDomain; - -/** - * gRPC error codes. - * Note that a few of these are never produced by the gRPC libraries, but are of general utility for - * server applications to produce. - */ -typedef NS_ENUM(NSUInteger, GRPCErrorCode) { - /** The operation was cancelled (typically by the caller). */ - GRPCErrorCodeCancelled = 1, - - /** - * Unknown error. Errors raised by APIs that do not return enough error information may be - * converted to this error. - */ - GRPCErrorCodeUnknown = 2, - - /** - * The client specified an invalid argument. Note that this differs from FAILED_PRECONDITION. - * INVALID_ARGUMENT indicates arguments that are problematic regardless of the state of the - * server (e.g., a malformed file name). - */ - GRPCErrorCodeInvalidArgument = 3, - - /** - * Deadline expired before operation could complete. For operations that change the state of the - * server, this error may be returned even if the operation has completed successfully. For - * example, a successful response from the server could have been delayed long enough for the - * deadline to expire. - */ - GRPCErrorCodeDeadlineExceeded = 4, - - /** Some requested entity (e.g., file or directory) was not found. */ - GRPCErrorCodeNotFound = 5, - - /** Some entity that we attempted to create (e.g., file or directory) already exists. */ - GRPCErrorCodeAlreadyExists = 6, - - /** - * The caller does not have permission to execute the specified operation. PERMISSION_DENIED isn't - * used for rejections caused by exhausting some resource (RESOURCE_EXHAUSTED is used instead for - * those errors). PERMISSION_DENIED doesn't indicate a failure to identify the caller - * (UNAUTHENTICATED is used instead for those errors). - */ - GRPCErrorCodePermissionDenied = 7, - - /** - * The request does not have valid authentication credentials for the operation (e.g. the caller's - * identity can't be verified). - */ - GRPCErrorCodeUnauthenticated = 16, - - /** Some resource has been exhausted, perhaps a per-user quota. */ - GRPCErrorCodeResourceExhausted = 8, - - /** - * The RPC was rejected because the server is not in a state required for the procedure's - * execution. For example, a directory to be deleted may be non-empty, etc. - * The client should not retry until the server state has been explicitly fixed (e.g. by - * performing another RPC). The details depend on the service being called, and should be found in - * the NSError's userInfo. - */ - GRPCErrorCodeFailedPrecondition = 9, - - /** - * The RPC was aborted, typically due to a concurrency issue like sequencer check failures, - * transaction aborts, etc. The client should retry at a higher-level (e.g., restarting a read- - * modify-write sequence). - */ - GRPCErrorCodeAborted = 10, - - /** - * The RPC was attempted past the valid range. E.g., enumerating past the end of a list. - * Unlike INVALID_ARGUMENT, this error indicates a problem that may be fixed if the system state - * changes. For example, an RPC to get elements of a list will generate INVALID_ARGUMENT if asked - * to return the element at a negative index, but it will generate OUT_OF_RANGE if asked to return - * the element at an index past the current size of the list. - */ - GRPCErrorCodeOutOfRange = 11, - - /** The procedure is not implemented or not supported/enabled in this server. */ - GRPCErrorCodeUnimplemented = 12, - - /** - * Internal error. Means some invariant expected by the server application or the gRPC library has - * been broken. - */ - GRPCErrorCodeInternal = 13, - - /** - * The server is currently unavailable. This is most likely a transient condition and may be - * corrected by retrying with a backoff. Note that it is not always safe to retry - * non-idempotent operations. - */ - GRPCErrorCodeUnavailable = 14, - - /** Unrecoverable data loss or corruption. */ - GRPCErrorCodeDataLoss = 15, -}; - -/** - * Keys used in |NSError|'s |userInfo| dictionary to store the response headers and trailers sent by - * the server. - */ -extern NSString *const kGRPCHeadersKey; -extern NSString *const kGRPCTrailersKey; - /** An object can implement this protocol to receive responses from server from a call. */ -@protocol GRPCResponseHandler - -@required - -/** - * All the responses must be issued to a user-provided dispatch queue. This property specifies the - * dispatch queue to be used for issuing the notifications. - */ -@property(atomic, readonly) dispatch_queue_t dispatchQueue; +@protocol GRPCResponseHandler @optional @@ -302,114 +187,3 @@ extern NSString *const kGRPCTrailersKey; @end NS_ASSUME_NONNULL_END - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wnullability-completeness" - -/** - * This interface is deprecated. Please use \a GRPCcall2. - * - * Represents a single gRPC remote call. - */ -@interface GRPCCall : GRXWriter - -- (instancetype)init NS_UNAVAILABLE; - -/** - * The container of the request headers of an RPC conforms to this protocol, which is a subset of - * NSMutableDictionary's interface. It will become a NSMutableDictionary later on. - * The keys of this container are the header names, which per the HTTP standard are case- - * insensitive. They are stored in lowercase (which is how HTTP/2 mandates them on the wire), and - * can only consist of ASCII characters. - * A header value is a NSString object (with only ASCII characters), unless the header name has the - * suffix "-bin", in which case the value has to be a NSData object. - */ -/** - * These HTTP headers will be passed to the server as part of this call. Each HTTP header is a - * name-value pair with string names and either string or binary values. - * - * The passed dictionary has to use NSString keys, corresponding to the header names. The value - * associated to each can be a NSString object or a NSData object. E.g.: - * - * call.requestHeaders = @{@"authorization": @"Bearer ..."}; - * - * call.requestHeaders[@"my-header-bin"] = someData; - * - * After the call is started, trying to modify this property is an error. - * - * The property is initialized to an empty NSMutableDictionary. - */ -@property(atomic, readonly) NSMutableDictionary *requestHeaders; - -/** - * This dictionary is populated with the HTTP headers received from the server. This happens before - * any response message is received from the server. It has the same structure as the request - * headers dictionary: Keys are NSString header names; names ending with the suffix "-bin" have a - * NSData value; the others have a NSString value. - * - * The value of this property is nil until all response headers are received, and will change before - * any of -writeValue: or -writesFinishedWithError: are sent to the writeable. - */ -@property(atomic, readonly) NSDictionary *responseHeaders; - -/** - * Same as responseHeaders, but populated with the HTTP trailers received from the server before the - * call finishes. - * - * The value of this property is nil until all response trailers are received, and will change - * before -writesFinishedWithError: is sent to the writeable. - */ -@property(atomic, readonly) NSDictionary *responseTrailers; - -/** - * The request writer has to write NSData objects into the provided Writeable. The server will - * receive each of those separately and in order as distinct messages. - * A gRPC call might not complete until the request writer finishes. On the other hand, the request - * finishing doesn't necessarily make the call to finish, as the server might continue sending - * messages to the response side of the call indefinitely (depending on the semantics of the - * specific remote method called). - * To finish a call right away, invoke cancel. - * host parameter should not contain the scheme (http:// or https://), only the name or IP addr - * and the port number, for example @"localhost:5050". - */ -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - requestsWriter:(GRXWriter *)requestWriter; - -/** - * Finishes the request side of this call, notifies the server that the RPC should be cancelled, and - * finishes the response side of the call with an error of code CANCELED. - */ -- (void)cancel; - -/** - * The following methods are deprecated. - */ -+ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path; -@property(atomic, copy, readwrite) NSString *serverName; -@property NSTimeInterval timeout; -- (void)setResponseDispatchQueue:(dispatch_queue_t)queue; - -@end - -#pragma mark Backwards compatibiity - -/** This protocol is kept for backwards compatibility with existing code. */ -DEPRECATED_MSG_ATTRIBUTE("Use NSDictionary or NSMutableDictionary instead.") -@protocol GRPCRequestHeaders -@property(nonatomic, readonly) NSUInteger count; - -- (id)objectForKeyedSubscript:(id)key; -- (void)setObject:(id)obj forKeyedSubscript:(id)key; - -- (void)removeAllObjects; -- (void)removeObjectForKey:(id)key; -@end - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated" -/** This is only needed for backwards-compatibility. */ -@interface NSMutableDictionary (GRPCRequestHeaders) -@end -#pragma clang diagnostic pop -#pragma clang diagnostic pop diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index cd293cc8e59..73ee530ef2c 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -17,56 +17,86 @@ */ #import "GRPCCall.h" + #import "GRPCCall+Interceptor.h" -#import "GRPCCall+OAuth2.h" #import "GRPCCallOptions.h" #import "GRPCInterceptor.h" -#import -#import -#import -#import -#include -#include - -#import "private/GRPCCall+V2API.h" -#import "private/GRPCCallInternal.h" -#import "private/GRPCChannelPool.h" -#import "private/GRPCCompletionQueue.h" -#import "private/GRPCHost.h" -#import "private/GRPCRequestHeaders.h" -#import "private/GRPCWrappedCall.h" -#import "private/NSData+GRPC.h" -#import "private/NSDictionary+GRPC.h" -#import "private/NSError+GRPC.h" - -// At most 6 ops can be in an op batch for a client: SEND_INITIAL_METADATA, -// SEND_MESSAGE, SEND_CLOSE_FROM_CLIENT, RECV_INITIAL_METADATA, RECV_MESSAGE, -// and RECV_STATUS_ON_CLIENT. -NSInteger kMaxClientBatch = 6; +#import "private/GRPCTransport+Private.h" NSString *const kGRPCHeadersKey = @"io.grpc.HeadersKey"; NSString *const kGRPCTrailersKey = @"io.grpc.TrailersKey"; -static NSMutableDictionary *callFlags; -static NSString *const kAuthorizationHeader = @"authorization"; -static NSString *const kBearerPrefix = @"Bearer "; +NSString *const kGRPCErrorDomain = @"io.grpc"; -const char *kCFStreamVarName = "grpc_cfstream"; +/** + * The response dispatcher creates its own serial dispatch queue and target the queue to the + * dispatch queue of a user provided response handler. It removes the requirement of having to use + * serial dispatch queue in the user provided response handler. + */ +@interface GRPCResponseDispatcher : NSObject -@interface GRPCCall () -// Make them read-write. -@property(atomic, strong) NSDictionary *responseHeaders; -@property(atomic, strong) NSDictionary *responseTrailers; +- (nullable instancetype)initWithResponseHandler:(id)responseHandler; -- (void)receiveNextMessages:(NSUInteger)numberOfMessages; +@end -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - callSafety:(GRPCCallSafety)safety - requestsWriter:(GRXWriter *)requestsWriter - callOptions:(GRPCCallOptions *)callOptions - writeDone:(void (^)(void))writeDone; +@implementation GRPCResponseDispatcher { + id _responseHandler; + dispatch_queue_t _dispatchQueue; +} + +- (instancetype)initWithResponseHandler:(id)responseHandler { + if ((self = [super init])) { + _responseHandler = responseHandler; +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 + if (@available(iOS 8.0, macOS 10.10, *)) { + _dispatchQueue = dispatch_queue_create( + NULL, + dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); + } else { +#else + { +#endif + _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); + } + dispatch_set_target_queue(_dispatchQueue, _responseHandler.dispatchQueue); + } + + return self; +} + +- (dispatch_queue_t)dispatchQueue { + return _dispatchQueue; +} + +- (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata { + if ([_responseHandler respondsToSelector:@selector(didReceiveInitialMetadata:)]) { + [_responseHandler didReceiveInitialMetadata:initialMetadata]; + } +} + +- (void)didReceiveData:(id)data { + // For backwards compatibility with didReceiveRawMessage, if the user provided a response handler + // that handles didReceiveRawMesssage, we issue to that method instead + if ([_responseHandler respondsToSelector:@selector(didReceiveRawMessage:)]) { + [_responseHandler didReceiveRawMessage:data]; + } else if ([_responseHandler respondsToSelector:@selector(didReceiveData:)]) { + [_responseHandler didReceiveData:data]; + } +} + +- (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata + error:(nullable NSError *)error { + if ([_responseHandler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { + [_responseHandler didCloseWithTrailingMetadata:trailingMetadata error:error]; + } +} + +- (void)didWriteData { + if ([_responseHandler respondsToSelector:@selector(didWriteData)]) { + [_responseHandler didWriteData]; + } +} @end @@ -140,54 +170,39 @@ const char *kCFStreamVarName = "grpc_cfstream"; } _responseHandler = responseHandler; - // Initialize the interceptor chain - - // First initialize the internal call - GRPCCall2Internal *internalCall = [[GRPCCall2Internal alloc] init]; - id nextInterceptor = internalCall; - GRPCInterceptorManager *nextManager = nil; - - // Then initialize the global interceptor, if applicable - id globalInterceptorFactory = [GRPCCall2 globalInterceptorFactory]; - if (globalInterceptorFactory) { - GRPCInterceptorManager *manager = - [[GRPCInterceptorManager alloc] initWithNextInterceptor:nextInterceptor]; - GRPCInterceptor *interceptor = - [globalInterceptorFactory createInterceptorWithManager:manager]; - if (interceptor != nil) { - [internalCall setResponseHandler:interceptor]; - nextInterceptor = interceptor; - nextManager = manager; - } - } - - // Finally initialize the interceptors in the chain - NSArray *interceptorFactories = _actualCallOptions.interceptorFactories; - for (int i = (int)interceptorFactories.count - 1; i >= 0; i--) { - GRPCInterceptorManager *manager = - [[GRPCInterceptorManager alloc] initWithNextInterceptor:nextInterceptor]; - GRPCInterceptor *interceptor = [interceptorFactories[i] createInterceptorWithManager:manager]; - NSAssert(interceptor != nil, @"Failed to create interceptor from factory: %@", - interceptorFactories[i]); - if (interceptor == nil) { - NSLog(@"Failed to create interceptor from factory: %@", interceptorFactories[i]); - continue; - } - if (nextManager == nil) { - [internalCall setResponseHandler:interceptor]; - } else { - [nextManager setPreviousInterceptor:interceptor]; - } - nextInterceptor = interceptor; - nextManager = manager; - } - if (nextManager == nil) { - [internalCall setResponseHandler:_responseHandler]; + GRPCResponseDispatcher *dispatcher = + [[GRPCResponseDispatcher alloc] initWithResponseHandler:_responseHandler]; + NSMutableArray> *interceptorFactories; + if (_actualCallOptions.interceptorFactories != nil) { + interceptorFactories = + [NSMutableArray arrayWithArray:_actualCallOptions.interceptorFactories]; } else { - [nextManager setPreviousInterceptor:_responseHandler]; + interceptorFactories = [NSMutableArray array]; + } + id globalInterceptorFactory = [GRPCCall2 globalInterceptorFactory]; + if (globalInterceptorFactory != nil) { + [interceptorFactories addObject:globalInterceptorFactory]; + } + // continuously create interceptor until one is successfully created + while (_firstInterceptor == nil) { + if (interceptorFactories.count == 0) { + _firstInterceptor = [[GRPCTransportManager alloc] initWithTransportId:_callOptions.transport + previousInterceptor:dispatcher]; + break; + } else { + _firstInterceptor = + [[GRPCInterceptorManager alloc] initWithFactories:interceptorFactories + previousInterceptor:dispatcher + transportId:_callOptions.transport]; + if (_firstInterceptor == nil) { + [interceptorFactories removeObjectAtIndex:0]; + } + } + } + NSAssert(_firstInterceptor != nil, @"Failed to create interceptor or transport."); + if (_firstInterceptor == nil) { + NSLog(@"Failed to create interceptor or transport."); } - - _firstInterceptor = nextInterceptor; } return self; @@ -200,696 +215,42 @@ const char *kCFStreamVarName = "grpc_cfstream"; } - (void)start { - id copiedFirstInterceptor; - @synchronized(self) { - copiedFirstInterceptor = _firstInterceptor; - } - GRPCRequestOptions *requestOptions = [_requestOptions copy]; - GRPCCallOptions *callOptions = [_actualCallOptions copy]; - if ([copiedFirstInterceptor respondsToSelector:@selector(startWithRequestOptions:callOptions:)]) { - dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ - [copiedFirstInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; - }); - } + id copiedFirstInterceptor = _firstInterceptor; + GRPCRequestOptions *requestOptions = _requestOptions; + GRPCCallOptions *callOptions = _actualCallOptions; + dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ + [copiedFirstInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; + }); } - (void)cancel { - id copiedFirstInterceptor; - @synchronized(self) { - copiedFirstInterceptor = _firstInterceptor; - } - if ([copiedFirstInterceptor respondsToSelector:@selector(cancel)]) { - dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ + id copiedFirstInterceptor = _firstInterceptor; + if (copiedFirstInterceptor != nil) { + dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ [copiedFirstInterceptor cancel]; }); } } - (void)writeData:(id)data { - id copiedFirstInterceptor; - @synchronized(self) { - copiedFirstInterceptor = _firstInterceptor; - } - if ([copiedFirstInterceptor respondsToSelector:@selector(writeData:)]) { - dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ - [copiedFirstInterceptor writeData:data]; - }); - } + id copiedFirstInterceptor = _firstInterceptor; + dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ + [copiedFirstInterceptor writeData:data]; + }); } - (void)finish { - id copiedFirstInterceptor; - @synchronized(self) { - copiedFirstInterceptor = _firstInterceptor; - } - if ([copiedFirstInterceptor respondsToSelector:@selector(finish)]) { - dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ - [copiedFirstInterceptor finish]; - }); - } -} - -- (void)receiveNextMessages:(NSUInteger)numberOfMessages { - id copiedFirstInterceptor; - @synchronized(self) { - copiedFirstInterceptor = _firstInterceptor; - } - if ([copiedFirstInterceptor respondsToSelector:@selector(receiveNextMessages:)]) { - dispatch_async(copiedFirstInterceptor.requestDispatchQueue, ^{ - [copiedFirstInterceptor receiveNextMessages:numberOfMessages]; - }); - } -} - -@end - -// The following methods of a C gRPC call object aren't reentrant, and thus -// calls to them must be serialized: -// - start_batch -// - destroy -// -// start_batch with a SEND_MESSAGE argument can only be called after the -// OP_COMPLETE event for any previous write is received. This is achieved by -// pausing the requests writer immediately every time it writes a value, and -// resuming it again when OP_COMPLETE is received. -// -// Similarly, start_batch with a RECV_MESSAGE argument can only be called after -// the OP_COMPLETE event for any previous read is received.This is easier to -// enforce, as we're writing the received messages into the writeable: -// start_batch is enqueued once upon receiving the OP_COMPLETE event for the -// RECV_METADATA batch, and then once after receiving each OP_COMPLETE event for -// each RECV_MESSAGE batch. -@implementation GRPCCall { - dispatch_queue_t _callQueue; - - NSString *_host; - NSString *_path; - GRPCCallSafety _callSafety; - GRPCCallOptions *_callOptions; - GRPCWrappedCall *_wrappedCall; - - // The C gRPC library has less guarantees on the ordering of events than we - // do. Particularly, in the face of errors, there's no ordering guarantee at - // all. This wrapper over our actual writeable ensures thread-safety and - // correct ordering. - GRXConcurrentWriteable *_responseWriteable; - - // The network thread wants the requestWriter to resume (when the server is ready for more input), - // or to stop (on errors), concurrently with user threads that want to start it, pause it or stop - // it. Because a writer isn't thread-safe, we'll synchronize those operations on it. - // We don't use a dispatch queue for that purpose, because the writer can call writeValue: or - // writesFinishedWithError: on this GRPCCall as part of those operations. We want to be able to - // pause the writer immediately on writeValue:, so we need our locking to be recursive. - GRXWriter *_requestWriter; - - // To create a retain cycle when a call is started, up until it finishes. See - // |startWithWriteable:| and |finishWithError:|. This saves users from having to retain a - // reference to the call object if all they're interested in is the handler being executed when - // the response arrives. - GRPCCall *_retainSelf; - - GRPCRequestHeaders *_requestHeaders; - - // In the case that the call is a unary call (i.e. the writer to GRPCCall is of type - // GRXImmediateSingleWriter), GRPCCall will delay sending ops (not send them to C core - // immediately) and buffer them into a batch _unaryOpBatch. The batch is sent to C core when - // the SendClose op is added. - BOOL _unaryCall; - NSMutableArray *_unaryOpBatch; - - // The dispatch queue to be used for enqueuing responses to user. Defaulted to the main dispatch - // queue - dispatch_queue_t _responseQueue; - - // The OAuth2 token fetched from a token provider. - NSString *_fetchedOauth2AccessToken; - - // The callback to be called when a write message op is done. - void (^_writeDone)(void); - - // Indicate a read request to core is pending. - BOOL _pendingCoreRead; - - // Indicate pending read message request from user. - NSUInteger _pendingReceiveNextMessages; -} - -@synthesize state = _state; - -+ (void)initialize { - // Guarantees the code in {} block is invoked only once. See ref at: - // https://developer.apple.com/documentation/objectivec/nsobject/1418639-initialize?language=objc - if (self == [GRPCCall self]) { - grpc_init(); - callFlags = [NSMutableDictionary dictionary]; - } -} - -+ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path { - if (host.length == 0 || path.length == 0) { - return; - } - NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path]; - @synchronized(callFlags) { - switch (callSafety) { - case GRPCCallSafetyDefault: - callFlags[hostAndPath] = @0; - break; - case GRPCCallSafetyIdempotentRequest: - callFlags[hostAndPath] = @GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST; - break; - case GRPCCallSafetyCacheableRequest: - callFlags[hostAndPath] = @GRPC_INITIAL_METADATA_CACHEABLE_REQUEST; - break; - default: - break; - } - } -} - -+ (uint32_t)callFlagsForHost:(NSString *)host path:(NSString *)path { - NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path]; - @synchronized(callFlags) { - return [callFlags[hostAndPath] intValue]; - } -} - -// Designated initializer -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - requestsWriter:(GRXWriter *)requestWriter { - return [self initWithHost:host - path:path - callSafety:GRPCCallSafetyDefault - requestsWriter:requestWriter - callOptions:nil]; -} - -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - callSafety:(GRPCCallSafety)safety - requestsWriter:(GRXWriter *)requestsWriter - callOptions:(GRPCCallOptions *)callOptions { - return [self initWithHost:host - path:path - callSafety:safety - requestsWriter:requestsWriter - callOptions:callOptions - writeDone:nil]; -} - -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - callSafety:(GRPCCallSafety)safety - requestsWriter:(GRXWriter *)requestsWriter - callOptions:(GRPCCallOptions *)callOptions - writeDone:(void (^)(void))writeDone { - // Purposely using pointer rather than length (host.length == 0) for backwards compatibility. - NSAssert(host != nil && path != nil, @"Neither host nor path can be nil."); - NSAssert(safety <= GRPCCallSafetyCacheableRequest, @"Invalid call safety value."); - NSAssert(requestsWriter.state == GRXWriterStateNotStarted, - @"The requests writer can't be already started."); - if (!host || !path) { - return nil; - } - if (safety > GRPCCallSafetyCacheableRequest) { - return nil; - } - if (requestsWriter.state != GRXWriterStateNotStarted) { - return nil; - } - - if ((self = [super init])) { - _host = [host copy]; - _path = [path copy]; - _callSafety = safety; - _callOptions = [callOptions copy]; - - // Serial queue to invoke the non-reentrant methods of the grpc_call object. - _callQueue = dispatch_queue_create("io.grpc.call", DISPATCH_QUEUE_SERIAL); - - _requestWriter = requestsWriter; - _requestHeaders = [[GRPCRequestHeaders alloc] initWithCall:self]; - _writeDone = writeDone; - - if ([requestsWriter isKindOfClass:[GRXImmediateSingleWriter class]]) { - _unaryCall = YES; - _unaryOpBatch = [NSMutableArray arrayWithCapacity:kMaxClientBatch]; - } - - _responseQueue = dispatch_get_main_queue(); - - // do not start a read until initial metadata is received - _pendingReceiveNextMessages = 0; - _pendingCoreRead = YES; - } - return self; -} - -- (void)setResponseDispatchQueue:(dispatch_queue_t)queue { - @synchronized(self) { - if (_state != GRXWriterStateNotStarted) { - return; - } - _responseQueue = queue; - } -} - -#pragma mark Finish - -// This function should support being called within a @synchronized(self) block in another function -// Should not manipulate _requestWriter for deadlock prevention. -- (void)finishWithError:(NSError *)errorOrNil { - @synchronized(self) { - if (_state == GRXWriterStateFinished) { - return; - } - _state = GRXWriterStateFinished; - - if (errorOrNil) { - [_responseWriteable cancelWithError:errorOrNil]; - } else { - [_responseWriteable enqueueSuccessfulCompletion]; - } - - // If the call isn't retained anywhere else, it can be deallocated now. - _retainSelf = nil; - } -} - -- (void)cancel { - @synchronized(self) { - if (_state == GRXWriterStateFinished) { - return; - } - [self finishWithError:[NSError - errorWithDomain:kGRPCErrorDomain - code:GRPCErrorCodeCancelled - userInfo:@{NSLocalizedDescriptionKey : @"Canceled by app"}]]; - [_wrappedCall cancel]; - } - _requestWriter.state = GRXWriterStateFinished; -} - -- (void)dealloc { - __block GRPCWrappedCall *wrappedCall = _wrappedCall; - dispatch_async(_callQueue, ^{ - wrappedCall = nil; - }); -} - -#pragma mark Read messages - -// Only called from the call queue. -// The handler will be called from the network queue. -- (void)startReadWithHandler:(void (^)(grpc_byte_buffer *))handler { - // TODO(jcanizales): Add error handlers for async failures - [_wrappedCall startBatchWithOperations:@[ [[GRPCOpRecvMessage alloc] initWithHandler:handler] ]]; -} - -// Called initially from the network queue once response headers are received, -// then "recursively" from the responseWriteable queue after each response from the -// server has been written. -// If the call is currently paused, this is a noop. Restarting the call will invoke this -// method. -// TODO(jcanizales): Rename to readResponseIfNotPaused. -- (void)maybeStartNextRead { - @synchronized(self) { - if (_state != GRXWriterStateStarted) { - return; - } - if (_callOptions.flowControlEnabled && (_pendingCoreRead || _pendingReceiveNextMessages == 0)) { - return; - } - _pendingCoreRead = YES; - _pendingReceiveNextMessages--; - } - - dispatch_async(_callQueue, ^{ - __weak GRPCCall *weakSelf = self; - [self startReadWithHandler:^(grpc_byte_buffer *message) { - if (message == NULL) { - // No more messages from the server - return; - } - __strong GRPCCall *strongSelf = weakSelf; - if (strongSelf == nil) { - grpc_byte_buffer_destroy(message); - return; - } - NSData *data = [NSData grpc_dataWithByteBuffer:message]; - grpc_byte_buffer_destroy(message); - if (!data) { - // The app doesn't have enough memory to hold the server response. We - // don't want to throw, because the app shouldn't crash for a behavior - // that's on the hands of any server to have. Instead we finish and ask - // the server to cancel. - @synchronized(strongSelf) { - strongSelf->_pendingCoreRead = NO; - [strongSelf - finishWithError:[NSError errorWithDomain:kGRPCErrorDomain - code:GRPCErrorCodeResourceExhausted - userInfo:@{ - NSLocalizedDescriptionKey : - @"Client does not have enough memory to " - @"hold the server response." - }]]; - [strongSelf->_wrappedCall cancel]; - } - strongSelf->_requestWriter.state = GRXWriterStateFinished; - } else { - @synchronized(strongSelf) { - [strongSelf->_responseWriteable enqueueValue:data - completionHandler:^{ - __strong GRPCCall *strongSelf = weakSelf; - if (strongSelf) { - @synchronized(strongSelf) { - strongSelf->_pendingCoreRead = NO; - [strongSelf maybeStartNextRead]; - } - } - }]; - } - } - }]; - }); -} - -#pragma mark Send headers - -- (void)sendHeaders { - // TODO (mxyan): Remove after deprecated methods are removed - uint32_t callSafetyFlags = 0; - switch (_callSafety) { - case GRPCCallSafetyDefault: - callSafetyFlags = 0; - break; - case GRPCCallSafetyIdempotentRequest: - callSafetyFlags = GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST; - break; - case GRPCCallSafetyCacheableRequest: - callSafetyFlags = GRPC_INITIAL_METADATA_CACHEABLE_REQUEST; - break; - } - - NSMutableDictionary *headers = [_requestHeaders mutableCopy]; - NSString *fetchedOauth2AccessToken; - @synchronized(self) { - fetchedOauth2AccessToken = _fetchedOauth2AccessToken; - } - if (fetchedOauth2AccessToken != nil) { - headers[@"authorization"] = [kBearerPrefix stringByAppendingString:fetchedOauth2AccessToken]; - } else if (_callOptions.oauth2AccessToken != nil) { - headers[@"authorization"] = - [kBearerPrefix stringByAppendingString:_callOptions.oauth2AccessToken]; - } - - // TODO(jcanizales): Add error handlers for async failures - GRPCOpSendMetadata *op = [[GRPCOpSendMetadata alloc] - initWithMetadata:headers - flags:callSafetyFlags - handler:nil]; // No clean-up needed after SEND_INITIAL_METADATA - dispatch_async(_callQueue, ^{ - if (!self->_unaryCall) { - [self->_wrappedCall startBatchWithOperations:@[ op ]]; - } else { - [self->_unaryOpBatch addObject:op]; - } + id copiedFirstInterceptor = _firstInterceptor; + dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ + [copiedFirstInterceptor finish]; }); } - (void)receiveNextMessages:(NSUInteger)numberOfMessages { - if (numberOfMessages == 0) { - return; - } - @synchronized(self) { - _pendingReceiveNextMessages += numberOfMessages; - - if (_state != GRXWriterStateStarted || !_callOptions.flowControlEnabled) { - return; - } - [self maybeStartNextRead]; - } -} - -#pragma mark GRXWriteable implementation - -// Only called from the call queue. The error handler will be called from the -// network queue if the write didn't succeed. -// If the call is a unary call, parameter \a errorHandler will be ignored and -// the error handler of GRPCOpSendClose will be executed in case of error. -- (void)writeMessage:(NSData *)message withErrorHandler:(void (^)(void))errorHandler { - __weak GRPCCall *weakSelf = self; - void (^resumingHandler)(void) = ^{ - // Resume the request writer. - GRPCCall *strongSelf = weakSelf; - if (strongSelf) { - strongSelf->_requestWriter.state = GRXWriterStateStarted; - if (strongSelf->_writeDone) { - strongSelf->_writeDone(); - } - } - }; - GRPCOpSendMessage *op = - [[GRPCOpSendMessage alloc] initWithMessage:message handler:resumingHandler]; - if (!_unaryCall) { - [_wrappedCall startBatchWithOperations:@[ op ] errorHandler:errorHandler]; - } else { - // Ignored errorHandler since it is the same as the one for GRPCOpSendClose. - // TODO (mxyan): unify the error handlers of all Ops into a single closure. - [_unaryOpBatch addObject:op]; - } -} - -- (void)writeValue:(id)value { - NSAssert([value isKindOfClass:[NSData class]], @"value must be of type NSData"); - - @synchronized(self) { - if (_state == GRXWriterStateFinished) { - return; - } - } - - // Pause the input and only resume it when the C layer notifies us that writes - // can proceed. - _requestWriter.state = GRXWriterStatePaused; - - dispatch_async(_callQueue, ^{ - // Write error is not processed here. It is handled by op batch of GRPC_OP_RECV_STATUS_ON_CLIENT - [self writeMessage:value withErrorHandler:nil]; + id copiedFirstInterceptor = _firstInterceptor; + dispatch_async(copiedFirstInterceptor.dispatchQueue, ^{ + [copiedFirstInterceptor receiveNextMessages:numberOfMessages]; }); } -// Only called from the call queue. The error handler will be called from the -// network queue if the requests stream couldn't be closed successfully. -- (void)finishRequestWithErrorHandler:(void (^)(void))errorHandler { - if (!_unaryCall) { - [_wrappedCall startBatchWithOperations:@[ [[GRPCOpSendClose alloc] init] ] - errorHandler:errorHandler]; - } else { - [_unaryOpBatch addObject:[[GRPCOpSendClose alloc] init]]; - [_wrappedCall startBatchWithOperations:_unaryOpBatch errorHandler:errorHandler]; - } -} - -- (void)writesFinishedWithError:(NSError *)errorOrNil { - if (errorOrNil) { - [self cancel]; - } else { - dispatch_async(_callQueue, ^{ - // EOS error is not processed here. It is handled by op batch of GRPC_OP_RECV_STATUS_ON_CLIENT - [self finishRequestWithErrorHandler:nil]; - }); - } -} - -#pragma mark Invoke - -// Both handlers will eventually be called, from the network queue. Writes can start immediately -// after this. -// The first one (headersHandler), when the response headers are received. -// The second one (completionHandler), whenever the RPC finishes for any reason. -- (void)invokeCallWithHeadersHandler:(void (^)(NSDictionary *))headersHandler - completionHandler:(void (^)(NSError *, NSDictionary *))completionHandler { - dispatch_async(_callQueue, ^{ - // TODO(jcanizales): Add error handlers for async failures - [self->_wrappedCall - startBatchWithOperations:@[ [[GRPCOpRecvMetadata alloc] initWithHandler:headersHandler] ]]; - [self->_wrappedCall - startBatchWithOperations:@[ [[GRPCOpRecvStatus alloc] initWithHandler:completionHandler] ]]; - }); -} - -- (void)invokeCall { - __weak GRPCCall *weakSelf = self; - [self invokeCallWithHeadersHandler:^(NSDictionary *headers) { - // Response headers received. - __strong GRPCCall *strongSelf = weakSelf; - if (strongSelf) { - @synchronized(strongSelf) { - // it is ok to set nil because headers are only received once - strongSelf.responseHeaders = nil; - // copy the header so that the GRPCOpRecvMetadata object may be dealloc'ed - NSDictionary *copiedHeaders = - [[NSDictionary alloc] initWithDictionary:headers copyItems:YES]; - strongSelf.responseHeaders = copiedHeaders; - strongSelf->_pendingCoreRead = NO; - [strongSelf maybeStartNextRead]; - } - } - } - completionHandler:^(NSError *error, NSDictionary *trailers) { - __strong GRPCCall *strongSelf = weakSelf; - if (strongSelf) { - strongSelf.responseTrailers = trailers; - - if (error) { - NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; - if (error.userInfo) { - [userInfo addEntriesFromDictionary:error.userInfo]; - } - userInfo[kGRPCTrailersKey] = strongSelf.responseTrailers; - // Since gRPC core does not guarantee the headers block being called before this block, - // responseHeaders might be nil. - userInfo[kGRPCHeadersKey] = strongSelf.responseHeaders; - error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo]; - } - [strongSelf finishWithError:error]; - strongSelf->_requestWriter.state = GRXWriterStateFinished; - } - }]; -} - -#pragma mark GRXWriter implementation - -// Lock acquired inside startWithWriteable: -- (void)startCallWithWriteable:(id)writeable { - @synchronized(self) { - if (_state == GRXWriterStateFinished) { - return; - } - - _responseWriteable = - [[GRXConcurrentWriteable alloc] initWithWriteable:writeable dispatchQueue:_responseQueue]; - - GRPCPooledChannel *channel = - [[GRPCChannelPool sharedInstance] channelWithHost:_host callOptions:_callOptions]; - _wrappedCall = [channel wrappedCallWithPath:_path - completionQueue:[GRPCCompletionQueue completionQueue] - callOptions:_callOptions]; - - if (_wrappedCall == nil) { - [self finishWithError:[NSError errorWithDomain:kGRPCErrorDomain - code:GRPCErrorCodeUnavailable - userInfo:@{ - NSLocalizedDescriptionKey : - @"Failed to create call or channel." - }]]; - return; - } - - [self sendHeaders]; - [self invokeCall]; - } - - // Now that the RPC has been initiated, request writes can start. - [_requestWriter startWithWriteable:self]; -} - -- (void)startWithWriteable:(id)writeable { - id tokenProvider = nil; - @synchronized(self) { - _state = GRXWriterStateStarted; - - // Create a retain cycle so that this instance lives until the RPC finishes (or is cancelled). - // This makes RPCs in which the call isn't externally retained possible (as long as it is - // started before being autoreleased). Care is taken not to retain self strongly in any of the - // blocks used in this implementation, so that the life of the instance is determined by this - // retain cycle. - _retainSelf = self; - - if (_callOptions == nil) { - GRPCMutableCallOptions *callOptions = [[GRPCHost callOptionsForHost:_host] mutableCopy]; - if (_serverName.length != 0) { - callOptions.serverAuthority = _serverName; - } - if (_timeout > 0) { - callOptions.timeout = _timeout; - } - uint32_t callFlags = [GRPCCall callFlagsForHost:_host path:_path]; - if (callFlags != 0) { - if (callFlags == GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) { - _callSafety = GRPCCallSafetyIdempotentRequest; - } else if (callFlags == GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) { - _callSafety = GRPCCallSafetyCacheableRequest; - } - } - - id tokenProvider = self.tokenProvider; - if (tokenProvider != nil) { - callOptions.authTokenProvider = tokenProvider; - } - _callOptions = callOptions; - } - - NSAssert(_callOptions.authTokenProvider == nil || _callOptions.oauth2AccessToken == nil, - @"authTokenProvider and oauth2AccessToken cannot be set at the same time"); - - tokenProvider = _callOptions.authTokenProvider; - } - - if (tokenProvider != nil) { - __weak typeof(self) weakSelf = self; - [tokenProvider getTokenWithHandler:^(NSString *token) { - __strong typeof(self) strongSelf = weakSelf; - if (strongSelf) { - BOOL startCall = NO; - @synchronized(strongSelf) { - if (strongSelf->_state != GRXWriterStateFinished) { - startCall = YES; - if (token) { - strongSelf->_fetchedOauth2AccessToken = [token copy]; - } - } - } - if (startCall) { - [strongSelf startCallWithWriteable:writeable]; - } - } - }]; - } else { - [self startCallWithWriteable:writeable]; - } -} - -- (void)setState:(GRXWriterState)newState { - @synchronized(self) { - // Manual transitions are only allowed from the started or paused states. - if (_state == GRXWriterStateNotStarted || _state == GRXWriterStateFinished) { - return; - } - - switch (newState) { - case GRXWriterStateFinished: - _state = newState; - // Per GRXWriter's contract, setting the state to Finished manually - // means one doesn't wish the writeable to be messaged anymore. - [_responseWriteable cancelSilently]; - _responseWriteable = nil; - return; - case GRXWriterStatePaused: - _state = newState; - return; - case GRXWriterStateStarted: - if (_state == GRXWriterStatePaused) { - _state = newState; - [self maybeStartNextRead]; - } - return; - case GRXWriterStateNotStarted: - return; - } - } -} - @end diff --git a/src/objective-c/GRPCClient/GRPCCallLegacy.h b/src/objective-c/GRPCClient/GRPCCallLegacy.h new file mode 100644 index 00000000000..51dd7da3440 --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCCallLegacy.h @@ -0,0 +1,136 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/** + * This is the legacy interface of this gRPC library. This API is deprecated and users should use + * the API in GRPCCall.h. This API exists solely for the purpose of backwards compatibility. + */ + +#import +#import "GRPCTypes.h" + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnullability-completeness" + +/** + * This interface is deprecated. Please use \a GRPCCall2. + * + * Represents a single gRPC remote call. + */ +@interface GRPCCall : GRXWriter + +- (instancetype)init NS_UNAVAILABLE; + +/** + * The container of the request headers of an RPC conforms to this protocol, which is a subset of + * NSMutableDictionary's interface. It will become a NSMutableDictionary later on. + * The keys of this container are the header names, which per the HTTP standard are case- + * insensitive. They are stored in lowercase (which is how HTTP/2 mandates them on the wire), and + * can only consist of ASCII characters. + * A header value is a NSString object (with only ASCII characters), unless the header name has the + * suffix "-bin", in which case the value has to be a NSData object. + */ +/** + * These HTTP headers will be passed to the server as part of this call. Each HTTP header is a + * name-value pair with string names and either string or binary values. + * + * The passed dictionary has to use NSString keys, corresponding to the header names. The value + * associated to each can be a NSString object or a NSData object. E.g.: + * + * call.requestHeaders = @{@"authorization": @"Bearer ..."}; + * + * call.requestHeaders[@"my-header-bin"] = someData; + * + * After the call is started, trying to modify this property is an error. + * + * The property is initialized to an empty NSMutableDictionary. + */ +@property(atomic, readonly) NSMutableDictionary *requestHeaders; + +/** + * This dictionary is populated with the HTTP headers received from the server. This happens before + * any response message is received from the server. It has the same structure as the request + * headers dictionary: Keys are NSString header names; names ending with the suffix "-bin" have a + * NSData value; the others have a NSString value. + * + * The value of this property is nil until all response headers are received, and will change before + * any of -writeValue: or -writesFinishedWithError: are sent to the writeable. + */ +@property(atomic, readonly) NSDictionary *responseHeaders; + +/** + * Same as responseHeaders, but populated with the HTTP trailers received from the server before the + * call finishes. + * + * The value of this property is nil until all response trailers are received, and will change + * before -writesFinishedWithError: is sent to the writeable. + */ +@property(atomic, readonly) NSDictionary *responseTrailers; + +/** + * The request writer has to write NSData objects into the provided Writeable. The server will + * receive each of those separately and in order as distinct messages. + * A gRPC call might not complete until the request writer finishes. On the other hand, the request + * finishing doesn't necessarily make the call to finish, as the server might continue sending + * messages to the response side of the call indefinitely (depending on the semantics of the + * specific remote method called). + * To finish a call right away, invoke cancel. + * host parameter should not contain the scheme (http:// or https://), only the name or IP addr + * and the port number, for example @"localhost:5050". + */ +- (instancetype)initWithHost:(NSString *)host + path:(NSString *)path + requestsWriter:(GRXWriter *)requestWriter; + +/** + * Finishes the request side of this call, notifies the server that the RPC should be cancelled, and + * finishes the response side of the call with an error of code CANCELED. + */ +- (void)cancel; + +/** + * The following methods are deprecated. + */ ++ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path; +@property(atomic, copy, readwrite) NSString *serverName; +@property NSTimeInterval timeout; +- (void)setResponseDispatchQueue:(dispatch_queue_t)queue; + +@end + +#pragma mark Backwards compatibiity + +/** This protocol is kept for backwards compatibility with existing code. */ +DEPRECATED_MSG_ATTRIBUTE("Use NSDictionary or NSMutableDictionary instead.") +@protocol GRPCRequestHeaders +@property(nonatomic, readonly) NSUInteger count; + +- (id)objectForKeyedSubscript:(id)key; +- (void)setObject:(id)obj forKeyedSubscript:(id)key; + +- (void)removeAllObjects; +- (void)removeObjectForKey:(id)key; +@end + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated" +/** This is only needed for backwards-compatibility. */ +@interface NSMutableDictionary (GRPCRequestHeaders) +@end +#pragma clang diagnostic pop +#pragma clang diagnostic pop diff --git a/src/objective-c/GRPCClient/GRPCCallLegacy.m b/src/objective-c/GRPCClient/GRPCCallLegacy.m new file mode 100644 index 00000000000..d06048c3a89 --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCCallLegacy.m @@ -0,0 +1,677 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "GRPCCallLegacy.h" + +#import "GRPCCall+OAuth2.h" +#import "GRPCCallOptions.h" +#import "GRPCTypes.h" + +#import "private/GRPCCore/GRPCChannelPool.h" +#import "private/GRPCCore/GRPCCompletionQueue.h" +#import "private/GRPCCore/GRPCHost.h" +#import "private/GRPCCore/GRPCWrappedCall.h" +#import "private/GRPCCore/NSData+GRPC.h" + +#import +#import +#import +#import + +#include + +const char *kCFStreamVarName = "grpc_cfstream"; +static NSMutableDictionary *callFlags; + +// At most 6 ops can be in an op batch for a client: SEND_INITIAL_METADATA, +// SEND_MESSAGE, SEND_CLOSE_FROM_CLIENT, RECV_INITIAL_METADATA, RECV_MESSAGE, +// and RECV_STATUS_ON_CLIENT. +NSInteger kMaxClientBatch = 6; + +static NSString *const kAuthorizationHeader = @"authorization"; +static NSString *const kBearerPrefix = @"Bearer "; + +@interface GRPCCall () +// Make them read-write. +@property(atomic, strong) NSDictionary *responseHeaders; +@property(atomic, strong) NSDictionary *responseTrailers; + +- (void)receiveNextMessages:(NSUInteger)numberOfMessages; + +@end + +// The following methods of a C gRPC call object aren't reentrant, and thus +// calls to them must be serialized: +// - start_batch +// - destroy +// +// start_batch with a SEND_MESSAGE argument can only be called after the +// OP_COMPLETE event for any previous write is received. This is achieved by +// pausing the requests writer immediately every time it writes a value, and +// resuming it again when OP_COMPLETE is received. +// +// Similarly, start_batch with a RECV_MESSAGE argument can only be called after +// the OP_COMPLETE event for any previous read is received.This is easier to +// enforce, as we're writing the received messages into the writeable: +// start_batch is enqueued once upon receiving the OP_COMPLETE event for the +// RECV_METADATA batch, and then once after receiving each OP_COMPLETE event for +// each RECV_MESSAGE batch. +@implementation GRPCCall { + dispatch_queue_t _callQueue; + + NSString *_host; + NSString *_path; + GRPCCallSafety _callSafety; + GRPCCallOptions *_callOptions; + GRPCWrappedCall *_wrappedCall; + + // The C gRPC library has less guarantees on the ordering of events than we + // do. Particularly, in the face of errors, there's no ordering guarantee at + // all. This wrapper over our actual writeable ensures thread-safety and + // correct ordering. + GRXConcurrentWriteable *_responseWriteable; + + // The network thread wants the requestWriter to resume (when the server is ready for more input), + // or to stop (on errors), concurrently with user threads that want to start it, pause it or stop + // it. Because a writer isn't thread-safe, we'll synchronize those operations on it. + // We don't use a dispatch queue for that purpose, because the writer can call writeValue: or + // writesFinishedWithError: on this GRPCCall as part of those operations. We want to be able to + // pause the writer immediately on writeValue:, so we need our locking to be recursive. + GRXWriter *_requestWriter; + + // To create a retain cycle when a call is started, up until it finishes. See + // |startWithWriteable:| and |finishWithError:|. This saves users from having to retain a + // reference to the call object if all they're interested in is the handler being executed when + // the response arrives. + GRPCCall *_retainSelf; + + GRPCRequestHeaders *_requestHeaders; + + // In the case that the call is a unary call (i.e. the writer to GRPCCall is of type + // GRXImmediateSingleWriter), GRPCCall will delay sending ops (not send them to C core + // immediately) and buffer them into a batch _unaryOpBatch. The batch is sent to C core when + // the SendClose op is added. + BOOL _unaryCall; + NSMutableArray *_unaryOpBatch; + + // The dispatch queue to be used for enqueuing responses to user. Defaulted to the main dispatch + // queue + dispatch_queue_t _responseQueue; + + // The OAuth2 token fetched from a token provider. + NSString *_fetchedOauth2AccessToken; + + // The callback to be called when a write message op is done. + void (^_writeDone)(void); + + // Indicate a read request to core is pending. + BOOL _pendingCoreRead; + + // Indicate pending read message request from user. + NSUInteger _pendingReceiveNextMessages; +} + +@synthesize state = _state; + ++ (void)initialize { + // Guarantees the code in {} block is invoked only once. See ref at: + // https://developer.apple.com/documentation/objectivec/nsobject/1418639-initialize?language=objc + if (self == [GRPCCall self]) { + grpc_init(); + callFlags = [NSMutableDictionary dictionary]; + } +} + ++ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path { + if (host.length == 0 || path.length == 0) { + return; + } + NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path]; + @synchronized(callFlags) { + switch (callSafety) { + case GRPCCallSafetyDefault: + callFlags[hostAndPath] = @0; + break; + case GRPCCallSafetyIdempotentRequest: + callFlags[hostAndPath] = @GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST; + break; + case GRPCCallSafetyCacheableRequest: + callFlags[hostAndPath] = @GRPC_INITIAL_METADATA_CACHEABLE_REQUEST; + break; + default: + break; + } + } +} + ++ (uint32_t)callFlagsForHost:(NSString *)host path:(NSString *)path { + NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path]; + @synchronized(callFlags) { + return [callFlags[hostAndPath] intValue]; + } +} + +- (instancetype)initWithHost:(NSString *)host + path:(NSString *)path + requestsWriter:(GRXWriter *)requestWriter { + return [self initWithHost:host + path:path + callSafety:GRPCCallSafetyDefault + requestsWriter:requestWriter + callOptions:nil + writeDone:nil]; +} + +- (instancetype)initWithHost:(NSString *)host + path:(NSString *)path + callSafety:(GRPCCallSafety)safety + requestsWriter:(GRXWriter *)requestsWriter + callOptions:(GRPCCallOptions *)callOptions + writeDone:(void (^)(void))writeDone { + // Purposely using pointer rather than length (host.length == 0) for backwards compatibility. + NSAssert(host != nil && path != nil, @"Neither host nor path can be nil."); + NSAssert(safety <= GRPCCallSafetyCacheableRequest, @"Invalid call safety value."); + NSAssert(requestsWriter.state == GRXWriterStateNotStarted, + @"The requests writer can't be already started."); + if (!host || !path) { + return nil; + } + if (safety > GRPCCallSafetyCacheableRequest) { + return nil; + } + if (requestsWriter.state != GRXWriterStateNotStarted) { + return nil; + } + + if ((self = [super init])) { + _host = [host copy]; + _path = [path copy]; + _callSafety = safety; + _callOptions = [callOptions copy]; + + // Serial queue to invoke the non-reentrant methods of the grpc_call object. + _callQueue = dispatch_queue_create("io.grpc.call", DISPATCH_QUEUE_SERIAL); + + _requestWriter = requestsWriter; + _requestHeaders = [[GRPCRequestHeaders alloc] initWithCall:self]; + _writeDone = writeDone; + + if ([requestsWriter isKindOfClass:[GRXImmediateSingleWriter class]]) { + _unaryCall = YES; + _unaryOpBatch = [NSMutableArray arrayWithCapacity:kMaxClientBatch]; + } + + _responseQueue = dispatch_get_main_queue(); + + // do not start a read until initial metadata is received + _pendingReceiveNextMessages = 0; + _pendingCoreRead = YES; + } + return self; +} + +- (void)setResponseDispatchQueue:(dispatch_queue_t)queue { + @synchronized(self) { + if (_state != GRXWriterStateNotStarted) { + return; + } + _responseQueue = queue; + } +} + +#pragma mark Finish + +// This function should support being called within a @synchronized(self) block in another function +// Should not manipulate _requestWriter for deadlock prevention. +- (void)finishWithError:(NSError *)errorOrNil { + @synchronized(self) { + if (_state == GRXWriterStateFinished) { + return; + } + _state = GRXWriterStateFinished; + + if (errorOrNil) { + [_responseWriteable cancelWithError:errorOrNil]; + } else { + [_responseWriteable enqueueSuccessfulCompletion]; + } + + // If the call isn't retained anywhere else, it can be deallocated now. + _retainSelf = nil; + } +} + +- (void)cancel { + @synchronized(self) { + if (_state == GRXWriterStateFinished) { + return; + } + [self finishWithError:[NSError + errorWithDomain:kGRPCErrorDomain + code:GRPCErrorCodeCancelled + userInfo:@{NSLocalizedDescriptionKey : @"Canceled by app"}]]; + [_wrappedCall cancel]; + } + _requestWriter.state = GRXWriterStateFinished; +} + +- (void)dealloc { + __block GRPCWrappedCall *wrappedCall = _wrappedCall; + dispatch_async(_callQueue, ^{ + wrappedCall = nil; + }); +} + +#pragma mark Read messages + +// Only called from the call queue. +// The handler will be called from the network queue. +- (void)startReadWithHandler:(void (^)(grpc_byte_buffer *))handler { + // TODO(jcanizales): Add error handlers for async failures + [_wrappedCall startBatchWithOperations:@[ [[GRPCOpRecvMessage alloc] initWithHandler:handler] ]]; +} + +// Called initially from the network queue once response headers are received, +// then "recursively" from the responseWriteable queue after each response from the +// server has been written. +// If the call is currently paused, this is a noop. Restarting the call will invoke this +// method. +// TODO(jcanizales): Rename to readResponseIfNotPaused. +- (void)maybeStartNextRead { + @synchronized(self) { + if (_state != GRXWriterStateStarted) { + return; + } + if (_callOptions.flowControlEnabled && (_pendingCoreRead || _pendingReceiveNextMessages == 0)) { + return; + } + _pendingCoreRead = YES; + _pendingReceiveNextMessages--; + } + + dispatch_async(_callQueue, ^{ + __weak GRPCCall *weakSelf = self; + [self startReadWithHandler:^(grpc_byte_buffer *message) { + if (message == NULL) { + // No more messages from the server + return; + } + __strong GRPCCall *strongSelf = weakSelf; + if (strongSelf == nil) { + grpc_byte_buffer_destroy(message); + return; + } + NSData *data = [NSData grpc_dataWithByteBuffer:message]; + grpc_byte_buffer_destroy(message); + if (!data) { + // The app doesn't have enough memory to hold the server response. We + // don't want to throw, because the app shouldn't crash for a behavior + // that's on the hands of any server to have. Instead we finish and ask + // the server to cancel. + @synchronized(strongSelf) { + strongSelf->_pendingCoreRead = NO; + [strongSelf + finishWithError:[NSError errorWithDomain:kGRPCErrorDomain + code:GRPCErrorCodeResourceExhausted + userInfo:@{ + NSLocalizedDescriptionKey : + @"Client does not have enough memory to " + @"hold the server response." + }]]; + [strongSelf->_wrappedCall cancel]; + } + strongSelf->_requestWriter.state = GRXWriterStateFinished; + } else { + @synchronized(strongSelf) { + [strongSelf->_responseWriteable enqueueValue:data + completionHandler:^{ + __strong GRPCCall *strongSelf = weakSelf; + if (strongSelf) { + @synchronized(strongSelf) { + strongSelf->_pendingCoreRead = NO; + [strongSelf maybeStartNextRead]; + } + } + }]; + } + } + }]; + }); +} + +#pragma mark Send headers + +- (void)sendHeaders { + // TODO (mxyan): Remove after deprecated methods are removed + uint32_t callSafetyFlags = 0; + switch (_callSafety) { + case GRPCCallSafetyDefault: + callSafetyFlags = 0; + break; + case GRPCCallSafetyIdempotentRequest: + callSafetyFlags = GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST; + break; + case GRPCCallSafetyCacheableRequest: + callSafetyFlags = GRPC_INITIAL_METADATA_CACHEABLE_REQUEST; + break; + } + + NSMutableDictionary *headers = [_requestHeaders mutableCopy]; + NSString *fetchedOauth2AccessToken; + @synchronized(self) { + fetchedOauth2AccessToken = _fetchedOauth2AccessToken; + } + if (fetchedOauth2AccessToken != nil) { + headers[@"authorization"] = [kBearerPrefix stringByAppendingString:fetchedOauth2AccessToken]; + } else if (_callOptions.oauth2AccessToken != nil) { + headers[@"authorization"] = + [kBearerPrefix stringByAppendingString:_callOptions.oauth2AccessToken]; + } + + // TODO(jcanizales): Add error handlers for async failures + GRPCOpSendMetadata *op = [[GRPCOpSendMetadata alloc] + initWithMetadata:headers + flags:callSafetyFlags + handler:nil]; // No clean-up needed after SEND_INITIAL_METADATA + dispatch_async(_callQueue, ^{ + if (!self->_unaryCall) { + [self->_wrappedCall startBatchWithOperations:@[ op ]]; + } else { + [self->_unaryOpBatch addObject:op]; + } + }); +} + +- (void)receiveNextMessages:(NSUInteger)numberOfMessages { + if (numberOfMessages == 0) { + return; + } + @synchronized(self) { + _pendingReceiveNextMessages += numberOfMessages; + + if (_state != GRXWriterStateStarted || !_callOptions.flowControlEnabled) { + return; + } + [self maybeStartNextRead]; + } +} + +#pragma mark GRXWriteable implementation + +// Only called from the call queue. The error handler will be called from the +// network queue if the write didn't succeed. +// If the call is a unary call, parameter \a errorHandler will be ignored and +// the error handler of GRPCOpSendClose will be executed in case of error. +- (void)writeMessage:(NSData *)message withErrorHandler:(void (^)(void))errorHandler { + __weak GRPCCall *weakSelf = self; + void (^resumingHandler)(void) = ^{ + // Resume the request writer. + GRPCCall *strongSelf = weakSelf; + if (strongSelf) { + strongSelf->_requestWriter.state = GRXWriterStateStarted; + if (strongSelf->_writeDone) { + strongSelf->_writeDone(); + } + } + }; + GRPCOpSendMessage *op = + [[GRPCOpSendMessage alloc] initWithMessage:message handler:resumingHandler]; + if (!_unaryCall) { + [_wrappedCall startBatchWithOperations:@[ op ] errorHandler:errorHandler]; + } else { + // Ignored errorHandler since it is the same as the one for GRPCOpSendClose. + // TODO (mxyan): unify the error handlers of all Ops into a single closure. + [_unaryOpBatch addObject:op]; + } +} + +- (void)writeValue:(id)value { + NSAssert([value isKindOfClass:[NSData class]], @"value must be of type NSData"); + + @synchronized(self) { + if (_state == GRXWriterStateFinished) { + return; + } + } + + // Pause the input and only resume it when the C layer notifies us that writes + // can proceed. + _requestWriter.state = GRXWriterStatePaused; + + dispatch_async(_callQueue, ^{ + // Write error is not processed here. It is handled by op batch of GRPC_OP_RECV_STATUS_ON_CLIENT + [self writeMessage:value withErrorHandler:nil]; + }); +} + +// Only called from the call queue. The error handler will be called from the +// network queue if the requests stream couldn't be closed successfully. +- (void)finishRequestWithErrorHandler:(void (^)(void))errorHandler { + if (!_unaryCall) { + [_wrappedCall startBatchWithOperations:@[ [[GRPCOpSendClose alloc] init] ] + errorHandler:errorHandler]; + } else { + [_unaryOpBatch addObject:[[GRPCOpSendClose alloc] init]]; + [_wrappedCall startBatchWithOperations:_unaryOpBatch errorHandler:errorHandler]; + } +} + +- (void)writesFinishedWithError:(NSError *)errorOrNil { + if (errorOrNil) { + [self cancel]; + } else { + dispatch_async(_callQueue, ^{ + // EOS error is not processed here. It is handled by op batch of GRPC_OP_RECV_STATUS_ON_CLIENT + [self finishRequestWithErrorHandler:nil]; + }); + } +} + +#pragma mark Invoke + +// Both handlers will eventually be called, from the network queue. Writes can start immediately +// after this. +// The first one (headersHandler), when the response headers are received. +// The second one (completionHandler), whenever the RPC finishes for any reason. +- (void)invokeCallWithHeadersHandler:(void (^)(NSDictionary *))headersHandler + completionHandler:(void (^)(NSError *, NSDictionary *))completionHandler { + dispatch_async(_callQueue, ^{ + // TODO(jcanizales): Add error handlers for async failures + [self->_wrappedCall + startBatchWithOperations:@[ [[GRPCOpRecvMetadata alloc] initWithHandler:headersHandler] ]]; + [self->_wrappedCall + startBatchWithOperations:@[ [[GRPCOpRecvStatus alloc] initWithHandler:completionHandler] ]]; + }); +} + +- (void)invokeCall { + __weak GRPCCall *weakSelf = self; + [self invokeCallWithHeadersHandler:^(NSDictionary *headers) { + // Response headers received. + __strong GRPCCall *strongSelf = weakSelf; + if (strongSelf) { + @synchronized(strongSelf) { + // it is ok to set nil because headers are only received once + strongSelf.responseHeaders = nil; + // copy the header so that the GRPCOpRecvMetadata object may be dealloc'ed + NSDictionary *copiedHeaders = + [[NSDictionary alloc] initWithDictionary:headers copyItems:YES]; + strongSelf.responseHeaders = copiedHeaders; + strongSelf->_pendingCoreRead = NO; + [strongSelf maybeStartNextRead]; + } + } + } + completionHandler:^(NSError *error, NSDictionary *trailers) { + __strong GRPCCall *strongSelf = weakSelf; + if (strongSelf) { + strongSelf.responseTrailers = trailers; + + if (error) { + NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; + if (error.userInfo) { + [userInfo addEntriesFromDictionary:error.userInfo]; + } + userInfo[kGRPCTrailersKey] = strongSelf.responseTrailers; + // Since gRPC core does not guarantee the headers block being called before this block, + // responseHeaders might be nil. + userInfo[kGRPCHeadersKey] = strongSelf.responseHeaders; + error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo]; + } + [strongSelf finishWithError:error]; + strongSelf->_requestWriter.state = GRXWriterStateFinished; + } + }]; +} + +#pragma mark GRXWriter implementation + +// Lock acquired inside startWithWriteable: +- (void)startCallWithWriteable:(id)writeable { + @synchronized(self) { + if (_state == GRXWriterStateFinished) { + return; + } + + _responseWriteable = + [[GRXConcurrentWriteable alloc] initWithWriteable:writeable dispatchQueue:_responseQueue]; + + GRPCPooledChannel *channel = + [[GRPCChannelPool sharedInstance] channelWithHost:_host callOptions:_callOptions]; + _wrappedCall = [channel wrappedCallWithPath:_path + completionQueue:[GRPCCompletionQueue completionQueue] + callOptions:_callOptions]; + + if (_wrappedCall == nil) { + [self finishWithError:[NSError errorWithDomain:kGRPCErrorDomain + code:GRPCErrorCodeUnavailable + userInfo:@{ + NSLocalizedDescriptionKey : + @"Failed to create call or channel." + }]]; + return; + } + + [self sendHeaders]; + [self invokeCall]; + } + + // Now that the RPC has been initiated, request writes can start. + [_requestWriter startWithWriteable:self]; +} + +- (void)startWithWriteable:(id)writeable { + id tokenProvider = nil; + @synchronized(self) { + _state = GRXWriterStateStarted; + + // Create a retain cycle so that this instance lives until the RPC finishes (or is cancelled). + // This makes RPCs in which the call isn't externally retained possible (as long as it is + // started before being autoreleased). Care is taken not to retain self strongly in any of the + // blocks used in this implementation, so that the life of the instance is determined by this + // retain cycle. + _retainSelf = self; + + // If _callOptions is nil, people must be using the deprecated v1 interface. In this case, + // generate the call options from the corresponding GRPCHost configs and apply other options + // that are not covered by GRPCHost. + if (_callOptions == nil) { + GRPCMutableCallOptions *callOptions = [[GRPCHost callOptionsForHost:_host] mutableCopy]; + if (_serverName.length != 0) { + callOptions.serverAuthority = _serverName; + } + if (_timeout > 0) { + callOptions.timeout = _timeout; + } + uint32_t callFlags = [GRPCCall callFlagsForHost:_host path:_path]; + if (callFlags != 0) { + if (callFlags == GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) { + _callSafety = GRPCCallSafetyIdempotentRequest; + } else if (callFlags == GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) { + _callSafety = GRPCCallSafetyCacheableRequest; + } + } + + id tokenProvider = self.tokenProvider; + if (tokenProvider != nil) { + callOptions.authTokenProvider = tokenProvider; + } + _callOptions = callOptions; + } + + NSAssert(_callOptions.authTokenProvider == nil || _callOptions.oauth2AccessToken == nil, + @"authTokenProvider and oauth2AccessToken cannot be set at the same time"); + + tokenProvider = _callOptions.authTokenProvider; + } + + if (tokenProvider != nil) { + __weak typeof(self) weakSelf = self; + [tokenProvider getTokenWithHandler:^(NSString *token) { + __strong typeof(self) strongSelf = weakSelf; + if (strongSelf) { + BOOL startCall = NO; + @synchronized(strongSelf) { + if (strongSelf->_state != GRXWriterStateFinished) { + startCall = YES; + if (token) { + strongSelf->_fetchedOauth2AccessToken = [token copy]; + } + } + } + if (startCall) { + [strongSelf startCallWithWriteable:writeable]; + } + } + }]; + } else { + [self startCallWithWriteable:writeable]; + } +} + +- (void)setState:(GRXWriterState)newState { + @synchronized(self) { + // Manual transitions are only allowed from the started or paused states. + if (_state == GRXWriterStateNotStarted || _state == GRXWriterStateFinished) { + return; + } + + switch (newState) { + case GRXWriterStateFinished: + _state = newState; + // Per GRXWriter's contract, setting the state to Finished manually + // means one doesn't wish the writeable to be messaged anymore. + [_responseWriteable cancelSilently]; + _responseWriteable = nil; + return; + case GRXWriterStatePaused: + _state = newState; + return; + case GRXWriterStateStarted: + if (_state == GRXWriterStatePaused) { + _state = newState; + [self maybeStartNextRead]; + } + return; + case GRXWriterStateNotStarted: + return; + } + } +} + +@end diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.h b/src/objective-c/GRPCClient/GRPCCallOptions.h index 98511e3f5cb..e4261b5b5f9 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.h +++ b/src/objective-c/GRPCClient/GRPCCallOptions.h @@ -18,57 +18,11 @@ #import +#import "GRPCTypes.h" + NS_ASSUME_NONNULL_BEGIN -/** - * Safety remark of a gRPC method as defined in RFC 2616 Section 9.1 - */ -typedef NS_ENUM(NSUInteger, GRPCCallSafety) { - /** Signal that there is no guarantees on how the call affects the server state. */ - GRPCCallSafetyDefault = 0, - /** Signal that the call is idempotent. gRPC is free to use PUT verb. */ - GRPCCallSafetyIdempotentRequest = 1, - /** - * Signal that the call is cacheable and will not affect server state. gRPC is free to use GET - * verb. - */ - GRPCCallSafetyCacheableRequest = 2, -}; - -// Compression algorithm to be used by a gRPC call -typedef NS_ENUM(NSUInteger, GRPCCompressionAlgorithm) { - GRPCCompressNone = 0, - GRPCCompressDeflate, - GRPCCompressGzip, - GRPCStreamCompressGzip, -}; - -// GRPCCompressAlgorithm is deprecated; use GRPCCompressionAlgorithm -typedef GRPCCompressionAlgorithm GRPCCompressAlgorithm; - -/** The transport to be used by a gRPC call */ -typedef NS_ENUM(NSUInteger, GRPCTransportType) { - GRPCTransportTypeDefault = 0, - /** gRPC internal HTTP/2 stack with BoringSSL */ - GRPCTransportTypeChttp2BoringSSL = 0, - /** Cronet stack */ - GRPCTransportTypeCronet, - /** Insecure channel. FOR TEST ONLY! */ - GRPCTransportTypeInsecure, -}; - -/** - * Implement this protocol to provide a token to gRPC when a call is initiated. - */ -@protocol GRPCAuthorizationProtocol - -/** - * This method is called when gRPC is about to start the call. When OAuth token is acquired, - * \a handler is expected to be called with \a token being the new token to be used for this call. - */ -- (void)getTokenWithHandler:(void (^)(NSString *_Nullable token))handler; - -@end +@protocol GRPCInterceptorFactory; @interface GRPCCallOptions : NSObject @@ -104,7 +58,7 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { * this array. This parameter should not be modified by any interceptor and will * not take effect if done so. */ -@property(copy, readonly) NSArray *interceptorFactories; +@property(copy, readonly) NSArray> *interceptorFactories; // OAuth2 parameters. Users of gRPC may specify one of the following two parameters. @@ -192,10 +146,23 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { @property(copy, readonly, nullable) NSString *PEMCertificateChain; /** + * Deprecated: this option is deprecated. Please use the property \a transport + * instead. + * * Select the transport type to be used for this call. */ @property(readonly) GRPCTransportType transportType; +/** + * The transport to be used for this call. Users may choose a native transport + * identifier defined in \a GRPCTransport or provided by a non-native transport + * implementation. If the option is left to be NULL, gRPC will use its default + * transport. + * + * This is currently an experimental option. + */ +@property(readonly) GRPCTransportId transport; + /** * Override the hostname during the TLS hostname validation process. */ @@ -267,7 +234,7 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { * this array. This parameter should not be modified by any interceptor and will * not take effect if done so. */ -@property(copy, readwrite) NSArray *interceptorFactories; +@property(copy, readwrite) NSArray> *interceptorFactories; // OAuth2 parameters. Users of gRPC may specify one of the following two parameters. @@ -357,10 +324,23 @@ typedef NS_ENUM(NSUInteger, GRPCTransportType) { @property(copy, readwrite, nullable) NSString *PEMCertificateChain; /** + * Deprecated: this option is deprecated. Please use the property \a transport + * instead. + * * Select the transport type to be used for this call. */ @property(readwrite) GRPCTransportType transportType; +/** + * The transport to be used for this call. Users may choose a native transport + * identifier defined in \a GRPCTransport or provided by a non-native ttransport + * implementation. If the option is left to be NULL, gRPC will use its default + * transport. + * + * An interceptor must not change the value of this option. + */ +@property(readwrite) GRPCTransportId transport; + /** * Override the hostname during the TLS hostname validation process. */ diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.m b/src/objective-c/GRPCClient/GRPCCallOptions.m index 392e42a9d47..7f88098eb6f 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.m +++ b/src/objective-c/GRPCClient/GRPCCallOptions.m @@ -17,13 +17,14 @@ */ #import "GRPCCallOptions.h" +#import "GRPCTransport.h" #import "internal/GRPCCallOptions+Internal.h" // The default values for the call options. static NSString *const kDefaultServerAuthority = nil; static const NSTimeInterval kDefaultTimeout = 0; static const BOOL kDefaultFlowControlEnabled = NO; -static NSArray *const kDefaultInterceptorFactories = nil; +static NSArray> *const kDefaultInterceptorFactories = nil; static NSDictionary *const kDefaultInitialMetadata = nil; static NSString *const kDefaultUserAgentPrefix = nil; static const NSUInteger kDefaultResponseSizeLimit = 0; @@ -41,6 +42,7 @@ static NSString *const kDefaultPEMCertificateChain = nil; static NSString *const kDefaultOauth2AccessToken = nil; static const id kDefaultAuthTokenProvider = nil; static const GRPCTransportType kDefaultTransportType = GRPCTransportTypeChttp2BoringSSL; +static const GRPCTransportId kDefaultTransport = NULL; static NSString *const kDefaultHostNameOverride = nil; static const id kDefaultLogContext = nil; static NSString *const kDefaultChannelPoolDomain = nil; @@ -62,7 +64,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { NSString *_serverAuthority; NSTimeInterval _timeout; BOOL _flowControlEnabled; - NSArray *_interceptorFactories; + NSArray> *_interceptorFactories; NSString *_oauth2AccessToken; id _authTokenProvider; NSDictionary *_initialMetadata; @@ -80,6 +82,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { NSString *_PEMPrivateKey; NSString *_PEMCertificateChain; GRPCTransportType _transportType; + GRPCTransportId _transport; NSString *_hostNameOverride; id _logContext; NSString *_channelPoolDomain; @@ -107,6 +110,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { @synthesize PEMPrivateKey = _PEMPrivateKey; @synthesize PEMCertificateChain = _PEMCertificateChain; @synthesize transportType = _transportType; +@synthesize transport = _transport; @synthesize hostNameOverride = _hostNameOverride; @synthesize logContext = _logContext; @synthesize channelPoolDomain = _channelPoolDomain; @@ -134,6 +138,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:kDefaultPEMPrivateKey PEMCertificateChain:kDefaultPEMCertificateChain transportType:kDefaultTransportType + transport:kDefaultTransport hostNameOverride:kDefaultHostNameOverride logContext:kDefaultLogContext channelPoolDomain:kDefaultChannelPoolDomain @@ -143,7 +148,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { - (instancetype)initWithServerAuthority:(NSString *)serverAuthority timeout:(NSTimeInterval)timeout flowControlEnabled:(BOOL)flowControlEnabled - interceptorFactories:(NSArray *)interceptorFactories + interceptorFactories:(NSArray> *)interceptorFactories oauth2AccessToken:(NSString *)oauth2AccessToken authTokenProvider:(id)authTokenProvider initialMetadata:(NSDictionary *)initialMetadata @@ -161,6 +166,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:(NSString *)PEMPrivateKey PEMCertificateChain:(NSString *)PEMCertificateChain transportType:(GRPCTransportType)transportType + transport:(GRPCTransportId)transport hostNameOverride:(NSString *)hostNameOverride logContext:(id)logContext channelPoolDomain:(NSString *)channelPoolDomain @@ -193,6 +199,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { _PEMPrivateKey = [PEMPrivateKey copy]; _PEMCertificateChain = [PEMCertificateChain copy]; _transportType = transportType; + _transport = transport; _hostNameOverride = [hostNameOverride copy]; _logContext = logContext; _channelPoolDomain = [channelPoolDomain copy]; @@ -224,6 +231,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:_PEMPrivateKey PEMCertificateChain:_PEMCertificateChain transportType:_transportType + transport:_transport hostNameOverride:_hostNameOverride logContext:_logContext channelPoolDomain:_channelPoolDomain @@ -256,6 +264,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:[_PEMPrivateKey copy] PEMCertificateChain:[_PEMCertificateChain copy] transportType:_transportType + transport:_transport hostNameOverride:[_hostNameOverride copy] logContext:_logContext channelPoolDomain:[_channelPoolDomain copy] @@ -280,6 +289,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { if (!areObjectsEqual(callOptions.PEMCertificateChain, _PEMCertificateChain)) return NO; if (!areObjectsEqual(callOptions.hostNameOverride, _hostNameOverride)) return NO; if (!(callOptions.transportType == _transportType)) return NO; + if (!(TransportIdIsEqual(callOptions.transport, _transport))) return NO; if (!areObjectsEqual(callOptions.logContext, _logContext)) return NO; if (!areObjectsEqual(callOptions.channelPoolDomain, _channelPoolDomain)) return NO; if (!(callOptions.channelID == _channelID)) return NO; @@ -304,6 +314,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { result ^= _PEMCertificateChain.hash; result ^= _hostNameOverride.hash; result ^= _transportType; + result ^= TransportIdHash(_transport); result ^= _logContext.hash; result ^= _channelPoolDomain.hash; result ^= _channelID; @@ -336,6 +347,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { @dynamic PEMPrivateKey; @dynamic PEMCertificateChain; @dynamic transportType; +@dynamic transport; @dynamic hostNameOverride; @dynamic logContext; @dynamic channelPoolDomain; @@ -363,6 +375,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:kDefaultPEMPrivateKey PEMCertificateChain:kDefaultPEMCertificateChain transportType:kDefaultTransportType + transport:kDefaultTransport hostNameOverride:kDefaultHostNameOverride logContext:kDefaultLogContext channelPoolDomain:kDefaultChannelPoolDomain @@ -392,6 +405,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:_PEMPrivateKey PEMCertificateChain:_PEMCertificateChain transportType:_transportType + transport:_transport hostNameOverride:_hostNameOverride logContext:_logContext channelPoolDomain:_channelPoolDomain @@ -422,6 +436,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:_PEMPrivateKey PEMCertificateChain:_PEMCertificateChain transportType:_transportType + transport:_transport hostNameOverride:_hostNameOverride logContext:_logContext channelPoolDomain:_channelPoolDomain @@ -445,7 +460,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { _flowControlEnabled = flowControlEnabled; } -- (void)setInterceptorFactories:(NSArray *)interceptorFactories { +- (void)setInterceptorFactories:(NSArray> *)interceptorFactories { _interceptorFactories = interceptorFactories; } @@ -538,6 +553,10 @@ static BOOL areObjectsEqual(id obj1, id obj2) { _transportType = transportType; } +- (void)setTransport:(GRPCTransportId)transport { + _transport = transport; +} + - (void)setHostNameOverride:(NSString *)hostNameOverride { _hostNameOverride = [hostNameOverride copy]; } diff --git a/src/objective-c/GRPCClient/GRPCDispatchable.h b/src/objective-c/GRPCClient/GRPCDispatchable.h new file mode 100644 index 00000000000..650103603d4 --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCDispatchable.h @@ -0,0 +1,30 @@ + +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/** + * An object that processes its methods with a dispatch queue. + */ +@protocol GRPCDispatchable + +/** + * The dispatch queue where the object's methods should be run on. + */ +@property(atomic, readonly) dispatch_queue_t dispatchQueue; + +@end diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.h b/src/objective-c/GRPCClient/GRPCInterceptor.h index 3b62c1b3ec0..509749769b3 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.h +++ b/src/objective-c/GRPCClient/GRPCInterceptor.h @@ -106,22 +106,20 @@ */ #import "GRPCCall.h" +#import "GRPCDispatchable.h" NS_ASSUME_NONNULL_BEGIN @class GRPCInterceptorManager; @class GRPCInterceptor; +@class GRPCRequestOptions; +@class GRPCCallOptions; +@protocol GRPCResponseHandler; /** * The GRPCInterceptorInterface defines the request events that can occur to an interceptr. */ -@protocol GRPCInterceptorInterface - -/** - * The queue on which all methods of this interceptor should be dispatched on. The queue must be a - * serial queue. - */ -@property(readonly) dispatch_queue_t requestDispatchQueue; +@protocol GRPCInterceptorInterface /** * To start the call. This method will only be called once for each instance. @@ -171,19 +169,20 @@ NS_ASSUME_NONNULL_BEGIN * invoke shutDown method of its corresponding manager so that references to other interceptors can * be released. */ -@interface GRPCInterceptorManager : NSObject +@interface GRPCInterceptorManager : NSObject - (instancetype)init NS_UNAVAILABLE; + (instancetype) new NS_UNAVAILABLE; -- (nullable instancetype)initWithNextInterceptor:(id)nextInterceptor - NS_DESIGNATED_INITIALIZER; +- (nullable instancetype)initWithFactories:(nullable NSArray> *)factories + previousInterceptor:(nullable id)previousInterceptor + transportId:(GRPCTransportId)transportId; -/** Set the previous interceptor in the chain. Can only be set once. */ -- (void)setPreviousInterceptor:(id)previousInterceptor; - -/** Indicate shutdown of the interceptor; release the reference to other interceptors */ +/** + * Notify the manager that the interceptor has shut down and the manager should release references + * to other interceptors and stop forwarding requests/responses. + */ - (void)shutDown; // Methods to forward GRPCInterceptorInterface calls to the next interceptor @@ -235,7 +234,6 @@ NS_ASSUME_NONNULL_BEGIN @interface GRPCInterceptor : NSObject - (instancetype)init NS_UNAVAILABLE; - + (instancetype) new NS_UNAVAILABLE; /** @@ -243,9 +241,7 @@ NS_ASSUME_NONNULL_BEGIN * that this interceptor's methods are dispatched onto. */ - (nullable instancetype)initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - requestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue - NS_DESIGNATED_INITIALIZER; + dispatchQueue:(dispatch_queue_t)dispatchQueue; // Default implementation of GRPCInterceptorInterface diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.m b/src/objective-c/GRPCClient/GRPCInterceptor.m index a385ecd7813..a7ffe05bddc 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.m +++ b/src/objective-c/GRPCClient/GRPCInterceptor.m @@ -19,117 +19,253 @@ #import #import "GRPCInterceptor.h" +#import "private/GRPCTransport+Private.h" + +@interface GRPCInterceptorManager () + +@end @implementation GRPCInterceptorManager { id _nextInterceptor; id _previousInterceptor; + GRPCInterceptor *_thisInterceptor; + dispatch_queue_t _dispatchQueue; + NSArray> *_factories; + GRPCTransportId _transportId; + BOOL _shutDown; } -- (instancetype)initWithNextInterceptor:(id)nextInterceptor { +- (instancetype)initWithFactories:(NSArray> *)factories + previousInterceptor:(id)previousInterceptor + transportId:(nonnull GRPCTransportId)transportId { if ((self = [super init])) { - _nextInterceptor = nextInterceptor; + if (factories.count == 0) { + [NSException raise:NSInternalInconsistencyException + format:@"Interceptor manager must have factories"]; + } + _thisInterceptor = [factories[0] createInterceptorWithManager:self]; + if (_thisInterceptor == nil) { + return nil; + } + _previousInterceptor = previousInterceptor; + _factories = factories; + // Generate interceptor +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 + if (@available(iOS 8.0, macOS 10.10, *)) { + _dispatchQueue = dispatch_queue_create( + NULL, + dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); + } else { +#else + { +#endif + _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); + } + dispatch_set_target_queue(_dispatchQueue, _thisInterceptor.dispatchQueue); + _transportId = transportId; } - return self; } -- (void)setPreviousInterceptor:(id)previousInterceptor { - _previousInterceptor = previousInterceptor; +- (void)shutDown { + dispatch_async(_dispatchQueue, ^{ + self->_nextInterceptor = nil; + self->_previousInterceptor = nil; + self->_thisInterceptor = nil; + self->_shutDown = YES; + }); } -- (void)shutDown { - _nextInterceptor = nil; - _previousInterceptor = nil; +- (void)createNextInterceptor { + NSAssert(_nextInterceptor == nil, @"Starting the next interceptor more than once"); + NSAssert(_factories.count > 0, @"Interceptor manager of transport cannot start next interceptor"); + if (_nextInterceptor != nil) { + NSLog(@"Starting the next interceptor more than once"); + return; + } + NSMutableArray> *interceptorFactories = [NSMutableArray + arrayWithArray:[_factories subarrayWithRange:NSMakeRange(1, _factories.count - 1)]]; + while (_nextInterceptor == nil) { + if (interceptorFactories.count == 0) { + _nextInterceptor = + [[GRPCTransportManager alloc] initWithTransportId:_transportId previousInterceptor:self]; + break; + } else { + _nextInterceptor = [[GRPCInterceptorManager alloc] initWithFactories:interceptorFactories + previousInterceptor:self + transportId:_transportId]; + if (_nextInterceptor == nil) { + [interceptorFactories removeObjectAtIndex:0]; + } + } + } + NSAssert(_nextInterceptor != nil, @"Failed to create interceptor or transport."); + if (_nextInterceptor == nil) { + NSLog(@"Failed to create interceptor or transport."); + } } - (void)startNextInterceptorWithRequest:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { - if (_nextInterceptor != nil) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; - }); + if (_nextInterceptor == nil && !_shutDown) { + [self createNextInterceptor]; } + if (_nextInterceptor == nil) { + return; + } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ + [copiedNextInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; + }); } - (void)writeNextInterceptorWithData:(id)data { - if (_nextInterceptor != nil) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor writeData:data]; - }); + if (_nextInterceptor == nil && !_shutDown) { + [self createNextInterceptor]; } + if (_nextInterceptor == nil) { + return; + } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ + [copiedNextInterceptor writeData:data]; + }); } - (void)finishNextInterceptor { - if (_nextInterceptor != nil) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor finish]; - }); + if (_nextInterceptor == nil && !_shutDown) { + [self createNextInterceptor]; } + if (_nextInterceptor == nil) { + return; + } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ + [copiedNextInterceptor finish]; + }); } - (void)cancelNextInterceptor { - if (_nextInterceptor != nil) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor cancel]; - }); + if (_nextInterceptor == nil && !_shutDown) { + [self createNextInterceptor]; } + if (_nextInterceptor == nil) { + return; + } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ + [copiedNextInterceptor cancel]; + }); } /** Notify the next interceptor in the chain to receive more messages */ - (void)receiveNextInterceptorMessages:(NSUInteger)numberOfMessages { - if (_nextInterceptor != nil) { - id copiedNextInterceptor = _nextInterceptor; - dispatch_async(copiedNextInterceptor.requestDispatchQueue, ^{ - [copiedNextInterceptor receiveNextMessages:numberOfMessages]; - }); + if (_nextInterceptor == nil && !_shutDown) { + [self createNextInterceptor]; } + if (_nextInterceptor == nil) { + return; + } + id copiedNextInterceptor = _nextInterceptor; + dispatch_async(copiedNextInterceptor.dispatchQueue, ^{ + [copiedNextInterceptor receiveNextMessages:numberOfMessages]; + }); } // Methods to forward GRPCResponseHandler callbacks to the previous object /** Forward initial metadata to the previous interceptor in the chain */ -- (void)forwardPreviousInterceptorWithInitialMetadata:(nullable NSDictionary *)initialMetadata { - if ([_previousInterceptor respondsToSelector:@selector(didReceiveInitialMetadata:)]) { - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didReceiveInitialMetadata:initialMetadata]; - }); +- (void)forwardPreviousInterceptorWithInitialMetadata:(NSDictionary *)initialMetadata { + if (_previousInterceptor == nil) { + return; } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didReceiveInitialMetadata:initialMetadata]; + }); } /** Forward a received message to the previous interceptor in the chain */ - (void)forwardPreviousInterceptorWithData:(id)data { - if ([_previousInterceptor respondsToSelector:@selector(didReceiveData:)]) { - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didReceiveData:data]; - }); + if (_previousInterceptor == nil) { + return; } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didReceiveData:data]; + }); } /** Forward call close and trailing metadata to the previous interceptor in the chain */ -- (void)forwardPreviousInterceptorCloseWithTrailingMetadata: - (nullable NSDictionary *)trailingMetadata - error:(nullable NSError *)error { - if ([_previousInterceptor respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; - }); +- (void)forwardPreviousInterceptorCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata + error:(NSError *)error { + if (_previousInterceptor == nil) { + return; } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; + }); } /** Forward write completion to the previous interceptor in the chain */ - (void)forwardPreviousInterceptorDidWriteData { - if ([_previousInterceptor respondsToSelector:@selector(didWriteData)]) { - id copiedPreviousInterceptor = _previousInterceptor; - dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ - [copiedPreviousInterceptor didWriteData]; - }); + if (_previousInterceptor == nil) { + return; + } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didWriteData]; + }); +} + +- (dispatch_queue_t)dispatchQueue { + return _dispatchQueue; +} + +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions + callOptions:(GRPCCallOptions *)callOptions { + [_thisInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; +} + +- (void)writeData:(id)data { + [_thisInterceptor writeData:data]; +} + +- (void)finish { + [_thisInterceptor finish]; +} + +- (void)cancel { + [_thisInterceptor cancel]; +} + +- (void)receiveNextMessages:(NSUInteger)numberOfMessages { + [_thisInterceptor receiveNextMessages:numberOfMessages]; +} + +- (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata { + if ([_thisInterceptor respondsToSelector:@selector(didReceiveInitialMetadata:)]) { + [_thisInterceptor didReceiveInitialMetadata:initialMetadata]; + } +} + +- (void)didReceiveData:(id)data { + if ([_thisInterceptor respondsToSelector:@selector(didReceiveData:)]) { + [_thisInterceptor didReceiveData:data]; + } +} + +- (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata + error:(nullable NSError *)error { + if ([_thisInterceptor respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { + [_thisInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; + } +} + +- (void)didWriteData { + if ([_thisInterceptor respondsToSelector:@selector(didWriteData)]) { + [_thisInterceptor didWriteData]; } } @@ -137,28 +273,21 @@ @implementation GRPCInterceptor { GRPCInterceptorManager *_manager; - dispatch_queue_t _requestDispatchQueue; - dispatch_queue_t _responseDispatchQueue; + dispatch_queue_t _dispatchQueue; } - (instancetype)initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - requestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue { + dispatchQueue:(dispatch_queue_t)dispatchQueue { if ((self = [super init])) { _manager = interceptorManager; - _requestDispatchQueue = requestDispatchQueue; - _responseDispatchQueue = responseDispatchQueue; + _dispatchQueue = dispatchQueue; } return self; } -- (dispatch_queue_t)requestDispatchQueue { - return _requestDispatchQueue; -} - - (dispatch_queue_t)dispatchQueue { - return _responseDispatchQueue; + return _dispatchQueue; } - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions diff --git a/src/objective-c/GRPCClient/GRPCTransport.h b/src/objective-c/GRPCClient/GRPCTransport.h new file mode 100644 index 00000000000..d5637922152 --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCTransport.h @@ -0,0 +1,82 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// The interface for a transport implementation + +#import "GRPCInterceptor.h" + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark Transport ID + +/** + * The default transport implementations available in gRPC. These implementations will be provided + * by gRPC by default unless explicitly excluded. + */ +extern const struct GRPCDefaultTransportImplList { + const GRPCTransportId core_secure; + const GRPCTransportId core_insecure; +} GRPCDefaultTransportImplList; + +/** Returns whether two transport id's are identical. */ +BOOL TransportIdIsEqual(GRPCTransportId lhs, GRPCTransportId rhs); + +/** Returns the hash value of a transport id. */ +NSUInteger TransportIdHash(GRPCTransportId); + +#pragma mark Transport and factory + +@protocol GRPCInterceptorInterface; +@protocol GRPCResponseHandler; +@class GRPCTransportManager; +@class GRPCRequestOptions; +@class GRPCCallOptions; +@class GRPCTransport; + +/** The factory method to create a transport. */ +@protocol GRPCTransportFactory + +- (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager; + +@end + +/** The registry of transport implementations. */ +@interface GRPCTransportRegistry : NSObject + ++ (instancetype)sharedInstance; + +/** + * Register a transport implementation with the registry. All transport implementations to be used + * in a process must register with the registry on process start-up in its +load: class method. + * Parameter \a transportId is the identifier of the implementation, and \a factory is the factory + * object to create the corresponding transport instance. + */ +- (void)registerTransportWithId:(GRPCTransportId)transportId + factory:(id)factory; + +@end + +/** + * Base class for transport implementations. All transport implementation should inherit from this + * class. + */ +@interface GRPCTransport : NSObject + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/objective-c/GRPCClient/GRPCTransport.m b/src/objective-c/GRPCClient/GRPCTransport.m new file mode 100644 index 00000000000..439acfb9cc2 --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCTransport.m @@ -0,0 +1,142 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "GRPCTransport.h" + +static const GRPCTransportId gGRPCCoreSecureId = "io.grpc.transport.core.secure"; +static const GRPCTransportId gGRPCCoreInsecureId = "io.grpc.transport.core.insecure"; + +const struct GRPCDefaultTransportImplList GRPCDefaultTransportImplList = { + .core_secure = gGRPCCoreSecureId, .core_insecure = gGRPCCoreInsecureId}; + +static const GRPCTransportId gDefaultTransportId = gGRPCCoreSecureId; + +static GRPCTransportRegistry *gTransportRegistry = nil; +static dispatch_once_t initTransportRegistry; + +BOOL TransportIdIsEqual(GRPCTransportId lhs, GRPCTransportId rhs) { + // Directly comparing pointers works because we require users to use the id provided by each + // implementation, not coming up with their own string. + return lhs == rhs; +} + +NSUInteger TransportIdHash(GRPCTransportId transportId) { + if (transportId == NULL) { + transportId = gDefaultTransportId; + } + return [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding].hash; +} + +@implementation GRPCTransportRegistry { + NSMutableDictionary> *_registry; + id _defaultFactory; +} + ++ (instancetype)sharedInstance { + dispatch_once(&initTransportRegistry, ^{ + gTransportRegistry = [[GRPCTransportRegistry alloc] init]; + NSAssert(gTransportRegistry != nil, @"Unable to initialize transport registry."); + if (gTransportRegistry == nil) { + NSLog(@"Unable to initialize transport registry."); + [NSException raise:NSGenericException format:@"Unable to initialize transport registry."]; + } + }); + return gTransportRegistry; +} + +- (instancetype)init { + if ((self = [super init])) { + _registry = [NSMutableDictionary dictionary]; + } + return self; +} + +- (void)registerTransportWithId:(GRPCTransportId)transportId + factory:(id)factory { + NSString *nsTransportId = [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding]; + NSAssert(_registry[nsTransportId] == nil, @"The transport %@ has already been registered.", + nsTransportId); + if (_registry[nsTransportId] != nil) { + NSLog(@"The transport %@ has already been registered.", nsTransportId); + return; + } + _registry[nsTransportId] = factory; + + // if the default transport is registered, mark it. + if (0 == strcmp(transportId, gDefaultTransportId)) { + _defaultFactory = factory; + } +} + +- (id)getTransportFactoryWithId:(GRPCTransportId)transportId { + if (transportId == NULL) { + if (_defaultFactory == nil) { + [NSException raise:NSInvalidArgumentException + format:@"Unable to get default transport factory"]; + return nil; + } + return _defaultFactory; + } + NSString *nsTransportId = [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding]; + id transportFactory = _registry[nsTransportId]; + if (transportFactory == nil) { + // User named a transport id that was not registered with the registry. + [NSException raise:NSInvalidArgumentException + format:@"Unable to get transport factory with id %s", transportId]; + return nil; + } + return transportFactory; +} + +@end + +@implementation GRPCTransport + +- (dispatch_queue_t)dispatchQueue { + [NSException raise:NSGenericException + format:@"Implementations should override the dispatch queue"]; + return nil; +} + +- (void)startWithRequestOptions:(nonnull GRPCRequestOptions *)requestOptions + callOptions:(nonnull GRPCCallOptions *)callOptions { + [NSException raise:NSGenericException + format:@"Implementations should override the methods of GRPCTransport"]; +} + +- (void)writeData:(nonnull id)data { + [NSException raise:NSGenericException + format:@"Implementations should override the methods of GRPCTransport"]; +} + +- (void)cancel { + [NSException raise:NSGenericException + format:@"Implementations should override the methods of GRPCTransport"]; +} + +- (void)finish { + [NSException raise:NSGenericException + format:@"Implementations should override the methods of GRPCTransport"]; +} + +- (void)receiveNextMessages:(NSUInteger)numberOfMessages { + [NSException raise:NSGenericException + format:@"Implementations should override the methods of GRPCTransport"]; +} + +@end diff --git a/src/objective-c/GRPCClient/GRPCTypes.h b/src/objective-c/GRPCClient/GRPCTypes.h new file mode 100644 index 00000000000..c804bca4eaa --- /dev/null +++ b/src/objective-c/GRPCClient/GRPCTypes.h @@ -0,0 +1,187 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/** + * gRPC error codes. + * Note that a few of these are never produced by the gRPC libraries, but are of + * general utility for server applications to produce. + */ +typedef NS_ENUM(NSUInteger, GRPCErrorCode) { + /** The operation was cancelled (typically by the caller). */ + GRPCErrorCodeCancelled = 1, + + /** + * Unknown error. Errors raised by APIs that do not return enough error + * information may be converted to this error. + */ + GRPCErrorCodeUnknown = 2, + + /** + * The client specified an invalid argument. Note that this differs from + * FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments that are + * problematic regardless of the state of the server (e.g., a malformed file + * name). + */ + GRPCErrorCodeInvalidArgument = 3, + + /** + * Deadline expired before operation could complete. For operations that + * change the state of the server, this error may be returned even if the + * operation has completed successfully. For example, a successful response + * from the server could have been delayed long enough for the deadline to + * expire. + */ + GRPCErrorCodeDeadlineExceeded = 4, + + /** Some requested entity (e.g., file or directory) was not found. */ + GRPCErrorCodeNotFound = 5, + + /** Some entity that we attempted to create (e.g., file or directory) already + exists. */ + GRPCErrorCodeAlreadyExists = 6, + + /** + * The caller does not have permission to execute the specified operation. + * PERMISSION_DENIED isn't used for rejections caused by exhausting some + * resource (RESOURCE_EXHAUSTED is used instead for those errors). + * PERMISSION_DENIED doesn't indicate a failure to identify the caller + * (UNAUTHENTICATED is used instead for those errors). + */ + GRPCErrorCodePermissionDenied = 7, + + /** + * The request does not have valid authentication credentials for the + * operation (e.g. the caller's identity can't be verified). + */ + GRPCErrorCodeUnauthenticated = 16, + + /** Some resource has been exhausted, perhaps a per-user quota. */ + GRPCErrorCodeResourceExhausted = 8, + + /** + * The RPC was rejected because the server is not in a state required for the + * procedure's execution. For example, a directory to be deleted may be + * non-empty, etc. The client should not retry until the server state has been + * explicitly fixed (e.g. by performing another RPC). The details depend on + * the service being called, and should be found in the NSError's userInfo. + */ + GRPCErrorCodeFailedPrecondition = 9, + + /** + * The RPC was aborted, typically due to a concurrency issue like sequencer + * check failures, transaction aborts, etc. The client should retry at a + * higher-level (e.g., restarting a read- modify-write sequence). + */ + GRPCErrorCodeAborted = 10, + + /** + * The RPC was attempted past the valid range. E.g., enumerating past the end + * of a list. Unlike INVALID_ARGUMENT, this error indicates a problem that may + * be fixed if the system state changes. For example, an RPC to get elements + * of a list will generate INVALID_ARGUMENT if asked to return the element at + * a negative index, but it will generate OUT_OF_RANGE if asked to return the + * element at an index past the current size of the list. + */ + GRPCErrorCodeOutOfRange = 11, + + /** The procedure is not implemented or not supported/enabled in this server. + */ + GRPCErrorCodeUnimplemented = 12, + + /** + * Internal error. Means some invariant expected by the server application or + * the gRPC library has been broken. + */ + GRPCErrorCodeInternal = 13, + + /** + * The server is currently unavailable. This is most likely a transient + * condition and may be corrected by retrying with a backoff. Note that it is + * not always safe to retry non-idempotent operations. + */ + GRPCErrorCodeUnavailable = 14, + + /** Unrecoverable data loss or corruption. */ + GRPCErrorCodeDataLoss = 15, +}; + +/** + * Safety remark of a gRPC method as defined in RFC 2616 Section 9.1 + */ +typedef NS_ENUM(NSUInteger, GRPCCallSafety) { + /** + * Signal that there is no guarantees on how the call affects the server + * state. + */ + GRPCCallSafetyDefault = 0, + /** Signal that the call is idempotent. gRPC is free to use PUT verb. */ + GRPCCallSafetyIdempotentRequest = 1, + /** + * Signal that the call is cacheable and will not affect server state. gRPC is + * free to use GET verb. + */ + GRPCCallSafetyCacheableRequest = 2, +}; + +// Compression algorithm to be used by a gRPC call +typedef NS_ENUM(NSUInteger, GRPCCompressionAlgorithm) { + GRPCCompressNone = 0, + GRPCCompressDeflate, + GRPCCompressGzip, + GRPCStreamCompressGzip, +}; + +// GRPCCompressAlgorithm is deprecated; use GRPCCompressionAlgorithm +typedef GRPCCompressionAlgorithm GRPCCompressAlgorithm; + +/** The transport to be used by a gRPC call */ +typedef NS_ENUM(NSUInteger, GRPCTransportType) { + GRPCTransportTypeDefault = 0, + /** gRPC internal HTTP/2 stack with BoringSSL */ + GRPCTransportTypeChttp2BoringSSL = 0, + /** Cronet stack */ + GRPCTransportTypeCronet, + /** Insecure channel. FOR TEST ONLY! */ + GRPCTransportTypeInsecure, +}; + +/** Domain of NSError objects produced by gRPC. */ +extern NSString* _Nonnull const kGRPCErrorDomain; + +/** + * Keys used in |NSError|'s |userInfo| dictionary to store the response headers + * and trailers sent by the server. + */ +extern NSString* _Nonnull const kGRPCHeadersKey; +extern NSString* _Nonnull const kGRPCTrailersKey; + +/** The id of a transport implementation. */ +typedef char* _Nonnull GRPCTransportId; + +/** + * Implement this protocol to provide a token to gRPC when a call is initiated. + */ +@protocol GRPCAuthorizationProtocol + +/** + * This method is called when gRPC is about to start the call. When OAuth token is acquired, + * \a handler is expected to be called with \a token being the new token to be used for this call. + */ +- (void)getTokenWithHandler:(void (^_Nonnull)(NSString* _Nullable token))handler; + +@end diff --git a/src/objective-c/GRPCClient/internal_testing/GRPCCall+InternalTests.m b/src/objective-c/GRPCClient/internal_testing/GRPCCall+InternalTests.m index 1bb352f0be2..8f98daa6348 100644 --- a/src/objective-c/GRPCClient/internal_testing/GRPCCall+InternalTests.m +++ b/src/objective-c/GRPCClient/internal_testing/GRPCCall+InternalTests.m @@ -20,7 +20,7 @@ #import "GRPCCall+InternalTests.h" -#import "../private/GRPCOpBatchLog.h" +#import "../private/GRPCCore/GRPCOpBatchLog.h" @implementation GRPCCall (InternalTests) diff --git a/src/objective-c/GRPCClient/private/ChannelArgsUtil.h b/src/objective-c/GRPCClient/private/GRPCCore/ChannelArgsUtil.h similarity index 100% rename from src/objective-c/GRPCClient/private/ChannelArgsUtil.h rename to src/objective-c/GRPCClient/private/GRPCCore/ChannelArgsUtil.h diff --git a/src/objective-c/GRPCClient/private/ChannelArgsUtil.m b/src/objective-c/GRPCClient/private/GRPCCore/ChannelArgsUtil.m similarity index 100% rename from src/objective-c/GRPCClient/private/ChannelArgsUtil.m rename to src/objective-c/GRPCClient/private/GRPCCore/ChannelArgsUtil.m diff --git a/src/objective-c/GRPCClient/private/GRPCCall+V2API.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCall+V2API.h similarity index 79% rename from src/objective-c/GRPCClient/private/GRPCCall+V2API.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCall+V2API.h index 22bf16962c6..f6db3023cac 100644 --- a/src/objective-c/GRPCClient/private/GRPCCall+V2API.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCall+V2API.h @@ -18,12 +18,6 @@ @interface GRPCCall (V2API) -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - callSafety:(GRPCCallSafety)safety - requestsWriter:(GRXWriter *)requestsWriter - callOptions:(GRPCCallOptions *)callOptions; - - (instancetype)initWithHost:(NSString *)host path:(NSString *)path callSafety:(GRPCCallSafety)safety diff --git a/src/objective-c/GRPCClient/private/GRPCCallInternal.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.h similarity index 70% rename from src/objective-c/GRPCClient/private/GRPCCallInternal.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.h index ac2d1cba2ec..641b1fb2e8a 100644 --- a/src/objective-c/GRPCClient/private/GRPCCallInternal.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.h @@ -16,20 +16,22 @@ * */ -#import +#import NS_ASSUME_NONNULL_BEGIN -@interface GRPCCall2Internal : NSObject +@protocol GRPCResponseHandler; +@class GRPCCallOptions; +@protocol GRPCChannelFactory; -- (instancetype)init; +@interface GRPCCall2Internal : GRPCTransport -- (void)setResponseHandler:(id)responseHandler; +- (instancetype)initWithTransportManager:(GRPCTransportManager *)transportManager; - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions - callOptions:(nullable GRPCCallOptions *)callOptions; + callOptions:(GRPCCallOptions *)callOptions; -- (void)writeData:(NSData *)data; +- (void)writeData:(id)data; - (void)finish; diff --git a/src/objective-c/GRPCClient/private/GRPCCallInternal.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m similarity index 69% rename from src/objective-c/GRPCClient/private/GRPCCallInternal.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m index 32e38158fad..ea01fcaf594 100644 --- a/src/objective-c/GRPCClient/private/GRPCCallInternal.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m @@ -19,8 +19,10 @@ #import "GRPCCallInternal.h" #import +#import #import +#import "../GRPCTransport+Private.h" #import "GRPCCall+V2API.h" @implementation GRPCCall2Internal { @@ -28,8 +30,8 @@ GRPCRequestOptions *_requestOptions; /** Options for the call. */ GRPCCallOptions *_callOptions; - /** The handler of responses. */ - id _handler; + /** The interceptor manager to process responses. */ + GRPCTransportManager *_transportManager; /** * Make use of legacy GRPCCall to make calls. Nullified when call is finished. @@ -51,40 +53,28 @@ NSUInteger _pendingReceiveNextMessages; } -- (instancetype)init { - if ((self = [super init])) { +- (instancetype)initWithTransportManager:(GRPCTransportManager *)transportManager { + dispatch_queue_t dispatchQueue; // Set queue QoS only when iOS version is 8.0 or above and Xcode version is 9.0 or above #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 - if (@available(iOS 8.0, macOS 10.10, *)) { - _dispatchQueue = dispatch_queue_create( - NULL, - dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); - } else { + if (@available(iOS 8.0, macOS 10.10, *)) { + dispatchQueue = dispatch_queue_create( + NULL, dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0)); + } else { #else - { + { #endif - _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); - } + dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); + } + if ((self = [super init])) { _pipe = [GRXBufferedPipe pipe]; + _transportManager = transportManager; + _dispatchQueue = dispatchQueue; } return self; } -- (void)setResponseHandler:(id)responseHandler { - @synchronized(self) { - NSAssert(!_started, @"Call already started."); - if (_started) { - return; - } - _handler = responseHandler; - _initialMetadataPublished = NO; - _started = NO; - _canceled = NO; - _finished = NO; - } -} - -- (dispatch_queue_t)requestDispatchQueue { +- (dispatch_queue_t)dispatchQueue { return _dispatchQueue; } @@ -102,26 +92,15 @@ return; } + GRPCCall *copiedCall = nil; @synchronized(self) { - NSAssert(_handler != nil, @"Response handler required."); - if (_handler == nil) { - NSLog(@"Invalid response handler."); - return; - } _requestOptions = requestOptions; if (callOptions == nil) { _callOptions = [[GRPCCallOptions alloc] init]; } else { _callOptions = [callOptions copy]; } - } - [self start]; -} - -- (void)start { - GRPCCall *copiedCall = nil; - @synchronized(self) { NSAssert(!_started, @"Call already started."); NSAssert(!_canceled, @"Call already canceled."); if (_started) { @@ -140,7 +119,7 @@ callOptions:_callOptions writeDone:^{ @synchronized(self) { - if (self->_handler) { + if (self->_transportManager) { [self issueDidWriteData]; } } @@ -158,7 +137,7 @@ void (^valueHandler)(id value) = ^(id value) { @synchronized(self) { - if (self->_handler) { + if (self->_transportManager) { if (!self->_initialMetadataPublished) { self->_initialMetadataPublished = YES; [self issueInitialMetadata:self->_call.responseHeaders]; @@ -171,7 +150,7 @@ }; void (^completionHandler)(NSError *errorOrNil) = ^(NSError *errorOrNil) { @synchronized(self) { - if (self->_handler) { + if (self->_transportManager) { if (!self->_initialMetadataPublished) { self->_initialMetadataPublished = YES; [self issueInitialMetadata:self->_call.responseHeaders]; @@ -207,20 +186,19 @@ _call = nil; _pipe = nil; - if ([_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { - id copiedHandler = _handler; - _handler = nil; - dispatch_async(copiedHandler.dispatchQueue, ^{ - [copiedHandler didCloseWithTrailingMetadata:nil - error:[NSError errorWithDomain:kGRPCErrorDomain - code:GRPCErrorCodeCancelled - userInfo:@{ - NSLocalizedDescriptionKey : - @"Canceled by app" - }]]; - }); - } else { - _handler = nil; + if (_transportManager != nil) { + [_transportManager + forwardPreviousInterceptorCloseWithTrailingMetadata:nil + error: + [NSError + errorWithDomain:kGRPCErrorDomain + code: + GRPCErrorCodeCancelled + userInfo:@{ + NSLocalizedDescriptionKey : + @"Canceled by app" + }]]; + [_transportManager shutDown]; } } [copiedCall cancel]; @@ -271,59 +249,25 @@ } - (void)issueInitialMetadata:(NSDictionary *)initialMetadata { - @synchronized(self) { - if (initialMetadata != nil && - [_handler respondsToSelector:@selector(didReceiveInitialMetadata:)]) { - id copiedHandler = _handler; - dispatch_async(_handler.dispatchQueue, ^{ - [copiedHandler didReceiveInitialMetadata:initialMetadata]; - }); - } + if (initialMetadata != nil) { + [_transportManager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; } } - (void)issueMessage:(id)message { - @synchronized(self) { - if (message != nil) { - if ([_handler respondsToSelector:@selector(didReceiveData:)]) { - id copiedHandler = _handler; - dispatch_async(_handler.dispatchQueue, ^{ - [copiedHandler didReceiveData:message]; - }); - } else if ([_handler respondsToSelector:@selector(didReceiveRawMessage:)]) { - id copiedHandler = _handler; - dispatch_async(_handler.dispatchQueue, ^{ - [copiedHandler didReceiveRawMessage:message]; - }); - } - } + if (message != nil) { + [_transportManager forwardPreviousInterceptorWithData:message]; } } - (void)issueClosedWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { - @synchronized(self) { - if ([_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { - id copiedHandler = _handler; - // Clean up _handler so that no more responses are reported to the handler. - _handler = nil; - dispatch_async(copiedHandler.dispatchQueue, ^{ - [copiedHandler didCloseWithTrailingMetadata:trailingMetadata error:error]; - }); - } else { - _handler = nil; - } - } + [_transportManager forwardPreviousInterceptorCloseWithTrailingMetadata:trailingMetadata + error:error]; + [_transportManager shutDown]; } - (void)issueDidWriteData { - @synchronized(self) { - if (_callOptions.flowControlEnabled && [_handler respondsToSelector:@selector(didWriteData)]) { - id copiedHandler = _handler; - dispatch_async(copiedHandler.dispatchQueue, ^{ - [copiedHandler didWriteData]; - }); - } - } + [_transportManager forwardPreviousInterceptorDidWriteData]; } - (void)receiveNextMessages:(NSUInteger)numberOfMessages { diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCChannel.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.h diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m similarity index 78% rename from src/objective-c/GRPCClient/private/GRPCChannel.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m index 1a79fb04a0d..cd2b4313acd 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m @@ -20,18 +20,19 @@ #include -#import "../internal/GRPCCallOptions+Internal.h" +#import "../../internal/GRPCCallOptions+Internal.h" +#import "../GRPCTransport+Private.h" #import "ChannelArgsUtil.h" #import "GRPCChannelFactory.h" #import "GRPCChannelPool.h" #import "GRPCCompletionQueue.h" -#import "GRPCCronetChannelFactory.h" +#import "GRPCCoreFactory.h" #import "GRPCInsecureChannelFactory.h" #import "GRPCSecureChannelFactory.h" -#import "version.h" #import #import +#import @implementation GRPCChannelConfiguration @@ -50,32 +51,48 @@ } - (id)channelFactory { - GRPCTransportType type = _callOptions.transportType; - switch (type) { - case GRPCTransportTypeChttp2BoringSSL: - // TODO (mxyan): Remove when the API is deprecated -#ifdef GRPC_COMPILE_WITH_CRONET - if (![GRPCCall isUsingCronet]) { -#else - { -#endif - NSError *error; - id factory = [GRPCSecureChannelFactory - factoryWithPEMRootCertificates:_callOptions.PEMRootCertificates - privateKey:_callOptions.PEMPrivateKey - certChain:_callOptions.PEMCertificateChain - error:&error]; - NSAssert(factory != nil, @"Failed to create secure channel factory"); - if (factory == nil) { - NSLog(@"Error creating secure channel factory: %@", error); + if (_callOptions.transport != NULL) { + id transportFactory = + [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:_callOptions.transport]; + if (! + [transportFactory respondsToSelector:@selector(createCoreChannelFactoryWithCallOptions:)]) { + // impossible because we are using GRPCCore now + [NSException raise:NSInternalInconsistencyException + format:@"Transport factory type is wrong"]; + } + id coreTransportFactory = + (id)transportFactory; + return [coreTransportFactory createCoreChannelFactoryWithCallOptions:_callOptions]; + } else { + // To maintain backwards compatibility with tranportType + GRPCTransportType type = _callOptions.transportType; + switch (type) { + case GRPCTransportTypeChttp2BoringSSL: + // TODO (mxyan): Remove when the API is deprecated + { + NSError *error; + id factory = [GRPCSecureChannelFactory + factoryWithPEMRootCertificates:_callOptions.PEMRootCertificates + privateKey:_callOptions.PEMPrivateKey + certChain:_callOptions.PEMCertificateChain + error:&error]; + NSAssert(factory != nil, @"Failed to create secure channel factory"); + if (factory == nil) { + NSLog(@"Error creating secure channel factory: %@", error); + } + return factory; } - return factory; + case GRPCTransportTypeCronet: { + id transportFactory = (id)[ + [GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:gGRPCCoreCronetId]; + return [transportFactory createCoreChannelFactoryWithCallOptions:_callOptions]; } - // fallthrough - case GRPCTransportTypeCronet: - return [GRPCCronetChannelFactory sharedInstance]; - case GRPCTransportTypeInsecure: - return [GRPCInsecureChannelFactory sharedInstance]; + case GRPCTransportTypeInsecure: + return [GRPCInsecureChannelFactory sharedInstance]; + default: + NSLog(@"Unrecognized transport type"); + return nil; + } } } @@ -198,6 +215,7 @@ } else { channelArgs = channelConfiguration.channelArgs; } + id factory = channelConfiguration.channelFactory; _unmanagedChannel = [factory createChannelWithHost:host channelArgs:channelArgs]; NSAssert(_unmanagedChannel != NULL, @"Failed to create channel"); diff --git a/src/objective-c/GRPCClient/private/GRPCChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelFactory.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCChannelFactory.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelFactory.h diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool+Test.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool+Test.h diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.h similarity index 98% rename from src/objective-c/GRPCClient/private/GRPCChannelPool.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.h index e00ee69e63a..b83a28a2368 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannelPool.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.h @@ -18,8 +18,6 @@ #import -#import "GRPCChannelFactory.h" - NS_ASSUME_NONNULL_BEGIN @protocol GRPCChannel; diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.m similarity index 98% rename from src/objective-c/GRPCClient/private/GRPCChannelPool.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.m index d545793fcce..92f52e67b75 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannelPool.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.m @@ -18,19 +18,16 @@ #import -#import "../internal/GRPCCallOptions+Internal.h" +#import "../../internal/GRPCCallOptions+Internal.h" #import "GRPCChannel.h" #import "GRPCChannelFactory.h" #import "GRPCChannelPool+Test.h" #import "GRPCChannelPool.h" #import "GRPCCompletionQueue.h" -#import "GRPCCronetChannelFactory.h" #import "GRPCInsecureChannelFactory.h" #import "GRPCSecureChannelFactory.h" #import "GRPCWrappedCall.h" -#import "version.h" -#import #include extern const char *kCFStreamVarName; diff --git a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCompletionQueue.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.h diff --git a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCCompletionQueue.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.m diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h new file mode 100644 index 00000000000..83d279d2c72 --- /dev/null +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h @@ -0,0 +1,32 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "../GRPCCoreFactory.h" + +/** + * The factory for gRPC Core + Cronet transport implementation. The + * implementation is not part of the default transports of gRPC and is for + * testing purpose only on Github. + * + * To use this transport, a user must include the GRPCCoreCronet module as a + * dependency of the project and use gGRPCCoreCronetId in call options to + * specify that this is the transport to be used for a call. + */ +@interface GRPCCoreCronetFactory : NSObject + +@end diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m new file mode 100644 index 00000000000..5772694fc54 --- /dev/null +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m @@ -0,0 +1,54 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "GRPCCoreCronetFactory.h" + +#import +#import + +#import "../GRPCCallInternal.h" +#import "../GRPCCoreFactory.h" +#import "GRPCCronetChannelFactory.h" + +static GRPCCoreCronetFactory *gGRPCCoreCronetFactory = nil; +static dispatch_once_t gInitGRPCCoreCronetFactory; + +@implementation GRPCCoreCronetFactory + ++ (instancetype)sharedInstance { + dispatch_once(&gInitGRPCCoreCronetFactory, ^{ + gGRPCCoreCronetFactory = [[GRPCCoreCronetFactory alloc] init]; + }); + return gGRPCCoreCronetFactory; +} + ++ (void)load { + [[GRPCTransportRegistry sharedInstance] + registerTransportWithId:gGRPCCoreCronetId + factory:[GRPCCoreCronetFactory sharedInstance]]; +} + +- (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager { + return [[GRPCCall2Internal alloc] initWithTransportManager:transportManager]; +} + +- (id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions { + return [GRPCCronetChannelFactory sharedInstance]; +} + +@end diff --git a/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.h similarity index 96% rename from src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.h index 738dfdb7370..138ddf1f730 100644 --- a/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.h @@ -15,7 +15,7 @@ * limitations under the License. * */ -#import "GRPCChannelFactory.h" +#import "../GRPCChannelFactory.h" @class GRPCChannel; typedef struct stream_engine stream_engine; diff --git a/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.m similarity index 76% rename from src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.m index 5bcb021dc4b..da3f3afd855 100644 --- a/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.m @@ -18,10 +18,8 @@ #import "GRPCCronetChannelFactory.h" -#import "ChannelArgsUtil.h" -#import "GRPCChannel.h" - -#ifdef GRPC_COMPILE_WITH_CRONET +#import "../ChannelArgsUtil.h" +#import "../GRPCChannel.h" #import #include @@ -59,21 +57,3 @@ } @end - -#else - -@implementation GRPCCronetChannelFactory - -+ (instancetype)sharedInstance { - NSAssert(NO, @"Must enable macro GRPC_COMPILE_WITH_CRONET to build Cronet channel."); - return nil; -} - -- (grpc_channel *)createChannelWithHost:(NSString *)host channelArgs:(NSDictionary *)args { - NSAssert(NO, @"Must enable macro GRPC_COMPILE_WITH_CRONET to build Cronet channel."); - return NULL; -} - -@end - -#endif diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h new file mode 100644 index 00000000000..3cd312d4ad0 --- /dev/null +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h @@ -0,0 +1,45 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol GRPCChannelFactory; +@protocol GRPCCallOptions; + +/** The interface for transport implementations that are based on Core. */ +@protocol GRPCCoreTransportFactory + +/** Get the channel factory for GRPCChannel from call options. */ +- (nullable id)createCoreChannelFactoryWithCallOptions: + (GRPCCallOptions *)callOptions; + +@end + +/** The factory for gRPC Core + CFStream + TLS secure channel transport implementation. */ +@interface GRPCCoreSecureFactory : NSObject + +@end + +/** The factory for gRPC Core + CFStream + insecure channel transport implementation. */ +@interface GRPCCoreInsecureFactory : NSObject + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m new file mode 100644 index 00000000000..19d7231a203 --- /dev/null +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m @@ -0,0 +1,90 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "GRPCCoreFactory.h" + +#import + +#import "GRPCCallInternal.h" +#import "GRPCInsecureChannelFactory.h" +#import "GRPCSecureChannelFactory.h" + +static GRPCCoreSecureFactory *gGRPCCoreSecureFactory = nil; +static GRPCCoreInsecureFactory *gGRPCCoreInsecureFactory = nil; +static dispatch_once_t gInitGRPCCoreSecureFactory; +static dispatch_once_t gInitGRPCCoreInsecureFactory; + +@implementation GRPCCoreSecureFactory + ++ (instancetype)sharedInstance { + dispatch_once(&gInitGRPCCoreSecureFactory, ^{ + gGRPCCoreSecureFactory = [[GRPCCoreSecureFactory alloc] init]; + }); + return gGRPCCoreSecureFactory; +} + ++ (void)load { + [[GRPCTransportRegistry sharedInstance] + registerTransportWithId:GRPCDefaultTransportImplList.core_secure + factory:[self sharedInstance]]; +} + +- (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager { + return [[GRPCCall2Internal alloc] initWithTransportManager:transportManager]; +} + +- (id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions { + NSError *error; + id factory = + [GRPCSecureChannelFactory factoryWithPEMRootCertificates:callOptions.PEMRootCertificates + privateKey:callOptions.PEMPrivateKey + certChain:callOptions.PEMCertificateChain + error:&error]; + if (error != nil) { + NSLog(@"Unable to create secure channel factory"); + return nil; + } + return factory; +} + +@end + +@implementation GRPCCoreInsecureFactory + ++ (instancetype)sharedInstance { + dispatch_once(&gInitGRPCCoreInsecureFactory, ^{ + gGRPCCoreInsecureFactory = [[GRPCCoreInsecureFactory alloc] init]; + }); + return gGRPCCoreInsecureFactory; +} + ++ (void)load { + [[GRPCTransportRegistry sharedInstance] + registerTransportWithId:GRPCDefaultTransportImplList.core_insecure + factory:[self sharedInstance]]; +} + +- (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager { + return [[GRPCCall2Internal alloc] initWithTransportManager:transportManager]; +} + +- (id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions { + return [GRPCInsecureChannelFactory sharedInstance]; +} + +@end diff --git a/src/objective-c/GRPCClient/private/GRPCHost.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCHost.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.h diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m similarity index 82% rename from src/objective-c/GRPCClient/private/GRPCHost.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m index 63ffc927411..1f6a25ff78f 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m @@ -21,17 +21,16 @@ #import #import #import +#import #include #include -#import "../internal/GRPCCallOptions+Internal.h" +#import "../../internal/GRPCCallOptions+Internal.h" #import "GRPCChannelFactory.h" #import "GRPCCompletionQueue.h" -#import "GRPCCronetChannelFactory.h" #import "GRPCSecureChannelFactory.h" #import "NSDictionary+GRPC.h" -#import "version.h" NS_ASSUME_NONNULL_BEGIN @@ -113,20 +112,12 @@ static NSMutableDictionary *gHostCache; options.PEMPrivateKey = _PEMPrivateKey; options.PEMCertificateChain = _PEMCertificateChain; options.hostNameOverride = _hostNameOverride; -#ifdef GRPC_COMPILE_WITH_CRONET - // By old API logic, insecure channel precedes Cronet channel; Cronet channel preceeds default - // channel. - if ([GRPCCall isUsingCronet]) { - if (_transportType == GRPCTransportTypeInsecure) { - options.transportType = GRPCTransportTypeInsecure; - } else { - NSAssert(_transportType == GRPCTransportTypeDefault, @"Invalid transport type"); - options.transportType = GRPCTransportTypeCronet; - } - } else -#endif - { - options.transportType = _transportType; + if (_transportType == GRPCTransportTypeInsecure) { + options.transport = GRPCDefaultTransportImplList.core_insecure; + } else if ([GRPCCall isUsingCronet]) { + options.transport = gGRPCCoreCronetId; + } else { + options.transport = GRPCDefaultTransportImplList.core_secure; } options.logContext = _logContext; @@ -135,16 +126,14 @@ static NSMutableDictionary *gHostCache; + (GRPCCallOptions *)callOptionsForHost:(NSString *)host { // TODO (mxyan): Remove when old API is deprecated - NSURL *hostURL = [NSURL URLWithString:[@"https://" stringByAppendingString:host]]; - if (hostURL.host && hostURL.port == nil) { - host = [hostURL.host stringByAppendingString:@":443"]; - } - GRPCCallOptions *callOptions = nil; @synchronized(gHostCache) { - callOptions = [gHostCache[host] callOptions]; + GRPCHost *hostConfig = [GRPCHost hostWithAddress:host]; + callOptions = [hostConfig callOptions]; } + NSAssert(callOptions != nil, @"Unable to create call options object"); if (callOptions == nil) { + NSLog(@"Unable to create call options object"); callOptions = [[GRPCCallOptions alloc] init]; } return callOptions; diff --git a/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.h diff --git a/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.m diff --git a/src/objective-c/GRPCClient/private/GRPCOpBatchLog.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCOpBatchLog.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCOpBatchLog.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCOpBatchLog.h diff --git a/src/objective-c/GRPCClient/private/GRPCOpBatchLog.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCOpBatchLog.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCOpBatchLog.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCOpBatchLog.m diff --git a/src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCReachabilityFlagNames.xmacro.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCReachabilityFlagNames.xmacro.h diff --git a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.h similarity index 95% rename from src/objective-c/GRPCClient/private/GRPCRequestHeaders.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.h index 545ff1cea82..0fced0c385a 100644 --- a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.h @@ -18,7 +18,7 @@ #import -#import "../GRPCCall.h" +#import @interface GRPCRequestHeaders : NSMutableDictionary diff --git a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCRequestHeaders.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.m diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.h diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.m diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.h similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCWrappedCall.h rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.h diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.m similarity index 100% rename from src/objective-c/GRPCClient/private/GRPCWrappedCall.m rename to src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.m diff --git a/src/objective-c/GRPCClient/private/NSData+GRPC.h b/src/objective-c/GRPCClient/private/GRPCCore/NSData+GRPC.h similarity index 100% rename from src/objective-c/GRPCClient/private/NSData+GRPC.h rename to src/objective-c/GRPCClient/private/GRPCCore/NSData+GRPC.h diff --git a/src/objective-c/GRPCClient/private/NSData+GRPC.m b/src/objective-c/GRPCClient/private/GRPCCore/NSData+GRPC.m similarity index 100% rename from src/objective-c/GRPCClient/private/NSData+GRPC.m rename to src/objective-c/GRPCClient/private/GRPCCore/NSData+GRPC.m diff --git a/src/objective-c/GRPCClient/private/NSDictionary+GRPC.h b/src/objective-c/GRPCClient/private/GRPCCore/NSDictionary+GRPC.h similarity index 100% rename from src/objective-c/GRPCClient/private/NSDictionary+GRPC.h rename to src/objective-c/GRPCClient/private/GRPCCore/NSDictionary+GRPC.h diff --git a/src/objective-c/GRPCClient/private/NSDictionary+GRPC.m b/src/objective-c/GRPCClient/private/GRPCCore/NSDictionary+GRPC.m similarity index 100% rename from src/objective-c/GRPCClient/private/NSDictionary+GRPC.m rename to src/objective-c/GRPCClient/private/GRPCCore/NSDictionary+GRPC.m diff --git a/src/objective-c/GRPCClient/private/NSError+GRPC.h b/src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.h similarity index 100% rename from src/objective-c/GRPCClient/private/NSError+GRPC.h rename to src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.h diff --git a/src/objective-c/GRPCClient/private/NSError+GRPC.m b/src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m similarity index 96% rename from src/objective-c/GRPCClient/private/NSError+GRPC.m rename to src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m index 3eefed88d63..5b5fc6263c5 100644 --- a/src/objective-c/GRPCClient/private/NSError+GRPC.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m @@ -18,10 +18,9 @@ #import "NSError+GRPC.h" +#import #include -NSString *const kGRPCErrorDomain = @"io.grpc"; - @implementation NSError (GRPC) + (instancetype)grpc_errorFromStatusCode:(grpc_status_code)statusCode details:(const char *)details diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h new file mode 100644 index 00000000000..2dc7357c363 --- /dev/null +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h @@ -0,0 +1,65 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * Private interfaces of the transport registry. + */ +@interface GRPCTransportRegistry (Private) + +/** + * Get a transport implementation's factory by its transport id. If the transport id was not + * registered with the registry, the default transport factory (core + secure) is returned. If the + * default transport does not exist, an exception is thrown. + */ +- (id)getTransportFactoryWithId:(GRPCTransportId)transportId; + +@end + +@interface GRPCTransportManager : NSObject + +- (instancetype)initWithTransportId:(GRPCTransportId)transportId + previousInterceptor:(id)previousInterceptor; + +/** + * Notify the manager that the transport has shut down and the manager should release references to + * its response handler and stop forwarding requests/responses. + */ +- (void)shutDown; + +/** Forward initial metadata to the previous interceptor in the interceptor chain */ +- (void)forwardPreviousInterceptorWithInitialMetadata:(nullable NSDictionary *)initialMetadata; + +/** Forward a received message to the previous interceptor in the interceptor chain */ +- (void)forwardPreviousInterceptorWithData:(nullable id)data; + +/** Forward call close and trailing metadata to the previous interceptor in the interceptor chain */ +- (void)forwardPreviousInterceptorCloseWithTrailingMetadata: + (nullable NSDictionary *)trailingMetadata + error:(nullable NSError *)error; + +/** Forward write completion to the previous interceptor in the interceptor chain */ +- (void)forwardPreviousInterceptorDidWriteData; + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m new file mode 100644 index 00000000000..9072f7afbe2 --- /dev/null +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m @@ -0,0 +1,131 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "GRPCTransport+Private.h" + +#import + +@implementation GRPCTransportManager { + GRPCTransportId _transportId; + GRPCTransport *_transport; + id _previousInterceptor; + dispatch_queue_t _dispatchQueue; +} + +- (instancetype)initWithTransportId:(GRPCTransportId)transportId + previousInterceptor:(id)previousInterceptor { + if ((self = [super init])) { + id factory = + [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:transportId]; + + _transport = [factory createTransportWithManager:self]; + NSAssert(_transport != nil, @"Failed to create transport with id: %s", transportId); + if (_transport == nil) { + NSLog(@"Failed to create transport with id: %s", transportId); + return nil; + } + _previousInterceptor = previousInterceptor; + _dispatchQueue = _transport.dispatchQueue; + _transportId = transportId; + } + return self; +} + +- (void)shutDown { + dispatch_async(_dispatchQueue, ^{ + self->_transport = nil; + self->_previousInterceptor = nil; + }); +} + +- (dispatch_queue_t)dispatchQueue { + return _dispatchQueue; +} + +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions + callOptions:(GRPCCallOptions *)callOptions { + if (_transportId != callOptions.transport) { + [NSException raise:NSInvalidArgumentException + format:@"Interceptors cannot change the call option 'transport'"]; + return; + } + [_transport startWithRequestOptions:requestOptions callOptions:callOptions]; +} + +- (void)writeData:(id)data { + [_transport writeData:data]; +} + +- (void)finish { + [_transport finish]; +} + +- (void)cancel { + [_transport cancel]; +} + +- (void)receiveNextMessages:(NSUInteger)numberOfMessages { + [_transport receiveNextMessages:numberOfMessages]; +} + +/** Forward initial metadata to the previous interceptor in the chain */ +- (void)forwardPreviousInterceptorWithInitialMetadata:(NSDictionary *)initialMetadata { + if (initialMetadata == nil || _previousInterceptor == nil) { + return; + } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didReceiveInitialMetadata:initialMetadata]; + }); +} + +/** Forward a received message to the previous interceptor in the chain */ +- (void)forwardPreviousInterceptorWithData:(id)data { + if (data == nil || _previousInterceptor == nil) { + return; + } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didReceiveData:data]; + }); +} + +/** Forward call close and trailing metadata to the previous interceptor in the chain */ +- (void)forwardPreviousInterceptorCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata + error:(NSError *)error { + if (_previousInterceptor == nil) { + return; + } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; + }); +} + +/** Forward write completion to the previous interceptor in the chain */ +- (void)forwardPreviousInterceptorDidWriteData { + if (_previousInterceptor == nil) { + return; + } + id copiedPreviousInterceptor = _previousInterceptor; + dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ + [copiedPreviousInterceptor didWriteData]; + }); +} + +@end diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/version.h similarity index 100% rename from src/objective-c/GRPCClient/private/version.h rename to src/objective-c/GRPCClient/version.h diff --git a/src/objective-c/ProtoRPC/ProtoRPC.h b/src/objective-c/ProtoRPC/ProtoRPC.h index 12db46adeda..c91adc7b7cd 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.h +++ b/src/objective-c/ProtoRPC/ProtoRPC.h @@ -17,12 +17,16 @@ */ #import -#import + +// import legacy header for compatibility with users using the ProtoRPC interface +#import "ProtoRPCLegacy.h" #import "ProtoMethod.h" NS_ASSUME_NONNULL_BEGIN +@class GRPCRequestOptions; +@class GRPCCallOptions; @class GPBMessage; /** An object can implement this protocol to receive responses from server from a call. */ @@ -160,35 +164,3 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wnullability-completeness" - -__attribute__((deprecated("Please use GRPCProtoCall."))) @interface ProtoRPC - : GRPCCall - - /** - * host parameter should not contain the scheme (http:// or https://), only the name or IP - * addr and the port number, for example @"localhost:5050". - */ - - - (instancetype)initWithHost : (NSString *)host method - : (GRPCProtoMethod *)method requestsWriter : (GRXWriter *)requestsWriter responseClass - : (Class)responseClass responsesWriteable - : (id)responsesWriteable NS_DESIGNATED_INITIALIZER; - -- (void)start; -@end - -/** - * This subclass is empty now. Eventually we'll remove ProtoRPC class - * to avoid potential naming conflict - */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - @interface GRPCProtoCall : ProtoRPC -#pragma clang diagnostic pop - - @end - -#pragma clang diagnostic pop diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m index 4700fdd1124..dbfa3c0f23d 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.m +++ b/src/objective-c/ProtoRPC/ProtoRPC.m @@ -27,24 +27,6 @@ #import #import -/** - * Generate an NSError object that represents a failure in parsing a proto class. - */ -static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError) { - NSDictionary *info = @{ - NSLocalizedDescriptionKey : @"Unable to parse response from the server", - NSLocalizedRecoverySuggestionErrorKey : - @"If this RPC is idempotent, retry " - @"with exponential backoff. Otherwise, query the server status before " - @"retrying.", - NSUnderlyingErrorKey : parsingError, - @"Expected class" : expectedClass, - @"Received value" : proto, - }; - // TODO(jcanizales): Use kGRPCErrorDomain and GRPCErrorCodeInternal when they're public. - return [NSError errorWithDomain:@"io.grpc" code:13 userInfo:info]; -} - @implementation GRPCUnaryProtoCall { GRPCStreamingProtoCall *_call; GPBMessage *_message; @@ -291,76 +273,3 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing } @end - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-implementations" -@implementation ProtoRPC { -#pragma clang diagnostic pop - id _responseWriteable; -} - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wobjc-designated-initializers" -- (instancetype)initWithHost:(NSString *)host - path:(NSString *)path - requestsWriter:(GRXWriter *)requestsWriter { - [NSException raise:NSInvalidArgumentException - format:@"Please use ProtoRPC's designated initializer instead."]; - return nil; -} -#pragma clang diagnostic pop - -// Designated initializer -- (instancetype)initWithHost:(NSString *)host - method:(GRPCProtoMethod *)method - requestsWriter:(GRXWriter *)requestsWriter - responseClass:(Class)responseClass - responsesWriteable:(id)responsesWriteable { - // Because we can't tell the type system to constrain the class, we need to check at runtime: - if (![responseClass respondsToSelector:@selector(parseFromData:error:)]) { - [NSException raise:NSInvalidArgumentException - format:@"A protobuf class to parse the responses must be provided."]; - } - // A writer that serializes the proto messages to send. - GRXWriter *bytesWriter = [requestsWriter map:^id(GPBMessage *proto) { - if (![proto isKindOfClass:[GPBMessage class]]) { - [NSException raise:NSInvalidArgumentException - format:@"Request must be a proto message: %@", proto]; - } - return [proto data]; - }]; - if ((self = [super initWithHost:host path:method.HTTPPath requestsWriter:bytesWriter])) { - __weak ProtoRPC *weakSelf = self; - - // A writeable that parses the proto messages received. - _responseWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { - // TODO(jcanizales): This is done in the main thread, and needs to happen in another thread. - NSError *error = nil; - id parsed = [responseClass parseFromData:value error:&error]; - if (parsed) { - [responsesWriteable writeValue:parsed]; - } else { - [weakSelf finishWithError:ErrorForBadProto(value, responseClass, error)]; - } - } - completionHandler:^(NSError *errorOrNil) { - [responsesWriteable writesFinishedWithError:errorOrNil]; - }]; - } - return self; -} - -- (void)start { - [self startWithWriteable:_responseWriteable]; -} - -- (void)startWithWriteable:(id)writeable { - [super startWithWriteable:writeable]; - // Break retain cycles. - _responseWriteable = nil; -} -@end - -@implementation GRPCProtoCall - -@end diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.h b/src/objective-c/ProtoRPC/ProtoRPCLegacy.h new file mode 100644 index 00000000000..b8d4003f695 --- /dev/null +++ b/src/objective-c/ProtoRPC/ProtoRPCLegacy.h @@ -0,0 +1,67 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import + +// Import category headers for Swift build +#import +#import +#import +#import +#import +#import + +@class GRPCProtoMethod; +@class GRXWriter; +@protocol GRXWriteable; + +__attribute__((deprecated("Please use GRPCProtoCall."))) @interface ProtoRPC + : GRPCCall + + /** + * host parameter should not contain the scheme (http:// or https://), only the name or IP + * addr and the port number, for example @"localhost:5050". + */ + - + (instancetype)initWithHost : (NSString *)host method + : (GRPCProtoMethod *)method requestsWriter : (GRXWriter *)requestsWriter responseClass + : (Class)responseClass responsesWriteable + : (id)responsesWriteable NS_DESIGNATED_INITIALIZER; + +- (void)start; + +@end + +/** + * This subclass is empty now. Eventually we'll remove ProtoRPC class + * to avoid potential naming conflict + */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + @interface GRPCProtoCall + : ProtoRPC +#pragma clang diagnostic pop + + @end + + /** + * Generate an NSError object that represents a failure in parsing a proto class. For gRPC + * internal use only. + */ + NSError * + ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError); diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.m b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m new file mode 100644 index 00000000000..4ba93674063 --- /dev/null +++ b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m @@ -0,0 +1,121 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "ProtoRPCLegacy.h" + +#import "ProtoMethod.h" + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS +#import +#else +#import +#endif +#import +#import +#import + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-implementations" +@implementation ProtoRPC { +#pragma clang diagnostic pop + id _responseWriteable; +} + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wobjc-designated-initializers" +- (instancetype)initWithHost:(NSString *)host + path:(NSString *)path + requestsWriter:(GRXWriter *)requestsWriter { + [NSException raise:NSInvalidArgumentException + format:@"Please use ProtoRPC's designated initializer instead."]; + return nil; +} +#pragma clang diagnostic pop + +// Designated initializer +- (instancetype)initWithHost:(NSString *)host + method:(GRPCProtoMethod *)method + requestsWriter:(GRXWriter *)requestsWriter + responseClass:(Class)responseClass + responsesWriteable:(id)responsesWriteable { + // Because we can't tell the type system to constrain the class, we need to check at runtime: + if (![responseClass respondsToSelector:@selector(parseFromData:error:)]) { + [NSException raise:NSInvalidArgumentException + format:@"A protobuf class to parse the responses must be provided."]; + } + // A writer that serializes the proto messages to send. + GRXWriter *bytesWriter = [requestsWriter map:^id(GPBMessage *proto) { + if (![proto isKindOfClass:[GPBMessage class]]) { + [NSException raise:NSInvalidArgumentException + format:@"Request must be a proto message: %@", proto]; + } + return [proto data]; + }]; + if ((self = [super initWithHost:host path:method.HTTPPath requestsWriter:bytesWriter])) { + __weak ProtoRPC *weakSelf = self; + + // A writeable that parses the proto messages received. + _responseWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { + // TODO(jcanizales): This is done in the main thread, and needs to happen in another thread. + NSError *error = nil; + id parsed = [responseClass parseFromData:value error:&error]; + if (parsed) { + [responsesWriteable writeValue:parsed]; + } else { + [weakSelf finishWithError:ErrorForBadProto(value, responseClass, error)]; + } + } + completionHandler:^(NSError *errorOrNil) { + [responsesWriteable writesFinishedWithError:errorOrNil]; + }]; + } + return self; +} + +- (void)start { + [self startWithWriteable:_responseWriteable]; +} + +- (void)startWithWriteable:(id)writeable { + [super startWithWriteable:writeable]; + // Break retain cycles. + _responseWriteable = nil; +} +@end + +@implementation GRPCProtoCall + +@end + +/** + * Generate an NSError object that represents a failure in parsing a proto class. + */ +NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError) { + NSDictionary *info = @{ + NSLocalizedDescriptionKey : @"Unable to parse response from the server", + NSLocalizedRecoverySuggestionErrorKey : + @"If this RPC is idempotent, retry " + @"with exponential backoff. Otherwise, query the server status before " + @"retrying.", + NSUnderlyingErrorKey : parsingError, + @"Expected class" : expectedClass, + @"Received value" : proto, + }; + // TODO(jcanizales): Use kGRPCErrorDomain and GRPCErrorCodeInternal when they're public. + return [NSError errorWithDomain:@"io.grpc" code:13 userInfo:info]; +} diff --git a/src/objective-c/ProtoRPC/ProtoService.h b/src/objective-c/ProtoRPC/ProtoService.h index 900ec8d0e1e..fd8a86bb2b2 100644 --- a/src/objective-c/ProtoRPC/ProtoService.h +++ b/src/objective-c/ProtoRPC/ProtoService.h @@ -18,14 +18,12 @@ #import -@class GRPCProtoCall; +#import +#import "ProtoRPC.h" + @protocol GRXWriteable; @class GRXWriter; @class GRPCCallOptions; -@class GRPCProtoCall; -@class GRPCUnaryProtoCall; -@class GRPCStreamingProtoCall; -@protocol GRPCProtoResponseHandler; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnullability-completeness" @@ -38,15 +36,6 @@ __attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoServ : (nonnull NSString *)packageName serviceName : (nonnull NSString *)serviceName callOptions : (nullable GRPCCallOptions *)callOptions NS_DESIGNATED_INITIALIZER; -- (instancetype)initWithHost:(NSString *)host - packageName:(NSString *)packageName - serviceName:(NSString *)serviceName; - -- (GRPCProtoCall *)RPCToMethod:(NSString *)method - requestsWriter:(GRXWriter *)requestsWriter - responseClass:(Class)responseClass - responsesWriteable:(id)responsesWriteable; - - (nullable GRPCUnaryProtoCall *)RPCToMethod:(nonnull NSString *)method message:(nonnull id)message responseHandler:(nonnull id)handler @@ -58,6 +47,18 @@ __attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoServ callOptions:(nullable GRPCCallOptions *)callOptions responseClass:(nonnull Class)responseClass; +@end + + @interface ProtoService(Legacy) + + - (instancetype)initWithHost : (NSString *)host packageName + : (NSString *)packageName serviceName : (NSString *)serviceName; + +- (GRPCProtoCall *)RPCToMethod:(NSString *)method + requestsWriter:(GRXWriter *)requestsWriter + responseClass:(Class)responseClass + responsesWriteable:(id)responsesWriteable; + @end #pragma clang diagnostic pop diff --git a/src/objective-c/ProtoRPC/ProtoService.m b/src/objective-c/ProtoRPC/ProtoService.m index 80a1f2f226c..e84cab8903f 100644 --- a/src/objective-c/ProtoRPC/ProtoService.m +++ b/src/objective-c/ProtoRPC/ProtoService.m @@ -29,15 +29,21 @@ #pragma clang diagnostic ignored "-Wdeprecated-implementations" @implementation ProtoService { #pragma clang diagnostic pop + + GRPCCallOptions *_callOptions; NSString *_host; NSString *_packageName; NSString *_serviceName; - GRPCCallOptions *_callOptions; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnonnull" +// Do not call the default init method - (instancetype)init { - return [self initWithHost:nil packageName:nil serviceName:nil]; + [NSException raise:NSGenericException format:@"Do not call init method of ProtoService"]; + return [self initWithHost:nil packageName:nil serviceName:nil callOptions:nil]; } +#pragma clang diagnostic pop // Designated initializer - (instancetype)initWithHost:(NSString *)host @@ -58,38 +64,6 @@ return self; } -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wobjc-designated-initializers" -// Do not call designated initializer here due to nullability incompatibility. This method is from -// old API and does not assert on nullability of the parameters. - -- (instancetype)initWithHost:(NSString *)host - packageName:(NSString *)packageName - serviceName:(NSString *)serviceName { - if ((self = [super init])) { - _host = [host copy]; - _packageName = [packageName copy]; - _serviceName = [serviceName copy]; - _callOptions = nil; - } - return self; -} - -#pragma clang diagnostic pop - -- (GRPCProtoCall *)RPCToMethod:(NSString *)method - requestsWriter:(GRXWriter *)requestsWriter - responseClass:(Class)responseClass - responsesWriteable:(id)responsesWriteable { - GRPCProtoMethod *methodName = - [[GRPCProtoMethod alloc] initWithPackage:_packageName service:_serviceName method:method]; - return [[GRPCProtoCall alloc] initWithHost:_host - method:methodName - requestsWriter:requestsWriter - responseClass:responseClass - responsesWriteable:responsesWriteable]; -} - - (GRPCUnaryProtoCall *)RPCToMethod:(NSString *)method message:(id)message responseHandler:(id)handler diff --git a/src/objective-c/ProtoRPC/ProtoServiceLegacy.h b/src/objective-c/ProtoRPC/ProtoServiceLegacy.h new file mode 100644 index 00000000000..7b0b7a4de7e --- /dev/null +++ b/src/objective-c/ProtoRPC/ProtoServiceLegacy.h @@ -0,0 +1,23 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import "ProtoService.h" + +@class GRPCProtoCall; +@class GRXWriter; +@protocol GRXWriteable; diff --git a/src/objective-c/ProtoRPC/ProtoServiceLegacy.m b/src/objective-c/ProtoRPC/ProtoServiceLegacy.m new file mode 100644 index 00000000000..6aa64955381 --- /dev/null +++ b/src/objective-c/ProtoRPC/ProtoServiceLegacy.m @@ -0,0 +1,71 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import + +#import "ProtoMethod.h" +#import "ProtoRPCLegacy.h" +#import "ProtoService.h" + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-implementations" +@implementation ProtoService (Legacy) +#pragma clang diagnostic pop + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wobjc-designated-initializers" +// Do not call designated initializer here due to nullability incompatibility. This method is from +// old API and does not assert on nullability of the parameters. + +- (instancetype)initWithHost:(NSString *)host + packageName:(NSString *)packageName + serviceName:(NSString *)serviceName { + if ((self = [super init])) { + Ivar hostIvar = class_getInstanceVariable([ProtoService class], "_host"); + Ivar packageNameIvar = class_getInstanceVariable([ProtoService class], "_packageName"); + Ivar serviceNameIvar = class_getInstanceVariable([ProtoService class], "_serviceName"); + + object_setIvar(self, hostIvar, [host copy]); + object_setIvar(self, packageNameIvar, [packageName copy]); + object_setIvar(self, serviceNameIvar, [serviceName copy]); + } + return self; +} +#pragma clang diagnostic pop + +- (GRPCProtoCall *)RPCToMethod:(NSString *)method + requestsWriter:(GRXWriter *)requestsWriter + responseClass:(Class)responseClass + responsesWriteable:(id)responsesWriteable { + Ivar hostIvar = class_getInstanceVariable([ProtoService class], "_host"); + Ivar packageNameIvar = class_getInstanceVariable([ProtoService class], "_packageName"); + Ivar serviceNameIvar = class_getInstanceVariable([ProtoService class], "_serviceName"); + NSString *host = object_getIvar(self, hostIvar); + NSString *packageName = object_getIvar(self, packageNameIvar); + NSString *serviceName = object_getIvar(self, serviceNameIvar); + + GRPCProtoMethod *methodName = + [[GRPCProtoMethod alloc] initWithPackage:packageName service:serviceName method:method]; + return [[GRPCProtoCall alloc] initWithHost:host + method:methodName + requestsWriter:requestsWriter + responseClass:responseClass + responsesWriteable:responsesWriteable]; +} + +@end diff --git a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m index c94ee8c2569..9c466260121 100644 --- a/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m +++ b/src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m @@ -25,6 +25,8 @@ #import "src/objective-c/examples/RemoteTestClient/Messages.pbobjc.h" #import "src/objective-c/examples/RemoteTestClient/Test.pbrpc.h" #endif +#import +#import @interface ViewController () diff --git a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m index 3e97767cf0c..ce204a9c146 100644 --- a/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m +++ b/src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m @@ -24,6 +24,8 @@ #import "src/objective-c/examples/RemoteTestClient/Messages.pbobjc.h" #import "src/objective-c/examples/RemoteTestClient/Test.pbrpc.h" #endif +#import +#import @interface InterfaceController () diff --git a/src/objective-c/tests/BUILD b/src/objective-c/tests/BUILD index fed92596b17..65a32d742a9 100644 --- a/src/objective-c/tests/BUILD +++ b/src/objective-c/tests/BUILD @@ -95,19 +95,12 @@ tvos_application( deps = ["host-lib"], ) -grpc_objc_testing_library( - name = "CronetConfig", - srcs = ["ConfigureCronet.m"], - hdrs = ["ConfigureCronet.h"], -) - grpc_objc_testing_library( name = "InteropTests-lib", hdrs = ["InteropTests/InteropTests.h"], srcs = ["InteropTests/InteropTests.m"], deps = [ ":InteropTestsBlockCallbacks-lib", - ":CronetConfig", ], ) @@ -200,7 +193,6 @@ ios_unit_test( ":InteropTestsRemote-lib", ":InteropTestsLocalSSL-lib", ":InteropTestsLocalCleartext-lib", - # ":InteropTestsMulitpleChannels-lib", # needs Cronet ], test_host = ":ios-host", ) diff --git a/src/objective-c/tests/ConfigureCronet.h b/src/objective-c/tests/ConfigureCronet.h index cc5c038f3c6..ba0efc4df66 100644 --- a/src/objective-c/tests/ConfigureCronet.h +++ b/src/objective-c/tests/ConfigureCronet.h @@ -16,8 +16,6 @@ * */ -#ifdef GRPC_COMPILE_WITH_CRONET - #ifdef __cplusplus extern "C" { #endif @@ -30,5 +28,3 @@ void configureCronet(void); #ifdef __cplusplus } #endif - -#endif diff --git a/src/objective-c/tests/ConfigureCronet.m b/src/objective-c/tests/ConfigureCronet.m index ab137e28cad..6fc7e0ee9f5 100644 --- a/src/objective-c/tests/ConfigureCronet.m +++ b/src/objective-c/tests/ConfigureCronet.m @@ -16,8 +16,6 @@ * */ -#ifdef GRPC_COMPILE_WITH_CRONET - #import "ConfigureCronet.h" #import @@ -35,5 +33,3 @@ void configureCronet(void) { [Cronet startNetLogToFile:@"cronet_netlog.json" logBytes:YES]; }); } - -#endif diff --git a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m index a2a79c46316..aa1af301b96 100644 --- a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m +++ b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m @@ -22,6 +22,7 @@ #import #import +#import "../ConfigureCronet.h" #import "InteropTests.h" // The server address is derived from preprocessor macro, which is @@ -40,12 +41,19 @@ static int32_t kRemoteInteropServerOverhead = 12; @implementation InteropTestsRemoteWithCronet ++ (void)setUp { + configureCronet(); + [GRPCCall useCronetWithEngine:[Cronet getGlobalEngine]]; + + [super setUp]; +} + + (NSString *)host { return kRemoteSSLHost; } -+ (BOOL)useCronet { - return YES; ++ (GRPCTransportId)transport { + return gGRPCCoreCronetId; } - (int32_t)encodingOverhead { diff --git a/src/objective-c/tests/InteropTests/InteropTests.h b/src/objective-c/tests/InteropTests/InteropTests.h index 28fcbff9695..a4adecd5415 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.h +++ b/src/objective-c/tests/InteropTests/InteropTests.h @@ -48,11 +48,19 @@ - (int32_t)encodingOverhead; /** + * DEPRECATED: \a transportType is a deprecated option. Please use \a transport instead. + * * The type of transport to be used. The base implementation returns default. Subclasses should * override to appropriate settings. */ + (GRPCTransportType)transportType; +/* + * The transport to be used. The base implementation returns NULL. Subclasses should override to + * appropriate settings. + */ ++ (GRPCTransportId)transport; + /** * The root certificates to be used. The base implementation returns nil. Subclasses should override * to appropriate settings. @@ -65,9 +73,4 @@ */ + (NSString *)hostNameOverride; -/** - * Whether to use Cronet for all the v1 API tests in the test suite. - */ -+ (BOOL)useCronet; - @end diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index a8f7db7ee93..21198f7bad9 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -20,9 +20,6 @@ #include -#ifdef GRPC_COMPILE_WITH_CRONET -#import -#endif #import #import #import @@ -38,7 +35,6 @@ #import "src/objective-c/tests/RemoteTestClient/Test.pbobjc.h" #import "src/objective-c/tests/RemoteTestClient/Test.pbrpc.h" -#import "../ConfigureCronet.h" #import "InteropTestsBlockCallbacks.h" #define TEST_TIMEOUT 32 @@ -91,9 +87,8 @@ BOOL isRemoteInteropTest(NSString *host) { - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { dispatch_queue_t queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); - return [[GRPCInterceptor alloc] initWithInterceptorManager:interceptorManager - requestDispatchQueue:queue - responseDispatchQueue:queue]; + return + [[GRPCInterceptor alloc] initWithInterceptorManager:interceptorManager dispatchQueue:queue]; } @end @@ -101,21 +96,19 @@ BOOL isRemoteInteropTest(NSString *host) { @interface HookInterceptorFactory : NSObject - (instancetype) -initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue - startHook:(void (^)(GRPCRequestOptions *requestOptions, - GRPCCallOptions *callOptions, - GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook - finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook - receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, - GRPCInterceptorManager *manager))receiveNextMessagesHook - responseHeaderHook:(void (^)(NSDictionary *initialMetadata, - GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook - responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, - GRPCInterceptorManager *manager))responseCloseHook - didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook; + initWithDispatchQueue:(dispatch_queue_t)dispatchQueue + startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager))startHook + writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook + finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook +receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, + GRPCInterceptorManager *manager))receiveNextMessagesHook + responseHeaderHook:(void (^)(NSDictionary *initialMetadata, + GRPCInterceptorManager *manager))responseHeaderHook + responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook + responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager))responseCloseHook + didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook; - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager; @@ -125,8 +118,7 @@ initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - (instancetype) initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - requestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue + dispatchQueue:(dispatch_queue_t)dispatchQueue startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook @@ -155,29 +147,25 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager void (^_responseCloseHook)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager); void (^_didWriteDataHook)(GRPCInterceptorManager *manager); - dispatch_queue_t _requestDispatchQueue; - dispatch_queue_t _responseDispatchQueue; + dispatch_queue_t _dispatchQueue; } - (instancetype) -initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue - startHook:(void (^)(GRPCRequestOptions *requestOptions, - GRPCCallOptions *callOptions, - GRPCInterceptorManager *manager))startHook - writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook - finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook - receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, - GRPCInterceptorManager *manager))receiveNextMessagesHook - responseHeaderHook:(void (^)(NSDictionary *initialMetadata, - GRPCInterceptorManager *manager))responseHeaderHook - responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook - responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, - GRPCInterceptorManager *manager))responseCloseHook - didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { + initWithDispatchQueue:(dispatch_queue_t)dispatchQueue + startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, + GRPCInterceptorManager *manager))startHook + writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook + finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook +receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages, + GRPCInterceptorManager *manager))receiveNextMessagesHook + responseHeaderHook:(void (^)(NSDictionary *initialMetadata, + GRPCInterceptorManager *manager))responseHeaderHook + responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook + responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, + GRPCInterceptorManager *manager))responseCloseHook + didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { if ((self = [super init])) { - _requestDispatchQueue = requestDispatchQueue; - _responseDispatchQueue = responseDispatchQueue; + _dispatchQueue = dispatchQueue; _startHook = startHook; _writeDataHook = writeDataHook; _finishHook = finishHook; @@ -192,8 +180,7 @@ initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { return [[HookInterceptor alloc] initWithInterceptorManager:interceptorManager - requestDispatchQueue:_requestDispatchQueue - responseDispatchQueue:_responseDispatchQueue + dispatchQueue:_dispatchQueue startHook:_startHook writeDataHook:_writeDataHook finishHook:_finishHook @@ -218,22 +205,16 @@ initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue GRPCInterceptorManager *manager); void (^_didWriteDataHook)(GRPCInterceptorManager *manager); GRPCInterceptorManager *_manager; - dispatch_queue_t _requestDispatchQueue; - dispatch_queue_t _responseDispatchQueue; -} - -- (dispatch_queue_t)requestDispatchQueue { - return _requestDispatchQueue; + dispatch_queue_t _dispatchQueue; } - (dispatch_queue_t)dispatchQueue { - return _responseDispatchQueue; + return _dispatchQueue; } - (instancetype) initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - requestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue + dispatchQueue:(dispatch_queue_t)dispatchQueue startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook @@ -247,9 +228,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error, GRPCInterceptorManager *manager))responseCloseHook didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook { - if ((self = [super initWithInterceptorManager:interceptorManager - requestDispatchQueue:requestDispatchQueue - responseDispatchQueue:responseDispatchQueue])) { + if ((self = [super initWithInterceptorManager:interceptorManager dispatchQueue:dispatchQueue])) { _startHook = startHook; _writeDataHook = writeDataHook; _finishHook = finishHook; @@ -258,8 +237,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager _responseDataHook = responseDataHook; _responseCloseHook = responseCloseHook; _didWriteDataHook = didWriteDataHook; - _requestDispatchQueue = requestDispatchQueue; - _responseDispatchQueue = responseDispatchQueue; + _dispatchQueue = dispatchQueue; _manager = interceptorManager; } return self; @@ -320,8 +298,7 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager @property BOOL enabled; -- (instancetype)initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue; +- (instancetype)initWithDispatchQueue:(dispatch_queue_t)dispatchQueue; - (void)setStartHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager))startHook @@ -340,26 +317,23 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager @implementation GlobalInterceptorFactory -- (instancetype)initWithRequestDispatchQueue:(dispatch_queue_t)requestDispatchQueue - responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue { +- (instancetype)initWithDispatchQueue:(dispatch_queue_t)dispatchQueue { _enabled = NO; - return [super initWithRequestDispatchQueue:requestDispatchQueue - responseDispatchQueue:responseDispatchQueue - startHook:nil - writeDataHook:nil - finishHook:nil - receiveNextMessagesHook:nil - responseHeaderHook:nil - responseDataHook:nil - responseCloseHook:nil - didWriteDataHook:nil]; + return [super initWithDispatchQueue:dispatchQueue + startHook:nil + writeDataHook:nil + finishHook:nil + receiveNextMessagesHook:nil + responseHeaderHook:nil + responseDataHook:nil + responseCloseHook:nil + didWriteDataHook:nil]; } - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { if (_enabled) { return [[HookInterceptor alloc] initWithInterceptorManager:interceptorManager - requestDispatchQueue:_requestDispatchQueue - responseDispatchQueue:_responseDispatchQueue + dispatchQueue:_dispatchQueue startHook:_startHook writeDataHook:_writeDataHook finishHook:_finishHook @@ -425,10 +399,15 @@ static dispatch_once_t initGlobalInterceptorFactory; return 0; } +// For backwards compatibility + (GRPCTransportType)transportType { return GRPCTransportTypeChttp2BoringSSL; } ++ (GRPCTransportId)transport { + return NULL; +} + + (NSString *)PEMRootCertificates { return nil; } @@ -437,26 +416,11 @@ static dispatch_once_t initGlobalInterceptorFactory; return nil; } -+ (BOOL)useCronet { - return NO; -} - + (void)setUp { -#ifdef GRPC_COMPILE_WITH_CRONET - configureCronet(); - if ([self useCronet]) { - [GRPCCall useCronetWithEngine:[Cronet getGlobalEngine]]; - } -#endif -#ifdef GRPC_CFSTREAM - setenv(kCFStreamVarName, "1", 1); -#endif - dispatch_once(&initGlobalInterceptorFactory, ^{ dispatch_queue_t globalInterceptorQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); globalInterceptorFactory = - [[GlobalInterceptorFactory alloc] initWithRequestDispatchQueue:globalInterceptorQueue - responseDispatchQueue:globalInterceptorQueue]; + [[GlobalInterceptorFactory alloc] initWithDispatchQueue:globalInterceptorQueue]; [GRPCCall2 registerGlobalInterceptor:globalInterceptorFactory]; }); } @@ -502,7 +466,9 @@ static dispatch_once_t initGlobalInterceptorFactory; GPBEmpty *request = [GPBEmpty message]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -531,7 +497,9 @@ static dispatch_once_t initGlobalInterceptorFactory; GPBEmpty *request = [GPBEmpty message]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -608,7 +576,9 @@ static dispatch_once_t initGlobalInterceptorFactory; request.payload.body = [NSMutableData dataWithLength:271828]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -656,7 +626,9 @@ static dispatch_once_t initGlobalInterceptorFactory; request.responseStatus.code = GRPC_STATUS_CANCELLED; } GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -958,7 +930,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; @@ -1010,7 +984,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.flowControlEnabled = YES; @@ -1167,7 +1143,9 @@ static dispatch_once_t initGlobalInterceptorFactory; __block BOOL receivedResponse = NO; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = self.class.transportType; + options.transport = [[self class] transport]; options.PEMRootCertificates = self.class.PEMRootCertificates; options.hostNameOverride = [[self class] hostNameOverride]; @@ -1200,7 +1178,9 @@ static dispatch_once_t initGlobalInterceptorFactory; [self expectationWithDescription:@"Call completed."]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = self.class.transportType; + options.transport = [[self class] transport]; options.PEMRootCertificates = self.class.PEMRootCertificates; options.hostNameOverride = [[self class] hostNameOverride]; @@ -1286,48 +1266,47 @@ static dispatch_once_t initGlobalInterceptorFactory; [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; } -#ifndef GRPC_COMPILE_WITH_CRONET -- (void)testKeepalive { +- (void)testKeepaliveWithV2API { XCTAssertNotNil([[self class] host]); + if ([[self class] transport] == gGRPCCoreCronetId) { + // Cronet does not support keepalive + return; + } __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Keepalive"]; - [GRPCCall setKeepaliveWithInterval:1500 timeout:0 forHost:[[self class] host]]; + NSNumber *kRequestSize = @27182; + NSNumber *kResponseSize = @31415; - NSArray *requests = @[ @27182, @8 ]; - NSArray *responses = @[ @31415, @9 ]; + id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:kRequestSize + requestedResponseSize:kResponseSize]; + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; + options.PEMRootCertificates = [[self class] PEMRootCertificates]; + options.hostNameOverride = [[self class] hostNameOverride]; + options.keepaliveInterval = 1.5; + options.keepaliveTimeout = 0; - GRXBufferedPipe *requestsBuffer = [[GRXBufferedPipe alloc] init]; - - __block int index = 0; - - id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] - requestedResponseSize:responses[index]]; - [requestsBuffer writeValue:request]; - - [_service - fullDuplexCallWithRequestsWriter:requestsBuffer - eventHandler:^(BOOL done, RMTStreamingOutputCallResponse *response, - NSError *error) { - if (index == 0) { - XCTAssertNil(error, @"Finished with unexpected error: %@", error); - XCTAssertTrue(response, @"Event handler called without an event."); - XCTAssertFalse(done); - index++; - } else { - // Keepalive should kick after 1s elapsed and fails the call. - XCTAssertNotNil(error); - XCTAssertEqual(error.code, GRPC_STATUS_UNAVAILABLE); - XCTAssertEqualObjects( - error.localizedDescription, @"keepalive watchdog timeout", - @"Unexpected failure that is not keepalive watchdog timeout."); - XCTAssertTrue(done); - [expectation fulfill]; - } - }]; + __block GRPCStreamingProtoCall *call = [_service + fullDuplexCallWithResponseHandler: + [[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { + XCTAssertNotNil(error); + XCTAssertEqual( + error.code, GRPC_STATUS_UNAVAILABLE, + @"Received status %ld instead of UNAVAILABLE (14).", + error.code); + [expectation fulfill]; + }] + callOptions:options]; + [call writeMessage:request]; + [call start]; [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; + [call finish]; } -#endif - (void)testDefaultInterceptor { XCTAssertNotNil([[self class] host]); @@ -1342,7 +1321,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.interceptorFactories = @[ [[DefaultInterceptorFactory alloc] init] ]; @@ -1397,8 +1378,7 @@ static dispatch_once_t initGlobalInterceptorFactory; __block NSUInteger responseCloseCount = 0; __block NSUInteger didWriteDataCount = 0; id factory = [[HookInterceptorFactory alloc] - initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager) { startCount++; @@ -1446,7 +1426,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.flowControlEnabled = YES; @@ -1524,8 +1506,7 @@ static dispatch_once_t initGlobalInterceptorFactory; __block NSUInteger responseDataCount = 0; __block NSUInteger responseCloseCount = 0; id factory = [[HookInterceptorFactory alloc] - initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager) { startCount++; @@ -1552,6 +1533,7 @@ static dispatch_once_t initGlobalInterceptorFactory; // finish must happen after the hijacking, so directly reply with a close [manager forwardPreviousInterceptorCloseWithTrailingMetadata:@{@"grpc-status" : @"0"} error:nil]; + [manager shutDown]; } receiveNextMessagesHook:nil responseHeaderHook:^(NSDictionary *initialMetadata, GRPCInterceptorManager *manager) { @@ -1578,7 +1560,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.interceptorFactories = @[ [[DefaultInterceptorFactory alloc] init], factory ]; @@ -1687,7 +1671,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.flowControlEnabled = YES; @@ -1742,16 +1728,15 @@ static dispatch_once_t initGlobalInterceptorFactory; - (void)testConflictingGlobalInterceptors { id factory = [[HookInterceptorFactory alloc] - initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - startHook:nil - writeDataHook:nil - finishHook:nil - receiveNextMessagesHook:nil - responseHeaderHook:nil - responseDataHook:nil - responseCloseHook:nil - didWriteDataHook:nil]; + initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + startHook:nil + writeDataHook:nil + finishHook:nil + receiveNextMessagesHook:nil + responseHeaderHook:nil + responseDataHook:nil + responseCloseHook:nil + didWriteDataHook:nil]; @try { [GRPCCall2 registerGlobalInterceptor:factory]; XCTFail(@"Did not receive an exception when registering global interceptor the second time"); @@ -1775,8 +1760,7 @@ static dispatch_once_t initGlobalInterceptorFactory; __block NSUInteger didWriteDataCount = 0; id factory = [[HookInterceptorFactory alloc] - initWithRequestDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) - responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + initWithDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) startHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions, GRPCInterceptorManager *manager) { startCount++; @@ -1872,7 +1856,9 @@ static dispatch_once_t initGlobalInterceptorFactory; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index] requestedResponseSize:responses[index]]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + // For backwards compatibility options.transportType = [[self class] transportType]; + options.transport = [[self class] transport]; options.PEMRootCertificates = [[self class] PEMRootCertificates]; options.hostNameOverride = [[self class] hostNameOverride]; options.flowControlEnabled = YES; diff --git a/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m b/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m index a9c69183332..2e638099e1e 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m +++ b/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m @@ -17,6 +17,7 @@ */ #import +#import #import #import "InteropTests.h" @@ -60,8 +61,8 @@ static int32_t kLocalInteropServerOverhead = 10; [GRPCCall useInsecureConnectionsForHost:kLocalCleartextHost]; } -+ (GRPCTransportType)transportType { - return GRPCTransportTypeInsecure; ++ (GRPCTransportId)transport { + return GRPCDefaultTransportImplList.core_insecure; } @end diff --git a/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m b/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m index e8222f602f4..30d8f4c34af 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m +++ b/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m @@ -17,6 +17,7 @@ */ #import +#import #import #import "InteropTests.h" @@ -56,8 +57,8 @@ static int32_t kLocalInteropServerOverhead = 10; return kLocalInteropServerOverhead; // bytes } -+ (GRPCTransportType)transportType { - return GRPCTransportTypeChttp2BoringSSL; ++ (GRPCTransportId)transport { + return GRPCDefaultTransportImplList.core_secure; } - (void)setUp { diff --git a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m index 98893a466bd..dc48391cbcc 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m +++ b/src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m @@ -18,9 +18,8 @@ #import -#ifdef GRPC_COMPILE_WITH_CRONET #import -#endif +#import #import #import "src/objective-c/tests/RemoteTestClient/Messages.pbobjc.h" #import "src/objective-c/tests/RemoteTestClient/Test.pbobjc.h" diff --git a/src/objective-c/tests/InteropTests/InteropTestsRemote.m b/src/objective-c/tests/InteropTests/InteropTestsRemote.m index c1cd9b81efc..2dd8f0aed89 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsRemote.m +++ b/src/objective-c/tests/InteropTests/InteropTestsRemote.m @@ -53,14 +53,8 @@ static int32_t kRemoteInteropServerOverhead = 12; return kRemoteInteropServerOverhead; // bytes } -#ifdef GRPC_COMPILE_WITH_CRONET -+ (GRPCTransportType)transportType { - return GRPCTransportTypeCronet; -} -#else + (GRPCTransportType)transportType { return GRPCTransportTypeChttp2BoringSSL; } -#endif @end diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile index c2297aa00fd..c83e8861e93 100644 --- a/src/objective-c/tests/Podfile +++ b/src/objective-c/tests/Podfile @@ -30,25 +30,25 @@ target 'MacTests' do grpc_deps end -target 'UnitTests' do - platform :ios, '8.0' - grpc_deps -end - %w( + UnitTests InteropTests - CronetTests ).each do |target_name| target target_name do platform :ios, '8.0' grpc_deps - - pod 'gRPC-Core/Cronet-Implementation', :path => GRPC_LOCAL_SRC - pod 'CronetFramework', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" - pod 'gRPC-Core/Tests', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true end end +target 'CronetTests' do + platform :ios, '8.0' + grpc_deps + + pod 'gRPC/GRPCCoreCronet', :path => GRPC_LOCAL_SRC + pod 'CronetFramework', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" + pod 'gRPC-Core/Tests', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true +end + # gRPC-Core.podspec needs to be modified to be successfully used for local development. A Podfile's # pre_install hook lets us do that. The block passed to it runs after the podspecs are downloaded # and before they are installed in the user project. @@ -103,7 +103,7 @@ post_install do |installer| # the test target 'InteropTestsRemoteWithCronet' # Activate GRPCCall+InternalTests functions for the dedicated build configuration 'Test', which will # be used by all test targets using it. - if /gRPC-(mac|i|tv)OS/.match(target.name) + if /gRPC(-macOS|-iOS|-tvOS|\.|-[0-9a-f])/.match(target.name) target.build_configurations.each do |config| if config.name == 'Cronet' config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_COMPILE_WITH_CRONET=1 GRPC_TEST_OBJC=1' @@ -114,7 +114,7 @@ post_install do |installer| end # Enable NSAssert on gRPC - if /(gRPC|ProtoRPC|RxLibrary)-(mac|i|tv)OS/.match(target.name) + if /(gRPC|ProtoRPC|RxLibrary)/.match(target.name) target.build_configurations.each do |config| if config.name != 'Release' config.build_settings['ENABLE_NS_ASSERTIONS'] = 'YES' diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index a88838fdc8b..6cb9f5560b9 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -8,15 +8,14 @@ /* Begin PBXBuildFile section */ 5E0282E9215AA697007AC99D /* NSErrorUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E0282E8215AA697007AC99D /* NSErrorUnitTests.m */; }; + 5E08D07023021E3B006D76EA /* InteropTestsMultipleChannels.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487722778226006656AD /* InteropTestsMultipleChannels.m */; }; 5E3F14842278B461007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; 5E3F14852278BF5D007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; 5E3F14862278BFFF007C6D90 /* InteropTestsBlockCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F14832278B461007C6D90 /* InteropTestsBlockCallbacks.m */; }; 5E3F148D22792856007C6D90 /* ConfigureCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F1487227918AA007C6D90 /* ConfigureCronet.m */; }; - 5E3F148E22792AF5007C6D90 /* ConfigureCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3F1487227918AA007C6D90 /* ConfigureCronet.m */; }; 5E7F486422775B37006656AD /* InteropTestsRemoteWithCronet.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EE84BF31D4717E40050C6CC /* InteropTestsRemoteWithCronet.m */; }; 5E7F486522775B41006656AD /* CronetUnitTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5EAD6D261E27047400002378 /* CronetUnitTests.mm */; }; 5E7F486E22778086006656AD /* CoreCronetEnd2EndTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F486D22778086006656AD /* CoreCronetEnd2EndTests.mm */; }; - 5E7F487922778226006656AD /* InteropTestsMultipleChannels.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487722778226006656AD /* InteropTestsMultipleChannels.m */; }; 5E7F487D22778256006656AD /* ChannelPoolTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487B22778256006656AD /* ChannelPoolTest.m */; }; 5E7F487E22778256006656AD /* ChannelTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487C22778256006656AD /* ChannelTests.m */; }; 5E7F4880227782C1006656AD /* APIv2Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F487F227782C1006656AD /* APIv2Tests.m */; }; @@ -34,6 +33,7 @@ 5EA4770322736178000F72FC /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; 5EA477042273617B000F72FC /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; 5EA4770522736AC4000F72FC /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; + 5ECFED8623030DCC00626501 /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; 65EB19E418B39A8374D407BB /* libPods-CronetTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B1511C20E16A8422B58D61A /* libPods-CronetTests.a */; }; 903163C7FE885838580AEC7A /* libPods-InteropTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D457AD9797664CFA191C3280 /* libPods-InteropTests.a */; }; 953CD2942A3A6D6CE695BE87 /* libPods-MacTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 276873A05AC5479B60DF6079 /* libPods-MacTests.a */; }; @@ -515,7 +515,6 @@ 5EA476F12272816A000F72FC /* Frameworks */, 5EA476F22272816A000F72FC /* Resources */, D11CB94CF56A1E53760D29D8 /* [CP] Copy Pods Resources */, - 0FEFD5FC6B323AC95549AE4A /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -630,6 +629,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 5ECFED8623030DCC00626501 /* TestCertificates.bundle in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -678,24 +678,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 0FEFD5FC6B323AC95549AE4A /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-frameworks.sh", - "${PODS_ROOT}/CronetFramework/Cronet.framework", - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InteropTests/Pods-InteropTests-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; 292EA42A76AC7933A37235FD /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -721,7 +703,7 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-CronetTests/Pods-CronetTests-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/gRPC-iOS/gRPCCertificates.bundle", + "${PODS_CONFIGURATION_BUILD_DIR}/gRPC.default-GRPCCoreCronet/gRPCCertificates.bundle", ); name = "[CP] Copy Pods Resources"; outputPaths = ( @@ -898,6 +880,7 @@ files = ( 5E3F14852278BF5D007C6D90 /* InteropTestsBlockCallbacks.m in Sources */, 5E3F148D22792856007C6D90 /* ConfigureCronet.m in Sources */, + 5E08D07023021E3B006D76EA /* InteropTestsMultipleChannels.m in Sources */, 5E7F486E22778086006656AD /* CoreCronetEnd2EndTests.mm in Sources */, 5E7F488522778A88006656AD /* InteropTests.m in Sources */, 5E7F486422775B37006656AD /* InteropTestsRemoteWithCronet.m in Sources */, @@ -910,9 +893,7 @@ buildActionMask = 2147483647; files = ( 5E3F14842278B461007C6D90 /* InteropTestsBlockCallbacks.m in Sources */, - 5E3F148E22792AF5007C6D90 /* ConfigureCronet.m in Sources */, 5E7F488922778B04006656AD /* InteropTestsRemote.m in Sources */, - 5E7F487922778226006656AD /* InteropTestsMultipleChannels.m in Sources */, 5EA477042273617B000F72FC /* InteropTestsLocalCleartext.m in Sources */, 5EA4770322736178000F72FC /* InteropTestsLocalSSL.m in Sources */, 5E7F488422778A88006656AD /* InteropTests.m in Sources */, diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme index adb3c366af2..cbde360a338 100644 --- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme +++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTests.xcscheme @@ -23,7 +23,7 @@ @@ -48,7 +48,7 @@ + buildConfiguration = "Test"> -#import "../../GRPCClient/private/GRPCChannel.h" -#import "../../GRPCClient/private/GRPCChannelPool+Test.h" -#import "../../GRPCClient/private/GRPCCompletionQueue.h" +#import "../../GRPCClient/private/GRPCCore/GRPCChannel.h" +#import "../../GRPCClient/private/GRPCCore/GRPCChannelPool+Test.h" +#import "../../GRPCClient/private/GRPCCore/GRPCCompletionQueue.h" #define TEST_TIMEOUT 32 diff --git a/src/objective-c/tests/UnitTests/ChannelTests.m b/src/objective-c/tests/UnitTests/ChannelTests.m index df78e8b1162..1ed0f16ecaf 100644 --- a/src/objective-c/tests/UnitTests/ChannelTests.m +++ b/src/objective-c/tests/UnitTests/ChannelTests.m @@ -19,11 +19,11 @@ #import #import "../../GRPCClient/GRPCCallOptions.h" -#import "../../GRPCClient/private/GRPCChannel.h" -#import "../../GRPCClient/private/GRPCChannelPool+Test.h" -#import "../../GRPCClient/private/GRPCChannelPool.h" -#import "../../GRPCClient/private/GRPCCompletionQueue.h" -#import "../../GRPCClient/private/GRPCWrappedCall.h" +#import "../../GRPCClient/private/GRPCCore/GRPCChannel.h" +#import "../../GRPCClient/private/GRPCCore/GRPCChannelPool+Test.h" +#import "../../GRPCClient/private/GRPCCore/GRPCChannelPool.h" +#import "../../GRPCClient/private/GRPCCore/GRPCCompletionQueue.h" +#import "../../GRPCClient/private/GRPCCore/GRPCWrappedCall.h" static NSString *kDummyHost = @"dummy.host"; static NSString *kDummyPath = @"/dummy/path"; diff --git a/src/objective-c/tests/UnitTests/NSErrorUnitTests.m b/src/objective-c/tests/UnitTests/NSErrorUnitTests.m index 8a4f03a4460..74e5794c480 100644 --- a/src/objective-c/tests/UnitTests/NSErrorUnitTests.m +++ b/src/objective-c/tests/UnitTests/NSErrorUnitTests.m @@ -20,7 +20,7 @@ #import -#import "../../GRPCClient/private/NSError+GRPC.h" +#import "../../GRPCClient/private/GRPCCore/NSError+GRPC.h" @interface NSErrorUnitTests : XCTestCase diff --git a/templates/gRPC-ProtoRPC.podspec.template b/templates/gRPC-ProtoRPC.podspec.template index 457d2988036..e94f149ee4a 100644 --- a/templates/gRPC-ProtoRPC.podspec.template +++ b/templates/gRPC-ProtoRPC.podspec.template @@ -44,22 +44,40 @@ s.module_name = name s.header_dir = name - src_dir = 'src/objective-c/ProtoRPC' + s.default_subspec = 'Main', 'Legacy', 'Legacy-Header' - s.default_subspec = 'Main' + s.subspec 'Legacy-Header' do |ss| + ss.header_mappings_dir = "src/objective-c/ProtoRPC" + ss.public_header_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.h" + ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.h" + end s.subspec 'Main' do |ss| - ss.header_mappings_dir = "#{src_dir}" - ss.dependency 'gRPC', version + ss.header_mappings_dir = "src/objective-c/ProtoRPC" + ss.dependency "#{s.name}/Legacy-Header", version + ss.dependency 'gRPC/Interface', version + ss.dependency 'Protobuf', '~> 3.0' + + ss.source_files = "src/objective-c/ProtoRPC/ProtoMethod.{h,m}", + "src/objective-c/ProtoRPC/ProtoRPC.{h,m}", + "src/objective-c/ProtoRPC/ProtoService.{h,m}" + end + + s.subspec 'Legacy' do |ss| + ss.header_mappings_dir = "src/objective-c/ProtoRPC" + ss.dependency "#{s.name}/Main", version + ss.dependency "#{s.name}/Legacy-Header", version + ss.dependency 'gRPC/GRPCCore', version ss.dependency 'gRPC-RxLibrary', version ss.dependency 'Protobuf', '~> 3.0' - ss.source_files = "#{src_dir}/*.{h,m}" + ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.m", + "src/objective-c/ProtoRPC/ProtoServiceLegacy.m" end # CFStream is now default. Leaving this subspec only for compatibility purpose. s.subspec 'CFStream' do |ss| - ss.dependency "#{s.name}/Main", version + ss.dependency "#{s.name}/Legacy", version end s.pod_target_xcconfig = { diff --git a/templates/gRPC-RxLibrary.podspec.template b/templates/gRPC-RxLibrary.podspec.template index 9389c5ecd8d..772265dadda 100644 --- a/templates/gRPC-RxLibrary.podspec.template +++ b/templates/gRPC-RxLibrary.podspec.template @@ -44,6 +44,23 @@ s.module_name = name s.header_dir = name + s.default_subspec = 'Interface', 'Implementation' + + src_dir = 'src/objective-c/RxLibrary' + s.subspec 'Interface' do |ss| + ss.header_mappings_dir = "#{src_dir}" + ss.source_files = "#{src_dir}/*.h" + ss.public_header_files = "#{src_dir}/*.h" + end + + s.subspec 'Implementation' do |ss| + ss.header_mappings_dir = "#{src_dir}" + ss.source_files = "#{src_dir}/*.m", "#{src_dir}/**/*.{h,m}" + ss.private_header_files = "#{src_dir}/**/*.h" + + ss.dependency "#{s.name}/Interface" + end + src_dir = 'src/objective-c/RxLibrary' s.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}" s.private_header_files = "#{src_dir}/private/*.h" diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index 8cb380ede03..e705edc1748 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -43,13 +43,7 @@ s.module_name = name s.header_dir = name - src_dir = 'src/objective-c/GRPCClient' - - s.dependency 'gRPC-RxLibrary', version - s.default_subspec = 'Main' - - # Certificates, to be able to establish TLS connections: - s.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } + s.default_subspec = 'Interface', 'GRPCCore', 'Interface-Legacy' s.pod_target_xcconfig = { # This is needed by all pods that depend on gRPC-RxLibrary: @@ -57,29 +51,103 @@ 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO', } - s.subspec 'Main' do |ss| - ss.header_mappings_dir = "#{src_dir}" + s.subspec 'Interface-Legacy' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' - ss.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}" - ss.exclude_files = "#{src_dir}/GRPCCall+GID.{h,m}" - ss.private_header_files = "#{src_dir}/private/*.h", "#{src_dir}/internal/*.h" + ss.public_header_files = "GRPCClient/GRPCCall+ChannelArg.h", + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", + "src/objective-c/GRPCClient/GRPCCallLegacy.h", + "src/objective-c/GRPCClient/GRPCTypes.h" + ss.source_files = "GRPCClient/GRPCCall+ChannelArg.h", + "GRPCClient/GRPCCall+ChannelCredentials.h", + "GRPCClient/GRPCCall+Cronet.h", + "GRPCClient/GRPCCall+OAuth2.h", + "GRPCClient/GRPCCall+Tests.h", + "src/objective-c/GRPCClient/GRPCCallLegacy.h", + "src/objective-c/GRPCClient/GRPCTypes.h" + ss.dependency "gRPC-RxLibrary/Interface", version + end + + s.subspec 'Interface' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' + + ss.public_header_files = 'src/objective-c/GRPCClient/GRPCCall.h', + 'src/objective-c/GRPCClient/GRPCCall+Interceptor.h', + 'src/objective-c/GRPCClient/GRPCCallOptions.h', + 'src/objective-c/GRPCClient/GRPCInterceptor.h', + 'src/objective-c/GRPCClient/GRPCTransport.h', + 'src/objective-c/GRPCClient/GRPCDispatchable.h', + 'src/objective-c/GRPCClient/version.h' + + ss.source_files = 'src/objective-c/GRPCClient/GRPCCall.h', + 'src/objective-c/GRPCClient/GRPCCall.m', + 'src/objective-c/GRPCClient/GRPCCall+Interceptor.h', + 'src/objective-c/GRPCClient/GRPCCall+Interceptor.m', + 'src/objective-c/GRPCClient/GRPCCallOptions.h', + 'src/objective-c/GRPCClient/GRPCCallOptions.m', + 'src/objective-c/GRPCClient/GRPCDispatchable.h', + 'src/objective-c/GRPCClient/GRPCInterceptor.h', + 'src/objective-c/GRPCClient/GRPCInterceptor.m', + 'src/objective-c/GRPCClient/GRPCTransport.h', + 'src/objective-c/GRPCClient/GRPCTransport.m', + 'src/objective-c/GRPCClient/internal/*.h', + 'src/objective-c/GRPCClient/private/GRPCTransport+Private.h', + 'src/objective-c/GRPCClient/private/GRPCTransport+Private.m', + 'src/objective-c/GRPCClient/version.h' + + ss.dependency "#{s.name}/Interface-Legacy", version + end + + s.subspec 'GRPCCore' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' + + ss.public_header_files = 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', + 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', + 'src/objective-c/GRPCClient/GRPCCall+Tests.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', + 'src/objective-c/GRPCClient/internal_testing/*.h' + ss.private_header_files = 'src/objective-c/GRPCClient/private/GRPCCore/*.h' + ss.source_files = 'src/objective-c/GRPCClient/internal_testing/*.{h,m}', + 'src/objective-c/GRPCClient/private/GRPCCore/*.{h,m}', + 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.m', + 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h', + 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.m', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.m', + 'src/objective-c/GRPCClient/GRPCCall+OAuth2.h', + 'src/objective-c/GRPCClient/GRPCCall+OAuth2.m', + 'src/objective-c/GRPCClient/GRPCCall+Tests.h', + 'src/objective-c/GRPCClient/GRPCCall+Tests.m', + 'src/objective-c/GRPCClient/GRPCCallLegacy.m' + + # Certificates, to be able to establish TLS connections: + ss.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } + + ss.dependency "#{s.name}/Interface-Legacy", version + ss.dependency "#{s.name}/Interface", version ss.dependency 'gRPC-Core', version + ss.dependency 'gRPC-RxLibrary', version + end + + s.subspec 'GRPCCoreCronet' do |ss| + ss.header_mappings_dir = 'src/objective-c/GRPCClient' + + ss.source_files = 'src/objective-c/GRPCClient/GRPCCall+Cronet.h', + 'src/objective-c/GRPCClient/GRPCCall+Cronet.m', + 'src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/*.{h,m}' + ss.dependency "#{s.name}/GRPCCore", version + ss.dependency 'gRPC-Core/Cronet-Implementation', version + ss.dependency 'CronetFramework' end # CFStream is now default. Leaving this subspec only for compatibility purpose. s.subspec 'CFStream' do |ss| - ss.dependency "#{s.name}/Main", version - end - - s.subspec 'GID' do |ss| - ss.ios.deployment_target = '7.0' - - ss.header_mappings_dir = "#{src_dir}" - - ss.source_files = "#{src_dir}/GRPCCall+GID.{h,m}" - - ss.dependency "#{s.name}/Main", version - ss.dependency 'Google/SignIn' + ss.dependency "#{s.name}/GRPCCore", version end end diff --git a/templates/src/objective-c/GRPCClient/private/version.h.template b/templates/src/objective-c/GRPCClient/version.h.template similarity index 100% rename from templates/src/objective-c/GRPCClient/private/version.h.template rename to templates/src/objective-c/GRPCClient/version.h.template From e70788364bf38947e9d3afb820800b14e44829b9 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 28 Aug 2019 13:50:37 -0700 Subject: [PATCH 1390/1555] Make dependency on template files explicit --- third_party/py/python_configure.bzl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/third_party/py/python_configure.bzl b/third_party/py/python_configure.bzl index 70380e9dde9..6f9a178a057 100644 --- a/third_party/py/python_configure.bzl +++ b/third_party/py/python_configure.bzl @@ -292,14 +292,24 @@ def _python_autoconf_impl(repository_ctx): python_configure = repository_rule( - implementation=_python_autoconf_impl, - environ=[ + implementation = _python_autoconf_impl, + environ = [ _BAZEL_SH, _PYTHON2_BIN_PATH, _PYTHON2_LIB_PATH, _PYTHON3_BIN_PATH, _PYTHON3_LIB_PATH, ], + attrs={ + "_build_tpl": attr.label( + default = Label("//third_party/py:BUILD.tpl"), + allow_single_file = True, + ), + "_variety_tpl": attr.label( + default = Label("//third_party/py:variety.tpl"), + allow_single_file = True, + ), + }, ) """Detects and configures the local Python. From 29bb3ef9733fbe61aa9fd7078952f5af662d1aa0 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 27 Aug 2019 10:19:40 -0700 Subject: [PATCH 1391/1555] Remove redundant MethodHandler friend declarations --- include/grpcpp/impl/codegen/byte_buffer.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/grpcpp/impl/codegen/byte_buffer.h b/include/grpcpp/impl/codegen/byte_buffer.h index 7fb678d5f7f..54886ae8086 100644 --- a/include/grpcpp/impl/codegen/byte_buffer.h +++ b/include/grpcpp/impl/codegen/byte_buffer.h @@ -173,8 +173,6 @@ class ByteBuffer final { friend class ::grpc_impl::internal::RpcMethodHandler; template friend class ::grpc_impl::internal::ServerStreamingHandler; - template - friend class ::grpc_impl::internal::RpcMethodHandler; template friend class ::grpc_impl::internal::CallbackUnaryHandler; template From 4dfa808e75fbf0fd94a9787c596bedaabb684215 Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Fri, 23 Aug 2019 17:12:41 -0700 Subject: [PATCH 1392/1555] Add test for timer expiry racing with cancelation --- test/cpp/common/timer_test.cc | 71 +++++++++++++++++++++++++++++------ 1 file changed, 60 insertions(+), 11 deletions(-) diff --git a/test/cpp/common/timer_test.cc b/test/cpp/common/timer_test.cc index 9b23be2885a..1abed1660e8 100644 --- a/test/cpp/common/timer_test.cc +++ b/test/cpp/common/timer_test.cc @@ -77,7 +77,7 @@ TEST_F(TimerTest, OneTimerExpires) { grpc_core::ExecCtx exec_ctx; grpc_timer timer; int timer_fired = 0; - grpc_timer_init(&timer, 500, + grpc_timer_init(&timer, grpc_core::ExecCtx::Get()->Now() + 500, GRPC_CLOSURE_CREATE( [](void* arg, grpc_error*) { int* timer_fired = static_cast(arg); @@ -102,7 +102,7 @@ TEST_F(TimerTest, MultipleTimersExpire) { grpc_timer timers[kNumTimers]; int timer_fired = 0; for (int i = 0; i < kNumTimers; ++i) { - grpc_timer_init(&timers[i], 500 + i, + grpc_timer_init(&timers[i], grpc_core::ExecCtx::Get()->Now() + 500 + i, GRPC_CLOSURE_CREATE( [](void* arg, grpc_error*) { int* timer_fired = static_cast(arg); @@ -129,7 +129,7 @@ TEST_F(TimerTest, CancelSomeTimers) { grpc_timer timers[kNumTimers]; int timer_fired = 0; for (int i = 0; i < kNumTimers; ++i) { - grpc_timer_init(&timers[i], 500 + i, + grpc_timer_init(&timers[i], grpc_core::ExecCtx::Get()->Now() + 500 + i, GRPC_CLOSURE_CREATE( [](void* arg, grpc_error* error) { if (error == GRPC_ERROR_CANCELLED) { @@ -157,17 +157,66 @@ TEST_F(TimerTest, CancelSomeTimers) { // Enable the following test after // https://github.com/grpc/grpc/issues/20049 has been fixed. -#if 0 -TEST_F(TimerTest, TimerNotCanceled) { +TEST_F(TimerTest, DISABLED_TimerNotCanceled) { grpc_core::ExecCtx exec_ctx; grpc_timer timer; - grpc_timer_init(&timer, 10000, - GRPC_CLOSURE_CREATE( - [](void*, grpc_error*) { - }, - nullptr, grpc_schedule_on_exec_ctx)); + grpc_timer_init(&timer, grpc_core::ExecCtx::Get()->Now() + 10000, + GRPC_CLOSURE_CREATE([](void*, grpc_error*) {}, nullptr, + grpc_schedule_on_exec_ctx)); +} + +// Enable the following test after +// https://github.com/grpc/grpc/issues/20064 has been fixed. +TEST_F(TimerTest, DISABLED_CancelRace) { + MAYBE_SKIP_TEST; + grpc_core::ExecCtx exec_ctx; + const int kNumTimers = 10; + grpc_timer timers[kNumTimers]; + for (int i = 0; i < kNumTimers; ++i) { + grpc_timer* arg = (i != 0) ? &timers[i - 1] : nullptr; + grpc_timer_init(&timers[i], grpc_core::ExecCtx::Get()->Now() + 100, + GRPC_CLOSURE_CREATE( + [](void* arg, grpc_error* error) { + grpc_timer* timer = static_cast(arg); + if (timer) { + grpc_timer_cancel(timer); + } + }, + arg, grpc_schedule_on_exec_ctx)); + } + gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(100)); +} + +// Enable the following test after +// https://github.com/grpc/grpc/issues/20066 has been fixed. +TEST_F(TimerTest, DISABLED_CancelNextTimer) { + MAYBE_SKIP_TEST; + grpc_core::ExecCtx exec_ctx; + const int kNumTimers = 10; + grpc_timer timers[kNumTimers]; + + for (int i = 0; i < kNumTimers; ++i) { + grpc_timer_init_unset(&timers[i]); + } + + for (int i = 0; i < kNumTimers; ++i) { + grpc_timer* arg = nullptr; + if (i < kNumTimers - 1) { + arg = &timers[i + 1]; + } + grpc_timer_init(&timers[i], grpc_core::ExecCtx::Get()->Now() + 100, + GRPC_CLOSURE_CREATE( + [](void* arg, grpc_error* error) { + grpc_timer* timer = static_cast(arg); + if (timer) { + grpc_timer_cancel(timer); + } + }, + arg, grpc_schedule_on_exec_ctx)); + } + grpc_timer_cancel(&timers[0]); + gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(100)); } -#endif int main(int argc, char** argv) { grpc::testing::TestEnvironment env(argc, argv); From 156a4cccdfe88580c6fb1b87a6a247e222b0fd3a Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 28 Aug 2019 18:00:38 -0700 Subject: [PATCH 1393/1555] Remove unusued arg --- src/core/lib/surface/call.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 1331e57ab0c..7bb818b91c9 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -1128,8 +1128,7 @@ static size_t batch_slot_for_op(grpc_op_type type) { } static batch_control* reuse_or_allocate_batch_control(grpc_call* call, - const grpc_op* ops, - size_t num_ops) { + const grpc_op* ops) { size_t slot_idx = batch_slot_for_op(ops[0].op); batch_control** pslot = &call->active_batches[slot_idx]; batch_control* bctl; @@ -1545,7 +1544,7 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops, goto done; } - bctl = reuse_or_allocate_batch_control(call, ops, nops); + bctl = reuse_or_allocate_batch_control(call, ops); if (bctl == nullptr) { return GRPC_CALL_ERROR_TOO_MANY_OPERATIONS; } From d34f3663379f7e010e985860b27d9f12ba702f32 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Wed, 28 Aug 2019 21:46:53 -0700 Subject: [PATCH 1394/1555] Test message size of 100MB --- test/core/util/test_config.cc | 4 +++ test/core/util/test_config.h | 3 ++ test/cpp/end2end/async_end2end_test.cc | 38 ++++++++++++++++++++++---- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/test/core/util/test_config.cc b/test/core/util/test_config.cc index 5b248a01daa..5033dc7b66a 100644 --- a/test/core/util/test_config.cc +++ b/test/core/util/test_config.cc @@ -342,6 +342,10 @@ bool BuiltUnderUbsan() { #endif } +bool grpc_test_built_under_tsan_or_msan() { + return BuiltUnderTsan() || BuiltUnderMsan(); +}; + int64_t grpc_test_sanitizer_slowdown_factor() { int64_t sanitizer_multiplier = 1; if (BuiltUnderValgrind()) { diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h index 112af3176f9..905d61f1dd6 100644 --- a/test/core/util/test_config.h +++ b/test/core/util/test_config.h @@ -24,6 +24,9 @@ extern int64_t g_fixture_slowdown_factor; extern int64_t g_poller_slowdown_factor; +/* Returns if the test is built under TSAN or MSAN. */ +bool grpc_test_built_under_tsan_or_msan(); + /* Returns an appropriate scaling factor for timeouts. */ int64_t grpc_test_slowdown_factor(); diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 6ca0edf123e..879f16815ee 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -34,6 +34,7 @@ #include "src/core/ext/filters/client_channel/backup_poller.h" #include "src/core/lib/gpr/tls.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/port.h" #include "src/proto/grpc/health/v1/health.grpc.pb.h" #include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" @@ -59,6 +60,18 @@ namespace testing { namespace { +const size_t MAX_TEST_MESSAGE_SIZE = +#if defined(GPR_APPLE) + // The test will time out with macos build. + GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH; +#else + // Don't test extreme size under tsan or msan, because it uses too much + // memory. + grpc_test_built_under_tsan_or_msan() + ? GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH + : GPR_MAX(100 * 1024 * 1024, GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH); +#endif + void* tag(int i) { return (void*)static_cast(i); } int detag(void* p) { return static_cast(reinterpret_cast(p)); } @@ -218,6 +231,17 @@ class ServerBuilderSyncPluginDisabler : public ::grpc::ServerBuilderOption { } }; +class ServerBuilderMaxRecvMessageSizeOption + : public ::grpc::ServerBuilderOption { + public: + void UpdateArguments(ChannelArguments* arg) override { + arg->SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, -1); + } + + void UpdatePlugins( + std::vector>* plugins) override {} +}; + class TestScenario { public: TestScenario(bool inproc_stub, const grpc::string& creds_type, bool hcs, @@ -290,6 +314,9 @@ class AsyncEnd2endTest : public ::testing::TestWithParam { std::unique_ptr sync_plugin_disabler( new ServerBuilderSyncPluginDisabler()); builder.SetOption(move(sync_plugin_disabler)); + std::unique_ptr max_recv_option( + new ServerBuilderMaxRecvMessageSizeOption()); + builder.SetOption(move(max_recv_option)); server_ = builder.BuildAndStart(); } @@ -297,6 +324,7 @@ class AsyncEnd2endTest : public ::testing::TestWithParam { ChannelArguments args; auto channel_creds = GetCredentialsProvider()->GetChannelCredentials( GetParam().credentials_type, &args); + args.SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, -1); std::shared_ptr channel = !(GetParam().inproc) ? ::grpc::CreateCustomChannel( server_address_.str(), channel_creds, args) @@ -1822,7 +1850,7 @@ TEST_P(AsyncEnd2endServerTryCancelTest, ServerBidiStreamingTryCancelAfter) { } std::vector CreateTestScenarios(bool test_secure, - bool test_message_size_limit) { + bool test_big_message) { std::vector scenarios; std::vector credentials_types; std::vector messages; @@ -1844,9 +1872,8 @@ std::vector CreateTestScenarios(bool test_secure, GPR_ASSERT(!credentials_types.empty()); messages.push_back("Hello"); - if (test_message_size_limit) { - for (size_t k = 1; k < GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH / 1024; - k *= 32) { + if (test_big_message) { + for (size_t k = 1; k < MAX_TEST_MESSAGE_SIZE / 1024; k *= 32) { grpc::string big_msg; for (size_t i = 0; i < k * 1024; ++i) { char c = 'a' + (i % 26); @@ -1854,8 +1881,7 @@ std::vector CreateTestScenarios(bool test_secure, } messages.push_back(big_msg); } - messages.push_back( - grpc::string(GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH - 10, 'a')); + messages.push_back(grpc::string(MAX_TEST_MESSAGE_SIZE - 10, 'a')); } // TODO (sreek) Renable tests with health check service after the issue From f113001d14410814777a7475867132107c7c77d6 Mon Sep 17 00:00:00 2001 From: Pavel Koshelev Date: Thu, 29 Aug 2019 11:49:47 +0300 Subject: [PATCH 1395/1555] Enable bitcode for ios native libraries --- src/csharp/experimental/build_native_ext_for_ios.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/csharp/experimental/build_native_ext_for_ios.sh b/src/csharp/experimental/build_native_ext_for_ios.sh index 130f4c51e96..876588daa06 100755 --- a/src/csharp/experimental/build_native_ext_for_ios.sh +++ b/src/csharp/experimental/build_native_ext_for_ios.sh @@ -28,7 +28,7 @@ function build { PATH_CC="$(xcrun --sdk $SDK --find clang)" PATH_CXX="$(xcrun --sdk $SDK --find clang++)" - CPPFLAGS="-O2 -Wframe-larger-than=16384 -arch $ARCH -isysroot $(xcrun --sdk $SDK --show-sdk-path) -mios-version-min=6.0 -DPB_NO_PACKED_STRUCTS=1" + CPPFLAGS="-O2 -Wframe-larger-than=16384 -arch $ARCH -isysroot $(xcrun --sdk $SDK --show-sdk-path) -fembed-bitcode -mios-version-min=6.0 -DPB_NO_PACKED_STRUCTS=1" LDFLAGS="-arch $ARCH -isysroot $(xcrun --sdk $SDK --show-sdk-path) -Wl,ios_version_min=6.0" # TODO(jtattermusch): revisit the build arguments From cb6d3a0623bd19510610c07f7d114b33dc603793 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 29 Aug 2019 14:52:19 +0200 Subject: [PATCH 1396/1555] address review feedback --- src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs | 2 +- src/csharp/ext/grpc_csharp_ext.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs index 77c14f1d9fb..9cbdce1cfe3 100644 --- a/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/SliceBufferSafeHandle.cs @@ -138,7 +138,7 @@ namespace Grpc.Core.Internal // if no hint is provided, keep the available space within some "reasonable" boundaries. // This is quite a naive approach which could use some fine-tuning, but currently in most case we know // the required buffer size in advance anyway, so this approach seems good enough for now. - if (tailSpaceLen < DefaultTailSpaceSize /2 ) + if (tailSpaceLen < DefaultTailSpaceSize / 2) { AdjustTailSpace(DefaultTailSpaceSize); } diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 2360c9e1d5f..d9bf85e02c7 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -44,8 +44,7 @@ static grpc_byte_buffer* grpcsharp_create_byte_buffer_from_stolen_slices( grpc_slice_buffer* slice_buffer) { grpc_byte_buffer* bb = - (grpc_byte_buffer*)gpr_malloc(sizeof(grpc_byte_buffer)); - memset(bb, 0, sizeof(grpc_byte_buffer)); + (grpc_byte_buffer*)gpr_zalloc(sizeof(grpc_byte_buffer)); bb->type = GRPC_BB_RAW; bb->data.raw.compression = GRPC_COMPRESS_NONE; grpc_slice_buffer_init(&bb->data.raw.slice_buffer); From 7357f63c09096f4dcff953ff87a5cc59e2a726c9 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 29 Aug 2019 10:39:04 -0400 Subject: [PATCH 1397/1555] update check_submodules.sh and grpc_deps.bzl --- bazel/grpc_deps.bzl | 6 +++--- tools/run_tests/sanity/check_submodules.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index b226f15aa2a..7bee7547b61 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -157,9 +157,9 @@ def grpc_deps(): if "com_github_google_benchmark" not in native.existing_rules(): http_archive( name = "com_github_google_benchmark", - sha256 = "c7682e9007ddfd94072647abab3e89ffd9084089460ae47d67060974467b58bf", - strip_prefix = "benchmark-e776aa0275e293707b6a0901e0e8d8a8a3679508", - url = "https://github.com/google/benchmark/archive/e776aa0275e293707b6a0901e0e8d8a8a3679508.tar.gz", + sha256 = "f68aec93154d010324c05bcd8c5cc53468b87af88d87acb5ddcfaa1bba044837", + strip_prefix = "benchmark-090faecb454fbd6e6e17a75ef8146acb037118d4", + url = "https://github.com/google/benchmark/archive/090faecb454fbd6e6e17a75ef8146acb037118d4.tar.gz", ) if "com_github_cares_cares" not in native.existing_rules(): diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index d5eb6677796..98c1a1ecb5c 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -27,7 +27,7 @@ want_submodules=$(mktemp /tmp/submXXXXXX) git submodule | awk '{ print $1 }' | sort > "$submodules" cat << EOF | awk '{ print $1 }' | sort > "$want_submodules" 74d91756c11bc22f9b0108b94da9326f7f9e376f third_party/abseil-cpp (74d9175) - e776aa0275e293707b6a0901e0e8d8a8a3679508 third_party/benchmark (v1.2.0) + 090faecb454fbd6e6e17a75ef8146acb037118d4 third_party/benchmark (v1.5.0) 73594cde8c9a52a102c4341c244c833aa61b9c06 third_party/bloaty (remotes/origin/wide-14-g73594cd) b29b21a81b32ec273f118f589f46d56ad3332420 third_party/boringssl (remotes/origin/chromium-stable) afc30d43eef92979b05776ec0963c9cede5fb80f third_party/boringssl-with-bazel (fips-20180716-116-gafc30d43e) From 0ee7a3ae9321a7af2151070feef6bf11be2a9890 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 29 Aug 2019 10:40:22 -0400 Subject: [PATCH 1398/1555] regenerate projects --- Makefile | 3 +++ grpc.gyp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Makefile b/Makefile index a0692f38d20..afeda543c40 100644 --- a/Makefile +++ b/Makefile @@ -7954,8 +7954,11 @@ endif LIBBENCHMARK_SRC = \ third_party/benchmark/src/benchmark.cc \ + third_party/benchmark/src/benchmark_api_internal.cc \ third_party/benchmark/src/benchmark_main.cc \ + third_party/benchmark/src/benchmark_name.cc \ third_party/benchmark/src/benchmark_register.cc \ + third_party/benchmark/src/benchmark_runner.cc \ third_party/benchmark/src/colorprint.cc \ third_party/benchmark/src/commandlineflags.cc \ third_party/benchmark/src/complexity.cc \ diff --git a/grpc.gyp b/grpc.gyp index ba847d99548..aef5f61fb2a 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -2241,8 +2241,11 @@ ], 'sources': [ 'third_party/benchmark/src/benchmark.cc', + 'third_party/benchmark/src/benchmark_api_internal.cc', 'third_party/benchmark/src/benchmark_main.cc', + 'third_party/benchmark/src/benchmark_name.cc', 'third_party/benchmark/src/benchmark_register.cc', + 'third_party/benchmark/src/benchmark_runner.cc', 'third_party/benchmark/src/colorprint.cc', 'third_party/benchmark/src/commandlineflags.cc', 'third_party/benchmark/src/complexity.cc', From 24c562dbaa95539031c45ab4bdce5070ca6c2af5 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Thu, 29 Aug 2019 10:47:44 -0700 Subject: [PATCH 1399/1555] Revert "Merge pull request #20097 from gnossen/dual_version_python_tests" This reverts commit c9c847f334d9310f01456c5f69ec983cfcb99496, reversing changes made to 07ba4de3927dbb2c71b92b4ca38b2fcd1b52e306. --- BUILD | 2 +- bazel/grpc_build_system.bzl | 11 +- bazel/grpc_deps.bzl | 15 ++- bazel/grpc_python_deps.bzl | 9 -- bazel/python_rules.bzl | 26 ----- examples/python/auth/BUILD.bazel | 3 - examples/python/cancellation/BUILD.bazel | 3 - examples/python/compression/BUILD.bazel | 3 - examples/python/debug/BUILD.bazel | 3 - examples/python/errors/BUILD.bazel | 1 - examples/python/multiprocessing/BUILD | 3 - examples/python/wait_for_ready/BUILD.bazel | 1 - .../grpcio_tests/tests/channelz/BUILD.bazel | 4 +- .../tests/health_check/BUILD.bazel | 3 +- .../grpcio_tests/tests/interop/BUILD.bazel | 5 +- .../grpcio_tests/tests/reflection/BUILD.bazel | 3 +- .../grpcio_tests/tests/status/BUILD.bazel | 3 +- .../grpcio_tests/tests/unit/BUILD.bazel | 4 +- .../tests/unit/_cython/BUILD.bazel | 3 +- .../unit/framework/foundation/BUILD.bazel | 3 +- templates/tools/dockerfile/bazel.include | 2 +- third_party/py/BUILD.tpl | 49 ++++----- third_party/py/python_configure.bzl | 104 +++++++----------- third_party/py/remote.BUILD.tpl | 10 ++ third_party/py/variety.tpl | 26 ----- tools/bazel | 2 +- tools/bazel.rc | 4 + tools/dockerfile/test/bazel/Dockerfile | 2 +- tools/dockerfile/test/sanity/Dockerfile | 2 +- .../linux/grpc_python_bazel_test_in_docker.sh | 3 + tools/remote_build/kokoro.bazelrc | 7 +- tools/remote_build/manual.bazelrc | 7 +- tools/remote_build/rbe_common.bazelrc | 2 +- 33 files changed, 114 insertions(+), 214 deletions(-) create mode 100644 third_party/py/remote.BUILD.tpl delete mode 100644 third_party/py/variety.tpl diff --git a/BUILD b/BUILD index e489bc2584a..9198dd61282 100644 --- a/BUILD +++ b/BUILD @@ -65,7 +65,7 @@ config_setting( config_setting( name = "python3", - flag_values = {"@bazel_tools//tools/python:python_version": "PY3"}, + values = {"python_path": "python3"}, ) config_setting( diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index f4777e50bc1..f386b87b583 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -269,22 +269,13 @@ def grpc_sh_binary(name, srcs, data = []): data = data, ) -def grpc_py_binary(name, - srcs, - data = [], - deps = [], - external_deps = [], - testonly = False, - python_version = "PY2", - **kwargs): +def grpc_py_binary(name, srcs, data = [], deps = [], external_deps = [], testonly = False): native.py_binary( name = name, srcs = srcs, testonly = testonly, data = data, deps = deps + _get_external_deps(external_deps), - python_version = python_version, - **kwargs ) def grpc_package(name, visibility = "private", features = []): diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 6bbb960b6c3..06323ff3f24 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -176,11 +176,11 @@ def grpc_deps(): if "bazel_toolchains" not in native.existing_rules(): http_archive( name = "bazel_toolchains", - sha256 = "872955b658113924eb1a3594b04d43238da47f4f90c17b76e8785709490dc041", - strip_prefix = "bazel-toolchains-1083686fde6032378d52b4c98044922cebde364e", + sha256 = "d968b414b32aa99c86977e1171645d31da2b52ac88060de3ac1e49932d5dcbf1", + strip_prefix = "bazel-toolchains-4bd5df80d77aa7f4fb943dfdfad5c9056a62fb47", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/1083686fde6032378d52b4c98044922cebde364e.tar.gz", - "https://github.com/bazelbuild/bazel-toolchains/archive/1083686fde6032378d52b4c98044922cebde364e.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/4bd5df80d77aa7f4fb943dfdfad5c9056a62fb47.tar.gz", + "https://github.com/bazelbuild/bazel-toolchains/archive/4bd5df80d77aa7f4fb943dfdfad5c9056a62fb47.tar.gz", ], ) @@ -221,11 +221,10 @@ def grpc_deps(): ) if "build_bazel_rules_apple" not in native.existing_rules(): - http_archive( + git_repository( name = "build_bazel_rules_apple", - url = "https://github.com/bazelbuild/rules_apple/archive/b869b0d3868d78a1d4ffd866ccb304fb68aa12c3.tar.gz", - strip_prefix = "rules_apple-b869b0d3868d78a1d4ffd866ccb304fb68aa12c3", - sha256 = "bdc8e66e70b8a75da23b79f1f8c6207356df07d041d96d2189add7ee0780cf4e", + remote = "https://github.com/bazelbuild/rules_apple.git", + tag = "0.17.2", ) grpc_python_deps() diff --git a/bazel/grpc_python_deps.bzl b/bazel/grpc_python_deps.bzl index 2a439bdf226..4e7cc1537fa 100644 --- a/bazel/grpc_python_deps.bzl +++ b/bazel/grpc_python_deps.bzl @@ -47,15 +47,6 @@ def grpc_python_deps(): remote = "https://github.com/bazelbuild/rules_python.git", ) - - if "rules_python" not in native.existing_rules(): - http_archive( - name = "rules_python", - url = "https://github.com/bazelbuild/rules_python/archive/9d68f24659e8ce8b736590ba1e4418af06ec2552.zip", - sha256 = "f7402f11691d657161f871e11968a984e5b48b023321935f5a55d7e56cf4758a", - strip_prefix = "rules_python-9d68f24659e8ce8b736590ba1e4418af06ec2552", - ) - python_configure(name = "local_config_python") native.bind( diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index e7e9e597b05..12f51f8b172 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -178,29 +178,3 @@ def py_grpc_library( deps = [Label("//src/python/grpcio/grpc:grpcio")] + deps, **kwargs ) - - -def py2and3_test(name, - py_test = native.py_test, - **kwargs): - if "python_version" in kwargs: - fail("Cannot specify 'python_version' in py2and3_test.") - - names = [name + suffix for suffix in (".python2", ".python3")] - python_versions = ["PY2", "PY3"] - for case_name, python_version in zip(names, python_versions): - py_test( - name = case_name, - python_version = python_version, - **kwargs - ) - - suite_kwargs = {} - if "visibility" in kwargs: - suite_kwargs["visibility"] = kwargs["visibility"] - - native.test_suite( - name = name, - tests = names, - **suite_kwargs - ) diff --git a/examples/python/auth/BUILD.bazel b/examples/python/auth/BUILD.bazel index 72620ee46c5..cc454fdfdfe 100644 --- a/examples/python/auth/BUILD.bazel +++ b/examples/python/auth/BUILD.bazel @@ -39,7 +39,6 @@ py_binary( "//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2_grpc", ], - python_version = "PY3", ) py_binary( @@ -52,7 +51,6 @@ py_binary( "//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2_grpc", ], - python_version = "PY3", ) py_test( @@ -65,5 +63,4 @@ py_test( ":customized_auth_server", ":_credentials", ], - python_version = "PY3", ) diff --git a/examples/python/cancellation/BUILD.bazel b/examples/python/cancellation/BUILD.bazel index b4451f60711..17b1b20168e 100644 --- a/examples/python/cancellation/BUILD.bazel +++ b/examples/python/cancellation/BUILD.bazel @@ -45,7 +45,6 @@ py_binary( "//external:six" ], srcs_version = "PY2AND3", - python_version = "PY3", ) py_library( @@ -69,7 +68,6 @@ py_binary( "//:python3": [], }), srcs_version = "PY2AND3", - python_version = "PY3", ) py_test( @@ -80,5 +78,4 @@ py_test( ":server" ], size = "small", - python_version = "PY3", ) diff --git a/examples/python/compression/BUILD.bazel b/examples/python/compression/BUILD.bazel index 4141eda2ffd..9d5f6bb83ed 100644 --- a/examples/python/compression/BUILD.bazel +++ b/examples/python/compression/BUILD.bazel @@ -21,7 +21,6 @@ py_binary( "//examples:helloworld_py_pb2_grpc", ], srcs_version = "PY2AND3", - python_version = "PY3", ) py_binary( @@ -33,7 +32,6 @@ py_binary( "//examples:helloworld_py_pb2_grpc", ], srcs_version = "PY2AND3", - python_version = "PY3", ) py_test( @@ -45,5 +43,4 @@ py_test( ":server", ], size = "small", - python_version = "PY3", ) diff --git a/examples/python/debug/BUILD.bazel b/examples/python/debug/BUILD.bazel index 332991332f8..657ae860ae3 100644 --- a/examples/python/debug/BUILD.bazel +++ b/examples/python/debug/BUILD.bazel @@ -35,7 +35,6 @@ py_binary( "//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2_grpc", ], - python_version = "PY3", ) py_binary( @@ -46,7 +45,6 @@ py_binary( "//src/python/grpcio/grpc:grpcio", "//src/python/grpcio_channelz/grpc_channelz/v1:grpc_channelz", ], - python_version = "PY3", ) py_test( @@ -61,5 +59,4 @@ py_test( ":send_message", ":get_stats", ], - python_version = "PY3", ) diff --git a/examples/python/errors/BUILD.bazel b/examples/python/errors/BUILD.bazel index 367bd81925f..4b779ddfcf1 100644 --- a/examples/python/errors/BUILD.bazel +++ b/examples/python/errors/BUILD.bazel @@ -55,5 +55,4 @@ py_test( "../../../src/python/grpcio_status", "../../../src/python/grpcio_tests", ], - python_version = "PY3", ) diff --git a/examples/python/multiprocessing/BUILD b/examples/python/multiprocessing/BUILD index 2503970bc80..490aea0c1e6 100644 --- a/examples/python/multiprocessing/BUILD +++ b/examples/python/multiprocessing/BUILD @@ -42,7 +42,6 @@ py_binary( ":prime_proto_pb2_grpc", ], srcs_version = "PY3", - python_version = "PY3", ) py_binary( @@ -58,7 +57,6 @@ py_binary( "//:python3": [], }), srcs_version = "PY3", - python_version = "PY3", ) py_test( @@ -69,5 +67,4 @@ py_test( ":server" ], size = "small", - python_version = "PY3", ) diff --git a/examples/python/wait_for_ready/BUILD.bazel b/examples/python/wait_for_ready/BUILD.bazel index 9cbddd1a6e3..f074ae7bb7f 100644 --- a/examples/python/wait_for_ready/BUILD.bazel +++ b/examples/python/wait_for_ready/BUILD.bazel @@ -30,5 +30,4 @@ py_test( srcs = ["test/_wait_for_ready_example_test.py"], deps = [":wait_for_ready_example",], size = "small", - python_version = "PY3", ) diff --git a/src/python/grpcio_tests/tests/channelz/BUILD.bazel b/src/python/grpcio_tests/tests/channelz/BUILD.bazel index f4d246847f7..63513616e77 100644 --- a/src/python/grpcio_tests/tests/channelz/BUILD.bazel +++ b/src/python/grpcio_tests/tests/channelz/BUILD.bazel @@ -1,8 +1,6 @@ package(default_visibility = ["//visibility:public"]) -load("//bazel:python_rules.bzl", "py2and3_test") - -py2and3_test( +py_test( name = "channelz_servicer_test", srcs = ["_channelz_servicer_test.py"], main = "_channelz_servicer_test.py", diff --git a/src/python/grpcio_tests/tests/health_check/BUILD.bazel b/src/python/grpcio_tests/tests/health_check/BUILD.bazel index 797b6a48e91..49f076be9a1 100644 --- a/src/python/grpcio_tests/tests/health_check/BUILD.bazel +++ b/src/python/grpcio_tests/tests/health_check/BUILD.bazel @@ -1,7 +1,6 @@ package(default_visibility = ["//visibility:public"]) -load("//bazel:python_rules.bzl", "py2and3_test") -py2and3_test( +py_test( name = "health_servicer_test", srcs = ["_health_servicer_test.py"], main = "_health_servicer_test.py", diff --git a/src/python/grpcio_tests/tests/interop/BUILD.bazel b/src/python/grpcio_tests/tests/interop/BUILD.bazel index 4685852162b..8ac3f7d52d5 100644 --- a/src/python/grpcio_tests/tests/interop/BUILD.bazel +++ b/src/python/grpcio_tests/tests/interop/BUILD.bazel @@ -1,5 +1,4 @@ load("@grpc_python_dependencies//:requirements.bzl", "requirement") -load("//bazel:python_rules.bzl", "py2and3_test") package(default_visibility = ["//visibility:public"]) @@ -81,7 +80,7 @@ py_library( ], ) -py2and3_test( +py_test( name = "_insecure_intraop_test", size = "small", srcs = ["_insecure_intraop_test.py"], @@ -100,7 +99,7 @@ py2and3_test( ], ) -py2and3_test( +py_test( name = "_secure_intraop_test", size = "small", srcs = ["_secure_intraop_test.py"], diff --git a/src/python/grpcio_tests/tests/reflection/BUILD.bazel b/src/python/grpcio_tests/tests/reflection/BUILD.bazel index 65a08c2a435..e9b56191df8 100644 --- a/src/python/grpcio_tests/tests/reflection/BUILD.bazel +++ b/src/python/grpcio_tests/tests/reflection/BUILD.bazel @@ -1,9 +1,8 @@ load("@grpc_python_dependencies//:requirements.bzl", "requirement") -load("//bazel:python_rules.bzl", "py2and3_test") package(default_visibility = ["//visibility:public"]) -py2and3_test( +py_test( name="_reflection_servicer_test", size="small", timeout="moderate", diff --git a/src/python/grpcio_tests/tests/status/BUILD.bazel b/src/python/grpcio_tests/tests/status/BUILD.bazel index 0868de01acf..b163fe3975e 100644 --- a/src/python/grpcio_tests/tests/status/BUILD.bazel +++ b/src/python/grpcio_tests/tests/status/BUILD.bazel @@ -1,9 +1,8 @@ load("@grpc_python_dependencies//:requirements.bzl", "requirement") -load("//bazel:python_rules.bzl", "py2and3_test") package(default_visibility = ["//visibility:public"]) -py2and3_test( +py_test( name = "grpc_status_test", srcs = ["_grpc_status_test.py"], main = "_grpc_status_test.py", diff --git a/src/python/grpcio_tests/tests/unit/BUILD.bazel b/src/python/grpcio_tests/tests/unit/BUILD.bazel index 587d8cb246f..49203b7fa16 100644 --- a/src/python/grpcio_tests/tests/unit/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/BUILD.bazel @@ -1,5 +1,3 @@ -load("//bazel:python_rules.bzl", "py2and3_test") - package(default_visibility = ["//visibility:public"]) GRPCIO_TESTS_UNIT = [ @@ -82,7 +80,7 @@ py_library( ) [ - py2and3_test( + py_test( name=test_file_name[:-3], size="small", srcs=[test_file_name], diff --git a/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel b/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel index 867649a6a50..458a6b1fb8a 100644 --- a/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel @@ -1,5 +1,4 @@ load("@grpc_python_dependencies//:requirements.bzl", "requirement") -load("//bazel:python_rules.bzl", "py2and3_test") package(default_visibility = ["//visibility:public"]) @@ -24,7 +23,7 @@ py_library( ) [ - py2and3_test( + py_test( name=test_file_name[:-3], size="small", srcs=[test_file_name], diff --git a/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel b/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel index a93249301c4..d69186e1fde 100644 --- a/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel @@ -1,12 +1,11 @@ package(default_visibility = ["//visibility:public"]) -load("//bazel:python_rules.bzl", "py2and3_test") py_library( name = "stream_testing", srcs = ["stream_testing.py"], ) -py2and3_test( +py_test( name = "logging_pool_test", srcs = ["_logging_pool_test.py"], main = "_logging_pool_test.py", diff --git a/templates/tools/dockerfile/bazel.include b/templates/tools/dockerfile/bazel.include index 12a22785623..adde6ed4787 100644 --- a/templates/tools/dockerfile/bazel.include +++ b/templates/tools/dockerfile/bazel.include @@ -2,7 +2,7 @@ # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.28.1 +ENV BAZEL_VERSION 0.26.0 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/third_party/py/BUILD.tpl b/third_party/py/BUILD.tpl index 8f010f85a03..2283c573bc3 100644 --- a/third_party/py/BUILD.tpl +++ b/third_party/py/BUILD.tpl @@ -2,36 +2,35 @@ package(default_visibility=["//visibility:public"]) +# To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib +# See https://docs.python.org/3/extending/windows.html +cc_import( + name="python_lib", + interface_library=select({ + ":windows": ":python_import_lib", + # A placeholder for Unix platforms which makes --no_build happy. + "//conditions:default": "not-existing.lib", + }), + system_provided=1, +) + +cc_library( + name="python_headers", + hdrs=[":python_include"], + deps=select({ + ":windows": [":python_lib"], + "//conditions:default": [], + }), + includes=["python_include"], +) + config_setting( name="windows", values={"cpu": "x64_windows"}, visibility=["//visibility:public"], ) -config_setting( - name="python2", - flag_values = {"@rules_python//python:python_version": "PY2"} -) +%{PYTHON_INCLUDE_GENRULE} +%{PYTHON_IMPORT_LIB_GENRULE} -config_setting( - name="python3", - flag_values = {"@rules_python//python:python_version": "PY3"} -) -cc_library( - name = "python_lib", - deps = select({ - ":python2": ["//_python2:_python2_lib"], - ":python3": ["//_python3:_python3_lib"], - "//conditions:default": ["not-existing.lib"], - }) -) - -cc_library( - name = "python_headers", - deps = select({ - ":python2": ["//_python2:_python2_headers"], - ":python3": ["//_python3:_python3_headers"], - "//conditions:default": ["not-existing.headers"], - }) -) diff --git a/third_party/py/python_configure.bzl b/third_party/py/python_configure.bzl index 6f9a178a057..e6fa5ed10e9 100644 --- a/third_party/py/python_configure.bzl +++ b/third_party/py/python_configure.bzl @@ -3,15 +3,14 @@ `python_configure` depends on the following environment variables: - * `PYTHON2_BIN_PATH`: location of python binary. - * `PYTHON2_LIB_PATH`: Location of python libraries. + * `PYTHON_BIN_PATH`: location of python binary. + * `PYTHON_LIB_PATH`: Location of python libraries. """ _BAZEL_SH = "BAZEL_SH" -_PYTHON2_BIN_PATH = "PYTHON2_BIN_PATH" -_PYTHON2_LIB_PATH = "PYTHON2_LIB_PATH" -_PYTHON3_BIN_PATH = "PYTHON3_BIN_PATH" -_PYTHON3_LIB_PATH = "PYTHON3_LIB_PATH" +_PYTHON_BIN_PATH = "PYTHON_BIN_PATH" +_PYTHON_LIB_PATH = "PYTHON_LIB_PATH" +_PYTHON_CONFIG_REPO = "PYTHON_CONFIG_REPO" def _tpl(repository_ctx, tpl, substitutions={}, out=None): @@ -137,9 +136,9 @@ def _symlink_genrule_for_dir(repository_ctx, "\n".join(outs)) -def _get_python_bin(repository_ctx, bin_path_key, default_bin_path): +def _get_python_bin(repository_ctx): """Gets the python bin path.""" - python_bin = repository_ctx.os.environ.get(bin_path_key, default_bin_path) + python_bin = repository_ctx.os.environ.get(_PYTHON_BIN_PATH, 'python') if not repository_ctx.path(python_bin).exists: # It's a command, use 'which' to find its path. python_bin_path = repository_ctx.which(python_bin) @@ -151,7 +150,7 @@ def _get_python_bin(repository_ctx, bin_path_key, default_bin_path): _fail("Cannot find python in PATH, please make sure " + "python is installed and add its directory in PATH, or --define " + "%s='/something/else'.\nPATH=%s" % - (bin_path_key, repository_ctx.os.environ.get("PATH", ""))) + (_PYTHON_BIN_PATH, repository_ctx.os.environ.get("PATH", ""))) def _get_bash_bin(repository_ctx): @@ -171,9 +170,9 @@ def _get_bash_bin(repository_ctx): (_BAZEL_SH, repository_ctx.os.environ.get("PATH", ""))) -def _get_python_lib(repository_ctx, python_bin, lib_path_key): +def _get_python_lib(repository_ctx, python_bin): """Gets the python lib path.""" - python_lib = repository_ctx.os.environ.get(lib_path_key) + python_lib = repository_ctx.os.environ.get(_PYTHON_LIB_PATH) if python_lib != None: return python_lib print_lib = ( @@ -203,13 +202,13 @@ def _check_python_lib(repository_ctx, python_lib): _fail("Invalid python library path: %s" % python_lib) -def _check_python_bin(repository_ctx, python_bin, bin_path_key): +def _check_python_bin(repository_ctx, python_bin): """Checks the python bin path.""" cmd = '[[ -x "%s" ]] && [[ ! -d "%s" ]]' % (python_bin, python_bin) result = repository_ctx.execute([_get_bash_bin(repository_ctx), "-c", cmd]) if result.return_code == 1: _fail("--define %s='%s' is not executable. Is it the python binary?" % - (bin_path_key, python_bin)) + (_PYTHON_BIN_PATH, python_bin)) def _get_python_include(repository_ctx, python_bin): @@ -223,11 +222,11 @@ def _get_python_include(repository_ctx, python_bin): error_msg="Problem getting python include path.", error_details=( "Is the Python binary path set up right? " + "(See ./configure or " - + _PYTHON2_BIN_PATH + ".) " + "Is distutils installed?")) + + _PYTHON_BIN_PATH + ".) " + "Is distutils installed?")) return result.stdout.splitlines()[0] -def _get_python_import_lib_name(repository_ctx, python_bin, bin_path_key): +def _get_python_import_lib_name(repository_ctx, python_bin): """Get Python import library name (pythonXY.lib) on Windows.""" result = _execute( repository_ctx, [ @@ -237,85 +236,66 @@ def _get_python_import_lib_name(repository_ctx, python_bin, bin_path_key): ], error_msg="Problem getting python import library.", error_details=("Is the Python binary path set up right? " + - "(See ./configure or " + bin_path_key + ".) ")) + "(See ./configure or " + _PYTHON_BIN_PATH + ".) ")) return result.stdout.splitlines()[0] -def _create_single_version_package(repository_ctx, - variety_name, - bin_path_key, - default_bin_path, - lib_path_key): +def _create_local_python_repository(repository_ctx): """Creates the repository containing files set up to build with Python.""" - python_bin = _get_python_bin(repository_ctx, bin_path_key, default_bin_path) - _check_python_bin(repository_ctx, python_bin, bin_path_key) - python_lib = _get_python_lib(repository_ctx, python_bin, lib_path_key) + python_bin = _get_python_bin(repository_ctx) + _check_python_bin(repository_ctx, python_bin) + python_lib = _get_python_lib(repository_ctx, python_bin) _check_python_lib(repository_ctx, python_lib) python_include = _get_python_include(repository_ctx, python_bin) python_include_rule = _symlink_genrule_for_dir( - repository_ctx, python_include, '{}_include'.format(variety_name), - '{}_include'.format(variety_name)) + repository_ctx, python_include, 'python_include', 'python_include') python_import_lib_genrule = "" # To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib # See https://docs.python.org/3/extending/windows.html if _is_windows(repository_ctx): python_include = _normalize_path(python_include) - python_import_lib_name = _get_python_import_lib_name, bin_path_key( + python_import_lib_name = _get_python_import_lib_name( repository_ctx, python_bin) python_import_lib_src = python_include.rsplit( '/', 1)[0] + "/libs/" + python_import_lib_name python_import_lib_genrule = _symlink_genrule_for_dir( - repository_ctx, None, '', '{}_import_lib'.format(variety_name), + repository_ctx, None, '', 'python_import_lib', [python_import_lib_src], [python_import_lib_name]) _tpl( - repository_ctx, "variety", { + repository_ctx, "BUILD", { "%{PYTHON_INCLUDE_GENRULE}": python_include_rule, "%{PYTHON_IMPORT_LIB_GENRULE}": python_import_lib_genrule, - "%{VARIETY_NAME}": variety_name, - }, - out="{}/BUILD".format(variety_name)) + }) + + +def _create_remote_python_repository(repository_ctx, remote_config_repo): + """Creates pointers to a remotely configured repo set up to build with Python. + """ + _tpl(repository_ctx, "remote.BUILD", { + "%{REMOTE_PYTHON_REPO}": remote_config_repo, + }, "BUILD") def _python_autoconf_impl(repository_ctx): """Implementation of the python_autoconf repository rule.""" - _create_single_version_package(repository_ctx, - "_python2", - _PYTHON2_BIN_PATH, - "python", - _PYTHON2_LIB_PATH) - _create_single_version_package(repository_ctx, - "_python3", - _PYTHON3_BIN_PATH, - "python3", - _PYTHON3_LIB_PATH) - _tpl(repository_ctx, "BUILD") + if _PYTHON_CONFIG_REPO in repository_ctx.os.environ: + _create_remote_python_repository( + repository_ctx, repository_ctx.os.environ[_PYTHON_CONFIG_REPO]) + else: + _create_local_python_repository(repository_ctx) python_configure = repository_rule( - implementation = _python_autoconf_impl, - environ = [ + implementation=_python_autoconf_impl, + environ=[ _BAZEL_SH, - _PYTHON2_BIN_PATH, - _PYTHON2_LIB_PATH, - _PYTHON3_BIN_PATH, - _PYTHON3_LIB_PATH, + _PYTHON_BIN_PATH, + _PYTHON_LIB_PATH, + _PYTHON_CONFIG_REPO, ], - attrs={ - "_build_tpl": attr.label( - default = Label("//third_party/py:BUILD.tpl"), - allow_single_file = True, - ), - "_variety_tpl": attr.label( - default = Label("//third_party/py:variety.tpl"), - allow_single_file = True, - ), - }, ) """Detects and configures the local Python. -It is expected that the system have both a working Python 2 and python 3 -installation - Add the following to your WORKSPACE FILE: ```python diff --git a/third_party/py/remote.BUILD.tpl b/third_party/py/remote.BUILD.tpl new file mode 100644 index 00000000000..1bfe1f0bf65 --- /dev/null +++ b/third_party/py/remote.BUILD.tpl @@ -0,0 +1,10 @@ +# Adapted with modifications from tensorflow/third_party/py/ + +package(default_visibility=["//visibility:public"]) + +alias( + name="python_headers", + actual="%{REMOTE_PYTHON_REPO}:python_headers", +) + + diff --git a/third_party/py/variety.tpl b/third_party/py/variety.tpl deleted file mode 100644 index 0c466d6d8f0..00000000000 --- a/third_party/py/variety.tpl +++ /dev/null @@ -1,26 +0,0 @@ -package(default_visibility=["//visibility:public"]) - -# To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib -# See https://docs.python.org/3/extending/windows.html -cc_import( - name="%{VARIETY_NAME}_lib", - interface_library=select({ - "//:windows": ":%{VARIETY_NAME}_import_lib", - # A placeholder for Unix platforms which makes --no_build happy. - "//conditions:default": "not-existing.lib", - }), - system_provided=1, -) - -cc_library( - name="%{VARIETY_NAME}_headers", - hdrs=[":%{VARIETY_NAME}_include"], - deps=select({ - "//:windows": [":%{VARIETY_NAME}_lib"], - "//conditions:default": [], - }), - includes=["%{VARIETY_NAME}_include"], -) - -%{PYTHON_INCLUDE_GENRULE} -%{PYTHON_IMPORT_LIB_GENRULE} diff --git a/tools/bazel b/tools/bazel index 4d1d57f60d9..4f08d18c656 100755 --- a/tools/bazel +++ b/tools/bazel @@ -32,7 +32,7 @@ then exec -a "$0" "${BAZEL_REAL}" "$@" fi -VERSION=0.28.1 +VERSION=0.26.0 echo "INFO: Running bazel wrapper (see //tools/bazel for details), bazel version $VERSION will be used instead of system-wide bazel installation." diff --git a/tools/bazel.rc b/tools/bazel.rc index fcbe9337b9f..b24f603ddda 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -82,3 +82,7 @@ build:basicprof --copt=-DNDEBUG build:basicprof --copt=-O2 build:basicprof --copt=-DGRPC_BASIC_PROFILER build:basicprof --copt=-DGRPC_TIMERS_RDTSC + +build:python3 --python_path=python3 +build:python3 --python_version=PY3 +build:python3 --action_env=PYTHON_BIN_PATH=python3 diff --git a/tools/dockerfile/test/bazel/Dockerfile b/tools/dockerfile/test/bazel/Dockerfile index 7141fb9c5f1..7e7903359e7 100644 --- a/tools/dockerfile/test/bazel/Dockerfile +++ b/tools/dockerfile/test/bazel/Dockerfile @@ -52,7 +52,7 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.2.post1 six==1.10.0 t # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.28.1 +ENV BAZEL_VERSION 0.26.0 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index badff52de34..675378b305b 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -97,7 +97,7 @@ ENV CLANG_TIDY=clang-tidy # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.28.1 +ENV BAZEL_VERSION 0.26.0 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh b/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh index 4a48760aab1..f725eb7a3d7 100755 --- a/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh +++ b/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh @@ -26,6 +26,9 @@ ${name}') cd /var/local/git/grpc/test bazel test --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //src/python/... bazel test --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //examples/python/... +bazel clean --expunge +bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //src/python/... +bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //examples/python/... # TODO(https://github.com/grpc/grpc/issues/19854): Move this to a new Kokoro # job. diff --git a/tools/remote_build/kokoro.bazelrc b/tools/remote_build/kokoro.bazelrc index 5c1b061bce3..064e94b2e15 100644 --- a/tools/remote_build/kokoro.bazelrc +++ b/tools/remote_build/kokoro.bazelrc @@ -16,12 +16,13 @@ import %workspace%/tools/remote_build/rbe_common.bazelrc -build --remote_cache=grpcs://remotebuildexecution.googleapis.com -build --remote_executor=grpcs://remotebuildexecution.googleapis.com +build --remote_cache=remotebuildexecution.googleapis.com +build --remote_executor=remotebuildexecution.googleapis.com +build --tls_enabled=true build --auth_enabled=true -build --bes_backend=grpcs://buildeventservice.googleapis.com +build --bes_backend=buildeventservice.googleapis.com build --bes_timeout=600s build --project_id=grpc-testing diff --git a/tools/remote_build/manual.bazelrc b/tools/remote_build/manual.bazelrc index c3c6af42877..fcd41f57521 100644 --- a/tools/remote_build/manual.bazelrc +++ b/tools/remote_build/manual.bazelrc @@ -17,8 +17,9 @@ import %workspace%/tools/remote_build/rbe_common.bazelrc -build --remote_cache=grpcs://remotebuildexecution.googleapis.com -build --remote_executor=grpcs://remotebuildexecution.googleapis.com +build --remote_cache=remotebuildexecution.googleapis.com +build --remote_executor=remotebuildexecution.googleapis.com +build --tls_enabled=true # Enable authentication. This will pick up application default credentials by # default. You can use --auth_credentials=some_file.json to use a service @@ -29,7 +30,7 @@ build --auth_enabled=true # Set flags for uploading to BES in order to view results in the Bazel Build # Results UI. -build --bes_backend=grpcs://buildeventservice.googleapis.com +build --bes_backend="buildeventservice.googleapis.com" build --bes_timeout=60s build --bes_results_url="https://source.cloud.google.com/results/invocations/" build --project_id=grpc-testing diff --git a/tools/remote_build/rbe_common.bazelrc b/tools/remote_build/rbe_common.bazelrc index 6236003fe17..6baaf24732c 100644 --- a/tools/remote_build/rbe_common.bazelrc +++ b/tools/remote_build/rbe_common.bazelrc @@ -87,4 +87,4 @@ build:ubsan --test_timeout=3600 # how to update the bazel toolchain for ubsan: # - check for the latest released version in https://github.com/bazelbuild/bazel-toolchains/tree/master/configs/experimental/ubuntu16_04_clang # - you might need to update the bazel_toolchains dependency in grpc_deps.bzl -build:ubsan --crosstool_top=@bazel_toolchains//configs/experimental/ubuntu16_04_clang/1.2/bazel_0.28.0/ubsan:toolchain +build:ubsan --crosstool_top=@bazel_toolchains//configs/experimental/ubuntu16_04_clang/1.2/bazel_0.23.0/ubsan:toolchain From 1444cd1dd31c81daa63477be445a941722a42f5d Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Thu, 29 Aug 2019 10:51:36 -0700 Subject: [PATCH 1400/1555] Revert "Revert "Merge pull request #20097 from gnossen/dual_version_python_tests"" This reverts commit 24c562dbaa95539031c45ab4bdce5070ca6c2af5. --- BUILD | 2 +- bazel/grpc_build_system.bzl | 11 +- bazel/grpc_deps.bzl | 15 +-- bazel/grpc_python_deps.bzl | 9 ++ bazel/python_rules.bzl | 26 +++++ examples/python/auth/BUILD.bazel | 3 + examples/python/cancellation/BUILD.bazel | 3 + examples/python/compression/BUILD.bazel | 3 + examples/python/debug/BUILD.bazel | 3 + examples/python/errors/BUILD.bazel | 1 + examples/python/multiprocessing/BUILD | 3 + examples/python/wait_for_ready/BUILD.bazel | 1 + .../grpcio_tests/tests/channelz/BUILD.bazel | 4 +- .../tests/health_check/BUILD.bazel | 3 +- .../grpcio_tests/tests/interop/BUILD.bazel | 5 +- .../grpcio_tests/tests/reflection/BUILD.bazel | 3 +- .../grpcio_tests/tests/status/BUILD.bazel | 3 +- .../grpcio_tests/tests/unit/BUILD.bazel | 4 +- .../tests/unit/_cython/BUILD.bazel | 3 +- .../unit/framework/foundation/BUILD.bazel | 3 +- templates/tools/dockerfile/bazel.include | 2 +- third_party/py/BUILD.tpl | 49 +++++---- third_party/py/python_configure.bzl | 104 +++++++++++------- third_party/py/remote.BUILD.tpl | 10 -- third_party/py/variety.tpl | 26 +++++ tools/bazel | 2 +- tools/bazel.rc | 4 - tools/dockerfile/test/bazel/Dockerfile | 2 +- tools/dockerfile/test/sanity/Dockerfile | 2 +- .../linux/grpc_python_bazel_test_in_docker.sh | 3 - tools/remote_build/kokoro.bazelrc | 7 +- tools/remote_build/manual.bazelrc | 7 +- tools/remote_build/rbe_common.bazelrc | 2 +- 33 files changed, 214 insertions(+), 114 deletions(-) delete mode 100644 third_party/py/remote.BUILD.tpl create mode 100644 third_party/py/variety.tpl diff --git a/BUILD b/BUILD index 9198dd61282..e489bc2584a 100644 --- a/BUILD +++ b/BUILD @@ -65,7 +65,7 @@ config_setting( config_setting( name = "python3", - values = {"python_path": "python3"}, + flag_values = {"@bazel_tools//tools/python:python_version": "PY3"}, ) config_setting( diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index f386b87b583..f4777e50bc1 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -269,13 +269,22 @@ def grpc_sh_binary(name, srcs, data = []): data = data, ) -def grpc_py_binary(name, srcs, data = [], deps = [], external_deps = [], testonly = False): +def grpc_py_binary(name, + srcs, + data = [], + deps = [], + external_deps = [], + testonly = False, + python_version = "PY2", + **kwargs): native.py_binary( name = name, srcs = srcs, testonly = testonly, data = data, deps = deps + _get_external_deps(external_deps), + python_version = python_version, + **kwargs ) def grpc_package(name, visibility = "private", features = []): diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 06323ff3f24..6bbb960b6c3 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -176,11 +176,11 @@ def grpc_deps(): if "bazel_toolchains" not in native.existing_rules(): http_archive( name = "bazel_toolchains", - sha256 = "d968b414b32aa99c86977e1171645d31da2b52ac88060de3ac1e49932d5dcbf1", - strip_prefix = "bazel-toolchains-4bd5df80d77aa7f4fb943dfdfad5c9056a62fb47", + sha256 = "872955b658113924eb1a3594b04d43238da47f4f90c17b76e8785709490dc041", + strip_prefix = "bazel-toolchains-1083686fde6032378d52b4c98044922cebde364e", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/4bd5df80d77aa7f4fb943dfdfad5c9056a62fb47.tar.gz", - "https://github.com/bazelbuild/bazel-toolchains/archive/4bd5df80d77aa7f4fb943dfdfad5c9056a62fb47.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/1083686fde6032378d52b4c98044922cebde364e.tar.gz", + "https://github.com/bazelbuild/bazel-toolchains/archive/1083686fde6032378d52b4c98044922cebde364e.tar.gz", ], ) @@ -221,10 +221,11 @@ def grpc_deps(): ) if "build_bazel_rules_apple" not in native.existing_rules(): - git_repository( + http_archive( name = "build_bazel_rules_apple", - remote = "https://github.com/bazelbuild/rules_apple.git", - tag = "0.17.2", + url = "https://github.com/bazelbuild/rules_apple/archive/b869b0d3868d78a1d4ffd866ccb304fb68aa12c3.tar.gz", + strip_prefix = "rules_apple-b869b0d3868d78a1d4ffd866ccb304fb68aa12c3", + sha256 = "bdc8e66e70b8a75da23b79f1f8c6207356df07d041d96d2189add7ee0780cf4e", ) grpc_python_deps() diff --git a/bazel/grpc_python_deps.bzl b/bazel/grpc_python_deps.bzl index 4e7cc1537fa..2a439bdf226 100644 --- a/bazel/grpc_python_deps.bzl +++ b/bazel/grpc_python_deps.bzl @@ -47,6 +47,15 @@ def grpc_python_deps(): remote = "https://github.com/bazelbuild/rules_python.git", ) + + if "rules_python" not in native.existing_rules(): + http_archive( + name = "rules_python", + url = "https://github.com/bazelbuild/rules_python/archive/9d68f24659e8ce8b736590ba1e4418af06ec2552.zip", + sha256 = "f7402f11691d657161f871e11968a984e5b48b023321935f5a55d7e56cf4758a", + strip_prefix = "rules_python-9d68f24659e8ce8b736590ba1e4418af06ec2552", + ) + python_configure(name = "local_config_python") native.bind( diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index 12f51f8b172..e7e9e597b05 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -178,3 +178,29 @@ def py_grpc_library( deps = [Label("//src/python/grpcio/grpc:grpcio")] + deps, **kwargs ) + + +def py2and3_test(name, + py_test = native.py_test, + **kwargs): + if "python_version" in kwargs: + fail("Cannot specify 'python_version' in py2and3_test.") + + names = [name + suffix for suffix in (".python2", ".python3")] + python_versions = ["PY2", "PY3"] + for case_name, python_version in zip(names, python_versions): + py_test( + name = case_name, + python_version = python_version, + **kwargs + ) + + suite_kwargs = {} + if "visibility" in kwargs: + suite_kwargs["visibility"] = kwargs["visibility"] + + native.test_suite( + name = name, + tests = names, + **suite_kwargs + ) diff --git a/examples/python/auth/BUILD.bazel b/examples/python/auth/BUILD.bazel index cc454fdfdfe..72620ee46c5 100644 --- a/examples/python/auth/BUILD.bazel +++ b/examples/python/auth/BUILD.bazel @@ -39,6 +39,7 @@ py_binary( "//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2_grpc", ], + python_version = "PY3", ) py_binary( @@ -51,6 +52,7 @@ py_binary( "//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2_grpc", ], + python_version = "PY3", ) py_test( @@ -63,4 +65,5 @@ py_test( ":customized_auth_server", ":_credentials", ], + python_version = "PY3", ) diff --git a/examples/python/cancellation/BUILD.bazel b/examples/python/cancellation/BUILD.bazel index 17b1b20168e..b4451f60711 100644 --- a/examples/python/cancellation/BUILD.bazel +++ b/examples/python/cancellation/BUILD.bazel @@ -45,6 +45,7 @@ py_binary( "//external:six" ], srcs_version = "PY2AND3", + python_version = "PY3", ) py_library( @@ -68,6 +69,7 @@ py_binary( "//:python3": [], }), srcs_version = "PY2AND3", + python_version = "PY3", ) py_test( @@ -78,4 +80,5 @@ py_test( ":server" ], size = "small", + python_version = "PY3", ) diff --git a/examples/python/compression/BUILD.bazel b/examples/python/compression/BUILD.bazel index 9d5f6bb83ed..4141eda2ffd 100644 --- a/examples/python/compression/BUILD.bazel +++ b/examples/python/compression/BUILD.bazel @@ -21,6 +21,7 @@ py_binary( "//examples:helloworld_py_pb2_grpc", ], srcs_version = "PY2AND3", + python_version = "PY3", ) py_binary( @@ -32,6 +33,7 @@ py_binary( "//examples:helloworld_py_pb2_grpc", ], srcs_version = "PY2AND3", + python_version = "PY3", ) py_test( @@ -43,4 +45,5 @@ py_test( ":server", ], size = "small", + python_version = "PY3", ) diff --git a/examples/python/debug/BUILD.bazel b/examples/python/debug/BUILD.bazel index 657ae860ae3..332991332f8 100644 --- a/examples/python/debug/BUILD.bazel +++ b/examples/python/debug/BUILD.bazel @@ -35,6 +35,7 @@ py_binary( "//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2_grpc", ], + python_version = "PY3", ) py_binary( @@ -45,6 +46,7 @@ py_binary( "//src/python/grpcio/grpc:grpcio", "//src/python/grpcio_channelz/grpc_channelz/v1:grpc_channelz", ], + python_version = "PY3", ) py_test( @@ -59,4 +61,5 @@ py_test( ":send_message", ":get_stats", ], + python_version = "PY3", ) diff --git a/examples/python/errors/BUILD.bazel b/examples/python/errors/BUILD.bazel index 4b779ddfcf1..367bd81925f 100644 --- a/examples/python/errors/BUILD.bazel +++ b/examples/python/errors/BUILD.bazel @@ -55,4 +55,5 @@ py_test( "../../../src/python/grpcio_status", "../../../src/python/grpcio_tests", ], + python_version = "PY3", ) diff --git a/examples/python/multiprocessing/BUILD b/examples/python/multiprocessing/BUILD index 490aea0c1e6..2503970bc80 100644 --- a/examples/python/multiprocessing/BUILD +++ b/examples/python/multiprocessing/BUILD @@ -42,6 +42,7 @@ py_binary( ":prime_proto_pb2_grpc", ], srcs_version = "PY3", + python_version = "PY3", ) py_binary( @@ -57,6 +58,7 @@ py_binary( "//:python3": [], }), srcs_version = "PY3", + python_version = "PY3", ) py_test( @@ -67,4 +69,5 @@ py_test( ":server" ], size = "small", + python_version = "PY3", ) diff --git a/examples/python/wait_for_ready/BUILD.bazel b/examples/python/wait_for_ready/BUILD.bazel index f074ae7bb7f..9cbddd1a6e3 100644 --- a/examples/python/wait_for_ready/BUILD.bazel +++ b/examples/python/wait_for_ready/BUILD.bazel @@ -30,4 +30,5 @@ py_test( srcs = ["test/_wait_for_ready_example_test.py"], deps = [":wait_for_ready_example",], size = "small", + python_version = "PY3", ) diff --git a/src/python/grpcio_tests/tests/channelz/BUILD.bazel b/src/python/grpcio_tests/tests/channelz/BUILD.bazel index 63513616e77..f4d246847f7 100644 --- a/src/python/grpcio_tests/tests/channelz/BUILD.bazel +++ b/src/python/grpcio_tests/tests/channelz/BUILD.bazel @@ -1,6 +1,8 @@ package(default_visibility = ["//visibility:public"]) -py_test( +load("//bazel:python_rules.bzl", "py2and3_test") + +py2and3_test( name = "channelz_servicer_test", srcs = ["_channelz_servicer_test.py"], main = "_channelz_servicer_test.py", diff --git a/src/python/grpcio_tests/tests/health_check/BUILD.bazel b/src/python/grpcio_tests/tests/health_check/BUILD.bazel index 49f076be9a1..797b6a48e91 100644 --- a/src/python/grpcio_tests/tests/health_check/BUILD.bazel +++ b/src/python/grpcio_tests/tests/health_check/BUILD.bazel @@ -1,6 +1,7 @@ package(default_visibility = ["//visibility:public"]) +load("//bazel:python_rules.bzl", "py2and3_test") -py_test( +py2and3_test( name = "health_servicer_test", srcs = ["_health_servicer_test.py"], main = "_health_servicer_test.py", diff --git a/src/python/grpcio_tests/tests/interop/BUILD.bazel b/src/python/grpcio_tests/tests/interop/BUILD.bazel index 8ac3f7d52d5..4685852162b 100644 --- a/src/python/grpcio_tests/tests/interop/BUILD.bazel +++ b/src/python/grpcio_tests/tests/interop/BUILD.bazel @@ -1,4 +1,5 @@ load("@grpc_python_dependencies//:requirements.bzl", "requirement") +load("//bazel:python_rules.bzl", "py2and3_test") package(default_visibility = ["//visibility:public"]) @@ -80,7 +81,7 @@ py_library( ], ) -py_test( +py2and3_test( name = "_insecure_intraop_test", size = "small", srcs = ["_insecure_intraop_test.py"], @@ -99,7 +100,7 @@ py_test( ], ) -py_test( +py2and3_test( name = "_secure_intraop_test", size = "small", srcs = ["_secure_intraop_test.py"], diff --git a/src/python/grpcio_tests/tests/reflection/BUILD.bazel b/src/python/grpcio_tests/tests/reflection/BUILD.bazel index e9b56191df8..65a08c2a435 100644 --- a/src/python/grpcio_tests/tests/reflection/BUILD.bazel +++ b/src/python/grpcio_tests/tests/reflection/BUILD.bazel @@ -1,8 +1,9 @@ load("@grpc_python_dependencies//:requirements.bzl", "requirement") +load("//bazel:python_rules.bzl", "py2and3_test") package(default_visibility = ["//visibility:public"]) -py_test( +py2and3_test( name="_reflection_servicer_test", size="small", timeout="moderate", diff --git a/src/python/grpcio_tests/tests/status/BUILD.bazel b/src/python/grpcio_tests/tests/status/BUILD.bazel index b163fe3975e..0868de01acf 100644 --- a/src/python/grpcio_tests/tests/status/BUILD.bazel +++ b/src/python/grpcio_tests/tests/status/BUILD.bazel @@ -1,8 +1,9 @@ load("@grpc_python_dependencies//:requirements.bzl", "requirement") +load("//bazel:python_rules.bzl", "py2and3_test") package(default_visibility = ["//visibility:public"]) -py_test( +py2and3_test( name = "grpc_status_test", srcs = ["_grpc_status_test.py"], main = "_grpc_status_test.py", diff --git a/src/python/grpcio_tests/tests/unit/BUILD.bazel b/src/python/grpcio_tests/tests/unit/BUILD.bazel index 49203b7fa16..587d8cb246f 100644 --- a/src/python/grpcio_tests/tests/unit/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/BUILD.bazel @@ -1,3 +1,5 @@ +load("//bazel:python_rules.bzl", "py2and3_test") + package(default_visibility = ["//visibility:public"]) GRPCIO_TESTS_UNIT = [ @@ -80,7 +82,7 @@ py_library( ) [ - py_test( + py2and3_test( name=test_file_name[:-3], size="small", srcs=[test_file_name], diff --git a/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel b/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel index 458a6b1fb8a..867649a6a50 100644 --- a/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel @@ -1,4 +1,5 @@ load("@grpc_python_dependencies//:requirements.bzl", "requirement") +load("//bazel:python_rules.bzl", "py2and3_test") package(default_visibility = ["//visibility:public"]) @@ -23,7 +24,7 @@ py_library( ) [ - py_test( + py2and3_test( name=test_file_name[:-3], size="small", srcs=[test_file_name], diff --git a/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel b/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel index d69186e1fde..a93249301c4 100644 --- a/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/framework/foundation/BUILD.bazel @@ -1,11 +1,12 @@ package(default_visibility = ["//visibility:public"]) +load("//bazel:python_rules.bzl", "py2and3_test") py_library( name = "stream_testing", srcs = ["stream_testing.py"], ) -py_test( +py2and3_test( name = "logging_pool_test", srcs = ["_logging_pool_test.py"], main = "_logging_pool_test.py", diff --git a/templates/tools/dockerfile/bazel.include b/templates/tools/dockerfile/bazel.include index adde6ed4787..12a22785623 100644 --- a/templates/tools/dockerfile/bazel.include +++ b/templates/tools/dockerfile/bazel.include @@ -2,7 +2,7 @@ # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.26.0 +ENV BAZEL_VERSION 0.28.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/third_party/py/BUILD.tpl b/third_party/py/BUILD.tpl index 2283c573bc3..8f010f85a03 100644 --- a/third_party/py/BUILD.tpl +++ b/third_party/py/BUILD.tpl @@ -2,35 +2,36 @@ package(default_visibility=["//visibility:public"]) -# To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib -# See https://docs.python.org/3/extending/windows.html -cc_import( - name="python_lib", - interface_library=select({ - ":windows": ":python_import_lib", - # A placeholder for Unix platforms which makes --no_build happy. - "//conditions:default": "not-existing.lib", - }), - system_provided=1, -) - -cc_library( - name="python_headers", - hdrs=[":python_include"], - deps=select({ - ":windows": [":python_lib"], - "//conditions:default": [], - }), - includes=["python_include"], -) - config_setting( name="windows", values={"cpu": "x64_windows"}, visibility=["//visibility:public"], ) -%{PYTHON_INCLUDE_GENRULE} -%{PYTHON_IMPORT_LIB_GENRULE} +config_setting( + name="python2", + flag_values = {"@rules_python//python:python_version": "PY2"} +) +config_setting( + name="python3", + flag_values = {"@rules_python//python:python_version": "PY3"} +) +cc_library( + name = "python_lib", + deps = select({ + ":python2": ["//_python2:_python2_lib"], + ":python3": ["//_python3:_python3_lib"], + "//conditions:default": ["not-existing.lib"], + }) +) + +cc_library( + name = "python_headers", + deps = select({ + ":python2": ["//_python2:_python2_headers"], + ":python3": ["//_python3:_python3_headers"], + "//conditions:default": ["not-existing.headers"], + }) +) diff --git a/third_party/py/python_configure.bzl b/third_party/py/python_configure.bzl index e6fa5ed10e9..6f9a178a057 100644 --- a/third_party/py/python_configure.bzl +++ b/third_party/py/python_configure.bzl @@ -3,14 +3,15 @@ `python_configure` depends on the following environment variables: - * `PYTHON_BIN_PATH`: location of python binary. - * `PYTHON_LIB_PATH`: Location of python libraries. + * `PYTHON2_BIN_PATH`: location of python binary. + * `PYTHON2_LIB_PATH`: Location of python libraries. """ _BAZEL_SH = "BAZEL_SH" -_PYTHON_BIN_PATH = "PYTHON_BIN_PATH" -_PYTHON_LIB_PATH = "PYTHON_LIB_PATH" -_PYTHON_CONFIG_REPO = "PYTHON_CONFIG_REPO" +_PYTHON2_BIN_PATH = "PYTHON2_BIN_PATH" +_PYTHON2_LIB_PATH = "PYTHON2_LIB_PATH" +_PYTHON3_BIN_PATH = "PYTHON3_BIN_PATH" +_PYTHON3_LIB_PATH = "PYTHON3_LIB_PATH" def _tpl(repository_ctx, tpl, substitutions={}, out=None): @@ -136,9 +137,9 @@ def _symlink_genrule_for_dir(repository_ctx, "\n".join(outs)) -def _get_python_bin(repository_ctx): +def _get_python_bin(repository_ctx, bin_path_key, default_bin_path): """Gets the python bin path.""" - python_bin = repository_ctx.os.environ.get(_PYTHON_BIN_PATH, 'python') + python_bin = repository_ctx.os.environ.get(bin_path_key, default_bin_path) if not repository_ctx.path(python_bin).exists: # It's a command, use 'which' to find its path. python_bin_path = repository_ctx.which(python_bin) @@ -150,7 +151,7 @@ def _get_python_bin(repository_ctx): _fail("Cannot find python in PATH, please make sure " + "python is installed and add its directory in PATH, or --define " + "%s='/something/else'.\nPATH=%s" % - (_PYTHON_BIN_PATH, repository_ctx.os.environ.get("PATH", ""))) + (bin_path_key, repository_ctx.os.environ.get("PATH", ""))) def _get_bash_bin(repository_ctx): @@ -170,9 +171,9 @@ def _get_bash_bin(repository_ctx): (_BAZEL_SH, repository_ctx.os.environ.get("PATH", ""))) -def _get_python_lib(repository_ctx, python_bin): +def _get_python_lib(repository_ctx, python_bin, lib_path_key): """Gets the python lib path.""" - python_lib = repository_ctx.os.environ.get(_PYTHON_LIB_PATH) + python_lib = repository_ctx.os.environ.get(lib_path_key) if python_lib != None: return python_lib print_lib = ( @@ -202,13 +203,13 @@ def _check_python_lib(repository_ctx, python_lib): _fail("Invalid python library path: %s" % python_lib) -def _check_python_bin(repository_ctx, python_bin): +def _check_python_bin(repository_ctx, python_bin, bin_path_key): """Checks the python bin path.""" cmd = '[[ -x "%s" ]] && [[ ! -d "%s" ]]' % (python_bin, python_bin) result = repository_ctx.execute([_get_bash_bin(repository_ctx), "-c", cmd]) if result.return_code == 1: _fail("--define %s='%s' is not executable. Is it the python binary?" % - (_PYTHON_BIN_PATH, python_bin)) + (bin_path_key, python_bin)) def _get_python_include(repository_ctx, python_bin): @@ -222,11 +223,11 @@ def _get_python_include(repository_ctx, python_bin): error_msg="Problem getting python include path.", error_details=( "Is the Python binary path set up right? " + "(See ./configure or " - + _PYTHON_BIN_PATH + ".) " + "Is distutils installed?")) + + _PYTHON2_BIN_PATH + ".) " + "Is distutils installed?")) return result.stdout.splitlines()[0] -def _get_python_import_lib_name(repository_ctx, python_bin): +def _get_python_import_lib_name(repository_ctx, python_bin, bin_path_key): """Get Python import library name (pythonXY.lib) on Windows.""" result = _execute( repository_ctx, [ @@ -236,66 +237,85 @@ def _get_python_import_lib_name(repository_ctx, python_bin): ], error_msg="Problem getting python import library.", error_details=("Is the Python binary path set up right? " + - "(See ./configure or " + _PYTHON_BIN_PATH + ".) ")) + "(See ./configure or " + bin_path_key + ".) ")) return result.stdout.splitlines()[0] -def _create_local_python_repository(repository_ctx): +def _create_single_version_package(repository_ctx, + variety_name, + bin_path_key, + default_bin_path, + lib_path_key): """Creates the repository containing files set up to build with Python.""" - python_bin = _get_python_bin(repository_ctx) - _check_python_bin(repository_ctx, python_bin) - python_lib = _get_python_lib(repository_ctx, python_bin) + python_bin = _get_python_bin(repository_ctx, bin_path_key, default_bin_path) + _check_python_bin(repository_ctx, python_bin, bin_path_key) + python_lib = _get_python_lib(repository_ctx, python_bin, lib_path_key) _check_python_lib(repository_ctx, python_lib) python_include = _get_python_include(repository_ctx, python_bin) python_include_rule = _symlink_genrule_for_dir( - repository_ctx, python_include, 'python_include', 'python_include') + repository_ctx, python_include, '{}_include'.format(variety_name), + '{}_include'.format(variety_name)) python_import_lib_genrule = "" # To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib # See https://docs.python.org/3/extending/windows.html if _is_windows(repository_ctx): python_include = _normalize_path(python_include) - python_import_lib_name = _get_python_import_lib_name( + python_import_lib_name = _get_python_import_lib_name, bin_path_key( repository_ctx, python_bin) python_import_lib_src = python_include.rsplit( '/', 1)[0] + "/libs/" + python_import_lib_name python_import_lib_genrule = _symlink_genrule_for_dir( - repository_ctx, None, '', 'python_import_lib', + repository_ctx, None, '', '{}_import_lib'.format(variety_name), [python_import_lib_src], [python_import_lib_name]) _tpl( - repository_ctx, "BUILD", { + repository_ctx, "variety", { "%{PYTHON_INCLUDE_GENRULE}": python_include_rule, "%{PYTHON_IMPORT_LIB_GENRULE}": python_import_lib_genrule, - }) - - -def _create_remote_python_repository(repository_ctx, remote_config_repo): - """Creates pointers to a remotely configured repo set up to build with Python. - """ - _tpl(repository_ctx, "remote.BUILD", { - "%{REMOTE_PYTHON_REPO}": remote_config_repo, - }, "BUILD") + "%{VARIETY_NAME}": variety_name, + }, + out="{}/BUILD".format(variety_name)) def _python_autoconf_impl(repository_ctx): """Implementation of the python_autoconf repository rule.""" - if _PYTHON_CONFIG_REPO in repository_ctx.os.environ: - _create_remote_python_repository( - repository_ctx, repository_ctx.os.environ[_PYTHON_CONFIG_REPO]) - else: - _create_local_python_repository(repository_ctx) + _create_single_version_package(repository_ctx, + "_python2", + _PYTHON2_BIN_PATH, + "python", + _PYTHON2_LIB_PATH) + _create_single_version_package(repository_ctx, + "_python3", + _PYTHON3_BIN_PATH, + "python3", + _PYTHON3_LIB_PATH) + _tpl(repository_ctx, "BUILD") python_configure = repository_rule( - implementation=_python_autoconf_impl, - environ=[ + implementation = _python_autoconf_impl, + environ = [ _BAZEL_SH, - _PYTHON_BIN_PATH, - _PYTHON_LIB_PATH, - _PYTHON_CONFIG_REPO, + _PYTHON2_BIN_PATH, + _PYTHON2_LIB_PATH, + _PYTHON3_BIN_PATH, + _PYTHON3_LIB_PATH, ], + attrs={ + "_build_tpl": attr.label( + default = Label("//third_party/py:BUILD.tpl"), + allow_single_file = True, + ), + "_variety_tpl": attr.label( + default = Label("//third_party/py:variety.tpl"), + allow_single_file = True, + ), + }, ) """Detects and configures the local Python. +It is expected that the system have both a working Python 2 and python 3 +installation + Add the following to your WORKSPACE FILE: ```python diff --git a/third_party/py/remote.BUILD.tpl b/third_party/py/remote.BUILD.tpl deleted file mode 100644 index 1bfe1f0bf65..00000000000 --- a/third_party/py/remote.BUILD.tpl +++ /dev/null @@ -1,10 +0,0 @@ -# Adapted with modifications from tensorflow/third_party/py/ - -package(default_visibility=["//visibility:public"]) - -alias( - name="python_headers", - actual="%{REMOTE_PYTHON_REPO}:python_headers", -) - - diff --git a/third_party/py/variety.tpl b/third_party/py/variety.tpl new file mode 100644 index 00000000000..0c466d6d8f0 --- /dev/null +++ b/third_party/py/variety.tpl @@ -0,0 +1,26 @@ +package(default_visibility=["//visibility:public"]) + +# To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib +# See https://docs.python.org/3/extending/windows.html +cc_import( + name="%{VARIETY_NAME}_lib", + interface_library=select({ + "//:windows": ":%{VARIETY_NAME}_import_lib", + # A placeholder for Unix platforms which makes --no_build happy. + "//conditions:default": "not-existing.lib", + }), + system_provided=1, +) + +cc_library( + name="%{VARIETY_NAME}_headers", + hdrs=[":%{VARIETY_NAME}_include"], + deps=select({ + "//:windows": [":%{VARIETY_NAME}_lib"], + "//conditions:default": [], + }), + includes=["%{VARIETY_NAME}_include"], +) + +%{PYTHON_INCLUDE_GENRULE} +%{PYTHON_IMPORT_LIB_GENRULE} diff --git a/tools/bazel b/tools/bazel index 4f08d18c656..4d1d57f60d9 100755 --- a/tools/bazel +++ b/tools/bazel @@ -32,7 +32,7 @@ then exec -a "$0" "${BAZEL_REAL}" "$@" fi -VERSION=0.26.0 +VERSION=0.28.1 echo "INFO: Running bazel wrapper (see //tools/bazel for details), bazel version $VERSION will be used instead of system-wide bazel installation." diff --git a/tools/bazel.rc b/tools/bazel.rc index b24f603ddda..fcbe9337b9f 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -82,7 +82,3 @@ build:basicprof --copt=-DNDEBUG build:basicprof --copt=-O2 build:basicprof --copt=-DGRPC_BASIC_PROFILER build:basicprof --copt=-DGRPC_TIMERS_RDTSC - -build:python3 --python_path=python3 -build:python3 --python_version=PY3 -build:python3 --action_env=PYTHON_BIN_PATH=python3 diff --git a/tools/dockerfile/test/bazel/Dockerfile b/tools/dockerfile/test/bazel/Dockerfile index 7e7903359e7..7141fb9c5f1 100644 --- a/tools/dockerfile/test/bazel/Dockerfile +++ b/tools/dockerfile/test/bazel/Dockerfile @@ -52,7 +52,7 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.2.post1 six==1.10.0 t # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.26.0 +ENV BAZEL_VERSION 0.28.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index 675378b305b..badff52de34 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -97,7 +97,7 @@ ENV CLANG_TIDY=clang-tidy # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.26.0 +ENV BAZEL_VERSION 0.28.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh b/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh index f725eb7a3d7..4a48760aab1 100755 --- a/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh +++ b/tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh @@ -26,9 +26,6 @@ ${name}') cd /var/local/git/grpc/test bazel test --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //src/python/... bazel test --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //examples/python/... -bazel clean --expunge -bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //src/python/... -bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //examples/python/... # TODO(https://github.com/grpc/grpc/issues/19854): Move this to a new Kokoro # job. diff --git a/tools/remote_build/kokoro.bazelrc b/tools/remote_build/kokoro.bazelrc index 064e94b2e15..5c1b061bce3 100644 --- a/tools/remote_build/kokoro.bazelrc +++ b/tools/remote_build/kokoro.bazelrc @@ -16,13 +16,12 @@ import %workspace%/tools/remote_build/rbe_common.bazelrc -build --remote_cache=remotebuildexecution.googleapis.com -build --remote_executor=remotebuildexecution.googleapis.com -build --tls_enabled=true +build --remote_cache=grpcs://remotebuildexecution.googleapis.com +build --remote_executor=grpcs://remotebuildexecution.googleapis.com build --auth_enabled=true -build --bes_backend=buildeventservice.googleapis.com +build --bes_backend=grpcs://buildeventservice.googleapis.com build --bes_timeout=600s build --project_id=grpc-testing diff --git a/tools/remote_build/manual.bazelrc b/tools/remote_build/manual.bazelrc index fcd41f57521..c3c6af42877 100644 --- a/tools/remote_build/manual.bazelrc +++ b/tools/remote_build/manual.bazelrc @@ -17,9 +17,8 @@ import %workspace%/tools/remote_build/rbe_common.bazelrc -build --remote_cache=remotebuildexecution.googleapis.com -build --remote_executor=remotebuildexecution.googleapis.com -build --tls_enabled=true +build --remote_cache=grpcs://remotebuildexecution.googleapis.com +build --remote_executor=grpcs://remotebuildexecution.googleapis.com # Enable authentication. This will pick up application default credentials by # default. You can use --auth_credentials=some_file.json to use a service @@ -30,7 +29,7 @@ build --auth_enabled=true # Set flags for uploading to BES in order to view results in the Bazel Build # Results UI. -build --bes_backend="buildeventservice.googleapis.com" +build --bes_backend=grpcs://buildeventservice.googleapis.com build --bes_timeout=60s build --bes_results_url="https://source.cloud.google.com/results/invocations/" build --project_id=grpc-testing diff --git a/tools/remote_build/rbe_common.bazelrc b/tools/remote_build/rbe_common.bazelrc index 6baaf24732c..6236003fe17 100644 --- a/tools/remote_build/rbe_common.bazelrc +++ b/tools/remote_build/rbe_common.bazelrc @@ -87,4 +87,4 @@ build:ubsan --test_timeout=3600 # how to update the bazel toolchain for ubsan: # - check for the latest released version in https://github.com/bazelbuild/bazel-toolchains/tree/master/configs/experimental/ubuntu16_04_clang # - you might need to update the bazel_toolchains dependency in grpc_deps.bzl -build:ubsan --crosstool_top=@bazel_toolchains//configs/experimental/ubuntu16_04_clang/1.2/bazel_0.23.0/ubsan:toolchain +build:ubsan --crosstool_top=@bazel_toolchains//configs/experimental/ubuntu16_04_clang/1.2/bazel_0.28.0/ubsan:toolchain From 1077b3435c3bf6699e118800a9c0681c900d240b Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 29 Aug 2019 11:27:00 -0700 Subject: [PATCH 1401/1555] Use range-based for on state rather than state.KeepRunning when possible --- test/cpp/microbenchmarks/bm_alarm.cc | 2 +- test/cpp/microbenchmarks/bm_arena.cc | 4 +- test/cpp/microbenchmarks/bm_byte_buffer.cc | 6 +-- test/cpp/microbenchmarks/bm_call_create.cc | 16 ++++---- test/cpp/microbenchmarks/bm_channel.cc | 2 +- test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 4 +- test/cpp/microbenchmarks/bm_closure.cc | 38 +++++++++---------- test/cpp/microbenchmarks/bm_cq.cc | 16 ++++---- .../microbenchmarks/bm_cq_multiple_threads.cc | 2 +- test/cpp/microbenchmarks/bm_error.cc | 34 ++++++++--------- test/cpp/microbenchmarks/bm_metadata.cc | 38 +++++++++---------- test/cpp/microbenchmarks/bm_pollset.cc | 10 ++--- test/cpp/microbenchmarks/bm_timer.cc | 4 +- .../fullstack_streaming_ping_pong.h | 6 +-- .../fullstack_streaming_pump.h | 4 +- .../fullstack_unary_ping_pong.h | 2 +- test/cpp/microbenchmarks/noop-benchmark.cc | 2 +- 17 files changed, 95 insertions(+), 95 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_alarm.cc b/test/cpp/microbenchmarks/bm_alarm.cc index d95771a57c6..5411b222eab 100644 --- a/test/cpp/microbenchmarks/bm_alarm.cc +++ b/test/cpp/microbenchmarks/bm_alarm.cc @@ -37,7 +37,7 @@ static void BM_Alarm_Tag_Immediate(benchmark::State& state) { void* output_tag; bool ok; auto deadline = grpc_timeout_seconds_to_deadline(0); - while (state.KeepRunning()) { + for (auto _ : state) { alarm.Set(&cq, deadline, nullptr); cq.Next(&output_tag, &ok); } diff --git a/test/cpp/microbenchmarks/bm_arena.cc b/test/cpp/microbenchmarks/bm_arena.cc index c3ded0d76f7..c0d76fa3d7d 100644 --- a/test/cpp/microbenchmarks/bm_arena.cc +++ b/test/cpp/microbenchmarks/bm_arena.cc @@ -26,7 +26,7 @@ using grpc_core::Arena; static void BM_Arena_NoOp(benchmark::State& state) { - while (state.KeepRunning()) { + for (auto _ : state) { Arena::Create(state.range(0))->Destroy(); } } @@ -49,7 +49,7 @@ static void BM_Arena_ManyAlloc(benchmark::State& state) { BENCHMARK(BM_Arena_ManyAlloc)->Ranges({{1, 1024 * 1024}, {1, 32 * 1024}}); static void BM_Arena_Batch(benchmark::State& state) { - while (state.KeepRunning()) { + for (auto _ : state) { Arena* a = Arena::Create(state.range(0)); for (int i = 0; i < state.range(1); i++) { a->Alloc(state.range(2)); diff --git a/test/cpp/microbenchmarks/bm_byte_buffer.cc b/test/cpp/microbenchmarks/bm_byte_buffer.cc index 595cc734b69..4dfa1326de9 100644 --- a/test/cpp/microbenchmarks/bm_byte_buffer.cc +++ b/test/cpp/microbenchmarks/bm_byte_buffer.cc @@ -40,7 +40,7 @@ static void BM_ByteBuffer_Copy(benchmark::State& state) { slices.emplace_back(buf.get(), slice_size); } grpc::ByteBuffer bb(slices.data(), num_slices); - while (state.KeepRunning()) { + for (auto _ : state) { grpc::ByteBuffer cc(bb); } } @@ -60,7 +60,7 @@ static void BM_ByteBufferReader_Next(benchmark::State& state) { grpc_byte_buffer_reader reader; GPR_ASSERT( g_core_codegen_interface->grpc_byte_buffer_reader_init(&reader, bb)); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_slice* slice; if (GPR_UNLIKELY(!g_core_codegen_interface->grpc_byte_buffer_reader_peek( &reader, &slice))) { @@ -93,7 +93,7 @@ static void BM_ByteBufferReader_Peek(benchmark::State& state) { grpc_byte_buffer_reader reader; GPR_ASSERT( g_core_codegen_interface->grpc_byte_buffer_reader_init(&reader, bb)); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_slice* slice; if (GPR_UNLIKELY(!g_core_codegen_interface->grpc_byte_buffer_reader_peek( &reader, &slice))) { diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 4eb717d82b5..99ea1e053e9 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -52,7 +52,7 @@ void BM_Zalloc(benchmark::State& state) { // sizes TrackCounters track_counters; size_t sz = state.range(0); - while (state.KeepRunning()) { + for (auto _ : state) { gpr_free(gpr_zalloc(sz)); } track_counters.Finish(state); @@ -107,7 +107,7 @@ static void BM_CallCreateDestroy(benchmark::State& state) { gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); void* method_hdl = grpc_channel_register_call(fixture.channel(), "/foo/bar", nullptr, nullptr); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_call_unref(grpc_channel_create_registered_call( fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, cq, method_hdl, deadline, nullptr)); @@ -139,7 +139,7 @@ static void BM_LameChannelCallCreateCpp(benchmark::State& state) { grpc::testing::EchoRequest send_request; grpc::testing::EchoResponse recv_response; grpc::Status recv_status; - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc::ClientContext cli_ctx; auto reader = stub->AsyncEcho(&cli_ctx, send_request, &cq); @@ -174,7 +174,7 @@ static void BM_LameChannelCallCreateCore(benchmark::State& state) { cq = grpc_completion_queue_create_for_next(nullptr); void* rc = grpc_channel_register_call( channel, "/grpc.testing.EchoTestService/Echo", nullptr, nullptr); - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc_call* call = grpc_channel_create_registered_call( channel, nullptr, GRPC_PROPAGATE_DEFAULTS, cq, rc, @@ -248,7 +248,7 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State& state) { cq = grpc_completion_queue_create_for_next(nullptr); void* rc = grpc_channel_register_call( channel, "/grpc.testing.EchoTestService/Echo", nullptr, nullptr); - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc_call* call = grpc_channel_create_registered_call( channel, nullptr, GRPC_PROPAGATE_DEFAULTS, cq, rc, @@ -720,7 +720,7 @@ static void BM_IsolatedCall_NoOp(benchmark::State& state) { gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); void* method_hdl = grpc_channel_register_call(fixture.channel(), "/foo/bar", nullptr, nullptr); - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc_call_unref(grpc_channel_create_registered_call( fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, fixture.cq(), @@ -759,7 +759,7 @@ static void BM_IsolatedCall_Unary(benchmark::State& state) { ops[5].data.recv_status_on_client.status = &status_code; ops[5].data.recv_status_on_client.status_details = &status_details; ops[5].data.recv_status_on_client.trailing_metadata = &recv_trailing_metadata; - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc_call* call = grpc_channel_create_registered_call( fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, fixture.cq(), @@ -802,7 +802,7 @@ static void BM_IsolatedCall_StreamingSend(benchmark::State& state) { memset(ops, 0, sizeof(ops)); ops[0].op = GRPC_OP_SEND_MESSAGE; ops[0].data.send_message.send_message = send_message; - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc_call_start_batch(call, ops, 1, tag(2), nullptr); grpc_completion_queue_next(fixture.cq(), diff --git a/test/cpp/microbenchmarks/bm_channel.cc b/test/cpp/microbenchmarks/bm_channel.cc index 88856c3439b..224170b32e9 100644 --- a/test/cpp/microbenchmarks/bm_channel.cc +++ b/test/cpp/microbenchmarks/bm_channel.cc @@ -62,7 +62,7 @@ static void BM_InsecureChannelCreateDestroy(benchmark::State& state) { for (int i = 0; i < state.range(0); i++) { initial_channels[i].Init(); } - while (state.KeepRunning()) { + for (auto _ : state) { Fixture channel; channel.Init(); } diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index 4950e7f7768..5d5be763d55 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -54,7 +54,7 @@ static void BM_HpackEncoderInitDestroy(benchmark::State& state) { grpc_core::ExecCtx exec_ctx; std::unique_ptr c( new grpc_chttp2_hpack_compressor); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_chttp2_hpack_compressor_init(c.get()); grpc_chttp2_hpack_compressor_destroy(c.get()); grpc_core::ExecCtx::Get()->Flush(); @@ -435,7 +435,7 @@ static void BM_HpackParserInitDestroy(benchmark::State& state) { grpc_chttp2_hpack_parser p; // Initial destruction so we don't leak memory in the loop. grpc_chttp2_hptbl_destroy(&p.table); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_chttp2_hpack_parser_init(&p); // Note that grpc_chttp2_hpack_parser_destroy frees the table dynamic // elements so we need to recreate it here. In actual operation, diff --git a/test/cpp/microbenchmarks/bm_closure.cc b/test/cpp/microbenchmarks/bm_closure.cc index 84b1c536bf0..5133c2a0f43 100644 --- a/test/cpp/microbenchmarks/bm_closure.cc +++ b/test/cpp/microbenchmarks/bm_closure.cc @@ -32,7 +32,7 @@ static void BM_NoOpExecCtx(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { grpc_core::ExecCtx exec_ctx; } track_counters.Finish(state); @@ -42,7 +42,7 @@ BENCHMARK(BM_NoOpExecCtx); static void BM_WellFlushed(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { grpc_core::ExecCtx::Get()->Flush(); } @@ -55,7 +55,7 @@ static void DoNothing(void* arg, grpc_error* error) {} static void BM_ClosureInitAgainstExecCtx(benchmark::State& state) { TrackCounters track_counters; grpc_closure c; - while (state.KeepRunning()) { + for (auto _ : state) { benchmark::DoNotOptimize( GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx)); } @@ -68,7 +68,7 @@ static void BM_ClosureInitAgainstCombiner(benchmark::State& state) { grpc_combiner* combiner = grpc_combiner_create(); grpc_closure c; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { benchmark::DoNotOptimize(GRPC_CLOSURE_INIT( &c, DoNothing, nullptr, grpc_combiner_scheduler(combiner))); } @@ -83,7 +83,7 @@ static void BM_ClosureRunOnExecCtx(benchmark::State& state) { grpc_closure c; GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_RUN(&c, GRPC_ERROR_NONE); grpc_core::ExecCtx::Get()->Flush(); } @@ -95,7 +95,7 @@ BENCHMARK(BM_ClosureRunOnExecCtx); static void BM_ClosureCreateAndRun(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_RUN( GRPC_CLOSURE_CREATE(DoNothing, nullptr, grpc_schedule_on_exec_ctx), GRPC_ERROR_NONE); @@ -109,7 +109,7 @@ static void BM_ClosureInitAndRun(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; grpc_closure c; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_RUN( GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx), GRPC_ERROR_NONE); @@ -124,7 +124,7 @@ static void BM_ClosureSchedOnExecCtx(benchmark::State& state) { grpc_closure c; GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_SCHED(&c, GRPC_ERROR_NONE); grpc_core::ExecCtx::Get()->Flush(); } @@ -140,7 +140,7 @@ static void BM_ClosureSched2OnExecCtx(benchmark::State& state) { GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_schedule_on_exec_ctx); GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_schedule_on_exec_ctx); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE); grpc_core::ExecCtx::Get()->Flush(); @@ -159,7 +159,7 @@ static void BM_ClosureSched3OnExecCtx(benchmark::State& state) { GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_schedule_on_exec_ctx); GRPC_CLOSURE_INIT(&c3, DoNothing, nullptr, grpc_schedule_on_exec_ctx); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(&c3, GRPC_ERROR_NONE); @@ -176,7 +176,7 @@ static void BM_AcquireMutex(benchmark::State& state) { gpr_mu mu; gpr_mu_init(&mu); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { gpr_mu_lock(&mu); DoNothing(nullptr, GRPC_ERROR_NONE); gpr_mu_unlock(&mu); @@ -193,7 +193,7 @@ static void BM_TryAcquireMutex(benchmark::State& state) { gpr_mu mu; gpr_mu_init(&mu); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { if (gpr_mu_trylock(&mu)) { DoNothing(nullptr, GRPC_ERROR_NONE); gpr_mu_unlock(&mu); @@ -212,7 +212,7 @@ static void BM_AcquireSpinlock(benchmark::State& state) { // for comparison with the combiner stuff below gpr_spinlock mu = GPR_SPINLOCK_INITIALIZER; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { gpr_spinlock_lock(&mu); DoNothing(nullptr, GRPC_ERROR_NONE); gpr_spinlock_unlock(&mu); @@ -227,7 +227,7 @@ static void BM_TryAcquireSpinlock(benchmark::State& state) { // for comparison with the combiner stuff below gpr_spinlock mu = GPR_SPINLOCK_INITIALIZER; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { if (gpr_spinlock_trylock(&mu)) { DoNothing(nullptr, GRPC_ERROR_NONE); gpr_spinlock_unlock(&mu); @@ -246,7 +246,7 @@ static void BM_ClosureSchedOnCombiner(benchmark::State& state) { grpc_closure c; GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_SCHED(&c, GRPC_ERROR_NONE); grpc_core::ExecCtx::Get()->Flush(); } @@ -264,7 +264,7 @@ static void BM_ClosureSched2OnCombiner(benchmark::State& state) { GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE); grpc_core::ExecCtx::Get()->Flush(); @@ -285,7 +285,7 @@ static void BM_ClosureSched3OnCombiner(benchmark::State& state) { GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); GRPC_CLOSURE_INIT(&c3, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(&c3, GRPC_ERROR_NONE); @@ -308,7 +308,7 @@ static void BM_ClosureSched2OnTwoCombiners(benchmark::State& state) { GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_combiner_scheduler(combiner2)); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE); grpc_core::ExecCtx::Get()->Flush(); @@ -337,7 +337,7 @@ static void BM_ClosureSched4OnTwoCombiners(benchmark::State& state) { GRPC_CLOSURE_INIT(&c4, DoNothing, nullptr, grpc_combiner_scheduler(combiner2)); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(&c3, GRPC_ERROR_NONE); diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index edbff9c2be3..e72de05537c 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -34,7 +34,7 @@ namespace testing { static void BM_CreateDestroyCpp(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { CompletionQueue cq; } track_counters.Finish(state); @@ -44,7 +44,7 @@ BENCHMARK(BM_CreateDestroyCpp); /* Create cq using a different constructor */ static void BM_CreateDestroyCpp2(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { grpc_completion_queue* core_cq = grpc_completion_queue_create_for_next(nullptr); CompletionQueue cq(core_cq); @@ -55,7 +55,7 @@ BENCHMARK(BM_CreateDestroyCpp2); static void BM_CreateDestroyCore(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { // TODO: sreek Templatize this benchmark and pass completion type and // polling type as parameters grpc_completion_queue_destroy( @@ -77,7 +77,7 @@ static void BM_Pass1Cpp(benchmark::State& state) { TrackCounters track_counters; CompletionQueue cq; grpc_completion_queue* c_cq = cq.cq(); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_cq_completion completion; DummyTag dummy_tag; grpc_core::ExecCtx exec_ctx; @@ -98,7 +98,7 @@ static void BM_Pass1Core(benchmark::State& state) { // TODO: sreek Templatize this benchmark and pass polling_type as a param grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_cq_completion completion; grpc_core::ExecCtx exec_ctx; GPR_ASSERT(grpc_cq_begin_op(cq, nullptr)); @@ -117,7 +117,7 @@ static void BM_Pluck1Core(benchmark::State& state) { // TODO: sreek Templatize this benchmark and pass polling_type as a param grpc_completion_queue* cq = grpc_completion_queue_create_for_pluck(nullptr); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_cq_completion completion; grpc_core::ExecCtx exec_ctx; GPR_ASSERT(grpc_cq_begin_op(cq, nullptr)); @@ -136,7 +136,7 @@ static void BM_EmptyCore(benchmark::State& state) { // TODO: sreek Templatize this benchmark and pass polling_type as a param grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); gpr_timespec deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_completion_queue_next(cq, deadline, nullptr); } grpc_completion_queue_destroy(cq); @@ -202,7 +202,7 @@ static void BM_Callback_CQ_Pass1Core(benchmark::State& state) { ShutdownCallback shutdown_cb(&got_shutdown); grpc_completion_queue* cc = grpc_completion_queue_create_for_callback(&shutdown_cb, nullptr); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; grpc_cq_completion completion; diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc index 329eaf2434e..4dc471b1bc5 100644 --- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc +++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc @@ -174,7 +174,7 @@ static void BM_Cq_Throughput(benchmark::State& state) { // (optionally including low-level counters) before and after the test TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { GPR_ASSERT(grpc_completion_queue_next(g_cq, deadline, nullptr).type == GRPC_OP_COMPLETE); } diff --git a/test/cpp/microbenchmarks/bm_error.cc b/test/cpp/microbenchmarks/bm_error.cc index a71817f7e54..c58453be4f5 100644 --- a/test/cpp/microbenchmarks/bm_error.cc +++ b/test/cpp/microbenchmarks/bm_error.cc @@ -35,7 +35,7 @@ typedef std::unique_ptr ErrorPtr; static void BM_ErrorCreateFromStatic(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_ERROR_UNREF(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error")); } track_counters.Finish(state); @@ -44,7 +44,7 @@ BENCHMARK(BM_ErrorCreateFromStatic); static void BM_ErrorCreateFromCopied(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_ERROR_UNREF(GRPC_ERROR_CREATE_FROM_COPIED_STRING("Error not inline")); } track_counters.Finish(state); @@ -53,7 +53,7 @@ BENCHMARK(BM_ErrorCreateFromCopied); static void BM_ErrorCreateAndSetStatus(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_ERROR_UNREF( grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_ABORTED)); @@ -64,7 +64,7 @@ BENCHMARK(BM_ErrorCreateAndSetStatus); static void BM_ErrorCreateAndSetIntAndStr(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_ERROR_UNREF(grpc_error_set_str( grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("GOAWAY received"), @@ -79,7 +79,7 @@ static void BM_ErrorCreateAndSetIntLoop(benchmark::State& state) { TrackCounters track_counters; grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"); int n = 0; - while (state.KeepRunning()) { + for (auto _ : state) { error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS, n++); } GRPC_ERROR_UNREF(error); @@ -91,7 +91,7 @@ static void BM_ErrorCreateAndSetStrLoop(benchmark::State& state) { TrackCounters track_counters; grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"); const char* str = "hello"; - while (state.KeepRunning()) { + for (auto _ : state) { error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, grpc_slice_from_static_string(str)); } @@ -103,7 +103,7 @@ BENCHMARK(BM_ErrorCreateAndSetStrLoop); static void BM_ErrorRefUnref(benchmark::State& state) { TrackCounters track_counters; grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"); - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_ERROR_UNREF(GRPC_ERROR_REF(error)); } GRPC_ERROR_UNREF(error); @@ -113,7 +113,7 @@ BENCHMARK(BM_ErrorRefUnref); static void BM_ErrorUnrefNone(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_ERROR_UNREF(GRPC_ERROR_NONE); } } @@ -121,7 +121,7 @@ BENCHMARK(BM_ErrorUnrefNone); static void BM_ErrorGetIntFromNoError(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { intptr_t value; grpc_error_get_int(GRPC_ERROR_NONE, GRPC_ERROR_INT_GRPC_STATUS, &value); } @@ -133,7 +133,7 @@ static void BM_ErrorGetMissingInt(benchmark::State& state) { TrackCounters track_counters; ErrorPtr error(grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_INDEX, 1)); - while (state.KeepRunning()) { + for (auto _ : state) { intptr_t value; grpc_error_get_int(error.get(), GRPC_ERROR_INT_OFFSET, &value); } @@ -145,7 +145,7 @@ static void BM_ErrorGetPresentInt(benchmark::State& state) { TrackCounters track_counters; ErrorPtr error(grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_OFFSET, 1)); - while (state.KeepRunning()) { + for (auto _ : state) { intptr_t value; grpc_error_get_int(error.get(), GRPC_ERROR_INT_OFFSET, &value); } @@ -224,7 +224,7 @@ class ErrorWithNestedGrpcStatus { template static void BM_ErrorStringOnNewError(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { Fixture fixture; grpc_error_string(fixture.error()); } @@ -235,7 +235,7 @@ template static void BM_ErrorStringRepeatedly(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; - while (state.KeepRunning()) { + for (auto _ : state) { grpc_error_string(fixture.error()); } track_counters.Finish(state); @@ -246,7 +246,7 @@ static void BM_ErrorGetStatus(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { grpc_status_code status; grpc_slice slice; grpc_error_get_status(fixture.error(), fixture.deadline(), &status, &slice, @@ -261,7 +261,7 @@ static void BM_ErrorGetStatusCode(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { grpc_status_code status; grpc_error_get_status(fixture.error(), fixture.deadline(), &status, nullptr, nullptr, nullptr); @@ -275,7 +275,7 @@ static void BM_ErrorHttpError(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { grpc_http2_error_code error; grpc_error_get_status(fixture.error(), fixture.deadline(), nullptr, nullptr, &error, nullptr); @@ -288,7 +288,7 @@ template static void BM_HasClearGrpcStatus(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; - while (state.KeepRunning()) { + for (auto _ : state) { grpc_error_has_clear_grpc_status(fixture.error()); } track_counters.Finish(state); diff --git a/test/cpp/microbenchmarks/bm_metadata.cc b/test/cpp/microbenchmarks/bm_metadata.cc index d472363eb87..d6ccee5ceef 100644 --- a/test/cpp/microbenchmarks/bm_metadata.cc +++ b/test/cpp/microbenchmarks/bm_metadata.cc @@ -30,7 +30,7 @@ static void BM_SliceFromStatic(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { benchmark::DoNotOptimize(grpc_core::ExternallyManagedSlice("abc")); } track_counters.Finish(state); @@ -39,7 +39,7 @@ BENCHMARK(BM_SliceFromStatic); static void BM_SliceFromCopied(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { grpc_slice_unref(grpc_core::UnmanagedMemorySlice("abc")); } track_counters.Finish(state); @@ -49,7 +49,7 @@ BENCHMARK(BM_SliceFromCopied); static void BM_SliceIntern(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExternallyManagedSlice slice("abc"); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_slice_unref(grpc_core::ManagedMemorySlice(&slice)); } track_counters.Finish(state); @@ -60,7 +60,7 @@ static void BM_SliceReIntern(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExternallyManagedSlice static_slice("abc"); grpc_core::ManagedMemorySlice slice(&static_slice); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_slice_unref(grpc_core::ManagedMemorySlice(&slice)); } track_counters.Finish(state); @@ -69,7 +69,7 @@ BENCHMARK(BM_SliceReIntern); static void BM_SliceInternStaticMetadata(benchmark::State& state) { TrackCounters track_counters; - while (state.KeepRunning()) { + for (auto _ : state) { benchmark::DoNotOptimize(grpc_core::ManagedMemorySlice(&GRPC_MDSTR_GZIP)); } track_counters.Finish(state); @@ -79,7 +79,7 @@ BENCHMARK(BM_SliceInternStaticMetadata); static void BM_SliceInternEqualToStaticMetadata(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExternallyManagedSlice slice("gzip"); - while (state.KeepRunning()) { + for (auto _ : state) { benchmark::DoNotOptimize(grpc_core::ManagedMemorySlice(&slice)); } track_counters.Finish(state); @@ -91,7 +91,7 @@ static void BM_MetadataFromNonInternedSlices(benchmark::State& state) { grpc_core::ExternallyManagedSlice k("key"); grpc_core::ExternallyManagedSlice v("value"); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr)); } @@ -104,7 +104,7 @@ static void BM_MetadataFromInternedSlices(benchmark::State& state) { grpc_core::ManagedMemorySlice k("key"); grpc_core::ManagedMemorySlice v("value"); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr)); } @@ -121,7 +121,7 @@ static void BM_MetadataFromInternedSlicesAlreadyInIndex( grpc_core::ManagedMemorySlice v("value"); grpc_core::ExecCtx exec_ctx; grpc_mdelem seed = grpc_mdelem_create(k, v, nullptr); - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr)); } GRPC_MDELEM_UNREF(seed); @@ -137,7 +137,7 @@ static void BM_MetadataFromInternedKey(benchmark::State& state) { grpc_core::ManagedMemorySlice k("key"); grpc_core::ExternallyManagedSlice v("value"); grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr)); } @@ -153,7 +153,7 @@ static void BM_MetadataFromNonInternedSlicesWithBackingStore( grpc_core::ExternallyManagedSlice v("value"); char backing_store[sizeof(grpc_mdelem_data)]; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(grpc_mdelem_create( k, v, reinterpret_cast(backing_store))); } @@ -169,7 +169,7 @@ static void BM_MetadataFromInternedSlicesWithBackingStore( grpc_core::ManagedMemorySlice v("value"); char backing_store[sizeof(grpc_mdelem_data)]; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(grpc_mdelem_create( k, v, reinterpret_cast(backing_store))); } @@ -187,7 +187,7 @@ static void BM_MetadataFromInternedKeyWithBackingStore( grpc_core::ExternallyManagedSlice v("value"); char backing_store[sizeof(grpc_mdelem_data)]; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(grpc_mdelem_create( k, v, reinterpret_cast(backing_store))); } @@ -200,7 +200,7 @@ BENCHMARK(BM_MetadataFromInternedKeyWithBackingStore); static void BM_MetadataFromStaticMetadataStrings(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF( grpc_mdelem_create(GRPC_MDSTR_STATUS, GRPC_MDSTR_200, nullptr)); } @@ -213,7 +213,7 @@ static void BM_MetadataFromStaticMetadataStringsNotIndexed( benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF( grpc_mdelem_create(GRPC_MDSTR_STATUS, GRPC_MDSTR_GZIP, nullptr)); } @@ -230,7 +230,7 @@ static void BM_MetadataRefUnrefExternal(benchmark::State& state) { grpc_mdelem_create(grpc_core::ExternallyManagedSlice("a"), grpc_core::ExternallyManagedSlice("b"), reinterpret_cast(backing_store)); - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el)); } GRPC_MDELEM_UNREF(el); @@ -249,7 +249,7 @@ static void BM_MetadataRefUnrefInterned(benchmark::State& state) { k, v, reinterpret_cast(backing_store)); grpc_slice_unref(k); grpc_slice_unref(v); - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el)); } GRPC_MDELEM_UNREF(el); @@ -264,7 +264,7 @@ static void BM_MetadataRefUnrefAllocated(benchmark::State& state) { grpc_mdelem el = grpc_mdelem_create(grpc_core::ExternallyManagedSlice("a"), grpc_core::ExternallyManagedSlice("b"), nullptr); - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el)); } GRPC_MDELEM_UNREF(el); @@ -278,7 +278,7 @@ static void BM_MetadataRefUnrefStatic(benchmark::State& state) { grpc_core::ExecCtx exec_ctx; grpc_mdelem el = grpc_mdelem_create(GRPC_MDSTR_STATUS, GRPC_MDSTR_200, nullptr); - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el)); } GRPC_MDELEM_UNREF(el); diff --git a/test/cpp/microbenchmarks/bm_pollset.cc b/test/cpp/microbenchmarks/bm_pollset.cc index f8e36f178e4..c360f02d466 100644 --- a/test/cpp/microbenchmarks/bm_pollset.cc +++ b/test/cpp/microbenchmarks/bm_pollset.cc @@ -53,7 +53,7 @@ static void BM_CreateDestroyPollset(benchmark::State& state) { grpc_closure shutdown_ps_closure; GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps, grpc_schedule_on_exec_ctx); - while (state.KeepRunning()) { + for (auto _ : state) { memset(ps, 0, ps_sz); grpc_pollset_init(ps, &mu); gpr_mu_lock(mu); @@ -84,7 +84,7 @@ static void BM_PollEmptyPollset_SpeedOfLight(benchmark::State& state) { ev.events = EPOLLIN; epoll_ctl(epfd, EPOLL_CTL_ADD, fds.back(), &ev); } - while (state.KeepRunning()) { + for (auto _ : state) { epoll_wait(epfd, ev, nev, 0); } for (auto fd : fds) { @@ -115,7 +115,7 @@ static void BM_PollEmptyPollset(benchmark::State& state) { grpc_pollset_init(ps, &mu); grpc_core::ExecCtx exec_ctx; gpr_mu_lock(mu); - while (state.KeepRunning()) { + for (auto _ : state) { GRPC_ERROR_UNREF(grpc_pollset_work(ps, nullptr, 0)); } grpc_closure shutdown_ps_closure; @@ -140,7 +140,7 @@ static void BM_PollAddFd(benchmark::State& state) { GPR_ASSERT( GRPC_LOG_IF_ERROR("wakeup_fd_init", grpc_wakeup_fd_init(&wakeup_fd))); grpc_fd* fd = grpc_fd_create(wakeup_fd.read_fd, "xxx", false); - while (state.KeepRunning()) { + for (auto _ : state) { grpc_pollset_add_fd(ps, fd); grpc_core::ExecCtx::Get()->Flush(); } @@ -188,7 +188,7 @@ static void BM_SingleThreadPollOneFd_SpeedOfLight(benchmark::State& state) { int fd = eventfd(0, EFD_NONBLOCK); ev[0].events = EPOLLIN; epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &ev[0]); - while (state.KeepRunning()) { + for (auto _ : state) { int err; do { err = eventfd_write(fd, 1); diff --git a/test/cpp/microbenchmarks/bm_timer.cc b/test/cpp/microbenchmarks/bm_timer.cc index 53aaead992d..7a493df5826 100644 --- a/test/cpp/microbenchmarks/bm_timer.cc +++ b/test/cpp/microbenchmarks/bm_timer.cc @@ -43,7 +43,7 @@ static void BM_InitCancelTimer(benchmark::State& state) { grpc_core::ExecCtx exec_ctx; std::vector timer_closures(kTimerCount); int i = 0; - while (state.KeepRunning()) { + for (auto _ : state) { TimerClosure* timer_closure = &timer_closures[i++ % kTimerCount]; GRPC_CLOSURE_INIT(&timer_closure->closure, [](void* /*args*/, grpc_error* /*err*/) {}, nullptr, @@ -71,7 +71,7 @@ static void BM_TimerBatch(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx exec_ctx; std::vector timer_closures(kTimerCount); - while (state.KeepRunning()) { + for (auto _ : state) { for (grpc_millis deadline = start; deadline != end; deadline += increment) { TimerClosure* timer_closure = &timer_closures[deadline % kTimerCount]; GRPC_CLOSURE_INIT(&timer_closure->closure, diff --git a/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h b/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h index f399949a32f..db9be84fefb 100644 --- a/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h @@ -65,7 +65,7 @@ static void BM_StreamingPingPong(benchmark::State& state) { std::unique_ptr stub( EchoTestService::NewStub(fixture->channel())); - while (state.KeepRunning()) { + for (auto _ : state) { ServerContext svr_ctx; ServerContextMutator svr_ctx_mut(&svr_ctx); ServerAsyncReaderWriter response_rw(&svr_ctx); @@ -180,7 +180,7 @@ static void BM_StreamingPingPongMsgs(benchmark::State& state) { need_tags &= ~(1 << i); } - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); request_rw->Write(send_request, tag(0)); // Start client send response_rw.Read(&recv_request, tag(1)); // Start server recv @@ -262,7 +262,7 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) { std::unique_ptr stub( EchoTestService::NewStub(fixture->channel())); - while (state.KeepRunning()) { + for (auto _ : state) { ServerContext svr_ctx; ServerContextMutator svr_ctx_mut(&svr_ctx); ServerAsyncReaderWriter response_rw(&svr_ctx); diff --git a/test/cpp/microbenchmarks/fullstack_streaming_pump.h b/test/cpp/microbenchmarks/fullstack_streaming_pump.h index 3623e373f6f..cf72710ccb9 100644 --- a/test/cpp/microbenchmarks/fullstack_streaming_pump.h +++ b/test/cpp/microbenchmarks/fullstack_streaming_pump.h @@ -67,7 +67,7 @@ static void BM_PumpStreamClientToServer(benchmark::State& state) { need_tags &= ~(1 << i); } response_rw.Read(&recv_request, tag(0)); - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); request_rw->Write(send_request, tag(1)); while (true) { @@ -136,7 +136,7 @@ static void BM_PumpStreamServerToClient(benchmark::State& state) { need_tags &= ~(1 << i); } request_rw->Read(&recv_response, tag(0)); - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); response_rw.Write(send_response, tag(1)); while (true) { diff --git a/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h b/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h index 843c8e14862..604e0ed511e 100644 --- a/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h +++ b/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h @@ -71,7 +71,7 @@ static void BM_UnaryPingPong(benchmark::State& state) { fixture->cq(), tag(1)); std::unique_ptr stub( EchoTestService::NewStub(fixture->channel())); - while (state.KeepRunning()) { + for (auto _ : state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); recv_response.Clear(); ClientContext cli_ctx; diff --git a/test/cpp/microbenchmarks/noop-benchmark.cc b/test/cpp/microbenchmarks/noop-benchmark.cc index 96605215dc6..49ffbf84bef 100644 --- a/test/cpp/microbenchmarks/noop-benchmark.cc +++ b/test/cpp/microbenchmarks/noop-benchmark.cc @@ -22,7 +22,7 @@ #include static void BM_NoOp(benchmark::State& state) { - while (state.KeepRunning()) { + for (auto _ : state) { } } BENCHMARK(BM_NoOp); From 88f5f130dd78bb18f683e7d410f427211500934a Mon Sep 17 00:00:00 2001 From: Steven E Wright Date: Thu, 29 Aug 2019 12:00:02 -0700 Subject: [PATCH 1402/1555] Fix `shorten-64-to-32` warning in `GRPCChannel` Per: https://github.com/grpc/grpc/issues/20122 this change avoids the `shorten-64-to-32` warning by calling the correct `NSNumber` factory method for an `NSUInteger` (the base type for the `GRPCCompressionAlgorithm` enum) --- src/objective-c/GRPCClient/private/GRPCChannel.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m index 1a79fb04a0d..2081d0534fa 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCChannel.m @@ -103,7 +103,7 @@ if (_callOptions.compressionAlgorithm != GRPC_COMPRESS_NONE) { args[@GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM] = - [NSNumber numberWithInt:_callOptions.compressionAlgorithm]; + [NSNumber numberWithInteger:_callOptions.compressionAlgorithm]; } if (_callOptions.keepaliveInterval != 0) { From 9c4de3a983f54a23cbf574356c55be3704ce19f6 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Thu, 29 Aug 2019 12:16:36 -0700 Subject: [PATCH 1403/1555] Move reference to external workspace to OSS-specific file --- BUILD | 8 +++----- bazel/grpc_build_system.bzl | 7 +++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/BUILD b/BUILD index e489bc2584a..d911050b1be 100644 --- a/BUILD +++ b/BUILD @@ -31,6 +31,7 @@ load( "grpc_cc_library", "grpc_generate_one_off_targets", "grpc_upb_proto_library", + "python_config_settings", ) config_setting( @@ -63,11 +64,6 @@ config_setting( values = {"cpu": "x64_windows_msvc"}, ) -config_setting( - name = "python3", - flag_values = {"@bazel_tools//tools/python:python_version": "PY3"}, -) - config_setting( name = "mac_x86_64", values = {"cpu": "darwin"}, @@ -78,6 +74,8 @@ config_setting( values = {"define": "GRPC_USE_CPP_STD_LIB=1"}, ) +python_config_settings() + # This should be updated along with build.yaml g_stands_for = "ganges" diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index f4777e50bc1..74a9c66ff67 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -342,3 +342,10 @@ def grpc_objc_library( def grpc_upb_proto_library(name, deps): upb_proto_library(name = name, deps = deps) + +def python_config_settings(): + native.config_setting( + name = "python3", + flag_values = {"@bazel_tools//tools/python:python_version": "PY3"}, + ) + From aa2a65faedd62be2024e270a88f1001b3f5b2f80 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 29 Aug 2019 14:08:52 -0700 Subject: [PATCH 1404/1555] Remove call from queued picks when failing it due to channel destruction --- src/core/ext/filters/client_channel/client_channel.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 3272bc3ffed..8a0fabfa6fd 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -3881,6 +3881,7 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { GRPC_ERROR_UNREF(result.error); GRPC_CLOSURE_SCHED(&calld->pick_closure_, GRPC_ERROR_REF(disconnect_error)); + if (calld->pick_queued_) calld->RemoveCallFromQueuedPicksLocked(elem); break; } // If wait_for_ready is false, then the error indicates the RPC From 32801fb5eb1b5f50e9282a563eb6226ce602b855 Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Thu, 29 Aug 2019 14:11:05 -0700 Subject: [PATCH 1405/1555] Remove build target for microbenchmark --- test/cpp/microbenchmarks/BUILD | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD index fdae8246c31..b8e9b14d4b4 100644 --- a/test/cpp/microbenchmarks/BUILD +++ b/test/cpp/microbenchmarks/BUILD @@ -27,14 +27,6 @@ grpc_cc_test( deps = ["//test/core/util:grpc_test_util"], ) -grpc_cc_binary( - name = "bm_chttp2_transport", - testonly = 1, - srcs = ["bm_chttp2_transport.cc"], - tags = ["no_windows"], - deps = [":helpers"], -) - grpc_cc_library( name = "helpers", testonly = 1, From 8a352221646479bc60dcc4a7e1099cda6e36510c Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 29 Aug 2019 15:52:42 -0700 Subject: [PATCH 1406/1555] fix Swift build --- src/objective-c/BUILD | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/objective-c/BUILD b/src/objective-c/BUILD index 5f53486d17e..be1cd09d0fa 100644 --- a/src/objective-c/BUILD +++ b/src/objective-c/BUILD @@ -101,7 +101,7 @@ grpc_objc_library( ) grpc_objc_library( - name = "grpc_objc_client_core", + name = "grpc_objc_client", hdrs = [ "GRPCClient/GRPCCall+ChannelCredentials.h", "GRPCClient/GRPCCall+Cronet.h", @@ -128,9 +128,11 @@ grpc_objc_library( ], ) +# TODO (mxyan): Switch "name" and "actual" when import is done +# Some internal Swift projects will need to be updated with the new name alias( - name = "grpc_objc_client", - actual = "grpc_objc_client_core", + name = "grpc_objc_client_core", + actual = "grpc_objc_client", ) grpc_objc_library( @@ -170,6 +172,7 @@ grpc_objc_library( ], hdrs = [ "ProtoRPC/ProtoMethod.h", + "ProtoRPC/ProtoRPC.h", "ProtoRPC/ProtoRPCLegacy.h", "ProtoRPC/ProtoService.h", ], From d1dae7d9d8cac4366766ca625d902060fa17cd9e Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 29 Aug 2019 16:50:42 -0700 Subject: [PATCH 1407/1555] Log errors in ALTS handshaker message op completion cb --- src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc index 917d375fd82..c5383b3a0ba 100644 --- a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +++ b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc @@ -251,7 +251,14 @@ static void on_handshaker_service_resp_recv(void* arg, grpc_error* error) { gpr_log(GPR_ERROR, "ALTS handshaker client is nullptr"); return; } - alts_handshaker_client_handle_response(client, true); + bool success = true; + if (error != GRPC_ERROR_NONE) { + gpr_log(GPR_ERROR, + "ALTS handshaker on_handshaker_service_resp_recv error: %s", + grpc_error_string(error)); + success = false; + } + alts_handshaker_client_handle_response(client, success); } /* gRPC provided callback used when dedicatd CQ and thread are used. From deee1f08268b78b16909e9767f5965aae1d2947a Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Fri, 30 Aug 2019 08:24:38 +0800 Subject: [PATCH 1408/1555] Update: add offical guide link --- examples/python/data_transmission/README.cn.md | 10 +++++----- examples/python/data_transmission/README.en.md | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/python/data_transmission/README.cn.md b/examples/python/data_transmission/README.cn.md index 500e9bf95de..c5cbb71c41d 100644 --- a/examples/python/data_transmission/README.cn.md +++ b/examples/python/data_transmission/README.cn.md @@ -1,10 +1,10 @@ ## Data transmission demo for using gRPC in Python -在Python中使用gRPC时, 进行数据传输的四种方式。 +在Python中使用gRPC时, 进行数据传输的四种方式 [官方指南]() -- #### 简单模式 +- #### 一元模式 - 没啥好说的,跟调普通方法没差 + 在一次调用中, 客户端只能向服务器传输一次请求数据, 服务器也只能返回一次响应 `client.py - line:13 - simple_method` @@ -12,7 +12,7 @@ - #### 客户端流模式 - 在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应. + 在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应 `clien.py - line:24 - client_streaming_method ` @@ -20,7 +20,7 @@ - #### 服务端流模式 - 在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应 + 在一次调用中, 客户端只能向服务器传输一次请求数据, 但是服务器可以多次返回响应 `clien.py - line:42 - server_streaming_method` diff --git a/examples/python/data_transmission/README.en.md b/examples/python/data_transmission/README.en.md index 7fc527cf51a..f87682f2038 100644 --- a/examples/python/data_transmission/README.en.md +++ b/examples/python/data_transmission/README.en.md @@ -1,10 +1,10 @@ ## Data transmission demo for using gRPC in Python -Four ways of data transmission when gRPC is used in Python. +Four ways of data transmission when gRPC is used in Python. [Offical Guide]() - #### unary-unary - There's nothing to say. It's no different from the usual way. + In a single call, the client can only send request once, and the server can only respond once. `client.py - line:13 - simple_method` From 25a1caa9b08d03729dbd2cce3c2bacd493ef4ce0 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Fri, 30 Aug 2019 08:30:07 +0800 Subject: [PATCH 1409/1555] Update: add proto3 document link, change chinese translation and comment of 'unary' --- examples/python/data_transmission/client.py | 7 ++++--- examples/python/data_transmission/demo.proto | 22 ++++++++++++-------- examples/python/data_transmission/server.py | 7 ++++--- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/examples/python/data_transmission/client.py b/examples/python/data_transmission/client.py index 21c61d6cc6e..66bfc76450d 100644 --- a/examples/python/data_transmission/client.py +++ b/examples/python/data_transmission/client.py @@ -4,12 +4,13 @@ import grpc import demo_pb2_grpc import demo_pb2 -SERVER_ADDRESS = "localhost:23334" +SERVER_ADDRESS = "localhost:23333" CLIENT_ID = 1 -# 简单模式 -# unary-unary +# 一元模式(在一次调用中, 客户端只能向服务器传输一次请求数据, 服务器也只能返回一次响应) +# unary-unary(In a single call, the client can only send request once, and the server can +# only respond once.) def simple_method(stub): print("--------------Call SimpleMethod Begin--------------") request = demo_pb2.Request(client_id=CLIENT_ID, request_data="called by Python client") diff --git a/examples/python/data_transmission/demo.proto b/examples/python/data_transmission/demo.proto index dd29a178d77..d3d96b523d1 100644 --- a/examples/python/data_transmission/demo.proto +++ b/examples/python/data_transmission/demo.proto @@ -1,9 +1,11 @@ // 语法版本声明,必须放在非注释的第一行 // Syntax version declaration. Must be placed on the first line of non-commentary. -syntax = "proto3"; -// 包名定义, Python中使用时可以省略不写(PS:我还要再Go中使用,所以留在这里了) -// Package name definition, which can be omitted in Python. (PS: I'll use it again in Go, so stay here) +syntax = "proto3"; +// The document of proto3: https://developers.google.com/protocol-buffers/docs/proto3 + +// 包名定义, Python中使用时可以省略不写 +// Package name definition, which can be omitted in Python. package demo; /* @@ -12,8 +14,8 @@ package demo; 总体格式类似于Python中定义一个类或者Golang中定义一个结构体 */ /* -`message` is used to define the structure of the data to be transmitted, After the equal sign is the field number. -Each field in the message definition has a unique number. +`message` is used to define the structure of the data to be transmitted, after the equal sign +is the field number. Each field in the message definition has a unique number. The overall format is similar to defining a class in Python or a structure in Golang. */ message Request { @@ -26,11 +28,13 @@ message Response { string response_data = 2; } -// service是用来给GRPC服务定义方法的, 格式固定, 类似于Golang中定义一个接口 -// `service` is used to define methods for GRPC services in a fixed format, similar to defining an interface in Golang +// `service` 是用来给gRPC服务定义方法的, 格式固定, 类似于Golang中定义一个接口 +// `service` is used to define methods for gRPC services in a fixed format, similar to defining +//an interface in Golang service GRPCDemo { - // 简单模式 - // unary-unary + // 一元模式(在一次调用中, 客户端只能向服务器传输一次请求数据, 服务器也只能返回一次响应) + // unary-unary(In a single call, the client can only send request once, and the server can + // only respond once.) rpc SimpleMethod (Request) returns (Response); // 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) diff --git a/examples/python/data_transmission/server.py b/examples/python/data_transmission/server.py index e6e51e1b733..64c697dd952 100644 --- a/examples/python/data_transmission/server.py +++ b/examples/python/data_transmission/server.py @@ -6,14 +6,15 @@ from concurrent import futures import demo_pb2_grpc import demo_pb2 -SERVER_ADDRESS = 'localhost:23334' +SERVER_ADDRESS = 'localhost:23333' SERVER_ID = 1 class DemoServer(demo_pb2_grpc.GRPCDemoServicer): - # 简单模式 - # unary-unary + # 一元模式(在一次调用中, 客户端只能向服务器传输一次请求数据, 服务器也只能返回一次响应) + # unary-unary(In a single call, the client can only send request once, and the server can + # only respond once.) def SimpleMethod(self, request, context): print("SimpleMethod called by client(%d) the message: %s" % (request.client_id, request.request_data)) response = demo_pb2.Response(server_id=SERVER_ID, response_data="Python server SimpleMethod Ok!!!!") From 5c0fed241d8ac0f7a90899ed262759fc1f57b675 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Fri, 30 Aug 2019 08:44:20 +0800 Subject: [PATCH 1410/1555] Fix: reformat code with YAPF script, and check with PyLint --- examples/python/data_transmission/client.py | 29 +++++++++++++------ examples/python/data_transmission/server.py | 32 ++++++++++++++------- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/examples/python/data_transmission/client.py b/examples/python/data_transmission/client.py index 66bfc76450d..0a9559ed79a 100644 --- a/examples/python/data_transmission/client.py +++ b/examples/python/data_transmission/client.py @@ -13,9 +13,11 @@ CLIENT_ID = 1 # only respond once.) def simple_method(stub): print("--------------Call SimpleMethod Begin--------------") - request = demo_pb2.Request(client_id=CLIENT_ID, request_data="called by Python client") + request = demo_pb2.Request( + client_id=CLIENT_ID, request_data="called by Python client") response = stub.SimpleMethod(request) - print("resp from server(%d), the message=%s" % (response.server_id, response.response_data)) + print("resp from server(%d), the message=%s" % (response.server_id, + response.response_data)) print("--------------Call SimpleMethod Over---------------") @@ -29,11 +31,14 @@ def client_streaming_method(stub): # create a generator def request_messages(): for i in range(5): - request = demo_pb2.Request(client_id=CLIENT_ID, request_data=("called by Python client, message:%d" % i)) + request = demo_pb2.Request( + client_id=CLIENT_ID, + request_data=("called by Python client, message:%d" % i)) yield request response = stub.ClientStreamingMethod(request_messages()) - print("resp from server(%d), the message=%s" % (response.server_id, response.response_data)) + print("resp from server(%d), the message=%s" % (response.server_id, + response.response_data)) print("--------------Call ClientStreamingMethod Over---------------") @@ -42,10 +47,12 @@ def client_streaming_method(stub): # but the server can return the response many times.) def server_streaming_method(stub): print("--------------Call ServerStreamingMethod Begin--------------") - request = demo_pb2.Request(client_id=CLIENT_ID, request_data="called by Python client") + request = demo_pb2.Request( + client_id=CLIENT_ID, request_data="called by Python client") response_iterator = stub.ServerStreamingMethod(request) for response in response_iterator: - print("recv from server(%d), message=%s" % (response.server_id, response.response_data)) + print("recv from server(%d), message=%s" % (response.server_id, + response.response_data)) print("--------------Call ServerStreamingMethod Over---------------") @@ -54,19 +61,23 @@ def server_streaming_method(stub): # stream-stream (In a single call, both client and server can send and receive data # to each other multiple times.) def bidirectional_streaming_method(stub): - print("--------------Call BidirectionalStreamingMethod Begin---------------") + print( + "--------------Call BidirectionalStreamingMethod Begin---------------") # 创建一个生成器 # create a generator def request_messages(): for i in range(5): - request = demo_pb2.Request(client_id=CLIENT_ID, request_data=("called by Python client, message: %d" % i)) + request = demo_pb2.Request( + client_id=CLIENT_ID, + request_data=("called by Python client, message: %d" % i)) yield request time.sleep(1) response_iterator = stub.BidirectionalStreamingMethod(request_messages()) for response in response_iterator: - print("recv from server(%d), message=%s" % (response.server_id, response.response_data)) + print("recv from server(%d), message=%s" % (response.server_id, + response.response_data)) print("--------------Call BidirectionalStreamingMethod Over---------------") diff --git a/examples/python/data_transmission/server.py b/examples/python/data_transmission/server.py index 64c697dd952..288c561382b 100644 --- a/examples/python/data_transmission/server.py +++ b/examples/python/data_transmission/server.py @@ -1,8 +1,7 @@ -import grpc - from threading import Thread from concurrent import futures +import grpc import demo_pb2_grpc import demo_pb2 @@ -16,8 +15,11 @@ class DemoServer(demo_pb2_grpc.GRPCDemoServicer): # unary-unary(In a single call, the client can only send request once, and the server can # only respond once.) def SimpleMethod(self, request, context): - print("SimpleMethod called by client(%d) the message: %s" % (request.client_id, request.request_data)) - response = demo_pb2.Response(server_id=SERVER_ID, response_data="Python server SimpleMethod Ok!!!!") + print("SimpleMethod called by client(%d) the message: %s" % + (request.client_id, request.request_data)) + response = demo_pb2.Response( + server_id=SERVER_ID, + response_data="Python server SimpleMethod Ok!!!!") return response # 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) @@ -26,22 +28,27 @@ class DemoServer(demo_pb2_grpc.GRPCDemoServicer): def ClientStreamingMethod(self, request_iterator, context): print("ClientStreamingMethod called by client...") for request in request_iterator: - print("recv from client(%d), message= %s" % (request.client_id, request.request_data)) - response = demo_pb2.Response(server_id=SERVER_ID, response_data="Python server ClientStreamingMethod ok") + print("recv from client(%d), message= %s" % (request.client_id, + request.request_data)) + response = demo_pb2.Response( + server_id=SERVER_ID, + response_data="Python server ClientStreamingMethod ok") return response # 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) # unary-stream (In a single call, the client can only transmit data to the server at one time, # but the server can return the response many times.) def ServerStreamingMethod(self, request, context): - print("ServerStreamingMethod called by client(%d), message= %s" % (request.client_id, request.request_data)) + print("ServerStreamingMethod called by client(%d), message= %s" % + (request.client_id, request.request_data)) # 创建一个生成器 # create a generator def response_messages(): for i in range(5): - response = demo_pb2.Response(server_id=SERVER_ID, - response_data=("send by Python server, message=%d" % i)) + response = demo_pb2.Response( + server_id=SERVER_ID, + response_data=("send by Python server, message=%d" % i)) yield response return response_messages() @@ -56,13 +63,16 @@ class DemoServer(demo_pb2_grpc.GRPCDemoServicer): # Open a sub thread to receive data def parse_request(): for request in request_iterator: - print("recv from client(%d), message= %s" % (request.client_id, request.request_data)) + print("recv from client(%d), message= %s" % + (request.client_id, request.request_data)) t = Thread(target=parse_request) t.start() for i in range(5): - yield demo_pb2.Response(server_id=SERVER_ID, response_data=("send by Python server, message= %d" % i)) + yield demo_pb2.Response( + server_id=SERVER_ID, + response_data=("send by Python server, message= %d" % i)) t.join() From 1859799ee326f06768ed7d0845cc1f0268a74d47 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Fri, 30 Aug 2019 08:55:01 +0800 Subject: [PATCH 1411/1555] Fix: update README because code reformat by YAPF script --- examples/python/data_transmission/README.cn.md | 14 +++++++------- examples/python/data_transmission/README.en.md | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/python/data_transmission/README.cn.md b/examples/python/data_transmission/README.cn.md index c5cbb71c41d..812a8bbb7d6 100644 --- a/examples/python/data_transmission/README.cn.md +++ b/examples/python/data_transmission/README.cn.md @@ -6,7 +6,7 @@ 在一次调用中, 客户端只能向服务器传输一次请求数据, 服务器也只能返回一次响应 - `client.py - line:13 - simple_method` + `client.py - line:14 - simple_method` `server.py - line:17 - SimpleMethod` @@ -14,23 +14,23 @@ 在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应 - `clien.py - line:24 - client_streaming_method ` + `clien.py - line:27 - client_streaming_method ` - `server.py - line:25 - ClientStreamingMethod` + `server.py - line:28 - ClientStreamingMethod` - #### 服务端流模式 在一次调用中, 客户端只能向服务器传输一次请求数据, 但是服务器可以多次返回响应 - `clien.py - line:42 - server_streaming_method` + `clien.py - line:48 - server_streaming_method` - `server.py - line:35 - ServerStreamingMethod` + `server.py - line:41 - ServerStreamingMethod` - #### 双向流模式 在一次调用中, 客户端和服务器都可以向对方多次收发数据 - `client.py - line:55 - bidirectional_streaming_method` + `client.py - line:63 - bidirectional_streaming_method` - `server.py - line:51 - BidirectionalStreamingMethod` + `server.py - line:59 - BidirectionalStreamingMethod` diff --git a/examples/python/data_transmission/README.en.md b/examples/python/data_transmission/README.en.md index f87682f2038..fb834ab80c9 100644 --- a/examples/python/data_transmission/README.en.md +++ b/examples/python/data_transmission/README.en.md @@ -6,31 +6,31 @@ Four ways of data transmission when gRPC is used in Python. [Offical Guide]( Date: Tue, 27 Aug 2019 17:35:49 -0700 Subject: [PATCH 1412/1555] Added test for time jumps --- test/cpp/common/BUILD | 13 ++ test/cpp/common/time_jump_test.cc | 128 ++++++++++++++++++ .../internal_ci/macos/grpc_run_bazel_tests.sh | 13 +- 3 files changed, 145 insertions(+), 9 deletions(-) create mode 100644 test/cpp/common/time_jump_test.cc diff --git a/test/cpp/common/BUILD b/test/cpp/common/BUILD index f0d0e9a6223..c31eb10344e 100644 --- a/test/cpp/common/BUILD +++ b/test/cpp/common/BUILD @@ -42,6 +42,19 @@ grpc_cc_test( ], ) +grpc_cc_test( + name = "time_jump_test", + srcs = ["time_jump_test.cc"], + external_deps = [ + "gtest", + ], + tags = ["manual"], + deps = [ + "//:grpc++", + "//test/core/util:grpc_test_util", + ], +) + grpc_cc_test( name = "auth_property_iterator_test", srcs = ["auth_property_iterator_test.cc"], diff --git a/test/cpp/common/time_jump_test.cc b/test/cpp/common/time_jump_test.cc new file mode 100644 index 00000000000..86bf012f7c0 --- /dev/null +++ b/test/cpp/common/time_jump_test.cc @@ -0,0 +1,128 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "src/core/lib/gprpp/sync.h" +#include "src/core/lib/iomgr/closure.h" +#include "src/core/lib/iomgr/error.h" +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/timer.h" +#include "src/core/lib/iomgr/timer_manager.h" +#include "test/core/util/test_config.h" + +extern char** environ; + +void run_cmd(const char* cmd) { + pid_t pid; + const char* argv[] = {const_cast("sh"), + const_cast("-c"), cmd, nullptr}; + int status; + + status = posix_spawn(&pid, const_cast("/bin/sh"), nullptr, + nullptr, const_cast(argv), environ); + if (status == 0) { + if (waitpid(pid, &status, 0) == -1) { + perror("waitpid"); + } + } +} + +class TimeJumpTest : public ::testing::TestWithParam { + protected: + void SetUp() override { grpc_init(); } + void TearDown() override { + run_cmd("sudo sntp -sS pool.ntp.org"); + grpc_shutdown_blocking(); + } + + const int kWaitTimeMs = 1500; +}; + +std::vector CreateTestScenarios() { + return {"-1M", "+1M", "-1H", "+1H", "-1d", "+1d", "-1y", "+1y"}; +} +INSTANTIATE_TEST_CASE_P(TimeJump, TimeJumpTest, + ::testing::ValuesIn(CreateTestScenarios())); + +TEST_P(TimeJumpTest, TimerRunning) { + grpc_core::ExecCtx exec_ctx; + grpc_timer timer; + grpc_timer_init(&timer, grpc_core::ExecCtx::Get()->Now() + 3000, + GRPC_CLOSURE_CREATE( + [](void*, grpc_error* error) { + GPR_ASSERT(error == GRPC_ERROR_CANCELLED); + }, + nullptr, grpc_schedule_on_exec_ctx)); + gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(100)); + std::ostringstream cmd; + cmd << "sudo date `date -v" << GetParam() << " \"+%m%d%H%M%y\"`"; + run_cmd(cmd.str().c_str()); + gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(kWaitTimeMs)); + // We expect 1 wakeup/sec when there are not timer expiries + int64_t wakeups = grpc_timer_manager_get_wakeups_testonly(); + gpr_log(GPR_DEBUG, "wakeups: %" PRId64 "", wakeups); + GPR_ASSERT(wakeups <= 3); + grpc_timer_cancel(&timer); +} + +TEST_P(TimeJumpTest, TimedWait) { + grpc_core::CondVar cond; + grpc_core::Mutex mu; + { + grpc_core::MutexLock lock(&mu); + std::thread thd = std::thread([]() { + gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(100)); + std::ostringstream cmd; + cmd << "sudo date `date -v" << GetParam() << " \"+%m%d%H%M%y\"`"; + run_cmd(cmd.str().c_str()); + }); + gpr_timespec before = gpr_now(GPR_CLOCK_MONOTONIC); + int timedout = cond.Wait( + &mu, grpc_millis_to_timespec(kWaitTimeMs, GPR_CLOCK_REALTIME)); + gpr_timespec after = gpr_now(GPR_CLOCK_MONOTONIC); + int32_t elapsed_ms = gpr_time_to_millis(gpr_time_sub(after, before)); + gpr_log(GPR_DEBUG, "After wait, timedout = %d elapsed_ms = %d", timedout, + elapsed_ms); + GPR_ASSERT(1 == timedout); + GPR_ASSERT(1 == + gpr_time_similar(gpr_time_sub(after, before), + gpr_time_from_millis(kWaitTimeMs, GPR_TIMESPAN), + gpr_time_from_millis(10, GPR_TIMESPAN))); + + thd.join(); + } + // We expect 1 wakeup/sec when there are not timer expiries + int64_t wakeups = grpc_timer_manager_get_wakeups_testonly(); + gpr_log(GPR_DEBUG, "wakeups: %" PRId64 "", wakeups); + GPR_ASSERT(wakeups <= 3); +} + +int main(int argc, char** argv) { + grpc::testing::TestEnvironment env(argc, argv); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/tools/internal_ci/macos/grpc_run_bazel_tests.sh b/tools/internal_ci/macos/grpc_run_bazel_tests.sh index d3db59e9379..aaa2dc3f63c 100644 --- a/tools/internal_ci/macos/grpc_run_bazel_tests.sh +++ b/tools/internal_ci/macos/grpc_run_bazel_tests.sh @@ -18,18 +18,13 @@ set -ex # change to grpc repo root cd $(dirname $0)/../../.. -# Download bazel -temp_dir="$(mktemp -d)" -wget -q https://github.com/bazelbuild/bazel/releases/download/0.26.0/bazel-0.26.0-darwin-x86_64 -O "${temp_dir}/bazel" -chmod 755 "${temp_dir}/bazel" -export PATH="${temp_dir}:${PATH}" -# This should show ${temp_dir}/bazel -which bazel - ./tools/run_tests/start_port_server.py # run cfstream_test separately because it messes with the network -bazel test $RUN_TESTS_FLAGS --spawn_strategy=standalone --genrule_strategy=standalone --test_output=all //test/cpp/end2end:cfstream_test +tools/bazel test $RUN_TESTS_FLAGS --spawn_strategy=standalone --genrule_strategy=standalone --test_output=all //test/cpp/end2end:cfstream_test + +# run time_jump_test separately because it changes system time +tools/bazel test $RUN_TESTS_FLAGS --spawn_strategy=standalone --genrule_strategy=standalone --test_output=all //test/cpp/common:time_jump_test # kill port_server.py to prevent the build from hanging ps aux | grep port_server\\.py | awk '{print $2}' | xargs kill -9 From 65eb9c9ddb188bddaf5b2a1fa2f04812903b7337 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Fri, 30 Aug 2019 08:14:44 -0700 Subject: [PATCH 1413/1555] Revert "Test message size of 100MB" --- test/core/util/test_config.cc | 4 --- test/core/util/test_config.h | 3 -- test/cpp/end2end/async_end2end_test.cc | 38 ++++---------------------- 3 files changed, 6 insertions(+), 39 deletions(-) diff --git a/test/core/util/test_config.cc b/test/core/util/test_config.cc index 5033dc7b66a..5b248a01daa 100644 --- a/test/core/util/test_config.cc +++ b/test/core/util/test_config.cc @@ -342,10 +342,6 @@ bool BuiltUnderUbsan() { #endif } -bool grpc_test_built_under_tsan_or_msan() { - return BuiltUnderTsan() || BuiltUnderMsan(); -}; - int64_t grpc_test_sanitizer_slowdown_factor() { int64_t sanitizer_multiplier = 1; if (BuiltUnderValgrind()) { diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h index 905d61f1dd6..112af3176f9 100644 --- a/test/core/util/test_config.h +++ b/test/core/util/test_config.h @@ -24,9 +24,6 @@ extern int64_t g_fixture_slowdown_factor; extern int64_t g_poller_slowdown_factor; -/* Returns if the test is built under TSAN or MSAN. */ -bool grpc_test_built_under_tsan_or_msan(); - /* Returns an appropriate scaling factor for timeouts. */ int64_t grpc_test_slowdown_factor(); diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 879f16815ee..6ca0edf123e 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -34,7 +34,6 @@ #include "src/core/ext/filters/client_channel/backup_poller.h" #include "src/core/lib/gpr/tls.h" -#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/port.h" #include "src/proto/grpc/health/v1/health.grpc.pb.h" #include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" @@ -60,18 +59,6 @@ namespace testing { namespace { -const size_t MAX_TEST_MESSAGE_SIZE = -#if defined(GPR_APPLE) - // The test will time out with macos build. - GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH; -#else - // Don't test extreme size under tsan or msan, because it uses too much - // memory. - grpc_test_built_under_tsan_or_msan() - ? GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH - : GPR_MAX(100 * 1024 * 1024, GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH); -#endif - void* tag(int i) { return (void*)static_cast(i); } int detag(void* p) { return static_cast(reinterpret_cast(p)); } @@ -231,17 +218,6 @@ class ServerBuilderSyncPluginDisabler : public ::grpc::ServerBuilderOption { } }; -class ServerBuilderMaxRecvMessageSizeOption - : public ::grpc::ServerBuilderOption { - public: - void UpdateArguments(ChannelArguments* arg) override { - arg->SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, -1); - } - - void UpdatePlugins( - std::vector>* plugins) override {} -}; - class TestScenario { public: TestScenario(bool inproc_stub, const grpc::string& creds_type, bool hcs, @@ -314,9 +290,6 @@ class AsyncEnd2endTest : public ::testing::TestWithParam { std::unique_ptr sync_plugin_disabler( new ServerBuilderSyncPluginDisabler()); builder.SetOption(move(sync_plugin_disabler)); - std::unique_ptr max_recv_option( - new ServerBuilderMaxRecvMessageSizeOption()); - builder.SetOption(move(max_recv_option)); server_ = builder.BuildAndStart(); } @@ -324,7 +297,6 @@ class AsyncEnd2endTest : public ::testing::TestWithParam { ChannelArguments args; auto channel_creds = GetCredentialsProvider()->GetChannelCredentials( GetParam().credentials_type, &args); - args.SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, -1); std::shared_ptr channel = !(GetParam().inproc) ? ::grpc::CreateCustomChannel( server_address_.str(), channel_creds, args) @@ -1850,7 +1822,7 @@ TEST_P(AsyncEnd2endServerTryCancelTest, ServerBidiStreamingTryCancelAfter) { } std::vector CreateTestScenarios(bool test_secure, - bool test_big_message) { + bool test_message_size_limit) { std::vector scenarios; std::vector credentials_types; std::vector messages; @@ -1872,8 +1844,9 @@ std::vector CreateTestScenarios(bool test_secure, GPR_ASSERT(!credentials_types.empty()); messages.push_back("Hello"); - if (test_big_message) { - for (size_t k = 1; k < MAX_TEST_MESSAGE_SIZE / 1024; k *= 32) { + if (test_message_size_limit) { + for (size_t k = 1; k < GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH / 1024; + k *= 32) { grpc::string big_msg; for (size_t i = 0; i < k * 1024; ++i) { char c = 'a' + (i % 26); @@ -1881,7 +1854,8 @@ std::vector CreateTestScenarios(bool test_secure, } messages.push_back(big_msg); } - messages.push_back(grpc::string(MAX_TEST_MESSAGE_SIZE - 10, 'a')); + messages.push_back( + grpc::string(GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH - 10, 'a')); } // TODO (sreek) Renable tests with health check service after the issue From fa7bdff69f6de851e5b34f9bb112cee7618baa84 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 28 Aug 2019 16:32:00 -0700 Subject: [PATCH 1414/1555] Fix buffer-overflow in grpc_static_mdelem_for_static_strings --- src/core/lib/transport/static_metadata.cc | 7 +------ tools/codegen/core/gen_static_metadata.py | 3 +-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/core/lib/transport/static_metadata.cc b/src/core/lib/transport/static_metadata.cc index bd6ff09c80d..f412edb1efe 100644 --- a/src/core/lib/transport/static_metadata.cc +++ b/src/core/lib/transport/static_metadata.cc @@ -1217,12 +1217,7 @@ static const uint16_t elem_keys[] = { 9076, 9185, 9294, 9403, 9512, 9621, 6242, 9730, 9839, 9948, 10057, 10166, 1189, 538, 10275, 10384, 212, 10493, 1195, 1196, 1197, 1198, 1080, 10602, 1843, 11365, 0, 0, 0, 1734, 0, 1850, 0, - 0, 0, 356, 1627, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0}; + 0, 0, 356, 1627}; static const uint8_t elem_idxs[] = { 7, 8, 9, 10, 11, 12, 13, 76, 78, 71, 1, 2, 5, 6, 25, 3, 4, 66, 65, 30, 83, 62, 63, 67, 61, 73, 57, 37, 14, 19, 21, 22, diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py index 4ac8f9dada7..8560fa47657 100755 --- a/tools/codegen/core/gen_static_metadata.py +++ b/tools/codegen/core/gen_static_metadata.py @@ -627,7 +627,6 @@ def perfect_hash(keys, name): return x + p.r[y] return { - 'PHASHRANGE': p.t - 1 + max(p.r), 'PHASHNKEYS': len(p.slots), 'pyfunc': f, 'code': """ @@ -659,7 +658,7 @@ elem_keys = [ elem_hash = perfect_hash(elem_keys, 'elems') print >> C, elem_hash['code'] -keys = [0] * int(elem_hash['PHASHRANGE']) +keys = [0] * int(elem_hash['PHASHNKEYS']) idxs = [255] * int(elem_hash['PHASHNKEYS']) for i, k in enumerate(elem_keys): h = elem_hash['pyfunc'](k) From 2e1cb0d91a3c8c2d2e818d5ea0dfd806cb5f7440 Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Fri, 30 Aug 2019 11:36:46 -0700 Subject: [PATCH 1415/1555] Don't run time_jump_test under sanitizers --- test/cpp/common/time_jump_test.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/test/cpp/common/time_jump_test.cc b/test/cpp/common/time_jump_test.cc index 86bf012f7c0..ea6711dfce3 100644 --- a/test/cpp/common/time_jump_test.cc +++ b/test/cpp/common/time_jump_test.cc @@ -53,10 +53,20 @@ void run_cmd(const char* cmd) { class TimeJumpTest : public ::testing::TestWithParam { protected: - void SetUp() override { grpc_init(); } + void SetUp() override { + // Skip test if slowdown factor > 1 + if (grpc_test_slowdown_factor() != 1) { + GTEST_SKIP(); + } else { + grpc_init(); + } + } void TearDown() override { - run_cmd("sudo sntp -sS pool.ntp.org"); - grpc_shutdown_blocking(); + // Skip test if slowdown factor > 1 + if (grpc_test_slowdown_factor() == 1) { + run_cmd("sudo sntp -sS pool.ntp.org"); + grpc_shutdown_blocking(); + } } const int kWaitTimeMs = 1500; From b436758b14fa15200089ca42216f4a41fd0902ca Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Fri, 28 Jun 2019 17:11:02 -0700 Subject: [PATCH 1416/1555] Added documentation for C++ tests on iOS --- test/cpp/README-iOS.md | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 test/cpp/README-iOS.md diff --git a/test/cpp/README-iOS.md b/test/cpp/README-iOS.md new file mode 100644 index 00000000000..898931085b3 --- /dev/null +++ b/test/cpp/README-iOS.md @@ -0,0 +1,52 @@ +## C++ tests on iOS + +[GTMGoogleTestRunner](https://github.com/google/google-toolbox-for-mac/blob/master/UnitTesting/GTMGoogleTestRunner.mm) is used to convert googletest cases to XCTest that can be run on iOS. GTMGoogleTestRunner doesn't execute the `main` function, so we can't have any test logic in `main`. +However, it's ok to call `::testing::InitGoogleTest` in `main`, as `GTMGoogleTestRunner` [calls InitGoogleTest](https://github.com/google/google-toolbox-for-mac/blob/master/UnitTesting/GTMGoogleTestRunner.mm#L151). +`grpc::testing::TestEnvironment` can also be called from `main`, as it does some test initialization (install crash handler, seed RNG) that's not strictly required to run testcases on iOS. + + +## Porting exising C++ tests to run on iOS + +Please follow these guidelines when porting tests to run on iOS: + +- Tests need to use the googletest framework +- Any setup/teardown code in `main` needs to be moved to `SetUpTestCase`/`TearDownTestCase`, and `TEST` needs to be changed to `TEST_F`. +- [Death tests](https://github.com/google/googletest/blob/master/googletest/docs/advanced.md#death-tests) are not supported on iOS, so use the `*_IF_SUPPORTED()` macros to ensure that your code compiles on iOS. + +For example, the following test +```c++ +TEST(MyTest, TestOne) { + ASSERT_DEATH(ThisShouldDie(), ""); +} + +int main(int argc, char** argv) { + grpc::testing::TestEnvironment env(argc, argv); + ::testing::InitGoogleTest(&argc, argv); + grpc_init(); + return RUN_ALL_TESTS(); + grpc_shutdown(); +} +``` + +should be changed to +```c++ +class MyTest : public ::testing::Test { + protected: + static void SetUpTestCase() { grpc_init(); } + static void TearDownTestCase() { grpc_shutdown(); } +}; + +TEST_F(MyTest, TestOne) { + ASSERT_DEATH_IF_SUPPORTED(ThisShouldDie(), ""); +} + +int main(int argc, char** argv) { + grpc::testing::TestEnvironment env(argc, argv); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} +``` + +## Limitations + +Due to a [limitation](https://github.com/google/google-toolbox-for-mac/blob/master/UnitTesting/GTMGoogleTestRunner.mm#L48-L56) in GTMGoogleTestRunner, `SetUpTestCase`/`TeardownTestCase` will be called before/after *every* individual test case, similar to `SetUp`/`TearDown`. From 3c6bb96a1fbc07a59e4def4600e5e0249e98ab53 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 30 Aug 2019 12:12:26 -0700 Subject: [PATCH 1417/1555] Add test for static elements --- test/core/transport/BUILD | 14 ++++++ test/core/transport/static_metadata_test.cc | 51 +++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 test/core/transport/static_metadata_test.cc diff --git a/test/core/transport/BUILD b/test/core/transport/BUILD index f38ecf2f66b..44e4fcb978e 100644 --- a/test/core/transport/BUILD +++ b/test/core/transport/BUILD @@ -82,6 +82,20 @@ grpc_cc_test( ], ) +grpc_cc_test( + name = "static_metadata_test", + srcs = ["static_metadata_test.cc"], + external_deps = [ + "gtest", + ], + language = "C++", + deps = [ + "//:gpr", + "//:grpc", + "//test/core/util:grpc_test_util", + ], +) + grpc_cc_test( name = "status_conversion_test", srcs = ["status_conversion_test.cc"], diff --git a/test/core/transport/static_metadata_test.cc b/test/core/transport/static_metadata_test.cc new file mode 100644 index 00000000000..6d3d5ef5c37 --- /dev/null +++ b/test/core/transport/static_metadata_test.cc @@ -0,0 +1,51 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include + +#include "src/core/lib/transport/metadata.h" +#include "src/core/lib/transport/static_metadata.h" +#include "test/core/util/test_config.h" + +namespace grpc_core { +namespace { + +TEST(StaticMetadataTest, ReadAllStaticElements) { + // This makes sure that all static elements are returned when + // grpc_mdelem_from_slices is called with key pairs pregenerated. + for (int i = 0; i < GRPC_STATIC_MDELEM_COUNT; i++) { + const grpc_mdelem mdelem = grpc_static_mdelem_manifested()[i]; + const grpc_mdelem mdelem2 = + grpc_mdelem_from_slices(GRPC_MDKEY(mdelem), GRPC_MDVALUE(mdelem)); + EXPECT_EQ(mdelem.payload, mdelem2.payload); + } +} + +} // namespace +} // namespace grpc_core + +int main(int argc, char** argv) { + grpc_init(); + grpc::testing::TestEnvironment env(argc, argv); + ::testing::InitGoogleTest(&argc, argv); + int retval = RUN_ALL_TESTS(); + grpc_shutdown(); + return retval; +} From a96cbbd592af2f705402b28e3f0337cff54d7d27 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 28 Aug 2019 16:39:08 -0700 Subject: [PATCH 1418/1555] Fix ubsan on InternNewStringLocked --- src/core/lib/slice/slice_intern.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/lib/slice/slice_intern.cc b/src/core/lib/slice/slice_intern.cc index d813e5195ad..369135c9eac 100644 --- a/src/core/lib/slice/slice_intern.cc +++ b/src/core/lib/slice/slice_intern.cc @@ -208,7 +208,11 @@ static InternedSliceRefcount* InternNewStringLocked(slice_shard* shard, InternedSliceRefcount* s = static_cast(gpr_malloc(sizeof(*s) + len)); new (s) grpc_core::InternedSliceRefcount(len, hash, shard->strs[shard_idx]); - memcpy(reinterpret_cast(s + 1), buffer, len); + // TODO(arjunroy): Investigate why hpack tried to intern the nullptr string. + // https://github.com/grpc/grpc/pull/20110#issuecomment-526729282 + if (len > 0) { + memcpy(reinterpret_cast(s + 1), buffer, len); + } shard->strs[shard_idx] = s; shard->count++; if (shard->count > shard->capacity * 2) { From e6ffb2c3bb97046605de54d4a74516d728aa6ae4 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 30 Aug 2019 14:36:35 -0700 Subject: [PATCH 1419/1555] Replace direct closure callback calls with GRPC_CLOSURE_SCHED --- src/core/ext/transport/chttp2/server/chttp2_server.cc | 2 +- src/core/lib/iomgr/tcp_posix.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc index 5e9cd77d18a..c0ae64eb2cc 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -266,7 +266,7 @@ static void tcp_server_shutdown_complete(void* arg, grpc_error* error) { // may do a synchronous unref. grpc_core::ExecCtx::Get()->Flush(); if (destroy_done != nullptr) { - destroy_done->cb(destroy_done->cb_arg, GRPC_ERROR_REF(error)); + GRPC_CLOSURE_SCHED(destroy_done, GRPC_ERROR_REF(error)); grpc_core::ExecCtx::Get()->Flush(); } grpc_channel_args_destroy(state->args); diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index 498aecc069b..f0c591d1c6d 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -1020,7 +1020,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) { if (error != GRPC_ERROR_NONE) { cb = tcp->write_cb; tcp->write_cb = nullptr; - cb->cb(cb->cb_arg, error); + GRPC_CLOSURE_SCHED(cb, error); TCP_UNREF(tcp, "write"); return; } From 3476df0b5021b7517d8c756ffdffc771349e8964 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 30 Aug 2019 15:04:06 -0700 Subject: [PATCH 1420/1555] Add in ref to error --- src/core/lib/iomgr/tcp_posix.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index f0c591d1c6d..571c7d229f2 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -1020,7 +1020,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) { if (error != GRPC_ERROR_NONE) { cb = tcp->write_cb; tcp->write_cb = nullptr; - GRPC_CLOSURE_SCHED(cb, error); + GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_REF(error)); TCP_UNREF(tcp, "write"); return; } From 7315e75ce6c8cea17196f9c0f907187caa851437 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 30 Aug 2019 15:25:50 -0700 Subject: [PATCH 1421/1555] Add comments --- src/core/lib/iomgr/tcp_posix.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index 571c7d229f2..b6d1381298a 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -1030,6 +1030,8 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) { gpr_log(GPR_INFO, "write: delayed"); } notify_on_write(tcp); + // tcp_flush does not populate error if it has returned false. + GPR_DEBUG_ASSERT(error == GRPC_ERROR_NONE); } else { cb = tcp->write_cb; tcp->write_cb = nullptr; @@ -1037,6 +1039,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) { const char* str = grpc_error_string(error); gpr_log(GPR_INFO, "write: %s", str); } + // No need to take a ref on error since tcp_flush provides a ref. GRPC_CLOSURE_SCHED(cb, error); TCP_UNREF(tcp, "write"); } From d6498800441e68e22854ee7daf94cadb709ffac9 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Fri, 30 Aug 2019 16:39:02 -0700 Subject: [PATCH 1422/1555] Add strip_prefix to python protoc plugin and py_grpc_library --- bazel/python_rules.bzl | 11 +++++- examples/python/debug/get_stats.py | 9 ++--- src/compiler/generator_helpers.h | 9 ++--- src/compiler/python_generator.cc | 35 ++++++++++++++++--- .../grpc_channelz/v1/BUILD.bazel | 1 + .../grpc_channelz/v1/channelz.py | 9 ++--- .../grpc_health/v1/BUILD.bazel | 1 + .../grpc_health/v1/health.py | 9 ++--- .../grpc_reflection/v1alpha/BUILD.bazel | 1 + .../grpc_reflection/v1alpha/reflection.py | 11 ++---- .../tests/channelz/_channelz_servicer_test.py | 12 ++----- .../health_check/_health_servicer_test.py | 12 ++----- .../reflection/_reflection_servicer_test.py | 12 ++----- 13 files changed, 66 insertions(+), 66 deletions(-) diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index 12f51f8b172..0cdd2b9739c 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -93,11 +93,13 @@ def _generate_pb2_grpc_src_impl(context): proto_root = get_proto_root(context.label.workspace_root) out_files = declare_out_files(protos, context, _GENERATED_GRPC_PROTO_FORMAT) + plugin_flags = ["grpc_2_0"] + context.attr.strip_prefixes + arguments = [] tools = [context.executable._protoc, context.executable._plugin] arguments += get_plugin_args( context.executable._plugin, - [], + plugin_flags, context.genfiles_dir.path, False, ) @@ -127,6 +129,7 @@ _generate_pb2_grpc_src = rule( allow_empty = False, providers = [ProtoInfo], ), + "strip_prefixes": attr.string_list(), "_plugin": attr.label( executable = True, providers = ["files_to_run"], @@ -147,6 +150,7 @@ def py_grpc_library( name, srcs, deps, + strip_prefixes = [], **kwargs): """Generate python code for gRPC services defined in a protobuf. @@ -156,6 +160,10 @@ def py_grpc_library( schema of the service. deps: (List of `labels`) a single py_proto_library target for the proto_library in `srcs`. + strip_prefixes: (List of `strings`) If provided, this prefix will be + stripped from the beginning of foo_pb2 modules imported by the + generated stubs. This is useful in combination with the `imports` + attribute of the `py_library` rule. """ codegen_grpc_target = "_{}_grpc_codegen".format(name) if len(srcs) != 1: @@ -167,6 +175,7 @@ def py_grpc_library( _generate_pb2_grpc_src( name = codegen_grpc_target, deps = srcs, + strip_prefixes = strip_prefixes, **kwargs ) diff --git a/examples/python/debug/get_stats.py b/examples/python/debug/get_stats.py index 2da51d0efcf..d8cb08df55e 100644 --- a/examples/python/debug/get_stats.py +++ b/examples/python/debug/get_stats.py @@ -21,13 +21,8 @@ import logging import argparse import grpc -# TODO(https://github.com/grpc/grpc/issues/19863): Remove. -try: - from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2 - from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2_grpc -except ImportError: - from grpc_channelz.v1 import channelz_pb2 - from grpc_channelz.v1 import channelz_pb2_grpc +from grpc_channelz.v1 import channelz_pb2 +from grpc_channelz.v1 import channelz_pb2_grpc def run(addr): diff --git a/src/compiler/generator_helpers.h b/src/compiler/generator_helpers.h index 747096f0657..0f261fb5a83 100644 --- a/src/compiler/generator_helpers.h +++ b/src/compiler/generator_helpers.h @@ -168,10 +168,11 @@ inline MethodType GetMethodType( inline void Split(const grpc::string& s, char delim, std::vector* append_to) { - std::istringstream iss(s); - grpc::string piece; - while (std::getline(iss, piece)) { - append_to->push_back(piece); + auto current = s.begin(); + while (current <= s.end()) { + auto next = std::find(current, s.end(), delim); + append_to->emplace_back(current, next); + current = next + 1; } } diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc index 705aef1c884..7afb2c532e0 100644 --- a/src/compiler/python_generator.cc +++ b/src/compiler/python_generator.cc @@ -756,6 +756,28 @@ static bool GenerateGrpc(GeneratorContext* context, PrivateGenerator& generator, } } +static bool ParseParameters(const grpc::string& parameter, + grpc::string* grpc_version, + std::vector* strip_prefixes, + grpc::string* error) { + std::vector comma_delimited_parameters; + grpc_generator::Split(parameter, ',', &comma_delimited_parameters); + if (comma_delimited_parameters.empty()) { + *grpc_version = "grpc_2_0"; + } else if (comma_delimited_parameters.size() == 1) { + *grpc_version = comma_delimited_parameters[0]; + } else if (comma_delimited_parameters.size() == 2) { + *grpc_version = comma_delimited_parameters[0]; + std::copy(comma_delimited_parameters.begin() + 1, + comma_delimited_parameters.end(), + std::back_inserter(*strip_prefixes)); + } else { + *error = "--grpc_python_out received too many comma-delimited parameters."; + return false; + } + return true; +} + bool PythonGrpcGenerator::Generate(const FileDescriptor* file, const grpc::string& parameter, GeneratorContext* context, @@ -778,14 +800,19 @@ bool PythonGrpcGenerator::Generate(const FileDescriptor* file, generator_file_name = file->name(); ProtoBufFile pbfile(file); - PrivateGenerator generator(config_, &pbfile); - if (parameter == "" || parameter == "grpc_2_0") { + grpc::string grpc_version; + GeneratorConfiguration extended_config(config_); + bool success = ParseParameters(parameter, &grpc_version, + &(extended_config.prefixes_to_filter), error); + PrivateGenerator generator(extended_config, &pbfile); + if (!success) return false; + if (grpc_version == "grpc_2_0") { return GenerateGrpc(context, generator, pb2_grpc_file_name, true); - } else if (parameter == "grpc_1_0") { + } else if (grpc_version == "grpc_1_0") { return GenerateGrpc(context, generator, pb2_grpc_file_name, true) && GenerateGrpc(context, generator, pb2_file_name, false); } else { - *error = "Invalid parameter '" + parameter + "'."; + *error = "Invalid grpc version '" + grpc_version + "'."; return false; } } diff --git a/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel b/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel index 5f4e512e9f4..c034297ff2d 100644 --- a/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel +++ b/src/python/grpcio_channelz/grpc_channelz/v1/BUILD.bazel @@ -10,6 +10,7 @@ py_grpc_library( name = "channelz_py_pb2_grpc", srcs = ["//src/proto/grpc/channelz:channelz_proto_descriptors"], deps = [":channelz_py_pb2"], + strip_prefixes = ["src.python.grpcio_channelz."], ) py_library( diff --git a/src/python/grpcio_channelz/grpc_channelz/v1/channelz.py b/src/python/grpcio_channelz/grpc_channelz/v1/channelz.py index 965797f89ec..00eca311dc1 100644 --- a/src/python/grpcio_channelz/grpc_channelz/v1/channelz.py +++ b/src/python/grpcio_channelz/grpc_channelz/v1/channelz.py @@ -16,13 +16,8 @@ import grpc from grpc._cython import cygrpc -# TODO(https://github.com/grpc/grpc/issues/19863): Remove. -try: - from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2 as _channelz_pb2 - from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2_grpc as _channelz_pb2_grpc -except ImportError: - import grpc_channelz.v1.channelz_pb2 as _channelz_pb2 - import grpc_channelz.v1.channelz_pb2_grpc as _channelz_pb2_grpc +import grpc_channelz.v1.channelz_pb2 as _channelz_pb2 +import grpc_channelz.v1.channelz_pb2_grpc as _channelz_pb2_grpc from google.protobuf import json_format diff --git a/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel b/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel index 62a44df7707..a3e2c7dfe3d 100644 --- a/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel +++ b/src/python/grpcio_health_checking/grpc_health/v1/BUILD.bazel @@ -10,6 +10,7 @@ py_grpc_library( name = "health_py_pb2_grpc", srcs = ["//src/proto/grpc/health/v1:health_proto_descriptor",], deps = [":health_py_pb2"], + strip_prefixes = ["src.python.grpcio_health_checking."], ) py_library( diff --git a/src/python/grpcio_health_checking/grpc_health/v1/health.py b/src/python/grpcio_health_checking/grpc_health/v1/health.py index a0d55570990..15494fafdbc 100644 --- a/src/python/grpcio_health_checking/grpc_health/v1/health.py +++ b/src/python/grpcio_health_checking/grpc_health/v1/health.py @@ -18,13 +18,8 @@ import threading import grpc -# TODO(https://github.com/grpc/grpc/issues/19863): Remove. -try: - from src.python.grpcio_health_checking.grpc_health.v1 import health_pb2 as _health_pb2 - from src.python.grpcio_health_checking.grpc_health.v1 import health_pb2_grpc as _health_pb2_grpc -except ImportError: - from grpc_health.v1 import health_pb2 as _health_pb2 - from grpc_health.v1 import health_pb2_grpc as _health_pb2_grpc +from grpc_health.v1 import health_pb2 as _health_pb2 +from grpc_health.v1 import health_pb2_grpc as _health_pb2_grpc SERVICE_NAME = _health_pb2.DESCRIPTOR.services_by_name['Health'].full_name diff --git a/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel b/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel index 10077fd9568..bad54d06c63 100644 --- a/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel +++ b/src/python/grpcio_reflection/grpc_reflection/v1alpha/BUILD.bazel @@ -12,6 +12,7 @@ py_grpc_library( name = "reflection_py_pb2_grpc", srcs = ["//src/proto/grpc/reflection/v1alpha:reflection_proto_descriptor",], deps = ["reflection_py_pb2"], + strip_prefixes = ["src.python.grpcio_reflection."], ) py_library( diff --git a/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py b/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py index 61153d9d625..6df1a364269 100644 --- a/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py +++ b/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py @@ -17,15 +17,8 @@ import grpc from google.protobuf import descriptor_pb2 from google.protobuf import descriptor_pool -# TODO(https://github.com/grpc/grpc/issues/19863): Remove. -try: - from src.python.grpcio_reflection.grpc_reflection.v1alpha \ - import reflection_pb2 as _reflection_pb2 - from src.python.grpcio_reflection.grpc_reflection.v1alpha \ - import reflection_pb2_grpc as _reflection_pb2_grpc -except ImportError: - from grpc_reflection.v1alpha import reflection_pb2 as _reflection_pb2 - from grpc_reflection.v1alpha import reflection_pb2_grpc as _reflection_pb2_grpc +from grpc_reflection.v1alpha import reflection_pb2 as _reflection_pb2 +from grpc_reflection.v1alpha import reflection_pb2_grpc as _reflection_pb2_grpc _POOL = descriptor_pool.Default() SERVICE_NAME = _reflection_pb2.DESCRIPTOR.services_by_name[ diff --git a/src/python/grpcio_tests/tests/channelz/_channelz_servicer_test.py b/src/python/grpcio_tests/tests/channelz/_channelz_servicer_test.py index f2357a4e4a3..48d25e99e35 100644 --- a/src/python/grpcio_tests/tests/channelz/_channelz_servicer_test.py +++ b/src/python/grpcio_tests/tests/channelz/_channelz_servicer_test.py @@ -19,15 +19,9 @@ from concurrent import futures import grpc -# TODO(https://github.com/grpc/grpc/issues/19863): Remove. -try: - from src.python.grpcio_channelz.grpc_channelz.v1 import channelz - from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2 - from src.python.grpcio_channelz.grpc_channelz.v1 import channelz_pb2_grpc -except ImportError: - from grpc_channelz.v1 import channelz - from grpc_channelz.v1 import channelz_pb2 - from grpc_channelz.v1 import channelz_pb2_grpc +from grpc_channelz.v1 import channelz +from grpc_channelz.v1 import channelz_pb2 +from grpc_channelz.v1 import channelz_pb2_grpc from tests.unit import test_common from tests.unit.framework.common import test_constants diff --git a/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py b/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py index 428806c71b0..8faffb448c3 100644 --- a/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py +++ b/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py @@ -20,15 +20,9 @@ import unittest import grpc -# TODO(https://github.com/grpc/grpc/issues/19863): Remove. -try: - from src.python.grpcio_health_checking.grpc_health.v1 import health - from src.python.grpcio_health_checking.grpc_health.v1 import health_pb2 - from src.python.grpcio_health_checking.grpc_health.v1 import health_pb2_grpc -except ImportError: - from grpc_health.v1 import health - from grpc_health.v1 import health_pb2 - from grpc_health.v1 import health_pb2_grpc +from grpc_health.v1 import health +from grpc_health.v1 import health_pb2 +from grpc_health.v1 import health_pb2_grpc from tests.unit import test_common from tests.unit import thread_pool diff --git a/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py b/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py index e45f98abec6..169e55022da 100644 --- a/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py +++ b/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py @@ -17,15 +17,9 @@ import unittest import grpc -# TODO(https://github.com/grpc/grpc/issues/19863): Remove. -try: - from src.python.grpcio_reflection.grpc_reflection.v1alpha import reflection - from src.python.grpcio_reflection.grpc_reflection.v1alpha import reflection_pb2 - from src.python.grpcio_reflection.grpc_reflection.v1alpha import reflection_pb2_grpc -except ImportError: - from grpc_reflection.v1alpha import reflection - from grpc_reflection.v1alpha import reflection_pb2 - from grpc_reflection.v1alpha import reflection_pb2_grpc +from grpc_reflection.v1alpha import reflection +from grpc_reflection.v1alpha import reflection_pb2 +from grpc_reflection.v1alpha import reflection_pb2_grpc from google.protobuf import descriptor_pool from google.protobuf import descriptor_pb2 From 358676db444d84db7412c695101c6b2f0e9774fd Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Fri, 30 Aug 2019 17:53:41 -0700 Subject: [PATCH 1423/1555] Alright. We'll do our own thing then --- src/compiler/generator_helpers.h | 9 ++++----- src/compiler/python_generator.cc | 2 +- src/compiler/python_generator_helpers.h | 10 ++++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/compiler/generator_helpers.h b/src/compiler/generator_helpers.h index 0f261fb5a83..747096f0657 100644 --- a/src/compiler/generator_helpers.h +++ b/src/compiler/generator_helpers.h @@ -168,11 +168,10 @@ inline MethodType GetMethodType( inline void Split(const grpc::string& s, char delim, std::vector* append_to) { - auto current = s.begin(); - while (current <= s.end()) { - auto next = std::find(current, s.end(), delim); - append_to->emplace_back(current, next); - current = next + 1; + std::istringstream iss(s); + grpc::string piece; + while (std::getline(iss, piece)) { + append_to->push_back(piece); } } diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc index 7afb2c532e0..0e76c95aed4 100644 --- a/src/compiler/python_generator.cc +++ b/src/compiler/python_generator.cc @@ -761,7 +761,7 @@ static bool ParseParameters(const grpc::string& parameter, std::vector* strip_prefixes, grpc::string* error) { std::vector comma_delimited_parameters; - grpc_generator::Split(parameter, ',', &comma_delimited_parameters); + grpc_python_generator::Split(parameter, ',', &comma_delimited_parameters); if (comma_delimited_parameters.empty()) { *grpc_version = "grpc_2_0"; } else if (comma_delimited_parameters.size() == 1) { diff --git a/src/compiler/python_generator_helpers.h b/src/compiler/python_generator_helpers.h index 171dd730a24..862292db475 100644 --- a/src/compiler/python_generator_helpers.h +++ b/src/compiler/python_generator_helpers.h @@ -136,6 +136,16 @@ StringVector get_all_comments(const DescriptorType* descriptor) { return comments; } +inline void Split(const grpc::string& s, char delim, + std::vector* append_to) { + auto current = s.begin(); + while (current <= s.end()) { + auto next = std::find(current, s.end(), delim); + append_to->emplace_back(current, next); + current = next + 1; + } +} + } // namespace } // namespace grpc_python_generator From e6fe85bc2ddb12bf2960fd27dc6f90a0e29d3ec5 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Fri, 30 Aug 2019 18:20:49 -0700 Subject: [PATCH 1424/1555] Properly handle default case --- src/compiler/python_generator.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc index 0e76c95aed4..f553d9e7a3c 100644 --- a/src/compiler/python_generator.cc +++ b/src/compiler/python_generator.cc @@ -762,7 +762,8 @@ static bool ParseParameters(const grpc::string& parameter, grpc::string* error) { std::vector comma_delimited_parameters; grpc_python_generator::Split(parameter, ',', &comma_delimited_parameters); - if (comma_delimited_parameters.empty()) { + if (comma_delimited_parameters.size() == 1 && + comma_delimited_parameters.empty()) { *grpc_version = "grpc_2_0"; } else if (comma_delimited_parameters.size() == 1) { *grpc_version = comma_delimited_parameters[0]; From e5e2b79c01cec333257ea5ec011128348e6d2a88 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Sat, 31 Aug 2019 22:10:33 -0700 Subject: [PATCH 1425/1555] GRPCTransportId -> GRPCTransportID --- src/objective-c/GRPCClient/GRPCCall+Cronet.h | 2 +- src/objective-c/GRPCClient/GRPCCall+Cronet.m | 2 +- src/objective-c/GRPCClient/GRPCCallOptions.h | 4 ++-- src/objective-c/GRPCClient/GRPCCallOptions.m | 8 ++++---- src/objective-c/GRPCClient/GRPCInterceptor.h | 2 +- src/objective-c/GRPCClient/GRPCInterceptor.m | 4 ++-- src/objective-c/GRPCClient/GRPCTransport.h | 10 +++++----- src/objective-c/GRPCClient/GRPCTransport.m | 14 +++++++------- src/objective-c/GRPCClient/GRPCTypes.h | 2 +- .../GRPCClient/private/GRPCTransport+Private.h | 4 ++-- .../GRPCClient/private/GRPCTransport+Private.m | 4 ++-- .../CronetTests/InteropTestsRemoteWithCronet.m | 2 +- src/objective-c/tests/InteropTests/InteropTests.h | 2 +- src/objective-c/tests/InteropTests/InteropTests.m | 2 +- .../InteropTests/InteropTestsLocalCleartext.m | 2 +- .../tests/InteropTests/InteropTestsLocalSSL.m | 2 +- 16 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall+Cronet.h b/src/objective-c/GRPCClient/GRPCCall+Cronet.h index d107ada3672..10cea963631 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Cronet.h +++ b/src/objective-c/GRPCClient/GRPCCall+Cronet.h @@ -22,7 +22,7 @@ typedef struct stream_engine stream_engine; // Transport id for Cronet transport -extern const GRPCTransportId gGRPCCoreCronetId; +extern const GRPCTransportID gGRPCCoreCronetId; // Deprecated class. Please use the gGRPCCoreCronetId with GRPCCallOptions.transport instead. @interface GRPCCall (Cronet) diff --git a/src/objective-c/GRPCClient/GRPCCall+Cronet.m b/src/objective-c/GRPCClient/GRPCCall+Cronet.m index a732208e1f6..33b09136b33 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Cronet.m +++ b/src/objective-c/GRPCClient/GRPCCall+Cronet.m @@ -18,7 +18,7 @@ #import "GRPCCall+Cronet.h" -const GRPCTransportId gGRPCCoreCronetId = "io.grpc.transport.core.cronet"; +const GRPCTransportID gGRPCCoreCronetId = "io.grpc.transport.core.cronet"; static BOOL useCronet = NO; static stream_engine *globalCronetEngine; diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.h b/src/objective-c/GRPCClient/GRPCCallOptions.h index e4261b5b5f9..adb4ecad48e 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.h +++ b/src/objective-c/GRPCClient/GRPCCallOptions.h @@ -161,7 +161,7 @@ NS_ASSUME_NONNULL_BEGIN * * This is currently an experimental option. */ -@property(readonly) GRPCTransportId transport; +@property(readonly) GRPCTransportID transport; /** * Override the hostname during the TLS hostname validation process. @@ -339,7 +339,7 @@ NS_ASSUME_NONNULL_BEGIN * * An interceptor must not change the value of this option. */ -@property(readwrite) GRPCTransportId transport; +@property(readwrite) GRPCTransportID transport; /** * Override the hostname during the TLS hostname validation process. diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.m b/src/objective-c/GRPCClient/GRPCCallOptions.m index 7f88098eb6f..f9044ddcd34 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.m +++ b/src/objective-c/GRPCClient/GRPCCallOptions.m @@ -42,7 +42,7 @@ static NSString *const kDefaultPEMCertificateChain = nil; static NSString *const kDefaultOauth2AccessToken = nil; static const id kDefaultAuthTokenProvider = nil; static const GRPCTransportType kDefaultTransportType = GRPCTransportTypeChttp2BoringSSL; -static const GRPCTransportId kDefaultTransport = NULL; +static const GRPCTransportID kDefaultTransport = NULL; static NSString *const kDefaultHostNameOverride = nil; static const id kDefaultLogContext = nil; static NSString *const kDefaultChannelPoolDomain = nil; @@ -82,7 +82,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { NSString *_PEMPrivateKey; NSString *_PEMCertificateChain; GRPCTransportType _transportType; - GRPCTransportId _transport; + GRPCTransportID _transport; NSString *_hostNameOverride; id _logContext; NSString *_channelPoolDomain; @@ -166,7 +166,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { PEMPrivateKey:(NSString *)PEMPrivateKey PEMCertificateChain:(NSString *)PEMCertificateChain transportType:(GRPCTransportType)transportType - transport:(GRPCTransportId)transport + transport:(GRPCTransportID)transport hostNameOverride:(NSString *)hostNameOverride logContext:(id)logContext channelPoolDomain:(NSString *)channelPoolDomain @@ -553,7 +553,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { _transportType = transportType; } -- (void)setTransport:(GRPCTransportId)transport { +- (void)setTransport:(GRPCTransportID)transport { _transport = transport; } diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.h b/src/objective-c/GRPCClient/GRPCInterceptor.h index 509749769b3..1794ef4b892 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.h +++ b/src/objective-c/GRPCClient/GRPCInterceptor.h @@ -177,7 +177,7 @@ NS_ASSUME_NONNULL_BEGIN - (nullable instancetype)initWithFactories:(nullable NSArray> *)factories previousInterceptor:(nullable id)previousInterceptor - transportId:(GRPCTransportId)transportId; + transportId:(GRPCTransportID)transportId; /** * Notify the manager that the interceptor has shut down and the manager should release references diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.m b/src/objective-c/GRPCClient/GRPCInterceptor.m index a7ffe05bddc..abada5a80c1 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.m +++ b/src/objective-c/GRPCClient/GRPCInterceptor.m @@ -31,13 +31,13 @@ GRPCInterceptor *_thisInterceptor; dispatch_queue_t _dispatchQueue; NSArray> *_factories; - GRPCTransportId _transportId; + GRPCTransportID _transportId; BOOL _shutDown; } - (instancetype)initWithFactories:(NSArray> *)factories previousInterceptor:(id)previousInterceptor - transportId:(nonnull GRPCTransportId)transportId { + transportId:(nonnull GRPCTransportID)transportId { if ((self = [super init])) { if (factories.count == 0) { [NSException raise:NSInternalInconsistencyException diff --git a/src/objective-c/GRPCClient/GRPCTransport.h b/src/objective-c/GRPCClient/GRPCTransport.h index d5637922152..d9f341d08a3 100644 --- a/src/objective-c/GRPCClient/GRPCTransport.h +++ b/src/objective-c/GRPCClient/GRPCTransport.h @@ -29,15 +29,15 @@ NS_ASSUME_NONNULL_BEGIN * by gRPC by default unless explicitly excluded. */ extern const struct GRPCDefaultTransportImplList { - const GRPCTransportId core_secure; - const GRPCTransportId core_insecure; + const GRPCTransportID core_secure; + const GRPCTransportID core_insecure; } GRPCDefaultTransportImplList; /** Returns whether two transport id's are identical. */ -BOOL TransportIdIsEqual(GRPCTransportId lhs, GRPCTransportId rhs); +BOOL TransportIdIsEqual(GRPCTransportID lhs, GRPCTransportID rhs); /** Returns the hash value of a transport id. */ -NSUInteger TransportIdHash(GRPCTransportId); +NSUInteger TransportIdHash(GRPCTransportID); #pragma mark Transport and factory @@ -66,7 +66,7 @@ NSUInteger TransportIdHash(GRPCTransportId); * Parameter \a transportId is the identifier of the implementation, and \a factory is the factory * object to create the corresponding transport instance. */ -- (void)registerTransportWithId:(GRPCTransportId)transportId +- (void)registerTransportWithId:(GRPCTransportID)transportId factory:(id)factory; @end diff --git a/src/objective-c/GRPCClient/GRPCTransport.m b/src/objective-c/GRPCClient/GRPCTransport.m index 439acfb9cc2..966dc50d64d 100644 --- a/src/objective-c/GRPCClient/GRPCTransport.m +++ b/src/objective-c/GRPCClient/GRPCTransport.m @@ -18,24 +18,24 @@ #import "GRPCTransport.h" -static const GRPCTransportId gGRPCCoreSecureId = "io.grpc.transport.core.secure"; -static const GRPCTransportId gGRPCCoreInsecureId = "io.grpc.transport.core.insecure"; +static const GRPCTransportID gGRPCCoreSecureId = "io.grpc.transport.core.secure"; +static const GRPCTransportID gGRPCCoreInsecureId = "io.grpc.transport.core.insecure"; const struct GRPCDefaultTransportImplList GRPCDefaultTransportImplList = { .core_secure = gGRPCCoreSecureId, .core_insecure = gGRPCCoreInsecureId}; -static const GRPCTransportId gDefaultTransportId = gGRPCCoreSecureId; +static const GRPCTransportID gDefaultTransportId = gGRPCCoreSecureId; static GRPCTransportRegistry *gTransportRegistry = nil; static dispatch_once_t initTransportRegistry; -BOOL TransportIdIsEqual(GRPCTransportId lhs, GRPCTransportId rhs) { +BOOL TransportIdIsEqual(GRPCTransportID lhs, GRPCTransportID rhs) { // Directly comparing pointers works because we require users to use the id provided by each // implementation, not coming up with their own string. return lhs == rhs; } -NSUInteger TransportIdHash(GRPCTransportId transportId) { +NSUInteger TransportIdHash(GRPCTransportID transportId) { if (transportId == NULL) { transportId = gDefaultTransportId; } @@ -66,7 +66,7 @@ NSUInteger TransportIdHash(GRPCTransportId transportId) { return self; } -- (void)registerTransportWithId:(GRPCTransportId)transportId +- (void)registerTransportWithId:(GRPCTransportID)transportId factory:(id)factory { NSString *nsTransportId = [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding]; NSAssert(_registry[nsTransportId] == nil, @"The transport %@ has already been registered.", @@ -83,7 +83,7 @@ NSUInteger TransportIdHash(GRPCTransportId transportId) { } } -- (id)getTransportFactoryWithId:(GRPCTransportId)transportId { +- (id)getTransportFactoryWithId:(GRPCTransportID)transportId { if (transportId == NULL) { if (_defaultFactory == nil) { [NSException raise:NSInvalidArgumentException diff --git a/src/objective-c/GRPCClient/GRPCTypes.h b/src/objective-c/GRPCClient/GRPCTypes.h index c804bca4eaa..8d434851aa6 100644 --- a/src/objective-c/GRPCClient/GRPCTypes.h +++ b/src/objective-c/GRPCClient/GRPCTypes.h @@ -171,7 +171,7 @@ extern NSString* _Nonnull const kGRPCHeadersKey; extern NSString* _Nonnull const kGRPCTrailersKey; /** The id of a transport implementation. */ -typedef char* _Nonnull GRPCTransportId; +typedef char* _Nonnull GRPCTransportID; /** * Implement this protocol to provide a token to gRPC when a call is initiated. diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h index 2dc7357c363..075d185e5d7 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h @@ -31,13 +31,13 @@ NS_ASSUME_NONNULL_BEGIN * registered with the registry, the default transport factory (core + secure) is returned. If the * default transport does not exist, an exception is thrown. */ -- (id)getTransportFactoryWithId:(GRPCTransportId)transportId; +- (id)getTransportFactoryWithId:(GRPCTransportID)transportId; @end @interface GRPCTransportManager : NSObject -- (instancetype)initWithTransportId:(GRPCTransportId)transportId +- (instancetype)initWithTransportId:(GRPCTransportID)transportId previousInterceptor:(id)previousInterceptor; /** diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m index 9072f7afbe2..5e9c2b52ab4 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m @@ -21,13 +21,13 @@ #import @implementation GRPCTransportManager { - GRPCTransportId _transportId; + GRPCTransportID _transportId; GRPCTransport *_transport; id _previousInterceptor; dispatch_queue_t _dispatchQueue; } -- (instancetype)initWithTransportId:(GRPCTransportId)transportId +- (instancetype)initWithTransportId:(GRPCTransportID)transportId previousInterceptor:(id)previousInterceptor { if ((self = [super init])) { id factory = diff --git a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m index aa1af301b96..f4cd9e064d2 100644 --- a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m +++ b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m @@ -52,7 +52,7 @@ static int32_t kRemoteInteropServerOverhead = 12; return kRemoteSSLHost; } -+ (GRPCTransportId)transport { ++ (GRPCTransportID)transport { return gGRPCCoreCronetId; } diff --git a/src/objective-c/tests/InteropTests/InteropTests.h b/src/objective-c/tests/InteropTests/InteropTests.h index a4adecd5415..4ebce5c961d 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.h +++ b/src/objective-c/tests/InteropTests/InteropTests.h @@ -59,7 +59,7 @@ * The transport to be used. The base implementation returns NULL. Subclasses should override to * appropriate settings. */ -+ (GRPCTransportId)transport; ++ (GRPCTransportID)transport; /** * The root certificates to be used. The base implementation returns nil. Subclasses should override diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 21198f7bad9..0c7ef44e0fa 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -404,7 +404,7 @@ static dispatch_once_t initGlobalInterceptorFactory; return GRPCTransportTypeChttp2BoringSSL; } -+ (GRPCTransportId)transport { ++ (GRPCTransportID)transport { return NULL; } diff --git a/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m b/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m index 2e638099e1e..23f39401230 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m +++ b/src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m @@ -61,7 +61,7 @@ static int32_t kLocalInteropServerOverhead = 10; [GRPCCall useInsecureConnectionsForHost:kLocalCleartextHost]; } -+ (GRPCTransportId)transport { ++ (GRPCTransportID)transport { return GRPCDefaultTransportImplList.core_insecure; } diff --git a/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m b/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m index 30d8f4c34af..9c8ce7fe810 100644 --- a/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m +++ b/src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m @@ -57,7 +57,7 @@ static int32_t kLocalInteropServerOverhead = 10; return kLocalInteropServerOverhead; // bytes } -+ (GRPCTransportId)transport { ++ (GRPCTransportID)transport { return GRPCDefaultTransportImplList.core_secure; } From 8274502af8142a4581a199d94f451e1efe8c1c91 Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Sun, 1 Sep 2019 23:01:30 -0700 Subject: [PATCH 1426/1555] Windows's STACKFRAME Frame Addr should be RBP, the base pointer, not RSP, the stack pointer. This is documented here: https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/ns-dbghelp-stackframe with the comment "AddrFrame x64: The frame pointer is RBP or RDI." Note that this is also what StackWalker uses: https://github.com/JochenKalmbach/StackWalker#initializing-the-stackframe64 and what Chromium uses: https://codesearch.chromium.org/chromium/src/v8/src/base/debug/stack_trace_win.cc?l=200&rcl=69d20d247f62a3378d15ce0956ed8bf9665e6a44 release notes: no --- test/core/util/test_config.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/util/test_config.cc b/test/core/util/test_config.cc index 5033dc7b66a..2216328dc08 100644 --- a/test/core/util/test_config.cc +++ b/test/core/util/test_config.cc @@ -114,7 +114,7 @@ static void print_stack_from_context(CONTEXT c) { imageType = IMAGE_FILE_MACHINE_AMD64; s.AddrPC.Offset = c.Rip; s.AddrPC.Mode = AddrModeFlat; - s.AddrFrame.Offset = c.Rsp; + s.AddrFrame.Offset = c.Rbp; s.AddrFrame.Mode = AddrModeFlat; s.AddrStack.Offset = c.Rsp; s.AddrStack.Mode = AddrModeFlat; From 7b2c253530c9675148e552d2761a0a8f28daed60 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 2 Sep 2019 10:57:36 -0400 Subject: [PATCH 1427/1555] Revert "only generate full or lite client, never both" This reverts commit 1b8418b5460a63c331288cd475db7198cb2c494a. --- src/compiler/csharp_generator.cc | 56 +++++++++++++++++--------------- src/compiler/csharp_generator.h | 4 +-- src/compiler/csharp_plugin.cc | 12 +++---- 3 files changed, 37 insertions(+), 35 deletions(-) diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc index d7ba4f2636a..7f178f63bb0 100644 --- a/src/compiler/csharp_generator.cc +++ b/src/compiler/csharp_generator.cc @@ -176,8 +176,9 @@ std::string GetServiceClassName(const ServiceDescriptor* service) { return service->name(); } -std::string GetClientClassName(const ServiceDescriptor* service) { - return service->name() + "Client"; +std::string GetClientClassName(const ServiceDescriptor* service, + bool lite_client) { + return service->name() + (lite_client ? "LiteClient" : "Client"); } std::string GetServerClassName(const ServiceDescriptor* service) { @@ -420,28 +421,26 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor* service, out->Print("/// Client for $servicename$\n", "servicename", GetServiceClassName(service)); out->Print("public partial class $name$ : grpc::ClientBase<$name$>\n", - "name", GetClientClassName(service)); + "name", GetClientClassName(service, lite_client)); } else { out->Print("/// Lite client for $servicename$\n", "servicename", GetServiceClassName(service)); out->Print("public partial class $name$ : grpc::LiteClientBase\n", "name", - GetClientClassName(service)); + GetClientClassName(service, lite_client)); } out->Print("{\n"); out->Indent(); // constructors - if (!lite_client) { - out->Print( - "/// Creates a new client for $servicename$\n" - "/// The channel to use to make remote " - "calls.\n", - "servicename", GetServiceClassName(service)); - out->Print("public $name$(grpc::ChannelBase channel) : base(channel)\n", - "name", GetClientClassName(service)); - out->Print("{\n"); - out->Print("}\n"); - } + out->Print( + "/// Creates a new client for $servicename$\n" + "/// The channel to use to make remote " + "calls.\n", + "servicename", GetServiceClassName(service)); + out->Print("public $name$(grpc::ChannelBase channel) : base(channel)\n", + "name", GetClientClassName(service)); + out->Print("{\n"); + out->Print("}\n"); out->Print( "/// Creates a new client for $servicename$ that uses a custom " "CallInvoker.\n" @@ -450,14 +449,14 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor* service, "servicename", GetServiceClassName(service)); out->Print( "public $name$(grpc::CallInvoker callInvoker) : base(callInvoker)\n", - "name", GetClientClassName(service)); + "name", GetClientClassName(service, lite_client)); out->Print("{\n"); out->Print("}\n"); out->Print( "/// Protected parameterless constructor to allow creation" " of test doubles.\n"); out->Print("protected $name$() : base()\n", "name", - GetClientClassName(service)); + GetClientClassName(service, lite_client)); out->Print("{\n"); out->Print("}\n"); if (!lite_client) { @@ -469,7 +468,7 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor* service, out->Print( "protected $name$(ClientBaseConfiguration configuration)" " : base(configuration)\n", - "name", GetClientClassName(service)); + "name", GetClientClassName(service, lite_client)); out->Print("{\n"); out->Print("}\n"); } @@ -598,11 +597,11 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor* service, out->Print( "protected override $name$ NewInstance(ClientBaseConfiguration " "configuration)\n", - "name", GetClientClassName(service)); + "name", GetClientClassName(service, lite_client)); out->Print("{\n"); out->Indent(); out->Print("return new $name$(configuration);\n", "name", - GetClientClassName(service)); + GetClientClassName(service, lite_client)); out->Outdent(); out->Print("}\n"); } @@ -686,8 +685,8 @@ void GenerateBindServiceWithBinderMethod(Printer* out, } void GenerateService(Printer* out, const ServiceDescriptor* service, - bool generate_client, bool generate_server, - bool internal_access, bool lite_client) { + bool generate_client, bool generate_lite_client, + bool generate_server, bool internal_access) { GenerateDocCommentBody(out, service); out->Print("$access_level$ static partial class $classname$\n", "access_level", GetAccessLevel(internal_access), "classname", @@ -709,7 +708,10 @@ void GenerateService(Printer* out, const ServiceDescriptor* service, GenerateServerClass(out, service); } if (generate_client) { - GenerateClientStub(out, service, lite_client); + GenerateClientStub(out, service, false); + } + if (generate_lite_client) { + GenerateClientStub(out, service, true); } if (generate_server) { @@ -724,8 +726,8 @@ void GenerateService(Printer* out, const ServiceDescriptor* service, } // anonymous namespace grpc::string GetServices(const FileDescriptor* file, bool generate_client, - bool generate_server, bool internal_access, - bool lite_client) { + bool generate_lite_client, bool generate_server, + bool internal_access) { grpc::string output; { // Scope the output stream so it closes and finalizes output to the string. @@ -766,8 +768,8 @@ grpc::string GetServices(const FileDescriptor* file, bool generate_client, out.Indent(); } for (int i = 0; i < file->service_count(); i++) { - GenerateService(&out, file->service(i), generate_client, generate_server, - internal_access, lite_client); + GenerateService(&out, file->service(i), generate_client, + generate_lite_client, generate_server, internal_access); } if (file_namespace != "") { out.Outdent(); diff --git a/src/compiler/csharp_generator.h b/src/compiler/csharp_generator.h index d4c13c67363..842d136494c 100644 --- a/src/compiler/csharp_generator.h +++ b/src/compiler/csharp_generator.h @@ -26,8 +26,8 @@ namespace grpc_csharp_generator { grpc::string GetServices(const grpc::protobuf::FileDescriptor* file, - bool generate_client, bool generate_server, - bool internal_access, bool lite_client); + bool generate_client, bool generate_lite_client, + bool generate_server, bool internal_access); } // namespace grpc_csharp_generator diff --git a/src/compiler/csharp_plugin.cc b/src/compiler/csharp_plugin.cc index c503fd61ded..a495f876792 100644 --- a/src/compiler/csharp_plugin.cc +++ b/src/compiler/csharp_plugin.cc @@ -38,19 +38,18 @@ class CSharpGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { bool generate_client = true; bool generate_server = true; + bool generate_lite_client = true; bool internal_access = false; - bool lite_client = false; for (size_t i = 0; i < options.size(); i++) { if (options[i].first == "no_client") { generate_client = false; + } else if (options[i].first == "no_lite_client") { + // TODO: better option + generate_lite_client = false; } else if (options[i].first == "no_server") { generate_server = false; } else if (options[i].first == "internal_access") { internal_access = true; - } else if (options[i].first == "lite_client") { - // will only be used if generate_client is true. - // NOTE: experimental option, can be removed in future release - lite_client = true; } else { *error = "Unknown generator option: " + options[i].first; return false; @@ -58,7 +57,8 @@ class CSharpGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { } grpc::string code = grpc_csharp_generator::GetServices( - file, generate_client, generate_server, internal_access, lite_client); + file, generate_client, generate_lite_client, generate_server, + internal_access); if (code.size() == 0) { return true; // don't generate a file if there are no services } From f73c03f47c29b0ef2bfe0f1fb0975ce210bce59a Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 2 Sep 2019 10:58:00 -0400 Subject: [PATCH 1428/1555] Revert "C# lite client codegen" This reverts commit 25e3d26e8cb361692101555cdb199933079cd90f. --- src/compiler/csharp_generator.cc | 96 +++++++++++++------------------- src/compiler/csharp_generator.h | 4 +- src/compiler/csharp_plugin.cc | 7 +-- 3 files changed, 41 insertions(+), 66 deletions(-) diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc index 7f178f63bb0..f630da7c58e 100644 --- a/src/compiler/csharp_generator.cc +++ b/src/compiler/csharp_generator.cc @@ -176,9 +176,8 @@ std::string GetServiceClassName(const ServiceDescriptor* service) { return service->name(); } -std::string GetClientClassName(const ServiceDescriptor* service, - bool lite_client) { - return service->name() + (lite_client ? "LiteClient" : "Client"); +std::string GetClientClassName(const ServiceDescriptor* service) { + return service->name() + "Client"; } std::string GetServerClassName(const ServiceDescriptor* service) { @@ -415,19 +414,11 @@ void GenerateServerClass(Printer* out, const ServiceDescriptor* service) { out->Print("\n"); } -void GenerateClientStub(Printer* out, const ServiceDescriptor* service, - bool lite_client) { - if (!lite_client) { - out->Print("/// Client for $servicename$\n", - "servicename", GetServiceClassName(service)); - out->Print("public partial class $name$ : grpc::ClientBase<$name$>\n", - "name", GetClientClassName(service, lite_client)); - } else { - out->Print("/// Lite client for $servicename$\n", - "servicename", GetServiceClassName(service)); - out->Print("public partial class $name$ : grpc::LiteClientBase\n", "name", - GetClientClassName(service, lite_client)); - } +void GenerateClientStub(Printer* out, const ServiceDescriptor* service) { + out->Print("/// Client for $servicename$\n", "servicename", + GetServiceClassName(service)); + out->Print("public partial class $name$ : grpc::ClientBase<$name$>\n", "name", + GetClientClassName(service)); out->Print("{\n"); out->Indent(); @@ -449,30 +440,26 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor* service, "servicename", GetServiceClassName(service)); out->Print( "public $name$(grpc::CallInvoker callInvoker) : base(callInvoker)\n", - "name", GetClientClassName(service, lite_client)); + "name", GetClientClassName(service)); out->Print("{\n"); out->Print("}\n"); out->Print( "/// Protected parameterless constructor to allow creation" " of test doubles.\n"); out->Print("protected $name$() : base()\n", "name", - GetClientClassName(service, lite_client)); + GetClientClassName(service)); out->Print("{\n"); out->Print("}\n"); - if (!lite_client) { - out->Print( - "/// Protected constructor to allow creation of configured " - "clients.\n" - "/// The client " - "configuration.\n"); - out->Print( - "protected $name$(ClientBaseConfiguration configuration)" - " : base(configuration)\n", - "name", GetClientClassName(service, lite_client)); - out->Print("{\n"); - out->Print("}\n"); - } - out->Print("\n"); + out->Print( + "/// Protected constructor to allow creation of configured " + "clients.\n" + "/// The client configuration.\n"); + out->Print( + "protected $name$(ClientBaseConfiguration configuration)" + " : base(configuration)\n", + "name", GetClientClassName(service)); + out->Print("{\n"); + out->Print("}\n\n"); for (int i = 0; i < service->method_count(); i++) { const MethodDescriptor* method = service->method(i); @@ -590,21 +577,19 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor* service, } // override NewInstance method - if (!lite_client) { - out->Print( - "/// Creates a new instance of client from given " - "ClientBaseConfiguration.\n"); - out->Print( - "protected override $name$ NewInstance(ClientBaseConfiguration " - "configuration)\n", - "name", GetClientClassName(service, lite_client)); - out->Print("{\n"); - out->Indent(); - out->Print("return new $name$(configuration);\n", "name", - GetClientClassName(service, lite_client)); - out->Outdent(); - out->Print("}\n"); - } + out->Print( + "/// Creates a new instance of client from given " + "ClientBaseConfiguration.\n"); + out->Print( + "protected override $name$ NewInstance(ClientBaseConfiguration " + "configuration)\n", + "name", GetClientClassName(service)); + out->Print("{\n"); + out->Indent(); + out->Print("return new $name$(configuration);\n", "name", + GetClientClassName(service)); + out->Outdent(); + out->Print("}\n"); out->Outdent(); out->Print("}\n"); @@ -685,8 +670,8 @@ void GenerateBindServiceWithBinderMethod(Printer* out, } void GenerateService(Printer* out, const ServiceDescriptor* service, - bool generate_client, bool generate_lite_client, - bool generate_server, bool internal_access) { + bool generate_client, bool generate_server, + bool internal_access) { GenerateDocCommentBody(out, service); out->Print("$access_level$ static partial class $classname$\n", "access_level", GetAccessLevel(internal_access), "classname", @@ -708,12 +693,8 @@ void GenerateService(Printer* out, const ServiceDescriptor* service, GenerateServerClass(out, service); } if (generate_client) { - GenerateClientStub(out, service, false); + GenerateClientStub(out, service); } - if (generate_lite_client) { - GenerateClientStub(out, service, true); - } - if (generate_server) { GenerateBindServiceMethod(out, service); GenerateBindServiceWithBinderMethod(out, service); @@ -726,8 +707,7 @@ void GenerateService(Printer* out, const ServiceDescriptor* service, } // anonymous namespace grpc::string GetServices(const FileDescriptor* file, bool generate_client, - bool generate_lite_client, bool generate_server, - bool internal_access) { + bool generate_server, bool internal_access) { grpc::string output; { // Scope the output stream so it closes and finalizes output to the string. @@ -768,8 +748,8 @@ grpc::string GetServices(const FileDescriptor* file, bool generate_client, out.Indent(); } for (int i = 0; i < file->service_count(); i++) { - GenerateService(&out, file->service(i), generate_client, - generate_lite_client, generate_server, internal_access); + GenerateService(&out, file->service(i), generate_client, generate_server, + internal_access); } if (file_namespace != "") { out.Outdent(); diff --git a/src/compiler/csharp_generator.h b/src/compiler/csharp_generator.h index 842d136494c..fd36e11851b 100644 --- a/src/compiler/csharp_generator.h +++ b/src/compiler/csharp_generator.h @@ -26,8 +26,8 @@ namespace grpc_csharp_generator { grpc::string GetServices(const grpc::protobuf::FileDescriptor* file, - bool generate_client, bool generate_lite_client, - bool generate_server, bool internal_access); + bool generate_client, bool generate_server, + bool internal_access); } // namespace grpc_csharp_generator diff --git a/src/compiler/csharp_plugin.cc b/src/compiler/csharp_plugin.cc index a495f876792..5f13aa6749e 100644 --- a/src/compiler/csharp_plugin.cc +++ b/src/compiler/csharp_plugin.cc @@ -38,14 +38,10 @@ class CSharpGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { bool generate_client = true; bool generate_server = true; - bool generate_lite_client = true; bool internal_access = false; for (size_t i = 0; i < options.size(); i++) { if (options[i].first == "no_client") { generate_client = false; - } else if (options[i].first == "no_lite_client") { - // TODO: better option - generate_lite_client = false; } else if (options[i].first == "no_server") { generate_server = false; } else if (options[i].first == "internal_access") { @@ -57,8 +53,7 @@ class CSharpGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { } grpc::string code = grpc_csharp_generator::GetServices( - file, generate_client, generate_lite_client, generate_server, - internal_access); + file, generate_client, generate_server, internal_access); if (code.size() == 0) { return true; // don't generate a file if there are no services } From 28f031f915e0a7b326f4845b868bd2b35f7f3ed3 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 2 Sep 2019 11:12:11 -0400 Subject: [PATCH 1429/1555] Revert "also generate code with "lite_client" option set" This reverts commit 4a4cf280a1d5f8690ee063a22a6b4b1d1d49f27f. --- .../math_with_protoc_options.proto | 65 ------------------- src/csharp/generate_proto_csharp.sh | 2 - 2 files changed, 67 deletions(-) delete mode 100644 src/csharp/Grpc.Examples/math_with_protoc_options.proto diff --git a/src/csharp/Grpc.Examples/math_with_protoc_options.proto b/src/csharp/Grpc.Examples/math_with_protoc_options.proto deleted file mode 100644 index ca13c6d4466..00000000000 --- a/src/csharp/Grpc.Examples/math_with_protoc_options.proto +++ /dev/null @@ -1,65 +0,0 @@ - -// Copyright 2015 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package math_with_protoc_options; - -message DivArgs { - int64 dividend = 1; - int64 divisor = 2; -} - -message DivReply { - int64 quotient = 1; - int64 remainder = 2; -} - -message FibArgs { - int64 limit = 1; -} - -message Num { - int64 num = 1; -} - -message FibReply { - int64 count = 1; -} - -service Math { - // Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient - // and remainder. - rpc Div (DivArgs) returns (DivReply) { - } - - // DivMany accepts an arbitrary number of division args from the client stream - // and sends back the results in the reply stream. The stream continues until - // the client closes its end; the server does the same after sending all the - // replies. The stream ends immediately if either end aborts. - rpc DivMany (stream DivArgs) returns (stream DivReply) { - } - - // Fib generates numbers in the Fibonacci sequence. If FibArgs.limit > 0, Fib - // generates up to limit numbers; otherwise it continues until the call is - // canceled. Unlike Fib above, Fib has no final FibReply. - rpc Fib (FibArgs) returns (stream Num) { - } - - // Sum sums a stream of numbers, returning the final result once the stream - // is closed. - rpc Sum (stream Num) returns (Num) { - } -} diff --git a/src/csharp/generate_proto_csharp.sh b/src/csharp/generate_proto_csharp.sh index 81463ace6ad..e79728ff959 100755 --- a/src/csharp/generate_proto_csharp.sh +++ b/src/csharp/generate_proto_csharp.sh @@ -26,8 +26,6 @@ TESTING_DIR=src/csharp/Grpc.IntegrationTesting $PROTOC --plugin=$PLUGIN --csharp_out=$EXAMPLES_DIR --grpc_out=$EXAMPLES_DIR \ -I src/proto src/proto/math/math.proto -$PROTOC --plugin=$PLUGIN --csharp_out=$EXAMPLES_DIR --grpc_out=$EXAMPLES_DIR --grpc_opt=lite_client,no_server \ - -I src/csharp/Grpc.Examples src/csharp/Grpc.Examples/math_with_protoc_options.proto $PROTOC --plugin=$PLUGIN --csharp_out=$HEALTHCHECK_DIR --grpc_out=$HEALTHCHECK_DIR \ -I src/proto src/proto/grpc/health/v1/health.proto From e84d0a2875b4e10b217fcf140a2cec8475b0a0e6 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 2 Sep 2019 11:15:32 -0400 Subject: [PATCH 1430/1555] remove LiteClientBase --- src/csharp/Grpc.Core.Api/LiteClientBase.cs | 63 ---------------------- 1 file changed, 63 deletions(-) delete mode 100644 src/csharp/Grpc.Core.Api/LiteClientBase.cs diff --git a/src/csharp/Grpc.Core.Api/LiteClientBase.cs b/src/csharp/Grpc.Core.Api/LiteClientBase.cs deleted file mode 100644 index 132f10a912f..00000000000 --- a/src/csharp/Grpc.Core.Api/LiteClientBase.cs +++ /dev/null @@ -1,63 +0,0 @@ -#region Copyright notice and license - -// Copyright 2019 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#endregion - -using System; -using Grpc.Core.Internal; -using Grpc.Core.Utils; - -namespace Grpc.Core -{ - /// - /// Base class for lightweight client-side stubs. - /// All calls are invoked via a CallInvoker. - /// Lite client stubs have no configuration knobs, all configuration - /// is provided by decorating the call invoker. - /// Note: experimental API that can change or be removed without any prior notice. - /// - public abstract class LiteClientBase - { - readonly CallInvoker callInvoker; - - /// - /// Initializes a new instance of LiteClientBase class that - /// throws NotImplementedException upon invocation of any RPC. - /// This constructor is only provided to allow creation of test doubles - /// for client classes (e.g. mocking requires a parameterless constructor). - /// - protected LiteClientBase() : this(new UnimplementedCallInvoker()) - { - } - - /// - /// Initializes a new instance of ClientBase class. - /// - /// The CallInvoker for remote call invocation. - public LiteClientBase(CallInvoker callInvoker) - { - this.callInvoker = GrpcPreconditions.CheckNotNull(callInvoker, nameof(callInvoker)); - } - - /// - /// Gets the call invoker. - /// - protected CallInvoker CallInvoker - { - get { return this.callInvoker; } - } - } -} From 3a6042b824170fbca329aa07a8137b9359a7432a Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 2 Sep 2019 11:22:08 -0400 Subject: [PATCH 1431/1555] regenerate C# protos --- .../Grpc.IntegrationTesting/Messages.cs | 137 +++++++++++++++--- 1 file changed, 113 insertions(+), 24 deletions(-) diff --git a/src/csharp/Grpc.IntegrationTesting/Messages.cs b/src/csharp/Grpc.IntegrationTesting/Messages.cs index 5c5042b75b6..dab90d8ae46 100644 --- a/src/csharp/Grpc.IntegrationTesting/Messages.cs +++ b/src/csharp/Grpc.IntegrationTesting/Messages.cs @@ -28,7 +28,7 @@ namespace Grpc.Testing { "LnRlc3RpbmciGgoJQm9vbFZhbHVlEg0KBXZhbHVlGAEgASgIIkAKB1BheWxv", "YWQSJwoEdHlwZRgBIAEoDjIZLmdycGMudGVzdGluZy5QYXlsb2FkVHlwZRIM", "CgRib2R5GAIgASgMIisKCkVjaG9TdGF0dXMSDAoEY29kZRgBIAEoBRIPCgdt", - "ZXNzYWdlGAIgASgJIuYCCg1TaW1wbGVSZXF1ZXN0EjAKDXJlc3BvbnNlX3R5", + "ZXNzYWdlGAIgASgJIoYDCg1TaW1wbGVSZXF1ZXN0EjAKDXJlc3BvbnNlX3R5", "cGUYASABKA4yGS5ncnBjLnRlc3RpbmcuUGF5bG9hZFR5cGUSFQoNcmVzcG9u", "c2Vfc2l6ZRgCIAEoBRImCgdwYXlsb2FkGAMgASgLMhUuZ3JwYy50ZXN0aW5n", "LlBheWxvYWQSFQoNZmlsbF91c2VybmFtZRgEIAEoCBIYChBmaWxsX29hdXRo", @@ -36,34 +36,38 @@ namespace Grpc.Testing { "cnBjLnRlc3RpbmcuQm9vbFZhbHVlEjEKD3Jlc3BvbnNlX3N0YXR1cxgHIAEo", "CzIYLmdycGMudGVzdGluZy5FY2hvU3RhdHVzEjIKEWV4cGVjdF9jb21wcmVz", "c2VkGAggASgLMhcuZ3JwYy50ZXN0aW5nLkJvb2xWYWx1ZRIWCg5maWxsX3Nl", - "cnZlcl9pZBgJIAEoCCJyCg5TaW1wbGVSZXNwb25zZRImCgdwYXlsb2FkGAEg", - "ASgLMhUuZ3JwYy50ZXN0aW5nLlBheWxvYWQSEAoIdXNlcm5hbWUYAiABKAkS", - "EwoLb2F1dGhfc2NvcGUYAyABKAkSEQoJc2VydmVyX2lkGAQgASgJIncKGVN0", - "cmVhbWluZ0lucHV0Q2FsbFJlcXVlc3QSJgoHcGF5bG9hZBgBIAEoCzIVLmdy", - "cGMudGVzdGluZy5QYXlsb2FkEjIKEWV4cGVjdF9jb21wcmVzc2VkGAIgASgL", - "MhcuZ3JwYy50ZXN0aW5nLkJvb2xWYWx1ZSI9ChpTdHJlYW1pbmdJbnB1dENh", - "bGxSZXNwb25zZRIfChdhZ2dyZWdhdGVkX3BheWxvYWRfc2l6ZRgBIAEoBSJk", - "ChJSZXNwb25zZVBhcmFtZXRlcnMSDAoEc2l6ZRgBIAEoBRITCgtpbnRlcnZh", - "bF91cxgCIAEoBRIrCgpjb21wcmVzc2VkGAMgASgLMhcuZ3JwYy50ZXN0aW5n", - "LkJvb2xWYWx1ZSLoAQoaU3RyZWFtaW5nT3V0cHV0Q2FsbFJlcXVlc3QSMAoN", - "cmVzcG9uc2VfdHlwZRgBIAEoDjIZLmdycGMudGVzdGluZy5QYXlsb2FkVHlw", - "ZRI9ChNyZXNwb25zZV9wYXJhbWV0ZXJzGAIgAygLMiAuZ3JwYy50ZXN0aW5n", - "LlJlc3BvbnNlUGFyYW1ldGVycxImCgdwYXlsb2FkGAMgASgLMhUuZ3JwYy50", - "ZXN0aW5nLlBheWxvYWQSMQoPcmVzcG9uc2Vfc3RhdHVzGAcgASgLMhguZ3Jw", - "Yy50ZXN0aW5nLkVjaG9TdGF0dXMiRQobU3RyZWFtaW5nT3V0cHV0Q2FsbFJl", - "c3BvbnNlEiYKB3BheWxvYWQYASABKAsyFS5ncnBjLnRlc3RpbmcuUGF5bG9h", - "ZCIzCg9SZWNvbm5lY3RQYXJhbXMSIAoYbWF4X3JlY29ubmVjdF9iYWNrb2Zm", - "X21zGAEgASgFIjMKDVJlY29ubmVjdEluZm8SDgoGcGFzc2VkGAEgASgIEhIK", - "CmJhY2tvZmZfbXMYAiADKAUqHwoLUGF5bG9hZFR5cGUSEAoMQ09NUFJFU1NB", - "QkxFEABiBnByb3RvMw==")); + "cnZlcl9pZBgJIAEoCBIeChZmaWxsX2dycGNsYl9yb3V0ZV90eXBlGAogASgI", + "IqwBCg5TaW1wbGVSZXNwb25zZRImCgdwYXlsb2FkGAEgASgLMhUuZ3JwYy50", + "ZXN0aW5nLlBheWxvYWQSEAoIdXNlcm5hbWUYAiABKAkSEwoLb2F1dGhfc2Nv", + "cGUYAyABKAkSEQoJc2VydmVyX2lkGAQgASgJEjgKEWdycGNsYl9yb3V0ZV90", + "eXBlGAUgASgOMh0uZ3JwYy50ZXN0aW5nLkdycGNsYlJvdXRlVHlwZSJ3ChlT", + "dHJlYW1pbmdJbnB1dENhbGxSZXF1ZXN0EiYKB3BheWxvYWQYASABKAsyFS5n", + "cnBjLnRlc3RpbmcuUGF5bG9hZBIyChFleHBlY3RfY29tcHJlc3NlZBgCIAEo", + "CzIXLmdycGMudGVzdGluZy5Cb29sVmFsdWUiPQoaU3RyZWFtaW5nSW5wdXRD", + "YWxsUmVzcG9uc2USHwoXYWdncmVnYXRlZF9wYXlsb2FkX3NpemUYASABKAUi", + "ZAoSUmVzcG9uc2VQYXJhbWV0ZXJzEgwKBHNpemUYASABKAUSEwoLaW50ZXJ2", + "YWxfdXMYAiABKAUSKwoKY29tcHJlc3NlZBgDIAEoCzIXLmdycGMudGVzdGlu", + "Zy5Cb29sVmFsdWUi6AEKGlN0cmVhbWluZ091dHB1dENhbGxSZXF1ZXN0EjAK", + "DXJlc3BvbnNlX3R5cGUYASABKA4yGS5ncnBjLnRlc3RpbmcuUGF5bG9hZFR5", + "cGUSPQoTcmVzcG9uc2VfcGFyYW1ldGVycxgCIAMoCzIgLmdycGMudGVzdGlu", + "Zy5SZXNwb25zZVBhcmFtZXRlcnMSJgoHcGF5bG9hZBgDIAEoCzIVLmdycGMu", + "dGVzdGluZy5QYXlsb2FkEjEKD3Jlc3BvbnNlX3N0YXR1cxgHIAEoCzIYLmdy", + "cGMudGVzdGluZy5FY2hvU3RhdHVzIkUKG1N0cmVhbWluZ091dHB1dENhbGxS", + "ZXNwb25zZRImCgdwYXlsb2FkGAEgASgLMhUuZ3JwYy50ZXN0aW5nLlBheWxv", + "YWQiMwoPUmVjb25uZWN0UGFyYW1zEiAKGG1heF9yZWNvbm5lY3RfYmFja29m", + "Zl9tcxgBIAEoBSIzCg1SZWNvbm5lY3RJbmZvEg4KBnBhc3NlZBgBIAEoCBIS", + "CgpiYWNrb2ZmX21zGAIgAygFKh8KC1BheWxvYWRUeXBlEhAKDENPTVBSRVNT", + "QUJMRRAAKm8KD0dycGNsYlJvdXRlVHlwZRIdChlHUlBDTEJfUk9VVEVfVFlQ", + "RV9VTktOT1dOEAASHgoaR1JQQ0xCX1JPVVRFX1RZUEVfRkFMTEJBQ0sQARId", + "ChlHUlBDTEJfUk9VVEVfVFlQRV9CQUNLRU5EEAJiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Grpc.Testing.PayloadType), }, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Grpc.Testing.PayloadType), typeof(global::Grpc.Testing.GrpclbRouteType), }, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.BoolValue), global::Grpc.Testing.BoolValue.Parser, new[]{ "Value" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.Payload), global::Grpc.Testing.Payload.Parser, new[]{ "Type", "Body" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.EchoStatus), global::Grpc.Testing.EchoStatus.Parser, new[]{ "Code", "Message" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.SimpleRequest), global::Grpc.Testing.SimpleRequest.Parser, new[]{ "ResponseType", "ResponseSize", "Payload", "FillUsername", "FillOauthScope", "ResponseCompressed", "ResponseStatus", "ExpectCompressed", "FillServerId" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.SimpleResponse), global::Grpc.Testing.SimpleResponse.Parser, new[]{ "Payload", "Username", "OauthScope", "ServerId" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.SimpleRequest), global::Grpc.Testing.SimpleRequest.Parser, new[]{ "ResponseType", "ResponseSize", "Payload", "FillUsername", "FillOauthScope", "ResponseCompressed", "ResponseStatus", "ExpectCompressed", "FillServerId", "FillGrpclbRouteType" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.SimpleResponse), global::Grpc.Testing.SimpleResponse.Parser, new[]{ "Payload", "Username", "OauthScope", "ServerId", "GrpclbRouteType" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.StreamingInputCallRequest), global::Grpc.Testing.StreamingInputCallRequest.Parser, new[]{ "Payload", "ExpectCompressed" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.StreamingInputCallResponse), global::Grpc.Testing.StreamingInputCallResponse.Parser, new[]{ "AggregatedPayloadSize" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ResponseParameters), global::Grpc.Testing.ResponseParameters.Parser, new[]{ "Size", "IntervalUs", "Compressed" }, null, null, null), @@ -87,6 +91,29 @@ namespace Grpc.Testing { [pbr::OriginalName("COMPRESSABLE")] Compressable = 0, } + /// + /// The type of route that a client took to reach a server w.r.t. gRPCLB. + /// The server must fill in "fallback" if it detects that the RPC reached + /// the server via the "gRPCLB fallback" path, and "backend" if it detects + /// that the RPC reached the server via "gRPCLB backend" path (i.e. if it got + /// the address of this server from the gRPCLB server BalanceLoad RPC). Exactly + /// how this detection is done is context and server dependant. + /// + public enum GrpclbRouteType { + /// + /// Server didn't detect the route that a client took to reach it. + /// + [pbr::OriginalName("GRPCLB_ROUTE_TYPE_UNKNOWN")] Unknown = 0, + /// + /// Indicates that a client reached a server via gRPCLB fallback. + /// + [pbr::OriginalName("GRPCLB_ROUTE_TYPE_FALLBACK")] Fallback = 1, + /// + /// Indicates that a client reached a server as a gRPCLB-given backend. + /// + [pbr::OriginalName("GRPCLB_ROUTE_TYPE_BACKEND")] Backend = 2, + } + #endregion #region Messages @@ -591,6 +618,7 @@ namespace Grpc.Testing { responseStatus_ = other.responseStatus_ != null ? other.responseStatus_.Clone() : null; expectCompressed_ = other.expectCompressed_ != null ? other.expectCompressed_.Clone() : null; fillServerId_ = other.fillServerId_; + fillGrpclbRouteType_ = other.fillGrpclbRouteType_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -729,6 +757,20 @@ namespace Grpc.Testing { } } + /// Field number for the "fill_grpclb_route_type" field. + public const int FillGrpclbRouteTypeFieldNumber = 10; + private bool fillGrpclbRouteType_; + /// + /// Whether SimpleResponse should include grpclb_route_type. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool FillGrpclbRouteType { + get { return fillGrpclbRouteType_; } + set { + fillGrpclbRouteType_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as SimpleRequest); @@ -751,6 +793,7 @@ namespace Grpc.Testing { if (!object.Equals(ResponseStatus, other.ResponseStatus)) return false; if (!object.Equals(ExpectCompressed, other.ExpectCompressed)) return false; if (FillServerId != other.FillServerId) return false; + if (FillGrpclbRouteType != other.FillGrpclbRouteType) return false; return Equals(_unknownFields, other._unknownFields); } @@ -766,6 +809,7 @@ namespace Grpc.Testing { if (responseStatus_ != null) hash ^= ResponseStatus.GetHashCode(); if (expectCompressed_ != null) hash ^= ExpectCompressed.GetHashCode(); if (FillServerId != false) hash ^= FillServerId.GetHashCode(); + if (FillGrpclbRouteType != false) hash ^= FillGrpclbRouteType.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } @@ -815,6 +859,10 @@ namespace Grpc.Testing { output.WriteRawTag(72); output.WriteBool(FillServerId); } + if (FillGrpclbRouteType != false) { + output.WriteRawTag(80); + output.WriteBool(FillGrpclbRouteType); + } if (_unknownFields != null) { _unknownFields.WriteTo(output); } @@ -850,6 +898,9 @@ namespace Grpc.Testing { if (FillServerId != false) { size += 1 + 1; } + if (FillGrpclbRouteType != false) { + size += 1 + 1; + } if (_unknownFields != null) { size += _unknownFields.CalculateSize(); } @@ -900,6 +951,9 @@ namespace Grpc.Testing { if (other.FillServerId != false) { FillServerId = other.FillServerId; } + if (other.FillGrpclbRouteType != false) { + FillGrpclbRouteType = other.FillGrpclbRouteType; + } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } @@ -959,6 +1013,10 @@ namespace Grpc.Testing { FillServerId = input.ReadBool(); break; } + case 80: { + FillGrpclbRouteType = input.ReadBool(); + break; + } } } } @@ -997,6 +1055,7 @@ namespace Grpc.Testing { username_ = other.username_; oauthScope_ = other.oauthScope_; serverId_ = other.serverId_; + grpclbRouteType_ = other.grpclbRouteType_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -1063,6 +1122,20 @@ namespace Grpc.Testing { } } + /// Field number for the "grpclb_route_type" field. + public const int GrpclbRouteTypeFieldNumber = 5; + private global::Grpc.Testing.GrpclbRouteType grpclbRouteType_ = 0; + /// + /// gRPCLB Path. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Grpc.Testing.GrpclbRouteType GrpclbRouteType { + get { return grpclbRouteType_; } + set { + grpclbRouteType_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as SimpleResponse); @@ -1080,6 +1153,7 @@ namespace Grpc.Testing { if (Username != other.Username) return false; if (OauthScope != other.OauthScope) return false; if (ServerId != other.ServerId) return false; + if (GrpclbRouteType != other.GrpclbRouteType) return false; return Equals(_unknownFields, other._unknownFields); } @@ -1090,6 +1164,7 @@ namespace Grpc.Testing { if (Username.Length != 0) hash ^= Username.GetHashCode(); if (OauthScope.Length != 0) hash ^= OauthScope.GetHashCode(); if (ServerId.Length != 0) hash ^= ServerId.GetHashCode(); + if (GrpclbRouteType != 0) hash ^= GrpclbRouteType.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } @@ -1119,6 +1194,10 @@ namespace Grpc.Testing { output.WriteRawTag(34); output.WriteString(ServerId); } + if (GrpclbRouteType != 0) { + output.WriteRawTag(40); + output.WriteEnum((int) GrpclbRouteType); + } if (_unknownFields != null) { _unknownFields.WriteTo(output); } @@ -1139,6 +1218,9 @@ namespace Grpc.Testing { if (ServerId.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(ServerId); } + if (GrpclbRouteType != 0) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) GrpclbRouteType); + } if (_unknownFields != null) { size += _unknownFields.CalculateSize(); } @@ -1165,6 +1247,9 @@ namespace Grpc.Testing { if (other.ServerId.Length != 0) { ServerId = other.ServerId; } + if (other.GrpclbRouteType != 0) { + GrpclbRouteType = other.GrpclbRouteType; + } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } @@ -1195,6 +1280,10 @@ namespace Grpc.Testing { ServerId = input.ReadString(); break; } + case 40: { + GrpclbRouteType = (global::Grpc.Testing.GrpclbRouteType) input.ReadEnum(); + break; + } } } } From 2ea334a60b6cb9f2a6d750cd7e033441d86c33d1 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 2 Sep 2019 11:27:38 -0400 Subject: [PATCH 1432/1555] remove no-longer-needed generated files --- .../Grpc.Examples/MathWithProtocOptions.cs | 759 ------------------ .../MathWithProtocOptionsGrpc.cs | 208 ----- 2 files changed, 967 deletions(-) delete mode 100644 src/csharp/Grpc.Examples/MathWithProtocOptions.cs delete mode 100644 src/csharp/Grpc.Examples/MathWithProtocOptionsGrpc.cs diff --git a/src/csharp/Grpc.Examples/MathWithProtocOptions.cs b/src/csharp/Grpc.Examples/MathWithProtocOptions.cs deleted file mode 100644 index ef9a5a4ff5c..00000000000 --- a/src/csharp/Grpc.Examples/MathWithProtocOptions.cs +++ /dev/null @@ -1,759 +0,0 @@ -// -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: math_with_protoc_options.proto -// -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace MathWithProtocOptions { - - /// Holder for reflection information generated from math_with_protoc_options.proto - public static partial class MathWithProtocOptionsReflection { - - #region Descriptor - /// File descriptor for math_with_protoc_options.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static MathWithProtocOptionsReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "Ch5tYXRoX3dpdGhfcHJvdG9jX29wdGlvbnMucHJvdG8SGG1hdGhfd2l0aF9w", - "cm90b2Nfb3B0aW9ucyIsCgdEaXZBcmdzEhAKCGRpdmlkZW5kGAEgASgDEg8K", - "B2Rpdmlzb3IYAiABKAMiLwoIRGl2UmVwbHkSEAoIcXVvdGllbnQYASABKAMS", - "EQoJcmVtYWluZGVyGAIgASgDIhgKB0ZpYkFyZ3MSDQoFbGltaXQYASABKAMi", - "EgoDTnVtEgsKA251bRgBIAEoAyIZCghGaWJSZXBseRINCgVjb3VudBgBIAEo", - "AzLEAgoETWF0aBJOCgNEaXYSIS5tYXRoX3dpdGhfcHJvdG9jX29wdGlvbnMu", - "RGl2QXJncxoiLm1hdGhfd2l0aF9wcm90b2Nfb3B0aW9ucy5EaXZSZXBseSIA", - "ElYKB0Rpdk1hbnkSIS5tYXRoX3dpdGhfcHJvdG9jX29wdGlvbnMuRGl2QXJn", - "cxoiLm1hdGhfd2l0aF9wcm90b2Nfb3B0aW9ucy5EaXZSZXBseSIAKAEwARJL", - "CgNGaWISIS5tYXRoX3dpdGhfcHJvdG9jX29wdGlvbnMuRmliQXJncxodLm1h", - "dGhfd2l0aF9wcm90b2Nfb3B0aW9ucy5OdW0iADABEkcKA1N1bRIdLm1hdGhf", - "d2l0aF9wcm90b2Nfb3B0aW9ucy5OdW0aHS5tYXRoX3dpdGhfcHJvdG9jX29w", - "dGlvbnMuTnVtIgAoAWIGcHJvdG8z")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::MathWithProtocOptions.DivArgs), global::MathWithProtocOptions.DivArgs.Parser, new[]{ "Dividend", "Divisor" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::MathWithProtocOptions.DivReply), global::MathWithProtocOptions.DivReply.Parser, new[]{ "Quotient", "Remainder" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::MathWithProtocOptions.FibArgs), global::MathWithProtocOptions.FibArgs.Parser, new[]{ "Limit" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::MathWithProtocOptions.Num), global::MathWithProtocOptions.Num.Parser, new[]{ "Num_" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::MathWithProtocOptions.FibReply), global::MathWithProtocOptions.FibReply.Parser, new[]{ "Count" }, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class DivArgs : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DivArgs()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::MathWithProtocOptions.MathWithProtocOptionsReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public DivArgs() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public DivArgs(DivArgs other) : this() { - dividend_ = other.dividend_; - divisor_ = other.divisor_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public DivArgs Clone() { - return new DivArgs(this); - } - - /// Field number for the "dividend" field. - public const int DividendFieldNumber = 1; - private long dividend_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Dividend { - get { return dividend_; } - set { - dividend_ = value; - } - } - - /// Field number for the "divisor" field. - public const int DivisorFieldNumber = 2; - private long divisor_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Divisor { - get { return divisor_; } - set { - divisor_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as DivArgs); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(DivArgs other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Dividend != other.Dividend) return false; - if (Divisor != other.Divisor) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (Dividend != 0L) hash ^= Dividend.GetHashCode(); - if (Divisor != 0L) hash ^= Divisor.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (Dividend != 0L) { - output.WriteRawTag(8); - output.WriteInt64(Dividend); - } - if (Divisor != 0L) { - output.WriteRawTag(16); - output.WriteInt64(Divisor); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (Dividend != 0L) { - size += 1 + pb::CodedOutputStream.ComputeInt64Size(Dividend); - } - if (Divisor != 0L) { - size += 1 + pb::CodedOutputStream.ComputeInt64Size(Divisor); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(DivArgs other) { - if (other == null) { - return; - } - if (other.Dividend != 0L) { - Dividend = other.Dividend; - } - if (other.Divisor != 0L) { - Divisor = other.Divisor; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 8: { - Dividend = input.ReadInt64(); - break; - } - case 16: { - Divisor = input.ReadInt64(); - break; - } - } - } - } - - } - - public sealed partial class DivReply : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DivReply()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::MathWithProtocOptions.MathWithProtocOptionsReflection.Descriptor.MessageTypes[1]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public DivReply() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public DivReply(DivReply other) : this() { - quotient_ = other.quotient_; - remainder_ = other.remainder_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public DivReply Clone() { - return new DivReply(this); - } - - /// Field number for the "quotient" field. - public const int QuotientFieldNumber = 1; - private long quotient_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Quotient { - get { return quotient_; } - set { - quotient_ = value; - } - } - - /// Field number for the "remainder" field. - public const int RemainderFieldNumber = 2; - private long remainder_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Remainder { - get { return remainder_; } - set { - remainder_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as DivReply); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(DivReply other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Quotient != other.Quotient) return false; - if (Remainder != other.Remainder) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (Quotient != 0L) hash ^= Quotient.GetHashCode(); - if (Remainder != 0L) hash ^= Remainder.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (Quotient != 0L) { - output.WriteRawTag(8); - output.WriteInt64(Quotient); - } - if (Remainder != 0L) { - output.WriteRawTag(16); - output.WriteInt64(Remainder); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (Quotient != 0L) { - size += 1 + pb::CodedOutputStream.ComputeInt64Size(Quotient); - } - if (Remainder != 0L) { - size += 1 + pb::CodedOutputStream.ComputeInt64Size(Remainder); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(DivReply other) { - if (other == null) { - return; - } - if (other.Quotient != 0L) { - Quotient = other.Quotient; - } - if (other.Remainder != 0L) { - Remainder = other.Remainder; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 8: { - Quotient = input.ReadInt64(); - break; - } - case 16: { - Remainder = input.ReadInt64(); - break; - } - } - } - } - - } - - public sealed partial class FibArgs : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FibArgs()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::MathWithProtocOptions.MathWithProtocOptionsReflection.Descriptor.MessageTypes[2]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public FibArgs() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public FibArgs(FibArgs other) : this() { - limit_ = other.limit_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public FibArgs Clone() { - return new FibArgs(this); - } - - /// Field number for the "limit" field. - public const int LimitFieldNumber = 1; - private long limit_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Limit { - get { return limit_; } - set { - limit_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as FibArgs); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(FibArgs other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Limit != other.Limit) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (Limit != 0L) hash ^= Limit.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (Limit != 0L) { - output.WriteRawTag(8); - output.WriteInt64(Limit); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (Limit != 0L) { - size += 1 + pb::CodedOutputStream.ComputeInt64Size(Limit); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(FibArgs other) { - if (other == null) { - return; - } - if (other.Limit != 0L) { - Limit = other.Limit; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 8: { - Limit = input.ReadInt64(); - break; - } - } - } - } - - } - - public sealed partial class Num : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Num()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::MathWithProtocOptions.MathWithProtocOptionsReflection.Descriptor.MessageTypes[3]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Num() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Num(Num other) : this() { - num_ = other.num_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Num Clone() { - return new Num(this); - } - - /// Field number for the "num" field. - public const int Num_FieldNumber = 1; - private long num_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Num_ { - get { return num_; } - set { - num_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as Num); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(Num other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Num_ != other.Num_) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (Num_ != 0L) hash ^= Num_.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (Num_ != 0L) { - output.WriteRawTag(8); - output.WriteInt64(Num_); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (Num_ != 0L) { - size += 1 + pb::CodedOutputStream.ComputeInt64Size(Num_); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(Num other) { - if (other == null) { - return; - } - if (other.Num_ != 0L) { - Num_ = other.Num_; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 8: { - Num_ = input.ReadInt64(); - break; - } - } - } - } - - } - - public sealed partial class FibReply : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FibReply()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::MathWithProtocOptions.MathWithProtocOptionsReflection.Descriptor.MessageTypes[4]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public FibReply() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public FibReply(FibReply other) : this() { - count_ = other.count_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public FibReply Clone() { - return new FibReply(this); - } - - /// Field number for the "count" field. - public const int CountFieldNumber = 1; - private long count_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Count { - get { return count_; } - set { - count_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as FibReply); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(FibReply other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Count != other.Count) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (Count != 0L) hash ^= Count.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (Count != 0L) { - output.WriteRawTag(8); - output.WriteInt64(Count); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (Count != 0L) { - size += 1 + pb::CodedOutputStream.ComputeInt64Size(Count); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(FibReply other) { - if (other == null) { - return; - } - if (other.Count != 0L) { - Count = other.Count; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 8: { - Count = input.ReadInt64(); - break; - } - } - } - } - - } - - #endregion - -} - -#endregion Designer generated code diff --git a/src/csharp/Grpc.Examples/MathWithProtocOptionsGrpc.cs b/src/csharp/Grpc.Examples/MathWithProtocOptionsGrpc.cs deleted file mode 100644 index dd61b72163f..00000000000 --- a/src/csharp/Grpc.Examples/MathWithProtocOptionsGrpc.cs +++ /dev/null @@ -1,208 +0,0 @@ -// -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: math_with_protoc_options.proto -// -// Original file comments: -// Copyright 2015 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#pragma warning disable 0414, 1591 -#region Designer generated code - -using grpc = global::Grpc.Core; - -namespace MathWithProtocOptions { - public static partial class Math - { - static readonly string __ServiceName = "math_with_protoc_options.Math"; - - static readonly grpc::Marshaller __Marshaller_math_with_protoc_options_DivArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::MathWithProtocOptions.DivArgs.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_math_with_protoc_options_DivReply = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::MathWithProtocOptions.DivReply.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_math_with_protoc_options_FibArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::MathWithProtocOptions.FibArgs.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_math_with_protoc_options_Num = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::MathWithProtocOptions.Num.Parser.ParseFrom); - - static readonly grpc::Method __Method_Div = new grpc::Method( - grpc::MethodType.Unary, - __ServiceName, - "Div", - __Marshaller_math_with_protoc_options_DivArgs, - __Marshaller_math_with_protoc_options_DivReply); - - static readonly grpc::Method __Method_DivMany = new grpc::Method( - grpc::MethodType.DuplexStreaming, - __ServiceName, - "DivMany", - __Marshaller_math_with_protoc_options_DivArgs, - __Marshaller_math_with_protoc_options_DivReply); - - static readonly grpc::Method __Method_Fib = new grpc::Method( - grpc::MethodType.ServerStreaming, - __ServiceName, - "Fib", - __Marshaller_math_with_protoc_options_FibArgs, - __Marshaller_math_with_protoc_options_Num); - - static readonly grpc::Method __Method_Sum = new grpc::Method( - grpc::MethodType.ClientStreaming, - __ServiceName, - "Sum", - __Marshaller_math_with_protoc_options_Num, - __Marshaller_math_with_protoc_options_Num); - - /// Service descriptor - public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor - { - get { return global::MathWithProtocOptions.MathWithProtocOptionsReflection.Descriptor.Services[0]; } - } - - /// Lite client for Math - public partial class MathClient : grpc::LiteClientBase - { - /// Creates a new client for Math that uses a custom CallInvoker. - /// The callInvoker to use to make remote calls. - public MathClient(grpc::CallInvoker callInvoker) : base(callInvoker) - { - } - /// Protected parameterless constructor to allow creation of test doubles. - protected MathClient() : base() - { - } - - /// - /// Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient - /// and remainder. - /// - /// The request to send to the server. - /// The initial metadata to send with the call. This parameter is optional. - /// An optional deadline for the call. The call will be cancelled if deadline is hit. - /// An optional token for canceling the call. - /// The response received from the server. - public virtual global::MathWithProtocOptions.DivReply Div(global::MathWithProtocOptions.DivArgs request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) - { - return Div(request, new grpc::CallOptions(headers, deadline, cancellationToken)); - } - /// - /// Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient - /// and remainder. - /// - /// The request to send to the server. - /// The options for the call. - /// The response received from the server. - public virtual global::MathWithProtocOptions.DivReply Div(global::MathWithProtocOptions.DivArgs request, grpc::CallOptions options) - { - return CallInvoker.BlockingUnaryCall(__Method_Div, null, options, request); - } - /// - /// Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient - /// and remainder. - /// - /// The request to send to the server. - /// The initial metadata to send with the call. This parameter is optional. - /// An optional deadline for the call. The call will be cancelled if deadline is hit. - /// An optional token for canceling the call. - /// The call object. - public virtual grpc::AsyncUnaryCall DivAsync(global::MathWithProtocOptions.DivArgs request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) - { - return DivAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); - } - /// - /// Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient - /// and remainder. - /// - /// The request to send to the server. - /// The options for the call. - /// The call object. - public virtual grpc::AsyncUnaryCall DivAsync(global::MathWithProtocOptions.DivArgs request, grpc::CallOptions options) - { - return CallInvoker.AsyncUnaryCall(__Method_Div, null, options, request); - } - /// - /// DivMany accepts an arbitrary number of division args from the client stream - /// and sends back the results in the reply stream. The stream continues until - /// the client closes its end; the server does the same after sending all the - /// replies. The stream ends immediately if either end aborts. - /// - /// The initial metadata to send with the call. This parameter is optional. - /// An optional deadline for the call. The call will be cancelled if deadline is hit. - /// An optional token for canceling the call. - /// The call object. - public virtual grpc::AsyncDuplexStreamingCall DivMany(grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) - { - return DivMany(new grpc::CallOptions(headers, deadline, cancellationToken)); - } - /// - /// DivMany accepts an arbitrary number of division args from the client stream - /// and sends back the results in the reply stream. The stream continues until - /// the client closes its end; the server does the same after sending all the - /// replies. The stream ends immediately if either end aborts. - /// - /// The options for the call. - /// The call object. - public virtual grpc::AsyncDuplexStreamingCall DivMany(grpc::CallOptions options) - { - return CallInvoker.AsyncDuplexStreamingCall(__Method_DivMany, null, options); - } - /// - /// Fib generates numbers in the Fibonacci sequence. If FibArgs.limit > 0, Fib - /// generates up to limit numbers; otherwise it continues until the call is - /// canceled. Unlike Fib above, Fib has no final FibReply. - /// - /// The request to send to the server. - /// The initial metadata to send with the call. This parameter is optional. - /// An optional deadline for the call. The call will be cancelled if deadline is hit. - /// An optional token for canceling the call. - /// The call object. - public virtual grpc::AsyncServerStreamingCall Fib(global::MathWithProtocOptions.FibArgs request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) - { - return Fib(request, new grpc::CallOptions(headers, deadline, cancellationToken)); - } - /// - /// Fib generates numbers in the Fibonacci sequence. If FibArgs.limit > 0, Fib - /// generates up to limit numbers; otherwise it continues until the call is - /// canceled. Unlike Fib above, Fib has no final FibReply. - /// - /// The request to send to the server. - /// The options for the call. - /// The call object. - public virtual grpc::AsyncServerStreamingCall Fib(global::MathWithProtocOptions.FibArgs request, grpc::CallOptions options) - { - return CallInvoker.AsyncServerStreamingCall(__Method_Fib, null, options, request); - } - /// - /// Sum sums a stream of numbers, returning the final result once the stream - /// is closed. - /// - /// The initial metadata to send with the call. This parameter is optional. - /// An optional deadline for the call. The call will be cancelled if deadline is hit. - /// An optional token for canceling the call. - /// The call object. - public virtual grpc::AsyncClientStreamingCall Sum(grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) - { - return Sum(new grpc::CallOptions(headers, deadline, cancellationToken)); - } - /// - /// Sum sums a stream of numbers, returning the final result once the stream - /// is closed. - /// - /// The options for the call. - /// The call object. - public virtual grpc::AsyncClientStreamingCall Sum(grpc::CallOptions options) - { - return CallInvoker.AsyncClientStreamingCall(__Method_Sum, null, options); - } - } - - } -} -#endregion From 7b54e095cbed9cbec7da473e56012578eaa938e8 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 2 Sep 2019 12:30:22 -0400 Subject: [PATCH 1433/1555] fix microbenchmarks --- src/csharp/Grpc.Microbenchmarks/PingBenchmark.cs | 2 +- src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/csharp/Grpc.Microbenchmarks/PingBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/PingBenchmark.cs index 3949040aac0..cbcf5d361ca 100644 --- a/src/csharp/Grpc.Microbenchmarks/PingBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/PingBenchmark.cs @@ -86,7 +86,7 @@ namespace Grpc.Microbenchmarks await server.ShutdownAsync(); } - class PingClient : LiteClientBase + class PingClient : ClientBase { public PingClient(CallInvoker callInvoker) : base(callInvoker) { } public AsyncUnaryCall PingAsync(string request, CallOptions options) diff --git a/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs b/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs index 8448f03dd62..1f87b41169c 100644 --- a/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs +++ b/src/csharp/Grpc.Microbenchmarks/UnaryCallOverheadBenchmark.cs @@ -91,7 +91,7 @@ namespace Grpc.Microbenchmarks await channel.ShutdownAsync(); } - class PingClient : LiteClientBase + class PingClient : ClientBase { public PingClient(CallInvoker callInvoker) : base(callInvoker) { } From 406a2473a60a3ef78f73344724fabd20024775f2 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Mon, 2 Sep 2019 19:36:11 -0700 Subject: [PATCH 1434/1555] Enable stale bot --- .github/stale.yml | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/stale.yml diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 00000000000..ff9049ddb96 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,59 @@ +# Configuration for probot-stale - https://github.com/probot/stale + +# Number of days of inactivity before an Issue or Pull Request becomes stale +daysUntilStale: 180 + +# Number of days of inactivity before an Issue or Pull Request with the stale label is closed. +# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale. +daysUntilClose: 1 + +# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled) +onlyLabels: [] + +# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable +exemptLabels: + - "disposition/never stale" + +# Set to true to ignore issues in a project (defaults to false) +exemptProjects: false + +# Set to true to ignore issues in a milestone (defaults to false) +exemptMilestones: false + +# Set to true to ignore issues with an assignee (defaults to false) +exemptAssignees: false + +# Label to use when marking as stale +staleLabel: "disposition/stale" + +# Comment to post when marking as stale. Set to `false` to disable +markComment: > + This issue/PR has been automatically marked as stale because it has not had any update (including + commits, comments, labels, milestones, etc) for 180 days. It will be closed automatically if no + further update occurs in 1 day. Thank you for your contributions! + +# Comment to post when removing the stale label. +# unmarkComment: > +# Your comment here. + +# Comment to post when closing a stale Issue or Pull Request. +# closeComment: > +# Your comment here. + +# Limit the number of actions per hour, from 1-30. Default is 30 +limitPerRun: 30 + +# Limit to only `issues` or `pulls` +# only: issues + +# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls': +# pulls: +# daysUntilStale: 30 +# markComment: > +# This pull request has been automatically marked as stale because it has not had +# recent activity. It will be closed if no further activity occurs. Thank you +# for your contributions. + +# issues: +# exemptLabels: +# - confirmed \ No newline at end of file From 903d30080d99b1601093b7af5a6db4c154bd7f27 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 3 Sep 2019 01:36:24 -0400 Subject: [PATCH 1435/1555] Revert "Mark as experiemental" This reverts commit 4275312e5174149357283c263e10c45c5552dd4b. --- src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml b/src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml index 2728c8bfdc2..dd220bf564d 100644 --- a/src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml +++ b/src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml @@ -28,7 +28,7 @@ + Description="The base type to use for the client."> From bac5b38c3641582684da353094fa6d1d6dfbf5ae Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 3 Sep 2019 01:38:32 -0400 Subject: [PATCH 1436/1555] Revert "Feedbackg" This reverts commit a0adb5003ce6066b795009cc9f2d3abaca9180b7. --- src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml | 11 ----------- src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets | 4 +--- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml b/src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml index dd220bf564d..66862582dad 100644 --- a/src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml +++ b/src/csharp/Grpc.Tools/build/_grpc/Grpc.CSharp.xml @@ -26,16 +26,5 @@ - - - - - - - - diff --git a/src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets b/src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets index bc78e340e33..493212fe7e5 100644 --- a/src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets +++ b/src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets @@ -38,13 +38,11 @@ <_GrpcOutputOptions>%(Protobuf_Compile._GrpcOutputOptions);no_server + <_GrpcOutputOptions Condition=" '%(Protobuf_Compile.ClientType)' == 'LiteClient' ">%(Protobuf_Compile._GrpcOutputOptions);lite_client <_GrpcOutputOptions>%(Protobuf_Compile._GrpcOutputOptions);no_client - - <_GrpcOutputOptions Condition=" '%(Protobuf_Compile.ClientBaseType)' == 'LiteClientBase' ">%(Protobuf_Compile._GrpcOutputOptions);lite_client - From 0afe3dba92921230ab87b88ad3d62895e40375cb Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 3 Sep 2019 01:39:01 -0400 Subject: [PATCH 1437/1555] Revert "Add MSBuild metadata to set LiteClient for client generation." This reverts commit 9b3c9e3635a360bfe2b7bd8b09e787b5d8f73d11. --- src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets | 1 - 1 file changed, 1 deletion(-) diff --git a/src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets b/src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets index 493212fe7e5..dd01b8183db 100644 --- a/src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets +++ b/src/csharp/Grpc.Tools/build/_grpc/_Grpc.Tools.targets @@ -38,7 +38,6 @@ <_GrpcOutputOptions>%(Protobuf_Compile._GrpcOutputOptions);no_server - <_GrpcOutputOptions Condition=" '%(Protobuf_Compile.ClientType)' == 'LiteClient' ">%(Protobuf_Compile._GrpcOutputOptions);lite_client <_GrpcOutputOptions>%(Protobuf_Compile._GrpcOutputOptions);no_client From 4c34f8352c0d3f02527297de8f7cc8e23eb1c6a8 Mon Sep 17 00:00:00 2001 From: Tim Gates Date: Tue, 3 Sep 2019 20:09:42 +1000 Subject: [PATCH 1438/1555] Fix simple typo: avaiable -> available --- doc/server_side_auth.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/server_side_auth.md b/doc/server_side_auth.md index e425289faa9..5905626fea6 100644 --- a/doc/server_side_auth.md +++ b/doc/server_side_auth.md @@ -2,7 +2,7 @@ Server-side API for Authenticating Clients ========================================== NOTE: This document describes how server-side authentication works in C-core based gRPC implementations only. In gRPC Java and Go, server side authentication is handled differently. -NOTE2: `CallCredentials` class is only valid for secure channels in C-Core. So, for connections under insecure channels, features below might not be avaiable. +NOTE2: `CallCredentials` class is only valid for secure channels in C-Core. So, for connections under insecure channels, features below might not be available. ## AuthContext From 3c5715466fb95a83186277f9e68e818316f9f32f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 3 Sep 2019 17:03:11 +0200 Subject: [PATCH 1439/1555] remove C# workaround for DeadlineExceeded status #2685 --- src/csharp/Grpc.Core.Tests/TimeoutsTest.cs | 10 +++------- .../Grpc.Examples.Tests/MathClientServerTests.cs | 4 +--- src/csharp/Grpc.IntegrationTesting/InteropClient.cs | 3 +-- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/TimeoutsTest.cs b/src/csharp/Grpc.Core.Tests/TimeoutsTest.cs index 55e69a01813..d92a2b9ff72 100644 --- a/src/csharp/Grpc.Core.Tests/TimeoutsTest.cs +++ b/src/csharp/Grpc.Core.Tests/TimeoutsTest.cs @@ -96,8 +96,7 @@ namespace Grpc.Core.Tests }); var ex = Assert.Throws(() => Calls.BlockingUnaryCall(helper.CreateUnaryCall(new CallOptions(deadline: DateTime.MinValue)), "abc")); - // We can't guarantee the status code always DeadlineExceeded. See issue #2685. - Assert.Contains(ex.Status.StatusCode, new[] { StatusCode.DeadlineExceeded, StatusCode.Internal }); + Assert.AreEqual(StatusCode.DeadlineExceeded, ex.Status.StatusCode); } [Test] @@ -110,8 +109,7 @@ namespace Grpc.Core.Tests }); var ex = Assert.Throws(() => Calls.BlockingUnaryCall(helper.CreateUnaryCall(new CallOptions(deadline: DateTime.UtcNow.Add(TimeSpan.FromSeconds(5)))), "abc")); - // We can't guarantee the status code always DeadlineExceeded. See issue #2685. - Assert.Contains(ex.Status.StatusCode, new[] { StatusCode.DeadlineExceeded, StatusCode.Internal }); + Assert.AreEqual(StatusCode.DeadlineExceeded, ex.Status.StatusCode); } [Test] @@ -130,9 +128,7 @@ namespace Grpc.Core.Tests }); var ex = Assert.Throws(() => Calls.BlockingUnaryCall(helper.CreateUnaryCall(new CallOptions(deadline: DateTime.UtcNow.Add(TimeSpan.FromSeconds(5)))), "abc")); - // We can't guarantee the status code always DeadlineExceeded. See issue #2685. - Assert.Contains(ex.Status.StatusCode, new[] { StatusCode.DeadlineExceeded, StatusCode.Internal }); - + Assert.AreEqual(StatusCode.DeadlineExceeded, ex.Status.StatusCode); Assert.IsTrue(await serverReceivedCancellationTcs.Task); } } diff --git a/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs b/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs index ded80ffba5f..6fa27a6b9af 100644 --- a/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs +++ b/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs @@ -136,9 +136,7 @@ namespace Math.Tests deadline: DateTime.UtcNow.AddMilliseconds(500))) { var ex = Assert.ThrowsAsync(async () => await call.ResponseStream.ToListAsync()); - - // We can't guarantee the status code always DeadlineExceeded. See issue #2685. - Assert.Contains(ex.Status.StatusCode, new[] { StatusCode.DeadlineExceeded, StatusCode.Internal }); + Assert.AreEqual(StatusCode.DeadlineExceeded, ex.Status.StatusCode); } } diff --git a/src/csharp/Grpc.IntegrationTesting/InteropClient.cs b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs index 83b0095f7f0..53cd4562ead 100644 --- a/src/csharp/Grpc.IntegrationTesting/InteropClient.cs +++ b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs @@ -476,8 +476,7 @@ namespace Grpc.IntegrationTesting } catch (RpcException ex) { - // We can't guarantee the status code always DeadlineExceeded. See issue #2685. - Assert.Contains(ex.Status.StatusCode, new[] { StatusCode.DeadlineExceeded, StatusCode.Internal }); + Assert.AreEqual(StatusCode.DeadlineExceeded, ex.Status.StatusCode); } } Console.WriteLine("Passed!"); From b28b483628e28b1438652896e705c1164b08b5a0 Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Tue, 3 Sep 2019 09:05:56 -0700 Subject: [PATCH 1440/1555] Assing Nana to next Github rotation --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/ISSUE_TEMPLATE/cleanup_request.md | 2 +- .github/ISSUE_TEMPLATE/feature_request.md | 2 +- .github/pull_request_template.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index e44c8966012..4709997666e 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -2,7 +2,7 @@ name: Report a bug about: Create a report to help us improve labels: kind/bug, priority/P2 -assignees: mhaidrygoog +assignees: nanahpang --- diff --git a/.github/ISSUE_TEMPLATE/cleanup_request.md b/.github/ISSUE_TEMPLATE/cleanup_request.md index 4fe128984b9..4ec33fafb58 100644 --- a/.github/ISSUE_TEMPLATE/cleanup_request.md +++ b/.github/ISSUE_TEMPLATE/cleanup_request.md @@ -2,7 +2,7 @@ name: Request a cleanup about: Suggest a cleanup in our repository labels: kind/internal cleanup -assignees: mhaidrygoog +assignees: nanahpang --- diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 499de024dd4..efa5b1611bb 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -2,7 +2,7 @@ name: Request a feature about: Suggest an idea for this project labels: kind/enhancement -assignees: mhaidrygoog +assignees: nanahpang --- diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index ac8c41a9f26..55d8d600541 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -8,4 +8,4 @@ If you know who should review your pull request, please remove the mentioning be --> -@mhaidrygoog \ No newline at end of file +@nanahpang From 647a9701f715a805da2bcefce49f8757c9dbcc9e Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 3 Sep 2019 09:23:56 -0700 Subject: [PATCH 1441/1555] Update debian:jessie docker to pin bundler version --- tools/dockerfile/distribtest/ruby_jessie_x64/Dockerfile | 2 +- tools/dockerfile/distribtest/ruby_jessie_x86/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/dockerfile/distribtest/ruby_jessie_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_jessie_x64/Dockerfile index 57d6771f9db..077aa16a057 100644 --- a/tools/dockerfile/distribtest/ruby_jessie_x64/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_jessie_x64/Dockerfile @@ -16,4 +16,4 @@ FROM debian:jessie RUN apt-get update && apt-get install -y ruby-full -RUN gem install bundler +RUN gem install bundler -v 1.17.3 --no-document diff --git a/tools/dockerfile/distribtest/ruby_jessie_x86/Dockerfile b/tools/dockerfile/distribtest/ruby_jessie_x86/Dockerfile index 04cfa51069c..48fba1fc2a2 100644 --- a/tools/dockerfile/distribtest/ruby_jessie_x86/Dockerfile +++ b/tools/dockerfile/distribtest/ruby_jessie_x86/Dockerfile @@ -16,4 +16,4 @@ FROM i386/debian:jessie RUN apt-get update && apt-get install -y ruby-full -RUN gem install bundler +RUN gem install bundler -v 1.17.3 --no-document From 49b9fb2b3ca8cc048db476b4b7aedb703dbb1734 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Mon, 12 Aug 2019 16:43:24 -0700 Subject: [PATCH 1442/1555] Enable C++ standard library --- CMakeLists.txt | 1034 --------------------- Makefile | 418 ++++----- config.m4 | 2 + include/grpc/impl/codegen/port_platform.h | 3 +- src/php/ext/grpc/config.m4 | 3 +- src/ruby/ext/grpc/rb_enable_cpp.cc | 22 + templates/CMakeLists.txt.template | 20 - templates/Makefile.template | 4 +- templates/config.m4.template | 2 + 9 files changed, 240 insertions(+), 1268 deletions(-) create mode 100644 src/ruby/ext/grpc/rb_enable_cpp.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index c5cdfff7f56..599f1441583 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,11 +125,6 @@ if(gRPC_BACKWARDS_COMPATIBILITY_MODE) endif() if (_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_IOS) - # C core has C++ source code, but should not depend on libstc++ (for better portability). - # We need to use a few tricks to convince cmake to do that. - # https://stackoverflow.com/questions/15058403/how-to-stop-cmake-from-linking-against-libstdc - set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "") - # Exceptions and RTTI must be off to avoid dependency on libstdc++ set(_gRPC_CORE_NOSTDCXX_FLAGS -fno-exceptions -fno-rtti) else() set(_gRPC_CORE_NOSTDCXX_FLAGS "") @@ -797,12 +792,6 @@ target_include_directories(address_sorting PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(address_sorting PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(address_sorting PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(address_sorting ${_gRPC_BASELIB_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} @@ -851,12 +840,6 @@ target_include_directories(alts_test_util PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(alts_test_util PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(alts_test_util PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(alts_test_util ${_gRPC_SSL_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} @@ -935,12 +918,6 @@ target_include_directories(gpr PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(gpr PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(gpr ${_gRPC_ALLTARGETS_LIBRARIES} ) @@ -1404,12 +1381,6 @@ target_include_directories(grpc PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(grpc PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(grpc ${_gRPC_BASELIB_LIBRARIES} ${_gRPC_SSL_LIBRARIES} @@ -1824,12 +1795,6 @@ target_include_directories(grpc_cronet PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_cronet PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(grpc_cronet PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(grpc_cronet ${_gRPC_BASELIB_LIBRARIES} ${_gRPC_SSL_LIBRARIES} @@ -2181,12 +2146,6 @@ target_include_directories(grpc_test_util PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_test_util PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(grpc_test_util PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(grpc_test_util ${_gRPC_ALLTARGETS_LIBRARIES} gpr @@ -2535,12 +2494,6 @@ target_include_directories(grpc_test_util_unsecure PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_test_util_unsecure PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(grpc_test_util_unsecure PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(grpc_test_util_unsecure ${_gRPC_ALLTARGETS_LIBRARIES} gpr @@ -2929,12 +2882,6 @@ target_include_directories(grpc_unsecure PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_unsecure PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(grpc_unsecure PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(grpc_unsecure ${_gRPC_BASELIB_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} @@ -3032,12 +2979,6 @@ target_include_directories(reconnect_server PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(reconnect_server PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(reconnect_server PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(reconnect_server ${_gRPC_ALLTARGETS_LIBRARIES} test_tcp_server @@ -3080,12 +3021,6 @@ target_include_directories(test_tcp_server PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(test_tcp_server PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(test_tcp_server PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(test_tcp_server ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util @@ -5445,12 +5380,6 @@ target_include_directories(grpc_csharp_ext PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_csharp_ext PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(grpc_csharp_ext PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(grpc_csharp_ext ${_gRPC_ALLTARGETS_LIBRARIES} grpc @@ -5548,12 +5477,6 @@ target_include_directories(bad_ssl_test_server PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(bad_ssl_test_server PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(bad_ssl_test_server PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(bad_ssl_test_server ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util @@ -5674,12 +5597,6 @@ target_include_directories(end2end_tests PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(end2end_tests PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(end2end_tests PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(end2end_tests ${_gRPC_SSL_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} @@ -5800,12 +5717,6 @@ target_include_directories(end2end_nosec_tests PRIVATE ${_gRPC_UPB_INCLUDE_DIR} PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(end2end_nosec_tests PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(end2end_nosec_tests PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() target_link_libraries(end2end_nosec_tests ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util_unsecure @@ -5845,11 +5756,6 @@ target_link_libraries(algorithm_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(algorithm_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(algorithm_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -5881,11 +5787,6 @@ target_link_libraries(alloc_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(alloc_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(alloc_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -5917,11 +5818,6 @@ target_link_libraries(alpn_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(alpn_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(alpn_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -5953,11 +5849,6 @@ target_link_libraries(arena_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(arena_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(arena_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -5989,11 +5880,6 @@ target_link_libraries(avl_test grpc ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(avl_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(avl_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6026,11 +5912,6 @@ target_link_libraries(bad_server_response_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(bad_server_response_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(bad_server_response_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6061,11 +5942,6 @@ target_link_libraries(bin_decoder_test grpc ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(bin_decoder_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(bin_decoder_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6096,11 +5972,6 @@ target_link_libraries(bin_encoder_test grpc ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(bin_encoder_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(bin_encoder_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6133,11 +6004,6 @@ target_link_libraries(buffer_list_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(buffer_list_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(buffer_list_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -6170,11 +6036,6 @@ target_link_libraries(channel_create_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(channel_create_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(channel_create_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) @@ -6204,11 +6065,6 @@ target_link_libraries(check_epollexclusive gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(check_epollexclusive PROPERTIES LINKER_LANGUAGE C) - target_compile_options(check_epollexclusive PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() if (gRPC_BUILD_TESTS) @@ -6239,11 +6095,6 @@ target_link_libraries(chttp2_hpack_encoder_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(chttp2_hpack_encoder_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(chttp2_hpack_encoder_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6275,11 +6126,6 @@ target_link_libraries(chttp2_stream_map_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(chttp2_stream_map_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(chttp2_stream_map_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6311,11 +6157,6 @@ target_link_libraries(chttp2_varint_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(chttp2_varint_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(chttp2_varint_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6348,11 +6189,6 @@ target_link_libraries(close_fd_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(close_fd_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(close_fd_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -6385,11 +6221,6 @@ target_link_libraries(cmdline_test grpc ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(cmdline_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(cmdline_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6421,11 +6252,6 @@ target_link_libraries(combiner_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(combiner_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(combiner_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6457,11 +6283,6 @@ target_link_libraries(compression_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(compression_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(compression_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6493,11 +6314,6 @@ target_link_libraries(concurrent_connectivity_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(concurrent_connectivity_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(concurrent_connectivity_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6529,11 +6345,6 @@ target_link_libraries(connection_refused_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(connection_refused_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(connection_refused_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6565,11 +6376,6 @@ target_link_libraries(dns_resolver_connectivity_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(dns_resolver_connectivity_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(dns_resolver_connectivity_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6601,11 +6407,6 @@ target_link_libraries(dns_resolver_cooldown_using_ares_resolver_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(dns_resolver_cooldown_using_ares_resolver_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(dns_resolver_cooldown_using_ares_resolver_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6637,11 +6438,6 @@ target_link_libraries(dns_resolver_cooldown_using_native_resolver_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(dns_resolver_cooldown_using_native_resolver_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(dns_resolver_cooldown_using_native_resolver_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6673,11 +6469,6 @@ target_link_libraries(dns_resolver_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(dns_resolver_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(dns_resolver_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6710,11 +6501,6 @@ target_link_libraries(dualstack_socket_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(dualstack_socket_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(dualstack_socket_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -6747,11 +6533,6 @@ target_link_libraries(endpoint_pair_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(endpoint_pair_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(endpoint_pair_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6783,11 +6564,6 @@ target_link_libraries(error_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(error_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(error_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6820,11 +6596,6 @@ target_link_libraries(ev_epollex_linux_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(ev_epollex_linux_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(ev_epollex_linux_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -6857,11 +6628,6 @@ target_link_libraries(fake_resolver_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(fake_resolver_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(fake_resolver_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -6895,11 +6661,6 @@ target_link_libraries(fake_transport_security_test grpc ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(fake_transport_security_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(fake_transport_security_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -6933,11 +6694,6 @@ target_link_libraries(fd_conservation_posix_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(fd_conservation_posix_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(fd_conservation_posix_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -6971,11 +6727,6 @@ target_link_libraries(fd_posix_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(fd_posix_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(fd_posix_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -7008,11 +6759,6 @@ target_link_libraries(fling_client gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(fling_client PROPERTIES LINKER_LANGUAGE C) - target_compile_options(fling_client PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7044,11 +6790,6 @@ target_link_libraries(fling_server gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(fling_server PROPERTIES LINKER_LANGUAGE C) - target_compile_options(fling_server PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7081,11 +6822,6 @@ target_link_libraries(fling_stream_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(fling_stream_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(fling_stream_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -7119,11 +6855,6 @@ target_link_libraries(fling_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(fling_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(fling_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -7157,11 +6888,6 @@ target_link_libraries(fork_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(fork_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(fork_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -7195,11 +6921,6 @@ target_link_libraries(goaway_server_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(goaway_server_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(goaway_server_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -7232,11 +6953,6 @@ target_link_libraries(gpr_cpu_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_cpu_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_cpu_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7268,11 +6984,6 @@ target_link_libraries(gpr_env_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_env_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_env_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7304,11 +7015,6 @@ target_link_libraries(gpr_host_port_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_host_port_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_host_port_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7340,11 +7046,6 @@ target_link_libraries(gpr_log_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_log_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_log_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7376,11 +7077,6 @@ target_link_libraries(gpr_manual_constructor_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_manual_constructor_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_manual_constructor_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7412,11 +7108,6 @@ target_link_libraries(gpr_mpscq_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_mpscq_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_mpscq_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7448,11 +7139,6 @@ target_link_libraries(gpr_spinlock_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_spinlock_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_spinlock_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7484,11 +7170,6 @@ target_link_libraries(gpr_string_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_string_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_string_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7520,11 +7201,6 @@ target_link_libraries(gpr_sync_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_sync_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_sync_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7556,11 +7232,6 @@ target_link_libraries(gpr_thd_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_thd_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_thd_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7592,11 +7263,6 @@ target_link_libraries(gpr_time_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_time_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_time_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7628,11 +7294,6 @@ target_link_libraries(gpr_tls_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_tls_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_tls_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7664,11 +7325,6 @@ target_link_libraries(gpr_useful_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(gpr_useful_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(gpr_useful_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7700,11 +7356,6 @@ target_link_libraries(grpc_auth_context_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_auth_context_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_auth_context_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7736,11 +7387,6 @@ target_link_libraries(grpc_b64_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_b64_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_b64_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7772,11 +7418,6 @@ target_link_libraries(grpc_byte_buffer_reader_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_byte_buffer_reader_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_byte_buffer_reader_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7808,11 +7449,6 @@ target_link_libraries(grpc_channel_args_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_channel_args_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_channel_args_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7844,11 +7480,6 @@ target_link_libraries(grpc_channel_stack_builder_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_channel_stack_builder_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_channel_stack_builder_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7880,11 +7511,6 @@ target_link_libraries(grpc_channel_stack_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_channel_stack_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_channel_stack_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7916,11 +7542,6 @@ target_link_libraries(grpc_completion_queue_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_completion_queue_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_completion_queue_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7952,11 +7573,6 @@ target_link_libraries(grpc_completion_queue_threading_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_completion_queue_threading_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_completion_queue_threading_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -7988,11 +7604,6 @@ target_link_libraries(grpc_control_plane_credentials_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_control_plane_credentials_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_control_plane_credentials_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) @@ -8024,11 +7635,6 @@ target_link_libraries(grpc_create_jwt gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_create_jwt PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_create_jwt PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() if (gRPC_BUILD_TESTS) @@ -8059,11 +7665,6 @@ target_link_libraries(grpc_credentials_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_credentials_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_credentials_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8095,11 +7696,6 @@ target_link_libraries(grpc_ipv6_loopback_available_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_ipv6_loopback_available_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_ipv6_loopback_available_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8132,11 +7728,6 @@ target_link_libraries(grpc_json_token_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_json_token_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_json_token_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -8169,11 +7760,6 @@ target_link_libraries(grpc_jwt_verifier_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_jwt_verifier_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_jwt_verifier_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) @@ -8204,11 +7790,6 @@ target_link_libraries(grpc_print_google_default_creds_token gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_print_google_default_creds_token PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_print_google_default_creds_token PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() if (gRPC_BUILD_TESTS) @@ -8239,11 +7820,6 @@ target_link_libraries(grpc_security_connector_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_security_connector_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_security_connector_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8275,11 +7851,6 @@ target_link_libraries(grpc_ssl_credentials_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_ssl_credentials_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_ssl_credentials_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) @@ -8310,11 +7881,6 @@ target_link_libraries(grpc_verify_jwt gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(grpc_verify_jwt PROPERTIES LINKER_LANGUAGE C) - target_compile_options(grpc_verify_jwt PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() if (gRPC_BUILD_TESTS) if(_gRPC_PLATFORM_LINUX) @@ -8347,11 +7913,6 @@ target_link_libraries(handshake_client_ssl gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(handshake_client_ssl PROPERTIES LINKER_LANGUAGE C) - target_compile_options(handshake_client_ssl PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -8387,11 +7948,6 @@ target_link_libraries(handshake_server_ssl gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(handshake_server_ssl PROPERTIES LINKER_LANGUAGE C) - target_compile_options(handshake_server_ssl PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -8427,11 +7983,6 @@ target_link_libraries(handshake_server_with_readahead_handshaker gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(handshake_server_with_readahead_handshaker PROPERTIES LINKER_LANGUAGE C) - target_compile_options(handshake_server_with_readahead_handshaker PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -8466,11 +8017,6 @@ target_link_libraries(handshake_verify_peer_options gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(handshake_verify_peer_options PROPERTIES LINKER_LANGUAGE C) - target_compile_options(handshake_verify_peer_options PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -8502,11 +8048,6 @@ target_link_libraries(histogram_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(histogram_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(histogram_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8538,11 +8079,6 @@ target_link_libraries(hpack_parser_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(hpack_parser_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(hpack_parser_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8574,11 +8110,6 @@ target_link_libraries(hpack_table_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(hpack_table_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(hpack_table_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8610,11 +8141,6 @@ target_link_libraries(http_parser_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(http_parser_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(http_parser_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8646,11 +8172,6 @@ target_link_libraries(httpcli_format_request_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(httpcli_format_request_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(httpcli_format_request_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8683,11 +8204,6 @@ target_link_libraries(httpcli_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(httpcli_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(httpcli_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -8721,11 +8237,6 @@ target_link_libraries(httpscli_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(httpscli_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(httpscli_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -8758,11 +8269,6 @@ target_link_libraries(init_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(init_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(init_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8794,11 +8300,6 @@ target_link_libraries(inproc_callback_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(inproc_callback_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(inproc_callback_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8830,11 +8331,6 @@ target_link_libraries(invalid_call_argument_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(invalid_call_argument_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(invalid_call_argument_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8866,11 +8362,6 @@ target_link_libraries(json_rewrite gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(json_rewrite PROPERTIES LINKER_LANGUAGE C) - target_compile_options(json_rewrite PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8902,11 +8393,6 @@ target_link_libraries(json_rewrite_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(json_rewrite_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(json_rewrite_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8938,11 +8424,6 @@ target_link_libraries(json_stream_error_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(json_stream_error_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(json_stream_error_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -8974,11 +8455,6 @@ target_link_libraries(json_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(json_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(json_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9010,11 +8486,6 @@ target_link_libraries(lame_client_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(lame_client_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(lame_client_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9046,11 +8517,6 @@ target_link_libraries(load_file_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(load_file_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(load_file_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9082,11 +8548,6 @@ target_link_libraries(memory_usage_client gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(memory_usage_client PROPERTIES LINKER_LANGUAGE C) - target_compile_options(memory_usage_client PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9118,11 +8579,6 @@ target_link_libraries(memory_usage_server gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(memory_usage_server PROPERTIES LINKER_LANGUAGE C) - target_compile_options(memory_usage_server PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9155,11 +8611,6 @@ target_link_libraries(memory_usage_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(memory_usage_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(memory_usage_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -9192,11 +8643,6 @@ target_link_libraries(message_compress_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(message_compress_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(message_compress_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9228,11 +8674,6 @@ target_link_libraries(minimal_stack_is_minimal_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(minimal_stack_is_minimal_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(minimal_stack_is_minimal_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9264,11 +8705,6 @@ target_link_libraries(mpmcqueue_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(mpmcqueue_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(mpmcqueue_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9300,11 +8736,6 @@ target_link_libraries(multiple_server_queues_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(multiple_server_queues_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(multiple_server_queues_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9336,11 +8767,6 @@ target_link_libraries(murmur_hash_test grpc_unsecure ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(murmur_hash_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(murmur_hash_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9372,11 +8798,6 @@ target_link_libraries(no_server_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(no_server_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(no_server_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9408,11 +8829,6 @@ target_link_libraries(num_external_connectivity_watchers_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(num_external_connectivity_watchers_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(num_external_connectivity_watchers_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9444,11 +8860,6 @@ target_link_libraries(parse_address_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(parse_address_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(parse_address_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9481,11 +8892,6 @@ target_link_libraries(parse_address_with_named_scope_id_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(parse_address_with_named_scope_id_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(parse_address_with_named_scope_id_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -9518,11 +8924,6 @@ target_link_libraries(percent_encoding_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(percent_encoding_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(percent_encoding_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9555,11 +8956,6 @@ target_link_libraries(resolve_address_using_ares_resolver_posix_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(resolve_address_using_ares_resolver_posix_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(resolve_address_using_ares_resolver_posix_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -9592,11 +8988,6 @@ target_link_libraries(resolve_address_using_ares_resolver_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(resolve_address_using_ares_resolver_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(resolve_address_using_ares_resolver_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9629,11 +9020,6 @@ target_link_libraries(resolve_address_using_native_resolver_posix_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(resolve_address_using_native_resolver_posix_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(resolve_address_using_native_resolver_posix_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -9666,11 +9052,6 @@ target_link_libraries(resolve_address_using_native_resolver_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(resolve_address_using_native_resolver_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(resolve_address_using_native_resolver_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9702,11 +9083,6 @@ target_link_libraries(resource_quota_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(resource_quota_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(resource_quota_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9738,11 +9114,6 @@ target_link_libraries(secure_channel_create_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(secure_channel_create_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(secure_channel_create_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9774,11 +9145,6 @@ target_link_libraries(secure_endpoint_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(secure_endpoint_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(secure_endpoint_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9810,11 +9176,6 @@ target_link_libraries(sequential_connectivity_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(sequential_connectivity_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(sequential_connectivity_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9846,11 +9207,6 @@ target_link_libraries(server_chttp2_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(server_chttp2_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(server_chttp2_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9882,11 +9238,6 @@ target_link_libraries(server_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(server_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(server_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9918,11 +9269,6 @@ target_link_libraries(slice_buffer_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(slice_buffer_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(slice_buffer_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9954,11 +9300,6 @@ target_link_libraries(slice_string_helpers_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(slice_string_helpers_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(slice_string_helpers_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -9990,11 +9331,6 @@ target_link_libraries(slice_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(slice_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(slice_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10026,11 +9362,6 @@ target_link_libraries(sockaddr_resolver_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(sockaddr_resolver_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(sockaddr_resolver_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10062,11 +9393,6 @@ target_link_libraries(sockaddr_utils_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(sockaddr_utils_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(sockaddr_utils_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10099,11 +9425,6 @@ target_link_libraries(socket_utils_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(socket_utils_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(socket_utils_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -10138,11 +9459,6 @@ target_link_libraries(ssl_transport_security_test grpc ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(ssl_transport_security_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(ssl_transport_security_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -10175,11 +9491,6 @@ target_link_libraries(status_conversion_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(status_conversion_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(status_conversion_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10211,11 +9522,6 @@ target_link_libraries(stream_compression_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(stream_compression_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(stream_compression_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10247,11 +9553,6 @@ target_link_libraries(stream_owned_slice_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(stream_owned_slice_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(stream_owned_slice_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10284,11 +9585,6 @@ target_link_libraries(tcp_client_posix_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(tcp_client_posix_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(tcp_client_posix_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -10321,11 +9617,6 @@ target_link_libraries(tcp_client_uv_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(tcp_client_uv_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(tcp_client_uv_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10358,11 +9649,6 @@ target_link_libraries(tcp_posix_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(tcp_posix_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(tcp_posix_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -10396,11 +9682,6 @@ target_link_libraries(tcp_server_posix_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(tcp_server_posix_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(tcp_server_posix_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -10433,11 +9714,6 @@ target_link_libraries(tcp_server_uv_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(tcp_server_uv_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(tcp_server_uv_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10469,11 +9745,6 @@ target_link_libraries(threadpool_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(threadpool_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(threadpool_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10505,11 +9776,6 @@ target_link_libraries(time_averaged_stats_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(time_averaged_stats_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(time_averaged_stats_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10541,11 +9807,6 @@ target_link_libraries(timeout_encoding_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(timeout_encoding_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(timeout_encoding_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10577,11 +9838,6 @@ target_link_libraries(timer_heap_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(timer_heap_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(timer_heap_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10613,11 +9869,6 @@ target_link_libraries(timer_list_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(timer_list_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(timer_list_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10649,11 +9900,6 @@ target_link_libraries(transport_connectivity_state_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(transport_connectivity_state_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(transport_connectivity_state_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10685,11 +9931,6 @@ target_link_libraries(transport_metadata_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(transport_metadata_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(transport_metadata_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -10722,11 +9963,6 @@ target_link_libraries(transport_security_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(transport_security_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(transport_security_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -10760,11 +9996,6 @@ target_link_libraries(udp_server_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(udp_server_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(udp_server_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -10797,11 +10028,6 @@ target_link_libraries(uri_parser_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(uri_parser_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(uri_parser_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18226,11 +17452,6 @@ target_link_libraries(bad_ssl_cert_server gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(bad_ssl_cert_server PROPERTIES LINKER_LANGUAGE C) - target_compile_options(bad_ssl_cert_server PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -18264,11 +17485,6 @@ target_link_libraries(bad_ssl_cert_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(bad_ssl_cert_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(bad_ssl_cert_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -18302,11 +17518,6 @@ target_link_libraries(h2_census_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_census_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_census_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18339,11 +17550,6 @@ target_link_libraries(h2_compress_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_compress_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_compress_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18376,11 +17582,6 @@ target_link_libraries(h2_fakesec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_fakesec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_fakesec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18414,11 +17615,6 @@ target_link_libraries(h2_fd_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_fd_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_fd_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -18452,11 +17648,6 @@ target_link_libraries(h2_full_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_full_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_full_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18490,11 +17681,6 @@ target_link_libraries(h2_full+pipe_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_full+pipe_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_full+pipe_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -18528,11 +17714,6 @@ target_link_libraries(h2_full+trace_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_full+trace_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_full+trace_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18565,11 +17746,6 @@ target_link_libraries(h2_full+workarounds_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_full+workarounds_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_full+workarounds_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18602,11 +17778,6 @@ target_link_libraries(h2_http_proxy_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_http_proxy_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_http_proxy_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18640,11 +17811,6 @@ target_link_libraries(h2_local_ipv4_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_local_ipv4_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_local_ipv4_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -18679,11 +17845,6 @@ target_link_libraries(h2_local_ipv6_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_local_ipv6_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_local_ipv6_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -18718,11 +17879,6 @@ target_link_libraries(h2_local_uds_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_local_uds_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_local_uds_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -18756,11 +17912,6 @@ target_link_libraries(h2_oauth2_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_oauth2_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_oauth2_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18793,11 +17944,6 @@ target_link_libraries(h2_proxy_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_proxy_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_proxy_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18830,11 +17976,6 @@ target_link_libraries(h2_sockpair_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_sockpair_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_sockpair_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18867,11 +18008,6 @@ target_link_libraries(h2_sockpair+trace_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_sockpair+trace_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_sockpair+trace_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18904,11 +18040,6 @@ target_link_libraries(h2_sockpair_1byte_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_sockpair_1byte_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_sockpair_1byte_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18941,11 +18072,6 @@ target_link_libraries(h2_spiffe_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_spiffe_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_spiffe_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -18978,11 +18104,6 @@ target_link_libraries(h2_ssl_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_ssl_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_ssl_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19015,11 +18136,6 @@ target_link_libraries(h2_ssl_cred_reload_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_ssl_cred_reload_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_ssl_cred_reload_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19052,11 +18168,6 @@ target_link_libraries(h2_ssl_proxy_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_ssl_proxy_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_ssl_proxy_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19090,11 +18201,6 @@ target_link_libraries(h2_uds_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_uds_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_uds_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -19128,11 +18234,6 @@ target_link_libraries(inproc_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(inproc_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(inproc_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19165,11 +18266,6 @@ target_link_libraries(h2_census_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_census_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_census_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19202,11 +18298,6 @@ target_link_libraries(h2_compress_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_compress_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_compress_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19240,11 +18331,6 @@ target_link_libraries(h2_fd_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_fd_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_fd_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -19278,11 +18364,6 @@ target_link_libraries(h2_full_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_full_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_full_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19316,11 +18397,6 @@ target_link_libraries(h2_full+pipe_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_full+pipe_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_full+pipe_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -19354,11 +18430,6 @@ target_link_libraries(h2_full+trace_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_full+trace_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_full+trace_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19391,11 +18462,6 @@ target_link_libraries(h2_full+workarounds_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_full+workarounds_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_full+workarounds_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19428,11 +18494,6 @@ target_link_libraries(h2_http_proxy_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_http_proxy_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_http_proxy_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19465,11 +18526,6 @@ target_link_libraries(h2_proxy_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_proxy_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_proxy_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19502,11 +18558,6 @@ target_link_libraries(h2_sockpair_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_sockpair_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_sockpair_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19539,11 +18590,6 @@ target_link_libraries(h2_sockpair+trace_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_sockpair+trace_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_sockpair+trace_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19576,11 +18622,6 @@ target_link_libraries(h2_sockpair_1byte_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_sockpair_1byte_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_sockpair_1byte_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19614,11 +18655,6 @@ target_link_libraries(h2_uds_nosec_test gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(h2_uds_nosec_test PROPERTIES LINKER_LANGUAGE C) - target_compile_options(h2_uds_nosec_test PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif() endif (gRPC_BUILD_TESTS) @@ -19960,11 +18996,6 @@ target_link_libraries(alts_credentials_fuzzer_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(alts_credentials_fuzzer_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(alts_credentials_fuzzer_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -19997,11 +19028,6 @@ target_link_libraries(api_fuzzer_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(api_fuzzer_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(api_fuzzer_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20034,11 +19060,6 @@ target_link_libraries(client_fuzzer_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(client_fuzzer_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(client_fuzzer_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20071,11 +19092,6 @@ target_link_libraries(hpack_parser_fuzzer_test_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(hpack_parser_fuzzer_test_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(hpack_parser_fuzzer_test_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20108,11 +19124,6 @@ target_link_libraries(http_request_fuzzer_test_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(http_request_fuzzer_test_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(http_request_fuzzer_test_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20145,11 +19156,6 @@ target_link_libraries(http_response_fuzzer_test_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(http_response_fuzzer_test_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(http_response_fuzzer_test_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20182,11 +19188,6 @@ target_link_libraries(json_fuzzer_test_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(json_fuzzer_test_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(json_fuzzer_test_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20219,11 +19220,6 @@ target_link_libraries(nanopb_fuzzer_response_test_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(nanopb_fuzzer_response_test_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(nanopb_fuzzer_response_test_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20256,11 +19252,6 @@ target_link_libraries(nanopb_fuzzer_serverlist_test_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(nanopb_fuzzer_serverlist_test_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(nanopb_fuzzer_serverlist_test_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20293,11 +19284,6 @@ target_link_libraries(percent_decode_fuzzer_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(percent_decode_fuzzer_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(percent_decode_fuzzer_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20330,11 +19316,6 @@ target_link_libraries(percent_encode_fuzzer_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(percent_encode_fuzzer_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(percent_encode_fuzzer_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20367,11 +19348,6 @@ target_link_libraries(server_fuzzer_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(server_fuzzer_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(server_fuzzer_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20404,11 +19380,6 @@ target_link_libraries(ssl_server_fuzzer_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(ssl_server_fuzzer_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(ssl_server_fuzzer_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -20441,11 +19412,6 @@ target_link_libraries(uri_fuzzer_test_one_entry gpr ) - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(uri_fuzzer_test_one_entry PROPERTIES LINKER_LANGUAGE C) - target_compile_options(uri_fuzzer_test_one_entry PRIVATE $<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() endif (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index 4ebf5b36cf8..9ac8955d33c 100644 --- a/Makefile +++ b/Makefile @@ -3339,15 +3339,15 @@ ifeq ($(SYSTEM),MINGW32) $(LIBDIR)/$(CONFIG)/address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBADDRESS_SORTING_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/address_sorting$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/address_sorting$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBADDRESS_SORTING_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` ifeq ($(SYSTEM),Darwin) - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libaddress_sorting.so.8 -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libaddress_sorting.so.8 -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).so.8 $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).so endif @@ -3535,15 +3535,15 @@ ifeq ($(SYSTEM),MINGW32) $(LIBDIR)/$(CONFIG)/gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGPR_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/gpr$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/gpr$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGPR_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` ifeq ($(SYSTEM),Darwin) - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgpr.so.8 -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgpr.so.8 -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so.8 $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so endif @@ -3997,15 +3997,15 @@ ifeq ($(SYSTEM),MINGW32) $(LIBDIR)/$(CONFIG)/grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` ifeq ($(SYSTEM),Darwin) - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.8 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.8 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so.8 $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so endif @@ -4395,15 +4395,15 @@ ifeq ($(SYSTEM),MINGW32) $(LIBDIR)/$(CONFIG)/grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_CRONET_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_cronet$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_cronet$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_CRONET_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` ifeq ($(SYSTEM),Darwin) - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_cronet.so.8 -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_cronet.so.8 -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).so.8 $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).so endif @@ -5438,15 +5438,15 @@ ifeq ($(SYSTEM),MINGW32) $(LIBDIR)/$(CONFIG)/grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_UNSECURE_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_unsecure$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_unsecure$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_UNSECURE_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` ifeq ($(SYSTEM),Darwin) - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_unsecure.so.8 -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_unsecure.so.8 -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so.8 $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so endif @@ -7679,15 +7679,15 @@ ifeq ($(SYSTEM),MINGW32) $(LIBDIR)/$(CONFIG)/grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP): $(LIBGRPC_CSHARP_EXT_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_csharp_ext$(SHARED_VERSION_CSHARP).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_csharp_ext$(SHARED_VERSION_CSHARP).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP): $(LIBGRPC_CSHARP_EXT_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` ifeq ($(SYSTEM),Darwin) - $(Q) $(LD) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_csharp_ext.so.2 -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) + $(Q) $(LDXX) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_csharp_ext.so.2 -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(LDLIBS) $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).so.2 $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).so endif @@ -8525,7 +8525,7 @@ else $(BINDIR)/$(CONFIG)/algorithm_test: $(ALGORITHM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(ALGORITHM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/algorithm_test + $(Q) $(LDXX) $(LDFLAGS) $(ALGORITHM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/algorithm_test endif @@ -8557,7 +8557,7 @@ else $(BINDIR)/$(CONFIG)/alloc_test: $(ALLOC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(ALLOC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/alloc_test + $(Q) $(LDXX) $(LDFLAGS) $(ALLOC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/alloc_test endif @@ -8589,7 +8589,7 @@ else $(BINDIR)/$(CONFIG)/alpn_test: $(ALPN_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(ALPN_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/alpn_test + $(Q) $(LDXX) $(LDFLAGS) $(ALPN_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/alpn_test endif @@ -8685,7 +8685,7 @@ else $(BINDIR)/$(CONFIG)/arena_test: $(ARENA_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(ARENA_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/arena_test + $(Q) $(LDXX) $(LDFLAGS) $(ARENA_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/arena_test endif @@ -8717,7 +8717,7 @@ else $(BINDIR)/$(CONFIG)/avl_test: $(AVL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(AVL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/avl_test + $(Q) $(LDXX) $(LDFLAGS) $(AVL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/avl_test endif @@ -8749,7 +8749,7 @@ else $(BINDIR)/$(CONFIG)/bad_server_response_test: $(BAD_SERVER_RESPONSE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libtest_tcp_server.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(BAD_SERVER_RESPONSE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libtest_tcp_server.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bad_server_response_test + $(Q) $(LDXX) $(LDFLAGS) $(BAD_SERVER_RESPONSE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libtest_tcp_server.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bad_server_response_test endif @@ -8781,7 +8781,7 @@ else $(BINDIR)/$(CONFIG)/bin_decoder_test: $(BIN_DECODER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(BIN_DECODER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bin_decoder_test + $(Q) $(LDXX) $(LDFLAGS) $(BIN_DECODER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bin_decoder_test endif @@ -8813,7 +8813,7 @@ else $(BINDIR)/$(CONFIG)/bin_encoder_test: $(BIN_ENCODER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(BIN_ENCODER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bin_encoder_test + $(Q) $(LDXX) $(LDFLAGS) $(BIN_ENCODER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bin_encoder_test endif @@ -8845,7 +8845,7 @@ else $(BINDIR)/$(CONFIG)/buffer_list_test: $(BUFFER_LIST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(BUFFER_LIST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/buffer_list_test + $(Q) $(LDXX) $(LDFLAGS) $(BUFFER_LIST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/buffer_list_test endif @@ -8877,7 +8877,7 @@ else $(BINDIR)/$(CONFIG)/channel_create_test: $(CHANNEL_CREATE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CHANNEL_CREATE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/channel_create_test + $(Q) $(LDXX) $(LDFLAGS) $(CHANNEL_CREATE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/channel_create_test endif @@ -8909,7 +8909,7 @@ else $(BINDIR)/$(CONFIG)/check_epollexclusive: $(CHECK_EPOLLEXCLUSIVE_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CHECK_EPOLLEXCLUSIVE_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/check_epollexclusive + $(Q) $(LDXX) $(LDFLAGS) $(CHECK_EPOLLEXCLUSIVE_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/check_epollexclusive endif @@ -8941,7 +8941,7 @@ else $(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test: $(CHTTP2_HPACK_ENCODER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CHTTP2_HPACK_ENCODER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test + $(Q) $(LDXX) $(LDFLAGS) $(CHTTP2_HPACK_ENCODER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test endif @@ -8973,7 +8973,7 @@ else $(BINDIR)/$(CONFIG)/chttp2_stream_map_test: $(CHTTP2_STREAM_MAP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CHTTP2_STREAM_MAP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/chttp2_stream_map_test + $(Q) $(LDXX) $(LDFLAGS) $(CHTTP2_STREAM_MAP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/chttp2_stream_map_test endif @@ -9005,7 +9005,7 @@ else $(BINDIR)/$(CONFIG)/chttp2_varint_test: $(CHTTP2_VARINT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CHTTP2_VARINT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/chttp2_varint_test + $(Q) $(LDXX) $(LDFLAGS) $(CHTTP2_VARINT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/chttp2_varint_test endif @@ -9069,7 +9069,7 @@ else $(BINDIR)/$(CONFIG)/close_fd_test: $(CLOSE_FD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CLOSE_FD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/close_fd_test + $(Q) $(LDXX) $(LDFLAGS) $(CLOSE_FD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/close_fd_test endif @@ -9101,7 +9101,7 @@ else $(BINDIR)/$(CONFIG)/cmdline_test: $(CMDLINE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CMDLINE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/cmdline_test + $(Q) $(LDXX) $(LDFLAGS) $(CMDLINE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/cmdline_test endif @@ -9133,7 +9133,7 @@ else $(BINDIR)/$(CONFIG)/combiner_test: $(COMBINER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(COMBINER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/combiner_test + $(Q) $(LDXX) $(LDFLAGS) $(COMBINER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/combiner_test endif @@ -9165,7 +9165,7 @@ else $(BINDIR)/$(CONFIG)/compression_test: $(COMPRESSION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(COMPRESSION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/compression_test + $(Q) $(LDXX) $(LDFLAGS) $(COMPRESSION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/compression_test endif @@ -9197,7 +9197,7 @@ else $(BINDIR)/$(CONFIG)/concurrent_connectivity_test: $(CONCURRENT_CONNECTIVITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CONCURRENT_CONNECTIVITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/concurrent_connectivity_test + $(Q) $(LDXX) $(LDFLAGS) $(CONCURRENT_CONNECTIVITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/concurrent_connectivity_test endif @@ -9229,7 +9229,7 @@ else $(BINDIR)/$(CONFIG)/connection_refused_test: $(CONNECTION_REFUSED_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CONNECTION_REFUSED_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/connection_refused_test + $(Q) $(LDXX) $(LDFLAGS) $(CONNECTION_REFUSED_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/connection_refused_test endif @@ -9261,7 +9261,7 @@ else $(BINDIR)/$(CONFIG)/dns_resolver_connectivity_test: $(DNS_RESOLVER_CONNECTIVITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(DNS_RESOLVER_CONNECTIVITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dns_resolver_connectivity_test + $(Q) $(LDXX) $(LDFLAGS) $(DNS_RESOLVER_CONNECTIVITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dns_resolver_connectivity_test endif @@ -9293,7 +9293,7 @@ else $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_ares_resolver_test: $(DNS_RESOLVER_COOLDOWN_USING_ARES_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(DNS_RESOLVER_COOLDOWN_USING_ARES_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_ares_resolver_test + $(Q) $(LDXX) $(LDFLAGS) $(DNS_RESOLVER_COOLDOWN_USING_ARES_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_ares_resolver_test endif @@ -9325,7 +9325,7 @@ else $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_native_resolver_test: $(DNS_RESOLVER_COOLDOWN_USING_NATIVE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(DNS_RESOLVER_COOLDOWN_USING_NATIVE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_native_resolver_test + $(Q) $(LDXX) $(LDFLAGS) $(DNS_RESOLVER_COOLDOWN_USING_NATIVE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dns_resolver_cooldown_using_native_resolver_test endif @@ -9357,7 +9357,7 @@ else $(BINDIR)/$(CONFIG)/dns_resolver_test: $(DNS_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(DNS_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dns_resolver_test + $(Q) $(LDXX) $(LDFLAGS) $(DNS_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dns_resolver_test endif @@ -9389,7 +9389,7 @@ else $(BINDIR)/$(CONFIG)/dualstack_socket_test: $(DUALSTACK_SOCKET_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(DUALSTACK_SOCKET_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dualstack_socket_test + $(Q) $(LDXX) $(LDFLAGS) $(DUALSTACK_SOCKET_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/dualstack_socket_test endif @@ -9421,7 +9421,7 @@ else $(BINDIR)/$(CONFIG)/endpoint_pair_test: $(ENDPOINT_PAIR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(ENDPOINT_PAIR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/endpoint_pair_test + $(Q) $(LDXX) $(LDFLAGS) $(ENDPOINT_PAIR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/endpoint_pair_test endif @@ -9453,7 +9453,7 @@ else $(BINDIR)/$(CONFIG)/error_test: $(ERROR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(ERROR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/error_test + $(Q) $(LDXX) $(LDFLAGS) $(ERROR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/error_test endif @@ -9485,7 +9485,7 @@ else $(BINDIR)/$(CONFIG)/ev_epollex_linux_test: $(EV_EPOLLEX_LINUX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(EV_EPOLLEX_LINUX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/ev_epollex_linux_test + $(Q) $(LDXX) $(LDFLAGS) $(EV_EPOLLEX_LINUX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/ev_epollex_linux_test endif @@ -9517,7 +9517,7 @@ else $(BINDIR)/$(CONFIG)/fake_resolver_test: $(FAKE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(FAKE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fake_resolver_test + $(Q) $(LDXX) $(LDFLAGS) $(FAKE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fake_resolver_test endif @@ -9550,7 +9550,7 @@ else $(BINDIR)/$(CONFIG)/fake_transport_security_test: $(FAKE_TRANSPORT_SECURITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(FAKE_TRANSPORT_SECURITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fake_transport_security_test + $(Q) $(LDXX) $(LDFLAGS) $(FAKE_TRANSPORT_SECURITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fake_transport_security_test endif @@ -9584,7 +9584,7 @@ else $(BINDIR)/$(CONFIG)/fd_conservation_posix_test: $(FD_CONSERVATION_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(FD_CONSERVATION_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fd_conservation_posix_test + $(Q) $(LDXX) $(LDFLAGS) $(FD_CONSERVATION_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fd_conservation_posix_test endif @@ -9616,7 +9616,7 @@ else $(BINDIR)/$(CONFIG)/fd_posix_test: $(FD_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(FD_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fd_posix_test + $(Q) $(LDXX) $(LDFLAGS) $(FD_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fd_posix_test endif @@ -9648,7 +9648,7 @@ else $(BINDIR)/$(CONFIG)/fling_client: $(FLING_CLIENT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(FLING_CLIENT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fling_client + $(Q) $(LDXX) $(LDFLAGS) $(FLING_CLIENT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fling_client endif @@ -9680,7 +9680,7 @@ else $(BINDIR)/$(CONFIG)/fling_server: $(FLING_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(FLING_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fling_server + $(Q) $(LDXX) $(LDFLAGS) $(FLING_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fling_server endif @@ -9712,7 +9712,7 @@ else $(BINDIR)/$(CONFIG)/fling_stream_test: $(FLING_STREAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(FLING_STREAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fling_stream_test + $(Q) $(LDXX) $(LDFLAGS) $(FLING_STREAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fling_stream_test endif @@ -9744,7 +9744,7 @@ else $(BINDIR)/$(CONFIG)/fling_test: $(FLING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(FLING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fling_test + $(Q) $(LDXX) $(LDFLAGS) $(FLING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fling_test endif @@ -9776,7 +9776,7 @@ else $(BINDIR)/$(CONFIG)/fork_test: $(FORK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(FORK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fork_test + $(Q) $(LDXX) $(LDFLAGS) $(FORK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/fork_test endif @@ -9808,7 +9808,7 @@ else $(BINDIR)/$(CONFIG)/goaway_server_test: $(GOAWAY_SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GOAWAY_SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/goaway_server_test + $(Q) $(LDXX) $(LDFLAGS) $(GOAWAY_SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/goaway_server_test endif @@ -9840,7 +9840,7 @@ else $(BINDIR)/$(CONFIG)/gpr_cpu_test: $(GPR_CPU_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_CPU_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_cpu_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_CPU_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_cpu_test endif @@ -9872,7 +9872,7 @@ else $(BINDIR)/$(CONFIG)/gpr_env_test: $(GPR_ENV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_ENV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_env_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_ENV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_env_test endif @@ -9904,7 +9904,7 @@ else $(BINDIR)/$(CONFIG)/gpr_host_port_test: $(GPR_HOST_PORT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_HOST_PORT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_host_port_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_HOST_PORT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_host_port_test endif @@ -9936,7 +9936,7 @@ else $(BINDIR)/$(CONFIG)/gpr_log_test: $(GPR_LOG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_LOG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_log_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_LOG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_log_test endif @@ -9968,7 +9968,7 @@ else $(BINDIR)/$(CONFIG)/gpr_manual_constructor_test: $(GPR_MANUAL_CONSTRUCTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_MANUAL_CONSTRUCTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_manual_constructor_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_MANUAL_CONSTRUCTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_manual_constructor_test endif @@ -10000,7 +10000,7 @@ else $(BINDIR)/$(CONFIG)/gpr_mpscq_test: $(GPR_MPSCQ_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_MPSCQ_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_mpscq_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_MPSCQ_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_mpscq_test endif @@ -10032,7 +10032,7 @@ else $(BINDIR)/$(CONFIG)/gpr_spinlock_test: $(GPR_SPINLOCK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_SPINLOCK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_spinlock_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_SPINLOCK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_spinlock_test endif @@ -10064,7 +10064,7 @@ else $(BINDIR)/$(CONFIG)/gpr_string_test: $(GPR_STRING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_STRING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_string_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_STRING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_string_test endif @@ -10096,7 +10096,7 @@ else $(BINDIR)/$(CONFIG)/gpr_sync_test: $(GPR_SYNC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_SYNC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_sync_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_SYNC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_sync_test endif @@ -10128,7 +10128,7 @@ else $(BINDIR)/$(CONFIG)/gpr_thd_test: $(GPR_THD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_THD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_thd_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_THD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_thd_test endif @@ -10160,7 +10160,7 @@ else $(BINDIR)/$(CONFIG)/gpr_time_test: $(GPR_TIME_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_TIME_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_time_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_TIME_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_time_test endif @@ -10192,7 +10192,7 @@ else $(BINDIR)/$(CONFIG)/gpr_tls_test: $(GPR_TLS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_TLS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_tls_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_TLS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_tls_test endif @@ -10224,7 +10224,7 @@ else $(BINDIR)/$(CONFIG)/gpr_useful_test: $(GPR_USEFUL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_USEFUL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_useful_test + $(Q) $(LDXX) $(LDFLAGS) $(GPR_USEFUL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_useful_test endif @@ -10256,7 +10256,7 @@ else $(BINDIR)/$(CONFIG)/grpc_auth_context_test: $(GRPC_AUTH_CONTEXT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_AUTH_CONTEXT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_auth_context_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_AUTH_CONTEXT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_auth_context_test endif @@ -10288,7 +10288,7 @@ else $(BINDIR)/$(CONFIG)/grpc_b64_test: $(GRPC_B64_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_B64_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_b64_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_B64_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_b64_test endif @@ -10320,7 +10320,7 @@ else $(BINDIR)/$(CONFIG)/grpc_byte_buffer_reader_test: $(GRPC_BYTE_BUFFER_READER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_BYTE_BUFFER_READER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_byte_buffer_reader_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_BYTE_BUFFER_READER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_byte_buffer_reader_test endif @@ -10352,7 +10352,7 @@ else $(BINDIR)/$(CONFIG)/grpc_channel_args_test: $(GRPC_CHANNEL_ARGS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_CHANNEL_ARGS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_channel_args_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_CHANNEL_ARGS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_channel_args_test endif @@ -10384,7 +10384,7 @@ else $(BINDIR)/$(CONFIG)/grpc_channel_stack_builder_test: $(GRPC_CHANNEL_STACK_BUILDER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_CHANNEL_STACK_BUILDER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_channel_stack_builder_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_CHANNEL_STACK_BUILDER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_channel_stack_builder_test endif @@ -10416,7 +10416,7 @@ else $(BINDIR)/$(CONFIG)/grpc_channel_stack_test: $(GRPC_CHANNEL_STACK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_CHANNEL_STACK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_channel_stack_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_CHANNEL_STACK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_channel_stack_test endif @@ -10448,7 +10448,7 @@ else $(BINDIR)/$(CONFIG)/grpc_completion_queue_test: $(GRPC_COMPLETION_QUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_COMPLETION_QUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_completion_queue_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_COMPLETION_QUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_completion_queue_test endif @@ -10480,7 +10480,7 @@ else $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test: $(GRPC_COMPLETION_QUEUE_THREADING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_COMPLETION_QUEUE_THREADING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_COMPLETION_QUEUE_THREADING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test endif @@ -10512,7 +10512,7 @@ else $(BINDIR)/$(CONFIG)/grpc_control_plane_credentials_test: $(GRPC_CONTROL_PLANE_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_CONTROL_PLANE_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_control_plane_credentials_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_CONTROL_PLANE_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_control_plane_credentials_test endif @@ -10545,7 +10545,7 @@ else $(BINDIR)/$(CONFIG)/grpc_create_jwt: $(GRPC_CREATE_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_CREATE_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_create_jwt + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_CREATE_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_create_jwt endif @@ -10579,7 +10579,7 @@ else $(BINDIR)/$(CONFIG)/grpc_credentials_test: $(GRPC_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_credentials_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_credentials_test endif @@ -10611,7 +10611,7 @@ else $(BINDIR)/$(CONFIG)/grpc_ipv6_loopback_available_test: $(GRPC_IPV6_LOOPBACK_AVAILABLE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_IPV6_LOOPBACK_AVAILABLE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_ipv6_loopback_available_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_IPV6_LOOPBACK_AVAILABLE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_ipv6_loopback_available_test endif @@ -10643,7 +10643,7 @@ else $(BINDIR)/$(CONFIG)/grpc_json_token_test: $(GRPC_JSON_TOKEN_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_JSON_TOKEN_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_json_token_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_JSON_TOKEN_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_json_token_test endif @@ -10675,7 +10675,7 @@ else $(BINDIR)/$(CONFIG)/grpc_jwt_verifier_test: $(GRPC_JWT_VERIFIER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_JWT_VERIFIER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_jwt_verifier_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_JWT_VERIFIER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_jwt_verifier_test endif @@ -10708,7 +10708,7 @@ else $(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token: $(GRPC_PRINT_GOOGLE_DEFAULT_CREDS_TOKEN_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_PRINT_GOOGLE_DEFAULT_CREDS_TOKEN_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_PRINT_GOOGLE_DEFAULT_CREDS_TOKEN_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token endif @@ -10742,7 +10742,7 @@ else $(BINDIR)/$(CONFIG)/grpc_security_connector_test: $(GRPC_SECURITY_CONNECTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_SECURITY_CONNECTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_security_connector_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_SECURITY_CONNECTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_security_connector_test endif @@ -10774,7 +10774,7 @@ else $(BINDIR)/$(CONFIG)/grpc_ssl_credentials_test: $(GRPC_SSL_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_SSL_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_ssl_credentials_test + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_SSL_CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_ssl_credentials_test endif @@ -10807,7 +10807,7 @@ else $(BINDIR)/$(CONFIG)/grpc_verify_jwt: $(GRPC_VERIFY_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_VERIFY_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_verify_jwt + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_VERIFY_JWT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_verify_jwt endif @@ -10841,7 +10841,7 @@ else $(BINDIR)/$(CONFIG)/handshake_client_ssl: $(HANDSHAKE_CLIENT_SSL_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HANDSHAKE_CLIENT_SSL_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/handshake_client_ssl + $(Q) $(LDXX) $(LDFLAGS) $(HANDSHAKE_CLIENT_SSL_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/handshake_client_ssl endif @@ -10874,7 +10874,7 @@ else $(BINDIR)/$(CONFIG)/handshake_server_ssl: $(HANDSHAKE_SERVER_SSL_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HANDSHAKE_SERVER_SSL_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/handshake_server_ssl + $(Q) $(LDXX) $(LDFLAGS) $(HANDSHAKE_SERVER_SSL_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/handshake_server_ssl endif @@ -10909,7 +10909,7 @@ else $(BINDIR)/$(CONFIG)/handshake_server_with_readahead_handshaker: $(HANDSHAKE_SERVER_WITH_READAHEAD_HANDSHAKER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HANDSHAKE_SERVER_WITH_READAHEAD_HANDSHAKER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/handshake_server_with_readahead_handshaker + $(Q) $(LDXX) $(LDFLAGS) $(HANDSHAKE_SERVER_WITH_READAHEAD_HANDSHAKER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/handshake_server_with_readahead_handshaker endif @@ -10943,7 +10943,7 @@ else $(BINDIR)/$(CONFIG)/handshake_verify_peer_options: $(HANDSHAKE_VERIFY_PEER_OPTIONS_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HANDSHAKE_VERIFY_PEER_OPTIONS_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/handshake_verify_peer_options + $(Q) $(LDXX) $(LDFLAGS) $(HANDSHAKE_VERIFY_PEER_OPTIONS_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/handshake_verify_peer_options endif @@ -10975,7 +10975,7 @@ else $(BINDIR)/$(CONFIG)/histogram_test: $(HISTOGRAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HISTOGRAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/histogram_test + $(Q) $(LDXX) $(LDFLAGS) $(HISTOGRAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/histogram_test endif @@ -11039,7 +11039,7 @@ else $(BINDIR)/$(CONFIG)/hpack_parser_test: $(HPACK_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HPACK_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/hpack_parser_test + $(Q) $(LDXX) $(LDFLAGS) $(HPACK_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/hpack_parser_test endif @@ -11071,7 +11071,7 @@ else $(BINDIR)/$(CONFIG)/hpack_table_test: $(HPACK_TABLE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HPACK_TABLE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/hpack_table_test + $(Q) $(LDXX) $(LDFLAGS) $(HPACK_TABLE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/hpack_table_test endif @@ -11103,7 +11103,7 @@ else $(BINDIR)/$(CONFIG)/http_parser_test: $(HTTP_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HTTP_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/http_parser_test + $(Q) $(LDXX) $(LDFLAGS) $(HTTP_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/http_parser_test endif @@ -11199,7 +11199,7 @@ else $(BINDIR)/$(CONFIG)/httpcli_format_request_test: $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpcli_format_request_test + $(Q) $(LDXX) $(LDFLAGS) $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpcli_format_request_test endif @@ -11231,7 +11231,7 @@ else $(BINDIR)/$(CONFIG)/httpcli_test: $(HTTPCLI_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HTTPCLI_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpcli_test + $(Q) $(LDXX) $(LDFLAGS) $(HTTPCLI_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpcli_test endif @@ -11263,7 +11263,7 @@ else $(BINDIR)/$(CONFIG)/httpscli_test: $(HTTPSCLI_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HTTPSCLI_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpscli_test + $(Q) $(LDXX) $(LDFLAGS) $(HTTPSCLI_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpscli_test endif @@ -11295,7 +11295,7 @@ else $(BINDIR)/$(CONFIG)/init_test: $(INIT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(INIT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/init_test + $(Q) $(LDXX) $(LDFLAGS) $(INIT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/init_test endif @@ -11327,7 +11327,7 @@ else $(BINDIR)/$(CONFIG)/inproc_callback_test: $(INPROC_CALLBACK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(INPROC_CALLBACK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/inproc_callback_test + $(Q) $(LDXX) $(LDFLAGS) $(INPROC_CALLBACK_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/inproc_callback_test endif @@ -11359,7 +11359,7 @@ else $(BINDIR)/$(CONFIG)/invalid_call_argument_test: $(INVALID_CALL_ARGUMENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(INVALID_CALL_ARGUMENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/invalid_call_argument_test + $(Q) $(LDXX) $(LDFLAGS) $(INVALID_CALL_ARGUMENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/invalid_call_argument_test endif @@ -11423,7 +11423,7 @@ else $(BINDIR)/$(CONFIG)/json_rewrite: $(JSON_REWRITE_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(JSON_REWRITE_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_rewrite + $(Q) $(LDXX) $(LDFLAGS) $(JSON_REWRITE_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_rewrite endif @@ -11455,7 +11455,7 @@ else $(BINDIR)/$(CONFIG)/json_rewrite_test: $(JSON_REWRITE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(JSON_REWRITE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_rewrite_test + $(Q) $(LDXX) $(LDFLAGS) $(JSON_REWRITE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_rewrite_test endif @@ -11487,7 +11487,7 @@ else $(BINDIR)/$(CONFIG)/json_stream_error_test: $(JSON_STREAM_ERROR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(JSON_STREAM_ERROR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_stream_error_test + $(Q) $(LDXX) $(LDFLAGS) $(JSON_STREAM_ERROR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_stream_error_test endif @@ -11519,7 +11519,7 @@ else $(BINDIR)/$(CONFIG)/json_test: $(JSON_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(JSON_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_test + $(Q) $(LDXX) $(LDFLAGS) $(JSON_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_test endif @@ -11551,7 +11551,7 @@ else $(BINDIR)/$(CONFIG)/lame_client_test: $(LAME_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(LAME_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/lame_client_test + $(Q) $(LDXX) $(LDFLAGS) $(LAME_CLIENT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/lame_client_test endif @@ -11583,7 +11583,7 @@ else $(BINDIR)/$(CONFIG)/load_file_test: $(LOAD_FILE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(LOAD_FILE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/load_file_test + $(Q) $(LDXX) $(LDFLAGS) $(LOAD_FILE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/load_file_test endif @@ -11615,7 +11615,7 @@ else $(BINDIR)/$(CONFIG)/low_level_ping_pong_benchmark: $(LOW_LEVEL_PING_PONG_BENCHMARK_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(LOW_LEVEL_PING_PONG_BENCHMARK_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/low_level_ping_pong_benchmark + $(Q) $(LDXX) $(LDFLAGS) $(LOW_LEVEL_PING_PONG_BENCHMARK_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/low_level_ping_pong_benchmark endif @@ -11647,7 +11647,7 @@ else $(BINDIR)/$(CONFIG)/memory_usage_client: $(MEMORY_USAGE_CLIENT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(MEMORY_USAGE_CLIENT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/memory_usage_client + $(Q) $(LDXX) $(LDFLAGS) $(MEMORY_USAGE_CLIENT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/memory_usage_client endif @@ -11679,7 +11679,7 @@ else $(BINDIR)/$(CONFIG)/memory_usage_server: $(MEMORY_USAGE_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(MEMORY_USAGE_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/memory_usage_server + $(Q) $(LDXX) $(LDFLAGS) $(MEMORY_USAGE_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/memory_usage_server endif @@ -11711,7 +11711,7 @@ else $(BINDIR)/$(CONFIG)/memory_usage_test: $(MEMORY_USAGE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(MEMORY_USAGE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/memory_usage_test + $(Q) $(LDXX) $(LDFLAGS) $(MEMORY_USAGE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/memory_usage_test endif @@ -11743,7 +11743,7 @@ else $(BINDIR)/$(CONFIG)/message_compress_test: $(MESSAGE_COMPRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(MESSAGE_COMPRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/message_compress_test + $(Q) $(LDXX) $(LDFLAGS) $(MESSAGE_COMPRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/message_compress_test endif @@ -11775,7 +11775,7 @@ else $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test: $(MINIMAL_STACK_IS_MINIMAL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(MINIMAL_STACK_IS_MINIMAL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test + $(Q) $(LDXX) $(LDFLAGS) $(MINIMAL_STACK_IS_MINIMAL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test endif @@ -11807,7 +11807,7 @@ else $(BINDIR)/$(CONFIG)/mpmcqueue_test: $(MPMCQUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(MPMCQUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/mpmcqueue_test + $(Q) $(LDXX) $(LDFLAGS) $(MPMCQUEUE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/mpmcqueue_test endif @@ -11839,7 +11839,7 @@ else $(BINDIR)/$(CONFIG)/multiple_server_queues_test: $(MULTIPLE_SERVER_QUEUES_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(MULTIPLE_SERVER_QUEUES_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/multiple_server_queues_test + $(Q) $(LDXX) $(LDFLAGS) $(MULTIPLE_SERVER_QUEUES_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/multiple_server_queues_test endif @@ -11871,7 +11871,7 @@ else $(BINDIR)/$(CONFIG)/murmur_hash_test: $(MURMUR_HASH_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(MURMUR_HASH_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/murmur_hash_test + $(Q) $(LDXX) $(LDFLAGS) $(MURMUR_HASH_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/murmur_hash_test endif @@ -11967,7 +11967,7 @@ else $(BINDIR)/$(CONFIG)/no_server_test: $(NO_SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(NO_SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/no_server_test + $(Q) $(LDXX) $(LDFLAGS) $(NO_SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/no_server_test endif @@ -11999,7 +11999,7 @@ else $(BINDIR)/$(CONFIG)/num_external_connectivity_watchers_test: $(NUM_EXTERNAL_CONNECTIVITY_WATCHERS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(NUM_EXTERNAL_CONNECTIVITY_WATCHERS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/num_external_connectivity_watchers_test + $(Q) $(LDXX) $(LDFLAGS) $(NUM_EXTERNAL_CONNECTIVITY_WATCHERS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/num_external_connectivity_watchers_test endif @@ -12031,7 +12031,7 @@ else $(BINDIR)/$(CONFIG)/parse_address_test: $(PARSE_ADDRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(PARSE_ADDRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/parse_address_test + $(Q) $(LDXX) $(LDFLAGS) $(PARSE_ADDRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/parse_address_test endif @@ -12063,7 +12063,7 @@ else $(BINDIR)/$(CONFIG)/parse_address_with_named_scope_id_test: $(PARSE_ADDRESS_WITH_NAMED_SCOPE_ID_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(PARSE_ADDRESS_WITH_NAMED_SCOPE_ID_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/parse_address_with_named_scope_id_test + $(Q) $(LDXX) $(LDFLAGS) $(PARSE_ADDRESS_WITH_NAMED_SCOPE_ID_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/parse_address_with_named_scope_id_test endif @@ -12159,7 +12159,7 @@ else $(BINDIR)/$(CONFIG)/percent_encoding_test: $(PERCENT_ENCODING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(PERCENT_ENCODING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/percent_encoding_test + $(Q) $(LDXX) $(LDFLAGS) $(PERCENT_ENCODING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/percent_encoding_test endif @@ -12191,7 +12191,7 @@ else $(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_posix_test: $(RESOLVE_ADDRESS_USING_ARES_RESOLVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(RESOLVE_ADDRESS_USING_ARES_RESOLVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_posix_test + $(Q) $(LDXX) $(LDFLAGS) $(RESOLVE_ADDRESS_USING_ARES_RESOLVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_posix_test endif @@ -12223,7 +12223,7 @@ else $(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_test: $(RESOLVE_ADDRESS_USING_ARES_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(RESOLVE_ADDRESS_USING_ARES_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_test + $(Q) $(LDXX) $(LDFLAGS) $(RESOLVE_ADDRESS_USING_ARES_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_test endif @@ -12255,7 +12255,7 @@ else $(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_posix_test: $(RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_posix_test + $(Q) $(LDXX) $(LDFLAGS) $(RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_posix_test endif @@ -12287,7 +12287,7 @@ else $(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_test: $(RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_test + $(Q) $(LDXX) $(LDFLAGS) $(RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_test endif @@ -12319,7 +12319,7 @@ else $(BINDIR)/$(CONFIG)/resource_quota_test: $(RESOURCE_QUOTA_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(RESOURCE_QUOTA_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resource_quota_test + $(Q) $(LDXX) $(LDFLAGS) $(RESOURCE_QUOTA_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resource_quota_test endif @@ -12351,7 +12351,7 @@ else $(BINDIR)/$(CONFIG)/secure_channel_create_test: $(SECURE_CHANNEL_CREATE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SECURE_CHANNEL_CREATE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/secure_channel_create_test + $(Q) $(LDXX) $(LDFLAGS) $(SECURE_CHANNEL_CREATE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/secure_channel_create_test endif @@ -12383,7 +12383,7 @@ else $(BINDIR)/$(CONFIG)/secure_endpoint_test: $(SECURE_ENDPOINT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SECURE_ENDPOINT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/secure_endpoint_test + $(Q) $(LDXX) $(LDFLAGS) $(SECURE_ENDPOINT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/secure_endpoint_test endif @@ -12415,7 +12415,7 @@ else $(BINDIR)/$(CONFIG)/sequential_connectivity_test: $(SEQUENTIAL_CONNECTIVITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SEQUENTIAL_CONNECTIVITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/sequential_connectivity_test + $(Q) $(LDXX) $(LDFLAGS) $(SEQUENTIAL_CONNECTIVITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/sequential_connectivity_test endif @@ -12447,7 +12447,7 @@ else $(BINDIR)/$(CONFIG)/server_chttp2_test: $(SERVER_CHTTP2_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SERVER_CHTTP2_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/server_chttp2_test + $(Q) $(LDXX) $(LDFLAGS) $(SERVER_CHTTP2_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/server_chttp2_test endif @@ -12511,7 +12511,7 @@ else $(BINDIR)/$(CONFIG)/server_test: $(SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/server_test + $(Q) $(LDXX) $(LDFLAGS) $(SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/server_test endif @@ -12543,7 +12543,7 @@ else $(BINDIR)/$(CONFIG)/slice_buffer_test: $(SLICE_BUFFER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SLICE_BUFFER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/slice_buffer_test + $(Q) $(LDXX) $(LDFLAGS) $(SLICE_BUFFER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/slice_buffer_test endif @@ -12575,7 +12575,7 @@ else $(BINDIR)/$(CONFIG)/slice_string_helpers_test: $(SLICE_STRING_HELPERS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SLICE_STRING_HELPERS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/slice_string_helpers_test + $(Q) $(LDXX) $(LDFLAGS) $(SLICE_STRING_HELPERS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/slice_string_helpers_test endif @@ -12607,7 +12607,7 @@ else $(BINDIR)/$(CONFIG)/slice_test: $(SLICE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SLICE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/slice_test + $(Q) $(LDXX) $(LDFLAGS) $(SLICE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/slice_test endif @@ -12639,7 +12639,7 @@ else $(BINDIR)/$(CONFIG)/sockaddr_resolver_test: $(SOCKADDR_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SOCKADDR_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/sockaddr_resolver_test + $(Q) $(LDXX) $(LDFLAGS) $(SOCKADDR_RESOLVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/sockaddr_resolver_test endif @@ -12671,7 +12671,7 @@ else $(BINDIR)/$(CONFIG)/sockaddr_utils_test: $(SOCKADDR_UTILS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SOCKADDR_UTILS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/sockaddr_utils_test + $(Q) $(LDXX) $(LDFLAGS) $(SOCKADDR_UTILS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/sockaddr_utils_test endif @@ -12703,7 +12703,7 @@ else $(BINDIR)/$(CONFIG)/socket_utils_test: $(SOCKET_UTILS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SOCKET_UTILS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/socket_utils_test + $(Q) $(LDXX) $(LDFLAGS) $(SOCKET_UTILS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/socket_utils_test endif @@ -12768,7 +12768,7 @@ else $(BINDIR)/$(CONFIG)/ssl_transport_security_test: $(SSL_TRANSPORT_SECURITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SSL_TRANSPORT_SECURITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/ssl_transport_security_test + $(Q) $(LDXX) $(LDFLAGS) $(SSL_TRANSPORT_SECURITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/ssl_transport_security_test endif @@ -12802,7 +12802,7 @@ else $(BINDIR)/$(CONFIG)/status_conversion_test: $(STATUS_CONVERSION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(STATUS_CONVERSION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/status_conversion_test + $(Q) $(LDXX) $(LDFLAGS) $(STATUS_CONVERSION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/status_conversion_test endif @@ -12834,7 +12834,7 @@ else $(BINDIR)/$(CONFIG)/stream_compression_test: $(STREAM_COMPRESSION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(STREAM_COMPRESSION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/stream_compression_test + $(Q) $(LDXX) $(LDFLAGS) $(STREAM_COMPRESSION_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/stream_compression_test endif @@ -12866,7 +12866,7 @@ else $(BINDIR)/$(CONFIG)/stream_owned_slice_test: $(STREAM_OWNED_SLICE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(STREAM_OWNED_SLICE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/stream_owned_slice_test + $(Q) $(LDXX) $(LDFLAGS) $(STREAM_OWNED_SLICE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/stream_owned_slice_test endif @@ -12898,7 +12898,7 @@ else $(BINDIR)/$(CONFIG)/tcp_client_posix_test: $(TCP_CLIENT_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TCP_CLIENT_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_client_posix_test + $(Q) $(LDXX) $(LDFLAGS) $(TCP_CLIENT_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_client_posix_test endif @@ -12930,7 +12930,7 @@ else $(BINDIR)/$(CONFIG)/tcp_client_uv_test: $(TCP_CLIENT_UV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TCP_CLIENT_UV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_client_uv_test + $(Q) $(LDXX) $(LDFLAGS) $(TCP_CLIENT_UV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_client_uv_test endif @@ -12962,7 +12962,7 @@ else $(BINDIR)/$(CONFIG)/tcp_posix_test: $(TCP_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TCP_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_posix_test + $(Q) $(LDXX) $(LDFLAGS) $(TCP_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_posix_test endif @@ -12994,7 +12994,7 @@ else $(BINDIR)/$(CONFIG)/tcp_server_posix_test: $(TCP_SERVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TCP_SERVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_server_posix_test + $(Q) $(LDXX) $(LDFLAGS) $(TCP_SERVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_server_posix_test endif @@ -13026,7 +13026,7 @@ else $(BINDIR)/$(CONFIG)/tcp_server_uv_test: $(TCP_SERVER_UV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TCP_SERVER_UV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_server_uv_test + $(Q) $(LDXX) $(LDFLAGS) $(TCP_SERVER_UV_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/tcp_server_uv_test endif @@ -13058,7 +13058,7 @@ else $(BINDIR)/$(CONFIG)/threadpool_test: $(THREADPOOL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(THREADPOOL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/threadpool_test + $(Q) $(LDXX) $(LDFLAGS) $(THREADPOOL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/threadpool_test endif @@ -13090,7 +13090,7 @@ else $(BINDIR)/$(CONFIG)/time_averaged_stats_test: $(TIME_AVERAGED_STATS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TIME_AVERAGED_STATS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/time_averaged_stats_test + $(Q) $(LDXX) $(LDFLAGS) $(TIME_AVERAGED_STATS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/time_averaged_stats_test endif @@ -13122,7 +13122,7 @@ else $(BINDIR)/$(CONFIG)/timeout_encoding_test: $(TIMEOUT_ENCODING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TIMEOUT_ENCODING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/timeout_encoding_test + $(Q) $(LDXX) $(LDFLAGS) $(TIMEOUT_ENCODING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/timeout_encoding_test endif @@ -13154,7 +13154,7 @@ else $(BINDIR)/$(CONFIG)/timer_heap_test: $(TIMER_HEAP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TIMER_HEAP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/timer_heap_test + $(Q) $(LDXX) $(LDFLAGS) $(TIMER_HEAP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/timer_heap_test endif @@ -13186,7 +13186,7 @@ else $(BINDIR)/$(CONFIG)/timer_list_test: $(TIMER_LIST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TIMER_LIST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/timer_list_test + $(Q) $(LDXX) $(LDFLAGS) $(TIMER_LIST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/timer_list_test endif @@ -13218,7 +13218,7 @@ else $(BINDIR)/$(CONFIG)/transport_connectivity_state_test: $(TRANSPORT_CONNECTIVITY_STATE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TRANSPORT_CONNECTIVITY_STATE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/transport_connectivity_state_test + $(Q) $(LDXX) $(LDFLAGS) $(TRANSPORT_CONNECTIVITY_STATE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/transport_connectivity_state_test endif @@ -13250,7 +13250,7 @@ else $(BINDIR)/$(CONFIG)/transport_metadata_test: $(TRANSPORT_METADATA_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TRANSPORT_METADATA_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/transport_metadata_test + $(Q) $(LDXX) $(LDFLAGS) $(TRANSPORT_METADATA_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/transport_metadata_test endif @@ -13282,7 +13282,7 @@ else $(BINDIR)/$(CONFIG)/transport_security_test: $(TRANSPORT_SECURITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(TRANSPORT_SECURITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/transport_security_test + $(Q) $(LDXX) $(LDFLAGS) $(TRANSPORT_SECURITY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/transport_security_test endif @@ -13314,7 +13314,7 @@ else $(BINDIR)/$(CONFIG)/udp_server_test: $(UDP_SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(UDP_SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/udp_server_test + $(Q) $(LDXX) $(LDFLAGS) $(UDP_SERVER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/udp_server_test endif @@ -13378,7 +13378,7 @@ else $(BINDIR)/$(CONFIG)/uri_parser_test: $(URI_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.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.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/uri_parser_test + $(Q) $(LDXX) $(LDFLAGS) $(URI_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/uri_parser_test endif @@ -20127,7 +20127,7 @@ else $(BINDIR)/$(CONFIG)/public_headers_must_be_c89: $(PUBLIC_HEADERS_MUST_BE_C89_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(PUBLIC_HEADERS_MUST_BE_C89_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/public_headers_must_be_c89 + $(Q) $(LDXX) $(LDFLAGS) $(PUBLIC_HEADERS_MUST_BE_C89_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/public_headers_must_be_c89 endif @@ -20796,7 +20796,7 @@ else $(BINDIR)/$(CONFIG)/bad_ssl_cert_server: $(BAD_SSL_CERT_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libbad_ssl_test_server.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(BAD_SSL_CERT_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libbad_ssl_test_server.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bad_ssl_cert_server + $(Q) $(LDXX) $(LDFLAGS) $(BAD_SSL_CERT_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libbad_ssl_test_server.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bad_ssl_cert_server endif @@ -20828,7 +20828,7 @@ else $(BINDIR)/$(CONFIG)/bad_ssl_cert_test: $(BAD_SSL_CERT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(BAD_SSL_CERT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bad_ssl_cert_test + $(Q) $(LDXX) $(LDFLAGS) $(BAD_SSL_CERT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bad_ssl_cert_test endif @@ -20860,7 +20860,7 @@ else $(BINDIR)/$(CONFIG)/h2_census_test: $(H2_CENSUS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_CENSUS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_census_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_CENSUS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_census_test endif @@ -20892,7 +20892,7 @@ else $(BINDIR)/$(CONFIG)/h2_compress_test: $(H2_COMPRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_COMPRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_compress_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_COMPRESS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_compress_test endif @@ -20924,7 +20924,7 @@ else $(BINDIR)/$(CONFIG)/h2_fakesec_test: $(H2_FAKESEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FAKESEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_fakesec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FAKESEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_fakesec_test endif @@ -20956,7 +20956,7 @@ else $(BINDIR)/$(CONFIG)/h2_fd_test: $(H2_FD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_fd_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_fd_test endif @@ -20988,7 +20988,7 @@ else $(BINDIR)/$(CONFIG)/h2_full_test: $(H2_FULL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FULL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_full_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FULL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_full_test endif @@ -21020,7 +21020,7 @@ else $(BINDIR)/$(CONFIG)/h2_full+pipe_test: $(H2_FULL+PIPE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FULL+PIPE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_full+pipe_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FULL+PIPE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_full+pipe_test endif @@ -21052,7 +21052,7 @@ else $(BINDIR)/$(CONFIG)/h2_full+trace_test: $(H2_FULL+TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FULL+TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_full+trace_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FULL+TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_full+trace_test endif @@ -21084,7 +21084,7 @@ else $(BINDIR)/$(CONFIG)/h2_full+workarounds_test: $(H2_FULL+WORKAROUNDS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FULL+WORKAROUNDS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_full+workarounds_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FULL+WORKAROUNDS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_full+workarounds_test endif @@ -21116,7 +21116,7 @@ else $(BINDIR)/$(CONFIG)/h2_http_proxy_test: $(H2_HTTP_PROXY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_HTTP_PROXY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_http_proxy_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_HTTP_PROXY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_http_proxy_test endif @@ -21148,7 +21148,7 @@ else $(BINDIR)/$(CONFIG)/h2_local_ipv4_test: $(H2_LOCAL_IPV4_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_LOCAL_IPV4_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_local_ipv4_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_LOCAL_IPV4_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_local_ipv4_test endif @@ -21180,7 +21180,7 @@ else $(BINDIR)/$(CONFIG)/h2_local_ipv6_test: $(H2_LOCAL_IPV6_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_LOCAL_IPV6_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_local_ipv6_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_LOCAL_IPV6_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_local_ipv6_test endif @@ -21212,7 +21212,7 @@ else $(BINDIR)/$(CONFIG)/h2_local_uds_test: $(H2_LOCAL_UDS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_LOCAL_UDS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_local_uds_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_LOCAL_UDS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_local_uds_test endif @@ -21244,7 +21244,7 @@ else $(BINDIR)/$(CONFIG)/h2_oauth2_test: $(H2_OAUTH2_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_OAUTH2_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_oauth2_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_OAUTH2_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_oauth2_test endif @@ -21276,7 +21276,7 @@ else $(BINDIR)/$(CONFIG)/h2_proxy_test: $(H2_PROXY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_PROXY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_proxy_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_PROXY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_proxy_test endif @@ -21308,7 +21308,7 @@ else $(BINDIR)/$(CONFIG)/h2_sockpair_test: $(H2_SOCKPAIR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SOCKPAIR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_sockpair_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SOCKPAIR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_sockpair_test endif @@ -21340,7 +21340,7 @@ else $(BINDIR)/$(CONFIG)/h2_sockpair+trace_test: $(H2_SOCKPAIR+TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SOCKPAIR+TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_sockpair+trace_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SOCKPAIR+TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_sockpair+trace_test endif @@ -21372,7 +21372,7 @@ else $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_test: $(H2_SOCKPAIR_1BYTE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SOCKPAIR_1BYTE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SOCKPAIR_1BYTE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_test endif @@ -21404,7 +21404,7 @@ else $(BINDIR)/$(CONFIG)/h2_spiffe_test: $(H2_SPIFFE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SPIFFE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_spiffe_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SPIFFE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_spiffe_test endif @@ -21436,7 +21436,7 @@ else $(BINDIR)/$(CONFIG)/h2_ssl_test: $(H2_SSL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SSL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_ssl_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SSL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_ssl_test endif @@ -21468,7 +21468,7 @@ else $(BINDIR)/$(CONFIG)/h2_ssl_cred_reload_test: $(H2_SSL_CRED_RELOAD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SSL_CRED_RELOAD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_ssl_cred_reload_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SSL_CRED_RELOAD_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_ssl_cred_reload_test endif @@ -21500,7 +21500,7 @@ else $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test: $(H2_SSL_PROXY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SSL_PROXY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SSL_PROXY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test endif @@ -21532,7 +21532,7 @@ else $(BINDIR)/$(CONFIG)/h2_uds_test: $(H2_UDS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_UDS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_uds_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_UDS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_uds_test endif @@ -21564,7 +21564,7 @@ else $(BINDIR)/$(CONFIG)/inproc_test: $(INPROC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(INPROC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/inproc_test + $(Q) $(LDXX) $(LDFLAGS) $(INPROC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/inproc_test endif @@ -21588,7 +21588,7 @@ H2_CENSUS_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $( $(BINDIR)/$(CONFIG)/h2_census_nosec_test: $(H2_CENSUS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_CENSUS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_census_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_CENSUS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_census_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_census.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21608,7 +21608,7 @@ H2_COMPRESS_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(BINDIR)/$(CONFIG)/h2_compress_nosec_test: $(H2_COMPRESS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_COMPRESS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_compress_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_COMPRESS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_compress_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_compress.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21628,7 +21628,7 @@ H2_FD_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(base $(BINDIR)/$(CONFIG)/h2_fd_nosec_test: $(H2_FD_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FD_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_fd_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FD_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_fd_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_fd.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21648,7 +21648,7 @@ H2_FULL_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(ba $(BINDIR)/$(CONFIG)/h2_full_nosec_test: $(H2_FULL_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FULL_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_full_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FULL_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_full_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_full.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21668,7 +21668,7 @@ H2_FULL+PIPE_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(BINDIR)/$(CONFIG)/h2_full+pipe_nosec_test: $(H2_FULL+PIPE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FULL+PIPE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_full+pipe_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FULL+PIPE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_full+pipe_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_full+pipe.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21688,7 +21688,7 @@ H2_FULL+TRACE_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o $(BINDIR)/$(CONFIG)/h2_full+trace_nosec_test: $(H2_FULL+TRACE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FULL+TRACE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_full+trace_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FULL+TRACE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_full+trace_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_full+trace.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21708,7 +21708,7 @@ H2_FULL+WORKAROUNDS_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuf $(BINDIR)/$(CONFIG)/h2_full+workarounds_nosec_test: $(H2_FULL+WORKAROUNDS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_FULL+WORKAROUNDS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_full+workarounds_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_FULL+WORKAROUNDS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_full+workarounds_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_full+workarounds.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21728,7 +21728,7 @@ H2_HTTP_PROXY_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o $(BINDIR)/$(CONFIG)/h2_http_proxy_nosec_test: $(H2_HTTP_PROXY_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_HTTP_PROXY_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_http_proxy_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_HTTP_PROXY_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_http_proxy_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_http_proxy.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21748,7 +21748,7 @@ H2_PROXY_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(b $(BINDIR)/$(CONFIG)/h2_proxy_nosec_test: $(H2_PROXY_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_PROXY_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_proxy_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_PROXY_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_proxy_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_proxy.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21768,7 +21768,7 @@ H2_SOCKPAIR_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(BINDIR)/$(CONFIG)/h2_sockpair_nosec_test: $(H2_SOCKPAIR_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SOCKPAIR_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_sockpair_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SOCKPAIR_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_sockpair_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_sockpair.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21788,7 +21788,7 @@ H2_SOCKPAIR+TRACE_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffi $(BINDIR)/$(CONFIG)/h2_sockpair+trace_nosec_test: $(H2_SOCKPAIR+TRACE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SOCKPAIR+TRACE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_sockpair+trace_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SOCKPAIR+TRACE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_sockpair+trace_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_sockpair+trace.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21808,7 +21808,7 @@ H2_SOCKPAIR_1BYTE_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffi $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_nosec_test: $(H2_SOCKPAIR_1BYTE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SOCKPAIR_1BYTE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_SOCKPAIR_1BYTE_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_sockpair_1byte.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -21828,7 +21828,7 @@ H2_UDS_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(bas $(BINDIR)/$(CONFIG)/h2_uds_nosec_test: $(H2_UDS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_UDS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_uds_nosec_test + $(Q) $(LDXX) $(LDFLAGS) $(H2_UDS_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_uds_nosec_test $(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_uds.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a @@ -22158,7 +22158,7 @@ else $(BINDIR)/$(CONFIG)/alts_credentials_fuzzer_one_entry: $(ALTS_CREDENTIALS_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(ALTS_CREDENTIALS_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/alts_credentials_fuzzer_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(ALTS_CREDENTIALS_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/alts_credentials_fuzzer_one_entry endif @@ -22193,7 +22193,7 @@ else $(BINDIR)/$(CONFIG)/api_fuzzer_one_entry: $(API_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(API_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/api_fuzzer_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(API_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/api_fuzzer_one_entry endif @@ -22228,7 +22228,7 @@ else $(BINDIR)/$(CONFIG)/client_fuzzer_one_entry: $(CLIENT_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(CLIENT_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/client_fuzzer_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(CLIENT_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/client_fuzzer_one_entry endif @@ -22263,7 +22263,7 @@ else $(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test_one_entry: $(HPACK_PARSER_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HPACK_PARSER_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(HPACK_PARSER_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test_one_entry endif @@ -22298,7 +22298,7 @@ else $(BINDIR)/$(CONFIG)/http_request_fuzzer_test_one_entry: $(HTTP_REQUEST_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HTTP_REQUEST_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/http_request_fuzzer_test_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(HTTP_REQUEST_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/http_request_fuzzer_test_one_entry endif @@ -22333,7 +22333,7 @@ else $(BINDIR)/$(CONFIG)/http_response_fuzzer_test_one_entry: $(HTTP_RESPONSE_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(HTTP_RESPONSE_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/http_response_fuzzer_test_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(HTTP_RESPONSE_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/http_response_fuzzer_test_one_entry endif @@ -22368,7 +22368,7 @@ else $(BINDIR)/$(CONFIG)/json_fuzzer_test_one_entry: $(JSON_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(JSON_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_fuzzer_test_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(JSON_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/json_fuzzer_test_one_entry endif @@ -22403,7 +22403,7 @@ else $(BINDIR)/$(CONFIG)/nanopb_fuzzer_response_test_one_entry: $(NANOPB_FUZZER_RESPONSE_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(NANOPB_FUZZER_RESPONSE_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/nanopb_fuzzer_response_test_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(NANOPB_FUZZER_RESPONSE_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/nanopb_fuzzer_response_test_one_entry endif @@ -22438,7 +22438,7 @@ else $(BINDIR)/$(CONFIG)/nanopb_fuzzer_serverlist_test_one_entry: $(NANOPB_FUZZER_SERVERLIST_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(NANOPB_FUZZER_SERVERLIST_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/nanopb_fuzzer_serverlist_test_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(NANOPB_FUZZER_SERVERLIST_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/nanopb_fuzzer_serverlist_test_one_entry endif @@ -22473,7 +22473,7 @@ else $(BINDIR)/$(CONFIG)/percent_decode_fuzzer_one_entry: $(PERCENT_DECODE_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(PERCENT_DECODE_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/percent_decode_fuzzer_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(PERCENT_DECODE_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/percent_decode_fuzzer_one_entry endif @@ -22508,7 +22508,7 @@ else $(BINDIR)/$(CONFIG)/percent_encode_fuzzer_one_entry: $(PERCENT_ENCODE_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(PERCENT_ENCODE_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/percent_encode_fuzzer_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(PERCENT_ENCODE_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/percent_encode_fuzzer_one_entry endif @@ -22543,7 +22543,7 @@ else $(BINDIR)/$(CONFIG)/server_fuzzer_one_entry: $(SERVER_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SERVER_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/server_fuzzer_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(SERVER_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/server_fuzzer_one_entry endif @@ -22578,7 +22578,7 @@ else $(BINDIR)/$(CONFIG)/ssl_server_fuzzer_one_entry: $(SSL_SERVER_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(SSL_SERVER_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/ssl_server_fuzzer_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(SSL_SERVER_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/ssl_server_fuzzer_one_entry endif @@ -22613,7 +22613,7 @@ else $(BINDIR)/$(CONFIG)/uri_fuzzer_test_one_entry: $(URI_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(URI_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/uri_fuzzer_test_one_entry + $(Q) $(LDXX) $(LDFLAGS) $(URI_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/uri_fuzzer_test_one_entry endif diff --git a/config.m4 b/config.m4 index effefa9b561..4a8651dae38 100644 --- a/config.m4 +++ b/config.m4 @@ -24,8 +24,10 @@ if test "$PHP_GRPC" != "no"; then case $host in *darwin*) + PHP_ADD_LIBRARY(c++,1,GRPC_SHARED_LIBADD) ;; *) + PHP_ADD_LIBRARY(stdc++,1,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(rt) ;; diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index bab57657a00..ca1d0aeef72 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -32,8 +32,7 @@ * in-house library if possible. (e.g. std::map) */ #ifndef GRPC_USE_CPP_STD_LIB -/* Default value will be 1 once all tests become green. */ -#define GRPC_USE_CPP_STD_LIB 0 +#define GRPC_USE_CPP_STD_LIB 1 #endif /* Get windows.h included everywhere (we need it) */ diff --git a/src/php/ext/grpc/config.m4 b/src/php/ext/grpc/config.m4 index 9ec2c7cf04c..1af93ceecad 100755 --- a/src/php/ext/grpc/config.m4 +++ b/src/php/ext/grpc/config.m4 @@ -42,7 +42,8 @@ if test "$PHP_GRPC" != "no"; then dnl PHP_ADD_LIBRARY(pthread,,GRPC_SHARED_LIBADD) GRPC_SHARED_LIBADD="-lpthread $GRPC_SHARED_LIBADD" PHP_ADD_LIBRARY(pthread) - + PHP_ADD_LIBRARY(stdc++,,GRPC_SHARED_LIBADD) + PHP_ADD_LIBRARY(stdc++) PHP_ADD_LIBRARY(dl,,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(dl) diff --git a/src/ruby/ext/grpc/rb_enable_cpp.cc b/src/ruby/ext/grpc/rb_enable_cpp.cc new file mode 100644 index 00000000000..f44e4f515a7 --- /dev/null +++ b/src/ruby/ext/grpc/rb_enable_cpp.cc @@ -0,0 +1,22 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +// This is a dummy C++ source file to trigger ruby extension builder to +// pick C++ rather than C linker to link with c++ library properly. diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index b6a0e83056f..16fc78d99ae 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -174,11 +174,6 @@ endif() if (_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_IOS) - # C core has C++ source code, but should not depend on libstc++ (for better portability). - # We need to use a few tricks to convince cmake to do that. - # https://stackoverflow.com/questions/15058403/how-to-stop-cmake-from-linking-against-libstdc - set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "") - # Exceptions and RTTI must be off to avoid dependency on libstdc++ set(_gRPC_CORE_NOSTDCXX_FLAGS -fno-exceptions -fno-rtti) else() set(_gRPC_CORE_NOSTDCXX_FLAGS "") @@ -444,14 +439,6 @@ PRIVATE <%text>${_gRPC_PROTO_GENS_DIR} % endif ) - % if lib.language in ['c', 'csharp']: - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(${lib.name} PROPERTIES LINKER_LANGUAGE C) - # only use the flags for C++ source files - target_compile_options(${lib.name} PRIVATE <%text>$<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() - % endif % if len(get_deps(lib)) > 0: target_link_libraries(${lib.name} % for dep in get_deps(lib): @@ -550,13 +537,6 @@ % endfor ) - % if tgt.language in ['c', 'csharp']: - # avoid dependency on libstdc++ - if (_gRPC_CORE_NOSTDCXX_FLAGS) - set_target_properties(${tgt.name} PROPERTIES LINKER_LANGUAGE C) - target_compile_options(${tgt.name} PRIVATE <%text>$<$:${_gRPC_CORE_NOSTDCXX_FLAGS}>) - endif() - % endif % endif diff --git a/templates/Makefile.template b/templates/Makefile.template index b17423cc4aa..bd8874c8154 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -1588,7 +1588,7 @@ if lib.language == 'c++': ld = '$(LDXX)' else: - ld = '$(LD)' + ld = '$(LDXX)' out_mingbase = '$(LIBDIR)/$(CONFIG)/' + lib.name + '$(SHARED_VERSION_' + lang_to_var[lib.language] + ')' out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name + '$(SHARED_VERSION_' + lang_to_var[lib.language] + ')' @@ -1781,7 +1781,7 @@ ## C-only targets specificities. $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) \ + $(Q) $(LDXX) $(LDFLAGS) \ % if not has_no_sources: $(${tgt.name.upper()}_OBJS)\ % endif diff --git a/templates/config.m4.template b/templates/config.m4.template index 4dbeeafb86a..f13ac75914f 100644 --- a/templates/config.m4.template +++ b/templates/config.m4.template @@ -26,8 +26,10 @@ case $host in *darwin*) + PHP_ADD_LIBRARY(c++,1,GRPC_SHARED_LIBADD) ;; *) + PHP_ADD_LIBRARY(stdc++,1,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(rt) ;; From db7365753e7e590e5bed13ac8cb0db1565d1fc84 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Tue, 3 Sep 2019 16:08:48 -0700 Subject: [PATCH 1443/1555] Fix the compile error due to ByteBuffer in method_handler_impl.h --- include/grpcpp/impl/codegen/method_handler_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grpcpp/impl/codegen/method_handler_impl.h b/include/grpcpp/impl/codegen/method_handler_impl.h index 232580cf839..f65a1736ad2 100644 --- a/include/grpcpp/impl/codegen/method_handler_impl.h +++ b/include/grpcpp/impl/codegen/method_handler_impl.h @@ -207,7 +207,7 @@ class ServerStreamingHandler : public ::grpc::internal::MethodHandler { void* Deserialize(grpc_call* call, grpc_byte_buffer* req, ::grpc::Status* status, void** /*handler_data*/) final { - ByteBuffer buf; + ::grpc::ByteBuffer buf; buf.set_buffer(req); auto* request = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( From c831a28dbd694f929fbbc0a4ac88fc4656d0caf3 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Mon, 2 Sep 2019 20:44:32 -0700 Subject: [PATCH 1444/1555] Organize test cases for xds test --- test/cpp/end2end/xds_end2end_test.cc | 413 ++++++++++++++------------- 1 file changed, 218 insertions(+), 195 deletions(-) diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index 1c073de1b12..17436bbc13a 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -914,6 +914,8 @@ class XdsResolverTest : public XdsEnd2endTest { XdsResolverTest() : XdsEnd2endTest(0, 0, 0) {} }; +// Tests that if the "xds-experimental" scheme is used, xDS resolver will be +// used. TEST_F(XdsResolverTest, XdsResolverIsUsed) { // Use xds-experimental scheme in URI. ResetStub(0, "", "xds-experimental"); @@ -923,12 +925,14 @@ TEST_F(XdsResolverTest, XdsResolverIsUsed) { EXPECT_EQ("xds_experimental", channel_->GetLoadBalancingPolicyName()); } -class SingleBalancerTest : public XdsEnd2endTest { +class BasicTest : public XdsEnd2endTest { public: - SingleBalancerTest() : XdsEnd2endTest(4, 1, 0) {} + BasicTest() : XdsEnd2endTest(4, 1, 0) {} }; -TEST_F(SingleBalancerTest, Vanilla) { +// Tests that the balancer sends the correct response to the client, and the +// client sends RPCs to the backends using the default child policy. +TEST_F(BasicTest, Vanilla) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcsPerAddress = 100; @@ -954,7 +958,9 @@ TEST_F(SingleBalancerTest, Vanilla) { EXPECT_EQ("xds_experimental", channel_->GetLoadBalancingPolicyName()); } -TEST_F(SingleBalancerTest, SameBackendListedMultipleTimes) { +// Tests that subchannel sharing works when the same backend is listed multiple +// times. +TEST_F(BasicTest, SameBackendListedMultipleTimes) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); // Same backend listed twice. @@ -976,55 +982,8 @@ TEST_F(SingleBalancerTest, SameBackendListedMultipleTimes) { EXPECT_EQ(1UL, backends_[0]->backend_service()->clients().size()); } -TEST_F(SingleBalancerTest, SecureNaming) { - // TODO(juanlishen): Use separate fake creds for the balancer channel. - ResetStub(0, kApplicationTargetName_ + ";lb"); - SetNextResolution({}, kDefaultServiceConfig_.c_str()); - SetNextResolutionForLbChannel({balancers_[0]->port()}); - const size_t kNumRpcsPerAddress = 100; - EdsServiceImpl::ResponseArgs args({ - {"locality0", GetBackendPorts()}, - }); - ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); - // Make sure that trying to connect works without a call. - channel_->GetState(true /* try_to_connect */); - // We need to wait for all backends to come online. - WaitForAllBackends(); - // Send kNumRpcsPerAddress RPCs per server. - CheckRpcSendOk(kNumRpcsPerAddress * num_backends_); - - // Each backend should have gotten 100 requests. - for (size_t i = 0; i < backends_.size(); ++i) { - EXPECT_EQ(kNumRpcsPerAddress, - backends_[i]->backend_service()->request_count()); - } - // The EDS service got a single request, and sent a single response. - EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); - EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); -} - -TEST_F(SingleBalancerTest, SecureNamingDeathTest) { - ::testing::FLAGS_gtest_death_test_style = "threadsafe"; - // Make sure that we blow up (via abort() from the security connector) when - // the name from the balancer doesn't match expectations. - ASSERT_DEATH_IF_SUPPORTED( - { - ResetStub(0, kApplicationTargetName_ + ";lb"); - SetNextResolution({}, - "{\n" - " \"loadBalancingConfig\":[\n" - " { \"does_not_exist\":{} },\n" - " { \"xds_experimental\":{ \"balancerName\": " - "\"fake:///wrong_lb\" } }\n" - " ]\n" - "}"); - SetNextResolutionForLbChannel({balancers_[0]->port()}); - channel_->WaitForConnected(grpc_timeout_seconds_to_deadline(1)); - }, - ""); -} - -TEST_F(SingleBalancerTest, InitiallyEmptyServerlist) { +// Tests that RPCs will be blocked until a non-empty serverlist is received. +TEST_F(BasicTest, InitiallyEmptyServerlist) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor(); @@ -1058,7 +1017,9 @@ TEST_F(SingleBalancerTest, InitiallyEmptyServerlist) { EXPECT_EQ(2U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, AllServersUnreachableFailFast) { +// Tests that RPCs will fail with UNAVAILABLE instead of DEADLINE_EXCEEDED if +// all the servers are unreachable. +TEST_F(BasicTest, AllServersUnreachableFailFast) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumUnreachableServers = 5; @@ -1078,7 +1039,81 @@ TEST_F(SingleBalancerTest, AllServersUnreachableFailFast) { EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, LocalityMapWeightedRoundRobin) { +// Tests that RPCs fail when the backends are down, and will succeed again after +// the backends are restarted. +TEST_F(BasicTest, BackendsRestart) { + SetNextResolution({}, kDefaultServiceConfig_.c_str()); + SetNextResolutionForLbChannelAllBalancers(); + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts()}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); + WaitForAllBackends(); + // Stop backends. RPCs should fail. + ShutdownAllBackends(); + CheckRpcSendFailure(); + // Restart all backends. RPCs should start succeeding again. + StartAllBackends(); + CheckRpcSendOk(1 /* times */, 2000 /* timeout_ms */, + true /* wait_for_ready */); +} + +using SecureNamingTest = BasicTest; + +// Tests that secure naming check passes if target name is expected. +TEST_F(SecureNamingTest, TargetNameIsExpected) { + // TODO(juanlishen): Use separate fake creds for the balancer channel. + ResetStub(0, kApplicationTargetName_ + ";lb"); + SetNextResolution({}, kDefaultServiceConfig_.c_str()); + SetNextResolutionForLbChannel({balancers_[0]->port()}); + const size_t kNumRpcsPerAddress = 100; + EdsServiceImpl::ResponseArgs args({ + {"locality0", GetBackendPorts()}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); + // Make sure that trying to connect works without a call. + channel_->GetState(true /* try_to_connect */); + // We need to wait for all backends to come online. + WaitForAllBackends(); + // Send kNumRpcsPerAddress RPCs per server. + CheckRpcSendOk(kNumRpcsPerAddress * num_backends_); + // Each backend should have gotten 100 requests. + for (size_t i = 0; i < backends_.size(); ++i) { + EXPECT_EQ(kNumRpcsPerAddress, + backends_[i]->backend_service()->request_count()); + } + // The EDS service got a single request, and sent a single response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); +} + +// Tests that secure naming check fails if target name is unexpected. +TEST_F(SecureNamingTest, TargetNameIsUnexpected) { + ::testing::FLAGS_gtest_death_test_style = "threadsafe"; + // Make sure that we blow up (via abort() from the security connector) when + // the name from the balancer doesn't match expectations. + ASSERT_DEATH_IF_SUPPORTED( + { + ResetStub(0, kApplicationTargetName_ + ";lb"); + SetNextResolution({}, + "{\n" + " \"loadBalancingConfig\":[\n" + " { \"does_not_exist\":{} },\n" + " { \"xds_experimental\":{ \"balancerName\": " + "\"fake:///wrong_lb\" } }\n" + " ]\n" + "}"); + SetNextResolutionForLbChannel({balancers_[0]->port()}); + channel_->WaitForConnected(grpc_timeout_seconds_to_deadline(1)); + }, + ""); +} + +using LocalityMapTest = BasicTest; + +// Tests that the localities in a locality map are picked according to their +// weights. +TEST_F(LocalityMapTest, WeightedRoundRobin) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcs = 5000; @@ -1120,7 +1155,9 @@ TEST_F(SingleBalancerTest, LocalityMapWeightedRoundRobin) { EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, LocalityMapStressTest) { +// Tests that the locality map can work properly even when it contains a large +// number of localities. +TEST_F(LocalityMapTest, StressTest) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumLocalities = 100; @@ -1153,7 +1190,9 @@ TEST_F(SingleBalancerTest, LocalityMapStressTest) { EXPECT_EQ(2U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, LocalityMapUpdate) { +// Tests that the localities in a locality map are picked correctly after update +// (addition, modification, deletion). +TEST_F(LocalityMapTest, UpdateMap) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcs = 1000; @@ -1244,7 +1283,10 @@ TEST_F(SingleBalancerTest, LocalityMapUpdate) { EXPECT_EQ(2U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, Drop) { +using DropTest = BasicTest; + +// Tests that RPCs are dropped according to the drop config. +TEST_F(DropTest, Vanilla) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcs = 5000; @@ -1289,7 +1331,8 @@ TEST_F(SingleBalancerTest, Drop) { EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, DropPerHundred) { +// Tests that drop config is converted correctly from per hundred. +TEST_F(DropTest, DropPerHundred) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcs = 5000; @@ -1329,7 +1372,8 @@ TEST_F(SingleBalancerTest, DropPerHundred) { EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, DropPerTenThousand) { +// Tests that drop config is converted correctly from per ten thousand. +TEST_F(DropTest, DropPerTenThousand) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcs = 5000; @@ -1369,7 +1413,8 @@ TEST_F(SingleBalancerTest, DropPerTenThousand) { EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, DropUpdate) { +// Tests that drop is working correctly after update. +TEST_F(DropTest, Update) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcs = 5000; @@ -1464,7 +1509,8 @@ TEST_F(SingleBalancerTest, DropUpdate) { EXPECT_EQ(2U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, DropAll) { +// Tests that all the RPCs are dropped if any drop category drops 100%. +TEST_F(DropTest, DropAll) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcs = 1000; @@ -1489,7 +1535,11 @@ TEST_F(SingleBalancerTest, DropAll) { EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, Fallback) { +using FallbackTest = BasicTest; + +// Tests that RPCs are handled by the fallback backends before the serverlist is +// received, but will be handled by the serverlist after it's received. +TEST_F(FallbackTest, Vanilla) { const int kFallbackTimeoutMs = 200 * grpc_test_slowdown_factor(); const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor(); const size_t kNumBackendsInResolution = backends_.size() / 2; @@ -1537,7 +1587,9 @@ TEST_F(SingleBalancerTest, Fallback) { EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, FallbackUpdate) { +// Tests that RPCs are handled by the updated fallback backends before +// serverlist is received, +TEST_F(FallbackTest, Update) { const int kFallbackTimeoutMs = 200 * grpc_test_slowdown_factor(); const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor(); const size_t kNumBackendsInResolution = backends_.size() / 3; @@ -1617,7 +1669,8 @@ TEST_F(SingleBalancerTest, FallbackUpdate) { EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); } -TEST_F(SingleBalancerTest, FallbackEarlyWhenBalancerChannelFails) { +// Tests that fallback will kick in immediately if the balancer channel fails. +TEST_F(FallbackTest, FallbackEarlyWhenBalancerChannelFails) { const int kFallbackTimeoutMs = 10000 * grpc_test_slowdown_factor(); ResetStub(kFallbackTimeoutMs); // Return an unreachable balancer and one fallback backend. @@ -1629,7 +1682,8 @@ TEST_F(SingleBalancerTest, FallbackEarlyWhenBalancerChannelFails) { /* wait_for_ready */ false); } -TEST_F(SingleBalancerTest, FallbackEarlyWhenBalancerCallFails) { +// Tests that fallback will kick in immediately if the balancer call fails. +TEST_F(FallbackTest, FallbackEarlyWhenBalancerCallFails) { const int kFallbackTimeoutMs = 10000 * grpc_test_slowdown_factor(); ResetStub(kFallbackTimeoutMs); // Return one balancer and one fallback backend. @@ -1643,7 +1697,9 @@ TEST_F(SingleBalancerTest, FallbackEarlyWhenBalancerCallFails) { /* wait_for_ready */ false); } -TEST_F(SingleBalancerTest, FallbackIfResponseReceivedButChildNotReady) { +// Tests that fallback mode is entered if balancer response is received but the +// backends can't be reached. +TEST_F(FallbackTest, FallbackIfResponseReceivedButChildNotReady) { const int kFallbackTimeoutMs = 500 * grpc_test_slowdown_factor(); ResetStub(kFallbackTimeoutMs); SetNextResolution({backends_[0]->port()}, kDefaultServiceConfig_.c_str()); @@ -1659,7 +1715,9 @@ TEST_F(SingleBalancerTest, FallbackIfResponseReceivedButChildNotReady) { WaitForBackend(0); } -TEST_F(SingleBalancerTest, FallbackModeIsExitedWhenBalancerSaysToDropAllCalls) { +// Tests that fallback mode is exited if the balancer tells the client to drop +// all the calls. +TEST_F(FallbackTest, FallbackModeIsExitedWhenBalancerSaysToDropAllCalls) { // Return an unreachable balancer and one fallback backend. SetNextResolution({backends_[0]->port()}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannel({grpc_pick_unused_port_or_die()}); @@ -1682,7 +1740,8 @@ TEST_F(SingleBalancerTest, FallbackModeIsExitedWhenBalancerSaysToDropAllCalls) { CheckRpcSendFailure(); } -TEST_F(SingleBalancerTest, FallbackModeIsExitedAfterChildRready) { +// Tests that fallback mode is exited if the child policy becomes ready. +TEST_F(FallbackTest, FallbackModeIsExitedAfterChildRready) { // Return an unreachable balancer and one fallback backend. SetNextResolution({backends_[0]->port()}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannel({grpc_pick_unused_port_or_die()}); @@ -1714,29 +1773,14 @@ TEST_F(SingleBalancerTest, FallbackModeIsExitedAfterChildRready) { EXPECT_EQ(100U, backends_[1]->backend_service()->request_count()); } -TEST_F(SingleBalancerTest, BackendsRestart) { - SetNextResolution({}, kDefaultServiceConfig_.c_str()); - SetNextResolutionForLbChannelAllBalancers(); - EdsServiceImpl::ResponseArgs args({ - {"locality0", GetBackendPorts()}, - }); - ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); - WaitForAllBackends(); - // Stop backends. RPCs should fail. - ShutdownAllBackends(); - CheckRpcSendFailure(); - // Restart all backends. RPCs should start succeeding again. - StartAllBackends(); - CheckRpcSendOk(1 /* times */, 2000 /* timeout_ms */, - true /* wait_for_ready */); -} - -class UpdatesTest : public XdsEnd2endTest { +class BalancerUpdateTest : public XdsEnd2endTest { public: - UpdatesTest() : XdsEnd2endTest(4, 3, 0) {} + BalancerUpdateTest() : XdsEnd2endTest(4, 3, 0) {} }; -TEST_F(UpdatesTest, UpdateBalancersButKeepUsingOriginalBalancer) { +// Tests that the old LB call is still used after the balancer address update as +// long as that call is still alive. +TEST_F(BalancerUpdateTest, UpdateBalancersButKeepUsingOriginalBalancer) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); EdsServiceImpl::ResponseArgs args({ @@ -1747,18 +1791,14 @@ TEST_F(UpdatesTest, UpdateBalancersButKeepUsingOriginalBalancer) { {"locality0", {backends_[1]->port()}}, }); ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(args), 0); - // Wait until the first backend is ready. WaitForBackend(0); - // Send 10 requests. gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); CheckRpcSendOk(10); gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); - // All 10 requests should have gone to the first backend. EXPECT_EQ(10U, backends_[0]->backend_service()->request_count()); - // The EDS service of balancer 0 got a single request, and sent a single // response. EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); @@ -1767,11 +1807,9 @@ TEST_F(UpdatesTest, UpdateBalancersButKeepUsingOriginalBalancer) { EXPECT_EQ(0U, balancers_[1]->eds_service()->response_count()); EXPECT_EQ(0U, balancers_[2]->eds_service()->request_count()); EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); - gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 1 =========="); SetNextResolutionForLbChannel({balancers_[1]->port()}); gpr_log(GPR_INFO, "========= UPDATE 1 DONE =========="); - EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); gpr_timespec deadline = gpr_time_add( gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(10000, GPR_TIMESPAN)); @@ -1782,7 +1820,6 @@ TEST_F(UpdatesTest, UpdateBalancersButKeepUsingOriginalBalancer) { // The current LB call is still working, so xds continued using it to the // first balancer, which doesn't assign the second backend. EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); - EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); EXPECT_EQ(0U, balancers_[1]->eds_service()->request_count()); @@ -1791,7 +1828,12 @@ TEST_F(UpdatesTest, UpdateBalancersButKeepUsingOriginalBalancer) { EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); } -TEST_F(UpdatesTest, UpdateBalancerName) { +// Tests that the old LB call is still used after multiple balancer address +// updates as long as that call is still alive. Send an update with the same set +// of LBs as the one in SetUp() in order to verify that the LB channel inside +// xds keeps the initial connection (which by definition is also present in the +// update). +TEST_F(BalancerUpdateTest, Repeated) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); EdsServiceImpl::ResponseArgs args({ @@ -1802,18 +1844,14 @@ TEST_F(UpdatesTest, UpdateBalancerName) { {"locality0", {backends_[1]->port()}}, }); ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(args), 0); - // Wait until the first backend is ready. WaitForBackend(0); - // Send 10 requests. gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); CheckRpcSendOk(10); gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); - // All 10 requests should have gone to the first backend. EXPECT_EQ(10U, backends_[0]->backend_service()->request_count()); - // The EDS service of balancer 0 got a single request, and sent a single // response. EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); @@ -1822,7 +1860,70 @@ TEST_F(UpdatesTest, UpdateBalancerName) { EXPECT_EQ(0U, balancers_[1]->eds_service()->response_count()); EXPECT_EQ(0U, balancers_[2]->eds_service()->request_count()); EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); + std::vector ports; + ports.emplace_back(balancers_[0]->port()); + ports.emplace_back(balancers_[1]->port()); + ports.emplace_back(balancers_[2]->port()); + gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 1 =========="); + SetNextResolutionForLbChannel(ports); + gpr_log(GPR_INFO, "========= UPDATE 1 DONE =========="); + EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); + gpr_timespec deadline = gpr_time_add( + gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(10000, GPR_TIMESPAN)); + // Send 10 seconds worth of RPCs + do { + CheckRpcSendOk(); + } while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0); + // xds continued using the original LB call to the first balancer, which + // doesn't assign the second backend. + EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); + ports.clear(); + ports.emplace_back(balancers_[0]->port()); + ports.emplace_back(balancers_[1]->port()); + gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 2 =========="); + SetNextResolutionForLbChannel(ports); + gpr_log(GPR_INFO, "========= UPDATE 2 DONE =========="); + EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); + deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_millis(10000, GPR_TIMESPAN)); + // Send 10 seconds worth of RPCs + do { + CheckRpcSendOk(); + } while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0); + // xds continued using the original LB call to the first balancer, which + // doesn't assign the second backend. + EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); +} +// Tests that if the balancer name changes, a new LB channel will be created to +// replace the old one. +TEST_F(BalancerUpdateTest, UpdateBalancerName) { + SetNextResolution({}, kDefaultServiceConfig_.c_str()); + SetNextResolutionForLbChannelAllBalancers(); + EdsServiceImpl::ResponseArgs args({ + {"locality0", {backends_[0]->port()}}, + }); + ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); + args = EdsServiceImpl::ResponseArgs({ + {"locality0", {backends_[1]->port()}}, + }); + ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(args), 0); + // Wait until the first backend is ready. + WaitForBackend(0); + // Send 10 requests. + gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); + CheckRpcSendOk(10); + gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); + // All 10 requests should have gone to the first backend. + EXPECT_EQ(10U, backends_[0]->backend_service()->request_count()); + // The EDS service of balancer 0 got a single request, and sent a single + // response. + EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); + EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); + EXPECT_EQ(0U, balancers_[1]->eds_service()->request_count()); + EXPECT_EQ(0U, balancers_[1]->eds_service()->response_count()); + EXPECT_EQ(0U, balancers_[2]->eds_service()->request_count()); + EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); std::vector ports; ports.emplace_back(balancers_[1]->port()); auto new_lb_channel_response_generator = @@ -1840,19 +1941,16 @@ TEST_F(UpdatesTest, UpdateBalancerName) { "}", new_lb_channel_response_generator.get()); gpr_log(GPR_INFO, "========= UPDATED BALANCER NAME =========="); - // Wait until update has been processed, as signaled by the second backend // receiving a request. EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); WaitForBackend(1); - backends_[1]->backend_service()->ResetCounters(); gpr_log(GPR_INFO, "========= BEFORE SECOND BATCH =========="); CheckRpcSendOk(10); gpr_log(GPR_INFO, "========= DONE WITH SECOND BATCH =========="); // All 10 requests should have gone to the second backend. EXPECT_EQ(10U, backends_[1]->backend_service()->request_count()); - EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); EXPECT_EQ(1U, balancers_[1]->eds_service()->request_count()); @@ -1861,80 +1959,10 @@ TEST_F(UpdatesTest, UpdateBalancerName) { EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); } -// Send an update with the same set of LBs as the one in SetUp() in order to -// verify that the LB channel inside xds keeps the initial connection (which -// by definition is also present in the update). -TEST_F(UpdatesTest, UpdateBalancersRepeated) { - SetNextResolution({}, kDefaultServiceConfig_.c_str()); - SetNextResolutionForLbChannelAllBalancers(); - EdsServiceImpl::ResponseArgs args({ - {"locality0", {backends_[0]->port()}}, - }); - ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0); - args = EdsServiceImpl::ResponseArgs({ - {"locality0", {backends_[1]->port()}}, - }); - ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(args), 0); - - // Wait until the first backend is ready. - WaitForBackend(0); - - // Send 10 requests. - gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); - CheckRpcSendOk(10); - gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); - - // All 10 requests should have gone to the first backend. - EXPECT_EQ(10U, backends_[0]->backend_service()->request_count()); - - // The EDS service of balancer 0 got a single request, and sent a single - // response. - EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); - EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); - EXPECT_EQ(0U, balancers_[1]->eds_service()->request_count()); - EXPECT_EQ(0U, balancers_[1]->eds_service()->response_count()); - EXPECT_EQ(0U, balancers_[2]->eds_service()->request_count()); - EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); - - std::vector ports; - ports.emplace_back(balancers_[0]->port()); - ports.emplace_back(balancers_[1]->port()); - ports.emplace_back(balancers_[2]->port()); - gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 1 =========="); - SetNextResolutionForLbChannel(ports); - gpr_log(GPR_INFO, "========= UPDATE 1 DONE =========="); - - EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); - gpr_timespec deadline = gpr_time_add( - gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(10000, GPR_TIMESPAN)); - // Send 10 seconds worth of RPCs - do { - CheckRpcSendOk(); - } while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0); - // xds continued using the original LB call to the first balancer, which - // doesn't assign the second backend. - EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); - - ports.clear(); - ports.emplace_back(balancers_[0]->port()); - ports.emplace_back(balancers_[1]->port()); - gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 2 =========="); - SetNextResolutionForLbChannel(ports); - gpr_log(GPR_INFO, "========= UPDATE 2 DONE =========="); - - EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); - deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_millis(10000, GPR_TIMESPAN)); - // Send 10 seconds worth of RPCs - do { - CheckRpcSendOk(); - } while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0); - // xds continued using the original LB call to the first balancer, which - // doesn't assign the second backend. - EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); -} - -TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { +// Tests that if the balancer is down, the RPCs will still be sent to the +// backends according to the last balancer response, until a new balancer is +// reachable. +TEST_F(BalancerUpdateTest, DeadUpdate) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannel({balancers_[0]->port()}); EdsServiceImpl::ResponseArgs args({ @@ -1945,19 +1973,16 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { {"locality0", {backends_[1]->port()}}, }); ScheduleResponseForBalancer(1, EdsServiceImpl::BuildResponse(args), 0); - // Start servers and send 10 RPCs per server. gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); CheckRpcSendOk(10); gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); // All 10 requests should have gone to the first backend. EXPECT_EQ(10U, backends_[0]->backend_service()->request_count()); - // Kill balancer 0 gpr_log(GPR_INFO, "********** ABOUT TO KILL BALANCER 0 *************"); balancers_[0]->Shutdown(); gpr_log(GPR_INFO, "********** KILLED BALANCER 0 *************"); - // This is serviced by the existing child policy. gpr_log(GPR_INFO, "========= BEFORE SECOND BATCH =========="); CheckRpcSendOk(10); @@ -1965,7 +1990,6 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { // All 10 requests should again have gone to the first backend. EXPECT_EQ(20U, backends_[0]->backend_service()->request_count()); EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); - // The EDS service of balancer 0 got a single request, and sent a single // response. EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); @@ -1974,17 +1998,14 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { EXPECT_EQ(0U, balancers_[1]->eds_service()->response_count()); EXPECT_EQ(0U, balancers_[2]->eds_service()->request_count()); EXPECT_EQ(0U, balancers_[2]->eds_service()->response_count()); - gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 1 =========="); SetNextResolutionForLbChannel({balancers_[1]->port()}); gpr_log(GPR_INFO, "========= UPDATE 1 DONE =========="); - // Wait until update has been processed, as signaled by the second backend // receiving a request. In the meantime, the client continues to be serviced // (by the first backend) without interruption. EXPECT_EQ(0U, backends_[1]->backend_service()->request_count()); WaitForBackend(1); - // This is serviced by the updated RR policy backends_[1]->backend_service()->ResetCounters(); gpr_log(GPR_INFO, "========= BEFORE THIRD BATCH =========="); @@ -1992,7 +2013,6 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { gpr_log(GPR_INFO, "========= DONE WITH THIRD BATCH =========="); // All 10 requests should have gone to the second backend. EXPECT_EQ(10U, backends_[1]->backend_service()->request_count()); - EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count()); EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count()); // The second balancer, published as part of the first update, may end up @@ -2010,17 +2030,18 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { // The re-resolution tests are deferred because they rely on the fallback mode, // which hasn't been supported. -// TODO(juanlishen): Add TEST_F(UpdatesTest, ReresolveDeadBackend). +// TODO(juanlishen): Add TEST_F(BalancerUpdateTest, ReresolveDeadBackend). // TODO(juanlishen): Add TEST_F(UpdatesWithClientLoadReportingTest, // ReresolveDeadBalancer) -class SingleBalancerWithClientLoadReportingTest : public XdsEnd2endTest { +class ClientLoadReportingTest : public XdsEnd2endTest { public: - SingleBalancerWithClientLoadReportingTest() : XdsEnd2endTest(4, 1, 3) {} + ClientLoadReportingTest() : XdsEnd2endTest(4, 1, 3) {} }; -TEST_F(SingleBalancerWithClientLoadReportingTest, Vanilla) { +// Tests that the load report received at the balancer is correct. +TEST_F(ClientLoadReportingTest, Vanilla) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannel({balancers_[0]->port()}); const size_t kNumRpcsPerAddress = 100; @@ -2059,7 +2080,9 @@ TEST_F(SingleBalancerWithClientLoadReportingTest, Vanilla) { EXPECT_EQ(0U, client_stats->total_dropped_requests()); } -TEST_F(SingleBalancerWithClientLoadReportingTest, BalancerRestart) { +// Tests that if the balancer restarts, the client load report contains the +// stats before and after the restart correctly. +TEST_F(ClientLoadReportingTest, BalancerRestart) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannel({balancers_[0]->port()}); const size_t kNumBackendsFirstPass = backends_.size() / 2; @@ -2116,13 +2139,13 @@ TEST_F(SingleBalancerWithClientLoadReportingTest, BalancerRestart) { EXPECT_EQ(0U, client_stats->total_dropped_requests()); } -class SingleBalancerWithClientLoadReportingAndDropTest : public XdsEnd2endTest { +class ClientLoadReportingWithDropTest : public XdsEnd2endTest { public: - SingleBalancerWithClientLoadReportingAndDropTest() - : XdsEnd2endTest(4, 1, 20) {} + ClientLoadReportingWithDropTest() : XdsEnd2endTest(4, 1, 20) {} }; -TEST_F(SingleBalancerWithClientLoadReportingAndDropTest, Vanilla) { +// Tests that the drop stats are correctly reported by client load reporting. +TEST_F(ClientLoadReportingWithDropTest, Vanilla) { SetNextResolution({}, kDefaultServiceConfig_.c_str()); SetNextResolutionForLbChannelAllBalancers(); const size_t kNumRpcs = 3000; From 88aef7cd75bcdb703d041317a5b719619fc71da8 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 3 Sep 2019 17:12:28 -0700 Subject: [PATCH 1445/1555] Fix default case --- src/compiler/python_generator.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc index f553d9e7a3c..8935a516f8a 100644 --- a/src/compiler/python_generator.cc +++ b/src/compiler/python_generator.cc @@ -763,7 +763,7 @@ static bool ParseParameters(const grpc::string& parameter, std::vector comma_delimited_parameters; grpc_python_generator::Split(parameter, ',', &comma_delimited_parameters); if (comma_delimited_parameters.size() == 1 && - comma_delimited_parameters.empty()) { + comma_delimited_parameters[0].empty()) { *grpc_version = "grpc_2_0"; } else if (comma_delimited_parameters.size() == 1) { *grpc_version = comma_delimited_parameters[0]; From ce9e6376149a82840645e8b7cef152033f71c741 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 29 Aug 2019 13:53:37 +0200 Subject: [PATCH 1446/1555] enable server compression tests for grpc.aspnetcore.server --- tools/run_tests/run_interop_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py index 0847d8426b8..099b8c7b1a5 100755 --- a/tools/run_tests/run_interop_tests.py +++ b/tools/run_tests/run_interop_tests.py @@ -211,7 +211,7 @@ class AspNetCoreLanguage: _SKIP_COMPUTE_ENGINE_CHANNEL_CREDS def unimplemented_test_cases_server(self): - return _SKIP_SERVER_COMPRESSION + return [] def __str__(self): return 'aspnetcore' From 36574888be8cabfb66345be8ffd1c152d80e0183 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 29 Aug 2019 09:53:41 -0400 Subject: [PATCH 1447/1555] upgrade bazel to 0.29 --- templates/tools/dockerfile/bazel.include | 2 +- tools/bazel | 2 +- tools/dockerfile/test/bazel/Dockerfile | 2 +- tools/dockerfile/test/sanity/Dockerfile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/tools/dockerfile/bazel.include b/templates/tools/dockerfile/bazel.include index 12a22785623..9762bdcb85f 100644 --- a/templates/tools/dockerfile/bazel.include +++ b/templates/tools/dockerfile/bazel.include @@ -2,7 +2,7 @@ # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.28.1 +ENV BAZEL_VERSION 0.29.0 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/bazel b/tools/bazel index 4d1d57f60d9..cfa875b0e63 100755 --- a/tools/bazel +++ b/tools/bazel @@ -32,7 +32,7 @@ then exec -a "$0" "${BAZEL_REAL}" "$@" fi -VERSION=0.28.1 +VERSION=0.29.0 echo "INFO: Running bazel wrapper (see //tools/bazel for details), bazel version $VERSION will be used instead of system-wide bazel installation." diff --git a/tools/dockerfile/test/bazel/Dockerfile b/tools/dockerfile/test/bazel/Dockerfile index 7141fb9c5f1..fde54bae877 100644 --- a/tools/dockerfile/test/bazel/Dockerfile +++ b/tools/dockerfile/test/bazel/Dockerfile @@ -52,7 +52,7 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.2.post1 six==1.10.0 t # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.28.1 +ENV BAZEL_VERSION 0.29.0 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index badff52de34..4d3691f32bd 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -97,7 +97,7 @@ ENV CLANG_TIDY=clang-tidy # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.28.1 +ENV BAZEL_VERSION 0.29.0 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 From 0c3a5990b1c3117f5808eed8933607772ef37e69 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 4 Sep 2019 03:48:40 -0400 Subject: [PATCH 1448/1555] upgrade windows RBE to bazel 0.29 --- tools/internal_ci/windows/bazel_rbe.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat index 153b2d59687..e55534e2e84 100644 --- a/tools/internal_ci/windows/bazel_rbe.bat +++ b/tools/internal_ci/windows/bazel_rbe.bat @@ -14,7 +14,7 @@ @rem TODO(jtattermusch): make this generate less output @rem TODO(jtattermusch): use tools/bazel script to keep the versions in sync -choco install bazel -y --version 0.26.0 --limit-output +choco install bazel -y --version 0.29.0 --limit-output cd github/grpc set PATH=C:\tools\msys64\usr\bin;C:\Python27;%PATH% From 08dc3310191031cf6eccb98c49216a407d4d0c0f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 4 Sep 2019 04:09:21 -0400 Subject: [PATCH 1449/1555] try fix win RBE build --- tools/internal_ci/windows/bazel_rbe.bat | 2 +- tools/remote_build/windows.bazelrc | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat index e55534e2e84..8d8ea118ebd 100644 --- a/tools/internal_ci/windows/bazel_rbe.bat +++ b/tools/internal_ci/windows/bazel_rbe.bat @@ -24,7 +24,7 @@ powershell -Command "[guid]::NewGuid().ToString()" >%KOKORO_ARTIFACTS_DIR%/bazel set /p BAZEL_INVOCATION_ID=<%KOKORO_ARTIFACTS_DIR%/bazel_invocation_ids @rem TODO(jtattermusch): windows RBE should be able to use the same credentials as Linux RBE. -bazel --bazelrc=tools/remote_build/windows.bazelrc build --invocation_id="%BAZEL_INVOCATION_ID%" --workspace_status_command=tools/remote_build/workspace_status_kokoro.sh :all --incompatible_disallow_filetype=false --google_credentials=%KOKORO_GFILE_DIR%/rbe-windows-credentials.json +bazel --bazelrc=tools/remote_build/windows.bazelrc build --invocation_id="%BAZEL_INVOCATION_ID%" --workspace_status_command=tools/remote_build/workspace_status_kokoro.sh :all --google_credentials=%KOKORO_GFILE_DIR%/rbe-windows-credentials.json set BAZEL_EXITCODE=%errorlevel% @rem TODO(jtattermusch): upload results to bigquery diff --git a/tools/remote_build/windows.bazelrc b/tools/remote_build/windows.bazelrc index 9fd3071e79f..825d6765de9 100644 --- a/tools/remote_build/windows.bazelrc +++ b/tools/remote_build/windows.bazelrc @@ -1,8 +1,7 @@ startup --host_jvm_args=-Dbazel.DigestFunction=SHA256 -build --remote_cache=remotebuildexecution.googleapis.com -build --remote_executor=remotebuildexecution.googleapis.com -build --tls_enabled=true +build --remote_cache=grpcs://remotebuildexecution.googleapis.com +build --remote_executor=grpcs://remotebuildexecution.googleapis.com build --host_crosstool_top=//third_party/toolchains/bazel_0.26.0_rbe_windows:toolchain build --crosstool_top=//third_party/toolchains/bazel_0.26.0_rbe_windows:toolchain @@ -38,7 +37,7 @@ test --test_env=GRPC_VERBOSITY=debug # Set flags for uploading to BES in order to view results in the Bazel Build # Results UI. -build --bes_backend="buildeventservice.googleapis.com" +build --bes_backend=grpcs://buildeventservice.googleapis.com build --bes_timeout=60s build --bes_results_url="https://source.cloud.google.com/results/invocations/" build --project_id=grpc-testing From 0040bb9353f782b788e4bbbe20efdc87b36aa619 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 21 Nov 2018 10:55:41 +0100 Subject: [PATCH 1450/1555] attempt to add alpine C# distribtest --- .../DistribTest/DistribTestDotNet.csproj | 2 +- .../csharp/run_distrib_test_dotnetcli.sh | 17 ++++++++----- .../distribtest/csharp_alpine_x64/Dockerfile | 24 +++++++++++++++++++ .../artifacts/distribtest_targets.py | 1 + 4 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 tools/dockerfile/distribtest/csharp_alpine_x64/Dockerfile diff --git a/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj b/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj index d19eac91ba4..8cdf926f07f 100644 --- a/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj +++ b/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp1.0;net45 + netcoreapp2.1 false false false diff --git a/test/distrib/csharp/run_distrib_test_dotnetcli.sh b/test/distrib/csharp/run_distrib_test_dotnetcli.sh index 86c2d5231e1..357ce136cb7 100755 --- a/test/distrib/csharp/run_distrib_test_dotnetcli.sh +++ b/test/distrib/csharp/run_distrib_test_dotnetcli.sh @@ -28,19 +28,24 @@ cd DistribTest dotnet restore DistribTestDotNet.csproj dotnet build DistribTestDotNet.csproj -dotnet publish -f netcoreapp1.0 DistribTestDotNet.csproj -dotnet publish -f net45 DistribTestDotNet.csproj +dotnet publish -f netcoreapp2.1 DistribTestDotNet.csproj +#dotnet publish -f net45 DistribTestDotNet.csproj ls -R bin +#ldd /root/.nuget/packages/grpc.core/*/lib/netstandard1.5/../../runtimes/linux/native/libgrpc_csharp_ext.x64.so + +#ldd /root/.nuget/packages/grpc.tools/*/tools/linux_x64/grpc_csharp_plugin + +#exit 1 # .NET 4.5 target after dotnet build -mono bin/Debug/net45/publish/DistribTestDotNet.exe +#mono bin/Debug/net45/publish/DistribTestDotNet.exe # .NET 4.5 target after dotnet publish -mono bin/Debug/net45/publish/DistribTestDotNet.exe +#mono bin/Debug/net45/publish/DistribTestDotNet.exe # .NET Core target after dotnet build -dotnet exec bin/Debug/netcoreapp1.0/DistribTestDotNet.dll +dotnet exec bin/Debug/netcoreapp2.1/DistribTestDotNet.dll # .NET Core target after dotnet publish -dotnet exec bin/Debug/netcoreapp1.0/publish/DistribTestDotNet.dll +dotnet exec bin/Debug/netcoreapp2.1/publish/DistribTestDotNet.dll diff --git a/tools/dockerfile/distribtest/csharp_alpine_x64/Dockerfile b/tools/dockerfile/distribtest/csharp_alpine_x64/Dockerfile new file mode 100644 index 00000000000..aa5034872c3 --- /dev/null +++ b/tools/dockerfile/distribtest/csharp_alpine_x64/Dockerfile @@ -0,0 +1,24 @@ +# Copyright 2015 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM microsoft/dotnet:2.1-sdk-alpine + +RUN apk update && apk add bash +RUN apk update && apk add unzip + +# needed to satisfy the "ld-linux-x86-64.so.2" dependency +RUN apk add libc6-compat + +#RUN apk add libnsl +#RUN cp /usr/lib/libnsl.so.2 /usr/lib/libnsl.so.1 diff --git a/tools/run_tests/artifacts/distribtest_targets.py b/tools/run_tests/artifacts/distribtest_targets.py index 35a561ea928..d45abdcbd41 100644 --- a/tools/run_tests/artifacts/distribtest_targets.py +++ b/tools/run_tests/artifacts/distribtest_targets.py @@ -309,6 +309,7 @@ def targets(): CSharpDistribTest('linux', 'x64', 'ubuntu1404'), CSharpDistribTest('linux', 'x64', 'ubuntu1604'), CSharpDistribTest('linux', 'x64', 'ubuntu1404', use_dotnet_cli=True), + CSharpDistribTest('linux', 'x64', 'alpine', use_dotnet_cli=True), CSharpDistribTest('macos', 'x86'), CSharpDistribTest('windows', 'x86'), CSharpDistribTest('windows', 'x64'), From 32dbe30b3517c8f4d93b6141d1f9066c2b53d960 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 4 Sep 2019 11:04:04 -0400 Subject: [PATCH 1451/1555] add .NET Core distribtest for ubuntu 16.04 --- .../distribtest/csharp_ubuntu1604_x64/Dockerfile | 10 ++++++++++ tools/run_tests/artifacts/distribtest_targets.py | 1 + 2 files changed, 11 insertions(+) diff --git a/tools/dockerfile/distribtest/csharp_ubuntu1604_x64/Dockerfile b/tools/dockerfile/distribtest/csharp_ubuntu1604_x64/Dockerfile index 93ee75cfcd4..e0d8c458d0a 100644 --- a/tools/dockerfile/distribtest/csharp_ubuntu1604_x64/Dockerfile +++ b/tools/dockerfile/distribtest/csharp_ubuntu1604_x64/Dockerfile @@ -24,6 +24,16 @@ RUN apt-get update && apt-get install -y \ nuget \ && apt-get clean +RUN apt-get update && apt-get install -y curl && apt-get clean + +# Install dotnet SDK +ENV DOTNET_SDK_VERSION 2.1.500 +RUN curl -sSL -o dotnet.tar.gz https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz \ + && mkdir -p /usr/share/dotnet \ + && tar -zxf dotnet.tar.gz -C /usr/share/dotnet \ + && rm dotnet.tar.gz \ + && ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet + RUN apt-get update && apt-get install -y unzip && apt-get clean # Make sure the mono certificate store is up-to-date to prevent issues with nuget restore diff --git a/tools/run_tests/artifacts/distribtest_targets.py b/tools/run_tests/artifacts/distribtest_targets.py index d45abdcbd41..e221dee3ab8 100644 --- a/tools/run_tests/artifacts/distribtest_targets.py +++ b/tools/run_tests/artifacts/distribtest_targets.py @@ -308,6 +308,7 @@ def targets(): CSharpDistribTest('linux', 'x64', 'centos7'), CSharpDistribTest('linux', 'x64', 'ubuntu1404'), CSharpDistribTest('linux', 'x64', 'ubuntu1604'), + CSharpDistribTest('linux', 'x64', 'ubuntu1604', use_dotnet_cli=True), CSharpDistribTest('linux', 'x64', 'ubuntu1404', use_dotnet_cli=True), CSharpDistribTest('linux', 'x64', 'alpine', use_dotnet_cli=True), CSharpDistribTest('macos', 'x86'), From f4c723556650dd49df1c1ad0c93eab4e7d86e5ca Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 4 Sep 2019 11:06:23 -0400 Subject: [PATCH 1452/1555] get rid of ubuntu14.04 C# distribtests --- .../csharp_ubuntu1404_x64/Dockerfile | 44 ------------------- .../artifacts/distribtest_targets.py | 2 - 2 files changed, 46 deletions(-) delete mode 100644 tools/dockerfile/distribtest/csharp_ubuntu1404_x64/Dockerfile diff --git a/tools/dockerfile/distribtest/csharp_ubuntu1404_x64/Dockerfile b/tools/dockerfile/distribtest/csharp_ubuntu1404_x64/Dockerfile deleted file mode 100644 index 61ca1a08a46..00000000000 --- a/tools/dockerfile/distribtest/csharp_ubuntu1404_x64/Dockerfile +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2015 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FROM ubuntu:14.04 - -RUN apt-get update && apt-get install -y apt-transport-https && apt-get clean - -RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF -RUN echo "deb https://download.mono-project.com/repo/ubuntu stable-trusty main" | tee /etc/apt/sources.list.d/mono-official-stable.list - -RUN apt-get update && apt-get install -y \ - mono-devel \ - nuget \ - && apt-get clean - -RUN apt-get update && apt-get install -y unzip && apt-get clean - -# Install dotnet CLI -RUN apt-get install -y apt-transport-https -RUN sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list' -RUN apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893 -RUN apt-get update && apt-get install -y dotnet-dev-1.0.4 - -# Trigger the population of the local package cache for dotnet CLI -RUN mkdir warmup \ - && cd warmup \ - && dotnet new \ - && cd .. \ - && rm -rf warmup - -# Make sure the mono certificate store is up-to-date to prevent issues with nuget restore -RUN apt-get update && apt-get install -y curl && apt-get clean -RUN curl https://curl.haxx.se/ca/cacert.pem > ~/cacert.pem && cert-sync ~/cacert.pem && rm -f ~/cacert.pem diff --git a/tools/run_tests/artifacts/distribtest_targets.py b/tools/run_tests/artifacts/distribtest_targets.py index e221dee3ab8..2c7af6e37fc 100644 --- a/tools/run_tests/artifacts/distribtest_targets.py +++ b/tools/run_tests/artifacts/distribtest_targets.py @@ -306,10 +306,8 @@ def targets(): CSharpDistribTest('linux', 'x64', 'jessie'), CSharpDistribTest('linux', 'x86', 'jessie'), CSharpDistribTest('linux', 'x64', 'centos7'), - CSharpDistribTest('linux', 'x64', 'ubuntu1404'), CSharpDistribTest('linux', 'x64', 'ubuntu1604'), CSharpDistribTest('linux', 'x64', 'ubuntu1604', use_dotnet_cli=True), - CSharpDistribTest('linux', 'x64', 'ubuntu1404', use_dotnet_cli=True), CSharpDistribTest('linux', 'x64', 'alpine', use_dotnet_cli=True), CSharpDistribTest('macos', 'x86'), CSharpDistribTest('windows', 'x86'), From e0b87cd4a13bb29eb68350b0207b75fdb9f8cd9f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 4 Sep 2019 11:26:27 -0400 Subject: [PATCH 1453/1555] add debian stretch distribtest --- .../distribtest/csharp_stretch_x64/Dockerfile | 41 +++++++++++++++++++ .../artifacts/distribtest_targets.py | 2 + 2 files changed, 43 insertions(+) create mode 100644 tools/dockerfile/distribtest/csharp_stretch_x64/Dockerfile diff --git a/tools/dockerfile/distribtest/csharp_stretch_x64/Dockerfile b/tools/dockerfile/distribtest/csharp_stretch_x64/Dockerfile new file mode 100644 index 00000000000..97779c52f8b --- /dev/null +++ b/tools/dockerfile/distribtest/csharp_stretch_x64/Dockerfile @@ -0,0 +1,41 @@ +# Copyright 2019 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM debian:stretch + +RUN apt-get update && apt-get install -y apt-transport-https dirmngr gnupg ca-certificates && apt-get clean + +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF +RUN echo "deb https://download.mono-project.com/repo/debian stable-stretch main" | tee /etc/apt/sources.list.d/mono-official-stable.list + +RUN apt-get update && apt-get install -y \ + mono-devel \ + nuget \ + && apt-get clean + +RUN apt-get update && apt-get install -y curl && apt-get clean + +# Install dotnet SDK +ENV DOTNET_SDK_VERSION 2.1.500 +RUN curl -sSL -o dotnet.tar.gz https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz \ + && mkdir -p /usr/share/dotnet \ + && tar -zxf dotnet.tar.gz -C /usr/share/dotnet \ + && rm dotnet.tar.gz \ + && ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet + +RUN apt-get update && apt-get install -y unzip && apt-get clean + +# Make sure the mono certificate store is up-to-date to prevent issues with nuget restore +RUN apt-get update && apt-get install -y curl && apt-get clean +RUN curl https://curl.haxx.se/ca/cacert.pem > ~/cacert.pem && cert-sync ~/cacert.pem && rm -f ~/cacert.pem diff --git a/tools/run_tests/artifacts/distribtest_targets.py b/tools/run_tests/artifacts/distribtest_targets.py index 2c7af6e37fc..5baf9d6c298 100644 --- a/tools/run_tests/artifacts/distribtest_targets.py +++ b/tools/run_tests/artifacts/distribtest_targets.py @@ -305,6 +305,8 @@ def targets(): CppDistribTest('windows', 'x86', testcase='cmake_as_externalproject'), CSharpDistribTest('linux', 'x64', 'jessie'), CSharpDistribTest('linux', 'x86', 'jessie'), + CSharpDistribTest('linux', 'x64', 'stretch'), + CSharpDistribTest('linux', 'x64', 'stretch', use_dotnet_cli=True), CSharpDistribTest('linux', 'x64', 'centos7'), CSharpDistribTest('linux', 'x64', 'ubuntu1604'), CSharpDistribTest('linux', 'x64', 'ubuntu1604', use_dotnet_cli=True), From 21104ec1ee26d2f89affaa76a737ec23fb185e61 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 4 Sep 2019 11:29:22 -0400 Subject: [PATCH 1454/1555] remove BOM --- test/distrib/csharp/DistribTest/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/distrib/csharp/DistribTest/Program.cs b/test/distrib/csharp/DistribTest/Program.cs index 0ea7211fc45..92f416785a6 100644 --- a/test/distrib/csharp/DistribTest/Program.cs +++ b/test/distrib/csharp/DistribTest/Program.cs @@ -16,7 +16,7 @@ #endregion -using System; +using System; using Grpc.Core; namespace TestGrpcPackage From 504c4ace804ba7e18c84125501628cf5cb327e97 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 4 Sep 2019 11:32:31 -0400 Subject: [PATCH 1455/1555] remove legacy c# testcodegen --- test/distrib/csharp/run_distrib_test.sh | 3 -- .../csharp/test_codegen/test_codegen.sh | 38 ------------------- .../csharp/test_codegen/testcodegen.proto | 29 -------------- test/distrib/csharp/update_version.sh | 2 +- 4 files changed, 1 insertion(+), 71 deletions(-) delete mode 100755 test/distrib/csharp/test_codegen/test_codegen.sh delete mode 100644 test/distrib/csharp/test_codegen/testcodegen.proto diff --git a/test/distrib/csharp/run_distrib_test.sh b/test/distrib/csharp/run_distrib_test.sh index 45911cd91a7..824e33e2876 100755 --- a/test/distrib/csharp/run_distrib_test.sh +++ b/test/distrib/csharp/run_distrib_test.sh @@ -27,6 +27,3 @@ nuget restore || nuget restore || nuget restore msbuild DistribTest.sln mono DistribTest/bin/Debug/DistribTest.exe - -# test that codegen work -test_codegen/test_codegen.sh diff --git a/test/distrib/csharp/test_codegen/test_codegen.sh b/test/distrib/csharp/test_codegen/test_codegen.sh deleted file mode 100755 index fa101889f68..00000000000 --- a/test/distrib/csharp/test_codegen/test_codegen.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# Copyright 2018 The gRPC Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -ex - -cd "$(dirname "$0")" - -ls -lR "../packages/Grpc.Tools.__GRPC_NUGET_VERSION__/tools" - -PLATFORM_ARCH=linux_x64 -if [ "$(uname)" == "Darwin" ] -then - PLATFORM_ARCH=macosx_x64 -elif [ "$(getconf LONG_BIT)" == "32" ] -then - PLATFORM_ARCH=linux_x86 -fi - -PROTOC=../packages/Grpc.Tools.__GRPC_NUGET_VERSION__/tools/${PLATFORM_ARCH}/protoc -PLUGIN=../packages/Grpc.Tools.__GRPC_NUGET_VERSION__/tools/${PLATFORM_ARCH}/grpc_csharp_plugin - -"${PROTOC}" --plugin="protoc-gen-grpc=${PLUGIN}" --csharp_out=. --grpc_out=. -I . testcodegen.proto - -ls ./*.cs - -echo 'Code generation works.' diff --git a/test/distrib/csharp/test_codegen/testcodegen.proto b/test/distrib/csharp/test_codegen/testcodegen.proto deleted file mode 100644 index 5c228b81dba..00000000000 --- a/test/distrib/csharp/test_codegen/testcodegen.proto +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2018 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package testcodegen; - -service Greeter { - rpc SayHello (HelloRequest) returns (HelloReply) {} -} - -message HelloRequest { - string name = 1; -} - -message HelloReply { - string message = 1; -} diff --git a/test/distrib/csharp/update_version.sh b/test/distrib/csharp/update_version.sh index 0e47ed3abd5..9759cc56481 100755 --- a/test/distrib/csharp/update_version.sh +++ b/test/distrib/csharp/update_version.sh @@ -28,4 +28,4 @@ then fi # Replaces version placeholder with value provided as first argument. -sed -ibak "s/__GRPC_NUGET_VERSION__/${CSHARP_VERSION}/g" DistribTest/packages.config DistribTest/DistribTest.csproj DistribTest/DistribTestDotNet.csproj test_codegen/test_codegen.sh +sed -ibak "s/__GRPC_NUGET_VERSION__/${CSHARP_VERSION}/g" DistribTest/packages.config DistribTest/DistribTest.csproj DistribTest/DistribTestDotNet.csproj From aeb04913adfcbf90cf3dd4c2cb1aa8f55ac54508 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 9 Apr 2019 12:41:27 -0400 Subject: [PATCH 1456/1555] improved C# distribtest --- test/distrib/csharp/DistribTest/Program.cs | 42 +++++++++++++++---- .../csharp/DistribTest/testcodegen.proto | 2 +- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/test/distrib/csharp/DistribTest/Program.cs b/test/distrib/csharp/DistribTest/Program.cs index 92f416785a6..bda7b2104d6 100644 --- a/test/distrib/csharp/DistribTest/Program.cs +++ b/test/distrib/csharp/DistribTest/Program.cs @@ -17,7 +17,10 @@ #endregion using System; +using System.Linq; +using System.Threading.Tasks; using Grpc.Core; +using Helloworld; namespace TestGrpcPackage { @@ -25,14 +28,39 @@ namespace TestGrpcPackage { public static void Main(string[] args) { - // test codegen works - var reply = new Testcodegen.HelloReply(); + // Disable SO_REUSEPORT to prevent https://github.com/grpc/grpc/issues/10755 + Server server = new Server(new[] { new ChannelOption(ChannelOptions.SoReuseport, 0) }) + { + Services = { Greeter.BindService(new GreeterImpl()) }, + Ports = { new ServerPort("localhost", ServerPort.PickUnused, ServerCredentials.Insecure) } + }; + server.Start(); - // This code doesn't do much but makes sure the native extension is loaded - // which is what we are testing here. - Channel c = new Channel("127.0.0.1:1000", ChannelCredentials.Insecure); - c.ShutdownAsync().Wait(); - Console.WriteLine("Success!"); + Channel channel = new Channel("localhost", server.Ports.Single().BoundPort, ChannelCredentials.Insecure); + + try + { + var client = new Greeter.GreeterClient(channel); + String user = "you"; + + var reply = client.SayHello(new HelloRequest { Name = user }); + Console.WriteLine("Greeting: " + reply.Message); + Console.WriteLine("Success!"); + } + finally + { + channel.ShutdownAsync().Wait(); + server.ShutdownAsync().Wait(); + } + } + } + + class GreeterImpl : Greeter.GreeterBase + { + // Server side handler of the SayHello RPC + public override Task SayHello(HelloRequest request, ServerCallContext context) + { + return Task.FromResult(new HelloReply { Message = "Hello " + request.Name }); } } } diff --git a/test/distrib/csharp/DistribTest/testcodegen.proto b/test/distrib/csharp/DistribTest/testcodegen.proto index 7845ac92c49..61444fc080e 100644 --- a/test/distrib/csharp/DistribTest/testcodegen.proto +++ b/test/distrib/csharp/DistribTest/testcodegen.proto @@ -14,7 +14,7 @@ syntax = "proto3"; -package testcodegen; +package helloworld; service Greeter { rpc SayHello (HelloRequest) returns (HelloReply) {} From a5560e8f7300463d4cb3506bb5fee73446affd8c Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 4 Sep 2019 09:20:33 -0700 Subject: [PATCH 1457/1555] Fix PHP build error --- config.m4 | 2 ++ src/php/ext/grpc/config.m4 | 7 ++++--- templates/config.m4.template | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config.m4 b/config.m4 index 4a8651dae38..efa86576f84 100644 --- a/config.m4 +++ b/config.m4 @@ -33,6 +33,8 @@ if test "$PHP_GRPC" != "no"; then ;; esac + PHP_SUBST(GRPC_SHARED_LIBADD) + PHP_NEW_EXTENSION(grpc, src/php/ext/grpc/byte_buffer.c \ src/php/ext/grpc/call.c \ diff --git a/src/php/ext/grpc/config.m4 b/src/php/ext/grpc/config.m4 index 1af93ceecad..ed62dee71cc 100755 --- a/src/php/ext/grpc/config.m4 +++ b/src/php/ext/grpc/config.m4 @@ -42,14 +42,15 @@ if test "$PHP_GRPC" != "no"; then dnl PHP_ADD_LIBRARY(pthread,,GRPC_SHARED_LIBADD) GRPC_SHARED_LIBADD="-lpthread $GRPC_SHARED_LIBADD" PHP_ADD_LIBRARY(pthread) - PHP_ADD_LIBRARY(stdc++,,GRPC_SHARED_LIBADD) - PHP_ADD_LIBRARY(stdc++) PHP_ADD_LIBRARY(dl,,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(dl) case $host in - *darwin*) ;; + *darwin*) + PHP_ADD_LIBRARY(c++,1,GRPC_SHARED_LIBADD) + ;; *) + PHP_ADD_LIBRARY(stdc++,1,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(rt) ;; diff --git a/templates/config.m4.template b/templates/config.m4.template index f13ac75914f..edb6a99dc67 100644 --- a/templates/config.m4.template +++ b/templates/config.m4.template @@ -35,6 +35,8 @@ ;; esac + PHP_SUBST(GRPC_SHARED_LIBADD) + PHP_NEW_EXTENSION(grpc, % for source in php_config_m4.src: ${source} ${"\\"} From 539b422708be9fc4ced914bf6738de49dc794852 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 4 Sep 2019 17:26:26 -0700 Subject: [PATCH 1458/1555] Trim trailing spaces --- src/php/ext/grpc/config.m4 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/php/ext/grpc/config.m4 b/src/php/ext/grpc/config.m4 index ed62dee71cc..7260dbc72ef 100755 --- a/src/php/ext/grpc/config.m4 +++ b/src/php/ext/grpc/config.m4 @@ -46,7 +46,7 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_LIBRARY(dl) case $host in - *darwin*) + *darwin*) PHP_ADD_LIBRARY(c++,1,GRPC_SHARED_LIBADD) ;; *) @@ -94,7 +94,7 @@ if test "$PHP_COVERAGE" = "yes"; then if test "$GCC" != "yes"; then AC_MSG_ERROR([GCC is required for --enable-coverage]) fi - + dnl Check if ccache is being used case `$php_shtool path $CC` in *ccache*[)] gcc_ccache=yes;; @@ -104,7 +104,7 @@ if test "$PHP_COVERAGE" = "yes"; then if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then AC_MSG_ERROR([ccache must be disabled when --enable-coverage option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.]) fi - + lcov_version_list="1.5 1.6 1.7 1.9 1.10 1.11 1.12 1.13" AC_CHECK_PROG(LCOV, lcov, lcov) @@ -123,7 +123,7 @@ if test "$PHP_COVERAGE" = "yes"; then done ]) else - lcov_msg="To enable code coverage reporting you must have one of the following LCOV versions installed: $lcov_version_list" + lcov_msg="To enable code coverage reporting you must have one of the following LCOV versions installed: $lcov_version_list" AC_MSG_ERROR([$lcov_msg]) fi From 1a331967102a7741369ee7f333a50e6418bb50ed Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 5 Sep 2019 09:50:21 +0200 Subject: [PATCH 1459/1555] upgrade helloworld example to 2.23.0 --- examples/csharp/Helloworld/Greeter/Greeter.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/csharp/Helloworld/Greeter/Greeter.csproj b/examples/csharp/Helloworld/Greeter/Greeter.csproj index 7989f795418..223b7fe1242 100644 --- a/examples/csharp/Helloworld/Greeter/Greeter.csproj +++ b/examples/csharp/Helloworld/Greeter/Greeter.csproj @@ -5,9 +5,9 @@ - - - + + + From cbac0b43616a1cb121923a70748be821c1cd02be Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 5 Sep 2019 09:50:41 +0200 Subject: [PATCH 1460/1555] upgrade routeguide example to 2.23.0 --- examples/csharp/RouteGuide/RouteGuide/RouteGuide.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/csharp/RouteGuide/RouteGuide/RouteGuide.csproj b/examples/csharp/RouteGuide/RouteGuide/RouteGuide.csproj index 4c6949488c7..bd374a887c1 100644 --- a/examples/csharp/RouteGuide/RouteGuide/RouteGuide.csproj +++ b/examples/csharp/RouteGuide/RouteGuide/RouteGuide.csproj @@ -5,9 +5,9 @@ - - - + + + From 10156898ea52c46e628aee42cd4c29d16ae21364 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 5 Sep 2019 09:58:11 +0200 Subject: [PATCH 1461/1555] upgrade helloworld classic example to 2.23.0 --- .../Greeter/Greeter.csproj | 30 ++++++++++++------- .../Greeter/packages.config | 15 ++++++---- .../GreeterClient/GreeterClient.csproj | 28 ++++++++++------- .../GreeterClient/packages.config | 13 ++++---- .../GreeterServer/GreeterServer.csproj | 28 ++++++++++------- .../GreeterServer/packages.config | 13 ++++---- 6 files changed, 80 insertions(+), 47 deletions(-) diff --git a/examples/csharp/HelloworldLegacyCsproj/Greeter/Greeter.csproj b/examples/csharp/HelloworldLegacyCsproj/Greeter/Greeter.csproj index da15ba3954b..adb2c7ac2c9 100644 --- a/examples/csharp/HelloworldLegacyCsproj/Greeter/Greeter.csproj +++ b/examples/csharp/HelloworldLegacyCsproj/Greeter/Greeter.csproj @@ -1,4 +1,4 @@ - + @@ -33,18 +33,26 @@ false - - ..\packages\Google.Protobuf.3.6.1\lib\net45\Google.Protobuf.dll + + ..\packages\Google.Protobuf.3.8.0\lib\net45\Google.Protobuf.dll - - ..\packages\Grpc.Core.1.17.0\lib\net45\Grpc.Core.dll + + ..\packages\Grpc.Core.2.23.0\lib\net45\Grpc.Core.dll + + + ..\packages\Grpc.Core.Api.2.23.0\lib\net45\Grpc.Core.Api.dll - - ..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll - True + + ..\packages\System.Buffers.4.4.0\lib\netstandard1.1\System.Buffers.dll + + ..\packages\System.Memory.4.5.3\lib\netstandard1.1\System.Memory.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll + @@ -57,14 +65,14 @@ - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + - + + \ No newline at end of file diff --git a/examples/csharp/HelloworldLegacyCsproj/Greeter/packages.config b/examples/csharp/HelloworldLegacyCsproj/Greeter/packages.config index 154b5993213..418bfaba736 100644 --- a/examples/csharp/HelloworldLegacyCsproj/Greeter/packages.config +++ b/examples/csharp/HelloworldLegacyCsproj/Greeter/packages.config @@ -1,8 +1,11 @@ - + - - - + + + + - - + + + + \ No newline at end of file diff --git a/examples/csharp/HelloworldLegacyCsproj/GreeterClient/GreeterClient.csproj b/examples/csharp/HelloworldLegacyCsproj/GreeterClient/GreeterClient.csproj index 31a3a90345b..ec860440cfb 100644 --- a/examples/csharp/HelloworldLegacyCsproj/GreeterClient/GreeterClient.csproj +++ b/examples/csharp/HelloworldLegacyCsproj/GreeterClient/GreeterClient.csproj @@ -1,4 +1,4 @@ - + Debug @@ -32,18 +32,26 @@ true - - ..\packages\Google.Protobuf.3.6.1\lib\net45\Google.Protobuf.dll + + ..\packages\Google.Protobuf.3.8.0\lib\net45\Google.Protobuf.dll - - ..\packages\Grpc.Core.1.17.0\lib\net45\Grpc.Core.dll + + ..\packages\Grpc.Core.2.23.0\lib\net45\Grpc.Core.dll + + + ..\packages\Grpc.Core.Api.2.23.0\lib\net45\Grpc.Core.Api.dll - - ..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll - True + + ..\packages\System.Buffers.4.4.0\lib\netstandard1.1\System.Buffers.dll + + ..\packages\System.Memory.4.5.3\lib\netstandard1.1\System.Memory.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll + @@ -59,11 +67,11 @@ - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/examples/csharp/HelloworldLegacyCsproj/GreeterClient/packages.config b/examples/csharp/HelloworldLegacyCsproj/GreeterClient/packages.config index 2fd8228689d..1f648dd06b8 100644 --- a/examples/csharp/HelloworldLegacyCsproj/GreeterClient/packages.config +++ b/examples/csharp/HelloworldLegacyCsproj/GreeterClient/packages.config @@ -1,7 +1,10 @@ - + - - - - + + + + + + + \ No newline at end of file diff --git a/examples/csharp/HelloworldLegacyCsproj/GreeterServer/GreeterServer.csproj b/examples/csharp/HelloworldLegacyCsproj/GreeterServer/GreeterServer.csproj index 27ca9630401..e4685a6fc07 100644 --- a/examples/csharp/HelloworldLegacyCsproj/GreeterServer/GreeterServer.csproj +++ b/examples/csharp/HelloworldLegacyCsproj/GreeterServer/GreeterServer.csproj @@ -1,4 +1,4 @@ - + Debug @@ -32,18 +32,26 @@ true - - ..\packages\Google.Protobuf.3.6.1\lib\net45\Google.Protobuf.dll + + ..\packages\Google.Protobuf.3.8.0\lib\net45\Google.Protobuf.dll - - ..\packages\Grpc.Core.1.17.0\lib\net45\Grpc.Core.dll + + ..\packages\Grpc.Core.2.23.0\lib\net45\Grpc.Core.dll + + + ..\packages\Grpc.Core.Api.2.23.0\lib\net45\Grpc.Core.Api.dll - - ..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll - True + + ..\packages\System.Buffers.4.4.0\lib\netstandard1.1\System.Buffers.dll + + ..\packages\System.Memory.4.5.3\lib\netstandard1.1\System.Memory.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll + @@ -59,11 +67,11 @@ - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/examples/csharp/HelloworldLegacyCsproj/GreeterServer/packages.config b/examples/csharp/HelloworldLegacyCsproj/GreeterServer/packages.config index 2fd8228689d..1f648dd06b8 100644 --- a/examples/csharp/HelloworldLegacyCsproj/GreeterServer/packages.config +++ b/examples/csharp/HelloworldLegacyCsproj/GreeterServer/packages.config @@ -1,7 +1,10 @@ - + - - - - + + + + + + + \ No newline at end of file From 12dc0da99db8da3d399d1acd77bb8f190b978c7d Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 5 Sep 2019 10:14:10 +0200 Subject: [PATCH 1462/1555] upgrade HelloworldXamarin example to 2.23.0 --- .../Droid/HelloworldXamarin.Droid.csproj | 38 ++++++++++++---- .../Droid/Properties/AndroidManifest.xml | 7 ++- .../HelloworldXamarin/Droid/packages.config | 8 +++- .../HelloworldXamarin/HelloworldXamarin.sln | 36 ++++++++++----- .../iOS/HelloworldXamarin.iOS.csproj | 45 ++++++++++++++----- .../HelloworldXamarin/iOS/packages.config | 8 +++- 6 files changed, 103 insertions(+), 39 deletions(-) diff --git a/examples/csharp/HelloworldXamarin/Droid/HelloworldXamarin.Droid.csproj b/examples/csharp/HelloworldXamarin/Droid/HelloworldXamarin.Droid.csproj index 991fa0c9bcc..a25dfdf92d0 100644 --- a/examples/csharp/HelloworldXamarin/Droid/HelloworldXamarin.Droid.csproj +++ b/examples/csharp/HelloworldXamarin/Droid/HelloworldXamarin.Droid.csproj @@ -1,4 +1,4 @@ - + Debug @@ -15,7 +15,8 @@ Properties\AndroidManifest.xml Resources Assets - true + + true @@ -38,7 +39,25 @@ false + + ..\packages\Google.Protobuf.3.8.0\lib\netstandard2.0\Google.Protobuf.dll + + + ..\packages\Grpc.Core.2.23.0\lib\netstandard2.0\Grpc.Core.dll + + + ..\packages\Grpc.Core.Api.2.23.0\lib\netstandard2.0\Grpc.Core.Api.dll + + + ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll + + + ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + @@ -50,12 +69,6 @@ ..\packages\System.Interactive.Async.3.1.1\lib\netstandard1.3\System.Interactive.Async.dll - - ..\packages\Google.Protobuf.3.6.0\lib\netstandard1.0\Google.Protobuf.dll - - - ..\packages\Grpc.Core.1.18.0\lib\netstandard1.5\Grpc.Core.dll - @@ -63,6 +76,7 @@ + @@ -79,5 +93,11 @@ - + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + \ No newline at end of file diff --git a/examples/csharp/HelloworldXamarin/Droid/Properties/AndroidManifest.xml b/examples/csharp/HelloworldXamarin/Droid/Properties/AndroidManifest.xml index 4f2167a1a03..9d767ff323d 100644 --- a/examples/csharp/HelloworldXamarin/Droid/Properties/AndroidManifest.xml +++ b/examples/csharp/HelloworldXamarin/Droid/Properties/AndroidManifest.xml @@ -1,6 +1,5 @@  - - - - + + + \ No newline at end of file diff --git a/examples/csharp/HelloworldXamarin/Droid/packages.config b/examples/csharp/HelloworldXamarin/Droid/packages.config index 29201117298..d56f8b7d22e 100644 --- a/examples/csharp/HelloworldXamarin/Droid/packages.config +++ b/examples/csharp/HelloworldXamarin/Droid/packages.config @@ -1,11 +1,13 @@  - - + + + + @@ -22,6 +24,7 @@ + @@ -31,6 +34,7 @@ + diff --git a/examples/csharp/HelloworldXamarin/HelloworldXamarin.sln b/examples/csharp/HelloworldXamarin/HelloworldXamarin.sln index e2a738f157e..ee3ea5c95d6 100644 --- a/examples/csharp/HelloworldXamarin/HelloworldXamarin.sln +++ b/examples/csharp/HelloworldXamarin/HelloworldXamarin.sln @@ -1,6 +1,7 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.329 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "HelloworldXamarin", "HelloworldXamarin\HelloworldXamarin.shproj", "{42FFF3D8-934F-4475-8E68-08DA340BF6E8}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloworldXamarin.Droid", "Droid\HelloworldXamarin.Droid.csproj", "{B9B0D41C-1C07-4590-A919-5865E741B2EA}" @@ -8,38 +9,49 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloworldXamarin.iOS", "iOS\HelloworldXamarin.iOS.csproj", "{62336DF0-60D8-478F-8140-B3CB089B417E}" EndProject Global + GlobalSection(SharedMSBuildProjectFiles) = preSolution + HelloworldXamarin\HelloworldXamarin.projitems*{42fff3d8-934f-4475-8e68-08da340bf6e8}*SharedItemsImports = 13 + HelloworldXamarin\HelloworldXamarin.projitems*{62336df0-60d8-478f-8140-b3cb089b417e}*SharedItemsImports = 4 + HelloworldXamarin\HelloworldXamarin.projitems*{b9b0d41c-1c07-4590-a919-5865e741b2ea}*SharedItemsImports = 4 + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU + Debug|iPhone = Debug|iPhone Debug|iPhoneSimulator = Debug|iPhoneSimulator + Release|Any CPU = Release|Any CPU Release|iPhone = Release|iPhone Release|iPhoneSimulator = Release|iPhoneSimulator - Debug|iPhone = Debug|iPhone EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Release|Any CPU.Build.0 = Release|Any CPU + {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Debug|iPhone.Build.0 = Debug|Any CPU {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Release|Any CPU.Build.0 = Release|Any CPU {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Release|iPhone.ActiveCfg = Release|Any CPU {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Release|iPhone.Build.0 = Release|Any CPU {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {B9B0D41C-1C07-4590-A919-5865E741B2EA}.Debug|iPhone.Build.0 = Debug|Any CPU {62336DF0-60D8-478F-8140-B3CB089B417E}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator {62336DF0-60D8-478F-8140-B3CB089B417E}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator - {62336DF0-60D8-478F-8140-B3CB089B417E}.Release|Any CPU.ActiveCfg = Release|iPhone - {62336DF0-60D8-478F-8140-B3CB089B417E}.Release|Any CPU.Build.0 = Release|iPhone + {62336DF0-60D8-478F-8140-B3CB089B417E}.Debug|iPhone.ActiveCfg = Debug|iPhone + {62336DF0-60D8-478F-8140-B3CB089B417E}.Debug|iPhone.Build.0 = Debug|iPhone {62336DF0-60D8-478F-8140-B3CB089B417E}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator {62336DF0-60D8-478F-8140-B3CB089B417E}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator + {62336DF0-60D8-478F-8140-B3CB089B417E}.Release|Any CPU.ActiveCfg = Release|iPhone + {62336DF0-60D8-478F-8140-B3CB089B417E}.Release|Any CPU.Build.0 = Release|iPhone {62336DF0-60D8-478F-8140-B3CB089B417E}.Release|iPhone.ActiveCfg = Release|iPhone {62336DF0-60D8-478F-8140-B3CB089B417E}.Release|iPhone.Build.0 = Release|iPhone {62336DF0-60D8-478F-8140-B3CB089B417E}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator {62336DF0-60D8-478F-8140-B3CB089B417E}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator - {62336DF0-60D8-478F-8140-B3CB089B417E}.Debug|iPhone.ActiveCfg = Debug|iPhone - {62336DF0-60D8-478F-8140-B3CB089B417E}.Debug|iPhone.Build.0 = Debug|iPhone + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {CDC6F6DC-E1C6-45A7-ACC2-A61CDCCA1436} EndGlobalSection EndGlobal diff --git a/examples/csharp/HelloworldXamarin/iOS/HelloworldXamarin.iOS.csproj b/examples/csharp/HelloworldXamarin/iOS/HelloworldXamarin.iOS.csproj index 9154bf33527..844e06c24c6 100644 --- a/examples/csharp/HelloworldXamarin/iOS/HelloworldXamarin.iOS.csproj +++ b/examples/csharp/HelloworldXamarin/iOS/HelloworldXamarin.iOS.csproj @@ -1,4 +1,4 @@ - + Debug @@ -9,6 +9,8 @@ HelloworldXamarin.iOS HelloworldXamarin.iOS Resources + + true @@ -77,7 +79,25 @@ x86 + + ..\packages\Google.Protobuf.3.8.0\lib\netstandard2.0\Google.Protobuf.dll + + + ..\packages\Grpc.Core.2.23.0\lib\netstandard2.0\Grpc.Core.dll + + + ..\packages\Grpc.Core.Api.2.23.0\lib\netstandard2.0\Grpc.Core.Api.dll + + + ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll + + + ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + @@ -89,16 +109,14 @@ ..\packages\System.Interactive.Async.3.1.1\lib\netstandard1.3\System.Interactive.Async.dll - - ..\packages\Google.Protobuf.3.6.0\lib\netstandard1.0\Google.Protobuf.dll - - - ..\packages\Grpc.Core.1.18.0\lib\netstandard1.5\Grpc.Core.dll - - - + + false + + + false + @@ -108,6 +126,7 @@ + @@ -122,5 +141,11 @@ - + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + \ No newline at end of file diff --git a/examples/csharp/HelloworldXamarin/iOS/packages.config b/examples/csharp/HelloworldXamarin/iOS/packages.config index 055222ba48f..80802a8d124 100644 --- a/examples/csharp/HelloworldXamarin/iOS/packages.config +++ b/examples/csharp/HelloworldXamarin/iOS/packages.config @@ -1,11 +1,13 @@  - - + + + + @@ -22,6 +24,7 @@ + @@ -31,6 +34,7 @@ + From b876b35457121878345de26a1542d24cbb2d56a4 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 5 Sep 2019 13:48:31 +0200 Subject: [PATCH 1463/1555] address review comments --- src/csharp/Grpc.Core.Api/SerializationContext.cs | 4 ++-- .../Internal/DefaultSerializationContextTest.cs | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/csharp/Grpc.Core.Api/SerializationContext.cs b/src/csharp/Grpc.Core.Api/SerializationContext.cs index 76f1951b68e..59e14c12e3b 100644 --- a/src/csharp/Grpc.Core.Api/SerializationContext.cs +++ b/src/csharp/Grpc.Core.Api/SerializationContext.cs @@ -28,7 +28,7 @@ namespace Grpc.Core { /// /// Use the byte array as serialized form of current message and mark serialization process as complete. - /// Complete() can only be called once. By calling this method the caller gives up the ownership of the + /// Complete(byte[]) can only be called once. By calling this method the caller gives up the ownership of the /// payload which must not be accessed afterwards. /// /// the serialized form of current message @@ -47,7 +47,7 @@ namespace Grpc.Core } /// - /// Complete the payload written to the buffer writer. Complete() can only be called once. + /// Complete the payload written to the buffer writer. Complete() can only be called once. /// public virtual void Complete() { diff --git a/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs b/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs index fcb12ae6656..061230d8ca4 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/DefaultSerializationContextTest.cs @@ -189,9 +189,6 @@ namespace Grpc.Core.Internal.Tests } } - // other ideas: - // AdjustTailSpace(0) if previous tail size is 0... (better for SliceBufferSafeHandle) - private DefaultSerializationContext.UsageScope NewDefaultSerializationContextScope() { return new DefaultSerializationContext.UsageScope(new DefaultSerializationContext()); From 91716467138c03fb97391c68cab3365ccf14a122 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 5 Sep 2019 08:05:36 -0400 Subject: [PATCH 1464/1555] fix dependencies for classic .csproj --- test/distrib/csharp/DistribTest/DistribTest.csproj | 10 ++++++++-- test/distrib/csharp/DistribTest/packages.config | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/test/distrib/csharp/DistribTest/DistribTest.csproj b/test/distrib/csharp/DistribTest/DistribTest.csproj index e3fc94b4f23..a7f48146a5d 100644 --- a/test/distrib/csharp/DistribTest/DistribTest.csproj +++ b/test/distrib/csharp/DistribTest/DistribTest.csproj @@ -68,8 +68,14 @@ - - ..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll + + ..\packages\System.Buffers.4.4.0\lib\netstandard1.1\System.Buffers.dll + + + ..\packages\System.Memory.4.5.3\lib\netstandard1.1\System.Memory.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll diff --git a/test/distrib/csharp/DistribTest/packages.config b/test/distrib/csharp/DistribTest/packages.config index 5e09d5dad01..b6c6730e34b 100644 --- a/test/distrib/csharp/DistribTest/packages.config +++ b/test/distrib/csharp/DistribTest/packages.config @@ -9,6 +9,8 @@ - + + + \ No newline at end of file From ece5fbdcb0aecc152da6cce81b33695c7adad453 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 5 Sep 2019 08:06:39 -0400 Subject: [PATCH 1465/1555] partially revert alpine distribtest attempts --- .../csharp/DistribTest/DistribTestDotNet.csproj | 12 +++++------- test/distrib/csharp/run_distrib_test_dotnetcli.sh | 11 +++-------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj b/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj index 8cdf926f07f..c855feb3fb3 100644 --- a/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj +++ b/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp2.1 + net45;netcoreapp2.1 false false false @@ -23,10 +23,8 @@ - - - /usr/lib/mono/4.5-api - /usr/local/lib/mono/4.5-api - /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5-api - + + + + \ No newline at end of file diff --git a/test/distrib/csharp/run_distrib_test_dotnetcli.sh b/test/distrib/csharp/run_distrib_test_dotnetcli.sh index 357ce136cb7..ca22bce9d85 100755 --- a/test/distrib/csharp/run_distrib_test_dotnetcli.sh +++ b/test/distrib/csharp/run_distrib_test_dotnetcli.sh @@ -29,20 +29,15 @@ dotnet restore DistribTestDotNet.csproj dotnet build DistribTestDotNet.csproj dotnet publish -f netcoreapp2.1 DistribTestDotNet.csproj -#dotnet publish -f net45 DistribTestDotNet.csproj +dotnet publish -f net45 DistribTestDotNet.csproj ls -R bin -#ldd /root/.nuget/packages/grpc.core/*/lib/netstandard1.5/../../runtimes/linux/native/libgrpc_csharp_ext.x64.so - -#ldd /root/.nuget/packages/grpc.tools/*/tools/linux_x64/grpc_csharp_plugin - -#exit 1 # .NET 4.5 target after dotnet build -#mono bin/Debug/net45/publish/DistribTestDotNet.exe +mono bin/Debug/net45/publish/DistribTestDotNet.exe # .NET 4.5 target after dotnet publish -#mono bin/Debug/net45/publish/DistribTestDotNet.exe +mono bin/Debug/net45/publish/DistribTestDotNet.exe # .NET Core target after dotnet build dotnet exec bin/Debug/netcoreapp2.1/DistribTestDotNet.dll From 54c02148664047d610cd60178a5dc2faaa654252 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 5 Sep 2019 08:08:46 -0400 Subject: [PATCH 1466/1555] protoc cannot be run on alpine linux --- .../distribtest/csharp_alpine_x64/Dockerfile | 24 ------------------- .../artifacts/distribtest_targets.py | 1 - 2 files changed, 25 deletions(-) delete mode 100644 tools/dockerfile/distribtest/csharp_alpine_x64/Dockerfile diff --git a/tools/dockerfile/distribtest/csharp_alpine_x64/Dockerfile b/tools/dockerfile/distribtest/csharp_alpine_x64/Dockerfile deleted file mode 100644 index aa5034872c3..00000000000 --- a/tools/dockerfile/distribtest/csharp_alpine_x64/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2015 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FROM microsoft/dotnet:2.1-sdk-alpine - -RUN apk update && apk add bash -RUN apk update && apk add unzip - -# needed to satisfy the "ld-linux-x86-64.so.2" dependency -RUN apk add libc6-compat - -#RUN apk add libnsl -#RUN cp /usr/lib/libnsl.so.2 /usr/lib/libnsl.so.1 diff --git a/tools/run_tests/artifacts/distribtest_targets.py b/tools/run_tests/artifacts/distribtest_targets.py index 5baf9d6c298..0674fc4c689 100644 --- a/tools/run_tests/artifacts/distribtest_targets.py +++ b/tools/run_tests/artifacts/distribtest_targets.py @@ -310,7 +310,6 @@ def targets(): CSharpDistribTest('linux', 'x64', 'centos7'), CSharpDistribTest('linux', 'x64', 'ubuntu1604'), CSharpDistribTest('linux', 'x64', 'ubuntu1604', use_dotnet_cli=True), - CSharpDistribTest('linux', 'x64', 'alpine', use_dotnet_cli=True), CSharpDistribTest('macos', 'x86'), CSharpDistribTest('windows', 'x86'), CSharpDistribTest('windows', 'x64'), From d3f50ace3953651c1f67a3c9da84821abae747fe Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 5 Sep 2019 08:13:59 -0700 Subject: [PATCH 1467/1555] Use mutex instead of combiner in client channel data plane. --- .../filters/client_channel/client_channel.cc | 450 +++++++++--------- src/core/lib/gprpp/ref_counted_ptr.h | 2 + test/core/gprpp/ref_counted_ptr_test.cc | 14 + 3 files changed, 229 insertions(+), 237 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 8a0fabfa6fd..40ac1f22059 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -130,7 +130,7 @@ class ChannelData { return disconnect_error_.Load(MemoryOrder::ACQUIRE); } - grpc_combiner* data_plane_combiner() const { return data_plane_combiner_; } + Mutex* data_plane_mu() const { return &data_plane_mu_; } LoadBalancingPolicy::SubchannelPicker* picker() const { return picker_.get(); @@ -166,8 +166,6 @@ class ChannelData { private: class SubchannelWrapper; - class ConnectivityStateAndPickerSetter; - class ServiceConfigSetter; class ClientChannelControlHelper; class ExternalConnectivityWatcher { @@ -214,6 +212,14 @@ class ChannelData { ChannelData(grpc_channel_element_args* args, grpc_error** error); ~ChannelData(); + void UpdateStateAndPickerLocked( + grpc_connectivity_state state, const char* reason, + UniquePtr picker); + + void UpdateServiceConfigLocked( + RefCountedPtr retry_throttle_data, + RefCountedPtr service_config); + void CreateResolvingLoadBalancingPolicyLocked(); void DestroyResolvingLoadBalancingPolicyLocked(); @@ -250,9 +256,9 @@ class ChannelData { channelz::ChannelNode* channelz_node_; // - // Fields used in the data plane. Guarded by data_plane_combiner. + // Fields used in the data plane. Guarded by data_plane_mu. // - grpc_combiner* data_plane_combiner_; + mutable Mutex data_plane_mu_; UniquePtr picker_; QueuedPick* queued_picks_ = nullptr; // Linked list of queued picks. // Data from service config. @@ -282,13 +288,13 @@ class ChannelData { Map subchannel_wrappers_; // Pending ConnectedSubchannel updates for each SubchannelWrapper. // Updates are queued here in the control plane combiner and then applied - // in the data plane combiner when the picker is updated. + // in the data plane mutex when the picker is updated. Map, RefCountedPtr, RefCountedPtrLess> pending_subchannel_updates_; // - // Fields accessed from both data plane and control plane combiners. + // Fields accessed from both data plane mutex and control plane combiner. // Atomic disconnect_error_; @@ -322,7 +328,16 @@ class CallData { void MaybeApplyServiceConfigToCallLocked(grpc_call_element* elem); // Invoked by channel for queued picks when the picker is updated. - static void StartPickLocked(void* arg, grpc_error* error); + static void PickSubchannel(void* arg, grpc_error* error); + + // Helper function for performing a pick while holding the data plane + // mutex. Returns true if the pick is complete, in which case the caller + // must invoke PickDone() or AsyncPickDone() with the returned error. + bool PickSubchannelLocked(grpc_call_element* elem, grpc_error** error); + + // Schedules a callback to process the completed pick. The callback + // will not run until after this method returns. + void AsyncPickDone(grpc_call_element* elem, grpc_error* error); private: class QueuedPickCanceller; @@ -931,7 +946,7 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { return connected_subchannel_.get(); } - // Caller must be holding the data-plane combiner. + // Caller must be holding the data-plane mutex. ConnectedSubchannel* connected_subchannel_in_data_plane() const { return connected_subchannel_in_data_plane_.get(); } @@ -1059,7 +1074,7 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { // Update the connected subchannel only if the channel is not shutting // down. This is because once the channel is shutting down, we // ignore picker updates from the LB policy, which means that - // ConnectivityStateAndPickerSetter will never process the entries + // UpdateStateAndPickerLocked() will never process the entries // in chand_->pending_subchannel_updates_. So we don't want to add // entries there that will never be processed, since that would // leave dangling refs to the channel and prevent its destruction. @@ -1069,7 +1084,7 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { if (connected_subchannel_ != connected_subchannel) { connected_subchannel_ = std::move(connected_subchannel); // Record the new connected subchannel so that it can be updated - // in the data plane combiner the next time the picker is updated. + // in the data plane mutex the next time the picker is updated. chand_->pending_subchannel_updates_[Ref( DEBUG_LOCATION, "ConnectedSubchannelUpdate")] = connected_subchannel_; } @@ -1086,159 +1101,10 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { Map watcher_map_; // To be accessed only in the control plane combiner. RefCountedPtr connected_subchannel_; - // To be accessed only in the data plane combiner. + // To be accessed only in the data plane mutex. RefCountedPtr connected_subchannel_in_data_plane_; }; -// -// ChannelData::ConnectivityStateAndPickerSetter -// - -// A fire-and-forget class that sets the channel's connectivity state -// and then hops into the data plane combiner to update the picker. -// Must be instantiated while holding the control plane combiner. -// Deletes itself when done. -class ChannelData::ConnectivityStateAndPickerSetter { - public: - ConnectivityStateAndPickerSetter( - ChannelData* chand, grpc_connectivity_state state, const char* reason, - UniquePtr picker) - : chand_(chand), picker_(std::move(picker)) { - // Clean the control plane when entering IDLE, while holding control plane - // combiner. - if (picker_ == nullptr) { - chand->health_check_service_name_.reset(); - chand->saved_service_config_.reset(); - chand->received_first_resolver_result_ = false; - } - // Update connectivity state here, while holding control plane combiner. - grpc_connectivity_state_set(&chand->state_tracker_, state, reason); - if (chand->channelz_node_ != nullptr) { - chand->channelz_node_->SetConnectivityState(state); - chand->channelz_node_->AddTraceEvent( - channelz::ChannelTrace::Severity::Info, - grpc_slice_from_static_string( - channelz::ChannelNode::GetChannelConnectivityStateChangeString( - state))); - } - // Grab any pending subchannel updates. - pending_subchannel_updates_ = - std::move(chand_->pending_subchannel_updates_); - // Bounce into the data plane combiner to reset the picker. - GRPC_CHANNEL_STACK_REF(chand->owning_stack_, - "ConnectivityStateAndPickerSetter"); - GRPC_CLOSURE_INIT(&closure_, SetPickerInDataPlane, this, - grpc_combiner_scheduler(chand->data_plane_combiner_)); - GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE); - } - - private: - static void SetPickerInDataPlane(void* arg, grpc_error* ignored) { - auto* self = static_cast(arg); - // Handle subchannel updates. - for (auto& p : self->pending_subchannel_updates_) { - if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { - gpr_log(GPR_INFO, - "chand=%p: updating subchannel wrapper %p data plane " - "connected_subchannel to %p", - self->chand_, p.first.get(), p.second.get()); - } - p.first->set_connected_subchannel_in_data_plane(std::move(p.second)); - } - // Swap out the picker. We hang on to the old picker so that it can - // be deleted in the control-plane combiner, since that's where we need - // to unref the subchannel wrappers that are reffed by the picker. - self->picker_.swap(self->chand_->picker_); - // Clean the data plane if the updated picker is nullptr. - if (self->chand_->picker_ == nullptr) { - self->chand_->received_service_config_data_ = false; - self->chand_->retry_throttle_data_.reset(); - self->chand_->service_config_.reset(); - } - // Re-process queued picks. - for (QueuedPick* pick = self->chand_->queued_picks_; pick != nullptr; - pick = pick->next) { - CallData::StartPickLocked(pick->elem, GRPC_ERROR_NONE); - } - // Pop back into the control plane combiner to delete ourself, so - // that we make sure to unref subchannel wrappers there. This - // includes both the ones reffed by the old picker (now stored in - // self->picker_) and the ones in self->pending_subchannel_updates_. - GRPC_CLOSURE_INIT(&self->closure_, CleanUpInControlPlane, self, - grpc_combiner_scheduler(self->chand_->combiner_)); - GRPC_CLOSURE_SCHED(&self->closure_, GRPC_ERROR_NONE); - } - - static void CleanUpInControlPlane(void* arg, grpc_error* ignored) { - auto* self = static_cast(arg); - GRPC_CHANNEL_STACK_UNREF(self->chand_->owning_stack_, - "ConnectivityStateAndPickerSetter"); - Delete(self); - } - - ChannelData* chand_; - UniquePtr picker_; - Map, RefCountedPtr, - RefCountedPtrLess> - pending_subchannel_updates_; - grpc_closure closure_; -}; - -// -// ChannelData::ServiceConfigSetter -// - -// A fire-and-forget class that sets the channel's service config data -// in the data plane combiner. Deletes itself when done. -class ChannelData::ServiceConfigSetter { - public: - ServiceConfigSetter( - ChannelData* chand, - Optional - retry_throttle_data, - RefCountedPtr service_config) - : chand_(chand), - retry_throttle_data_(retry_throttle_data), - service_config_(std::move(service_config)) { - GRPC_CHANNEL_STACK_REF(chand->owning_stack_, "ServiceConfigSetter"); - GRPC_CLOSURE_INIT(&closure_, SetServiceConfigData, this, - grpc_combiner_scheduler(chand->data_plane_combiner_)); - GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE); - } - - private: - static void SetServiceConfigData(void* arg, grpc_error* ignored) { - ServiceConfigSetter* self = static_cast(arg); - ChannelData* chand = self->chand_; - // Update channel state. - chand->received_service_config_data_ = true; - if (self->retry_throttle_data_.has_value()) { - chand->retry_throttle_data_ = - internal::ServerRetryThrottleMap::GetDataForServer( - chand->server_name_.get(), - self->retry_throttle_data_.value().max_milli_tokens, - self->retry_throttle_data_.value().milli_token_ratio); - } - chand->service_config_ = std::move(self->service_config_); - // Apply service config to queued picks. - for (QueuedPick* pick = chand->queued_picks_; pick != nullptr; - pick = pick->next) { - CallData* calld = static_cast(pick->elem->call_data); - calld->MaybeApplyServiceConfigToCallLocked(pick->elem); - } - // Clean up. - GRPC_CHANNEL_STACK_UNREF(self->chand_->owning_stack_, - "ServiceConfigSetter"); - Delete(self); - } - - ChannelData* chand_; - Optional - retry_throttle_data_; - RefCountedPtr service_config_; - grpc_closure closure_; -}; - // // ChannelData::ExternalConnectivityWatcher::WatcherList // @@ -1409,9 +1275,7 @@ class ChannelData::ClientChannelControlHelper } // Do update only if not shutting down. if (disconnect_error == GRPC_ERROR_NONE) { - // Will delete itself. - New(chand_, state, "helper", - std::move(picker)); + chand_->UpdateStateAndPickerLocked(state, "helper", std::move(picker)); } } @@ -1495,7 +1359,6 @@ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error) client_channel_factory_( ClientChannelFactory::GetFromChannelArgs(args->channel_args)), channelz_node_(GetChannelzNode(args->channel_args)), - data_plane_combiner_(grpc_combiner_create()), combiner_(grpc_combiner_create()), interested_parties_(grpc_pollset_set_create()), subchannel_pool_(GetSubchannelPool(args->channel_args)), @@ -1568,13 +1431,108 @@ ChannelData::~ChannelData() { // Stop backup polling. grpc_client_channel_stop_backup_polling(interested_parties_); grpc_pollset_set_destroy(interested_parties_); - GRPC_COMBINER_UNREF(data_plane_combiner_, "client_channel"); GRPC_COMBINER_UNREF(combiner_, "client_channel"); GRPC_ERROR_UNREF(disconnect_error_.Load(MemoryOrder::RELAXED)); grpc_connectivity_state_destroy(&state_tracker_); gpr_mu_destroy(&info_mu_); } +void ChannelData::UpdateStateAndPickerLocked( + grpc_connectivity_state state, const char* reason, + UniquePtr picker) { + // Clean the control plane when entering IDLE. + if (picker_ == nullptr) { + health_check_service_name_.reset(); + saved_service_config_.reset(); + received_first_resolver_result_ = false; + } + // Update connectivity state. + grpc_connectivity_state_set(&state_tracker_, state, reason); + if (channelz_node_ != nullptr) { + channelz_node_->SetConnectivityState(state); + channelz_node_->AddTraceEvent( + channelz::ChannelTrace::Severity::Info, + grpc_slice_from_static_string( + channelz::ChannelNode::GetChannelConnectivityStateChangeString( + state))); + } + // Grab data plane lock to do subchannel updates and update the picker. + // + // Note that we want to minimize the work done while holding the data + // plane lock, to keep the critical section small. So, for all of the + // objects that we might wind up unreffing here, we actually hold onto + // the refs until after we release the lock, and then unref them at + // that point. This includes the following: + // - refs to subchannel wrappers in the keys of pending_subchannel_updates_ + // - ref stored in retry_throttle_data_ + // - ref stored in service_config_ + // - ownership of the existing picker in picker_ + RefCountedPtr retry_throttle_data_to_unref; + RefCountedPtr service_config_to_unref; + { + MutexLock lock(&data_plane_mu_); + // Handle subchannel updates. + for (auto& p : pending_subchannel_updates_) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { + gpr_log(GPR_INFO, + "chand=%p: updating subchannel wrapper %p data plane " + "connected_subchannel to %p", + this, p.first.get(), p.second.get()); + } + // Note: We do not remove the entry from pending_subchannel_updates_ + // here, since this would unref the subchannel wrapper; instead, + // we wait until we've released the lock to clear the map. + p.first->set_connected_subchannel_in_data_plane(std::move(p.second)); + } + // Swap out the picker. + // Note: Original value will be destroyed after the lock is released. + picker_.swap(picker); + // Clean the data plane if the updated picker is nullptr. + if (picker_ == nullptr) { + received_service_config_data_ = false; + // Note: We save the objects to unref until after the lock is released. + retry_throttle_data_to_unref = std::move(retry_throttle_data_); + service_config_to_unref = std::move(service_config_); + } + // Re-process queued picks. + for (QueuedPick* pick = queued_picks_; pick != nullptr; pick = pick->next) { + grpc_call_element* elem = pick->elem; + CallData* calld = static_cast(elem->call_data); + grpc_error* error = GRPC_ERROR_NONE; + if (calld->PickSubchannelLocked(elem, &error)) { + calld->AsyncPickDone(elem, error); + } + } + } + // Clear the pending update map after releasing the lock, to keep the + // critical section small. + pending_subchannel_updates_.clear(); +} + +void ChannelData::UpdateServiceConfigLocked( + RefCountedPtr retry_throttle_data, + RefCountedPtr service_config) { + // Grab data plane lock to update service config. + // + // We defer unreffing the old values (and deallocating memory) until + // after releasing the lock to keep the critical section small. + { + MutexLock lock(&data_plane_mu_); + // Update service config. + received_service_config_data_ = true; + // Old values will be unreffed after lock is released. + retry_throttle_data_.swap(retry_throttle_data); + service_config_.swap(service_config); + // Apply service config to queued picks. + for (QueuedPick* pick = queued_picks_; pick != nullptr; pick = pick->next) { + CallData* calld = static_cast(pick->elem->call_data); + calld->MaybeApplyServiceConfigToCallLocked(pick->elem); + } + } + // Old values will be unreffed after lock is released when they go out + // of scope. +} + void ChannelData::CreateResolvingLoadBalancingPolicyLocked() { // Instantiate resolving LB policy. LoadBalancingPolicy::Args lb_args; @@ -1746,15 +1704,20 @@ bool ChannelData::ProcessResolverResultLocked( // if we feel it is unnecessary. if (service_config_changed || !chand->received_first_resolver_result_) { chand->received_first_resolver_result_ = true; - Optional - retry_throttle_data; + RefCountedPtr retry_throttle_data; if (parsed_service_config != nullptr) { - retry_throttle_data = parsed_service_config->retry_throttling(); + Optional + retry_throttle_config = parsed_service_config->retry_throttling(); + if (retry_throttle_config.has_value()) { + retry_throttle_data = + internal::ServerRetryThrottleMap::GetDataForServer( + chand->server_name_.get(), + retry_throttle_config.value().max_milli_tokens, + retry_throttle_config.value().milli_token_ratio); + } } - // Create service config setter to update channel state in the data - // plane combiner. Destroys itself when done. - New(chand, retry_throttle_data, - chand->saved_service_config_); + chand->UpdateServiceConfigLocked(std::move(retry_throttle_data), + chand->saved_service_config_); } UniquePtr processed_lb_policy_name; chand->ProcessLbPolicy(result, parsed_service_config, @@ -1838,8 +1801,8 @@ void ChannelData::StartTransportOpLocked(void* arg, grpc_error* ignored) { static_cast(value) == GRPC_CHANNEL_IDLE) { if (chand->disconnect_error() == GRPC_ERROR_NONE) { // Enter IDLE state. - New(chand, GRPC_CHANNEL_IDLE, - "channel entering IDLE", nullptr); + chand->UpdateStateAndPickerLocked(GRPC_CHANNEL_IDLE, + "channel entering IDLE", nullptr); } GRPC_ERROR_UNREF(op->disconnect_with_error); } else { @@ -1848,8 +1811,8 @@ void ChannelData::StartTransportOpLocked(void* arg, grpc_error* ignored) { GRPC_ERROR_NONE); chand->disconnect_error_.Store(op->disconnect_with_error, MemoryOrder::RELEASE); - New( - chand, GRPC_CHANNEL_SHUTDOWN, "shutdown from API", + chand->UpdateStateAndPickerLocked( + GRPC_CHANNEL_SHUTDOWN, "shutdown from API", UniquePtr( New( GRPC_ERROR_REF(op->disconnect_with_error)))); @@ -2092,8 +2055,8 @@ void CallData::StartTransportStreamOpBatch( // Add the batch to the pending list. calld->PendingBatchesAdd(elem, batch); // Check if we've already gotten a subchannel call. - // Note that once we have completed the pick, we do not need to enter - // the channel combiner, which is more efficient (especially for + // Note that once we have picked a subchannel, we do not need to acquire + // the channel's data plane mutex, which is more efficient (especially for // streaming calls). if (calld->subchannel_call_ != nullptr) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) { @@ -2105,18 +2068,15 @@ void CallData::StartTransportStreamOpBatch( return; } // We do not yet have a subchannel call. - // For batches containing a send_initial_metadata op, enter the channel - // combiner to start a pick. + // For batches containing a send_initial_metadata op, acquire the + // channel's data plane mutex to pick a subchannel. if (GPR_LIKELY(batch->send_initial_metadata)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) { - gpr_log(GPR_INFO, "chand=%p calld=%p: entering client_channel combiner", + gpr_log(GPR_INFO, + "chand=%p calld=%p: grabbing data plane mutex to perform pick", chand, calld); } - GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_INIT( - &batch->handler_private.closure, StartPickLocked, elem, - grpc_combiner_scheduler(chand->data_plane_combiner())), - GRPC_ERROR_NONE); + PickSubchannel(elem, GRPC_ERROR_NONE); } else { // For all other batches, release the call combiner. if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) { @@ -2544,8 +2504,8 @@ void CallData::DoRetry(grpc_call_element* elem, this, next_attempt_time - ExecCtx::Get()->Now()); } // Schedule retry after computed delay. - GRPC_CLOSURE_INIT(&pick_closure_, StartPickLocked, elem, - grpc_combiner_scheduler(chand->data_plane_combiner())); + GRPC_CLOSURE_INIT(&pick_closure_, PickSubchannel, elem, + grpc_schedule_on_exec_ctx); grpc_timer_init(&retry_timer_, next_attempt_time, &pick_closure_); // Update bookkeeping. if (retry_state != nullptr) retry_state->retry_dispatched = true; @@ -3660,6 +3620,11 @@ void CallData::CreateSubchannelCall(grpc_call_element* elem) { } } +void CallData::AsyncPickDone(grpc_call_element* elem, grpc_error* error) { + GRPC_CLOSURE_INIT(&pick_closure_, PickDone, elem, grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_SCHED(&pick_closure_, error); +} + void CallData::PickDone(void* arg, grpc_error* error) { grpc_call_element* elem = static_cast(arg); ChannelData* chand = static_cast(elem->channel_data); @@ -3682,10 +3647,9 @@ class CallData::QueuedPickCanceller { public: explicit QueuedPickCanceller(grpc_call_element* elem) : elem_(elem) { auto* calld = static_cast(elem->call_data); - auto* chand = static_cast(elem->channel_data); GRPC_CALL_STACK_REF(calld->owning_call_, "QueuedPickCanceller"); GRPC_CLOSURE_INIT(&closure_, &CancelLocked, this, - grpc_combiner_scheduler(chand->data_plane_combiner())); + grpc_schedule_on_exec_ctx); calld->call_combiner_->SetNotifyOnCancel(&closure_); } @@ -3694,6 +3658,7 @@ class CallData::QueuedPickCanceller { auto* self = static_cast(arg); auto* chand = static_cast(self->elem_->channel_data); auto* calld = static_cast(self->elem_->call_data); + MutexLock lock(chand->data_plane_mu()); if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { gpr_log(GPR_INFO, "chand=%p calld=%p: cancelling queued pick: " @@ -3818,23 +3783,38 @@ const char* PickResultTypeName( GPR_UNREACHABLE_CODE(return "UNKNOWN"); } -void CallData::StartPickLocked(void* arg, grpc_error* error) { +void CallData::PickSubchannel(void* arg, grpc_error* error) { grpc_call_element* elem = static_cast(arg); CallData* calld = static_cast(elem->call_data); ChannelData* chand = static_cast(elem->channel_data); - GPR_ASSERT(calld->connected_subchannel_ == nullptr); - GPR_ASSERT(calld->subchannel_call_ == nullptr); - // picker's being null means the channel is currently in IDLE state. The - // incoming call will make the channel exit IDLE and queue itself. + bool pick_complete; + { + MutexLock lock(chand->data_plane_mu()); + pick_complete = calld->PickSubchannelLocked(elem, &error); + } + if (pick_complete) { + PickDone(elem, error); + GRPC_ERROR_UNREF(error); + } +} + +bool CallData::PickSubchannelLocked(grpc_call_element* elem, + grpc_error** error) { + ChannelData* chand = static_cast(elem->channel_data); + GPR_ASSERT(connected_subchannel_ == nullptr); + GPR_ASSERT(subchannel_call_ == nullptr); + // The picker being null means that the channel is currently in IDLE state. + // The incoming call will make the channel exit IDLE. if (chand->picker() == nullptr) { - // We are currently in the data plane. - // Bounce into the control plane to exit IDLE. - chand->CheckConnectivityState(true); - calld->AddCallToQueuedPicksLocked(elem); - return; + // Bounce into the control plane combiner to exit IDLE. + chand->CheckConnectivityState(/*try_to_connect=*/true); + // Queue the pick, so that it will be attempted once the channel + // becomes connected. + AddCallToQueuedPicksLocked(elem); + return false; } // Apply service config to call if needed. - calld->MaybeApplyServiceConfigToCallLocked(elem); + MaybeApplyServiceConfigToCallLocked(elem); // If this is a retry, use the send_initial_metadata payload that // we've cached; otherwise, use the pending batch. The // send_initial_metadata batch will be the first pending batch in the @@ -3846,31 +3826,27 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { // subchannel's copy of the metadata batch (which is copied for each // attempt) to the LB policy instead the one from the parent channel. LoadBalancingPolicy::PickArgs pick_args; - pick_args.call_state = &calld->lb_call_state_; + pick_args.call_state = &lb_call_state_; Metadata initial_metadata( - calld, - calld->seen_send_initial_metadata_ - ? &calld->send_initial_metadata_ - : calld->pending_batches_[0] + this, + seen_send_initial_metadata_ + ? &send_initial_metadata_ + : pending_batches_[0] .batch->payload->send_initial_metadata.send_initial_metadata); pick_args.initial_metadata = &initial_metadata; // Grab initial metadata flags so that we can check later if the call has // wait_for_ready enabled. const uint32_t send_initial_metadata_flags = - calld->seen_send_initial_metadata_ - ? calld->send_initial_metadata_flags_ - : calld->pending_batches_[0] - .batch->payload->send_initial_metadata - .send_initial_metadata_flags; - // When done, we schedule this closure to leave the data plane combiner. - GRPC_CLOSURE_INIT(&calld->pick_closure_, PickDone, elem, - grpc_schedule_on_exec_ctx); + seen_send_initial_metadata_ ? send_initial_metadata_flags_ + : pending_batches_[0] + .batch->payload->send_initial_metadata + .send_initial_metadata_flags; // Attempt pick. auto result = chand->picker()->Pick(pick_args); if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { gpr_log(GPR_INFO, "chand=%p calld=%p: LB pick returned %s (subchannel=%p, error=%s)", - chand, calld, PickResultTypeName(result.type), + chand, this, PickResultTypeName(result.type), result.subchannel.get(), grpc_error_string(result.error)); } switch (result.type) { @@ -3879,10 +3855,9 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { grpc_error* disconnect_error = chand->disconnect_error(); if (disconnect_error != GRPC_ERROR_NONE) { GRPC_ERROR_UNREF(result.error); - GRPC_CLOSURE_SCHED(&calld->pick_closure_, - GRPC_ERROR_REF(disconnect_error)); - if (calld->pick_queued_) calld->RemoveCallFromQueuedPicksLocked(elem); - break; + if (pick_queued_) RemoveCallFromQueuedPicksLocked(elem); + *error = GRPC_ERROR_REF(disconnect_error); + return true; } // If wait_for_ready is false, then the error indicates the RPC // attempt's final status. @@ -3890,19 +3865,20 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { GRPC_INITIAL_METADATA_WAIT_FOR_READY) == 0) { // Retry if appropriate; otherwise, fail. grpc_status_code status = GRPC_STATUS_OK; - grpc_error_get_status(result.error, calld->deadline_, &status, nullptr, + grpc_error_get_status(result.error, deadline_, &status, nullptr, nullptr, nullptr); - if (!calld->enable_retries_ || - !calld->MaybeRetry(elem, nullptr /* batch_data */, status, - nullptr /* server_pushback_md */)) { + const bool retried = enable_retries_ && + MaybeRetry(elem, nullptr /* batch_data */, status, + nullptr /* server_pushback_md */); + if (!retried) { grpc_error* new_error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( "Failed to pick subchannel", &result.error, 1); GRPC_ERROR_UNREF(result.error); - GRPC_CLOSURE_SCHED(&calld->pick_closure_, new_error); + *error = new_error; } - if (calld->pick_queued_) calld->RemoveCallFromQueuedPicksLocked(elem); - break; + if (pick_queued_) RemoveCallFromQueuedPicksLocked(elem); + return !retried; } // If wait_for_ready is true, then queue to retry when we get a new // picker. @@ -3910,26 +3886,26 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) { } // Fallthrough case LoadBalancingPolicy::PickResult::PICK_QUEUE: - if (!calld->pick_queued_) calld->AddCallToQueuedPicksLocked(elem); - break; + if (!pick_queued_) AddCallToQueuedPicksLocked(elem); + return false; default: // PICK_COMPLETE + if (pick_queued_) RemoveCallFromQueuedPicksLocked(elem); // Handle drops. if (GPR_UNLIKELY(result.subchannel == nullptr)) { result.error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Call dropped by load balancing policy"); } else { // Grab a ref to the connected subchannel while we're still - // holding the data plane combiner. - calld->connected_subchannel_ = + // holding the data plane mutex. + connected_subchannel_ = chand->GetConnectedSubchannelInDataPlane(result.subchannel.get()); - GPR_ASSERT(calld->connected_subchannel_ != nullptr); + GPR_ASSERT(connected_subchannel_ != nullptr); } - calld->lb_recv_trailing_metadata_ready_ = - result.recv_trailing_metadata_ready; - calld->lb_recv_trailing_metadata_ready_user_data_ = + lb_recv_trailing_metadata_ready_ = result.recv_trailing_metadata_ready; + lb_recv_trailing_metadata_ready_user_data_ = result.recv_trailing_metadata_ready_user_data; - GRPC_CLOSURE_SCHED(&calld->pick_closure_, result.error); - if (calld->pick_queued_) calld->RemoveCallFromQueuedPicksLocked(elem); + *error = result.error; + return true; } } diff --git a/src/core/lib/gprpp/ref_counted_ptr.h b/src/core/lib/gprpp/ref_counted_ptr.h index 19f38d7f013..2e3f4671581 100644 --- a/src/core/lib/gprpp/ref_counted_ptr.h +++ b/src/core/lib/gprpp/ref_counted_ptr.h @@ -103,6 +103,8 @@ class RefCountedPtr { if (value_ != nullptr) value_->Unref(); } + void swap(RefCountedPtr& other) { std::swap(value_, other.value_); } + // If value is non-null, we take ownership of a ref to it. void reset(T* value = nullptr) { if (value_ != nullptr) value_->Unref(); diff --git a/test/core/gprpp/ref_counted_ptr_test.cc b/test/core/gprpp/ref_counted_ptr_test.cc index 96dbdf884b0..38bd4b61364 100644 --- a/test/core/gprpp/ref_counted_ptr_test.cc +++ b/test/core/gprpp/ref_counted_ptr_test.cc @@ -151,6 +151,20 @@ TEST(RefCountedPtr, EqualityOperators) { EXPECT_NE(foo, nullptr); } +TEST(RefCountedPtr, Swap) { + Foo* foo = New(); + Foo* bar = New(); + RefCountedPtr ptr1(foo); + RefCountedPtr ptr2(bar); + ptr1.swap(ptr2); + EXPECT_EQ(foo, ptr2.get()); + EXPECT_EQ(bar, ptr1.get()); + RefCountedPtr ptr3; + ptr3.swap(ptr2); + EXPECT_EQ(nullptr, ptr2.get()); + EXPECT_EQ(foo, ptr3.get()); +} + TEST(MakeRefCounted, NoArgs) { RefCountedPtr foo = MakeRefCounted(); EXPECT_EQ(0, foo->value()); From fd9bdd9922fffe88ae9f2752f790922d0ed8f369 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 5 Sep 2019 08:17:16 -0700 Subject: [PATCH 1468/1555] Avoid duplicate initialization of SSL (from within grpc and from test) --- test/core/handshake/server_ssl_common.cc | 58 +++++++++++++++++++----- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/test/core/handshake/server_ssl_common.cc b/test/core/handshake/server_ssl_common.cc index 41b2829d8b7..1493094e3c3 100644 --- a/test/core/handshake/server_ssl_common.cc +++ b/test/core/handshake/server_ssl_common.cc @@ -32,6 +32,7 @@ #include #include +#include "src/core/lib/gprpp/sync.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/load_file.h" #include "test/core/util/port.h" @@ -41,10 +42,12 @@ #define SSL_KEY_PATH "src/core/tsi/test_creds/server1.key" #define SSL_CA_PATH "src/core/tsi/test_creds/ca.pem" -// Handshake completed signal to server thread. -static gpr_event client_handshake_complete; +namespace { -static int create_socket(int port) { +// Handshake completed signal to server thread. +gpr_event client_handshake_complete; + +int create_socket(int port) { int s; struct sockaddr_in addr; @@ -66,9 +69,34 @@ static int create_socket(int port) { return s; } +class ServerInfo { + public: + explicit ServerInfo(int p) : port_(p) {} + + int port() const { return port_; } + + void Activate() { + grpc_core::MutexLock lock(&mu_); + ready_ = true; + cv_.Signal(); + } + + void Await() { + grpc_core::MutexLock lock(&mu_); + cv_.WaitUntil(&mu_, [this] { return ready_; }); + } + + private: + const int port_; + grpc_core::Mutex mu_; + grpc_core::CondVar cv_; + bool ready_ = false; +}; + // Simple gRPC server. This listens until client_handshake_complete occurs. -static void server_thread(void* arg) { - const int port = *static_cast(arg); +void server_thread(void* arg) { + ServerInfo* s = static_cast(arg); + const int port = s->port(); // Load key pair and establish server SSL credentials. grpc_ssl_pem_key_cert_pair pem_key_cert_pair; @@ -100,6 +128,10 @@ static void server_thread(void* arg) { grpc_server_register_completion_queue(server, cq, nullptr); grpc_server_start(server); + // Notify the other side that it is now ok to start working since SSL is + // definitely already started. + s->Activate(); + // Wait a bounded number of time until client_handshake_complete is set, // sleeping between polls. int retries = 10; @@ -125,6 +157,8 @@ static void server_thread(void* arg) { grpc_slice_unref(ca_slice); } +} // namespace + // This test launches a gRPC server on a separate thread and then establishes a // TLS handshake via a minimal TLS client. The TLS client has configurable (via // alpn_list) ALPN settings and can probe at the supported ALPN preferences @@ -134,17 +168,19 @@ bool server_ssl_test(const char* alpn_list[], unsigned int alpn_list_len, bool success = true; grpc_init(); - int port = grpc_pick_unused_port_or_die(); + ServerInfo s(grpc_pick_unused_port_or_die()); gpr_event_init(&client_handshake_complete); // Launch the gRPC server thread. bool ok; - grpc_core::Thread thd("grpc_ssl_test", server_thread, &port, &ok); + grpc_core::Thread thd("grpc_ssl_test", server_thread, &s, &ok); GPR_ASSERT(ok); thd.Start(); - SSL_load_error_strings(); - OpenSSL_add_ssl_algorithms(); + // The work in server_thread will cause the SSL initialization to take place + // so long as we wait for it to reach beyond the point of adding a secure + // server port. + s.Await(); const SSL_METHOD* method = TLSv1_2_client_method(); SSL_CTX* ctx = SSL_CTX_new(method); @@ -197,13 +233,13 @@ bool server_ssl_test(const char* alpn_list[], unsigned int alpn_list_len, int retries = 10; int sock = -1; while (sock == -1 && retries-- > 0) { - sock = create_socket(port); + sock = create_socket(s.port()); if (sock < 0) { sleep(1); } } GPR_ASSERT(sock > 0); - gpr_log(GPR_INFO, "Connected to server on port %d", port); + gpr_log(GPR_INFO, "Connected to server on port %d", s.port()); // Establish a SSL* and connect at SSL layer. SSL* ssl = SSL_new(ctx); From ee603bf172d9905d172883106b8c64bf15beba34 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Wed, 4 Sep 2019 20:05:38 -0700 Subject: [PATCH 1469/1555] Better codegenfor validate_filtered_metadata. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit validate_filtered_metadata() performs several checks to see if a call must be failed. Failure is the unlikely case; to that end, failing branches are marked unlikely, and the specific code handling failure cases is refactored into explicitly un-inlined helper methods. This will prevent us from unnecessarily clobbering registers and give us a straight-line codepath for the success case. Results: BM_UnaryPingPong/8/0 [polls/iter:3.00008 ] 22.5µs ± 0% 21.6µs ± 0% -4.02% (p=0.036 n=5+3) BM_UnaryPingPong/64/64 [polls/iter:3.00008 ] 23.4µs ± 1% 23.0µs ± 1% -1.63% (p=0.010 n=6+4) BM_UnaryPingPong/32768/0 [polls/iter:3.00007 ] 34.4µs ± 1% 34.1µs ± 0% -0.99% (p=0.024 n=6+3) BM_UnaryPingPong/0/0 [polls/iter:0 ] 6.36µs ± 5% 6.16µs ± 2% -3.26% (p=0.013 n=20+19) BM_UnaryPingPong/1/1 [polls/iter:0 ] 6.62µs ± 6% 6.50µs ± 4% -1.72% (p=0.049 n=20+20) BM_UnaryPingPong/512/0 [polls/iter:0 ] 6.67µs ± 6% 6.59µs ± 2% -1.29% (p=0.047 n=20+19) BM_UnaryPingPong/4096/0 [polls/iter:0 ] 7.68µs ± 1% 7.65µs ± 2% -0.46% (p=0.031 n=18+18) BM_UnaryPingPong/0/262144 [polls/iter:0 ] 86.0µs ± 2% 85.3µs ± 2% -0.77% (p=0.046 n=19+19) BM_UnaryPingPong/0/0 [polls/iter:0 ] 6.28µs ± 5% 6.00µs ± 2% -4.37% (p=0.000 n=20+20) BM_UnaryPingPong/1/0 [polls/iter:0 ] 6.39µs ± 6% 6.20µs ± 2% -3.03% (p=0.001 n=20+19) BM_UnaryPingPong/0/1 [polls/iter:0 ] 6.36µs ± 6% 6.17µs ± 1% -3.00% (p=0.006 n=20+17) BM_UnaryPingPong/1/1 [polls/iter:0 ] 6.59µs ± 5% 6.30µs ± 2% -4.37% (p=0.000 n=20+19) BM_UnaryPingPong/8/0 [polls/iter:0 ] 6.37µs ± 5% 6.20µs ± 2% -2.76% (p=0.001 n=20+20) BM_UnaryPingPong/0/8 [polls/iter:0 ] 6.36µs ± 5% 6.17µs ± 2% -2.95% (p=0.001 n=20+19) BM_UnaryPingPong/8/8 [polls/iter:0 ] 6.45µs ± 7% 6.27µs ± 1% -2.72% (p=0.002 n=20+18) BM_UnaryPingPong/64/0 [polls/iter:0 ] 6.46µs ± 6% 6.31µs ± 1% -2.39% (p=0.001 n=20+20) BM_UnaryPingPong/512/0 [polls/iter:0 ] 6.62µs ± 6% 6.43µs ± 2% -2.92% (p=0.000 n=20+18) BM_UnaryPingPong/0/512 [polls/iter:0 ] 6.58µs ± 7% 6.41µs ± 1% -2.57% (p=0.002 n=20+17) BM_UnaryPingPong/512/512 [polls/iter:0 ] 6.88µs ± 7% 6.76µs ± 2% -1.81% (p=0.047 n=20+19) BM_UnaryPingPong/4096/0 [polls/iter:0 ] 7.57µs ± 3% 7.49µs ± 2% -0.99% (p=0.007 n=20+20) BM_UnaryPingPong/0/4096 [polls/iter:0 ] 7.66µs ± 5% 7.50µs ± 2% -2.15% (p=0.003 n=20+20) BM_UnaryPingPong/32768/0 [polls/iter:0 ] 15.8µs ± 2% 15.7µs ± 1% -0.75% (p=0.001 n=20+19) BM_UnaryPingPong/0/32768 [polls/iter:0 ] 16.1µs ± 2% 16.0µs ± 2% -0.84% (p=0.002 n=20+20) BM_UnaryPingPong/32768/32768 [polls/iter:0 ] 25.5µs ± 1% 25.4µs ± 1% -0.42% (p=0.011 n=20+19) BM_UnaryPingPong, 2>, NoOpMutator>/0/0 [polls/iter:0 ] 7.99µs ± 5% 7.85µs ± 2% -1.81% (p=0.028 n=20+20) BM_UnaryPingPong, 1>>/0/0 [polls/iter:0 ] 7.07µs ± 6% 7.14µs ± 5% +0.95% (p=0.007 n=19+18) BM_UnaryPingPong, 1>, NoOpMutator>/0/0 [polls/iter:0 ] 6.95µs ± 5% 7.02µs ± 3% +0.94% (p=0.017 n=18+19) BM_UnaryPingPong, 1>, NoOpMutator>/0/0 [polls/iter:0 ] 7.10µs ± 2% 7.19µs ± 2% +1.31% (p=0.000 n=16+20) BM_UnaryPingPong, 1>>/0/0 [polls/iter:0 ] 6.89µs ± 2% 7.00µs ± 3% +1.61% (p=0.000 n=17+19) BM_UnaryPingPong/512/512 [polls/iter:3.00007 ] 24.1µs ± 1% 23.7µs ± 1% -1.77% (p=0.024 n=6+3) BM_UnaryPingPong/1/0 [polls/iter:3.00009 ] 21.5µs ± 1% 20.9µs ± 0% -2.78% (p=0.024 n=6+3) BM_UnaryPingPong/4096/0 [polls/iter:3.00005 ] 24.4µs ± 2% 23.9µs ± 2% -2.16% (p=0.020 n=9+4) BM_UnaryPingPong/32768/0 [polls/iter:3.0001 ] 35.3µs ± 1% 34.8µs ± 1% -1.45% (p=0.008 n=5+5) BM_UnaryPingPong/0/0 [polls/iter:3.00008 ] 19.5µs ± 1% 19.1µs ± 1% -2.30% (p=0.016 n=4+5) BM_UnaryPingPong/0/32768 [polls/iter:3.0001 ] 35.4µs ± 1% 34.7µs ± 1% -1.77% (p=0.016 n=4+5) --- src/core/lib/compression/compression.cc | 3 +- .../lib/compression/compression_internal.h | 8 ++ src/core/lib/surface/call.cc | 127 +++++++++++------- 3 files changed, 89 insertions(+), 49 deletions(-) diff --git a/src/core/lib/compression/compression.cc b/src/core/lib/compression/compression.cc index 2f35e5fa03f..8a0abca8dd7 100644 --- a/src/core/lib/compression/compression.cc +++ b/src/core/lib/compression/compression.cc @@ -127,7 +127,8 @@ void grpc_compression_options_disable_algorithm( int grpc_compression_options_is_algorithm_enabled( const grpc_compression_options* opts, grpc_compression_algorithm algorithm) { - return GPR_BITGET(opts->enabled_algorithms_bitset, algorithm); + return grpc_compression_options_is_algorithm_enabled_internal(opts, + algorithm); } grpc_slice grpc_compression_algorithm_slice( diff --git a/src/core/lib/compression/compression_internal.h b/src/core/lib/compression/compression_internal.h index 73947a2c34d..49afb941d73 100644 --- a/src/core/lib/compression/compression_internal.h +++ b/src/core/lib/compression/compression_internal.h @@ -23,6 +23,8 @@ #include +#include "src/core/lib/gpr/useful.h" + #ifdef __cplusplus extern "C" { #endif @@ -85,4 +87,10 @@ int grpc_stream_compression_algorithm_parse( } #endif +inline int grpc_compression_options_is_algorithm_enabled_internal( + const grpc_compression_options* opts, + grpc_compression_algorithm algorithm) { + return GPR_BITGET(opts->enabled_algorithms_bitset, algorithm); +} + #endif /* GRPC_CORE_LIB_COMPRESSION_COMPRESSION_INTERNAL_H */ diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 1331e57ab0c..3c6a5d098ae 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -1365,64 +1365,95 @@ static void receiving_stream_ready_in_call_combiner(void* bctlp, receiving_stream_ready(bctlp, error); } +static void GPR_ATTRIBUTE_NOINLINE +handle_both_stream_and_msg_compression_set(grpc_call* call) { + char* error_msg = nullptr; + gpr_asprintf(&error_msg, + "Incoming stream has both stream compression (%d) and message " + "compression (%d).", + call->incoming_stream_compression_algorithm, + call->incoming_message_compression_algorithm); + gpr_log(GPR_ERROR, "%s", error_msg); + cancel_with_status(call, GRPC_STATUS_INTERNAL, error_msg); + gpr_free(error_msg); +} + +static void GPR_ATTRIBUTE_NOINLINE +handle_error_parsing_compression_algorithm(grpc_call* call) { + char* error_msg = nullptr; + gpr_asprintf(&error_msg, + "Error in incoming message compression (%d) or stream " + "compression (%d).", + call->incoming_stream_compression_algorithm, + call->incoming_message_compression_algorithm); + cancel_with_status(call, GRPC_STATUS_INTERNAL, error_msg); + gpr_free(error_msg); +} + +static void GPR_ATTRIBUTE_NOINLINE handle_invalid_compression( + grpc_call* call, grpc_compression_algorithm compression_algorithm) { + char* error_msg = nullptr; + gpr_asprintf(&error_msg, "Invalid compression algorithm value '%d'.", + compression_algorithm); + gpr_log(GPR_ERROR, "%s", error_msg); + cancel_with_status(call, GRPC_STATUS_UNIMPLEMENTED, error_msg); + gpr_free(error_msg); +} + +static void GPR_ATTRIBUTE_NOINLINE handle_compression_algorithm_disabled( + grpc_call* call, grpc_compression_algorithm compression_algorithm) { + char* error_msg = nullptr; + const char* algo_name = nullptr; + grpc_compression_algorithm_name(compression_algorithm, &algo_name); + gpr_asprintf(&error_msg, "Compression algorithm '%s' is disabled.", + algo_name); + gpr_log(GPR_ERROR, "%s", error_msg); + cancel_with_status(call, GRPC_STATUS_UNIMPLEMENTED, error_msg); + gpr_free(error_msg); +} + +static void GPR_ATTRIBUTE_NOINLINE handle_compression_algorithm_not_accepted( + grpc_call* call, grpc_compression_algorithm compression_algorithm) { + const char* algo_name = nullptr; + grpc_compression_algorithm_name(compression_algorithm, &algo_name); + gpr_log(GPR_ERROR, + "Compression algorithm ('%s') not present in the bitset of " + "accepted encodings ('0x%x')", + algo_name, call->encodings_accepted_by_peer); +} + static void validate_filtered_metadata(batch_control* bctl) { grpc_compression_algorithm compression_algorithm; grpc_call* call = bctl->call; - if (call->incoming_stream_compression_algorithm != - GRPC_STREAM_COMPRESS_NONE && - call->incoming_message_compression_algorithm != - GRPC_MESSAGE_COMPRESS_NONE) { - char* error_msg = nullptr; - gpr_asprintf(&error_msg, - "Incoming stream has both stream compression (%d) and message " - "compression (%d).", - call->incoming_stream_compression_algorithm, - call->incoming_message_compression_algorithm); - gpr_log(GPR_ERROR, "%s", error_msg); - cancel_with_status(call, GRPC_STATUS_INTERNAL, error_msg); - gpr_free(error_msg); + if (GPR_UNLIKELY(call->incoming_stream_compression_algorithm != + GRPC_STREAM_COMPRESS_NONE && + call->incoming_message_compression_algorithm != + GRPC_MESSAGE_COMPRESS_NONE)) { + handle_both_stream_and_msg_compression_set(call); } else if ( - grpc_compression_algorithm_from_message_stream_compression_algorithm( - &compression_algorithm, call->incoming_message_compression_algorithm, - call->incoming_stream_compression_algorithm) == 0) { - char* error_msg = nullptr; - gpr_asprintf(&error_msg, - "Error in incoming message compression (%d) or stream " - "compression (%d).", - call->incoming_stream_compression_algorithm, - call->incoming_message_compression_algorithm); - cancel_with_status(call, GRPC_STATUS_INTERNAL, error_msg); - gpr_free(error_msg); + GPR_UNLIKELY( + grpc_compression_algorithm_from_message_stream_compression_algorithm( + &compression_algorithm, + call->incoming_message_compression_algorithm, + call->incoming_stream_compression_algorithm) == 0)) { + handle_error_parsing_compression_algorithm(call); } else { - char* error_msg = nullptr; const grpc_compression_options compression_options = grpc_channel_compression_options(call->channel); - if (compression_algorithm >= GRPC_COMPRESS_ALGORITHMS_COUNT) { - gpr_asprintf(&error_msg, "Invalid compression algorithm value '%d'.", - compression_algorithm); - gpr_log(GPR_ERROR, "%s", error_msg); - cancel_with_status(call, GRPC_STATUS_UNIMPLEMENTED, error_msg); - } else if (grpc_compression_options_is_algorithm_enabled( - &compression_options, compression_algorithm) == 0) { + if (GPR_UNLIKELY(compression_algorithm >= GRPC_COMPRESS_ALGORITHMS_COUNT)) { + handle_invalid_compression(call, compression_algorithm); + } else if (GPR_UNLIKELY( + grpc_compression_options_is_algorithm_enabled_internal( + &compression_options, compression_algorithm) == 0)) { /* check if algorithm is supported by current channel config */ - const char* algo_name = nullptr; - grpc_compression_algorithm_name(compression_algorithm, &algo_name); - gpr_asprintf(&error_msg, "Compression algorithm '%s' is disabled.", - algo_name); - gpr_log(GPR_ERROR, "%s", error_msg); - cancel_with_status(call, GRPC_STATUS_UNIMPLEMENTED, error_msg); + handle_compression_algorithm_disabled(call, compression_algorithm); } - gpr_free(error_msg); - - GPR_ASSERT(call->encodings_accepted_by_peer != 0); - if (!GPR_BITGET(call->encodings_accepted_by_peer, compression_algorithm)) { + /* GRPC_COMPRESS_NONE is always set. */ + GPR_DEBUG_ASSERT(call->encodings_accepted_by_peer != 0); + if (GPR_UNLIKELY(!GPR_BITGET(call->encodings_accepted_by_peer, + compression_algorithm))) { if (GRPC_TRACE_FLAG_ENABLED(grpc_compression_trace)) { - const char* algo_name = nullptr; - grpc_compression_algorithm_name(compression_algorithm, &algo_name); - gpr_log(GPR_ERROR, - "Compression algorithm ('%s') not present in the bitset of " - "accepted encodings ('0x%x')", - algo_name, call->encodings_accepted_by_peer); + handle_compression_algorithm_not_accepted(call, compression_algorithm); } } } From 51d18ecc63cf2444c5e216b14e0c4bd0f542185a Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 5 Sep 2019 10:32:36 -0700 Subject: [PATCH 1470/1555] Convert mpscq API from C to C++. --- BUILD | 4 +- BUILD.gn | 6 +- CMakeLists.txt | 75 +++++++------ Makefile | 86 +++++++------- build.yaml | 26 ++--- config.m4 | 2 +- config.w32 | 2 +- gRPC-C++.podspec | 2 +- gRPC-Core.podspec | 6 +- grpc.gemspec | 4 +- grpc.gyp | 2 +- package.xml | 4 +- src/core/lib/gpr/mpscq.cc | 117 -------------------- src/core/lib/gpr/mpscq.h | 88 --------------- src/core/lib/gprpp/mpscq.cc | 108 ++++++++++++++++++ src/core/lib/gprpp/mpscq.h | 98 ++++++++++++++++ src/core/lib/iomgr/call_combiner.cc | 9 +- src/core/lib/iomgr/call_combiner.h | 4 +- src/core/lib/iomgr/closure.h | 11 +- src/core/lib/iomgr/combiner.cc | 17 ++- src/core/lib/iomgr/combiner.h | 1 - src/core/lib/surface/completion_queue.cc | 23 ++-- src/core/lib/surface/completion_queue.h | 5 +- src/core/lib/surface/server.cc | 33 +++--- src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/gpr/BUILD | 11 -- test/core/gprpp/BUILD | 11 ++ test/core/{gpr => gprpp}/mpscq_test.cc | 37 +++---- tools/doxygen/Doxyfile.c++.internal | 2 +- tools/doxygen/Doxyfile.core.internal | 4 +- tools/run_tests/generated/tests.json | 48 ++++---- 31 files changed, 438 insertions(+), 410 deletions(-) delete mode 100644 src/core/lib/gpr/mpscq.cc delete mode 100644 src/core/lib/gpr/mpscq.h create mode 100644 src/core/lib/gprpp/mpscq.cc create mode 100644 src/core/lib/gprpp/mpscq.h rename test/core/{gpr => gprpp}/mpscq_test.cc (85%) diff --git a/BUILD b/BUILD index d911050b1be..9bb6533b4b6 100644 --- a/BUILD +++ b/BUILD @@ -471,7 +471,6 @@ grpc_cc_library( "src/core/lib/gpr/log_linux.cc", "src/core/lib/gpr/log_posix.cc", "src/core/lib/gpr/log_windows.cc", - "src/core/lib/gpr/mpscq.cc", "src/core/lib/gpr/murmur_hash.cc", "src/core/lib/gpr/string.cc", "src/core/lib/gpr/string_posix.cc", @@ -493,6 +492,7 @@ grpc_cc_library( "src/core/lib/gprpp/fork.cc", "src/core/lib/gprpp/global_config_env.cc", "src/core/lib/gprpp/host_port.cc", + "src/core/lib/gprpp/mpscq.cc", "src/core/lib/gprpp/thd_posix.cc", "src/core/lib/gprpp/thd_windows.cc", "src/core/lib/profiling/basic_timers.cc", @@ -502,7 +502,6 @@ grpc_cc_library( "src/core/lib/gpr/alloc.h", "src/core/lib/gpr/arena.h", "src/core/lib/gpr/env.h", - "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", "src/core/lib/gpr/spinlock.h", "src/core/lib/gpr/string.h", @@ -526,6 +525,7 @@ grpc_cc_library( "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", + "src/core/lib/gprpp/mpscq.h", "src/core/lib/gprpp/pair.h", "src/core/lib/gprpp/string_view.h", "src/core/lib/gprpp/sync.h", diff --git a/BUILD.gn b/BUILD.gn index 771e968f366..0f340214aa3 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -104,8 +104,6 @@ config("grpc_config") { "src/core/lib/gpr/log_linux.cc", "src/core/lib/gpr/log_posix.cc", "src/core/lib/gpr/log_windows.cc", - "src/core/lib/gpr/mpscq.cc", - "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.cc", "src/core/lib/gpr/murmur_hash.h", "src/core/lib/gpr/spinlock.h", @@ -150,6 +148,8 @@ config("grpc_config") { "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", + "src/core/lib/gprpp/mpscq.cc", + "src/core/lib/gprpp/mpscq.h", "src/core/lib/gprpp/pair.h", "src/core/lib/gprpp/sync.h", "src/core/lib/gprpp/thd.h", @@ -1223,7 +1223,6 @@ config("grpc_config") { "src/core/lib/gpr/alloc.h", "src/core/lib/gpr/arena.h", "src/core/lib/gpr/env.h", - "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", "src/core/lib/gpr/spinlock.h", "src/core/lib/gpr/string.h", @@ -1249,6 +1248,7 @@ config("grpc_config") { "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", + "src/core/lib/gprpp/mpscq.h", "src/core/lib/gprpp/optional.h", "src/core/lib/gprpp/orphanable.h", "src/core/lib/gprpp/pair.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 599f1441583..23fafa061d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -308,7 +308,6 @@ add_dependencies(buildtests_c gpr_env_test) add_dependencies(buildtests_c gpr_host_port_test) add_dependencies(buildtests_c gpr_log_test) add_dependencies(buildtests_c gpr_manual_constructor_test) -add_dependencies(buildtests_c gpr_mpscq_test) add_dependencies(buildtests_c gpr_spinlock_test) add_dependencies(buildtests_c gpr_string_test) add_dependencies(buildtests_c gpr_sync_test) @@ -628,6 +627,7 @@ add_dependencies(buildtests_cxx generic_end2end_test) add_dependencies(buildtests_cxx global_config_env_test) add_dependencies(buildtests_cxx global_config_test) add_dependencies(buildtests_cxx golden_file_test) +add_dependencies(buildtests_cxx gprpp_mpscq_test) add_dependencies(buildtests_cxx grpc_alts_credentials_options_test) add_dependencies(buildtests_cxx grpc_cli) add_dependencies(buildtests_cxx grpc_core_map_test) @@ -864,7 +864,6 @@ add_library(gpr src/core/lib/gpr/log_linux.cc src/core/lib/gpr/log_posix.cc src/core/lib/gpr/log_windows.cc - src/core/lib/gpr/mpscq.cc src/core/lib/gpr/murmur_hash.cc src/core/lib/gpr/string.cc src/core/lib/gpr/string_posix.cc @@ -886,6 +885,7 @@ add_library(gpr src/core/lib/gprpp/fork.cc src/core/lib/gprpp/global_config_env.cc src/core/lib/gprpp/host_port.cc + src/core/lib/gprpp/mpscq.cc src/core/lib/gprpp/thd_posix.cc src/core/lib/gprpp/thd_windows.cc src/core/lib/profiling/basic_timers.cc @@ -7078,37 +7078,6 @@ target_link_libraries(gpr_manual_constructor_test ) -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) - -add_executable(gpr_mpscq_test - test/core/gpr/mpscq_test.cc -) - - -target_include_directories(gpr_mpscq_test - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_UPB_GENERATED_DIR} - PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} - PRIVATE ${_gRPC_UPB_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} -) - -target_link_libraries(gpr_mpscq_test - ${_gRPC_ALLTARGETS_LIBRARIES} - gpr - grpc_test_util_unsecure - grpc_unsecure -) - - endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) @@ -13340,6 +13309,46 @@ target_link_libraries(golden_file_test ) +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + +add_executable(gprpp_mpscq_test + test/core/gprpp/mpscq_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(gprpp_mpscq_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_UPB_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} + PRIVATE ${_gRPC_UPB_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(gprpp_mpscq_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + gpr + grpc_test_util_unsecure + grpc_unsecure + ${_gRPC_GFLAGS_LIBRARIES} +) + + endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index d48b36a531f..5e334107f5a 100644 --- a/Makefile +++ b/Makefile @@ -1038,7 +1038,6 @@ gpr_env_test: $(BINDIR)/$(CONFIG)/gpr_env_test gpr_host_port_test: $(BINDIR)/$(CONFIG)/gpr_host_port_test gpr_log_test: $(BINDIR)/$(CONFIG)/gpr_log_test gpr_manual_constructor_test: $(BINDIR)/$(CONFIG)/gpr_manual_constructor_test -gpr_mpscq_test: $(BINDIR)/$(CONFIG)/gpr_mpscq_test gpr_spinlock_test: $(BINDIR)/$(CONFIG)/gpr_spinlock_test gpr_string_test: $(BINDIR)/$(CONFIG)/gpr_string_test gpr_sync_test: $(BINDIR)/$(CONFIG)/gpr_sync_test @@ -1219,6 +1218,7 @@ generic_end2end_test: $(BINDIR)/$(CONFIG)/generic_end2end_test global_config_env_test: $(BINDIR)/$(CONFIG)/global_config_env_test global_config_test: $(BINDIR)/$(CONFIG)/global_config_test golden_file_test: $(BINDIR)/$(CONFIG)/golden_file_test +gprpp_mpscq_test: $(BINDIR)/$(CONFIG)/gprpp_mpscq_test grpc_alts_credentials_options_test: $(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test grpc_cli: $(BINDIR)/$(CONFIG)/grpc_cli grpc_core_map_test: $(BINDIR)/$(CONFIG)/grpc_core_map_test @@ -1478,7 +1478,6 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/gpr_host_port_test \ $(BINDIR)/$(CONFIG)/gpr_log_test \ $(BINDIR)/$(CONFIG)/gpr_manual_constructor_test \ - $(BINDIR)/$(CONFIG)/gpr_mpscq_test \ $(BINDIR)/$(CONFIG)/gpr_spinlock_test \ $(BINDIR)/$(CONFIG)/gpr_string_test \ $(BINDIR)/$(CONFIG)/gpr_sync_test \ @@ -1698,6 +1697,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/global_config_env_test \ $(BINDIR)/$(CONFIG)/global_config_test \ $(BINDIR)/$(CONFIG)/golden_file_test \ + $(BINDIR)/$(CONFIG)/gprpp_mpscq_test \ $(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test \ $(BINDIR)/$(CONFIG)/grpc_cli \ $(BINDIR)/$(CONFIG)/grpc_core_map_test \ @@ -1867,6 +1867,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/global_config_env_test \ $(BINDIR)/$(CONFIG)/global_config_test \ $(BINDIR)/$(CONFIG)/golden_file_test \ + $(BINDIR)/$(CONFIG)/gprpp_mpscq_test \ $(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test \ $(BINDIR)/$(CONFIG)/grpc_cli \ $(BINDIR)/$(CONFIG)/grpc_core_map_test \ @@ -2048,8 +2049,6 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/gpr_log_test || ( echo test gpr_log_test failed ; exit 1 ) $(E) "[RUN] Testing gpr_manual_constructor_test" $(Q) $(BINDIR)/$(CONFIG)/gpr_manual_constructor_test || ( echo test gpr_manual_constructor_test failed ; exit 1 ) - $(E) "[RUN] Testing gpr_mpscq_test" - $(Q) $(BINDIR)/$(CONFIG)/gpr_mpscq_test || ( echo test gpr_mpscq_test failed ; exit 1 ) $(E) "[RUN] Testing gpr_spinlock_test" $(Q) $(BINDIR)/$(CONFIG)/gpr_spinlock_test || ( echo test gpr_spinlock_test failed ; exit 1 ) $(E) "[RUN] Testing gpr_string_test" @@ -2376,6 +2375,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/global_config_test || ( echo test global_config_test failed ; exit 1 ) $(E) "[RUN] Testing golden_file_test" $(Q) $(BINDIR)/$(CONFIG)/golden_file_test || ( echo test golden_file_test failed ; exit 1 ) + $(E) "[RUN] Testing gprpp_mpscq_test" + $(Q) $(BINDIR)/$(CONFIG)/gprpp_mpscq_test || ( echo test gprpp_mpscq_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_alts_credentials_options_test" $(Q) $(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test || ( echo test grpc_alts_credentials_options_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_core_map_test" @@ -3457,7 +3458,6 @@ LIBGPR_SRC = \ src/core/lib/gpr/log_linux.cc \ src/core/lib/gpr/log_posix.cc \ src/core/lib/gpr/log_windows.cc \ - src/core/lib/gpr/mpscq.cc \ src/core/lib/gpr/murmur_hash.cc \ src/core/lib/gpr/string.cc \ src/core/lib/gpr/string_posix.cc \ @@ -3479,6 +3479,7 @@ LIBGPR_SRC = \ src/core/lib/gprpp/fork.cc \ src/core/lib/gprpp/global_config_env.cc \ src/core/lib/gprpp/host_port.cc \ + src/core/lib/gprpp/mpscq.cc \ src/core/lib/gprpp/thd_posix.cc \ src/core/lib/gprpp/thd_windows.cc \ src/core/lib/profiling/basic_timers.cc \ @@ -9986,38 +9987,6 @@ endif endif -GPR_MPSCQ_TEST_SRC = \ - test/core/gpr/mpscq_test.cc \ - -GPR_MPSCQ_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_MPSCQ_TEST_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/gpr_mpscq_test: openssl_dep_error - -else - - - -$(BINDIR)/$(CONFIG)/gpr_mpscq_test: $(GPR_MPSCQ_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(GPR_MPSCQ_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_mpscq_test - -endif - -$(OBJDIR)/$(CONFIG)/test/core/gpr/mpscq_test.o: $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a - -deps_gpr_mpscq_test: $(GPR_MPSCQ_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(GPR_MPSCQ_TEST_OBJS:.o=.dep) -endif -endif - - GPR_SPINLOCK_TEST_SRC = \ test/core/gpr/spinlock_test.cc \ @@ -16730,6 +16699,49 @@ endif $(OBJDIR)/$(CONFIG)/test/cpp/codegen/golden_file_test.o: $(GENDIR)/src/proto/grpc/testing/compiler_test.pb.cc $(GENDIR)/src/proto/grpc/testing/compiler_test.grpc.pb.cc +GPRPP_MPSCQ_TEST_SRC = \ + test/core/gprpp/mpscq_test.cc \ + +GPRPP_MPSCQ_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPRPP_MPSCQ_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/gprpp_mpscq_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. + +$(BINDIR)/$(CONFIG)/gprpp_mpscq_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/gprpp_mpscq_test: $(PROTOBUF_DEP) $(GPRPP_MPSCQ_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(GPRPP_MPSCQ_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/gprpp_mpscq_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/core/gprpp/mpscq_test.o: $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a + +deps_gprpp_mpscq_test: $(GPRPP_MPSCQ_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(GPRPP_MPSCQ_TEST_OBJS:.o=.dep) +endif +endif + + GRPC_ALTS_CREDENTIALS_OPTIONS_TEST_SRC = \ test/core/security/grpc_alts_credentials_options_test.cc \ diff --git a/build.yaml b/build.yaml index 9c546246ab0..bbbf4eb6374 100644 --- a/build.yaml +++ b/build.yaml @@ -217,7 +217,6 @@ filegroups: - src/core/lib/gpr/log_linux.cc - src/core/lib/gpr/log_posix.cc - src/core/lib/gpr/log_windows.cc - - src/core/lib/gpr/mpscq.cc - src/core/lib/gpr/murmur_hash.cc - src/core/lib/gpr/string.cc - src/core/lib/gpr/string_posix.cc @@ -239,6 +238,7 @@ filegroups: - src/core/lib/gprpp/fork.cc - src/core/lib/gprpp/global_config_env.cc - src/core/lib/gprpp/host_port.cc + - src/core/lib/gprpp/mpscq.cc - src/core/lib/gprpp/thd_posix.cc - src/core/lib/gprpp/thd_windows.cc - src/core/lib/profiling/basic_timers.cc @@ -268,7 +268,6 @@ filegroups: - src/core/lib/gpr/alloc.h - src/core/lib/gpr/arena.h - src/core/lib/gpr/env.h - - src/core/lib/gpr/mpscq.h - src/core/lib/gpr/murmur_hash.h - src/core/lib/gpr/spinlock.h - src/core/lib/gpr/string.h @@ -292,6 +291,7 @@ filegroups: - src/core/lib/gprpp/manual_constructor.h - src/core/lib/gprpp/map.h - src/core/lib/gprpp/memory.h + - src/core/lib/gprpp/mpscq.h - src/core/lib/gprpp/pair.h - src/core/lib/gprpp/sync.h - src/core/lib/gprpp/thd.h @@ -2738,17 +2738,6 @@ targets: - grpc_test_util_unsecure - grpc_unsecure uses_polling: false -- name: gpr_mpscq_test - cpu_cost: 30 - build: test - language: c - src: - - test/core/gpr/mpscq_test.cc - deps: - - gpr - - grpc_test_util_unsecure - - grpc_unsecure - uses_polling: false - name: gpr_spinlock_test cpu_cost: 3 build: test @@ -5001,6 +4990,17 @@ targets: args: - --generated_file_path=gens/src/proto/grpc/testing/ uses_polling: false +- name: gprpp_mpscq_test + cpu_cost: 30 + build: test + language: c++ + src: + - test/core/gprpp/mpscq_test.cc + deps: + - gpr + - grpc_test_util_unsecure + - grpc_unsecure + uses_polling: false - name: grpc_alts_credentials_options_test build: test language: c++ diff --git a/config.m4 b/config.m4 index efa86576f84..05bb4eada44 100644 --- a/config.m4 +++ b/config.m4 @@ -63,7 +63,6 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/gpr/log_linux.cc \ src/core/lib/gpr/log_posix.cc \ src/core/lib/gpr/log_windows.cc \ - src/core/lib/gpr/mpscq.cc \ src/core/lib/gpr/murmur_hash.cc \ src/core/lib/gpr/string.cc \ src/core/lib/gpr/string_posix.cc \ @@ -85,6 +84,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/gprpp/fork.cc \ src/core/lib/gprpp/global_config_env.cc \ src/core/lib/gprpp/host_port.cc \ + src/core/lib/gprpp/mpscq.cc \ src/core/lib/gprpp/thd_posix.cc \ src/core/lib/gprpp/thd_windows.cc \ src/core/lib/profiling/basic_timers.cc \ diff --git a/config.w32 b/config.w32 index 13b5f1350f0..ed52f91e87d 100644 --- a/config.w32 +++ b/config.w32 @@ -33,7 +33,6 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\gpr\\log_linux.cc " + "src\\core\\lib\\gpr\\log_posix.cc " + "src\\core\\lib\\gpr\\log_windows.cc " + - "src\\core\\lib\\gpr\\mpscq.cc " + "src\\core\\lib\\gpr\\murmur_hash.cc " + "src\\core\\lib\\gpr\\string.cc " + "src\\core\\lib\\gpr\\string_posix.cc " + @@ -55,6 +54,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\gprpp\\fork.cc " + "src\\core\\lib\\gprpp\\global_config_env.cc " + "src\\core\\lib\\gprpp\\host_port.cc " + + "src\\core\\lib\\gprpp\\mpscq.cc " + "src\\core\\lib\\gprpp\\thd_posix.cc " + "src\\core\\lib\\gprpp\\thd_windows.cc " + "src\\core\\lib\\profiling\\basic_timers.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 881e8959651..1a1a6365488 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -287,7 +287,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/alloc.h', 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', - 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', 'src/core/lib/gpr/spinlock.h', 'src/core/lib/gpr/string.h', @@ -311,6 +310,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', + 'src/core/lib/gprpp/mpscq.h', 'src/core/lib/gprpp/pair.h', 'src/core/lib/gprpp/sync.h', 'src/core/lib/gprpp/thd.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 658a3ad6158..189cf935128 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -191,7 +191,6 @@ Pod::Spec.new do |s| ss.source_files = 'src/core/lib/gpr/alloc.h', 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', - 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', 'src/core/lib/gpr/spinlock.h', 'src/core/lib/gpr/string.h', @@ -215,6 +214,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', + 'src/core/lib/gprpp/mpscq.h', 'src/core/lib/gprpp/pair.h', 'src/core/lib/gprpp/sync.h', 'src/core/lib/gprpp/thd.h', @@ -233,7 +233,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/log_linux.cc', 'src/core/lib/gpr/log_posix.cc', 'src/core/lib/gpr/log_windows.cc', - 'src/core/lib/gpr/mpscq.cc', 'src/core/lib/gpr/murmur_hash.cc', 'src/core/lib/gpr/string.cc', 'src/core/lib/gpr/string_posix.cc', @@ -255,6 +254,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/fork.cc', 'src/core/lib/gprpp/global_config_env.cc', 'src/core/lib/gprpp/host_port.cc', + 'src/core/lib/gprpp/mpscq.cc', 'src/core/lib/gprpp/thd_posix.cc', 'src/core/lib/gprpp/thd_windows.cc', 'src/core/lib/profiling/basic_timers.cc', @@ -965,7 +965,6 @@ Pod::Spec.new do |s| ss.private_header_files = 'src/core/lib/gpr/alloc.h', 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', - 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', 'src/core/lib/gpr/spinlock.h', 'src/core/lib/gpr/string.h', @@ -989,6 +988,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', + 'src/core/lib/gprpp/mpscq.h', 'src/core/lib/gprpp/pair.h', 'src/core/lib/gprpp/sync.h', 'src/core/lib/gprpp/thd.h', diff --git a/grpc.gemspec b/grpc.gemspec index 1b705016cee..0319a265a66 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -85,7 +85,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/alloc.h ) s.files += %w( src/core/lib/gpr/arena.h ) s.files += %w( src/core/lib/gpr/env.h ) - s.files += %w( src/core/lib/gpr/mpscq.h ) s.files += %w( src/core/lib/gpr/murmur_hash.h ) s.files += %w( src/core/lib/gpr/spinlock.h ) s.files += %w( src/core/lib/gpr/string.h ) @@ -109,6 +108,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gprpp/manual_constructor.h ) s.files += %w( src/core/lib/gprpp/map.h ) s.files += %w( src/core/lib/gprpp/memory.h ) + s.files += %w( src/core/lib/gprpp/mpscq.h ) s.files += %w( src/core/lib/gprpp/pair.h ) s.files += %w( src/core/lib/gprpp/sync.h ) s.files += %w( src/core/lib/gprpp/thd.h ) @@ -127,7 +127,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/log_linux.cc ) s.files += %w( src/core/lib/gpr/log_posix.cc ) s.files += %w( src/core/lib/gpr/log_windows.cc ) - s.files += %w( src/core/lib/gpr/mpscq.cc ) s.files += %w( src/core/lib/gpr/murmur_hash.cc ) s.files += %w( src/core/lib/gpr/string.cc ) s.files += %w( src/core/lib/gpr/string_posix.cc ) @@ -149,6 +148,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gprpp/fork.cc ) s.files += %w( src/core/lib/gprpp/global_config_env.cc ) s.files += %w( src/core/lib/gprpp/host_port.cc ) + s.files += %w( src/core/lib/gprpp/mpscq.cc ) s.files += %w( src/core/lib/gprpp/thd_posix.cc ) s.files += %w( src/core/lib/gprpp/thd_windows.cc ) s.files += %w( src/core/lib/profiling/basic_timers.cc ) diff --git a/grpc.gyp b/grpc.gyp index 5468675e768..e7bb27d9ed2 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -254,7 +254,6 @@ 'src/core/lib/gpr/log_linux.cc', 'src/core/lib/gpr/log_posix.cc', 'src/core/lib/gpr/log_windows.cc', - 'src/core/lib/gpr/mpscq.cc', 'src/core/lib/gpr/murmur_hash.cc', 'src/core/lib/gpr/string.cc', 'src/core/lib/gpr/string_posix.cc', @@ -276,6 +275,7 @@ 'src/core/lib/gprpp/fork.cc', 'src/core/lib/gprpp/global_config_env.cc', 'src/core/lib/gprpp/host_port.cc', + 'src/core/lib/gprpp/mpscq.cc', 'src/core/lib/gprpp/thd_posix.cc', 'src/core/lib/gprpp/thd_windows.cc', 'src/core/lib/profiling/basic_timers.cc', diff --git a/package.xml b/package.xml index 385a57c77ea..b05be16f392 100644 --- a/package.xml +++ b/package.xml @@ -90,7 +90,6 @@ - @@ -114,6 +113,7 @@ + @@ -132,7 +132,6 @@ - @@ -154,6 +153,7 @@ + diff --git a/src/core/lib/gpr/mpscq.cc b/src/core/lib/gpr/mpscq.cc deleted file mode 100644 index 076a6bb033c..00000000000 --- a/src/core/lib/gpr/mpscq.cc +++ /dev/null @@ -1,117 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/lib/gpr/mpscq.h" - -#include - -void gpr_mpscq_init(gpr_mpscq* q) { - gpr_atm_no_barrier_store(&q->head, (gpr_atm)&q->stub); - q->tail = &q->stub; - gpr_atm_no_barrier_store(&q->stub.next, (gpr_atm)NULL); -} - -void gpr_mpscq_destroy(gpr_mpscq* q) { - GPR_ASSERT(gpr_atm_no_barrier_load(&q->head) == (gpr_atm)&q->stub); - GPR_ASSERT(q->tail == &q->stub); -} - -bool gpr_mpscq_push(gpr_mpscq* q, gpr_mpscq_node* n) { - gpr_atm_no_barrier_store(&n->next, (gpr_atm)NULL); - gpr_mpscq_node* prev = - (gpr_mpscq_node*)gpr_atm_full_xchg(&q->head, (gpr_atm)n); - gpr_atm_rel_store(&prev->next, (gpr_atm)n); - return prev == &q->stub; -} - -gpr_mpscq_node* gpr_mpscq_pop(gpr_mpscq* q) { - bool empty; - return gpr_mpscq_pop_and_check_end(q, &empty); -} - -gpr_mpscq_node* gpr_mpscq_pop_and_check_end(gpr_mpscq* q, bool* empty) { - gpr_mpscq_node* tail = q->tail; - gpr_mpscq_node* next = (gpr_mpscq_node*)gpr_atm_acq_load(&tail->next); - if (tail == &q->stub) { - // indicates the list is actually (ephemerally) empty - if (next == nullptr) { - *empty = true; - return nullptr; - } - q->tail = next; - tail = next; - next = (gpr_mpscq_node*)gpr_atm_acq_load(&tail->next); - } - if (next != nullptr) { - *empty = false; - q->tail = next; - return tail; - } - gpr_mpscq_node* head = (gpr_mpscq_node*)gpr_atm_acq_load(&q->head); - if (tail != head) { - *empty = false; - // indicates a retry is in order: we're still adding - return nullptr; - } - gpr_mpscq_push(q, &q->stub); - next = (gpr_mpscq_node*)gpr_atm_acq_load(&tail->next); - if (next != nullptr) { - *empty = false; - q->tail = next; - return tail; - } - // indicates a retry is in order: we're still adding - *empty = false; - return nullptr; -} - -void gpr_locked_mpscq_init(gpr_locked_mpscq* q) { - gpr_mpscq_init(&q->queue); - gpr_mu_init(&q->mu); -} - -void gpr_locked_mpscq_destroy(gpr_locked_mpscq* q) { - gpr_mpscq_destroy(&q->queue); - gpr_mu_destroy(&q->mu); -} - -bool gpr_locked_mpscq_push(gpr_locked_mpscq* q, gpr_mpscq_node* n) { - return gpr_mpscq_push(&q->queue, n); -} - -gpr_mpscq_node* gpr_locked_mpscq_try_pop(gpr_locked_mpscq* q) { - if (gpr_mu_trylock(&q->mu)) { - gpr_mpscq_node* n = gpr_mpscq_pop(&q->queue); - gpr_mu_unlock(&q->mu); - return n; - } - return nullptr; -} - -gpr_mpscq_node* gpr_locked_mpscq_pop(gpr_locked_mpscq* q) { - gpr_mu_lock(&q->mu); - bool empty = false; - gpr_mpscq_node* n; - do { - n = gpr_mpscq_pop_and_check_end(&q->queue, &empty); - } while (n == nullptr && !empty); - gpr_mu_unlock(&q->mu); - return n; -} diff --git a/src/core/lib/gpr/mpscq.h b/src/core/lib/gpr/mpscq.h deleted file mode 100644 index 5ded2522bd6..00000000000 --- a/src/core/lib/gpr/mpscq.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_CORE_LIB_GPR_MPSCQ_H -#define GRPC_CORE_LIB_GPR_MPSCQ_H - -#include - -#include -#include -#include -#include - -// Multiple-producer single-consumer lock free queue, based upon the -// implementation from Dmitry Vyukov here: -// http://www.1024cores.net/home/lock-free-algorithms/queues/intrusive-mpsc-node-based-queue - -// List node (include this in a data structure at the top, and add application -// fields after it - to simulate inheritance) -typedef struct gpr_mpscq_node { - gpr_atm next; -} gpr_mpscq_node; - -// Actual queue type -typedef struct gpr_mpscq { - // make sure head & tail don't share a cacheline - union { - char padding[GPR_CACHELINE_SIZE]; - gpr_atm head; - }; - gpr_mpscq_node* tail; - gpr_mpscq_node stub; -} gpr_mpscq; - -void gpr_mpscq_init(gpr_mpscq* q); -void gpr_mpscq_destroy(gpr_mpscq* q); -// Push a node -// Thread safe - can be called from multiple threads concurrently -// Returns true if this was possibly the first node (may return true -// sporadically, will not return false sporadically) -bool gpr_mpscq_push(gpr_mpscq* q, gpr_mpscq_node* n); -// Pop a node (returns NULL if no node is ready - which doesn't indicate that -// the queue is empty!!) -// Thread compatible - can only be called from one thread at a time -gpr_mpscq_node* gpr_mpscq_pop(gpr_mpscq* q); -// Pop a node; sets *empty to true if the queue is empty, or false if it is not -gpr_mpscq_node* gpr_mpscq_pop_and_check_end(gpr_mpscq* q, bool* empty); - -// An mpscq with a lock: it's safe to pop from multiple threads, but doing -// only one thread will succeed concurrently -typedef struct gpr_locked_mpscq { - gpr_mpscq queue; - gpr_mu mu; -} gpr_locked_mpscq; - -void gpr_locked_mpscq_init(gpr_locked_mpscq* q); -void gpr_locked_mpscq_destroy(gpr_locked_mpscq* q); -// Push a node -// Thread safe - can be called from multiple threads concurrently -// Returns true if this was possibly the first node (may return true -// sporadically, will not return false sporadically) -bool gpr_locked_mpscq_push(gpr_locked_mpscq* q, gpr_mpscq_node* n); - -// Pop a node (returns NULL if no node is ready - which doesn't indicate that -// the queue is empty!!) -// Thread safe - can be called from multiple threads concurrently -gpr_mpscq_node* gpr_locked_mpscq_try_pop(gpr_locked_mpscq* q); - -// Pop a node. Returns NULL only if the queue was empty at some point after -// calling this function -gpr_mpscq_node* gpr_locked_mpscq_pop(gpr_locked_mpscq* q); - -#endif /* GRPC_CORE_LIB_GPR_MPSCQ_H */ diff --git a/src/core/lib/gprpp/mpscq.cc b/src/core/lib/gprpp/mpscq.cc new file mode 100644 index 00000000000..2bf9981ee26 --- /dev/null +++ b/src/core/lib/gprpp/mpscq.cc @@ -0,0 +1,108 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/gprpp/mpscq.h" + +namespace grpc_core { + +// +// MultiProducerSingleConsumerQueue +// + +bool MultiProducerSingleConsumerQueue::Push(Node* node) { + node->next.Store(nullptr, MemoryOrder::RELAXED); + Node* prev = head_.Exchange(node, MemoryOrder::ACQ_REL); + prev->next.Store(node, MemoryOrder::RELEASE); + return prev == &stub_; +} + +MultiProducerSingleConsumerQueue::Node* +MultiProducerSingleConsumerQueue::Pop() { + bool empty; + return PopAndCheckEnd(&empty); +} + +MultiProducerSingleConsumerQueue::Node* +MultiProducerSingleConsumerQueue::PopAndCheckEnd(bool* empty) { + Node* tail = tail_; + Node* next = tail_->next.Load(MemoryOrder::ACQUIRE); + if (tail == &stub_) { + // indicates the list is actually (ephemerally) empty + if (next == nullptr) { + *empty = true; + return nullptr; + } + tail_ = next; + tail = next; + next = tail->next.Load(MemoryOrder::ACQUIRE); + } + if (next != nullptr) { + *empty = false; + tail_ = next; + return tail; + } + Node* head = head_.Load(MemoryOrder::ACQUIRE); + if (tail != head) { + *empty = false; + // indicates a retry is in order: we're still adding + return nullptr; + } + Push(&stub_); + next = tail->next.Load(MemoryOrder::ACQUIRE); + if (next != nullptr) { + *empty = false; + tail_ = next; + return tail; + } + // indicates a retry is in order: we're still adding + *empty = false; + return nullptr; +} + +// +// LockedMultiProducerSingleConsumerQueue +// + +bool LockedMultiProducerSingleConsumerQueue::Push(Node* node) { + return queue_.Push(node); +} + +LockedMultiProducerSingleConsumerQueue::Node* +LockedMultiProducerSingleConsumerQueue::TryPop() { + if (gpr_mu_trylock(mu_.get())) { + Node* node = queue_.Pop(); + gpr_mu_unlock(mu_.get()); + return node; + } + return nullptr; +} + +LockedMultiProducerSingleConsumerQueue::Node* +LockedMultiProducerSingleConsumerQueue::Pop() { + MutexLock lock(&mu_); + bool empty = false; + Node* node; + do { + node = queue_.PopAndCheckEnd(&empty); + } while (node == nullptr && !empty); + return node; +} + +} // namespace grpc_core diff --git a/src/core/lib/gprpp/mpscq.h b/src/core/lib/gprpp/mpscq.h new file mode 100644 index 00000000000..a1c04cae23c --- /dev/null +++ b/src/core/lib/gprpp/mpscq.h @@ -0,0 +1,98 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_GPRPP_MPSCQ_H +#define GRPC_CORE_LIB_GPRPP_MPSCQ_H + +#include + +#include "src/core/lib/gprpp/atomic.h" +#include "src/core/lib/gprpp/sync.h" + +#include + +namespace grpc_core { + +// Multiple-producer single-consumer lock free queue, based upon the +// implementation from Dmitry Vyukov here: +// http://www.1024cores.net/home/lock-free-algorithms/queues/intrusive-mpsc-node-based-queue +class MultiProducerSingleConsumerQueue { + public: + // List node. Application node types can inherit from this. + struct Node { + Atomic next; + }; + + MultiProducerSingleConsumerQueue() : head_{&stub_}, tail_(&stub_) {} + ~MultiProducerSingleConsumerQueue() { + GPR_ASSERT(head_.Load(MemoryOrder::RELAXED) == &stub_); + GPR_ASSERT(tail_ == &stub_); + } + + // Push a node + // Thread safe - can be called from multiple threads concurrently + // Returns true if this was possibly the first node (may return true + // sporadically, will not return false sporadically) + bool Push(Node* node); + // Pop a node (returns NULL if no node is ready - which doesn't indicate that + // the queue is empty!!) + // Thread compatible - can only be called from one thread at a time + Node* Pop(); + // Pop a node; sets *empty to true if the queue is empty, or false if it is + // not. + Node* PopAndCheckEnd(bool* empty); + + private: + // make sure head & tail don't share a cacheline + union { + char padding_[GPR_CACHELINE_SIZE]; + Atomic head_; + }; + Node* tail_; + Node stub_; +}; + +// An mpscq with a lock: it's safe to pop from multiple threads, but doing +// only one thread will succeed concurrently. +class LockedMultiProducerSingleConsumerQueue { + public: + typedef MultiProducerSingleConsumerQueue::Node Node; + + // Push a node + // Thread safe - can be called from multiple threads concurrently + // Returns true if this was possibly the first node (may return true + // sporadically, will not return false sporadically) + bool Push(Node* node); + + // Pop a node (returns NULL if no node is ready - which doesn't indicate that + // the queue is empty!!) + // Thread safe - can be called from multiple threads concurrently + Node* TryPop(); + + // Pop a node. Returns NULL only if the queue was empty at some point after + // calling this function + Node* Pop(); + + private: + MultiProducerSingleConsumerQueue queue_; + Mutex mu_; +}; + +} // namespace grpc_core + +#endif /* GRPC_CORE_LIB_GPRPP_MPSCQ_H */ diff --git a/src/core/lib/iomgr/call_combiner.cc b/src/core/lib/iomgr/call_combiner.cc index 6530d1c6ce6..bfbbb7f385d 100644 --- a/src/core/lib/iomgr/call_combiner.cc +++ b/src/core/lib/iomgr/call_combiner.cc @@ -48,7 +48,6 @@ gpr_atm EncodeCancelStateError(grpc_error* error) { CallCombiner::CallCombiner() { gpr_atm_no_barrier_store(&cancel_state_, 0); gpr_atm_no_barrier_store(&size_, 0); - gpr_mpscq_init(&queue_); #ifdef GRPC_TSAN_ENABLED GRPC_CLOSURE_INIT(&tsan_closure_, TsanClosure, this, grpc_schedule_on_exec_ctx); @@ -56,7 +55,6 @@ CallCombiner::CallCombiner() { } CallCombiner::~CallCombiner() { - gpr_mpscq_destroy(&queue_); GRPC_ERROR_UNREF(DecodeCancelStateError(cancel_state_)); } @@ -140,7 +138,8 @@ void CallCombiner::Start(grpc_closure* closure, grpc_error* error, } // Queue was not empty, so add closure to queue. closure->error_data.error = error; - gpr_mpscq_push(&queue_, reinterpret_cast(closure)); + queue_.Push( + reinterpret_cast(closure)); } } @@ -163,8 +162,8 @@ void CallCombiner::Stop(DEBUG_ARGS const char* reason) { gpr_log(GPR_INFO, " checking queue"); } bool empty; - grpc_closure* closure = reinterpret_cast( - gpr_mpscq_pop_and_check_end(&queue_, &empty)); + grpc_closure* closure = + reinterpret_cast(queue_.PopAndCheckEnd(&empty)); if (closure == nullptr) { // This can happen either due to a race condition within the mpscq // code or because of a race with Start(). diff --git a/src/core/lib/iomgr/call_combiner.h b/src/core/lib/iomgr/call_combiner.h index b56966f4196..c90e565860a 100644 --- a/src/core/lib/iomgr/call_combiner.h +++ b/src/core/lib/iomgr/call_combiner.h @@ -25,8 +25,8 @@ #include -#include "src/core/lib/gpr/mpscq.h" #include "src/core/lib/gprpp/inlined_vector.h" +#include "src/core/lib/gprpp/mpscq.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/closure.h" @@ -108,7 +108,7 @@ class CallCombiner { #endif gpr_atm size_ = 0; // size_t, num closures in queue or currently executing - gpr_mpscq queue_; + MultiProducerSingleConsumerQueue queue_; // Either 0 (if not cancelled and no cancellation closure set), // a grpc_closure* (if the lowest bit is 0), // or a grpc_error* (if the lowest bit is 1). diff --git a/src/core/lib/iomgr/closure.h b/src/core/lib/iomgr/closure.h index bde3437c02e..c7b2e8299b9 100644 --- a/src/core/lib/iomgr/closure.h +++ b/src/core/lib/iomgr/closure.h @@ -22,10 +22,13 @@ #include #include +#include + #include #include -#include -#include "src/core/lib/gpr/mpscq.h" + +#include "src/core/lib/gprpp/manual_constructor.h" +#include "src/core/lib/gprpp/mpscq.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/profiling/timers.h" @@ -69,7 +72,9 @@ struct grpc_closure { * space */ union { grpc_closure* next; - gpr_mpscq_node atm_next; + grpc_core::ManualConstructor< + grpc_core::MultiProducerSingleConsumerQueue::Node> + mpscq_node; uintptr_t scratch; } next_data; diff --git a/src/core/lib/iomgr/combiner.cc b/src/core/lib/iomgr/combiner.cc index 9a6290f29a8..31db1b70bab 100644 --- a/src/core/lib/iomgr/combiner.cc +++ b/src/core/lib/iomgr/combiner.cc @@ -28,6 +28,7 @@ #include #include "src/core/lib/debug/stats.h" +#include "src/core/lib/gprpp/mpscq.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/profiling/timers.h" @@ -45,10 +46,10 @@ grpc_core::DebugOnlyTraceFlag grpc_combiner_trace(false, "combiner"); #define STATE_ELEM_COUNT_LOW_BIT 2 struct grpc_combiner { - grpc_combiner* next_combiner_on_this_exec_ctx; + grpc_combiner* next_combiner_on_this_exec_ctx = nullptr; grpc_closure_scheduler scheduler; grpc_closure_scheduler finally_scheduler; - gpr_mpscq queue; + grpc_core::MultiProducerSingleConsumerQueue queue; // either: // a pointer to the initiating exec ctx if that is the only exec_ctx that has // ever queued to this combiner, or NULL. If this is non-null, it's not @@ -58,7 +59,7 @@ struct grpc_combiner { // lower bit - zero if orphaned (STATE_UNORPHANED) // other bits - number of items queued on the lock (STATE_ELEM_COUNT_LOW_BIT) gpr_atm state; - bool time_to_execute_final_list; + bool time_to_execute_final_list = false; grpc_closure_list final_list; grpc_closure offload; gpr_refcount refs; @@ -76,12 +77,11 @@ static const grpc_closure_scheduler_vtable finally_scheduler = { static void offload(void* arg, grpc_error* error); grpc_combiner* grpc_combiner_create(void) { - grpc_combiner* lock = static_cast(gpr_zalloc(sizeof(*lock))); + grpc_combiner* lock = grpc_core::New(); gpr_ref_init(&lock->refs, 1); lock->scheduler.vtable = &scheduler; lock->finally_scheduler.vtable = &finally_scheduler; gpr_atm_no_barrier_store(&lock->state, STATE_UNORPHANED); - gpr_mpscq_init(&lock->queue); grpc_closure_list_init(&lock->final_list); GRPC_CLOSURE_INIT( &lock->offload, offload, lock, @@ -93,8 +93,7 @@ grpc_combiner* grpc_combiner_create(void) { static void really_destroy(grpc_combiner* lock) { GRPC_COMBINER_TRACE(gpr_log(GPR_INFO, "C:%p really_destroy", lock)); GPR_ASSERT(gpr_atm_no_barrier_load(&lock->state) == 0); - gpr_mpscq_destroy(&lock->queue); - gpr_free(lock); + grpc_core::Delete(lock); } static void start_destroy(grpc_combiner* lock) { @@ -185,7 +184,7 @@ static void combiner_exec(grpc_closure* cl, grpc_error* error) { GPR_ASSERT(last & STATE_UNORPHANED); // ensure lock has not been destroyed assert(cl->cb); cl->error_data.error = error; - gpr_mpscq_push(&lock->queue, &cl->next_data.atm_next); + lock->queue.Push(cl->next_data.mpscq_node.get()); } static void move_next() { @@ -249,7 +248,7 @@ bool grpc_combiner_continue_exec_ctx() { // peek to see if something new has shown up, and execute that with // priority (gpr_atm_acq_load(&lock->state) >> 1) > 1) { - gpr_mpscq_node* n = gpr_mpscq_pop(&lock->queue); + grpc_core::MultiProducerSingleConsumerQueue::Node* n = lock->queue.Pop(); GRPC_COMBINER_TRACE( gpr_log(GPR_INFO, "C:%p maybe_finish_one n=%p", lock, n)); if (n == nullptr) { diff --git a/src/core/lib/iomgr/combiner.h b/src/core/lib/iomgr/combiner.h index b9274216993..8401dd97d2d 100644 --- a/src/core/lib/iomgr/combiner.h +++ b/src/core/lib/iomgr/combiner.h @@ -25,7 +25,6 @@ #include #include "src/core/lib/debug/trace.h" -#include "src/core/lib/gpr/mpscq.h" #include "src/core/lib/iomgr/exec_ctx.h" // Provides serialized access to some resource. diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index acdf42eae34..bb249331e12 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -210,14 +210,14 @@ struct cq_vtable { namespace { -/* Queue that holds the cq_completion_events. Internally uses gpr_mpscq queue - * (a lockfree multiproducer single consumer queue). It uses a queue_lock - * to support multiple consumers. +/* Queue that holds the cq_completion_events. Internally uses + * MultiProducerSingleConsumerQueue (a lockfree multiproducer single consumer + * queue). It uses a queue_lock to support multiple consumers. * Only used in completion queues whose completion_type is GRPC_CQ_NEXT */ class CqEventQueue { public: - CqEventQueue() { gpr_mpscq_init(&queue_); } - ~CqEventQueue() { gpr_mpscq_destroy(&queue_); } + CqEventQueue() = default; + ~CqEventQueue() = default; /* Note: The counter is not incremented/decremented atomically with push/pop. * The count is only eventually consistent */ @@ -232,7 +232,7 @@ class CqEventQueue { /* Spinlock to serialize consumers i.e pop() operations */ gpr_spinlock queue_lock_ = GPR_SPINLOCK_INITIALIZER; - gpr_mpscq queue_; + grpc_core::MultiProducerSingleConsumerQueue queue_; /* A lazy counter of number of items in the queue. This is NOT atomically incremented/decremented along with push/pop operations and hence is only @@ -462,7 +462,8 @@ int grpc_completion_queue_thread_local_cache_flush(grpc_completion_queue* cq, } bool CqEventQueue::Push(grpc_cq_completion* c) { - gpr_mpscq_push(&queue_, reinterpret_cast(c)); + queue_.Push( + reinterpret_cast(c)); return num_queue_items_.FetchAdd(1, grpc_core::MemoryOrder::RELAXED) == 0; } @@ -473,8 +474,7 @@ grpc_cq_completion* CqEventQueue::Pop() { GRPC_STATS_INC_CQ_EV_QUEUE_TRYLOCK_SUCCESSES(); bool is_empty = false; - c = reinterpret_cast( - gpr_mpscq_pop_and_check_end(&queue_, &is_empty)); + c = reinterpret_cast(queue_.PopAndCheckEnd(&is_empty)); gpr_spinlock_unlock(&queue_lock_); if (c == nullptr && !is_empty) { @@ -1007,8 +1007,9 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline, if (cqd->pending_events.Load(grpc_core::MemoryOrder::ACQUIRE) == 0) { /* Before returning, check if the queue has any items left over (since - gpr_mpscq_pop() can sometimes return NULL even if the queue is not - empty. If so, keep retrying but do not return GRPC_QUEUE_SHUTDOWN */ + MultiProducerSingleConsumerQueue::Pop() can sometimes return NULL + even if the queue is not empty. If so, keep retrying but do not + return GRPC_QUEUE_SHUTDOWN */ if (cqd->queue.num_items() > 0) { /* Go to the beginning of the loop. No point doing a poll because (cq->shutdown == true) is only possible when there is no pending diff --git a/src/core/lib/surface/completion_queue.h b/src/core/lib/surface/completion_queue.h index 3ba9fbb8765..dc13bc50f91 100644 --- a/src/core/lib/surface/completion_queue.h +++ b/src/core/lib/surface/completion_queue.h @@ -24,8 +24,10 @@ #include #include + #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/abstract.h" +#include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/pollset.h" /* These trace flags default to 1. The corresponding lines are only traced @@ -36,7 +38,8 @@ extern grpc_core::DebugOnlyTraceFlag grpc_trace_pending_tags; extern grpc_core::DebugOnlyTraceFlag grpc_trace_cq_refcount; typedef struct grpc_cq_completion { - gpr_mpscq_node node; + grpc_core::ManualConstructor + node; /** user supplied tag */ void* tag; diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 2cc7e88cab4..784ffe2b79a 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -34,9 +34,9 @@ #include "src/core/lib/channel/channelz.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/debug/stats.h" -#include "src/core/lib/gpr/mpscq.h" #include "src/core/lib/gpr/spinlock.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/mpscq.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/slice/slice_internal.h" @@ -50,6 +50,8 @@ grpc_core::TraceFlag grpc_server_channel_trace(false, "server_channel"); +using grpc_core::LockedMultiProducerSingleConsumerQueue; + static void server_on_recv_initial_metadata(void* ptr, grpc_error* error); static void server_recv_trailing_metadata_ready(void* user_data, grpc_error* error); @@ -70,7 +72,9 @@ enum requested_call_type { BATCH_CALL, REGISTERED_CALL }; struct registered_method; struct requested_call { - gpr_mpscq_node request_link; /* must be first */ + grpc_core::ManualConstructor< + grpc_core::MultiProducerSingleConsumerQueue::Node> + mpscq_node; requested_call_type type; size_t cq_idx; void* tag; @@ -198,7 +202,7 @@ struct request_matcher { grpc_server* server; call_data* pending_head; call_data* pending_tail; - gpr_locked_mpscq* requests_per_cq; + LockedMultiProducerSingleConsumerQueue* requests_per_cq; }; struct registered_method { @@ -350,17 +354,17 @@ static void channel_broadcaster_shutdown(channel_broadcaster* cb, static void request_matcher_init(request_matcher* rm, grpc_server* server) { rm->server = server; rm->pending_head = rm->pending_tail = nullptr; - rm->requests_per_cq = static_cast( + rm->requests_per_cq = static_cast( gpr_malloc(sizeof(*rm->requests_per_cq) * server->cq_count)); for (size_t i = 0; i < server->cq_count; i++) { - gpr_locked_mpscq_init(&rm->requests_per_cq[i]); + new (&rm->requests_per_cq[i]) LockedMultiProducerSingleConsumerQueue(); } } static void request_matcher_destroy(request_matcher* rm) { for (size_t i = 0; i < rm->server->cq_count; i++) { - GPR_ASSERT(gpr_locked_mpscq_pop(&rm->requests_per_cq[i]) == nullptr); - gpr_locked_mpscq_destroy(&rm->requests_per_cq[i]); + GPR_ASSERT(rm->requests_per_cq[i].Pop() == nullptr); + rm->requests_per_cq[i].~LockedMultiProducerSingleConsumerQueue(); } gpr_free(rm->requests_per_cq); } @@ -389,7 +393,7 @@ static void request_matcher_kill_requests(grpc_server* server, requested_call* rc; for (size_t i = 0; i < server->cq_count; i++) { while ((rc = reinterpret_cast( - gpr_locked_mpscq_pop(&rm->requests_per_cq[i]))) != nullptr) { + rm->requests_per_cq[i].Pop())) != nullptr) { fail_call(server, i, rc, GRPC_ERROR_REF(error)); } } @@ -534,8 +538,8 @@ static void publish_new_rpc(void* arg, grpc_error* error) { for (size_t i = 0; i < server->cq_count; i++) { size_t cq_idx = (chand->cq_idx + i) % server->cq_count; - requested_call* rc = reinterpret_cast( - gpr_locked_mpscq_try_pop(&rm->requests_per_cq[cq_idx])); + requested_call* rc = + reinterpret_cast(rm->requests_per_cq[cq_idx].TryPop()); if (rc == nullptr) { continue; } else { @@ -556,8 +560,8 @@ static void publish_new_rpc(void* arg, grpc_error* error) { // added to the pending list. for (size_t i = 0; i < server->cq_count; i++) { size_t cq_idx = (chand->cq_idx + i) % server->cq_count; - requested_call* rc = reinterpret_cast( - gpr_locked_mpscq_pop(&rm->requests_per_cq[cq_idx])); + requested_call* rc = + reinterpret_cast(rm->requests_per_cq[cq_idx].Pop()); if (rc == nullptr) { continue; } else { @@ -1430,13 +1434,12 @@ static grpc_call_error queue_call_request(grpc_server* server, size_t cq_idx, rm = &rc->data.registered.method->matcher; break; } - if (gpr_locked_mpscq_push(&rm->requests_per_cq[cq_idx], &rc->request_link)) { + if (rm->requests_per_cq[cq_idx].Push(rc->mpscq_node.get())) { /* this was the first queued request: we need to lock and start matching calls */ gpr_mu_lock(&server->mu_call); while ((calld = rm->pending_head) != nullptr) { - rc = reinterpret_cast( - gpr_locked_mpscq_pop(&rm->requests_per_cq[cq_idx])); + rc = reinterpret_cast(rm->requests_per_cq[cq_idx].Pop()); if (rc == nullptr) break; rm->pending_head = calld->pending_next; gpr_mu_unlock(&server->mu_call); diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 6eb8bc8c9c1..30caf49806c 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -32,7 +32,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/gpr/log_linux.cc', 'src/core/lib/gpr/log_posix.cc', 'src/core/lib/gpr/log_windows.cc', - 'src/core/lib/gpr/mpscq.cc', 'src/core/lib/gpr/murmur_hash.cc', 'src/core/lib/gpr/string.cc', 'src/core/lib/gpr/string_posix.cc', @@ -54,6 +53,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/gprpp/fork.cc', 'src/core/lib/gprpp/global_config_env.cc', 'src/core/lib/gprpp/host_port.cc', + 'src/core/lib/gprpp/mpscq.cc', 'src/core/lib/gprpp/thd_posix.cc', 'src/core/lib/gprpp/thd_windows.cc', 'src/core/lib/profiling/basic_timers.cc', diff --git a/test/core/gpr/BUILD b/test/core/gpr/BUILD index c2b2576ff03..c4ee5e977ad 100644 --- a/test/core/gpr/BUILD +++ b/test/core/gpr/BUILD @@ -68,17 +68,6 @@ grpc_cc_test( ], ) -grpc_cc_test( - name = "mpscq_test", - srcs = ["mpscq_test.cc"], - exec_compatible_with = ["//third_party/toolchains/machine_size:large"], - language = "C++", - deps = [ - "//:gpr", - "//test/core/util:grpc_test_util", - ], -) - grpc_cc_test( name = "murmur_hash_test", srcs = ["murmur_hash_test.cc"], diff --git a/test/core/gprpp/BUILD b/test/core/gprpp/BUILD index 5cee96a3ad2..142fcbb571b 100644 --- a/test/core/gprpp/BUILD +++ b/test/core/gprpp/BUILD @@ -113,6 +113,17 @@ grpc_cc_test( ], ) +grpc_cc_test( + name = "mpscq_test", + srcs = ["mpscq_test.cc"], + exec_compatible_with = ["//third_party/toolchains/machine_size:large"], + language = "C++", + deps = [ + "//:gpr", + "//test/core/util:grpc_test_util", + ], +) + grpc_cc_test( name = "optional_test", srcs = ["optional_test.cc"], diff --git a/test/core/gpr/mpscq_test.cc b/test/core/gprpp/mpscq_test.cc similarity index 85% rename from test/core/gpr/mpscq_test.cc rename to test/core/gprpp/mpscq_test.cc index 744cea934c5..a3b6bb59e4b 100644 --- a/test/core/gpr/mpscq_test.cc +++ b/test/core/gprpp/mpscq_test.cc @@ -16,7 +16,7 @@ * */ -#include "src/core/lib/gpr/mpscq.h" +#include "src/core/lib/gprpp/mpscq.h" #include #include @@ -29,14 +29,16 @@ #include "src/core/lib/gprpp/thd.h" #include "test/core/util/test_config.h" +using grpc_core::MultiProducerSingleConsumerQueue; + typedef struct test_node { - gpr_mpscq_node node; + MultiProducerSingleConsumerQueue::Node node; size_t i; size_t* ctr; } test_node; static test_node* new_node(size_t i, size_t* ctr) { - test_node* n = static_cast(gpr_malloc(sizeof(test_node))); + test_node* n = grpc_core::New(); n->i = i; n->ctr = ctr; return n; @@ -44,13 +46,12 @@ static test_node* new_node(size_t i, size_t* ctr) { static void test_serial(void) { gpr_log(GPR_DEBUG, "test_serial"); - gpr_mpscq q; - gpr_mpscq_init(&q); + MultiProducerSingleConsumerQueue q; for (size_t i = 0; i < 10000000; i++) { - gpr_mpscq_push(&q, &new_node(i, nullptr)->node); + q.Push(&new_node(i, nullptr)->node); } for (size_t i = 0; i < 10000000; i++) { - test_node* n = reinterpret_cast(gpr_mpscq_pop(&q)); + test_node* n = reinterpret_cast(q.Pop()); GPR_ASSERT(n); GPR_ASSERT(n->i == i); gpr_free(n); @@ -59,7 +60,7 @@ static void test_serial(void) { typedef struct { size_t ctr; - gpr_mpscq* q; + MultiProducerSingleConsumerQueue* q; gpr_event* start; } thd_args; @@ -69,7 +70,7 @@ static void test_thread(void* args) { thd_args* a = static_cast(args); gpr_event_wait(a->start, gpr_inf_future(GPR_CLOCK_REALTIME)); for (size_t i = 1; i <= THREAD_ITERATIONS; i++) { - gpr_mpscq_push(a->q, &new_node(i, &a->ctr)->node); + a->q->Push(&new_node(i, &a->ctr)->node); } } @@ -79,8 +80,7 @@ static void test_mt(void) { gpr_event_init(&start); grpc_core::Thread thds[100]; thd_args ta[GPR_ARRAY_SIZE(thds)]; - gpr_mpscq q; - gpr_mpscq_init(&q); + MultiProducerSingleConsumerQueue q; for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) { ta[i].ctr = 0; ta[i].q = &q; @@ -92,8 +92,8 @@ static void test_mt(void) { size_t spins = 0; gpr_event_set(&start, (void*)1); while (num_done != GPR_ARRAY_SIZE(thds)) { - gpr_mpscq_node* n; - while ((n = gpr_mpscq_pop(&q)) == nullptr) { + MultiProducerSingleConsumerQueue::Node* n; + while ((n = q.Pop()) == nullptr) { spins++; } test_node* tn = reinterpret_cast(n); @@ -106,7 +106,6 @@ static void test_mt(void) { for (auto& th : thds) { th.Join(); } - gpr_mpscq_destroy(&q); } typedef struct { @@ -115,7 +114,7 @@ typedef struct { gpr_mu mu; size_t num_done; size_t spins; - gpr_mpscq* q; + MultiProducerSingleConsumerQueue* q; gpr_event* start; } pull_args; @@ -129,8 +128,8 @@ static void pull_thread(void* arg) { gpr_mu_unlock(&pa->mu); return; } - gpr_mpscq_node* n; - while ((n = gpr_mpscq_pop(pa->q)) == nullptr) { + MultiProducerSingleConsumerQueue::Node* n; + while ((n = pa->q->Pop()) == nullptr) { pa->spins++; } test_node* tn = reinterpret_cast(n); @@ -149,8 +148,7 @@ static void test_mt_multipop(void) { grpc_core::Thread thds[50]; grpc_core::Thread pull_thds[50]; thd_args ta[GPR_ARRAY_SIZE(thds)]; - gpr_mpscq q; - gpr_mpscq_init(&q); + MultiProducerSingleConsumerQueue q; for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) { ta[i].ctr = 0; ta[i].q = &q; @@ -179,7 +177,6 @@ static void test_mt_multipop(void) { th.Join(); } gpr_mu_destroy(&pa.mu); - gpr_mpscq_destroy(&q); } int main(int argc, char** argv) { diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 3b7af742baa..6a37a440479 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1089,7 +1089,6 @@ src/core/lib/debug/trace.h \ src/core/lib/gpr/alloc.h \ src/core/lib/gpr/arena.h \ src/core/lib/gpr/env.h \ -src/core/lib/gpr/mpscq.h \ src/core/lib/gpr/murmur_hash.h \ src/core/lib/gpr/spinlock.h \ src/core/lib/gpr/string.h \ @@ -1115,6 +1114,7 @@ src/core/lib/gprpp/inlined_vector.h \ src/core/lib/gprpp/manual_constructor.h \ src/core/lib/gprpp/map.h \ src/core/lib/gprpp/memory.h \ +src/core/lib/gprpp/mpscq.h \ src/core/lib/gprpp/optional.h \ src/core/lib/gprpp/orphanable.h \ src/core/lib/gprpp/pair.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index ed6f88dde3c..0878bb4de49 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1203,8 +1203,6 @@ src/core/lib/gpr/log_android.cc \ src/core/lib/gpr/log_linux.cc \ src/core/lib/gpr/log_posix.cc \ src/core/lib/gpr/log_windows.cc \ -src/core/lib/gpr/mpscq.cc \ -src/core/lib/gpr/mpscq.h \ src/core/lib/gpr/murmur_hash.cc \ src/core/lib/gpr/murmur_hash.h \ src/core/lib/gpr/spinlock.h \ @@ -1252,6 +1250,8 @@ src/core/lib/gprpp/inlined_vector.h \ src/core/lib/gprpp/manual_constructor.h \ src/core/lib/gprpp/map.h \ src/core/lib/gprpp/memory.h \ +src/core/lib/gprpp/mpscq.cc \ +src/core/lib/gprpp/mpscq.h \ src/core/lib/gprpp/optional.h \ src/core/lib/gprpp/orphanable.h \ src/core/lib/gprpp/pair.h \ diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 8f0b447abac..28140a8e71a 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -955,30 +955,6 @@ ], "uses_polling": false }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 30, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": false, - "language": "c", - "name": "gpr_mpscq_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "uses_polling": false - }, { "args": [], "benchmark": false, @@ -4739,6 +4715,30 @@ ], "uses_polling": false }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 30, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": false, + "language": "c++", + "name": "gprpp_mpscq_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": false + }, { "args": [], "benchmark": false, From 7235091dc26918f1b112d706786ca62b6ca17b45 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 5 Sep 2019 10:41:32 -0700 Subject: [PATCH 1471/1555] Don't start AuthMetadataProcessor threadpool for non-blocking processor --- src/cpp/server/secure_server_credentials.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cpp/server/secure_server_credentials.h b/src/cpp/server/secure_server_credentials.h index 24b133cf7f0..cc5ed1e1f92 100644 --- a/src/cpp/server/secure_server_credentials.h +++ b/src/cpp/server/secure_server_credentials.h @@ -46,7 +46,11 @@ class AuthMetadataProcessorAyncWrapper final { AuthMetadataProcessorAyncWrapper( const std::shared_ptr& processor) - : thread_pool_(CreateDefaultThreadPool()), processor_(processor) {} + : processor_(processor) { + if (processor && processor->IsBlocking()) { + thread_pool_.reset(CreateDefaultThreadPool()); + } + } private: void InvokeProcessor(grpc_auth_context* context, const grpc_metadata* md, From 63cd77c835de2d0ea56d7a3535eb3dc2a975071d Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 5 Sep 2019 11:01:46 -0700 Subject: [PATCH 1472/1555] Fix transport manager shutdown queuing --- src/objective-c/GRPCClient/private/GRPCTransport+Private.m | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m index 5e9c2b52ab4..1ce9e8940ef 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m @@ -46,11 +46,10 @@ return self; } +// Must be called on _dispatchQueue or queues targeted by _dispatchQueue - (void)shutDown { - dispatch_async(_dispatchQueue, ^{ - self->_transport = nil; - self->_previousInterceptor = nil; - }); + _transport = nil; + _previousInterceptor = nil; } - (dispatch_queue_t)dispatchQueue { From ecf7274aaae21a2828b393c263520901a5fbad53 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Thu, 5 Sep 2019 11:41:36 -0700 Subject: [PATCH 1473/1555] Add docstring to py2and3_test --- bazel/python_rules.bzl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index e7e9e597b05..373895fc94d 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -183,6 +183,12 @@ def py_grpc_library( def py2and3_test(name, py_test = native.py_test, **kwargs): + """Runs a Python test under both Python 2 and Python 3. + + Args: + name: The name of the test. + py_test: The rule to use for each test. + """ if "python_version" in kwargs: fail("Cannot specify 'python_version' in py2and3_test.") From 04dd147b411dfbb203df73d8b2b39f82338691e9 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 5 Sep 2019 12:24:26 -0700 Subject: [PATCH 1474/1555] Add Python 3.6 to default gRPC Python test environments --- tools/run_tests/run_tests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 1ff37ca85af..a90f6e3245e 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -846,6 +846,7 @@ class PythonLanguage(object): else: return ( python27_config, + python36_config, python37_config, ) elif args.compiler == 'python2.7': From c11539f79e75e6f6dd4fb17debe4e4f09755f07e Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Thu, 5 Sep 2019 12:32:58 -0700 Subject: [PATCH 1475/1555] Document kwargs --- bazel/python_rules.bzl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index 373895fc94d..356c62d673a 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -188,6 +188,8 @@ def py2and3_test(name, Args: name: The name of the test. py_test: The rule to use for each test. + **kwargs: Keyword arguments passed directly to the underlying py_test + rule. """ if "python_version" in kwargs: fail("Cannot specify 'python_version' in py2and3_test.") From 9f02fc7f91aa40e364835b4cf9fe9e78429d9ffb Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Wed, 21 Aug 2019 14:54:56 -0700 Subject: [PATCH 1476/1555] Enable end2end C++ tests on iOS. Some e2e tests were disabled on iOS because they hit the Apple CFStream bug. This commit enables e2e tests and works around the Apple bug by disabling CFStream. --- test/cpp/common/time_jump_test.cc | 2 +- test/cpp/end2end/BUILD | 8 +- test/cpp/end2end/channelz_service_test.cc | 8 +- .../end2end/client_callback_end2end_test.cc | 6 ++ test/cpp/end2end/client_lb_end2end_test.cc | 5 ++ test/cpp/end2end/end2end_test.cc | 14 +++- test/cpp/end2end/grpclb_end2end_test.cc | 5 ++ test/cpp/end2end/hybrid_end2end_test.cc | 8 ++ test/cpp/end2end/port_sharing_end2end_test.cc | 7 ++ test/cpp/end2end/thread_stress_test.cc | 8 +- test/cpp/end2end/xds_end2end_test.cc | 4 + .../UnitTesting/GTMGoogleTestRunner.mm | 83 +++++++++---------- 12 files changed, 100 insertions(+), 58 deletions(-) diff --git a/test/cpp/common/time_jump_test.cc b/test/cpp/common/time_jump_test.cc index ea6711dfce3..a997982d9fa 100644 --- a/test/cpp/common/time_jump_test.cc +++ b/test/cpp/common/time_jump_test.cc @@ -121,7 +121,7 @@ TEST_P(TimeJumpTest, TimedWait) { GPR_ASSERT(1 == gpr_time_similar(gpr_time_sub(after, before), gpr_time_from_millis(kWaitTimeMs, GPR_TIMESPAN), - gpr_time_from_millis(10, GPR_TIMESPAN))); + gpr_time_from_millis(50, GPR_TIMESPAN))); thd.join(); } diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD index 1b487602a7a..9153439341f 100644 --- a/test/cpp/end2end/BUILD +++ b/test/cpp/end2end/BUILD @@ -165,7 +165,6 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], - tags = ["no_test_ios"], ) grpc_cc_test( @@ -224,6 +223,7 @@ grpc_cc_library( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], + alwayslink = 1, ) grpc_cc_test( @@ -272,6 +272,7 @@ grpc_cc_test( # system uses it to specialize targets "//:grpc++", ], + tags = ["no_test_ios"], ) grpc_cc_test( @@ -441,7 +442,6 @@ grpc_cc_test( "//test/core/util:test_lb_policies", "//test/cpp/util:test_util", ], - tags = ["no_test_ios"], ) grpc_cc_test( @@ -482,7 +482,6 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], - tags = ["no_test_ios"], ) grpc_cc_test( @@ -505,7 +504,6 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], - tags = ["no_test_ios"], ) grpc_cc_test( @@ -698,7 +696,6 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], - tags = ["no_test_ios"], ) grpc_cc_test( @@ -756,5 +753,4 @@ grpc_cc_test( "//test/core/util:grpc_test_util", "//test/cpp/util:test_util", ], - tags = ["no_test_ios"], ) diff --git a/test/cpp/end2end/channelz_service_test.cc b/test/cpp/end2end/channelz_service_test.cc index 1ed2d8c65f2..325a6ef7094 100644 --- a/test/cpp/end2end/channelz_service_test.cc +++ b/test/cpp/end2end/channelz_service_test.cc @@ -29,6 +29,7 @@ #include #include +#include "src/core/lib/gpr/env.h" #include "src/proto/grpc/channelz/channelz.grpc.pb.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "test/core/util/port.h" @@ -104,7 +105,12 @@ class Proxy : public ::grpc::testing::EchoTestService::Service { class ChannelzServerTest : public ::testing::Test { public: ChannelzServerTest() {} - + static void SetUpTestCase() { +#if TARGET_OS_IPHONE + // Workaround Apple CFStream bug + gpr_setenv("grpc_cfstream", "0"); +#endif + } void SetUp() override { // ensure channel server is brought up on all severs we build. ::grpc::channelz::experimental::InitChannelzService(); diff --git a/test/cpp/end2end/client_callback_end2end_test.cc b/test/cpp/end2end/client_callback_end2end_test.cc index a54158ac1d1..c4375b884ee 100644 --- a/test/cpp/end2end/client_callback_end2end_test.cc +++ b/test/cpp/end2end/client_callback_end2end_test.cc @@ -32,6 +32,7 @@ #include #include +#include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "test/core/util/port.h" @@ -1336,6 +1337,11 @@ TEST_P(ClientCallbackEnd2endTest, } std::vector CreateTestScenarios(bool test_insecure) { +#if TARGET_OS_IPHONE + // Workaround Apple CFStream bug + gpr_setenv("grpc_cfstream", "0"); +#endif + std::vector scenarios; std::vector credentials_types{ GetCredentialsProvider()->GetSecureCredentialsTypeList()}; diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index 1a96aafd7a1..e0b4b074ff2 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -45,6 +45,7 @@ #include "src/core/ext/filters/client_channel/service_config.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/tcp_client.h" @@ -220,6 +221,10 @@ class ClientLbEnd2endTest : public ::testing::Test { // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); +#if TARGET_OS_IPHONE + // Workaround Apple CFStream bug + gpr_setenv("grpc_cfstream", "0"); +#endif } void SetUp() override { grpc_init(); } diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index a8592fd97c2..a5a9675d14d 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -36,6 +36,7 @@ #include #include "src/core/ext/filters/client_channel/backup_poller.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" @@ -254,6 +255,8 @@ void TestScenario::Log() const { class End2endTest : public ::testing::TestWithParam { protected: + static void SetUpTestCase() { grpc_init(); } + static void TearDownTestCase() { grpc_shutdown(); } End2endTest() : is_server_started_(false), kMaxMessageSize_(8192), @@ -2106,6 +2109,13 @@ std::vector CreateTestScenarios(bool use_proxy, bool test_callback_server) { std::vector scenarios; std::vector credentials_types; + + GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 200); +#if TARGET_OS_IPHONE + // Workaround Apple CFStream bug + gpr_setenv("grpc_cfstream", "0"); +#endif + if (test_secure) { credentials_types = GetCredentialsProvider()->GetSecureCredentialsTypeList(); @@ -2173,12 +2183,8 @@ INSTANTIATE_TEST_CASE_P( } // namespace grpc int main(int argc, char** argv) { - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 200); grpc::testing::TestEnvironment env(argc, argv); - // The grpc_init is to cover the MAYBE_SKIP_TEST. - grpc_init(); ::testing::InitGoogleTest(&argc, argv); int ret = RUN_ALL_TESTS(); - grpc_shutdown(); return ret; } diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc index d71dafc855f..8f0b4cef2ee 100644 --- a/test/cpp/end2end/grpclb_end2end_test.cc +++ b/test/cpp/end2end/grpclb_end2end_test.cc @@ -39,6 +39,7 @@ #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/ext/filters/client_channel/service_config.h" +#include "src/core/lib/gpr/env.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" @@ -378,6 +379,10 @@ class GrpclbEnd2endTest : public ::testing::Test { // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); +#if TARGET_OS_IPHONE + // Workaround Apple CFStream bug + gpr_setenv("grpc_cfstream", "0"); +#endif grpc_init(); } diff --git a/test/cpp/end2end/hybrid_end2end_test.cc b/test/cpp/end2end/hybrid_end2end_test.cc index 75001f0ab27..58ee1e3abb3 100644 --- a/test/cpp/end2end/hybrid_end2end_test.cc +++ b/test/cpp/end2end/hybrid_end2end_test.cc @@ -28,6 +28,7 @@ #include #include +#include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" @@ -229,6 +230,13 @@ class HybridEnd2endTest : public ::testing::TestWithParam { protected: HybridEnd2endTest() {} + static void SetUpTestCase() { +#if TARGET_OS_IPHONE + // Workaround Apple CFStream bug + gpr_setenv("grpc_cfstream", "0"); +#endif + } + void SetUp() override { inproc_ = (::testing::UnitTest::GetInstance() ->current_test_info() diff --git a/test/cpp/end2end/port_sharing_end2end_test.cc b/test/cpp/end2end/port_sharing_end2end_test.cc index 4f30290d815..2c094c523c0 100644 --- a/test/cpp/end2end/port_sharing_end2end_test.cc +++ b/test/cpp/end2end/port_sharing_end2end_test.cc @@ -33,6 +33,7 @@ #include #include +#include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/pollset.h" @@ -310,6 +311,12 @@ static void SendRpc(EchoTestService::Stub* stub, int num_rpcs) { std::vector CreateTestScenarios() { std::vector scenarios; std::vector credentials_types; + +#if TARGET_OS_IPHONE + // Workaround Apple CFStream bug + gpr_setenv("grpc_cfstream", "0"); +#endif + credentials_types = GetCredentialsProvider()->GetSecureCredentialsTypeList(); // Only allow insecure credentials type when it is registered with the // provider. User may create providers that do not have insecure. diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc index eb8e7958b4b..fee20c82679 100644 --- a/test/cpp/end2end/thread_stress_test.cc +++ b/test/cpp/end2end/thread_stress_test.cc @@ -31,6 +31,7 @@ #include #include +#include "src/core/lib/gpr/env.h" #include "src/core/lib/surface/api_trace.h" #include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" @@ -66,7 +67,12 @@ class TestServiceImpl : public ::grpc::testing::EchoTestService::Service { template class CommonStressTest { public: - CommonStressTest() : kMaxMessageSize_(8192) {} + CommonStressTest() : kMaxMessageSize_(8192) { +#if TARGET_OS_IPHONE + // Workaround Apple CFStream bug + gpr_setenv("grpc_cfstream", "0"); +#endif + } virtual ~CommonStressTest() {} virtual void SetUp() = 0; virtual void TearDown() = 0; diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index 17436bbc13a..2d506c56c87 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -521,6 +521,10 @@ class XdsEnd2endTest : public ::testing::Test { // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); +#if TARGET_OS_IPHONE + // Workaround Apple CFStream bug + gpr_setenv("grpc_cfstream", "0"); +#endif grpc_init(); } diff --git a/third_party/objective_c/google_toolbox_for_mac/UnitTesting/GTMGoogleTestRunner.mm b/third_party/objective_c/google_toolbox_for_mac/UnitTesting/GTMGoogleTestRunner.mm index 3e8e9245fd4..20b2855cfb1 100644 --- a/third_party/objective_c/google_toolbox_for_mac/UnitTesting/GTMGoogleTestRunner.mm +++ b/third_party/objective_c/google_toolbox_for_mac/UnitTesting/GTMGoogleTestRunner.mm @@ -20,14 +20,14 @@ #error "This file requires ARC support." #endif -// This is a SenTest/XCTest based unit test that will run all of the GoogleTest +// This is a XCTest based unit test that will run all of the GoogleTest // https://code.google.com/p/googletest/ -// based tests in the project, and will report results correctly via SenTest so +// based tests in the project, and will report results correctly via XCTest so // that Xcode can pick them up in it's UI. -// SenTest dynamically creates one SenTest per GoogleTest. +// XCTest dynamically creates one XCTest per GoogleTest. // GoogleTest is set up using a custom event listener (GoogleTestPrinter) -// which knows how to log GoogleTest test results in a manner that SenTest (and +// which knows how to log GoogleTest test results in a manner that XCTest (and // the Xcode IDE) understand. // Note that this does not able you to control individual tests from the Xcode @@ -39,33 +39,30 @@ // project because of it's dependency on https://code.google.com/p/googletest/ // To use this: -// - If you are using XCTest (vs SenTest) make sure to define GTM_USING_XCTEST -// in the settings for your testing bundle. // - Add GTMGoogleTestRunner to your test bundle sources. // - Add gtest-all.cc from gtest to your test bundle sources. // - Write some C++ tests and add them to your test bundle sources. // - Build and run tests. Your C++ tests should just execute. -// If you are using this with XCTest (as opposed to SenTestingKit) -// make sure to define GTM_USING_XCTEST. -#ifndef GTM_USING_XCTEST -#define GTM_USING_XCTEST 0 -#endif +// NOTE: +// A key difference between how GTMGoogleTestRunner runs tests versus how a +// "standard" unit test package runs tests is that SetUpTestSuite/SetupTestCase +// and TeardownTestSuite/TeardownTestCase are going to be called before/after +// *every* individual test. Unfortunately this is due to restrictions in the +// design of GoogleTest in that the only way to run individual tests is to +// use a filter to focus on a specific test, and then "run" all the tests +// multiple times. +// If you have state that you need maintained across tests (not normally a +// great idea anyhow), using SetUp*, Teardown* is not going to work for you. -#if GTM_USING_XCTEST #import -#define SenTestCase XCTestCase -#define SenTestSuite XCTestSuite -#else // GTM_USING_XCTEST -#import -#endif // GTM_USING_XCTEST - #import #include using ::testing::EmptyTestEventListener; using ::testing::TestCase; +using ::testing::TestEventListener; using ::testing::TestEventListeners; using ::testing::TestInfo; using ::testing::TestPartResult; @@ -75,18 +72,19 @@ using ::testing::UnitTest; namespace { // A gtest printer that takes care of reporting gtest results via the -// SenTest interface. Note that a test suite in SenTest == a test case in gtest -// and a test case in SenTest == a test in gtest. +// XCTest interface. Note that a test suite in XCTest == a test case in gtest +// and a test case in XCTest == a test in gtest. // This will handle fatal and non-fatal gtests properly. class GoogleTestPrinter : public EmptyTestEventListener { public: - GoogleTestPrinter(SenTestCase *test_case) : test_case_(test_case) {} + GoogleTestPrinter(XCTestCase *test_case) : test_case_(test_case) {} virtual ~GoogleTestPrinter() {} virtual void OnTestPartResult(const TestPartResult &test_part_result) { if (!test_part_result.passed()) { - NSString *file = @(test_part_result.file_name()); + const char *file_name = test_part_result.file_name(); + NSString *file = @(file_name ? file_name : ""); int line = test_part_result.line_number(); NSString *summary = @(test_part_result.summary()); @@ -94,26 +92,16 @@ class GoogleTestPrinter : public EmptyTestEventListener { // the Xcode UI, so we clean them up. NSString *oneLineSummary = [summary stringByReplacingOccurrencesOfString:@"\n" withString:@" "]; -#if GTM_USING_XCTEST BOOL expected = test_part_result.nonfatally_failed(); [test_case_ recordFailureWithDescription:oneLineSummary inFile:file atLine:line expected:expected]; -#else // GTM_USING_XCTEST - NSException *exception = - [NSException failureInFile:file - atLine:line - withDescription:@"%@", oneLineSummary]; - - // failWithException: will log appropriately. - [test_case_ failWithException:exception]; -#endif // GTM_USING_XCTEST } } private: - SenTestCase *test_case_; + XCTestCase *test_case_; }; NSString *SelectorNameFromGTestName(NSString *testName) { @@ -127,7 +115,7 @@ NSString *SelectorNameFromGTestName(NSString *testName) { // GTMGoogleTestRunner is a GTMTestCase that makes a sub test suite populated // with all of the GoogleTest unit tests. -@interface GTMGoogleTestRunner : SenTestCase { +@interface GTMGoogleTestRunner : XCTestCase { NSString *testName_; } @@ -154,8 +142,7 @@ NSString *SelectorNameFromGTestName(NSString *testName) { + (id)defaultTestSuite { [GTMGoogleTestRunner initGoogleTest]; - SenTestSuite *result = - [[SenTestSuite alloc] initWithName:NSStringFromClass(self)]; + XCTestSuite *result = [[XCTestSuite alloc] initWithName:NSStringFromClass(self)]; UnitTest *test = UnitTest::GetInstance(); // Walk the GoogleTest tests, adding sub tests and sub suites as appropriate. @@ -163,15 +150,14 @@ NSString *SelectorNameFromGTestName(NSString *testName) { for (int i = 0; i < total_test_case_count; ++i) { const TestCase *test_case = test->GetTestCase(i); int total_test_count = test_case->total_test_count(); - SenTestSuite *subSuite = - [[SenTestSuite alloc] initWithName:@(test_case->name())]; + XCTestSuite *subSuite = [[XCTestSuite alloc] initWithName:@(test_case->name())]; [result addTest:subSuite]; for (int j = 0; j < total_test_count; ++j) { const TestInfo *test_info = test_case->GetTestInfo(j); NSString *testName = [NSString stringWithFormat:@"%s.%s", test_case->name(), test_info->name()]; - SenTestCase *senTest = [[self alloc] initWithName:testName]; - [subSuite addTest:senTest]; + XCTestCase *xcTest = [[self alloc] initWithName:testName]; + [subSuite addTest:xcTest]; } } return result; @@ -201,7 +187,7 @@ NSString *SelectorNameFromGTestName(NSString *testName) { } - (NSString *)name { - // A SenTest name must be "-[foo bar]" or it won't be parsed properly. + // An XCTest name must be "-[foo bar]" or it won't be parsed properly. NSRange dot = [testName_ rangeOfString:@"."]; return [NSString stringWithFormat:@"-[%@ %@]", [testName_ substringToIndex:dot.location], @@ -214,11 +200,15 @@ NSString *SelectorNameFromGTestName(NSString *testName) { // Gets hold of the event listener list. TestEventListeners& listeners = UnitTest::GetInstance()->listeners(); - // Adds a listener to the end. Google Test takes the ownership. - listeners.Append(new GoogleTestPrinter(self)); + // Adds a listener to the end. + GoogleTestPrinter printer = GoogleTestPrinter(self); + listeners.Append(&printer); - // Remove the default printer. - delete listeners.Release(listeners.default_result_printer()); + // Remove the default printer if it exists. + TestEventListener *defaultListener = listeners.default_result_printer(); + if (defaultListener) { + delete listeners.Release(defaultListener); + } // Since there is no way of running a single GoogleTest directly, we use the // filter mechanism in GoogleTest to simulate it for us. @@ -228,6 +218,9 @@ NSString *SelectorNameFromGTestName(NSString *testName) { // the output appropriately, and there is no reason to mark this test as // "failed" if RUN_ALL_TESTS returns non-zero. (void)RUN_ALL_TESTS(); + + // Remove the listener that we added. + listeners.Release(&printer); } @end From e6e5d2d5318ddbc218e2a02896f6be4c931e7329 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Thu, 5 Sep 2019 14:18:35 -0700 Subject: [PATCH 1477/1555] Use libc++ for clang sanity test --- Makefile | 24 ++++++++++++------------ build.yaml | 35 ++++++++++++++++++----------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index d48b36a531f..1e8acd7e99e 100644 --- a/Makefile +++ b/Makefile @@ -86,8 +86,8 @@ CC_asan-trace-cmp = clang CXX_asan-trace-cmp = clang++ LD_asan-trace-cmp = clang++ LDXX_asan-trace-cmp = clang++ -CPPFLAGS_asan-trace-cmp = -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize-coverage=trace-cmp -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_asan-trace-cmp = -fsanitize=address +CPPFLAGS_asan-trace-cmp = -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize-coverage=trace-cmp -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_asan-trace-cmp = -stdlib=libc++ -fsanitize=address VALID_CONFIG_dbg = 1 CC_dbg = $(DEFAULT_CC) @@ -103,8 +103,8 @@ CC_asan = clang CXX_asan = clang++ LD_asan = clang++ LDXX_asan = clang++ -CPPFLAGS_asan = -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_asan = -fsanitize=address +CPPFLAGS_asan = -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_asan = -stdlib=libc++ -fsanitize=address VALID_CONFIG_msan = 1 REQUIRE_CUSTOM_LIBRARIES_msan = 1 @@ -112,8 +112,8 @@ CC_msan = clang CXX_msan = clang++ LD_msan = clang++ LDXX_msan = clang++ -CPPFLAGS_msan = -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=memory -fsanitize-memory-track-origins -fsanitize-memory-use-after-dtor -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_msan = -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,) +CPPFLAGS_msan = -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=memory -fsanitize-memory-track-origins -fsanitize-memory-use-after-dtor -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_msan = -stdlib=libc++ -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,) DEFINES_msan = NDEBUG VALID_CONFIG_basicprof = 1 @@ -139,8 +139,8 @@ CC_asan-noleaks = clang CXX_asan-noleaks = clang++ LD_asan-noleaks = clang++ LDXX_asan-noleaks = clang++ -CPPFLAGS_asan-noleaks = -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_asan-noleaks = -fsanitize=address +CPPFLAGS_asan-noleaks = -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_asan-noleaks = -stdlib=libc++ -fsanitize=address VALID_CONFIG_noexcept = 1 CC_noexcept = $(DEFAULT_CC) @@ -157,8 +157,8 @@ CC_ubsan = clang CXX_ubsan = clang++ LD_ubsan = clang++ LDXX_ubsan = clang++ -CPPFLAGS_ubsan = -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=undefined -fno-omit-frame-pointer -Wno-unused-command-line-argument -Wvarargs -LDFLAGS_ubsan = -fsanitize=undefined,unsigned-integer-overflow +CPPFLAGS_ubsan = -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=undefined -fno-omit-frame-pointer -Wno-unused-command-line-argument -Wvarargs +LDFLAGS_ubsan = -stdlib=libc++ -fsanitize=undefined,unsigned-integer-overflow DEFINES_ubsan = NDEBUG GRPC_UBSAN VALID_CONFIG_tsan = 1 @@ -167,8 +167,8 @@ CC_tsan = clang CXX_tsan = clang++ LD_tsan = clang++ LDXX_tsan = clang++ -CPPFLAGS_tsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_tsan = -fsanitize=thread +CPPFLAGS_tsan = -O0 -stdlib=libc++ -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_tsan = -stdlib=libc++ -fsanitize=thread DEFINES_tsan = GRPC_TSAN VALID_CONFIG_stapprof = 1 diff --git a/build.yaml b/build.yaml index 9c546246ab0..ee51a72bb8d 100644 --- a/build.yaml +++ b/build.yaml @@ -6067,11 +6067,11 @@ vspackages: configs: asan: CC: clang - CPPFLAGS: -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer - -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS + CPPFLAGS: -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address + -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ LD: clang++ - LDFLAGS: -fsanitize=address + LDFLAGS: -stdlib=libc++ -fsanitize=address LDXX: clang++ compile_the_world: true test_environ: @@ -6079,23 +6079,23 @@ configs: LSAN_OPTIONS: suppressions=test/core/util/lsan_suppressions.txt:report_objects=1 asan-noleaks: CC: clang - CPPFLAGS: -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer - -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS + CPPFLAGS: -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address + -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ LD: clang++ - LDFLAGS: -fsanitize=address + LDFLAGS: -stdlib=libc++ -fsanitize=address LDXX: clang++ compile_the_world: true test_environ: ASAN_OPTIONS: detect_leaks=0:color=always asan-trace-cmp: CC: clang - CPPFLAGS: -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize-coverage=trace-cmp + CPPFLAGS: -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize-coverage=trace-cmp -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ LD: clang++ - LDFLAGS: -fsanitize=address + LDFLAGS: -stdlib=libc++ -fsanitize=address LDXX: clang++ compile_the_world: true test_environ: @@ -6137,13 +6137,14 @@ configs: valgrind: --tool=memcheck --leak-check=full msan: CC: clang - CPPFLAGS: -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=memory -fsanitize-memory-track-origins - -fsanitize-memory-use-after-dtor -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 - -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS + CPPFLAGS: -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=memory + -fsanitize-memory-track-origins -fsanitize-memory-use-after-dtor -fno-omit-frame-pointer + -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument + -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ DEFINES: NDEBUG LD: clang++ - LDFLAGS: -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 + LDFLAGS: -stdlib=libc++ -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,) LDXX: clang++ compile_the_world: true @@ -6165,24 +6166,24 @@ configs: DEFINES: NDEBUG tsan: CC: clang - CPPFLAGS: -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument + CPPFLAGS: -O0 -stdlib=libc++ -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ DEFINES: GRPC_TSAN LD: clang++ - LDFLAGS: -fsanitize=thread + LDFLAGS: -stdlib=libc++ -fsanitize=thread LDXX: clang++ compile_the_world: true test_environ: TSAN_OPTIONS: suppressions=test/core/util/tsan_suppressions.txt:halt_on_error=1:second_deadlock_stack=1 ubsan: CC: clang - CPPFLAGS: -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=undefined -fno-omit-frame-pointer - -Wno-unused-command-line-argument -Wvarargs + CPPFLAGS: -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=undefined + -fno-omit-frame-pointer -Wno-unused-command-line-argument -Wvarargs CXX: clang++ DEFINES: NDEBUG GRPC_UBSAN LD: clang++ - LDFLAGS: -fsanitize=undefined,unsigned-integer-overflow + LDFLAGS: -stdlib=libc++ -fsanitize=undefined,unsigned-integer-overflow LDXX: clang++ compile_the_world: true test_environ: From 8b91cdbf6db580856dbe7f2da51055837f30ca94 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 5 Sep 2019 15:53:34 -0700 Subject: [PATCH 1478/1555] Add a default Dockerfile for Python testing --- .../Dockerfile.template | 37 ++++++++ .../python_stretch_default_x64/Dockerfile | 88 +++++++++++++++++++ tools/run_tests/run_tests.py | 2 +- 3 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template create mode 100644 tools/dockerfile/test/python_stretch_default_x64/Dockerfile diff --git a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template new file mode 100644 index 00000000000..c6799a38fb5 --- /dev/null +++ b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template @@ -0,0 +1,37 @@ +%YAML 1.2 +--- | + # Copyright 2018 The gRPC Authors + # + # Licensed under the Apache License, Version 2.0 (the "License"); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + + <%include file="../../python_stretch.include"/> + + RUN apt-get install -y jq zlib1g-dev libssl-dev + RUN apt-get install -y jq build-essential libffi-dev + + RUN cd /tmp && ${'\\'} + wget -q https://github.com/python/cpython/archive/v3.6.9.tar.gz && ${'\\'} + tar xzvf v3.6.9.tar.gz && ${'\\'} + cd cpython-3.6.9 && ${'\\'} + ./configure && ${'\\'} + make install + + RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev + RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 + + # for Python test coverage reporting + RUN python3.7 -m ensurepip && ${'\\'} + python3.7 -m pip install coverage + + RUN python3.6 -m ensurepip && ${'\\'} + python3.6 -m pip install coverage diff --git a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile new file mode 100644 index 00000000000..8f1f7c820db --- /dev/null +++ b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile @@ -0,0 +1,88 @@ +# Copyright 2018 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM debian:stretch + +# Install Git and basic packages. +RUN apt-get update && apt-get install -y \ + autoconf \ + autotools-dev \ + build-essential \ + bzip2 \ + ccache \ + curl \ + dnsutils \ + gcc \ + gcc-multilib \ + git \ + golang \ + gyp \ + lcov \ + libc6 \ + libc6-dbg \ + libc6-dev \ + libgtest-dev \ + libtool \ + make \ + perl \ + strace \ + python-dev \ + python-setuptools \ + python-yaml \ + telnet \ + unzip \ + wget \ + zip && apt-get clean + +#================ +# Build profiling +RUN apt-get update && apt-get install -y time && apt-get clean + +# Google Cloud platform API libraries +RUN apt-get update && apt-get install -y python-pip && apt-get clean +RUN pip install --upgrade google-api-python-client oauth2client + +# Install Python 2.7 +RUN apt-get update && apt-get install -y python2.7 python-all-dev +RUN curl https://bootstrap.pypa.io/get-pip.py | python2.7 + +# Add Debian 'buster' repository, we will need it for installing newer versions of python +RUN echo 'deb http://ftp.de.debian.org/debian buster main' >> /etc/apt/sources.list +RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local + +RUN mkdir /var/local/jenkins + +# Define the default command. +CMD ["bash"] + + +RUN apt-get install -y jq zlib1g-dev libssl-dev +RUN apt-get install -y jq build-essential libffi-dev + +RUN cd /tmp && \ + wget -q https://github.com/python/cpython/archive/v3.6.9.tar.gz && \ + tar xzvf v3.6.9.tar.gz && \ + cd cpython-3.6.9 && \ + ./configure && \ + make install + +RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev +RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 + +# for Python test coverage reporting +RUN python3.7 -m ensurepip && \ + python3.7 -m pip install coverage + +RUN python3.6 -m ensurepip && \ + python3.6 -m pip install coverage diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index a90f6e3245e..8ee0710b484 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -761,7 +761,7 @@ class PythonLanguage(object): elif self.args.compiler == 'python3.4': return 'jessie' else: - return 'stretch_3.7' + return 'stretch_default' def _get_pythons(self, args): """Get python runtimes to test with, based on current platform, architecture, compiler etc.""" From 6620a74b7273bbc711fb0254baa3a228658f1f11 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 5 Sep 2019 15:59:27 -0700 Subject: [PATCH 1479/1555] Run apt-get update before installing packages --- .../test/python_stretch_default_x64/Dockerfile.template | 4 ++-- tools/dockerfile/test/python_stretch_default_x64/Dockerfile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template index c6799a38fb5..af86101b71b 100644 --- a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template @@ -16,8 +16,8 @@ <%include file="../../python_stretch.include"/> - RUN apt-get install -y jq zlib1g-dev libssl-dev - RUN apt-get install -y jq build-essential libffi-dev + RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev + RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && ${'\\'} wget -q https://github.com/python/cpython/archive/v3.6.9.tar.gz && ${'\\'} diff --git a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile index 8f1f7c820db..484b5e0428a 100644 --- a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile @@ -67,8 +67,8 @@ RUN mkdir /var/local/jenkins CMD ["bash"] -RUN apt-get install -y jq zlib1g-dev libssl-dev -RUN apt-get install -y jq build-essential libffi-dev +RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev +RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && \ wget -q https://github.com/python/cpython/archive/v3.6.9.tar.gz && \ From 113b2f2225bf4362367a51c15cff4a3b94227aa7 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 5 Sep 2019 16:07:15 -0700 Subject: [PATCH 1480/1555] Remove the ensurepip for Python 3.7 --- .../test/python_stretch_default_x64/Dockerfile.template | 3 +-- tools/dockerfile/test/python_stretch_default_x64/Dockerfile | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template index af86101b71b..57620b17aa4 100644 --- a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template @@ -30,8 +30,7 @@ RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 # for Python test coverage reporting - RUN python3.7 -m ensurepip && ${'\\'} - python3.7 -m pip install coverage + RUN python3.7 -m pip install coverage RUN python3.6 -m ensurepip && ${'\\'} python3.6 -m pip install coverage diff --git a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile index 484b5e0428a..a412c93fe73 100644 --- a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile @@ -81,8 +81,7 @@ RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 # for Python test coverage reporting -RUN python3.7 -m ensurepip && \ - python3.7 -m pip install coverage +RUN python3.7 -m pip install coverage RUN python3.6 -m ensurepip && \ python3.6 -m pip install coverage From 04b3b8e9215994cba3243d0726163f22cec665f9 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 5 Sep 2019 16:39:55 -0700 Subject: [PATCH 1481/1555] Add default transport fallback --- src/objective-c/GRPCClient/GRPCTransport.m | 17 +++++-- .../CronetTests/TransportRegistryTests.m | 41 +++++++++++++++ .../tests/Tests.xcodeproj/project.pbxproj | 8 +++ .../tests/UnitTests/TransportRegistryTests.m | 51 +++++++++++++++++++ 4 files changed, 112 insertions(+), 5 deletions(-) create mode 100644 src/objective-c/tests/CronetTests/TransportRegistryTests.m create mode 100644 src/objective-c/tests/UnitTests/TransportRegistryTests.m diff --git a/src/objective-c/GRPCClient/GRPCTransport.m b/src/objective-c/GRPCClient/GRPCTransport.m index 966dc50d64d..353300c3bc4 100644 --- a/src/objective-c/GRPCClient/GRPCTransport.m +++ b/src/objective-c/GRPCClient/GRPCTransport.m @@ -86,8 +86,9 @@ NSUInteger TransportIdHash(GRPCTransportID transportId) { - (id)getTransportFactoryWithId:(GRPCTransportID)transportId { if (transportId == NULL) { if (_defaultFactory == nil) { + // fall back to default transport if no transport is provided [NSException raise:NSInvalidArgumentException - format:@"Unable to get default transport factory"]; + format:@"Did not specify transport and unable to find a default transport."]; return nil; } return _defaultFactory; @@ -95,10 +96,16 @@ NSUInteger TransportIdHash(GRPCTransportID transportId) { NSString *nsTransportId = [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding]; id transportFactory = _registry[nsTransportId]; if (transportFactory == nil) { - // User named a transport id that was not registered with the registry. - [NSException raise:NSInvalidArgumentException - format:@"Unable to get transport factory with id %s", transportId]; - return nil; + if (_defaultFactory != nil) { + // fall back to default transport if no transport is found + NSLog(@"Unable to find transport with id %s; falling back to default transport.", + transportId); + return _defaultFactory; + } else { + [NSException raise:NSInvalidArgumentException + format:@"Unable to find transport with id %s", transportId]; + return nil; + } } return transportFactory; } diff --git a/src/objective-c/tests/CronetTests/TransportRegistryTests.m b/src/objective-c/tests/CronetTests/TransportRegistryTests.m new file mode 100644 index 00000000000..75802e17c4f --- /dev/null +++ b/src/objective-c/tests/CronetTests/TransportRegistryTests.m @@ -0,0 +1,41 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import + +#import +#import +#import "src/objective-c/GRPCClient/private/GRPCTransport+Private.h" + +@interface TransportRegistryTests : XCTestCase + +@end + +@implementation TransportRegistryTests + +- (void)testCronetImplementationExist { + id secureTransportFactory = [[GRPCTransportRegistry sharedInstance] + getTransportFactoryWithId:GRPCDefaultTransportImplList.core_secure]; + id cronetTransportFactory = + [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:gGRPCCoreCronetId]; + XCTAssertNotNil(secureTransportFactory); + XCTAssertNotNil(cronetTransportFactory); + XCTAssertNotEqual(secureTransportFactory, cronetTransportFactory); +} + +@end diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index 6cb9f5560b9..2ce32d3916d 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -30,6 +30,8 @@ 5E7F488E22778C87006656AD /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; 5E7F488F22778C8C006656AD /* InteropTestsRemote.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F488822778B04006656AD /* InteropTestsRemote.m */; }; 5E7F489022778C95006656AD /* RxLibraryUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F488A22778B5D006656AD /* RxLibraryUnitTests.m */; }; + 5E9F1C332321AB1700837469 /* TransportRegistryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E9F1C322321AB1700837469 /* TransportRegistryTests.m */; }; + 5E9F1C352321C9B200837469 /* TransportRegistryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E9F1C342321C9B200837469 /* TransportRegistryTests.m */; }; 5EA4770322736178000F72FC /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; 5EA477042273617B000F72FC /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; 5EA4770522736AC4000F72FC /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; @@ -121,6 +123,8 @@ 5E7F488622778AEA006656AD /* GRPCClientTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GRPCClientTests.m; sourceTree = ""; }; 5E7F488822778B04006656AD /* InteropTestsRemote.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InteropTestsRemote.m; sourceTree = ""; }; 5E7F488A22778B5D006656AD /* RxLibraryUnitTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RxLibraryUnitTests.m; sourceTree = ""; }; + 5E9F1C322321AB1700837469 /* TransportRegistryTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TransportRegistryTests.m; sourceTree = ""; }; + 5E9F1C342321C9B200837469 /* TransportRegistryTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TransportRegistryTests.m; sourceTree = ""; }; 5EA476F42272816A000F72FC /* InteropTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 5EA908CF4CDA4CE218352A06 /* Pods-InteropTestsLocalSSLCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.release.xcconfig"; sourceTree = ""; }; 5EAD6D261E27047400002378 /* CronetUnitTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = CronetUnitTests.mm; path = CronetTests/CronetUnitTests.mm; sourceTree = SOURCE_ROOT; }; @@ -362,6 +366,7 @@ 5E0282E7215AA697007AC99D /* UnitTests */ = { isa = PBXGroup; children = ( + 5E9F1C322321AB1700837469 /* TransportRegistryTests.m */, 5E7F488A22778B5D006656AD /* RxLibraryUnitTests.m */, 5E7F488622778AEA006656AD /* GRPCClientTests.m */, 5E7F487F227782C1006656AD /* APIv2Tests.m */, @@ -375,6 +380,7 @@ 5E7F485A22775B15006656AD /* CronetTests */ = { isa = PBXGroup; children = ( + 5E9F1C342321C9B200837469 /* TransportRegistryTests.m */, 5EE84BF31D4717E40050C6CC /* InteropTestsRemoteWithCronet.m */, 5E7F486D22778086006656AD /* CoreCronetEnd2EndTests.mm */, 5EAD6D261E27047400002378 /* CronetUnitTests.mm */, @@ -868,6 +874,7 @@ 5E0282E9215AA697007AC99D /* NSErrorUnitTests.m in Sources */, 5E7F4880227782C1006656AD /* APIv2Tests.m in Sources */, 5E7F487D22778256006656AD /* ChannelPoolTest.m in Sources */, + 5E9F1C332321AB1700837469 /* TransportRegistryTests.m in Sources */, 5E7F488722778AEA006656AD /* GRPCClientTests.m in Sources */, 5E7F487E22778256006656AD /* ChannelTests.m in Sources */, 5E7F488B22778B5D006656AD /* RxLibraryUnitTests.m in Sources */, @@ -882,6 +889,7 @@ 5E3F148D22792856007C6D90 /* ConfigureCronet.m in Sources */, 5E08D07023021E3B006D76EA /* InteropTestsMultipleChannels.m in Sources */, 5E7F486E22778086006656AD /* CoreCronetEnd2EndTests.mm in Sources */, + 5E9F1C352321C9B200837469 /* TransportRegistryTests.m in Sources */, 5E7F488522778A88006656AD /* InteropTests.m in Sources */, 5E7F486422775B37006656AD /* InteropTestsRemoteWithCronet.m in Sources */, 5E7F486522775B41006656AD /* CronetUnitTests.mm in Sources */, diff --git a/src/objective-c/tests/UnitTests/TransportRegistryTests.m b/src/objective-c/tests/UnitTests/TransportRegistryTests.m new file mode 100644 index 00000000000..40035fefa90 --- /dev/null +++ b/src/objective-c/tests/UnitTests/TransportRegistryTests.m @@ -0,0 +1,51 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import + +#import +#import +#import "src/objective-c/GRPCClient/private/GRPCTransport+Private.h" + +@interface TransportRegistryTests : XCTestCase + +@end + +@implementation TransportRegistryTests + +- (void)testDefaultImplementationsExist { + id secureTransportFactory = [[GRPCTransportRegistry sharedInstance] + getTransportFactoryWithId:GRPCDefaultTransportImplList.core_secure]; + id insecureTransportFactory = [[GRPCTransportRegistry sharedInstance] + getTransportFactoryWithId:GRPCDefaultTransportImplList.core_insecure]; + XCTAssertNotNil(secureTransportFactory); + XCTAssertNotNil(insecureTransportFactory); + XCTAssertNotEqual(secureTransportFactory, insecureTransportFactory); +} + +- (void)testCronetImplementationNotExistAndFallBack { + id secureTransportFactory = [[GRPCTransportRegistry sharedInstance] + getTransportFactoryWithId:GRPCDefaultTransportImplList.core_secure]; + id cronetTransportFactory = + [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:gGRPCCoreCronetId]; + XCTAssertNotNil(secureTransportFactory); + XCTAssertNotNil(cronetTransportFactory); + XCTAssertEqual(secureTransportFactory, cronetTransportFactory); +} + +@end From 97f1f57dab1eda1c45601f19d104dcbdcc54ff46 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 5 Sep 2019 18:13:59 -0700 Subject: [PATCH 1482/1555] Allow call credentials to be set even after the call is created but before initial metadata is sent --- .../grpcpp/impl/codegen/client_context_impl.h | 6 +- src/cpp/client/client_context.cc | 16 ++++ test/cpp/end2end/end2end_test.cc | 81 +++++++++++++++++-- 3 files changed, 92 insertions(+), 11 deletions(-) diff --git a/include/grpcpp/impl/codegen/client_context_impl.h b/include/grpcpp/impl/codegen/client_context_impl.h index 7a543055b4b..bf5afa44b10 100644 --- a/include/grpcpp/impl/codegen/client_context_impl.h +++ b/include/grpcpp/impl/codegen/client_context_impl.h @@ -310,11 +310,11 @@ class ClientContext { /// client’s identity, role, or whether it is authorized to make a particular /// call. /// + /// It is legal to call this only before initial metadata is sent. + /// /// \see https://grpc.io/docs/guides/auth.html void set_credentials( - const std::shared_ptr& creds) { - creds_ = creds; - } + const std::shared_ptr& creds); /// Return the compression algorithm the client call will request be used. /// Note that the gRPC runtime may decide to ignore this request, for example, diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index efb10a44006..fc44b654efe 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -72,6 +72,22 @@ ClientContext::~ClientContext() { g_client_callbacks->Destructor(this); } +void ClientContext::set_credentials( + const std::shared_ptr& creds) { + creds_ = creds; + // If call_ is set, we have already created the call, and set the call + // credentials. This should only be done before we have started the batch + // for sending initial metadata. + if (creds_ != nullptr && call_ != nullptr) { + if (!creds_->ApplyToCall(call_)) { + SendCancelToInterceptors(); + grpc_call_cancel_with_status(call_, GRPC_STATUS_CANCELLED, + "Failed to set credentials to rpc.", + nullptr); + } + } +} + std::unique_ptr ClientContext::FromServerContext( const grpc::ServerContext& context, PropagationOptions options) { std::unique_ptr ctx(new ClientContext); diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index a8592fd97c2..a4655329250 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -16,9 +16,6 @@ * */ -#include -#include - #include #include #include @@ -35,6 +32,9 @@ #include #include +#include +#include + #include "src/core/ext/filters/client_channel/backup_poller.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/security/credentials/credentials.h" @@ -338,7 +338,11 @@ class End2endTest : public ::testing::TestWithParam { kMaxMessageSize_); // For testing max message size. } - void ResetChannel() { + void ResetChannel( + std::vector< + std::unique_ptr> + interceptor_creators = std::vector>()) { if (!is_server_started_) { StartServer(std::shared_ptr()); } @@ -358,20 +362,27 @@ class End2endTest : public ::testing::TestWithParam { } else { channel_ = CreateCustomChannelWithInterceptors( server_address_.str(), channel_creds, args, - CreateDummyClientInterceptors()); + interceptor_creators.empty() ? CreateDummyClientInterceptors() + : std::move(interceptor_creators)); } } else { if (!GetParam().use_interceptors) { channel_ = server_->InProcessChannel(args); } else { channel_ = server_->experimental().InProcessChannelWithInterceptors( - args, CreateDummyClientInterceptors()); + args, interceptor_creators.empty() + ? CreateDummyClientInterceptors() + : std::move(interceptor_creators)); } } } - void ResetStub() { - ResetChannel(); + void ResetStub( + std::vector< + std::unique_ptr> + interceptor_creators = std::vector>()) { + ResetChannel(std::move(interceptor_creators)); if (GetParam().use_proxy) { proxy_service_.reset(new Proxy(channel_)); int port = grpc_pick_unused_port_or_die(); @@ -1802,6 +1813,60 @@ TEST_P(SecureEnd2endTest, SetPerCallCredentials) { "fake_selector")); } +class CredentialsInterceptor : public experimental::Interceptor { + public: + CredentialsInterceptor(experimental::ClientRpcInfo* info) : info_(info) {} + + void Intercept(experimental::InterceptorBatchMethods* methods) { + if (methods->QueryInterceptionHookPoint( + experimental::InterceptionHookPoints::PRE_SEND_INITIAL_METADATA)) { + std::shared_ptr creds = + GoogleIAMCredentials("fake_token", "fake_selector"); + info_->client_context()->set_credentials(creds); + } + methods->Proceed(); + } + + private: + experimental::ClientRpcInfo* info_ = nullptr; +}; + +class CredentialsInterceptorFactory + : public experimental::ClientInterceptorFactoryInterface { + CredentialsInterceptor* CreateClientInterceptor( + experimental::ClientRpcInfo* info) { + return new CredentialsInterceptor(info); + } +}; + +TEST_P(SecureEnd2endTest, CallCredentialsInterception) { + MAYBE_SKIP_TEST; + if (!GetParam().use_interceptors) { + return; + } + std::vector> + interceptor_creators; + interceptor_creators.push_back(std::unique_ptr( + new CredentialsInterceptorFactory())); + ResetStub(std::move(interceptor_creators)); + EchoRequest request; + EchoResponse response; + ClientContext context; + + request.set_message("Hello"); + request.mutable_param()->set_echo_metadata(true); + + Status s = stub_->Echo(&context, request, &response); + EXPECT_EQ(request.message(), response.message()); + EXPECT_TRUE(s.ok()); + EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), + GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, + "fake_token")); + EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), + GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, + "fake_selector")); +} + TEST_P(SecureEnd2endTest, OverridePerCallCredentials) { MAYBE_SKIP_TEST; ResetStub(); From 4e8ecb9fe63c3d15363bb568c016636325ed3fb1 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 6 Sep 2019 12:31:45 +0200 Subject: [PATCH 1483/1555] Revert "Upgrade to Bazel 0.29 (including Windows RBE)" --- templates/tools/dockerfile/bazel.include | 2 +- tools/bazel | 2 +- tools/dockerfile/test/bazel/Dockerfile | 2 +- tools/dockerfile/test/sanity/Dockerfile | 2 +- tools/internal_ci/windows/bazel_rbe.bat | 4 ++-- tools/remote_build/windows.bazelrc | 7 ++++--- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/templates/tools/dockerfile/bazel.include b/templates/tools/dockerfile/bazel.include index 9762bdcb85f..12a22785623 100644 --- a/templates/tools/dockerfile/bazel.include +++ b/templates/tools/dockerfile/bazel.include @@ -2,7 +2,7 @@ # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.29.0 +ENV BAZEL_VERSION 0.28.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/bazel b/tools/bazel index cfa875b0e63..4d1d57f60d9 100755 --- a/tools/bazel +++ b/tools/bazel @@ -32,7 +32,7 @@ then exec -a "$0" "${BAZEL_REAL}" "$@" fi -VERSION=0.29.0 +VERSION=0.28.1 echo "INFO: Running bazel wrapper (see //tools/bazel for details), bazel version $VERSION will be used instead of system-wide bazel installation." diff --git a/tools/dockerfile/test/bazel/Dockerfile b/tools/dockerfile/test/bazel/Dockerfile index fde54bae877..7141fb9c5f1 100644 --- a/tools/dockerfile/test/bazel/Dockerfile +++ b/tools/dockerfile/test/bazel/Dockerfile @@ -52,7 +52,7 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.2.post1 six==1.10.0 t # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.29.0 +ENV BAZEL_VERSION 0.28.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index 4d3691f32bd..badff52de34 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -97,7 +97,7 @@ ENV CLANG_TIDY=clang-tidy # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.29.0 +ENV BAZEL_VERSION 0.28.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat index 8d8ea118ebd..153b2d59687 100644 --- a/tools/internal_ci/windows/bazel_rbe.bat +++ b/tools/internal_ci/windows/bazel_rbe.bat @@ -14,7 +14,7 @@ @rem TODO(jtattermusch): make this generate less output @rem TODO(jtattermusch): use tools/bazel script to keep the versions in sync -choco install bazel -y --version 0.29.0 --limit-output +choco install bazel -y --version 0.26.0 --limit-output cd github/grpc set PATH=C:\tools\msys64\usr\bin;C:\Python27;%PATH% @@ -24,7 +24,7 @@ powershell -Command "[guid]::NewGuid().ToString()" >%KOKORO_ARTIFACTS_DIR%/bazel set /p BAZEL_INVOCATION_ID=<%KOKORO_ARTIFACTS_DIR%/bazel_invocation_ids @rem TODO(jtattermusch): windows RBE should be able to use the same credentials as Linux RBE. -bazel --bazelrc=tools/remote_build/windows.bazelrc build --invocation_id="%BAZEL_INVOCATION_ID%" --workspace_status_command=tools/remote_build/workspace_status_kokoro.sh :all --google_credentials=%KOKORO_GFILE_DIR%/rbe-windows-credentials.json +bazel --bazelrc=tools/remote_build/windows.bazelrc build --invocation_id="%BAZEL_INVOCATION_ID%" --workspace_status_command=tools/remote_build/workspace_status_kokoro.sh :all --incompatible_disallow_filetype=false --google_credentials=%KOKORO_GFILE_DIR%/rbe-windows-credentials.json set BAZEL_EXITCODE=%errorlevel% @rem TODO(jtattermusch): upload results to bigquery diff --git a/tools/remote_build/windows.bazelrc b/tools/remote_build/windows.bazelrc index 825d6765de9..9fd3071e79f 100644 --- a/tools/remote_build/windows.bazelrc +++ b/tools/remote_build/windows.bazelrc @@ -1,7 +1,8 @@ startup --host_jvm_args=-Dbazel.DigestFunction=SHA256 -build --remote_cache=grpcs://remotebuildexecution.googleapis.com -build --remote_executor=grpcs://remotebuildexecution.googleapis.com +build --remote_cache=remotebuildexecution.googleapis.com +build --remote_executor=remotebuildexecution.googleapis.com +build --tls_enabled=true build --host_crosstool_top=//third_party/toolchains/bazel_0.26.0_rbe_windows:toolchain build --crosstool_top=//third_party/toolchains/bazel_0.26.0_rbe_windows:toolchain @@ -37,7 +38,7 @@ test --test_env=GRPC_VERBOSITY=debug # Set flags for uploading to BES in order to view results in the Bazel Build # Results UI. -build --bes_backend=grpcs://buildeventservice.googleapis.com +build --bes_backend="buildeventservice.googleapis.com" build --bes_timeout=60s build --bes_results_url="https://source.cloud.google.com/results/invocations/" build --project_id=grpc-testing From 49d67b3531978b45ea091f0d06423ed315462668 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 6 Sep 2019 10:17:11 -0700 Subject: [PATCH 1484/1555] Revert using libc++ for asan & tsan --- Makefile | 16 ++++++++-------- build.yaml | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 1e8acd7e99e..e666a19eb79 100644 --- a/Makefile +++ b/Makefile @@ -86,8 +86,8 @@ CC_asan-trace-cmp = clang CXX_asan-trace-cmp = clang++ LD_asan-trace-cmp = clang++ LDXX_asan-trace-cmp = clang++ -CPPFLAGS_asan-trace-cmp = -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize-coverage=trace-cmp -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_asan-trace-cmp = -stdlib=libc++ -fsanitize=address +CPPFLAGS_asan-trace-cmp = -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize-coverage=trace-cmp -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_asan-trace-cmp = -fsanitize=address VALID_CONFIG_dbg = 1 CC_dbg = $(DEFAULT_CC) @@ -103,8 +103,8 @@ CC_asan = clang CXX_asan = clang++ LD_asan = clang++ LDXX_asan = clang++ -CPPFLAGS_asan = -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_asan = -stdlib=libc++ -fsanitize=address +CPPFLAGS_asan = -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_asan = -fsanitize=address VALID_CONFIG_msan = 1 REQUIRE_CUSTOM_LIBRARIES_msan = 1 @@ -139,8 +139,8 @@ CC_asan-noleaks = clang CXX_asan-noleaks = clang++ LD_asan-noleaks = clang++ LDXX_asan-noleaks = clang++ -CPPFLAGS_asan-noleaks = -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_asan-noleaks = -stdlib=libc++ -fsanitize=address +CPPFLAGS_asan-noleaks = -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_asan-noleaks = fsanitize=address VALID_CONFIG_noexcept = 1 CC_noexcept = $(DEFAULT_CC) @@ -167,8 +167,8 @@ CC_tsan = clang CXX_tsan = clang++ LD_tsan = clang++ LDXX_tsan = clang++ -CPPFLAGS_tsan = -O0 -stdlib=libc++ -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_tsan = -stdlib=libc++ -fsanitize=thread +CPPFLAGS_tsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_tsan = -fsanitize=thread DEFINES_tsan = GRPC_TSAN VALID_CONFIG_stapprof = 1 diff --git a/build.yaml b/build.yaml index ee51a72bb8d..15203f242c9 100644 --- a/build.yaml +++ b/build.yaml @@ -6067,11 +6067,11 @@ vspackages: configs: asan: CC: clang - CPPFLAGS: -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address - -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS + CPPFLAGS: -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer + -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ LD: clang++ - LDFLAGS: -stdlib=libc++ -fsanitize=address + LDFLAGS: -fsanitize=address LDXX: clang++ compile_the_world: true test_environ: @@ -6079,23 +6079,23 @@ configs: LSAN_OPTIONS: suppressions=test/core/util/lsan_suppressions.txt:report_objects=1 asan-noleaks: CC: clang - CPPFLAGS: -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address - -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS + CPPFLAGS: -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize=address -fno-omit-frame-pointer + -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ LD: clang++ - LDFLAGS: -stdlib=libc++ -fsanitize=address + LDFLAGS: fsanitize=address LDXX: clang++ compile_the_world: true test_environ: ASAN_OPTIONS: detect_leaks=0:color=always asan-trace-cmp: CC: clang - CPPFLAGS: -O0 -stdlib=libc++ -fsanitize-coverage=edge,trace-pc-guard -fsanitize-coverage=trace-cmp + CPPFLAGS: -O0 -fsanitize-coverage=edge,trace-pc-guard -fsanitize-coverage=trace-cmp -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ LD: clang++ - LDFLAGS: -stdlib=libc++ -fsanitize=address + LDFLAGS: -fsanitize=address LDXX: clang++ compile_the_world: true test_environ: @@ -6166,12 +6166,12 @@ configs: DEFINES: NDEBUG tsan: CC: clang - CPPFLAGS: -O0 -stdlib=libc++ -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument + CPPFLAGS: -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ DEFINES: GRPC_TSAN LD: clang++ - LDFLAGS: -stdlib=libc++ -fsanitize=thread + LDFLAGS: -fsanitize=thread LDXX: clang++ compile_the_world: true test_environ: From 3e2171ed6188b0941b47ed27785485cfd80a6341 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 6 Sep 2019 11:15:00 -0700 Subject: [PATCH 1485/1555] Adopt reviewer's advice --- templates/tools/dockerfile/python_stretch.include | 2 -- .../test/python_stretch_default_x64/Dockerfile.template | 3 +++ tools/dockerfile/interoptest/grpc_interop_python/Dockerfile | 2 -- tools/dockerfile/test/python_stretch_2.7_x64/Dockerfile | 2 -- tools/dockerfile/test/python_stretch_3.5_x64/Dockerfile | 2 -- tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile | 2 -- tools/dockerfile/test/python_stretch_3.7_x64/Dockerfile | 2 -- tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile | 2 -- tools/dockerfile/test/python_stretch_default_x64/Dockerfile | 5 +++-- tools/dockerfile/test/sanity/Dockerfile | 2 -- 10 files changed, 6 insertions(+), 18 deletions(-) diff --git a/templates/tools/dockerfile/python_stretch.include b/templates/tools/dockerfile/python_stretch.include index 43ba98ae64c..8591e753d01 100644 --- a/templates/tools/dockerfile/python_stretch.include +++ b/templates/tools/dockerfile/python_stretch.include @@ -7,5 +7,3 @@ FROM debian:stretch RUN echo 'deb http://ftp.de.debian.org/debian buster main' >> /etc/apt/sources.list RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local <%include file="./run_tests_addons.include"/> -# Define the default command. -CMD ["bash"] diff --git a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template index 57620b17aa4..155e0068a99 100644 --- a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template @@ -25,6 +25,9 @@ cd cpython-3.6.9 && ${'\\'} ./configure && ${'\\'} make install + + RUN echo "ff7cdaef4846c89c1ec0d7b709bbd54d v3.6.9.tar.gz" > checksum.md5 + RUN md5sum -c checksum.md5 RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 diff --git a/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile index b11a1a1aa31..3583d783a81 100644 --- a/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile +++ b/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile @@ -63,8 +63,6 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins -# Define the default command. -CMD ["bash"] RUN apt-get update && apt-get -t stable install -y python3.7 python3-all-dev diff --git a/tools/dockerfile/test/python_stretch_2.7_x64/Dockerfile b/tools/dockerfile/test/python_stretch_2.7_x64/Dockerfile index 92b18e740da..0bbc11a21b2 100644 --- a/tools/dockerfile/test/python_stretch_2.7_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_2.7_x64/Dockerfile @@ -63,6 +63,4 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins -# Define the default command. -CMD ["bash"] diff --git a/tools/dockerfile/test/python_stretch_3.5_x64/Dockerfile b/tools/dockerfile/test/python_stretch_3.5_x64/Dockerfile index 7a256edffb2..bfedf432b78 100644 --- a/tools/dockerfile/test/python_stretch_3.5_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_3.5_x64/Dockerfile @@ -63,8 +63,6 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins -# Define the default command. -CMD ["bash"] RUN apt-get update && apt-get install -y python3.5 python3-all-dev diff --git a/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile b/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile index f18af660488..7a3a4a6dea5 100644 --- a/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile @@ -63,8 +63,6 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins -# Define the default command. -CMD ["bash"] RUN apt-get install -y jq zlib1g-dev libssl-dev diff --git a/tools/dockerfile/test/python_stretch_3.7_x64/Dockerfile b/tools/dockerfile/test/python_stretch_3.7_x64/Dockerfile index 46b6526dc69..6745055c14f 100644 --- a/tools/dockerfile/test/python_stretch_3.7_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_3.7_x64/Dockerfile @@ -63,8 +63,6 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins -# Define the default command. -CMD ["bash"] RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev diff --git a/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile b/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile index 495d86fd099..b0e386ac57f 100644 --- a/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile @@ -63,8 +63,6 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins -# Define the default command. -CMD ["bash"] RUN apt-get install -y jq zlib1g-dev libssl-dev diff --git a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile index a412c93fe73..7a6e51fdf7a 100644 --- a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile @@ -63,8 +63,6 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins -# Define the default command. -CMD ["bash"] RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev @@ -77,6 +75,9 @@ RUN cd /tmp && \ ./configure && \ make install +RUN echo "ff7cdaef4846c89c1ec0d7b709bbd54d v3.6.9.tar.gz" > checksum.md5 +RUN md5sum -c checksum.md5 + RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index 4d3691f32bd..6ab449f14b1 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -63,8 +63,6 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins -# Define the default command. -CMD ["bash"] #================= # C++ dependencies From 40d495a31b9ba29642561e33886eb2fa7b57650e Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 6 Sep 2019 11:25:12 -0700 Subject: [PATCH 1486/1555] Correct the checksum and download link --- .../python_stretch_default_x64/Dockerfile.template | 11 ++++++----- .../test/python_stretch_default_x64/Dockerfile | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template index 155e0068a99..80347d4b4d0 100644 --- a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template @@ -20,14 +20,15 @@ RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && ${'\\'} - wget -q https://github.com/python/cpython/archive/v3.6.9.tar.gz && ${'\\'} - tar xzvf v3.6.9.tar.gz && ${'\\'} - cd cpython-3.6.9 && ${'\\'} + wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && ${'\\'} + tar xzvf Python-3.6.9.tgz && ${'\\'} + cd Python-3.6.9 && ${'\\'} ./configure && ${'\\'} make install - RUN echo "ff7cdaef4846c89c1ec0d7b709bbd54d v3.6.9.tar.gz" > checksum.md5 - RUN md5sum -c checksum.md5 + RUN cd /tmp && ${'\\'} + echo "ff7cdaef4846c89c1ec0d7b709bbd54d Python-3.6.9.tgz" > checksum.md5 && ${'\\'} + md5sum -c checksum.md5 RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 diff --git a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile index 7a6e51fdf7a..cf0eebe2ad6 100644 --- a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile @@ -69,14 +69,15 @@ RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && \ - wget -q https://github.com/python/cpython/archive/v3.6.9.tar.gz && \ - tar xzvf v3.6.9.tar.gz && \ - cd cpython-3.6.9 && \ + wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && \ + tar xzvf Python-3.6.9.tgz && \ + cd Python-3.6.9 && \ ./configure && \ make install -RUN echo "ff7cdaef4846c89c1ec0d7b709bbd54d v3.6.9.tar.gz" > checksum.md5 -RUN md5sum -c checksum.md5 +RUN cd /tmp && \ + echo "ff7cdaef4846c89c1ec0d7b709bbd54d Python-3.6.9.tgz" > checksum.md5 && \ + md5sum -c checksum.md5 RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 From 9094826cf5e8da6718a531e44305eff5a6977113 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 6 Sep 2019 11:25:18 -0700 Subject: [PATCH 1487/1555] Polish interceptor/transport manager logic --- src/objective-c/GRPCClient/GRPCInterceptor.h | 2 ++ src/objective-c/GRPCClient/GRPCInterceptor.m | 13 +++++++------ .../GRPCClient/private/GRPCTransport+Private.h | 2 ++ .../GRPCClient/private/GRPCTransport+Private.m | 4 +++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.h b/src/objective-c/GRPCClient/GRPCInterceptor.h index 1794ef4b892..ed907a33054 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.h +++ b/src/objective-c/GRPCClient/GRPCInterceptor.h @@ -182,6 +182,8 @@ NS_ASSUME_NONNULL_BEGIN /** * Notify the manager that the interceptor has shut down and the manager should release references * to other interceptors and stop forwarding requests/responses. + * + * The method can only be called by the manager's associated interceptor. */ - (void)shutDown; diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.m b/src/objective-c/GRPCClient/GRPCInterceptor.m index abada5a80c1..1a64bccb89b 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.m +++ b/src/objective-c/GRPCClient/GRPCInterceptor.m @@ -68,12 +68,11 @@ } - (void)shutDown { - dispatch_async(_dispatchQueue, ^{ - self->_nextInterceptor = nil; - self->_previousInterceptor = nil; - self->_thisInterceptor = nil; - self->_shutDown = YES; - }); + // immediately releases reference; should not queue to dispatch queue. + _nextInterceptor = nil; + _previousInterceptor = nil; + _thisInterceptor = nil; + _shutDown = YES; } - (void)createNextInterceptor { @@ -203,6 +202,8 @@ return; } id copiedPreviousInterceptor = _previousInterceptor; + // no more callbacks should be issued to the previous interceptor + _previousInterceptor = nil; dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ [copiedPreviousInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; }); diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h index 075d185e5d7..eaf07950815 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h @@ -43,6 +43,8 @@ NS_ASSUME_NONNULL_BEGIN /** * Notify the manager that the transport has shut down and the manager should release references to * its response handler and stop forwarding requests/responses. + * + * The method can only be called by the manager's associated transport instance. */ - (void)shutDown; diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m index 1ce9e8940ef..aa9c7f2ce58 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m @@ -46,8 +46,8 @@ return self; } -// Must be called on _dispatchQueue or queues targeted by _dispatchQueue - (void)shutDown { + // immediately releases reference; should not queue to dispatch queue. _transport = nil; _previousInterceptor = nil; } @@ -111,6 +111,8 @@ return; } id copiedPreviousInterceptor = _previousInterceptor; + // no more callbacks should be issued to the previous interceptor + _previousInterceptor = nil; dispatch_async(copiedPreviousInterceptor.dispatchQueue, ^{ [copiedPreviousInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; }); From e592414fae42df3d4b4887480eda9a5c81c60fd3 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 6 Sep 2019 11:37:19 -0700 Subject: [PATCH 1488/1555] Add check for input parameter being null. --- src/core/ext/filters/client_channel/lb_policy_registry.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/ext/filters/client_channel/lb_policy_registry.cc b/src/core/ext/filters/client_channel/lb_policy_registry.cc index 20099b52d6c..c0788955419 100644 --- a/src/core/ext/filters/client_channel/lb_policy_registry.cc +++ b/src/core/ext/filters/client_channel/lb_policy_registry.cc @@ -117,8 +117,13 @@ namespace { grpc_json* ParseLoadBalancingConfigHelper(const grpc_json* lb_config_array, grpc_error** error) { GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); + if (lb_config_array == nullptr) { + *error = + GRPC_ERROR_CREATE_FROM_STATIC_STRING("LB config JSON tree is null"); + return nullptr; + } char* error_msg; - if (lb_config_array == nullptr || lb_config_array->type != GRPC_JSON_ARRAY) { + if (lb_config_array->type != GRPC_JSON_ARRAY) { gpr_asprintf(&error_msg, "field:%s error:type should be array", lb_config_array->key); *error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg); From f6445add1f3966c6f1e13fb9751a9fc7b4f1f254 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 6 Sep 2019 13:05:42 -0700 Subject: [PATCH 1489/1555] Move compile CPython 3.6 to a separate include file --- .../tools/dockerfile/compile_python_36.include | 15 +++++++++++++++ .../python_stretch_3.6_x64/Dockerfile.template | 16 +--------------- .../Dockerfile.template | 11 +---------- .../test/python_stretch_3.6_x64/Dockerfile | 17 +++++++++-------- .../test/python_stretch_default_x64/Dockerfile | 15 ++++++++++----- 5 files changed, 36 insertions(+), 38 deletions(-) create mode 100644 templates/tools/dockerfile/compile_python_36.include diff --git a/templates/tools/dockerfile/compile_python_36.include b/templates/tools/dockerfile/compile_python_36.include new file mode 100644 index 00000000000..e8983db334f --- /dev/null +++ b/templates/tools/dockerfile/compile_python_36.include @@ -0,0 +1,15 @@ +#================= +# Compile CPython 3.6.9 from source + +RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev +RUN apt-get update && apt-get install -y jq build-essential libffi-dev + +RUN cd /tmp && ${'\\'} +wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && ${'\\'} +tar xzvf Python-3.6.9.tgz && ${'\\'} +cd Python-3.6.9 && ${'\\'} +./configure && ${'\\'} +make install + +RUN python3.6 -m ensurepip && ${'\\'} + python3.6 -m pip install coverage \ No newline at end of file diff --git a/templates/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile.template index 2c2cb6de08b..c7d5fe36faa 100644 --- a/templates/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile.template @@ -15,18 +15,4 @@ # limitations under the License. <%include file="../../python_stretch.include"/> - - RUN apt-get install -y jq zlib1g-dev libssl-dev - - RUN apt-get install -y jq build-essential libffi-dev - - RUN cd /tmp && ${'\\'} - wget -q https://github.com/python/cpython/archive/v3.6.9.tar.gz && ${'\\'} - tar xzvf v3.6.9.tar.gz && ${'\\'} - cd cpython-3.6.9 && ${'\\'} - ./configure && ${'\\'} - make install - - RUN python3.6 -m ensurepip && ${'\\'} - python3.6 -m pip install coverage - + <%include file="../../compile_python_36.include"/> diff --git a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template index 80347d4b4d0..8f8bea1eb50 100644 --- a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template @@ -15,17 +15,8 @@ # limitations under the License. <%include file="../../python_stretch.include"/> + <%include file="../../compile_python_36.include"/> - RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev - RUN apt-get update && apt-get install -y jq build-essential libffi-dev - - RUN cd /tmp && ${'\\'} - wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && ${'\\'} - tar xzvf Python-3.6.9.tgz && ${'\\'} - cd Python-3.6.9 && ${'\\'} - ./configure && ${'\\'} - make install - RUN cd /tmp && ${'\\'} echo "ff7cdaef4846c89c1ec0d7b709bbd54d Python-3.6.9.tgz" > checksum.md5 && ${'\\'} md5sum -c checksum.md5 diff --git a/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile b/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile index 7a3a4a6dea5..a7a5f53e549 100644 --- a/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile @@ -64,17 +64,18 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins +#================= +# Compile CPython 3.6.9 from source -RUN apt-get install -y jq zlib1g-dev libssl-dev - -RUN apt-get install -y jq build-essential libffi-dev +RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev +RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && \ - wget -q https://github.com/python/cpython/archive/v3.6.9.tar.gz && \ - tar xzvf v3.6.9.tar.gz && \ - cd cpython-3.6.9 && \ - ./configure && \ - make install +wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && \ +tar xzvf Python-3.6.9.tgz && \ +cd Python-3.6.9 && \ +./configure && \ +make install RUN python3.6 -m ensurepip && \ python3.6 -m pip install coverage diff --git a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile index cf0eebe2ad6..7aba6c87593 100644 --- a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile @@ -64,16 +64,21 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins +#================= +# Compile CPython 3.6.9 from source RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && \ - wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && \ - tar xzvf Python-3.6.9.tgz && \ - cd Python-3.6.9 && \ - ./configure && \ - make install +wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && \ +tar xzvf Python-3.6.9.tgz && \ +cd Python-3.6.9 && \ +./configure && \ +make install + +RUN python3.6 -m ensurepip && \ + python3.6 -m pip install coverage RUN cd /tmp && \ echo "ff7cdaef4846c89c1ec0d7b709bbd54d Python-3.6.9.tgz" > checksum.md5 && \ From 67b2eff113f5c256a50d99e17ee6a4f3bd5eda3c Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 6 Sep 2019 13:17:30 -0700 Subject: [PATCH 1490/1555] Also fix the compilation of 3.8 --- .../dockerfile/compile_python_36.include | 16 ++++++++++------ .../dockerfile/compile_python_38.include | 19 +++++++++++++++++++ .../Dockerfile.template | 14 +------------- .../Dockerfile.template | 9 +-------- 4 files changed, 31 insertions(+), 27 deletions(-) create mode 100644 templates/tools/dockerfile/compile_python_38.include diff --git a/templates/tools/dockerfile/compile_python_36.include b/templates/tools/dockerfile/compile_python_36.include index e8983db334f..af4d73e9f6b 100644 --- a/templates/tools/dockerfile/compile_python_36.include +++ b/templates/tools/dockerfile/compile_python_36.include @@ -5,11 +5,15 @@ RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && ${'\\'} -wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && ${'\\'} -tar xzvf Python-3.6.9.tgz && ${'\\'} -cd Python-3.6.9 && ${'\\'} -./configure && ${'\\'} -make install + wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && ${'\\'} + tar xzvf Python-3.6.9.tgz && ${'\\'} + cd Python-3.6.9 && ${'\\'} + ./configure && ${'\\'} + make install + +RUN cd /tmp && ${'\\'} + echo "ff7cdaef4846c89c1ec0d7b709bbd54d Python-3.6.9.tgz" > checksum.md5 && ${'\\'} + md5sum -c checksum.md5 RUN python3.6 -m ensurepip && ${'\\'} - python3.6 -m pip install coverage \ No newline at end of file + python3.6 -m pip install coverage diff --git a/templates/tools/dockerfile/compile_python_38.include b/templates/tools/dockerfile/compile_python_38.include new file mode 100644 index 00000000000..30337e0ecb7 --- /dev/null +++ b/templates/tools/dockerfile/compile_python_38.include @@ -0,0 +1,19 @@ +#================= +# Compile CPython 3.8.0b4 from source + +RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev +RUN apt-get update && apt-get install -y jq build-essential libffi-dev + +RUN cd /tmp && ${'\\'} + wget -q https://www.python.org/ftp/python/3.8.0/Python-3.8.0b4.tgz && ${'\\'} + tar xzvf Python-3.8.0b4.tgz && ${'\\'} + cd Python-3.8.0b4 && ${'\\'} + ./configure && ${'\\'} + make install + +RUN cd /tmp && ${'\\'} + echo "b8f4f897df967014ddb42033b90c3058 Python-3.8.0b4.tgz" > checksum.md5 && ${'\\'} + md5sum -c checksum.md5 + +RUN python3.8 -m ensurepip && ${'\\'} + python3.8 -m pip install coverage diff --git a/templates/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile.template index 841a7f51b51..b0098fda0cc 100644 --- a/templates/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile.template @@ -16,16 +16,4 @@ # limitations under the License. <%include file="../../python_stretch.include"/> - RUN apt-get install -y jq zlib1g-dev libssl-dev - - RUN apt-get install -y jq build-essential libffi-dev - - RUN cd /tmp && ${'\\'} - wget -q https://github.com/python/cpython/archive/v3.8.0b3.tar.gz && ${'\\'} - tar xzvf v3.8.0b3.tar.gz && ${'\\'} - cd cpython-3.8.0b3 && ${'\\'} - ./configure && ${'\\'} - make install - - RUN python3.8 -m ensurepip && ${'\\'} - python3.8 -m pip install coverage + <%include file="../../compile_python_38.include"/> diff --git a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template index 8f8bea1eb50..ccb88e75302 100644 --- a/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/python_stretch_default_x64/Dockerfile.template @@ -16,16 +16,9 @@ <%include file="../../python_stretch.include"/> <%include file="../../compile_python_36.include"/> - - RUN cd /tmp && ${'\\'} - echo "ff7cdaef4846c89c1ec0d7b709bbd54d Python-3.6.9.tgz" > checksum.md5 && ${'\\'} - md5sum -c checksum.md5 - + RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 # for Python test coverage reporting RUN python3.7 -m pip install coverage - - RUN python3.6 -m ensurepip && ${'\\'} - python3.6 -m pip install coverage From 7f49b9f1624ba9ea8922881691391cf3bf7e0957 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 6 Sep 2019 13:20:31 -0700 Subject: [PATCH 1491/1555] Auto-generate the project --- .../test/python_stretch_3.6_x64/Dockerfile | 15 ++++++++----- .../test/python_stretch_3.8_x64/Dockerfile | 21 ++++++++++++------- .../python_stretch_default_x64/Dockerfile | 20 ++++++++---------- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile b/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile index a7a5f53e549..3d475849bb9 100644 --- a/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_3.6_x64/Dockerfile @@ -71,11 +71,16 @@ RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && \ -wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && \ -tar xzvf Python-3.6.9.tgz && \ -cd Python-3.6.9 && \ -./configure && \ -make install + wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && \ + tar xzvf Python-3.6.9.tgz && \ + cd Python-3.6.9 && \ + ./configure && \ + make install + +RUN cd /tmp && \ + echo "ff7cdaef4846c89c1ec0d7b709bbd54d Python-3.6.9.tgz" > checksum.md5 && \ + md5sum -c checksum.md5 RUN python3.6 -m ensurepip && \ python3.6 -m pip install coverage + diff --git a/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile b/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile index b0e386ac57f..8d780f0ad78 100644 --- a/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_3.8_x64/Dockerfile @@ -64,16 +64,23 @@ RUN echo 'APT::Default-Release "stretch";' | tee -a /etc/apt/apt.conf.d/00local RUN mkdir /var/local/jenkins -RUN apt-get install -y jq zlib1g-dev libssl-dev +#================= +# Compile CPython 3.8.0b4 from source -RUN apt-get install -y jq build-essential libffi-dev +RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev +RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && \ - wget -q https://github.com/python/cpython/archive/v3.8.0b3.tar.gz && \ - tar xzvf v3.8.0b3.tar.gz && \ - cd cpython-3.8.0b3 && \ - ./configure && \ - make install + wget -q https://www.python.org/ftp/python/3.8.0/Python-3.8.0b4.tgz && \ + tar xzvf Python-3.8.0b4.tgz && \ + cd Python-3.8.0b4 && \ + ./configure && \ + make install + +RUN cd /tmp && \ + echo "b8f4f897df967014ddb42033b90c3058 Python-3.8.0b4.tgz" > checksum.md5 && \ + md5sum -c checksum.md5 RUN python3.8 -m ensurepip && \ python3.8 -m pip install coverage + diff --git a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile index 7aba6c87593..9a1d6c09deb 100644 --- a/tools/dockerfile/test/python_stretch_default_x64/Dockerfile +++ b/tools/dockerfile/test/python_stretch_default_x64/Dockerfile @@ -71,24 +71,22 @@ RUN apt-get update && apt-get install -y zlib1g-dev libssl-dev RUN apt-get update && apt-get install -y jq build-essential libffi-dev RUN cd /tmp && \ -wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && \ -tar xzvf Python-3.6.9.tgz && \ -cd Python-3.6.9 && \ -./configure && \ -make install + wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && \ + tar xzvf Python-3.6.9.tgz && \ + cd Python-3.6.9 && \ + ./configure && \ + make install + +RUN cd /tmp && \ + echo "ff7cdaef4846c89c1ec0d7b709bbd54d Python-3.6.9.tgz" > checksum.md5 && \ + md5sum -c checksum.md5 RUN python3.6 -m ensurepip && \ python3.6 -m pip install coverage -RUN cd /tmp && \ - echo "ff7cdaef4846c89c1ec0d7b709bbd54d Python-3.6.9.tgz" > checksum.md5 && \ - md5sum -c checksum.md5 RUN apt-get update && apt-get -t buster install -y python3.7 python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 # for Python test coverage reporting RUN python3.7 -m pip install coverage - -RUN python3.6 -m ensurepip && \ - python3.6 -m pip install coverage From 0b06676c9e9e1df592cd725a0f7ad874d1b5ce80 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Wed, 4 Sep 2019 14:50:26 -0700 Subject: [PATCH 1492/1555] hpack encoder optimizations. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed some cycles and branches from hpack_enc for CH2. Specifically: 1. Pushed certain metadata key/value length checks to prepare_application_metadata() in src/core/lib/surface/call.cc. This means that rather than check all key/val lengths for all metadata, we only do so for custom added user metadata. Inside CH2, we change the length checks to debug checks so we can catch if core/filter metadata fails to pass the check. 2. Changed various asserts to debug asserts when able. 3. Refactored some of the header emission code to remove duplicated code. 4. Un-inlined some logging methods. This results in somewhat faster hpack_encoder performance: BM_HpackEncoderInitDestroy 222ns ± 0% 221ns ± 0% -0.29% (p=0.000 n=34+34) BM_HpackEncoderEncodeDeadline [framing_bytes/iter:9 header_bytes/iter:6 ] 135ns ± 1% 124ns ± 0% -8.05% (p=0.000 n=39+38) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:0 ] 34.2ns ± 0% 34.2ns ± 0% -0.01% (p=0.014 n=34+38) BM_HpackEncoderEncodeHeader/1/16384 [framing_bytes/iter:9 header_bytes/iter:0 ] 34.2ns ± 0% 34.2ns ± 0% -0.04% (p=0.004 n=34+37) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.5ns ± 0% 45.9ns ± 0% -3.28% (p=0.000 n=28+38) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:6 ] 77.0ns ± 1% 68.3ns ± 1% -11.33% (p=0.000 n=39+40) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.7ns ± 1% 45.5ns ± 0% -4.63% (p=0.000 n=39+33) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.2ns ± 0% 45.3ns ± 0% -3.96% (p=0.000 n=33+34) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.7ns ± 0% 45.6ns ± 0% -4.54% (p=0.000 n=38+40) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.7ns ± 0% 45.5ns ± 0% -4.63% (p=0.000 n=39+32) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.8ns ± 0% 45.6ns ± 1% -4.59% (p=0.000 n=38+39) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.8ns ± 0% 45.5ns ± 0% -4.64% (p=0.000 n=39+36) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.3ns ± 0% 45.3ns ± 0% -4.09% (p=0.000 n=38+36) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.8ns ± 1% 45.6ns ± 0% -4.71% (p=0.000 n=37+40) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.7ns ± 0% 45.5ns ± 0% -4.66% (p=0.000 n=39+32) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.8ns ± 1% 45.6ns ± 1% -4.62% (p=0.000 n=37+39) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.7ns ± 0% 45.5ns ± 0% -4.67% (p=0.000 n=38+32) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:9 ] 80.5ns ± 1% 74.7ns ± 0% -7.16% (p=0.000 n=38+35) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:12 ] 105ns ± 1% 99ns ± 0% -5.91% (p=0.000 n=38+34) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:14 ] 111ns ± 1% 106ns ± 1% -4.86% (p=0.020 n=39+2) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:23 ] 135ns ± 0% 130ns ± 0% -3.45% (p=0.020 n=35+2) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:46 ] 225ns ± 1% 223ns ± 0% -0.91% (p=0.003 n=37+2) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:120 ] 467ns ± 0% 472ns ± 0% +1.09% (p=0.003 n=38+2) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:12 ] 81.6ns ± 1% 74.8ns ± 0% -8.40% (p=0.000 n=37+33) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:14 ] 82.0ns ± 1% 74.8ns ± 0% -8.80% (p=0.000 n=37+32) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:21 ] 82.1ns ± 1% 74.9ns ± 0% -8.86% (p=0.000 n=35+34) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:42 ] 97.6ns ± 2% 91.8ns ± 0% -5.95% (p=0.000 n=35+27) BM_HpackEncoderEncodeHeader>/0/16384 [framing_bytes/iter:9 header_bytes/iter:111 ] 97.2ns ± 1% 91.2ns ± 2% -6.19% (p=0.000 n=37+38) BM_HpackEncoderEncodeHeader/0/1 [framing_bytes/iter:54 header_bytes/iter:9 ] 230ns ± 0% 221ns ± 0% -3.91% (p=0.000 n=38+37) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:16 ] 206ns ± 2% 170ns ± 1% -17.51% (p=0.000 n=39+39) BM_HpackEncoderEncodeHeader/0/16384 [framing_bytes/iter:9 header_bytes/iter:3 ] 66.4ns ± 2% 62.5ns ± 1% -5.85% (p=0.000 n=34+39) BM_HpackEncoderEncodeHeader/1/16384 [framing_bytes/iter:9 header_bytes/iter:1 ] 47.5ns ± 0% 45.9ns ± 1% -3.29% (p=0.000 n=26+38) --- .../chttp2/transport/hpack_encoder.cc | 424 ++++++++++-------- src/core/lib/slice/slice_internal.h | 30 +- src/core/lib/surface/call.cc | 3 + src/core/lib/surface/validate_metadata.cc | 4 + test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 3 +- 5 files changed, 267 insertions(+), 197 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc index e46504d9b30..f1291a10cc6 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc @@ -88,7 +88,19 @@ typedef struct { * with a data frame header */ static void fill_header(uint8_t* p, uint8_t type, uint32_t id, size_t len, uint8_t flags) { - GPR_ASSERT(len < 16777316); + /* len is the current frame size (i.e. for the frame we're finishing). + We finish a frame if: + 1) We called ensure_space(), (i.e. add_tiny_header_data()) and adding + 'need_bytes' to the frame would cause us to exceed st->max_frame_size. + 2) We called add_header_data, and adding the slice would cause us to exceed + st->max_frame_size. + 3) We're done encoding the header. + + Thus, len is always <= st->max_frame_size. + st->max_frame_size is derived from GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE, + which has a max allowable value of 16777215 (see chttp_transport.cc). + Thus, the following assert can be a debug assert. */ + GPR_DEBUG_ASSERT(len < 16777316); *p++ = static_cast(len >> 16); *p++ = static_cast(len >> 8); *p++ = static_cast(len); @@ -100,6 +112,13 @@ static void fill_header(uint8_t* p, uint8_t type, uint32_t id, size_t len, *p++ = static_cast(id); } +static size_t current_frame_size(framer_state* st) { + const size_t frame_size = + st->output->length - st->output_length_at_start_of_frame; + GPR_DEBUG_ASSERT(frame_size <= st->max_frame_size); + return frame_size; +} + /* finish a frame - fill in the previously reserved header */ static void finish_frame(framer_state* st, int is_header_boundary, int is_last_in_stream) { @@ -108,7 +127,7 @@ static void finish_frame(framer_state* st, int is_header_boundary, : GRPC_CHTTP2_FRAME_CONTINUATION; fill_header( GRPC_SLICE_START_PTR(st->output->slices[st->header_idx]), type, - st->stream_id, st->output->length - st->output_length_at_start_of_frame, + st->stream_id, current_frame_size(st), static_cast( (is_last_in_stream ? GRPC_CHTTP2_DATA_FLAG_END_STREAM : 0) | (is_header_boundary ? GRPC_CHTTP2_DATA_FLAG_END_HEADERS : 0))); @@ -130,9 +149,7 @@ static void begin_frame(framer_state* st) { space to add at least about_to_add bytes -- finishes the current frame if needed */ static void ensure_space(framer_state* st, size_t need_bytes) { - if (GPR_LIKELY(st->output->length - st->output_length_at_start_of_frame + - need_bytes <= - st->max_frame_size)) { + if (GPR_LIKELY(current_frame_size(st) + need_bytes <= st->max_frame_size)) { return; } finish_frame(st, 0, 0); @@ -158,8 +175,7 @@ static void add_header_data(framer_state* st, grpc_slice slice) { size_t len = GRPC_SLICE_LENGTH(slice); size_t remaining; if (len == 0) return; - remaining = st->max_frame_size + st->output_length_at_start_of_frame - - st->output->length; + remaining = st->max_frame_size - current_frame_size(st); if (len <= remaining) { st->stats->header_bytes += len; grpc_slice_buffer_add(st->output, slice); @@ -325,132 +341,129 @@ static void emit_indexed(grpc_chttp2_hpack_compressor* c, uint32_t elem_index, len); } -typedef struct { - grpc_slice data; - uint8_t huffman_prefix; - bool insert_null_before_wire_value; -} wire_value; +struct wire_value { + wire_value(uint8_t huffman_prefix, bool insert_null_before_wire_value, + const grpc_slice& slice) + : data(slice), + huffman_prefix(huffman_prefix), + insert_null_before_wire_value(insert_null_before_wire_value), + length(GRPC_SLICE_LENGTH(slice) + + (insert_null_before_wire_value ? 1 : 0)) {} + // While wire_value is const from the POV of hpack encoder code, actually + // adding it to a slice buffer will possibly split the slice. + const grpc_slice data; + const uint8_t huffman_prefix; + const bool insert_null_before_wire_value; + const size_t length; +}; template static wire_value get_wire_value(grpc_mdelem elem, bool true_binary_enabled) { - wire_value wire_val; - bool is_bin_hdr = + const bool is_bin_hdr = mdkey_definitely_interned ? grpc_is_refcounted_slice_binary_header(GRPC_MDKEY(elem)) : grpc_is_binary_header_internal(GRPC_MDKEY(elem)); + const grpc_slice& value = GRPC_MDVALUE(elem); if (is_bin_hdr) { if (true_binary_enabled) { GRPC_STATS_INC_HPACK_SEND_BINARY(); - wire_val.huffman_prefix = 0x00; - wire_val.insert_null_before_wire_value = true; - wire_val.data = grpc_slice_ref_internal(GRPC_MDVALUE(elem)); - + return wire_value(0x00, true, grpc_slice_ref_internal(value)); } else { GRPC_STATS_INC_HPACK_SEND_BINARY_BASE64(); - wire_val.huffman_prefix = 0x80; - wire_val.insert_null_before_wire_value = false; - wire_val.data = - grpc_chttp2_base64_encode_and_huffman_compress(GRPC_MDVALUE(elem)); + return wire_value(0x80, false, + grpc_chttp2_base64_encode_and_huffman_compress(value)); } } else { /* TODO(ctiller): opportunistically compress non-binary headers */ GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(); - wire_val.huffman_prefix = 0x00; - wire_val.insert_null_before_wire_value = false; - wire_val.data = grpc_slice_ref_internal(GRPC_MDVALUE(elem)); + return wire_value(0x00, false, grpc_slice_ref_internal(value)); } - return wire_val; } -static size_t wire_value_length(wire_value v) { - return GPR_SLICE_LENGTH(v.data) + v.insert_null_before_wire_value; +static uint32_t wire_value_length(const wire_value& v) { + GPR_DEBUG_ASSERT(v.length <= UINT32_MAX); + return static_cast(v.length); } -static void add_wire_value(framer_state* st, wire_value v) { - if (v.insert_null_before_wire_value) *add_tiny_header_data(st, 1) = 0; - add_header_data(st, v.data); -} +namespace { +enum class EmitLitHdrType { INC_IDX, NO_IDX }; -static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor* c, - uint32_t key_index, grpc_mdelem elem, - framer_state* st) { - GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX(); - uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2); - wire_value value = get_wire_value(elem, st->use_true_binary_metadata); - size_t len_val = wire_value_length(value); - uint32_t len_val_len; - GPR_ASSERT(len_val <= UINT32_MAX); - len_val_len = GRPC_CHTTP2_VARINT_LENGTH((uint32_t)len_val, 1); +enum class EmitLitHdrVType { INC_IDX_V, NO_IDX_V }; +} // namespace + +template +static void emit_lithdr(grpc_chttp2_hpack_compressor* c, uint32_t key_index, + grpc_mdelem elem, framer_state* st) { + switch (type) { + case EmitLitHdrType::INC_IDX: + GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX(); + break; + case EmitLitHdrType::NO_IDX: + GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX(); + break; + } + const uint32_t len_pfx = type == EmitLitHdrType::INC_IDX + ? GRPC_CHTTP2_VARINT_LENGTH(key_index, 2) + : GRPC_CHTTP2_VARINT_LENGTH(key_index, 4); + const wire_value value = + get_wire_value(elem, st->use_true_binary_metadata); + const uint32_t len_val = wire_value_length(value); + const uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); GPR_DEBUG_ASSERT(len_pfx + len_val_len < GRPC_SLICE_INLINED_SIZE); - uint8_t* data = add_tiny_header_data(st, len_pfx + len_val_len); - GRPC_CHTTP2_WRITE_VARINT(key_index, 2, 0x40, data, len_pfx); - GRPC_CHTTP2_WRITE_VARINT((uint32_t)len_val, 1, value.huffman_prefix, - &data[len_pfx], len_val_len); - add_wire_value(st, value); + uint8_t* data = add_tiny_header_data( + st, + len_pfx + len_val_len + (value.insert_null_before_wire_value ? 1 : 0)); + switch (type) { + case EmitLitHdrType::INC_IDX: + GRPC_CHTTP2_WRITE_VARINT(key_index, 2, 0x40, data, len_pfx); + break; + case EmitLitHdrType::NO_IDX: + GRPC_CHTTP2_WRITE_VARINT(key_index, 4, 0x00, data, len_pfx); + break; + } + GRPC_CHTTP2_WRITE_VARINT(len_val, 1, value.huffman_prefix, &data[len_pfx], + len_val_len); + if (value.insert_null_before_wire_value) { + data[len_pfx + len_val_len] = 0; + } + add_header_data(st, value.data); } -static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor* c, - uint32_t key_index, grpc_mdelem elem, - framer_state* st) { - GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX(); - uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4); - wire_value value = get_wire_value(elem, st->use_true_binary_metadata); - size_t len_val = wire_value_length(value); - uint32_t len_val_len; - GPR_ASSERT(len_val <= UINT32_MAX); - len_val_len = GRPC_CHTTP2_VARINT_LENGTH((uint32_t)len_val, 1); - GPR_DEBUG_ASSERT(len_pfx + len_val_len < GRPC_SLICE_INLINED_SIZE); - uint8_t* data = add_tiny_header_data(st, len_pfx + len_val_len); - GRPC_CHTTP2_WRITE_VARINT(key_index, 4, 0x00, data, len_pfx); - GRPC_CHTTP2_WRITE_VARINT((uint32_t)len_val, 1, value.huffman_prefix, - &data[len_pfx], len_val_len); - add_wire_value(st, value); -} - -static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor* c, - uint32_t unused_index, grpc_mdelem elem, - framer_state* st) { - GPR_ASSERT(unused_index == 0); - GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX_V(); +template +static void emit_lithdr_v(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, + framer_state* st) { + switch (type) { + case EmitLitHdrVType::INC_IDX_V: + GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX_V(); + break; + case EmitLitHdrVType::NO_IDX_V: + GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX_V(); + break; + } GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(); - uint32_t len_key = static_cast GRPC_SLICE_LENGTH(GRPC_MDKEY(elem)); - wire_value value = get_wire_value(elem, st->use_true_binary_metadata); - uint32_t len_val = static_cast(wire_value_length(value)); - uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1); - uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); - GPR_ASSERT(len_key <= UINT32_MAX); - GPR_ASSERT(wire_value_length(value) <= UINT32_MAX); + const uint32_t len_key = + static_cast(GRPC_SLICE_LENGTH(GRPC_MDKEY(elem))); + const wire_value value = + type == EmitLitHdrVType::INC_IDX_V + ? get_wire_value(elem, st->use_true_binary_metadata) + : get_wire_value(elem, st->use_true_binary_metadata); + const uint32_t len_val = wire_value_length(value); + const uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1); + const uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); + GPR_DEBUG_ASSERT(len_key <= UINT32_MAX); GPR_DEBUG_ASSERT(1 + len_key_len < GRPC_SLICE_INLINED_SIZE); - uint8_t* data = add_tiny_header_data(st, 1 + len_key_len); - data[0] = 0x40; - GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, &data[1], len_key_len); + uint8_t* key_buf = add_tiny_header_data(st, 1 + len_key_len); + key_buf[0] = type == EmitLitHdrVType::INC_IDX_V ? 0x40 : 0x00; + GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, &key_buf[1], len_key_len); add_header_data(st, grpc_slice_ref_internal(GRPC_MDKEY(elem))); - GRPC_CHTTP2_WRITE_VARINT(len_val, 1, value.huffman_prefix, - add_tiny_header_data(st, len_val_len), len_val_len); - add_wire_value(st, value); -} - -static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor* c, - uint32_t unused_index, grpc_mdelem elem, - framer_state* st) { - GPR_ASSERT(unused_index == 0); - GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX_V(); - GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(); - uint32_t len_key = static_cast GRPC_SLICE_LENGTH(GRPC_MDKEY(elem)); - wire_value value = get_wire_value(elem, st->use_true_binary_metadata); - uint32_t len_val = static_cast(wire_value_length(value)); - uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1); - uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); - GPR_ASSERT(len_key <= UINT32_MAX); - GPR_ASSERT(wire_value_length(value) <= UINT32_MAX); - /* Preconditions passed; emit header. */ - uint8_t* data = add_tiny_header_data(st, 1 + len_key_len); - data[0] = 0x00; - GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, &data[1], len_key_len); - add_header_data(st, grpc_slice_ref_internal(GRPC_MDKEY(elem))); - GRPC_CHTTP2_WRITE_VARINT(len_val, 1, value.huffman_prefix, - add_tiny_header_data(st, len_val_len), len_val_len); - add_wire_value(st, value); + uint8_t* value_buf = add_tiny_header_data( + st, len_val_len + (value.insert_null_before_wire_value ? 1 : 0)); + GRPC_CHTTP2_WRITE_VARINT(len_val, 1, value.huffman_prefix, value_buf, + len_val_len); + if (value.insert_null_before_wire_value) { + value_buf[len_val_len] = 0; + } + add_header_data(st, value.data); } static void emit_advertise_table_size_change(grpc_chttp2_hpack_compressor* c, @@ -461,113 +474,142 @@ static void emit_advertise_table_size_change(grpc_chttp2_hpack_compressor* c, c->advertise_table_size_change = 0; } +static void GPR_ATTRIBUTE_NOINLINE hpack_enc_log(grpc_mdelem elem) { + char* k = grpc_slice_to_c_string(GRPC_MDKEY(elem)); + char* v = nullptr; + if (grpc_is_binary_header_internal(GRPC_MDKEY(elem))) { + v = grpc_dump_slice(GRPC_MDVALUE(elem), GPR_DUMP_HEX); + } else { + v = grpc_slice_to_c_string(GRPC_MDVALUE(elem)); + } + gpr_log( + GPR_INFO, + "Encode: '%s: %s', elem_interned=%d [%d], k_interned=%d, v_interned=%d", + k, v, GRPC_MDELEM_IS_INTERNED(elem), GRPC_MDELEM_STORAGE(elem), + grpc_slice_is_interned(GRPC_MDKEY(elem)), + grpc_slice_is_interned(GRPC_MDVALUE(elem))); + gpr_free(k); + gpr_free(v); +} + static uint32_t dynidx(grpc_chttp2_hpack_compressor* c, uint32_t elem_index) { return 1 + GRPC_CHTTP2_LAST_STATIC_ENTRY + c->tail_remote_index + c->table_elems - elem_index; } +struct EmitIndexedStatus { + EmitIndexedStatus() = default; + EmitIndexedStatus(uint32_t elem_hash, bool emitted, bool can_add) + : elem_hash(elem_hash), emitted(emitted), can_add(can_add) {} + const uint32_t elem_hash = 0; + const bool emitted = false; + const bool can_add = false; +}; + +static EmitIndexedStatus maybe_emit_indexed(grpc_chttp2_hpack_compressor* c, + grpc_mdelem elem, + framer_state* st) { + const uint32_t elem_hash = + GRPC_MDELEM_STORAGE(elem) == GRPC_MDELEM_STORAGE_INTERNED + ? reinterpret_cast( + GRPC_MDELEM_DATA(elem)) + ->hash() + : reinterpret_cast(GRPC_MDELEM_DATA(elem)) + ->hash(); + + inc_filter(HASH_FRAGMENT_1(elem_hash), &c->filter_elems_sum, c->filter_elems); + + /* is this elem currently in the decoders table? */ + if (grpc_mdelem_both_interned_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], + elem) && + c->indices_elems[HASH_FRAGMENT_2(elem_hash)] > c->tail_remote_index) { + /* HIT: complete element (first cuckoo hash) */ + emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_2(elem_hash)]), + st); + return EmitIndexedStatus(elem_hash, true, false); + } + if (grpc_mdelem_both_interned_eq(c->entries_elems[HASH_FRAGMENT_3(elem_hash)], + elem) && + c->indices_elems[HASH_FRAGMENT_3(elem_hash)] > c->tail_remote_index) { + /* HIT: complete element (second cuckoo hash) */ + emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_3(elem_hash)]), + st); + return EmitIndexedStatus(elem_hash, true, false); + } + + const bool can_add = c->filter_elems[HASH_FRAGMENT_1(elem_hash)] >= + c->filter_elems_sum / ONE_ON_ADD_PROBABILITY; + return EmitIndexedStatus(elem_hash, false, can_add); +} + +static void emit_maybe_add(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, + framer_state* st, uint32_t indices_key, + bool should_add_elem, size_t decoder_space_usage, + uint32_t elem_hash, uint32_t key_hash) { + if (should_add_elem) { + emit_lithdr(c, dynidx(c, indices_key), elem, st); + add_elem(c, elem, decoder_space_usage, elem_hash, key_hash); + } else { + emit_lithdr(c, dynidx(c, indices_key), elem, st); + } +} + /* encode an mdelem */ static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, framer_state* st) { - GPR_ASSERT(GRPC_SLICE_LENGTH(GRPC_MDKEY(elem)) > 0); + /* User-provided key len validated in grpc_validate_header_key_is_legal(). */ + GPR_DEBUG_ASSERT(GRPC_SLICE_LENGTH(GRPC_MDKEY(elem)) > 0); + /* Header ordering: all reserved headers (prefixed with ':') must precede + * regular headers. This can be a debug assert, since: + * 1) User cannot give us ':' headers (grpc_validate_header_key_is_legal()). + * 2) grpc filters/core should be checked during debug builds. */ +#ifndef NDEBUG if (GRPC_SLICE_START_PTR(GRPC_MDKEY(elem))[0] != ':') { /* regular header */ st->seen_regular_header = 1; } else { - GPR_ASSERT( + GPR_DEBUG_ASSERT( st->seen_regular_header == 0 && "Reserved header (colon-prefixed) happening after regular ones."); } - +#endif if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { - char* k = grpc_slice_to_c_string(GRPC_MDKEY(elem)); - char* v = nullptr; - if (grpc_is_binary_header_internal(GRPC_MDKEY(elem))) { - v = grpc_dump_slice(GRPC_MDVALUE(elem), GPR_DUMP_HEX); - } else { - v = grpc_slice_to_c_string(GRPC_MDVALUE(elem)); - } - gpr_log( - GPR_INFO, - "Encode: '%s: %s', elem_interned=%d [%d], k_interned=%d, v_interned=%d", - k, v, GRPC_MDELEM_IS_INTERNED(elem), GRPC_MDELEM_STORAGE(elem), - grpc_slice_is_interned(GRPC_MDKEY(elem)), - grpc_slice_is_interned(GRPC_MDVALUE(elem))); - gpr_free(k); - gpr_free(v); + hpack_enc_log(elem); } - bool elem_interned = GRPC_MDELEM_IS_INTERNED(elem); - bool key_interned = elem_interned || grpc_slice_is_interned(GRPC_MDKEY(elem)); + const bool elem_interned = GRPC_MDELEM_IS_INTERNED(elem); + const bool key_interned = + elem_interned || grpc_slice_is_interned(GRPC_MDKEY(elem)); - // Key is not interned, emit literals. + /* Key is not interned, emit literals. */ if (!key_interned) { - emit_lithdr_noidx_v(c, 0, elem, st); + emit_lithdr_v(c, elem, st); return; } - - uint32_t elem_hash = 0; - - if (elem_interned) { - if (GRPC_MDELEM_STORAGE(elem) == GRPC_MDELEM_STORAGE_INTERNED) { - elem_hash = - reinterpret_cast(GRPC_MDELEM_DATA(elem)) - ->hash(); - } else { - elem_hash = - reinterpret_cast(GRPC_MDELEM_DATA(elem)) - ->hash(); - } - - inc_filter(HASH_FRAGMENT_1(elem_hash), &c->filter_elems_sum, - c->filter_elems); - - /* is this elem currently in the decoders table? */ - if (grpc_mdelem_both_interned_eq( - c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem) && - c->indices_elems[HASH_FRAGMENT_2(elem_hash)] > c->tail_remote_index) { - /* HIT: complete element (first cuckoo hash) */ - emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_2(elem_hash)]), - st); - return; - } - if (grpc_mdelem_both_interned_eq( - c->entries_elems[HASH_FRAGMENT_3(elem_hash)], elem) && - c->indices_elems[HASH_FRAGMENT_3(elem_hash)] > c->tail_remote_index) { - /* HIT: complete element (second cuckoo hash) */ - emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_3(elem_hash)]), - st); - return; - } + /* Interned metadata => maybe already indexed. */ + const EmitIndexedStatus ret = + elem_interned ? maybe_emit_indexed(c, elem, st) : EmitIndexedStatus(); + if (ret.emitted) { + return; } - uint32_t indices_key; - /* should this elem be in the table? */ const size_t decoder_space_usage = grpc_chttp2_get_size_in_hpack_table(elem, st->use_true_binary_metadata); - const bool should_add_elem = elem_interned && - decoder_space_usage < MAX_DECODER_SPACE_USAGE && - c->filter_elems[HASH_FRAGMENT_1(elem_hash)] >= - c->filter_elems_sum / ONE_ON_ADD_PROBABILITY; - - uint32_t key_hash = GRPC_MDKEY(elem).refcount->Hash(GRPC_MDKEY(elem)); - auto emit_maybe_add = [&should_add_elem, &elem, &st, &c, &indices_key, - &decoder_space_usage, &elem_hash, &key_hash] { - if (should_add_elem) { - emit_lithdr_incidx(c, dynidx(c, indices_key), elem, st); - add_elem(c, elem, decoder_space_usage, elem_hash, key_hash); - } else { - emit_lithdr_noidx(c, dynidx(c, indices_key), elem, st); - } - }; + const bool decoder_space_available = + decoder_space_usage < MAX_DECODER_SPACE_USAGE; + const bool should_add_elem = + elem_interned && decoder_space_available && ret.can_add; + const uint32_t elem_hash = ret.elem_hash; /* no hits for the elem... maybe there's a key? */ - indices_key = c->indices_keys[HASH_FRAGMENT_2(key_hash)]; + const uint32_t key_hash = GRPC_MDKEY(elem).refcount->Hash(GRPC_MDKEY(elem)); + uint32_t indices_key = c->indices_keys[HASH_FRAGMENT_2(key_hash)]; if (grpc_slice_static_interned_equal( c->entries_keys[HASH_FRAGMENT_2(key_hash)], GRPC_MDKEY(elem)) && indices_key > c->tail_remote_index) { /* HIT: key (first cuckoo hash) */ - emit_maybe_add(); + emit_maybe_add(c, elem, st, indices_key, should_add_elem, + decoder_space_usage, elem_hash, key_hash); return; } @@ -575,18 +617,18 @@ static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, if (grpc_slice_static_interned_equal( c->entries_keys[HASH_FRAGMENT_3(key_hash)], GRPC_MDKEY(elem)) && indices_key > c->tail_remote_index) { - /* HIT: key (first cuckoo hash) */ - emit_maybe_add(); + /* HIT: key (second cuckoo hash) */ + emit_maybe_add(c, elem, st, indices_key, should_add_elem, + decoder_space_usage, elem_hash, key_hash); return; } /* no elem, key in the table... fall back to literal emission */ - const bool should_add_key = - !elem_interned && decoder_space_usage < MAX_DECODER_SPACE_USAGE; + const bool should_add_key = !elem_interned && decoder_space_available; if (should_add_elem || should_add_key) { - emit_lithdr_incidx_v(c, 0, elem, st); + emit_lithdr_v(c, elem, st); } else { - emit_lithdr_noidx_v(c, 0, elem, st); + emit_lithdr_v(c, elem, st); } if (should_add_elem) { add_elem(c, elem, decoder_space_usage, elem_hash, key_hash); @@ -695,8 +737,12 @@ void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor* c, grpc_metadata_batch* metadata, const grpc_encode_header_options* options, grpc_slice_buffer* outbuf) { - GPR_ASSERT(options->stream_id != 0); - + /* grpc_chttp2_encode_header is called by FlushInitial/TrailingMetadata in + writing.cc. Specifically, on streams returned by NextStream(), which + returns streams from the list GRPC_CHTTP2_LIST_WRITABLE. The only way to be + added to the list is via grpc_chttp2_list_add_writable_stream(), which + validates that stream_id is not 0. So, this can be a debug assert. */ + GPR_DEBUG_ASSERT(options->stream_id != 0); framer_state st; st.seen_regular_header = 0; st.stream_id = options->stream_id; diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index 49ad15d5a56..f1939b5ba7c 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -214,23 +214,39 @@ struct InternedSliceRefcount { } // namespace grpc_core +inline size_t grpc_refcounted_slice_length(const grpc_slice& slice) { + GPR_DEBUG_ASSERT(slice.refcount != nullptr); + return slice.data.refcounted.length; +} + +inline const uint8_t* grpc_refcounted_slice_data(const grpc_slice& slice) { + GPR_DEBUG_ASSERT(slice.refcount != nullptr); + return slice.data.refcounted.bytes; +} + inline int grpc_slice_refcount::Eq(const grpc_slice& a, const grpc_slice& b) { + GPR_DEBUG_ASSERT(a.refcount != nullptr); + GPR_DEBUG_ASSERT(a.refcount == this); switch (ref_type_) { case Type::STATIC: - return GRPC_STATIC_METADATA_INDEX(a) == GRPC_STATIC_METADATA_INDEX(b); + GPR_DEBUG_ASSERT( + (GRPC_STATIC_METADATA_INDEX(a) == GRPC_STATIC_METADATA_INDEX(b)) == + (a.refcount == b.refcount)); case Type::INTERNED: return a.refcount == b.refcount; case Type::NOP: case Type::REGULAR: break; } - if (GRPC_SLICE_LENGTH(a) != GRPC_SLICE_LENGTH(b)) return false; - if (GRPC_SLICE_LENGTH(a) == 0) return true; - return 0 == memcmp(GRPC_SLICE_START_PTR(a), GRPC_SLICE_START_PTR(b), - GRPC_SLICE_LENGTH(a)); + if (grpc_refcounted_slice_length(a) != GRPC_SLICE_LENGTH(b)) return false; + if (grpc_refcounted_slice_length(a) == 0) return true; + return 0 == memcmp(grpc_refcounted_slice_data(a), GRPC_SLICE_START_PTR(b), + grpc_refcounted_slice_length(a)); } inline uint32_t grpc_slice_refcount::Hash(const grpc_slice& slice) { + GPR_DEBUG_ASSERT(slice.refcount != nullptr); + GPR_DEBUG_ASSERT(slice.refcount == this); switch (ref_type_) { case Type::STATIC: return ::grpc_static_metadata_hash_values[GRPC_STATIC_METADATA_INDEX( @@ -242,8 +258,8 @@ inline uint32_t grpc_slice_refcount::Hash(const grpc_slice& slice) { case Type::REGULAR: break; } - return gpr_murmur_hash3(GRPC_SLICE_START_PTR(slice), GRPC_SLICE_LENGTH(slice), - g_hash_seed); + return gpr_murmur_hash3(grpc_refcounted_slice_data(slice), + grpc_refcounted_slice_length(slice), g_hash_seed); } inline const grpc_slice& grpc_slice_ref_internal(const grpc_slice& slice) { diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 1331e57ab0c..5388cbd75a9 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -910,6 +910,9 @@ static int prepare_application_metadata(grpc_call* call, int count, "validate_metadata", grpc_validate_header_nonbin_value_is_legal(md->value))) { break; + } else if (GRPC_SLICE_LENGTH(md->value) >= UINT32_MAX) { + // HTTP2 hpack encoding has a maximum limit. + break; } l->md = grpc_mdelem_from_grpc_metadata(const_cast(md)); } diff --git a/src/core/lib/surface/validate_metadata.cc b/src/core/lib/surface/validate_metadata.cc index 0f65091333d..138f5745e51 100644 --- a/src/core/lib/surface/validate_metadata.cc +++ b/src/core/lib/surface/validate_metadata.cc @@ -67,6 +67,10 @@ grpc_error* grpc_validate_header_key_is_legal(const grpc_slice& slice) { return GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Metadata keys cannot be zero length"); } + if (GRPC_SLICE_LENGTH(slice) > UINT32_MAX) { + return GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "Metadata keys cannot be larger than UINT32_MAX"); + } if (GRPC_SLICE_START_PTR(slice)[0] == ':') { return GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Metadata keys cannot start with :"); diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index 0c3c35edc56..18928531c83 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -131,11 +131,12 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State& state) { grpc_slice_buffer outbuf; grpc_slice_buffer_init(&outbuf); while (state.KeepRunning()) { + static constexpr int kEnsureMaxFrameAtLeast = 2; grpc_encode_header_options hopt = { static_cast(state.iterations()), state.range(0) != 0, Fixture::kEnableTrueBinary, - static_cast(state.range(1)), + static_cast(state.range(1) + kEnsureMaxFrameAtLeast), &stats, }; grpc_chttp2_encode_header(c.get(), nullptr, 0, &b, &hopt, &outbuf); From c63f419c4900399a45f5de0f45aedc95fa331f80 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Thu, 5 Sep 2019 12:52:44 -0700 Subject: [PATCH 1493/1555] Mark CH2 on_initial_header error path unlikely. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Yields slightly better unary and streaming performance for TCP: BM_UnaryPingPong/4096/4096 [polls/iter:3.00006 ] 27.1µs ± 2% 26.3µs ± 1% -2.77% (p=0.036 n=5+3) BM_UnaryPingPong/1/0 [polls/iter:3.00009 ] 21.7µs ± 2% 21.1µs ± 1% -2.88% (p=0.029 n=4+4) BM_UnaryPingPong/0/1 [polls/iter:3.00009 ] 21.8µs ± 2% 20.9µs ± 1% -4.32% (p=0.003 n=7+5) BM_UnaryPingPong/1/1 [polls/iter:3.00008 ] 22.0µs ± 1% 21.3µs ± 1% -3.15% (p=0.036 n=3+5) BM_UnaryPingPong/64/0 [polls/iter:3.00006 ] 22.0µs ± 1% 21.5µs ± 1% -2.19% (p=0.032 n=4+5) BM_UnaryPingPong/32768/0 [polls/iter:3.00007 ] 34.7µs ± 1% 34.1µs ± 0% -1.72% (p=0.017 n=7+3) BM_UnaryPingPong/0/262144 [polls/iter:3.00023 ] 160µs ± 1% 158µs ± 1% -1.29% (p=0.016 n=8+4) BM_UnaryPingPong/0/0 [polls/iter:3.00012 ] 20.8µs ± 1% 20.4µs ± 0% -1.89% (p=0.029 n=4+4) BM_UnaryPingPong/0/0 [polls/iter:3.00008 ] 22.1µs ± 4% 21.3µs ± 0% -3.88% (p=0.004 n=6+5) BM_UnaryPingPong/64/0 [polls/iter:3.00008 ] 23.2µs ± 2% 22.5µs ± 3% -3.07% (p=0.014 n=7+6) BM_UnaryPingPong/512/512 [polls/iter:3.0001 ] 23.5µs ± 2% 22.9µs ± 0% -2.85% (p=0.010 n=6+4) BM_UnaryPingPong/1/0 [polls/iter:3.00008 ] 22.5µs ± 1% 21.7µs ± 1% -3.35% (p=0.036 n=3+5) BM_UnaryPingPong/32768/32768 [polls/iter:3.0001 ] 48.6µs ± 1% 48.3µs ± 1% -0.58% (p=0.045 n=5+8) BM_UnaryPingPong/8/8 [polls/iter:3.00008 ] 22.0µs ± 1% 21.5µs ± 1% -2.35% (p=0.016 n=4+5) BM_UnaryPingPong/8/8 [polls/iter:3.00006 ] 22.4µs ± 3% 21.4µs ± 1% -4.05% (p=0.017 n=7+3) BM_UnaryPingPong/4096/0 [polls/iter:3.00007 ] 24.5µs ± 1% 23.9µs ± 1% -2.30% BM_UnaryPingPong/1/1 [polls/iter:3.0001 ] 22.9µs ± 2% 22.4µs ± 3% -2.04% (p=0.048 n=7+5) BM_UnaryPingPong/8/8 [polls/iter:3.0001 ] 23.0µs ± 2% 22.4µs ± 1% -2.75% (p=0.012 n=7+4) BM_UnaryPingPong/64/64 [polls/iter:3.00008 ] 23.5µs ± 2% 23.1µs ± 0% -2.10% (p=0.002 n=8+5) BM_UnaryPingPong/64/0 [polls/iter:3.00008 ] 22.1µs ± 2% 21.5µs ± 1% -2.93% (p=0.009 n=9+3) BM_UnaryPingPong/0/64 [polls/iter:3.00008 ] 22.2µs ± 1% 21.4µs ± 1% -3.51% (p=0.003 n=4+9) BM_UnaryPingPong/512/0 [polls/iter:3.00008 ] 22.4µs ± 2% 21.8µs ± 1% -2.75% (p=0.009 n=5+6) BM_UnaryPingPong/32768/0 [polls/iter:3.0001 ] 34.5µs ± 1% 34.0µs ± 1% -1.58% But, slightly worse performance for in-proc (about 2-3%). --- .../ext/transport/chttp2/transport/parsing.cc | 129 +++++++++++------- 1 file changed, 77 insertions(+), 52 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index a39f6e83db7..e789006ed31 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -422,6 +422,76 @@ static bool is_nonzero_status(grpc_mdelem md) { !md_cmp(md, GRPC_MDELEM_GRPC_STATUS_0, GRPC_MDSTR_GRPC_STATUS); } +static void GPR_ATTRIBUTE_NOINLINE on_initial_header_log( + grpc_chttp2_transport* t, grpc_chttp2_stream* s, grpc_mdelem md) { + char* key = grpc_slice_to_c_string(GRPC_MDKEY(md)); + char* value = + grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX | GPR_DUMP_ASCII); + gpr_log(GPR_INFO, "HTTP:%d:HDR:%s: %s: %s", s->id, + t->is_client ? "CLI" : "SVR", key, value); + gpr_free(key); + gpr_free(value); +} + +static grpc_error* GPR_ATTRIBUTE_NOINLINE handle_timeout(grpc_chttp2_stream* s, + grpc_mdelem md) { + grpc_millis* cached_timeout = + static_cast(grpc_mdelem_get_user_data(md, free_timeout)); + grpc_millis timeout; + if (cached_timeout != nullptr) { + timeout = *cached_timeout; + } else { + if (GPR_UNLIKELY(!grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout))) { + char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); + gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'", val); + gpr_free(val); + timeout = GRPC_MILLIS_INF_FUTURE; + } + if (GRPC_MDELEM_IS_INTERNED(md)) { + /* store the result */ + cached_timeout = + static_cast(gpr_malloc(sizeof(grpc_millis))); + *cached_timeout = timeout; + grpc_mdelem_set_user_data(md, free_timeout, cached_timeout); + } + } + if (timeout != GRPC_MILLIS_INF_FUTURE) { + grpc_chttp2_incoming_metadata_buffer_set_deadline( + &s->metadata_buffer[0], grpc_core::ExecCtx::Get()->Now() + timeout); + } + GRPC_MDELEM_UNREF(md); + return GRPC_ERROR_NONE; +} + +static grpc_error* GPR_ATTRIBUTE_NOINLINE handle_metadata_size_limit_exceeded( + grpc_chttp2_transport* t, grpc_chttp2_stream* s, grpc_mdelem md, + size_t new_size, size_t metadata_size_limit) { + gpr_log(GPR_DEBUG, + "received initial metadata size exceeds limit (%" PRIuPTR + " vs. %" PRIuPTR ")", + new_size, metadata_size_limit); + grpc_chttp2_cancel_stream( + t, s, + grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "received initial metadata size exceeds limit"), + GRPC_ERROR_INT_GRPC_STATUS, + GRPC_STATUS_RESOURCE_EXHAUSTED)); + grpc_chttp2_parsing_become_skip_parser(t); + s->seen_error = true; + GRPC_MDELEM_UNREF(md); + return GRPC_ERROR_NONE; +} + +static grpc_error* GPR_ATTRIBUTE_NOINLINE +handle_metadata_add_failure(grpc_chttp2_transport* t, grpc_chttp2_stream* s, + grpc_mdelem md, grpc_error* error) { + grpc_chttp2_cancel_stream(t, s, error); + grpc_chttp2_parsing_become_skip_parser(t); + s->seen_error = true; + GRPC_MDELEM_UNREF(md); + return GRPC_ERROR_NONE; +} + static grpc_error* on_initial_header(void* tp, grpc_mdelem md) { GPR_TIMER_SCOPE("on_initial_header", 0); @@ -430,45 +500,13 @@ static grpc_error* on_initial_header(void* tp, grpc_mdelem md) { GPR_DEBUG_ASSERT(s != nullptr); if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { - char* key = grpc_slice_to_c_string(GRPC_MDKEY(md)); - char* value = - grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_INFO, "HTTP:%d:HDR:%s: %s: %s", s->id, - t->is_client ? "CLI" : "SVR", key, value); - gpr_free(key); - gpr_free(value); + on_initial_header_log(t, s, md); } if (is_nonzero_status(md)) { // not GRPC_MDELEM_GRPC_STATUS_0? s->seen_error = true; } else if (md_key_cmp(md, GRPC_MDSTR_GRPC_TIMEOUT)) { - grpc_millis* cached_timeout = - static_cast(grpc_mdelem_get_user_data(md, free_timeout)); - grpc_millis timeout; - if (cached_timeout != nullptr) { - timeout = *cached_timeout; - } else { - if (GPR_UNLIKELY( - !grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout))) { - char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); - gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'", val); - gpr_free(val); - timeout = GRPC_MILLIS_INF_FUTURE; - } - if (GRPC_MDELEM_IS_INTERNED(md)) { - /* store the result */ - cached_timeout = - static_cast(gpr_malloc(sizeof(grpc_millis))); - *cached_timeout = timeout; - grpc_mdelem_set_user_data(md, free_timeout, cached_timeout); - } - } - if (timeout != GRPC_MILLIS_INF_FUTURE) { - grpc_chttp2_incoming_metadata_buffer_set_deadline( - &s->metadata_buffer[0], grpc_core::ExecCtx::Get()->Now() + timeout); - } - GRPC_MDELEM_UNREF(md); - return GRPC_ERROR_NONE; + return handle_timeout(s, md); } const size_t new_size = s->metadata_buffer[0].size + GRPC_MDELEM_LENGTH(md); @@ -476,29 +514,16 @@ static grpc_error* on_initial_header(void* tp, grpc_mdelem md) { t->settings[GRPC_ACKED_SETTINGS] [GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE]; if (GPR_UNLIKELY(new_size > metadata_size_limit)) { - gpr_log(GPR_DEBUG, - "received initial metadata size exceeds limit (%" PRIuPTR - " vs. %" PRIuPTR ")", - new_size, metadata_size_limit); - grpc_chttp2_cancel_stream( - t, s, - grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "received initial metadata size exceeds limit"), - GRPC_ERROR_INT_GRPC_STATUS, - GRPC_STATUS_RESOURCE_EXHAUSTED)); - grpc_chttp2_parsing_become_skip_parser(t); - s->seen_error = true; - GRPC_MDELEM_UNREF(md); + return handle_metadata_size_limit_exceeded(t, s, md, new_size, + metadata_size_limit); } else { grpc_error* error = grpc_chttp2_incoming_metadata_buffer_add(&s->metadata_buffer[0], md); - if (error != GRPC_ERROR_NONE) { - grpc_chttp2_cancel_stream(t, s, error); - grpc_chttp2_parsing_become_skip_parser(t); - s->seen_error = true; - GRPC_MDELEM_UNREF(md); + if (GPR_UNLIKELY(error != GRPC_ERROR_NONE)) { + return handle_metadata_add_failure(t, s, md, error); } } + // Not timeout-related metadata, and no error occurred. return GRPC_ERROR_NONE; } From f89e11d03735a3a0df4de96bc6c156904caff2ae Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 6 Sep 2019 13:53:31 -0700 Subject: [PATCH 1494/1555] More Id -> ID --- src/objective-c/GRPCClient/GRPCCall+Cronet.h | 4 +- src/objective-c/GRPCClient/GRPCCall+Cronet.m | 2 +- src/objective-c/GRPCClient/GRPCCall.m | 4 +- src/objective-c/GRPCClient/GRPCCallOptions.m | 4 +- src/objective-c/GRPCClient/GRPCInterceptor.h | 2 +- src/objective-c/GRPCClient/GRPCInterceptor.m | 10 ++-- src/objective-c/GRPCClient/GRPCTransport.h | 8 ++-- src/objective-c/GRPCClient/GRPCTransport.m | 46 +++++++++---------- .../GRPCClient/private/GRPCCore/GRPCChannel.m | 4 +- .../GRPCCoreCronet/GRPCCoreCronetFactory.h | 2 +- .../GRPCCoreCronet/GRPCCoreCronetFactory.m | 2 +- .../private/GRPCCore/GRPCCoreFactory.m | 4 +- .../GRPCClient/private/GRPCCore/GRPCHost.m | 2 +- .../private/GRPCTransport+Private.h | 4 +- .../private/GRPCTransport+Private.m | 14 +++--- .../InteropTestsRemoteWithCronet.m | 2 +- .../CronetTests/TransportRegistryTests.m | 4 +- .../tests/InteropTests/InteropTests.m | 2 +- .../tests/UnitTests/TransportRegistryTests.m | 8 ++-- 19 files changed, 64 insertions(+), 64 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall+Cronet.h b/src/objective-c/GRPCClient/GRPCCall+Cronet.h index 10cea963631..f89b108c1bd 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Cronet.h +++ b/src/objective-c/GRPCClient/GRPCCall+Cronet.h @@ -22,9 +22,9 @@ typedef struct stream_engine stream_engine; // Transport id for Cronet transport -extern const GRPCTransportID gGRPCCoreCronetId; +extern const GRPCTransportID gGRPCCoreCronetID; -// Deprecated class. Please use the gGRPCCoreCronetId with GRPCCallOptions.transport instead. +// Deprecated class. Please use the gGRPCCoreCronetID with GRPCCallOptions.transport instead. @interface GRPCCall (Cronet) + (void)useCronetWithEngine:(stream_engine*)engine; diff --git a/src/objective-c/GRPCClient/GRPCCall+Cronet.m b/src/objective-c/GRPCClient/GRPCCall+Cronet.m index 33b09136b33..15e79717bea 100644 --- a/src/objective-c/GRPCClient/GRPCCall+Cronet.m +++ b/src/objective-c/GRPCClient/GRPCCall+Cronet.m @@ -18,7 +18,7 @@ #import "GRPCCall+Cronet.h" -const GRPCTransportID gGRPCCoreCronetId = "io.grpc.transport.core.cronet"; +const GRPCTransportID gGRPCCoreCronetID = "io.grpc.transport.core.cronet"; static BOOL useCronet = NO; static stream_engine *globalCronetEngine; diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 73ee530ef2c..87c2768187e 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -186,14 +186,14 @@ NSString *const kGRPCErrorDomain = @"io.grpc"; // continuously create interceptor until one is successfully created while (_firstInterceptor == nil) { if (interceptorFactories.count == 0) { - _firstInterceptor = [[GRPCTransportManager alloc] initWithTransportId:_callOptions.transport + _firstInterceptor = [[GRPCTransportManager alloc] initWithTransportID:_callOptions.transport previousInterceptor:dispatcher]; break; } else { _firstInterceptor = [[GRPCInterceptorManager alloc] initWithFactories:interceptorFactories previousInterceptor:dispatcher - transportId:_callOptions.transport]; + transportID:_callOptions.transport]; if (_firstInterceptor == nil) { [interceptorFactories removeObjectAtIndex:0]; } diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.m b/src/objective-c/GRPCClient/GRPCCallOptions.m index f9044ddcd34..d147b2305a2 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.m +++ b/src/objective-c/GRPCClient/GRPCCallOptions.m @@ -289,7 +289,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { if (!areObjectsEqual(callOptions.PEMCertificateChain, _PEMCertificateChain)) return NO; if (!areObjectsEqual(callOptions.hostNameOverride, _hostNameOverride)) return NO; if (!(callOptions.transportType == _transportType)) return NO; - if (!(TransportIdIsEqual(callOptions.transport, _transport))) return NO; + if (!(TransportIDIsEqual(callOptions.transport, _transport))) return NO; if (!areObjectsEqual(callOptions.logContext, _logContext)) return NO; if (!areObjectsEqual(callOptions.channelPoolDomain, _channelPoolDomain)) return NO; if (!(callOptions.channelID == _channelID)) return NO; @@ -314,7 +314,7 @@ static BOOL areObjectsEqual(id obj1, id obj2) { result ^= _PEMCertificateChain.hash; result ^= _hostNameOverride.hash; result ^= _transportType; - result ^= TransportIdHash(_transport); + result ^= TransportIDHash(_transport); result ^= _logContext.hash; result ^= _channelPoolDomain.hash; result ^= _channelID; diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.h b/src/objective-c/GRPCClient/GRPCInterceptor.h index ed907a33054..5c203445fba 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.h +++ b/src/objective-c/GRPCClient/GRPCInterceptor.h @@ -177,7 +177,7 @@ NS_ASSUME_NONNULL_BEGIN - (nullable instancetype)initWithFactories:(nullable NSArray> *)factories previousInterceptor:(nullable id)previousInterceptor - transportId:(GRPCTransportID)transportId; + transportID:(GRPCTransportID)transportID; /** * Notify the manager that the interceptor has shut down and the manager should release references diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.m b/src/objective-c/GRPCClient/GRPCInterceptor.m index 1a64bccb89b..ea723369737 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.m +++ b/src/objective-c/GRPCClient/GRPCInterceptor.m @@ -31,13 +31,13 @@ GRPCInterceptor *_thisInterceptor; dispatch_queue_t _dispatchQueue; NSArray> *_factories; - GRPCTransportID _transportId; + GRPCTransportID _transportID; BOOL _shutDown; } - (instancetype)initWithFactories:(NSArray> *)factories previousInterceptor:(id)previousInterceptor - transportId:(nonnull GRPCTransportID)transportId { + transportID:(nonnull GRPCTransportID)transportID { if ((self = [super init])) { if (factories.count == 0) { [NSException raise:NSInternalInconsistencyException @@ -62,7 +62,7 @@ _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); } dispatch_set_target_queue(_dispatchQueue, _thisInterceptor.dispatchQueue); - _transportId = transportId; + _transportID = transportID; } return self; } @@ -87,12 +87,12 @@ while (_nextInterceptor == nil) { if (interceptorFactories.count == 0) { _nextInterceptor = - [[GRPCTransportManager alloc] initWithTransportId:_transportId previousInterceptor:self]; + [[GRPCTransportManager alloc] initWithTransportID:_transportID previousInterceptor:self]; break; } else { _nextInterceptor = [[GRPCInterceptorManager alloc] initWithFactories:interceptorFactories previousInterceptor:self - transportId:_transportId]; + transportID:_transportID]; if (_nextInterceptor == nil) { [interceptorFactories removeObjectAtIndex:0]; } diff --git a/src/objective-c/GRPCClient/GRPCTransport.h b/src/objective-c/GRPCClient/GRPCTransport.h index d9f341d08a3..a29dbd20e4d 100644 --- a/src/objective-c/GRPCClient/GRPCTransport.h +++ b/src/objective-c/GRPCClient/GRPCTransport.h @@ -34,10 +34,10 @@ extern const struct GRPCDefaultTransportImplList { } GRPCDefaultTransportImplList; /** Returns whether two transport id's are identical. */ -BOOL TransportIdIsEqual(GRPCTransportID lhs, GRPCTransportID rhs); +BOOL TransportIDIsEqual(GRPCTransportID lhs, GRPCTransportID rhs); /** Returns the hash value of a transport id. */ -NSUInteger TransportIdHash(GRPCTransportID); +NSUInteger TransportIDHash(GRPCTransportID); #pragma mark Transport and factory @@ -63,10 +63,10 @@ NSUInteger TransportIdHash(GRPCTransportID); /** * Register a transport implementation with the registry. All transport implementations to be used * in a process must register with the registry on process start-up in its +load: class method. - * Parameter \a transportId is the identifier of the implementation, and \a factory is the factory + * Parameter \a transportID is the identifier of the implementation, and \a factory is the factory * object to create the corresponding transport instance. */ -- (void)registerTransportWithId:(GRPCTransportID)transportId +- (void)registerTransportWithID:(GRPCTransportID)transportID factory:(id)factory; @end diff --git a/src/objective-c/GRPCClient/GRPCTransport.m b/src/objective-c/GRPCClient/GRPCTransport.m index 353300c3bc4..c55beca0c4a 100644 --- a/src/objective-c/GRPCClient/GRPCTransport.m +++ b/src/objective-c/GRPCClient/GRPCTransport.m @@ -18,28 +18,28 @@ #import "GRPCTransport.h" -static const GRPCTransportID gGRPCCoreSecureId = "io.grpc.transport.core.secure"; -static const GRPCTransportID gGRPCCoreInsecureId = "io.grpc.transport.core.insecure"; +static const GRPCTransportID gGRPCCoreSecureID = "io.grpc.transport.core.secure"; +static const GRPCTransportID gGRPCCoreInsecureID = "io.grpc.transport.core.insecure"; const struct GRPCDefaultTransportImplList GRPCDefaultTransportImplList = { - .core_secure = gGRPCCoreSecureId, .core_insecure = gGRPCCoreInsecureId}; + .core_secure = gGRPCCoreSecureID, .core_insecure = gGRPCCoreInsecureID}; -static const GRPCTransportID gDefaultTransportId = gGRPCCoreSecureId; +static const GRPCTransportID gDefaultTransportID = gGRPCCoreSecureID; static GRPCTransportRegistry *gTransportRegistry = nil; static dispatch_once_t initTransportRegistry; -BOOL TransportIdIsEqual(GRPCTransportID lhs, GRPCTransportID rhs) { +BOOL TransportIDIsEqual(GRPCTransportID lhs, GRPCTransportID rhs) { // Directly comparing pointers works because we require users to use the id provided by each // implementation, not coming up with their own string. return lhs == rhs; } -NSUInteger TransportIdHash(GRPCTransportID transportId) { - if (transportId == NULL) { - transportId = gDefaultTransportId; +NSUInteger TransportIDHash(GRPCTransportID transportID) { + if (transportID == NULL) { + transportID = gDefaultTransportID; } - return [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding].hash; + return [NSString stringWithCString:transportID encoding:NSUTF8StringEncoding].hash; } @implementation GRPCTransportRegistry { @@ -66,25 +66,25 @@ NSUInteger TransportIdHash(GRPCTransportID transportId) { return self; } -- (void)registerTransportWithId:(GRPCTransportID)transportId +- (void)registerTransportWithID:(GRPCTransportID)transportID factory:(id)factory { - NSString *nsTransportId = [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding]; - NSAssert(_registry[nsTransportId] == nil, @"The transport %@ has already been registered.", - nsTransportId); - if (_registry[nsTransportId] != nil) { - NSLog(@"The transport %@ has already been registered.", nsTransportId); + NSString *nsTransportID = [NSString stringWithCString:transportID encoding:NSUTF8StringEncoding]; + NSAssert(_registry[nsTransportID] == nil, @"The transport %@ has already been registered.", + nsTransportID); + if (_registry[nsTransportID] != nil) { + NSLog(@"The transport %@ has already been registered.", nsTransportID); return; } - _registry[nsTransportId] = factory; + _registry[nsTransportID] = factory; // if the default transport is registered, mark it. - if (0 == strcmp(transportId, gDefaultTransportId)) { + if (0 == strcmp(transportID, gDefaultTransportID)) { _defaultFactory = factory; } } -- (id)getTransportFactoryWithId:(GRPCTransportID)transportId { - if (transportId == NULL) { +- (id)getTransportFactoryWithID:(GRPCTransportID)transportID { + if (transportID == NULL) { if (_defaultFactory == nil) { // fall back to default transport if no transport is provided [NSException raise:NSInvalidArgumentException @@ -93,17 +93,17 @@ NSUInteger TransportIdHash(GRPCTransportID transportId) { } return _defaultFactory; } - NSString *nsTransportId = [NSString stringWithCString:transportId encoding:NSUTF8StringEncoding]; - id transportFactory = _registry[nsTransportId]; + NSString *nsTransportID = [NSString stringWithCString:transportID encoding:NSUTF8StringEncoding]; + id transportFactory = _registry[nsTransportID]; if (transportFactory == nil) { if (_defaultFactory != nil) { // fall back to default transport if no transport is found NSLog(@"Unable to find transport with id %s; falling back to default transport.", - transportId); + transportID); return _defaultFactory; } else { [NSException raise:NSInvalidArgumentException - format:@"Unable to find transport with id %s", transportId]; + format:@"Unable to find transport with id %s", transportID]; return nil; } } diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m index 89a12d96575..92670c89e52 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m @@ -53,7 +53,7 @@ - (id)channelFactory { if (_callOptions.transport != NULL) { id transportFactory = - [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:_callOptions.transport]; + [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithID:_callOptions.transport]; if (! [transportFactory respondsToSelector:@selector(createCoreChannelFactoryWithCallOptions:)]) { // impossible because we are using GRPCCore now @@ -84,7 +84,7 @@ } case GRPCTransportTypeCronet: { id transportFactory = (id)[ - [GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:gGRPCCoreCronetId]; + [GRPCTransportRegistry sharedInstance] getTransportFactoryWithID:gGRPCCoreCronetID]; return [transportFactory createCoreChannelFactoryWithCallOptions:_callOptions]; } case GRPCTransportTypeInsecure: diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h index 83d279d2c72..a36da1b502d 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h @@ -24,7 +24,7 @@ * testing purpose only on Github. * * To use this transport, a user must include the GRPCCoreCronet module as a - * dependency of the project and use gGRPCCoreCronetId in call options to + * dependency of the project and use gGRPCCoreCronetID in call options to * specify that this is the transport to be used for a call. */ @interface GRPCCoreCronetFactory : NSObject diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m index 5772694fc54..2205d167d82 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m @@ -39,7 +39,7 @@ static dispatch_once_t gInitGRPCCoreCronetFactory; + (void)load { [[GRPCTransportRegistry sharedInstance] - registerTransportWithId:gGRPCCoreCronetId + registerTransportWithID:gGRPCCoreCronetID factory:[GRPCCoreCronetFactory sharedInstance]]; } diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m index 19d7231a203..928625f1275 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m @@ -40,7 +40,7 @@ static dispatch_once_t gInitGRPCCoreInsecureFactory; + (void)load { [[GRPCTransportRegistry sharedInstance] - registerTransportWithId:GRPCDefaultTransportImplList.core_secure + registerTransportWithID:GRPCDefaultTransportImplList.core_secure factory:[self sharedInstance]]; } @@ -75,7 +75,7 @@ static dispatch_once_t gInitGRPCCoreInsecureFactory; + (void)load { [[GRPCTransportRegistry sharedInstance] - registerTransportWithId:GRPCDefaultTransportImplList.core_insecure + registerTransportWithID:GRPCDefaultTransportImplList.core_insecure factory:[self sharedInstance]]; } diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m index 1f6a25ff78f..6a3853fc94e 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCHost.m @@ -115,7 +115,7 @@ static NSMutableDictionary *gHostCache; if (_transportType == GRPCTransportTypeInsecure) { options.transport = GRPCDefaultTransportImplList.core_insecure; } else if ([GRPCCall isUsingCronet]) { - options.transport = gGRPCCoreCronetId; + options.transport = gGRPCCoreCronetID; } else { options.transport = GRPCDefaultTransportImplList.core_secure; } diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h index eaf07950815..4574e51b39f 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h @@ -31,13 +31,13 @@ NS_ASSUME_NONNULL_BEGIN * registered with the registry, the default transport factory (core + secure) is returned. If the * default transport does not exist, an exception is thrown. */ -- (id)getTransportFactoryWithId:(GRPCTransportID)transportId; +- (id)getTransportFactoryWithID:(GRPCTransportID)transportID; @end @interface GRPCTransportManager : NSObject -- (instancetype)initWithTransportId:(GRPCTransportID)transportId +- (instancetype)initWithTransportID:(GRPCTransportID)transportID previousInterceptor:(id)previousInterceptor; /** diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m index aa9c7f2ce58..3084ed9ee4e 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m @@ -21,27 +21,27 @@ #import @implementation GRPCTransportManager { - GRPCTransportID _transportId; + GRPCTransportID _transportID; GRPCTransport *_transport; id _previousInterceptor; dispatch_queue_t _dispatchQueue; } -- (instancetype)initWithTransportId:(GRPCTransportID)transportId +- (instancetype)initWithTransportID:(GRPCTransportID)transportID previousInterceptor:(id)previousInterceptor { if ((self = [super init])) { id factory = - [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:transportId]; + [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithID:transportID]; _transport = [factory createTransportWithManager:self]; - NSAssert(_transport != nil, @"Failed to create transport with id: %s", transportId); + NSAssert(_transport != nil, @"Failed to create transport with id: %s", transportID); if (_transport == nil) { - NSLog(@"Failed to create transport with id: %s", transportId); + NSLog(@"Failed to create transport with id: %s", transportID); return nil; } _previousInterceptor = previousInterceptor; _dispatchQueue = _transport.dispatchQueue; - _transportId = transportId; + _transportID = transportID; } return self; } @@ -58,7 +58,7 @@ - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { - if (_transportId != callOptions.transport) { + if (_transportID != callOptions.transport) { [NSException raise:NSInvalidArgumentException format:@"Interceptors cannot change the call option 'transport'"]; return; diff --git a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m index f4cd9e064d2..883734de26f 100644 --- a/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m +++ b/src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m @@ -53,7 +53,7 @@ static int32_t kRemoteInteropServerOverhead = 12; } + (GRPCTransportID)transport { - return gGRPCCoreCronetId; + return gGRPCCoreCronetID; } - (int32_t)encodingOverhead { diff --git a/src/objective-c/tests/CronetTests/TransportRegistryTests.m b/src/objective-c/tests/CronetTests/TransportRegistryTests.m index 75802e17c4f..9e9be5ed733 100644 --- a/src/objective-c/tests/CronetTests/TransportRegistryTests.m +++ b/src/objective-c/tests/CronetTests/TransportRegistryTests.m @@ -30,9 +30,9 @@ - (void)testCronetImplementationExist { id secureTransportFactory = [[GRPCTransportRegistry sharedInstance] - getTransportFactoryWithId:GRPCDefaultTransportImplList.core_secure]; + getTransportFactoryWithID:GRPCDefaultTransportImplList.core_secure]; id cronetTransportFactory = - [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:gGRPCCoreCronetId]; + [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithID:gGRPCCoreCronetID]; XCTAssertNotNil(secureTransportFactory); XCTAssertNotNil(cronetTransportFactory); XCTAssertNotEqual(secureTransportFactory, cronetTransportFactory); diff --git a/src/objective-c/tests/InteropTests/InteropTests.m b/src/objective-c/tests/InteropTests/InteropTests.m index 0c7ef44e0fa..9a10cccecd4 100644 --- a/src/objective-c/tests/InteropTests/InteropTests.m +++ b/src/objective-c/tests/InteropTests/InteropTests.m @@ -1268,7 +1268,7 @@ static dispatch_once_t initGlobalInterceptorFactory; - (void)testKeepaliveWithV2API { XCTAssertNotNil([[self class] host]); - if ([[self class] transport] == gGRPCCoreCronetId) { + if ([[self class] transport] == gGRPCCoreCronetID) { // Cronet does not support keepalive return; } diff --git a/src/objective-c/tests/UnitTests/TransportRegistryTests.m b/src/objective-c/tests/UnitTests/TransportRegistryTests.m index 40035fefa90..6fbf02d925d 100644 --- a/src/objective-c/tests/UnitTests/TransportRegistryTests.m +++ b/src/objective-c/tests/UnitTests/TransportRegistryTests.m @@ -30,9 +30,9 @@ - (void)testDefaultImplementationsExist { id secureTransportFactory = [[GRPCTransportRegistry sharedInstance] - getTransportFactoryWithId:GRPCDefaultTransportImplList.core_secure]; + getTransportFactoryWithID:GRPCDefaultTransportImplList.core_secure]; id insecureTransportFactory = [[GRPCTransportRegistry sharedInstance] - getTransportFactoryWithId:GRPCDefaultTransportImplList.core_insecure]; + getTransportFactoryWithID:GRPCDefaultTransportImplList.core_insecure]; XCTAssertNotNil(secureTransportFactory); XCTAssertNotNil(insecureTransportFactory); XCTAssertNotEqual(secureTransportFactory, insecureTransportFactory); @@ -40,9 +40,9 @@ - (void)testCronetImplementationNotExistAndFallBack { id secureTransportFactory = [[GRPCTransportRegistry sharedInstance] - getTransportFactoryWithId:GRPCDefaultTransportImplList.core_secure]; + getTransportFactoryWithID:GRPCDefaultTransportImplList.core_secure]; id cronetTransportFactory = - [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithId:gGRPCCoreCronetId]; + [[GRPCTransportRegistry sharedInstance] getTransportFactoryWithID:gGRPCCoreCronetID]; XCTAssertNotNil(secureTransportFactory); XCTAssertNotNil(cronetTransportFactory); XCTAssertEqual(secureTransportFactory, cronetTransportFactory); From 361a902262e72f3d647df933b3f4f84a51920996 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 6 Sep 2019 14:20:39 -0700 Subject: [PATCH 1495/1555] Reviewer comments --- test/cpp/end2end/end2end_test.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index a4655329250..5fb69c177b6 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -341,8 +341,7 @@ class End2endTest : public ::testing::TestWithParam { void ResetChannel( std::vector< std::unique_ptr> - interceptor_creators = std::vector>()) { + interceptor_creators = {}) { if (!is_server_started_) { StartServer(std::shared_ptr()); } @@ -380,8 +379,7 @@ class End2endTest : public ::testing::TestWithParam { void ResetStub( std::vector< std::unique_ptr> - interceptor_creators = std::vector>()) { + interceptor_creators = {}) { ResetChannel(std::move(interceptor_creators)); if (GetParam().use_proxy) { proxy_service_.reset(new Proxy(channel_)); From 56acfb9f26df67700824fe9b3f7c8c4e042f0c3c Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 6 Sep 2019 18:18:32 -0700 Subject: [PATCH 1496/1555] Thread safety fix --- src/objective-c/GRPCClient/GRPCInterceptor.h | 17 ++++--- src/objective-c/GRPCClient/GRPCInterceptor.m | 45 +++++++++++++++---- .../private/GRPCCore/GRPCCallInternal.m | 32 +++++++++---- .../private/GRPCTransport+Private.h | 14 +++++- .../private/GRPCTransport+Private.m | 25 ++++++++--- 5 files changed, 103 insertions(+), 30 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.h b/src/objective-c/GRPCClient/GRPCInterceptor.h index 5c203445fba..e3f49f444c4 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.h +++ b/src/objective-c/GRPCClient/GRPCInterceptor.h @@ -164,10 +164,17 @@ NS_ASSUME_NONNULL_BEGIN @end /** - * The interceptor manager object retains reference to the next and previous interceptor object in - * the interceptor chain, and forward corresponding events to them. When a call terminates, it must - * invoke shutDown method of its corresponding manager so that references to other interceptors can - * be released. + * GRPCInterceptorManager is a helper class to forward messages between the interceptors. The + * interceptor manager object retains reference to the next and previous interceptor object in the + * interceptor chain, and forward corresponding events to them. + * + * All methods except the initializer of the class can only be called on the manager's dispatch + * queue. Since the manager's dispatch queue targets corresponding interceptor's dispatch queue, it + * is also safe to call the manager's methods in the corresponding interceptor instance's methods + * that implement GRPCInterceptorInterface. + * + * When an interceptor is shutting down, it must invoke -shutDown method of its corresponding + * manager so that references to other interceptors can be released and proper clean-up is made. */ @interface GRPCInterceptorManager : NSObject @@ -182,8 +189,6 @@ NS_ASSUME_NONNULL_BEGIN /** * Notify the manager that the interceptor has shut down and the manager should release references * to other interceptors and stop forwarding requests/responses. - * - * The method can only be called by the manager's associated interceptor. */ - (void)shutDown; diff --git a/src/objective-c/GRPCClient/GRPCInterceptor.m b/src/objective-c/GRPCClient/GRPCInterceptor.m index ea723369737..3aae52f7d4e 100644 --- a/src/objective-c/GRPCClient/GRPCInterceptor.m +++ b/src/objective-c/GRPCClient/GRPCInterceptor.m @@ -226,47 +226,74 @@ - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { - [_thisInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; + // retain this interceptor until the method exit to prevent deallocation of the interceptor within + // the interceptor's method + GRPCInterceptor *thisInterceptor = _thisInterceptor; + [thisInterceptor startWithRequestOptions:requestOptions callOptions:callOptions]; } - (void)writeData:(id)data { - [_thisInterceptor writeData:data]; + // retain this interceptor until the method exit to prevent deallocation of the interceptor within + // the interceptor's method + GRPCInterceptor *thisInterceptor = _thisInterceptor; + [thisInterceptor writeData:data]; } - (void)finish { - [_thisInterceptor finish]; + // retain this interceptor until the method exit to prevent deallocation of the interceptor within + // the interceptor's method + GRPCInterceptor *thisInterceptor = _thisInterceptor; + [thisInterceptor finish]; } - (void)cancel { - [_thisInterceptor cancel]; + // retain this interceptor until the method exit to prevent deallocation of the interceptor within + // the interceptor's method + GRPCInterceptor *thisInterceptor = _thisInterceptor; + [thisInterceptor cancel]; } - (void)receiveNextMessages:(NSUInteger)numberOfMessages { - [_thisInterceptor receiveNextMessages:numberOfMessages]; + // retain this interceptor until the method exit to prevent deallocation of the interceptor within + // the interceptor's method + GRPCInterceptor *thisInterceptor = _thisInterceptor; + [thisInterceptor receiveNextMessages:numberOfMessages]; } - (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata { if ([_thisInterceptor respondsToSelector:@selector(didReceiveInitialMetadata:)]) { - [_thisInterceptor didReceiveInitialMetadata:initialMetadata]; + // retain this interceptor until the method exit to prevent deallocation of the interceptor + // within the interceptor's method + GRPCInterceptor *thisInterceptor = _thisInterceptor; + [thisInterceptor didReceiveInitialMetadata:initialMetadata]; } } - (void)didReceiveData:(id)data { if ([_thisInterceptor respondsToSelector:@selector(didReceiveData:)]) { - [_thisInterceptor didReceiveData:data]; + // retain this interceptor until the method exit to prevent deallocation of the interceptor + // within the interceptor's method + GRPCInterceptor *thisInterceptor = _thisInterceptor; + [thisInterceptor didReceiveData:data]; } } - (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata error:(nullable NSError *)error { if ([_thisInterceptor respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { - [_thisInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; + // retain this interceptor until the method exit to prevent deallocation of the interceptor + // within the interceptor's method + GRPCInterceptor *thisInterceptor = _thisInterceptor; + [thisInterceptor didCloseWithTrailingMetadata:trailingMetadata error:error]; } } - (void)didWriteData { if ([_thisInterceptor respondsToSelector:@selector(didWriteData)]) { - [_thisInterceptor didWriteData]; + // retain this interceptor until the method exit to prevent deallocation of the interceptor + // within the interceptor's method + GRPCInterceptor *thisInterceptor = _thisInterceptor; + [thisInterceptor didWriteData]; } } diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m index ea01fcaf594..4c42ba80399 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCallInternal.m @@ -155,7 +155,7 @@ self->_initialMetadataPublished = YES; [self issueInitialMetadata:self->_call.responseHeaders]; } - [self issueClosedWithTrailingMetadata:self->_call.responseTrailers error:errorOrNil]; + [self issueCloseWithTrailingMetadata:self->_call.responseTrailers error:errorOrNil]; } // Clearing _call must happen *after* dispatching close in order to get trailing // metadata from _call. @@ -250,24 +250,40 @@ - (void)issueInitialMetadata:(NSDictionary *)initialMetadata { if (initialMetadata != nil) { - [_transportManager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; + // cannot directly call callback because this may not be running on manager's dispatch queue + GRPCTransportManager *copiedManager = _transportManager; + dispatch_async(copiedManager.dispatchQueue, ^{ + [copiedManager forwardPreviousInterceptorWithInitialMetadata:initialMetadata]; + }); } } - (void)issueMessage:(id)message { if (message != nil) { - [_transportManager forwardPreviousInterceptorWithData:message]; + // cannot directly call callback because this may not be running on manager's dispatch queue + GRPCTransportManager *copiedManager = _transportManager; + dispatch_async(copiedManager.dispatchQueue, ^{ + [copiedManager forwardPreviousInterceptorWithData:message]; + }); } } -- (void)issueClosedWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { - [_transportManager forwardPreviousInterceptorCloseWithTrailingMetadata:trailingMetadata - error:error]; - [_transportManager shutDown]; +- (void)issueCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { + // cannot directly call callback because this may not be running on manager's dispatch queue + GRPCTransportManager *copiedManager = _transportManager; + dispatch_async(copiedManager.dispatchQueue, ^{ + [copiedManager forwardPreviousInterceptorCloseWithTrailingMetadata:trailingMetadata + error:error]; + [copiedManager shutDown]; + }); } - (void)issueDidWriteData { - [_transportManager forwardPreviousInterceptorDidWriteData]; + // cannot directly call callback because this may not be running on manager's dispatch queue + GRPCTransportManager *copiedManager = _transportManager; + dispatch_async(copiedManager.dispatchQueue, ^{ + [copiedManager forwardPreviousInterceptorDidWriteData]; + }); } - (void)receiveNextMessages:(NSUInteger)numberOfMessages { diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h index 4574e51b39f..184aa287f0b 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.h +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.h @@ -35,6 +35,18 @@ NS_ASSUME_NONNULL_BEGIN @end +/** + * GRPCTransportManager is a helper class to forward messages between the last interceptor and the + * transport instance. + * + * All methods except the initializer of the class can only be called on the manager's dispatch + * queue. Since the manager's dispatch queue is the same as the transport's dispatch queue, it is + * also safe to call the manager's methods in the corresponding transport instance's methods that + * implement GRPCInterceptorInterface. + * + * When a transport instance is shutting down, it must call -shutDown method of its associated + * transport manager for proper clean-up. + */ @interface GRPCTransportManager : NSObject - (instancetype)initWithTransportID:(GRPCTransportID)transportID @@ -43,8 +55,6 @@ NS_ASSUME_NONNULL_BEGIN /** * Notify the manager that the transport has shut down and the manager should release references to * its response handler and stop forwarding requests/responses. - * - * The method can only be called by the manager's associated transport instance. */ - (void)shutDown; diff --git a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m index 3084ed9ee4e..81c7dd1de1e 100644 --- a/src/objective-c/GRPCClient/private/GRPCTransport+Private.m +++ b/src/objective-c/GRPCClient/private/GRPCTransport+Private.m @@ -63,23 +63,38 @@ format:@"Interceptors cannot change the call option 'transport'"]; return; } - [_transport startWithRequestOptions:requestOptions callOptions:callOptions]; + // retain the transport instance until the method exit to prevent deallocation of the transport + // instance within the method + GRPCTransport *transport = _transport; + [transport startWithRequestOptions:requestOptions callOptions:callOptions]; } - (void)writeData:(id)data { - [_transport writeData:data]; + // retain the transport instance until the method exit to prevent deallocation of the transport + // instance within the method + GRPCTransport *transport = _transport; + [transport writeData:data]; } - (void)finish { - [_transport finish]; + // retain the transport instance until the method exit to prevent deallocation of the transport + // instance within the method + GRPCTransport *transport = _transport; + [transport finish]; } - (void)cancel { - [_transport cancel]; + // retain the transport instance until the method exit to prevent deallocation of the transport + // instance within the method + GRPCTransport *transport = _transport; + [transport cancel]; } - (void)receiveNextMessages:(NSUInteger)numberOfMessages { - [_transport receiveNextMessages:numberOfMessages]; + // retain the transport instance until the method exit to prevent deallocation of the transport + // instance within the method + GRPCTransport *transport = _transport; + [transport receiveNextMessages:numberOfMessages]; } /** Forward initial metadata to the previous interceptor in the chain */ From c9376b4e0bbd14808636ad0410e0b0387431d792 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Mon, 12 Aug 2019 11:07:22 -0400 Subject: [PATCH 1497/1555] Use cycle clock instead of clock monotonic to measure call latency. This removes two more getttime syscalls from the hot path, when cycle clock is enabled. --- .../ext/filters/client_channel/client_channel.cc | 5 +++-- .../client_channel/health/health_check_client.cc | 4 ++-- src/core/ext/filters/client_channel/subchannel.h | 3 ++- src/core/lib/channel/channel_stack.h | 3 ++- src/core/lib/gpr/time_precise.cc | 15 +++++++++++++++ src/core/lib/gpr/time_precise.h | 1 + src/core/lib/surface/call.cc | 6 +++--- test/core/channel/channel_stack_test.cc | 16 ++++++++-------- test/cpp/microbenchmarks/bm_call_create.cc | 2 +- 9 files changed, 37 insertions(+), 18 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 40ac1f22059..51210107872 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -720,7 +720,7 @@ class CallData { grpc_deadline_state deadline_state_; grpc_slice path_; // Request path. - gpr_timespec call_start_time_; + gpr_cycle_counter call_start_time_; grpc_millis deadline_; Arena* arena_; grpc_call_stack* owning_call_; @@ -3730,7 +3730,8 @@ void CallData::ApplyServiceConfigToCallLocked(grpc_call_element* elem) { // from the client API, reset the deadline timer. if (chand->deadline_checking_enabled() && method_params_->timeout() != 0) { const grpc_millis per_method_deadline = - grpc_timespec_to_millis_round_up(call_start_time_) + + grpc_timespec_to_millis_round_up( + gpr_cycle_counter_to_time(call_start_time_)) + method_params_->timeout(); if (per_method_deadline < deadline_) { deadline_ = per_method_deadline; diff --git a/src/core/ext/filters/client_channel/health/health_check_client.cc b/src/core/ext/filters/client_channel/health/health_check_client.cc index 026831645c0..2662d8466b6 100644 --- a/src/core/ext/filters/client_channel/health/health_check_client.cc +++ b/src/core/ext/filters/client_channel/health/health_check_client.cc @@ -304,8 +304,8 @@ void HealthCheckClient::CallState::StartCall() { health_check_client_->connected_subchannel_, &pollent_, GRPC_MDSTR_SLASH_GRPC_DOT_HEALTH_DOT_V1_DOT_HEALTH_SLASH_WATCH, - gpr_now(GPR_CLOCK_MONOTONIC), // start_time - GRPC_MILLIS_INF_FUTURE, // deadline + gpr_get_cycle_counter(), // start_time + GRPC_MILLIS_INF_FUTURE, // deadline arena_, context_, &call_combiner_, diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h index d745bc8ddc2..c178401ca8a 100644 --- a/src/core/ext/filters/client_channel/subchannel.h +++ b/src/core/ext/filters/client_channel/subchannel.h @@ -26,6 +26,7 @@ #include "src/core/ext/filters/client_channel/subchannel_pool_interface.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/gpr/time_precise.h" #include "src/core/lib/gprpp/arena.h" #include "src/core/lib/gprpp/map.h" #include "src/core/lib/gprpp/ref_counted.h" @@ -104,7 +105,7 @@ class SubchannelCall { RefCountedPtr connected_subchannel; grpc_polling_entity* pollent; grpc_slice path; - gpr_timespec start_time; + gpr_cycle_counter start_time; grpc_millis deadline; Arena* arena; grpc_call_context_element* context; diff --git a/src/core/lib/channel/channel_stack.h b/src/core/lib/channel/channel_stack.h index a7c28d059f3..f7be806b695 100644 --- a/src/core/lib/channel/channel_stack.h +++ b/src/core/lib/channel/channel_stack.h @@ -42,6 +42,7 @@ #include #include "src/core/lib/debug/trace.h" +#include "src/core/lib/gpr/time_precise.h" #include "src/core/lib/gprpp/arena.h" #include "src/core/lib/iomgr/call_combiner.h" #include "src/core/lib/iomgr/polling_entity.h" @@ -67,7 +68,7 @@ typedef struct { const void* server_transport_data; grpc_call_context_element* context; const grpc_slice& path; - gpr_timespec start_time; + gpr_cycle_counter start_time; grpc_millis deadline; grpc_core::Arena* arena; grpc_core::CallCombiner* call_combiner; diff --git a/src/core/lib/gpr/time_precise.cc b/src/core/lib/gpr/time_precise.cc index 9d11c66831c..56b00d119ad 100644 --- a/src/core/lib/gpr/time_precise.cc +++ b/src/core/lib/gpr/time_precise.cc @@ -122,6 +122,16 @@ gpr_timespec gpr_cycle_counter_to_time(gpr_cycle_counter cycles) { return ts; } +gpr_timespec gpr_cycle_counter_sub(gpr_cycle_counter a, gpr_cycle_counter b) { + double secs = static_cast(a - b) / cycles_per_second; + gpr_timespec ts; + ts.tv_sec = static_cast(secs); + ts.tv_nsec = static_cast(GPR_NS_PER_SEC * + (secs - static_cast(ts.tv_sec))); + ts.clock_type = GPR_TIMESPAN; + return ts; +} + void gpr_precise_clock_now(gpr_timespec* clk) { int64_t counter = gpr_get_cycle_counter(); *clk = gpr_cycle_counter_to_time(counter); @@ -146,4 +156,9 @@ void gpr_precise_clock_now(gpr_timespec* clk) { *clk = gpr_now(GPR_CLOCK_REALTIME); clk->clock_type = GPR_CLOCK_PRECISE; } + +gpr_timespec gpr_cycle_counter_sub(gpr_cycle_counter a, gpr_cycle_counter b) { + return gpr_time_sub(gpr_cycle_counter_to_time(a), + gpr_cycle_counter_to_time(b)); +} #endif /* GPR_CYCLE_COUNTER_FALLBACK */ diff --git a/src/core/lib/gpr/time_precise.h b/src/core/lib/gpr/time_precise.h index ce16bafab2d..55eceb6c8ba 100644 --- a/src/core/lib/gpr/time_precise.h +++ b/src/core/lib/gpr/time_precise.h @@ -61,5 +61,6 @@ gpr_cycle_counter gpr_get_cycle_counter(); void gpr_precise_clock_init(void); void gpr_precise_clock_now(gpr_timespec* clk); gpr_timespec gpr_cycle_counter_to_time(gpr_cycle_counter cycles); +gpr_timespec gpr_cycle_counter_sub(gpr_cycle_counter a, gpr_cycle_counter b); #endif /* GRPC_CORE_LIB_GPR_TIME_PRECISE_H */ diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 5388cbd75a9..435f536b3df 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -36,6 +36,7 @@ #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/alloc.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/time_precise.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/arena.h" #include "src/core/lib/gprpp/manual_constructor.h" @@ -154,7 +155,7 @@ struct grpc_call { grpc_completion_queue* cq; grpc_polling_entity pollent; grpc_channel* channel; - gpr_timespec start_time = gpr_now(GPR_CLOCK_MONOTONIC); + gpr_cycle_counter start_time = gpr_get_cycle_counter(); /* parent_call* */ gpr_atm parent_call_atm = 0; child_call* child = nullptr; @@ -552,8 +553,7 @@ static void destroy_call(void* call, grpc_error* error) { &(c->final_info.error_string)); GRPC_ERROR_UNREF(status_error); c->final_info.stats.latency = - gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), c->start_time); - + gpr_cycle_counter_sub(gpr_get_cycle_counter(), c->start_time); grpc_call_stack_destroy(CALL_STACK_FROM_CALL(c), &c->final_info, GRPC_CLOSURE_INIT(&c->release_call, release_call, c, grpc_schedule_on_exec_ctx)); diff --git a/test/core/channel/channel_stack_test.cc b/test/core/channel/channel_stack_test.cc index 14726336f92..3f15a0010bd 100644 --- a/test/core/channel/channel_stack_test.cc +++ b/test/core/channel/channel_stack_test.cc @@ -117,14 +117,14 @@ static void test_create_channel_stack(void) { call_stack = static_cast(gpr_malloc(channel_stack->call_stack_size)); const grpc_call_element_args args = { - call_stack, /* call_stack */ - nullptr, /* server_transport_data */ - nullptr, /* context */ - path, /* path */ - gpr_now(GPR_CLOCK_MONOTONIC), /* start_time */ - GRPC_MILLIS_INF_FUTURE, /* deadline */ - nullptr, /* arena */ - nullptr, /* call_combiner */ + call_stack, /* call_stack */ + nullptr, /* server_transport_data */ + nullptr, /* context */ + path, /* path */ + gpr_get_cycle_counter(), /* start_time */ + GRPC_MILLIS_INF_FUTURE, /* deadline */ + nullptr, /* arena */ + nullptr, /* call_combiner */ }; grpc_error* error = grpc_call_stack_init(channel_stack, 1, free_call, call_stack, &args); diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 99ea1e053e9..e3c853d4430 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -523,7 +523,7 @@ static void BM_IsolatedFilter(benchmark::State& state) { grpc_call_stack* call_stack = static_cast(gpr_zalloc(channel_stack->call_stack_size)); grpc_millis deadline = GRPC_MILLIS_INF_FUTURE; - gpr_timespec start_time = gpr_now(GPR_CLOCK_MONOTONIC); + gpr_cycle_counter start_time = gpr_get_cycle_counter(); grpc_slice method = grpc_slice_from_static_string("/foo/bar"); grpc_call_final_info final_info; TestOp test_op_data; From 81a29ae1a62bb8e7877ea100cc975ea27d431a7e Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Mon, 12 Aug 2019 17:32:47 -0400 Subject: [PATCH 1498/1555] Mark double-second local variables as const. --- src/core/lib/gpr/time_precise.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/lib/gpr/time_precise.cc b/src/core/lib/gpr/time_precise.cc index 56b00d119ad..3223a84c7ad 100644 --- a/src/core/lib/gpr/time_precise.cc +++ b/src/core/lib/gpr/time_precise.cc @@ -113,7 +113,8 @@ void gpr_precise_clock_init(void) { } gpr_timespec gpr_cycle_counter_to_time(gpr_cycle_counter cycles) { - double secs = static_cast(cycles - start_cycle) / cycles_per_second; + const double secs = + static_cast(cycles - start_cycle) / cycles_per_second; gpr_timespec ts; ts.tv_sec = static_cast(secs); ts.tv_nsec = static_cast(GPR_NS_PER_SEC * @@ -123,7 +124,7 @@ gpr_timespec gpr_cycle_counter_to_time(gpr_cycle_counter cycles) { } gpr_timespec gpr_cycle_counter_sub(gpr_cycle_counter a, gpr_cycle_counter b) { - double secs = static_cast(a - b) / cycles_per_second; + const double secs = static_cast(a - b) / cycles_per_second; gpr_timespec ts; ts.tv_sec = static_cast(secs); ts.tv_nsec = static_cast(GPR_NS_PER_SEC * From 7b84f81a8ca570c3d1e74bbb98d8d38de2bce3c7 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Tue, 13 Aug 2019 15:04:03 -0400 Subject: [PATCH 1499/1555] Add grpc_cycle_counter_to_millis(). --- .../filters/client_channel/client_channel.cc | 3 +-- src/core/lib/iomgr/exec_ctx.cc | 17 +++++++++++++++++ src/core/lib/iomgr/exec_ctx.h | 3 +++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 51210107872..0a9b5ac43fb 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -3730,8 +3730,7 @@ void CallData::ApplyServiceConfigToCallLocked(grpc_call_element* elem) { // from the client API, reset the deadline timer. if (chand->deadline_checking_enabled() && method_params_->timeout() != 0) { const grpc_millis per_method_deadline = - grpc_timespec_to_millis_round_up( - gpr_cycle_counter_to_time(call_start_time_)) + + grpc_cycle_counter_to_millis_round_up(call_start_time_) + method_params_->timeout(); if (per_method_deadline < deadline_) { deadline_ = per_method_deadline; diff --git a/src/core/lib/iomgr/exec_ctx.cc b/src/core/lib/iomgr/exec_ctx.cc index a847b4dcefc..5cb778de98e 100644 --- a/src/core/lib/iomgr/exec_ctx.cc +++ b/src/core/lib/iomgr/exec_ctx.cc @@ -52,6 +52,7 @@ static void exec_ctx_sched(grpc_closure* closure, grpc_error* error) { } static gpr_timespec g_start_time; +static gpr_cycle_counter g_start_cycle; static grpc_millis timespec_to_millis_round_down(gpr_timespec ts) { ts = gpr_time_sub(ts, g_start_time); @@ -101,6 +102,16 @@ grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec ts) { gpr_convert_clock_type(ts, g_start_time.clock_type)); } +grpc_millis grpc_cycle_counter_to_millis_round_down(gpr_cycle_counter cycles) { + return timespec_to_millis_round_down( + gpr_time_add(g_start_time, gpr_cycle_counter_sub(cycles, g_start_cycle))); +} + +grpc_millis grpc_cycle_counter_to_millis_round_up(gpr_cycle_counter cycles) { + return timespec_to_millis_round_up( + gpr_time_add(g_start_time, gpr_cycle_counter_sub(cycles, g_start_cycle))); +} + static const grpc_closure_scheduler_vtable exec_ctx_scheduler_vtable = { exec_ctx_run, exec_ctx_sched, "exec_ctx"}; static grpc_closure_scheduler exec_ctx_scheduler = {&exec_ctx_scheduler_vtable}; @@ -117,7 +128,13 @@ void ExecCtx::TestOnlyGlobalInit(gpr_timespec new_val) { } void ExecCtx::GlobalInit(void) { + // gpr_now(GPR_CLOCK_MONOTONIC) incurs a syscall. We don't actually know the + // exact cycle the time was captured, so we use the average of cycles before + // and after the syscall as the starting cycle. + const gpr_cycle_counter cycle_before = gpr_get_cycle_counter(); g_start_time = gpr_now(GPR_CLOCK_MONOTONIC); + const gpr_cycle_counter cycle_after = gpr_get_cycle_counter(); + g_start_cycle = (cycle_before + cycle_after) / 2; gpr_tls_init(&exec_ctx_); } diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h index daf019c41ee..0ccf2a878bf 100644 --- a/src/core/lib/iomgr/exec_ctx.h +++ b/src/core/lib/iomgr/exec_ctx.h @@ -26,6 +26,7 @@ #include #include +#include "src/core/lib/gpr/time_precise.h" #include "src/core/lib/gpr/tls.h" #include "src/core/lib/gprpp/fork.h" #include "src/core/lib/iomgr/closure.h" @@ -58,6 +59,8 @@ extern grpc_closure_scheduler* grpc_schedule_on_exec_ctx; gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_clock_type clock); grpc_millis grpc_timespec_to_millis_round_down(gpr_timespec timespec); grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec timespec); +grpc_millis grpc_cycle_counter_to_millis_round_down(gpr_cycle_counter cycles); +grpc_millis grpc_cycle_counter_to_millis_round_up(gpr_cycle_counter cycles); namespace grpc_core { /** Execution context. From 4b2b00b35bb8be4752b4b986640ef76dd0eadc40 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Tue, 13 Aug 2019 15:25:34 -0400 Subject: [PATCH 1500/1555] Optimize cycle to millis conversion by bypassing sub+add. --- src/core/lib/iomgr/exec_ctx.cc | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/core/lib/iomgr/exec_ctx.cc b/src/core/lib/iomgr/exec_ctx.cc index 5cb778de98e..730237a250d 100644 --- a/src/core/lib/iomgr/exec_ctx.cc +++ b/src/core/lib/iomgr/exec_ctx.cc @@ -54,8 +54,7 @@ static void exec_ctx_sched(grpc_closure* closure, grpc_error* error) { static gpr_timespec g_start_time; static gpr_cycle_counter g_start_cycle; -static grpc_millis timespec_to_millis_round_down(gpr_timespec ts) { - ts = gpr_time_sub(ts, g_start_time); +static grpc_millis timespan_to_millis_round_down(gpr_timespec ts) { double x = GPR_MS_PER_SEC * static_cast(ts.tv_sec) + static_cast(ts.tv_nsec) / GPR_NS_PER_MS; if (x < 0) return 0; @@ -63,8 +62,11 @@ static grpc_millis timespec_to_millis_round_down(gpr_timespec ts) { return static_cast(x); } -static grpc_millis timespec_to_millis_round_up(gpr_timespec ts) { - ts = gpr_time_sub(ts, g_start_time); +static grpc_millis timespec_to_millis_round_down(gpr_timespec ts) { + return timespan_to_millis_round_down(gpr_time_sub(ts, g_start_time)); +} + +static grpc_millis timespan_to_millis_round_up(gpr_timespec ts) { double x = GPR_MS_PER_SEC * static_cast(ts.tv_sec) + static_cast(ts.tv_nsec) / GPR_NS_PER_MS + static_cast(GPR_NS_PER_SEC - 1) / @@ -74,6 +76,10 @@ static grpc_millis timespec_to_millis_round_up(gpr_timespec ts) { return static_cast(x); } +static grpc_millis timespec_to_millis_round_up(gpr_timespec ts) { + return timespan_to_millis_round_up(gpr_time_sub(ts, g_start_time)); +} + gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_clock_type clock_type) { // special-case infinities as grpc_millis can be 32bit on some platforms @@ -103,13 +109,13 @@ grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec ts) { } grpc_millis grpc_cycle_counter_to_millis_round_down(gpr_cycle_counter cycles) { - return timespec_to_millis_round_down( - gpr_time_add(g_start_time, gpr_cycle_counter_sub(cycles, g_start_cycle))); + return timespan_to_millis_round_down( + gpr_cycle_counter_sub(cycles, g_start_cycle)); } grpc_millis grpc_cycle_counter_to_millis_round_up(gpr_cycle_counter cycles) { - return timespec_to_millis_round_up( - gpr_time_add(g_start_time, gpr_cycle_counter_sub(cycles, g_start_cycle))); + return timespan_to_millis_round_up( + gpr_cycle_counter_sub(cycles, g_start_cycle)); } static const grpc_closure_scheduler_vtable exec_ctx_scheduler_vtable = { From c965ca14940dda1606109d959204d3eaeef9c1d6 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Mon, 9 Sep 2019 10:12:39 -0700 Subject: [PATCH 1501/1555] Pull out configuration from ssl_utils --- BUILD | 2 ++ BUILD.gn | 2 ++ CMakeLists.txt | 2 ++ Makefile | 3 ++ build.yaml | 2 ++ config.m4 | 1 + config.w32 | 1 + gRPC-Core.podspec | 3 ++ grpc.gemspec | 2 ++ grpc.gyp | 1 + package.xml | 2 ++ .../interop/app/src/main/cpp/grpc-interop.cc | 2 +- .../security/security_connector/ssl_utils.cc | 13 +------- .../security/security_connector/ssl_utils.h | 4 +-- .../security_connector/ssl_utils_config.cc | 32 +++++++++++++++++++ .../security_connector/ssl_utils_config.h | 30 +++++++++++++++++ .../CronetTests/CoreCronetEnd2EndTests.mm | 2 +- src/python/grpcio/grpc_core_dependencies.py | 1 + test/core/bad_ssl/bad_ssl_test.cc | 2 +- test/core/end2end/fixtures/h2_spiffe.cc | 2 +- test/core/end2end/fixtures/h2_ssl.cc | 2 +- .../end2end/fixtures/h2_ssl_cred_reload.cc | 2 +- test/core/end2end/fixtures/h2_ssl_proxy.cc | 2 +- test/core/end2end/h2_ssl_cert_test.cc | 2 +- .../core/end2end/h2_ssl_session_reuse_test.cc | 2 +- test/core/http/httpscli_test.cc | 2 +- tools/doxygen/Doxyfile.core.internal | 2 ++ 27 files changed, 98 insertions(+), 25 deletions(-) create mode 100644 src/core/lib/security/security_connector/ssl_utils_config.cc create mode 100644 src/core/lib/security/security_connector/ssl_utils_config.h diff --git a/BUILD b/BUILD index d911050b1be..576325c82f1 100644 --- a/BUILD +++ b/BUILD @@ -1580,6 +1580,7 @@ grpc_cc_library( "src/core/lib/security/security_connector/security_connector.cc", "src/core/lib/security/security_connector/ssl/ssl_security_connector.cc", "src/core/lib/security/security_connector/ssl_utils.cc", + "src/core/lib/security/security_connector/ssl_utils_config.cc", "src/core/lib/security/security_connector/tls/spiffe_security_connector.cc", "src/core/lib/security/transport/client_auth_filter.cc", "src/core/lib/security/transport/secure_endpoint.cc", @@ -1617,6 +1618,7 @@ grpc_cc_library( "src/core/lib/security/security_connector/security_connector.h", "src/core/lib/security/security_connector/ssl/ssl_security_connector.h", "src/core/lib/security/security_connector/ssl_utils.h", + "src/core/lib/security/security_connector/ssl_utils_config.h", "src/core/lib/security/security_connector/tls/spiffe_security_connector.h", "src/core/lib/security/transport/auth_filters.h", "src/core/lib/security/transport/secure_endpoint.h", diff --git a/BUILD.gn b/BUILD.gn index 771e968f366..3d0363cf175 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -749,6 +749,8 @@ config("grpc_config") { "src/core/lib/security/security_connector/ssl/ssl_security_connector.h", "src/core/lib/security/security_connector/ssl_utils.cc", "src/core/lib/security/security_connector/ssl_utils.h", + "src/core/lib/security/security_connector/ssl_utils_config.cc", + "src/core/lib/security/security_connector/ssl_utils_config.h", "src/core/lib/security/security_connector/tls/spiffe_security_connector.cc", "src/core/lib/security/security_connector/tls/spiffe_security_connector.h", "src/core/lib/security/transport/auth_filters.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 599f1441583..08a49697750 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1194,6 +1194,7 @@ add_library(grpc src/core/lib/security/security_connector/security_connector.cc src/core/lib/security/security_connector/ssl/ssl_security_connector.cc src/core/lib/security/security_connector/ssl_utils.cc + src/core/lib/security/security_connector/ssl_utils_config.cc src/core/lib/security/security_connector/tls/spiffe_security_connector.cc src/core/lib/security/transport/client_auth_filter.cc src/core/lib/security/transport/secure_endpoint.cc @@ -1717,6 +1718,7 @@ add_library(grpc_cronet src/core/lib/security/security_connector/security_connector.cc src/core/lib/security/security_connector/ssl/ssl_security_connector.cc src/core/lib/security/security_connector/ssl_utils.cc + src/core/lib/security/security_connector/ssl_utils_config.cc src/core/lib/security/security_connector/tls/spiffe_security_connector.cc src/core/lib/security/transport/client_auth_filter.cc src/core/lib/security/transport/secure_endpoint.cc diff --git a/Makefile b/Makefile index e666a19eb79..b24a27acfe6 100644 --- a/Makefile +++ b/Makefile @@ -3770,6 +3770,7 @@ LIBGRPC_SRC = \ src/core/lib/security/security_connector/security_connector.cc \ src/core/lib/security/security_connector/ssl/ssl_security_connector.cc \ src/core/lib/security/security_connector/ssl_utils.cc \ + src/core/lib/security/security_connector/ssl_utils_config.cc \ src/core/lib/security/security_connector/tls/spiffe_security_connector.cc \ src/core/lib/security/transport/client_auth_filter.cc \ src/core/lib/security/transport/secure_endpoint.cc \ @@ -4288,6 +4289,7 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/security/security_connector/security_connector.cc \ src/core/lib/security/security_connector/ssl/ssl_security_connector.cc \ src/core/lib/security/security_connector/ssl_utils.cc \ + src/core/lib/security/security_connector/ssl_utils_config.cc \ src/core/lib/security/security_connector/tls/spiffe_security_connector.cc \ src/core/lib/security/transport/client_auth_filter.cc \ src/core/lib/security/transport/secure_endpoint.cc \ @@ -22686,6 +22688,7 @@ src/core/lib/security/security_connector/local/local_security_connector.cc: $(OP src/core/lib/security/security_connector/security_connector.cc: $(OPENSSL_DEP) src/core/lib/security/security_connector/ssl/ssl_security_connector.cc: $(OPENSSL_DEP) src/core/lib/security/security_connector/ssl_utils.cc: $(OPENSSL_DEP) +src/core/lib/security/security_connector/ssl_utils_config.cc: $(OPENSSL_DEP) src/core/lib/security/security_connector/tls/spiffe_security_connector.cc: $(OPENSSL_DEP) src/core/lib/security/transport/client_auth_filter.cc: $(OPENSSL_DEP) src/core/lib/security/transport/secure_endpoint.cc: $(OPENSSL_DEP) diff --git a/build.yaml b/build.yaml index 15203f242c9..dc5fd4236da 100644 --- a/build.yaml +++ b/build.yaml @@ -1274,6 +1274,7 @@ filegroups: - src/core/lib/security/security_connector/security_connector.h - src/core/lib/security/security_connector/ssl/ssl_security_connector.h - src/core/lib/security/security_connector/ssl_utils.h + - src/core/lib/security/security_connector/ssl_utils_config.h - src/core/lib/security/security_connector/tls/spiffe_security_connector.h - src/core/lib/security/transport/auth_filters.h - src/core/lib/security/transport/secure_endpoint.h @@ -1309,6 +1310,7 @@ filegroups: - src/core/lib/security/security_connector/security_connector.cc - src/core/lib/security/security_connector/ssl/ssl_security_connector.cc - src/core/lib/security/security_connector/ssl_utils.cc + - src/core/lib/security/security_connector/ssl_utils_config.cc - src/core/lib/security/security_connector/tls/spiffe_security_connector.cc - src/core/lib/security/transport/client_auth_filter.cc - src/core/lib/security/transport/secure_endpoint.cc diff --git a/config.m4 b/config.m4 index efa86576f84..15455a8e114 100644 --- a/config.m4 +++ b/config.m4 @@ -304,6 +304,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/security/security_connector/security_connector.cc \ src/core/lib/security/security_connector/ssl/ssl_security_connector.cc \ src/core/lib/security/security_connector/ssl_utils.cc \ + src/core/lib/security/security_connector/ssl_utils_config.cc \ src/core/lib/security/security_connector/tls/spiffe_security_connector.cc \ src/core/lib/security/transport/client_auth_filter.cc \ src/core/lib/security/transport/secure_endpoint.cc \ diff --git a/config.w32 b/config.w32 index 13b5f1350f0..f5adca6fb53 100644 --- a/config.w32 +++ b/config.w32 @@ -274,6 +274,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\security\\security_connector\\security_connector.cc " + "src\\core\\lib\\security\\security_connector\\ssl\\ssl_security_connector.cc " + "src\\core\\lib\\security\\security_connector\\ssl_utils.cc " + + "src\\core\\lib\\security\\security_connector\\ssl_utils_config.cc " + "src\\core\\lib\\security\\security_connector\\tls\\spiffe_security_connector.cc " + "src\\core\\lib\\security\\transport\\client_auth_filter.cc " + "src\\core\\lib\\security\\transport\\secure_endpoint.cc " + diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 658a3ad6158..3770425e5e3 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -310,6 +310,7 @@ Pod::Spec.new do |s| 'src/core/lib/security/security_connector/security_connector.h', 'src/core/lib/security/security_connector/ssl/ssl_security_connector.h', 'src/core/lib/security/security_connector/ssl_utils.h', + 'src/core/lib/security/security_connector/ssl_utils_config.h', 'src/core/lib/security/security_connector/tls/spiffe_security_connector.h', 'src/core/lib/security/transport/auth_filters.h', 'src/core/lib/security/transport/secure_endpoint.h', @@ -802,6 +803,7 @@ Pod::Spec.new do |s| 'src/core/lib/security/security_connector/security_connector.cc', 'src/core/lib/security/security_connector/ssl/ssl_security_connector.cc', 'src/core/lib/security/security_connector/ssl_utils.cc', + 'src/core/lib/security/security_connector/ssl_utils_config.cc', 'src/core/lib/security/security_connector/tls/spiffe_security_connector.cc', 'src/core/lib/security/transport/client_auth_filter.cc', 'src/core/lib/security/transport/secure_endpoint.cc', @@ -1044,6 +1046,7 @@ Pod::Spec.new do |s| 'src/core/lib/security/security_connector/security_connector.h', 'src/core/lib/security/security_connector/ssl/ssl_security_connector.h', 'src/core/lib/security/security_connector/ssl_utils.h', + 'src/core/lib/security/security_connector/ssl_utils_config.h', 'src/core/lib/security/security_connector/tls/spiffe_security_connector.h', 'src/core/lib/security/transport/auth_filters.h', 'src/core/lib/security/transport/secure_endpoint.h', diff --git a/grpc.gemspec b/grpc.gemspec index 1b705016cee..431dd9f8f7e 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -240,6 +240,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/security/security_connector/security_connector.h ) s.files += %w( src/core/lib/security/security_connector/ssl/ssl_security_connector.h ) s.files += %w( src/core/lib/security/security_connector/ssl_utils.h ) + s.files += %w( src/core/lib/security/security_connector/ssl_utils_config.h ) s.files += %w( src/core/lib/security/security_connector/tls/spiffe_security_connector.h ) s.files += %w( src/core/lib/security/transport/auth_filters.h ) s.files += %w( src/core/lib/security/transport/secure_endpoint.h ) @@ -732,6 +733,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/security/security_connector/security_connector.cc ) s.files += %w( src/core/lib/security/security_connector/ssl/ssl_security_connector.cc ) s.files += %w( src/core/lib/security/security_connector/ssl_utils.cc ) + s.files += %w( src/core/lib/security/security_connector/ssl_utils_config.cc ) s.files += %w( src/core/lib/security/security_connector/tls/spiffe_security_connector.cc ) s.files += %w( src/core/lib/security/transport/client_auth_filter.cc ) s.files += %w( src/core/lib/security/transport/secure_endpoint.cc ) diff --git a/grpc.gyp b/grpc.gyp index 5468675e768..b0168dc15df 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -504,6 +504,7 @@ 'src/core/lib/security/security_connector/security_connector.cc', 'src/core/lib/security/security_connector/ssl/ssl_security_connector.cc', 'src/core/lib/security/security_connector/ssl_utils.cc', + 'src/core/lib/security/security_connector/ssl_utils_config.cc', 'src/core/lib/security/security_connector/tls/spiffe_security_connector.cc', 'src/core/lib/security/transport/client_auth_filter.cc', 'src/core/lib/security/transport/secure_endpoint.cc', diff --git a/package.xml b/package.xml index 385a57c77ea..fb43cf9c4d7 100644 --- a/package.xml +++ b/package.xml @@ -245,6 +245,7 @@ + @@ -737,6 +738,7 @@ + diff --git a/src/android/test/interop/app/src/main/cpp/grpc-interop.cc b/src/android/test/interop/app/src/main/cpp/grpc-interop.cc index b5075529be2..15cf44fb88d 100644 --- a/src/android/test/interop/app/src/main/cpp/grpc-interop.cc +++ b/src/android/test/interop/app/src/main/cpp/grpc-interop.cc @@ -19,7 +19,7 @@ #include #include -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/cpp/interop/interop_client.h" extern "C" JNIEXPORT void JNICALL diff --git a/src/core/lib/security/security_connector/ssl_utils.cc b/src/core/lib/security/security_connector/ssl_utils.cc index ebb4a3f9ee8..bacd31a1f30 100644 --- a/src/core/lib/security/security_connector/ssl_utils.cc +++ b/src/core/lib/security/security_connector/ssl_utils.cc @@ -28,12 +28,12 @@ #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/context/security_context.h" #include "src/core/lib/security/security_connector/load_system_roots.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "src/core/tsi/ssl_transport_security.h" /* -- Constants. -- */ @@ -45,17 +45,6 @@ static const char* installed_roots_path = INSTALL_PREFIX "/share/grpc/roots.pem"; #endif -/** Config variable that points to the default SSL roots file. This file - must be a PEM encoded file with all the roots such as the one that can be - downloaded from https://pki.google.com/roots.pem. */ -GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_default_ssl_roots_file_path, "", - "Path to the default SSL roots file."); - -/** Config variable used as a flag to enable/disable loading system root - certificates from the OS trust store. */ -GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_not_use_system_ssl_roots, false, - "Disable loading system root certificates."); - #ifndef TSI_OPENSSL_ALPN_SUPPORT #define TSI_OPENSSL_ALPN_SUPPORT 1 #endif diff --git a/src/core/lib/security/security_connector/ssl_utils.h b/src/core/lib/security/security_connector/ssl_utils.h index 29366b309e8..c13dd90a932 100644 --- a/src/core/lib/security/security_connector/ssl_utils.h +++ b/src/core/lib/security/security_connector/ssl_utils.h @@ -31,13 +31,11 @@ #include "src/core/lib/gprpp/string_view.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/security/security_connector/security_connector.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "src/core/tsi/ssl_transport_security.h" #include "src/core/tsi/transport_security.h" #include "src/core/tsi/transport_security_interface.h" -GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_default_ssl_roots_file_path); -GPR_GLOBAL_CONFIG_DECLARE_BOOL(grpc_not_use_system_ssl_roots); - /* --- Util --- */ /* --- URL schemes. --- */ diff --git a/src/core/lib/security/security_connector/ssl_utils_config.cc b/src/core/lib/security/security_connector/ssl_utils_config.cc new file mode 100644 index 00000000000..2d056a781fd --- /dev/null +++ b/src/core/lib/security/security_connector/ssl_utils_config.cc @@ -0,0 +1,32 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/security/security_connector/ssl_utils_config.h" + +/** Config variable that points to the default SSL roots file. This file + must be a PEM encoded file with all the roots such as the one that can be + downloaded from https://pki.google.com/roots.pem. */ +GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_default_ssl_roots_file_path, "", + "Path to the default SSL roots file."); + +/** Config variable used as a flag to enable/disable loading system root + certificates from the OS trust store. */ +GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_not_use_system_ssl_roots, false, + "Disable loading system root certificates."); diff --git a/src/core/lib/security/security_connector/ssl_utils_config.h b/src/core/lib/security/security_connector/ssl_utils_config.h new file mode 100644 index 00000000000..efaf497ab1e --- /dev/null +++ b/src/core/lib/security/security_connector/ssl_utils_config.h @@ -0,0 +1,30 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_SSL_UTILS_CONFIG_H +#define GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_SSL_UTILS_CONFIG_H + +#include + +#include "src/core/lib/gprpp/global_config.h" + +GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_default_ssl_roots_file_path); +GPR_GLOBAL_CONFIG_DECLARE_BOOL(grpc_not_use_system_ssl_roots); + +#endif /* GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_SSL_UTILS_CONFIG_H \ + */ diff --git a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm index ad426014a5b..c3963874f77 100644 --- a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm +++ b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm @@ -41,7 +41,7 @@ #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 6eb8bc8c9c1..9ef13c117ee 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -273,6 +273,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/security/security_connector/security_connector.cc', 'src/core/lib/security/security_connector/ssl/ssl_security_connector.cc', 'src/core/lib/security/security_connector/ssl_utils.cc', + 'src/core/lib/security/security_connector/ssl_utils_config.cc', 'src/core/lib/security/security_connector/tls/spiffe_security_connector.cc', 'src/core/lib/security/transport/client_auth_filter.cc', 'src/core/lib/security/transport/secure_endpoint.cc', diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc index deae9072613..0480815443a 100644 --- a/test/core/bad_ssl/bad_ssl_test.cc +++ b/test/core/bad_ssl/bad_ssl_test.cc @@ -28,7 +28,7 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/memory.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" diff --git a/test/core/end2end/fixtures/h2_spiffe.cc b/test/core/end2end/fixtures/h2_spiffe.cc index 37fb44b5ad6..c56a13b17a0 100644 --- a/test/core/end2end/fixtures/h2_spiffe.cc +++ b/test/core/end2end/fixtures/h2_spiffe.cc @@ -35,7 +35,7 @@ #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" diff --git a/test/core/end2end/fixtures/h2_ssl.cc b/test/core/end2end/fixtures/h2_ssl.cc index cb55bb72061..4e09bccd0a3 100644 --- a/test/core/end2end/fixtures/h2_ssl.cc +++ b/test/core/end2end/fixtures/h2_ssl.cc @@ -29,7 +29,7 @@ #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" diff --git a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc index 2a9591845b9..e5a05570809 100644 --- a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc +++ b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc @@ -29,7 +29,7 @@ #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.cc b/test/core/end2end/fixtures/h2_ssl_proxy.cc index b16ffa1b8b8..77420e38b3a 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.cc +++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc @@ -28,7 +28,7 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/end2end/fixtures/proxy.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc index 34a9ef760b5..2b97ab3d3f7 100644 --- a/test/core/end2end/h2_ssl_cert_test.cc +++ b/test/core/end2end/h2_ssl_cert_test.cc @@ -29,7 +29,7 @@ #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/h2_ssl_session_reuse_test.cc b/test/core/end2end/h2_ssl_session_reuse_test.cc index 6ffc138820e..ed450aebf1b 100644 --- a/test/core/end2end/h2_ssl_session_reuse_test.cc +++ b/test/core/end2end/h2_ssl_session_reuse_test.cc @@ -29,7 +29,7 @@ #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc index eb63367d750..79f0c1ea365 100644 --- a/test/core/http/httpscli_test.cc +++ b/test/core/http/httpscli_test.cc @@ -29,7 +29,7 @@ #include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/iomgr.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" +#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" #include "test/core/util/test_config.h" diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index ed6f88dde3c..10e11825f8d 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1502,6 +1502,8 @@ src/core/lib/security/security_connector/ssl/ssl_security_connector.cc \ src/core/lib/security/security_connector/ssl/ssl_security_connector.h \ src/core/lib/security/security_connector/ssl_utils.cc \ src/core/lib/security/security_connector/ssl_utils.h \ +src/core/lib/security/security_connector/ssl_utils_config.cc \ +src/core/lib/security/security_connector/ssl_utils_config.h \ src/core/lib/security/security_connector/tls/spiffe_security_connector.cc \ src/core/lib/security/security_connector/tls/spiffe_security_connector.h \ src/core/lib/security/transport/auth_filters.h \ From 0a3b333c045800e3be4e8fce8d1b28ee0123b6aa Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Mon, 9 Sep 2019 11:32:04 -0700 Subject: [PATCH 1502/1555] Fix internal warning --- bazel/python_rules.bzl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index e65bae3f5b5..c2a16d6cce1 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -164,6 +164,8 @@ def py_grpc_library( stripped from the beginning of foo_pb2 modules imported by the generated stubs. This is useful in combination with the `imports` attribute of the `py_library` rule. + **kwargs: Additional arguments to be supplied to the invocation of + py_library. """ codegen_grpc_target = "_{}_grpc_codegen".format(name) if len(srcs) != 1: From 05901eaaa36fc85e357f0e717bce56bf796a6c09 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Mon, 9 Sep 2019 14:14:26 -0400 Subject: [PATCH 1503/1555] Fix filter_latency.cc On Windows tests, clock monotonic doesn't progress. Switch to CLOCK_PRECISE to fix this. --- test/core/end2end/tests/filter_latency.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/core/end2end/tests/filter_latency.cc b/test/core/end2end/tests/filter_latency.cc index a89db7b094b..85de58a3d20 100644 --- a/test/core/end2end/tests/filter_latency.cc +++ b/test/core/end2end/tests/filter_latency.cc @@ -122,7 +122,7 @@ static void test_request(grpc_end2end_test_config config) { g_client_latency = gpr_time_0(GPR_TIMESPAN); g_server_latency = gpr_time_0(GPR_TIMESPAN); gpr_mu_unlock(&g_mu); - const gpr_timespec start_time = gpr_now(GPR_CLOCK_MONOTONIC); + const gpr_timespec start_time = gpr_now(GPR_CLOCK_REALTIME); gpr_timespec deadline = five_seconds_from_now(); c = grpc_channel_create_call(f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq, @@ -224,7 +224,7 @@ static void test_request(grpc_end2end_test_config config) { end_test(&f); config.tear_down_data(&f); - const gpr_timespec end_time = gpr_now(GPR_CLOCK_MONOTONIC); + const gpr_timespec end_time = gpr_now(GPR_CLOCK_REALTIME); const gpr_timespec max_latency = gpr_time_sub(end_time, start_time); // Perform checks after test tear-down From aa84ceb38ea48058de2ce940842e8aefdc0ae69d Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 9 Sep 2019 15:58:33 -0700 Subject: [PATCH 1504/1555] Add another test for when the credentials were previously set --- test/cpp/end2end/end2end_test.cc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 5fb69c177b6..778a3dc6507 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -1865,6 +1865,36 @@ TEST_P(SecureEnd2endTest, CallCredentialsInterception) { "fake_selector")); } +TEST_P(SecureEnd2endTest, CallCredentialsInterceptionWithSetCredentials) { + MAYBE_SKIP_TEST; + if (!GetParam().use_interceptors) { + return; + } + std::vector> + interceptor_creators; + interceptor_creators.push_back(std::unique_ptr( + new CredentialsInterceptorFactory())); + ResetStub(std::move(interceptor_creators)); + EchoRequest request; + EchoResponse response; + ClientContext context; + std::shared_ptr creds1 = + GoogleIAMCredentials("wrong_token", "wrong_selector"); + context.set_credentials(creds1); + request.set_message("Hello"); + request.mutable_param()->set_echo_metadata(true); + + Status s = stub_->Echo(&context, request, &response); + EXPECT_EQ(request.message(), response.message()); + EXPECT_TRUE(s.ok()); + EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), + GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, + "fake_token")); + EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), + GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, + "fake_selector")); +} + TEST_P(SecureEnd2endTest, OverridePerCallCredentials) { MAYBE_SKIP_TEST; ResetStub(); From e7c9b46a1e4e01e0c0424dc774b2e1a970d7d164 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 9 Sep 2019 16:08:23 -0700 Subject: [PATCH 1505/1555] Move ErrorForBadProto --- src/objective-c/ProtoRPC/ProtoRPC.m | 18 ++++++++++++++++++ src/objective-c/ProtoRPC/ProtoRPCLegacy.m | 18 ------------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m index dbfa3c0f23d..9c0eb13d9d6 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.m +++ b/src/objective-c/ProtoRPC/ProtoRPC.m @@ -273,3 +273,21 @@ } @end + +/** + * Generate an NSError object that represents a failure in parsing a proto class. + */ +NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError) { + NSDictionary *info = @{ + NSLocalizedDescriptionKey : @"Unable to parse response from the server", + NSLocalizedRecoverySuggestionErrorKey : + @"If this RPC is idempotent, retry " + @"with exponential backoff. Otherwise, query the server status before " + @"retrying.", + NSUnderlyingErrorKey : parsingError, + @"Expected class" : expectedClass, + @"Received value" : proto, + }; + // TODO(jcanizales): Use kGRPCErrorDomain and GRPCErrorCodeInternal when they're public. + return [NSError errorWithDomain:@"io.grpc" code:13 userInfo:info]; +} diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.m b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m index 4ba93674063..eaa02e9170b 100644 --- a/src/objective-c/ProtoRPC/ProtoRPCLegacy.m +++ b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m @@ -101,21 +101,3 @@ @implementation GRPCProtoCall @end - -/** - * Generate an NSError object that represents a failure in parsing a proto class. - */ -NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError) { - NSDictionary *info = @{ - NSLocalizedDescriptionKey : @"Unable to parse response from the server", - NSLocalizedRecoverySuggestionErrorKey : - @"If this RPC is idempotent, retry " - @"with exponential backoff. Otherwise, query the server status before " - @"retrying.", - NSUnderlyingErrorKey : parsingError, - @"Expected class" : expectedClass, - @"Received value" : proto, - }; - // TODO(jcanizales): Use kGRPCErrorDomain and GRPCErrorCodeInternal when they're public. - return [NSError errorWithDomain:@"io.grpc" code:13 userInfo:info]; -} From deb8d569bae85789c31c41b1d949a52d01915402 Mon Sep 17 00:00:00 2001 From: Na-Na Pang Date: Mon, 9 Sep 2019 19:35:11 -0700 Subject: [PATCH 1506/1555] Assign Karthik to next github rotation --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/ISSUE_TEMPLATE/cleanup_request.md | 2 +- .github/ISSUE_TEMPLATE/feature_request.md | 2 +- .github/pull_request_template.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 4709997666e..66d87f4f508 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -2,7 +2,7 @@ name: Report a bug about: Create a report to help us improve labels: kind/bug, priority/P2 -assignees: nanahpang +assignees: karthikravis --- diff --git a/.github/ISSUE_TEMPLATE/cleanup_request.md b/.github/ISSUE_TEMPLATE/cleanup_request.md index 4ec33fafb58..ee564f00630 100644 --- a/.github/ISSUE_TEMPLATE/cleanup_request.md +++ b/.github/ISSUE_TEMPLATE/cleanup_request.md @@ -2,7 +2,7 @@ name: Request a cleanup about: Suggest a cleanup in our repository labels: kind/internal cleanup -assignees: nanahpang +assignees: karthikravis --- diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index efa5b1611bb..b6ef503c7c2 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -2,7 +2,7 @@ name: Request a feature about: Suggest an idea for this project labels: kind/enhancement -assignees: nanahpang +assignees: karthikravis --- diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 55d8d600541..681d2f819ce 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -8,4 +8,4 @@ If you know who should review your pull request, please remove the mentioning be --> -@nanahpang +@karthikravis From 107db8dab43120ed4f2815eef5e3d52d5f5d480f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 29 Aug 2019 09:53:41 -0400 Subject: [PATCH 1507/1555] upgrade bazel to 0.29 --- templates/tools/dockerfile/bazel.include | 2 +- tools/bazel | 2 +- tools/dockerfile/test/bazel/Dockerfile | 2 +- tools/dockerfile/test/sanity/Dockerfile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/tools/dockerfile/bazel.include b/templates/tools/dockerfile/bazel.include index 12a22785623..9762bdcb85f 100644 --- a/templates/tools/dockerfile/bazel.include +++ b/templates/tools/dockerfile/bazel.include @@ -2,7 +2,7 @@ # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.28.1 +ENV BAZEL_VERSION 0.29.0 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/bazel b/tools/bazel index 4d1d57f60d9..cfa875b0e63 100755 --- a/tools/bazel +++ b/tools/bazel @@ -32,7 +32,7 @@ then exec -a "$0" "${BAZEL_REAL}" "$@" fi -VERSION=0.28.1 +VERSION=0.29.0 echo "INFO: Running bazel wrapper (see //tools/bazel for details), bazel version $VERSION will be used instead of system-wide bazel installation." diff --git a/tools/dockerfile/test/bazel/Dockerfile b/tools/dockerfile/test/bazel/Dockerfile index 7141fb9c5f1..fde54bae877 100644 --- a/tools/dockerfile/test/bazel/Dockerfile +++ b/tools/dockerfile/test/bazel/Dockerfile @@ -52,7 +52,7 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.2.post1 six==1.10.0 t # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.28.1 +ENV BAZEL_VERSION 0.29.0 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index badff52de34..4d3691f32bd 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -97,7 +97,7 @@ ENV CLANG_TIDY=clang-tidy # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.28.1 +ENV BAZEL_VERSION 0.29.0 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 From e88553ed17dd0c59f75c11869ce3b7fa6a6540d7 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 4 Sep 2019 03:48:40 -0400 Subject: [PATCH 1508/1555] upgrade windows RBE to bazel 0.29 --- tools/internal_ci/windows/bazel_rbe.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat index 153b2d59687..e55534e2e84 100644 --- a/tools/internal_ci/windows/bazel_rbe.bat +++ b/tools/internal_ci/windows/bazel_rbe.bat @@ -14,7 +14,7 @@ @rem TODO(jtattermusch): make this generate less output @rem TODO(jtattermusch): use tools/bazel script to keep the versions in sync -choco install bazel -y --version 0.26.0 --limit-output +choco install bazel -y --version 0.29.0 --limit-output cd github/grpc set PATH=C:\tools\msys64\usr\bin;C:\Python27;%PATH% From 5cd37064cb0533844d9150f3e90503fd55d68008 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 4 Sep 2019 04:09:21 -0400 Subject: [PATCH 1509/1555] try fix win RBE build --- tools/internal_ci/windows/bazel_rbe.bat | 2 +- tools/remote_build/windows.bazelrc | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat index e55534e2e84..8d8ea118ebd 100644 --- a/tools/internal_ci/windows/bazel_rbe.bat +++ b/tools/internal_ci/windows/bazel_rbe.bat @@ -24,7 +24,7 @@ powershell -Command "[guid]::NewGuid().ToString()" >%KOKORO_ARTIFACTS_DIR%/bazel set /p BAZEL_INVOCATION_ID=<%KOKORO_ARTIFACTS_DIR%/bazel_invocation_ids @rem TODO(jtattermusch): windows RBE should be able to use the same credentials as Linux RBE. -bazel --bazelrc=tools/remote_build/windows.bazelrc build --invocation_id="%BAZEL_INVOCATION_ID%" --workspace_status_command=tools/remote_build/workspace_status_kokoro.sh :all --incompatible_disallow_filetype=false --google_credentials=%KOKORO_GFILE_DIR%/rbe-windows-credentials.json +bazel --bazelrc=tools/remote_build/windows.bazelrc build --invocation_id="%BAZEL_INVOCATION_ID%" --workspace_status_command=tools/remote_build/workspace_status_kokoro.sh :all --google_credentials=%KOKORO_GFILE_DIR%/rbe-windows-credentials.json set BAZEL_EXITCODE=%errorlevel% @rem TODO(jtattermusch): upload results to bigquery diff --git a/tools/remote_build/windows.bazelrc b/tools/remote_build/windows.bazelrc index 9fd3071e79f..825d6765de9 100644 --- a/tools/remote_build/windows.bazelrc +++ b/tools/remote_build/windows.bazelrc @@ -1,8 +1,7 @@ startup --host_jvm_args=-Dbazel.DigestFunction=SHA256 -build --remote_cache=remotebuildexecution.googleapis.com -build --remote_executor=remotebuildexecution.googleapis.com -build --tls_enabled=true +build --remote_cache=grpcs://remotebuildexecution.googleapis.com +build --remote_executor=grpcs://remotebuildexecution.googleapis.com build --host_crosstool_top=//third_party/toolchains/bazel_0.26.0_rbe_windows:toolchain build --crosstool_top=//third_party/toolchains/bazel_0.26.0_rbe_windows:toolchain @@ -38,7 +37,7 @@ test --test_env=GRPC_VERBOSITY=debug # Set flags for uploading to BES in order to view results in the Bazel Build # Results UI. -build --bes_backend="buildeventservice.googleapis.com" +build --bes_backend=grpcs://buildeventservice.googleapis.com build --bes_timeout=60s build --bes_results_url="https://source.cloud.google.com/results/invocations/" build --project_id=grpc-testing From 98d2d32b9edf9ff740d867e12ff529c0b637d980 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 10 Sep 2019 12:11:19 -0400 Subject: [PATCH 1510/1555] upgrade to bazel 0.29.1 --- templates/tools/dockerfile/bazel.include | 2 +- tools/bazel | 2 +- tools/dockerfile/test/bazel/Dockerfile | 2 +- tools/dockerfile/test/sanity/Dockerfile | 2 +- tools/internal_ci/windows/bazel_rbe.bat | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/tools/dockerfile/bazel.include b/templates/tools/dockerfile/bazel.include index 9762bdcb85f..f2124a62db8 100644 --- a/templates/tools/dockerfile/bazel.include +++ b/templates/tools/dockerfile/bazel.include @@ -2,7 +2,7 @@ # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.29.0 +ENV BAZEL_VERSION 0.29.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/bazel b/tools/bazel index cfa875b0e63..0ff7fa09487 100755 --- a/tools/bazel +++ b/tools/bazel @@ -32,7 +32,7 @@ then exec -a "$0" "${BAZEL_REAL}" "$@" fi -VERSION=0.29.0 +VERSION=0.29.1 echo "INFO: Running bazel wrapper (see //tools/bazel for details), bazel version $VERSION will be used instead of system-wide bazel installation." diff --git a/tools/dockerfile/test/bazel/Dockerfile b/tools/dockerfile/test/bazel/Dockerfile index fde54bae877..25fcf3e6f28 100644 --- a/tools/dockerfile/test/bazel/Dockerfile +++ b/tools/dockerfile/test/bazel/Dockerfile @@ -52,7 +52,7 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.2.post1 six==1.10.0 t # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.29.0 +ENV BAZEL_VERSION 0.29.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index 4d3691f32bd..b455a9171da 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -97,7 +97,7 @@ ENV CLANG_TIDY=clang-tidy # Bazel installation # Must be in sync with tools/bazel -ENV BAZEL_VERSION 0.29.0 +ENV BAZEL_VERSION 0.29.1 # The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper. ENV DISABLE_BAZEL_WRAPPER 1 diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat index 8d8ea118ebd..86dcc74c429 100644 --- a/tools/internal_ci/windows/bazel_rbe.bat +++ b/tools/internal_ci/windows/bazel_rbe.bat @@ -14,7 +14,7 @@ @rem TODO(jtattermusch): make this generate less output @rem TODO(jtattermusch): use tools/bazel script to keep the versions in sync -choco install bazel -y --version 0.29.0 --limit-output +choco install bazel -y --version 0.29.1 --limit-output cd github/grpc set PATH=C:\tools\msys64\usr\bin;C:\Python27;%PATH% From 37491ccd32d879fce1daff06bf162f0a230a18bc Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 10 Sep 2019 14:07:37 -0700 Subject: [PATCH 1511/1555] Bump version to 1.25 --- BUILD | 4 ++-- build.yaml | 4 ++-- doc/g_stands_for.md | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/BUILD b/BUILD index 576325c82f1..b2be0a29b90 100644 --- a/BUILD +++ b/BUILD @@ -77,11 +77,11 @@ config_setting( python_config_settings() # This should be updated along with build.yaml -g_stands_for = "ganges" +g_stands_for = "game" core_version = "7.0.0" -version = "1.24.0-dev" +version = "1.25.0-dev" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", diff --git a/build.yaml b/build.yaml index dc5fd4236da..1164b9023ce 100644 --- a/build.yaml +++ b/build.yaml @@ -14,8 +14,8 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 8.0.0 csharp_major_version: 2 - g_stands_for: ganges - version: 1.24.0-dev + g_stands_for: game + version: 1.25.0-dev filegroups: - name: alts_tsi headers: diff --git a/doc/g_stands_for.md b/doc/g_stands_for.md index 413ddcb341d..ccc79b24916 100644 --- a/doc/g_stands_for.md +++ b/doc/g_stands_for.md @@ -23,4 +23,5 @@ - 1.21 'g' stands for ['gandalf'](https://github.com/grpc/grpc/tree/v1.21.x) - 1.22 'g' stands for ['gale'](https://github.com/grpc/grpc/tree/v1.22.x) - 1.23 'g' stands for ['gangnam'](https://github.com/grpc/grpc/tree/v1.23.x) -- 1.24 'g' stands for ['ganges'](https://github.com/grpc/grpc/tree/master) +- 1.24 'g' stands for ['ganges'](https://github.com/grpc/grpc/tree/v1.24.x) +- 1.25 'g' stands for ['game'](https://github.com/grpc/grpc/tree/master) From cf444b9cab9e41ff4c7bf04271c127eb0eb98688 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 10 Sep 2019 14:08:50 -0700 Subject: [PATCH 1512/1555] Regenerate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 4 ++-- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 4 ++-- src/core/lib/surface/version.cc | 2 +- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core.Api/VersionInfo.cs | 4 ++-- src/csharp/build/dependencies.props | 2 +- src/csharp/build_unitypackage.bat | 2 +- src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/composer.json | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_channelz/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_status/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 32 files changed, 36 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08a49697750..ebcabe99cb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 3.5.1) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.24.0-dev") +set(PACKAGE_VERSION "1.25.0-dev") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index b24a27acfe6..f73924257f8 100644 --- a/Makefile +++ b/Makefile @@ -461,8 +461,8 @@ Q = @ endif CORE_VERSION = 8.0.0 -CPP_VERSION = 1.24.0-dev -CSHARP_VERSION = 2.24.0-dev +CPP_VERSION = 1.25.0-dev +CSHARP_VERSION = 2.25.0-dev CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 881e8959651..30cb9ce1de9 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,7 +23,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.24.0-dev' + # version = '1.25.0-dev' version = '0.0.9-dev' s.version = version s.summary = 'gRPC C++ library' @@ -31,7 +31,7 @@ Pod::Spec.new do |s| s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.24.0-dev' + grpc_version = '1.25.0-dev' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 3770425e5e3..7c2877f6edc 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.24.0-dev' + version = '1.25.0-dev' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 4c5ebb36562..551999bbea8 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.24.0-dev' + version = '1.25.0-dev' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 2e412cf67d6..dfa9363cd2c 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.24.0-dev' + version = '1.25.0-dev' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index e18adcd276e..1b36c5ed2ea 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.24.0-dev' + version = '1.25.0-dev' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index fb43cf9c4d7..375f2e0e436 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2018-01-19 - 1.24.0dev - 1.24.0dev + 1.25.0dev + 1.25.0dev beta diff --git a/src/core/lib/surface/version.cc b/src/core/lib/surface/version.cc index 71eb89a1b42..d05b6ab9563 100644 --- a/src/core/lib/surface/version.cc +++ b/src/core/lib/surface/version.cc @@ -25,4 +25,4 @@ const char* grpc_version_string(void) { return "8.0.0"; } -const char* grpc_g_stands_for(void) { return "ganges"; } +const char* grpc_g_stands_for(void) { return "game"; } diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 71ddc6e5d71..041956ecf5c 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.24.0-dev"; } +grpc::string Version() { return "1.25.0-dev"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index f732af32ec3..6d540155d9a 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -33,11 +33,11 @@ namespace Grpc.Core /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "2.24.0.0"; + public const string CurrentAssemblyFileVersion = "2.25.0.0"; /// /// Current version of gRPC C# /// - public const string CurrentVersion = "2.24.0-dev"; + public const string CurrentVersion = "2.25.0-dev"; } } diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index d45d3b1b0eb..df109183253 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 2.24.0-dev + 2.25.0-dev 3.8.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index 9fade5c1dd0..4e689754aca 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=2.24.0-dev +set VERSION=2.25.0-dev @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec index 67faaeb2567..9103c785f85 100644 --- a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCCppPlugin' - v = '1.24.0-dev' + v = '1.25.0-dev' s.version = v s.summary = 'The gRPC ProtoC plugin generates C++ files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index f65086b6df5..30a07f1647d 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.24.0-dev' + v = '1.25.0-dev' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/version.h b/src/objective-c/GRPCClient/version.h index fc6982c55d6..01ba728003d 100644 --- a/src/objective-c/GRPCClient/version.h +++ b/src/objective-c/GRPCClient/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.24.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.25.0-dev" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 9182189f4c8..54d05af8226 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.24.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.25.0-dev" #define GRPC_C_VERSION_STRING @"8.0.0" diff --git a/src/php/composer.json b/src/php/composer.json index 6da1fd77d65..f4af57682ab 100644 --- a/src/php/composer.json +++ b/src/php/composer.json @@ -2,7 +2,7 @@ "name": "grpc/grpc-dev", "description": "gRPC library for PHP - for Developement use only", "license": "Apache-2.0", - "version": "1.24.0", + "version": "1.25.0", "require": { "php": ">=5.5.0", "google/protobuf": "^v3.3.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 000508dd3f8..82863121990 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.24.0dev" +#define PHP_GRPC_VERSION "1.25.0dev" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index ff1b1a17d25..cf9055adb49 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.24.0.dev0""" +__version__ = """1.25.0.dev0""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index e0280abaa7c..3902f3fecac 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.24.0.dev0' +VERSION = '1.25.0.dev0' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index 93a448ecb64..61a651d45d3 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.24.0.dev0' +VERSION = '1.25.0.dev0' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index 2a1aa0c9359..7e9703c3c93 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.24.0.dev0' +VERSION = '1.25.0.dev0' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 93c28ba9fac..0c82a4c7768 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.24.0.dev0' +VERSION = '1.25.0.dev0' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index a2b5a814b52..307d9ba7245 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.24.0.dev0' +VERSION = '1.25.0.dev0' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 937e57da02f..b6a2dc2ba21 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.24.0.dev0' +VERSION = '1.25.0.dev0' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index a1e43215b09..4656e5af94a 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.24.0.dev0' +VERSION = '1.25.0.dev0' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 43f08a0c87b..40744531d72 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.24.0.dev' + VERSION = '1.25.0.dev' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index b08edb08478..4d67f9c6302 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.24.0.dev' + VERSION = '1.25.0.dev' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 184a0a9dda6..716add95195 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.24.0.dev0' +VERSION = '1.25.0.dev0' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 168e6c8d770..12435d0edb9 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.24.0-dev +PROJECT_NUMBER = 1.25.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 3b7af742baa..14e5599bc17 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.24.0-dev +PROJECT_NUMBER = 1.25.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From db861a254623228468c736a17b13af1d4afdc112 Mon Sep 17 00:00:00 2001 From: Arjun Roy Date: Mon, 9 Sep 2019 12:07:00 -0700 Subject: [PATCH 1513/1555] Coalesced arena allocs in callback unary C++ code. --- .../grpcpp/impl/codegen/client_callback_impl.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/include/grpcpp/impl/codegen/client_callback_impl.h b/include/grpcpp/impl/codegen/client_callback_impl.h index 37746ef5ce4..34c738ac1e6 100644 --- a/include/grpcpp/impl/codegen/client_callback_impl.h +++ b/include/grpcpp/impl/codegen/client_callback_impl.h @@ -72,11 +72,16 @@ class CallbackUnaryCallImpl { grpc::internal::CallOpClientSendClose, grpc::internal::CallOpClientRecvStatus>; - auto* ops = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(FullCallOpSet))) FullCallOpSet; - - auto* tag = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( - call.call(), sizeof(grpc::internal::CallbackWithStatusTag))) + struct OpSetAndTag { + FullCallOpSet opset; + grpc::internal::CallbackWithStatusTag tag; + }; + const size_t alloc_sz = sizeof(OpSetAndTag); + auto* const alloced = static_cast( + ::grpc::g_core_codegen_interface->grpc_call_arena_alloc(call.call(), + alloc_sz)); + auto* ops = new (&alloced->opset) FullCallOpSet; + auto* tag = new (&alloced->tag) grpc::internal::CallbackWithStatusTag(call.call(), on_completion, ops); // TODO(vjpai): Unify code with sync API as much as possible From 300077aac1f12dfa8365494f0a82194ccd8cb0b4 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Tue, 10 Sep 2019 15:26:33 -0700 Subject: [PATCH 1514/1555] Update upb to HEAD --- bazel/grpc_deps.bzl | 6 +++--- third_party/upb | 2 +- tools/run_tests/sanity/check_submodules.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index f904f42f8c9..01b9ffc9a0e 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -201,9 +201,9 @@ def grpc_deps(): if "upb" not in native.existing_rules(): http_archive( name = "upb", - sha256 = "95150db57b51b65f3422c38953956e0f786945d842d76f8ab685fbcd93ab5caa", - strip_prefix = "upb-931bbecbd3230ae7f22efa5d203639facc47f719", - url = "https://github.com/protocolbuffers/upb/archive/931bbecbd3230ae7f22efa5d203639facc47f719.tar.gz", + sha256 = "61d0417abd60e65ed589c9deee7c124fe76a4106831f6ad39464e1525cef1454", + strip_prefix = "upb-9effcbcb27f0a665f9f345030188c0b291e32482", + url = "https://github.com/protocolbuffers/upb/archive/9effcbcb27f0a665f9f345030188c0b291e32482.tar.gz", ) if "envoy_api" not in native.existing_rules(): http_archive( diff --git a/third_party/upb b/third_party/upb index 931bbecbd32..9effcbcb27f 160000 --- a/third_party/upb +++ b/third_party/upb @@ -1 +1 @@ -Subproject commit 931bbecbd3230ae7f22efa5d203639facc47f719 +Subproject commit 9effcbcb27f0a665f9f345030188c0b291e32482 diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index bd98e5c479a..e49ddc8950e 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -41,7 +41,7 @@ cat << EOF | awk '{ print $1 }' | sort > "$want_submodules" 09745575a923640154bcf307fba8aedff47f240a third_party/protobuf (v3.7.0-rc.2-247-g09745575) e143189bf6f37b3957fb31743df6a1bcf4a8c685 third_party/protoc-gen-validate (v0.0.10) 94324803a497c8f76dbc78df393ef629d3a9f3c3 third_party/udpa (heads/master) - 931bbecbd3230ae7f22efa5d203639facc47f719 third_party/upb (heads/master) + 9effcbcb27f0a665f9f345030188c0b291e32482 third_party/upb (heads/master) cacf7f1d4e3d44d871b605da3b647f07d718623f third_party/zlib (v1.2.11) EOF From 711a4147ae1cdc0568ef4179dfc3958a59e241dc Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Wed, 11 Sep 2019 01:21:47 +0200 Subject: [PATCH 1515/1555] Removing all warning flags and Werror for now. --- Makefile | 18 +++++++++--------- build.yaml | 17 +++++------------ grpc.gyp | 36 ------------------------------------ 3 files changed, 14 insertions(+), 57 deletions(-) diff --git a/Makefile b/Makefile index 5189f704297..e1f7480a54c 100644 --- a/Makefile +++ b/Makefile @@ -353,8 +353,8 @@ ifeq ($(SYSTEM),Darwin) CXXFLAGS += -stdlib=libc++ LDFLAGS += -framework CoreFoundation endif -CXXFLAGS += -Wnon-virtual-dtor -CPPFLAGS += -g -Wall -Wextra -Werror $(W_NO_UNKNOWN_WARNING_OPTION) -Wno-long-long -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-maybe-uninitialized -DOSATOMIC_USE_INLINED=1 -Ithird_party/upb -Isrc/core/ext/upb-generated +CFLAGS += -g +CPPFLAGS += -g -Wall -Wextra -DOSATOMIC_USE_INLINED=1 -Ithird_party/upb -Isrc/core/ext/upb-generated COREFLAGS += -fno-rtti -fno-exceptions LDFLAGS += -g @@ -553,7 +553,7 @@ OPENSSL_LIBS = ssl crypto endif OPENSSL_ALPN_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/openssl-alpn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS) -BORINGSSL_COMPILE_CHECK_CMD = $(CC) $(CPPFLAGS) -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI) -o $(TMPOUT) test/build/boringssl.c $(LDFLAGS) +BORINGSSL_COMPILE_CHECK_CMD = $(CC) $(CPPFLAGS) -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(CFLAGS) -g -o $(TMPOUT) test/build/boringssl.c $(LDFLAGS) ZLIB_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS) PROTOBUF_CHECK_CMD = $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS) CARES_CHECK_CMD = $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $(TMPOUT) test/build/c-ares.c -lcares $(LDFLAGS) @@ -7901,7 +7901,7 @@ LIBBORINGSSL_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(LIBBORINGSSL_OBJS): CXXFLAGS += -fno-rtti -fno-exceptions -$(LIBBORINGSSL_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI) +$(LIBBORINGSSL_OBJS): CFLAGS += -g $(LIBDIR)/$(CONFIG)/libboringssl.a: $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(LIBBORINGSSL_OBJS) $(E) "[AR] Creating $@" @@ -7931,7 +7931,7 @@ LIBBORINGSSL_TEST_UTIL_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(LIBBORINGSSL_TEST_UTIL_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(LIBBORINGSSL_TEST_UTIL_OBJS): CXXFLAGS += -fno-rtti -fno-exceptions -$(LIBBORINGSSL_TEST_UTIL_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI) +$(LIBBORINGSSL_TEST_UTIL_OBJS): CFLAGS += -g ifeq ($(NO_PROTOBUF),true) @@ -8034,7 +8034,7 @@ PUBLIC_HEADERS_C += \ LIBZ_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBZ_SRC)))) -$(LIBZ_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration -Wno-implicit-fallthrough $(W_NO_SHIFT_NEGATIVE_VALUE) -fvisibility=hidden +$(LIBZ_OBJS): CFLAGS += -fvisibility=hidden $(LIBDIR)/$(CONFIG)/libz.a: $(LIBZ_OBJS) $(E) "[AR] Creating $@" @@ -8110,7 +8110,7 @@ PUBLIC_HEADERS_C += \ LIBARES_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBARES_SRC)))) $(LIBARES_OBJS): CPPFLAGS += -Ithird_party/cares -Ithird_party/cares/cares -fvisibility=hidden -D_GNU_SOURCE $(if $(subst Darwin,,$(SYSTEM)),,-Ithird_party/cares/config_darwin) $(if $(subst FreeBSD,,$(SYSTEM)),,-Ithird_party/cares/config_freebsd) $(if $(subst Linux,,$(SYSTEM)),,-Ithird_party/cares/config_linux) $(if $(subst OpenBSD,,$(SYSTEM)),,-Ithird_party/cares/config_openbsd) -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(if $(subst MINGW32,,$(SYSTEM)),-DHAVE_CONFIG_H,) -$(LIBARES_OBJS): CFLAGS += -Wno-sign-conversion $(if $(subst Darwin,,$(SYSTEM)),,-Wno-shorten-64-to-32) $(if $(subst MINGW32,,$(SYSTEM)),-Wno-invalid-source-encoding,) +$(LIBARES_OBJS): CFLAGS += -g $(LIBDIR)/$(CONFIG)/libares.a: $(LIBARES_OBJS) $(E) "[AR] Creating $@" @@ -20108,7 +20108,7 @@ endif $(BORINGSSL_SSL_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(BORINGSSL_SSL_TEST_OBJS): CXXFLAGS += -fno-rtti -fno-exceptions -$(BORINGSSL_SSL_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI) +$(BORINGSSL_SSL_TEST_OBJS): CFLAGS += -g $(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/test/gtest_main.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a $(OBJDIR)/$(CONFIG)/third_party/boringssl/ssl/span_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a @@ -20200,7 +20200,7 @@ endif $(BORINGSSL_CRYPTO_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(BORINGSSL_CRYPTO_TEST_OBJS): CXXFLAGS += -fno-rtti -fno-exceptions -$(BORINGSSL_CRYPTO_TEST_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough $(NO_W_EXTRA_SEMI) +$(BORINGSSL_CRYPTO_TEST_OBJS): CFLAGS += -g $(OBJDIR)/$(CONFIG)/src/boringssl/crypto_test_data.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a $(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/asn1/asn1_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a diff --git a/build.yaml b/build.yaml index cbdbf8a60bc..d231dc41f16 100644 --- a/build.yaml +++ b/build.yaml @@ -6174,8 +6174,7 @@ configs: UBSAN_OPTIONS: halt_on_error=1:print_stacktrace=1:suppressions=test/core/util/ubsan_suppressions.txt defaults: ares: - CFLAGS: -Wno-sign-conversion $(if $(subst Darwin,,$(SYSTEM)),,-Wno-shorten-64-to-32) - $(if $(subst MINGW32,,$(SYSTEM)),-Wno-invalid-source-encoding,) + CFLAGS: -g CPPFLAGS: -Ithird_party/cares -Ithird_party/cares/cares -fvisibility=hidden -D_GNU_SOURCE $(if $(subst Darwin,,$(SYSTEM)),,-Ithird_party/cares/config_darwin) $(if $(subst FreeBSD,,$(SYSTEM)),,-Ithird_party/cares/config_freebsd) $(if $(subst Linux,,$(SYSTEM)),,-Ithird_party/cares/config_linux) @@ -6184,9 +6183,7 @@ defaults: benchmark: CPPFLAGS: -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX boringssl: - CFLAGS: -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas - -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough - $(NO_W_EXTRA_SEMI) + CFLAGS: -g CPPFLAGS: -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX CXXFLAGS: -fno-rtti -fno-exceptions @@ -6196,16 +6193,12 @@ defaults: $(W_NO_MAYBE_UNINITIALIZED) -fvisibility=hidden CXXFLAGS: $(W_NO_CXX14_COMPAT) global: + CFLAGS: -g COREFLAGS: -fno-rtti -fno-exceptions - CPPFLAGS: -g -Wall -Wextra -Werror $(W_NO_UNKNOWN_WARNING_OPTION) -Wno-long-long - -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow - -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers - -Wno-maybe-uninitialized -DOSATOMIC_USE_INLINED=1 -Ithird_party/upb -Isrc/core/ext/upb-generated - CXXFLAGS: -Wnon-virtual-dtor + CPPFLAGS: -g -Wall -Wextra -DOSATOMIC_USE_INLINED=1 -Ithird_party/upb -Isrc/core/ext/upb-generated LDFLAGS: -g zlib: - CFLAGS: -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration - -Wno-implicit-fallthrough $(W_NO_SHIFT_NEGATIVE_VALUE) -fvisibility=hidden + CFLAGS: -fvisibility=hidden openssl_fallback: base_uri: https://openssl.org/source/old/1.0.2/ extraction_dir: openssl-1.0.2f diff --git a/grpc.gyp b/grpc.gyp index 3b86e613131..9ef4488689a 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -54,18 +54,6 @@ '-g', '-Wall', '-Wextra', - '-Werror', - '$(W_NO_UNKNOWN_WARNING_OPTION)', - '-Wno-long-long', - '-Wno-unused-parameter', - '-Wno-deprecated-declarations', - '-Wno-sign-conversion', - '-Wno-shadow', - '-Wno-conversion', - '-Wno-implicit-fallthrough', - '-Wno-sign-compare', - '-Wno-missing-field-initializers', - '-Wno-maybe-uninitialized', '-DOSATOMIC_USE_INLINED=1', '-Ithird_party/upb', '-Isrc/core/ext/upb-generated', @@ -142,18 +130,6 @@ '-g', '-Wall', '-Wextra', - '-Werror', - '$(W_NO_UNKNOWN_WARNING_OPTION)', - '-Wno-long-long', - '-Wno-unused-parameter', - '-Wno-deprecated-declarations', - '-Wno-sign-conversion', - '-Wno-shadow', - '-Wno-conversion', - '-Wno-implicit-fallthrough', - '-Wno-sign-compare', - '-Wno-missing-field-initializers', - '-Wno-maybe-uninitialized', '-DOSATOMIC_USE_INLINED=1', '-Ithird_party/upb', '-Isrc/core/ext/upb-generated', @@ -162,18 +138,6 @@ '-g', '-Wall', '-Wextra', - '-Werror', - '$(W_NO_UNKNOWN_WARNING_OPTION)', - '-Wno-long-long', - '-Wno-unused-parameter', - '-Wno-deprecated-declarations', - '-Wno-sign-conversion', - '-Wno-shadow', - '-Wno-conversion', - '-Wno-implicit-fallthrough', - '-Wno-sign-compare', - '-Wno-missing-field-initializers', - '-Wno-maybe-uninitialized', '-DOSATOMIC_USE_INLINED=1', '-Ithird_party/upb', '-Isrc/core/ext/upb-generated', From 6f5e358da7f3ba2de1dbfeafa7116adf093c073b Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 10 Sep 2019 16:46:06 -0700 Subject: [PATCH 1516/1555] Rename filter functions to be able to uniquely identify them --- .../grpclb/client_load_reporting_filter.cc | 28 ++++++------- .../ext/filters/deadline/deadline_filter.cc | 40 +++++++++---------- .../filters/http/client/http_client_filter.cc | 24 +++++------ .../filters/http/client_authority_filter.cc | 28 ++++++------- .../message_compress_filter.cc | 24 +++++------ .../ext/filters/max_age/max_age_filter.cc | 24 +++++------ .../message_size/message_size_filter.cc | 28 ++++++------- .../workaround_cronet_compression_filter.cc | 29 +++++++------- .../security/transport/client_auth_filter.cc | 34 ++++++++-------- .../security/transport/server_auth_filter.cc | 28 ++++++------- src/core/lib/surface/lame_client.cc | 24 +++++------ 11 files changed, 156 insertions(+), 155 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc index 3057b26d315..09dd75b041f 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc @@ -30,12 +30,12 @@ #include "src/core/lib/iomgr/error.h" #include "src/core/lib/profiling/timers.h" -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* clr_init_channel_elem(grpc_channel_element* elem, + grpc_channel_element_args* args) { return GRPC_ERROR_NONE; } -static void destroy_channel_elem(grpc_channel_element* elem) {} +static void clr_destroy_channel_elem(grpc_channel_element* elem) {} namespace { @@ -71,16 +71,16 @@ static void recv_initial_metadata_ready(void* arg, grpc_error* error) { GRPC_ERROR_REF(error)); } -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* clr_init_call_elem(grpc_call_element* elem, + const grpc_call_element_args* args) { GPR_ASSERT(args->context != nullptr); new (elem->call_data) call_data(); return GRPC_ERROR_NONE; } -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { +static void clr_destroy_call_elem(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) { call_data* calld = static_cast(elem->call_data); if (calld->client_stats != nullptr) { // Record call finished, optionally setting client_failed_to_send and @@ -92,7 +92,7 @@ static void destroy_call_elem(grpc_call_element* elem, calld->~call_data(); } -static void start_transport_stream_op_batch( +static void clr_start_transport_stream_op_batch( grpc_call_element* elem, grpc_transport_stream_op_batch* batch) { call_data* calld = static_cast(elem->call_data); GPR_TIMER_SCOPE("clr_start_transport_stream_op_batch", 0); @@ -142,14 +142,14 @@ static void start_transport_stream_op_batch( } const grpc_channel_filter grpc_client_load_reporting_filter = { - start_transport_stream_op_batch, + clr_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), - init_call_elem, + clr_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + clr_destroy_call_elem, 0, // sizeof(channel_data) - init_channel_elem, - destroy_channel_elem, + clr_init_channel_elem, + clr_destroy_channel_elem, grpc_channel_next_get_info, "client_load_reporting"}; diff --git a/src/core/ext/filters/deadline/deadline_filter.cc b/src/core/ext/filters/deadline/deadline_filter.cc index 20a2953e5ff..d6c2b8e2588 100644 --- a/src/core/ext/filters/deadline/deadline_filter.cc +++ b/src/core/ext/filters/deadline/deadline_filter.cc @@ -233,14 +233,14 @@ void grpc_deadline_state_client_start_transport_stream_op_batch( // // Constructor for channel_data. Used for both client and server filters. -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* deadline_init_channel_elem(grpc_channel_element* elem, + grpc_channel_element_args* args) { GPR_ASSERT(!args->is_last); return GRPC_ERROR_NONE; } // Destructor for channel_data. Used for both client and server filters. -static void destroy_channel_elem(grpc_channel_element* elem) {} +static void deadline_destroy_channel_elem(grpc_channel_element* elem) {} // Call data used for both client and server filter. typedef struct base_call_data { @@ -260,24 +260,24 @@ typedef struct server_call_data { } server_call_data; // Constructor for call_data. Used for both client and server filters. -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* deadline_init_call_elem(grpc_call_element* elem, + const grpc_call_element_args* args) { new (elem->call_data) grpc_deadline_state( elem, args->call_stack, args->call_combiner, args->deadline); return GRPC_ERROR_NONE; } // Destructor for call_data. Used for both client and server filters. -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { +static void deadline_destroy_call_elem(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) { grpc_deadline_state* deadline_state = static_cast(elem->call_data); deadline_state->~grpc_deadline_state(); } // Method for starting a call op for client filter. -static void client_start_transport_stream_op_batch( +static void deadline_client_start_transport_stream_op_batch( grpc_call_element* elem, grpc_transport_stream_op_batch* op) { grpc_deadline_state_client_start_transport_stream_op_batch(elem, op); // Chain to next filter. @@ -295,7 +295,7 @@ static void recv_initial_metadata_ready(void* arg, grpc_error* error) { } // Method for starting a call op for server filter. -static void server_start_transport_stream_op_batch( +static void deadline_server_start_transport_stream_op_batch( grpc_call_element* elem, grpc_transport_stream_op_batch* op) { server_call_data* calld = static_cast(elem->call_data); if (op->cancel_stream) { @@ -329,29 +329,29 @@ static void server_start_transport_stream_op_batch( } const grpc_channel_filter grpc_client_deadline_filter = { - client_start_transport_stream_op_batch, + deadline_client_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(base_call_data), - init_call_elem, + deadline_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + deadline_destroy_call_elem, 0, // sizeof(channel_data) - init_channel_elem, - destroy_channel_elem, + deadline_init_channel_elem, + deadline_destroy_channel_elem, grpc_channel_next_get_info, "deadline", }; const grpc_channel_filter grpc_server_deadline_filter = { - server_start_transport_stream_op_batch, + deadline_server_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(server_call_data), - init_call_elem, + deadline_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + deadline_destroy_call_elem, 0, // sizeof(channel_data) - init_channel_elem, - destroy_channel_elem, + deadline_init_channel_elem, + deadline_destroy_channel_elem, grpc_channel_next_get_info, "deadline", }; diff --git a/src/core/ext/filters/http/client/http_client_filter.cc b/src/core/ext/filters/http/client/http_client_filter.cc index b16d26b1f24..1793e8106e4 100644 --- a/src/core/ext/filters/http/client/http_client_filter.cc +++ b/src/core/ext/filters/http/client/http_client_filter.cc @@ -465,16 +465,16 @@ done: } /* Constructor for call_data */ -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* hc_init_call_elem(grpc_call_element* elem, + const grpc_call_element_args* args) { new (elem->call_data) call_data(elem, *args); return GRPC_ERROR_NONE; } /* Destructor for call_data */ -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { +static void hc_destroy_call_elem(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) { call_data* calld = static_cast(elem->call_data); calld->~call_data(); } @@ -566,8 +566,8 @@ static grpc_core::ManagedMemorySlice user_agent_from_args( } /* Constructor for channel_data */ -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* hc_init_channel_elem(grpc_channel_element* elem, + grpc_channel_element_args* args) { channel_data* chand = static_cast(elem->channel_data); GPR_ASSERT(!args->is_last); GPR_ASSERT(args->optional_transport != nullptr); @@ -582,7 +582,7 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem, } /* Destructor for channel data */ -static void destroy_channel_elem(grpc_channel_element* elem) { +static void hc_destroy_channel_elem(grpc_channel_element* elem) { channel_data* chand = static_cast(elem->channel_data); GRPC_MDELEM_UNREF(chand->user_agent); } @@ -591,11 +591,11 @@ const grpc_channel_filter grpc_http_client_filter = { hc_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), - init_call_elem, + hc_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + hc_destroy_call_elem, sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, + hc_init_channel_elem, + hc_destroy_channel_elem, grpc_channel_next_get_info, "http-client"}; diff --git a/src/core/ext/filters/http/client_authority_filter.cc b/src/core/ext/filters/http/client_authority_filter.cc index dc8beb986fc..4d5d6233f8c 100644 --- a/src/core/ext/filters/http/client_authority_filter.cc +++ b/src/core/ext/filters/http/client_authority_filter.cc @@ -48,7 +48,7 @@ struct channel_data { grpc_mdelem default_authority_mdelem; }; -void authority_start_transport_stream_op_batch( +void client_authority_start_transport_stream_op_batch( grpc_call_element* elem, grpc_transport_stream_op_batch* batch) { channel_data* chand = static_cast(elem->channel_data); call_data* calld = static_cast(elem->call_data); @@ -72,21 +72,21 @@ void authority_start_transport_stream_op_batch( } /* Constructor for call_data */ -grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +grpc_error* client_authority_init_call_elem( + grpc_call_element* elem, const grpc_call_element_args* args) { call_data* calld = static_cast(elem->call_data); calld->call_combiner = args->call_combiner; return GRPC_ERROR_NONE; } /* Destructor for call_data */ -void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) {} +void client_authority_destroy_call_elem(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) {} /* Constructor for channel_data */ -grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +grpc_error* client_authority_init_channel_elem( + grpc_channel_element* elem, grpc_channel_element_args* args) { channel_data* chand = static_cast(elem->channel_data); const grpc_arg* default_authority_arg = grpc_channel_args_find(args->channel_args, GRPC_ARG_DEFAULT_AUTHORITY); @@ -110,7 +110,7 @@ grpc_error* init_channel_elem(grpc_channel_element* elem, } /* Destructor for channel data */ -void destroy_channel_elem(grpc_channel_element* elem) { +void client_authority_destroy_channel_elem(grpc_channel_element* elem) { channel_data* chand = static_cast(elem->channel_data); grpc_slice_unref_internal(chand->default_authority); GRPC_MDELEM_UNREF(chand->default_authority_mdelem); @@ -118,15 +118,15 @@ void destroy_channel_elem(grpc_channel_element* elem) { } // namespace const grpc_channel_filter grpc_client_authority_filter = { - authority_start_transport_stream_op_batch, + client_authority_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), - init_call_elem, + client_authority_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + client_authority_destroy_call_elem, sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, + client_authority_init_channel_elem, + client_authority_destroy_channel_elem, grpc_channel_next_get_info, "authority"}; diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.cc b/src/core/ext/filters/http/message_compress/message_compress_filter.cc index 9ef8e6a1990..2f4854e43ec 100644 --- a/src/core/ext/filters/http/message_compress/message_compress_filter.cc +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.cc @@ -441,23 +441,23 @@ static void compress_start_transport_stream_op_batch( } /* Constructor for call_data */ -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* compress_init_call_elem(grpc_call_element* elem, + const grpc_call_element_args* args) { new (elem->call_data) call_data(elem, *args); return GRPC_ERROR_NONE; } /* Destructor for call_data */ -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { +static void compress_destroy_call_elem(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) { call_data* calld = static_cast(elem->call_data); calld->~call_data(); } /* Constructor for channel_data */ -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* compress_init_channel_elem(grpc_channel_element* elem, + grpc_channel_element_args* args) { channel_data* channeld = static_cast(elem->channel_data); // Get the enabled and the default algorithms from channel args. channeld->enabled_compression_algorithms_bitset = @@ -487,17 +487,17 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem, } /* Destructor for channel data */ -static void destroy_channel_elem(grpc_channel_element* elem) {} +static void compress_destroy_channel_elem(grpc_channel_element* elem) {} const grpc_channel_filter grpc_message_compress_filter = { compress_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), - init_call_elem, + compress_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + compress_destroy_call_elem, sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, + compress_init_channel_elem, + compress_destroy_channel_elem, grpc_channel_next_get_info, "message_compress"}; diff --git a/src/core/ext/filters/max_age/max_age_filter.cc b/src/core/ext/filters/max_age/max_age_filter.cc index 96f2f02056f..770343d9b1f 100644 --- a/src/core/ext/filters/max_age/max_age_filter.cc +++ b/src/core/ext/filters/max_age/max_age_filter.cc @@ -395,24 +395,24 @@ add_random_max_connection_age_jitter_and_convert_to_grpc_millis(int value) { } /* Constructor for call_data. */ -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* max_age_init_call_elem(grpc_call_element* elem, + const grpc_call_element_args* args) { channel_data* chand = static_cast(elem->channel_data); increase_call_count(chand); return GRPC_ERROR_NONE; } /* Destructor for call_data. */ -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { +static void max_age_destroy_call_elem(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) { channel_data* chand = static_cast(elem->channel_data); decrease_call_count(chand); } /* Constructor for channel_data. */ -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* max_age_init_channel_elem(grpc_channel_element* elem, + grpc_channel_element_args* args) { channel_data* chand = static_cast(elem->channel_data); gpr_mu_init(&chand->max_age_timer_mu); chand->max_age_timer_pending = false; @@ -499,7 +499,7 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem, } /* Destructor for channel_data. */ -static void destroy_channel_elem(grpc_channel_element* elem) { +static void max_age_destroy_channel_elem(grpc_channel_element* elem) { channel_data* chand = static_cast(elem->channel_data); gpr_mu_destroy(&chand->max_age_timer_mu); } @@ -508,12 +508,12 @@ const grpc_channel_filter grpc_max_age_filter = { grpc_call_next_op, grpc_channel_next_op, 0, /* sizeof_call_data */ - init_call_elem, + max_age_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + max_age_destroy_call_elem, sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, + max_age_init_channel_elem, + max_age_destroy_channel_elem, grpc_channel_next_get_info, "max_age"}; diff --git a/src/core/ext/filters/message_size/message_size_filter.cc b/src/core/ext/filters/message_size/message_size_filter.cc index 8e93d11c9c0..df447c226b1 100644 --- a/src/core/ext/filters/message_size/message_size_filter.cc +++ b/src/core/ext/filters/message_size/message_size_filter.cc @@ -238,7 +238,7 @@ static void recv_trailing_metadata_ready(void* user_data, grpc_error* error) { } // Start transport stream op. -static void start_transport_stream_op_batch( +static void message_size_start_transport_stream_op_batch( grpc_call_element* elem, grpc_transport_stream_op_batch* op) { call_data* calld = static_cast(elem->call_data); // Check max send message size. @@ -277,17 +277,17 @@ static void start_transport_stream_op_batch( } // Constructor for call_data. -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* message_size_init_call_elem( + grpc_call_element* elem, const grpc_call_element_args* args) { channel_data* chand = static_cast(elem->channel_data); new (elem->call_data) call_data(elem, *chand, *args); return GRPC_ERROR_NONE; } // Destructor for call_data. -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { +static void message_size_destroy_call_elem( + grpc_call_element* elem, const grpc_call_final_info* final_info, + grpc_closure* ignored) { call_data* calld = (call_data*)elem->call_data; calld->~call_data(); } @@ -325,8 +325,8 @@ grpc_core::MessageSizeParsedConfig::message_size_limits get_message_size_limits( } // Constructor for channel_data. -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* message_size_init_channel_elem( + grpc_channel_element* elem, grpc_channel_element_args* args) { GPR_ASSERT(!args->is_last); channel_data* chand = static_cast(elem->channel_data); new (chand) channel_data(); @@ -355,21 +355,21 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem, } // Destructor for channel_data. -static void destroy_channel_elem(grpc_channel_element* elem) { +static void message_size_destroy_channel_elem(grpc_channel_element* elem) { channel_data* chand = static_cast(elem->channel_data); chand->~channel_data(); } const grpc_channel_filter grpc_message_size_filter = { - start_transport_stream_op_batch, + message_size_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), - init_call_elem, + message_size_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + message_size_destroy_call_elem, sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, + message_size_init_channel_elem, + message_size_destroy_channel_elem, grpc_channel_next_get_info, "message_size"}; diff --git a/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc b/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc index c7070d4d9ba..0426e008e40 100644 --- a/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +++ b/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc @@ -75,7 +75,7 @@ static void recv_initial_metadata_ready(void* user_data, grpc_error* error) { } // Start transport stream op. -static void start_transport_stream_op_batch( +static void cronet_compression_start_transport_stream_op_batch( grpc_call_element* elem, grpc_transport_stream_op_batch* op) { call_data* calld = static_cast(elem->call_data); @@ -104,8 +104,8 @@ static void start_transport_stream_op_batch( } // Constructor for call_data. -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* cronet_compression_init_call_elem( + grpc_call_element* elem, const grpc_call_element_args* args) { call_data* calld = static_cast(elem->call_data); calld->next_recv_initial_metadata_ready = nullptr; calld->workaround_active = false; @@ -116,18 +116,19 @@ static grpc_error* init_call_elem(grpc_call_element* elem, } // Destructor for call_data. -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) {} +static void cronet_compression_destroy_call_elem( + grpc_call_element* elem, const grpc_call_final_info* final_info, + grpc_closure* ignored) {} // Constructor for channel_data. -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* cronet_compression_init_channel_elem( + grpc_channel_element* elem, grpc_channel_element_args* args) { return GRPC_ERROR_NONE; } // Destructor for channel_data. -static void destroy_channel_elem(grpc_channel_element* elem) {} +static void cronet_compression_destroy_channel_elem( + grpc_channel_element* elem) {} // Parse the user agent static bool parse_user_agent(grpc_mdelem md) { @@ -169,15 +170,15 @@ static bool parse_user_agent(grpc_mdelem md) { } const grpc_channel_filter grpc_workaround_cronet_compression_filter = { - start_transport_stream_op_batch, + cronet_compression_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), - init_call_elem, + cronet_compression_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + cronet_compression_destroy_call_elem, 0, - init_channel_elem, - destroy_channel_elem, + cronet_compression_init_channel_elem, + cronet_compression_destroy_channel_elem, grpc_channel_next_get_info, "workaround_cronet_compression"}; diff --git a/src/core/lib/security/transport/client_auth_filter.cc b/src/core/lib/security/transport/client_auth_filter.cc index 33343d276eb..282ec5c97a9 100644 --- a/src/core/lib/security/transport/client_auth_filter.cc +++ b/src/core/lib/security/transport/client_auth_filter.cc @@ -324,7 +324,7 @@ static void cancel_check_call_host(void* arg, grpc_error* error) { } } -static void auth_start_transport_stream_op_batch( +static void client_auth_start_transport_stream_op_batch( grpc_call_element* elem, grpc_transport_stream_op_batch* batch) { GPR_TIMER_SCOPE("auth_start_transport_stream_op_batch", 0); @@ -369,29 +369,29 @@ static void auth_start_transport_stream_op_batch( } /* Constructor for call_data */ -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* client_auth_init_call_elem( + grpc_call_element* elem, const grpc_call_element_args* args) { new (elem->call_data) call_data(elem, *args); return GRPC_ERROR_NONE; } -static void set_pollset_or_pollset_set(grpc_call_element* elem, - grpc_polling_entity* pollent) { +static void client_auth_set_pollset_or_pollset_set( + grpc_call_element* elem, grpc_polling_entity* pollent) { call_data* calld = static_cast(elem->call_data); calld->pollent = pollent; } /* Destructor for call_data */ -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { +static void client_auth_destroy_call_elem( + grpc_call_element* elem, const grpc_call_final_info* final_info, + grpc_closure* ignored) { call_data* calld = static_cast(elem->call_data); calld->destroy(); } /* Constructor for channel_data */ -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* client_auth_init_channel_elem( + grpc_channel_element* elem, grpc_channel_element_args* args) { /* 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 */ @@ -414,20 +414,20 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem, } /* Destructor for channel data */ -static void destroy_channel_elem(grpc_channel_element* elem) { +static void client_auth_destroy_channel_elem(grpc_channel_element* elem) { channel_data* chand = static_cast(elem->channel_data); chand->~channel_data(); } const grpc_channel_filter grpc_client_auth_filter = { - auth_start_transport_stream_op_batch, + client_auth_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), - init_call_elem, - set_pollset_or_pollset_set, - destroy_call_elem, + client_auth_init_call_elem, + client_auth_set_pollset_or_pollset_set, + client_auth_destroy_call_elem, sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, + client_auth_init_channel_elem, + client_auth_destroy_channel_elem, grpc_channel_next_get_info, "client-auth"}; diff --git a/src/core/lib/security/transport/server_auth_filter.cc b/src/core/lib/security/transport/server_auth_filter.cc index 43509e6c61b..341e0e4a86a 100644 --- a/src/core/lib/security/transport/server_auth_filter.cc +++ b/src/core/lib/security/transport/server_auth_filter.cc @@ -257,7 +257,7 @@ static void recv_trailing_metadata_ready(void* user_data, grpc_error* err) { GRPC_CLOSURE_RUN(calld->original_recv_trailing_metadata_ready, err); } -static void auth_start_transport_stream_op_batch( +static void server_auth_start_transport_stream_op_batch( grpc_call_element* elem, grpc_transport_stream_op_batch* batch) { call_data* calld = static_cast(elem->call_data); if (batch->recv_initial_metadata) { @@ -278,23 +278,23 @@ static void auth_start_transport_stream_op_batch( } /* Constructor for call_data */ -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* server_auth_init_call_elem( + grpc_call_element* elem, const grpc_call_element_args* args) { new (elem->call_data) call_data(elem, *args); return GRPC_ERROR_NONE; } /* Destructor for call_data */ -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { +static void server_auth_destroy_call_elem( + grpc_call_element* elem, const grpc_call_final_info* final_info, + grpc_closure* ignored) { call_data* calld = static_cast(elem->call_data); calld->~call_data(); } /* Constructor for channel_data */ -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* server_auth_init_channel_elem( + grpc_channel_element* elem, grpc_channel_element_args* args) { GPR_ASSERT(!args->is_last); grpc_auth_context* auth_context = grpc_find_auth_context_in_args(args->channel_args); @@ -306,20 +306,20 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem, } /* Destructor for channel data */ -static void destroy_channel_elem(grpc_channel_element* elem) { +static void server_auth_destroy_channel_elem(grpc_channel_element* elem) { channel_data* chand = static_cast(elem->channel_data); chand->~channel_data(); } const grpc_channel_filter grpc_server_auth_filter = { - auth_start_transport_stream_op_batch, + server_auth_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), - init_call_elem, + server_auth_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + server_auth_destroy_call_elem, sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, + server_auth_init_channel_elem, + server_auth_destroy_channel_elem, grpc_channel_next_get_info, "server-auth"}; diff --git a/src/core/lib/surface/lame_client.cc b/src/core/lib/surface/lame_client.cc index 10a27924073..9208160938e 100644 --- a/src/core/lib/surface/lame_client.cc +++ b/src/core/lib/surface/lame_client.cc @@ -115,27 +115,27 @@ static void lame_start_transport_op(grpc_channel_element* elem, } } -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* lame_init_call_elem(grpc_call_element* elem, + const grpc_call_element_args* args) { CallData* calld = static_cast(elem->call_data); calld->call_combiner = args->call_combiner; return GRPC_ERROR_NONE; } -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* then_schedule_closure) { +static void lame_destroy_call_elem(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* then_schedule_closure) { GRPC_CLOSURE_SCHED(then_schedule_closure, GRPC_ERROR_NONE); } -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* lame_init_channel_elem(grpc_channel_element* elem, + grpc_channel_element_args* args) { GPR_ASSERT(args->is_first); GPR_ASSERT(args->is_last); return GRPC_ERROR_NONE; } -static void destroy_channel_elem(grpc_channel_element* elem) {} +static void lame_destroy_channel_elem(grpc_channel_element* elem) {} } // namespace @@ -145,12 +145,12 @@ const grpc_channel_filter grpc_lame_filter = { grpc_core::lame_start_transport_stream_op_batch, grpc_core::lame_start_transport_op, sizeof(grpc_core::CallData), - grpc_core::init_call_elem, + grpc_core::lame_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - grpc_core::destroy_call_elem, + grpc_core::lame_destroy_call_elem, sizeof(grpc_core::ChannelData), - grpc_core::init_channel_elem, - grpc_core::destroy_channel_elem, + grpc_core::lame_init_channel_elem, + grpc_core::lame_destroy_channel_elem, grpc_core::lame_get_channel_info, "lame-client", }; From 5abf2e5095c9fe28ae1d562970326664249bd743 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Wed, 11 Sep 2019 09:53:14 +0800 Subject: [PATCH 1517/1555] Fix: add a blank line before the subtitle --- examples/python/data_transmission/README.en.md | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/python/data_transmission/README.en.md b/examples/python/data_transmission/README.en.md index fb834ab80c9..659ee1b93fb 100644 --- a/examples/python/data_transmission/README.en.md +++ b/examples/python/data_transmission/README.en.md @@ -9,6 +9,7 @@ Four ways of data transmission when gRPC is used in Python. [Offical Guide]( Date: Wed, 11 Sep 2019 10:20:23 +0800 Subject: [PATCH 1518/1555] Fix: add copyright headers in `client.py` --- examples/python/data_transmission/client.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/examples/python/data_transmission/client.py b/examples/python/data_transmission/client.py index 0a9559ed79a..dee25b3a2ab 100644 --- a/examples/python/data_transmission/client.py +++ b/examples/python/data_transmission/client.py @@ -1,3 +1,18 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""The example of four ways of data transmission using gRPC in Python.""" + import time import grpc From 5c0fd4b4e6b535d3f5fc93b88dde8a38461d85bb Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Wed, 11 Sep 2019 10:23:31 +0800 Subject: [PATCH 1519/1555] Fix: add copyright headers in `demo.proto` --- examples/python/data_transmission/demo.proto | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/python/data_transmission/demo.proto b/examples/python/data_transmission/demo.proto index d3d96b523d1..b2d956c89d5 100644 --- a/examples/python/data_transmission/demo.proto +++ b/examples/python/data_transmission/demo.proto @@ -1,3 +1,17 @@ +// Copyright 2019 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // 语法版本声明,必须放在非注释的第一行 // Syntax version declaration. Must be placed on the first line of non-commentary. From c5d55ee64f48db1334e973a7f9290324c2c83175 Mon Sep 17 00:00:00 2001 From: kerbalwzy Date: Wed, 11 Sep 2019 10:27:15 +0800 Subject: [PATCH 1520/1555] Fix: add copyright headers in `server.py` --- examples/python/data_transmission/server.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/examples/python/data_transmission/server.py b/examples/python/data_transmission/server.py index 288c561382b..f550b9b7bd2 100644 --- a/examples/python/data_transmission/server.py +++ b/examples/python/data_transmission/server.py @@ -1,3 +1,18 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""The example of four ways of data transmission using gRPC in Python.""" + from threading import Thread from concurrent import futures From 9e0eb19ca4cef2aaa61236dcb9a042092166da86 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 9 Sep 2019 14:54:36 +0200 Subject: [PATCH 1521/1555] generate separate sponge target for each test suite --- tools/run_tests/python_utils/report_utils.py | 20 +++++++++++++++----- tools/run_tests/run_tests.py | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/run_tests/python_utils/report_utils.py b/tools/run_tests/python_utils/report_utils.py index 8d8dedb929b..707f9ef656c 100644 --- a/tools/run_tests/python_utils/report_utils.py +++ b/tools/run_tests/python_utils/report_utils.py @@ -49,12 +49,22 @@ def render_junit_xml_report(resultset, report_file, suite_package='grpc', suite_name='tests', - replace_dots=True): + replace_dots=True, + split_by_target=False): """Generate JUnit-like XML report.""" - tree = new_junit_xml_tree() - append_junit_xml_results(tree, resultset, suite_package, suite_name, '1', - replace_dots) - create_xml_report_file(tree, report_file) + if not split_by_target: + tree = new_junit_xml_tree() + append_junit_xml_results(tree, resultset, suite_package, suite_name, '1', + replace_dots) + create_xml_report_file(tree, report_file) + else: + for shortname, results in six.iteritems(resultset): + one_result = { shortname: results } + tree = new_junit_xml_tree() + append_junit_xml_results(tree, one_result, '%s_%s' % (suite_package, shortname), '%s_%s' % (suite_name, shortname), '1', + replace_dots) + per_suite_report_file = os.path.join(os.path.dirname(report_file), shortname, os.path.basename(report_file)) + create_xml_report_file(tree, per_suite_report_file) def create_xml_report_file(tree, report_file): diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 1ff37ca85af..cb26d0ab772 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1880,7 +1880,7 @@ def _build_and_run(check_cancelled, upload_extra_fields) if xml_report and resultset: report_utils.render_junit_xml_report( - resultset, xml_report, suite_name=args.report_suite_name) + resultset, xml_report, suite_name=args.report_suite_name, split_by_target=True) number_failures, _ = jobset.run( post_tests_steps, From 42da89171442ce6eadcd6d1cd00844f484bd0b4f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 10 Sep 2019 10:01:02 +0200 Subject: [PATCH 1522/1555] include run_tests in target name --- tools/run_tests/run_tests_matrix.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index 80c0a7d6455..5d38cb4c711 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -52,14 +52,14 @@ def _safe_report_name(name): def _report_filename(name): """Generates report file name with directory structure that leads to better presentation by internal CI""" # 'sponge_log.xml' suffix must be there for results to get recognized by kokoro. - return '%s/%s' % (_safe_report_name(name), 'sponge_log.xml') + return 'run_tests_%s/%s' % (_safe_report_name(name), 'sponge_log.xml') def _report_logfilename(name): """Generates log file name that corresponds to name generated by _report_filename""" # 'sponge_log.log' suffix must be there for log to get recognized as "target log" # for the corresponding 'sponge_log.xml' report. - return '%s/%s' % (_safe_report_name(name), 'sponge_log.log') + return 'run_tests_%s/%s' % (_safe_report_name(name), 'sponge_log.log') def _docker_jobspec(name, From 6b44344161d51c1018a5f1acf6eb39122f4251ef Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 10 Sep 2019 10:04:34 +0200 Subject: [PATCH 1523/1555] use run_tests_invocations instead of aggregate tests --- tools/run_tests/run_tests_matrix.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index 5d38cb4c711..a517e261056 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -604,8 +604,8 @@ if __name__ == "__main__": resultset.update(skipped_results) report_utils.render_junit_xml_report( resultset, - _report_filename('aggregate_tests'), - suite_name='aggregate_tests') + _report_filename('run_tests_invocations'), + suite_name='run_tests_invocations') if num_failures == 0: jobset.message( From 243b43d6cc596f09b72af19026e791dec4406a0c Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 10 Sep 2019 18:36:21 +0200 Subject: [PATCH 1524/1555] better run_tests prefix --- tools/run_tests/run_tests_matrix.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index a517e261056..e0f070ffed8 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -52,14 +52,14 @@ def _safe_report_name(name): def _report_filename(name): """Generates report file name with directory structure that leads to better presentation by internal CI""" # 'sponge_log.xml' suffix must be there for results to get recognized by kokoro. - return 'run_tests_%s/%s' % (_safe_report_name(name), 'sponge_log.xml') + return '%s/%s' % (_safe_report_name(name), 'sponge_log.xml') def _report_logfilename(name): """Generates log file name that corresponds to name generated by _report_filename""" # 'sponge_log.log' suffix must be there for log to get recognized as "target log" # for the corresponding 'sponge_log.xml' report. - return 'run_tests_%s/%s' % (_safe_report_name(name), 'sponge_log.log') + return '%s/%s' % (_safe_report_name(name), 'sponge_log.log') def _docker_jobspec(name, @@ -75,7 +75,7 @@ def _docker_jobspec(name, 'python', 'tools/run_tests/run_tests.py', '--use_docker', '-t', '-j', str(inner_jobs), '-x', - _report_filename(name), '--report_suite_name', + 'run_tests/%s' % _report_filename(name), '--report_suite_name', '%s' % _safe_report_name(name) ] + runtests_args, environ=runtests_envs, @@ -103,7 +103,7 @@ def _workspace_jobspec(name, 'bash', 'tools/run_tests/helper_scripts/run_tests_in_workspace.sh', '-t', '-j', str(inner_jobs), '-x', - '../%s' % _report_filename(name), '--report_suite_name', + '../run_tests/%s' % _report_filename(name), '--report_suite_name', '%s' % _safe_report_name(name) ] + runtests_args, environ=env, From 218e7b0c54ea121c2c90f105c14d538525b243ae Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 10 Sep 2019 18:44:56 +0200 Subject: [PATCH 1525/1555] split run_tests_invocations to separate targets --- tools/run_tests/run_tests_matrix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index e0f070ffed8..0321ea2c455 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -605,7 +605,7 @@ if __name__ == "__main__": report_utils.render_junit_xml_report( resultset, _report_filename('run_tests_invocations'), - suite_name='run_tests_invocations') + suite_name='run_tests_invocations', split_by_target=True) if num_failures == 0: jobset.message( From 902094f9f2a4e91ba06cc40b6a45e5cb55d54663 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 10 Sep 2019 20:28:07 +0200 Subject: [PATCH 1526/1555] rename to run_tests_matrix_jobs --- tools/run_tests/run_tests_matrix.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index 0321ea2c455..36df41b4abd 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -604,8 +604,8 @@ if __name__ == "__main__": resultset.update(skipped_results) report_utils.render_junit_xml_report( resultset, - _report_filename('run_tests_invocations'), - suite_name='run_tests_invocations', split_by_target=True) + _report_filename('run_tests_matrix_jobs'), + suite_name='run_tests_matrix_jobs', split_by_target=True) if num_failures == 0: jobset.message( From 11222b78c24ba73e32032d5fe068479a0173c6ea Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 11 Sep 2019 09:27:59 +0200 Subject: [PATCH 1527/1555] only use multi_target report for selected languages --- tools/run_tests/python_utils/report_utils.py | 6 +++-- tools/run_tests/run_tests.py | 10 +++++++- tools/run_tests/run_tests_matrix.py | 26 ++++++++++---------- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/tools/run_tests/python_utils/report_utils.py b/tools/run_tests/python_utils/report_utils.py index 707f9ef656c..714d9cf0605 100644 --- a/tools/run_tests/python_utils/report_utils.py +++ b/tools/run_tests/python_utils/report_utils.py @@ -50,14 +50,16 @@ def render_junit_xml_report(resultset, suite_package='grpc', suite_name='tests', replace_dots=True, - split_by_target=False): + multi_target=False): """Generate JUnit-like XML report.""" - if not split_by_target: + if not multi_targets: tree = new_junit_xml_tree() append_junit_xml_results(tree, resultset, suite_package, suite_name, '1', replace_dots) create_xml_report_file(tree, report_file) else: + # To have each test result displayed as a separate target by the Resultstore/Sponge UI, + # we generate a separate XML report file for each test result for shortname, results in six.iteritems(resultset): one_result = { shortname: results } tree = new_junit_xml_tree() diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index cb26d0ab772..8b2dfad2ef0 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1472,6 +1472,14 @@ argp.add_argument( default='tests', type=str, help='Test suite name to use in generated JUnit XML report') +argp.add_argument( + '--report_multi_target', + default=False, + const=True, + action='store_const', + help= + 'Generate separate XML report for each test job (Looks better in UIs).' +) argp.add_argument( '--quiet_success', default=False, @@ -1880,7 +1888,7 @@ def _build_and_run(check_cancelled, upload_extra_fields) if xml_report and resultset: report_utils.render_junit_xml_report( - resultset, xml_report, suite_name=args.report_suite_name, split_by_target=True) + resultset, xml_report, suite_name=args.report_suite_name, multi_target=args.report_multi_target) number_failures, _ = jobset.run( post_tests_steps, diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index 36df41b4abd..2948f415559 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -175,7 +175,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['dbg', 'opt'], platforms=['linux'], labels=['basictests'], - extra_args=extra_args, + extra_args=extra_args + ['--report_multi_target'], inner_jobs=inner_jobs) # supported on linux only @@ -184,7 +184,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['dbg', 'opt'], platforms=['linux'], labels=['basictests', 'multilang'], - extra_args=extra_args, + extra_args=extra_args + ['--report_multi_target'], inner_jobs=inner_jobs) # supported on all platforms. @@ -193,7 +193,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['dbg', 'opt'], platforms=['linux', 'macos', 'windows'], labels=['basictests', 'corelang'], - extra_args=extra_args, + extra_args=extra_args, # don't use multi_target report because C has too many test cases inner_jobs=inner_jobs, timeout_seconds=_CPP_RUNTESTS_TIMEOUT) @@ -203,7 +203,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['dbg', 'opt'], platforms=['linux', 'macos', 'windows'], labels=['basictests', 'multilang'], - extra_args=extra_args, + extra_args=extra_args + ['--report_multi_target'], inner_jobs=inner_jobs) # C# tests on .NET core test_jobs += _generate_jobs( @@ -213,7 +213,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): arch='default', compiler='coreclr', labels=['basictests', 'multilang'], - extra_args=extra_args, + extra_args=extra_args + ['--report_multi_target'], inner_jobs=inner_jobs) test_jobs += _generate_jobs( @@ -222,7 +222,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): platforms=['linux', 'macos', 'windows'], iomgr_platforms=['native', 'gevent'], labels=['basictests', 'multilang'], - extra_args=extra_args, + extra_args=extra_args + ['--report_multi_target'], inner_jobs=inner_jobs) # supported on linux and mac. @@ -231,7 +231,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['dbg', 'opt'], platforms=['linux', 'macos'], labels=['basictests', 'corelang'], - extra_args=extra_args, + extra_args=extra_args, # don't use multi_target report because C++ has too many test cases inner_jobs=inner_jobs, timeout_seconds=_CPP_RUNTESTS_TIMEOUT) @@ -240,7 +240,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['dbg', 'opt'], platforms=['linux', 'macos'], labels=['basictests', 'multilang'], - extra_args=extra_args, + extra_args=extra_args + ['--report_multi_target'], inner_jobs=inner_jobs) # supported on mac only. @@ -249,7 +249,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['opt'], platforms=['macos'], labels=['basictests', 'multilang'], - extra_args=extra_args, + extra_args=extra_args + ['--report_multi_target'], inner_jobs=inner_jobs, timeout_seconds=_OBJC_RUNTESTS_TIMEOUT) @@ -400,7 +400,7 @@ def _create_portability_test_jobs(extra_args=[], arch='default', compiler='python_alpine', labels=['portability', 'multilang'], - extra_args=extra_args, + extra_args=extra_args + ['--report_multi_target'], inner_jobs=inner_jobs) # TODO(jtattermusch): a large portion of the libuv tests is failing, @@ -605,16 +605,16 @@ if __name__ == "__main__": report_utils.render_junit_xml_report( resultset, _report_filename('run_tests_matrix_jobs'), - suite_name='run_tests_matrix_jobs', split_by_target=True) + suite_name='run_tests_matrix_jobs', multi_target=True) if num_failures == 0: jobset.message( 'SUCCESS', - 'All run_tests.py instance finished successfully.', + 'All run_tests.py instances finished successfully.', do_newline=True) else: jobset.message( 'FAILED', - 'Some run_tests.py instance have failed.', + 'Some run_tests.py instances have failed.', do_newline=True) sys.exit(1) From 2381d693b82e0a6c9d350fe959fddbfcea9c6333 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 11 Sep 2019 10:03:36 +0200 Subject: [PATCH 1528/1555] preserve the run_tests.py logs in sponge --- tools/run_tests/run_tests_matrix.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index 2948f415559..f7ce0ae9664 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -43,6 +43,8 @@ _OBJC_RUNTESTS_TIMEOUT = 90 * 60 # Number of jobs assigned to each run_tests.py instance _DEFAULT_INNER_JOBS = 2 +# Name of the top-level umbrella report that includes all the run_tests.py invocations +_MATRIX_REPORT_NAME = 'run_tests_matrix_jobs' def _safe_report_name(name): """Reports with '+' in target name won't show correctly in ResultStore""" @@ -55,11 +57,15 @@ def _report_filename(name): return '%s/%s' % (_safe_report_name(name), 'sponge_log.xml') -def _report_logfilename(name): - """Generates log file name that corresponds to name generated by _report_filename""" +def _matrix_job_logfilename(shortname_for_multi_target): + """Generate location for log file that will match the sponge_log.xml from the top-level matrix report.""" # 'sponge_log.log' suffix must be there for log to get recognized as "target log" # for the corresponding 'sponge_log.xml' report. - return '%s/%s' % (_safe_report_name(name), 'sponge_log.log') + # the shortname_for_multi_target component must be set to match the sponge_log.xml location + # because the top-level render_junit_xml_report is called with multi_target=True + s = '%s/%s/%s' % (_MATRIX_REPORT_NAME, shortname_for_multi_target, 'sponge_log.log') + print(s) + return s def _docker_jobspec(name, @@ -70,6 +76,7 @@ def _docker_jobspec(name, """Run a single instance of run_tests.py in a docker container""" if not timeout_seconds: timeout_seconds = _DEFAULT_RUNTESTS_TIMEOUT + shortname = 'run_tests_%s' % name test_job = jobset.JobSpec( cmdline=[ 'python', 'tools/run_tests/run_tests.py', '--use_docker', '-t', @@ -79,9 +86,9 @@ def _docker_jobspec(name, '%s' % _safe_report_name(name) ] + runtests_args, environ=runtests_envs, - shortname='run_tests_%s' % name, + shortname=shortname, timeout_seconds=timeout_seconds, - logfilename=_report_logfilename(name)) + logfilename=_matrix_job_logfilename(shortname)) return test_job @@ -96,6 +103,7 @@ def _workspace_jobspec(name, workspace_name = 'workspace_%s' % name if not timeout_seconds: timeout_seconds = _DEFAULT_RUNTESTS_TIMEOUT + shortname = 'run_tests_%s' % name env = {'WORKSPACE_NAME': workspace_name} env.update(runtests_envs) test_job = jobset.JobSpec( @@ -107,9 +115,9 @@ def _workspace_jobspec(name, '%s' % _safe_report_name(name) ] + runtests_args, environ=env, - shortname='run_tests_%s' % name, + shortname=shortname, timeout_seconds=timeout_seconds, - logfilename=_report_logfilename(name)) + logfilename=_matrix_job_logfilename(shortname)) return test_job @@ -604,8 +612,8 @@ if __name__ == "__main__": resultset.update(skipped_results) report_utils.render_junit_xml_report( resultset, - _report_filename('run_tests_matrix_jobs'), - suite_name='run_tests_matrix_jobs', multi_target=True) + _report_filename(_MATRIX_REPORT_NAME), + suite_name=_MATRIX_REPORT_NAME, multi_target=True) if num_failures == 0: jobset.message( From babb70705d76b7730808b13ccfaef1c1d6e75113 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 11 Sep 2019 10:05:54 +0200 Subject: [PATCH 1529/1555] fixup in report_utils.py --- tools/run_tests/python_utils/report_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/python_utils/report_utils.py b/tools/run_tests/python_utils/report_utils.py index 714d9cf0605..d9f6c5595d0 100644 --- a/tools/run_tests/python_utils/report_utils.py +++ b/tools/run_tests/python_utils/report_utils.py @@ -52,7 +52,7 @@ def render_junit_xml_report(resultset, replace_dots=True, multi_target=False): """Generate JUnit-like XML report.""" - if not multi_targets: + if not multi_target: tree = new_junit_xml_tree() append_junit_xml_results(tree, resultset, suite_package, suite_name, '1', replace_dots) From 5207c148ff2dac593e8bfa3b671df4ba8509e1a6 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 11 Sep 2019 10:35:01 +0200 Subject: [PATCH 1530/1555] more readable test target ordering --- tools/run_tests/run_tests_matrix.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index f7ce0ae9664..f4e8f3cdc5f 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -44,7 +44,9 @@ _OBJC_RUNTESTS_TIMEOUT = 90 * 60 _DEFAULT_INNER_JOBS = 2 # Name of the top-level umbrella report that includes all the run_tests.py invocations -_MATRIX_REPORT_NAME = 'run_tests_matrix_jobs' +# Note that the starting letter 't' matters so that the targets are listed AFTER +# the per-test breakdown items that start with 'run_tests/' (it is more readable that way) +_MATRIX_REPORT_NAME = 'toplevel_run_tests_invocations' def _safe_report_name(name): """Reports with '+' in target name won't show correctly in ResultStore""" From f268db6f33cbde498aa5f8e37c01318a7e5eec8b Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 11 Sep 2019 04:56:10 -0400 Subject: [PATCH 1531/1555] yapf format code --- tools/run_tests/python_utils/report_utils.py | 16 ++++++++++------ tools/run_tests/run_tests.py | 8 +++++--- tools/run_tests/run_tests_matrix.py | 13 +++++++++---- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/tools/run_tests/python_utils/report_utils.py b/tools/run_tests/python_utils/report_utils.py index d9f6c5595d0..0ab346b6139 100644 --- a/tools/run_tests/python_utils/report_utils.py +++ b/tools/run_tests/python_utils/report_utils.py @@ -54,18 +54,22 @@ def render_junit_xml_report(resultset, """Generate JUnit-like XML report.""" if not multi_target: tree = new_junit_xml_tree() - append_junit_xml_results(tree, resultset, suite_package, suite_name, '1', - replace_dots) + append_junit_xml_results(tree, resultset, suite_package, suite_name, + '1', replace_dots) create_xml_report_file(tree, report_file) else: # To have each test result displayed as a separate target by the Resultstore/Sponge UI, # we generate a separate XML report file for each test result for shortname, results in six.iteritems(resultset): - one_result = { shortname: results } + one_result = {shortname: results} tree = new_junit_xml_tree() - append_junit_xml_results(tree, one_result, '%s_%s' % (suite_package, shortname), '%s_%s' % (suite_name, shortname), '1', - replace_dots) - per_suite_report_file = os.path.join(os.path.dirname(report_file), shortname, os.path.basename(report_file)) + append_junit_xml_results(tree, one_result, '%s_%s' % (suite_package, + shortname), + '%s_%s' % (suite_name, + shortname), '1', replace_dots) + per_suite_report_file = os.path.join( + os.path.dirname(report_file), shortname, + os.path.basename(report_file)) create_xml_report_file(tree, per_suite_report_file) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 8b2dfad2ef0..a3708dc2b80 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1477,8 +1477,7 @@ argp.add_argument( default=False, const=True, action='store_const', - help= - 'Generate separate XML report for each test job (Looks better in UIs).' + help='Generate separate XML report for each test job (Looks better in UIs).' ) argp.add_argument( '--quiet_success', @@ -1888,7 +1887,10 @@ def _build_and_run(check_cancelled, upload_extra_fields) if xml_report and resultset: report_utils.render_junit_xml_report( - resultset, xml_report, suite_name=args.report_suite_name, multi_target=args.report_multi_target) + resultset, + xml_report, + suite_name=args.report_suite_name, + multi_target=args.report_multi_target) number_failures, _ = jobset.run( post_tests_steps, diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index f4e8f3cdc5f..105e5dcd906 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -48,6 +48,7 @@ _DEFAULT_INNER_JOBS = 2 # the per-test breakdown items that start with 'run_tests/' (it is more readable that way) _MATRIX_REPORT_NAME = 'toplevel_run_tests_invocations' + def _safe_report_name(name): """Reports with '+' in target name won't show correctly in ResultStore""" return name.replace('+', 'p') @@ -65,7 +66,8 @@ def _matrix_job_logfilename(shortname_for_multi_target): # for the corresponding 'sponge_log.xml' report. # the shortname_for_multi_target component must be set to match the sponge_log.xml location # because the top-level render_junit_xml_report is called with multi_target=True - s = '%s/%s/%s' % (_MATRIX_REPORT_NAME, shortname_for_multi_target, 'sponge_log.log') + s = '%s/%s/%s' % (_MATRIX_REPORT_NAME, shortname_for_multi_target, + 'sponge_log.log') print(s) return s @@ -203,7 +205,8 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['dbg', 'opt'], platforms=['linux', 'macos', 'windows'], labels=['basictests', 'corelang'], - extra_args=extra_args, # don't use multi_target report because C has too many test cases + extra_args= + extra_args, # don't use multi_target report because C has too many test cases inner_jobs=inner_jobs, timeout_seconds=_CPP_RUNTESTS_TIMEOUT) @@ -241,7 +244,8 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): configs=['dbg', 'opt'], platforms=['linux', 'macos'], labels=['basictests', 'corelang'], - extra_args=extra_args, # don't use multi_target report because C++ has too many test cases + extra_args= + extra_args, # don't use multi_target report because C++ has too many test cases inner_jobs=inner_jobs, timeout_seconds=_CPP_RUNTESTS_TIMEOUT) @@ -615,7 +619,8 @@ if __name__ == "__main__": report_utils.render_junit_xml_report( resultset, _report_filename(_MATRIX_REPORT_NAME), - suite_name=_MATRIX_REPORT_NAME, multi_target=True) + suite_name=_MATRIX_REPORT_NAME, + multi_target=True) if num_failures == 0: jobset.message( From 38d6c74fb3e8ad7dc41555fcfd319fffacf6f48a Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 11 Sep 2019 14:47:33 +0200 Subject: [PATCH 1532/1555] remove node from singlevm e2e benchmarks --- tools/internal_ci/linux/grpc_e2e_performance_singlevm.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/internal_ci/linux/grpc_e2e_performance_singlevm.sh b/tools/internal_ci/linux/grpc_e2e_performance_singlevm.sh index 21f9d48ac41..710ca25a982 100755 --- a/tools/internal_ci/linux/grpc_e2e_performance_singlevm.sh +++ b/tools/internal_ci/linux/grpc_e2e_performance_singlevm.sh @@ -20,8 +20,10 @@ cd $(dirname $0)/../../.. source tools/internal_ci/helper_scripts/prepare_build_linux_perf_multilang_rc # "smoketest" scenarios on a single VM (=no remote VM for running qps_workers) +# TODO(jtattermusch): add back "node" language once the scenarios are passing again +# See https://github.com/grpc/grpc/issues/20234 tools/run_tests/run_performance_tests.py \ - -l c++ csharp ruby java python go php7 php7_protobuf_c node \ + -l c++ csharp ruby java python go php7 php7_protobuf_c \ --netperf \ --category smoketest \ -u kbuilder \ From a44e6d76b74d977ad121f942202a087db853607f Mon Sep 17 00:00:00 2001 From: Pau Freixes Date: Wed, 11 Sep 2019 20:37:45 +0200 Subject: [PATCH 1533/1555] [Aio] Unary unary client call barebones implementation Implement the minimal stuff for making a unary call with the new experimental gRPC Python implementation for Asyncio, called Aio. What has been added: - Minimal iomgr code for performing the required network and timer calls. - Minimal Cython code implementing the channel, call and the callback context. - Minimal Python code that mimics the synchronous implementation but designed to be asynchronous. Testing considerations: Tests have to be executed using the `GRPC_ENABLE_FORK_SUPPORT=0` environment variable for skipping the fork handles installed by the core library. This is due to the usage of a syncrhonous server used as a fixture executed in another process. Co-authored-by: Manuel Miranda Co-authored-by: Mariano Anaya Co-authored-by: Zhanghui Mao Co-authored-by: Lidi Zheng --- AUTHORS | 1 + setup.py | 3 + src/python/grpcio/grpc/_cython/BUILD.bazel | 16 ++ .../grpc/_cython/_cygrpc/aio/call.pxd.pxi | 27 +++ .../grpc/_cython/_cygrpc/aio/call.pyx.pxi | 149 ++++++++++++++ .../_cygrpc/aio/callbackcontext.pxd.pxi | 20 ++ .../grpc/_cython/_cygrpc/aio/channel.pxd.pxi | 18 ++ .../grpc/_cython/_cygrpc/aio/channel.pyx.pxi | 30 +++ .../grpc/_cython/_cygrpc/aio/grpc_aio.pxd.pxi | 25 +++ .../grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi | 37 ++++ .../_cython/_cygrpc/aio/iomgr/iomgr.pyx.pxi | 185 ++++++++++++++++++ .../_cygrpc/aio/iomgr/resolver.pxd.pxi | 23 +++ .../_cygrpc/aio/iomgr/resolver.pyx.pxi | 61 ++++++ .../_cython/_cygrpc/aio/iomgr/socket.pxd.pxi | 34 ++++ .../_cython/_cygrpc/aio/iomgr/socket.pyx.pxi | 134 +++++++++++++ .../_cython/_cygrpc/aio/iomgr/timer.pxd.pxi | 25 +++ .../_cython/_cygrpc/aio/iomgr/timer.pyx.pxi | 45 +++++ .../grpcio/grpc/_cython/_cygrpc/grpc.pxi | 10 + .../grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi | 109 ----------- .../grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi | 46 ----- .../grpcio/grpc/_cython/_cygrpc/iomgr.pxd.pxi | 124 ++++++++++++ .../grpcio/grpc/_cython/_cygrpc/iomgr.pyx.pxi | 62 ++++++ src/python/grpcio/grpc/_cython/cygrpc.pxd | 11 ++ src/python/grpcio/grpc/_cython/cygrpc.pyx | 19 ++ .../grpcio/grpc/experimental/BUILD.bazel | 12 ++ .../grpcio/grpc/experimental/aio/__init__.py | 123 ++++++++++++ .../grpcio/grpc/experimental/aio/_channel.py | 105 ++++++++++ src/python/grpcio_tests/commands.py | 29 +++ src/python/grpcio_tests/setup.py | 1 + .../tests/_sanity/_sanity_test.py | 7 +- src/python/grpcio_tests/tests_aio/__init__.py | 21 ++ .../tests_aio/_sanity/__init__.py | 13 ++ .../tests_aio/_sanity/_sanity_test.py | 27 +++ src/python/grpcio_tests/tests_aio/tests.json | 5 + .../grpcio_tests/tests_aio/unit/__init__.py | 13 ++ .../tests_aio/unit/channel_test.py | 58 ++++++ .../grpcio_tests/tests_aio/unit/init_test.py | 35 ++++ .../tests_aio/unit/sync_server.py | 50 +++++ .../grpcio_tests/tests_aio/unit/test_base.py | 101 ++++++++++ tools/run_tests/run_tests.py | 38 +++- 40 files changed, 1691 insertions(+), 161 deletions(-) create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pxd.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pyx.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/callbackcontext.pxd.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pxd.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pyx.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pxd.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/iomgr.pyx.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pxd.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pyx.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pxd.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pyx.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/timer.pxd.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/timer.pyx.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pxd.pxi create mode 100644 src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pyx.pxi create mode 100644 src/python/grpcio/grpc/experimental/aio/__init__.py create mode 100644 src/python/grpcio/grpc/experimental/aio/_channel.py create mode 100644 src/python/grpcio_tests/tests_aio/__init__.py create mode 100644 src/python/grpcio_tests/tests_aio/_sanity/__init__.py create mode 100644 src/python/grpcio_tests/tests_aio/_sanity/_sanity_test.py create mode 100644 src/python/grpcio_tests/tests_aio/tests.json create mode 100644 src/python/grpcio_tests/tests_aio/unit/__init__.py create mode 100644 src/python/grpcio_tests/tests_aio/unit/channel_test.py create mode 100644 src/python/grpcio_tests/tests_aio/unit/init_test.py create mode 100644 src/python/grpcio_tests/tests_aio/unit/sync_server.py create mode 100644 src/python/grpcio_tests/tests_aio/unit/test_base.py diff --git a/AUTHORS b/AUTHORS index 0e8797391f2..0c5fee8c739 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1,4 @@ Dropbox, Inc. Google Inc. +Skyscanner Ltd. WeWork Companies Inc. diff --git a/setup.py b/setup.py index 609b18e01b5..eed516a1f11 100644 --- a/setup.py +++ b/setup.py @@ -265,6 +265,7 @@ if 'darwin' in sys.platform and PY3: r'macosx-10.7-\1', util.get_platform()) + def cython_extensions_and_necessity(): cython_module_files = [os.path.join(PYTHON_STEM, name.replace('.', '/') + '.pyx') @@ -295,6 +296,8 @@ def cython_extensions_and_necessity(): need_cython = BUILD_WITH_CYTHON if not BUILD_WITH_CYTHON: need_cython = need_cython or not commands.check_and_update_cythonization(extensions) + # TODO: the strategy for conditional compiling and exposing the aio Cython + # dependencies will be revisited by https://github.com/grpc/grpc/issues/19728 return commands.try_cythonize(extensions, linetracing=ENABLE_CYTHON_TRACING, mandatory=BUILD_WITH_CYTHON), need_cython CYTHON_EXTENSION_MODULES, need_cython = cython_extensions_and_necessity() diff --git a/src/python/grpcio/grpc/_cython/BUILD.bazel b/src/python/grpcio/grpc/_cython/BUILD.bazel index 18b1c92b9a7..e3cb89a81d3 100644 --- a/src/python/grpcio/grpc/_cython/BUILD.bazel +++ b/src/python/grpcio/grpc/_cython/BUILD.bazel @@ -8,6 +8,20 @@ pyx_library( "__init__.py", "_cygrpc/_hooks.pxd.pxi", "_cygrpc/_hooks.pyx.pxi", + "_cygrpc/aio/call.pxd.pxi", + "_cygrpc/aio/call.pyx.pxi", + "_cygrpc/aio/callbackcontext.pxd.pxi", + "_cygrpc/aio/channel.pxd.pxi", + "_cygrpc/aio/channel.pyx.pxi", + "_cygrpc/aio/grpc_aio.pxd.pxi", + "_cygrpc/aio/grpc_aio.pyx.pxi", + "_cygrpc/aio/iomgr/iomgr.pyx.pxi", + "_cygrpc/aio/iomgr/resolver.pxd.pxi", + "_cygrpc/aio/iomgr/resolver.pyx.pxi", + "_cygrpc/aio/iomgr/socket.pxd.pxi", + "_cygrpc/aio/iomgr/socket.pyx.pxi", + "_cygrpc/aio/iomgr/timer.pxd.pxi", + "_cygrpc/aio/iomgr/timer.pyx.pxi", "_cygrpc/arguments.pxd.pxi", "_cygrpc/arguments.pyx.pxi", "_cygrpc/call.pxd.pxi", @@ -27,6 +41,8 @@ pyx_library( "_cygrpc/grpc_gevent.pxd.pxi", "_cygrpc/grpc_gevent.pyx.pxi", "_cygrpc/grpc_string.pyx.pxi", + "_cygrpc/iomgr.pxd.pxi", + "_cygrpc/iomgr.pyx.pxi", "_cygrpc/metadata.pxd.pxi", "_cygrpc/metadata.pyx.pxi", "_cygrpc/operation.pxd.pxi", diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pxd.pxi new file mode 100644 index 00000000000..1166551fd5c --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pxd.pxi @@ -0,0 +1,27 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +cdef class _AioCall: + cdef: + AioChannel _channel + CallbackContext _watcher_call + grpc_completion_queue * _cq + grpc_experimental_completion_queue_functor _functor + object _waiter_call + + @staticmethod + cdef void functor_run(grpc_experimental_completion_queue_functor* functor, int succeed) + @staticmethod + cdef void watcher_call_functor_run(grpc_experimental_completion_queue_functor* functor, int succeed) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pyx.pxi new file mode 100644 index 00000000000..9530a47f389 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pyx.pxi @@ -0,0 +1,149 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cimport cpython + +_EMPTY_FLAGS = 0 +_EMPTY_METADATA = () +_OP_ARRAY_LENGTH = 6 + + +cdef class _AioCall: + + + def __cinit__(self, AioChannel channel): + self._channel = channel + self._functor.functor_run = _AioCall.functor_run + + self._cq = grpc_completion_queue_create_for_callback( + &self._functor, + NULL + ) + + self._watcher_call.functor.functor_run = _AioCall.watcher_call_functor_run + self._watcher_call.waiter = self + self._waiter_call = None + + def __dealloc__(self): + grpc_completion_queue_shutdown(self._cq) + grpc_completion_queue_destroy(self._cq) + + def __repr__(self): + class_name = self.__class__.__name__ + id_ = id(self) + return f"<{class_name} {id_}>" + + @staticmethod + cdef void functor_run(grpc_experimental_completion_queue_functor* functor, int succeed): + pass + + @staticmethod + cdef void watcher_call_functor_run(grpc_experimental_completion_queue_functor* functor, int succeed): + call = <_AioCall>(functor).waiter + + assert call._waiter_call + + if succeed == 0: + call._waiter_call.set_exception(Exception("Some error ocurred")) + else: + call._waiter_call.set_result(None) + + async def unary_unary(self, method, request): + cdef grpc_call * call + cdef grpc_slice method_slice + cdef grpc_op * ops + + cdef Operation initial_metadata_operation + cdef Operation send_message_operation + cdef Operation send_close_from_client_operation + cdef Operation receive_initial_metadata_operation + cdef Operation receive_message_operation + cdef Operation receive_status_on_client_operation + + cdef grpc_call_error call_status + + + method_slice = grpc_slice_from_copied_buffer( + method, + len(method) + ) + + call = grpc_channel_create_call( + self._channel.channel, + NULL, + 0, + self._cq, + method_slice, + NULL, + _timespec_from_time(None), + NULL + ) + + grpc_slice_unref(method_slice) + + ops = gpr_malloc(sizeof(grpc_op) * _OP_ARRAY_LENGTH) + + initial_metadata_operation = SendInitialMetadataOperation(_EMPTY_METADATA, GRPC_INITIAL_METADATA_USED_MASK) + initial_metadata_operation.c() + ops[0] = initial_metadata_operation.c_op + + send_message_operation = SendMessageOperation(request, _EMPTY_FLAGS) + send_message_operation.c() + ops[1] = send_message_operation.c_op + + send_close_from_client_operation = SendCloseFromClientOperation(_EMPTY_FLAGS) + send_close_from_client_operation.c() + ops[2] = send_close_from_client_operation.c_op + + receive_initial_metadata_operation = ReceiveInitialMetadataOperation(_EMPTY_FLAGS) + receive_initial_metadata_operation.c() + ops[3] = receive_initial_metadata_operation.c_op + + receive_message_operation = ReceiveMessageOperation(_EMPTY_FLAGS) + receive_message_operation.c() + ops[4] = receive_message_operation.c_op + + receive_status_on_client_operation = ReceiveStatusOnClientOperation(_EMPTY_FLAGS) + receive_status_on_client_operation.c() + ops[5] = receive_status_on_client_operation.c_op + + self._waiter_call = asyncio.get_event_loop().create_future() + + call_status = grpc_call_start_batch( + call, + ops, + _OP_ARRAY_LENGTH, + &self._watcher_call.functor, + NULL + ) + + try: + if call_status != GRPC_CALL_OK: + self._waiter_call = None + raise Exception("Error with grpc_call_start_batch {}".format(call_status)) + + await self._waiter_call + + finally: + initial_metadata_operation.un_c() + send_message_operation.un_c() + send_close_from_client_operation.un_c() + receive_initial_metadata_operation.un_c() + receive_message_operation.un_c() + receive_status_on_client_operation.un_c() + + grpc_call_unref(call) + gpr_free(ops) + + return receive_message_operation.message() diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/callbackcontext.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/callbackcontext.pxd.pxi new file mode 100644 index 00000000000..8e52c856dd2 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/callbackcontext.pxd.pxi @@ -0,0 +1,20 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cimport cpython + +cdef struct CallbackContext: + grpc_experimental_completion_queue_functor functor + cpython.PyObject *waiter + diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pxd.pxi new file mode 100644 index 00000000000..f5e1a5d3095 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pxd.pxi @@ -0,0 +1,18 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cdef class AioChannel: + cdef: + grpc_channel * channel + bytes _target diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pyx.pxi new file mode 100644 index 00000000000..b52c070553d --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pyx.pxi @@ -0,0 +1,30 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cdef class AioChannel: + def __cinit__(self, bytes target): + self.channel = grpc_insecure_channel_create(target, NULL, NULL) + self._target = target + + def __repr__(self): + class_name = self.__class__.__name__ + id_ = id(self) + return f"<{class_name} {id_}>" + + def close(self): + grpc_channel_destroy(self.channel) + + async def unary_unary(self, method, request): + call = _AioCall(self) + return await call.unary_unary(method, request) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pxd.pxi new file mode 100644 index 00000000000..6cefb63d208 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pxd.pxi @@ -0,0 +1,25 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# distutils: language=c++ + +cdef extern from "src/core/lib/iomgr/timer_manager.h": + void grpc_timer_manager_set_threading(bint enabled); + +cdef extern from "src/core/lib/iomgr/iomgr_internal.h": + void grpc_set_default_iomgr_platform(); + +cdef extern from "src/core/lib/iomgr/executor.h" namespace "grpc_core": + cdef cppclass Executor: + @staticmethod + void SetThreadingAll(bint enable); diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi new file mode 100644 index 00000000000..64645a6c3b4 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi @@ -0,0 +1,37 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +cdef bint _grpc_aio_initialized = 0 + + +def init_grpc_aio(): + global _grpc_aio_initialized + + if _grpc_aio_initialized: + return + + install_asyncio_iomgr() + grpc_init() + + # Timers are triggered by the Asyncio loop. We disable + # the background thread that is being used by the native + # gRPC iomgr. + grpc_timer_manager_set_threading(0) + + # gRPC callbaks are executed within the same thread used by the Asyncio + # event loop, as it is being done by the other Asyncio callbacks. + Executor.SetThreadingAll(0) + + _grpc_aio_initialized = 1 diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/iomgr.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/iomgr.pyx.pxi new file mode 100644 index 00000000000..13e95ee1206 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/iomgr.pyx.pxi @@ -0,0 +1,185 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +from cpython cimport Py_INCREF, Py_DECREF + +from libc cimport string + +cdef grpc_socket_vtable asyncio_socket_vtable +cdef grpc_custom_resolver_vtable asyncio_resolver_vtable +cdef grpc_custom_timer_vtable asyncio_timer_vtable +cdef grpc_custom_poller_vtable asyncio_pollset_vtable + + +cdef grpc_error* asyncio_socket_init( + grpc_custom_socket* grpc_socket, + int domain) with gil: + socket = _AsyncioSocket.create(grpc_socket) + Py_INCREF(socket) + grpc_socket.impl = socket + return 0 + + +cdef void asyncio_socket_destroy(grpc_custom_socket* grpc_socket) with gil: + Py_DECREF(<_AsyncioSocket>grpc_socket.impl) + + +cdef void asyncio_socket_connect( + grpc_custom_socket* grpc_socket, + const grpc_sockaddr* addr, + size_t addr_len, + grpc_custom_connect_callback connect_cb) with gil: + + host, port = sockaddr_to_tuple(addr, addr_len) + socket = <_AsyncioSocket>grpc_socket.impl + socket.connect(host, port, connect_cb) + + +cdef void asyncio_socket_close( + grpc_custom_socket* grpc_socket, + grpc_custom_close_callback close_cb) with gil: + socket = (<_AsyncioSocket>grpc_socket.impl) + socket.close() + close_cb(grpc_socket) + + +cdef void asyncio_socket_shutdown(grpc_custom_socket* grpc_socket) with gil: + socket = (<_AsyncioSocket>grpc_socket.impl) + socket.close() + + +cdef void asyncio_socket_write( + grpc_custom_socket* grpc_socket, + grpc_slice_buffer* slice_buffer, + grpc_custom_write_callback write_cb) with gil: + socket = (<_AsyncioSocket>grpc_socket.impl) + socket.write(slice_buffer, write_cb) + + +cdef void asyncio_socket_read( + grpc_custom_socket* grpc_socket, + char* buffer_, + size_t length, + grpc_custom_read_callback read_cb) with gil: + socket = (<_AsyncioSocket>grpc_socket.impl) + socket.read(buffer_, length, read_cb) + + +cdef grpc_error* asyncio_socket_getpeername( + grpc_custom_socket* grpc_socket, + const grpc_sockaddr* addr, + int* length) with gil: + raise NotImplemented() + + +cdef grpc_error* asyncio_socket_getsockname( + grpc_custom_socket* grpc_socket, + const grpc_sockaddr* addr, + int* length) with gil: + raise NotImplemented() + + +cdef grpc_error* asyncio_socket_listen(grpc_custom_socket* grpc_socket) with gil: + raise NotImplemented() + + +cdef grpc_error* asyncio_socket_bind( + grpc_custom_socket* grpc_socket, + const grpc_sockaddr* addr, + size_t len, int flags) with gil: + raise NotImplemented() + + +cdef void asyncio_socket_accept( + grpc_custom_socket* grpc_socket, + grpc_custom_socket* grpc_socket_client, + grpc_custom_accept_callback accept_cb) with gil: + raise NotImplemented() + + +cdef grpc_error* asyncio_resolve( + char* host, + char* port, + grpc_resolved_addresses** res) with gil: + raise NotImplemented() + + +cdef void asyncio_resolve_async( + grpc_custom_resolver* grpc_resolver, + char* host, + char* port) with gil: + resolver = _AsyncioResolver.create(grpc_resolver) + resolver.resolve(host, port) + + +cdef void asyncio_timer_start(grpc_custom_timer* grpc_timer) with gil: + timer = _AsyncioTimer.create(grpc_timer, grpc_timer.timeout_ms / 1000.0) + Py_INCREF(timer) + grpc_timer.timer = timer + + +cdef void asyncio_timer_stop(grpc_custom_timer* grpc_timer) with gil: + timer = <_AsyncioTimer>grpc_timer.timer + timer.stop() + Py_DECREF(timer) + + +cdef void asyncio_init_loop() with gil: + pass + + +cdef void asyncio_destroy_loop() with gil: + pass + + +cdef void asyncio_kick_loop() with gil: + pass + + +cdef void asyncio_run_loop(size_t timeout_ms) with gil: + pass + + +def install_asyncio_iomgr(): + asyncio_resolver_vtable.resolve = asyncio_resolve + asyncio_resolver_vtable.resolve_async = asyncio_resolve_async + + asyncio_socket_vtable.init = asyncio_socket_init + asyncio_socket_vtable.connect = asyncio_socket_connect + asyncio_socket_vtable.destroy = asyncio_socket_destroy + asyncio_socket_vtable.shutdown = asyncio_socket_shutdown + asyncio_socket_vtable.close = asyncio_socket_close + asyncio_socket_vtable.write = asyncio_socket_write + asyncio_socket_vtable.read = asyncio_socket_read + asyncio_socket_vtable.getpeername = asyncio_socket_getpeername + asyncio_socket_vtable.getsockname = asyncio_socket_getsockname + asyncio_socket_vtable.bind = asyncio_socket_bind + asyncio_socket_vtable.listen = asyncio_socket_listen + asyncio_socket_vtable.accept = asyncio_socket_accept + + asyncio_timer_vtable.start = asyncio_timer_start + asyncio_timer_vtable.stop = asyncio_timer_stop + + asyncio_pollset_vtable.init = asyncio_init_loop + asyncio_pollset_vtable.poll = asyncio_run_loop + asyncio_pollset_vtable.kick = asyncio_kick_loop + asyncio_pollset_vtable.shutdown = asyncio_destroy_loop + + grpc_custom_iomgr_init( + &asyncio_socket_vtable, + &asyncio_resolver_vtable, + &asyncio_timer_vtable, + &asyncio_pollset_vtable + ) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pxd.pxi new file mode 100644 index 00000000000..26089c95337 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pxd.pxi @@ -0,0 +1,23 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cdef class _AsyncioResolver: + cdef: + grpc_custom_resolver* _grpc_resolver + object _task_resolve + + @staticmethod + cdef _AsyncioResolver create(grpc_custom_resolver* grpc_resolver) + + cdef void resolve(self, char* host, char* port) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pyx.pxi new file mode 100644 index 00000000000..4c102392e5c --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pyx.pxi @@ -0,0 +1,61 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +cdef class _AsyncioResolver: + def __cinit__(self): + self._grpc_resolver = NULL + self._task_resolve = None + + @staticmethod + cdef _AsyncioResolver create(grpc_custom_resolver* grpc_resolver): + resolver = _AsyncioResolver() + resolver._grpc_resolver = grpc_resolver + return resolver + + def __repr__(self): + class_name = self.__class__.__name__ + id_ = id(self) + return f"<{class_name} {id_}>" + + def _resolve_cb(self, future): + error = False + try: + res = future.result() + except Exception as e: + error = True + finally: + self._task_resolve = None + + if not error: + grpc_custom_resolve_callback( + self._grpc_resolver, + tuples_to_resolvaddr(res), + 0 + ) + else: + grpc_custom_resolve_callback( + self._grpc_resolver, + NULL, + grpc_socket_error("getaddrinfo {}".format(str(e)).encode()) + ) + + cdef void resolve(self, char* host, char* port): + assert not self._task_resolve + + loop = asyncio.get_event_loop() + self._task_resolve = asyncio.ensure_future( + loop.getaddrinfo(host, port) + ) + self._task_resolve.add_done_callback(self._resolve_cb) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pxd.pxi new file mode 100644 index 00000000000..aab5db2149a --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pxd.pxi @@ -0,0 +1,34 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +cdef class _AsyncioSocket: + cdef: + grpc_custom_socket * _grpc_socket + grpc_custom_connect_callback _grpc_connect_cb + grpc_custom_read_callback _grpc_read_cb + object _reader + object _writer + object _task_read + object _task_connect + char * _read_buffer + + @staticmethod + cdef _AsyncioSocket create(grpc_custom_socket * grpc_socket) + + cdef void connect(self, object host, object port, grpc_custom_connect_callback grpc_connect_cb) + cdef void write(self, grpc_slice_buffer * g_slice_buffer, grpc_custom_write_callback grpc_write_cb) + cdef void read(self, char * buffer_, size_t length, grpc_custom_read_callback grpc_read_cb) + cdef bint is_connected(self) + cdef void close(self) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pyx.pxi new file mode 100644 index 00000000000..690c34c2da9 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pyx.pxi @@ -0,0 +1,134 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import socket + +from libc cimport string + +cdef class _AsyncioSocket: + def __cinit__(self): + self._grpc_socket = NULL + self._grpc_connect_cb = NULL + self._grpc_read_cb = NULL + self._reader = None + self._writer = None + self._task_connect = None + self._task_read = None + self._read_buffer = NULL + + @staticmethod + cdef _AsyncioSocket create(grpc_custom_socket * grpc_socket): + socket = _AsyncioSocket() + socket._grpc_socket = grpc_socket + return socket + + def __repr__(self): + class_name = self.__class__.__name__ + id_ = id(self) + connected = self.is_connected() + return f"<{class_name} {id_} connected={connected}>" + + def _connect_cb(self, future): + error = False + try: + self._reader, self._writer = future.result() + except Exception as e: + error = True + finally: + self._task_connect = None + + if not error: + # gRPC default posix implementation disables nagle + # algorithm. + sock = self._writer.transport.get_extra_info('socket') + sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, True) + + self._grpc_connect_cb( + self._grpc_socket, + 0 + ) + else: + self._grpc_connect_cb( + self._grpc_socket, + grpc_socket_error("connect {}".format(str(e)).encode()) + ) + + def _read_cb(self, future): + error = False + try: + buffer_ = future.result() + except Exception as e: + error = True + error_msg = str(e) + finally: + self._task_read = None + + if not error: + string.memcpy( + self._read_buffer, + buffer_, + len(buffer_) + ) + self._grpc_read_cb( + self._grpc_socket, + len(buffer_), + 0 + ) + else: + self._grpc_read_cb( + self._grpc_socket, + -1, + grpc_socket_error("read {}".format(error_msg).encode()) + ) + + cdef void connect(self, object host, object port, grpc_custom_connect_callback grpc_connect_cb): + assert not self._task_connect + + self._task_connect = asyncio.ensure_future( + asyncio.open_connection(host, port) + ) + self._grpc_connect_cb = grpc_connect_cb + self._task_connect.add_done_callback(self._connect_cb) + + cdef void read(self, char * buffer_, size_t length, grpc_custom_read_callback grpc_read_cb): + assert not self._task_read + + self._task_read = asyncio.ensure_future( + self._reader.read(n=length) + ) + self._grpc_read_cb = grpc_read_cb + self._task_read.add_done_callback(self._read_cb) + self._read_buffer = buffer_ + + cdef void write(self, grpc_slice_buffer * g_slice_buffer, grpc_custom_write_callback grpc_write_cb): + cdef char* start + buffer_ = bytearray() + for i in range(g_slice_buffer.count): + start = grpc_slice_buffer_start(g_slice_buffer, i) + length = grpc_slice_buffer_length(g_slice_buffer, i) + buffer_.extend(start[:length]) + + self._writer.write(buffer_) + + grpc_write_cb( + self._grpc_socket, + 0 + ) + + cdef bint is_connected(self): + return self._reader and not self._reader._transport.is_closing() + + cdef void close(self): + if self.is_connected(): + self._writer.close() diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/timer.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/timer.pxd.pxi new file mode 100644 index 00000000000..5af5dcd9282 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/timer.pxd.pxi @@ -0,0 +1,25 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cdef class _AsyncioTimer: + cdef: + grpc_custom_timer * _grpc_timer + object _deadline + object _timer_handler + int _active + + @staticmethod + cdef _AsyncioTimer create(grpc_custom_timer * grpc_timer, deadline) + + cdef stop(self) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/timer.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/timer.pyx.pxi new file mode 100644 index 00000000000..e8edb4a5cf8 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/timer.pyx.pxi @@ -0,0 +1,45 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +cdef class _AsyncioTimer: + def __cinit__(self): + self._grpc_timer = NULL + self._timer_handler = None + self._active = 0 + + @staticmethod + cdef _AsyncioTimer create(grpc_custom_timer * grpc_timer, deadline): + timer = _AsyncioTimer() + timer._grpc_timer = grpc_timer + timer._deadline = deadline + timer._timer_handler = asyncio.get_event_loop().call_later(deadline, timer._on_deadline) + timer._active = 1 + return timer + + def _on_deadline(self): + self._active = 0 + grpc_custom_timer_callback(self._grpc_timer, 0) + + def __repr__(self): + class_name = self.__class__.__name__ + id_ = id(self) + return f"<{class_name} {id_} deadline={self._deadline} active={self._active}>" + + cdef stop(self): + if self._active == 0: + return + + self._timer_handler.cancel() + self._active = 0 diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index 4bfb42026aa..e2117905421 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -41,6 +41,11 @@ cdef extern from "grpc/byte_buffer_reader.h": pass +cdef extern from "grpc/impl/codegen/grpc_types.h": + ctypedef struct grpc_experimental_completion_queue_functor: + void (*functor_run)(grpc_experimental_completion_queue_functor*, int); + + cdef extern from "grpc/grpc.h": ctypedef struct grpc_slice: @@ -325,6 +330,7 @@ cdef extern from "grpc/grpc.h": ctypedef struct grpc_op: grpc_op_type type "op" uint32_t flags + void * reserved grpc_op_data data void grpc_init() nogil @@ -350,6 +356,10 @@ cdef extern from "grpc/grpc.h": void grpc_completion_queue_shutdown(grpc_completion_queue *cq) nogil void grpc_completion_queue_destroy(grpc_completion_queue *cq) nogil + grpc_completion_queue *grpc_completion_queue_create_for_callback( + grpc_experimental_completion_queue_functor* shutdown_callback, + void *reserved) nogil + grpc_call_error grpc_call_start_batch( grpc_call *call, const grpc_op *ops, size_t nops, void *tag, void *reserved) nogil diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi index 30fdf6a7600..4f5033b8e44 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi @@ -13,115 +13,6 @@ # limitations under the License. # distutils: language=c++ -cdef extern from "grpc/impl/codegen/slice.h": - struct grpc_slice_buffer: - int count - -cdef extern from "src/core/lib/iomgr/error.h": - struct grpc_error: - pass - -cdef extern from "src/core/lib/iomgr/gevent_util.h": - grpc_error* grpc_socket_error(char* error) - char* grpc_slice_buffer_start(grpc_slice_buffer* buffer, int i) - int grpc_slice_buffer_length(grpc_slice_buffer* buffer, int i) - -cdef extern from "src/core/lib/iomgr/sockaddr.h": - ctypedef struct grpc_sockaddr: - pass - -cdef extern from "src/core/lib/iomgr/resolve_address.h": - ctypedef struct grpc_resolved_addresses: - size_t naddrs - grpc_resolved_address* addrs - - ctypedef struct grpc_resolved_address: - char[128] addr - size_t len - -cdef extern from "src/core/lib/iomgr/resolve_address_custom.h": - struct grpc_custom_resolver: - pass - - struct grpc_custom_resolver_vtable: - grpc_error* (*resolve)(char* host, char* port, grpc_resolved_addresses** res); - void (*resolve_async)(grpc_custom_resolver* resolver, char* host, char* port); - - void grpc_custom_resolve_callback(grpc_custom_resolver* resolver, - grpc_resolved_addresses* result, - grpc_error* error); - -cdef extern from "src/core/lib/iomgr/tcp_custom.h": - struct grpc_custom_socket: - void* impl - # We don't care about the rest of the fields - ctypedef void (*grpc_custom_connect_callback)(grpc_custom_socket* socket, - grpc_error* error) - ctypedef void (*grpc_custom_write_callback)(grpc_custom_socket* socket, - grpc_error* error) - ctypedef void (*grpc_custom_read_callback)(grpc_custom_socket* socket, - size_t nread, grpc_error* error) - ctypedef void (*grpc_custom_accept_callback)(grpc_custom_socket* socket, - grpc_custom_socket* client, - grpc_error* error) - ctypedef void (*grpc_custom_close_callback)(grpc_custom_socket* socket) - - struct grpc_socket_vtable: - grpc_error* (*init)(grpc_custom_socket* socket, int domain); - void (*connect)(grpc_custom_socket* socket, const grpc_sockaddr* addr, - size_t len, grpc_custom_connect_callback cb); - void (*destroy)(grpc_custom_socket* socket); - void (*shutdown)(grpc_custom_socket* socket); - void (*close)(grpc_custom_socket* socket, grpc_custom_close_callback cb); - void (*write)(grpc_custom_socket* socket, grpc_slice_buffer* slices, - grpc_custom_write_callback cb); - void (*read)(grpc_custom_socket* socket, char* buffer, size_t length, - grpc_custom_read_callback cb); - grpc_error* (*getpeername)(grpc_custom_socket* socket, - const grpc_sockaddr* addr, int* len); - grpc_error* (*getsockname)(grpc_custom_socket* socket, - const grpc_sockaddr* addr, int* len); - grpc_error* (*bind)(grpc_custom_socket* socket, const grpc_sockaddr* addr, - size_t len, int flags); - grpc_error* (*listen)(grpc_custom_socket* socket); - void (*accept)(grpc_custom_socket* socket, grpc_custom_socket* client, - grpc_custom_accept_callback cb); - -cdef extern from "src/core/lib/iomgr/timer_custom.h": - struct grpc_custom_timer: - void* timer - int timeout_ms - # We don't care about the rest of the fields - - struct grpc_custom_timer_vtable: - void (*start)(grpc_custom_timer* t); - void (*stop)(grpc_custom_timer* t); - - void grpc_custom_timer_callback(grpc_custom_timer* t, grpc_error* error); - -cdef extern from "src/core/lib/iomgr/pollset_custom.h": - struct grpc_custom_poller_vtable: - void (*init)() - void (*poll)(size_t timeout_ms) - void (*kick)() - void (*shutdown)() - -cdef extern from "src/core/lib/iomgr/iomgr_custom.h": - void grpc_custom_iomgr_init(grpc_socket_vtable* socket, - grpc_custom_resolver_vtable* resolver, - grpc_custom_timer_vtable* timer, - grpc_custom_poller_vtable* poller); - -cdef extern from "src/core/lib/iomgr/sockaddr_utils.h": - int grpc_sockaddr_get_port(const grpc_resolved_address *addr); - int grpc_sockaddr_to_string(char **out, const grpc_resolved_address *addr, - int normalize); - void grpc_string_to_sockaddr(grpc_resolved_address *out, char* addr, int port); - int grpc_sockaddr_set_port(const grpc_resolved_address *resolved_addr, - int port) - const char* grpc_sockaddr_get_uri_scheme(const grpc_resolved_address* resolved_addr) - - cdef class TimerWrapper: cdef grpc_custom_timer *c_timer diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi index a1618d04d0e..13256ed49b8 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi @@ -15,7 +15,6 @@ cimport cpython from libc cimport string -from libc.stdlib cimport malloc, free import errno gevent_g = None gevent_socket = None @@ -24,51 +23,6 @@ gevent_event = None g_event = None g_pool = None -cdef grpc_error* grpc_error_none(): - return 0 - -cdef grpc_error* socket_error(str syscall, str err): - error_str = "{} failed: {}".format(syscall, err) - error_bytes = str_to_bytes(error_str) - return grpc_socket_error(error_bytes) - -cdef resolved_addr_to_tuple(grpc_resolved_address* address): - cdef char* res_str - port = grpc_sockaddr_get_port(address) - str_len = grpc_sockaddr_to_string(&res_str, address, 0) - byte_str = _decode(res_str[:str_len]) - if byte_str.endswith(':' + str(port)): - byte_str = byte_str[:(0 - len(str(port)) - 1)] - byte_str = byte_str.lstrip('[') - byte_str = byte_str.rstrip(']') - byte_str = '{}'.format(byte_str) - return byte_str, port - -cdef sockaddr_to_tuple(const grpc_sockaddr* address, size_t length): - cdef grpc_resolved_address c_addr - string.memcpy(c_addr.addr, address, length) - c_addr.len = length - return resolved_addr_to_tuple(&c_addr) - -cdef sockaddr_is_ipv4(const grpc_sockaddr* address, size_t length): - cdef grpc_resolved_address c_addr - string.memcpy(c_addr.addr, address, length) - c_addr.len = length - return grpc_sockaddr_get_uri_scheme(&c_addr) == b'ipv4' - -cdef grpc_resolved_addresses* tuples_to_resolvaddr(tups): - cdef grpc_resolved_addresses* addresses - tups_set = set((tup[4][0], tup[4][1]) for tup in tups) - addresses = malloc(sizeof(grpc_resolved_addresses)) - addresses.naddrs = len(tups_set) - addresses.addrs = malloc(sizeof(grpc_resolved_address) * len(tups_set)) - i = 0 - for tup in set(tups_set): - hostname = str_to_bytes(tup[0]) - grpc_string_to_sockaddr(&addresses.addrs[i], hostname, tup[1]) - i += 1 - return addresses - def _spawn_greenlet(*args): greenlet = g_pool.spawn(*args) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pxd.pxi new file mode 100644 index 00000000000..2f00bab3c0a --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pxd.pxi @@ -0,0 +1,124 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# distutils: language=c++ + +cdef extern from "grpc/impl/codegen/slice.h": + struct grpc_slice_buffer: + int count + +cdef extern from "src/core/lib/iomgr/error.h": + struct grpc_error: + pass + +# TODO(https://github.com/grpc/grpc/issues/20135) Change the filename +# for something more meaningful. +cdef extern from "src/core/lib/iomgr/gevent_util.h": + grpc_error* grpc_socket_error(char* error) + char* grpc_slice_buffer_start(grpc_slice_buffer* buffer, int i) + int grpc_slice_buffer_length(grpc_slice_buffer* buffer, int i) + +cdef extern from "src/core/lib/iomgr/sockaddr.h": + ctypedef struct grpc_sockaddr: + pass + +cdef extern from "src/core/lib/iomgr/resolve_address.h": + ctypedef struct grpc_resolved_addresses: + size_t naddrs + grpc_resolved_address* addrs + + ctypedef struct grpc_resolved_address: + char[128] addr + size_t len + +cdef extern from "src/core/lib/iomgr/resolve_address_custom.h": + struct grpc_custom_resolver: + pass + + struct grpc_custom_resolver_vtable: + grpc_error* (*resolve)(char* host, char* port, grpc_resolved_addresses** res); + void (*resolve_async)(grpc_custom_resolver* resolver, char* host, char* port); + + void grpc_custom_resolve_callback(grpc_custom_resolver* resolver, + grpc_resolved_addresses* result, + grpc_error* error); + +cdef extern from "src/core/lib/iomgr/tcp_custom.h": + struct grpc_custom_socket: + void* impl + # We don't care about the rest of the fields + ctypedef void (*grpc_custom_connect_callback)(grpc_custom_socket* socket, + grpc_error* error) + ctypedef void (*grpc_custom_write_callback)(grpc_custom_socket* socket, + grpc_error* error) + ctypedef void (*grpc_custom_read_callback)(grpc_custom_socket* socket, + size_t nread, grpc_error* error) + ctypedef void (*grpc_custom_accept_callback)(grpc_custom_socket* socket, + grpc_custom_socket* client, + grpc_error* error) + ctypedef void (*grpc_custom_close_callback)(grpc_custom_socket* socket) + + struct grpc_socket_vtable: + grpc_error* (*init)(grpc_custom_socket* socket, int domain); + void (*connect)(grpc_custom_socket* socket, const grpc_sockaddr* addr, + size_t len, grpc_custom_connect_callback cb); + void (*destroy)(grpc_custom_socket* socket); + void (*shutdown)(grpc_custom_socket* socket); + void (*close)(grpc_custom_socket* socket, grpc_custom_close_callback cb); + void (*write)(grpc_custom_socket* socket, grpc_slice_buffer* slices, + grpc_custom_write_callback cb); + void (*read)(grpc_custom_socket* socket, char* buffer, size_t length, + grpc_custom_read_callback cb); + grpc_error* (*getpeername)(grpc_custom_socket* socket, + const grpc_sockaddr* addr, int* len); + grpc_error* (*getsockname)(grpc_custom_socket* socket, + const grpc_sockaddr* addr, int* len); + grpc_error* (*bind)(grpc_custom_socket* socket, const grpc_sockaddr* addr, + size_t len, int flags); + grpc_error* (*listen)(grpc_custom_socket* socket); + void (*accept)(grpc_custom_socket* socket, grpc_custom_socket* client, + grpc_custom_accept_callback cb); + +cdef extern from "src/core/lib/iomgr/timer_custom.h": + struct grpc_custom_timer: + void* timer + int timeout_ms + # We don't care about the rest of the fields + + struct grpc_custom_timer_vtable: + void (*start)(grpc_custom_timer* t); + void (*stop)(grpc_custom_timer* t); + + void grpc_custom_timer_callback(grpc_custom_timer* t, grpc_error* error); + +cdef extern from "src/core/lib/iomgr/pollset_custom.h": + struct grpc_custom_poller_vtable: + void (*init)() + void (*poll)(size_t timeout_ms) + void (*kick)() + void (*shutdown)() + +cdef extern from "src/core/lib/iomgr/iomgr_custom.h": + void grpc_custom_iomgr_init(grpc_socket_vtable* socket, + grpc_custom_resolver_vtable* resolver, + grpc_custom_timer_vtable* timer, + grpc_custom_poller_vtable* poller); + +cdef extern from "src/core/lib/iomgr/sockaddr_utils.h": + int grpc_sockaddr_get_port(const grpc_resolved_address *addr); + int grpc_sockaddr_to_string(char **out, const grpc_resolved_address *addr, + int normalize); + void grpc_string_to_sockaddr(grpc_resolved_address *out, char* addr, int port); + int grpc_sockaddr_set_port(const grpc_resolved_address *resolved_addr, + int port) + const char* grpc_sockaddr_get_uri_scheme(const grpc_resolved_address* resolved_addr) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pyx.pxi new file mode 100644 index 00000000000..9274f1c5fdb --- /dev/null +++ b/src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pyx.pxi @@ -0,0 +1,62 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# distutils: language=c++ + +from libc cimport string +from libc.stdlib cimport malloc + +cdef grpc_error* grpc_error_none(): + return 0 + +cdef grpc_error* socket_error(str syscall, str err): + error_str = "{} failed: {}".format(syscall, err) + error_bytes = str_to_bytes(error_str) + return grpc_socket_error(error_bytes) + +cdef resolved_addr_to_tuple(grpc_resolved_address* address): + cdef char* res_str + port = grpc_sockaddr_get_port(address) + str_len = grpc_sockaddr_to_string(&res_str, address, 0) + byte_str = _decode(res_str[:str_len]) + if byte_str.endswith(':' + str(port)): + byte_str = byte_str[:(0 - len(str(port)) - 1)] + byte_str = byte_str.lstrip('[') + byte_str = byte_str.rstrip(']') + byte_str = '{}'.format(byte_str) + return byte_str, port + +cdef sockaddr_to_tuple(const grpc_sockaddr* address, size_t length): + cdef grpc_resolved_address c_addr + string.memcpy(c_addr.addr, address, length) + c_addr.len = length + return resolved_addr_to_tuple(&c_addr) + +cdef sockaddr_is_ipv4(const grpc_sockaddr* address, size_t length): + cdef grpc_resolved_address c_addr + string.memcpy(c_addr.addr, address, length) + c_addr.len = length + return grpc_sockaddr_get_uri_scheme(&c_addr) == b'ipv4' + +cdef grpc_resolved_addresses* tuples_to_resolvaddr(tups): + cdef grpc_resolved_addresses* addresses + tups_set = set((tup[4][0], tup[4][1]) for tup in tups) + addresses = malloc(sizeof(grpc_resolved_addresses)) + addresses.naddrs = len(tups_set) + addresses.addrs = malloc(sizeof(grpc_resolved_address) * len(tups_set)) + i = 0 + for tup in set(tups_set): + hostname = str_to_bytes(tup[0]) + grpc_string_to_sockaddr(&addresses.addrs[i], hostname, tup[1]) + i += 1 + return addresses diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pxd b/src/python/grpcio/grpc/_cython/cygrpc.pxd index e29f7aee97a..4d081fb83e2 100644 --- a/src/python/grpcio/grpc/_cython/cygrpc.pxd +++ b/src/python/grpcio/grpc/_cython/cygrpc.pxd @@ -32,7 +32,18 @@ include "_cygrpc/time.pxd.pxi" include "_cygrpc/vtable.pxd.pxi" include "_cygrpc/_hooks.pxd.pxi" +include "_cygrpc/iomgr.pxd.pxi" + include "_cygrpc/grpc_gevent.pxd.pxi" IF UNAME_SYSNAME != "Windows": include "_cygrpc/fork_posix.pxd.pxi" + +# Following pxi files are part of the Aio module +include "_cygrpc/aio/iomgr/socket.pxd.pxi" +include "_cygrpc/aio/iomgr/timer.pxd.pxi" +include "_cygrpc/aio/iomgr/resolver.pxd.pxi" +include "_cygrpc/aio/grpc_aio.pxd.pxi" +include "_cygrpc/aio/callbackcontext.pxd.pxi" +include "_cygrpc/aio/call.pxd.pxi" +include "_cygrpc/aio/channel.pxd.pxi" diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pyx b/src/python/grpcio/grpc/_cython/cygrpc.pyx index f2dd0df89d4..316fb993095 100644 --- a/src/python/grpcio/grpc/_cython/cygrpc.pyx +++ b/src/python/grpcio/grpc/_cython/cygrpc.pyx @@ -17,6 +17,13 @@ cimport cpython import os.path import sys +try: + import asyncio +except ImportError: + # TODO(https://github.com/grpc/grpc/issues/19728) Improve how Aio Cython is + # distributed without breaking none compatible Python versions. For now, if + # Asyncio package is not available we just skip it. + pass # TODO(atash): figure out why the coverage tool gets confused about the Cython # coverage plugin when the following files don't have a '.pxi' suffix. @@ -39,6 +46,8 @@ include "_cygrpc/time.pyx.pxi" include "_cygrpc/vtable.pyx.pxi" include "_cygrpc/_hooks.pyx.pxi" +include "_cygrpc/iomgr.pyx.pxi" + include "_cygrpc/grpc_gevent.pyx.pxi" IF UNAME_SYSNAME == "Windows": @@ -46,6 +55,16 @@ IF UNAME_SYSNAME == "Windows": ELSE: include "_cygrpc/fork_posix.pyx.pxi" +# Following pxi files are part of the Aio module +include "_cygrpc/aio/iomgr/iomgr.pyx.pxi" +include "_cygrpc/aio/iomgr/socket.pyx.pxi" +include "_cygrpc/aio/iomgr/timer.pyx.pxi" +include "_cygrpc/aio/iomgr/resolver.pyx.pxi" +include "_cygrpc/aio/grpc_aio.pyx.pxi" +include "_cygrpc/aio/call.pyx.pxi" +include "_cygrpc/aio/channel.pyx.pxi" + + # # initialize gRPC # diff --git a/src/python/grpcio/grpc/experimental/BUILD.bazel b/src/python/grpcio/grpc/experimental/BUILD.bazel index cd8afe533b6..00815c4e72e 100644 --- a/src/python/grpcio/grpc/experimental/BUILD.bazel +++ b/src/python/grpcio/grpc/experimental/BUILD.bazel @@ -1,9 +1,21 @@ package(default_visibility = ["//visibility:public"]) +py_library( + name = "aio", + srcs = [ + "aio/__init__.py", + "aio/_channel.py", + ], + deps = [ + "//src/python/grpcio/grpc/_cython:cygrpc", + ], +) + py_library( name = "experimental", srcs = ["__init__.py",], deps = [ + ":aio", ":gevent", ":session_cache", ], diff --git a/src/python/grpcio/grpc/experimental/aio/__init__.py b/src/python/grpcio/grpc/experimental/aio/__init__.py new file mode 100644 index 00000000000..6004126549b --- /dev/null +++ b/src/python/grpcio/grpc/experimental/aio/__init__.py @@ -0,0 +1,123 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""gRPC's Asynchronous Python API.""" + +import abc +import six + +from grpc._cython.cygrpc import init_grpc_aio + + +class Channel(six.with_metaclass(abc.ABCMeta)): + """Asynchronous Channel implementation.""" + + @abc.abstractmethod + def unary_unary(self, + method, + request_serializer=None, + response_deserializer=None): + """Creates a UnaryUnaryMultiCallable for a unary-unary method. + + Args: + method: The name of the RPC method. + request_serializer: Optional behaviour for serializing the request + message. Request goes unserialized in case None is passed. + response_deserializer: Optional behaviour for deserializing the + response message. Response goes undeserialized in case None + is passed. + + Returns: + A UnaryUnaryMultiCallable value for the named unary-unary method. + """ + raise NotImplementedError() + + @abc.abstractmethod + async def close(self): + """Closes this Channel and releases all resources held by it. + + Closing the Channel will proactively terminate all RPCs active with the + Channel and it is not valid to invoke new RPCs with the Channel. + + This method is idempotent. + """ + raise NotImplementedError() + + @abc.abstractmethod + async def __aenter__(self): + """Starts an asynchronous context manager. + + Returns: + Channel the channel that was instantiated. + """ + raise NotImplementedError() + + @abc.abstractmethod + async def __aexit__(self, exc_type, exc_val, exc_tb): + """Finishes the asynchronous context manager by closing gracefully the channel.""" + raise NotImplementedError() + + +class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): + """Affords invoking a unary-unary RPC from client-side in an asynchronous way.""" + + @abc.abstractmethod + async def __call__(self, + request, + timeout=None, + metadata=None, + credentials=None, + wait_for_ready=None, + compression=None): + """Asynchronously invokes the underlying RPC. + + Args: + request: The request value for the RPC. + timeout: An optional duration of time in seconds to allow + for the RPC. + metadata: Optional :term:`metadata` to be transmitted to the + service-side of the RPC. + credentials: An optional CallCredentials for the RPC. Only valid for + secure Channel. + wait_for_ready: This is an EXPERIMENTAL argument. An optional + flag to enable wait for ready mechanism + compression: An element of grpc.compression, e.g. + grpc.compression.Gzip. This is an EXPERIMENTAL option. + + Returns: + The response value for the RPC. + + Raises: + RpcError: Indicating that the RPC terminated with non-OK status. The + raised RpcError will also be a Call for the RPC affording the RPC's + metadata, status code, and details. + """ + raise NotImplementedError() + + +def insecure_channel(target, options=None, compression=None): + """Creates an insecure asynchronous Channel to a server. + + Args: + target: The server address + options: An optional list of key-value pairs (channel args + in gRPC Core runtime) to configure the channel. + compression: An optional value indicating the compression method to be + used over the lifetime of the channel. This is an EXPERIMENTAL option. + + Returns: + A Channel. + """ + from grpc.experimental.aio import _channel # pylint: disable=cyclic-import + return _channel.Channel(target, () + if options is None else options, None, compression) diff --git a/src/python/grpcio/grpc/experimental/aio/_channel.py b/src/python/grpcio/grpc/experimental/aio/_channel.py new file mode 100644 index 00000000000..e3c8fcdbf2f --- /dev/null +++ b/src/python/grpcio/grpc/experimental/aio/_channel.py @@ -0,0 +1,105 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Invocation-side implementation of gRPC Asyncio Python.""" + +from grpc import _common +from grpc._cython import cygrpc +from grpc.experimental import aio + + +class UnaryUnaryMultiCallable(aio.UnaryUnaryMultiCallable): + + def __init__(self, channel, method, request_serializer, + response_deserializer): + self._channel = channel + self._method = method + self._request_serializer = request_serializer + self._response_deserializer = response_deserializer + + async def __call__(self, + request, + timeout=None, + metadata=None, + credentials=None, + wait_for_ready=None, + compression=None): + + if timeout: + raise NotImplementedError("TODO: timeout not implemented yet") + + if metadata: + raise NotImplementedError("TODO: metadata not implemented yet") + + if credentials: + raise NotImplementedError("TODO: credentials not implemented yet") + + if wait_for_ready: + raise NotImplementedError( + "TODO: wait_for_ready not implemented yet") + + if compression: + raise NotImplementedError("TODO: compression not implemented yet") + + response = await self._channel.unary_unary( + self._method, _common.serialize(request, self._request_serializer)) + + return _common.deserialize(response, self._response_deserializer) + + +class Channel(aio.Channel): + """A cygrpc.AioChannel-backed implementation of grpc.experimental.aio.Channel.""" + + def __init__(self, target, options, credentials, compression): + """Constructor. + + Args: + target: The target to which to connect. + options: Configuration options for the channel. + credentials: A cygrpc.ChannelCredentials or None. + compression: An optional value indicating the compression method to be + used over the lifetime of the channel. + """ + + if options: + raise NotImplementedError("TODO: options not implemented yet") + + if credentials: + raise NotImplementedError("TODO: credentials not implemented yet") + + if compression: + raise NotImplementedError("TODO: compression not implemented yet") + + self._channel = cygrpc.AioChannel(_common.encode(target)) + + def unary_unary(self, + method, + request_serializer=None, + response_deserializer=None): + + return UnaryUnaryMultiCallable(self._channel, _common.encode(method), + request_serializer, + response_deserializer) + + async def _close(self): + # TODO: Send cancellation status + self._channel.close() + + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc_val, exc_tb): + await self._close() + + async def close(self): + await self._close() diff --git a/src/python/grpcio_tests/commands.py b/src/python/grpcio_tests/commands.py index 61d8bdc1f7b..2912ba113c9 100644 --- a/src/python/grpcio_tests/commands.py +++ b/src/python/grpcio_tests/commands.py @@ -107,6 +107,35 @@ class TestLite(setuptools.Command): self.distribution.fetch_build_eggs(self.distribution.tests_require) +class TestAio(setuptools.Command): + """Command to run aio tests without fetching or building anything.""" + + description = 'run aio tests without fetching or building anything.' + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + self._add_eggs_to_path() + + import tests + loader = tests.Loader() + loader.loadTestsFromNames(['tests_aio']) + runner = tests.Runner() + result = runner.run(loader.suite) + if not result.wasSuccessful(): + sys.exit('Test failure') + + def _add_eggs_to_path(self): + """Fetch install and test requirements""" + self.distribution.fetch_build_eggs(self.distribution.install_requires) + self.distribution.fetch_build_eggs(self.distribution.tests_require) + + class TestGevent(setuptools.Command): """Command to run tests w/gevent.""" diff --git a/src/python/grpcio_tests/setup.py b/src/python/grpcio_tests/setup.py index f9cb9d0cec9..50ba1bb5942 100644 --- a/src/python/grpcio_tests/setup.py +++ b/src/python/grpcio_tests/setup.py @@ -58,6 +58,7 @@ COMMAND_CLASS = { 'run_interop': commands.RunInterop, 'test_lite': commands.TestLite, 'test_gevent': commands.TestGevent, + 'test_aio': commands.TestAio, } PACKAGE_DATA = { diff --git a/src/python/grpcio_tests/tests/_sanity/_sanity_test.py b/src/python/grpcio_tests/tests/_sanity/_sanity_test.py index 7da6e7b34c3..6b4efdaca9f 100644 --- a/src/python/grpcio_tests/tests/_sanity/_sanity_test.py +++ b/src/python/grpcio_tests/tests/_sanity/_sanity_test.py @@ -25,17 +25,20 @@ class SanityTest(unittest.TestCase): maxDiff = 32768 + TEST_PKG_MODULE_NAME = 'tests' + TEST_PKG_PATH = 'tests' + def testTestsJsonUpToDate(self): """Autodiscovers all test suites and checks that tests.json is up to date""" loader = tests.Loader() - loader.loadTestsFromNames(['tests']) + loader.loadTestsFromNames([self.TEST_PKG_MODULE_NAME]) test_suite_names = sorted({ test_case_class.id().rsplit('.', 1)[0] for test_case_class in tests._loader.iterate_suite_cases( loader.suite) }) - tests_json_string = pkgutil.get_data('tests', 'tests.json') + tests_json_string = pkgutil.get_data(self.TEST_PKG_PATH, 'tests.json') tests_json = json.loads(tests_json_string.decode() if six.PY3 else tests_json_string) diff --git a/src/python/grpcio_tests/tests_aio/__init__.py b/src/python/grpcio_tests/tests_aio/__init__.py new file mode 100644 index 00000000000..8ddd3106965 --- /dev/null +++ b/src/python/grpcio_tests/tests_aio/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import absolute_import + +from tests import _loader +from tests import _runner + +Loader = _loader.Loader +Runner = _runner.Runner diff --git a/src/python/grpcio_tests/tests_aio/_sanity/__init__.py b/src/python/grpcio_tests/tests_aio/_sanity/__init__.py new file mode 100644 index 00000000000..f4b321fc5b2 --- /dev/null +++ b/src/python/grpcio_tests/tests_aio/_sanity/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2019 The gRPC Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/src/python/grpcio_tests/tests_aio/_sanity/_sanity_test.py b/src/python/grpcio_tests/tests_aio/_sanity/_sanity_test.py new file mode 100644 index 00000000000..e74dec0739b --- /dev/null +++ b/src/python/grpcio_tests/tests_aio/_sanity/_sanity_test.py @@ -0,0 +1,27 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import unittest + +from tests._sanity import _sanity_test + + +class AioSanityTest(_sanity_test.SanityTest): + + TEST_PKG_MODULE_NAME = 'tests_aio' + TEST_PKG_PATH = 'tests_aio' + + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/src/python/grpcio_tests/tests_aio/tests.json b/src/python/grpcio_tests/tests_aio/tests.json new file mode 100644 index 00000000000..49d025a5abe --- /dev/null +++ b/src/python/grpcio_tests/tests_aio/tests.json @@ -0,0 +1,5 @@ +[ + "_sanity._sanity_test.AioSanityTest", + "unit.channel_test.TestChannel", + "unit.init_test.TestInsecureChannel" +] diff --git a/src/python/grpcio_tests/tests_aio/unit/__init__.py b/src/python/grpcio_tests/tests_aio/unit/__init__.py new file mode 100644 index 00000000000..f4b321fc5b2 --- /dev/null +++ b/src/python/grpcio_tests/tests_aio/unit/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2019 The gRPC Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/src/python/grpcio_tests/tests_aio/unit/channel_test.py b/src/python/grpcio_tests/tests_aio/unit/channel_test.py new file mode 100644 index 00000000000..6bc53ec625e --- /dev/null +++ b/src/python/grpcio_tests/tests_aio/unit/channel_test.py @@ -0,0 +1,58 @@ +# Copyright 2019 The gRPC Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging +import unittest + +from grpc.experimental import aio +from tests_aio.unit import test_base +from src.proto.grpc.testing import messages_pb2 + + +class TestChannel(test_base.AioTestBase): + + def test_async_context(self): + + async def coro(): + async with aio.insecure_channel(self.server_target) as channel: + hi = channel.unary_unary( + '/grpc.testing.TestService/UnaryCall', + request_serializer=messages_pb2.SimpleRequest. + SerializeToString, + response_deserializer=messages_pb2.SimpleResponse.FromString + ) + await hi(messages_pb2.SimpleRequest()) + + self.loop.run_until_complete(coro()) + + def test_unary_unary(self): + + async def coro(): + channel = aio.insecure_channel(self.server_target) + hi = channel.unary_unary( + '/grpc.testing.TestService/UnaryCall', + request_serializer=messages_pb2.SimpleRequest.SerializeToString, + response_deserializer=messages_pb2.SimpleResponse.FromString) + response = await hi(messages_pb2.SimpleRequest()) + + self.assertEqual(type(response), messages_pb2.SimpleResponse) + + await channel.close() + + self.loop.run_until_complete(coro()) + + +if __name__ == '__main__': + logging.basicConfig() + unittest.main(verbosity=2) diff --git a/src/python/grpcio_tests/tests_aio/unit/init_test.py b/src/python/grpcio_tests/tests_aio/unit/init_test.py new file mode 100644 index 00000000000..ab580f18e11 --- /dev/null +++ b/src/python/grpcio_tests/tests_aio/unit/init_test.py @@ -0,0 +1,35 @@ +# Copyright 2019 The gRPC Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging +import unittest + +from grpc.experimental import aio +from tests_aio.unit import test_base + + +class TestInsecureChannel(test_base.AioTestBase): + + def test_insecure_channel(self): + + async def coro(): + channel = aio.insecure_channel(self.server_target) + self.assertIsInstance(channel, aio.Channel) + + self.loop.run_until_complete(coro()) + + +if __name__ == '__main__': + logging.basicConfig() + unittest.main(verbosity=2) diff --git a/src/python/grpcio_tests/tests_aio/unit/sync_server.py b/src/python/grpcio_tests/tests_aio/unit/sync_server.py new file mode 100644 index 00000000000..105ded8e76c --- /dev/null +++ b/src/python/grpcio_tests/tests_aio/unit/sync_server.py @@ -0,0 +1,50 @@ +# Copyright 2019 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse + +from concurrent import futures +from time import sleep + +import grpc +from src.proto.grpc.testing import messages_pb2 +from src.proto.grpc.testing import test_pb2_grpc + + +# TODO (https://github.com/grpc/grpc/issues/19762) +# Change for an asynchronous server version once it's implemented. +class TestServiceServicer(test_pb2_grpc.TestServiceServicer): + + def UnaryCall(self, request, context): + return messages_pb2.SimpleResponse() + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Synchronous gRPC server.') + parser.add_argument( + '--host_and_port', + required=True, + type=str, + nargs=1, + help='the host and port to listen.') + args = parser.parse_args() + + server = grpc.server( + futures.ThreadPoolExecutor(max_workers=1), + options=(('grpc.so_reuseport', 1),)) + test_pb2_grpc.add_TestServiceServicer_to_server(TestServiceServicer(), + server) + server.add_insecure_port(args.host_and_port[0]) + server.start() + server.wait_for_termination() diff --git a/src/python/grpcio_tests/tests_aio/unit/test_base.py b/src/python/grpcio_tests/tests_aio/unit/test_base.py new file mode 100644 index 00000000000..0b325523e0f --- /dev/null +++ b/src/python/grpcio_tests/tests_aio/unit/test_base.py @@ -0,0 +1,101 @@ +# Copyright 2019 The gRPC Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import sys +import subprocess + +import asyncio +import unittest +import socket + +from grpc.experimental import aio +from tests_aio.unit import sync_server + + +def _get_free_loopback_tcp_port(): + if socket.has_ipv6: + tcp_socket = socket.socket(socket.AF_INET6) + host = "::1" + host_target = "[::1]" + else: + tcp_socket = socket.socket(socket.AF_INET) + host = "127.0.0.1" + host_target = host + tcp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) + tcp_socket.bind((host, 0)) + address_tuple = tcp_socket.getsockname() + return tcp_socket, "%s:%s" % (host_target, address_tuple[1]) + + +class _Server: + """_Server is an wrapper for a sync-server subprocess. + + The synchronous server is executed in another process which initializes + implicitly the grpc using the synchronous configuration. Both worlds + can not coexist within the same process. + """ + + def __init__(self, host_and_port): # pylint: disable=W0621 + self._host_and_port = host_and_port + self._handle = None + + def start(self): + assert self._handle is None + + try: + from google3.pyglib import resources + executable = resources.GetResourceFilename( + "google3/third_party/py/grpc/sync_server") + args = [executable, '--host_and_port', self._host_and_port] + except ImportError: + executable = sys.executable + directory, _ = os.path.split(os.path.abspath(__file__)) + filename = directory + '/sync_server.py' + args = [ + executable, filename, '--host_and_port', self._host_and_port + ] + + self._handle = subprocess.Popen(args) + + def terminate(self): + if not self._handle: + return + + self._handle.terminate() + self._handle.wait() + self._handle = None + + +class AioTestBase(unittest.TestCase): + + def setUp(self): + self._socket, self._target = _get_free_loopback_tcp_port() + self._server = _Server(self._target) + self._server.start() + self._loop = asyncio.new_event_loop() + asyncio.set_event_loop(self._loop) + aio.init_grpc_aio() + + def tearDown(self): + self._server.terminate() + self._socket.close() + + @property + def loop(self): + return self._loop + + @property + def server_target(self): + return self._target diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index a3708dc2b80..3476f9ce4c8 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -703,6 +703,10 @@ class PythonConfig( class PythonLanguage(object): + _DEFAULT_COMMAND = 'test_lite' + _TEST_SPECS_FILE = 'src/python/grpcio_tests/tests/tests.json' + _TEST_FOLDER = 'test' + def configure(self, config, args): self.config = config self.args = args @@ -710,8 +714,7 @@ class PythonLanguage(object): def test_specs(self): # load list of known test suites - with open( - 'src/python/grpcio_tests/tests/tests.json') as tests_json_file: + with open(self._TEST_SPECS_FILE) as tests_json_file: tests_json = json.load(tests_json_file) environment = dict(_FORCE_ENVIRON_FOR_WRAPPERS) return [ @@ -721,7 +724,8 @@ class PythonLanguage(object): environ=dict( list(environment.items()) + [( 'GRPC_PYTHON_TESTRUNNER_FILTER', str(suite_name))]), - shortname='%s.test.%s' % (config.name, suite_name), + shortname='%s.%s.%s' % (config.name, self._TEST_FOLDER, + suite_name), ) for suite_name in tests_json for config in self.pythons ] @@ -789,7 +793,7 @@ class PythonLanguage(object): venv_relative_python = ['bin/python'] toolchain = ['unix'] - test_command = 'test_lite' + test_command = self._DEFAULT_COMMAND if args.iomgr_platform == 'gevent': test_command = 'test_gevent' runner = [ @@ -882,6 +886,31 @@ class PythonLanguage(object): return 'python' +class PythonAioLanguage(PythonLanguage): + + _DEFAULT_COMMAND = 'test_aio' + _TEST_SPECS_FILE = 'src/python/grpcio_tests/tests_aio/tests.json' + _TEST_FOLDER = 'test_aio' + + def configure(self, config, args): + self.config = config + self.args = args + self.pythons = self._get_pythons(self.args) + + def _get_pythons(self, args): + """Get python runtimes to test with, based on current platform, architecture, compiler etc.""" + + if args.compiler not in ('python3.6', 'python3.7', 'python3.8'): + raise Exception('Compiler %s not supported.' % args.compiler) + if args.iomgr_platform not in ('native'): + raise Exception( + 'Iomgr platform %s not supported.' % args.iomgr_platform) + return super()._get_pythons(args) + + def __str__(self): + return 'python_aio' + + class RubyLanguage(object): def configure(self, config, args): @@ -1269,6 +1298,7 @@ _LANGUAGES = { 'php': PhpLanguage(), 'php7': Php7Language(), 'python': PythonLanguage(), + 'python-aio': PythonAioLanguage(), 'ruby': RubyLanguage(), 'csharp': CSharpLanguage(), 'objc': ObjCLanguage(), From e9802ca190550dbe38f89c4b79914b008f56a26f Mon Sep 17 00:00:00 2001 From: Easwar Swaminathan Date: Wed, 11 Sep 2019 19:06:34 +0000 Subject: [PATCH 1534/1555] Add v1.22.3 and v1.23.1 release of grpc-go to interop matrix. v1.23.0 seems to have missed out since the [PR](https://github.com/grpc/grpc/pull/19928) to add that had a merge conflict and was never merged. --- tools/interop_matrix/client_matrix.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index 5011e2ae700..ec219655543 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -145,7 +145,8 @@ LANG_RELEASE_MATRIX = { ReleaseInfo(runtimes=['go1.11'], testcases_file='go__v1.0.5')), ('v1.20.0', ReleaseInfo(runtimes=['go1.11'])), ('v1.21.3', ReleaseInfo(runtimes=['go1.11'])), - ('v1.22.2', ReleaseInfo(runtimes=['go1.11'])), + ('v1.22.3', ReleaseInfo(runtimes=['go1.11'])), + ('v1.23.1', ReleaseInfo(runtimes=['go1.11'])), ]), 'java': OrderedDict([ From 35a1f0a9634baea573b343edf77e63f09dbff039 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 2 Sep 2019 21:10:11 -0700 Subject: [PATCH 1535/1555] Add transport interceptor --- src/objective-c/GRPCClient/GRPCCall.m | 11 + src/objective-c/GRPCClient/GRPCTransport.h | 6 +- .../GRPCCoreCronet/GRPCCoreCronetFactory.m | 4 + .../private/GRPCCore/GRPCCoreFactory.m | 8 + .../tests/Tests.xcodeproj/project.pbxproj | 4 + .../tests/UnitTests/TransportTests.m | 232 ++++++++++++++++++ 6 files changed, 264 insertions(+), 1 deletion(-) create mode 100644 src/objective-c/tests/UnitTests/TransportTests.m diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 87c2768187e..0cfa38aa3e5 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -22,6 +22,7 @@ #import "GRPCCallOptions.h" #import "GRPCInterceptor.h" +#import "GRPCTransport.h" #import "private/GRPCTransport+Private.h" NSString *const kGRPCHeadersKey = @"io.grpc.HeadersKey"; @@ -183,6 +184,16 @@ NSString *const kGRPCErrorDomain = @"io.grpc"; if (globalInterceptorFactory != nil) { [interceptorFactories addObject:globalInterceptorFactory]; } + if (_actualCallOptions.transport != NULL) { + id transportFactory = [[GRPCTransportRegistry sharedInstance] + getTransportFactoryWithID:_actualCallOptions.transport]; + + NSArray> *transportInterceptorFactories = + transportFactory.transportInterceptorFactories; + if (transportInterceptorFactories != nil) { + [interceptorFactories addObjectsFromArray:transportInterceptorFactories]; + } + } // continuously create interceptor until one is successfully created while (_firstInterceptor == nil) { if (interceptorFactories.count == 0) { diff --git a/src/objective-c/GRPCClient/GRPCTransport.h b/src/objective-c/GRPCClient/GRPCTransport.h index a29dbd20e4d..400cf46e705 100644 --- a/src/objective-c/GRPCClient/GRPCTransport.h +++ b/src/objective-c/GRPCClient/GRPCTransport.h @@ -48,11 +48,15 @@ NSUInteger TransportIDHash(GRPCTransportID); @class GRPCCallOptions; @class GRPCTransport; -/** The factory method to create a transport. */ +/** The factory to create a transport. */ @protocol GRPCTransportFactory +/** Create a transport implementation. */ - (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager; +/** Get a list of factories for transport inteceptors. */ +@property(nonatomic, readonly) NSArray> *transportInterceptorFactories; + @end /** The registry of transport implementations. */ diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m index 2205d167d82..a595f4b7e63 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.m @@ -47,6 +47,10 @@ static dispatch_once_t gInitGRPCCoreCronetFactory; return [[GRPCCall2Internal alloc] initWithTransportManager:transportManager]; } +- (NSArray> *)transportInterceptorFactories { + return nil; +} + - (id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions { return [GRPCCronetChannelFactory sharedInstance]; } diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m index 928625f1275..c3cefb7b649 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.m @@ -48,6 +48,10 @@ static dispatch_once_t gInitGRPCCoreInsecureFactory; return [[GRPCCall2Internal alloc] initWithTransportManager:transportManager]; } +- (NSArray> *)transportInterceptorFactories { + return nil; +} + - (id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions { NSError *error; id factory = @@ -83,6 +87,10 @@ static dispatch_once_t gInitGRPCCoreInsecureFactory; return [[GRPCCall2Internal alloc] initWithTransportManager:transportManager]; } +- (NSArray> *)transportInterceptorFactories { + return nil; +} + - (id)createCoreChannelFactoryWithCallOptions:(GRPCCallOptions *)callOptions { return [GRPCInsecureChannelFactory sharedInstance]; } diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index 2ce32d3916d..927a7b64c3e 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -32,6 +32,7 @@ 5E7F489022778C95006656AD /* RxLibraryUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7F488A22778B5D006656AD /* RxLibraryUnitTests.m */; }; 5E9F1C332321AB1700837469 /* TransportRegistryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E9F1C322321AB1700837469 /* TransportRegistryTests.m */; }; 5E9F1C352321C9B200837469 /* TransportRegistryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E9F1C342321C9B200837469 /* TransportRegistryTests.m */; }; + 5E9F1C59232302E200837469 /* TransportTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E9F1C58232302E200837469 /* TransportTests.m */; }; 5EA4770322736178000F72FC /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; }; 5EA477042273617B000F72FC /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; }; 5EA4770522736AC4000F72FC /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; }; @@ -125,6 +126,7 @@ 5E7F488A22778B5D006656AD /* RxLibraryUnitTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RxLibraryUnitTests.m; sourceTree = ""; }; 5E9F1C322321AB1700837469 /* TransportRegistryTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TransportRegistryTests.m; sourceTree = ""; }; 5E9F1C342321C9B200837469 /* TransportRegistryTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TransportRegistryTests.m; sourceTree = ""; }; + 5E9F1C58232302E200837469 /* TransportTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TransportTests.m; sourceTree = ""; }; 5EA476F42272816A000F72FC /* InteropTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 5EA908CF4CDA4CE218352A06 /* Pods-InteropTestsLocalSSLCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.release.xcconfig"; sourceTree = ""; }; 5EAD6D261E27047400002378 /* CronetUnitTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = CronetUnitTests.mm; path = CronetTests/CronetUnitTests.mm; sourceTree = SOURCE_ROOT; }; @@ -366,6 +368,7 @@ 5E0282E7215AA697007AC99D /* UnitTests */ = { isa = PBXGroup; children = ( + 5E9F1C58232302E200837469 /* TransportTests.m */, 5E9F1C322321AB1700837469 /* TransportRegistryTests.m */, 5E7F488A22778B5D006656AD /* RxLibraryUnitTests.m */, 5E7F488622778AEA006656AD /* GRPCClientTests.m */, @@ -874,6 +877,7 @@ 5E0282E9215AA697007AC99D /* NSErrorUnitTests.m in Sources */, 5E7F4880227782C1006656AD /* APIv2Tests.m in Sources */, 5E7F487D22778256006656AD /* ChannelPoolTest.m in Sources */, + 5E9F1C59232302E200837469 /* TransportTests.m in Sources */, 5E9F1C332321AB1700837469 /* TransportRegistryTests.m in Sources */, 5E7F488722778AEA006656AD /* GRPCClientTests.m in Sources */, 5E7F487E22778256006656AD /* ChannelTests.m in Sources */, diff --git a/src/objective-c/tests/UnitTests/TransportTests.m b/src/objective-c/tests/UnitTests/TransportTests.m new file mode 100644 index 00000000000..5f4db26258e --- /dev/null +++ b/src/objective-c/tests/UnitTests/TransportTests.m @@ -0,0 +1,232 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import +#import +#import +#import + +#define TEST_TIMEOUT (8.0) + +static NSString *const kRemoteHost = @"grpc-test.sandbox.googleapis.com:443"; + +static const GRPCTransportID kFakeTransportID = "io.grpc.transport.unittest.fake"; + +@class GRPCFakeTransportFactory; +dispatch_once_t initFakeTransportFactory; +static GRPCFakeTransportFactory *fakeTransportFactory; + +@interface GRPCFakeTransportFactory : NSObject + +@property(atomic) GRPCTransport *nextTransportInstance; +- (void)setTransportInterceptorFactories:(NSArray> *)factories; + +@end + +@implementation GRPCFakeTransportFactory { + NSArray> *_interceptorFactories; +} + ++ (instancetype)sharedInstance { + dispatch_once(&initFakeTransportFactory, ^{ + fakeTransportFactory = [[GRPCFakeTransportFactory alloc] init]; + }); + return fakeTransportFactory; +} + ++ (void)load { + [[GRPCTransportRegistry sharedInstance] registerTransportWithID:kFakeTransportID + factory:[self sharedInstance]]; +} + +- (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager { + return _nextTransportInstance; +} + +- (void)setTransportInterceptorFactories:(NSArray> *)factories { + _interceptorFactories = [NSArray arrayWithArray:factories]; +} + +- (NSArray> *)transportInterceptorFactories { + return _interceptorFactories; +} + +@end + +@interface DummyInterceptor : GRPCInterceptor + +@property(atomic) BOOL hit; + +@end + +@implementation DummyInterceptor { + GRPCInterceptorManager *_manager; +} + +- (instancetype)initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager + dispatchQueue:(dispatch_queue_t)dispatchQueue { + if (dispatchQueue == nil) { + dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); + } + if ((self = [super initWithInterceptorManager:interceptorManager dispatchQueue:dispatchQueue])) { + _manager = interceptorManager; + } + return self; +} + +- (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions + callOptions:(GRPCCallOptions *)callOptions { + self.hit = YES; + [_manager + forwardPreviousInterceptorCloseWithTrailingMetadata:nil + error:[NSError + errorWithDomain:kGRPCErrorDomain + code:GRPCErrorCodeCancelled + userInfo:@{ + NSLocalizedDescriptionKey : + @"Canceled." + }]]; + [_manager shutDown]; +} + +@end + +@interface DummyInterceptorFactory : NSObject + ++ (instancetype)sharedInstance; + +@end + +static DummyInterceptorFactory *dummyInterceptorFactory; +static dispatch_once_t initDummyInterceptorFactory; + +@implementation DummyInterceptorFactory + ++ (instancetype)sharedInstance { + dispatch_once(&initDummyInterceptorFactory, ^{ + dummyInterceptorFactory = [[DummyInterceptorFactory alloc] init]; + }); + return dummyInterceptorFactory; +} + +- (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { + return [[DummyInterceptor alloc] + initWithInterceptorManager:interceptorManager + dispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL)]; +} + +@end + +@interface TestsBlockCallbacks : NSObject + +- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback + dataCallback:(void (^)(id))dataCallback + closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback + writeMessageCallback:(void (^)(void))writeMessageCallback; + +@end + +@implementation TestsBlockCallbacks { + void (^_initialMetadataCallback)(NSDictionary *); + void (^_dataCallback)(id); + void (^_closeCallback)(NSDictionary *, NSError *); + void (^_writeMessageCallback)(void); + dispatch_queue_t _dispatchQueue; +} + +- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback + dataCallback:(void (^)(id))dataCallback + closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback + writeMessageCallback:(void (^)(void))writeMessageCallback { + if ((self = [super init])) { + _initialMetadataCallback = initialMetadataCallback; + _dataCallback = dataCallback; + _closeCallback = closeCallback; + _writeMessageCallback = writeMessageCallback; + _dispatchQueue = dispatch_queue_create(nil, DISPATCH_QUEUE_SERIAL); + } + return self; +} + +- (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata { + if (_initialMetadataCallback) { + _initialMetadataCallback(initialMetadata); + } +} + +- (void)didReceiveProtoMessage:(id)message { + if (_dataCallback) { + _dataCallback(message); + } +} + +- (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { + if (_closeCallback) { + _closeCallback(trailingMetadata, error); + } +} + +- (void)didWriteMessage { + if (_writeMessageCallback) { + _writeMessageCallback(); + } +} + +- (dispatch_queue_t)dispatchQueue { + return _dispatchQueue; +} +@end + +@interface TransportTests : XCTestCase + +@end + +@implementation TransportTests + +- (void)testTransportInterceptors { + __weak XCTestExpectation *expectComplete = + [self expectationWithDescription:@"Expect call complete"]; + [GRPCFakeTransportFactory sharedInstance].nextTransportInstance = nil; + + [[GRPCFakeTransportFactory sharedInstance] + setTransportInterceptorFactories:@[ [DummyInterceptorFactory sharedInstance] ]]; + GRPCRequestOptions *requestOptions = + [[GRPCRequestOptions alloc] initWithHost:kRemoteHost + path:@"/UnaryCall" + safety:GRPCCallSafetyDefault]; + GRPCMutableCallOptions *callOptions = [[GRPCMutableCallOptions alloc] init]; + callOptions.transport = kFakeTransportID; + GRPCCall2 *call = [[GRPCCall2 alloc] + initWithRequestOptions:requestOptions + responseHandler:[[TestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + dataCallback:nil + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + XCTAssertNotNil(error); + XCTAssertEqual(error.code, + GRPCErrorCodeCancelled); + [expectComplete fulfill]; + } + writeMessageCallback:nil] + callOptions:callOptions]; + [call start]; + [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; +} + +@end From 1b1364eb6b6b17875d1dce77377ec1a8b343d0a2 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 11 Sep 2019 14:17:27 -0700 Subject: [PATCH 1536/1555] Reviewer comments --- .../filters/http/client/http_client_filter.cc | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/core/ext/filters/http/client/http_client_filter.cc b/src/core/ext/filters/http/client/http_client_filter.cc index 1793e8106e4..1687f7ead09 100644 --- a/src/core/ext/filters/http/client/http_client_filter.cc +++ b/src/core/ext/filters/http/client/http_client_filter.cc @@ -340,11 +340,11 @@ static void remove_if_present(grpc_metadata_batch* batch, } } -static void hc_start_transport_stream_op_batch( +static void http_client_start_transport_stream_op_batch( grpc_call_element* elem, grpc_transport_stream_op_batch* batch) { call_data* calld = static_cast(elem->call_data); channel_data* channeld = static_cast(elem->channel_data); - GPR_TIMER_SCOPE("hc_start_transport_stream_op_batch", 0); + GPR_TIMER_SCOPE("http_client_start_transport_stream_op_batch", 0); if (batch->recv_initial_metadata) { /* substitute our callback for the higher callback */ @@ -465,16 +465,16 @@ done: } /* Constructor for call_data */ -static grpc_error* hc_init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* http_client_init_call_elem( + grpc_call_element* elem, const grpc_call_element_args* args) { new (elem->call_data) call_data(elem, *args); return GRPC_ERROR_NONE; } /* Destructor for call_data */ -static void hc_destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { +static void http_client_destroy_call_elem( + grpc_call_element* elem, const grpc_call_final_info* final_info, + grpc_closure* ignored) { call_data* calld = static_cast(elem->call_data); calld->~call_data(); } @@ -566,8 +566,8 @@ static grpc_core::ManagedMemorySlice user_agent_from_args( } /* Constructor for channel_data */ -static grpc_error* hc_init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* http_client_init_channel_elem( + grpc_channel_element* elem, grpc_channel_element_args* args) { channel_data* chand = static_cast(elem->channel_data); GPR_ASSERT(!args->is_last); GPR_ASSERT(args->optional_transport != nullptr); @@ -582,20 +582,20 @@ static grpc_error* hc_init_channel_elem(grpc_channel_element* elem, } /* Destructor for channel data */ -static void hc_destroy_channel_elem(grpc_channel_element* elem) { +static void http_client_destroy_channel_elem(grpc_channel_element* elem) { channel_data* chand = static_cast(elem->channel_data); GRPC_MDELEM_UNREF(chand->user_agent); } const grpc_channel_filter grpc_http_client_filter = { - hc_start_transport_stream_op_batch, + http_client_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), - hc_init_call_elem, + http_client_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - hc_destroy_call_elem, + http_client_destroy_call_elem, sizeof(channel_data), - hc_init_channel_elem, - hc_destroy_channel_elem, + http_client_init_channel_elem, + http_client_destroy_channel_elem, grpc_channel_next_get_info, "http-client"}; From 9f6f04d91a89fb71ab7a46932aa43df7ca8d2a5f Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 11 Sep 2019 14:12:29 -0700 Subject: [PATCH 1537/1555] Address comments --- src/objective-c/GRPCClient/GRPCCall.m | 8 +-- .../tests/UnitTests/TransportTests.m | 51 ++++++++++++------- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 0cfa38aa3e5..047e6774c74 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -197,14 +197,15 @@ NSString *const kGRPCErrorDomain = @"io.grpc"; // continuously create interceptor until one is successfully created while (_firstInterceptor == nil) { if (interceptorFactories.count == 0) { - _firstInterceptor = [[GRPCTransportManager alloc] initWithTransportID:_callOptions.transport - previousInterceptor:dispatcher]; + _firstInterceptor = + [[GRPCTransportManager alloc] initWithTransportID:_actualCallOptions.transport + previousInterceptor:dispatcher]; break; } else { _firstInterceptor = [[GRPCInterceptorManager alloc] initWithFactories:interceptorFactories previousInterceptor:dispatcher - transportID:_callOptions.transport]; + transportID:_actualCallOptions.transport]; if (_firstInterceptor == nil) { [interceptorFactories removeObjectAtIndex:0]; } @@ -215,7 +216,6 @@ NSString *const kGRPCErrorDomain = @"io.grpc"; NSLog(@"Failed to create interceptor or transport."); } } - return self; } diff --git a/src/objective-c/tests/UnitTests/TransportTests.m b/src/objective-c/tests/UnitTests/TransportTests.m index 5f4db26258e..37564cdb972 100644 --- a/src/objective-c/tests/UnitTests/TransportTests.m +++ b/src/objective-c/tests/UnitTests/TransportTests.m @@ -76,15 +76,18 @@ static GRPCFakeTransportFactory *fakeTransportFactory; @implementation DummyInterceptor { GRPCInterceptorManager *_manager; + BOOL _passthrough; } - (instancetype)initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager - dispatchQueue:(dispatch_queue_t)dispatchQueue { + dispatchQueue:(dispatch_queue_t)dispatchQueue + passthrough:(BOOL)passthrough { if (dispatchQueue == nil) { dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); } if ((self = [super initWithInterceptorManager:interceptorManager dispatchQueue:dispatchQueue])) { _manager = interceptorManager; + _passthrough = passthrough; } return self; } @@ -92,42 +95,50 @@ static GRPCFakeTransportFactory *fakeTransportFactory; - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions callOptions:(GRPCCallOptions *)callOptions { self.hit = YES; - [_manager - forwardPreviousInterceptorCloseWithTrailingMetadata:nil - error:[NSError + if (_passthrough) { + [super startWithRequestOptions:requestOptions callOptions:callOptions]; + } else { + [_manager + forwardPreviousInterceptorCloseWithTrailingMetadata:nil + error: + [NSError errorWithDomain:kGRPCErrorDomain code:GRPCErrorCodeCancelled userInfo:@{ NSLocalizedDescriptionKey : @"Canceled." }]]; - [_manager shutDown]; + [_manager shutDown]; + } } @end @interface DummyInterceptorFactory : NSObject -+ (instancetype)sharedInstance; +- (instancetype)initWithPassthrough:(BOOL)passthrough; + +@property(nonatomic, readonly) DummyInterceptor *lastInterceptor; @end -static DummyInterceptorFactory *dummyInterceptorFactory; -static dispatch_once_t initDummyInterceptorFactory; +@implementation DummyInterceptorFactory { + BOOL _passthrough; +} -@implementation DummyInterceptorFactory - -+ (instancetype)sharedInstance { - dispatch_once(&initDummyInterceptorFactory, ^{ - dummyInterceptorFactory = [[DummyInterceptorFactory alloc] init]; - }); - return dummyInterceptorFactory; +- (instancetype)initWithPassthrough:(BOOL)passthrough { + if ((self = [super init])) { + _passthrough = passthrough; + } + return self; } - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager { - return [[DummyInterceptor alloc] + _lastInterceptor = [[DummyInterceptor alloc] initWithInterceptorManager:interceptorManager - dispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL)]; + dispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL) + passthrough:_passthrough]; + return _lastInterceptor; } @end @@ -203,8 +214,10 @@ static dispatch_once_t initDummyInterceptorFactory; [self expectationWithDescription:@"Expect call complete"]; [GRPCFakeTransportFactory sharedInstance].nextTransportInstance = nil; + DummyInterceptorFactory *factory = [[DummyInterceptorFactory alloc] initWithPassthrough:YES]; + DummyInterceptorFactory *factory2 = [[DummyInterceptorFactory alloc] initWithPassthrough:NO]; [[GRPCFakeTransportFactory sharedInstance] - setTransportInterceptorFactories:@[ [DummyInterceptorFactory sharedInstance] ]]; + setTransportInterceptorFactories:@[ factory, factory2 ]]; GRPCRequestOptions *requestOptions = [[GRPCRequestOptions alloc] initWithHost:kRemoteHost path:@"/UnaryCall" @@ -227,6 +240,8 @@ static dispatch_once_t initDummyInterceptorFactory; callOptions:callOptions]; [call start]; [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; + XCTAssertTrue(factory.lastInterceptor.hit); + XCTAssertTrue(factory2.lastInterceptor.hit); } @end From 5630b97a6ccb1495707119027996bddf8ccb47c9 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 12 Sep 2019 10:18:59 +0200 Subject: [PATCH 1538/1555] update docs with grpc-dotnet info --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b3a4c1f17d1..9f91412bc2c 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Libraries in different languages may be in various states of development. We are | Ruby | [src/ruby](src/ruby) | | Python | [src/python](src/python) | | PHP | [src/php](src/php) | -| C# | [src/csharp](src/csharp) | +| C# (core library based) | [src/csharp](src/csharp) | | Objective-C | [src/objective-c](src/objective-c) | | Language | Source repo | @@ -82,4 +82,4 @@ Libraries in different languages may be in various states of development. We are | NodeJS | [grpc-node](https://github.com/grpc/grpc-node) | | WebJS | [grpc-web](https://github.com/grpc/grpc-web) | | Dart | [grpc-dart](https://github.com/grpc/grpc-dart) | - +| .NET (pure C# impl.) | [grpc-dotnet](https://github.com/grpc/grpc-dotnet) | From 275b613681b62e7b14a84d263118c5ef363740bc Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 12 Sep 2019 14:52:06 +0200 Subject: [PATCH 1539/1555] note on two C# implementations --- src/csharp/README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/csharp/README.md b/src/csharp/README.md index 13c8502af61..26da8d560cc 100644 --- a/src/csharp/README.md +++ b/src/csharp/README.md @@ -2,7 +2,18 @@ gRPC C# ======= -A C# implementation of gRPC. +A C# implementation of gRPC based on the native gRPC Core library. + +There are currently two official implementations of gRPC for C# + +- The original gRPC C# implementation based on the native gRPC Core library (the source code lives in this directory) +- The new "gRPC for .NET" implementation written in pure C# and based on the newly released .NET Core 3 (source code available at https://github.com/grpc/grpc-dotnet) + +The implementations are meant to coexist side-by-side and each has its own advantages in terms of available features, integrations, supported platforms, maturity level and performance. +They share the same API for invoking and handling RPCs, thus limiting the lock-in and enabling users to choose the implementation that satisfies their needs the best +(and perhaps adjust their choice over time without needing to do too much refactoring). + +The following documentation is for the original gRPC C# implementation only (the `Grpc.Core` nuget package). SUPPORTED PLATFORMS ------------------ From a879ff73c29c932a3e864b865341bf75901618c7 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Thu, 12 Sep 2019 16:27:45 -0700 Subject: [PATCH 1540/1555] Move mock test to use ::grpc_impl Some mock tests are using ::grpc which was causing build issues. Move them over to use ::grpc_impl. --- include/grpcpp/test/mock_stream.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/grpcpp/test/mock_stream.h b/include/grpcpp/test/mock_stream.h index 93963f7dbb7..b4e16159061 100644 --- a/include/grpcpp/test/mock_stream.h +++ b/include/grpcpp/test/mock_stream.h @@ -31,7 +31,7 @@ namespace grpc { namespace testing { template -class MockClientReader : public ClientReaderInterface { +class MockClientReader : public ::grpc_impl::ClientReaderInterface { public: MockClientReader() = default; @@ -47,7 +47,7 @@ class MockClientReader : public ClientReaderInterface { }; template -class MockClientWriter : public ClientWriterInterface { +class MockClientWriter : public ::grpc_impl::ClientWriterInterface { public: MockClientWriter() = default; @@ -62,7 +62,7 @@ class MockClientWriter : public ClientWriterInterface { }; template -class MockClientReaderWriter : public ClientReaderWriterInterface { +class MockClientReaderWriter : public ::grpc_impl::ClientReaderWriterInterface { public: MockClientReaderWriter() = default; @@ -85,7 +85,7 @@ class MockClientReaderWriter : public ClientReaderWriterInterface { template class MockClientAsyncResponseReader - : public ClientAsyncResponseReaderInterface { + : public ::grpc_impl::ClientAsyncResponseReaderInterface { public: MockClientAsyncResponseReader() = default; @@ -107,7 +107,7 @@ class MockClientAsyncReader : public ClientAsyncReaderInterface { }; template -class MockClientAsyncWriter : public ClientAsyncWriterInterface { +class MockClientAsyncWriter : public ::grpc_impl::ClientAsyncWriterInterface { public: MockClientAsyncWriter() = default; From 3e4fd7967c3d07e7cec501c583efc19e246cd312 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Fri, 13 Sep 2019 09:10:59 -0700 Subject: [PATCH 1541/1555] Formatting fixes --- include/grpcpp/test/mock_stream.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/grpcpp/test/mock_stream.h b/include/grpcpp/test/mock_stream.h index b4e16159061..55e76f6f0a2 100644 --- a/include/grpcpp/test/mock_stream.h +++ b/include/grpcpp/test/mock_stream.h @@ -62,7 +62,8 @@ class MockClientWriter : public ::grpc_impl::ClientWriterInterface { }; template -class MockClientReaderWriter : public ::grpc_impl::ClientReaderWriterInterface { +class MockClientReaderWriter + : public ::grpc_impl::ClientReaderWriterInterface { public: MockClientReaderWriter() = default; @@ -107,7 +108,8 @@ class MockClientAsyncReader : public ClientAsyncReaderInterface { }; template -class MockClientAsyncWriter : public ::grpc_impl::ClientAsyncWriterInterface { +class MockClientAsyncWriter + : public ::grpc_impl::ClientAsyncWriterInterface { public: MockClientAsyncWriter() = default; From ad8d728b0015eba4075aa3abf118920eaa751ad4 Mon Sep 17 00:00:00 2001 From: jiangtaoli2016 Date: Fri, 13 Sep 2019 10:31:22 -0700 Subject: [PATCH 1542/1555] Root pem certificates update on Sept 2019 --- etc/roots.pem | 100 -------------------------------------------------- 1 file changed, 100 deletions(-) diff --git a/etc/roots.pem b/etc/roots.pem index 22bd2ab88dd..85850b9a78f 100644 --- a/etc/roots.pem +++ b/etc/roots.pem @@ -774,36 +774,6 @@ vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep +OkuE6N36B9K -----END CERTIFICATE----- -# Issuer: CN=Class 2 Primary CA O=Certplus -# Subject: CN=Class 2 Primary CA O=Certplus -# Label: "Certplus Class 2 Primary CA" -# Serial: 177770208045934040241468760488327595043 -# MD5 Fingerprint: 88:2c:8c:52:b8:a2:3c:f3:f7:bb:03:ea:ae:ac:42:0b -# SHA1 Fingerprint: 74:20:74:41:72:9c:dd:92:ec:79:31:d8:23:10:8d:c2:81:92:e2:bb -# SHA256 Fingerprint: 0f:99:3c:8a:ef:97:ba:af:56:87:14:0e:d5:9a:d1:82:1b:b4:af:ac:f0:aa:9a:58:b5:d5:7a:33:8a:3a:fb:cb ------BEGIN CERTIFICATE----- -MIIDkjCCAnqgAwIBAgIRAIW9S/PY2uNp9pTXX8OlRCMwDQYJKoZIhvcNAQEFBQAw -PTELMAkGA1UEBhMCRlIxETAPBgNVBAoTCENlcnRwbHVzMRswGQYDVQQDExJDbGFz -cyAyIFByaW1hcnkgQ0EwHhcNOTkwNzA3MTcwNTAwWhcNMTkwNzA2MjM1OTU5WjA9 -MQswCQYDVQQGEwJGUjERMA8GA1UEChMIQ2VydHBsdXMxGzAZBgNVBAMTEkNsYXNz -IDIgUHJpbWFyeSBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANxQ -ltAS+DXSCHh6tlJw/W/uz7kRy1134ezpfgSN1sxvc0NXYKwzCkTsA18cgCSR5aiR -VhKC9+Ar9NuuYS6JEI1rbLqzAr3VNsVINyPi8Fo3UjMXEuLRYE2+L0ER4/YXJQyL -kcAbmXuZVg2v7tK8R1fjeUl7NIknJITesezpWE7+Tt9avkGtrAjFGA7v0lPubNCd -EgETjdyAYveVqUSISnFOYFWe2yMZeVYHDD9jC1yw4r5+FfyUM1hBOHTE4Y+L3yas -H7WLO7dDWWuwJKZtkIvEcupdM5i3y95ee++U8Rs+yskhwcWYAqqi9lt3m/V+llU0 -HGdpwPFC40es/CgcZlUCAwEAAaOBjDCBiTAPBgNVHRMECDAGAQH/AgEKMAsGA1Ud -DwQEAwIBBjAdBgNVHQ4EFgQU43Mt38sOKAze3bOkynm4jrvoMIkwEQYJYIZIAYb4 -QgEBBAQDAgEGMDcGA1UdHwQwMC4wLKAqoCiGJmh0dHA6Ly93d3cuY2VydHBsdXMu -Y29tL0NSTC9jbGFzczIuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQCnVM+IRBnL39R/ -AN9WM2K191EBkOvDP9GIROkkXe/nFL0gt5o8AP5tn9uQ3Nf0YtaLcF3n5QRIqWh8 -yfFC82x/xXp8HVGIutIKPidd3i1RTtMTZGnkLuPT55sJmabglZvOGtd/vjzOUrMR -FcEPF80Du5wlFbqidon8BvEY0JNLDnyCt6X09l/+7UCmnYR0ObncHoUW2ikbhiMA -ybuJfm6AiB4vFLQDJKgybwOaRywwvlbGp0ICcBvqQNi6BQNwB6SW//1IMwrh3KWB -kJtN3X3n57LNXMhqlfil9o3EXXgIvnsG1knPGTZQIy4I5p4FTUcY1Rbpsda2ENW7 -l7+ijrRU ------END CERTIFICATE----- - # Issuer: CN=DST Root CA X3 O=Digital Signature Trust Co. # Subject: CN=DST Root CA X3 O=Digital Signature Trust Co. # Label: "DST Root CA X3" @@ -1222,36 +1192,6 @@ t0QmwCbAr1UwnjvVNioZBPRcHv/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg== -----END CERTIFICATE----- -# Issuer: CN=Deutsche Telekom Root CA 2 O=Deutsche Telekom AG OU=T-TeleSec Trust Center -# Subject: CN=Deutsche Telekom Root CA 2 O=Deutsche Telekom AG OU=T-TeleSec Trust Center -# Label: "Deutsche Telekom Root CA 2" -# Serial: 38 -# MD5 Fingerprint: 74:01:4a:91:b1:08:c4:58:ce:47:cd:f0:dd:11:53:08 -# SHA1 Fingerprint: 85:a4:08:c0:9c:19:3e:5d:51:58:7d:cd:d6:13:30:fd:8c:de:37:bf -# SHA256 Fingerprint: b6:19:1a:50:d0:c3:97:7f:7d:a9:9b:cd:aa:c8:6a:22:7d:ae:b9:67:9e:c7:0b:a3:b0:c9:d9:22:71:c1:70:d3 ------BEGIN CERTIFICATE----- -MIIDnzCCAoegAwIBAgIBJjANBgkqhkiG9w0BAQUFADBxMQswCQYDVQQGEwJERTEc -MBoGA1UEChMTRGV1dHNjaGUgVGVsZWtvbSBBRzEfMB0GA1UECxMWVC1UZWxlU2Vj -IFRydXN0IENlbnRlcjEjMCEGA1UEAxMaRGV1dHNjaGUgVGVsZWtvbSBSb290IENB -IDIwHhcNOTkwNzA5MTIxMTAwWhcNMTkwNzA5MjM1OTAwWjBxMQswCQYDVQQGEwJE -RTEcMBoGA1UEChMTRGV1dHNjaGUgVGVsZWtvbSBBRzEfMB0GA1UECxMWVC1UZWxl -U2VjIFRydXN0IENlbnRlcjEjMCEGA1UEAxMaRGV1dHNjaGUgVGVsZWtvbSBSb290 -IENBIDIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCrC6M14IspFLEU -ha88EOQ5bzVdSq7d6mGNlUn0b2SjGmBmpKlAIoTZ1KXleJMOaAGtuU1cOs7TuKhC -QN/Po7qCWWqSG6wcmtoIKyUn+WkjR/Hg6yx6m/UTAtB+NHzCnjwAWav12gz1Mjwr -rFDa1sPeg5TKqAyZMg4ISFZbavva4VhYAUlfckE8FQYBjl2tqriTtM2e66foai1S -NNs671x1Udrb8zH57nGYMsRUFUQM+ZtV7a3fGAigo4aKSe5TBY8ZTNXeWHmb0moc -QqvF1afPaA+W5OFhmHZhyJF81j4A4pFQh+GdCuatl9Idxjp9y7zaAzTVjlsB9WoH -txa2bkp/AgMBAAGjQjBAMB0GA1UdDgQWBBQxw3kbuvVT1xfgiXotF2wKsyudMzAP -BgNVHRMECDAGAQH/AgEFMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOC -AQEAlGRZrTlk5ynrE/5aw4sTV8gEJPB0d8Bg42f76Ymmg7+Wgnxu1MM9756Abrsp -tJh6sTtU6zkXR34ajgv8HzFZMQSyzhfzLMdiNlXiItiJVbSYSKpk+tYcNthEeFpa -IzpXl/V6ME+un2pMSyuOoAPjPuCp1NJ70rOo4nI8rZ7/gFnkm0W09juwzTkZmDLl -6iFhkOQxIY40sfcvNUqFENrnijchvllj4PKFiDFT1FQUhXB59C4Gdyd1Lx+4ivn+ -xbrYNuSD7Odlt79jWvNGr4GUN9RBjNYj1h7P9WgbRGOiWrqnNVmh5XAFmw4jV5mU -Cm26OWMohpLzGITY+9HPBVZkVw== ------END CERTIFICATE----- - # Issuer: CN=Cybertrust Global Root O=Cybertrust, Inc # Subject: CN=Cybertrust Global Root O=Cybertrust, Inc # Label: "Cybertrust Global Root" @@ -3495,46 +3435,6 @@ AAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3CekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ 5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su -----END CERTIFICATE----- -# Issuer: CN=Certinomis - Root CA O=Certinomis OU=0002 433998903 -# Subject: CN=Certinomis - Root CA O=Certinomis OU=0002 433998903 -# Label: "Certinomis - Root CA" -# Serial: 1 -# MD5 Fingerprint: 14:0a:fd:8d:a8:28:b5:38:69:db:56:7e:61:22:03:3f -# SHA1 Fingerprint: 9d:70:bb:01:a5:a4:a0:18:11:2e:f7:1c:01:b9:32:c5:34:e7:88:a8 -# SHA256 Fingerprint: 2a:99:f5:bc:11:74:b7:3c:bb:1d:62:08:84:e0:1c:34:e5:1c:cb:39:78:da:12:5f:0e:33:26:88:83:bf:41:58 ------BEGIN CERTIFICATE----- -MIIFkjCCA3qgAwIBAgIBATANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJGUjET -MBEGA1UEChMKQ2VydGlub21pczEXMBUGA1UECxMOMDAwMiA0MzM5OTg5MDMxHTAb -BgNVBAMTFENlcnRpbm9taXMgLSBSb290IENBMB4XDTEzMTAyMTA5MTcxOFoXDTMz -MTAyMTA5MTcxOFowWjELMAkGA1UEBhMCRlIxEzARBgNVBAoTCkNlcnRpbm9taXMx -FzAVBgNVBAsTDjAwMDIgNDMzOTk4OTAzMR0wGwYDVQQDExRDZXJ0aW5vbWlzIC0g -Um9vdCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANTMCQosP5L2 -fxSeC5yaah1AMGT9qt8OHgZbn1CF6s2Nq0Nn3rD6foCWnoR4kkjW4znuzuRZWJfl -LieY6pOod5tK8O90gC3rMB+12ceAnGInkYjwSond3IjmFPnVAy//ldu9n+ws+hQV -WZUKxkd8aRi5pwP5ynapz8dvtF4F/u7BUrJ1Mofs7SlmO/NKFoL21prbcpjp3vDF -TKWrteoB4owuZH9kb/2jJZOLyKIOSY008B/sWEUuNKqEUL3nskoTuLAPrjhdsKkb -5nPJWqHZZkCqqU2mNAKthH6yI8H7KsZn9DS2sJVqM09xRLWtwHkziOC/7aOgFLSc -CbAK42C++PhmiM1b8XcF4LVzbsF9Ri6OSyemzTUK/eVNfaoqoynHWmgE6OXWk6Ri -wsXm9E/G+Z8ajYJJGYrKWUM66A0ywfRMEwNvbqY/kXPLynNvEiCL7sCCeN5LLsJJ -wx3tFvYk9CcbXFcx3FXuqB5vbKziRcxXV4p1VxngtViZSTYxPDMBbRZKzbgqg4SG -m/lg0h9tkQPTYKbVPZrdd5A9NaSfD171UkRpucC63M9933zZxKyGIjK8e2uR73r4 -F2iw4lNVYC2vPsKD2NkJK/DAZNuHi5HMkesE/Xa0lZrmFAYb1TQdvtj/dBxThZng -WVJKYe2InmtJiUZ+IFrZ50rlau7SZRFDAgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIB -BjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTvkUz1pcMw6C8I6tNxIqSSaHh0 -2TAfBgNVHSMEGDAWgBTvkUz1pcMw6C8I6tNxIqSSaHh02TANBgkqhkiG9w0BAQsF -AAOCAgEAfj1U2iJdGlg+O1QnurrMyOMaauo++RLrVl89UM7g6kgmJs95Vn6RHJk/ -0KGRHCwPT5iVWVO90CLYiF2cN/z7ZMF4jIuaYAnq1fohX9B0ZedQxb8uuQsLrbWw -F6YSjNRieOpWauwK0kDDPAUwPk2Ut59KA9N9J0u2/kTO+hkzGm2kQtHdzMjI1xZS -g081lLMSVX3l4kLr5JyTCcBMWwerx20RoFAXlCOotQqSD7J6wWAsOMwaplv/8gzj -qh8c3LigkyfeY+N/IZ865Z764BNqdeuWXGKRlI5nU7aJ+BIJy29SWwNyhlCVCNSN -h4YVH5Uk2KRvms6knZtt0rJ2BobGVgjF6wnaNsIbW0G+YSrjcOa4pvi2WsS9Iff/ -ql+hbHY5ZtbqTFXhADObE5hjyW/QASAJN1LnDE8+zbz1X5YnpyACleAu6AdBBR8V -btaw5BngDwKTACdyxYvRVB9dSsNAl35VpnzBMwQUAR1JIGkLGZOdblgi90AMRgwj -Y/M50n92Uaf0yKHxDHYiI0ZSKS3io0EHVmmY0gUJvGnHWmHNj4FgFU2A3ZDifcRQ -8ow7bkrHxuaAKzyBvBGAFhAn1/DNP3nMcyrDflOR1m749fPH0FFNjkulW+YZFzvW -gQncItzujrnEj1PhZ7szuIgVRs/taTX/dQ1G885x4cVrhkIGuUE= ------END CERTIFICATE----- - # Issuer: CN=OISTE WISeKey Global Root GB CA O=WISeKey OU=OISTE Foundation Endorsed # Subject: CN=OISTE WISeKey Global Root GB CA O=WISeKey OU=OISTE Foundation Endorsed # Label: "OISTE WISeKey Global Root GB CA" From a6bdc7d463eb65d5b19452107bb890f11fd76683 Mon Sep 17 00:00:00 2001 From: dmaclach Date: Sun, 15 Sep 2019 10:50:42 -0700 Subject: [PATCH 1543/1555] Remove -DGTM_USING_XCTEST It is not longer being used in GTMGoogleTestRunner, so no need to define it. --- third_party/objective_c/google_toolbox_for_mac/BUILD | 3 --- 1 file changed, 3 deletions(-) diff --git a/third_party/objective_c/google_toolbox_for_mac/BUILD b/third_party/objective_c/google_toolbox_for_mac/BUILD index dc505f30fc3..9fc517c45eb 100644 --- a/third_party/objective_c/google_toolbox_for_mac/BUILD +++ b/third_party/objective_c/google_toolbox_for_mac/BUILD @@ -21,9 +21,6 @@ native.objc_library( srcs = [ "UnitTesting/GTMGoogleTestRunner.mm", ], - copts = [ - "-DGTM_USING_XCTEST", - ], deps = [ "//external:gtest", ], From c5662bba808569eba9a2b47312a357cb35887b5c Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 16 Sep 2019 13:16:33 +0200 Subject: [PATCH 1544/1555] use bazel 0.29.0 on windows --- tools/internal_ci/windows/bazel_rbe.bat | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat index 86dcc74c429..827952791c9 100644 --- a/tools/internal_ci/windows/bazel_rbe.bat +++ b/tools/internal_ci/windows/bazel_rbe.bat @@ -14,7 +14,8 @@ @rem TODO(jtattermusch): make this generate less output @rem TODO(jtattermusch): use tools/bazel script to keep the versions in sync -choco install bazel -y --version 0.29.1 --limit-output +@rem TODO(jtattermusch): https://github.com/bazelbuild/bazel/issues/9369 prevents upgrade to 0.29.1 +choco install bazel -y --version 0.29.0 --limit-output cd github/grpc set PATH=C:\tools\msys64\usr\bin;C:\Python27;%PATH% From e14212b9a5d29ce54f7ad68a66fa2f8c5f05cc12 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 16 Sep 2019 15:26:32 +0200 Subject: [PATCH 1545/1555] fix windows RBE manual build instructions --- tools/remote_build/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/remote_build/README.md b/tools/remote_build/README.md index 2cd5f03daf1..aa96704f4ca 100644 --- a/tools/remote_build/README.md +++ b/tools/remote_build/README.md @@ -32,7 +32,7 @@ bazel --bazelrc=tools/remote_build/manual.bazelrc test --config=asan //test/... Run on Windows MSVC: ``` # RBE manual run only for c-core (must be run on a Windows host machine) -bazel --bazelrc=tools/remote_build/windows.bazelrc build :all [--credentials_json=(path to service account credentials)] +bazel --bazelrc=tools/remote_build/windows.bazelrc build :all [--google_credentials=(path to service account credentials)] ``` Available command line options can be found in From 4521dea985257deab98f392e420ac73d312201e5 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 16 Sep 2019 15:30:04 +0200 Subject: [PATCH 1546/1555] try bazel 0.29.1 for windows --- tools/internal_ci/windows/bazel_rbe.bat | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat index 827952791c9..86dcc74c429 100644 --- a/tools/internal_ci/windows/bazel_rbe.bat +++ b/tools/internal_ci/windows/bazel_rbe.bat @@ -14,8 +14,7 @@ @rem TODO(jtattermusch): make this generate less output @rem TODO(jtattermusch): use tools/bazel script to keep the versions in sync -@rem TODO(jtattermusch): https://github.com/bazelbuild/bazel/issues/9369 prevents upgrade to 0.29.1 -choco install bazel -y --version 0.29.0 --limit-output +choco install bazel -y --version 0.29.1 --limit-output cd github/grpc set PATH=C:\tools\msys64\usr\bin;C:\Python27;%PATH% From 84f555bfd8aefb1b0e12d14b56949bbfbef78d5f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 16 Sep 2019 16:31:21 +0200 Subject: [PATCH 1547/1555] simplify and unify manual builds --- tools/remote_build/README.md | 2 +- tools/remote_build/manual.bazelrc | 7 +++---- tools/remote_build/windows.bazelrc | 2 ++ 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/remote_build/README.md b/tools/remote_build/README.md index aa96704f4ca..68d68400577 100644 --- a/tools/remote_build/README.md +++ b/tools/remote_build/README.md @@ -32,7 +32,7 @@ bazel --bazelrc=tools/remote_build/manual.bazelrc test --config=asan //test/... Run on Windows MSVC: ``` # RBE manual run only for c-core (must be run on a Windows host machine) -bazel --bazelrc=tools/remote_build/windows.bazelrc build :all [--google_credentials=(path to service account credentials)] +bazel --bazelrc=tools/remote_build/windows.bazelrc build :all ``` Available command line options can be found in diff --git a/tools/remote_build/manual.bazelrc b/tools/remote_build/manual.bazelrc index c3c6af42877..9819a9ffb36 100644 --- a/tools/remote_build/manual.bazelrc +++ b/tools/remote_build/manual.bazelrc @@ -20,11 +20,10 @@ import %workspace%/tools/remote_build/rbe_common.bazelrc build --remote_cache=grpcs://remotebuildexecution.googleapis.com build --remote_executor=grpcs://remotebuildexecution.googleapis.com -# Enable authentication. This will pick up application default credentials by -# default. You can use --auth_credentials=some_file.json to use a service -# account credential instead. +# Enable authentication. Bazel will use application default credentials +# unless overridden by --google_credentials=service_account_credentials.json # How to setup credentials: -# See https://cloud.google.com/remote-build-execution/docs/getting-started#set_credentials +# https://cloud.google.com/remote-build-execution/docs/results-ui/getting-started-results-ui build --auth_enabled=true # Set flags for uploading to BES in order to view results in the Bazel Build diff --git a/tools/remote_build/windows.bazelrc b/tools/remote_build/windows.bazelrc index 825d6765de9..e9b418f9837 100644 --- a/tools/remote_build/windows.bazelrc +++ b/tools/remote_build/windows.bazelrc @@ -3,6 +3,8 @@ startup --host_jvm_args=-Dbazel.DigestFunction=SHA256 build --remote_cache=grpcs://remotebuildexecution.googleapis.com build --remote_executor=grpcs://remotebuildexecution.googleapis.com +build --auth_enabled=true + build --host_crosstool_top=//third_party/toolchains/bazel_0.26.0_rbe_windows:toolchain build --crosstool_top=//third_party/toolchains/bazel_0.26.0_rbe_windows:toolchain build --extra_toolchains=//third_party/toolchains/bazel_0.26.0_rbe_windows:cc-toolchain-x64_windows From dd6e6e3ef7876fad718acea7b11c4ee60da25ca6 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Mon, 16 Sep 2019 14:52:46 -0400 Subject: [PATCH 1548/1555] Introduce GRPC_ARG_TSI_MAX_FRAME_SIZE channel arg. Introduce GRPC_ARG_TSI_MAX_FRAME_SIZE so that users can use larger than 14KiB frame size if they need to. --- include/grpc/impl/codegen/grpc_types.h | 8 ++++ .../lib/http/httpcli_security_connector.cc | 16 +++++--- .../alts/alts_security_connector.cc | 8 ++-- .../fake/fake_security_connector.cc | 10 +++-- .../local/local_security_connector.cc | 8 ++-- .../security_connector/security_connector.cc | 1 + .../security_connector/security_connector.h | 22 +++++++---- .../ssl/ssl_security_connector.cc | 10 +++-- .../tls/spiffe_security_connector.cc | 8 ++-- .../tls/spiffe_security_connector.h | 6 ++- .../security/transport/security_handshaker.cc | 38 +++++++++++++------ .../security/transport/security_handshaker.h | 6 ++- .../frame_protector/alts_frame_protector.cc | 2 +- 13 files changed, 94 insertions(+), 49 deletions(-) diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 8108b853fca..3bedf219dc0 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -267,6 +267,14 @@ typedef struct { grpc_ssl_session_cache*). (use grpc_ssl_session_cache_arg_vtable() to fetch an appropriate pointer arg vtable) */ #define GRPC_SSL_SESSION_CACHE_ARG "grpc.ssl_session_cache" +/** If non-zero, it will determine the maximum frame size used by TSI's frame + * protector. + * + * NOTE: Be aware that using a large "max_frame_size" is memory inefficient + * for non-zerocopy protectors. Also, increasing this value above 1MiB + * can break old binaries that don't support larger than 1MiB frame + * size. */ +#define GRPC_ARG_TSI_MAX_FRAME_SIZE "grpc.tsi.max_frame_size" /** Maximum metadata size, in bytes. Note this limit applies to the max sum of all metadata key-value entries in a batch of headers. */ #define GRPC_ARG_MAX_METADATA_SIZE "grpc.max_metadata_size" diff --git a/src/core/lib/http/httpcli_security_connector.cc b/src/core/lib/http/httpcli_security_connector.cc index 8196019f098..e6750621c2e 100644 --- a/src/core/lib/http/httpcli_security_connector.cc +++ b/src/core/lib/http/httpcli_security_connector.cc @@ -41,7 +41,7 @@ class grpc_httpcli_ssl_channel_security_connector final : public grpc_channel_security_connector { public: - explicit grpc_httpcli_ssl_channel_security_connector(char* secure_peer_name) + grpc_httpcli_ssl_channel_security_connector(char* secure_peer_name) : grpc_channel_security_connector( /*url_scheme=*/nullptr, /*channel_creds=*/nullptr, @@ -66,7 +66,8 @@ class grpc_httpcli_ssl_channel_security_connector final &options, &handshaker_factory_); } - void add_handshakers(grpc_pollset_set* interested_parties, + void add_handshakers(const grpc_channel_args* args, + grpc_pollset_set* interested_parties, grpc_core::HandshakeManager* handshake_mgr) override { tsi_handshaker* handshaker = nullptr; if (handshaker_factory_ != nullptr) { @@ -77,7 +78,8 @@ class grpc_httpcli_ssl_channel_security_connector final tsi_result_to_string(result)); } } - handshake_mgr->Add(grpc_core::SecurityHandshakerCreate(handshaker, this)); + handshake_mgr->Add( + grpc_core::SecurityHandshakerCreate(handshaker, this, args)); } tsi_ssl_client_handshaker_factory* handshaker_factory() const { @@ -132,7 +134,7 @@ class grpc_httpcli_ssl_channel_security_connector final static grpc_core::RefCountedPtr httpcli_ssl_channel_security_connector_create( const char* pem_root_certs, const tsi_ssl_root_certs_store* root_store, - const char* secure_peer_name) { + const char* secure_peer_name, grpc_channel_args* channel_args) { if (secure_peer_name != nullptr && pem_root_certs == nullptr) { gpr_log(GPR_ERROR, "Cannot assert a secure peer name without a trust root."); @@ -192,8 +194,10 @@ static void ssl_handshake(void* arg, grpc_endpoint* tcp, const char* host, c->func = on_done; c->arg = arg; grpc_core::RefCountedPtr sc = - httpcli_ssl_channel_security_connector_create(pem_root_certs, root_store, - host); + httpcli_ssl_channel_security_connector_create( + pem_root_certs, root_store, host, + static_cast(arg)->args); + GPR_ASSERT(sc != nullptr); grpc_arg channel_arg = grpc_security_connector_to_arg(sc.get()); grpc_channel_args args = {1, &channel_arg}; diff --git a/src/core/lib/security/security_connector/alts/alts_security_connector.cc b/src/core/lib/security/security_connector/alts/alts_security_connector.cc index 79908601130..c309958fe5b 100644 --- a/src/core/lib/security/security_connector/alts/alts_security_connector.cc +++ b/src/core/lib/security/security_connector/alts/alts_security_connector.cc @@ -81,7 +81,7 @@ class grpc_alts_channel_security_connector final ~grpc_alts_channel_security_connector() override { gpr_free(target_name_); } void add_handshakers( - grpc_pollset_set* interested_parties, + const grpc_channel_args* args, grpc_pollset_set* interested_parties, grpc_core::HandshakeManager* handshake_manager) override { tsi_handshaker* handshaker = nullptr; const grpc_alts_credentials* creds = @@ -91,7 +91,7 @@ class grpc_alts_channel_security_connector final interested_parties, &handshaker) == TSI_OK); handshake_manager->Add( - grpc_core::SecurityHandshakerCreate(handshaker, this)); + grpc_core::SecurityHandshakerCreate(handshaker, this, args)); } void check_peer(tsi_peer peer, grpc_endpoint* ep, @@ -142,7 +142,7 @@ class grpc_alts_server_security_connector final ~grpc_alts_server_security_connector() override = default; void add_handshakers( - grpc_pollset_set* interested_parties, + const grpc_channel_args* args, grpc_pollset_set* interested_parties, grpc_core::HandshakeManager* handshake_manager) override { tsi_handshaker* handshaker = nullptr; const grpc_alts_server_credentials* creds = @@ -151,7 +151,7 @@ class grpc_alts_server_security_connector final creds->options(), nullptr, creds->handshaker_service_url(), false, interested_parties, &handshaker) == TSI_OK); handshake_manager->Add( - grpc_core::SecurityHandshakerCreate(handshaker, this)); + grpc_core::SecurityHandshakerCreate(handshaker, this, args)); } void check_peer(tsi_peer peer, grpc_endpoint* ep, diff --git a/src/core/lib/security/security_connector/fake/fake_security_connector.cc b/src/core/lib/security/security_connector/fake/fake_security_connector.cc index 940c2ac5ee5..6a010740dff 100644 --- a/src/core/lib/security/security_connector/fake/fake_security_connector.cc +++ b/src/core/lib/security/security_connector/fake/fake_security_connector.cc @@ -96,10 +96,11 @@ class grpc_fake_channel_security_connector final return GPR_ICMP(is_lb_channel_, other->is_lb_channel_); } - void add_handshakers(grpc_pollset_set* interested_parties, + void add_handshakers(const grpc_channel_args* args, + grpc_pollset_set* interested_parties, grpc_core::HandshakeManager* handshake_mgr) override { handshake_mgr->Add(grpc_core::SecurityHandshakerCreate( - tsi_create_fake_handshaker(/*is_client=*/true), this)); + tsi_create_fake_handshaker(/*is_client=*/true), this, args)); } bool check_call_host(grpc_core::StringView host, @@ -271,10 +272,11 @@ class grpc_fake_server_security_connector fake_check_peer(this, peer, auth_context, on_peer_checked); } - void add_handshakers(grpc_pollset_set* interested_parties, + void add_handshakers(const grpc_channel_args* args, + grpc_pollset_set* interested_parties, grpc_core::HandshakeManager* handshake_mgr) override { handshake_mgr->Add(grpc_core::SecurityHandshakerCreate( - tsi_create_fake_handshaker(/*=is_client*/ false), this)); + tsi_create_fake_handshaker(/*=is_client*/ false), this, args)); } int cmp(const grpc_security_connector* other) const override { diff --git a/src/core/lib/security/security_connector/local/local_security_connector.cc b/src/core/lib/security/security_connector/local/local_security_connector.cc index 5b777009d34..0af8e0764d9 100644 --- a/src/core/lib/security/security_connector/local/local_security_connector.cc +++ b/src/core/lib/security/security_connector/local/local_security_connector.cc @@ -129,13 +129,13 @@ class grpc_local_channel_security_connector final ~grpc_local_channel_security_connector() override { gpr_free(target_name_); } void add_handshakers( - grpc_pollset_set* interested_parties, + const grpc_channel_args* args, grpc_pollset_set* interested_parties, grpc_core::HandshakeManager* handshake_manager) override { tsi_handshaker* handshaker = nullptr; GPR_ASSERT(local_tsi_handshaker_create(true /* is_client */, &handshaker) == TSI_OK); handshake_manager->Add( - grpc_core::SecurityHandshakerCreate(handshaker, this)); + grpc_core::SecurityHandshakerCreate(handshaker, this, args)); } int cmp(const grpc_security_connector* other_sc) const override { @@ -187,13 +187,13 @@ class grpc_local_server_security_connector final ~grpc_local_server_security_connector() override = default; void add_handshakers( - grpc_pollset_set* interested_parties, + const grpc_channel_args* args, grpc_pollset_set* interested_parties, grpc_core::HandshakeManager* handshake_manager) override { tsi_handshaker* handshaker = nullptr; GPR_ASSERT(local_tsi_handshaker_create(false /* is_client */, &handshaker) == TSI_OK); handshake_manager->Add( - grpc_core::SecurityHandshakerCreate(handshaker, this)); + grpc_core::SecurityHandshakerCreate(handshaker, this, args)); } void check_peer(tsi_peer peer, grpc_endpoint* ep, diff --git a/src/core/lib/security/security_connector/security_connector.cc b/src/core/lib/security/security_connector/security_connector.cc index 2c7c982e719..3d9b077b633 100644 --- a/src/core/lib/security/security_connector/security_connector.cc +++ b/src/core/lib/security/security_connector/security_connector.cc @@ -53,6 +53,7 @@ grpc_channel_security_connector::grpc_channel_security_connector( : grpc_security_connector(url_scheme), channel_creds_(std::move(channel_creds)), request_metadata_creds_(std::move(request_metadata_creds)) {} + grpc_channel_security_connector::~grpc_channel_security_connector() {} int grpc_security_connector_cmp(const grpc_security_connector* sc, diff --git a/src/core/lib/security/security_connector/security_connector.h b/src/core/lib/security/security_connector/security_connector.h index e5ced44638b..2e573d65dfe 100644 --- a/src/core/lib/security/security_connector/security_connector.h +++ b/src/core/lib/security/security_connector/security_connector.h @@ -91,7 +91,9 @@ class grpc_channel_security_connector : public grpc_security_connector { grpc_channel_security_connector( const char* url_scheme, grpc_core::RefCountedPtr channel_creds, - grpc_core::RefCountedPtr request_metadata_creds); + grpc_core::RefCountedPtr request_metadata_creds + /*, + grpc_channel_args* channel_args = nullptr*/); ~grpc_channel_security_connector() override; /// Checks that the host that will be set for a call is acceptable. @@ -108,9 +110,9 @@ class grpc_channel_security_connector : public grpc_security_connector { virtual void cancel_check_call_host(grpc_closure* on_call_host_checked, grpc_error* error) GRPC_ABSTRACT; /// Registers handshakers with \a handshake_mgr. - virtual void add_handshakers(grpc_pollset_set* interested_parties, - grpc_core::HandshakeManager* handshake_mgr) - GRPC_ABSTRACT; + virtual void add_handshakers( + const grpc_channel_args* args, grpc_pollset_set* interested_parties, + grpc_core::HandshakeManager* handshake_mgr) GRPC_ABSTRACT; const grpc_channel_credentials* channel_creds() const { return channel_creds_.get(); @@ -132,9 +134,15 @@ class grpc_channel_security_connector : public grpc_security_connector { int channel_security_connector_cmp( const grpc_channel_security_connector* other) const; + // grpc_channel_args* channel_args() const { return channel_args_.get(); } + //// Should be called as soon as the channel args are not needed to reduce + //// memory usage. + // void clear_channel_arg() { channel_args_.reset(); } + private: grpc_core::RefCountedPtr channel_creds_; grpc_core::RefCountedPtr request_metadata_creds_; + grpc_core::UniquePtr channel_args_; }; /* --- server_security_connector object. --- @@ -149,9 +157,9 @@ class grpc_server_security_connector : public grpc_security_connector { grpc_core::RefCountedPtr server_creds); ~grpc_server_security_connector() override = default; - virtual void add_handshakers(grpc_pollset_set* interested_parties, - grpc_core::HandshakeManager* handshake_mgr) - GRPC_ABSTRACT; + virtual void add_handshakers( + const grpc_channel_args* args, grpc_pollset_set* interested_parties, + grpc_core::HandshakeManager* handshake_mgr) GRPC_ABSTRACT; const grpc_server_credentials* server_creds() const { return server_creds_.get(); diff --git a/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc b/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc index 97c04cafce4..0318e0aeb62 100644 --- a/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +++ b/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc @@ -116,7 +116,8 @@ class grpc_ssl_channel_security_connector final return GRPC_SECURITY_OK; } - void add_handshakers(grpc_pollset_set* interested_parties, + void add_handshakers(const grpc_channel_args* args, + grpc_pollset_set* interested_parties, grpc_core::HandshakeManager* handshake_mgr) override { // Instantiate TSI handshaker. tsi_handshaker* tsi_hs = nullptr; @@ -131,7 +132,7 @@ class grpc_ssl_channel_security_connector final return; } // Create handshakers. - handshake_mgr->Add(grpc_core::SecurityHandshakerCreate(tsi_hs, this)); + handshake_mgr->Add(grpc_core::SecurityHandshakerCreate(tsi_hs, this, args)); } void check_peer(tsi_peer peer, grpc_endpoint* ep, @@ -278,7 +279,8 @@ class grpc_ssl_server_security_connector return GRPC_SECURITY_OK; } - void add_handshakers(grpc_pollset_set* interested_parties, + void add_handshakers(const grpc_channel_args* args, + grpc_pollset_set* interested_parties, grpc_core::HandshakeManager* handshake_mgr) override { // Instantiate TSI handshaker. try_fetch_ssl_server_credentials(); @@ -291,7 +293,7 @@ class grpc_ssl_server_security_connector return; } // Create handshakers. - handshake_mgr->Add(grpc_core::SecurityHandshakerCreate(tsi_hs, this)); + handshake_mgr->Add(grpc_core::SecurityHandshakerCreate(tsi_hs, this, args)); } void check_peer(tsi_peer peer, grpc_endpoint* ep, diff --git a/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc b/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc index be20b60645b..bac32c08813 100644 --- a/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +++ b/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc @@ -138,7 +138,7 @@ SpiffeChannelSecurityConnector::~SpiffeChannelSecurityConnector() { } void SpiffeChannelSecurityConnector::add_handshakers( - grpc_pollset_set* interested_parties, + const grpc_channel_args* args, grpc_pollset_set* interested_parties, grpc_core::HandshakeManager* handshake_mgr) { if (RefreshHandshakerFactory() != GRPC_SECURITY_OK) { gpr_log(GPR_ERROR, "Handshaker factory refresh failed."); @@ -157,7 +157,7 @@ void SpiffeChannelSecurityConnector::add_handshakers( return; } // Create handshakers. - handshake_mgr->Add(grpc_core::SecurityHandshakerCreate(tsi_hs, this)); + handshake_mgr->Add(grpc_core::SecurityHandshakerCreate(tsi_hs, this, args)); } void SpiffeChannelSecurityConnector::check_peer( @@ -412,7 +412,7 @@ SpiffeServerSecurityConnector::~SpiffeServerSecurityConnector() { } void SpiffeServerSecurityConnector::add_handshakers( - grpc_pollset_set* interested_parties, + const grpc_channel_args* args, grpc_pollset_set* interested_parties, grpc_core::HandshakeManager* handshake_mgr) { /* Refresh handshaker factory if needed. */ if (RefreshHandshakerFactory() != GRPC_SECURITY_OK) { @@ -428,7 +428,7 @@ void SpiffeServerSecurityConnector::add_handshakers( tsi_result_to_string(result)); return; } - handshake_mgr->Add(grpc_core::SecurityHandshakerCreate(tsi_hs, this)); + handshake_mgr->Add(grpc_core::SecurityHandshakerCreate(tsi_hs, this, args)); } void SpiffeServerSecurityConnector::check_peer( diff --git a/src/core/lib/security/security_connector/tls/spiffe_security_connector.h b/src/core/lib/security/security_connector/tls/spiffe_security_connector.h index 3739b463159..8de2bfcd3a4 100644 --- a/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +++ b/src/core/lib/security/security_connector/tls/spiffe_security_connector.h @@ -47,7 +47,8 @@ class SpiffeChannelSecurityConnector final const char* target_name, const char* overridden_target_name); ~SpiffeChannelSecurityConnector() override; - void add_handshakers(grpc_pollset_set* interested_parties, + void add_handshakers(const grpc_channel_args* args, + grpc_pollset_set* interested_parties, grpc_core::HandshakeManager* handshake_mgr) override; void check_peer(tsi_peer peer, grpc_endpoint* ep, @@ -117,7 +118,8 @@ class SpiffeServerSecurityConnector final grpc_core::RefCountedPtr server_creds); ~SpiffeServerSecurityConnector() override; - void add_handshakers(grpc_pollset_set* interested_parties, + void add_handshakers(const grpc_channel_args* args, + grpc_pollset_set* interested_parties, grpc_core::HandshakeManager* handshake_mgr) override; void check_peer(tsi_peer peer, grpc_endpoint* ep, diff --git a/src/core/lib/security/transport/security_handshaker.cc b/src/core/lib/security/transport/security_handshaker.cc index 3ad04774837..1d0b5ec0c6e 100644 --- a/src/core/lib/security/transport/security_handshaker.cc +++ b/src/core/lib/security/transport/security_handshaker.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -46,7 +47,8 @@ namespace { class SecurityHandshaker : public Handshaker { public: SecurityHandshaker(tsi_handshaker* handshaker, - grpc_security_connector* connector); + grpc_security_connector* connector, + const grpc_channel_args* args); ~SecurityHandshaker() override; void Shutdown(grpc_error* why) override; void DoHandshake(grpc_tcp_server_acceptor* acceptor, @@ -97,15 +99,23 @@ class SecurityHandshaker : public Handshaker { grpc_closure on_peer_checked_; RefCountedPtr auth_context_; tsi_handshaker_result* handshaker_result_ = nullptr; + size_t max_frame_size_ = 0; }; SecurityHandshaker::SecurityHandshaker(tsi_handshaker* handshaker, - grpc_security_connector* connector) + grpc_security_connector* connector, + const grpc_channel_args* args) : handshaker_(handshaker), connector_(connector->Ref(DEBUG_LOCATION, "handshake")), handshake_buffer_size_(GRPC_INITIAL_HANDSHAKE_BUFFER_SIZE), handshake_buffer_( static_cast(gpr_malloc(handshake_buffer_size_))) { + const grpc_arg* arg = + grpc_channel_args_find(args, GRPC_ARG_TSI_MAX_FRAME_SIZE); + if (arg != nullptr && arg->type == GRPC_ARG_INTEGER) { + max_frame_size_ = grpc_channel_arg_get_integer( + arg, {0, 0, std::numeric_limits::max()}); + } gpr_mu_init(&mu_); grpc_slice_buffer_init(&outgoing_); GRPC_CLOSURE_INIT(&on_handshake_data_sent_to_peer_, @@ -201,7 +211,8 @@ void SecurityHandshaker::OnPeerCheckedInner(grpc_error* error) { // Create zero-copy frame protector, if implemented. tsi_zero_copy_grpc_protector* zero_copy_protector = nullptr; tsi_result result = tsi_handshaker_result_create_zero_copy_grpc_protector( - handshaker_result_, nullptr, &zero_copy_protector); + handshaker_result_, max_frame_size_ == 0 ? nullptr : &max_frame_size_, + &zero_copy_protector); if (result != TSI_OK && result != TSI_UNIMPLEMENTED) { error = grpc_set_tsi_error_result( GRPC_ERROR_CREATE_FROM_STATIC_STRING( @@ -213,8 +224,9 @@ void SecurityHandshaker::OnPeerCheckedInner(grpc_error* error) { // Create frame protector if zero-copy frame protector is NULL. tsi_frame_protector* protector = nullptr; if (zero_copy_protector == nullptr) { - result = tsi_handshaker_result_create_frame_protector(handshaker_result_, - nullptr, &protector); + result = tsi_handshaker_result_create_frame_protector( + handshaker_result_, max_frame_size_ == 0 ? nullptr : &max_frame_size_, + &protector); if (result != TSI_OK) { error = grpc_set_tsi_error_result(GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Frame protector creation failed"), @@ -459,7 +471,8 @@ class ClientSecurityHandshakerFactory : public HandshakerFactory { reinterpret_cast( grpc_security_connector_find_in_args(args)); if (security_connector) { - security_connector->add_handshakers(interested_parties, handshake_mgr); + security_connector->add_handshakers(args, interested_parties, + handshake_mgr); } } ~ClientSecurityHandshakerFactory() override = default; @@ -474,7 +487,8 @@ class ServerSecurityHandshakerFactory : public HandshakerFactory { reinterpret_cast( grpc_security_connector_find_in_args(args)); if (security_connector) { - security_connector->add_handshakers(interested_parties, handshake_mgr); + security_connector->add_handshakers(args, interested_parties, + handshake_mgr); } } ~ServerSecurityHandshakerFactory() override = default; @@ -487,13 +501,14 @@ class ServerSecurityHandshakerFactory : public HandshakerFactory { // RefCountedPtr SecurityHandshakerCreate( - tsi_handshaker* handshaker, grpc_security_connector* connector) { + tsi_handshaker* handshaker, grpc_security_connector* connector, + const grpc_channel_args* args) { // If no TSI handshaker was created, return a handshaker that always fails. // Otherwise, return a real security handshaker. if (handshaker == nullptr) { return MakeRefCounted(); } else { - return MakeRefCounted(handshaker, connector); + return MakeRefCounted(handshaker, connector, args); } } @@ -509,6 +524,7 @@ void SecurityRegisterHandshakerFactories() { } // namespace grpc_core grpc_handshaker* grpc_security_handshaker_create( - tsi_handshaker* handshaker, grpc_security_connector* connector) { - return SecurityHandshakerCreate(handshaker, connector).release(); + tsi_handshaker* handshaker, grpc_security_connector* connector, + const grpc_channel_args* args) { + return SecurityHandshakerCreate(handshaker, connector, args).release(); } diff --git a/src/core/lib/security/transport/security_handshaker.h b/src/core/lib/security/transport/security_handshaker.h index 263fe555967..a9e1fe83d45 100644 --- a/src/core/lib/security/transport/security_handshaker.h +++ b/src/core/lib/security/transport/security_handshaker.h @@ -28,7 +28,8 @@ namespace grpc_core { /// Creates a security handshaker using \a handshaker. RefCountedPtr SecurityHandshakerCreate( - tsi_handshaker* handshaker, grpc_security_connector* connector); + tsi_handshaker* handshaker, grpc_security_connector* connector, + const grpc_channel_args* args); /// Registers security handshaker factories. void SecurityRegisterHandshakerFactories(); @@ -38,6 +39,7 @@ void SecurityRegisterHandshakerFactories(); // TODO(arjunroy): This is transitional to account for the new handshaker API // and will eventually be removed entirely. grpc_handshaker* grpc_security_handshaker_create( - tsi_handshaker* handshaker, grpc_security_connector* connector); + tsi_handshaker* handshaker, grpc_security_connector* connector, + const grpc_channel_args* args); #endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURITY_HANDSHAKER_H */ diff --git a/src/core/tsi/alts/frame_protector/alts_frame_protector.cc b/src/core/tsi/alts/frame_protector/alts_frame_protector.cc index bfa0b7a720f..b1c6c6155fe 100644 --- a/src/core/tsi/alts/frame_protector/alts_frame_protector.cc +++ b/src/core/tsi/alts/frame_protector/alts_frame_protector.cc @@ -34,7 +34,7 @@ constexpr size_t kMinFrameLength = 1024; constexpr size_t kDefaultFrameLength = 16 * 1024; -constexpr size_t kMaxFrameLength = 1024 * 1024; +constexpr size_t kMaxFrameLength = 16 * 1024 * 1024; // Limit k on number of frames such that at most 2^(8 * k) frames can be sent. constexpr size_t kAltsRecordProtocolRekeyFrameLimit = 8; From 9b9764cb2a42492f2e598a211cad05b1645d8337 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Mon, 16 Sep 2019 15:10:02 -0400 Subject: [PATCH 1549/1555] Fix build error in SSL fuzzer. --- test/core/security/ssl_server_fuzzer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/security/ssl_server_fuzzer.cc b/test/core/security/ssl_server_fuzzer.cc index 5846964eb90..74343c21098 100644 --- a/test/core/security/ssl_server_fuzzer.cc +++ b/test/core/security/ssl_server_fuzzer.cc @@ -91,7 +91,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { state.done_callback_called = false; auto handshake_mgr = grpc_core::MakeRefCounted(); - sc->add_handshakers(nullptr, handshake_mgr.get()); + sc->add_handshakers(nullptr, nullptr, handshake_mgr.get()); handshake_mgr->DoHandshake(mock_endpoint, nullptr /* channel_args */, deadline, nullptr /* acceptor */, on_handshake_done, &state); From 7be5d098cf381f366dd7534c22db89aba2f024f3 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Mon, 16 Sep 2019 13:42:12 -0700 Subject: [PATCH 1550/1555] Tune xds test --- test/cpp/end2end/BUILD | 1 + 1 file changed, 1 insertion(+) diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD index 9153439341f..3ddd6d68c93 100644 --- a/test/cpp/end2end/BUILD +++ b/test/cpp/end2end/BUILD @@ -486,6 +486,7 @@ grpc_cc_test( grpc_cc_test( name = "xds_end2end_test", + timeout = "long", srcs = ["xds_end2end_test.cc"], external_deps = [ "gtest", From f1914fba0002ffbda56eec13b562eebcde084fc3 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 16 Sep 2019 16:11:00 -0700 Subject: [PATCH 1551/1555] Renaming remaining filter functions --- src/core/lib/channel/connected_channel.cc | 40 +++++++++++------------ src/core/lib/surface/server.cc | 24 +++++++------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/core/lib/channel/connected_channel.cc b/src/core/lib/channel/connected_channel.cc index bd30c3663a2..c9c64b8cb33 100644 --- a/src/core/lib/channel/connected_channel.cc +++ b/src/core/lib/channel/connected_channel.cc @@ -97,7 +97,7 @@ static callback_state* get_state_for_batch( /* Intercept a call operation and either push it directly up or translate it into transport stream operations */ -static void con_start_transport_stream_op_batch( +static void connected_channel_start_transport_stream_op_batch( grpc_call_element* elem, grpc_transport_stream_op_batch* batch) { call_data* calld = static_cast(elem->call_data); channel_data* chand = static_cast(elem->channel_data); @@ -137,15 +137,15 @@ static void con_start_transport_stream_op_batch( GRPC_CALL_COMBINER_STOP(calld->call_combiner, "passed batch to transport"); } -static void con_start_transport_op(grpc_channel_element* elem, - grpc_transport_op* op) { +static void connected_channel_start_transport_op(grpc_channel_element* elem, + grpc_transport_op* op) { channel_data* chand = static_cast(elem->channel_data); grpc_transport_perform_op(chand->transport, op); } /* Constructor for call_data */ -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* connected_channel_init_call_elem( + grpc_call_element* elem, const grpc_call_element_args* args) { call_data* calld = static_cast(elem->call_data); channel_data* chand = static_cast(elem->channel_data); calld->call_combiner = args->call_combiner; @@ -166,9 +166,9 @@ static void set_pollset_or_pollset_set(grpc_call_element* elem, } /* Destructor for call_data */ -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* then_schedule_closure) { +static void connected_channel_destroy_call_elem( + grpc_call_element* elem, const grpc_call_final_info* final_info, + grpc_closure* then_schedule_closure) { call_data* calld = static_cast(elem->call_data); channel_data* chand = static_cast(elem->channel_data); grpc_transport_destroy_stream(chand->transport, @@ -177,8 +177,8 @@ static void destroy_call_elem(grpc_call_element* elem, } /* Constructor for channel_data */ -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* connected_channel_init_channel_elem( + grpc_channel_element* elem, grpc_channel_element_args* args) { channel_data* cd = static_cast(elem->channel_data); GPR_ASSERT(args->is_last); cd->transport = nullptr; @@ -186,7 +186,7 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem, } /* Destructor for channel_data */ -static void destroy_channel_elem(grpc_channel_element* elem) { +static void connected_channel_destroy_channel_elem(grpc_channel_element* elem) { channel_data* cd = static_cast(elem->channel_data); if (cd->transport) { grpc_transport_destroy(cd->transport); @@ -194,20 +194,20 @@ static void destroy_channel_elem(grpc_channel_element* elem) { } /* No-op. */ -static void con_get_channel_info(grpc_channel_element* elem, - const grpc_channel_info* channel_info) {} +static void connected_channel_get_channel_info( + grpc_channel_element* elem, const grpc_channel_info* channel_info) {} const grpc_channel_filter grpc_connected_filter = { - con_start_transport_stream_op_batch, - con_start_transport_op, + connected_channel_start_transport_stream_op_batch, + connected_channel_start_transport_op, sizeof(call_data), - init_call_elem, + connected_channel_init_call_elem, set_pollset_or_pollset_set, - destroy_call_elem, + connected_channel_destroy_call_elem, sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, - con_get_channel_info, + connected_channel_init_channel_elem, + connected_channel_destroy_channel_elem, + connected_channel_get_channel_info, "connected", }; diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 2cc7e88cab4..d50dd1d8235 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -905,25 +905,25 @@ static void channel_connectivity_changed(void* cd, grpc_error* error) { } } -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { +static grpc_error* server_init_call_elem(grpc_call_element* elem, + const grpc_call_element_args* args) { channel_data* chand = static_cast(elem->channel_data); server_ref(chand->server); new (elem->call_data) call_data(elem, *args); return GRPC_ERROR_NONE; } -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { +static void server_destroy_call_elem(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) { call_data* calld = static_cast(elem->call_data); calld->~call_data(); channel_data* chand = static_cast(elem->channel_data); server_unref(chand->server); } -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { +static grpc_error* server_init_channel_elem(grpc_channel_element* elem, + grpc_channel_element_args* args) { channel_data* chand = static_cast(elem->channel_data); GPR_ASSERT(args->is_first); GPR_ASSERT(!args->is_last); @@ -938,7 +938,7 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem, return GRPC_ERROR_NONE; } -static void destroy_channel_elem(grpc_channel_element* elem) { +static void server_destroy_channel_elem(grpc_channel_element* elem) { size_t i; channel_data* chand = static_cast(elem->channel_data); if (chand->registered_methods) { @@ -970,12 +970,12 @@ const grpc_channel_filter grpc_server_top_filter = { server_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), - init_call_elem, + server_init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, + server_destroy_call_elem, sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, + server_init_channel_elem, + server_destroy_channel_elem, grpc_channel_next_get_info, "server", }; From fd37378a52c6fe81b6bccb9bf617f25df8aeae4f Mon Sep 17 00:00:00 2001 From: Alex Polcyn Date: Tue, 17 Sep 2019 06:52:58 +0000 Subject: [PATCH 1552/1555] Fix use after free --- .../dns/c_ares/grpc_ares_ev_driver_windows.cc | 58 +++++++++++++++---- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc index addae23dc3e..4d05c05bef5 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc @@ -88,7 +88,7 @@ class WSAErrorContext { * from c-ares and are used with the grpc windows poller, and it, e.g., * manufactures virtual socket error codes when it e.g. needs to tell the c-ares * library to wait for an async read. */ -class GrpcPolledFdWindows : public GrpcPolledFd { +class GrpcPolledFdWindows { public: enum WriteState { WRITE_IDLE, @@ -146,7 +146,7 @@ class GrpcPolledFdWindows : public GrpcPolledFd { write_closure_ = nullptr; } - void RegisterForOnReadableLocked(grpc_closure* read_closure) override { + void RegisterForOnReadableLocked(grpc_closure* read_closure) { GPR_ASSERT(read_closure_ == nullptr); read_closure_ = read_closure; GPR_ASSERT(GRPC_SLICE_LENGTH(read_buf_) == 0); @@ -206,7 +206,7 @@ class GrpcPolledFdWindows : public GrpcPolledFd { grpc_socket_notify_on_read(winsocket_, &outer_read_closure_); } - void RegisterForOnWriteableLocked(grpc_closure* write_closure) override { + void RegisterForOnWriteableLocked(grpc_closure* write_closure) { if (socket_type_ == SOCK_DGRAM) { GRPC_CARES_TRACE_LOG("fd:|%s| RegisterForOnWriteableLocked called", GetName()); @@ -272,19 +272,17 @@ class GrpcPolledFdWindows : public GrpcPolledFd { } } - bool IsFdStillReadableLocked() override { - return GRPC_SLICE_LENGTH(read_buf_) > 0; - } + bool IsFdStillReadableLocked() { return GRPC_SLICE_LENGTH(read_buf_) > 0; } - void ShutdownLocked(grpc_error* error) override { + void ShutdownLocked(grpc_error* error) { grpc_winsocket_shutdown(winsocket_); } - ares_socket_t GetWrappedAresSocketLocked() override { + ares_socket_t GetWrappedAresSocketLocked() { return grpc_winsocket_wrapped_socket(winsocket_); } - const char* GetName() override { return name_; } + const char* GetName() { return name_; } ares_ssize_t RecvFrom(WSAErrorContext* wsa_error_ctx, void* data, ares_socket_t data_len, int flags, @@ -816,14 +814,16 @@ class SockToPolledFdMap { SockToPolledFdMap* map = static_cast(user_data); GrpcPolledFdWindows* polled_fd = map->LookupPolledFd(s); map->RemoveEntry(s); + GRPC_CARES_TRACE_LOG("CloseSocket called for socket: %s", + polled_fd->GetName()); // If a gRPC polled fd has not made it in to the driver's list yet, then // the driver has not and will never see this socket. if (!polled_fd->gotten_into_driver_list()) { polled_fd->ShutdownLocked(GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Shut down c-ares fd before without it ever having made it into the " "driver's list")); - return 0; } + grpc_core::Delete(polled_fd); return 0; } @@ -840,6 +840,42 @@ const struct ares_socket_functions custom_ares_sock_funcs = { &SockToPolledFdMap::SendV /* sendv */, }; +/* A thin wrapper over a GrpcPolledFdWindows object but with a shorter + lifetime. This object releases it's GrpcPolledFdWindows upon destruction, + so that c-ares can close it via usual socket teardown. */ +class GrpcPolledFdWindowsWrapper : public GrpcPolledFd { + public: + GrpcPolledFdWindowsWrapper(GrpcPolledFdWindows* wrapped) + : wrapped_(wrapped) {} + + ~GrpcPolledFdWindowsWrapper() {} + + void RegisterForOnReadableLocked(grpc_closure* read_closure) override { + wrapped_->RegisterForOnReadableLocked(read_closure); + } + + void RegisterForOnWriteableLocked(grpc_closure* write_closure) override { + wrapped_->RegisterForOnWriteableLocked(write_closure); + } + + bool IsFdStillReadableLocked() override { + return wrapped_->IsFdStillReadableLocked(); + } + + void ShutdownLocked(grpc_error* error) override { + wrapped_->ShutdownLocked(error); + } + + ares_socket_t GetWrappedAresSocketLocked() override { + return wrapped_->GetWrappedAresSocketLocked(); + } + + const char* GetName() override { return wrapped_->GetName(); } + + private: + GrpcPolledFdWindows* wrapped_; +}; + class GrpcPolledFdFactoryWindows : public GrpcPolledFdFactory { public: GrpcPolledFdFactoryWindows(grpc_combiner* combiner) @@ -852,7 +888,7 @@ class GrpcPolledFdFactoryWindows : public GrpcPolledFdFactory { // Set a flag so that the virtual socket "close" method knows it // doesn't need to call ShutdownLocked, since now the driver will. polled_fd->set_gotten_into_driver_list(); - return polled_fd; + return grpc_core::New(polled_fd); } void ConfigureAresChannelLocked(ares_channel channel) override { From 88cfae00bedc1badeebf9b617bf8d001c60a53fc Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 13 Sep 2019 08:58:50 -0700 Subject: [PATCH 1553/1555] Build fix for Cocoapods release --- gRPC-Core.podspec | 4 +- gRPC.podspec | 52 +++++++++++++------ .../!ProtoCompiler-gRPCPlugin.podspec | 6 ++- src/objective-c/!ProtoCompiler.podspec | 14 +++-- src/objective-c/BoringSSL-GRPC.podspec | 2 +- templates/gRPC-Core.podspec.template | 4 +- templates/gRPC.podspec.template | 52 +++++++++++++------ ...!ProtoCompiler-gRPCPlugin.podspec.template | 6 ++- .../BoringSSL-GRPC.podspec.template | 2 +- 9 files changed, 99 insertions(+), 43 deletions(-) diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 7c2877f6edc..6c664a8e722 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -32,6 +32,7 @@ Pod::Spec.new do |s| s.source = { :git => 'https://github.com/grpc/grpc.git', :tag => "v#{version}", + :submodules => true, } # gRPC podspecs depend on fix for https://github.com/CocoaPods/CocoaPods/issues/6024, @@ -184,10 +185,9 @@ Pod::Spec.new do |s| ss.header_mappings_dir = '.' ss.libraries = 'z' ss.dependency "#{s.name}/Interface", version - ss.dependency 'BoringSSL-GRPC', '0.0.3' + ss.dependency 'BoringSSL-GRPC', '0.0.4' ss.compiler_flags = '-DGRPC_SHADOW_BORINGSSL_SYMBOLS' - # To save you from scrolling, this is the last part of the podspec. ss.source_files = 'src/core/lib/gpr/alloc.h', 'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/env.h', diff --git a/gRPC.podspec b/gRPC.podspec index 1b36c5ed2ea..e104f2f513c 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -32,11 +32,6 @@ Pod::Spec.new do |s| :tag => "v#{version}", } - s.ios.deployment_target = '7.0' - s.osx.deployment_target = '10.9' - s.tvos.deployment_target = '10.0' - s.watchos.deployment_target = '4.0' - name = 'GRPCClient' s.module_name = name s.header_dir = name @@ -49,25 +44,35 @@ Pod::Spec.new do |s| 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO', } + s.ios.deployment_target = '7.0' + s.osx.deployment_target = '10.9' + s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '4.0' + s.subspec 'Interface-Legacy' do |ss| ss.header_mappings_dir = 'src/objective-c/GRPCClient' - ss.public_header_files = "GRPCClient/GRPCCall+ChannelArg.h", - "GRPCClient/GRPCCall+ChannelCredentials.h", - "GRPCClient/GRPCCall+Cronet.h", - "GRPCClient/GRPCCall+OAuth2.h", - "GRPCClient/GRPCCall+Tests.h", + ss.public_header_files = "src/objective-c/GRPCClient/GRPCCall+ChannelArg.h", + "src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h", + "src/objective-c/GRPCClient/GRPCCall+Cronet.h", + "src/objective-c/GRPCClient/GRPCCall+OAuth2.h", + "src/objective-c/GRPCClient/GRPCCall+Tests.h", "src/objective-c/GRPCClient/GRPCCallLegacy.h", "src/objective-c/GRPCClient/GRPCTypes.h" - ss.source_files = "GRPCClient/GRPCCall+ChannelArg.h", - "GRPCClient/GRPCCall+ChannelCredentials.h", - "GRPCClient/GRPCCall+Cronet.h", - "GRPCClient/GRPCCall+OAuth2.h", - "GRPCClient/GRPCCall+Tests.h", + ss.source_files = "src/objective-c/GRPCClient/GRPCCall+ChannelArg.h", + "src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h", + "src/objective-c/GRPCClient/GRPCCall+Cronet.h", + "src/objective-c/GRPCClient/GRPCCall+OAuth2.h", + "src/objective-c/GRPCClient/GRPCCall+Tests.h", "src/objective-c/GRPCClient/GRPCCallLegacy.h", "src/objective-c/GRPCClient/GRPCTypes.h" ss.dependency "gRPC-RxLibrary/Interface", version + + ss.ios.deployment_target = '7.0' + ss.osx.deployment_target = '10.9' + ss.tvos.deployment_target = '10.0' + ss.watchos.deployment_target = '4.0' end s.subspec 'Interface' do |ss| @@ -98,6 +103,11 @@ Pod::Spec.new do |s| 'src/objective-c/GRPCClient/version.h' ss.dependency "#{s.name}/Interface-Legacy", version + + ss.ios.deployment_target = '7.0' + ss.osx.deployment_target = '10.9' + ss.tvos.deployment_target = '10.0' + ss.watchos.deployment_target = '4.0' end s.subspec 'GRPCCore' do |ss| @@ -131,6 +141,11 @@ Pod::Spec.new do |s| ss.dependency "#{s.name}/Interface", version ss.dependency 'gRPC-Core', version ss.dependency 'gRPC-RxLibrary', version + + ss.ios.deployment_target = '7.0' + ss.osx.deployment_target = '10.9' + ss.tvos.deployment_target = '10.0' + ss.watchos.deployment_target = '4.0' end s.subspec 'GRPCCoreCronet' do |ss| @@ -142,10 +157,17 @@ Pod::Spec.new do |s| ss.dependency "#{s.name}/GRPCCore", version ss.dependency 'gRPC-Core/Cronet-Implementation', version ss.dependency 'CronetFramework' + + ss.ios.deployment_target = '8.0' end # CFStream is now default. Leaving this subspec only for compatibility purpose. s.subspec 'CFStream' do |ss| ss.dependency "#{s.name}/GRPCCore", version + + ss.ios.deployment_target = '7.0' + ss.osx.deployment_target = '10.9' + ss.tvos.deployment_target = '10.0' + ss.watchos.deployment_target = '4.0' end end diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 30a07f1647d..d38d8ca91ef 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -102,7 +102,7 @@ Pod::Spec.new do |s| s.preserve_paths = plugin # Restrict the protoc version to the one supported by this plugin. - s.dependency '!ProtoCompiler', '3.8.0' + s.dependency '!ProtoCompiler', '3.8.1' # For the Protobuf dependency not to complain: s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' @@ -116,6 +116,8 @@ Pod::Spec.new do |s| # present in this pod's directory. We use that knowledge to check for the existence of the file # and, if absent, compile the plugin from the local sources. s.prepare_command = <<-CMD - #{bazel} build //src/compiler:grpc_objective_c_plugin + if [ ! -f #{plugin} ]; then + #{bazel} build //src/compiler:grpc_objective_c_plugin + fi CMD end diff --git a/src/objective-c/!ProtoCompiler.podspec b/src/objective-c/!ProtoCompiler.podspec index 9d036ac0b5b..3d872c8c9cf 100644 --- a/src/objective-c/!ProtoCompiler.podspec +++ b/src/objective-c/!ProtoCompiler.podspec @@ -36,7 +36,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler' - v = '3.8.0' + v = '3.8.1' s.version = v s.summary = 'The Protobuf Compiler (protoc) generates Objective-C files from .proto files' s.description = <<-DESC @@ -99,7 +99,10 @@ Pod::Spec.new do |s| repo = 'google/protobuf' file = "protoc-#{v}-osx-x86_64.zip" s.source = { - :http => "https://github.com/#{repo}/releases/download/v#{v}/#{file}", + # TODO (mxyan): Restore the next line upon next minor version update + # :http => "https://github.com/#{repo}/releases/download/v#{v}/#{file}", + :http => "https://github.com/#{repo}/releases/download/v3.8.0/protoc-3.8.0-osx-x86_64.zip", + # TODO(jcanizales): Add sha1 or sha256 # :sha1 => '??', } @@ -123,6 +126,11 @@ Pod::Spec.new do |s| bazel = "#{repo_root}/tools/bazel" s.prepare_command = <<-CMD - #{bazel} build @com_google_protobuf//:protoc + if [ ! -f bin/protoc ]; then + #{bazel} build @com_google_protobuf//:protoc + else + mv bin/protoc . + mv include/google . + fi CMD end diff --git a/src/objective-c/BoringSSL-GRPC.podspec b/src/objective-c/BoringSSL-GRPC.podspec index f0d9750d6d1..78cd20f3958 100644 --- a/src/objective-c/BoringSSL-GRPC.podspec +++ b/src/objective-c/BoringSSL-GRPC.podspec @@ -39,7 +39,7 @@ Pod::Spec.new do |s| s.name = 'BoringSSL-GRPC' - version = '0.0.3' + version = '0.0.4' s.version = version s.summary = 'BoringSSL is a fork of OpenSSL that is designed to meet Google\'s needs.' # Adapted from the homepage: diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template index 9b77723a854..36b08794b81 100644 --- a/templates/gRPC-Core.podspec.template +++ b/templates/gRPC-Core.podspec.template @@ -85,6 +85,7 @@ s.source = { :git => 'https://github.com/grpc/grpc.git', :tag => "v#{version}", + :submodules => true, } # gRPC podspecs depend on fix for https://github.com/CocoaPods/CocoaPods/issues/6024, @@ -171,10 +172,9 @@ ss.header_mappings_dir = '.' ss.libraries = 'z' ss.dependency "#{s.name}/Interface", version - ss.dependency 'BoringSSL-GRPC', '0.0.3' + ss.dependency 'BoringSSL-GRPC', '0.0.4' ss.compiler_flags = '-DGRPC_SHADOW_BORINGSSL_SYMBOLS' - # To save you from scrolling, this is the last part of the podspec. ss.source_files = ${ruby_multiline_list(grpc_private_files(libs), 22)} ss.private_header_files = ${ruby_multiline_list(grpc_private_headers(libs), 30)} diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index e705edc1748..e8afdb14062 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -34,11 +34,6 @@ :tag => "v#{version}", } - s.ios.deployment_target = '7.0' - s.osx.deployment_target = '10.9' - s.tvos.deployment_target = '10.0' - s.watchos.deployment_target = '4.0' - name = 'GRPCClient' s.module_name = name s.header_dir = name @@ -51,25 +46,35 @@ 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO', } + s.ios.deployment_target = '7.0' + s.osx.deployment_target = '10.9' + s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '4.0' + s.subspec 'Interface-Legacy' do |ss| ss.header_mappings_dir = 'src/objective-c/GRPCClient' - ss.public_header_files = "GRPCClient/GRPCCall+ChannelArg.h", - "GRPCClient/GRPCCall+ChannelCredentials.h", - "GRPCClient/GRPCCall+Cronet.h", - "GRPCClient/GRPCCall+OAuth2.h", - "GRPCClient/GRPCCall+Tests.h", + ss.public_header_files = "src/objective-c/GRPCClient/GRPCCall+ChannelArg.h", + "src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h", + "src/objective-c/GRPCClient/GRPCCall+Cronet.h", + "src/objective-c/GRPCClient/GRPCCall+OAuth2.h", + "src/objective-c/GRPCClient/GRPCCall+Tests.h", "src/objective-c/GRPCClient/GRPCCallLegacy.h", "src/objective-c/GRPCClient/GRPCTypes.h" - ss.source_files = "GRPCClient/GRPCCall+ChannelArg.h", - "GRPCClient/GRPCCall+ChannelCredentials.h", - "GRPCClient/GRPCCall+Cronet.h", - "GRPCClient/GRPCCall+OAuth2.h", - "GRPCClient/GRPCCall+Tests.h", + ss.source_files = "src/objective-c/GRPCClient/GRPCCall+ChannelArg.h", + "src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h", + "src/objective-c/GRPCClient/GRPCCall+Cronet.h", + "src/objective-c/GRPCClient/GRPCCall+OAuth2.h", + "src/objective-c/GRPCClient/GRPCCall+Tests.h", "src/objective-c/GRPCClient/GRPCCallLegacy.h", "src/objective-c/GRPCClient/GRPCTypes.h" ss.dependency "gRPC-RxLibrary/Interface", version + + ss.ios.deployment_target = '7.0' + ss.osx.deployment_target = '10.9' + ss.tvos.deployment_target = '10.0' + ss.watchos.deployment_target = '4.0' end s.subspec 'Interface' do |ss| @@ -100,6 +105,11 @@ 'src/objective-c/GRPCClient/version.h' ss.dependency "#{s.name}/Interface-Legacy", version + + ss.ios.deployment_target = '7.0' + ss.osx.deployment_target = '10.9' + ss.tvos.deployment_target = '10.0' + ss.watchos.deployment_target = '4.0' end s.subspec 'GRPCCore' do |ss| @@ -133,6 +143,11 @@ ss.dependency "#{s.name}/Interface", version ss.dependency 'gRPC-Core', version ss.dependency 'gRPC-RxLibrary', version + + ss.ios.deployment_target = '7.0' + ss.osx.deployment_target = '10.9' + ss.tvos.deployment_target = '10.0' + ss.watchos.deployment_target = '4.0' end s.subspec 'GRPCCoreCronet' do |ss| @@ -144,10 +159,17 @@ ss.dependency "#{s.name}/GRPCCore", version ss.dependency 'gRPC-Core/Cronet-Implementation', version ss.dependency 'CronetFramework' + + ss.ios.deployment_target = '8.0' end # CFStream is now default. Leaving this subspec only for compatibility purpose. s.subspec 'CFStream' do |ss| ss.dependency "#{s.name}/GRPCCore", version + + ss.ios.deployment_target = '7.0' + ss.osx.deployment_target = '10.9' + ss.tvos.deployment_target = '10.0' + ss.watchos.deployment_target = '4.0' end end diff --git a/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template b/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template index 6286e3369e2..9dddfa9f06b 100644 --- a/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template +++ b/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template @@ -104,7 +104,7 @@ s.preserve_paths = plugin # Restrict the protoc version to the one supported by this plugin. - s.dependency '!ProtoCompiler', '3.8.0' + s.dependency '!ProtoCompiler', '3.8.1' # For the Protobuf dependency not to complain: s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' @@ -118,6 +118,8 @@ # present in this pod's directory. We use that knowledge to check for the existence of the file # and, if absent, compile the plugin from the local sources. s.prepare_command = <<-CMD - #{bazel} build //src/compiler:grpc_objective_c_plugin + if [ ! -f #{plugin} ]; then + #{bazel} build //src/compiler:grpc_objective_c_plugin + fi CMD end diff --git a/templates/src/objective-c/BoringSSL-GRPC.podspec.template b/templates/src/objective-c/BoringSSL-GRPC.podspec.template index 3d2736e3307..462283286b6 100644 --- a/templates/src/objective-c/BoringSSL-GRPC.podspec.template +++ b/templates/src/objective-c/BoringSSL-GRPC.podspec.template @@ -44,7 +44,7 @@ Pod::Spec.new do |s| s.name = 'BoringSSL-GRPC' - version = '0.0.3' + version = '0.0.4' s.version = version s.summary = 'BoringSSL is a fork of OpenSSL that is designed to meet Google\'s needs.' # Adapted from the homepage: From 951f3d960388339cd744af16c83a66fb52cf5ef0 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 13 Sep 2019 15:05:26 -0700 Subject: [PATCH 1554/1555] Temporarily disable watchOS support for !ProtoCompiler-gRPCPlugin --- .../!ProtoCompiler-gRPCPlugin.podspec | 9 +++++-- src/objective-c/!ProtoCompiler.podspec | 7 ++---- ...!ProtoCompiler-gRPCPlugin.podspec.template | 9 +++++-- tools/run_tests/run_tests.py | 24 ++++++++++--------- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index d38d8ca91ef..57230e6329c 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -102,12 +102,17 @@ Pod::Spec.new do |s| s.preserve_paths = plugin # Restrict the protoc version to the one supported by this plugin. - s.dependency '!ProtoCompiler', '3.8.1' + s.dependency '!ProtoCompiler', '3.8.0' # For the Protobuf dependency not to complain: s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' s.tvos.deployment_target = '10.0' - s.watchos.deployment_target = '4.0' + + # watchOS is disabled due to #20258. + # TODO (mxyan): Enable watchos when !ProtoCompiler.podspec is updated for + # support of watchos in the next release + # s.watchos.deployment_target = '4.0' + # Restrict the gRPC runtime version to the one supported by this plugin. s.dependency 'gRPC-ProtoRPC', v diff --git a/src/objective-c/!ProtoCompiler.podspec b/src/objective-c/!ProtoCompiler.podspec index 3d872c8c9cf..a3e49f64795 100644 --- a/src/objective-c/!ProtoCompiler.podspec +++ b/src/objective-c/!ProtoCompiler.podspec @@ -36,7 +36,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler' - v = '3.8.1' + v = '3.8.0' s.version = v s.summary = 'The Protobuf Compiler (protoc) generates Objective-C files from .proto files' s.description = <<-DESC @@ -99,10 +99,7 @@ Pod::Spec.new do |s| repo = 'google/protobuf' file = "protoc-#{v}-osx-x86_64.zip" s.source = { - # TODO (mxyan): Restore the next line upon next minor version update - # :http => "https://github.com/#{repo}/releases/download/v#{v}/#{file}", - :http => "https://github.com/#{repo}/releases/download/v3.8.0/protoc-3.8.0-osx-x86_64.zip", - + :http => "https://github.com/#{repo}/releases/download/v#{v}/#{file}", # TODO(jcanizales): Add sha1 or sha256 # :sha1 => '??', } diff --git a/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template b/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template index 9dddfa9f06b..85a4ab07a87 100644 --- a/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template +++ b/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template @@ -104,12 +104,17 @@ s.preserve_paths = plugin # Restrict the protoc version to the one supported by this plugin. - s.dependency '!ProtoCompiler', '3.8.1' + s.dependency '!ProtoCompiler', '3.8.0' # For the Protobuf dependency not to complain: s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' s.tvos.deployment_target = '10.0' - s.watchos.deployment_target = '4.0' + + # watchOS is disabled due to #20258. + # TODO (mxyan): Enable watchos when !ProtoCompiler.podspec is updated for + # support of watchos in the next release + # s.watchos.deployment_target = '4.0' + # Restrict the gRPC runtime version to the one supported by this plugin. s.dependency 'gRPC-ProtoRPC', v diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index a57efb95fe6..a99eb6cc86e 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1132,17 +1132,19 @@ class ObjCLanguage(object): 'EXAMPLE_PATH': 'src/objective-c/examples/tvOS-sample', 'FRAMEWORKS': 'NO' })) - out.append( - self.config.job_spec( - ['src/objective-c/tests/build_one_example_bazel.sh'], - timeout_seconds=20 * 60, - shortname='ios-buildtest-example-watchOS-sample', - cpu_cost=1e6, - environ={ - 'SCHEME': 'watchOS-sample-WatchKit-App', - 'EXAMPLE_PATH': 'src/objective-c/examples/watchOS-sample', - 'FRAMEWORKS': 'NO' - })) + # Disabled due to #20258 + # TODO (mxyan): Reenable this test when #20258 is resolved. + # out.append( + # self.config.job_spec( + # ['src/objective-c/tests/build_one_example_bazel.sh'], + # timeout_seconds=20 * 60, + # shortname='ios-buildtest-example-watchOS-sample', + # cpu_cost=1e6, + # environ={ + # 'SCHEME': 'watchOS-sample-WatchKit-App', + # 'EXAMPLE_PATH': 'src/objective-c/examples/watchOS-sample', + # 'FRAMEWORKS': 'NO' + # })) out.append( self.config.job_spec( ['src/objective-c/tests/run_plugin_tests.sh'], From 1c56cda52660c609c92a00a674541877bdb1a0e2 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Tue, 17 Sep 2019 14:13:22 -0700 Subject: [PATCH 1555/1555] Add comment --- .../resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc index 4d05c05bef5..d72c453d748 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc @@ -814,6 +814,9 @@ class SockToPolledFdMap { SockToPolledFdMap* map = static_cast(user_data); GrpcPolledFdWindows* polled_fd = map->LookupPolledFd(s); map->RemoveEntry(s); + // See https://github.com/grpc/grpc/pull/20284, this trace log is + // intentionally placed to attempt to trigger a crash in case of a + // use after free on polled_fd. GRPC_CARES_TRACE_LOG("CloseSocket called for socket: %s", polled_fd->GetName()); // If a gRPC polled fd has not made it in to the driver's list yet, then